@arcgis/core 4.33.0-next.20250312 → 4.33.0-next.20250314
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.
- package/Basemap.js +1 -1
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/065ae931b5891847a06f.js +1 -0
- package/assets/esri/core/workers/chunks/{4263eee3247aaf4e64bf.js → 147e412de9972da16a1d.js} +1 -1
- package/assets/esri/core/workers/chunks/{3ee2cf2db08164cde43c.js → 23aa7254fffe67e3f1bc.js} +74 -75
- package/assets/esri/core/workers/chunks/29ba2022c2978e9bd53e.js +1 -0
- package/assets/esri/core/workers/chunks/2b21152c7e2d9c170ed7.js +1 -0
- package/assets/esri/core/workers/chunks/7ded83eb64eff069b761.js +1 -0
- package/assets/esri/core/workers/chunks/a7a1832274892e99c388.js +1 -0
- package/assets/esri/core/workers/chunks/c43c273725b1a33712ec.js +314 -0
- package/assets/esri/core/workers/chunks/{2c227d97d00b3849f441.js → d459c790a3b89ac53d2d.js} +1 -1
- package/chunks/ComponentShader.glsl.js +7 -8
- package/chunks/FocusAreaMask.glsl.js +2 -1
- package/chunks/HighlightApply.glsl.js +27 -132
- package/chunks/{SingleHighlightBlur.glsl.js → HighlightBlur.glsl.js} +4 -4
- package/chunks/HighlightDownsample.glsl.js +8 -8
- package/chunks/HighlightToSingle.glsl.js +2 -2
- package/chunks/ShadowHighlight.glsl.js +5 -6
- package/chunks/Terrain.glsl.js +15 -16
- package/core/has.js +1 -1
- package/layers/VoxelWasmPerSceneView.js +1 -1
- package/layers/orientedImagery/transformations/utils.js +1 -1
- package/layers/support/layerUtils.js +1 -1
- package/package.json +1 -1
- package/support/revision.js +1 -1
- package/views/2d/engine/vectorTiles/VectorTileContainer.js +1 -1
- package/views/2d/engine/webgl/Painter.js +1 -1
- package/views/2d/engine/webgl/WorldExtentClipRenderer.js +1 -1
- package/views/2d/engine/webgl/effects/FeatureEffect.js +1 -1
- package/views/2d/engine/webgl/effects/HighlightEffect.js +1 -1
- package/views/2d/engine/webgl/effects/HittestEffect.js +1 -1
- package/views/2d/layers/imagery/BaseImageryTileSubView2D.js +1 -1
- package/views/2d/layers/imagery/ImageryTileView2D.js +1 -1
- package/views/2d/layers/imagery/VectorFieldTileView2D.js +1 -1
- package/views/3d/analysis/Dimension/DimensionVisualization.js +1 -1
- package/views/3d/analysis/Dimension/LengthDimensionSubTool.js +1 -1
- package/views/3d/analysis/Slice/SliceTool.js +1 -1
- package/views/3d/environment/ChapmanAtmosphere.js +1 -1
- package/views/3d/environment/CloudsRenderer.js +1 -1
- package/views/3d/environment/EnvironmentManager.js +1 -1
- package/views/3d/environment/EnvironmentRenderer.js +1 -1
- package/views/3d/environment/Fog.js +1 -1
- package/views/3d/environment/MarsAtmosphere.js +1 -1
- package/views/3d/environment/Precipitation.js +1 -1
- package/views/3d/interactive/Manipulator3D.js +1 -1
- package/views/3d/interactive/editingTools/transform/extentTransform/ExtentRotate.js +1 -1
- package/views/3d/interactive/visualElements/LabelVisualElement.js +1 -1
- package/views/3d/interactive/visualElements/LaserlineVisualElement.js +1 -1
- package/views/3d/interactive/visualElements/Object3DVisualElement.js +1 -1
- package/views/3d/interactive/visualElements/PointVisualElement.js +1 -1
- package/views/3d/interactive/visualElements/VisualElement.js +1 -1
- package/views/3d/interactive/visualElements/VisualElementResources.js +1 -1
- package/views/3d/layers/DrapedSubView3D.js +5 -0
- package/views/3d/layers/DynamicLayerView3D.js +1 -1
- package/views/3d/layers/I3SMeshView3D.js +1 -1
- package/views/3d/layers/ImageryLayerView3D.js +1 -1
- package/views/3d/layers/ImagerySubView3D.js +5 -0
- package/views/3d/layers/ImageryTileLayerView3D.js +1 -1
- package/views/3d/layers/IntegratedMesh3DTilesLayerView3D.js +1 -1
- package/views/3d/layers/Lyr3DWasm.js +1 -1
- package/views/3d/layers/MediaLayerView3D.js +1 -1
- package/views/3d/layers/PointCloudLayerView3D.js +1 -1
- package/views/3d/layers/SceneLayerGraphicsView3D.js +1 -1
- package/views/3d/layers/SubView3D.js +5 -0
- package/views/3d/layers/VoxelLayerView3D.js +1 -1
- package/views/3d/layers/WMSLayerView3D.js +1 -1
- package/views/3d/layers/graphics/Graphics3DCore.js +1 -1
- package/views/3d/layers/graphics/Graphics3DDrapedGraphicLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DGraphic.js +1 -1
- package/views/3d/layers/graphics/Graphics3DLodInstanceGraphicLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DObject3DGraphicLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DPathSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Labeler.js +1 -1
- package/views/3d/layers/graphics/pipeline/Feature3DPipeline.js +1 -1
- package/views/3d/layers/graphics/pipeline/Feature3DPipelineWorker.js +1 -1
- package/views/3d/layers/graphics/pipeline/Feature3DPipelineWorkerHandle.js +1 -1
- package/views/3d/layers/graphics/pipeline/featureData/processingUtils.js +1 -1
- package/views/3d/layers/graphics/pipeline/rendering/DirectRenderer.js +1 -1
- package/views/3d/layers/graphics/pipeline/rendering/FeaturePipelineRenderManager.js +1 -1
- package/views/3d/layers/graphics/pipeline/rendering/LodRenderer.js +1 -1
- package/views/3d/layers/graphics/pipeline/rendering/RenderCommandContext.js +1 -1
- package/views/3d/layers/graphics/pipeline/symbolization/TestObjectSymbol.js +1 -1
- package/views/3d/layers/graphics/pipeline/symbolization/TestSymbol.js +1 -1
- package/views/3d/layers/graphics/pipeline/utils.js +1 -1
- package/views/3d/layers/support/FeatureTileFetcher3D.js +1 -1
- package/views/3d/layers/support/HeatmapFeatureProcessor.js +1 -1
- package/views/3d/layers/support/Tiles3DIntersectionHandler.js +1 -1
- package/views/3d/state/ViewStateManager.js +1 -1
- package/views/3d/state/controllers/FovController.js +1 -1
- package/views/3d/state/controllers/PinchAndPanControllerGlobal.js +1 -1
- package/views/3d/state/controllers/PinchAndPanControllerLocal.js +1 -1
- package/views/3d/state/controllers/RotateController.js +1 -1
- package/views/3d/state/controllers/ZoomControllerGlobal.js +1 -1
- package/views/3d/state/controllers/ZoomControllerLocal.js +1 -1
- package/views/3d/state/controllers/ZoomStepControllerGlobal.js +1 -1
- package/views/3d/state/controllers/ZoomStepControllerLocal.js +1 -1
- package/views/3d/state/helpers/SceneIntersectionHelper.js +1 -1
- package/views/3d/support/MemoryController.js +1 -1
- package/views/3d/support/SceneViewPerformanceInfo.js +1 -1
- package/views/3d/support/SharedSymbolResources.js +1 -1
- package/views/3d/support/buffer/InterleavedLayout.js +1 -1
- package/views/3d/support/flowUtils.js +5 -0
- package/views/3d/terrain/OverlayManager.js +1 -1
- package/views/3d/terrain/OverlayRenderTargets.js +1 -1
- package/views/3d/terrain/OverlayRenderer.js +1 -1
- package/views/3d/terrain/TerrainSurface.js +1 -1
- package/views/3d/terrain/TileCompositor.js +1 -1
- package/views/3d/terrain/TileRenderer.js +1 -1
- package/views/3d/webgl/ManagedFBO.js +1 -1
- package/views/3d/webgl/RenderNode.js +1 -1
- package/views/3d/webgl/formats.js +1 -1
- package/views/3d/webgl-engine/Stage.js +1 -1
- package/views/3d/webgl-engine/core/FBOCache.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/HighlightCellGridScreenSpacePass.glsl.js +2 -2
- package/views/3d/webgl-engine/core/shaderLibrary/HighlightReadBitmap.glsl.js +3 -3
- package/views/3d/webgl-engine/core/shaderLibrary/output/OutputHighlight.glsl.js +7 -8
- package/views/3d/webgl-engine/core/shaderLibrary/terrain/Overlay.glsl.js +18 -18
- package/views/3d/webgl-engine/core/shaderModules/UintTexture2DBindUniform.js +5 -0
- package/views/3d/webgl-engine/core/shaderModules/UintTexture2DDrawUniform.js +5 -0
- package/views/3d/webgl-engine/core/shaderModules/UintTexture2DPassUniform.js +5 -0
- package/views/3d/webgl-engine/effects/bloom/BloomRenderNode.js +1 -1
- package/views/3d/webgl-engine/effects/debug/RenderNodeVisualizerNode.js +1 -1
- package/views/3d/webgl-engine/effects/focusArea/FocusAreaColorNode.js +1 -1
- package/views/3d/webgl-engine/effects/focusArea/FocusAreaMaskNode.js +1 -1
- package/views/3d/webgl-engine/effects/geometry/ObjectAndLayerIDRenderNode.js +1 -1
- package/views/3d/webgl-engine/effects/geometry/RenderOccludedRenderNode.js +1 -1
- package/views/3d/webgl-engine/effects/haze/Haze.js +1 -1
- package/views/3d/webgl-engine/effects/highlight/Highlight.js +1 -1
- package/views/3d/webgl-engine/effects/highlight/HighlightBlurTechnique.js +5 -0
- package/views/3d/webgl-engine/effects/highlight/ShadowHighlight.js +1 -1
- package/views/3d/webgl-engine/effects/laserlines/LaserLineRenderer.js +1 -1
- package/views/3d/webgl-engine/effects/transparency/OITBlend.js +1 -1
- package/views/3d/webgl-engine/effects/transparency/OITBlendTechnique.js +1 -1
- package/views/3d/webgl-engine/lib/GridLocalOriginFactory.js +1 -1
- package/views/3d/webgl-engine/lib/MainFramebuffer.js +1 -1
- package/views/3d/webgl-engine/lib/OrderIndependentTransparency.js +1 -1
- package/views/3d/webgl-engine/lib/Program.js +1 -1
- package/views/3d/webgl-engine/lib/Renderer.js +1 -1
- package/views/3d/webgl-engine/lib/TextTextureAtlas.js +1 -1
- package/views/3d/webgl-engine/lib/Viewshed.js +1 -1
- package/views/3d/webgl-engine/lib/lodRendering/LodRenderer.js +1 -1
- package/views/3d/webgl-engine/shaders/HighlightApply.glsl.js +1 -1
- package/views/3d/webgl-engine/shaders/{SingleHighlightBlur.glsl.js → HighlightBlur.glsl.js} +1 -1
- package/views/3d/webgl-engine/shaders/HighlightDownsample.glsl.js +1 -1
- package/views/3d/webgl-engine/shaders/HighlightToSingle.glsl.js +1 -1
- package/views/3d/webgl-engine/shaders/ShadowHighlight.glsl.js +1 -1
- package/views/FocusAreas.js +1 -1
- package/views/SceneView.js +1 -1
- package/views/support/imageReprojection.js +1 -1
- package/views/webgl/FramebufferObject.js +1 -1
- package/views/webgl/Program.js +1 -1
- package/views/webgl/RenderingContext.js +1 -1
- package/views/webgl/ShaderBuilder.js +1 -1
- package/views/webgl/ShaderTranspiler.js +1 -1
- package/views/webgl/Texture.js +1 -1
- package/views/webgl/ValidatedTextureDescriptor.js +1 -1
- package/views/webgl/capabilities/Capabilities.js +1 -1
- package/views/webgl/checkWebGLError.js +1 -1
- package/views/webgl/enums.js +1 -1
- package/views/webgl/testFloatBufferBlend.js +1 -1
- package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
- package/widgets/OrientedImageryViewer/adapters/sketch/DataCaptureAdapter.js +1 -1
- package/widgets/OrientedImageryViewer/dataCaptureUtils.js +1 -1
- package/widgets/ShadowCast/ShadowCastViewModel.js +1 -1
- package/assets/esri/core/workers/chunks/15fe629cd4da1bb2169f.js +0 -1
- package/assets/esri/core/workers/chunks/8196ff250c0de00104f7.js +0 -1
- package/assets/esri/core/workers/chunks/be883ebdbaf11647b718.js +0 -1
- package/assets/esri/core/workers/chunks/d0ad20548eb4786b7750.js +0 -314
- package/assets/esri/core/workers/chunks/d374d2a1487faee3672d.js +0 -1
- package/assets/esri/core/workers/chunks/dbdca19978fbee8dc106.js +0 -1
- package/chunks/SingleHighlightApply.glsl.js +0 -32
- package/views/3d/webgl-engine/effects/highlight/SingleHighlightApplyTechnique.js +0 -5
- package/views/3d/webgl-engine/effects/highlight/SingleHighlightBlurTechnique.js +0 -5
- package/views/3d/webgl-engine/shaders/SingleHighlightApply.glsl.js +0 -5
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import"../../core/has.js";import{ShaderType as e}from"./enums.js";import t from"./reservedWordsGLSL3.js";import{shaderTranspiler as r}from"./testUtils.js";const a=["precision","highp","mediump","lowp","attribute","const","uniform","varying","break","continue","do","for","while","if","else","in","out","inout","float","int","void","bool","true","false","discard","return","mat2","mat3","mat4","vec2","vec3","vec4","ivec2","ivec3","ivec4","bvec2","bvec3","bvec4","sampler1D","sampler2D","sampler3D","samplerCube","sampler1DShadow","sampler2DShadow","struct","asm","class","union","enum","typedef","template","this","packed","goto","switch","default","inline","noinline","volatile","public","static","extern","external","interface","long","short","double","half","fixed","unsigned","input","output","hvec2","hvec3","hvec4","dvec2","dvec3","dvec4","fvec2","fvec3","fvec4","sampler2DRect","sampler3DRect","sampler2DRectShadow","sizeof","cast","namespace","using"],o=["<<=",">>=","++","--","<<",">>","<=",">=","==","!=","&&","||","+=","-=","*=","/=","%=","&=","^^","^=","|=","(",")","[","]",".","!","~","*","/","%","+","-","<",">","&","^","|","?",":","=",",",";","{","}"],n=["abs","acos","all","any","asin","atan","ceil","clamp","cos","cross","dFdx","dFdy","degrees","distance","dot","equal","exp","exp2","faceforward","floor","fract","gl_BackColor","gl_BackLightModelProduct","gl_BackLightProduct","gl_BackMaterial","gl_BackSecondaryColor","gl_ClipPlane","gl_ClipVertex","gl_Color","gl_DepthRange","gl_DepthRangeParameters","gl_EyePlaneQ","gl_EyePlaneR","gl_EyePlaneS","gl_EyePlaneT","gl_Fog","gl_FogCoord","gl_FogFragCoord","gl_FogParameters","gl_FragColor","gl_FragCoord","gl_FragData","gl_FragDepth","gl_FragDepthEXT","gl_FrontColor","gl_FrontFacing","gl_FrontLightModelProduct","gl_FrontLightProduct","gl_FrontMaterial","gl_FrontSecondaryColor","gl_LightModel","gl_LightModelParameters","gl_LightModelProducts","gl_LightProducts","gl_LightSource","gl_LightSourceParameters","gl_MaterialParameters","gl_MaxClipPlanes","gl_MaxCombinedTextureImageUnits","gl_MaxDrawBuffers","gl_MaxFragmentUniformComponents","gl_MaxLights","gl_MaxTextureCoords","gl_MaxTextureImageUnits","gl_MaxTextureUnits","gl_MaxVaryingFloats","gl_MaxVertexAttribs","gl_MaxVertexTextureImageUnits","gl_MaxVertexUniformComponents","gl_ModelViewMatrix","gl_ModelViewMatrixInverse","gl_ModelViewMatrixInverseTranspose","gl_ModelViewMatrixTranspose","gl_ModelViewProjectionMatrix","gl_ModelViewProjectionMatrixInverse","gl_ModelViewProjectionMatrixInverseTranspose","gl_ModelViewProjectionMatrixTranspose","gl_MultiTexCoord0","gl_MultiTexCoord1","gl_MultiTexCoord2","gl_MultiTexCoord3","gl_MultiTexCoord4","gl_MultiTexCoord5","gl_MultiTexCoord6","gl_MultiTexCoord7","gl_Normal","gl_NormalMatrix","gl_NormalScale","gl_ObjectPlaneQ","gl_ObjectPlaneR","gl_ObjectPlaneS","gl_ObjectPlaneT","gl_Point","gl_PointCoord","gl_PointParameters","gl_PointSize","gl_Position","gl_ProjectionMatrix","gl_ProjectionMatrixInverse","gl_ProjectionMatrixInverseTranspose","gl_ProjectionMatrixTranspose","gl_SecondaryColor","gl_TexCoord","gl_TextureEnvColor","gl_TextureMatrix","gl_TextureMatrixInverse","gl_TextureMatrixInverseTranspose","gl_TextureMatrixTranspose","gl_Vertex","greaterThan","greaterThanEqual","inversesqrt","length","lessThan","lessThanEqual","log","log2","matrixCompMult","max","min","mix","mod","normalize","not","notEqual","pow","radians","reflect","refract","sign","sin","smoothstep","sqrt","step","tan","texture2D","texture2DLod","texture2DProj","texture2DProjLod","textureCube","textureCubeLod","texture2DLodEXT","texture2DProjLodEXT","textureCubeLodEXT","texture2DGradEXT","texture2DProjGradEXT","textureCubeGradEXT","textureSize","texelFetch"];var i=999,l=9999,s=0,c=1,d=2,u=3,g=4,p=5,f=6,_=7,h=8,x=9,m=10,y=11,w=["block-comment","line-comment","preprocessor","operator","integer","float","ident","builtin","keyword","whitespace","eof","integer"];function M(){var e,t,r,M=0,v=0,T=i,b=[],P=[],E=1,C=0,k=0,D=!1,j=!1,F="";return function(e){return P=[],null!==e?S(e.replace?e.replace(/\r\n/g,"\n"):e):R()};function L(e){e.length&&P.push({type:w[T],data:e,position:k,line:E,column:C})}function S(t){var a;for(M=0,r=(F+=t).length;e=F[M],M<r;){switch(a=M,T){case s:M=I();break;case c:M=G();break;case d:M=A();break;case u:M=O();break;case g:M=B();break;case y:M=q();break;case p:M=H();break;case l:M=N();break;case x:M=X();break;case i:M=V()}if(a!==M)if("\n"===F[a])C=0,++E;else++C}return v+=M,F=F.slice(M),P}function R(e){return b.length&&L(b.join("")),T=m,L("(eof)"),P}function V(){return b=b.length?[]:b,"/"===t&&"*"===e?(k=v+M-1,T=s,t=e,M+1):"/"===t&&"/"===e?(k=v+M-1,T=c,t=e,M+1):"#"===e?(T=d,k=v+M,M):/\s/.test(e)?(T=x,k=v+M,M):(D=/\d/.test(e),j=/[^\w_]/.test(e),k=v+M,T=D?g:j?u:l,M)}function X(){return/[^\s]/g.test(e)?(L(b.join("")),T=i,M):(b.push(e),t=e,M+1)}function A(){return"\r"!==e&&"\n"!==e||"\\"===t?(b.push(e),t=e,M+1):(L(b.join("")),T=i,M)}function G(){return A()}function I(){return"/"===e&&"*"===t?(b.push(e),L(b.join("")),T=i,M+1):(b.push(e),t=e,M+1)}function O(){if("."===t&&/\d/.test(e))return T=p,M;if("/"===t&&"*"===e)return T=s,M;if("/"===t&&"/"===e)return T=c,M;if("."===e&&b.length){for(;U(b););return T=p,M}if(";"===e||")"===e||"("===e){if(b.length)for(;U(b););return L(e),T=i,M+1}var r=2===b.length&&"="!==e;if(/[\w_\d\s]/.test(e)||r){for(;U(b););return T=i,M}return b.push(e),t=e,M+1}function U(e){for(var t,r,a=0;;){if(t=o.indexOf(e.slice(0,e.length+a).join("")),r=o[t],-1===t){if(a--+e.length>0)continue;r=e.slice(0,1).join("")}return L(r),k+=r.length,(b=b.slice(r.length)).length}}function q(){return/[^a-fA-F0-9]/.test(e)?(L(b.join("")),T=i,M):(b.push(e),t=e,M+1)}function B(){return"."===e||/[eE]/.test(e)?(b.push(e),T=p,t=e,M+1):"x"===e&&1===b.length&&"0"===b[0]?(T=y,b.push(e),t=e,M+1):/[^\d]/.test(e)?(L(b.join("")),T=i,M):(b.push(e),t=e,M+1)}function H(){return"f"===e&&(b.push(e),t=e,M+=1),/[eE]/.test(e)||"-"===e&&/[eE]/.test(t)?(b.push(e),t=e,M+1):/[^\d]/.test(e)?(L(b.join("")),T=i,M):(b.push(e),t=e,M+1)}function N(){if(/[^\d\w_]/.test(e)){var r=b.join("");return T=a.indexOf(r)>-1?h:n.indexOf(r)>-1?_:f,L(b.join("")),T=i,M}return b.push(e),t=e,M+1}}function v(e){var t=M(),r=[];return r=(r=r.concat(t(e))).concat(t(null))}function T(e){return v(e)}function b(e){return e.map((e=>"eof"!==e.type?e.data:"")).join("")}const P=new Set(["GL_OES_standard_derivatives","GL_EXT_frag_depth","GL_EXT_draw_buffers","GL_EXT_shader_texture_lod"]);function E(e,t="100",r="300 es"){const a=/^\s*#version\s+([0-9]+(\s+[a-zA-Z]+)?)\s*/;for(const o of e)if("preprocessor"===o.type){const e=a.exec(o.data);if(e){const a=e[1].replaceAll(/\s{2,}/g," ");if(a===r)return a;if(a===t)return o.data="#version "+r,t;throw new Error("unknown glsl version: "+a)}}return e.splice(0,0,{type:"preprocessor",data:"#version "+r},{type:"whitespace",data:"\n"}),null}function C(e,t){for(let r=t-1;r>=0;r--){const t=e[r];if("whitespace"!==t.type&&"block-comment"!==t.type){if("keyword"!==t.type)break;if("attribute"===t.data||"in"===t.data)return!0}}return!1}function k(e,t,r,a){a=a||r;for(const o of e)if("ident"===o.type&&o.data===r){a in t?t[a]++:t[a]=0;return k(e,t,a+"_"+t[a],a)}return r}function D(e,t,r="afterVersion"){function a(e,t){for(let r=t;r<e.length;r++){const t=e[r];if("operator"===t.type&&";"===t.data)return r}return null}function o(e){let t=-1,o=0,n=-1;for(let i=0;i<e.length;i++){const l=e[i];if("preprocessor"===l.type&&(/#(if|ifdef|ifndef)\s+.+/.test(l.data)?++o:/#endif\s*.*/.test(l.data)&&--o),"afterVersion"!==r&&"afterPrecision"!==r||"preprocessor"===l.type&&l.data.startsWith("#version")&&(n=Math.max(n,i)),"afterPrecision"===r&&"keyword"===l.type&&"precision"===l.data){const t=a(e,i);if(null===t)throw new Error("precision statement not followed by any semicolons!");n=Math.max(n,t)}t<n&&0===o&&(t=i)}return t+1}const n={data:"\n",type:"whitespace"},i=t=>t<e.length&&/[^\r\n]$/.test(e[t].data);let l=o(e);i(l-1)&&e.splice(l++,0,n);for(const s of t)e.splice(l++,0,s);i(l-1)&&i(l)&&e.splice(l,0,n)}function j(e,t,r,a="lowp"){D(e,[{type:"keyword",data:"out"},{type:"whitespace",data:" "},{type:"keyword",data:a},{type:"whitespace",data:" "},{type:"keyword",data:r},{type:"whitespace",data:" "},{type:"ident",data:t},{type:"operator",data:";"}],"afterPrecision")}function F(e,t,r,a,o="lowp"){D(e,[{type:"keyword",data:"layout"},{type:"operator",data:"("},{type:"keyword",data:"location"},{type:"whitespace",data:" "},{type:"operator",data:"="},{type:"whitespace",data:" "},{type:"integer",data:a.toString()},{type:"operator",data:")"},{type:"whitespace",data:" "},{type:"keyword",data:"out"},{type:"whitespace",data:" "},{type:"keyword",data:o},{type:"whitespace",data:" "},{type:"keyword",data:r},{type:"whitespace",data:" "},{type:"ident",data:t},{type:"operator",data:";"}],"afterPrecision")}function L(e,t){let r,a,o=-1;for(let n=t;n<e.length;n++){const t=e[n];if("operator"===t.type&&("["===t.data&&(r=n),"]"===t.data)){a=n;break}"integer"===t.type&&(o=parseInt(t.data,10))}return r&&a&&e.splice(r,a-r+1),o}function S(r,a){if(r.startsWith("#version 300"))return r;const o=V(r);if(null!=o)return o;const n=T(r);if("300 es"===E(n,"100","300 es"))return r;let i=null,l=null;const s={},c={};for(let d=0;d<n.length;++d){const r=n[d];switch(r.type){case"keyword":a===e.VERTEX_SHADER&&"attribute"===r.data?r.data="in":"varying"===r.data&&(r.data=a===e.VERTEX_SHADER?"out":"in");break;case"builtin":if(/^texture(2D|Cube)(Proj)?(Lod|Grad)?(EXT)?$/.test(r.data.trim())&&(r.data=r.data.replaceAll(/(2D|Cube|EXT)/g,"")),a===e.FRAGMENT_SHADER&&"gl_FragColor"===r.data&&(i||(i=k(n,s,"fragColor"),j(n,i,"vec4")),r.data=i),a===e.FRAGMENT_SHADER&&"gl_FragData"===r.data){const e=L(n,d+1),t=k(n,s,"fragData");F(n,t,"vec4",e,"mediump"),r.data=t}else a===e.FRAGMENT_SHADER&&"gl_FragDepthEXT"===r.data&&(l||(l=k(n,s,"gl_FragDepth")),r.data=l);break;case"ident":if(t.includes(r.data)){if(a===e.VERTEX_SHADER&&C(n,d))throw new Error("attribute in vertex shader uses a name that is a reserved word in glsl 300 es");r.data in c||(c[r.data]=k(n,s,r.data)),r.data=c[r.data]}}}for(let e=n.length-1;e>=0;--e){const t=n[e];if("preprocessor"===t.type){const r=t.data.match(/#extension\s+(.*):/);if(r?.[1]&&P.has(r[1].trim())){const t=n[e+1];n.splice(e,t&&"whitespace"===t.type?2:1)}const a=t.data.match(/#ifdef\s+(.*)/);a?.[1]&&P.has(a[1].trim())&&(t.data="#if 1");const o=t.data.match(/#ifndef\s+(.*)/);o?.[1]&&P.has(o[1].trim())&&(t.data="#if 0")}}return X(r,b(n))}const R=new Map;function V(e){return r.enableCache?R.get(e):null}function X(e,t){return r.enableCache&&R.set(e,t),t}export{S as transpileShader};
|
|
5
|
+
import"../../core/has.js";import{ShaderType as e}from"./enums.js";import t from"./reservedWordsGLSL3.js";import{shaderTranspiler as r}from"./testUtils.js";const a=["precision","highp","mediump","lowp","attribute","const","uniform","varying","break","continue","do","for","while","if","else","in","out","inout","float","int","void","bool","true","false","discard","return","mat2","mat3","mat4","vec2","vec3","vec4","ivec2","ivec3","ivec4","uvec2","uvec3","uvec4","bvec2","bvec3","bvec4","sampler1D","sampler2D","sampler3D","usampler1D","usampler2D","usampler3D","samplerCube","sampler1DShadow","sampler2DShadow","struct","asm","class","union","enum","typedef","template","this","packed","goto","switch","default","inline","noinline","volatile","public","static","extern","external","interface","long","short","double","half","fixed","unsigned","input","output","hvec2","hvec3","hvec4","dvec2","dvec3","dvec4","fvec2","fvec3","fvec4","sampler2DRect","sampler3DRect","sampler2DRectShadow","sizeof","cast","namespace","using"],o=["<<=",">>=","++","--","<<",">>","<=",">=","==","!=","&&","||","+=","-=","*=","/=","%=","&=","^^","^=","|=","(",")","[","]",".","!","~","*","/","%","+","-","<",">","&","^","|","?",":","=",",",";","{","}"],n=["abs","acos","all","any","asin","atan","ceil","clamp","cos","cross","dFdx","dFdy","degrees","distance","dot","equal","exp","exp2","faceforward","floor","fract","gl_BackColor","gl_BackLightModelProduct","gl_BackLightProduct","gl_BackMaterial","gl_BackSecondaryColor","gl_ClipPlane","gl_ClipVertex","gl_Color","gl_DepthRange","gl_DepthRangeParameters","gl_EyePlaneQ","gl_EyePlaneR","gl_EyePlaneS","gl_EyePlaneT","gl_Fog","gl_FogCoord","gl_FogFragCoord","gl_FogParameters","gl_FragColor","gl_FragCoord","gl_FragData","gl_FragDepth","gl_FragDepthEXT","gl_FrontColor","gl_FrontFacing","gl_FrontLightModelProduct","gl_FrontLightProduct","gl_FrontMaterial","gl_FrontSecondaryColor","gl_LightModel","gl_LightModelParameters","gl_LightModelProducts","gl_LightProducts","gl_LightSource","gl_LightSourceParameters","gl_MaterialParameters","gl_MaxClipPlanes","gl_MaxCombinedTextureImageUnits","gl_MaxDrawBuffers","gl_MaxFragmentUniformComponents","gl_MaxLights","gl_MaxTextureCoords","gl_MaxTextureImageUnits","gl_MaxTextureUnits","gl_MaxVaryingFloats","gl_MaxVertexAttribs","gl_MaxVertexTextureImageUnits","gl_MaxVertexUniformComponents","gl_ModelViewMatrix","gl_ModelViewMatrixInverse","gl_ModelViewMatrixInverseTranspose","gl_ModelViewMatrixTranspose","gl_ModelViewProjectionMatrix","gl_ModelViewProjectionMatrixInverse","gl_ModelViewProjectionMatrixInverseTranspose","gl_ModelViewProjectionMatrixTranspose","gl_MultiTexCoord0","gl_MultiTexCoord1","gl_MultiTexCoord2","gl_MultiTexCoord3","gl_MultiTexCoord4","gl_MultiTexCoord5","gl_MultiTexCoord6","gl_MultiTexCoord7","gl_Normal","gl_NormalMatrix","gl_NormalScale","gl_ObjectPlaneQ","gl_ObjectPlaneR","gl_ObjectPlaneS","gl_ObjectPlaneT","gl_Point","gl_PointCoord","gl_PointParameters","gl_PointSize","gl_Position","gl_ProjectionMatrix","gl_ProjectionMatrixInverse","gl_ProjectionMatrixInverseTranspose","gl_ProjectionMatrixTranspose","gl_SecondaryColor","gl_TexCoord","gl_TextureEnvColor","gl_TextureMatrix","gl_TextureMatrixInverse","gl_TextureMatrixInverseTranspose","gl_TextureMatrixTranspose","gl_Vertex","greaterThan","greaterThanEqual","inversesqrt","length","lessThan","lessThanEqual","log","log2","matrixCompMult","max","min","mix","mod","normalize","not","notEqual","pow","radians","reflect","refract","sign","sin","smoothstep","sqrt","step","tan","texture2D","texture2DLod","texture2DProj","texture2DProjLod","textureCube","textureCubeLod","texture2DLodEXT","texture2DProjLodEXT","textureCubeLodEXT","texture2DGradEXT","texture2DProjGradEXT","textureCubeGradEXT","textureSize","texelFetch"];var i=999,l=9999,s=0,c=1,u=2,d=3,g=4,p=5,f=6,_=7,h=8,x=9,m=10,y=11,w=["block-comment","line-comment","preprocessor","operator","integer","float","ident","builtin","keyword","whitespace","eof","integer"];function M(){var e,t,r,M=0,v=0,T=i,b=[],P=[],E=1,C=0,D=0,k=!1,j=!1,F="";return function(e){return P=[],null!==e?S(e.replace?e.replace(/\r\n/g,"\n"):e):R()};function L(e){e.length&&P.push({type:w[T],data:e,position:D,line:E,column:C})}function S(t){var a;for(M=0,r=(F+=t).length;e=F[M],M<r;){switch(a=M,T){case s:M=I();break;case c:M=G();break;case u:M=A();break;case d:M=O();break;case g:M=B();break;case y:M=q();break;case p:M=H();break;case l:M=N();break;case x:M=X();break;case i:M=V()}if(a!==M)if("\n"===F[a])C=0,++E;else++C}return v+=M,F=F.slice(M),P}function R(e){return b.length&&L(b.join("")),T=m,L("(eof)"),P}function V(){return b=b.length?[]:b,"/"===t&&"*"===e?(D=v+M-1,T=s,t=e,M+1):"/"===t&&"/"===e?(D=v+M-1,T=c,t=e,M+1):"#"===e?(T=u,D=v+M,M):/\s/.test(e)?(T=x,D=v+M,M):(k=/\d/.test(e),j=/[^\w_]/.test(e),D=v+M,T=k?g:j?d:l,M)}function X(){return/[^\s]/g.test(e)?(L(b.join("")),T=i,M):(b.push(e),t=e,M+1)}function A(){return"\r"!==e&&"\n"!==e||"\\"===t?(b.push(e),t=e,M+1):(L(b.join("")),T=i,M)}function G(){return A()}function I(){return"/"===e&&"*"===t?(b.push(e),L(b.join("")),T=i,M+1):(b.push(e),t=e,M+1)}function O(){if("."===t&&/\d/.test(e))return T=p,M;if("/"===t&&"*"===e)return T=s,M;if("/"===t&&"/"===e)return T=c,M;if("."===e&&b.length){for(;U(b););return T=p,M}if(";"===e||")"===e||"("===e){if(b.length)for(;U(b););return L(e),T=i,M+1}var r=2===b.length&&"="!==e;if(/[\w_\d\s]/.test(e)||r){for(;U(b););return T=i,M}return b.push(e),t=e,M+1}function U(e){for(var t,r,a=0;;){if(t=o.indexOf(e.slice(0,e.length+a).join("")),r=o[t],-1===t){if(a--+e.length>0)continue;r=e.slice(0,1).join("")}return L(r),D+=r.length,(b=b.slice(r.length)).length}}function q(){return/[^a-fA-F0-9]/.test(e)?(L(b.join("")),T=i,M):(b.push(e),t=e,M+1)}function B(){return"."===e||/[eE]/.test(e)?(b.push(e),T=p,t=e,M+1):"x"===e&&1===b.length&&"0"===b[0]?(T=y,b.push(e),t=e,M+1):/[^\d]/.test(e)?(L(b.join("")),T=i,M):(b.push(e),t=e,M+1)}function H(){return"f"===e&&(b.push(e),t=e,M+=1),/[eE]/.test(e)||"-"===e&&/[eE]/.test(t)?(b.push(e),t=e,M+1):/[^\d]/.test(e)?(L(b.join("")),T=i,M):(b.push(e),t=e,M+1)}function N(){if(/[^\d\w_]/.test(e)){var r=b.join("");return T=a.indexOf(r)>-1?h:n.indexOf(r)>-1?_:f,L(b.join("")),T=i,M}return b.push(e),t=e,M+1}}function v(e){var t=M(),r=[];return r=(r=r.concat(t(e))).concat(t(null))}function T(e){return v(e)}function b(e){return e.map((e=>"eof"!==e.type?e.data:"")).join("")}const P=new Set(["GL_OES_standard_derivatives","GL_EXT_frag_depth","GL_EXT_draw_buffers","GL_EXT_shader_texture_lod"]);function E(e,t="100",r="300 es"){const a=/^\s*#version\s+([0-9]+(\s+[a-zA-Z]+)?)\s*/;for(const o of e)if("preprocessor"===o.type){const e=a.exec(o.data);if(e){const a=e[1].replaceAll(/\s{2,}/g," ");if(a===r)return a;if(a===t)return o.data="#version "+r,t;throw new Error("unknown glsl version: "+a)}}return e.splice(0,0,{type:"preprocessor",data:"#version "+r},{type:"whitespace",data:"\n"}),null}function C(e,t){for(let r=t-1;r>=0;r--){const t=e[r];if("whitespace"!==t.type&&"block-comment"!==t.type){if("keyword"!==t.type)break;if("attribute"===t.data||"in"===t.data)return!0}}return!1}function D(e,t,r,a){a=a||r;for(const o of e)if("ident"===o.type&&o.data===r){a in t?t[a]++:t[a]=0;return D(e,t,a+"_"+t[a],a)}return r}function k(e,t,r="afterVersion"){function a(e,t){for(let r=t;r<e.length;r++){const t=e[r];if("operator"===t.type&&";"===t.data)return r}return null}function o(e){let t=-1,o=0,n=-1;for(let i=0;i<e.length;i++){const l=e[i];if("preprocessor"===l.type&&(/#(if|ifdef|ifndef)\s+.+/.test(l.data)?++o:/#endif\s*.*/.test(l.data)&&--o),"afterVersion"!==r&&"afterPrecision"!==r||"preprocessor"===l.type&&l.data.startsWith("#version")&&(n=Math.max(n,i)),"afterPrecision"===r&&"keyword"===l.type&&"precision"===l.data){const t=a(e,i);if(null===t)throw new Error("precision statement not followed by any semicolons!");n=Math.max(n,t)}t<n&&0===o&&(t=i)}return t+1}const n={data:"\n",type:"whitespace"},i=t=>t<e.length&&/[^\r\n]$/.test(e[t].data);let l=o(e);i(l-1)&&e.splice(l++,0,n);for(const s of t)e.splice(l++,0,s);i(l-1)&&i(l)&&e.splice(l,0,n)}function j(e,t,r,a="lowp"){k(e,[{type:"keyword",data:"out"},{type:"whitespace",data:" "},{type:"keyword",data:a},{type:"whitespace",data:" "},{type:"keyword",data:r},{type:"whitespace",data:" "},{type:"ident",data:t},{type:"operator",data:";"}],"afterPrecision")}function F(e,t,r,a,o="lowp"){k(e,[{type:"keyword",data:"layout"},{type:"operator",data:"("},{type:"keyword",data:"location"},{type:"whitespace",data:" "},{type:"operator",data:"="},{type:"whitespace",data:" "},{type:"integer",data:a.toString()},{type:"operator",data:")"},{type:"whitespace",data:" "},{type:"keyword",data:"out"},{type:"whitespace",data:" "},{type:"keyword",data:o},{type:"whitespace",data:" "},{type:"keyword",data:r},{type:"whitespace",data:" "},{type:"ident",data:t},{type:"operator",data:";"}],"afterPrecision")}function L(e,t){let r,a,o=-1;for(let n=t;n<e.length;n++){const t=e[n];if("operator"===t.type&&("["===t.data&&(r=n),"]"===t.data)){a=n;break}"integer"===t.type&&(o=parseInt(t.data,10))}return r&&a&&e.splice(r,a-r+1),o}function S(r,a){if(r.startsWith("#version 300"))return r;const o=V(r);if(null!=o)return o;const n=T(r);if("300 es"===E(n,"100","300 es"))return r;let i=null,l=null;const s={},c={};for(let u=0;u<n.length;++u){const r=n[u];switch(r.type){case"keyword":a===e.VERTEX_SHADER&&"attribute"===r.data?r.data="in":"varying"===r.data&&(r.data=a===e.VERTEX_SHADER?"out":"in");break;case"builtin":if(/^texture(2D|Cube)(Proj)?(Lod|Grad)?(EXT)?$/.test(r.data.trim())&&(r.data=r.data.replaceAll(/(2D|Cube|EXT)/g,"")),a===e.FRAGMENT_SHADER&&"gl_FragColor"===r.data&&(i||(i=D(n,s,"fragColor"),j(n,i,"vec4")),r.data=i),a===e.FRAGMENT_SHADER&&"gl_FragData"===r.data){const e=L(n,u+1),t=D(n,s,"fragData");F(n,t,"vec4",e,"mediump"),r.data=t}else a===e.FRAGMENT_SHADER&&"gl_FragDepthEXT"===r.data&&(l||(l=D(n,s,"gl_FragDepth")),r.data=l);break;case"ident":if(t.includes(r.data)){if(a===e.VERTEX_SHADER&&C(n,u))throw new Error("attribute in vertex shader uses a name that is a reserved word in glsl 300 es");r.data in c||(c[r.data]=D(n,s,r.data)),r.data=c[r.data]}}}for(let e=n.length-1;e>=0;--e){const t=n[e];if("preprocessor"===t.type){const r=t.data.match(/#extension\s+(.*):/);if(r?.[1]&&P.has(r[1].trim())){const t=n[e+1];n.splice(e,t&&"whitespace"===t.type?2:1)}const a=t.data.match(/#ifdef\s+(.*)/);a?.[1]&&P.has(a[1].trim())&&(t.data="#if 1");const o=t.data.match(/#ifndef\s+(.*)/);o?.[1]&&P.has(o[1].trim())&&(t.data="#if 0")}}return X(r,b(n))}const R=new Map;function V(e){return r.enableCache?R.get(e):null}function X(e,t){return r.enableCache&&R.set(e,t),t}export{S as transpileShader};
|
package/views/webgl/Texture.js
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import t from"../../core/Error.js";import"../../core/has.js";import e from"../../core/Logger.js";import{abortMaybe as i}from"../../core/maybe.js";import{isAbortError as r}from"../../core/promiseUtils.js";import{signal as s}from"../../core/signal.js";import{checkWebGLError as o}from"./checkWebGLError.js";import{TextureType as a,ResourceType as n,CompressedTextureFormat as l,TextureSamplingMode as p}from"./enums.js";import{GLObjectType as m}from"./GLObjectType.js";import{estimateMemory as h}from"./TextureDescriptor.js";import{isCompressedData as _,deriveInternalFormat as d,isTexImageSource as c,is3DTarget as u,validateTexture as g,isCompressedFormat as T,getDimensions as x,calcMipmapLevels as E,isSizedPixelFormat as M}from"./textureUtils.js";import{ValidatedTextureDescriptor as A}from"./ValidatedTextureDescriptor.js";const I=null,f=()=>e.getLogger("esri/views/webgl/Texture");let w=class e{static{this.TEXTURE_UNIT_FOR_UPDATES=0}static{this.compressionWorkerHandle=null}constructor(e,i=null,r=null){if(this.type=m.Texture,this._glName=null,this._samplingModeDirty=!1,this._wrapModeDirty=!1,this._wasImmutablyAllocated=!1,this._compressionAbortController=s(null),"context"in e)this._descriptor=e,r=i;else{const r=A.validate(e,i);if(!r)throw new t("Texture descriptor invalid");this._descriptor=r}this._descriptor.target===a.TEXTURE_CUBE_MAP?this._setDataCubeMap(r):this.setData(r)}get glName(){return this._glName}get descriptor(){return this._descriptor}get usedMemory(){return h(this._descriptor)}get cachedMemory(){return this.usedMemory}get isDirty(){return this._samplingModeDirty||this._wrapModeDirty}get isCompressing(){return null!==this._compressionAbortController.value}dispose(){this.abortCompression(),this._descriptor.context.gl&&this._glName&&(this._descriptor.context.instanceCounter.decrement(n.Texture,this),this._descriptor.context.unbindTexture(this),this._descriptor.context.gl.deleteTexture(this._glName),this._glName=null)}release(){this.dispose()}resize(e,i){const r=this._descriptor;if(r.width!==e||r.height!==i){if(this._wasImmutablyAllocated)throw new t("Immutable textures can't be resized!");r.width=e,r.height=i,this._descriptor.target===a.TEXTURE_CUBE_MAP?this._setDataCubeMap(null):this.setData(null)}}enableCompression(t){this._descriptor.shouldCompress=t}setData(t){this.abortCompression(),!_(t)&&this._descriptor.internalFormat&&this._descriptor.internalFormat in l&&(this._descriptor.internalFormat=void 0),this._setData(t),!_(t)&&this._descriptor.shouldCompress&&this._compressOnWorker(t)}updateData(i,r,s,o,a,n,l=0){n||f().error("An attempt to use uninitialized data!"),this._glName||f().error("An attempt to update uninitialized texture!");const p=this._descriptor;p.internalFormat=d(p);const{context:m,pixelFormat:h,dataType:u,target:g,isImmutable:T}=p;if(T&&!this._wasImmutablyAllocated)throw new t("Cannot update immutable texture before allocation!");const x=m.bindTexture(this,e.TEXTURE_UNIT_FOR_UPDATES,!0);(r<0||s<0||r+o>p.width||s+a>p.height)&&f().error("An attempt to update out of bounds of the texture!"),this._configurePixelStorage();const{gl:E}=m;l&&(o&&a||f().warn("Must pass width and height if `UNPACK_SKIP_ROWS` is used"),E.pixelStorei(E.UNPACK_SKIP_ROWS,l)),c(n)?E.texSubImage2D(g,i,r,s,o,a,h,u,n):_(n)?E.compressedTexSubImage2D(g,i,r,s,o,a,p.internalFormat,n.levels[i]):E.texSubImage2D(g,i,r,s,o,a,h,u,n),l&&E.pixelStorei(E.UNPACK_SKIP_ROWS,0),m.bindTexture(x,e.TEXTURE_UNIT_FOR_UPDATES)}updateData3D(i,r,s,o,a,n,l,p){p||f().error("An attempt to use uninitialized data!"),this._glName||f().error("An attempt to update an uninitialized texture!");const m=this._descriptor;m.internalFormat=d(m);const{context:h,pixelFormat:c,dataType:g,isImmutable:T,target:x}=m;if(T&&!this._wasImmutablyAllocated)throw new t("Cannot update immutable texture before allocation!");u(x)||f().warn("Attempting to set 3D texture data on a non-3D texture");const E=h.bindTexture(this,e.TEXTURE_UNIT_FOR_UPDATES);h.setActiveTexture(e.TEXTURE_UNIT_FOR_UPDATES),(r<0||s<0||o<0||r+a>m.width||s+n>m.height||o+l>m.depth)&&f().error("An attempt to update out of bounds of the texture!"),this._configurePixelStorage();const{gl:M}=h;if(_(p))p=p.levels[i],M.compressedTexSubImage3D(x,i,r,s,o,a,n,l,m.internalFormat,p);else{const t=p;M.texSubImage3D(x,i,r,s,o,a,n,l,c,g,t)}h.bindTexture(E,e.TEXTURE_UNIT_FOR_UPDATES)}generateMipmap(){const i=this._descriptor;if(0===i.width||0===i.height)return;if(!i.hasMipmap){if(this._wasImmutablyAllocated)throw new t("Cannot add mipmaps to immutable texture after allocation");i.hasMipmap=!0,this._samplingModeDirty=!0,g(i)}i.samplingMode===p.LINEAR?(this._samplingModeDirty=!0,i.samplingMode=p.LINEAR_MIPMAP_NEAREST):i.samplingMode===p.NEAREST&&(this._samplingModeDirty=!0,i.samplingMode=p.NEAREST_MIPMAP_NEAREST);const r=this._descriptor.context.bindTexture(this,e.TEXTURE_UNIT_FOR_UPDATES);this._descriptor.context.setActiveTexture(e.TEXTURE_UNIT_FOR_UPDATES),this._descriptor.context.gl.generateMipmap(i.target),this._descriptor.context.bindTexture(r,e.TEXTURE_UNIT_FOR_UPDATES)}clearMipmap(){const e=this._descriptor;if(e.hasMipmap){if(this._wasImmutablyAllocated)throw new t("Cannot delete mipmaps to immutable texture after allocation");e.hasMipmap=!1,this._samplingModeDirty=!0,g(e)}e.samplingMode===p.LINEAR_MIPMAP_NEAREST?(this._samplingModeDirty=!0,e.samplingMode=p.LINEAR):e.samplingMode===p.NEAREST_MIPMAP_NEAREST&&(this._samplingModeDirty=!0,e.samplingMode=p.NEAREST)}setSamplingMode(t){t!==this._descriptor.samplingMode&&(this._descriptor.samplingMode=t,this._samplingModeDirty=!0)}setWrapMode(t){t!==this._descriptor.wrapMode&&(this._descriptor.wrapMode=t,g(this._descriptor),this._wrapModeDirty=!0)}applyChanges(){this._samplingModeDirty&&(this._applySamplingMode(),this._samplingModeDirty=!1),this._wrapModeDirty&&(this._applyWrapMode(),this._wrapModeDirty=!1)}abortCompression(){this.isCompressing&&(this._compressionAbortController.value=i(this._compressionAbortController.value))}_setData(i,r){const s=this._descriptor,a=s.context?.gl;if(!a)return;o(a),this._glName||(this._glName=a.createTexture(),s.context.instanceCounter.increment(n.Texture,this)),g(s);const l=s.context.bindTexture(this,e.TEXTURE_UNIT_FOR_UPDATES);s.context.setActiveTexture(e.TEXTURE_UNIT_FOR_UPDATES),this._configurePixelStorage(),o(a);const p=r??s.target,m=u(p);if(c(i))this._setDataFromTexImageSource(i,p);else{const{width:e,height:r,depth:n}=s;if(null==e||null==r)throw new t("Width and height must be specified!");if(m&&null==n)throw new t("Depth must be specified!");if(s.internalFormat=d(s),s.isImmutable&&!this._wasImmutablyAllocated&&this._texStorage(p,s.internalFormat,s.hasMipmap,e,r,n),_(i)){if(!T(s.internalFormat))throw new t("Attempting to use compressed data with an uncompressed format!");this._setDataFromCompressedSource(i,s.internalFormat,p)}else this._texImage(p,0,s.internalFormat,e,r,n,i),o(a),s.hasMipmap&&this.generateMipmap()}this._applySamplingMode(),this._applyWrapMode(),this._applyAnisotropicFilteringParameters(),o(a),s.context.bindTexture(l,e.TEXTURE_UNIT_FOR_UPDATES)}_setDataCubeMap(t=null){for(let e=a.TEXTURE_CUBE_MAP_POSITIVE_X;e<=a.TEXTURE_CUBE_MAP_NEGATIVE_Z;e++)this._setData(t,e)}_configurePixelStorage(){const t=this._descriptor.context.gl,{unpackAlignment:e,flipped:i,preMultiplyAlpha:r}=this._descriptor;t.pixelStorei(t.UNPACK_ALIGNMENT,e),t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,i?1:0),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,r?1:0)}_setDataFromTexImageSource(t,e){const{gl:i}=this._descriptor.context,r=this._descriptor;r.internalFormat=d(r);const s=u(e),{width:a,height:n,depth:l}=x(t);r.width&&r.height,r.width||(r.width=a),r.height||(r.height=n),s&&r.depth,s&&(r.depth=l),r.isImmutable&&!this._wasImmutablyAllocated&&this._texStorage(e,r.internalFormat,r.hasMipmap,a,n,l),this._texImage(e,0,r.internalFormat,a,n,l,t),o(i),r.hasMipmap&&(this.generateMipmap(),o(i))}_setDataFromCompressedSource(t,e,i){const r=this._descriptor,{width:s,height:o,depth:a}=r,n=t.levels,l=E(i,s,o,a),p=Math.min(l,n.length)-1;this._descriptor.context.gl.texParameteri(r.target,r.context.gl.TEXTURE_MAX_LEVEL,p),this._forEachMipmapLevel(((t,r,s,o)=>{const a=n[Math.min(t,n.length-1)];this._compressedTexImage(i,t,e,r,s,o,a)}),p)}_texStorage(e,i,r,s,o,a){const{gl:n}=this._descriptor.context;if(!M(i))throw new t("Immutable textures must have a sized internal format");if(!this._descriptor.isImmutable)return;const l=r?E(e,s,o,a):1;if(u(e)){if(null==a)throw new t("Missing depth dimension for 3D texture upload");n.texStorage3D(e,l,i,s,o,a)}else n.texStorage2D(e,l,i,s,o);this._wasImmutablyAllocated=!0}_texImage(e,i,r,s,o,a,n){const l=this._descriptor.context.gl,p=u(e),{isImmutable:m,pixelFormat:h,dataType:_}=this._descriptor;if(m){if(null!=n){const r=n;if(p){if(null==a)throw new t("Missing depth dimension for 3D texture upload");l.texSubImage3D(e,i,0,0,0,s,o,a,h,_,r)}else l.texSubImage2D(e,i,0,0,s,o,h,_,r)}}else{const m=n;if(p){if(null==a)throw new t("Missing depth dimension for 3D texture upload");l.texImage3D(e,i,r,s,o,a,0,h,_,m)}else l.texImage2D(e,i,r,s,o,0,h,_,m)}}_compressedTexImage(e,i,r,s,o,a,n){const l=this._descriptor.context.gl,p=u(e);if(this._descriptor.isImmutable){if(null!=n)if(p){if(null==a)throw new t("Missing depth dimension for 3D texture upload");l.compressedTexSubImage3D(e,i,0,0,0,s,o,a,r,n)}else l.compressedTexSubImage2D(e,i,0,0,s,o,r,n)}else if(p){if(null==a)throw new t("Missing depth dimension for 3D texture upload");l.compressedTexImage3D(e,i,r,s,o,a,0,n)}else l.compressedTexImage2D(e,i,r,s,o,0,n)}async _compressOnWorker(t){if(!e.compressionWorkerHandle||!e.compressionWorkerHandle.isCompressible(t))return;const i=this._descriptor.context?.gl.getExtension("WEBGL_compressed_texture_etc"),s=this._descriptor.context?.gl.getExtension("WEBGL_compressed_texture_s3tc");if(i||s){const o=new AbortController;this._compressionAbortController.value=o;const a={data:await createImageBitmap(t),flipped:this.descriptor.flipped,width:t.width,height:t.height,hasMipmap:this._descriptor.hasMipmap,hasETC:!!i,hasS3TC:!!s};e.compressionWorkerHandle.invoke(a,this._compressionAbortController.value.signal).then((t=>{t&&this.isCompressing&&this.glName&&(this._descriptor.internalFormat=t.internalFormat,this._setData(t.compressedTexture)),o===this._compressionAbortController.value&&(this._compressionAbortController.value=null)})).catch((t=>{r(t)||o!==this._compressionAbortController.value||(this._compressionAbortController.value=null)}))}}_forEachMipmapLevel(e,i=1/0){let{width:r,height:s,depth:o,hasMipmap:n,target:l}=this._descriptor;const p=l===a.TEXTURE_3D;if(null==r||null==s||p&&null==o)throw new t("Missing texture dimensions for mipmap calculation");for(let t=0;e(t,r,s,o),n&&(1!==r||1!==s||p&&1!==o)&&!(t>=i);++t)r=Math.max(1,r>>1),s=Math.max(1,s>>1),p&&(o=Math.max(1,o>>1))}_applySamplingMode(){const t=this._descriptor,e=t.context?.gl;let i=t.samplingMode,r=t.samplingMode;i===p.LINEAR_MIPMAP_NEAREST||i===p.LINEAR_MIPMAP_LINEAR?(i=p.LINEAR,t.hasMipmap||(r=p.LINEAR)):i!==p.NEAREST_MIPMAP_NEAREST&&i!==p.NEAREST_MIPMAP_LINEAR||(i=p.NEAREST,t.hasMipmap||(r=p.NEAREST)),e.texParameteri(t.target,e.TEXTURE_MAG_FILTER,i),e.texParameteri(t.target,e.TEXTURE_MIN_FILTER,r)}_applyWrapMode(){const t=this._descriptor,e=t.context?.gl;"number"==typeof t.wrapMode?(e.texParameteri(t.target,e.TEXTURE_WRAP_S,t.wrapMode),e.texParameteri(t.target,e.TEXTURE_WRAP_T,t.wrapMode)):(e.texParameteri(t.target,e.TEXTURE_WRAP_S,t.wrapMode.s),e.texParameteri(t.target,e.TEXTURE_WRAP_T,t.wrapMode.t))}_applyAnisotropicFilteringParameters(){const t=this._descriptor,e=t.context.capabilities.textureFilterAnisotropic;if(!e)return;t.context.gl.texParameterf(t.target,e.TEXTURE_MAX_ANISOTROPY,t.maxAnisotropy??1)}};export{w as Texture,I as tracer};
|
|
5
|
+
import t from"../../core/Error.js";import"../../core/has.js";import e from"../../core/Logger.js";import{abortMaybe as i}from"../../core/maybe.js";import{isAbortError as r}from"../../core/promiseUtils.js";import{signal as s}from"../../core/signal.js";import{checkWebGLError as o}from"./checkWebGLError.js";import{TextureType as a,ResourceType as n,CompressedTextureFormat as l,TextureSamplingMode as p,TextureConstants as m}from"./enums.js";import{GLObjectType as h}from"./GLObjectType.js";import{estimateMemory as _}from"./TextureDescriptor.js";import{isCompressedData as d,deriveInternalFormat as c,isTexImageSource as u,is3DTarget as g,validateTexture as T,isCompressedFormat as x,getDimensions as E,calcMipmapLevels as M,isSizedPixelFormat as A}from"./textureUtils.js";import{ValidatedTextureDescriptor as I}from"./ValidatedTextureDescriptor.js";const f=null,w=()=>e.getLogger("esri/views/webgl/Texture");let b=class e{static{this.TEXTURE_UNIT_FOR_UPDATES=0}static{this.compressionWorkerHandle=null}constructor(e,i=null,r=null){if(this.type=h.Texture,this._glName=null,this._samplingModeDirty=!1,this._wrapModeDirty=!1,this._wasImmutablyAllocated=!1,this._compressionAbortController=s(null),"context"in e)this._descriptor=e,r=i;else{const r=I.validate(e,i);if(!r)throw new t("Texture descriptor invalid");this._descriptor=r}this._descriptor.target===a.TEXTURE_CUBE_MAP?this._setDataCubeMap(r):this.setData(r)}get glName(){return this._glName}get descriptor(){return this._descriptor}get usedMemory(){return _(this._descriptor)}get cachedMemory(){return this.usedMemory}get isDirty(){return this._samplingModeDirty||this._wrapModeDirty}get isCompressing(){return null!==this._compressionAbortController.value}dispose(){this.abortCompression(),this._descriptor.context.gl&&this._glName&&(this._descriptor.context.instanceCounter.decrement(n.Texture,this),this._descriptor.context.unbindTexture(this),this._descriptor.context.gl.deleteTexture(this._glName),this._glName=null)}release(){this.dispose()}resize(e,i){const r=this._descriptor;if(r.width!==e||r.height!==i){if(this._wasImmutablyAllocated)throw new t("Immutable textures can't be resized!");r.width=e,r.height=i,this._descriptor.target===a.TEXTURE_CUBE_MAP?this._setDataCubeMap(null):this.setData(null)}}enableCompression(t){this._descriptor.shouldCompress=t}setData(t){this.abortCompression(),!d(t)&&this._descriptor.internalFormat&&this._descriptor.internalFormat in l&&(this._descriptor.internalFormat=void 0),this._setData(t),!d(t)&&this._descriptor.shouldCompress&&this._compressOnWorker(t)}updateData(i,r,s,o,a,n,l=0){n||w().error("An attempt to use uninitialized data!"),this._glName||w().error("An attempt to update uninitialized texture!");const p=this._descriptor;p.internalFormat=c(p);const{context:m,pixelFormat:h,dataType:_,target:g,isImmutable:T}=p;if(T&&!this._wasImmutablyAllocated)throw new t("Cannot update immutable texture before allocation!");const x=m.bindTexture(this,e.TEXTURE_UNIT_FOR_UPDATES,!0);(r<0||s<0||r+o>p.width||s+a>p.height)&&w().error("An attempt to update out of bounds of the texture!"),this._configurePixelStorage();const{gl:E}=m;l&&(o&&a||w().warn("Must pass width and height if `UNPACK_SKIP_ROWS` is used"),E.pixelStorei(E.UNPACK_SKIP_ROWS,l)),u(n)?E.texSubImage2D(g,i,r,s,o,a,h,_,n):d(n)?E.compressedTexSubImage2D(g,i,r,s,o,a,p.internalFormat,n.levels[i]):E.texSubImage2D(g,i,r,s,o,a,h,_,n),l&&E.pixelStorei(E.UNPACK_SKIP_ROWS,0),m.bindTexture(x,e.TEXTURE_UNIT_FOR_UPDATES)}updateData3D(i,r,s,o,a,n,l,p){p||w().error("An attempt to use uninitialized data!"),this._glName||w().error("An attempt to update an uninitialized texture!");const m=this._descriptor;m.internalFormat=c(m);const{context:h,pixelFormat:_,dataType:u,isImmutable:T,target:x}=m;if(T&&!this._wasImmutablyAllocated)throw new t("Cannot update immutable texture before allocation!");g(x)||w().warn("Attempting to set 3D texture data on a non-3D texture");const E=h.bindTexture(this,e.TEXTURE_UNIT_FOR_UPDATES);h.setActiveTexture(e.TEXTURE_UNIT_FOR_UPDATES),(r<0||s<0||o<0||r+a>m.width||s+n>m.height||o+l>m.depth)&&w().error("An attempt to update out of bounds of the texture!"),this._configurePixelStorage();const{gl:M}=h;if(d(p))p=p.levels[i],M.compressedTexSubImage3D(x,i,r,s,o,a,n,l,m.internalFormat,p);else{const t=p;M.texSubImage3D(x,i,r,s,o,a,n,l,_,u,t)}h.bindTexture(E,e.TEXTURE_UNIT_FOR_UPDATES)}generateMipmap(){const i=this._descriptor;if(0===i.width||0===i.height)return;if(!i.hasMipmap){if(this._wasImmutablyAllocated)throw new t("Cannot add mipmaps to immutable texture after allocation");i.hasMipmap=!0,this._samplingModeDirty=!0,T(i)}i.samplingMode===p.LINEAR?(this._samplingModeDirty=!0,i.samplingMode=p.LINEAR_MIPMAP_NEAREST):i.samplingMode===p.NEAREST&&(this._samplingModeDirty=!0,i.samplingMode=p.NEAREST_MIPMAP_NEAREST);const r=this._descriptor.context.bindTexture(this,e.TEXTURE_UNIT_FOR_UPDATES);this._descriptor.context.setActiveTexture(e.TEXTURE_UNIT_FOR_UPDATES),this._descriptor.context.gl.generateMipmap(i.target),this._descriptor.context.bindTexture(r,e.TEXTURE_UNIT_FOR_UPDATES)}clearMipmap(){const e=this._descriptor;if(e.hasMipmap){if(this._wasImmutablyAllocated)throw new t("Cannot delete mipmaps to immutable texture after allocation");e.hasMipmap=!1,this._samplingModeDirty=!0,T(e)}e.samplingMode===p.LINEAR_MIPMAP_NEAREST?(this._samplingModeDirty=!0,e.samplingMode=p.LINEAR):e.samplingMode===p.NEAREST_MIPMAP_NEAREST&&(this._samplingModeDirty=!0,e.samplingMode=p.NEAREST)}setSamplingMode(t){t!==this._descriptor.samplingMode&&(this._descriptor.samplingMode=t,this._samplingModeDirty=!0)}setWrapMode(t){t!==this._descriptor.wrapMode&&(this._descriptor.wrapMode=t,T(this._descriptor),this._wrapModeDirty=!0)}applyChanges(){this._samplingModeDirty&&(this._applySamplingMode(),this._samplingModeDirty=!1),this._wrapModeDirty&&(this._applyWrapMode(),this._wrapModeDirty=!1)}abortCompression(){this.isCompressing&&(this._compressionAbortController.value=i(this._compressionAbortController.value))}_setData(i,r){const s=this._descriptor,a=s.context?.gl;if(!a)return;o(a),this._glName||(this._glName=a.createTexture(),s.context.instanceCounter.increment(n.Texture,this)),T(s);const l=s.context.bindTexture(this,e.TEXTURE_UNIT_FOR_UPDATES);s.context.setActiveTexture(e.TEXTURE_UNIT_FOR_UPDATES),this._configurePixelStorage(),o(a);const p=r??s.target,m=g(p);if(u(i))this._setDataFromTexImageSource(i,p);else{const{width:e,height:r,depth:n}=s;if(null==e||null==r)throw new t("Width and height must be specified!");if(m&&null==n)throw new t("Depth must be specified!");if(s.internalFormat=c(s),s.isImmutable&&!this._wasImmutablyAllocated&&this._texStorage(p,s.internalFormat,s.hasMipmap,e,r,n),d(i)){if(!x(s.internalFormat))throw new t("Attempting to use compressed data with an uncompressed format!");this._setDataFromCompressedSource(i,s.internalFormat,p)}else this._texImage(p,0,s.internalFormat,e,r,n,i),o(a),s.hasMipmap&&this.generateMipmap()}this._applySamplingMode(),this._applyWrapMode(),this._applyAnisotropicFilteringParameters(),o(a),s.context.bindTexture(l,e.TEXTURE_UNIT_FOR_UPDATES)}_setDataCubeMap(t=null){for(let e=a.TEXTURE_CUBE_MAP_POSITIVE_X;e<=a.TEXTURE_CUBE_MAP_NEGATIVE_Z;e++)this._setData(t,e)}_configurePixelStorage(){const t=this._descriptor.context.gl,{unpackAlignment:e,flipped:i,preMultiplyAlpha:r}=this._descriptor;t.pixelStorei(t.UNPACK_ALIGNMENT,e),t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,i?1:0),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,r?1:0)}_setDataFromTexImageSource(t,e){const{gl:i}=this._descriptor.context,r=this._descriptor;r.internalFormat=c(r);const s=g(e),{width:a,height:n,depth:l}=E(t);r.width&&r.height,r.width||(r.width=a),r.height||(r.height=n),s&&r.depth,s&&(r.depth=l),r.isImmutable&&!this._wasImmutablyAllocated&&this._texStorage(e,r.internalFormat,r.hasMipmap,a,n,l),this._texImage(e,0,r.internalFormat,a,n,l,t),o(i),r.hasMipmap&&(this.generateMipmap(),o(i))}_setDataFromCompressedSource(t,e,i){const r=this._descriptor,{width:s,height:o,depth:a}=r,n=t.levels,l=M(i,s,o,a),p=Math.min(l,n.length)-1;this._descriptor.context.gl.texParameteri(r.target,m.MAX_LEVEL,p),this._forEachMipmapLevel(((t,r,s,o)=>{const a=n[Math.min(t,n.length-1)];this._compressedTexImage(i,t,e,r,s,o,a)}),p)}_texStorage(e,i,r,s,o,a){const{gl:n}=this._descriptor.context;if(!A(i))throw new t("Immutable textures must have a sized internal format");if(!this._descriptor.isImmutable)return;const l=r?M(e,s,o,a):1;if(g(e)){if(null==a)throw new t("Missing depth dimension for 3D texture upload");n.texStorage3D(e,l,i,s,o,a)}else n.texStorage2D(e,l,i,s,o);this._wasImmutablyAllocated=!0}_texImage(e,i,r,s,o,a,n){const l=this._descriptor.context.gl,p=g(e),{isImmutable:m,pixelFormat:h,dataType:_}=this._descriptor;if(m){if(null!=n){const r=n;if(p){if(null==a)throw new t("Missing depth dimension for 3D texture upload");l.texSubImage3D(e,i,0,0,0,s,o,a,h,_,r)}else l.texSubImage2D(e,i,0,0,s,o,h,_,r)}}else{const m=n;if(p){if(null==a)throw new t("Missing depth dimension for 3D texture upload");l.texImage3D(e,i,r,s,o,a,0,h,_,m)}else l.texImage2D(e,i,r,s,o,0,h,_,m)}}_compressedTexImage(e,i,r,s,o,a,n){const l=this._descriptor.context.gl,p=g(e);if(this._descriptor.isImmutable){if(null!=n)if(p){if(null==a)throw new t("Missing depth dimension for 3D texture upload");l.compressedTexSubImage3D(e,i,0,0,0,s,o,a,r,n)}else l.compressedTexSubImage2D(e,i,0,0,s,o,r,n)}else if(p){if(null==a)throw new t("Missing depth dimension for 3D texture upload");l.compressedTexImage3D(e,i,r,s,o,a,0,n)}else l.compressedTexImage2D(e,i,r,s,o,0,n)}async _compressOnWorker(t){if(!e.compressionWorkerHandle||!e.compressionWorkerHandle.isCompressible(t))return;const i=!!this._descriptor.context.capabilities.compressedTextureETC,s=!!this._descriptor.context.capabilities.compressedTextureS3TC;if(i||s){const o=new AbortController;this._compressionAbortController.value=o;const a={data:await createImageBitmap(t),flipped:this.descriptor.flipped,width:t.width,height:t.height,hasMipmap:this._descriptor.hasMipmap,hasETC:!!i,hasS3TC:!!s};e.compressionWorkerHandle.invoke(a,this._compressionAbortController.value.signal).then((t=>{t&&this.isCompressing&&this.glName&&(this._descriptor.internalFormat=t.internalFormat,this._setData(t.compressedTexture)),o===this._compressionAbortController.value&&(this._compressionAbortController.value=null)})).catch((t=>{r(t)||o!==this._compressionAbortController.value||(this._compressionAbortController.value=null)}))}}_forEachMipmapLevel(e,i=1/0){let{width:r,height:s,depth:o,hasMipmap:n,target:l}=this._descriptor;const p=l===a.TEXTURE_3D;if(null==r||null==s||p&&null==o)throw new t("Missing texture dimensions for mipmap calculation");for(let t=0;e(t,r,s,o),n&&(1!==r||1!==s||p&&1!==o)&&!(t>=i);++t)r=Math.max(1,r>>1),s=Math.max(1,s>>1),p&&(o=Math.max(1,o>>1))}_applySamplingMode(){const t=this._descriptor,e=t.context?.gl;let i=t.samplingMode,r=t.samplingMode;i===p.LINEAR_MIPMAP_NEAREST||i===p.LINEAR_MIPMAP_LINEAR?(i=p.LINEAR,t.hasMipmap||(r=p.LINEAR)):i!==p.NEAREST_MIPMAP_NEAREST&&i!==p.NEAREST_MIPMAP_LINEAR||(i=p.NEAREST,t.hasMipmap||(r=p.NEAREST)),e.texParameteri(t.target,e.TEXTURE_MAG_FILTER,i),e.texParameteri(t.target,e.TEXTURE_MIN_FILTER,r)}_applyWrapMode(){const t=this._descriptor,e=t.context?.gl;"number"==typeof t.wrapMode?(e.texParameteri(t.target,e.TEXTURE_WRAP_S,t.wrapMode),e.texParameteri(t.target,e.TEXTURE_WRAP_T,t.wrapMode)):(e.texParameteri(t.target,e.TEXTURE_WRAP_S,t.wrapMode.s),e.texParameteri(t.target,e.TEXTURE_WRAP_T,t.wrapMode.t))}_applyAnisotropicFilteringParameters(){const t=this._descriptor,e=t.context.capabilities.textureFilterAnisotropic;if(!e)return;t.context.gl.texParameterf(t.target,e.TEXTURE_MAX_ANISOTROPY,t.maxAnisotropy??1)}};export{b as Texture,f as tracer};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{SizedPixelFormat as s,PixelFormat as e}from"./enums.js";import{TextureDescriptor as t}from"./TextureDescriptor.js";class a extends t{constructor(t,a){switch(super(),this.context=t,Object.assign(this,a),this.internalFormat){case s.R16F:case s.
|
|
5
|
+
import{SizedPixelFormat as s,PixelFormat as e}from"./enums.js";import{TextureDescriptor as t}from"./TextureDescriptor.js";class a extends t{constructor(t,a){switch(super(),this.context=t,Object.assign(this,a),this.internalFormat){case s.R16F:case s.R32F:case s.R8_SNORM:case s.R8:this.pixelFormat=e.RED;break;case s.R8I:case s.R8UI:case s.R16I:case s.R16UI:case s.R32I:case s.R32UI:this.pixelFormat=e.RED_INTEGER}}static validate(s,e){return new a(s,e)}}export{a as ValidatedTextureDescriptor};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{loadRendererInfo as e}from"./DebugRendererInfo.js";import{createDisjointTimerQuery as t}from"./DisjointTimerQuery.js";import{loadCompressedTextureETC as s,loadCompressedTextureS3TC as r,loadTextureFilterAnisotropicCapability as i,loadColorBufferFloat as
|
|
5
|
+
import{loadRendererInfo as e}from"./DebugRendererInfo.js";import{createDisjointTimerQuery as t}from"./DisjointTimerQuery.js";import{loadCompressedTextureETC as s,loadCompressedTextureS3TC as r,loadTextureFilterAnisotropicCapability as i,loadColorBufferFloat as l,loadTextureNorm16 as o,loadBooleanExtension as n}from"./load.js";import{load as h}from"./LoseContext.js";class _{constructor(e,t){this._gl=e,this._compressedTextureETC=null,this._compressedTextureS3TC=null,this._textureFilterAnisotropic=null,this._colorBufferFloat=null,this._loseContext=null,this._textureNorm16=null,this._textureFloatLinear=null,this._parallelShaderCompile=null,this._rendererInfo=null,this._disabledExtensions=t.disabledExtensions||{},this._debugWebGLExtensions=t.debugWebGLExtensions||{}}get compressedTextureETC(){return this._compressedTextureETC??=s(this._gl,this._disabledExtensions),this._compressedTextureETC}get compressedTextureS3TC(){return this._compressedTextureS3TC??=r(this._gl,this._disabledExtensions),this._compressedTextureS3TC}get textureFilterAnisotropic(){return this._textureFilterAnisotropic??=i(this._gl,this._disabledExtensions),this._textureFilterAnisotropic}get disjointTimerQuery(){return this._disjointTimerQuery??=t(this._gl,this._disabledExtensions),this._disjointTimerQuery}get colorBufferFloat(){return this._colorBufferFloat??=l(this._gl,this._disabledExtensions),this._colorBufferFloat}get textureNorm16(){return this._textureNorm16??=o(this._gl,this._disabledExtensions),this._textureNorm16}get textureFloatLinear(){return this._textureFloatLinear??=n(this._gl,this._disabledExtensions,"textureFloatLinear",!1,["OES_texture_float_linear"]),this._textureFloatLinear}get parallelShaderCompile(){return this._parallelShaderCompile??=n(this._gl,this._disabledExtensions,"parallelShaderCompile",!1,["KHR_parallel_shader_compile"]),this._parallelShaderCompile}get loseContext(){return this._loseContext??=h(this._gl,this._debugWebGLExtensions),this._loseContext}get rendererInfo(){return this._rendererInfo??=e(this._gl),this._rendererInfo}enable(e){return this[e]}}export{_ as Capabilities};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"../../core/Error.js";import has from"../../core/has.js";import r from"../../core/Logger.js";const
|
|
5
|
+
import e from"../../core/Error.js";import has from"../../core/has.js";import r from"../../core/Logger.js";import{ErrorConstant as o}from"./enums.js";const t=()=>r.getLogger("esri.views.webgl.checkWebGLError");function n(e){switch(e){case o.INVALID_ENUM:return"Invalid Enum. An unacceptable value has been specified for an enumerated argument.";case o.INVALID_VALUE:return"Invalid Value. A numeric argument is out of range.";case o.INVALID_OPERATION:return"Invalid Operation. The specified command is not allowed for the current state.";case o.INVALID_FRAMEBUFFER_OPERATION:return"Invalid Framebuffer operation. The currently bound framebuffer is not framebuffer complete when trying to render to or to read from it.";case o.OUT_OF_MEMORY:return"Out of memory. Not enough memory is left to execute the command.";case o.CONTEXT_LOST_WEBGL:return"WebGL context has been lost";default:return"Unknown error"}}const a=!!has("enable-feature:webgl-debug");function c(){return a}function u(){return a}function s(r){if(c()){const o=r.getError();if(o){const r=n(o),a=(new Error).stack;t().error(new e("webgl-error","WebGL error occurred",{message:r,stack:a}))}}}export{s as checkWebGLError,a as hasFeatureFlagWebGLDebug,c as webglDebugEnabled,u as webglValidateShadersEnabled};
|
package/views/webgl/enums.js
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
var _,E,R,T,A,N,S,C,O,I,L,D,M,G,P,U,B,F,H,n;!function(_){_[_.DEPTH=256]="DEPTH",_[_.STENCIL=1024]="STENCIL",_[_.COLOR=16384]="COLOR"}(_||(_={})),function(_){_[_.POINTS=0]="POINTS",_[_.LINES=1]="LINES",_[_.LINE_LOOP=2]="LINE_LOOP",_[_.LINE_STRIP=3]="LINE_STRIP",_[_.TRIANGLES=4]="TRIANGLES",_[_.TRIANGLE_STRIP=5]="TRIANGLE_STRIP",_[_.TRIANGLE_FAN=6]="TRIANGLE_FAN"}(E||(E={})),function(_){_[_.ZERO=0]="ZERO",_[_.ONE=1]="ONE",_[_.SRC_COLOR=768]="SRC_COLOR",_[_.ONE_MINUS_SRC_COLOR=769]="ONE_MINUS_SRC_COLOR",_[_.SRC_ALPHA=770]="SRC_ALPHA",_[_.ONE_MINUS_SRC_ALPHA=771]="ONE_MINUS_SRC_ALPHA",_[_.DST_ALPHA=772]="DST_ALPHA",_[_.ONE_MINUS_DST_ALPHA=773]="ONE_MINUS_DST_ALPHA",_[_.DST_COLOR=774]="DST_COLOR",_[_.ONE_MINUS_DST_COLOR=775]="ONE_MINUS_DST_COLOR",_[_.SRC_ALPHA_SATURATE=776]="SRC_ALPHA_SATURATE",_[_.CONSTANT_COLOR=32769]="CONSTANT_COLOR",_[_.ONE_MINUS_CONSTANT_COLOR=32770]="ONE_MINUS_CONSTANT_COLOR",_[_.CONSTANT_ALPHA=32771]="CONSTANT_ALPHA",_[_.ONE_MINUS_CONSTANT_ALPHA=32772]="ONE_MINUS_CONSTANT_ALPHA"}(R||(R={})),function(_){_[_.ADD=32774]="ADD",_[_.MIN=32775]="MIN",_[_.MAX=32776]="MAX",_[_.SUBTRACT=32778]="SUBTRACT",_[_.REVERSE_SUBTRACT=32779]="REVERSE_SUBTRACT"}(T||(T={})),function(_){_[_.ARRAY_BUFFER=34962]="ARRAY_BUFFER",_[_.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER",_[_.UNIFORM_BUFFER=35345]="UNIFORM_BUFFER",_[_.PIXEL_PACK_BUFFER=35051]="PIXEL_PACK_BUFFER",_[_.PIXEL_UNPACK_BUFFER=35052]="PIXEL_UNPACK_BUFFER",_[_.COPY_READ_BUFFER=36662]="COPY_READ_BUFFER",_[_.COPY_WRITE_BUFFER=36663]="COPY_WRITE_BUFFER",_[_.TRANSFORM_FEEDBACK_BUFFER=35982]="TRANSFORM_FEEDBACK_BUFFER"}(A||(A={})),function(_){_[_.FRONT=1028]="FRONT",_[_.BACK=1029]="BACK",_[_.FRONT_AND_BACK=1032]="FRONT_AND_BACK"}(N||(N={})),function(_){_[_.CW=2304]="CW",_[_.CCW=2305]="CCW"}(S||(S={})),function(_){_[_.BYTE=5120]="BYTE",_[_.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",_[_.SHORT=5122]="SHORT",_[_.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",_[_.INT=5124]="INT",_[_.UNSIGNED_INT=5125]="UNSIGNED_INT",_[_.FLOAT=5126]="FLOAT",_[_.HALF_FLOAT=5131]="HALF_FLOAT"}(C||(C={})),function(_){_[_.NEVER=512]="NEVER",_[_.LESS=513]="LESS",_[_.EQUAL=514]="EQUAL",_[_.LEQUAL=515]="LEQUAL",_[_.GREATER=516]="GREATER",_[_.NOTEQUAL=517]="NOTEQUAL",_[_.GEQUAL=518]="GEQUAL",_[_.ALWAYS=519]="ALWAYS"}(O||(O={})),function(_){_[_.ZERO=0]="ZERO",_[_.KEEP=7680]="KEEP",_[_.REPLACE=7681]="REPLACE",_[_.INCR=7682]="INCR",_[_.DECR=7683]="DECR",_[_.INVERT=5386]="INVERT",_[_.INCR_WRAP=34055]="INCR_WRAP",_[_.DECR_WRAP=34056]="DECR_WRAP"}(I||(I={})),function(_){_[_.NEAREST=9728]="NEAREST",_[_.LINEAR=9729]="LINEAR",_[_.NEAREST_MIPMAP_NEAREST=9984]="NEAREST_MIPMAP_NEAREST",_[_.LINEAR_MIPMAP_NEAREST=9985]="LINEAR_MIPMAP_NEAREST",_[_.NEAREST_MIPMAP_LINEAR=9986]="NEAREST_MIPMAP_LINEAR",_[_.LINEAR_MIPMAP_LINEAR=9987]="LINEAR_MIPMAP_LINEAR"}(L||(L={})),function(_){_[_.CLAMP_TO_EDGE=33071]="CLAMP_TO_EDGE",_[_.REPEAT=10497]="REPEAT",_[_.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT"}(D||(D={})),function(_){_[_.TEXTURE_2D=3553]="TEXTURE_2D",_[_.TEXTURE_CUBE_MAP=34067]="TEXTURE_CUBE_MAP",_[_.TEXTURE_3D=32879]="TEXTURE_3D",_[_.TEXTURE_CUBE_MAP_POSITIVE_X=34069]="TEXTURE_CUBE_MAP_POSITIVE_X",_[_.TEXTURE_CUBE_MAP_NEGATIVE_X=34070]="TEXTURE_CUBE_MAP_NEGATIVE_X",_[_.TEXTURE_CUBE_MAP_POSITIVE_Y=34071]="TEXTURE_CUBE_MAP_POSITIVE_Y",_[_.TEXTURE_CUBE_MAP_NEGATIVE_Y=34072]="TEXTURE_CUBE_MAP_NEGATIVE_Y",_[_.TEXTURE_CUBE_MAP_POSITIVE_Z=34073]="TEXTURE_CUBE_MAP_POSITIVE_Z",_[_.TEXTURE_CUBE_MAP_NEGATIVE_Z=34074]="TEXTURE_CUBE_MAP_NEGATIVE_Z",_[_.TEXTURE_2D_ARRAY=35866]="TEXTURE_2D_ARRAY"}(M||(M={})),function(_){_[_.DEPTH_COMPONENT=6402]="DEPTH_COMPONENT",_[_.DEPTH_STENCIL=34041]="DEPTH_STENCIL",_[_.DEPTH24_STENCIL8=35056]="DEPTH24_STENCIL8",_[_.ALPHA=6406]="ALPHA",_[_.RGB=6407]="RGB",_[_.RGBA=6408]="RGBA",_[_.LUMINANCE=6409]="LUMINANCE",_[_.LUMINANCE_ALPHA=6410]="LUMINANCE_ALPHA",_[_.RED=6403]="RED",_[_.RG=33319]="RG",_[_.RED_INTEGER=36244]="RED_INTEGER",_[_.RG_INTEGER=33320]="RG_INTEGER",_[_.RGB_INTEGER=36248]="RGB_INTEGER",_[_.RGBA_INTEGER=36249]="RGBA_INTEGER"}(G||(G={})),function(_){_[_.RGBA4=32854]="RGBA4",_[_.R16F=33325]="R16F",_[_.RG16F=33327]="RG16F",_[_.RGB32F=34837]="RGB32F",_[_.RGBA16F=34842]="RGBA16F",_[_.R32F=33326]="R32F",_[_.RG32F=33328]="RG32F",_[_.RGBA32F=34836]="RGBA32F",_[_.R11F_G11F_B10F=35898]="R11F_G11F_B10F",_[_.RGB8=32849]="RGB8",_[_.RGBA8=32856]="RGBA8",_[_.RGB5_A1=32855]="RGB5_A1",_[_.R8=33321]="R8",_[_.RG8=33323]="RG8",_[_.R8I=33329]="R8I",_[_.R8UI=33330]="R8UI",_[_.R16I=33331]="R16I",_[_.R16UI=33332]="R16UI",_[_.R32I=33333]="R32I",_[_.R32UI=33334]="R32UI",_[_.RG8I=33335]="RG8I",_[_.RG8UI=33336]="RG8UI",_[_.RG16I=33337]="RG16I",_[_.RG16UI=33338]="RG16UI",_[_.RG32I=33339]="RG32I",_[_.RG32UI=33340]="RG32UI",_[_.RGB16F=34843]="RGB16F",_[_.RGB9_E5=35901]="RGB9_E5",_[_.SRGB8=35905]="SRGB8",_[_.SRGB8_ALPHA8=35907]="SRGB8_ALPHA8",_[_.RGB565=36194]="RGB565",_[_.RGBA32UI=36208]="RGBA32UI",_[_.RGB32UI=36209]="RGB32UI",_[_.RGBA16UI=36214]="RGBA16UI",_[_.RGB16UI=36215]="RGB16UI",_[_.RGBA8UI=36220]="RGBA8UI",_[_.RGB8UI=36221]="RGB8UI",_[_.RGBA32I=36226]="RGBA32I",_[_.RGB32I=36227]="RGB32I",_[_.RGBA16I=36232]="RGBA16I",_[_.RGB16I=36233]="RGB16I",_[_.RGBA8I=36238]="RGBA8I",_[_.RGB8I=36239]="RGB8I",_[_.R8_SNORM=36756]="R8_SNORM",_[_.RG8_SNORM=36757]="RG8_SNORM",_[_.RGB8_SNORM=36758]="RGB8_SNORM",_[_.RGBA8_SNORM=36759]="RGBA8_SNORM",_[_.RGB10_A2=32857]="RGB10_A2",_[_.RGB10_A2UI=36975]="RGB10_A2UI"}(P||(P={})),function(_){_[_.FLOAT=5126]="FLOAT",_[_.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",_[_.UNSIGNED_INT_24_8=34042]="UNSIGNED_INT_24_8",_[_.UNSIGNED_SHORT_4_4_4_4=32819]="UNSIGNED_SHORT_4_4_4_4",_[_.UNSIGNED_SHORT_5_5_5_1=32820]="UNSIGNED_SHORT_5_5_5_1",_[_.UNSIGNED_SHORT_5_6_5=33635]="UNSIGNED_SHORT_5_6_5",_[_.BYTE=5120]="BYTE",_[_.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",_[_.SHORT=5122]="SHORT",_[_.UNSIGNED_INT=5125]="UNSIGNED_INT",_[_.INT=5124]="INT",_[_.HALF_FLOAT=5131]="HALF_FLOAT",_[_.UNSIGNED_INT_2_10_10_10_REV=33640]="UNSIGNED_INT_2_10_10_10_REV",_[_.UNSIGNED_INT_10F_11F_11F_REV=35899]="UNSIGNED_INT_10F_11F_11F_REV",_[_.UNSIGNED_INT_5_9_9_9_REV=35902]="UNSIGNED_INT_5_9_9_9_REV",_[_.FLOAT_32_UNSIGNED_INT_24_8_REV=36269]="FLOAT_32_UNSIGNED_INT_24_8_REV"}(U||(U={})),function(_){_[_.DEPTH_COMPONENT16=33189]="DEPTH_COMPONENT16",_[_.STENCIL_INDEX8=36168]="STENCIL_INDEX8",_[_.DEPTH_STENCIL=34041]="DEPTH_STENCIL",_[_.DEPTH_COMPONENT24=33190]="DEPTH_COMPONENT24",_[_.DEPTH_COMPONENT32F=36012]="DEPTH_COMPONENT32F",_[_.DEPTH24_STENCIL8=35056]="DEPTH24_STENCIL8",_[_.DEPTH32F_STENCIL8=36013]="DEPTH32F_STENCIL8"}(B||(B={})),function(_){_[_.STATIC_DRAW=35044]="STATIC_DRAW",_[_.DYNAMIC_DRAW=35048]="DYNAMIC_DRAW",_[_.STREAM_DRAW=35040]="STREAM_DRAW",_[_.STATIC_READ=35045]="STATIC_READ",_[_.DYNAMIC_READ=35049]="DYNAMIC_READ",_[_.STREAM_READ=35041]="STREAM_READ",_[_.STATIC_COPY=35046]="STATIC_COPY",_[_.DYNAMIC_COPY=35050]="DYNAMIC_COPY",_[_.STREAM_COPY=35042]="STREAM_COPY"}(F||(F={})),function(_){_[_.FRAGMENT_SHADER=35632]="FRAGMENT_SHADER",_[_.VERTEX_SHADER=35633]="VERTEX_SHADER"}(H||(H={})),function(_){_[_.FRAMEBUFFER=36160]="FRAMEBUFFER",_[_.READ_FRAMEBUFFER=36008]="READ_FRAMEBUFFER",_[_.DRAW_FRAMEBUFFER=36009]="DRAW_FRAMEBUFFER"}(n||(n={}));const Y=33984;var V,X,f;!function(_){_[_.Texture=0]="Texture",_[_.BufferObject=1]="BufferObject",_[_.VertexArrayObject=2]="VertexArrayObject",_[_.Shader=3]="Shader",_[_.Program=4]="Program",_[_.FramebufferObject=5]="FramebufferObject",_[_.Renderbuffer=6]="Renderbuffer",_[_.TransformFeedback=7]="TransformFeedback",_[_.Sync=8]="Sync",_[_.UNCOUNTED=9]="UNCOUNTED",_[_.LinesOfCode=9]="LinesOfCode",_[_.Uniform=10]="Uniform",_[_.COUNT=11]="COUNT"}(V||(V={})),function(_){_[_.COLOR_ATTACHMENT0=36064]="COLOR_ATTACHMENT0",_[_.COLOR_ATTACHMENT1=36065]="COLOR_ATTACHMENT1",_[_.COLOR_ATTACHMENT2=36066]="COLOR_ATTACHMENT2",_[_.COLOR_ATTACHMENT3=36067]="COLOR_ATTACHMENT3",_[_.COLOR_ATTACHMENT4=36068]="COLOR_ATTACHMENT4",_[_.COLOR_ATTACHMENT5=36069]="COLOR_ATTACHMENT5",_[_.COLOR_ATTACHMENT6=36070]="COLOR_ATTACHMENT6",_[_.COLOR_ATTACHMENT7=36071]="COLOR_ATTACHMENT7",_[_.COLOR_ATTACHMENT8=36072]="COLOR_ATTACHMENT8",_[_.COLOR_ATTACHMENT9=36073]="COLOR_ATTACHMENT9",_[_.COLOR_ATTACHMENT10=36074]="COLOR_ATTACHMENT10",_[_.COLOR_ATTACHMENT11=36075]="COLOR_ATTACHMENT11",_[_.COLOR_ATTACHMENT12=36076]="COLOR_ATTACHMENT12",_[_.COLOR_ATTACHMENT13=36077]="COLOR_ATTACHMENT13",_[_.COLOR_ATTACHMENT14=36078]="COLOR_ATTACHMENT14",_[_.COLOR_ATTACHMENT15=36079]="COLOR_ATTACHMENT15"}(X||(X={})),function(_){_[_.NONE=0]="NONE",_[_.BACK=1029]="BACK"}(f||(f={}));const t=33306;var c,o,u,e,i,r,W;!function(_){_[_.COMPRESSED_RGB_S3TC_DXT1_EXT=33776]="COMPRESSED_RGB_S3TC_DXT1_EXT",_[_.COMPRESSED_RGBA_S3TC_DXT1_EXT=33777]="COMPRESSED_RGBA_S3TC_DXT1_EXT",_[_.COMPRESSED_RGBA_S3TC_DXT3_EXT=33778]="COMPRESSED_RGBA_S3TC_DXT3_EXT",_[_.COMPRESSED_RGBA_S3TC_DXT5_EXT=33779]="COMPRESSED_RGBA_S3TC_DXT5_EXT",_[_.COMPRESSED_R11_EAC=37488]="COMPRESSED_R11_EAC",_[_.COMPRESSED_SIGNED_R11_EAC=37489]="COMPRESSED_SIGNED_R11_EAC",_[_.COMPRESSED_RG11_EAC=37490]="COMPRESSED_RG11_EAC",_[_.COMPRESSED_SIGNED_RG11_EAC=37491]="COMPRESSED_SIGNED_RG11_EAC",_[_.COMPRESSED_RGB8_ETC2=37492]="COMPRESSED_RGB8_ETC2",_[_.COMPRESSED_SRGB8_ETC2=37493]="COMPRESSED_SRGB8_ETC2",_[_.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2=37494]="COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2",_[_.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2=37495]="COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2",_[_.COMPRESSED_RGBA8_ETC2_EAC=37496]="COMPRESSED_RGBA8_ETC2_EAC",_[_.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC=37497]="COMPRESSED_SRGB8_ALPHA8_ETC2_EAC"}(c||(c={})),function(_){_[_.FLOAT=5126]="FLOAT",_[_.FLOAT_VEC2=35664]="FLOAT_VEC2",_[_.FLOAT_VEC3=35665]="FLOAT_VEC3",_[_.FLOAT_VEC4=35666]="FLOAT_VEC4",_[_.INT=5124]="INT",_[_.INT_VEC2=35667]="INT_VEC2",_[_.INT_VEC3=35668]="INT_VEC3",_[_.INT_VEC4=35669]="INT_VEC4",_[_.BOOL=35670]="BOOL",_[_.BOOL_VEC2=35671]="BOOL_VEC2",_[_.BOOL_VEC3=35672]="BOOL_VEC3",_[_.BOOL_VEC4=35673]="BOOL_VEC4",_[_.FLOAT_MAT2=35674]="FLOAT_MAT2",_[_.FLOAT_MAT3=35675]="FLOAT_MAT3",_[_.FLOAT_MAT4=35676]="FLOAT_MAT4",_[_.SAMPLER_2D=35678]="SAMPLER_2D",_[_.SAMPLER_CUBE=35680]="SAMPLER_CUBE",_[_.UNSIGNED_INT=5125]="UNSIGNED_INT",_[_.UNSIGNED_INT_VEC2=36294]="UNSIGNED_INT_VEC2",_[_.UNSIGNED_INT_VEC3=36295]="UNSIGNED_INT_VEC3",_[_.UNSIGNED_INT_VEC4=36296]="UNSIGNED_INT_VEC4",_[_.FLOAT_MAT2x3=35685]="FLOAT_MAT2x3",_[_.FLOAT_MAT2x4=35686]="FLOAT_MAT2x4",_[_.FLOAT_MAT3x2=35687]="FLOAT_MAT3x2",_[_.FLOAT_MAT3x4=35688]="FLOAT_MAT3x4",_[_.FLOAT_MAT4x2=35689]="FLOAT_MAT4x2",_[_.FLOAT_MAT4x3=35690]="FLOAT_MAT4x3",_[_.SAMPLER_3D=35679]="SAMPLER_3D",_[_.SAMPLER_2D_SHADOW=35682]="SAMPLER_2D_SHADOW",_[_.SAMPLER_2D_ARRAY=36289]="SAMPLER_2D_ARRAY",_[_.SAMPLER_2D_ARRAY_SHADOW=36292]="SAMPLER_2D_ARRAY_SHADOW",_[_.SAMPLER_CUBE_SHADOW=36293]="SAMPLER_CUBE_SHADOW",_[_.INT_SAMPLER_2D=36298]="INT_SAMPLER_2D",_[_.INT_SAMPLER_3D=36299]="INT_SAMPLER_3D",_[_.INT_SAMPLER_CUBE=36300]="INT_SAMPLER_CUBE",_[_.INT_SAMPLER_2D_ARRAY=36303]="INT_SAMPLER_2D_ARRAY",_[_.UNSIGNED_INT_SAMPLER_2D=36306]="UNSIGNED_INT_SAMPLER_2D",_[_.UNSIGNED_INT_SAMPLER_3D=36307]="UNSIGNED_INT_SAMPLER_3D",_[_.UNSIGNED_INT_SAMPLER_CUBE=36308]="UNSIGNED_INT_SAMPLER_CUBE",_[_.UNSIGNED_INT_SAMPLER_2D_ARRAY=36311]="UNSIGNED_INT_SAMPLER_2D_ARRAY"}(o||(o={})),function(_){_[_.OBJECT_TYPE=37138]="OBJECT_TYPE",_[_.SYNC_CONDITION=37139]="SYNC_CONDITION",_[_.SYNC_STATUS=37140]="SYNC_STATUS",_[_.SYNC_FLAGS=37141]="SYNC_FLAGS"}(u||(u={})),function(_){_[_.UNSIGNALED=37144]="UNSIGNALED",_[_.SIGNALED=37145]="SIGNALED"}(e||(e={})),function(_){_[_.ALREADY_SIGNALED=37146]="ALREADY_SIGNALED",_[_.TIMEOUT_EXPIRED=37147]="TIMEOUT_EXPIRED",_[_.CONDITION_SATISFIED=37148]="CONDITION_SATISFIED",_[_.WAIT_FAILED=37149]="WAIT_FAILED"}(i||(i={})),function(_){_[_.SYNC_GPU_COMMANDS_COMPLETE=37143]="SYNC_GPU_COMMANDS_COMPLETE"}(r||(r={})),function(_){_[_.SYNC_FLUSH_COMMANDS_BIT=1]="SYNC_FLUSH_COMMANDS_BIT"}(W||(W={}));export{R as BlendFactor,T as BlendOperation,A as BufferType,i as ClientWaitSyncStatus,X as ColorAttachment,O as CompareFunction,c as CompressedTextureFormat,S as CullMode,C as DataType,t as DepthStencilAttachment,N as Face,_ as FramebufferBit,n as FramebufferTarget,G as PixelFormat,U as PixelType,E as PrimitiveType,B as RenderbufferFormat,V as ResourceType,H as ShaderType,P as SizedPixelFormat,f as SpecialDrawBuffers,I as StencilOperation,r as SyncCondition,W as SyncFlag,u as SyncParameter,e as SyncStatus,L as TextureSamplingMode,M as TextureType,D as TextureWrapMode,o as UniformType,F as Usage,Y as baseTextureUnit};
|
|
5
|
+
var _,E,R,A,T,N,S,I,O,C,D,L,P,G,U,M,B,F,H,n,V,X;!function(_){_[_.DEPTH=256]="DEPTH",_[_.STENCIL=1024]="STENCIL",_[_.COLOR=16384]="COLOR"}(_||(_={})),function(_){_[_.COLOR=6144]="COLOR",_[_.DEPTH=6145]="DEPTH",_[_.STENCIL=6146]="STENCIL",_[_.DEPTH_STENCIL=34041]="DEPTH_STENCIL"}(E||(E={})),function(_){_[_.POINTS=0]="POINTS",_[_.LINES=1]="LINES",_[_.LINE_LOOP=2]="LINE_LOOP",_[_.LINE_STRIP=3]="LINE_STRIP",_[_.TRIANGLES=4]="TRIANGLES",_[_.TRIANGLE_STRIP=5]="TRIANGLE_STRIP",_[_.TRIANGLE_FAN=6]="TRIANGLE_FAN"}(R||(R={})),function(_){_[_.ZERO=0]="ZERO",_[_.ONE=1]="ONE",_[_.SRC_COLOR=768]="SRC_COLOR",_[_.ONE_MINUS_SRC_COLOR=769]="ONE_MINUS_SRC_COLOR",_[_.SRC_ALPHA=770]="SRC_ALPHA",_[_.ONE_MINUS_SRC_ALPHA=771]="ONE_MINUS_SRC_ALPHA",_[_.DST_ALPHA=772]="DST_ALPHA",_[_.ONE_MINUS_DST_ALPHA=773]="ONE_MINUS_DST_ALPHA",_[_.DST_COLOR=774]="DST_COLOR",_[_.ONE_MINUS_DST_COLOR=775]="ONE_MINUS_DST_COLOR",_[_.SRC_ALPHA_SATURATE=776]="SRC_ALPHA_SATURATE",_[_.CONSTANT_COLOR=32769]="CONSTANT_COLOR",_[_.ONE_MINUS_CONSTANT_COLOR=32770]="ONE_MINUS_CONSTANT_COLOR",_[_.CONSTANT_ALPHA=32771]="CONSTANT_ALPHA",_[_.ONE_MINUS_CONSTANT_ALPHA=32772]="ONE_MINUS_CONSTANT_ALPHA"}(A||(A={})),function(_){_[_.ADD=32774]="ADD",_[_.MIN=32775]="MIN",_[_.MAX=32776]="MAX",_[_.SUBTRACT=32778]="SUBTRACT",_[_.REVERSE_SUBTRACT=32779]="REVERSE_SUBTRACT"}(T||(T={})),function(_){_[_.ARRAY_BUFFER=34962]="ARRAY_BUFFER",_[_.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER",_[_.UNIFORM_BUFFER=35345]="UNIFORM_BUFFER",_[_.PIXEL_PACK_BUFFER=35051]="PIXEL_PACK_BUFFER",_[_.PIXEL_UNPACK_BUFFER=35052]="PIXEL_UNPACK_BUFFER",_[_.COPY_READ_BUFFER=36662]="COPY_READ_BUFFER",_[_.COPY_WRITE_BUFFER=36663]="COPY_WRITE_BUFFER",_[_.TRANSFORM_FEEDBACK_BUFFER=35982]="TRANSFORM_FEEDBACK_BUFFER"}(N||(N={})),function(_){_[_.FRONT=1028]="FRONT",_[_.BACK=1029]="BACK",_[_.FRONT_AND_BACK=1032]="FRONT_AND_BACK"}(S||(S={})),function(_){_[_.CW=2304]="CW",_[_.CCW=2305]="CCW"}(I||(I={})),function(_){_[_.BYTE=5120]="BYTE",_[_.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",_[_.SHORT=5122]="SHORT",_[_.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",_[_.INT=5124]="INT",_[_.UNSIGNED_INT=5125]="UNSIGNED_INT",_[_.FLOAT=5126]="FLOAT",_[_.HALF_FLOAT=5131]="HALF_FLOAT"}(O||(O={})),function(_){_[_.NEVER=512]="NEVER",_[_.LESS=513]="LESS",_[_.EQUAL=514]="EQUAL",_[_.LEQUAL=515]="LEQUAL",_[_.GREATER=516]="GREATER",_[_.NOTEQUAL=517]="NOTEQUAL",_[_.GEQUAL=518]="GEQUAL",_[_.ALWAYS=519]="ALWAYS"}(C||(C={})),function(_){_[_.ZERO=0]="ZERO",_[_.KEEP=7680]="KEEP",_[_.REPLACE=7681]="REPLACE",_[_.INCR=7682]="INCR",_[_.DECR=7683]="DECR",_[_.INVERT=5386]="INVERT",_[_.INCR_WRAP=34055]="INCR_WRAP",_[_.DECR_WRAP=34056]="DECR_WRAP"}(D||(D={})),function(_){_[_.NEAREST=9728]="NEAREST",_[_.LINEAR=9729]="LINEAR",_[_.NEAREST_MIPMAP_NEAREST=9984]="NEAREST_MIPMAP_NEAREST",_[_.LINEAR_MIPMAP_NEAREST=9985]="LINEAR_MIPMAP_NEAREST",_[_.NEAREST_MIPMAP_LINEAR=9986]="NEAREST_MIPMAP_LINEAR",_[_.LINEAR_MIPMAP_LINEAR=9987]="LINEAR_MIPMAP_LINEAR"}(L||(L={})),function(_){_[_.CLAMP_TO_EDGE=33071]="CLAMP_TO_EDGE",_[_.REPEAT=10497]="REPEAT",_[_.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT"}(P||(P={})),function(_){_[_.TEXTURE_2D=3553]="TEXTURE_2D",_[_.TEXTURE_CUBE_MAP=34067]="TEXTURE_CUBE_MAP",_[_.TEXTURE_3D=32879]="TEXTURE_3D",_[_.TEXTURE_CUBE_MAP_POSITIVE_X=34069]="TEXTURE_CUBE_MAP_POSITIVE_X",_[_.TEXTURE_CUBE_MAP_NEGATIVE_X=34070]="TEXTURE_CUBE_MAP_NEGATIVE_X",_[_.TEXTURE_CUBE_MAP_POSITIVE_Y=34071]="TEXTURE_CUBE_MAP_POSITIVE_Y",_[_.TEXTURE_CUBE_MAP_NEGATIVE_Y=34072]="TEXTURE_CUBE_MAP_NEGATIVE_Y",_[_.TEXTURE_CUBE_MAP_POSITIVE_Z=34073]="TEXTURE_CUBE_MAP_POSITIVE_Z",_[_.TEXTURE_CUBE_MAP_NEGATIVE_Z=34074]="TEXTURE_CUBE_MAP_NEGATIVE_Z",_[_.TEXTURE_2D_ARRAY=35866]="TEXTURE_2D_ARRAY"}(G||(G={})),function(_){_[_.MIN_LOD=33082]="MIN_LOD",_[_.MAX_LOD=33083]="MAX_LOD",_[_.BASE_LEVEL=33084]="BASE_LEVEL",_[_.MAX_LEVEL=33085]="MAX_LEVEL",_[_.MAX_TEXTURE_SIZE=3379]="MAX_TEXTURE_SIZE"}(U||(U={})),function(_){_[_.DEPTH_COMPONENT=6402]="DEPTH_COMPONENT",_[_.DEPTH_STENCIL=34041]="DEPTH_STENCIL",_[_.DEPTH24_STENCIL8=35056]="DEPTH24_STENCIL8",_[_.ALPHA=6406]="ALPHA",_[_.RGB=6407]="RGB",_[_.RGBA=6408]="RGBA",_[_.LUMINANCE=6409]="LUMINANCE",_[_.LUMINANCE_ALPHA=6410]="LUMINANCE_ALPHA",_[_.RED=6403]="RED",_[_.RG=33319]="RG",_[_.RED_INTEGER=36244]="RED_INTEGER",_[_.RG_INTEGER=33320]="RG_INTEGER",_[_.RGB_INTEGER=36248]="RGB_INTEGER",_[_.RGBA_INTEGER=36249]="RGBA_INTEGER"}(M||(M={})),function(_){_[_.RGBA4=32854]="RGBA4",_[_.R16F=33325]="R16F",_[_.RG16F=33327]="RG16F",_[_.RGB32F=34837]="RGB32F",_[_.RGBA16F=34842]="RGBA16F",_[_.R32F=33326]="R32F",_[_.RG32F=33328]="RG32F",_[_.RGBA32F=34836]="RGBA32F",_[_.R11F_G11F_B10F=35898]="R11F_G11F_B10F",_[_.RGB8=32849]="RGB8",_[_.RGBA8=32856]="RGBA8",_[_.RGB5_A1=32855]="RGB5_A1",_[_.R8=33321]="R8",_[_.RG8=33323]="RG8",_[_.R8I=33329]="R8I",_[_.R8UI=33330]="R8UI",_[_.R16I=33331]="R16I",_[_.R16UI=33332]="R16UI",_[_.R32I=33333]="R32I",_[_.R32UI=33334]="R32UI",_[_.RG8I=33335]="RG8I",_[_.RG8UI=33336]="RG8UI",_[_.RG16I=33337]="RG16I",_[_.RG16UI=33338]="RG16UI",_[_.RG32I=33339]="RG32I",_[_.RG32UI=33340]="RG32UI",_[_.RGB16F=34843]="RGB16F",_[_.RGB9_E5=35901]="RGB9_E5",_[_.SRGB8=35905]="SRGB8",_[_.SRGB8_ALPHA8=35907]="SRGB8_ALPHA8",_[_.RGB565=36194]="RGB565",_[_.RGBA32UI=36208]="RGBA32UI",_[_.RGB32UI=36209]="RGB32UI",_[_.RGBA16UI=36214]="RGBA16UI",_[_.RGB16UI=36215]="RGB16UI",_[_.RGBA8UI=36220]="RGBA8UI",_[_.RGB8UI=36221]="RGB8UI",_[_.RGBA32I=36226]="RGBA32I",_[_.RGB32I=36227]="RGB32I",_[_.RGBA16I=36232]="RGBA16I",_[_.RGB16I=36233]="RGB16I",_[_.RGBA8I=36238]="RGBA8I",_[_.RGB8I=36239]="RGB8I",_[_.R8_SNORM=36756]="R8_SNORM",_[_.RG8_SNORM=36757]="RG8_SNORM",_[_.RGB8_SNORM=36758]="RGB8_SNORM",_[_.RGBA8_SNORM=36759]="RGBA8_SNORM",_[_.RGB10_A2=32857]="RGB10_A2",_[_.RGB10_A2UI=36975]="RGB10_A2UI"}(B||(B={})),function(_){_[_.FLOAT=5126]="FLOAT",_[_.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",_[_.UNSIGNED_INT_24_8=34042]="UNSIGNED_INT_24_8",_[_.UNSIGNED_SHORT_4_4_4_4=32819]="UNSIGNED_SHORT_4_4_4_4",_[_.UNSIGNED_SHORT_5_5_5_1=32820]="UNSIGNED_SHORT_5_5_5_1",_[_.UNSIGNED_SHORT_5_6_5=33635]="UNSIGNED_SHORT_5_6_5",_[_.BYTE=5120]="BYTE",_[_.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",_[_.SHORT=5122]="SHORT",_[_.UNSIGNED_INT=5125]="UNSIGNED_INT",_[_.INT=5124]="INT",_[_.HALF_FLOAT=5131]="HALF_FLOAT",_[_.UNSIGNED_INT_2_10_10_10_REV=33640]="UNSIGNED_INT_2_10_10_10_REV",_[_.UNSIGNED_INT_10F_11F_11F_REV=35899]="UNSIGNED_INT_10F_11F_11F_REV",_[_.UNSIGNED_INT_5_9_9_9_REV=35902]="UNSIGNED_INT_5_9_9_9_REV",_[_.FLOAT_32_UNSIGNED_INT_24_8_REV=36269]="FLOAT_32_UNSIGNED_INT_24_8_REV"}(F||(F={})),function(_){_[_.DEPTH_COMPONENT16=33189]="DEPTH_COMPONENT16",_[_.STENCIL_INDEX8=36168]="STENCIL_INDEX8",_[_.DEPTH_STENCIL=34041]="DEPTH_STENCIL",_[_.DEPTH_COMPONENT24=33190]="DEPTH_COMPONENT24",_[_.DEPTH_COMPONENT32F=36012]="DEPTH_COMPONENT32F",_[_.DEPTH24_STENCIL8=35056]="DEPTH24_STENCIL8",_[_.DEPTH32F_STENCIL8=36013]="DEPTH32F_STENCIL8"}(H||(H={})),function(_){_[_.STATIC_DRAW=35044]="STATIC_DRAW",_[_.DYNAMIC_DRAW=35048]="DYNAMIC_DRAW",_[_.STREAM_DRAW=35040]="STREAM_DRAW",_[_.STATIC_READ=35045]="STATIC_READ",_[_.DYNAMIC_READ=35049]="DYNAMIC_READ",_[_.STREAM_READ=35041]="STREAM_READ",_[_.STATIC_COPY=35046]="STATIC_COPY",_[_.DYNAMIC_COPY=35050]="DYNAMIC_COPY",_[_.STREAM_COPY=35042]="STREAM_COPY"}(n||(n={})),function(_){_[_.FRAGMENT_SHADER=35632]="FRAGMENT_SHADER",_[_.VERTEX_SHADER=35633]="VERTEX_SHADER"}(V||(V={})),function(_){_[_.FRAMEBUFFER=36160]="FRAMEBUFFER",_[_.READ_FRAMEBUFFER=36008]="READ_FRAMEBUFFER",_[_.DRAW_FRAMEBUFFER=36009]="DRAW_FRAMEBUFFER"}(X||(X={}));const Y=33984;var f,t;!function(_){_[_.Texture=0]="Texture",_[_.BufferObject=1]="BufferObject",_[_.VertexArrayObject=2]="VertexArrayObject",_[_.Shader=3]="Shader",_[_.Program=4]="Program",_[_.FramebufferObject=5]="FramebufferObject",_[_.Renderbuffer=6]="Renderbuffer",_[_.TransformFeedback=7]="TransformFeedback",_[_.Sync=8]="Sync",_[_.UNCOUNTED=9]="UNCOUNTED",_[_.LinesOfCode=9]="LinesOfCode",_[_.Uniform=10]="Uniform",_[_.COUNT=11]="COUNT"}(f||(f={})),function(_){_[_.NONE=0]="NONE",_[_.BACK=1029]="BACK"}(t||(t={}));const c=36064,o=36065,u=36066,e=36067,i=36068,r=36069,W=36070,x=36071,K=36072,a=36073,b=36074,Z=36075,d=36076,m=36077,Q=36078,j=36079,s=33306,y=36096,v=36128;var g,h,k,J,p,l,q,w,z;!function(_){_[_.COMPRESSED_RGB_S3TC_DXT1_EXT=33776]="COMPRESSED_RGB_S3TC_DXT1_EXT",_[_.COMPRESSED_RGBA_S3TC_DXT1_EXT=33777]="COMPRESSED_RGBA_S3TC_DXT1_EXT",_[_.COMPRESSED_RGBA_S3TC_DXT3_EXT=33778]="COMPRESSED_RGBA_S3TC_DXT3_EXT",_[_.COMPRESSED_RGBA_S3TC_DXT5_EXT=33779]="COMPRESSED_RGBA_S3TC_DXT5_EXT",_[_.COMPRESSED_R11_EAC=37488]="COMPRESSED_R11_EAC",_[_.COMPRESSED_SIGNED_R11_EAC=37489]="COMPRESSED_SIGNED_R11_EAC",_[_.COMPRESSED_RG11_EAC=37490]="COMPRESSED_RG11_EAC",_[_.COMPRESSED_SIGNED_RG11_EAC=37491]="COMPRESSED_SIGNED_RG11_EAC",_[_.COMPRESSED_RGB8_ETC2=37492]="COMPRESSED_RGB8_ETC2",_[_.COMPRESSED_SRGB8_ETC2=37493]="COMPRESSED_SRGB8_ETC2",_[_.COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2=37494]="COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2",_[_.COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2=37495]="COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2",_[_.COMPRESSED_RGBA8_ETC2_EAC=37496]="COMPRESSED_RGBA8_ETC2_EAC",_[_.COMPRESSED_SRGB8_ALPHA8_ETC2_EAC=37497]="COMPRESSED_SRGB8_ALPHA8_ETC2_EAC"}(g||(g={})),function(_){_[_.FLOAT=5126]="FLOAT",_[_.FLOAT_VEC2=35664]="FLOAT_VEC2",_[_.FLOAT_VEC3=35665]="FLOAT_VEC3",_[_.FLOAT_VEC4=35666]="FLOAT_VEC4",_[_.INT=5124]="INT",_[_.INT_VEC2=35667]="INT_VEC2",_[_.INT_VEC3=35668]="INT_VEC3",_[_.INT_VEC4=35669]="INT_VEC4",_[_.BOOL=35670]="BOOL",_[_.BOOL_VEC2=35671]="BOOL_VEC2",_[_.BOOL_VEC3=35672]="BOOL_VEC3",_[_.BOOL_VEC4=35673]="BOOL_VEC4",_[_.FLOAT_MAT2=35674]="FLOAT_MAT2",_[_.FLOAT_MAT3=35675]="FLOAT_MAT3",_[_.FLOAT_MAT4=35676]="FLOAT_MAT4",_[_.SAMPLER_2D=35678]="SAMPLER_2D",_[_.SAMPLER_CUBE=35680]="SAMPLER_CUBE",_[_.UNSIGNED_INT=5125]="UNSIGNED_INT",_[_.UNSIGNED_INT_VEC2=36294]="UNSIGNED_INT_VEC2",_[_.UNSIGNED_INT_VEC3=36295]="UNSIGNED_INT_VEC3",_[_.UNSIGNED_INT_VEC4=36296]="UNSIGNED_INT_VEC4",_[_.FLOAT_MAT2x3=35685]="FLOAT_MAT2x3",_[_.FLOAT_MAT2x4=35686]="FLOAT_MAT2x4",_[_.FLOAT_MAT3x2=35687]="FLOAT_MAT3x2",_[_.FLOAT_MAT3x4=35688]="FLOAT_MAT3x4",_[_.FLOAT_MAT4x2=35689]="FLOAT_MAT4x2",_[_.FLOAT_MAT4x3=35690]="FLOAT_MAT4x3",_[_.SAMPLER_3D=35679]="SAMPLER_3D",_[_.SAMPLER_2D_SHADOW=35682]="SAMPLER_2D_SHADOW",_[_.SAMPLER_2D_ARRAY=36289]="SAMPLER_2D_ARRAY",_[_.SAMPLER_2D_ARRAY_SHADOW=36292]="SAMPLER_2D_ARRAY_SHADOW",_[_.SAMPLER_CUBE_SHADOW=36293]="SAMPLER_CUBE_SHADOW",_[_.INT_SAMPLER_2D=36298]="INT_SAMPLER_2D",_[_.INT_SAMPLER_3D=36299]="INT_SAMPLER_3D",_[_.INT_SAMPLER_CUBE=36300]="INT_SAMPLER_CUBE",_[_.INT_SAMPLER_2D_ARRAY=36303]="INT_SAMPLER_2D_ARRAY",_[_.UNSIGNED_INT_SAMPLER_2D=36306]="UNSIGNED_INT_SAMPLER_2D",_[_.UNSIGNED_INT_SAMPLER_3D=36307]="UNSIGNED_INT_SAMPLER_3D",_[_.UNSIGNED_INT_SAMPLER_CUBE=36308]="UNSIGNED_INT_SAMPLER_CUBE",_[_.UNSIGNED_INT_SAMPLER_2D_ARRAY=36311]="UNSIGNED_INT_SAMPLER_2D_ARRAY"}(h||(h={})),function(_){_[_.OBJECT_TYPE=37138]="OBJECT_TYPE",_[_.SYNC_CONDITION=37139]="SYNC_CONDITION",_[_.SYNC_STATUS=37140]="SYNC_STATUS",_[_.SYNC_FLAGS=37141]="SYNC_FLAGS"}(k||(k={})),function(_){_[_.UNSIGNALED=37144]="UNSIGNALED",_[_.SIGNALED=37145]="SIGNALED"}(J||(J={})),function(_){_[_.ALREADY_SIGNALED=37146]="ALREADY_SIGNALED",_[_.TIMEOUT_EXPIRED=37147]="TIMEOUT_EXPIRED",_[_.CONDITION_SATISFIED=37148]="CONDITION_SATISFIED",_[_.WAIT_FAILED=37149]="WAIT_FAILED"}(p||(p={})),function(_){_[_.SYNC_GPU_COMMANDS_COMPLETE=37143]="SYNC_GPU_COMMANDS_COMPLETE"}(l||(l={})),function(_){_[_.SYNC_FLUSH_COMMANDS_BIT=1]="SYNC_FLUSH_COMMANDS_BIT"}(q||(q={})),function(_){_[_.INVALID_ENUM=1280]="INVALID_ENUM",_[_.INVALID_VALUE=1281]="INVALID_VALUE",_[_.INVALID_OPERATION=1282]="INVALID_OPERATION",_[_.OUT_OF_MEMORY=1285]="OUT_OF_MEMORY",_[_.INVALID_FRAMEBUFFER_OPERATION=1286]="INVALID_FRAMEBUFFER_OPERATION",_[_.CONTEXT_LOST_WEBGL=37442]="CONTEXT_LOST_WEBGL"}(w||(w={})),function(_){_[_.COMPLETION_STATUS_KHR=37297]="COMPLETION_STATUS_KHR"}(z||(z={}));export{A as BlendFactor,T as BlendOperation,E as BufferContent,N as BufferType,p as ClientWaitSyncStatus,c as ColorAttachment0,o as ColorAttachment1,b as ColorAttachment10,Z as ColorAttachment11,d as ColorAttachment12,m as ColorAttachment13,Q as ColorAttachment14,j as ColorAttachment15,u as ColorAttachment2,e as ColorAttachment3,i as ColorAttachment4,r as ColorAttachment5,W as ColorAttachment6,x as ColorAttachment7,K as ColorAttachment8,a as ColorAttachment9,C as CompareFunction,g as CompressedTextureFormat,I as CullMode,O as DataType,y as DepthAttachment,s as DepthStencilAttachment,w as ErrorConstant,z as Extension,S as Face,_ as FramebufferBit,X as FramebufferTarget,M as PixelFormat,F as PixelType,R as PrimitiveType,H as RenderbufferFormat,f as ResourceType,V as ShaderType,B as SizedPixelFormat,t as SpecialDrawBuffers,v as StencilAttachment,D as StencilOperation,l as SyncCondition,q as SyncFlag,k as SyncParameter,J as SyncStatus,U as TextureConstants,L as TextureSamplingMode,G as TextureType,P as TextureWrapMode,h as UniformType,n as Usage,Y as baseTextureUnit};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{BufferObject as e}from"./BufferObject.js";import{TextureWrapMode as r,PixelType as t,SizedPixelFormat as o,TextureSamplingMode as n,Usage as i,DataType as s,PrimitiveType as a}from"./enums.js";import{FramebufferObject as
|
|
5
|
+
import{BufferObject as e}from"./BufferObject.js";import{TextureWrapMode as r,PixelType as t,SizedPixelFormat as o,TextureSamplingMode as n,Usage as i,DataType as s,PrimitiveType as a,ErrorConstant as p}from"./enums.js";import{FramebufferObject as c}from"./FramebufferObject.js";import{makePipelineState as m,writeDestinationPremultipliedAlpha as f}from"./renderState.js";import{TextureDescriptor as l}from"./TextureDescriptor.js";import{VertexArrayObject as u}from"./VertexArrayObject.js";import{VertexElementDescriptor as b}from"./VertexElementDescriptor.js";import{WebGLDriverTestModule as d}from"./WebGLDriverTestModule.js";class g extends d{constructor(e){if(super(),this._rctx=e,!e.gl)return;if(!(e.capabilities.colorBufferFloat?.textureFloat&&e.capabilities.colorBufferFloat?.floatBlend))return;const r="\n precision highp float;\n attribute vec2 a_pos;\n\n void main() {\n gl_Position = vec4(a_pos * 2.0 - 1.0, 0.0, 1.0);\n }\n ",t="\n precision highp float;\n\n void main() {\n gl_FragColor = vec4(0.5, 0.5, 0.5, 0.5);\n }\n ";this._program=e.programCache.acquire(r,t,new Map([["a_pos",0]]))}_test(d){const g=this._rctx,_=new l(1);_.wrapMode=r.CLAMP_TO_EDGE,_.dataType=t.FLOAT,_.internalFormat=o.RGBA32F,_.samplingMode=n.NEAREST;const w=new c(g,_),A=e.createVertex(g,i.STATIC_DRAW,new Uint16Array([0,0,1,0,0,1,1,1])),T=new u(g,new Map([["a_pos",0]]),new Map([["geometry",[new b("a_pos",2,s.UNSIGNED_SHORT,0,4)]]]),new Map([["geometry",A]]));g.gl.getError(),g.useProgram(d);const j=g.getBoundFramebufferObject(),{x,y:E,width:h,height:F}=g.getViewport();g.bindFramebuffer(w),g.setViewport(0,0,1,1),g.bindVAO(T),g.drawArrays(a.TRIANGLE_STRIP,0,4);const O=m({blending:f});g.setPipelineState(O),g.drawArrays(a.TRIANGLE_STRIP,0,4);const y=g.gl.getError();return g.setViewport(x,E,h,F),g.bindFramebuffer(j),T.dispose(),w.dispose(),y!==p.INVALID_OPERATION||(console.warn("Device claims support for WebGL extension EXT_float_blend but does not support it. Using fall back."),!1)}}export{g as FloatBufferBlend};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../Graphic.js";import{isSome as i,equals as a}from"../../core/arrayUtils.js";import{createTask as r}from"../../core/asyncUtils.js";import s from"../../core/Collection.js";import{deprecatedProperty as o}from"../../core/deprecate.js";import n from"../../core/Error.js";import l from"../../core/Evented.js";import c from"../../core/JSONSupport.js";import{equalsShallow as h}from"../../core/lang.js";import u from"../../core/Logger.js";import{clamp as p}from"../../core/mathUtils.js";import{abortMaybe as m,destroyMaybe as d}from"../../core/maybe.js";import g from"../../core/Promise.js";import{isAbortError as y,throwIfAborted as f,waitTick as v}from"../../core/promiseUtils.js";import w from"../../core/ReactiveMap.js";import{on as b,watch as F,syncAndInitial as _,initial as P}from"../../core/reactiveUtils.js";import{sqlAnd as I}from"../../core/sql.js";import{getMetersPerUnitForSR as S}from"../../core/unitUtils.js";import{property as M}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import{subclass as C}from"../../core/accessorSupport/decorators/subclass.js";import{distance as k}from"../../core/libs/gl-matrix-2/math/vec2.js";import{UpdatingHandles as V}from"../../core/support/UpdatingHandles.js";import{union as A}from"../../geometry/geometryEngineAsync.js";import G from"../../geometry/Multipoint.js";import R from"../../geometry/Point.js";import O from"../../geometry/Polygon.js";import L from"../../geometry/Polyline.js";import{projectWithZConversion as x}from"../../geometry/projection.js";import j from"../../geometry/SpatialReference.js";import{isClockwise as E}from"../../geometry/support/coordsUtils.js";import{geographicToWebMercator as B}from"../../geometry/support/webMercatorUtils.js";import z from"../../layers/GraphicsLayer.js";import{searchImages as H}from"../../layers/orientedImagery/queries.js";import{calculateSuitabilities as D}from"../../layers/orientedImagery/core/bestImageUtils.js";import{createCoveragePolygon as T,computePolygonForInspection as U,resizePolygon as N,checkIfPolygonContainsSelectedPoint as W}from"../../layers/orientedImagery/core/coverageUtils.js";import{isConstantElevation as q,isElevationSource as $}from"../../layers/orientedImagery/core/ElevationSourceDefinitions.js";import{imageToWorld as J,imageToWorldPanoramic as Z}from"../../layers/orientedImagery/transformations/imageToWorld.js";import K from"../../layers/orientedImagery/transformations/updateElevation.js";import{getElevationSampler as Q}from"../../layers/orientedImagery/transformations/updateElevationUtils.js";import{getInitialAngle as X,convertPixelToHeadingPitch as Y,getImageToWorldProperties as ee,getUpdateElevationProps as te,isElevationSampler as ie,getImageToWorldPanoramicProperties as ae,pointToArray as re,transformGraphicCoordinatesToPixel as se,getWorldToImageProperties as oe,convertHeadingPitchToSphereVertex as ne,or as le}from"../../layers/orientedImagery/transformations/utils.js";import{worldToImagePanoramic as ce,worldToImage as he}from"../../layers/orientedImagery/transformations/worldToImage.js";import{getFloorFilterClause as ue}from"../../layers/support/floorFilterUtils.js";import pe from"../../symbols/SimpleLineSymbol.js";import me from"../../views/draw/Draw.js";import{scale as de}from"../../views/draw/support/drawUtils.js";import{ViewEventPriorities as ge}from"../../views/input/InputManager.js";import ye from"../PanoramicViewer.js";import{invalidCameraHeading as fe,sectorsInOrder as ve,sectorsRadii as we}from"./constants.js";import{configureSketchTool as be,extractFieldsFromDataCaptureLayer as Fe,isValidDataCaptureLayer as _e,constructGraphicFromImageGeometry as Pe}from"./dataCaptureUtils.js";import{isFeatureAttachment as Ie,getImageSourceFromAttachment as Se}from"./galleryUtils.js";import{formatPixels as Me,heightMeasurementPanoramic as Ce,heightMeasurement2D as ke,calculateHeightAccuracyPanoramic as Ve,calculateHeightAccuracy as Ae,pixelAreaMeasurement2D as Ge,pixelAreaMeasurementPanoramic as Re,pixelDistanceMeasurement2D as Oe,pixelDistanceMeasurementPanoramic as Le,generateCombinations as xe,getRootOfSumOfSquaredErrors as je,generateCombinationsPanoramic as Ee,calculateReferenceImagePointPanoramic as Be,calculateAnglePano as ze,calculateTempImagePoint as He,calculateAngle as De,getModeCorrectedPoint as Te,calculateCorrectedPixel as Ue,calculateHeightFromTemporaryDistance as Ne}from"./imageMeasurementUtils.js";import{crossSymbol as We,crossSymbol3D as qe,measurementPolygonSymbol as $e,polylineSymbolPanoramic as Je,measurementPolylineSymbol as Ze,sourcePointSymbol as Ke,diamondSymbol as Qe,diamondSymbol3D as Xe,locationSymbol as Ye,locationSymbol3D as et,activeSourcePointSymbol as tt}from"./symbols.js";import{isNoAttachmentError as it,getContentType as at,isTifOrMrf as rt,filterOILLayerView as st,isSceneView as ot,isGraphic as nt,calculateSegment as lt,calculateDirection as ct}from"./utils.js";import ht from"./components/ImageViewer.js";const ut={click:"view-click",imageClick:"image-click",interactionHandles:"interaction-handles",footprintHandles:"footprint-handles",sketchHandles:"sketch-handles"},pt=new Set(["JPG","JPEG"]),mt=/\.(\w+)$/,dt=()=>new n("orientedimageryviewer:sketch-not-initialized","Sketch property is not initialized, call loadSketch first");let gt=class extends(l.EventedMixin(g)){constructor(e){super(e),this.additionalFeatures=new s,this.additionalCameraLocations=new s,this.additionalFootprints=new s,this.areaMeasurementResult=0,this.areaMeasurementAccuracy=0,this.bestFeatureAngle=0,this.bestFeatureCurrentFootprint=null,this.bestFeatureFootprint=null,this.collectionId=null,this.conversionProps=null,this.coverageFrustums=new s,this.coveragePolygons=new s,this.currentBestFeature=null,this.currentBestFeatureLocation=null,this.currentCoverageVisible=!0,this.determineWorkflowForFeature=async(e,t,i)=>{const{currentBestFeature:a,selectedPoint:r,view:s}=this;if(s?.closePopup(),a&&r){this._initialCurrentCoverageUpdate=!0,this._updateGroundElevation=!0;try{await this._updatePointsAndPolygons(i),await this._loadImage(i)}catch(o){y(o)||(this.loadImageError(o),u.getLogger(this).error("#loadIImage()","error occured while loading image",o))}}},this.disabled=!1,this.displayMessage={key:"onLoadMessage",type:"info"},this.displayNewMeasurementButton=!0,this.distanceMeasurementResult=0,this.distanceAccuracyArray=[],this.dataCaptureLayer=null,this.features=new s,this.groundCoordinates=null,this.heightMeasurementPixels=[],this.heightGraphic=null,this.heightMeasurementResult=0,this.heightMeasurementAccuracy=0,this.measurementAngle=null,this.tempDistance=null,this.imageGeometryField=null,this.imageLocationToolState=!1,this.isAdditionalCoverageVisible=!1,this.isAdditionalPointSourcesVisible=!1,this.layer=null,this.localPort=null,this.mapImageConversionToolState=!1,this.measureType=null,this.measurementGraphic=null,this.navigatorCurrentBestFeature=null,this.oiObjectIdField=null,this.overlayedCameraLocations=new s,this.overlayedMapFeatures=new w,this.pixelCoordinates=null,this.pointSources=new s,this.previousFeatureAngle=0,this.selectedPoint=null,this.shouldShowSelectedImage=!1,this.sketch=null,this.draw=null,this.sketchAdapter=null,this.updateFootprint=async(e,t)=>{"image-loaded"===this.state&&await(this._adapter?.updateFootprint(e,t))},this.updateFootprintPanorama=async(e,t)=>{await(this._adapter?.updateFootprintPanorama(e,t))},this._adapter=null,this._highlightedFeatureHandle=null,this._imageViewer=new ht,this._initialCurrentCoverageUpdate=!0,this._locationPointOnImage=null,this._overlays=new z({listMode:"hide",internal:!0,elevationInfo:{mode:"absolute-height"}}),this._panoramicViewer=new ye,this._previousCursor=null,this._referencePointOnGround=null,this._referencePointOnImage=null,this._sectorData=null,this._updatingHandles=new V,this._clickTask=null,this._crossSymbol=null,this.footprintExtent=null,this._featureChangedTask=null,this._openPopupTask=null,this._suitabilities=null,this._transformController=new AbortController,this._updateFootprintTask=null,this._updateGroundElevation=!1,this.hideImageGeometry=e=>{},this.highlight=e=>{if(!this._overlaysView)return;this.removeHighlight();const t=this.additionalFootprints.find((({attributes:{imageID:t}})=>t===Number(e)));this._highlightedFeatureHandle=t?this._overlaysView?.highlight(t):null},this.loadDataCaptureAdapter=async e=>{await this.loadSketch(e);const t=import("./adapters/sketch/DataCaptureAdapter.js"),{default:i}=await t;return f(e),this.sketchAdapter=new i({viewModel:this}),this.sketchAdapter},this.loadImageFromSource=async(e,t)=>this._updatingHandles.addPromise(this._loadImageFromSourceInternal(e,t)),this.loadImageViewer=e=>{this._imageViewer.container=e},this.loadPanoramicViewer=e=>{this._panoramicViewer.container=e},this.removeHighlight=()=>this._highlightedFeatureHandle?.remove(),this.revealImageGeometry=e=>{},this.toggleImageAttributes=()=>{m(this._openPopupTask),this._openPopupTask=r((async e=>{const{currentBestFeature:i,popupEnabled:a,layer:r,view:s}=this;if(s?.closePopup(),!(s&&i&&a&&r))return;const{attributes:o,geometry:n}=i,l=new t({geometry:n,attributes:o.toJSON(),layer:r});f(e),await s.openPopup({features:[l],location:o.location.clone()})}))},this._createViewClickHandle=()=>{if(this.removeHandles(ut.click),"disabled"===this.state||null==this.view)return;const e=this.mapImageConversionToolState&&"image-loaded"===this.state?this._mapImageConversionToolViewClickHandler:this._viewClickHandler;this.addHandles(this.view.on("click",e,ge.WIDGET),ut.click)},this._createImageClickHandle=()=>{this.removeHandles(ut.imageClick);const{mapImageConversionToolState:e,mode:t,activeViewer:i,currentBestFeature:a,footprintExtent:s}=this,o=i?.imageSize;if(!(e&&"none"!==t&&o&&s&&a))return;i.clickAction="pixel-location";let n=null;const l=b((()=>i),"pixel-location",(e=>{this.plotReferencePointOnImage(e),n?.abort(),n=r((async i=>{if(!e)return;const r=await this.getMapPoint(e,{feature:a,imageSize:o,mode:t}).then((e=>{const t=this.view?.spatialReference;return le(!t,e.spatialReference.equals(t))?e:x(e,t)}));f(i),this.plotReferencePointOnGround(r)}))}));this.addHandles(l,ut.imageClick)},this._createImageLocationHandle=()=>{this.removeHandles(ut.imageClick);const{imageLocationToolState:e,mode:t,activeViewer:i,currentBestFeature:a,footprintExtent:s}=this,o=i?.imageSize;if(!(e&&"none"!==t&&o&&s&&a))return;i.clickAction="pixel-location";let n=null;const l=b((()=>i),"pixel-location",(e=>{this.pixelCoordinates=e,this.plotLocationPointOnImage(e),n?.abort(),n=r((async i=>{if(!e)return;let r=await this.getMapPoint(e,{feature:a,imageSize:o,mode:t});f(i);const s=this.view?.spatialReference;s&&!r.spatialReference.equals(s)&&(r=await x(r,s),f(i)),this.groundCoordinates=r}))}));this.addHandles(l,ut.imageClick)},this._loadImage=async e=>{const{currentBestFeature:t,layer:i,mode:a}=this;if(this.clearGraphics(),!i||!t||"none"===a)return;const{attributes:r}=t,{imagePath:s,imageRotation:o,cameraHeading:n,cameraRoll:l,cameraPitch:c,objectId:h,cameraOrientation:p,location:m}=r,d=(l??0)+(o??0),g=m.spatialReference.isWGS84&&4!==p?.type?B(m):new R(m);let v=s;if(Ie(s))try{v=await Se(i,h,e)}catch(w){if(y(w))return;return it(w)?(u.getLogger(this).error(w),void this.setMessage("noAttachment","error",`${i.objectIdField}: ${h}`)):(u.getLogger(this).error(w,{[i.objectIdField]:h,layer:i}),void this.setMessage("imageLoadError","error",`query-attachments-failed:${i.objectIdField} ${h}`))}try{await this.loadImageFromSource(v,{imageRotation:d,options:e,pitch:c,yaw:n,mode:a,cameraLocation:g}),f(e),await this.transformAndPlotSelectedLocation(e)}catch(w){y(w)||this.loadImageError(w)}},this._loadImageFromSourceInternal=async(e,t)=>{const{mode:i,imageRotation:a,options:r}=t,s="string"==typeof e,o=s?e:e.url,{pathname:n,searchParams:l}=new URL(o);let c=s?n.match(mt)?.[1]:e.datasetFormat;if(!c)try{c=await at(o,{...t.options})}catch(h){y(h)||u.getLogger(this).error("#getContentType()",h)}switch(c??="UNKNOWN FORMAT",i){case"default":this._imageViewer.imageSource={datasetFormat:c.toUpperCase(),url:o.split("?")[0]},this._imageViewer.customParameters=Object.fromEntries(l),this._imageViewer.imageRotation=a??0,await this._imageViewer.loadImage(r);break;case"panoramic":if(pt.has(c.toUpperCase())){const{selectedPoint:e}=this,{pitch:i,yaw:a,cameraLocation:s,viewAngle:n}=t;this._panoramicViewer.imageSource=o;let l=a??0;"number"==typeof n?l=n-l:s&&e&&(l=await X(s,e)-l),this._panoramicViewer.pitch=i??0,this._panoramicViewer.yaw=l,await this._panoramicViewer.loadImage(r)}else this.setMessage("unsupportedPanoramicImageryError","error",void 0,{datasetFormat:c});break}},this._loadViewAdapter=async e=>{const{view:t}=this;if(t)switch(t.type){case"2d":{const{default:t}=await import("./adapters/view/MapViewAdapter.js");f(e),this._adapter=new t(this);break}case"3d":{const{default:t}=await import("./adapters/view/SceneViewAdapter.js");f(e),this._adapter=new t(this);break}}else this._adapter=null},this._mapImageConversionToolViewClickHandler=e=>{e.stopPropagation(),e.preventDefault(),e.mapPoint&&this.plotMapPoint(e.mapPoint)},this._viewClickHandler=e=>{this._clickTask?.abort(),this._clickTask=r((async t=>{const{pointerType:i,button:a,mapPoint:r}=e;if(("mouse"!==i||0===a)&&r)return e.stopPropagation(),e.preventDefault(),this._updatingHandles.addPromise(this.loadBestImage(r,{signal:t}))}))},this.plotSelectedPointOnImage=async(e,i)=>{if(await v(i),!e)return;const a=new R({...c.isSerializable(e)?e.toJSON():e});if("default"===this.mode)a.x-=.5,a.y=.5-a.y,a.spatialReference=this._imageViewer.imageRenderer.spatialReference.clone(),this._crossSymbol=new t({geometry:a,symbol:We}),this._imageViewer.addGraphic(this._crossSymbol,0);else if("panoramic"===this.mode){const{imageSize:i}=this._panoramicViewer;if(!i)return;const[a,r]=i,{heading:s,pitch:o}=Y(e,a,r),n=ne(s,o);this._crossSymbol=new t({geometry:new R(n,j.WebMercator),symbol:qe}),this._panoramicViewer.addGraphic(this._crossSymbol,0)}},this.handleSectorClick=this.handleSectorClick.bind(this),this.searchBestImage=this.searchBestImage.bind(this),this.transformAndPlotReferencePointOnImage=this.transformAndPlotReferencePointOnImage.bind(this),this.updateSuitabilities=this.updateSuitabilities.bind(this),this.selectBestFeature=this.selectBestFeature.bind(this)}initialize(){this.addHandles([F((()=>this.view),(()=>{this.load()}),_),F((()=>this.view?.map),((e,t)=>{t?.layers.remove(this._overlays),e?.layers.add(this._overlays)}),P),F((()=>this.view?.map?.allLayers?.length),(e=>{e&&this.view?.map?.layers.reorder(this._overlays,e-1)}),P),F((()=>[this.state,this.mapImageConversionToolState,this.view]),(()=>{this._createViewClickHandle(),this._createImageClickHandle()}),_),F((()=>[this.state,this.imageLocationToolState,this.view]),(()=>{if(this._createImageLocationHandle(),!this.imageLocationToolState)return this.clearPreviousGroundLocation(),void this._resetCursor();this._setMeasurementCursor()}),_),F((()=>this.measureType),(()=>{this.clearPreviousMeasurements()}),_),F((()=>this.bestFeatureAngle),((e,t)=>{this.previousFeatureAngle=t??0}),_),F((()=>this.currentBestFeature),(async(e,t)=>{m(this._featureChangedTask),this._featureChangedTask=r((async i=>this.determineWorkflowForFeature.apply(this,[e,t,{signal:i}]))),await this._featureChangedTask.promise}),{sync:!0}),F((()=>this.mode),(e=>{switch(this.removeHandles(ut.interactionHandles),e){case"default":this.addHandles(F((()=>{const{state:e}=this;return"image-loaded"===e?this._imageViewer.imagePointsInView:null}),(e=>{e&&(m(this._updateFootprintTask),this._updateFootprintTask=r((async t=>{await this.updateFootprint(e,{signal:t})})))}),{..._,equals:(e,t)=>a(e,t,h)}),ut.interactionHandles);break;case"panoramic":this.addHandles(F((()=>{const{currentBestFeature:e,state:t}=this,{imageSize:i,vfov:a,hfov:r,pitch:s,yaw:o}=this._panoramicViewer;return e&&i&&!t.includes("loading")?[a,r,o,s]:null}),(e=>{if(!e||this.state.includes("loading"))return;const[t,i,a,s]=e;m(this._updateFootprintTask),this._updateFootprintTask=r((async e=>{await this.updateFootprintPanorama({verticalFieldOfView:t,horizontalFieldOfView:i,yaw:a,pitch:s},{signal:e})}))}),{..._,equals:(e,t)=>a(e,t,h)}),ut.interactionHandles)}}),_),F((()=>[this.brightness,this.contrast,this.sharpness]),(()=>{const{_imageViewer:e,brightness:t,contrast:i,mode:a,sharpness:r}=this;"default"===a&&(e.brightness=t,e.contrast=i,e.sharpness=r)}),_),F((()=>this.activeViewer?.imageRenderer),(()=>{this.sketch&&(this.sketch.view=this.activeViewer?.imageRenderer)}))]),this.when().finally((()=>{this.notifyChange("state")}))}destroy(){this._updateFootprintTask=m(this._updateFootprintTask),this._clickTask=m(this._clickTask),this.coverageFrustums.destroy(),this.coveragePolygons.destroy(),this.pointSources.destroy(),this.additionalFootprints.destroy(),this.additionalCameraLocations.destroy(),this.bestFeatureFootprint=d(this.bestFeatureFootprint),this.bestFeatureCurrentFootprint=d(this.bestFeatureCurrentFootprint),this._crossSymbol=d(this._crossSymbol),this._referencePointOnGround=d(this._referencePointOnGround),this._referencePointOnImage=d(this._referencePointOnImage),this._locationPointOnImage=d(this._locationPointOnImage),this._overlays&&this.view?.map?.remove(this._overlays),this._overlays.destroy(),this._imageViewer.destroy(),this._panoramicViewer.destroy()}get activeLayer(){return o(u.getLogger(this),"activeLayer",{replacement:"layer"}),this.layer}set activeLayer(e){o(u.getLogger(this),"activeLayer",{replacement:"layer"}),this.layer=e}get activeViewer(){const{_imageViewer:e,_panoramicViewer:t,mode:i}=this;switch(i){case"default":return e;case"panoramic":return t;default:return null}}get accuracyParametersMissing(){return this.layer?.orientationAccuracy?.every((e=>0===e))??!0}get brightness(){return this._get("brightness")??0}set brightness(e){this._set("brightness",p(e,-10,10))}get contrast(){return this._get("contrast")??0}set contrast(e){this._set("contrast",p(e,-10,10))}get featureCount(){return this.features?.length??0}get imageGalleryEnabled(){const{currentBestFeature:e}=this;if(!e)return!1;const t=e.attributes.imagePath?.trim();return rt(t)||Ie(t)}get imageLoaded(){return o(u.getLogger(this),"imageLoaded",{replacement:'Use OrientedImageryViewer.state === "image-loaded"',version:"4.29",warnOnce:!0}),"image-loaded"===this.state}get invalidCameraHeading(){return this.currentBestFeature?.attributes?.cameraHeading===fe}get imagePointsInView(){const{mode:e,_imageViewer:t}=this;return"default"===e?t.imagePointsInView:null}get layerView(){const{layer:e,view:t}=this;if(e&&t)return t.allLayerViews.find(st(e))}get layerFloorFilterClause(){const{layerView:e}=this;return e?ue(e):null}get mode(){const e=this.currentBestFeature?.attributes;if(!e)return"none";const{horizontalFieldOfView:t,isSpherical:i}=e;return 360===t||i?"panoramic":"default"}get popupEnabled(){return!0===this.layer?.popupEnabled}get referencePoint(){return this._referencePointOnGround?.geometry}get sectorData(){const{_sectorData:e}=this;return e?ve.map((t=>e[t])):null}get sharpness(){return this._get("sharpness")??0}set sharpness(e){this._set("sharpness",p(e,0,1))}get sketchGraphicsLayer(){return this.sketch?.layer}get state(){const{mode:e,disabled:t,_updatingHandles:{updating:i},_featureChangedTask:a}=this;if(t)return"disabled";if(!this.isFulfilled()||i||!1===a?.finished)return"loading";if(this.isRejected())return"error";if("error"===this.displayMessage?.type)return"image-load-error";switch(e){case"default":return this._imageViewer.state;case"panoramic":return this._panoramicViewer.state}return"ready"}get thumbnails(){const{features:e}=this;return e?new s(e.map((({attributes:{imagePath:e,objectId:t,cameraRoll:i,imageRotation:a}})=>{const r=e?.trim();return rt(r)||Ie(r)?{url:r,objectId:t,rotation:(i??0)+(a??0)}:null})).filter(i)):null}set view(e){this._set("view",e)}get _sketchGraphicsLayer(){const{mode:e}=this;switch(e){case"panoramic":return new z({elevationInfo:{mode:"absolute-height"}});case"default":return new z;case"none":return}}get _overlaysView(){return this.view?.layerViews.find((({layer:e})=>e===this._overlays))}async computeHeight(e,t,i=!0){const{currentBestFeature:a,activeViewer:r,layer:s,footprintExtent:o}=this,n=r?.imageSize,l=a?.attributes,c=s?.orientationAccuracy;if(!l||!n||!e||e.length<2||!c)return;const h="panoramic"===t?await this.getMeasurementPropertiesPanoramic():ee(l,n[0],n[1]),u=e.at(0),p=e.at(-1);if(!(h&&u&&p&&c&&o))return;const m=[p,u],d=Me(m,!1),g="panoramic"===t?await Ce(m,h,c,a,!0,!1):await ke(m,h,c,!0,i);if(!g)return;const y="panoramic"===t?await Ve(c,d,h,g,a,!0):await Ae(c,d,h,g,!0);return y?{value:g,accuracy:y}:{value:g}}async calculateAreaMeasurement(e,t,i){if(e.length<3||!this.currentBestFeature||!this.activeViewer?.imageSize||"none"===t)return null;const a="default"===t?await this.getMeasurementProperties():await this.getMeasurementPropertiesPanoramic();return f(i),a?"default"===t?await Ge(e,a,!0):await Re(e,a,!0,i):null}async calculateDistanceMeasurement(e,t,i){const{currentBestFeature:a,activeViewer:r}=this;if(e.length<2||!a||!r?.imageSize||"none"===t)return null;const s="default"===t?await this.getMeasurementProperties():await this.getMeasurementPropertiesPanoramic();return f(i),s?"default"===t?await Oe([e.at(0),e.at(-1)],s,!0):await Le([e.at(0),e.at(-1)],s,!0):null}async calculateAccuracy(e,t,i){const{layer:a,currentBestFeature:r,activeViewer:s}=this,o=a?.orientationAccuracy,n=o?.every((e=>0===e))||!o?.length;if("area"===t&&e.length<3||"distance"===t&&e.length<2||!r||!s?.imageSize||n)return null;const l=await this.getMeasurementProperties();if(f(i),!l)return null;const c="area"===t?await Ge(e,l,!0):await Oe([e.at(0),e.at(-1)],l,!0);f(i);const{updateElevationProps:h,...u}=l,p=xe(u,o);if(!p?.length)return null;const m=p.map((e=>({...e,updateElevationProps:h}))).map((async a=>{const r="area"===t?await Ge(e,a,!0):await Oe([e.at(0),e.at(-1)],a,!0);if(f(i),r&&c){if("area"===t){const e="number"!=typeof r?r.area:null;return e?Math.abs(e-c.area):null}return Math.abs(r-c)}return null})),d=await Promise.all(m);f(i);const g=d.filter((e=>null!==e));return 0===g.length?null:je(g)}async calculateAccuracyPanoramic(e,t,i){const{layer:a,currentBestFeature:r,activeViewer:s,mode:o}=this,n=a?.orientationAccuracy,l=n?.every((e=>0===e))||!n?.length;if("area"===t&&e.length<3||"distance"===t&&e.length<2||!r||!s?.imageSize||l||"panoramic"!==o)return null;const c=await this.getMeasurementPropertiesPanoramic();if(f(i),!c)return null;const h="area"===t?await Re(e,c,!0):await Le([e.at(0),e.at(-1)],c,!0);f(i);const{updateElevationProps:u,...p}=c,m=Ee(p,n);if(!m?.length)return null;const d=m.map((e=>({...e,updateElevationProps:u}))).map((async a=>{const r="area"===t?await Re(e,a,!0):await Le([e.at(0),e.at(-1)],a,!0);if(f(i),r&&h){if("area"===t){const e="number"!=typeof r?r.area:null;return e?Math.abs(e-h.area):null}return Math.abs(r-h)}return null})),g=await Promise.all(d);f(i);const y=g.filter((e=>null!==e));return 0===y.length?null:je(y)}async calculateHeightMeasurementInfo(e,t,i){const{currentBestFeature:a,activeViewer:r}=this,s=r?.imageSize;if(!a||!r||!s?.length||"none"===t)return;const{attributes:o}=a,[n]=Me([e],"panoramic"!==t),l="panoramic"===t?await this.getMeasurementPropertiesPanoramic():ee(o,s[0],s[1]);if("panoramic"===t){if(!l)return;const e=await Be(n,l,a,i);if(!e)return;e?.heading>180&&(e.heading-=360);const t=ze(n,e),r=k([n.x,n.y],[e.x,e.y]);if(!t||!r)return;return{measurementAngle:t,tempDistance:r}}const c=await He(n,l,i);if(!c)return;const h=De(n,c),u=k([n.x,n.y],[c.x,c.y]);return h&&u?{measurementAngle:h,tempDistance:u}:void 0}clearPreviousMeasurements(){this.clearMeasurementGraphics(),this.resetMeasurementData(),this.stopMeasurement()}clearPreviousGroundLocation(){this.groundCoordinates=null,this.pixelCoordinates=null,this.clearLocationPointOnImage()}clearMeasurementGraphics(){this.measurementGraphic&&(this.activeViewer?.removeGraphic(this.measurementGraphic),this.measurementGraphic=null),this.heightGraphic&&(this.activeViewer?.removeGraphic(this.heightGraphic),this.heightGraphic=null)}digitizeCancel(){return this.sketch?.cancel()}digitizeCanRedo(){return this.sketch?.canRedo()??!1}digitizeCanUndo(){return this.sketch?.canUndo()??!1}digitizeComplete(){return this.sketch?.complete()}async digitizeCreate(e,t){const{sketch:i,dataCaptureLayer:a}=this;if(!i)throw dt();be(a,e,i),await i.create(e,{...t,defaultZ:0})}async digitizeDelete(){if(!this.sketch)throw dt();return this.sketch.delete()}digitizeDuplicate(){if(!this.sketch)throw dt();return this.sketch.duplicate()}digitizePlace(e,t){if(!this.sketch)throw dt();return this.sketch.place(e,t)}digitizeRedo(){if(!this.sketch)throw dt();return this.sketch.redo()}digitizeUndo(){if(!this.sketch)throw dt();return this.sketch.undo()}digitizeUpdate(e,t){if(!this.sketch)throw dt();return this.sketch.update(e,t)}async displayHeightResults(){const{currentBestFeature:e,activeViewer:t,heightMeasurementPixels:i,mode:a}=this,r=t?.imageSize,s=e?.attributes;if(!s||!r)return;const o=await this.computeHeight(i,a);o?.value&&o?.accuracy&&(this.heightMeasurementResult=o.value,this.heightMeasurementAccuracy=o.accuracy)}filterByFootprints(e,t){const i=[],a=[],r=[];return e.forEach((e=>{const{layer:{coveragePercent:s},attributes:o}=e;let n;const l=S(e.geometry.spatialReference);o.cameraHeight/=l,o.farDistance/=l,o.nearDistance/=l,q(o.elevationSource)&&(o.elevationSource.constantElevation/=l);const{polygon:c,frustum:h}=T(o);if(n=c.clone(),o.isInspection&&(n=U(o)),s&&(n=N(n,s)),W(n,t)){r.push(e);const{geometry:t,objectId:s,cameraHeight:n,cameraHeading:l}=o,u=t.clone();u.z=n,u.imageID=s,this.pointSources.push(u),l!==fe&&(i.push(c),h&&a.push(h))}})),{features:r,polygons:i,frustums:a}}getMeasurementProperties(){const{currentBestFeature:e,activeViewer:t}=this;if(!e||!t?.imageSize)return;const{elevationSample:i,attributes:a}=e,{elevationSource:r,cameraHeight:s}=a,o=ee(a,t.imageSize[0],t.imageSize[1]);let n=o.cameraLocation;return(n.spatialReference.isGeographic?x(n,j.WebMercator):Promise.resolve(n)).then((e=>(n=e,te((n.z??0)-s,{elevationSample:i,elevationSource:r,extent:this.footprintExtent})))).then((t=>("elevationSample"in t&&ie(t.elevationSample)&&(e.elevationSample=t.elevationSample),{...o,cameraLocation:n,updateElevationProps:t})))}getMeasurementPropertiesPanoramic(){const{currentBestFeature:e,activeViewer:t}=this;if(!e||!t?.imageSize)return;const{elevationSample:i,attributes:a}=e,{elevationSource:r,cameraHeight:s}=a,o=ae(a,t.imageSize[0],t.imageSize[1]);let n=o.cameraLocation;return(n.spatialReference.isGeographic?x(n,j.WebMercator):Promise.resolve(n)).then((e=>(n=e,te((n.z??0)-s,{elevationSample:i,elevationSource:r,extent:this.footprintExtent})))).then((t=>("elevationSample"in t&&ie(t.elevationSample)&&(e.elevationSample=t.elevationSample),{...o,cameraLocation:n,updateElevationProps:t})))}async deleteDataCaptureFeatures(e){const{dataCaptureLayer:t}=this;if(!t)throw new n("Data capture layer is not available");return t.queryFeatures({objectIds:e}).then((({features:e})=>t.applyEdits({deleteFeatures:e})))}handleSectorClick(e){if(isNaN(e))return;const t=this._sectorData?.[ve[e]];t?.length&&this._updateCurrentBestFeature(t.at(0))}handleFeatureClick(e){const{sector:t,featureIndexInSector:i}=e;if(isNaN(i))return;const a=this._sectorData?.[t];a?.length&&this._updateCurrentBestFeature(a.at(i))}handleDrawCursorUpdateEvents(e){const{measurementAngle:t,tempDistance:i,heightMeasurementPixels:a,mode:r,activeViewer:s}=this,o=s?.imageSize;if(!e.vertices||!o)return;const n=Te(e.vertices.at(-1),r,o);if(a.length<1||!n||!i||!t||"none"===r)return;const l=Ue(a[0],n,t);if(!l?.length)return;this.heightMeasurementPixels.push(l),"panoramic"===r?this.createPolylineGraphicPano():this.createPolylineGraphic();const c=Ne(this.heightMeasurementPixels,i);c&&(this.heightMeasurementResult=c)}async handleDrawVertexAddEvents(e,t){const{currentBestFeature:i,activeViewer:a,heightMeasurementPixels:r,mode:s}=this;if(!i||!a||!e.vertices?.length||"none"===s)return;const o=a?.imageSize;if(!r.length&&o){const i=Te(e.vertices.at(-1),s,o);this.heightMeasurementPixels.push(i);const a=await this.calculateHeightMeasurementInfo(i,s,t);if(!a?.measurementAngle||!a?.tempDistance)return;this.measurementAngle=a.measurementAngle,this.tempDistance=a.tempDistance}}async load(e){return this.addResolvingPromise(this._loadViewAdapter(e).catch((e=>{if(!y(e))throw e}))),this}async loadBestImage(e,t){return this.view?.closePopup(),this.displayMessage=null,this.clearPreviousGroundLocation(),this.imageLocationToolState=!1,this.selectedPoint=e.spatialReference.isGeographic?B(e):e.clone(),this.features.removeAll(),this.currentBestFeature=null,this.additionalFeatures.removeAll(),this.additionalFootprints.removeAll(),this.additionalCameraLocations.removeAll(),this.bestFeatureCurrentFootprint=d(this.bestFeatureCurrentFootprint),this._overlays?.removeAll(),this._fetchFeaturesWithController(e,t)}loadImageError(e){u.getLogger(this).error("oriented-imagery-viewer:load-image",e),this.setMessage("imageLoadError","error",e.message)}async loadSketch(e){if(!this.sketch){const t=import("../Sketch/SketchViewModel.js"),{default:i}=await t;f(e),this.sketch=new i({layer:this._sketchGraphicsLayer,view:this.activeViewer?.imageRenderer,updateOnGraphicClick:!1,defaultUpdateOptions:{reshapeOptions:{edgeOperation:"none",shapeOperation:"none",vertexOperation:void 0},enableMoveAllGraphics:!1,enableRotation:!1,enableScaling:!1,multipleSelectionEnabled:!1,toggleToolOnClick:!1,tool:"transform"}})}return this.sketch}async loadMeasurementAdapter(e){if(!this.sketchAdapter){const t=import("./adapters/sketch/MeasurementAdapter.js"),{default:i}=await t;if(f(e),this.sketchAdapter=new i({viewModel:this}),!this.sketchAdapter.viewModel.isResolved())return}return this.sketchAdapter}async startMeasurement(e,t){await this.loadSketch(t),await this.loadMeasurementAdapter(t);const{sketch:i,sketchAdapter:a,activeViewer:r,mode:s}=this;if(!i||!a||!r||"none"===s)return;if(this.displayNewMeasurementButton=!1,"panoramic"===s&&(i.defaultCreateOptions.defaultZ=0),await i.create(e),"panoramic"===s){const{drawOperation:e}=i.view.activeTool;e.constraintsEnabled=!1,e._set("elevationDrawSurface",null)}const o=this.activeViewer?.imageRenderer.effectiveTheme.accentColor;o&&this.sketch&&(this.sketch.polygonSymbol=$e(o),this.sketch.polylineSymbol="panoramic"===s?Je:Ze(o))}startHeightMeasurement(){this.heightMeasurementPixels=[],this.displayNewMeasurementButton=!1,this.draw??=new me({view:this.activeViewer?.imageRenderer});this.draw.create("polyline").on(["cursor-update","vertex-add","draw-complete"],(e=>this.handleDrawEvents(e)))}createPolylineGraphic(){const e=[this.heightMeasurementPixels[0],this.heightMeasurementPixels.at(-1)],i=this.activeViewer?.imageRenderer.spatialReference;if(this.heightGraphic)this.heightGraphic.geometry=new L({paths:[e],spatialReference:i});else{const a=new L({paths:[e],spatialReference:i}),r=this.activeViewer?.imageRenderer.effectiveTheme.accentColor;this.heightGraphic=new t({geometry:a,symbol:Ze(r,2.5)}),this.activeViewer?.addGraphic(this.heightGraphic)}}createPolylineGraphicPano(){const e=this.activeViewer?.imageRenderer.spatialReference,i=this.activeViewer?.imageSize;if(!i)return;const a={x:this.heightMeasurementPixels[0][0],y:this.heightMeasurementPixels[0][1]},r={x:this.heightMeasurementPixels.at(-1)[0],y:this.heightMeasurementPixels.at(-1)[1]},{heading:s,pitch:o}=Y(a,i[0],i[1]),{heading:n,pitch:l}=Y(r,i[0],i[1]),c=[[...ne(s,o)],[...ne(n,l)]];if(this.heightGraphic)this.heightGraphic.geometry=new L({paths:[c],spatialReference:e});else{const i=new L({paths:[c],spatialReference:e});this.heightGraphic=new t({geometry:i,symbol:Je}),this._panoramicViewer.addGraphic(this.heightGraphic,0)}}async handleDrawEvents(e,t){if(this.draw)switch(e.type){case"cursor-update":this.handleDrawCursorUpdateEvents(e);break;case"vertex-add":this.handleDrawVertexAddEvents(e,t);break;case"draw-complete":await this.displayHeightResults()}}initializeMeasurement(e){switch(this.clearMeasurementGraphics(),this.resetMeasurementData(),e){case"distance":this.startMeasurement("polyline");break;case"area":this.startMeasurement("polygon");break;case"height":this.startHeightMeasurement()}}async overlayCameraLocations(e){const{activeViewer:i,currentBestFeature:a,overlayedCameraLocations:r,layer:s,mode:o,state:n}=this,l=i?.imageSize;if(!l||!a||!s||"none"===o||n.includes("loading"))return;const{polygon:c}=T(a.attributes);if(i.removeManyGraphics(r.toArray()),r.removeAll(),e){const{features:e}=await s.queryFeatures({where:`${s.objectIdField} <> ${a.attributes.objectId}`,geometry:c,returnGeometry:!0,outFields:[s.objectIdField]}),n=await Promise.all(e.map((async e=>{const{attributes:i,geometry:r}=e,s=await this.getPixels(r,{feature:a,imageSize:l,mode:o}),n=Ke.clone();return n.outline=new pe({color:[0,0,0],width:1}),new t({attributes:i,symbol:n,geometry:s})})));r.addMany(n),i.addManyGraphics(r.toArray())}}overlayGraphicsOnImage(e,t){this.removeOverlayedGraphicsOnImage(e),this.overlayedMapFeatures.set(e,t),this.activeViewer?.addManyGraphics(t.toArray())}async overlayMapFeatures(e,a=!1){const{activeViewer:r,currentBestFeature:o,mode:n,state:l,layer:c}=this,h=r?.imageSize;if(!h||!o||"none"===n||l.includes("loading")||!c)return;const{polygon:p}=T(o.attributes);try{const{imageGeometryField:t,oiObjectIdField:i}=Fe(e,c.imageGeometryField,c.imageReferenceField);this.imageGeometryField=t.name,this.oiObjectIdField=i.name}catch(g){u.getLogger(this).warn("oriented-imagery-viewer:overlay-map-features",g)}const{features:m}=await e.queryFeatures({geometry:p,returnGeometry:!0,outFields:["*"]}),d=new s((await Promise.all(m.map((async i=>{const r=i.symbol?.clone()??e.renderer?.getSymbol(i)?.clone(),{attributes:s,geometry:l}=i,c=l,{imageGeometryField:p,oiObjectIdField:m}=this;if(p&&m&&_e(e,p,m)&&`${s[m]}`==`${o.attributes.objectId}`)try{return Pe(s,p,e,a,r)}catch(g){u.getLogger(this).warn("oriented-imagery-viewer:overlay-map-features","couldn't create graphic from attributes, geometry will be used",{error:g,feature:i,layer:e,imageGeometryField:this.imageGeometryField,imageReferenceField:this.oiObjectIdField})}switch(c?.type){case"point":{const i=await this.getPixels(c,{feature:o,imageSize:h,mode:n});return new t({attributes:s,layer:e,symbol:r,geometry:i,visible:e.visible&&a})}case"polygon":{const{rings:i,spatialReference:l}=c,u=i.map((e=>e.map((([e,t,i])=>new R({x:e,y:t,z:i,spatialReference:l}))))),p=await Promise.all(u.map((async e=>this.getPixels(e,{feature:o,imageSize:h,mode:n}).then((e=>e.map(re))))));return new t({attributes:s,layer:e,symbol:r,geometry:new O({rings:p,spatialReference:j.WebMercator}),visible:e.visible&&a})}case"polyline":{const{paths:i,spatialReference:l}=c,u=i.map((e=>e.map((([e,t,i])=>new R({x:e,y:t,z:i,spatialReference:l}))))),p=await Promise.all(u.map((async e=>this.getPixels(e,{feature:o,imageSize:h,mode:n}).then((e=>e.map(re))))));return new t({attributes:s,layer:e,symbol:r,geometry:new L({paths:p,spatialReference:j.WebMercator}),visible:e.visible&&a})}case"multipoint":{const{points:i,spatialReference:l}=c,u=i.map((([e,t,i])=>new R({x:e,y:t,z:i,spatialReference:l}))),p=await this.getPixels(u,{feature:o,imageSize:h,mode:n}).then((e=>e.map(re)));return new t({attributes:s,layer:e,symbol:r,geometry:new G({points:p,spatialReference:j.WebMercator}),visible:e.visible&&a})}}return null})))).filter(i));this.overlayGraphicsOnImage(`${e.id}`,d)}async getPixels(e,t){const{imageSize:i,mode:a}=t,r=(await this.worldToImage(Array.isArray(e)?e:[e])).map((e=>{if("default"===a)return new R({x:e.x-.5,y:.5-e.y,spatialReference:j.WebMercator});const[t,r]=i,{heading:s,pitch:o}=Y(e,t,r),n=ne(s,o);return new R(n,j.WebMercator)}));return Array.isArray(e)?r:r[0]}async getMapPoint(e,t){const{feature:i,mode:a,imageSize:r}=t,{elevationSample:s,attributes:o}=i,{elevationSource:n,location:l,elevation:c,cameraHeight:h}=o;let u=l.clone();u.spatialReference.isGeographic&&(u=await x(u,j.WebMercator));const p=await te(c??(l.z??0)-h,{elevationSample:s,elevationSource:n,extent:this.footprintExtent});let m;if("elevationSample"in p&&ie(p.elevationSample)&&(i.elevationSample=p.elevationSample),"default"===a){const t=ee(o,r[0],r[1]);m=await J(Array.isArray(e)?e:[e],{...t,cameraLocation:u},p)}else{const t=ae(o,r[0],r[1]);m=await Z(Array.isArray(e)?e:[e],{...t,cameraLocation:u},p)}return Array.isArray(e)?m:m[0]}async plotMapPoint(e){return this.plotReferencePoint(e),this.transformAndPlotReferencePointOnImage({feature:this.currentBestFeature,selectedLocation:e,options:{signal:this._transformController?.signal}})}plotReferencePointOnGround(e){this._referencePointOnGround&&(this._overlays?.remove(this._referencePointOnGround),this._referencePointOnGround.destroy()),null!=e&&(this._referencePointOnGround=new t({geometry:new R({...e.toJSON()}),symbol:Qe}),this.view?this._overlays?.add(this._referencePointOnGround):this.emit("plot-ground-point",{data:{point:this._referencePointOnGround?.geometry}}))}plotReferencePointOnImage(e){if("image-loaded"===this.state)switch(this.clearReferencePointOnImage(),this.mode){case"default":{const i=c.isSerializable(e)?e.toJSON():e;i.x-=.5,i.y=.5-i.y,this._referencePointOnImage=new t({geometry:new R({spatialReference:this._imageViewer.imageRenderer.spatialReference,...i}),symbol:Qe}),this._imageViewer.addGraphic(this._referencePointOnImage,0);break}case"panoramic":{const{imageSize:i}=this._panoramicViewer;if(!i)return;const[a,r]=i,{heading:s,pitch:o}=Y(e,a,r),n=ne(s,o);this._referencePointOnImage=new t({geometry:new R(n,j.WebMercator),symbol:Xe}),this._panoramicViewer.addGraphic(this._referencePointOnImage,0);break}}}plotLocationPointOnImage(e){if("image-loaded"===this.state)switch(this.clearLocationPointOnImage(),this.mode){case"default":this._plotLocationPointOnDefaultImage(e);break;case"panoramic":this._plotLocationPointOnPanoramicImage(e)}}removeAllOverlayMapFeatures(){this.overlayedMapFeatures.forEach((e=>{this._imageViewer.removeManyGraphics(e.toArray())})),this.overlayedMapFeatures.clear()}removeOverlayedGraphicsOnImage(e){const t=this.overlayedMapFeatures.get(e);t?.length&&(this.activeViewer?.removeManyGraphics(t.toArray()),this.overlayedMapFeatures.delete(e))}resetImage(){switch(this.setMessage("onLoadMessage","info"),this.mode){case"default":this._imageViewer.clearImage(),this._imageViewer.clearGraphics();break;case"panoramic":this._panoramicViewer.clearGraphics()}this._clickTask=m(this._clickTask)}resetMeasurementData(){this.areaMeasurementResult=0,this.areaMeasurementAccuracy=0,this.distanceMeasurementResult=0,this.distanceAccuracyArray=[],this.heightMeasurementPixels=[],this.heightMeasurementResult=0,this.tempDistance=null,this.measurementAngle=null,this.heightMeasurementAccuracy=0,this.heightGraphic=null}async saveDrawing(){const{dataCaptureLayer:e,sketchAdapter:t}=this;if(!e||"data-capture"!==t?.type)return;const{pendingGraphics:i,savedGraphics:a}=t,r=i.get(e.id),s=r?.toArray();if(!r||!s?.length)return;const{addFeatureResults:o}=await this.saveDataCaptureFeatures(s),n=o.reduce(((t,{objectId:i,globalId:a,error:r},o)=>{const n=s[o],{attributes:l}=n;return r?t.error.push(n):(i&&(l[e.objectIdField]=i),a&&e.globalIdField&&(l[e.globalIdField]=a),t.success.push(n)),t}),{success:[],error:[]});a.addMany(n.success),r.removeAll(),r.addMany(n.error)}async saveDataCaptureFeatures(e){const{activeViewer:t,currentBestFeature:a,dataCaptureLayer:r,mode:s}=this,o=t?.imageSize;if(!o||!a||"none"===s)throw new n("Image size, current best feature and mode are required to save data capture features");if(!r)throw new n("Data capture layer is not available");const l=await Promise.all(e.map((async e=>{const t=e.clone(),{geometry:i}=t;if(!i)return;const n=i.type,l=r.hasZ,c=r.geometryType,h=n!==c,u=h?await import("./transformers.js"):null,p=u?.default[c],m=h?p?.(i):i;if(m)switch(m.type){case"point":return t.geometry=await this.getMapPoint(se(s,m,o),{feature:a,imageSize:o,mode:s}),l||(delete t.geometry.z,t.geometry.hasZ=!1),t.geometry.hasM=!1,t;case"polygon":{const e=await Promise.all(m.rings.map((async e=>this.getMapPoint(e.map((([e,t,i])=>se(s,{x:e,y:t,z:i},o))),{feature:a,imageSize:o,mode:s}))));return t.geometry=new O({spatialReference:e[0][0].spatialReference,hasZ:l,hasM:!1,rings:e.map((e=>e.map(re)))}),t}case"polyline":{const e=await Promise.all(m.paths.map((async e=>this.getMapPoint(e.map((([e,t,i])=>se(s,{x:e,y:t,z:i},o))),{feature:a,imageSize:o,mode:s}))));return t.geometry=new L({spatialReference:e[0][0].spatialReference,hasZ:l,hasM:!1,paths:e.map((e=>e.map(re)))}),t}}}))),c=l.filter(i);return r.applyEdits({addFeatures:c}).then((e=>{const{addFeatureResults:t}=e;let i=0;const a=l.map((e=>{const a=t[i++];return e?a:{error:new n("Error in saving data capture features"),objectId:null,globalId:null}}));return{...e,addFeatureResults:a}}))}async searchBestImage(e,t){try{const i=await H(e,t);i&&await this._processFeatureResponse(i,e.point,{signal:t?.signal})}catch(i){y(i)||(this.setMessage("imageLoadError","error",i.message),u.getLogger(this).error("error occurred while finding best image",i))}}selectBestFeature(e){this.currentBestFeature=this.features?.find((({attributes:t})=>t.objectId===Number(e)))}setAdditionalCameraLocationsVisibility(e){this.additionalCameraLocations.forEach((t=>{t.visible=e}))}setAdditionalCoverageVisibility(e){this.additionalFootprints.forEach((t=>{t.visible=e}))}setCurrentCoverageVisibility(e){this.bestFeatureCurrentFootprint&&(this.bestFeatureCurrentFootprint.visible=e),this.currentBestFeatureLocation&&(this.currentBestFeatureLocation.visible=e)}setMapImageConversionToolState(e){this.mapImageConversionToolState=e}async startDataCapture(e,t){const i=this.activeViewer?.imageRenderer,{oiObjectIdField:a,currentBestFeature:r}=this;if(!i||!r||!a)return;const{attributes:{objectId:o}}=r,n=this.overlayedMapFeatures.get(e.id)?.toArray()??[],l=[],c=[];for(const s of n)`${s.getAttribute(a)}`==`${o}`?l.push(s):c.push(s);this.overlayGraphicsOnImage(e.id,new s(c)),this.collectionId=e.id;const h=await this.loadSketch(t),u=await this.loadDataCaptureAdapter(t);f(t),h.layer.addMany(l),h.layer.blendMode="source-atop",u.savedGraphics.addMany(l);i.ui.find("zoom").visible=!1,i.map.layers.add(this.sketchGraphicsLayer)}async stopDataCapture(e=!1){this.sketch?.cancel(),this.sketchGraphicsLayer?.removeAll(),this.sketchAdapter=d(this.sketchAdapter),this.sketch=d(this.sketch),this.collectionId=null;const{dataCaptureLayer:t}=this,i=this.activeViewer?.imageRenderer;if(!i||i.destroyed)return;i.map.layers.remove(this.sketchGraphicsLayer),e&&t&&await this.overlayMapFeatures(t,!0);const a=i.ui.find("zoom");a&&(a.visible=!0)}stopMeasurement(){this.heightMeasurementPixels=[],this.draw?.reset(),this.sketch?.cancel()}toggleAllOverlayMapFeatures(e){this.overlayedMapFeatures.forEach((t=>{this._toggleVisiblity(t,e)}))}toggleOverlayMapFeatures(e,t){const i=this.overlayedMapFeatures.get(e);i&&this._toggleVisiblity(i,t)}toggleSelection(e){const{sketch:t}=this;t&&(t.updateOnGraphicClick=e,t.cancel())}async transformAndPlotReferencePointOnImage(e){const{selectedLocation:t,options:i}=e;let a=!1,r=!1;const s=this.bestFeatureFootprint?.geometry;switch(s?.type){case"polygon":{const e=t.spatialReference.equals(s.spatialReference)?t:await x(t,s.spatialReference);a=s.contains(e);break}case"mesh":{const e=t.spatialReference.equals(s.spatialReference)?t:await x(t,s.spatialReference);r=s.extent.contains(e);break}}if(!a&&!r)return void this.clearReferencePointOnImage();const o=await this.worldToImage(t,i);if(o)return f(i),this.plotReferencePointOnImage(o),{x:o.x,y:o.y};this.clearReferencePointOnImage()}updateSuitabilities(e){e.sort(((e,t)=>e.suitability-t.suitability)),this._suitabilities=e;const t=this._suitabilities.map((({feature:e})=>e));this._initialCurrentCoverageUpdate=!0,this._updateFeatures(t),this._groupFeaturesBySectors()}async _fetchFeatures(e,t){if(!this.view)return;const i=this.layer;if(i){const a={include:i},r=this.view.toScreen(e);if(!r)return;const s=await this.view.hitTest(r,a);return this._processHitTestResults(i,s,t)}}async _fetchFeaturesWithController(e,t){try{await this._fetchFeatures(e,t)}catch(i){if(y(i))return;this.setMessage("imageLoadError","error"),u.getLogger(this).error("error occurred while fetching features",i)}}_groupFeaturesBySectors(){const{_suitabilities:e,additionalFeatures:t,currentBestFeature:i,features:a,invalidCameraHeading:r}=this;if(!e||!t||!i||!a||r)return void(this._sectorData=null);this._sectorData={};for(const c of ve)this._sectorData[c]=new s;const o=e.map(((e,t)=>({...e,featureIndex:t})));o.sort(((e,t)=>e.trueSuitability-t.trueSuitability));const n=o.map((({distance:e})=>e)),l=Math.max(...n);o.forEach((e=>{const{distance:t,angle:i,featureIndex:r}=e,s=t/l*we[2],o=lt(t,l),n=ct(i);if(!this._sectorData)return;const c=we[3]+s*Math.sin(i*Math.PI/180),h=we[3]+s*Math.cos(i*Math.PI/180);let u;const p=a.at(r),m=p===this.currentBestFeature,d=this.currentBestFeature?.attributes.cameraPitch&&this.currentBestFeature?.attributes.cameraPitch<5;if(m&&d)u=-90;else{const e=c-we[3],t=h-we[3],i=t/Math.sqrt(e**2+t**2);let a=180*Math.acos(i)/Math.PI;(e<0&&t<0||e<0&&t>0)&&(a*=-1),u=a}const g=""===o?n:`${o}_${n}`;m&&(u===this.bestFeatureAngle?this.previousFeatureAngle=u:this.bestFeatureAngle=u,this.navigatorCurrentBestFeature=d?null:{x:c,y:h,direction:n});const y=this._sectorData[g];y.add({angle:i,featureIndex:r,x:c,y:h,objectID:p.attributes.objectId,sector:g,featureIndexInSector:y.length})}))}_plotLocationPointOnDefaultImage(e){const i=c.isSerializable(e)?e.toJSON():e;i.x-=.5,i.y=.5-i.y,this._locationPointOnImage=new t({geometry:new R({spatialReference:this._imageViewer.imageRenderer.spatialReference,...i}),symbol:Ye}),this._imageViewer.addGraphic(this._locationPointOnImage,0)}_plotLocationPointOnPanoramicImage(e){const{imageSize:i}=this._panoramicViewer;if(!i)return;const[a,r]=i,{heading:s,pitch:o}=Y(e,a,r),n=ne(s,o);this._locationPointOnImage=new t({geometry:new R(n,j.WebMercator),symbol:et}),this._panoramicViewer.addGraphic(this._locationPointOnImage,0)}async _processFeatureResponse(e,t,i){const{features:a}=e;if(!a?.length)return this.setMessage("noImageError","error"),void(this.currentBestFeature=null);this.coveragePolygons.removeAll(),this.coverageFrustums.removeAll(),this.pointSources.removeAll();const{features:r,polygons:s,frustums:o}=this.filterByFootprints(a,t);if(!r.length)return this.setMessage("noImageError","error"),void(this.currentBestFeature=null);let n;if(this.coveragePolygons.addMany(s),this.coverageFrustums.addMany(o),s[0]){let e=new O({spatialReference:s[0].spatialReference});for(const i of s)e=await A(e,i);const t=[];for(const{geometry:i}of r)e.contains(i)||t.push([i.x,i.y]);if(t.sort(((e,t)=>+E([e,t]))),e.addRing(t),this.footprintExtent=de(e.extent,2,2),this.view?.supportsGround)try{n=await this.view.map.ground.createElevationSampler(this.footprintExtent,i)}catch(l){y(l)||u.getLogger(this).error(l)}}if((n||r[0].attributes.elevationSource)&&this.footprintExtent){const e=r[0].attributes.elevationSource;$(e)&&!n&&(n=await Q({extent:this.footprintExtent,lod:e.lod,url:e.url,rasterFunction:e.rasterFunction}));const i=await te((r[0].attributes.location.z??0)-r[0].attributes.cameraHeight,{elevationSample:n,elevationSource:e,extent:this.footprintExtent}),[a,...s]=await K([t,...r.map((e=>e.attributes.geometry.clone()))],i);r[0].elevationSample=n??i.elevationSample,t.elevation=a.z,r.forEach(((e,t)=>{e.attributes.elevation=s[t].z}))}r[0].elevationSample&&r.forEach((e=>{e.elevationSample=r[0].elevationSample})),this._suitabilities=D({features:r,selectedPoint:t,camera:ot(this.view)?this.view.camera:null,currentImage:this.currentBestFeature}),this.updateSuitabilities(this._suitabilities)}async _processHitTestResults(e,t,i){const{screenPoint:a,results:[r]}=t,s="graphic"===r?.type&&this.shouldShowSelectedImage,o=r?.mapPoint??this.view?.toMap(a);if(!o)return;const{layerFloorFilterClause:n}=this,l=e.spatialReference.equals(o.spatialReference)?o:await x(o,e.spatialReference),c=I("1=1",I(e.definitionExpression,n)),h=l.spatialReference.isGeographic?1:S(l.spatialReference),u={layerInstanceOrURL:e,point:l,queryParams:{where:c,maximumDistance:e.maximumDistance?e.maximumDistance/h:void 0,objectIds:s?[r.graphic.getAttribute(e.objectIdField)]:void 0}};await this.searchBestImage(u,i)}_resetCursor(){const{activeViewer:e}=this;e&&(e.imageRenderer.cursor=this._previousCursor)}_setMeasurementCursor(){const{activeViewer:e}=this;e&&(this._previousCursor=e.imageRenderer.cursor,e.imageRenderer.cursor="crosshair")}_toggleVisiblity(e,t){e.forEach((e=>{e.visible=t}))}_updateFeatures(e){if(!e.length)return this.currentBestFeature=null,void this.additionalFeatures.removeAll();this.features.removeAll(),this.features.addMany(e),e.length>1?this.additionalFeatures.addMany(e.slice(1)):this.additionalFeatures.removeAll(),this._updateGroundElevation=!0,this.currentBestFeature=e[0]}async _updatePointsAndPolygons(e){const{pointSources:i,currentBestFeature:a,currentCoverageVisible:r,isAdditionalPointSourcesVisible:s}=this;if(a&&(this.additionalFootprints.removeAll(),this.additionalCameraLocations.removeAll(),this.bestFeatureCurrentFootprint&&(this.bestFeatureCurrentFootprint.destroy(),this.bestFeatureCurrentFootprint=null,this.bestFeatureFootprint=null),!this.invalidCameraHeading)){await(this._adapter?.createFootprints(e)),f(e);for(const e of i)e.imageID===a.attributes.objectId?this.currentBestFeatureLocation=new t({attributes:{imageID:e.imageID},geometry:e.clone(),symbol:tt,visible:r}):this.additionalCameraLocations.push(new t({attributes:{imageID:e.imageID},geometry:e.clone(),symbol:Ke,visible:s}))}}_updateCurrentBestFeature(e){if(!e)return;this.currentBestFeature=this.features?.at(e.featureIndex);const t=this.currentBestFeature?.attributes.cameraPitch&&this.currentBestFeature?.attributes.cameraPitch<5;let i;if(t)i=-90;else{const t=e.x-we[3],a=e.y-we[3],r=a/Math.sqrt(t**2+a**2);let s=180*Math.acos(r)/Math.PI;(t<0&&a<0||t<0&&a>0)&&(s*=-1),i=s}i===this.bestFeatureAngle?this.previousFeatureAngle=i:this.bestFeatureAngle=i,this.navigatorCurrentBestFeature=t?null:{x:e.x,y:e.y,direction:e.sector.includes("_")?e.sector.split("_")[1]:e.sector}}clearGraphics(){this._imageViewer.clearGraphics(),this._panoramicViewer.clearGraphics()}clearReferencePointOnImage(){this._referencePointOnImage&&(this._imageViewer.removeGraphic(this._referencePointOnImage),this._panoramicViewer.removeGraphic(this._referencePointOnImage),this._referencePointOnImage=d(this._referencePointOnImage))}clearLocationPointOnImage(){this._locationPointOnImage&&(this._imageViewer.removeGraphic(this._locationPointOnImage),this._panoramicViewer.removeGraphic(this._locationPointOnImage),this._locationPointOnImage=d(this._locationPointOnImage))}plotReferencePoint(e){"mapPoint"in e?this.plotReferencePointOnGround(e.mapPoint):this.plotReferencePointOnGround(e)}setMessage(e,t,i,a){this.displayMessage={key:e,type:t,data:i,map:a}}async transformAndPlotSelectedLocation(e){const{currentBestFeature:t,invalidCameraHeading:i,selectedPoint:a,activeViewer:r}=this;if(this._crossSymbol&&(this._panoramicViewer.removeGraphic(this._crossSymbol),this._imageViewer.removeGraphic(this._crossSymbol),this._crossSymbol=d(this._crossSymbol)),!a||!t||"image-loaded"!==r?.state||i)return;let s;try{s=await this.worldToImage(a,e),f(e),await this.plotSelectedPointOnImage(s,e)}catch(o){y(o)||u.getLogger(this).error("failed to transform map point to pixel, cross symbol will not be plotted on image",{error:o,selectedPoint:a,feature:t})}}async worldToImage(e,t){const{footprintExtent:i}=this,{imageSize:a}=this.activeViewer;if("none"===this.mode||!this.currentBestFeature||!a||!i)return;const{attributes:{location:r,elevationSource:s,cameraHeading:o,elevation:n,cameraHeight:l},elevationSample:c}=this.currentBestFeature;let h=r.clone();const u=await te(n??(r.z??0)-l,{elevationSample:c,elevationSource:s});this.currentBestFeature.elevationSample=u.elevationSample;const p=Array.isArray(e)?e:[e];let m,d=await Promise.all(p.map((e=>new Promise((t=>{if(!e.hasZ)return t(K(e,u));t(e)})))));if(r.spatialReference.isGeographic&&(h=await x(h,j.WebMercator,t)),d=await Promise.all(d.map((async e=>h.spatialReference.equals(e.spatialReference)?e:await x(e,h.spatialReference,t)))),f(t),"panoramic"===this.mode)m=ce(d,{imageHeight:a[1],imageWidth:a[0],cameraHeading:o,cameraLocation:h});else{const e=oe(this.currentBestFeature.attributes,a[0],a[1]);m=he(d,{...e,cameraLocation:h})}return Array.isArray(e)?m:m[0]}updateCurrentCoveragePolygon(e){const{additionalFootprints:i,additionalCameraLocations:a,currentBestFeature:r,currentBestFeatureLocation:s,currentCoverageVisible:o,selectedPoint:n,view:l,_adapter:c,mode:h}=this,{attributes:{objectId:u},elevationSample:p}=r;if(this._initialCurrentCoverageUpdate){if(this._overlays?.removeAll(),this._initialCurrentCoverageUpdate=!1,this.bestFeatureCurrentFootprint=d(this.bestFeatureCurrentFootprint),e&&!this.invalidCameraHeading&&(e.visible=o,this.bestFeatureCurrentFootprint=e),l){const e=[...i,...a,s].filter(nt);l.supportsGround&&p&&c?.updateGroundElevation&&(this._updateGroundElevation&&c.updateGroundElevation(e,p),"panoramic"===h&&c.updateGroundElevation([this.bestFeatureCurrentFootprint],p)),this._updateGroundElevation=!1,n&&(e.splice(-2,0,this.bestFeatureCurrentFootprint),e.push(new t({geometry:n.clone(),symbol:We.clone(),attributes:{imageID:u}}))),this._overlays.graphics.addMany(e)}}else if(l){if(this.invalidCameraHeading)return;this.bestFeatureCurrentFootprint&&(this._overlays?.remove(this.bestFeatureCurrentFootprint),this.bestFeatureCurrentFootprint=d(this.bestFeatureCurrentFootprint));const t=this.bestFeatureCurrentFootprint&&this._overlays?this._overlays.graphics.indexOf(this.bestFeatureCurrentFootprint):-1;e&&(this.bestFeatureCurrentFootprint=e,l?.supportsGround&&p&&c?.updateGroundElevation&&"panoramic"===h&&c.updateGroundElevation([e],p),e.visible=this.currentCoverageVisible,this._overlays?.graphics.add(this.bestFeatureCurrentFootprint,t>=0?t:this._overlays.graphics.length-1))}}};e([M()],gt.prototype,"activeLayer",null),e([M({readOnly:!0})],gt.prototype,"activeViewer",null),e([M()],gt.prototype,"accuracyParametersMissing",null),e([M()],gt.prototype,"additionalFeatures",void 0),e([M({type:s.ofType(t)})],gt.prototype,"additionalCameraLocations",void 0),e([M({type:s.ofType(t)})],gt.prototype,"additionalFootprints",void 0),e([M()],gt.prototype,"areaMeasurementResult",void 0),e([M()],gt.prototype,"areaMeasurementAccuracy",void 0),e([M()],gt.prototype,"bestFeatureAngle",void 0),e([M()],gt.prototype,"bestFeatureCurrentFootprint",void 0),e([M({type:t})],gt.prototype,"bestFeatureFootprint",void 0),e([M({type:Number})],gt.prototype,"brightness",null),e([M()],gt.prototype,"collectionId",void 0),e([M({type:Number})],gt.prototype,"contrast",null),e([M()],gt.prototype,"conversionProps",void 0),e([M()],gt.prototype,"coverageFrustums",void 0),e([M()],gt.prototype,"coveragePolygons",void 0),e([M()],gt.prototype,"currentBestFeature",void 0),e([M()],gt.prototype,"currentBestFeatureLocation",void 0),e([M()],gt.prototype,"currentCoverageVisible",void 0),e([M({json:{write:!1}})],gt.prototype,"determineWorkflowForFeature",void 0),e([M()],gt.prototype,"disabled",void 0),e([M()],gt.prototype,"displayMessage",void 0),e([M()],gt.prototype,"displayNewMeasurementButton",void 0),e([M()],gt.prototype,"distanceMeasurementResult",void 0),e([M()],gt.prototype,"distanceAccuracyArray",void 0),e([M()],gt.prototype,"dataCaptureLayer",void 0),e([M({readOnly:!0})],gt.prototype,"featureCount",null),e([M()],gt.prototype,"features",void 0),e([M()],gt.prototype,"groundCoordinates",void 0),e([M()],gt.prototype,"heightMeasurementPixels",void 0),e([M()],gt.prototype,"heightGraphic",void 0),e([M()],gt.prototype,"heightMeasurementResult",void 0),e([M()],gt.prototype,"heightMeasurementAccuracy",void 0),e([M()],gt.prototype,"measurementAngle",void 0),e([M()],gt.prototype,"tempDistance",void 0),e([M({readOnly:!0})],gt.prototype,"imageGalleryEnabled",null),e([M()],gt.prototype,"imageGeometryField",void 0),e([M({readOnly:!0})],gt.prototype,"imageLoaded",null),e([M()],gt.prototype,"imageLocationToolState",void 0),e([M({readOnly:!0})],gt.prototype,"invalidCameraHeading",null),e([M()],gt.prototype,"imagePointsInView",null),e([M()],gt.prototype,"isAdditionalCoverageVisible",void 0),e([M()],gt.prototype,"isAdditionalPointSourcesVisible",void 0),e([M()],gt.prototype,"layer",void 0),e([M()],gt.prototype,"layerView",null),e([M({readOnly:!0})],gt.prototype,"layerFloorFilterClause",null),e([M({type:Number})],gt.prototype,"localPort",void 0),e([M()],gt.prototype,"mapImageConversionToolState",void 0),e([M()],gt.prototype,"measureType",void 0),e([M()],gt.prototype,"measurementGraphic",void 0),e([M({readOnly:!0,value:"none"})],gt.prototype,"mode",null),e([M()],gt.prototype,"navigatorCurrentBestFeature",void 0),e([M()],gt.prototype,"oiObjectIdField",void 0),e([M({type:s.ofType(t)})],gt.prototype,"overlayedCameraLocations",void 0),e([M()],gt.prototype,"overlayedMapFeatures",void 0),e([M()],gt.prototype,"pixelCoordinates",void 0),e([M()],gt.prototype,"pointSources",void 0),e([M({readOnly:!0})],gt.prototype,"popupEnabled",null),e([M()],gt.prototype,"previousFeatureAngle",void 0),e([M()],gt.prototype,"referencePoint",null),e([M({readOnly:!0})],gt.prototype,"sectorData",null),e([M()],gt.prototype,"selectedPoint",void 0),e([M({type:Number})],gt.prototype,"sharpness",null),e([M()],gt.prototype,"shouldShowSelectedImage",void 0),e([M()],gt.prototype,"sketch",void 0),e([M()],gt.prototype,"draw",void 0),e([M()],gt.prototype,"sketchAdapter",void 0),e([M({readOnly:!0})],gt.prototype,"sketchGraphicsLayer",null),e([M({readOnly:!0})],gt.prototype,"state",null),e([M({readOnly:!0})],gt.prototype,"thumbnails",null),e([M()],gt.prototype,"updateFootprint",void 0),e([M()],gt.prototype,"updateFootprintPanorama",void 0),e([M({value:null})],gt.prototype,"view",null),e([M()],gt.prototype,"_adapter",void 0),e([M()],gt.prototype,"_sketchGraphicsLayer",null),e([M()],gt.prototype,"_highlightedFeatureHandle",void 0),e([M()],gt.prototype,"_imageViewer",void 0),e([M()],gt.prototype,"_initialCurrentCoverageUpdate",void 0),e([M()],gt.prototype,"_locationPointOnImage",void 0),e([M()],gt.prototype,"_overlays",void 0),e([M({readOnly:!0})],gt.prototype,"_overlaysView",null),e([M()],gt.prototype,"_panoramicViewer",void 0),e([M()],gt.prototype,"_previousCursor",void 0),e([M()],gt.prototype,"_referencePointOnGround",void 0),e([M()],gt.prototype,"_referencePointOnImage",void 0),e([M()],gt.prototype,"_sectorData",void 0),e([M({readOnly:!0})],gt.prototype,"_updatingHandles",void 0),e([M()],gt.prototype,"footprintExtent",void 0),e([M()],gt.prototype,"_featureChangedTask",void 0),gt=e([C("esri.widgets.OrientedImageryViewer.OrientedImageryViewerViewModel")],gt);const yt=gt;export{yt as default};
|
|
5
|
+
import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../Graphic.js";import{isSome as i,equals as a}from"../../core/arrayUtils.js";import{createTask as r}from"../../core/asyncUtils.js";import s from"../../core/Collection.js";import{deprecatedProperty as o}from"../../core/deprecate.js";import n from"../../core/Error.js";import l from"../../core/Evented.js";import c from"../../core/JSONSupport.js";import{equalsShallow as h}from"../../core/lang.js";import u from"../../core/Logger.js";import{clamp as p}from"../../core/mathUtils.js";import{abortMaybe as m,destroyMaybe as d}from"../../core/maybe.js";import g from"../../core/Promise.js";import{isAbortError as y,throwIfAborted as f,waitTick as v}from"../../core/promiseUtils.js";import w from"../../core/ReactiveMap.js";import{on as b,watch as F,syncAndInitial as _,initial as P}from"../../core/reactiveUtils.js";import{sqlAnd as I}from"../../core/sql.js";import{getMetersPerUnitForSR as S}from"../../core/unitUtils.js";import{property as M}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import{subclass as C}from"../../core/accessorSupport/decorators/subclass.js";import{distance as k}from"../../core/libs/gl-matrix-2/math/vec2.js";import{UpdatingHandles as V}from"../../core/support/UpdatingHandles.js";import{union as A}from"../../geometry/geometryEngineAsync.js";import G from"../../geometry/Multipoint.js";import R from"../../geometry/Point.js";import O from"../../geometry/Polygon.js";import L from"../../geometry/Polyline.js";import{projectWithZConversion as x}from"../../geometry/projection.js";import j from"../../geometry/SpatialReference.js";import{isClockwise as E}from"../../geometry/support/coordsUtils.js";import{geographicToWebMercator as B}from"../../geometry/support/webMercatorUtils.js";import z from"../../layers/GraphicsLayer.js";import{searchImages as H}from"../../layers/orientedImagery/queries.js";import{calculateSuitabilities as D}from"../../layers/orientedImagery/core/bestImageUtils.js";import{createCoveragePolygon as T,computePolygonForInspection as U,resizePolygon as N,checkIfPolygonContainsSelectedPoint as W}from"../../layers/orientedImagery/core/coverageUtils.js";import{isConstantElevation as q,isElevationSource as $}from"../../layers/orientedImagery/core/ElevationSourceDefinitions.js";import{imageToWorld as J,imageToWorldPanoramic as Z}from"../../layers/orientedImagery/transformations/imageToWorld.js";import K from"../../layers/orientedImagery/transformations/updateElevation.js";import{getElevationSampler as Q}from"../../layers/orientedImagery/transformations/updateElevationUtils.js";import{getInitialAngle as X,convertPixelToHeadingPitch as Y,getImageToWorldProperties as ee,getUpdateElevationProps as te,isElevationSampler as ie,getImageToWorldPanoramicProperties as ae,pointToArray as re,transformGraphicCoordinatesToPixel as se,getWorldToImageProperties as oe,convertHeadingPitchToSphereVertex as ne,or as le}from"../../layers/orientedImagery/transformations/utils.js";import{worldToImagePanoramic as ce,worldToImage as he}from"../../layers/orientedImagery/transformations/worldToImage.js";import{getFloorFilterClause as ue}from"../../layers/support/floorFilterUtils.js";import pe from"../../symbols/SimpleLineSymbol.js";import me from"../../views/draw/Draw.js";import{scale as de}from"../../views/draw/support/drawUtils.js";import{ViewEventPriorities as ge}from"../../views/input/InputManager.js";import ye from"../PanoramicViewer.js";import{invalidCameraHeading as fe,sectorsInOrder as ve,sectorsRadii as we}from"./constants.js";import{configureSketchTool as be,extractFieldsFromDataCaptureLayer as Fe,isValidDataCaptureLayer as _e,constructGraphicFromImageGeometry as Pe}from"./dataCaptureUtils.js";import{isFeatureAttachment as Ie,getImageSourceFromAttachment as Se}from"./galleryUtils.js";import{formatPixels as Me,heightMeasurementPanoramic as Ce,heightMeasurement2D as ke,calculateHeightAccuracyPanoramic as Ve,calculateHeightAccuracy as Ae,pixelAreaMeasurement2D as Ge,pixelAreaMeasurementPanoramic as Re,pixelDistanceMeasurement2D as Oe,pixelDistanceMeasurementPanoramic as Le,generateCombinations as xe,getRootOfSumOfSquaredErrors as je,generateCombinationsPanoramic as Ee,calculateReferenceImagePointPanoramic as Be,calculateAnglePano as ze,calculateTempImagePoint as He,calculateAngle as De,getModeCorrectedPoint as Te,calculateCorrectedPixel as Ue,calculateHeightFromTemporaryDistance as Ne}from"./imageMeasurementUtils.js";import{crossSymbol as We,crossSymbol3D as qe,measurementPolygonSymbol as $e,polylineSymbolPanoramic as Je,measurementPolylineSymbol as Ze,sourcePointSymbol as Ke,diamondSymbol as Qe,diamondSymbol3D as Xe,locationSymbol as Ye,locationSymbol3D as et,activeSourcePointSymbol as tt}from"./symbols.js";import{isNoAttachmentError as it,getContentType as at,isTifOrMrf as rt,filterOILLayerView as st,isSceneView as ot,isGraphic as nt,calculateSegment as lt,calculateDirection as ct}from"./utils.js";import ht from"./components/ImageViewer.js";const ut={click:"view-click",imageClick:"image-click",interactionHandles:"interaction-handles",footprintHandles:"footprint-handles",sketchHandles:"sketch-handles"},pt=new Set(["JPG","JPEG"]),mt=/\.(\w+)$/,dt=()=>new n("orientedimageryviewer:sketch-not-initialized","Sketch property is not initialized, call loadSketch first");let gt=class extends(l.EventedMixin(g)){constructor(e){super(e),this.additionalFeatures=new s,this.additionalCameraLocations=new s,this.additionalFootprints=new s,this.areaMeasurementResult=0,this.areaMeasurementAccuracy=0,this.bestFeatureAngle=0,this.bestFeatureCurrentFootprint=null,this.bestFeatureFootprint=null,this.collectionId=null,this.conversionProps=null,this.coverageFrustums=new s,this.coveragePolygons=new s,this.currentBestFeature=null,this.currentBestFeatureLocation=null,this.currentCoverageVisible=!0,this.determineWorkflowForFeature=async(e,t,i)=>{const{currentBestFeature:a,selectedPoint:r,view:s}=this;if(s?.closePopup(),a&&r){this._initialCurrentCoverageUpdate=!0,this._updateGroundElevation=!0;try{await this._updatePointsAndPolygons(i),await this._loadImage(i)}catch(o){y(o)||(this.loadImageError(o),u.getLogger(this).error("#loadIImage()","error occured while loading image",o))}}},this.disabled=!1,this.displayMessage={key:"onLoadMessage",type:"info"},this.displayNewMeasurementButton=!0,this.distanceMeasurementResult=0,this.distanceAccuracyArray=[],this.dataCaptureLayer=null,this.features=new s,this.groundCoordinates=null,this.heightMeasurementPixels=[],this.heightGraphic=null,this.heightMeasurementResult=0,this.heightMeasurementAccuracy=0,this.measurementAngle=null,this.tempDistance=null,this.imageGeometryField=null,this.imageLocationToolState=!1,this.isAdditionalCoverageVisible=!1,this.isAdditionalPointSourcesVisible=!1,this.layer=null,this.localPort=null,this.mapImageConversionToolState=!1,this.measureType=null,this.measurementGraphic=null,this.navigatorCurrentBestFeature=null,this.oiObjectIdField=null,this.overlayedCameraLocations=new s,this.overlayedMapFeatures=new w,this.pixelCoordinates=null,this.pointSources=new s,this.previousFeatureAngle=0,this.selectedPoint=null,this.shouldShowSelectedImage=!1,this.sketch=null,this.draw=null,this.sketchAdapter=null,this.updateFootprint=async(e,t)=>{"image-loaded"===this.state&&await(this._adapter?.updateFootprint(e,t))},this.updateFootprintPanorama=async(e,t)=>{await(this._adapter?.updateFootprintPanorama(e,t))},this._adapter=null,this._highlightedFeatureHandle=null,this._imageViewer=new ht,this._initialCurrentCoverageUpdate=!0,this._locationPointOnImage=null,this._overlays=new z({listMode:"hide",internal:!0,elevationInfo:{mode:"absolute-height"}}),this._panoramicViewer=new ye,this._previousCursor=null,this._referencePointOnGround=null,this._referencePointOnImage=null,this._sectorData=null,this._updatingHandles=new V,this._clickTask=null,this._crossSymbol=null,this.footprintExtent=null,this._featureChangedTask=null,this._openPopupTask=null,this._suitabilities=null,this._transformController=new AbortController,this._updateFootprintTask=null,this._updateGroundElevation=!1,this.hideImageGeometry=e=>{},this.highlight=e=>{if(!this._overlaysView)return;this.removeHighlight();const t=this.additionalFootprints.find((({attributes:{imageID:t}})=>t===Number(e)));this._highlightedFeatureHandle=t?this._overlaysView?.highlight(t):null},this.loadDataCaptureAdapter=async e=>{await this.loadSketch(e);const t=import("./adapters/sketch/DataCaptureAdapter.js"),{default:i}=await t;return f(e),this.sketchAdapter=new i({viewModel:this}),this.sketchAdapter},this.loadImageFromSource=async(e,t)=>this._updatingHandles.addPromise(this._loadImageFromSourceInternal(e,t)),this.loadImageViewer=e=>{this._imageViewer.container=e},this.loadPanoramicViewer=e=>{this._panoramicViewer.container=e},this.removeHighlight=()=>this._highlightedFeatureHandle?.remove(),this.revealImageGeometry=e=>{},this.toggleImageAttributes=()=>{m(this._openPopupTask),this._openPopupTask=r((async e=>{const{currentBestFeature:i,popupEnabled:a,layer:r,view:s}=this;if(s?.closePopup(),!(s&&i&&a&&r))return;const{attributes:o,geometry:n}=i,l=new t({geometry:n,attributes:o.toJSON(),layer:r});f(e),await s.openPopup({features:[l],location:o.location.clone()})}))},this._createViewClickHandle=()=>{if(this.removeHandles(ut.click),"disabled"===this.state||null==this.view)return;const e=this.mapImageConversionToolState&&"image-loaded"===this.state?this._mapImageConversionToolViewClickHandler:this._viewClickHandler;this.addHandles(this.view.on("click",e,ge.WIDGET),ut.click)},this._createImageClickHandle=()=>{this.removeHandles(ut.imageClick);const{mapImageConversionToolState:e,mode:t,activeViewer:i,currentBestFeature:a,footprintExtent:s}=this,o=i?.imageSize;if(!(e&&"none"!==t&&o&&s&&a))return;i.clickAction="pixel-location";let n=null;const l=b((()=>i),"pixel-location",(e=>{this.plotReferencePointOnImage(e),n?.abort(),n=r((async i=>{if(!e)return;const r=await this.getMapPoint(e,{feature:a,imageSize:o,mode:t}).then((e=>{const t=this.view?.spatialReference;return le(!t,e.spatialReference.equals(t))?e:x(e,t)}));f(i),this.plotReferencePointOnGround(r)}))}));this.addHandles(l,ut.imageClick)},this._createImageLocationHandle=()=>{this.removeHandles(ut.imageClick);const{imageLocationToolState:e,mode:t,activeViewer:i,currentBestFeature:a,footprintExtent:s}=this,o=i?.imageSize;if(!(e&&"none"!==t&&o&&s&&a))return;i.clickAction="pixel-location";let n=null;const l=b((()=>i),"pixel-location",(e=>{this.pixelCoordinates=e,this.plotLocationPointOnImage(e),n?.abort(),n=r((async i=>{if(!e)return;let r=await this.getMapPoint(e,{feature:a,imageSize:o,mode:t});f(i);const s=this.view?.spatialReference;s&&!r.spatialReference.equals(s)&&(r=await x(r,s),f(i)),this.groundCoordinates=r}))}));this.addHandles(l,ut.imageClick)},this._loadImage=async e=>{const{currentBestFeature:t,layer:i,mode:a}=this;if(this.clearGraphics(),!i||!t||"none"===a)return;const{attributes:r}=t,{imagePath:s,imageRotation:o,cameraHeading:n,cameraRoll:l,cameraPitch:c,objectId:h,cameraOrientation:p,location:m}=r,d=(l??0)+(o??0),g=m.spatialReference.isWGS84&&4!==p?.type?B(m):new R(m);let v=s;if(Ie(s))try{v=await Se(i,h,e)}catch(w){if(y(w))return;return it(w)?(u.getLogger(this).error(w),void this.setMessage("noAttachment","error",`${i.objectIdField}: ${h}`)):(u.getLogger(this).error(w,{[i.objectIdField]:h,layer:i}),void this.setMessage("imageLoadError","error",`query-attachments-failed:${i.objectIdField} ${h}`))}try{await this.loadImageFromSource(v,{imageRotation:d,options:e,pitch:c,yaw:n,mode:a,cameraLocation:g}),f(e),await this.transformAndPlotSelectedLocation(e)}catch(w){y(w)||this.loadImageError(w)}},this._loadImageFromSourceInternal=async(e,t)=>{const{mode:i,imageRotation:a,options:r}=t,s="string"==typeof e,o=s?e:e.url,{pathname:n,searchParams:l}=new URL(o);let c=s?n.match(mt)?.[1]:e.datasetFormat;if(!c)try{c=await at(o,{...t.options})}catch(h){y(h)||u.getLogger(this).error("#getContentType()",h)}switch(c??="UNKNOWN FORMAT",i){case"default":this._imageViewer.imageSource={datasetFormat:c.toUpperCase(),url:o.split("?")[0]},this._imageViewer.customParameters=Object.fromEntries(l),this._imageViewer.imageRotation=a??0,await this._imageViewer.loadImage(r);break;case"panoramic":if(pt.has(c.toUpperCase())){const{selectedPoint:e}=this,{pitch:i,yaw:a,cameraLocation:s,viewAngle:n}=t;this._panoramicViewer.imageSource=o;let l=a??0;"number"==typeof n?l=n-l:s&&e&&(l=await X(s,e)-l),this._panoramicViewer.pitch=i??0,this._panoramicViewer.yaw=l,await this._panoramicViewer.loadImage(r)}else this.setMessage("unsupportedPanoramicImageryError","error",void 0,{datasetFormat:c});break}},this._loadViewAdapter=async e=>{const{view:t}=this;if(t)switch(t.type){case"2d":{const{default:t}=await import("./adapters/view/MapViewAdapter.js");f(e),this._adapter=new t(this);break}case"3d":{const{default:t}=await import("./adapters/view/SceneViewAdapter.js");f(e),this._adapter=new t(this);break}}else this._adapter=null},this._mapImageConversionToolViewClickHandler=e=>{e.stopPropagation(),e.preventDefault(),e.mapPoint&&this.plotMapPoint(e.mapPoint)},this._viewClickHandler=e=>{this._clickTask?.abort(),this._clickTask=r((async t=>{const{pointerType:i,button:a,mapPoint:r}=e;if(("mouse"!==i||0===a)&&r)return e.stopPropagation(),e.preventDefault(),this._updatingHandles.addPromise(this.loadBestImage(r,{signal:t}))}))},this.plotSelectedPointOnImage=async(e,i)=>{if(await v(i),!e)return;const a=new R({...c.isSerializable(e)?e.toJSON():e});if("default"===this.mode)a.x-=.5,a.y=.5-a.y,a.spatialReference=this._imageViewer.imageRenderer.spatialReference.clone(),this._crossSymbol=new t({geometry:a,symbol:We}),this._imageViewer.addGraphic(this._crossSymbol,0);else if("panoramic"===this.mode){const{imageSize:i}=this._panoramicViewer;if(!i)return;const[a,r]=i,{heading:s,pitch:o}=Y(e,a,r),n=ne(s,o);this._crossSymbol=new t({geometry:new R(n,j.WebMercator),symbol:qe}),this._panoramicViewer.addGraphic(this._crossSymbol,0)}},this.handleSectorClick=this.handleSectorClick.bind(this),this.searchBestImage=this.searchBestImage.bind(this),this.transformAndPlotReferencePointOnImage=this.transformAndPlotReferencePointOnImage.bind(this),this.updateSuitabilities=this.updateSuitabilities.bind(this),this.selectBestFeature=this.selectBestFeature.bind(this)}initialize(){this.addHandles([F((()=>this.view),(()=>{this.load()}),_),F((()=>this.view?.map),((e,t)=>{t?.layers.remove(this._overlays),e?.layers.add(this._overlays)}),P),F((()=>this.view?.map?.allLayers?.length),(e=>{e&&this.view?.map?.layers.reorder(this._overlays,e-1)}),P),F((()=>[this.state,this.mapImageConversionToolState,this.view]),(()=>{this._createViewClickHandle(),this._createImageClickHandle()}),_),F((()=>[this.state,this.imageLocationToolState,this.view]),(()=>{if(this._createImageLocationHandle(),!this.imageLocationToolState)return this.clearPreviousGroundLocation(),void this._resetCursor();this._setMeasurementCursor()}),_),F((()=>this.measureType),(()=>{this.clearPreviousMeasurements()}),_),F((()=>this.bestFeatureAngle),((e,t)=>{this.previousFeatureAngle=t??0}),_),F((()=>this.currentBestFeature),(async(e,t)=>{m(this._featureChangedTask),this._featureChangedTask=r((async i=>this.determineWorkflowForFeature.apply(this,[e,t,{signal:i}]))),await this._featureChangedTask.promise}),{sync:!0}),F((()=>this.mode),(e=>{switch(this.removeHandles(ut.interactionHandles),e){case"default":this.addHandles(F((()=>{const{state:e}=this;return"image-loaded"===e?this._imageViewer.imagePointsInView:null}),(e=>{e&&(m(this._updateFootprintTask),this._updateFootprintTask=r((async t=>{await this.updateFootprint(e,{signal:t})})))}),{..._,equals:(e,t)=>a(e,t,h)}),ut.interactionHandles);break;case"panoramic":this.addHandles(F((()=>{const{currentBestFeature:e,state:t}=this,{imageSize:i,vfov:a,hfov:r,pitch:s,yaw:o}=this._panoramicViewer;return e&&i&&!t.includes("loading")?[a,r,o,s]:null}),(e=>{if(!e||this.state.includes("loading"))return;const[t,i,a,s]=e;m(this._updateFootprintTask),this._updateFootprintTask=r((async e=>{await this.updateFootprintPanorama({verticalFieldOfView:t,horizontalFieldOfView:i,yaw:a,pitch:s},{signal:e})}))}),{..._,equals:(e,t)=>a(e,t,h)}),ut.interactionHandles)}}),_),F((()=>[this.brightness,this.contrast,this.sharpness]),(()=>{const{_imageViewer:e,brightness:t,contrast:i,mode:a,sharpness:r}=this;"default"===a&&(e.brightness=t,e.contrast=i,e.sharpness=r)}),_),F((()=>this.activeViewer?.imageRenderer),(()=>{this.sketch&&(this.sketch.view=this.activeViewer?.imageRenderer)}))]),this.when().finally((()=>{this.notifyChange("state")}))}destroy(){this._updateFootprintTask=m(this._updateFootprintTask),this._clickTask=m(this._clickTask),this.coverageFrustums.destroy(),this.coveragePolygons.destroy(),this.pointSources.destroy(),this.additionalFootprints.destroy(),this.additionalCameraLocations.destroy(),this.bestFeatureFootprint=d(this.bestFeatureFootprint),this.bestFeatureCurrentFootprint=d(this.bestFeatureCurrentFootprint),this._crossSymbol=d(this._crossSymbol),this._referencePointOnGround=d(this._referencePointOnGround),this._referencePointOnImage=d(this._referencePointOnImage),this._locationPointOnImage=d(this._locationPointOnImage),this._overlays&&this.view?.map?.remove(this._overlays),this._overlays.destroy(),this._imageViewer.destroy(),this._panoramicViewer.destroy()}get activeLayer(){return o(u.getLogger(this),"activeLayer",{replacement:"layer"}),this.layer}set activeLayer(e){o(u.getLogger(this),"activeLayer",{replacement:"layer"}),this.layer=e}get activeViewer(){const{_imageViewer:e,_panoramicViewer:t,mode:i}=this;switch(i){case"default":return e;case"panoramic":return t;default:return null}}get accuracyParametersMissing(){return this.layer?.orientationAccuracy?.every((e=>0===e))??!0}get brightness(){return this._get("brightness")??0}set brightness(e){this._set("brightness",p(e,-10,10))}get contrast(){return this._get("contrast")??0}set contrast(e){this._set("contrast",p(e,-10,10))}get featureCount(){return this.features?.length??0}get imageGalleryEnabled(){const{currentBestFeature:e}=this;if(!e)return!1;const t=e.attributes.imagePath?.trim();return rt(t)||Ie(t)}get imageLoaded(){return o(u.getLogger(this),"imageLoaded",{replacement:'Use OrientedImageryViewer.state === "image-loaded"',version:"4.29",warnOnce:!0}),"image-loaded"===this.state}get invalidCameraHeading(){return this.currentBestFeature?.attributes?.cameraHeading===fe}get imagePointsInView(){const{mode:e,_imageViewer:t}=this;return"default"===e?t.imagePointsInView:null}get layerView(){const{layer:e,view:t}=this;if(e&&t)return t.allLayerViews.find(st(e))}get layerFloorFilterClause(){const{layerView:e}=this;return e?ue(e):null}get mode(){const e=this.currentBestFeature?.attributes;if(!e)return"none";const{horizontalFieldOfView:t,isSpherical:i}=e;return 360===t||i?"panoramic":"default"}get popupEnabled(){return!0===this.layer?.popupEnabled}get referencePoint(){return this._referencePointOnGround?.geometry}get sectorData(){const{_sectorData:e}=this;return e?ve.map((t=>e[t])):null}get sharpness(){return this._get("sharpness")??0}set sharpness(e){this._set("sharpness",p(e,0,1))}get sketchGraphicsLayer(){return this.sketch?.layer}get state(){const{mode:e,disabled:t,_updatingHandles:{updating:i},_featureChangedTask:a}=this;if(t)return"disabled";if(!this.isFulfilled()||i||!1===a?.finished)return"loading";if(this.isRejected())return"error";if("error"===this.displayMessage?.type)return"image-load-error";switch(e){case"default":return this._imageViewer.state;case"panoramic":return this._panoramicViewer.state}return"ready"}get thumbnails(){const{features:e}=this;return e?new s(e.map((({attributes:{imagePath:e,objectId:t,cameraRoll:i,imageRotation:a}})=>{const r=e?.trim();return rt(r)||Ie(r)?{url:r,objectId:t,rotation:(i??0)+(a??0)}:null})).filter(i)):null}set view(e){this._set("view",e)}get _sketchGraphicsLayer(){const{mode:e}=this;switch(e){case"panoramic":return new z({elevationInfo:{mode:"absolute-height"}});case"default":return new z;case"none":return}}get _overlaysView(){return this.view?.layerViews.find((({layer:e})=>e===this._overlays))}async computeHeight(e,t,i=!0){const{currentBestFeature:a,activeViewer:r,layer:s,footprintExtent:o}=this,n=r?.imageSize,l=a?.attributes,c=s?.orientationAccuracy;if(!l||!n||!e||e.length<2||!c)return;const h="panoramic"===t?await this.getMeasurementPropertiesPanoramic():ee(l,n[0],n[1]),u=e.at(0),p=e.at(-1);if(!(h&&u&&p&&c&&o))return;const m=[p,u],d=Me(m,!1),g="panoramic"===t?await Ce(m,h,c,a,!0,!1):await ke(m,h,c,!0,i);if(!g)return;const y="panoramic"===t?await Ve(c,d,h,g,a,!0):await Ae(c,d,h,g,!0);return y?{value:g,accuracy:y}:{value:g}}async calculateAreaMeasurement(e,t,i){if(e.length<3||!this.currentBestFeature||!this.activeViewer?.imageSize||"none"===t)return null;const a="default"===t?await this.getMeasurementProperties():await this.getMeasurementPropertiesPanoramic();return f(i),a?"default"===t?await Ge(e,a,!0):await Re(e,a,!0,i):null}async calculateDistanceMeasurement(e,t,i){const{currentBestFeature:a,activeViewer:r}=this;if(e.length<2||!a||!r?.imageSize||"none"===t)return null;const s="default"===t?await this.getMeasurementProperties():await this.getMeasurementPropertiesPanoramic();return f(i),s?"default"===t?await Oe([e.at(0),e.at(-1)],s,!0):await Le([e.at(0),e.at(-1)],s,!0):null}async calculateAccuracy(e,t,i){const{layer:a,currentBestFeature:r,activeViewer:s}=this,o=a?.orientationAccuracy,n=o?.every((e=>0===e))||!o?.length;if("area"===t&&e.length<3||"distance"===t&&e.length<2||!r||!s?.imageSize||n)return null;const l=await this.getMeasurementProperties();if(f(i),!l)return null;const c="area"===t?await Ge(e,l,!0):await Oe([e.at(0),e.at(-1)],l,!0);f(i);const{updateElevationProps:h,...u}=l,p=xe(u,o);if(!p?.length)return null;const m=p.map((e=>({...e,updateElevationProps:h}))).map((async a=>{const r="area"===t?await Ge(e,a,!0):await Oe([e.at(0),e.at(-1)],a,!0);if(f(i),r&&c){if("area"===t){const e="number"!=typeof r?r.area:null;return e?Math.abs(e-c.area):null}return Math.abs(r-c)}return null})),d=await Promise.all(m);f(i);const g=d.filter((e=>null!==e));return 0===g.length?null:je(g)}async calculateAccuracyPanoramic(e,t,i){const{layer:a,currentBestFeature:r,activeViewer:s,mode:o}=this,n=a?.orientationAccuracy,l=n?.every((e=>0===e))||!n?.length;if("area"===t&&e.length<3||"distance"===t&&e.length<2||!r||!s?.imageSize||l||"panoramic"!==o)return null;const c=await this.getMeasurementPropertiesPanoramic();if(f(i),!c)return null;const h="area"===t?await Re(e,c,!0):await Le([e.at(0),e.at(-1)],c,!0);f(i);const{updateElevationProps:u,...p}=c,m=Ee(p,n);if(!m?.length)return null;const d=m.map((e=>({...e,updateElevationProps:u}))).map((async a=>{const r="area"===t?await Re(e,a,!0):await Le([e.at(0),e.at(-1)],a,!0);if(f(i),r&&h){if("area"===t){const e="number"!=typeof r?r.area:null;return e?Math.abs(e-h.area):null}return Math.abs(r-h)}return null})),g=await Promise.all(d);f(i);const y=g.filter((e=>null!==e));return 0===y.length?null:je(y)}async calculateHeightMeasurementInfo(e,t,i){const{currentBestFeature:a,activeViewer:r}=this,s=r?.imageSize;if(!a||!r||!s?.length||"none"===t)return;const{attributes:o}=a,[n]=Me([e],"panoramic"!==t),l="panoramic"===t?await this.getMeasurementPropertiesPanoramic():ee(o,s[0],s[1]);if("panoramic"===t){if(!l)return;const e=await Be(n,l,a,i);if(!e)return;e?.heading>180&&(e.heading-=360);const t=ze(n,e),r=k([n.x,n.y],[e.x,e.y]);if(!t||!r)return;return{measurementAngle:t,tempDistance:r}}const c=await He(n,l,i);if(!c)return;const h=De(n,c),u=k([n.x,n.y],[c.x,c.y]);return h&&u?{measurementAngle:h,tempDistance:u}:void 0}clearPreviousMeasurements(){this.clearMeasurementGraphics(),this.resetMeasurementData(),this.stopMeasurement()}clearPreviousGroundLocation(){this.groundCoordinates=null,this.pixelCoordinates=null,this.clearLocationPointOnImage()}clearMeasurementGraphics(){this.measurementGraphic&&(this.activeViewer?.removeGraphic(this.measurementGraphic),this.measurementGraphic=null),this.heightGraphic&&(this.activeViewer?.removeGraphic(this.heightGraphic),this.heightGraphic=null)}digitizeCancel(){return this.sketch?.cancel()}digitizeCanRedo(){return this.sketch?.canRedo()??!1}digitizeCanUndo(){return this.sketch?.canUndo()??!1}digitizeComplete(){return this.sketch?.complete()}async digitizeCreate(e,t){const{sketch:i,dataCaptureLayer:a}=this;if(!i)throw dt();be(a,e,i),await i.create(e,{...t,defaultZ:0})}async digitizeDelete(){if(!this.sketch)throw dt();return this.sketch.delete()}digitizeDuplicate(){if(!this.sketch)throw dt();return this.sketch.duplicate()}digitizePlace(e,t){if(!this.sketch)throw dt();return this.sketch.place(e,t)}digitizeRedo(){if(!this.sketch)throw dt();return this.sketch.redo()}digitizeUndo(){if(!this.sketch)throw dt();return this.sketch.undo()}digitizeUpdate(e,t){if(!this.sketch)throw dt();return this.sketch.update(e,t)}async displayHeightResults(){const{currentBestFeature:e,activeViewer:t,heightMeasurementPixels:i,mode:a}=this,r=t?.imageSize,s=e?.attributes;if(!s||!r)return;const o=await this.computeHeight(i,a);o?.value&&o?.accuracy&&(this.heightMeasurementResult=o.value,this.heightMeasurementAccuracy=o.accuracy)}filterByFootprints(e,t){const i=[],a=[],r=[];return e.forEach((e=>{const{layer:{coveragePercent:s},attributes:o}=e;let n;const l=S(e.geometry.spatialReference);o.cameraHeight/=l,o.farDistance/=l,o.nearDistance/=l,q(o.elevationSource)&&(o.elevationSource.constantElevation/=l);const{polygon:c,frustum:h}=T(o);if(n=c.clone(),o.isInspection&&(n=U(o)),s&&(n=N(n,s)),W(n,t)){r.push(e);const{geometry:t,objectId:s,cameraHeight:n,cameraHeading:l}=o,u=t.clone();u.z=n,u.imageID=s,this.pointSources.push(u),l!==fe&&(i.push(c),h&&a.push(h))}})),{features:r,polygons:i,frustums:a}}getMeasurementProperties(){const{currentBestFeature:e,activeViewer:t}=this;if(!e||!t?.imageSize)return;const{elevationSample:i,attributes:a}=e,{elevationSource:r,cameraHeight:s}=a,o=ee(a,t.imageSize[0],t.imageSize[1]);let n=o.cameraLocation;return(n.spatialReference.isGeographic?x(n,j.WebMercator):Promise.resolve(n)).then((e=>(n=e,te((n.z??0)-s,{elevationSample:i,elevationSource:r,extent:this.footprintExtent})))).then((t=>("elevationSample"in t&&ie(t.elevationSample)&&(e.elevationSample=t.elevationSample),{...o,cameraLocation:n,updateElevationProps:t})))}getMeasurementPropertiesPanoramic(){const{currentBestFeature:e,activeViewer:t}=this;if(!e||!t?.imageSize)return;const{elevationSample:i,attributes:a}=e,{elevationSource:r,cameraHeight:s}=a,o=ae(a,t.imageSize[0],t.imageSize[1]);let n=o.cameraLocation;return(n.spatialReference.isGeographic?x(n,j.WebMercator):Promise.resolve(n)).then((e=>(n=e,te((n.z??0)-s,{elevationSample:i,elevationSource:r,extent:this.footprintExtent})))).then((t=>("elevationSample"in t&&ie(t.elevationSample)&&(e.elevationSample=t.elevationSample),{...o,cameraLocation:n,updateElevationProps:t})))}async deleteDataCaptureFeatures(e){const{dataCaptureLayer:t}=this;if(!t)throw new n("Data capture layer is not available");return t.queryFeatures({objectIds:e}).then((({features:e})=>t.applyEdits({deleteFeatures:e})))}handleSectorClick(e){if(isNaN(e))return;const t=this._sectorData?.[ve[e]];t?.length&&this._updateCurrentBestFeature(t.at(0))}handleFeatureClick(e){const{sector:t,featureIndexInSector:i}=e;if(isNaN(i))return;const a=this._sectorData?.[t];a?.length&&this._updateCurrentBestFeature(a.at(i))}handleDrawCursorUpdateEvents(e){const{measurementAngle:t,tempDistance:i,heightMeasurementPixels:a,mode:r,activeViewer:s}=this,o=s?.imageSize;if(!e.vertices||!o)return;const n=Te(e.vertices.at(-1),r,o);if(a.length<1||!n||!i||!t||"none"===r)return;const l=Ue(a[0],n,t);if(!l?.length)return;this.heightMeasurementPixels.push(l),"panoramic"===r?this.createPolylineGraphicPano():this.createPolylineGraphic();const c=Ne(this.heightMeasurementPixels,i);c&&(this.heightMeasurementResult=c)}async handleDrawVertexAddEvents(e,t){const{currentBestFeature:i,activeViewer:a,heightMeasurementPixels:r,mode:s}=this;if(!i||!a||!e.vertices?.length||"none"===s)return;const o=a?.imageSize;if(!r.length&&o){const i=Te(e.vertices.at(-1),s,o);this.heightMeasurementPixels.push(i);const a=await this.calculateHeightMeasurementInfo(i,s,t);if(!a?.measurementAngle||!a?.tempDistance)return;this.measurementAngle=a.measurementAngle,this.tempDistance=a.tempDistance}}async load(e){return this.addResolvingPromise(this._loadViewAdapter(e).catch((e=>{if(!y(e))throw e}))),this}async loadBestImage(e,t){return this.view?.closePopup(),this.displayMessage=null,this.clearPreviousGroundLocation(),this.imageLocationToolState=!1,this.selectedPoint=e.spatialReference.isGeographic?B(e):e.clone(),this.features.removeAll(),this.currentBestFeature=null,this.additionalFeatures.removeAll(),this.additionalFootprints.removeAll(),this.additionalCameraLocations.removeAll(),this.bestFeatureCurrentFootprint=d(this.bestFeatureCurrentFootprint),this._overlays?.removeAll(),this._fetchFeaturesWithController(e,t)}loadImageError(e){u.getLogger(this).error("oriented-imagery-viewer:load-image",e),this.setMessage("imageLoadError","error",e.message)}async loadSketch(e){if(!this.sketch){const t=import("../Sketch/SketchViewModel.js"),{default:i}=await t;f(e),this.sketch=new i({layer:this._sketchGraphicsLayer,view:this.activeViewer?.imageRenderer,updateOnGraphicClick:!1,defaultUpdateOptions:{reshapeOptions:{edgeOperation:"none",shapeOperation:"none",vertexOperation:void 0},enableMoveAllGraphics:!1,enableRotation:!1,enableScaling:!1,multipleSelectionEnabled:!1,toggleToolOnClick:!1,tool:"transform"}})}return this.sketch}async loadMeasurementAdapter(e){if(!this.sketchAdapter){const t=import("./adapters/sketch/MeasurementAdapter.js"),{default:i}=await t;if(f(e),this.sketchAdapter=new i({viewModel:this}),!this.sketchAdapter.viewModel.isResolved())return}return this.sketchAdapter}async startMeasurement(e,t){await this.loadSketch(t),await this.loadMeasurementAdapter(t);const{sketch:i,sketchAdapter:a,activeViewer:r,mode:s}=this;if(!i||!a||!r||"none"===s)return;if(this.displayNewMeasurementButton=!1,"panoramic"===s&&(i.defaultCreateOptions.defaultZ=0),await i.create(e),"panoramic"===s){const{drawOperation:e}=i.view.activeTool;e.constraintsEnabled=!1,e._set("elevationDrawSurface",null)}const o=this.activeViewer?.imageRenderer.effectiveTheme.accentColor;o&&this.sketch&&(this.sketch.polygonSymbol=$e(o),this.sketch.polylineSymbol="panoramic"===s?Je:Ze(o))}startHeightMeasurement(){this.heightMeasurementPixels=[],this.displayNewMeasurementButton=!1,this.draw??=new me({view:this.activeViewer?.imageRenderer});this.draw.create("polyline").on(["cursor-update","vertex-add","draw-complete"],(e=>this.handleDrawEvents(e)))}createPolylineGraphic(){const e=[this.heightMeasurementPixels[0],this.heightMeasurementPixels.at(-1)],i=this.activeViewer?.imageRenderer.spatialReference;if(this.heightGraphic)this.heightGraphic.geometry=new L({paths:[e],spatialReference:i});else{const a=new L({paths:[e],spatialReference:i}),r=this.activeViewer?.imageRenderer.effectiveTheme.accentColor;this.heightGraphic=new t({geometry:a,symbol:Ze(r,2.5)}),this.activeViewer?.addGraphic(this.heightGraphic)}}createPolylineGraphicPano(){const e=this.activeViewer?.imageRenderer.spatialReference,i=this.activeViewer?.imageSize;if(!i)return;const a={x:this.heightMeasurementPixels[0][0],y:this.heightMeasurementPixels[0][1]},r={x:this.heightMeasurementPixels.at(-1)[0],y:this.heightMeasurementPixels.at(-1)[1]},{heading:s,pitch:o}=Y(a,i[0],i[1]),{heading:n,pitch:l}=Y(r,i[0],i[1]),c=[[...ne(s,o)],[...ne(n,l)]];if(this.heightGraphic)this.heightGraphic.geometry=new L({paths:[c],spatialReference:e});else{const i=new L({paths:[c],spatialReference:e});this.heightGraphic=new t({geometry:i,symbol:Je}),this._panoramicViewer.addGraphic(this.heightGraphic,0)}}async handleDrawEvents(e,t){if(this.draw)switch(e.type){case"cursor-update":this.handleDrawCursorUpdateEvents(e);break;case"vertex-add":this.handleDrawVertexAddEvents(e,t);break;case"draw-complete":await this.displayHeightResults()}}initializeMeasurement(e){switch(this.clearMeasurementGraphics(),this.resetMeasurementData(),e){case"distance":this.startMeasurement("polyline");break;case"area":this.startMeasurement("polygon");break;case"height":this.startHeightMeasurement()}}async overlayCameraLocations(e){const{activeViewer:i,currentBestFeature:a,overlayedCameraLocations:r,layer:s,mode:o,state:n}=this,l=i?.imageSize;if(!l||!a||!s||"none"===o||n.includes("loading"))return;const{polygon:c}=T(a.attributes);if(i.removeManyGraphics(r.toArray()),r.removeAll(),e){const{features:e}=await s.queryFeatures({where:`${s.objectIdField} <> ${a.attributes.objectId}`,geometry:c,returnGeometry:!0,outFields:[s.objectIdField]}),n=await Promise.all(e.map((async e=>{const{attributes:i,geometry:r}=e,s=await this.getPixels(r,{feature:a,imageSize:l,mode:o}),n=Ke.clone();return n.outline=new pe({color:[0,0,0],width:1}),new t({attributes:i,symbol:n,geometry:s})})));r.addMany(n),i.addManyGraphics(r.toArray())}}overlayGraphicsOnImage(e,t){this.removeOverlayedGraphicsOnImage(e),this.overlayedMapFeatures.set(e,t),this.activeViewer?.addManyGraphics(t.toArray())}async overlayMapFeatures(e,a=!1){const{activeViewer:r,currentBestFeature:o,mode:n,state:l,layer:c}=this,h=r?.imageSize;if(!h||!o||"none"===n||l.includes("loading")||!c)return;const{polygon:p}=T(o.attributes);try{const{imageGeometryField:t,oiObjectIdField:i}=Fe(e,c.imageGeometryField,c.imageReferenceField);this.imageGeometryField=t.name,this.oiObjectIdField=i.name}catch(g){u.getLogger(this).warn("oriented-imagery-viewer:overlay-map-features",g)}const{features:m}=await e.queryFeatures({geometry:p,returnGeometry:!0,outFields:["*"]}),d=new s((await Promise.all(m.map((async i=>{const r=i.symbol?.clone()??e.renderer?.getSymbol(i)?.clone(),{attributes:s,geometry:l}=i,c=l,{imageGeometryField:p,oiObjectIdField:m}=this;if(p&&m&&_e(e,p,m)&&`${s[m]}`==`${o.attributes.objectId}`)try{return Pe(s,p,e,a,h,n,r)}catch(g){u.getLogger(this).warn("oriented-imagery-viewer:overlay-map-features","couldn't create graphic from attributes, geometry will be used",{error:g,feature:i,layer:e,imageGeometryField:this.imageGeometryField,imageReferenceField:this.oiObjectIdField})}switch(c?.type){case"point":{const i=await this.getPixels(c,{feature:o,imageSize:h,mode:n});return new t({attributes:s,layer:e,symbol:r,geometry:i,visible:e.visible&&a})}case"polygon":{const{rings:i,spatialReference:l}=c,u=i.map((e=>e.map((([e,t,i])=>new R({x:e,y:t,z:i,spatialReference:l}))))),p=await Promise.all(u.map((async e=>this.getPixels(e,{feature:o,imageSize:h,mode:n}).then((e=>e.map(re))))));return new t({attributes:s,layer:e,symbol:r,geometry:new O({rings:p,spatialReference:j.WebMercator}),visible:e.visible&&a})}case"polyline":{const{paths:i,spatialReference:l}=c,u=i.map((e=>e.map((([e,t,i])=>new R({x:e,y:t,z:i,spatialReference:l}))))),p=await Promise.all(u.map((async e=>this.getPixels(e,{feature:o,imageSize:h,mode:n}).then((e=>e.map(re))))));return new t({attributes:s,layer:e,symbol:r,geometry:new L({paths:p,spatialReference:j.WebMercator}),visible:e.visible&&a})}case"multipoint":{const{points:i,spatialReference:l}=c,u=i.map((([e,t,i])=>new R({x:e,y:t,z:i,spatialReference:l}))),p=await this.getPixels(u,{feature:o,imageSize:h,mode:n}).then((e=>e.map(re)));return new t({attributes:s,layer:e,symbol:r,geometry:new G({points:p,spatialReference:j.WebMercator}),visible:e.visible&&a})}}return null})))).filter(i));this.overlayGraphicsOnImage(`${e.id}`,d)}async getPixels(e,t){const{imageSize:i,mode:a}=t,r=(await this.worldToImage(Array.isArray(e)?e:[e])).map((e=>{if("default"===a)return new R({x:e.x-.5,y:.5-e.y,spatialReference:j.WebMercator});const[t,r]=i,{heading:s,pitch:o}=Y(e,t,r),n=ne(s,o);return new R(n,j.WebMercator)}));return Array.isArray(e)?r:r[0]}async getMapPoint(e,t){const{feature:i,mode:a,imageSize:r}=t,{elevationSample:s,attributes:o}=i,{elevationSource:n,location:l,elevation:c,cameraHeight:h}=o;let u=l.clone();u.spatialReference.isGeographic&&(u=await x(u,j.WebMercator));const p=await te(c??(l.z??0)-h,{elevationSample:s,elevationSource:n,extent:this.footprintExtent});let m;if("elevationSample"in p&&ie(p.elevationSample)&&(i.elevationSample=p.elevationSample),"default"===a){const t=ee(o,r[0],r[1]);m=await J(Array.isArray(e)?e:[e],{...t,cameraLocation:u},p)}else{const t=ae(o,r[0],r[1]);m=await Z(Array.isArray(e)?e:[e],{...t,cameraLocation:u},p)}return Array.isArray(e)?m:m[0]}async plotMapPoint(e){return this.plotReferencePoint(e),this.transformAndPlotReferencePointOnImage({feature:this.currentBestFeature,selectedLocation:e,options:{signal:this._transformController?.signal}})}plotReferencePointOnGround(e){this._referencePointOnGround&&(this._overlays?.remove(this._referencePointOnGround),this._referencePointOnGround.destroy()),null!=e&&(this._referencePointOnGround=new t({geometry:new R({...e.toJSON()}),symbol:Qe}),this.view?this._overlays?.add(this._referencePointOnGround):this.emit("plot-ground-point",{data:{point:this._referencePointOnGround?.geometry}}))}plotReferencePointOnImage(e){if("image-loaded"===this.state)switch(this.clearReferencePointOnImage(),this.mode){case"default":{const i=c.isSerializable(e)?e.toJSON():e;i.x-=.5,i.y=.5-i.y,this._referencePointOnImage=new t({geometry:new R({spatialReference:this._imageViewer.imageRenderer.spatialReference,...i}),symbol:Qe}),this._imageViewer.addGraphic(this._referencePointOnImage,0);break}case"panoramic":{const{imageSize:i}=this._panoramicViewer;if(!i)return;const[a,r]=i,{heading:s,pitch:o}=Y(e,a,r),n=ne(s,o);this._referencePointOnImage=new t({geometry:new R(n,j.WebMercator),symbol:Xe}),this._panoramicViewer.addGraphic(this._referencePointOnImage,0);break}}}plotLocationPointOnImage(e){if("image-loaded"===this.state)switch(this.clearLocationPointOnImage(),this.mode){case"default":this._plotLocationPointOnDefaultImage(e);break;case"panoramic":this._plotLocationPointOnPanoramicImage(e)}}removeAllOverlayMapFeatures(){this.overlayedMapFeatures.forEach((e=>{this._imageViewer.removeManyGraphics(e.toArray())})),this.overlayedMapFeatures.clear()}removeOverlayedGraphicsOnImage(e){const t=this.overlayedMapFeatures.get(e);t?.length&&(this.activeViewer?.removeManyGraphics(t.toArray()),this.overlayedMapFeatures.delete(e))}resetImage(){switch(this.setMessage("onLoadMessage","info"),this.mode){case"default":this._imageViewer.clearImage(),this._imageViewer.clearGraphics();break;case"panoramic":this._panoramicViewer.clearGraphics()}this._clickTask=m(this._clickTask)}resetMeasurementData(){this.areaMeasurementResult=0,this.areaMeasurementAccuracy=0,this.distanceMeasurementResult=0,this.distanceAccuracyArray=[],this.heightMeasurementPixels=[],this.heightMeasurementResult=0,this.tempDistance=null,this.measurementAngle=null,this.heightMeasurementAccuracy=0,this.heightGraphic=null}async saveDrawing(){const{dataCaptureLayer:e,sketchAdapter:t}=this;if(!e||"data-capture"!==t?.type)return;const{pendingGraphics:i,savedGraphics:a}=t,r=i.get(e.id),s=r?.toArray();if(!r||!s?.length)return;const{addFeatureResults:o}=await this.saveDataCaptureFeatures(s),n=o.reduce(((t,{objectId:i,globalId:a,error:r},o)=>{const n=s[o],{attributes:l}=n;return r?t.error.push(n):(i&&(l[e.objectIdField]=i),a&&e.globalIdField&&(l[e.globalIdField]=a),t.success.push(n)),t}),{success:[],error:[]});a.addMany(n.success),r.removeAll(),r.addMany(n.error)}async saveDataCaptureFeatures(e){const{activeViewer:t,currentBestFeature:a,dataCaptureLayer:r,mode:s}=this,o=t?.imageSize;if(!o||!a||"none"===s)throw new n("Image size, current best feature and mode are required to save data capture features");if(!r)throw new n("Data capture layer is not available");const l=await Promise.all(e.map((async e=>{const t=e.clone(),{geometry:i}=t;if(!i)return;const n=i.type,l=r.hasZ,c=r.geometryType,h=n!==c,u=h?await import("./transformers.js"):null,p=u?.default[c],m=h?p?.(i):i;if(m)switch(m.type){case"point":return t.geometry=await this.getMapPoint(se(s,m,o),{feature:a,imageSize:o,mode:s}),l||(delete t.geometry.z,t.geometry.hasZ=!1),t.geometry.hasM=!1,t;case"polygon":{const e=await Promise.all(m.rings.map((async e=>this.getMapPoint(e.map((([e,t,i])=>se(s,{x:e,y:t,z:i},o))),{feature:a,imageSize:o,mode:s}))));return t.geometry=new O({spatialReference:e[0][0].spatialReference,hasZ:l,hasM:!1,rings:e.map((e=>e.map(re)))}),t}case"polyline":{const e=await Promise.all(m.paths.map((async e=>this.getMapPoint(e.map((([e,t,i])=>se(s,{x:e,y:t,z:i},o))),{feature:a,imageSize:o,mode:s}))));return t.geometry=new L({spatialReference:e[0][0].spatialReference,hasZ:l,hasM:!1,paths:e.map((e=>e.map(re)))}),t}}}))),c=l.filter(i);return r.applyEdits({addFeatures:c}).then((e=>{const{addFeatureResults:t}=e;let i=0;const a=l.map((e=>{const a=t[i++];return e?a:{error:new n("Error in saving data capture features"),objectId:null,globalId:null}}));return{...e,addFeatureResults:a}}))}async searchBestImage(e,t){try{const i=await H(e,t);i&&await this._processFeatureResponse(i,e.point,{signal:t?.signal})}catch(i){y(i)||(this.setMessage("imageLoadError","error",i.message),u.getLogger(this).error("error occurred while finding best image",i))}}selectBestFeature(e){this.currentBestFeature=this.features?.find((({attributes:t})=>t.objectId===Number(e)))}setAdditionalCameraLocationsVisibility(e){this.additionalCameraLocations.forEach((t=>{t.visible=e}))}setAdditionalCoverageVisibility(e){this.additionalFootprints.forEach((t=>{t.visible=e}))}setCurrentCoverageVisibility(e){this.bestFeatureCurrentFootprint&&(this.bestFeatureCurrentFootprint.visible=e),this.currentBestFeatureLocation&&(this.currentBestFeatureLocation.visible=e)}setMapImageConversionToolState(e){this.mapImageConversionToolState=e}async startDataCapture(e,t){const i=this.activeViewer?.imageRenderer,{oiObjectIdField:a,currentBestFeature:r}=this;if(!i||!r||!a)return;const{attributes:{objectId:o}}=r,n=this.overlayedMapFeatures.get(e.id)?.toArray()??[],l=[],c=[];for(const s of n)`${s.getAttribute(a)}`==`${o}`?l.push(s):c.push(s);this.overlayGraphicsOnImage(e.id,new s(c)),this.collectionId=e.id;const h=await this.loadSketch(t),u=await this.loadDataCaptureAdapter(t);f(t),h.layer.addMany(l),h.layer.blendMode="source-atop",u.savedGraphics.addMany(l);i.ui.find("zoom").visible=!1,i.map.layers.add(this.sketchGraphicsLayer)}async stopDataCapture(e=!1){this.sketch?.cancel(),this.sketchGraphicsLayer?.removeAll(),this.sketchAdapter=d(this.sketchAdapter),this.sketch=d(this.sketch),this.collectionId=null;const{dataCaptureLayer:t}=this,i=this.activeViewer?.imageRenderer;if(!i||i.destroyed)return;i.map.layers.remove(this.sketchGraphicsLayer),e&&t&&await this.overlayMapFeatures(t,!0);const a=i.ui.find("zoom");a&&(a.visible=!0)}stopMeasurement(){this.heightMeasurementPixels=[],this.draw?.reset(),this.sketch?.cancel()}toggleAllOverlayMapFeatures(e){this.overlayedMapFeatures.forEach((t=>{this._toggleVisiblity(t,e)}))}toggleOverlayMapFeatures(e,t){const i=this.overlayedMapFeatures.get(e);i&&this._toggleVisiblity(i,t)}toggleSelection(e){const{sketch:t}=this;t&&(t.updateOnGraphicClick=e,t.cancel())}async transformAndPlotReferencePointOnImage(e){const{selectedLocation:t,options:i}=e;let a=!1,r=!1;const s=this.bestFeatureFootprint?.geometry;switch(s?.type){case"polygon":{const e=t.spatialReference.equals(s.spatialReference)?t:await x(t,s.spatialReference);a=s.contains(e);break}case"mesh":{const e=t.spatialReference.equals(s.spatialReference)?t:await x(t,s.spatialReference);r=s.extent.contains(e);break}}if(!a&&!r)return void this.clearReferencePointOnImage();const o=await this.worldToImage(t,i);if(o)return f(i),this.plotReferencePointOnImage(o),{x:o.x,y:o.y};this.clearReferencePointOnImage()}updateSuitabilities(e){e.sort(((e,t)=>e.suitability-t.suitability)),this._suitabilities=e;const t=this._suitabilities.map((({feature:e})=>e));this._initialCurrentCoverageUpdate=!0,this._updateFeatures(t),this._groupFeaturesBySectors()}async _fetchFeatures(e,t){if(!this.view)return;const i=this.layer;if(i){const a={include:i},r=this.view.toScreen(e);if(!r)return;const s=await this.view.hitTest(r,a);return this._processHitTestResults(i,s,t)}}async _fetchFeaturesWithController(e,t){try{await this._fetchFeatures(e,t)}catch(i){if(y(i))return;this.setMessage("imageLoadError","error"),u.getLogger(this).error("error occurred while fetching features",i)}}_groupFeaturesBySectors(){const{_suitabilities:e,additionalFeatures:t,currentBestFeature:i,features:a,invalidCameraHeading:r}=this;if(!e||!t||!i||!a||r)return void(this._sectorData=null);this._sectorData={};for(const c of ve)this._sectorData[c]=new s;const o=e.map(((e,t)=>({...e,featureIndex:t})));o.sort(((e,t)=>e.trueSuitability-t.trueSuitability));const n=o.map((({distance:e})=>e)),l=Math.max(...n);o.forEach((e=>{const{distance:t,angle:i,featureIndex:r}=e,s=t/l*we[2],o=lt(t,l),n=ct(i);if(!this._sectorData)return;const c=we[3]+s*Math.sin(i*Math.PI/180),h=we[3]+s*Math.cos(i*Math.PI/180);let u;const p=a.at(r),m=p===this.currentBestFeature,d=this.currentBestFeature?.attributes.cameraPitch&&this.currentBestFeature?.attributes.cameraPitch<5;if(m&&d)u=-90;else{const e=c-we[3],t=h-we[3],i=t/Math.sqrt(e**2+t**2);let a=180*Math.acos(i)/Math.PI;(e<0&&t<0||e<0&&t>0)&&(a*=-1),u=a}const g=""===o?n:`${o}_${n}`;m&&(u===this.bestFeatureAngle?this.previousFeatureAngle=u:this.bestFeatureAngle=u,this.navigatorCurrentBestFeature=d?null:{x:c,y:h,direction:n});const y=this._sectorData[g];y.add({angle:i,featureIndex:r,x:c,y:h,objectID:p.attributes.objectId,sector:g,featureIndexInSector:y.length})}))}_plotLocationPointOnDefaultImage(e){const i=c.isSerializable(e)?e.toJSON():e;i.x-=.5,i.y=.5-i.y,this._locationPointOnImage=new t({geometry:new R({spatialReference:this._imageViewer.imageRenderer.spatialReference,...i}),symbol:Ye}),this._imageViewer.addGraphic(this._locationPointOnImage,0)}_plotLocationPointOnPanoramicImage(e){const{imageSize:i}=this._panoramicViewer;if(!i)return;const[a,r]=i,{heading:s,pitch:o}=Y(e,a,r),n=ne(s,o);this._locationPointOnImage=new t({geometry:new R(n,j.WebMercator),symbol:et}),this._panoramicViewer.addGraphic(this._locationPointOnImage,0)}async _processFeatureResponse(e,t,i){const{features:a}=e;if(!a?.length)return this.setMessage("noImageError","error"),void(this.currentBestFeature=null);this.coveragePolygons.removeAll(),this.coverageFrustums.removeAll(),this.pointSources.removeAll();const{features:r,polygons:s,frustums:o}=this.filterByFootprints(a,t);if(!r.length)return this.setMessage("noImageError","error"),void(this.currentBestFeature=null);let n;if(this.coveragePolygons.addMany(s),this.coverageFrustums.addMany(o),s[0]){let e=new O({spatialReference:s[0].spatialReference});for(const i of s)e=await A(e,i);const t=[];for(const{geometry:i}of r)e.contains(i)||t.push([i.x,i.y]);if(t.sort(((e,t)=>+E([e,t]))),e.addRing(t),this.footprintExtent=de(e.extent,2,2),this.view?.supportsGround)try{n=await this.view.map.ground.createElevationSampler(this.footprintExtent,i)}catch(l){y(l)||u.getLogger(this).error(l)}}if((n||r[0].attributes.elevationSource)&&this.footprintExtent){const e=r[0].attributes.elevationSource;$(e)&&!n&&(n=await Q({extent:this.footprintExtent,lod:e.lod,url:e.url,rasterFunction:e.rasterFunction}));const i=await te((r[0].attributes.location.z??0)-r[0].attributes.cameraHeight,{elevationSample:n,elevationSource:e,extent:this.footprintExtent}),[a,...s]=await K([t,...r.map((e=>e.attributes.geometry.clone()))],i);r[0].elevationSample=n??i.elevationSample,t.elevation=a.z,r.forEach(((e,t)=>{e.attributes.elevation=s[t].z}))}r[0].elevationSample&&r.forEach((e=>{e.elevationSample=r[0].elevationSample})),this._suitabilities=D({features:r,selectedPoint:t,camera:ot(this.view)?this.view.camera:null,currentImage:this.currentBestFeature}),this.updateSuitabilities(this._suitabilities)}async _processHitTestResults(e,t,i){const{screenPoint:a,results:[r]}=t,s="graphic"===r?.type&&this.shouldShowSelectedImage,o=r?.mapPoint??this.view?.toMap(a);if(!o)return;const{layerFloorFilterClause:n}=this,l=e.spatialReference.equals(o.spatialReference)?o:await x(o,e.spatialReference),c=I("1=1",I(e.definitionExpression,n)),h=l.spatialReference.isGeographic?1:S(l.spatialReference),u={layerInstanceOrURL:e,point:l,queryParams:{where:c,maximumDistance:e.maximumDistance?e.maximumDistance/h:void 0,objectIds:s?[r.graphic.getAttribute(e.objectIdField)]:void 0}};await this.searchBestImage(u,i)}_resetCursor(){const{activeViewer:e}=this;e&&(e.imageRenderer.cursor=this._previousCursor)}_setMeasurementCursor(){const{activeViewer:e}=this;e&&(this._previousCursor=e.imageRenderer.cursor,e.imageRenderer.cursor="crosshair")}_toggleVisiblity(e,t){e.forEach((e=>{e.visible=t}))}_updateFeatures(e){if(!e.length)return this.currentBestFeature=null,void this.additionalFeatures.removeAll();this.features.removeAll(),this.features.addMany(e),e.length>1?this.additionalFeatures.addMany(e.slice(1)):this.additionalFeatures.removeAll(),this._updateGroundElevation=!0,this.currentBestFeature=e[0]}async _updatePointsAndPolygons(e){const{pointSources:i,currentBestFeature:a,currentCoverageVisible:r,isAdditionalPointSourcesVisible:s}=this;if(a&&(this.additionalFootprints.removeAll(),this.additionalCameraLocations.removeAll(),this.bestFeatureCurrentFootprint&&(this.bestFeatureCurrentFootprint.destroy(),this.bestFeatureCurrentFootprint=null,this.bestFeatureFootprint=null),!this.invalidCameraHeading)){await(this._adapter?.createFootprints(e)),f(e);for(const e of i)e.imageID===a.attributes.objectId?this.currentBestFeatureLocation=new t({attributes:{imageID:e.imageID},geometry:e.clone(),symbol:tt,visible:r}):this.additionalCameraLocations.push(new t({attributes:{imageID:e.imageID},geometry:e.clone(),symbol:Ke,visible:s}))}}_updateCurrentBestFeature(e){if(!e)return;this.currentBestFeature=this.features?.at(e.featureIndex);const t=this.currentBestFeature?.attributes.cameraPitch&&this.currentBestFeature?.attributes.cameraPitch<5;let i;if(t)i=-90;else{const t=e.x-we[3],a=e.y-we[3],r=a/Math.sqrt(t**2+a**2);let s=180*Math.acos(r)/Math.PI;(t<0&&a<0||t<0&&a>0)&&(s*=-1),i=s}i===this.bestFeatureAngle?this.previousFeatureAngle=i:this.bestFeatureAngle=i,this.navigatorCurrentBestFeature=t?null:{x:e.x,y:e.y,direction:e.sector.includes("_")?e.sector.split("_")[1]:e.sector}}clearGraphics(){this._imageViewer.clearGraphics(),this._panoramicViewer.clearGraphics()}clearReferencePointOnImage(){this._referencePointOnImage&&(this._imageViewer.removeGraphic(this._referencePointOnImage),this._panoramicViewer.removeGraphic(this._referencePointOnImage),this._referencePointOnImage=d(this._referencePointOnImage))}clearLocationPointOnImage(){this._locationPointOnImage&&(this._imageViewer.removeGraphic(this._locationPointOnImage),this._panoramicViewer.removeGraphic(this._locationPointOnImage),this._locationPointOnImage=d(this._locationPointOnImage))}plotReferencePoint(e){"mapPoint"in e?this.plotReferencePointOnGround(e.mapPoint):this.plotReferencePointOnGround(e)}setMessage(e,t,i,a){this.displayMessage={key:e,type:t,data:i,map:a}}async transformAndPlotSelectedLocation(e){const{currentBestFeature:t,invalidCameraHeading:i,selectedPoint:a,activeViewer:r}=this;if(this._crossSymbol&&(this._panoramicViewer.removeGraphic(this._crossSymbol),this._imageViewer.removeGraphic(this._crossSymbol),this._crossSymbol=d(this._crossSymbol)),!a||!t||"image-loaded"!==r?.state||i)return;let s;try{s=await this.worldToImage(a,e),f(e),await this.plotSelectedPointOnImage(s,e)}catch(o){y(o)||u.getLogger(this).error("failed to transform map point to pixel, cross symbol will not be plotted on image",{error:o,selectedPoint:a,feature:t})}}async worldToImage(e,t){const{footprintExtent:i}=this,{imageSize:a}=this.activeViewer;if("none"===this.mode||!this.currentBestFeature||!a||!i)return;const{attributes:{location:r,elevationSource:s,cameraHeading:o,elevation:n,cameraHeight:l},elevationSample:c}=this.currentBestFeature;let h=r.clone();const u=await te(n??(r.z??0)-l,{elevationSample:c,elevationSource:s});this.currentBestFeature.elevationSample=u.elevationSample;const p=Array.isArray(e)?e:[e];let m,d=await Promise.all(p.map((e=>new Promise((t=>{if(!e.hasZ)return t(K(e,u));t(e)})))));if(r.spatialReference.isGeographic&&(h=await x(h,j.WebMercator,t)),d=await Promise.all(d.map((async e=>h.spatialReference.equals(e.spatialReference)?e:await x(e,h.spatialReference,t)))),f(t),"panoramic"===this.mode)m=ce(d,{imageHeight:a[1],imageWidth:a[0],cameraHeading:o,cameraLocation:h});else{const e=oe(this.currentBestFeature.attributes,a[0],a[1]);m=he(d,{...e,cameraLocation:h})}return Array.isArray(e)?m:m[0]}updateCurrentCoveragePolygon(e){const{additionalFootprints:i,additionalCameraLocations:a,currentBestFeature:r,currentBestFeatureLocation:s,currentCoverageVisible:o,selectedPoint:n,view:l,_adapter:c,mode:h}=this,{attributes:{objectId:u},elevationSample:p}=r;if(this._initialCurrentCoverageUpdate){if(this._overlays?.removeAll(),this._initialCurrentCoverageUpdate=!1,this.bestFeatureCurrentFootprint=d(this.bestFeatureCurrentFootprint),e&&!this.invalidCameraHeading&&(e.visible=o,this.bestFeatureCurrentFootprint=e),l){const e=[...i,...a,s].filter(nt);l.supportsGround&&p&&c?.updateGroundElevation&&(this._updateGroundElevation&&c.updateGroundElevation(e,p),"panoramic"===h&&c.updateGroundElevation([this.bestFeatureCurrentFootprint],p)),this._updateGroundElevation=!1,n&&(e.splice(-2,0,this.bestFeatureCurrentFootprint),e.push(new t({geometry:n.clone(),symbol:We.clone(),attributes:{imageID:u}}))),this._overlays.graphics.addMany(e)}}else if(l){if(this.invalidCameraHeading)return;this.bestFeatureCurrentFootprint&&(this._overlays?.remove(this.bestFeatureCurrentFootprint),this.bestFeatureCurrentFootprint=d(this.bestFeatureCurrentFootprint));const t=this.bestFeatureCurrentFootprint&&this._overlays?this._overlays.graphics.indexOf(this.bestFeatureCurrentFootprint):-1;e&&(this.bestFeatureCurrentFootprint=e,l?.supportsGround&&p&&c?.updateGroundElevation&&"panoramic"===h&&c.updateGroundElevation([e],p),e.visible=this.currentCoverageVisible,this._overlays?.graphics.add(this.bestFeatureCurrentFootprint,t>=0?t:this._overlays.graphics.length-1))}}};e([M()],gt.prototype,"activeLayer",null),e([M({readOnly:!0})],gt.prototype,"activeViewer",null),e([M()],gt.prototype,"accuracyParametersMissing",null),e([M()],gt.prototype,"additionalFeatures",void 0),e([M({type:s.ofType(t)})],gt.prototype,"additionalCameraLocations",void 0),e([M({type:s.ofType(t)})],gt.prototype,"additionalFootprints",void 0),e([M()],gt.prototype,"areaMeasurementResult",void 0),e([M()],gt.prototype,"areaMeasurementAccuracy",void 0),e([M()],gt.prototype,"bestFeatureAngle",void 0),e([M()],gt.prototype,"bestFeatureCurrentFootprint",void 0),e([M({type:t})],gt.prototype,"bestFeatureFootprint",void 0),e([M({type:Number})],gt.prototype,"brightness",null),e([M()],gt.prototype,"collectionId",void 0),e([M({type:Number})],gt.prototype,"contrast",null),e([M()],gt.prototype,"conversionProps",void 0),e([M()],gt.prototype,"coverageFrustums",void 0),e([M()],gt.prototype,"coveragePolygons",void 0),e([M()],gt.prototype,"currentBestFeature",void 0),e([M()],gt.prototype,"currentBestFeatureLocation",void 0),e([M()],gt.prototype,"currentCoverageVisible",void 0),e([M({json:{write:!1}})],gt.prototype,"determineWorkflowForFeature",void 0),e([M()],gt.prototype,"disabled",void 0),e([M()],gt.prototype,"displayMessage",void 0),e([M()],gt.prototype,"displayNewMeasurementButton",void 0),e([M()],gt.prototype,"distanceMeasurementResult",void 0),e([M()],gt.prototype,"distanceAccuracyArray",void 0),e([M()],gt.prototype,"dataCaptureLayer",void 0),e([M({readOnly:!0})],gt.prototype,"featureCount",null),e([M()],gt.prototype,"features",void 0),e([M()],gt.prototype,"groundCoordinates",void 0),e([M()],gt.prototype,"heightMeasurementPixels",void 0),e([M()],gt.prototype,"heightGraphic",void 0),e([M()],gt.prototype,"heightMeasurementResult",void 0),e([M()],gt.prototype,"heightMeasurementAccuracy",void 0),e([M()],gt.prototype,"measurementAngle",void 0),e([M()],gt.prototype,"tempDistance",void 0),e([M({readOnly:!0})],gt.prototype,"imageGalleryEnabled",null),e([M()],gt.prototype,"imageGeometryField",void 0),e([M({readOnly:!0})],gt.prototype,"imageLoaded",null),e([M()],gt.prototype,"imageLocationToolState",void 0),e([M({readOnly:!0})],gt.prototype,"invalidCameraHeading",null),e([M()],gt.prototype,"imagePointsInView",null),e([M()],gt.prototype,"isAdditionalCoverageVisible",void 0),e([M()],gt.prototype,"isAdditionalPointSourcesVisible",void 0),e([M()],gt.prototype,"layer",void 0),e([M()],gt.prototype,"layerView",null),e([M({readOnly:!0})],gt.prototype,"layerFloorFilterClause",null),e([M({type:Number})],gt.prototype,"localPort",void 0),e([M()],gt.prototype,"mapImageConversionToolState",void 0),e([M()],gt.prototype,"measureType",void 0),e([M()],gt.prototype,"measurementGraphic",void 0),e([M({readOnly:!0,value:"none"})],gt.prototype,"mode",null),e([M()],gt.prototype,"navigatorCurrentBestFeature",void 0),e([M()],gt.prototype,"oiObjectIdField",void 0),e([M({type:s.ofType(t)})],gt.prototype,"overlayedCameraLocations",void 0),e([M()],gt.prototype,"overlayedMapFeatures",void 0),e([M()],gt.prototype,"pixelCoordinates",void 0),e([M()],gt.prototype,"pointSources",void 0),e([M({readOnly:!0})],gt.prototype,"popupEnabled",null),e([M()],gt.prototype,"previousFeatureAngle",void 0),e([M()],gt.prototype,"referencePoint",null),e([M({readOnly:!0})],gt.prototype,"sectorData",null),e([M()],gt.prototype,"selectedPoint",void 0),e([M({type:Number})],gt.prototype,"sharpness",null),e([M()],gt.prototype,"shouldShowSelectedImage",void 0),e([M()],gt.prototype,"sketch",void 0),e([M()],gt.prototype,"draw",void 0),e([M()],gt.prototype,"sketchAdapter",void 0),e([M({readOnly:!0})],gt.prototype,"sketchGraphicsLayer",null),e([M({readOnly:!0})],gt.prototype,"state",null),e([M({readOnly:!0})],gt.prototype,"thumbnails",null),e([M()],gt.prototype,"updateFootprint",void 0),e([M()],gt.prototype,"updateFootprintPanorama",void 0),e([M({value:null})],gt.prototype,"view",null),e([M()],gt.prototype,"_adapter",void 0),e([M()],gt.prototype,"_sketchGraphicsLayer",null),e([M()],gt.prototype,"_highlightedFeatureHandle",void 0),e([M()],gt.prototype,"_imageViewer",void 0),e([M()],gt.prototype,"_initialCurrentCoverageUpdate",void 0),e([M()],gt.prototype,"_locationPointOnImage",void 0),e([M()],gt.prototype,"_overlays",void 0),e([M({readOnly:!0})],gt.prototype,"_overlaysView",null),e([M()],gt.prototype,"_panoramicViewer",void 0),e([M()],gt.prototype,"_previousCursor",void 0),e([M()],gt.prototype,"_referencePointOnGround",void 0),e([M()],gt.prototype,"_referencePointOnImage",void 0),e([M()],gt.prototype,"_sectorData",void 0),e([M({readOnly:!0})],gt.prototype,"_updatingHandles",void 0),e([M()],gt.prototype,"footprintExtent",void 0),e([M()],gt.prototype,"_featureChangedTask",void 0),gt=e([C("esri.widgets.OrientedImageryViewer.OrientedImageryViewerViewModel")],gt);const yt=gt;export{yt as default};
|