@arcgis/core 5.2.0-next.50 → 5.2.0-next.51

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 (39) hide show
  1. package/assets/esri/core/workers/RemoteClient.js +1 -1
  2. package/assets/esri/core/workers/chunks/{de50a19944617cd426b8.js → 0ffd0190adfed8e5937a.js} +1 -1
  3. package/assets/esri/core/workers/chunks/{877c848beaf9a939862c.js → 290fbc6d32c799841ccc.js} +1 -1
  4. package/assets/esri/core/workers/chunks/{851bcc75acac4a2f199b.js → 2d6d2d4df05bba9fa4a6.js} +1 -1
  5. package/assets/esri/core/workers/chunks/{304a22c580ce103480cb.js → 2fbb00a29faeaa02912b.js} +1 -1
  6. package/assets/esri/core/workers/chunks/{9d0a9d465ec3a8ba1ed2.js → 5d6d07ecebf881ad913f.js} +1 -1
  7. package/assets/esri/core/workers/chunks/{0037a878499d8a512772.js → 61d3fcb419d6bf7e355e.js} +38 -19
  8. package/assets/esri/core/workers/chunks/{cdb331b58e22f8c1c988.js → 77f19d204a4673b1e676.js} +2 -2
  9. package/assets/esri/core/workers/chunks/{1bc45872d22d61dbd7d1.js → 7e2bf6dd26c3cf0b49b0.js} +1 -1
  10. package/assets/esri/core/workers/chunks/{baac90da0703891d59c4.js → 847ce06b14a921cd16f0.js} +1 -1
  11. package/assets/esri/core/workers/chunks/a1fcef22b6151a7f7917.js +1 -0
  12. package/assets/esri/core/workers/chunks/{0ea374f7b16745b9bbc7.js → a239f1e82dde4f7ada32.js} +1 -1
  13. package/assets/esri/core/workers/chunks/{47af3525396f890f2a6b.js → c38992b250731137cb1a.js} +1 -1
  14. package/assets/esri/core/workers/chunks/{5ec8b02e097cf6718462.js → ce719d3aec8b52bfe160.js} +1 -1
  15. package/assets/esri/core/workers/chunks/{b0b37c67a14a4dfb6538.js → cef7f4237539574f0730.js} +1 -1
  16. package/chunks/CutFillMinMaxDepth.glsl.js +1 -1
  17. package/chunks/CutFillReduction.glsl.js +5 -14
  18. package/chunks/CutFillTotalDepth.glsl.js +1 -1
  19. package/chunks/GlobalIllumination.glsl.js +41 -30
  20. package/chunks/GlobalIlluminationBlur.glsl.js +19 -11
  21. package/chunks/GlobalIlluminationUpscale.glsl.js +10 -10
  22. package/config.js +1 -1
  23. package/core/types.d.ts +5 -1
  24. package/kernel.js +1 -1
  25. package/package.json +3 -3
  26. package/support/revision.js +1 -1
  27. package/views/3d/analysis/LineOfSight/LineOfSightTool2.js +1 -1
  28. package/views/3d/analysis/VolumeMeasurement/VolumeMeasurementCutFillController.js +1 -1
  29. package/views/3d/support/hitTest.js +1 -1
  30. package/views/3d/webgl-engine/core/FBOCacheFormats.js +1 -1
  31. package/views/3d/webgl-engine/effects/globalIllumination/GlobalIllumination.js +1 -1
  32. package/views/3d/webgl-engine/lib/CutFillComputation.js +1 -1
  33. package/views/3d/webgl-engine/lib/Renderer.js +1 -1
  34. package/views/3d/webgl-engine/shaders/CutFillReductionTechniqueConfiguration.js +1 -1
  35. package/views/SceneView.d.ts +24 -12
  36. package/widgets/LineOfSight/LineOfSightViewModel.js +1 -1
  37. package/widgets/support/AnalysisViewModelMixin.js +1 -1
  38. package/assets/esri/core/workers/chunks/5ce168ae45ab7e7a71d1.js +0 -1
  39. /package/assets/esri/core/workers/chunks/{cdb331b58e22f8c1c988.js.LICENSE.txt → 77f19d204a4673b1e676.js.LICENSE.txt} +0 -0
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import{nextPowerOfTwo as t}from"../../../../core/mathUtils.js";import{disposeMaybe as i,destroyMaybe as r}from"../../../../core/maybe.js";import{property as s,subclass as h}from"../../../../core/accessorSupport/decorators.js";import{ortho as o}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{set as n}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{create as a}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{create as u}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{UNIT_X as d,ZEROS as c}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{InternalRenderCategory as l}from"../../webgl.js";import{Frustum as m}from"../../state/Frustum.js";import{glLayout as p}from"../../support/buffer/glUtil.js";import{newLayout as _}from"../../support/buffer/InterleavedLayout.js";import f from"../../webgl/RenderCamera.js";import g from"../../webgl/RenderNode.js";import{VertexArrayObject as C}from"./VertexArrayObject.js";import{CutFillMinMaxDepthTechnique as w}from"../shaders/CutFillMinMaxDepthTechnique.js";import{C as x}from"../../../../chunks/CutFillReduction.glsl.js";import{CutFillReductionTechnique as T}from"../shaders/CutFillReductionTechnique.js";import{CutFillReductionTechniqueConfiguration as P}from"../shaders/CutFillReductionTechniqueConfiguration.js";import{C as R}from"../../../../chunks/CutFillTargetDepth.glsl.js";import{CutFillTargetDepthTechnique as b}from"../shaders/CutFillTargetDepthTechnique.js";import{C as y}from"../../../../chunks/CutFillTotalDepth.glsl.js";import{CutFillTotalDepthTechnique as F}from"../shaders/CutFillTotalDepthTechnique.js";import{ImmediateTask as B,TaskPriority as j}from"../../../support/Scheduler.js";import{Yield as E}from"../../../support/Yield.js";import{PrimitiveType as O,DataType as S}from"../../../webgl/enums.js";import{Sync as q}from"../../../webgl/Sync.js";import{VertexBuffer as D}from"../../../webgl/VertexBuffer.js";let v=class extends g{constructor(e){super(e),this.consumes={required:[l.CUTFILL_COMPUTATION,l.TRANSPARENT_NO_DEPTH]},this.produces=l.CUTFILL_COMPUTATION,this.needsRender=!1,this.readyToRun=!1,this.done=!0,this._frameTask=B,this._result=new L,this._localOrigin=u(),this._maxTextureSize=512,this._width=0,this._height=0,this._reducedWidth=0,this._reducedHeight=0,this._depthFormat=14,this._colorFormat=11,this._numChannels=2,this._reductionConfiguration=new P,this._targetDepthParameters=new R,this._depthParameters=new y,this._reductionParameters=new x,this._numReductions=3,this._reductionPasses=0,this._pixelBufferSize=0,this._pixelBufferOffset=0,this._perReductionPixelBufferSize=0}initialize(){this._frameTask=this.view.resourceController.scheduler.registerTask(j.VOLUME_MEASUREMENT,this),this.addHandles(this._frameTask),this._maxTextureSize=Math.min(this._maxTextureSize,this.fboCache.rctx.parameters.maxTextureSize),this._frustum=new m(this.view.renderCoordsHelper)}destroy(){this._targetGeometryVao=i(this._targetGeometryVao),this._sync=r(this._sync),this._pixelBuffer&&(this.gl.deleteBuffer(this._pixelBuffer),this._pixelBuffer=null,this._pixelBufferSize=0)}precompile(){this.view.stage.renderer.precompileCutFillOrthographicReferenceDepth()}render(){const e=this.input;if(!this._orthographicCamera||!this._targetGeometryVao||!this.needsRender||this._sync)return e;const t=this.techniques.getCompiled(b),i=this.techniques.getCompiled(F),r=this.techniques.getCompiled(w);this._reductionConfiguration.reductionPass=0;const s=this.techniques.getCompiled(T,this._reductionConfiguration);this._reductionConfiguration.reductionPass=1;const h=this.techniques.getCompiled(T,this._reductionConfiguration);this._reductionConfiguration.reductionPass=2;const o=this.techniques.getCompiled(T,this._reductionConfiguration);if(!(t&&i&&r&&s&&h&&o))return this.requestRender(1),e;this.needsRender=!1;const n=this.renderingContext,a=this.fboCache,u=this.gl,c=n.getViewport(),l=a.acquire(this._width,this._height,"cutfill reference depth",this._depthFormat);n.bindFramebuffer(l.fbo),n.setViewport(0,0,this._width,this._height),n.clear(1280),this.view.stage.renderer.renderCutFillOrthographicReferenceDepth(this._orthographicCamera);const m=a.acquire(this._width,this._height,"cutfill target depth",this._depthFormat);n.bindFramebuffer(m.fbo),n.setViewport(0,0,this._width,this._height),n.setClearDepth(1),n.clear(256),this._targetDepthParameters.origin=this._localOrigin,this._targetDepthParameters.cutFillCamera=this._orthographicCamera,n.bindTechnique(t,this.bindParameters,this._targetDepthParameters),n.bindVAO(this._targetGeometryVao),n.drawArrays(O.TRIANGLES,0,this._targetGeometryVao.vertexCount("geometry"));const p=a.acquire(this._width,this._height,"cutfill reduction even",this._colorFormat),_=a.acquire(Math.ceil(this._width/2),Math.ceil(this._height/2),"cutfill reduction odd",this._colorFormat);return this._depthParameters.referenceDepth=l.depthTexture,this._depthParameters.targetDepth=m.depthTexture,this._pixelBuffer||(this._pixelBuffer=u.createBuffer()),u.bindBuffer(u.PIXEL_PACK_BUFFER,this._pixelBuffer),u.bufferData(u.PIXEL_PACK_BUFFER,this._pixelBufferSize,u.STREAM_READ),this._prepareFBO(p,this.width,this.height),n.bindTechnique(i,this.bindParameters,this._depthParameters),n.screen.draw(),this._runPyramidReduction(p,_,s),this._prepareFBO(p,this.width,this.height,d),n.bindTechnique(r,this.bindParameters,this._depthParameters),n.screen.draw(),this._runPyramidReduction(p,_,h),this._prepareFBO(p,this.width,this.height),n.bindTechnique(r,this.bindParameters,this._depthParameters),n.screen.draw(),this._runPyramidReduction(p,_,o),l.release(),m.release(),p.release(),_.release(),u.bindBuffer(u.PIXEL_PACK_BUFFER,null),n.setViewport(c.x,c.y,c.width,c.height),this._sync=new q(u),setTimeout(()=>this.readyToRun=!0,0),e}update(e,i){if(!this.done)return;this.done=!1;const r=this.renderingContext,{cameraDimensions:{width:s,height:h},localOriginRenderSpace:o}=e,n=this._maxTextureSize,a=h/s,u=s>h?n:n/a,d=s>h?n*a:n;this._width=t(u),this._height=t(d);const c=[this._width,this._height];this._orthographicCamera=this._createCamera(e,c),this._frustum?.update(this._orthographicCamera),this._updateTargetVao(r,i),this._localOrigin=o,this._reductionPasses=Math.ceil(Math.log2(Math.min(this._width,this._height))),this._reducedWidth=Math.ceil(this._width/2**this._reductionPasses),this._reducedHeight=Math.ceil(this._height/2**this._reductionPasses),this._perReductionPixelBufferSize=this._reducedWidth*this._reducedHeight*this._numChannels*4,this._pixelBufferSize=this._perReductionPixelBufferSize*this._numReductions,this._pixelBufferOffset=0,this.needsRender=!0,this.requestRender(1)}runTask(){if(!this._sync)return void(this.readyToRun=!1);try{if(!this._sync.poll())return E}catch(t){return this.readyToRun=!1,void(this._sync=r(this._sync))}this.readyToRun=!1,this._sync=r(this._sync);const e=this.gl;this._cpuBuffer=new Float32Array(this._pixelBufferSize/4),e.bindBuffer(e.PIXEL_PACK_BUFFER,this._pixelBuffer),e.getBufferSubData(e.PIXEL_PACK_BUFFER,0,this._cpuBuffer),e.bindBuffer(e.PIXEL_PACK_BUFFER,null),this._updateResults(this._cpuBuffer),this.done=!0}getResult(){return this._result}get frustum(){return this._frustum}get width(){return this._width}get height(){return this._height}get updating(){return this.readyToRun||!this.done||this._frameTask.updating}_runPyramidReduction(e,t,i){const r=this.renderingContext,s=this.gl;let h=this._width,o=this._height;for(let n=0;n<this._reductionPasses;n++)h=Math.ceil(h/2),o=Math.ceil(o/2),this._reductionParameters.depthTexture=e.getTexture(),this._prepareFBO(t,h,o),r.bindTechnique(i,this.bindParameters,this._reductionParameters),r.screen.draw(),[e,t]=[t,e];s.readPixels(0,0,h,o,33319,S.FLOAT,this._pixelBufferOffset),this._pixelBufferOffset+=this._perReductionPixelBufferSize}_updateResults(e){const t=new z(0,1,a()),i=new z(0,0,a());for(let r=0;r<this._reducedWidth;r++)for(let s=0;s<this._reducedHeight;s++){let h=(r+s*this._reducedWidth)*this._numChannels;const o=this._reducedWidth*this._reducedHeight*this._numChannels;t.totalDepth+=e[h],i.totalDepth+=e[h+1],h+=o;const n=e[h];n<t.depthExtremum&&(t.depthExtremum=n,V(t.depthExtremumCoords,e[h+1],this._width)),h+=o;const a=e[h];a>i.depthExtremum&&(i.depthExtremum=a,V(i.depthExtremumCoords,e[h+1],this._width))}this._result=new L(this._width,this._height,t,i)}_prepareFBO(e,t,i,r=c){const s=this.renderingContext;s.bindFramebuffer(e.fbo),s.setViewport(0,0,t,i),s.setClearColor(r[0],r[1],r[2],r[3]),s.clear(16384)}_createCamera(e,t){const{cameraPositionRenderSpace:i,localOriginRenderSpace:r,northVector:s,cameraDimensions:{width:h,height:n},cameraNearFar:{near:a,far:u}}=e,d=new f({eye:i,center:r,up:s,near:a,far:u});return d.viewport=[0,0,t[0],t[1]],o(d.projectionMatrix,-h/2,h/2,-n/2,n/2,a,u),d}_updateTargetVao(e,t){this._targetGeometryVao=i(this._targetGeometryVao);const r=t.indices.length,s=M.createBuffer(r),h=s.position,{positions:o,indices:n}=t;for(let i=0;i<n.length;++i){const e=3*n[i];h.set(i,0,o[e]),h.set(i,1,o[e+1]),h.set(i,2,o[e+2])}const a=new D(e,p(M),s.buffer);this._targetGeometryVao=new C(e,a)}};e([s()],v.prototype,"consumes",void 0),e([s()],v.prototype,"produces",void 0),e([s()],v.prototype,"needsRender",void 0),e([s()],v.prototype,"readyToRun",void 0),e([s()],v.prototype,"done",void 0),e([s()],v.prototype,"updating",null),e([s()],v.prototype,"_frameTask",void 0),v=e([h("esri.views.3d.webgl-engine.lib.CutFillComputation")],v);const M=_().vec3f("position").freeze();function V(e,t,i){const r=t%i,s=Math.floor(t/i);n(e,r,s)}class A{constructor(e,t){this.positions=e,this.indices=t}}class z{constructor(e,t,i){this.totalDepth=e,this.depthExtremum=t,this.depthExtremumCoords=i}}class L{constructor(e=0,t=0,i=new z(0,1,a()),r=new z(0,0,a())){this.width=e,this.height=t,this.cut=i,this.fill=r}}export{v as CutFillComputation,L as CutFillComputationResult,z as CutFillDepthResult,A as TargetGeometryRenderInfo};
2
+ import{__decorate as e}from"tslib";import{nextPowerOfTwo as t}from"../../../../core/mathUtils.js";import{disposeMaybe as i,destroyMaybe as r,releaseMaybe as s}from"../../../../core/maybe.js";import{property as h,subclass as o}from"../../../../core/accessorSupport/decorators.js";import{ortho as n}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{set as a}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{create as u}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{create as d}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{UNIT_X as c,ZEROS as l}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{InternalRenderCategory as f}from"../../webgl.js";import{Frustum as p}from"../../state/Frustum.js";import{glLayout as m}from"../../support/buffer/glUtil.js";import{newLayout as _}from"../../support/buffer/InterleavedLayout.js";import g from"../../webgl/RenderCamera.js";import C from"../../webgl/RenderNode.js";import{VertexArrayObject as x}from"./VertexArrayObject.js";import{CutFillMinMaxDepthTechnique as w}from"../shaders/CutFillMinMaxDepthTechnique.js";import{C as T}from"../../../../chunks/CutFillReduction.glsl.js";import{CutFillReductionTechnique as b}from"../shaders/CutFillReductionTechnique.js";import{CutFillReductionTechniqueConfiguration as y}from"../shaders/CutFillReductionTechniqueConfiguration.js";import{C as R}from"../../../../chunks/CutFillTargetDepth.glsl.js";import{CutFillTargetDepthTechnique as B}from"../shaders/CutFillTargetDepthTechnique.js";import{C as F}from"../../../../chunks/CutFillTotalDepth.glsl.js";import{CutFillTotalDepthTechnique as P}from"../shaders/CutFillTotalDepthTechnique.js";import{ImmediateTask as j,TaskPriority as E}from"../../../support/Scheduler.js";import{Yield as D}from"../../../support/Yield.js";import{PrimitiveType as S,DataType as v}from"../../../webgl/enums.js";import{Sync as O}from"../../../webgl/Sync.js";import{VertexBuffer as M}from"../../../webgl/VertexBuffer.js";let V=class extends C{constructor(e){super(e),this.consumes={required:[f.CUTFILL_COMPUTATION,f.TRANSPARENT_NO_DEPTH]},this.produces=f.CUTFILL_COMPUTATION,this.needsRender=!1,this.readyToRun=!1,this.done=!0,this._frameTask=j,this._localOrigin=d(),this._maxTextureSize=512,this._width=0,this._height=0,this._reducedWidth=0,this._reducedHeight=0,this._depthFormat=14,this._colorFormat=11,this._numChannels=4,this._reductionConfiguration=new y,this._targetDepthPass=new R,this._depthPass=new F,this._reductionPass=new T,this._numReductions=2,this._reductionPasses=0,this._pixelBufferSize=0,this._pixelBufferOffset=0,this._perReductionPixelBufferSize=0}initialize(){this._frameTask=this.view.resourceController.scheduler.registerTask(E.VOLUME_MEASUREMENT,this),this.addHandles(this._frameTask),this._maxTextureSize=Math.min(this._maxTextureSize,this.fboCache.rctx.parameters.maxTextureSize),this._frustum=new p(this.view.renderCoordsHelper)}destroy(){this._targetGeometryVao=i(this._targetGeometryVao),this._sync=r(this._sync),this._pixelBuffer&&(this.gl.deleteBuffer(this._pixelBuffer),this._pixelBuffer=null,this._pixelBufferSize=0)}precompile(){this.view.stage.renderer.precompileCutFillDepth()}render(){const e=this.input;if(!this._orthographicCamera||!this._targetGeometryVao||!this.needsRender||this._sync)return e;const t=this.techniques,i=t.getCompiled(B),r=t.getCompiled(P),h=t.getCompiled(w);this._reductionConfiguration.pass=0;const o=t.getCompiled(b,this._reductionConfiguration);this._reductionConfiguration.pass=1;const n=t.getCompiled(b,this._reductionConfiguration);if(!(i&&r&&h&&o&&n))return this.requestRender(1),e;this.needsRender=!1;const a=this.renderingContext,u=this.fboCache,{_width:d,_height:l,_depthPass:f,_depthFormat:p,_colorFormat:m,_orthographicCamera:_,_targetDepthPass:g}=this,C=this.gl,x=a.getViewport();f.referenceDepth=u.acquire(d,l,"cutfill reference depth",p),a.bindFramebuffer(f.referenceDepth.fbo),a.setViewport(0,0,d,l),a.clear(1280),this.view.stage.renderer.renderCutFillDepth(_),f.targetDepth=u.acquire(d,l,"cutfill target depth",p),a.bindFramebuffer(f.targetDepth.fbo),a.setViewport(0,0,d,l),a.setClearDepth(1),a.clear(256),g.origin=this._localOrigin,g.cutFillCamera=_,a.bindTechnique(i,this.bindParameters,g),a.bindVAO(this._targetGeometryVao),a.drawArrays(S.TRIANGLES,0,this._targetGeometryVao.vertexCount("geometry"));const T=u.acquire(d,l,"cutfill reduction even",m),y=u.acquire(Math.ceil(d/2),Math.ceil(l/2),"cutfill reduction odd",m);return this._pixelBuffer||(this._pixelBuffer=C.createBuffer()),C.bindBuffer(C.PIXEL_PACK_BUFFER,this._pixelBuffer),C.bufferData(C.PIXEL_PACK_BUFFER,this._pixelBufferSize,C.STREAM_READ),this._prepareFBO(T,this.width,this.height),a.bindTechnique(r,this.bindParameters,f),a.screen.draw(),this._runPyramidReduction(T,y,o),this._prepareFBO(T,this.width,this.height,c),a.bindTechnique(h,this.bindParameters,f),a.screen.draw(),this._runPyramidReduction(T,y,n),f.referenceDepth=s(f.referenceDepth),f.targetDepth=s(f.targetDepth),T.release(),y.release(),C.bindBuffer(C.PIXEL_PACK_BUFFER,null),a.setViewport(x.x,x.y,x.width,x.height),this._sync=new O(C),setTimeout(()=>this.readyToRun=!0,0),e}update(e,i){if(!this.done)return;this.done=!1;const r=this.renderingContext,{cameraDimensions:{width:s,height:h},localOriginRenderSpace:o}=e,n=this._maxTextureSize,a=h/s,u=s>h?n:n/a,d=s>h?n*a:n;this._width=t(u),this._height=t(d);const c=[this._width,this._height];this._orthographicCamera=this._createCamera(e,c),this._frustum?.update(this._orthographicCamera),this._updateTargetVao(r,i),this._localOrigin=o,this._reductionPasses=Math.ceil(Math.log2(Math.min(this._width,this._height))),this._reducedWidth=Math.ceil(this._width/2**this._reductionPasses),this._reducedHeight=Math.ceil(this._height/2**this._reductionPasses),this._perReductionPixelBufferSize=this._reducedWidth*this._reducedHeight*this._numChannels*4,this._pixelBufferSize=this._perReductionPixelBufferSize*this._numReductions,this._pixelBufferOffset=0,this.needsRender=!0,this.requestRender(1)}runTask(){if(!this._sync)return void(this.readyToRun=!1);try{if(!this._sync.poll())return D}catch(t){return this.readyToRun=!1,void(this._sync=r(this._sync))}this.readyToRun=!1,this._sync=r(this._sync);const e=this.gl;this._cpuBuffer=new Float32Array(this._pixelBufferSize/4),e.bindBuffer(e.PIXEL_PACK_BUFFER,this._pixelBuffer),e.getBufferSubData(e.PIXEL_PACK_BUFFER,0,this._cpuBuffer),e.bindBuffer(e.PIXEL_PACK_BUFFER,null),this._updateResults(this._cpuBuffer),this.done=!0}get result(){return this._result}get frustum(){return this._frustum}get width(){return this._width}get height(){return this._height}get updating(){return this.readyToRun||!this.done||this._frameTask.updating}_runPyramidReduction(e,t,i){const r=this.renderingContext,s=this.gl;let h=this._width,o=this._height;for(let n=0;n<this._reductionPasses;n++)h=Math.ceil(h/2),o=Math.ceil(o/2),this._reductionPass.depthTexture=e.getTexture(),this._prepareFBO(t,h,o),r.bindTechnique(i,this.bindParameters,this._reductionPass),r.screen.draw(),[e,t]=[t,e];s.readPixels(0,0,h,o,6408,v.FLOAT,this._pixelBufferOffset),this._pixelBufferOffset+=this._perReductionPixelBufferSize}_updateResults(e){const t=new L(0,1),i=new L(0,0);for(let r=0;r<this._reducedWidth;r++)for(let s=0;s<this._reducedHeight;s++){let h=(r+s*this._reducedWidth)*this._numChannels;const o=this._reducedWidth*this._reducedHeight*this._numChannels;t.totalDepth+=e[h],i.totalDepth+=e[h+1],h+=o;const n=e[h];n<t.depthExtremum&&(t.depthExtremum=n,q(t.depthExtremumCoords,e[h+1],this._width));const a=e[h+2];a>i.depthExtremum&&(i.depthExtremum=a,q(i.depthExtremumCoords,e[h+3],this._width))}this._result=new U(this._width,this._height,t,i)}_prepareFBO(e,t,i,r=l){const s=this.renderingContext;s.bindFramebuffer(e.fbo),s.setViewport(0,0,t,i),s.setClearColor(r[0],r[1],r[2],r[3]),s.clear(16384)}_createCamera(e,t){const{cameraPositionRenderSpace:i,localOriginRenderSpace:r,northVector:s,cameraDimensions:{width:h,height:o},cameraNearFar:{near:a,far:u}}=e,d=new g({eye:i,center:r,up:s,near:a,far:u});return d.viewport=[0,0,t[0],t[1]],n(d.projectionMatrix,-h/2,h/2,-o/2,o/2,a,u),d}_updateTargetVao(e,t){this._targetGeometryVao=i(this._targetGeometryVao);const{positions:r,indices:s}=t,h=s.length,o=A.createBuffer(h),n=o.position;for(let i=0;i<s.length;++i){const e=3*s[i];n.set(i,0,r[e]),n.set(i,1,r[e+1]),n.set(i,2,r[e+2])}const a=new M(e,m(A),o.buffer);this._targetGeometryVao=new x(e,a)}};e([h()],V.prototype,"consumes",void 0),e([h()],V.prototype,"produces",void 0),e([h()],V.prototype,"needsRender",void 0),e([h()],V.prototype,"readyToRun",void 0),e([h()],V.prototype,"done",void 0),e([h()],V.prototype,"_frameTask",void 0),V=e([o("esri.views.3d.webgl-engine.lib.CutFillComputation")],V);const A=_().vec3f("position").freeze();function q(e,t,i){const r=t%i,s=Math.floor(t/i);a(e,r,s)}class z{constructor(e,t){this.positions=e,this.indices=t}}class L{constructor(e,t){this.totalDepth=e,this.depthExtremum=t,this.depthExtremumCoords=u()}}class U{constructor(e=0,t=0,i,r){this.width=e,this.height=t,this.cut=i,this.fill=r}}export{V as CutFillComputation,U as CutFillComputationResult,L as CutFillDepthResult,z as TargetGeometryRenderInfo};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import{update as t}from"../../../../core/arrayUtils.js";import{createTask as s}from"../../../../core/asyncUtils.js";import has from"../../../../core/has.js";import{removeMaybe as i,abortMaybe as r,destroyMaybe as a,releaseMaybe as n,releaseReferencedMaybe as h}from"../../../../core/maybe.js";import{throwIfAborted as o}from"../../../../core/promiseUtils.js";import{watch as d,syncAndInitial as l,initial as m,sync as u}from"../../../../core/reactiveUtils.js";import{signal as _}from"../../../../core/signal.js";import{property as p,subclass as c}from"../../../../core/accessorSupport/decorators.js";import{equals as b,invert as f,multiply as g,copy as P}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{IDENTITY as w,create as E}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{set as I}from"../../../../core/libs/gl-matrix-2/math/vec4.js";import{fromValues as A,ZEROS as C}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{pruneIndexArrays as T}from"../../../../geometry/support/Indices.js";import{RenderNodeOutput as R,InternalRenderCategory as O,AllRenderNodeOutputs as S,AllInternalRenderNodeOutputs as D}from"../../webgl.js";import{minNearDistanceInMeters as N}from"../../state/NearFarHeuristic.js";import{debugFlags as F}from"../../support/debugFlags.js";import{computeShadowsEnabled as G}from"../../support/sunUtils.js";import{FBOCache as H}from"../core/FBOCache.js";import{RenderPassManager as x}from"../core/renderPasses/RenderPassManager.js";import{isColor as y}from"../core/shaderLibrary/ShaderOutput.js";import{distanceFadeEnd as v}from"../core/shaderLibrary/shading/ScreenSpaceConstants.js";import{RenderNodes as M}from"../effects/RenderNodes.js";import{RenderPluginManager as L}from"../effects/RenderPluginManager.js";import{WeatherFader as q}from"../effects/WeatherFader.js";import{innerAtmosphereFadeStart as j}from"../effects/atmosphere/atmosphereUtils.js";import{Blit as U}from"../effects/blit/Blit.js";import{maxHighlightsPerChannel as B,renderHighlightBuffer as V}from"../effects/highlight/Highlight.js";import{OITBlend as k}from"../effects/transparency/OITBlend.js";import{AnimationTimer as W}from"./AnimationTimer.js";import{AnimationTimeStep as Q}from"./AnimationTimeStep.js";import{BoundingInfo as z}from"./BoundingInfo.js";import{Compositor as Y}from"./Compositor.js";import{DepthRange as J}from"./DepthRange.js";import{depthRangeFromScene as X}from"./depthRangeUtils.js";import{MainFramebuffer as $}from"./MainFramebuffer.js";import{NavigationDepthCache as K}from"./NavigationDepthCache.js";import{blendingColorAlphaClear as Z}from"./OrderIndependentTransparency.js";import{RenderContext as ee,defaultRenderOccludedMask as te}from"./RenderContext.js";import{RendererBase as se}from"./RendererBase.js";import{setupFeatureDefaults as ie}from"./RenderFeature.js";import{RenderPluginInput as re}from"./RenderPluginInput.js";import{ShadowAccumulator as ae}from"./ShadowAccumulator.js";import{ShadowMap as ne}from"./ShadowMap.js";import he from"./SliceHelper.js";import{MergedRenderer as oe}from"../materials/renderers/MergedRenderer.js";import{RenderSceneResult as de}from"../parts/renderUtils.js";import{RendererPerformanceInfo as le,PerformanceCategory as me}from"../statistics/RendererPerformanceInfo.js";import{ColorAttachment1 as ue,PixelType as _e,ColorAttachment2 as pe,ColorAttachment0 as ce,DrawBufferNone as be}from"../../../webgl/enums.js";const fe=has("disable-feature:async-navigation-3d-depth-readback");let ge=class extends se{constructor(e,t,s,i,r){super({stage:e}),this._techniques=s,this._rctx=i,this._requestRender=r,this._pluginsHas={occludedHudElements:!1,hudElements:!1,water:!1},this.renderPassManager=new x,this._isRendering=!1,this._inGlobeView=!1,this._backgroundColor=A(0,0,0,1),this._sliceHelper=new he,this.sceneDepthRange=_(J.Infinite),this._state=_(2),this._hasGlobalIlluminationFlag=!!has("enable-feature:global-illumination"),this._hasAnimations=!1,this._animationTimestep=new Q,this._loadEdgeViewTask=null,this._edgeViewCallbacks=[],this._reprojectionMatrixVersion=_(0),this._renderHiddenTransparentEdges=()=>{},this._pluginInput=new re,this._hasTransparentGeometry=!1,this._releaseNodeInputs=e=>{for(const t of Ne)e.some(({name:e})=>e===t)&&this._pluginInput.release(t)},this._testsNeedsDepth=!1,this._fboCache=new H(i),this._compositor=new Y(i,s),this._renderStateFeatures=_(ie(e.view.qualityProfile));const a=new ne(this._fboCache,e.viewingMode);this._renderContext=new ee(this._rctx,a,s),this._framebuffer=new $(this._fboCache,this._bindParameters),this._performanceInfo=new le(this._rctx),this._blit=new U(s),this.navigationDepthCache=new K(this._rctx,this._fboCache,s,()=>this._requestRender(0)),this._shadowAccumulator=new ae(this.fboCache,s,e,(t,s,i)=>{const r=e.view.qualitySettings.maximumPixelRatio;t.shadowMap.start(t.camera,s,i,!0,r),this._renderShadowCascades(5,t.shadowMap),t.camera.setGLViewport(this._rctx),this._ensureBindParametersCamera(t.camera,t.contentCamera)},r),this._nodes=new M(this._renderContext),this._plugins=new L({renderContext:this._renderContext,techniques:s,materials:t,requestRender:r,controller:e}),this._plugins.add(this.renderPassManager),this.weatherFader=new q({view:e.view,context:this._renderContext}),this.addHandles([d(()=>e.view.state.camera,()=>r(),l),d(()=>F.EDGES_SHOW_HIDDEN_TRANSPARENT_EDGES,e=>{this._renderHiddenTransparentEdges=e?()=>this._renderEdges(0):()=>{},r()},m),d(()=>e.view.environment.background?.color,e=>{const t=e?e.toUnitRGBA():C;I(this._backgroundColor,t[0]*t[3],t[1]*t[3],t[2]*t[3],t[3]),r()},l),d(()=>e.view.state.camera.relativeElevation,e=>this._inGlobeView=(e??1/0)>=v,l),d(()=>this._bindParameters.clouds.fadeFactor,()=>{this._bindParameters.fadeLighting(),this._requestRender(2)},u),d(()=>this._bindParameters.clouds.data?.state,()=>r(),u),d(()=>e.view.state.highlights,e=>{this._bindParameters.highlights=e,r()},m),d(()=>"sun"===e.view.environment.lighting?.type,e=>{this._bindParameters.enableFillLights=e,this._requestRender()},l)])}destroy(){this._gpuTimerHandle=i(this._gpuTimerHandle),this._nodes.destroy(),this._framebuffer.dispose(),this._shadowAccumulator.destroy(),this._shadowAccumulator=null,this._loadEdgeViewTask=r(this._loadEdgeViewTask),this._edgeView=a(this._edgeView),this.renderPassManager.dispose(),this.weatherFader=a(this.weatherFader),this._releaseFBOs(),this._disposeOffscreenBuffers(),this.navigationDepthCache.destroy(),this._fboCache.destroy(),this._fboCache=null,this._renderContext.destroy(),this._plugins.destroy(),this._pluginInput=null,this._oitBlendOrNil=null,this._nodes=null,this._framebuffer=null,this._performanceInfo=null,z.prune(),oe.prune(),T()}get renderContext(){return this._renderContext}get _bindParameters(){return this._renderContext.bind}get _oitBlend(){return this._oitBlendOrNil??=new k(this._techniques),this._oitBlendOrNil}get performanceInfo(){return this._performanceInfo}updateRenderFeatures(e){this._renderStateFeatures.value=ie(e),this._requestRender()}isFeatureEnabled(e,t=this._state.value){return this._renderStateFeatures.value.get(t,e)??!1}setFeatureEnabled(e,t,s){this._renderStateFeatures.mutate(i=>i.set(t,e,s)),this._requestRender()}setTime(e){this._renderContext.time=e}get hasReflections(){return this._bindParameters.screenSpaceReflections.enabled=this._pluginsHas.water&&this.isFeatureEnabled(4),this._bindParameters.screenSpaceReflections.enabled}get _hasHighlights(){return this._plugins.produces(10,2,4,18,12,13,14)}hasHighlight(e){return this._plugins.hasHighlight(e)}get _hasHUDHighlights(){return this._plugins.produces(10,12,13,14)}get hasAmbientIllumination(){return this.isFeatureEnabled(3)&&!this._inGlobeView}get hasGlobalIllumination(){return this._hasGlobalIlluminationFlag&&this.hasAmbientIllumination}get hasGlobalIlluminationHighQuality(){return this.hasGlobalIllumination&&this.isFeatureEnabled(10)}get _keepGlobalIlluminationShadingAlive(){return this._hasGlobalIlluminationFlag&&!this._inGlobeView}get hasSMAA(){return this.isFeatureEnabled(0)}get _emissions(){const e=this._plugins.emissions;return this._hasTransparentGeometry?e:1===e||3===e?1:0}get hasFloatBlend(){return this._rctx.driverTest.floatBufferBlend.result&&this.isFeatureEnabled(9)}get highResolutionAtmosphere(){return this.isFeatureEnabled(2)}get fboCache(){return this._fboCache}_releaseFBOs(){this._bindParameters.hudOcclusion=n(this._bindParameters.hudOcclusion),this._bindParameters.depth=null}_disposeOffscreenBuffers(){this._framebuffer.dispose(),this._bindParameters.globalIllumination=n(this._bindParameters.globalIllumination),this._bindParameters.reprojection.lastFrameDepth=n(this._bindParameters.reprojection.lastFrameDepth),this._bindParameters.reprojection.lastFrameEmission=n(this._bindParameters.reprojection.lastFrameEmission),this._disposeBindBuffers()}_disposeBindBuffers(){this._bindParameters.shadowMap.disposeOutputs()}get updating(){return this._loadEdgeViewTask&&!this._loadEdgeViewTask.finished||this._edgeView?.updating||this._plugins.updating||this.weatherFader?.readyToRun||!this.isCameraFinal}loadEdgeView(){return this._loadEdgeViewTask||(this._loadEdgeViewTask=s(async e=>{const{EdgeView:t}=await import("./edgeRendering/EdgeView.js");o(e);const s=this._edgeView=new t({rctx:this._rctx,renderSR:this.stage.view.renderSpatialReference,viewingMode:this.stage.view.stage.viewingMode,techniques:this._techniques,setNeedsRender:()=>this._requestRender(),schedule:ye(this.stage.view.resourceController)});return this.addHandles(d(()=>s.updating,()=>this._requestRender(),u)),this._requestRender(),this._edgeViewCallbacks.forEach(e=>e(s)),this._edgeViewCallbacks.length=0,s})),this._loadEdgeViewTask.promise}withEdgeView(e){this.loadEdgeView(),null==this._edgeView?this._edgeViewCallbacks.push(e):e(this._edgeView)}get edgeView(){return this._edgeView}get isCameraFinal(){return this._reprojectionMatrixVersion.value>=0&&b(this._bindParameters.reprojection.matrix,w)}set _reprojectionMatrix(e){t(this._bindParameters.reprojection.matrix,e)&&this._reprojectionMatrixVersion.value++}modifyShadowsEnabled(){const e=this.stage.view.environmentManager.referencePositionGeographic,t=null==e||G(e[2],this.stage.viewingMode),s=this.stage.view.environment.lighting.directShadowsEnabled&&t;this._bindParameters.shadowMap.enabled!==s&&(this._bindParameters.shadowMap.enabled=s,this._requestRender(1))}get shadowsEnabled(){return!!this._bindParameters.shadowMap.enabled}setParameters(e){e.shadowCast&&this._shadowAccumulator.setParameters(e.shadowCast)}set slice(e){this._sliceHelper.update(e)&&this._requestRender()}get plugins(){return this._plugins}commit(e,t){return this._isRendering&&console.warn("Renderer.modify called while rendering"),!!super.commit(e,t,this._plugins.context)&&(this.updateHasFlags(),!0)}addRenderer(e){this._plugins.add(e)}removeRenderer(e){this._plugins.remove(e)}get occludedRequiresStencil(){return this._occludedRequiresOccludeeStencil||this.occludedRequiresIntegratedMeshStencil}get _occludedRequiresOccludeeStencil(){return this._bindParameters.hasOccludees&&!!(8&this.plugins.renderOccludedFlags)}get occludedRequiresIntegratedMeshStencil(){return this._plugins.produces(0,0)&&this._plugins.produces(0,9)}updateHasFlags(){const has=this._pluginsHas;has.occludedHudElements=this._plugins.produces(0,13),has.hudElements=has.occludedHudElements||this._plugins.produces(0,...Te),has.water=this._plugins.produces(4,19),this._bindParameters.hasOccludees=this._plugins.hasOccludees,this._requestRender()}updateAnimation(e,t){this._animationTimer??=new W(e.camera,t),this._animationTimer.advance(e.camera,t,this._animationTimeDilation);const s=this._hasAnimations;return this._hasAnimations=this._plugins.updateAnimation(this._animationTimer),this._hasAnimations=this._nodes.updateAnimation(this._animationTimer)||this._hasAnimations,this._hasAnimations!==s&&(this._gpuTimerHandle=s?i(this._gpuTimerHandle):this.performanceInfo.enableGPUPerformanceInfo()),this._hasAnimations}get animationTimestep(){return this._animationTimestep.value}get _animationTimeDilation(){return this._animationTimestep.timeDilation}resetAnimation(){this._animationTimestep.clear()}tick(){this.fboCache.clean()}render(e,t,s=!1){try{return this._isRendering=!0,this._render(e,t,s)}catch(i){console.error(`Exception during rendering: ${i}:\n${i.stack}`)}finally{this._isRendering=!1}return new de(this._pluginInput.get(R.FINAL),null)}_render(e,t,s){const i=0===t;this.performanceInfo.startFrame(),this.fboCache.frameStart(),this.fboCache.interactive=i,this._disposeBindBuffers();const{camera:r,contentCamera:a,mode:o,alignPixelEnabled:d}=e;this._state.value=o,this._bindParameters.output=0,this._bindParameters.emissions=this._emissions,this._bindParameters.alignPixelEnabled=d,this._bindParameters.decorations=!s,this._bindParameters.mainDepth=null,this._bindParameters.useFloatBlend.value=this.hasFloatBlend;const l=!s||!this._sliceHelper.isDecoration;this._bindParameters.slicePlane=l?this._sliceHelper.plane:null,this._bindParameters.viewshedEnabled=this._nodes.produces(O.VIEWSHED),this._bindParameters.cutFillComputationEnabled=this._nodes.produces(O.CUTFILL_COMPUTATION),this._bindParameters.cutFillVisualizationEnabled=this._nodes.produces(O.CUTFILL_COLOR),this._ensureBindParameters(r,a),this._plugins.sortTestsTransparentOrderedSlots(Oe),this._plugins.prepareRender(),this._hasTransparentGeometry=this._plugins.produces(1,...we),this._renderOverlay(),r.setGLViewport(this._rctx);const m=this._framebuffer,u=m.initialize(r.fullWidth,r.fullHeight,this._backgroundColor),_=this._needsLastFrameColor;_?(u?.retain(_-1),u?.setName("last frame color"),this._bindParameters.reprojection.lastFrameColor?.release(),this._bindParameters.reprojection.lastFrameColor=u):u?.release(),this._bindParameters.hasShadowHighlights=this._needsShadowHighlight&&!s,this._shadowAccumulator.fullyRecompute=!i,this._shadowAccumulator.updateCamera(r),this._precompilePrepasses(),this.performanceInfo.advance(me.PREPARE);const p=this._computeShadowDepthRange(r);this._pluginInput.set("normals",this._renderNormals()),this._renderAmbientIlluminationAndDepth(),this._renderShadowMap(r,a,this._bindParameters.lighting.mainLight.direction,p),this._renderShadowAccumulation(p),m.bind(),this._bindParameters.mainDepth=m.depth.attachment,this._precompileShaders(i),this._bindParameters.output=0,this._renderOpaque(),this._renderPreTransparent(),this._renderTransparent(),this.hasReflections&&(this._bindParameters.depth=h(this._bindParameters.depth),this._bindParameters.reprojection.lastFrameColor=h(this._bindParameters.reprojection.lastFrameColor)),this._bindParameters.shadowMap.disposeOutput(5),m.update(e=>this._renderNodes(O.CUTFILL_COMPUTATION,e)),this._pluginInput.set(O.FOCUSAREA,this._renderFocusAreaGeometry()),m.update(e=>this._renderNodes(O.TRANSPARENT_ENVIRONMENT,e)),m.update(e=>this._renderNodes(O.VIEWSHED,e)),m.update(e=>this._renderNodes(O.LASERLINES,e)),this._nodes.requireGeometryDepth&&(this._bindParameters.depth=h(this._bindParameters.depth)),m.update(e=>this._renderNodes(O.FOCUSAREA_COLOR,e)),m.update(e=>this._renderNodes(O.CUTFILL_COLOR,e)),this._pluginInput.release(O.FOCUSAREA),this._pluginInput.release(O.GROUND_DEPTH),m.update(e=>this._renderNodes(O.OCCLUDED,e)),this._pluginInput.set("highlights",this._renderHighlightPrepass());const c=2===t?this._renderObjectAndLayerIdColor():null;m.update(e=>this._renderNodes(R.COMPOSITE,e)),this._bindParameters.shadowMap.disposeOutputs(),this._bindParameters.shadowHighlight=n(this._bindParameters.shadowHighlight),m.update(e=>this._renderNodes(O.ANTIALIASING,e));const b=this._hasTransparentGeometry?2:1,f=this._bindParameters.emissions;let g;return this._bindParameters.emissions=0,this._hasHUDHighlights&&m.update(e=>this._renderHUD(b,e)),m.update(e=>this._renderNodes(O.HIGHLIGHT_COLOR,e)),this._hasHUDHighlights||m.update(e=>this._renderHUD(b,e)),this._bindParameters.emissions=f,m.update(e=>this._renderNodes(O.MAGNIFIER,e)),m.update(e=>this._renderNodes(R.FINAL,e)),i&&(this._blit.toFramebuffer(m.color,this._bindParameters),fe||2!==o&&0!==o||this.navigationDepthCache.update(this._bindParameters,m.depth.attachment,this._renderContext.time)),this._bindParameters.reprojection.lastFrameDepth?.release(),this._bindParameters.reprojection.lastFrameEmission?.release(),this.hasGlobalIllumination&&(this._bindParameters.reprojection.lastFrameDepth?.release(),this._bindParameters.reprojection.lastFrameDepth=this._bindParameters.depth,0!==this._emissions&&(this._bindParameters.reprojection.lastFrameEmission?.release(),this._bindParameters.reprojection.lastFrameEmission=m.color.obtainAttachment(ue))),this._testsNeedsDepth&&(this._bindParameters.depth=h(this._bindParameters.depth)),this._releaseFBOs(),m.releaseDepth(),this._bindParameters.reprojection.lastFrameCamera.copyFrom(this._bindParameters.camera),this.fboCache.frameEnd(),i||(g=m.color,g.retain(),this._releaseFBOs(),this._disposeOffscreenBuffers()),this.performanceInfo.finishFrame(),new de(g,c)}_precompileShaders(e){++this._plugins.context.techniques.precompiling;const t=this._bindParameters;t.output=0;const s=t.emissions;if(this._precompileOpaqueGeometry(),this._nodes.precompile(t.hasOpaqueEmission,O.OPAQUE_ENVIRONMENT,O.GAUSSIAN_SPLAT,O.OPAQUE_OCCLUSION_QUERY,O.VOXEL),this._precompileOpaqueGeometry(),t.output=3,this._plugins.precompile(...Ee),t.output=0,this._plugins.precompile(...Ee),this._hasTransparentGeometry){const e=this._pluginsHas.occludedHudElements;this._oitBlend.precompile(t,e,0),this._pluginsHas.hudElements&&this._oitBlend.precompile(t,!1,1),this._precompileTransparentGeometry(),t.hasTransparentEmission&&(t.emissions=3)}this._nodes.precompile(t.hasOpaqueEmission,O.FOCUSAREA),this._compositor.precompile(this._usesPremultipliedAlphaBlit,!!this._needsEdges,t),this._hasTransparentGeometry||this._plugins.precompile(15),this._nodes.precompile(t.hasOpaqueEmission,O.TRANSPARENT_ENVIRONMENT,O.VIEWSHED,O.CUTFILL_COMPUTATION,O.CUTFILL_COLOR,O.LASERLINES,O.FOCUSAREA_COLOR,O.OCCLUDED,O.ANTIALIASING),t.highlightMixTexture=t.highlights.length>1?this._rctx.emptyTexture:null,this._precompileHUD(0),t.emissions=0,this._precompileHUD(0),this._precompileHUD(1),t.emissions=s,this._hasHighlights&&(t.highlights.forEach((e,s)=>{t.highlightLevel=s,this._precompileAllGeometry(10),this._hasHUDHighlights&&this._plugins.precompile(13,12)}),t.highlightLevel=null,this._nodes.precompile(t.hasEmissions,O.HIGHLIGHT_COLOR)),t.highlightMixTexture=null,this._nodes.precompile(t.hasEmissions,R.COMPOSITE,O.MAGNIFIER),this._shadowAccumulator.precompile(),this._plugins.precompile(8),t.hasOpaqueEmission&&(t.transparentWithoutDepthEmissionDimmingPass=!0,this._plugins.precompile(8),t.transparentWithoutDepthEmissionDimmingPass=!1),e&&this._blit.precompile(),--this._plugins.context.techniques.precompiling}_renderFocusAreaGeometry(){const e=this._nodes.produce(O.FOCUSAREA,this._pluginInput);return e&&this.performanceInfo.advance(me.FOCUS_AREA_MASK),e}_renderObjectAndLayerIdColor(){if(!this._nodes.produces(O.OBJECT_AND_LAYER_ID_COLOR))return null;const e=this._bindParameters.output;++this._techniques.precompiling;const{width:t,height:s}=this._framebuffer.size;let i=this.fboCache.acquire(t,s,O.OBJECT_AND_LAYER_ID_COLOR).acquireDepth(14);return i=this._renderNodes(O.OBJECT_AND_LAYER_ID_COLOR,i),--this._techniques.precompiling,this._bindParameters.output=e,i}finish(e){this._hasAnimations||this._animationTimestep.clear();const t=this.performanceInfo.gpuSamplingEnabled,s=0===e;if(s||t){const e=s?this.performanceInfo.elapsedTime:0;let i=0;t?i=this.performanceInfo.totalGPUTimeSampler.last:this._rctx.gl.finish();const r=Math.max(e,i);this._animationTimestep.frame(r,s)}}readAccumulatedShadow(e){return this._shadowAccumulator.readAccumulatedShadow(e[0],e[1])}readMainDepth(e,t){const{mainDepth:s,camera:i}=this._bindParameters;if(!s)return;const r=this.fboCache.acquire(this._framebuffer.size.width,this._framebuffer.size.height,"linear depth");this._rctx.bindFramebuffer(r.fbo),i.setGLViewport(this._rctx),this._rctx.setScissorRect(e[0],e[1],e[2],e[3]),this._rctx.setScissorTestEnabled(!0),this._rctx.clearFramebuffer(C),this._compositor.blitDepthToLinearDepth(this._bindParameters,s),this._rctx.setScissorTestEnabled(!1),this._rctx.setScissorRect(0,0,this._rctx.gl.canvas.width,this._rctx.gl.canvas.width),r.fbo?.readPixels(e[0],e[1],e[2],e[3],6408,_e.UNSIGNED_BYTE,t),r.release()}get _needsEdges(){return this._edgeView?.shouldRender()?this._edgeView:null}_renderEdges(e){const t=this._needsEdges;if(!t)return;const{width:s,height:i}=this._framebuffer.size,r=this.fboCache.acquire(s,i,"edges");r.attachDepth(this._framebuffer.depth),this._rctx.bindFramebuffer(r.fbo),this._rctx.clearFramebuffer(C),t.render(this._bindParameters,e),r.detachDepth(),this._framebuffer.bind(),this._compositor.composite(this._bindParameters,r.getTexture()),r.release(),this.performanceInfo.advance(1===e?me.OPAQUE_EDGES:me.TRANSPARENT_EDGES)}_renderOverlay(){this._bindParameters.overlay=this.overlay?.render(this._renderContext.time),this._bindParameters.overlay&&this.performanceInfo.advance(me.OVERLAY)}_renderShadowMap(e,t,s,i){if(!this.shadowsEnabled)return;const r=this._bindParameters.shadowMap;if(r.start(e,s,i,this.isFeatureEnabled(5),this.stage.view.qualitySettings.maximumPixelRatio),this._needsShadowHighlight){this._renderShadowCascades(6,r),e.setGLViewport(this._rctx),this._ensureBindParametersCamera(e,t);const s=this._bindParameters.output;this._bindParameters.output=0,this._bindParameters.shadowHighlight=this._nodes.produce(O.SHADOW_HIGHLIGHT,this._pluginInput),this._bindParameters.output=s,r.disposeOutput(6),r.clear(),this._renderShadowCascades(7,r)}else this._renderShadowCascades(5);e.setGLViewport(this._rctx),this._ensureBindParametersCamera(e,this._bindParameters.contentCamera),this._needsShadowHighlight&&(this._bindParameters.depth=h(this._bindParameters.depth)),this.performanceInfo.advance(O.SHADOWMAP)}_precompileShadowCascades(e){0!==this._bindParameters.shadowMap.cascades.length&&this._precompileAllGeometry(e)}_renderShadowCascades(e,t=this._bindParameters.shadowMap){const s=this._bindParameters.output,i=t===this._bindParameters.shadowMap&&6!==e;t.bindFramebuffer();for(const r of t.cascades)r.camera.setGLViewport(this._rctx),this._ensureBindParametersCamera(r.camera,r.camera),this.renderAllGeometry(e),i&&this._renderShadowNodes();t.finish(e),this._bindParameters.output=s}_renderShadowNodes(){const e=this._bindParameters.shadowMap.renderTarget;e&&(this._renderNodes(O.SHADOWMAP,e),this._pluginInput.set(O.SHADOWMAP,null))}get _needsLastFrameColor(){return+this.hasReflections+ +this.hasGlobalIllumination}get _needsDepth(){return+this._nodes.requireGeometryDepth+ +this.hasReflections+ +this.hasGlobalIllumination+ +this._shadowAccumulator.requiresDepth+ +this._testsNeedsDepth+ +this._needsShadowHighlight}get _usesPremultipliedAlphaBlit(){return this._pluginsHas.hudElements}_renderAmbientIlluminationAndDepth(){this._bindParameters.depth=n(this._bindParameters.depth);const e=this._pluginInput.get("normals");if(e){this._pluginInput.set(O.AMBIENT_ILLUMINATION,this._hasGlobalIlluminationFlag?this._renderGlobalIllumination():this._renderSSAO());const t=this._needsDepth;t?(this._rctx.bindFramebuffer(e.fbo),this._rctx.clear(1024),this._renderGeometryWithoutNormals(3),this._bindParameters.depth=e.obtainDepthTexture(),this._bindParameters.depth?.retain(t-1),this.performanceInfo.advance(me.DEPTH)):e.detachDepth(),this.hasAmbientIllumination&&this._pluginInput.release("normals")}else this._hasGlobalIlluminationFlag&&(this._releaseGlobalIlluminationBuffers(),this._bindParameters.globalIlluminationEnabled=this._keepGlobalIlluminationShadingAlive),this._renderAllGeometryDepth()}_renderAllGeometryDepth(){const e=this._needsDepth;if(0===e)return;const{width:t,height:s}=this._framebuffer.size,i=this.fboCache.acquire(t,s,"geometry depth",14);this._rctx.bindFramebuffer(i.fbo),this._rctx.clear(1280),this.renderAllGeometry(3),this._bindParameters.depth=i.obtainDepthTexture(),this._bindParameters.depth?.retain(e-1),i.release(),this.performanceInfo.advance(me.DEPTH)}get _needsShadowDepthRange(){return this._bindParameters.shadowMap.enabled||this._shadowAccumulator.active}_computeShadowDepthRange(e){if(!this._needsShadowDepthRange)return J.Zero;const t=X(e,this._plugins.plugins,this.stage.layers,0);return t.union(this._plugins.queryDepthRange(e)),this._bindParameters.shadowMap.enabled&&t.union(this._nodes.queryDepthRange(O.SHADOWMAP,e)),t.near=Math.max(e.near,t.near),t.far=Math.min(e.far,t.far),t}updateSceneDepthRange(e){if(!this.stage.view.state.isGlobal)return void(this.sceneDepthRange.value=J.Infinite);if((this.stage.view.renderCoordsHelper?.getAltitude(e.eye)??0)<j)return void(this.sceneDepthRange.value=J.Infinite);const t=e.clone();t.near=N,t.far=1e10;const s=X(t,this._plugins.plugins,this.stage.layers,1);s.union(this._plugins.queryDepthRange(t)),this.sceneDepthRange.value.equals(s)||(this.sceneDepthRange.value=s)}get _normalsRequired(){return this._nodes.require("normals",...S,O.VIEWSHED,O.LASERLINES)+(this.hasAmbientIllumination?1:0)}_precompilePrepasses(){this._normalsRequired?(this._precompilePlugins(4,Ie),this._needsDepth&&this._precompilePlugins(3,Ae)):this._needsDepth&&this._precompileAllGeometry(3),this.shadowsEnabled&&(this._needsShadowHighlight?(this._nodes.precompile(this._bindParameters.hasEmission,O.SHADOW_HIGHLIGHT),this._precompileShadowCascades(6),this._precompileShadowCascades(7)):this._precompileShadowCascades(5),this._nodes.precompile(!1,O.SHADOWMAP)),this._shadowAccumulator.active&&(this._shadowAccumulator.precompilePrepass(),this._precompileAllGeometry(5)),this.hasAmbientIllumination&&this._normalsRequired&&this._nodes.precompile(this._bindParameters.hasEmission,O.AMBIENT_ILLUMINATION)}_renderNormals(){const e=this._normalsRequired;if(0===e)return;const{width:t,height:s}=this._framebuffer.size,i=this.fboCache.acquire(t,s,"normals");i.acquireDepth(14),this._rctx.bindFramebuffer(i.fbo),this._rctx.clearFramebuffer(C,!0,!0),this._bindParameters.output=4,this._plugins.render(...Ie);const r=this._nodes.optional("normals",...S,O.VIEWSHED);return i.retain(e+r-1),this.performanceInfo.advance(me.NORMALS),i}_renderSSAO(){this._bindParameters.globalIlluminationEnabled=!1;const e=this._pluginInput.get("normals");return this.hasAmbientIllumination&&e?(this._bindParameters.ssao=this._nodes.produce(O.AMBIENT_ILLUMINATION,this._pluginInput),this._bindParameters.ssao&&this.performanceInfo.advance(me.AMBIENT_ILLUMINATION),this._bindParameters.ssao):null}_renderGlobalIllumination(){const e=this._bindParameters;if(!this.hasGlobalIllumination)return this._releaseGlobalIlluminationBuffers(),e.globalIlluminationEnabled=this._keepGlobalIlluminationShadingAlive,null;const t=this._nodes.produce(O.AMBIENT_ILLUMINATION,this._pluginInput);return this._releaseGlobalIlluminationBuffers(),this._bindParameters.globalIllumination=t,this._bindParameters.globalIlluminationEnabled=!0,this.performanceInfo.advance(this.hasGlobalIlluminationHighQuality?me.AMBIENT_ILLUMINATION_HIGH_QUALITY:me.AMBIENT_ILLUMINATION),e.globalIllumination}_releaseGlobalIlluminationBuffers(){const e=this._bindParameters;e.reprojection.lastFrameColor=h(e.reprojection.lastFrameColor),e.reprojection.lastFrameDepth=n(e.reprojection.lastFrameDepth),e.reprojection.lastFrameEmission=n(e.reprojection.lastFrameEmission),e.globalIllumination=h(e.globalIllumination),e.globalIlluminationEnabled=!1}_precompileAllGeometry(e){const t=this._bindParameters.output;this._bindParameters.output=e,this._precompileOpaqueGeometry(),this._precompileTransparentGeometry(),this._plugins.precompile(...Ee),this._bindParameters.output=t}renderAllGeometry(e){this._bindParameters.output=e,this._renderOpaqueAndTransparentGeometry(e),this._renderTransparentGround()}precompileSlots(e,...t){for(const s of t)this._bindParameters.slot=s,e.precompile(this._renderContext)}precompileOccludedSlots(e,t){for(const s of t)this._renderContext.renderOccludedMask=s,this.precompileSlots(e,...Ce);this._renderContext.renderOccludedMask=te}renderSlots(e,...t){for(const s of t)this._bindParameters.slot=s,e.forAll(e=>{const t=e.acquireTechniques(this._renderContext);t&&e.render(this._renderContext,t)})}renderOccludedSlots(e,t){this._renderContext.renderOccludedMask=t,this.plugins.renderOccludedFlags>1&&this._plugins.render(9),this.renderSlots(e,...Ce),this._renderContext.renderOccludedMask=te}renderHUD(e){this._bindParameters.hudRenderStyle=e,this._plugins.render(...Se[e])}_renderHUDElements(e){this._bindParameters.hudRenderStyle=e,this._plugins.render(16),this.renderHUD(e),this._bindParameters.hudRenderStyle=e,this._plugins.render(14)}precompileViewshedShadowMap(){this._precompileAllGeometry(8)}precompileCutFillOrthographicReferenceDepth(){this._precompilePlugins(9,De)}_precompilePlugins(e,t){const s=this._bindParameters.output;this._bindParameters.output=e,this._plugins.precompile(...t),this._bindParameters.output=s}renderViewshedShadowMap(e){const{camera:t,contentCamera:s}=this._bindParameters,i=this._bindParameters.output;e.setGLViewport(this._rctx),this._ensureBindParametersCamera(e,e),this.renderAllGeometry(8),this._ensureBindParametersCamera(t,s),this._bindParameters.camera.setGLViewport(this._rctx),this._bindParameters.output=i}renderCutFillOrthographicReferenceDepth(e){const{camera:t,contentCamera:s}=this._bindParameters,i=this._bindParameters.output;e.setGLViewport(this._rctx),this._ensureBindParametersCamera(e,e),this._bindParameters.output=9,this._plugins.render(...De),this._ensureBindParametersCamera(t,s),t.setGLViewport(this._rctx),this._bindParameters.output=i}get _needsGroundDepth(){return this._bindParameters.cutFillVisualizationEnabled}_blitGroundDepth(){if(!this._needsGroundDepth)return null;const{width:e,height:t}=this._framebuffer.size,s=this.fboCache.acquire(e,t,O.GROUND_DEPTH,14);return this._rctx.blitFramebuffer(this._framebuffer.color.fbo,s.fbo,256),this._framebuffer.bind(),s}_renderOpaqueAndTransparentGeometry(e){this._bindParameters.output=e,this._renderOpaqueGeometry(),this._renderTransparentGeometry()}_renderGeometryWithoutNormals(e){this._bindParameters.output=e,this._plugins.render(...Ae)}_precompileOpaqueGeometry(){this._needsOpaquePass&&(this._plugins.precompile(...Pe),this._nodes.precompile(this._bindParameters.hasEmission,"opaque-color"))}_renderOpaqueGeometry(){this._plugins.render(...Pe)}_renderTransparentGeometry(){this._plugins.render(...we),this._hasTransparentGeometry&&this._plugins.render(15)}_renderTransparentGround(){this._plugins.render(...Ee)}_precompileHUD(e){if(!this._pluginsHas.hudElements)return;const t=this._bindParameters.output,s=this._bindParameters.hudRenderStyle,i=this._bindParameters.emissions;this._bindParameters.emissions=0,this._bindParameters.hudRenderStyle=e,this._bindParameters.output=1,this._plugins.precompile(...Te),this._bindParameters.output=2,this._plugins.precompile(...Te),this._bindParameters.output=0,this._oitBlend.precompile(this._bindParameters,!1,1),this._hasHighlights&&(this._bindParameters.output=10,this._plugins.precompile(...Te)),this._bindParameters.emissions=i,this._bindParameters.output=t,this._bindParameters.hudRenderStyle=s}_renderHUD(e,t){if(!this._pluginsHas.hudElements)return t;const s=this._renderOIT(1,e);this._rctx.bindFramebuffer(t.fbo);const i=!!t.getTexture(ue);return this._compositor.compositePreMultipliedAlpha(this._bindParameters,s.getTexture(),i),s.release(),this.performanceInfo.advance(0===e?me.HUD_OCCLUDED:me.HUD),t}get _needsShadowHighlight(){return this.shadowsEnabled&&this._plugins.produces(6,2)}_renderHighlightPrepass(){if(!this._hasHighlights)return;const{fboCache:e,_rctx:t,_bindParameters:s}=this,{width:i,height:r}=this._framebuffer.size,{highlights:a}=s,n=a.length>B?3:1,h=e.acquire(i,r,"highlights",n);h.acquireDepth(14);const o=this._plugins.produces(10,0);return o&&this._framebuffer.color.fbo&&h.fbo&&t.blitFramebuffer(this._framebuffer.color.fbo,h.fbo,1024),t.bindFramebuffer(h.fbo),t.gl.clearBufferuiv(6144,0,[0,0,0,0]),o||t.clear(1024),this._bindParameters.output=10,t.bindFramebuffer(h.fbo),V(t,e,i,r,s,()=>this._renderHighlightGeometries()),h.detachDepth(),this.performanceInfo.advance(me.HIGHLIGHTS),h.retain(this._nodes.require("highlights",...D)+this._nodes.optional("highlights",...D)-1),h}_renderHighlightGeometries(){this._plugins.render(...Re),this._rctx.clear(256),this._renderHUDElements(2)}_renderShadowAccumulation(e){this._shadowAccumulator.updateDepthRange(e);const t=this._shadowAccumulator.requiresDepth;this._bindParameters.output=0,this._shadowAccumulator.renderAccumulation(this._bindParameters)&&this.performanceInfo.advance(me.ACCUMULATED_SHADOWS),this._shadowAccumulator.updateMask(),t&&(this._bindParameters.depth=h(this._bindParameters.depth))}_precompileTransparentGeometry(){y(this._bindParameters.output)?(this._bindParameters.output=1,this._plugins.precompile(...we),this._hasTransparentGeometry&&this._plugins.precompile(15),this._bindParameters.output=2,this._plugins.precompile(...we),this._hasTransparentGeometry&&this._plugins.precompile(15),this._bindParameters.output=0):this._plugins.precompile(...we)}_renderOIT(e,t=2){const s=1===e,{width:i,height:r}=this._framebuffer.size,a=s?()=>this._renderHUDElements(t):()=>this._renderTransparentGeometry(),h=this._bindParameters,o=h.useFloatBlend.value?8:5,d=h.output;h.output=1;const l=s?"oit hud":"oit",m=this.fboCache.acquire(i,r,l,o).acquireColor(ue,this.hasFloatBlend?7:0,"oit alpha"),u=h.hasEmission&&(0===e||1!==t);u&&m.acquireColor(pe,o,"oit emissive"),s||m.attachDepth(this._framebuffer.depth),this._rctx.bindFramebuffer(m.fbo),this._rctx.clearFramebuffer(Z),u&&this._rctx.clearBuffer(2,Z),a(),m.detachDepth(),h.output=2;const _=this.fboCache.acquire(i,r,s?"oit front hud":"oit front");u&&_.acquireColor(ue,o,"oit front emissive"),s?_.acquireDepth(this._hudDepthFormat):_.attachDepth(this._framebuffer.depth),this._rctx.bindFramebuffer(_.fbo),this._rctx.clearFramebuffer(C,s),a(),_.detachDepth();const p=this._pluginsHas.occludedHudElements&&!s,c=p&&0!==h.emissions?pe:ue;let b;return h.hudOcclusion=n(this._bindParameters.hudOcclusion),h.output=0,s?(b=this.fboCache.acquire(i,r,"oit composite hud"),this._rctx.bindFramebuffer(b.fbo),this._rctx.setClearColor(0,0,0,1e-13),this._rctx.clear(16384)):(0!==h.emissions&&this._framebuffer.ensureEmissionAttachment(),p&&(this._framebuffer.color.acquireColor(c,0,"hud occlusion"),this._rctx.clearBuffer(c-ce,C)),this._framebuffer.bind()),this._oitBlend.blend(this._rctx,m,_,h,p,e,this._fboCache.debugCallback),b?.detachDepth(),s||(u&&(this._bindParameters.emissions=3),p&&(h.hudOcclusion=this._framebuffer.color.obtainAttachment(c))),_.release(),m.release(),h.output=d,b}get _hudDepthFormat(){return this.isFeatureEnabled(7)?14:13}get _needsOpaquePass(){return this.plugins.produces(0,...Pe)||this.plugins.produces(5,...Pe)||this.plugins.produces(3,3)}_renderOpaque(){const e=this._needsOpaquePass;e&&(this._plugins.render(0,1),this._pluginInput.set(O.GROUND_DEPTH,this._blitGroundDepth()),this._plugins.render(2,3));const t=this._framebuffer;t.update(t=>this._renderNodes(R.OPAQUE,t,e)),this.fboCache.debugCallback?.(R.OPAQUE,t.color.fbo),t.update(e=>this._renderNodes(O.OPAQUE_ENVIRONMENT,e)),this.fboCache.debugCallback?.(O.OPAQUE_ENVIRONMENT,t.color.fbo),this._renderEdges(1)}_renderPreTransparent(){this._framebuffer.update(e=>this._renderNodes(O.GAUSSIAN_SPLAT,e)),this.fboCache.debugCallback?.(O.GAUSSIAN_SPLAT,this._framebuffer.color.fbo),this._framebuffer.update(e=>this._renderNodes(O.OPAQUE_OCCLUSION_QUERY,e)),this.fboCache.debugCallback?.(O.OPAQUE_OCCLUSION_QUERY,this._framebuffer.color.fbo),this._framebuffer.update(e=>this._renderNodes(O.VOXEL,e)),this.fboCache.debugCallback?.(O.VOXEL,this._framebuffer.color.fbo)}_renderTransparent(){const e=this._framebuffer;if(this._renderHiddenTransparentEdges(),this._hasTransparentGeometry&&this._renderOIT(0),e.update(e=>this._renderNodes(R.TRANSPARENT,e,this._hasTransparentGeometry)),this.fboCache.debugCallback?.(R.TRANSPARENT,e.color.fbo),this._hasTransparentGeometry||this._plugins.render(15),this._renderEdges(0),this._bindParameters.ssao=n(this._bindParameters.ssao),e.update(e=>this._renderNodes(O.TRANSPARENT_NO_DEPTH,e)),this.fboCache.debugCallback?.(O.TRANSPARENT_NO_DEPTH,e.color.fbo),this._framebuffer.bind(),this._plugins.render(8),this._bindParameters.hasEmission){const e=this._rctx.setDrawBuffers([be,ue]);this._bindParameters.transparentWithoutDepthEmissionDimmingPass=!0,this._plugins.render(8),this._bindParameters.transparentWithoutDepthEmissionDimmingPass=!1,this._rctx.setDrawBuffers(e)}this.performanceInfo.advance(me.TRANSPARENT_MATERIAL_WITHOUT_DEPTH)}_renderNodes(e,t,s=!1){if(t.setName(e),this._pluginInput.set(e,t),!this._nodes.produces(e))return s&&this.performanceInfo.advance(e),t;const i=this._nodes.render(t,this._pluginInput,this._releaseNodeInputs);return this.performanceInfo.advance(e),this._fboCache.debugCallback?.(e,i.fbo),i}_ensureBindParameters(e,t){this._ensureBindParametersCamera(e,t),this._ensureBindParametersWeatherFader(),this._ensureBindParametersScreenSpaceReflections(),this._ensureBindParametersReprojection()}_ensureBindParametersCamera(e,t){this._bindParameters.camera=e,this._bindParameters.contentCamera=t}_ensureBindParametersWeatherFader(){1===this.stage.viewingMode&&(this._bindParameters.clouds.data&&(this._bindParameters.clouds.fade(this._bindParameters.camera,this.renderContext.time,this.stage.view.qualitySettings.fadeDuration,this.stage.view.state.stationary),this.weatherFader?.cleanupCubemap()),this._bindParameters.snowCover=this.weatherFader?.snowCover??0)}_ensureBindParametersScreenSpaceReflections(){const{time:e}=this.renderContext,{screenSpaceReflections:t}=this._bindParameters;if(this.hasReflections){null==this._ssrEnableTime&&(this._ssrEnableTime=e);const s=this.stage.view.qualitySettings.fadeDuration;t.fadeFactor=s>0?Math.min(s,e-this._ssrEnableTime)/s:1,t.fadeFactor<1&&this._requestRender()}else this._ssrEnableTime=null}_ensureBindParametersReprojection(){if(!(this.hasReflections||this.hasGlobalIllumination))return void(this._reprojectionMatrix=w);const{reprojection:e,camera:t}=this._bindParameters,{lastFrameCamera:s}=e,i=!s.equals(t);if(i?(f(Ge,t.viewMatrix),f(Fe,t.projectionMatrix),g(He,Ge,Fe),g(He,s.viewMatrix,He),g(He,s.projectionMatrix,He),this._reprojectionMatrix=He):this._reprojectionMatrix=w,this.hasGlobalIllumination){const{viewMatrix:t}=e;i?(g(xe,s.viewMatrix,Ge),P(t,xe)):P(t,w)}}addRenderNode(e){this._nodes.add(e),this._requestRender()}removeRenderNode(e){this._nodes.remove(e),this._requestRender()}updateLighting(e,t,s,i){this._bindParameters.updateLighting(e,t,s,i),this._requestRender(1)}get usedMemory(){return{fbos:this.fboCache.usedMemory,plugins:this._plugins.usedMemory,edges:this.edgeView?.usedMemory??0,clouds:this.weatherFader?.usedMemory??0}}get test(){}};e([p()],ge.prototype,"_inGlobeView",void 0),e([p({readOnly:!0})],ge.prototype,"highResolutionAtmosphere",null),e([p()],ge.prototype,"_edgeView",void 0),e([p()],ge.prototype,"updating",null),ge=e([c("esri.views.3d.webgl-engine.lib.Renderer")],ge);const Pe=[0,1,2,3],we=[7,6,4,5],Ee=[7,6],Ie=[0,1,2,4,...Ee],Ae=[3,5],Ce=[2,4,8],Te=[16,12,14,13],Re=[4,5,2,3,0,1,...Ee],Oe=[4,8,5,11],Se={0:[13],1:[12],2:[13,12],3:[13,12]},De=[0,1,...Ee],Ne=["normals","highlights"],Fe=E(),Ge=E(),He=E(),xe=E();function ye(e){return t=>e.immediate.schedule(t)}export{ge as Renderer};
2
+ import{__decorate as e}from"tslib";import{update as t}from"../../../../core/arrayUtils.js";import{createTask as s}from"../../../../core/asyncUtils.js";import has from"../../../../core/has.js";import{removeMaybe as i,abortMaybe as r,destroyMaybe as a,releaseMaybe as n,releaseReferencedMaybe as h}from"../../../../core/maybe.js";import{throwIfAborted as o}from"../../../../core/promiseUtils.js";import{watch as d,syncAndInitial as l,initial as m,sync as u}from"../../../../core/reactiveUtils.js";import{signal as _}from"../../../../core/signal.js";import{property as p,subclass as c}from"../../../../core/accessorSupport/decorators.js";import{equals as b,invert as f,multiply as g,copy as P}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{IDENTITY as w,create as E}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{set as I}from"../../../../core/libs/gl-matrix-2/math/vec4.js";import{fromValues as A,ZEROS as C}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{pruneIndexArrays as T}from"../../../../geometry/support/Indices.js";import{RenderNodeOutput as R,InternalRenderCategory as O,AllRenderNodeOutputs as S,AllInternalRenderNodeOutputs as D}from"../../webgl.js";import{minNearDistanceInMeters as N}from"../../state/NearFarHeuristic.js";import{debugFlags as F}from"../../support/debugFlags.js";import{computeShadowsEnabled as G}from"../../support/sunUtils.js";import{FBOCache as H}from"../core/FBOCache.js";import{RenderPassManager as x}from"../core/renderPasses/RenderPassManager.js";import{isColor as y}from"../core/shaderLibrary/ShaderOutput.js";import{distanceFadeEnd as v}from"../core/shaderLibrary/shading/ScreenSpaceConstants.js";import{RenderNodes as M}from"../effects/RenderNodes.js";import{RenderPluginManager as L}from"../effects/RenderPluginManager.js";import{WeatherFader as q}from"../effects/WeatherFader.js";import{innerAtmosphereFadeStart as j}from"../effects/atmosphere/atmosphereUtils.js";import{Blit as U}from"../effects/blit/Blit.js";import{maxHighlightsPerChannel as B,renderHighlightBuffer as V}from"../effects/highlight/Highlight.js";import{OITBlend as k}from"../effects/transparency/OITBlend.js";import{AnimationTimer as W}from"./AnimationTimer.js";import{AnimationTimeStep as Q}from"./AnimationTimeStep.js";import{BoundingInfo as z}from"./BoundingInfo.js";import{Compositor as Y}from"./Compositor.js";import{DepthRange as J}from"./DepthRange.js";import{depthRangeFromScene as X}from"./depthRangeUtils.js";import{MainFramebuffer as $}from"./MainFramebuffer.js";import{NavigationDepthCache as K}from"./NavigationDepthCache.js";import{blendingColorAlphaClear as Z}from"./OrderIndependentTransparency.js";import{RenderContext as ee,defaultRenderOccludedMask as te}from"./RenderContext.js";import{RendererBase as se}from"./RendererBase.js";import{setupFeatureDefaults as ie}from"./RenderFeature.js";import{RenderPluginInput as re}from"./RenderPluginInput.js";import{ShadowAccumulator as ae}from"./ShadowAccumulator.js";import{ShadowMap as ne}from"./ShadowMap.js";import he from"./SliceHelper.js";import{MergedRenderer as oe}from"../materials/renderers/MergedRenderer.js";import{RenderSceneResult as de}from"../parts/renderUtils.js";import{RendererPerformanceInfo as le,PerformanceCategory as me}from"../statistics/RendererPerformanceInfo.js";import{ColorAttachment1 as ue,PixelType as _e,ColorAttachment2 as pe,ColorAttachment0 as ce,DrawBufferNone as be}from"../../../webgl/enums.js";const fe=has("disable-feature:async-navigation-3d-depth-readback");let ge=class extends se{constructor(e,t,s,i,r){super({stage:e}),this._techniques=s,this._rctx=i,this._requestRender=r,this._pluginsHas={occludedHudElements:!1,hudElements:!1,water:!1},this.renderPassManager=new x,this._isRendering=!1,this._inGlobeView=!1,this._backgroundColor=A(0,0,0,1),this._sliceHelper=new he,this.sceneDepthRange=_(J.Infinite),this._state=_(2),this._hasGlobalIlluminationFlag=!!has("enable-feature:global-illumination"),this._hasAnimations=!1,this._animationTimestep=new Q,this._loadEdgeViewTask=null,this._edgeViewCallbacks=[],this._reprojectionMatrixVersion=_(0),this._renderHiddenTransparentEdges=()=>{},this._pluginInput=new re,this._hasTransparentGeometry=!1,this._releaseNodeInputs=e=>{for(const t of Ne)e.some(({name:e})=>e===t)&&this._pluginInput.release(t)},this._testsNeedsDepth=!1,this._fboCache=new H(i),this._compositor=new Y(i,s),this._renderStateFeatures=_(ie(e.view.qualityProfile));const a=new ne(this._fboCache,e.viewingMode);this._renderContext=new ee(this._rctx,a,s),this._framebuffer=new $(this._fboCache,this._bindParameters),this._performanceInfo=new le(this._rctx),this._blit=new U(s),this.navigationDepthCache=new K(this._rctx,this._fboCache,s,()=>this._requestRender(0)),this._shadowAccumulator=new ae(this.fboCache,s,e,(t,s,i)=>{const r=e.view.qualitySettings.maximumPixelRatio;t.shadowMap.start(t.camera,s,i,!0,r),this._renderShadowCascades(5,t.shadowMap),t.camera.setGLViewport(this._rctx),this._ensureBindParametersCamera(t.camera,t.contentCamera)},r),this._nodes=new M(this._renderContext),this._plugins=new L({renderContext:this._renderContext,techniques:s,materials:t,requestRender:r,controller:e}),this._plugins.add(this.renderPassManager),this.weatherFader=new q({view:e.view,context:this._renderContext}),this.addHandles([d(()=>e.view.state.camera,()=>r(),l),d(()=>F.EDGES_SHOW_HIDDEN_TRANSPARENT_EDGES,e=>{this._renderHiddenTransparentEdges=e?()=>this._renderEdges(0):()=>{},r()},m),d(()=>e.view.environment.background?.color,e=>{const t=e?e.toUnitRGBA():C;I(this._backgroundColor,t[0]*t[3],t[1]*t[3],t[2]*t[3],t[3]),r()},l),d(()=>e.view.state.camera.relativeElevation,e=>this._inGlobeView=(e??1/0)>=v,l),d(()=>this._bindParameters.clouds.fadeFactor,()=>{this._bindParameters.fadeLighting(),this._requestRender(2)},u),d(()=>this._bindParameters.clouds.data?.state,()=>r(),u),d(()=>e.view.state.highlights,e=>{this._bindParameters.highlights=e,r()},m),d(()=>"sun"===e.view.environment.lighting?.type,e=>{this._bindParameters.enableFillLights=e,this._requestRender()},l)])}destroy(){this._gpuTimerHandle=i(this._gpuTimerHandle),this._nodes.destroy(),this._framebuffer.dispose(),this._shadowAccumulator.destroy(),this._shadowAccumulator=null,this._loadEdgeViewTask=r(this._loadEdgeViewTask),this._edgeView=a(this._edgeView),this.renderPassManager.dispose(),this.weatherFader=a(this.weatherFader),this._releaseFBOs(),this._disposeOffscreenBuffers(),this.navigationDepthCache.destroy(),this._fboCache.destroy(),this._fboCache=null,this._renderContext.destroy(),this._plugins.destroy(),this._pluginInput=null,this._oitBlendOrNil=null,this._nodes=null,this._framebuffer=null,this._performanceInfo=null,z.prune(),oe.prune(),T()}get renderContext(){return this._renderContext}get _bindParameters(){return this._renderContext.bind}get _oitBlend(){return this._oitBlendOrNil??=new k(this._techniques),this._oitBlendOrNil}get performanceInfo(){return this._performanceInfo}updateRenderFeatures(e){this._renderStateFeatures.value=ie(e),this._requestRender()}isFeatureEnabled(e,t=this._state.value){return this._renderStateFeatures.value.get(t,e)??!1}setFeatureEnabled(e,t,s){this._renderStateFeatures.mutate(i=>i.set(t,e,s)),this._requestRender()}setTime(e){this._renderContext.time=e}get hasReflections(){return this._bindParameters.screenSpaceReflections.enabled=this._pluginsHas.water&&this.isFeatureEnabled(4),this._bindParameters.screenSpaceReflections.enabled}get _hasHighlights(){return this._plugins.produces(10,2,4,18,12,13,14)}hasHighlight(e){return this._plugins.hasHighlight(e)}get _hasHUDHighlights(){return this._plugins.produces(10,12,13,14)}get hasAmbientIllumination(){return this.isFeatureEnabled(3)&&!this._inGlobeView}get hasGlobalIllumination(){return this._hasGlobalIlluminationFlag&&this.hasAmbientIllumination}get hasGlobalIlluminationHighQuality(){return this.hasGlobalIllumination&&this.isFeatureEnabled(10)}get _keepGlobalIlluminationShadingAlive(){return this._hasGlobalIlluminationFlag&&!this._inGlobeView}get hasSMAA(){return this.isFeatureEnabled(0)}get _emissions(){const e=this._plugins.emissions;return this._hasTransparentGeometry?e:1===e||3===e?1:0}get hasFloatBlend(){return this._rctx.driverTest.floatBufferBlend.result&&this.isFeatureEnabled(9)}get highResolutionAtmosphere(){return this.isFeatureEnabled(2)}get fboCache(){return this._fboCache}_releaseFBOs(){this._bindParameters.hudOcclusion=n(this._bindParameters.hudOcclusion),this._bindParameters.depth=null}_disposeOffscreenBuffers(){this._framebuffer.dispose(),this._bindParameters.globalIllumination=n(this._bindParameters.globalIllumination),this._bindParameters.reprojection.lastFrameDepth=n(this._bindParameters.reprojection.lastFrameDepth),this._bindParameters.reprojection.lastFrameEmission=n(this._bindParameters.reprojection.lastFrameEmission),this._disposeBindBuffers()}_disposeBindBuffers(){this._bindParameters.shadowMap.disposeOutputs()}get updating(){return this._loadEdgeViewTask&&!this._loadEdgeViewTask.finished||this._edgeView?.updating||this._plugins.updating||this.weatherFader?.readyToRun||!this.isCameraFinal}loadEdgeView(){return this._loadEdgeViewTask||(this._loadEdgeViewTask=s(async e=>{const{EdgeView:t}=await import("./edgeRendering/EdgeView.js");o(e);const s=this._edgeView=new t({rctx:this._rctx,renderSR:this.stage.view.renderSpatialReference,viewingMode:this.stage.view.stage.viewingMode,techniques:this._techniques,setNeedsRender:()=>this._requestRender(),schedule:ye(this.stage.view.resourceController)});return this.addHandles(d(()=>s.updating,()=>this._requestRender(),u)),this._requestRender(),this._edgeViewCallbacks.forEach(e=>e(s)),this._edgeViewCallbacks.length=0,s})),this._loadEdgeViewTask.promise}withEdgeView(e){this.loadEdgeView(),null==this._edgeView?this._edgeViewCallbacks.push(e):e(this._edgeView)}get edgeView(){return this._edgeView}get isCameraFinal(){return this._reprojectionMatrixVersion.value>=0&&b(this._bindParameters.reprojection.matrix,w)}set _reprojectionMatrix(e){t(this._bindParameters.reprojection.matrix,e)&&this._reprojectionMatrixVersion.value++}modifyShadowsEnabled(){const e=this.stage.view.environmentManager.referencePositionGeographic,t=null==e||G(e[2],this.stage.viewingMode),s=this.stage.view.environment.lighting.directShadowsEnabled&&t;this._bindParameters.shadowMap.enabled!==s&&(this._bindParameters.shadowMap.enabled=s,this._requestRender(1))}get shadowsEnabled(){return!!this._bindParameters.shadowMap.enabled}setParameters(e){e.shadowCast&&this._shadowAccumulator.setParameters(e.shadowCast)}set slice(e){this._sliceHelper.update(e)&&this._requestRender()}get plugins(){return this._plugins}commit(e,t){return this._isRendering&&console.warn("Renderer.modify called while rendering"),!!super.commit(e,t,this._plugins.context)&&(this.updateHasFlags(),!0)}addRenderer(e){this._plugins.add(e)}removeRenderer(e){this._plugins.remove(e)}get occludedRequiresStencil(){return this._occludedRequiresOccludeeStencil||this.occludedRequiresIntegratedMeshStencil}get _occludedRequiresOccludeeStencil(){return this._bindParameters.hasOccludees&&!!(8&this.plugins.renderOccludedFlags)}get occludedRequiresIntegratedMeshStencil(){return this._plugins.produces(0,0)&&this._plugins.produces(0,9)}updateHasFlags(){const has=this._pluginsHas;has.occludedHudElements=this._plugins.produces(0,13),has.hudElements=has.occludedHudElements||this._plugins.produces(0,...Te),has.water=this._plugins.produces(4,19),this._bindParameters.hasOccludees=this._plugins.hasOccludees,this._requestRender()}updateAnimation(e,t){this._animationTimer??=new W(e.camera,t),this._animationTimer.advance(e.camera,t,this._animationTimeDilation);const s=this._hasAnimations;return this._hasAnimations=this._plugins.updateAnimation(this._animationTimer),this._hasAnimations=this._nodes.updateAnimation(this._animationTimer)||this._hasAnimations,this._hasAnimations!==s&&(this._gpuTimerHandle=s?i(this._gpuTimerHandle):this.performanceInfo.enableGPUPerformanceInfo()),this._hasAnimations}get animationTimestep(){return this._animationTimestep.value}get _animationTimeDilation(){return this._animationTimestep.timeDilation}resetAnimation(){this._animationTimestep.clear()}tick(){this.fboCache.clean()}render(e,t,s=!1){try{return this._isRendering=!0,this._render(e,t,s)}catch(i){console.error(`Exception during rendering: ${i}:\n${i.stack}`)}finally{this._isRendering=!1}return new de(this._pluginInput.get(R.FINAL),null)}_render(e,t,s){const i=0===t;this.performanceInfo.startFrame(),this.fboCache.frameStart(),this.fboCache.interactive=i,this._disposeBindBuffers();const{camera:r,contentCamera:a,mode:o,alignPixelEnabled:d}=e;this._state.value=o,this._bindParameters.output=0,this._bindParameters.emissions=this._emissions,this._bindParameters.alignPixelEnabled=d,this._bindParameters.decorations=!s,this._bindParameters.mainDepth=null,this._bindParameters.useFloatBlend.value=this.hasFloatBlend;const l=!s||!this._sliceHelper.isDecoration;this._bindParameters.slicePlane=l?this._sliceHelper.plane:null,this._bindParameters.viewshedEnabled=this._nodes.produces(O.VIEWSHED),this._bindParameters.cutFillComputationEnabled=this._nodes.produces(O.CUTFILL_COMPUTATION),this._bindParameters.cutFillVisualizationEnabled=this._nodes.produces(O.CUTFILL_COLOR),this._ensureBindParameters(r,a),this._plugins.sortTestsTransparentOrderedSlots(Oe),this._plugins.prepareRender(),this._hasTransparentGeometry=this._plugins.produces(1,...we),this._renderOverlay(),r.setGLViewport(this._rctx);const m=this._framebuffer,u=m.initialize(r.fullWidth,r.fullHeight,this._backgroundColor),_=this._needsLastFrameColor;_?(u?.retain(_-1),u?.setName("last frame color"),this._bindParameters.reprojection.lastFrameColor?.release(),this._bindParameters.reprojection.lastFrameColor=u):u?.release(),this._bindParameters.hasShadowHighlights=this._needsShadowHighlight&&!s,this._shadowAccumulator.fullyRecompute=!i,this._shadowAccumulator.updateCamera(r),this._precompilePrepasses(),this.performanceInfo.advance(me.PREPARE);const p=this._computeShadowDepthRange(r);this._pluginInput.set("normals",this._renderNormals()),this._renderAmbientIlluminationAndDepth(),this._renderShadowMap(r,a,this._bindParameters.lighting.mainLight.direction,p),this._renderShadowAccumulation(p),m.bind(),this._bindParameters.mainDepth=m.depth.attachment,this._precompileShaders(i),this._bindParameters.output=0,this._renderOpaque(),this._renderPreTransparent(),this._renderTransparent(),this.hasReflections&&(this._bindParameters.depth=h(this._bindParameters.depth),this._bindParameters.reprojection.lastFrameColor=h(this._bindParameters.reprojection.lastFrameColor)),this._bindParameters.shadowMap.disposeOutput(5),m.update(e=>this._renderNodes(O.CUTFILL_COMPUTATION,e)),this._pluginInput.set(O.FOCUSAREA,this._renderFocusAreaGeometry()),m.update(e=>this._renderNodes(O.TRANSPARENT_ENVIRONMENT,e)),m.update(e=>this._renderNodes(O.VIEWSHED,e)),m.update(e=>this._renderNodes(O.LASERLINES,e)),this._nodes.requireGeometryDepth&&(this._bindParameters.depth=h(this._bindParameters.depth)),m.update(e=>this._renderNodes(O.FOCUSAREA_COLOR,e)),m.update(e=>this._renderNodes(O.CUTFILL_COLOR,e)),this._pluginInput.release(O.FOCUSAREA),this._pluginInput.release(O.GROUND_DEPTH),m.update(e=>this._renderNodes(O.OCCLUDED,e)),this._pluginInput.set("highlights",this._renderHighlightPrepass());const c=2===t?this._renderObjectAndLayerIdColor():null;m.update(e=>this._renderNodes(R.COMPOSITE,e)),this._bindParameters.shadowMap.disposeOutputs(),this._bindParameters.shadowHighlight=n(this._bindParameters.shadowHighlight),m.update(e=>this._renderNodes(O.ANTIALIASING,e));const b=this._hasTransparentGeometry?2:1,f=this._bindParameters.emissions;let g;return this._bindParameters.emissions=0,this._hasHUDHighlights&&m.update(e=>this._renderHUD(b,e)),m.update(e=>this._renderNodes(O.HIGHLIGHT_COLOR,e)),this._hasHUDHighlights||m.update(e=>this._renderHUD(b,e)),this._bindParameters.emissions=f,m.update(e=>this._renderNodes(O.MAGNIFIER,e)),m.update(e=>this._renderNodes(R.FINAL,e)),i&&(this._blit.toFramebuffer(m.color,this._bindParameters),fe||2!==o&&0!==o||this.navigationDepthCache.update(this._bindParameters,m.depth.attachment,this._renderContext.time)),this._bindParameters.reprojection.lastFrameDepth?.release(),this._bindParameters.reprojection.lastFrameEmission?.release(),this.hasGlobalIllumination&&(this._bindParameters.reprojection.lastFrameDepth?.release(),this._bindParameters.reprojection.lastFrameDepth=this._bindParameters.depth,0!==this._emissions&&(this._bindParameters.reprojection.lastFrameEmission?.release(),this._bindParameters.reprojection.lastFrameEmission=m.color.obtainAttachment(ue))),this._testsNeedsDepth&&(this._bindParameters.depth=h(this._bindParameters.depth)),this._releaseFBOs(),m.releaseDepth(),this._bindParameters.reprojection.lastFrameCamera.copyFrom(this._bindParameters.camera),this.fboCache.frameEnd(),i||(g=m.color,g.retain(),this._releaseFBOs(),this._disposeOffscreenBuffers()),this.performanceInfo.finishFrame(),new de(g,c)}_precompileShaders(e){++this._plugins.context.techniques.precompiling;const t=this._bindParameters;t.output=0;const s=t.emissions;if(this._precompileOpaqueGeometry(),this._nodes.precompile(t.hasOpaqueEmission,O.OPAQUE_ENVIRONMENT,O.GAUSSIAN_SPLAT,O.OPAQUE_OCCLUSION_QUERY,O.VOXEL),this._precompileOpaqueGeometry(),t.output=3,this._plugins.precompile(...Ee),t.output=0,this._plugins.precompile(...Ee),this._hasTransparentGeometry){const e=this._pluginsHas.occludedHudElements;this._oitBlend.precompile(t,e,0),this._pluginsHas.hudElements&&this._oitBlend.precompile(t,!1,1),this._precompileTransparentGeometry(),t.hasTransparentEmission&&(t.emissions=3)}this._nodes.precompile(t.hasOpaqueEmission,O.FOCUSAREA),this._compositor.precompile(this._usesPremultipliedAlphaBlit,!!this._needsEdges,t),this._hasTransparentGeometry||this._plugins.precompile(15),this._nodes.precompile(t.hasOpaqueEmission,O.TRANSPARENT_ENVIRONMENT,O.VIEWSHED,O.CUTFILL_COMPUTATION,O.CUTFILL_COLOR,O.LASERLINES,O.FOCUSAREA_COLOR,O.OCCLUDED,O.ANTIALIASING),t.highlightMixTexture=t.highlights.length>1?this._rctx.emptyTexture:null,this._precompileHUD(0),t.emissions=0,this._precompileHUD(0),this._precompileHUD(1),t.emissions=s,this._hasHighlights&&(t.highlights.forEach((e,s)=>{t.highlightLevel=s,this._precompileAllGeometry(10),this._hasHUDHighlights&&this._plugins.precompile(13,12)}),t.highlightLevel=null,this._nodes.precompile(t.hasEmissions,O.HIGHLIGHT_COLOR)),t.highlightMixTexture=null,this._nodes.precompile(t.hasEmissions,R.COMPOSITE,O.MAGNIFIER),this._shadowAccumulator.precompile(),this._plugins.precompile(8),t.hasOpaqueEmission&&(t.transparentWithoutDepthEmissionDimmingPass=!0,this._plugins.precompile(8),t.transparentWithoutDepthEmissionDimmingPass=!1),e&&this._blit.precompile(),--this._plugins.context.techniques.precompiling}_renderFocusAreaGeometry(){const e=this._nodes.produce(O.FOCUSAREA,this._pluginInput);return e&&this.performanceInfo.advance(me.FOCUS_AREA_MASK),e}_renderObjectAndLayerIdColor(){if(!this._nodes.produces(O.OBJECT_AND_LAYER_ID_COLOR))return null;const e=this._bindParameters.output;++this._techniques.precompiling;const{width:t,height:s}=this._framebuffer.size;let i=this.fboCache.acquire(t,s,O.OBJECT_AND_LAYER_ID_COLOR).acquireDepth(14);return i=this._renderNodes(O.OBJECT_AND_LAYER_ID_COLOR,i),--this._techniques.precompiling,this._bindParameters.output=e,i}finish(e){this._hasAnimations||this._animationTimestep.clear();const t=this.performanceInfo.gpuSamplingEnabled,s=0===e;if(s||t){const e=s?this.performanceInfo.elapsedTime:0;let i=0;t?i=this.performanceInfo.totalGPUTimeSampler.last:this._rctx.gl.finish();const r=Math.max(e,i);this._animationTimestep.frame(r,s)}}readAccumulatedShadow(e){return this._shadowAccumulator.readAccumulatedShadow(e[0],e[1])}readMainDepth(e,t){const{mainDepth:s,camera:i}=this._bindParameters;if(!s)return;const r=this.fboCache.acquire(this._framebuffer.size.width,this._framebuffer.size.height,"linear depth");this._rctx.bindFramebuffer(r.fbo),i.setGLViewport(this._rctx),this._rctx.setScissorRect(e[0],e[1],e[2],e[3]),this._rctx.setScissorTestEnabled(!0),this._rctx.clearFramebuffer(C),this._compositor.blitDepthToLinearDepth(this._bindParameters,s),this._rctx.setScissorTestEnabled(!1),this._rctx.setScissorRect(0,0,this._rctx.gl.canvas.width,this._rctx.gl.canvas.width),r.fbo?.readPixels(e[0],e[1],e[2],e[3],6408,_e.UNSIGNED_BYTE,t),r.release()}get _needsEdges(){return this._edgeView?.shouldRender()?this._edgeView:null}_renderEdges(e){const t=this._needsEdges;if(!t)return;const{width:s,height:i}=this._framebuffer.size,r=this.fboCache.acquire(s,i,"edges");r.attachDepth(this._framebuffer.depth),this._rctx.bindFramebuffer(r.fbo),this._rctx.clearFramebuffer(C),t.render(this._bindParameters,e),r.detachDepth(),this._framebuffer.bind(),this._compositor.composite(this._bindParameters,r.getTexture()),r.release(),this.performanceInfo.advance(1===e?me.OPAQUE_EDGES:me.TRANSPARENT_EDGES)}_renderOverlay(){this._bindParameters.overlay=this.overlay?.render(this._renderContext.time),this._bindParameters.overlay&&this.performanceInfo.advance(me.OVERLAY)}_renderShadowMap(e,t,s,i){if(!this.shadowsEnabled)return;const r=this._bindParameters.shadowMap;if(r.start(e,s,i,this.isFeatureEnabled(5),this.stage.view.qualitySettings.maximumPixelRatio),this._needsShadowHighlight){this._renderShadowCascades(6,r),e.setGLViewport(this._rctx),this._ensureBindParametersCamera(e,t);const s=this._bindParameters.output;this._bindParameters.output=0,this._bindParameters.shadowHighlight=this._nodes.produce(O.SHADOW_HIGHLIGHT,this._pluginInput),this._bindParameters.output=s,r.disposeOutput(6),r.clear(),this._renderShadowCascades(7,r)}else this._renderShadowCascades(5);e.setGLViewport(this._rctx),this._ensureBindParametersCamera(e,this._bindParameters.contentCamera),this._needsShadowHighlight&&(this._bindParameters.depth=h(this._bindParameters.depth)),this.performanceInfo.advance(O.SHADOWMAP)}_precompileShadowCascades(e){0!==this._bindParameters.shadowMap.cascades.length&&this._precompileAllGeometry(e)}_renderShadowCascades(e,t=this._bindParameters.shadowMap){const s=this._bindParameters.output,i=t===this._bindParameters.shadowMap&&6!==e;t.bindFramebuffer();for(const r of t.cascades)r.camera.setGLViewport(this._rctx),this._ensureBindParametersCamera(r.camera,r.camera),this.renderAllGeometry(e),i&&this._renderShadowNodes();t.finish(e),this._bindParameters.output=s}_renderShadowNodes(){const e=this._bindParameters.shadowMap.renderTarget;e&&(this._renderNodes(O.SHADOWMAP,e),this._pluginInput.set(O.SHADOWMAP,null))}get _needsLastFrameColor(){return+this.hasReflections+ +this.hasGlobalIllumination}get _needsDepth(){return+this._nodes.requireGeometryDepth+ +this.hasReflections+ +this.hasGlobalIllumination+ +this._shadowAccumulator.requiresDepth+ +this._testsNeedsDepth+ +this._needsShadowHighlight}get _usesPremultipliedAlphaBlit(){return this._pluginsHas.hudElements}_renderAmbientIlluminationAndDepth(){this._bindParameters.depth=n(this._bindParameters.depth);const e=this._pluginInput.get("normals");if(e){this._pluginInput.set(O.AMBIENT_ILLUMINATION,this._hasGlobalIlluminationFlag?this._renderGlobalIllumination():this._renderSSAO());const t=this._needsDepth;t?(this._rctx.bindFramebuffer(e.fbo),this._rctx.clear(1024),this._renderGeometryWithoutNormals(3),this._bindParameters.depth=e.obtainDepthTexture(),this._bindParameters.depth?.retain(t-1),this.performanceInfo.advance(me.DEPTH)):e.detachDepth(),this.hasAmbientIllumination&&this._pluginInput.release("normals")}else this._hasGlobalIlluminationFlag&&(this._releaseGlobalIlluminationBuffers(),this._bindParameters.globalIlluminationEnabled=this._keepGlobalIlluminationShadingAlive),this._renderAllGeometryDepth()}_renderAllGeometryDepth(){const e=this._needsDepth;if(0===e)return;const{width:t,height:s}=this._framebuffer.size,i=this.fboCache.acquire(t,s,"geometry depth",14);this._rctx.bindFramebuffer(i.fbo),this._rctx.clear(1280),this.renderAllGeometry(3),this._bindParameters.depth=i.obtainDepthTexture(),this._bindParameters.depth?.retain(e-1),i.release(),this.performanceInfo.advance(me.DEPTH)}get _needsShadowDepthRange(){return this._bindParameters.shadowMap.enabled||this._shadowAccumulator.active}_computeShadowDepthRange(e){if(!this._needsShadowDepthRange)return J.Zero;const t=X(e,this._plugins.plugins,this.stage.layers,0);return t.union(this._plugins.queryDepthRange(e)),this._bindParameters.shadowMap.enabled&&t.union(this._nodes.queryDepthRange(O.SHADOWMAP,e)),t.near=Math.max(e.near,t.near),t.far=Math.min(e.far,t.far),t}updateSceneDepthRange(e){if(!this.stage.view.state.isGlobal)return void(this.sceneDepthRange.value=J.Infinite);if((this.stage.view.renderCoordsHelper?.getAltitude(e.eye)??0)<j)return void(this.sceneDepthRange.value=J.Infinite);const t=e.clone();t.near=N,t.far=1e10;const s=X(t,this._plugins.plugins,this.stage.layers,1);s.union(this._plugins.queryDepthRange(t)),this.sceneDepthRange.value.equals(s)||(this.sceneDepthRange.value=s)}get _normalsRequired(){return this._nodes.require("normals",...S,O.VIEWSHED,O.LASERLINES)+(this.hasAmbientIllumination?1:0)}_precompilePrepasses(){this._normalsRequired?(this._precompilePlugins(4,Ie),this._needsDepth&&this._precompilePlugins(3,Ae)):this._needsDepth&&this._precompileAllGeometry(3),this.shadowsEnabled&&(this._needsShadowHighlight?(this._nodes.precompile(this._bindParameters.hasEmission,O.SHADOW_HIGHLIGHT),this._precompileShadowCascades(6),this._precompileShadowCascades(7)):this._precompileShadowCascades(5),this._nodes.precompile(!1,O.SHADOWMAP)),this._shadowAccumulator.active&&(this._shadowAccumulator.precompilePrepass(),this._precompileAllGeometry(5)),this.hasAmbientIllumination&&this._normalsRequired&&this._nodes.precompile(this._bindParameters.hasEmission,O.AMBIENT_ILLUMINATION)}_renderNormals(){const e=this._normalsRequired;if(0===e)return;const{width:t,height:s}=this._framebuffer.size,i=this.fboCache.acquire(t,s,"normals");i.acquireDepth(14),this._rctx.bindFramebuffer(i.fbo),this._rctx.clearFramebuffer(C,!0,!0),this._bindParameters.output=4,this._plugins.render(...Ie);const r=this._nodes.optional("normals",...S,O.VIEWSHED);return i.retain(e+r-1),this.performanceInfo.advance(me.NORMALS),i}_renderSSAO(){this._bindParameters.globalIlluminationEnabled=!1;const e=this._pluginInput.get("normals");return this.hasAmbientIllumination&&e?(this._bindParameters.ssao=this._nodes.produce(O.AMBIENT_ILLUMINATION,this._pluginInput),this._bindParameters.ssao&&this.performanceInfo.advance(me.AMBIENT_ILLUMINATION),this._bindParameters.ssao):null}_renderGlobalIllumination(){const e=this._bindParameters;if(!this.hasGlobalIllumination)return this._releaseGlobalIlluminationBuffers(),e.globalIlluminationEnabled=this._keepGlobalIlluminationShadingAlive,null;const t=this._nodes.produce(O.AMBIENT_ILLUMINATION,this._pluginInput);return this._releaseGlobalIlluminationBuffers(),this._bindParameters.globalIllumination=t,this._bindParameters.globalIlluminationEnabled=!0,this.performanceInfo.advance(this.hasGlobalIlluminationHighQuality?me.AMBIENT_ILLUMINATION_HIGH_QUALITY:me.AMBIENT_ILLUMINATION),e.globalIllumination}_releaseGlobalIlluminationBuffers(){const e=this._bindParameters;e.reprojection.lastFrameColor=h(e.reprojection.lastFrameColor),e.reprojection.lastFrameDepth=n(e.reprojection.lastFrameDepth),e.reprojection.lastFrameEmission=n(e.reprojection.lastFrameEmission),e.globalIllumination=h(e.globalIllumination),e.globalIlluminationEnabled=!1}_precompileAllGeometry(e){const t=this._bindParameters.output;this._bindParameters.output=e,this._precompileOpaqueGeometry(),this._precompileTransparentGeometry(),this._plugins.precompile(...Ee),this._bindParameters.output=t}renderAllGeometry(e){this._bindParameters.output=e,this._renderOpaqueAndTransparentGeometry(e),this._renderTransparentGround()}precompileSlots(e,...t){for(const s of t)this._bindParameters.slot=s,e.precompile(this._renderContext)}precompileOccludedSlots(e,t){for(const s of t)this._renderContext.renderOccludedMask=s,this.precompileSlots(e,...Ce);this._renderContext.renderOccludedMask=te}renderSlots(e,...t){for(const s of t)this._bindParameters.slot=s,e.forAll(e=>{const t=e.acquireTechniques(this._renderContext);t&&e.render(this._renderContext,t)})}renderOccludedSlots(e,t){this._renderContext.renderOccludedMask=t,this.plugins.renderOccludedFlags>1&&this._plugins.render(9),this.renderSlots(e,...Ce),this._renderContext.renderOccludedMask=te}renderHUD(e){this._bindParameters.hudRenderStyle=e,this._plugins.render(...Se[e])}_renderHUDElements(e){this._bindParameters.hudRenderStyle=e,this._plugins.render(16),this.renderHUD(e),this._bindParameters.hudRenderStyle=e,this._plugins.render(14)}precompileViewshedShadowMap(){this._precompileAllGeometry(8)}precompileCutFillDepth(){this._precompilePlugins(9,De)}_precompilePlugins(e,t){const s=this._bindParameters.output;this._bindParameters.output=e,this._plugins.precompile(...t),this._bindParameters.output=s}renderViewshedShadowMap(e){const{camera:t,contentCamera:s}=this._bindParameters,i=this._bindParameters.output;e.setGLViewport(this._rctx),this._ensureBindParametersCamera(e,e),this.renderAllGeometry(8),this._ensureBindParametersCamera(t,s),this._bindParameters.camera.setGLViewport(this._rctx),this._bindParameters.output=i}renderCutFillDepth(e){const{camera:t,contentCamera:s}=this._bindParameters,i=this._bindParameters.output;e.setGLViewport(this._rctx),this._ensureBindParametersCamera(e,e),this._bindParameters.output=9,this._plugins.render(...De),this._ensureBindParametersCamera(t,s),t.setGLViewport(this._rctx),this._bindParameters.output=i}get _needsGroundDepth(){return this._bindParameters.cutFillVisualizationEnabled}_blitGroundDepth(){if(!this._needsGroundDepth)return null;const{width:e,height:t}=this._framebuffer.size,s=this.fboCache.acquire(e,t,O.GROUND_DEPTH,14);return this._rctx.blitFramebuffer(this._framebuffer.color.fbo,s.fbo,256),this._framebuffer.bind(),s}_renderOpaqueAndTransparentGeometry(e){this._bindParameters.output=e,this._renderOpaqueGeometry(),this._renderTransparentGeometry()}_renderGeometryWithoutNormals(e){this._bindParameters.output=e,this._plugins.render(...Ae)}_precompileOpaqueGeometry(){this._needsOpaquePass&&(this._plugins.precompile(...Pe),this._nodes.precompile(this._bindParameters.hasEmission,"opaque-color"))}_renderOpaqueGeometry(){this._plugins.render(...Pe)}_renderTransparentGeometry(){this._plugins.render(...we),this._hasTransparentGeometry&&this._plugins.render(15)}_renderTransparentGround(){this._plugins.render(...Ee)}_precompileHUD(e){if(!this._pluginsHas.hudElements)return;const t=this._bindParameters.output,s=this._bindParameters.hudRenderStyle,i=this._bindParameters.emissions;this._bindParameters.emissions=0,this._bindParameters.hudRenderStyle=e,this._bindParameters.output=1,this._plugins.precompile(...Te),this._bindParameters.output=2,this._plugins.precompile(...Te),this._bindParameters.output=0,this._oitBlend.precompile(this._bindParameters,!1,1),this._hasHighlights&&(this._bindParameters.output=10,this._plugins.precompile(...Te)),this._bindParameters.emissions=i,this._bindParameters.output=t,this._bindParameters.hudRenderStyle=s}_renderHUD(e,t){if(!this._pluginsHas.hudElements)return t;const s=this._renderOIT(1,e);this._rctx.bindFramebuffer(t.fbo);const i=!!t.getTexture(ue);return this._compositor.compositePreMultipliedAlpha(this._bindParameters,s.getTexture(),i),s.release(),this.performanceInfo.advance(0===e?me.HUD_OCCLUDED:me.HUD),t}get _needsShadowHighlight(){return this.shadowsEnabled&&this._plugins.produces(6,2)}_renderHighlightPrepass(){if(!this._hasHighlights)return;const{fboCache:e,_rctx:t,_bindParameters:s}=this,{width:i,height:r}=this._framebuffer.size,{highlights:a}=s,n=a.length>B?3:1,h=e.acquire(i,r,"highlights",n);h.acquireDepth(14);const o=this._plugins.produces(10,0);return o&&this._framebuffer.color.fbo&&h.fbo&&t.blitFramebuffer(this._framebuffer.color.fbo,h.fbo,1024),t.bindFramebuffer(h.fbo),t.gl.clearBufferuiv(6144,0,[0,0,0,0]),o||t.clear(1024),this._bindParameters.output=10,t.bindFramebuffer(h.fbo),V(t,e,i,r,s,()=>this._renderHighlightGeometries()),h.detachDepth(),this.performanceInfo.advance(me.HIGHLIGHTS),h.retain(this._nodes.require("highlights",...D)+this._nodes.optional("highlights",...D)-1),h}_renderHighlightGeometries(){this._plugins.render(...Re),this._rctx.clear(256),this._renderHUDElements(2)}_renderShadowAccumulation(e){this._shadowAccumulator.updateDepthRange(e);const t=this._shadowAccumulator.requiresDepth;this._bindParameters.output=0,this._shadowAccumulator.renderAccumulation(this._bindParameters)&&this.performanceInfo.advance(me.ACCUMULATED_SHADOWS),this._shadowAccumulator.updateMask(),t&&(this._bindParameters.depth=h(this._bindParameters.depth))}_precompileTransparentGeometry(){y(this._bindParameters.output)?(this._bindParameters.output=1,this._plugins.precompile(...we),this._hasTransparentGeometry&&this._plugins.precompile(15),this._bindParameters.output=2,this._plugins.precompile(...we),this._hasTransparentGeometry&&this._plugins.precompile(15),this._bindParameters.output=0):this._plugins.precompile(...we)}_renderOIT(e,t=2){const s=1===e,{width:i,height:r}=this._framebuffer.size,a=s?()=>this._renderHUDElements(t):()=>this._renderTransparentGeometry(),h=this._bindParameters,o=h.useFloatBlend.value?8:5,d=h.output;h.output=1;const l=s?"oit hud":"oit",m=this.fboCache.acquire(i,r,l,o).acquireColor(ue,this.hasFloatBlend?7:0,"oit alpha"),u=h.hasEmission&&(0===e||1!==t);u&&m.acquireColor(pe,o,"oit emissive"),s||m.attachDepth(this._framebuffer.depth),this._rctx.bindFramebuffer(m.fbo),this._rctx.clearFramebuffer(Z),u&&this._rctx.clearBuffer(2,Z),a(),m.detachDepth(),h.output=2;const _=this.fboCache.acquire(i,r,s?"oit front hud":"oit front");u&&_.acquireColor(ue,o,"oit front emissive"),s?_.acquireDepth(this._hudDepthFormat):_.attachDepth(this._framebuffer.depth),this._rctx.bindFramebuffer(_.fbo),this._rctx.clearFramebuffer(C,s),a(),_.detachDepth();const p=this._pluginsHas.occludedHudElements&&!s,c=p&&0!==h.emissions?pe:ue;let b;return h.hudOcclusion=n(this._bindParameters.hudOcclusion),h.output=0,s?(b=this.fboCache.acquire(i,r,"oit composite hud"),this._rctx.bindFramebuffer(b.fbo),this._rctx.setClearColor(0,0,0,1e-13),this._rctx.clear(16384)):(0!==h.emissions&&this._framebuffer.ensureEmissionAttachment(),p&&(this._framebuffer.color.acquireColor(c,0,"hud occlusion"),this._rctx.clearBuffer(c-ce,C)),this._framebuffer.bind()),this._oitBlend.blend(this._rctx,m,_,h,p,e,this._fboCache.debugCallback),b?.detachDepth(),s||(u&&(this._bindParameters.emissions=3),p&&(h.hudOcclusion=this._framebuffer.color.obtainAttachment(c))),_.release(),m.release(),h.output=d,b}get _hudDepthFormat(){return this.isFeatureEnabled(7)?14:13}get _needsOpaquePass(){return this.plugins.produces(0,...Pe)||this.plugins.produces(5,...Pe)||this.plugins.produces(3,3)}_renderOpaque(){const e=this._needsOpaquePass;e&&(this._plugins.render(0,1),this._pluginInput.set(O.GROUND_DEPTH,this._blitGroundDepth()),this._plugins.render(2,3));const t=this._framebuffer;t.update(t=>this._renderNodes(R.OPAQUE,t,e)),this.fboCache.debugCallback?.(R.OPAQUE,t.color.fbo),t.update(e=>this._renderNodes(O.OPAQUE_ENVIRONMENT,e)),this.fboCache.debugCallback?.(O.OPAQUE_ENVIRONMENT,t.color.fbo),this._renderEdges(1)}_renderPreTransparent(){this._framebuffer.update(e=>this._renderNodes(O.GAUSSIAN_SPLAT,e)),this.fboCache.debugCallback?.(O.GAUSSIAN_SPLAT,this._framebuffer.color.fbo),this._framebuffer.update(e=>this._renderNodes(O.OPAQUE_OCCLUSION_QUERY,e)),this.fboCache.debugCallback?.(O.OPAQUE_OCCLUSION_QUERY,this._framebuffer.color.fbo),this._framebuffer.update(e=>this._renderNodes(O.VOXEL,e)),this.fboCache.debugCallback?.(O.VOXEL,this._framebuffer.color.fbo)}_renderTransparent(){const e=this._framebuffer;if(this._renderHiddenTransparentEdges(),this._hasTransparentGeometry&&this._renderOIT(0),e.update(e=>this._renderNodes(R.TRANSPARENT,e,this._hasTransparentGeometry)),this.fboCache.debugCallback?.(R.TRANSPARENT,e.color.fbo),this._hasTransparentGeometry||this._plugins.render(15),this._renderEdges(0),this._bindParameters.ssao=n(this._bindParameters.ssao),e.update(e=>this._renderNodes(O.TRANSPARENT_NO_DEPTH,e)),this.fboCache.debugCallback?.(O.TRANSPARENT_NO_DEPTH,e.color.fbo),this._framebuffer.bind(),this._plugins.render(8),this._bindParameters.hasEmission){const e=this._rctx.setDrawBuffers([be,ue]);this._bindParameters.transparentWithoutDepthEmissionDimmingPass=!0,this._plugins.render(8),this._bindParameters.transparentWithoutDepthEmissionDimmingPass=!1,this._rctx.setDrawBuffers(e)}this.performanceInfo.advance(me.TRANSPARENT_MATERIAL_WITHOUT_DEPTH)}_renderNodes(e,t,s=!1){if(t.setName(e),this._pluginInput.set(e,t),!this._nodes.produces(e))return s&&this.performanceInfo.advance(e),t;const i=this._nodes.render(t,this._pluginInput,this._releaseNodeInputs);return this.performanceInfo.advance(e),this._fboCache.debugCallback?.(e,i.fbo),i}_ensureBindParameters(e,t){this._ensureBindParametersCamera(e,t),this._ensureBindParametersWeatherFader(),this._ensureBindParametersScreenSpaceReflections(),this._ensureBindParametersReprojection()}_ensureBindParametersCamera(e,t){this._bindParameters.camera=e,this._bindParameters.contentCamera=t}_ensureBindParametersWeatherFader(){1===this.stage.viewingMode&&(this._bindParameters.clouds.data&&(this._bindParameters.clouds.fade(this._bindParameters.camera,this.renderContext.time,this.stage.view.qualitySettings.fadeDuration,this.stage.view.state.stationary),this.weatherFader?.cleanupCubemap()),this._bindParameters.snowCover=this.weatherFader?.snowCover??0)}_ensureBindParametersScreenSpaceReflections(){const{time:e}=this.renderContext,{screenSpaceReflections:t}=this._bindParameters;if(this.hasReflections){null==this._ssrEnableTime&&(this._ssrEnableTime=e);const s=this.stage.view.qualitySettings.fadeDuration;t.fadeFactor=s>0?Math.min(s,e-this._ssrEnableTime)/s:1,t.fadeFactor<1&&this._requestRender()}else this._ssrEnableTime=null}_ensureBindParametersReprojection(){if(!(this.hasReflections||this.hasGlobalIllumination))return void(this._reprojectionMatrix=w);const{reprojection:e,camera:t}=this._bindParameters,{lastFrameCamera:s}=e,i=!s.equals(t);if(i?(f(Ge,t.viewMatrix),f(Fe,t.projectionMatrix),g(He,Ge,Fe),g(He,s.viewMatrix,He),g(He,s.projectionMatrix,He),this._reprojectionMatrix=He):this._reprojectionMatrix=w,this.hasGlobalIllumination){const{viewMatrix:t}=e;i?(g(xe,s.viewMatrix,Ge),P(t,xe)):P(t,w)}}addRenderNode(e){this._nodes.add(e),this._requestRender()}removeRenderNode(e){this._nodes.remove(e),this._requestRender()}updateLighting(e,t,s,i){this._bindParameters.updateLighting(e,t,s,i),this._requestRender(1)}get usedMemory(){return{fbos:this.fboCache.usedMemory,plugins:this._plugins.usedMemory,edges:this.edgeView?.usedMemory??0,clouds:this.weatherFader?.usedMemory??0}}get test(){}};e([p()],ge.prototype,"_inGlobeView",void 0),e([p({readOnly:!0})],ge.prototype,"highResolutionAtmosphere",null),e([p()],ge.prototype,"_edgeView",void 0),e([p()],ge.prototype,"updating",null),ge=e([c("esri.views.3d.webgl-engine.lib.Renderer")],ge);const Pe=[0,1,2,3],we=[7,6,4,5],Ee=[7,6],Ie=[0,1,2,4,...Ee],Ae=[3,5],Ce=[2,4,8],Te=[16,12,14,13],Re=[4,5,2,3,0,1,...Ee],Oe=[4,8,5,11],Se={0:[13],1:[12],2:[13,12],3:[13,12]},De=[0,1,...Ee],Ne=["normals","highlights"],Fe=E(),Ge=E(),He=E(),xe=E();function ye(e){return t=>e.immediate.schedule(t)}export{ge as Renderer};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{__decorate as o}from"tslib";import{parameter as r,ShaderTechniqueConfiguration as e}from"../core/shaderTechnique/ShaderTechniqueConfiguration.js";class t extends e{constructor(){super(...arguments),this.reductionPass=0}}o([r({count:3})],t.prototype,"reductionPass",void 0);export{t as CutFillReductionTechniqueConfiguration};
2
+ import{__decorate as o}from"tslib";import{parameter as r,ShaderTechniqueConfiguration as s}from"../core/shaderTechnique/ShaderTechniqueConfiguration.js";class e extends s{constructor(){super(...arguments),this.pass=0}}o([r({count:2})],e.prototype,"pass",void 0);export{e as CutFillReductionTechniqueConfiguration};
@@ -1365,10 +1365,32 @@ export default class SceneView extends SceneViewSuperclass {
1365
1365
  */
1366
1366
  goTo(target: GoToTarget3D, options?: GoToOptions3D): Promise<void>;
1367
1367
  /**
1368
- * Returns [hit test results](https://developers.arcgis.com/javascript/latest/references/core/views/types/#SceneViewHitTestResult) from each layer that intersects the specified screen coordinates.
1368
+ * Returns [hit test results](https://developers.arcgis.com/javascript/latest/references/core/views/types/#SceneViewHitTestResult) from each layer that intersects the specified hit target.
1369
1369
  * The results are organized as an array of objects containing different [result types](https://developers.arcgis.com/javascript/latest/references/core/views/types/#SceneViewHit).
1370
1370
  *
1371
- * The following layer types will return all [features](https://developers.arcgis.com/javascript/latest/references/core/views/types/#SceneViewGraphicHit) if a hit is made on intersecting features:
1371
+ * The type of `hitTarget` determines which results are returned:
1372
+ * - A [ScreenPoint](https://developers.arcgis.com/javascript/latest/references/core/core/types/#ScreenPoint) or native mouse event tests a single screen location. It returns
1373
+ * [results](https://developers.arcgis.com/javascript/latest/references/core/views/types/#SceneViewHit): [graphic](https://developers.arcgis.com/javascript/latest/references/core/views/types/#SceneViewGraphicHit),
1374
+ * [media](https://developers.arcgis.com/javascript/latest/references/core/views/types/#SceneViewMediaHit), [route](https://developers.arcgis.com/javascript/latest/references/core/views/types/#SceneViewRouteHit), or
1375
+ * [layer](https://developers.arcgis.com/javascript/latest/references/core/views/types/#SceneViewLayerHit). The layer-specific results are:
1376
+ * - [MediaLayer](https://developers.arcgis.com/javascript/latest/references/core/layers/MediaLayer/) returns a [media result](https://developers.arcgis.com/javascript/latest/references/core/views/types/#SceneViewMediaHit) for each intersecting media element.
1377
+ * - [RouteLayer](https://developers.arcgis.com/javascript/latest/references/core/layers/RouteLayer/) returns a [route result](https://developers.arcgis.com/javascript/latest/references/core/views/types/#SceneViewRouteHit) for each intersecting route element.
1378
+ * - [GaussianSplatLayer](https://developers.arcgis.com/javascript/latest/references/core/layers/GaussianSplatLayer/) returns a [layer result](https://developers.arcgis.com/javascript/latest/references/core/views/types/#SceneViewLayerHit) with the intersected layer,
1379
+ * hit location, and hit distance.
1380
+ * - [VoxelLayer](https://developers.arcgis.com/javascript/latest/references/core/layers/VoxelLayer/) returns a [graphic result](https://developers.arcgis.com/javascript/latest/references/core/views/types/#SceneViewGraphicHit) with information about the intersecting voxel.
1381
+ *
1382
+ * The `ground` property contains the map location where the screen point intersects the ground and its distance from
1383
+ * the camera. By default, graphics behind an opaque ground surface are not returned. To control whether the ground
1384
+ * prevents graphics below it from being returned, add [Map.ground](https://developers.arcgis.com/javascript/latest/references/core/Map/#ground) to the `include` or `exclude` property of
1385
+ * the `hitTest()` `options` parameter.
1386
+ * - A [ScreenRect](https://developers.arcgis.com/javascript/latest/references/core/core/types/#ScreenRect) or [ScreenPolygon](https://developers.arcgis.com/javascript/latest/references/core/core/types/#ScreenPolygon) defines an area of the screen. For the supported
1387
+ * feature-like layers listed below, it returns a [graphic result](https://developers.arcgis.com/javascript/latest/references/core/views/types/#SceneViewGraphicHit) for each
1388
+ * feature that intersects the area. An area does not identify a
1389
+ * single map or ground location. Therefore, `mapPoint` is `null` on each result, `ground.mapPoint` is `null`, and
1390
+ * `ground.distance` is `0`.
1391
+ *
1392
+ * The following layer types support both single-location and area-based hit targets and return
1393
+ * [graphic results](https://developers.arcgis.com/javascript/latest/references/core/views/types/#SceneViewGraphicHit) for features that intersect the hit target:
1372
1394
  * [GraphicsLayer](https://developers.arcgis.com/javascript/latest/references/core/layers/GraphicsLayer/),
1373
1395
  * [FeatureLayer](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/),
1374
1396
  * [SceneLayer](https://developers.arcgis.com/javascript/latest/references/core/layers/SceneLayer/),
@@ -1379,16 +1401,6 @@ export default class SceneView extends SceneViewSuperclass {
1379
1401
  * [GeoJSONLayer](https://developers.arcgis.com/javascript/latest/references/core/layers/GeoJSONLayer/),
1380
1402
  * [OGCFeatureLayer](https://developers.arcgis.com/javascript/latest/references/core/layers/OGCFeatureLayer/), and [graphics](https://developers.arcgis.com/javascript/latest/references/core/views/SceneView/#graphics).
1381
1403
  *
1382
- * The [MediaLayer](https://developers.arcgis.com/javascript/latest/references/core/layers/MediaLayer/) hit test [result](https://developers.arcgis.com/javascript/latest/references/core/views/types/#SceneViewMediaHit) contains all media elements if the hit is made on intersecting elements.
1383
- * The [RouteLayer](https://developers.arcgis.com/javascript/latest/references/core/layers/RouteLayer/) hit test [result](https://developers.arcgis.com/javascript/latest/references/core/views/types/#SceneViewRouteHit) contains all route elements if the hit is made on intersecting elements.
1384
- * The [GaussianSplatLayer](https://developers.arcgis.com/javascript/latest/references/core/layers/GaussianSplatLayer/) hit test [result](https://developers.arcgis.com/javascript/latest/references/core/views/types/#SceneViewLayerHit) returns the intersected layer,
1385
- * hit location, and hit distance.
1386
- * The [VoxelLayer](https://developers.arcgis.com/javascript/latest/references/core/layers/VoxelLayer/) hit test [result](https://developers.arcgis.com/javascript/latest/references/core/views/types/#SceneViewGraphicHit) contains information about the intersecting voxel if a hit is made.
1387
- *
1388
- * If no options are specified, graphics that are behind the ground surface will not be returned unless the ground surface is
1389
- * semi-transparent. Otherwise, using the [Map.ground](https://developers.arcgis.com/javascript/latest/references/core/Map/#ground) in the include and exclude options determines
1390
- * whether the ground surface prevents hit testing graphics that are under it.
1391
- *
1392
1404
  * Release-specific changes:
1393
1405
  * * At version 4.24, [SceneViewHitTestResult](https://developers.arcgis.com/javascript/latest/references/core/views/types/#SceneViewHitTestResult) returns an array of objects containing [graphic](https://developers.arcgis.com/javascript/latest/references/core/views/types/#SceneViewGraphicHit),
1394
1406
  * [media element](https://developers.arcgis.com/javascript/latest/references/core/views/types/#SceneViewMediaHit), and [route](https://developers.arcgis.com/javascript/latest/references/core/views/types/#SceneViewRouteHit).
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import t from"../../analysis/LineOfSightAnalysis.js";import s from"../../analysis/LineOfSightAnalysisObserver.js";import o from"../../analysis/LineOfSightAnalysisTarget.js";import i from"../../core/Accessor.js";import n from"../../core/Collection.js";import{referenceSetter as r,castForReferenceSetter as a}from"../../core/collectionUtils.js";import{deprecateUnnecessaryViewModel as l}from"../../core/deprecate.js";import{handlesGroup as c}from"../../core/handleUtils.js";import"../../core/has.js";import g from"../../core/Logger.js";import{watch as h,syncAndInitial as d,sync as p}from"../../core/reactiveUtils.js";import{property as m,subclass as y}from"../../core/accessorSupport/decorators.js";import v from"../../geometry/Point.js";import{getEffectiveElevationInfo as T,getConvertedElevation as u,absoluteHeightElevationInfo as f}from"../../support/elevationInfoUtils.js";import w from"./LineOfSightTarget.js";import{AnalysisViewModelMixin as A}from"../support/AnalysisViewModelMixin.js";const _=n.ofType(w);let M=class extends(A(i)){constructor(e){super(e),this.analysis=null,this.supportedViewType="3d",this.unsupportedErrorMessage="LineOfSightViewModel is only supported in 3D views.",this._vmTargetsToConnection=new Map,this._analysisTargetsToConnection=new Map,e?.suppressDeprecationWarning||l(g.getLogger(this),"Line Of Sight","arcgis-line-of-sight",{version:"4.33"})}initialize(){this.addHandles([this.targets.on("after-add",e=>this._onViewModelTargetAdded(e.item)),this.targets.on("after-remove",e=>this._onViewModelTargetRemoved(e.item)),h(()=>this.analysis,e=>this._onAnalysisChange(e),d)])}destroy(){this._analysisTargetsToConnection.forEach(e=>e.remove())}get state(){return this.disabled||!this.ready?"disabled":null==this.tool?"ready":this.tool.state}get observer(){const{observer:e}=this.analysis;return null==e?.position?null:this._convertAnalysisPointToAbsoluteHeight(e.position,e.elevationInfo)}set observer(e){let t=null;e&&(t=e.clone(),t.hasZ||(t.z=0)),this.analysis.observer=new s({position:t})}get targets(){return this._get("targets")||new _}set targets(e){this._set("targets",r(e,this.targets,_))}continue(){null!=this.tool&&this.tool.continue()}stop(){null!=this.tool&&this.tool.stop()}get testInfo(){}constructAnalysis(){return new t}async onConnectToAnalysisView(e){this.addHandles([e.on("result-changed",e=>{const t=this._analysisTargetsToConnection.get(e.target);t&&(null!=e.result?(t.viewModelTarget.intersectedGraphic=e.result.intersectedGraphic,t.viewModelTarget.intersectedLocation=e.result.intersectedLocation,t.viewModelTarget.visible=e.result.visible):(t.viewModelTarget.intersectedGraphic=null,t.viewModelTarget.intersectedLocation=null,t.viewModelTarget.visible=void 0))})],"view")}onDisconnectFromAnalysisView(){this.removeHandles("view")}_onViewModelTargetAdded(e){if(this._vmTargetsToConnection.get(e))return;const t=new o({position:e.location});this._connectViewModelWithAnalysisTarget(e,t),this.analysis.targets.add(t)}_onViewModelTargetRemoved(e){const t=this._vmTargetsToConnection.get(e);t&&(t.remove(),this.analysis.targets.remove(t.analysisTarget))}_onAnalysisTargetAdded(e){if(this._analysisTargetsToConnection.get(e))return;const{position:t}=e,s=new w({location:t?this._convertAnalysisPointToAbsoluteHeight(t,e.elevationInfo):null});this._connectViewModelWithAnalysisTarget(s,e),this.targets.add(s)}_onAnalysisTargetRemoved(e){const t=this._analysisTargetsToConnection.get(e);t&&(t.remove(),this.targets.remove(t.viewModelTarget))}_connectViewModelWithAnalysisTarget(e,t){let s=!1;const o=c([h(()=>({position:t.position,elevationInfo:t.elevationInfo}),({position:t,elevationInfo:o})=>{s||(s=!0,e.location=t?this._convertAnalysisPointToAbsoluteHeight(t,o):null,s=!1)},p),h(()=>e.location,e=>{if(!s){s=!0;let o=null;e&&(o=e.clone(),o.hasZ||(o.z=0)),t.position=o,t.elevationInfo=null,s=!1}},p)]),i={analysisTarget:t,viewModelTarget:e,remove:()=>{o.remove(),this._vmTargetsToConnection.delete(e),this._analysisTargetsToConnection.delete(t)}};this._vmTargetsToConnection.set(e,i),this._analysisTargetsToConnection.set(t,i)}_onAnalysisChange(e){const t="analysis";this.removeHandles(t),this.addHandles([this.analysis.targets.on("after-add",e=>this._onAnalysisTargetAdded(e.item)),this.analysis.targets.on("after-remove",e=>this._onAnalysisTargetRemoved(e.item))],t),this.targets.removeAll(),e.targets.forEach(e=>{this._onAnalysisTargetAdded(e)})}_convertAnalysisPointToAbsoluteHeight(e,t){const s=e.clone();if(null!=this.view){const o=T(e.hasZ,t);s.z=u(this.view,e,o,f)}return s}};e([m({type:t})],M.prototype,"analysis",void 0),e([m({readOnly:!0})],M.prototype,"state",null),e([m({type:v})],M.prototype,"observer",null),e([m({type:_,cast:a,nonNullable:!0})],M.prototype,"targets",null),M=e([y("esri.widgets.LineOfSight.LineOfSightViewModel")],M);const b=M;export{b as default};
2
+ import{__decorate as e}from"tslib";import t from"../../analysis/LineOfSightAnalysis.js";import s from"../../analysis/LineOfSightAnalysisObserver.js";import o from"../../analysis/LineOfSightAnalysisTarget.js";import i from"../../core/Accessor.js";import n from"../../core/Collection.js";import{referenceSetter as r,castForReferenceSetter as a}from"../../core/collectionUtils.js";import{deprecateUnnecessaryViewModel as l}from"../../core/deprecate.js";import{handlesGroup as c}from"../../core/handleUtils.js";import"../../core/has.js";import g from"../../core/Logger.js";import{ignoreAbortErrors as h}from"../../core/promiseUtils.js";import{watch as d,syncAndInitial as p,sync as m}from"../../core/reactiveUtils.js";import{property as v,subclass as y}from"../../core/accessorSupport/decorators.js";import T from"../../geometry/Point.js";import{getEffectiveElevationInfo as u,getConvertedElevation as f,absoluteHeightElevationInfo as w}from"../../support/elevationInfoUtils.js";import A from"./LineOfSightTarget.js";import{AnalysisViewModelMixin as _}from"../support/AnalysisViewModelMixin.js";const M=n.ofType(A);let b=class extends(_(i)){constructor(e){super(e),this.analysis=null,this.supportedViewType="3d",this.unsupportedErrorMessage="LineOfSightViewModel is only supported in 3D views.",this._vmTargetsToConnection=new Map,this._analysisTargetsToConnection=new Map,e?.suppressDeprecationWarning||l(g.getLogger(this),"Line Of Sight","arcgis-line-of-sight",{version:"4.33"})}initialize(){this.addHandles([this.targets.on("after-add",e=>this._onViewModelTargetAdded(e.item)),this.targets.on("after-remove",e=>this._onViewModelTargetRemoved(e.item)),d(()=>this.analysis,e=>this._onAnalysisChange(e),p)])}destroy(){this._analysisTargetsToConnection.forEach(e=>e.remove())}get state(){return this.disabled||!this.ready?"disabled":null==this.tool?"ready":this.tool.state}get observer(){const{observer:e}=this.analysis;return null==e?.position?null:this._convertAnalysisPointToAbsoluteHeight(e.position,e.elevationInfo)}set observer(e){let t=null;e&&(t=e.clone(),t.hasZ||(t.z=0)),this.analysis.observer=new s({position:t})}get targets(){return this._get("targets")||new M}set targets(e){this._set("targets",r(e,this.targets,M))}continue(){null!=this.tool&&this.tool.continue()}stop(){null!=this.tool&&this.tool.stop()}get testInfo(){}constructAnalysis(){return new t}_startInteractiveCreation(e){const t=new AbortController;return h(e.place({signal:t.signal})),()=>t.abort()}async onConnectToAnalysisView(e){this.addHandles([e.on("result-changed",e=>{const t=this._analysisTargetsToConnection.get(e.target);t&&(null!=e.result?(t.viewModelTarget.intersectedGraphic=e.result.intersectedGraphic,t.viewModelTarget.intersectedLocation=e.result.intersectedLocation,t.viewModelTarget.visible=e.result.visible):(t.viewModelTarget.intersectedGraphic=null,t.viewModelTarget.intersectedLocation=null,t.viewModelTarget.visible=void 0))})],"view")}onDisconnectFromAnalysisView(){this.removeHandles("view")}_onViewModelTargetAdded(e){if(this._vmTargetsToConnection.get(e))return;const t=new o({position:e.location});this._connectViewModelWithAnalysisTarget(e,t),this.analysis.targets.add(t)}_onViewModelTargetRemoved(e){const t=this._vmTargetsToConnection.get(e);t&&(t.remove(),this.analysis.targets.remove(t.analysisTarget))}_onAnalysisTargetAdded(e){if(this._analysisTargetsToConnection.get(e))return;const{position:t}=e,s=new A({location:t?this._convertAnalysisPointToAbsoluteHeight(t,e.elevationInfo):null});this._connectViewModelWithAnalysisTarget(s,e),this.targets.add(s)}_onAnalysisTargetRemoved(e){const t=this._analysisTargetsToConnection.get(e);t&&(t.remove(),this.targets.remove(t.viewModelTarget))}_connectViewModelWithAnalysisTarget(e,t){let s=!1;const o=c([d(()=>({position:t.position,elevationInfo:t.elevationInfo}),({position:t,elevationInfo:o})=>{s||(s=!0,e.location=t?this._convertAnalysisPointToAbsoluteHeight(t,o):null,s=!1)},m),d(()=>e.location,e=>{if(!s){s=!0;let o=null;e&&(o=e.clone(),o.hasZ||(o.z=0)),t.position=o,t.elevationInfo=null,s=!1}},m)]),i={analysisTarget:t,viewModelTarget:e,remove:()=>{o.remove(),this._vmTargetsToConnection.delete(e),this._analysisTargetsToConnection.delete(t)}};this._vmTargetsToConnection.set(e,i),this._analysisTargetsToConnection.set(t,i)}_onAnalysisChange(e){const t="analysis";this.removeHandles(t),this.addHandles([this.analysis.targets.on("after-add",e=>this._onAnalysisTargetAdded(e.item)),this.analysis.targets.on("after-remove",e=>this._onAnalysisTargetRemoved(e.item))],t),this.targets.removeAll(),e.targets.forEach(e=>{this._onAnalysisTargetAdded(e)})}_convertAnalysisPointToAbsoluteHeight(e,t){const s=e.clone();if(null!=this.view){const o=u(e.hasZ,t);s.z=f(this.view,e,o,w)}return s}};e([v({type:t})],b.prototype,"analysis",void 0),e([v({readOnly:!0})],b.prototype,"state",null),e([v({type:T})],b.prototype,"observer",null),e([v({type:M,cast:a,nonNullable:!0})],b.prototype,"targets",null),b=e([y("esri.widgets.LineOfSight.LineOfSightViewModel")],b);const C=b;export{C as default};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{__decorate as s}from"tslib";import{createTask as t}from"../../core/asyncUtils.js";import"../../core/has.js";import i from"../../core/Logger.js";import{abortMaybe as e,removeMaybe as n}from"../../core/maybe.js";import{throwIfAborted as a,isAbortError as r,isAborted as l}from"../../core/promiseUtils.js";import{when as o,syncAndInitial as h,watch as c,sync as y,on as w,whenOnce as u}from"../../core/reactiveUtils.js";import{property as p,subclass as v}from"../../core/accessorSupport/decorators.js";const d=d=>{const V=d;let g=class extends V{constructor(s={}){super(s),this.view=null,this.analysisView=null,this._reconnectViewTask=null,this._forceInteractiveHandle=null,this._changeFromReconnect=!1,this._startUserOperation=null;const t=s?.analysis;null!=t?this.analysis=t:(this._set("analysis",this.constructAnalysis()),this._set("isAnalysisOwner",!0)),null!=s?.visible&&(this.visible=s.visible)}normalizeCtorArgs(s){const{analysis:t,suppressDeprecationWarning:i,...e}=s;return e}initialize(){const s=()=>{this._changeFromReconnect||this._viewHasAnalysis||this._set("isAnalysisOwner",!1);const s=!this._changeFromReconnect;this._changeFromReconnect=!1,s&&this._scheduleViewReconnect()};this.addHandles([o(()=>null!=this.view&&this.view.ready&&!this.supported,()=>i.getLogger(this).errorOnce(this.unsupportedErrorMessage),h),c(()=>[this.analysis,this._viewHasAnalysis],s,y),w(()=>this.view,"analysis-view-destroy",t=>{t.analysis===this.analysis&&s()}),c(()=>({view:this.view,ready:null!=this.view&&this.view.ready,supported:this.supported}),({view:s},t)=>{const i=t?.view;s!==i&&(this._startUserOperation=e(this._startUserOperation),this._disconnectFromView(i)),this._scheduleViewReconnect()},h)])}destroy(){this._reconnectViewTask=e(this._reconnectViewTask),this._startUserOperation=e(this._startUserOperation),null!=this.analysisView&&(this.analysisView.visible=void 0),this._disconnectFromView(this.view),this._set("view",null),null!=this.analysis&&this.isAnalysisOwner&&(this.analysis.destroy(),this._set("analysis",null))}get supported(){return null==this.view||this.view.type===this.supportedViewType}set visible(s){this._set("visible",s),null!=this.analysisView&&(this.analysisView.visible=s)}get active(){return null!=this.tool&&this.tool.active}get disabled(){return null==this.view||!this.view.ready||!this.supported}set analysis(s){s!==this._get("analysis")&&(this._startUserOperation=e(this._startUserOperation),this._disconnectFromView(this.view),this._setExternalAnalysis(s),this._scheduleViewReconnect())}get ready(){return null!=this.analysisView&&!this.connectingToView}get connectingToView(){return null!=this._reconnectViewTask}get isAnalysisOwner(){return this._get("isAnalysisOwner")}get _viewHasAnalysis(){const{view:s}=this;return null!=s&&s.analyses.includes(this.analysis)}get tool(){return this.analysisView?.tool}clear(){this._startUserOperation=e(this._startUserOperation),this._resetInteractiveCreationState(),null!=this.tool&&null!=this.view&&this.view.activeTool===this.tool&&(this.view.activeTool=null)}async start(){if(!this.visible)return void i.getLogger(this).warn("Cannot start analysis when not visible");this.clear();const s={task:null,abort:null,state:0},e=t(async t=>{if(s.state=1,await u(()=>this.ready,t),s.state=2,null==this.analysisView||null==this.view)return;const i=this.analysisView.tool;null!=i&&(this.view.activeTool=i,o(()=>i.created,()=>{i.active&&null!=this.view&&(this.view.activeTool=null)},{initial:!0,once:!0}))});return s.task=e,s.abort=()=>e.abort(),this._startUserOperation=s,e.promise}onConnectToAnalysisView(s){}onDisconnectFromAnalysisView(){}_scheduleViewReconnect(){this._reconnectViewTask=e(this._reconnectViewTask);const s=t(async t=>{try{await this._reconnectView(t)}catch(e){if(a(t),!r(e))return void i.getLogger(this).warn("Failed to use analysis in view model",e);throw e}finally{s===this._reconnectViewTask&&(this._reconnectViewTask=null)}});this._reconnectViewTask=s}async _reconnectView(s){const{view:t}=this,i=null!=t&&t.ready&&this.supported,e=this.analysis;this._startUserOperation=_(this._startUserOperation),this._disconnectFromView(t),i&&null!=t&&null!=e&&(this.isAnalysisOwner&&(this._changeFromReconnect=!0,t.analyses.add(e)),this.analysisView=await t.whenAnalysisView(e),l(s)?this._startUserOperation=_(this._startUserOperation):(this.analysisView.visible=this.visible,this._forceInteractiveHandle=this.analysisView.forceInteractive(),this.addHandles(this._forceInteractiveHandle),this.onConnectToAnalysisView(this.analysisView)))}_disconnectFromView(s){null!=s&&this.isAnalysisOwner&&s.analyses.includes(this.analysis)&&(this._changeFromReconnect=!0,this.analysis.clear(),s.analyses.remove(this.analysis)),this.onDisconnectFromAnalysisView(),this._forceInteractiveHandle=n(this._forceInteractiveHandle),this.analysisView=null}_setExternalAnalysis(s){null==this.analysisView||this.isAnalysisOwner||(this.analysisView.visible=void 0,this._forceInteractiveHandle=n(this._forceInteractiveHandle)),this.analysisView=null,this._set("isAnalysisOwner",!1),this._set("analysis",s),this._changeFromReconnect=!1}_resetInteractiveCreationState(){this.analysis.clear(),this.tool?.resetCreated()}get testInfo(){}};return s([p()],g.prototype,"supported",null),s([p()],g.prototype,"view",void 0),s([p({type:Boolean,value:!0})],g.prototype,"visible",null),s([p()],g.prototype,"active",null),s([p()],g.prototype,"disabled",null),s([p({nonNullable:!0})],g.prototype,"analysis",null),s([p()],g.prototype,"analysisView",void 0),s([p()],g.prototype,"ready",null),s([p()],g.prototype,"connectingToView",null),s([p({readOnly:!0})],g.prototype,"isAnalysisOwner",null),s([p()],g.prototype,"_viewHasAnalysis",null),s([p()],g.prototype,"_reconnectViewTask",void 0),s([p()],g.prototype,"_forceInteractiveHandle",void 0),s([p()],g.prototype,"tool",null),g=s([v("esri.widgets.support.AnalysisViewModelMixin")],g),g};function _(s){return null!=s&&s.state>=2?(s.abort(),null):s}export{d as AnalysisViewModelMixin};
2
+ import{__decorate as s}from"tslib";import{createTask as t}from"../../core/asyncUtils.js";import"../../core/has.js";import i from"../../core/Logger.js";import{abortMaybe as e,removeMaybe as n}from"../../core/maybe.js";import{throwIfAborted as a,isAbortError as r,isAborted as l}from"../../core/promiseUtils.js";import{when as o,syncAndInitial as c,watch as h,sync as y,on as w,whenOnce as u}from"../../core/reactiveUtils.js";import{property as p,subclass as v}from"../../core/accessorSupport/decorators.js";const _=_=>{const V=_;let g=class extends V{constructor(s={}){super(s),this.view=null,this.analysisView=null,this._reconnectViewTask=null,this._forceInteractiveHandle=null,this._changeFromReconnect=!1,this._startUserOperation=null;const t=s?.analysis;null!=t?this.analysis=t:(this._set("analysis",this.constructAnalysis()),this._set("isAnalysisOwner",!0)),null!=s?.visible&&(this.visible=s.visible)}normalizeCtorArgs(s){const{analysis:t,suppressDeprecationWarning:i,...e}=s;return e}initialize(){const s=()=>{this._changeFromReconnect||this._viewHasAnalysis||this._set("isAnalysisOwner",!1);const s=!this._changeFromReconnect;this._changeFromReconnect=!1,s&&this._scheduleViewReconnect()};this.addHandles([o(()=>null!=this.view&&this.view.ready&&!this.supported,()=>i.getLogger(this).errorOnce(this.unsupportedErrorMessage),c),h(()=>[this.analysis,this._viewHasAnalysis],s,y),w(()=>this.view,"analysis-view-destroy",t=>{t.analysis===this.analysis&&s()}),h(()=>({view:this.view,ready:null!=this.view&&this.view.ready,supported:this.supported}),({view:s},t)=>{const i=t?.view;s!==i&&(this._startUserOperation=e(this._startUserOperation),this._disconnectFromView(i)),this._scheduleViewReconnect()},c)])}destroy(){this._reconnectViewTask=e(this._reconnectViewTask),this._startUserOperation=e(this._startUserOperation),null!=this.analysisView&&(this.analysisView.visible=void 0),this._disconnectFromView(this.view),this._set("view",null),null!=this.analysis&&this.isAnalysisOwner&&(this.analysis.destroy(),this._set("analysis",null))}get supported(){return null==this.view||this.view.type===this.supportedViewType}set visible(s){this._set("visible",s),null!=this.analysisView&&(this.analysisView.visible=s)}get active(){return null!=this.tool&&this.tool.active}get disabled(){return null==this.view||!this.view.ready||!this.supported}set analysis(s){s!==this._get("analysis")&&(this._startUserOperation=e(this._startUserOperation),this._disconnectFromView(this.view),this._setExternalAnalysis(s),this._scheduleViewReconnect())}get ready(){return null!=this.analysisView&&!this.connectingToView}get connectingToView(){return null!=this._reconnectViewTask}get isAnalysisOwner(){return this._get("isAnalysisOwner")}get _viewHasAnalysis(){const{view:s}=this;return null!=s&&s.analyses.includes(this.analysis)}get tool(){return this.analysisView?.tool}clear(){this._startUserOperation=e(this._startUserOperation),this._resetInteractiveCreationState(),null!=this.tool&&null!=this.view&&this.tool.active&&(this.view.activeTool=null)}async start(){if(!this.visible)return void i.getLogger(this).warn("Cannot start analysis when not visible");this.clear();const s={task:null,abort:null,state:0},e=t(async t=>{if(s.state=1,await u(()=>this.ready,t),s.state=2,null==this.analysisView||null==this.view)return;if(null==this.analysisView.tool)return;const i=this._startInteractiveCreation(this.analysisView);if(null!=i){const t=s.abort;s.abort=()=>{i(),t()}}});return s.task=e,s.abort=()=>e.abort(),this._startUserOperation=s,e.promise}onConnectToAnalysisView(s){}onDisconnectFromAnalysisView(){}_startInteractiveCreation(s){const{tool:t}=s;null!=t&&(s.view.activeTool=t,o(()=>t.created,()=>{t.active&&(s.view.activeTool=null)},{initial:!0,once:!0}))}_scheduleViewReconnect(){this._reconnectViewTask=e(this._reconnectViewTask);const s=t(async t=>{try{await this._reconnectView(t)}catch(e){if(a(t),!r(e))return void i.getLogger(this).warn("Failed to use analysis in view model",e);throw e}finally{s===this._reconnectViewTask&&(this._reconnectViewTask=null)}});this._reconnectViewTask=s}async _reconnectView(s){const{view:t}=this,i=null!=t&&t.ready&&this.supported,e=this.analysis;this._startUserOperation=d(this._startUserOperation),this._disconnectFromView(t),i&&null!=t&&null!=e&&(this.isAnalysisOwner&&(this._changeFromReconnect=!0,t.analyses.add(e)),this.analysisView=await t.whenAnalysisView(e),l(s)?this._startUserOperation=d(this._startUserOperation):(this.analysisView.visible=this.visible,this._forceInteractiveHandle=this.analysisView.forceInteractive(),this.addHandles(this._forceInteractiveHandle),this.onConnectToAnalysisView(this.analysisView)))}_disconnectFromView(s){null!=s&&this.isAnalysisOwner&&s.analyses.includes(this.analysis)&&(this._changeFromReconnect=!0,this.analysis.clear(),s.analyses.remove(this.analysis)),this.onDisconnectFromAnalysisView(),this._forceInteractiveHandle=n(this._forceInteractiveHandle),this.analysisView=null}_setExternalAnalysis(s){null==this.analysisView||this.isAnalysisOwner||(this.analysisView.visible=void 0,this._forceInteractiveHandle=n(this._forceInteractiveHandle)),this.analysisView=null,this._set("isAnalysisOwner",!1),this._set("analysis",s),this._changeFromReconnect=!1}_resetInteractiveCreationState(){this.analysis.clear(),this.tool?.resetCreated()}get testInfo(){}};return s([p()],g.prototype,"supported",null),s([p()],g.prototype,"view",void 0),s([p({type:Boolean,value:!0})],g.prototype,"visible",null),s([p()],g.prototype,"active",null),s([p()],g.prototype,"disabled",null),s([p({nonNullable:!0})],g.prototype,"analysis",null),s([p()],g.prototype,"analysisView",void 0),s([p()],g.prototype,"ready",null),s([p()],g.prototype,"connectingToView",null),s([p({readOnly:!0})],g.prototype,"isAnalysisOwner",null),s([p()],g.prototype,"_viewHasAnalysis",null),s([p()],g.prototype,"_reconnectViewTask",void 0),s([p()],g.prototype,"_forceInteractiveHandle",void 0),s([p()],g.prototype,"tool",null),g=s([v("esri.widgets.support.AnalysisViewModelMixin")],g),g};function d(s){return null!=s&&s.state>=2?(s.abort(),null):s}export{_ as AnalysisViewModelMixin};