@arcgis/core 4.23.0-next.20220118 → 4.23.0-next.20220119

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 (27) hide show
  1. package/assets/esri/core/workers/RemoteClient.js +1 -1
  2. package/assets/esri/core/workers/chunks/{2d947080a27db6ce0d75.js → 05db312a0ca6bd3f014a.js} +1 -1
  3. package/assets/esri/core/workers/chunks/{7c9d2638693d5f798b23.js → 1b28042fdf3f4dbc8ea5.js} +1 -1
  4. package/assets/esri/core/workers/chunks/43cdff2418325e163420.js +1 -0
  5. package/assets/esri/core/workers/chunks/{bc790b2f964144d10abe.js → 618076e6de605873e433.js} +1 -1
  6. package/assets/esri/core/workers/chunks/{ba6fdaed6c315dc13981.js → 625d2663daa8e0cf64b0.js} +1 -1
  7. package/assets/esri/core/workers/chunks/{85b34d91cf07567d6873.js → 67162b3e2cc1b5dc6818.js} +1 -1
  8. package/assets/esri/core/workers/chunks/{987182b3a578fc7de251.js → 76eef4799f6c5fff7e2d.js} +1 -1
  9. package/assets/esri/core/workers/chunks/{b99e69302ea701fff0ea.js → c8f976e53e232e8da9cc.js} +39 -29
  10. package/assets/esri/core/workers/chunks/{4c301ca9c493b96df746.js → e6df9839b551569fbc62.js} +1 -1
  11. package/chunks/DefaultMaterial.glsl.js +2 -2
  12. package/core/typedArrayUtil.js +1 -1
  13. package/layers/mixins/OperationalLayer.js +1 -1
  14. package/package.json +1 -1
  15. package/rasterRenderers.js +1 -1
  16. package/support/revision.js +1 -1
  17. package/views/2d/engine/vectorTiles/style/VectorTilesRequestManager.js +1 -1
  18. package/views/3d/webgl-engine/core/shaderLibrary/Transform.glsl.js +7 -1
  19. package/views/3d/webgl-engine/core/shaderLibrary/default/DefaultMaterialAuxiliaryPasses.glsl.js +28 -24
  20. package/views/3d/webgl-engine/lib/TextRenderer.js +1 -1
  21. package/views/3d/webgl-engine/materials/DefaultMaterial.js +1 -1
  22. package/views/3d/webgl-engine/shaders/DefaultMaterialTechnique.js +1 -1
  23. package/views/3d/webgl-engine/shaders/RealisticTreeTechnique.js +1 -1
  24. package/views/SceneView.js +1 -1
  25. package/views/support/DefaultsFromMap.js +1 -1
  26. package/widgets/Editor/workflowUtils.js +1 -1
  27. package/assets/esri/core/workers/chunks/89de05207744149fb58b.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.23/esri/copyright.txt for details.
4
4
  */
5
- import{isNone as e,isSome as t}from"../../../../core/maybe.js";import i from"../../support/debugFlags.js";class s{constructor(e,t,i=2048){this.text=e,this._parameters=t,this.maxSize=i,this._lineWidths=new Array,this._renderPixelRatio=null,this._displayWidth=null,this._lineHeight=null,this._baselinePosition=null,this.key=`${this._parameters.key}--${e}`,this._lines=e.split(/\r?\n/)}get displayWidth(){return this._ensureTextWidth()}get displayHeight(){const e=this.linePadding*(this._lines.length-1);return Math.ceil(this.lineHeight*this._lines.length+e)}get renderedWidth(){return Math.ceil(this.displayWidth*this.renderPixelRatio)}get renderedHeight(){return Math.ceil(this.displayHeight*this.renderPixelRatio)}get renderedLineSpacing(){return(this.lineHeight+this.linePadding)*this.renderPixelRatio}get lineHeight(){return this._ensureHeightMetrics().lineHeight}get linePadding(){return this.lineHeight*d}get renderedBaselinePosition(){return this.baselinePosition*this.renderPixelRatio}get baselinePosition(){return this._ensureHeightMetrics().baselinePosition}get renderedFontSize(){return this._parameters.definition.size*this.renderPixelRatio}get renderedHaloSize(){return this._parameters.haloSize*this.renderPixelRatio}get renderPixelRatio(){if(e(this._renderPixelRatio)){const e=this._parameters.definition.pixelRatio;this.maxSize>0?this._renderPixelRatio=Math.min(e,Math.min(this.maxSize/(this.displayWidth*e),this.maxSize/(this.displayHeight*e))):this._renderPixelRatio=e}return this._renderPixelRatio}_getLineXOffset(e){return Math.round((this.renderedWidth-this._lineWidths[e]*this.renderPixelRatio)/2)}render(e,t=0,s=0){const r=this.renderedLineSpacing,o=this.renderedHaloSize,l=t,a=s,d=n(e.textAlign,this.renderedWidth)+o,g=o;e.save(),o>0&&this._renderHalo(e,d,g,t,s),this._setFontProperties(e,this.renderedFontSize),s+=g+this.renderedBaselinePosition,t+=d;for(let i=0;i<this._lines.length;++i){e.globalCompositeOperation="destination-out",e.fillStyle="rgb(0, 0, 0)";const n=this._lines[i];h(e,n,t+this._getLineXOffset(i),s),e.globalCompositeOperation="source-over",e.fillStyle=this._parameters.fillStyle,h(e,n,t+this._getLineXOffset(i),s),s+=r}if(i.TEXT_SHOW_BASELINE){e.strokeStyle=_,e.setLineDash([2,2]),e.lineWidth=1;let t=a+g;const i=this.renderedBaselinePosition;for(let s=0;s<this._lines.length;++s){const s=Math.round(t+i)+.5;e.beginPath(),e.moveTo(l,s),e.lineTo(l+this.renderedWidth,s),e.stroke(),t+=r}}i.TEXT_SHOW_BORDER&&(e.strokeStyle=_,e.setLineDash([]),e.lineWidth=1,e.beginPath(),e.moveTo(l+.5,a+.5),e.lineTo(l+this.renderedWidth-.5,a+.5),e.lineTo(l+this.renderedWidth-.5,a+this.renderedHeight-.5),e.lineTo(l+.5,a+this.renderedHeight-.5),e.lineTo(l+.5,a+.5),e.stroke()),e.restore()}_renderHalo(e,t,i,s,n){const r=this.renderedWidth,h=this.renderedHeight,o=l(a,Math.max(r,g),Math.max(h,g)),d=o.getContext("2d");d.clearRect(0,0,r,h),this._setFontProperties(d,this.renderedFontSize),d.fillStyle=this._parameters.haloStyle,d.strokeStyle=this._parameters.haloStyle;const _=this.renderedHaloSize<3;d.lineJoin=_?"miter":"round",_?this._renderHaloEmulated(d,t,i):this._renderHaloNative(d,t,i),e.globalAlpha=this._parameters.definition.halo.color[3],e.drawImage(o,0,0,r,h,s,n,r,h),e.globalAlpha=1}_renderHaloEmulated(e,t,i){const s=this.renderedLineSpacing,n=this.renderedHaloSize,o=this.renderedBaselinePosition;for(let l=0;l<this._lines.length;++l){const a=this._lines[l],d=this._getLineXOffset(l);for(const[s,l]of r)h(e,a,t+d+n*s,i+o+n*l);i+=s}}_renderHaloNative(e,t,i){const s=this.renderedLineSpacing,n=this.renderedHaloSize,r=this.renderedBaselinePosition;for(let h=0;h<this._lines.length;++h){const l=2*n,a=this._lines[h],d=this._getLineXOffset(h),g=5,_=.1;for(let s=0;s<g;s++){const n=1-(g-1)*_+s*_;e.lineWidth=n*l,o(e,a,t+d,i+r)}i+=s}}_setFontProperties(e,t){e.font=this._parameters.fontString(t),e.textAlign="left",e.textBaseline="alphabetic"}_ensureTextWidth(){if(t(this._displayWidth))return this._displayWidth;const e=l(a,g,g).getContext("2d");this._setFontProperties(e,this._parameters.definition.size);let i=0,s=2*this._parameters.haloSize;this._lineWidths.length=0;const n=this._parameters.definition.font;("italic"===n.style||"oblique"===n.style||"string"==typeof n.weight&&("bold"===n.weight||"bolder"===n.weight)||"number"==typeof n.weight&&n.weight>600)&&(s+=.3*e.measureText("A").width);for(const t of this._lines){const n=Math.ceil(e.measureText(t).width+s);this._lineWidths.push(n),i=Math.max(i,n)}return this._displayWidth=i,this._displayWidth}_ensureHeightMetrics(){if(e(this._lineHeight)||e(this._baselinePosition)){const e=this.text+c,t=l(a,g,g).getContext("2d");this._setFontProperties(t,this._parameters.definition.size);const i=t.measureText(e),s=i.actualBoundingBoxAscent+i.actualBoundingBoxDescent;this._lineHeight=Math.ceil(s+2*this._parameters.haloSize),this._baselinePosition=i.actualBoundingBoxAscent}return{lineHeight:this._lineHeight,baselinePosition:this._baselinePosition}}}function n(e,t){return"center"===e?.5*t:"right"===e?t:0}const r=[];{const e=16;for(let t=0;t<360;t+=360/e)r.push([Math.cos(Math.PI*t/180),Math.sin(Math.PI*t/180)])}function h(e,t,i,s){e.fillText(t,Math.round(i),Math.round(s))}function o(e,t,i,s){e.strokeText(t,Math.round(i),Math.round(s))}function l(e,t,i){return e.canvas||(e.canvas=document.createElement("canvas")),e.canvas.width=t,e.canvas.height=i,e.canvas}const a={canvas:null},d=.25,g=512,_="rgb(255, 0, 255, 0.5)",c=(()=>{let e="";for(let t=32;t<127;t++)e+=String.fromCharCode(t);return e})();export{s as TextRenderer,s as default,l as getTextHelperCanvas};
5
+ import{isNone as e,isSome as t}from"../../../../core/maybe.js";import i from"../../support/debugFlags.js";class s{constructor(e,t,i=2048){this.text=e,this._parameters=t,this.maxSize=i,this._lineWidths=new Array,this._renderPixelRatio=null,this._displayWidth=null,this._lineHeight=null,this._baselinePosition=null,this.key=`${this._parameters.key}--${e}`,this._lines=e.split(/\r?\n/)}get displayWidth(){return this._ensureTextWidth()}get displayHeight(){const e=this.linePadding*(this._lines.length-1);return Math.ceil(this.lineHeight*this._lines.length+e)}get renderedWidth(){return Math.ceil(this.displayWidth*this.renderPixelRatio)}get renderedHeight(){return Math.ceil(this.displayHeight*this.renderPixelRatio)}get renderedLineSpacing(){return(this.lineHeight+this.linePadding)*this.renderPixelRatio}get lineHeight(){return this._ensureHeightMetrics().lineHeight}get linePadding(){return this.lineHeight*d}get renderedBaselinePosition(){return this.baselinePosition*this.renderPixelRatio}get baselinePosition(){return this._ensureHeightMetrics().baselinePosition}get renderedFontSize(){return this._parameters.definition.size*this.renderPixelRatio}get renderedHaloSize(){return this._parameters.haloSize*this.renderPixelRatio}get renderPixelRatio(){if(e(this._renderPixelRatio)){const e=this._parameters.definition.pixelRatio;this.maxSize>0?this._renderPixelRatio=Math.min(e,Math.min(this.maxSize/(this.displayWidth*e),this.maxSize/(this.displayHeight*e))):this._renderPixelRatio=e}return this._renderPixelRatio}_getLineXOffset(e){return Math.round((this.renderedWidth-this._lineWidths[e]*this.renderPixelRatio)/2)}render(e,t=0,s=0){const r=this.renderedLineSpacing,o=this.renderedHaloSize,l=t,a=s,d=n(e.textAlign,this.renderedWidth)+o,g=o;e.save(),o>0&&this._renderHalo(e,d,g,t,s),this._setFontProperties(e,this.renderedFontSize),s+=g+this.renderedBaselinePosition,t+=d;for(let i=0;i<this._lines.length;++i){e.globalCompositeOperation="destination-out",e.fillStyle="rgb(0, 0, 0)";const n=this._lines[i];h(e,n,t+this._getLineXOffset(i),s),e.globalCompositeOperation="source-over",e.fillStyle=this._parameters.fillStyle,h(e,n,t+this._getLineXOffset(i),s),s+=r}if(i.TEXT_SHOW_BASELINE){e.strokeStyle=_,e.setLineDash([2,2]),e.lineWidth=1;let t=a+g;const i=this.renderedBaselinePosition;for(let s=0;s<this._lines.length;++s){const s=Math.round(t+i)+.5;e.beginPath(),e.moveTo(l,s),e.lineTo(l+this.renderedWidth,s),e.stroke(),t+=r}}i.TEXT_SHOW_BORDER&&(e.strokeStyle=_,e.setLineDash([]),e.lineWidth=1,e.beginPath(),e.moveTo(l+.5,a+.5),e.lineTo(l+this.renderedWidth-.5,a+.5),e.lineTo(l+this.renderedWidth-.5,a+this.renderedHeight-.5),e.lineTo(l+.5,a+this.renderedHeight-.5),e.lineTo(l+.5,a+.5),e.stroke()),e.restore()}_renderHalo(e,t,i,s,n){const r=this.renderedWidth,h=this.renderedHeight,o=l(a,Math.max(r,g),Math.max(h,g)),d=o.getContext("2d");d.clearRect(0,0,r,h),this._setFontProperties(d,this.renderedFontSize),d.fillStyle=this._parameters.haloStyle,d.strokeStyle=this._parameters.haloStyle;const _=this.renderedHaloSize<3;d.lineJoin=_?"miter":"round",_?this._renderHaloEmulated(d,t,i):this._renderHaloNative(d,t,i),e.globalAlpha=this._parameters.definition.halo.color[3],e.drawImage(o,0,0,r,h,s,n,r,h),e.globalAlpha=1}_renderHaloEmulated(e,t,i){const s=this.renderedLineSpacing,n=this.renderedHaloSize,o=this.renderedBaselinePosition;for(let l=0;l<this._lines.length;++l){const a=this._lines[l],d=this._getLineXOffset(l);for(const[s,l]of r)h(e,a,t+d+n*s,i+o+n*l);i+=s}}_renderHaloNative(e,t,i){const s=this.renderedLineSpacing,n=this.renderedHaloSize,r=this.renderedBaselinePosition;for(let h=0;h<this._lines.length;++h){const l=2*n,a=this._lines[h],d=this._getLineXOffset(h),g=5,_=.1;for(let s=0;s<g;s++){const n=1-(g-1)*_+s*_;e.lineWidth=n*l,o(e,a,t+d,i+r)}i+=s}}_setFontProperties(e,t){e.font=this._parameters.fontString(t),e.textAlign="left",e.textBaseline="alphabetic"}_ensureTextWidth(){if(t(this._displayWidth))return this._displayWidth;const e=l(a,g,g).getContext("2d");this._setFontProperties(e,this._parameters.definition.size);let i=0,s=2*this._parameters.haloSize;this._lineWidths.length=0;const n=this._parameters.definition.font;("italic"===n.style||"oblique"===n.style||"string"==typeof n.weight&&("bold"===n.weight||"bolder"===n.weight)||"number"==typeof n.weight&&n.weight>600)&&(s+=.3*e.measureText("A").width);for(const t of this._lines){const n=Math.ceil(e.measureText(t).width+s);this._lineWidths.push(n),i=Math.max(i,n)}return this._displayWidth=i,this._displayWidth}_ensureHeightMetrics(){if(e(this._lineHeight)||e(this._baselinePosition)){const e=this.text+c,t=l(a,g,g).getContext("2d");this._setFontProperties(t,this._parameters.definition.size);const i=t.measureText(e),s=i.actualBoundingBoxAscent+i.actualBoundingBoxDescent;this._lineHeight=Math.ceil(s+2*this._parameters.haloSize),this._baselinePosition=i.actualBoundingBoxAscent}return{lineHeight:this._lineHeight,baselinePosition:this._baselinePosition}}}function n(e,t){return"center"===e?.5*t:"right"===e?t:0}const r=[];{const e=16;for(let t=0;t<360;t+=360/e)r.push([Math.cos(Math.PI*t/180),Math.sin(Math.PI*t/180)])}function h(e,t,i,s){e.fillText(t,Math.round(i),Math.round(s))}function o(e,t,i,s){e.strokeText(t,Math.round(i),Math.round(s))}function l(e,t,i){return e.canvas||(e.canvas=document.createElement("canvas")),e.canvas.width=t,e.canvas.height=i,e.canvas}const a={canvas:null},d=.2,g=512,_="rgb(255, 0, 255, 0.5)",c=(()=>{let e="";for(let t=32;t<127;t++)e+=String.fromCharCode(t);return e})();export{s as TextRenderer,s as default,l as getTextHelperCanvas};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.23/esri/copyright.txt for details.
4
4
  */
5
- import{c as e}from"../../../../chunks/mat3f64.js";import{s as t,g as i,n as s,f as r,l as a,a as n,d as o,t as l}from"../../../../chunks/vec3.js";import{c,f as u}from"../../../../chunks/vec3f64.js";import{ViewingMode as h}from"../../../ViewingMode.js";import{newLayout as d}from"../../support/buffer/InterleavedLayout.js";import{ShaderOutput as p}from"../core/shaderLibrary/ShaderOutputOptions.js";import{Normals as m}from"../core/shaderLibrary/shading/Normals.glsl.js";import{defaultMaskAlphaCutoff as f}from"../core/shaderLibrary/util/AlphaDiscard.glsl.js";import{CullFaceOptions as v,AlphaDiscardMode as g,VertexAttribute as b}from"../lib/basicInterfaces.js";import T from"../lib/GLMaterialTexture.js";import{materialParametersDefaults as C,Material as S}from"../lib/Material.js";import{OITPolygonOffsetLimit as O}from"../lib/OrderIndependentTransparency.js";import{RenderPass as x}from"../lib/RenderPass.js";import{RenderSlot as A}from"../lib/RenderSlot.js";import{getVerticalOffsetObject3D as E}from"../lib/verticalOffsetUtils.js";import{writeDefaultAttributes as M}from"./internal/bufferWriterUtils.js";import{verticalOffsetAtDistance as q,intersectTriangleGeometry as I}from"./internal/MaterialUtil.js";import{DefaultMaterialTechniqueConfiguration as P,DefaultMaterialTechnique as L}from"../shaders/DefaultMaterialTechnique.js";import{RealisticTreeTechnique as D}from"../shaders/RealisticTreeTechnique.js";class R extends S{constructor(e){super(e,_),this.supportsEdges=!0,this.techniqueConfig=new P,this.vertexBufferLayout=B(this.parameters),this.instanceBufferLayout=e.instanced?N(this.parameters):null}isVisibleInPass(e){return e!==x.MATERIAL_DEPTH_SHADOWMAP_ALL&&e!==x.MATERIAL_DEPTH_SHADOWMAP_DEFAULT&&e!==x.MATERIAL_DEPTH_SHADOWMAP_HIGHLIGHT||this.parameters.castShadows}isVisible(){const e=this.parameters;if(!super.isVisible()||0===e.layerOpacity)return!1;const t=e.instanced,i=e.vertexColors,s=e.symbolColors,r=!!t&&t.indexOf("color")>-1,a=e.vvColorEnabled,n="replace"===e.colorMixMode,o=e.opacity>0,l=e.externalColor&&e.externalColor[3]>0;return i&&(r||a||s)?!!n||o:i?n?l:o:r||a||s?!!n||o:n?l:o}getTechniqueConfig(e,t){return this.techniqueConfig.output=e,this.techniqueConfig.hasNormalTexture=!!this.parameters.normalTextureId,this.techniqueConfig.hasColorTexture=!!this.parameters.textureId,this.techniqueConfig.vertexTangents=this.parameters.vertexTangents,this.techniqueConfig.instanced=!!this.parameters.instanced,this.techniqueConfig.instancedDoublePrecision=this.parameters.instancedDoublePrecision,this.techniqueConfig.vvSize=this.parameters.vvSizeEnabled,this.techniqueConfig.verticalOffset=null!==this.parameters.verticalOffset,this.techniqueConfig.screenSizePerspective=null!==this.parameters.screenSizePerspective,this.techniqueConfig.slicePlaneEnabled=this.parameters.slicePlaneEnabled,this.techniqueConfig.sliceHighlightDisabled=this.parameters.sliceHighlightDisabled,this.techniqueConfig.alphaDiscardMode=this.parameters.textureAlphaMode,this.techniqueConfig.normalsTypeDerivate="screenDerivative"===this.parameters.normals,this.techniqueConfig.transparent=this.parameters.transparent,this.techniqueConfig.writeDepth=this.parameters.writeDepth,this.techniqueConfig.sceneHasOcludees=this.parameters.sceneHasOcludees,this.techniqueConfig.cullFace=this.parameters.slicePlaneEnabled?v.None:this.parameters.cullFace,this.techniqueConfig.multipassTerrainEnabled=t.multipassTerrainEnabled,this.techniqueConfig.cullAboveGround=t.cullAboveGround,e!==p.Color&&e!==p.Alpha||(this.techniqueConfig.vertexColors=this.parameters.vertexColors,this.techniqueConfig.symbolColors=this.parameters.symbolColors,this.parameters.treeRendering?this.techniqueConfig.doubleSidedMode=m.DoubleSidedMode.WindingOrder:this.techniqueConfig.doubleSidedMode=this.parameters.doubleSided&&"normal"===this.parameters.doubleSidedType?m.DoubleSidedMode.View:this.parameters.doubleSided&&"winding-order"===this.parameters.doubleSidedType?m.DoubleSidedMode.WindingOrder:m.DoubleSidedMode.None,this.techniqueConfig.instancedColor=!!this.parameters.instanced&&this.parameters.instanced.indexOf("color")>-1,this.techniqueConfig.receiveShadows=this.parameters.receiveShadows&&this.parameters.shadowMappingEnabled,this.techniqueConfig.receiveAmbientOcclusion=!!t.ssaoEnabled&&this.parameters.receiveSSAO,this.techniqueConfig.vvColor=this.parameters.vvColorEnabled,this.techniqueConfig.textureAlphaPremultiplied=!!this.parameters.textureAlphaPremultiplied,this.techniqueConfig.usePBR=this.parameters.usePBR,this.techniqueConfig.hasMetalnessAndRoughnessTexture=!!this.parameters.metallicRoughnessTextureId,this.techniqueConfig.hasEmissionTexture=!!this.parameters.emissiveTextureId,this.techniqueConfig.hasOcclusionTexture=!!this.parameters.occlusionTextureId,this.techniqueConfig.offsetBackfaces=!(!this.parameters.transparent||!this.parameters.offsetTransparentBackfaces),this.techniqueConfig.isSchematic=this.parameters.usePBR&&this.parameters.isSchematic,this.techniqueConfig.transparencyPassType=t.transparencyPassType,this.techniqueConfig.enableOffset=t.camera.relativeElevation<O),this.techniqueConfig}intersect(e,c,u,d,p,m,f){if(null!==this.parameters.verticalOffset){const e=d.camera;t(F,u[12],u[13],u[14]);let c=null;switch(d.viewingMode){case h.Global:c=s(G,F);break;case h.Local:c=i(G,z)}let f=0;if(null!==this.parameters.verticalOffset){const t=r(U,F,e.eye),i=a(t),s=n(t,t,1/i);let l=null;this.parameters.screenSizePerspective&&(l=o(c,s)),f+=q(e,i,this.parameters.verticalOffset,l,this.parameters.screenSizePerspective)}n(c,c,f),l(k,c,d.transform.inverseRotation),p=r(H,p,k),m=r(j,m,k)}I(e,c,d,p,m,E(d.verticalOffset),f)}requiresSlot(e){return e===(this.parameters.transparent?this.parameters.writeDepth?A.TRANSPARENT_MATERIAL:A.TRANSPARENT_DEPTH_WRITE_DISABLED_MATERIAL:A.OPAQUE_MATERIAL)||e===A.DRAPED_MATERIAL}createGLMaterial(e){return e.output===p.Color||e.output===p.Alpha||e.output===p.Depth||e.output===p.Normal||e.output===p.Shadow||e.output===p.Highlight?new y(e):null}createBufferWriter(){return new w(this.vertexBufferLayout,this.instanceBufferLayout)}}class y extends T{constructor(e){super({...e,...e.material.parameters})}updateParameters(e){const t=this._material.parameters;return this.updateTexture(t.textureId),this.ensureTechnique(t.treeRendering?D:L,e)}_updateShadowState(e){e.shadowMappingEnabled!==this._material.parameters.shadowMappingEnabled&&this._material.setParameters({shadowMappingEnabled:e.shadowMappingEnabled})}_updateOccludeeState(e){e.hasOccludees!==this._material.parameters.sceneHasOcludees&&this._material.setParameters({sceneHasOcludees:e.hasOccludees})}beginSlot(e){return this._output!==p.Color&&this._output!==p.Alpha||(this._updateShadowState(e),this._updateOccludeeState(e)),this.updateParameters(e)}bind(e,t){t.bindPass(this._material.parameters,e),this.bindTextures(t.program)}}const _={textureId:void 0,initTextureTransparent:!1,isSchematic:!1,usePBR:!1,normalTextureId:void 0,vertexTangents:!1,occlusionTextureId:void 0,emissiveTextureId:void 0,metallicRoughnessTextureId:void 0,emissiveFactor:[0,0,0],mrrFactors:[0,1,.5],ambient:[.2,.2,.2],diffuse:[.8,.8,.8],externalColor:[1,1,1,1],colorMixMode:"multiply",opacity:1,layerOpacity:1,vertexColors:!1,symbolColors:!1,doubleSided:!1,doubleSidedType:"normal",cullFace:v.Back,instanced:void 0,instancedDoublePrecision:!1,normals:"default",receiveSSAO:!0,receiveShadows:!0,castShadows:!0,shadowMappingEnabled:!1,verticalOffset:null,screenSizePerspective:null,slicePlaneEnabled:!1,sliceHighlightDisabled:!1,offsetTransparentBackfaces:!1,vvSizeEnabled:!1,vvSizeMinSize:[1,1,1],vvSizeMaxSize:[100,100,100],vvSizeOffset:[0,0,0],vvSizeFactor:[1,1,1],vvSizeValue:[1,1,1],vvColorEnabled:!1,vvColorValues:[0,0,0,0,0,0,0,0],vvColorColors:[1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0],vvSymbolAnchor:[0,0,0],vvSymbolRotationMatrix:e(),transparent:!1,writeDepth:!0,textureAlphaMode:g.Blend,textureAlphaCutoff:f,textureAlphaPremultiplied:!1,sceneHasOcludees:!1,...C};class w{constructor(e,t){this.vertexBufferLayout=e,this.instanceBufferLayout=t}allocate(e){return this.vertexBufferLayout.createBuffer(e)}elementCount(e){return e.indices.get(b.POSITION).length}write(e,t,i,s){M(t,this.vertexBufferLayout,e.transformation,e.invTranspTransformation,i,s)}}function B(e){const t=e.textureId||e.normalTextureId||e.metallicRoughnessTextureId||e.emissiveTextureId||e.occlusionTextureId,i=d().vec3f(b.POSITION).vec3f(b.NORMAL);return e.vertexTangents&&i.vec4f(b.TANGENT),t&&i.vec2f(b.UV0),e.vertexColors&&i.vec4u8(b.COLOR),e.symbolColors&&i.vec4u8(b.SYMBOLCOLOR),i}function N(e){let t=d();return t=e.instancedDoublePrecision?t.vec3f(b.MODELORIGINHI).vec3f(b.MODELORIGINLO).mat3f(b.MODEL).mat3f(b.MODELNORMAL):t.mat4f(b.MODEL).mat4f(b.MODELNORMAL),e.instanced&&e.instanced.indexOf("color")>-1&&(t=t.vec4f(b.INSTANCECOLOR)),e.instanced&&e.instanced.indexOf("featureAttribute")>-1&&(t=t.vec4f(b.INSTANCEFEATUREATTRIBUTE)),t}const H=c(),j=c(),z=u(0,0,1),G=c(),k=c(),F=c(),U=c();export{R as DefaultMaterial,N as getInstanceBufferLayout};
5
+ import{isSome as e}from"../../../../core/maybe.js";import{c as t}from"../../../../chunks/mat3f64.js";import{s as i,g as s,n as r,f as a,l as n,a as o,d as l,t as c}from"../../../../chunks/vec3.js";import{c as u,f as h}from"../../../../chunks/vec3f64.js";import{ViewingMode as d}from"../../../ViewingMode.js";import{newLayout as p}from"../../support/buffer/InterleavedLayout.js";import{ShaderOutput as m}from"../core/shaderLibrary/ShaderOutputOptions.js";import{Normals as f}from"../core/shaderLibrary/shading/Normals.glsl.js";import{defaultMaskAlphaCutoff as v}from"../core/shaderLibrary/util/AlphaDiscard.glsl.js";import{CullFaceOptions as g,AlphaDiscardMode as T,VertexAttribute as b}from"../lib/basicInterfaces.js";import C from"../lib/GLMaterialTexture.js";import{materialParametersDefaults as S,Material as O}from"../lib/Material.js";import{OITPolygonOffsetLimit as x}from"../lib/OrderIndependentTransparency.js";import{RenderPass as A}from"../lib/RenderPass.js";import{RenderSlot as E}from"../lib/RenderSlot.js";import{getVerticalOffsetObject3D as M}from"../lib/verticalOffsetUtils.js";import{writeDefaultAttributes as q}from"./internal/bufferWriterUtils.js";import{verticalOffsetAtDistance as I,intersectTriangleGeometry as P}from"./internal/MaterialUtil.js";import{DefaultMaterialTechniqueConfiguration as L,DefaultMaterialTechnique as D}from"../shaders/DefaultMaterialTechnique.js";import{RealisticTreeTechnique as R}from"../shaders/RealisticTreeTechnique.js";class y extends O{constructor(e){super(e,w),this.supportsEdges=!0,this.techniqueConfig=new L,this.vertexBufferLayout=N(this.parameters),this.instanceBufferLayout=e.instanced?j(this.parameters):null}isVisibleInPass(e){return e!==A.MATERIAL_DEPTH_SHADOWMAP_ALL&&e!==A.MATERIAL_DEPTH_SHADOWMAP_DEFAULT&&e!==A.MATERIAL_DEPTH_SHADOWMAP_HIGHLIGHT||this.parameters.castShadows}isVisible(){const e=this.parameters;if(!super.isVisible()||0===e.layerOpacity)return!1;const t=e.instanced,i=e.vertexColors,s=e.symbolColors,r=!!t&&t.indexOf("color")>-1,a=e.vvColorEnabled,n="replace"===e.colorMixMode,o=e.opacity>0,l=e.externalColor&&e.externalColor[3]>0;return i&&(r||a||s)?!!n||o:i?n?l:o:r||a||s?!!n||o:n?l:o}getTechniqueConfig(t,i){return this.techniqueConfig.output=t,this.techniqueConfig.hasNormalTexture=!!this.parameters.normalTextureId,this.techniqueConfig.hasColorTexture=!!this.parameters.textureId,this.techniqueConfig.vertexTangents=this.parameters.vertexTangents,this.techniqueConfig.instanced=!!this.parameters.instanced,this.techniqueConfig.instancedDoublePrecision=this.parameters.instancedDoublePrecision,this.techniqueConfig.vvSize=this.parameters.vvSizeEnabled,this.techniqueConfig.verticalOffset=null!==this.parameters.verticalOffset,this.techniqueConfig.screenSizePerspective=null!==this.parameters.screenSizePerspective,this.techniqueConfig.slicePlaneEnabled=this.parameters.slicePlaneEnabled,this.techniqueConfig.sliceHighlightDisabled=this.parameters.sliceHighlightDisabled,this.techniqueConfig.alphaDiscardMode=this.parameters.textureAlphaMode,this.techniqueConfig.normalsTypeDerivate="screenDerivative"===this.parameters.normals,this.techniqueConfig.transparent=this.parameters.transparent,this.techniqueConfig.writeDepth=this.parameters.writeDepth,this.techniqueConfig.sceneHasOcludees=this.parameters.sceneHasOcludees,this.techniqueConfig.cullFace=this.parameters.slicePlaneEnabled?g.None:this.parameters.cullFace,this.techniqueConfig.multipassTerrainEnabled=i.multipassTerrainEnabled,this.techniqueConfig.cullAboveGround=i.cullAboveGround,this.techniqueConfig.hasModelTransformation=e(this.parameters.modelTransformation),t!==m.Color&&t!==m.Alpha||(this.techniqueConfig.vertexColors=this.parameters.vertexColors,this.techniqueConfig.symbolColors=this.parameters.symbolColors,this.parameters.treeRendering?this.techniqueConfig.doubleSidedMode=f.DoubleSidedMode.WindingOrder:this.techniqueConfig.doubleSidedMode=this.parameters.doubleSided&&"normal"===this.parameters.doubleSidedType?f.DoubleSidedMode.View:this.parameters.doubleSided&&"winding-order"===this.parameters.doubleSidedType?f.DoubleSidedMode.WindingOrder:f.DoubleSidedMode.None,this.techniqueConfig.instancedColor=!!this.parameters.instanced&&this.parameters.instanced.indexOf("color")>-1,this.techniqueConfig.receiveShadows=this.parameters.receiveShadows&&this.parameters.shadowMappingEnabled,this.techniqueConfig.receiveAmbientOcclusion=!!i.ssaoEnabled&&this.parameters.receiveSSAO,this.techniqueConfig.vvColor=this.parameters.vvColorEnabled,this.techniqueConfig.textureAlphaPremultiplied=!!this.parameters.textureAlphaPremultiplied,this.techniqueConfig.usePBR=this.parameters.usePBR,this.techniqueConfig.hasMetalnessAndRoughnessTexture=!!this.parameters.metallicRoughnessTextureId,this.techniqueConfig.hasEmissionTexture=!!this.parameters.emissiveTextureId,this.techniqueConfig.hasOcclusionTexture=!!this.parameters.occlusionTextureId,this.techniqueConfig.offsetBackfaces=!(!this.parameters.transparent||!this.parameters.offsetTransparentBackfaces),this.techniqueConfig.isSchematic=this.parameters.usePBR&&this.parameters.isSchematic,this.techniqueConfig.transparencyPassType=i.transparencyPassType,this.techniqueConfig.enableOffset=i.camera.relativeElevation<x),this.techniqueConfig}intersect(e,t,u,h,p,m,f){if(null!==this.parameters.verticalOffset){const e=h.camera;i(U,u[12],u[13],u[14]);let t=null;switch(h.viewingMode){case d.Global:t=r(k,U);break;case d.Local:t=s(k,G)}let f=0;if(null!==this.parameters.verticalOffset){const i=a(V,U,e.eye),s=n(i),r=o(i,i,1/s);let c=null;this.parameters.screenSizePerspective&&(c=l(t,r)),f+=I(e,s,this.parameters.verticalOffset,c,this.parameters.screenSizePerspective)}o(t,t,f),c(F,t,h.transform.inverseRotation),p=a(H,p,F),m=a(z,m,F)}P(e,t,h,p,m,M(h.verticalOffset),f)}requiresSlot(e){return e===(this.parameters.transparent?this.parameters.writeDepth?E.TRANSPARENT_MATERIAL:E.TRANSPARENT_DEPTH_WRITE_DISABLED_MATERIAL:E.OPAQUE_MATERIAL)||e===E.DRAPED_MATERIAL}createGLMaterial(e){return e.output===m.Color||e.output===m.Alpha||e.output===m.Depth||e.output===m.Normal||e.output===m.Shadow||e.output===m.Highlight?new _(e):null}createBufferWriter(){return new B(this.vertexBufferLayout,this.instanceBufferLayout)}}class _ extends C{constructor(e){super({...e,...e.material.parameters})}updateParameters(e){const t=this._material.parameters;return this.updateTexture(t.textureId),this.ensureTechnique(t.treeRendering?R:D,e)}_updateShadowState(e){e.shadowMappingEnabled!==this._material.parameters.shadowMappingEnabled&&this._material.setParameters({shadowMappingEnabled:e.shadowMappingEnabled})}_updateOccludeeState(e){e.hasOccludees!==this._material.parameters.sceneHasOcludees&&this._material.setParameters({sceneHasOcludees:e.hasOccludees})}beginSlot(e){return this._output!==m.Color&&this._output!==m.Alpha||(this._updateShadowState(e),this._updateOccludeeState(e)),this.updateParameters(e)}bind(e,t){t.bindPass(this._material.parameters,e),this.bindTextures(t.program)}}const w={textureId:void 0,initTextureTransparent:!1,isSchematic:!1,usePBR:!1,normalTextureId:void 0,vertexTangents:!1,occlusionTextureId:void 0,emissiveTextureId:void 0,metallicRoughnessTextureId:void 0,emissiveFactor:[0,0,0],mrrFactors:[0,1,.5],ambient:[.2,.2,.2],diffuse:[.8,.8,.8],externalColor:[1,1,1,1],colorMixMode:"multiply",opacity:1,layerOpacity:1,vertexColors:!1,symbolColors:!1,doubleSided:!1,doubleSidedType:"normal",cullFace:g.Back,instanced:void 0,instancedDoublePrecision:!1,normals:"default",receiveSSAO:!0,receiveShadows:!0,castShadows:!0,shadowMappingEnabled:!1,verticalOffset:null,screenSizePerspective:null,slicePlaneEnabled:!1,sliceHighlightDisabled:!1,offsetTransparentBackfaces:!1,vvSizeEnabled:!1,vvSizeMinSize:[1,1,1],vvSizeMaxSize:[100,100,100],vvSizeOffset:[0,0,0],vvSizeFactor:[1,1,1],vvSizeValue:[1,1,1],vvColorEnabled:!1,vvColorValues:[0,0,0,0,0,0,0,0],vvColorColors:[1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0],vvSymbolAnchor:[0,0,0],vvSymbolRotationMatrix:t(),modelTransformation:null,transparent:!1,writeDepth:!0,textureAlphaMode:T.Blend,textureAlphaCutoff:v,textureAlphaPremultiplied:!1,sceneHasOcludees:!1,...S};class B{constructor(e,t){this.vertexBufferLayout=e,this.instanceBufferLayout=t}allocate(e){return this.vertexBufferLayout.createBuffer(e)}elementCount(e){return e.indices.get(b.POSITION).length}write(e,t,i,s){q(t,this.vertexBufferLayout,e.transformation,e.invTranspTransformation,i,s)}}function N(e){const t=e.textureId||e.normalTextureId||e.metallicRoughnessTextureId||e.emissiveTextureId||e.occlusionTextureId,i=p().vec3f(b.POSITION).vec3f(b.NORMAL);return e.vertexTangents&&i.vec4f(b.TANGENT),t&&i.vec2f(b.UV0),e.vertexColors&&i.vec4u8(b.COLOR),e.symbolColors&&i.vec4u8(b.SYMBOLCOLOR),i}function j(e){let t=p();return t=e.instancedDoublePrecision?t.vec3f(b.MODELORIGINHI).vec3f(b.MODELORIGINLO).mat3f(b.MODEL).mat3f(b.MODELNORMAL):t.mat4f(b.MODEL).mat4f(b.MODELNORMAL),e.instanced&&e.instanced.indexOf("color")>-1&&(t=t.vec4f(b.INSTANCECOLOR)),e.instanced&&e.instanced.indexOf("featureAttribute")>-1&&(t=t.vec4f(b.INSTANCEFEATUREATTRIBUTE)),t}const H=u(),z=u(),G=h(0,0,1),k=u(),F=u(),U=u(),V=u();export{y as DefaultMaterial,j as getInstanceBufferLayout};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.23/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../../chunks/tslib.es6.js";import{f as t}from"../../../../chunks/vec3f64.js";import{ShaderOutput as r}from"../core/shaderLibrary/ShaderOutputOptions.js";import{bindSliceUniforms as i}from"../core/shaderLibrary/Slice.glsl.js";import{bindCustomOrigin as o}from"../core/shaderLibrary/attributes/InstancedDoublePrecision.glsl.js";import{NormalAttribute as s}from"../core/shaderLibrary/attributes/NormalAttribute.glsl.js";import{TextureCoordinateAttribute as a}from"../core/shaderLibrary/attributes/TextureCoordinateAttribute.glsl.js";import{bindVerticalOffsetUniforms as n}from"../core/shaderLibrary/attributes/VerticalOffset.glsl.js";import{bindOutputHighlight as l}from"../core/shaderLibrary/output/OutputHighlight.glsl.js";import{bindMultipassTerrainTexture as p}from"../core/shaderLibrary/shading/MultipassTerrainTest.glsl.js";import{Normals as c}from"../core/shaderLibrary/shading/Normals.glsl.js";import{PBRMode as u,bindPBRUniforms as h}from"../core/shaderLibrary/shading/PhysicallyBasedRenderingParameters.glsl.js";import{bindReadShadowMapViewCustomOrigin as d}from"../core/shaderLibrary/shading/ReadShadowMap.glsl.js";import{bindVisualVariablesUniformsForSymbols as m}from"../core/shaderLibrary/shading/VisualVariables.glsl.js";import{doublePrecisionRequiresObfuscation as f}from"../core/shaderLibrary/util/DoublePrecision.glsl.js";import{bindProjectionMatrix as v,bindViewCustomOrigin as g,bindCameraPosition as b}from"../core/shaderLibrary/util/View.glsl.js";import{ReloadableShaderModule as y}from"../core/shaderTechnique/ReloadableShaderModule.js";import{ShaderTechnique as T}from"../core/shaderTechnique/ShaderTechnique.js";import{parameter as x,ShaderTechniqueConfiguration as P}from"../core/shaderTechnique/ShaderTechniqueConfiguration.js";import{AlphaDiscardMode as M,CullFaceOptions as S,TransparencyPassType as C}from"../lib/basicInterfaces.js";import{Default3D as O}from"../lib/DefaultVertexAttributeLocations.js";import{blendingDefault as D,oitBlending as A,oitDepthTest as j,getOITPolygonOffset as w}from"../lib/OrderIndependentTransparency.js";import{Program as N}from"../lib/Program.js";import{stencilWriteMaskOn as E,stencilToolMaskBaseParams as U,stencilBaseAllZerosParams as z}from"../lib/StencilUtils.js";import{colorMixModes as L,bindScreenSizePerspective as R}from"../materials/internal/MaterialUtil.js";import{D as H}from"../../../../chunks/DefaultMaterial.glsl.js";import{makePipelineState as F,cullingParams as B,defaultDepthWriteParams as I,defaultColorWriteParams as k}from"../../../webgl/renderState.js";class V extends T{initializeProgram(e){const t=V.shader.get(),r=this.configuration,i=t.build({OITEnabled:r.transparencyPassType===C.Color,output:r.output,viewingMode:e.viewingMode,receiveShadows:r.receiveShadows,slicePlaneEnabled:r.slicePlaneEnabled,sliceHighlightDisabled:r.sliceHighlightDisabled,sliceEnabledForVertexPrograms:!1,symbolColor:r.symbolColors,vvSize:r.vvSize,vvColor:r.vvColor,vvInstancingEnabled:!0,instanced:r.instanced,instancedColor:r.instancedColor,instancedDoublePrecision:r.instancedDoublePrecision,pbrMode:r.usePBR?r.isSchematic?u.Schematic:u.Normal:u.Disabled,hasMetalnessAndRoughnessTexture:r.hasMetalnessAndRoughnessTexture,hasEmissionTexture:r.hasEmissionTexture,hasOcclusionTexture:r.hasOcclusionTexture,hasNormalTexture:r.hasNormalTexture,hasColorTexture:r.hasColorTexture,receiveAmbientOcclusion:r.receiveAmbientOcclusion,useCustomDTRExponentForWater:!1,normalType:r.normalsTypeDerivate?s.Type.ScreenDerivative:s.Type.Attribute,doubleSidedMode:r.doubleSidedMode,vertexTangents:r.vertexTangents,attributeTextureCoordinates:r.hasMetalnessAndRoughnessTexture||r.hasEmissionTexture||r.hasOcclusionTexture||r.hasNormalTexture||r.hasColorTexture?a.AttributeType.Default:a.AttributeType.None,textureAlphaPremultiplied:r.textureAlphaPremultiplied,attributeColor:r.vertexColors,screenSizePerspectiveEnabled:r.screenSizePerspective,verticalOffsetEnabled:r.verticalOffset,offsetBackfaces:r.offsetBackfaces,doublePrecisionRequiresObfuscation:f(e.rctx),alphaDiscardMode:r.alphaDiscardMode,supportsTextureAtlas:!1,multipassTerrainEnabled:r.multipassTerrainEnabled,cullAboveGround:r.cullAboveGround});return new N(e.rctx,i,O)}bindPass(e,t){var i,o;v(this.program,t.camera.projectionMatrix);const s=this.configuration.output;(this.configuration.output===r.Depth||t.multipassTerrainEnabled||s===r.Shadow)&&this.program.setUniform2fv("cameraNearFar",t.camera.nearFar),t.multipassTerrainEnabled&&(this.program.setUniform2fv("inverseViewport",t.inverseViewport),p(this.program,t)),s===r.Alpha&&(this.program.setUniform1f("opacity",e.opacity),this.program.setUniform1f("layerOpacity",e.layerOpacity),this.program.setUniform4fv("externalColor",e.externalColor),this.program.setUniform1i("colorMixMode",L[e.colorMixMode])),s===r.Color?(t.lighting.setUniforms(this.program,!1),this.program.setUniform3fv("ambient",e.ambient),this.program.setUniform3fv("diffuse",e.diffuse),this.program.setUniform4fv("externalColor",e.externalColor),this.program.setUniform1i("colorMixMode",L[e.colorMixMode]),this.program.setUniform1f("opacity",e.opacity),this.program.setUniform1f("layerOpacity",e.layerOpacity),this.configuration.usePBR&&h(this.program,e,this.configuration.isSchematic)):s===r.Highlight&&l(this.program,t),m(this.program,e),n(this.program,e,t),R(e.screenSizePerspective,this.program,"screenSizePerspectiveAlignment"),e.textureAlphaMode!==M.Mask&&e.textureAlphaMode!==M.MaskBlend||this.program.setUniform1f("textureAlphaCutoff",e.textureAlphaCutoff),null==(i=t.shadowMap)||i.bind(this.program),null==(o=t.ssaoHelper)||o.bind(this.program,t.camera)}bindDraw(e){const s=this.configuration.instancedDoublePrecision?t(e.camera.viewInverseTransposeMatrix[3],e.camera.viewInverseTransposeMatrix[7],e.camera.viewInverseTransposeMatrix[11]):e.origin;g(this.program,s,e.camera.viewMatrix),this.program.rebindTextures(),(this.configuration.output===r.Color||this.configuration.output===r.Alpha||this.configuration.output===r.Depth&&this.configuration.screenSizePerspective||this.configuration.output===r.Normal&&this.configuration.screenSizePerspective||this.configuration.output===r.Highlight&&this.configuration.screenSizePerspective)&&b(this.program,s,e.camera.viewInverseTransposeMatrix),this.configuration.output===r.Normal&&this.program.setUniformMatrix4fv("viewNormal",e.camera.viewInverseTransposeMatrix),this.configuration.instancedDoublePrecision&&o(this.program,s),i(this.program,this.configuration,e.slicePlane,s),this.configuration.output===r.Color&&d(this.program,e,s)}_setPipeline(e,t){const i=this.configuration,o=e===C.NONE,s=e===C.FrontFace;return F({blending:i.output!==r.Color&&i.output!==r.Alpha||!i.transparent?null:o?D:A(e),culling:q(i)&&B(i.cullFace),depthTest:{func:j(e)},depthWrite:o||s?i.writeDepth&&I:null,colorWrite:k,stencilWrite:i.sceneHasOcludees?E:null,stencilTest:i.sceneHasOcludees?t?U:z:null,polygonOffset:o||s?null:w(i.enableOffset)})}initializePipeline(){return this._occludeePipelineState=this._setPipeline(this.configuration.transparencyPassType,!0),this._setPipeline(this.configuration.transparencyPassType,!1)}getPipelineState(e,t){return t?this._occludeePipelineState:super.getPipelineState(e,t)}}function q(e){return e.cullFace?e.cullFace!==S.None:!e.slicePlaneEnabled&&(!e.transparent&&!e.doubleSidedMode)}V.shader=new y(H,(()=>import("./DefaultMaterial.glsl.js")));class _ extends P{constructor(){super(...arguments),this.output=r.Color,this.alphaDiscardMode=M.Opaque,this.doubleSidedMode=c.DoubleSidedMode.None,this.isSchematic=!1,this.vertexColors=!1,this.offsetBackfaces=!1,this.symbolColors=!1,this.vvSize=!1,this.vvColor=!1,this.verticalOffset=!1,this.receiveShadows=!1,this.slicePlaneEnabled=!1,this.sliceHighlightDisabled=!1,this.receiveAmbientOcclusion=!1,this.screenSizePerspective=!1,this.textureAlphaPremultiplied=!1,this.hasColorTexture=!1,this.usePBR=!1,this.hasMetalnessAndRoughnessTexture=!1,this.hasEmissionTexture=!1,this.hasOcclusionTexture=!1,this.hasNormalTexture=!1,this.instanced=!1,this.instancedColor=!1,this.instancedDoublePrecision=!1,this.vertexTangents=!1,this.normalsTypeDerivate=!1,this.writeDepth=!0,this.sceneHasOcludees=!1,this.transparent=!1,this.enableOffset=!0,this.cullFace=S.None,this.transparencyPassType=C.NONE,this.multipassTerrainEnabled=!1,this.cullAboveGround=!1}}e([x({count:r.COUNT})],_.prototype,"output",void 0),e([x({count:M.COUNT})],_.prototype,"alphaDiscardMode",void 0),e([x({count:c.DoubleSidedMode.COUNT})],_.prototype,"doubleSidedMode",void 0),e([x()],_.prototype,"isSchematic",void 0),e([x()],_.prototype,"vertexColors",void 0),e([x()],_.prototype,"offsetBackfaces",void 0),e([x()],_.prototype,"symbolColors",void 0),e([x()],_.prototype,"vvSize",void 0),e([x()],_.prototype,"vvColor",void 0),e([x()],_.prototype,"verticalOffset",void 0),e([x()],_.prototype,"receiveShadows",void 0),e([x()],_.prototype,"slicePlaneEnabled",void 0),e([x()],_.prototype,"sliceHighlightDisabled",void 0),e([x()],_.prototype,"receiveAmbientOcclusion",void 0),e([x()],_.prototype,"screenSizePerspective",void 0),e([x()],_.prototype,"textureAlphaPremultiplied",void 0),e([x()],_.prototype,"hasColorTexture",void 0),e([x()],_.prototype,"usePBR",void 0),e([x()],_.prototype,"hasMetalnessAndRoughnessTexture",void 0),e([x()],_.prototype,"hasEmissionTexture",void 0),e([x()],_.prototype,"hasOcclusionTexture",void 0),e([x()],_.prototype,"hasNormalTexture",void 0),e([x()],_.prototype,"instanced",void 0),e([x()],_.prototype,"instancedColor",void 0),e([x()],_.prototype,"instancedDoublePrecision",void 0),e([x()],_.prototype,"vertexTangents",void 0),e([x()],_.prototype,"normalsTypeDerivate",void 0),e([x()],_.prototype,"writeDepth",void 0),e([x()],_.prototype,"sceneHasOcludees",void 0),e([x()],_.prototype,"transparent",void 0),e([x()],_.prototype,"enableOffset",void 0),e([x({count:S.COUNT})],_.prototype,"cullFace",void 0),e([x({count:C.COUNT})],_.prototype,"transparencyPassType",void 0),e([x()],_.prototype,"multipassTerrainEnabled",void 0),e([x()],_.prototype,"cullAboveGround",void 0);export{V as DefaultMaterialTechnique,_ as DefaultMaterialTechniqueConfiguration};
5
+ import{_ as e}from"../../../../chunks/tslib.es6.js";import r from"../../../../core/Logger.js";import{isSome as t}from"../../../../core/maybe.js";import{f as o}from"../../../../chunks/vec3f64.js";import{ShaderOutput as i}from"../core/shaderLibrary/ShaderOutputOptions.js";import{bindSliceUniforms as s}from"../core/shaderLibrary/Slice.glsl.js";import{bindCustomOrigin as a}from"../core/shaderLibrary/attributes/InstancedDoublePrecision.glsl.js";import{NormalAttribute as n}from"../core/shaderLibrary/attributes/NormalAttribute.glsl.js";import{TextureCoordinateAttribute as l}from"../core/shaderLibrary/attributes/TextureCoordinateAttribute.glsl.js";import{bindVerticalOffsetUniforms as p}from"../core/shaderLibrary/attributes/VerticalOffset.glsl.js";import{bindOutputHighlight as c}from"../core/shaderLibrary/output/OutputHighlight.glsl.js";import{bindMultipassTerrainTexture as u}from"../core/shaderLibrary/shading/MultipassTerrainTest.glsl.js";import{Normals as h}from"../core/shaderLibrary/shading/Normals.glsl.js";import{PBRMode as d,bindPBRUniforms as m}from"../core/shaderLibrary/shading/PhysicallyBasedRenderingParameters.glsl.js";import{bindReadShadowMapViewCustomOrigin as f}from"../core/shaderLibrary/shading/ReadShadowMap.glsl.js";import{bindVisualVariablesUniformsForSymbols as g}from"../core/shaderLibrary/shading/VisualVariables.glsl.js";import{doublePrecisionRequiresObfuscation as v}from"../core/shaderLibrary/util/DoublePrecision.glsl.js";import{bindProjectionMatrix as b,bindViewCustomOrigin as y,bindCameraPosition as T}from"../core/shaderLibrary/util/View.glsl.js";import{ReloadableShaderModule as x}from"../core/shaderTechnique/ReloadableShaderModule.js";import{ShaderTechnique as M}from"../core/shaderTechnique/ShaderTechnique.js";import{parameter as P,ShaderTechniqueConfiguration as S}from"../core/shaderTechnique/ShaderTechniqueConfiguration.js";import{AlphaDiscardMode as C,CullFaceOptions as O,TransparencyPassType as D}from"../lib/basicInterfaces.js";import{Default3D as A}from"../lib/DefaultVertexAttributeLocations.js";import{blendingDefault as j,oitBlending as w,oitDepthTest as N,getOITPolygonOffset as E}from"../lib/OrderIndependentTransparency.js";import{Program as U}from"../lib/Program.js";import{stencilWriteMaskOn as L,stencilToolMaskBaseParams as z,stencilBaseAllZerosParams as R}from"../lib/StencilUtils.js";import{colorMixModes as H,bindScreenSizePerspective as F}from"../materials/internal/MaterialUtil.js";import{D as B}from"../../../../chunks/DefaultMaterial.glsl.js";import{makePipelineState as I,cullingParams as k,defaultDepthWriteParams as q,defaultColorWriteParams as V}from"../../../webgl/renderState.js";const _=r.getLogger("esri.views.3d.webgl-engine.shaders.DefaultTechnique");class G extends M{initializeProgram(e){const r=G.shader.get(),t=this.configuration,o=r.build({OITEnabled:t.transparencyPassType===D.Color,output:t.output,viewingMode:e.viewingMode,receiveShadows:t.receiveShadows,slicePlaneEnabled:t.slicePlaneEnabled,sliceHighlightDisabled:t.sliceHighlightDisabled,sliceEnabledForVertexPrograms:!1,symbolColor:t.symbolColors,vvSize:t.vvSize,vvColor:t.vvColor,vvInstancingEnabled:!0,instanced:t.instanced,instancedColor:t.instancedColor,instancedDoublePrecision:t.instancedDoublePrecision,pbrMode:t.usePBR?t.isSchematic?d.Schematic:d.Normal:d.Disabled,hasMetalnessAndRoughnessTexture:t.hasMetalnessAndRoughnessTexture,hasEmissionTexture:t.hasEmissionTexture,hasOcclusionTexture:t.hasOcclusionTexture,hasNormalTexture:t.hasNormalTexture,hasColorTexture:t.hasColorTexture,hasModelTransformation:t.hasModelTransformation,receiveAmbientOcclusion:t.receiveAmbientOcclusion,useCustomDTRExponentForWater:!1,normalType:t.normalsTypeDerivate?n.Type.ScreenDerivative:n.Type.Attribute,doubleSidedMode:t.doubleSidedMode,vertexTangents:t.vertexTangents,attributeTextureCoordinates:t.hasMetalnessAndRoughnessTexture||t.hasEmissionTexture||t.hasOcclusionTexture||t.hasNormalTexture||t.hasColorTexture?l.AttributeType.Default:l.AttributeType.None,textureAlphaPremultiplied:t.textureAlphaPremultiplied,attributeColor:t.vertexColors,screenSizePerspectiveEnabled:t.screenSizePerspective,verticalOffsetEnabled:t.verticalOffset,offsetBackfaces:t.offsetBackfaces,doublePrecisionRequiresObfuscation:v(e.rctx),alphaDiscardMode:t.alphaDiscardMode,supportsTextureAtlas:!1,multipassTerrainEnabled:t.multipassTerrainEnabled,cullAboveGround:t.cullAboveGround});return new U(e.rctx,o,A)}bindPass(e,r){var o,s;b(this.program,r.camera.projectionMatrix);const a=this.configuration.output;this.configuration.hasModelTransformation&&(t(e.modelTransformation)?this.program.setUniformMatrix4fv("model",e.modelTransformation):_.warnOnce("hasModelTransformation true, but no modelTransformation found.")),(this.configuration.output===i.Depth||r.multipassTerrainEnabled||a===i.Shadow)&&this.program.setUniform2fv("cameraNearFar",r.camera.nearFar),r.multipassTerrainEnabled&&(this.program.setUniform2fv("inverseViewport",r.inverseViewport),u(this.program,r)),a===i.Alpha&&(this.program.setUniform1f("opacity",e.opacity),this.program.setUniform1f("layerOpacity",e.layerOpacity),this.program.setUniform4fv("externalColor",e.externalColor),this.program.setUniform1i("colorMixMode",H[e.colorMixMode])),a===i.Color?(r.lighting.setUniforms(this.program,!1),this.program.setUniform3fv("ambient",e.ambient),this.program.setUniform3fv("diffuse",e.diffuse),this.program.setUniform4fv("externalColor",e.externalColor),this.program.setUniform1i("colorMixMode",H[e.colorMixMode]),this.program.setUniform1f("opacity",e.opacity),this.program.setUniform1f("layerOpacity",e.layerOpacity),this.configuration.usePBR&&m(this.program,e,this.configuration.isSchematic)):a===i.Highlight&&c(this.program,r),g(this.program,e),p(this.program,e,r),F(e.screenSizePerspective,this.program,"screenSizePerspectiveAlignment"),e.textureAlphaMode!==C.Mask&&e.textureAlphaMode!==C.MaskBlend||this.program.setUniform1f("textureAlphaCutoff",e.textureAlphaCutoff),null==(o=r.shadowMap)||o.bind(this.program),null==(s=r.ssaoHelper)||s.bind(this.program,r.camera)}bindDraw(e){const r=this.configuration.instancedDoublePrecision?o(e.camera.viewInverseTransposeMatrix[3],e.camera.viewInverseTransposeMatrix[7],e.camera.viewInverseTransposeMatrix[11]):e.origin;y(this.program,r,e.camera.viewMatrix),this.program.rebindTextures(),(this.configuration.output===i.Color||this.configuration.output===i.Alpha||this.configuration.output===i.Depth&&this.configuration.screenSizePerspective||this.configuration.output===i.Normal&&this.configuration.screenSizePerspective||this.configuration.output===i.Highlight&&this.configuration.screenSizePerspective)&&T(this.program,r,e.camera.viewInverseTransposeMatrix),this.configuration.output===i.Normal&&this.program.setUniformMatrix4fv("viewNormal",e.camera.viewInverseTransposeMatrix),this.configuration.instancedDoublePrecision&&a(this.program,r),s(this.program,this.configuration,e.slicePlane,r),this.configuration.output===i.Color&&f(this.program,e,r)}_setPipeline(e,r){const t=this.configuration,o=e===D.NONE,s=e===D.FrontFace;return I({blending:t.output!==i.Color&&t.output!==i.Alpha||!t.transparent?null:o?j:w(e),culling:W(t)&&k(t.cullFace),depthTest:{func:N(e)},depthWrite:o||s?t.writeDepth&&q:null,colorWrite:V,stencilWrite:t.sceneHasOcludees?L:null,stencilTest:t.sceneHasOcludees?r?z:R:null,polygonOffset:o||s?null:E(t.enableOffset)})}initializePipeline(){return this._occludeePipelineState=this._setPipeline(this.configuration.transparencyPassType,!0),this._setPipeline(this.configuration.transparencyPassType,!1)}getPipelineState(e,r){return r?this._occludeePipelineState:super.getPipelineState(e,r)}}function W(e){return e.cullFace?e.cullFace!==O.None:!e.slicePlaneEnabled&&(!e.transparent&&!e.doubleSidedMode)}G.shader=new x(B,(()=>import("./DefaultMaterial.glsl.js")));class J extends S{constructor(){super(...arguments),this.output=i.Color,this.alphaDiscardMode=C.Opaque,this.doubleSidedMode=h.DoubleSidedMode.None,this.isSchematic=!1,this.vertexColors=!1,this.offsetBackfaces=!1,this.symbolColors=!1,this.vvSize=!1,this.vvColor=!1,this.verticalOffset=!1,this.receiveShadows=!1,this.slicePlaneEnabled=!1,this.sliceHighlightDisabled=!1,this.receiveAmbientOcclusion=!1,this.screenSizePerspective=!1,this.textureAlphaPremultiplied=!1,this.hasColorTexture=!1,this.usePBR=!1,this.hasMetalnessAndRoughnessTexture=!1,this.hasEmissionTexture=!1,this.hasOcclusionTexture=!1,this.hasNormalTexture=!1,this.instanced=!1,this.instancedColor=!1,this.instancedDoublePrecision=!1,this.vertexTangents=!1,this.normalsTypeDerivate=!1,this.writeDepth=!0,this.sceneHasOcludees=!1,this.transparent=!1,this.enableOffset=!0,this.cullFace=O.None,this.transparencyPassType=D.NONE,this.multipassTerrainEnabled=!1,this.cullAboveGround=!1,this.hasModelTransformation=!1}}e([P({count:i.COUNT})],J.prototype,"output",void 0),e([P({count:C.COUNT})],J.prototype,"alphaDiscardMode",void 0),e([P({count:h.DoubleSidedMode.COUNT})],J.prototype,"doubleSidedMode",void 0),e([P()],J.prototype,"isSchematic",void 0),e([P()],J.prototype,"vertexColors",void 0),e([P()],J.prototype,"offsetBackfaces",void 0),e([P()],J.prototype,"symbolColors",void 0),e([P()],J.prototype,"vvSize",void 0),e([P()],J.prototype,"vvColor",void 0),e([P()],J.prototype,"verticalOffset",void 0),e([P()],J.prototype,"receiveShadows",void 0),e([P()],J.prototype,"slicePlaneEnabled",void 0),e([P()],J.prototype,"sliceHighlightDisabled",void 0),e([P()],J.prototype,"receiveAmbientOcclusion",void 0),e([P()],J.prototype,"screenSizePerspective",void 0),e([P()],J.prototype,"textureAlphaPremultiplied",void 0),e([P()],J.prototype,"hasColorTexture",void 0),e([P()],J.prototype,"usePBR",void 0),e([P()],J.prototype,"hasMetalnessAndRoughnessTexture",void 0),e([P()],J.prototype,"hasEmissionTexture",void 0),e([P()],J.prototype,"hasOcclusionTexture",void 0),e([P()],J.prototype,"hasNormalTexture",void 0),e([P()],J.prototype,"instanced",void 0),e([P()],J.prototype,"instancedColor",void 0),e([P()],J.prototype,"instancedDoublePrecision",void 0),e([P()],J.prototype,"vertexTangents",void 0),e([P()],J.prototype,"normalsTypeDerivate",void 0),e([P()],J.prototype,"writeDepth",void 0),e([P()],J.prototype,"sceneHasOcludees",void 0),e([P()],J.prototype,"transparent",void 0),e([P()],J.prototype,"enableOffset",void 0),e([P({count:O.COUNT})],J.prototype,"cullFace",void 0),e([P({count:D.COUNT})],J.prototype,"transparencyPassType",void 0),e([P()],J.prototype,"multipassTerrainEnabled",void 0),e([P()],J.prototype,"cullAboveGround",void 0),e([P()],J.prototype,"hasModelTransformation",void 0);export{G as DefaultMaterialTechnique,J as DefaultMaterialTechniqueConfiguration};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.23/esri/copyright.txt for details.
4
4
  */
5
- import{NormalAttribute as e}from"../core/shaderLibrary/attributes/NormalAttribute.glsl.js";import{TextureCoordinateAttribute as r}from"../core/shaderLibrary/attributes/TextureCoordinateAttribute.glsl.js";import{R as i}from"../../../../chunks/RealisticTree.glsl.js";import{Normals as s}from"../core/shaderLibrary/shading/Normals.glsl.js";import{PBRMode as t}from"../core/shaderLibrary/shading/PhysicallyBasedRenderingParameters.glsl.js";import{doublePrecisionRequiresObfuscation as o}from"../core/shaderLibrary/util/DoublePrecision.glsl.js";import{ReloadableShaderModule as a}from"../core/shaderTechnique/ReloadableShaderModule.js";import{TransparencyPassType as l}from"../lib/basicInterfaces.js";import{Default3D as n}from"../lib/DefaultVertexAttributeLocations.js";import{Program as c}from"../lib/Program.js";import{DefaultMaterialTechnique as d}from"./DefaultMaterialTechnique.js";class u extends d{initializeProgram(i){const a=u.shader.get(),d=this.configuration,b=a.build({OITEnabled:d.transparencyPassType===l.Color,output:d.output,viewingMode:i.viewingMode,receiveShadows:d.receiveShadows,slicePlaneEnabled:d.slicePlaneEnabled,sliceHighlightDisabled:d.sliceHighlightDisabled,sliceEnabledForVertexPrograms:!1,symbolColor:d.symbolColors,vvSize:d.vvSize,vvColor:d.vvColor,vvInstancingEnabled:!0,instanced:d.instanced,instancedColor:d.instancedColor,instancedDoublePrecision:d.instancedDoublePrecision,pbrMode:d.usePBR?t.Normal:t.Disabled,hasMetalnessAndRoughnessTexture:!1,hasEmissionTexture:!1,hasOcclusionTexture:!1,hasNormalTexture:!1,hasColorTexture:d.hasColorTexture,receiveAmbientOcclusion:d.receiveAmbientOcclusion,useCustomDTRExponentForWater:!1,normalType:e.Type.Attribute,doubleSidedMode:s.DoubleSidedMode.WindingOrder,vertexTangents:!1,attributeTextureCoordinates:d.hasColorTexture?r.AttributeType.Default:r.AttributeType.None,textureAlphaPremultiplied:d.textureAlphaPremultiplied,attributeColor:d.vertexColors,screenSizePerspectiveEnabled:d.screenSizePerspective,verticalOffsetEnabled:d.verticalOffset,offsetBackfaces:d.offsetBackfaces,doublePrecisionRequiresObfuscation:o(i.rctx),alphaDiscardMode:d.alphaDiscardMode,supportsTextureAtlas:!1,multipassTerrainEnabled:d.multipassTerrainEnabled,cullAboveGround:d.cullAboveGround});return new c(i.rctx,b,n)}}u.shader=new a(i,(()=>import("../core/shaderLibrary/default/RealisticTree.glsl.js")));export{u as RealisticTreeTechnique};
5
+ import{NormalAttribute as e}from"../core/shaderLibrary/attributes/NormalAttribute.glsl.js";import{TextureCoordinateAttribute as r}from"../core/shaderLibrary/attributes/TextureCoordinateAttribute.glsl.js";import{R as i}from"../../../../chunks/RealisticTree.glsl.js";import{Normals as s}from"../core/shaderLibrary/shading/Normals.glsl.js";import{PBRMode as t}from"../core/shaderLibrary/shading/PhysicallyBasedRenderingParameters.glsl.js";import{doublePrecisionRequiresObfuscation as o}from"../core/shaderLibrary/util/DoublePrecision.glsl.js";import{ReloadableShaderModule as a}from"../core/shaderTechnique/ReloadableShaderModule.js";import{TransparencyPassType as l}from"../lib/basicInterfaces.js";import{Default3D as n}from"../lib/DefaultVertexAttributeLocations.js";import{Program as d}from"../lib/Program.js";import{DefaultMaterialTechnique as c}from"./DefaultMaterialTechnique.js";class u extends c{initializeProgram(i){const a=u.shader.get(),c=this.configuration,b=a.build({OITEnabled:c.transparencyPassType===l.Color,output:c.output,viewingMode:i.viewingMode,receiveShadows:c.receiveShadows,slicePlaneEnabled:c.slicePlaneEnabled,sliceHighlightDisabled:c.sliceHighlightDisabled,sliceEnabledForVertexPrograms:!1,symbolColor:c.symbolColors,vvSize:c.vvSize,vvColor:c.vvColor,vvInstancingEnabled:!0,instanced:c.instanced,instancedColor:c.instancedColor,instancedDoublePrecision:c.instancedDoublePrecision,pbrMode:c.usePBR?t.Normal:t.Disabled,hasMetalnessAndRoughnessTexture:!1,hasEmissionTexture:!1,hasOcclusionTexture:!1,hasNormalTexture:!1,hasColorTexture:c.hasColorTexture,hasModelTransformation:!1,receiveAmbientOcclusion:c.receiveAmbientOcclusion,useCustomDTRExponentForWater:!1,normalType:e.Type.Attribute,doubleSidedMode:s.DoubleSidedMode.WindingOrder,vertexTangents:!1,attributeTextureCoordinates:c.hasColorTexture?r.AttributeType.Default:r.AttributeType.None,textureAlphaPremultiplied:c.textureAlphaPremultiplied,attributeColor:c.vertexColors,screenSizePerspectiveEnabled:c.screenSizePerspective,verticalOffsetEnabled:c.verticalOffset,offsetBackfaces:c.offsetBackfaces,doublePrecisionRequiresObfuscation:o(i.rctx),alphaDiscardMode:c.alphaDiscardMode,supportsTextureAtlas:!1,multipassTerrainEnabled:c.multipassTerrainEnabled,cullAboveGround:c.cullAboveGround});return new d(i.rctx,b,n)}}u.shader=new a(i,(()=>import("../core/shaderLibrary/default/RealisticTree.glsl.js")));export{u as RealisticTreeTechnique};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.23/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../chunks/tslib.es6.js";import t from"../Camera.js";import"../geometry.js";import i from"../Graphic.js";import r from"../Ground.js";import s from"../Viewpoint.js";import n from"../core/Collection.js";import{byId as a}from"../core/domUtils.js";import o from"../core/Error.js";import{on as l}from"../core/events.js";import{handlesGroup as p,makeHandle as h}from"../core/handleUtils.js";import d from"../core/has.js";import{isIterable as c}from"../core/iteratorUtils.js";import u from"../core/Logger.js";import{destroyMaybe as g,isNone as m,isSome as f,unwrapOr as y}from"../core/maybe.js";import{ObservableChangesType as w}from"../core/ObservableChangesType.js";import{throwIfAborted as v}from"../core/promiseUtils.js";import{initial as _,syncAndInitial as b}from"../core/reactiveUtils.js";import{setFrameDuration as S}from"../core/scheduling.js";import{on as M,whenOnce as R,init as x,whenTrueOnce as V}from"../core/watchUtils.js";import{initialize as T}from"../core/workers/workers.js";import{screenPointObjectToArray as C,createScreenPoint as O,createScreenPointArray as P}from"../core/screenUtils.js";import{property as E}from"../core/accessorSupport/decorators/property.js";import"../core/arrayUtils.js";import{cast as j}from"../core/accessorSupport/decorators/cast.js";import{subclass as I}from"../core/accessorSupport/decorators/subclass.js";import{ensureType as G}from"../core/accessorSupport/ensureType.js";import{c as H}from"../chunks/vec3f64.js";import L from"../geometry/HeightModelInfo.js";import{canProjectWithoutEngine as U,project as A,projectPointToVector as D,projectVectorToVector as F,projectBoundingRect as W}from"../geometry/projection.js";import{create as q,toExtent as z}from"../geometry/support/aaBoundingRect.js";import{B as k,a as N}from"../chunks/boundedPlane.js";import{renderSRFromViewSR as B}from"../geometry/support/coordinateSystem.js";import{getResolutionForScale as Q}from"../geometry/support/scaleUtils.js";import $ from"../layers/VoxelWasmManager.js";import{isTiledLayer as X}from"../layers/support/layerUtils.js";import{BreakpointsOwner as K}from"./BreakpointsOwner.js";import{DOMContainer as Z}from"./DOMContainer.js";import J from"./GroundView.js";import{PopupView as Y}from"./PopupView.js";import ee from"./View.js";import te from"./ViewAnimation.js";import{ViewingMode as ie,stringFromViewingMode as re,viewingModeFromString as se}from"./ViewingMode.js";import{layerView3DImporter as ne}from"./3d/layerViewModuleImportUtils.js";import ae from"./3d/analysis/AnalysisViewManager3D.js";import oe from"./3d/constraints/Constraints.js";import le from"./3d/environment/SceneViewEnvironment.js";import{SceneViewEnvironmentManager as pe}from"./3d/environment/SceneViewEnvironmentManager.js";import he from"./3d/input/SceneInputManager.js";import{GraphicsDeconflictor as de}from"./3d/layers/graphics/GraphicsDeconflictor.js";import{Labeler as ce}from"./3d/layers/graphics/Labeler.js";import{ObjectResourceCache as ue}from"./3d/layers/graphics/ObjectResourceCache.js";import ge from"./3d/layers/support/FeatureTileTree3D.js";import me from"./3d/state/ViewState.js";import fe from"./3d/state/ViewStateManager.js";import{SceneIntersectionHelper as ye}from"./3d/state/helpers/SceneIntersectionHelper.js";import{CombinedElevationProvider as we}from"./3d/support/CombinedElevationProvider.js";import ve from"./3d/support/debugFlags.js";import _e from"./3d/support/DisplayQualityProfile.js";import{getElevationAtPoint as be}from"./3d/support/ElevationProvider.js";import Se from"./3d/support/HighlightOptions.js";import{MapCoordsHelper as Me}from"./3d/support/MapCoordsHelper.js";import{PropertiesPool as Re}from"./3d/support/PropertiesPool.js";import xe from"./3d/support/QualitySettings.js";import{RenderCoordsHelper as Ve}from"./3d/support/RenderCoordsHelper.js";import{newResourceController as Te}from"./3d/support/ResourceController.js";import Ce from"./3d/support/SceneViewPerformanceInfo.js";import{SharedSymbolResources as Oe}from"./3d/support/SharedSymbolResources.js";import Pe from"./3d/support/pointsOfInterest/PointsOfInterest.js";import Ee from"./3d/terrain/TerrainSurface.js";import{isSurfaceLayerView as je,getTiledLayerInfo as Ie}from"./3d/terrain/terrainUtils.js";import{Stage as Ge}from"./3d/webgl-engine/Stage.js";import{newIntersector as He,DEFAULT_TOLERANCE as Le}from"./3d/webgl-engine/lib/Intersector.js";import{StoreResults as Ue,IntersectorType as Ae}from"./3d/webgl-engine/lib/IntersectorInterfaces.js";import{isValidIntersectorResult as De}from"./3d/webgl-engine/lib/intersectorUtils.js";import{toGraphic as Fe,toOwner as We}from"./3d/webgl-engine/lib/intersectorUtilsConversions.js";import{TERRAIN_ID as qe}from"./3d/webgl-engine/lib/verticalOffsetUtils.js";import{hitTestSelectSameDistance as ze}from"./support/hitTestSelectUtils.js";import{occludeesSupported as ke}from"./support/layerViewUtils.js";import{toRenderSettings as Ne,screenshotSuperSampleSettings as Be}from"./support/screenshotUtils.js";import{isSupportedScreenPointEvent as Qe,createScreenPointFromSupportedEvent as $e}from"./support/screenUtils.js";import{isSpatialReferenceSupported as Xe}from"./support/spatialReferenceSupport.js";import{check as Ke}from"./support/WebGLRequirements.js";import Ze from"./ui/3d/DefaultUI3D.js";import Je from"../webscene/Environment.js";import Ye from"../geometry/Extent.js";import et from"../geometry/SpatialReference.js";import tt from"../geometry/Point.js";const it=u.getLogger("esri.views.SceneView");let rt=class extends(K(Z(Y(ee)))){constructor(e){super(e),this._userClippingArea=null,this._clippingArea=null,this._initialDefaultSpatialReference=null,this._defaults={},this._externallySet={environment:!1},this._createGraphicsViewController=null,this._resolveWhenReady=[],this.propertiesPool=new Re({slicePlane:k},this),this._resourceController=Te(this),this._defaultToMapOptions={include:new Set},this._defaultHitTestOptions={exclude:new Set},this.deconflictor=new de({view:this}),this.labeler=new ce({view:this,deconflictor:this.deconflictor.labels}),this.sharedSymbolResources=null,this.basemapTerrain=null,this.elevationProvider=null,this.camera=null,this.canvas=null,this.center=null,this.constraints=new oe,this.environmentManager=new pe,this.extent=null,this.floors=new n,this.windowDevicePixelRatio=1,this.fullOpacity=1,this.graphicsView=null,this.analysisViewManager=new ae({view:this}),this.groundView=null,this.navigating=!1,this.map=null,this.screenSizePerspectiveEnabled=!0,this.state=new me,this.scale=null,this.spatialReference=null,this.alphaCompositingEnabled=!1,this.supersampleScreenshotsEnabled=!0,this.type="3d",this.ui=new Ze,this._numUpdating=0,this._lastUpdateTime=0,this.updatingProgress=.5,this.viewpoint=null,this.zoom=null,this.highlightOptions=new Se,T(),e&&e.environment||(this._defaults.environment=new le,this.environment=this._defaults.environment);const t=e=>{f(e)&&e.type===w.MOVE||(this._updatingChanged(),this.map&&this.map.allLayers.forEach((async e=>{try{await e.when()}catch{}this._updatingChanged()})))};this.handles.add([M(this,"map.allLayers","after-changes",t,t,t,!0),this.allLayerViews.on("after-changes",(e=>this._updateUpdatingMonitors(e))),this.watch("map",(e=>{e&&e.load&&e.load().catch((()=>{}))}))]),this.inputManager=new he({view:this});const i=()=>{const e=window.devicePixelRatio;e!==this.windowDevicePixelRatio&&(this.windowDevicePixelRatio=e,this.notifyChange("pixelRatio"))};this.stateManager=new fe({view:this,updateDevicePixelRatio:i})}initialize(){this.groundView=new J({view:this}),this._updateUpdatingMonitors();const e=()=>this._updateDefaultToMapOptions();this.handles.add(M(this,"map.allLayers","after-changes",e,e,e)),this.updatingHandles.add((()=>this.qualitySettings.memoryLimit),(e=>{this.resourceController&&(this.resourceController.memoryController.maxMemory=e)}),_),this.updatingHandles.add((()=>this.qualitySettings.additionalCacheMemory),(e=>{this.resourceController&&(this.resourceController.memoryController.additionalCacheMemory=e)}),_),this.updatingHandles.add((()=>this.qualitySettings.frameRate),(e=>S(e>0?1e3/Math.ceil(e):0)),_),this.updatingHandles.add((()=>ve.SCENEVIEW_LOCKING_LOG),(e=>this.defaultsFromMap.logDebugInformation=e),_),this.updatingHandles.add((()=>{var e;return null==(e=this.map)?void 0:e.ground}),e,b),this.updatingHandles.add((()=>{var e,t;return null==(e=this.map)||null==(t=e.ground)?void 0:t.opacity}),(()=>this._updateDefaultHitTestOptions()),b),this.handles.add(this.watch("spatialReference",(()=>this.notifyChange("clippingArea")),!0))}destroy(){this.destroyed||(this.invalidate(),this.activeTool=null,this.layerViewManager.clear(),this._exitSurface(),this._disposeGraphicsView(),this.sharedSymbolResources=g(this.sharedSymbolResources),this.labeler.destroy(),this._set("labeler",null),this.deconflictor.destroy(),this._set("deconflictor",null),this._resourceController=g(this._resourceController),this.stateManager.destroy(),this._set("stateManager",null),this.inputManager.destroy(),this._set("inputManager",null),this.propertiesPool.destroy(),this.handles.remove("updatingMonitors"),this.environmentManager.destroy(),this._set("environmentManager",null),this.groundView=g(this.groundView))}get renderSpatialReference(){return this.renderCoordsHelper&&this.renderCoordsHelper.spatialReference}get basemapSpatialReference(){return this.basemapTerrain&&this.basemapTerrain.spatialReference}installContentCameraReset(e={sticky:!1}){return this.stateManager.installContentCameraReset(e)}get clippingArea(){if("global"===this.viewingMode)return null;let e=this._userClippingArea||this.get("map.clippingArea");return!(!!this._userClippingArea||this.get("map.clippingEnabled"))||m(e)?(this._clippingArea=null,null):e instanceof Ye?this.spatialReference&&(e=at(e,this.spatialReference),m(e))?(it.error("#clippingArea","setting clippingArea with incompatible SpatialReference"),this._clippingArea):(e=e.clone(),m(e.intersection(this.groundAndLayersExtent))&&(e.xmin=e.xmax,e.ymin=e.ymax),e.zmin=void 0,e.zmax=void 0,e.equals(this._clippingArea)||(this._clippingArea=e),this._clippingArea):(it.error("#clippingArea","only clippingArea geometries of type Extent are supported"),this._clippingArea)}set clippingArea(e){this.ready&&"global"===this.viewingMode&&f(e)?it.error("#clippingArea=","Clipping area is only supported in local viewingMode"):this._userClippingArea=e}get renderDataExtent(){if(this.state.viewingMode===ie.Global)return null;const e=this.renderSpatialReference,t=this.dataExtent;return m(t)||m(e)||t.spatialReference.equals(e)?t:at(t,e)}get dataExtent(){let e=this.groundAndLayersExtent;const t=this.spatialReference||et.WGS84,i=at(this.clippingArea,t);f(i)&&(e=f(e)?e.intersection(i):i);const r=this._get("dataExtent");return f(e)&&e.equals(r)?r:e}get groundAndLayersExtent(){const e=this.spatialReference||et.WGS84;let t;const i=i=>{const r=at(i,e);m(r)||(f(t)?t.union(r):t=r.clone())},r=this.basemapTerrain;if(null!=r&&r.spatialReference){const e=r.groundExtent;i(new Ye({xmin:e[0],ymin:e[1],zmin:0,xmax:e[2],ymax:e[3],zmax:0,spatialReference:r.spatialReference}))}if(this.map){const e=e=>{!f(e.fullExtent)||"graphics"===e.type&&e.internal||i(e.fullExtent)};this.map.allLayers.forEach((t=>e(t)))}if(m(t))return null;t.hasZ?(t.zmin=Math.min(0,t.zmin),t.zmax=Math.max(0,t.zmax)):(t.zmin=0,t.zmax=0);const s=this._get("groundAndLayersExtent");return t.equals(s)?s:t}set environment(e){e!==this._defaults.environment&&(this._externallySet.environment=!0),this._set("environment",e)}castEnvironment(e){return e?e instanceof le?e:e instanceof Je?null!=this.environment?this.environment.cloneWithWebsceneEnvironment(e):le.fromWebsceneEnvironment(e):G(le,e):new le}get pixelRatio(){return Math.min(this.windowDevicePixelRatio,this.maximumPixelRatio)}set pixelRatio(e){f(e)?this._override("pixelRatio",e):this._clearOverride("pixelRatio")}get maximumPixelRatio(){let e=1/0;const{maximumPixelRatio:t,maximumRenderResolution:i}=this.qualitySettings;if(null!=t&&(e=Math.min(e,t)),null!=i){const t=i/Math.max(this.width,this.height);e=Math.min(e,t)}return e}set maximumPixelRatio(e){f(e)?this._override("maximumPixelRatio",e):this._clearOverride("maximumPixelRatio")}get initialExtentRequired(){return this.stateManager&&!this.stateManager.hasInitialView}get _defaultsFromMapSettings(){return{required:{tileInfo:!1,heightModelInfo:!0,extent:!1}}}get interacting(){return this.navigating||f(this.activeTool)}get stationary(){return!this.animation&&!this.resizing&&(m(this.state)||this.state.stationary)}set qualityProfile(e){_e.isValidProfile(e)&&(_e.apply(e,this.qualitySettings),this._set("qualityProfile",e))}get qualityProfile(){return this._get("qualityProfile")||_e.getDefaultProfile()}set slicePlane(e){if(f(this._stage)&&this._stage.renderView.setRenderParameters({slicePlane:e}),m(e))return void this._set("slicePlane",null);const t=this.propertiesPool.get("slicePlane");N(e,t),this._set("slicePlane",t)}get typeSpecificPreconditionsReady(){return!!this.viewingMode}get resolution(){return null!=this.spatialReference?Q(this.scale,this.spatialReference):0}get heightModelInfo(){const e=this.getDefaultHeightModelInfo();return null!=e?L.deriveUnitFromSR(e,this.spatialReference):null}get updating(){var e,t,i;if(this.destroyed)return!1;let r=0,s=this.layerViewManager.updating,n=s?this.layerViewManager.updatingRemaining:0;this.allLayerViews.forEach((e=>{if(e.isFulfilled()){if(e.updating){if(s=!0,e.suspended||je(e))return;++n,r+=e.updatingProgress}}else++n}));for(const a of[this.graphicsView,this.basemapView,this._resourceController,this._stage,this.featureTiles,this.pointsOfInterest,this.environmentManager,this.overlay,this.featureTreeDebugger,this.toolViewManager,this.analysisViewManager])if(f(a)&&a.updating){const e=.1;n+=e,r+=.5*e}for(const a of[this.deconflictor,this.labeler,this.basemapTerrain])f(a)&&a.updating&&(++n,r+=a.updatingProgress);if(s=!!(s||n>0||this.updatingHandles.updating||!this.ready||!this.stationary||this._createGraphicsViewController||null!=(e=this.inputManager)&&e.hasPendingInputs||null!=(t=this.map)&&null!=(i=t.allLayers)&&i.some((e=>!e.isFulfilled()))),s?(this._numUpdating=Math.max(n,this._numUpdating),r+=this._numUpdating-n):this._numUpdating=0,this._numUpdating>0?r/=this._numUpdating:r=s?0:1,this._get("updatingProgress")!==r){const e=this._resourceController.scheduler.now;if(r<1){const t=Math.min((e-this._lastUpdateTime)/2e3,1);r=this.updatingProgress*(1-t)+r*t}this._set("updatingProgress",r),this._lastUpdateTime=s&&r<1?e:0}return s}get viewingMode(){var e;const t=this._predeterminedViewingMode;if(f(t))return re(t);const i=this.spatialReference;return f(null==(e=this.defaultsFromMap)?void 0:e.viewingMode)&&i&&i.equals(this.defaultsFromMap.spatialReference)?re(this.defaultsFromMap.viewingMode):!i||Xe(i,ie.Global)?"global":"local"}set viewingMode(e){this.ready?it.error("#viewingMode","viewingMode cannot be set once view is ready"):e?this._override("viewingMode",e):void 0===e&&this._clearOverride("viewingMode")}get resourceController(){return this._resourceController}get performanceInfo(){return new Ce(this)}forceAnimationTime(e){this._stage.renderView.forcedAnimationTime=this.basemapTerrain.overlayManager.forcedAnimationTime=e}on(e,t,i,r){const s=this.viewEvents.on(e,t,i,r);return s||super.on(e,t)}hasEventListener(e){return super.hasEventListener(e)||this.viewEvents.hasHandler(e)}toMap(e,t){if(!this.ready)return it.error("#toMap()","Scene view cannot be used before it is ready"),null;const i=t?this.externalToInternalIntersectOptions(t):this._defaultToMapOptions,r=f(i.graphics)&&(f(i.graphics.include)||f(i.graphics.exclude)),s=Qe(e)?$e(this,e):e,n=C(s);i.enableDraped=i.include&&!i.include.has(qe)||i.exclude&&i.exclude.has(qe);const a=this.sceneIntersectionHelper,o=He(this.state.viewingMode);if(o.options.selectionMode=!0,o.options.store=r?Ue.ALL:Ue.MIN,a.intersectIntersectorScreen(n,o,i),r){for(const e of o.results.all){const t=Fe(e,this);if(m(t))return this._intersectResultToMapPoint(e);if(this._testGraphicUidFilter(i.graphics,t))return this._intersectResultToMapPoint(e)}return null}return this._intersectResultToMapPoint(o.results.min)}toScreen(e){if(!this.ready)return it.error("#toScreen()","Scene view cannot be used before it is ready"),null;const t=y(null==e.z&&be(this.elevationProvider,e),0);return D(e,lt,this.renderSpatialReference,t),this.state.camera.projectToScreen(lt,pt),O(pt[0],pt[1])}pixelSizeAt(e){return this.ready?e?(D(e,lt,this.renderSpatialReference),this.state.camera.computeScreenPixelSizeAt(lt)):0:(it.error("#pixelSizeAt()","Scene view cannot be used before it is ready"),null)}overlayPixelSizeInMapUnits(e){const t=this.basemapTerrain.overlayManager;return t?t.overlayPixelSizeInMapUnits(e):1}hitTest(e,t){if(!this.ready)return it.error("#hitTest()","Scene view cannot be used before it is ready"),null;const i=Qe(e)?$e(this,e):e,r=P(i.x,i.y),s=t?this.externalToInternalIntersectOptions(t):this._defaultHitTestOptions;s.requiresGroundFeedback=!0,s.enableDraped=!0;const n=He(this.state.viewingMode);n.options.selectionMode=!0,n.options.store=Ue.ALL,this.sceneIntersectionHelper.intersectIntersectorScreen(r,n,s);const a=this._intersectResultsToHits(n.results.all,s.graphics),o=n.results.ground,l=We(o,this),p=f(l)&&"type"in l&&"integrated-mesh"===l.type?l:null,h={screenPoint:i,results:a,ground:{mapPoint:this._intersectResultToMapPoint(o),distance:De(o)?o.distanceInRenderSpace:0,layer:p}};return ve.SCENEVIEW_HITTEST_RETURN_INTERSECTOR&&(h.intersector=n),Promise.resolve(h)}popupHitTest(e){return ze(this,e).then((({results:t,ground:i})=>{let r=null;return!(0===t.length||Math.abs(y(t[0].distance,0)-i.distance)<1e-5)||i.layer&&"integrated-mesh"===i.layer.type||(r=i.mapPoint),{results:t,screenPoint:e,mapPoint:r}}))}goTo(e,t){return this.updatingHandles.addPromise(this.stateManager.goTo(e,t))}async whenAnalysisView(e){if(m(e.parent))throw new o("view:no-analysisview-for-analysis","The analysis has not been added to an AnalysisLayer or SceneView.analyses",{analysis:e});if("analysis"===e.parent.type){return(await this.whenLayerView(e.parent)).whenAnalysisView(e)}return this.analysisViewManager.whenAnalysisView(e)}whenLayerView(e){return super.whenLayerView(e)}takeScreenshot(e){return this.whenReady().then((()=>{const t=Ne(e,this);for(const e of this.map.allLayers.items)"voxel"===e.type&&(t.renderScreenshotTwice=!0);return t.pixelRatio/=this.pixelRatio,this._stage.renderView.takeScreenshot(Be(t,this.supersampleScreenshotsEnabled,this.padding))}))}addUpdatingPromise(e){return this.updatingHandles.addPromise(e)}importLayerView(e){return ne.importLayerView(e)}hasLayerViewModule(e){return ne.hasLayerViewModule(e)}forceDOMReadyCycle(){this.forceReadyCycle()}getDefaultSpatialReference(){var e,t,i,r;return this.map&&"initialViewProperties"in this.map&&(null==(e=this.map)||null==(t=e.initialViewProperties)?void 0:t.spatialReference)||(null==(i=this.defaultsFromMap)?void 0:i.spatialReference)||(null==(r=this.defaultsFromMap)?void 0:r.ready)&&this._initialDefaultSpatialReference||null}async validate(){let e=Ke(this.type);if(d("safari")&&d("safari")<9&&(e=new o("sceneview:browser-not-supported","This browser is not supported by SceneView (Safari < 9)",{type:"safari",requiredVersion:9,detectedVersion:d("safari")})),f(e))throw it.warn("#validate()",e.message),e}get _predeterminedViewingMode(){var e,t;const i=this._isOverridden("viewingMode")?this._get("viewingMode"):null!=(e=this.map&&"initialViewProperties"in this.map?null==(t=this.map.initialViewProperties)?void 0:t.viewingMode:null)?e:null;return f(i)?se(i):null}getSpatialReferenceSupport({spatialReference:e,layer:t}){const i=this._predeterminedViewingMode;if(f(i))return this._validateSpatialReferenceForViewingMode(e,t,i)?{constraints:this._makeSpatialReferenceConstraints(e,t,i)}:null;const r=this._validateSpatialReferenceForViewingMode(e,t,ie.Local),s=this._validateSpatialReferenceForViewingMode(e,t,ie.Global);return r||s?r&&s?{constraints:this._makeSpatialReferenceConstraints(e,t,null)}:r?{constraints:this._makeSpatialReferenceConstraints(e,t,ie.Local)}:{constraints:this._makeSpatialReferenceConstraints(e,t,ie.Global)}:null}_validateSpatialReferenceForViewingMode(e,t,i){return!!Xe(e,i)&&(!!m(t)||(!X(t)||!m(Ie(t,e,i)))&&("voxel"!==t.type||i===ie.Local))}_makeSpatialReferenceConstraints(e,t,i){return t&&!X(t)&&"voxel"!==t.type&&(e.isWebMercator||e.isWGS84)?[{spatialReference:e,viewingMode:i},{spatialReference:e.isWebMercator?et.WGS84:et.WebMercator,viewingMode:i}]:[{spatialReference:e,viewingMode:i}]}_validateSpatialReference(e){const t=f(this.getSpatialReferenceSupport({spatialReference:e})),i=this._predeterminedViewingMode;return t||(f(i)?it.warnOnce(`Spatial reference defined on view not supported in ${re(i)} viewing mode.`):e.isGeographic&&it.warnOnce("Spatial reference is geographic but not supported.")),t}whenReady(){return new Promise((e=>{this.ready?e(this):this._resolveWhenReady.push(e)}))}computeMapPointFromVec3d(e,t){let i=this.spatialReference||et.WGS84;return F(e,this.renderSpatialReference,e,i)||(i=et.WGS84,F(e,this.renderSpatialReference,e,i)),t?(t.x=e[0],t.y=e[1],t.z=e[2],t.spatialReference=i):t=new tt(e,i),t}trackGraphicState(e){if(!e.graphic)return it.error("trackGraphicState","GraphicState.graphic must not be null or undefined to start tracking"),null;const t=this.getViewForGraphic(e.graphic);let i=null,r=!1;const s=t=>{!r&&f(t)&&"graphics3d"in t&&t.graphics3d&&t.graphics3d.graphicsCore&&(i=t.graphics3d.graphicsCore.trackGraphicState(e))};return f(t)?s(t):this.whenViewForGraphic(e.graphic,{waitForLayer:!0}).then((e=>s(e)),(()=>{})).catch((()=>{})),{remove:()=>{r=!0,f(i)&&(i.remove(),i=null)}}}highlight(e){if(Array.isArray(e))return p(e.map((e=>this.highlight(e))));if(n.isCollection(e))return p(e.toArray().map((e=>this.highlight(e))));const t=this.getViewForGraphic(e);return t&&"highlight"in t?t.highlight(e):h()}maskOccludee(e){if(!e)return it.error("maskOccludee","GraphicState.graphic must not be null or undefined to mask an occludee"),null;const t=this.getViewForGraphic(e);let i=null,r=!1;const s=t=>{!r&&f(t)&&"graphics3d"in t&&ke(t)&&(i=t.maskOccludee(e))};return f(t)?s(t):this.whenViewForGraphic(e,{waitForLayer:!0}).then((e=>s(e)),(()=>{})).catch((()=>{})),{remove:()=>{r=!0,f(i)&&(i.remove(),i=null)}}}getViewForGraphic(e){return e.layer===this.graphics?this.graphicsView:e.layer?this.allLayerViews.find((t=>t.layer===e.layer)):null}graphicChanged(e){f(this.graphicsView)&&this.graphicsView.graphicChanged(e)}async whenViewForGraphic(e,t){if(e.layer===this)return await R(this,"graphicsView"),this.graphicsView;if(!e.layer||!this.map)throw new o("no-view-for-graphic");return t&&t.waitForLayer&&!this.map.allLayers.includes(e.layer)?new Promise(((t,i)=>{const r=this.map.allLayers.on("change",(s=>{-1!==s.added.indexOf(e.layer)&&(r.remove(),this.whenLayerView(e.layer).then(t,i))}))})):this.whenLayerView(e.layer)}externalToInternalIntersectOptions(e){const t=this._externalToInternalRenderItems(e.include,ot.INCLUDE),i=this._externalToInternalRenderItems(e.exclude,ot.EXCLUDE);return{include:t.layerUids,exclude:i.layerUids,graphics:{include:t.graphicUids,exclude:i.graphicUids}}}_intersectResultToMapPoint(e,t){return e.getIntersectionPoint(lt)?(t=this.computeMapPointFromVec3d(lt,t),e.intersector===Ae.TERRAIN&&this.basemapTerrain&&(t.z=y(be(this.basemapTerrain,t),0)),t):null}_intersectResultsToHits(e,t){const i=new Array;let r=null;for(let s=0;s<e.length;s++){const n=e[s],a=We(n,this);if(f(a)&&(a===this.map.ground||"type"in a&&"integrated-mesh"===a.type))break;const o=Fe(n,this);if(!f(o))continue;if(m(r)&&s!==e.length-1&&(r=new Set),f(r)){const e=this._getGraphicFilterUid(o);if(r.has(e))continue;r.add(e)}if(!this._testGraphicUidFilter(t,o))continue;const l=this._intersectResultToMapPoint(n),p=n.distanceInRenderSpace;i.push({graphic:o,mapPoint:l,distance:p})}return i}_getGraphicFilterUid(e){if(e.layer&&"objectIdField"in e.layer){const t=e.attributes[e.layer.objectIdField];if(t)return`o-${e.layer.id}-${t}`}return`u-${e.uid}`}_testGraphicUidFilter(e,t){const i=this._getGraphicFilterUid(t);return m(e)||(m(e.include)||e.include.has(i))&&(m(e.exclude)||!e.exclude.has(i))}_externalToInternalRenderItems(e,t,s={layerUids:null,graphicUids:null}){if(!e)return s;if(e instanceof i)nt(s,this._getGraphicFilterUid(e)),t===ot.INCLUDE&&(f(this.graphicsView)&&e.layer===this?st(s,this.graphicsView.graphics3d.layer.id):e.layer&&st(s,e.layer.uid));else if(c(e))for(const i of e)i===this.graphics&&f(this.graphicsView)?st(s,this.graphicsView.graphics3d.layer.id):i instanceof r?i===this.map.ground&&st(s,qe):this._externalToInternalRenderItems(i,t,s);else st(s,e.uid);return s}_initBasemapTerrain(){this._set("basemapTerrain",new Ee({view:this})),this._set("elevationProvider",new we({view:this})),this.elevationProvider.register("ground",this.basemapTerrain)}_exitBasemapTerrain(){this.basemapTerrain&&(this.elevationProvider.unregister(this.basemapTerrain),this.elevationProvider.destroy(),this._set("elevationProvider",null),this.basemapTerrain.destroy(),this._set("basemapTerrain",null))}_initGlobe(){this._initCoordinateSystem(),this.state.createInitialCamera(),this._initBasemapTerrain(),this._set("pointsOfInterest",new Pe({view:this})),this._set("featureTiles",new ge({renderCoordsHelper:this.renderCoordsHelper,cameraOnSurface:this.pointsOfInterest.contentCameraOnSurface,focus:this.pointsOfInterest.focus,tilingSchemeOwner:this.basemapTerrain,viewState:this.state,scheduler:this._resourceController.scheduler,terrain:this.basemapTerrain}));const e=()=>{const e=this.basemapTerrain&&this.basemapTerrain.extent;if(this.clippingArea||e)if(e&&this.basemapTerrain.spatialReference){const e=f(this.basemapTerrain.extent)?A(z(this.basemapTerrain.extent,this.basemapTerrain.spatialReference),this.spatialReference):null;f(this.clippingArea)?this.featureTiles.filterExtent=this.clippingArea.intersection(e):this.featureTiles.filterExtent=e}else this.featureTiles.filterExtent=this.clippingArea;else this.featureTiles.filterExtent=null};this.handles.add([this.updatingHandles.add((()=>ve.FEATURE_TILE_TREE_SHOW_TILES),(e=>{e&&this.featureTiles&&!this.featureTreeDebugger?this.updatingHandles.addPromise(import("./3d/layers/support/FeatureTileTree3DDebugger.js")).then((({FeatureTileTree3DDebugger:e})=>{!this.featureTreeDebugger&&ve.FEATURE_TILE_TREE_SHOW_TILES&&(this.featureTreeDebugger=new e({view:this}))})):e||!this.featureTreeDebugger||ve.FEATURE_TILE_TREE_SHOW_TILES||(this.featureTreeDebugger.destroy(),this.featureTreeDebugger=null)}),b),this.updatingHandles.add((()=>this.clippingArea),e,b),this.updatingHandles.add((()=>this.basemapTerrain.extent),e,b)],"feature-tiles"),this.stateManager.init()}_exitGlobe(){this.state&&(this.stateManager.deinit(),this.handles.remove("render-coords-helper"),this.handles.remove("feature-tiles"),this.featureTiles.destroy(),this._set("featureTiles",null),this.pointsOfInterest.destroy(),this._set("pointsOfInterest",null),this._exitBasemapTerrain(),this.state.exit(),this._exitCoordinateSystem())}_initCoordinateSystem(){if(this.spatialReference){const e=this.spatialReference;this.mapCoordsHelper&&this.mapCoordsHelper.spatialReference.equals(e)||this._set("mapCoordsHelper",new Me(this.map,e));const t=this.state.isGlobal,i=B(t,e);i!==this.renderSpatialReference&&(this._set("renderCoordsHelper",Ve.create(this.state.viewingMode,i)),t||this.handles.add(this.watch("basemapTerrain.extent",(e=>{const t=this.renderCoordsHelper.spatialReference;0===e[0]&&0===e[1]&&0===e[2]&&0===e[3]||!W(e,this.basemapTerrain.spatialReference,ht,t)||(this.renderCoordsHelper.extent=ht)}),!0),"render-coords-helper"),this.sceneIntersectionHelper&&this.sceneIntersectionHelper.setTolerance(Le/this.renderCoordsHelper.unitInMeters))}else this._set("mapCoordsHelper",null),this._set("renderCoordsHelper",null)}_exitCoordinateSystem(){this.mapCoordsHelper&&(this.handles.remove("render-coords-helper"),this._set("renderCoordsHelper",null),this._set("mapCoordsHelper",null))}_updatingChanged(){this.notifyChange("updating")}_updateUpdatingMonitors(e=null){f(e)&&e.type===w.MOVE||(this.handles.remove("updatingMonitors"),this.allLayerViews.forEach((e=>{e.destroyed||(this.handles.add([e.watch(["updating","updatingProgress"],(()=>this._updatingChanged()),!0)],"updatingMonitors"),e.when((()=>this._updatingChanged()),(()=>this._updatingChanged())))})),this._updatingChanged())}_renderScreenshotOverlay(e,t){if(!this.overlay||!this.overlay.hasVisibleItems)return t;const i=e.getContext("2d");return i.putImageData(t,0,0),this.overlay.renderCanvas(e),i.getImageData(0,0,t.width,t.height)}_initStage(){const e={deactivatedWebGLExtensions:this.deactivatedWebGLExtensions,debugWebGLExtensions:this.debugWebGLExtensions,alpha:this.alphaCompositingEnabled,canvas:this.renderCanvas,screenshot:{renderOverlay:(e,t)=>this._renderScreenshotOverlay(e,t)}},t=new ye(this.state.viewingMode,(e=>this._stage.layers.forAll(e)),this);this._set("sceneIntersectionHelper",t);const i=a(this.surface),{resourceController:r,state:s,renderSpatialReference:n}=this;this._stage=new Ge({options:e,container:i,resourceController:r,state:s,sceneIntersectionHelper:t,renderSR:n}),this._stage.renderView.setRenderParameters({slicePlane:this.slicePlane}),this._lostWebGLContextHandle=l(this._stage.renderView.canvas,"webglcontextlost",(()=>this.fatalError=new o("webgl-context-lost"))),this.handles.add([this.updatingHandles.add((()=>this.qualitySettings.antialiasingEnabled),(()=>this._stage.renderView.setRenderParameters({antialiasingEnabled:this.qualitySettings.antialiasingEnabled})),_),this.updatingHandles.add((()=>this.qualitySettings.highQualityTransparency),(()=>this._stage.renderView.setRenderParameters({highQualityTransparency:this.qualitySettings.highQualityTransparency})),_),x(this,"magnifier",(e=>this._stage.renderView.magnifier=e),!0)],"stage");const p=()=>{this._stage.renderView.setRenderParameters({defaultHighlightOptions:Se.toEngineOptions(this.highlightOptions)})};this.handles.add(this.updatingHandles.add((()=>[this.highlightOptions.color,this.highlightOptions.haloColor,this.highlightOptions.haloOpacity,this.highlightOptions.fillOpacity,this.highlightOptions.shadowOpacity,this.highlightOptions.shadowColor,this.highlightOptions.shadowDifference]),p),"stage"),p(),this.renderCoordsHelper&&this.sceneIntersectionHelper.setTolerance(Le/this.renderCoordsHelper.unitInMeters),this._set("canvas",this._stage.renderView.canvas)}_exitStage(){this._set("sceneIntersectionHelper",null),this._stage.destroy(),this._stage=null,this._lostWebGLContextHandle.remove(),this._lostWebGLContextHandle=null,this.handles.remove("stage"),this._set("canvas",null)}_initSurface(e){this._exitSurface(),this.state.init(e,this.spatialReference),this._initStage(),this._initGlobe(),this.sharedSymbolResources=new Oe({view:this,viewingMode:e,resourceController:this._resourceController,pointsOfInterest:this.pointsOfInterest,viewState:this.state,objectResourceCache:new ue})}_exitSurface(){this.sharedSymbolResources&&(this.sharedSymbolResources.objectResourceCache.destroy(),this.sharedSymbolResources.destroy(),this.sharedSymbolResources=null,this._exitGlobe(),this._exitStage())}_createGraphicsViewIfNeeded(){if(this.graphicsView||this._createGraphicsViewController)return;if(0===this.graphics.length)return;this.handles.remove("graphics-view"),this._createGraphicsViewController=new AbortController;const e=()=>{this._createGraphicsViewController=null,this._updatingChanged()};this._createGraphicsViewAsync(this._createGraphicsViewController.signal).then(e,e),this._updatingChanged()}async _createGraphicsViewAsync(e){const t=(await import("./3d/layers/GraphicsView3D.js")).default;v(e),await V(this.basemapTerrain,"ready",e),this._set("graphicsView",new t({view:this}))}_disposeGraphicsView(){this._createGraphicsViewController&&(this._createGraphicsViewController.abort(),this._createGraphicsViewController=null),this.handles.remove("graphics-view"),f(this.graphicsView)&&(this.handles.remove(this.graphicsView.graphics3d.layer.id),this.graphicsView.destroy(),this._set("graphicsView",null))}_startup(){const e=se(this.viewingMode);if(e===ie.Global&&(this._clippingArea=null),this._initSurface(e),this._set("ready",!0),this.handles.add(M(this,"graphics","after-changes",(()=>this._createGraphicsViewIfNeeded())),"graphics-view"),this._createGraphicsViewIfNeeded(),!this._externallySet.environment){const e=this.get("map.initialViewProperties.environment");e&&(this.environment=e)}this.labeler.setup(),this.environmentManager.connectView(this),this.inputManager.connect();const t=this._resolveWhenReady;this._resolveWhenReady=[],t.forEach((e=>e(this)))}_teardown(){this._initialDefaultSpatialReference=null,this.inputManager.disconnect(),this.environmentManager.disconnectView(),this.labeler.dispose(),this._disposeGraphicsView(),this.handles.remove("graphics-view"),this._exitSurface(),this._set("ready",!1)}_updateDefaultToMapOptions(){if(this._defaultToMapOptions.include.clear(),this.map){this.map.ground&&this._defaultToMapOptions.include.add(qe);for(const e of this.map.allLayers.items)"integrated-mesh"===e.type&&this._defaultToMapOptions.include.add(e.uid)}}_updateDefaultHitTestOptions(){if(this._defaultHitTestOptions.exclude.clear(),this.map){this.map.ground&&this.map.ground.opacity<1&&this._defaultHitTestOptions.exclude.add(qe);for(const e of this.map.allLayers.items)"integrated-mesh"===e.type&&e.opacity<1&&this._defaultToMapOptions.exclude.add(e.uid)}}getVoxelWasmPerSceneView(){return $.getInstance().getVoxelWasmPerSceneView(this)}};function st(e,t){e.layerUids||(e.layerUids=new Set),e.layerUids.add(t)}function nt(e,t){e.graphicUids||(e.graphicUids=new Set),e.graphicUids.add(t)}function at(e,t){return f(e)&&U(e.spatialReference,t)?A(e,t):null}var ot;e([E()],rt.prototype,"_userClippingArea",void 0),e([E()],rt.prototype,"_resourceController",void 0),e([E()],rt.prototype,"_stage",void 0),e([E({readOnly:!0})],rt.prototype,"deconflictor",void 0),e([E({readOnly:!0})],rt.prototype,"labeler",void 0),e([E({type:te,readOnly:!0,aliasOf:"state.animation"})],rt.prototype,"animation",void 0),e([E({readOnly:!0})],rt.prototype,"basemapTerrain",void 0),e([E({readOnly:!0})],rt.prototype,"elevationProvider",void 0),e([E({type:t,aliasOf:"stateManager.camera"})],rt.prototype,"camera",void 0),e([E({type:t,aliasOf:"stateManager.contentCamera"})],rt.prototype,"contentCamera",void 0),e([E({readOnly:!0})],rt.prototype,"canvas",void 0),e([E({type:tt,aliasOf:"stateManager.center"})],rt.prototype,"center",void 0),e([E({type:Ye})],rt.prototype,"clippingArea",null),e([E({type:oe})],rt.prototype,"constraints",void 0),e([E({type:Ye,readOnly:!0})],rt.prototype,"renderDataExtent",null),e([E({type:Ye,readOnly:!0})],rt.prototype,"dataExtent",null),e([E({type:Ye,readOnly:!0})],rt.prototype,"groundAndLayersExtent",null),e([E({value:null,type:le})],rt.prototype,"environment",null),e([j("environment")],rt.prototype,"castEnvironment",null),e([E({readOnly:!0})],rt.prototype,"environmentManager",void 0),e([E({type:Ye,aliasOf:"stateManager.extent"})],rt.prototype,"extent",void 0),e([E()],rt.prototype,"floors",void 0),e([E({readOnly:!0,aliasOf:"stateManager.screenCenter"})],rt.prototype,"screenCenter",void 0),e([E({type:Number})],rt.prototype,"pixelRatio",null),e([E({type:Number,dependsOn:["qualitySettings.maximumPixelRatio","qualitySettings.maximumRenderResolution","size"]})],rt.prototype,"maximumPixelRatio",null),e([E({aliasOf:"stateManager.frustum"})],rt.prototype,"frustum",void 0),e([E({type:Number,readOnly:!0})],rt.prototype,"fullOpacity",void 0),e([E({readOnly:!0})],rt.prototype,"graphicsView",void 0),e([E({readOnly:!0})],rt.prototype,"analysisViewManager",void 0),e([E()],rt.prototype,"groundView",void 0),e([E({type:Boolean})],rt.prototype,"initialExtentRequired",null),e([E()],rt.prototype,"_defaultsFromMapSettings",null),e([E({type:Boolean,readOnly:!0})],rt.prototype,"interacting",null),e([E()],rt.prototype,"stationary",null),e([E({aliasOf:"state.navigating"})],rt.prototype,"navigating",void 0),e([E()],rt.prototype,"map",void 0),e([E({readOnly:!0})],rt.prototype,"mapCoordsHelper",void 0),e([E({aliasOf:"stateManager.padding"})],rt.prototype,"padding",void 0),e([E({type:Pe,readOnly:!0})],rt.prototype,"pointsOfInterest",void 0),e([E({type:ge,readOnly:!0})],rt.prototype,"featureTiles",void 0),e([E()],rt.prototype,"featureTreeDebugger",void 0),e([E({type:Boolean})],rt.prototype,"screenSizePerspectiveEnabled",void 0),e([E({constructOnly:!0})],rt.prototype,"deactivatedWebGLExtensions",void 0),e([E({constructOnly:!0})],rt.prototype,"debugWebGLExtensions",void 0),e([E({constructOnly:!0})],rt.prototype,"renderCanvas",void 0),e([E({constructOnly:!0})],rt.prototype,"state",void 0),e([E({readOnly:!0})],rt.prototype,"inputManager",void 0),e([E({readOnly:!0})],rt.prototype,"stateManager",void 0),e([E({type:["low","medium","high"]})],rt.prototype,"qualityProfile",null),e([E({type:xe,get(){let e=this._get("qualitySettings");return e||(e=new xe,_e.apply(this.qualityProfile,e)),e}})],rt.prototype,"qualitySettings",void 0),e([E()],rt.prototype,"slicePlane",null),e([E({readOnly:!0})],rt.prototype,"typeSpecificPreconditionsReady",null),e([E({readOnly:!0})],rt.prototype,"renderCoordsHelper",void 0),e([E({readOnly:!0})],rt.prototype,"sceneIntersectionHelper",void 0),e([E({type:Number,dependsOn:["scale","spatialReference"],readOnly:!0})],rt.prototype,"resolution",null),e([E({type:Number,aliasOf:"stateManager.scale"})],rt.prototype,"scale",void 0),e([E()],rt.prototype,"heightModelInfo",null),e([E()],rt.prototype,"spatialReference",void 0),e([E({type:Boolean,constructOnly:!0})],rt.prototype,"alphaCompositingEnabled",void 0),e([E({type:Boolean})],rt.prototype,"supersampleScreenshotsEnabled",void 0),e([E({readOnly:!0})],rt.prototype,"type",void 0),e([E({type:Ze})],rt.prototype,"ui",void 0),e([E({type:Boolean,readOnly:!0,dependsOn:["graphicsView.updating","basemapView.updating","basemapTerrain.updating","layerViewManager.updating","layerViewManager.updatingRemaining","_resourceController.updating","_stage.updating","featureTiles.updating","pointsOfInterest.updating","environmentManager.updating","overlay.updating","updatingHandles.updating","featureTreeDebugger.updating","labeler.updating","deconflictor.updating","ready","stationary","inputManager.hasPendingInputs","toolViewManager.updating","analysisViewManager.updating"]})],rt.prototype,"updating",null),e([E({type:Number,readOnly:!0,dependsOn:["updating"]})],rt.prototype,"updatingProgress",void 0),e([E({type:["global","local"]})],rt.prototype,"viewingMode",null),e([E({type:s,aliasOf:"stateManager.viewpoint"})],rt.prototype,"viewpoint",void 0),e([E({type:Number,aliasOf:"stateManager.zoom"})],rt.prototype,"zoom",void 0),e([E({type:Se})],rt.prototype,"highlightOptions",void 0),rt=e([I("esri.views.SceneView")],rt),function(e){e[e.INCLUDE=0]="INCLUDE",e[e.EXCLUDE=1]="EXCLUDE"}(ot||(ot={}));const lt=H(),pt=P(),ht=q(),dt=rt;export{dt as default};
5
+ import{_ as e}from"../chunks/tslib.es6.js";import t from"../Camera.js";import"../geometry.js";import i from"../Graphic.js";import r from"../Ground.js";import s from"../Viewpoint.js";import n from"../core/Collection.js";import{byId as a}from"../core/domUtils.js";import o from"../core/Error.js";import{on as l}from"../core/events.js";import{handlesGroup as p,makeHandle as h}from"../core/handleUtils.js";import d from"../core/has.js";import{isIterable as c}from"../core/iteratorUtils.js";import u from"../core/Logger.js";import{destroyMaybe as g,isNone as m,isSome as f,unwrapOr as y}from"../core/maybe.js";import{ObservableChangesType as w}from"../core/ObservableChangesType.js";import{throwIfAborted as v}from"../core/promiseUtils.js";import{initial as _,syncAndInitial as b}from"../core/reactiveUtils.js";import{setFrameDuration as M}from"../core/scheduling.js";import{on as R,whenOnce as S,init as x,whenTrueOnce as V}from"../core/watchUtils.js";import{initialize as T}from"../core/workers/workers.js";import{screenPointObjectToArray as C,createScreenPoint as O,createScreenPointArray as P}from"../core/screenUtils.js";import{property as E}from"../core/accessorSupport/decorators/property.js";import"../core/arrayUtils.js";import{cast as j}from"../core/accessorSupport/decorators/cast.js";import{subclass as I}from"../core/accessorSupport/decorators/subclass.js";import{ensureType as G}from"../core/accessorSupport/ensureType.js";import{c as L}from"../chunks/vec3f64.js";import H from"../geometry/HeightModelInfo.js";import{canProjectWithoutEngine as U,project as A,projectPointToVector as D,projectVectorToVector as F,projectBoundingRect as W}from"../geometry/projection.js";import{create as q,toExtent as z}from"../geometry/support/aaBoundingRect.js";import{B as k,a as N}from"../chunks/boundedPlane.js";import{renderSRFromViewSR as B}from"../geometry/support/coordinateSystem.js";import{getResolutionForScale as Q}from"../geometry/support/scaleUtils.js";import $ from"../layers/VoxelWasmManager.js";import{isTiledLayer as X}from"../layers/support/layerUtils.js";import{BreakpointsOwner as K}from"./BreakpointsOwner.js";import{DOMContainer as Z}from"./DOMContainer.js";import J from"./GroundView.js";import{PopupView as Y}from"./PopupView.js";import ee from"./View.js";import te from"./ViewAnimation.js";import{ViewingMode as ie,stringFromViewingMode as re,viewingModeFromString as se}from"./ViewingMode.js";import{layerView3DImporter as ne}from"./3d/layerViewModuleImportUtils.js";import ae from"./3d/analysis/AnalysisViewManager3D.js";import oe from"./3d/constraints/Constraints.js";import le from"./3d/environment/SceneViewEnvironment.js";import{SceneViewEnvironmentManager as pe}from"./3d/environment/SceneViewEnvironmentManager.js";import he from"./3d/input/SceneInputManager.js";import{GraphicsDeconflictor as de}from"./3d/layers/graphics/GraphicsDeconflictor.js";import{Labeler as ce}from"./3d/layers/graphics/Labeler.js";import{ObjectResourceCache as ue}from"./3d/layers/graphics/ObjectResourceCache.js";import ge from"./3d/layers/support/FeatureTileTree3D.js";import me from"./3d/state/ViewState.js";import fe from"./3d/state/ViewStateManager.js";import{SceneIntersectionHelper as ye}from"./3d/state/helpers/SceneIntersectionHelper.js";import{CombinedElevationProvider as we}from"./3d/support/CombinedElevationProvider.js";import ve from"./3d/support/debugFlags.js";import _e from"./3d/support/DisplayQualityProfile.js";import{getElevationAtPoint as be}from"./3d/support/ElevationProvider.js";import Me from"./3d/support/HighlightOptions.js";import{MapCoordsHelper as Re}from"./3d/support/MapCoordsHelper.js";import{PropertiesPool as Se}from"./3d/support/PropertiesPool.js";import xe from"./3d/support/QualitySettings.js";import{RenderCoordsHelper as Ve}from"./3d/support/RenderCoordsHelper.js";import{newResourceController as Te}from"./3d/support/ResourceController.js";import Ce from"./3d/support/SceneViewPerformanceInfo.js";import{SharedSymbolResources as Oe}from"./3d/support/SharedSymbolResources.js";import Pe from"./3d/support/pointsOfInterest/PointsOfInterest.js";import Ee from"./3d/terrain/TerrainSurface.js";import{isSurfaceLayerView as je,getTiledLayerInfo as Ie}from"./3d/terrain/terrainUtils.js";import{Stage as Ge}from"./3d/webgl-engine/Stage.js";import{newIntersector as Le,DEFAULT_TOLERANCE as He}from"./3d/webgl-engine/lib/Intersector.js";import{StoreResults as Ue,IntersectorType as Ae}from"./3d/webgl-engine/lib/IntersectorInterfaces.js";import{isValidIntersectorResult as De}from"./3d/webgl-engine/lib/intersectorUtils.js";import{toGraphic as Fe,toOwner as We}from"./3d/webgl-engine/lib/intersectorUtilsConversions.js";import{TERRAIN_ID as qe}from"./3d/webgl-engine/lib/verticalOffsetUtils.js";import{hitTestSelectSameDistance as ze}from"./support/hitTestSelectUtils.js";import{occludeesSupported as ke}from"./support/layerViewUtils.js";import{toRenderSettings as Ne,screenshotSuperSampleSettings as Be}from"./support/screenshotUtils.js";import{isSupportedScreenPointEvent as Qe,createScreenPointFromSupportedEvent as $e}from"./support/screenUtils.js";import{isSpatialReferenceSupported as Xe}from"./support/spatialReferenceSupport.js";import{check as Ke}from"./support/WebGLRequirements.js";import Ze from"./ui/3d/DefaultUI3D.js";import Je from"../webscene/Environment.js";import Ye from"../geometry/Extent.js";import et from"../geometry/SpatialReference.js";import tt from"../geometry/Point.js";const it=u.getLogger("esri.views.SceneView");let rt=class extends(K(Z(Y(ee)))){constructor(e){super(e),this._userClippingArea=null,this._clippingArea=null,this._initialDefaultSpatialReference=null,this._defaults={},this._externallySet={environment:!1},this._createGraphicsViewController=null,this._resolveWhenReady=[],this.propertiesPool=new Se({slicePlane:k},this),this._resourceController=Te(this),this._defaultToMapOptions={include:new Set},this._defaultHitTestOptions={exclude:new Set},this.deconflictor=new de({view:this}),this.labeler=new ce({view:this,deconflictor:this.deconflictor.labels}),this.sharedSymbolResources=null,this.basemapTerrain=null,this.elevationProvider=null,this.camera=null,this.canvas=null,this.center=null,this.constraints=new oe,this.environmentManager=new pe,this.extent=null,this.floors=new n,this.windowDevicePixelRatio=1,this.fullOpacity=1,this.graphicsView=null,this.analysisViewManager=new ae({view:this}),this.groundView=null,this.navigating=!1,this.map=null,this.screenSizePerspectiveEnabled=!0,this.state=new me,this.scale=null,this.spatialReference=null,this.alphaCompositingEnabled=!1,this.supersampleScreenshotsEnabled=!0,this.type="3d",this.ui=new Ze,this._numUpdating=0,this._lastUpdateTime=0,this.updatingProgress=.5,this.viewpoint=null,this.zoom=null,this.highlightOptions=new Me,T(),e&&e.environment||(this._defaults.environment=new le,this.environment=this._defaults.environment);const t=e=>{f(e)&&e.type===w.MOVE||(this._updatingChanged(),this.map&&this.map.allLayers.forEach((async e=>{try{await e.when()}catch{}this._updatingChanged()})))};this.handles.add([R(this,"map.allLayers","after-changes",t,t,t,!0),this.allLayerViews.on("after-changes",(e=>this._updateUpdatingMonitors(e))),this.watch("map",(e=>{e&&e.load&&e.load().catch((()=>{}))}))]),this.inputManager=new he({view:this});const i=()=>{const e=window.devicePixelRatio;e!==this.windowDevicePixelRatio&&(this.windowDevicePixelRatio=e,this.notifyChange("pixelRatio"))};this.stateManager=new fe({view:this,updateDevicePixelRatio:i})}initialize(){this.groundView=new J({view:this}),this._updateUpdatingMonitors();const e=()=>this._updateDefaultToMapOptions();this.handles.add(R(this,"map.allLayers","after-changes",e,e,e)),this.updatingHandles.add((()=>this.qualitySettings.memoryLimit),(e=>{this.resourceController&&(this.resourceController.memoryController.maxMemory=e)}),_),this.updatingHandles.add((()=>this.qualitySettings.additionalCacheMemory),(e=>{this.resourceController&&(this.resourceController.memoryController.additionalCacheMemory=e)}),_),this.updatingHandles.add((()=>this.qualitySettings.frameRate),(e=>M(e>0?1e3/Math.ceil(e):0)),_),this.updatingHandles.add((()=>ve.SCENEVIEW_LOCKING_LOG),(e=>this.defaultsFromMap.logDebugInformation=e),_),this.updatingHandles.add((()=>{var e;return null==(e=this.map)?void 0:e.ground}),e,b),this.updatingHandles.add((()=>{var e,t;return null==(e=this.map)||null==(t=e.ground)?void 0:t.opacity}),(()=>this._updateDefaultHitTestOptions()),b),this.handles.add(this.watch("spatialReference",(()=>this.notifyChange("clippingArea")),!0))}destroy(){this.destroyed||(this.invalidate(),this.activeTool=null,this.layerViewManager.clear(),this._exitSurface(),this._disposeGraphicsView(),this.sharedSymbolResources=g(this.sharedSymbolResources),this.labeler.destroy(),this._set("labeler",null),this.deconflictor.destroy(),this._set("deconflictor",null),this._resourceController=g(this._resourceController),this.stateManager.destroy(),this._set("stateManager",null),this.inputManager.destroy(),this._set("inputManager",null),this.propertiesPool.destroy(),this.handles.remove("updatingMonitors"),this.environmentManager.destroy(),this._set("environmentManager",null),this.groundView=g(this.groundView))}get renderSpatialReference(){return this.renderCoordsHelper&&this.renderCoordsHelper.spatialReference}get basemapSpatialReference(){return this.basemapTerrain&&this.basemapTerrain.spatialReference}installContentCameraReset(e={sticky:!1}){return this.stateManager.installContentCameraReset(e)}get clippingArea(){if("global"===this.viewingMode)return null;let e=this._userClippingArea||this.get("map.clippingArea");return!(!!this._userClippingArea||this.get("map.clippingEnabled"))||m(e)?(this._clippingArea=null,null):e instanceof Ye?this.spatialReference&&(e=at(e,this.spatialReference),m(e))?(it.error("#clippingArea","setting clippingArea with incompatible SpatialReference"),this._clippingArea):(e=e.clone(),m(e.intersection(this.groundAndLayersExtent))&&(e.xmin=e.xmax,e.ymin=e.ymax),e.zmin=void 0,e.zmax=void 0,e.equals(this._clippingArea)||(this._clippingArea=e),this._clippingArea):(it.error("#clippingArea","only clippingArea geometries of type Extent are supported"),this._clippingArea)}set clippingArea(e){this.ready&&"global"===this.viewingMode&&f(e)?it.error("#clippingArea=","Clipping area is only supported in local viewingMode"):this._userClippingArea=e}get renderDataExtent(){if(this.state.viewingMode===ie.Global)return null;const e=this.renderSpatialReference,t=this.dataExtent;return m(t)||m(e)||t.spatialReference.equals(e)?t:at(t,e)}get dataExtent(){let e=this.groundAndLayersExtent;const t=this.spatialReference||et.WGS84,i=at(this.clippingArea,t);f(i)&&(e=f(e)?e.intersection(i):i);const r=this._get("dataExtent");return f(e)&&e.equals(r)?r:e}get groundAndLayersExtent(){const e=this.spatialReference||et.WGS84;let t;const i=i=>{const r=at(i,e);m(r)||(f(t)?t.union(r):t=r.clone())},r=this.basemapTerrain;if(null!=r&&r.spatialReference){const e=r.groundExtent;i(new Ye({xmin:e[0],ymin:e[1],zmin:0,xmax:e[2],ymax:e[3],zmax:0,spatialReference:r.spatialReference}))}if(this.map){const e=e=>{!f(e.fullExtent)||"graphics"===e.type&&e.internal||i(e.fullExtent)};this.map.allLayers.forEach((t=>e(t)))}if(m(t))return null;t.hasZ?(t.zmin=Math.min(0,t.zmin),t.zmax=Math.max(0,t.zmax)):(t.zmin=0,t.zmax=0);const s=this._get("groundAndLayersExtent");return t.equals(s)?s:t}set environment(e){e!==this._defaults.environment&&(this._externallySet.environment=!0),this._set("environment",e)}castEnvironment(e){return e?e instanceof le?e:e instanceof Je?null!=this.environment?this.environment.cloneWithWebsceneEnvironment(e):le.fromWebsceneEnvironment(e):G(le,e):new le}get pixelRatio(){return Math.min(this.windowDevicePixelRatio,this.maximumPixelRatio)}set pixelRatio(e){f(e)?this._override("pixelRatio",e):this._clearOverride("pixelRatio")}get maximumPixelRatio(){let e=1/0;const{maximumPixelRatio:t,maximumRenderResolution:i}=this.qualitySettings;if(null!=t&&(e=Math.min(e,t)),null!=i){const t=i/Math.max(this.width,this.height);e=Math.min(e,t)}return e}set maximumPixelRatio(e){f(e)?this._override("maximumPixelRatio",e):this._clearOverride("maximumPixelRatio")}get initialExtentRequired(){return this.stateManager&&!this.stateManager.hasInitialView}get _defaultsFromMapSettings(){return{required:{tileInfo:!1,heightModelInfo:!0,extent:!1}}}get interacting(){return this.navigating||f(this.activeTool)}get stationary(){return!this.animation&&!this.resizing&&(m(this.state)||this.state.stationary)}set qualityProfile(e){_e.isValidProfile(e)&&(_e.apply(e,this.qualitySettings),this._set("qualityProfile",e))}get qualityProfile(){return this._get("qualityProfile")||_e.getDefaultProfile()}set slicePlane(e){if(f(this._stage)&&this._stage.renderView.setRenderParameters({slicePlane:e}),m(e))return void this._set("slicePlane",null);const t=this.propertiesPool.get("slicePlane");N(e,t),this._set("slicePlane",t)}get typeSpecificPreconditionsReady(){return!!this.viewingMode}get resolution(){return null!=this.spatialReference?Q(this.scale,this.spatialReference):0}get heightModelInfo(){const e=this.getDefaultHeightModelInfo();return null!=e?H.deriveUnitFromSR(e,this.spatialReference):null}get updating(){var e,t,i;if(this.destroyed)return!1;let r=0,s=this.layerViewManager.updating,n=s?this.layerViewManager.updatingRemaining:0;this.allLayerViews.forEach((e=>{if(e.isFulfilled()){if(e.updating){if(s=!0,e.suspended||je(e))return;++n,r+=e.updatingProgress}}else++n}));for(const a of[this.graphicsView,this.basemapView,this._resourceController,this._stage,this.featureTiles,this.pointsOfInterest,this.environmentManager,this.overlay,this.featureTreeDebugger,this.toolViewManager,this.analysisViewManager])if(f(a)&&a.updating){const e=.1;n+=e,r+=.5*e}for(const a of[this.deconflictor,this.labeler,this.basemapTerrain])f(a)&&a.updating&&(++n,r+=a.updatingProgress);if(s=!!(s||n>0||this.updatingHandles.updating||!this.ready||!this.stationary||this._createGraphicsViewController||null!=(e=this.inputManager)&&e.hasPendingInputs||null!=(t=this.map)&&null!=(i=t.allLayers)&&i.some((e=>!e.isFulfilled()))),s?(this._numUpdating=Math.max(n,this._numUpdating),r+=this._numUpdating-n):this._numUpdating=0,this._numUpdating>0?r/=this._numUpdating:r=s?0:1,this._get("updatingProgress")!==r){const e=this._resourceController.scheduler.now;if(r<1){const t=Math.min((e-this._lastUpdateTime)/2e3,1);r=this.updatingProgress*(1-t)+r*t}this._set("updatingProgress",r),this._lastUpdateTime=s&&r<1?e:0}return s}get viewingMode(){var e;const t=this._predeterminedViewingMode;if(f(t))return re(t);const i=this.spatialReference;return f(null==(e=this.defaultsFromMap)?void 0:e.viewingMode)&&i&&i.equals(this.defaultsFromMap.spatialReference)?re(this.defaultsFromMap.viewingMode):!i||Xe(i,ie.Global)?"global":"local"}set viewingMode(e){this.ready?it.error("#viewingMode","viewingMode cannot be set once view is ready"):e?this._override("viewingMode",e):void 0===e&&this._clearOverride("viewingMode")}get resourceController(){return this._resourceController}get performanceInfo(){return new Ce(this)}forceAnimationTime(e){this._stage.renderView.forcedAnimationTime=this.basemapTerrain.overlayManager.forcedAnimationTime=e}on(e,t,i,r){const s=this.viewEvents.on(e,t,i,r);return s||super.on(e,t)}hasEventListener(e){return super.hasEventListener(e)||this.viewEvents.hasHandler(e)}toMap(e,t){if(!this.ready)return it.error("#toMap()","Scene view cannot be used before it is ready"),null;const i=t?this.externalToInternalIntersectOptions(t):this._defaultToMapOptions,r=f(i.graphics)&&(f(i.graphics.include)||f(i.graphics.exclude)),s=Qe(e)?$e(this,e):e,n=C(s);i.enableDraped=i.include&&!i.include.has(qe)||i.exclude&&i.exclude.has(qe);const a=this.sceneIntersectionHelper,o=Le(this.state.viewingMode);if(o.options.selectionMode=!0,o.options.store=r?Ue.ALL:Ue.MIN,a.intersectIntersectorScreen(n,o,i),r){for(const e of o.results.all){const t=Fe(e,this);if(m(t))return this._intersectResultToMapPoint(e);if(this._testGraphicUidFilter(i.graphics,t))return this._intersectResultToMapPoint(e)}return null}return this._intersectResultToMapPoint(o.results.min)}toScreen(e){if(!this.ready)return it.error("#toScreen()","Scene view cannot be used before it is ready"),null;const t=y(null==e.z&&be(this.elevationProvider,e),0);return D(e,lt,this.renderSpatialReference,t),this.state.camera.projectToScreen(lt,pt),O(pt[0],pt[1])}pixelSizeAt(e){return this.ready?e?(D(e,lt,this.renderSpatialReference),this.state.camera.computeScreenPixelSizeAt(lt)):0:(it.error("#pixelSizeAt()","Scene view cannot be used before it is ready"),null)}overlayPixelSizeInMapUnits(e){const t=this.basemapTerrain.overlayManager;return t?t.overlayPixelSizeInMapUnits(e):1}hitTest(e,t){if(!this.ready)return it.error("#hitTest()","Scene view cannot be used before it is ready"),null;const i=Qe(e)?$e(this,e):e,r=P(i.x,i.y),s=t?this.externalToInternalIntersectOptions(t):this._defaultHitTestOptions;s.requiresGroundFeedback=!0,s.enableDraped=!0;const n=Le(this.state.viewingMode);n.options.selectionMode=!0,n.options.store=Ue.ALL,this.sceneIntersectionHelper.intersectIntersectorScreen(r,n,s);const a=this._intersectResultsToHits(n.results.all,s.graphics),o=n.results.ground,l=We(o,this),p=f(l)&&"type"in l&&"integrated-mesh"===l.type?l:null,h={screenPoint:i,results:a,ground:{mapPoint:this._intersectResultToMapPoint(o),distance:De(o)?o.distanceInRenderSpace:0,layer:p}};return ve.SCENEVIEW_HITTEST_RETURN_INTERSECTOR&&(h.intersector=n),Promise.resolve(h)}popupHitTest(e){return ze(this,e).then((({results:t,ground:i})=>{let r=null;return!(0===t.length||Math.abs(y(t[0].distance,0)-i.distance)<1e-5)||i.layer&&"integrated-mesh"===i.layer.type||(r=i.mapPoint),{results:t,screenPoint:e,mapPoint:r}}))}goTo(e,t){return this.updatingHandles.addPromise(this.stateManager.goTo(e,t))}async whenAnalysisView(e){if(m(e.parent))throw new o("view:no-analysisview-for-analysis","The analysis has not been added to an AnalysisLayer or SceneView.analyses",{analysis:e});if("analysis"===e.parent.type){return(await this.whenLayerView(e.parent)).whenAnalysisView(e)}return this.analysisViewManager.whenAnalysisView(e)}whenLayerView(e){return super.whenLayerView(e)}takeScreenshot(e){return this.whenReady().then((()=>{const t=Ne(e,this);for(const e of this.map.allLayers.items)"voxel"===e.type&&(t.renderScreenshotTwice=!0);return t.pixelRatio/=this.pixelRatio,this._stage.renderView.takeScreenshot(Be(t,this.supersampleScreenshotsEnabled,this.padding))}))}addUpdatingPromise(e){return this.updatingHandles.addPromise(e)}importLayerView(e){return ne.importLayerView(e)}hasLayerViewModule(e){return ne.hasLayerViewModule(e)}forceDOMReadyCycle(){this.forceReadyCycle()}getDefaultSpatialReference(){var e,t,i,r;return this.map&&"initialViewProperties"in this.map&&(null==(e=this.map)||null==(t=e.initialViewProperties)?void 0:t.spatialReference)||(null==(i=this.defaultsFromMap)?void 0:i.spatialReference)||(null==(r=this.defaultsFromMap)?void 0:r.ready)&&this._initialDefaultSpatialReference||null}async validate(){let e=Ke(this.type);if(d("safari")&&d("safari")<9&&(e=new o("sceneview:browser-not-supported","This browser is not supported by SceneView (Safari < 9)",{type:"safari",requiredVersion:9,detectedVersion:d("safari")})),f(e))throw it.warn("#validate()",e.message),e}get _predeterminedViewingMode(){var e,t;const i=this._isOverridden("viewingMode")?this._get("viewingMode"):null!=(e=this.map&&"initialViewProperties"in this.map?null==(t=this.map.initialViewProperties)?void 0:t.viewingMode:null)?e:null;return f(i)?se(i):null}getSpatialReferenceSupport({spatialReference:e,layer:t}){const i=this._predeterminedViewingMode;if(f(i))return this._validateSpatialReferenceForViewingMode(e,t,i)?{constraints:this._makeSpatialReferenceConstraints(e,t,i)}:null;const r=this._validateSpatialReferenceForViewingMode(e,t,ie.Local),s=this._validateSpatialReferenceForViewingMode(e,t,ie.Global);return r||s?r&&s?{constraints:this._makeSpatialReferenceConstraints(e,t,null)}:r?{constraints:this._makeSpatialReferenceConstraints(e,t,ie.Local)}:{constraints:this._makeSpatialReferenceConstraints(e,t,ie.Global)}:null}_validateSpatialReferenceForViewingMode(e,t,i){return!!Xe(e,i)&&(!!m(t)||(!X(t)||!m(Ie(t,e,i)))&&("voxel"!==t.type||i===ie.Local))}_makeSpatialReferenceConstraints(e,t,i){return t&&!X(t)&&"voxel"!==t.type&&(e.isWebMercator||e.isWGS84)?[{spatialReference:e,viewingMode:i},{spatialReference:e.isWebMercator?et.WGS84:et.WebMercator,viewingMode:i}]:t&&X(t)&&e.isWebMercator&&i!==ie.Global?[{spatialReference:e,viewingMode:i},{spatialReference:et.WGS84,viewingMode:ie.Local}]:[{spatialReference:e,viewingMode:i}]}_validateSpatialReference(e){const t=f(this.getSpatialReferenceSupport({spatialReference:e})),i=this._predeterminedViewingMode;return t||(f(i)?it.warnOnce(`Spatial reference defined on view not supported in ${re(i)} viewing mode.`):e.isGeographic&&it.warnOnce("Spatial reference is geographic but not supported.")),t}whenReady(){return new Promise((e=>{this.ready?e(this):this._resolveWhenReady.push(e)}))}computeMapPointFromVec3d(e,t){let i=this.spatialReference||et.WGS84;return F(e,this.renderSpatialReference,e,i)||(i=et.WGS84,F(e,this.renderSpatialReference,e,i)),t?(t.x=e[0],t.y=e[1],t.z=e[2],t.spatialReference=i):t=new tt(e,i),t}trackGraphicState(e){if(!e.graphic)return it.error("trackGraphicState","GraphicState.graphic must not be null or undefined to start tracking"),null;const t=this.getViewForGraphic(e.graphic);let i=null,r=!1;const s=t=>{!r&&f(t)&&"graphics3d"in t&&t.graphics3d&&t.graphics3d.graphicsCore&&(i=t.graphics3d.graphicsCore.trackGraphicState(e))};return f(t)?s(t):this.whenViewForGraphic(e.graphic,{waitForLayer:!0}).then((e=>s(e)),(()=>{})).catch((()=>{})),{remove:()=>{r=!0,f(i)&&(i.remove(),i=null)}}}highlight(e){if(Array.isArray(e))return p(e.map((e=>this.highlight(e))));if(n.isCollection(e))return p(e.toArray().map((e=>this.highlight(e))));const t=this.getViewForGraphic(e);return t&&"highlight"in t?t.highlight(e):h()}maskOccludee(e){if(!e)return it.error("maskOccludee","GraphicState.graphic must not be null or undefined to mask an occludee"),null;const t=this.getViewForGraphic(e);let i=null,r=!1;const s=t=>{!r&&f(t)&&"graphics3d"in t&&ke(t)&&(i=t.maskOccludee(e))};return f(t)?s(t):this.whenViewForGraphic(e,{waitForLayer:!0}).then((e=>s(e)),(()=>{})).catch((()=>{})),{remove:()=>{r=!0,f(i)&&(i.remove(),i=null)}}}getViewForGraphic(e){return e.layer===this.graphics?this.graphicsView:e.layer?this.allLayerViews.find((t=>t.layer===e.layer)):null}graphicChanged(e){f(this.graphicsView)&&this.graphicsView.graphicChanged(e)}async whenViewForGraphic(e,t){if(e.layer===this)return await S(this,"graphicsView"),this.graphicsView;if(!e.layer||!this.map)throw new o("no-view-for-graphic");return t&&t.waitForLayer&&!this.map.allLayers.includes(e.layer)?new Promise(((t,i)=>{const r=this.map.allLayers.on("change",(s=>{-1!==s.added.indexOf(e.layer)&&(r.remove(),this.whenLayerView(e.layer).then(t,i))}))})):this.whenLayerView(e.layer)}externalToInternalIntersectOptions(e){const t=this._externalToInternalRenderItems(e.include,ot.INCLUDE),i=this._externalToInternalRenderItems(e.exclude,ot.EXCLUDE);return{include:t.layerUids,exclude:i.layerUids,graphics:{include:t.graphicUids,exclude:i.graphicUids}}}_intersectResultToMapPoint(e,t){return e.getIntersectionPoint(lt)?(t=this.computeMapPointFromVec3d(lt,t),e.intersector===Ae.TERRAIN&&this.basemapTerrain&&(t.z=y(be(this.basemapTerrain,t),0)),t):null}_intersectResultsToHits(e,t){const i=new Array;let r=null;for(let s=0;s<e.length;s++){const n=e[s],a=We(n,this);if(f(a)&&(a===this.map.ground||"type"in a&&"integrated-mesh"===a.type))break;const o=Fe(n,this);if(!f(o))continue;if(m(r)&&s!==e.length-1&&(r=new Set),f(r)){const e=this._getGraphicFilterUid(o);if(r.has(e))continue;r.add(e)}if(!this._testGraphicUidFilter(t,o))continue;const l=this._intersectResultToMapPoint(n),p=n.distanceInRenderSpace;i.push({graphic:o,mapPoint:l,distance:p})}return i}_getGraphicFilterUid(e){if(e.layer&&"objectIdField"in e.layer){const t=e.attributes[e.layer.objectIdField];if(t)return`o-${e.layer.id}-${t}`}return`u-${e.uid}`}_testGraphicUidFilter(e,t){const i=this._getGraphicFilterUid(t);return m(e)||(m(e.include)||e.include.has(i))&&(m(e.exclude)||!e.exclude.has(i))}_externalToInternalRenderItems(e,t,s={layerUids:null,graphicUids:null}){if(!e)return s;if(e instanceof i)nt(s,this._getGraphicFilterUid(e)),t===ot.INCLUDE&&(f(this.graphicsView)&&e.layer===this?st(s,this.graphicsView.graphics3d.layer.id):e.layer&&st(s,e.layer.uid));else if(c(e))for(const i of e)i===this.graphics&&f(this.graphicsView)?st(s,this.graphicsView.graphics3d.layer.id):i instanceof r?i===this.map.ground&&st(s,qe):this._externalToInternalRenderItems(i,t,s);else st(s,e.uid);return s}_initBasemapTerrain(){this._set("basemapTerrain",new Ee({view:this})),this._set("elevationProvider",new we({view:this})),this.elevationProvider.register("ground",this.basemapTerrain)}_exitBasemapTerrain(){this.basemapTerrain&&(this.elevationProvider.unregister(this.basemapTerrain),this.elevationProvider.destroy(),this._set("elevationProvider",null),this.basemapTerrain.destroy(),this._set("basemapTerrain",null))}_initGlobe(){this._initCoordinateSystem(),this.state.createInitialCamera(),this._initBasemapTerrain(),this._set("pointsOfInterest",new Pe({view:this})),this._set("featureTiles",new ge({renderCoordsHelper:this.renderCoordsHelper,cameraOnSurface:this.pointsOfInterest.contentCameraOnSurface,focus:this.pointsOfInterest.focus,tilingSchemeOwner:this.basemapTerrain,viewState:this.state,scheduler:this._resourceController.scheduler,terrain:this.basemapTerrain}));const e=()=>{const e=this.basemapTerrain&&this.basemapTerrain.extent;if(this.clippingArea||e)if(e&&this.basemapTerrain.spatialReference){const e=f(this.basemapTerrain.extent)?A(z(this.basemapTerrain.extent,this.basemapTerrain.spatialReference),this.spatialReference):null;f(this.clippingArea)?this.featureTiles.filterExtent=this.clippingArea.intersection(e):this.featureTiles.filterExtent=e}else this.featureTiles.filterExtent=this.clippingArea;else this.featureTiles.filterExtent=null};this.handles.add([this.updatingHandles.add((()=>ve.FEATURE_TILE_TREE_SHOW_TILES),(e=>{e&&this.featureTiles&&!this.featureTreeDebugger?this.updatingHandles.addPromise(import("./3d/layers/support/FeatureTileTree3DDebugger.js")).then((({FeatureTileTree3DDebugger:e})=>{!this.featureTreeDebugger&&ve.FEATURE_TILE_TREE_SHOW_TILES&&(this.featureTreeDebugger=new e({view:this}))})):e||!this.featureTreeDebugger||ve.FEATURE_TILE_TREE_SHOW_TILES||(this.featureTreeDebugger.destroy(),this.featureTreeDebugger=null)}),b),this.updatingHandles.add((()=>this.clippingArea),e,b),this.updatingHandles.add((()=>this.basemapTerrain.extent),e,b)],"feature-tiles"),this.stateManager.init()}_exitGlobe(){this.state&&(this.stateManager.deinit(),this.handles.remove("render-coords-helper"),this.handles.remove("feature-tiles"),this.featureTiles.destroy(),this._set("featureTiles",null),this.pointsOfInterest.destroy(),this._set("pointsOfInterest",null),this._exitBasemapTerrain(),this.state.exit(),this._exitCoordinateSystem())}_initCoordinateSystem(){if(this.spatialReference){const e=this.spatialReference;this.mapCoordsHelper&&this.mapCoordsHelper.spatialReference.equals(e)||this._set("mapCoordsHelper",new Re(this.map,e));const t=this.state.isGlobal,i=B(t,e);i!==this.renderSpatialReference&&(this._set("renderCoordsHelper",Ve.create(this.state.viewingMode,i)),t||this.handles.add(this.watch("basemapTerrain.extent",(e=>{const t=this.renderCoordsHelper.spatialReference;0===e[0]&&0===e[1]&&0===e[2]&&0===e[3]||!W(e,this.basemapTerrain.spatialReference,ht,t)||(this.renderCoordsHelper.extent=ht)}),!0),"render-coords-helper"),this.sceneIntersectionHelper&&this.sceneIntersectionHelper.setTolerance(He/this.renderCoordsHelper.unitInMeters))}else this._set("mapCoordsHelper",null),this._set("renderCoordsHelper",null)}_exitCoordinateSystem(){this.mapCoordsHelper&&(this.handles.remove("render-coords-helper"),this._set("renderCoordsHelper",null),this._set("mapCoordsHelper",null))}_updatingChanged(){this.notifyChange("updating")}_updateUpdatingMonitors(e=null){f(e)&&e.type===w.MOVE||(this.handles.remove("updatingMonitors"),this.allLayerViews.forEach((e=>{e.destroyed||(this.handles.add([e.watch(["updating","updatingProgress"],(()=>this._updatingChanged()),!0)],"updatingMonitors"),e.when((()=>this._updatingChanged()),(()=>this._updatingChanged())))})),this._updatingChanged())}_renderScreenshotOverlay(e,t){if(!this.overlay||!this.overlay.hasVisibleItems)return t;const i=e.getContext("2d");return i.putImageData(t,0,0),this.overlay.renderCanvas(e),i.getImageData(0,0,t.width,t.height)}_initStage(){const e={deactivatedWebGLExtensions:this.deactivatedWebGLExtensions,debugWebGLExtensions:this.debugWebGLExtensions,alpha:this.alphaCompositingEnabled,canvas:this.renderCanvas,screenshot:{renderOverlay:(e,t)=>this._renderScreenshotOverlay(e,t)}},t=new ye(this.state.viewingMode,(e=>this._stage.layers.forAll(e)),this);this._set("sceneIntersectionHelper",t);const i=a(this.surface),{resourceController:r,state:s,renderSpatialReference:n}=this;this._stage=new Ge({options:e,container:i,resourceController:r,state:s,sceneIntersectionHelper:t,renderSR:n}),this._stage.renderView.setRenderParameters({slicePlane:this.slicePlane}),this._lostWebGLContextHandle=l(this._stage.renderView.canvas,"webglcontextlost",(()=>this.fatalError=new o("webgl-context-lost"))),this.handles.add([this.updatingHandles.add((()=>this.qualitySettings.antialiasingEnabled),(()=>this._stage.renderView.setRenderParameters({antialiasingEnabled:this.qualitySettings.antialiasingEnabled})),_),this.updatingHandles.add((()=>this.qualitySettings.highQualityTransparency),(()=>this._stage.renderView.setRenderParameters({highQualityTransparency:this.qualitySettings.highQualityTransparency})),_),x(this,"magnifier",(e=>this._stage.renderView.magnifier=e),!0)],"stage");const p=()=>{this._stage.renderView.setRenderParameters({defaultHighlightOptions:Me.toEngineOptions(this.highlightOptions)})};this.handles.add(this.updatingHandles.add((()=>[this.highlightOptions.color,this.highlightOptions.haloColor,this.highlightOptions.haloOpacity,this.highlightOptions.fillOpacity,this.highlightOptions.shadowOpacity,this.highlightOptions.shadowColor,this.highlightOptions.shadowDifference]),p),"stage"),p(),this.renderCoordsHelper&&this.sceneIntersectionHelper.setTolerance(He/this.renderCoordsHelper.unitInMeters),this._set("canvas",this._stage.renderView.canvas)}_exitStage(){this._set("sceneIntersectionHelper",null),this._stage.destroy(),this._stage=null,this._lostWebGLContextHandle.remove(),this._lostWebGLContextHandle=null,this.handles.remove("stage"),this._set("canvas",null)}_initSurface(e){this._exitSurface(),this.state.init(e,this.spatialReference),this._initStage(),this._initGlobe(),this.sharedSymbolResources=new Oe({view:this,viewingMode:e,resourceController:this._resourceController,pointsOfInterest:this.pointsOfInterest,viewState:this.state,objectResourceCache:new ue})}_exitSurface(){this.sharedSymbolResources&&(this.sharedSymbolResources.objectResourceCache.destroy(),this.sharedSymbolResources.destroy(),this.sharedSymbolResources=null,this._exitGlobe(),this._exitStage())}_createGraphicsViewIfNeeded(){if(this.graphicsView||this._createGraphicsViewController)return;if(0===this.graphics.length)return;this.handles.remove("graphics-view"),this._createGraphicsViewController=new AbortController;const e=()=>{this._createGraphicsViewController=null,this._updatingChanged()};this._createGraphicsViewAsync(this._createGraphicsViewController.signal).then(e,e),this._updatingChanged()}async _createGraphicsViewAsync(e){const t=(await import("./3d/layers/GraphicsView3D.js")).default;v(e),await V(this.basemapTerrain,"ready",e),this._set("graphicsView",new t({view:this}))}_disposeGraphicsView(){this._createGraphicsViewController&&(this._createGraphicsViewController.abort(),this._createGraphicsViewController=null),this.handles.remove("graphics-view"),f(this.graphicsView)&&(this.handles.remove(this.graphicsView.graphics3d.layer.id),this.graphicsView.destroy(),this._set("graphicsView",null))}_startup(){const e=se(this.viewingMode);if(e===ie.Global&&(this._clippingArea=null),this._initSurface(e),this._set("ready",!0),this.handles.add(R(this,"graphics","after-changes",(()=>this._createGraphicsViewIfNeeded())),"graphics-view"),this._createGraphicsViewIfNeeded(),!this._externallySet.environment){const e=this.get("map.initialViewProperties.environment");e&&(this.environment=e)}this.labeler.setup(),this.environmentManager.connectView(this),this.inputManager.connect();const t=this._resolveWhenReady;this._resolveWhenReady=[],t.forEach((e=>e(this)))}_teardown(){this._initialDefaultSpatialReference=null,this.inputManager.disconnect(),this.environmentManager.disconnectView(),this.labeler.dispose(),this._disposeGraphicsView(),this.handles.remove("graphics-view"),this._exitSurface(),this._set("ready",!1)}_updateDefaultToMapOptions(){if(this._defaultToMapOptions.include.clear(),this.map){this.map.ground&&this._defaultToMapOptions.include.add(qe);for(const e of this.map.allLayers.items)"integrated-mesh"===e.type&&this._defaultToMapOptions.include.add(e.uid)}}_updateDefaultHitTestOptions(){if(this._defaultHitTestOptions.exclude.clear(),this.map){this.map.ground&&this.map.ground.opacity<1&&this._defaultHitTestOptions.exclude.add(qe);for(const e of this.map.allLayers.items)"integrated-mesh"===e.type&&e.opacity<1&&this._defaultToMapOptions.exclude.add(e.uid)}}getVoxelWasmPerSceneView(){return $.getInstance().getVoxelWasmPerSceneView(this)}};function st(e,t){e.layerUids||(e.layerUids=new Set),e.layerUids.add(t)}function nt(e,t){e.graphicUids||(e.graphicUids=new Set),e.graphicUids.add(t)}function at(e,t){return f(e)&&U(e.spatialReference,t)?A(e,t):null}var ot;e([E()],rt.prototype,"_userClippingArea",void 0),e([E()],rt.prototype,"_resourceController",void 0),e([E()],rt.prototype,"_stage",void 0),e([E({readOnly:!0})],rt.prototype,"deconflictor",void 0),e([E({readOnly:!0})],rt.prototype,"labeler",void 0),e([E({type:te,readOnly:!0,aliasOf:"state.animation"})],rt.prototype,"animation",void 0),e([E({readOnly:!0})],rt.prototype,"basemapTerrain",void 0),e([E({readOnly:!0})],rt.prototype,"elevationProvider",void 0),e([E({type:t,aliasOf:"stateManager.camera"})],rt.prototype,"camera",void 0),e([E({type:t,aliasOf:"stateManager.contentCamera"})],rt.prototype,"contentCamera",void 0),e([E({readOnly:!0})],rt.prototype,"canvas",void 0),e([E({type:tt,aliasOf:"stateManager.center"})],rt.prototype,"center",void 0),e([E({type:Ye})],rt.prototype,"clippingArea",null),e([E({type:oe})],rt.prototype,"constraints",void 0),e([E({type:Ye,readOnly:!0})],rt.prototype,"renderDataExtent",null),e([E({type:Ye,readOnly:!0})],rt.prototype,"dataExtent",null),e([E({type:Ye,readOnly:!0})],rt.prototype,"groundAndLayersExtent",null),e([E({value:null,type:le})],rt.prototype,"environment",null),e([j("environment")],rt.prototype,"castEnvironment",null),e([E({readOnly:!0})],rt.prototype,"environmentManager",void 0),e([E({type:Ye,aliasOf:"stateManager.extent"})],rt.prototype,"extent",void 0),e([E()],rt.prototype,"floors",void 0),e([E({readOnly:!0,aliasOf:"stateManager.screenCenter"})],rt.prototype,"screenCenter",void 0),e([E({type:Number})],rt.prototype,"pixelRatio",null),e([E({type:Number,dependsOn:["qualitySettings.maximumPixelRatio","qualitySettings.maximumRenderResolution","size"]})],rt.prototype,"maximumPixelRatio",null),e([E({aliasOf:"stateManager.frustum"})],rt.prototype,"frustum",void 0),e([E({type:Number,readOnly:!0})],rt.prototype,"fullOpacity",void 0),e([E({readOnly:!0})],rt.prototype,"graphicsView",void 0),e([E({readOnly:!0})],rt.prototype,"analysisViewManager",void 0),e([E()],rt.prototype,"groundView",void 0),e([E({type:Boolean})],rt.prototype,"initialExtentRequired",null),e([E()],rt.prototype,"_defaultsFromMapSettings",null),e([E({type:Boolean,readOnly:!0})],rt.prototype,"interacting",null),e([E()],rt.prototype,"stationary",null),e([E({aliasOf:"state.navigating"})],rt.prototype,"navigating",void 0),e([E()],rt.prototype,"map",void 0),e([E({readOnly:!0})],rt.prototype,"mapCoordsHelper",void 0),e([E({aliasOf:"stateManager.padding"})],rt.prototype,"padding",void 0),e([E({type:Pe,readOnly:!0})],rt.prototype,"pointsOfInterest",void 0),e([E({type:ge,readOnly:!0})],rt.prototype,"featureTiles",void 0),e([E()],rt.prototype,"featureTreeDebugger",void 0),e([E({type:Boolean})],rt.prototype,"screenSizePerspectiveEnabled",void 0),e([E({constructOnly:!0})],rt.prototype,"deactivatedWebGLExtensions",void 0),e([E({constructOnly:!0})],rt.prototype,"debugWebGLExtensions",void 0),e([E({constructOnly:!0})],rt.prototype,"renderCanvas",void 0),e([E({constructOnly:!0})],rt.prototype,"state",void 0),e([E({readOnly:!0})],rt.prototype,"inputManager",void 0),e([E({readOnly:!0})],rt.prototype,"stateManager",void 0),e([E({type:["low","medium","high"]})],rt.prototype,"qualityProfile",null),e([E({type:xe,get(){let e=this._get("qualitySettings");return e||(e=new xe,_e.apply(this.qualityProfile,e)),e}})],rt.prototype,"qualitySettings",void 0),e([E()],rt.prototype,"slicePlane",null),e([E({readOnly:!0})],rt.prototype,"typeSpecificPreconditionsReady",null),e([E({readOnly:!0})],rt.prototype,"renderCoordsHelper",void 0),e([E({readOnly:!0})],rt.prototype,"sceneIntersectionHelper",void 0),e([E({type:Number,dependsOn:["scale","spatialReference"],readOnly:!0})],rt.prototype,"resolution",null),e([E({type:Number,aliasOf:"stateManager.scale"})],rt.prototype,"scale",void 0),e([E()],rt.prototype,"heightModelInfo",null),e([E()],rt.prototype,"spatialReference",void 0),e([E({type:Boolean,constructOnly:!0})],rt.prototype,"alphaCompositingEnabled",void 0),e([E({type:Boolean})],rt.prototype,"supersampleScreenshotsEnabled",void 0),e([E({readOnly:!0})],rt.prototype,"type",void 0),e([E({type:Ze})],rt.prototype,"ui",void 0),e([E({type:Boolean,readOnly:!0,dependsOn:["graphicsView.updating","basemapView.updating","basemapTerrain.updating","layerViewManager.updating","layerViewManager.updatingRemaining","_resourceController.updating","_stage.updating","featureTiles.updating","pointsOfInterest.updating","environmentManager.updating","overlay.updating","updatingHandles.updating","featureTreeDebugger.updating","labeler.updating","deconflictor.updating","ready","stationary","inputManager.hasPendingInputs","toolViewManager.updating","analysisViewManager.updating"]})],rt.prototype,"updating",null),e([E({type:Number,readOnly:!0,dependsOn:["updating"]})],rt.prototype,"updatingProgress",void 0),e([E({type:["global","local"]})],rt.prototype,"viewingMode",null),e([E({type:s,aliasOf:"stateManager.viewpoint"})],rt.prototype,"viewpoint",void 0),e([E({type:Number,aliasOf:"stateManager.zoom"})],rt.prototype,"zoom",void 0),e([E({type:Me})],rt.prototype,"highlightOptions",void 0),rt=e([I("esri.views.SceneView")],rt),function(e){e[e.INCLUDE=0]="INCLUDE",e[e.EXCLUDE=1]="EXCLUDE"}(ot||(ot={}));const lt=L(),pt=P(),ht=q(),dt=rt;export{dt as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.23/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../core/Accessor.js";import a from"../../core/Handles.js";import i from"../../core/Logger.js";import{destroyMaybe as n,abortMaybe as s,isSome as l,unwrap as r,isNone as o}from"../../core/maybe.js";import{createTask as p,whenOrAbort as d,isAborted as u}from"../../core/promiseUtils.js";import{property as c}from"../../core/accessorSupport/decorators/property.js";import"../../core/arrayUtils.js";import"../../core/has.js";import"../../core/accessorSupport/ensureType.js";import{subclass as f}from"../../core/accessorSupport/decorators/subclass.js";import{project as h,canProjectWithoutEngine as g,isLoaded as y}from"../../geometry/projection.js";import{mayHaveHeightModelInfo as _,deriveHeightModelInfoFromLayer as k}from"../../geometry/support/heightModelInfoUtils.js";import{stringFromViewingMode as v}from"../ViewingMode.js";const R=10,m=i.getLogger("esri.views.support.DefaultsFromMap");m.level="info";let x=class extends t{constructor(e){super(e),this._handles=new a,this.required={tileInfo:!1,heightModelInfo:!1,extent:!1},this.defaultSpatialReference=null,this.userSpatialReference=null,this.priorityCollection=null,this.logDebugInformation=!1,this.suspended=!1,this._projectExtentTask={task:null,input:null,output:null,spatialReference:null}}destroy(){this._handles=n(this._handles),this._projectExtentTask.task&&(this._debug("Aborting project extent task"),this._projectExtentTask.task=s(this._projectExtentTask.task)),this._set("map",null)}get ready(){return!this._spatialReferenceTask.updating&&!this._tileInfoTask.updating&&!this._extentTask.updating}get heightModelInfoReady(){return!this._heightModelInfoTask.updating}get spatialReference(){return l(this.userSpatialReference)?this.userSpatialReference:r(this._spatialReferenceTask.spatialReference)}get extent(){return r(this._extentTask.extent)}get heightModelInfo(){return r(this._heightModelInfoTask.heightModelInfo)}get vcsWkid(){return r(this._heightModelInfoTask.vcsWkid)}get latestVcsWkid(){return r(this._heightModelInfoTask.latestVcsWkid)}get viewingMode(){return o(this.userSpatialReference)||this.userSpatialReference.equals(r(this._spatialReferenceTask.spatialReference))?r(this._spatialReferenceTask.viewingMode):null}get tileInfo(){return r(this._tileInfoTask.tileInfo)}get mapCollections(){var e,t,a,i;const n=null==(e=this.map)?void 0:e.call(this),s=[];return l(this.priorityCollection)&&s.push(this.priorityCollection),s.push({parent:null==n?void 0:n.basemap,layers:null==n||null==(t=n.basemap)?void 0:t.baseLayers},{layers:null==n?void 0:n.layers},{parent:null==n?void 0:n.ground,layers:null==n||null==(a=n.ground)?void 0:a.layers},{parent:null==n?void 0:n.basemap,layers:null==n||null==(i=n.basemap)?void 0:i.referenceLayers}),s}get _allLayers(){var e,t;const a=this._collectLayers(this.mapCollections);return this._debug("Collected",null!=(e=null==(t=a.layers)?void 0:t.length)?e:0,"layers, updating",a.updating),a}get _spatialReferenceTask(){var e,t;if(this.suspended)return null!=(t=this._get("_spatialReferenceTask"))?t:{updating:!1};const{layers:a,updating:i}=this._allLayers,n={candidates:null};for(const l of a)if(this._processSpatialReferenceCandidates(l,n),n.candidates&&1===n.candidates.length)break;if(1!==(null==(e=n.candidates)?void 0:e.length)&&i)return{updating:!0};const s=this._pickSpatialReferenceCandidate(n.candidates);return this._debug("Finished spatial reference",l(s)?`${s.spatialReference.wkid}:${l(s.viewingMode)?v(s.viewingMode):"global/local"}`:"none available"),{spatialReference:l(s)?s.spatialReference:null,viewingMode:l(s)?s.viewingMode:null,updating:!1}}get _tileInfoTask(){var e,t,a,i,n,s,l,r;if(!this.required.tileInfo)return null!=(r=this._get("_tileInfoTask"))?r:{updating:!1};if(!this.spatialReference)return{updating:this._spatialReferenceTask.updating};const{layers:o,updating:p}=this._collectLayers([{parent:null==(e=this.map)||null==(t=e.call(this))?void 0:t.basemap,layers:null==(a=this.map)||null==(i=a.call(this))||null==(n=i.basemap)?void 0:n.baseLayers},{layers:null==(s=this.map)||null==(l=s.call(this))?void 0:l.layers}]);if(o&&o.length>0&&"tileInfo"in o[0]){const e=o[0].tileInfo;return{tileInfo:e&&e.spatialReference.equals(this.spatialReference)?e:null,updating:!1}}return{updating:p}}get _heightModelInfoTask(){var e,t;if(!this.required.heightModelInfo||this.suspended&&null!=(e=this._get("_heightModelInfoTask"))&&e.heightModelInfo)return null!=(t=this._get("_heightModelInfoTask"))?t:{updating:!1};const{layers:a,updating:i}=this._allLayers;for(const o of a){var n,s;if(this._debug("Considering",null!=(n=null!=(s=o.title)?s:o.id)?n:o.declaredClass,"for height model info"),_(o)){const e=k(o);var l,r;if(e)return this._debug("Derived height model info",e),{heightModelInfo:e,vcsWkid:null==(l=o.spatialReference)?void 0:l.vcsWkid,latestVcsWkid:null==(r=o.spatialReference)?void 0:r.latestVcsWkid,updating:!1}}this._debug("Layer does not support height models")}return this._debug("No height model info found,","updating",i),{updating:i}}get _extentCandidatesTask(){var e;if(this.suspended||!this.required.extent)return null!=(e=this._get("_extentCandidatesTask"))?e:{updating:!1};if(!this.spatialReference)return{updating:this._spatialReferenceTask.updating};const t=this._allLayers,a=t.updating,i=[];for(const n of t.layers){const e="fullExtents"in n&&n.fullExtents||(l(n.fullExtent)?[n.fullExtent]:[]),t=e.find((e=>e.spatialReference.equals(this.spatialReference)));if(t)return{candidates:[{extent:t,layer:n}],updating:!1};if(this._getSupportedSpatialReferences(n).length>0)for(const a of e)i.push({extent:a,layer:n})}return{candidates:i,updating:a}}get _extentTask(){const{candidates:e,updating:t}=this._extentCandidatesTask;if(t)return{updating:t};if(o(e)||0===e.length)return{updating:!1};if(!this.spatialReference)return{updating:this._spatialReferenceTask.updating};const{candidate:a,requiresGeometryService:i}=this._pickExtentCandidate(e),n=this.spatialReference;if(a.extent.equals(this._projectExtentTask.input)&&n.equals(this._projectExtentTask.spatialReference))return{extent:this._projectExtentTask.output,updating:l(this._projectExtentTask.task)&&!this._projectExtentTask.task.finished};if(l(this._projectExtentTask.task)&&(this._debug("Aborting project extent task"),this._projectExtentTask.task=s(this._projectExtentTask.task)),!i){this._projectExtentTask={input:null,output:null,task:null,spatialReference:null};try{return{extent:h(a.extent,n),updating:!1}}catch{return{updating:!1}}}return this._debug("Starting project extent task for",a.extent),this._projectExtentTask={input:a.extent.clone(),output:null,spatialReference:n.clone(),task:p((async e=>{try{const t=await d(import("../../portal/support/geometryServiceUtils.js"),e),i=await t.projectGeometry(a.extent,n,a.layer.portalItem,e);this._debug("Project extent task finished",i),this._projectExtentTask={...this._projectExtentTask,task:null,output:i}}catch(t){if(u(e))return;this._projectExtentTask={...this._projectExtentTask,task:null}}}))},{updating:!0}}_processSpatialReferenceCandidates(e,t){var a;const i=this._getSupportedSpatialReferences(e);if(0!==i.length)if(this._debug("Spatial reference candidates from",null!=(a=e.title)?a:e.id,":",i.map((e=>`${e.spatialReference.wkid}:${l(e.viewingMode)?v(e.viewingMode):"global/local"}`)).join(", ")),t.candidates){const e=[],a=(e,t)=>o(e.viewingMode)?t.viewingMode:(o(t.viewingMode)||e.viewingMode===t.viewingMode)&&e.viewingMode;for(const n of t.candidates)for(const t of i){if(!n.spatialReference.equals(t.spatialReference))continue;const i=a(n,t);if(!1!==i){e.push({spatialReference:n.spatialReference,viewingMode:i});break}}e.length>0&&(t.candidates=e)}else t.candidates=i}_pickSpatialReferenceCandidate(e){const t=this.defaultSpatialReference;return!e||e.length<1?l(t)?{spatialReference:t,viewingMode:null}:null:l(t)&&e.length>1&&e.some((({spatialReference:e})=>e.equals(t)))?{spatialReference:t,viewingMode:null}:e[0]}_getSupportedSpatialReferences(e){const t="supportedSpatialReferences"in e&&e.supportedSpatialReferences||(e.spatialReference?[e.spatialReference]:[]);if(0===t.length)return[];const a=[];for(const i of t){const t=this.getSpatialReferenceSupport({spatialReference:i,layer:e});if(l(t)){const e=l(t.constraints)?t.constraints:[{spatialReference:i}];for(const{spatialReference:t,viewingMode:i}of e)(o(this.userSpatialReference)||t.equals(this.userSpatialReference))&&a.push({spatialReference:t,viewingMode:i})}}return a}_pickExtentCandidate(e){const t=this.spatialReference,a=e.find((({extent:e})=>g(e.spatialReference,t)||y()));return l(a)?{candidate:a,requiresGeometryService:!1}:{candidate:e[0],requiresGeometryService:!0}}_collectLayers(e){var t;if("loaded"!==this._loadMaybe(null==(t=this.map)?void 0:t.call(this)))return{layers:[],updating:!0};const a={layers:[],preloading:-1,updating:!1};for(const i of e)if(this._collectCollection(i,a),a.preloading===R)break;return{layers:a.layers,updating:a.updating}}_collectCollection(e,t){if(e.layers){switch(this._loadMaybe(e.parent)){case"loading":return t.updating=!0,void++t.preloading;case"failed":return}for(const n of e.layers){switch(this._loadMaybe(n)){case"failed":continue;case"loading":t.updating=!0,++t.preloading;break;case"loaded":var a,i;if(!t.updating)this._debug("Considering layer",null!=(a=null!=(i=n.title)?i:n.id)?a:n.declaredClass),t.layers.push(n);"layers"in n&&this._collectCollection({layers:n.layers},t)}if(t.preloading===R)break}}}_loadMaybe(e){return e&&"loadStatus"in e?"not-loaded"===e.loadStatus?(this._debug("Triggering load",null!=(t=null!=(a=e.title)?a:e.id)?t:e.declaredClass),e.load(),"loading"):e.loadStatus:"loaded";var t,a}_debug(...e){this.logDebugInformation&&m.info(...e)}};e([c()],x.prototype,"required",void 0),e([c({constructOnly:!0})],x.prototype,"map",void 0),e([c({constructOnly:!0})],x.prototype,"getSpatialReferenceSupport",void 0),e([c()],x.prototype,"defaultSpatialReference",void 0),e([c()],x.prototype,"userSpatialReference",void 0),e([c()],x.prototype,"priorityCollection",void 0),e([c()],x.prototype,"logDebugInformation",void 0),e([c()],x.prototype,"suspended",void 0),e([c({readOnly:!0})],x.prototype,"ready",null),e([c({readOnly:!0})],x.prototype,"heightModelInfoReady",null),e([c({readOnly:!0})],x.prototype,"spatialReference",null),e([c({readOnly:!0})],x.prototype,"extent",null),e([c({readOnly:!0})],x.prototype,"heightModelInfo",null),e([c({readOnly:!0})],x.prototype,"vcsWkid",null),e([c({readOnly:!0})],x.prototype,"latestVcsWkid",null),e([c({readOnly:!0})],x.prototype,"viewingMode",null),e([c({readOnly:!0})],x.prototype,"tileInfo",null),e([c({readOnly:!0})],x.prototype,"mapCollections",null),e([c({readOnly:!0})],x.prototype,"_allLayers",null),e([c({readOnly:!0})],x.prototype,"_spatialReferenceTask",null),e([c({readOnly:!0})],x.prototype,"_tileInfoTask",null),e([c({readOnly:!0})],x.prototype,"_heightModelInfoTask",null),e([c({readOnly:!0})],x.prototype,"_extentCandidatesTask",null),e([c()],x.prototype,"_extentTask",null),e([c()],x.prototype,"_projectExtentTask",void 0),x=e([f("esri.views.support.DefaultsFromMap")],x);const T=x;export{T as default};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../core/Accessor.js";import a from"../../core/Handles.js";import i from"../../core/Logger.js";import{destroyMaybe as n,abortMaybe as s,isSome as l,unwrap as r,isNone as o}from"../../core/maybe.js";import{createTask as p,whenOrAbort as d,isAborted as u}from"../../core/promiseUtils.js";import{property as c}from"../../core/accessorSupport/decorators/property.js";import"../../core/arrayUtils.js";import"../../core/has.js";import"../../core/accessorSupport/ensureType.js";import{subclass as f}from"../../core/accessorSupport/decorators/subclass.js";import{project as h,canProjectWithoutEngine as g,isLoaded as y}from"../../geometry/projection.js";import{mayHaveHeightModelInfo as _,deriveHeightModelInfoFromLayer as k}from"../../geometry/support/heightModelInfoUtils.js";import{stringFromViewingMode as v,ViewingMode as R}from"../ViewingMode.js";const m=10,x=i.getLogger("esri.views.support.DefaultsFromMap");x.level="info";let T=class extends t{constructor(e){super(e),this._handles=new a,this.required={tileInfo:!1,heightModelInfo:!1,extent:!1},this.defaultSpatialReference=null,this.userSpatialReference=null,this.priorityCollection=null,this.logDebugInformation=!1,this.suspended=!1,this._projectExtentTask={task:null,input:null,output:null,spatialReference:null}}destroy(){this._handles=n(this._handles),this._projectExtentTask.task&&(this._debug("Aborting project extent task"),this._projectExtentTask.task=s(this._projectExtentTask.task)),this._set("map",null)}get ready(){return!this._spatialReferenceTask.updating&&!this._tileInfoTask.updating&&!this._extentTask.updating}get heightModelInfoReady(){return!this._heightModelInfoTask.updating}get spatialReference(){return l(this.userSpatialReference)?this.userSpatialReference:r(this._spatialReferenceTask.spatialReference)}get extent(){return r(this._extentTask.extent)}get heightModelInfo(){return r(this._heightModelInfoTask.heightModelInfo)}get vcsWkid(){return r(this._heightModelInfoTask.vcsWkid)}get latestVcsWkid(){return r(this._heightModelInfoTask.latestVcsWkid)}get viewingMode(){return o(this.userSpatialReference)||this.userSpatialReference.equals(r(this._spatialReferenceTask.spatialReference))?r(this._spatialReferenceTask.viewingMode):null}get tileInfo(){return r(this._tileInfoTask.tileInfo)}get mapCollections(){var e,t,a,i;const n=null==(e=this.map)?void 0:e.call(this),s=[];return l(this.priorityCollection)&&s.push(this.priorityCollection),s.push({parent:null==n?void 0:n.basemap,layers:null==n||null==(t=n.basemap)?void 0:t.baseLayers},{layers:null==n?void 0:n.layers},{parent:null==n?void 0:n.ground,layers:null==n||null==(a=n.ground)?void 0:a.layers},{parent:null==n?void 0:n.basemap,layers:null==n||null==(i=n.basemap)?void 0:i.referenceLayers}),s}get _allLayers(){var e,t;const a=this._collectLayers(this.mapCollections);return this._debug("Collected",null!=(e=null==(t=a.layers)?void 0:t.length)?e:0,"layers, updating",a.updating),a}get _spatialReferenceTask(){var e,t;if(this.suspended)return null!=(t=this._get("_spatialReferenceTask"))?t:{updating:!1};const{layers:a,updating:i}=this._allLayers,n={candidates:null};for(const l of a)if(this._processSpatialReferenceCandidates(l,n),n.candidates&&1===n.candidates.length)break;if(1!==(null==(e=n.candidates)?void 0:e.length)&&i)return{updating:!0};const s=this._pickSpatialReferenceCandidate(n.candidates);return this._debug("Finished spatial reference",l(s)?`${s.spatialReference.wkid}:${l(s.viewingMode)?v(s.viewingMode):"global/local"}`:"none available"),{spatialReference:l(s)?s.spatialReference:null,viewingMode:l(s)?s.viewingMode:null,updating:!1}}get _tileInfoTask(){var e,t,a,i,n,s,l,r;if(!this.required.tileInfo)return null!=(r=this._get("_tileInfoTask"))?r:{updating:!1};if(!this.spatialReference)return{updating:this._spatialReferenceTask.updating};const{layers:o,updating:p}=this._collectLayers([{parent:null==(e=this.map)||null==(t=e.call(this))?void 0:t.basemap,layers:null==(a=this.map)||null==(i=a.call(this))||null==(n=i.basemap)?void 0:n.baseLayers},{layers:null==(s=this.map)||null==(l=s.call(this))?void 0:l.layers}]);if(o&&o.length>0&&"tileInfo"in o[0]){const e=o[0].tileInfo;return{tileInfo:e&&e.spatialReference.equals(this.spatialReference)?e:null,updating:!1}}return{updating:p}}get _heightModelInfoTask(){var e,t;if(!this.required.heightModelInfo||this.suspended&&null!=(e=this._get("_heightModelInfoTask"))&&e.heightModelInfo)return null!=(t=this._get("_heightModelInfoTask"))?t:{updating:!1};const{layers:a,updating:i}=this._allLayers;for(const o of a){var n,s;if(this._debug("Considering",null!=(n=null!=(s=o.title)?s:o.id)?n:o.declaredClass,"for height model info"),_(o)){const e=k(o);var l,r;if(e)return this._debug("Derived height model info",e),{heightModelInfo:e,vcsWkid:null==(l=o.spatialReference)?void 0:l.vcsWkid,latestVcsWkid:null==(r=o.spatialReference)?void 0:r.latestVcsWkid,updating:!1}}this._debug("Layer does not support height models")}return this._debug("No height model info found,","updating",i),{updating:i}}get _extentCandidatesTask(){var e;if(this.suspended||!this.required.extent)return null!=(e=this._get("_extentCandidatesTask"))?e:{updating:!1};if(!this.spatialReference)return{updating:this._spatialReferenceTask.updating};const t=this._allLayers,a=t.updating,i=[];for(const n of t.layers){const e="fullExtents"in n&&n.fullExtents||(l(n.fullExtent)?[n.fullExtent]:[]),t=e.find((e=>e.spatialReference.equals(this.spatialReference)));if(t)return{candidates:[{extent:t,layer:n}],updating:!1};if(this._getSupportedSpatialReferences(n).length>0)for(const a of e)i.push({extent:a,layer:n})}return{candidates:i,updating:a}}get _extentTask(){const{candidates:e,updating:t}=this._extentCandidatesTask;if(t)return{updating:t};if(o(e)||0===e.length)return{updating:!1};if(!this.spatialReference)return{updating:this._spatialReferenceTask.updating};const{candidate:a,requiresGeometryService:i}=this._pickExtentCandidate(e),n=this.spatialReference;if(a.extent.equals(this._projectExtentTask.input)&&n.equals(this._projectExtentTask.spatialReference))return{extent:this._projectExtentTask.output,updating:l(this._projectExtentTask.task)&&!this._projectExtentTask.task.finished};if(l(this._projectExtentTask.task)&&(this._debug("Aborting project extent task"),this._projectExtentTask.task=s(this._projectExtentTask.task)),!i){this._projectExtentTask={input:null,output:null,task:null,spatialReference:null};try{return{extent:h(a.extent,n),updating:!1}}catch{return{updating:!1}}}return this._debug("Starting project extent task for",a.extent),this._projectExtentTask={input:a.extent.clone(),output:null,spatialReference:n.clone(),task:p((async e=>{try{const t=await d(import("../../portal/support/geometryServiceUtils.js"),e),i=await t.projectGeometry(a.extent,n,a.layer.portalItem,e);this._debug("Project extent task finished",i),this._projectExtentTask={...this._projectExtentTask,task:null,output:i}}catch(t){if(u(e))return;this._projectExtentTask={...this._projectExtentTask,task:null}}}))},{updating:!0}}_processSpatialReferenceCandidates(e,t){var a;const i=this._getSupportedSpatialReferences(e);if(0!==i.length)if(this._debug("Spatial reference candidates from",null!=(a=e.title)?a:e.id,":",i.map((e=>`${e.spatialReference.wkid}:${l(e.viewingMode)?v(e.viewingMode):"global/local"}`)).join(", ")),t.candidates){const e=[],a=(e,t)=>o(e.viewingMode)?t.viewingMode:(o(t.viewingMode)||e.viewingMode===t.viewingMode)&&e.viewingMode;for(const n of t.candidates)for(const t of i){if(!n.spatialReference.equals(t.spatialReference))continue;const i=a(n,t);if(!1!==i){e.push({spatialReference:n.spatialReference,viewingMode:i});break}}e.length>0&&(t.candidates=e)}else t.candidates=i}_pickSpatialReferenceCandidate(e){const t=this.defaultSpatialReference;return!e||e.length<1?l(t)?{spatialReference:t,viewingMode:null}:null:(l(t)&&e.length>1&&e.some((({spatialReference:e})=>e.equals(t)))&&(e=e.filter((({spatialReference:e})=>e.equals(t)))),e.length>1&&e.some((({viewingMode:e})=>e!==R.Local))&&(e=e.filter((({viewingMode:e})=>e!==R.Local))),e[0])}_getSupportedSpatialReferences(e){const t="supportedSpatialReferences"in e&&e.supportedSpatialReferences||(e.spatialReference?[e.spatialReference]:[]);if(0===t.length)return[];const a=[];for(const i of t){const t=this.getSpatialReferenceSupport({spatialReference:i,layer:e});if(l(t)){const e=l(t.constraints)?t.constraints:[{spatialReference:i}];for(const{spatialReference:t,viewingMode:i}of e)(o(this.userSpatialReference)||t.equals(this.userSpatialReference))&&a.push({spatialReference:t,viewingMode:i})}}return a}_pickExtentCandidate(e){const t=this.spatialReference,a=e.find((({extent:e})=>g(e.spatialReference,t)||y()));return l(a)?{candidate:a,requiresGeometryService:!1}:{candidate:e[0],requiresGeometryService:!0}}_collectLayers(e){var t;if("loaded"!==this._loadMaybe(null==(t=this.map)?void 0:t.call(this)))return{layers:[],updating:!0};const a={layers:[],preloading:-1,updating:!1};for(const i of e)if(this._collectCollection(i,a),a.preloading===m)break;return{layers:a.layers,updating:a.updating}}_collectCollection(e,t){if(e.layers){switch(this._loadMaybe(e.parent)){case"loading":return t.updating=!0,void++t.preloading;case"failed":return}for(const n of e.layers){switch(this._loadMaybe(n)){case"failed":continue;case"loading":t.updating=!0,++t.preloading;break;case"loaded":var a,i;if(!t.updating)this._debug("Considering layer",null!=(a=null!=(i=n.title)?i:n.id)?a:n.declaredClass),t.layers.push(n);"layers"in n&&this._collectCollection({layers:n.layers},t)}if(t.preloading===m)break}}}_loadMaybe(e){return e&&"loadStatus"in e?"not-loaded"===e.loadStatus?(this._debug("Triggering load",null!=(t=null!=(a=e.title)?a:e.id)?t:e.declaredClass),e.load(),"loading"):e.loadStatus:"loaded";var t,a}_debug(...e){this.logDebugInformation&&x.info(...e)}};e([c()],T.prototype,"required",void 0),e([c({constructOnly:!0})],T.prototype,"map",void 0),e([c({constructOnly:!0})],T.prototype,"getSpatialReferenceSupport",void 0),e([c()],T.prototype,"defaultSpatialReference",void 0),e([c()],T.prototype,"userSpatialReference",void 0),e([c()],T.prototype,"priorityCollection",void 0),e([c()],T.prototype,"logDebugInformation",void 0),e([c()],T.prototype,"suspended",void 0),e([c({readOnly:!0})],T.prototype,"ready",null),e([c({readOnly:!0})],T.prototype,"heightModelInfoReady",null),e([c({readOnly:!0})],T.prototype,"spatialReference",null),e([c({readOnly:!0})],T.prototype,"extent",null),e([c({readOnly:!0})],T.prototype,"heightModelInfo",null),e([c({readOnly:!0})],T.prototype,"vcsWkid",null),e([c({readOnly:!0})],T.prototype,"latestVcsWkid",null),e([c({readOnly:!0})],T.prototype,"viewingMode",null),e([c({readOnly:!0})],T.prototype,"tileInfo",null),e([c({readOnly:!0})],T.prototype,"mapCollections",null),e([c({readOnly:!0})],T.prototype,"_allLayers",null),e([c({readOnly:!0})],T.prototype,"_spatialReferenceTask",null),e([c({readOnly:!0})],T.prototype,"_tileInfoTask",null),e([c({readOnly:!0})],T.prototype,"_heightModelInfoTask",null),e([c({readOnly:!0})],T.prototype,"_extentCandidatesTask",null),e([c()],T.prototype,"_extentTask",null),e([c()],T.prototype,"_projectExtentTask",void 0),T=e([f("esri.views.support.DefaultsFromMap")],T);const M=T;export{M as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.23/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../Graphic.js";import"../../core/has.js";import{isSome as t,isNone as r,removeMaybe as i}from"../../core/maybe.js";import{whenOrAbort as a,eachAlways as n}from"../../core/promiseUtils.js";import{px2pt as s}from"../../core/screenUtils.js";import{init as o,whenFalseOnce as l}from"../../core/watchUtils.js";import{diff as c}from"../../core/accessorSupport/diffUtils.js";import{calculateTolerance as u}from"../../renderers/support/clickToleranceUtils.js";import{meterIn as p}from"../../renderers/support/lengthUtils.js";import{getTransformationType as y,TransformationType as f}from"../../renderers/visualVariables/support/sizeVariableUtils.js";import{getRotationAngle as d,getSize as m}from"../../renderers/visualVariables/support/visualVariableUtils.js";import{to3D as h}from"../../symbols/support/symbolConversion.js";import{getDisplayedSymbol as g}from"../../symbols/support/symbolUtils.js";import{GraphicState as b}from"../../views/3d/layers/graphics/GraphicState.js";import{createQueryGeometry as w}from"../../views/support/drapedUtils.js";import{hitTestSelectSameDistance as v}from"../../views/support/hitTestSelectUtils.js";function S(e){const r=e.sourceLayer;if("feature"!==r.type||!F(r.renderer))return{rotation:null,size:null};let i=null,a=null;const n=r.renderer.getVisualVariablesForType("rotation").filter((r=>(!r.axis||"heading"===r.axis)&&r.field&&!r.valueExpression&&t(d(r,e))));1===n.length&&(i=j(n[0],r));const s=r.renderer.getVisualVariablesForType("size").filter((r=>r.field&&!r.useSymbolValue&&!r.valueExpression&&y(r)===f.RealWorldSize&&t(m(r,e))));return 1===s.length&&(a=U(s[0],r)),{rotation:i,size:a}}function j(e,t){const r="heading"===(e.axis||"heading")&&"arithmetic"===e.rotationType?-1:1,i=e.field,a=t.fields&&t.fields.filter((e=>e.name===i)),n=a&&1===a.length?a[0].type:"double",s={initial:0,current:0};return{field:i,getDefault:()=>Promise.resolve(0),getValue:e=>(s.current=s.initial-r*e,z((s.current+360)%360,n)),initValue:e=>{s.initial=null!=e?e:s.current,s.current=0},isUpdatingInteractively:!1}}function I(e,t){switch(t){case"width":return e[0];case"depth":return e[1];case"height":return e[2];default:return e[2]||e[1]||e[0]}}async function V(e,t,i){if(r(t))return 0;const{symbol:a}=h(t);if(r(a)||"web-style"===a.type||"cim"===a.type)return 0;const n=a.symbolLayers.getItemAt(0);if(!n)return 0;switch(n.type){case"icon":{const{computeIconLayerResourceSize:e}=await import("../../symbols/support/symbolLayerUtils.js");return n.size||Math.min(B.icon,(await e(n,B.icon))[0])||B.icon}case"text":return n.size||B.text;case"line":return n.size||B.line;case"object":{const{computeObjectLayerResourceSize:t}=await import("../../symbols/support/symbolLayerUtils.js");return I(await t(n,e.scale/B.viewScaleSizeFactor),i)}case"path":return(null!=n.width?n.width:n.height)||e.scale/B.viewScaleSizeFactor;case"extrude":return n.size||e.scale/B.viewScaleSizeFactor;default:return 0}}function U(e,t){const r=e.field,i=e.axis,a=t.fields&&t.fields.filter((e=>e.name===r)),n=a&&1===a.length?a[0].type:"double",s={updating:!1,initial:0,current:0},o=p[e.valueUnit];let l;return l="area"===e.valueRepresentation?e=>(e*o/2)**2*Math.PI:"radius"===e.valueRepresentation||"distance"===e.valueRepresentation?e=>e*o/2:e=>e*o,{field:r,getDefault:async(e,t)=>z(l(await V(t,e,i)),n),getValue:(e,t)=>(s.initial||(s.initial=t.pixelSizeAt(t.center)),s.current=s.initial*e,z(s.current,n)),initValue:e=>{s.initial=null!=e?e:s.current,s.current=0},isUpdatingInteractively:!1}}function z(e,t){switch(t){case"small-integer":case"integer":case"long":return Math.round(e);case"double":case"single":return e;default:return 0}}function F(e){switch(e.type){case"class-breaks":case"simple":case"unique-value":case"dot-density":case"dictionary":return!0;default:return!1}}async function L(e){const r=await g(e,{useSourceLayer:!0,ignoreGraphicSymbol:!0}),i=c(e.symbol,r);t(i)&&(e.symbol=r)}function x(e){if("mesh"===e||"multipatch"===e)throw new Error("Mesh and Multipatch not supported");return e}async function M(e,t,r){await R(e,t);const i=e.on("create",(async i=>{if("cancel"===i.state)return R(e,t);if("complete"===i.state){const e=i.graphic;e.sourceLayer||(e.sourceLayer=t.layer),e.attributes||(e.attributes={...t.template.prototype.attributes}),await L(e),r(e)}}));return{remove:()=>{i.remove(),e.cancel()}}}async function R(e,t){const r=t.layer,i={...t.template.prototype.attributes};await T(e,r,i);const a={graphicProperties:{attributes:i,sourceLayer:r},hasZ:r.capabilities.data.supportsZ};return e.layer.elevationInfo=r.elevationInfo,e.create(x(r.geometryType),a)}async function T(t,i,a){var n;const s=new e({sourceLayer:i,attributes:a}),{rotation:o,size:l}=S(s);let c=await g(s,{useSourceLayer:!0}),u=!1;for(const e of[l,o]){if(r(e))continue;null==a[e.field]&&(a[e.field]=await e.getDefault(c,t.view),u=!0)}switch(u&&(c=await g(s,{useSourceLayer:!0})),null==(n=c)?void 0:n.type){case"simple-fill":case"polygon-3d":t.polygonSymbol=c;break;case"simple-line":case"line-3d":t.polylineSymbol=c;break;case"simple-marker":case"picture-marker":case"point-3d":t.pointSymbol=c}}function E(e,t){return e&&e.find((e=>e.layer===t))}async function k(e,t,r,i){if(0===e.length)return[];const{updatable:s,graphicsByLayer:o}=await r.async((async()=>{const{results:n}=await a(v(t,r),i),s=new Map,o=({layer:e})=>{const t=s.get(e);if(!t){const t=new Array;return s.set(e,t),t}return t};n.forEach((({graphic:e})=>o(e).push(e)));const l=e.filter((({supports:e,layer:t})=>e.indexOf("update")>-1&&s.has(t)));return 0!==l.length&&r.stopPropagation(),{updatable:l,graphicsByLayer:s}}));return a(n(s.map((async({layer:e})=>{const{objectIdField:t,displayField:r}=e,a=[t];e.fieldsIndex.has(r)&&a.push(r);const n=o.get(e);if(!!n.some((e=>a.some((t=>!(t in e.attributes)))))){const t=e.createQuery();return t.outFields=a,t.returnGeometry=!1,t.objectIds=n.map((e=>e.getObjectId())),e.queryFeatures(t,{signal:i}).then((({features:e})=>e))}return n}))),i)}async function A(e,t,r,i){if(0===e.length)return[];const s=await r.async((async()=>{const{results:n}=await a(t.hitTest(r),i);if(0===n.length)return[];const s=new Set;n.forEach((({graphic:e})=>s.add(e.layer)));const o=e.items.filter((({layer:e,supports:t})=>t.indexOf("update")>-1&&s.has(e)));return o.length>0&&r.stopPropagation(),o}));return a(n(s.map((({layer:e})=>{const{objectIdField:a,displayField:n}=e,s=[a];e.fieldsIndex.has(n)&&s.push(n);const o=e.createQuery();o.outFields=s,o.returnGeometry=!1;const l="renderer"in e?u({renderer:e.renderer,event:r}):0;return o.geometry=w(r.mapPoint,l,t),o.outSpatialReference=t.spatialReference,e.queryFeatures(o,{signal:i}).then((({features:e})=>e))}))),i)}async function G(e,t,r,i){switch(t.type){case"3d":return k(e,t,r,i);case"2d":return A(e,t,r,i)}}async function P(e,t,r){const i=e.layer,a=i.createQuery();return a.objectIds=[e.getAttribute(i.objectIdField)],a.outFields=["*"],a.outSpatialReference=t.spatialReference,a.returnM=i.capabilities.data.supportsM,a.returnZ=i.capabilities.data.supportsZ,(await i.queryFeatures(a,{signal:r})).features[0]}async function q(e,i,a,n){let s=!1;const{rotation:o,size:l}=n;[o,l].forEach((async a=>{if(r(a))return;const n=i.attributes[a.field];if(t(n))a.initValue(n);else{const t=await a.getDefault(i.symbol,e.view);a.initValue(t),i.setAttribute(a.field,t),s=!0}})),s&&await L(i);const c={multipleSelectionEnabled:!1};return"point"===a.geometryType&&(c.enableRotation=t(o),c.enableScaling=t(l)),e.layer.elevationInfo=a.elevationInfo,e.update(i,c)}function D(e){return!e||"rotate-start"!==e.type&&"rotate"!==e.type&&"rotate-stop"!==e.type?null:e}function O(e){return!e||"scale-start"!==e.type&&"scale"!==e.type&&"scale-stop"!==e.type?null:e}async function Z(e,r,i,a){var n;if(!t(r.geometry)||"point"!==(null==(n=r.geometry)?void 0:n.type))return;const s=a.rotation,o=D(i.toolEventInfo);if(t(s)&&t(o))if("rotate-stop"===o.type)s.isUpdatingInteractively=!1,s.initValue();else{s.isUpdatingInteractively=!0;const{field:t,getValue:i}=s;r.attributes[t]=i(o.angle,e)}const l=a.size,c=O(i.toolEventInfo);if(t(l)&&t(c))if("scale-stop"===c.type)l.isUpdatingInteractively=!1,l.initValue();else{l.isUpdatingInteractively=!0;const{field:t,getValue:i}=l;r.attributes[t]=i(c.xScale,e)}await L(r)}async function Q(e,a,n,s,c){const u=e.clone();await L(u),s.map.add(n.layer),n.layer.add(u);const p=e.sourceLayer,y=s.whenLayerView(p),f=()=>{const t=e.layer,r=e.attributes[t.objectIdField];return y.then((e=>e.setVisibility(r,!1)),(()=>{})),{remove(){y.then((e=>e.setVisibility(r,!0)),(()=>{}))}}};let d=null,m=null;if("3d"===s.type){const e=new b({graphic:u});d=s.trackGraphicState(e),o(e,"displaying",(e=>{m=e?f():i(m)}))}else m=f();await q(n,u,p,a);let h=null;y.then((e=>h=e),(()=>{}));const g=a.size,w=a.rotation,v=e.watch("attributes",(async e=>{let i=!1;for(const a in e){const n=e[a];n!==u.attributes[a]&&(u.setAttribute(a,n),t(g)&&!g.isUpdatingInteractively&&g.field===a&&g.initValue(n),t(w)&&!w.isUpdatingInteractively&&w.field===a&&w.initValue(n),(r(h)||h.requiredFields.includes(a))&&(i=!0))}i&&await L(u)})),S=n.on("update",(async e=>{const t=e.graphics[0];if("complete"===e.state)return q(n,t,p,a);await Z(s,t,e,a),c(t.clone())})),j=n.on(["undo","redo"],(async e=>{c(e.graphics[0].clone())})),I=()=>{};return{interactive:{remove(){j.remove(),S.remove(),n.cancel(),v&&v.remove(),this.remove=I}},visual:{remove(){i(m),s.whenLayerView(p).then((e=>l(e,"updating"))).then((()=>{i(d),n.layer.remove(u),this.remove=I}))}}}}const B={icon:s(24),text:s(12),line:s(1),viewScaleSizeFactor:100};function C(e,t,r){let i=!1;return e.filter((e=>!!i||(i=e===t,i))).map((e=>r[e]()))}function W(e){if(1!==e.length)return null;const t=e[0];if("items"in t){const e=t;return 1===e.items.length?e.items[0]:null}return t}function H(e,r){if(e.viewModel.refreshCreationTemplates(),"awaiting-feature-creation-info"===r[0].id){const i=W(e.viewModel.featureTemplatesViewModel.items);t(i)&&(e.creationInfo={layer:i.layer,template:i.template},r.shift())}return r}export{H as avoidFeatureTemplateSelectionWithOnlyOneItem,C as createWorkflowSteps,G as fetchCandidates,P as fetchFullFeature,E as findLayerInfo,S as getVisualVariableAttributes,M as setUpFeatureAdd,Q as setUpGeometryUpdate,B as sizeDefaults,R as startCreatingNewFeature,q as startUpdatingFeature,L as updateGraphicSymbolWhenRequired,Z as visualVariableInteractiveUpdate};
5
+ import e from"../../Graphic.js";import"../../core/has.js";import{isSome as t,isNone as r,removeMaybe as i}from"../../core/maybe.js";import{whenOrAbort as a,eachAlways as n}from"../../core/promiseUtils.js";import{px2pt as s}from"../../core/screenUtils.js";import{init as o,whenFalseOnce as l}from"../../core/watchUtils.js";import{diff as c}from"../../core/accessorSupport/diffUtils.js";import{calculateTolerance as u}from"../../renderers/support/clickToleranceUtils.js";import{meterIn as p}from"../../renderers/support/lengthUtils.js";import{getTransformationType as y,TransformationType as f}from"../../renderers/visualVariables/support/sizeVariableUtils.js";import{getRotationAngle as d,getSize as m}from"../../renderers/visualVariables/support/visualVariableUtils.js";import{to3D as h}from"../../symbols/support/symbolConversion.js";import{getDisplayedSymbol as g}from"../../symbols/support/symbolUtils.js";import{GraphicState as b}from"../../views/3d/layers/graphics/GraphicState.js";import{createQueryGeometry as w}from"../../views/support/drapedUtils.js";import{hitTestSelectSameDistance as v}from"../../views/support/hitTestSelectUtils.js";function S(e){const r=e.sourceLayer;if("feature"!==r.type||!F(r.renderer))return{rotation:null,size:null};let i=null,a=null;const n=r.renderer.getVisualVariablesForType("rotation").filter((r=>(!r.axis||"heading"===r.axis)&&r.field&&!r.valueExpression&&t(d(r,e))));1===n.length&&(i=j(n[0],r));const s=r.renderer.getVisualVariablesForType("size").filter((r=>r.field&&!r.useSymbolValue&&!r.valueExpression&&y(r)===f.RealWorldSize&&t(m(r,e))));return 1===s.length&&(a=U(s[0],r)),{rotation:i,size:a}}function j(e,t){const r="heading"===(e.axis||"heading")&&"arithmetic"===e.rotationType?-1:1,i=e.field,a=t.fields&&t.fields.filter((e=>e.name===i)),n=a&&1===a.length?a[0].type:"double",s={initial:0,current:0};return{field:i,getDefault:()=>Promise.resolve(0),getValue:e=>(s.current=s.initial-r*e,z((s.current+360)%360,n)),initValue:e=>{s.initial=null!=e?e:s.current,s.current=0},isUpdatingInteractively:!1}}function I(e,t){switch(t){case"width":return e[0];case"depth":return e[1];case"height":return e[2];default:return e[2]||e[1]||e[0]}}async function V(e,t,i){if(r(t))return 0;const{symbol:a}=h(t);if(r(a)||"web-style"===a.type||"cim"===a.type)return 0;const n=a.symbolLayers.getItemAt(0);if(!n)return 0;switch(n.type){case"icon":{const{computeIconLayerResourceSize:e}=await import("../../symbols/support/symbolLayerUtils.js");return n.size||Math.min(B.icon,(await e(n,B.icon))[0])||B.icon}case"text":return n.size||B.text;case"line":return n.size||B.line;case"object":{const{computeObjectLayerResourceSize:t}=await import("../../symbols/support/symbolLayerUtils.js");return I(await t(n,e.scale/B.viewScaleSizeFactor),i)}case"path":return(null!=n.width?n.width:n.height)||e.scale/B.viewScaleSizeFactor;case"extrude":return n.size||e.scale/B.viewScaleSizeFactor;default:return 0}}function U(e,t){const r=e.field,i=e.axis,a=t.fields&&t.fields.filter((e=>e.name===r)),n=a&&1===a.length?a[0].type:"double",s={updating:!1,initial:0,current:0},o=p[e.valueUnit];let l;return l="area"===e.valueRepresentation?e=>(e*o/2)**2*Math.PI:"radius"===e.valueRepresentation||"distance"===e.valueRepresentation?e=>e*o/2:e=>e*o,{field:r,getDefault:async(e,t)=>z(l(await V(t,e,i)),n),getValue:(e,t)=>(s.initial||(s.initial=t.pixelSizeAt(t.center)),s.current=s.initial*e,z(s.current,n)),initValue:e=>{s.initial=null!=e?e:s.current,s.current=0},isUpdatingInteractively:!1}}function z(e,t){switch(t){case"small-integer":case"integer":case"long":return Math.round(e);case"double":case"single":return e;default:return 0}}function F(e){switch(e.type){case"class-breaks":case"simple":case"unique-value":case"dot-density":case"dictionary":return!0;default:return!1}}async function L(e){const r=await g(e,{useSourceLayer:!0,ignoreGraphicSymbol:!0}),i=c(e.symbol,r);t(i)&&(e.symbol=r)}function x(e){if("mesh"===e||"multipatch"===e)throw new Error("Mesh and Multipatch not supported");return e}async function M(e,t,r){await R(e,t);const i=e.on("create",(async i=>{if("cancel"===i.state)return R(e,t);if("complete"===i.state){const e=i.graphic;e.sourceLayer||(e.sourceLayer=t.layer),e.attributes||(e.attributes={...t.template.prototype.attributes}),await L(e),r(e)}}));return{remove:()=>{i.remove(),e.cancel()}}}async function R(e,t){const r=t.layer,i={...t.template.prototype.attributes};await E(e,r,i);const a={graphicProperties:{attributes:i,sourceLayer:r},hasZ:r.capabilities.data.supportsZ};return e.layer.elevationInfo=r.elevationInfo,e.create(x(r.geometryType),a)}async function E(t,i,a){var n;const s=new e({sourceLayer:i,attributes:a}),{rotation:o,size:l}=S(s);let c=await g(s,{useSourceLayer:!0}),u=!1;for(const e of[l,o]){if(r(e))continue;null==a[e.field]&&(a[e.field]=await e.getDefault(c,t.view),u=!0)}switch(u&&(c=await g(s,{useSourceLayer:!0})),null==(n=c)?void 0:n.type){case"simple-fill":case"polygon-3d":t.polygonSymbol=c;break;case"simple-line":case"line-3d":t.polylineSymbol=c;break;case"simple-marker":case"picture-marker":case"point-3d":t.pointSymbol=c}}function T(e,t){return e&&e.find((e=>e.layer===t))}async function k(e,t,r,i){if(0===e.length)return[];const{updatable:s,graphicsByLayer:o}=await r.async((async()=>{const{results:n}=await a(v(t,r),i),s=new Map,o=({layer:e})=>{const t=s.get(e);if(!t){const t=new Array;return s.set(e,t),t}return t};n.forEach((({graphic:e})=>o(e).push(e)));const l=e.filter((({supports:e,layer:t})=>e.indexOf("update")>-1&&s.has(t)));return 0!==l.length&&r.stopPropagation(),{updatable:l,graphicsByLayer:s}}));return a(n(s.map((async({layer:e})=>{const{objectIdField:t,displayField:r}=e,a=[t];e.fieldsIndex.has(r)&&a.push(r);const n=o.get(e);if(!!n.some((e=>a.some((t=>!(t in e.attributes)))))){const t=e.createQuery();return t.outFields=a,t.returnGeometry=!1,t.objectIds=n.map((e=>e.getObjectId())),e.queryFeatures(t,{signal:i}).then((({features:e})=>e))}return n}))),i)}async function A(e,t,r,i){if(0===e.length)return[];let s=null;const o=await r.async((async()=>{const{results:n}=await a(t.hitTest(r),i);if(0===n.length)return[];const o=new Set;s=n,s.forEach((({graphic:e})=>o.add(e.layer)));const l=e.items.filter((({layer:e,supports:t})=>t.indexOf("update")>-1&&o.has(e)));return l.length>0&&r.stopPropagation(),l}));return a(n(o.map((({layer:e})=>{const{objectIdField:a,displayField:n}=e,o=[a];e.fieldsIndex.has(n)&&o.push(n);const l=e.createQuery();l.outFields=o,l.returnGeometry=!1;const c="renderer"in e?u({renderer:e.renderer,event:r}):0;return l.geometry=w(r.mapPoint,c,t),l.outSpatialReference=t.spatialReference,e.queryFeatures(l,{signal:i}).then((({features:t})=>(s.forEach((({graphic:r})=>{if(r.layer===e){t.find((t=>t.attributes[a]===r.attributes[e.objectIdField]))||t.push(r)}})),t)))}))),i)}async function G(e,t,r,i){switch(t.type){case"3d":return k(e,t,r,i);case"2d":return A(e,t,r,i)}}async function P(e,t,r){const i=e.layer,a=i.createQuery();return a.objectIds=[e.getAttribute(i.objectIdField)],a.outFields=["*"],a.outSpatialReference=t.spatialReference,a.returnM=i.capabilities.data.supportsM,a.returnZ=i.capabilities.data.supportsZ,(await i.queryFeatures(a,{signal:r})).features[0]}async function q(e,i,a,n){let s=!1;const{rotation:o,size:l}=n;[o,l].forEach((async a=>{if(r(a))return;const n=i.attributes[a.field];if(t(n))a.initValue(n);else{const t=await a.getDefault(i.symbol,e.view);a.initValue(t),i.setAttribute(a.field,t),s=!0}})),s&&await L(i);const c={multipleSelectionEnabled:!1};return"point"===a.geometryType&&(c.enableRotation=t(o),c.enableScaling=t(l)),e.layer.elevationInfo=a.elevationInfo,e.update(i,c)}function D(e){return!e||"rotate-start"!==e.type&&"rotate"!==e.type&&"rotate-stop"!==e.type?null:e}function O(e){return!e||"scale-start"!==e.type&&"scale"!==e.type&&"scale-stop"!==e.type?null:e}async function Z(e,r,i,a){var n;if(!t(r.geometry)||"point"!==(null==(n=r.geometry)?void 0:n.type))return;const s=a.rotation,o=D(i.toolEventInfo);if(t(s)&&t(o))if("rotate-stop"===o.type)s.isUpdatingInteractively=!1,s.initValue();else{s.isUpdatingInteractively=!0;const{field:t,getValue:i}=s;r.attributes[t]=i(o.angle,e)}const l=a.size,c=O(i.toolEventInfo);if(t(l)&&t(c))if("scale-stop"===c.type)l.isUpdatingInteractively=!1,l.initValue();else{l.isUpdatingInteractively=!0;const{field:t,getValue:i}=l;r.attributes[t]=i(c.xScale,e)}await L(r)}async function Q(e,a,n,s,c){const u=e.clone();await L(u),s.map.add(n.layer),n.layer.add(u);const p=e.sourceLayer,y=s.whenLayerView(p),f=()=>{const t=e.layer,r=e.attributes[t.objectIdField];return y.then((e=>e.setVisibility(r,!1)),(()=>{})),{remove(){y.then((e=>e.setVisibility(r,!0)),(()=>{}))}}};let d=null,m=null;if("3d"===s.type){const e=new b({graphic:u});d=s.trackGraphicState(e),o(e,"displaying",(e=>{m=e?f():i(m)}))}else m=f();await q(n,u,p,a);let h=null;y.then((e=>h=e),(()=>{}));const g=a.size,w=a.rotation,v=e.watch("attributes",(async e=>{let i=!1;for(const a in e){const n=e[a];n!==u.attributes[a]&&(u.setAttribute(a,n),t(g)&&!g.isUpdatingInteractively&&g.field===a&&g.initValue(n),t(w)&&!w.isUpdatingInteractively&&w.field===a&&w.initValue(n),(r(h)||h.requiredFields.includes(a))&&(i=!0))}i&&await L(u)})),S=n.on("update",(async e=>{const t=e.graphics[0];if("complete"===e.state)return q(n,t,p,a);await Z(s,t,e,a),c(t.clone())})),j=n.on(["undo","redo"],(async e=>{c(e.graphics[0].clone())})),I=()=>{};return{interactive:{remove(){j.remove(),S.remove(),n.cancel(),v&&v.remove(),this.remove=I}},visual:{remove(){i(m),s.whenLayerView(p).then((e=>l(e,"updating"))).then((()=>{i(d),n.layer.remove(u),this.remove=I}))}}}}const B={icon:s(24),text:s(12),line:s(1),viewScaleSizeFactor:100};function C(e,t,r){let i=!1;return e.filter((e=>!!i||(i=e===t,i))).map((e=>r[e]()))}function W(e){if(1!==e.length)return null;const t=e[0];if("items"in t){const e=t;return 1===e.items.length?e.items[0]:null}return t}function H(e,r){if(e.viewModel.refreshCreationTemplates(),"awaiting-feature-creation-info"===r[0].id){const i=W(e.viewModel.featureTemplatesViewModel.items);t(i)&&(e.creationInfo={layer:i.layer,template:i.template},r.shift())}return r}export{H as avoidFeatureTemplateSelectionWithOnlyOneItem,C as createWorkflowSteps,G as fetchCandidates,P as fetchFullFeature,T as findLayerInfo,S as getVisualVariableAttributes,M as setUpFeatureAdd,Q as setUpGeometryUpdate,B as sizeDefaults,R as startCreatingNewFeature,q as startUpdatingFeature,L as updateGraphicSymbolWhenRequired,Z as visualVariableInteractiveUpdate};