@arcgis/core 4.28.0-next.20230711 → 4.28.0-next.20230713

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 (83) hide show
  1. package/assets/esri/core/workers/RemoteClient.js +1 -1
  2. package/assets/esri/core/workers/chunks/08ee2bd914867fd2cbd5.js +1 -0
  3. package/assets/esri/core/workers/chunks/{4f92fd5167e22c602e8a.js → 169b04f05f5c875c5083.js} +1 -1
  4. package/assets/esri/core/workers/chunks/{d2f9988b576ac968dd92.js → 3a614d35dec6deebd041.js} +1 -1
  5. package/assets/esri/core/workers/chunks/55109f141c9f120833f6.js +1 -0
  6. package/assets/esri/core/workers/chunks/{086173d3ada7857eea15.js → 7c585aee0f931e6b56c0.js} +1 -1
  7. package/assets/esri/core/workers/chunks/{27fec382097efdcfee8a.js → 839d9039f0628ee98466.js} +1 -1
  8. package/assets/esri/core/workers/chunks/8c5a8c1dfb086069bb06.js +1 -0
  9. package/assets/esri/core/workers/chunks/{f156387d6c645b18a8dd.js → b2a0e3e1dfccda7ed12e.js} +1 -1
  10. package/assets/esri/core/workers/chunks/d4881b238c8a93390cde.js +1 -0
  11. package/assets/esri/core/workers/chunks/dcb004dfba27335c7c3c.js +1 -0
  12. package/assets/esri/core/workers/chunks/e3610549f4c573e705ba.js +1 -0
  13. package/assets/esri/core/workers/chunks/{ad38aede3ec854191511.js → f6e24113643784bc6731.js} +1 -1
  14. package/assets/esri/core/workers/chunks/{3a0e2535f6cdb2e65667.js → fb610982b1366cdbc0c3.js} +1 -1
  15. package/assets/esri/core/workers/chunks/{5583921a498172edd5ac.js → fcab431f13b4a9f92dbf.js} +1 -1
  16. package/assets/esri/themes/base/_mixins.scss +3 -1
  17. package/assets/esri/themes/base/widgets/_BasemapGallery.scss +6 -2
  18. package/assets/esri/themes/base/widgets/_BasemapLayerList.scss +6 -2
  19. package/assets/esri/themes/base/widgets/_Bookmarks.scss +3 -1
  20. package/assets/esri/themes/base/widgets/_BuildingLevelPicker.scss +6 -2
  21. package/assets/esri/themes/base/widgets/_ColorPicker.scss +3 -1
  22. package/assets/esri/themes/base/widgets/_Expand.scss +3 -1
  23. package/assets/esri/themes/base/widgets/_FeatureForm.scss +3 -1
  24. package/assets/esri/themes/base/widgets/_LayerList.scss +6 -2
  25. package/assets/esri/themes/base/widgets/_Popup.scss +3 -1
  26. package/assets/esri/themes/base/widgets/_ScaleBar.scss +7 -2
  27. package/assets/esri/themes/base/widgets/_SnappingControls.scss +6 -2
  28. package/assets/esri/themes/base/widgets/_TableList.scss +6 -2
  29. package/assets/esri/themes/base/widgets/_Widget.scss +3 -1
  30. package/copyright.txt +19 -20
  31. package/core/Collection.js +1 -1
  32. package/core/accessorSupport/ensureType.js +1 -1
  33. package/core/accessorSupport/set.js +1 -1
  34. package/layers/VoxelLayer.js +1 -1
  35. package/layers/VoxelWasmPerSceneView.js +1 -1
  36. package/layers/graphics/editingSupport.js +1 -1
  37. package/layers/support/rasterDatasets/ImageServerRaster.js +1 -1
  38. package/layers/support/rasterDatasets/multipartParser.js +1 -1
  39. package/layers/support/wmtsUtils.js +1 -1
  40. package/package.json +1 -1
  41. package/support/revision.js +1 -1
  42. package/views/3d/environment/EnvironmentRenderer.js +1 -1
  43. package/views/3d/externalRenderers/ExternalRendererStore.js +1 -1
  44. package/views/3d/layers/i3s/PointRenderer.js +1 -1
  45. package/views/3d/support/LaserLineRenderer.js +1 -1
  46. package/views/3d/support/engineContent/line.js +1 -1
  47. package/views/3d/terrain/PatchRenderData.js +1 -1
  48. package/views/3d/terrain/TerrainRenderer.js +1 -1
  49. package/views/3d/terrain/TileRenderer.js +1 -1
  50. package/views/3d/webgl-engine/core/renderPasses/RenderPassManager.js +1 -1
  51. package/views/3d/webgl-engine/core/shaderLibrary/shading/LineStipple.glsl.js +17 -21
  52. package/views/3d/webgl-engine/lib/GLMaterialRepository.js +1 -1
  53. package/views/3d/webgl-engine/lib/GLMaterials.js +1 -1
  54. package/views/3d/webgl-engine/lib/RenderPluginManager.js +1 -1
  55. package/views/3d/webgl-engine/lib/Renderer.js +1 -1
  56. package/views/3d/webgl-engine/lib/SmaaRenderPass.js +1 -1
  57. package/views/3d/webgl-engine/lib/lodRendering/LodRenderer.js +1 -1
  58. package/views/3d/webgl-engine/materials/CheckerBoardMaterial.js +1 -1
  59. package/views/3d/webgl-engine/materials/ColorMaterial.js +1 -1
  60. package/views/3d/webgl-engine/materials/DefaultMaterial.js +1 -1
  61. package/views/3d/webgl-engine/materials/HUDMaterial.js +1 -1
  62. package/views/3d/webgl-engine/materials/HeatmapDensityMaterial.js +1 -1
  63. package/views/3d/webgl-engine/materials/ImageMaterial.js +1 -1
  64. package/views/3d/webgl-engine/materials/LineCalloutMaterial.js +1 -1
  65. package/views/3d/webgl-engine/materials/LineMarkerMaterial.js +1 -1
  66. package/views/3d/webgl-engine/materials/MeasurementArrowMaterial.js +1 -1
  67. package/views/3d/webgl-engine/materials/NativeLineMaterial.js +1 -1
  68. package/views/3d/webgl-engine/materials/PathMaterial.js +1 -1
  69. package/views/3d/webgl-engine/materials/PatternMaterial.js +1 -1
  70. package/views/3d/webgl-engine/materials/RibbonLineMaterial.js +1 -1
  71. package/views/3d/webgl-engine/materials/ShadedColorMaterial.js +1 -1
  72. package/views/3d/webgl-engine/materials/SlicePlaneMaterial.js +1 -1
  73. package/views/3d/webgl-engine/materials/WaterMaterial.js +1 -1
  74. package/views/3d/webgl-engine/materials/renderers/MergedRenderer.js +1 -1
  75. package/views/3d/webgl-engine/materials/stippleTextureRepository.js +1 -1
  76. package/widgets/ElevationProfile/support/ProfileGenerationError.js +1 -1
  77. package/widgets/ElevationProfile/support/chartUtils.js +1 -1
  78. package/assets/esri/core/workers/chunks/00b023cb63f23bc074b8.js +0 -1
  79. package/assets/esri/core/workers/chunks/1e413a44b35bfecbfa59.js +0 -1
  80. package/assets/esri/core/workers/chunks/71c029f95cb4666ae207.js +0 -1
  81. package/assets/esri/core/workers/chunks/c9ef45225947ccc2bd4c.js +0 -1
  82. package/assets/esri/core/workers/chunks/dda6fab95d50c1215808.js +0 -1
  83. package/assets/esri/core/workers/chunks/f5f0a5318337439d464e.js +0 -1
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../../core/Collection.js";import t from"../../../core/Logger.js";import{removeMaybe as r}from"../../../core/maybe.js";import{watch as n,initial as s}from"../../../core/reactiveUtils.js";import i from"./RenderContext.js";import{ShaderOutput as d}from"../webgl-engine/core/shaderLibrary/ShaderOutput.js";import{RenderSlot as o}from"../webgl-engine/lib/RenderSlot.js";class a{constructor(){this._renderers=new e}add(e,t){this._findOrCreateStageRenderer(e).add(t)}remove(e,t){const r=this._findStageRenderer(e);r&&(r.remove(t),0===r.renderers.length&&(r.destroy(),this._renderers.remove(r)))}_findStageRenderer(e){return this._renderers.find((t=>t.view===e))}_findOrCreateStageRenderer(e){let t=this._findStageRenderer(e);return t||(t=new h(e),this._renderers.add(t)),t}}class h{constructor(t){this.view=t,this.canRender=!0,this.renderers=new e,this.context=null,this.renderSlots=[o.OPAQUE_MATERIAL,o.TRANSPARENT_MATERIAL],this._readyWatchHandle=n((()=>t.ready),(e=>{e?(this.context=new i(this.view),this.view._stage.addRenderPlugin(this)):(this.renderers.forEach((e=>c(e,"dispose",this.context))),this.context=null)}),s)}destroy(){this.renderers.drain((e=>{this.context&&c(e,"dispose",this.context)})),this.view._stage?.removeRenderPlugin(this),this._readyWatchHandle=r(this._readyWatchHandle),this.context=null}add(e){this.renderers.includes(e)?t.getLogger("esri.views.3d.externalRenderers.ExternalRendererStore").warn("add(): Cannot add external renderer: renderer has already been added"):(this.renderers.add(e),this.context&&(this._webglStateReset(),c(e,"setup",this.context),this.view._stage.renderView.requestRender()))}remove(e){const t=this.renderers.indexOf(e);-1!==t&&(this.renderers.removeAt(t),this.context&&(c(e,"dispose",this.context),this.view._stage.renderView.requestRender()))}initializeRenderContext(e){this.context.rctx=e.renderContext.rctx,this.renderers.length>0&&this._webglStateReset(),this.renderers.forEach((e=>c(e,"setup",this.context)))}uninitializeRenderContext(){}render(e){0===this.renderers.length||e.output!==d.Color||e.bindParameters.slot!==o.OPAQUE_MATERIAL&&e.bindParameters.slot!==o.TRANSPARENT_MATERIAL||(this._updateContext(e),this._webglStateReset(),this.renderers.forEach((t=>{switch(e.bindParameters.slot){case o.OPAQUE_MATERIAL:c(t,"render",this.context);break;case o.TRANSPARENT_MATERIAL:c(t,"renderTransparent",this.context)}})))}_updateContext(e){this.context.camera.copyFrom(e.bindParameters.camera),this.context.sunLight=e.bindParameters.lighting.legacy,this.context._renderTargetHelper=e.offscreenRenderingHelper}_webglStateReset(){this.context.rctx.resetState(),this.context._renderTargetHelper?.bindFbo()}get needsTransparentPass(){return this.renderers.some((e=>"function"==typeof e.renderTransparent))}}function c(e,t,r){"function"==typeof e[t]&&null!=r&&e[t]?.(r)}export{a as default};
5
+ import e from"../../../core/Collection.js";import t from"../../../core/Logger.js";import{removeMaybe as r}from"../../../core/maybe.js";import{watch as n,initial as s}from"../../../core/reactiveUtils.js";import i from"./RenderContext.js";import{ShaderOutput as d}from"../webgl-engine/core/shaderLibrary/ShaderOutput.js";import{RenderSlot as o}from"../webgl-engine/lib/RenderSlot.js";class a{constructor(){this._renderers=new e}add(e,t){this._findOrCreateStageRenderer(e).add(t)}remove(e,t){const r=this._findStageRenderer(e);r&&(r.remove(t),0===r.renderers.length&&(r.destroy(),this._renderers.remove(r)))}_findStageRenderer(e){return this._renderers.find((t=>t.view===e))}_findOrCreateStageRenderer(e){let t=this._findStageRenderer(e);return t||(t=new h(e),this._renderers.add(t)),t}}class h{canRender(e){return e!==o.TRANSPARENT_MATERIAL||this.renderers.some((e=>"function"==typeof e.renderTransparent))}requiresOutput(){return!1}constructor(t){this.view=t,this.renderers=new e,this.context=null,this.renderSlots=[o.OPAQUE_MATERIAL,o.TRANSPARENT_MATERIAL],this._readyWatchHandle=n((()=>t.ready),(e=>{e?(this.context=new i(this.view),this.view._stage.addRenderPlugin(this)):(this.renderers.forEach((e=>c(e,"dispose",this.context))),this.context=null)}),s)}destroy(){this.renderers.drain((e=>{this.context&&c(e,"dispose",this.context)})),this.view._stage?.removeRenderPlugin(this),this._readyWatchHandle=r(this._readyWatchHandle),this.context=null}add(e){this.renderers.includes(e)?t.getLogger("esri.views.3d.externalRenderers.ExternalRendererStore").warn("add(): Cannot add external renderer: renderer has already been added"):(this.renderers.add(e),this.context&&(this._webglStateReset(),c(e,"setup",this.context),this.view._stage.renderView.requestRender()))}remove(e){const t=this.renderers.indexOf(e);-1!==t&&(this.renderers.removeAt(t),this.context&&(c(e,"dispose",this.context),this.view._stage.renderView.requestRender()))}initializeRenderContext(e){this.context.rctx=e.renderContext.rctx,this.renderers.length>0&&this._webglStateReset(),this.renderers.forEach((e=>c(e,"setup",this.context)))}uninitializeRenderContext(){}render(e){0===this.renderers.length||e.output!==d.Color||e.bindParameters.slot!==o.OPAQUE_MATERIAL&&e.bindParameters.slot!==o.TRANSPARENT_MATERIAL||(this._updateContext(e),this._webglStateReset(),this.renderers.forEach((t=>{switch(e.bindParameters.slot){case o.OPAQUE_MATERIAL:c(t,"render",this.context);break;case o.TRANSPARENT_MATERIAL:c(t,"renderTransparent",this.context)}})))}_updateContext(e){this.context.camera.copyFrom(e.bindParameters.camera),this.context.sunLight=e.bindParameters.lighting.legacy,this.context._renderTargetHelper=e.offscreenRenderingHelper}_webglStateReset(){this.context.rctx.resetState(),this.context._renderTargetHelper?.bindFbo()}}function c(e,t,r){"function"==typeof e[t]&&null!=r&&e[t]?.(r)}export{a 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.28/esri/copyright.txt for details.
4
4
  */
5
- import{disposeMaybe as e}from"../../../../core/maybe.js";import t from"../../../../core/PooledArray.js";import{b as s,l as i,g as r,o as n,e as o,p as a}from"../../../../chunks/vec3.js";import{c as h}from"../../../../chunks/vec3f64.js";import{s as l}from"../../../../chunks/vec4.js";import{create as c,offset as u,contains as d,containsPoint as p,set as m,POSITIVE_INFINITY as g,equals as _}from"../../../../geometry/support/aaBoundingBox.js";import{create as f}from"../../../../geometry/support/plane.js";import{fromPoints as P}from"../../../../geometry/support/ray.js";import{PclTarget as b}from"./Intersector.js";import{PointHighlights as S}from"./PointHighlights.js";import{minimumDistancePlane as x,maximumDistancePlane as z,intersectLine as R,toAaBoundingBox as w}from"../../support/orientedBoundingBox.js";import{ShaderOutput as q}from"../../webgl-engine/core/shaderLibrary/ShaderOutput.js";import{Default3D as A}from"../../webgl-engine/lib/DefaultVertexAttributeLocations.js";import{newIntersectorResult as y}from"../../webgl-engine/lib/Intersector.js";import{IntersectorType as j,StoreResults as I}from"../../webgl-engine/lib/IntersectorInterfaces.js";import{RenderSlot as E}from"../../webgl-engine/lib/RenderSlot.js";import{VertexArrayObject as F}from"../../webgl-engine/lib/VertexArrayObject.js";import{VertexAttribute as v}from"../../webgl-engine/lib/VertexAttribute.js";import{P as C,a as O,g as H}from"../../../../chunks/PointRenderer.glsl.js";import{PointRendererTechnique as L}from"../../webgl-engine/shaders/PointRendererTechnique.js";import{PointRendererTechniqueConfiguration as N}from"../../webgl-engine/shaders/PointRendererTechniqueConfiguration.js";import{BufferObject as T}from"../../../webgl/BufferObject.js";import{DataType as B,PrimitiveType as M,Usage as D}from"../../../webgl/enums.js";import{VertexElementDescriptor as U}from"../../../webgl/VertexElementDescriptor.js";const V={positions:[new U(v.POSITION,3,B.FLOAT,0,12)],colors:[new U(v.COLOR,3,B.UNSIGNED_BYTE,0,3,!0)]};class W{get needsHighlight(){return this._highlights.hasHighlights}constructor(e){this._params=e,this.type=j.PCL,this.isGround=!1,this.renderSlots=[E.OPAQUE_MATERIAL],this._passParameters=new C,this._highlights=new S({forEachNode:e=>this.forEachNode(e),addHighlight:(e,t,s)=>this._addHighlight(e,t,s),removeHighlight:(e,t)=>this._removeHighlight(e,t)}),this.canRender=!0,this.layerUid="",this._slicePlaneEnabled=!1,this._techniqueConfig=new N,this._nodes=new t}initializeRenderContext(e){this._context=e,this._techniqueRepository=this._context.techniqueRepository,e.requestRender()}uninitializeRenderContext(){}intersect(e,t,m,g){const _=h(),S=h(),q=h(),A=h(),j=f(),E=e.camera.perScreenPixelRatio/2,F=e.camera.near;s(S,g,m);const v=1/i(S);r(S,S,v),n(q,S),l(j,S[0],S[1],S[2],-o(S,m));const C=new $,O=new $,H=new Array,L=c(),N=c(this._passParameters.clipBox);u(N,-m[0],-m[1],-m[2],N),this._nodes.forAll((i=>{const r=i.splatSize*this._passParameters.scaleFactor;let n=x(i.obb,j),h=z(i.obb,j);n-=Y(r,n+F,this._passParameters,E,i.isLeaf),h-=Y(r,h+F,this._passParameters,E,i.isLeaf);const l=h<0,c=null!=C.dist&&null!=O.dist&&C.dist<n*v&&O.dist>h*v;if(l||c)return;const f=Q(r,h+F,this._passParameters,E,i.isLeaf);if(!R(i.obb,m,S,f))return;const P=f*f;w(i.obb,L),u(L,-m[0],-m[1],-m[2],L);const b=!d(N,L);s(A,i.origin,m);const y=i.coordinates.length/3;for(let s=0;s<y;s++){if(_[0]=A[0]+i.coordinates[3*s],_[1]=A[1]+i.coordinates[3*s+1],_[2]=A[2]+i.coordinates[3*s+2],b&&!p(N,_))continue;const n=o(_,S),h=a(_)-n*n;if(h>P)continue;let l=n+F;const c=Y(r,l,this._passParameters,E,i.isLeaf);if(n-c<0)continue;l-=c;const u=Q(r,l,this._passParameters,E,i.isLeaf);if(h>u*u)continue;const d=(n-c)*v,f=e=>(e.point=J(i,s,e.point),e.dist=d,e.normal=q,e.node=i,e.pointId=s,e.layerUid=this.layerUid,e);if((null==C.dist||d<C.dist)&&(null==t||t(m,g,d))&&f(C),e.options.store!==I.MIN&&(null==O.dist||d>O.dist)&&(null==t||t(m,g,d))&&f(O),e.options.store===I.ALL&&(null==t||t(m,g,d))){const e=new $;H.push(f(e))}}}));const T=e=>{const{layerUid:t,node:s,pointId:i}=e;return new b(e.point,t,i,(()=>this._params.createGraphic(s,i,e.point)))},B=(e,t)=>{const s=T(t);e.set(this.type,s,t.dist,t.normal)};if(ee(C)){const t=e.results.min;(null==t.dist||C.dist<t.dist)&&B(t,C)}if(ee(O)&&e.options.store!==I.MIN){const t=e.results.max;(null==t.dist||O.dist>t.dist)&&B(t,O)}if(e.options.store===I.ALL){const t=P(m,g);for(const s of H){const i=y(t);B(i,s),e.results.all.push(i)}}}prepareTechnique(e){return 0===this._nodes.length||e.output!==q.Color&&e.output!==q.Depth&&e.output!==q.Highlight?null:(this._nodes.forAll((t=>{null==t.vao&&this._initNode(e,t)})),this._techniqueConfig.drawScreenSize=this._passParameters.drawScreenSpace,this._techniqueConfig.useFixedSizes=this._passParameters.useFixedSizes,this._techniqueConfig.hasSlicePlane=this._slicePlaneEnabled,this._techniqueConfig.hasOccludees=e.bindParameters.hasOccludees,this._techniqueConfig.clippingEnabled=this._clippingEnabled,this._techniqueConfig.output=e.output===q.Depth?q.Depth:e.output===q.Highlight?q.Highlight:q.Color,this._techniqueRepository.releaseAndAcquire(L,this._techniqueConfig,this._technique))}render(e,t){const s=e.rctx,i=s.bindTechnique(t,this._passParameters,e.bindParameters),r=e.output===q.Highlight;this._nodes.forAll((t=>{0===t.coordinates.length||r&&!t.highlights||(i.bindDraw(t,e.bindParameters,this._passParameters),s.bindVAO(t.vao),r?this._renderHighlightFragments(s,t):s.drawArrays(M.POINTS,0,t.coordinates.length/3))}))}_renderHighlightFragments(e,t){const s=t.highlights;if(null==s)return;let i=s[0].component,r=i+1;for(let o=1;o<s.length;o++){const t=s[o].component;if(t!==r){const s=r-i;s>0&&e.drawArrays(M.POINTS,i,s),i=t}r=t+1}const n=r-i;n>0&&e.drawArrays(M.POINTS,i,n)}set useFixedSizes(e){this._passParameters.useFixedSizes!==e&&(this._passParameters.useFixedSizes=e,this._requestRender())}get useFixedSizes(){return this._passParameters.useFixedSizes}set scaleFactor(e){this._passParameters.scaleFactor!==e&&(this._passParameters.scaleFactor=e,this._requestRender())}get scaleFactor(){return this._passParameters.scaleFactor}set minSizePx(e){this._passParameters.minSizePx!==e&&(this._passParameters.minSizePx=e,this._requestRender())}get minSizePx(){return this._passParameters.minSizePx}set useRealWorldSymbolSizes(e){this._passParameters.useRealWorldSymbolSizes!==e&&(this._passParameters.useRealWorldSymbolSizes=e,this._requestRender())}get useRealWorldSymbolSizes(){return this._passParameters.useRealWorldSymbolSizes}set size(e){this._passParameters.size!==e&&(this._passParameters.size=e,this._requestRender())}get size(){return this._passParameters.size}set sizePx(e){this._passParameters.sizePx!==e&&(this._passParameters.sizePx=e,this._requestRender())}get sizePx(){return this._passParameters.sizePx}set clippingBox(e){m(this._passParameters.clipBox,e||g)}get _clippingEnabled(){return!_(this._passParameters.clipBox,g,((e,t)=>e===t))}get slicePlaneEnabled(){return this._slicePlaneEnabled}set slicePlaneEnabled(e){this._slicePlaneEnabled!==e&&(this._slicePlaneEnabled=e,this._requestRender())}addNode(e){this._nodes.push(e),this._highlights.nodeAdded(e),this._requestRender()}removeNode(t){let s=null;return this._nodes.filterInPlace((i=>i.id!==t||(s=i,i.vao=e(i.vao),this._highlights.nodeRemoved(i),!1))),this._requestRender(),s}forEachNode(e){this._nodes.forAll(e)}removeAll(){this._nodes.forAll((t=>t.vao=e(t.vao))),this._highlights.removeAll(),this._nodes.clear(),this._requestRender()}highlight(e){return this._highlights.add(e)}_addHighlight(e,t,s){e.highlights=X(e.highlights,t,s),this._requestRender()}_removeHighlight(e,t){e.highlights=Z(e.highlights,t),this._requestRender()}_initNode(e,t){const s=e.rctx;t.vao=new F(s,A,V,{positions:T.createVertex(s,D.STATIC_DRAW,t.coordinates),colors:T.createVertex(s,D.STATIC_DRAW,t.rgb)})}_requestRender(){this._context&&this._context.requestRender()}}class k extends O{constructor(e,t,s,i,r,n,o,a,h=null,l=null){super(s,r,t),this.id=e,this.obb=i,this.coordinates=n,this.rgb=o,this.attributes=a,this.pointIdFilterMap=h,this.highlights=l}}function G(e){return e.hasOwnProperty("splatSize")}function Q(e,t,s,i,r){if(s.drawScreenSpace)return s.fixedSize*t*i;const n=H(r)*t*i;return s.useFixedSizes?Math.min(s.fixedSize/2,n):s.screenMinSize>0?Math.min(Math.max(s.screenMinSize*t*i,e/2),n):Math.min(e/2,n)}function Y(e,t,s,i,r){return s.drawScreenSpace?0:Q(e,t,s,i,r)}function J(e,t,s){return null==s&&(s=h()),s[0]=e.origin[0]+e.coordinates[3*t],s[1]=e.origin[1]+e.coordinates[3*t+1],s[2]=e.origin[2]+e.coordinates[3*t+2],s}function K(e){return null!=e.component?e.component:-1}function X(e,t,s){null==e&&(e=[]);const i={component:t,id:s};e.push(i);const r=K(i);let n=e.length-1;for(;n>0&&r<K(e[n-1]);)[e[n-1],e[n]]=[e[n],e[n-1]],--n;return e}function Z(e,t){if(null==e)return e;const s=e.filter((e=>e.id!==t));return 0===s.length?null:s}class ${constructor(){this.node=null,this.pointId=null,this.point=null,this.dist=null,this.normal=null,this.layerUid=""}}function ee(e){return null!=e.dist&&null!=e.point&&null!=e.pointId&&null!=e.node}export{W as PointRenderer,k as PointRendererNode,G as isInstanceOfNode};
5
+ import{disposeMaybe as e}from"../../../../core/maybe.js";import t from"../../../../core/PooledArray.js";import{b as s,l as i,g as r,o as n,e as o,p as a}from"../../../../chunks/vec3.js";import{c as h}from"../../../../chunks/vec3f64.js";import{s as l}from"../../../../chunks/vec4.js";import{create as c,offset as u,contains as d,containsPoint as p,set as m,POSITIVE_INFINITY as g,equals as _}from"../../../../geometry/support/aaBoundingBox.js";import{create as f}from"../../../../geometry/support/plane.js";import{fromPoints as P}from"../../../../geometry/support/ray.js";import{PclTarget as b}from"./Intersector.js";import{PointHighlights as S}from"./PointHighlights.js";import{minimumDistancePlane as x,maximumDistancePlane as z,intersectLine as R,toAaBoundingBox as q}from"../../support/orientedBoundingBox.js";import{ShaderOutput as w}from"../../webgl-engine/core/shaderLibrary/ShaderOutput.js";import{Default3D as A}from"../../webgl-engine/lib/DefaultVertexAttributeLocations.js";import{newIntersectorResult as y}from"../../webgl-engine/lib/Intersector.js";import{IntersectorType as j,StoreResults as I}from"../../webgl-engine/lib/IntersectorInterfaces.js";import{RenderSlot as E}from"../../webgl-engine/lib/RenderSlot.js";import{VertexArrayObject as F}from"../../webgl-engine/lib/VertexArrayObject.js";import{VertexAttribute as v}from"../../webgl-engine/lib/VertexAttribute.js";import{P as C,a as O,g as H}from"../../../../chunks/PointRenderer.glsl.js";import{PointRendererTechnique as L}from"../../webgl-engine/shaders/PointRendererTechnique.js";import{PointRendererTechniqueConfiguration as N}from"../../webgl-engine/shaders/PointRendererTechniqueConfiguration.js";import{BufferObject as T}from"../../../webgl/BufferObject.js";import{DataType as B,PrimitiveType as M,Usage as D}from"../../../webgl/enums.js";import{VertexElementDescriptor as U}from"../../../webgl/VertexElementDescriptor.js";const V={positions:[new U(v.POSITION,3,B.FLOAT,0,12)],colors:[new U(v.COLOR,3,B.UNSIGNED_BYTE,0,3,!0)]};class W{canRender(){return!0}requiresOutput(e){return e===w.Highlight&&this._highlights.hasHighlights}constructor(e){this._params=e,this.type=j.PCL,this.isGround=!1,this.renderSlots=[E.OPAQUE_MATERIAL],this._passParameters=new C,this._highlights=new S({forEachNode:e=>this.forEachNode(e),addHighlight:(e,t,s)=>this._addHighlight(e,t,s),removeHighlight:(e,t)=>this._removeHighlight(e,t)}),this.layerUid="",this._slicePlaneEnabled=!1,this._techniqueConfig=new N,this._nodes=new t}initializeRenderContext(e){this._context=e,this._techniqueRepository=this._context.techniqueRepository,e.requestRender()}uninitializeRenderContext(){}intersect(e,t,m,g){const _=h(),S=h(),w=h(),A=h(),j=f(),E=e.camera.perScreenPixelRatio/2,F=e.camera.near;s(S,g,m);const v=1/i(S);r(S,S,v),n(w,S),l(j,S[0],S[1],S[2],-o(S,m));const C=new $,O=new $,H=new Array,L=c(),N=c(this._passParameters.clipBox);u(N,-m[0],-m[1],-m[2],N),this._nodes.forAll((i=>{const r=i.splatSize*this._passParameters.scaleFactor;let n=x(i.obb,j),h=z(i.obb,j);n-=Y(r,n+F,this._passParameters,E,i.isLeaf),h-=Y(r,h+F,this._passParameters,E,i.isLeaf);const l=h<0,c=null!=C.dist&&null!=O.dist&&C.dist<n*v&&O.dist>h*v;if(l||c)return;const f=Q(r,h+F,this._passParameters,E,i.isLeaf);if(!R(i.obb,m,S,f))return;const P=f*f;q(i.obb,L),u(L,-m[0],-m[1],-m[2],L);const b=!d(N,L);s(A,i.origin,m);const y=i.coordinates.length/3;for(let s=0;s<y;s++){if(_[0]=A[0]+i.coordinates[3*s],_[1]=A[1]+i.coordinates[3*s+1],_[2]=A[2]+i.coordinates[3*s+2],b&&!p(N,_))continue;const n=o(_,S),h=a(_)-n*n;if(h>P)continue;let l=n+F;const c=Y(r,l,this._passParameters,E,i.isLeaf);if(n-c<0)continue;l-=c;const u=Q(r,l,this._passParameters,E,i.isLeaf);if(h>u*u)continue;const d=(n-c)*v,f=e=>(e.point=J(i,s,e.point),e.dist=d,e.normal=w,e.node=i,e.pointId=s,e.layerUid=this.layerUid,e);if((null==C.dist||d<C.dist)&&(null==t||t(m,g,d))&&f(C),e.options.store!==I.MIN&&(null==O.dist||d>O.dist)&&(null==t||t(m,g,d))&&f(O),e.options.store===I.ALL&&(null==t||t(m,g,d))){const e=new $;H.push(f(e))}}}));const T=e=>{const{layerUid:t,node:s,pointId:i}=e;return new b(e.point,t,i,(()=>this._params.createGraphic(s,i,e.point)))},B=(e,t)=>{const s=T(t);e.set(this.type,s,t.dist,t.normal)};if(ee(C)){const t=e.results.min;(null==t.dist||C.dist<t.dist)&&B(t,C)}if(ee(O)&&e.options.store!==I.MIN){const t=e.results.max;(null==t.dist||O.dist>t.dist)&&B(t,O)}if(e.options.store===I.ALL){const t=P(m,g);for(const s of H){const i=y(t);B(i,s),e.results.all.push(i)}}}prepareTechnique(e){return 0===this._nodes.length||e.output!==w.Color&&e.output!==w.Depth&&e.output!==w.Highlight?null:(this._nodes.forAll((t=>{null==t.vao&&this._initNode(e,t)})),this._techniqueConfig.drawScreenSize=this._passParameters.drawScreenSpace,this._techniqueConfig.useFixedSizes=this._passParameters.useFixedSizes,this._techniqueConfig.hasSlicePlane=this._slicePlaneEnabled,this._techniqueConfig.hasOccludees=e.bindParameters.hasOccludees,this._techniqueConfig.clippingEnabled=this._clippingEnabled,this._techniqueConfig.output=e.output===w.Depth?w.Depth:e.output===w.Highlight?w.Highlight:w.Color,this._techniqueRepository.releaseAndAcquire(L,this._techniqueConfig,this._technique))}render(e,t){const s=e.rctx,i=s.bindTechnique(t,this._passParameters,e.bindParameters),r=e.output===w.Highlight;this._nodes.forAll((t=>{0===t.coordinates.length||r&&!t.highlights||(i.bindDraw(t,e.bindParameters,this._passParameters),s.bindVAO(t.vao),r?this._renderHighlightFragments(s,t):s.drawArrays(M.POINTS,0,t.coordinates.length/3))}))}_renderHighlightFragments(e,t){const s=t.highlights;if(null==s)return;let i=s[0].component,r=i+1;for(let o=1;o<s.length;o++){const t=s[o].component;if(t!==r){const s=r-i;s>0&&e.drawArrays(M.POINTS,i,s),i=t}r=t+1}const n=r-i;n>0&&e.drawArrays(M.POINTS,i,n)}set useFixedSizes(e){this._passParameters.useFixedSizes!==e&&(this._passParameters.useFixedSizes=e,this._requestRender())}get useFixedSizes(){return this._passParameters.useFixedSizes}set scaleFactor(e){this._passParameters.scaleFactor!==e&&(this._passParameters.scaleFactor=e,this._requestRender())}get scaleFactor(){return this._passParameters.scaleFactor}set minSizePx(e){this._passParameters.minSizePx!==e&&(this._passParameters.minSizePx=e,this._requestRender())}get minSizePx(){return this._passParameters.minSizePx}set useRealWorldSymbolSizes(e){this._passParameters.useRealWorldSymbolSizes!==e&&(this._passParameters.useRealWorldSymbolSizes=e,this._requestRender())}get useRealWorldSymbolSizes(){return this._passParameters.useRealWorldSymbolSizes}set size(e){this._passParameters.size!==e&&(this._passParameters.size=e,this._requestRender())}get size(){return this._passParameters.size}set sizePx(e){this._passParameters.sizePx!==e&&(this._passParameters.sizePx=e,this._requestRender())}get sizePx(){return this._passParameters.sizePx}set clippingBox(e){m(this._passParameters.clipBox,e||g)}get _clippingEnabled(){return!_(this._passParameters.clipBox,g,((e,t)=>e===t))}get slicePlaneEnabled(){return this._slicePlaneEnabled}set slicePlaneEnabled(e){this._slicePlaneEnabled!==e&&(this._slicePlaneEnabled=e,this._requestRender())}addNode(e){this._nodes.push(e),this._highlights.nodeAdded(e),this._requestRender()}removeNode(t){let s=null;return this._nodes.filterInPlace((i=>i.id!==t||(s=i,i.vao=e(i.vao),this._highlights.nodeRemoved(i),!1))),this._requestRender(),s}forEachNode(e){this._nodes.forAll(e)}removeAll(){this._nodes.forAll((t=>t.vao=e(t.vao))),this._highlights.removeAll(),this._nodes.clear(),this._requestRender()}highlight(e){return this._highlights.add(e)}_addHighlight(e,t,s){e.highlights=X(e.highlights,t,s),this._requestRender()}_removeHighlight(e,t){e.highlights=Z(e.highlights,t),this._requestRender()}_initNode(e,t){const s=e.rctx;t.vao=new F(s,A,V,{positions:T.createVertex(s,D.STATIC_DRAW,t.coordinates),colors:T.createVertex(s,D.STATIC_DRAW,t.rgb)})}_requestRender(){this._context&&this._context.requestRender()}}class k extends O{constructor(e,t,s,i,r,n,o,a,h=null,l=null){super(s,r,t),this.id=e,this.obb=i,this.coordinates=n,this.rgb=o,this.attributes=a,this.pointIdFilterMap=h,this.highlights=l}}function G(e){return e.hasOwnProperty("splatSize")}function Q(e,t,s,i,r){if(s.drawScreenSpace)return s.fixedSize*t*i;const n=H(r)*t*i;return s.useFixedSizes?Math.min(s.fixedSize/2,n):s.screenMinSize>0?Math.min(Math.max(s.screenMinSize*t*i,e/2),n):Math.min(e/2,n)}function Y(e,t,s,i,r){return s.drawScreenSpace?0:Q(e,t,s,i,r)}function J(e,t,s){return null==s&&(s=h()),s[0]=e.origin[0]+e.coordinates[3*t],s[1]=e.origin[1]+e.coordinates[3*t+1],s[2]=e.origin[2]+e.coordinates[3*t+2],s}function K(e){return null!=e.component?e.component:-1}function X(e,t,s){null==e&&(e=[]);const i={component:t,id:s};e.push(i);const r=K(i);let n=e.length-1;for(;n>0&&r<K(e[n-1]);)[e[n-1],e[n]]=[e[n],e[n-1]],--n;return e}function Z(e,t){if(null==e)return e;const s=e.filter((e=>e.id!==t));return 0===s.length?null:s}class ${constructor(){this.node=null,this.pointId=null,this.point=null,this.dist=null,this.normal=null,this.layerUid=""}}function ee(e){return null!=e.dist&&null!=e.point&&null!=e.pointId&&null!=e.node}export{W as PointRenderer,k as PointRendererNode,G as isInstanceOfNode};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import{disposeMaybe as e,releaseMaybe as t}from"../../../core/maybe.js";import{c as i,a as n}from"../../../chunks/vec3.js";import{create as s,fromRay as a,getStart as r,getEnd as h}from"../../../geometry/support/clipRay.js";import{intersectClipRay as l}from"../../../geometry/support/frustum.js";import{copy as c}from"../../../geometry/support/lineSegment.js";import{wrap as o}from"../../../geometry/support/ray.js";import{ViewingMode as d}from"../../ViewingMode.js";import{LaserlinePathData as _}from"./LaserlinePathData.js";import{createQuadVAO as p}from"../webgl-engine/lib/glUtil3D.js";import{RenderSlot as u}from"../webgl-engine/lib/RenderSlot.js";import{copyParameters as g,updateParameters as m}from"../webgl-engine/materials/internal/MaterialUtil.js";import{LaserlinePathTechnique as P}from"../webgl-engine/shaders/LaserlinePathTechnique.js";import{LaserlinePathTechniqueConfiguration as b}from"../webgl-engine/shaders/LaserlinePathTechniqueConfiguration.js";import{LaserlinePassParameters as f,LaserlineTechnique as E}from"../webgl-engine/shaders/LaserlineTechnique.js";import{LaserlineTechniqueConfiguration as q}from"../webgl-engine/shaders/LaserlineTechniqueConfiguration.js";import{PrimitiveType as L}from"../../webgl/enums.js";class V{constructor(e,t={contrastControlEnabled:!1,isDecoration:!0}){this._config=t,this._technique=null,this._heightManifoldEnabled=!1,this._pointDistanceEnabled=!1,this._lineVerticalPlaneEnabled=!1,this._intersectsLineEnabled=!1,this._intersectsLineInfinite=!1,this._viewingMode=d.Local,this._pathVerticalPlaneEnabled=!1,this._pathVerticalPlaneData=null,this._pathTechnique=null,this.canRender=!0,this._passParameters=g(e,new f)}get renderSlots(){return[this._config.contrastControlEnabled?u.LASERLINES_CONTRAST_CONTROL:u.LASERLINES]}get needsLinearDepth(){return!0}get isDecoration(){return this._config.isDecoration}get heightManifoldEnabled(){return this._heightManifoldEnabled}set heightManifoldEnabled(e){this._heightManifoldEnabled!==e&&(this._heightManifoldEnabled=e,this._requestRender())}get heightManifoldTarget(){return this._passParameters.heightManifoldTarget}set heightManifoldTarget(e){i(this._passParameters.heightManifoldTarget,e),this._requestRender()}get pointDistanceEnabled(){return this._pointDistanceEnabled}set pointDistanceEnabled(e){e!==this._pointDistanceEnabled&&(this._pointDistanceEnabled=e,this._requestRender())}get pointDistanceTarget(){return this._passParameters.pointDistanceTarget}set pointDistanceTarget(e){i(this._passParameters.pointDistanceTarget,e),this._requestRender()}get pointDistanceOrigin(){return this._passParameters.pointDistanceOrigin}set pointDistanceOrigin(e){i(this._passParameters.pointDistanceOrigin,e),this._requestRender()}get lineVerticalPlaneEnabled(){return this._lineVerticalPlaneEnabled}set lineVerticalPlaneEnabled(e){e!==this._lineVerticalPlaneEnabled&&(this._lineVerticalPlaneEnabled=e,this._requestRender())}get lineVerticalPlaneSegment(){return this._passParameters.lineVerticalPlaneSegment}set lineVerticalPlaneSegment(e){c(e,this._passParameters.lineVerticalPlaneSegment),this._requestRender()}get intersectsLineEnabled(){return this._intersectsLineEnabled}set intersectsLineEnabled(e){e!==this._intersectsLineEnabled&&(this._intersectsLineEnabled=e,this._requestRender())}get intersectsLineSegment(){return this._passParameters.intersectsLineSegment}set intersectsLineSegment(e){c(e,this._passParameters.intersectsLineSegment),this._requestRender()}get intersectsLineRadius(){return this._passParameters.intersectsLineRadius}set intersectsLineRadius(e){e!==this._passParameters.intersectsLineRadius&&(this._passParameters.intersectsLineRadius=e,this._requestRender())}get intersectsLineInfinite(){return this._intersectsLineInfinite}set intersectsLineInfinite(e){e!==this._intersectsLineInfinite&&(this._intersectsLineInfinite=e,this._requestRender())}get viewingMode(){return this._viewingMode}set viewingMode(e){e!==this._viewingMode&&(this._viewingMode=e,this._requestRender())}get pathVerticalPlaneEnabled(){return this._pathVerticalPlaneEnabled}set pathVerticalPlaneEnabled(e){e!==this._pathVerticalPlaneEnabled&&(this._pathVerticalPlaneEnabled=e,null!=this._pathVerticalPlaneData&&this._requestRender())}set pathVerticalPlaneVertices(e){null==this._pathVerticalPlaneData&&(this._pathVerticalPlaneData=new _(this._passParameters.renderCoordsHelper)),this._pathVerticalPlaneData.vertices=e,this.pathVerticalPlaneEnabled&&this._requestRender()}set pathVerticalPlaneBuffers(e){null==this._pathVerticalPlaneData&&(this._pathVerticalPlaneData=new _(this._passParameters.renderCoordsHelper)),this._pathVerticalPlaneData.buffers=e,this.pathVerticalPlaneEnabled&&this._requestRender()}setParameters(e){m(this._passParameters,e)&&this._requestRender()}initializeRenderContext(e){this._context=e;const t=e.renderContext.rctx;this._quadVAO=p(t),this._techniqueRepository=e.techniqueRepository,this._techniqueConfig=new q;const i=new b;i.contrastControlEnabled=this._config.contrastControlEnabled,this._pathTechnique=this._techniqueRepository.acquire(P,i)}uninitializeRenderContext(){this._quadVAO=e(this._quadVAO),this._technique=t(this._technique),this._pathVerticalPlaneData=e(this._pathVerticalPlaneData),this._pathTechnique=t(this._pathTechnique)}prepareTechnique(){return this.heightManifoldEnabled||this.pointDistanceEnabled||this.lineVerticalPlaneSegment||this.intersectsLineEnabled?(this._techniqueConfig.heightManifoldEnabled=this.heightManifoldEnabled,this._techniqueConfig.lineVerticalPlaneEnabled=this.lineVerticalPlaneEnabled,this._techniqueConfig.pointDistanceEnabled=this.pointDistanceEnabled,this._techniqueConfig.intersectsLineEnabled=this.intersectsLineEnabled,this._techniqueConfig.contrastControlEnabled=this._config.contrastControlEnabled,this._techniqueConfig.spherical=this._viewingMode===d.Global,this._technique=this._techniqueRepository.releaseAndAcquire(E,this._techniqueConfig,this._technique),this._technique):this._pathTechnique}render(e,t){(this.heightManifoldEnabled||this.pointDistanceEnabled||this.lineVerticalPlaneSegment||this.intersectsLineEnabled)&&this._renderUnified(e,t),this.pathVerticalPlaneEnabled&&this._renderPath(e)}_renderUnified(e,t){const i=e.rctx;this._updatePassParameters(e),i.bindTechnique(t,this._passParameters,e.bindParameters),i.bindVAO(this._quadVAO),i.drawArrays(L.TRIANGLE_STRIP,0,4)}_renderPath(e){if(null==this._pathVerticalPlaneData||null==this._pathTechnique)return;const t=e.rctx,i=this._pathTechnique;t.bindTechnique(i,{...this._passParameters,origin:this._pathVerticalPlaneData.origin},e.bindParameters),this._pathVerticalPlaneData.draw(e.rctx)}_updatePassParameters(e){if(!this._intersectsLineEnabled)return;const t=e.bindParameters.camera;if(this._intersectsLineInfinite){if(a(o(this._passParameters.intersectsLineSegment.origin,this._passParameters.intersectsLineSegment.vector),R),R.c0=-Number.MAX_VALUE,!l(t.frustum,R))return;r(R,this._passParameters.lineStartWorld),h(R,this._passParameters.lineEndWorld)}else i(this._passParameters.lineStartWorld,this._passParameters.intersectsLineSegment.origin),n(this._passParameters.lineEndWorld,this._passParameters.intersectsLineSegment.origin,this._passParameters.intersectsLineSegment.vector)}_requestRender(){this._context&&this._context.requestRender()}}const R=s();export{V as LaserLineRenderer};
5
+ import{disposeMaybe as e,releaseMaybe as t}from"../../../core/maybe.js";import{c as i,a as n}from"../../../chunks/vec3.js";import{create as s,fromRay as a,getStart as r,getEnd as h}from"../../../geometry/support/clipRay.js";import{intersectClipRay as l}from"../../../geometry/support/frustum.js";import{copy as c}from"../../../geometry/support/lineSegment.js";import{wrap as o}from"../../../geometry/support/ray.js";import{ViewingMode as d}from"../../ViewingMode.js";import{LaserlinePathData as _}from"./LaserlinePathData.js";import{ShaderOutput as p}from"../webgl-engine/core/shaderLibrary/ShaderOutput.js";import{createQuadVAO as u}from"../webgl-engine/lib/glUtil3D.js";import{RenderSlot as g}from"../webgl-engine/lib/RenderSlot.js";import{copyParameters as m,updateParameters as P}from"../webgl-engine/materials/internal/MaterialUtil.js";import{LaserlinePathTechnique as b}from"../webgl-engine/shaders/LaserlinePathTechnique.js";import{LaserlinePathTechniqueConfiguration as f}from"../webgl-engine/shaders/LaserlinePathTechniqueConfiguration.js";import{LaserlinePassParameters as E,LaserlineTechnique as q}from"../webgl-engine/shaders/LaserlineTechnique.js";import{LaserlineTechniqueConfiguration as L}from"../webgl-engine/shaders/LaserlineTechniqueConfiguration.js";import{PrimitiveType as V}from"../../webgl/enums.js";class R{constructor(e,t={contrastControlEnabled:!1,isDecoration:!0}){this._config=t,this._technique=null,this._heightManifoldEnabled=!1,this._pointDistanceEnabled=!1,this._lineVerticalPlaneEnabled=!1,this._intersectsLineEnabled=!1,this._intersectsLineInfinite=!1,this._viewingMode=d.Local,this._pathVerticalPlaneEnabled=!1,this._pathVerticalPlaneData=null,this._pathTechnique=null,this._passParameters=m(e,new E)}get renderSlots(){return[this._config.contrastControlEnabled?g.LASERLINES_CONTRAST_CONTROL:g.LASERLINES]}canRender(){return!0}requiresOutput(e){return e===p.Depth}get isDecoration(){return this._config.isDecoration}get heightManifoldEnabled(){return this._heightManifoldEnabled}set heightManifoldEnabled(e){this._heightManifoldEnabled!==e&&(this._heightManifoldEnabled=e,this._requestRender())}get heightManifoldTarget(){return this._passParameters.heightManifoldTarget}set heightManifoldTarget(e){i(this._passParameters.heightManifoldTarget,e),this._requestRender()}get pointDistanceEnabled(){return this._pointDistanceEnabled}set pointDistanceEnabled(e){e!==this._pointDistanceEnabled&&(this._pointDistanceEnabled=e,this._requestRender())}get pointDistanceTarget(){return this._passParameters.pointDistanceTarget}set pointDistanceTarget(e){i(this._passParameters.pointDistanceTarget,e),this._requestRender()}get pointDistanceOrigin(){return this._passParameters.pointDistanceOrigin}set pointDistanceOrigin(e){i(this._passParameters.pointDistanceOrigin,e),this._requestRender()}get lineVerticalPlaneEnabled(){return this._lineVerticalPlaneEnabled}set lineVerticalPlaneEnabled(e){e!==this._lineVerticalPlaneEnabled&&(this._lineVerticalPlaneEnabled=e,this._requestRender())}get lineVerticalPlaneSegment(){return this._passParameters.lineVerticalPlaneSegment}set lineVerticalPlaneSegment(e){c(e,this._passParameters.lineVerticalPlaneSegment),this._requestRender()}get intersectsLineEnabled(){return this._intersectsLineEnabled}set intersectsLineEnabled(e){e!==this._intersectsLineEnabled&&(this._intersectsLineEnabled=e,this._requestRender())}get intersectsLineSegment(){return this._passParameters.intersectsLineSegment}set intersectsLineSegment(e){c(e,this._passParameters.intersectsLineSegment),this._requestRender()}get intersectsLineRadius(){return this._passParameters.intersectsLineRadius}set intersectsLineRadius(e){e!==this._passParameters.intersectsLineRadius&&(this._passParameters.intersectsLineRadius=e,this._requestRender())}get intersectsLineInfinite(){return this._intersectsLineInfinite}set intersectsLineInfinite(e){e!==this._intersectsLineInfinite&&(this._intersectsLineInfinite=e,this._requestRender())}get viewingMode(){return this._viewingMode}set viewingMode(e){e!==this._viewingMode&&(this._viewingMode=e,this._requestRender())}get pathVerticalPlaneEnabled(){return this._pathVerticalPlaneEnabled}set pathVerticalPlaneEnabled(e){e!==this._pathVerticalPlaneEnabled&&(this._pathVerticalPlaneEnabled=e,null!=this._pathVerticalPlaneData&&this._requestRender())}set pathVerticalPlaneVertices(e){null==this._pathVerticalPlaneData&&(this._pathVerticalPlaneData=new _(this._passParameters.renderCoordsHelper)),this._pathVerticalPlaneData.vertices=e,this.pathVerticalPlaneEnabled&&this._requestRender()}set pathVerticalPlaneBuffers(e){null==this._pathVerticalPlaneData&&(this._pathVerticalPlaneData=new _(this._passParameters.renderCoordsHelper)),this._pathVerticalPlaneData.buffers=e,this.pathVerticalPlaneEnabled&&this._requestRender()}setParameters(e){P(this._passParameters,e)&&this._requestRender()}initializeRenderContext(e){this._context=e;const t=e.renderContext.rctx;this._quadVAO=u(t),this._techniqueRepository=e.techniqueRepository,this._techniqueConfig=new L;const i=new f;i.contrastControlEnabled=this._config.contrastControlEnabled,this._pathTechnique=this._techniqueRepository.acquire(b,i)}uninitializeRenderContext(){this._quadVAO=e(this._quadVAO),this._technique=t(this._technique),this._pathVerticalPlaneData=e(this._pathVerticalPlaneData),this._pathTechnique=t(this._pathTechnique)}prepareTechnique(){return this.heightManifoldEnabled||this.pointDistanceEnabled||this.lineVerticalPlaneSegment||this.intersectsLineEnabled?(this._techniqueConfig.heightManifoldEnabled=this.heightManifoldEnabled,this._techniqueConfig.lineVerticalPlaneEnabled=this.lineVerticalPlaneEnabled,this._techniqueConfig.pointDistanceEnabled=this.pointDistanceEnabled,this._techniqueConfig.intersectsLineEnabled=this.intersectsLineEnabled,this._techniqueConfig.contrastControlEnabled=this._config.contrastControlEnabled,this._techniqueConfig.spherical=this._viewingMode===d.Global,this._technique=this._techniqueRepository.releaseAndAcquire(q,this._techniqueConfig,this._technique),this._technique):this._pathTechnique}render(e,t){(this.heightManifoldEnabled||this.pointDistanceEnabled||this.lineVerticalPlaneSegment||this.intersectsLineEnabled)&&this._renderUnified(e,t),this.pathVerticalPlaneEnabled&&this._renderPath(e)}_renderUnified(e,t){const i=e.rctx;this._updatePassParameters(e),i.bindTechnique(t,this._passParameters,e.bindParameters),i.bindVAO(this._quadVAO),i.drawArrays(V.TRIANGLE_STRIP,0,4)}_renderPath(e){if(null==this._pathVerticalPlaneData||null==this._pathTechnique)return;const t=e.rctx,i=this._pathTechnique;t.bindTechnique(i,{...this._passParameters,origin:this._pathVerticalPlaneData.origin},e.bindParameters),this._pathVerticalPlaneData.draw(e.rctx)}_updatePassParameters(e){if(!this._intersectsLineEnabled)return;const t=e.bindParameters.camera;if(this._intersectsLineInfinite){if(a(o(this._passParameters.intersectsLineSegment.origin,this._passParameters.intersectsLineSegment.vector),D),D.c0=-Number.MAX_VALUE,!l(t.frustum,D))return;r(D,this._passParameters.lineStartWorld),h(D,this._passParameters.lineEndWorld)}else i(this._passParameters.lineStartWorld,this._passParameters.intersectsLineSegment.origin),n(this._passParameters.lineEndWorld,this._passParameters.intersectsLineSegment.origin,this._passParameters.intersectsLineSegment.vector)}_requestRender(){this._context&&this._context.requestRender()}}const D=s();export{R as LaserLineRenderer};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import{p as t}from"../../../../chunks/vec2.js";import{s as e}from"../../../../chunks/vec3.js";import{c as r}from"../../../../chunks/vec3f64.js";import{O as o}from"../../../../chunks/vec4f64.js";import{getReferenceEllipsoid as n}from"../../../../geometry/ellipsoidUtils.js";import{lonLatToWebMercatorComparable as i}from"../../../../geometry/projection.js";import{newDoubleArray as a}from"../../../../geometry/support/DoubleArray.js";import{newFloatArray as u}from"../../../../geometry/support/FloatArray.js";import{getZeroIndexArray as s}from"../../../../geometry/support/Indices.js";import{ViewingMode as l}from"../../../ViewingMode.js";import{Attribute as p}from"../../webgl-engine/lib/Attribute.js";import{ContentObjectType as c}from"../../webgl-engine/lib/ContentObjectType.js";import{Geometry as f}from"../../webgl-engine/lib/Geometry.js";import{VertexAttribute as m}from"../../webgl-engine/lib/VertexAttribute.js";function h(t,e,r=null){const o=[],n=[],i=e.mapPositions;T(e,n,o);const a=n[0][1].data,u=o[0][1].length,l=s(u);return b(e,n,o,l),A(e,n,o,l),g(e,n,o,l),E(e,n,o,l),I(e,n,o,l),O(e,n,o,l),R(e,n,o,a),new f(t,n,o,i,c.Line,r)}function T(t,e,r){const{attributeData:{position:o},removeDuplicateStartEnd:n}=t,i=D(o)&&n,a=o.length/3-(i?1:0),u=new Array(2*(a-1)),s=i?o.slice(0,o.length-3):o;let l=0;for(let p=0;p<a-1;p++)u[l++]=p,u[l++]=p+1;e.push([m.POSITION,new p(s,3,i)]),r.push([m.POSITION,u])}function b(t,e,r,n){if(null!=t.attributeData.colorFeature)return;const i=t.attributeData.color;e.push([m.COLOR,new p(i??o,4)]),r.push([m.COLOR,n])}function g(t,e,r,o){if(null==t.attributeData.normal)return;const n=t.attributeData.normal;e.push([m.NORMAL,new p(n,3)]),r.push([m.NORMAL,o])}function E(t,e,r,o){null!=t.attributeData.colorFeature&&(e.push([m.COLORFEATUREATTRIBUTE,new p([t.attributeData.colorFeature],1,!0)]),r.push([m.COLOR,o]))}function A(t,e,r,o){null==t.attributeData.sizeFeature&&(e.push([m.SIZE,new p([t.attributeData.size??1],1,!0)]),r.push([m.SIZE,o]))}function I(t,e,r,o){null!=t.attributeData.sizeFeature&&(e.push([m.SIZEFEATUREATTRIBUTE,new p([t.attributeData.sizeFeature],1,!0)]),r.push([m.SIZEFEATUREATTRIBUTE,o]))}function O(t,e,r,o){const n=t.attributeData.opacityFeature;null!=n&&(e.push([m.OPACITYFEATUREATTRIBUTE,new p([n],1,!0)]),r.push([m.OPACITYFEATUREATTRIBUTE,o]))}function R(r,o,s,c){if(null==r.overlayInfo||r.overlayInfo.renderCoordsHelper.viewingMode!==l.Global||!r.overlayInfo.spatialReference.isGeographic)return;const f=a(c.length),h=n(r.overlayInfo.spatialReference);for(let t=0;t<f.length;t+=3)i(c,t,f,t,h);const T=c.length/3,b=u(T+1);let g=j,E=w,A=0,I=0;e(g,f[I++],f[I++],f[I++]),b[0]=0;for(let n=1;n<T+1;++n)n===T&&(I=0),e(E,f[I++],f[I++],f[I++]),A+=t(g,E),b[n]=A,[g,E]=[E,g];o.push([m.DISTANCETOSTART,new p(b,1,!0)]),s.push([m.DISTANCETOSTART,s[0][1]])}function D(t){const e=t.length;return t[0]===t[e-3]&&t[1]===t[e-2]&&t[2]===t[e-1]}const j=r(),w=r();function y(t,e){if(null==t||0===t.length)return[];const r=[];return t.forEach((t=>{const o=t.length,n=a(3*o);t.forEach(((t,e)=>{n[3*e]=t[0],n[3*e+1]=t[1],n[3*e+2]=t[2]}));const i={attributeData:{position:n,normal:e},removeDuplicateStartEnd:!1};r.push(i)})),r}export{h as createGeometry,y as lineStripsToParameters};
5
+ import{p as t}from"../../../../chunks/vec2.js";import{s as e}from"../../../../chunks/vec3.js";import{c as r}from"../../../../chunks/vec3f64.js";import{O as o}from"../../../../chunks/vec4f64.js";import{getReferenceEllipsoid as n}from"../../../../geometry/ellipsoidUtils.js";import{lonLatToWebMercatorComparable as i}from"../../../../geometry/projection.js";import{newDoubleArray as a}from"../../../../geometry/support/DoubleArray.js";import{newFloatArray as u}from"../../../../geometry/support/FloatArray.js";import{getZeroIndexArray as s}from"../../../../geometry/support/Indices.js";import{ViewingMode as l}from"../../../ViewingMode.js";import{Attribute as p}from"../../webgl-engine/lib/Attribute.js";import{ContentObjectType as c}from"../../webgl-engine/lib/ContentObjectType.js";import{Geometry as f}from"../../webgl-engine/lib/Geometry.js";import{VertexAttribute as m}from"../../webgl-engine/lib/VertexAttribute.js";function T(t,e,r=null){const o=[],n=[],i=e.mapPositions;h(e,n,o);const a=n[0][1].data,u=o[0][1].length,l=s(u);return b(e,n,o,l),A(e,n,o,l),E(e,n,o,l),g(e,n,o,l),I(e,n,o,l),O(e,n,o,l),R(e,n,o,a),new f(t,n,o,i,c.Line,r)}function h(t,e,r){const{attributeData:{position:o},removeDuplicateStartEnd:n}=t,i=D(o)&&n,a=o.length/3-(i?1:0),u=new Array(2*(a-1)),s=i?o.slice(0,-3):o;let l=0;for(let p=0;p<a-1;p++)u[l++]=p,u[l++]=p+1;e.push([m.POSITION,new p(s,3,i)]),r.push([m.POSITION,u])}function b(t,e,r,n){if(null!=t.attributeData.colorFeature)return;const i=t.attributeData.color;e.push([m.COLOR,new p(i??o,4)]),r.push([m.COLOR,n])}function E(t,e,r,o){if(null==t.attributeData.normal)return;const n=t.attributeData.normal;e.push([m.NORMAL,new p(n,3)]),r.push([m.NORMAL,o])}function g(t,e,r,o){null!=t.attributeData.colorFeature&&(e.push([m.COLORFEATUREATTRIBUTE,new p([t.attributeData.colorFeature],1,!0)]),r.push([m.COLOR,o]))}function A(t,e,r,o){null==t.attributeData.sizeFeature&&(e.push([m.SIZE,new p([t.attributeData.size??1],1,!0)]),r.push([m.SIZE,o]))}function I(t,e,r,o){null!=t.attributeData.sizeFeature&&(e.push([m.SIZEFEATUREATTRIBUTE,new p([t.attributeData.sizeFeature],1,!0)]),r.push([m.SIZEFEATUREATTRIBUTE,o]))}function O(t,e,r,o){const n=t.attributeData.opacityFeature;null!=n&&(e.push([m.OPACITYFEATUREATTRIBUTE,new p([n],1,!0)]),r.push([m.OPACITYFEATUREATTRIBUTE,o]))}function R(r,o,s,c){if(null==r.overlayInfo||r.overlayInfo.renderCoordsHelper.viewingMode!==l.Global||!r.overlayInfo.spatialReference.isGeographic)return;const f=a(c.length),T=n(r.overlayInfo.spatialReference);for(let t=0;t<f.length;t+=3)i(c,t,f,t,T);const h=c.length/3,b=u(h+1);let E=j,g=w,A=0,I=0;e(E,f[I++],f[I++],f[I++]),b[0]=0;for(let n=1;n<h+1;++n)n===h&&(I=0),e(g,f[I++],f[I++],f[I++]),A+=t(E,g),b[n]=A,[E,g]=[g,E];o.push([m.DISTANCETOSTART,new p(b,1,!0)]),s.push([m.DISTANCETOSTART,s[0][1]])}function D(t){const e=t.length;return t[0]===t[e-3]&&t[1]===t[e-2]&&t[2]===t[e-1]}const j=r(),w=r();function y(t,e){if(null==t||0===t.length)return[];const r=[];return t.forEach((t=>{const o=t.length,n=a(3*o);t.forEach(((t,e)=>{n[3*e]=t[0],n[3*e+1]=t[1],n[3*e+2]=t[2]}));const i={attributeData:{position:n,normal:e},removeDuplicateStartEnd:!1};r.push(i)})),r}export{T as createGeometry,y as lineStripsToParameters};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import{equals as e}from"../../../core/arrayUtils.js";import{isPowerOfTwo as t}from"../../../core/mathUtils.js";import{i as r,j as i,B as s,b as a,n as o,e as n,A as l,G as h}from"../../../chunks/vec3.js";import{c as d,a as g}from"../../../chunks/vec3f64.js";import{empty as u}from"../../../geometry/support/aaBoundingBox.js";import{containsXY as c}from"../../../geometry/support/aaBoundingRect.js";import{earth as m}from"../../../geometry/support/Ellipsoid.js";import{glLayout as p}from"../support/buffer/glUtil.js";import{GeometryState as y}from"./GeometryState.js";import{NeighborIndex as f}from"./ITile.js";import{LayerClass as _}from"./LayerClass.js";import{PatchGeometry as x,releaseGeometry as D}from"./PatchGeometry.js";import{ENABLE_TERRAIN_INTERNAL_CHECKS as v,internalAssert as C,neighborEdgeIndices as S,oppositeEdge as $,neighborCornerIndices as E,v32s as b,lij2s as T}from"./terrainUtils.js";import{TextureFader as A,ActivationTime as V}from"./TextureFader.js";import{isEdgeNeighbor as j}from"./Tile.js";import R from"./TileOverlayData.js";import{fallsWithinLayer as w}from"./tileUtils.js";import{VertexArrayObject as L}from"../webgl-engine/lib/VertexArrayObject.js";import{terrainVertexAttributeLocations as P}from"../webgl-engine/shaders/TerrainTechnique.js";import{BufferObject as N}from"../../webgl/BufferObject.js";class G{constructor(){this.geometry=new x,this.intersectionData=null,this.geometryState=null,this._textureRef=new A((()=>this.tile.surface.textureFadeDuration)),this.overlay=new R,this._geometryStateChangedSinceLastUpdate=!0,this._hasGeometry=!1,this._numVerticesPerSideChanged=!1,this._samplerDataChanged=!1,this._clippingAreaChanged=!1,this._wireframeChanged=!1,this._dirtyEdgeResolutions=15,this._dirtyEdges=15,this._dirtyCorners=15}get tile(){return this._tile}init(e){this.clear(),this._tile=e;const t=this.geometry;t.indices=null,t.vertexAttributes=null,u(t.boundingBox),t.indexCount=0,t.numVerticesPerSide=0,this.intersectionData=null,this.geometryState=new y,this.localOrigin=null,this.overlay.clear()}clear(){this.releaseGeometry(),this.releaseTexture(),this._textureRef.clear(),this._tile=null,this.intersectionData=null,this.geometryState=null}updateGeometryIfNeeded(e){if((!this._vao||this._geometryStateChangedSinceLastUpdate||this._wireframeChanged||this._clippingAreaChanged||this._samplerDataChanged||this._numVerticesPerSideChanged||this._dirtyCorners||this._dirtyEdgeResolutions||this._dirtyEdges)&&(this._updateGeometry(e),this._geometryStateChangedSinceLastUpdate=!1),v&&this.tile.intersectsClippingArea)for(let t=0;t<4;++t)C(this.geometry.outerEdges[t].count===this.geometryState.neighborData.edgeResolutions[t]+1)}_calculateEdgeResolution(e,t){const r=this.tile,i=this.geometryState.numVerticesPerSide-1;if(!r.surface.isGlobal){const t=r.surface.extent;if(null!=t&&(0===e&&r.extent[3]>t[3]||1===e&&r.extent[2]>t[2]||2===e&&r.extent[1]<t[1]||3===e&&r.extent[0]<t[0]))return i}const s=r.level,a=S[e];if(!t)return C(null==r.surface?.rootTiles||r.surface.updatingRootTiles||!r.shouldHaveNeighbor(a)),i;if(t.isLoaded){const r=t,a=r.renderData.geometryState,o=s-r.level;if(C(o>=0),0===o){const e=a.numVerticesPerSide-1;return Math.max(e,i)}const n=2**o,l=a.neighborData.edgeResolutions[(e+2)%4]/n;return Math.max(1,l)}C(!t.isLeaf);let o=i;return t.forAllSubtreeOnSide($(a),(e=>e===r||(e.isLoaded?(o=Math.max(o,2**(e.level-s)),!0):(C(!e.isLeaf),!1)))),o}updateNeighborData(){const e=this.tile;if(!e.intersectsClippingArea)return;const r=e.renderData.geometryState.neighborData,i=t=>(t.isLoaded||t.level===e.level)&&t?.intersectsClippingArea,s=r.edgePeerNeighbors,a=r.edgePeerNeighborSamplerVersions;for(let n=0;n<4;++n){const o=e.findNeighborTile(S[n],i),l=H(e,o),h=l?.renderData?.geometryState.samplerDataVersion??-1,d=s[n],g=l!==H(e,d),u=a[n]!==h;s[n]=o,(g||u)&&(a[n]=h,this._markEdgeDirty(n));const c=r.edgeResolutions[n],m=this._calculateEdgeResolution(n,o);C(t(m)),C(m>=1),r.edgeResolutions[n]=m,c!==m&&this._markEdgeResolutionDirty(n)}const o=r.cornerPeerNeighbors;for(let t=0;t<4;++t){const a=e.findNeighborTile(E[t],i);o[t]=a;const n=H(e,s[t]),l=H(e,s[(t+1)%4]),h=H(e,a);X[t]=h,X[(t+1)%4]=l,X[(t+2)%4]=e,X[(t+3)%4]=n,C(X.some((t=>t?.isLoaded||t===e)));const d=X.reduce(((e,t)=>Math.min(e,t?.level??1/0)),1/0);X.forEach(((e,t)=>{e&&e?.level>d&&(X[t]=null)})),C(X.some((t=>t?.isLoaded||t===e)));const g=r.cornerNeighborData[t].cornerTiles,u=r.cornerNeighborData[t].cornerTileSamplerVersions;for(let e=0;e<4;++e){const r=X[e],i=r?.renderData.geometryState.samplerDataVersion??-1,s=g[e]!==r,a=!s&&u[e]!==i;(s||a)&&(g[e]=r,u[e]=i,this._markCornerDirty(t))}C(g.some((t=>t?.isLoaded||t===e)))}v&&C(this.geometryState.neighborData.edgeResolutions.every((e=>e>0)));for(let t=0;t<4;++t)X[t]=null}_updateGeometry(e){if(!this.tile.intersectsClippingArea)return;v&&C(!this.tile.intersectsClippingArea||this.geometryState.neighborData.edgeResolutions.every((e=>e>0))),this.intersectionData=null;const t=this.tile,r=this._vao,i=this.geometry.vertexAttributes,s=!r||!i||this._wireframeChanged||this._numVerticesPerSideChanged||this._samplerDataChanged||this._clippingAreaChanged||this._dirtyEdgeResolutions,a=!s&&(0!==this._dirtyEdges||0!==this._dirtyEdgeResolutions),o=!a&&0!==this._dirtyCorners;s?(this.releaseGeometry(),this._createGeometry(e)):a||o?t.updateEdgeElevations():o?t.updateCornerElevations():console.warn("Update for no reason?"),this._numVerticesPerSideChanged=!1,this._samplerDataChanged=!1,this._dirtyEdgeResolutions=0,this._dirtyEdges=0,this._dirtyCorners=0,this._clippingAreaChanged=!1,this._wireframeChanged=!1}get hasGeometry(){return this._hasGeometry}releaseGeometry(){return this._hasGeometry=!1,this.intersectionData=null,!!this._vao&&(this._vao.dispose(),this._vao=null,D(this.geometry),!0)}ensureTexture(e,t){return null!=this._texture&&this._texture.descriptor.width!==e&&this.releaseTexture(),null==this._texture&&(this._texture=t(),this.tile.setMemoryDirty()),this._texture}releaseTexture(){null!=this._texture&&(this._texture.release(),this._texture=null,this.tile.setMemoryDirty())}_markCornerDirty(e){const t=1<<e;this._dirtyCorners|=t}_markEdgeDirty(e){const t=1<<e;this._dirtyEdges|=t,this._markCornerDirty((e+0)%4),this._markCornerDirty((e+3)%4)}_markEdgeResolutionDirty(e){const t=1<<e;this._dirtyEdgeResolutions|=t,this._markEdgeDirty(e)}_markAllEdgesAndCornersDirty(){this._dirtyCorners=15,this._dirtyEdges=15,this._dirtyEdgeResolutions=15}updateGeometryState(){const t=this._getElevationInfo(),r=this.tile,i=t.samplerData?r.getElevationVerticesPerSide(t.maxTileLevel):r.getDefaultVerticesPerSide(),s=Math.max(i,5);let a=r.clippingArea;r.intersectsClippingArea&&!r.isWithinClippingArea||(a=null);const o=this.geometryState;let n=!1;o.numVerticesPerSide!==s&&(this._numVerticesPerSideChanged=!0,o.numVerticesPerSide=s,o.samplerDataVersion++,n=!0),t.changed&&(this._samplerDataChanged=!0,o.samplerData=t.samplerData,o.samplerDataVersion++,n=!0),e(o.clippingArea,a)||(this._clippingAreaChanged=!0,o.clippingArea=a,n=!0);const l=r.surface.wireframe;return o.wireframe!==l&&(this._wireframeChanged=!0,o.wireframe=l,n=!0),this._geometryStateChangedSinceLastUpdate||=n,n&&this._markAllEdgesAndCornersDirty(),this._hasGeometry=!0,this._geometryStateChangedSinceLastUpdate}_createGeometry(e){this.tile.createGeometry();const t=this.geometry.vertexAttributes,r=this.geometry.indices,i=e.gl;this._vao=new L(e,P,{geometry:p(t.layout)},{geometry:N.createVertex(e,i.STATIC_DRAW,t.buffer)},N.createIndex(e,i.STATIC_DRAW,r)),this._hasGeometry=!0}get vao(){return this._vao}setTextureReference(e,t=V.Immediate){null!=e&&e.texture!==this._texture&&this.releaseTexture(),this._textureRef.push(e,t)}get textureReference(){return this._textureRef.current}get nextTextureReference(){return this._textureRef.next}get textureFadeFactor(){return this._textureRef.fadeFactor}get textureIsFading(){return this._textureRef.isFading}_getElevationInfo(){const e=this.geometryState.samplerData,t=this.tile.layerInfo[_.ELEVATION],r=t.length,i=new Array(r);let s=0,a=0,o=!1;for(let h=0;h<r;h++){const r=t[h];if(null!=r.upsampleInfo){const t=r.upsampleInfo.tile,n=t.layerInfo[_.ELEVATION][h].data,l=n&&n.samplerData;e&&e[s]===l||(o=!0),i[s++]=l,a=Math.max(a,t.lij[0])}else if(r.data){const t=this.tile.surface.layerViewByIndex(h,_.ELEVATION);if(w(this.tile,t.layer,!1)){const t=r.data;e&&e[s]===t.samplerData||(o=!0),i[s++]=t.samplerData,a=this.tile.level}}}null!=e&&e.length!==s&&(o=!0);const n=s>0,l=n?i:null;return n&&(i.length=s),{changed:o,samplerData:l,maxTileLevel:a}}get estimatedGeometryMemoryUsage(){const e=this.intersectionData?.estimatedMemoryUsage??0;return(this.geometry.indices?.byteLength??0)+(this.geometry.vertexAttributes?.byteLength??0)+e}get texture(){return this._texture}get test(){return{hasTexture:null!=this._texture}}checkGeometryWaterproofness(){if(!v)return;const e=this.tile;if(!e.isLoaded||!e.intersectsClippingArea||0===e.level)return void C(e?.isLoaded);const u=e.surface.extent;if(null!=u&&!e.intersectsExtent(u))return;const p=S.map(((t,r)=>null!=u&&(r<2?-1:1)*(e.extent[3-r]-u[3-r])<0)),y=e.level;C(0===this._dirtyCorners),C(0===this._dirtyEdges),C(0===this._dirtyEdgeResolutions),C(!this._numVerticesPerSideChanged),C(!this._samplerDataChanged),C(!this._clippingAreaChanged),C(!this._wireframeChanged);const _=E.map((t=>e.findNeighborCornerTileExact(t,(t=>!t.intersectsClippingArea||t.isLoaded||t.level===e.level))??null)).map((e=>e?.intersectsClippingArea?e:null)),x=this.geometryState.neighborData;for(let t=0;t<4;++t){const r=x.cornerPeerNeighbors[t],i=_[t];C(i===r,`Tile[${e.lij}].corner[${t}] out of date: cur=[${r?.lij}] exp=[${i?.lij}]`)}S.forEach(((u,_)=>{if(p[_])return;const x=e.findNeighborTile(u,(e=>(e.level===y||e?.isLoaded)&&e?.intersectsClippingArea));if(!x){const t=!e.surface.updatingRootTiles&&null!=e.surface.rootTiles&&e.surface.rootTiles.length>0&&e.shouldHaveNeighbor(u);return void C(!t)}C(x.isLoaded||x.level===e.level),C(x===this.geometryState.neighborData.edgePeerNeighbors[_]);const D=y-x.level;if(!x.isLoaded)return C(!x.isLeaf),void C(0===D);const v=x.renderData;C(j(e,x,u)),C(D>=0);const S=2**D;if(D<0)return void C(!1);const $=e.renderData,E=$.geometry,A=E.outerEdges[_],V=E.numVerticesPerSide-1,R=v.geometry;if(!R)return void C(!1);const w=this.geometryState.neighborData.edgePeerNeighbors[_];if(w?.isLoaded){const e=w.renderData;C(w==w),C($.geometryState.neighborData.edgePeerNeighborSamplerVersions[_]===e.geometryState.samplerDataVersion),C(this.geometryState.neighborData.edgePeerNeighborSamplerVersions[_]===e.geometryState.samplerDataVersion)}const L=(_+2)%4,P=R.outerEdges[L],N=A.count-1,G=P.count-1;C(N*S===G,`Tile[${e.lij}]:e${_},res=${N} edgeRes mismatch with Neighbor[${x.lij}]:e${L},res=${G} (expected:${N*S})`);const X=e.extent,H=u===f.NORTH||u===f.SOUTH,W=P.count-1,q=W/2**D,z=A.count-1;if(q<1)return void C(1===z);C(q===z),C(t(q));const J=R.numVerticesPerSide-1;C(D>0||q===Math.max(J,V));const K=e.getNeighborEdgeStartVertexIndex(_,x);C(0<=K&&K<S);const Q=K*q;C(0<=Q&&Q<=W-q);let Y=0,Z=Q;A.getVertexPos(I,0),A.getVertexPos(M,A.count-1);const ee=r(I,M),te=Math.max(F,1e-4*ee);for(let t=0;t<=q;++t){A.getVertexPos(I,Y),P.getVertexPos(M,Z);const r=t/q,p=H?X[0]+r*(X[2]-X[0]):u===f.WEST?X[0]:X[2],y=H?u===f.SOUTH?X[1]:X[3]:X[1]+r*(X[3]-X[1]),D=e.surface.extent;if(null==D||c(D,p,y)){const t=i(I,M),r=s(I)-m.radius,u=s(M)-m.radius,c=t<te;if(!c){console.warn(`Tile edge vertex position mismatch: between [${e.lij}].edge${_}[${Y}/${A.count}] and [${x.lij}].edge${L}[${Z}/${P.count}]`),null!=D&&console.warn(" surface extent= ",D," x,y=",p,",",y);const i=d();a(i,$.localOrigin,v.localOrigin),s(i)>0&&console.warn(` localOrigins: ${$.localOrigin} vs ${v.localOrigin} d=${s(i)} [${i}]`);(()=>{const t=g(I),r=g(M);e.updateEdgeElevations(),x.updateEdgeElevations(),A.getVertexPos(I,Y),P.getVertexPos(M,Z);const i=d();l(i,I,t),s(i)>0&&console.warn(` XXX Tile[${e.lij}] edge out of date: ${t} vs ${I} d=${s(i)} [${i}]`),l(i,M,r),s(i)>0&&console.warn(` XXX Neighbor[${x.lij}] edge out of date: ${r} vs ${M} d=${s(i)} [${i}]`)})(),C(c,`Mismatch in tile [${e.lij}].edge[${_}][${Y}/${A.count}] vs neighbor [${x.lij}].edge[${L}][${Z}/${P.count}] ${b(I)} vs ${b(M)} dist=${t} h(t|n|d)=${r}|${u}|${u-r}`)}A.getNormal(O,Y),P.getNormal(U,Z),o(k,O),o(B,U);const f=n(k,B),S=1-f<.01||!1||e===x;if(!S){const t=d();l(t,O,U);const r=()=>`Mismatch in tile edge normal ${T(e.lij)} (${Y}/${A.count-1}) edge ${_} vs neighbor ${T(x.lij)} (${Z}/${P.count-1}) nedge ${L} :${b(O)} vs ${b(U)} dot = ${f} : ${b(t)}`;console.warn("Mismatch in tile edge normal: ",r());{e.updateEdgeElevations(),x.updateEdgeElevations();const t=d(),r=d();A.getNormal(t,Y),P.getNormal(r,Z),h(O,t)||console.warn("Missing update in tile normal: ",b(O)," => ",b(t)),h(U,r)||console.warn("Missing update in neighbor normal: ",b(U)," => ",b(r))}C(S,r())}}Y+=1,Z+=1}}))}}const I=d(),M=d(),O=d(),U=d(),k=d(),B=d(),F=1,X=[null,null,null,null];function H(e,t){return t?.isLoaded||t===e?t:null}export{V as ActivationTime,G as PatchRenderData,H as neighborTileIfLoadedOrSelf};
5
+ import{equals as e}from"../../../core/arrayUtils.js";import{isPowerOfTwo as t}from"../../../core/mathUtils.js";import{i as r,j as i,B as s,b as o,n as a,e as n,A as l,G as h}from"../../../chunks/vec3.js";import{c as d,a as g}from"../../../chunks/vec3f64.js";import{empty as u}from"../../../geometry/support/aaBoundingBox.js";import{containsXY as c}from"../../../geometry/support/aaBoundingRect.js";import{earth as m}from"../../../geometry/support/Ellipsoid.js";import{glLayout as p}from"../support/buffer/glUtil.js";import{GeometryState as y}from"./GeometryState.js";import{NeighborIndex as f}from"./ITile.js";import{LayerClass as _}from"./LayerClass.js";import{PatchGeometry as x,releaseGeometry as D}from"./PatchGeometry.js";import{ENABLE_TERRAIN_INTERNAL_CHECKS as v,internalAssert as C,neighborEdgeIndices as S,oppositeEdge as $,neighborCornerIndices as E,v32s as b,lij2s as T}from"./terrainUtils.js";import{TextureFader as A,ActivationTime as j}from"./TextureFader.js";import{isEdgeNeighbor as V}from"./Tile.js";import R from"./TileOverlayData.js";import{fallsWithinLayer as w}from"./tileUtils.js";import{VertexArrayObject as L}from"../webgl-engine/lib/VertexArrayObject.js";import{terrainVertexAttributeLocations as P}from"../webgl-engine/shaders/TerrainTechnique.js";import{BufferObject as N}from"../../webgl/BufferObject.js";import{PixelFormat as G}from"../../webgl/enums.js";class I{constructor(){this.geometry=new x,this.intersectionData=null,this.geometryState=null,this._textureRef=new A((()=>this.tile.surface.textureFadeDuration)),this.overlay=new R,this._geometryStateChangedSinceLastUpdate=!0,this._hasGeometry=!1,this._numVerticesPerSideChanged=!1,this._samplerDataChanged=!1,this._clippingAreaChanged=!1,this._wireframeChanged=!1,this._dirtyEdgeResolutions=15,this._dirtyEdges=15,this._dirtyCorners=15}get tile(){return this._tile}init(e){this.clear(),this._tile=e;const t=this.geometry;t.indices=null,t.vertexAttributes=null,u(t.boundingBox),t.indexCount=0,t.numVerticesPerSide=0,this.intersectionData=null,this.geometryState=new y,this.localOrigin=null,this.overlay.clear()}clear(){this.releaseGeometry(),this.releaseTexture(),this._textureRef.clear(),this._tile=null,this.intersectionData=null,this.geometryState=null}updateGeometryIfNeeded(e){if((!this._vao||this._geometryStateChangedSinceLastUpdate||this._wireframeChanged||this._clippingAreaChanged||this._samplerDataChanged||this._numVerticesPerSideChanged||this._dirtyCorners||this._dirtyEdgeResolutions||this._dirtyEdges)&&(this._updateGeometry(e),this._geometryStateChangedSinceLastUpdate=!1),v&&this.tile.intersectsClippingArea)for(let t=0;t<4;++t)C(this.geometry.outerEdges[t].count===this.geometryState.neighborData.edgeResolutions[t]+1)}_calculateEdgeResolution(e,t){const r=this.tile,i=this.geometryState.numVerticesPerSide-1;if(!r.surface.isGlobal){const t=r.surface.extent;if(null!=t&&(0===e&&r.extent[3]>t[3]||1===e&&r.extent[2]>t[2]||2===e&&r.extent[1]<t[1]||3===e&&r.extent[0]<t[0]))return i}const s=r.level,o=S[e];if(!t)return C(null==r.surface?.rootTiles||r.surface.updatingRootTiles||!r.shouldHaveNeighbor(o)),i;if(t.isLoaded){const r=t,o=r.renderData.geometryState,a=s-r.level;if(C(a>=0),0===a){const e=o.numVerticesPerSide-1;return Math.max(e,i)}const n=2**a,l=o.neighborData.edgeResolutions[(e+2)%4]/n;return Math.max(1,l)}C(!t.isLeaf);let a=i;return t.forAllSubtreeOnSide($(o),(e=>e===r||(e.isLoaded?(a=Math.max(a,2**(e.level-s)),!0):(C(!e.isLeaf),!1)))),a}updateNeighborData(){const e=this.tile;if(!e.intersectsClippingArea)return;const r=e.renderData.geometryState.neighborData,i=t=>(t.isLoaded||t.level===e.level)&&t?.intersectsClippingArea,s=r.edgePeerNeighbors,o=r.edgePeerNeighborSamplerVersions;for(let n=0;n<4;++n){const a=e.findNeighborTile(S[n],i),l=W(e,a),h=l?.renderData?.geometryState.samplerDataVersion??-1,d=s[n],g=l!==W(e,d),u=o[n]!==h;s[n]=a,(g||u)&&(o[n]=h,this._markEdgeDirty(n));const c=r.edgeResolutions[n],m=this._calculateEdgeResolution(n,a);C(t(m)),C(m>=1),r.edgeResolutions[n]=m,c!==m&&this._markEdgeResolutionDirty(n)}const a=r.cornerPeerNeighbors;for(let t=0;t<4;++t){const o=e.findNeighborTile(E[t],i);a[t]=o;const n=W(e,s[t]),l=W(e,s[(t+1)%4]),h=W(e,o);H[t]=h,H[(t+1)%4]=l,H[(t+2)%4]=e,H[(t+3)%4]=n,C(H.some((t=>t?.isLoaded||t===e)));const d=H.reduce(((e,t)=>Math.min(e,t?.level??1/0)),1/0);H.forEach(((e,t)=>{e&&e?.level>d&&(H[t]=null)})),C(H.some((t=>t?.isLoaded||t===e)));const g=r.cornerNeighborData[t].cornerTiles,u=r.cornerNeighborData[t].cornerTileSamplerVersions;for(let e=0;e<4;++e){const r=H[e],i=r?.renderData.geometryState.samplerDataVersion??-1,s=g[e]!==r,o=!s&&u[e]!==i;(s||o)&&(g[e]=r,u[e]=i,this._markCornerDirty(t))}C(g.some((t=>t?.isLoaded||t===e)))}v&&C(this.geometryState.neighborData.edgeResolutions.every((e=>e>0)));for(let t=0;t<4;++t)H[t]=null}_updateGeometry(e){if(!this.tile.intersectsClippingArea)return;v&&C(!this.tile.intersectsClippingArea||this.geometryState.neighborData.edgeResolutions.every((e=>e>0))),this.intersectionData=null;const t=this.tile,r=this._vao,i=this.geometry.vertexAttributes,s=!r||!i||this._wireframeChanged||this._numVerticesPerSideChanged||this._samplerDataChanged||this._clippingAreaChanged||this._dirtyEdgeResolutions,o=!s&&(0!==this._dirtyEdges||0!==this._dirtyEdgeResolutions),a=!o&&0!==this._dirtyCorners;s?(this.releaseGeometry(),this._createGeometry(e)):o||a?t.updateEdgeElevations():a?t.updateCornerElevations():console.warn("Update for no reason?"),this._numVerticesPerSideChanged=!1,this._samplerDataChanged=!1,this._dirtyEdgeResolutions=0,this._dirtyEdges=0,this._dirtyCorners=0,this._clippingAreaChanged=!1,this._wireframeChanged=!1}get hasGeometry(){return this._hasGeometry}releaseGeometry(){return this._hasGeometry=!1,this.intersectionData=null,!!this._vao&&(this._vao.dispose(),this._vao=null,D(this.geometry),!0)}ensureTexture(e,t,r){const i=t?G.RGBA:G.RGB;return null==this._texture||this._texture.descriptor.width===e&&this._texture.descriptor.pixelFormat===i||this.releaseTexture(),null==this._texture&&(this._texture=r(),this.tile.setMemoryDirty()),this._texture}releaseTexture(){null!=this._texture&&(this._texture.release(),this._texture=null,this.tile.setMemoryDirty())}_markCornerDirty(e){const t=1<<e;this._dirtyCorners|=t}_markEdgeDirty(e){const t=1<<e;this._dirtyEdges|=t,this._markCornerDirty((e+0)%4),this._markCornerDirty((e+3)%4)}_markEdgeResolutionDirty(e){const t=1<<e;this._dirtyEdgeResolutions|=t,this._markEdgeDirty(e)}_markAllEdgesAndCornersDirty(){this._dirtyCorners=15,this._dirtyEdges=15,this._dirtyEdgeResolutions=15}updateGeometryState(){const t=this._getElevationInfo(),r=this.tile,i=t.samplerData?r.getElevationVerticesPerSide(t.maxTileLevel):r.getDefaultVerticesPerSide(),s=Math.max(i,5);let o=r.clippingArea;r.intersectsClippingArea&&!r.isWithinClippingArea||(o=null);const a=this.geometryState;let n=!1;a.numVerticesPerSide!==s&&(this._numVerticesPerSideChanged=!0,a.numVerticesPerSide=s,a.samplerDataVersion++,n=!0),t.changed&&(this._samplerDataChanged=!0,a.samplerData=t.samplerData,a.samplerDataVersion++,n=!0),e(a.clippingArea,o)||(this._clippingAreaChanged=!0,a.clippingArea=o,n=!0);const l=r.surface.wireframe;return a.wireframe!==l&&(this._wireframeChanged=!0,a.wireframe=l,n=!0),this._geometryStateChangedSinceLastUpdate||=n,n&&this._markAllEdgesAndCornersDirty(),this._hasGeometry=!0,this._geometryStateChangedSinceLastUpdate}_createGeometry(e){this.tile.createGeometry();const t=this.geometry.vertexAttributes,r=this.geometry.indices,i=e.gl;this._vao=new L(e,P,{geometry:p(t.layout)},{geometry:N.createVertex(e,i.STATIC_DRAW,t.buffer)},N.createIndex(e,i.STATIC_DRAW,r)),this._hasGeometry=!0}get vao(){return this._vao}setTextureReference(e,t=j.Immediate){null!=e&&e.texture!==this._texture&&this.releaseTexture(),this._textureRef.push(e,t)}get textureReference(){return this._textureRef.current}get nextTextureReference(){return this._textureRef.next}get textureFadeFactor(){return this._textureRef.fadeFactor}get textureIsFading(){return this._textureRef.isFading}_getElevationInfo(){const e=this.geometryState.samplerData,t=this.tile.layerInfo[_.ELEVATION],r=t.length,i=new Array(r);let s=0,o=0,a=!1;for(let h=0;h<r;h++){const r=t[h];if(null!=r.upsampleInfo){const t=r.upsampleInfo.tile,n=t.layerInfo[_.ELEVATION][h].data,l=n&&n.samplerData;e&&e[s]===l||(a=!0),i[s++]=l,o=Math.max(o,t.lij[0])}else if(r.data){const t=this.tile.surface.layerViewByIndex(h,_.ELEVATION);if(w(this.tile,t.layer,!1)){const t=r.data;e&&e[s]===t.samplerData||(a=!0),i[s++]=t.samplerData,o=this.tile.level}}}null!=e&&e.length!==s&&(a=!0);const n=s>0,l=n?i:null;return n&&(i.length=s),{changed:a,samplerData:l,maxTileLevel:o}}get estimatedGeometryMemoryUsage(){const e=this.intersectionData?.estimatedMemoryUsage??0;return(this.geometry.indices?.byteLength??0)+(this.geometry.vertexAttributes?.byteLength??0)+e}get texture(){return this._texture}get test(){return{hasTexture:null!=this._texture}}checkGeometryWaterproofness(){if(!v)return;const e=this.tile;if(!e.isLoaded||!e.intersectsClippingArea||0===e.level)return void C(e?.isLoaded);const u=e.surface.extent;if(null!=u&&!e.intersectsExtent(u))return;const p=S.map(((t,r)=>null!=u&&(r<2?-1:1)*(e.extent[3-r]-u[3-r])<0)),y=e.level;C(0===this._dirtyCorners),C(0===this._dirtyEdges),C(0===this._dirtyEdgeResolutions),C(!this._numVerticesPerSideChanged),C(!this._samplerDataChanged),C(!this._clippingAreaChanged),C(!this._wireframeChanged);const _=E.map((t=>e.findNeighborCornerTileExact(t,(t=>!t.intersectsClippingArea||t.isLoaded||t.level===e.level))??null)).map((e=>e?.intersectsClippingArea?e:null)),x=this.geometryState.neighborData;for(let t=0;t<4;++t){const r=x.cornerPeerNeighbors[t],i=_[t];C(i===r,`Tile[${e.lij}].corner[${t}] out of date: cur=[${r?.lij}] exp=[${i?.lij}]`)}S.forEach(((u,_)=>{if(p[_])return;const x=e.findNeighborTile(u,(e=>(e.level===y||e?.isLoaded)&&e?.intersectsClippingArea));if(!x){const t=!e.surface.updatingRootTiles&&null!=e.surface.rootTiles&&e.surface.rootTiles.length>0&&e.shouldHaveNeighbor(u);return void C(!t)}C(x.isLoaded||x.level===e.level),C(x===this.geometryState.neighborData.edgePeerNeighbors[_]);const D=y-x.level;if(!x.isLoaded)return C(!x.isLeaf),void C(0===D);const v=x.renderData;C(V(e,x,u)),C(D>=0);const S=2**D;if(D<0)return void C(!1);const $=e.renderData,E=$.geometry,A=E.outerEdges[_],j=E.numVerticesPerSide-1,R=v.geometry;if(!R)return void C(!1);const w=this.geometryState.neighborData.edgePeerNeighbors[_];if(w?.isLoaded){const e=w.renderData;C(w==w),C($.geometryState.neighborData.edgePeerNeighborSamplerVersions[_]===e.geometryState.samplerDataVersion),C(this.geometryState.neighborData.edgePeerNeighborSamplerVersions[_]===e.geometryState.samplerDataVersion)}const L=(_+2)%4,P=R.outerEdges[L],N=A.count-1,G=P.count-1;C(N*S===G,`Tile[${e.lij}]:e${_},res=${N} edgeRes mismatch with Neighbor[${x.lij}]:e${L},res=${G} (expected:${N*S})`);const I=e.extent,H=u===f.NORTH||u===f.SOUTH,W=P.count-1,q=W/2**D,z=A.count-1;if(q<1)return void C(1===z);C(q===z),C(t(q));const J=R.numVerticesPerSide-1;C(D>0||q===Math.max(J,j));const K=e.getNeighborEdgeStartVertexIndex(_,x);C(0<=K&&K<S);const Q=K*q;C(0<=Q&&Q<=W-q);let Y=0,Z=Q;A.getVertexPos(M,0),A.getVertexPos(O,A.count-1);const ee=r(M,O),te=Math.max(X,1e-4*ee);for(let t=0;t<=q;++t){A.getVertexPos(M,Y),P.getVertexPos(O,Z);const r=t/q,p=H?I[0]+r*(I[2]-I[0]):u===f.WEST?I[0]:I[2],y=H?u===f.SOUTH?I[1]:I[3]:I[1]+r*(I[3]-I[1]),D=e.surface.extent;if(null==D||c(D,p,y)){const t=i(M,O),r=s(M)-m.radius,u=s(O)-m.radius,c=t<te;if(!c){console.warn(`Tile edge vertex position mismatch: between [${e.lij}].edge${_}[${Y}/${A.count}] and [${x.lij}].edge${L}[${Z}/${P.count}]`),null!=D&&console.warn(" surface extent= ",D," x,y=",p,",",y);const i=d();o(i,$.localOrigin,v.localOrigin),s(i)>0&&console.warn(` localOrigins: ${$.localOrigin} vs ${v.localOrigin} d=${s(i)} [${i}]`);(()=>{const t=g(M),r=g(O);e.updateEdgeElevations(),x.updateEdgeElevations(),A.getVertexPos(M,Y),P.getVertexPos(O,Z);const i=d();l(i,M,t),s(i)>0&&console.warn(` XXX Tile[${e.lij}] edge out of date: ${t} vs ${M} d=${s(i)} [${i}]`),l(i,O,r),s(i)>0&&console.warn(` XXX Neighbor[${x.lij}] edge out of date: ${r} vs ${O} d=${s(i)} [${i}]`)})(),C(c,`Mismatch in tile [${e.lij}].edge[${_}][${Y}/${A.count}] vs neighbor [${x.lij}].edge[${L}][${Z}/${P.count}] ${b(M)} vs ${b(O)} dist=${t} h(t|n|d)=${r}|${u}|${u-r}`)}A.getNormal(U,Y),P.getNormal(k,Z),a(B,U),a(F,k);const f=n(B,F),S=1-f<.01||!1||e===x;if(!S){const t=d();l(t,U,k);const r=()=>`Mismatch in tile edge normal ${T(e.lij)} (${Y}/${A.count-1}) edge ${_} vs neighbor ${T(x.lij)} (${Z}/${P.count-1}) nedge ${L} :${b(U)} vs ${b(k)} dot = ${f} : ${b(t)}`;console.warn("Mismatch in tile edge normal: ",r());{e.updateEdgeElevations(),x.updateEdgeElevations();const t=d(),r=d();A.getNormal(t,Y),P.getNormal(r,Z),h(U,t)||console.warn("Missing update in tile normal: ",b(U)," => ",b(t)),h(k,r)||console.warn("Missing update in neighbor normal: ",b(k)," => ",b(r))}C(S,r())}}Y+=1,Z+=1}}))}}const M=d(),O=d(),U=d(),k=d(),B=d(),F=d(),X=1,H=[null,null,null,null];function W(e,t){return t?.isLoaded||t===e?t:null}export{j as ActivationTime,I as PatchRenderData,W as neighborTileIfLoadedOrSelf};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../Color.js";import r from"../../../core/Accessor.js";import{disposeMaybe as i}from"../../../core/maybe.js";import s from"../../../core/ObjectPool.js";import{property as n}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import"../../../core/arrayUtils.js";import"../../../core/has.js";import{subclass as o}from"../../../core/accessorSupport/decorators/subclass.js";import{I as a}from"../../../chunks/mat4f64.js";import{b as l,s as h,e as u}from"../../../chunks/vec3.js";import{Z as c,f as d,c as p}from"../../../chunks/vec3f64.js";import{Z as _}from"../../../chunks/vec4f64.js";import{create as f,set as m}from"../../../geometry/support/aaBoundingBox.js";import{BufferViewVec3f as g}from"../../../geometry/support/buffer/BufferView.js";import{ViewingMode as b}from"../../ViewingMode.js";import{TextureUpdate as y}from"./interfaces.js";import{LayerClass as T}from"./LayerClass.js";import{OverlaySource as R}from"./Overlay.js";import{overlayRenderOccludedFlag as x}from"./OverlayRenderer.js";import{clearCaches as O}from"./PatchGeometry.js";import{PatchRenderData as C}from"./PatchRenderData.js";import{RenderOrder as v}from"./RenderOrder.js";import{ENABLE_TERRAIN_INTERNAL_CHECKS as D}from"./terrainUtils.js";import{TileRenderer as P}from"./TileRenderer.js";import{TileUpdate as S}from"./TileUpdate.js";import{IteratorPreorder as E,sortTiles as q,compareTiles as A}from"./tileUtils.js";import{componentMinimalSizeForIntersectionData as w,ComponentIntersectionData as N}from"../webgl-engine/collections/Component/ComponentIntersectionData.js";import{ShaderOutput as j}from"../webgl-engine/core/shaderLibrary/ShaderOutput.js";import{OverlayMode as G}from"../webgl-engine/core/shaderLibrary/terrain/Overlay.glsl.js";import{T as I}from"../../../chunks/Terrain.glsl.js";import{TileBlendInput as L}from"../webgl-engine/core/shaderLibrary/terrain/TileBlendInput.js";import{Attribute as F}from"../webgl-engine/lib/Attribute.js";import{RenderRequestType as U}from"../webgl-engine/lib/basicInterfaces.js";import{createEmptyTexture as k}from"../webgl-engine/lib/glUtil3D.js";import{newIntersectorResult as B}from"../webgl-engine/lib/Intersector.js";import{IntersectorType as M,StoreResults as z}from"../webgl-engine/lib/IntersectorInterfaces.js";import{RenderOccludedFlag as V}from"../webgl-engine/lib/Material.js";import{RenderSlot as H}from"../webgl-engine/lib/RenderSlot.js";import{getSettings as W}from"../webgl-engine/lib/screenSizePerspectiveUtils.js";import{VertexAttribute as Y}from"../webgl-engine/lib/VertexAttribute.js";import{TERRAIN_ID as Q,getVerticalOffsetTerrain as X}from"../webgl-engine/lib/verticalOffsetUtils.js";import{DrawParameters as Z}from"../webgl-engine/materials/DrawParameters.js";import{intersectAabbInvDirBefore as K,intersectTriangles as J}from"../webgl-engine/materials/internal/MaterialUtil.js";import{TerrainTechnique as $}from"../webgl-engine/shaders/TerrainTechnique.js";import{TerrainTechniqueConfiguration as ee}from"../webgl-engine/shaders/TerrainTechniqueConfiguration.js";import{PrimitiveType as te}from"../../webgl/enums.js";const re=7,ie=10,se=f();var ne;!function(e){e[e.Opaque=0]="Opaque",e[e.Semitransparent=1]="Semitransparent",e[e.TransparentWithDraped=2]="TransparentWithDraped",e[e.Empty=3]="Empty"}(ne||(ne={}));let oe=class extends r{get _isGlobal(){return this._stage.viewingMode===b.Global}constructor(e){super(e),this.type=M.TERRAIN,this.isGround=!0,this.renderSlots=[H.OPAQUE_TERRAIN,H.TRANSPARENT_TERRAIN,H.OCCLUDED_TERRAIN],this._tileSize=256,this._techniqueConfiguration=new ee,this._passParameters=new I,this._rctx=null,this._renderDataPool=new s(C),this._patchGroups=new Map,this._patchGroupsDirty=!0,this._patchSortingDirty=!0,this._tileIterator=new E,this._highestVisibleLODTile=null,this._visible=!0,this._transparencyState=ne.Opaque,this._castShadows=!0,this._emptyTex=null,this._tileRenderer=null,this._stencilEnabledLayerExtents=new Array,this._numTilesRendered=0,this._numTilesCulled=0,this._numOriginsRendered=0,this.needsHighlight=!1,this.renderOccludedFlags=V.Occlude}initialize(){this._stage.addRenderPlugin(this)}destroy(){this._stage.removeRenderPlugin(this),O()}get canRender(){return this._visible&&!!this._rootTiles&&!this.renderingDisabled}set renderingDisabled(e){this._set("renderingDisabled",!!e),this.setDirty()}set transparency(e){this._transparencyState!==e&&(this._techniqueConfiguration.invisible=e===ne.TransparentWithDraped||e===ne.Empty,this._transparencyState=e,this.setNeedsRender())}get transparency(){return this._transparencyState}get needsLinearDepth(){return this._overlayRenderer.hasWater}get renderPatchBorders(){return!!this._techniqueConfiguration.tileBorders}set renderPatchBorders(e){this._techniqueConfiguration.tileBorders!==e&&(this._techniqueConfiguration.tileBorders=e,this.setNeedsRender(),this.notifyChange("renderPatchBorders"))}get visualizeNormals(){return!!this._techniqueConfiguration.visualizeNormals}set visualizeNormals(e){this._techniqueConfiguration.visualizeNormals!==e&&(this._techniqueConfiguration.visualizeNormals=e,this.setNeedsRender(),this.notifyChange("visualizeNormals"))}get cullBackFaces(){return this._techniqueConfiguration.backfaceCullingEnabled}set cullBackFaces(e){this._techniqueConfiguration.backfaceCullingEnabled!==e&&(this._techniqueConfiguration.backfaceCullingEnabled=e,this.notifyChange("cullBackFaces"),this.setNeedsRender())}set renderOrder(e){this._set("renderOrder",e),this._setSortingDirty()}get layerUid(){return Q}get slicePlaneEnabled(){return this._techniqueConfiguration.hasSlicePlane}set slicePlaneEnabled(e){this._techniqueConfiguration.hasSlicePlane!==e&&(this._techniqueConfiguration.hasSlicePlane=e,this.setNeedsRender())}set textureFadingEnabled(e){this._techniqueConfiguration.textureFadingEnabled!==e&&(this._techniqueConfiguration.textureFadingEnabled=e,this.setNeedsRender())}set pbrMode(e){this._techniqueConfiguration.pbrMode!==e&&(this._techniqueConfiguration.pbrMode=e,this.setNeedsRender())}setDebugScreenSizePerspective(e){this._techniqueConfiguration.screenSizePerspective!==e&&(this._techniqueConfiguration.screenSizePerspective=e,this.setNeedsRender())}setRootTiles(e){this._rootTiles=e,this.setDirty()}setNeedsHighlight(e){this.needsHighlight=e,this.setNeedsRender()}setRenderOccludedOverlay(e){this.renderOccludedFlags=e?x:V.Occlude,this.setNeedsRender()}setStencilEnabledLayerExtents(e){this._stencilEnabledLayerExtents=e,this._setSortingDirty()}setTileSize(e){this._tileSize=e,null!=this._tileRenderer&&(this._tileRenderer.tileSize=e),this.setDirty()}_prepareTileForLoading(e){e.renderData||(e.renderData=this._renderDataPool.acquire(),e.renderData.init(e),e.renderData.localOrigin=this._getLocalOriginOfTile(e))}loadTile(e){this._prepareTileForLoading(e),this.updateTileGeometryState(e),this.updateTileTexture(e,S.TEXTURE_FADING)}updateTileTexture(e,t){null!=this._tileRenderer&&(this._tileRenderer.updateTileTexture(e,t===S.TEXTURE_FADING?y.FADING:y.UNFADED),this.setNeedsRender(),e.resetPendingUpdate(t))}updateTileGeometryState(e){for(const r of e.layerInfo[T.ELEVATION])r.pendingUpdates&=~S.GEOMETRY;e.resetPendingUpdate(S.GEOMETRY);const t=e.renderData.updateGeometryState();return t&&this.setDirty(),t}updateGeometryIfNeeded(e){e.isLoaded&&e.renderData.updateGeometryIfNeeded(this._rctx)}unloadTile(e){const t=e.renderData;t&&(t.releaseGeometry(),this._renderDataPool.release(t),t.clear(),e.renderData=null,e.setMemoryDirty(),this.setDirty())}_getLocalOriginOfTile(e){const t=ie-re,r=Math.max(0,Math.floor((e.level-t)/re)*re);if(this._isGlobal&&0===r)return c;for(;e.parent&&e.level>r;)e=e.parent;return e.centerAtSeaLevel}setVisibility(e){this._visible=e,this.setDirty()}getStats(){return{numTilesRendered:this._numTilesRendered,numTilesCulled:this._numTilesCulled,numOriginsRendered:this._numOriginsRendered}}set wireframe(e){this._get("wireframe")!==e&&(this._set("wireframe",e),this.setNeedsRender())}setDirty(e=U.UPDATE){this._patchGroupsDirty=!0,this._context.requestRender(e)}_setSortingDirty(e=U.UPDATE){this._patchSortingDirty=!0,this._context.requestRender(e)}setNeedsRender(e=U.UPDATE){this._context.requestRender(e)}initializeRenderContext(e){this._context=e,this._rctx=e.renderContext.rctx,this._techniqueRepository=e.techniqueRepository,this._tileRenderer=new P(this._rctx,this._tileSize,this._techniqueRepository),this.updateTileBackground(),this._emptyTex=k(this._rctx)}uninitializeRenderContext(){this._emptyTex=i(this._emptyTex),this._tileRenderer=i(this._tileRenderer)}intersect(e,t,r,i){if(!this._rootTiles||e.options.selectOpaqueTerrainOnly&&e.options.selectionMode&&this.transparency!==ne.Opaque)return;const s=ae,n=le;l(s,i,r),h(n,1/s[0],1/s[1],1/s[2]);const o=e.results.min,c=e.results.max,d=e.results.ground,p=e.options.store===z.MIN,_=!!e.results.ground.target,f=X(e.verticalOffset),b=e.tolerance;let y,T=p&&null!=o.dist?o.dist:1/0;const R=h=>{const _=h.renderData;if(!_?.vao)return;const R=_.geometry;m(se,R.boundingBox);const x=_.localOrigin;null!=f&&(f.localOrigin=x,f.applyToAabb(se));const O=se;if(he[0]=r[0]-x[0],he[1]=r[1]-x[1],he[2]=r[2]-x[2],!K(O,he,n,b,T))return;const C=(e,t,r)=>{e.set(this.type,h,t,r,a),T=p&&null!=o.dist?o.dist:1/0},v=(n,a)=>{if(null!=a&&n>=0&&(e.options.backfacesTerrain||u(a,s)<0)&&(e.options.invisibleTerrain||!e.options.selectionMode||null==t||t(r,i,n))){if((null==d.dist||n<d.dist)&&C(d,n,a),e.options.isFiltered)return;e.options.store===z.ALL&&(null==y?(y=B(e.ray),C(y,n,a),e.results.all.push(y)):n<y.dist&&C(y,n,a)),(null==o.dist||n<o.dist)&&C(o,n,a),e.options.store!==z.MIN&&(null==c.dist||n>c.dist)&&C(c,n,a)}},D=ue;l(D,i,x);const P=R.indices,S=R.vertexAttributes,E=S.getField(Y.POSITION,g),q=new F(E.typedBuffer,3,!1,S.stride/4),A=R.indexCount/3;if(!f&&A>w){const e=h.renderData;null==e.intersectionData&&(e.intersectionData=new N(P,0,A,q)),e.intersectionData.intersectRay({r0:he,r1:D},v)}else J(he,D,0,A,P,q,null,f,v)},x=this._rootTiles;if(null!=x){(()=>{const t=this._tileIterator;t.reset(x);const i=e.options.invisibleTerrain;for(let e=t.next();e;e=t.next())!(e.visible||i&&e.intersectsClippingArea)||null==f&&!e.intersectsRay(r,s,b,T)||_&&this._useStencilForTile(e)?t.skipSubtree():R(e)})()}}processScaleRangeQueries(e,t){if(!t.done)for(this._updatePatchGroups();e.updating&&!t.done;){e.prepare();for(const t of this._patchGroups.values())for(const r of t)null!=r.renderData?.textureReference&&e.queriesForTile(r);e.process(),t.madeProgress()}}prepareTechnique(e){if(e.bindParameters.slot===H.OCCLUDED_TERRAIN){if(0==(e.renderOccludedMask&x))return null}else{const t=this.transparency===ne.Opaque?H.OPAQUE_TERRAIN:H.TRANSPARENT_TERRAIN;if(e.bindParameters.slot!==t)return null}switch(e.output){case j.Color:return this.transparency===ne.Empty?null:(this._techniqueConfiguration.hasScreenSpaceReflections=null!=e.bindParameters.ssr.lastFrameColor,this._techniqueConfiguration.hasCloudsReflections=null!=e.bindParameters.cloudsFade.data,this._techniqueConfiguration.receiveShadows=e.bindParameters.shadowMap.ready,this._techniqueConfiguration.receiveAmbientOcclusion=e.bindParameters.ssaoHelper.active,this._techniqueConfiguration.overlayMode=this._overlayRenderer.isEmpty?G.Disabled:this._overlayRenderer.hasWater?G.EnabledWithWater:G.Enabled,this._updateTechnique(j.Color,e.bindParameters.slot===H.OCCLUDED_TERRAIN));case j.Shadow:case j.ShadowExcludeHighlight:return this._castShadows&&1===e.bindParameters.lighting.globalFactor?(this._techniqueConfiguration.receiveShadows=this._techniqueConfiguration.receiveAmbientOcclusion=!1,this._updateTechnique(j.Shadow,!1)):null;case j.Depth:return this.transparency===ne.Empty?null:(this._techniqueConfiguration.receiveShadows=this._techniqueConfiguration.receiveAmbientOcclusion=!1,this._updateTechnique(j.Depth,!1));case j.Normal:return this.transparency===ne.Empty?null:(this._techniqueConfiguration.receiveShadows=this._techniqueConfiguration.receiveAmbientOcclusion=!1,this._updateTechnique(j.Normal,!1));case j.ObjectAndLayerIdColor:return this.transparency===ne.Empty?null:this._updateTechnique(j.ObjectAndLayerIdColor,!1);case j.Highlight:return this.transparency!==ne.Empty&&this.needsHighlight?(this._techniqueConfiguration.receiveShadows=this._techniqueConfiguration.receiveAmbientOcclusion=!1,this._updateTechnique(j.Highlight,!1)):null}return null}render(e,t){switch(this._updatePatchGroups(),t.useStencil=!1,e.output){case j.Color:{const r=e.bindParameters.slot===H.OCCLUDED_TERRAIN?R.Occluded:R.ColorAndWater;this._renderMaterialPass(e,t,r);break}case j.Depth:case j.Normal:this._renderAuxiliaryPass(e,t,R.ColorAndWater);break;case j.Highlight:this._renderAuxiliaryPass(e,t,R.Highlight);break;case j.Shadow:case j.ShadowExcludeHighlight:this._renderAuxiliaryPass(e,t,R.None);break;case j.ObjectAndLayerIdColor:this._renderAuxiliaryPass(e,t,R.ObjectAndLayerIdColor)}}_renderMaterialPass(e,t,r){const{rctx:i}=e;this._passParameters.overlaySource=r,i.bindTechnique(t,this._passParameters,e.bindParameters),this._numTilesRendered=0,this._numTilesCulled=0,this._numOriginsRendered=0,this._renderPatchGroups(e,t,r)}_renderAuxiliaryPass(e,t,r){const i=e.rctx;this._passParameters.overlaySource=r,i.bindTechnique(t,this._passParameters,e.bindParameters),this._renderPatchGroupsAuxiliary(e,t,r)}updateTileBackground(e=null){if(null==this._tileRenderer)return;const r=this._tileRenderer;let i=null;if(null!=e){const r=t.toUnitRGBA(e);i=d(r[0]||0,r[1]||0,r[2]||0)}r.setBackground(i),this._allTiles.forAll((e=>r.updateTileTexture(e,y.FADING))),this._techniqueConfiguration.tileBlendInput=r.backgroundIsGrid?L.GridComposite:null!=r.backgroundColor?L.ColorComposite:L.LayerOnly,this.setNeedsRender()}_updatePatchGroups(){if(this._patchGroupsDirty&&(this._highestVisibleLODTile=null,this._rebuildPatchGroups(),this._patchGroupsDirty=!1,this._patchSortingDirty=!0),this._patchSortingDirty&&this.renderOrder!==v.NONE){const e=Array.from(this._patchGroups.values()),t=this._stencilEnabledLayerExtents;for(const r of e)q(this.renderOrder,r,t);e.sort(((e,t)=>A(e[0],t[0],this.renderOrder))),this._patchGroups=new Map(e.map((e=>[e[0].renderData.localOrigin,e]))),this._patchSortingDirty=!1}}_rebuildPatchGroups(){const e=this._rootTiles;if(null!=e){e[0]?.surface.checkAllTilesWaterproofness(),this._patchGroups.clear();for(const t of e)this._rebuildPatchGroupsForRootTile(t)}}_rebuildPatchGroupsForRootTile(e){const t=this._tileIterator;for(t.resetOne(e);!t.done;){const e=t.next(),r=e.renderData;if(!r){this._numTilesCulled++;continue}if(!e.visible){this._numTilesCulled++,t.skipSubtree();continue}const i=r.localOrigin;let s=this._patchGroups.get(i);s||(s=new Array,this._patchGroups.set(i,s)),s.push(e),(!this._highestVisibleLODTile||e.elevationLevel>this._highestVisibleLODTile.elevationLevel)&&(this._highestVisibleLODTile=e),t.skipSubtree()}}_useStencilForTile(e){for(const t of this._stencilEnabledLayerExtents)if(e.intersectsExtent(t))return!0;return!1}_renderPatchGroupsAuxiliary(e,t,r){const i=this._stencilEnabledLayerExtents.length>0;this._patchGroups.forEach((s=>{const n=s[0].renderData.localOrigin;t.program.bindDraw(new Z(n),e.bindParameters,this._passParameters);for(let o=0;o<s.length;o++)this._renderPatch(e,t,s[o],te.TRIANGLES,i,r)})),e.rctx.bindVAO(null)}_renderPatchGroups(e,t,r){const i=e.bindParameters.camera,s=t.program;if(this._techniqueConfiguration.screenSizePerspective&&this.pointsOfInterest){const e=W(this._stage.viewingMode,this._ellipsoidRadius),t=this.pointsOfInterest.centerOnSurfaceFrequent.distance;e.update({distance:t,fovY:i.fovY})}const n=this._stencilEnabledLayerExtents.length>0,o=r===R.Occluded;o&&(s.bindTexture("tex",this._emptyTex),s.setUniform3fv("textureOpacities",c),s.setUniform4fv("texOffsetAndScale",_));const a=null!=this._tileRenderer&&null!=this._tileRenderer.backgroundColor?this._tileRenderer.backgroundColor:c;this._techniqueConfiguration.tileBlendInput===L.ColorComposite&&s.setUniform3fv("backgroundColor",a);const l=this.wireframe?te.LINES:te.TRIANGLES;this._techniqueConfiguration.textureFadingEnabled&&s.bindTexture("texNext",this._emptyTex);const h=this._patchGroups;for(const u of h.values()){const i=u[0].renderData.localOrigin;t.program.bindDraw(new Z(i),e.bindParameters,this._passParameters),this._numOriginsRendered++;for(const a of u){const i=a.renderData,h=i.textureReference;if(null!=h){if(!o){s.setUniform4fv("texOffsetAndScale",h.offsetAndScale),s.bindTexture("tex",h.texture.texture);const e=i.textureFadeFactor,t=e<1?i.nextTextureReference:null;this._techniqueConfiguration.textureFadingEnabled&&null!=t&&e<1?(s.setUniform1f("fadeFactor",e),s.setUniform4fv("nextTexOffsetAndScale",t.offsetAndScale),s.setUniform3fv("nextTexOpacities",t.opacities),s.bindTexture("texNext",t.texture.texture)):s.setUniform1f("fadeFactor",1),i.textureIsFading&&this.setNeedsRender(),s.setUniform3fv("textureOpacities",h.opacities)}this._renderPatch(e,t,a,l,n,r),a.renderOrder=this._numTilesRendered,this._numTilesRendered++}}}e.rctx.bindVAO(null)}_renderPatch(e,t,r,i,s,n){const o=r.renderData,a=o.vao,l=a.indexBuffer;if(null==l)return void(D&&console.error("Rendered tile with no indices: ",r.lij," : ",o));const h=t.program;n===R.None||this._overlayRenderer.isEmpty||this._bindOverlayPatchData(h,o.overlay),s&&(t.useStencil=this._useStencilForTile(r),t.bindPipelineState(e.rctx,e.bindParameters.slot));const u=o.geometry.indexCount;e.rctx.bindVAO(a),h.assertCompatibleVertexAttributeLocations(a),e.rctx.drawElements(i,u,l.indexType,0)}_bindOverlayPatchData(e,t){e.setUniform4fv("overlayTexOffset",t.offsets),e.setUniform4fv("overlayTexScale",t.scales)}_updateTechnique(e,t){return this._techniqueConfiguration.output=e,this._techniqueConfiguration.renderOccluded=t,this._shaderTechnique=this._techniqueRepository.releaseAndAcquire($,this._techniqueConfiguration,this._shaderTechnique),this._shaderTechnique}get test(){return{tileRenderer:this._tileRenderer}}};e([n({constructOnly:!0})],oe.prototype,"_overlayRenderer",void 0),e([n({constructOnly:!0})],oe.prototype,"_stage",void 0),e([n({readOnly:!0})],oe.prototype,"_isGlobal",null),e([n({constructOnly:!0})],oe.prototype,"_allTiles",void 0),e([n({constructOnly:!0})],oe.prototype,"_ellipsoidRadius",void 0),e([n({value:!1})],oe.prototype,"renderingDisabled",null),e([n()],oe.prototype,"renderPatchBorders",null),e([n()],oe.prototype,"visualizeNormals",null),e([n()],oe.prototype,"cullBackFaces",null),e([n({value:v.FRONT_TO_BACK})],oe.prototype,"renderOrder",null),e([n()],oe.prototype,"wireframe",null),oe=e([o("esri.views.3d.terrain.TerrainRenderer")],oe);const ae=p(),le=p(),he=p(),ue=p();export{oe as TerrainRenderer,ne as TransparencyMode};
5
+ import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../Color.js";import i from"../../../core/Accessor.js";import{disposeMaybe as r}from"../../../core/maybe.js";import s from"../../../core/ObjectPool.js";import{property as n}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import"../../../core/arrayUtils.js";import"../../../core/has.js";import{subclass as o}from"../../../core/accessorSupport/decorators/subclass.js";import{I as a}from"../../../chunks/mat4f64.js";import{b as l,s as h,e as u}from"../../../chunks/vec3.js";import{Z as c,f as d,c as p}from"../../../chunks/vec3f64.js";import{Z as _}from"../../../chunks/vec4f64.js";import{create as f,set as m}from"../../../geometry/support/aaBoundingBox.js";import{BufferViewVec3f as g}from"../../../geometry/support/buffer/BufferView.js";import{ViewingMode as b}from"../../ViewingMode.js";import{TextureUpdate as y}from"./interfaces.js";import{LayerClass as T}from"./LayerClass.js";import{OverlaySource as R}from"./Overlay.js";import{overlayRenderOccludedFlag as O}from"./OverlayRenderer.js";import{clearCaches as x}from"./PatchGeometry.js";import{PatchRenderData as C}from"./PatchRenderData.js";import{RenderOrder as v}from"./RenderOrder.js";import{ENABLE_TERRAIN_INTERNAL_CHECKS as D}from"./terrainUtils.js";import{TileRenderer as P}from"./TileRenderer.js";import{TileUpdate as S}from"./TileUpdate.js";import{IteratorPreorder as E,sortTiles as q,compareTiles as A}from"./tileUtils.js";import{componentMinimalSizeForIntersectionData as w,ComponentIntersectionData as N}from"../webgl-engine/collections/Component/ComponentIntersectionData.js";import{ShaderOutput as j}from"../webgl-engine/core/shaderLibrary/ShaderOutput.js";import{OverlayMode as G}from"../webgl-engine/core/shaderLibrary/terrain/Overlay.glsl.js";import{T as I}from"../../../chunks/Terrain.glsl.js";import{TileBlendInput as L}from"../webgl-engine/core/shaderLibrary/terrain/TileBlendInput.js";import{Attribute as F}from"../webgl-engine/lib/Attribute.js";import{RenderRequestType as U}from"../webgl-engine/lib/basicInterfaces.js";import{createEmptyTexture as k}from"../webgl-engine/lib/glUtil3D.js";import{newIntersectorResult as B}from"../webgl-engine/lib/Intersector.js";import{IntersectorType as M,StoreResults as z}from"../webgl-engine/lib/IntersectorInterfaces.js";import{RenderOccludedFlag as V}from"../webgl-engine/lib/Material.js";import{RenderSlot as H}from"../webgl-engine/lib/RenderSlot.js";import{getSettings as W}from"../webgl-engine/lib/screenSizePerspectiveUtils.js";import{VertexAttribute as Y}from"../webgl-engine/lib/VertexAttribute.js";import{TERRAIN_ID as Q,getVerticalOffsetTerrain as X}from"../webgl-engine/lib/verticalOffsetUtils.js";import{DrawParameters as Z}from"../webgl-engine/materials/DrawParameters.js";import{intersectAabbInvDirBefore as K,intersectTriangles as J}from"../webgl-engine/materials/internal/MaterialUtil.js";import{TerrainTechnique as $}from"../webgl-engine/shaders/TerrainTechnique.js";import{TerrainTechniqueConfiguration as ee}from"../webgl-engine/shaders/TerrainTechniqueConfiguration.js";import{PrimitiveType as te}from"../../webgl/enums.js";const ie=7,re=10,se=f();var ne;!function(e){e[e.Opaque=0]="Opaque",e[e.Semitransparent=1]="Semitransparent",e[e.TransparentWithDraped=2]="TransparentWithDraped",e[e.Empty=3]="Empty"}(ne||(ne={}));let oe=class extends i{get _isGlobal(){return this._stage.viewingMode===b.Global}constructor(e){super(e),this.type=M.TERRAIN,this.isGround=!0,this.renderSlots=[H.OPAQUE_TERRAIN,H.TRANSPARENT_TERRAIN,H.OCCLUDED_TERRAIN],this._tileSize=256,this._techniqueConfiguration=new ee,this._passParameters=new I,this._rctx=null,this._renderDataPool=new s(C),this._patchGroups=new Map,this._patchGroupsDirty=!0,this._patchSortingDirty=!0,this._tileIterator=new E,this._highestVisibleLODTile=null,this._visible=!0,this._transparencyState=ne.Opaque,this._castShadows=!0,this._emptyTex=null,this._tileRenderer=null,this._stencilEnabledLayerExtents=new Array,this._numTilesRendered=0,this._numTilesCulled=0,this._numOriginsRendered=0,this.needsHighlight=!1,this.renderOccludedFlags=V.Occlude}initialize(){this._stage.addRenderPlugin(this)}destroy(){this._stage.removeRenderPlugin(this),x()}canRender(){return this._visible&&!!this._rootTiles&&!this.renderingDisabled}requiresOutput(e){return e===j.Depth&&this._overlayRenderer.hasWater||e===j.Highlight&&this.needsHighlight}set renderingDisabled(e){this._set("renderingDisabled",!!e),this.setDirty()}set transparency(e){this._transparencyState!==e&&(this._techniqueConfiguration.invisible=e===ne.TransparentWithDraped||e===ne.Empty,this._transparencyState=e,this.setNeedsRender())}get transparency(){return this._transparencyState}get renderPatchBorders(){return!!this._techniqueConfiguration.tileBorders}set renderPatchBorders(e){this._techniqueConfiguration.tileBorders!==e&&(this._techniqueConfiguration.tileBorders=e,this.setNeedsRender(),this.notifyChange("renderPatchBorders"))}get visualizeNormals(){return!!this._techniqueConfiguration.visualizeNormals}set visualizeNormals(e){this._techniqueConfiguration.visualizeNormals!==e&&(this._techniqueConfiguration.visualizeNormals=e,this.setNeedsRender(),this.notifyChange("visualizeNormals"))}get cullBackFaces(){return this._techniqueConfiguration.backfaceCullingEnabled}set cullBackFaces(e){this._techniqueConfiguration.backfaceCullingEnabled!==e&&(this._techniqueConfiguration.backfaceCullingEnabled=e,this.notifyChange("cullBackFaces"),this.setNeedsRender())}set renderOrder(e){this._set("renderOrder",e),this._setSortingDirty()}get layerUid(){return Q}get slicePlaneEnabled(){return this._techniqueConfiguration.hasSlicePlane}set slicePlaneEnabled(e){this._techniqueConfiguration.hasSlicePlane!==e&&(this._techniqueConfiguration.hasSlicePlane=e,this.setNeedsRender())}set textureFadingEnabled(e){this._techniqueConfiguration.textureFadingEnabled!==e&&(this._techniqueConfiguration.textureFadingEnabled=e,this.setNeedsRender())}set pbrMode(e){this._techniqueConfiguration.pbrMode!==e&&(this._techniqueConfiguration.pbrMode=e,this.setNeedsRender())}setDebugScreenSizePerspective(e){this._techniqueConfiguration.screenSizePerspective!==e&&(this._techniqueConfiguration.screenSizePerspective=e,this.setNeedsRender())}setRootTiles(e){this._rootTiles=e,this.setDirty()}setNeedsHighlight(e){this.needsHighlight=e,this.setNeedsRender()}setRenderOccludedOverlay(e){this.renderOccludedFlags=e?O:V.Occlude,this.setNeedsRender()}setStencilEnabledLayerExtents(e){this._stencilEnabledLayerExtents=e,this._setSortingDirty()}setTileSize(e){this._tileSize=e,null!=this._tileRenderer&&(this._tileRenderer.tileSize=e),this.setDirty()}_prepareTileForLoading(e){e.renderData||(e.renderData=this._renderDataPool.acquire(),e.renderData.init(e),e.renderData.localOrigin=this._getLocalOriginOfTile(e))}loadTile(e){this._prepareTileForLoading(e),this.updateTileGeometryState(e),this.updateTileTexture(e,S.TEXTURE_FADING)}updateTileTexture(e,t){null!=this._tileRenderer&&(this._tileRenderer.updateTileTexture(e,t===S.TEXTURE_FADING?y.FADING:y.UNFADED),this.setNeedsRender(),e.resetPendingUpdate(t))}updateTileGeometryState(e){for(const i of e.layerInfo[T.ELEVATION])i.pendingUpdates&=~S.GEOMETRY;e.resetPendingUpdate(S.GEOMETRY);const t=e.renderData.updateGeometryState();return t&&this.setDirty(),t}updateGeometryIfNeeded(e){e.isLoaded&&e.renderData.updateGeometryIfNeeded(this._rctx)}unloadTile(e){const t=e.renderData;t&&(t.releaseGeometry(),this._renderDataPool.release(t),t.clear(),e.renderData=null,e.setMemoryDirty(),this.setDirty())}_getLocalOriginOfTile(e){const t=re-ie,i=Math.max(0,Math.floor((e.level-t)/ie)*ie);if(this._isGlobal&&0===i)return c;for(;e.parent&&e.level>i;)e=e.parent;return e.centerAtSeaLevel}setVisibility(e){this._visible=e,this.setDirty()}getStats(){return{numTilesRendered:this._numTilesRendered,numTilesCulled:this._numTilesCulled,numOriginsRendered:this._numOriginsRendered}}set wireframe(e){this._get("wireframe")!==e&&(this._set("wireframe",e),this.setNeedsRender())}setDirty(e=U.UPDATE){this._patchGroupsDirty=!0,this._context.requestRender(e)}_setSortingDirty(e=U.UPDATE){this._patchSortingDirty=!0,this._context.requestRender(e)}setNeedsRender(e=U.UPDATE){this._context.requestRender(e)}initializeRenderContext(e){this._context=e,this._rctx=e.renderContext.rctx,this._techniqueRepository=e.techniqueRepository,this._tileRenderer=new P(this._rctx,this._tileSize,this._techniqueRepository),this.updateTileBackground(),this._emptyTex=k(this._rctx)}uninitializeRenderContext(){this._emptyTex=r(this._emptyTex),this._tileRenderer=r(this._tileRenderer)}intersect(e,t,i,r){if(!this._rootTiles||e.options.selectOpaqueTerrainOnly&&e.options.selectionMode&&this.transparency!==ne.Opaque)return;const s=ae,n=le;l(s,r,i),h(n,1/s[0],1/s[1],1/s[2]);const o=e.results.min,c=e.results.max,d=e.results.ground,p=e.options.store===z.MIN,_=!!e.results.ground.target,f=X(e.verticalOffset),b=e.tolerance;let y,T=p&&null!=o.dist?o.dist:1/0;const R=h=>{const _=h.renderData;if(!_?.vao)return;const R=_.geometry;m(se,R.boundingBox);const O=_.localOrigin;null!=f&&(f.localOrigin=O,f.applyToAabb(se));const x=se;if(he[0]=i[0]-O[0],he[1]=i[1]-O[1],he[2]=i[2]-O[2],!K(x,he,n,b,T))return;const C=(e,t,i)=>{e.set(this.type,h,t,i,a),T=p&&null!=o.dist?o.dist:1/0},v=(n,a)=>{if(null!=a&&n>=0&&(e.options.backfacesTerrain||u(a,s)<0)&&(e.options.invisibleTerrain||!e.options.selectionMode||null==t||t(i,r,n))){if((null==d.dist||n<d.dist)&&C(d,n,a),e.options.isFiltered)return;e.options.store===z.ALL&&(null==y?(y=B(e.ray),C(y,n,a),e.results.all.push(y)):n<y.dist&&C(y,n,a)),(null==o.dist||n<o.dist)&&C(o,n,a),e.options.store!==z.MIN&&(null==c.dist||n>c.dist)&&C(c,n,a)}},D=ue;l(D,r,O);const P=R.indices,S=R.vertexAttributes,E=S.getField(Y.POSITION,g),q=new F(E.typedBuffer,3,!1,S.stride/4),A=R.indexCount/3;if(!f&&A>w){const e=h.renderData;null==e.intersectionData&&(e.intersectionData=new N(P,0,A,q)),e.intersectionData.intersectRay({r0:he,r1:D},v)}else J(he,D,0,A,P,q,null,f,v)},O=this._rootTiles;if(null!=O){(()=>{const t=this._tileIterator;t.reset(O);const r=e.options.invisibleTerrain;for(let e=t.next();e;e=t.next())!(e.visible||r&&e.intersectsClippingArea)||null==f&&!e.intersectsRay(i,s,b,T)||_&&this._useStencilForTile(e)?t.skipSubtree():R(e)})()}}processScaleRangeQueries(e,t){if(!t.done)for(this._updatePatchGroups();e.updating&&!t.done;){e.prepare();for(const t of this._patchGroups.values())for(const i of t)null!=i.renderData?.textureReference&&e.queriesForTile(i);e.process(),t.madeProgress()}}prepareTechnique(e){if(e.bindParameters.slot===H.OCCLUDED_TERRAIN){if(0==(e.renderOccludedMask&O))return null}else{const t=this.transparency===ne.Opaque?H.OPAQUE_TERRAIN:H.TRANSPARENT_TERRAIN;if(e.bindParameters.slot!==t)return null}switch(e.output){case j.Color:return this.transparency===ne.Empty?null:(this._techniqueConfiguration.hasScreenSpaceReflections=null!=e.bindParameters.ssr.lastFrameColor,this._techniqueConfiguration.hasCloudsReflections=null!=e.bindParameters.cloudsFade.data,this._techniqueConfiguration.receiveShadows=e.bindParameters.shadowMap.ready,this._techniqueConfiguration.receiveAmbientOcclusion=e.bindParameters.ssaoHelper.active,this._techniqueConfiguration.overlayMode=this._overlayRenderer.isEmpty?G.Disabled:this._overlayRenderer.hasWater?G.EnabledWithWater:G.Enabled,this._updateTechnique(j.Color,e.bindParameters.slot===H.OCCLUDED_TERRAIN));case j.Shadow:case j.ShadowExcludeHighlight:return this._castShadows&&1===e.bindParameters.lighting.globalFactor?(this._techniqueConfiguration.receiveShadows=this._techniqueConfiguration.receiveAmbientOcclusion=!1,this._updateTechnique(j.Shadow,!1)):null;case j.Depth:return this.transparency===ne.Empty?null:(this._techniqueConfiguration.receiveShadows=this._techniqueConfiguration.receiveAmbientOcclusion=!1,this._updateTechnique(j.Depth,!1));case j.Normal:return this.transparency===ne.Empty?null:(this._techniqueConfiguration.receiveShadows=this._techniqueConfiguration.receiveAmbientOcclusion=!1,this._updateTechnique(j.Normal,!1));case j.ObjectAndLayerIdColor:return this.transparency===ne.Empty?null:this._updateTechnique(j.ObjectAndLayerIdColor,!1);case j.Highlight:return this.transparency!==ne.Empty&&this.needsHighlight?(this._techniqueConfiguration.receiveShadows=this._techniqueConfiguration.receiveAmbientOcclusion=!1,this._updateTechnique(j.Highlight,!1)):null}return null}render(e,t){switch(this._updatePatchGroups(),t.useStencil=!1,e.output){case j.Color:{const i=e.bindParameters.slot===H.OCCLUDED_TERRAIN?R.Occluded:R.ColorAndWater;this._renderMaterialPass(e,t,i);break}case j.Depth:case j.Normal:this._renderAuxiliaryPass(e,t,R.ColorAndWater);break;case j.Highlight:this._renderAuxiliaryPass(e,t,R.Highlight);break;case j.Shadow:case j.ShadowExcludeHighlight:this._renderAuxiliaryPass(e,t,R.None);break;case j.ObjectAndLayerIdColor:this._renderAuxiliaryPass(e,t,R.ObjectAndLayerIdColor)}}_renderMaterialPass(e,t,i){const{rctx:r}=e;this._passParameters.overlaySource=i,r.bindTechnique(t,this._passParameters,e.bindParameters),this._numTilesRendered=0,this._numTilesCulled=0,this._numOriginsRendered=0,this._renderPatchGroups(e,t,i)}_renderAuxiliaryPass(e,t,i){const r=e.rctx;this._passParameters.overlaySource=i,r.bindTechnique(t,this._passParameters,e.bindParameters),this._renderPatchGroupsAuxiliary(e,t,i)}updateTileBackground(e=null){if(null==this._tileRenderer)return;const i=this._tileRenderer;let r=null;if(null!=e){const i=t.toUnitRGBA(e);r=d(i[0]||0,i[1]||0,i[2]||0)}i.setBackground(r),this._allTiles.forAll((e=>i.updateTileTexture(e,y.FADING))),this._techniqueConfiguration.tileBlendInput=i.backgroundIsGrid?L.GridComposite:null!=i.backgroundColor?L.ColorComposite:L.LayerOnly,this.setNeedsRender()}_updatePatchGroups(){if(this._patchGroupsDirty&&(this._highestVisibleLODTile=null,this._rebuildPatchGroups(),this._patchGroupsDirty=!1,this._patchSortingDirty=!0),this._patchSortingDirty&&this.renderOrder!==v.NONE){const e=Array.from(this._patchGroups.values()),t=this._stencilEnabledLayerExtents;for(const i of e)q(this.renderOrder,i,t);e.sort(((e,t)=>A(e[0],t[0],this.renderOrder))),this._patchGroups=new Map(e.map((e=>[e[0].renderData.localOrigin,e]))),this._patchSortingDirty=!1}}_rebuildPatchGroups(){const e=this._rootTiles;if(null!=e){e[0]?.surface.checkAllTilesWaterproofness(),this._patchGroups.clear();for(const t of e)this._rebuildPatchGroupsForRootTile(t)}}_rebuildPatchGroupsForRootTile(e){const t=this._tileIterator;for(t.resetOne(e);!t.done;){const e=t.next(),i=e.renderData;if(!i){this._numTilesCulled++;continue}if(!e.visible){this._numTilesCulled++,t.skipSubtree();continue}const r=i.localOrigin;let s=this._patchGroups.get(r);s||(s=new Array,this._patchGroups.set(r,s)),s.push(e),(!this._highestVisibleLODTile||e.elevationLevel>this._highestVisibleLODTile.elevationLevel)&&(this._highestVisibleLODTile=e),t.skipSubtree()}}_useStencilForTile(e){for(const t of this._stencilEnabledLayerExtents)if(e.intersectsExtent(t))return!0;return!1}_renderPatchGroupsAuxiliary(e,t,i){const r=this._stencilEnabledLayerExtents.length>0;this._patchGroups.forEach((s=>{const n=s[0].renderData.localOrigin;t.program.bindDraw(new Z(n),e.bindParameters,this._passParameters);for(let o=0;o<s.length;o++)this._renderPatch(e,t,s[o],te.TRIANGLES,r,i)})),e.rctx.bindVAO(null)}_renderPatchGroups(e,t,i){const r=e.bindParameters.camera,s=t.program;if(this._techniqueConfiguration.screenSizePerspective&&this.pointsOfInterest){const e=W(this._stage.viewingMode,this._ellipsoidRadius),t=this.pointsOfInterest.centerOnSurfaceFrequent.distance;e.update({distance:t,fovY:r.fovY})}const n=this._stencilEnabledLayerExtents.length>0,o=i===R.Occluded;o&&(s.bindTexture("tex",this._emptyTex),s.setUniform3fv("textureOpacities",c),s.setUniform4fv("texOffsetAndScale",_));const a=null!=this._tileRenderer&&null!=this._tileRenderer.backgroundColor?this._tileRenderer.backgroundColor:c;this._techniqueConfiguration.tileBlendInput===L.ColorComposite&&s.setUniform3fv("backgroundColor",a);const l=this.wireframe?te.LINES:te.TRIANGLES;this._techniqueConfiguration.textureFadingEnabled&&s.bindTexture("texNext",this._emptyTex);const h=this._patchGroups;for(const u of h.values()){const r=u[0].renderData.localOrigin;t.program.bindDraw(new Z(r),e.bindParameters,this._passParameters),this._numOriginsRendered++;for(const a of u){const r=a.renderData,h=r.textureReference;if(null!=h){if(!o){s.setUniform4fv("texOffsetAndScale",h.offsetAndScale),s.bindTexture("tex",h.texture.texture);const e=r.textureFadeFactor,t=e<1?r.nextTextureReference:null;this._techniqueConfiguration.textureFadingEnabled&&null!=t&&e<1?(s.setUniform1f("fadeFactor",e),s.setUniform4fv("nextTexOffsetAndScale",t.offsetAndScale),s.setUniform3fv("nextTexOpacities",t.opacities),s.bindTexture("texNext",t.texture.texture)):s.setUniform1f("fadeFactor",1),r.textureIsFading&&this.setNeedsRender(),s.setUniform3fv("textureOpacities",h.opacities)}this._renderPatch(e,t,a,l,n,i),a.renderOrder=this._numTilesRendered,this._numTilesRendered++}}}e.rctx.bindVAO(null)}_renderPatch(e,t,i,r,s,n){const o=i.renderData,a=o.vao,l=a.indexBuffer;if(null==l)return void(D&&console.error("Rendered tile with no indices: ",i.lij," : ",o));const h=t.program;n===R.None||this._overlayRenderer.isEmpty||this._bindOverlayPatchData(h,o.overlay),s&&(t.useStencil=this._useStencilForTile(i),t.bindPipelineState(e.rctx,e.bindParameters.slot));const u=o.geometry.indexCount;e.rctx.bindVAO(a),h.assertCompatibleVertexAttributeLocations(a),e.rctx.drawElements(r,u,l.indexType,0)}_bindOverlayPatchData(e,t){e.setUniform4fv("overlayTexOffset",t.offsets),e.setUniform4fv("overlayTexScale",t.scales)}_updateTechnique(e,t){return this._techniqueConfiguration.output=e,this._techniqueConfiguration.renderOccluded=t,this._shaderTechnique=this._techniqueRepository.releaseAndAcquire($,this._techniqueConfiguration,this._shaderTechnique),this._shaderTechnique}get test(){return{tileRenderer:this._tileRenderer}}};e([n({constructOnly:!0})],oe.prototype,"_overlayRenderer",void 0),e([n({constructOnly:!0})],oe.prototype,"_stage",void 0),e([n({readOnly:!0})],oe.prototype,"_isGlobal",null),e([n({constructOnly:!0})],oe.prototype,"_allTiles",void 0),e([n({constructOnly:!0})],oe.prototype,"_ellipsoidRadius",void 0),e([n({value:!1})],oe.prototype,"renderingDisabled",null),e([n()],oe.prototype,"renderPatchBorders",null),e([n()],oe.prototype,"visualizeNormals",null),e([n()],oe.prototype,"cullBackFaces",null),e([n({value:v.FRONT_TO_BACK})],oe.prototype,"renderOrder",null),e([n()],oe.prototype,"wireframe",null),oe=e([o("esri.views.3d.terrain.TerrainRenderer")],oe);const ae=p(),le=p(),he=p(),ue=p();export{oe as TerrainRenderer,ne as TransparencyMode};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import{disposeMaybe as e,releaseMaybe as t}from"../../../core/maybe.js";import{s as r,j as s}from"../../../chunks/vec2.js";import{Z as o}from"../../../chunks/vec2f64.js";import{isBaseLayer as a,isGroupLayer as i}from"../../../layers/support/layerUtils.js";import{ImageWithType as n}from"../support/StreamDataLoader.js";import{BlendLayersPassParameters as u}from"./BlendLayersTechnique.js";import{TextureUpdate as c}from"./interfaces.js";import{NeighborIndex as l}from"./ITile.js";import{LayerClass as p}from"./LayerClass.js";import{isBlendableLayerView as h,isVectorTileLayerView as d,isVectorTileRenderInfo as m,isImageryTileRenderInfo as _,isRasterTileRenderInfo as f,isTextureTileRenderInfo as T,isVectorTilePerLayerInfo as y}from"./terrainUtils.js";import{ActivationTime as g}from"./TextureFader.js";import{TextureReference as b}from"./TextureReference.js";import{TileCompositor as x}from"./TileCompositor.js";import{TileRenderInfo as k}from"./TileRenderInfo.js";import w from"./TileTexture.js";import{TileUpdate as I}from"./TileUpdate.js";import{blendModeFromString as A}from"../webgl-engine/core/shaderLibrary/output/BlendOptions.js";import{BaseOpacityMode as P,BlendLayersOutput as E}from"../webgl-engine/core/shaderLibrary/terrain/TileBackground.glsl.js";import{createColorTexture as R,createEmptyTexture as M}from"../webgl-engine/lib/glUtil3D.js";import{TextureSamplingMode as D,TextureWrapMode as j}from"../../webgl/enums.js";import{Texture as L}from"../../webgl/Texture.js";import{TextureDescriptor as O}from"../../webgl/TextureDescriptor.js";class N{constructor(e,t,r,s){this.start=e,this.end=t,this.blendMode=r,this.opacity=s}}class C{constructor(e,t,r){this._rctx=e,this.tileSize=t,this._techniqueRepository=r,this._passParameters=new u,this._backgroundTexture=null,this._backgroundColor=null,this._backgroundDirty=!1,this._maxAnisotropy=this._rctx.parameters.maxMaxAnisotropy,this._composition=new x(this._rctx,this._techniqueRepository),this._blackTex=new w(R(this._rctx,[0,0,0,1])),this._ensureBackgroundTexture(this.tileSize)}dispose(){this._composition=e(this._composition),this._backgroundTexture=t(this._backgroundTexture),this._blackTex=t(this._blackTex)}get backgroundIsGrid(){return null==this._backgroundColor}get backgroundColor(){return this._backgroundColor}updateTileTexture(e,t){if(!e.renderData)return;const r=e.surface,s=r.baseOpacity;let o=0,n=0,u=this.tileSize,c=!1;const l=r.view.state.contentPixelRatio;let m=!1;z.clear(),H.length=0;const _=e.layerInfo[p.MAP];let f=_.length,T=0,y=null;for(;T<_.length;T++){const t=r.layerViewByIndex(T,p.MAP),g=t.layer.opacity;F[T]=g;const b=t.fullOpacity;if(q[T]=b,a(t.layer)&&f>=_.length&&(f=T),h(t)){v[T]=t.layer.blendMode;let e="normal"!==t.layer.blendMode;if(i(t.layer.parent)){const r=U(t.layer.parent);null!=r&&""!==r&&(e=B(t.layer.parent)||e)}e&&(m=e,c=!1)}if(0===g&&!m){_[T].pendingUpdates&=~(I.TEXTURE_NOFADING&I.TEXTURE_FADING);continue}++n;const x=S(e,T);if(x){if(_[T].pendingUpdates&=~(I.TEXTURE_NOFADING&I.TEXTURE_FADING),i(t.layer.parent)){const e=U(t.layer.parent);null!=e&&""!==e&&G(t.layer.parent,T)}d(t)?u=Math.max(u,this.tileSize*l):1===s&&1===b&&(t.isOpaque||this._dataToTexture(x)&&x.sourceLayerInfo.data.descriptor.isOpaque)&&(c=!0),++o,null===y&&(y=T)}}const g=u/this.tileSize;this._ensureBackgroundTexture(this.tileSize),0!==o&&null!==y?1===o&&!m&&this._useLayerTexture(e,y,f,q[y])||this._composeMapLayers(e,t,T-1,f,F,v,u,g,!c||m,z,m):this._useBackgroundTexture(e,n)}_ensureBackgroundTexture(e){null==this._backgroundTexture&&(this._backgroundTexture=this._buildTexture(e),this._backgroundDirty=!0),this._backgroundDirty&&(this._composition.bind(e),this._passParameters.offset=o,this._passParameters.scale=1,this._passParameters.opacity=1,null!=this.backgroundColor&&(this._passParameters.backgroundColor=this.backgroundColor),this._composition.drawBackground(this._passParameters,null!=this.backgroundColor),this._composition.copyFBOToTexture(this._backgroundTexture),this._composition.unbind(),this._backgroundDirty=!1)}_useBackgroundTexture(e,t){let r=g.Immediate;(e.surface.view.layerViewManager.updating||t>0)&&(r=g.Delayed);const s=e.renderData;this._backgroundTexture&&null==s.textureReference&&(r=g.Immediate),s.setTextureReference(null!=this._backgroundTexture?new b(this._backgroundTexture,c.FADING,V,e.surface.baseOpacity,0,1):null,r)}_useLayerTexture(e,t,r,s){const o=t<r,a=o?1:e.surface.baseOpacity,i=o?e.surface.baseOpacity:1,n=S(e,t);return!!this._dataToTexture(n)&&(e.renderData.setTextureReference(new b(n.sourceLayerInfo.data,c.FADING,n,a,i,s)),!0)}_composeMapLayers(e,t,r,s,a,i,n,u,c,l,p){this._composition.ensureBuffer(n);const h=e.surface.baseOpacity;let d=!1,f=D.LINEAR_MIPMAP_LINEAR,T=!1,y=0;for(let b=r;b>=0;b--){const t=S(e,b);if(!t)continue;if(0===a[b]&&!p)continue;const r=b<s&&h<1&&!d;this._passParameters.baseOpacity=r?h:1;const g=this._passParameters.baseOpacity<1?P.Required:P.NotRequired;r&&(d=!0);let x=!1;l.forEach((e=>{e.start===b&&(H.push(e),this._composition.openGroup(n),x=!0)}));const k=0===y,w=x?E.GroupBackgroundComposite:c&&k?this.backgroundIsGrid?E.GridComposite:E.ColorComposite:E.Composite,I=A[i[b]];for(m(t)?(this._passParameters.opacity=a[b],T=this._composition.drawVectorData(this._passParameters,w,n,I,g,t,u,this.tileSize,T)):_(t)?(this._passParameters.opacity=a[b],this._composition.drawImageryTileData(this._passParameters,w,n,I,g,t),this._hasNearestInterpolation(t)&&(f=D.NEAREST)):this._dataToTexture(t)&&(this._passParameters.texture=t.sourceLayerInfo.data.texture,this._passParameters.offset=t.offset,this._passParameters.scale=t.scale,this._passParameters.opacity=a[b],this._composition.drawRasterData(this._passParameters,w,n,I,g));H.length>0&&H[H.length-1].end===b;){const e=H.pop();this._passParameters.opacity=e.opacity,this._passParameters.offset=o,this._passParameters.scale=1;const t=c&&k?this.backgroundIsGrid?E.GridComposite:E.ColorComposite:E.Composite;this._composition.drawGroup(this._passParameters,t,n,A[e.blendMode],g)}y++}const g=e.renderData,x=g.ensureTexture(n,(()=>this._buildTexture(n,f)));this._composition.copyFBOToTexture(x),this._composition.unbind(),g.setTextureReference(new b(x,t,V,d?1:h,0,1))}_hasNearestInterpolation(e){const t=e.sourceLayerInfo.data;return!!t.source&&"nearest"===t.interpolation}_dataToTexture(e){if(f(e)){const t=e.sourceLayerInfo;t.data=this._buildTexture(t.data),e.tile.setMemoryDirty()}return T(e)}setBackground(e){this._backgroundColor!==e&&(this._backgroundColor=e,this._backgroundDirty=!0)}_buildTexture(e,t=D.LINEAR_MIPMAP_LINEAR){if(null==e)return null;const r=new O;r.wrapMode=j.CLAMP_TO_EDGE,r.samplingMode=t,r.maxAnisotropy=this._maxAnisotropy,r.preMultiplyAlpha=!0,r.flipped=!0,r.hasMipmap=!0;const s=this._rctx;let o;if("number"==typeof e)r.width=r.height=e,o=new w(new L(s,r));else if(e instanceof n)r.isOpaque=e.isOpaque,o=new w(new L(s,r,e.image)),e.release();else try{r.width=e.width,r.height=e.height,o=new w(new L(s,r,e))}catch(i){o=new w(M(s)),console.warn("TileRenderer: failed to execute 'texImage2D', cross-origin image may not be loaded.")}const a=s.bindTexture(o.texture,L.TEXTURE_UNIT_FOR_UPDATES);return o.generateMipmap(),s.bindTexture(a,L.TEXTURE_UNIT_FOR_UPDATES),o}get test(){return{backgroundTexture:this._backgroundTexture}}}function S(e,t){X.layerIndex=t,X.vtlNeighborInfos.clear();const o=e.layerInfo[p.MAP][t];if(o.data)return r(X.offset,0,0),X.tile=e,X.scale=1,X.sourceLod=e.lij,X.sourceLayerInfo=o,m(X)&&e.forEachLoadedNeighbor(((r,s)=>{if(r.level!==e.level)return;const a=r.layerInfo[p.MAP][t];if(!y(a)||o.data===a.data)return;const i=X.vtlNeighborInfos.pushNew();i.offset=W[s],i.sourceLod=r.lij,i.sourceLayerInfo=a})),X;const a=o.upsampleInfo;if(a){const e=a.tile.layerInfo[p.MAP][t];return X.tile=a.tile,s(X.offset,a.offset),X.scale=a.scale,X.sourceLod=a.tile.lij,X.sourceLayerInfo=e,X}return null}function U(e){return e.uid}function B(e){let t="normal"!==e.blendMode;return i(e.parent)&&(t=B(e.parent)||t),t}function G(e,t){i(e.parent)&&G(e.parent,t);const r=U(e);if(null!=r&&""!==r){const s=z.get(r);s?s.start=t:z.set(r,new N(t,t,e.blendMode,e.opacity))}}const F=new Array,q=new Array,v=new Array,z=new Map,H=new Array,X=new k,V={offset:[0,0],scale:1},W=new Array;W[l.NORTH]=[0,-1],W[l.NORTH_EAST]=[-1,-1],W[l.EAST]=[-1,0],W[l.SOUTH_EAST]=[-1,1],W[l.SOUTH]=[0,1],W[l.SOUTH_WEST]=[1,1],W[l.WEST]=[1,0],W[l.NORTH_WEST]=[1,-1];export{N as GroupInfo,C as TileRenderer};
5
+ import{disposeMaybe as e,releaseMaybe as t}from"../../../core/maybe.js";import{s as r,j as s}from"../../../chunks/vec2.js";import{Z as o}from"../../../chunks/vec2f64.js";import{isBaseLayer as a,isGroupLayer as i}from"../../../layers/support/layerUtils.js";import{ImageWithType as n}from"../support/StreamDataLoader.js";import{BlendLayersPassParameters as u}from"./BlendLayersTechnique.js";import{TextureUpdate as c}from"./interfaces.js";import{NeighborIndex as l}from"./ITile.js";import{LayerClass as p}from"./LayerClass.js";import{isBlendableLayerView as h,isVectorTileLayerView as d,isVectorTileRenderInfo as m,isImageryTileRenderInfo as _,isRasterTileRenderInfo as f,isTextureTileRenderInfo as T,isVectorTilePerLayerInfo as y}from"./terrainUtils.js";import{ActivationTime as g}from"./TextureFader.js";import{TextureReference as b}from"./TextureReference.js";import{TileCompositor as x}from"./TileCompositor.js";import{TileRenderInfo as w}from"./TileRenderInfo.js";import I from"./TileTexture.js";import{TileUpdate as k}from"./TileUpdate.js";import{blendModeFromString as A}from"../webgl-engine/core/shaderLibrary/output/BlendOptions.js";import{BaseOpacityMode as P,BlendLayersOutput as R}from"../webgl-engine/core/shaderLibrary/terrain/TileBackground.glsl.js";import{createColorTexture as E,createEmptyTexture as M}from"../webgl-engine/lib/glUtil3D.js";import{TextureSamplingMode as D,TextureWrapMode as O,PixelFormat as j}from"../../webgl/enums.js";import{Texture as L}from"../../webgl/Texture.js";import{TextureDescriptor as N}from"../../webgl/TextureDescriptor.js";class C{constructor(e,t,r,s){this.start=e,this.end=t,this.blendMode=r,this.opacity=s}}class S{constructor(e,t,r){this._rctx=e,this.tileSize=t,this._techniqueRepository=r,this._passParameters=new u,this._backgroundTexture=null,this._backgroundColor=null,this._backgroundDirty=!1,this._maxAnisotropy=this._rctx.parameters.maxMaxAnisotropy,this._composition=new x(this._rctx,this._techniqueRepository),this._blackTex=new I(E(this._rctx,[0,0,0,1])),this._ensureBackgroundTexture(this.tileSize)}dispose(){this._composition=e(this._composition),this._backgroundTexture=t(this._backgroundTexture),this._blackTex=t(this._blackTex)}get backgroundIsGrid(){return null==this._backgroundColor}get backgroundColor(){return this._backgroundColor}updateTileTexture(e,t){if(!e.renderData)return;const r=e.surface,s=r.baseOpacity;let o=0,n=0,u=this.tileSize,c=!1;const l=r.view.state.contentPixelRatio;let m=!1;H.clear(),X.length=0;const _=e.layerInfo[p.MAP];let f=_.length,T=0,y=null;for(;T<_.length;T++){const t=r.layerViewByIndex(T,p.MAP),g=t.layer.opacity;q[T]=g;const b=t.fullOpacity;if(v[T]=b,a(t.layer)&&f>=_.length&&(f=T),h(t)){z[T]=t.layer.blendMode;let e="normal"!==t.layer.blendMode;if(i(t.layer.parent)){const r=B(t.layer.parent);null!=r&&""!==r&&(e=G(t.layer.parent)||e)}e&&(m=e,c=!1)}if(0===g&&!m){_[T].pendingUpdates&=~(k.TEXTURE_NOFADING&k.TEXTURE_FADING);continue}++n;const x=U(e,T);if(x){if(_[T].pendingUpdates&=~(k.TEXTURE_NOFADING&k.TEXTURE_FADING),i(t.layer.parent)){const e=B(t.layer.parent);null!=e&&""!==e&&F(t.layer.parent,T)}d(t)?u=Math.max(u,this.tileSize*l):1===s&&1===b&&(t.isOpaque||this._dataToTexture(x)&&x.sourceLayerInfo.data.descriptor.isOpaque)&&(c=!0),++o,null===y&&(y=T)}}const g=u/this.tileSize;0!==o&&null!==y?1===o&&!m&&this._useLayerTexture(e,y,f,v[y])||this._composeMapLayers(e,t,T-1,f,q,z,u,g,!c||m,H,m):this._useBackgroundTexture(e,n)}_ensureBackgroundTexture(e){return null==this._backgroundTexture&&(this._backgroundTexture=this._buildTexture(e,!1),this._backgroundDirty=!0),this._backgroundDirty&&(this._composition.bind(e),this._passParameters.offset=o,this._passParameters.scale=1,this._passParameters.opacity=1,null!=this.backgroundColor&&(this._passParameters.backgroundColor=this.backgroundColor),this._composition.drawBackground(this._passParameters,null!=this.backgroundColor),this._composition.copyFBOToTexture(this._backgroundTexture),this._composition.unbind(),this._backgroundDirty=!1),this._backgroundTexture}_useBackgroundTexture(e,t){const r=this._ensureBackgroundTexture(this.tileSize);let s=g.Immediate;(e.surface.view.layerViewManager.updating||t>0)&&(s=g.Delayed);const o=e.renderData;null==o.textureReference&&(s=g.Immediate),o.setTextureReference(new b(r,c.FADING,W,e.surface.baseOpacity,0,1),s)}_useLayerTexture(e,t,r,s){const o=t<r,a=o?1:e.surface.baseOpacity,i=o?e.surface.baseOpacity:1,n=U(e,t);return!!this._dataToTexture(n)&&(e.renderData.setTextureReference(new b(n.sourceLayerInfo.data,c.FADING,n,a,i,s)),!0)}_composeMapLayers(e,t,r,s,a,i,n,u,c,l,p){this._composition.ensureBuffer(n);const h=e.surface.baseOpacity;let d=!1,f=D.LINEAR_MIPMAP_LINEAR,T=!1,y=0;for(let b=r;b>=0;b--){const t=U(e,b);if(!t||0===a[b]&&!p)continue;const r=b<s&&h<1&&!d;r&&(d=!0),this._passParameters.baseOpacity=r?h:1;const g=this._passParameters.baseOpacity<1?P.Required:P.NotRequired;let x=!1;l.forEach((e=>{e.start===b&&(X.push(e),this._composition.openGroup(n),x=!0)}));const w=0===y,I=x?R.GroupBackgroundComposite:c&&w?this.backgroundIsGrid?R.GridComposite:R.ColorComposite:R.Composite,k=A[i[b]];for(m(t)?(this._passParameters.opacity=a[b],T=this._composition.drawVectorData(this._passParameters,I,n,k,g,t,u,this.tileSize,T)):_(t)?(this._passParameters.opacity=a[b],this._composition.drawImageryTileData(this._passParameters,I,n,k,g,t),this._hasNearestInterpolation(t)&&(f=D.NEAREST)):this._dataToTexture(t)&&(this._passParameters.texture=t.sourceLayerInfo.data.texture,this._passParameters.offset=t.offset,this._passParameters.scale=t.scale,this._passParameters.opacity=a[b],this._composition.drawRasterData(this._passParameters,I,n,k,g));X.length>0&&X[X.length-1].end===b;){const e=X.pop();this._passParameters.opacity=e.opacity,this._passParameters.offset=o,this._passParameters.scale=1;const t=c&&w?this.backgroundIsGrid?R.GridComposite:R.ColorComposite:R.Composite;this._composition.drawGroup(this._passParameters,t,n,A[e.blendMode],g)}y++}const g=e.renderData,x=p||d&&h<1,w=g.ensureTexture(n,x,(()=>this._buildTexture(n,x,f)));this._composition.copyFBOToTexture(w),this._composition.unbind(),g.setTextureReference(new b(w,t,W,d?1:h,0,1))}_hasNearestInterpolation(e){const t=e.sourceLayerInfo.data;return!!t.source&&"nearest"===t.interpolation}_dataToTexture(e){if(f(e)){const t=e.sourceLayerInfo;t.data=this._buildTexture(t.data,!0),e.tile.setMemoryDirty()}return T(e)}setBackground(e){this._backgroundColor!==e&&(this._backgroundColor=e,this._backgroundDirty=!0)}_buildTexture(e,t,r=D.LINEAR_MIPMAP_LINEAR){if(null==e)return null;const s=new N;s.wrapMode=O.CLAMP_TO_EDGE,s.samplingMode=r,s.maxAnisotropy=this._maxAnisotropy,s.preMultiplyAlpha=!0,s.flipped=!0,s.hasMipmap=!0,t||(s.pixelFormat=j.RGB);const o=this._rctx;let a;if("number"==typeof e)s.width=s.height=e,a=new I(new L(o,s));else if(e instanceof n)s.isOpaque=e.isOpaque,s.isOpaque&&(s.pixelFormat=j.RGB),a=new I(new L(o,s,e.image)),e.release();else try{s.width=e.width,s.height=e.height,a=new I(new L(o,s,e))}catch(u){a=new I(M(o)),console.warn("TileRenderer: failed to execute 'texImage2D', cross-origin image may not be loaded.")}const i=o.bindTexture(a.texture,L.TEXTURE_UNIT_FOR_UPDATES);return a.generateMipmap(),o.bindTexture(i,L.TEXTURE_UNIT_FOR_UPDATES),a}get test(){return{backgroundTexture:this._backgroundTexture}}}function U(e,t){V.layerIndex=t,V.vtlNeighborInfos.clear();const o=e.layerInfo[p.MAP][t];if(o.data)return r(V.offset,0,0),V.tile=e,V.scale=1,V.sourceLod=e.lij,V.sourceLayerInfo=o,m(V)&&e.forEachLoadedNeighbor(((r,s)=>{if(r.level!==e.level)return;const a=r.layerInfo[p.MAP][t];if(!y(a)||o.data===a.data)return;const i=V.vtlNeighborInfos.pushNew();i.offset=Z[s],i.sourceLod=r.lij,i.sourceLayerInfo=a})),V;const a=o.upsampleInfo;if(a){const e=a.tile.layerInfo[p.MAP][t];return V.tile=a.tile,s(V.offset,a.offset),V.scale=a.scale,V.sourceLod=a.tile.lij,V.sourceLayerInfo=e,V}return null}function B(e){return e.uid}function G(e){let t="normal"!==e.blendMode;return i(e.parent)&&(t=G(e.parent)||t),t}function F(e,t){i(e.parent)&&F(e.parent,t);const r=B(e);if(null!=r&&""!==r){const s=H.get(r);s?s.start=t:H.set(r,new C(t,t,e.blendMode,e.opacity))}}const q=new Array,v=new Array,z=new Array,H=new Map,X=new Array,V=new w,W={offset:[0,0],scale:1},Z=new Array;Z[l.NORTH]=[0,-1],Z[l.NORTH_EAST]=[-1,-1],Z[l.EAST]=[-1,0],Z[l.SOUTH_EAST]=[-1,1],Z[l.SOUTH]=[0,1],Z[l.SOUTH_WEST]=[1,1],Z[l.WEST]=[1,0],Z[l.NORTH_WEST]=[1,-1];export{C as GroupInfo,S as TileRenderer};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import{f as s,t as e,e as t}from"../../../../../chunks/mat3.js";import{c as a}from"../../../../../chunks/mat3f64.js";import{c as r}from"../../../../../chunks/mat4.js";import{s as i,c as h}from"../../../../../chunks/vec3.js";import{c as o}from"../../../../../chunks/vec3f64.js";import{MaterialPassParameters as n,ShadowMapPassParameters as m,HighlightPassParameters as l,RenderPassIdentifier as c}from"./AllRenderPasses.js";import{RenderPass as p,RenderPassSorting as u}from"./RenderPass.js";import{ShaderOutput as d}from"../shaderLibrary/ShaderOutput.js";import{TwoVectorPosition as g}from"../util/TwoVectorPosition.js";import{union as _}from"../../lib/depthRange.js";import{RenderSlot as P}from"../../lib/RenderSlot.js";class w{constructor(s,e){this.rctx=s,this.shaderTechniqueRepository=e,this.canRender=!0,this._materialPassParameters=new n,this._shadowPassParameters=new m,this._highlightPassParameters=new l,this._systems=new Set,this._passes={materialOpaque:new p(s,e),materialTransparent:new p(s,e,u.BackToFront),materialIntegratedMesh:new p(s,e),shadowMap:new p(s,e),highlight:new p(s,e),highlightIntegratedMesh:new p(s,e),highlightShadowMap:new p(s,e),defaultShadowMap:new p(s,e)}}destroy(){this._context=null,this._systems.clear()}register(s){this._systems.add(s)}prepareRender(s){if(0!==this._systems.size){for(const s of Object.values(this._passes))s.prepareSubmit();this._systems.forEach((e=>e.submit(this._passes,s.bindParameters)));for(const s of Object.values(this._passes))s.finishSubmit();this.shaderTechniqueRepository.frameUpdate()}}prepareTechniques(s){return 0===this._systems.size?null:(this._configure(s),this._materialPassParameters.output=s.output,this._invoke(s,((e,t)=>e.prepare(t,s.bindParameters))))}render(s,e){this._invoke(s,((t,a)=>t.dispatch(a,s.bindParameters,e)))}_invoke(s,e){switch(s.bindParameters.slot){case P.OPAQUE_MATERIAL:switch(s.output){case d.Color:case d.Depth:case d.Normal:case d.ObjectAndLayerIdColor:return e(this._passes.materialOpaque,this._materialPassParameters);case d.Highlight:return e(this._passes.highlight,this._highlightPassParameters);case d.Shadow:return e(this._passes.shadowMap,this._shadowPassParameters);case d.ShadowHighlight:return e(this._passes.highlightShadowMap,this._shadowPassParameters);case d.ShadowExcludeHighlight:return e(this._passes.defaultShadowMap,this._shadowPassParameters)}break;case P.TRANSPARENT_MATERIAL:switch(s.output){case d.Color:case d.Alpha:case d.Depth:case d.Normal:case d.ObjectAndLayerIdColor:return e(this._passes.materialTransparent,this._materialPassParameters)}break;case P.INTEGRATED_MESH:switch(s.output){case d.Color:case d.Depth:case d.Normal:case d.ObjectAndLayerIdColor:return e(this._passes.materialIntegratedMesh,this._materialPassParameters);case d.Highlight:return e(this._passes.highlightIntegratedMesh,this._highlightPassParameters)}}return null}notifyDirty(){this._context.requestRender()}get renderSlots(){return[P.OPAQUE_MATERIAL,P.TRANSPARENT_MATERIAL,P.INTEGRATED_MESH]}initializeRenderContext(s){this._context=s}uninitializeRenderContext(){}queryDepthRange(s){const e={near:1/0,far:-1/0};return this._systems.forEach((t=>{const a=t.queryShadowCasterDepthRange(s);null!=a&&_(e,a,e)})),e}_configure(s){const e=s.output===d.Shadow||s.output===d.ShadowHighlight||s.output===d.ShadowExcludeHighlight?this._shadowPassParameters:s.output===d.Highlight?this._highlightPassParameters:this._materialPassParameters;this._updateParameters(s,e)}_updateParameters(a,o){const n=a.bindParameters.camera,m=n.viewInverseTransposeMatrix;i(f,m[3],m[7],m[11]),T.set(f),h(o.transformWorldFromViewTH,T.high),h(o.transformWorldFromViewTL,T.low),h(o.slicePlaneLocalOrigin,f),s(o.transformViewFromCameraRelativeRS,n.viewMatrix),r(o.transformProjFromView,n.projectionMatrix),o.identifier===c.Material&&(this._materialPassParameters.transparent=a.bindParameters.slot===P.TRANSPARENT_MATERIAL,this._materialPassParameters.integratedMesh=a.bindParameters.slot===P.INTEGRATED_MESH,e(R,o.transformViewFromCameraRelativeRS),t(o.transformNormalViewFromGlobal,R))}get needsHighlight(){return this._passes.highlight.count>0||this._passes.highlightIntegratedMesh.count>0}get needsTransparentPass(){return this._passes.materialTransparent.count>0}}const f=o(),R=a(),T=new g;export{w as RenderPassManager};
5
+ import{f as s,t as e,e as t}from"../../../../../chunks/mat3.js";import{c as a}from"../../../../../chunks/mat3f64.js";import{c as r}from"../../../../../chunks/mat4.js";import{s as i,c as h}from"../../../../../chunks/vec3.js";import{c as o}from"../../../../../chunks/vec3f64.js";import{MaterialPassParameters as n,ShadowMapPassParameters as m,HighlightPassParameters as l,RenderPassIdentifier as c}from"./AllRenderPasses.js";import{RenderPass as p,RenderPassSorting as u}from"./RenderPass.js";import{ShaderOutput as d}from"../shaderLibrary/ShaderOutput.js";import{TwoVectorPosition as _}from"../util/TwoVectorPosition.js";import{union as g}from"../../lib/depthRange.js";import{RenderSlot as P}from"../../lib/RenderSlot.js";class w{constructor(s,e){this.rctx=s,this.shaderTechniqueRepository=e,this._materialPassParameters=new n,this._shadowPassParameters=new m,this._highlightPassParameters=new l,this._systems=new Set,this._passes={materialOpaque:new p(s,e),materialTransparent:new p(s,e,u.BackToFront),materialIntegratedMesh:new p(s,e),shadowMap:new p(s,e),highlight:new p(s,e),highlightIntegratedMesh:new p(s,e),highlightShadowMap:new p(s,e),defaultShadowMap:new p(s,e)}}destroy(){this._context=null,this._systems.clear()}register(s){this._systems.add(s)}canRender(s){return s!==P.TRANSPARENT_MATERIAL||this._passes.materialTransparent.count>0}requiresOutput(s){return s===d.Highlight&&(this._passes.highlight.count>0||this._passes.highlightIntegratedMesh.count>0)}prepareRender(s){if(0!==this._systems.size){for(const s of Object.values(this._passes))s.prepareSubmit();this._systems.forEach((e=>e.submit(this._passes,s.bindParameters)));for(const s of Object.values(this._passes))s.finishSubmit();this.shaderTechniqueRepository.frameUpdate()}}prepareTechniques(s){return 0===this._systems.size?null:(this._configure(s),this._materialPassParameters.output=s.output,this._invoke(s,((e,t)=>e.prepare(t,s.bindParameters))))}render(s,e){this._invoke(s,((t,a)=>t.dispatch(a,s.bindParameters,e)))}_invoke(s,e){switch(s.bindParameters.slot){case P.OPAQUE_MATERIAL:switch(s.output){case d.Color:case d.Depth:case d.Normal:case d.ObjectAndLayerIdColor:return e(this._passes.materialOpaque,this._materialPassParameters);case d.Highlight:return e(this._passes.highlight,this._highlightPassParameters);case d.Shadow:return e(this._passes.shadowMap,this._shadowPassParameters);case d.ShadowHighlight:return e(this._passes.highlightShadowMap,this._shadowPassParameters);case d.ShadowExcludeHighlight:return e(this._passes.defaultShadowMap,this._shadowPassParameters)}break;case P.TRANSPARENT_MATERIAL:switch(s.output){case d.Color:case d.Alpha:case d.Depth:case d.Normal:case d.ObjectAndLayerIdColor:return e(this._passes.materialTransparent,this._materialPassParameters)}break;case P.INTEGRATED_MESH:switch(s.output){case d.Color:case d.Depth:case d.Normal:case d.ObjectAndLayerIdColor:return e(this._passes.materialIntegratedMesh,this._materialPassParameters);case d.Highlight:return e(this._passes.highlightIntegratedMesh,this._highlightPassParameters)}}return null}notifyDirty(){this._context.requestRender()}get renderSlots(){return[P.OPAQUE_MATERIAL,P.TRANSPARENT_MATERIAL,P.INTEGRATED_MESH]}initializeRenderContext(s){this._context=s}uninitializeRenderContext(){}queryDepthRange(s){const e={near:1/0,far:-1/0};return this._systems.forEach((t=>{const a=t.queryShadowCasterDepthRange(s);null!=a&&g(e,a,e)})),e}_configure(s){const e=s.output===d.Shadow||s.output===d.ShadowHighlight||s.output===d.ShadowExcludeHighlight?this._shadowPassParameters:s.output===d.Highlight?this._highlightPassParameters:this._materialPassParameters;this._updateParameters(s,e)}_updateParameters(a,o){const n=a.bindParameters.camera,m=n.viewInverseTransposeMatrix;i(f,m[3],m[7],m[11]),T.set(f),h(o.transformWorldFromViewTH,T.high),h(o.transformWorldFromViewTL,T.low),h(o.slicePlaneLocalOrigin,f),s(o.transformViewFromCameraRelativeRS,n.viewMatrix),r(o.transformProjFromView,n.projectionMatrix),o.identifier===c.Material&&(this._materialPassParameters.transparent=a.bindParameters.slot===P.TRANSPARENT_MATERIAL,this._materialPassParameters.integratedMesh=a.bindParameters.slot===P.INTEGRATED_MESH,e(R,o.transformViewFromCameraRelativeRS),t(o.transformNormalViewFromGlobal,R))}}const f=o(),R=a(),T=new _;export{w as RenderPassManager};
@@ -2,27 +2,27 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import{RgbaFloatEncoding as e}from"../util/RgbaFloatEncoding.glsl.js";import{addCameraPosition as t,addPixelRatio as i}from"../util/View.glsl.js";import{Float4PassUniform as o}from"../../shaderModules/Float4PassUniform.js";import{FloatPassUniform as r}from"../../shaderModules/FloatPassUniform.js";import{glsl as l}from"../../shaderModules/interfaces.js";import{Texture2DPassUniform as a}from"../../shaderModules/Texture2DPassUniform.js";import{STIPPLE_TEXTURE_PADDING as p,computeLongestPattern as s,computeTextureSize as n}from"../../../materials/stippleTextureRepository.js";import{ensureColor4 as d}from"../../../shaders/ensureColor4.js";function c(e,t){e.constants.add("stippleAlphaColorDiscard","float",.001),e.constants.add("stippleAlphaHighlightDiscard","float",.5),t.stippleEnabled?f(e,t):u(e)}function f(s,n){const c=!(n.draped&&n.stipplePreferContinuous),{vertex:f,fragment:u}=s;u.include(e),n.draped||(t(f,n),f.uniforms.add(new r("worldToScreenPerDistanceRatio",((e,t)=>1/t.camera.perScreenPixelRatio))),f.code.add(l`float computeWorldToScreenRatio(vec3 segmentCenter) {
5
+ import{RgbaFloatEncoding as e}from"../util/RgbaFloatEncoding.glsl.js";import{addCameraPosition as t,addPixelRatio as i}from"../util/View.glsl.js";import{Float4PassUniform as o}from"../../shaderModules/Float4PassUniform.js";import{FloatPassUniform as r}from"../../shaderModules/FloatPassUniform.js";import{glsl as l}from"../../shaderModules/interfaces.js";import{Texture2DPassUniform as a}from"../../shaderModules/Texture2DPassUniform.js";import{computeLongestPattern as p,computeTextureSize as s}from"../../../materials/stippleTextureRepository.js";import{ensureColor4 as n}from"../../../shaders/ensureColor4.js";function d(e,t){e.constants.add("stippleAlphaColorDiscard","float",.001),e.constants.add("stippleAlphaHighlightDiscard","float",.5),t.stippleEnabled?c(e,t):f(e)}function c(p,s){const d=!(s.draped&&s.stipplePreferContinuous),{vertex:c,fragment:f}=p;f.include(e),s.draped||(t(c,s),c.uniforms.add(new r("worldToScreenPerDistanceRatio",((e,t)=>1/t.camera.perScreenPixelRatio))),c.code.add(l`float computeWorldToScreenRatio(vec3 segmentCenter) {
6
6
  float segmentDistanceToCamera = length(segmentCenter - cameraPosition);
7
7
  return worldToScreenPerDistanceRatio / segmentDistanceToCamera;
8
- }`)),s.varyings.add("vStippleDistance","float"),n.stippleRequiresClamp&&s.varyings.add("vStippleDistanceLimits","vec2"),n.stippleRequiresStretchMeasure&&s.varyings.add("vStipplePatternStretch","float"),f.code.add(l`
8
+ }`)),p.varyings.add("vStippleDistance","float"),s.stippleRequiresClamp&&p.varyings.add("vStippleDistanceLimits","vec2"),s.stippleRequiresStretchMeasure&&p.varyings.add("vStipplePatternStretch","float"),c.code.add(l`
9
9
  float discretizeWorldToScreenRatio(float worldToScreenRatio) {
10
- float step = ${h};
10
+ float step = ${u};
11
11
 
12
12
  float discreteWorldToScreenRatio = log(worldToScreenRatio);
13
13
  discreteWorldToScreenRatio = ceil(discreteWorldToScreenRatio / step) * step;
14
14
  discreteWorldToScreenRatio = exp(discreteWorldToScreenRatio);
15
15
  return discreteWorldToScreenRatio;
16
16
  }
17
- `),f.code.add(l`vec2 computeStippleDistanceLimits(float startPseudoScreen, float segmentLengthPseudoScreen, float segmentLengthScreen, float patternLength) {`),f.code.add(l`
18
- if (segmentLengthPseudoScreen >= ${c?"patternLength":"1e4"}) {
19
- `),i(f),f.code.add(l`
17
+ `),c.code.add(l`vec2 computeStippleDistanceLimits(float startPseudoScreen, float segmentLengthPseudoScreen, float segmentLengthScreen, float patternLength) {`),c.code.add(l`
18
+ if (segmentLengthPseudoScreen >= ${d?"patternLength":"1e4"}) {
19
+ `),i(c),c.code.add(l`
20
20
  // Round the screen length to get an integer number of pattern repetitions (minimum 1).
21
21
  float repetitions = segmentLengthScreen / (patternLength * pixelRatio);
22
22
  float flooredRepetitions = max(1.0, floor(repetitions + 0.5));
23
23
  float segmentLengthScreenRounded = flooredRepetitions * patternLength;
24
24
 
25
- ${n.stippleRequiresStretchMeasure?l`
25
+ ${s.stippleRequiresStretchMeasure?l`
26
26
  float stretch = repetitions / flooredRepetitions;
27
27
 
28
28
  // We need to impose a lower bound on the stretch factor to prevent the dots from merging together when there is only 1 repetition.
@@ -33,13 +33,9 @@ return worldToScreenPerDistanceRatio / segmentDistanceToCamera;
33
33
  }
34
34
  return vec2(startPseudoScreen, startPseudoScreen + segmentLengthPseudoScreen);
35
35
  }
36
- `),u.constants.add("stippleTexturePadding","float",p),u.uniforms.add(new a("stipplePatternTexture",(e=>e.stippleTexture)),new r("stipplePatternSDFNormalizer",(e=>S(e.stipplePattern))),new r("stipplePatternPixelSizeInv",(e=>1/m(e)))),u.code.add(l`float padStippleTexture(float u) {
37
- float paddedTextureSize = float(textureSize(stipplePatternTexture, 0).x);
38
- float unpaddedTextureSize = paddedTextureSize - stippleTexturePadding;
39
- return (u * unpaddedTextureSize + stippleTexturePadding * 0.5) / paddedTextureSize;
40
- }`),u.code.add(l`
36
+ `),f.uniforms.add(new a("stipplePatternTexture",(e=>e.stippleTexture)),new r("stipplePatternSDFNormalizer",(e=>m(e.stipplePattern))),new r("stipplePatternPixelSizeInv",(e=>1/S(e)))),f.code.add(l`
41
37
  float getStippleSDF(out bool isClamped) {
42
- ${n.stippleRequiresClamp?l`
38
+ ${s.stippleRequiresClamp?l`
43
39
  float stippleDistanceClamped = clamp(vStippleDistance, vStippleDistanceLimits.x, vStippleDistanceLimits.y);
44
40
  vec2 aaCorrectedLimits = vStippleDistanceLimits + vec2(1.0, -1.0) / gl_FragCoord.w;
45
41
  isClamped = vStippleDistance < aaCorrectedLimits.x || vStippleDistance > aaCorrectedLimits.y;`:l`
@@ -47,13 +43,13 @@ return (u * unpaddedTextureSize + stippleTexturePadding * 0.5) / paddedTextureSi
47
43
  isClamped = false;`}
48
44
 
49
45
  float u = stippleDistanceClamped * gl_FragCoord.w * stipplePatternPixelSizeInv;
50
- ${n.stippleScaleWithLineWidth?l`u *= vLineSizeInv;`:""}
51
- u = padStippleTexture(fract(u));
46
+ ${s.stippleScaleWithLineWidth?l`u *= vLineSizeInv;`:""}
47
+ u = fract(u);
52
48
 
53
49
  float encodedSDF = rgba2float(texture(stipplePatternTexture, vec2(u, 0.5)));
54
50
  float sdf = (encodedSDF * 2.0 - 1.0) * stipplePatternSDFNormalizer;
55
51
 
56
- ${n.stippleRequiresStretchMeasure?l`return (sdf - 0.5) * vStipplePatternStretch + 0.5;`:l`return sdf;`}
52
+ ${s.stippleRequiresStretchMeasure?l`return (sdf - 0.5) * vStipplePatternStretch + 0.5;`:l`return sdf;`}
57
53
  }
58
54
 
59
55
  float getStippleSDF() {
@@ -65,12 +61,12 @@ return (u * unpaddedTextureSize + stippleTexturePadding * 0.5) / paddedTextureSi
65
61
  bool isClamped;
66
62
  float stippleSDF = getStippleSDF(isClamped);
67
63
 
68
- float antiAliasedResult = ${n.stippleScaleWithLineWidth?l`clamp(stippleSDF * vLineWidth + 0.5, 0.0, 1.0);`:l`clamp(stippleSDF + 0.5, 0.0, 1.0);`}
64
+ float antiAliasedResult = ${s.stippleScaleWithLineWidth?l`clamp(stippleSDF * vLineWidth + 0.5, 0.0, 1.0);`:l`clamp(stippleSDF + 0.5, 0.0, 1.0);`}
69
65
 
70
66
  return isClamped ? floor(antiAliasedResult + 0.5) : antiAliasedResult;
71
67
  }
72
- `),n.stippleOffColorEnabled?(u.uniforms.add(new o("stippleOffColor",(e=>d(e.stippleOffColor)))),u.code.add(l`#define discardByStippleAlpha(stippleAlpha, threshold) {}
73
- #define blendStipple(color, stippleAlpha) mix(color, stippleOffColor, stippleAlpha)`)):u.code.add(l`#define discardByStippleAlpha(stippleAlpha, threshold) if (stippleAlpha < threshold) { discard; }
74
- #define blendStipple(color, stippleAlpha) vec4(color.rgb, color.a * stippleAlpha)`)}function u(e){e.fragment.code.add(l`float getStippleAlpha() { return 1.0; }
68
+ `),s.stippleOffColorEnabled?(f.uniforms.add(new o("stippleOffColor",(e=>n(e.stippleOffColor)))),f.code.add(l`#define discardByStippleAlpha(stippleAlpha, threshold) {}
69
+ #define blendStipple(color, stippleAlpha) mix(color, stippleOffColor, stippleAlpha)`)):f.code.add(l`#define discardByStippleAlpha(stippleAlpha, threshold) if (stippleAlpha < threshold) { discard; }
70
+ #define blendStipple(color, stippleAlpha) vec4(color.rgb, color.a * stippleAlpha)`)}function f(e){e.fragment.code.add(l`float getStippleAlpha() { return 1.0; }
75
71
  #define discardByStippleAlpha(_stippleAlpha_, _threshold_) {}
76
- #define blendStipple(color, _stippleAlpha_) color`)}function S(e){return e?(Math.floor(.5*(s(e)-1))+.5)/e.pixelRatio:1}function m(e){const t=e.stipplePattern;return t?n(e.stipplePattern)/t.pixelRatio:1}const h=l.float(.4);export{c as LineStipple,m as computePixelSize};
72
+ #define blendStipple(color, _stippleAlpha_) color`)}function m(e){return e?(Math.floor(.5*(p(e)-1))+.5)/e.pixelRatio:1}function S(e){const t=e.stipplePattern;return t?s(e.stipplePattern)/t.pixelRatio:1}const u=l.float(.4);export{d as LineStipple,S as computePixelSize};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../../../core/Logger.js";import{disposeMaybe as t}from"../../../../core/maybe.js";import{NestedMap as r}from"../../../../core/NestedMap.js";import{assert as i}from"./Util.js";class s{constructor(e,t,i,s){this._textureRepository=e,this._techniqueRepository=t,this.materialChanged=i,this.requestRender=s,this._id2glMaterialRef=new r}dispose(){this._textureRepository.destroy()}acquire(e,t,r){if(this._ownMaterial(e),!e.requiresSlot(t,r))return null;let i=this._id2glMaterialRef.get(r,e.id);if(null==i){const t=e.createGLMaterial({material:e,techniqueRep:this._techniqueRepository,textureRep:this._textureRepository,output:r});i=new o(t),this._id2glMaterialRef.set(r,e.id,i)}return i.ref(),i.glMaterial}release(e,r){const i=this._id2glMaterialRef.get(r,e.id);null!=i&&(i.unref(),i.referenced||(t(i.glMaterial),this._id2glMaterialRef.delete(r,e.id)))}_ownMaterial(t){null!=t.repository&&t.repository!==this&&e.getLogger("esri.views.3d.webgl-engine.lib.GLMaterialRepository").error("Material is already owned by a different material repository"),t.repository=this}}class o{constructor(e){this.glMaterial=e,this._refCnt=0}ref(){++this._refCnt}unref(){--this._refCnt,i(this._refCnt>=0)}get referenced(){return this._refCnt>0}}export{s as GLMaterialRepository};
5
+ import e from"../../../../core/Logger.js";import{disposeMaybe as t}from"../../../../core/maybe.js";import{NestedMap as r}from"../../../../core/NestedMap.js";import{assert as i}from"./Util.js";class s{constructor(e,t,i,s){this._textureRepository=e,this._techniqueRepository=t,this.materialChanged=i,this.requestRender=s,this._id2glMaterialRef=new r}dispose(){this._textureRepository.destroy()}acquire(e,t,r){if(this._ownMaterial(e),!e.canRender(t,r))return null;let i=this._id2glMaterialRef.get(r,e.id);if(null==i){const t=e.createGLMaterial({material:e,techniqueRep:this._techniqueRepository,textureRep:this._textureRepository,output:r});i=new o(t),this._id2glMaterialRef.set(r,e.id,i)}return i.ref(),i.glMaterial}release(e,r){const i=this._id2glMaterialRef.get(r,e.id);null!=i&&(i.unref(),i.referenced||(t(i.glMaterial),this._id2glMaterialRef.delete(r,e.id)))}_ownMaterial(t){null!=t.repository&&t.repository!==this&&e.getLogger("esri.views.3d.webgl-engine.lib.GLMaterialRepository").error("Material is already owned by a different material repository"),t.repository=this}}class o{constructor(e){this.glMaterial=e,this._refCnt=0}ref(){++this._refCnt}unref(){--this._refCnt,i(this._refCnt>=0)}get referenced(){return this._refCnt>0}}export{s as GLMaterialRepository};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import{ResourceState as t}from"./basicInterfaces.js";class r{constructor(t,r){this._material=t,this._repository=r,this._map=new Map}destroy(){this._map.forEach(((t,r)=>{null!=t&&this._repository.release(this._material,r)}))}load(r,s,e){if(!this._material.requiresSlot(s,e))return null;this._map.has(e)||this._map.set(e,this._repository.acquire(this._material,s,e));const i=this._map.get(e);if(null!=i){if(i.ensureResources(r)===t.LOADED)return i;this._repository.requestRender()}return null}}export{r as GLMaterials};
5
+ import{ResourceState as t}from"./basicInterfaces.js";class r{constructor(t,r){this._material=t,this._repository=r,this._map=new Map}destroy(){this._map.forEach(((t,r)=>{null!=t&&this._repository.release(this._material,r)}))}load(r,e,s){if(!this._material.canRender(e,s))return null;this._map.has(s)||this._map.set(s,this._repository.acquire(this._material,e,s));const i=this._map.get(s);if(null!=i){if(i.ensureResources(r)===t.LOADED)return i;this._repository.requestRender()}return null}}export{r as GLMaterials};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../../chunks/tslib.es6.js";import r from"../../../../core/Accessor.js";import t from"../../../../core/PooledArray.js";import{isPromiseLike as n,createAbortError as s}from"../../../../core/promiseUtils.js";import{property as o}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/accessorSupport/ensureType.js";import"../../../../core/arrayUtils.js";import"../../../../core/has.js";import{subclass as i}from"../../../../core/accessorSupport/decorators/subclass.js";import{Decorations as a}from"./basicInterfaces.js";import{union as d}from"./depthRange.js";import{RenderOccludedFlag as l}from"./Material.js";import{RenderSlot as u}from"./RenderSlot.js";let c=class extends r{constructor(e){super({}),this._context=e,this._renderPlugins=new t,this._slots=new Array;for(let r=0;r<u.MAX_SLOTS;++r)this._slots[r]=[]}normalizeCtorArgs(){return{}}add(e,r){const t=()=>{if(r?.aborted)throw e.uninitializeRenderContext(),s();this._renderPlugins.push(e);for(const r of e.renderSlots)this._slots[r].push(e);this._context.requestRender(),this.notifyChange("updating")},o=e.initializeRenderContext(this._context,r);if(n(o))return o.then(t);t()}remove(e){if(null!=this._renderPlugins.removeUnordered(e)){for(let r=0;r<this._slots.length;++r)this._slots[r]=this._slots[r].filter((r=>r!==e));e.uninitializeRenderContext(),this._context.requestRender(),this.notifyChange("updating")}}prepareRender(){this._renderPlugins.forAll((e=>{e.prepareRender&&e.prepareRender(this._context.renderContext)}))}updateAnimation(e){let r=!1;return this._renderPlugins.forAll((t=>{t.updateAnimation&&(r=t.updateAnimation(e)||r)})),r}renderFeatureChanged(){this._renderPlugins.forAll((e=>{e.renderFeatureChanged&&e.renderFeatureChanged()}))}prepareSlots(e){for(const r of e)this._context.renderContext.bindParameters.slot=r,this._slots[r].filter((e=>{e.canRender&&(h(e)&&e.prepareTechnique(this._context.renderContext),p(e)&&e.prepareTechniques(this._context.renderContext))}))}prepare(e){this._context.renderContext.bindParameters.slot=e;const r=this._slots[e],t=new Map;return r.forEach((e=>{if(e.canRender&&(!e.isDecoration||this._context.renderContext.bindParameters.decorations!==a.OFF))if(h(e)){const r=e.prepareTechnique(this._context.renderContext);null!=r&&t.set(e,r)}else if(p(e)){const r=e.prepareTechniques(this._context.renderContext);null!=r&&t.set(e,r)}else t.set(e,null)})),t}render(e){e.forEach(((e,r)=>r.render(this._context.renderContext,e)))}queryDepthRange(e){const r=g;return r.near=1/0,r.far=-1/0,this._renderPlugins.forAll((t=>{if(t.queryDepthRange){const n=t.queryDepthRange(e);n&&d(r,n,r)}})),r}get updating(){return this._renderPlugins.some((e=>e.running))}canRender(e){return this._slots[e].some((e=>e.canRender))}get needsTransparentPass(){return this._renderPlugins.some((e=>e.needsTransparentPass))}get needsHighlight(){return this._renderPlugins.some((e=>e.needsHighlight))}get hasDecorations(){return this._renderPlugins.some((e=>e.isDecoration))}get needsLinearDepth(){return this._renderPlugins.some((e=>e.needsLinearDepth))}get needsLaserlineWithContrastControl(){const e=this._slots[u.LASERLINES_CONTRAST_CONTROL];return!!e&&e.length>0}get renderOccludedFlags(){return this._renderPlugins.reduce(((e,r)=>e|r.renderOccludedFlags),l.None)}get usedMemory(){return this._renderPlugins.reduce(((e,r)=>e+(r.usedMemory??0)),0)}};function h(e){return"prepareTechnique"in e}function p(e){return"prepareTechniques"in e}e([o({readOnly:!0})],c.prototype,"updating",null),c=e([i("esri.views.3d.webgl-engine.lib.RenderPluginManager")],c);const g={near:0,far:0};export{c as RenderPluginManager};
5
+ import{_ as e}from"../../../../chunks/tslib.es6.js";import r from"../../../../core/Accessor.js";import t from"../../../../core/PooledArray.js";import{isPromiseLike as n,createAbortError as s}from"../../../../core/promiseUtils.js";import{property as o}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/accessorSupport/ensureType.js";import"../../../../core/arrayUtils.js";import"../../../../core/has.js";import{subclass as i}from"../../../../core/accessorSupport/decorators/subclass.js";import{Decorations as a}from"./basicInterfaces.js";import{union as u}from"./depthRange.js";import{RenderOccludedFlag as d}from"./Material.js";import{RenderSlot as l}from"./RenderSlot.js";let c=class extends r{constructor(e){super({}),this._context=e,this._renderPlugins=new t,this._slots=new Array;for(let r=0;r<l.MAX_SLOTS;++r)this._slots[r]=[]}normalizeCtorArgs(){return{}}add(e,r){const t=()=>{if(r?.aborted)throw e.uninitializeRenderContext(),s();this._renderPlugins.push(e);for(const r of e.renderSlots)this._slots[r].push(e);this._context.requestRender(),this.notifyChange("updating")},o=e.initializeRenderContext(this._context,r);if(n(o))return o.then(t);t()}remove(e){if(null!=this._renderPlugins.removeUnordered(e)){for(let r=0;r<this._slots.length;++r)this._slots[r]=this._slots[r].filter((r=>r!==e));e.uninitializeRenderContext(),this._context.requestRender(),this.notifyChange("updating")}}prepareRender(){this._renderPlugins.forAll((e=>{e.prepareRender&&e.prepareRender(this._context.renderContext)}))}updateAnimation(e){let r=!1;return this._renderPlugins.forAll((t=>{t.updateAnimation&&(r=t.updateAnimation(e)||r)})),r}renderFeatureChanged(){this._renderPlugins.forAll((e=>{e.renderFeatureChanged&&e.renderFeatureChanged()}))}prepareSlots(e){for(const r of e)this._context.renderContext.bindParameters.slot=r,this._slots[r].filter((e=>{e.canRender(r)&&(p(e)&&e.prepareTechnique(this._context.renderContext),h(e)&&e.prepareTechniques(this._context.renderContext))}))}prepare(e){this._context.renderContext.bindParameters.slot=e;const r=this._slots[e],t=new Map;return r.forEach((r=>{if(r.canRender(e)&&(!r.isDecoration||this._context.renderContext.bindParameters.decorations!==a.OFF))if(p(r)){const e=r.prepareTechnique(this._context.renderContext);null!=e&&t.set(r,e)}else if(h(r)){const e=r.prepareTechniques(this._context.renderContext);null!=e&&t.set(r,e)}else t.set(r,null)})),t}render(e){e.forEach(((e,r)=>r.render(this._context.renderContext,e)))}queryDepthRange(e){const r=g;return r.near=1/0,r.far=-1/0,this._renderPlugins.forAll((t=>{if(t.queryDepthRange){const n=t.queryDepthRange(e);n&&u(r,n,r)}})),r}get updating(){return this._renderPlugins.some((e=>e.running))}canRender(e){return this._slots[e].some((r=>r.canRender(e)))}requiresOutput(e){return this._renderPlugins.some((r=>r.requiresOutput(e)))}get hasDecorations(){return this._renderPlugins.some((e=>e.isDecoration))}get needsLaserlineWithContrastControl(){const e=this._slots[l.LASERLINES_CONTRAST_CONTROL];return!!e&&e.length>0}get renderOccludedFlags(){return this._renderPlugins.reduce(((e,r)=>e|r.renderOccludedFlags),d.None)}get usedMemory(){return this._renderPlugins.reduce(((e,r)=>e+(r.usedMemory??0)),0)}};function p(e){return"prepareTechnique"in e}function h(e){return"prepareTechniques"in e}e([o({readOnly:!0})],c.prototype,"updating",null),c=e([i("esri.views.3d.webgl-engine.lib.RenderPluginManager")],c);const g={near:0,far:0};export{c as RenderPluginManager};