@arcgis/core 4.28.0-rc.3 → 4.28.0

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 (62) hide show
  1. package/arcade/ArcadeDate.js +1 -1
  2. package/arcade/functions/featuresetbase.js +1 -1
  3. package/assets/esri/core/workers/RemoteClient.js +1 -1
  4. package/assets/esri/core/workers/chunks/1da721608993783dc9cf.js +1 -0
  5. package/assets/esri/core/workers/chunks/{78e2fa121760383b08ec.js → 3dcb2a82e1e4b520c9c9.js} +2 -2
  6. package/assets/esri/core/workers/chunks/{969a82b674eda9f8720f.js → 6bc1f6f8a2408fa4bb6a.js} +1 -1
  7. package/assets/esri/core/workers/chunks/78e49a70193e5adea17c.js +1 -0
  8. package/assets/esri/core/workers/chunks/830d99e6c58a52a58973.js +1 -0
  9. package/assets/esri/core/workers/chunks/8f7997e8e6ee9e56239f.js +1 -0
  10. package/assets/esri/core/workers/chunks/{a4341ec0fe89b865d849.js → a160576f21ada91995ac.js} +1 -1
  11. package/assets/esri/core/workers/chunks/b6bd31674076e543d8b2.js +1 -0
  12. package/assets/esri/core/workers/chunks/{562eafa5090827ebb7ec.js → c87e9280681c20d042b5.js} +1 -1
  13. package/assets/esri/core/workers/chunks/{2c560a075d9ef2069ed1.js → ed97761ac077a96aeb29.js} +1 -1
  14. package/assets/esri/themes/base/widgets/_BasemapGallery.scss +6 -4
  15. package/assets/esri/themes/base/widgets/_Features.scss +5 -0
  16. package/assets/esri/themes/base/widgets/_Popup.scss +0 -1
  17. package/assets/esri/themes/dark/main.css +1 -1
  18. package/assets/esri/themes/light/main.css +1 -1
  19. package/assets/esri/themes/light/view.css +1 -1
  20. package/interfaces.d.ts +252 -52
  21. package/intl/date.js +1 -1
  22. package/kernel.js +1 -1
  23. package/layers/FeatureLayer.js +1 -1
  24. package/layers/OrientedImageryLayer.js +1 -1
  25. package/layers/graphics/data/QueryEngineResult.js +1 -1
  26. package/layers/support/LayerContingentValuesCache.js +1 -1
  27. package/package.json +1 -1
  28. package/smartMapping/support/utils.js +1 -1
  29. package/statistics/utils.js +1 -1
  30. package/support/basemapUtils.js +1 -1
  31. package/support/revision.js +1 -1
  32. package/views/2d/engine/Container.js +1 -1
  33. package/views/3d/analysis/Slice/RotateManipulator.js +1 -1
  34. package/views/3d/analysis/Slice/ShiftManipulator.js +1 -1
  35. package/views/3d/interactive/measurementTools/areaMeasurement3D/AreaMeasurement3DView.js +1 -1
  36. package/views/3d/webgl-engine/core/FBOCache.js +1 -1
  37. package/views/3d/webgl-engine/core/FBOPool.js +1 -1
  38. package/views/3d/webgl-engine/core/shaderLibrary/shading/EvaluateSceneLighting.glsl.js +2 -2
  39. package/views/3d/webgl-engine/effects/highlight/Highlight.js +1 -1
  40. package/views/3d/webgl-engine/lib/Renderer.js +1 -1
  41. package/views/draw/DrawOperation.js +1 -1
  42. package/views/interactive/sketch/constraints.js +1 -1
  43. package/views/interactive/snapping/featureSources/FeatureCollectionSnappingSource.js +1 -1
  44. package/views/interactive/snapping/featureSources/FeatureServiceSnappingSource.js +1 -1
  45. package/views/interactive/snapping/featureSources/GraphicsSnappingSource.js +1 -1
  46. package/views/interactive/snapping/featureSources/queryEngineUtils.js +1 -1
  47. package/webdoc/support/writeUtils.js +1 -1
  48. package/widgets/Editor/EditorViewModel.js +1 -1
  49. package/widgets/Editor/UpdateRecordWorkflow.js +1 -1
  50. package/widgets/Editor/VisibleElements.js +1 -1
  51. package/widgets/Editor/workflowUtils.js +1 -1
  52. package/widgets/Editor.js +1 -1
  53. package/widgets/FeatureForm/FieldInput.js +1 -1
  54. package/widgets/FeatureForm/FormExpressionsManager.js +1 -1
  55. package/widgets/FeatureForm.js +1 -1
  56. package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.d.ts +4 -0
  57. package/widgets/support/dateUtils.js +1 -1
  58. package/assets/esri/core/workers/chunks/7648f3341b7dff2825c3.js +0 -1
  59. package/assets/esri/core/workers/chunks/9c77d69a13ec22cdd760.js +0 -1
  60. package/assets/esri/core/workers/chunks/a821fa1870b83fed5d31.js +0 -1
  61. package/assets/esri/core/workers/chunks/c416df0668f6c596095f.js +0 -1
  62. package/assets/esri/core/workers/chunks/f0d342303fc20e266d27.js +0 -1
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import{releaseMaybe as e}from"../../../../core/maybe.js";import{FBOPool as t}from"./FBOPool.js";import{PixelFormat as r,SizedPixelFormat as h,TextureWrapMode as s,PixelType as o,TextureSamplingMode as i,RenderbufferFormat as a,ColorAttachment as c}from"../../../webgl/enums.js";import{FramebufferObject as n}from"../../../webgl/FramebufferObject.js";import{Renderbuffer as _}from"../../../webgl/Renderbuffer.js";import{RenderbufferDescriptor as p}from"../../../webgl/RenderbufferDescriptor.js";import{Texture as d}from"../../../webgl/Texture.js";import{TextureDescriptor as l}from"../../../webgl/TextureDescriptor.js";class u{constructor(e){this.rctx=e,this._acquired=new Set,this._cache=new t(e.newCache,"FBOCache"),this._depthCache=new t(e.newCache,"DepthAttachmentCache"),this._colorCache=new t(e.newCache,"ColorAttachmentCache")}destroy(){this._cache.destroy(),this._depthCache.destroy(),this._colorCache.destroy()}tick(){this._cache.tick(),this._colorCache.tick(),this._depthCache.tick()}get usedMemory(){return Array.from(this._acquired.values()).reduce(((e,t)=>e+("colorTexture"in t?t.colorTexture?.gpuMemoryUsage??0:t.usedMemory)),this._cache.usedMemory+this._colorCache.usedMemory+this._depthCache.usedMemory)}set interactive(e){this._cache.interactive=this._colorCache.interactive=this._depthCache.interactive=e}acquire(e,t,r){const h=R(e,t,r),s=this._cache.pop(h)||new E(h,new n(this.rctx,{...b[e],width:t,height:r}),(e=>(s.releaseDepth(),s.depth=this._acquireDepth(e,s.fbo.width,s.fbo.height),s.fbo.attachDepthStencil(s.depth.attachment),s)),((e,h)=>{const o=this._acquireColor(e,t,r);return s.colors??=new Map,s.colors.set(h,o),s.fbo.attachColorTexture(o.attachment,h),s}));return s.release=()=>{this._acquired.delete(s),s.releaseDepth(),this._cache.put(s),s.release=()=>console.log(`Double FBO release in ${(new Error).stack}`)},this.rctx.unbindTexture(s.fbo.colorTexture),this._trackHandle(s)}acquireDepth(e,t,r){return this._acquireDepth(e,t,r)}_acquireDepth(e,t,r){const h=R(e,t,r),s=this._depthCache.pop(h);if(s)return this._trackHandle(s);const o=e===g.DEPTH_STENCIL_TEXTURE?new m(h,new d(this.rctx,{...G[e],width:t,height:r}),(()=>{this._acquired.delete(o),this._depthCache.put(o)})):new m(h,new _(this.rctx,{...G[e],width:t,height:r}),(()=>{this._acquired.delete(o),this._depthCache.put(o)}));return this._trackHandle(o)}_acquireColor(e,t,r){const h=R(e,t,r),s=this._colorCache.pop(h);if(s)return this._trackHandle(s);const o=new D(h,new d(this.rctx,{...b[e],width:t,height:r}),(()=>{this._acquired.delete(o),this._colorCache.put(o)}));return this._trackHandle(o)}_trackHandle(e){return this._acquired.add(e),e}}class E{constructor(e,t,r,h){this.key=e,this.fbo=t,this.acquireDepth=r,this.acquireColor=h,this.release=()=>{},this.incarnation=0}dispose(){this.fbo.dispose()}releaseDepth(){this.fbo.detachDepthStencilTexture(),this.fbo.detachDepthStencilBuffer(),this.depth=e(this.depth)}detachDepth(){const e=this.depth;return this.depth=void 0,this.fbo.detachDepthStencilTexture(),this.fbo.detachDepthStencilBuffer(),e}attachDepth(e){return this.releaseDepth(),e&&(this.fbo.attachDepthStencil(e.attachment),this.depth=e),this}releaseColor(t){this.fbo.detachColorTexture(t);const r=this.colors?.get(t);this.colors?.delete(t),e(r)}get colorTexture(){return this.fbo?.colorTexture}getColorTexture(e=c.COLOR_ATTACHMENT0){return this.fbo?.getColorTexture(e)}get usedMemory(){return this.fbo.gpuMemoryUsage}}class T{constructor(e,t,r){this.key=e,this.attachment=t,this.release=r,this.incarnation=0}dispose(){this.attachment.dispose()}get usedMemory(){return this.attachment.gpuMemoryUsage}}class m extends T{}class D extends T{constructor(e,t,r){super(e,t,r),this.attachment=t,this.release=r}}function R(e,t,r){return`${e}x${t}x${r}`}var C;!function(e){e[e.RED=0]="RED",e[e.RG=1]="RG",e[e.RGBA4=2]="RGBA4",e[e.RGBA=3]="RGBA",e[e.RGBA_MIPMAP=4]="RGBA_MIPMAP",e[e.R16F=5]="R16F",e[e.RGBA16F=6]="RGBA16F"}(C||(C={}));const w=new l;w.pixelFormat=r.RED,w.internalFormat=h.R8,w.wrapMode=s.CLAMP_TO_EDGE;const F=new l;F.pixelFormat=r.RG,F.internalFormat=h.RG8,F.wrapMode=s.CLAMP_TO_EDGE;const f=new l;f.internalFormat=h.RGBA4,f.dataType=o.UNSIGNED_SHORT_4_4_4_4,f.wrapMode=s.CLAMP_TO_EDGE;const A=new l;A.wrapMode=s.CLAMP_TO_EDGE;const M=new l;M.wrapMode=s.CLAMP_TO_EDGE,M.samplingMode=i.LINEAR_MIPMAP_LINEAR,M.hasMipmap=!0,M.maxAnisotropy=8;const P=new l;P.pixelFormat=r.RED,P.dataType=o.HALF_FLOAT,P.internalFormat=h.R16F,P.samplingMode=i.NEAREST;const x=new l;x.dataType=o.HALF_FLOAT,x.internalFormat=h.RGBA16F,x.samplingMode=i.NEAREST;const b={[C.RED]:w,[C.RG]:F,[C.RGBA4]:f,[C.RGBA]:A,[C.RGBA_MIPMAP]:M,[C.R16F]:P,[C.RGBA16F]:x};var g;!function(e){e[e.DEPTH_STENCIL_TEXTURE=0]="DEPTH_STENCIL_TEXTURE",e[e.DEPTH_STENCIL_BUFFER=1]="DEPTH_STENCIL_BUFFER",e[e.DEPTH24_BUFFER=2]="DEPTH24_BUFFER",e[e.DEPTH16_BUFFER=3]="DEPTH16_BUFFER"}(g||(g={}));const B=new l;B.pixelFormat=r.DEPTH_STENCIL,B.dataType=o.UNSIGNED_INT_24_8,B.samplingMode=i.NEAREST,B.wrapMode=s.CLAMP_TO_EDGE;const G={[g.DEPTH_STENCIL_TEXTURE]:B,[g.DEPTH_STENCIL_BUFFER]:new p(a.DEPTH24_STENCIL8,4),[g.DEPTH24_BUFFER]:new p(a.DEPTH_COMPONENT24,4),[g.DEPTH16_BUFFER]:new p(a.DEPTH_COMPONENT16,4)};export{C as ColorFormat,g as DepthFormat,u as FBOCache};
5
+ import{releaseMaybe as e}from"../../../../core/maybe.js";import{FBOPool as t}from"./FBOPool.js";import{PixelFormat as r,SizedPixelFormat as h,TextureWrapMode as s,PixelType as o,TextureSamplingMode as a,RenderbufferFormat as i,ColorAttachment as c}from"../../../webgl/enums.js";import{FramebufferObject as n}from"../../../webgl/FramebufferObject.js";import{Renderbuffer as _}from"../../../webgl/Renderbuffer.js";import{RenderbufferDescriptor as l}from"../../../webgl/RenderbufferDescriptor.js";import{Texture as p}from"../../../webgl/Texture.js";import{TextureDescriptor as d}from"../../../webgl/TextureDescriptor.js";class u{constructor(e){this.rctx=e,this._acquired=new Set,this._cache=new t(e.newCache,"FBOCache"),this._depthCache=new t(e.newCache,"DepthAttachmentCache"),this._colorCache=new t(e.newCache,"ColorAttachmentCache")}destroy(){this._cache.destroy(),this._depthCache.destroy(),this._colorCache.destroy()}clean(){this._cache.clean(),this._colorCache.clean(),this._depthCache.clean()}frame(){this._cache.frame(),this._colorCache.frame(),this._depthCache.frame()}get usedMemory(){return Array.from(this._acquired.values()).reduce(((e,t)=>e+("colorTexture"in t?t.colorTexture?.gpuMemoryUsage??0:t.usedMemory)),this._cache.usedMemory+this._colorCache.usedMemory+this._depthCache.usedMemory)}set interactive(e){this._cache.interactive=this._colorCache.interactive=this._depthCache.interactive=e}acquire(e,t,r){const h=D(e,t,r),s=this._cache.pop(h)||new E(h,new n(this.rctx,{...b[e],width:t,height:r}),(e=>(s.releaseDepth(),s.depth=this._acquireDepth(e,s.fbo.width,s.fbo.height),s.fbo.attachDepthStencil(s.depth.attachment),s)),((e,h)=>{const o=this._acquireColor(e,t,r);return s.colors??=new Map,s.colors.set(h,o),s.fbo.attachColorTexture(o.attachment,h),s}));return s.release=()=>{this._acquired.delete(s),s.releaseDepth(),this._cache.put(s),s.release=()=>console.log(`Double FBO release in ${(new Error).stack}`)},this.rctx.unbindTexture(s.fbo.colorTexture),this._trackHandle(s)}acquireDepth(e,t,r){return this._acquireDepth(e,t,r)}_acquireDepth(e,t,r){const h=D(e,t,r),s=this._depthCache.pop(h);if(s)return this._trackHandle(s);const o=e===g.DEPTH_STENCIL_TEXTURE?new m(h,new p(this.rctx,{...G[e],width:t,height:r}),(()=>{this._acquired.delete(o),this._depthCache.put(o)})):new m(h,new _(this.rctx,{...G[e],width:t,height:r}),(()=>{this._acquired.delete(o),this._depthCache.put(o)}));return this._trackHandle(o)}_acquireColor(e,t,r){const h=D(e,t,r),s=this._colorCache.pop(h);if(s)return this._trackHandle(s);const o=new C(h,new p(this.rctx,{...b[e],width:t,height:r}),(()=>{this._acquired.delete(o),this._colorCache.put(o)}));return this._trackHandle(o)}_trackHandle(e){return this._acquired.add(e),e}}class E{constructor(e,t,r,h){this.key=e,this.fbo=t,this.acquireDepth=r,this.acquireColor=h,this.release=()=>{},this.incarnation=0}dispose(){this.fbo.dispose()}releaseDepth(){this.fbo.detachDepthStencilTexture(),this.fbo.detachDepthStencilBuffer(),this.depth=e(this.depth)}detachDepth(){const e=this.depth;return this.depth=void 0,this.fbo.detachDepthStencilTexture(),this.fbo.detachDepthStencilBuffer(),e}attachDepth(e){return this.releaseDepth(),e&&(this.fbo.attachDepthStencil(e.attachment),this.depth=e),this}releaseColor(t){this.fbo.detachColorTexture(t);const r=this.colors?.get(t);this.colors?.delete(t),e(r)}get colorTexture(){return this.fbo?.colorTexture}getColorTexture(e=c.COLOR_ATTACHMENT0){return this.fbo?.getColorTexture(e)}get usedMemory(){return this.fbo.gpuMemoryUsage}}class T{constructor(e,t,r){this.key=e,this.attachment=t,this.release=r,this.incarnation=0}dispose(){this.attachment.dispose()}get usedMemory(){return this.attachment.gpuMemoryUsage}}class m extends T{}class C extends T{constructor(e,t,r){super(e,t,r),this.attachment=t,this.release=r}}function D(e,t,r){return`${e}x${t}x${r}`}var R;!function(e){e[e.RED=0]="RED",e[e.RG=1]="RG",e[e.RGBA4=2]="RGBA4",e[e.RGBA=3]="RGBA",e[e.RGBA_MIPMAP=4]="RGBA_MIPMAP",e[e.R16F=5]="R16F",e[e.RGBA16F=6]="RGBA16F"}(R||(R={}));const w=new d;w.pixelFormat=r.RED,w.internalFormat=h.R8,w.wrapMode=s.CLAMP_TO_EDGE;const f=new d;f.pixelFormat=r.RG,f.internalFormat=h.RG8,f.wrapMode=s.CLAMP_TO_EDGE;const F=new d;F.internalFormat=h.RGBA4,F.dataType=o.UNSIGNED_SHORT_4_4_4_4,F.wrapMode=s.CLAMP_TO_EDGE;const A=new d;A.wrapMode=s.CLAMP_TO_EDGE;const M=new d;M.wrapMode=s.CLAMP_TO_EDGE,M.samplingMode=a.LINEAR_MIPMAP_LINEAR,M.hasMipmap=!0,M.maxAnisotropy=8;const P=new d;P.pixelFormat=r.RED,P.dataType=o.HALF_FLOAT,P.internalFormat=h.R16F,P.samplingMode=a.NEAREST;const x=new d;x.dataType=o.HALF_FLOAT,x.internalFormat=h.RGBA16F,x.samplingMode=a.NEAREST;const b={[R.RED]:w,[R.RG]:f,[R.RGBA4]:F,[R.RGBA]:A,[R.RGBA_MIPMAP]:M,[R.R16F]:P,[R.RGBA16F]:x};var g;!function(e){e[e.DEPTH_STENCIL_TEXTURE=0]="DEPTH_STENCIL_TEXTURE",e[e.DEPTH_STENCIL_BUFFER=1]="DEPTH_STENCIL_BUFFER",e[e.DEPTH24_BUFFER=2]="DEPTH24_BUFFER",e[e.DEPTH16_BUFFER=3]="DEPTH16_BUFFER"}(g||(g={}));const B=new d;B.pixelFormat=r.DEPTH_STENCIL,B.dataType=o.UNSIGNED_INT_24_8,B.samplingMode=a.NEAREST,B.wrapMode=s.CLAMP_TO_EDGE;const G={[g.DEPTH_STENCIL_TEXTURE]:B,[g.DEPTH_STENCIL_BUFFER]:new l(i.DEPTH24_STENCIL8,4),[g.DEPTH24_BUFFER]:new l(i.DEPTH_COMPONENT24,4),[g.DEPTH16_BUFFER]:new l(i.DEPTH_COMPONENT16,4)};export{R as ColorFormat,g as DepthFormat,u as FBOCache};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import{MemCachePool as t}from"../../../../core/MemCachePool.js";import s from"../../../../core/PooledArray.js";class i{constructor(i,e){this._last=new s,this._incarnation=0,this._cache=new t(i,e)}destroy(){this._last?.forAll((t=>t.dispose())),this._last=null,this._cache.destroy()}set interactive(t){t&&!this._last?this._last=new s:t||(this._last?.forAll((t=>t.dispose())),this._last=null)}tick(){this._last?.filterInPlace((t=>!(t.incarnation<this._incarnation)||(this._cache.put(t.key,t),!1))),++this._incarnation}pop(t){if(this._last){const s=this._last.find((s=>s.key===t));if(s)return this._last.removeUnordered(s),s}return this._cache.pop(t)}put(t){t.incarnation=this._incarnation,this._last?this._last.push(t):this._cache.put(t.key,t)}get usedMemory(){return this._last?.reduce(((t,s)=>t+s.usedMemory),0)??0}}export{i as FBOPool};
5
+ import{MemCachePool as t}from"../../../../core/MemCachePool.js";import s from"../../../../core/PooledArray.js";class i{constructor(i,e){this._last=new s,this._incarnation=0,this._cache=new t(i,e)}destroy(){this._last?.forAll((t=>t.dispose())),this._last=null,this._cache.destroy()}set interactive(t){t&&!this._last?this._last=new s:t||(this._last?.forAll((t=>t.dispose())),this._last=null)}clean(){this._last?.filterInPlace((t=>!(t.incarnation<this._incarnation)||(this._cache.put(t.key,t),!1)))}frame(){++this._incarnation}pop(t){if(this._last){const s=this._last.find((s=>s.key===t));if(s)return this._last.removeUnordered(s),s}return this._cache.pop(t)}put(t){t.incarnation=this._incarnation,this._last?this._last.push(t):this._cache.put(t.key,t)}get usedMemory(){return this._last?.reduce(((t,s)=>t+s.usedMemory),0)??0}}export{i as FBOPool};
@@ -44,7 +44,7 @@ inputs.metalness = mrr[0];
44
44
  inputs.roughness = clamp(mrr[1] * mrr[1], 0.001, 0.99);`),v.code.add(m`inputs.f0 = (0.16 * mrr[2] * mrr[2]) * (1.0 - inputs.metalness) + inputs.albedoLinear * inputs.metalness;
45
45
  inputs.f90 = vec3(clamp(dot(inputs.f0, vec3(50.0 * 0.33)), 0.0, 1.0));
46
46
  inputs.diffuseColor = inputs.albedoLinear * (vec3(1.0) - inputs.f0) * (1.0 - inputs.metalness);`),p.useFillLights?v.uniforms.add(new d("hasFillLights",((i,n)=>n.enableFillLights))):v.constants.add("hasFillLights","bool",!1),v.code.add(m`vec3 ambientDir = vec3(5.0 * normalGround[1] - normalGround[0] * normalGround[2], - 5.0 * normalGround[0] - normalGround[2] * normalGround[1], normalGround[1] * normalGround[1] + normalGround[0] * normalGround[0]);
47
- ambientDir = ambientDir != vec3(0.0)? normalize(ambientDir) : normalize(vec3(5.0, -1.0, 0.0));
47
+ ambientDir = ambientDir != vec3(0.0) ? normalize(ambientDir) : normalize(vec3(5.0, -1.0, 0.0));
48
48
  inputs.NdotAmbDir = hasFillLights ? abs(dot(normal, ambientDir)) : 1.0;
49
49
  vec3 mainLightIrradianceComponent = inputs.NdotL * (1.0 - shadow) * mainLightIntensity;
50
50
  vec3 fillLightsIrradianceComponent = inputs.NdotAmbDir * mainLightIntensity * fillLightIntensity;
@@ -62,7 +62,7 @@ inputs.groundRadianceToSurface = 0.5 * GROUND_REFLECTANCE * (ambientLightRadianc
62
62
  inputs.averageAmbientRadiance = ambientLightIrradianceComponent[1] * (1.0 + GROUND_REFLECTANCE[1]);`),v.code.add(m`
63
63
  vec3 reflectedColorComponent = evaluateEnvironmentIllumination(inputs);
64
64
  vec3 additionalMaterialReflectanceComponent = inputs.albedoLinear * additionalAmbientIrradiance;
65
- vec3 emissionComponent = pow(_emission, vec3(GAMMA_SRGB));
65
+ vec3 emissionComponent = _emission == vec3(0.0) ? _emission : pow(_emission, vec3(GAMMA_SRGB));
66
66
  vec3 outColorLinear = reflectedColorComponent + additionalMaterialReflectanceComponent + emissionComponent;
67
67
  ${p.pbrMode!==l.Schematic||p.hasColorTexture?m`vec3 outColor = pow(blackLevelSoftCompression(outColorLinear, inputs), vec3(INV_GAMMA_SRGB));`:m`vec3 outColor = pow(max(vec3(0.0), outColorLinear - 0.005 * inputs.averageAmbientRadiance), vec3(INV_GAMMA_SRGB));`}
68
68
  return outColor;
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../../../chunks/tslib.es6.js";import{unitRGBAFromColor as t}from"../../../../../core/colorUtils.js";import{releaseMaybe as r,disposeMaybe as i}from"../../../../../core/maybe.js";import{watch as s,syncAndInitial as o}from"../../../../../core/reactiveUtils.js";import{property as a}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/accessorSupport/ensureType.js";import"../../../../../core/arrayUtils.js";import"../../../../../core/has.js";import{subclass as h}from"../../../../../core/accessorSupport/decorators/subclass.js";import{s as l}from"../../../../../chunks/vec2.js";import{ColorFormat as c}from"../../core/FBOCache.js";import{SyncRenderPlugin as n,ConsumesHighlight as p}from"../RenderPlugin.js";import{HighlightApplyTechnique as u}from"./HighlightApplyTechnique.js";import{HighlightBlurTechnique as m}from"./HighlightBlurTechnique.js";import{defaultColor as _,defaultHaloOpacity as d,defaultFillOpacity as g}from"./HighlightDefaults.js";import{HighlightDownsampleTechnique as b}from"./HighlightDownsampleTechnique.js";import{HighlightPassParameters as f}from"./HighlightPassParameters.js";import{Default3D as w}from"../../lib/DefaultVertexAttributeLocations.js";import{Pos2Tex as T}from"../../lib/DefaultVertexBufferLayouts.js";import{RenderSlot as q}from"../../lib/RenderSlot.js";import{VertexArrayObject as v}from"../../lib/VertexArrayObject.js";import{H as P}from"../../../../../chunks/HighlightBlur.glsl.js";import{H as x,g as y}from"../../../../../chunks/HighlightDownsample.glsl.js";import{BufferObject as j}from"../../../../webgl/BufferObject.js";import{ClearBufferBit as C,Usage as R}from"../../../../webgl/enums.js";import{vertexCount as O}from"../../../../webgl/Util.js";let D=class extends n{constructor(e){super(e),this._context=null,this._passParameters=new f,this._downsampleDrawParameters=new x,this._blurDrawParameters=new P,this._grid={coverage:null,vao:null,verticalCellCount:0,horizontalCellCount:0,viewportWidth:0,viewportHeight:0},this.produces=new Map([[q.HIGHLIGHT,()=>!0]])}consumes(){return p}initializeRenderContext(e){this._context=e,null==this._blurTechnique&&(this._blurTechnique=this._context.techniqueRepository.acquire(m)),null==this._downsampleTechnique&&(this._downsampleTechnique=this._context.techniqueRepository.acquire(b)),null==this._applyTechnique&&(this._applyTechnique=this._context.techniqueRepository.acquire(u)),this.addHandles([s((()=>this.view.highlightOptions.color),(e=>{this._passParameters.color=t(e??_),this.view.highlightOptions.haloColor||(this._passParameters.haloColor=this._passParameters.color),this._context.requestRender()}),o),s((()=>this.view.highlightOptions.haloColor),(e=>{this._passParameters.haloColor=null!=e?t(e):this._passParameters.color,this._context.requestRender()}),o),s((()=>this.view.highlightOptions.haloOpacity),(e=>{this._passParameters.haloOpacity=e??d,this._passParameters.haloOpacityOccluded=.25*this._passParameters.haloOpacity,this._context.requestRender()}),o),s((()=>this.view.highlightOptions.fillOpacity),(e=>{this._passParameters.fillOpacity=e??g,this._passParameters.fillOpacityOccluded=.25*this._passParameters.fillOpacity,this._context.requestRender()}),o)])}uninitializeRenderContext(){this._context=null}dispose(){this._blurTechnique=r(this._blurTechnique),this._downsampleTechnique=r(this._downsampleTechnique),this._applyTechnique=r(this._applyTechnique),this._grid.coverage=r(this._grid.coverage),this._grid.vao=i(this._grid.vao)}renderNode(e,t,r,i){const s=r?.highlight?.colorTexture;if(!this._context||!s)return;if(!(this._blurTechnique.compiled&&this._downsampleTechnique.compiled&&this._applyTechnique.compiled))return void this._context.requestRender();const o=e.bindParameters.camera,a=o.fullWidth,h=o.fullHeight,n=o.pixelRatio,p=Math.ceil(a/n),u=Math.ceil(h/n),m=this._context.fbos,_=m.rctx;this._gridUpdateResources(s),this._gridComputeCoverage(s,e.bindParameters),this._passParameters.highlightTexture=s,this._passParameters.coverageTexture=this._grid.coverage?.colorTexture;const{width:d,height:g}=s.descriptor;l(this._passParameters.coverageRounding,d/(Math.ceil(d/y)*y),g/(Math.ceil(g/y)*y));const b=_.bindTechnique(this._blurTechnique,this._passParameters,e.bindParameters),f=this._grid.vao;_.bindVAO(f);const w=m.acquire(c.RGBA4,p,u);_.bindFramebuffer(w.fbo),_.setViewport(0,0,p,u),_.setClearColor(0,0,0,0),_.clear(C.COLOR_BUFFER_BIT),this._blurDrawParameters.blurInputTexture=s,l(this._blurDrawParameters.blurSize,1/p,0),b.bindDraw(this._blurDrawParameters,e.bindParameters,this._passParameters),_.drawArrays(this._blurTechnique.primitiveType,0,O(f,"geometry"));const T=m.acquire(c.RGBA4,p,u);_.bindFramebuffer(T.fbo),_.clear(C.COLOR_BUFFER_BIT),this._blurDrawParameters.blurInputTexture=w.colorTexture,l(this._blurDrawParameters.blurSize,0,1/u),b.bindDraw(this._blurDrawParameters,e.bindParameters,this._passParameters),_.drawArrays(this._blurTechnique.primitiveType,0,O(f,"geometry")),_.bindFramebuffer(i?.fbo),_.setViewport4fv(o.fullViewport),this._passParameters.blurTexture=T.colorTexture,_.bindTechnique(this._applyTechnique,this._passParameters,e.bindParameters),_.drawArrays(this._applyTechnique.primitiveType,0,O(f,"geometry")),T.release(),w.release()}_gridUpdateResources(e){if(!this._context)return;const t=this._context.fbos.rctx,r=this._grid,i=Math.ceil(e.descriptor.height/y),s=Math.ceil(e.descriptor.width/y);if(r.vao&&r.verticalCellCount===i&&r.horizontalCellCount===s)return;r.verticalCellCount=i,r.horizontalCellCount=s;const o=i+1,a=s+1,h=1/i,l=1/s,c=new Float32Array(6*4*o*a);let n=0;for(let p=0;p<o;p++)for(let e=0;e<a;e++)c[n++]=(e-.5)*l*2-1,c[n++]=(p-.5)*h*2-1,c[n++]=e*l,c[n++]=p*h,c[n++]=(e+.5)*l*2-1,c[n++]=(p-.5)*h*2-1,c[n++]=e*l,c[n++]=p*h,c[n++]=(e-.5)*l*2-1,c[n++]=(p+.5)*h*2-1,c[n++]=e*l,c[n++]=p*h,c[n++]=(e-.5)*l*2-1,c[n++]=(p+.5)*h*2-1,c[n++]=e*l,c[n++]=p*h,c[n++]=(e+.5)*l*2-1,c[n++]=(p-.5)*h*2-1,c[n++]=e*l,c[n++]=p*h,c[n++]=(e+.5)*l*2-1,c[n++]=(p+.5)*h*2-1,c[n++]=e*l,c[n++]=p*h;r.vao?.dispose(),r.vao=new v(t,w,{geometry:T},{geometry:j.createVertex(t,R.STATIC_DRAW,c)})}_gridComputeCoverage(e,t){if(!this._context)return;const r=this._context.fbos.rctx,i=this._grid,s=e.descriptor,o=Math.ceil(s.width/y),a=Math.ceil(s.height/y);i.coverage?.release(),i.coverage=this._context.fbos.acquire(c.RG,o,a),this._downsampleDrawParameters.input=e,r.bindFramebuffer(i.coverage.fbo),r.bindTechnique(this._downsampleTechnique,this._passParameters,t).bindDraw(this._downsampleDrawParameters,t,this._passParameters),r.setViewport(0,0,o,a),r.screen.draw()}get test(){return{coverage:this._grid.coverage}}};e([a()],D.prototype,"_context",void 0),e([a()],D.prototype,"view",void 0),D=e([h("esri.views.3d.webgl-engine.effects.highlight.Highlight")],D);export{D as Highlight};
5
+ import{_ as e}from"../../../../../chunks/tslib.es6.js";import{unitRGBAFromColor as t}from"../../../../../core/colorUtils.js";import has from"../../../../../core/has.js";import{releaseMaybe as r,disposeMaybe as i}from"../../../../../core/maybe.js";import{watch as s,syncAndInitial as o}from"../../../../../core/reactiveUtils.js";import{property as a}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/accessorSupport/ensureType.js";import"../../../../../core/arrayUtils.js";import{subclass as h}from"../../../../../core/accessorSupport/decorators/subclass.js";import{s as l}from"../../../../../chunks/vec2.js";import{ColorFormat as c}from"../../core/FBOCache.js";import{SyncRenderPlugin as n,ConsumesHighlight as p}from"../RenderPlugin.js";import{HighlightApplyTechnique as u}from"./HighlightApplyTechnique.js";import{HighlightBlurTechnique as m}from"./HighlightBlurTechnique.js";import{defaultColor as _,defaultHaloOpacity as d,defaultFillOpacity as g}from"./HighlightDefaults.js";import{HighlightDownsampleTechnique as b}from"./HighlightDownsampleTechnique.js";import{HighlightPassParameters as f}from"./HighlightPassParameters.js";import{Default3D as w}from"../../lib/DefaultVertexAttributeLocations.js";import{Pos2Tex as T}from"../../lib/DefaultVertexBufferLayouts.js";import{RenderSlot as q}from"../../lib/RenderSlot.js";import{VertexArrayObject as v}from"../../lib/VertexArrayObject.js";import{H as P}from"../../../../../chunks/HighlightBlur.glsl.js";import{H as x,g as y}from"../../../../../chunks/HighlightDownsample.glsl.js";import{BufferObject as C}from"../../../../webgl/BufferObject.js";import{ClearBufferBit as j,Usage as R}from"../../../../webgl/enums.js";import{vertexCount as O}from"../../../../webgl/Util.js";let D=class extends n{constructor(e){super(e),this._context=null,this._passParameters=new f,this._downsampleDrawParameters=new x,this._blurDrawParameters=new P,this._blurColorFormat=has("mac")?c.RGBA:c.RGBA4,this._grid={coverage:null,vao:null,verticalCellCount:0,horizontalCellCount:0,viewportWidth:0,viewportHeight:0},this.produces=new Map([[q.HIGHLIGHT,()=>!0]])}consumes(){return p}initializeRenderContext(e){this._context=e,null==this._blurTechnique&&(this._blurTechnique=this._context.techniqueRepository.acquire(m)),null==this._downsampleTechnique&&(this._downsampleTechnique=this._context.techniqueRepository.acquire(b)),null==this._applyTechnique&&(this._applyTechnique=this._context.techniqueRepository.acquire(u)),this.addHandles([s((()=>this.view.highlightOptions.color),(e=>{this._passParameters.color=t(e??_),this.view.highlightOptions.haloColor||(this._passParameters.haloColor=this._passParameters.color),this._context.requestRender()}),o),s((()=>this.view.highlightOptions.haloColor),(e=>{this._passParameters.haloColor=null!=e?t(e):this._passParameters.color,this._context.requestRender()}),o),s((()=>this.view.highlightOptions.haloOpacity),(e=>{this._passParameters.haloOpacity=e??d,this._passParameters.haloOpacityOccluded=.25*this._passParameters.haloOpacity,this._context.requestRender()}),o),s((()=>this.view.highlightOptions.fillOpacity),(e=>{this._passParameters.fillOpacity=e??g,this._passParameters.fillOpacityOccluded=.25*this._passParameters.fillOpacity,this._context.requestRender()}),o)])}uninitializeRenderContext(){this._context=null}dispose(){this._blurTechnique=r(this._blurTechnique),this._downsampleTechnique=r(this._downsampleTechnique),this._applyTechnique=r(this._applyTechnique),this._grid.coverage=r(this._grid.coverage),this._grid.vao=i(this._grid.vao)}renderNode(e,t,r,i){const s=r?.highlight?.colorTexture;if(!this._context||!s)return;if(!(this._blurTechnique.compiled&&this._downsampleTechnique.compiled&&this._applyTechnique.compiled))return void this._context.requestRender();const o=e.bindParameters.camera,a=o.fullWidth,h=o.fullHeight,c=o.pixelRatio,n=Math.ceil(a/c),p=Math.ceil(h/c),u=this._context.fbos,m=u.rctx;this._gridUpdateResources(s),this._gridComputeCoverage(s,e.bindParameters),this._passParameters.highlightTexture=s,this._passParameters.coverageTexture=this._grid.coverage?.colorTexture;const{width:_,height:d}=s.descriptor;l(this._passParameters.coverageRounding,_/(Math.ceil(_/y)*y),d/(Math.ceil(d/y)*y));const g=m.bindTechnique(this._blurTechnique,this._passParameters,e.bindParameters),b=this._grid.vao;m.bindVAO(b);const f=u.acquire(this._blurColorFormat,n,p);m.bindFramebuffer(f.fbo),m.setViewport(0,0,n,p),m.clear(j.COLOR_BUFFER_BIT),this._blurDrawParameters.blurInputTexture=s,l(this._blurDrawParameters.blurSize,1/n,0),g.bindDraw(this._blurDrawParameters,e.bindParameters,this._passParameters),m.drawArrays(this._blurTechnique.primitiveType,0,O(b,"geometry"));const w=u.acquire(this._blurColorFormat,n,p);m.bindFramebuffer(w.fbo),m.clear(j.COLOR_BUFFER_BIT),this._blurDrawParameters.blurInputTexture=f.colorTexture,l(this._blurDrawParameters.blurSize,0,1/p),g.bindDraw(this._blurDrawParameters,e.bindParameters,this._passParameters),m.drawArrays(this._blurTechnique.primitiveType,0,O(b,"geometry")),m.bindFramebuffer(i?.fbo),m.setViewport4fv(o.fullViewport),this._passParameters.blurTexture=w.colorTexture,m.bindTechnique(this._applyTechnique,this._passParameters,e.bindParameters),m.drawArrays(this._applyTechnique.primitiveType,0,O(b,"geometry")),w.release(),f.release()}_gridUpdateResources(e){if(!this._context)return;const t=this._context.fbos.rctx,r=this._grid,i=Math.ceil(e.descriptor.height/y),s=Math.ceil(e.descriptor.width/y);if(r.vao&&r.verticalCellCount===i&&r.horizontalCellCount===s)return;r.verticalCellCount=i,r.horizontalCellCount=s;const o=i+1,a=s+1,h=1/i,l=1/s,c=new Float32Array(6*4*o*a);let n=0;for(let p=0;p<o;p++)for(let e=0;e<a;e++)c[n++]=(e-.5)*l*2-1,c[n++]=(p-.5)*h*2-1,c[n++]=e*l,c[n++]=p*h,c[n++]=(e+.5)*l*2-1,c[n++]=(p-.5)*h*2-1,c[n++]=e*l,c[n++]=p*h,c[n++]=(e-.5)*l*2-1,c[n++]=(p+.5)*h*2-1,c[n++]=e*l,c[n++]=p*h,c[n++]=(e-.5)*l*2-1,c[n++]=(p+.5)*h*2-1,c[n++]=e*l,c[n++]=p*h,c[n++]=(e+.5)*l*2-1,c[n++]=(p-.5)*h*2-1,c[n++]=e*l,c[n++]=p*h,c[n++]=(e+.5)*l*2-1,c[n++]=(p+.5)*h*2-1,c[n++]=e*l,c[n++]=p*h;r.vao?.dispose(),r.vao=new v(t,w,{geometry:T},{geometry:C.createVertex(t,R.STATIC_DRAW,c)})}_gridComputeCoverage(e,t){if(!this._context)return;const r=this._context.fbos.rctx,i=this._grid,s=e.descriptor,o=Math.ceil(s.width/y),a=Math.ceil(s.height/y);i.coverage?.release(),i.coverage=this._context.fbos.acquire(c.RG,o,a),this._downsampleDrawParameters.input=e,r.bindFramebuffer(i.coverage.fbo),r.bindTechnique(this._downsampleTechnique,this._passParameters,t).bindDraw(this._downsampleDrawParameters,t,this._passParameters),r.setViewport(0,0,o,a),r.screen.draw()}get test(){return{coverage:this._grid.coverage}}};e([a()],D.prototype,"_context",void 0),e([a()],D.prototype,"view",void 0),D=e([h("esri.views.3d.webgl-engine.effects.highlight.Highlight")],D);export{D as Highlight};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../../chunks/tslib.es6.js";import r from"../../../../core/Accessor.js";import{update as t}from"../../../../core/arrayUtils.js";import{unitRGBAFromColor as s}from"../../../../core/colorUtils.js";import has from"../../../../core/has.js";import{removeMaybe as i,destroyMaybe as a,releaseMaybe as n}from"../../../../core/maybe.js";import h from"../../../../core/PooledArray.js";import{watch as o,syncAndInitial as d,initial as l,sync as _}from"../../../../core/reactiveUtils.js";import{property as p}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/accessorSupport/ensureType.js";import{subclass as u}from"../../../../core/accessorSupport/decorators/subclass.js";import{a as c,i as m,m as f}from"../../../../chunks/mat4.js";import{I as g,a as T}from"../../../../chunks/mat4f64.js";import{s as A}from"../../../../chunks/vec4.js";import{f as P,Z as R}from"../../../../chunks/vec4f64.js";import{a as E}from"../../../../chunks/boundedPlane.js";import{debugFlags as b}from"../../support/debugFlags.js";import{TransparencyMode as S}from"../../terrain/TerrainRenderer.js";import{DepthFormat as I,FBOCache as y,ColorFormat as C}from"../core/FBOCache.js";import{RenderPassManager as w}from"../core/renderPasses/RenderPassManager.js";import{ShaderOutput as D}from"../core/shaderLibrary/ShaderOutput.js";import{HUDRenderStyle as O}from"../core/shaderLibrary/hud/HUDRenderStyle.js";import{RenderPluginInput as L}from"../effects/RenderPluginInput.js";import{RenderPluginManager as N}from"../effects/RenderPluginManager.js";import{Blit as M}from"../effects/blit/Blit.js";import{Highlight as H}from"../effects/highlight/Highlight.js";import{ShadowHighlight as F}from"../effects/highlight/ShadowHighlight.js";import{SMAA as x}from"../effects/smaa/SMAA.js";import{SSAO as v}from"../effects/ssao/SSAO.js";import{AnimationTimeStep as U}from"./AnimationTimeStep.js";import{Decorations as B,RenderRequestType as G,StencilBits as j}from"./basicInterfaces.js";import{BoundingInfo as q}from"./BoundingInfo.js";import{zero as V,union as Q}from"./depthRange.js";import{depthRangeFromScene as W}from"./depthRangeUtils.js";import{RenderOccludedFlag as k}from"./Material.js";import{OffscreenRendering as Y}from"./OffscreenRendering.js";import{RenderContext as X}from"./RenderContext.js";import{splitRenderGeometryChangeSetByMaterial as z}from"./rendererUtils.js";import{setupFeatureDefaults as J,RenderFeature as K}from"./RenderFeature.js";import{RenderSlot as Z}from"./RenderSlot.js";import{ShadowAccumulator as $}from"./ShadowAccumulator.js";import{ShadowMap as ee,SnapshotSlot as re}from"./ShadowMap.js";import te from"./SliceHelper.js";import{TransparencyPassType as se}from"./TransparencyPassType.js";import{EdgeView as ie}from"./edgeRendering/EdgeView.js";import{Transparency as ae}from"./edgeRendering/interfaces.js";import{MergedRenderer as ne}from"../materials/renderers/MergedRenderer.js";import{AlphaMode as he}from"../shaders/CompositingTechniqueConfiguration.js";import{RendererPerformanceInfo as oe,PerformanceCategory as de}from"../statistics/RendererPerformanceInfo.js";import{RenderState as le}from"../../../support/RenderState.js";import{PixelFormat as _e,PixelType as pe,ClearBufferBit as ue}from"../../../webgl/enums.js";let ce=class extends r{get _bindParameters(){return this._renderContext.bindParameters}updateRenderFeatures(e=null,r=!has("disable-feature:high-quality-idle")){this._renderStateFeatures=J(r,e),this.notifyChange("_renderStateFeatures"),this._renderPlugins.renderFeatureChanged(),this._requestRender()}isFeatureEnabled(e,r=this._state){return this._renderStateFeatures.get(r,e)??!1}setFeatureEnabled(e,r,t){this._renderStateFeatures.set(r,e,t),this.notifyChange("_renderStateFeatures"),this._requestRender()}get _highQualityTransparency(){return this._highQualityTransparencyEnabled||this.isFeatureEnabled(K.HighQualityTransparency)}get hasReflections(){return this.hasWater&&(this._ssrEnabled||this.isFeatureEnabled(K.WaterReflection))}get hasDecorations(){return this._materialRenderersHas.decorations||this._renderPlugins.hasDecorations}get hasHighlights(){return this._materialRenderersHas.highlights||this._renderPlugins.produces(Z.OPAQUE_MATERIAL,D.Highlight)||this._renderPlugins.produces(Z.DRAPED_MATERIAL,D.Highlight)}get hasShadowHighlights(){return this._materialRenderersHas.highlights||this._renderPlugins.produces(Z.OPAQUE_MATERIAL,D.ShadowHighlight)}get _magnifierEnabled(){return this._bindParameters.decorations===B.ON&&this._magnifierHelper.enabled}get fullResolutionAtmosphere(){return this._stage.view.qualitySettings.highResolutionAtmosphere||this.isFeatureEnabled(K.HighResolutionAtmosphere)}get hasWater(){return this._materialRenderersHas.water||this._hasOverlayWater}constructor(e,r,t,i,a,n,_,p){super({}),this._stage=e,this._techniqueRepository=i,this._rctx=a,this._compositingHelper=n,this._magnifierHelper=_,this._requestRender=p,this._materialRenderers=new h,this._needsTransparentPass=!1,this._materialRenderersHas={hudElements:!1,highlights:!1,water:!1,decorations:!1,occludees:!1},this._hasOverlayWater=!1,this.renderOverlay=e=>{},this._isRendering=!1,this._backgroundColor=P(0,0,0,1),this._sliceHelper=new te,this._state=le.IDLE,this._highQualityTransparencyEnabled=!0,this._terrainTransparency=S.Opaque,this._ssrEnabled=!1,this._hasAnimations=!1,this._animationTimestep=new U,this._renderHiddenTransparentEdges=()=>{},this._pluginInput=new L,this._releaseGeometryLinearDepth=e=>e?.release(),this._geometryLinearDepthFormat=I.DEPTH16_BUFFER,this.fboCache=new y(a),this._renderStateFeatures=J(!has("disable-feature:high-quality-idle"),e.view.qualityProfile),this._offscreen=new Y(this.fboCache,this._compositingHelper),this.performanceInfo=new oe(this._rctx),this._shadowMap=new ee(this.fboCache,e.viewingMode),this._highlight=new H({view:e.view}),this._shadowHighlight=new F({view:e.view,viewingMode:e.viewingMode}),this._shadowAccumulator=new $(this.fboCache,i,e,(e=>{const r=this.shadowsEnabled;this._shadowMap.enabled=!0,this._prepare(e.camera,e.contentCamera),this._renderPlugins.prepareRender(),this._shadowMap.enabled=r}),((e,r,t)=>{e.shadowMap.start(e.camera,r,t,!0,this._stage.view.qualitySettings.maximumPixelRatio),this._renderShadowCascades(D.Shadow,e.shadowMap),e.shadowMap.finish(),e.camera.setGLViewport(this._rctx),this._prepare(e.camera,e.contentCamera)}),p),this._ssao=new v({view:this._stage.view}),this._renderContext=new X(this._rctx,this._offscreen,this._shadowMap,this._sliceHelper),this._renderPlugins=new N({renderContext:this._renderContext,techniqueRepository:i,textureRepository:t,materialRepository:r,requestRender:p,controller:e,fbos:this.fboCache,isFeatureEnabled:e=>this.isFeatureEnabled(e)}),this.renderPassManager=new w,this._renderPlugins.add(this.renderPassManager),this._smaa=new x({view:this._stage.view}),this._renderPlugins.add(this._smaa),this._blit=new M({opacity:1,alphaMode:he.None}),this._renderPlugins.add(this._blit),this._renderPlugins.add(this._ssao),this._renderPlugins.add(this._highlight),this._renderPlugins.add(this._shadowHighlight),this.addHandles([o((()=>this._stage.view.state.camera),(()=>p()),d),o((()=>b.EDGES_SHOW_HIDDEN_TRANSPARENT_EDGES),(e=>{this._renderHiddenTransparentEdges=e?()=>this._renderEdges(ae.TRANSPARENT):()=>{},p()}),l),o((()=>this._stage.view.environment.background?.color),(e=>{const r=e?s(e):R;A(this._backgroundColor,r[0]*r[3],r[1]*r[3],r[2]*r[3],r[3]),p()}),d)])}normalizeCtorArgs(){return{}}destroy(){this._smaa.destroy(),this._blit.destroy(),this._gpuTimerHandle=i(this._gpuTimerHandle),this._materialRenderers.forAll((e=>e.dispose())),this._materialRenderers.clear(),this._offscreen.dispose(),this._shadowMap.dispose(),this._ssao.destroy(),this._highlight.dispose(),this._shadowHighlight.destroy(),this._shadowAccumulator.dispose(),this._edgeView=a(this._edgeView),this.renderPassManager.dispose(),this._releaseFBOs(),this._disposeOffscreenBuffers(),this.fboCache.destroy(),q.prune()}_releaseFBOs(){this._bindParameters.ssr.lastFrameColor=n(this._bindParameters.ssr.lastFrameColor),this._bindParameters.multipassTerrain.linearDepth=n(this._bindParameters.multipassTerrain.linearDepth),this._bindParameters.multipassGeometry.linearDepth=n(this._bindParameters.multipassGeometry.linearDepth)}_disposeOffscreenBuffers(){this._offscreen.dispose(),this._disposeBindBuffers()}_disposeBindBuffers(){this._shadowMap.disposeOffscreenBuffers(),this._bindParameters.linearDepth=n(this._bindParameters.linearDepth),this._bindParameters.hudVisibility=n(this._bindParameters.hudVisibility)}get updating(){return this._smaa.updating||null!=this._edgeView&&this._edgeView.updating||this._shadowAccumulator.running||this._renderPlugins.updating||!this.isCameraFinal}ensureEdgeView(){if(null==this._edgeView){const e=this._stage.view.resourceController;this._edgeView=new ie({rctx:this._rctx,renderSR:this._stage.view.renderSpatialReference,viewingMode:this._stage.viewingMode,techniqueRepository:this._techniqueRepository,setNeedsRender:()=>this._requestRender(),schedule:Ee(e)}),this.addHandles(o((()=>this._edgeView?.updating),(()=>this._requestRender()),_)),this._requestRender()}return this._edgeView}get edgeView(){return this._edgeView}get isCameraFinal(){return c(this._bindParameters.ssr.reprojectionMatrix,g)}set _reprojectionMatrix(e){t(this._bindParameters.ssr.reprojectionMatrix,e)&&this.notifyChange("isCameraFinal")}get shadowsEnabled(){return!!this._shadowMap?.enabled}setParameters(e){const{_shadowMap:r,_bindParameters:t}=this;if(void 0!==e.qualitySettings?.reflections&&this._ssrEnabled!==e.qualitySettings.reflections&&(this._ssrEnabled=e.qualitySettings.reflections,this._requestRender()),void 0!==e.shadowMap&&this._shadowMap.enabled!==e.shadowMap&&(this._shadowMap.enabled=e.shadowMap,this._requestRender()),void 0!==e.shadowMapMaxCascades&&r.maxCascades!==e.shadowMapMaxCascades&&(r.maxCascades=e.shadowMapMaxCascades,this._requestRender()),null!=e.environment){null!=e.environment.weather&&(this._bindParameters.weather=e.environment.weather,this._bindParameters.weatherVisible=!!e.weatherVisible);const r="virtual"!==e.environment.lighting.type;t.enableFillLights!==r&&(t.enableFillLights=r,this._requestRender())}void 0!==e.highQualityTransparency&&this._highQualityTransparencyEnabled!==e.highQualityTransparency&&(this._highQualityTransparencyEnabled=e.highQualityTransparency,this._requestRender()),void 0!==e.hasOverlayWater&&this._hasOverlayWater!==e.hasOverlayWater&&(this._hasOverlayWater=e.hasOverlayWater,this._requestRender()),void 0!==e.slicePlane&&this._sliceHelper.plane!==e.slicePlane&&(this._sliceHelper.plane=e.slicePlane,this._requestRender()),void 0!==e.terrainTransparency&&this._terrainTransparency!==e.terrainTransparency&&(this._terrainTransparency=e.terrainTransparency,this._requestRender()),void 0!==e.shadowCastOptions&&this._shadowAccumulator.setOptions(e.shadowCastOptions)}get hasSlicePlane(){return!!this._sliceHelper.plane}get renderPlugins(){return this._renderPlugins}get _hasOITSupport(){return this._rctx.driverTest.floatBufferBlend.result}get _oitEnabled(){return this._highQualityTransparency&&this._hasOITSupport}modify(e,r){this._isRendering&&console.warn("Renderer.modify called while rendering");const{adds:t,removes:s,updates:i}=e;if(0===t.length&&0===s.length&&0===i.length)return;const a=z(e);let n=!1;a.forEach(((t,s)=>{if(r.done)return;let i=this._materialRenderers.find((e=>e.material===s));if(null==i&&t.adds.length>0){const e=new ne({material:s});e.initializeRenderContext(this._renderPlugins._context),i=e,this._materialRenderers.push(i)}i&&(i.modify(t),i.isEmpty&&(n=!0)),t.removes.forEach((r=>e.removes.removeUnordered(r))),t.adds.forEach((r=>e.adds.removeUnordered(r))),t.updates.forEach((r=>e.updates.removeUnordered(r))),r.madeProgress()})),n&&this._materialRenderers.filterInPlace((e=>!e.isEmpty||(e.dispose(),!1))),this._updateHasFlags(),this._requestRender()}_updateHasFlags(){const has=this._materialRenderersHas;has.decorations=!1,has.highlights=!1,has.hudElements=!1,has.water=!1,has.occludees=!1,this._materialRenderers.forAll((e=>{has.highlights||=e.hasHighlights,has.occludees||=e.hasOccludees,has.water||=e.hasWater,has.decorations||=e.isDecoration,has.hudElements||=e.material.produces(Z.LINE_CALLOUTS_HUD_DEPTH,D.Color)||e.material.produces(Z.HUD_MATERIAL,D.Color)||e.material.produces(Z.LABEL_MATERIAL,D.Color)})),this._bindParameters.hasOccludees=has.occludees}updateAnimation(e){const r=this._hasAnimations;return this._hasAnimations=!1,this._materialRenderers.forAll((r=>this._hasAnimations=r.updateAnimation(e)||this._hasAnimations)),this._hasAnimations=this._renderPlugins.updateAnimation(e)||this._hasAnimations,this._hasAnimations!==r&&(this._gpuTimerHandle=r?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.tick()}render(e,r,t,s,i){const a=null!=e;this._isRendering=!0,this.performanceInfo.startFrame(),this._disposeBindBuffers();const h=this._offscreen,{camera:o,contentCamera:d,mode:l,alignPixelEnabled:_}=t;this._state=l,this._bindParameters.overlay=this.renderOverlay(i),this.performanceInfo.advance(de.OVERLAY),this._renderContext.time=i,this._bindParameters.transparencyPassType=se.NONE,this._bindParameters.alignPixelEnabled=_,this._bindParameters.decorations=s;const p=E(this._sliceHelper.plane);s===B.OFF&&(this._sliceHelper.plane=null),o.setGLViewport(this._rctx);const u=h.initializeFrame(o,this._backgroundColor,a);this.hasReflections?this._bindParameters.ssr.lastFrameColor=u:u?.release(),this._prepare(o,d),this._renderPlugins.prepareRender(),this.performanceInfo.advance(de.PREPARE);const c=this._computeDepthRange(o);this._renderShadowMap(o,this._bindParameters.lighting.mainLight.direction,c),this.performanceInfo.advance(de.SHADOW_MAP),this._ensureBindParameters(o,d);const m=this._renderPlugins.produces(Z.OPAQUE_TERRAIN)&&(this._terrainTransparency===S.Semitransparent||this._terrainTransparency===S.TransparentWithDraped),f=this._highQualityTransparency&&m,g=this._needsTransparentPass||this._renderPlugins.produces(Z.TRANSPARENT_MATERIAL);this._prepareShaders(f,g),this._renderLinearDepth(),this.performanceInfo.advance(de.LINEAR_DEPTH),this._renderShadowAccumulation(c,o,d),this.performanceInfo.advance(de.ACCUMULATED_SHADOWS),this._ensureBindParametersSSR(i),this._renderSSAO(),this.performanceInfo.advance(de.SSAO),this._renderContext.output=D.Color,h.bindFbo(),this._renderOpaqueGeometry(),this._renderPlugins.render(Z.ENVIRONMENT_OPAQUE),this.performanceInfo.advance(de.OPAQUE),this._renderTerrainLinearDepth(f),this._setMultipassTerrain(f),this._renderEdges(ae.OPAQUE),this.performanceInfo.advance(de.OPAQUE_EDGES),h.bindFbo(),this._renderPlugins.render(Z.VOXEL),this.performanceInfo.advance(de.VOXEL),this._renderHiddenTransparentEdges(),g&&(this._oitEnabled?this._renderOITPass(me.Geometry):this._renderTransparentMaterial()),this.performanceInfo.advance(de.TRANSPARENT);const T=this._renderGeometryLinearDepth(f);this._renderHUDVisibility(T),f||this._renderInternalSlot(Z.LINE_CALLOUTS),this.performanceInfo.advance(de.HUD_VISIBILITY),this._renderObjectAndLayerIdColor(r),this.performanceInfo.advance(de.OBJECT_AND_LAYER_ID_COLOR),this._renderEdges(ae.TRANSPARENT,T),this._releaseGeometryLinearDepth(T),this.performanceInfo.advance(de.TRANSPARENT_EDGES);const A=m?this._renderTransparentTerrain():null;A&&this._bindParameters.hudVisibility&&(f?this._renderLineCallouts(O.Occluded):h.compositeToHUDVisibility(this._bindParameters,A.colorTexture),this._renderHUD(O.Occluded,h.color),this.performanceInfo.advance(de.HUD_OCCLUDED)),this.performanceInfo.advance(de.TRANSPARENT_TERRAIN),this._setTerrainCulling(!1),A&&(h.compositeToFramebuffer(this._bindParameters,A.colorTexture,he.PremultipliedAlpha,1),A.release(),f&&(this._renderEdges(ae.OPAQUE),this.performanceInfo.advance(de.OPAQUE_EDGES),g&&(this._oitEnabled?this._renderOITPass(me.Geometry):this._renderTransparentMaterial()),this.performanceInfo.advance(de.TRANSPARENT),this._renderEdges(ae.TRANSPARENT),this.performanceInfo.advance(de.TRANSPARENT_EDGES))),this._bindParameters.ssao=n(this._bindParameters.ssao),f&&this._renderLineCallouts(O.NotOccluded),this._setMultipassEnabled(!1),this._shadowAccumulator.render(this._bindParameters),h.bindFbo(),this._renderInternalSlot(Z.TRANSPARENT_DEPTH_WRITE_DISABLED_MATERIAL),this._renderPlugins.render(Z.ENVIRONMENT_TRANSPARENT),this.performanceInfo.advance(de.ENVIRONMENT),this._renderLaserlines(),this.performanceInfo.advance(de.LASER_LINES),this._renderOccluded(),this.performanceInfo.advance(de.OCCLUDED);const P=this._magnifierEnabled&&null==e?this.fboCache.acquire(C.RGBA,this._offscreen.width,this._offscreen.height):null,R=this._renderComposite(P??e,this._offscreen.color)??e;this.performanceInfo.advance(de.ANTIALIASING),this._renderHUD(O.NotOccluded,R),this.performanceInfo.advance(de.HUD),this._renderHighlights(R,this._bindParameters),this.performanceInfo.advance(de.HIGHLIGHTS),this._magnifierEnabled&&this._magnifierHelper.render(this._rctx,this._bindParameters),R!==e&&(this._rctx.bindFramebuffer(e?.fbo),this._compositingHelper.composite(this._bindParameters,P?.colorTexture,he.None)),P!==e&&P?.release(),this.onPostRender&&this.onPostRender(),this._releaseFBOs(),this._offscreen.releaseBuffers(),this._renderContext.lastFrameCamera.copyFrom(this._bindParameters.camera),this._sliceHelper.plane=p,this._isRendering=!1,this.performanceInfo.finishFrame(),a&&(this._releaseFBOs(),this._disposeOffscreenBuffers())}_prepareShaders(e,r){this._renderContext.output=D.Color,this._prepareOpaqueGeometrySlots(),this._setMultipassTerrain(e),this._renderPlugins.prepare(Z.TRANSPARENT_TERRAIN),this._setMultipassTerrain(!1),e||this._prepareInternalSlots(this._materialRenderers,Z.LINE_CALLOUTS),r&&this._prepareTransparencySlots(),this._prepareInternalSlots(this._materialRenderers,Z.TRANSPARENT_DEPTH_WRITE_DISABLED_MATERIAL),this._renderPlugins.prepare(Z.ENVIRONMENT_TRANSPARENT),this._renderPlugins.prepare(Z.LASERLINES),this._rctx.gl.flush()}_renderObjectAndLayerIdColor(e){if(null==e||!has("enable-feature:objectAndLayerId-rendering"))return;const r=this._renderContext.output;this._rctx.bindFramebuffer(e.fbo),this._offscreen.renderToFBO((()=>this._renderAllGeometry(D.ObjectAndLayerIdColor)),[0,0,0,0],!0,!0),this._rctx.bindFramebuffer(e.fbo),this._offscreen.renderToFBO((()=>{this._bindParameters.hudRenderStyle=O.NotOccluded,this._renderInternalSlot(Z.HUD_MATERIAL)}),void 0,!0,!0),this._renderContext.output=r}finish(e){this._hasAnimations||this._animationTimestep.clear();const r=this.performanceInfo.gpuSamplingEnabled,t=e===G.BACKGROUND;if(t||r){const e=t?this.performanceInfo.elapsedTime:0,s=r?this.performanceInfo.totalGPUTimeSampler.last:this._rctx.gl.getError(),i=Math.max(e,s);this._animationTimestep.frame(i,t)}}readDepthPixels(e,r,t){const s=this._bindParameters.linearDepth?.fbo;if(s?.colorTexture)return void s.readPixels(r[0],r[1],r[2],r[3],_e.RGBA,pe.UNSIGNED_BYTE,t);const i=this.fboCache.acquire(C.RGBA,this._offscreen.width,this._offscreen.height).acquireDepth(I.DEPTH16_BUFFER);this._rctx.bindFramebuffer(i.fbo),this._ensureBindParameters(e,e),this._bindParameters.camera.setGLViewport(this._rctx),this._rctx.setClearColor(0,0,0,0);const a=ue.COLOR_BUFFER_BIT|ue.DEPTH_BUFFER_BIT|ue.STENCIL_BUFFER_BIT;this._rctx.clearSafe(a),this._renderAllGeometry(D.Depth),i.fbo.readPixels(r[0],r[1],r[2],r[3],_e.RGBA,pe.UNSIGNED_BYTE,t),i.release()}readHUDVisibility(e,r,t,s,i){this._bindParameters.hudVisibility?.fbo.readPixels(e,r,t,s,_e.RGBA,pe.UNSIGNED_BYTE,i)}readAccumulatedShadow(e){return this._shadowAccumulator.readAccumulatedShadow(e[0],e[1])}_setMultipassTerrain(e){this._setMultipassEnabled(e),this._setTerrainCulling(e)}_setMultipassEnabled(e){this._bindParameters.multipassEnabled=e}_setTerrainCulling(e){this._bindParameters.multipassTerrain.cullAboveGround=e}_renderEdges(e,r){const t=this._edgeView;if(t?.shouldRender()){const{width:s,height:i,depth:a}=this._offscreen,n=this.fboCache.acquire(C.RGBA,s,i),h=()=>t.render(this._bindParameters,e);this._offscreen.renderToTargets(h,n,r??a,ge),this._offscreen.compositeToFramebuffer(this._bindParameters,n.colorTexture,he.Alpha,1),n.release()}}_renderShadowMap(e,r,t){const s=this._shadowMap;s.enabled&&(s.start(e,r,t,this.isFeatureEnabled(K.HighResolutionShadows),this._stage.view.qualitySettings.maximumPixelRatio),this._shadowHighlight.updateParameters(e,r),this._needsShadowHighlight?(this._renderShadowCascades(D.ShadowHighlight,this._shadowMap),s.moveSnapshot(re.Highlight),s.clear(),this._renderShadowCascades(D.ShadowExcludeHighlight,this._shadowMap),s.copySnapshot(re.Default),this._renderShadowCascades(D.ShadowHighlight,this._shadowMap)):this._renderShadowCascades(D.Shadow),s.finish(),e.setGLViewport(this._rctx))}_renderShadowCascades(e,r=this._shadowMap){for(const t of r.cascades)t.camera.setGLViewport(this._rctx),this._prepare(t.camera,t.camera),this._renderAllGeometry(e)}get _needsLinearDepth(){return this._renderPlugins.consumes(D.Depth)||this.hasReflections||this._needsShadowHighlight||this._needsShadowCast}_renderLinearDepth(){this._needsLinearDepth?(this._bindParameters.linearDepth=this._offscreen.renderToCachedFBO(this._bindParameters.linearDepth,(()=>this._renderAllGeometry(D.Depth)),[0,0,0,0],C.RGBA,I.DEPTH_STENCIL_BUFFER),this._bindParameters.linearDepth.releaseDepth(),this._offscreen.bindFbo()):this._bindParameters.linearDepth=n(this._bindParameters.linearDepth)}_renderTerrainLinearDepth(e){if(e){const e=this._renderContext.output;this._renderContext.output=D.Depth,this._bindParameters.multipassTerrain.linearDepth=this._offscreen.renderToCachedFBO(this._bindParameters.multipassTerrain.linearDepth,(()=>this._renderTransparentTerrain()),[-1e10,-1e10,-1e10,1]),this._bindParameters.multipassTerrain.linearDepth.releaseDepth(),this._renderContext.output=e}else this._bindParameters.multipassTerrain.linearDepth=n(this._bindParameters.multipassTerrain.linearDepth)}_renderGeometryLinearDepth(e){if(!e)return void(this._bindParameters.multipassGeometry.linearDepth=n(this._bindParameters.multipassGeometry.linearDepth));const r=this._renderContext.output;return this._bindParameters.multipassGeometry.linearDepth=this._offscreen.renderToCachedFBO(this._bindParameters.multipassGeometry.linearDepth,(()=>this._renderOpaqueGeometryAndTransparentMaterial(D.Depth)),[1,1,1,1],C.RGBA,this._geometryLinearDepthFormat),this._renderContext.output=r,this._bindParameters.multipassGeometry.linearDepth.detachDepth()}get _needsDepthRange(){return this._shadowMap.enabled||this._needsShadowCast}_computeDepthRange(e){if(!this._needsDepthRange)return V;const r=W(e,this._materialRenderers,this._stage.layers);return Q(r,this._renderPlugins.queryDepthRange(e)),r.near=Math.max(e.near,r.near),r.far=Math.min(e.far,r.far),r}_renderAllGeometry(e){this._renderContext.output=e,this._renderPlugins.prepare(Z.TRANSPARENT_TERRAIN),this._renderOpaqueGeometryAndTransparentMaterial(e),this._renderTransparentTerrain()}_renderOpaqueGeometryAndTransparentMaterial(e){this._renderContext.output=e,this._renderPlugins.prepare(Z.TRANSPARENT_MATERIAL),this._renderOpaqueGeometry(),this._renderTransparentMaterial()}_renderSSAO(){if(!this._renderPlugins.produces(Z.SSAO))return;const e=this._offscreen.renderToCachedFBO(null,(()=>this._renderAllGeometry(D.Normal)),[0,0,0,0],C.RGBA4,I.DEPTH24_BUFFER);e.releaseDepth(),this._offscreen.bindFbo(),this._pluginInput.normal=e,this._bindParameters.ssao=this._renderPlugins.render(Z.SSAO,this._pluginInput),e.release()}_prepareOpaqueGeometrySlots(){this._renderPlugins.prepare(Z.INTEGRATED_MESH),this._renderPlugins.prepare(Z.OPAQUE_TERRAIN),this._renderPlugins.prepare(Z.OPAQUE_MATERIAL),this._renderPlugins.prepare(Z.ENVIRONMENT_OPAQUE),this._prepareInternalSlots(this._materialRenderers,Z.OPAQUE_MATERIAL)}_renderOpaqueGeometry(){this._renderPlugins.render(Z.INTEGRATED_MESH),this._renderPlugins.render(Z.OPAQUE_TERRAIN),this._renderInternalSlot(Z.OPAQUE_MATERIAL),this._renderPlugins.render(Z.OPAQUE_MATERIAL)}_renderTransparentMaterial(){this._renderInternalSlot(Z.TRANSPARENT_MATERIAL),this._renderPlugins.render(Z.TRANSPARENT_MATERIAL)}_renderTransparentTerrain(){if(!this._renderPlugins.produces(Z.TRANSPARENT_TERRAIN))return;const e=()=>this._renderPlugins.render(Z.TRANSPARENT_TERRAIN,null);if(this._renderContext.output!==D.Color)return void e();const{width:r,height:t,depth:s}=this._offscreen,i=this.fboCache.acquire(C.RGBA,r,t);return this._offscreen.renderToTargets(e,i,s,[0,0,0,0]),i}_renderHUDVisibility(e){this._shouldRenderInternalSlot(this._materialRenderers,Z.OCCLUSION_PIXELS)?(this._bindParameters.hudVisibility=this._offscreen.renderHUDVisibility(this._bindParameters.hudVisibility,(()=>this._renderInternalSlot(Z.OCCLUSION_PIXELS)),e),this._offscreen.bindFbo()):this._bindParameters.hudVisibility=n(this._bindParameters.hudVisibility)}_renderLineCallouts(e){if(this._bindParameters.hudRenderStyle=e,e===O.Occluded){const e=()=>this._renderInternalSlot(Z.LINE_CALLOUTS),{width:r,height:t,color:s}=this._offscreen,i=this.fboCache.acquireDepth(I.DEPTH16_BUFFER,r,t);this._offscreen.renderToTargets(e,s,i,void 0,!0,!0),i.release()}else this._renderInternalSlot(Z.LINE_CALLOUTS)}_renderLaserlines(){if(this._renderPlugins.render(Z.LASERLINES),this._renderPlugins.produces(Z.LASERLINES_CONTRAST_CONTROL)){const e=this._offscreen,{width:r,height:t,depth:s}=e,i=this.fboCache.acquire(C.RGBA,r,t),a=()=>this._renderPlugins.render(Z.LASERLINES_CONTRAST_CONTROL);e.renderToTargets(a,i,s,ge),e.compositeToFramebuffer(this._bindParameters,i.colorTexture,he.PremultipliedAlpha,1),i.release()}}_renderHUD(e,r){if(this._materialRenderersHas.hudElements)if(this._oitEnabled){const t=this._renderOITPass(me.HUD,e);this._rctx.bindFramebuffer(r?.fbo),this._compositingHelper.composite(this._bindParameters,t.colorTexture,he.PremultipliedAlpha),t.release()}else if(e===O.Occluded){const r=()=>this._renderHUDElements(e),{width:t,height:s,color:i}=this._offscreen,a=this.fboCache.acquireDepth(I.DEPTH16_BUFFER,t,s);this._offscreen.renderToTargets(r,i,a,void 0,!0,!0),a.release()}else this._rctx.bindFramebuffer(null),r?.acquireDepth(I.DEPTH16_BUFFER),this._rctx.bindFramebuffer(r?.fbo),this._renderHUDElements(e),r?.releaseDepth()}_renderHUDElements(e){this._bindParameters.hudRenderStyle=e,this._prepareInternalSlots(this._materialRenderers,Z.LINE_CALLOUTS_HUD_DEPTH,Z.HUD_MATERIAL,Z.LABEL_MATERIAL),this._renderInternalSlot(Z.LINE_CALLOUTS_HUD_DEPTH),this._renderInternalSlot(Z.HUD_MATERIAL),this._renderInternalSlot(Z.LABEL_MATERIAL)}get _needsShadowHighlight(){return this._shadowMap.enabled&&this._renderPlugins.produces(Z.SHADOW_HIGHLIGHT)&&this.hasShadowHighlights}_renderHighlights(e,r){if(!this.hasHighlights||r.decorations===B.OFF)return;const t=()=>{this._renderAllGeometry(D.Highlight),this._rctx.clearSafe(ue.DEPTH_BUFFER_BIT),this._renderHUDElements(O.Both)},s=this._offscreen.renderToCachedFBO(null,t,[0,0,0,0],C.RGBA4,I.DEPTH_STENCIL_BUFFER);s.releaseDepth(),this._needsShadowHighlight&&(this._pluginInput.highlight=s,this._renderPlugins.render(Z.SHADOW_HIGHLIGHT,this._pluginInput,e)),this._renderPlugins.produces(Z.HIGHLIGHT)&&(this._pluginInput.composite=null,this._pluginInput.normal=null,this._pluginInput.highlight=s,this._renderPlugins.render(Z.HIGHLIGHT,this._pluginInput,e)),s.release()}get _needsShadowCast(){return this._shadowAccumulator.isAccumulating}_renderShadowAccumulation(e,r,t){this._needsShadowCast&&this._bindParameters.linearDepth?.colorTexture&&this._shadowAccumulator.renderAccumulation(this._bindParameters.linearDepth,e,r,t)}_prepareTransparencySlots(){this._renderContext.output=D.Alpha,this._bindParameters.transparencyPassType=se.Alpha,this._prepareInternalSlots(this._materialRenderers,Z.TRANSPARENT_MATERIAL),this._renderPlugins.prepare(Z.TRANSPARENT_MATERIAL),this._renderContext.output=D.Color,this._bindParameters.transparencyPassType=se.Color,this._prepareInternalSlots(this._materialRenderers,Z.TRANSPARENT_MATERIAL),this._renderPlugins.prepare(Z.TRANSPARENT_MATERIAL),this._bindParameters.transparencyPassType=se.FrontFace,this._prepareInternalSlots(this._materialRenderers,Z.TRANSPARENT_MATERIAL),this._renderPlugins.prepare(Z.TRANSPARENT_MATERIAL),this._bindParameters.transparencyPassType=se.NONE}_renderOITPass(e,r=O.Both){const t=e===me.HUD,s=t?this.fboCache.acquire(C.RGBA,this._offscreen.width,this._offscreen.height):null,i=t?()=>this._renderHUDElements(r):()=>this._renderTransparentMaterial(),a=this._renderContext.output;this._renderContext.output=D.Alpha,this._bindParameters.transparencyPassType=se.Alpha;const n=this._offscreen.renderOITPass(i,se.Alpha,t);this._renderContext.output=D.Color,this._bindParameters.transparencyPassType=se.Color;const h=this._offscreen.renderOITPass(i,se.Color,t);this._bindParameters.transparencyPassType=se.FrontFace;const o=this._offscreen.renderOITPass(i,se.FrontFace,t);return this._offscreen.compositeTransparentOntoOpaque(this._bindParameters,h,n,o,s),s?.releaseDepth(),o.release(),h.release(),n.release(),this._bindParameters.transparencyPassType=se.NONE,this._renderContext.output=a,s}_renderOccluded(){let e=0;Te.clear(),this._materialRenderers.forAll((r=>{r.material&&r.material.isVisible()&&r.material.parameters.renderOccluded===k.OccludeAndTransparentStencil&&(e|=r.material.parameters.renderOccluded,Te.push(r))}));const r=this._offscreen,t=(t,s,i,a,n)=>{if(0==(e&s))return;const{width:h,height:o,depth:d}=r,l=this.fboCache.acquire(C.RGBA,h,o);r.renderToTargets(i,l,d,[0,0,0,0],a,n),r.compositeToFramebuffer(this._bindParameters,l.colorTexture,he.PremultipliedAlpha,t),l.release()};0!==Te.length&&(this._prepareInternalSlots(Te,Z.OCCLUDER_MATERIAL,Z.TRANSPARENT_OCCLUDER_MATERIAL),this._renderInternalSlot(Z.OCCLUDER_MATERIAL,Te),t(.5,k.OccludeAndTransparentStencil,(()=>this._renderInternalSlot(Z.TRANSPARENT_OCCLUDER_MATERIAL,Te)),!1,!1)),Te.clear(),this._materialRenderers.forAll((r=>{r.material&&r.material.isVisible()&&(r.material.parameters.renderOccluded===k.OccludeAndTransparent||r.material.parameters.renderOccluded===k.Transparent||r.material.parameters.renderOccluded===k.Opaque)&&(e|=r.material.parameters.renderOccluded,Te.push(r))}));const s=this._renderPlugins.renderOccludedFlags;if(e|=s,!e)return;const i=e=>{this._renderContext.renderOccludedMask=e,this._prepareInternalSlots(Te,Z.OPAQUE_MATERIAL,Z.TRANSPARENT_MATERIAL,Z.TRANSPARENT_DEPTH_WRITE_DISABLED_MATERIAL),s>k.Occlude&&this._renderPlugins.render(Z.OCCLUDED_TERRAIN),this._renderInternalSlot(Z.OPAQUE_MATERIAL,Te),this._renderInternalSlot(Z.TRANSPARENT_MATERIAL,Te),this._renderInternalSlot(Z.TRANSPARENT_DEPTH_WRITE_DISABLED_MATERIAL,Te),this._renderContext.resetRenderOccludedMask()};this._renderContext.output=D.Color,t(.5,k.OccludeAndTransparent,(()=>i(k.OccludeAndTransparent)),!0,j.OutlineVisualElementMask),t(.5,k.Transparent,(()=>i(k.Transparent)),!0,j.OutlineVisualElementMask),t(1,k.Opaque,(()=>i(k.Opaque)),!0,j.OutlineVisualElementMask),Te.clear()}_renderComposite(e,r){this._renderPlugins.consumes(D.CompositeColor)&&(this._pluginInput.composite=r);let t=null;const s=this._renderPlugins.produces(Z.COMPOSITE);s&&(t=this._renderPlugins.renderComposition(Z.COMPOSITE,this._pluginInput),this._pluginInput.composite=t);const i=this._renderPlugins.produces(Z.ANTIALIASING),a=this._renderPlugins.render(i?Z.ANTIALIASING:Z.BLIT,this._pluginInput,e);return s&&t?.release(),a}_prepare(e,r){this._needsTransparentPass=this._materialRenderers.some((e=>e.material.produces(Z.TRANSPARENT_MATERIAL,D.Color))),this._bindParameters.camera=e,this._bindParameters.contentCamera=r}_ensureBindParameters(e,r){this._bindParameters.camera=e,this._bindParameters.contentCamera=r;const t=this._renderContext.offscreenRenderingHelper;this._bindParameters.mainColor=t.colorTexture,this._bindParameters.mainDepth=t.depthTexture}_ensureBindParametersSSR(e){if(this._bindParameters.ssr.lastFrameColor){null==this._ssrEnableTime&&(this._ssrEnableTime=e),this._renderContext.lastFrameCamera.equals(this._bindParameters.camera)?this._reprojectionMatrix=g:(m(Pe,this._bindParameters.camera.viewMatrix),m(Ae,this._bindParameters.camera.projectionMatrix),f(Re,Pe,Ae),f(Re,this._renderContext.lastFrameCamera.viewMatrix,Re),f(Re,this._renderContext.lastFrameCamera.projectionMatrix,Re),this._reprojectionMatrix=Re);const r=this._stage.view.qualitySettings.fadeDuration;this._bindParameters.ssr.fadeFactor=r>0?Math.min(r,e-this._ssrEnableTime)/r:1,this._bindParameters.ssr.fadeFactor<1&&this._requestRender()}else this._reprojectionMatrix=g,this._ssrEnableTime=null}_shouldRenderInternalSlot(e,r){return this._bindParameters.slot=r,e.some((e=>null!=e.prepareTechnique(this._renderContext)))}_prepareInternalSlots(e,...r){for(const t of r)this._bindParameters.slot=t,e.forAll((e=>null!=e.prepareTechnique(this._renderContext)))}_renderInternalSlot(e,r=this._materialRenderers){this._bindParameters.slot=e,r.forAll((e=>{const r=e.prepareTechnique(this._renderContext);r&&e.renderNode(this._renderContext,r)}))}get memoryInfo(){return{fbos:this.fboCache.usedMemory,vaos:this._materialRenderers.reduce(((e,r)=>e+r.usedMemory),0),plugins:this._renderPlugins.usedMemory}}getMemoryForMaterial(e){if(null==e)return 0;const r=this._materialRenderers.find((r=>r.material===e));return r?.usedMemory??0}get usedMemory(){return this.fboCache.usedMemory+(this.edgeView?.usedMemory??0)+this._renderPlugins.usedMemory}get test(){const e=this;return{offscreen:this._offscreen,shadowMap:this._shadowMap,highlight:this._highlight,lighting:this._bindParameters.lighting,materialRenderers:this._materialRenderers,shadowAccumulator:this._shadowAccumulator,weatherIsFading:this._bindParameters.cloudsFade.isFading,resetRenderStateFeatures:()=>{e._renderStateFeatures=J(),this._renderPlugins.renderFeatureChanged(),this._requestRender()},releaseGeometryLinearDepth(r){e._releaseGeometryLinearDepth=r??(e=>e?.release()),e._geometryLinearDepthFormat=r?I.DEPTH_STENCIL_TEXTURE:I.DEPTH16_BUFFER},getFramebufferTexture:r=>{switch(r){case fe.Color:return e._offscreen.colorTexture;case fe.LinearDepth:return e._bindParameters.linearDepth?.colorTexture;case fe.ShadowMap:return e._shadowMap.depthTexture;case fe.HudVisibility:return e._bindParameters.hudVisibility?.colorTexture}}}}};var me,fe;e([p()],ce.prototype,"_renderPlugins",void 0),e([p()],ce.prototype,"_shadowAccumulator",void 0),e([p()],ce.prototype,"_state",void 0),e([p()],ce.prototype,"_renderStateFeatures",void 0),e([p({readOnly:!0})],ce.prototype,"fullResolutionAtmosphere",null),e([p()],ce.prototype,"_smaa",void 0),e([p()],ce.prototype,"_blit",void 0),e([p({autoDestroy:!0})],ce.prototype,"_edgeView",void 0),e([p()],ce.prototype,"updating",null),e([p()],ce.prototype,"isCameraFinal",null),ce=e([u("esri.views.3d.webgl-engine.lib.Renderer")],ce),function(e){e[e.Geometry=0]="Geometry",e[e.HUD=1]="HUD"}(me||(me={})),function(e){e[e.Color=0]="Color",e[e.LinearDepth=1]="LinearDepth",e[e.ShadowMap=2]="ShadowMap",e[e.HudVisibility=3]="HudVisibility"}(fe||(fe={}));const ge=[0,0,0,0],Te=new h,Ae=T(),Pe=T(),Re=T();function Ee(e){return r=>e.immediate.schedule(r)}export{fe as FramebufferId,ce as Renderer};
5
+ import{_ as e}from"../../../../chunks/tslib.es6.js";import r from"../../../../core/Accessor.js";import{update as t}from"../../../../core/arrayUtils.js";import{unitRGBAFromColor as s}from"../../../../core/colorUtils.js";import has from"../../../../core/has.js";import{removeMaybe as i,destroyMaybe as a,releaseMaybe as n}from"../../../../core/maybe.js";import h from"../../../../core/PooledArray.js";import{watch as o,syncAndInitial as d,initial as l,sync as _}from"../../../../core/reactiveUtils.js";import{property as p}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/accessorSupport/ensureType.js";import{subclass as u}from"../../../../core/accessorSupport/decorators/subclass.js";import{a as c,i as m,m as f}from"../../../../chunks/mat4.js";import{I as g,a as T}from"../../../../chunks/mat4f64.js";import{s as A}from"../../../../chunks/vec4.js";import{f as P,Z as R}from"../../../../chunks/vec4f64.js";import{a as E}from"../../../../chunks/boundedPlane.js";import{debugFlags as b}from"../../support/debugFlags.js";import{TransparencyMode as S}from"../../terrain/TerrainRenderer.js";import{DepthFormat as I,FBOCache as y,ColorFormat as C}from"../core/FBOCache.js";import{RenderPassManager as w}from"../core/renderPasses/RenderPassManager.js";import{ShaderOutput as D}from"../core/shaderLibrary/ShaderOutput.js";import{HUDRenderStyle as O}from"../core/shaderLibrary/hud/HUDRenderStyle.js";import{RenderPluginInput as L}from"../effects/RenderPluginInput.js";import{RenderPluginManager as N}from"../effects/RenderPluginManager.js";import{Blit as M}from"../effects/blit/Blit.js";import{Highlight as H}from"../effects/highlight/Highlight.js";import{ShadowHighlight as F}from"../effects/highlight/ShadowHighlight.js";import{SMAA as x}from"../effects/smaa/SMAA.js";import{SSAO as v}from"../effects/ssao/SSAO.js";import{AnimationTimeStep as U}from"./AnimationTimeStep.js";import{Decorations as B,RenderRequestType as G,StencilBits as j}from"./basicInterfaces.js";import{BoundingInfo as q}from"./BoundingInfo.js";import{zero as V,union as Q}from"./depthRange.js";import{depthRangeFromScene as W}from"./depthRangeUtils.js";import{RenderOccludedFlag as k}from"./Material.js";import{OffscreenRendering as Y}from"./OffscreenRendering.js";import{RenderContext as X}from"./RenderContext.js";import{splitRenderGeometryChangeSetByMaterial as z}from"./rendererUtils.js";import{setupFeatureDefaults as J,RenderFeature as K}from"./RenderFeature.js";import{RenderSlot as Z}from"./RenderSlot.js";import{ShadowAccumulator as $}from"./ShadowAccumulator.js";import{ShadowMap as ee,SnapshotSlot as re}from"./ShadowMap.js";import te from"./SliceHelper.js";import{TransparencyPassType as se}from"./TransparencyPassType.js";import{EdgeView as ie}from"./edgeRendering/EdgeView.js";import{Transparency as ae}from"./edgeRendering/interfaces.js";import{MergedRenderer as ne}from"../materials/renderers/MergedRenderer.js";import{AlphaMode as he}from"../shaders/CompositingTechniqueConfiguration.js";import{RendererPerformanceInfo as oe,PerformanceCategory as de}from"../statistics/RendererPerformanceInfo.js";import{RenderState as le}from"../../../support/RenderState.js";import{PixelFormat as _e,PixelType as pe,ClearBufferBit as ue}from"../../../webgl/enums.js";let ce=class extends r{get _bindParameters(){return this._renderContext.bindParameters}updateRenderFeatures(e=null,r=!has("disable-feature:high-quality-idle")){this._renderStateFeatures=J(r,e),this.notifyChange("_renderStateFeatures"),this._renderPlugins.renderFeatureChanged(),this._requestRender()}isFeatureEnabled(e,r=this._state){return this._renderStateFeatures.get(r,e)??!1}setFeatureEnabled(e,r,t){this._renderStateFeatures.set(r,e,t),this.notifyChange("_renderStateFeatures"),this._requestRender()}get _highQualityTransparency(){return this._highQualityTransparencyEnabled||this.isFeatureEnabled(K.HighQualityTransparency)}get hasReflections(){return this.hasWater&&(this._ssrEnabled||this.isFeatureEnabled(K.WaterReflection))}get hasDecorations(){return this._materialRenderersHas.decorations||this._renderPlugins.hasDecorations}get hasHighlights(){return this._materialRenderersHas.highlights||this._renderPlugins.produces(Z.OPAQUE_MATERIAL,D.Highlight)||this._renderPlugins.produces(Z.DRAPED_MATERIAL,D.Highlight)}get hasShadowHighlights(){return this._materialRenderersHas.highlights||this._renderPlugins.produces(Z.OPAQUE_MATERIAL,D.ShadowHighlight)}get _magnifierEnabled(){return this._bindParameters.decorations===B.ON&&this._magnifierHelper.enabled}get fullResolutionAtmosphere(){return this._stage.view.qualitySettings.highResolutionAtmosphere||this.isFeatureEnabled(K.HighResolutionAtmosphere)}get hasWater(){return this._materialRenderersHas.water||this._hasOverlayWater}constructor(e,r,t,i,a,n,_,p){super({}),this._stage=e,this._techniqueRepository=i,this._rctx=a,this._compositingHelper=n,this._magnifierHelper=_,this._requestRender=p,this._materialRenderers=new h,this._needsTransparentPass=!1,this._materialRenderersHas={hudElements:!1,highlights:!1,water:!1,decorations:!1,occludees:!1},this._hasOverlayWater=!1,this.renderOverlay=e=>{},this._isRendering=!1,this._backgroundColor=P(0,0,0,1),this._sliceHelper=new te,this._state=le.IDLE,this._highQualityTransparencyEnabled=!0,this._terrainTransparency=S.Opaque,this._ssrEnabled=!1,this._hasAnimations=!1,this._animationTimestep=new U,this._renderHiddenTransparentEdges=()=>{},this._pluginInput=new L,this._releaseGeometryLinearDepth=e=>e?.release(),this._geometryLinearDepthFormat=I.DEPTH16_BUFFER,this.fboCache=new y(a),this._renderStateFeatures=J(!has("disable-feature:high-quality-idle"),e.view.qualityProfile),this._offscreen=new Y(this.fboCache,this._compositingHelper),this.performanceInfo=new oe(this._rctx),this._shadowMap=new ee(this.fboCache,e.viewingMode),this._highlight=new H({view:e.view}),this._shadowHighlight=new F({view:e.view,viewingMode:e.viewingMode}),this._shadowAccumulator=new $(this.fboCache,i,e,(e=>{const r=this.shadowsEnabled;this._shadowMap.enabled=!0,this._prepare(e.camera,e.contentCamera),this._renderPlugins.prepareRender(),this._shadowMap.enabled=r}),((e,r,t)=>{e.shadowMap.start(e.camera,r,t,!0,this._stage.view.qualitySettings.maximumPixelRatio),this._renderShadowCascades(D.Shadow,e.shadowMap),e.shadowMap.finish(),e.camera.setGLViewport(this._rctx),this._prepare(e.camera,e.contentCamera)}),p),this._ssao=new v({view:this._stage.view}),this._renderContext=new X(this._rctx,this._offscreen,this._shadowMap,this._sliceHelper),this._renderPlugins=new N({renderContext:this._renderContext,techniqueRepository:i,textureRepository:t,materialRepository:r,requestRender:p,controller:e,fbos:this.fboCache,isFeatureEnabled:e=>this.isFeatureEnabled(e)}),this.renderPassManager=new w,this._renderPlugins.add(this.renderPassManager),this._smaa=new x({view:this._stage.view}),this._renderPlugins.add(this._smaa),this._blit=new M({opacity:1,alphaMode:he.None}),this._renderPlugins.add(this._blit),this._renderPlugins.add(this._ssao),this._renderPlugins.add(this._highlight),this._renderPlugins.add(this._shadowHighlight),this.addHandles([o((()=>this._stage.view.state.camera),(()=>p()),d),o((()=>b.EDGES_SHOW_HIDDEN_TRANSPARENT_EDGES),(e=>{this._renderHiddenTransparentEdges=e?()=>this._renderEdges(ae.TRANSPARENT):()=>{},p()}),l),o((()=>this._stage.view.environment.background?.color),(e=>{const r=e?s(e):R;A(this._backgroundColor,r[0]*r[3],r[1]*r[3],r[2]*r[3],r[3]),p()}),d)])}normalizeCtorArgs(){return{}}destroy(){this._smaa.destroy(),this._blit.destroy(),this._gpuTimerHandle=i(this._gpuTimerHandle),this._materialRenderers.forAll((e=>e.dispose())),this._materialRenderers.clear(),this._offscreen.dispose(),this._shadowMap.dispose(),this._ssao.destroy(),this._highlight.dispose(),this._shadowHighlight.destroy(),this._shadowAccumulator.dispose(),this._edgeView=a(this._edgeView),this.renderPassManager.dispose(),this._releaseFBOs(),this._disposeOffscreenBuffers(),this.fboCache.destroy(),q.prune()}_releaseFBOs(){this._bindParameters.ssr.lastFrameColor=n(this._bindParameters.ssr.lastFrameColor),this._bindParameters.multipassTerrain.linearDepth=n(this._bindParameters.multipassTerrain.linearDepth),this._bindParameters.multipassGeometry.linearDepth=n(this._bindParameters.multipassGeometry.linearDepth)}_disposeOffscreenBuffers(){this._offscreen.dispose(),this._disposeBindBuffers()}_disposeBindBuffers(){this._shadowMap.disposeOffscreenBuffers(),this._bindParameters.linearDepth=n(this._bindParameters.linearDepth),this._bindParameters.hudVisibility=n(this._bindParameters.hudVisibility)}get updating(){return this._smaa.updating||null!=this._edgeView&&this._edgeView.updating||this._shadowAccumulator.running||this._renderPlugins.updating||!this.isCameraFinal}ensureEdgeView(){if(null==this._edgeView){const e=this._stage.view.resourceController;this._edgeView=new ie({rctx:this._rctx,renderSR:this._stage.view.renderSpatialReference,viewingMode:this._stage.viewingMode,techniqueRepository:this._techniqueRepository,setNeedsRender:()=>this._requestRender(),schedule:Ee(e)}),this.addHandles(o((()=>this._edgeView?.updating),(()=>this._requestRender()),_)),this._requestRender()}return this._edgeView}get edgeView(){return this._edgeView}get isCameraFinal(){return c(this._bindParameters.ssr.reprojectionMatrix,g)}set _reprojectionMatrix(e){t(this._bindParameters.ssr.reprojectionMatrix,e)&&this.notifyChange("isCameraFinal")}get shadowsEnabled(){return!!this._shadowMap?.enabled}setParameters(e){const{_shadowMap:r,_bindParameters:t}=this;if(void 0!==e.qualitySettings?.reflections&&this._ssrEnabled!==e.qualitySettings.reflections&&(this._ssrEnabled=e.qualitySettings.reflections,this._requestRender()),void 0!==e.shadowMap&&this._shadowMap.enabled!==e.shadowMap&&(this._shadowMap.enabled=e.shadowMap,this._requestRender()),void 0!==e.shadowMapMaxCascades&&r.maxCascades!==e.shadowMapMaxCascades&&(r.maxCascades=e.shadowMapMaxCascades,this._requestRender()),null!=e.environment){null!=e.environment.weather&&(this._bindParameters.weather=e.environment.weather,this._bindParameters.weatherVisible=!!e.weatherVisible);const r="virtual"!==e.environment.lighting.type;t.enableFillLights!==r&&(t.enableFillLights=r,this._requestRender())}void 0!==e.highQualityTransparency&&this._highQualityTransparencyEnabled!==e.highQualityTransparency&&(this._highQualityTransparencyEnabled=e.highQualityTransparency,this._requestRender()),void 0!==e.hasOverlayWater&&this._hasOverlayWater!==e.hasOverlayWater&&(this._hasOverlayWater=e.hasOverlayWater,this._requestRender()),void 0!==e.slicePlane&&this._sliceHelper.plane!==e.slicePlane&&(this._sliceHelper.plane=e.slicePlane,this._requestRender()),void 0!==e.terrainTransparency&&this._terrainTransparency!==e.terrainTransparency&&(this._terrainTransparency=e.terrainTransparency,this._requestRender()),void 0!==e.shadowCastOptions&&this._shadowAccumulator.setOptions(e.shadowCastOptions)}get hasSlicePlane(){return!!this._sliceHelper.plane}get renderPlugins(){return this._renderPlugins}get _hasOITSupport(){return this._rctx.driverTest.floatBufferBlend.result}get _oitEnabled(){return this._highQualityTransparency&&this._hasOITSupport}modify(e,r){this._isRendering&&console.warn("Renderer.modify called while rendering");const{adds:t,removes:s,updates:i}=e;if(0===t.length&&0===s.length&&0===i.length)return;const a=z(e);let n=!1;a.forEach(((t,s)=>{if(r.done)return;let i=this._materialRenderers.find((e=>e.material===s));if(null==i&&t.adds.length>0){const e=new ne({material:s});e.initializeRenderContext(this._renderPlugins._context),i=e,this._materialRenderers.push(i)}i&&(i.modify(t),i.isEmpty&&(n=!0)),t.removes.forEach((r=>e.removes.removeUnordered(r))),t.adds.forEach((r=>e.adds.removeUnordered(r))),t.updates.forEach((r=>e.updates.removeUnordered(r))),r.madeProgress()})),n&&this._materialRenderers.filterInPlace((e=>!e.isEmpty||(e.dispose(),!1))),this._updateHasFlags(),this._requestRender()}_updateHasFlags(){const has=this._materialRenderersHas;has.decorations=!1,has.highlights=!1,has.hudElements=!1,has.water=!1,has.occludees=!1,this._materialRenderers.forAll((e=>{has.highlights||=e.hasHighlights,has.occludees||=e.hasOccludees,has.water||=e.hasWater,has.decorations||=e.isDecoration,has.hudElements||=e.material.produces(Z.LINE_CALLOUTS_HUD_DEPTH,D.Color)||e.material.produces(Z.HUD_MATERIAL,D.Color)||e.material.produces(Z.LABEL_MATERIAL,D.Color)})),this._bindParameters.hasOccludees=has.occludees}updateAnimation(e){const r=this._hasAnimations;return this._hasAnimations=!1,this._materialRenderers.forAll((r=>this._hasAnimations=r.updateAnimation(e)||this._hasAnimations)),this._hasAnimations=this._renderPlugins.updateAnimation(e)||this._hasAnimations,this._hasAnimations!==r&&(this._gpuTimerHandle=r?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,r,t,s,i){const a=null!=e;this._isRendering=!0,this.performanceInfo.startFrame(),this.fboCache.frame(),this._disposeBindBuffers();const h=this._offscreen,{camera:o,contentCamera:d,mode:l,alignPixelEnabled:_}=t;this._state=l,this._bindParameters.overlay=this.renderOverlay(i),this.performanceInfo.advance(de.OVERLAY),this._renderContext.time=i,this._bindParameters.transparencyPassType=se.NONE,this._bindParameters.alignPixelEnabled=_,this._bindParameters.decorations=s;const p=E(this._sliceHelper.plane);s===B.OFF&&(this._sliceHelper.plane=null),o.setGLViewport(this._rctx);const u=h.initializeFrame(o,this._backgroundColor,a);this.hasReflections?this._bindParameters.ssr.lastFrameColor=u:u?.release(),this._prepare(o,d),this._renderPlugins.prepareRender(),this.performanceInfo.advance(de.PREPARE);const c=this._computeDepthRange(o);this._renderShadowMap(o,this._bindParameters.lighting.mainLight.direction,c),this.performanceInfo.advance(de.SHADOW_MAP),this._ensureBindParameters(o,d);const m=this._renderPlugins.produces(Z.OPAQUE_TERRAIN)&&(this._terrainTransparency===S.Semitransparent||this._terrainTransparency===S.TransparentWithDraped),f=this._highQualityTransparency&&m,g=this._needsTransparentPass||this._renderPlugins.produces(Z.TRANSPARENT_MATERIAL);this._prepareShaders(f,g),this._renderLinearDepth(),this.performanceInfo.advance(de.LINEAR_DEPTH),this._renderShadowAccumulation(c,o,d),this.performanceInfo.advance(de.ACCUMULATED_SHADOWS),this._ensureBindParametersSSR(i),this._renderSSAO(),this.performanceInfo.advance(de.SSAO),this._renderContext.output=D.Color,h.bindFbo(),this._renderOpaqueGeometry(),this._renderPlugins.render(Z.ENVIRONMENT_OPAQUE),this.performanceInfo.advance(de.OPAQUE),this._renderTerrainLinearDepth(f),this._setMultipassTerrain(f),this._renderEdges(ae.OPAQUE),this.performanceInfo.advance(de.OPAQUE_EDGES),h.bindFbo(),this._renderPlugins.render(Z.VOXEL),this.performanceInfo.advance(de.VOXEL),this._renderHiddenTransparentEdges(),g&&(this._oitEnabled?this._renderOITPass(me.Geometry):this._renderTransparentMaterial()),this.performanceInfo.advance(de.TRANSPARENT);const T=this._renderGeometryLinearDepth(f);this._renderHUDVisibility(T),f||this._renderInternalSlot(Z.LINE_CALLOUTS),this.performanceInfo.advance(de.HUD_VISIBILITY),this._renderObjectAndLayerIdColor(r),this.performanceInfo.advance(de.OBJECT_AND_LAYER_ID_COLOR),this._renderEdges(ae.TRANSPARENT,T),this._releaseGeometryLinearDepth(T),this.performanceInfo.advance(de.TRANSPARENT_EDGES);const A=m?this._renderTransparentTerrain():null;A&&this._bindParameters.hudVisibility&&(f?this._renderLineCallouts(O.Occluded):h.compositeToHUDVisibility(this._bindParameters,A.colorTexture),this._renderHUD(O.Occluded,h.color),this.performanceInfo.advance(de.HUD_OCCLUDED)),this.performanceInfo.advance(de.TRANSPARENT_TERRAIN),this._setTerrainCulling(!1),A&&(h.compositeToFramebuffer(this._bindParameters,A.colorTexture,he.PremultipliedAlpha,1),A.release(),f&&(this._renderEdges(ae.OPAQUE),this.performanceInfo.advance(de.OPAQUE_EDGES),g&&(this._oitEnabled?this._renderOITPass(me.Geometry):this._renderTransparentMaterial()),this.performanceInfo.advance(de.TRANSPARENT),this._renderEdges(ae.TRANSPARENT),this.performanceInfo.advance(de.TRANSPARENT_EDGES))),this._bindParameters.ssao=n(this._bindParameters.ssao),f&&this._renderLineCallouts(O.NotOccluded),this._setMultipassEnabled(!1),this._shadowAccumulator.render(this._bindParameters),h.bindFbo(),this._renderInternalSlot(Z.TRANSPARENT_DEPTH_WRITE_DISABLED_MATERIAL),this._renderPlugins.render(Z.ENVIRONMENT_TRANSPARENT),this.performanceInfo.advance(de.ENVIRONMENT),this._renderLaserlines(),this.performanceInfo.advance(de.LASER_LINES),this._renderOccluded(),this.performanceInfo.advance(de.OCCLUDED);const P=this._magnifierEnabled&&null==e?this.fboCache.acquire(C.RGBA,this._offscreen.width,this._offscreen.height):null,R=this._renderComposite(P??e,this._offscreen.color)??e;this.performanceInfo.advance(de.ANTIALIASING),this._renderHUD(O.NotOccluded,R),this.performanceInfo.advance(de.HUD),this._renderHighlights(R,this._bindParameters),this.performanceInfo.advance(de.HIGHLIGHTS),this._magnifierEnabled&&this._magnifierHelper.render(this._rctx,this._bindParameters),R!==e&&(this._rctx.bindFramebuffer(e?.fbo),this._compositingHelper.composite(this._bindParameters,P?.colorTexture,he.None)),P!==e&&P?.release(),this.onPostRender&&this.onPostRender(),this._releaseFBOs(),this._offscreen.releaseBuffers(),this._renderContext.lastFrameCamera.copyFrom(this._bindParameters.camera),this._sliceHelper.plane=p,this._isRendering=!1,this.performanceInfo.finishFrame(),a&&(this._releaseFBOs(),this._disposeOffscreenBuffers())}_prepareShaders(e,r){this._renderContext.output=D.Color,this._prepareOpaqueGeometrySlots(),this._setMultipassTerrain(e),this._renderPlugins.prepare(Z.TRANSPARENT_TERRAIN),this._setMultipassTerrain(!1),e||this._prepareInternalSlots(this._materialRenderers,Z.LINE_CALLOUTS),r&&this._prepareTransparencySlots(),this._prepareInternalSlots(this._materialRenderers,Z.TRANSPARENT_DEPTH_WRITE_DISABLED_MATERIAL),this._renderPlugins.prepare(Z.ENVIRONMENT_TRANSPARENT),this._renderPlugins.prepare(Z.LASERLINES),this._rctx.gl.flush()}_renderObjectAndLayerIdColor(e){if(null==e||!has("enable-feature:objectAndLayerId-rendering"))return;const r=this._renderContext.output;this._rctx.bindFramebuffer(e.fbo),this._offscreen.renderToFBO((()=>this._renderAllGeometry(D.ObjectAndLayerIdColor)),[0,0,0,0],!0,!0),this._rctx.bindFramebuffer(e.fbo),this._offscreen.renderToFBO((()=>{this._bindParameters.hudRenderStyle=O.NotOccluded,this._renderInternalSlot(Z.HUD_MATERIAL)}),void 0,!0,!0),this._renderContext.output=r}finish(e){this._hasAnimations||this._animationTimestep.clear();const r=this.performanceInfo.gpuSamplingEnabled,t=e===G.BACKGROUND;if(t||r){const e=t?this.performanceInfo.elapsedTime:0,s=r?this.performanceInfo.totalGPUTimeSampler.last:this._rctx.gl.getError(),i=Math.max(e,s);this._animationTimestep.frame(i,t)}}readDepthPixels(e,r,t){const s=this._bindParameters.linearDepth?.fbo;if(s?.colorTexture)return void s.readPixels(r[0],r[1],r[2],r[3],_e.RGBA,pe.UNSIGNED_BYTE,t);const i=this.fboCache.acquire(C.RGBA,this._offscreen.width,this._offscreen.height).acquireDepth(I.DEPTH16_BUFFER);this._rctx.bindFramebuffer(i.fbo),this._ensureBindParameters(e,e),this._bindParameters.camera.setGLViewport(this._rctx),this._rctx.setClearColor(0,0,0,0);const a=ue.COLOR_BUFFER_BIT|ue.DEPTH_BUFFER_BIT|ue.STENCIL_BUFFER_BIT;this._rctx.clearSafe(a),this._renderAllGeometry(D.Depth),i.fbo.readPixels(r[0],r[1],r[2],r[3],_e.RGBA,pe.UNSIGNED_BYTE,t),i.release()}readHUDVisibility(e,r,t,s,i){this._bindParameters.hudVisibility?.fbo.readPixels(e,r,t,s,_e.RGBA,pe.UNSIGNED_BYTE,i)}readAccumulatedShadow(e){return this._shadowAccumulator.readAccumulatedShadow(e[0],e[1])}_setMultipassTerrain(e){this._setMultipassEnabled(e),this._setTerrainCulling(e)}_setMultipassEnabled(e){this._bindParameters.multipassEnabled=e}_setTerrainCulling(e){this._bindParameters.multipassTerrain.cullAboveGround=e}_renderEdges(e,r){const t=this._edgeView;if(t?.shouldRender()){const{width:s,height:i,depth:a}=this._offscreen,n=this.fboCache.acquire(C.RGBA,s,i),h=()=>t.render(this._bindParameters,e);this._offscreen.renderToTargets(h,n,r??a,ge),this._offscreen.compositeToFramebuffer(this._bindParameters,n.colorTexture,he.Alpha,1),n.release()}}_renderShadowMap(e,r,t){const s=this._shadowMap;s.enabled&&(s.start(e,r,t,this.isFeatureEnabled(K.HighResolutionShadows),this._stage.view.qualitySettings.maximumPixelRatio),this._shadowHighlight.updateParameters(e,r),this._needsShadowHighlight?(this._renderShadowCascades(D.ShadowHighlight,this._shadowMap),s.moveSnapshot(re.Highlight),s.clear(),this._renderShadowCascades(D.ShadowExcludeHighlight,this._shadowMap),s.copySnapshot(re.Default),this._renderShadowCascades(D.ShadowHighlight,this._shadowMap)):this._renderShadowCascades(D.Shadow),s.finish(),e.setGLViewport(this._rctx))}_renderShadowCascades(e,r=this._shadowMap){for(const t of r.cascades)t.camera.setGLViewport(this._rctx),this._prepare(t.camera,t.camera),this._renderAllGeometry(e)}get _needsLinearDepth(){return this._renderPlugins.consumes(D.Depth)||this.hasReflections||this._needsShadowHighlight||this._needsShadowCast}_renderLinearDepth(){this._needsLinearDepth?(this._bindParameters.linearDepth=this._offscreen.renderToCachedFBO(this._bindParameters.linearDepth,(()=>this._renderAllGeometry(D.Depth)),[0,0,0,0],C.RGBA,I.DEPTH_STENCIL_BUFFER),this._bindParameters.linearDepth.releaseDepth(),this._offscreen.bindFbo()):this._bindParameters.linearDepth=n(this._bindParameters.linearDepth)}_renderTerrainLinearDepth(e){if(e){const e=this._renderContext.output;this._renderContext.output=D.Depth,this._bindParameters.multipassTerrain.linearDepth=this._offscreen.renderToCachedFBO(this._bindParameters.multipassTerrain.linearDepth,(()=>this._renderTransparentTerrain()),[-1e10,-1e10,-1e10,1]),this._bindParameters.multipassTerrain.linearDepth.releaseDepth(),this._renderContext.output=e}else this._bindParameters.multipassTerrain.linearDepth=n(this._bindParameters.multipassTerrain.linearDepth)}_renderGeometryLinearDepth(e){if(!e)return void(this._bindParameters.multipassGeometry.linearDepth=n(this._bindParameters.multipassGeometry.linearDepth));const r=this._renderContext.output;return this._bindParameters.multipassGeometry.linearDepth=this._offscreen.renderToCachedFBO(this._bindParameters.multipassGeometry.linearDepth,(()=>this._renderOpaqueGeometryAndTransparentMaterial(D.Depth)),[1,1,1,1],C.RGBA,this._geometryLinearDepthFormat),this._renderContext.output=r,this._bindParameters.multipassGeometry.linearDepth.detachDepth()}get _needsDepthRange(){return this._shadowMap.enabled||this._needsShadowCast}_computeDepthRange(e){if(!this._needsDepthRange)return V;const r=W(e,this._materialRenderers,this._stage.layers);return Q(r,this._renderPlugins.queryDepthRange(e)),r.near=Math.max(e.near,r.near),r.far=Math.min(e.far,r.far),r}_renderAllGeometry(e){this._renderContext.output=e,this._renderPlugins.prepare(Z.TRANSPARENT_TERRAIN),this._renderOpaqueGeometryAndTransparentMaterial(e),this._renderTransparentTerrain()}_renderOpaqueGeometryAndTransparentMaterial(e){this._renderContext.output=e,this._renderPlugins.prepare(Z.TRANSPARENT_MATERIAL),this._renderOpaqueGeometry(),this._renderTransparentMaterial()}_renderSSAO(){if(!this._renderPlugins.produces(Z.SSAO))return;const e=this._offscreen.renderToCachedFBO(null,(()=>this._renderAllGeometry(D.Normal)),[0,0,0,0],C.RGBA4,I.DEPTH24_BUFFER);e.releaseDepth(),this._offscreen.bindFbo(),this._pluginInput.normal=e,this._bindParameters.ssao=this._renderPlugins.render(Z.SSAO,this._pluginInput),e.release()}_prepareOpaqueGeometrySlots(){this._renderPlugins.prepare(Z.INTEGRATED_MESH),this._renderPlugins.prepare(Z.OPAQUE_TERRAIN),this._renderPlugins.prepare(Z.OPAQUE_MATERIAL),this._renderPlugins.prepare(Z.ENVIRONMENT_OPAQUE),this._prepareInternalSlots(this._materialRenderers,Z.OPAQUE_MATERIAL)}_renderOpaqueGeometry(){this._renderPlugins.render(Z.INTEGRATED_MESH),this._renderPlugins.render(Z.OPAQUE_TERRAIN),this._renderInternalSlot(Z.OPAQUE_MATERIAL),this._renderPlugins.render(Z.OPAQUE_MATERIAL)}_renderTransparentMaterial(){this._renderInternalSlot(Z.TRANSPARENT_MATERIAL),this._renderPlugins.render(Z.TRANSPARENT_MATERIAL)}_renderTransparentTerrain(){if(!this._renderPlugins.produces(Z.TRANSPARENT_TERRAIN))return;const e=()=>this._renderPlugins.render(Z.TRANSPARENT_TERRAIN,null);if(this._renderContext.output!==D.Color)return void e();const{width:r,height:t,depth:s}=this._offscreen,i=this.fboCache.acquire(C.RGBA,r,t);return this._offscreen.renderToTargets(e,i,s,[0,0,0,0]),i}_renderHUDVisibility(e){this._shouldRenderInternalSlot(this._materialRenderers,Z.OCCLUSION_PIXELS)?(this._bindParameters.hudVisibility=this._offscreen.renderHUDVisibility(this._bindParameters.hudVisibility,(()=>this._renderInternalSlot(Z.OCCLUSION_PIXELS)),e),this._offscreen.bindFbo()):this._bindParameters.hudVisibility=n(this._bindParameters.hudVisibility)}_renderLineCallouts(e){if(this._bindParameters.hudRenderStyle=e,e===O.Occluded){const e=()=>this._renderInternalSlot(Z.LINE_CALLOUTS),{width:r,height:t,color:s}=this._offscreen,i=this.fboCache.acquireDepth(I.DEPTH16_BUFFER,r,t);this._offscreen.renderToTargets(e,s,i,void 0,!0,!0),i.release()}else this._renderInternalSlot(Z.LINE_CALLOUTS)}_renderLaserlines(){if(this._renderPlugins.render(Z.LASERLINES),this._renderPlugins.produces(Z.LASERLINES_CONTRAST_CONTROL)){const e=this._offscreen,{width:r,height:t,depth:s}=e,i=this.fboCache.acquire(C.RGBA,r,t),a=()=>this._renderPlugins.render(Z.LASERLINES_CONTRAST_CONTROL);e.renderToTargets(a,i,s,ge),e.compositeToFramebuffer(this._bindParameters,i.colorTexture,he.PremultipliedAlpha,1),i.release()}}_renderHUD(e,r){if(this._materialRenderersHas.hudElements)if(this._oitEnabled){const t=this._renderOITPass(me.HUD,e);this._rctx.bindFramebuffer(r?.fbo),this._compositingHelper.composite(this._bindParameters,t.colorTexture,he.PremultipliedAlpha),t.release()}else if(e===O.Occluded){const r=()=>this._renderHUDElements(e),{width:t,height:s,color:i}=this._offscreen,a=this.fboCache.acquireDepth(I.DEPTH16_BUFFER,t,s);this._offscreen.renderToTargets(r,i,a,void 0,!0,!0),a.release()}else this._rctx.bindFramebuffer(null),r?.acquireDepth(I.DEPTH16_BUFFER),this._rctx.bindFramebuffer(r?.fbo),this._renderHUDElements(e),r?.releaseDepth()}_renderHUDElements(e){this._bindParameters.hudRenderStyle=e,this._prepareInternalSlots(this._materialRenderers,Z.LINE_CALLOUTS_HUD_DEPTH,Z.HUD_MATERIAL,Z.LABEL_MATERIAL),this._renderInternalSlot(Z.LINE_CALLOUTS_HUD_DEPTH),this._renderInternalSlot(Z.HUD_MATERIAL),this._renderInternalSlot(Z.LABEL_MATERIAL)}get _needsShadowHighlight(){return this._shadowMap.enabled&&this._renderPlugins.produces(Z.SHADOW_HIGHLIGHT)&&this.hasShadowHighlights}_renderHighlights(e,r){if(!this.hasHighlights||r.decorations===B.OFF)return;const t=()=>{this._renderAllGeometry(D.Highlight),this._rctx.clearSafe(ue.DEPTH_BUFFER_BIT),this._renderHUDElements(O.Both)},s=this._offscreen.renderToCachedFBO(null,t,[0,0,0,0],C.RGBA4,I.DEPTH_STENCIL_BUFFER);s.releaseDepth(),this._needsShadowHighlight&&(this._pluginInput.highlight=s,this._renderPlugins.render(Z.SHADOW_HIGHLIGHT,this._pluginInput,e)),this._renderPlugins.produces(Z.HIGHLIGHT)&&(this._pluginInput.composite=null,this._pluginInput.normal=null,this._pluginInput.highlight=s,this._renderPlugins.render(Z.HIGHLIGHT,this._pluginInput,e)),s.release()}get _needsShadowCast(){return this._shadowAccumulator.isAccumulating}_renderShadowAccumulation(e,r,t){this._needsShadowCast&&this._bindParameters.linearDepth?.colorTexture&&this._shadowAccumulator.renderAccumulation(this._bindParameters.linearDepth,e,r,t)}_prepareTransparencySlots(){this._renderContext.output=D.Alpha,this._bindParameters.transparencyPassType=se.Alpha,this._prepareInternalSlots(this._materialRenderers,Z.TRANSPARENT_MATERIAL),this._renderPlugins.prepare(Z.TRANSPARENT_MATERIAL),this._renderContext.output=D.Color,this._bindParameters.transparencyPassType=se.Color,this._prepareInternalSlots(this._materialRenderers,Z.TRANSPARENT_MATERIAL),this._renderPlugins.prepare(Z.TRANSPARENT_MATERIAL),this._bindParameters.transparencyPassType=se.FrontFace,this._prepareInternalSlots(this._materialRenderers,Z.TRANSPARENT_MATERIAL),this._renderPlugins.prepare(Z.TRANSPARENT_MATERIAL),this._bindParameters.transparencyPassType=se.NONE}_renderOITPass(e,r=O.Both){const t=e===me.HUD,s=t?this.fboCache.acquire(C.RGBA,this._offscreen.width,this._offscreen.height):null,i=t?()=>this._renderHUDElements(r):()=>this._renderTransparentMaterial(),a=this._renderContext.output;this._renderContext.output=D.Alpha,this._bindParameters.transparencyPassType=se.Alpha;const n=this._offscreen.renderOITPass(i,se.Alpha,t);this._renderContext.output=D.Color,this._bindParameters.transparencyPassType=se.Color;const h=this._offscreen.renderOITPass(i,se.Color,t);this._bindParameters.transparencyPassType=se.FrontFace;const o=this._offscreen.renderOITPass(i,se.FrontFace,t);return this._offscreen.compositeTransparentOntoOpaque(this._bindParameters,h,n,o,s),s?.releaseDepth(),o.release(),h.release(),n.release(),this._bindParameters.transparencyPassType=se.NONE,this._renderContext.output=a,s}_renderOccluded(){let e=0;Te.clear(),this._materialRenderers.forAll((r=>{r.material&&r.material.isVisible()&&r.material.parameters.renderOccluded===k.OccludeAndTransparentStencil&&(e|=r.material.parameters.renderOccluded,Te.push(r))}));const r=this._offscreen,t=(t,s,i,a,n)=>{if(0==(e&s))return;const{width:h,height:o,depth:d}=r,l=this.fboCache.acquire(C.RGBA,h,o);r.renderToTargets(i,l,d,[0,0,0,0],a,n),r.compositeToFramebuffer(this._bindParameters,l.colorTexture,he.PremultipliedAlpha,t),l.release()};0!==Te.length&&(this._prepareInternalSlots(Te,Z.OCCLUDER_MATERIAL,Z.TRANSPARENT_OCCLUDER_MATERIAL),this._renderInternalSlot(Z.OCCLUDER_MATERIAL,Te),t(.5,k.OccludeAndTransparentStencil,(()=>this._renderInternalSlot(Z.TRANSPARENT_OCCLUDER_MATERIAL,Te)),!1,!1)),Te.clear(),this._materialRenderers.forAll((r=>{r.material&&r.material.isVisible()&&(r.material.parameters.renderOccluded===k.OccludeAndTransparent||r.material.parameters.renderOccluded===k.Transparent||r.material.parameters.renderOccluded===k.Opaque)&&(e|=r.material.parameters.renderOccluded,Te.push(r))}));const s=this._renderPlugins.renderOccludedFlags;if(e|=s,!e)return;const i=e=>{this._renderContext.renderOccludedMask=e,this._prepareInternalSlots(Te,Z.OPAQUE_MATERIAL,Z.TRANSPARENT_MATERIAL,Z.TRANSPARENT_DEPTH_WRITE_DISABLED_MATERIAL),s>k.Occlude&&this._renderPlugins.render(Z.OCCLUDED_TERRAIN),this._renderInternalSlot(Z.OPAQUE_MATERIAL,Te),this._renderInternalSlot(Z.TRANSPARENT_MATERIAL,Te),this._renderInternalSlot(Z.TRANSPARENT_DEPTH_WRITE_DISABLED_MATERIAL,Te),this._renderContext.resetRenderOccludedMask()};this._renderContext.output=D.Color,t(.5,k.OccludeAndTransparent,(()=>i(k.OccludeAndTransparent)),!0,j.OutlineVisualElementMask),t(.5,k.Transparent,(()=>i(k.Transparent)),!0,j.OutlineVisualElementMask),t(1,k.Opaque,(()=>i(k.Opaque)),!0,j.OutlineVisualElementMask),Te.clear()}_renderComposite(e,r){this._renderPlugins.consumes(D.CompositeColor)&&(this._pluginInput.composite=r);let t=null;const s=this._renderPlugins.produces(Z.COMPOSITE);s&&(t=this._renderPlugins.renderComposition(Z.COMPOSITE,this._pluginInput),this._pluginInput.composite=t);const i=this._renderPlugins.produces(Z.ANTIALIASING),a=this._renderPlugins.render(i?Z.ANTIALIASING:Z.BLIT,this._pluginInput,e);return s&&t?.release(),a}_prepare(e,r){this._needsTransparentPass=this._materialRenderers.some((e=>e.material.produces(Z.TRANSPARENT_MATERIAL,D.Color))),this._bindParameters.camera=e,this._bindParameters.contentCamera=r}_ensureBindParameters(e,r){this._bindParameters.camera=e,this._bindParameters.contentCamera=r;const t=this._renderContext.offscreenRenderingHelper;this._bindParameters.mainColor=t.colorTexture,this._bindParameters.mainDepth=t.depthTexture}_ensureBindParametersSSR(e){if(this._bindParameters.ssr.lastFrameColor){null==this._ssrEnableTime&&(this._ssrEnableTime=e),this._renderContext.lastFrameCamera.equals(this._bindParameters.camera)?this._reprojectionMatrix=g:(m(Pe,this._bindParameters.camera.viewMatrix),m(Ae,this._bindParameters.camera.projectionMatrix),f(Re,Pe,Ae),f(Re,this._renderContext.lastFrameCamera.viewMatrix,Re),f(Re,this._renderContext.lastFrameCamera.projectionMatrix,Re),this._reprojectionMatrix=Re);const r=this._stage.view.qualitySettings.fadeDuration;this._bindParameters.ssr.fadeFactor=r>0?Math.min(r,e-this._ssrEnableTime)/r:1,this._bindParameters.ssr.fadeFactor<1&&this._requestRender()}else this._reprojectionMatrix=g,this._ssrEnableTime=null}_shouldRenderInternalSlot(e,r){return this._bindParameters.slot=r,e.some((e=>null!=e.prepareTechnique(this._renderContext)))}_prepareInternalSlots(e,...r){for(const t of r)this._bindParameters.slot=t,e.forAll((e=>null!=e.prepareTechnique(this._renderContext)))}_renderInternalSlot(e,r=this._materialRenderers){this._bindParameters.slot=e,r.forAll((e=>{const r=e.prepareTechnique(this._renderContext);r&&e.renderNode(this._renderContext,r)}))}get memoryInfo(){return{fbos:this.fboCache.usedMemory,vaos:this._materialRenderers.reduce(((e,r)=>e+r.usedMemory),0),plugins:this._renderPlugins.usedMemory}}getMemoryForMaterial(e){if(null==e)return 0;const r=this._materialRenderers.find((r=>r.material===e));return r?.usedMemory??0}get usedMemory(){return this.fboCache.usedMemory+(this.edgeView?.usedMemory??0)+this._renderPlugins.usedMemory}get test(){const e=this;return{offscreen:this._offscreen,shadowMap:this._shadowMap,highlight:this._highlight,lighting:this._bindParameters.lighting,materialRenderers:this._materialRenderers,shadowAccumulator:this._shadowAccumulator,weatherIsFading:this._bindParameters.cloudsFade.isFading,resetRenderStateFeatures:()=>{e._renderStateFeatures=J(),this._renderPlugins.renderFeatureChanged(),this._requestRender()},releaseGeometryLinearDepth(r){e._releaseGeometryLinearDepth=r??(e=>e?.release()),e._geometryLinearDepthFormat=r?I.DEPTH_STENCIL_TEXTURE:I.DEPTH16_BUFFER},getFramebufferTexture:r=>{switch(r){case fe.Color:return e._offscreen.colorTexture;case fe.LinearDepth:return e._bindParameters.linearDepth?.colorTexture;case fe.ShadowMap:return e._shadowMap.depthTexture;case fe.HudVisibility:return e._bindParameters.hudVisibility?.colorTexture}}}}};var me,fe;e([p()],ce.prototype,"_renderPlugins",void 0),e([p()],ce.prototype,"_shadowAccumulator",void 0),e([p()],ce.prototype,"_state",void 0),e([p()],ce.prototype,"_renderStateFeatures",void 0),e([p({readOnly:!0})],ce.prototype,"fullResolutionAtmosphere",null),e([p()],ce.prototype,"_smaa",void 0),e([p()],ce.prototype,"_blit",void 0),e([p({autoDestroy:!0})],ce.prototype,"_edgeView",void 0),e([p()],ce.prototype,"updating",null),e([p()],ce.prototype,"isCameraFinal",null),ce=e([u("esri.views.3d.webgl-engine.lib.Renderer")],ce),function(e){e[e.Geometry=0]="Geometry",e[e.HUD=1]="HUD"}(me||(me={})),function(e){e[e.Color=0]="Color",e[e.LinearDepth=1]="LinearDepth",e[e.ShadowMap=2]="ShadowMap",e[e.HudVisibility=3]="HudVisibility"}(fe||(fe={}));const ge=[0,0,0,0],Te=new h,Ae=T(),Pe=T(),Re=T();function Ee(e){return r=>e.immediate.schedule(r)}export{fe as FramebufferId,ce as Renderer};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../core/Accessor.js";import i from"../../core/Evented.js";import{clone as n}from"../../core/lang.js";import{destroyMaybe as o,equalsMaybe as r}from"../../core/maybe.js";import{ignoreAbortErrors as s}from"../../core/promiseUtils.js";import{watch as a,syncAndInitial as p}from"../../core/reactiveUtils.js";import{createScreenPoint as c}from"../../core/screenUtils.js";import{property as l}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import{subclass as d}from"../../core/accessorSupport/decorators/subclass.js";import{diff as h}from"../../core/accessorSupport/diffUtils.js";import{UpdatingHandles as g}from"../../core/support/UpdatingHandles.js";import{pointEquals as u}from"../../layers/graphics/dehydratedFeatureComparison.js";import{getEffectiveElevationInfo as m}from"../../support/elevationInfoUtils.js";import{ViewingMode as v}from"../ViewingMode.js";import{defaultDrawingMode as y}from"./DrawingMode.js";import{DrawManipulator as _}from"./DrawManipulator.js";import{createCoordinateHelper as f}from"../interactive/coordinateHelper.js";import{createManipulatorDragEventPipeline as x,sceneSnappingAtLocation as S}from"../interactive/dragEventPipeline.js";import{EditGeometry as w,Component as V}from"../interactive/editGeometry/EditGeometry.js";import{EditGeometryOperations as O}from"../interactive/editGeometry/EditGeometryOperations.js";import{fromPoint as T,toDehydratedPoint as b}from"../interactive/sketch/normalizedPoint.js";import M from"../interactive/sketch/SketchLabelOptions.js";import C from"../interactive/sketch/SketchTooltipOptions.js";import{SnappingContext as P}from"../interactive/snapping/SnappingContext.js";import{createSnapDragEventPipelineStep as D}from"../interactive/snapping/SnappingDragPipelineStep.js";import{SnappingOperation as I}from"../interactive/snapping/SnappingOperation.js";import{setupSnappingToggleHandles as E}from"../interactive/snapping/snappingUtils.js";const H="crosshair",j="progress";let k=class extends(i.EventedMixin(t)){constructor(e){super(e),this._createOperationCompleted=!1,this._hideDefaultCursor=!1,this._pointerDownStates=new Set,this._stagedScreenPoint=null,this._stagedPointerType=null,this._stagedPointerId=null,this._updatingHandles=new g,this.constraint=void 0,this.isDraped=!0,this.labelOptions=new M,this.tooltipOptions=new C,this.cursor=null,this.loading=!1,this.snapToSceneEnabled=null,this.lastVertex=null,null==e.elevationInfo&&(this.elevationInfo=m(!!e.hasZ))}initialize(){const{geometryType:e,view:t}=this,i=t.spatialReference,n="viewingMode"in t.state?t.state.viewingMode:v.Local,o="segment"===e||"multipoint"===e?"polyline":e;this.coordinateHelper=f(this.hasZ,this.hasM,i),this._editGeometryOperations=new O(new w(o,this.coordinateHelper)),this._snappingOperation=new I({view:t,constrainResult:e=>e?this._getEffectiveDrawSurface()?.constrainZ(e):void 0}),this.addHandles([a((()=>this.stagedVertex),(e=>{null!=e&&this.emit("cursor-update",{updated:null,vertices:[{componentIndex:0,vertexIndex:this._activeComponent.vertices.length,coordinates:this.coordinateHelper.pointToArray(e)}],operation:"apply",type:"vertex-update"})}),{sync:!0,equals:(e,t)=>r(e,t,u)}),a((()=>this.view.viewpoint),((e,t)=>{e&&t&&h(e,t)&&this._onViewpointChange()}))]),this._activeComponent=new V(i,n),this._editGeometryOperations.data.components.push(this._activeComponent);const c=this.segmentLabels;null!=c&&(c.context={view:t,editGeometryOperations:this._editGeometryOperations,elevationInfo:this.elevationInfo,labelOptions:this.labelOptions},this.addHandles([a((()=>this.labelOptions.enabled),(e=>{c.visible=e}),p),this.on("cursor-update",(()=>{const e=this.stagedVertex;c.stagedVertex=null!=e?this.coordinateHelper.pointToVector(e):null}))])),this.addHandles(this._editGeometryOperations.on(["vertex-add","vertex-update","vertex-remove"],(e=>{const t=e.vertices.map((e=>({componentIndex:0,vertexIndex:e.index,coordinates:this.coordinateHelper.vectorToArray(e.pos)}))),i=t.map((e=>e.coordinates));switch(e.type){case"vertex-add":this.emit(e.type,{...e,added:i,vertices:t});break;case"vertex-update":this.emit(e.type,{...e,updated:i,vertices:t});break;case"vertex-remove":this.emit(e.type,{...e,removed:i,vertices:t})}const n=this._activeComponent.getLastVertex(),o=null!=n?this.coordinateHelper.vectorToDehydratedPoint(n.pos):null;null!=o&&null!=this.lastVertex&&u(this.lastVertex,o)||(this.lastVertex=o)})));const l=this._manipulator=new _({grabbableForEvent:e=>"click"!==this.drawingMode||"touch"===e.pointerType&&this._snappingEnabled&&1===this._pointerDownStates.size});this.manipulators.add(l),l.grabbable="point"!==e,this.addHandles([this._createManipulatorDragPipeline(l),l.events.on("immediate-click",(e=>this._onImmediateClick(e))),l.events.on("immediate-double-click",(e=>this._onImmediateDoubleClick(e))),a((()=>({effectiveCursor:this.effectiveCursor})),(({effectiveCursor:e})=>{l.cursor=e}),p)]),E(this,(()=>{const e=this.view.inputManager.latestPointerType??"mouse",t=this._getSnappingContext(e);null!=this.snappingManager&&this._updatingHandles.addPromise(s(this._snappingOperation.resnap(this.snappingManager,t)))}))}destroy(){o(this.segmentLabels),o(this._snappingOperation),this._editGeometryOperations=o(this._editGeometryOperations),this._updatingHandles.destroy()}get _snappingEnabled(){return null!=this.snappingManager&&this.snappingManager.options.effectiveEnabled}get _requiresScenePoint(){const e=this._getEffectiveDrawSurface();return"3d"===this.view.type&&this.drawSurface!==e}get canRedo(){return this._editGeometryOperations.canRedo}get canUndo(){return this._editGeometryOperations.canUndo}get committedVertices(){return this._activeComponent.vertices.map((e=>this.coordinateHelper.vectorToArray(e.pos)))}set drawingMode(e){this._set("drawingMode",e??y)}get effectiveCursor(){return this.loading?j:this._hideDefaultCursor?null:this.cursor||H}get interactive(){return this._manipulator.interactive}set interactive(e){this._manipulator.interactive=e}get isCompleted(){return this._createOperationCompleted}get numCommittedVertices(){return this._activeComponent.vertices.length}get numVertices(){return null!=this.stagedVertex?this._activeComponent.vertices.length+1:this._activeComponent.vertices.length}get snappingOptions(){return null!=this.snappingManager?this.snappingManager.options:null}get stagedVertex(){const e=this._snappingOperation.stagedPoint,{constraint:t,elevationInfo:i,view:n}=this;if(!e||!t)return e;const o=T(e,n,i),r=o?t.closestTo(o):void 0;return r?b(r,e.spatialReference):e}set stagedVertex(e){this._snappingOperation.stagedPoint=n(e)}get updating(){return this._updatingHandles.updating}get vertices(){const e=this.committedVertices;return null!=this.stagedVertex&&e.push(this.coordinateHelper.pointToArray(this.stagedVertex)),e}cancel(){this.complete({aborted:!0})}commitStagedVertex(){if(this._snappingOperation.abort(),null!=this.stagedVertex){const{stagedVertex:e}=this;this.stagedVertex=null,this._editGeometryOperations.appendVertex(this.coordinateHelper.pointToVector(e))}}complete(e){const t=e&&e.aborted||!1;this._snappingOperation.abort(),null!=this.snappingManager&&this.snappingManager.doneSnapping(),"segment"===this.geometryType||"point"===this.geometryType?this.commitStagedVertex():this.stagedVertex=null;const i="multipoint"===this.geometryType&&0===this.numVertices||"polyline"===this.geometryType&&this.numVertices<2||"polygon"===this.geometryType&&this.numVertices<3;this._createOperationCompleted=!i,(this.isCompleted||t)&&this.emit("complete",{vertices:this.vertices.map(((e,t)=>({componentIndex:0,vertexIndex:t,coordinates:e}))),aborted:t,type:"complete"})}onInputEvent(e){switch(e.type){case"pointer-down":this._pointerDownStates.add(e.pointerId);break;case"pointer-up":this._pointerDownStates.delete(e.pointerId)}switch(e.type){case"pointer-move":return this._onPointerMove(e);case"hold":return this._onHold(e)}}redo(){this._editGeometryOperations.redo()}undo(){null!=this.snappingManager&&this.snappingManager.doneSnapping(),this._editGeometryOperations.undo()}_closeOnClickVertexIndex(e){const t=this._activeComponent;if("polygon"===this.geometryType&&t.vertices.length>2){if(this._vertexWithinPointerDistance(t.vertices[0].pos,e))return 0;if(this._vertexWithinPointerDistance(t.vertices[t.vertices.length-1].pos,e))return t.vertices.length-1}return null}_createManipulatorDragPipeline(e){switch(this.drawingMode){case"click":return this._createManipulatorDragPipelineClick(e);case"freehand":return this._createManipulatorDragPipelineFreehand(e);case"hybrid":return this._createManipulatorDragPipelineHybrid(e)}}_createManipulatorDragPipelineClick(e){return x(e,((e,t,i,n)=>{const o="touch"===n&&this._snappingEnabled;if(this.isCompleted||!o)return;const{snappingStep:r,cancelSnapping:s}=D({predicate:()=>o,snappingManager:this.snappingManager,snappingContext:new P({editGeometryOperations:this._editGeometryOperations,elevationInfo:this.elevationInfo,feature:this.graphic,pointer:n,visualizer:this.snappingVisualizer}),updatingHandles:this._updatingHandles,useZ:!this._requiresScenePoint});i=i.next((e=>(o&&null!=this.snappingManager&&this.snappingManager.doneSnapping(),e))).next(s),t.next(this._screenToMapDragEventStep()).next((e=>("start"===e.action&&(this.stagedVertex=e.mapStart,("segment"===this.geometryType||o&&0===this.numVertices)&&this.commitStagedVertex()),e))).next(S(this.view,this.elevationInfo)).next(...r).next((e=>(o&&(this.stagedVertex=e.mapEnd,"end"===e.action&&this.commitStagedVertex()),e))).next((e=>("end"===e.action&&("segment"!==this.geometryType&&"point"!==this.geometryType||this.complete()),e)))}))}_createManipulatorDragPipelineFreehand(e){return x(e,((e,t)=>{this.isCompleted||t.next(this._screenToMapDragEventStep()).next((e=>("start"===e.action&&(null==this.stagedVertex&&(this.stagedVertex=e.mapStart),"segment"===this.geometryType&&this.commitStagedVertex()),e))).next((e=>{switch(e.action){case"start":case"update":this.stagedVertex=e.mapEnd,"polygon"!==this.geometryType&&"polyline"!==this.geometryType||this.commitStagedVertex();break;case"end":this.complete()}return e}))}))}_createManipulatorDragPipelineHybrid(e){return x(e,((e,t)=>{this.isCompleted||t.next(this._screenToMapDragEventStep()).next((e=>("start"===e.action&&(null==this.stagedVertex&&(this.stagedVertex=e.mapStart),this.commitStagedVertex()),e))).next((e=>{switch(e.action){case"start":case"update":this.stagedVertex=e.mapEnd,"polygon"!==this.geometryType&&"polyline"!==this.geometryType||this.commitStagedVertex();break;case"end":"segment"!==this.geometryType&&"point"!==this.geometryType||this.complete()}return e}))}))}get _drawAtFixedElevation(){return("segment"===this.geometryType||"polygon"===this.geometryType)&&this.numCommittedVertices>0}_getEffectiveDrawSurface(){if(null==this.elevationDrawSurface)return this.drawSurface;if(!this.coordinateHelper.hasZ())return this.elevationDrawSurface.defaultZ=null,this.elevationDrawSurface;let e=this.defaultZ,t=!1;return null!=this.elevationInfo&&"absolute-height"===this.elevationInfo.mode&&(t=!0),null!=this.snapToSceneEnabled&&(t=this.snapToSceneEnabled),null!=this.elevationInfo&&"on-the-ground"===this.elevationInfo.mode&&(t=!1),this._drawAtFixedElevation&&(e=this.coordinateHelper.getZ(this._activeComponent.vertices[0].pos),t=!1),t?this.drawSurface:(this.elevationDrawSurface.defaultZ=e,this.elevationDrawSurface)}_mapToScreen(e){return this._getEffectiveDrawSurface()?.mapToScreen(e)}_onHold(e){this._snappingOperation.abort(),"click"===this.drawingMode&&"touch"===e.pointerType&&this._snappingEnabled&&(this.stagedVertex=e.mapPoint),e.stopPropagation()}_onImmediateClick(e){if("mouse"===e.pointerType&&2===e.button||this._manipulator.dragging)return;const t=this._activeComponent;if(null!=this._closeOnClickVertexIndex(e.screenPoint))return e.stopPropagation(),void this.complete();const i=this._screenToMap(e.screenPoint);if(null!=i)switch(this.drawingMode){case"freehand":"point"===this.geometryType&&(null!=this.stagedVertex?this.commitStagedVertex():this._editGeometryOperations.appendVertex(this.coordinateHelper.pointToVector(i)),this.complete());break;case"click":case"hybrid":this._snappingOperation.abort(),null!=this.stagedVertex?this.commitStagedVertex():this._editGeometryOperations.appendVertex(this.coordinateHelper.pointToVector(i)),("point"===this.geometryType||"segment"===this.geometryType&&2===t.vertices.length||"segment"===this.geometryType&&"hybrid"===this.drawingMode&&1===t.vertices.length)&&this.complete()}e.stopPropagation()}_onImmediateDoubleClick(e){this._manipulator.dragging||"point"===this.geometryType||(this.complete(),e.stopPropagation())}_onPointerMove(e){const t=c(e.x,e.y);this._stagedScreenPoint=t,this._stagedPointerType=e.pointerType,this._stagedPointerId=e.pointerId;const i=this._snappingOperation,n=this._manipulator;this._pointerDownStates.has(e.pointerId)||n.grabbing||!n.interactive?i.abort():(e.stopPropagation(),this._updateStagedVertexOnPointerMove(t,e.pointerType))}_onViewpointChange(){const e=this._manipulator;this._stagedScreenPoint&&null!=this._stagedPointerId&&!this._pointerDownStates.has(this._stagedPointerId)&&!e.grabbing&&e.interactive?this._updateStagedVertexOnPointerMove(this._stagedScreenPoint,this._stagedPointerType??"mouse"):this._snappingOperation.abort()}_updateStagedVertexOnPointerMove(e,t){const i=this._snappingOperation,n=this._closeOnClickVertexIndex(e);if(null!=n)return this._closeOnVertex(n),void i.abort();const o=this._screenToMap(e),r=this._requiresScenePoint?this.drawSurface?.screenToMap(e):null;if(null==o)return this._hideDefaultCursor=!0,void i.abort();this._hideDefaultCursor=!1;const a=this.snappingManager;if(null==a)return this.stagedVertex=o,void i.abort();const p=this._getSnappingContext(t);this._updatingHandles.addPromise(s(i.snap({point:o,scenePoint:r},a,p)))}_closeOnVertex(e){this.stagedVertex=null;const t={componentIndex:0,vertexIndex:e,coordinates:this.coordinateHelper.vectorToArray(this._activeComponent.vertices[e].pos)};this.emit("cursor-update",{updated:null,vertices:[t],operation:"apply",type:"vertex-update"})}_screenToMap(e){return this._getEffectiveDrawSurface()?.screenToMap(e)}_screenToMapDragEventStep(){let e=null;return t=>{if("start"===t.action&&(e=this._screenToMap(t.screenStart)),null==e)return null;const i=this._screenToMap(t.screenEnd);return null!=i?{...t,mapStart:e,mapEnd:i}:null}}_vertexWithinPointerDistance(e,t){const i=25,n=this._mapToScreen(this.coordinateHelper.vectorToDehydratedPoint(e));return null!=n&&G(n,t,i)}_getSnappingContext(e){const t=this._drawAtFixedElevation?this.elevationDrawSurface?.defaultZ:null;return new P({editGeometryOperations:this._editGeometryOperations,elevationInfo:this.elevationInfo,pointer:e,feature:this.graphic,visualizer:this.snappingVisualizer,selfSnappingZ:null!=t?{value:t,elevationInfo:this.elevationInfo}:null})}};function G(e,t,i){const n=e.x-t.x,o=e.y-t.y;return n*n+o*o<=i}e([l()],k.prototype,"_hideDefaultCursor",void 0),e([l()],k.prototype,"_snappingOperation",void 0),e([l()],k.prototype,"_snappingEnabled",null),e([l({constructOnly:!0})],k.prototype,"graphic",void 0),e([l()],k.prototype,"constraint",void 0),e([l()],k.prototype,"defaultZ",void 0),e([l()],k.prototype,"isDraped",void 0),e([l({value:y})],k.prototype,"drawingMode",null),e([l({constructOnly:!0})],k.prototype,"elevationDrawSurface",void 0),e([l({constructOnly:!0})],k.prototype,"elevationInfo",void 0),e([l({constructOnly:!0,type:M})],k.prototype,"labelOptions",void 0),e([l({constructOnly:!0,type:C})],k.prototype,"tooltipOptions",void 0),e([l({constructOnly:!0})],k.prototype,"geometryType",void 0),e([l({constructOnly:!0})],k.prototype,"hasM",void 0),e([l({constructOnly:!0})],k.prototype,"hasZ",void 0),e([l()],k.prototype,"cursor",void 0),e([l()],k.prototype,"effectiveCursor",null),e([l()],k.prototype,"loading",void 0),e([l({constructOnly:!0})],k.prototype,"manipulators",void 0),e([l({constructOnly:!0})],k.prototype,"drawSurface",void 0),e([l({constructOnly:!0})],k.prototype,"segmentLabels",void 0),e([l({constructOnly:!0})],k.prototype,"snappingManager",void 0),e([l({constructOnly:!0})],k.prototype,"snappingVisualizer",void 0),e([l()],k.prototype,"snapToSceneEnabled",void 0),e([l()],k.prototype,"stagedVertex",null),e([l()],k.prototype,"lastVertex",void 0),e([l()],k.prototype,"updating",null),e([l({constructOnly:!0})],k.prototype,"view",void 0),k=e([d("esri.views.draw.DrawOperation")],k);export{k as DrawOperation,H as defaultCursor,j as defaultLoadingCursor};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../core/Accessor.js";import i from"../../core/Evented.js";import{clone as n}from"../../core/lang.js";import{destroyMaybe as o,equalsMaybe as r}from"../../core/maybe.js";import{ignoreAbortErrors as s}from"../../core/promiseUtils.js";import{watch as a,syncAndInitial as p}from"../../core/reactiveUtils.js";import{createScreenPoint as c}from"../../core/screenUtils.js";import{property as l}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import{subclass as d}from"../../core/accessorSupport/decorators/subclass.js";import{diff as h}from"../../core/accessorSupport/diffUtils.js";import{UpdatingHandles as g}from"../../core/support/UpdatingHandles.js";import{pointEquals as u}from"../../layers/graphics/dehydratedFeatureComparison.js";import{getEffectiveElevationInfo as m}from"../../support/elevationInfoUtils.js";import{ViewingMode as v}from"../ViewingMode.js";import{defaultDrawingMode as y}from"./DrawingMode.js";import{DrawManipulator as _}from"./DrawManipulator.js";import{createCoordinateHelper as f}from"../interactive/coordinateHelper.js";import{createManipulatorDragEventPipeline as x,sceneSnappingAtLocation as S}from"../interactive/dragEventPipeline.js";import{EditGeometry as w,Component as V}from"../interactive/editGeometry/EditGeometry.js";import{EditGeometryOperations as O}from"../interactive/editGeometry/EditGeometryOperations.js";import{fromPoint as T,toDehydratedPoint as b}from"../interactive/sketch/normalizedPoint.js";import M from"../interactive/sketch/SketchLabelOptions.js";import P from"../interactive/sketch/SketchTooltipOptions.js";import{SnappingContext as C}from"../interactive/snapping/SnappingContext.js";import{createSnapDragEventPipelineStep as D}from"../interactive/snapping/SnappingDragPipelineStep.js";import{SnappingOperation as I}from"../interactive/snapping/SnappingOperation.js";import{setupSnappingToggleHandles as E}from"../interactive/snapping/snappingUtils.js";const H="crosshair",j="progress";let k=class extends(i.EventedMixin(t)){constructor(e){super(e),this._createOperationCompleted=!1,this._hideDefaultCursor=!1,this._pointerDownStates=new Set,this._stagedScreenPoint=null,this._stagedPointerType=null,this._stagedPointerId=null,this._updatingHandles=new g,this.constraint=void 0,this.isDraped=!0,this.labelOptions=new M,this.tooltipOptions=new P,this.cursor=null,this.loading=!1,this.snapToSceneEnabled=null,this.lastVertex=null,null==e.elevationInfo&&(this.elevationInfo=m(!!e.hasZ))}initialize(){const{geometryType:e,view:t}=this,i=t.spatialReference,n="viewingMode"in t.state?t.state.viewingMode:v.Local,o="segment"===e||"multipoint"===e?"polyline":e;this.coordinateHelper=f(this.hasZ,this.hasM,i),this._editGeometryOperations=new O(new w(o,this.coordinateHelper)),this._snappingOperation=new I({view:t,constrainResult:e=>e?this._getEffectiveDrawSurface()?.constrainZ(e):void 0}),this.addHandles([a((()=>this.stagedVertex),(e=>{null!=e&&this.emit("cursor-update",{updated:null,vertices:[{componentIndex:0,vertexIndex:this._activeComponent.vertices.length,coordinates:this.coordinateHelper.pointToArray(e)}],operation:"apply",type:"vertex-update"})}),{sync:!0,equals:(e,t)=>r(e,t,u)}),a((()=>this.view.viewpoint),((e,t)=>{e&&t&&h(e,t)&&this._onViewpointChange()}))]),this._activeComponent=new V(i,n),this._editGeometryOperations.data.components.push(this._activeComponent);const c=this.segmentLabels;null!=c&&(c.context={view:t,editGeometryOperations:this._editGeometryOperations,elevationInfo:this.elevationInfo,labelOptions:this.labelOptions},this.addHandles([a((()=>this.labelOptions.enabled),(e=>{c.visible=e}),p),this.on("cursor-update",(()=>{const e=this.stagedVertex;c.stagedVertex=null!=e?this.coordinateHelper.pointToVector(e):null}))])),this.addHandles(this._editGeometryOperations.on(["vertex-add","vertex-update","vertex-remove"],(e=>{const t=e.vertices.map((e=>({componentIndex:0,vertexIndex:e.index,coordinates:this.coordinateHelper.vectorToArray(e.pos)}))),i=t.map((e=>e.coordinates));switch(e.type){case"vertex-add":this.emit(e.type,{...e,added:i,vertices:t});break;case"vertex-update":this.emit(e.type,{...e,updated:i,vertices:t});break;case"vertex-remove":this.emit(e.type,{...e,removed:i,vertices:t})}const n=this._activeComponent.getLastVertex(),o=null!=n?this.coordinateHelper.vectorToDehydratedPoint(n.pos):null;null!=o&&null!=this.lastVertex&&u(this.lastVertex,o)||(this.lastVertex=o)})));const l=this._manipulator=new _({grabbableForEvent:e=>"click"!==this.drawingMode||"touch"===e.pointerType&&this._snappingEnabled&&1===this._pointerDownStates.size});this.manipulators.add(l),l.grabbable="point"!==e,this.addHandles([this._createManipulatorDragPipeline(l),l.events.on("immediate-click",(e=>this._onImmediateClick(e))),l.events.on("immediate-double-click",(e=>this._onImmediateDoubleClick(e))),a((()=>({effectiveCursor:this.effectiveCursor})),(({effectiveCursor:e})=>{l.cursor=e}),p)]),E(this,(()=>{const e=this.view.inputManager.latestPointerType??"mouse",t=this._getSnappingContext(e);null!=this.snappingManager&&this._updatingHandles.addPromise(s(this._snappingOperation.resnap(this.snappingManager,t)))}))}destroy(){o(this.segmentLabels),o(this._snappingOperation),this._editGeometryOperations=o(this._editGeometryOperations),this._updatingHandles.destroy()}get _snappingEnabled(){return null!=this.snappingManager&&this.snappingManager.options.effectiveEnabled}get _requiresScenePoint(){const e=this._getEffectiveDrawSurface();return"3d"===this.view.type&&this.drawSurface!==e}get canRedo(){return this._editGeometryOperations.canRedo}get canUndo(){return this._editGeometryOperations.canUndo}get committedVertices(){return this._activeComponent.vertices.map((e=>this.coordinateHelper.vectorToArray(e.pos)))}set drawingMode(e){this._set("drawingMode",e??y)}get effectiveCursor(){return this.loading?j:this._hideDefaultCursor?null:this.cursor||H}get interactive(){return this._manipulator.interactive}set interactive(e){this._manipulator.interactive=e}get isCompleted(){return this._createOperationCompleted}get numCommittedVertices(){return this._activeComponent.vertices.length}get numVertices(){return null!=this.stagedVertex?this._activeComponent.vertices.length+1:this._activeComponent.vertices.length}get snappingOptions(){return null!=this.snappingManager?this.snappingManager.options:null}get stagedVertex(){const e=this._snappingOperation.stagedPoint,{constraint:t,elevationInfo:i,view:n}=this;if(!e||!t)return e;const o=T(e,n,i),r=o?t.closestTo(o):void 0;return r?b(r,e.spatialReference):e}set stagedVertex(e){this._snappingOperation.stagedPoint=n(e)}get updating(){return this._updatingHandles.updating}get vertices(){const e=this.committedVertices;return null!=this.stagedVertex&&e.push(this.coordinateHelper.pointToArray(this.stagedVertex)),e}cancel(){this.complete({aborted:!0})}commitStagedVertex(){if(this._snappingOperation.abort(),null!=this.stagedVertex){const{stagedVertex:e}=this;this.stagedVertex=null,this._editGeometryOperations.appendVertex(this.coordinateHelper.pointToVector(e))}}complete(e){const t=e&&e.aborted||!1;this._snappingOperation.abort(),null!=this.snappingManager&&this.snappingManager.doneSnapping(),"segment"===this.geometryType||"point"===this.geometryType?this.commitStagedVertex():this.stagedVertex=null;const i="multipoint"===this.geometryType&&0===this.numVertices||"polyline"===this.geometryType&&this.numVertices<2||"polygon"===this.geometryType&&this.numVertices<3;this._createOperationCompleted=!i,(this.isCompleted||t)&&this.emit("complete",{vertices:this.vertices.map(((e,t)=>({componentIndex:0,vertexIndex:t,coordinates:e}))),aborted:t,type:"complete"})}onInputEvent(e){switch(e.type){case"pointer-down":this._pointerDownStates.add(e.pointerId);break;case"pointer-up":this._pointerDownStates.delete(e.pointerId)}switch(e.type){case"pointer-move":return this._onPointerMove(e);case"hold":return this._onHold(e)}}redo(){this._editGeometryOperations.redo()}undo(){null!=this.snappingManager&&this.snappingManager.doneSnapping(),this._editGeometryOperations.undo()}_closeOnClickVertexIndex(e){const t=this._activeComponent;if("polygon"===this.geometryType&&t.vertices.length>2){if(this._vertexWithinPointerDistance(t.vertices[0].pos,e))return 0;if(this._vertexWithinPointerDistance(t.vertices[t.vertices.length-1].pos,e))return t.vertices.length-1}return null}_createManipulatorDragPipeline(e){switch(this.drawingMode){case"click":return this._createManipulatorDragPipelineClick(e);case"freehand":return this._createManipulatorDragPipelineFreehand(e);case"hybrid":return this._createManipulatorDragPipelineHybrid(e)}}_createManipulatorDragPipelineClick(e){return x(e,((e,t,i,n)=>{const o="touch"===n&&this._snappingEnabled;if(this.isCompleted||!o)return;const{snappingStep:r,cancelSnapping:s}=D({predicate:()=>o,snappingManager:this.snappingManager,snappingContext:new C({editGeometryOperations:this._editGeometryOperations,elevationInfo:this.elevationInfo,feature:this.graphic,pointer:n,visualizer:this.snappingVisualizer}),updatingHandles:this._updatingHandles,useZ:!this._requiresScenePoint});i=i.next((e=>(o&&null!=this.snappingManager&&this.snappingManager.doneSnapping(),e))).next(s),t.next(this._screenToMapDragEventStep()).next((e=>("start"===e.action&&(this.stagedVertex=e.mapStart,("segment"===this.geometryType||o&&0===this.numVertices)&&this.commitStagedVertex()),e))).next(S(this.view,this.elevationInfo)).next(...r).next((e=>(o&&(this.stagedVertex=e.mapEnd,"end"===e.action&&this.commitStagedVertex()),e))).next((e=>("end"===e.action&&("segment"!==this.geometryType&&"point"!==this.geometryType||this.complete()),e)))}))}_createManipulatorDragPipelineFreehand(e){return x(e,((e,t)=>{this.isCompleted||t.next(this._screenToMapDragEventStep()).next((e=>("start"===e.action&&(null==this.stagedVertex&&(this.stagedVertex=e.mapStart),"segment"===this.geometryType&&this.commitStagedVertex()),e))).next((e=>{switch(e.action){case"start":case"update":this.stagedVertex=e.mapEnd,"polygon"!==this.geometryType&&"polyline"!==this.geometryType||this.commitStagedVertex();break;case"end":this.complete()}return e}))}))}_createManipulatorDragPipelineHybrid(e){return x(e,((e,t)=>{this.isCompleted||t.next(this._screenToMapDragEventStep()).next((e=>("start"===e.action&&(null==this.stagedVertex&&(this.stagedVertex=e.mapStart),this.commitStagedVertex()),e))).next((e=>{switch(e.action){case"start":case"update":this.stagedVertex=e.mapEnd,"polygon"!==this.geometryType&&"polyline"!==this.geometryType||this.commitStagedVertex();break;case"end":"segment"!==this.geometryType&&"point"!==this.geometryType||this.complete()}return e}))}))}get _drawAtFixedElevation(){return("segment"===this.geometryType||"polygon"===this.geometryType)&&this.numCommittedVertices>0}_getEffectiveDrawSurface(){if(null==this.elevationDrawSurface)return this.drawSurface;if(!this.coordinateHelper.hasZ())return this.elevationDrawSurface.defaultZ=null,this.elevationDrawSurface;let e=this.defaultZ,t=!1;return null!=this.elevationInfo&&"absolute-height"===this.elevationInfo.mode&&(t=!0),null!=this.snapToSceneEnabled&&(t=this.snapToSceneEnabled),null!=this.elevationInfo&&"on-the-ground"===this.elevationInfo.mode&&(t=!1),this._drawAtFixedElevation&&(e=this.coordinateHelper.getZ(this._activeComponent.vertices[0].pos),t=!1),t?this.drawSurface:(this.elevationDrawSurface.defaultZ=e,this.elevationDrawSurface)}_mapToScreen(e){return this._getEffectiveDrawSurface()?.mapToScreen(e)}_onHold(e){this._snappingOperation.abort(),"click"===this.drawingMode&&"touch"===e.pointerType&&this._snappingEnabled&&(this.stagedVertex=e.mapPoint),e.stopPropagation()}_onImmediateClick(e){if("mouse"===e.pointerType&&2===e.button||this._manipulator.dragging)return;const t=this._activeComponent;if(null!=this._closeOnClickVertexIndex(e.screenPoint))return e.stopPropagation(),void this.complete();const i=this._screenToMap(e.screenPoint);if(null!=i)switch(this.drawingMode){case"freehand":"point"===this.geometryType&&(null!=this.stagedVertex?this.commitStagedVertex():this._editGeometryOperations.appendVertex(this.coordinateHelper.pointToVector(i)),this.complete());break;case"click":case"hybrid":this._snappingOperation.abort(),null!=this.stagedVertex?this.commitStagedVertex():this._editGeometryOperations.appendVertex(this.coordinateHelper.pointToVector(i)),("point"===this.geometryType||"segment"===this.geometryType&&2===t.vertices.length||"segment"===this.geometryType&&"hybrid"===this.drawingMode&&1===t.vertices.length)&&this.complete()}e.stopPropagation()}_onImmediateDoubleClick(e){this._manipulator.dragging||"point"===this.geometryType||(this.complete(),e.stopPropagation())}_onPointerMove(e){const t=c(e.x,e.y);this._stagedScreenPoint=t,this._stagedPointerType=e.pointerType,this._stagedPointerId=e.pointerId;const i=this._snappingOperation,n=this._manipulator;this._pointerDownStates.has(e.pointerId)||n.grabbing||!n.interactive?i.abort():(e.stopPropagation(),this._updateStagedVertexOnPointerMove(t,e.pointerType))}_onViewpointChange(){const e=this._manipulator;"mouse"===this._stagedPointerType&&this._stagedScreenPoint&&null!=this._stagedPointerId&&!this._pointerDownStates.has(this._stagedPointerId)&&!e.grabbing&&e.interactive?this._updateStagedVertexOnPointerMove(this._stagedScreenPoint,this._stagedPointerType??"mouse"):this._snappingOperation.abort()}_updateStagedVertexOnPointerMove(e,t){const i=this._snappingOperation,n=this._closeOnClickVertexIndex(e);if(null!=n)return this._closeOnVertex(n),void i.abort();const o=this._screenToMap(e),r=this._requiresScenePoint?this.drawSurface?.screenToMap(e):null;if(null==o)return this._hideDefaultCursor=!0,void i.abort();this._hideDefaultCursor=!1;const a=this.snappingManager;if(null==a)return this.stagedVertex=o,void i.abort();const p=this._getSnappingContext(t);this._updatingHandles.addPromise(s(i.snap({point:o,scenePoint:r},a,p)))}_closeOnVertex(e){this.stagedVertex=null;const t={componentIndex:0,vertexIndex:e,coordinates:this.coordinateHelper.vectorToArray(this._activeComponent.vertices[e].pos)};this.emit("cursor-update",{updated:null,vertices:[t],operation:"apply",type:"vertex-update"})}_screenToMap(e){return this._getEffectiveDrawSurface()?.screenToMap(e)}_screenToMapDragEventStep(){let e=null;return t=>{if("start"===t.action&&(e=this._screenToMap(t.screenStart)),null==e)return null;const i=this._screenToMap(t.screenEnd);return null!=i?{...t,mapStart:e,mapEnd:i}:null}}_vertexWithinPointerDistance(e,t){const i=25,n=this._mapToScreen(this.coordinateHelper.vectorToDehydratedPoint(e));return null!=n&&G(n,t,i)}_getSnappingContext(e){const t=this._drawAtFixedElevation?this.elevationDrawSurface?.defaultZ:null;return new C({editGeometryOperations:this._editGeometryOperations,elevationInfo:this.elevationInfo,pointer:e,feature:this.graphic,visualizer:this.snappingVisualizer,selfSnappingZ:null!=t?{value:t,elevationInfo:this.elevationInfo}:null})}};function G(e,t,i){const n=e.x-t.x,o=e.y-t.y;return n*n+o*o<=i}e([l()],k.prototype,"_hideDefaultCursor",void 0),e([l()],k.prototype,"_snappingOperation",void 0),e([l()],k.prototype,"_snappingEnabled",null),e([l({constructOnly:!0})],k.prototype,"graphic",void 0),e([l()],k.prototype,"constraint",void 0),e([l()],k.prototype,"defaultZ",void 0),e([l()],k.prototype,"isDraped",void 0),e([l({value:y})],k.prototype,"drawingMode",null),e([l({constructOnly:!0})],k.prototype,"elevationDrawSurface",void 0),e([l({constructOnly:!0})],k.prototype,"elevationInfo",void 0),e([l({constructOnly:!0,type:M})],k.prototype,"labelOptions",void 0),e([l({constructOnly:!0,type:P})],k.prototype,"tooltipOptions",void 0),e([l({constructOnly:!0})],k.prototype,"geometryType",void 0),e([l({constructOnly:!0})],k.prototype,"hasM",void 0),e([l({constructOnly:!0})],k.prototype,"hasZ",void 0),e([l()],k.prototype,"cursor",void 0),e([l()],k.prototype,"effectiveCursor",null),e([l()],k.prototype,"loading",void 0),e([l({constructOnly:!0})],k.prototype,"manipulators",void 0),e([l({constructOnly:!0})],k.prototype,"drawSurface",void 0),e([l({constructOnly:!0})],k.prototype,"segmentLabels",void 0),e([l({constructOnly:!0})],k.prototype,"snappingManager",void 0),e([l({constructOnly:!0})],k.prototype,"snappingVisualizer",void 0),e([l()],k.prototype,"snapToSceneEnabled",void 0),e([l()],k.prototype,"stagedVertex",null),e([l()],k.prototype,"lastVertex",void 0),e([l()],k.prototype,"updating",null),e([l({constructOnly:!0})],k.prototype,"view",void 0),k=e([d("esri.views.draw.DrawOperation")],k);export{k as DrawOperation,H as defaultCursor,j as defaultLoadingCursor};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import{isSome as t,equals as e}from"../../../core/arrayUtils.js";import{g as n,c as r,k as s}from"../../../chunks/vec2.js";import{a as i}from"../../../chunks/vec2f64.js";import{j as o,c as u,g as c,q as a,h as f,a as l,u as h,m as d,s as p,f as m,G as L}from"../../../chunks/vec3.js";import{c as k,g,f as P,d as T}from"../../../chunks/vec3f64.js";import{create as y,intersectLine as q,distance as x,isVertical as v,intersectPlanes as z,signedDistance as j,projectPoint as w,fromPositionAndNormal as E,fromPoints as A,normal as M}from"../../../geometry/support/plane.js";import{create as N}from"../../../geometry/support/ray.js";import{k as Z,l as I,p as G,m as S}from"../../../chunks/sphere.js";import{fromVec3 as O,clone as U,fromValues as b}from"./normalizedPoint.js";import{vectorsHaveCloseZ as C,isClose as F,isPointInsidePlane as H,intersectLineLikeAndCircle as R,pointsInsidePlane as Y,intersectVerticalPlaneAndVerticalCylinder as _,projectPointToLineLike as B,projectPointToVerticalCylinder as D,projectPointToVerticalPlane as J,VerticalPlaneType as K,intersectLineLikes as Q,intersectVerticalPlaneAndLineLike as V,intersectLineLikeAndVerticalCylinder as W,intersectVerticalPlanes as X,intersectVerticalCylinders as $,intersectVerticalPlaneAndPoint as tt}from"../../support/geometry3dUtils.js";import{LineType as et}from"../../support/geometry2dUtils.js";class nt{intersect(t){return zt(this,t)}closestPoints(t){return[this.closestTo(t)]}}class rt extends nt{constructor(t){super(),this.point=t}equals(t){return this===t||$t(t)&&f(this.point,t.point)}closestTo(){return U(this.point)}}class st extends nt{constructor(t,e,n){super(),this.start=t,this.end=e,this.lineLike={start:t,end:e,type:n}}equals(t){return this===t||te(t)&&this.lineLike.type===t.lineLike.type&&f(this.start,t.start)&&f(this.end,t.end)}closestTo(t){const e=B(t,this.lineLike);return O(e)}}class it extends st{constructor(t,e){super(t,e,et.LINE)}}class ot extends st{constructor(t,e){super(t,e,et.RAY)}}class ut extends nt{constructor(t){super(),this.constraints=t}equals(t){return this===t||Xt(t)&&e(this.constraints,t.constraints,((t,e)=>t.equals(e)))}closestTo(t){let e,n=1/0;for(const r of this.constraints){const s=r.closestTo(t),i=l(t,s);i<n&&(n=i,e=s)}return e?U(e):t}closestPoints(t){return this.constraints.flatMap((e=>e===this?[]:e.closestPoints(t)))}}class ct extends nt{constructor(t,e){super(),this.center=t,this.radius=e}equals(t){return this===t||re(t)&&this.center[0]===t.center[0]&&this.center[1]===t.center[1]&&this.radius===t.radius}closestTo(t){const e=D(t,this.center,this.radius);return O(e)}}class at extends nt{constructor(t,e){super(),this.center=t,this.radius=e}equals(t){return this===t||se(t)&&f(this.center,t.center)&&this.radius===t.radius}closestTo(t){const e=D(t,this.center,this.radius);return e[2]=this.center[2],O(e)}asCircle(){return new ft(U(this.center),this.radius,b(0,0,1))}}class ft extends nt{constructor(t,e,n,r=void 0){super(),this.center=t,this.radius=e,this.normal=n,this.slicePlane=r}equals(t){return this===t||ie(t)&&f(this.center,t.center)&&f(this.normal,t.normal)&&this.radius===t.radius}closestTo(t){const{center:e,radius:n}=this;w(this.getPlane(ht),t,lt);const r=h(lt,lt,e),s=d(r);if(F(s,0))return U(t);const i=n/Math.sqrt(s),o=a(k(),e,r,i),{slicePlane:u}=this;if(u&&!H(u,o)){const e=At(u,this);return e?.closestTo(t)??U(t)}return O(o)}getPlane(t=y()){return E(this.center,this.normal,t)}}const lt=k(),ht=y();class dt extends nt{constructor(t){super(),this.z=t}equals(t){return this===t||ee(t)&&this.z===t.z}closestTo(t){return O(P(t[0],t[1],this.z))}getPlane(t=y()){return p(pt,0,0,this.z),E(pt,T,t)}}const pt=k();class mt extends nt{constructor(t,e,n){super(),this.start=t,this.end=e,this.planeLike={start:t,end:e,type:n}}equals(t){return this===t||ne(t)&&this.planeLike.type===t.planeLike.type&&f(this.start,t.start)&&f(this.end,t.end)}closestTo(t){return O(J(t,this.planeLike))}closestEndTo(t){const{start:e,end:s}=this;return Math.sign(n(r(Lt,s,e),r(kt,t,e)))>0?s:e}getPlane(t=y()){const e=u(gt,this.end);return e[2]+=1,A(this.start,this.end,e,t)}getSlicePlane(t=y()){const{start:e,end:n,type:r}=this.planeLike;if(r===K.PLANE)return;const s=p(gt,e[0],e[1],0),i=p(Pt,n[0],n[1],0),o=m(Pt,i,s);return E(s,o,t),t}}const Lt=i(),kt=i(),gt=k(),Pt=k();class Tt extends mt{constructor(t,e){super(t,e,K.HALF_PLANE)}}class yt extends mt{constructor(t,e){super(t,e,K.PLANE)}}class qt extends nt{constructor(t,e){super(),this.sphere=Z(t,e)}equals(t){return this===t||oe(t)&&I(this.sphere,t.sphere)}closestTo(t){const e=G(this.sphere,t,k());return O(e)}get center(){return this.sphere}get radius(){return this.sphere[3]}}class xt extends nt{constructor(t,e,n){super(),this.start=t,this.end=e,this.getZ=n,this.planeLike={start:t,end:e,type:K.PLANE}}equals(t){return this===t||ue(t)&&f(this.start,t.start)&&f(this.end,t.end)&&this.getZ===t.getZ}closestTo(t){return vt(this,t)}addIfOnTheGround(t,e){for(const n of e){const e=this.getZ(n[0],n[1],n[2])??0;F(n[2],e)&&(n[2]=e,t.push(n))}}}function vt(t,e){const n=J(e,t.planeLike);return n[2]=t.getZ(e[0],e[1],e[2])??ce,O(n)}function zt(t,e){if(Xt(t)){const n=[];for(const r of t.constraints){const t=r.intersect(e);t&&n.push(t)}return Wt(n)}if(Xt(e))return zt(e,t);if(ue(t))return Jt(t,e);if(ue(e))return Jt(e,t);if($t(t)){const{point:n}=t,r=e.closestTo(n);return L(r,n)?t:void 0}if(te(t)){if($t(e))return zt(e,t);if(te(e))return Qt(Q(t.lineLike,e.lineLike));if(ee(e))return jt(t,e);if(ne(e))return Qt(V(e.planeLike,t.lineLike));if(re(e))return Qt(W(t.lineLike,e.center,e.radius));if(ie(e))return Qt(R(t.lineLike,e));if(se(e))return wt(t,e);if(oe(e))return Et(t,e)}else if(ee(t)){if($t(e)||te(e))return zt(e,t);if(ee(e))return Mt(t,e);if(ne(e))return Nt(t,e);if(re(e))return Zt(t,e);if(ie(e))return Gt(t,e);if(se(e))return It(t,e);if(oe(e))return St(t,e)}else if(ne(t)){if($t(e)||te(e)||ee(e))return zt(e,t);if(ne(e))return Kt(X(t.planeLike,e.planeLike));if(re(e))return Kt(_(t.planeLike,e.center,e.radius));if(ie(e))return Ut(t,e);if(se(e))return Ot(t,e);if(oe(e))return bt(t,e)}else if(re(t)){if($t(e)||te(e)||ee(e)||ne(e))return zt(e,t);if(re(e))return Kt($(t.center,t.radius,e.center,e.radius));if(ie(e))return Ct();if(se(e))return Ft(t,e);if(oe(e))return Ht()}else if(ie(t)){if($t(e)||te(e)||ee(e)||ne(e)||re(e))return zt(e,t);if(ie(e))return Rt();if(se(e))return Rt(e.asCircle());if(oe(e))return Yt()}else if(se(t)){if($t(e)||te(e)||ee(e)||ne(e)||re(e)||ie(e))return zt(e,t);if(se(e))return _t(e,t);if(oe(e))return Bt()}else if(oe(t)){if($t(e)||te(e)||ee(e)||ne(e)||re(e)||se(e))return zt(e,t);if(oe(e))return Dt()}}const jt=(()=>{const t=y();return(e,n)=>{const{start:r,end:s}=e;if(C(r,s)&&F(r[2],n.z))return e;const i=k();return q(n.getPlane(t),r,s,i)?new rt(O(i)):void 0}})();function wt({lineLike:t},{center:e,radius:n}){const r=e[2];return Qt(W(t,e,n).filter((t=>F(t[2],r))))}function Et({lineLike:t},{sphere:e}){return Qt(S(e,t.start,t.end))}const At=(()=>{const t=N(),e=y(),n={start:k(),end:k(),type:et.LINE};return(r,s,i)=>{const{normal:a,center:f,radius:l}=s,h=o(a,M(r)),d=F(x(r,f),0);if(F(h,1))return d?s:void 0;if(s.getPlane(e),d&&F(h,0)&&v(r)&&v(e)){if(F(l,0))return!i||H(i,f)?new rt(U(f)):void 0;const t=g(f);t[2]+=l;const e=g(f);e[2]-=l;const n=[];return i&&!H(i,t)||n.push(t),i&&!H(i,e)||n.push(e),Qt(n)}if(!z(r,e,t))return;u(n.start,t.origin),c(n.end,t.origin,t.direction);const p=R(n,s);return Qt(i?Y(i,p):p)}})();function Mt(t,e){return F(t.z,e.z)?t:void 0}function Nt({z:t},{planeLike:e}){const[n,r]=e.start,[s,i]=e.end,o=b(n,r,t),u=b(s,i,t);return e.type===K.PLANE?new it(o,u):new ot(o,u)}function Zt(t,e){const[n,r]=e.center;return new at(b(n,r,t.z),e.radius)}function It(t,e){return F(e.center[2],t.z)?e:void 0}const Gt=(()=>{const t=y();return(e,n)=>At(e.getPlane(t),n)})();function St(t,{center:e,radius:n}){const r=Math.abs(e[2]-t.z);if(r>n&&!F(r,n))return;const s=b(e[0],e[1],t.z),i=Math.sqrt(n**2-r**2);return F(i,0)?void 0:new at(s,i)}const Ot=(()=>{const t=y();return(e,{center:n,radius:r})=>{const s=_(e.planeLike,n,r),i=n[2];e.getSlicePlane(t);const o=[];for(const[u,c]of s){const e=[u,c,i];H(t,e)&&o.push(e)}return Qt(o)}})(),Ut=(()=>{const t=y(),e=y();return(n,r)=>At(n.getPlane(t),r,n.getSlicePlane(e))})(),bt=(()=>{const t=y();return(e,{center:n,radius:r})=>{const s=e.getPlane(t),i=j(s,n),o=Math.abs(i);if(o>r&&!F(o,r))return;const u=g(M(s)),c=a(k(),n,u,i),f=Math.sqrt(r**2-i**2);return F(f,0)?new rt(O(w(s,n,k()))):new ft(O(c),f,u,e.getSlicePlane())}})();function Ct(t,e){}function Ft(t,e){const n=s(t.center,e.center);if(F(n,0)&&F(t.radius,e.radius))return e;return Vt($(t.center,t.radius,e.center,e.radius),e.center[2])}function Ht(t,e){}function Rt(t,e){}function Yt(t,e){}function _t(t,e){if(!C(t.center,e.center))return;const n=s(t.center,e.center);if(F(n,0)&&F(t.radius,e.radius))return t;return Vt($(t.center,t.radius,e.center,e.radius),t.center[2])}function Bt(t,e){}function Dt(t,e){}function Jt(t,e){const{planeLike:n,getZ:r}=t,s=[];if($t(e))t.addIfOnTheGround(s,tt(n,e.point));else if(te(e))t.addIfOnTheGround(s,V(n,e.lineLike));else if(re(e))for(const[i,o]of _(n,e.center,e.radius)){const t=r(i,o,0);null!=t&&s.push(P(i,o,t))}else if(ne(e)||ue(e))for(const[i,o]of X(n,e.planeLike)){const t=r(i,o,0)??ce;s.push(P(i,o,t))}return Qt(s)}function Kt(t){return Wt(t.map((([t,e])=>{const n=b(t,e,0),r=b(t,e,1);return new it(n,r)})))}function Qt(t){return Wt(t.map((t=>t?new rt(O(t)):void 0)))}function Vt(t,e){return Qt(t.map((([t,n])=>[t,n,e])))}function Wt(e){if(0!==e.length)return 1===e.length?e[0]??void 0:new ut(e.filter(t))}function Xt(t){return t instanceof ut}function $t(t){return t instanceof rt}function te(t){return t instanceof st}function ee(t){return t instanceof dt}function ne(t){return t instanceof mt}function re(t){return t instanceof ct}function se(t){return t instanceof at}function ie(t){return t instanceof ft}function oe(t){return t instanceof qt}function ue(t){return t instanceof xt}const ce=0;export{ft as CircleConstraint,nt as Constraint,xt as DrapedLineConstraint,at as HorizontalCircleConstraint,dt as HorizontalPlaneConstraint,it as LineConstraint,st as LineLikeConstraint,rt as PointConstraint,ot as RayConstraint,ut as SetConstraint,qt as SphereConstraint,ct as VerticalCylinderConstraint,Tt as VerticalHalfPlaneConstraint,yt as VerticalPlaneConstraint,mt as VerticalPlaneLikeConstraint};
5
+ import{isSome as t,equals as e}from"../../../core/arrayUtils.js";import{g as n,c as r,k as s}from"../../../chunks/vec2.js";import{a as i}from"../../../chunks/vec2f64.js";import{j as o,c as u,g as c,q as a,h as f,a as l,u as h,m as d,s as p,f as m,G as L}from"../../../chunks/vec3.js";import{c as k,g,f as P,d as T}from"../../../chunks/vec3f64.js";import{create as y,intersectLine as q,distance as x,isVertical as v,intersectPlanes as z,signedDistance as j,projectPoint as w,fromPositionAndNormal as E,fromPoints as A,normal as M}from"../../../geometry/support/plane.js";import{create as N}from"../../../geometry/support/ray.js";import{k as Z,l as I,p as G,m as S}from"../../../chunks/sphere.js";import{fromVec3 as O,clone as U,fromValues as b}from"./normalizedPoint.js";import{vectorsHaveCloseZ as C,isClose as F,isPointInsidePlane as H,intersectLineLikeAndCircle as R,pointsInsidePlane as Y,intersectVerticalPlaneAndVerticalCylinder as _,projectPointToLineLike as B,projectPointToVerticalCylinder as D,projectPointToVerticalPlane as J,VerticalPlaneType as K,intersectLineLikes as Q,intersectVerticalPlaneAndLineLike as V,intersectLineLikeAndVerticalCylinder as W,intersectVerticalPlanes as X,intersectVerticalCylinders as $,intersectVerticalPlaneAndPoint as tt}from"../../support/geometry3dUtils.js";import{LineType as et}from"../../support/geometry2dUtils.js";class nt{intersect(t){return zt(this,t)}closestPoints(t){return[this.closestTo(t)]}}class rt extends nt{constructor(t){super(),this.point=t}equals(t){return this===t||$t(t)&&f(this.point,t.point)}closestTo(){return U(this.point)}}class st extends nt{constructor(t,e,n){super(),this.start=t,this.end=e,this.lineLike={start:t,end:e,type:n}}equals(t){return this===t||te(t)&&this.lineLike.type===t.lineLike.type&&f(this.start,t.start)&&f(this.end,t.end)}closestTo(t){const e=B(t,this.lineLike);return O(e)}}class it extends st{constructor(t,e){super(t,e,et.LINE)}}class ot extends st{constructor(t,e){super(t,e,et.RAY)}}class ut extends nt{constructor(t){super(),this.constraints=t}equals(t){return this===t||Xt(t)&&e(this.constraints,t.constraints,((t,e)=>t.equals(e)))}closestTo(t){let e,n=1/0;for(const r of this.constraints){const s=r.closestTo(t),i=l(t,s);i<n&&(n=i,e=s)}return e?U(e):t}closestPoints(t){return this.constraints.flatMap((e=>e===this?[]:e.closestPoints(t)))}}class ct extends nt{constructor(t,e){super(),this.center=t,this.radius=e}equals(t){return this===t||re(t)&&this.center[0]===t.center[0]&&this.center[1]===t.center[1]&&this.radius===t.radius}closestTo(t){const e=D(t,this.center,this.radius);return O(e)}}class at extends nt{constructor(t,e){super(),this.center=t,this.radius=e}equals(t){return this===t||se(t)&&f(this.center,t.center)&&this.radius===t.radius}closestTo(t){const e=D(t,this.center,this.radius);return e[2]=this.center[2],O(e)}asCircle(){return new ft(U(this.center),this.radius,b(0,0,1))}}class ft extends nt{constructor(t,e,n,r=void 0){super(),this.center=t,this.radius=e,this.normal=n,this.slicePlane=r}equals(t){return this===t||ie(t)&&f(this.center,t.center)&&f(this.normal,t.normal)&&this.radius===t.radius}closestTo(t){const{center:e,radius:n}=this;w(this.getPlane(ht),t,lt);const r=h(lt,lt,e),s=d(r);if(F(s,0))return U(t);const i=n/Math.sqrt(s),o=a(k(),e,r,i),{slicePlane:u}=this;if(u&&!H(u,o)){const e=At(u,this);return e?.closestTo(t)??U(t)}return O(o)}getPlane(t=y()){return E(this.center,this.normal,t)}}const lt=k(),ht=y();class dt extends nt{constructor(t){super(),this.z=t}equals(t){return this===t||ee(t)&&this.z===t.z}closestTo(t){return O(P(t[0],t[1],this.z))}getPlane(t=y()){return p(pt,0,0,this.z),E(pt,T,t)}}const pt=k();class mt extends nt{constructor(t,e,n){super(),this.start=t,this.end=e,this.planeLike={start:t,end:e,type:n}}equals(t){return this===t||ne(t)&&this.planeLike.type===t.planeLike.type&&f(this.start,t.start)&&f(this.end,t.end)}closestTo(t){return O(J(t,this.planeLike))}closestEndTo(t){const{start:e,end:s}=this;return Math.sign(n(r(Lt,s,e),r(kt,t,e)))>0?s:e}getPlane(t=y()){const e=u(gt,this.end);return e[2]+=1,A(this.start,this.end,e,t)}getSlicePlane(t=y()){const{start:e,end:n,type:r}=this.planeLike;if(r===K.PLANE)return;const s=p(gt,e[0],e[1],0),i=p(Pt,n[0],n[1],0),o=m(Pt,i,s);return E(s,o,t),t}}const Lt=i(),kt=i(),gt=k(),Pt=k();class Tt extends mt{constructor(t,e){super(t,e,K.HALF_PLANE)}}class yt extends mt{constructor(t,e){super(t,e,K.PLANE)}}class qt extends nt{constructor(t,e){super(),this.sphere=Z(t,e)}equals(t){return this===t||oe(t)&&I(this.sphere,t.sphere)}closestTo(t){const e=G(this.sphere,t,k());return O(e)}get center(){return this.sphere}get radius(){return this.sphere[3]}}class xt extends nt{constructor(t,e,n){super(),this.start=t,this.end=e,this.getZ=n,this.planeLike={start:t,end:e,type:K.PLANE}}equals(t){return this===t||ue(t)&&f(this.start,t.start)&&f(this.end,t.end)&&this.getZ===t.getZ}closestTo(t){return vt(this,t)}addIfOnTheGround(t,e){for(const n of e){const e=this.getZ(n[0],n[1])??0;F(n[2],e)&&(n[2]=e,t.push(n))}}}function vt(t,e){const n=J(e,t.planeLike);return n[2]=t.getZ(n[0],n[1])??ce,O(n)}function zt(t,e){if(Xt(t)){const n=[];for(const r of t.constraints){const t=r.intersect(e);t&&n.push(t)}return Wt(n)}if(Xt(e))return zt(e,t);if(ue(t))return Jt(t,e);if(ue(e))return Jt(e,t);if($t(t)){const{point:n}=t,r=e.closestTo(n);return L(r,n)?t:void 0}if(te(t)){if($t(e))return zt(e,t);if(te(e))return Qt(Q(t.lineLike,e.lineLike));if(ee(e))return jt(t,e);if(ne(e))return Qt(V(e.planeLike,t.lineLike));if(re(e))return Qt(W(t.lineLike,e.center,e.radius));if(ie(e))return Qt(R(t.lineLike,e));if(se(e))return wt(t,e);if(oe(e))return Et(t,e)}else if(ee(t)){if($t(e)||te(e))return zt(e,t);if(ee(e))return Mt(t,e);if(ne(e))return Nt(t,e);if(re(e))return Zt(t,e);if(ie(e))return Gt(t,e);if(se(e))return It(t,e);if(oe(e))return St(t,e)}else if(ne(t)){if($t(e)||te(e)||ee(e))return zt(e,t);if(ne(e))return Kt(X(t.planeLike,e.planeLike));if(re(e))return Kt(_(t.planeLike,e.center,e.radius));if(ie(e))return Ut(t,e);if(se(e))return Ot(t,e);if(oe(e))return bt(t,e)}else if(re(t)){if($t(e)||te(e)||ee(e)||ne(e))return zt(e,t);if(re(e))return Kt($(t.center,t.radius,e.center,e.radius));if(ie(e))return Ct();if(se(e))return Ft(t,e);if(oe(e))return Ht()}else if(ie(t)){if($t(e)||te(e)||ee(e)||ne(e)||re(e))return zt(e,t);if(ie(e))return Rt();if(se(e))return Rt(e.asCircle());if(oe(e))return Yt()}else if(se(t)){if($t(e)||te(e)||ee(e)||ne(e)||re(e)||ie(e))return zt(e,t);if(se(e))return _t(e,t);if(oe(e))return Bt()}else if(oe(t)){if($t(e)||te(e)||ee(e)||ne(e)||re(e)||se(e))return zt(e,t);if(oe(e))return Dt()}}const jt=(()=>{const t=y();return(e,n)=>{const{start:r,end:s}=e;if(C(r,s)&&F(r[2],n.z))return e;const i=k();return q(n.getPlane(t),r,s,i)?new rt(O(i)):void 0}})();function wt({lineLike:t},{center:e,radius:n}){const r=e[2];return Qt(W(t,e,n).filter((t=>F(t[2],r))))}function Et({lineLike:t},{sphere:e}){return Qt(S(e,t.start,t.end))}const At=(()=>{const t=N(),e=y(),n={start:k(),end:k(),type:et.LINE};return(r,s,i)=>{const{normal:a,center:f,radius:l}=s,h=o(a,M(r)),d=F(x(r,f),0);if(F(h,1))return d?s:void 0;if(s.getPlane(e),d&&F(h,0)&&v(r)&&v(e)){if(F(l,0))return!i||H(i,f)?new rt(U(f)):void 0;const t=g(f);t[2]+=l;const e=g(f);e[2]-=l;const n=[];return i&&!H(i,t)||n.push(t),i&&!H(i,e)||n.push(e),Qt(n)}if(!z(r,e,t))return;u(n.start,t.origin),c(n.end,t.origin,t.direction);const p=R(n,s);return Qt(i?Y(i,p):p)}})();function Mt(t,e){return F(t.z,e.z)?t:void 0}function Nt({z:t},{planeLike:e}){const[n,r]=e.start,[s,i]=e.end,o=b(n,r,t),u=b(s,i,t);return e.type===K.PLANE?new it(o,u):new ot(o,u)}function Zt(t,e){const[n,r]=e.center;return new at(b(n,r,t.z),e.radius)}function It(t,e){return F(e.center[2],t.z)?e:void 0}const Gt=(()=>{const t=y();return(e,n)=>At(e.getPlane(t),n)})();function St(t,{center:e,radius:n}){const r=Math.abs(e[2]-t.z);if(r>n&&!F(r,n))return;const s=b(e[0],e[1],t.z),i=Math.sqrt(n**2-r**2);return F(i,0)?void 0:new at(s,i)}const Ot=(()=>{const t=y();return(e,{center:n,radius:r})=>{const s=_(e.planeLike,n,r),i=n[2];e.getSlicePlane(t);const o=[];for(const[u,c]of s){const e=[u,c,i];H(t,e)&&o.push(e)}return Qt(o)}})(),Ut=(()=>{const t=y(),e=y();return(n,r)=>At(n.getPlane(t),r,n.getSlicePlane(e))})(),bt=(()=>{const t=y();return(e,{center:n,radius:r})=>{const s=e.getPlane(t),i=j(s,n),o=Math.abs(i);if(o>r&&!F(o,r))return;const u=g(M(s)),c=a(k(),n,u,i),f=Math.sqrt(r**2-i**2);return F(f,0)?new rt(O(w(s,n,k()))):new ft(O(c),f,u,e.getSlicePlane())}})();function Ct(t,e){}function Ft(t,e){const n=s(t.center,e.center);if(F(n,0)&&F(t.radius,e.radius))return e;return Vt($(t.center,t.radius,e.center,e.radius),e.center[2])}function Ht(t,e){}function Rt(t,e){}function Yt(t,e){}function _t(t,e){if(!C(t.center,e.center))return;const n=s(t.center,e.center);if(F(n,0)&&F(t.radius,e.radius))return t;return Vt($(t.center,t.radius,e.center,e.radius),t.center[2])}function Bt(t,e){}function Dt(t,e){}function Jt(t,e){const{planeLike:n,getZ:r}=t,s=[];if($t(e))t.addIfOnTheGround(s,tt(n,e.point));else if(te(e))t.addIfOnTheGround(s,V(n,e.lineLike));else if(re(e))for(const[i,o]of _(n,e.center,e.radius)){const t=r(i,o);null!=t&&s.push(P(i,o,t))}else if(ne(e)||ue(e))for(const[i,o]of X(n,e.planeLike)){const t=r(i,o)??ce;s.push(P(i,o,t))}return Qt(s)}function Kt(t){return Wt(t.map((([t,e])=>{const n=b(t,e,0),r=b(t,e,1);return new it(n,r)})))}function Qt(t){return Wt(t.map((t=>t?new rt(O(t)):void 0)))}function Vt(t,e){return Qt(t.map((([t,n])=>[t,n,e])))}function Wt(e){if(0!==e.length)return 1===e.length?e[0]??void 0:new ut(e.filter(t))}function Xt(t){return t instanceof ut}function $t(t){return t instanceof rt}function te(t){return t instanceof st}function ee(t){return t instanceof dt}function ne(t){return t instanceof mt}function re(t){return t instanceof ct}function se(t){return t instanceof at}function ie(t){return t instanceof ft}function oe(t){return t instanceof qt}function ue(t){return t instanceof xt}const ce=0;export{ft as CircleConstraint,nt as Constraint,xt as DrapedLineConstraint,at as HorizontalCircleConstraint,dt as HorizontalPlaneConstraint,it as LineConstraint,st as LineLikeConstraint,rt as PointConstraint,ot as RayConstraint,ut as SetConstraint,qt as SphereConstraint,ct as VerticalCylinderConstraint,Tt as VerticalHalfPlaneConstraint,yt as VerticalPlaneConstraint,mt as VerticalPlaneLikeConstraint};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../../chunks/tslib.es6.js";import t from"../../../../core/Accessor.js";import{throwIfAborted as i,whenOrAbort as n}from"../../../../core/promiseUtils.js";import{watch as o,initial as r,on as a}from"../../../../core/reactiveUtils.js";import{property as s}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/accessorSupport/ensureType.js";import"../../../../core/arrayUtils.js";import"../../../../core/has.js";import{subclass as p}from"../../../../core/accessorSupport/decorators/subclass.js";import{elevationContextAffectsAlignment as l}from"../../../../support/elevationInfoUtils.js";import{makeFilter as y,makeSnappingQuery as c}from"../snappingUtils.js";import{convertSnappingCandidate as u,makeGetGroundElevation as g}from"./queryEngineUtils.js";import{getSnappingCandidateElevationAligner as h}from"./snappingCandidateElevationAlignment.js";import{getSnappingCandidateElevationFilter as d}from"./snappingCandidateElevationFilter.js";import{getSymbologySnappingCandidatesFetcher as m}from"./symbologySnappingCandidates.js";let v=class extends t{get availability(){return 1}get updating(){return this.layerSource.updating}get _snappingElevationAligner(){const{view:e}=this,{layer:t}=this.layerSource,i=null!=e&&"3d"===e.type;if(!i||"subtype-group"===t.type)return h();const o=async(i,o)=>(await n(e.whenLayerView(t),o)).elevationAlignPointsInFeatures(i,o);return h(i,{elevationInfo:t.elevationInfo,alignPointsInFeatures:o})}get _snappingElevationFilter(){const{view:e}=this,t=null!=e&&"3d"===e.type&&"subtype-group"!==this.layerSource.layer.type;return d(t)}get _symbologySnappingFetcher(){const{view:e}=this,{layer:t}=this.layerSource;return null!=e&&"3d"===e.type&&"subtype-group"!==t.type?m(this._symbologySnappingSupported,(async(n,o)=>{const r=await e.whenLayerView(t);return i(o),r.queryForSymbologySnapping({candidates:n,spatialReference:e.spatialReference},o)})):m()}get _symbologySnappingSupported(){return null!=this._layerView3D&&this._layerView3D.symbologySnappingSupported}initialize(){const{view:e}=this,{layer:t}=this.layerSource;null!=e&&"3d"===e.type&&"subtype-group"!==t.type&&(e.whenLayerView(t).then((e=>this._layerView3D=e)),this.addHandles([e.elevationProvider.on("elevation-change",(({context:e})=>{const{elevationInfo:i}=t;l(e,i)&&this._snappingElevationAligner.notifyElevationSourceChange()})),o((()=>t.elevationInfo),(()=>this._snappingElevationAligner.notifyElevationSourceChange()),r),o((()=>null!=this._layerView3D?this._layerView3D.processor?.renderer:null),(()=>this._symbologySnappingFetcher.notifySymbologyChange()),r),a((()=>this._layerView3D?.layer),["edits","apply-edits","graphic-update"],(()=>this._symbologySnappingFetcher.notifySymbologyChange()))]))}constructor(e){super(e),this.view=null,this._layerView3D=null}refresh(){}async fetchCandidates(e,t){const{layer:n}=this.layerSource,o=n.source;if(!o?.querySnapping)return[];const r=y(n),a=c(e,this.view?.type??"2d",r),s=await o.querySnapping(a,{signal:t});i(t);const p=await this._snappingElevationAligner.alignCandidates(s.candidates,e.coordinateHelper.spatialReference,t);i(t);const l=await this._symbologySnappingFetcher.fetch(p,t);i(t);const g=0===l.length?p:[...p,...l],h=this._snappingElevationFilter.filter(a,g),d=this._getGroundElevation;return h.map((e=>u(e,d)))}get _getGroundElevation(){return g(this.view)}};e([s({constructOnly:!0})],v.prototype,"layerSource",void 0),e([s({constructOnly:!0})],v.prototype,"view",void 0),e([s()],v.prototype,"_snappingElevationAligner",null),e([s()],v.prototype,"_snappingElevationFilter",null),e([s()],v.prototype,"_symbologySnappingFetcher",null),e([s()],v.prototype,"_layerView3D",void 0),e([s()],v.prototype,"_symbologySnappingSupported",null),e([s()],v.prototype,"_getGroundElevation",null),v=e([p("esri.views.interactive.snapping.featureSources.FeatureCollectionSnappingSource")],v);export{v as FeatureCollectionSnappingSource};
5
+ import{_ as e}from"../../../../chunks/tslib.es6.js";import t from"../../../../core/Accessor.js";import{memoize as i}from"../../../../core/memoize.js";import{throwIfAborted as o,whenOrAbort as n}from"../../../../core/promiseUtils.js";import{watch as r,initial as a,on as s}from"../../../../core/reactiveUtils.js";import{property as p}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/accessorSupport/ensureType.js";import"../../../../core/arrayUtils.js";import"../../../../core/has.js";import{subclass as l}from"../../../../core/accessorSupport/decorators/subclass.js";import{elevationContextAffectsAlignment as y}from"../../../../support/elevationInfoUtils.js";import{makeFilter as c,makeSnappingQuery as u}from"../snappingUtils.js";import{convertSnappingCandidate as g,makeGetGroundElevation as h}from"./queryEngineUtils.js";import{getSnappingCandidateElevationAligner as m}from"./snappingCandidateElevationAlignment.js";import{getSnappingCandidateElevationFilter as d}from"./snappingCandidateElevationFilter.js";import{getSymbologySnappingCandidatesFetcher as v}from"./symbologySnappingCandidates.js";let S=class extends t{get availability(){return 1}get updating(){return this.layerSource.updating}get _snappingElevationAligner(){const{view:e}=this,{layer:t}=this.layerSource,i=null!=e&&"3d"===e.type;if(!i||"subtype-group"===t.type)return m();const o=async(i,o)=>(await n(e.whenLayerView(t),o)).elevationAlignPointsInFeatures(i,o);return m(i,{elevationInfo:t.elevationInfo,alignPointsInFeatures:o})}get _snappingElevationFilter(){const{view:e}=this,t=null!=e&&"3d"===e.type&&"subtype-group"!==this.layerSource.layer.type;return d(t)}get _symbologySnappingFetcher(){const{view:e}=this,{layer:t}=this.layerSource;return null!=e&&"3d"===e.type&&"subtype-group"!==t.type?v(this._symbologySnappingSupported,(async(i,n)=>{const r=await e.whenLayerView(t);return o(n),r.queryForSymbologySnapping({candidates:i,spatialReference:e.spatialReference},n)})):v()}get _symbologySnappingSupported(){return null!=this._layerView3D&&this._layerView3D.symbologySnappingSupported}initialize(){const{view:e}=this,{layer:t}=this.layerSource;null!=e&&"3d"===e.type&&"subtype-group"!==t.type&&(e.whenLayerView(t).then((e=>this._layerView3D=e)),this.addHandles([e.elevationProvider.on("elevation-change",(({context:e})=>{const{elevationInfo:i}=t;y(e,i)&&this._snappingElevationAligner.notifyElevationSourceChange()})),r((()=>t.elevationInfo),(()=>this._snappingElevationAligner.notifyElevationSourceChange()),a),r((()=>null!=this._layerView3D?this._layerView3D.processor?.renderer:null),(()=>this._symbologySnappingFetcher.notifySymbologyChange()),a),s((()=>this._layerView3D?.layer),["edits","apply-edits","graphic-update"],(()=>this._symbologySnappingFetcher.notifySymbologyChange()))]))}constructor(e){super(e),this.view=null,this._layerView3D=null,this._memoizedMakeGetGroundElevation=i(h)}refresh(){}async fetchCandidates(e,t){const{layer:i}=this.layerSource,n=i.source;if(!n?.querySnapping)return[];const r=c(i),a=u(e,this.view?.type??"2d",r),s=await n.querySnapping(a,{signal:t});o(t);const p=e.coordinateHelper.spatialReference,l=await this._snappingElevationAligner.alignCandidates(s.candidates,p,t);o(t);const y=await this._symbologySnappingFetcher.fetch(l,t);o(t);const h=0===y.length?l:[...l,...y],m=this._snappingElevationFilter.filter(a,h),d=this._memoizedMakeGetGroundElevation(this.view,p);return m.map((e=>g(e,d)))}};e([p({constructOnly:!0})],S.prototype,"layerSource",void 0),e([p({constructOnly:!0})],S.prototype,"view",void 0),e([p()],S.prototype,"_snappingElevationAligner",null),e([p()],S.prototype,"_snappingElevationFilter",null),e([p()],S.prototype,"_symbologySnappingFetcher",null),e([p()],S.prototype,"_layerView3D",void 0),e([p()],S.prototype,"_symbologySnappingSupported",null),S=e([l("esri.views.interactive.snapping.featureSources.FeatureCollectionSnappingSource")],S);export{S as FeatureCollectionSnappingSource};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../../chunks/tslib.es6.js";import t from"../../../../core/Accessor.js";import{createTask as r}from"../../../../core/asyncUtils.js";import{destroyHandle as i}from"../../../../core/handleUtils.js";import{throwIfAborted as s,ignoreAbortErrors as o}from"../../../../core/promiseUtils.js";import{watch as a,initial as n,on as l,sync as u,syncAndInitial as d}from"../../../../core/reactiveUtils.js";import{property as p}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/accessorSupport/ensureType.js";import"../../../../core/arrayUtils.js";import"../../../../core/has.js";import{subclass as h}from"../../../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as c}from"../../../../core/support/UpdatingHandles.js";import{isSubtypeGroupLayer as y}from"../../../../layers/support/layerUtils.js";import{elevationContextAffectsAlignment as f}from"../../../../support/elevationInfoUtils.js";import{FeatureServiceTiles2D as g}from"../../../2d/interactive/snapping/featureSources/featureServiceSource/FeatureServiceTiles2D.js";import{FeatureServiceTiles3D as m}from"../../../3d/interactive/snapping/featureSources/featureServiceSource/FeatureServiceTiles3D.js";import{isUtilityNetworkWebMap as _}from"../snappingUtils.js";import{convertSnappingCandidate as w,makeGetGroundElevation as S}from"./queryEngineUtils.js";import{WorkerTileTreeDebugger as v}from"./WorkerTileTreeDebugger.js";import{FeatureServiceSnappingSourceWorkerHandle as b}from"./featureServiceSource/FeatureServiceSnappingSourceWorkerHandle.js";import{FeatureServiceTilesSimple as I}from"./featureServiceSource/FeatureServiceTilesSimple.js";import H from"../../../support/debugFlags.js";let j=class extends t{get _updateTilesParameters(){return{tiles:this._tilesOfInterest.tiles,tileInfo:this._tilesOfInterest.tileInfo,tileSize:this._tilesOfInterest.tileSize}}get _layerView(){return this.view?.allLayerViews.find((e=>e.layer===this._layer))}get _isSuspended(){if(y(this._layer)){if(!this._layer.sublayers.find((e=>e.visible)))return!0}return!!this.view&&(!1!==this._layerView?.suspended||!this.layerSource.enabled)}get updating(){return this._workerHandle?.updating||this._updatingHandles.updating}get _outFields(){const{view:e,_layerView:t,layerSource:r}=this,{layer:i}=r,{fieldsIndex:s,timeInfo:o,floorInfo:a,subtypeField:n}=i,l=t&&"filter"in t?t.filter:null,u=l?.where&&"1=1"!==l.where?this._getOrLoadWhereFields(l.where,s):[];if(l?.timeExtent&&o){const{startField:e,endField:t}=o,r=s.get(e)?.name??e,i=s.get(t)?.name??t;r&&u.push(r),i&&u.push(i)}if(e?.map&&_(e.map)&&e.map.utilityNetworks?.find((e=>e.isUtilityLayer(i)))){const e=i.fieldsIndex.get("assetGroup")?.name,t=i.fieldsIndex.get("assetType")?.name;e&&t&&(u.push(e),u.push(t))}if(i&&a?.floorField&&e?.floors?.length){const e=s.get(a.floorField)?.name??a.floorField;e&&u.push(e)}if(n){const e=s.get(n)?.name??n;e&&u.push(e)}return new Set(u)}get configuration(){const{view:e}=this,t=null!=e?e.type:"2d";return{filter:this._layer.createQuery(),customParameters:this._layer.customParameters,viewType:t}}get availability(){return this._workerHandle?.availability??0}get _layer(){return this.layerSource.layer}constructor(e){super(e),this._updatingHandles=new c,this._workerHandle=null,this._debug=null}initialize(){let e;const t=this.view;if(null!=t)switch(t.type){case"2d":this._tilesOfInterest=new g({view:t,layer:this._layer}),e=this._workerHandle=new b;break;case"3d":{const{resourceController:r}=t,i=this._layer;this._tilesOfInterest=new m({view:t}),e=this._workerHandle=new b({schedule:e=>r.immediate.schedule(e),hasZ:this._layer.hasZ&&(this._layer.returnZ??!0),elevationAlignPointsInFeatures:async(e,r)=>{const o=await t.whenLayerView(i);return s(r),o.elevationAlignPointsInFeatures(e,r)},queryForSymbologySnapping:async(e,r)=>{const o=await t.whenLayerView(i);return s(r),o.queryForSymbologySnapping(e,r)}}),this.addHandles([t.elevationProvider.on("elevation-change",(({context:t})=>{const{elevationInfo:r}=i;f(t,r)&&o(e.notifyElevationSourceChange())})),a((()=>i.elevationInfo),(()=>o(e.notifyElevationSourceChange())),n),a((()=>this._layerView?.processor?.renderer),(()=>o(e.notifySymbologyChange())),n),a((()=>this._layerView?.symbologySnappingSupported??!1),(t=>o(e.setSymbologySnappingSupported(t))),n),l((()=>this._layerView?.layer),["edits","apply-edits","graphic-update"],(()=>e.notifySymbologyChange()))]);break}}else this._tilesOfInterest=new I({layer:this._layer}),e=this._workerHandle=new b;this.addHandles([i(e)]),o(e.setup({layer:this._layer,spatialReference:this.spatialReference,configuration:this.configuration},null)),this._updatingHandles.add((()=>this._updateTilesParameters),(()=>o(e.updateTiles(this._updateTilesParameters,null))),n),this.addHandles([a((()=>this.configuration),(t=>o(e.configure(t,null))),u),a((()=>this._outFields),(t=>o(e.updateOutFields(t))),n),a((()=>this._isSuspended),(t=>o(e.setSuspended(t))),d)]),null!=t&&this.addHandles(a((()=>H.FEATURE_SERVICE_SNAPPING_SOURCE_TILE_TREE_SHOW_TILES),(r=>{r&&!this._debug?(this._debug=new v({view:t,handle:e}),this.addHandles(i(this._debug),"debug")):!r&&this._debug&&this.removeHandles("debug")}),n)),this.addHandles(this.layerSource.layer.on("apply-edits",(t=>{o(e.applyEdits(t,null))})))}destroy(){this._updatingHandles.destroy()}refresh(){this._workerHandle?.refresh(null)}async fetchCandidates(e,t){const{coordinateHelper:r,point:i}=e;this._tilesOfInterest.pointOfInterest=r.arrayToPoint(i);const s=this._getGroundElevation;return(await this._workerHandle.fetchCandidates({...e},t)).candidates.map((e=>w(e,s)))}getDebugInfo(e){return this._workerHandle.getDebugInfo(e)}get _getGroundElevation(){return S(this.view)}_getOrLoadWhereFields(e,t){const{_whereModule:i}=this;if(!this._loadWhereModuleTask&&!i){const e=r((async()=>{const e=await import("../../../../core/sql/WhereClause.js");return this._whereModule=e.WhereClause,this._whereModule}));return this._loadWhereModuleTask=e,this._updatingHandles.addPromise(e.promise),[]}if(!i)return[];try{return i.create(e,t).fieldNames}catch(s){return[]}}};e([p({constructOnly:!0})],j.prototype,"spatialReference",void 0),e([p({constructOnly:!0})],j.prototype,"layerSource",void 0),e([p({constructOnly:!0})],j.prototype,"view",void 0),e([p()],j.prototype,"_tilesOfInterest",void 0),e([p({readOnly:!0})],j.prototype,"_updateTilesParameters",null),e([p()],j.prototype,"_layerView",null),e([p()],j.prototype,"_isSuspended",null),e([p({readOnly:!0})],j.prototype,"updating",null),e([p()],j.prototype,"_outFields",null),e([p({readOnly:!0})],j.prototype,"configuration",null),e([p({readOnly:!0})],j.prototype,"availability",null),e([p()],j.prototype,"_getGroundElevation",null),e([p()],j.prototype,"_loadWhereModuleTask",void 0),e([p()],j.prototype,"_whereModule",void 0),j=e([h("esri.views.interactive.snapping.featureSources.FeatureServiceSnappingSource")],j);export{j as FeatureServiceSnappingSource};
5
+ import{_ as e}from"../../../../chunks/tslib.es6.js";import t from"../../../../core/Accessor.js";import{createTask as r}from"../../../../core/asyncUtils.js";import{destroyHandle as i}from"../../../../core/handleUtils.js";import{memoize as s}from"../../../../core/memoize.js";import{throwIfAborted as o,ignoreAbortErrors as a}from"../../../../core/promiseUtils.js";import{watch as n,initial as l,on as u,sync as d,syncAndInitial as p}from"../../../../core/reactiveUtils.js";import{property as h}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/accessorSupport/ensureType.js";import"../../../../core/arrayUtils.js";import"../../../../core/has.js";import{subclass as c}from"../../../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as y}from"../../../../core/support/UpdatingHandles.js";import{isSubtypeGroupLayer as f}from"../../../../layers/support/layerUtils.js";import{elevationContextAffectsAlignment as m}from"../../../../support/elevationInfoUtils.js";import{FeatureServiceTiles2D as _}from"../../../2d/interactive/snapping/featureSources/featureServiceSource/FeatureServiceTiles2D.js";import{FeatureServiceTiles3D as g}from"../../../3d/interactive/snapping/featureSources/featureServiceSource/FeatureServiceTiles3D.js";import{isUtilityNetworkWebMap as w}from"../snappingUtils.js";import{convertSnappingCandidate as S,makeGetGroundElevation as v}from"./queryEngineUtils.js";import{WorkerTileTreeDebugger as b}from"./WorkerTileTreeDebugger.js";import{FeatureServiceSnappingSourceWorkerHandle as I}from"./featureServiceSource/FeatureServiceSnappingSourceWorkerHandle.js";import{FeatureServiceTilesSimple as H}from"./featureServiceSource/FeatureServiceTilesSimple.js";import j from"../../../support/debugFlags.js";let F=class extends t{get _updateTilesParameters(){return{tiles:this._tilesOfInterest.tiles,tileInfo:this._tilesOfInterest.tileInfo,tileSize:this._tilesOfInterest.tileSize}}get _layerView(){return this.view?.allLayerViews.find((e=>e.layer===this._layer))}get _isSuspended(){if(f(this._layer)){if(!this._layer.sublayers.find((e=>e.visible)))return!0}return!!this.view&&(!1!==this._layerView?.suspended||!this.layerSource.enabled)}get updating(){return this._workerHandle?.updating||this._updatingHandles.updating}get _outFields(){const{view:e,_layerView:t,layerSource:r}=this,{layer:i}=r,{fieldsIndex:s,timeInfo:o,floorInfo:a,subtypeField:n}=i,l=t&&"filter"in t?t.filter:null,u=l?.where&&"1=1"!==l.where?this._getOrLoadWhereFields(l.where,s):[];if(l?.timeExtent&&o){const{startField:e,endField:t}=o,r=s.get(e)?.name??e,i=s.get(t)?.name??t;r&&u.push(r),i&&u.push(i)}if(e?.map&&w(e.map)&&e.map.utilityNetworks?.find((e=>e.isUtilityLayer(i)))){const e=i.fieldsIndex.get("assetGroup")?.name,t=i.fieldsIndex.get("assetType")?.name;e&&t&&(u.push(e),u.push(t))}if(i&&a?.floorField&&e?.floors?.length){const e=s.get(a.floorField)?.name??a.floorField;e&&u.push(e)}if(n){const e=s.get(n)?.name??n;e&&u.push(e)}return new Set(u)}get configuration(){const{view:e}=this,t=null!=e?e.type:"2d";return{filter:this._layer.createQuery(),customParameters:this._layer.customParameters,viewType:t}}get availability(){return this._workerHandle?.availability??0}get _layer(){return this.layerSource.layer}constructor(e){super(e),this._updatingHandles=new y,this._workerHandle=null,this._debug=null,this._memoizedMakeGetGroundElevation=s(v)}initialize(){let e;const t=this.view;if(null!=t)switch(t.type){case"2d":this._tilesOfInterest=new _({view:t,layer:this._layer}),e=this._workerHandle=new I;break;case"3d":{const{resourceController:r}=t,i=this._layer;this._tilesOfInterest=new g({view:t}),e=this._workerHandle=new I({schedule:e=>r.immediate.schedule(e),hasZ:this._layer.hasZ&&(this._layer.returnZ??!0),elevationAlignPointsInFeatures:async(e,r)=>{const s=await t.whenLayerView(i);return o(r),s.elevationAlignPointsInFeatures(e,r)},queryForSymbologySnapping:async(e,r)=>{const s=await t.whenLayerView(i);return o(r),s.queryForSymbologySnapping(e,r)}}),this.addHandles([t.elevationProvider.on("elevation-change",(({context:t})=>{const{elevationInfo:r}=i;m(t,r)&&a(e.notifyElevationSourceChange())})),n((()=>i.elevationInfo),(()=>a(e.notifyElevationSourceChange())),l),n((()=>this._layerView?.processor?.renderer),(()=>a(e.notifySymbologyChange())),l),n((()=>this._layerView?.symbologySnappingSupported??!1),(t=>a(e.setSymbologySnappingSupported(t))),l),u((()=>this._layerView?.layer),["edits","apply-edits","graphic-update"],(()=>e.notifySymbologyChange()))]);break}}else this._tilesOfInterest=new H({layer:this._layer}),e=this._workerHandle=new I;this.addHandles([i(e)]),a(e.setup({layer:this._layer,spatialReference:this.spatialReference,configuration:this.configuration},null)),this._updatingHandles.add((()=>this._updateTilesParameters),(()=>a(e.updateTiles(this._updateTilesParameters,null))),l),this.addHandles([n((()=>this.configuration),(t=>a(e.configure(t,null))),d),n((()=>this._outFields),(t=>a(e.updateOutFields(t))),l),n((()=>this._isSuspended),(t=>a(e.setSuspended(t))),p)]),null!=t&&this.addHandles(n((()=>j.FEATURE_SERVICE_SNAPPING_SOURCE_TILE_TREE_SHOW_TILES),(r=>{r&&!this._debug?(this._debug=new b({view:t,handle:e}),this.addHandles(i(this._debug),"debug")):!r&&this._debug&&this.removeHandles("debug")}),l)),this.addHandles(this.layerSource.layer.on("apply-edits",(t=>{a(e.applyEdits(t,null))})))}destroy(){this._updatingHandles.destroy()}refresh(){this._workerHandle?.refresh(null)}async fetchCandidates(e,t){const{coordinateHelper:r,point:i}=e;this._tilesOfInterest.pointOfInterest=r.arrayToPoint(i);const s=this._memoizedMakeGetGroundElevation(this.view,r.spatialReference);return(await this._workerHandle.fetchCandidates({...e},t)).candidates.map((e=>S(e,s)))}getDebugInfo(e){return this._workerHandle.getDebugInfo(e)}_getOrLoadWhereFields(e,t){const{_whereModule:i}=this;if(!this._loadWhereModuleTask&&!i){const e=r((async()=>{const e=await import("../../../../core/sql/WhereClause.js");return this._whereModule=e.WhereClause,this._whereModule}));return this._loadWhereModuleTask=e,this._updatingHandles.addPromise(e.promise),[]}if(!i)return[];try{return i.create(e,t).fieldNames}catch(s){return[]}}};e([h({constructOnly:!0})],F.prototype,"spatialReference",void 0),e([h({constructOnly:!0})],F.prototype,"layerSource",void 0),e([h({constructOnly:!0})],F.prototype,"view",void 0),e([h()],F.prototype,"_tilesOfInterest",void 0),e([h({readOnly:!0})],F.prototype,"_updateTilesParameters",null),e([h()],F.prototype,"_layerView",null),e([h()],F.prototype,"_isSuspended",null),e([h({readOnly:!0})],F.prototype,"updating",null),e([h()],F.prototype,"_outFields",null),e([h({readOnly:!0})],F.prototype,"configuration",null),e([h({readOnly:!0})],F.prototype,"availability",null),e([h()],F.prototype,"_loadWhereModuleTask",void 0),e([h()],F.prototype,"_whereModule",void 0),F=e([c("esri.views.interactive.snapping.featureSources.FeatureServiceSnappingSource")],F);export{F as FeatureServiceSnappingSource};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../../chunks/tslib.es6.js";import t from"../../../../core/Accessor.js";import{removeUnordered as s}from"../../../../core/arrayUtils.js";import{createTask as o}from"../../../../core/asyncUtils.js";import{throwIfAborted as r,allSettledValues as i,whenOrAbort as n}from"../../../../core/promiseUtils.js";import{initial as a,watch as p,on as l}from"../../../../core/reactiveUtils.js";import{property as d}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/accessorSupport/ensureType.js";import"../../../../core/has.js";import{subclass as c}from"../../../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as u}from"../../../../core/support/UpdatingHandles.js";import h from"../../../../geometry/Polygon.js";import{initializeProjection as y,canProjectWithoutEngine as m,project as g}from"../../../../geometry/projection.js";import{normalizeCentralMeridianForDisplay as f}from"../../../../geometry/support/normalizeUtilsSync.js";import{featureGeometryTypeKebabDictionary as _}from"../../../../geometry/support/typeUtils.js";import{convertFromGeometry as v}from"../../../../layers/graphics/featureConversionUtils.js";import{OptimizedFeature as S}from"../../../../layers/graphics/OptimizedFeature.js";import w from"../../../../layers/graphics/data/FeatureStore.js";import{QueryEngine as j}from"../../../../layers/graphics/data/QueryEngine.js";import b from"../../../../layers/support/FieldsIndex.js";import{elevationContextAffectsAlignment as E}from"../../../../support/elevationInfoUtils.js";import{symbolHasExtrudeSymbolLayer as k}from"../../../../symbols/support/utils.js";import{sortCandidatesInPlace as F,makeSnappingQuery as C}from"../snappingUtils.js";import{convertSnappingCandidate as A,makeGetGroundElevation as I}from"./queryEngineUtils.js";import{getSnappingCandidateElevationAligner as P}from"./snappingCandidateElevationAlignment.js";import{getSnappingCandidateElevationFilter as G}from"./snappingCandidateElevationFilter.js";import{getSymbologySnappingCandidatesFetcher as H}from"./symbologySnappingCandidates.js";import{TaskPriority as x}from"../../../support/Scheduler.js";const O="graphics-collections";let R=class extends t{get updating(){return this._updatingHandles.updating}get _hasZ(){const e=this.view;return null!=e&&"3d"===e.type&&"map-notes"!==this.layerSource.layer.type}get _snappingElevationAligner(){const{view:e}=this,{layer:t}=this.layerSource,s=null!=e&&"3d"===e.type;if(!s||"map-notes"===t.type)return P();const o=async(s,o)=>(await n(e.whenLayerView(t),o)).elevationAlignPointsInFeatures(s,o);return P(s,{elevationInfo:t.elevationInfo,alignPointsInFeatures:o})}get _snappingElevationFilter(){const{view:e}=this,t=null!=e&&"3d"===e.type&&"map-notes"!==this.layerSource.layer.type;return G(t)}get _symbologySnappingFetcher(){const{view:e}=this,{layer:t}=this.layerSource,s=null!=e&&"3d"===e.type,o=this._extrudedPolygonSymbolsCount>0;return s&&"map-notes"!==t.type&&o?H(o,(async(s,o)=>{const i=await e.whenLayerView(t);return r(o),i.queryForSymbologySnapping({candidates:s,spatialReference:e.spatialReference},o)})):H()}constructor(e){super(e),this.availability=1,this._sources={multipoint:null,point:null,polygon:null,polyline:null},this._loadedWkids=new Set,this._loadedWkts=new Set,this._pendingAdds=[],this._extrudedPolygonSymbolsCount=0,this._updatingHandles=new u}destroy(){for(const e of this._pendingAdds)e.task.abort();this._pendingAdds.length=0,this._mapSources((e=>this._destroySource(e))),this._updatingHandles.destroy()}initialize(){this._updatingHandles.add((()=>this.getGraphicsLayers()),(e=>{this._updatingHandles.removeHandles(O);for(const t of e)this._addMany(t.graphics.toArray()),this.addHandles([t.on("graphic-update",(e=>this._onGraphicUpdate(e))),this._updatingHandles.addOnCollectionChange((()=>t.graphics),(e=>this._onGraphicsChanged(e)))],O)}),a);const{view:e}=this,{layer:t}=this.layerSource;null!=e&&"3d"===e.type&&"map-notes"!==t.type&&this.addHandles([e.elevationProvider.on("elevation-change",(({context:e})=>{E(e,t.elevationInfo)&&this._snappingElevationAligner.notifyElevationSourceChange()})),p((()=>t.elevationInfo),(()=>this._snappingElevationAligner.notifyElevationSourceChange()),a),l((()=>t),["edits","apply-edits","graphic-update"],(()=>this._symbologySnappingFetcher.notifySymbologyChange()))])}async fetchCandidates(e,t){const{point:s}=e,o=await i(this._mapSources((s=>this._fetchCandidatesForSource(s,e,t))));r(t);const n=this._getGroundElevation,a=o.flat().map((e=>A(e,n)));return F(s,a),a}get _getGroundElevation(){return I(this.view)}async _fetchCandidatesForSource(e,t,s){const o=C(t,this.view?.type??"2d"),i=await e.queryEngine.executeQueryForSnapping(o,s);r(s);const n=await this._snappingElevationAligner.alignCandidates(i.candidates,t.coordinateHelper.spatialReference,s);r(s);const a=await this._symbologySnappingFetcher.fetch(n,s);r(s);const p=0===a.length?n:[...n,...a];return this._snappingElevationFilter.filter(o,p)}refresh(){}_onGraphicUpdate(e){if(this.getGraphicsLayers().some((t=>t.graphics.includes(e.graphic))))switch(e.property){case"geometry":case"visible":this._remove(e.graphic),this._addMany([e.graphic])}}_onGraphicsChanged(e){for(const t of e.removed)this._remove(t);this._addMany(e.added)}_addMany(e){const t=[],s=new Map;for(const o of e)null!=o.geometry&&(this._needsInitializeProjection(o.geometry.spatialReference)?(t.push(o.geometry.spatialReference),s.set(o.uid,o)):this._add(o));this._createPendingAdd(t,s)}_createPendingAdd(e,t){if(!e.length)return;const r=o((async s=>{await y(e.map((e=>({source:e,dest:this.spatialReference}))),{signal:s}),this._markLoadedSpatialReferences(e);for(const[,e]of t)this._add(e)}));this._updatingHandles.addPromise(r.promise);const i={task:r,graphics:t},n=()=>s(this._pendingAdds,i);r.promise.then(n,n),this._pendingAdds.push(i)}_markLoadedSpatialReferences(e){for(const t of e){null!=t.wkid&&this._loadedWkids.add(t.wkid);const e=t.wkt2||t.wkt;e&&this._loadedWkts.add(e)}}_add(e){if(null==e.geometry||!e.visible)return;let t=e.geometry;if("mesh"===t.type)return;"extent"===t.type&&(t=h.fromExtent(t));const s=this._ensureSource(t.type);if(null==s)return;const o=this._createOptimizedFeature(e.uid,t);null!=o&&(s.featureStore.add(o),k(e.symbol)&&this._extrudedPolygonSymbolsCount++)}_needsInitializeProjection(e){if(null!=e.wkid&&this._loadedWkids.has(e.wkid))return!1;const t=e.wkt2||e.wkt;return(!t||!this._loadedWkts.has(t))&&!m(e,this.spatialReference)}_createOptimizedFeature(e,t){const s=g(f(t),this.spatialReference);if(!s)return null;const o=this._ensureGeometryHasZ(s),r=v(o,this._hasZ,!1);return new S(r,{[U]:e},null,e)}_ensureGeometryHasZ(e){if(!this._hasZ)return e;const t=e=>{for(;e.length<3;)e.push(0)},s=e.clone();switch(s.hasZ=!0,s.type){case"point":s.z=s.z??0;break;case"multipoint":s.points.forEach(t);break;case"polyline":s.paths.forEach((e=>e.forEach(t)));break;case"polygon":s.rings.forEach((e=>e.forEach(t)))}return s}_ensureSource(e){const t=this._sources[e];if(null!=t)return t;const s=this._createSource(e);return this._sources[e]=s,s}_createSource(e){const t=_.toJSON(e),s=this._hasZ,o=new w({geometryType:t,hasZ:s,hasM:!1});return{featureStore:o,queryEngine:new j({featureStore:o,fieldsIndex:b.fromLayerJSON({fields:[{name:U,type:"esriFieldTypeOID",alias:U}]}),geometryType:t,hasM:!1,hasZ:s,objectIdField:U,spatialReference:this.spatialReference,priority:x.SNAPPING,scheduler:null!=this.view&&"3d"===this.view.type?this.view.resourceController.scheduler:null}),type:e}}_remove(e){this._mapSources((t=>this._removeFromSource(t,e)));for(const t of this._pendingAdds)t.graphics.delete(e.uid),0===t.graphics.size&&t.task.abort()}_removeFromSource(e,t){const s=t.uid;e.featureStore.has(s)&&(e.featureStore.removeById(t.uid),k(t.symbol)&&this._extrudedPolygonSymbolsCount--)}_destroySource(e){e.queryEngine.destroy(),this._sources[e.type]=null}_mapSources(e){const{point:t,polygon:s,polyline:o,multipoint:r}=this._sources,i=[];return null!=t&&i.push(e(t)),null!=s&&i.push(e(s)),null!=o&&i.push(e(o)),null!=r&&i.push(e(r)),i}};e([d()],R.prototype,"getGraphicsLayers",void 0),e([d({constructOnly:!0})],R.prototype,"layerSource",void 0),e([d({constructOnly:!0})],R.prototype,"spatialReference",void 0),e([d({constructOnly:!0})],R.prototype,"view",void 0),e([d({readOnly:!0})],R.prototype,"updating",null),e([d({readOnly:!0})],R.prototype,"availability",void 0),e([d()],R.prototype,"_hasZ",null),e([d()],R.prototype,"_snappingElevationAligner",null),e([d()],R.prototype,"_snappingElevationFilter",null),e([d()],R.prototype,"_symbologySnappingFetcher",null),e([d()],R.prototype,"_extrudedPolygonSymbolsCount",void 0),e([d()],R.prototype,"_getGroundElevation",null),R=e([c("esri.views.interactive.snapping.featureSources.GraphicsSnappingSource")],R);const U="OBJECTID";export{R as GraphicsSnappingSource};
5
+ import{_ as e}from"../../../../chunks/tslib.es6.js";import t from"../../../../core/Accessor.js";import{removeUnordered as s}from"../../../../core/arrayUtils.js";import{createTask as o}from"../../../../core/asyncUtils.js";import{memoize as r}from"../../../../core/memoize.js";import{throwIfAborted as i,allSettledValues as n,whenOrAbort as a}from"../../../../core/promiseUtils.js";import{initial as p,watch as l,on as d}from"../../../../core/reactiveUtils.js";import{property as c}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/accessorSupport/ensureType.js";import"../../../../core/has.js";import{subclass as u}from"../../../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as h}from"../../../../core/support/UpdatingHandles.js";import y from"../../../../geometry/Polygon.js";import{initializeProjection as m,canProjectWithoutEngine as g,project as f}from"../../../../geometry/projection.js";import{normalizeCentralMeridianForDisplay as _}from"../../../../geometry/support/normalizeUtilsSync.js";import{featureGeometryTypeKebabDictionary as S}from"../../../../geometry/support/typeUtils.js";import{convertFromGeometry as v}from"../../../../layers/graphics/featureConversionUtils.js";import{OptimizedFeature as w}from"../../../../layers/graphics/OptimizedFeature.js";import j from"../../../../layers/graphics/data/FeatureStore.js";import{QueryEngine as b}from"../../../../layers/graphics/data/QueryEngine.js";import E from"../../../../layers/support/FieldsIndex.js";import{elevationContextAffectsAlignment as k}from"../../../../support/elevationInfoUtils.js";import{symbolHasExtrudeSymbolLayer as F}from"../../../../symbols/support/utils.js";import{sortCandidatesInPlace as C,makeSnappingQuery as A}from"../snappingUtils.js";import{convertSnappingCandidate as I,makeGetGroundElevation as P}from"./queryEngineUtils.js";import{getSnappingCandidateElevationAligner as G}from"./snappingCandidateElevationAlignment.js";import{getSnappingCandidateElevationFilter as H}from"./snappingCandidateElevationFilter.js";import{getSymbologySnappingCandidatesFetcher as R}from"./symbologySnappingCandidates.js";import{TaskPriority as x}from"../../../support/Scheduler.js";const z="graphics-collections";let O=class extends t{get updating(){return this._updatingHandles.updating}get _hasZ(){const e=this.view;return null!=e&&"3d"===e.type&&"map-notes"!==this.layerSource.layer.type}get _snappingElevationAligner(){const{view:e}=this,{layer:t}=this.layerSource,s=null!=e&&"3d"===e.type;if(!s||"map-notes"===t.type)return G();const o=async(s,o)=>(await a(e.whenLayerView(t),o)).elevationAlignPointsInFeatures(s,o);return G(s,{elevationInfo:t.elevationInfo,alignPointsInFeatures:o})}get _snappingElevationFilter(){const{view:e}=this,t=null!=e&&"3d"===e.type&&"map-notes"!==this.layerSource.layer.type;return H(t)}get _symbologySnappingFetcher(){const{view:e}=this,{layer:t}=this.layerSource,s=null!=e&&"3d"===e.type,o=this._extrudedPolygonSymbolsCount>0;return s&&"map-notes"!==t.type&&o?R(o,(async(s,o)=>{const r=await e.whenLayerView(t);return i(o),r.queryForSymbologySnapping({candidates:s,spatialReference:e.spatialReference},o)})):R()}constructor(e){super(e),this.availability=1,this._sources={multipoint:null,point:null,polygon:null,polyline:null},this._loadedWkids=new Set,this._loadedWkts=new Set,this._pendingAdds=[],this._extrudedPolygonSymbolsCount=0,this._updatingHandles=new h,this._memoizedMakeGetGroundElevation=r(P)}destroy(){for(const e of this._pendingAdds)e.task.abort();this._pendingAdds.length=0,this._mapSources((e=>this._destroySource(e))),this._updatingHandles.destroy()}initialize(){this._updatingHandles.add((()=>this.getGraphicsLayers()),(e=>{this._updatingHandles.removeHandles(z);for(const t of e)this._addMany(t.graphics.toArray()),this.addHandles([t.on("graphic-update",(e=>this._onGraphicUpdate(e))),this._updatingHandles.addOnCollectionChange((()=>t.graphics),(e=>this._onGraphicsChanged(e)))],z)}),p);const{view:e}=this,{layer:t}=this.layerSource;null!=e&&"3d"===e.type&&"map-notes"!==t.type&&this.addHandles([e.elevationProvider.on("elevation-change",(({context:e})=>{k(e,t.elevationInfo)&&this._snappingElevationAligner.notifyElevationSourceChange()})),l((()=>t.elevationInfo),(()=>this._snappingElevationAligner.notifyElevationSourceChange()),p),d((()=>t),["edits","apply-edits","graphic-update"],(()=>this._symbologySnappingFetcher.notifySymbologyChange()))])}async fetchCandidates(e,t){const{point:s,coordinateHelper:{spatialReference:o}}=e,r=await n(this._mapSources((s=>this._fetchCandidatesForSource(s,e,t))));i(t);const a=this._memoizedMakeGetGroundElevation(this.view,o),p=r.flat().map((e=>I(e,a)));return C(s,p),p}async _fetchCandidatesForSource(e,t,s){const o=A(t,this.view?.type??"2d"),r=await e.queryEngine.executeQueryForSnapping(o,s);i(s);const n=await this._snappingElevationAligner.alignCandidates(r.candidates,t.coordinateHelper.spatialReference,s);i(s);const a=await this._symbologySnappingFetcher.fetch(n,s);i(s);const p=0===a.length?n:[...n,...a];return this._snappingElevationFilter.filter(o,p)}refresh(){}_onGraphicUpdate(e){if(this.getGraphicsLayers().some((t=>t.graphics.includes(e.graphic))))switch(e.property){case"geometry":case"visible":this._remove(e.graphic),this._addMany([e.graphic])}}_onGraphicsChanged(e){for(const t of e.removed)this._remove(t);this._addMany(e.added)}_addMany(e){const t=[],s=new Map;for(const o of e)null!=o.geometry&&(this._needsInitializeProjection(o.geometry.spatialReference)?(t.push(o.geometry.spatialReference),s.set(o.uid,o)):this._add(o));this._createPendingAdd(t,s)}_createPendingAdd(e,t){if(!e.length)return;const r=o((async s=>{await m(e.map((e=>({source:e,dest:this.spatialReference}))),{signal:s}),this._markLoadedSpatialReferences(e);for(const[,e]of t)this._add(e)}));this._updatingHandles.addPromise(r.promise);const i={task:r,graphics:t},n=()=>s(this._pendingAdds,i);r.promise.then(n,n),this._pendingAdds.push(i)}_markLoadedSpatialReferences(e){for(const t of e){null!=t.wkid&&this._loadedWkids.add(t.wkid);const e=t.wkt2||t.wkt;e&&this._loadedWkts.add(e)}}_add(e){if(null==e.geometry||!e.visible)return;let t=e.geometry;if("mesh"===t.type)return;"extent"===t.type&&(t=y.fromExtent(t));const s=this._ensureSource(t.type);if(null==s)return;const o=this._createOptimizedFeature(e.uid,t);null!=o&&(s.featureStore.add(o),F(e.symbol)&&this._extrudedPolygonSymbolsCount++)}_needsInitializeProjection(e){if(null!=e.wkid&&this._loadedWkids.has(e.wkid))return!1;const t=e.wkt2||e.wkt;return(!t||!this._loadedWkts.has(t))&&!g(e,this.spatialReference)}_createOptimizedFeature(e,t){const s=f(_(t),this.spatialReference);if(!s)return null;const o=this._ensureGeometryHasZ(s),r=v(o,this._hasZ,!1);return new w(r,{[U]:e},null,e)}_ensureGeometryHasZ(e){if(!this._hasZ)return e;const t=e=>{for(;e.length<3;)e.push(0)},s=e.clone();switch(s.hasZ=!0,s.type){case"point":s.z=s.z??0;break;case"multipoint":s.points.forEach(t);break;case"polyline":s.paths.forEach((e=>e.forEach(t)));break;case"polygon":s.rings.forEach((e=>e.forEach(t)))}return s}_ensureSource(e){const t=this._sources[e];if(null!=t)return t;const s=this._createSource(e);return this._sources[e]=s,s}_createSource(e){const t=S.toJSON(e),s=this._hasZ,o=new j({geometryType:t,hasZ:s,hasM:!1});return{featureStore:o,queryEngine:new b({featureStore:o,fieldsIndex:E.fromLayerJSON({fields:[{name:U,type:"esriFieldTypeOID",alias:U}]}),geometryType:t,hasM:!1,hasZ:s,objectIdField:U,spatialReference:this.spatialReference,priority:x.SNAPPING,scheduler:null!=this.view&&"3d"===this.view.type?this.view.resourceController.scheduler:null}),type:e}}_remove(e){this._mapSources((t=>this._removeFromSource(t,e)));for(const t of this._pendingAdds)t.graphics.delete(e.uid),0===t.graphics.size&&t.task.abort()}_removeFromSource(e,t){const s=t.uid;e.featureStore.has(s)&&(e.featureStore.removeById(t.uid),F(t.symbol)&&this._extrudedPolygonSymbolsCount--)}_destroySource(e){e.queryEngine.destroy(),this._sources[e.type]=null}_mapSources(e){const{point:t,polygon:s,polyline:o,multipoint:r}=this._sources,i=[];return null!=t&&i.push(e(t)),null!=s&&i.push(e(s)),null!=o&&i.push(e(o)),null!=r&&i.push(e(r)),i}};e([c()],O.prototype,"getGraphicsLayers",void 0),e([c({constructOnly:!0})],O.prototype,"layerSource",void 0),e([c({constructOnly:!0})],O.prototype,"spatialReference",void 0),e([c({constructOnly:!0})],O.prototype,"view",void 0),e([c({readOnly:!0})],O.prototype,"updating",null),e([c({readOnly:!0})],O.prototype,"availability",void 0),e([c()],O.prototype,"_hasZ",null),e([c()],O.prototype,"_snappingElevationAligner",null),e([c()],O.prototype,"_snappingElevationFilter",null),e([c()],O.prototype,"_symbologySnappingFetcher",null),e([c()],O.prototype,"_extrudedPolygonSymbolsCount",void 0),O=e([u("esri.views.interactive.snapping.featureSources.GraphicsSnappingSource")],O);const U="OBJECTID";export{O as GraphicsSnappingSource};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import{fromValues as e}from"../../sketch/normalizedPoint.js";import{DrapedEdgeSnappingCandidate as t}from"../candidates/DrapedEdgeSnappingCandidate.js";import{EdgeSnappingCandidate as n}from"../candidates/EdgeSnappingCandidate.js";import{VertexSnappingCandidate as d}from"../candidates/VertexSnappingCandidate.js";function r({x:t,y:n,z:d}){return e(t,n,d??0)}function a(e,a){switch(e.type){case"edge":return e.draped?new t({edgeStart:r(e.start),edgeEnd:r(e.end),targetPoint:r(e.target),objectId:e.objectId,getGroundElevation:a}):new n({edgeStart:r(e.start),edgeEnd:r(e.end),targetPoint:r(e.target),objectId:e.objectId,isDraped:!1});case"vertex":return new d({targetPoint:r(e.target),objectId:e.objectId,isDraped:!1})}}function i(e){return null!=e&&"3d"===e.type?(t,n,d)=>e.elevationProvider.getElevation(t,n,d??0,e.spatialReference,"ground"):()=>null}export{a as convertSnappingCandidate,i as makeGetGroundElevation};
5
+ import{fromValues as e}from"../../sketch/normalizedPoint.js";import{DrapedEdgeSnappingCandidate as t}from"../candidates/DrapedEdgeSnappingCandidate.js";import{EdgeSnappingCandidate as n}from"../candidates/EdgeSnappingCandidate.js";import{VertexSnappingCandidate as d}from"../candidates/VertexSnappingCandidate.js";function r({x:t,y:n,z:d}){return e(t,n,d??0)}function a(e,a){switch(e.type){case"edge":return e.draped?new t({edgeStart:r(e.start),edgeEnd:r(e.end),targetPoint:r(e.target),objectId:e.objectId,getGroundElevation:a}):new n({edgeStart:r(e.start),edgeEnd:r(e.end),targetPoint:r(e.target),objectId:e.objectId,isDraped:!1});case"vertex":return new d({targetPoint:r(e.target),objectId:e.objectId,isDraped:!1})}}function o(e,t){return null!=e&&"3d"===e.type?(n,d)=>e.elevationProvider.getElevation(n,d,0,t,"ground"):()=>null}export{a as convertSnappingCandidate,o as makeGetGroundElevation};