@arcgis/core 4.23.0-next.20220130 → 4.23.0-next.20220131

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 (108) hide show
  1. package/assets/esri/core/workers/RemoteClient.js +1 -1
  2. package/assets/esri/core/workers/chunks/{357033117dfe61eb81ea.js → 0c15d77d8e817cf45a9a.js} +1 -1
  3. package/assets/esri/core/workers/chunks/{e93dfdede0532a89ffa5.js → 2b25fc7945a187c2bb9d.js} +1 -1
  4. package/assets/esri/core/workers/chunks/{7903a3e2e0faff0f86c0.js → 56657f890e0f79f5d2ad.js} +1 -1
  5. package/assets/esri/core/workers/chunks/70d6bb3c7112cb702389.js +1 -0
  6. package/assets/esri/core/workers/chunks/810a763373d7f78ae398.js +1 -0
  7. package/assets/esri/core/workers/chunks/{9d77467aa71d345fc1b6.js → bcc01bbffaa3bb5f60a8.js} +1 -1
  8. package/assets/esri/core/workers/chunks/d98dab12b71912fa397b.js +1 -0
  9. package/assets/esri/core/workers/chunks/{ff6abdc72076f3994659.js → f7150547d7e3259a0f29.js} +1 -1
  10. package/assets/esri/core/workers/chunks/{386f86f961146f530aa7.js → fc046a15466c25d081ff.js} +1 -1
  11. package/assets/esri/images/portal/mediaservice16.png +0 -0
  12. package/assets/esri/widgets/Directions/t9n/Directions.json +1 -1
  13. package/assets/esri/widgets/Directions/t9n/Directions_ar.json +1 -1
  14. package/assets/esri/widgets/Directions/t9n/Directions_bg.json +1 -1
  15. package/assets/esri/widgets/Directions/t9n/Directions_bs.json +1 -1
  16. package/assets/esri/widgets/Directions/t9n/Directions_ca.json +1 -1
  17. package/assets/esri/widgets/Directions/t9n/Directions_cs.json +1 -1
  18. package/assets/esri/widgets/Directions/t9n/Directions_da.json +1 -1
  19. package/assets/esri/widgets/Directions/t9n/Directions_de.json +1 -1
  20. package/assets/esri/widgets/Directions/t9n/Directions_el.json +1 -1
  21. package/assets/esri/widgets/Directions/t9n/Directions_en.json +1 -1
  22. package/assets/esri/widgets/Directions/t9n/Directions_es.json +1 -1
  23. package/assets/esri/widgets/Directions/t9n/Directions_et.json +1 -1
  24. package/assets/esri/widgets/Directions/t9n/Directions_fi.json +1 -1
  25. package/assets/esri/widgets/Directions/t9n/Directions_fr.json +1 -1
  26. package/assets/esri/widgets/Directions/t9n/Directions_he.json +1 -1
  27. package/assets/esri/widgets/Directions/t9n/Directions_hr.json +1 -1
  28. package/assets/esri/widgets/Directions/t9n/Directions_hu.json +1 -1
  29. package/assets/esri/widgets/Directions/t9n/Directions_id.json +1 -1
  30. package/assets/esri/widgets/Directions/t9n/Directions_it.json +1 -1
  31. package/assets/esri/widgets/Directions/t9n/Directions_ja.json +1 -1
  32. package/assets/esri/widgets/Directions/t9n/Directions_ko.json +1 -1
  33. package/assets/esri/widgets/Directions/t9n/Directions_lt.json +1 -1
  34. package/assets/esri/widgets/Directions/t9n/Directions_lv.json +1 -1
  35. package/assets/esri/widgets/Directions/t9n/Directions_nb.json +1 -1
  36. package/assets/esri/widgets/Directions/t9n/Directions_nl.json +1 -1
  37. package/assets/esri/widgets/Directions/t9n/Directions_pl.json +1 -1
  38. package/assets/esri/widgets/Directions/t9n/Directions_pt-BR.json +1 -1
  39. package/assets/esri/widgets/Directions/t9n/Directions_pt-PT.json +1 -1
  40. package/assets/esri/widgets/Directions/t9n/Directions_ro.json +1 -1
  41. package/assets/esri/widgets/Directions/t9n/Directions_ru.json +1 -1
  42. package/assets/esri/widgets/Directions/t9n/Directions_sk.json +1 -1
  43. package/assets/esri/widgets/Directions/t9n/Directions_sl.json +1 -1
  44. package/assets/esri/widgets/Directions/t9n/Directions_sr.json +1 -1
  45. package/assets/esri/widgets/Directions/t9n/Directions_sv.json +1 -1
  46. package/assets/esri/widgets/Directions/t9n/Directions_th.json +1 -1
  47. package/assets/esri/widgets/Directions/t9n/Directions_tr.json +1 -1
  48. package/assets/esri/widgets/Directions/t9n/Directions_uk.json +1 -1
  49. package/assets/esri/widgets/Directions/t9n/Directions_vi.json +1 -1
  50. package/assets/esri/widgets/Directions/t9n/Directions_zh-CN.json +1 -1
  51. package/assets/esri/widgets/Directions/t9n/Directions_zh-HK.json +1 -1
  52. package/assets/esri/widgets/Directions/t9n/Directions_zh-TW.json +1 -1
  53. package/interfaces.d.ts +449 -45
  54. package/layers/RouteLayer.d.ts +4 -0
  55. package/layers/RouteLayer.js +1 -1
  56. package/layers/graphics/controllers/I3SOnDemandController.js +1 -1
  57. package/package.json +1 -1
  58. package/portal/PortalItem.js +1 -1
  59. package/rest/support/DirectionLine.d.ts +4 -0
  60. package/rest/support/DirectionPoint.d.ts +4 -0
  61. package/rest/support/RouteInfo.d.ts +4 -0
  62. package/rest/support/RouteInfo.js +1 -1
  63. package/rest/support/RouteSolveResult.d.ts +4 -0
  64. package/support/revision.js +1 -1
  65. package/views/2d/layers/RouteLayerView2D.js +1 -1
  66. package/views/3d/environment/ChapmanAtmosphere.js +1 -1
  67. package/views/3d/environment/CloudsComposition.js +1 -1
  68. package/views/3d/environment/CloudsGenerator.js +1 -1
  69. package/views/3d/environment/Fog.js +1 -1
  70. package/views/3d/environment/NoiseTextureAtlas.js +1 -1
  71. package/views/3d/environment/PanoramicAtmosphere.js +1 -1
  72. package/views/3d/environment/Precipitation.js +1 -1
  73. package/views/3d/environment/SimpleAtmosphere.js +1 -1
  74. package/views/3d/environment/Stars.js +1 -1
  75. package/views/3d/layers/I3SMeshView3D.js +1 -1
  76. package/views/3d/layers/i3s/I3SCrossfadeHelper.js +1 -1
  77. package/views/3d/layers/i3s/I3SIndex.js +1 -1
  78. package/views/3d/layers/i3s/I3SMaterialUtil.js +1 -1
  79. package/views/3d/layers/i3s/I3SViewportQueries.js +1 -1
  80. package/views/3d/layers/i3s/PointRenderer.js +1 -1
  81. package/views/3d/support/LaserLineRenderer.js +1 -1
  82. package/views/3d/terrain/OverlayRenderer.js +1 -1
  83. package/views/3d/terrain/TerrainRenderer.js +1 -1
  84. package/views/3d/terrain/TileRenderer.js +1 -1
  85. package/views/3d/webgl-engine/core/renderPasses/RenderPass.js +1 -1
  86. package/views/3d/webgl-engine/lib/CompositingHelper.js +1 -1
  87. package/views/3d/webgl-engine/lib/HighlightHelper.js +1 -1
  88. package/views/3d/webgl-engine/lib/RenderingContext.js +1 -1
  89. package/views/3d/webgl-engine/lib/SSAOHelper.js +1 -1
  90. package/views/3d/webgl-engine/lib/ShadowAccumulator.js +1 -1
  91. package/views/3d/webgl-engine/lib/ShadowCastRenderer.js +1 -1
  92. package/views/3d/webgl-engine/lib/ShadowHighlightHelper.js +1 -1
  93. package/views/3d/webgl-engine/lib/SmaaRenderPass.js +1 -1
  94. package/views/3d/webgl-engine/lib/Texture.js +1 -1
  95. package/views/3d/webgl-engine/lib/edgeRendering/EdgeRenderer.js +1 -1
  96. package/views/3d/webgl-engine/lib/lodRendering/LodRenderer.js +1 -1
  97. package/views/3d/webgl-engine/materials/renderers/MergedRenderer.js +1 -1
  98. package/widgets/Directions/DirectionsViewModel.js +1 -1
  99. package/widgets/Directions/support/directionsUtils.js +1 -1
  100. package/widgets/Directions/support/resources.js +1 -1
  101. package/widgets/Directions.js +1 -1
  102. package/assets/esri/core/workers/chunks/c093dff4592832ac0973.js +0 -1
  103. package/assets/esri/core/workers/chunks/fc7e31d87555beb63291.js +0 -1
  104. package/assets/esri/core/workers/chunks/fff6b0338f06dad0c45d.js +0 -1
  105. package/widgets/Directions/support/CostSummary.js +0 -5
  106. package/widgets/Directions/support/RouteSection.js +0 -5
  107. package/widgets/Directions/support/RouteSections.js +0 -5
  108. package/widgets/Directions/support/maneuverUtils.js +0 -5
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.23/esri/copyright.txt for details.
4
4
  */
5
- import{unwrap as e}from"../../../../../core/maybe.js";import t from"../../../../../core/PooledArray.js";import{TransparencyPassType as r}from"../../lib/basicInterfaces.js";import{DataType as s}from"../../../../webgl/enums.js";var a;!function(e){e[e.FrontToBack=0]="FrontToBack",e[e.BackToFront=1]="BackToFront"}(a||(a={}));class i{constructor(e,r,s=a.FrontToBack){this._rctx=e,this._techniqueRepository=r,this._sorting=s,this._draws=new t({initialSize:32,allocator:e=>e||{material:null,geometry:null,geometryRanges:null,bindDrawParams:null,depthSquaredHint:0,indexType:0}}),this._passBoundTechniques=new Set,this._previouslyBoundMaterials=new Map,this._previouslyBoundDraw=new Map}submitDraw(t,r,s,a,i){const n=this._draws.pushNew();n.geometry=r,n.geometryRanges=s,n.material=t,n.bindDrawParams=a,n.depthSquaredHint=i,n.indexType=r.indexed?e(r.vao.indexBuffer).indexType:0}dispatch(e){const t=this._rctx;this._passBoundTechniques.clear(),this._previouslyBoundMaterials.clear(),this._previouslyBoundDraw.clear();let s=null;const a=this._draws.map((t=>t.material.prepareTechnique(this._techniqueRepository,e,t.geometry.parameters))),i=this._draws.length;for(let o=0;o<i;o++){const i=a[o];i===s&&i.configuration.transparencyPassType===r.NONE||(t.useProgram(i.program),i.bindPipelineState(t,e.slot),s=i),this._passBoundTechniques.has(i)||(i.bindPass(e),this._passBoundTechniques.add(i));const d=this._draws.data[o],l=d.geometry;t.bindVAO(l.vao),this._previouslyBoundMaterials.get(i)!==d.material&&(i.bindMaterial(d.material,e),this._previouslyBoundMaterials.set(i,d.material)),this._previouslyBoundDraw.get(i)!==d.bindDrawParams&&(i.bindDraw(d.bindDrawParams),this._previouslyBoundDraw.set(i,d.bindDrawParams));const u=d.geometryRanges,p=u.length;if(0!==d.indexType){const e=n.get(d.indexType);for(let r=0;r<p;r+=2){const s=u[r],a=u[r+1];t.drawElements(l.primitiveType,a,d.indexType,s*e)}}else for(let e=0;e<p;e+=2){const r=u[e],s=u[e+1];t.drawArrays(l.primitiveType,r,s)}}}prepareSubmit(){this._draws.clear()}finishSubmit(){const e=this._sorting===a.FrontToBack?1:-1;this._draws.sort(((t,r)=>{const s=e*(t.depthSquaredHint-r.depthSquaredHint);return 0!==s?s:t.geometry.vao.size-r.geometry.vao.size}))}get count(){return this._draws.length}}const n=new Map;n.set(s.UNSIGNED_BYTE,1),n.set(s.UNSIGNED_SHORT,2),n.set(s.UNSIGNED_INT,4);export{i as RenderPass,a as RenderPassSorting};
5
+ import{unwrap as e}from"../../../../../core/maybe.js";import t from"../../../../../core/PooledArray.js";import{TransparencyPassType as s}from"../../lib/basicInterfaces.js";import{DataType as r}from"../../../../webgl/enums.js";var a;!function(e){e[e.FrontToBack=0]="FrontToBack",e[e.BackToFront=1]="BackToFront"}(a||(a={}));class i{constructor(e,s,r=a.FrontToBack){this._rctx=e,this._techniqueRepository=s,this._sorting=r,this._draws=new t({initialSize:32,allocator:e=>e||{material:null,geometry:null,geometryRanges:null,bindDrawParams:null,depthSquaredHint:0,indexType:0}}),this._passBoundTechniques=new Set,this._previouslyBoundMaterials=new Map,this._previouslyBoundDraw=new Map}submitDraw(t,s,r,a,i){const n=this._draws.pushNew();n.geometry=s,n.geometryRanges=r,n.material=t,n.bindDrawParams=a,n.depthSquaredHint=i,n.indexType=s.indexed?e(s.vao.indexBuffer).indexType:0}dispatch(e){const t=this._rctx;this._passBoundTechniques.clear(),this._previouslyBoundMaterials.clear(),this._previouslyBoundDraw.clear();let r=null;const a=this._draws.map((t=>t.material.prepareTechnique(this._techniqueRepository,e,t.geometry.parameters))),i=this._draws.length;for(let o=0;o<i;o++){const i=a[o];i===r&&i.configuration.transparencyPassType===s.NONE||(t.useTechnique(i,e.slot),r=i),this._passBoundTechniques.has(i)||(i.bindPass(e),this._passBoundTechniques.add(i));const d=this._draws.data[o],l=d.geometry;t.bindVAO(l.vao),this._previouslyBoundMaterials.get(i)!==d.material&&(i.bindMaterial(d.material,e),this._previouslyBoundMaterials.set(i,d.material)),this._previouslyBoundDraw.get(i)!==d.bindDrawParams&&(i.bindDraw(d.bindDrawParams),this._previouslyBoundDraw.set(i,d.bindDrawParams));const u=d.geometryRanges,p=u.length;if(0!==d.indexType){const e=n.get(d.indexType);for(let s=0;s<p;s+=2){const r=u[s],a=u[s+1];t.drawElements(l.primitiveType,a,d.indexType,r*e)}}else for(let e=0;e<p;e+=2){const s=u[e],r=u[e+1];t.drawArrays(l.primitiveType,s,r)}}}prepareSubmit(){this._draws.clear()}finishSubmit(){const e=this._sorting===a.FrontToBack?1:-1;this._draws.sort(((t,s)=>{const r=e*(t.depthSquaredHint-s.depthSquaredHint);return 0!==r?r:t.geometry.vao.size-s.geometry.vao.size}))}get count(){return this._draws.length}}const n=new Map;n.set(r.UNSIGNED_BYTE,1),n.set(r.UNSIGNED_SHORT,2),n.set(r.UNSIGNED_INT,4);export{i as RenderPass,a as RenderPassSorting};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.23/esri/copyright.txt for details.
4
4
  */
5
- import{disposeMaybe as r,isNone as t}from"../../../../core/maybe.js";import{OverlayIndex as e}from"../../terrain/interfaces.js";import{createQuadVAO as o}from"./glUtil3D.js";import{C as s}from"../../../../chunks/Compositing.glsl.js";import{CompositingTechniqueConfiguration as i,AlphaMode as a,CompositingTechnique as n}from"../shaders/CompositingTechnique.js";import{PrimitiveType as c}from"../../../webgl/enums.js";import{vertexCount as p}from"../../../webgl/Util.js";class m{constructor(r,t){this._rctx=r,this._techniqueRepository=t}dispose(){this._vao=r(this._vao)}compositeTransparent(r,t,e,o=1){const i=this._rctx;h.alphaMode=a.Alpha,h.function=s.Transparency,h.hasOpacityFactor=1!==o;const m=this._techniqueRepository.acquire(n,h);i.useProgram(m.program),m.bindPipelineState(i),m.program.bindTexture(r,"colorTexture"),m.program.bindTexture(t,"alphaTexture"),m.program.bindTexture(e,"frontFaceTexture");const u=this._ensureVAO();i.bindVAO(u),i.drawArrays(c.TRIANGLE_STRIP,0,p(u,"geometry")),m.release()}composite(r,t=a.None,o=1,i=s.Standard,m=e.INNER){const u=this._rctx;h.alphaMode=t,h.function=i,h.hasOpacityFactor=1!==o;const l=this._techniqueRepository.acquire(n,h);u.useProgram(l.program),l.bindPipelineState(u),l.program.bindTexture(r,"tex"),h.hasOpacityFactor&&l.program.setUniform1f("opacity",o),i===s.OverlayWithTransparency&&l.program.setUniform1i("overlayIdx",m);const d=this._ensureVAO();u.bindVAO(d),u.drawArrays(c.TRIANGLE_STRIP,0,p(d,"geometry")),l.release()}_ensureVAO(){return t(this._vao)&&(this._vao=o(this._rctx)),this._vao}}const h=new i;export{m as default};
5
+ import{disposeMaybe as e,isNone as t}from"../../../../core/maybe.js";import{OverlayIndex as r}from"../../terrain/interfaces.js";import{createQuadVAO as s}from"./glUtil3D.js";import{C as o}from"../../../../chunks/Compositing.glsl.js";import{CompositingTechniqueConfiguration as i,AlphaMode as a,CompositingTechnique as n}from"../shaders/CompositingTechnique.js";import{PrimitiveType as c}from"../../../webgl/enums.js";import{vertexCount as h}from"../../../webgl/Util.js";class p{constructor(e,t){this._rctx=e,this._techniqueRepository=t}dispose(){this._vao=e(this._vao)}compositeTransparent(e,t,r,s=1){const i=this._rctx;u.alphaMode=a.Alpha,u.function=o.Transparency,u.hasOpacityFactor=1!==s;const p=this._techniqueRepository.acquire(n,u),m=i.useTechnique(p);m.bindTexture(e,"colorTexture"),m.bindTexture(t,"alphaTexture"),m.bindTexture(r,"frontFaceTexture");const l=this._ensureVAO();i.bindVAO(l),i.drawArrays(c.TRIANGLE_STRIP,0,h(l,"geometry")),p.release()}composite(e,t=a.None,s=1,i=o.Standard,p=r.INNER){const m=this._rctx;u.alphaMode=t,u.function=i,u.hasOpacityFactor=1!==s;const l=this._techniqueRepository.acquire(n,u),T=m.useTechnique(l);T.bindTexture(e,"tex"),u.hasOpacityFactor&&T.setUniform1f("opacity",s),i===o.OverlayWithTransparency&&T.setUniform1i("overlayIdx",p);const _=this._ensureVAO();m.bindVAO(_),m.drawArrays(c.TRIANGLE_STRIP,0,h(_,"geometry")),l.release()}_ensureVAO(){return t(this._vao)&&(this._vao=s(this._rctx)),this._vao}}const u=new i;export{p as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.23/esri/copyright.txt for details.
4
4
  */
5
- import{disposeMaybe as e,isSome as i}from"../../../../core/maybe.js";import{c as t}from"../../../../chunks/vec4.js";import{f as r}from"../../../../chunks/vec4f32.js";import{c as o}from"../../../../chunks/vec4f64.js";import a from"../../support/debugFlags.js";import{Default3D as s}from"./DefaultVertexAttributeLocations.js";import{Pos2Tex as l}from"./DefaultVertexBufferLayouts.js";import{createQuadVAO as h}from"./glUtil3D.js";import{H as p}from"../../../../chunks/HighlightComposition.glsl.js";import{HighlightCompositionTechniqueConfiguration as c,HighlightCompositionTechnique as g}from"../shaders/HighlightTechnique.js";import{BufferObject as u}from"../../../webgl/BufferObject.js";import{TargetType as m,DepthStencilTargetType as n,TextureType as d,PixelFormat as b,PixelType as f,TextureSamplingMode as T,TextureWrapMode as v,ClearBufferBit as _,Usage as w,PrimitiveType as O}from"../../../webgl/enums.js";import{FramebufferObject as M}from"../../../webgl/FramebufferObject.js";import{vertexCount as x}from"../../../webgl/Util.js";import{VertexArrayObject as y}from"../../../webgl/VertexArrayObject.js";const R=32;class A{constructor(e,i){this._techniqueRep=e,this._rctx=i,this.viewportToRestore=o(),this.defaultOptions={color:r(1,0,1,1),haloColor:r(1,0,1,1),haloOpacity:1,fillOpacity:.2,haloOpacityOccluded:.25,fillOpacityOccluded:.05,shadowColor:r(1,0,1,1),shadowOpacity:.15,occludedShadowOpacity:.075},this._grid={coverageMipmap:null,vao:null,verticalCellCount:0,horizontalCellCount:0,cellPixelSize:0,mipmapLevels:0,viewportWidth:0,viewportHeight:0}}_assertResources(){if(this.quadVAO)return;this.quadVAO=h(this._rctx);const e={colorTarget:m.TEXTURE,depthStencilTarget:n.NONE,width:0,height:0},i={target:d.TEXTURE_2D,pixelFormat:b.RGBA,dataType:f.UNSIGNED_BYTE,samplingMode:T.LINEAR,wrapMode:v.CLAMP_TO_EDGE,width:0,height:0};this.blur0Fbo=new M(this._rctx,e,i),this.blur1Fbo=new M(this._rctx,e,i);const t=new c;t.highlightStage=p.Blur,t.gridOptimization=!1,this.blurTechnique=this._techniqueRep.acquire(g,t),t.highlightStage=p.Blur,t.gridOptimization=!0,this.blurGridTechnique=this._techniqueRep.acquire(g,t),t.highlightStage=p.Apply,t.gridOptimization=!1,this.applyTechnique=this._techniqueRep.acquire(g,t),t.highlightStage=p.Apply,t.gridOptimization=!0,this.applyGridTechnique=this._techniqueRep.acquire(g,t),t.highlightStage=p.Downsample,t.gridOptimization=!1,this.downsampleTechnique=this._techniqueRep.acquire(g,t)}dispose(){if(this._grid.coverageMipmap)for(let e=1;e<this._grid.coverageMipmap.length;e++)this._grid.coverageMipmap[e].dispose();this._grid.vao&&this._grid.vao.dispose(!0),this.quadVAO&&(this.quadVAO.dispose(!0),this.quadVAO=null),this.blur0Fbo=e(this.blur0Fbo),this.blur1Fbo=e(this.blur1Fbo)}get profilingCallback(){return a.HIGHLIGHTS_PROFILE_TO_CONSOLE?e=>console.log(e):null}setDefaultOptions(e){this.defaultOptions=e}render(e,i,r){const o=e.pixelRatio,s=a.HIGHLIGHTS_GRID_OPTIMIZATION_ENABLED,l=this._rctx;this._assertResources(),t(this.viewportToRestore,e.fullViewport);const h=e.fullWidth,p=e.fullHeight,c=Math.ceil(h/o),g=Math.ceil(p/o);this.blur0Fbo.resize(c,g),this.blur1Fbo.resize(c,g),l.bindVAO(this.quadVAO);let u=null;const m=s?this.blurGridTechnique:this.blurTechnique;m.bindPipelineState(l),l.useProgram(m.program),s?(this._gridUpdateResources(i,R),this._gridComputeMipmap(),u=this._grid.vao,m.program.bindTexture(this._grid.coverageMipmap[this._grid.mipmapLevels].colorTexture,"coverageTex")):u=this.quadVAO,l.bindVAO(u),l.bindFramebuffer(this.blur0Fbo),l.setViewport(0,0,c,g),l.setClearColor(0,0,0,0),l.clear(_.COLOR_BUFFER_BIT),m.program.bindTexture(i.colorTexture,"tex"),m.program.setUniform2f("blurSize",1/c,0),l.drawArrays(m.primitiveType,0,x(u,"geometry")),l.bindFramebuffer(this.blur1Fbo),l.clear(_.COLOR_BUFFER_BIT),m.program.bindTexture(this.blur0Fbo.colorTexture,"tex"),m.program.setUniform2f("blurSize",0,1/g),l.drawArrays(m.primitiveType,0,x(u,"geometry"));const n=s?this.applyGridTechnique:this.applyTechnique;if(l.bindFramebuffer(r),n.bindPipelineState(l),l.setViewport(this.viewportToRestore[0],this.viewportToRestore[1],this.viewportToRestore[2],this.viewportToRestore[3]),l.useProgram(n.program),n.program.bindTexture(this.blur1Fbo.colorTexture,"tex"),n.program.bindTexture(i.colorTexture,"origin"),s){const e=this._grid.coverageMipmap[this._grid.mipmapLevels].colorTexture;n.program.bindTexture(e,"coverageTex")}n.bindApplyPass(this.defaultOptions),l.drawArrays(n.primitiveType,0,x(u,"geometry")),l.bindVAO(null)}_gridUpdateResources(e,i){const t=this._rctx,r=this._grid;let o=!1;if(null===r.coverageMipmap&&(r.coverageMipmap=[e],o=!0),r.viewportWidth===e.width&&r.viewportHeight===e.height||(o=!0,r.viewportWidth=e.width,r.viewportHeight=e.height),r.coverageMipmap[0]=e,r.cellPixelSize!==i&&(r.cellPixelSize=i,o=!0),o){for(let e=1;e<r.coverageMipmap.length;e++)r.coverageMipmap[e].dispose();r.mipmapLevels=Math.ceil(Math.log(r.cellPixelSize)*Math.LOG2E),r.coverageMipmap.length=r.mipmapLevels+1;for(let e=0;e<r.mipmapLevels;e++){const i=r.coverageMipmap[e],o={target:d.TEXTURE_2D,pixelFormat:b.RGB,dataType:f.UNSIGNED_SHORT_5_6_5,samplingMode:T.LINEAR,wrapMode:v.CLAMP_TO_EDGE,width:Math.ceil(i.width/2),height:Math.ceil(i.height/2)},a={colorTarget:m.TEXTURE,depthStencilTarget:n.NONE,width:Math.ceil(i.width/2),height:Math.ceil(i.height/2)};r.coverageMipmap[e+1]=new M(t,a,o)}}const a=Math.ceil(e.height/r.cellPixelSize),h=Math.ceil(e.width/r.cellPixelSize);if(!r.vao||r.verticalCellCount!==a||r.horizontalCellCount!==h){r.verticalCellCount=a,r.horizontalCellCount=h;const e=a+1,i=h+1,o=1/a,p=1/h,c=6,g=4,m=new Float32Array(c*g*e*i);let n=0;for(let t=0;t<e;t++)for(let e=0;e<i;e++)m[n+0]=(e-.5)*p*2-1,m[n+1]=(t-.5)*o*2-1,m[n+2]=e*p,m[n+3]=t*o,m[n+4]=(e+.5)*p*2-1,m[n+5]=(t-.5)*o*2-1,m[n+6]=e*p,m[n+7]=t*o,m[n+8]=(e-.5)*p*2-1,m[n+9]=(t+.5)*o*2-1,m[n+10]=e*p,m[n+11]=t*o,m[n+12]=(e-.5)*p*2-1,m[n+13]=(t+.5)*o*2-1,m[n+14]=e*p,m[n+15]=t*o,m[n+16]=(e+.5)*p*2-1,m[n+17]=(t-.5)*o*2-1,m[n+18]=e*p,m[n+19]=t*o,m[n+20]=(e+.5)*p*2-1,m[n+21]=(t+.5)*o*2-1,m[n+22]=e*p,m[n+23]=t*o,n+=c*g;r.vao&&r.vao.dispose(!0),r.vao=new y(t,s,{geometry:l},{geometry:u.createVertex(t,w.STATIC_DRAW,m)})}}_gridComputeMipmap(){const e=this._rctx,i=this._grid,t=this.downsampleTechnique.program;this.downsampleTechnique.bindPipelineState(e),e.bindVAO(this.quadVAO),e.useProgram(t);for(let r=0;r<i.mipmapLevels;r++){e.bindFramebuffer(i.coverageMipmap[r+1]),t.bindTexture(i.coverageMipmap[r].colorTexture,"tex");const o=i.coverageMipmap[r+1].width,a=i.coverageMipmap[r+1].height;t.setUniform2f("invFramebufferDim",1/o,1/a),e.setViewport(0,0,o,a),e.drawArrays(O.TRIANGLE_STRIP,0,x(this.quadVAO,"geometry"))}}get gpuMemoryUsage(){let e=(i(this.blur0Fbo)?this.blur0Fbo.gpuMemoryUsage:0)+(i(this.blur1Fbo)?this.blur1Fbo.gpuMemoryUsage:0);if(this._grid.coverageMipmap)for(const i of this._grid.coverageMipmap)e+=i.gpuMemoryUsage;return e}get test(){return{coverage:this._grid.coverageMipmap,blur:[this.blur0Fbo,this.blur1Fbo]}}}export{A as default};
5
+ import{disposeMaybe as e,isSome as i}from"../../../../core/maybe.js";import{c as t}from"../../../../chunks/vec4.js";import{f as r}from"../../../../chunks/vec4f32.js";import{c as o}from"../../../../chunks/vec4f64.js";import s from"../../support/debugFlags.js";import{Default3D as a}from"./DefaultVertexAttributeLocations.js";import{Pos2Tex as l}from"./DefaultVertexBufferLayouts.js";import{createQuadVAO as h}from"./glUtil3D.js";import{H as p}from"../../../../chunks/HighlightComposition.glsl.js";import{HighlightCompositionTechniqueConfiguration as c,HighlightCompositionTechnique as u}from"../shaders/HighlightTechnique.js";import{BufferObject as g}from"../../../webgl/BufferObject.js";import{TargetType as n,DepthStencilTargetType as m,TextureType as d,PixelFormat as b,PixelType as T,TextureSamplingMode as f,TextureWrapMode as v,ClearBufferBit as _,Usage as w,PrimitiveType as O}from"../../../webgl/enums.js";import{FramebufferObject as M}from"../../../webgl/FramebufferObject.js";import{vertexCount as x}from"../../../webgl/Util.js";import{VertexArrayObject as y}from"../../../webgl/VertexArrayObject.js";const R=32;class q{constructor(e,i){this._techniqueRep=e,this._rctx=i,this.viewportToRestore=o(),this.defaultOptions={color:r(1,0,1,1),haloColor:r(1,0,1,1),haloOpacity:1,fillOpacity:.2,haloOpacityOccluded:.25,fillOpacityOccluded:.05,shadowColor:r(1,0,1,1),shadowOpacity:.15,occludedShadowOpacity:.075},this._grid={coverageMipmap:null,vao:null,verticalCellCount:0,horizontalCellCount:0,cellPixelSize:0,mipmapLevels:0,viewportWidth:0,viewportHeight:0}}_assertResources(){if(this.quadVAO)return;this.quadVAO=h(this._rctx);const e={colorTarget:n.TEXTURE,depthStencilTarget:m.NONE,width:0,height:0},i={target:d.TEXTURE_2D,pixelFormat:b.RGBA,dataType:T.UNSIGNED_BYTE,samplingMode:f.LINEAR,wrapMode:v.CLAMP_TO_EDGE,width:0,height:0};this.blur0Fbo=new M(this._rctx,e,i),this.blur1Fbo=new M(this._rctx,e,i);const t=new c;t.highlightStage=p.Blur,t.gridOptimization=!1,this.blurTechnique=this._techniqueRep.acquire(u,t),t.highlightStage=p.Blur,t.gridOptimization=!0,this.blurGridTechnique=this._techniqueRep.acquire(u,t),t.highlightStage=p.Apply,t.gridOptimization=!1,this.applyTechnique=this._techniqueRep.acquire(u,t),t.highlightStage=p.Apply,t.gridOptimization=!0,this.applyGridTechnique=this._techniqueRep.acquire(u,t),t.highlightStage=p.Downsample,t.gridOptimization=!1,this.downsampleTechnique=this._techniqueRep.acquire(u,t)}dispose(){if(this._grid.coverageMipmap)for(let e=1;e<this._grid.coverageMipmap.length;e++)this._grid.coverageMipmap[e].dispose();this._grid.vao&&this._grid.vao.dispose(!0),this.quadVAO&&(this.quadVAO.dispose(!0),this.quadVAO=null),this.blur0Fbo=e(this.blur0Fbo),this.blur1Fbo=e(this.blur1Fbo)}get profilingCallback(){return s.HIGHLIGHTS_PROFILE_TO_CONSOLE?e=>console.log(e):null}setDefaultOptions(e){this.defaultOptions=e}render(e,i,r){const o=e.pixelRatio,a=s.HIGHLIGHTS_GRID_OPTIMIZATION_ENABLED,l=this._rctx;this._assertResources(),t(this.viewportToRestore,e.fullViewport);const h=e.fullWidth,p=e.fullHeight,c=Math.ceil(h/o),u=Math.ceil(p/o);this.blur0Fbo.resize(c,u),this.blur1Fbo.resize(c,u),l.bindVAO(this.quadVAO);let g=null;const n=a?this.blurGridTechnique:this.blurTechnique,m=l.useTechnique(n);a?(this._gridUpdateResources(i,R),this._gridComputeMipmap(),g=this._grid.vao,m.bindTexture(this._grid.coverageMipmap[this._grid.mipmapLevels].colorTexture,"coverageTex")):g=this.quadVAO,l.bindVAO(g),l.bindFramebuffer(this.blur0Fbo),l.setViewport(0,0,c,u),l.setClearColor(0,0,0,0),l.clear(_.COLOR_BUFFER_BIT),m.bindTexture(i.colorTexture,"tex"),m.setUniform2f("blurSize",1/c,0),l.drawArrays(n.primitiveType,0,x(g,"geometry")),l.bindFramebuffer(this.blur1Fbo),l.clear(_.COLOR_BUFFER_BIT),m.bindTexture(this.blur0Fbo.colorTexture,"tex"),m.setUniform2f("blurSize",0,1/u),l.drawArrays(n.primitiveType,0,x(g,"geometry")),l.bindFramebuffer(r),l.setViewport(this.viewportToRestore[0],this.viewportToRestore[1],this.viewportToRestore[2],this.viewportToRestore[3]);const d=a?this.applyGridTechnique:this.applyTechnique,b=l.useTechnique(d);if(b.bindTexture(this.blur1Fbo.colorTexture,"tex"),b.bindTexture(i.colorTexture,"origin"),a){const e=this._grid.coverageMipmap[this._grid.mipmapLevels].colorTexture;b.bindTexture(e,"coverageTex")}d.bindApplyPass(this.defaultOptions),l.drawArrays(d.primitiveType,0,x(g,"geometry")),l.bindVAO(null)}_gridUpdateResources(e,i){const t=this._rctx,r=this._grid;let o=!1;if(null===r.coverageMipmap&&(r.coverageMipmap=[e],o=!0),r.viewportWidth===e.width&&r.viewportHeight===e.height||(o=!0,r.viewportWidth=e.width,r.viewportHeight=e.height),r.coverageMipmap[0]=e,r.cellPixelSize!==i&&(r.cellPixelSize=i,o=!0),o){for(let e=1;e<r.coverageMipmap.length;e++)r.coverageMipmap[e].dispose();r.mipmapLevels=Math.ceil(Math.log(r.cellPixelSize)*Math.LOG2E),r.coverageMipmap.length=r.mipmapLevels+1;for(let e=0;e<r.mipmapLevels;e++){const i=r.coverageMipmap[e],o={target:d.TEXTURE_2D,pixelFormat:b.RGB,dataType:T.UNSIGNED_SHORT_5_6_5,samplingMode:f.LINEAR,wrapMode:v.CLAMP_TO_EDGE,width:Math.ceil(i.width/2),height:Math.ceil(i.height/2)},s={colorTarget:n.TEXTURE,depthStencilTarget:m.NONE,width:Math.ceil(i.width/2),height:Math.ceil(i.height/2)};r.coverageMipmap[e+1]=new M(t,s,o)}}const s=Math.ceil(e.height/r.cellPixelSize),h=Math.ceil(e.width/r.cellPixelSize);if(!r.vao||r.verticalCellCount!==s||r.horizontalCellCount!==h){r.verticalCellCount=s,r.horizontalCellCount=h;const e=s+1,i=h+1,o=1/s,p=1/h,c=6,u=4,n=new Float32Array(c*u*e*i);let m=0;for(let t=0;t<e;t++)for(let e=0;e<i;e++)n[m+0]=(e-.5)*p*2-1,n[m+1]=(t-.5)*o*2-1,n[m+2]=e*p,n[m+3]=t*o,n[m+4]=(e+.5)*p*2-1,n[m+5]=(t-.5)*o*2-1,n[m+6]=e*p,n[m+7]=t*o,n[m+8]=(e-.5)*p*2-1,n[m+9]=(t+.5)*o*2-1,n[m+10]=e*p,n[m+11]=t*o,n[m+12]=(e-.5)*p*2-1,n[m+13]=(t+.5)*o*2-1,n[m+14]=e*p,n[m+15]=t*o,n[m+16]=(e+.5)*p*2-1,n[m+17]=(t-.5)*o*2-1,n[m+18]=e*p,n[m+19]=t*o,n[m+20]=(e+.5)*p*2-1,n[m+21]=(t+.5)*o*2-1,n[m+22]=e*p,n[m+23]=t*o,m+=c*u;r.vao&&r.vao.dispose(!0),r.vao=new y(t,a,{geometry:l},{geometry:g.createVertex(t,w.STATIC_DRAW,n)})}}_gridComputeMipmap(){const e=this._rctx,i=this._grid,t=e.useTechnique(this.downsampleTechnique);e.bindVAO(this.quadVAO);for(let r=0;r<i.mipmapLevels;r++){e.bindFramebuffer(i.coverageMipmap[r+1]),t.bindTexture(i.coverageMipmap[r].colorTexture,"tex");const o=i.coverageMipmap[r+1].width,s=i.coverageMipmap[r+1].height;t.setUniform2f("invFramebufferDim",1/o,1/s),e.setViewport(0,0,o,s),e.drawArrays(O.TRIANGLE_STRIP,0,x(this.quadVAO,"geometry"))}}get gpuMemoryUsage(){let e=(i(this.blur0Fbo)?this.blur0Fbo.gpuMemoryUsage:0)+(i(this.blur1Fbo)?this.blur1Fbo.gpuMemoryUsage:0);if(this._grid.coverageMipmap)for(const i of this._grid.coverageMipmap)e+=i.gpuMemoryUsage;return e}get test(){return{coverage:this._grid.coverageMipmap,blur:[this.blur0Fbo,this.blur1Fbo]}}}export{q as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.23/esri/copyright.txt for details.
4
4
  */
5
- import{RenderingContext as e}from"../../../webgl/RenderingContext.js";class t extends e{constructor(e,t,s){super(e,t),this.newCache=s,this._refCount=1}dispose(){--this._refCount>0||super.dispose()}ref(){++this._refCount}get test(){return this.programCache.test}}export{t as RenderingContext};
5
+ import{RenderingContext as e}from"../../../webgl/RenderingContext.js";class t extends e{constructor(e,t,r){super(e,t),this.newCache=r,this._refCount=1}dispose(){--this._refCount>0||super.dispose()}ref(){++this._refCount}useTechnique(e,t=null,r){return this.useProgram(e.program),e.bindPipelineState(this,t,r),e.program}get test(){return this.programCache.test}}export{t as RenderingContext};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.23/esri/copyright.txt for details.
4
4
  */
5
- import{disposeMaybe as e,applySome as t,isSome as s,isNone as i}from"../../../../core/maybe.js";import{a as r}from"../../../../chunks/vec2f64.js";import{i as h}from"../../../../chunks/vec3.js";import{c as o}from"../../../../chunks/vec4f64.js";import{requestImage as a}from"../../../../support/requestImageUtils.js";import{createQuadVAO as n}from"./glUtil3D.js";import{SSAOTechniqueConfiguration as u,SSAOTechnique as l}from"./SSAOTechnique.js";import{inverseProjectionInfo as _}from"./Util.js";import{S as b}from"../../../../chunks/SSAO.glsl.js";import{PrimitiveType as m,TextureType as d,PixelFormat as f,PixelType as c,TextureSamplingMode as p,TextureWrapMode as O,TargetType as T,DepthStencilTargetType as F}from"../../../webgl/enums.js";import{FramebufferObject as x}from"../../../webgl/FramebufferObject.js";import{Texture as B}from"../../../webgl/Texture.js";import{vertexCount as g}from"../../../webgl/Util.js";class S{constructor(e,t,s){this._techniqueRep=e,this._rctx=t,this._requestRender=s,this._enabled=!1,this._ssaoTechniqueConfig=new u,this.quadVAO=null,this._blurSizePx=2,this._attenuation=.5}dispose(){this.quadVAO=e(this.quadVAO)}disposeOffscreenBuffers(){t(this._ssaoFBO,(e=>e.resize(0,0))),t(this._blur0FBO,(e=>e.resize(0,0))),t(this._blur1FBO,(e=>e.resize(0,0)))}set enabled(e){e?this._enable():this._disable()}get enabled(){return this._enabled}get ready(){return this.enabled&&s(this._noiseTexture)&&s(this._ssaoFBO)&&s(this._blur0FBO)&&s(this._blur1FBO)}computeSSAO(e,t,s){if(!this.enabled||i(t)||i(s)||i(this._noiseTexture)||i(this._ssaoFBO)||i(this._blur0FBO)||i(this._blur1FBO))return;const r=this._rctx,o=e.fullViewport,a=o[2],u=o[3],l=a/this._blurSizePx,b=u/this._blurSizePx;this._ssaoFBO.resize(a,u),this._blur0FBO.resize(l,b),this._blur1FBO.resize(l,b);const d=1,f=1,c=a*d,p=u*f;r.bindFramebuffer(this._ssaoFBO),r.setViewport(0,0,a,u);const O=this._ssaoTechnique.program;r.useProgram(O),this._ssaoTechnique.bindPipelineState(r),O.setUniform2f("rnmScale",a/this._noiseTexture.descriptor.width,u/this._noiseTexture.descriptor.height),_(e.projectionMatrix,e.fullWidth,e.fullHeight,q,A),O.setUniform4fv("projInfo",q),O.setUniform2fv("zScale",A),O.setUniform2fv("nearFar",e.nearFar);let T=1/e.computeRenderPixelSizeAtDist(1);O.setUniform1f("projScale",T*d),O.setUniform2f("screenDimensions",c,p);const F=h(e.eye,e.center);let x=20*e.computeRenderPixelSizeAtDist(F);x=Math.max(.1,x),O.setUniform1f("radius",x),O.setUniform1f("intensity",4*this._attenuation/x**6),O.bindTexture(this._noiseTexture,"rnm"),O.bindTexture(s,"normalMap"),O.bindTexture(t,"depthMap"),i(this.quadVAO)&&(this.quadVAO=n(this._rctx)),r.bindVAO(this.quadVAO),r.drawArrays(m.TRIANGLE_STRIP,0,g(this.quadVAO,"geometry"));const B=this._blurTechnique.program;r.useProgram(B),B.bindTexture(this._ssaoFBO.colorTexture,"tex"),B.bindTexture(s,"normalMap"),B.bindTexture(t,"depthMap"),r.setViewport(0,0,c/this._blurSizePx,p/this._blurSizePx),r.bindFramebuffer(this._blur0FBO),B.setUniform2f("screenDimensions",c,p),B.setUniform2f("blurSize",0,this._blurSizePx*d/p),B.setUniform2fv("nearFar",e.nearFar),F>5e4&&(T=Math.max(0,T-(F-5e4))),B.setUniform1f("projScale",T),r.drawArrays(m.TRIANGLE_STRIP,0,g(this.quadVAO,"geometry")),B.setUniform2f("blurSize",this._blurSizePx*f/c,0),r.bindFramebuffer(this._blur1FBO),B.bindTexture(this._blur0FBO.colorTexture,"tex"),r.drawArrays(m.TRIANGLE_STRIP,0,g(this.quadVAO,"geometry")),r.setViewport(o[0],o[1],o[2],o[3])}bind(e,t){this.enabled&&s(this._blur1FBO)&&s(this._ssaoFBO)?(e.bindTexture(this._blur1FBO.colorTexture,"ssaoTex"),e.setUniform4f("viewportPixelSz",t.fullViewport[0],t.fullViewport[1],1/this._ssaoFBO.width,1/this._ssaoFBO.height)):e.setUniform4f("viewportPixelSz",-1,-1,-1,-1)}_selectPrograms(){this._ssaoTechniqueConfig.output=b.SSAO,this._ssaoTechnique=this._techniqueRep.releaseAndAcquire(l,this._ssaoTechniqueConfig,this._ssaoTechnique),this._ssaoTechniqueConfig.output=b.Blur,this._blurTechnique=this._techniqueRep.releaseAndAcquire(l,this._ssaoTechniqueConfig,this._blurTechnique)}_enable(){this.enabled||(this._enabled=!0,this._loadResources((()=>{this._enabled&&this._initialize()})))}_loadResources(e){this._data?e():import("./SSAOHelperData.js").then((t=>{this._data=t,e()}))}_initialize(){const e={target:d.TEXTURE_2D,pixelFormat:f.RGBA,dataType:c.UNSIGNED_BYTE,samplingMode:p.LINEAR,wrapMode:O.CLAMP_TO_EDGE,width:0,height:0},t={colorTarget:T.TEXTURE,depthStencilTarget:F.NONE};a(this._data.noiseTexture).then((s=>{this._enabled&&(this._ssaoFBO=new x(this._rctx,t,e),this._blur0FBO=new x(this._rctx,t,e),this._blur1FBO=new x(this._rctx,t,e),this._noiseTexture=new B(this._rctx,{target:d.TEXTURE_2D,pixelFormat:f.RGBA,dataType:c.UNSIGNED_BYTE,hasMipmap:!0,width:s.width,height:s.height},s),this._requestRender())})),this._selectPrograms()}_disable(){this._enabled=!1,this._noiseTexture=e(this._noiseTexture),this._blur1FBO=e(this._blur1FBO),this._blur0FBO=e(this._blur0FBO),this._ssaoFBO=e(this._ssaoFBO)}get gpuMemoryUsage(){return(s(this._blur0FBO)?this._blur0FBO.gpuMemoryUsage:0)+(s(this._blur1FBO)?this._blur1FBO.gpuMemoryUsage:0)+(s(this._ssaoFBO)?this._ssaoFBO.gpuMemoryUsage:0)}get test(){return{ssao:this._ssaoFBO,blur:this._blur1FBO}}}const A=r(),q=o();export{S as SSAOHelper};
5
+ import{disposeMaybe as e,applySome as t,isSome as s,isNone as i}from"../../../../core/maybe.js";import{a as r}from"../../../../chunks/vec2f64.js";import{i as h}from"../../../../chunks/vec3.js";import{c as o}from"../../../../chunks/vec4f64.js";import{requestImage as n}from"../../../../support/requestImageUtils.js";import{createQuadVAO as a}from"./glUtil3D.js";import{SSAOTechniqueConfiguration as u,SSAOTechnique as l}from"./SSAOTechnique.js";import{inverseProjectionInfo as _}from"./Util.js";import{S as b}from"../../../../chunks/SSAO.glsl.js";import{PrimitiveType as m,TextureType as c,PixelFormat as d,PixelType as f,TextureSamplingMode as p,TextureWrapMode as O,TargetType as T,DepthStencilTargetType as F}from"../../../webgl/enums.js";import{FramebufferObject as x}from"../../../webgl/FramebufferObject.js";import{Texture as B}from"../../../webgl/Texture.js";import{vertexCount as g}from"../../../webgl/Util.js";class S{constructor(e,t,s){this._techniqueRep=e,this._rctx=t,this._requestRender=s,this._enabled=!1,this._ssaoTechniqueConfig=new u,this.quadVAO=null,this._blurSizePx=2,this._attenuation=.5}dispose(){this.quadVAO=e(this.quadVAO)}disposeOffscreenBuffers(){t(this._ssaoFBO,(e=>e.resize(0,0))),t(this._blur0FBO,(e=>e.resize(0,0))),t(this._blur1FBO,(e=>e.resize(0,0)))}set enabled(e){e?this._enable():this._disable()}get enabled(){return this._enabled}get ready(){return this.enabled&&s(this._noiseTexture)&&s(this._ssaoFBO)&&s(this._blur0FBO)&&s(this._blur1FBO)}computeSSAO(e,t,s){if(!this.enabled||i(t)||i(s)||i(this._noiseTexture)||i(this._ssaoFBO)||i(this._blur0FBO)||i(this._blur1FBO))return;const r=this._rctx,o=e.fullViewport,n=o[2],u=o[3],l=n/this._blurSizePx,b=u/this._blurSizePx;this._ssaoFBO.resize(n,u),this._blur0FBO.resize(l,b),this._blur1FBO.resize(l,b);const c=1,d=1,f=n*c,p=u*d;r.bindFramebuffer(this._ssaoFBO),r.setViewport(0,0,n,u);const O=r.useTechnique(this._ssaoTechnique);O.setUniform2f("rnmScale",n/this._noiseTexture.descriptor.width,u/this._noiseTexture.descriptor.height),_(e.projectionMatrix,e.fullWidth,e.fullHeight,A,q),O.setUniform4fv("projInfo",A),O.setUniform2fv("zScale",q),O.setUniform2fv("nearFar",e.nearFar);let T=1/e.computeRenderPixelSizeAtDist(1);O.setUniform1f("projScale",T*c),O.setUniform2f("screenDimensions",f,p);const F=h(e.eye,e.center);let x=20*e.computeRenderPixelSizeAtDist(F);x=Math.max(.1,x),O.setUniform1f("radius",x),O.setUniform1f("intensity",4*this._attenuation/x**6),O.bindTexture(this._noiseTexture,"rnm"),O.bindTexture(s,"normalMap"),O.bindTexture(t,"depthMap"),i(this.quadVAO)&&(this.quadVAO=a(this._rctx)),r.bindVAO(this.quadVAO),r.drawArrays(m.TRIANGLE_STRIP,0,g(this.quadVAO,"geometry"));const B=r.useTechnique(this._blurTechnique);B.bindTexture(this._ssaoFBO.colorTexture,"tex"),B.bindTexture(s,"normalMap"),B.bindTexture(t,"depthMap"),r.setViewport(0,0,f/this._blurSizePx,p/this._blurSizePx),r.bindFramebuffer(this._blur0FBO),B.setUniform2f("screenDimensions",f,p),B.setUniform2f("blurSize",0,this._blurSizePx*c/p),B.setUniform2fv("nearFar",e.nearFar),F>5e4&&(T=Math.max(0,T-(F-5e4))),B.setUniform1f("projScale",T),r.drawArrays(m.TRIANGLE_STRIP,0,g(this.quadVAO,"geometry")),B.setUniform2f("blurSize",this._blurSizePx*d/f,0),r.bindFramebuffer(this._blur1FBO),B.bindTexture(this._blur0FBO.colorTexture,"tex"),r.drawArrays(m.TRIANGLE_STRIP,0,g(this.quadVAO,"geometry")),r.setViewport(o[0],o[1],o[2],o[3])}bind(e,t){this.enabled&&s(this._blur1FBO)&&s(this._ssaoFBO)?(e.bindTexture(this._blur1FBO.colorTexture,"ssaoTex"),e.setUniform4f("viewportPixelSz",t.fullViewport[0],t.fullViewport[1],1/this._ssaoFBO.width,1/this._ssaoFBO.height)):e.setUniform4f("viewportPixelSz",-1,-1,-1,-1)}_selectPrograms(){this._ssaoTechniqueConfig.output=b.SSAO,this._ssaoTechnique=this._techniqueRep.releaseAndAcquire(l,this._ssaoTechniqueConfig,this._ssaoTechnique),this._ssaoTechniqueConfig.output=b.Blur,this._blurTechnique=this._techniqueRep.releaseAndAcquire(l,this._ssaoTechniqueConfig,this._blurTechnique)}_enable(){this.enabled||(this._enabled=!0,this._loadResources((()=>{this._enabled&&this._initialize()})))}_loadResources(e){this._data?e():import("./SSAOHelperData.js").then((t=>{this._data=t,e()}))}_initialize(){const e={target:c.TEXTURE_2D,pixelFormat:d.RGBA,dataType:f.UNSIGNED_BYTE,samplingMode:p.LINEAR,wrapMode:O.CLAMP_TO_EDGE,width:0,height:0},t={colorTarget:T.TEXTURE,depthStencilTarget:F.NONE};n(this._data.noiseTexture).then((s=>{this._enabled&&(this._ssaoFBO=new x(this._rctx,t,e),this._blur0FBO=new x(this._rctx,t,e),this._blur1FBO=new x(this._rctx,t,e),this._noiseTexture=new B(this._rctx,{target:c.TEXTURE_2D,pixelFormat:d.RGBA,dataType:f.UNSIGNED_BYTE,hasMipmap:!0,width:s.width,height:s.height},s),this._requestRender())})),this._selectPrograms()}_disable(){this._enabled=!1,this._noiseTexture=e(this._noiseTexture),this._blur1FBO=e(this._blur1FBO),this._blur0FBO=e(this._blur0FBO),this._ssaoFBO=e(this._ssaoFBO)}get gpuMemoryUsage(){return(s(this._blur0FBO)?this._blur0FBO.gpuMemoryUsage:0)+(s(this._blur1FBO)?this._blur1FBO.gpuMemoryUsage:0)+(s(this._ssaoFBO)?this._ssaoFBO.gpuMemoryUsage:0)}get test(){return{ssao:this._ssaoFBO,blur:this._blur1FBO}}}const q=r(),A=o();export{S as SSAOHelper};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.23/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../../chunks/tslib.es6.js";import t from"../../../../core/Accessor.js";import{equals as i}from"../../../../core/arrayUtils.js";import s from"../../../../core/Handles.js";import{smoothstep as r}from"../../../../core/mathUtils.js";import{isNone as a,disposeMaybe as o}from"../../../../core/maybe.js";import{watch as n,syncAndInitial as h}from"../../../../core/reactiveUtils.js";import{property as c}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/has.js";import"../../../../core/accessorSupport/ensureType.js";import{subclass as _}from"../../../../core/accessorSupport/decorators/subclass.js";import{j as u,a as l}from"../../../../chunks/mat4.js";import{c as m}from"../../../../chunks/mat4f64.js";import{a as p}from"../../../../chunks/vec2f64.js";import{y as d,g}from"../../../../chunks/vec3.js";import{c as f}from"../../../../chunks/vec3f64.js";import{c as w}from"../../../../chunks/vec4f64.js";import v from"./Camera.js";import{ZERO as b}from"./depthRange.js";import{createQuadVAO as S}from"./glUtil3D.js";import{ShadowCastRenderer as j,shadowCastDisabledElevationThreshold as y,shadowCastDisableElevationMax as A,shadowCastDisableElevationMin as C}from"./ShadowCastRenderer.js";import R from"./ShadowMap.js";import{inverseProjectionInfo as T}from"./Util.js";import{S as D,s as F}from"../../../../chunks/ShadowCast.glsl.js";import{ShadowCastTechniqueConfiguration as E,ShadowCastTechnique as x}from"../shaders/ShadowCastTechnique.js";import{TaskPriority as M}from"../../../support/Scheduler.js";import{TargetType as P,DepthStencilTargetType as q,TextureType as U,PixelFormat as V,PixelType as I,TextureSamplingMode as k,TextureWrapMode as L,ClearBufferBit as O}from"../../../webgl/enums.js";import{FramebufferObject as N}from"../../../webgl/FramebufferObject.js";import{vertexCount as z}from"../../../webgl/Util.js";var B;let H=B=class extends t{constructor(e,t,i,r,o,c){super({}),this._rctx=e,this._stage=i,this._prepareForShadowMapPass=r,this._renderToShadowMap=o,this._requestRender=c,this._progress=0,this._sampleCount=0,this._cachedCamera=new v,this._contentCamera=new v,this._enabled=!1,this._cachedLightDirections=[],this._depthRange=b,this._previewing=!1,this._handles=new s,this._cameraForcedForScreenshot=!1,this._shadowMap=new R(e,i.viewingMode),this._shadowMap.enabled=!0,this._vao=S(e);const _={colorTarget:P.TEXTURE,depthStencilTarget:q.NONE,width:0,height:0},u={target:U.TEXTURE_2D,pixelFormat:V.RGBA,dataType:I.UNSIGNED_BYTE,samplingMode:k.LINEAR,wrapMode:L.CLAMP_TO_EDGE,width:0,height:0};this._fbo=new N(e,_,u),this._accumulationParams={camera:this._cachedCamera,linearDepthTexture:null,shadowMap:this._shadowMap,inverseViewMatrix:m(),projInfo:w(),zScale:p()},this._accumulationRenderer=new j(t,e,this,c);const l=this._stage.resourceController.scheduler;this._handles.add(l.registerTask(M.SHADOW_ACCUMULATOR,this)),this._handles.add(n((()=>i.renderView),(e=>{this._handles.remove(B.renderViewHandleKey),a(e)||this._handles.add(e.events.on("force-camera-for-screenshot",(()=>this._cameraForcedForScreenshot=!0)),B.renderViewHandleKey)}),h))}normalizeCtorArgs(){return{}}get computedSamples(){return this._progress}get shadowCastTexture(){return this._fbo.colorTexture}get isAccumulating(){return this._isPreviewing||this._isRefining}get accumulationTechnique(){if(a(this._accumulationTechnique)){const e={rctx:this._rctx,viewingMode:this._stage.viewingMode},t=new E;t.pass=D.Accumulate,this._accumulationTechnique=new x(e,t)}return this._accumulationTechnique}get _isRefining(){return this._isActive&&!this._isDoneAccumulating&&!this._previewing}get _isPreviewing(){return this._isActive&&this._previewing}get _isActive(){return this._enabled&&this._sampleCount>0}get _canAccumulate(){return null!==this._accumulationParams.linearDepthTexture&&this._depthRange!==b&&this._opacityFromElevation>y}get _isDoneAccumulating(){return this._progress>=this._sampleCount}get _lightDirections(){return this._cachedLightDirections}set _lightDirections(e){const t=this._cachedLightDirections;if(i(t,e,d))return;const s=e.length;t.length=s,this._sampleCount=Math.min(F,s);for(let i=0;i<s;++i){const s=e[i],r=t[i]||f();g(r,s),t[i]=r}this._invalidate()}get _projInfo(){return this._accumulationParams.projInfo}get _zScale(){return this._accumulationParams.zScale}get _inverseView(){return this._accumulationParams.inverseViewMatrix}get _opacityFromElevation(){return this._accumulationRenderer.opacityFromElevation}set _opacityFromElevation(e){this._accumulationRenderer.opacityFromElevation=e}get running(){return this._isRefining&&this._canAccumulate&&this._progress>0}runTask(e){for(this._prepareForShadowMapPass(this._cachedCamera,this._contentCamera);!e.done&&!this._isDoneAccumulating;)this._accumulateShadow(),e.madeProgress();this._requestRender()}accumulateFixedSamples(){if(!this.isAccumulating||!this._canAccumulate)return;(this._previewing||0===this._progress||this._cameraForcedForScreenshot)&&this._clear();const e=this._cameraForcedForScreenshot?this._sampleCount:Math.min(B.previewSamples,this._sampleCount-this._progress);for(let t=0;t<e;++t)this._accumulateShadow();this._cameraForcedForScreenshot=!1}render(){this._accumulationRenderer.render()}dispose(){this._stop(),this._handles.destroy(),this._accumulationRenderer=o(this._accumulationRenderer),this._shadowMap=o(this._shadowMap),this._fbo=o(this._fbo),this._vao=o(this._vao),this._accumulationTechnique=o(this._accumulationTechnique),this._cachedLightDirections.length=0,this._sampleCount=0}setOptions(e){void 0!==e.enabled&&this._setEnabled(e.enabled),void 0!==e.previewing&&this.setPreviewing(e.previewing),void 0!==e.lightDirections&&this.setLightDirections(e.lightDirections),this._accumulationRenderer.setOptions(e)}setPreviewing(e){this._previewing!==e&&(this._previewing=e,this._requestRenderIfEnabled())}setLightDirections(e){this._lightDirections=e}setAccumulationDependencies(e,t,i,s){this._accumulationParams.linearDepthTexture=e,this._depthRange=t,this._updateCamera(i),this._contentCamera=s,this.notifyChange("_canAccumulate")}readAccumulatedShadow(e,t){if(!this._isActive||this._progress<1||e<0||e>this._fbo.width||t<0||t>this._fbo.height)return 0;const i=G;return this._fbo.readPixels(e,t,1,1,V.RGBA,I.UNSIGNED_BYTE,i),i[0]/this._progress}_start(){this._progress=0,this._enabled=!0}_stop(){this._enabled=!1}_invalidate(){this._progress=0,this._requestRenderIfEnabled()}_clear(){this._rctx.bindFramebuffer(this._fbo),this._rctx.setClearColor(0,0,0,0),this._rctx.clearSafe(O.COLOR_BUFFER_BIT),this._progress=0}_accumulateShadow(){const e=this._lightDirections[this._progress],t=this._cachedCamera;this._renderToShadowMap(this._shadowMap,e,t,this._depthRange),this._rctx.bindFramebuffer(this._fbo);const i=this.accumulationTechnique;this._rctx.useProgram(i.program),i.bindPipelineState(this._rctx),i.bindPass(this._accumulationParams),this._rctx.bindVAO(this._vao),this._rctx.drawArrays(i.primitiveType,0,z(this._vao,"geometry")),this._progress++}_updateCamera(e){if(e.equals(this._cachedCamera))return;const{fullWidth:t,fullHeight:i,projectionMatrix:s,viewMatrix:a,center:o}=e;this._cachedCamera.copyFrom(e),this._fbo.resize(t,i),T(s,t,i,this._projInfo,this._zScale),u(this._inverseView,a,o),l(this._inverseView,this._inverseView),this._opacityFromElevation=1-r(C,A,e.relativeElevation)}_setEnabled(e){e!==this._enabled&&(e?this._start():this._stop())}_requestRenderIfEnabled(){this._enabled&&this._requestRender()}get test(){return{lightDirections:this._lightDirections,isDone:()=>this._isDoneAccumulating,isActive:()=>this._isActive}}};H.previewSamples=6,H.renderViewHandleKey="renderView",e([c()],H.prototype,"_progress",void 0),e([c()],H.prototype,"_sampleCount",void 0),e([c()],H.prototype,"_enabled",void 0),e([c()],H.prototype,"_depthRange",void 0),e([c()],H.prototype,"_previewing",void 0),e([c()],H.prototype,"_accumulationRenderer",void 0),e([c()],H.prototype,"_isRefining",null),e([c()],H.prototype,"_isActive",null),e([c()],H.prototype,"_canAccumulate",null),e([c()],H.prototype,"_isDoneAccumulating",null),e([c()],H.prototype,"_opacityFromElevation",null),e([c()],H.prototype,"running",null),H=B=e([_("esri.views.3d.webgl-engine.lib.ShadowAccumulator")],H);const G=new Uint8Array(4);export{H as ShadowAccumulator};
5
+ import{_ as e}from"../../../../chunks/tslib.es6.js";import t from"../../../../core/Accessor.js";import{equals as i}from"../../../../core/arrayUtils.js";import s from"../../../../core/Handles.js";import{smoothstep as r}from"../../../../core/mathUtils.js";import{isNone as a,disposeMaybe as o}from"../../../../core/maybe.js";import{watch as n,syncAndInitial as h}from"../../../../core/reactiveUtils.js";import{property as c}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/has.js";import"../../../../core/accessorSupport/ensureType.js";import{subclass as _}from"../../../../core/accessorSupport/decorators/subclass.js";import{j as u,a as l}from"../../../../chunks/mat4.js";import{c as m}from"../../../../chunks/mat4f64.js";import{a as p}from"../../../../chunks/vec2f64.js";import{y as d,g}from"../../../../chunks/vec3.js";import{c as f}from"../../../../chunks/vec3f64.js";import{c as w}from"../../../../chunks/vec4f64.js";import v from"./Camera.js";import{ZERO as b}from"./depthRange.js";import{createQuadVAO as j}from"./glUtil3D.js";import{ShadowCastRenderer as S,shadowCastDisabledElevationThreshold as y,shadowCastDisableElevationMax as A,shadowCastDisableElevationMin as C}from"./ShadowCastRenderer.js";import R from"./ShadowMap.js";import{inverseProjectionInfo as T}from"./Util.js";import{S as D,s as F}from"../../../../chunks/ShadowCast.glsl.js";import{ShadowCastTechniqueConfiguration as E,ShadowCastTechnique as M}from"../shaders/ShadowCastTechnique.js";import{TaskPriority as x}from"../../../support/Scheduler.js";import{TargetType as P,DepthStencilTargetType as q,TextureType as U,PixelFormat as V,PixelType as I,TextureSamplingMode as k,TextureWrapMode as L,ClearBufferBit as O}from"../../../webgl/enums.js";import{FramebufferObject as N}from"../../../webgl/FramebufferObject.js";import{vertexCount as z}from"../../../webgl/Util.js";var B;let H=B=class extends t{constructor(e,t,i,r,o,c){super({}),this._rctx=e,this._stage=i,this._prepareForShadowMapPass=r,this._renderToShadowMap=o,this._requestRender=c,this._progress=0,this._sampleCount=0,this._cachedCamera=new v,this._contentCamera=new v,this._enabled=!1,this._cachedLightDirections=[],this._depthRange=b,this._previewing=!1,this._handles=new s,this._cameraForcedForScreenshot=!1,this._shadowMap=new R(e,i.viewingMode),this._shadowMap.enabled=!0,this._vao=j(e);const _={colorTarget:P.TEXTURE,depthStencilTarget:q.NONE,width:0,height:0},u={target:U.TEXTURE_2D,pixelFormat:V.RGBA,dataType:I.UNSIGNED_BYTE,samplingMode:k.LINEAR,wrapMode:L.CLAMP_TO_EDGE,width:0,height:0};this._fbo=new N(e,_,u),this._accumulationParams={camera:this._cachedCamera,linearDepthTexture:null,shadowMap:this._shadowMap,inverseViewMatrix:m(),projInfo:w(),zScale:p()},this._accumulationRenderer=new S(t,e,this,c);const l=this._stage.resourceController.scheduler;this._handles.add(l.registerTask(x.SHADOW_ACCUMULATOR,this)),this._handles.add(n((()=>i.renderView),(e=>{this._handles.remove(B.renderViewHandleKey),a(e)||this._handles.add(e.events.on("force-camera-for-screenshot",(()=>this._cameraForcedForScreenshot=!0)),B.renderViewHandleKey)}),h))}normalizeCtorArgs(){return{}}get computedSamples(){return this._progress}get shadowCastTexture(){return this._fbo.colorTexture}get isAccumulating(){return this._isPreviewing||this._isRefining}get accumulationTechnique(){if(a(this._accumulationTechnique)){const e={rctx:this._rctx,viewingMode:this._stage.viewingMode},t=new E;t.pass=D.Accumulate,this._accumulationTechnique=new M(e,t)}return this._accumulationTechnique}get _isRefining(){return this._isActive&&!this._isDoneAccumulating&&!this._previewing}get _isPreviewing(){return this._isActive&&this._previewing}get _isActive(){return this._enabled&&this._sampleCount>0}get _canAccumulate(){return null!==this._accumulationParams.linearDepthTexture&&this._depthRange!==b&&this._opacityFromElevation>y}get _isDoneAccumulating(){return this._progress>=this._sampleCount}get _lightDirections(){return this._cachedLightDirections}set _lightDirections(e){const t=this._cachedLightDirections;if(i(t,e,d))return;const s=e.length;t.length=s,this._sampleCount=Math.min(F,s);for(let i=0;i<s;++i){const s=e[i],r=t[i]||f();g(r,s),t[i]=r}this._invalidate()}get _projInfo(){return this._accumulationParams.projInfo}get _zScale(){return this._accumulationParams.zScale}get _inverseView(){return this._accumulationParams.inverseViewMatrix}get _opacityFromElevation(){return this._accumulationRenderer.opacityFromElevation}set _opacityFromElevation(e){this._accumulationRenderer.opacityFromElevation=e}get running(){return this._isRefining&&this._canAccumulate&&this._progress>0}runTask(e){for(this._prepareForShadowMapPass(this._cachedCamera,this._contentCamera);!e.done&&!this._isDoneAccumulating;)this._accumulateShadow(),e.madeProgress();this._requestRender()}accumulateFixedSamples(){if(!this.isAccumulating||!this._canAccumulate)return;(this._previewing||0===this._progress||this._cameraForcedForScreenshot)&&this._clear();const e=this._cameraForcedForScreenshot?this._sampleCount:Math.min(B.previewSamples,this._sampleCount-this._progress);for(let t=0;t<e;++t)this._accumulateShadow();this._cameraForcedForScreenshot=!1}render(){this._accumulationRenderer.render()}dispose(){this._stop(),this._handles.destroy(),this._accumulationRenderer=o(this._accumulationRenderer),this._shadowMap=o(this._shadowMap),this._fbo=o(this._fbo),this._vao=o(this._vao),this._accumulationTechnique=o(this._accumulationTechnique),this._cachedLightDirections.length=0,this._sampleCount=0}setOptions(e){void 0!==e.enabled&&this._setEnabled(e.enabled),void 0!==e.previewing&&this.setPreviewing(e.previewing),void 0!==e.lightDirections&&this.setLightDirections(e.lightDirections),this._accumulationRenderer.setOptions(e)}setPreviewing(e){this._previewing!==e&&(this._previewing=e,this._requestRenderIfEnabled())}setLightDirections(e){this._lightDirections=e}setAccumulationDependencies(e,t,i,s){this._accumulationParams.linearDepthTexture=e,this._depthRange=t,this._updateCamera(i),this._contentCamera=s,this.notifyChange("_canAccumulate")}readAccumulatedShadow(e,t){if(!this._isActive||this._progress<1||e<0||e>this._fbo.width||t<0||t>this._fbo.height)return 0;const i=G;return this._fbo.readPixels(e,t,1,1,V.RGBA,I.UNSIGNED_BYTE,i),i[0]/this._progress}_start(){this._progress=0,this._enabled=!0}_stop(){this._enabled=!1}_invalidate(){this._progress=0,this._requestRenderIfEnabled()}_clear(){this._rctx.bindFramebuffer(this._fbo),this._rctx.setClearColor(0,0,0,0),this._rctx.clearSafe(O.COLOR_BUFFER_BIT),this._progress=0}_accumulateShadow(){const e=this._lightDirections[this._progress],t=this._cachedCamera;this._renderToShadowMap(this._shadowMap,e,t,this._depthRange),this._rctx.bindFramebuffer(this._fbo);const i=this.accumulationTechnique;this._rctx.useTechnique(i),i.bindPass(this._accumulationParams),this._rctx.bindVAO(this._vao),this._rctx.drawArrays(i.primitiveType,0,z(this._vao,"geometry")),this._progress++}_updateCamera(e){if(e.equals(this._cachedCamera))return;const{fullWidth:t,fullHeight:i,projectionMatrix:s,viewMatrix:a,center:o}=e;this._cachedCamera.copyFrom(e),this._fbo.resize(t,i),T(s,t,i,this._projInfo,this._zScale),u(this._inverseView,a,o),l(this._inverseView,this._inverseView),this._opacityFromElevation=1-r(C,A,e.relativeElevation)}_setEnabled(e){e!==this._enabled&&(e?this._start():this._stop())}_requestRenderIfEnabled(){this._enabled&&this._requestRender()}get test(){return{lightDirections:this._lightDirections,isDone:()=>this._isDoneAccumulating,isActive:()=>this._isActive}}};H.previewSamples=6,H.renderViewHandleKey="renderView",e([c()],H.prototype,"_progress",void 0),e([c()],H.prototype,"_sampleCount",void 0),e([c()],H.prototype,"_enabled",void 0),e([c()],H.prototype,"_depthRange",void 0),e([c()],H.prototype,"_previewing",void 0),e([c()],H.prototype,"_accumulationRenderer",void 0),e([c()],H.prototype,"_isRefining",null),e([c()],H.prototype,"_isActive",null),e([c()],H.prototype,"_canAccumulate",null),e([c()],H.prototype,"_isDoneAccumulating",null),e([c()],H.prototype,"_opacityFromElevation",null),e([c()],H.prototype,"running",null),H=B=e([_("esri.views.3d.webgl-engine.lib.ShadowAccumulator")],H);const G=new Uint8Array(4);export{H as ShadowAccumulator};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.23/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../../chunks/tslib.es6.js";import i from"../../../../core/Accessor.js";import{disposeMaybe as t}from"../../../../core/maybe.js";import{property as s}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/arrayUtils.js";import"../../../../core/has.js";import"../../../../core/accessorSupport/ensureType.js";import{subclass as a}from"../../../../core/accessorSupport/decorators/subclass.js";import{g as o,c as r}from"../../../../chunks/vec4.js";import{f as n}from"../../../../chunks/vec4f64.js";import{createQuadVAO as h}from"./glUtil3D.js";import{S as l,a as u}from"../../../../chunks/ShadowCast.glsl.js";import{ShadowCastTechniqueConfiguration as _,ShadowCastTechnique as c}from"../shaders/ShadowCastTechnique.js";import{vertexCount as d}from"../../../webgl/Util.js";const m=n(.01,0,.25,1),p=4e4,v=5e4,b=1/512;let g=class extends i{constructor(e,i,t,s){super({}),this._techniqueRepository=e,this._rctx=i,this._shadowAccumulator=t,this._requestRender=s,this._visualizationParams={shadowCastMap:this._shadowCastTexture,sampleScale:0,color:m,threshold:.5,bandSize:.1,opacityFromElevation:1},this._techniqueConfig=new _,this._enabled=!1,this._vao=h(i),this._techniqueConfig.pass=l.Visualize,this._techniqueConfig.visualization=u.Gradient}normalizeCtorArgs(){return{}}dispose(){this._stop(),this._vao=t(this._vao),this._techniqueRepository.release(this._technique),this._technique=null,this._shadowAccumulator=null}get visualizeShadowCastTechnique(){return this._technique=this._techniqueRepository.releaseAndAcquire(c,this._techniqueConfig,this._technique),this._technique}render(){if(!this._isRenderingVisualization)return;this._sampleScale=1/this._computedSamples,this._rctx.bindVAO(this._vao);const e=this.visualizeShadowCastTechnique;this._rctx.useProgram(e.program),e.bindPipelineState(this._rctx),e.bindPass(this._visualizationParams),this._rctx.drawArrays(e.primitiveType,0,d(this._vao,"geometry"))}setOptions(e){void 0!==e.enabled&&this._setEnabled(e.enabled),void 0!==e.color&&this._setColor(e.color),void 0!==e.threshold&&(this._threshold=e.threshold),void 0!==e.visualization&&(this._visualization=e.visualization),void 0!==e.bandSize&&(this._bandSize=e.bandSize),void 0!==e.bandsEnabled&&(this._bandsEnabled=e.bandsEnabled)}get opacityFromElevation(){return this._visualizationParams.opacityFromElevation}set opacityFromElevation(e){this._visualizationParams.opacityFromElevation!==e&&(this._visualizationParams.opacityFromElevation=e,this.notifyChange("opacityFromElevation"))}get _isRenderingVisualization(){return this._enabled&&this._computedSamples>0&&this.opacityFromElevation>b}get _computedSamples(){return this._shadowAccumulator.computedSamples}get _shadowCastTexture(){return this._shadowAccumulator.shadowCastTexture}get _sampleScale(){return this._visualizationParams.sampleScale}set _sampleScale(e){this._visualizationParams.sampleScale=e}get _threshold(){return this._visualizationParams.threshold}set _threshold(e){this._threshold!==e&&(this._visualizationParams.threshold=e,this._requestRenderIfRunning())}get _visualization(){return this._techniqueConfig.visualization}set _visualization(e){e!==this._visualization&&(this._techniqueConfig.visualization=e,this._techniqueRepository.release(this._technique),this._technique=null,this._requestRenderIfRunning())}get _bandSize(){return this._visualizationParams.bandSize}set _bandSize(e){e!==this._bandSize&&(this._visualizationParams.bandSize=e,this._requestRenderIfRunning())}get _bandsEnabled(){return this._techniqueConfig.bandsEnabled}set _bandsEnabled(e){e!==this._bandsEnabled&&(this._techniqueConfig.bandsEnabled=e,this._techniqueRepository.release(this._technique),this._technique=null,this._requestRenderIfRunning())}_setColor(e){const i=this._visualizationParams.color;o(e,i)||(r(this._visualizationParams.color,e),this._requestRenderIfRunning())}_setEnabled(e){e!==this._enabled&&(e?this._start():this._stop())}_requestRenderIfRunning(){this._enabled&&this._requestRender()}_start(){this._enabled=!0,this._requestRender()}_stop(){this._enabled=!1,this._requestRender()}};e([s()],g.prototype,"opacityFromElevation",null),g=e([a("esri.views.3d.webgl-engine.lib.ShadowCastRenderer")],g);export{g as ShadowCastRenderer,v as shadowCastDisableElevationMax,p as shadowCastDisableElevationMin,b as shadowCastDisabledElevationThreshold};
5
+ import{_ as e}from"../../../../chunks/tslib.es6.js";import i from"../../../../core/Accessor.js";import{disposeMaybe as t}from"../../../../core/maybe.js";import{property as s}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/arrayUtils.js";import"../../../../core/has.js";import"../../../../core/accessorSupport/ensureType.js";import{subclass as a}from"../../../../core/accessorSupport/decorators/subclass.js";import{g as o,c as r}from"../../../../chunks/vec4.js";import{f as n}from"../../../../chunks/vec4f64.js";import{createQuadVAO as h}from"./glUtil3D.js";import{S as l,a as u}from"../../../../chunks/ShadowCast.glsl.js";import{ShadowCastTechniqueConfiguration as _,ShadowCastTechnique as c}from"../shaders/ShadowCastTechnique.js";import{vertexCount as d}from"../../../webgl/Util.js";const m=n(.01,0,.25,1),p=4e4,v=5e4,b=1/512;let q=class extends i{constructor(e,i,t,s){super({}),this._techniqueRepository=e,this._rctx=i,this._shadowAccumulator=t,this._requestRender=s,this._visualizationParams={shadowCastMap:this._shadowCastTexture,sampleScale:0,color:m,threshold:.5,bandSize:.1,opacityFromElevation:1},this._techniqueConfig=new _,this._enabled=!1,this._vao=h(i),this._techniqueConfig.pass=l.Visualize,this._techniqueConfig.visualization=u.Gradient}normalizeCtorArgs(){return{}}dispose(){this._stop(),this._vao=t(this._vao),this._techniqueRepository.release(this._technique),this._technique=null,this._shadowAccumulator=null}get visualizeShadowCastTechnique(){return this._technique=this._techniqueRepository.releaseAndAcquire(c,this._techniqueConfig,this._technique),this._technique}render(){if(!this._isRenderingVisualization)return;this._sampleScale=1/this._computedSamples,this._rctx.bindVAO(this._vao);const e=this.visualizeShadowCastTechnique;this._rctx.useTechnique(e),e.bindPass(this._visualizationParams),this._rctx.drawArrays(e.primitiveType,0,d(this._vao,"geometry"))}setOptions(e){void 0!==e.enabled&&this._setEnabled(e.enabled),void 0!==e.color&&this._setColor(e.color),void 0!==e.threshold&&(this._threshold=e.threshold),void 0!==e.visualization&&(this._visualization=e.visualization),void 0!==e.bandSize&&(this._bandSize=e.bandSize),void 0!==e.bandsEnabled&&(this._bandsEnabled=e.bandsEnabled)}get opacityFromElevation(){return this._visualizationParams.opacityFromElevation}set opacityFromElevation(e){this._visualizationParams.opacityFromElevation!==e&&(this._visualizationParams.opacityFromElevation=e,this.notifyChange("opacityFromElevation"))}get _isRenderingVisualization(){return this._enabled&&this._computedSamples>0&&this.opacityFromElevation>b}get _computedSamples(){return this._shadowAccumulator.computedSamples}get _shadowCastTexture(){return this._shadowAccumulator.shadowCastTexture}get _sampleScale(){return this._visualizationParams.sampleScale}set _sampleScale(e){this._visualizationParams.sampleScale=e}get _threshold(){return this._visualizationParams.threshold}set _threshold(e){this._threshold!==e&&(this._visualizationParams.threshold=e,this._requestRenderIfRunning())}get _visualization(){return this._techniqueConfig.visualization}set _visualization(e){e!==this._visualization&&(this._techniqueConfig.visualization=e,this._techniqueRepository.release(this._technique),this._technique=null,this._requestRenderIfRunning())}get _bandSize(){return this._visualizationParams.bandSize}set _bandSize(e){e!==this._bandSize&&(this._visualizationParams.bandSize=e,this._requestRenderIfRunning())}get _bandsEnabled(){return this._techniqueConfig.bandsEnabled}set _bandsEnabled(e){e!==this._bandsEnabled&&(this._techniqueConfig.bandsEnabled=e,this._techniqueRepository.release(this._technique),this._technique=null,this._requestRenderIfRunning())}_setColor(e){const i=this._visualizationParams.color;o(e,i)||(r(this._visualizationParams.color,e),this._requestRenderIfRunning())}_setEnabled(e){e!==this._enabled&&(e?this._start():this._stop())}_requestRenderIfRunning(){this._enabled&&this._requestRender()}_start(){this._enabled=!0,this._requestRender()}_stop(){this._enabled=!1,this._requestRender()}};e([s()],q.prototype,"opacityFromElevation",null),q=e([a("esri.views.3d.webgl-engine.lib.ShadowCastRenderer")],q);export{q as ShadowCastRenderer,v as shadowCastDisableElevationMax,p as shadowCastDisableElevationMin,b as shadowCastDisabledElevationThreshold};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.23/esri/copyright.txt for details.
4
4
  */
5
- import{smoothstep as t,clamp as i}from"../../../../core/mathUtils.js";import{isNone as e,disposeMaybe as a}from"../../../../core/maybe.js";import{n as s,s as r,d as o}from"../../../../chunks/vec3.js";import{c as h}from"../../../../chunks/vec3f64.js";import{f as c}from"../../../../chunks/vec4f32.js";import{ViewingMode as n}from"../../../ViewingMode.js";import{createQuadVAO as m}from"./glUtil3D.js";import{ShadowHighlightTechnique as p}from"../shaders/ShadowHighlightTechnique.js";import{vertexCount as _}from"../../../webgl/Util.js";const d=.001953125,l=4e4,u=5e4;class g{constructor(t,i){this._rctx=t,this._viewingMode=i,this._maxOpacity=1,this._parameters={shadowColor:c(1,0,1,1),shadowOpacity:.2,occludedShadowOpacity:.1,opacityElevation:1,dayNightTerminator:1},this._vao=m(this._rctx)}get technique(){return e(this._technique)&&(this._technique=new p({rctx:this._rctx,viewingMode:this._viewingMode},null)),this._technique}render(t,i){if(this._updateParameters(t),!t.shadowMap.enabled||!t.linearDepthTexture||!this.isVisible)return;const e=this.technique;this._rctx.bindFramebuffer(i),this._rctx.useProgram(e.program),e.bindPipelineState(this._rctx),e.bindPass(this._parameters,t),this._rctx.bindVAO(this._vao),this._rctx.drawArrays(e.primitiveType,0,_(this._vao,"geometry"))}get gpuMemoryUsage(){var t,i;return null!=(t=null==(i=this._vao)?void 0:i.size)?t:0}setDefaultOptions(t){this._parameters={...this._parameters,...t},this._updateMaxOpacity()}_updateParameters(e){this._parameters.opacityElevation=1-t(l,u,e.camera.relativeElevation);const a=this._viewingMode===n.Global?s(v,e.camera.center):r(v,0,0,1),h=o(a,e.lighting.lightingMainDirection);this._parameters.dayNightTerminator=t(0,1,i(30*h,0,1))}dispose(){this._vao=a(this._vao),this._technique=a(this._technique)}get isVisible(){return this._maxOpacity*this._parameters.opacityElevation*this._parameters.dayNightTerminator>=d}_updateMaxOpacity(){const t=this._parameters,i=t.shadowColor,e=Math.max(t.shadowOpacity,t.occludedShadowOpacity);this._maxOpacity=e*i[3]}}const v=h();export{g as ShadowHighlightHelper};
5
+ import{smoothstep as t,clamp as i}from"../../../../core/mathUtils.js";import{isNone as e,disposeMaybe as s}from"../../../../core/maybe.js";import{n as a,s as r,d as o}from"../../../../chunks/vec3.js";import{c as h}from"../../../../chunks/vec3f64.js";import{f as c}from"../../../../chunks/vec4f32.js";import{ViewingMode as n}from"../../../ViewingMode.js";import{createQuadVAO as m}from"./glUtil3D.js";import{ShadowHighlightTechnique as p}from"../shaders/ShadowHighlightTechnique.js";import{vertexCount as _}from"../../../webgl/Util.js";const d=.001953125,l=4e4,u=5e4;class g{constructor(t,i){this._rctx=t,this._viewingMode=i,this._maxOpacity=1,this._parameters={shadowColor:c(1,0,1,1),shadowOpacity:.2,occludedShadowOpacity:.1,opacityElevation:1,dayNightTerminator:1},this._vao=m(this._rctx)}get technique(){return e(this._technique)&&(this._technique=new p({rctx:this._rctx,viewingMode:this._viewingMode},null)),this._technique}render(t,i){if(this._updateParameters(t),!t.shadowMap.enabled||!t.linearDepthTexture||!this.isVisible)return;const e=this.technique;this._rctx.bindFramebuffer(i),this._rctx.useTechnique(e),e.bindPass(this._parameters,t),this._rctx.bindVAO(this._vao),this._rctx.drawArrays(e.primitiveType,0,_(this._vao,"geometry"))}get gpuMemoryUsage(){var t,i;return null!=(t=null==(i=this._vao)?void 0:i.size)?t:0}setDefaultOptions(t){this._parameters={...this._parameters,...t},this._updateMaxOpacity()}_updateParameters(e){this._parameters.opacityElevation=1-t(l,u,e.camera.relativeElevation);const s=this._viewingMode===n.Global?a(v,e.camera.center):r(v,0,0,1),h=o(s,e.lighting.lightingMainDirection);this._parameters.dayNightTerminator=t(0,1,i(30*h,0,1))}dispose(){this._vao=s(this._vao),this._technique=s(this._technique)}get isVisible(){return this._maxOpacity*this._parameters.opacityElevation*this._parameters.dayNightTerminator>=d}_updateMaxOpacity(){const t=this._parameters,i=t.shadowColor,e=Math.max(t.shadowOpacity,t.occludedShadowOpacity);this._maxOpacity=e*i[3]}}const v=h();export{g as ShadowHighlightHelper};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.23/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../../chunks/tslib.es6.js";import t from"../../../../core/Accessor.js";import{abortMaybe as r,isSome as s,disposeMaybe as i}from"../../../../core/maybe.js";import{throwIfAborted as o,isAborted as h}from"../../../../core/promiseUtils.js";import{property as a}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/arrayUtils.js";import"../../../../core/has.js";import"../../../../core/accessorSupport/ensureType.js";import{subclass as l}from"../../../../core/accessorSupport/decorators/subclass.js";import{requestImage as n}from"../../../../support/requestImageUtils.js";import{createScreenSizeTriangleVAO as d}from"./glUtil3D.js";import{SMAATechniqueConfiguration as u,SMAATechnique as _}from"./SMAATechnique.js";import{S as g}from"../../../../chunks/SMAA.glsl.js";import{TextureSamplingMode as c,PixelFormat as p,TargetType as m,DepthStencilTargetType as b,TextureType as T,PixelType as E,TextureWrapMode as x,ClearBufferBit as f,PrimitiveType as w}from"../../../webgl/enums.js";import{FramebufferObject as A}from"../../../webgl/FramebufferObject.js";import{Texture as R}from"../../../webgl/Texture.js";let C=class extends t{constructor(e,t){super({}),this.rctx=e,this._techniqueRep=t,this._isEnabled=!1}normalizeCtorArgs(){return{}}dispose(){this._abortController=r(this._abortController),this.disable()}_loadResources(e){if(s(this._abortController))return!1;if(s(this._searchTexture))return!0;this._abortController=new AbortController;const t=this._abortController.signal;return import("./SmaaRenderPassData.js").then((e=>this._loadTextures(e,t))).then((()=>e())).finally((()=>this._abortController=null)),!1}_loadTextures(e,t){return o(t),Promise.all([this._loadTextureFromBase64(e.areaTexture,c.LINEAR,p.RGB),this._loadTextureFromBase64(e.searchTexure,c.NEAREST,p.LUMINANCE)]).then((([e,r])=>{h(t)?(e.dispose(),r.dispose(),o(t)):(this._areaTexture=e,this._searchTexture=r)}))}get updating(){return s(this._abortController)}enable(e){if(this._isEnabled)return!0;if(!this._edgeDetectTechnique||!this._blendWeights||!this._blur){const e=new u,t=(e,t)=>this._techniqueRep.releaseAndAcquire(_,e,t);e.output=g.EdgeDetector,this._edgeDetectTechnique=t(e,this._edgeDetectTechnique),e.output=g.BlendWeight,this._blendWeights=t(e,this._blendWeights),e.output=g.Blur,this._blur=t(e,this._blur)}return!!this._loadResources(e)&&(this._vao=d(this.rctx),this._edges=new A(this.rctx,{colorTarget:m.TEXTURE,depthStencilTarget:b.NONE},{target:T.TEXTURE_2D,pixelFormat:p.RGB,dataType:E.UNSIGNED_BYTE,samplingMode:c.LINEAR,wrapMode:x.CLAMP_TO_EDGE,width:4,height:4}),this._blend=new A(this.rctx,{colorTarget:m.TEXTURE,depthStencilTarget:b.NONE},{target:T.TEXTURE_2D,pixelFormat:p.RGBA,dataType:E.UNSIGNED_BYTE,samplingMode:c.LINEAR,wrapMode:x.CLAMP_TO_EDGE,width:4,height:4}),this._isEnabled=!0,!0)}disable(){this._isEnabled&&(this._vao=i(this._vao),this._areaTexture=i(this._areaTexture),this._searchTexture=i(this._searchTexture),this._blend=i(this._blend),this._edges=i(this._edges),this._isEnabled=!1)}render(e){if(!this._isEnabled)return;const t=this.rctx,r=t.getBoundFramebufferObject(),s={x:0,y:0,width:e.descriptor.width,height:e.descriptor.height};t.bindVAO(this._vao),this._edgeDetectTechnique.bindPipelineState(t),t.setViewport(s.x,s.y,s.width,s.height),this._edges.resize(s.width,s.height),t.bindFramebuffer(this._edges),t.setClearColor(0,0,0,1),t.clear(f.COLOR_BUFFER_BIT),t.useProgram(this._edgeDetectTechnique.program),this._edgeDetectTechnique.program.bindTexture(e,"tColor"),this._edgeDetectTechnique.program.setUniform4f("resolution",1/s.width,1/s.height,s.width,s.height),t.drawArrays(w.TRIANGLES,0,3),this._blend.resize(s.width,s.height),t.bindFramebuffer(this._blend),t.setClearColor(0,0,1,1),t.clear(f.COLOR_BUFFER_BIT),t.useProgram(this._blendWeights.program),this._blendWeights.program.setUniform4f("resolution",1/s.width,1/s.height,s.width,s.height),this._blendWeights.program.bindTexture(this._searchTexture,"tSearch"),this._blendWeights.program.bindTexture(this._areaTexture,"tArea"),this._blendWeights.program.bindTexture(this._edges.colorTexture,"tEdges"),t.drawArrays(w.TRIANGLES,0,3),t.bindFramebuffer(r),t.setClearColor(0,1,0,1),t.clear(f.COLOR_BUFFER_BIT),t.useProgram(this._blur.program),this._blur.program.setUniform4f("resolution",1/s.width,1/s.height,s.width,s.height),this._blur.program.bindTexture(e,"tColor"),this._blur.program.bindTexture(this._blend.colorTexture,"tBlendWeights"),t.drawArrays(w.TRIANGLES,0,3)}_loadTextureFromBase64(e,t,r){const s=new R(this.rctx,{pixelFormat:r,dataType:E.UNSIGNED_BYTE,wrapMode:x.CLAMP_TO_EDGE,samplingMode:t},null);return n(e).then((e=>(s.resize(e.width,e.height),s.setData(e),s)))}};e([a()],C.prototype,"_abortController",void 0),e([a({readOnly:!0})],C.prototype,"updating",null),C=e([l("esri.views.3d.webgl-engine.lib.SmaaRenderPass")],C);export{C as SmaaRenderPass};
5
+ import{_ as e}from"../../../../chunks/tslib.es6.js";import t from"../../../../core/Accessor.js";import{abortMaybe as r,isSome as s,disposeMaybe as i}from"../../../../core/maybe.js";import{throwIfAborted as o,isAborted as h}from"../../../../core/promiseUtils.js";import{property as a}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/arrayUtils.js";import"../../../../core/has.js";import"../../../../core/accessorSupport/ensureType.js";import{subclass as n}from"../../../../core/accessorSupport/decorators/subclass.js";import{requestImage as l}from"../../../../support/requestImageUtils.js";import{createScreenSizeTriangleVAO as u}from"./glUtil3D.js";import{SMAATechniqueConfiguration as d,SMAATechnique as c}from"./SMAATechnique.js";import{S as _}from"../../../../chunks/SMAA.glsl.js";import{TextureSamplingMode as T,PixelFormat as p,TargetType as b,DepthStencilTargetType as g,TextureType as m,PixelType as E,TextureWrapMode as x,ClearBufferBit as f,PrimitiveType as w}from"../../../webgl/enums.js";import{FramebufferObject as A}from"../../../webgl/FramebufferObject.js";import{Texture as R}from"../../../webgl/Texture.js";let C=class extends t{constructor(e,t){super({}),this.rctx=e,this._techniqueRep=t,this._isEnabled=!1}normalizeCtorArgs(){return{}}dispose(){this._abortController=r(this._abortController),this.disable()}_loadResources(e){if(s(this._abortController))return!1;if(s(this._searchTexture))return!0;this._abortController=new AbortController;const t=this._abortController.signal;return import("./SmaaRenderPassData.js").then((e=>this._loadTextures(e,t))).then((()=>e())).finally((()=>this._abortController=null)),!1}_loadTextures(e,t){return o(t),Promise.all([this._loadTextureFromBase64(e.areaTexture,T.LINEAR,p.RGB),this._loadTextureFromBase64(e.searchTexure,T.NEAREST,p.LUMINANCE)]).then((([e,r])=>{h(t)?(e.dispose(),r.dispose(),o(t)):(this._areaTexture=e,this._searchTexture=r)}))}get updating(){return s(this._abortController)}enable(e){if(this._isEnabled)return!0;if(!this._edgeDetectTechnique||!this._blendWeightsTechnique||!this._blurTechnique){const e=new d,t=(e,t)=>this._techniqueRep.releaseAndAcquire(c,e,t);e.output=_.EdgeDetector,this._edgeDetectTechnique=t(e,this._edgeDetectTechnique),e.output=_.BlendWeight,this._blendWeightsTechnique=t(e,this._blendWeightsTechnique),e.output=_.Blur,this._blurTechnique=t(e,this._blurTechnique)}return!!this._loadResources(e)&&(this._vao=u(this.rctx),this._edges=new A(this.rctx,{colorTarget:b.TEXTURE,depthStencilTarget:g.NONE},{target:m.TEXTURE_2D,pixelFormat:p.RGB,dataType:E.UNSIGNED_BYTE,samplingMode:T.LINEAR,wrapMode:x.CLAMP_TO_EDGE,width:4,height:4}),this._blend=new A(this.rctx,{colorTarget:b.TEXTURE,depthStencilTarget:g.NONE},{target:m.TEXTURE_2D,pixelFormat:p.RGBA,dataType:E.UNSIGNED_BYTE,samplingMode:T.LINEAR,wrapMode:x.CLAMP_TO_EDGE,width:4,height:4}),this._isEnabled=!0,!0)}disable(){this._isEnabled&&(this._vao=i(this._vao),this._areaTexture=i(this._areaTexture),this._searchTexture=i(this._searchTexture),this._blend=i(this._blend),this._edges=i(this._edges),this._isEnabled=!1)}render(e){if(!this._isEnabled)return;const t=this.rctx,r=t.getBoundFramebufferObject(),s={x:0,y:0,width:e.descriptor.width,height:e.descriptor.height};t.bindVAO(this._vao),t.setViewport(s.x,s.y,s.width,s.height),this._edges.resize(s.width,s.height),t.bindFramebuffer(this._edges),t.setClearColor(0,0,0,1),t.clear(f.COLOR_BUFFER_BIT);const i=t.useTechnique(this._edgeDetectTechnique);i.bindTexture(e,"tColor"),i.setUniform4f("resolution",1/s.width,1/s.height,s.width,s.height),t.drawArrays(w.TRIANGLES,0,3),this._blend.resize(s.width,s.height),t.bindFramebuffer(this._blend),t.setClearColor(0,0,1,1),t.clear(f.COLOR_BUFFER_BIT);const o=t.useTechnique(this._blendWeightsTechnique);o.setUniform4f("resolution",1/s.width,1/s.height,s.width,s.height),o.bindTexture(this._searchTexture,"tSearch"),o.bindTexture(this._areaTexture,"tArea"),o.bindTexture(this._edges.colorTexture,"tEdges"),t.drawArrays(w.TRIANGLES,0,3),t.bindFramebuffer(r),t.setClearColor(0,1,0,1),t.clear(f.COLOR_BUFFER_BIT);const h=t.useTechnique(this._blurTechnique);h.setUniform4f("resolution",1/s.width,1/s.height,s.width,s.height),h.bindTexture(e,"tColor"),h.bindTexture(this._blend.colorTexture,"tBlendWeights"),t.drawArrays(w.TRIANGLES,0,3)}_loadTextureFromBase64(e,t,r){const s=new R(this.rctx,{pixelFormat:r,dataType:E.UNSIGNED_BYTE,wrapMode:x.CLAMP_TO_EDGE,samplingMode:t},null);return l(e).then((e=>(s.resize(e.width,e.height),s.setData(e),s)))}};e([a()],C.prototype,"_abortController",void 0),e([a({readOnly:!0})],C.prototype,"updating",null),C=e([n("esri.views.3d.webgl-engine.lib.SmaaRenderPass")],C);export{C as SmaaRenderPass};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.23/esri/copyright.txt for details.
4
4
  */
5
- import{neverReached as t}from"../../../../core/compilerUtils.js";import e from"../../../../core/Error.js";import r from"../../../../core/Evented.js";import{isPowerOfTwo as i,nextHighestPowerOfTwo as s}from"../../../../core/mathUtils.js";import{isNone as a,isSome as o,removeMaybe as n}from"../../../../core/maybe.js";import{throwIfAborted as m,onAbort as h,createAbortError as l}from"../../../../core/promiseUtils.js";import{isArrayBuffer as p,isUint8Array as d}from"../../../../core/typedArrayUtil.js";import{isBlobProtocol as _,isDataProtocol as c}from"../../../../core/urlUtils.js";import{requestImage as u}from"../../../../support/requestImageUtils.js";import{loadImageAsync as T}from"../../../../support/requestUtils.js";import{PowerOfTwoResizeMode as g}from"./basicInterfaces.js";import{estimateMemoryKTX2 as f,estimateMemoryBasis as w,createTextureKTX2 as E,createTextureBasis as A}from"./BasisUtil.js";import{ContentObject as x}from"./ContentObject.js";import{ContentObjectType as D}from"./ContentObjectType.js";import{createDDSTexture as I}from"./DDSUtil.js";import{createQuadVAO as M}from"./glUtil3D.js";import{assert as F}from"./Util.js";import{TextureWrapMode as O,TextureType as N,PixelFormat as y,PixelType as R,TextureSamplingMode as U,TargetType as b,DepthStencilTargetType as C,PrimitiveType as P}from"../../../webgl/enums.js";import{FramebufferObject as S}from"../../../webgl/FramebufferObject.js";import{Texture as H}from"../../../webgl/Texture.js";import{vertexCount as V}from"../../../webgl/Util.js";import j from"../../../webgl/capabilities/isWebGL2Context.js";class L extends x{constructor(t,e){super(),this.data=t,this.type=D.Texture,this._glTexture=null,this._powerOfTwoStretchInfo=null,this._loadingPromise=null,this._loadingController=null,this.events=new r,this.params=e||{},this.params.mipmap=!1!==this.params.mipmap,this.params.noUnpackFlip=this.params.noUnpackFlip||!1,this.params.preMultiplyAlpha=this.params.preMultiplyAlpha||!1,this.params.wrap=this.params.wrap||{s:O.REPEAT,t:O.REPEAT},this.params.powerOfTwoResizeMode=this.params.powerOfTwoResizeMode||g.STRETCH,this.estimatedTexMemRequired=L._estimateTexMemRequired(this.data,this.params),this._startPreload()}_startPreload(){const t=this.data;a(t)||(t instanceof HTMLVideoElement?this._startPreloadVideoElement(t):t instanceof HTMLImageElement&&this._startPreloadImageElement(t))}_startPreloadVideoElement(t){_(t.src)||"auto"===t.preload&&t.crossOrigin||(t.preload="auto",t.crossOrigin="anonymous",t.src=t.src)}_startPreloadImageElement(t){c(t.src)||_(t.src)||t.crossOrigin||(t.crossOrigin="anonymous",t.src=t.src)}static _getDataDimensions(t){return t instanceof HTMLVideoElement?{width:t.videoWidth,height:t.videoHeight}:t}static _estimateTexMemRequired(t,e){if(a(t))return 0;if(p(t)||d(t))return e.encoding===L.KTX2_ENCODING?f(t,e.mipmap):e.encoding===L.BASIS_ENCODING?w(t,e.mipmap):t.byteLength;const{width:r,height:i}=t instanceof Image||t instanceof ImageData||t instanceof HTMLCanvasElement||t instanceof HTMLVideoElement?L._getDataDimensions(t):e;return(e.mipmap?4/3:1)*r*i*(e.components||4)||0}dispose(){this.data=void 0}get width(){return this.params.width}get height(){return this.params.height}_createDescriptor(t){var e;return{target:N.TEXTURE_2D,pixelFormat:y.RGBA,dataType:R.UNSIGNED_BYTE,wrapMode:this.params.wrap,flipped:!this.params.noUnpackFlip,samplingMode:this.params.mipmap?U.LINEAR_MIPMAP_LINEAR:U.LINEAR,hasMipmap:this.params.mipmap,preMultiplyAlpha:this.params.preMultiplyAlpha,maxAnisotropy:null!=(e=this.params.maxAnisotropy)?e:this.params.mipmap?t.parameters.maxMaxAnisotropy:1}}get glTexture(){return this._glTexture}load(t,e){if(o(this._glTexture))return this._glTexture;if(o(this._loadingPromise))return this._loadingPromise;const r=this.data;return a(r)?(this._glTexture=new H(t,this._createDescriptor(t),null),this._glTexture):"string"==typeof r?this._loadFromURL(t,e,r):r instanceof Image?this._loadFromImageElement(t,e,r):r instanceof HTMLVideoElement?this._loadFromVideoElement(t,e,r):r instanceof ImageData||r instanceof HTMLCanvasElement?this._loadFromImage(t,r,e):(p(r)||d(r))&&this.params.encoding===L.DDS_ENCODING?this._loadFromDDSData(t,r):(p(r)||d(r))&&this.params.encoding===L.KTX2_ENCODING?this._loadFromKTX2(t,r):(p(r)||d(r))&&this.params.encoding===L.BASIS_ENCODING?this._loadFromBasis(t,r):d(r)?this._loadFromPixelData(t,r):p(r)?this._loadFromPixelData(t,new Uint8Array(r)):null}get requiresFrameUpdates(){return this.data instanceof HTMLVideoElement}frameUpdate(t,e,r){if(!(this.data instanceof HTMLVideoElement)||a(this._glTexture))return r;if(this.data.readyState<G.HAVE_CURRENT_DATA||r===this.data.currentTime)return r;if(o(this._powerOfTwoStretchInfo)){const{framebuffer:r,vao:i,sourceTexture:s}=this._powerOfTwoStretchInfo;s.setData(this.data),this._drawStretchedTexture(t,e,r,i,s,this._glTexture)}else{const{width:t,height:e}=this.data,{width:r,height:i}=this._glTexture.descriptor;t!==r||e!==i?this._glTexture.updateData(0,0,0,Math.min(t,r),Math.min(e,i),this.data):this._glTexture.setData(this.data)}return this._glTexture.descriptor.hasMipmap&&this._glTexture.generateMipmap(),this.data.currentTime}_loadFromDDSData(t,e){return this._glTexture=I(t,this._createDescriptor(t),e),this._glTexture}_loadFromKTX2(t,e){return this._loadAsync((()=>E(t,this._createDescriptor(t),e).then((t=>(this._glTexture=t,t)))))}_loadFromBasis(t,e){return this._loadAsync((()=>A(t,this._createDescriptor(t),e).then((t=>(this._glTexture=t,t)))))}_loadFromPixelData(t,e){F(this.params.width>0&&this.params.height>0);const r=this._createDescriptor(t);return r.pixelFormat=1===this.params.components?y.LUMINANCE:3===this.params.components?y.RGB:y.RGBA,r.width=this.params.width,r.height=this.params.height,this._glTexture=new H(t,r,e),this._glTexture}_loadFromURL(t,e,r){return this._loadAsync((async i=>{const s=await u(r,{signal:i});return m(i),this._loadFromImage(t,s,e)}))}_loadFromImageElement(t,e,r){return r.complete?this._loadFromImage(t,r,e):this._loadAsync((async i=>{const s=await T(r,r.src,!1,i);return m(i),this._loadFromImage(t,s,e)}))}_loadFromVideoElement(t,e,r){return r.readyState>=G.HAVE_CURRENT_DATA?this._loadFromImage(t,r,e):this._loadFromVideoElementAsync(t,e,r)}_loadFromVideoElementAsync(t,r,i){return this._loadAsync((s=>new Promise(((a,o)=>{const m=()=>{i.removeEventListener("loadeddata",p),i.removeEventListener("error",d),n(_)},p=()=>{i.readyState>=G.HAVE_CURRENT_DATA&&(m(),a(this._loadFromImage(t,i,r)))},d=t=>{m(),o(t||new e("Failed to load video"))};i.addEventListener("loadeddata",p),i.addEventListener("error",d);const _=h(s,(()=>d(l())))}))))}_loadFromImage(t,e,r){const s=L._getDataDimensions(e);this.params.width=s.width,this.params.height=s.height;const a=this._createDescriptor(t);return a.pixelFormat=3===this.params.components?y.RGB:y.RGBA,!this._requiresPowerOfTwo(t,a)||i(s.width)&&i(s.height)?(a.width=s.width,a.height=s.height,this._glTexture=new H(t,a,e),this._glTexture):(this._glTexture=this._makePowerOfTwoTexture(t,e,s,a,r),this._glTexture)}_loadAsync(t){const e=new AbortController;this._loadingController=e;const r=t(e.signal);this._loadingPromise=r;const i=()=>{this._loadingController===e&&(this._loadingController=null),this._loadingPromise===r&&(this._loadingPromise=null)};return r.then(i,i),r}_requiresPowerOfTwo(t,e){const r=O.CLAMP_TO_EDGE,i="number"==typeof e.wrapMode?e.wrapMode===r:e.wrapMode.s===r&&e.wrapMode.t===r;return!j(t.gl)&&(e.hasMipmap||!i)}_makePowerOfTwoTexture(e,r,i,a,o){const{width:n,height:m}=i,h=s(n),l=s(m);let p;switch(a.width=h,a.height=l,this.params.powerOfTwoResizeMode){case g.PAD:a.textureCoordinateScaleFactor=[n/h,m/l],p=new H(e,a),p.updateData(0,0,0,n,m,r);break;case g.STRETCH:case null:case void 0:p=this._stretchToPowerOfTwo(e,r,a,o());break;default:t(this.params.powerOfTwoResizeMode)}return a.hasMipmap&&p.generateMipmap(),p}_stretchToPowerOfTwo(t,e,r,i){const s=new H(t,r),a=new S(t,{colorTarget:b.TEXTURE,depthStencilTarget:C.NONE},s),o=new H(t,{target:N.TEXTURE_2D,pixelFormat:r.pixelFormat,dataType:R.UNSIGNED_BYTE,wrapMode:O.CLAMP_TO_EDGE,samplingMode:U.LINEAR,flipped:!!r.flipped,maxAnisotropy:8,preMultiplyAlpha:r.preMultiplyAlpha},e),n=M(t),m=t.getBoundFramebufferObject();return this._drawStretchedTexture(t,i,a,n,o,s),this.requiresFrameUpdates?this._powerOfTwoStretchInfo={vao:n,sourceTexture:o,framebuffer:a}:(n.dispose(!0),o.dispose(),a.detachColorTexture(),a.dispose()),t.bindFramebuffer(m),s}_drawStretchedTexture(t,e,r,i,s,a){t.bindFramebuffer(r);const o=t.getViewport();t.setViewport(0,0,a.descriptor.width,a.descriptor.height);const n=e.program;t.useProgram(n),n.setUniform4f("uColor",1,1,1,1),n.bindTexture(s,"tex"),t.bindVAO(i),e.bindPipelineState(t),t.drawArrays(P.TRIANGLE_STRIP,0,V(i,"geometry")),t.bindFramebuffer(null),t.setViewport(o.x,o.y,o.width,o.height)}unload(){if(o(this._powerOfTwoStretchInfo)){const{framebuffer:t,vao:e,sourceTexture:r}=this._powerOfTwoStretchInfo;e.dispose(!0),r.dispose(),t.dispose(),this._glTexture=null,this._powerOfTwoStretchInfo=null}if(o(this._glTexture)&&(this._glTexture.dispose(),this._glTexture=null),o(this._loadingController)){const t=this._loadingController;this._loadingController=null,this._loadingPromise=null,t.abort()}this.events.emit("unloaded")}}var G;L.DDS_ENCODING="image/vnd-ms.dds",L.KTX2_ENCODING="image/ktx2",L.BASIS_ENCODING="image/x.basis",function(t){t[t.HAVE_NOTHING=0]="HAVE_NOTHING",t[t.HAVE_METADATA=1]="HAVE_METADATA",t[t.HAVE_CURRENT_DATA=2]="HAVE_CURRENT_DATA",t[t.HAVE_FUTURE_DATA=3]="HAVE_FUTURE_DATA",t[t.HAVE_ENOUGH_DATA=4]="HAVE_ENOUGH_DATA"}(G||(G={}));export{L as Texture};
5
+ import{neverReached as t}from"../../../../core/compilerUtils.js";import e from"../../../../core/Error.js";import r from"../../../../core/Evented.js";import{isPowerOfTwo as i,nextHighestPowerOfTwo as s}from"../../../../core/mathUtils.js";import{isNone as a,isSome as o,removeMaybe as n}from"../../../../core/maybe.js";import{throwIfAborted as m,onAbort as h,createAbortError as l}from"../../../../core/promiseUtils.js";import{isArrayBuffer as p,isUint8Array as d}from"../../../../core/typedArrayUtil.js";import{isBlobProtocol as _,isDataProtocol as c}from"../../../../core/urlUtils.js";import{requestImage as u}from"../../../../support/requestImageUtils.js";import{loadImageAsync as T}from"../../../../support/requestUtils.js";import{PowerOfTwoResizeMode as g}from"./basicInterfaces.js";import{estimateMemoryKTX2 as f,estimateMemoryBasis as w,createTextureKTX2 as E,createTextureBasis as A}from"./BasisUtil.js";import{ContentObject as x}from"./ContentObject.js";import{ContentObjectType as D}from"./ContentObjectType.js";import{createDDSTexture as I}from"./DDSUtil.js";import{createQuadVAO as M}from"./glUtil3D.js";import{assert as F}from"./Util.js";import{TextureWrapMode as O,TextureType as N,PixelFormat as y,PixelType as R,TextureSamplingMode as U,TargetType as C,DepthStencilTargetType as b,PrimitiveType as P}from"../../../webgl/enums.js";import{FramebufferObject as S}from"../../../webgl/FramebufferObject.js";import{Texture as H}from"../../../webgl/Texture.js";import{vertexCount as V}from"../../../webgl/Util.js";import j from"../../../webgl/capabilities/isWebGL2Context.js";class L extends x{constructor(t,e){super(),this.data=t,this.type=D.Texture,this._glTexture=null,this._powerOfTwoStretchInfo=null,this._loadingPromise=null,this._loadingController=null,this.events=new r,this.params=e||{},this.params.mipmap=!1!==this.params.mipmap,this.params.noUnpackFlip=this.params.noUnpackFlip||!1,this.params.preMultiplyAlpha=this.params.preMultiplyAlpha||!1,this.params.wrap=this.params.wrap||{s:O.REPEAT,t:O.REPEAT},this.params.powerOfTwoResizeMode=this.params.powerOfTwoResizeMode||g.STRETCH,this.estimatedTexMemRequired=L._estimateTexMemRequired(this.data,this.params),this._startPreload()}_startPreload(){const t=this.data;a(t)||(t instanceof HTMLVideoElement?this._startPreloadVideoElement(t):t instanceof HTMLImageElement&&this._startPreloadImageElement(t))}_startPreloadVideoElement(t){_(t.src)||"auto"===t.preload&&t.crossOrigin||(t.preload="auto",t.crossOrigin="anonymous",t.src=t.src)}_startPreloadImageElement(t){c(t.src)||_(t.src)||t.crossOrigin||(t.crossOrigin="anonymous",t.src=t.src)}static _getDataDimensions(t){return t instanceof HTMLVideoElement?{width:t.videoWidth,height:t.videoHeight}:t}static _estimateTexMemRequired(t,e){if(a(t))return 0;if(p(t)||d(t))return e.encoding===L.KTX2_ENCODING?f(t,e.mipmap):e.encoding===L.BASIS_ENCODING?w(t,e.mipmap):t.byteLength;const{width:r,height:i}=t instanceof Image||t instanceof ImageData||t instanceof HTMLCanvasElement||t instanceof HTMLVideoElement?L._getDataDimensions(t):e;return(e.mipmap?4/3:1)*r*i*(e.components||4)||0}dispose(){this.data=void 0}get width(){return this.params.width}get height(){return this.params.height}_createDescriptor(t){var e;return{target:N.TEXTURE_2D,pixelFormat:y.RGBA,dataType:R.UNSIGNED_BYTE,wrapMode:this.params.wrap,flipped:!this.params.noUnpackFlip,samplingMode:this.params.mipmap?U.LINEAR_MIPMAP_LINEAR:U.LINEAR,hasMipmap:this.params.mipmap,preMultiplyAlpha:this.params.preMultiplyAlpha,maxAnisotropy:null!=(e=this.params.maxAnisotropy)?e:this.params.mipmap?t.parameters.maxMaxAnisotropy:1}}get glTexture(){return this._glTexture}load(t,e){if(o(this._glTexture))return this._glTexture;if(o(this._loadingPromise))return this._loadingPromise;const r=this.data;return a(r)?(this._glTexture=new H(t,this._createDescriptor(t),null),this._glTexture):"string"==typeof r?this._loadFromURL(t,e,r):r instanceof Image?this._loadFromImageElement(t,e,r):r instanceof HTMLVideoElement?this._loadFromVideoElement(t,e,r):r instanceof ImageData||r instanceof HTMLCanvasElement?this._loadFromImage(t,r,e):(p(r)||d(r))&&this.params.encoding===L.DDS_ENCODING?this._loadFromDDSData(t,r):(p(r)||d(r))&&this.params.encoding===L.KTX2_ENCODING?this._loadFromKTX2(t,r):(p(r)||d(r))&&this.params.encoding===L.BASIS_ENCODING?this._loadFromBasis(t,r):d(r)?this._loadFromPixelData(t,r):p(r)?this._loadFromPixelData(t,new Uint8Array(r)):null}get requiresFrameUpdates(){return this.data instanceof HTMLVideoElement}frameUpdate(t,e,r){if(!(this.data instanceof HTMLVideoElement)||a(this._glTexture))return r;if(this.data.readyState<G.HAVE_CURRENT_DATA||r===this.data.currentTime)return r;if(o(this._powerOfTwoStretchInfo)){const{framebuffer:r,vao:i,sourceTexture:s}=this._powerOfTwoStretchInfo;s.setData(this.data),this._drawStretchedTexture(t,e,r,i,s,this._glTexture)}else{const{width:t,height:e}=this.data,{width:r,height:i}=this._glTexture.descriptor;t!==r||e!==i?this._glTexture.updateData(0,0,0,Math.min(t,r),Math.min(e,i),this.data):this._glTexture.setData(this.data)}return this._glTexture.descriptor.hasMipmap&&this._glTexture.generateMipmap(),this.data.currentTime}_loadFromDDSData(t,e){return this._glTexture=I(t,this._createDescriptor(t),e),this._glTexture}_loadFromKTX2(t,e){return this._loadAsync((()=>E(t,this._createDescriptor(t),e).then((t=>(this._glTexture=t,t)))))}_loadFromBasis(t,e){return this._loadAsync((()=>A(t,this._createDescriptor(t),e).then((t=>(this._glTexture=t,t)))))}_loadFromPixelData(t,e){F(this.params.width>0&&this.params.height>0);const r=this._createDescriptor(t);return r.pixelFormat=1===this.params.components?y.LUMINANCE:3===this.params.components?y.RGB:y.RGBA,r.width=this.params.width,r.height=this.params.height,this._glTexture=new H(t,r,e),this._glTexture}_loadFromURL(t,e,r){return this._loadAsync((async i=>{const s=await u(r,{signal:i});return m(i),this._loadFromImage(t,s,e)}))}_loadFromImageElement(t,e,r){return r.complete?this._loadFromImage(t,r,e):this._loadAsync((async i=>{const s=await T(r,r.src,!1,i);return m(i),this._loadFromImage(t,s,e)}))}_loadFromVideoElement(t,e,r){return r.readyState>=G.HAVE_CURRENT_DATA?this._loadFromImage(t,r,e):this._loadFromVideoElementAsync(t,e,r)}_loadFromVideoElementAsync(t,r,i){return this._loadAsync((s=>new Promise(((a,o)=>{const m=()=>{i.removeEventListener("loadeddata",p),i.removeEventListener("error",d),n(_)},p=()=>{i.readyState>=G.HAVE_CURRENT_DATA&&(m(),a(this._loadFromImage(t,i,r)))},d=t=>{m(),o(t||new e("Failed to load video"))};i.addEventListener("loadeddata",p),i.addEventListener("error",d);const _=h(s,(()=>d(l())))}))))}_loadFromImage(t,e,r){const s=L._getDataDimensions(e);this.params.width=s.width,this.params.height=s.height;const a=this._createDescriptor(t);return a.pixelFormat=3===this.params.components?y.RGB:y.RGBA,!this._requiresPowerOfTwo(t,a)||i(s.width)&&i(s.height)?(a.width=s.width,a.height=s.height,this._glTexture=new H(t,a,e),this._glTexture):(this._glTexture=this._makePowerOfTwoTexture(t,e,s,a,r),this._glTexture)}_loadAsync(t){const e=new AbortController;this._loadingController=e;const r=t(e.signal);this._loadingPromise=r;const i=()=>{this._loadingController===e&&(this._loadingController=null),this._loadingPromise===r&&(this._loadingPromise=null)};return r.then(i,i),r}_requiresPowerOfTwo(t,e){const r=O.CLAMP_TO_EDGE,i="number"==typeof e.wrapMode?e.wrapMode===r:e.wrapMode.s===r&&e.wrapMode.t===r;return!j(t.gl)&&(e.hasMipmap||!i)}_makePowerOfTwoTexture(e,r,i,a,o){const{width:n,height:m}=i,h=s(n),l=s(m);let p;switch(a.width=h,a.height=l,this.params.powerOfTwoResizeMode){case g.PAD:a.textureCoordinateScaleFactor=[n/h,m/l],p=new H(e,a),p.updateData(0,0,0,n,m,r);break;case g.STRETCH:case null:case void 0:p=this._stretchToPowerOfTwo(e,r,a,o());break;default:t(this.params.powerOfTwoResizeMode)}return a.hasMipmap&&p.generateMipmap(),p}_stretchToPowerOfTwo(t,e,r,i){const s=new H(t,r),a=new S(t,{colorTarget:C.TEXTURE,depthStencilTarget:b.NONE},s),o=new H(t,{target:N.TEXTURE_2D,pixelFormat:r.pixelFormat,dataType:R.UNSIGNED_BYTE,wrapMode:O.CLAMP_TO_EDGE,samplingMode:U.LINEAR,flipped:!!r.flipped,maxAnisotropy:8,preMultiplyAlpha:r.preMultiplyAlpha},e),n=M(t),m=t.getBoundFramebufferObject();return this._drawStretchedTexture(t,i,a,n,o,s),this.requiresFrameUpdates?this._powerOfTwoStretchInfo={vao:n,sourceTexture:o,framebuffer:a}:(n.dispose(!0),o.dispose(),a.detachColorTexture(),a.dispose()),t.bindFramebuffer(m),s}_drawStretchedTexture(t,e,r,i,s,a){t.bindFramebuffer(r);const o=t.getViewport();t.setViewport(0,0,a.descriptor.width,a.descriptor.height);const n=t.useTechnique(e);n.setUniform4f("uColor",1,1,1,1),n.bindTexture(s,"tex"),t.bindVAO(i),t.drawArrays(P.TRIANGLE_STRIP,0,V(i,"geometry")),t.bindFramebuffer(null),t.setViewport(o.x,o.y,o.width,o.height)}unload(){if(o(this._powerOfTwoStretchInfo)){const{framebuffer:t,vao:e,sourceTexture:r}=this._powerOfTwoStretchInfo;e.dispose(!0),r.dispose(),t.dispose(),this._glTexture=null,this._powerOfTwoStretchInfo=null}if(o(this._glTexture)&&(this._glTexture.dispose(),this._glTexture=null),o(this._loadingController)){const t=this._loadingController;this._loadingController=null,this._loadingPromise=null,t.abort()}this.events.emit("unloaded")}}var G;L.DDS_ENCODING="image/vnd-ms.dds",L.KTX2_ENCODING="image/ktx2",L.BASIS_ENCODING="image/x.basis",function(t){t[t.HAVE_NOTHING=0]="HAVE_NOTHING",t[t.HAVE_METADATA=1]="HAVE_METADATA",t[t.HAVE_CURRENT_DATA=2]="HAVE_CURRENT_DATA",t[t.HAVE_FUTURE_DATA=3]="HAVE_FUTURE_DATA",t[t.HAVE_ENOUGH_DATA=4]="HAVE_ENOUGH_DATA"}(G||(G={}));export{L as Texture};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.23/esri/copyright.txt for details.
4
4
  */
5
- import{releaseMaybe as e,isNone as s}from"../../../../../core/maybe.js";import t from"../../../../../core/PooledArray.js";import{t as r,e as i,g as n}from"../../../../../chunks/mat3.js";import{c as o}from"../../../../../chunks/mat3f32.js";import{g as a,s as l}from"../../../../../chunks/vec3.js";import{c as h}from"../../../../../chunks/vec3f64.js";import c from"../../../support/debugFlags.js";import{ComponentDrawParameters as d}from"../../collections/Component/Material/ComponentTechnique.js";import{bindSliceUniforms as m}from"../../core/shaderLibrary/Slice.glsl.js";import{bindModelTransform as u}from"../../core/shaderLibrary/attributes/VertexPosition.glsl.js";import{bindMultipassTerrainTexture as f}from"../../core/shaderLibrary/shading/MultipassTerrainTest.glsl.js";import{doublePrecisionRequiresObfuscation as g}from"../../core/shaderLibrary/util/DoublePrecision.glsl.js";import{TwoVectorPosition as b}from"../../core/util/TwoVectorPosition.js";import{EdgeShaderTechniqueConfiguration as p,EdgeShaderTechnique as T}from"./EdgeShaderTechnique.js";import{Transparency as R}from"./interfaces.js";import{EdgeUtilMode as A}from"../../shaders/sources/edgeRenderer/EdgeUtil.glsl.js";import{PrimitiveType as P}from"../../../../webgl/enums.js";const E=8,S=128,y={type:"uber",slicePlaneEnabled:!1,sliceHighlightDisabled:!1,strokesTexture:null,legacy:!0};class N{constructor(){this._value=0}get value(){return this._value}increment(){this._value++}decrement(){this._value--}}const v={solid:A.SOLID,sketch:A.SKETCH,uber:A.MIXED};class x{constructor(e,s,r){this.rctx=e,this.shaderTechniqueRepository=s,this.config=new p,this.technique=null,this.refCount=new N,this.renderables=new Set,this.sortedRenderables={[R.TRANSPARENT]:{[R.TRANSPARENT]:new t,[R.OPAQUE]:new t},[R.OPAQUE]:{[R.TRANSPARENT]:new t,[R.OPAQUE]:new t}},this.renderablesDirty=!1,this.settings={...y,...r},this.key=x.getKey(this.settings.type,this.settings.slicePlaneEnabled,this.settings.legacy);const i=this.settings.strokesTexture.variants;this.writerSettings={variants:i,reducedPrecision:c.TESTS_DISABLE_OPTIMIZATIONS},this.config.legacy=this.settings.legacy,this.config.mode=v[this.settings.type],this.config.silhouette=!1,this.config.antialiasing=!!this.rctx.capabilities.blendMinMax,this.config.slicePlaneEnabled=this.settings.slicePlaneEnabled,this.config.doublePrecisionRequiresObfuscation=g(e)}dispose(){this.technique=e(this.technique)}addRenderable(e){this.renderables.add(e),this.renderablesDirty=!0}removeRenderable(e){this.renderables.delete(e),this.renderablesDirty=!0}setRenderablesDirty(){this.renderablesDirty=!0}forEachRenderable(e,s){this.renderablesDirty&&this._sortRenderables(),this.sortedRenderables[s][R.TRANSPARENT].forAll(e),this.sortedRenderables[s][R.OPAQUE].forAll(e)}setMultipassParameters(e){this.config.multipassTerrainEnabled=!!e.multipassTerrainEnabled&&e.multipassTerrainEnabled,this.config.cullAboveGround=!!e.cullAboveGround&&e.cullAboveGround}bindRegularEdges(e,s){this.setMultipassParameters(e),this.config.silhouette=!1,this.technique=this.shaderTechniqueRepository.releaseAndAcquire(T,this.config,this.technique),this.rctx.useProgram(this.technique.program),this.technique.bindPass({bindParameters:e,edgeRenderParameters:s}),this.technique.bindPipelineState(this.rctx,e.slot)}bindSilhouetteEdges(e,s){this.setMultipassParameters(e),this.config.silhouette=!0,this.technique=this.shaderTechniqueRepository.releaseAndAcquire(T,this.config,this.technique),this.rctx.useProgram(this.technique.program),this.technique.bindPass({bindParameters:e,edgeRenderParameters:s}),this.technique.bindPipelineState(this.rctx,e.slot)}renderRegularEdges(e,s,t){this._render(e,e.regular.vao,s,t)}renderSilhouetteEdges(e,s,t){this._render(e,e.silhouette.vao,s,t)}_render(e,s,t,r){this._setUniforms(e,t),this.rctx.bindVAO(s),this.rctx.capabilities.instancing.drawArraysInstanced(P.TRIANGLE_FAN,0,4,r)}_setUniforms(e,s){const t=this.technique.program;if(e.components.buffer.textureBuffer.bind(t,U,q),s.multipassTerrainEnabled&&(t.setUniform2fv("nearFar",s.camera.nearFar),t.setUniform2fv("inverseViewport",s.inverseViewport),f(t,s)),"origin"in e.transform)t.setUniformMatrix4fv("view",s.localViewMatrixForEdges),t.setUniformMatrix4fv("model",e.transform.modelMatrix),m(t,this.settings,s.slicePlane,e.transform.origin.vec3);else{const o=new b(e.transform.position),h=r(M,i(M,e.transform.rotationScale)),c=new d;a(c.transformWorldFromModelTL,o.low),a(c.transformWorldFromModelTH,o.high),n(c.transformWorldFromModelRS,e.transform.rotationScale),n(c.transformNormalGlobalFromModel,h),u(t,c),t.setUniformMatrix3fv("transformNormalGlobalFromModel",c.transformNormalGlobalFromModel);const f=s.camera.viewInverseTransposeMatrix,g=l(w,f[3],f[7],f[11]);m(t,this.settings,s.slicePlane,g)}"uber"!==this.settings.type&&"sketch"!==this.settings.type||this._setSketchUniforms(t)}_setSketchUniforms(e){const t=this.settings.strokesTexture,r=t.texture;s(r)||(e.bindTexture(r,"strokesTexture"),e.setUniform2f("strokesTextureScale",1/r.descriptor.width,1/r.descriptor.height),e.setUniform1f("strokesLog2Resolution",Math.log2(t.resolution)),e.setUniform1f("strokesNormalizationScale",t.normalizationScale),e.setUniform1f("strokesAmplitude",t.amplitude),e.setUniform1f("strokeVariants",t.variants))}_sortRenderables(){this.renderablesDirty=!1,this.sortedRenderables[R.TRANSPARENT][R.TRANSPARENT].clear(),this.sortedRenderables[R.TRANSPARENT][R.OPAQUE].clear(),this.sortedRenderables[R.OPAQUE][R.TRANSPARENT].clear(),this.sortedRenderables[R.OPAQUE][R.OPAQUE].clear(),this.renderables.forEach((e=>{e.objectTransparency!==R.INVISIBLE&&e.edgeTransparency!==R.INVISIBLE&&this.sortedRenderables[e.objectTransparency][e.edgeTransparency].push(e)}));const e=(e,s)=>"origin"in e.transform&&"origin"in s.transform?e.transform.origin.id<s.transform.origin.id?-1:e.transform.origin.id>s.transform.origin.id?1:0:0;this.sortedRenderables[R.TRANSPARENT][R.TRANSPARENT].sort(e),this.sortedRenderables[R.TRANSPARENT][R.OPAQUE].sort(e),this.sortedRenderables[R.OPAQUE][R.TRANSPARENT].sort(e),this.sortedRenderables[R.OPAQUE][R.OPAQUE].sort(e)}static getKey(e,s,t){return`edges-t:${e}:${s}:${t}`}}const U="componentDataTex",q="componentDataTexInvDim",M=o(),w=h();export{S as EXTENSION_LENGTH_OFFSET,x as EdgeRenderer,E as LINE_WIDTH_FRACTION_FACTOR,q as componentDataInvDimName,U as componentDataTexName};
5
+ import{releaseMaybe as e,isNone as s}from"../../../../../core/maybe.js";import t from"../../../../../core/PooledArray.js";import{t as r,e as i,g as n}from"../../../../../chunks/mat3.js";import{c as o}from"../../../../../chunks/mat3f32.js";import{g as a,s as l}from"../../../../../chunks/vec3.js";import{c as h}from"../../../../../chunks/vec3f64.js";import c from"../../../support/debugFlags.js";import{ComponentDrawParameters as d}from"../../collections/Component/Material/ComponentTechnique.js";import{bindSliceUniforms as m}from"../../core/shaderLibrary/Slice.glsl.js";import{bindModelTransform as u}from"../../core/shaderLibrary/attributes/VertexPosition.glsl.js";import{bindMultipassTerrainTexture as f}from"../../core/shaderLibrary/shading/MultipassTerrainTest.glsl.js";import{doublePrecisionRequiresObfuscation as g}from"../../core/shaderLibrary/util/DoublePrecision.glsl.js";import{TwoVectorPosition as b}from"../../core/util/TwoVectorPosition.js";import{EdgeShaderTechniqueConfiguration as T,EdgeShaderTechnique as p}from"./EdgeShaderTechnique.js";import{Transparency as R}from"./interfaces.js";import{EdgeUtilMode as A}from"../../shaders/sources/edgeRenderer/EdgeUtil.glsl.js";import{PrimitiveType as E}from"../../../../webgl/enums.js";const P=8,S=128,y={type:"uber",slicePlaneEnabled:!1,sliceHighlightDisabled:!1,strokesTexture:null,legacy:!0};class N{constructor(){this._value=0}get value(){return this._value}increment(){this._value++}decrement(){this._value--}}const v={solid:A.SOLID,sketch:A.SKETCH,uber:A.MIXED};class U{constructor(e,s,r){this.rctx=e,this.shaderTechniqueRepository=s,this.config=new T,this.technique=null,this.refCount=new N,this.renderables=new Set,this.sortedRenderables={[R.TRANSPARENT]:{[R.TRANSPARENT]:new t,[R.OPAQUE]:new t},[R.OPAQUE]:{[R.TRANSPARENT]:new t,[R.OPAQUE]:new t}},this.renderablesDirty=!1,this.settings={...y,...r},this.key=U.getKey(this.settings.type,this.settings.slicePlaneEnabled,this.settings.legacy);const i=this.settings.strokesTexture.variants;this.writerSettings={variants:i,reducedPrecision:c.TESTS_DISABLE_OPTIMIZATIONS},this.config.legacy=this.settings.legacy,this.config.mode=v[this.settings.type],this.config.silhouette=!1,this.config.antialiasing=!!this.rctx.capabilities.blendMinMax,this.config.slicePlaneEnabled=this.settings.slicePlaneEnabled,this.config.doublePrecisionRequiresObfuscation=g(e)}dispose(){this.technique=e(this.technique)}addRenderable(e){this.renderables.add(e),this.renderablesDirty=!0}removeRenderable(e){this.renderables.delete(e),this.renderablesDirty=!0}setRenderablesDirty(){this.renderablesDirty=!0}forEachRenderable(e,s){this.renderablesDirty&&this._sortRenderables(),this.sortedRenderables[s][R.TRANSPARENT].forAll(e),this.sortedRenderables[s][R.OPAQUE].forAll(e)}setMultipassParameters(e){this.config.multipassTerrainEnabled=!!e.multipassTerrainEnabled&&e.multipassTerrainEnabled,this.config.cullAboveGround=!!e.cullAboveGround&&e.cullAboveGround}bindRegularEdges(e,s){this.setMultipassParameters(e),this.config.silhouette=!1,this.technique=this.shaderTechniqueRepository.releaseAndAcquire(p,this.config,this.technique),this.rctx.useTechnique(this.technique,e.slot),this.technique.bindPass({bindParameters:e,edgeRenderParameters:s})}bindSilhouetteEdges(e,s){this.setMultipassParameters(e),this.config.silhouette=!0,this.technique=this.shaderTechniqueRepository.releaseAndAcquire(p,this.config,this.technique),this.rctx.useTechnique(this.technique,e.slot),this.technique.bindPass({bindParameters:e,edgeRenderParameters:s})}renderRegularEdges(e,s,t){this._render(e,e.regular.vao,s,t)}renderSilhouetteEdges(e,s,t){this._render(e,e.silhouette.vao,s,t)}_render(e,s,t,r){this._setUniforms(e,t),this.rctx.bindVAO(s),this.rctx.capabilities.instancing.drawArraysInstanced(E.TRIANGLE_FAN,0,4,r)}_setUniforms(e,s){const t=this.technique.program;if(e.components.buffer.textureBuffer.bind(t,x,q),s.multipassTerrainEnabled&&(t.setUniform2fv("nearFar",s.camera.nearFar),t.setUniform2fv("inverseViewport",s.inverseViewport),f(t,s)),"origin"in e.transform)t.setUniformMatrix4fv("view",s.localViewMatrixForEdges),t.setUniformMatrix4fv("model",e.transform.modelMatrix),m(t,this.settings,s.slicePlane,e.transform.origin.vec3);else{const o=new b(e.transform.position),h=r(M,i(M,e.transform.rotationScale)),c=new d;a(c.transformWorldFromModelTL,o.low),a(c.transformWorldFromModelTH,o.high),n(c.transformWorldFromModelRS,e.transform.rotationScale),n(c.transformNormalGlobalFromModel,h),u(t,c),t.setUniformMatrix3fv("transformNormalGlobalFromModel",c.transformNormalGlobalFromModel);const f=s.camera.viewInverseTransposeMatrix,g=l(w,f[3],f[7],f[11]);m(t,this.settings,s.slicePlane,g)}"uber"!==this.settings.type&&"sketch"!==this.settings.type||this._setSketchUniforms(t)}_setSketchUniforms(e){const t=this.settings.strokesTexture,r=t.texture;s(r)||(e.bindTexture(r,"strokesTexture"),e.setUniform2f("strokesTextureScale",1/r.descriptor.width,1/r.descriptor.height),e.setUniform1f("strokesLog2Resolution",Math.log2(t.resolution)),e.setUniform1f("strokesNormalizationScale",t.normalizationScale),e.setUniform1f("strokesAmplitude",t.amplitude),e.setUniform1f("strokeVariants",t.variants))}_sortRenderables(){this.renderablesDirty=!1,this.sortedRenderables[R.TRANSPARENT][R.TRANSPARENT].clear(),this.sortedRenderables[R.TRANSPARENT][R.OPAQUE].clear(),this.sortedRenderables[R.OPAQUE][R.TRANSPARENT].clear(),this.sortedRenderables[R.OPAQUE][R.OPAQUE].clear(),this.renderables.forEach((e=>{e.objectTransparency!==R.INVISIBLE&&e.edgeTransparency!==R.INVISIBLE&&this.sortedRenderables[e.objectTransparency][e.edgeTransparency].push(e)}));const e=(e,s)=>"origin"in e.transform&&"origin"in s.transform?e.transform.origin.id<s.transform.origin.id?-1:e.transform.origin.id>s.transform.origin.id?1:0:0;this.sortedRenderables[R.TRANSPARENT][R.TRANSPARENT].sort(e),this.sortedRenderables[R.TRANSPARENT][R.OPAQUE].sort(e),this.sortedRenderables[R.OPAQUE][R.TRANSPARENT].sort(e),this.sortedRenderables[R.OPAQUE][R.OPAQUE].sort(e)}static getKey(e,s,t){return`edges-t:${e}:${s}:${t}`}}const x="componentDataTex",q="componentDataTexInvDim",M=o(),w=h();export{S as EXTENSION_LENGTH_OFFSET,U as EdgeRenderer,P as LINE_WIDTH_FRACTION_FACTOR,q as componentDataInvDimName,x as componentDataTexName};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.23/esri/copyright.txt for details.
4
4
  */
5
- import{isNone as e}from"../../../../../core/maybe.js";import{isAborted as t,throwIfAborted as s}from"../../../../../core/promiseUtils.js";import{I as a,c as n}from"../../../../../chunks/mat4f64.js";import{a as i}from"../../../../../chunks/vec2f64.js";import{f as r,d as l,m as o}from"../../../../../chunks/vec3.js";import{c}from"../../../../../chunks/vec3f64.js";import{c as h}from"../../../../../chunks/vec4f64.js";import d from"../../../support/debugFlags.js";import{glLayout as u}from"../../../support/buffer/glUtil.js";import{bindOutputHighlight as _}from"../../core/shaderLibrary/output/OutputHighlight.glsl.js";import m from"../Camera.js";import{Default3D as p}from"../DefaultVertexAttributeLocations.js";import{IntersectorType as f}from"../IntersectorInterfaces.js";import{DepthOrder as g}from"../Octree.js";import{RenderPass as I}from"../RenderPass.js";import{RenderSlot as D}from"../RenderSlot.js";import{assert as v}from"../Util.js";import{InstanceData as y,StateFlags as E}from"./InstanceData.js";import{InstanceOctree as T}from"./InstanceOctree.js";import{LevelSelector as R}from"./LevelSelector.js";import{LodLevel as A}from"./LodLevel.js";import{RenderInstanceData as C}from"./RenderInstanceData.js";import{getInstanceBufferLayout as b}from"../../materials/DefaultMaterial.js";import{colorMixModes as L}from"../../materials/internal/MaterialUtil.js";import{encodeDoubleVec3 as S}from"../../materials/renderers/utils.js";import{bindVertexBufferLayout as U,unbindVertexBufferLayout as x}from"../../../../webgl/Util.js";let P=function(e){const t=e.baseBoundingSphere.radius,s=e.levels.map((e=>e.minScreenSpaceRadius));return new R(t,s)};function O(e){P=e}class H{constructor(e,t,s,a){this.type=f.LOD,this.isGround=!1,this._inverseViewport=i(),this._levels=[],this._defaultRenderInstanceData=[],this._highlightRenderInstanceData=[],this._instanceIndex=0,this._slicePlane=!1,this._enableLevelSelection=!0,this._lastCamera=new m,this._updateCyclesWithStaticCamera=-1,this._needFullCycle=!1,this.slots=[D.OPAQUE_PLUGIN,D.TRANSPARENT_PLUGIN],this.canRender=!0,this._symbol=e,this._optionalFields=t,this._metadata=s,this._instanceBufferLayout=b({instancedDoublePrecision:!0,instanced:t}),this._glInstanceBufferLayout=u(this._instanceBufferLayout,1),this._instanceData=new y(this._optionalFields,a),this._instanceData.on("instance-added",(()=>this._requestUpdateCycle())),this._instanceData.on("instance-removed",(()=>this._requestUpdateCycle())),this._instanceData.on("instance-transform-changed",(e=>{this._requestUpdateCycle(),this._metadata.notifyGraphicGeometryChanged(e.index)})),this._instanceData.on("instance-visibility-changed",(e=>{this._requestUpdateCycle(!0),this._metadata.notifyGraphicVisibilityChanged(e.index)})),this._instanceData.on("instance-highlight-changed",(()=>this._requestUpdateCycle(!0))),this._enableLevelSelection=this._symbol.levels.length>1}get levels(){return this._levels}get baseBoundingBox(){return this._levels[this._levels.length-1].boundingBox}get baseBoundingSphere(){return this._levels[this._levels.length-1].boundingSphere}get baseMaterial(){return this._levels[this._levels.length-1].components[0].material}get slicePlaneEnabled(){return this._slicePlane}set slicePlaneEnabled(e){this._slicePlane=e}get layerUid(){return this._metadata.layerUid}get instanceData(){return this._instanceData}get memoryUsage(){const e={cpu:0,gpu:0};return this._defaultRenderInstanceData.forEach((t=>{const s=t.memoryUsage;e.cpu+=s.cpu,e.gpu+=s.gpu})),this._highlightRenderInstanceData.forEach((t=>{const s=t.memoryUsage;e.cpu+=s.cpu,e.gpu+=s.gpu})),e}get renderStats(){const e=this._instanceData.size,t=[];return this._levels.forEach(((e,s)=>{const a=this._defaultRenderInstanceData[s],n=this._highlightRenderInstanceData[s],i=a.size+n.size,r=e.triangleCount;t.push({renderedInstances:i,renderedTriangles:i*r,trianglesPerInstance:r})})),{totalInstances:e,renderedInstances:t.reduce(((e,t)=>e+t.renderedInstances),0),renderedTriangles:t.reduce(((e,t)=>e+t.renderedTriangles),0),levels:t}}async initializeRenderContext(e,a){this._context=e;const n=e.renderContext.rctx,i=await Promise.allSettled(this._symbol.levels.map((t=>(this._defaultRenderInstanceData.push(new C(n,this._instanceBufferLayout)),this._highlightRenderInstanceData.push(new C(n,this._instanceBufferLayout)),A.create(e,t,a))))),r=i.map((e=>"fulfilled"===e.status?e.value:null)).filter((e=>e));if(t(a)||r.length!==i.length){r.forEach((e=>e.destroy())),s(a);for(const e of i)if("rejected"===e.status)throw e.reason}this._levels=r,this._levelSelector=P(this)}uninitializeRenderContext(){this._invalidateOctree(),this._levels.forEach((e=>e.destroy())),this._defaultRenderInstanceData.forEach((e=>e.destroy())),this._highlightRenderInstanceData.forEach((e=>e.destroy()))}get needsTransparentPass(){return this._levels.some((e=>e.components.some((e=>e.material.requiresSlot(D.TRANSPARENT_MATERIAL)))))}get needsHighlight(){return this._highlightRenderInstanceData.some((e=>e.size>0))}prepareRender(e,t){if(d.LOD_INSTANCE_RENDERER_DISABLE_UPDATES)return;if(this._enableLevelSelection){const e=t.equals(this._lastCamera);this._lastCamera.copyFrom(t),e||this._requestUpdateCycle()}const s=this._needFullCycle?this._instanceData.size:2e3;this._needFullCycle=!1,this._updateInstances(t,s),this.needsUpdates&&this._context.requestRender()}render(e){var t,s,n,i;const r=e.slot===D.OPAQUE_PLUGIN?D.OPAQUE_MATERIAL:e.slot===D.TRANSPARENT_PLUGIN?D.TRANSPARENT_MATERIAL:null;if(!r||!this.baseMaterial.isVisible()||!this.baseMaterial.isVisibleInPass(e.pass))return;const l=e.camera;this._inverseViewport[0]=1/l.fullViewport[2],this._inverseViewport[1]=1/l.fullViewport[3];const o={slot:r,origin:[0,0,0],camera:l,inverseViewport:this._inverseViewport,shadowMap:e.shadowMap,shadowMappingEnabled:e.shadowMap.enabled,ssaoHelper:e.ssaoHelper,ssaoEnabled:e.ssaoHelper.enabled,screenToWorldRatio:null,screenToPCSRatio:null,slicePlane:e.sliceHelper&&e.sliceHelper.plane,hudVisibilityTexture:null!=(t=null==(s=e.offscreenRenderingHelper)?void 0:s.hudVisibilityTexture)?t:null,highlightDepthTexture:null!=(n=null==(i=e.offscreenRenderingHelper)?void 0:i.depthTexture)?n:null,hasOccludees:!1,linearDepthTexture:null,lastFrameColorTexture:null,reprojectionMatrix:a,ssrEnabled:!1,lighting:e.scenelightingData,transparencyPassType:e.transparencyPassType,terrainLinearDepthTexture:e.multipassTerrainParams.terrainLinearDepthTexture,geometryLinearDepthTexture:e.multipassGeometryParams.geometryLinearDepthTexture,multipassTerrainEnabled:e.multipassTerrainParams.multipassTerrainEnabled,cullAboveGround:e.multipassTerrainParams.cullAboveGround,multipassGeometryEnabled:e.multipassGeometryParams.multipassGeometryEnabled,highlightColorTexture:null,cloudsCompositionParams:null};e.rctx.bindVAO();const c=e.pass!==I.MATERIAL_HIGHLIGHT&&e.pass!==I.MATERIAL_DEPTH_SHADOWMAP_HIGHLIGHT,h=e.pass!==I.MATERIAL_DEPTH_SHADOWMAP_DEFAULT;c&&this._renderComponents(e,r,o,this._defaultRenderInstanceData),h&&this._renderComponents(e,r,o,this._highlightRenderInstanceData)}intersect(e,t,s,a){if(!this.baseMaterial.isVisible())return;const n=c();r(n,a,s);const i=n=>{this._instanceData.getCombinedModelTransform(n,N),e.transform.set(N),o(G,s,e.transform.inverse),o(F,a,e.transform.inverse);const i=this._instanceData.getState(n),r=this._instanceData.getLodLevel(n);v(i&E.ACTIVE,"invalid instance state"),v(r>=0&&r<this._levels.length,"invaid lod level"),this._levels[r].intersect(e,t,G,F,n,this._metadata)};this.baseMaterial.parameters.verticalOffset?this.octree.forEach(i):this.octree.forEachAlongRay(s,n,i)}queryDepthRange(e){return this._queryDepthRangeOctree(e)}notifyShaderTransformationChanged(){this._invalidateOctree()}_requestUpdateCycle(e=!1){this._updateCyclesWithStaticCamera=-1,e&&(this._needFullCycle=!0),this.needsUpdates&&this._context.requestRender()}get needsUpdates(){return this._instanceData.size>0&&this._updateCyclesWithStaticCamera<1}get octree(){return this._octree||(this._octree=this._buildOctree()),this._octree}_invalidateOctree(){this._octree&&(this._octree.destroy(),this._octree=null)}_buildOctree(){const e=new T(this._instanceData,this.baseBoundingSphere),t=this._instanceData,s=t.view?t.view.state:null;for(let a=0;a<this._instanceData.capacity;++a){s.get(a)&E.ACTIVE&&e.addInstance(a)}return e}_queryDepthRangeOctree(e){const t=e.eye,s=e.viewForward,a=this.octree.findClosest(s,g.FRONT_TO_BACK,e.frustum),n=this.octree.findClosest(s,g.BACK_TO_FRONT,e.frustum);if(null!=a&&null!=n){this._instanceData.view.boundingSphere.getVec(a,j),r(j,j,t);const i=l(j,s)-j[3];this._instanceData.view.boundingSphere.getVec(n,j),r(j,j,t);const o=l(j,s)+j[3];return{near:Math.max(e.near,i),far:Math.min(e.far,o)}}return{near:1/0,far:-1/0}}_startUpdateCycle(){this._updateCyclesWithStaticCamera++,this._defaultRenderInstanceData.forEach((e=>{e.startUpdateCylce()})),this._highlightRenderInstanceData.forEach((e=>{e.startUpdateCylce()})),this.needsUpdates&&this._context.requestRender()}_updateInstances(e,t){const s=this._enableLevelSelection,a=this._levelSelector;a.updateCamera(e),this._defaultRenderInstanceData.forEach((e=>{e.beginUpdate()})),this._highlightRenderInstanceData.forEach((e=>{e.beginUpdate()}));const n=this._instanceData,i=this._instanceData.view,r=n.size,l=n.capacity;let o=this._instanceIndex;t=Math.min(r,t);for(let c=0;c<t;++c){0===o&&this._startUpdateCycle();const e=i.state.get(o);let r=0;if(!(e&E.ALLOCATED)){o=(o+1)%l,t++;continue}const c=i.lodLevel.get(o);if(e&E.DEFAULT_ACTIVE&&this._defaultRenderInstanceData[c].freeTail(),e&E.HIGHLIGHT_ACTIVE&&this._highlightRenderInstanceData[c].freeTail(),e&E.REMOVE)n.freeInstance(o);else if(e&E.VISIBLE){let t=0;s&&(i.modelOrigin.getVec(o,w),t=a.selectLevel(w,n.getCombinedMedianScaleFactor(o))),r=e&~(E.ACTIVE|E.TRANSFORM_CHANGED),t>=0&&(e&E.HIGHLIGHT?(M(this._highlightRenderInstanceData[t],i,o),r|=E.HIGHLIGHT_ACTIVE):(M(this._defaultRenderInstanceData[t],i,o),r|=E.DEFAULT_ACTIVE)),i.state.set(o,r),i.lodLevel.set(o,t)}else r=e&~(E.ACTIVE|E.TRANSFORM_CHANGED),i.state.set(o,r);if(this._octree){const t=!!(e&E.ACTIVE),s=!!(r&E.ACTIVE);!t&&s?this._octree.addInstance(o):t&&!s?this._octree.removeInstance(o):t&&s&&e&E.TRANSFORM_CHANGED&&(this._octree.removeInstance(o),this._octree.addInstance(o))}o=(o+1)%l}this._instanceIndex=o,this._defaultRenderInstanceData.forEach((e=>{e.endUpdate()})),this._highlightRenderInstanceData.forEach((e=>{e.endUpdate()}))}_renderComponents(e,t,s,a){this.levels.forEach(((n,i)=>{n.components.forEach((n=>{this._renderComponent(e,t,s,a[i],n,i)}))}))}_renderComponent(t,s,a,n,i,r){if(0===n.size||!i.material.requiresSlot(s))return;const{rctx:l,pass:o}=t,c=i.glMaterials.load(l,o);if(e(c))return;const h=l.capabilities.instancing,u=c.beginSlot(a),m=u.program;u.bindPipelineState(l,s),l.useProgram(m),c.bind(a,u),l.bindVAO(i.vao),u.ensureAttributeLocations(i.vao),t.isHighlightPass&&_(m,a),u.bindDraw(a),d.LOD_INSTANCE_RENDERER_COLORIZE_BY_LEVEL&&t.pass===I.MATERIAL&&(m.setUniform4fv("externalColor",B[Math.min(r,B.length-1)]),m.setUniform1i("colorMixMode",L.replace));const f=n.capacity,g=n.headIndex,D=n.tailIndex,y=n.firstIndex,E=this._glInstanceBufferLayout,T=(e,t)=>{U(l,p,n.buffer,E,e),h.drawArraysInstanced(u.primitiveType,0,i.vertexCount,t-e),x(l,p,n.buffer,E)};i.material.parameters.transparent&&null!=y?g>D?(v(y>=D&&y<=g,"invalid firstIndex"),T(y,g),T(D,y)):g<D&&(y<=g?(v(y>=0&&y<=g,"invalid firstIndex"),T(y,g),T(D,f),T(0,y)):(v(y>=D&&y<=f,"invalid firstIndex"),T(y,f),T(0,g),T(D,y))):g>D?T(D,g):g<D&&(T(0,g),T(D,f)),l.bindVAO(null)}}function M(e,t,s){const a=e.allocateHead();V(t,s,e.view,a)}function V(e,t,s,a){S(e.modelOrigin,t,s.modelOriginHi,s.modelOriginLo,a),s.model.copyFrom(a,e.model,t),s.modelNormal.copyFrom(a,e.modelNormal,t),e.color&&s.color&&s.color.copyFrom(a,e.color,t),e.featureAttribute&&s.featureAttribute&&s.featureAttribute.copyFrom(a,e.featureAttribute,t)}const w=c(),j=h(),N=n(),G=c(),F=c(),B=[[1,0,1,1],[0,0,1,1],[0,1,0,1],[1,1,0,1],[1,0,0,1]];export{H as LodRenderer,O as setLevelSelectorFactory};
5
+ import{isNone as e}from"../../../../../core/maybe.js";import{isAborted as t,throwIfAborted as s}from"../../../../../core/promiseUtils.js";import{I as a,c as n}from"../../../../../chunks/mat4f64.js";import{a as i}from"../../../../../chunks/vec2f64.js";import{f as r,d as l,m as o}from"../../../../../chunks/vec3.js";import{c}from"../../../../../chunks/vec3f64.js";import{c as h}from"../../../../../chunks/vec4f64.js";import d from"../../../support/debugFlags.js";import{glLayout as u}from"../../../support/buffer/glUtil.js";import{bindOutputHighlight as _}from"../../core/shaderLibrary/output/OutputHighlight.glsl.js";import m from"../Camera.js";import{Default3D as p}from"../DefaultVertexAttributeLocations.js";import{IntersectorType as f}from"../IntersectorInterfaces.js";import{DepthOrder as g}from"../Octree.js";import{RenderPass as I}from"../RenderPass.js";import{RenderSlot as D}from"../RenderSlot.js";import{assert as T}from"../Util.js";import{InstanceData as v,StateFlags as y}from"./InstanceData.js";import{InstanceOctree as E}from"./InstanceOctree.js";import{LevelSelector as R}from"./LevelSelector.js";import{LodLevel as A}from"./LodLevel.js";import{RenderInstanceData as C}from"./RenderInstanceData.js";import{getInstanceBufferLayout as b}from"../../materials/DefaultMaterial.js";import{colorMixModes as L}from"../../materials/internal/MaterialUtil.js";import{encodeDoubleVec3 as S}from"../../materials/renderers/utils.js";import{bindVertexBufferLayout as U,unbindVertexBufferLayout as x}from"../../../../webgl/Util.js";let O=function(e){const t=e.baseBoundingSphere.radius,s=e.levels.map((e=>e.minScreenSpaceRadius));return new R(t,s)};function P(e){O=e}class H{constructor(e,t,s,a){this.type=f.LOD,this.isGround=!1,this._inverseViewport=i(),this._levels=[],this._defaultRenderInstanceData=[],this._highlightRenderInstanceData=[],this._instanceIndex=0,this._slicePlane=!1,this._enableLevelSelection=!0,this._lastCamera=new m,this._updateCyclesWithStaticCamera=-1,this._needFullCycle=!1,this.slots=[D.OPAQUE_PLUGIN,D.TRANSPARENT_PLUGIN],this.canRender=!0,this._symbol=e,this._optionalFields=t,this._metadata=s,this._instanceBufferLayout=b({instancedDoublePrecision:!0,instanced:t}),this._glInstanceBufferLayout=u(this._instanceBufferLayout,1),this._instanceData=new v(this._optionalFields,a),this._instanceData.on("instance-added",(()=>this._requestUpdateCycle())),this._instanceData.on("instance-removed",(()=>this._requestUpdateCycle())),this._instanceData.on("instance-transform-changed",(e=>{this._requestUpdateCycle(),this._metadata.notifyGraphicGeometryChanged(e.index)})),this._instanceData.on("instance-visibility-changed",(e=>{this._requestUpdateCycle(!0),this._metadata.notifyGraphicVisibilityChanged(e.index)})),this._instanceData.on("instance-highlight-changed",(()=>this._requestUpdateCycle(!0))),this._enableLevelSelection=this._symbol.levels.length>1}get levels(){return this._levels}get baseBoundingBox(){return this._levels[this._levels.length-1].boundingBox}get baseBoundingSphere(){return this._levels[this._levels.length-1].boundingSphere}get baseMaterial(){return this._levels[this._levels.length-1].components[0].material}get slicePlaneEnabled(){return this._slicePlane}set slicePlaneEnabled(e){this._slicePlane=e}get layerUid(){return this._metadata.layerUid}get instanceData(){return this._instanceData}get memoryUsage(){const e={cpu:0,gpu:0};return this._defaultRenderInstanceData.forEach((t=>{const s=t.memoryUsage;e.cpu+=s.cpu,e.gpu+=s.gpu})),this._highlightRenderInstanceData.forEach((t=>{const s=t.memoryUsage;e.cpu+=s.cpu,e.gpu+=s.gpu})),e}get renderStats(){const e=this._instanceData.size,t=[];return this._levels.forEach(((e,s)=>{const a=this._defaultRenderInstanceData[s],n=this._highlightRenderInstanceData[s],i=a.size+n.size,r=e.triangleCount;t.push({renderedInstances:i,renderedTriangles:i*r,trianglesPerInstance:r})})),{totalInstances:e,renderedInstances:t.reduce(((e,t)=>e+t.renderedInstances),0),renderedTriangles:t.reduce(((e,t)=>e+t.renderedTriangles),0),levels:t}}async initializeRenderContext(e,a){this._context=e;const n=e.renderContext.rctx,i=await Promise.allSettled(this._symbol.levels.map((t=>(this._defaultRenderInstanceData.push(new C(n,this._instanceBufferLayout)),this._highlightRenderInstanceData.push(new C(n,this._instanceBufferLayout)),A.create(e,t,a))))),r=i.map((e=>"fulfilled"===e.status?e.value:null)).filter((e=>e));if(t(a)||r.length!==i.length){r.forEach((e=>e.destroy())),s(a);for(const e of i)if("rejected"===e.status)throw e.reason}this._levels=r,this._levelSelector=O(this)}uninitializeRenderContext(){this._invalidateOctree(),this._levels.forEach((e=>e.destroy())),this._defaultRenderInstanceData.forEach((e=>e.destroy())),this._highlightRenderInstanceData.forEach((e=>e.destroy()))}get needsTransparentPass(){return this._levels.some((e=>e.components.some((e=>e.material.requiresSlot(D.TRANSPARENT_MATERIAL)))))}get needsHighlight(){return this._highlightRenderInstanceData.some((e=>e.size>0))}prepareRender(e,t){if(d.LOD_INSTANCE_RENDERER_DISABLE_UPDATES)return;if(this._enableLevelSelection){const e=t.equals(this._lastCamera);this._lastCamera.copyFrom(t),e||this._requestUpdateCycle()}const s=this._needFullCycle?this._instanceData.size:2e3;this._needFullCycle=!1,this._updateInstances(t,s),this.needsUpdates&&this._context.requestRender()}render(e){var t,s,n,i;const r=e.slot===D.OPAQUE_PLUGIN?D.OPAQUE_MATERIAL:e.slot===D.TRANSPARENT_PLUGIN?D.TRANSPARENT_MATERIAL:null;if(!r||!this.baseMaterial.isVisible()||!this.baseMaterial.isVisibleInPass(e.pass))return;const l=e.camera;this._inverseViewport[0]=1/l.fullViewport[2],this._inverseViewport[1]=1/l.fullViewport[3];const o={slot:r,origin:[0,0,0],camera:l,inverseViewport:this._inverseViewport,shadowMap:e.shadowMap,shadowMappingEnabled:e.shadowMap.enabled,ssaoHelper:e.ssaoHelper,ssaoEnabled:e.ssaoHelper.enabled,screenToWorldRatio:null,screenToPCSRatio:null,slicePlane:e.sliceHelper&&e.sliceHelper.plane,hudVisibilityTexture:null!=(t=null==(s=e.offscreenRenderingHelper)?void 0:s.hudVisibilityTexture)?t:null,highlightDepthTexture:null!=(n=null==(i=e.offscreenRenderingHelper)?void 0:i.depthTexture)?n:null,hasOccludees:!1,linearDepthTexture:null,lastFrameColorTexture:null,reprojectionMatrix:a,ssrEnabled:!1,lighting:e.scenelightingData,transparencyPassType:e.transparencyPassType,terrainLinearDepthTexture:e.multipassTerrainParams.terrainLinearDepthTexture,geometryLinearDepthTexture:e.multipassGeometryParams.geometryLinearDepthTexture,multipassTerrainEnabled:e.multipassTerrainParams.multipassTerrainEnabled,cullAboveGround:e.multipassTerrainParams.cullAboveGround,multipassGeometryEnabled:e.multipassGeometryParams.multipassGeometryEnabled,highlightColorTexture:null,cloudsCompositionParams:null};e.rctx.bindVAO();const c=e.pass!==I.MATERIAL_HIGHLIGHT&&e.pass!==I.MATERIAL_DEPTH_SHADOWMAP_HIGHLIGHT,h=e.pass!==I.MATERIAL_DEPTH_SHADOWMAP_DEFAULT;c&&this._renderComponents(e,r,o,this._defaultRenderInstanceData),h&&this._renderComponents(e,r,o,this._highlightRenderInstanceData)}intersect(e,t,s,a){if(!this.baseMaterial.isVisible())return;const n=c();r(n,a,s);const i=n=>{this._instanceData.getCombinedModelTransform(n,N),e.transform.set(N),o(G,s,e.transform.inverse),o(F,a,e.transform.inverse);const i=this._instanceData.getState(n),r=this._instanceData.getLodLevel(n);T(i&y.ACTIVE,"invalid instance state"),T(r>=0&&r<this._levels.length,"invaid lod level"),this._levels[r].intersect(e,t,G,F,n,this._metadata)};this.baseMaterial.parameters.verticalOffset?this.octree.forEach(i):this.octree.forEachAlongRay(s,n,i)}queryDepthRange(e){return this._queryDepthRangeOctree(e)}notifyShaderTransformationChanged(){this._invalidateOctree()}_requestUpdateCycle(e=!1){this._updateCyclesWithStaticCamera=-1,e&&(this._needFullCycle=!0),this.needsUpdates&&this._context.requestRender()}get needsUpdates(){return this._instanceData.size>0&&this._updateCyclesWithStaticCamera<1}get octree(){return this._octree||(this._octree=this._buildOctree()),this._octree}_invalidateOctree(){this._octree&&(this._octree.destroy(),this._octree=null)}_buildOctree(){const e=new E(this._instanceData,this.baseBoundingSphere),t=this._instanceData,s=t.view?t.view.state:null;for(let a=0;a<this._instanceData.capacity;++a){s.get(a)&y.ACTIVE&&e.addInstance(a)}return e}_queryDepthRangeOctree(e){const t=e.eye,s=e.viewForward,a=this.octree.findClosest(s,g.FRONT_TO_BACK,e.frustum),n=this.octree.findClosest(s,g.BACK_TO_FRONT,e.frustum);if(null!=a&&null!=n){this._instanceData.view.boundingSphere.getVec(a,j),r(j,j,t);const i=l(j,s)-j[3];this._instanceData.view.boundingSphere.getVec(n,j),r(j,j,t);const o=l(j,s)+j[3];return{near:Math.max(e.near,i),far:Math.min(e.far,o)}}return{near:1/0,far:-1/0}}_startUpdateCycle(){this._updateCyclesWithStaticCamera++,this._defaultRenderInstanceData.forEach((e=>{e.startUpdateCylce()})),this._highlightRenderInstanceData.forEach((e=>{e.startUpdateCylce()})),this.needsUpdates&&this._context.requestRender()}_updateInstances(e,t){const s=this._enableLevelSelection,a=this._levelSelector;a.updateCamera(e),this._defaultRenderInstanceData.forEach((e=>{e.beginUpdate()})),this._highlightRenderInstanceData.forEach((e=>{e.beginUpdate()}));const n=this._instanceData,i=this._instanceData.view,r=n.size,l=n.capacity;let o=this._instanceIndex;t=Math.min(r,t);for(let c=0;c<t;++c){0===o&&this._startUpdateCycle();const e=i.state.get(o);let r=0;if(!(e&y.ALLOCATED)){o=(o+1)%l,t++;continue}const c=i.lodLevel.get(o);if(e&y.DEFAULT_ACTIVE&&this._defaultRenderInstanceData[c].freeTail(),e&y.HIGHLIGHT_ACTIVE&&this._highlightRenderInstanceData[c].freeTail(),e&y.REMOVE)n.freeInstance(o);else if(e&y.VISIBLE){let t=0;s&&(i.modelOrigin.getVec(o,w),t=a.selectLevel(w,n.getCombinedMedianScaleFactor(o))),r=e&~(y.ACTIVE|y.TRANSFORM_CHANGED),t>=0&&(e&y.HIGHLIGHT?(M(this._highlightRenderInstanceData[t],i,o),r|=y.HIGHLIGHT_ACTIVE):(M(this._defaultRenderInstanceData[t],i,o),r|=y.DEFAULT_ACTIVE)),i.state.set(o,r),i.lodLevel.set(o,t)}else r=e&~(y.ACTIVE|y.TRANSFORM_CHANGED),i.state.set(o,r);if(this._octree){const t=!!(e&y.ACTIVE),s=!!(r&y.ACTIVE);!t&&s?this._octree.addInstance(o):t&&!s?this._octree.removeInstance(o):t&&s&&e&y.TRANSFORM_CHANGED&&(this._octree.removeInstance(o),this._octree.addInstance(o))}o=(o+1)%l}this._instanceIndex=o,this._defaultRenderInstanceData.forEach((e=>{e.endUpdate()})),this._highlightRenderInstanceData.forEach((e=>{e.endUpdate()}))}_renderComponents(e,t,s,a){this.levels.forEach(((n,i)=>{n.components.forEach((n=>{this._renderComponent(e,t,s,a[i],n,i)}))}))}_renderComponent(t,s,a,n,i,r){if(0===n.size||!i.material.requiresSlot(s))return;const{rctx:l,pass:o}=t,c=i.glMaterials.load(l,o);if(e(c))return;const h=c.beginSlot(a),u=l.useTechnique(h,s);c.bind(a,h),l.bindVAO(i.vao),h.ensureAttributeLocations(i.vao),t.isHighlightPass&&_(u,a),h.bindDraw(a),d.LOD_INSTANCE_RENDERER_COLORIZE_BY_LEVEL&&t.pass===I.MATERIAL&&(u.setUniform4fv("externalColor",q[Math.min(r,q.length-1)]),u.setUniform1i("colorMixMode",L.replace));const m=l.capabilities.instancing,f=n.capacity,g=n.headIndex,D=n.tailIndex,v=n.firstIndex,y=this._glInstanceBufferLayout,E=(e,t)=>{U(l,p,n.buffer,y,e),m.drawArraysInstanced(h.primitiveType,0,i.vertexCount,t-e),x(l,p,n.buffer,y)};i.material.parameters.transparent&&null!=v?g>D?(T(v>=D&&v<=g,"invalid firstIndex"),E(v,g),E(D,v)):g<D&&(v<=g?(T(v>=0&&v<=g,"invalid firstIndex"),E(v,g),E(D,f),E(0,v)):(T(v>=D&&v<=f,"invalid firstIndex"),E(v,f),E(0,g),E(D,v))):g>D?E(D,g):g<D&&(E(0,g),E(D,f)),l.bindVAO(null)}}function M(e,t,s){const a=e.allocateHead();V(t,s,e.view,a)}function V(e,t,s,a){S(e.modelOrigin,t,s.modelOriginHi,s.modelOriginLo,a),s.model.copyFrom(a,e.model,t),s.modelNormal.copyFrom(a,e.modelNormal,t),e.color&&s.color&&s.color.copyFrom(a,e.color,t),e.featureAttribute&&s.featureAttribute&&s.featureAttribute.copyFrom(a,e.featureAttribute,t)}const w=c(),j=h(),N=n(),G=c(),F=c(),q=[[1,0,1,1],[0,0,1,1],[0,1,0,1],[1,1,0,1],[1,0,0,1]];export{H as LodRenderer,P as setLevelSelectorFactory};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.23/esri/copyright.txt for details.
4
4
  */
5
- import{someMap as e}from"../../../../../core/MapUtils.js";import{isSome as t,isNone as r}from"../../../../../core/maybe.js";import s from"../../../../../core/PooledArray.js";import{m as i,a,t as o}from"../../../../../chunks/mat4.js";import{c as n}from"../../../../../chunks/mat4f64.js";import{glLayout as d}from"../../../support/buffer/glUtil.js";import{GLMaterials as h}from"../../lib/GLMaterials.js";import{RenderOccludedFlag as l}from"../../lib/Material.js";import{ModelDirty as f}from"../../lib/ModelDirtyTypes.js";import{RenderPass as m}from"../../lib/RenderPass.js";import{assert as c,setMatrixTranslation3 as u}from"../../lib/Util.js";import{WaterMaterial as g}from"../WaterMaterial.js";import{sortInstancesByRange as _,BufferRange as p,Instance as b,addOrMerge as w}from"./Instance.js";import{MergedGeometryBuffer as y}from"./MergedGeometryBuffer.js";import{MergedGeometryBufferPool as C}from"./MergedGeometryBufferPool.js";import{calculateTransformRelativeToOrigin as H}from"./utils.js";class v{constructor(e,t,r){this._rctx=e,this._materialRepository=t,this._material=r,this.type="MergedRenderer",this._dataByOrigin=new Map,this._renderCommandData=new s,this._hasHighlights=!1,this._hasOccludees=!1,this._glMaterials=new h(this._material,this._materialRepository),this._bufferWriter=r.createBufferWriter(),this._bufferPool=new C(e,r.vertexAttributeLocations,d(this._bufferWriter.vertexBufferLayout))}dispose(){this._glMaterials.destroy(),this._dataByOrigin.forEach((e=>e.buffer.dispose())),this._dataByOrigin.clear(),this._bufferPool.dispose()}get isEmpty(){return 0===this._dataByOrigin.size}get hasHighlights(){return this._hasHighlights}get hasOccludees(){return this._hasOccludees}get hasWater(){return!this.isEmpty&&this._material instanceof g}get rendersOccluded(){return!this.isEmpty&&this._material.renderOccluded!==l.Occlude}modify(e){this._updateGeometries(e.updates),this._addAndRemoveGeometries(e.adds,e.removes),this._updateRenderCommands()}_addAndRemoveGeometries(e,t){const r=this._bufferWriter,s=r.vertexBufferLayout.stride/4,i=this._dataByOrigin,a=A(e,t);a.forEach(((e,t)=>{a.delete(t);const o=e.toAdd.reduce(((e,t)=>e+r.elementCount(t.data)),0);let n=i.get(t);if(null==n)c(0===e.toRemove.length),n=new B(e.origin,new y(this._bufferPool,o*s)),i.set(t,n);else if(0===e.toAdd.length&&n.instances.size===e.toRemove.length)return n.buffer.dispose(),void i.delete(t);let d=0;n.instances.forEach((e=>d+=e.to-e.from));const h=e.toRemove.reduce(((e,t)=>e+r.elementCount(t.data)),0),l=n.buffer.size,f=(d+o-h)*s,m=T;if(f<l/2?this._removeAndRebuild(n,e.toRemove,s,f,m):e.toRemove.length>0&&this._remove(n,e.toRemove,s,m),e.toAdd.length>0){const t=E;u(t,-e.origin[0],-e.origin[1],-e.origin[2]),this._add(n,e.toAdd,s,t,m)}const g=n.buffer.vao.vertexBuffers.geometry;I(m),m.forAll((({from:e,to:t})=>{if(e<t){const r=n.buffer.array,s=4,i=e*s,a=t*s;g.setSubData(r,i,i,a)}})),m.clear(),n.drawCommandsDirty=!0}))}_updateGeometries(e){const t=this._bufferWriter,r=t.vertexBufferLayout.stride/4;for(const s of e){const e=s.renderGeometry,i=this._dataByOrigin.get(e.origin.id),a=i&&i.instances.get(e.id);if(!a)return;const o=s.updateType;if(o&f.State.VISIBILITIES&&(a.isVisible=e.instanceParameters.visible),o&(f.State.HIGHLIGHTS|f.State.VISIBILITIES)){const t=e.instanceParameters.visible;a.hasHighlights=!!e.instanceParameters.highlights&&t}if(o&f.State.OCCLUDEES&&(a.hasOccludees=!!e.instanceParameters.occludees),o&(f.State.VERTEXATTRS|f.State.TRANSFORMATION)){const{array:s,vao:o}=i.buffer;H(e,P,L),t.write({transformation:P,invTranspTransformation:L},e.data,t.vertexBufferLayout.createView(s.buffer),a.from),c(a.from+t.elementCount(e.data)===a.to,"material VBO layout has changed"),o.vertexBuffers.geometry.setSubData(s,a.from*r*4,a.from*r*4,a.to*r*4)}i.drawCommandsDirty=!0}}_updateRenderCommands(){this._hasHighlights=!1,this._hasOccludees=!1,this._dataByOrigin.forEach((t=>{t.hasHiddenInstances=!1,t.hasHighlights=!1,t.hasOccludees=!1,e(t.instances,(e=>(e.isVisible?(e.hasHighlights&&(this._hasHighlights=!0,t.hasHighlights=!0),e.hasOccludees&&(this._hasOccludees=!0,t.hasOccludees=!0)):t.hasHiddenInstances=!0,t.hasHiddenInstances&&t.hasHighlights&&t.hasOccludees)))}));const t=e=>{if(e.drawCommandsDefault=null,e.drawCommandsHighlight=null,e.drawCommandsOccludees=null,e.drawCommandsShadowHighlightRest=null,0===e.instances.size)return;if(!S(e)){const t=this._bufferWriter.vertexBufferLayout.stride,r=4*e.buffer.size/t;return void(e.drawCommandsDefault=[{first:0,count:r}])}const t=_(e.instances);e.drawCommandsDefault=[],e.drawCommandsHighlight=[],e.drawCommandsOccludees=[],e.drawCommandsShadowHighlightRest=[];for(const r of t)r.isVisible&&(r.hasOccludees?w(e.drawCommandsOccludees,r):w(e.drawCommandsDefault,r),r.hasHighlights?w(e.drawCommandsHighlight,r):w(e.drawCommandsShadowHighlightRest,r))};this._dataByOrigin.forEach((e=>{e.drawCommandsDirty&&(t(e),e.drawCommandsDirty=!1)}))}updateAnimation(e){return this._material.update(e)}requiresSlot(e,t){return null==e||this._material.requiresSlot(e,t)}render(e,s,i){if(!this.requiresSlot(e,s))return!1;const a=s===m.MATERIAL_HIGHLIGHT||s===m.MATERIAL_DEPTH_SHADOWMAP_HIGHLIGHT;if(a&&!this._hasHighlights)return!1;const o=s===m.MATERIAL_DEPTH_SHADOWMAP_DEFAULT,n=!(a||o);if(this._dataByOrigin.forEach((e=>{if(a&&!e.hasHighlights)return;const r=(a?e.drawCommandsHighlight:o&&S(e)?e.drawCommandsShadowHighlightRest:e.drawCommandsDefault)||null,s=n&&e.drawCommandsOccludees||null;(t(r)||t(s))&&this._renderCommandData.push(new M(e.origin,e.buffer,r,s))})),0===this._renderCommandData.length)return!1;const d=this._rctx,h=this._glMaterials.load(d,s);if(r(h))return this._renderCommandData.clear(),!1;const l=h.beginSlot(i);return l.bindPipelineState(d,e,!1),d.useProgram(l.program),h.bind(i,l),this._renderCommandData.forAll((({origin:r,buffer:s,renderCommands:a,occludeeCommands:o})=>{i.origin=r,l.bindDraw(i),l.ensureAttributeLocations(s.vao),d.bindVAO(s.vao);const n=l.primitiveType;t(a)&&this._renderCommands(d,n,a),t(o)&&(l.bindPipelineState(d,e,!0),this._renderCommands(d,n,o),l.bindPipelineState(d,e,!1))})),this._renderCommandData.clear(),!0}_renderCommands(e,t,r){for(let s=0;s<r.length;s++)e.drawArrays(t,r[s].first,r[s].count)}_removeAndRebuild(e,t,r,s,i){for(const h of t)e.instances.delete(h.id);const a=_(e.instances);e.instances.clear();const o=e.buffer.size,n=e.buffer.alloc(s);let d=0;for(const h of a){const t=h.from*r,s=h.to*r;n.copy(d,t,s),h.from=d/r,d+=s-t,h.to=d/r,e.instances.set(h.id,h)}i.push(new p(0,n.hasNewBuffer?e.buffer.array.length:o)),n.dispose(),e.buffer.erase(d,i.back().to),e.holes.clear()}_remove(e,t,r,s){for(const i of t){const t=i.id,a=e.instances.get(t),o=a.from*r,n=a.to*r;e.buffer.erase(o,n),e.holes.push(new p(a.from,a.to)),e.instances.delete(t),s.push(new p(o,n))}I(e.holes)}_add(e,s,n,d,h){const l=this._bufferWriter;let f=l.vertexBufferLayout.createView(e.buffer.array.buffer);for(const m of s){const s=t(m.transformation)?i(P,d,m.transformation):d;a(L,s);const u=o(L,L),g=l.elementCount(m.data),_=g*n;let w=D(e.holes,g);r(w)&&(w=e.buffer.size/n,e.buffer.grow(_),f=l.vertexBufferLayout.createView(e.buffer.array.buffer)),l.write({transformation:s,invTranspTransformation:u},m.data,f,w);const y=m.instanceParameters.visible,C=!!m.instanceParameters.highlights&&y,H=!!m.instanceParameters.occludees,v=new b(m.id,w,w+g,y,C,H);c(null==e.instances.get(m.id)),e.instances.set(m.id,v),h.push(new p(v.from*n,v.to*n))}}get test(){return{material:this._material,glMaterials:this._glMaterials}}}class O{constructor(e){this.origin=e,this.toAdd=new Array,this.toRemove=new Array}}function A(e,t){const r=new Map;for(const s of e)R(r,s,!0);for(const s of t)R(r,s,!1);return r}function R(e,t,s){const i=t.origin;if(r(i))return;let a=e.get(i.id);null==a&&(a=new O(i.vec3),e.set(i.id,a)),s?a.toAdd.push(t):a.toRemove.push(t)}function S(e){return e.hasOccludees||e.hasHighlights||e.hasHiddenInstances}function D(e,t){let r;if(!e.some((e=>!(e.to-e.from<t)&&(r=e,!0))))return null;const s=r.from;return r.from+=t,r.from>=r.to&&e.removeUnordered(r),s}function I(e){const t=new Map;e.forAll((e=>t.set(e.from,e)));let r=!0;for(;r;)r=!1,e.forEach((s=>{const i=t.get(s.to);i&&(s.to=i.to,t.delete(i.from),e.removeUnordered(i),r=!0)}))}class B{constructor(e,t){this.origin=e,this.buffer=t,this.instances=new Map,this.holes=new s({deallocator:null}),this.hasHiddenInstances=!1,this.hasHighlights=!1,this.hasOccludees=!1,this.drawCommandsDirty=!1}}class M{constructor(e,t,r,s){this.origin=e,this.buffer=t,this.renderCommands=r,this.occludeeCommands=s}}const T=new s({deallocator:null}),E=n(),P=n(),L=n();export{v as MergedRenderer};
5
+ import{someMap as e}from"../../../../../core/MapUtils.js";import{isSome as t,isNone as r}from"../../../../../core/maybe.js";import s from"../../../../../core/PooledArray.js";import{m as i,a,t as o}from"../../../../../chunks/mat4.js";import{c as n}from"../../../../../chunks/mat4f64.js";import{glLayout as d}from"../../../support/buffer/glUtil.js";import{GLMaterials as h}from"../../lib/GLMaterials.js";import{RenderOccludedFlag as f}from"../../lib/Material.js";import{ModelDirty as l}from"../../lib/ModelDirtyTypes.js";import{RenderPass as m}from"../../lib/RenderPass.js";import{assert as c,setMatrixTranslation3 as u}from"../../lib/Util.js";import{WaterMaterial as g}from"../WaterMaterial.js";import{sortInstancesByRange as _,BufferRange as p,Instance as b,addOrMerge as w}from"./Instance.js";import{MergedGeometryBuffer as y}from"./MergedGeometryBuffer.js";import{MergedGeometryBufferPool as C}from"./MergedGeometryBufferPool.js";import{calculateTransformRelativeToOrigin as H}from"./utils.js";class v{constructor(e,t,r){this._rctx=e,this._materialRepository=t,this._material=r,this.type="MergedRenderer",this._dataByOrigin=new Map,this._renderCommandData=new s,this._hasHighlights=!1,this._hasOccludees=!1,this._glMaterials=new h(this._material,this._materialRepository),this._bufferWriter=r.createBufferWriter(),this._bufferPool=new C(e,r.vertexAttributeLocations,d(this._bufferWriter.vertexBufferLayout))}dispose(){this._glMaterials.destroy(),this._dataByOrigin.forEach((e=>e.buffer.dispose())),this._dataByOrigin.clear(),this._bufferPool.dispose()}get isEmpty(){return 0===this._dataByOrigin.size}get hasHighlights(){return this._hasHighlights}get hasOccludees(){return this._hasOccludees}get hasWater(){return!this.isEmpty&&this._material instanceof g}get rendersOccluded(){return!this.isEmpty&&this._material.renderOccluded!==f.Occlude}modify(e){this._updateGeometries(e.updates),this._addAndRemoveGeometries(e.adds,e.removes),this._updateRenderCommands()}_addAndRemoveGeometries(e,t){const r=this._bufferWriter,s=r.vertexBufferLayout.stride/4,i=this._dataByOrigin,a=A(e,t);a.forEach(((e,t)=>{a.delete(t);const o=e.toAdd.reduce(((e,t)=>e+r.elementCount(t.data)),0);let n=i.get(t);if(null==n)c(0===e.toRemove.length),n=new B(e.origin,new y(this._bufferPool,o*s)),i.set(t,n);else if(0===e.toAdd.length&&n.instances.size===e.toRemove.length)return n.buffer.dispose(),void i.delete(t);let d=0;n.instances.forEach((e=>d+=e.to-e.from));const h=e.toRemove.reduce(((e,t)=>e+r.elementCount(t.data)),0),f=n.buffer.size,l=(d+o-h)*s,m=M;if(l<f/2?this._removeAndRebuild(n,e.toRemove,s,l,m):e.toRemove.length>0&&this._remove(n,e.toRemove,s,m),e.toAdd.length>0){const t=E;u(t,-e.origin[0],-e.origin[1],-e.origin[2]),this._add(n,e.toAdd,s,t,m)}const g=n.buffer.vao.vertexBuffers.geometry;I(m),m.forAll((({from:e,to:t})=>{if(e<t){const r=n.buffer.array,s=4,i=e*s,a=t*s;g.setSubData(r,i,i,a)}})),m.clear(),n.drawCommandsDirty=!0}))}_updateGeometries(e){const t=this._bufferWriter,r=t.vertexBufferLayout.stride/4;for(const s of e){const e=s.renderGeometry,i=this._dataByOrigin.get(e.origin.id),a=i&&i.instances.get(e.id);if(!a)return;const o=s.updateType;if(o&l.State.VISIBILITIES&&(a.isVisible=e.instanceParameters.visible),o&(l.State.HIGHLIGHTS|l.State.VISIBILITIES)){const t=e.instanceParameters.visible;a.hasHighlights=!!e.instanceParameters.highlights&&t}if(o&l.State.OCCLUDEES&&(a.hasOccludees=!!e.instanceParameters.occludees),o&(l.State.VERTEXATTRS|l.State.TRANSFORMATION)){const{array:s,vao:o}=i.buffer;H(e,L,P),t.write({transformation:L,invTranspTransformation:P},e.data,t.vertexBufferLayout.createView(s.buffer),a.from),c(a.from+t.elementCount(e.data)===a.to,"material VBO layout has changed"),o.vertexBuffers.geometry.setSubData(s,a.from*r*4,a.from*r*4,a.to*r*4)}i.drawCommandsDirty=!0}}_updateRenderCommands(){this._hasHighlights=!1,this._hasOccludees=!1,this._dataByOrigin.forEach((t=>{t.hasHiddenInstances=!1,t.hasHighlights=!1,t.hasOccludees=!1,e(t.instances,(e=>(e.isVisible?(e.hasHighlights&&(this._hasHighlights=!0,t.hasHighlights=!0),e.hasOccludees&&(this._hasOccludees=!0,t.hasOccludees=!0)):t.hasHiddenInstances=!0,t.hasHiddenInstances&&t.hasHighlights&&t.hasOccludees)))}));const t=e=>{if(e.drawCommandsDefault=null,e.drawCommandsHighlight=null,e.drawCommandsOccludees=null,e.drawCommandsShadowHighlightRest=null,0===e.instances.size)return;if(!S(e)){const t=this._bufferWriter.vertexBufferLayout.stride,r=4*e.buffer.size/t;return void(e.drawCommandsDefault=[{first:0,count:r}])}const t=_(e.instances);e.drawCommandsDefault=[],e.drawCommandsHighlight=[],e.drawCommandsOccludees=[],e.drawCommandsShadowHighlightRest=[];for(const r of t)r.isVisible&&(r.hasOccludees?w(e.drawCommandsOccludees,r):w(e.drawCommandsDefault,r),r.hasHighlights?w(e.drawCommandsHighlight,r):w(e.drawCommandsShadowHighlightRest,r))};this._dataByOrigin.forEach((e=>{e.drawCommandsDirty&&(t(e),e.drawCommandsDirty=!1)}))}updateAnimation(e){return this._material.update(e)}requiresSlot(e,t){return null==e||this._material.requiresSlot(e,t)}render(e,s,i){if(!this.requiresSlot(e,s))return!1;const a=s===m.MATERIAL_HIGHLIGHT||s===m.MATERIAL_DEPTH_SHADOWMAP_HIGHLIGHT;if(a&&!this._hasHighlights)return!1;const o=s===m.MATERIAL_DEPTH_SHADOWMAP_DEFAULT,n=!(a||o);if(this._dataByOrigin.forEach((e=>{if(a&&!e.hasHighlights)return;const r=(a?e.drawCommandsHighlight:o&&S(e)?e.drawCommandsShadowHighlightRest:e.drawCommandsDefault)||null,s=n&&e.drawCommandsOccludees||null;(t(r)||t(s))&&this._renderCommandData.push(new T(e.origin,e.buffer,r,s))})),0===this._renderCommandData.length)return!1;const d=this._rctx,h=this._glMaterials.load(d,s);if(r(h))return this._renderCommandData.clear(),!1;const f=h.beginSlot(i);return d.useTechnique(f,e,!1),h.bind(i,f),this._renderCommandData.forAll((({origin:r,buffer:s,renderCommands:a,occludeeCommands:o})=>{i.origin=r,f.bindDraw(i),f.ensureAttributeLocations(s.vao),d.bindVAO(s.vao);const n=f.primitiveType;t(a)&&this._renderCommands(d,n,a),t(o)&&(f.bindPipelineState(d,e,!0),this._renderCommands(d,n,o),f.bindPipelineState(d,e,!1))})),this._renderCommandData.clear(),!0}_renderCommands(e,t,r){for(let s=0;s<r.length;s++)e.drawArrays(t,r[s].first,r[s].count)}_removeAndRebuild(e,t,r,s,i){for(const h of t)e.instances.delete(h.id);const a=_(e.instances);e.instances.clear();const o=e.buffer.size,n=e.buffer.alloc(s);let d=0;for(const h of a){const t=h.from*r,s=h.to*r;n.copy(d,t,s),h.from=d/r,d+=s-t,h.to=d/r,e.instances.set(h.id,h)}i.push(new p(0,n.hasNewBuffer?e.buffer.array.length:o)),n.dispose(),e.buffer.erase(d,i.back().to),e.holes.clear()}_remove(e,t,r,s){for(const i of t){const t=i.id,a=e.instances.get(t),o=a.from*r,n=a.to*r;e.buffer.erase(o,n),e.holes.push(new p(a.from,a.to)),e.instances.delete(t),s.push(new p(o,n))}I(e.holes)}_add(e,s,n,d,h){const f=this._bufferWriter;let l=f.vertexBufferLayout.createView(e.buffer.array.buffer);for(const m of s){const s=t(m.transformation)?i(L,d,m.transformation):d;a(P,s);const u=o(P,P),g=f.elementCount(m.data),_=g*n;let w=D(e.holes,g);r(w)&&(w=e.buffer.size/n,e.buffer.grow(_),l=f.vertexBufferLayout.createView(e.buffer.array.buffer)),f.write({transformation:s,invTranspTransformation:u},m.data,l,w);const y=m.instanceParameters.visible,C=!!m.instanceParameters.highlights&&y,H=!!m.instanceParameters.occludees,v=new b(m.id,w,w+g,y,C,H);c(null==e.instances.get(m.id)),e.instances.set(m.id,v),h.push(new p(v.from*n,v.to*n))}}get test(){return{material:this._material,glMaterials:this._glMaterials}}}class O{constructor(e){this.origin=e,this.toAdd=new Array,this.toRemove=new Array}}function A(e,t){const r=new Map;for(const s of e)R(r,s,!0);for(const s of t)R(r,s,!1);return r}function R(e,t,s){const i=t.origin;if(r(i))return;let a=e.get(i.id);null==a&&(a=new O(i.vec3),e.set(i.id,a)),s?a.toAdd.push(t):a.toRemove.push(t)}function S(e){return e.hasOccludees||e.hasHighlights||e.hasHiddenInstances}function D(e,t){let r;if(!e.some((e=>!(e.to-e.from<t)&&(r=e,!0))))return null;const s=r.from;return r.from+=t,r.from>=r.to&&e.removeUnordered(r),s}function I(e){const t=new Map;e.forAll((e=>t.set(e.from,e)));let r=!0;for(;r;)r=!1,e.forEach((s=>{const i=t.get(s.to);i&&(s.to=i.to,t.delete(i.from),e.removeUnordered(i),r=!0)}))}class B{constructor(e,t){this.origin=e,this.buffer=t,this.instances=new Map,this.holes=new s({deallocator:null}),this.hasHiddenInstances=!1,this.hasHighlights=!1,this.hasOccludees=!1,this.drawCommandsDirty=!1}}class T{constructor(e,t,r,s){this.origin=e,this.buffer=t,this.renderCommands=r,this.occludeeCommands=s}}const M=new s({deallocator:null}),E=n(),L=n(),P=n();export{v as MergedRenderer};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.23/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../Color.js";import r from"../../Graphic.js";import"../../symbols.js";import s from"../../core/Collection.js";import o from"../../core/Error.js";import i from"../../core/Evented.js";import a from"../../core/Handles.js";import l from"../../core/Logger.js";import{isNone as n}from"../../core/maybe.js";import{isAbortError as u,isPromiseLike as c}from"../../core/promiseUtils.js";import{on as p,init as h,watch as d}from"../../core/watchUtils.js";import{property as m}from"../../core/accessorSupport/decorators/property.js";import"../../core/arrayUtils.js";import"../../core/has.js";import"../../core/accessorSupport/ensureType.js";import{subclass as v}from"../../core/accessorSupport/decorators/subclass.js";import{graphicsExtent as g}from"../../geometry/support/graphicsUtils.js";import{getLocale as y}from"../../intl/locale.js";import w from"../../layers/GraphicsLayer.js";import{fetchServiceDescription as f}from"../../rest/networkService.js";import b from"../../rest/support/NetworkFeatureSet.js";import _ from"../../rest/support/RouteParameters.js";import T from"../../tasks/RouteTask.js";import{isWaypoint as S,isStopLocated as L,isFirstStop as C,isLastStop as R}from"./support/directionsUtils.js";import{GoToMixin as A}from"../support/GoTo.js";import D from"../../symbols/SimpleMarkerSymbol.js";import M from"../../symbols/PictureMarkerSymbol.js";import j from"../../symbols/SimpleLineSymbol.js";const N=l.getLogger("esri.widgets.Directions.DirectionsViewModel"),z={first:new D({color:[105,220,255,1],size:19,outline:{color:[51,51,51,1],width:3}}),middle:new D({color:[51,51,51,1],size:12,outline:{color:[105,220,255,1],width:3}}),last:new M({width:23,height:23,url:`data:image/svg+xml;base64,${btoa('<svg width="30" height="30" viewBox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"><g fill-rule="nonzero" fill="none"><path d="M15.15.3C6.9.3.3 6.9.3 15.15S6.9 29.7 15.15 29.7 29.7 23.1 29.7 15.15C29.7 6.9 23.25.3 15.15.3z" fill="#333"/><path d="M15 4.8C9.3 4.8 4.8 9.45 4.8 15c0 5.55 4.65 10.2 10.2 10.2 5.55 0 10.2-4.5 10.2-10.2 0-5.55-4.5-10.2-10.2-10.2z" fill="#69DCFF"/><path fill="#333" d="M10.5 10.5h9v9h-9z"/></g></svg>')}`}),unlocated:new M({height:18,width:18,url:`data:image/svg+xml;base64,${btoa('<svg width="20" height="20" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><g fill="none" fill-rule="evenodd"><path d="M10.1.2C4.6.2.2 4.6.2 10.1s4.4 9.7 9.9 9.7 9.7-4.4 9.7-9.7c0-5.5-4.3-9.9-9.7-9.9z" fill="#333" fill-rule="nonzero"/><path d="M10 2.7c-4.08 0-7.3 3.328-7.3 7.3s3.328 7.3 7.3 7.3 7.3-3.22 7.3-7.3c0-3.972-3.22-7.3-7.3-7.3z" fill="#69DCFF" fill-rule="nonzero"/><path d="M11.414 10l5.304-5.303-1.415-1.415L10 8.586 4.697 3.282 3.282 4.697 8.586 10l-5.304 5.303 1.415 1.415L10 11.414l5.303 5.304 1.415-1.415L11.414 10z" fill="#333"/></g></svg>')}`}),waypoint:new D({color:[255,255,255,1],size:10,outline:{color:[20,89,127,1],width:2.5}})};var U;!function(e){e[e.Idle=0]="Idle",e[e.Active=1]="Active",e[e.Complete=2]="Complete",e[e.Failed=3]="Failed",e[e.Suspended=4]="Suspended"}(U||(U={}));let x=class extends(A(i.EventedAccessor)){constructor(e){super(e),this._handles=new a,this._routeLayer=new w({listMode:"hide"}),this._highlightLayer=new w({listMode:"hide"}),this._stopId=9999,this._stopLayer=new w({listMode:"hide"}),this._serviceDescriptionLoadStatus=U.Idle,this.apiKey=void 0,this.departureTime="now",this.lastRoute=null,this.routeSymbol=new j({color:[105,220,255,1],width:7,cap:"round",join:"round"}),this.routeParameters=new _({ignoreInvalidLocations:!0,directionsOutputType:"complete",findBestSequence:!1,preserveFirstStop:!0,preserveLastStop:!0,restrictUTurns:"at-dead-ends-and-intersections",directionsLengthUnits:"kilometers",returnBarriers:!1,returnDirections:!0,returnPolygonBarriers:!1,returnPolylineBarriers:!1,returnRoutes:!1,returnStops:!0,returnZ:!0,startTime:null,startTimeIsUTC:!0,stops:null,useHierarchy:!0,useTimeWindows:!1}),this.routeServiceUrl="https://route-api.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World",this.serviceDescription=null,this.error=null,this.stops=new s,this.view=null}initialize(){this._handles.add([p(this,"stops","change",(()=>{this.clearResults(),this._addStopsToLayer()})),h(this,"view.map",((e,t)=>{const r=[this._routeLayer,this._stopLayer,this._highlightLayer];t&&t.removeMany(r),e&&e.addMany(r)})),d(this,"lastRoute",(()=>this._addRouteToLayer()))])}destroy(){this.stops.destroy();const e=this.get("view.map");e&&e.removeMany([this._routeLayer,this._stopLayer,this._highlightLayer])}get _directionsLanguage(){const{routeParameters:e,serviceDescription:t}=this,{directionsSupportedLanguages:r}=t;if(!r)return;const s=(e.directionsLanguage||y()).slice(0,2);return r.find((e=>e.toLowerCase().slice(0,2)===s))}get _routeTask(){return new T(this.routeServiceUrl)}get impedanceAttribute(){var e,t,r,s,o,i;const a=null!=(e=null!=(t=null==(r=this.routeParameters)||null==(s=r.travelMode)?void 0:s.impedanceAttributeName)?t:null==(o=this.routeParameters)?void 0:o.impedanceAttribute)?e:null==(i=this.serviceDescription)?void 0:i.impedance;return this.getCostAttribute(a)}set maxStops(e){const t=50,r=2;e=e<=r?r:e>t?t:e,this._set("maxStops",e)}get selectedTravelMode(){const{serviceDescription:e}=this;if(!e)return null;const{defaultTravelMode:t,supportedTravelModes:r=[]}=e;let s=null;for(let o=0;o<r.length;o++)r[o].id===t&&(s=r[o]);return s||r[0]||null}set selectedTravelMode(e){void 0!==e?this._override("selectedTravelMode",e):this._clearOverride("selectedTravelMode")}get state(){const e=this._serviceDescriptionLoadStatus;return e===U.Suspended?"unauthenticated":e===U.Idle?"disabled":e===U.Active?"initializing":this._activeRouteController?"routing":e===U.Failed||this.error?"error":"ready"}set stopSymbols(e){const t={...z,...e};this._set("stopSymbols",t)}get timeAttribute(){var e,t,r,s,o,i;const a=null!=(e=null!=(t=null==(r=this.routeParameters)||null==(s=r.travelMode)?void 0:s.timeAttributeName)?t:null==(o=this.routeParameters)?void 0:o.directionsTimeAttribute)?e:null==(i=this.serviceDescription)?void 0:i.directionsTimeAttribute;return this.getCostAttribute(a)}get travelModes(){var e,t;return null!=(e=null==(t=this.serviceDescription)?void 0:t.supportedTravelModes)?e:[]}async load(){if(!this.serviceDescription)try{this._serviceDescriptionLoadStatus=U.Active,this.notifyChange("state"),await this._loadServiceDescription(),this._serviceDescriptionLoadStatus=U.Complete,this.notifyChange("state")}catch(e){const t="identity-manager:user-aborted"===e.name;if(this._serviceDescriptionLoadStatus=t?U.Suspended:U.Failed,this.notifyChange("state"),!t){const t=new o("directions-view-model:service-metadata-unavailable","Cannot load route service metadata",{error:e});throw this._set("error",t),t}}}highlightSegment(e){const{view:s,_highlightLayer:o}=this;if(!s||n(e.symbol))return;this.clearHighlights();const i=e.symbol.clone();i.color=new t([0,0,0,.8]),i.width=Math.ceil(i.width/2);const a=new r({geometry:e.geometry,symbol:i});o.graphics.add(a)}clearHighlights(){this._highlightLayer.graphics.removeAll()}centerAt(e){const{view:t}=this;t&&this.callGoTo({target:e})}clearResults(){this._set("lastRoute",null)}getDirections(){const{state:e}=this;if("unauthenticated"===e||"initializing"===e||"disabled"===e||this._serviceDescriptionLoadStatus===U.Failed)return Promise.reject(new o("directions-view-model:not-loaded","Cannot get directions until view model loads."));this._set("error",null),this._activeRouteController&&(this._activeRouteController.abort(),this._activeRouteController=null);const{apiKey:t,departureTime:r}=this,s="now"===r,i="now"===r?new Date:r;if(i&&!s){const e=60*i.getTimezoneOffset()*1e3;i.setTime(i.getTime()-e)}const a=this.routeParameters.clone();if(a.set({startTime:i,startTimeIsUTC:s,directionsLanguage:this._directionsLanguage,apiKey:t}),this.selectedTravelMode&&(a.travelMode=this.selectedTravelMode),this.stops.length<=1){const e=new o("directions-view-model:not-enough-stops","Not enough stops for routing");return this._set("error",e),Promise.reject(e)}const l=new AbortController,{signal:n}=l;this._activeRouteController=l;const c=this._enqueue((()=>{const e=this.stops.clone().toArray(),t={},r=r=>{const s=r&&r.routeResults&&r.routeResults[0]&&r.routeResults[0].stops||[];(r&&r.routeResults&&r.routeResults[0]&&r.routeResults[0].directions&&r.routeResults[0].directions.features||[]).map((r=>{for(let s=0;s<e.length;s++)if(r.attributes.text.indexOf(e[s].attributes.Name)>-1){const o=e[s].attributes.Name;r.attributes.text=r.attributes.text.replace(o,t[o]),r._associatedStop=e[s];break}})),e.map((e=>e.attributes.Name=t[e.attributes.Name])),s.map((e=>{e.attributes.Name=t[e.attributes.Name]}))},s=e=>{if(e&&e.routeResults&&e.routeResults[0]){const t=e.routeResults[0],r=t.stops||[],s=this.stops.clone().toArray();let o=t.directions&&t.directions.routeName||t.routeName||"";r.map(((e,t)=>{const r=e.attributes,i=s[t].attributes;o=o.replace(r.Name,i.Name),Object.keys(r).forEach((e=>{0===e.indexOf("Cumul_")&&(i[e]=r[e])})),i.ArriveCurbApproach=r.ArriveCurbApproach,i.ArriveTime=r.ArriveTime,i.ArriveTimeUTC=r.ArriveTimeUTC,i.DepartCurbApproach=r.DepartCurbApproach,i.DepartTime=r.DepartTime,i.DepartTimeUTC=r.DepartTimeUTC,i.Sequence=r.Sequence,i.Status=r.Status})),t.directions&&(t.directions.routeName=o),null!==t.route&&(t.route.attributes.Name=o),t.routeName=o}},o=e=>{const r=e&&e.routeResults&&e.routeResults[0]&&e.routeResults[0].stops||[],s=this.stops.toArray();let o=r.length===s.length,i=0;for(;o&&i<r.length;)o=o&&t[r[i].attributes.Name]===s[i++].attributes.Name;return o};return(()=>{e.map((e=>{const r=e.attributes,s=`${(r.Name||"[not yet geocoded]").substr(0,100)}_#${++this._stopId}`;t[s]=r.Name,r.Name=s}))})(),a.stops=new b({doNotLocateOnRestrictedElements:!0,features:e}),this._routeTask.solve(a,{signal:n}).then((e=>o(e)?(s(e),r(e),this._set("lastRoute",e),e):(N.warn("Response stops don't match current stops of the ViewModel, invalidating the results."),this._set("lastRoute",null),null))).catch((e=>{throw r(null),e}))})).then((e=>(this._activeRouteController=null,this.notifyChange("state"),this.zoomToRoute(),e))).catch((e=>{if(this._activeRouteController=null,this.notifyChange("state"),!u(e))throw e=new o("directions-view-model:unable-to-route","Unable to route to these addresses",{error:e}),this._set("error",e),e}));return this.notifyChange("state"),c}getCostAttribute(e){var t,r;const s=(null!=(t=null==(r=this.serviceDescription)?void 0:r.networkDataset.networkAttributes)?t:[]).find((t=>t.name===e&&"esriNAUTCost"===t.usageType));return null!=s?s:null}reset(){this.stops.removeAll(),this.clearHighlights(),this._set("lastRoute",null)}zoomToRoute(){const{directionLines:e,view:t}=this;if(!e||!t)return;const r=g(e),s=r.width>r.height;this.callGoTo({target:r.expand(s?2:1)})}async _loadServiceDescription(){const e=await f(this.routeServiceUrl,this.apiKey);this._set("serviceDescription",e)}_enqueue(e){this._requestQueueTail||(this._requestQueueTail=Promise.resolve());const t=new Promise(((t,r)=>{this._requestQueueTail.catch((()=>{})).then((()=>{try{const s=e.call(this);c(s)?s.then(t,r):t(s)}catch(s){r(s)}}))}));return this._requestQueueTail=t,t}_addStopsToLayer(){this._stopLayer.graphics.removeAll();const e=this.stops.clone().map(((e,t)=>{const{first:r,middle:s,last:o,unlocated:i,waypoint:a}=this.stopSymbols;return S(e)?e.symbol=a:void 0===e.attributes.Status?e.symbol=0===t?r:t===this.stops.length-1?o:s:e.symbol=S(e)?a:L(e)?C(e)?r:R(e)?o:s:i,e}));this._stopLayer.graphics.addMany(e)}_addRouteToLayer(){this._routeLayer.graphics.removeAll();const{directionLines:e}=this;e&&(e.forEach((e=>{e.symbol=this.routeSymbol})),this._routeLayer.graphics.addMany(e))}};e([m()],x.prototype,"_directionsLanguage",null),e([m({type:T})],x.prototype,"_routeTask",null),e([m()],x.prototype,"apiKey",void 0),e([m()],x.prototype,"departureTime",void 0),e([m({aliasOf:"lastRoute.routeResults.0.directions.features"})],x.prototype,"directionLines",void 0),e([m({readOnly:!0})],x.prototype,"impedanceAttribute",null),e([m({readOnly:!0})],x.prototype,"lastRoute",void 0),e([m({value:50})],x.prototype,"maxStops",null),e([m()],x.prototype,"routeSymbol",void 0),e([m({type:_})],x.prototype,"routeParameters",void 0),e([m()],x.prototype,"routeServiceUrl",void 0),e([m()],x.prototype,"selectedTravelMode",null),e([m({readOnly:!0})],x.prototype,"serviceDescription",void 0),e([m({readOnly:!0})],x.prototype,"state",null),e([m()],x.prototype,"error",void 0),e([m({type:s})],x.prototype,"stops",void 0),e([m({value:z})],x.prototype,"stopSymbols",null),e([m({readOnly:!0})],x.prototype,"timeAttribute",null),e([m()],x.prototype,"travelModes",null),e([m()],x.prototype,"view",void 0),e([m()],x.prototype,"getDirections",null),e([m()],x.prototype,"zoomToRoute",null),x=e([v("esri.widgets.Directions.DirectionsViewModel")],x);const P=x;export{P as default};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../Color.js";import r from"../../Graphic.js";import"../../symbols.js";import o from"../../core/Collection.js";import i from"../../core/Error.js";import s from"../../core/Evented.js";import{HandleOwnerMixin as l}from"../../core/HandleOwner.js";import{isNone as n,isSome as a}from"../../core/maybe.js";import{isAbortError as c}from"../../core/promiseUtils.js";import{on as u,watch as p,initial as d}from"../../core/reactiveUtils.js";import{aliasOf as h}from"../../core/accessorSupport/decorators/aliasOf.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{cast as m}from"../../core/accessorSupport/decorators/cast.js";import{property as v}from"../../core/accessorSupport/decorators/property.js";import{subclass as y}from"../../core/accessorSupport/decorators/subclass.js";import{getLocale as g}from"../../intl/locale.js";import w from"../../layers/GraphicsLayer.js";import f from"../../layers/RouteLayer.js";import S from"../../layers/support/DefaultSymbols.js";import{fetchServiceDescription as b}from"../../rest/networkService.js";import _ from"../../rest/support/RouteParameters.js";import T from"../../rest/support/Stop.js";import{GoToMixin as D}from"../support/GoTo.js";import j from"../../symbols/SimpleLineSymbol.js";import M from"../../symbols/SimpleMarkerSymbol.js";import C from"../../symbols/PictureMarkerSymbol.js";function L(e){return e.length>0&&e.getItemAt(0)instanceof r}const A=o.ofType(T),z=[105,220,255],R=new j({color:z,width:7,cap:"round",join:"round"}),U={first:new M({color:z,size:19,outline:{color:[51,51,51],width:3}}),middle:new M({color:[51,51,51],size:12,outline:{color:z,width:3}}),last:new C({width:23,height:23,url:`data:image/svg+xml;base64,${btoa('<svg width="30" height="30" viewBox="0 0 30 30" xmlns="http://www.w3.org/2000/svg"><g fill-rule="nonzero" fill="none"><path d="M15.15.3C6.9.3.3 6.9.3 15.15S6.9 29.7 15.15 29.7 29.7 23.1 29.7 15.15C29.7 6.9 23.25.3 15.15.3z" fill="#333"/><path d="M15 4.8C9.3 4.8 4.8 9.45 4.8 15c0 5.55 4.65 10.2 10.2 10.2 5.55 0 10.2-4.5 10.2-10.2 0-5.55-4.5-10.2-10.2-10.2z" fill="#69DCFF"/><path fill="#333" d="M10.5 10.5h9v9h-9z"/></g></svg>')}`}),unlocated:new C({height:18,width:18,url:`data:image/svg+xml;base64,${btoa('<svg width="20" height="20" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><g fill="none" fill-rule="evenodd"><path d="M10.1.2C4.6.2.2 4.6.2 10.1s4.4 9.7 9.9 9.7 9.7-4.4 9.7-9.7c0-5.5-4.3-9.9-9.7-9.9z" fill="#333" fill-rule="nonzero"/><path d="M10 2.7c-4.08 0-7.3 3.328-7.3 7.3s3.328 7.3 7.3 7.3 7.3-3.22 7.3-7.3c0-3.972-3.22-7.3-7.3-7.3z" fill="#69DCFF" fill-rule="nonzero"/><path d="M11.414 10l5.304-5.303-1.415-1.415L10 8.586 4.697 3.282 3.282 4.697 8.586 10l-5.304 5.303 1.415 1.415L10 11.414l5.303 5.304 1.415-1.415L11.414 10z" fill="#333"/></g></svg>')}`}),waypoint:new M({color:[255,255,255],size:10,outline:{color:[20,89,127],width:2.5}})};var x;!function(e){e[e.Active=0]="Active",e[e.Complete=1]="Complete",e[e.Failed=2]="Failed",e[e.Idle=3]="Idle",e[e.Suspended=4]="Suspended"}(x||(x={}));let P=class extends(l(D(s.EventedAccessor))){constructor(e){super(e),this._highlightLayer=new w({listMode:"hide"}),this._routeController=null,this._serviceDescriptionStatus=x.Idle,this.apiKey=void 0,this.departureTime="now",this.lastRoute=null,this.routeLayer=new f({listMode:"show",defaultSymbols:new S({directionLines:R,directionPoints:new M({size:0}),routeInfo:new j({width:0}),firstStop:U.first,middleStop:U.middle,lastStop:U.last,invalidStop:U.unlocated,waypointStop:U.waypoint,breakStop:U.waypoint})}),this.routeSymbol=R,this.routeParameters=new _({directionsLengthUnits:"kilometers",findBestSequence:!1,restrictUTurns:"at-dead-ends-and-intersections",returnZ:!0,startTime:null,startTimeIsUTC:!0,useHierarchy:!0,useTimeWindows:!1}),this.routeServiceUrl="https://route-api.arcgis.com/arcgis/rest/services/World/Route/NAServer/Route_World",this.serviceDescription=null,this.error=null,this.stops=new A,this.view=null}initialize(){this.handles.add([u((()=>this.stops),"change",(()=>{this.clearResults()})),p((()=>{var e;return null==(e=this.view)?void 0:e.map}),((e,t)=>{const r=[this.routeLayer,this._highlightLayer];t&&t.removeMany(r),e&&e.addMany(r)}),d),p((()=>this.routeServiceUrl),(()=>{this.routeLayer.url=this.routeServiceUrl,this._set("serviceDescription",null),this.load()}),d)])}destroy(){var e;null==(e=this.view)||e.map.removeMany([this.routeLayer,this._highlightLayer])}get _directionsLanguage(){var e;if(n(this.serviceDescription))return;const t=this.serviceDescription.directionsSupportedLanguages;if(!t)return;const r=(null!=(e=this.routeParameters.directionsLanguage)?e:g()).slice(0,2);return t.find((e=>e.toLowerCase().slice(0,2)===r))}get impedanceAttribute(){var e,t,r;const o=a(this.serviceDescription)?this.serviceDescription.impedance:null,i=null!=(e=null!=(t=null==(r=this.routeParameters.travelMode)?void 0:r.impedanceAttributeName)?t:this.routeParameters.impedanceAttribute)?e:o;return this.getCostAttribute(i)}set maxStops(e){const t=50,r=2;e=e<=r?r:e>t?t:e,this._set("maxStops",e)}get selectedTravelMode(){const{serviceDescription:e}=this;if(n(e))return null;const{defaultTravelMode:t,supportedTravelModes:r=[]}=e;return r.find((e=>e.id===t))||r[0]||null}set selectedTravelMode(e){void 0!==e?this._override("selectedTravelMode",e):this._clearOverride("selectedTravelMode")}get state(){if(a(this._routeController))return"routing";if(a(this.error))return"error";switch(this._serviceDescriptionStatus){case x.Suspended:return"unauthenticated";case x.Idle:return"disabled";case x.Active:return"initializing";case x.Failed:return"error";default:return"ready"}}castStops(e){return L(e)?new o(e.map((e=>T.fromJSON(e.toJSON())))):e}set stopSymbols(e){const t={...U,...e};this._set("stopSymbols",t)}get timeAttribute(){var e,t,r;const o=null!=(e=null!=(t=null==(r=this.routeParameters.travelMode)?void 0:r.timeAttributeName)?t:this.routeParameters.directionsTimeAttribute)?e:a(this.serviceDescription)?this.serviceDescription.directionsTimeAttribute:null;return this.getCostAttribute(o)}get travelModes(){return a(this.serviceDescription)?this.serviceDescription.supportedTravelModes:[]}async load(){if(!a(this.serviceDescription))try{this._serviceDescriptionStatus=x.Active;const e=await b(this.routeServiceUrl,this.apiKey);this._set("serviceDescription",e),this._serviceDescriptionStatus=x.Complete}catch(e){const t="identity-manager:user-aborted"===e.name;if(this._serviceDescriptionStatus=t?x.Suspended:x.Failed,!t){const t=new i("directions-view-model:service-metadata-unavailable","Cannot load route service metadata",{error:e});throw this._set("error",t),t}}}highlightSegment(e){const{geometry:o,symbol:i}=e;if(n(this.view)||n(o)||n(i))return;this.clearHighlights();const s=i.clone();s.color=new t([0,0,0,.8]),s.width=Math.ceil(s.width/2);const l=new r({geometry:o,symbol:s});this._highlightLayer.add(l)}clearHighlights(){this._highlightLayer.removeAll()}centerAt(e){this.view&&this.callGoTo({target:e})}clearResults(){this._set("lastRoute",null)}async getDirections(){const{state:e}=this;if("unauthenticated"===e||"initializing"===e||"disabled"===e||this._serviceDescriptionStatus===x.Failed)return Promise.reject(new i("directions-view-model:not-loaded","Cannot get directions until view model loads."));this._set("error",null),a(this._routeController)&&(this._routeController.abort(),this._routeController=null);const{apiKey:t,departureTime:r}=this,o="now"===r,s="now"===r?new Date:r;if(s&&!o){const e=60*s.getTimezoneOffset()*1e3;s.setTime(s.getTime()-e)}const l=this.routeParameters.clone();if(l.set({startTime:s,startTimeIsUTC:o,directionsLanguage:this._directionsLanguage,apiKey:t}),a(this.selectedTravelMode)&&(l.travelMode=this.selectedTravelMode),this.stops.length<2){const e=new i("directions-view-model:not-enough-stops","Not enough stops for routing");return this._set("error",e),Promise.reject(e)}const n=new AbortController,{signal:u}=n;this._routeController=n;let p=null;try{p=await this.routeLayer.solve(l,{signal:u}),this.routeLayer.update(p),this._set("lastRoute",p)}catch(d){if(!c(d)){const e=new i("directions-view-model:unable-to-route","Unable to route to these addresses",{error:d});throw this._set("error",e),this._set("lastRoute",null),e}}finally{this._routeController=null}return this.zoomToRoute(),p}getCostAttribute(e){const t=(a(this.serviceDescription)?this.serviceDescription.networkDataset.networkAttributes:[]).find((t=>t.name===e&&"esriNAUTCost"===t.usageType));return null!=t?t:null}reset(){this.clearHighlights(),this.clearResults(),this.routeLayer.removeAll()}zoomToRoute(){const{view:e,lastRoute:t}=this;if(!e||n(t))return;const{routeInfo:r}=t;if(n(r))return;const{geometry:o}=r;if(n(o))return;const{extent:i}=o,s=i.width>i.height,l=i.clone().expand(s?2:1);this.callGoTo({target:l})}};e([v()],P.prototype,"_directionsLanguage",null),e([v()],P.prototype,"_routeController",void 0),e([v()],P.prototype,"_serviceDescriptionStatus",void 0),e([v()],P.prototype,"apiKey",void 0),e([v()],P.prototype,"departureTime",void 0),e([v({readOnly:!0})],P.prototype,"impedanceAttribute",null),e([v({readOnly:!0})],P.prototype,"lastRoute",void 0),e([v({value:50})],P.prototype,"maxStops",null),e([v()],P.prototype,"routeLayer",void 0),e([v()],P.prototype,"routeSymbol",void 0),e([v({type:_,nonNullable:!0})],P.prototype,"routeParameters",void 0),e([v({nonNullable:!0})],P.prototype,"routeServiceUrl",void 0),e([v()],P.prototype,"selectedTravelMode",null),e([v({readOnly:!0})],P.prototype,"serviceDescription",void 0),e([v({readOnly:!0})],P.prototype,"state",null),e([v()],P.prototype,"error",void 0),e([v({type:A,nonNullable:!0}),h("routeLayer.stops")],P.prototype,"stops",void 0),e([m("stops")],P.prototype,"castStops",null),e([v({value:U})],P.prototype,"stopSymbols",null),e([v({readOnly:!0})],P.prototype,"timeAttribute",null),e([v()],P.prototype,"travelModes",null),e([v()],P.prototype,"view",void 0),e([v()],P.prototype,"getDirections",null),e([v()],P.prototype,"zoomToRoute",null),P=e([y("esri.widgets.Directions.DirectionsViewModel")],P);const O=P;export{O as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.23/esri/copyright.txt for details.
4
4
  */
5
- import"../../../intl.js";import{formatDate as t}from"../../../intl/date.js";import{formatNumber as e}from"../../../intl/number.js";import{substitute as r}from"../../../intl/substitute.js";function n(t,e){return!(!A(t)||!e||-22091616e5===t.get("attributes.ETA"))}function i(r,n,i,s){const u=new Date(i),o=new Date(u.getTime()+60*u.getTimezoneOffset()*1e3),a=t(o,{hour:"2-digit",minute:"2-digit",hour12:!1});if(n){const t=(i-n)/1e3/60/60,s=Math.floor(t),u=60*(t-s),o=e(s,{minimumIntegerDigits:2}),c=e(u,{minimumIntegerDigits:2});return`${a} ${r.gmt}${s<0?"":"+"}${o}${c}`}return s?t(o,{hour:"numeric",minute:"numeric"}):a}function s(t){return"esriNAUSeconds"===t||"esriNAUMinutes"===t||"esriNAUHours"===t||"esriNAUDays"===t}function u(t,e,r){const n=s(e),i=s(r),u=n?o(t,e):c(t,e);return n===i?i?a(u,r):l(u,r):t}function o(t,e,r){switch(t=t||0,e){case"esriNAUSeconds":t/=60**(r?-1:1);break;case"esriNAUHours":t*=60**(r?-1:1);break;case"esriNAUDays":t*=1440**(r?-1:1)}return t}function a(t,e){return o(t,e,!0)}function c(t,e,r){switch(t=t||0,(e||"").replace("esriNAU","esri")){case"esriInches":t*=.0254**(r?-1:1);break;case"esriFeet":t*=.3048**(r?-1:1);break;case"esriYards":t*=.9144**(r?-1:1);break;case"esriMiles":t*=1609.344**(r?-1:1);break;case"esriNauticalMiles":t*=1851.995396854**(r?-1:1);break;case"esriMillimeters":t/=1e3**(r?-1:1);break;case"esriCentimeters":t/=100**(r?-1:1);break;case"esriKilometers":t*=1e3**(r?-1:1);break;case"esriDecimeters":t/=10**(r?-1:1)}return t}function l(t,e){return c(t,e,!0)}function m(t){const e=t&&t.attributes||{};return null===(e.ArriveCurbApproach||null)&&null!==(e.DepartCurbApproach||null)}function f(t){const e=t&&t.attributes||{};return null!==(e.ArriveCurbApproach||null)&&null!==(e.DepartCurbApproach||null)}function p(t){const e=t&&t.attributes||{};return null!==(e.ArriveCurbApproach||null)&&null===(e.DepartCurbApproach||null)}function b(t){return t&&t.get("attributes.isWaypoint")}function h(t){const e=t&&t.get("attributes.Status");return!e||6===e}function A(t){return t._associatedStop}function g(t,e={}){const{unit:r="minutes"}=e;return d(t,r)}function d(t,e){const r=60,n=60,i="days"===(e=e.toLowerCase())?t*24:"hours"===e?t:"minutes"===e?t/r:t/r/n;if(i<1)return`${Math.floor(i*n)}m`;const s=i%1*r;return`${Math.floor(i)}:${String(Math.floor(s)).padStart(2,"0")}h`}function D(t,e,n,i={}){const{fromUnits:s,toUnits:o}=i,a=u(n,s,o);if(!a)return"";const c=e.units[o],l=c?c.abbr:o.replace("esri","").toLowerCase();return r(t.distanceTemplate,{distance:a,units:l},{format:{distance:{type:"number",intlOptions:{minimumFractionDigits:2,maximumFractionDigits:2}}}})}export{u as convertCostValue,D as formatDistance,g as formatTime,l as fromMeters,a as fromMinutes,A as getAssociatedStop,m as isFirstStop,p as isLastStop,f as isMiddleStop,h as isStopLocated,s as isTimeUnits,b as isWaypoint,c as toMeters,o as toMinutes,i as toSpatiallyLocalTimeString,n as useSpatiallyLocalTime};
5
+ import"../../../intl.js";import"../../../core/has.js";import{convertUnit as t}from"../../../core/unitUtils.js";import{substitute as r}from"../../../intl/substitute.js";function n(t){return"esriNAUSeconds"===t||"esriNAUMinutes"===t||"esriNAUHours"===t||"esriNAUDays"===t}function i(t,r){const n=s(t,r);if(n<1)return`${Math.floor(60*n)}m`;const i=n%1*60;return`${Math.floor(n)}:${String(Math.floor(i)).padStart(2,"0")}h`}function s(t,r){switch(r){case"days":return 24*t;case"hours":return t;case"minutes":return t/60;case"seconds":return t/60/60;default:return 0}}function e(n,i,s,e){const{fromUnits:o,toUnits:u}=e,a=t(s,o,u);if(!a)return"";const c=i.units[u],m=c?c.abbr:u.toLowerCase();return r(n.distanceTemplate,{distance:a,units:m},{format:{distance:{type:"number",intlOptions:{minimumFractionDigits:2,maximumFractionDigits:2}}}})}export{e as formatDistance,i as formatTime,n as isTimeUnits};