@arcgis/core 5.1.0-next.25 → 5.1.0-next.26

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 (66) hide show
  1. package/README.md +4 -5
  2. package/assets/esri/core/workers/RemoteClient.js +1 -1
  3. package/assets/esri/core/workers/chunks/{f1c1f7583fa13dff9b5c.js → 7fbee83c9463892f4808.js} +1 -1
  4. package/assets/esri/core/workers/chunks/{ef267b938327c41727c1.js → f89b7b0ccfbd1e5f9a0f.js} +1 -1
  5. package/chunks/MeasurementArrow.glsl.js +5 -8
  6. package/config.d.ts +2 -2
  7. package/config.js +1 -1
  8. package/editing/templateUtils.js +1 -1
  9. package/kernel.js +1 -1
  10. package/layers/support/FeatureReductionBinning.d.ts +3 -4
  11. package/layers/support/FeatureReductionBinning.js +1 -1
  12. package/layers/support/FeatureReductionCluster.d.ts +3 -4
  13. package/layers/support/FeatureReductionCluster.js +1 -1
  14. package/layers/support/featureReductionProperties.js +1 -1
  15. package/package.json +1 -1
  16. package/renderers/FlowRenderer.d.ts +6 -2
  17. package/support/revision.js +1 -1
  18. package/views/2d/analysis/AreaMeasurement/AreaMeasurementTool.js +1 -1
  19. package/views/2d/analysis/DistanceMeasurement/DistanceMeasurementTool.js +1 -1
  20. package/views/2d/engine/webgl/shaders/sources/shaderRepository.js +1 -1
  21. package/views/2d/layers/MediaLayerView2D.js +1 -1
  22. package/views/2d/layers/imagery/VectorFieldView2D.js +1 -1
  23. package/views/3d/GroundView3D.js +1 -1
  24. package/views/3d/environment/ChapmanAtmosphere.js +1 -1
  25. package/views/3d/environment/CloudsComposition.js +1 -1
  26. package/views/3d/environment/CloudsRenderer.js +1 -1
  27. package/views/3d/environment/Fog.js +1 -1
  28. package/views/3d/environment/LocalAtmosphere.js +1 -1
  29. package/views/3d/environment/MarsAtmosphere.js +1 -1
  30. package/views/3d/environment/NoiseTextureAtlas.js +1 -1
  31. package/views/3d/environment/Precipitation.js +1 -1
  32. package/views/3d/environment/PrecipitationTechnique.js +1 -1
  33. package/views/3d/layers/MediaLayerView3D.js +1 -1
  34. package/views/3d/layers/PointCloudLayerView3D.js +1 -1
  35. package/views/3d/webgl-engine/core/shaderTechnique/ShaderTechniqueRepository.js +1 -1
  36. package/views/3d/webgl-engine/effects/RenderNodes.js +1 -1
  37. package/views/3d/webgl-engine/effects/blit/Blit.js +1 -1
  38. package/views/3d/webgl-engine/effects/focusArea/FocusAreaColorNode.js +1 -1
  39. package/views/3d/webgl-engine/effects/focusArea/FocusAreaMaskNode.js +1 -1
  40. package/views/3d/webgl-engine/effects/glow/GlowBlurTechnique.js +1 -1
  41. package/views/3d/webgl-engine/effects/glow/GlowCompositionTechnique.js +1 -1
  42. package/views/3d/webgl-engine/effects/glow/GlowRenderNode.js +1 -1
  43. package/views/3d/webgl-engine/effects/haze/Haze.js +1 -1
  44. package/views/3d/webgl-engine/effects/highlight/Highlight.js +1 -1
  45. package/views/3d/webgl-engine/effects/highlight/ShadowHighlight.js +1 -1
  46. package/views/3d/webgl-engine/effects/laserlines/LaserLineRenderer.js +1 -1
  47. package/views/3d/webgl-engine/effects/magnifier/Magnifier.js +1 -1
  48. package/views/3d/webgl-engine/effects/smaa/SMAA.js +1 -1
  49. package/views/3d/webgl-engine/effects/ssao/SSAO.js +1 -1
  50. package/views/3d/webgl-engine/effects/stars/Stars.js +1 -1
  51. package/views/3d/webgl-engine/lib/CutFillColor.js +1 -1
  52. package/views/3d/webgl-engine/lib/CutFillDepth.js +1 -1
  53. package/views/3d/webgl-engine/lib/GaussianSplatRenderNode.js +1 -1
  54. package/views/3d/webgl-engine/lib/Renderer.js +1 -1
  55. package/views/3d/webgl-engine/lib/ShadowAccumulator.js +1 -1
  56. package/views/3d/webgl-engine/lib/Viewshed.js +1 -1
  57. package/views/3d/webgl-engine/shaders/MeasurementArrow.glsl.js +1 -1
  58. package/views/3d/webgl-engine/shaders/MeasurementArrowTechnique.js +1 -1
  59. package/views/3d/webgl-engine/shaders/MeasurementArrowTechniqueConfiguration.js +1 -1
  60. package/views/layers/MediaLayerView.d.ts +90 -4
  61. package/views/layers/MediaLayerView.js +1 -1
  62. package/widgets/Measurement.d.ts +1 -1
  63. package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
  64. package/widgets/ValuePicker.d.ts +1 -1
  65. package/views/layers/MediaLayerViewMixin.d.ts +0 -109
  66. package/views/layers/MediaLayerViewMixin.js +0 -2
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import{lerp as t}from"../../../core/mathUtils.js";import{disposeMaybe as r}from"../../../core/maybe.js";import{watch as i,syncAndInitial as s,initial as o}from"../../../core/reactiveUtils.js";import{subclass as a}from"../../../core/accessorSupport/decorators.js";import{set as n}from"../../../core/libs/gl-matrix-2/math/vec2.js";import{set as m,length as h}from"../../../core/libs/gl-matrix-2/math/vec3.js";import{ZEROS as c}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{earth as p}from"../../../geometry/support/Ellipsoid.js";import{InternalRenderCategory as d}from"../webgl.js";import{computeInnerAltitudeFade as u,innerAtmosphereDepth as l}from"./atmosphereUtils.js";import{ChapmanAtmospherePassParameters as f,ChapmanAtmosphereTechnique as g}from"./ChapmanAtmosphereTechnique.js";import{ChapmanAtmosphereTechniqueConfiguration as b}from"./ChapmanAtmosphereTechniqueConfiguration.js";import{OpaqueEnvironment as _}from"../webgl-engine/effects/OpaqueEnvironment.js";import{createQuadVAO as w}from"../webgl-engine/lib/glUtil3D.js";import{applyTextureResizeModulo as P}from"../webgl-engine/lib/textureUtils.js";import{A as v}from"../../../chunks/AtmosphereCompositing.glsl.js";import{AtmosphereCompositingTechnique as j}from"../webgl-engine/shaders/AtmosphereCompositingTechnique.js";import{DepthStencilAttachment as A,PrimitiveType as q}from"../../webgl/enums.js";import x from"../../../webscene/background/ColorBackground.js";let T=class extends _{constructor(){super(...arguments),this._compositingPassParameters=new v,this._vao=null,this._passParameters=new f,this._configuration=new b}initialize(){this.addHandles([i(()=>this.view.environment.background,e=>{const t=e instanceof x?e.color.toUnitRGBA():c;m(this._passParameters.backgroundColor,t[0]*t[3],t[1]*t[3],t[2]*t[3])},s),i(()=>this.view.stage?.renderer?.highResolutionAtmosphere,e=>this._configuration.reduced=!e,s),i(()=>this.view.map.ground.undergroundColor,e=>{this._passParameters.undergroundColor=e?.toUnitRGBA()??c,this.requestRender(1)},o),i(()=>this.view.environment.atmosphereEnabled,e=>e?this._enable():this._disable(),s)])}destroy(){this._vao=r(this._vao)}precompile(){this.techniques.precompile(g,this._configuration),this.techniques.precompile(j)}render(e){const r=e.find(({name:e})=>e===d.OPAQUE_ENVIRONMENT);if(!this.bindParameters.mainDepth)return r;const i=this.renderingContext;this._vao??=w(i,1);const s=r.getAttachment(A);this._update();const o=this.techniques.get(g,this._configuration);if(!o.compiled)return this.requestRender(1),r;if(!this._configuration.reduced)return r.detachDepth(),i.bindFramebuffer(r.fbo),i.bindTechnique(o,this.bindParameters,this._passParameters),i.bindVAO(this._vao),i.drawArrays(q.TRIANGLE_STRIP,0,4),r.attachDepth(s),r;const a=this.techniques.get(j);if(!a.compiled)return this.requestRender(1),r;const n=i.getViewport(),m=this.bindParameters.camera,c=h(m.eye)-p.radius;let u;const l=p.atmosphereHeight;if(c<l){const e=Math.min(1,Math.max(0,c/l));u=t(.2,.3,e)}else{const e=Math.min(1,Math.max(0,(c-l)/(15*l)));u=t(.3,.6,e)}const f=this.renderingContext.parameters.maxTextureSize,b=P(Math.round(u*m.fullViewport[2]),f),_=P(Math.round(u*m.fullViewport[3]),f);i.setViewport(0,0,b,_);const v=this.fboCache.acquire(b,_,"chapman",5);return i.bindFramebuffer(v.fbo),i.clearFramebuffer([0,0,0,1],!0,!0),i.bindTechnique(o,this.bindParameters,this._passParameters),i.bindVAO(this._vao),i.drawArrays(q.TRIANGLE_STRIP,0,4),i.setViewport(n.x,n.y,n.width,n.height),this._compositingPassParameters.color=v.getTexture(),r.detachDepth(),i.bindFramebuffer(r.fbo),i.bindTechnique(a,this.bindParameters,this._compositingPassParameters),i.screen.draw(),r.attachDepth(s),v.release(),r}_update(){const e=this.view.basemapTerrain?.getLowerBoundRadius()??0;n(this._passParameters.radii,e,e+p.atmosphereHeight);const t=h(this.bindParameters.camera.eye);this._passParameters.altitudeFade=u(t-e),this._passParameters.innerFadeDistance=2*Math.sqrt((2*e-l)*l)}};T=e([a("esri.views.3d.environment.ChapmanAtmosphere")],T);export{T as ChapmanAtmosphere};
2
+ import{__decorate as e}from"tslib";import{lerp as t}from"../../../core/mathUtils.js";import{disposeMaybe as r}from"../../../core/maybe.js";import{watch as i,syncAndInitial as s,initial as o}from"../../../core/reactiveUtils.js";import{subclass as a}from"../../../core/accessorSupport/decorators.js";import{set as n}from"../../../core/libs/gl-matrix-2/math/vec2.js";import{set as m,length as h}from"../../../core/libs/gl-matrix-2/math/vec3.js";import{ZEROS as c}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{earth as p}from"../../../geometry/support/Ellipsoid.js";import{InternalRenderCategory as d}from"../webgl.js";import{computeInnerAltitudeFade as u,innerAtmosphereDepth as l}from"./atmosphereUtils.js";import{ChapmanAtmospherePassParameters as f,ChapmanAtmosphereTechnique as g}from"./ChapmanAtmosphereTechnique.js";import{ChapmanAtmosphereTechniqueConfiguration as b}from"./ChapmanAtmosphereTechniqueConfiguration.js";import{OpaqueEnvironment as _}from"../webgl-engine/effects/OpaqueEnvironment.js";import{createQuadVAO as w}from"../webgl-engine/lib/glUtil3D.js";import{applyTextureResizeModulo as P}from"../webgl-engine/lib/textureUtils.js";import{A as v}from"../../../chunks/AtmosphereCompositing.glsl.js";import{AtmosphereCompositingTechnique as j}from"../webgl-engine/shaders/AtmosphereCompositingTechnique.js";import{DepthStencilAttachment as A,PrimitiveType as q}from"../../webgl/enums.js";import x from"../../../webscene/background/ColorBackground.js";let C=class extends _{constructor(){super(...arguments),this._compositingPassParameters=new v,this._vao=null,this._passParameters=new f,this._configuration=new b}initialize(){this.addHandles([i(()=>this.view.environment.background,e=>{const t=e instanceof x?e.color.toUnitRGBA():c;m(this._passParameters.backgroundColor,t[0]*t[3],t[1]*t[3],t[2]*t[3])},s),i(()=>this.view.stage?.renderer?.highResolutionAtmosphere,e=>this._configuration.reduced=!e,s),i(()=>this.view.map.ground.undergroundColor,e=>{this._passParameters.undergroundColor=e?.toUnitRGBA()??c,this.requestRender(1)},o),i(()=>this.view.environment.atmosphereEnabled,e=>e?this._enable():this._disable(),s)])}destroy(){this._vao=r(this._vao)}precompile(){this.techniques.precompile(g,this._configuration),this.techniques.precompile(j)}render(e){const r=e.find(({name:e})=>e===d.OPAQUE_ENVIRONMENT);if(!this.bindParameters.mainDepth)return r;const i=this.renderingContext;this._vao??=w(i,1);const s=r.getAttachment(A);this._update();const o=this.techniques.getCompiled(g,this._configuration);if(!o)return this.requestRender(1),r;if(!this._configuration.reduced)return r.detachDepth(),i.bindFramebuffer(r.fbo),i.bindTechnique(o,this.bindParameters,this._passParameters),i.bindVAO(this._vao),i.drawArrays(q.TRIANGLE_STRIP,0,4),r.attachDepth(s),r;const a=this.techniques.get(j);if(!a.compiled)return this.requestRender(1),r;const n=i.getViewport(),m=this.bindParameters.camera,c=h(m.eye)-p.radius;let u;const l=p.atmosphereHeight;if(c<l){const e=Math.min(1,Math.max(0,c/l));u=t(.2,.3,e)}else{const e=Math.min(1,Math.max(0,(c-l)/(15*l)));u=t(.3,.6,e)}const f=this.renderingContext.parameters.maxTextureSize,b=P(Math.round(u*m.fullViewport[2]),f),_=P(Math.round(u*m.fullViewport[3]),f);i.setViewport(0,0,b,_);const v=this.fboCache.acquire(b,_,"chapman",5);return i.bindFramebuffer(v.fbo),i.clearFramebuffer([0,0,0,1],!0,!0),i.bindTechnique(o,this.bindParameters,this._passParameters),i.bindVAO(this._vao),i.drawArrays(q.TRIANGLE_STRIP,0,4),i.setViewport(n.x,n.y,n.width,n.height),this._compositingPassParameters.color=v.getTexture(),r.detachDepth(),i.bindFramebuffer(r.fbo),i.bindTechnique(a,this.bindParameters,this._compositingPassParameters),i.screen.draw(),r.attachDepth(s),v.release(),r}_update(){const e=this.view.basemapTerrain?.getLowerBoundRadius()??0;n(this._passParameters.radii,e,e+p.atmosphereHeight);const t=h(this.bindParameters.camera.eye);this._passParameters.altitudeFade=u(t-e),this._passParameters.innerFadeDistance=2*Math.sqrt((2*e-l)*l)}};C=e([a("esri.views.3d.environment.ChapmanAtmosphere")],C);export{C as ChapmanAtmosphere};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import{disposeMaybe as t}from"../../../core/maybe.js";import{watch as i,initial as s}from"../../../core/reactiveUtils.js";import{subclass as r}from"../../../core/accessorSupport/decorators.js";import{CloudsCompositionTechnique as o}from"./CloudsCompositionTechnique.js";import{OpaqueEnvironment as n}from"../webgl-engine/effects/OpaqueEnvironment.js";import{createQuadVAO as a}from"../webgl-engine/lib/glUtil3D.js";import{PrimitiveType as m}from"../../webgl/enums.js";let d=class extends n{initialize(){this.addHandles([i(()=>null!=this.view.environment.weather&&this.view.environment.atmosphereEnabled,e=>e?this._enable():this._disable(),s)])}destroy(){this._vao=t(this._vao)}precompile(){this.bindParameters.clouds.data&&this.techniques.precompile(o)}render(e){const t=e.find(({name:e})=>e===this.produces),i=this.bindParameters.clouds;if(!i.data)return t;const s=this.techniques.get(o);if(!s.compiled)return this.requestRender(1),t;const r=this.renderingContext;this._vao??=a(r);const n=r.bindTechnique(s,this.bindParameters);return r.bindVAO(this._vao),n.assertCompatibleVertexAttributeLocations(this._vao),r.drawArrays(m.TRIANGLE_STRIP,0,4),i.isFading&&this.requestRender(2),t}};d=e([r("esri.views.3d.environment.CloudsComposition")],d);export{d as CloudsComposition};
2
+ import{__decorate as e}from"tslib";import{disposeMaybe as t}from"../../../core/maybe.js";import{watch as i,initial as s}from"../../../core/reactiveUtils.js";import{subclass as r}from"../../../core/accessorSupport/decorators.js";import{CloudsCompositionTechnique as o}from"./CloudsCompositionTechnique.js";import{OpaqueEnvironment as n}from"../webgl-engine/effects/OpaqueEnvironment.js";import{createQuadVAO as a}from"../webgl-engine/lib/glUtil3D.js";import{PrimitiveType as m}from"../../webgl/enums.js";let d=class extends n{initialize(){this.addHandles([i(()=>null!=this.view.environment.weather&&this.view.environment.atmosphereEnabled,e=>e?this._enable():this._disable(),s)])}destroy(){this._vao=t(this._vao)}precompile(){this.bindParameters.clouds.data&&this.techniques.precompile(o)}render(e){const t=e.find(({name:e})=>e===this.produces),i=this.bindParameters.clouds;if(!i.data)return t;const s=this.techniques.getCompiled(o);if(!s)return this.requestRender(1),t;const r=this.renderingContext;this._vao??=a(r);const n=r.bindTechnique(s,this.bindParameters);return r.bindVAO(this._vao),n.assertCompatibleVertexAttributeLocations(this._vao),r.drawArrays(m.TRIANGLE_STRIP,0,4),i.isFading&&this.requestRender(2),t}};d=e([r("esri.views.3d.environment.CloudsComposition")],d);export{d as CloudsComposition};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{__decorate as t}from"tslib";import e from"../../../core/Accessor.js";import{lerp as s}from"../../../core/mathUtils.js";import{destroyMaybe as i,disposeMaybe as r}from"../../../core/maybe.js";import{watch as o,initial as a}from"../../../core/reactiveUtils.js";import{signal as h}from"../../../core/signal.js";import{property as n,subclass as l}from"../../../core/accessorSupport/decorators.js";import{fromMat4 as c}from"../../../core/libs/gl-matrix-2/math/mat3.js";import{targetTo as u}from"../../../core/libs/gl-matrix-2/math/mat4.js";import{create as d}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{equals as p,copy as m,set as _}from"../../../core/libs/gl-matrix-2/math/vec2.js";import{clone as f,ZEROS as g,zeros as x}from"../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{fromValues as y}from"../../../core/libs/gl-matrix-2/factories/vec3f32.js";import{zeros as b}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{getReferenceEllipsoid as T}from"../../../geometry/ellipsoidUtils.js";import{C as v,c as S}from"../../../chunks/Clouds.glsl.js";import{cloudPresets as C}from"./CloudsPresets.js";import{CloudsTechnique as w}from"./CloudsTechnique.js";import{CloudsTechniqueConfiguration as P}from"./CloudsTechniqueConfiguration.js";import{NoiseTextureAtlas as j}from"./NoiseTextureAtlas.js";import{TaskPriority as z}from"../../support/Scheduler.js";import{Yield as I}from"../../support/Yield.js";import{ColorAttachment0 as M}from"../../webgl/enums.js";import{FramebufferObject as H}from"../../webgl/FramebufferObject.js";import{TextureDescriptor as q}from"../../webgl/TextureDescriptor.js";let R=class extends e{constructor(t){super(t),this._state=h(0),this._passParameters=new v,this._weatherTileCount=128,this._sliceIndex=0,this._tileIndex=0,this._tilesPerSlice=1,this.coverage=s(C.default.coverage[0],C.default.coverage[1],.5),this.density=s(C.default.density[0],C.default.density[1],.5),this.absorption=s(C.default.absorption[0],C.default.absorption[1],.5),this.cloudSize=s(C.default.cloudSize[0],C.default.cloudSize[1],.5),this.detailSize=s(C.default.detailSize[0],C.default.detailSize[1],.5),this.smoothness=s(C.default.smoothness[0],C.default.smoothness[1],.5),this.cloudHeight=s(C.default.cloudHeight[0],C.default.cloudHeight[1],.5),this.raymarchingSteps=C.default.raymarchingSteps,this._viewMatrix=d(),this._dirty=!0,this.readyToRun=!0,this._configuration=new P}initialize(){const t=T(this.view.spatialReference);this._passParameters.cloudRadius=.5*t.radius;const e=()=>this.setDirty();this.addHandles([this.view.resourceController.scheduler.registerTask(z.CLOUDS_GENERATOR,this),o(()=>this.coverage,e,a),o(()=>this.density,e,a),o(()=>this.absorption,e,a),o(()=>this.cloudSize,e,a),o(()=>this.detailSize,e,a),o(()=>this.smoothness,e,a),o(()=>this.cloudHeight,e,a),o(()=>this.raymarchingSteps,e,a)]);const s=f(this._computeWeatherTile());let i=0;this.addHandles(o(()=>{const t=this._computeWeatherTile();return p(s,t)||(++i,m(s,t)),i},e))}destroy(){this.destroyCubeMap(),this._passParameters.noiseTexture=i(this._passParameters.noiseTexture)}_precompile(){this._configuration.steps=this.raymarchingSteps,this._configuration.writeTextureChannels=1-this.parameters.readChannels,this.context.techniques.precompile(w,this._configuration)}_acquireTechnique(){switch(this.raymarchingSteps){case 0:this._tilesPerSlice=1;break;case 1:this._tilesPerSlice=4;break;case 3:case 2:this._tilesPerSlice=8;break;default:this.raymarchingSteps}return this._configuration.steps=this.raymarchingSteps,this._configuration.writeTextureChannels=1-this.parameters.readChannels,this.context.techniques.get(w,this._configuration)}_computeWeatherTile(){const{camera:t,environment:e}=this.view,{latitude:s,longitude:i}=t.position;if(null==s||null==i)return g;_(D,(s+90)/180,(i+180)/360);const r=Math.floor(this._weatherTileCount*Math.abs(2*D[0]-1));D[0]=Math.floor(2*this._weatherTileCount*D[0]),D[1]=Math.floor(4*(this._weatherTileCount-r)*D[1]);let o=0,a=0;if("virtual"!==e?.lighting?.type&&null!=e?.lighting?.date){const t=new Date(e.lighting.date);t.setUTCHours(e.lighting.date.getUTCHours()+(e.lighting.displayUTCOffset??0)),o=31*t.getUTCMonth()+t.getUTCDate(),a=t.getUTCFullYear()}return D[0]=(D[0]+o)%(2*this._weatherTileCount),D[1]=(D[1]+a%100)%(4*this._weatherTileCount),D}get state(){return this._state.value}set state(t){this._state.value=t}get usedMemory(){return(this._fbo?.usedMemory??0)+(this._passParameters.noiseTexture?.textureAtlas?.usedMemory??0)}_ensureNoiseTexture(){return this._passParameters.noiseTexture??=new j({context:this.context}),this._passParameters.noiseTexture}_ensureFrameBufferCube(t){const e=this.context.renderContext.rctx;if(null==this._fbo){const s=new q(t,t/2);s.target=35866,s.depth=6,s.wrapMode=33071,this._fbo=new H(e,s),this.parameters.data=this,this.parameters.absorption=this.absorption,this.parameters.coverage=this.coverage}return e.unbindTexture(this._fbo.colorTexture),this._fbo}get cubeMap(){return this._fbo}get parameters(){return this.context.renderContext.bind.clouds}destroyCubeMap(){this._fbo=r(this._fbo),this.parameters.data=null}applyPreset(t,e){const i=t.median,r=t=>{const r=s(t[0],t[1],i);return e<.5?s(t[0],r,2*e):s(r,t[1],2*(e-.5))};this.coverage=r(t.coverage),this.density=r(t.density),this.absorption=r(t.absorption),this.cloudSize=r(t.cloudSize),this.detailSize=r(t.detailSize),this.smoothness=r(t.smoothness),this.cloudHeight=r(t.cloudHeight),this.raymarchingSteps=t.raymarchingSteps}setDirty(){this._dirty=this.readyToRun=!0,this._precompile()}runTask(t){if(3===this.state)return I;this._dirty&&(this._sliceIndex=this._tileIndex=0,this.state=1,this._passParameters.absorption=this.absorption,this._passParameters.density=this.density,this._passParameters.cloudSize=this.cloudSize,this._passParameters.detailSize=this.detailSize,this._passParameters.smoothness=this.smoothness,this._passParameters.cloudHeight=this.cloudHeight,this._passParameters.coverage=this.coverage,this._ensureNoiseTexture().updateWeatherMap(this._computeWeatherTile()),this._dirty=!1);const e=this._acquireTechnique();if(!this._ensureNoiseTexture().textureAtlas||!e.compiled)return I;const s=U[this._sliceIndex],i=O[this._sliceIndex];u(this._viewMatrix,k,s,i),c(this._passParameters.viewMatrix,this._viewMatrix);const r=this.context.renderContext.rctx,o=r.getViewport(),a=S/this._tilesPerSlice,h=this._tileIndex*a;r.setViewport(0,h,S,a);const n=this._ensureFrameBufferCube(S);r.bindFramebuffer(n),this._passParameters.lastSlice=5===this._sliceIndex,r.bindTechnique(e,this.context.renderContext.bind,this._passParameters);const l=35866;return n.setColorTextureTarget(l,M,this._sliceIndex),r.screen.draw(),r.gl.flush(),r.setViewport(o.x,o.y,o.width,o.height),this.requestRender(),++this._tileIndex,5===this._sliceIndex&&this._tileIndex===this._tilesPerSlice?(this._sliceIndex=this._tileIndex=0,this.state=2,this.readyToRun=!1):this._tileIndex===this._tilesPerSlice&&(++this._sliceIndex,this._tileIndex=0),t.madeProgress(),I}};t([n({constructOnly:!0})],R.prototype,"context",void 0),t([n({constructOnly:!0})],R.prototype,"view",void 0),t([n({constructOnly:!0})],R.prototype,"requestRender",void 0),t([n()],R.prototype,"coverage",void 0),t([n()],R.prototype,"density",void 0),t([n()],R.prototype,"absorption",void 0),t([n()],R.prototype,"cloudSize",void 0),t([n()],R.prototype,"detailSize",void 0),t([n()],R.prototype,"smoothness",void 0),t([n()],R.prototype,"cloudHeight",void 0),t([n()],R.prototype,"raymarchingSteps",void 0),t([n()],R.prototype,"readyToRun",void 0),R=t([l("esri.views.3d.environment.CloudsRenderer")],R);const U=[y(1,0,0),y(-1,0,0),y(0,1,0),y(0,-1,0),y(0,0,1),y(0,0,1)],O=[y(0,0,-1),y(0,0,-1),y(0,0,-1),y(0,0,-1),y(0,1,0),y(0,1,0)],k=b(),D=x();export{R as CloudsRenderer};
2
+ import{__decorate as t}from"tslib";import e from"../../../core/Accessor.js";import{lerp as s}from"../../../core/mathUtils.js";import{destroyMaybe as i,disposeMaybe as r}from"../../../core/maybe.js";import{watch as o,initial as a}from"../../../core/reactiveUtils.js";import{signal as h}from"../../../core/signal.js";import{property as n,subclass as l}from"../../../core/accessorSupport/decorators.js";import{fromMat4 as c}from"../../../core/libs/gl-matrix-2/math/mat3.js";import{targetTo as u}from"../../../core/libs/gl-matrix-2/math/mat4.js";import{create as d}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{equals as p,copy as m,set as _}from"../../../core/libs/gl-matrix-2/math/vec2.js";import{clone as f,ZEROS as g,zeros as x}from"../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{fromValues as y}from"../../../core/libs/gl-matrix-2/factories/vec3f32.js";import{zeros as b}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{getReferenceEllipsoid as T}from"../../../geometry/ellipsoidUtils.js";import{C as v,c as S}from"../../../chunks/Clouds.glsl.js";import{cloudPresets as C}from"./CloudsPresets.js";import{CloudsTechnique as w}from"./CloudsTechnique.js";import{CloudsTechniqueConfiguration as P}from"./CloudsTechniqueConfiguration.js";import{NoiseTextureAtlas as j}from"./NoiseTextureAtlas.js";import{TaskPriority as z}from"../../support/Scheduler.js";import{Yield as I}from"../../support/Yield.js";import{ColorAttachment0 as M}from"../../webgl/enums.js";import{FramebufferObject as H}from"../../webgl/FramebufferObject.js";import{TextureDescriptor as q}from"../../webgl/TextureDescriptor.js";let R=class extends e{constructor(t){super(t),this._state=h(0),this._passParameters=new v,this._weatherTileCount=128,this._sliceIndex=0,this._tileIndex=0,this._tilesPerSlice=1,this.coverage=s(C.default.coverage[0],C.default.coverage[1],.5),this.density=s(C.default.density[0],C.default.density[1],.5),this.absorption=s(C.default.absorption[0],C.default.absorption[1],.5),this.cloudSize=s(C.default.cloudSize[0],C.default.cloudSize[1],.5),this.detailSize=s(C.default.detailSize[0],C.default.detailSize[1],.5),this.smoothness=s(C.default.smoothness[0],C.default.smoothness[1],.5),this.cloudHeight=s(C.default.cloudHeight[0],C.default.cloudHeight[1],.5),this.raymarchingSteps=C.default.raymarchingSteps,this._viewMatrix=d(),this._dirty=!0,this.readyToRun=!0,this._configuration=new P}initialize(){const t=T(this.view.spatialReference);this._passParameters.cloudRadius=.5*t.radius;const e=()=>this.setDirty();this.addHandles([this.view.resourceController.scheduler.registerTask(z.CLOUDS_GENERATOR,this),o(()=>this.coverage,e,a),o(()=>this.density,e,a),o(()=>this.absorption,e,a),o(()=>this.cloudSize,e,a),o(()=>this.detailSize,e,a),o(()=>this.smoothness,e,a),o(()=>this.cloudHeight,e,a),o(()=>this.raymarchingSteps,e,a)]);const s=f(this._computeWeatherTile());let i=0;this.addHandles(o(()=>{const t=this._computeWeatherTile();return p(s,t)||(++i,m(s,t)),i},e))}destroy(){this.destroyCubeMap(),this._passParameters.noiseTexture=i(this._passParameters.noiseTexture)}_precompile(){this._configuration.steps=this.raymarchingSteps,this._configuration.writeTextureChannels=1-this.parameters.readChannels,this.context.techniques.precompile(w,this._configuration)}_acquireTechnique(){switch(this.raymarchingSteps){case 0:this._tilesPerSlice=1;break;case 1:this._tilesPerSlice=4;break;case 3:case 2:this._tilesPerSlice=8;break;default:this.raymarchingSteps}return this._configuration.steps=this.raymarchingSteps,this._configuration.writeTextureChannels=1-this.parameters.readChannels,this.context.techniques.getCompiled(w,this._configuration)}_computeWeatherTile(){const{camera:t,environment:e}=this.view,{latitude:s,longitude:i}=t.position;if(null==s||null==i)return g;_(D,(s+90)/180,(i+180)/360);const r=Math.floor(this._weatherTileCount*Math.abs(2*D[0]-1));D[0]=Math.floor(2*this._weatherTileCount*D[0]),D[1]=Math.floor(4*(this._weatherTileCount-r)*D[1]);let o=0,a=0;if("virtual"!==e?.lighting?.type&&null!=e?.lighting?.date){const t=new Date(e.lighting.date);t.setUTCHours(e.lighting.date.getUTCHours()+(e.lighting.displayUTCOffset??0)),o=31*t.getUTCMonth()+t.getUTCDate(),a=t.getUTCFullYear()}return D[0]=(D[0]+o)%(2*this._weatherTileCount),D[1]=(D[1]+a%100)%(4*this._weatherTileCount),D}get state(){return this._state.value}set state(t){this._state.value=t}get usedMemory(){return(this._fbo?.usedMemory??0)+(this._passParameters.noiseTexture?.textureAtlas?.usedMemory??0)}_ensureNoiseTexture(){return this._passParameters.noiseTexture??=new j({context:this.context}),this._passParameters.noiseTexture}_ensureFrameBufferCube(t){const e=this.context.renderContext.rctx;if(null==this._fbo){const s=new q(t,t/2);s.target=35866,s.depth=6,s.wrapMode=33071,this._fbo=new H(e,s),this.parameters.data=this,this.parameters.absorption=this.absorption,this.parameters.coverage=this.coverage}return e.unbindTexture(this._fbo.colorTexture),this._fbo}get cubeMap(){return this._fbo}get parameters(){return this.context.renderContext.bind.clouds}destroyCubeMap(){this._fbo=r(this._fbo),this.parameters.data=null}applyPreset(t,e){const i=t.median,r=t=>{const r=s(t[0],t[1],i);return e<.5?s(t[0],r,2*e):s(r,t[1],2*(e-.5))};this.coverage=r(t.coverage),this.density=r(t.density),this.absorption=r(t.absorption),this.cloudSize=r(t.cloudSize),this.detailSize=r(t.detailSize),this.smoothness=r(t.smoothness),this.cloudHeight=r(t.cloudHeight),this.raymarchingSteps=t.raymarchingSteps}setDirty(){this._dirty=this.readyToRun=!0,this._precompile()}runTask(t){if(3===this.state)return I;this._dirty&&(this._sliceIndex=this._tileIndex=0,this.state=1,this._passParameters.absorption=this.absorption,this._passParameters.density=this.density,this._passParameters.cloudSize=this.cloudSize,this._passParameters.detailSize=this.detailSize,this._passParameters.smoothness=this.smoothness,this._passParameters.cloudHeight=this.cloudHeight,this._passParameters.coverage=this.coverage,this._ensureNoiseTexture().updateWeatherMap(this._computeWeatherTile()),this._dirty=!1);const e=this._acquireTechnique();if(!this._ensureNoiseTexture().textureAtlas||!e)return I;const s=U[this._sliceIndex],i=O[this._sliceIndex];u(this._viewMatrix,k,s,i),c(this._passParameters.viewMatrix,this._viewMatrix);const r=this.context.renderContext.rctx,o=r.getViewport(),a=S/this._tilesPerSlice,h=this._tileIndex*a;r.setViewport(0,h,S,a);const n=this._ensureFrameBufferCube(S);r.bindFramebuffer(n),this._passParameters.lastSlice=5===this._sliceIndex,r.bindTechnique(e,this.context.renderContext.bind,this._passParameters);const l=35866;return n.setColorTextureTarget(l,M,this._sliceIndex),r.screen.draw(),r.gl.flush(),r.setViewport(o.x,o.y,o.width,o.height),this.requestRender(),++this._tileIndex,5===this._sliceIndex&&this._tileIndex===this._tilesPerSlice?(this._sliceIndex=this._tileIndex=0,this.state=2,this.readyToRun=!1):this._tileIndex===this._tilesPerSlice&&(++this._sliceIndex,this._tileIndex=0),t.madeProgress(),I}};t([n({constructOnly:!0})],R.prototype,"context",void 0),t([n({constructOnly:!0})],R.prototype,"view",void 0),t([n({constructOnly:!0})],R.prototype,"requestRender",void 0),t([n()],R.prototype,"coverage",void 0),t([n()],R.prototype,"density",void 0),t([n()],R.prototype,"absorption",void 0),t([n()],R.prototype,"cloudSize",void 0),t([n()],R.prototype,"detailSize",void 0),t([n()],R.prototype,"smoothness",void 0),t([n()],R.prototype,"cloudHeight",void 0),t([n()],R.prototype,"raymarchingSteps",void 0),t([n()],R.prototype,"readyToRun",void 0),R=t([l("esri.views.3d.environment.CloudsRenderer")],R);const U=[y(1,0,0),y(-1,0,0),y(0,1,0),y(0,-1,0),y(0,0,1),y(0,0,1)],O=[y(0,0,-1),y(0,0,-1),y(0,0,-1),y(0,0,-1),y(0,1,0),y(0,1,0)],k=b(),D=x();export{R as CloudsRenderer};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import{lerp as t,smoothstep as s}from"../../../core/mathUtils.js";import{releaseMaybe as r}from"../../../core/maybe.js";import{watch as a,syncAndInitial as i}from"../../../core/reactiveUtils.js";import{subclass as o}from"../../../core/accessorSupport/decorators.js";import{copy as n,normalize as h,dot as m,scale as p,lerp as c,length as l}from"../../../core/libs/gl-matrix-2/math/vec3.js";import{create as d,fromValues as _}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{getReferenceEllipsoid as u}from"../../../geometry/ellipsoidUtils.js";import{InternalRenderCategory as f}from"../webgl.js";import{F as g}from"../../../chunks/Fog.glsl.js";import{FogTechnique as P}from"./FogTechnique.js";import{FogTechniqueConfiguration as w}from"./FogTechniqueConfiguration.js";import{heightLimit as b}from"./weather.js";import{TransparentEnvironment as y}from"../webgl-engine/effects/TransparentEnvironment.js";import{Blit as v}from"../webgl-engine/effects/blit/Blit.js";import{ColorAttachment1 as j,DepthStencilAttachment as F}from"../../webgl/enums.js";const E=.95,R=1;let q=class extends y{constructor(e){super(e),this._configuration=new w,this._newParameters=new x,this._oldParameters=new x,this._fadedParameters=new x,this._parameters=this._newParameters,this._passParameters=new g,this._blit=null;const t=u(e.view.spatialReference);this._planetRadius=t.radius,this._atmosphereRadius=t.radius+t.atmosphereHeight}initialize(){this.addHandles([a(()=>this.view.environment.atmosphereEnabled,()=>this._updateEnabled(),i),a(()=>this.view.environment.weather,()=>this._updateEnabled(),i),a(()=>this._updateFogParameters(),()=>{},i)]),this.addHandles(a(()=>this._fadeFactor,e=>this._fade(e),i))}_updateEnabled(){this.view.environment.atmosphereEnabled&&this.view.environment.weather?this._enable():this._disable()}get _fadeFactor(){return this.view.stage?.renderer.renderContext.bind.clouds.fadeFactor??1}_fade(e){const{_newParameters:t,_oldParameters:s}=this;e>=1?(this._parameters=t,this._oldParameters.copyFrom(this._newParameters)):e<=0?this._parameters=s:(this._fadedParameters.lerp(s,t,e),this._parameters=this._fadedParameters)}_updateFogParameters(){const e=this.view.environment.weather,s="foggy"===e.type||"snowy"===e.type||"rainy"===e.type;this._newParameters.strength="foggy"===e.type?t(3e-5,.005,e.fogStrength**3):"snowy"===e.type||"rainy"===e.type?t(4e-6,2e-4,(e.precipitation??0)**3):0,this._newParameters.amount=s?1:0,"foggy"!==e.type&&"snowy"!==e.type||n(this._newParameters.color,A),"rainy"===e.type&&n(this._newParameters.color,N),this._fadeFactor>=1&&this._oldParameters.copyFrom(this._newParameters),this.requestRender(2)}precompile(){this._parameters.amount>0&&(this._configuration.hasEmissive=this.bindParameters.hasEmission,this.techniques.precompile(P,this._configuration))}render(e){const t=e.find(({name:e})=>e===f.TRANSPARENT_ENVIRONMENT);if(0===this._parameters.amount)return t;if(this._update(),this._passParameters.amount<=0)return t;const s=t.getAttachment(j);this._configuration.hasEmissive=null!=s;const a=this.techniques.get(P,this._configuration);if(!a.compiled)return this.requestRender(1),t;const i=t.getAttachment(F),o=this.renderingContext,{fullWidth:n,fullHeight:h}=this.bindParameters.camera,m=n,p=h;return s&&(this._passParameters.emission=this.fboCache.acquire(m,p,"glow horizontal",8),this._blit??=new v(this.techniques),this._blit.blitTexture(o,s?.attachment,this.bindParameters,this._passParameters.emission)),t.attachDepth(null),o.bindFramebuffer(t.fbo),o.bindTechnique(a,this.bindParameters,this._passParameters),o.screen.draw(),t.attachDepth(i),this._passParameters.emission=r(this._passParameters.emission),t}_update(){const e=this.bindParameters.camera;h(T,e.eye);const t=Math.max(0,m(T,this.bindParameters.lighting.mainLight.direction)),r=this._parameters.color;p(C,r,.1),c(this._passParameters.color,C,r,t);const a=l(e.eye);this._passParameters.atmosphereC=a**2-this._atmosphereRadius**2,this._passParameters.amount=(1-s(E*b,R*b,Math.abs(a-this._planetRadius)))*this._parameters.amount,this._passParameters.strength=this._parameters.strength}get test(){return{parameters:this._passParameters}}};q=e([o("esri.views.3d.environment.Fog")],q);class x{constructor(){this.color=d(),this.strength=0,this.amount=0}copyFrom(e){this.amount=e.amount,this.strength=e.strength,n(this.color,e.color)}lerp(e,s,r){this.amount=t(e.amount,s.amount,r),this.strength=t(e.strength,s.strength,r),c(this.color,e.color,s.color,r)}}const T=d(),C=d(),N=_(.5,.5,.5),A=_(1.5,1.5,1.5);export{q as Fog,x as FogParameters};
2
+ import{__decorate as e}from"tslib";import{lerp as t,smoothstep as s}from"../../../core/mathUtils.js";import{releaseMaybe as r}from"../../../core/maybe.js";import{watch as a,syncAndInitial as i}from"../../../core/reactiveUtils.js";import{subclass as o}from"../../../core/accessorSupport/decorators.js";import{copy as n,normalize as h,dot as m,scale as p,lerp as c,length as l}from"../../../core/libs/gl-matrix-2/math/vec3.js";import{create as d,fromValues as _}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{getReferenceEllipsoid as u}from"../../../geometry/ellipsoidUtils.js";import{InternalRenderCategory as f}from"../webgl.js";import{F as g}from"../../../chunks/Fog.glsl.js";import{FogTechnique as P}from"./FogTechnique.js";import{FogTechniqueConfiguration as w}from"./FogTechniqueConfiguration.js";import{heightLimit as b}from"./weather.js";import{TransparentEnvironment as y}from"../webgl-engine/effects/TransparentEnvironment.js";import{Blit as v}from"../webgl-engine/effects/blit/Blit.js";import{ColorAttachment1 as j,DepthStencilAttachment as F}from"../../webgl/enums.js";const E=.95,R=1;let q=class extends y{constructor(e){super(e),this._configuration=new w,this._newParameters=new x,this._oldParameters=new x,this._fadedParameters=new x,this._parameters=this._newParameters,this._passParameters=new g,this._blit=null;const t=u(e.view.spatialReference);this._planetRadius=t.radius,this._atmosphereRadius=t.radius+t.atmosphereHeight}initialize(){this.addHandles([a(()=>this.view.environment.atmosphereEnabled,()=>this._updateEnabled(),i),a(()=>this.view.environment.weather,()=>this._updateEnabled(),i),a(()=>this._updateFogParameters(),()=>{},i)]),this.addHandles(a(()=>this._fadeFactor,e=>this._fade(e),i))}_updateEnabled(){this.view.environment.atmosphereEnabled&&this.view.environment.weather?this._enable():this._disable()}get _fadeFactor(){return this.view.stage?.renderer.renderContext.bind.clouds.fadeFactor??1}_fade(e){const{_newParameters:t,_oldParameters:s}=this;e>=1?(this._parameters=t,this._oldParameters.copyFrom(this._newParameters)):e<=0?this._parameters=s:(this._fadedParameters.lerp(s,t,e),this._parameters=this._fadedParameters)}_updateFogParameters(){const e=this.view.environment.weather,s="foggy"===e.type||"snowy"===e.type||"rainy"===e.type;this._newParameters.strength="foggy"===e.type?t(3e-5,.005,e.fogStrength**3):"snowy"===e.type||"rainy"===e.type?t(4e-6,2e-4,(e.precipitation??0)**3):0,this._newParameters.amount=s?1:0,"foggy"!==e.type&&"snowy"!==e.type||n(this._newParameters.color,A),"rainy"===e.type&&n(this._newParameters.color,N),this._fadeFactor>=1&&this._oldParameters.copyFrom(this._newParameters),this.requestRender(2)}precompile(){this._parameters.amount>0&&(this._configuration.hasEmissive=this.bindParameters.hasEmission,this.techniques.precompile(P,this._configuration))}render(e){const t=e.find(({name:e})=>e===f.TRANSPARENT_ENVIRONMENT);if(0===this._parameters.amount)return t;if(this._update(),this._passParameters.amount<=0)return t;const s=t.getAttachment(j);this._configuration.hasEmissive=null!=s;const a=this.techniques.getCompiled(P,this._configuration);if(!a)return this.requestRender(1),t;const i=t.getAttachment(F),o=this.renderingContext,{fullWidth:n,fullHeight:h}=this.bindParameters.camera,m=n,p=h;return s&&(this._passParameters.emission=this.fboCache.acquire(m,p,"glow horizontal",8),this._blit??=new v(this.techniques),this._blit.blitTexture(o,s?.attachment,this.bindParameters,this._passParameters.emission)),t.attachDepth(null),o.bindFramebuffer(t.fbo),o.bindTechnique(a,this.bindParameters,this._passParameters),o.screen.draw(),t.attachDepth(i),this._passParameters.emission=r(this._passParameters.emission),t}_update(){const e=this.bindParameters.camera;h(T,e.eye);const t=Math.max(0,m(T,this.bindParameters.lighting.mainLight.direction)),r=this._parameters.color;p(C,r,.1),c(this._passParameters.color,C,r,t);const a=l(e.eye);this._passParameters.atmosphereC=a**2-this._atmosphereRadius**2,this._passParameters.amount=(1-s(E*b,R*b,Math.abs(a-this._planetRadius)))*this._parameters.amount,this._passParameters.strength=this._parameters.strength}get test(){return{parameters:this._passParameters}}};q=e([o("esri.views.3d.environment.Fog")],q);class x{constructor(){this.color=d(),this.strength=0,this.amount=0}copyFrom(e){this.amount=e.amount,this.strength=e.strength,n(this.color,e.color)}lerp(e,s,r){this.amount=t(e.amount,s.amount,r),this.strength=t(e.strength,s.strength,r),c(this.color,e.color,s.color,r)}}const T=d(),C=d(),N=_(.5,.5,.5),A=_(1.5,1.5,1.5);export{q as Fog,x as FogParameters};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import{disposeMaybe as t}from"../../../core/maybe.js";import{watch as r,initial as i}from"../../../core/reactiveUtils.js";import{subclass as s}from"../../../core/accessorSupport/decorators.js";import{copy as o}from"../../../core/libs/gl-matrix-2/math/mat4.js";import{create as n}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{InternalRenderCategory as m}from"../webgl.js";import{S as a}from"../../../chunks/SimpleAtmosphere.glsl.js";import{SimpleAtmosphereTechnique as p,layout as h}from"./SimpleAtmosphereTechnique.js";import{SimpleAtmosphereTechniqueConfiguration as f}from"./SimpleAtmosphereTechniqueConfiguration.js";import{earthAtmosphereTextureSimple as c}from"./resources/SimpleAtmosphereTexture.js";import{glLayout as l}from"../support/buffer/glUtil.js";import{OpaqueEnvironment as u}from"../webgl-engine/effects/OpaqueEnvironment.js";import{createPolySphereData as b}from"../webgl-engine/lib/GeometryUtil.js";import{VertexArrayObject as g}from"../webgl-engine/lib/VertexArrayObject.js";import{PrimitiveType as _}from"../../webgl/enums.js";import d from"../../webgl/Texture.js";import{TextureDescriptor as v}from"../../webgl/TextureDescriptor.js";import{VertexBuffer as w}from"../../webgl/VertexBuffer.js";let j=class extends u{constructor(){super(...arguments),this._configuration=new f,this._passParameters=new a,this._vao=null,this._vaoCount=0}initialize(){this._configuration.geometry=1,this.addHandles([r(()=>this.view.environment.atmosphereEnabled,e=>e?this._enable():this._disable(),i)])}destroy(){this._passParameters.texture=t(this._passParameters.texture),this._vao=t(this._vao)}precompile(){this.techniques.precompile(p,this._configuration)}render(e){const t=e.find(({name:e})=>e===m.OPAQUE_ENVIRONMENT),r=this.techniques.get(p,this._configuration);if(!r.compiled)return this.requestRender(1),t;const i=this.renderingContext;if(this._vao||(this._vao=x(i),this._vaoCount=this._vao.vertexCount("geometry")),!this._passParameters.texture){const e=new v(1,512);e.wrapMode=33071,e.flipped=!0,this._passParameters.texture=new d(i,e,c)}const s=i.bindTechnique(r,this.bindParameters,this._passParameters);return A(P,this.bindParameters.camera.viewMatrix),s.setUniformMatrix4fv("view",P),i.bindVAO(this._vao),s.assertCompatibleVertexAttributeLocations(this._vao),i.drawArrays(_.TRIANGLES,0,this._vaoCount),t}};function x(e){const t=b(1,2,!1),{data:r,indices:i}=t[0][1],s=h.createBuffer(i.length),o=s.position;for(let n=0;n<i.length;++n){const e=3*i[n%3==0?n+2:n%3==2?n-2:n];o.set(n,0,r[e]),o.set(n,1,r[e+1]),o.set(n,2,r[e+2])}return new g(e,new w(e,l(h),s.buffer))}function A(e,t){o(e,t),e[12]=0,e[13]=0,e[14]=0,e[15]=1}j=e([s("esri.views.3d.environment.LocalAtmosphere")],j);const P=n();export{j as LocalAtmosphere};
2
+ import{__decorate as e}from"tslib";import{disposeMaybe as t}from"../../../core/maybe.js";import{watch as r,initial as i}from"../../../core/reactiveUtils.js";import{subclass as s}from"../../../core/accessorSupport/decorators.js";import{copy as o}from"../../../core/libs/gl-matrix-2/math/mat4.js";import{create as n}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{InternalRenderCategory as m}from"../webgl.js";import{S as a}from"../../../chunks/SimpleAtmosphere.glsl.js";import{SimpleAtmosphereTechnique as p,layout as h}from"./SimpleAtmosphereTechnique.js";import{SimpleAtmosphereTechniqueConfiguration as f}from"./SimpleAtmosphereTechniqueConfiguration.js";import{earthAtmosphereTextureSimple as c}from"./resources/SimpleAtmosphereTexture.js";import{glLayout as l}from"../support/buffer/glUtil.js";import{OpaqueEnvironment as u}from"../webgl-engine/effects/OpaqueEnvironment.js";import{createPolySphereData as b}from"../webgl-engine/lib/GeometryUtil.js";import{VertexArrayObject as g}from"../webgl-engine/lib/VertexArrayObject.js";import{PrimitiveType as _}from"../../webgl/enums.js";import d from"../../webgl/Texture.js";import{TextureDescriptor as v}from"../../webgl/TextureDescriptor.js";import{VertexBuffer as w}from"../../webgl/VertexBuffer.js";let j=class extends u{constructor(){super(...arguments),this._configuration=new f,this._passParameters=new a,this._vao=null,this._vaoCount=0}initialize(){this._configuration.geometry=1,this.addHandles([r(()=>this.view.environment.atmosphereEnabled,e=>e?this._enable():this._disable(),i)])}destroy(){this._passParameters.texture=t(this._passParameters.texture),this._vao=t(this._vao)}precompile(){this.techniques.precompile(p,this._configuration)}render(e){const t=e.find(({name:e})=>e===m.OPAQUE_ENVIRONMENT),r=this.techniques.getCompiled(p,this._configuration);if(!r)return this.requestRender(1),t;const i=this.renderingContext;if(this._vao||(this._vao=x(i),this._vaoCount=this._vao.vertexCount("geometry")),!this._passParameters.texture){const e=new v(1,512);e.wrapMode=33071,e.flipped=!0,this._passParameters.texture=new d(i,e,c)}const s=i.bindTechnique(r,this.bindParameters,this._passParameters);return A(P,this.bindParameters.camera.viewMatrix),s.setUniformMatrix4fv("view",P),i.bindVAO(this._vao),s.assertCompatibleVertexAttributeLocations(this._vao),i.drawArrays(_.TRIANGLES,0,this._vaoCount),t}};function x(e){const t=b(1,2,!1),{data:r,indices:i}=t[0][1],s=h.createBuffer(i.length),o=s.position;for(let n=0;n<i.length;++n){const e=3*i[n%3==0?n+2:n%3==2?n-2:n];o.set(n,0,r[e]),o.set(n,1,r[e+1]),o.set(n,2,r[e+2])}return new g(e,new w(e,l(h),s.buffer))}function A(e,t){o(e,t),e[12]=0,e[13]=0,e[14]=0,e[15]=1}j=e([s("esri.views.3d.environment.LocalAtmosphere")],j);const P=n();export{j as LocalAtmosphere};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import{lerp as t,clamp as r}from"../../../core/mathUtils.js";import{disposeMaybe as s}from"../../../core/maybe.js";import{watch as i,initial as o}from"../../../core/reactiveUtils.js";import{subclass as a}from"../../../core/accessorSupport/decorators.js";import{lookAt as n}from"../../../core/libs/gl-matrix-2/math/mat4.js";import{create as m}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{set as h}from"../../../core/libs/gl-matrix-2/math/vec2.js";import{length as p,scale as c,add as l,distance as u,cross as _,squaredLength as f}from"../../../core/libs/gl-matrix-2/math/vec3.js";import{create as d}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{getReferenceEllipsoid as g}from"../../../geometry/ellipsoidUtils.js";import{newFloatArray as x}from"../../../geometry/support/FloatArray.js";import{InternalRenderCategory as b}from"../webgl.js";import{computeInnerAltitudeFade as j,innerAtmosphereDepth as V}from"./atmosphereUtils.js";import{S as w}from"../../../chunks/SimpleAtmosphere.glsl.js";import{SimpleAtmosphereTechnique as v,layout as P}from"./SimpleAtmosphereTechnique.js";import{SimpleAtmosphereTechniqueConfiguration as R}from"./SimpleAtmosphereTechniqueConfiguration.js";import{marsAtmosphereTextureSimple as A}from"./resources/MarsAtmosphereTexture.js";import{makePiecewiseLinearFunction as y}from"../support/mathUtils.js";import{glLayout as S}from"../support/buffer/glUtil.js";import{OpaqueEnvironment as q}from"../webgl-engine/effects/OpaqueEnvironment.js";import{createQuadVAO as F}from"../webgl-engine/lib/glUtil3D.js";import{project as M}from"../webgl-engine/lib/Util.js";import{VertexArrayObject as T}from"../webgl-engine/lib/VertexArrayObject.js";import{PrimitiveType as U}from"../../webgl/enums.js";import E from"../../webgl/Texture.js";import{TextureDescriptor as O}from"../../webgl/TextureDescriptor.js";import{VertexBuffer as N}from"../../webgl/VertexBuffer.js";const C=128,I=-V,W=0,B=50,D=()=>1-511/512,G=y([[50,.1015625],[500,.21875],[5e3,1-250/512],[5e4,.4140625]]);let L=class extends q{constructor(e){super(e),this._passParameters=new w,this._configuration=new R,this._vao=null,this._fadeVao=null,this._texV1=1;const t=e.view,r=g(t.spatialReference),{outerAtmosphereRimWidth:s,radius:i}=r;this._planetRadius=i,this._innerRimFactor=1+I/i,this._middleRimFactor=1+W/i,this._outerRimFactor=1+s/i,this._texV0=W/s,this._texVScale=this._texV1-this._texV0;const o=t.stage.renderView.techniques;o.precompile(v,this._configuration),this._configuration.geometry=2,o.precompile(v,this._configuration)}initialize(){this.addHandles(i(()=>this.view.environment.atmosphereEnabled,e=>e?this._enable():this._disable(),o))}destroy(){this._passParameters.texture=s(this._passParameters.texture),this._fadeVao=s(this._fadeVao),this._vao=s(this._vao)}render(e){const t=e.find(({name:e})=>e===b.OPAQUE_ENVIRONMENT);this._update();const r=this.renderingContext;if(!this._passParameters.texture){const e=new O(1,512);e.wrapMode=33071,e.flipped=!0,this._passParameters.texture=new E(r,e,A)}if(this._passParameters.undergroundFadeAlpha<1){this._vao??=this._createRibbon(r),this._configuration.geometry=0;const e=this.techniques.get(v,this._configuration);if(!e.compiled)return this.requestRender(1),t;r.bindTechnique(e,this.bindParameters,this._passParameters),r.bindVAO(this._vao),r.drawArrays(U.TRIANGLES,0,this._vao.vertexCount("geometry"))}if(this._passParameters.undergroundFadeAlpha>0){this._fadeVao??=F(r),this._configuration.geometry=2;const e=this.techniques.get(v,this._configuration);if(!e.compiled)return this.requestRender(1),t;r.bindTechnique(e,this.bindParameters,this._passParameters),r.bindVAO(this._fadeVao),r.drawArrays(U.TRIANGLE_STRIP,0,this._fadeVao.vertexCount("geometry"))}return t}_update(){const e=this.bindParameters.camera,s=d(),i=this._planetRadius,o=p(e.eye),a=o-i;if(a<0){const e=Math.min(-a/5e3,1);this._passParameters.undergroundFadeAlpha=e}else this._passParameters.undergroundFadeAlpha=0;const n=Math.max(B,a),m=i+I;this._passParameters.innerScale=J(i+n,i,m)-1,this._passParameters.altitudeFade=j(a),c(s,e.eye,(i+B)/o),k(s,e.center,e.up,i,this._passParameters.silhouette);const l=this._computeScreenRimWidth(e,s,e.up,this._passParameters.silhouette),u=D(),_=G(a);let f=this._texV0+u*this._texVScale,g=this._texV0+l*_*this._texVScale;if(a>B){k(e.eye,e.center,e.up,i,this._passParameters.silhouette);const s=this._computeScreenRimWidth(e,e.eye,e.up,this._passParameters.silhouette),o=r((s-1.5)/(l-1.5),0,1);f=this._texV0+o*u*this._texVScale,g=this._texV0+t(this._texV1,l*_,o)*this._texVScale}h(this._passParameters.texV,f,g)}_createRibbon(e){const t=x(3+3*C*3),r=new Uint32Array(3*C*5);t[0]=0,t[1]=0,t[2]=-1;for(let o=0;o<C;o++){const e=9*o+3;t[e]=o,t[e+1]=this._innerRimFactor,t[e+2]=-1,t[e+3]=o,t[e+4]=this._middleRimFactor,t[e+5]=0,t[e+6]=o,t[e+7]=this._outerRimFactor,t[e+8]=1;const s=3*o+1,i=o===C-1?1:s+3,a=15*o;r[a]=s,r[a+1]=s+1,r[a+2]=i+1,r[a+3]=i+1,r[a+4]=i,r[a+5]=s,r[a+6]=s+1,r[a+7]=s+2,r[a+8]=i+2,r[a+9]=i+2,r[a+10]=i+1,r[a+11]=s+1,r[a+12]=s,r[a+13]=i,r[a+14]=0}const s=P.createBuffer(r.length),i=s.position;for(let o=0;o<r.length;++o){const e=3*r[o];i.set(o,0,t[e]),i.set(o,1,t[e+1]),i.set(o,2,t[e+2])}return new T(e,new N(e,S(P),s.buffer))}_computeScreenRimWidth(e,t,r,s){return l(H,s.center,s.v2),c(Q,H,this._outerRimFactor),n(z,t,H,r),M(H,z,e.projectionMatrix,e.viewport,H),M(Q,z,e.projectionMatrix,e.viewport,Q),u(H,Q)/e.height}};function k(e,t,r,s,i){const o=p(e),a=s*Math.sqrt(o*o-s*s)/o,n=Math.sqrt(s*s-a*a),m=i.v1,h=i.v2;return c(i.center,e,n/o),_(m,e,t),f(m)<1&&_(m,e,r),c(m,m,a/p(m)),_(h,m,e),c(h,h,a/p(h)),a}L=e([a("esri.views.3d.environment.MarsAtmosphere")],L);const z=m(),H=d(),Q=d();function J(e,t,r){return e*e/(Math.sqrt(e*e-t*t)*Math.sqrt(e*e-r*r)+t*r)}export{L as MarsAtmosphere};
2
+ import{__decorate as e}from"tslib";import{lerp as t,clamp as r}from"../../../core/mathUtils.js";import{disposeMaybe as s}from"../../../core/maybe.js";import{watch as i,initial as o}from"../../../core/reactiveUtils.js";import{subclass as a}from"../../../core/accessorSupport/decorators.js";import{lookAt as n}from"../../../core/libs/gl-matrix-2/math/mat4.js";import{create as m}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{set as h}from"../../../core/libs/gl-matrix-2/math/vec2.js";import{length as p,scale as c,add as l,distance as u,cross as _,squaredLength as f}from"../../../core/libs/gl-matrix-2/math/vec3.js";import{create as d}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{getReferenceEllipsoid as g}from"../../../geometry/ellipsoidUtils.js";import{newFloatArray as x}from"../../../geometry/support/FloatArray.js";import{InternalRenderCategory as b}from"../webgl.js";import{computeInnerAltitudeFade as j,innerAtmosphereDepth as V}from"./atmosphereUtils.js";import{S as w}from"../../../chunks/SimpleAtmosphere.glsl.js";import{SimpleAtmosphereTechnique as v,layout as P}from"./SimpleAtmosphereTechnique.js";import{SimpleAtmosphereTechniqueConfiguration as R}from"./SimpleAtmosphereTechniqueConfiguration.js";import{marsAtmosphereTextureSimple as A}from"./resources/MarsAtmosphereTexture.js";import{makePiecewiseLinearFunction as y}from"../support/mathUtils.js";import{glLayout as S}from"../support/buffer/glUtil.js";import{OpaqueEnvironment as q}from"../webgl-engine/effects/OpaqueEnvironment.js";import{createQuadVAO as F}from"../webgl-engine/lib/glUtil3D.js";import{project as M}from"../webgl-engine/lib/Util.js";import{VertexArrayObject as T}from"../webgl-engine/lib/VertexArrayObject.js";import{PrimitiveType as U}from"../../webgl/enums.js";import E from"../../webgl/Texture.js";import{TextureDescriptor as C}from"../../webgl/TextureDescriptor.js";import{VertexBuffer as O}from"../../webgl/VertexBuffer.js";const N=128,I=-V,W=0,B=50,D=()=>1-511/512,G=y([[50,.1015625],[500,.21875],[5e3,1-250/512],[5e4,.4140625]]);let L=class extends q{constructor(e){super(e),this._passParameters=new w,this._configuration=new R,this._vao=null,this._fadeVao=null,this._texV1=1;const t=e.view,r=g(t.spatialReference),{outerAtmosphereRimWidth:s,radius:i}=r;this._planetRadius=i,this._innerRimFactor=1+I/i,this._middleRimFactor=1+W/i,this._outerRimFactor=1+s/i,this._texV0=W/s,this._texVScale=this._texV1-this._texV0;const o=t.stage.renderView.techniques;o.precompile(v,this._configuration),this._configuration.geometry=2,o.precompile(v,this._configuration)}initialize(){this.addHandles(i(()=>this.view.environment.atmosphereEnabled,e=>e?this._enable():this._disable(),o))}destroy(){this._passParameters.texture=s(this._passParameters.texture),this._fadeVao=s(this._fadeVao),this._vao=s(this._vao)}render(e){const t=e.find(({name:e})=>e===b.OPAQUE_ENVIRONMENT);this._update();const r=this.renderingContext;if(!this._passParameters.texture){const e=new C(1,512);e.wrapMode=33071,e.flipped=!0,this._passParameters.texture=new E(r,e,A)}if(this._passParameters.undergroundFadeAlpha<1){this._vao??=this._createRibbon(r),this._configuration.geometry=0;const e=this.techniques.getCompiled(v,this._configuration);if(!e)return this.requestRender(1),t;r.bindTechnique(e,this.bindParameters,this._passParameters),r.bindVAO(this._vao),r.drawArrays(U.TRIANGLES,0,this._vao.vertexCount("geometry"))}if(this._passParameters.undergroundFadeAlpha>0){this._fadeVao??=F(r),this._configuration.geometry=2;const e=this.techniques.getCompiled(v,this._configuration);if(!e)return this.requestRender(1),t;r.bindTechnique(e,this.bindParameters,this._passParameters),r.bindVAO(this._fadeVao),r.drawArrays(U.TRIANGLE_STRIP,0,this._fadeVao.vertexCount("geometry"))}return t}_update(){const e=this.bindParameters.camera,s=d(),i=this._planetRadius,o=p(e.eye),a=o-i;if(a<0){const e=Math.min(-a/5e3,1);this._passParameters.undergroundFadeAlpha=e}else this._passParameters.undergroundFadeAlpha=0;const n=Math.max(B,a),m=i+I;this._passParameters.innerScale=J(i+n,i,m)-1,this._passParameters.altitudeFade=j(a),c(s,e.eye,(i+B)/o),k(s,e.center,e.up,i,this._passParameters.silhouette);const l=this._computeScreenRimWidth(e,s,e.up,this._passParameters.silhouette),u=D(),_=G(a);let f=this._texV0+u*this._texVScale,g=this._texV0+l*_*this._texVScale;if(a>B){k(e.eye,e.center,e.up,i,this._passParameters.silhouette);const s=this._computeScreenRimWidth(e,e.eye,e.up,this._passParameters.silhouette),o=r((s-1.5)/(l-1.5),0,1);f=this._texV0+o*u*this._texVScale,g=this._texV0+t(this._texV1,l*_,o)*this._texVScale}h(this._passParameters.texV,f,g)}_createRibbon(e){const t=x(3+3*N*3),r=new Uint32Array(3*N*5);t[0]=0,t[1]=0,t[2]=-1;for(let o=0;o<N;o++){const e=9*o+3;t[e]=o,t[e+1]=this._innerRimFactor,t[e+2]=-1,t[e+3]=o,t[e+4]=this._middleRimFactor,t[e+5]=0,t[e+6]=o,t[e+7]=this._outerRimFactor,t[e+8]=1;const s=3*o+1,i=o===N-1?1:s+3,a=15*o;r[a]=s,r[a+1]=s+1,r[a+2]=i+1,r[a+3]=i+1,r[a+4]=i,r[a+5]=s,r[a+6]=s+1,r[a+7]=s+2,r[a+8]=i+2,r[a+9]=i+2,r[a+10]=i+1,r[a+11]=s+1,r[a+12]=s,r[a+13]=i,r[a+14]=0}const s=P.createBuffer(r.length),i=s.position;for(let o=0;o<r.length;++o){const e=3*r[o];i.set(o,0,t[e]),i.set(o,1,t[e+1]),i.set(o,2,t[e+2])}return new T(e,new O(e,S(P),s.buffer))}_computeScreenRimWidth(e,t,r,s){return l(H,s.center,s.v2),c(Q,H,this._outerRimFactor),n(z,t,H,r),M(H,z,e.projectionMatrix,e.viewport,H),M(Q,z,e.projectionMatrix,e.viewport,Q),u(H,Q)/e.height}};function k(e,t,r,s,i){const o=p(e),a=s*Math.sqrt(o*o-s*s)/o,n=Math.sqrt(s*s-a*a),m=i.v1,h=i.v2;return c(i.center,e,n/o),_(m,e,t),f(m)<1&&_(m,e,r),c(m,m,a/p(m)),_(h,m,e),c(h,h,a/p(h)),a}L=e([a("esri.views.3d.environment.MarsAtmosphere")],L);const z=m(),H=d(),Q=d();function J(e,t,r){return e*e/(Math.sqrt(e*e-t*t)*Math.sqrt(e*e-r*r)+t*r)}export{L as MarsAtmosphere};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{__decorate as t}from"tslib";import e from"../../../core/Accessor.js";import{disposeMaybe as r}from"../../../core/maybe.js";import{subclass as o}from"../../../core/accessorSupport/decorators.js";import{property as s}from"../../../core/accessorSupport/decorators/property.js";import{equals as i,copy as n}from"../../../core/libs/gl-matrix-2/math/vec2.js";import{N as c}from"../../../chunks/NoiseTextureAtlas.glsl.js";import{NoiseTextureAtlasTechniqueConfiguration as a}from"./NoiseTextureAtlasConfiguration.js";import{atlasSize as u}from"./NoiseTextureAtlasDimensions.js";import{NoiseTextureAtlasTechnique as h}from"./NoiseTextureAtlasTechnique.js";import{FramebufferObject as m}from"../../webgl/FramebufferObject.js";import{TextureDescriptor as p}from"../../webgl/TextureDescriptor.js";let f=class extends e{constructor(t){super(t),this._passParameters=new c,this._configuration=new a,this._fbo=new m(t.context.renderContext.rctx,new p(u)),t.context.techniques.precompile(h,this._configuration)}get textureAtlas(){if(this._texture)return this._texture;const t=this.context.techniques.get(h,this._configuration);return t.compiled&&(this._texture=this._render(t)),this._texture}updateWeatherMap(t){i(this._passParameters.weatherTile,t)||(n(this._passParameters.weatherTile,t),this._configuration.mode=this._texture?1:0,this._texture=null,this.context.techniques.precompile(h,this._configuration))}destroy(){this._fbo=r(this._fbo)}_render(t){if(!this._fbo)return null;const e=this.context.renderContext.rctx,r=e.getViewport();return e.setViewport(0,0,u,u),e.bindFramebuffer(this._fbo),e.bindTechnique(t,this.context.renderContext.bind,this._passParameters),e.screen.draw(),e.setViewport(r.x,r.y,r.width,r.height),this._fbo.colorTexture}};t([s({constructOnly:!0})],f.prototype,"context",void 0),f=t([o("esri.views.3d.environment.NoiseTextureAtlas")],f);export{f as NoiseTextureAtlas};
2
+ import{__decorate as t}from"tslib";import e from"../../../core/Accessor.js";import{disposeMaybe as r}from"../../../core/maybe.js";import{subclass as o}from"../../../core/accessorSupport/decorators.js";import{property as s}from"../../../core/accessorSupport/decorators/property.js";import{equals as i,copy as n}from"../../../core/libs/gl-matrix-2/math/vec2.js";import{N as c}from"../../../chunks/NoiseTextureAtlas.glsl.js";import{NoiseTextureAtlasTechniqueConfiguration as a}from"./NoiseTextureAtlasConfiguration.js";import{atlasSize as u}from"./NoiseTextureAtlasDimensions.js";import{NoiseTextureAtlasTechnique as h}from"./NoiseTextureAtlasTechnique.js";import{FramebufferObject as m}from"../../webgl/FramebufferObject.js";import{TextureDescriptor as p}from"../../webgl/TextureDescriptor.js";let f=class extends e{constructor(t){super(t),this._passParameters=new c,this._configuration=new a,this._fbo=new m(t.context.renderContext.rctx,new p(u)),t.context.techniques.precompile(h,this._configuration)}get textureAtlas(){if(this._texture)return this._texture;const t=this.context.techniques.getCompiled(h,this._configuration);return t&&(this._texture=this._render(t)),this._texture}updateWeatherMap(t){i(this._passParameters.weatherTile,t)||(n(this._passParameters.weatherTile,t),this._configuration.mode=this._texture?1:0,this._texture=null,this.context.techniques.precompile(h,this._configuration))}destroy(){this._fbo=r(this._fbo)}_render(t){if(!this._fbo)return null;const e=this.context.renderContext.rctx,r=e.getViewport();return e.setViewport(0,0,u,u),e.bindFramebuffer(this._fbo),e.bindTechnique(t,this.context.renderContext.bind,this._passParameters),e.screen.draw(),e.setViewport(r.x,r.y,r.width,r.height),this._fbo.colorTexture}};t([s({constructOnly:!0})],f.prototype,"context",void 0),f=t([o("esri.views.3d.environment.NoiseTextureAtlas")],f);export{f as NoiseTextureAtlas};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import{lerp as t}from"../../../core/mathUtils.js";import{disposeMaybe as s}from"../../../core/maybe.js";import{watch as i,syncAndInitial as r,sync as n}from"../../../core/reactiveUtils.js";import{secondsFromMilliseconds as o}from"../../../core/time.js";import{property as a,subclass as d}from"../../../core/accessorSupport/decorators.js";import{getReferenceEllipsoid as c}from"../../../geometry/ellipsoidUtils.js";import{getContinuousIndexArray as m}from"../../../geometry/support/Indices.js";import{InternalRenderCategory as p}from"../webgl.js";import{PrecipitationPassParameters as h,PrecipitationTechnique as f}from"./PrecipitationTechnique.js";import{PrecipitationTechniqueConfiguration as u}from"./PrecipitationTechniqueConfiguration.js";import{glLayout as l}from"../support/buffer/glUtil.js";import{newLayout as _}from"../support/buffer/InterleavedLayout.js";import{TransparentEnvironment as b}from"../webgl-engine/effects/TransparentEnvironment.js";import{VertexArrayObject as y}from"../webgl-engine/lib/VertexArrayObject.js";import{PrimitiveType as w}from"../../webgl/enums.js";import{bindVertexBufferLayout as v}from"../../webgl/Util.js";import{fromLayout as g}from"../../webgl/VertexAttributeLocations.js";import{VertexBuffer as P}from"../../webgl/VertexBuffer.js";let j=class extends b{constructor(e){super(e),this._hasSnowCover=!1,this._rainSpeed=.1,this._snowSpeed=.01,this._numParticles=0,this._passParameters=new h,this._configuration=new u;const{view:t,type:s}=e;this._configuration.type="rainy"===s?0:1,t.stage.renderView.techniques.precompile(f,this._configuration),this._passParameters.time=0,this._passParameters.radius=c(t.spatialReference).radius,this.addHandles([i(()=>t.environment.weather,e=>{e.type===s&&this.addHandles([i(()=>e.precipitation,e=>this._adjustParticles(e),r),i(()=>"snowy"===e.type&&"enabled"===e.snowCover,e=>this._hasSnowCover=e,r)])},r)]),this.addHandles(i(()=>t.stage?.renderer.renderContext.bind.clouds.fadeFactor??1,e=>{this._passParameters.opacity=e,1===e&&(this.removeHandles("opacity"),this.addHandles(i(()=>t.stage?.renderer.renderContext.bind.clouds.opacity??1,e=>this._passParameters.opacity=e,r),"opacity"))},n),"opacity")}initialize(){this.addHandles([i(()=>this.view.environment.atmosphereEnabled,e=>e?this._enable():this._disable(),r)])}_adjustParticles(e){const s=.35,i=e<.5?t(0,s,2*e):t(s,1,2*(e-.5));this._numParticles=A*i}destroy(){this._numParticles=0,this._vao=s(this._vao),this._instanceIdBuffer=s(this._instanceIdBuffer)}fadeOut(e){this.removeAllHandles(),this.addHandles(i(()=>this.renderContext?.bind.clouds.fadeFactor??1,t=>{this._passParameters.opacity=1-t,1===t&&(this.removeAllHandles(),e())}),"opacity")}get snowCover(){return this._hasSnowCover?this._passParameters.opacity:null}updateAnimation(e){const t=("rainy"===this.type?this._rainSpeed:this._snowSpeed)*o(e.time)%1e5;return this._passParameters.time!==t&&(this._passParameters.time=t,!0)}render(e){const t=this.renderingContext,s=Math.round(this._numParticles*this._passParameters.opacity),i=e.find(({name:e})=>e===p.TRANSPARENT_ENVIRONMENT);if(s<1)return i;const r=this.techniques.get(f,this._configuration);if(!r.compiled)return this.requestRender(1),i;const n=t.bindTechnique(r,this.bindParameters,this._passParameters);return this._vao??=I(t),t.bindVAO(this._vao),this._bindInstanceIdBuffer(n.locations),n.assertCompatibleVertexAttributeLocations(this._vao,g(x)),t.drawArraysInstanced(w.TRIANGLES,0,3,s),t.unbindBuffer(34962),i}_bindInstanceIdBuffer(e){const t=this.renderingContext;if(this._instanceIdBuffer)return void t.bindBuffer(this._instanceIdBuffer);const s=m(A);this._instanceIdBuffer=new P(t,x,new Float32Array(s)),v(t,e,this._instanceIdBuffer,0)}};function I(e){const t=new Float32Array([-1,0,1,1,0,-1,1,0,1]);return new y(e,new P(e,l(C),t))}e([a({constructOnly:!0})],j.prototype,"type",void 0),j=e([d("esri.views.3d.environment.Precipitation")],j);const A=25e4,C=_().vec3f("position").freeze(),x=l(_().f32("instanceFeatureAttribute"),1);export{j as Precipitation};
2
+ import{__decorate as e}from"tslib";import{lerp as t}from"../../../core/mathUtils.js";import{disposeMaybe as i}from"../../../core/maybe.js";import{watch as s,syncAndInitial as r,sync as n}from"../../../core/reactiveUtils.js";import{secondsFromMilliseconds as o}from"../../../core/time.js";import{property as a,subclass as d}from"../../../core/accessorSupport/decorators.js";import{getReferenceEllipsoid as c}from"../../../geometry/ellipsoidUtils.js";import{getContinuousIndexArray as p}from"../../../geometry/support/Indices.js";import{InternalRenderCategory as m}from"../webgl.js";import{PrecipitationPassParameters as h,PrecipitationTechnique as f}from"./PrecipitationTechnique.js";import{PrecipitationTechniqueConfiguration as u}from"./PrecipitationTechniqueConfiguration.js";import{glLayout as l}from"../support/buffer/glUtil.js";import{newLayout as _}from"../support/buffer/InterleavedLayout.js";import{TransparentEnvironment as b}from"../webgl-engine/effects/TransparentEnvironment.js";import{VertexArrayObject as y}from"../webgl-engine/lib/VertexArrayObject.js";import{PrimitiveType as w}from"../../webgl/enums.js";import{bindVertexBufferLayout as v}from"../../webgl/Util.js";import{fromLayout as g}from"../../webgl/VertexAttributeLocations.js";import{VertexBuffer as P}from"../../webgl/VertexBuffer.js";let j=class extends b{constructor(e){super(e),this._hasSnowCover=!1,this._rainSpeed=.1,this._snowSpeed=.01,this._numParticles=0,this._passParameters=new h,this._configuration=new u;const{view:t,type:i}=e;this._configuration.type="rainy"===i?0:1,this._passParameters.time=0,this._passParameters.radius=c(t.spatialReference).radius,this.addHandles([s(()=>t.environment.weather,e=>{e.type===i&&this.addHandles([s(()=>e.precipitation,e=>this._adjustParticles(e),r),s(()=>"snowy"===e.type&&"enabled"===e.snowCover,e=>this._hasSnowCover=e,r)])},r)]),this.addHandles(s(()=>t.stage?.renderer.renderContext.bind.clouds.fadeFactor??1,e=>{this._passParameters.opacity=e,1===e&&(this.removeHandles("opacity"),this.addHandles(s(()=>t.stage?.renderer.renderContext.bind.clouds.opacity??1,e=>this._passParameters.opacity=e,r),"opacity"))},n),"opacity")}initialize(){this.addHandles([s(()=>this.view.environment.atmosphereEnabled,e=>e?this._enable():this._disable(),r)])}_adjustParticles(e){const i=.35,s=e<.5?t(0,i,2*e):t(i,1,2*(e-.5));this._numParticles=A*s}destroy(){this._numParticles=0,this._vao=i(this._vao),this._instanceIdBuffer=i(this._instanceIdBuffer)}fadeOut(e){this.removeAllHandles(),this.addHandles(s(()=>this.renderContext?.bind.clouds.fadeFactor??1,t=>{this._passParameters.opacity=1-t,1===t&&(this.removeAllHandles(),e())}),"opacity")}get snowCover(){return this._hasSnowCover?this._passParameters.opacity:null}updateAnimation(e){const t=("rainy"===this.type?this._rainSpeed:this._snowSpeed)*o(e.time)%1e5;return this._passParameters.time!==t&&(this._passParameters.time=t,!0)}precompile(){this.view.stage.renderView.techniques.precompile(f,this._configuration)}render(e){const t=e.find(({name:e})=>e===m.TRANSPARENT_ENVIRONMENT),i=this.techniques.getCompiled(f,this._configuration);if(!i)return this.requestRender(1),t;const s=Math.round(this._numParticles*this._passParameters.opacity);if(s<1)return t;const r=this.renderingContext,n=r.bindTechnique(i,this.bindParameters,this._passParameters);return this._vao??=I(r),r.bindVAO(this._vao),this._bindInstanceIdBuffer(n.locations),n.assertCompatibleVertexAttributeLocations(this._vao,g(x)),r.drawArraysInstanced(w.TRIANGLES,0,3,s),r.unbindBuffer(34962),t}_bindInstanceIdBuffer(e){const t=this.renderingContext;if(this._instanceIdBuffer)return void t.bindBuffer(this._instanceIdBuffer);const i=p(A);this._instanceIdBuffer=new P(t,x,new Float32Array(i)),v(t,e,this._instanceIdBuffer,0)}};function I(e){const t=new Float32Array([-1,0,1,1,0,-1,1,0,1]);return new y(e,new P(e,l(C),t))}e([a({constructOnly:!0})],j.prototype,"type",void 0),j=e([d("esri.views.3d.environment.Precipitation")],j);const A=25e4,C=_().vec3f("position").freeze(),x=l(_().f32("instanceFeatureAttribute"),1);export{j as Precipitation};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import{subclass as r}from"../../../core/accessorSupport/decorators.js";import{P as t}from"../../../chunks/Precipitation.glsl.js";import{ReloadableShader as i}from"../webgl-engine/core/shaderTechnique/ReloadableShader.js";import{ShaderTechnique as s}from"../webgl-engine/core/shaderTechnique/ShaderTechnique.js";import{DataType as o}from"../../webgl/enums.js";import{NoParameters as n}from"../../webgl/NoParameters.js";import{makePipelineState as c,defaultColorWrite as m,premultipliedAlpha as a}from"../../webgl/renderState.js";import{VertexElementDescriptor as p}from"../../webgl/VertexElementDescriptor.js";class l extends n{constructor(){super(...arguments),this.time=0,this.radius=1,this.width=500,this.opacity=0}}let h=class extends s{constructor(e,r){super(e,r,[new p("position",2,o.FLOAT,0,16),new p("instanceFeatureAttribute",2,o.FLOAT,8,16)]),this.shader=new i(t,()=>import("./Precipitation.glsl.js")),this.ignoreUnused=!0}initializePipeline(){return c({blending:a,depthTest:{func:515},colorWrite:m})}};h=e([r("esri.views.3d.environment.PrecipitationTechnique")],h);export{l as PrecipitationPassParameters,h as PrecipitationTechnique};
2
+ import{__decorate as e}from"tslib";import{subclass as r}from"../../../core/accessorSupport/decorators.js";import{P as t}from"../../../chunks/Precipitation.glsl.js";import{ReloadableShader as i}from"../webgl-engine/core/shaderTechnique/ReloadableShader.js";import{ShaderTechnique as s}from"../webgl-engine/core/shaderTechnique/ShaderTechnique.js";import{DataType as o}from"../../webgl/enums.js";import{NoParameters as n}from"../../webgl/NoParameters.js";import{makePipelineState as c,defaultColorWrite as m,premultipliedAlpha as a}from"../../webgl/renderState.js";import{VertexElementDescriptor as p}from"../../webgl/VertexElementDescriptor.js";class l extends n{constructor(){super(...arguments),this.time=0,this.radius=1,this.width=500,this.opacity=0}}let h=class extends s{constructor(e,r){super(e,r,[new p("position",2,o.FLOAT,0,16),new p("instanceFeatureAttribute",2,o.FLOAT,8,16)]),this.shader=new i(t,()=>import("./Precipitation.glsl.js"))}initializePipeline(){return c({blending:a,depthTest:{func:515},colorWrite:m})}};h=e([r("esri.views.3d.environment.PrecipitationTechnique")],h);export{l as PrecipitationPassParameters,h as PrecipitationTechnique};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import t from"../../../core/Error.js";import{makeHandle as i,handlesGroup as r,destroyHandle as n}from"../../../core/handleUtils.js";import"../../../core/has.js";import{isIterable as s}from"../../../core/iteratorUtils.js";import{getProjectiveTransform as a}from"../../../core/perspectiveUtils.js";import{debounce as o,isPromiseLike as d}from"../../../core/promiseUtils.js";import{watch as l,syncAndInitial as h,on as m}from"../../../core/reactiveUtils.js";import{property as c,subclass as p}from"../../../core/accessorSupport/decorators.js";import{create as g}from"../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{toExtent as u}from"../../../geometry/support/aaBoundingRect.js";import{MediaElementView as y}from"../../../layers/support/MediaElementView.js";import{LayerView3D as _}from"./LayerView3D.js";import{MediaLayerInteraction as f}from"./support/MediaLayerInteraction.js";import{drapedZ as v}from"../terrain/OverlayRenderer.js";import{Attribute as w}from"../webgl-engine/lib/Attribute.js";import{Geometry as E}from"../webgl-engine/lib/Geometry.js";import{ManagedTexture as D}from"../webgl-engine/lib/ManagedTexture.js";import{Object3DHighlightStateID as R}from"../webgl-engine/lib/Object3DStateID.js";import{RenderGeometry as b}from"../webgl-engine/lib/RenderGeometry.js";import{Parameters as j,ImageMaterial as M}from"../webgl-engine/materials/ImageMaterial.js";import x from"../../layers/LayerView.js";import{MediaLayerViewMixin as A}from"../../layers/MediaLayerViewMixin.js";import{getHighlightName as H}from"../../support/highlightOptionsUtils.js";import{isInEffectiveScaleRange as G}from"../../support/layerViewUtils.js";let S=class extends(_(A(x))){get interactive(){return this._interaction.enabled}set interactive(e){this._interaction&&(this._interaction.enabled=e)}get selectedElement(){return this._interaction.selectedElement}set selectedElement(e){this._interaction&&(this._interaction.selectedElement=e)}get visibleAtCurrentScale(){return G(this.layer.effectiveScaleRange,this.view.scale)}get usedMemory(){return Array.from(this._renderElements.values()).reduce((e,t)=>e+(t.getRenderData()?.texture.usedMemory??0),0)}constructor(e){super(e),this.type="media-3d",this.drapeSourceType=1,this.updatePolicy=1,this.ignoresMemoryFactor=!0,this.unloadedMemory=0,this._uidToElement=new Map,this._highlightedElements=new Map,this._elementsInHighlightedId=new Map,this._renderElements=new Map,this._lastDrapingExtent=null,this._update=o(async(e,t,i)=>{const r=await this._collectMediaElements(e,t,i);this._synchronizeRenderElements(r)},0);const{view:t,layer:i}=e;this._interaction=new f({view:t,layer:i}),this.addHandles(l(()=>this.interactionOptions,e=>this._interaction.options=e,h))}initialize(){const{view:e,layer:t}=this;this._renderer=e.overlayManager.registerGeometryDrapeSource(this);const r=()=>this._updateWithLastDrapingExtent();this.addHandles([i(()=>e.overlayManager.unregisterDrapeSource(this)),m(()=>t.effectiveSource,"change",r),m(()=>t.effectiveSource,"refresh",r)]),this._updatingHandles.add(()=>this.suspended,r)}destroy(){this._synchronizeRenderElements(new Set)}setDrapingExtent(e,t){this._lastDrapingExtent={overlays:e,spatialReference:t},this._updateWithLastDrapingExtent()}getHit(e){const t=this._uidToElement.get(e);return t?{type:"media",element:t,layer:this.layer}:null}highlight(e,t){const r=H(t),n=new R(r),a=s(e)?Array.from(e):[e];this._elementsInHighlightedId.set(n,a);for(const i of a){const e=this._highlightedElements.get(i);e?e.add(n):this._highlightedElements.set(i,new Set([n]));const t=this._renderElements.get(i)?.getRenderData();t&&(t.renderGeometry.geometry.addHighlight(n),this._renderer.modifyGeometries([t.renderGeometry],8))}return i(()=>{const e=this._elementsInHighlightedId.get(n);if(e){for(const t of e){const e=this._highlightedElements.get(t);if(!e)continue;e.delete(n);const i=this._renderElements.get(t)?.getRenderData();i&&(i.renderGeometry.geometry.removeHighlight(n),this._renderer.modifyGeometries([i.renderGeometry],8)),0===e.size&&this._highlightedElements.delete(t)}this._elementsInHighlightedId.delete(n)}})}isUpdating(){return super.isUpdating()||this._interaction.updating}_updateWithLastDrapingExtent(){if(null==this._lastDrapingExtent||this.suspended)return void(this._renderer&&this._synchronizeRenderElements(new Set));const{overlays:e,spatialReference:t}=this._lastDrapingExtent;this._updatingHandles.consumePromise(this._update(e,t))}async _collectMediaElements(e,t,i){const r=this.layer.effectiveSource;return null==r?new Set:new Set((await Promise.all(e.map(e=>r.queryElements(u(e.extent,t),{signal:i})))).flat())}_synchronizeRenderElements(e){this._synchronizeRenderElementsRemove(e),this._synchronizeRenderElementsAdd(e)}_synchronizeRenderElementsRemove(e){this._renderElements.forEach((t,i)=>{e.has(i)||(this._removeElement(i,t),this.emit("element-render-changed",{element:i}))})}_synchronizeRenderElementsAdd(e){for(const t of e)this._renderElements.has(t)||this._createRenderElement(t)}_removeElement(e,t){this._destroyRenderData(e,t),this._renderElements.delete(e),this._uidToElement.delete(e.uid),t.handle.remove()}_createRenderElement(e){const t=new y({spatialReference:this.view.spatialReference,element:e}),i=new z(r([this._updatingHandles.add(()=>e.opacity,e=>i.getRenderData()?.material.setParameters({opacity:e})),this._updatingHandles.add(()=>t.coords,()=>{i.data?this._updateGeometry(t,i):this._initializeRenderData(t,i)}),this._updatingHandles.add(()=>e.content,()=>this._initializeRenderData(t,i)),n(t)]));this._renderElements.set(e,i),this._uidToElement.set(e.uid,e),this._updatingHandles.consumePromise(e.load()),this._initializeRenderData(t,i)}_initializeRenderData(e,t){const{coords:i,element:r}=e,{contentWidth:n,contentHeight:s}=r;if(null==i||null==r.content)return void this._destroyRenderData(r,t);if(t.data)return;const a=this._createTexture(r.content),o=a.load(this.view.stage.renderView.renderingContext),l=()=>{if(!a.loaded)return;this.view.stage.addTexture(a);const e=new j(a,!0);e.opacity=r.opacity,e.perspectiveInterpolation=!0;const o=new M(e),d=this._getPositionAttributeArray(i),l=[0,0,1,0,1,1,0,1],h=this._getPerspectiveDivideAttributeArray(d,n,s),m=[0,1,2,0,2,3],c=new E(o,[["position",new w(d,m,3,!0)],["uv0",new w(l,m,2,!0)],["perspectiveDivide",new w(h,m,1,!0)]]),p=new b(c,{layerViewUid:this.uid,graphicUid:r.uid}),g=this._highlightedElements.get(r);g?.forEach(e=>p.geometry.addHighlight(e)),this._renderer.addGeometries([p],0),t.data=new P(p,a,o),this.emit("element-render-changed",{element:r})};d(o)?(t.data=a,this._updatingHandles.consumePromise(o),o.then(l).catch(()=>a.dispose())):l()}_updateGeometry(e,t){const{coords:i,element:r}=e;if(null==i||null==r.content)return void this._destroyRenderData(r,t);const n=t.getRenderData();if(!n)return;const s=this._getPositionAttributeArray(i);n.renderGeometry.geometry.setAttributeData("position",s);const a=this._getPerspectiveDivideAttributeArray(s,r.contentWidth,r.contentHeight);n.renderGeometry.geometry.setAttributeData("perspectiveDivide",a),n.renderGeometry.geometry.invalidateBoundingInfo(),this._renderer.modifyGeometries([n.renderGeometry],2),this.emit("element-render-changed",{element:r})}_getPositionAttributeArray(e){const[t,i,r,n]=e.rings[0];return[t[0],t[1],v,n[0],n[1],v,r[0],r[1],v,i[0],i[1],v]}_getPerspectiveDivideAttributeArray(e,t,i){a(I,[0,0,t,0,t,i,0,i],[e[0],e[1],e[3],e[4],e[6],e[7],e[9],e[10]]);const r=I[6]/I[8]*t,n=I[7]/I[8]*i;return[1,1+r,1+r+n,1+n]}_destroyRenderData(e,t){const i=t.data;if(null==i)return;if(t.data=null,"dispose"in i)return void i.dispose();const r=i.texture;r.unload(),this.view.stage.removeTexture(r),this._renderer.removeGeometries([i.renderGeometry],2),this.emit("element-render-changed",{element:e})}_createTexture(e){const i=e instanceof HTMLImageElement?e.naturalWidth:e.width,r=e instanceof HTMLImageElement?e.naturalHeight:e.height;if("getFrame"in e)throw new t("media-layer-view-3d","animation is not supported");return new D(e,{wrap:{s:33071,t:33071},preMultiplyAlpha:!0,width:i,height:r,mipmap:!0,updateCallback:()=>this.view.overlayManager.requestRender()})}get test(){}};e([c({readOnly:!0})],S.prototype,"type",void 0),e([c()],S.prototype,"layer",void 0),e([c()],S.prototype,"interactive",null),e([c()],S.prototype,"selectedElement",null),e([c({readOnly:!0})],S.prototype,"visibleAtCurrentScale",null),S=e([p("esri.views.3d.layers.MediaLayerView3D")],S);const I=g();class z{constructor(e){this.handle=e}getRenderData(){return this.data&&"type"in this.data&&"RenderData"===this.data.type?this.data:null}}class P{constructor(e,t,i){this.renderGeometry=e,this.texture=t,this.material=i,this.type="RenderData"}}const T=S;export{T as default};
2
+ import{__decorate as e}from"tslib";import t from"../../../core/Error.js";import{makeHandle as i,handlesGroup as r,destroyHandle as n}from"../../../core/handleUtils.js";import"../../../core/has.js";import{isIterable as s}from"../../../core/iteratorUtils.js";import{getProjectiveTransform as a}from"../../../core/perspectiveUtils.js";import{debounce as o,isPromiseLike as d}from"../../../core/promiseUtils.js";import{watch as l,syncAndInitial as h,on as m}from"../../../core/reactiveUtils.js";import{property as c,subclass as p}from"../../../core/accessorSupport/decorators.js";import{create as g}from"../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{toExtent as u}from"../../../geometry/support/aaBoundingRect.js";import{MediaElementView as y}from"../../../layers/support/MediaElementView.js";import{LayerView3D as _}from"./LayerView3D.js";import{MediaLayerInteraction as f}from"./support/MediaLayerInteraction.js";import{drapedZ as v}from"../terrain/OverlayRenderer.js";import{Attribute as w}from"../webgl-engine/lib/Attribute.js";import{Geometry as E}from"../webgl-engine/lib/Geometry.js";import{ManagedTexture as D}from"../webgl-engine/lib/ManagedTexture.js";import{Object3DHighlightStateID as R}from"../webgl-engine/lib/Object3DStateID.js";import{RenderGeometry as b}from"../webgl-engine/lib/RenderGeometry.js";import{Parameters as j,ImageMaterial as A}from"../webgl-engine/materials/ImageMaterial.js";import H from"../../layers/MediaLayerView.js";import{getHighlightName as M}from"../../support/highlightOptionsUtils.js";import{isInEffectiveScaleRange as x}from"../../support/layerViewUtils.js";let G=class extends(_(H)){get interactive(){return this._interaction.enabled}set interactive(e){this._interaction&&(this._interaction.enabled=e)}get selectedElement(){return this._interaction.selectedElement}set selectedElement(e){this._interaction&&(this._interaction.selectedElement=e)}get visibleAtCurrentScale(){return x(this.layer.effectiveScaleRange,this.view.scale)}get usedMemory(){return Array.from(this._renderElements.values()).reduce((e,t)=>e+(t.getRenderData()?.texture.usedMemory??0),0)}constructor(e){super(e),this.type="media-3d",this.drapeSourceType=1,this.updatePolicy=1,this.ignoresMemoryFactor=!0,this.unloadedMemory=0,this._uidToElement=new Map,this._highlightedElements=new Map,this._elementsInHighlightedId=new Map,this._renderElements=new Map,this._lastDrapingExtent=null,this._update=o(async(e,t,i)=>{const r=await this._collectMediaElements(e,t,i);this._synchronizeRenderElements(r)},0);const{view:t,layer:i}=e;this._interaction=new f({view:t,layer:i}),this.addHandles(l(()=>this.interactionOptions,e=>this._interaction.options=e,h))}initialize(){const{view:e,layer:t}=this;this._renderer=e.overlayManager.registerGeometryDrapeSource(this);const r=()=>this._updateWithLastDrapingExtent();this.addHandles([i(()=>e.overlayManager.unregisterDrapeSource(this)),m(()=>t.effectiveSource,"change",r),m(()=>t.effectiveSource,"refresh",r)]),this._updatingHandles.add(()=>this.suspended,r)}destroy(){this._synchronizeRenderElements(new Set)}setDrapingExtent(e,t){this._lastDrapingExtent={overlays:e,spatialReference:t},this._updateWithLastDrapingExtent()}getHit(e){const t=this._uidToElement.get(e);return t?{type:"media",element:t,layer:this.layer}:null}highlight(e,t){const r=M(t),n=new R(r),a=s(e)?Array.from(e):[e];this._elementsInHighlightedId.set(n,a);for(const i of a){const e=this._highlightedElements.get(i);e?e.add(n):this._highlightedElements.set(i,new Set([n]));const t=this._renderElements.get(i)?.getRenderData();t&&(t.renderGeometry.geometry.addHighlight(n),this._renderer.modifyGeometries([t.renderGeometry],8))}return i(()=>{const e=this._elementsInHighlightedId.get(n);if(e){for(const t of e){const e=this._highlightedElements.get(t);if(!e)continue;e.delete(n);const i=this._renderElements.get(t)?.getRenderData();i&&(i.renderGeometry.geometry.removeHighlight(n),this._renderer.modifyGeometries([i.renderGeometry],8)),0===e.size&&this._highlightedElements.delete(t)}this._elementsInHighlightedId.delete(n)}})}isUpdating(){return super.isUpdating()||this._interaction.updating}_updateWithLastDrapingExtent(){if(null==this._lastDrapingExtent||this.suspended)return void(this._renderer&&this._synchronizeRenderElements(new Set));const{overlays:e,spatialReference:t}=this._lastDrapingExtent;this._updatingHandles.consumePromise(this._update(e,t))}async _collectMediaElements(e,t,i){const r=this.layer.effectiveSource;return null==r?new Set:new Set((await Promise.all(e.map(e=>r.queryElements(u(e.extent,t),{signal:i})))).flat())}_synchronizeRenderElements(e){this._synchronizeRenderElementsRemove(e),this._synchronizeRenderElementsAdd(e)}_synchronizeRenderElementsRemove(e){this._renderElements.forEach((t,i)=>{e.has(i)||(this._removeElement(i,t),this.emit("element-render-changed",{element:i}))})}_synchronizeRenderElementsAdd(e){for(const t of e)this._renderElements.has(t)||this._createRenderElement(t)}_removeElement(e,t){this._destroyRenderData(e,t),this._renderElements.delete(e),this._uidToElement.delete(e.uid),t.handle.remove()}_createRenderElement(e){const t=new y({spatialReference:this.view.spatialReference,element:e}),i=new I(r([this._updatingHandles.add(()=>e.opacity,e=>i.getRenderData()?.material.setParameters({opacity:e})),this._updatingHandles.add(()=>t.coords,()=>{i.data?this._updateGeometry(t,i):this._initializeRenderData(t,i)}),this._updatingHandles.add(()=>e.content,()=>this._initializeRenderData(t,i)),n(t)]));this._renderElements.set(e,i),this._uidToElement.set(e.uid,e),this._updatingHandles.consumePromise(e.load()),this._initializeRenderData(t,i)}_initializeRenderData(e,t){const{coords:i,element:r}=e,{contentWidth:n,contentHeight:s}=r;if(null==i||null==r.content)return void this._destroyRenderData(r,t);if(t.data)return;const a=this._createTexture(r.content),o=a.load(this.view.stage.renderView.renderingContext),l=()=>{if(!a.loaded)return;this.view.stage.addTexture(a);const e=new j(a,!0);e.opacity=r.opacity,e.perspectiveInterpolation=!0;const o=new A(e),d=this._getPositionAttributeArray(i),l=[0,0,1,0,1,1,0,1],h=this._getPerspectiveDivideAttributeArray(d,n,s),m=[0,1,2,0,2,3],c=new E(o,[["position",new w(d,m,3,!0)],["uv0",new w(l,m,2,!0)],["perspectiveDivide",new w(h,m,1,!0)]]),p=new b(c,{layerViewUid:this.uid,graphicUid:r.uid}),g=this._highlightedElements.get(r);g?.forEach(e=>p.geometry.addHighlight(e)),this._renderer.addGeometries([p],0),t.data=new z(p,a,o),this.emit("element-render-changed",{element:r})};d(o)?(t.data=a,this._updatingHandles.consumePromise(o),o.then(l).catch(()=>a.dispose())):l()}_updateGeometry(e,t){const{coords:i,element:r}=e;if(null==i||null==r.content)return void this._destroyRenderData(r,t);const n=t.getRenderData();if(!n)return;const s=this._getPositionAttributeArray(i);n.renderGeometry.geometry.setAttributeData("position",s);const a=this._getPerspectiveDivideAttributeArray(s,r.contentWidth,r.contentHeight);n.renderGeometry.geometry.setAttributeData("perspectiveDivide",a),n.renderGeometry.geometry.invalidateBoundingInfo(),this._renderer.modifyGeometries([n.renderGeometry],2),this.emit("element-render-changed",{element:r})}_getPositionAttributeArray(e){const[t,i,r,n]=e.rings[0];return[t[0],t[1],v,n[0],n[1],v,r[0],r[1],v,i[0],i[1],v]}_getPerspectiveDivideAttributeArray(e,t,i){a(S,[0,0,t,0,t,i,0,i],[e[0],e[1],e[3],e[4],e[6],e[7],e[9],e[10]]);const r=S[6]/S[8]*t,n=S[7]/S[8]*i;return[1,1+r,1+r+n,1+n]}_destroyRenderData(e,t){const i=t.data;if(null==i)return;if(t.data=null,"dispose"in i)return void i.dispose();const r=i.texture;r.unload(),this.view.stage.removeTexture(r),this._renderer.removeGeometries([i.renderGeometry],2),this.emit("element-render-changed",{element:e})}_createTexture(e){const i=e instanceof HTMLImageElement?e.naturalWidth:e.width,r=e instanceof HTMLImageElement?e.naturalHeight:e.height;if("getFrame"in e)throw new t("media-layer-view-3d","animation is not supported");return new D(e,{wrap:{s:33071,t:33071},preMultiplyAlpha:!0,width:i,height:r,mipmap:!0,updateCallback:()=>this.view.overlayManager.requestRender()})}get test(){}};e([c({readOnly:!0})],G.prototype,"type",void 0),e([c()],G.prototype,"interactive",null),e([c()],G.prototype,"selectedElement",null),e([c({readOnly:!0})],G.prototype,"visibleAtCurrentScale",null),G=e([p("esri.views.3d.layers.MediaLayerView3D")],G);const S=g();class I{constructor(e){this.handle=e}getRenderData(){return this.data&&"type"in this.data&&"RenderData"===this.data.type?this.data:null}}class z{constructor(e,t,i){this.renderGeometry=e,this.texture=t,this.material=i,this.type="RenderData"}}const P=G;export{P as default};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import t from"../../../Graphic.js";import i from"../../../request.js";import{isSome as r}from"../../../core/arrayUtils.js";import{result as s,forEach as o}from"../../../core/asyncUtils.js";import"../../../core/has.js";import n from"../../../core/Logger.js";import{destroyMaybe as a,abortMaybe as d}from"../../../core/maybe.js";import{estimateNumberArrayMemory as l,baseObjectMemory as u,estimateNumberMemory as h,estimateFixedArrayMemory as p,baseArrayMemory as c}from"../../../core/memoryEstimations.js";import{isAbortError as _,allSettledValues as m,throwIfAborted as g}from"../../../core/promiseUtils.js";import{initial as f,watch as y,sync as b,syncAndInitial as w}from"../../../core/reactiveUtils.js";import{pt2px as P}from"../../../core/screenUtils.js";import{isArrayBuffer as N}from"../../../core/typedArrayUtil.js";import{property as v,subclass as x}from"../../../core/accessorSupport/decorators.js";import{length as C,add as S,dot as I,copy as A}from"../../../core/libs/gl-matrix-2/math/vec3.js";import{clone as R}from"../../../core/libs/gl-matrix-2/factories/vec3f32.js";import{fromValues as j}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import V from"../../../geometry/Extent.js";import k from"../../../geometry/Point.js";import{projectBoundingSphere as Q}from"../../../geometry/projection/projectBoundingSphere.js";import{projectVectorToVector as F}from"../../../geometry/projection/projectVectorToVector.js";import{create as E,fromMinMax as O}from"../../../geometry/support/aaBoundingBox.js";import{fromNormalAndOffset as L,create as D}from"../../../geometry/support/plane.js";import{Sphere as U}from"../../../geometry/support/sphere.js";import W from"../../../layers/graphics/OptimizedGeometry.js";import{QueryEngine as G}from"../../../layers/graphics/data/QueryEngine.js";import M from"../../../layers/support/CodedValue.js";import q from"../../../layers/support/CodedValueDomain.js";import{unpackFieldNames as z}from"../../../layers/support/fieldUtils.js";import{queueAutoPriority as H}from"../../../request/queue.js";import T from"../../../rest/support/FeatureSet.js";import B from"../../../rest/support/Query.js";import{getElevationOffset as $}from"../../../support/elevationInfoUtils.js";import{LayerView3D as J}from"./LayerView3D.js";import{PointCloudLayerViewPerformanceInfo as K,QueuePerformanceInfo as Z}from"./PointCloudLayerViewPerformanceInfo.js";import{PointCloudWorkerHandle as Y}from"./PointCloudWorkerHandle.js";import{I3SQueryFeatureStore as X}from"./i3s/I3SQueryFeatureStore.js";import{checkPointCloudLayerValid as ee,checkPointCloudLayerCompatibleWithView as te}from"./i3s/I3SUtil.js";import{nodeDiff as ie,sortFrontToBack as re,splitWorkEntries as se}from"./i3s/LoDUtil.js";import{PagedNodeIndex as oe}from"./i3s/PagedNodeIndex.js";import{PointCloudGraphic as ne}from"./i3s/PointCloudGraphic.js";import{PointCloudRenderer as ae}from"./i3s/PointCloudRenderer.js";import{isPointRendererNode as de,PointCloudRendererNode as le}from"./i3s/PointCloudRendererNode.js";import{getSplatSizeAlgorithm as ue,getFixedSizeAlgorithm as he,getRendererInfo as pe,getFilterInfo as ce,rendererUsesFixedSizes as _e,getAttributeInfo as me}from"./i3s/PointCloudRendererUtil.js";import{getAttributeValues as ge,readGeometry as fe,elevationFromPositions as ye}from"./i3s/PointCloudWorkerUtil.js";import{normalizeHighlightTarget as be,emptyHighlightHandle as we}from"./support/highlightUtils.js";import{PopupSceneLayerView as Pe}from"./support/PopupSceneLayerView.js";import{projectToBoundingBox as Ne}from"../support/extentUtils.js";import{computeMapPointFromVec3d as ve}from"../support/hitTest.js";import{Obb as xe}from"../support/orientedBoundingBox.js";import{updatingProgress as Ce}from"../support/updatingProperties.js";import Se from"../../layers/LayerView.js";import{PointCloudLayerViewMixin as Ie}from"../../layers/PointCloudLayerView.js";import{getHighlightName as Ae}from"../../support/highlightOptionsUtils.js";import{isInEffectiveScaleRange as Re}from"../../support/layerViewUtils.js";import{PromiseQueue as je}from"../../support/PromiseQueue.js";import{TaskPriority as Ve}from"../../support/Scheduler.js";const ke=8,Qe=D();let Fe=class extends(Ie(Pe(J(Se)))){constructor(){super(...arguments),this.type="point-cloud-3d",this.maximumPointCount=4e6,this.slicePlaneEnabled=!1,this._renderer=null,this._rendererAdded=!1,this._renderedNodes=new Set,this._updateViewNeeded=!0,this._lodFactor=1,this._maxLoggedBoxWarnings=5,this._pageMultiplier=1,this._nodeLoadEpoch=0,this._indexQueue=[],this._workQueue=new Array,this._idleQueue=new je,this._loadingPages=new Map,this._loadingNodes=new Map,this._recalcWork=!0,this._layerIsVisible=!1,this._codedDomainPopulationPromise=null,this._codedDomainPopulationAbortController=null,this._totalWork=0,this._index=null,this._loadingInitNodePage=!1,this._nodeIdArray=[],this.ignoresMemoryFactor=!1}get baseUrl(){return this.layer.parsedUrl?.path??""}get pointScale(){const e=ue(this.layer?.renderer),t=1;return null!=e?.scaleFactor?e.scaleFactor:t}get useRealWorldSymbolSizes(){const e=he(this.layer?.renderer),t=!1;return null!=e?.useRealWorldSymbolSizes?e.useRealWorldSymbolSizes:t}get pointSize(){const e=he(this.layer?.renderer),t=0;return null!=e?.size?e.size:t}get inverseDensity(){const e=96;return this.layer?.renderer?1*e/this.layer.renderer.pointsPerInch:5}get availableFields(){const e=pe(this.layer),t=new Set;e.primaryAttribute&&t.add(e.primaryAttribute.name),e.modulationAttribute&&t.add(e.modulationAttribute.name);const i=ce(this.layer);if(i)for(const r of i)r.attributeInfo&&t.add(r.attributeInfo.name);if(this.layer.outFields)for(const r of z(this.layer.fieldsIndex,this.layer.outFields))t.add(r);return Array.from(t)}get _clippingBox(){if(!this.view||!this.view.clippingArea)return null;const e=E(),t=this.view.renderSpatialReference;return Ne(this.view.clippingArea,e,t)?e:null}get _elevationOffset(){const e=this.layer&&this.layer.elevationInfo;return"absolute-height"===e?.mode?$(e,this.layer.spatialReference):0}get _graphicOrigin(){return this.layer.graphicOrigin}initialize(){const e=this.view.resourceController,t=Ue(e);this._worker=new Y(t),this.addResolvingPromise(this._worker.promise),this.addResolvingPromise(this.layer.rootPagePromise),ee(this.layer),te(this.layer,this.view),this._initRenderer();const i=this._initNodePages(),r=this.view.resourceController.memoryController;this._memCache=r.newCache(`pcl-${this.layer.uid}`),this._queryFeaturesCache=r.newCache(`pcl-query-features-${this.layer.uid};`),this._updatingHandles.add(()=>this._clippingBox,()=>this._setUpdateViewNeeded(),f),this._updatingHandles.add(()=>this._elevationOffset,()=>this._elevationOffsetChanged(),f),this._updatingHandles.add(()=>this.layer.renderer,()=>this._rendererChanged(),f),this._updatingHandles.add(()=>this.layer.filters,()=>this._reload(),f),this._updatingHandles.add(()=>this.layer.outFields,()=>this._reload(),f),this._updatingHandles.add(()=>this.layer.effectiveScaleRange,()=>this._setUpdateViewNeeded()),this._updatingHandles.add(()=>this.view.state.contentCamera,()=>this._setUpdateViewNeeded()),this.addHandles([y(()=>this.view.quality,()=>this._setUpdateViewNeeded(),b)]),this.addResolvingPromise(i),this.when(()=>{this.addHandles([e.scheduler.registerTask(Ve.POINT_CLOUD_LAYER,this),y(()=>2===this.view.state.mode,()=>this._setUpdateViewNeeded(),w),this._updatingHandles.add(()=>this.suspended,e=>{e?this._clearNodeState():this._setUpdateViewNeeded()},f)])},()=>{this._updatingHandles.removeAll(),this.removeAllHandles()})}_setUpdateViewNeeded(){this._updateViewNeeded=!0,this._updateLoading()}destroy(){this.cancelLoading(),this._worker=a(this._worker),this._destroyRenderer(),this._memCache=a(this._memCache),this._queryFeaturesCache=a(this._queryFeaturesCache),this._queryEngine=a(this._queryEngine),this._codedDomainPopulationAbortController=d(this._codedDomainPopulationAbortController),this._codedDomainPopulationPromise=null}_initRenderer(){this._renderer=new ae({createGraphic:(e,t,i)=>this._createGraphic(e,t,i)}),this._renderer.layerViewUid=this.uid,this._updatingHandles.add(()=>this._clippingBox,e=>this._renderer.clippingBox=e,f),this._updatingHandles.add(()=>this.suspended,e=>this._setPointsVisible(!e),f),this._updatingHandles.add(()=>this.pointScale,e=>this._renderer.scaleFactor=e,f),this._renderer.minSizePx=Math.sqrt(2),this._updatingHandles.add(()=>this.useRealWorldSymbolSizes,e=>this._renderer.useRealWorldSymbolSizes=e,f),this._updatingHandles.add(()=>this.pointSize,e=>{const t=P(e);this._renderer.size=e,this._renderer.sizePx=t},f),this._updatingHandles.add(()=>this.slicePlaneEnabled,e=>this._renderer.slicePlaneEnabled=e,f),this._updatingHandles.add(()=>this.inverseDensity,()=>this._setUpdateViewNeeded(),f),this._updatingHandles.add(()=>this.maximumPointCount,()=>this._setUpdateViewNeeded(),f),this._updatingHandles.add(()=>this.view.qualitySettings.sceneService.pointCloudLoDFactor,e=>{this._lodFactor=e,this._setUpdateViewNeeded()},f)}_destroyRenderer(){this._renderer.removeAll(),this._setPointsVisible(!1)}_createGraphic(e,t,i,r){const s=null!=e.pointIdFilterMap?e.pointIdFilterMap[t]:t,o=i?"declaredClass"in i?i:ve(this.view,i):null;return r??=this._createGraphicAttributes(e,s),new ne({pointCloudMetadata:{nodeId:e.id,pointIndexInNode:t,attributePointIndexInNode:s,epoch:this._nodeLoadEpoch},geometry:o,attributes:r,layer:this.layer,sourceLayer:this.layer,origin:this._graphicOrigin})}_createGraphicAttributes(e,t){const i={};for(const r of e.attributes)this._encodeGraphicAttribute(r.attributeInfo,r.values,t,i);return i}_getGraphicAttribute(e,t,i){const r=e.storageInfo?.attributeValues,s=r?.valuesPerElement??1;if(1===s)return t[i];if("UInt8"===r?.valueType&&s<=4){let e=0;const r=i*s;for(let i=r;i<r+s;i++)e=(e<<8)+t[i];return e}}_encodeGraphicAttribute(e,t,i,r){r[e.name]=this._getGraphicAttribute(e,t,i)}_setPointsVisible(e){e&&!this._rendererAdded?(this.view.stage.addRenderPlugin(this._renderer),this._rendererAdded=!0):!e&&this._rendererAdded&&(this.view.stage.removeRenderPlugin(this._renderer),this._rendererAdded=!1)}_rendererChanged(){this._renderer.useFixedSizes=_e(this.layer.renderer),this._reload()}_reload(){this._clearNodeState(),this._memCache.clear(),this._setUpdateViewNeeded()}_elevationOffsetChanged(){this._clearNodeState(),this._memCache.clear(),this._initNodePages()}_displayNodes(e){this._workQueue=ie([...this._renderedNodes],e,this._index),re(this._workQueue,this.view.state.contentCamera.viewForward,this._index),se(this._workQueue,ke,this._index),this._updateQueues(),this._totalWork=this._computeWork(),this._updateLoading(),this._layerIsVisible=e.length>0||this._loadingInitNodePage,this.notifyChange("suspended")}cancelLoading(){this._cancelNodeLoading(),this._cancelIndexLoading()}_cancelNodeLoading(){[...this._loadingNodes.values()].forEach(e=>e.abort()),this._workQueue=[],this._idleQueue.cancelAll(),this._totalWork=this._computeWork(),this._updateLoading()}_updateQueues(){const e=new Set;this._workQueue.forEach(t=>t.load.forEach(t=>e.add(t)));const t=new Array;this._loadingNodes.forEach((i,r)=>{e.has(r)||(this._loadingNodes.delete(r),t.push(i))}),t.forEach(e=>e.abort()),this._workQueue=this._workQueue.filter(e=>{for(const t of e.load)if(this._loadingNodes.has(t))return this._recalcWork=!0,!1;return!0}),this._totalWork=this._computeWork(),this._updateLoading()}_cancelIndexLoading(){this._indexQueue=[],this._loadingPages.forEach(e=>e.abort()),this._loadingPages.clear(),this._totalWork=this._computeWork(),this._updateLoading()}_clearNodeState(){this._nodeLoadEpoch++,this._renderedNodes.forEach(e=>this._removeFromRenderer(e)),this._cancelNodeLoading()}get readyToRun(){return this.suspended?this._updateViewNeeded:this._updateViewNeeded||this._indexQueue.length>0||this._workQueue.length>0||this._idleQueue.readyToRun}runTask(e){if(this.suspended){if(this._updateViewNeeded){this._updateViewNeeded=!1;const e=this._isRootNodeVisible();e!==this._layerIsVisible&&(this._layerIsVisible=e,this.notifyChange("suspended")),this._updateLoading()}}else{for(e.run(()=>this._updateWorkQueues());this._indexQueue.length>0&&!e.done;)this._processIndexQueue(),e.madeProgress();this._processWorkQueue(e),this._idleQueue.runTask(e)}}async _processIndexQueue(){const e=this._indexQueue.shift(),t=new AbortController;this._loadingPages.set(e,t);try{const i=await this._loadNodePage(e,t.signal);this._index.addPage(e,i,this._elevationOffset),this._setUpdateViewNeeded(),this._loadingPages.delete(e)}catch(i){this._loadingPages.get(e)===t&&this._loadingPages.delete(e)}}_processWorkQueue(e){for(;!e.done;){const t=this._scheduleWorkEntry();if(null==t)return void e.madeProgress();this._processWorkEntry(t),e.madeProgress()}}_scheduleWorkEntry(){let e=this._workQueue.length;for(;e--;){const e=this._workQueue.shift();if(!e.remove.find(e=>!this._renderedNodes.has(e)))return e;this._workQueue.push(e)}return null}async _processWorkEntry(e){if(0===e.load.length){for(const t of e.remove)this._removeFromRenderer(t);return}const t=e.load.map(e=>{const t=new AbortController;return this._loadingNodes.set(e,t),t});this._updateLoading();try{const i=await Promise.all(e.load.map((e,i)=>this._memCache.pop(`${e}`)??this._loadNode(e,t[i].signal)));for(let t=0;t<e.load.length;t++)if(i[t]){const r=this._setupRendererData(e.load[t],i[t]);this._addToRenderer(r)}for(const t of e.remove)this._removeFromRenderer(t);for(const t of e.load)this._loadingNodes.delete(t)}catch(i){e.load.forEach((e,i)=>{this._loadingNodes.get(e)===t[i]&&this._loadingNodes.delete(e)})}this._updateLoading(),this._recalcWork&&!this._idleQueue.updating&&0===this._indexQueue.length&&0===this._loadingNodes.size&&(this._recalcWork=!1,this._setUpdateViewNeeded())}async _populateClassCodeCodedDomain(e,t){const i="CLASS_CODE",r=this.layer.fieldsIndex.get(i);if(!r||r.domain)return;if(!e.includes(r.name))return;const o=await s(this.layer.queryCachedStatistics(i,{signal:t}));if(!1===o.ok)return;const n=o.value?.stats?.labels?.labels;n&&Array.isArray(n)&&(r.domain=new q({name:"CLASS_CODE",codedValues:n.map(e=>new M({code:e.value,name:e.label}))}))}async prepareFetchPopupFeatures(e){return this._codedDomainPopulationPromise||(this._codedDomainPopulationAbortController=new AbortController,this._codedDomainPopulationPromise=this._populateClassCodeCodedDomain(e,this._codedDomainPopulationAbortController.signal).then(()=>{this._codedDomainPopulationAbortController=null})),this._codedDomainPopulationPromise}async whenGraphicAttributes(e,t){const i=this._splitGraphicsPerNode(e),s=this.layer.attributeStorageInfo,n=t.map(e=>me(s,e)).filter(r),a=async(e,t)=>{const i=this._index.getNode(t);await o(n,async t=>{const r=t.useElevation?await this._loadElevationAttributeFromGeometry(i.resourceId):await this._loadAndParseAttribute(i,t);if(r)for(const i of e)if(this._isValidPointGraphic(i)){const e=i.pointCloudMetadata.attributePointIndexInNode;this._encodeGraphicAttribute(t,r,e,i.attributes)}})},d=[];return i.forEach((e,t)=>{d.push(a(e,t))}),await Promise.allSettled(d),e}_isValidPointGraphic(e){return e instanceof ne&&e.pointCloudMetadata?.epoch===this._nodeLoadEpoch}_splitGraphicsPerNode(e){const t=new Map;for(const i of e){if(!this._isValidPointGraphic(i))continue;const e=i.pointCloudMetadata,r=t.get(e.nodeId);r?r.push(i):t.set(e.nodeId,[i])}return t}async _loadAndParseAttribute(e,t){const i=await this._loadAttribute(e.resourceId,t,null);return i?ge({attributeInfo:t,buffer:i},null,e.vertexCount):null}async _loadElevationAttributeFromGeometry(e){const t=this.layer.store.defaultGeometrySchema,i=fe(t,await this._loadGeometry(e,null));return ye(i,i.length/3)}highlight(e,i){const r=be(e);if(0===r.length)return we;if(!(r[0]instanceof t))return we;const s=r;return this._renderer.highlight(s.map(e=>this._graphicToPointDefinition(e)),Ae(i))}_graphicToPointDefinition(e){if(!this._isValidPointGraphic(e))return null;const{nodeId:t,pointIndexInNode:i}=e.pointCloudMetadata;return null!=t&&null!=i?{nodeId:t,pointId:i}:null}_computeWork(){let e=0;for(const t of this._workQueue)e+=t.load.length+t.remove.length;return e+=this._loadingNodes.size,e+=(this._indexQueue.length+this._loadingPages.size)*this._index.pageSize,e+=this._loadingInitNodePage?100:0,e+=this._updateViewNeeded?100:0,e}get updatingProgressValue(){if(this.suspended)return this._updateViewNeeded?0:1;const e=this._computeWork();return 1-Math.min(this._totalWork,e)/this._totalWork}_updateLoading(){this.notifyChange("updating"),this.notifyChange("updatingProgressValue")}canResume(){return super.canResume()&&this._layerIsVisible}isUpdating(){return this.suspended?this._updateViewNeeded:this._computeWork()>0}get visibleAtCurrentScale(){return Re(this.layer.effectiveScaleRange,this.view.scale)}async queryFeatures(e,i){const r=await this._ensureQueryEngine().executeQuery(this._ensureQueryJSON(e),i?.signal),s=r.features;r.features=[];const o=T.fromJSON(r),n=this.view.spatialReference;return o.features=s.map(e=>{const{attributes:i,metadata:r}=e;if(!r){const i=t.fromJSON(e);return i.geometry&&(i.geometry.spatialReference=o.spatialReference??n),i.layer=this.layer,i.sourceLayer=this.layer,i.origin=this._graphicOrigin,i}const s=e.geometry?k.fromJSON(e.geometry):void 0;return s&&(s.spatialReference=o.spatialReference??n),this._createGraphic(r.node,r.pointId,s,i)}),o}createQuery(){const e={outFields:["*"],returnGeometry:!0,outSpatialReference:this.view.spatialReference,returnZ:!0};return new B(e)}async queryFeatureCount(e,t){return await this._ensureQueryEngine().executeQueryForCount(this._ensureQueryJSON(e),t?.signal)}async queryExtent(e,t){const{count:i,extent:r}=await this._ensureQueryEngine().executeQueryForExtent(this._ensureQueryJSON(e),t?.signal);return{count:i,extent:V.fromJSON(r)}}_ensureQueryJSON(e){return null==e?new B({outSpatialReference:this.view.spatialReference}).toJSON():B.from(e).toJSON()}_ensureQueryEngine(){if(this._queryEngine)return this._queryEngine;const{spatialReference:e}=this.view;return this._queryEngine=new G({fieldsIndex:this.layer.fieldsIndex.toJSON(),geometryType:"esriGeometryPoint",spatialReference:e,featureIdInfo:{type:"object-id",fieldName:"objectId"},hasZ:!0,featureStore:new X({sourceSpatialReference:e,viewSpatialReference:e,forAllFeatures:(e,t)=>{this._renderer.forEachNode(i=>{if(t){const e=i.obb,r=new U(e.center,C(e.halfSize));Q(r,this.view.renderSpatialReference,r,this.view.spatialReference);if(1===t(r))return}let r=this._queryFeaturesCache.get(`${i.id}`);r||(r=this._createQueryPointFeatures(i),this._queryFeaturesCache.put(`${i.id}`,r)),r.features.forEach(e)})},getFeatureExtent:({point:e},t)=>O(e,e,t),featureAdapter:{cloneWithGeometry:(e,t,i)=>new Oe(e.node,e.pointId,t.coords),getAttribute:({node:e,attributePointId:t},i)=>{for(const r of e.attributes)if(r.attributeInfo.name===i)return this._getGraphicAttribute(r.attributeInfo,r.values,t)},getAttributes:({node:e,attributePointId:t})=>this._createGraphicAttributes(e,t),getCentroid:e=>e.getGeometry(),getGeometry:e=>e.getGeometry(),getObjectId:()=>{},getMetadata:e=>e}})}),this._queryEngine}_createQueryPointFeatures(e){const t=e.coordinates,i=new Array;for(let r=0;r<t.length/3;r++){const s=3*r,o=j(t[s+0],t[s+1],t[s+2]);S(o,o,e.origin),F(o,this.view.renderSpatialReference,o,this.view.spatialReference);const n=new Oe(e,r,o);i.push(n)}return new Le(i)}async _initNodePages(){const e=this.layer.store.index,t=e.nodesPerPage||e.nodePerIndexBlock;this._index=new oe(this.layer.spatialReference,this.view.renderCoordsHelper.spatialReference,t),this._cancelIndexLoading(),this._traverseVisible=this._index.createVisibilityTraverse(),this._loadingInitNodePage=!0,this._layerIsVisible=!0,this.notifyChange("suspended"),this._updateLoading(),this._pageMultiplier=null!=e.nodesPerPage?1:e.nodePerIndexBlock;const i=await this.layer.rootPagePromise;this._loadingInitNodePage=!1,i?(this._index.addPage(0,this._processJSONNodes(i,0),this._elevationOffset),this._setUpdateViewNeeded()):n.getLogger(this).error("Point cloud layer root page not loaded")}_loadNodePage(e,t){const i=`${this.baseUrl}/nodepages/${e*this._pageMultiplier}`;return this._requestNodePage(i,t).then(t=>this._processJSONNodes(t,e))}_processJSONNodes(e,t){const i=t*this._index.pageSize;return e.nodes.map((e,t)=>({resourceId:e.resourceId??i+t,obb:xe.fromJSON(e.obb),obbInRenderSR:new xe,firstChild:e.firstChild,childCount:e.childCount,vertexCount:e.vertexCount??e.pointCount,lodThreshold:e.lodThreshold??e.effectiveArea}))}_updateWorkQueues(){if(!this._updateViewNeeded)return!1;const e=this.view.quality;let t=this.inverseDensity/this._lodFactor*e;const i=this.maximumPointCount*this._lodFactor*e;let r=this._computeNodesForMinimumDensity(t),s=this._computePointCount(r),o=Math.sqrt(s/(.75*i));for(;s>i;)t*=o,r=this._computeNodesForMinimumDensity(t),s=this._computePointCount(r),o=Math.sqrt(2);return this._displayNodes(r),this._updateViewNeeded=!1,this._updateLoading(),!0}_computePointCount(e){let t=0;for(let i=0;i<e.length;i++){const r=this._index.getNode(e[i]);r&&(t+=r.vertexCount)}return t}_isRootNodeVisible(){let e=!1;return this._traverseVisible({frustum:this.view.state.contentCamera.frustum,clippingBox:this._clippingBox},{predicate:(t,i,r)=>(e=r,!1),pageMiss:()=>{}}),e}_computeNodesForMinimumDensity(e){const t=this.view.state.contentCamera,i=t.frustum,r=this._clippingBox,s=t.viewForward,o=I(s,t.eye),n=L(s,-o,Qe),a=t.perScreenPixelRatio/2,d=e*e,l=this._nodeIdArray;l.length=0;const u=e=>l.push(e);return this._traverseVisible({frustum:i,clippingBox:r},{predicate:(e,t,i)=>{if(!i)return!1;if(0===t.childCount)return u(e),!1;const r=this._index.getRenderObb(e);return!(this._computeAveragePixelArea(r,t.lodThreshold,t.vertexCount,n,a)<=d)||(u(e),!1)},pageMiss:(e,t)=>{u(e),this._indexQueue.includes(t)||this._indexQueue.push(t)}}),l}_computeAveragePixelArea(e,t,i,r,s){const o=1e-7,n=Math.max(o,e.minimumDistancePlane(r));return t/(n*n)/(4*s*s)/i}_loadNode(e,t){try{return this._loadNodeAsync(e,t)}catch(i){throw _(i)||n.getLogger(this).error(i),i}}async _loadAdditionalUserAttributes(e,t,i){const s=this.layer.outFields;if(!s)return[];const o=z(this.layer.fieldsIndex,s),n=new Set(e.map(e=>null!=e?e.name:null)),a=this.layer.attributeStorageInfo,d=[];for(const r of o){if(n.has(r))continue;const e=me(a,r);e&&d.push(t(e))}const l=await m(d);return g(i),l.filter(r)}async _loadNodeAsync(e,t){const i=this._index.getNode(e),r=pe(this.layer),s=ce(this.layer),o=i.resourceId,n=async e=>{if(!e)return null;if(e.useElevation)return{attributeInfo:e,buffer:null};const i=await this._loadAttribute(o,e,t);return null!=i?{attributeInfo:e,buffer:i}:null};return this._idleQueue.push(async()=>{const i=this._loadGeometry(o,t),{primaryAttribute:a,modulationAttribute:d}=r,l=n(a),u=n(d),h=s.map(e=>e.attributeInfo),p=h.map(e=>n(e)),c=this._loadAdditionalUserAttributes([a,d,...h],n,t),[_,m,f,y,b]=await Promise.all([i,l,u,Promise.all(p),c]);g(t);const w={geometryBuffer:_,primaryAttributeData:m,modulationAttributeData:f,filterAttributesData:y,userAttributesData:b,schema:this.layer.store.defaultGeometrySchema,rendererInfo:r,filterInfo:s,obbData:this._index.getRenderObb(e).data,elevationOffset:this._elevationOffset,inSR:this.layer.spatialReference.toJSON(),outSR:this.view.renderCoordsHelper.spatialReference.toJSON()};return this._worker.invoke(w,t)},t)}async _loadGeometry(e,t){return this._requestData(`${this.baseUrl}/nodes/${e}/geometries/0`,t)}async _loadAttribute(e,t,i){if(!t?.storageInfo)return null;const r=t.storageInfo.key;return this._requestData(`${this.baseUrl}/nodes/${e}/attributes/${r}`,i)}async _requestNodePage(e,t){const r={f:"json",...this.layer.customParameters,token:this.layer.apiKey},s={...H,query:r,responseType:"json",signal:t};return(await i(e,s)).data}async _requestData(e,t){const r={...this.layer.customParameters,token:this.layer.apiKey},s={...H,query:r,responseType:"array-buffer",signal:t};return(await i(e,s)).data}_removeFromRenderer(e){if(this._renderedNodes.has(e)){const t=this._renderer.removeNode(e);this._renderedNodes.delete(e),this._memCache.put(`${t.id}`,t)}}_addToRenderer(e){this._renderedNodes.has(e.id)||(this._renderedNodes.add(e.id),this._renderer.addNode(e))}_setupRendererData(e,t){const i=this._index.getNode(e),r=Math.sqrt(i.lodThreshold/i.vertexCount),s=this._index.getRenderObb(e);if(de(t))return t.splatSize=r,t.obb=s,A(t.origin,t.obb.center),t;const o=xe.fromData(t.obbData),a=o.halfSize,d=s.halfSize,l=.01*Math.max(d[0],d[1],d[2]);if(a[0]>d[0]+l||a[1]>d[1]+l||a[2]>d[2]+l){if(this._maxLoggedBoxWarnings>0){const t=e=>`[${e.halfSize[0]}, ${e.halfSize[1]}, ${e.halfSize[2]}]`;n.getLogger(this).warn(`Node ${e} reported bounding box too small. got ${t(s)} but points cover ${t(o)}`),0===--this._maxLoggedBoxWarnings&&n.getLogger(this).warn(" Too many bounding box errors, stopping reporting for this layer.")}this._index.setRenderObb(e,o)}return new le(e,r,R(s.center),s,0===i.childCount,t.points,t.rgb,t.attributes,t.pointIdFilterMap)}get usedMemory(){let e=0;return this._renderer.forEachNode(t=>{e+=De,e+=l(t.coordinates);for(const i of t.attributes){const t=i.values;N(t.buffer)&&(e+=l(t))}}),e}get unloadedMemory(){const e=this._renderedNodes.size;if(e<4)return 0;const t=[...this._renderedNodes].reduce((e,t)=>e+this._index.getNode(t).vertexCount);let i=this._loadingNodes.size;for(let r=0;r<this._workQueue.length;r++)i+=this._workQueue[r].load.length,i-=this._workQueue[r].remove.length;if(i<0)return 0;return i*t/e*((this.usedMemory-e*De)/t)+i*De}get performanceInfo(){return new K(this.usedMemory,this._renderedNodes.size,[...this._renderedNodes].reduce((e,t)=>e+this._index.getNode(t).vertexCount,0),this.maximumPointCount,new Z(this._loadingNodes.size,this._indexQueue.length,this._workQueue.length,this._idleQueue.length))}get test(){}};e([v()],Fe.prototype,"layer",void 0),e([v()],Fe.prototype,"baseUrl",null),e([v()],Fe.prototype,"pointScale",null),e([v()],Fe.prototype,"useRealWorldSymbolSizes",null),e([v()],Fe.prototype,"pointSize",null),e([v()],Fe.prototype,"inverseDensity",null),e([v()],Fe.prototype,"maximumPointCount",void 0),e([v({readOnly:!0})],Fe.prototype,"availableFields",null),e([v({readOnly:!0})],Fe.prototype,"_clippingBox",null),e([v({readOnly:!0})],Fe.prototype,"_elevationOffset",null),e([v({type:Boolean})],Fe.prototype,"slicePlaneEnabled",void 0),e([v()],Fe.prototype,"_graphicOrigin",null),e([v()],Fe.prototype,"updating",void 0),e([v(Ce)],Fe.prototype,"updatingProgress",void 0),e([v({readOnly:!0})],Fe.prototype,"updatingProgressValue",null),e([v({readOnly:!0})],Fe.prototype,"visibleAtCurrentScale",null),Fe=e([x("esri.views.3d.layers.PointCloudLayerView3D")],Fe);const Ee=Fe;class Oe{constructor(e,t,i){this.node=e,this.pointId=t,this.point=i}getGeometry(){return new W([],Array.from(this.point),!0,!1)}get attributePointId(){const{node:e,pointId:t}=this;return null!=e.pointIdFilterMap?e.pointIdFilterMap[t]:t}get usedMemory(){return u+u+h+p(this.point,h)}}class Le{constructor(e){this.features=e}get usedMemory(){return this.features.reduce((e,t)=>e+t.usedMemory,u+c)}}const De=160;function Ue(e){return t=>e.immediate.schedule(t)}export{Ee as default};
2
+ import{__decorate as e}from"tslib";import t from"../../../Graphic.js";import i from"../../../request.js";import{isSome as r}from"../../../core/arrayUtils.js";import{result as s,forEach as o}from"../../../core/asyncUtils.js";import"../../../core/has.js";import n from"../../../core/Logger.js";import{destroyMaybe as a,abortMaybe as d}from"../../../core/maybe.js";import{estimateNumberArrayMemory as l,baseObjectMemory as u,estimateNumberMemory as h,estimateFixedArrayMemory as p,baseArrayMemory as c}from"../../../core/memoryEstimations.js";import{isAbortError as _,allSettledValues as m,throwIfAborted as g}from"../../../core/promiseUtils.js";import{initial as f,watch as y,sync as b,syncAndInitial as w}from"../../../core/reactiveUtils.js";import{pt2px as P}from"../../../core/screenUtils.js";import{isArrayBuffer as N}from"../../../core/typedArrayUtil.js";import{property as v,subclass as x}from"../../../core/accessorSupport/decorators.js";import{length as C,add as S,dot as I,copy as A}from"../../../core/libs/gl-matrix-2/math/vec3.js";import{clone as R}from"../../../core/libs/gl-matrix-2/factories/vec3f32.js";import{fromValues as j}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import Q from"../../../geometry/Extent.js";import V from"../../../geometry/Point.js";import{projectBoundingSphere as k}from"../../../geometry/projection/projectBoundingSphere.js";import{projectVectorToVector as F}from"../../../geometry/projection/projectVectorToVector.js";import{create as E,fromMinMax as O}from"../../../geometry/support/aaBoundingBox.js";import{fromNormalAndOffset as L,create as D}from"../../../geometry/support/plane.js";import{Sphere as U}from"../../../geometry/support/sphere.js";import W from"../../../layers/graphics/OptimizedGeometry.js";import{QueryEngine as G}from"../../../layers/graphics/data/QueryEngine.js";import M from"../../../layers/support/CodedValue.js";import z from"../../../layers/support/CodedValueDomain.js";import{unpackFieldNames as q}from"../../../layers/support/fieldUtils.js";import H from"../../../rest/support/FeatureSet.js";import T from"../../../rest/support/Query.js";import{getElevationOffset as B}from"../../../support/elevationInfoUtils.js";import{LayerView3D as $}from"./LayerView3D.js";import{PointCloudLayerViewPerformanceInfo as J,QueuePerformanceInfo as K}from"./PointCloudLayerViewPerformanceInfo.js";import{PointCloudWorkerHandle as Z}from"./PointCloudWorkerHandle.js";import{I3SQueryFeatureStore as Y}from"./i3s/I3SQueryFeatureStore.js";import{checkPointCloudLayerValid as X,checkPointCloudLayerCompatibleWithView as ee}from"./i3s/I3SUtil.js";import{nodeDiff as te,sortFrontToBack as ie,splitWorkEntries as re}from"./i3s/LoDUtil.js";import{PagedNodeIndex as se}from"./i3s/PagedNodeIndex.js";import{PointCloudGraphic as oe}from"./i3s/PointCloudGraphic.js";import{PointCloudRenderer as ne}from"./i3s/PointCloudRenderer.js";import{isPointRendererNode as ae,PointCloudRendererNode as de}from"./i3s/PointCloudRendererNode.js";import{getSplatSizeAlgorithm as le,getFixedSizeAlgorithm as ue,getRendererInfo as he,getFilterInfo as pe,rendererUsesFixedSizes as ce,getAttributeInfo as _e}from"./i3s/PointCloudRendererUtil.js";import{getAttributeValues as me,readGeometry as ge,elevationFromPositions as fe}from"./i3s/PointCloudWorkerUtil.js";import{normalizeHighlightTarget as ye,emptyHighlightHandle as be}from"./support/highlightUtils.js";import{PopupSceneLayerView as we}from"./support/PopupSceneLayerView.js";import{projectToBoundingBox as Pe}from"../support/extentUtils.js";import{computeMapPointFromVec3d as Ne}from"../support/hitTest.js";import{Obb as ve}from"../support/orientedBoundingBox.js";import{updatingProgress as xe}from"../support/updatingProperties.js";import Ce from"../../layers/LayerView.js";import{PointCloudLayerViewMixin as Se}from"../../layers/PointCloudLayerView.js";import{getHighlightName as Ie}from"../../support/highlightOptionsUtils.js";import{isInEffectiveScaleRange as Ae}from"../../support/layerViewUtils.js";import{PromiseQueue as Re}from"../../support/PromiseQueue.js";import{TaskPriority as je}from"../../support/Scheduler.js";const Qe=8,Ve=D();let ke=class extends(Se(we($(Ce)))){constructor(){super(...arguments),this.type="point-cloud-3d",this.maximumPointCount=4e6,this.slicePlaneEnabled=!1,this._renderer=null,this._rendererAdded=!1,this._renderedNodes=new Set,this._updateViewNeeded=!0,this._lodFactor=1,this._maxLoggedBoxWarnings=5,this._pageMultiplier=1,this._nodeLoadEpoch=0,this._indexQueue=[],this._workQueue=new Array,this._idleQueue=new Re,this._loadingPages=new Map,this._loadingNodes=new Map,this._recalcWork=!0,this._layerIsVisible=!1,this._codedDomainPopulationPromise=null,this._codedDomainPopulationAbortController=null,this._totalWork=0,this._index=null,this._loadingInitNodePage=!1,this._nodeIdArray=[],this.ignoresMemoryFactor=!1}get baseUrl(){return this.layer.parsedUrl?.path??""}get pointScale(){const e=le(this.layer?.renderer),t=1;return null!=e?.scaleFactor?e.scaleFactor:t}get useRealWorldSymbolSizes(){const e=ue(this.layer?.renderer),t=!1;return null!=e?.useRealWorldSymbolSizes?e.useRealWorldSymbolSizes:t}get pointSize(){const e=ue(this.layer?.renderer),t=0;return null!=e?.size?e.size:t}get inverseDensity(){const e=96;return this.layer?.renderer?1*e/this.layer.renderer.pointsPerInch:5}get availableFields(){const e=he(this.layer),t=new Set;e.primaryAttribute&&t.add(e.primaryAttribute.name),e.modulationAttribute&&t.add(e.modulationAttribute.name);const i=pe(this.layer);if(i)for(const r of i)r.attributeInfo&&t.add(r.attributeInfo.name);if(this.layer.outFields)for(const r of q(this.layer.fieldsIndex,this.layer.outFields))t.add(r);return Array.from(t)}get _clippingBox(){if(!this.view||!this.view.clippingArea)return null;const e=E(),t=this.view.renderSpatialReference;return Pe(this.view.clippingArea,e,t)?e:null}get _elevationOffset(){const e=this.layer&&this.layer.elevationInfo;return"absolute-height"===e?.mode?B(e,this.layer.spatialReference):0}get _graphicOrigin(){return this.layer.graphicOrigin}initialize(){const e=this.view.resourceController,t=De(e);this._worker=new Z(t),this.addResolvingPromise(this._worker.promise),this.addResolvingPromise(this.layer.rootPagePromise),X(this.layer),ee(this.layer,this.view),this._initRenderer();const i=this._initNodePages(),r=this.view.resourceController.memoryController;this._memCache=r.newCache(`pcl-${this.layer.uid}`),this._queryFeaturesCache=r.newCache(`pcl-query-features-${this.layer.uid};`),this._updatingHandles.add(()=>this._clippingBox,()=>this._setUpdateViewNeeded(),f),this._updatingHandles.add(()=>this._elevationOffset,()=>this._elevationOffsetChanged(),f),this._updatingHandles.add(()=>this.layer.renderer,()=>this._rendererChanged(),f),this._updatingHandles.add(()=>this.layer.filters,()=>this._reload(),f),this._updatingHandles.add(()=>this.layer.outFields,()=>this._reload(),f),this._updatingHandles.add(()=>this.layer.effectiveScaleRange,()=>this._setUpdateViewNeeded()),this._updatingHandles.add(()=>this.view.state.contentCamera,()=>this._setUpdateViewNeeded()),this.addHandles([y(()=>this.view.quality,()=>this._setUpdateViewNeeded(),b)]),this.addResolvingPromise(i),this.when(()=>{this.addHandles([e.scheduler.registerTask(je.POINT_CLOUD_LAYER,this),y(()=>2===this.view.state.mode,()=>this._setUpdateViewNeeded(),w),this._updatingHandles.add(()=>this.suspended,e=>{e?this._clearNodeState():this._setUpdateViewNeeded()},f)])},()=>{this._updatingHandles.removeAll(),this.removeAllHandles()})}_setUpdateViewNeeded(){this._updateViewNeeded=!0,this._updateLoading()}destroy(){this.cancelLoading(),this._worker=a(this._worker),this._destroyRenderer(),this._memCache=a(this._memCache),this._queryFeaturesCache=a(this._queryFeaturesCache),this._queryEngine=a(this._queryEngine),this._codedDomainPopulationAbortController=d(this._codedDomainPopulationAbortController),this._codedDomainPopulationPromise=null}_initRenderer(){this._renderer=new ne({createGraphic:(e,t,i)=>this._createGraphic(e,t,i)}),this._renderer.layerViewUid=this.uid,this._updatingHandles.add(()=>this._clippingBox,e=>this._renderer.clippingBox=e,f),this._updatingHandles.add(()=>this.suspended,e=>this._setPointsVisible(!e),f),this._updatingHandles.add(()=>this.pointScale,e=>this._renderer.scaleFactor=e,f),this._renderer.minSizePx=Math.sqrt(2),this._updatingHandles.add(()=>this.useRealWorldSymbolSizes,e=>this._renderer.useRealWorldSymbolSizes=e,f),this._updatingHandles.add(()=>this.pointSize,e=>{const t=P(e);this._renderer.size=e,this._renderer.sizePx=t},f),this._updatingHandles.add(()=>this.slicePlaneEnabled,e=>this._renderer.slicePlaneEnabled=e,f),this._updatingHandles.add(()=>this.inverseDensity,()=>this._setUpdateViewNeeded(),f),this._updatingHandles.add(()=>this.maximumPointCount,()=>this._setUpdateViewNeeded(),f),this._updatingHandles.add(()=>this.view.qualitySettings.sceneService.pointCloudLoDFactor,e=>{this._lodFactor=e,this._setUpdateViewNeeded()},f)}_destroyRenderer(){this._renderer.removeAll(),this._setPointsVisible(!1)}_createGraphic(e,t,i,r){const s=null!=e.pointIdFilterMap?e.pointIdFilterMap[t]:t,o=i?"declaredClass"in i?i:Ne(this.view,i):null;return r??=this._createGraphicAttributes(e,s),new oe({pointCloudMetadata:{nodeId:e.id,pointIndexInNode:t,attributePointIndexInNode:s,epoch:this._nodeLoadEpoch},geometry:o,attributes:r,layer:this.layer,sourceLayer:this.layer,origin:this._graphicOrigin})}_createGraphicAttributes(e,t){const i={};for(const r of e.attributes)this._encodeGraphicAttribute(r.attributeInfo,r.values,t,i);return i}_getGraphicAttribute(e,t,i){const r=e.storageInfo?.attributeValues,s=r?.valuesPerElement??1;if(1===s)return t[i];if("UInt8"===r?.valueType&&s<=4){let e=0;const r=i*s;for(let i=r;i<r+s;i++)e=(e<<8)+t[i];return e}}_encodeGraphicAttribute(e,t,i,r){r[e.name]=this._getGraphicAttribute(e,t,i)}_setPointsVisible(e){e&&!this._rendererAdded?(this.view.stage.addRenderPlugin(this._renderer),this._rendererAdded=!0):!e&&this._rendererAdded&&(this.view.stage.removeRenderPlugin(this._renderer),this._rendererAdded=!1)}_rendererChanged(){this._renderer.useFixedSizes=ce(this.layer.renderer),this._reload()}_reload(){this._clearNodeState(),this._memCache.clear(),this._setUpdateViewNeeded()}_elevationOffsetChanged(){this._clearNodeState(),this._memCache.clear(),this._initNodePages()}_displayNodes(e){this._workQueue=te([...this._renderedNodes],e,this._index),ie(this._workQueue,this.view.state.contentCamera.viewForward,this._index),re(this._workQueue,Qe,this._index),this._updateQueues(),this._totalWork=this._computeWork(),this._updateLoading(),this._layerIsVisible=e.length>0||this._loadingInitNodePage,this.notifyChange("suspended")}cancelLoading(){this._cancelNodeLoading(),this._cancelIndexLoading()}_cancelNodeLoading(){[...this._loadingNodes.values()].forEach(e=>e.abort()),this._workQueue=[],this._idleQueue.cancelAll(),this._totalWork=this._computeWork(),this._updateLoading()}_updateQueues(){const e=new Set;this._workQueue.forEach(t=>t.load.forEach(t=>e.add(t)));const t=new Array;this._loadingNodes.forEach((i,r)=>{e.has(r)||(this._loadingNodes.delete(r),t.push(i))}),t.forEach(e=>e.abort()),this._workQueue=this._workQueue.filter(e=>{for(const t of e.load)if(this._loadingNodes.has(t))return this._recalcWork=!0,!1;return!0}),this._totalWork=this._computeWork(),this._updateLoading()}_cancelIndexLoading(){this._indexQueue=[],this._loadingPages.forEach(e=>e.abort()),this._loadingPages.clear(),this._totalWork=this._computeWork(),this._updateLoading()}_clearNodeState(){this._nodeLoadEpoch++,this._renderedNodes.forEach(e=>this._removeFromRenderer(e)),this._cancelNodeLoading()}get readyToRun(){return this.suspended?this._updateViewNeeded:this._updateViewNeeded||this._indexQueue.length>0||this._workQueue.length>0||this._idleQueue.readyToRun}runTask(e){if(this.suspended){if(this._updateViewNeeded){this._updateViewNeeded=!1;const e=this._isRootNodeVisible();e!==this._layerIsVisible&&(this._layerIsVisible=e,this.notifyChange("suspended")),this._updateLoading()}}else{for(e.run(()=>this._updateWorkQueues());this._indexQueue.length>0&&!e.done;)this._processIndexQueue(),e.madeProgress();this._processWorkQueue(e),this._idleQueue.runTask(e)}}async _processIndexQueue(){const e=this._indexQueue.shift(),t=new AbortController;this._loadingPages.set(e,t);try{const i=await this._loadNodePage(e,t.signal);this._index.addPage(e,i,this._elevationOffset),this._setUpdateViewNeeded(),this._loadingPages.delete(e)}catch(i){this._loadingPages.get(e)===t&&this._loadingPages.delete(e)}}_processWorkQueue(e){for(;!e.done;){const t=this._scheduleWorkEntry();if(null==t)return void e.madeProgress();this._processWorkEntry(t),e.madeProgress()}}_scheduleWorkEntry(){let e=this._workQueue.length;for(;e--;){const e=this._workQueue.shift();if(!e.remove.find(e=>!this._renderedNodes.has(e)))return e;this._workQueue.push(e)}return null}async _processWorkEntry(e){if(0===e.load.length){for(const t of e.remove)this._removeFromRenderer(t);return}const t=e.load.map(e=>{const t=new AbortController;return this._loadingNodes.set(e,t),t});this._updateLoading();try{const i=await Promise.all(e.load.map((e,i)=>this._memCache.pop(`${e}`)??this._loadNode(e,t[i].signal)));for(let t=0;t<e.load.length;t++)if(i[t]){const r=this._setupRendererData(e.load[t],i[t]);this._addToRenderer(r)}for(const t of e.remove)this._removeFromRenderer(t);for(const t of e.load)this._loadingNodes.delete(t)}catch(i){e.load.forEach((e,i)=>{this._loadingNodes.get(e)===t[i]&&this._loadingNodes.delete(e)})}this._updateLoading(),this._recalcWork&&!this._idleQueue.updating&&0===this._indexQueue.length&&0===this._loadingNodes.size&&(this._recalcWork=!1,this._setUpdateViewNeeded())}async _populateClassCodeCodedDomain(e,t){const i="CLASS_CODE",r=this.layer.fieldsIndex.get(i);if(!r||r.domain)return;if(!e.includes(r.name))return;const o=await s(this.layer.queryCachedStatistics(i,{signal:t}));if(!1===o.ok)return;const n=o.value?.stats?.labels?.labels;n&&Array.isArray(n)&&(r.domain=new z({name:"CLASS_CODE",codedValues:n.map(e=>new M({code:e.value,name:e.label}))}))}async prepareFetchPopupFeatures(e){return this._codedDomainPopulationPromise||(this._codedDomainPopulationAbortController=new AbortController,this._codedDomainPopulationPromise=this._populateClassCodeCodedDomain(e,this._codedDomainPopulationAbortController.signal).then(()=>{this._codedDomainPopulationAbortController=null})),this._codedDomainPopulationPromise}async whenGraphicAttributes(e,t){const i=this._splitGraphicsPerNode(e),s=this.layer.attributeStorageInfo,n=t.map(e=>_e(s,e)).filter(r),a=async(e,t)=>{const i=this._index.getNode(t);await o(n,async t=>{const r=t.useElevation?await this._loadElevationAttributeFromGeometry(i.resourceId):await this._loadAndParseAttribute(i,t);if(r)for(const i of e)if(this._isValidPointGraphic(i)){const e=i.pointCloudMetadata.attributePointIndexInNode;this._encodeGraphicAttribute(t,r,e,i.attributes)}})},d=[];return i.forEach((e,t)=>{d.push(a(e,t))}),await Promise.allSettled(d),e}_isValidPointGraphic(e){return e instanceof oe&&e.pointCloudMetadata?.epoch===this._nodeLoadEpoch}_splitGraphicsPerNode(e){const t=new Map;for(const i of e){if(!this._isValidPointGraphic(i))continue;const e=i.pointCloudMetadata,r=t.get(e.nodeId);r?r.push(i):t.set(e.nodeId,[i])}return t}async _loadAndParseAttribute(e,t){const i=await this._loadAttribute(e.resourceId,t,null);return i?me({attributeInfo:t,buffer:i},null,e.vertexCount):null}async _loadElevationAttributeFromGeometry(e){const t=this.layer.store.defaultGeometrySchema,i=ge(t,await this._loadGeometry(e,null));return fe(i,i.length/3)}highlight(e,i){const r=ye(e);if(0===r.length)return be;if(!(r[0]instanceof t))return be;const s=r;return this._renderer.highlight(s.map(e=>this._graphicToPointDefinition(e)),Ie(i))}_graphicToPointDefinition(e){if(!this._isValidPointGraphic(e))return null;const{nodeId:t,pointIndexInNode:i}=e.pointCloudMetadata;return null!=t&&null!=i?{nodeId:t,pointId:i}:null}_computeWork(){let e=0;for(const t of this._workQueue)e+=t.load.length+t.remove.length;return e+=this._loadingNodes.size,e+=(this._indexQueue.length+this._loadingPages.size)*this._index.pageSize,e+=this._loadingInitNodePage?100:0,e+=this._updateViewNeeded?100:0,e}get updatingProgressValue(){if(this.suspended)return this._updateViewNeeded?0:1;const e=this._computeWork();return 1-Math.min(this._totalWork,e)/this._totalWork}_updateLoading(){this.notifyChange("updating"),this.notifyChange("updatingProgressValue")}canResume(){return super.canResume()&&this._layerIsVisible}isUpdating(){return this.suspended?this._updateViewNeeded:this._computeWork()>0}get visibleAtCurrentScale(){return Ae(this.layer.effectiveScaleRange,this.view.scale)}async queryFeatures(e,i){const r=await this._ensureQueryEngine().executeQuery(this._ensureQueryJSON(e),i?.signal),s=r.features;r.features=[];const o=H.fromJSON(r),n=this.view.spatialReference;return o.features=s.map(e=>{const{attributes:i,metadata:r}=e;if(!r){const i=t.fromJSON(e);return i.geometry&&(i.geometry.spatialReference=o.spatialReference??n),i.layer=this.layer,i.sourceLayer=this.layer,i.origin=this._graphicOrigin,i}const s=e.geometry?V.fromJSON(e.geometry):void 0;return s&&(s.spatialReference=o.spatialReference??n),this._createGraphic(r.node,r.pointId,s,i)}),o}createQuery(){const e={outFields:["*"],returnGeometry:!0,outSpatialReference:this.view.spatialReference,returnZ:!0};return new T(e)}async queryFeatureCount(e,t){return await this._ensureQueryEngine().executeQueryForCount(this._ensureQueryJSON(e),t?.signal)}async queryExtent(e,t){const{count:i,extent:r}=await this._ensureQueryEngine().executeQueryForExtent(this._ensureQueryJSON(e),t?.signal);return{count:i,extent:Q.fromJSON(r)}}_ensureQueryJSON(e){return null==e?new T({outSpatialReference:this.view.spatialReference}).toJSON():T.from(e).toJSON()}_ensureQueryEngine(){if(this._queryEngine)return this._queryEngine;const{spatialReference:e}=this.view;return this._queryEngine=new G({fieldsIndex:this.layer.fieldsIndex.toJSON(),geometryType:"esriGeometryPoint",spatialReference:e,featureIdInfo:{type:"object-id",fieldName:"objectId"},hasZ:!0,featureStore:new Y({sourceSpatialReference:e,viewSpatialReference:e,forAllFeatures:(e,t)=>{this._renderer.forEachNode(i=>{if(t){const e=i.obb,r=new U(e.center,C(e.halfSize));k(r,this.view.renderSpatialReference,r,this.view.spatialReference);if(1===t(r))return}let r=this._queryFeaturesCache.get(`${i.id}`);r||(r=this._createQueryPointFeatures(i),this._queryFeaturesCache.put(`${i.id}`,r)),r.features.forEach(e)})},getFeatureExtent:({point:e},t)=>O(e,e,t),featureAdapter:{cloneWithGeometry:(e,t,i)=>new Ee(e.node,e.pointId,t.coords),getAttribute:({node:e,attributePointId:t},i)=>{for(const r of e.attributes)if(r.attributeInfo.name===i)return this._getGraphicAttribute(r.attributeInfo,r.values,t)},getAttributes:({node:e,attributePointId:t})=>this._createGraphicAttributes(e,t),getCentroid:e=>e.getGeometry(),getGeometry:e=>e.getGeometry(),getObjectId:()=>{},getMetadata:e=>e}})}),this._queryEngine}_createQueryPointFeatures(e){const t=e.coordinates,i=new Array;for(let r=0;r<t.length/3;r++){const s=3*r,o=j(t[s+0],t[s+1],t[s+2]);S(o,o,e.origin),F(o,this.view.renderSpatialReference,o,this.view.spatialReference);const n=new Ee(e,r,o);i.push(n)}return new Oe(i)}async _initNodePages(){const e=this.layer.store.index,t=e.nodesPerPage||e.nodePerIndexBlock;this._index=new se(this.layer.spatialReference,this.view.renderCoordsHelper.spatialReference,t),this._cancelIndexLoading(),this._traverseVisible=this._index.createVisibilityTraverse(),this._loadingInitNodePage=!0,this._layerIsVisible=!0,this.notifyChange("suspended"),this._updateLoading(),this._pageMultiplier=null!=e.nodesPerPage?1:e.nodePerIndexBlock;const i=await this.layer.rootPagePromise;this._loadingInitNodePage=!1,i?(this._index.addPage(0,this._processJSONNodes(i,0),this._elevationOffset),this._setUpdateViewNeeded()):n.getLogger(this).error("Point cloud layer root page not loaded")}_loadNodePage(e,t){const i=`${this.baseUrl}/nodepages/${e*this._pageMultiplier}`;return this._requestNodePage(i,t).then(t=>this._processJSONNodes(t,e))}_processJSONNodes(e,t){const i=t*this._index.pageSize;return e.nodes.map((e,t)=>({resourceId:e.resourceId??i+t,obb:ve.fromJSON(e.obb),obbInRenderSR:new ve,firstChild:e.firstChild,childCount:e.childCount,vertexCount:e.vertexCount??e.pointCount,lodThreshold:e.lodThreshold??e.effectiveArea}))}_updateWorkQueues(){if(!this._updateViewNeeded)return!1;const e=this.view.quality;let t=this.inverseDensity/this._lodFactor*e;const i=this.maximumPointCount*this._lodFactor*e;let r=this._computeNodesForMinimumDensity(t),s=this._computePointCount(r),o=Math.sqrt(s/(.75*i));for(;s>i;)t*=o,r=this._computeNodesForMinimumDensity(t),s=this._computePointCount(r),o=Math.sqrt(2);return this._displayNodes(r),this._updateViewNeeded=!1,this._updateLoading(),!0}_computePointCount(e){let t=0;for(let i=0;i<e.length;i++){const r=this._index.getNode(e[i]);r&&(t+=r.vertexCount)}return t}_isRootNodeVisible(){let e=!1;return this._traverseVisible({frustum:this.view.state.contentCamera.frustum,clippingBox:this._clippingBox},{predicate:(t,i,r)=>(e=r,!1),pageMiss:()=>{}}),e}_computeNodesForMinimumDensity(e){const t=this.view.state.contentCamera,i=t.frustum,r=this._clippingBox,s=t.viewForward,o=I(s,t.eye),n=L(s,-o,Ve),a=t.perScreenPixelRatio/2,d=e*e,l=this._nodeIdArray;l.length=0;const u=e=>l.push(e);return this._traverseVisible({frustum:i,clippingBox:r},{predicate:(e,t,i)=>{if(!i)return!1;if(0===t.childCount)return u(e),!1;const r=this._index.getRenderObb(e);return!(this._computeAveragePixelArea(r,t.lodThreshold,t.vertexCount,n,a)<=d)||(u(e),!1)},pageMiss:(e,t)=>{u(e),this._indexQueue.includes(t)||this._indexQueue.push(t)}}),l}_computeAveragePixelArea(e,t,i,r,s){const o=1e-7,n=Math.max(o,e.minimumDistancePlane(r));return t/(n*n)/(4*s*s)/i}_loadNode(e,t){try{return this._loadNodeAsync(e,t)}catch(i){throw _(i)||n.getLogger(this).error(i),i}}async _loadAdditionalUserAttributes(e,t,i){const s=this.layer.outFields;if(!s)return[];const o=q(this.layer.fieldsIndex,s),n=new Set(e.map(e=>null!=e?e.name:null)),a=this.layer.attributeStorageInfo,d=[];for(const r of o){if(n.has(r))continue;const e=_e(a,r);e&&d.push(t(e))}const l=await m(d);return g(i),l.filter(r)}async _loadNodeAsync(e,t){const i=this._index.getNode(e),r=he(this.layer),s=pe(this.layer),o=i.resourceId,n=async e=>{if(!e)return null;if(e.useElevation)return{attributeInfo:e,buffer:null};const i=await this._loadAttribute(o,e,t);return null!=i?{attributeInfo:e,buffer:i}:null};return this._idleQueue.push(async()=>{const i=this._loadGeometry(o,t),{primaryAttribute:a,modulationAttribute:d}=r,l=n(a),u=n(d),h=s.map(e=>e.attributeInfo),p=h.map(e=>n(e)),c=this._loadAdditionalUserAttributes([a,d,...h],n,t),[_,m,f,y,b]=await Promise.all([i,l,u,Promise.all(p),c]);g(t);const w={geometryBuffer:_,primaryAttributeData:m,modulationAttributeData:f,filterAttributesData:y,userAttributesData:b,schema:this.layer.store.defaultGeometrySchema,rendererInfo:r,filterInfo:s,obbData:this._index.getRenderObb(e).data,elevationOffset:this._elevationOffset,inSR:this.layer.spatialReference.toJSON(),outSR:this.view.renderCoordsHelper.spatialReference.toJSON()};return this._worker.invoke(w,t)},t)}async _loadGeometry(e,t){return this._requestData(`${this.baseUrl}/nodes/${e}/geometries/0`,t)}async _loadAttribute(e,t,i){if(!t?.storageInfo)return null;const r=t.storageInfo.key;return this._requestData(`${this.baseUrl}/nodes/${e}/attributes/${r}`,i)}async _requestNodePage(e,t){const r={useQueue:!1,query:{f:"json",...this.layer.customParameters,token:this.layer.apiKey},responseType:"json",signal:t};return(await i(e,r)).data}async _requestData(e,t){const r={useQueue:!1,query:{...this.layer.customParameters,token:this.layer.apiKey},responseType:"array-buffer",signal:t};return(await i(e,r)).data}_removeFromRenderer(e){if(this._renderedNodes.has(e)){const t=this._renderer.removeNode(e);this._renderedNodes.delete(e),this._memCache.put(`${t.id}`,t)}}_addToRenderer(e){this._renderedNodes.has(e.id)||(this._renderedNodes.add(e.id),this._renderer.addNode(e))}_setupRendererData(e,t){const i=this._index.getNode(e),r=Math.sqrt(i.lodThreshold/i.vertexCount),s=this._index.getRenderObb(e);if(ae(t))return t.splatSize=r,t.obb=s,A(t.origin,t.obb.center),t;const o=ve.fromData(t.obbData),a=o.halfSize,d=s.halfSize,l=.01*Math.max(d[0],d[1],d[2]);if(a[0]>d[0]+l||a[1]>d[1]+l||a[2]>d[2]+l){if(this._maxLoggedBoxWarnings>0){const t=e=>`[${e.halfSize[0]}, ${e.halfSize[1]}, ${e.halfSize[2]}]`;n.getLogger(this).warn(`Node ${e} reported bounding box too small. got ${t(s)} but points cover ${t(o)}`),0===--this._maxLoggedBoxWarnings&&n.getLogger(this).warn(" Too many bounding box errors, stopping reporting for this layer.")}this._index.setRenderObb(e,o)}return new de(e,r,R(s.center),s,0===i.childCount,t.points,t.rgb,t.attributes,t.pointIdFilterMap)}get usedMemory(){let e=0;return this._renderer.forEachNode(t=>{e+=Le,e+=l(t.coordinates);for(const i of t.attributes){const t=i.values;N(t.buffer)&&(e+=l(t))}}),e}get unloadedMemory(){const e=this._renderedNodes.size;if(e<4)return 0;const t=[...this._renderedNodes].reduce((e,t)=>e+this._index.getNode(t).vertexCount);let i=this._loadingNodes.size;for(let r=0;r<this._workQueue.length;r++)i+=this._workQueue[r].load.length,i-=this._workQueue[r].remove.length;if(i<0)return 0;return i*t/e*((this.usedMemory-e*Le)/t)+i*Le}get performanceInfo(){return new J(this.usedMemory,this._renderedNodes.size,[...this._renderedNodes].reduce((e,t)=>e+this._index.getNode(t).vertexCount,0),this.maximumPointCount,new K(this._loadingNodes.size,this._indexQueue.length,this._workQueue.length,this._idleQueue.length))}get test(){}};e([v()],ke.prototype,"layer",void 0),e([v()],ke.prototype,"baseUrl",null),e([v()],ke.prototype,"pointScale",null),e([v()],ke.prototype,"useRealWorldSymbolSizes",null),e([v()],ke.prototype,"pointSize",null),e([v()],ke.prototype,"inverseDensity",null),e([v()],ke.prototype,"maximumPointCount",void 0),e([v({readOnly:!0})],ke.prototype,"availableFields",null),e([v({readOnly:!0})],ke.prototype,"_clippingBox",null),e([v({readOnly:!0})],ke.prototype,"_elevationOffset",null),e([v({type:Boolean})],ke.prototype,"slicePlaneEnabled",void 0),e([v()],ke.prototype,"_graphicOrigin",null),e([v()],ke.prototype,"updating",void 0),e([v(xe)],ke.prototype,"updatingProgress",void 0),e([v({readOnly:!0})],ke.prototype,"updatingProgressValue",null),e([v({readOnly:!0})],ke.prototype,"visibleAtCurrentScale",null),ke=e([x("esri.views.3d.layers.PointCloudLayerView3D")],ke);const Fe=ke;class Ee{constructor(e,t,i){this.node=e,this.pointId=t,this.point=i}getGeometry(){return new W([],Array.from(this.point),!0,!1)}get attributePointId(){const{node:e,pointId:t}=this;return null!=e.pointIdFilterMap?e.pointIdFilterMap[t]:t}get usedMemory(){return u+u+h+p(this.point,h)}}class Oe{constructor(e){this.features=e}get usedMemory(){return this.features.reduce((e,t)=>e+t.usedMemory,u+c)}}const Le=160;function De(e){return t=>e.immediate.schedule(t)}export{Fe as default};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import e from"../../../../../core/Error.js";import"../../../../../core/has.js";import{NestedMap as t}from"../../../../../core/NestedMap.js";import{ShaderTechniqueConfiguration as o}from"./ShaderTechniqueConfiguration.js";class c{constructor(e){this._context=e,this._debug=null,this._precompiling=this._debug?0:1,this._cache=new t}get context(){return this._context}get precompiling(){return this._precompiling}set precompiling(e){this._precompiling=e,0===e&&this.context.rctx.gl.flush()}destroy(){this._cache.forAll(e=>e.destroy()),this._cache.clear(),this._context=null}precompile(e,t=i){++this.precompiling,this.get(e,t),--this.precompiling}get(t,o=i,c){const n=o.key.code;let s=this._cache.get(t,n);if(null==s){if(s=new t(this.context,o,c),this._debug){if(0===this._precompiling){let c=`Uncached shader compile in ${(new Error).stack}\n for configuration\n${o.decode()}`;const r=this._cache.getInner(t);throw r?.size&&(c+="\n\n cached configurations:\n",c+=Array.from(r.values()).map(e=>o.decode(e.key)).sort().join("\n\n")),console.log(c),new e("shader:uncached-compile",c)}this._debug.set(s,new r(o,(new Error).stack))}this._cache.set(t,n,s)}return s}frameUpdate(){this._debug&&this._cache.forAll(t=>{if(!t.unused||t.ignoreUnused)return;const o=this._debug?.get(t),c=`Unused shader technique for ${t.declaredClass}\n${o?.configuration.decode(t.key)} \nfrom\n${o?.stack}`;throw console.log(c),new e("shader:unused-precompile",c)})}async reloadAll(){const e=new Array;this._cache.forEach(t=>e.push(n(t))),await Promise.all(e)}}class r{constructor(e,t){this.configuration=e,this.stack=t}}async function n(e){let t=!0;e.forEach(async e=>{await e.reload(t),t=!1})}const i=new o;export{i as NoConfiguration,c as ShaderTechniqueRepository};
2
+ import e from"../../../../../core/Error.js";import"../../../../../core/has.js";import{NestedMap as t}from"../../../../../core/NestedMap.js";import{ShaderTechniqueConfiguration as o}from"./ShaderTechniqueConfiguration.js";class c{constructor(e){this._context=e,this._debug=null,this._precompiling=this._debug?0:1,this._cache=new t}get context(){return this._context}get precompiling(){return this._precompiling}set precompiling(e){this._precompiling=e,0===e&&this.context.rctx.gl.flush()}destroy(){this._cache.forAll(e=>e.destroy()),this._cache.clear(),this._context=null}precompile(e,t=i){++this.precompiling,this.get(e,t),--this.precompiling}get(t,o=i,c){const r=o.key.code;let s=this._cache.get(t,r);if(null==s){if(s=new t(this.context,o,c),this._debug){if(0===this._precompiling){let c=`Uncached shader compile in ${(new Error).stack}\n for configuration\n${o.decode()}`;const n=this._cache.getInner(t);throw n?.size&&(c+="\n\n cached configurations:\n",c+=Array.from(n.values()).map(e=>o.decode(e.key)).sort().join("\n\n")),console.log(c),new e("shader:uncached-compile",c)}this._debug.set(s,new n(o,(new Error).stack))}this._cache.set(t,r,s)}return s}getCompiled(e,t=i,o){const c=this.get(e,t,o);return c.compiled?c:null}frameUpdate(){this._debug&&this._cache.forAll(t=>{if(!t.unused||t.ignoreUnused)return;const o=this._debug?.get(t),c=`Unused shader technique for ${t.declaredClass}\n${o?.configuration.decode(t.key)} \nfrom\n${o?.stack}`;throw console.log(c),new e("shader:unused-precompile",c)})}async reloadAll(){const e=new Array;this._cache.forEach(t=>e.push(r(t))),await Promise.all(e)}}class n{constructor(e,t){this.configuration=e,this.stack=t}}async function r(e){let t=!0;e.forEach(async e=>{await e.reload(t),t=!1})}const i=new o;export{i as NoConfiguration,c as ShaderTechniqueRepository};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import e from"../../../../core/Logger.js";import r from"../../../../core/PooledArray.js";class t{constructor(e){this._context=e,this._nodes=new r}destroy(){this._nodes.forEach(e=>e.destroy()),this._nodes.prune()}add(e){this._nodes.push(e)}remove(e){this._nodes.remove(e)}produces(e){return this._nodes.some(({produces:r})=>r===e)}require(e,...r){const t=this._nodes,o=r=>t.reduce((t,{consumes:o,produces:n})=>t+(!o.required.includes(e)||null!=r&&n!==r?0:1),0);return 0===r.length?o():r.reduce((e,r)=>e+o(r),0)}optional(e,...r){const t=this._nodes,o=r=>t.reduce((t,{consumes:o,produces:n})=>t+(!o.optional?.includes(e)||null!=r&&n!==r?0:1),0);return 0===r.length?o():r.reduce((e,r)=>e+o(r),0)}updateAnimation(e){return this._nodes.reduce((r,t)=>t.updateAnimation(e)||r,!1)}precompile(...e){++this._context.techniques.precompiling;for(const r of e)this._nodes.forEach(e=>{e.produces===r&&e.precompile()});--this._context.techniques.precompiling}render(e,r,t=()=>{}){return this._render(e,r,t)??e}produce(e,r,t=()=>{}){return this._render(e,r,t)}_render(r,t,o=()=>{}){const n="string"==typeof r?r:r.name,s=this._nodes.filter(({produces:e})=>e===n);if(0===s.length)return;let i="string"==typeof r?null:r;return s.some(r=>{const s=i?[i]:[],c=null==i;for(const e of r.consumes.required){if(e===n){if(c)return!1;continue}const r=t.get(e);if(r)s.push(r);else if("emissive"!==e||!t.get(n)?.hasAttachment(e))return o?.(s),!1}if(r.consumes.optional)for(const e of r.consumes.optional){if(e===n)continue;const r=t.get(e);r&&s.push(r)}try{const o=r.doRender(s);o&&o!==i&&(n!==o.name&&(e.getLogger(r).errorOnce(`RenderNode produced ${o.name}, expected ${n}`),o.setName(n)),i?.release(),i=o,t.set(n,i))}catch(u){e.getLogger(r).errorOnce(u)}return o?.(s),c&&null!=i}),this._context.rctx.enforceState(),i}requireGeometryDepth(){return this._nodes.some(e=>"disabled"!==e.produces&&e.requireGeometryDepth)}get test(){return{nodes:this._nodes}}}export{t as RenderNodes};
2
+ import e from"../../../../core/Logger.js";import r from"../../../../core/PooledArray.js";class t{constructor(e){this._context=e,this._nodes=new r}destroy(){this._nodes.forEach(e=>e.destroy()),this._nodes.prune()}add(e){this._nodes.push(e)}remove(e){this._nodes.remove(e)}produces(e){return this._nodes.some(({produces:r})=>r===e)}require(e,...r){const t=this._nodes,o=r=>t.reduce((t,{consumes:o,produces:s})=>t+(!o.required.includes(e)||null!=r&&s!==r?0:1),0);return 0===r.length?o():r.reduce((e,r)=>e+o(r),0)}optional(e,...r){const t=this._nodes,o=r=>t.reduce((t,{consumes:o,produces:s})=>t+(!o.optional?.includes(e)||null!=r&&s!==r?0:1),0);return 0===r.length?o():r.reduce((e,r)=>e+o(r),0)}updateAnimation(e){return this._nodes.reduce((r,t)=>t.updateAnimation(e)||r,!1)}precompile(e,...r){++this._context.techniques.precompiling;for(const t of r)this._nodes.forEach(r=>{const o=e||!r.consumes.required.includes("emissive");r.produces===t&&o&&r.precompile()});--this._context.techniques.precompiling}render(e,r,t=()=>{}){return this._render(e,r,t)??e}produce(e,r,t=()=>{}){return this._render(e,r,t)}_render(r,t,o=()=>{}){const s="string"==typeof r?r:r.name,n=this._nodes.filter(({produces:e})=>e===s);if(0===n.length)return;let i="string"==typeof r?null:r;return n.some(r=>{const n=i?[i]:[],c=null==i;for(const e of r.consumes.required){if(e===s){if(c)return!1;continue}const r=t.get(e);if(r)n.push(r);else if("emissive"!==e||!t.get(s)?.hasAttachment(e))return o?.(n),!1}if(r.consumes.optional)for(const e of r.consumes.optional){if(e===s)continue;const r=t.get(e);r&&n.push(r)}try{const o=r.doRender(n);o&&o!==i&&(s!==o.name&&(e.getLogger(r).errorOnce(`RenderNode produced ${o.name}, expected ${s}`),o.setName(s)),i?.release(),i=o,t.set(s,i))}catch(u){e.getLogger(r).errorOnce(u)}return o?.(n),c&&null!=i}),this._context.rctx.enforceState(),i}requireGeometryDepth(){return this._nodes.some(e=>"disabled"!==e.produces&&e.requireGeometryDepth)}get test(){return{nodes:this._nodes}}}export{t as RenderNodes};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{C as e}from"../../../../../chunks/Compositing.glsl.js";import{CompositingTechnique as t}from"../../shaders/CompositingTechnique.js";import{CompositingTechniqueConfiguration as i}from"../../shaders/CompositingTechniqueConfiguration.js";class r{constructor(t,r=0){this._techniques=t,this._parameters=new e,this._configuration=new i,this._configuration.blitMode=r,this.precompile()}precompile(){this._techniques.precompile(t,this._configuration)}toFramebuffer(e,t,i){this.blitTexture(e,t.getTexture(),i)}blitTexture(e,i,r,s){e.bindFramebuffer(s?.fbo),e.setClearColor(0,0,0,1),e.clear(16384),this._parameters.texture=i;const o=this._techniques.get(t,this._configuration);e.bindTechnique(o,r,this._parameters),e.screen.draw()}blend(e,i,r,s,o=1){const n=this._techniques.get(t,this._configuration);return!!n.compiled&&(e.bindFramebuffer(r.fbo),this._parameters.texture=i.getTexture(),this._parameters.opacity=o,e.bindTechnique(n,s,this._parameters),e.screen.draw(),!0)}}export{r as Blit};
2
+ import{C as e}from"../../../../../chunks/Compositing.glsl.js";import{CompositingTechnique as t}from"../../shaders/CompositingTechnique.js";import{CompositingTechniqueConfiguration as i}from"../../shaders/CompositingTechniqueConfiguration.js";class r{constructor(t,r=0){this._techniques=t,this._parameters=new e,this._configuration=new i,this._configuration.blitMode=r,this.precompile()}precompile(){this._techniques.precompile(t,this._configuration)}toFramebuffer(e,t,i){this.blitTexture(e,t.getTexture(),i)}blitTexture(e,i,r,s){e.bindFramebuffer(s?.fbo),e.setClearColor(0,0,0,1),e.clear(16384),this._parameters.texture=i;const o=this._techniques.get(t,this._configuration);e.bindTechnique(o,r,this._parameters),e.screen.draw()}blend(e,i,r,s,o=1){const n=this._techniques.getCompiled(t,this._configuration);return!!n&&(e.bindFramebuffer(r.fbo),this._parameters.texture=i.getTexture(),this._parameters.opacity=o,e.bindTechnique(n,s,this._parameters),e.screen.draw(),!0)}}export{r as Blit};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import{watch as t}from"../../../../../core/reactiveUtils.js";import{property as s,subclass as r}from"../../../../../core/accessorSupport/decorators.js";import{InternalRenderCategory as i}from"../../../webgl.js";import o from"../../../webgl/RenderNode.js";import{F as a}from"../../../../../chunks/FocusAreaColor.glsl.js";import{FocusAreaColorTechnique as n}from"./FocusAreaColorTechnique.js";import{DepthStencilAttachment as c}from"../../../../webgl/enums.js";let d=class extends o{constructor(e){super({...e,view:e.focusAreasView.view}),this.consumes={required:[i.FOCUSAREA_COLOR,i.FOCUSAREA]},this.produces=i.FOCUSAREA_COLOR,this._fadeDirection=0,this._passParameters=new a}precompile(){this.techniques.precompile(n)}fadeOut(e){this.removeAllHandles(),this._startTime=null,this._fadeDirection=1,this.addHandles(t(()=>this._passParameters.fadeFactor.value,t=>{0===t&&(this.removeAllHandles(),e())})),this.requestRender(2)}render(e){const t=this.techniques.get(n),s=e.find(({name:e})=>e===this.produces);if(!t.compiled)return this.requestRender(1),s;const r=this.focusAreasView.style,o=this.bindParameters,a=o.camera,d=a.fullViewport[2],m=a.fullViewport[3];this._startTime??=this.view.stage?.renderer.renderContext.time;const u=this.view.qualitySettings.fadeDuration,p=u>0?Math.min(u,this.view.stage?.renderer.renderContext.time-this._startTime)/u:1,l=e.find(({name:e})=>e===i.FOCUSAREA),f=this.fboCache.acquire(d,m,this.produces),A=this.renderingContext;return A.bindFramebuffer(f.fbo),this._passParameters.color=s.getTexture(),this._passParameters.focusArea=l.getTexture(),this._passParameters.effect=h[r],this._passParameters.fadeFactor.value=0===this._fadeDirection?p:1-p,A.bindTechnique(t,o,this._passParameters),A.screen.draw(),f.attachDepth(s.getAttachment(c)),p<1&&this.requestRender(2),f}};e([s()],d.prototype,"consumes",void 0),e([s()],d.prototype,"produces",void 0),e([s({constructOnly:!0})],d.prototype,"focusAreasView",void 0),d=e([r("esri.views.3d.webgl-engine.effects.focusArea.FocusAreaColorNode")],d);const h={bright:0,dark:1};export{d as FocusAreaColorNode,h as styleToEffect};
2
+ import{__decorate as e}from"tslib";import{watch as t}from"../../../../../core/reactiveUtils.js";import{property as s,subclass as r}from"../../../../../core/accessorSupport/decorators.js";import{InternalRenderCategory as i}from"../../../webgl.js";import o from"../../../webgl/RenderNode.js";import{F as a}from"../../../../../chunks/FocusAreaColor.glsl.js";import{FocusAreaColorTechnique as n}from"./FocusAreaColorTechnique.js";import{DepthStencilAttachment as c}from"../../../../webgl/enums.js";let d=class extends o{constructor(e){super({...e,view:e.focusAreasView.view}),this.consumes={required:[i.FOCUSAREA_COLOR,i.FOCUSAREA]},this.produces=i.FOCUSAREA_COLOR,this._fadeDirection=0,this._passParameters=new a}precompile(){this.techniques.precompile(n)}fadeOut(e){this.removeAllHandles(),this._startTime=null,this._fadeDirection=1,this.addHandles(t(()=>this._passParameters.fadeFactor.value,t=>{0===t&&(this.removeAllHandles(),e())})),this.requestRender(2)}render(e){const t=e.find(({name:e})=>e===this.produces),s=this.techniques.getCompiled(n);if(!s)return this.requestRender(1),t;const r=this.focusAreasView.style,o=this.bindParameters,a=o.camera,d=a.fullViewport[2],m=a.fullViewport[3];this._startTime??=this.view.stage?.renderer.renderContext.time;const u=this.view.qualitySettings.fadeDuration,p=u>0?Math.min(u,this.view.stage?.renderer.renderContext.time-this._startTime)/u:1,l=e.find(({name:e})=>e===i.FOCUSAREA),f=this.fboCache.acquire(d,m,this.produces),A=this.renderingContext;return A.bindFramebuffer(f.fbo),this._passParameters.color=t.getTexture(),this._passParameters.focusArea=l.getTexture(),this._passParameters.effect=h[r],this._passParameters.fadeFactor.value=0===this._fadeDirection?p:1-p,A.bindTechnique(s,o,this._passParameters),A.screen.draw(),f.attachDepth(t.getAttachment(c)),p<1&&this.requestRender(2),f}};e([s()],d.prototype,"consumes",void 0),e([s()],d.prototype,"produces",void 0),e([s({constructOnly:!0})],d.prototype,"focusAreasView",void 0),d=e([r("esri.views.3d.webgl-engine.effects.focusArea.FocusAreaColorNode")],d);const h={bright:0,dark:1};export{d as FocusAreaColorNode,h as styleToEffect};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import{property as t,subclass as s}from"../../../../../core/accessorSupport/decorators.js";import{RenderNodeOutput as r,InternalRenderCategory as i}from"../../../webgl.js";import o from"../../../webgl/RenderNode.js";import{F as n}from"../../../../../chunks/FocusAreaMask.glsl.js";import{FocusAreaMaskTechnique as a}from"./FocusAreaMaskTechnique.js";import{Pos3 as h}from"../../lib/DefaultVertexBufferLayouts.js";import{VertexArrayObject as c}from"../../lib/VertexArrayObject.js";import{DepthStencilAttachment as l,PrimitiveType as u}from"../../../../webgl/enums.js";import{noParameters as p}from"../../../../webgl/NoParameters.js";import{VertexBuffer as m}from"../../../../webgl/VertexBuffer.js";let d=class extends o{constructor(e){super({...e,view:e.focusAreasView.view}),this.consumes={required:[r.TRANSPARENT]},this.produces=i.FOCUSAREA,this._vaos=new Array,this._counts=new Array,this._origins=new Array,this._maskParameters=new n}initialize(){this.updateGeometries()}destroy(){this._vaos.forEach(e=>e.dispose()),this._vaos.length=this._counts.length=this._origins.length=0}precompile(){this.techniques.precompile(a)}render(e){const t=this.techniques.get(a),s=this.bindParameters,o=s.camera,n=o.fullViewport[2],h=o.fullViewport[3];if(!t.compiled||!this._vaos)return void this.requestRender(1);const c=e.find(({name:e})=>e===r.TRANSPARENT),m=this.renderingContext,d=this.fboCache.acquire(n,h,i.FOCUSAREA,2);this.view.stage.renderer.occludedRequiresStencil?(d.acquireDepth(13),m.blitFramebuffer(c.fbo,d.fbo,256)):d.attachDepth(c.getAttachment(l)),m.bindFramebuffer(d.fbo),m.setClearColor(0,0,0,1),m.clear(17408),m.setViewport(0,0,n,h);const f=m.bindTechnique(t,s);m.setFaceCullingEnabled(!1),m.setStencilTestEnabled(!0),m.setStencilOpSeparate(1028,7680,34055,7680),m.setStencilOpSeparate(1029,7680,34056,7680),m.setDepthWriteEnabled(!1);for(let r=0;r<this._vaos.length;r++){const e=this._vaos[r],t=this._counts[r];this._maskParameters.origin=this._origins[r],f.bindDraw(s,p,this._maskParameters),m.bindVAO(e),m.setDepthTestEnabled(!0),m.setStencilWriteMask(255),m.setStencilFunction(519,0,255),m.setColorMask(!1,!1,!1,!1),m.drawArrays(u.TRIANGLES,0,t),m.setDepthTestEnabled(!1),m.setStencilWriteMask(0),m.setStencilFunction(517,0,255),m.setColorMask(!0,!0,!0,!0),m.drawArrays(u.TRIANGLES,0,t)}return d}updateGeometries(){if(!this.view.stage)return;this._vaos.forEach(e=>e.dispose()),this._vaos.length=this._counts.length=this._origins.length=0;this.focusAreasView.volumes.forEach(e=>{const t=new Array;let s=0,r=0;e.geometryVolumes.forEach(e=>{const i=e.indicesBottom;s+=i.length;for(let s=0;s<i.length;s++)t.push(e.positions[3*(i[s]-1)]),t.push(e.positions[3*(i[s]-1)+1]),t.push(e.positions[3*(i[s]-1)+2]);const o=e.indicesExtruded;r+=o.length;for(let s=0;s<o.length;s++)t.push(e.positions[3*o[s]]),t.push(e.positions[3*o[s]+1]),t.push(e.positions[3*o[s]+2])});const i=new c(this.renderingContext,new m(this.renderingContext,h,new Float32Array(t)));this._vaos.push(i),this._counts.push(s+r),this._origins.push(e.origin)}),this.requestRender(1)}};e([t()],d.prototype,"consumes",void 0),e([t()],d.prototype,"produces",void 0),e([t({constructOnly:!0})],d.prototype,"focusAreasView",void 0),d=e([s("esri.views.3d.webgl-engine.effects.focusArea.FocusAreaMaskNode")],d);export{d as FocusAreaMaskNode};
2
+ import{__decorate as e}from"tslib";import{property as t,subclass as s}from"../../../../../core/accessorSupport/decorators.js";import{RenderNodeOutput as r,InternalRenderCategory as i}from"../../../webgl.js";import o from"../../../webgl/RenderNode.js";import{F as n}from"../../../../../chunks/FocusAreaMask.glsl.js";import{FocusAreaMaskTechnique as a}from"./FocusAreaMaskTechnique.js";import{Pos3 as h}from"../../lib/DefaultVertexBufferLayouts.js";import{VertexArrayObject as c}from"../../lib/VertexArrayObject.js";import{DepthStencilAttachment as l,PrimitiveType as u}from"../../../../webgl/enums.js";import{noParameters as p}from"../../../../webgl/NoParameters.js";import{VertexBuffer as m}from"../../../../webgl/VertexBuffer.js";let d=class extends o{constructor(e){super({...e,view:e.focusAreasView.view}),this.consumes={required:[r.TRANSPARENT]},this.produces=i.FOCUSAREA,this._vaos=new Array,this._counts=new Array,this._origins=new Array,this._maskParameters=new n}initialize(){this.updateGeometries()}destroy(){this._vaos.forEach(e=>e.dispose()),this._vaos.length=this._counts.length=this._origins.length=0}precompile(){this.techniques.precompile(a)}render(e){const t=this.techniques.getCompiled(a);if(!t||!this._vaos)return void this.requestRender(1);const s=e.find(({name:e})=>e===r.TRANSPARENT),o=this.renderingContext,n=this.bindParameters,h=n.camera,c=h.fullViewport[2],m=h.fullViewport[3],d=this.fboCache.acquire(c,m,i.FOCUSAREA,2);this.view.stage.renderer.occludedRequiresStencil?(d.acquireDepth(13),o.blitFramebuffer(s.fbo,d.fbo,256)):d.attachDepth(s.getAttachment(l)),o.bindFramebuffer(d.fbo),o.setClearColor(0,0,0,1),o.clear(17408),o.setViewport(0,0,c,m);const f=o.bindTechnique(t,n);o.setFaceCullingEnabled(!1),o.setStencilTestEnabled(!0),o.setStencilOpSeparate(1028,7680,34055,7680),o.setStencilOpSeparate(1029,7680,34056,7680),o.setDepthWriteEnabled(!1);for(let r=0;r<this._vaos.length;r++){const e=this._vaos[r],t=this._counts[r];this._maskParameters.origin=this._origins[r],f.bindDraw(n,p,this._maskParameters),o.bindVAO(e),o.setDepthTestEnabled(!0),o.setStencilWriteMask(255),o.setStencilFunction(519,0,255),o.setColorMask(!1,!1,!1,!1),o.drawArrays(u.TRIANGLES,0,t),o.setDepthTestEnabled(!1),o.setStencilWriteMask(0),o.setStencilFunction(517,0,255),o.setColorMask(!0,!0,!0,!0),o.drawArrays(u.TRIANGLES,0,t)}return d}updateGeometries(){if(!this.view.stage)return;this._vaos.forEach(e=>e.dispose()),this._vaos.length=this._counts.length=this._origins.length=0;this.focusAreasView.volumes.forEach(e=>{const t=new Array;let s=0,r=0;e.geometryVolumes.forEach(e=>{const i=e.indicesBottom;s+=i.length;for(let s=0;s<i.length;s++)t.push(e.positions[3*(i[s]-1)]),t.push(e.positions[3*(i[s]-1)+1]),t.push(e.positions[3*(i[s]-1)+2]);const o=e.indicesExtruded;r+=o.length;for(let s=0;s<o.length;s++)t.push(e.positions[3*o[s]]),t.push(e.positions[3*o[s]+1]),t.push(e.positions[3*o[s]+2])});const i=new c(this.renderingContext,new m(this.renderingContext,h,new Float32Array(t)));this._vaos.push(i),this._counts.push(s+r),this._origins.push(e.origin)}),this.requestRender(1)}};e([t()],d.prototype,"consumes",void 0),e([t()],d.prototype,"produces",void 0),e([t({constructOnly:!0})],d.prototype,"focusAreasView",void 0),d=e([s("esri.views.3d.webgl-engine.effects.focusArea.FocusAreaMaskNode")],d);export{d as FocusAreaMaskNode};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import{subclass as r}from"../../../../../core/accessorSupport/decorators.js";import{ReloadableShader as o}from"../../core/shaderTechnique/ReloadableShader.js";import{ShaderTechnique as s}from"../../core/shaderTechnique/ShaderTechnique.js";import{a as i}from"../../../../../chunks/GlowBlur.glsl.js";import{makePipelineState as t,defaultColorWrite as l}from"../../../../webgl/renderState.js";let c=class extends s{constructor(){super(...arguments),this.shader=new o(i,()=>import("./GlowBlur.glsl.js")),this.ignoreUnused=!0}initializePipeline(){return t({colorWrite:l})}};c=e([r("esri.views.3d.webgl-engine.effects.glow.GlowBlurTechnique")],c);export{c as GlowBlurTechnique};
2
+ import{__decorate as e}from"tslib";import{subclass as r}from"../../../../../core/accessorSupport/decorators.js";import{ReloadableShader as o}from"../../core/shaderTechnique/ReloadableShader.js";import{ShaderTechnique as s}from"../../core/shaderTechnique/ShaderTechnique.js";import{a as i}from"../../../../../chunks/GlowBlur.glsl.js";import{makePipelineState as t,defaultColorWrite as l}from"../../../../webgl/renderState.js";let c=class extends s{constructor(){super(...arguments),this.shader=new o(i,()=>import("./GlowBlur.glsl.js"))}initializePipeline(){return t({colorWrite:l})}};c=e([r("esri.views.3d.webgl-engine.effects.glow.GlowBlurTechnique")],c);export{c as GlowBlurTechnique};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import{subclass as r}from"../../../../../core/accessorSupport/decorators.js";import{ReloadableShader as o}from"../../core/shaderTechnique/ReloadableShader.js";import{ShaderTechnique as s}from"../../core/shaderTechnique/ShaderTechnique.js";import{b as i}from"../../../../../chunks/GlowComposition.glsl.js";import{ColorAttachment0 as t,ColorAttachment1 as l}from"../../../../webgl/enums.js";import{makePipelineState as n,defaultColorWrite as m}from"../../../../webgl/renderState.js";let c=class extends s{constructor(){super(...arguments),this.shader=new o(i,()=>import("./GlowComposition.glsl.js")),this.ignoreUnused=!0}initializePipeline(e){return n({colorWrite:m,drawBuffers:{buffers:e.blurEnabled?[t,l]:[t]}})}};c=e([r("esri.views.3d.webgl-engine.effects.glow.GlowCompositionTechnique")],c);export{c as GlowCompositionTechnique};
2
+ import{__decorate as e}from"tslib";import{subclass as r}from"../../../../../core/accessorSupport/decorators.js";import{ReloadableShader as o}from"../../core/shaderTechnique/ReloadableShader.js";import{ShaderTechnique as s}from"../../core/shaderTechnique/ShaderTechnique.js";import{b as i}from"../../../../../chunks/GlowComposition.glsl.js";import{ColorAttachment0 as t,ColorAttachment1 as l}from"../../../../webgl/enums.js";import{makePipelineState as m,defaultColorWrite as n}from"../../../../webgl/renderState.js";let c=class extends s{constructor(){super(...arguments),this.shader=new o(i,()=>import("./GlowComposition.glsl.js"))}initializePipeline(e){return m({colorWrite:n,drawBuffers:{buffers:e.blurEnabled?[t,l]:[t]}})}};c=e([r("esri.views.3d.webgl-engine.effects.glow.GlowCompositionTechnique")],c);export{c as GlowCompositionTechnique};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{__decorate as t}from"tslib";import{lerp as e}from"../../../../../core/mathUtils.js";import{watch as i,syncAndInitial as s}from"../../../../../core/reactiveUtils.js";import{property as r,subclass as o}from"../../../../../core/accessorSupport/decorators.js";import{length as a}from"../../../../../core/libs/gl-matrix-2/math/vec3.js";import{ZEROS as n}from"../../../../../core/libs/gl-matrix-2/factories/vec4f32.js";import{getReferenceEllipsoid as h}from"../../../../../geometry/ellipsoidUtils.js";import{InternalRenderCategory as c}from"../../../webgl.js";import{TransparentEnvironment as m}from"../TransparentEnvironment.js";import{G as l}from"../../../../../chunks/GlowBlur.glsl.js";import{GlowBlurTechnique as p}from"./GlowBlurTechnique.js";import{GlowBlurTechniqueConfiguration as u}from"./GlowBlurTechniqueConfiguration.js";import{G as g,a as _,m as d}from"../../../../../chunks/GlowComposition.glsl.js";import{GlowCompositionTechnique as f}from"./GlowCompositionTechnique.js";import{GlowCompositionTechniqueConfiguration as w}from"./GlowCompositionTechniqueConfiguration.js";import{ColorAttachment1 as b,DepthStencilAttachment as P}from"../../../../webgl/enums.js";let T=class extends m{constructor(t){super(t),this.consumes={required:[c.TRANSPARENT_ENVIRONMENT,"emissive"]},this.produces=c.TRANSPARENT_ENVIRONMENT,this._blurHorizontalConfiguration=new u,this._blurVerticalConfiguration=new u,this._compositionConfiguration=new w,this._compositionParameters=new g,this._blurParameters=new l,this._blurScalePerLod=3.06,this._logicalBlurRadius=.0037,this._mode=0,this._intensity=.5,this._scatteringFactors={realistic:new _([.8,.12,.05,.02,.01,0]),maximumFog:new _([0,.27,.6,1.05,1.58,2.1],!1),cartographicMin:new _([.4,.18,.25,.12,.05,0],!1),cartographicDefault:new _([1.17,1.08,.78,.4,.26,.11],!1),cartographicMax:new _([3.59,3.9,2.46,1.4,.93,.44],!1)},this._glowResults=new Array;const e=h(t.view.spatialReference);this._atmosphereRadius=e.radius+e.atmosphereHeight;t.view.stage.renderView.techniques.precompile(f,this._compositionConfiguration),this._compositionParameters.minDisperse=new _([.8,.12,.05,.02,.01,0])}initialize(){this.addHandles([i(()=>this._updateFogParameters(),()=>{},s),i(()=>this._updateParameters(),()=>{},s)])}_updateParameters(){const t=this.view.environment.lighting.glow;this._mode=null==t?this.view.environment.atmosphereEnabled?0:2:1,t&&(this._intensity=t.intensity),this._compositionParameters.minDisperse&&(this._compositionParameters.minDisperse.presets=this.getPreset(this._mode)),this.precompile(),this.requestRender(1)}_updateFogParameters(){const t=this.view.environment.weather;"sunny"===t.type||"cloudy"===t.type?this._compositionParameters.distanceModifier=0:this._compositionParameters.distanceModifier="foggy"===t.type?e(3e-5,.005,t.fogStrength**3):e(4e-6,2e-4,(t.precipitation??0)**3),this._compositionParameters.maxDisperse=this._scatteringFactors.maximumFog,this.requestRender(1)}precompile(){this.techniques.precompile(p,this._blurHorizontalConfiguration),this._blurVerticalConfiguration.glowStage=1,this.techniques.precompile(p,this._blurVerticalConfiguration),this._compositionConfiguration.blurEnabled=!0,this.techniques.precompile(f,this._compositionConfiguration),this._compositionConfiguration.blurEnabled=!1,this.techniques.precompile(f,this._compositionConfiguration)}render(t){const e=t.find(({name:t})=>t===c.TRANSPARENT_ENVIRONMENT),i=e.getAttachment(b);if(!i?.attachment)return e;const s=2!==this._mode;this._compositionConfiguration.blurEnabled=s;const r=e.getAttachment(P);if(!s){const t=this.techniques.get(f,this._compositionConfiguration);if(!t.compiled)return this.requestRender(1),e;const s=e.getTexture(),o=this.fboCache,{fullWidth:a,fullHeight:n}=this.bindParameters.camera,h=this.renderingContext,c=o.acquire(s.descriptor.width,s.descriptor.height,this.produces);return this._prepareFBO(c,a,n),this._compositionParameters.color=s,this._compositionParameters.emission=i.attachment,h.bindTechnique(t,this.bindParameters,this._compositionParameters),h.screen.draw(),c.attachDepth(r),c.attachColor(i,b),c}const o=this.techniques.get(p,this._blurHorizontalConfiguration),n=this.techniques.get(p,this._blurVerticalConfiguration),h=this.techniques.get(f,this._compositionConfiguration);if(!o.compiled||!n.compiled||!h.compiled)return this.requestRender(1),e;const m=e.getTexture(),l=this.fboCache,{fullWidth:u,fullHeight:g}=this.bindParameters.camera,_=this.renderingContext;let d=i.attachment,w=Math.ceil(u/2),T=Math.ceil(g/2);const C=5;this._blurParameters.blurRadius=this._logicalBlurRadius;for(let a=0;a<C;a++){const t=l.acquire(w,T,"glow horizontal",8);this._blurParameters.emissionsToDownsample=d,this._prepareFBO(t,w,T),_.bindTechnique(o,this.bindParameters,this._blurParameters),_.screen.draw();const e=l.acquire(w,T,"glow vertical",8);this._blurParameters.emissionsToDownsample=t.getTexture(),this._prepareFBO(e,w,T),_.bindTechnique(n,this.bindParameters,this._blurParameters),_.screen.draw(),t.release(),this._glowResults[a]=e,w=Math.ceil(w/2),T=Math.ceil(T/2),d=this._glowResults[a].getTexture(),this._blurParameters.blurRadius*=this._blurScalePerLod}const R=this.bindParameters.camera,q=a(R.eye);this._compositionParameters.atmosphereC=q**2-this._atmosphereRadius**2,this._compositionParameters.color=m,this._compositionParameters.emission=i.attachment,this._compositionParameters.lodTexture0=this._glowResults[0].getTexture(),this._compositionParameters.lodTexture1=this._glowResults[1].getTexture(),this._compositionParameters.lodTexture2=this._glowResults[2].getTexture(),this._compositionParameters.lodTexture3=this._glowResults[3].getTexture(),this._compositionParameters.lodTexture4=this._glowResults[4].getTexture();const x=l.acquire(m.descriptor.width,m.descriptor.height,this.produces);return x.acquireColor(b,8,"emissive glow"),this._prepareFBO(x,u,g,!0),_.bindTechnique(h,this.bindParameters,this._compositionParameters),_.screen.draw(),this._glowResults.forEach(t=>t.release()),x.attachDepth(r),x}getPreset(t){return 0===t?this._scatteringFactors.realistic.presets:this._intensity<=.5?d(this._scatteringFactors.cartographicMin.presets,this._scatteringFactors.cartographicDefault.presets,2*this._intensity):d(this._scatteringFactors.cartographicDefault.presets,this._scatteringFactors.cartographicMax.presets,2*(this._intensity-.5))}_prepareFBO(t,e,i,s=!1){const r=this.renderingContext;r.bindFramebuffer(t.fbo),r.setViewport(0,0,e,i),r.setClearColor(0,0,0,0),r.clear(16384),s&&r.clearBuffer(1,n)}get test(){return{compositionParameters:this._compositionParameters,blurParameters:this._blurParameters,setBlurLodCombination:t=>{this._compositionParameters.dispersionWeight=t},getPresets:this.getPreset(this._mode),setMinDisperse:(t,e)=>{0===this._mode?this._scatteringFactors.realistic.presets[t]=e:(this._scatteringFactors.cartographicMin.presets[t]=e,this._scatteringFactors.cartographicMax.presets[t]=e)},toggleTonemapping:t=>{this._compositionConfiguration.tonemappingEnabled=t,this.requestRender(1)}}}};t([r()],T.prototype,"consumes",void 0),t([r()],T.prototype,"produces",void 0),T=t([o("esri.views.3d.webgl-engine.effects.glow.GlowRenderNode")],T);export{T as GlowRenderNode};
2
+ import{__decorate as t}from"tslib";import{lerp as e}from"../../../../../core/mathUtils.js";import{watch as i,syncAndInitial as s}from"../../../../../core/reactiveUtils.js";import{property as r,subclass as o}from"../../../../../core/accessorSupport/decorators.js";import{length as a}from"../../../../../core/libs/gl-matrix-2/math/vec3.js";import{ZEROS as n}from"../../../../../core/libs/gl-matrix-2/factories/vec4f32.js";import{getReferenceEllipsoid as h}from"../../../../../geometry/ellipsoidUtils.js";import{InternalRenderCategory as c}from"../../../webgl.js";import{TransparentEnvironment as m}from"../TransparentEnvironment.js";import{G as l}from"../../../../../chunks/GlowBlur.glsl.js";import{GlowBlurTechnique as u}from"./GlowBlurTechnique.js";import{GlowBlurTechniqueConfiguration as p}from"./GlowBlurTechniqueConfiguration.js";import{G as g,a as _,m as d}from"../../../../../chunks/GlowComposition.glsl.js";import{GlowCompositionTechnique as f}from"./GlowCompositionTechnique.js";import{GlowCompositionTechniqueConfiguration as b}from"./GlowCompositionTechniqueConfiguration.js";import{ColorAttachment1 as w,DepthStencilAttachment as P}from"../../../../webgl/enums.js";let C=class extends m{constructor(t){super(t),this.consumes={required:[c.TRANSPARENT_ENVIRONMENT,"emissive"]},this.produces=c.TRANSPARENT_ENVIRONMENT,this._blurHorizontalConfiguration=new p,this._blurVerticalConfiguration=new p,this._compositionConfiguration=new b,this._compositionParameters=new g,this._blurParameters=new l,this._blurScalePerLod=3.06,this._logicalBlurRadius=.0037,this._mode=0,this._intensity=.5,this._scatteringFactors={realistic:new _([.8,.12,.05,.02,.01,0]),maximumFog:new _([0,.27,.6,1.05,1.58,2.1],!1),cartographicMin:new _([.4,.18,.25,.12,.05,0],!1),cartographicDefault:new _([1.17,1.08,.78,.4,.26,.11],!1),cartographicMax:new _([3.59,3.9,2.46,1.4,.93,.44],!1)},this._glowResults=new Array;const e=h(t.view.spatialReference);this._atmosphereRadius=e.radius+e.atmosphereHeight,this._compositionParameters.minDisperse=new _([.8,.12,.05,.02,.01,0])}initialize(){this.addHandles([i(()=>this._updateFogParameters(),()=>{},s),i(()=>this._updateParameters(),()=>{},s)])}_updateParameters(){const t=this.view.environment.lighting.glow;this._mode=null==t?this.view.environment.atmosphereEnabled?0:2:1,t&&(this._intensity=t.intensity),this._compositionParameters.minDisperse&&(this._compositionParameters.minDisperse.presets=this.getPreset(this._mode)),this.requestRender(1)}_updateFogParameters(){const t=this.view.environment.weather;"sunny"===t.type||"cloudy"===t.type?this._compositionParameters.distanceModifier=0:this._compositionParameters.distanceModifier="foggy"===t.type?e(3e-5,.005,t.fogStrength**3):e(4e-6,2e-4,(t.precipitation??0)**3),this._compositionParameters.maxDisperse=this._scatteringFactors.maximumFog,this.requestRender(1)}precompile(){this._compositionConfiguration.blurEnabled=2!==this._mode,this._compositionConfiguration.blurEnabled&&(this.techniques.precompile(u,this._blurHorizontalConfiguration),this._blurVerticalConfiguration.glowStage=1,this.techniques.precompile(u,this._blurVerticalConfiguration)),this.techniques.precompile(f,this._compositionConfiguration)}render(t){const e=t.find(({name:t})=>t===c.TRANSPARENT_ENVIRONMENT),i=e.getAttachment(w);if(!i?.attachment)return e;const s=e.getAttachment(P);if(2===this._mode){this._compositionConfiguration.blurEnabled=!1;const t=this.techniques.getCompiled(f,this._compositionConfiguration);if(!t)return this.requestRender(1),e;const r=e.getTexture(),o=this.fboCache,{fullWidth:a,fullHeight:n}=this.bindParameters.camera,h=this.renderingContext,c=o.acquire(r.descriptor.width,r.descriptor.height,this.produces);return this._prepareFBO(c,a,n),this._compositionParameters.color=r,this._compositionParameters.emission=i.attachment,h.bindTechnique(t,this.bindParameters,this._compositionParameters),h.screen.draw(),c.attachDepth(s),c.attachColor(i,w),c}this._compositionConfiguration.blurEnabled=!0;const r=this.techniques.getCompiled(u,this._blurHorizontalConfiguration),o=this.techniques.getCompiled(u,this._blurVerticalConfiguration),n=this.techniques.getCompiled(f,this._compositionConfiguration);if(!r||!o||!n)return this.requestRender(1),e;const h=e.getTexture(),m=this.fboCache,{fullWidth:l,fullHeight:p}=this.bindParameters.camera,g=this.renderingContext;let _=i.attachment,d=Math.ceil(l/2),b=Math.ceil(p/2);const C=5;this._blurParameters.blurRadius=this._logicalBlurRadius;for(let a=0;a<C;a++){const t=m.acquire(d,b,"glow horizontal",8);this._blurParameters.emissionsToDownsample=_,this._prepareFBO(t,d,b),g.bindTechnique(r,this.bindParameters,this._blurParameters),g.screen.draw();const e=m.acquire(d,b,"glow vertical",8);this._blurParameters.emissionsToDownsample=t.getTexture(),this._prepareFBO(e,d,b),g.bindTechnique(o,this.bindParameters,this._blurParameters),g.screen.draw(),t.release(),this._glowResults[a]=e,d=Math.ceil(d/2),b=Math.ceil(b/2),_=this._glowResults[a].getTexture(),this._blurParameters.blurRadius*=this._blurScalePerLod}const T=this.bindParameters.camera,R=a(T.eye);this._compositionParameters.atmosphereC=R**2-this._atmosphereRadius**2,this._compositionParameters.color=h,this._compositionParameters.emission=i.attachment,this._compositionParameters.lodTexture0=this._glowResults[0].getTexture(),this._compositionParameters.lodTexture1=this._glowResults[1].getTexture(),this._compositionParameters.lodTexture2=this._glowResults[2].getTexture(),this._compositionParameters.lodTexture3=this._glowResults[3].getTexture(),this._compositionParameters.lodTexture4=this._glowResults[4].getTexture();const x=m.acquire(h.descriptor.width,h.descriptor.height,this.produces);return x.acquireColor(w,8,"emissive glow"),this._prepareFBO(x,l,p,!0),g.bindTechnique(n,this.bindParameters,this._compositionParameters),g.screen.draw(),this._glowResults.forEach(t=>t.release()),x.attachDepth(s),x}getPreset(t){return 0===t?this._scatteringFactors.realistic.presets:this._intensity<=.5?d(this._scatteringFactors.cartographicMin.presets,this._scatteringFactors.cartographicDefault.presets,2*this._intensity):d(this._scatteringFactors.cartographicDefault.presets,this._scatteringFactors.cartographicMax.presets,2*(this._intensity-.5))}_prepareFBO(t,e,i,s=!1){const r=this.renderingContext;r.bindFramebuffer(t.fbo),r.setViewport(0,0,e,i),r.setClearColor(0,0,0,0),r.clear(16384),s&&r.clearBuffer(1,n)}get test(){return{compositionParameters:this._compositionParameters,blurParameters:this._blurParameters,setBlurLodCombination:t=>{this._compositionParameters.dispersionWeight=t},getPresets:this.getPreset(this._mode),setMinDisperse:(t,e)=>{0===this._mode?this._scatteringFactors.realistic.presets[t]=e:(this._scatteringFactors.cartographicMin.presets[t]=e,this._scatteringFactors.cartographicMax.presets[t]=e)},toggleTonemapping:t=>{this._compositionConfiguration.tonemappingEnabled=t,this.requestRender(1)}}}};t([r()],C.prototype,"consumes",void 0),t([r()],C.prototype,"produces",void 0),C=t([o("esri.views.3d.webgl-engine.effects.glow.GlowRenderNode")],C);export{C as GlowRenderNode};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import{lerp as t,smoothstep as i}from"../../../../../core/mathUtils.js";import{disposeMaybe as r}from"../../../../../core/maybe.js";import{watch as s,syncAndInitial as o}from"../../../../../core/reactiveUtils.js";import{subclass as a}from"../../../../../core/accessorSupport/decorators.js";import{set as n}from"../../../../../core/libs/gl-matrix-2/math/vec2.js";import{length as h}from"../../../../../core/libs/gl-matrix-2/math/vec3.js";import{earth as m}from"../../../../../geometry/support/Ellipsoid.js";import{TransparentEnvironment as c}from"../TransparentEnvironment.js";import{H as u}from"../../../../../chunks/HazeCompositing.glsl.js";import{HazeCompositingTechnique as d}from"./HazeCompositingTechnique.js";import{HazePassParameters as p,HazeTechnique as f}from"./HazeTechnique.js";import{HazeTechniqueConfiguration as l}from"./HazeTechniqueConfiguration.js";import{createQuadVAO as _}from"../../lib/glUtil3D.js";import{applyTextureResizeModulo as g}from"../../lib/textureUtils.js";import{DepthStencilAttachment as b,PrimitiveType as w}from"../../../../webgl/enums.js";let P=class extends c{constructor(e){super(e),this._compositingPassParameters=new u,this._passParameters=new p,this._hazeConfiguration=new l,this._oldAmount=1,this._newAmount=1,this._amount=this._newAmount}initialize(){this.addHandles([s(()=>this.view.environment.atmosphereEnabled,e=>e?this._enable():this._disable(),o),s(()=>this.view.stage?.renderer.renderContext.bind.clouds.fadeFactor??1,e=>this._fade(e),o),s(()=>this.view.environment.weather.type,e=>this._newAmount="rainy"===e?0:1,o),s(()=>this.view.stage.renderer?.highResolutionAtmosphere,e=>this._hazeConfiguration.reduced=!e,o)])}_fade(e){e>=1?(this._amount=this._newAmount,this._oldAmount=this._newAmount):this._amount=e<=0?this._oldAmount:t(this._oldAmount,this._newAmount,e)}destroy(){this._vao=r(this._vao)}precompile(){this.techniques.precompile(f,this._hazeConfiguration),this.techniques.precompile(d)}render(e){const i=e.find(({name:e})=>e===this.produces);if(!this.bindParameters.mainDepth)return i;const r=this.techniques.get(f,this._hazeConfiguration);if(!r.compiled)return i;const s=this.renderingContext,o=i.getAttachment(b);if(this._update(),!this._hazeConfiguration.reduced)return i.detachDepth(),s.bindFramebuffer(i.fbo),s.bindTechnique(r,this.bindParameters,this._passParameters),this._renderCommon(s),i.attachDepth(o),i;const a=this.techniques.get(d);if(!a.compiled)return i;const n=s.getViewport(),c=this.camera,u=h(c.eye)-m.radius;let p;const l=m.atmosphereHeight;if(u<l){const e=Math.min(1,Math.max(0,u/l));p=t(.4,.5,e)}else{const e=Math.min(1,Math.max(0,(u-l)/(15*l)));p=t(.5,1,e)}const _=this.renderingContext.parameters.maxTextureSize,w=g(Math.round(p*c.fullViewport[2]),_),P=g(Math.round(p*c.fullViewport[3]),_);s.setViewport(0,0,w,P);const v=this.fboCache.acquire(w,P,"haze",5);return s.bindFramebuffer(v.fbo),s.clearFramebuffer([0,0,0,1],!0,!0),s.bindTechnique(r,this.bindParameters,this._passParameters),this._renderCommon(s),s.setViewport(n.x,n.y,n.width,n.height),this._compositingPassParameters.color=v.getTexture(),i.detachDepth(),s.bindFramebuffer(i.fbo),s.bindTechnique(a,this.bindParameters,this._compositingPassParameters),s.screen.draw(),i.attachDepth(o),v.release(),i}_renderCommon(e){this._vao??=_(e,1),e.bindVAO(this._vao),e.drawArrays(w.TRIANGLE_STRIP,0,4)}_update(){const e=this.view.basemapTerrain?.getLowerBoundRadius()??0;n(this._passParameters.radii,e,e+m.atmosphereHeight);const r=h(this.bindParameters.camera.eye);this._passParameters.hazeStrength=t(t(.6,1,i(9500,10500,r-m.radius)),1,this._amount)}};P=e([a("esri.views.3d.webgl-engine.effects.haze.Haze")],P);export{P as Haze};
2
+ import{__decorate as e}from"tslib";import{lerp as t,smoothstep as i}from"../../../../../core/mathUtils.js";import{disposeMaybe as r}from"../../../../../core/maybe.js";import{watch as s,syncAndInitial as o}from"../../../../../core/reactiveUtils.js";import{subclass as a}from"../../../../../core/accessorSupport/decorators.js";import{set as n}from"../../../../../core/libs/gl-matrix-2/math/vec2.js";import{length as h}from"../../../../../core/libs/gl-matrix-2/math/vec3.js";import{earth as m}from"../../../../../geometry/support/Ellipsoid.js";import{TransparentEnvironment as u}from"../TransparentEnvironment.js";import{H as c}from"../../../../../chunks/HazeCompositing.glsl.js";import{HazeCompositingTechnique as d}from"./HazeCompositingTechnique.js";import{HazePassParameters as p,HazeTechnique as f}from"./HazeTechnique.js";import{HazeTechniqueConfiguration as l}from"./HazeTechniqueConfiguration.js";import{createQuadVAO as _}from"../../lib/glUtil3D.js";import{applyTextureResizeModulo as g}from"../../lib/textureUtils.js";import{DepthStencilAttachment as b,PrimitiveType as w}from"../../../../webgl/enums.js";let C=class extends u{constructor(e){super(e),this._compositingPassParameters=new c,this._passParameters=new p,this._hazeConfiguration=new l,this._oldAmount=1,this._newAmount=1,this._amount=this._newAmount}initialize(){this.addHandles([s(()=>this.view.environment.atmosphereEnabled,e=>e?this._enable():this._disable(),o),s(()=>this.view.stage?.renderer.renderContext.bind.clouds.fadeFactor??1,e=>this._fade(e),o),s(()=>this.view.environment.weather.type,e=>this._newAmount="rainy"===e?0:1,o),s(()=>this.view.stage.renderer?.highResolutionAtmosphere,e=>this._hazeConfiguration.reduced=!e,o)])}_fade(e){e>=1?(this._amount=this._newAmount,this._oldAmount=this._newAmount):this._amount=e<=0?this._oldAmount:t(this._oldAmount,this._newAmount,e)}destroy(){this._vao=r(this._vao)}precompile(){this.techniques.precompile(f,this._hazeConfiguration),this.techniques.precompile(d)}render(e){const i=e.find(({name:e})=>e===this.produces);if(!this.bindParameters.mainDepth)return i;const r=this.techniques.getCompiled(f,this._hazeConfiguration);if(!r)return i;const s=this.renderingContext,o=i.getAttachment(b);if(this._update(),!this._hazeConfiguration.reduced)return i.detachDepth(),s.bindFramebuffer(i.fbo),s.bindTechnique(r,this.bindParameters,this._passParameters),this._renderCommon(s),i.attachDepth(o),i;const a=this.techniques.getCompiled(d);if(!a)return i;const n=s.getViewport(),u=this.camera,c=h(u.eye)-m.radius;let p;const l=m.atmosphereHeight;if(c<l){const e=Math.min(1,Math.max(0,c/l));p=t(.4,.5,e)}else{const e=Math.min(1,Math.max(0,(c-l)/(15*l)));p=t(.5,1,e)}const _=this.renderingContext.parameters.maxTextureSize,w=g(Math.round(p*u.fullViewport[2]),_),C=g(Math.round(p*u.fullViewport[3]),_);s.setViewport(0,0,w,C);const P=this.fboCache.acquire(w,C,"haze",5);return s.bindFramebuffer(P.fbo),s.clearFramebuffer([0,0,0,1],!0,!0),s.bindTechnique(r,this.bindParameters,this._passParameters),this._renderCommon(s),s.setViewport(n.x,n.y,n.width,n.height),this._compositingPassParameters.color=P.getTexture(),i.detachDepth(),s.bindFramebuffer(i.fbo),s.bindTechnique(a,this.bindParameters,this._compositingPassParameters),s.screen.draw(),i.attachDepth(o),P.release(),i}_renderCommon(e){this._vao??=_(e,1),e.bindVAO(this._vao),e.drawArrays(w.TRIANGLE_STRIP,0,4)}_update(){const e=this.view.basemapTerrain?.getLowerBoundRadius()??0;n(this._passParameters.radii,e,e+m.atmosphereHeight);const r=h(this.bindParameters.camera.eye);this._passParameters.hazeStrength=t(t(.6,1,i(9500,10500,r-m.radius)),1,this._amount)}};C=e([a("esri.views.3d.webgl-engine.effects.haze.Haze")],C);export{C as Haze};