@arcgis/core 5.0.0-next.42 → 5.0.0-next.43

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (89) hide show
  1. package/arcade/featureset/sources/FeatureLayerOGC.js +1 -1
  2. package/assets/esri/core/workers/RemoteClient.js +1 -1
  3. package/assets/esri/core/workers/chunks/00ff4ca88c9d291d82c3.js +1 -0
  4. package/assets/esri/core/workers/chunks/04a0685ee53ef74883aa.js +1 -0
  5. package/assets/esri/core/workers/chunks/{c320a29df40e85fb4a8e.js → 15a0750c10b510564a42.js} +1 -1
  6. package/assets/esri/core/workers/chunks/{816227de5bd42b437df4.js → 233f9eb617f3d72995b5.js} +1 -1
  7. package/assets/esri/core/workers/chunks/{fb9643b74cf35221ff98.js → 249504f7d356be80d214.js} +1 -1
  8. package/assets/esri/core/workers/chunks/{9d95f38da21f97214f83.js → 324d66962aeec17d3e28.js} +10 -10
  9. package/assets/esri/core/workers/chunks/385cfd3087f00dbd1146.js +1 -0
  10. package/assets/esri/core/workers/chunks/{4f4d51181ae7db9fbe6d.js → 4404b6f931f681cca342.js} +1 -1
  11. package/assets/esri/core/workers/chunks/555a0ea44ba77819d493.js +1 -0
  12. package/assets/esri/core/workers/chunks/6e8925412fb90f88d688.js +1 -0
  13. package/assets/esri/core/workers/chunks/83da9ee6544ee9d3c124.js +1 -0
  14. package/assets/esri/core/workers/chunks/{da517b4b07d4d27ce94c.js → 8e26831f71634288f834.js} +1 -1
  15. package/assets/esri/core/workers/chunks/{c367c7e553be3682f2db.js → 93c5f097bb7b380bb175.js} +1 -1
  16. package/assets/esri/core/workers/chunks/9c7682b300b877f60095.js +1 -0
  17. package/assets/esri/core/workers/chunks/{f3b3b193959db809c8c6.js → ab520fd1ae917daf07d8.js} +1 -1
  18. package/assets/esri/core/workers/chunks/{2c9865e34f32fb5683e5.js → af8d6e6949930d0e6c7b.js} +1 -1
  19. package/assets/esri/core/workers/chunks/c9942ca57f542582ab4d.js +1 -0
  20. package/assets/esri/core/workers/chunks/da2ba40bc017bff0fe49.js +1 -0
  21. package/assets/esri/core/workers/chunks/e5a6a646f27715152714.js +1 -0
  22. package/assets/esri/core/workers/chunks/e8a9971c8354569cb81d.js +1 -0
  23. package/assets/esri/core/workers/chunks/ed550bf27f2bbf8d30fa.js +1 -0
  24. package/assets/esri/core/workers/chunks/ee186ddbb1eb5144a790.js +1 -0
  25. package/assets/esri/core/workers/chunks/{1357cc637524cd254974.js → ffcdc7ae03b0570e0db8.js} +1 -1
  26. package/assets/esri/themes/base/widgets/_Attribution.scss +1 -1
  27. package/assets/esri/themes/dark/main.css +1 -1
  28. package/assets/esri/themes/light/main.css +1 -1
  29. package/assets/esri/themes/light/view.css +1 -1
  30. package/config.js +1 -1
  31. package/core/PooledArray.js +1 -1
  32. package/geometry/FlatGeometry.js +1 -1
  33. package/geometry/support/MeshMaterialMetallicRoughness.js +1 -1
  34. package/geometry/support/meshUtils/exporters/gltf/gltf.js +1 -1
  35. package/geometry/support/meshUtils/loadGLTFMesh.js +1 -1
  36. package/interfaces.d.ts +31 -35
  37. package/kernel.js +1 -1
  38. package/layers/graphics/controllers/I3SOnDemandController.js +1 -1
  39. package/layers/graphics/sources/support/clientSideDefaults.js +1 -1
  40. package/package.json +1 -1
  41. package/support/revision.js +1 -1
  42. package/views/2d/engine/webgl/cpuMapped/MappedMesh.js +1 -1
  43. package/views/2d/engine/webgl/shaderGraph/typed/TypedShaderProgram.js +1 -1
  44. package/views/2d/engine/webgl/textureUtils.js +1 -1
  45. package/views/2d/layers/MediaLayerView2D.js +1 -1
  46. package/views/2d/layers/TileLayerView2D.js +1 -1
  47. package/views/3d/glTF/LoaderResult.js +1 -1
  48. package/views/3d/glTF/internal/Resource.js +1 -1
  49. package/views/3d/glTF/loader.js +1 -1
  50. package/views/3d/layers/SceneLayerGraphicsView3D.js +1 -1
  51. package/views/3d/layers/graphics/Graphics3DExtrudeSymbolLayer.js +1 -1
  52. package/views/3d/layers/graphics/Graphics3DMeshFillSymbolLayer.js +1 -1
  53. package/views/3d/layers/graphics/Graphics3DObjectSymbolLayer.js +1 -1
  54. package/views/3d/layers/graphics/Graphics3DPathSymbolLayer.js +1 -1
  55. package/views/3d/layers/graphics/objectResourceUtils.js +1 -1
  56. package/views/3d/layers/i3s/I3SGraphicsMap.js +1 -1
  57. package/views/3d/layers/i3s/I3SIndex.js +1 -1
  58. package/views/3d/support/buffer/glUtil.js +1 -1
  59. package/views/3d/support/gaussianSplatting/GaussianSplatFadeTexture.js +1 -1
  60. package/views/3d/support/gaussianSplatting/GaussianSplatOrderTexture.js +1 -1
  61. package/views/3d/support/gaussianSplatting/GaussianSplatTextureAtlas.js +1 -1
  62. package/views/3d/webgl-engine/collections/Component/Material/ComponentData.glsl.js +1 -1
  63. package/views/3d/webgl-engine/core/shaderLibrary/TextureBackedBuffer.glsl.js +10 -10
  64. package/views/3d/webgl-engine/lib/edgeRendering/bufferLayouts.js +1 -1
  65. package/views/3d/webgl-engine/lib/edgeRendering/edgeProcessing.js +1 -1
  66. package/views/3d/webgl-engine/materials/DefaultLayouts.js +1 -1
  67. package/views/3d/webgl-engine/materials/DefaultMaterial.js +1 -1
  68. package/views/3d/webgl-engine/materials/PathTechnique.js +1 -1
  69. package/views/3d/webgl-engine/shaders/DefaultMaterialTechnique.js +1 -1
  70. package/views/3d/webgl-engine/shaders/sources/edgeRenderer/EdgeUtil.glsl.js +9 -9
  71. package/views/VideoView.js +1 -1
  72. package/views/webgl/ShaderBuilder.js +1 -1
  73. package/views/webgl/Util.js +1 -1
  74. package/views/webgl/VertexElementDescriptor.js +1 -1
  75. package/widgets/Editor.js +1 -1
  76. package/widgets/VersionManagement/VersionManagementViewModel.js +1 -1
  77. package/assets/esri/core/workers/chunks/0a5427127634738aa239.js +0 -1
  78. package/assets/esri/core/workers/chunks/110429583b28c28c36ee.js +0 -1
  79. package/assets/esri/core/workers/chunks/145c6a7cdcc9893efb27.js +0 -1
  80. package/assets/esri/core/workers/chunks/1bacdd17e199e22b5cd1.js +0 -1
  81. package/assets/esri/core/workers/chunks/1d566539ff6fb6ac798c.js +0 -1
  82. package/assets/esri/core/workers/chunks/5dc0d853c21ccb6054c7.js +0 -1
  83. package/assets/esri/core/workers/chunks/613cbac9cb925cd20b48.js +0 -1
  84. package/assets/esri/core/workers/chunks/800c91302eaad7f00877.js +0 -1
  85. package/assets/esri/core/workers/chunks/c4de24582c29fda5a033.js +0 -1
  86. package/assets/esri/core/workers/chunks/d786b17cc9062b1450ac.js +0 -1
  87. package/assets/esri/core/workers/chunks/d9958654c6438f28237b.js +0 -1
  88. package/assets/esri/core/workers/chunks/e6fa6f9c278589c8a713.js +0 -1
  89. package/assets/esri/core/workers/chunks/e7f4d135ef9665de1468.js +0 -1
@@ -2,4 +2,4 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import r from"../../../../../../core/Error.js";import e from"../../../../../../core/Logger.js";import{disposeMaybe as t}from"../../../../../../core/maybe.js";import{getDeepValue as o}from"../../../../../../core/object.js";import"../../../../../webgl/BufferObject.js";import"../../../../../webgl/FramebufferObject.js";import{Program as i}from"../../../../../webgl/Program.js";import"../../../../../../core/has.js";import"../../../../../webgl/Renderbuffer.js";import"../../../../../webgl/Texture.js";import"../../../../../webgl/enums.js";import"../../../../../webgl/checkWebGLError.js";import{createTexture as s}from"../../textureUtils.js";const n=()=>e.getLogger("esri.views.2d.engine.webgl.shaderGraph.typed.TypedShaderProgram");function a(e,t,o){const i=t.length;if(i!==o){const s=new r("Invalid Uniform",`Invalid length, expected ${o} but got ${i}`,{uniformName:e,values:t});n().errorOnce(s)}}class f{constructor(r,e,t,o,i){this.vertexShader=r,this.fragmentShader=e,this._locations=t,this._uniformBindings=o,this._transformFeedbackBindings=i,this._vao=null,this._temporaryTextures=[]}destroy(){this._program=t(this._program),this.cleanupTemporaryTextures()}setUniforms(r){this._uniforms=r}cleanupTemporaryTextures(){for(const r of this._temporaryTextures)r.dispose();this._temporaryTextures=[]}bind(r){const e=this._uniforms;if(!this._program){const e=[];for(const r of this._transformFeedbackBindings??[]){const{index:t,propertyKey:o}=r;e[t]=`v_${o}`}this._program=new i(r,this.vertexShader,this.fragmentShader,this._locations,new Map,e)}const t=this._program;r.useProgram(t);for(const i of this._uniformBindings){const{shaderModulePath:n,uniformName:f,uniformType:m,uniformArrayLength:c}=i,u=o(n,e);if(null==u){if("sampler2D"===m)continue;throw new Error(`Failed to find uniform value for ${n}`)}switch("array"===m||"array-2d"===m?i.uniformArrayElementType:m){case"sampler2D":{const{unit:e,texture:o}=u;if(t.setUniform1i(f,e),"type"in o)r.bindTexture(o,e);else{const t=s(r,o.descriptor,o.data);r.bindTexture(t,e)}break}case"int":if(!c){t.setUniform1i(f,u);break}a(i.uniformName,u,c),t.setUniform1iv(f,u);break;case"float":if(!c){t.setUniform1f(f,u);break}a(i.uniformName,u,c),t.setUniform1fv(f,u);break;case"vec2":if(!c){t.setUniform2f(f,u[0],u[1]);break}a(i.uniformName,u,c),t.setUniform2fv(f,u.flat());break;case"vec3":if(!c){t.setUniform3f(f,u[0],u[1],u[2]);break}a(i.uniformName,u,c),t.setUniform3fv(f,u.flat());break;case"vec4":if(!c){t.setUniform4f(f,u[0],u[1],u[2],u[3]);break}a(i.uniformName,u,c),t.setUniform4fv(f,u.flat());break;case"mat3":t.setUniformMatrix3fv(f,u);break;case"mat4":t.setUniformMatrix4fv(f,u);break;default:throw new Error(`Unable to set uniform for type ${m}`)}}}}export{f as TypedShaderProgram};
5
+ import r from"../../../../../../core/Error.js";import e from"../../../../../../core/Logger.js";import{disposeMaybe as t}from"../../../../../../core/maybe.js";import{getDeepValue as o}from"../../../../../../core/object.js";import"../../../../../webgl/BufferObject.js";import"../../../../../webgl/FramebufferObject.js";import{Program as i}from"../../../../../webgl/Program.js";import"../../../../../../core/has.js";import"../../../../../webgl/Renderbuffer.js";import"../../../../../webgl/Texture.js";import"../../../../../webgl/enums.js";import"../../../../../webgl/Util.js";import{createTexture as s}from"../../textureUtils.js";const n=()=>e.getLogger("esri.views.2d.engine.webgl.shaderGraph.typed.TypedShaderProgram");function a(e,t,o){const i=t.length;if(i!==o){const s=new r("Invalid Uniform",`Invalid length, expected ${o} but got ${i}`,{uniformName:e,values:t});n().errorOnce(s)}}class f{constructor(r,e,t,o,i){this.vertexShader=r,this.fragmentShader=e,this._locations=t,this._uniformBindings=o,this._transformFeedbackBindings=i,this._vao=null,this._temporaryTextures=[]}destroy(){this._program=t(this._program),this.cleanupTemporaryTextures()}setUniforms(r){this._uniforms=r}cleanupTemporaryTextures(){for(const r of this._temporaryTextures)r.dispose();this._temporaryTextures=[]}bind(r){const e=this._uniforms;if(!this._program){const e=[];for(const r of this._transformFeedbackBindings??[]){const{index:t,propertyKey:o}=r;e[t]=`v_${o}`}this._program=new i(r,this.vertexShader,this.fragmentShader,this._locations,new Map,e)}const t=this._program;r.useProgram(t);for(const i of this._uniformBindings){const{shaderModulePath:n,uniformName:f,uniformType:m,uniformArrayLength:c}=i,u=o(n,e);if(null==u){if("sampler2D"===m)continue;throw new Error(`Failed to find uniform value for ${n}`)}switch("array"===m||"array-2d"===m?i.uniformArrayElementType:m){case"sampler2D":{const{unit:e,texture:o}=u;if(t.setUniform1i(f,e),"type"in o)r.bindTexture(o,e);else{const t=s(r,o.descriptor,o.data);r.bindTexture(t,e)}break}case"int":if(!c){t.setUniform1i(f,u);break}a(i.uniformName,u,c),t.setUniform1iv(f,u);break;case"float":if(!c){t.setUniform1f(f,u);break}a(i.uniformName,u,c),t.setUniform1fv(f,u);break;case"vec2":if(!c){t.setUniform2f(f,u[0],u[1]);break}a(i.uniformName,u,c),t.setUniform2fv(f,u.flat());break;case"vec3":if(!c){t.setUniform3f(f,u[0],u[1],u[2]);break}a(i.uniformName,u,c),t.setUniform3fv(f,u.flat());break;case"vec4":if(!c){t.setUniform4f(f,u[0],u[1],u[2],u[3]);break}a(i.uniformName,u,c),t.setUniform4fv(f,u.flat());break;case"mat3":t.setUniformMatrix3fv(f,u);break;case"mat4":t.setUniformMatrix4fv(f,u);break;default:throw new Error(`Unable to set uniform for type ${m}`)}}}}export{f as TypedShaderProgram};
@@ -2,4 +2,4 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import"../../../webgl/BufferObject.js";import"../../../webgl/FramebufferObject.js";import"../../../webgl/Program.js";import"../../../../core/has.js";import"../../../webgl/Renderbuffer.js";import{Texture as e}from"../../../webgl/Texture.js";import"../../../../core/Logger.js";import"../../../webgl/enums.js";import"../../../webgl/checkWebGLError.js";import{TextureDescriptor as p}from"../../../webgl/TextureDescriptor.js";function r(r,t,a){const i=new p(t.width,t.height);return i.dataType=t.dataType,t.depth&&(i.depth=t.depth),t.flipped&&(i.flipped=t.flipped),t.hasMipmap&&(i.hasMipmap=t.hasMipmap),i.internalFormat=t.internalFormat,t.isImmutable&&(i.isImmutable=t.isImmutable),t.isOpaque&&(i.isOpaque=t.isOpaque),t.maxAnisotropy&&(i.maxAnisotropy=t.maxAnisotropy),i.pixelFormat=t.pixelFormat,t.preMultiplyAlpha&&(i.preMultiplyAlpha=t.preMultiplyAlpha),t.samplingMode&&(i.samplingMode=t.samplingMode),t.target&&(i.target=t.target),t.unpackAlignment&&(i.unpackAlignment=t.unpackAlignment),t.wrapMode&&(i.wrapMode=t.wrapMode),new e(r,i,a)}export{r as createTexture};
5
+ import"../../../webgl/BufferObject.js";import"../../../webgl/FramebufferObject.js";import"../../../webgl/Program.js";import"../../../../core/has.js";import"../../../webgl/Renderbuffer.js";import{Texture as e}from"../../../webgl/Texture.js";import"../../../../core/Logger.js";import"../../../webgl/enums.js";import"../../../webgl/Util.js";import{TextureDescriptor as p}from"../../../webgl/TextureDescriptor.js";function t(t,r,a){const i=new p(r.width,r.height);return i.dataType=r.dataType,r.depth&&(i.depth=r.depth),r.flipped&&(i.flipped=r.flipped),r.hasMipmap&&(i.hasMipmap=r.hasMipmap),i.internalFormat=r.internalFormat,r.isImmutable&&(i.isImmutable=r.isImmutable),r.isOpaque&&(i.isOpaque=r.isOpaque),r.maxAnisotropy&&(i.maxAnisotropy=r.maxAnisotropy),i.pixelFormat=r.pixelFormat,r.preMultiplyAlpha&&(i.preMultiplyAlpha=r.preMultiplyAlpha),r.samplingMode&&(i.samplingMode=r.samplingMode),r.target&&(i.target=r.target),r.unpackAlignment&&(i.unpackAlignment=r.unpackAlignment),r.wrapMode&&(i.wrapMode=r.wrapMode),new e(t,i,a)}export{t as createTexture};
@@ -2,4 +2,4 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import"../../../Graphic.js";import t from"../../../core/Collection.js";import i from"../../../core/Error.js";import"../../../core/has.js";import s from"../../../core/Logger.js";import{getOrCreateMapValue as r}from"../../../core/MapUtils.js";import{isAbortError as o}from"../../../core/promiseUtils.js";import{watch as n,syncAndInitial as l,on as m}from"../../../core/reactiveUtils.js";import{property as a,subclass as p}from"../../../core/accessorSupport/decorators.js";import c from"../../../geometry/Extent.js";import{create as h}from"../../../geometry/support/aaBoundingRect.js";import{ringsContainsCoords as d}from"../../../geometry/support/contains.js";import{extentIntersectsPolygon as g}from"../../../geometry/support/intersectsBase.js";import{MediaElementView as f}from"../../../layers/support/MediaElementView.js";import"../../../renderers/SimpleRenderer.js";import"../../../symbols/SimpleFillSymbol.js";import"../../../core/scheduling.js";import"../../../core/RandomLCG.js";import"../../../Color.js";import"../../../core/mathUtils.js";import"../../../config.js";import"../../../symbols/cim/defaultCIMValues.js";import"../../../core/floatRGBA.js";import"../../../geometry/Geometry.js";import"../../../geometry/Multipoint.js";import"../../../geometry/Point.js";import"../../../geometry/Polygon.js";import"../../../geometry/Polyline.js";import"../../../symbols/Font.js";import"../../../core/ObjectPool.js";import"../../../geometry/support/spatialReferenceUtils.js";import"../../../symbols/cim/effects/EffectAddControlPoints.js";import"../../../symbols/cim/effects/EffectArrow.js";import"../../../symbols/cim/effects/EffectBuffer.js";import"../../../symbols/cim/effects/EffectControlMeasureLine.js";import"../../../symbols/cim/effects/EffectCut.js";import"../../../symbols/cim/effects/EffectDashes.js";import"../../../symbols/cim/effects/EffectDonut.js";import"../../../symbols/cim/effects/EffectEnclosingPolygon.js";import"../../../symbols/cim/effects/EffectJog.js";import"../../../symbols/cim/effects/EffectMove.js";import"../../../symbols/cim/effects/EffectOffset.js";import"../../../symbols/cim/effects/EffectRadial.js";import"../../../symbols/cim/effects/EffectReverse.js";import"../../../symbols/cim/effects/EffectRotate.js";import"../../../symbols/cim/effects/EffectScale.js";import"../../../symbols/cim/effects/EffectSuppress.js";import"../../../symbols/cim/effects/EffectTaperedPolygon.js";import"../../../symbols/cim/effects/EffectWave.js";import"../../../symbols/cim/placements/PlacementAlongLineSameSize.js";import"../../../symbols/cim/placements/PlacementAtExtremities.js";import"../../../symbols/cim/placements/PlacementAtMeasuredUnits.js";import"../../../symbols/cim/placements/PlacementAtRatioPositions.js";import"../../../symbols/cim/placements/PlacementInsidePolygon.js";import"../../../symbols/cim/placements/PlacementOnLine.js";import"../../../symbols/cim/placements/PlacementOnVertices.js";import"../../../symbols/cim/placements/PlacementPolygonCenter.js";import"../../../symbols/cim/constants.js";import"../../../core/libs/gl-matrix-2/factories/vec2f32.js";import"../../../symbols/support/defaults.js";import"../../../symbols/cim/OverrideHelper.js";import"../../../layers/effects/EffectView.js";import"../../../core/Accessor.js";import"../engine/transitions/FadeTransition.js";import"../../../core/libs/gl-matrix-2/factories/vec4f32.js";import"../../webgl/enums.js";import"../engine/webgl/shaders/BackgroundPrograms.js";import"../../webgl/Program.js";import"../../webgl/checkWebGLError.js";import"../../webgl/VertexAttributeLayouts.js";import"../../webgl/BufferObject.js";import"../engine/webgl/AFeatureTile.js";import"../engine/webgl/DisplayEntity.js";import"../engine/webgl/shaderGraph/techniques/featureTechniqueUtils.js";import"../engine/webgl/cpuMapped/MappedMesh.js";import"../engine/webgl/number.js";import"../engine/webgl/shaders/TileInfoPrograms.js";import"../../webgl/Texture.js";import"../engine/webgl/shaders/BitBlitPrograms.js";import"../../../request.js";import"../../../core/urlUtils.js";import"../../../core/pbf.js";import"../engine/webgl/shaders/StencilPrograms.js";import"../engine/webgl/shaderGraph/techniques/shaders/BlendShader.js";import"../engine/webgl/shaderGraph/techniques/shaders/OpacityShader.js";import"../engine/webgl/shaders/HighlightPrograms.js";import"../../webgl/FramebufferObject.js";import"../engine/webgl/shaderGraph/techniques/shaders/BlitShader.js";import"../engine/webgl/shaderGraph/techniques/shaders/BloomShader.js";import"../engine/webgl/shaderGraph/techniques/shaders/BlurShader.js";import"../engine/webgl/shaderGraph/techniques/shaders/ColorizeShader.js";import"../engine/webgl/shaderGraph/techniques/shaders/DropShadowShader.js";import"../engine/webgl/meshing/SimpleMesh.js";import"../../webgl/Renderbuffer.js";import"../engine/webgl/PooledUint32Array.js";import"../engine/webgl/Profiler.js";import"../engine/webgl/shaderGraph/techniques/TechniqueRegistry.js";import"../engine/webgl/shaderGraph/techniques/animated/attributes.js";import"../engine/webgl/mesh/templates/templateUtils.js";import"../engine/webgl/shaderGraph/techniques/line/LineMeshWriter.js";import"../engine/webgl/shaderGraph/techniques/dotDensity/DotDensityMeshWriter.js";import"../engine/webgl/shaderGraph/techniques/fill/ComplexFillMeshWriter.js";import"../engine/webgl/shaderGraph/techniques/fill/ComplexOutlineFillMeshWriter.js";import"../engine/webgl/shaderGraph/techniques/fill/FillMeshWriter.js";import"../engine/webgl/shaderGraph/techniques/fill/GradientFillMeshWriter.js";import"../engine/webgl/shaderGraph/techniques/fill/OutlineFillMeshWriter.js";import"../engine/webgl/shaderGraph/techniques/fill/PatternFillMeshWriter.js";import"../engine/webgl/shaderGraph/techniques/fill/PatternOutlineFillMeshWriter.js";import"../engine/webgl/shaderGraph/techniques/heatmap/HeatmapMeshWriter.js";import"../../../geometry/support/aaBoundingBox.js";import"../engine/webgl/shaderGraph/techniques/text/TextMeshWriter.js";import"../engine/webgl/shaderGraph/techniques/line/GradientStrokeMeshWriter.js";import"../engine/webgl/shaderGraph/techniques/line/TexturedLineMeshWriter.js";import"../engine/webgl/shaderGraph/techniques/markers/MarkerMeshWriter.js";import"../../../core/sql/UnknownTimeZone.js";import"luxon";import"../../../intl/locale.js";import"../../../layers/support/fieldUtils.js";import"../../../time/constants.js";import"../engine/webgl/animations/instructions.js";import"../engine/webgl/shaderGraph/techniques/pieChart/PieChartMeshWriter.js";import"../../webgl/renderState.js";import"../../3d/webgl-engine/core/shaderModules/glsl.js";import"../../webgl/testSVGPremultipliedAlpha.js";import"../../../chunks/pe.js";import"../engine/webgl/meshing/definitions.js";import"../engine/webgl/shaderGraph/techniques/shaders/VideoScreenShader.js";import"../LabelManager.js";import"./graphics/GraphicsView2D.js";import"../../../chunks/earcut.js";import"../../../core/libs/gl-matrix-2/factories/vec3f32.js";import"../../../geometry/support/normalizeUtils.js";import"./support/util.js";import"../navigation/MapViewNavigation.js";import"../../../core/asyncUtils.js";import"../../../core/support/UpdatingHandles.js";import"../engine/webgl/shaderGraph/techniques/shaders/MagnifierShader.js";import"../../../core/units.js";import"../../../geometry/ellipsoidUtils.js";import"../../../geometry/SpatialReference.js";import"../../../geometry/operators/support/GeographicTransformation.js";import"../../../geometry/projection/projectors.js";import"../engine/webgl/shaderGraph/techniques/shaders/GridShader.js";import"../../../geometry/support/geodesicConstants.js";import"../../../geometry/support/Ellipsoid.js";import"../tiling/TileInfoView.js";import"../tiling/TileKey.js";import u from"../tiling/TileQueue.js";import j from"../tiling/TileStrategy.js";import y from"../engine/webgl/Overlay.js";import b from"../engine/webgl/OverlayContainer.js";import{LayerView2DMixin as w}from"./LayerView2D.js";import _ from"../../layers/LayerView.js";import{MediaLayerViewMixin as v}from"../../layers/MediaLayerViewMixin.js";import{TaskPriority as E}from"../../support/Scheduler.js";let G=class extends(w(v(_))){constructor(){super(...arguments),this._overlayContainer=null,this._fetchQueue=null,this._tileStrategy=null,this._elementReferences=new Map,this._debugGraphicsView=null,this._interaction=null,this.layer=null,this.elements=new t}initialize(){this.addHandles([n(()=>[this.interactive,this.suspended],async()=>{if(this.interactive&&!this._interaction){const{MediaLayerInteraction:e}=await import("./support/MediaLayerInteraction.js");this._interaction=new e({view:this.view,layer:this.layer}),this.selectedElement!==this._interaction.selectedElement&&(this._interaction.selectedElement=this.selectedElement),this.interactionOptions!==this._interaction.options&&(this._interaction.options=this.interactionOptions)}this._interaction&&(this._interaction.enabled=!this.suspended&&this.interactive)},l),n(()=>this.interactionOptions,e=>{this._interaction&&(this._interaction.options=e)},l),n(()=>this.selectedElement,e=>{this._interaction&&(this._interaction.selectedElement=e)},l)])}attach(){this.addAttachHandles([m(()=>this.layer.effectiveSource,"refresh",()=>{this._tileStrategy.refresh(e=>this._updateTile(e)),this.requestUpdate()}),m(()=>this.layer.effectiveSource,"change",({element:e})=>this._elementUpdateHandler(e))]),this._overlayContainer=new b,this.container.addChild(this._overlayContainer),this._fetchQueue=new u({tileInfoView:this.view.featuresTilingScheme,concurrency:10,process:(e,t)=>this._queryElements(e,t),scheduler:this.scheduler,priority:E.MAPVIEW_FETCH_QUEUE}),this._tileStrategy=new j({cachePolicy:"purge",resampling:!0,acquireTile:e=>this._acquireTile(e),releaseTile:e=>this._releaseTile(e),tileInfoView:this.view.featuresTilingScheme}),this.requestUpdate()}detach(){this.elements.removeAll(),this._tileStrategy.destroy(),this._fetchQueue.destroy(),this._overlayContainer.removeAllChildren(),this.container.removeAllChildren(),this._elementReferences.clear(),this._debugGraphicsView?.destroy()}supportsSpatialReference(e){return!0}viewChange(){this.requestUpdate()}moveEnd(){this.requestUpdate()}update(e){this._tileStrategy.update(e),this._debugGraphicsView?.update(e)}async hitTest(e,t){const i=[],s=e.normalize(),r=[s.x,s.y];for(const{elementView:{normalizedCoords:o,element:n}}of this._elementReferences.values())null!=o&&d(o.rings,r)&&i.push({type:"media",element:n,layer:this.layer,mapPoint:e,sourcePoint:n.toSource(e)});return i.reverse()}canResume(){return null!=this.layer.source&&super.canResume()}async doRefresh(){this._fetchQueue.reset(),this._tileStrategy.refresh(e=>this._updateTile(e))}_acquireTile(e){const t=new P(e.clone());return this._updateTile(t),t}_updateTile(e){this._updatingHandles.addPromise(this._fetchQueue.push(e.key).then(t=>{const[i,s]=e.setElements(t);this._referenceElements(e,i),this._dereferenceElements(e,s),this.requestUpdate()},e=>{o(e)||s.getLogger(this).error(e)}))}_releaseTile(e){this._fetchQueue.abort(e.key.id),e.elements&&this._dereferenceElements(e,e.elements),this.requestUpdate()}async _queryElements(e,t){const i=this.layer.effectiveSource;if(null==i)return[];this.view.featuresTilingScheme.getTileBounds(S,e,!0);const s=new c({xmin:S[0],ymin:S[1],xmax:S[2],ymax:S[3],spatialReference:this.view.spatialReference});return i.queryElements(s,t)}_referenceElements(e,t){if(null!=this.layer.source)for(const i of t)this._referenceElement(e,i)}_referenceElement(e,t){r(this._elementReferences,t.uid,()=>{const e=new f({element:t,spatialReference:this.view.spatialReference}),r=new y(e);return this._overlayContainer.addChild(r),this.elements.add(t),this._updatingHandles.addPromise(t.load().catch(e=>{s.getLogger("esri.views.2d.layers.MediaLayerView2D").error(new i("element-load-error","Element cannot be displayed",{element:t,error:e}))})),{debugGraphic:null,elementView:e,overlay:r,tiles:new Set}}).tiles.add(e)}_dereferenceElements(e,t){for(const i of t)this._dereferenceElement(e,i)}_dereferenceElement(e,t){const i=this._elementReferences.get(t.uid);i.tiles.delete(e),i.tiles.size||(this._overlayContainer.removeChild(i.overlay),i.overlay.destroy(),i.elementView.destroy(),this._elementReferences.delete(t.uid),this.elements.remove(t),this._debugGraphicsView?.graphics.remove(i.debugGraphic))}_elementUpdateHandler(e){let t=this._elementReferences.get(e.uid);if(t){const i=t.elementView.normalizedCoords;if(null==i)return this._overlayContainer.removeChild(t.overlay),t.overlay.destroy(),t.elementView.destroy(),this._elementReferences.delete(e.uid),this.elements.remove(e),void this._debugGraphicsView?.graphics.remove(t.debugGraphic);const s=[],r=[];for(const e of this._tileStrategy.tiles){const o=M(this.view.featuresTilingScheme,e,i);t.tiles.has(e)?o||r.push(e):o&&s.push(e)}for(const t of s)this._referenceElement(t,e);for(const t of r)this._dereferenceElement(t,e);return t=this._elementReferences.get(e.uid),void(t?.debugGraphic&&(t.debugGraphic.geometry=t.elementView.normalizedCoords,this._debugGraphicsView.graphicUpdateHandler({graphic:t.debugGraphic,property:"geometry"})))}const i=new f({element:e,spatialReference:this.view.spatialReference}).normalizedCoords;if(null!=i)for(const s of this._tileStrategy.tiles){M(this.view.featuresTilingScheme,s,i)&&this._referenceElement(s,e)}}};e([a()],G.prototype,"layer",void 0),e([a({readOnly:!0})],G.prototype,"elements",void 0),G=e([p("esri.views.2d.layers.MediaLayerView2D")],G);const S=h(),q={xmin:0,ymin:0,xmax:0,ymax:0};function M(e,t,i){return e.getTileBounds(S,t.key,!0),q.xmin=S[0],q.ymin=S[1],q.xmax=S[2],q.ymax=S[3],g(q,i)}class P{constructor(e){this.key=e,this.elements=null,this.isReady=!1,this.visible=!0}setElements(e){const t=[],i=new Set(this.elements);this.elements=e;for(const s of e)i.has(s)?i.delete(s):t.push(s);return this.isReady=!0,[t,Array.from(i)]}destroy(){}}const C=G;export{C as default};
5
+ import{__decorate as e}from"tslib";import"../../../Graphic.js";import t from"../../../core/Collection.js";import i from"../../../core/Error.js";import"../../../core/has.js";import s from"../../../core/Logger.js";import{getOrCreateMapValue as r}from"../../../core/MapUtils.js";import{isAbortError as o}from"../../../core/promiseUtils.js";import{watch as n,syncAndInitial as l,on as m}from"../../../core/reactiveUtils.js";import{property as a,subclass as p}from"../../../core/accessorSupport/decorators.js";import c from"../../../geometry/Extent.js";import{create as h}from"../../../geometry/support/aaBoundingRect.js";import{ringsContainsCoords as d}from"../../../geometry/support/contains.js";import{extentIntersectsPolygon as g}from"../../../geometry/support/intersectsBase.js";import{MediaElementView as f}from"../../../layers/support/MediaElementView.js";import"../../../renderers/SimpleRenderer.js";import"../../../symbols/SimpleFillSymbol.js";import"../../../core/scheduling.js";import"../../../core/RandomLCG.js";import"../../../Color.js";import"../../../core/mathUtils.js";import"../../../config.js";import"../../../symbols/cim/defaultCIMValues.js";import"../../../core/floatRGBA.js";import"../../../geometry/Geometry.js";import"../../../geometry/Multipoint.js";import"../../../geometry/Point.js";import"../../../geometry/Polygon.js";import"../../../geometry/Polyline.js";import"../../../symbols/Font.js";import"../../../core/ObjectPool.js";import"../../../geometry/support/spatialReferenceUtils.js";import"../../../symbols/cim/effects/EffectAddControlPoints.js";import"../../../symbols/cim/effects/EffectArrow.js";import"../../../symbols/cim/effects/EffectBuffer.js";import"../../../symbols/cim/effects/EffectControlMeasureLine.js";import"../../../symbols/cim/effects/EffectCut.js";import"../../../symbols/cim/effects/EffectDashes.js";import"../../../symbols/cim/effects/EffectDonut.js";import"../../../symbols/cim/effects/EffectEnclosingPolygon.js";import"../../../symbols/cim/effects/EffectJog.js";import"../../../symbols/cim/effects/EffectMove.js";import"../../../symbols/cim/effects/EffectOffset.js";import"../../../symbols/cim/effects/EffectRadial.js";import"../../../symbols/cim/effects/EffectReverse.js";import"../../../symbols/cim/effects/EffectRotate.js";import"../../../symbols/cim/effects/EffectScale.js";import"../../../symbols/cim/effects/EffectSuppress.js";import"../../../symbols/cim/effects/EffectTaperedPolygon.js";import"../../../symbols/cim/effects/EffectWave.js";import"../../../symbols/cim/placements/PlacementAlongLineSameSize.js";import"../../../symbols/cim/placements/PlacementAtExtremities.js";import"../../../symbols/cim/placements/PlacementAtMeasuredUnits.js";import"../../../symbols/cim/placements/PlacementAtRatioPositions.js";import"../../../symbols/cim/placements/PlacementInsidePolygon.js";import"../../../symbols/cim/placements/PlacementOnLine.js";import"../../../symbols/cim/placements/PlacementOnVertices.js";import"../../../symbols/cim/placements/PlacementPolygonCenter.js";import"../../../symbols/cim/constants.js";import"../../../core/libs/gl-matrix-2/factories/vec2f32.js";import"../../../symbols/support/defaults.js";import"../../../symbols/cim/OverrideHelper.js";import"../../../layers/effects/EffectView.js";import"../../../core/Accessor.js";import"../engine/transitions/FadeTransition.js";import"../../../core/libs/gl-matrix-2/factories/vec4f32.js";import"../../webgl/enums.js";import"../engine/webgl/shaders/BackgroundPrograms.js";import"../../webgl/Program.js";import"../../webgl/Util.js";import"../../webgl/VertexAttributeLayouts.js";import"../../webgl/BufferObject.js";import"../engine/webgl/AFeatureTile.js";import"../engine/webgl/DisplayEntity.js";import"../engine/webgl/shaderGraph/techniques/featureTechniqueUtils.js";import"../engine/webgl/cpuMapped/MappedMesh.js";import"../engine/webgl/number.js";import"../engine/webgl/shaders/TileInfoPrograms.js";import"../../webgl/Texture.js";import"../engine/webgl/shaders/BitBlitPrograms.js";import"../../../request.js";import"../../../core/urlUtils.js";import"../../../core/pbf.js";import"../engine/webgl/shaders/StencilPrograms.js";import"../engine/webgl/shaderGraph/techniques/shaders/BlendShader.js";import"../engine/webgl/shaderGraph/techniques/shaders/OpacityShader.js";import"../engine/webgl/shaders/HighlightPrograms.js";import"../../webgl/FramebufferObject.js";import"../engine/webgl/shaderGraph/techniques/shaders/BlitShader.js";import"../engine/webgl/shaderGraph/techniques/shaders/BloomShader.js";import"../engine/webgl/shaderGraph/techniques/shaders/BlurShader.js";import"../engine/webgl/shaderGraph/techniques/shaders/ColorizeShader.js";import"../engine/webgl/shaderGraph/techniques/shaders/DropShadowShader.js";import"../engine/webgl/meshing/SimpleMesh.js";import"../../webgl/Renderbuffer.js";import"../engine/webgl/PooledUint32Array.js";import"../engine/webgl/Profiler.js";import"../engine/webgl/shaderGraph/techniques/TechniqueRegistry.js";import"../engine/webgl/shaderGraph/techniques/animated/attributes.js";import"../engine/webgl/mesh/templates/templateUtils.js";import"../engine/webgl/shaderGraph/techniques/line/LineMeshWriter.js";import"../engine/webgl/shaderGraph/techniques/dotDensity/DotDensityMeshWriter.js";import"../engine/webgl/shaderGraph/techniques/fill/ComplexFillMeshWriter.js";import"../engine/webgl/shaderGraph/techniques/fill/ComplexOutlineFillMeshWriter.js";import"../engine/webgl/shaderGraph/techniques/fill/FillMeshWriter.js";import"../engine/webgl/shaderGraph/techniques/fill/GradientFillMeshWriter.js";import"../engine/webgl/shaderGraph/techniques/fill/OutlineFillMeshWriter.js";import"../engine/webgl/shaderGraph/techniques/fill/PatternFillMeshWriter.js";import"../engine/webgl/shaderGraph/techniques/fill/PatternOutlineFillMeshWriter.js";import"../engine/webgl/shaderGraph/techniques/heatmap/HeatmapMeshWriter.js";import"../../../geometry/support/aaBoundingBox.js";import"../engine/webgl/shaderGraph/techniques/text/TextMeshWriter.js";import"../engine/webgl/shaderGraph/techniques/line/GradientStrokeMeshWriter.js";import"../engine/webgl/shaderGraph/techniques/line/TexturedLineMeshWriter.js";import"../engine/webgl/shaderGraph/techniques/markers/MarkerMeshWriter.js";import"../../../core/sql/UnknownTimeZone.js";import"luxon";import"../../../intl/locale.js";import"../../../layers/support/fieldUtils.js";import"../../../time/constants.js";import"../engine/webgl/animations/instructions.js";import"../engine/webgl/shaderGraph/techniques/pieChart/PieChartMeshWriter.js";import"../../webgl/checkWebGLError.js";import"../../webgl/renderState.js";import"../../3d/webgl-engine/core/shaderModules/glsl.js";import"../../webgl/testSVGPremultipliedAlpha.js";import"../../../chunks/pe.js";import"../engine/webgl/meshing/definitions.js";import"../engine/webgl/shaderGraph/techniques/shaders/VideoScreenShader.js";import"../LabelManager.js";import"./graphics/GraphicsView2D.js";import"../../../chunks/earcut.js";import"../../../core/libs/gl-matrix-2/factories/vec3f32.js";import"../../../geometry/support/normalizeUtils.js";import"./support/util.js";import"../navigation/MapViewNavigation.js";import"../../../core/asyncUtils.js";import"../../../core/support/UpdatingHandles.js";import"../engine/webgl/shaderGraph/techniques/shaders/MagnifierShader.js";import"../../../core/units.js";import"../../../geometry/ellipsoidUtils.js";import"../../../geometry/SpatialReference.js";import"../../../geometry/operators/support/GeographicTransformation.js";import"../../../geometry/projection/projectors.js";import"../engine/webgl/shaderGraph/techniques/shaders/GridShader.js";import"../../../geometry/support/geodesicConstants.js";import"../../../geometry/support/Ellipsoid.js";import"../tiling/TileInfoView.js";import"../tiling/TileKey.js";import u from"../tiling/TileQueue.js";import j from"../tiling/TileStrategy.js";import y from"../engine/webgl/Overlay.js";import b from"../engine/webgl/OverlayContainer.js";import{LayerView2DMixin as w}from"./LayerView2D.js";import _ from"../../layers/LayerView.js";import{MediaLayerViewMixin as v}from"../../layers/MediaLayerViewMixin.js";import{TaskPriority as E}from"../../support/Scheduler.js";let G=class extends(w(v(_))){constructor(){super(...arguments),this._overlayContainer=null,this._fetchQueue=null,this._tileStrategy=null,this._elementReferences=new Map,this._debugGraphicsView=null,this._interaction=null,this.layer=null,this.elements=new t}initialize(){this.addHandles([n(()=>[this.interactive,this.suspended],async()=>{if(this.interactive&&!this._interaction){const{MediaLayerInteraction:e}=await import("./support/MediaLayerInteraction.js");this._interaction=new e({view:this.view,layer:this.layer}),this.selectedElement!==this._interaction.selectedElement&&(this._interaction.selectedElement=this.selectedElement),this.interactionOptions!==this._interaction.options&&(this._interaction.options=this.interactionOptions)}this._interaction&&(this._interaction.enabled=!this.suspended&&this.interactive)},l),n(()=>this.interactionOptions,e=>{this._interaction&&(this._interaction.options=e)},l),n(()=>this.selectedElement,e=>{this._interaction&&(this._interaction.selectedElement=e)},l)])}attach(){this.addAttachHandles([m(()=>this.layer.effectiveSource,"refresh",()=>{this._tileStrategy.refresh(e=>this._updateTile(e)),this.requestUpdate()}),m(()=>this.layer.effectiveSource,"change",({element:e})=>this._elementUpdateHandler(e))]),this._overlayContainer=new b,this.container.addChild(this._overlayContainer),this._fetchQueue=new u({tileInfoView:this.view.featuresTilingScheme,concurrency:10,process:(e,t)=>this._queryElements(e,t),scheduler:this.scheduler,priority:E.MAPVIEW_FETCH_QUEUE}),this._tileStrategy=new j({cachePolicy:"purge",resampling:!0,acquireTile:e=>this._acquireTile(e),releaseTile:e=>this._releaseTile(e),tileInfoView:this.view.featuresTilingScheme}),this.requestUpdate()}detach(){this.elements.removeAll(),this._tileStrategy.destroy(),this._fetchQueue.destroy(),this._overlayContainer.removeAllChildren(),this.container.removeAllChildren(),this._elementReferences.clear(),this._debugGraphicsView?.destroy()}supportsSpatialReference(e){return!0}viewChange(){this.requestUpdate()}moveEnd(){this.requestUpdate()}update(e){this._tileStrategy.update(e),this._debugGraphicsView?.update(e)}async hitTest(e,t){const i=[],s=e.normalize(),r=[s.x,s.y];for(const{elementView:{normalizedCoords:o,element:n}}of this._elementReferences.values())null!=o&&d(o.rings,r)&&i.push({type:"media",element:n,layer:this.layer,mapPoint:e,sourcePoint:n.toSource(e)});return i.reverse()}canResume(){return null!=this.layer.source&&super.canResume()}async doRefresh(){this._fetchQueue.reset(),this._tileStrategy.refresh(e=>this._updateTile(e))}_acquireTile(e){const t=new P(e.clone());return this._updateTile(t),t}_updateTile(e){this._updatingHandles.addPromise(this._fetchQueue.push(e.key).then(t=>{const[i,s]=e.setElements(t);this._referenceElements(e,i),this._dereferenceElements(e,s),this.requestUpdate()},e=>{o(e)||s.getLogger(this).error(e)}))}_releaseTile(e){this._fetchQueue.abort(e.key.id),e.elements&&this._dereferenceElements(e,e.elements),this.requestUpdate()}async _queryElements(e,t){const i=this.layer.effectiveSource;if(null==i)return[];this.view.featuresTilingScheme.getTileBounds(S,e,!0);const s=new c({xmin:S[0],ymin:S[1],xmax:S[2],ymax:S[3],spatialReference:this.view.spatialReference});return i.queryElements(s,t)}_referenceElements(e,t){if(null!=this.layer.source)for(const i of t)this._referenceElement(e,i)}_referenceElement(e,t){r(this._elementReferences,t.uid,()=>{const e=new f({element:t,spatialReference:this.view.spatialReference}),r=new y(e);return this._overlayContainer.addChild(r),this.elements.add(t),this._updatingHandles.addPromise(t.load().catch(e=>{s.getLogger("esri.views.2d.layers.MediaLayerView2D").error(new i("element-load-error","Element cannot be displayed",{element:t,error:e}))})),{debugGraphic:null,elementView:e,overlay:r,tiles:new Set}}).tiles.add(e)}_dereferenceElements(e,t){for(const i of t)this._dereferenceElement(e,i)}_dereferenceElement(e,t){const i=this._elementReferences.get(t.uid);i.tiles.delete(e),i.tiles.size||(this._overlayContainer.removeChild(i.overlay),i.overlay.destroy(),i.elementView.destroy(),this._elementReferences.delete(t.uid),this.elements.remove(t),this._debugGraphicsView?.graphics.remove(i.debugGraphic))}_elementUpdateHandler(e){let t=this._elementReferences.get(e.uid);if(t){const i=t.elementView.normalizedCoords;if(null==i)return this._overlayContainer.removeChild(t.overlay),t.overlay.destroy(),t.elementView.destroy(),this._elementReferences.delete(e.uid),this.elements.remove(e),void this._debugGraphicsView?.graphics.remove(t.debugGraphic);const s=[],r=[];for(const e of this._tileStrategy.tiles){const o=M(this.view.featuresTilingScheme,e,i);t.tiles.has(e)?o||r.push(e):o&&s.push(e)}for(const t of s)this._referenceElement(t,e);for(const t of r)this._dereferenceElement(t,e);return t=this._elementReferences.get(e.uid),void(t?.debugGraphic&&(t.debugGraphic.geometry=t.elementView.normalizedCoords,this._debugGraphicsView.graphicUpdateHandler({graphic:t.debugGraphic,property:"geometry"})))}const i=new f({element:e,spatialReference:this.view.spatialReference}).normalizedCoords;if(null!=i)for(const s of this._tileStrategy.tiles){M(this.view.featuresTilingScheme,s,i)&&this._referenceElement(s,e)}}};e([a()],G.prototype,"layer",void 0),e([a({readOnly:!0})],G.prototype,"elements",void 0),G=e([p("esri.views.2d.layers.MediaLayerView2D")],G);const S=h(),q={xmin:0,ymin:0,xmax:0,ymax:0};function M(e,t,i){return e.getTileBounds(S,t.key,!0),q.xmin=S[0],q.ymin=S[1],q.xmax=S[2],q.ymax=S[3],g(q,i)}class P{constructor(e){this.key=e,this.elements=null,this.isReady=!1,this.visible=!0}setElements(e){const t=[],i=new Set(this.elements);this.elements=e;for(const s of e)i.has(s)?i.delete(s):t.push(s);return this.isReady=!0,[t,Array.from(i)]}destroy(){}}const C=G;export{C as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import{makeHandle as i}from"../../../core/handleUtils.js";import t from"../../../core/Logger.js";import{isAbortError as s,waitTick as r}from"../../../core/promiseUtils.js";import{property as o,subclass as l}from"../../../core/accessorSupport/decorators.js";import{equals as h}from"../../../geometry/support/spatialReferenceUtils.js";import{GraphicsCollection as a}from"../../../support/GraphicsCollection.js";import"../../../core/Error.js";import"../../../core/has.js";import"../../../core/scheduling.js";import"../../../core/RandomLCG.js";import"../../../Color.js";import"../../../core/mathUtils.js";import"../../../config.js";import"../../../symbols/cim/defaultCIMValues.js";import"../../../core/floatRGBA.js";import"../../../geometry/Extent.js";import"../../../geometry/Geometry.js";import"../../../geometry/Multipoint.js";import"../../../geometry/Point.js";import"../../../geometry/Polygon.js";import"../../../geometry/Polyline.js";import"../../../symbols/Font.js";import"../../../core/ObjectPool.js";import"../../../symbols/cim/effects/EffectAddControlPoints.js";import"../../../symbols/cim/effects/EffectArrow.js";import"../../../symbols/cim/effects/EffectBuffer.js";import"../../../symbols/cim/effects/EffectControlMeasureLine.js";import"../../../symbols/cim/effects/EffectCut.js";import"../../../symbols/cim/effects/EffectDashes.js";import"../../../symbols/cim/effects/EffectDonut.js";import"../../../symbols/cim/effects/EffectEnclosingPolygon.js";import"../../../symbols/cim/effects/EffectJog.js";import"../../../symbols/cim/effects/EffectMove.js";import"../../../symbols/cim/effects/EffectOffset.js";import"../../../symbols/cim/effects/EffectRadial.js";import"../../../symbols/cim/effects/EffectReverse.js";import"../../../symbols/cim/effects/EffectRotate.js";import"../../../symbols/cim/effects/EffectScale.js";import"../../../symbols/cim/effects/EffectSuppress.js";import"../../../symbols/cim/effects/EffectTaperedPolygon.js";import"../../../symbols/cim/effects/EffectWave.js";import"../../../symbols/cim/placements/PlacementAlongLineSameSize.js";import"../../../symbols/cim/placements/PlacementAtExtremities.js";import"../../../symbols/cim/placements/PlacementAtMeasuredUnits.js";import"../../../symbols/cim/placements/PlacementAtRatioPositions.js";import"../../../symbols/cim/placements/PlacementInsidePolygon.js";import"../../../symbols/cim/placements/PlacementOnLine.js";import"../../../symbols/cim/placements/PlacementOnVertices.js";import"../../../symbols/cim/placements/PlacementPolygonCenter.js";import"../../../symbols/cim/constants.js";import"../../../core/libs/gl-matrix-2/factories/vec2f32.js";import"../../../symbols/support/defaults.js";import"../../../symbols/cim/OverrideHelper.js";import"../../../layers/effects/EffectView.js";import"../../../core/Accessor.js";import"../engine/transitions/FadeTransition.js";import"../../../core/libs/gl-matrix-2/factories/vec4f32.js";import"../../webgl/enums.js";import"../engine/webgl/shaders/BackgroundPrograms.js";import"../../webgl/Program.js";import"../../webgl/checkWebGLError.js";import"../../webgl/VertexAttributeLayouts.js";import"../../webgl/BufferObject.js";import"../engine/webgl/AFeatureTile.js";import"../engine/webgl/DisplayEntity.js";import"../engine/webgl/shaderGraph/techniques/featureTechniqueUtils.js";import"../engine/webgl/cpuMapped/MappedMesh.js";import"../engine/webgl/number.js";import"../engine/webgl/shaders/TileInfoPrograms.js";import"../../webgl/Texture.js";import"../engine/webgl/shaders/BitBlitPrograms.js";import"../../../request.js";import"../../../core/urlUtils.js";import"../../../core/pbf.js";import"../engine/webgl/shaders/StencilPrograms.js";import"../engine/webgl/shaderGraph/techniques/shaders/BlendShader.js";import"../engine/webgl/shaderGraph/techniques/shaders/OpacityShader.js";import"../engine/webgl/shaders/HighlightPrograms.js";import"../../webgl/FramebufferObject.js";import"../engine/webgl/shaderGraph/techniques/shaders/BlitShader.js";import"../engine/webgl/shaderGraph/techniques/shaders/BloomShader.js";import"../engine/webgl/shaderGraph/techniques/shaders/BlurShader.js";import"../engine/webgl/shaderGraph/techniques/shaders/ColorizeShader.js";import"../engine/webgl/shaderGraph/techniques/shaders/DropShadowShader.js";import"../engine/webgl/meshing/SimpleMesh.js";import"../../webgl/Renderbuffer.js";import"../engine/webgl/PooledUint32Array.js";import"../engine/webgl/Profiler.js";import"../engine/webgl/shaderGraph/techniques/TechniqueRegistry.js";import"../engine/webgl/shaderGraph/techniques/animated/attributes.js";import"../engine/webgl/mesh/templates/templateUtils.js";import"../engine/webgl/shaderGraph/techniques/line/LineMeshWriter.js";import"../engine/webgl/shaderGraph/techniques/dotDensity/DotDensityMeshWriter.js";import"../engine/webgl/shaderGraph/techniques/fill/ComplexFillMeshWriter.js";import"../engine/webgl/shaderGraph/techniques/fill/ComplexOutlineFillMeshWriter.js";import"../engine/webgl/shaderGraph/techniques/fill/FillMeshWriter.js";import"../engine/webgl/shaderGraph/techniques/fill/GradientFillMeshWriter.js";import"../engine/webgl/shaderGraph/techniques/fill/OutlineFillMeshWriter.js";import"../engine/webgl/shaderGraph/techniques/fill/PatternFillMeshWriter.js";import"../engine/webgl/shaderGraph/techniques/fill/PatternOutlineFillMeshWriter.js";import"../engine/webgl/shaderGraph/techniques/heatmap/HeatmapMeshWriter.js";import"../../../geometry/support/aaBoundingBox.js";import"../engine/webgl/shaderGraph/techniques/text/TextMeshWriter.js";import"../engine/webgl/shaderGraph/techniques/line/GradientStrokeMeshWriter.js";import"../engine/webgl/shaderGraph/techniques/line/TexturedLineMeshWriter.js";import"../engine/webgl/shaderGraph/techniques/markers/MarkerMeshWriter.js";import"../../../core/sql/UnknownTimeZone.js";import"luxon";import"../../../intl/locale.js";import"../../../layers/support/fieldUtils.js";import"../../../time/constants.js";import"../engine/webgl/animations/instructions.js";import"../engine/webgl/shaderGraph/techniques/pieChart/PieChartMeshWriter.js";import"../../webgl/renderState.js";import"../../3d/webgl-engine/core/shaderModules/glsl.js";import"../../webgl/testSVGPremultipliedAlpha.js";import"../../../chunks/pe.js";import"../engine/webgl/meshing/definitions.js";import"../engine/webgl/shaderGraph/techniques/shaders/VideoScreenShader.js";import"../LabelManager.js";import p from"./graphics/GraphicsView2D.js";import"../../../core/accessorSupport/watch.js";import"../../../core/accessorSupport/tracking/SimpleTrackingTarget.js";import"../../../chunks/earcut.js";import"../../../core/libs/gl-matrix-2/factories/vec3f32.js";import"../../../geometry/support/normalizeUtils.js";import"./support/util.js";import"../navigation/MapViewNavigation.js";import"../../../core/asyncUtils.js";import"../../../core/support/UpdatingHandles.js";import"../engine/webgl/shaderGraph/techniques/shaders/MagnifierShader.js";import"../../../core/units.js";import"../../../geometry/ellipsoidUtils.js";import"../../../geometry/SpatialReference.js";import"../../../geometry/operators/support/GeographicTransformation.js";import"../../../geometry/projection/projectors.js";import"../engine/webgl/shaderGraph/techniques/shaders/GridShader.js";import"../../../geometry/support/geodesicConstants.js";import"../../../geometry/support/Ellipsoid.js";import{BitmapTileLayerView2D as n}from"./BitmapTileLayerView2D.js";import{LayerView2DMixin as m}from"./LayerView2D.js";import c from"./graphics/HighlightGraphicContainer.js";import{createBlankImage as g,resampleImage as f}from"./support/imageUtils.js";import u from"../tiling/TileInfoView.js";import d from"../tiling/TileKey.js";import j from"../tiling/TileQueue.js";import y from"../tiling/TileStrategy.js";import w from"../../layers/LayerView.js";import{RefreshableLayerView as b}from"../../layers/RefreshableLayerView.js";import{getHighlightGraphics as _}from"../../layers/support/highlightUtils.js";import{isMapServiceLayerView as G,MapServiceLayerViewHelper as T}from"../../layers/support/MapServiceLayerViewHelper.js";import{createQueryGeometry as q}from"../../support/drapedUtils.js";import{getHighlightName as V}from"../../support/highlightOptionsUtils.js";import{TaskPriority as S}from"../../support/Scheduler.js";const P=[0,0];let I=class extends(b(n(m(w)))){constructor(){super(...arguments),this._fetchQueue=null,this._highlightGraphics=new a,this._highlightView=null,this._popupHighlightHelper=null,this._tileStrategy=null,this.layer=null}get resampling(){return!("resampling"in this.layer)||!1!==this.layer.resampling}get tilemapCache(){return"tilemapCache"in this.layer?this.layer.tilemapCache:null}update(e){this._fetchQueue.pause(),this._fetchQueue.state=e.state,this._tileStrategy.update(e),this._fetchQueue.resume(),this._highlightView?.processUpdate(e)}attach(){const e="tileServers"in this.layer?this.layer.tileServers:null,i=this.tilemapCache;if(this._tileInfoView=new u(this.layer.tileInfo,this.layer.fullExtent,i?.effectiveMinLOD,i?.effectiveMaxLOD),this._fetchQueue=new j({tileInfoView:this._tileInfoView,concurrency:e&&10*e.length||10,process:(e,i)=>this.fetchTile(e,i),scheduler:this.scheduler,priority:S.MAPVIEW_FETCH_QUEUE}),this._tileStrategy=new y({cachePolicy:"keep",resampling:this.resampling,acquireTile:e=>this.acquireTile(e),releaseTile:e=>this.releaseTile(e),tileInfoView:this._tileInfoView}),G(this,this.layer)){const e=this._highlightView=new p({view:this.view,graphics:this._highlightGraphics,requestUpdateCallback:()=>this.requestUpdate(),container:new c(this.view.featuresTilingScheme),defaultPointSymbolEnabled:!1});this.container.addChild(this._highlightView.container),this._popupHighlightHelper=new T({createFetchPopupFeaturesQueryGeometry:(e,i)=>q(e,i,this.view),highlightGraphics:this._highlightGraphics,highlightGraphicUpdated:({graphic:i,property:t})=>e.graphicUpdateHandler({graphic:i,property:t}),layerView:this,updatingHandles:this._updatingHandles})}this.requestUpdate(),this.addAttachHandles(this._updatingHandles.add(()=>this.resampling,()=>{this.doRefresh()})),super.attach()}detach(){super.detach(),this._tileStrategy.destroy(),this._fetchQueue.clear(),this.container.removeAllChildren(),this._popupHighlightHelper?.destroy(),this._highlightView?.destroy(),this._fetchQueue=this._tileStrategy=this._tileInfoView=this._popupHighlightHelper=null}async fetchPopupFeaturesAtLocation(e,i){return this._popupHighlightHelper?this._popupHighlightHelper.fetchPopupFeaturesAtLocation(e,i):[]}highlight(e,t){const s=_(e);if(0===s.length)return i();const r=V(t);return this._addHighlightGraphics(s,r),i(()=>!this.destroyed&&this._removeHighlightGraphics(s,r))}_processHighlight(){const e=this._getHighlights();this._highlightView?.setHighlight(e)}_addHighlightGraphics(e,i){this._highlightGraphics.addMany(e),this._addHighlights(e.map(e=>e.uid),i)}_removeHighlightGraphics(e,i){this._highlightGraphics.removeMany(e),this._removeHighlights(e.map(e=>e.uid),i)}viewChange(){this.requestUpdate()}moveEnd(){this.requestUpdate()}supportsSpatialReference(e){return h(this.layer.tileInfo?.spatialReference,e)}async doRefresh(){if(this.attached){if(this.suspended)return this._tileStrategy.clear(),void this.requestUpdate();this._fetchQueue.reset(),this._tileStrategy.refresh(e=>this._updatingHandles.addPromise(this._enqueueTileFetch(e)))}}acquireTile(e){const i=this._bitmapView.createTile(e),t=i.bitmap;return[t.x,t.y]=this._tileInfoView.getTileCoords(P,i.key),t.resolution=this._tileInfoView.getTileResolution(i.key),[t.width,t.height]=this._tileInfoView.tileInfo.size,this._updatingHandles.addPromise(this._enqueueTileFetch(i)),this._bitmapView.addChild(i),this.requestUpdate(),i}releaseTile(e){this._fetchQueue.abort(e.key.id),this._bitmapView.removeChild(e),e.once("detach",()=>e.destroy()),this.requestUpdate()}async fetchTile(e,i={}){return this.tilemapCache?this._fetchTileWithTilemapCache(e,i):this._fetchTileWithoutTilemapCache(e,i)}async _fetchTileWithoutTilemapCache(e,i={}){const{signal:t,resamplingLevel:r=0}=i;try{return await this._fetchImage(e,t)}catch(o){if(s(o))throw o;if(!this.resampling)return g(this._tileInfoView.tileInfo.size);if(r<3){const t=this._tileInfoView.getTileParentId(e.id);if(t){const s=new d(t),o=await this._fetchTileWithoutTilemapCache(s,{...i,resamplingLevel:r+1});return f(this._tileInfoView,o,s,e)}}return g(this._tileInfoView.tileInfo.size)}}async _fetchTileWithTilemapCache(e,i={}){const t=this.tilemapCache,{signal:o,resamplingLevel:l=0}=i,h=new d(0,0,0,0);let a,p=null;try{if(p=await t.fetchAvailabilityUpsample(e.level,e.row,e.col,h,{signal:o}),!this.resampling&&h.level!==e.level)return await r(i),g(this._tileInfoView.tileInfo.size);a=await this._fetchImage(h,o)}catch(n){if(s(n))throw n;if(this.resampling&&"unknown"===p&&l<3){const t=this._tileInfoView.getTileParentId(e.id);if(t){h.set(t);try{a=await this._fetchTileWithTilemapCache(h,{...i,resamplingLevel:l+1})}catch{}}}}return a?this.resampling?f(this._tileInfoView,a,h,e):a:g(this._tileInfoView.tileInfo.size)}async _enqueueTileFetch(e){if(!this._fetchQueue.has(e.key.id)){try{const i=await this._fetchQueue.push(e.key);e.bitmap.source=i,e.bitmap.width=this._tileInfoView.tileInfo.size[0],e.bitmap.height=this._tileInfoView.tileInfo.size[1],e.once("attach",()=>this.requestUpdate())}catch(i){s(i)||t.getLogger(this).error(i)}this.requestUpdate()}}async _fetchImage(e,i){return this.layer.fetchImageBitmapTile(e.level,e.row,e.col,{signal:i})}};e([o()],I.prototype,"resampling",null),e([o()],I.prototype,"tilemapCache",null),I=e([l("esri.views.2d.layers.TileLayerView2D")],I);const v=I;export{v as default};
5
+ import{__decorate as e}from"tslib";import{makeHandle as i}from"../../../core/handleUtils.js";import t from"../../../core/Logger.js";import{isAbortError as s,waitTick as r}from"../../../core/promiseUtils.js";import{property as o,subclass as l}from"../../../core/accessorSupport/decorators.js";import{equals as h}from"../../../geometry/support/spatialReferenceUtils.js";import{GraphicsCollection as a}from"../../../support/GraphicsCollection.js";import"../../../core/Error.js";import"../../../core/has.js";import"../../../core/scheduling.js";import"../../../core/RandomLCG.js";import"../../../Color.js";import"../../../core/mathUtils.js";import"../../../config.js";import"../../../symbols/cim/defaultCIMValues.js";import"../../../core/floatRGBA.js";import"../../../geometry/Extent.js";import"../../../geometry/Geometry.js";import"../../../geometry/Multipoint.js";import"../../../geometry/Point.js";import"../../../geometry/Polygon.js";import"../../../geometry/Polyline.js";import"../../../symbols/Font.js";import"../../../core/ObjectPool.js";import"../../../symbols/cim/effects/EffectAddControlPoints.js";import"../../../symbols/cim/effects/EffectArrow.js";import"../../../symbols/cim/effects/EffectBuffer.js";import"../../../symbols/cim/effects/EffectControlMeasureLine.js";import"../../../symbols/cim/effects/EffectCut.js";import"../../../symbols/cim/effects/EffectDashes.js";import"../../../symbols/cim/effects/EffectDonut.js";import"../../../symbols/cim/effects/EffectEnclosingPolygon.js";import"../../../symbols/cim/effects/EffectJog.js";import"../../../symbols/cim/effects/EffectMove.js";import"../../../symbols/cim/effects/EffectOffset.js";import"../../../symbols/cim/effects/EffectRadial.js";import"../../../symbols/cim/effects/EffectReverse.js";import"../../../symbols/cim/effects/EffectRotate.js";import"../../../symbols/cim/effects/EffectScale.js";import"../../../symbols/cim/effects/EffectSuppress.js";import"../../../symbols/cim/effects/EffectTaperedPolygon.js";import"../../../symbols/cim/effects/EffectWave.js";import"../../../symbols/cim/placements/PlacementAlongLineSameSize.js";import"../../../symbols/cim/placements/PlacementAtExtremities.js";import"../../../symbols/cim/placements/PlacementAtMeasuredUnits.js";import"../../../symbols/cim/placements/PlacementAtRatioPositions.js";import"../../../symbols/cim/placements/PlacementInsidePolygon.js";import"../../../symbols/cim/placements/PlacementOnLine.js";import"../../../symbols/cim/placements/PlacementOnVertices.js";import"../../../symbols/cim/placements/PlacementPolygonCenter.js";import"../../../symbols/cim/constants.js";import"../../../core/libs/gl-matrix-2/factories/vec2f32.js";import"../../../symbols/support/defaults.js";import"../../../symbols/cim/OverrideHelper.js";import"../../../layers/effects/EffectView.js";import"../../../core/Accessor.js";import"../engine/transitions/FadeTransition.js";import"../../../core/libs/gl-matrix-2/factories/vec4f32.js";import"../../webgl/enums.js";import"../engine/webgl/shaders/BackgroundPrograms.js";import"../../webgl/Program.js";import"../../webgl/Util.js";import"../../webgl/VertexAttributeLayouts.js";import"../../webgl/BufferObject.js";import"../engine/webgl/AFeatureTile.js";import"../engine/webgl/DisplayEntity.js";import"../engine/webgl/shaderGraph/techniques/featureTechniqueUtils.js";import"../engine/webgl/cpuMapped/MappedMesh.js";import"../engine/webgl/number.js";import"../engine/webgl/shaders/TileInfoPrograms.js";import"../../webgl/Texture.js";import"../engine/webgl/shaders/BitBlitPrograms.js";import"../../../request.js";import"../../../core/urlUtils.js";import"../../../core/pbf.js";import"../engine/webgl/shaders/StencilPrograms.js";import"../engine/webgl/shaderGraph/techniques/shaders/BlendShader.js";import"../engine/webgl/shaderGraph/techniques/shaders/OpacityShader.js";import"../engine/webgl/shaders/HighlightPrograms.js";import"../../webgl/FramebufferObject.js";import"../engine/webgl/shaderGraph/techniques/shaders/BlitShader.js";import"../engine/webgl/shaderGraph/techniques/shaders/BloomShader.js";import"../engine/webgl/shaderGraph/techniques/shaders/BlurShader.js";import"../engine/webgl/shaderGraph/techniques/shaders/ColorizeShader.js";import"../engine/webgl/shaderGraph/techniques/shaders/DropShadowShader.js";import"../engine/webgl/meshing/SimpleMesh.js";import"../../webgl/Renderbuffer.js";import"../engine/webgl/PooledUint32Array.js";import"../engine/webgl/Profiler.js";import"../engine/webgl/shaderGraph/techniques/TechniqueRegistry.js";import"../engine/webgl/shaderGraph/techniques/animated/attributes.js";import"../engine/webgl/mesh/templates/templateUtils.js";import"../engine/webgl/shaderGraph/techniques/line/LineMeshWriter.js";import"../engine/webgl/shaderGraph/techniques/dotDensity/DotDensityMeshWriter.js";import"../engine/webgl/shaderGraph/techniques/fill/ComplexFillMeshWriter.js";import"../engine/webgl/shaderGraph/techniques/fill/ComplexOutlineFillMeshWriter.js";import"../engine/webgl/shaderGraph/techniques/fill/FillMeshWriter.js";import"../engine/webgl/shaderGraph/techniques/fill/GradientFillMeshWriter.js";import"../engine/webgl/shaderGraph/techniques/fill/OutlineFillMeshWriter.js";import"../engine/webgl/shaderGraph/techniques/fill/PatternFillMeshWriter.js";import"../engine/webgl/shaderGraph/techniques/fill/PatternOutlineFillMeshWriter.js";import"../engine/webgl/shaderGraph/techniques/heatmap/HeatmapMeshWriter.js";import"../../../geometry/support/aaBoundingBox.js";import"../engine/webgl/shaderGraph/techniques/text/TextMeshWriter.js";import"../engine/webgl/shaderGraph/techniques/line/GradientStrokeMeshWriter.js";import"../engine/webgl/shaderGraph/techniques/line/TexturedLineMeshWriter.js";import"../engine/webgl/shaderGraph/techniques/markers/MarkerMeshWriter.js";import"../../../core/sql/UnknownTimeZone.js";import"luxon";import"../../../intl/locale.js";import"../../../layers/support/fieldUtils.js";import"../../../time/constants.js";import"../engine/webgl/animations/instructions.js";import"../engine/webgl/shaderGraph/techniques/pieChart/PieChartMeshWriter.js";import"../../webgl/checkWebGLError.js";import"../../webgl/renderState.js";import"../../3d/webgl-engine/core/shaderModules/glsl.js";import"../../webgl/testSVGPremultipliedAlpha.js";import"../../../chunks/pe.js";import"../engine/webgl/meshing/definitions.js";import"../engine/webgl/shaderGraph/techniques/shaders/VideoScreenShader.js";import"../LabelManager.js";import p from"./graphics/GraphicsView2D.js";import"../../../core/accessorSupport/watch.js";import"../../../core/accessorSupport/tracking/SimpleTrackingTarget.js";import"../../../chunks/earcut.js";import"../../../core/libs/gl-matrix-2/factories/vec3f32.js";import"../../../geometry/support/normalizeUtils.js";import"./support/util.js";import"../navigation/MapViewNavigation.js";import"../../../core/asyncUtils.js";import"../../../core/support/UpdatingHandles.js";import"../engine/webgl/shaderGraph/techniques/shaders/MagnifierShader.js";import"../../../core/units.js";import"../../../geometry/ellipsoidUtils.js";import"../../../geometry/SpatialReference.js";import"../../../geometry/operators/support/GeographicTransformation.js";import"../../../geometry/projection/projectors.js";import"../engine/webgl/shaderGraph/techniques/shaders/GridShader.js";import"../../../geometry/support/geodesicConstants.js";import"../../../geometry/support/Ellipsoid.js";import{BitmapTileLayerView2D as n}from"./BitmapTileLayerView2D.js";import{LayerView2DMixin as m}from"./LayerView2D.js";import c from"./graphics/HighlightGraphicContainer.js";import{createBlankImage as g,resampleImage as f}from"./support/imageUtils.js";import u from"../tiling/TileInfoView.js";import d from"../tiling/TileKey.js";import j from"../tiling/TileQueue.js";import y from"../tiling/TileStrategy.js";import w from"../../layers/LayerView.js";import{RefreshableLayerView as b}from"../../layers/RefreshableLayerView.js";import{getHighlightGraphics as _}from"../../layers/support/highlightUtils.js";import{isMapServiceLayerView as G,MapServiceLayerViewHelper as T}from"../../layers/support/MapServiceLayerViewHelper.js";import{createQueryGeometry as q}from"../../support/drapedUtils.js";import{getHighlightName as V}from"../../support/highlightOptionsUtils.js";import{TaskPriority as S}from"../../support/Scheduler.js";const P=[0,0];let I=class extends(b(n(m(w)))){constructor(){super(...arguments),this._fetchQueue=null,this._highlightGraphics=new a,this._highlightView=null,this._popupHighlightHelper=null,this._tileStrategy=null,this.layer=null}get resampling(){return!("resampling"in this.layer)||!1!==this.layer.resampling}get tilemapCache(){return"tilemapCache"in this.layer?this.layer.tilemapCache:null}update(e){this._fetchQueue.pause(),this._fetchQueue.state=e.state,this._tileStrategy.update(e),this._fetchQueue.resume(),this._highlightView?.processUpdate(e)}attach(){const e="tileServers"in this.layer?this.layer.tileServers:null,i=this.tilemapCache;if(this._tileInfoView=new u(this.layer.tileInfo,this.layer.fullExtent,i?.effectiveMinLOD,i?.effectiveMaxLOD),this._fetchQueue=new j({tileInfoView:this._tileInfoView,concurrency:e&&10*e.length||10,process:(e,i)=>this.fetchTile(e,i),scheduler:this.scheduler,priority:S.MAPVIEW_FETCH_QUEUE}),this._tileStrategy=new y({cachePolicy:"keep",resampling:this.resampling,acquireTile:e=>this.acquireTile(e),releaseTile:e=>this.releaseTile(e),tileInfoView:this._tileInfoView}),G(this,this.layer)){const e=this._highlightView=new p({view:this.view,graphics:this._highlightGraphics,requestUpdateCallback:()=>this.requestUpdate(),container:new c(this.view.featuresTilingScheme),defaultPointSymbolEnabled:!1});this.container.addChild(this._highlightView.container),this._popupHighlightHelper=new T({createFetchPopupFeaturesQueryGeometry:(e,i)=>q(e,i,this.view),highlightGraphics:this._highlightGraphics,highlightGraphicUpdated:({graphic:i,property:t})=>e.graphicUpdateHandler({graphic:i,property:t}),layerView:this,updatingHandles:this._updatingHandles})}this.requestUpdate(),this.addAttachHandles(this._updatingHandles.add(()=>this.resampling,()=>{this.doRefresh()})),super.attach()}detach(){super.detach(),this._tileStrategy.destroy(),this._fetchQueue.clear(),this.container.removeAllChildren(),this._popupHighlightHelper?.destroy(),this._highlightView?.destroy(),this._fetchQueue=this._tileStrategy=this._tileInfoView=this._popupHighlightHelper=null}async fetchPopupFeaturesAtLocation(e,i){return this._popupHighlightHelper?this._popupHighlightHelper.fetchPopupFeaturesAtLocation(e,i):[]}highlight(e,t){const s=_(e);if(0===s.length)return i();const r=V(t);return this._addHighlightGraphics(s,r),i(()=>!this.destroyed&&this._removeHighlightGraphics(s,r))}_processHighlight(){const e=this._getHighlights();this._highlightView?.setHighlight(e)}_addHighlightGraphics(e,i){this._highlightGraphics.addMany(e),this._addHighlights(e.map(e=>e.uid),i)}_removeHighlightGraphics(e,i){this._highlightGraphics.removeMany(e),this._removeHighlights(e.map(e=>e.uid),i)}viewChange(){this.requestUpdate()}moveEnd(){this.requestUpdate()}supportsSpatialReference(e){return h(this.layer.tileInfo?.spatialReference,e)}async doRefresh(){if(this.attached){if(this.suspended)return this._tileStrategy.clear(),void this.requestUpdate();this._fetchQueue.reset(),this._tileStrategy.refresh(e=>this._updatingHandles.addPromise(this._enqueueTileFetch(e)))}}acquireTile(e){const i=this._bitmapView.createTile(e),t=i.bitmap;return[t.x,t.y]=this._tileInfoView.getTileCoords(P,i.key),t.resolution=this._tileInfoView.getTileResolution(i.key),[t.width,t.height]=this._tileInfoView.tileInfo.size,this._updatingHandles.addPromise(this._enqueueTileFetch(i)),this._bitmapView.addChild(i),this.requestUpdate(),i}releaseTile(e){this._fetchQueue.abort(e.key.id),this._bitmapView.removeChild(e),e.once("detach",()=>e.destroy()),this.requestUpdate()}async fetchTile(e,i={}){return this.tilemapCache?this._fetchTileWithTilemapCache(e,i):this._fetchTileWithoutTilemapCache(e,i)}async _fetchTileWithoutTilemapCache(e,i={}){const{signal:t,resamplingLevel:r=0}=i;try{return await this._fetchImage(e,t)}catch(o){if(s(o))throw o;if(!this.resampling)return g(this._tileInfoView.tileInfo.size);if(r<3){const t=this._tileInfoView.getTileParentId(e.id);if(t){const s=new d(t),o=await this._fetchTileWithoutTilemapCache(s,{...i,resamplingLevel:r+1});return f(this._tileInfoView,o,s,e)}}return g(this._tileInfoView.tileInfo.size)}}async _fetchTileWithTilemapCache(e,i={}){const t=this.tilemapCache,{signal:o,resamplingLevel:l=0}=i,h=new d(0,0,0,0);let a,p=null;try{if(p=await t.fetchAvailabilityUpsample(e.level,e.row,e.col,h,{signal:o}),!this.resampling&&h.level!==e.level)return await r(i),g(this._tileInfoView.tileInfo.size);a=await this._fetchImage(h,o)}catch(n){if(s(n))throw n;if(this.resampling&&"unknown"===p&&l<3){const t=this._tileInfoView.getTileParentId(e.id);if(t){h.set(t);try{a=await this._fetchTileWithTilemapCache(h,{...i,resamplingLevel:l+1})}catch{}}}}return a?this.resampling?f(this._tileInfoView,a,h,e):a:g(this._tileInfoView.tileInfo.size)}async _enqueueTileFetch(e){if(!this._fetchQueue.has(e.key.id)){try{const i=await this._fetchQueue.push(e.key);e.bitmap.source=i,e.bitmap.width=this._tileInfoView.tileInfo.size[0],e.bitmap.height=this._tileInfoView.tileInfo.size[1],e.once("attach",()=>this.requestUpdate())}catch(i){s(i)||t.getLogger(this).error(i)}this.requestUpdate()}}async _fetchImage(e,i){return this.layer.fetchImageBitmapTile(e.level,e.row,e.col,{signal:i})}};e([o()],I.prototype,"resampling",null),e([o()],I.prototype,"tilemapCache",null),I=e([l("esri.views.2d.layers.TileLayerView2D")],I);const v=I;export{v as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- function e(e={}){return{color:[1,1,1],opacity:1,alphaMode:"OPAQUE",alphaCutoff:.5,doubleSided:!1,castShadows:!0,receiveShadows:!0,receiveAmbientOcclusion:!0,colorTexture:null,normalTexture:null,occlusionTexture:null,emissiveTexture:null,metallicRoughnessTexture:null,colorTextureTransform:null,normalTextureTransform:null,occlusionTextureTransform:null,emissiveTextureTransform:null,metallicRoughnessTextureTransform:null,emissiveFactor:[0,0,0],metallicFactor:1,roughnessFactor:1,colorMixMode:"multiply",...e}}function l(e,l={}){return{data:e,parameters:{wrap:{s:10497,t:10497,...l.wrap},noUnpackFlip:!0,mipmap:!1,...l}}}export{e as makeMaterialParameters,l as makeTextureSource};
5
+ function e(e={}){return{color:[1,1,1],opacity:1,alphaMode:"OPAQUE",alphaCutoff:.5,doubleSided:!1,castShadows:!0,receiveShadows:!0,receiveAmbientOcclusion:!0,colorTexture:null,normalTexture:null,occlusionTexture:null,emissiveTexture:null,emissiveStrengthKHR:null,metallicRoughnessTexture:null,colorTextureTransform:null,normalTextureTransform:null,occlusionTextureTransform:null,emissiveTextureTransform:null,metallicRoughnessTextureTransform:null,emissiveFactor:[0,0,0],metallicFactor:1,roughnessFactor:1,colorMixMode:"multiply",...e}}function l(e,l={}){return{data:e,parameters:{wrap:{s:10497,t:10497,...l.wrap},noUnpackFlip:!0,mipmap:!1,...l}}}export{e as makeMaterialParameters,l as makeTextureSource};
@@ -2,4 +2,4 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../../../core/Error.js";import t from"../../../../core/Logger.js";import{getOrCreateMapValue as r}from"../../../../core/MapUtils.js";import{getKey as o}from"../../../../core/object.js";import{allSettledValues as n}from"../../../../core/promiseUtils.js";import{isDataProtocol as s,dataComponents as a,dataToArrayBuffer as i,makeAbsolute as u}from"../../../../core/urlUtils.js";import{Version as f}from"../../../../core/Version.js";import{fromXRotation as c,multiply as d,translate as l,rotate as p,scale as m}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as h,clone as b}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{getAxisAngle as w}from"../../../../core/libs/gl-matrix-2/math/quat.js";import{create as y}from"../../../../core/libs/gl-matrix-2/factories/quatf64.js";import{BufferViewVec2f as g,BufferViewVec2u32 as T,BufferViewVec2u16 as _,BufferViewVec2i16 as x,BufferViewVec2u8 as O,BufferViewVec2i8 as N,BufferViewUint32 as S,BufferViewUint16 as C,BufferViewUint8 as A,BufferViewVec3f as L,BufferViewVec4f as E,BufferViewVec4u8 as R,BufferViewVec4u16 as I,BufferViewVec3u8 as v,BufferViewVec3u16 as D}from"../../../../geometry/support/buffer/BufferView.js";import{m as B}from"../../../../chunks/scalar.js";import"../../../../core/has.js";import{getDracoMeshDecoder as U}from"../../../../libs/dracoMeshDecoder/dracoMeshDecoder.js";import{BinaryStreamReader as M}from"./BinaryStreamReader.js";import{material as j,textureSampler as G}from"./fillDefaults.js";import{splitURI as F}from"./pathUtils.js";import{jsonFromBinaryData as H,EncodedMeshTexture as P,imageFromBinaryData as V,isEncodedMeshTexture as z}from"./resourceUtils.js";import{DataType as K}from"../../../webgl/enums.js";const k={MAGIC:1179937895,CHUNK_TYPE_JSON:1313821514,CHUNK_TYPE_BIN:5130562};class Y{constructor(t,r,o,n){if(this._context=t,this.uri=r,this.json=o,this._glbBuffer=n,this._bufferLoaders=new Map,this._textureLoaders=new Map,this._dracoBuffersSize=0,this._textureCache=new Map,this._materialCache=new Map,this._nodeParentMap=new Map,this._nodeTransformCache=new Map,this._supportedExtensions=["KHR_texture_basisu","KHR_texture_transform","KHR_draco_mesh_compression"],this._baseUri=F(this.uri).dirPart,this._checkVersionSupported(),this._checkRequiredExtensionsSupported(),null==o.scenes)throw new e("gltf-loader-unsupported-feature","Scenes must be defined.");if(null==o.meshes)throw new e("gltf-loader-unsupported-feature","Meshes must be defined");if(null==o.nodes)throw new e("gltf-loader-unsupported-feature","Nodes must be defined.");this._computeNodeParents()}static async load(t,r,o){if(s(r)){const e=a(r);if(e&&"model/gltf-binary"!==e.mediaType)try{const o=JSON.parse(e.isBase64?atob(e.data):e.data);return new Y(t,r,o)}catch{}const o=i(r);if(Y._isGLBData(o))return this._fromGLBData(t,r,o)}if(te.test(r)||"gltf"===o?.expectedType){const e=await t.loadJSON(r,o);return new Y(t,r,e)}const n=await t.loadBinary(r,o);if(Y._isGLBData(n))return this._fromGLBData(t,r,n);if(re.test(r)||"glb"===o?.expectedType)throw new e("gltf-loader-invalid-glb","This is not a valid glb file.");const u=await t.loadJSON(r,o);return new Y(t,r,u)}static _isGLBData(e){if(null==e)return!1;const t=new M(e);return t.remainingBytes()>=4&&t.readUint32()===k.MAGIC}static async _fromGLBData(e,t,r){const o=await Y._parseGLBData(r);return new Y(e,t,o.json,o.binaryData)}static async _parseGLBData(r){const o=new M(r);if(o.remainingBytes()<12)throw new e("gltf-loader-error","glb binary data is insufficiently large.");const n=o.readUint32(),s=o.readUint32(),a=o.readUint32();if(n!==k.MAGIC)throw new e("gltf-loader-error","Magic first 4 bytes do not fit to expected glb value.");if(r.byteLength<a)throw new e("gltf-loader-error","glb binary data is smaller than header specifies.");if(2!==s)throw new e("gltf-loader-unsupported-feature","An unsupported glb container version was detected. Only version 2 is supported.");let i,u,f=0;for(;o.remainingBytes()>=8;){const r=o.readUint32(),n=o.readUint32();if(0===f){if(n!==k.CHUNK_TYPE_JSON)throw new e("gltf-loader-error","First glb chunk must be JSON.");if(r<0)throw new e("gltf-loader-error","No JSON data found.");i=await H(o.readUint8Array(r))}else if(1===f){if(n!==k.CHUNK_TYPE_BIN)throw new e("gltf-loader-unsupported-feature","Second glb chunk expected to be BIN.");u=o.readUint8Array(r)}else t.getLogger("esri.views.3d.glTF").warn("[Unsupported Feature] More than 2 glb chunks detected. Skipping.");f+=1}if(!i)throw new e("gltf-loader-error","No glb JSON chunk detected.");return{json:i,binaryData:u}}async getBuffer(t,r){const o=this.json.buffers[t];if(null==o.uri){if(null==this._glbBuffer)throw new e("gltf-loader-error","glb buffer not present");return this._glbBuffer}const n=await this._getBufferLoader(t,r);if(n.byteLength!==o.byteLength)throw new e("gltf-loader-error","Buffer byte lengths should match.");return n}async _getBufferLoader(e,t){const r=this._bufferLoaders.get(e);if(r)return r;const o=this.json.buffers[e].uri,n=this._context.loadBinary(this._resolveUri(o),t).then(e=>new Uint8Array(e));return this._bufferLoaders.set(e,n),n}_validateAccessor(t){if(!this.json.accessors)throw new e("gltf-loader-unsupported-feature","Accessors missing.");const r=this.json.accessors[t];if(r.type in["MAT2","MAT3","MAT4"])throw new e("gltf-loader-unsupported-feature",`AttributeType ${r.type} is not supported`);return r}_getComponentInfo(e,t){const r=$[e.type],o=t?.componentType||e.componentType,n=W[o];return{componentType:o,componentCount:r,componentByteSize:n,denseByteStride:r*n}}getDracoAccessor(e,t){const r=this._validateAccessor(e),o=t.accessorInfos.get(e),{componentType:n,componentCount:s,componentByteSize:a,denseByteStride:i}=this._getComponentInfo(r,o);return{raw:t.data.buffer,byteStride:i,byteOffset:t.data.byteOffset+(o?.byteOffset||0),entryCount:o?.count??r.count,isDenselyPacked:!0,componentCount:s,componentByteSize:a,componentType:n,min:r.min,max:r.max,normalized:!!r.normalized}}async getAccessor(t,r){const o=this._validateAccessor(t);if(null==o?.bufferView)throw new e("gltf-loader-unsupported-feature","Some accessor does not specify a bufferView.");const{componentCount:n,componentByteSize:s,denseByteStride:a}=this._getComponentInfo(o),i=this.json.bufferViews[o.bufferView],u=await this.getBuffer(i.buffer,r),f=i.byteStride||a;return{raw:u.buffer,byteStride:f,byteOffset:u.byteOffset+(i.byteOffset||0)+(o.byteOffset||0),entryCount:o.count,isDenselyPacked:f===a,componentCount:n,componentByteSize:s,componentType:o.componentType,min:o.min,max:o.max,normalized:!!o.normalized}}async getIndexData(e,t,r){if(null==e.indices)return;const o=e.indices,n=r?this.getDracoAccessor(o,r):await this.getAccessor(o,t);if(n.isDenselyPacked)switch(n.componentType){case K.UNSIGNED_BYTE:return new Uint8Array(n.raw,n.byteOffset,n.entryCount);case K.UNSIGNED_SHORT:return new Uint16Array(n.raw,n.byteOffset,n.entryCount);case K.UNSIGNED_INT:return new Uint32Array(n.raw,n.byteOffset,n.entryCount)}else switch(n.componentType){case K.UNSIGNED_BYTE:return B(Z(A,n));case K.UNSIGNED_SHORT:return B(Z(C,n));case K.UNSIGNED_INT:return B(Z(S,n))}}async getPositionData(t,r,n){if(null==t.attributes.POSITION)throw new e("gltf-loader-unsupported-feature","No POSITION vertex data found.");const s=t.attributes.POSITION,a=n?this.getDracoAccessor(s,n):await this.getAccessor(s,r);if(a.componentType!==K.FLOAT)throw new e("gltf-loader-unsupported-feature","Expected type FLOAT for POSITION vertex attribute, but found "+o(K,a.componentType));if(3!==a.componentCount)throw new e("gltf-loader-unsupported-feature","POSITION vertex attribute must have 3 components, but found "+a.componentCount.toFixed());return Z(L,a)}async getNormalData(t,r,n){if(null==t.attributes.NORMAL)throw new e("gltf-loader-error","No NORMAL vertex data found.");const s=t.attributes.NORMAL,a=n?this.getDracoAccessor(s,n):await this.getAccessor(s,r);if(a.componentType!==K.FLOAT)throw new e("gltf-loader-unsupported-feature","Expected type FLOAT for NORMAL vertex attribute, but found "+o(K,a.componentType));if(3!==a.componentCount)throw new e("gltf-loader-unsupported-feature","NORMAL vertex attribute must have 3 components, but found "+a.componentCount.toFixed());return Z(L,a)}async getTangentData(t,r,n){if(null==t.attributes.TANGENT)throw new e("gltf-loader-error","No TANGENT vertex data found.");const s=t.attributes.TANGENT,a=n?this.getDracoAccessor(s,n):await this.getAccessor(s,r);if(a.componentType!==K.FLOAT)throw new e("gltf-loader-unsupported-feature","Expected type FLOAT for TANGENT vertex attribute, but found "+o(K,a.componentType));if(4!==a.componentCount)throw new e("gltf-loader-unsupported-feature","TANGENT vertex attribute must have 4 components, but found "+a.componentCount.toFixed());return Z(E,a)}async getTextureCoordinates(t,r,o){if(null==t.attributes.TEXCOORD_0)throw new e("gltf-loader-error","No TEXCOORD_0 vertex data found.");const n=t.attributes.TEXCOORD_0,s=o?this.getDracoAccessor(n,o):await this.getAccessor(n,r);if(2!==s.componentCount)throw new e("gltf-loader-unsupported-feature","TEXCOORD_0 vertex attribute must have 2 components, but found "+s.componentCount.toFixed());if(s.componentType===K.FLOAT)return Z(g,s);if(!s.normalized)throw new e("gltf-loader-unsupported-feature","Integer component types are only supported for a normalized accessor for TEXCOORD_0.");return Q(s)}async getVertexColors(t,r,n){if(null==t.attributes.COLOR_0)throw new e("gltf-loader-error","No COLOR_0 vertex data found.");const s=t.attributes.COLOR_0,a=n?this.getDracoAccessor(s,n):await this.getAccessor(s,r);if(4!==a.componentCount&&3!==a.componentCount)throw new e("gltf-loader-unsupported-feature","COLOR_0 attribute must have 3 or 4 components, but found "+a.componentCount.toFixed());if(4===a.componentCount){if(a.componentType===K.FLOAT)return Z(E,a);if(a.componentType===K.UNSIGNED_BYTE)return Z(R,a);if(a.componentType===K.UNSIGNED_SHORT)return Z(I,a)}else if(3===a.componentCount){if(a.componentType===K.FLOAT)return Z(L,a);if(a.componentType===K.UNSIGNED_BYTE)return Z(v,a);if(a.componentType===K.UNSIGNED_SHORT)return Z(D,a)}throw new e("gltf-loader-unsupported-feature","Unsupported component type for COLOR_0 attribute: "+o(K,a.componentType))}hasPositions(e){return void 0!==e.attributes.POSITION}hasNormals(e){return void 0!==e.attributes.NORMAL}hasVertexColors(e){return void 0!==e.attributes.COLOR_0}hasTextureCoordinates(e){return void 0!==e.attributes.TEXCOORD_0}hasTangents(e){return void 0!==e.attributes.TANGENT}async getMaterial(e,t,r){let o=e.material?this._materialCache.get(e.material):void 0;if(!o){const n=null!=e.material?j(this.json.materials[e.material]):j(),s=n.pbrMetallicRoughness,a=this.hasVertexColors(e),i=this.getTexture(s.baseColorTexture,t),u=this.getTexture(n.normalTexture,t),f=r?this.getTexture(n.occlusionTexture,t):void 0,c=r?this.getTexture(n.emissiveTexture,t):void 0,d=r?this.getTexture(s.metallicRoughnessTexture,t):void 0,l=null!=e.material?e.material:-1;o={alphaMode:n.alphaMode,alphaCutoff:n.alphaCutoff,color:s.baseColorFactor,doubleSided:!!n.doubleSided,colorTexture:await i,normalTexture:await u,name:n.name,id:l,occlusionTexture:await f,emissiveTexture:await c,emissiveFactor:n.emissiveFactor,metallicFactor:s.metallicFactor,roughnessFactor:s.roughnessFactor,metallicRoughnessTexture:await d,hasVertexColors:a,ESRI_externalColorMixMode:n.extras.ESRI_externalColorMixMode,colorTextureTransform:s?.baseColorTexture?.extensions?.KHR_texture_transform,normalTextureTransform:n.normalTexture?.extensions?.KHR_texture_transform,occlusionTextureTransform:n.occlusionTexture?.extensions?.KHR_texture_transform,emissiveTextureTransform:n.emissiveTexture?.extensions?.KHR_texture_transform,metallicRoughnessTextureTransform:s?.metallicRoughnessTexture?.extensions?.KHR_texture_transform,receiveAmbientOcclusion:n.extras.ESRI_receiveAmbientOcclusion,receiveShadows:n.extras.ESRI_receiveShadows}}return o}async decode(t,r){const o=t.extensions?.KHR_draco_mesh_compression;if(!o)return;if(null==t.indices)throw new e("gltf-loader-error","Found Draco compressed primitive without indices.");const n=this.json.bufferViews[o.bufferView],s=await this.getBuffer(n.buffer,r),a=(await U()).decode(new Uint8Array(s.buffer,s.byteOffset+(n.byteOffset||0),n.byteLength));this._bufferLoaders.delete(n.buffer);const i=new Map([[t.indices,a.indices],[t.attributes.POSITION,a.positions]]);return t.attributes.TEXCOORD_0&&i.set(t.attributes.TEXCOORD_0,a.uvs),t.attributes.NORMAL&&i.set(t.attributes.NORMAL,a.normals),t.attributes.COLOR_0&&i.set(t.attributes.COLOR_0,a.colors),t.attributes.TANGENT&&i.set(t.attributes.TANGENT,a.tangents),this._dracoBuffersSize+=a.buffer.byteLength,{data:a.buffer,accessorInfos:i}}async getTexture(t,o){if(!t)return;if(0!==(t.texCoord||0))throw new e("gltf-loader-unsupported-feature","Only TEXCOORD with index 0 is supported.");const n=t.index,s=this.json.textures[n],a=G(null!=s.sampler?this.json.samplers[s.sampler]:{}),i=ee(s),u=this.json.images[i],f=await this._loadTextureImageData(n,s,o);return r(this._textureCache,n,()=>{const t=e=>33071===e||33648===e||10497===e,r=t=>{throw new e("gltf-loader-error",`Unexpected TextureSampler WrapMode: ${t}`)};return{data:f,wrapS:t(a.wrapS)?a.wrapS:r(a.wrapS),wrapT:t(a.wrapT)?a.wrapT:r(a.wrapT),minFilter:a.minFilter,name:u.name,id:n}})}getNodeTransform(e){if(void 0===e)return X;let t=this._nodeTransformCache.get(e);if(!t){const r=this.getNodeTransform(this._getNodeParent(e)),o=this.json.nodes[e];o.matrix?t=d(h(),r,o.matrix):o.translation||o.rotation||o.scale?(t=b(r),o.translation&&l(t,t,o.translation),o.rotation&&(J[3]=w(J,o.rotation),p(t,t,J[3],J)),o.scale&&m(t,t,o.scale)):t=b(r),this._nodeTransformCache.set(e,t)}return t}_resolveUri(e){return u(e,this._baseUri)}_getNodeParent(e){return this._nodeParentMap.get(e)}_checkVersionSupported(){const e=f.parse(this.json.asset.version,"glTF");q.validate(e)}_checkRequiredExtensionsSupported(){const t=this.json;if(t.extensionsRequired){if(!t.extensionsRequired.every(e=>this._supportedExtensions.includes(e)))throw new e("gltf-loader-unsupported-feature","gltf loader was not able to load unsupported feature. Required extensions: "+t.extensionsRequired.join(", "))}}_computeNodeParents(){this.json.nodes.forEach((e,t)=>{e.children&&e.children.forEach(e=>{this._nodeParentMap.set(e,t)})})}async _loadTextureImageData(e,t,r){const o=this._textureLoaders.get(e);if(o)return o;const n=this._createTextureLoader(t,r);return this._textureLoaders.set(e,n),n}async _createTextureLoader(t,r){const o=ee(t),n=this.json.images[o];if(n.uri){if(n.uri.endsWith(".ktx2")){const e=await this._context.loadBinary(this._resolveUri(n.uri),r);return new P(new Uint8Array(e))}return this._context.loadImage(this._resolveUri(n.uri),r)}if(null==n.bufferView)throw new e("gltf-loader-unsupported-feature","Image bufferView must be defined.");if(null==n.mimeType)throw new e("gltf-loader-unsupported-feature","Image mimeType must be defined.");const s=this.json.bufferViews[n.bufferView],a=await this.getBuffer(s.buffer,r);if(null!=s.byteStride)throw new e("gltf-loader-unsupported-feature","byteStride not supported for image buffer");const i=a.byteOffset+(s.byteOffset||0);return V(new Uint8Array(a.buffer,i,s.byteLength),n.mimeType)}async getLoadedBuffersSize(){if(this._glbBuffer)return this._glbBuffer.byteLength;const e=await n(Array.from(this._bufferLoaders.values())),t=await n(Array.from(this._textureLoaders.values()));return e.reduce((e,t)=>e+(t?.byteLength??0),0)+this._dracoBuffersSize+t.reduce((e,t)=>e+(t?z(t)?t.data.byteLength:t.width*t.height*4:0),0)}}const X=c(h(),Math.PI/2),q=new f(2,0,"glTF"),J=y(),$={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},W={[K.BYTE]:1,[K.UNSIGNED_BYTE]:1,[K.SHORT]:2,[K.UNSIGNED_SHORT]:2,[K.HALF_FLOAT]:2,[K.FLOAT]:4,[K.INT]:4,[K.UNSIGNED_INT]:4};function Q(e){switch(e.componentType){case K.BYTE:return new N(e.raw,e.byteOffset,e.byteStride,e.byteOffset+e.byteStride*e.entryCount);case K.UNSIGNED_BYTE:return new O(e.raw,e.byteOffset,e.byteStride,e.byteOffset+e.byteStride*e.entryCount);case K.SHORT:return new x(e.raw,e.byteOffset,e.byteStride,e.byteOffset+e.byteStride*e.entryCount);case K.UNSIGNED_SHORT:return new _(e.raw,e.byteOffset,e.byteStride,e.byteOffset+e.byteStride*e.entryCount);case K.UNSIGNED_INT:return new T(e.raw,e.byteOffset,e.byteStride,e.byteOffset+e.byteStride*e.entryCount);case K.FLOAT:return new g(e.raw,e.byteOffset,e.byteStride,e.byteOffset+e.byteStride*e.entryCount)}}function Z(e,t){return new e(t.raw,t.byteOffset,t.byteStride,t.byteOffset+t.byteStride*(t.entryCount-1)+t.componentByteSize*t.componentCount)}function ee(t){if(null!=t.extensions?.KHR_texture_basisu)return t.extensions.KHR_texture_basisu.source;if(null!==t.source)return t.source;throw new e("gltf-loader-unsupported-feature","Source is expected to be defined for a texture. It can also be omitted in favour of an KHR_texture_basisu extension tag.")}const te=/\.gltf$/i,re=/\.glb$/i;export{Y as GLTFResource,X as transformGltfToEngine};
5
+ import e from"../../../../core/Error.js";import t from"../../../../core/Logger.js";import{getOrCreateMapValue as r}from"../../../../core/MapUtils.js";import{getKey as o}from"../../../../core/object.js";import{allSettledValues as n}from"../../../../core/promiseUtils.js";import{isDataProtocol as s,dataComponents as a,dataToArrayBuffer as i,makeAbsolute as u}from"../../../../core/urlUtils.js";import{Version as f}from"../../../../core/Version.js";import{fromXRotation as c,multiply as d,translate as l,rotate as p,scale as m}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as h,clone as b}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{getAxisAngle as w}from"../../../../core/libs/gl-matrix-2/math/quat.js";import{create as y}from"../../../../core/libs/gl-matrix-2/factories/quatf64.js";import{BufferViewVec2f as g,BufferViewVec2u32 as T,BufferViewVec2u16 as _,BufferViewVec2i16 as x,BufferViewVec2u8 as O,BufferViewVec2i8 as N,BufferViewUint32 as S,BufferViewUint16 as C,BufferViewUint8 as A,BufferViewVec3f as R,BufferViewVec4f as L,BufferViewVec4u8 as v,BufferViewVec4u16 as E,BufferViewVec3u8 as I,BufferViewVec3u16 as D}from"../../../../geometry/support/buffer/BufferView.js";import{m as B}from"../../../../chunks/scalar.js";import"../../../../core/has.js";import{getDracoMeshDecoder as U}from"../../../../libs/dracoMeshDecoder/dracoMeshDecoder.js";import{BinaryStreamReader as M}from"./BinaryStreamReader.js";import{material as j,textureSampler as G}from"./fillDefaults.js";import{splitURI as F}from"./pathUtils.js";import{jsonFromBinaryData as H,EncodedMeshTexture as P,imageFromBinaryData as V,isEncodedMeshTexture as K}from"./resourceUtils.js";import{DataType as z}from"../../../webgl/enums.js";const k={MAGIC:1179937895,CHUNK_TYPE_JSON:1313821514,CHUNK_TYPE_BIN:5130562};class Y{constructor(t,r,o,n){if(this._context=t,this.uri=r,this.json=o,this._glbBuffer=n,this._bufferLoaders=new Map,this._textureLoaders=new Map,this._dracoBuffersSize=0,this._textureCache=new Map,this._materialCache=new Map,this._nodeParentMap=new Map,this._nodeTransformCache=new Map,this._supportedExtensions=["KHR_texture_basisu","KHR_texture_transform","KHR_draco_mesh_compression","KHR_materials_emissive_strength"],this._baseUri=F(this.uri).dirPart,this._checkVersionSupported(),this._checkRequiredExtensionsSupported(),null==o.scenes)throw new e("gltf-loader-unsupported-feature","Scenes must be defined.");if(null==o.meshes)throw new e("gltf-loader-unsupported-feature","Meshes must be defined");if(null==o.nodes)throw new e("gltf-loader-unsupported-feature","Nodes must be defined.");this._computeNodeParents()}static async load(t,r,o){if(s(r)){const e=a(r);if(e&&"model/gltf-binary"!==e.mediaType)try{const o=JSON.parse(e.isBase64?atob(e.data):e.data);return new Y(t,r,o)}catch{}const o=i(r);if(Y._isGLBData(o))return this._fromGLBData(t,r,o)}if(te.test(r)||"gltf"===o?.expectedType){const e=await t.loadJSON(r,o);return new Y(t,r,e)}const n=await t.loadBinary(r,o);if(Y._isGLBData(n))return this._fromGLBData(t,r,n);if(re.test(r)||"glb"===o?.expectedType)throw new e("gltf-loader-invalid-glb","This is not a valid glb file.");const u=await t.loadJSON(r,o);return new Y(t,r,u)}static _isGLBData(e){if(null==e)return!1;const t=new M(e);return t.remainingBytes()>=4&&t.readUint32()===k.MAGIC}static async _fromGLBData(e,t,r){const o=await Y._parseGLBData(r);return new Y(e,t,o.json,o.binaryData)}static async _parseGLBData(r){const o=new M(r);if(o.remainingBytes()<12)throw new e("gltf-loader-error","glb binary data is insufficiently large.");const n=o.readUint32(),s=o.readUint32(),a=o.readUint32();if(n!==k.MAGIC)throw new e("gltf-loader-error","Magic first 4 bytes do not fit to expected glb value.");if(r.byteLength<a)throw new e("gltf-loader-error","glb binary data is smaller than header specifies.");if(2!==s)throw new e("gltf-loader-unsupported-feature","An unsupported glb container version was detected. Only version 2 is supported.");let i,u,f=0;for(;o.remainingBytes()>=8;){const r=o.readUint32(),n=o.readUint32();if(0===f){if(n!==k.CHUNK_TYPE_JSON)throw new e("gltf-loader-error","First glb chunk must be JSON.");if(r<0)throw new e("gltf-loader-error","No JSON data found.");i=await H(o.readUint8Array(r))}else if(1===f){if(n!==k.CHUNK_TYPE_BIN)throw new e("gltf-loader-unsupported-feature","Second glb chunk expected to be BIN.");u=o.readUint8Array(r)}else t.getLogger("esri.views.3d.glTF").warn("[Unsupported Feature] More than 2 glb chunks detected. Skipping.");f+=1}if(!i)throw new e("gltf-loader-error","No glb JSON chunk detected.");return{json:i,binaryData:u}}async getBuffer(t,r){const o=this.json.buffers[t];if(null==o.uri){if(null==this._glbBuffer)throw new e("gltf-loader-error","glb buffer not present");return this._glbBuffer}const n=await this._getBufferLoader(t,r);if(n.byteLength!==o.byteLength)throw new e("gltf-loader-error","Buffer byte lengths should match.");return n}async _getBufferLoader(e,t){const r=this._bufferLoaders.get(e);if(r)return r;const o=this.json.buffers[e].uri,n=this._context.loadBinary(this._resolveUri(o),t).then(e=>new Uint8Array(e));return this._bufferLoaders.set(e,n),n}_validateAccessor(t){if(!this.json.accessors)throw new e("gltf-loader-unsupported-feature","Accessors missing.");const r=this.json.accessors[t];if(r.type in["MAT2","MAT3","MAT4"])throw new e("gltf-loader-unsupported-feature",`AttributeType ${r.type} is not supported`);return r}_getComponentInfo(e,t){const r=$[e.type],o=t?.componentType||e.componentType,n=W[o];return{componentType:o,componentCount:r,componentByteSize:n,denseByteStride:r*n}}getDracoAccessor(e,t){const r=this._validateAccessor(e),o=t.accessorInfos.get(e),{componentType:n,componentCount:s,componentByteSize:a,denseByteStride:i}=this._getComponentInfo(r,o);return{raw:t.data.buffer,byteStride:i,byteOffset:t.data.byteOffset+(o?.byteOffset||0),entryCount:o?.count??r.count,isDenselyPacked:!0,componentCount:s,componentByteSize:a,componentType:n,min:r.min,max:r.max,normalized:!!r.normalized}}async getAccessor(t,r){const o=this._validateAccessor(t);if(null==o?.bufferView)throw new e("gltf-loader-unsupported-feature","Some accessor does not specify a bufferView.");const{componentCount:n,componentByteSize:s,denseByteStride:a}=this._getComponentInfo(o),i=this.json.bufferViews[o.bufferView],u=await this.getBuffer(i.buffer,r),f=i.byteStride||a;return{raw:u.buffer,byteStride:f,byteOffset:u.byteOffset+(i.byteOffset||0)+(o.byteOffset||0),entryCount:o.count,isDenselyPacked:f===a,componentCount:n,componentByteSize:s,componentType:o.componentType,min:o.min,max:o.max,normalized:!!o.normalized}}async getIndexData(e,t,r){if(null==e.indices)return;const o=e.indices,n=r?this.getDracoAccessor(o,r):await this.getAccessor(o,t);if(n.isDenselyPacked)switch(n.componentType){case z.UNSIGNED_BYTE:return new Uint8Array(n.raw,n.byteOffset,n.entryCount);case z.UNSIGNED_SHORT:return new Uint16Array(n.raw,n.byteOffset,n.entryCount);case z.UNSIGNED_INT:return new Uint32Array(n.raw,n.byteOffset,n.entryCount)}else switch(n.componentType){case z.UNSIGNED_BYTE:return B(Z(A,n));case z.UNSIGNED_SHORT:return B(Z(C,n));case z.UNSIGNED_INT:return B(Z(S,n))}}async getPositionData(t,r,n){if(null==t.attributes.POSITION)throw new e("gltf-loader-unsupported-feature","No POSITION vertex data found.");const s=t.attributes.POSITION,a=n?this.getDracoAccessor(s,n):await this.getAccessor(s,r);if(a.componentType!==z.FLOAT)throw new e("gltf-loader-unsupported-feature","Expected type FLOAT for POSITION vertex attribute, but found "+o(z,a.componentType));if(3!==a.componentCount)throw new e("gltf-loader-unsupported-feature","POSITION vertex attribute must have 3 components, but found "+a.componentCount.toFixed());return Z(R,a)}async getNormalData(t,r,n){if(null==t.attributes.NORMAL)throw new e("gltf-loader-error","No NORMAL vertex data found.");const s=t.attributes.NORMAL,a=n?this.getDracoAccessor(s,n):await this.getAccessor(s,r);if(a.componentType!==z.FLOAT)throw new e("gltf-loader-unsupported-feature","Expected type FLOAT for NORMAL vertex attribute, but found "+o(z,a.componentType));if(3!==a.componentCount)throw new e("gltf-loader-unsupported-feature","NORMAL vertex attribute must have 3 components, but found "+a.componentCount.toFixed());return Z(R,a)}async getTangentData(t,r,n){if(null==t.attributes.TANGENT)throw new e("gltf-loader-error","No TANGENT vertex data found.");const s=t.attributes.TANGENT,a=n?this.getDracoAccessor(s,n):await this.getAccessor(s,r);if(a.componentType!==z.FLOAT)throw new e("gltf-loader-unsupported-feature","Expected type FLOAT for TANGENT vertex attribute, but found "+o(z,a.componentType));if(4!==a.componentCount)throw new e("gltf-loader-unsupported-feature","TANGENT vertex attribute must have 4 components, but found "+a.componentCount.toFixed());return Z(L,a)}async getTextureCoordinates(t,r,o){if(null==t.attributes.TEXCOORD_0)throw new e("gltf-loader-error","No TEXCOORD_0 vertex data found.");const n=t.attributes.TEXCOORD_0,s=o?this.getDracoAccessor(n,o):await this.getAccessor(n,r);if(2!==s.componentCount)throw new e("gltf-loader-unsupported-feature","TEXCOORD_0 vertex attribute must have 2 components, but found "+s.componentCount.toFixed());if(s.componentType===z.FLOAT)return Z(g,s);if(!s.normalized)throw new e("gltf-loader-unsupported-feature","Integer component types are only supported for a normalized accessor for TEXCOORD_0.");return Q(s)}async getVertexColors(t,r,n){if(null==t.attributes.COLOR_0)throw new e("gltf-loader-error","No COLOR_0 vertex data found.");const s=t.attributes.COLOR_0,a=n?this.getDracoAccessor(s,n):await this.getAccessor(s,r);if(4!==a.componentCount&&3!==a.componentCount)throw new e("gltf-loader-unsupported-feature","COLOR_0 attribute must have 3 or 4 components, but found "+a.componentCount.toFixed());if(4===a.componentCount){if(a.componentType===z.FLOAT)return Z(L,a);if(a.componentType===z.UNSIGNED_BYTE)return Z(v,a);if(a.componentType===z.UNSIGNED_SHORT)return Z(E,a)}else if(3===a.componentCount){if(a.componentType===z.FLOAT)return Z(R,a);if(a.componentType===z.UNSIGNED_BYTE)return Z(I,a);if(a.componentType===z.UNSIGNED_SHORT)return Z(D,a)}throw new e("gltf-loader-unsupported-feature","Unsupported component type for COLOR_0 attribute: "+o(z,a.componentType))}hasPositions(e){return void 0!==e.attributes.POSITION}hasNormals(e){return void 0!==e.attributes.NORMAL}hasVertexColors(e){return void 0!==e.attributes.COLOR_0}hasTextureCoordinates(e){return void 0!==e.attributes.TEXCOORD_0}hasTangents(e){return void 0!==e.attributes.TANGENT}async getMaterial(e,t,r){let o=e.material?this._materialCache.get(e.material):void 0;if(!o){const n=null!=e.material?j(this.json.materials[e.material]):j(),s=n.pbrMetallicRoughness,a=this.hasVertexColors(e),i=this.getTexture(s.baseColorTexture,t),u=this.getTexture(n.normalTexture,t),f=r?this.getTexture(n.occlusionTexture,t):void 0,c=r?this.getTexture(n.emissiveTexture,t):void 0,d=r?this.getTexture(s.metallicRoughnessTexture,t):void 0,l=null!=e.material?e.material:-1;o={alphaMode:n.alphaMode,alphaCutoff:n.alphaCutoff,color:s.baseColorFactor,doubleSided:!!n.doubleSided,colorTexture:await i,normalTexture:await u,name:n.name,id:l,occlusionTexture:await f,emissiveTexture:await c,emissiveFactor:n.emissiveFactor,emissiveStrengthKHR:n.extensions?.KHR_materials_emissive_strength?.emissiveStrength,metallicFactor:s.metallicFactor,roughnessFactor:s.roughnessFactor,metallicRoughnessTexture:await d,hasVertexColors:a,ESRI_externalColorMixMode:n.extras.ESRI_externalColorMixMode,colorTextureTransform:s?.baseColorTexture?.extensions?.KHR_texture_transform,normalTextureTransform:n.normalTexture?.extensions?.KHR_texture_transform,occlusionTextureTransform:n.occlusionTexture?.extensions?.KHR_texture_transform,emissiveTextureTransform:n.emissiveTexture?.extensions?.KHR_texture_transform,metallicRoughnessTextureTransform:s?.metallicRoughnessTexture?.extensions?.KHR_texture_transform,receiveAmbientOcclusion:n.extras.ESRI_receiveAmbientOcclusion,receiveShadows:n.extras.ESRI_receiveShadows}}return o}async decode(t,r){const o=t.extensions?.KHR_draco_mesh_compression;if(!o)return;if(null==t.indices)throw new e("gltf-loader-error","Found Draco compressed primitive without indices.");const n=this.json.bufferViews[o.bufferView],s=await this.getBuffer(n.buffer,r),a=(await U()).decode(new Uint8Array(s.buffer,s.byteOffset+(n.byteOffset||0),n.byteLength));this._bufferLoaders.delete(n.buffer);const i=new Map([[t.indices,a.indices],[t.attributes.POSITION,a.positions]]);return t.attributes.TEXCOORD_0&&i.set(t.attributes.TEXCOORD_0,a.uvs),t.attributes.NORMAL&&i.set(t.attributes.NORMAL,a.normals),t.attributes.COLOR_0&&i.set(t.attributes.COLOR_0,a.colors),t.attributes.TANGENT&&i.set(t.attributes.TANGENT,a.tangents),this._dracoBuffersSize+=a.buffer.byteLength,{data:a.buffer,accessorInfos:i}}async getTexture(t,o){if(!t)return;if(0!==(t.texCoord||0))throw new e("gltf-loader-unsupported-feature","Only TEXCOORD with index 0 is supported.");const n=t.index,s=this.json.textures[n],a=G(null!=s.sampler?this.json.samplers[s.sampler]:{}),i=ee(s),u=this.json.images[i],f=await this._loadTextureImageData(n,s,o);return r(this._textureCache,n,()=>{const t=e=>33071===e||33648===e||10497===e,r=t=>{throw new e("gltf-loader-error",`Unexpected TextureSampler WrapMode: ${t}`)};return{data:f,wrapS:t(a.wrapS)?a.wrapS:r(a.wrapS),wrapT:t(a.wrapT)?a.wrapT:r(a.wrapT),minFilter:a.minFilter,name:u.name,id:n}})}getNodeTransform(e){if(void 0===e)return X;let t=this._nodeTransformCache.get(e);if(!t){const r=this.getNodeTransform(this._getNodeParent(e)),o=this.json.nodes[e];o.matrix?t=d(h(),r,o.matrix):o.translation||o.rotation||o.scale?(t=b(r),o.translation&&l(t,t,o.translation),o.rotation&&(J[3]=w(J,o.rotation),p(t,t,J[3],J)),o.scale&&m(t,t,o.scale)):t=b(r),this._nodeTransformCache.set(e,t)}return t}_resolveUri(e){return u(e,this._baseUri)}_getNodeParent(e){return this._nodeParentMap.get(e)}_checkVersionSupported(){const e=f.parse(this.json.asset.version,"glTF");q.validate(e)}_checkRequiredExtensionsSupported(){const t=this.json;if(t.extensionsRequired){if(!t.extensionsRequired.every(e=>this._supportedExtensions.includes(e)))throw new e("gltf-loader-unsupported-feature","gltf loader was not able to load unsupported feature. Required extensions: "+t.extensionsRequired.join(", "))}}_computeNodeParents(){this.json.nodes.forEach((e,t)=>{e.children&&e.children.forEach(e=>{this._nodeParentMap.set(e,t)})})}async _loadTextureImageData(e,t,r){const o=this._textureLoaders.get(e);if(o)return o;const n=this._createTextureLoader(t,r);return this._textureLoaders.set(e,n),n}async _createTextureLoader(t,r){const o=ee(t),n=this.json.images[o];if(n.uri){if(n.uri.endsWith(".ktx2")){const e=await this._context.loadBinary(this._resolveUri(n.uri),r);return new P(new Uint8Array(e))}return this._context.loadImage(this._resolveUri(n.uri),r)}if(null==n.bufferView)throw new e("gltf-loader-unsupported-feature","Image bufferView must be defined.");if(null==n.mimeType)throw new e("gltf-loader-unsupported-feature","Image mimeType must be defined.");const s=this.json.bufferViews[n.bufferView],a=await this.getBuffer(s.buffer,r);if(null!=s.byteStride)throw new e("gltf-loader-unsupported-feature","byteStride not supported for image buffer");const i=a.byteOffset+(s.byteOffset||0);return V(new Uint8Array(a.buffer,i,s.byteLength),n.mimeType)}async getLoadedBuffersSize(){if(this._glbBuffer)return this._glbBuffer.byteLength;const e=await n(Array.from(this._bufferLoaders.values())),t=await n(Array.from(this._textureLoaders.values()));return e.reduce((e,t)=>e+(t?.byteLength??0),0)+this._dracoBuffersSize+t.reduce((e,t)=>e+(t?K(t)?t.data.byteLength:t.width*t.height*4:0),0)}}const X=c(h(),Math.PI/2),q=new f(2,0,"glTF"),J=y(),$={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},W={[z.BYTE]:1,[z.UNSIGNED_BYTE]:1,[z.SHORT]:2,[z.UNSIGNED_SHORT]:2,[z.HALF_FLOAT]:2,[z.FLOAT]:4,[z.INT]:4,[z.UNSIGNED_INT]:4};function Q(e){switch(e.componentType){case z.BYTE:return new N(e.raw,e.byteOffset,e.byteStride,e.byteOffset+e.byteStride*e.entryCount);case z.UNSIGNED_BYTE:return new O(e.raw,e.byteOffset,e.byteStride,e.byteOffset+e.byteStride*e.entryCount);case z.SHORT:return new x(e.raw,e.byteOffset,e.byteStride,e.byteOffset+e.byteStride*e.entryCount);case z.UNSIGNED_SHORT:return new _(e.raw,e.byteOffset,e.byteStride,e.byteOffset+e.byteStride*e.entryCount);case z.UNSIGNED_INT:return new T(e.raw,e.byteOffset,e.byteStride,e.byteOffset+e.byteStride*e.entryCount);case z.FLOAT:return new g(e.raw,e.byteOffset,e.byteStride,e.byteOffset+e.byteStride*e.entryCount)}}function Z(e,t){return new e(t.raw,t.byteOffset,t.byteStride,t.byteOffset+t.byteStride*(t.entryCount-1)+t.componentByteSize*t.componentCount)}function ee(t){if(null!=t.extensions?.KHR_texture_basisu)return t.extensions.KHR_texture_basisu.source;if(null!==t.source)return t.source;throw new e("gltf-loader-unsupported-feature","Source is expected to be defined for a texture. It can also be omitted in favour of an KHR_texture_basisu extension tag.")}const te=/\.gltf$/i,re=/\.glb$/i;export{Y as GLTFResource,X as transformGltfToEngine};
@@ -2,4 +2,4 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../../core/Logger.js";import{getKey as o}from"../../../core/object.js";import{clone as t}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{makeMaterialParameters as r,makeTextureSource as s}from"./LoaderResult.js";import{GLTFResource as a}from"./internal/Resource.js";import{PrimitiveType as i}from"../../webgl/enums.js";let n=0;async function l(r,s,l={},m=!0){const T=await a.load(r,s,l),p="gltf_"+n++,f={lods:[],materials:new Map,textures:new Map,meta:u(T)},x=!(!T.json.asset.extras||"symbolResource"!==T.json.asset.extras.ESRI_type),g=T.json.asset.extras?.ESRI_webstyleSymbol?.webstyle,h=new Map;let w=!1;await c(T,async(r,s,a,n)=>{const u=h.get(a)??0;h.set(a,u+1);const c=void 0!==r.mode?r.mode:i.TRIANGLES,x=c===i.TRIANGLES||c===i.TRIANGLE_STRIP||c===i.TRIANGLE_FAN?c:null;if(null==x)return void e.getLogger("esri.views.3d.glTF").warn("[Unsupported Feature] Unsupported primitive mode ("+o(i,c)+"). Skipping primitive.");if(!T.hasPositions(r))return void e.getLogger("esri.views.3d.glTF").warn("Skipping primitive without POSITION vertex attribute.");const g=await T.decode(r,l);w||=!!g;const v=T.getPositionData(r,l,g),S=T.getMaterial(r,l,m),R=T.hasNormals(r)?T.getNormalData(r,l,g):null,_=T.hasTangents(r)?T.getTangentData(r,l,g):null,F=T.hasTextureCoordinates(r)?T.getTextureCoordinates(r,l,g):null,y=T.hasVertexColors(r)?T.getVertexColors(r,l,g):null,E=T.getIndexData(r,l,g),I={name:n,transform:t(s),attributes:{position:await v,normal:R?await R:null,texCoord0:F?await F:null,color:y?await y:null,tangent:_?await _:null},indices:await E,primitiveType:x,material:d(f,await S,p)};let M=null;null!=f.meta?.ESRI_lod&&"screenSpaceRadius"===f.meta.ESRI_lod.metric&&(M=f.meta.ESRI_lod.thresholds[a]),f.lods[a]=f.lods[a]||{parts:[],name:n,lodThreshold:M},f.lods[a].parts[u]=I});for(const e of f.lods)e.parts=e.parts.filter(e=>!!e);const v=await T.getLoadedBuffersSize();return{model:f,meta:{isEsriSymbolResource:x,uri:T.uri,ESRI_webstyle:g,isDracoDecompressed:w},customMeta:{},usedMemory:v}}function u(e){const o=e.json;let t=null;return o.nodes.forEach(e=>{const o=e.extras;null!=o&&(o.ESRI_proxyEllipsoid||o.ESRI_lod)&&(t=o)}),t}async function c(o,t){const r=o.json,s=r.scenes[r.scene||0].nodes,a=s.length>1,i=[];for(const e of s){const o=r.nodes[e];if(i.push(n(e,0)),m(o)&&!a){o.extensions.MSFT_lod.ids.forEach((e,o)=>n(e,o+1))}}async function n(s,a){const l=r.nodes[s],u=o.getNodeTransform(s);if(null!=l.weights&&e.getLogger("esri.views.3d.glTF").warn("[Unsupported Feature] Morph targets are not supported."),null!=l.mesh){const e=r.meshes[l.mesh];for(const o of e.primitives)i.push(t(o,u,a,e.name))}for(const e of l.children||[])i.push(n(e,a))}await Promise.all(i)}function m(e){return e.extensions?.MSFT_lod&&Array.isArray(e.extensions.MSFT_lod.ids)}function d(e,o,t){const a=o=>{const r=`${t}_tex_${o&&o.id}${o?.name?"_"+o.name:""}`;if(o&&!e.textures.has(r)){const t=s(o.data,{wrap:{s:o.wrapS,t:o.wrapT},mipmap:T.has(o.minFilter),noUnpackFlip:!0});e.textures.set(r,t)}return r},i=`${t}_mat_${o.id}_${o.name}`;if(!e.materials.has(i)){const t=r({color:[o.color[0],o.color[1],o.color[2]],opacity:o.color[3],alphaMode:o.alphaMode,alphaCutoff:o.alphaCutoff,doubleSided:o.doubleSided,colorMixMode:o.ESRI_externalColorMixMode,colorTexture:o.colorTexture?a(o.colorTexture):void 0,normalTexture:o.normalTexture?a(o.normalTexture):void 0,occlusionTexture:o.occlusionTexture?a(o.occlusionTexture):void 0,emissiveTexture:o.emissiveTexture?a(o.emissiveTexture):void 0,metallicRoughnessTexture:o.metallicRoughnessTexture?a(o.metallicRoughnessTexture):void 0,emissiveFactor:[o.emissiveFactor[0],o.emissiveFactor[1],o.emissiveFactor[2]],colorTextureTransform:o.colorTextureTransform,normalTextureTransform:o.normalTextureTransform,occlusionTextureTransform:o.occlusionTextureTransform,emissiveTextureTransform:o.emissiveTextureTransform,metallicRoughnessTextureTransform:o.metallicRoughnessTextureTransform,metallicFactor:o.metallicFactor,roughnessFactor:o.roughnessFactor,receiveShadows:o.receiveShadows,receiveAmbientOcclusion:o.receiveAmbientOcclusion});e.materials.set(i,t)}return i}const T=new Set([9987,9985]);export{l as loadGLTF};
5
+ import e from"../../../core/Logger.js";import{getKey as o}from"../../../core/object.js";import{clone as t}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{makeMaterialParameters as r,makeTextureSource as s}from"./LoaderResult.js";import{GLTFResource as a}from"./internal/Resource.js";import{PrimitiveType as i}from"../../webgl/enums.js";let n=0;async function l(r,s,l={},m=!0){const T=await a.load(r,s,l),p="gltf_"+n++,f={lods:[],materials:new Map,textures:new Map,meta:u(T)},x=!(!T.json.asset.extras||"symbolResource"!==T.json.asset.extras.ESRI_type),g=T.json.asset.extras?.ESRI_webstyleSymbol?.webstyle,h=new Map;let w=!1;await c(T,async(r,s,a,n)=>{const u=h.get(a)??0;h.set(a,u+1);const c=void 0!==r.mode?r.mode:i.TRIANGLES,x=c===i.TRIANGLES||c===i.TRIANGLE_STRIP||c===i.TRIANGLE_FAN?c:null;if(null==x)return void e.getLogger("esri.views.3d.glTF").warn("[Unsupported Feature] Unsupported primitive mode ("+o(i,c)+"). Skipping primitive.");if(!T.hasPositions(r))return void e.getLogger("esri.views.3d.glTF").warn("Skipping primitive without POSITION vertex attribute.");const g=await T.decode(r,l);w||=!!g;const v=T.getPositionData(r,l,g),S=T.getMaterial(r,l,m),R=T.hasNormals(r)?T.getNormalData(r,l,g):null,_=T.hasTangents(r)?T.getTangentData(r,l,g):null,F=T.hasTextureCoordinates(r)?T.getTextureCoordinates(r,l,g):null,y=T.hasVertexColors(r)?T.getVertexColors(r,l,g):null,E=T.getIndexData(r,l,g),I={name:n,transform:t(s),attributes:{position:await v,normal:R?await R:null,texCoord0:F?await F:null,color:y?await y:null,tangent:_?await _:null},indices:await E,primitiveType:x,material:d(f,await S,p)};let M=null;null!=f.meta?.ESRI_lod&&"screenSpaceRadius"===f.meta.ESRI_lod.metric&&(M=f.meta.ESRI_lod.thresholds[a]),f.lods[a]=f.lods[a]||{parts:[],name:n,lodThreshold:M},f.lods[a].parts[u]=I});for(const e of f.lods)e.parts=e.parts.filter(e=>!!e);const v=await T.getLoadedBuffersSize();return{model:f,meta:{isEsriSymbolResource:x,uri:T.uri,ESRI_webstyle:g,isDracoDecompressed:w},customMeta:{},usedMemory:v}}function u(e){const o=e.json;let t=null;return o.nodes.forEach(e=>{const o=e.extras;null!=o&&(o.ESRI_proxyEllipsoid||o.ESRI_lod)&&(t=o)}),t}async function c(o,t){const r=o.json,s=r.scenes[r.scene||0].nodes,a=s.length>1,i=[];for(const e of s){const o=r.nodes[e];if(i.push(n(e,0)),m(o)&&!a){o.extensions.MSFT_lod.ids.forEach((e,o)=>n(e,o+1))}}async function n(s,a){const l=r.nodes[s],u=o.getNodeTransform(s);if(null!=l.weights&&e.getLogger("esri.views.3d.glTF").warn("[Unsupported Feature] Morph targets are not supported."),null!=l.mesh){const e=r.meshes[l.mesh];for(const o of e.primitives)i.push(t(o,u,a,e.name))}for(const e of l.children||[])i.push(n(e,a))}await Promise.all(i)}function m(e){return e.extensions?.MSFT_lod&&Array.isArray(e.extensions.MSFT_lod.ids)}function d(e,o,t){const a=o=>{const r=`${t}_tex_${o&&o.id}${o?.name?"_"+o.name:""}`;if(o&&!e.textures.has(r)){const t=s(o.data,{wrap:{s:o.wrapS,t:o.wrapT},mipmap:T.has(o.minFilter),noUnpackFlip:!0});e.textures.set(r,t)}return r},i=`${t}_mat_${o.id}_${o.name}`;if(!e.materials.has(i)){const t=r({color:[o.color[0],o.color[1],o.color[2]],opacity:o.color[3],alphaMode:o.alphaMode,alphaCutoff:o.alphaCutoff,doubleSided:o.doubleSided,colorMixMode:o.ESRI_externalColorMixMode,colorTexture:o.colorTexture?a(o.colorTexture):void 0,normalTexture:o.normalTexture?a(o.normalTexture):void 0,occlusionTexture:o.occlusionTexture?a(o.occlusionTexture):void 0,emissiveTexture:o.emissiveTexture?a(o.emissiveTexture):void 0,metallicRoughnessTexture:o.metallicRoughnessTexture?a(o.metallicRoughnessTexture):void 0,emissiveFactor:[o.emissiveFactor[0],o.emissiveFactor[1],o.emissiveFactor[2]],emissiveStrengthKHR:o.emissiveStrengthKHR,colorTextureTransform:o.colorTextureTransform,normalTextureTransform:o.normalTextureTransform,occlusionTextureTransform:o.occlusionTextureTransform,emissiveTextureTransform:o.emissiveTextureTransform,metallicRoughnessTextureTransform:o.metallicRoughnessTextureTransform,metallicFactor:o.metallicFactor,roughnessFactor:o.roughnessFactor,receiveShadows:o.receiveShadows,receiveAmbientOcclusion:o.receiveAmbientOcclusion});e.materials.set(i,t)}return i}const T=new Set([9987,9985]);export{l as loadGLTF};
@@ -2,4 +2,4 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import"../../../core/has.js";import t from"../../../core/Logger.js";import{destroyMaybe as r}from"../../../core/maybe.js";import{estimateNumberArrayMemory as i}from"../../../core/memoryEstimations.js";import{throwIfAborted as s}from"../../../core/promiseUtils.js";import{initial as o,watch as a}from"../../../core/reactiveUtils.js";import{generateUID as n}from"../../../core/uid.js";import{property as l,subclass as d}from"../../../core/accessorSupport/decorators.js";import{h as u}from"../../../chunks/vec32.js";import{create as h,ZEROS as p}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{projectBuffer as c}from"../../../geometry/projection/projectBuffer.js";import{projectVectorToVector as g}from"../../../geometry/projection/projectVectorToVector.js";import{extentContainsCoords3D as m,extentContainsCoords2D as y}from"../../../geometry/support/contains.js";import{newDoubleArray as f,doubleArrayFrom as _}from"../../../geometry/support/DoubleArray.js";import{getGeometryZScaler as b}from"../../../geometry/support/zscale.js";import{fallbackObjectIDAttribute as v}from"../../../layers/LayerConstants.js";import{estimateSize as I}from"../../../layers/graphics/dehydratedFeatures.js";import{ImmutableDehydratedPoint as x}from"../../../layers/graphics/dehydratedPoint.js";import{hydrateGraphic as E}from"../../../layers/graphics/hydratedFeatures.js";import w from"../../../layers/graphics/controllers/I3SOnDemandController.js";import O from"../../../layers/support/FeatureFilter.js";import j from"../../../rest/support/Query.js";import{isBasemapLayerView as N}from"../../../support/basemapUtils.js";import{isGraphic as C}from"../../../support/guards.js";import{I3SPointsWorkerHandle as D}from"./I3SPointsWorkerHandle.js";import{LayerView3D as F}from"./LayerView3D.js";import{Graphics3DFeatureProcessor as S}from"./graphics/Graphics3DFeatureProcessor.js";import{QueryEngine as G}from"./graphics/QueryEngine.js";import{QueryEngineContext as A}from"./graphics/QueryEngineContext.js";import{createInteractiveEditSession as V,normalizeEditResultsEvent as P,processAttributeEdits as L}from"./i3s/featureEditing.js";import{getCachedAttributeValue as R}from"./i3s/I3SBinaryReader.js";import{I3SGraphicsMap as H}from"./i3s/I3SGraphicsMap.js";import{I3SOverrides as M}from"./i3s/I3SOverrides.js";import{checkRecyclable as U,checkSpatialReferences as Q,containsDraco as q,whenGraphicAttributes as T}from"./i3s/I3SUtil.js";import{attributeLookup as B}from"./support/attributeUtils.js";import{DefinitionExpressionSceneLayerView as k}from"./support/DefinitionExpressionSceneLayerView.js";import{defineFieldProperties as z}from"./support/fieldProperties.js";import{normalizeHighlightTarget as W,emptyHighlightHandle as K,isObjectId as Z}from"./support/highlightUtils.js";import{LayerViewPerformanceInfo as $}from"./support/LayerViewPerformanceInfo.js";import{PopupSceneLayerView as Y}from"./support/PopupSceneLayerView.js";import{SceneLayerViewRequiredFields as J}from"./support/SceneLayerViewRequiredFields.js";import{TemporalSceneLayerView as X}from"./support/TemporalSceneLayerView.js";import{debugFlags as ee}from"../support/debugFlags.js";import{compute as te}from"../support/orientedBoundingBox.js";import{updatingProgress as re}from"../support/updatingProperties.js";import{Vertices as ie}from"../webgl-engine/lib/Attribute.js";import se from"../../layers/SceneLayerView.js";import{hasPopupTemplate as oe}from"../../layers/support/popupUtils.js";import{getHighlightName as ae}from"../../support/highlightOptionsUtils.js";import{hasLayerBasedScaleVisibility as ne,isInEffectiveScaleRange as le}from"../../support/layerViewUtils.js";import{TaskPriority as de}from"../../support/Scheduler.js";const ue=z();class he{constructor(e,t,r,i){this.graphics=e,this.featureIds=t,this.attributeInfo=r,this.node=i}get usedMemory(){return this.graphics.reduce((e,t)=>I(t)+e,i(this.featureIds)+1024)}}let pe=class extends(X(k(Y(F(se))))){constructor(){super(...arguments),this.type="scene-layer-graphics-3d",this._queryEngine=null,this._memCache=null,this._interactiveEditingSessions=new Map,this._pendingEditsQueue=Promise.resolve(),this.loadedGraphics=new H((e,t,r)=>ye(e,t,r),e=>this.processor.graphicsCore.recreateGraphics(e)),this.holeFilling="always",this.progressiveLoadFactor=1,this.supportsHeightUnitConversion=!0,this._coordinatesOutsideExtentErrors=0,this._maxCoordinatesOutsideExtentErrors=20}tryRecycleWith(e,t){return e.url===this.layer.url&&this._i3sOverrides.isEmpty?e.load(t).then(()=>{s(t),U(this.layer,e,this._i3sOverrides),this.layer=e,this._i3sOverrides.destroy();const i=this.view.resourceController?.memoryController;this._i3sOverrides=new M({view:this.view,layer:e,memoryController:i}),r(this._queryEngine),this._setupQueryEngine(),this.processor.resetObjectStates()}):null}initialize(){this.addResolvingPromise(this.layer.indexInfo);const e=this.view.resourceController?.memoryController;this._i3sOverrides=new M({view:this.view,layer:this.layer,memoryController:e}),Q(this.layer,this.view.spatialReference,this.view.viewingMode),this._fieldsHelper=new J({layerView:this}),this._updatingHandles.add(()=>this.layer.rangeInfos,e=>this._rangeInfosChanged(e),o),this._updatingHandles.add(()=>this.layer.renderer,(e,t)=>this._rendererChange(e,t)),this._updatingHandles.add(()=>[this.parsedDefinitionExpression,this.layer.excludeObjectIds],()=>this._filterChange()),this._set("processor",new S({owner:this,preferredUpdatePolicy:0,scaleVisibilityEnabled:!ne(),filterVisibilityEnabled:!0,timeExtentEnabled:!1,frustumVisibilityEnabled:!1,elevationAlignmentEnabled:!0,elevationFeatureExpressionEnabled:!1,setUidToIdOnAdd:!1,dataExtent:this.layer.fullExtent,updateClippingExtent:e=>this._updateClippingExtent(e)})),this.processor.elevationAlignment?.events.on("invalidate-elevation",({extent:e,spatialReference:t})=>this._controller.updateElevationChanged(e,t)),this.supportsHeightUnitConversion&&(this._verticalScale=b("point",this.layer.spatialReference,this.view.spatialReference)),this.addResolvingPromise(this.processor.when()),this._memCache=this.view.resourceController.memoryController.newCache(`psl-${this.uid}`),this._controller=new w({layerView:this}),q(this.layer.geometryDefinitions)&&(this._workerHandle=new D(e=>this.view.resourceController.immediate.schedule(e))),this.addHandles(this.layer.on("apply-edits",e=>this._updatingHandles.addPromise(e.result))),this.addHandles([this.layer.on("edits",e=>{const t=this._pendingEditsQueue.then(()=>this._handleEdits(e)).then();this._pendingEditsQueue=t,this._updatingHandles.addPromise(t)}),a(()=>ee.I3S_TREE_SHOW_TILES,e=>{if(e&&!this._treeDebugger){const e=this._controller.crsIndex;import("./support/I3STreeDebugger.js").then(({I3STreeDebugger:t})=>{!this._treeDebugger&&ee.I3S_TREE_SHOW_TILES&&(this._treeDebugger=new t({lv:this,view:this.view,nodeSR:e}))})}else e||!this._treeDebugger||ee.I3S_TREE_SHOW_TILES||(this._treeDebugger.destroy(),this._treeDebugger=null)},o)]),this.when(()=>{this._setupQueryEngine(),this._updatingHandles.add(()=>this.maximumNumberOfFeatures,e=>this._controller.featureTarget=e,o),this._updatingHandles.add(()=>this.suspended,e=>{e&&this._removeAllNodeData()})})}destroy(){this._treeDebugger=r(this._treeDebugger),this._i3sOverrides=r(this._i3sOverrides),this._set("processor",r(this.processor)),this._controller=r(this._controller),this._queryEngine=r(this._queryEngine),this._workerHandle=r(this._workerHandle),this._memCache=r(this._memCache),this.loadedGraphics.clear(),this._fieldsHelper=r(this._fieldsHelper)}get i3slayer(){return this.layer}get layerViewUid(){return this.uid}get updatingProgressValue(){return this._controller?.updatingProgress??1}get visibleAtCurrentScale(){return ne()?le(this.layer.effectiveScaleRange,this.view.scale):!this.processor?.scaleVisibilitySuspended}get requiredFields(){return this._fieldsHelper?.requiredFields??[]}get maximumNumberOfFeatures(){const e=this.processor?.graphicsCore?.displayFeatureLimit;return e?.maximumNumberOfFeatures??0}set maximumNumberOfFeatures(e){null!=e?(this._override("maximumNumberOfFeatures",e),this._controller.fixedFeatureTarget=!0):(this._clearOverride("maximumNumberOfFeatures"),this._controller.fixedFeatureTarget=!1)}get maximumNumberOfFeaturesExceeded(){return!this.suspended&&(!!this._controller?.useMaximumNumberOfFeatures&&!this._controller.leavesReached)}get _excludeObjectIds(){return new Set(this.layer.excludeObjectIds)}get lodFactor(){return"Labels"===this.layer.semantic?1:this.view.qualitySettings.sceneService.pointLoDFactor}get hasM(){return!1}get hasZ(){return!0}get contentVisible(){return!this.suspended&&!!this._controller?.rootNodeVisible}get legendEnabled(){return this.contentVisible&&!0===this.i3slayer?.legendEnabled}get _graphicOrigin(){return this.layer.graphicOrigin}async whenGraphicAttributes(e,t){return T(this.layer,e,this._getObjectIdField(),t,()=>[...this.loadedGraphics.nodes()])}getHit(e){if(!this.loadedGraphics)return null;const t=E(this.loadedGraphics.find(t=>t.uid===e),this.layer,this._graphicOrigin),r=this._getObjectIdField();return null==t?.attributes?.[r]?null:{type:"graphic",graphic:t,layer:t.layer}}whenGraphicBounds(e,t){return this.processor.whenGraphicBounds(e,t)}computeAttachmentOrigin(e,t){return this.processor.computeAttachmentOrigin(e,t)}isUpdating(){return!!(this._controller?.updating||this.processor?.updating||this._fieldsHelper?.updating||this.layerFilterUpdating)}highlight(e,t){const r=ae(t),i=this.layer.objectIdField,s=W(e);if(0===s.length)return K;if(C(s[0])){const e=s;if(null!=B(this.layer.fieldsIndex,e[0].attributes,i)){const t=e.map(e=>B(this.layer.fieldsIndex,e.attributes,i));return this.processor.highlightByObjectIds(t,i,r)}return this.processor.highlightByGraphics(e,r)}return Z(s[0])?this.processor.highlightByObjectIds(s,i,r):K}get updatePolicy(){return this.processor.graphicsCore.effectiveUpdatePolicy}createInteractiveEditSession(e){return V(this._attributeEditingContext,e)}async _decompressBinaryPointData(e,t){const r={geometryBuffer:e.geometryBuffer};null==this._workerHandle&&(this._workerHandle=new D(e=>this.view.resourceController.immediate.schedule(e)));const i=await this._workerHandle.invoke(r,t);if(null==i)throw new Error("Failed to decompress Draco point data");return{positionData:i.positions,featureIds:i.featureIds}}async addNode(e,r,i){if(!me(r)&&!ge(r))throw new Error;if(this.loadedGraphics.hasNode(e.index))return void t.getLogger(this).error("I3S node "+e.id+" already added");const s=null!=this.layer.fullExtent?_e(this.layer.fullExtent.clone(),.5):null,{featureIds:o,pointPositions:a}=me(r)?await this._extractBinaryPointPositions(e,r,i):this._extractLegacyPointPositions(r),n=new Array;this._validatePositions(e,o,a,s,n);const l=this._controller.crsVertex,d=this.view.spatialReference;c(a,l,0,a,d,0,o.length);const u=me(r)?e.level:0,h=this._createGraphics(o,a,e.index,u),p=new he(h,o,r.attributeDataInfo,e);if(await this._i3sOverrides.applyAttributeOverrides(p.featureIds,r.attributeDataInfo,i),e.numFeatures=p.graphics.length,this._updateNodeMemory(e),fe(p),n.length>0&&(this._computeObb(e,n,l),this._controller.updateVisibility(e.index)),!this._controller.isGeometryVisible(e))return void this._cacheNodeData(p);if(null!=this._verticalScale)for(const t of p.graphics)this._verticalScale(t.geometry);const g=this.view.stage.renderView.olidRenderHelper;if(g){const e=N(this.view,this.uid);for(let t=0;t<p.featureIds.length;t++){const r=p.featureIds[t];g.setUidToObjectAndLayerId(r,p.graphics[t].uid,this.layer.id,this.uid,this.layer.popupEnabled&&!e&&oe(this.layer,this.view.popup?.defaultPopupTemplateEnabled),p.node.resources.attributes,t)}}this.loadedGraphics.addNode(e.index,p),this._controller.updateLoadStatus(e.index,!0),this._filterNode(p),this._treeDebugger&&this._treeDebugger.update()}_computeObb(e,t,r){const i=this._controller.crsIndex,s=i.isGeographic?this.view.renderSpatialReference:i;c(t,r,0,t,s,0),e.serviceObbInIndexSR=te(new ie(t,3)),i.isGeographic&&(g(e.serviceObbInIndexSR.center,s,ve,i),e.serviceObbInIndexSR.center=ve)}isNodeLoaded(e){return this.loadedGraphics.hasNode(e)}isNodeReloading(){return!1}updateNodeState(){}getNodeComponentHandle(){}async _extractBinaryPointPositions(e,t,r){const i=await this._decompressBinaryPointData(t,r),s=i.positionData,o=3,a=s.length/o,n=f(3*a),l=null!=e.serviceObbInIndexSR?e.serviceObbInIndexSR.center:p,d=Math.abs(l[2])*2**-20;for(let u=0;u<a;u++){const e=u*o;n[e]=s[e]+l[0],n[e+1]=s[e+1]+l[1],n[e+2]=s[e+2]+l[2],Math.abs(n[e+2])<d&&(n[e+2]=0)}return{featureIds:i.featureIds?_(i.featureIds):[],pointPositions:n}}_extractLegacyPointPositions(e){const t=e.pointData.length,r=f(3*t),i=new Array;for(let s=0;s<t;s++){const t=e.pointData[s],o=t.featureDataPosition,a=o.length,n=t.geometries?.[0]??be[a],l=t.featureIds[0];if("Embedded"!==n.type||"points"!==n.params.type||a<2||a>3)continue;const d=n.params.vertexAttributes?.position??[0,0,0],u=3*i.length;r[u]=o[0]+d[0],r[u+1]=o[1]+d[1],r[u+2]=3===a?o[2]+d[2]:NaN,i.push(l)}return{featureIds:i,pointPositions:r}}_validatePositions(e,r,i,s,o){if(null==s&&e.serviceObbInIndexSR)return;const a=r.length,n=3;for(let l=0;l<a;l++){const r=l*n;u(ve,i[r],i[r+1],i[r+2]);const a=!Number.isNaN(i[2]);null==s||(a?m(s,ve):y(s,ve))||(this._coordinatesOutsideExtentErrors<this._maxCoordinatesOutsideExtentErrors&&t.getLogger(this).error("Service Error: Coordinates outside of layer extent"),this._coordinatesOutsideExtentErrors+1===this._maxCoordinatesOutsideExtentErrors&&t.getLogger(this).error("Maximum number of errors reached. Further errors are ignored."),this._coordinatesOutsideExtentErrors++),e.serviceObbInIndexSR||o.push(ve[0],ve[1],ve[2])}}_createGraphics(e,t,r,i){const s=e.length,o=3,a=this._getObjectIdField(),l=this.processor.graphicsCore,d=new Array,u=this.view.spatialReference;for(let h=0;h<s;h++){const s=e[h],p={};null!=s&&(p[a]=s);const c=s??n(),g=h*o,m=isNaN(t[g+2])?void 0:t[g+2],y=new x(u,t[g],t[g+1],m),f=this.loadedGraphics.get(c);if(null!=f)(null==f.level||f.level<i)&&(Ie.property="geometry",Ie.graphic=f,Ie.oldValue=f.geometry,Ie.newValue=y,f.geometry=y,f.level=i,l.graphicUpdateHandler(Ie),xe()),d.push(f);else{const e=n();d.push({objectId:c,uid:e,geometry:y,attributes:p,visible:!0,nodeIndex:r,level:i})}}return d}_updateNodeMemory(e){e.memory=4096+(e.numFeatures??0)*this.processor.graphicsCore.usedMemoryPerGraphic}_cacheNodeData(e){this._memCache.put(this._getMemCacheKey(e.node),e)}_getMemCacheKey(e){return`${e.index}`}_removeAllNodeData(){this.loadedGraphics.forEachNode((e,t)=>{if(e){const t=e.node;this._updateNodeMemory(t),this._cacheNodeData(e)}this._controller.updateLoadStatus(t,!1)}),this._treeDebugger&&this._treeDebugger.update(),this.loadedGraphics.clear()}removeNode(e){const t=this._removeNodeStageData(e);t&&(this._updateNodeMemory(t.node),this._cacheNodeData(t))}_removeNodeStageData(e){const t=this.loadedGraphics.getNode(e);return null==t?null:(this._controller.updateLoadStatus(e,!1),this.loadedGraphics.removeNode(e),this._treeDebugger&&this._treeDebugger.update(),t)}async loadCachedNodeData(e){return this._memCache?.pop(this._getMemCacheKey(e))}async addCachedNodeData(e,r,i,s){this.loadedGraphics.hasNode(e.index)?t.getLogger(this).error("I3S node "+e.id+" already added"):(await this._i3sOverrides.applyAttributeOverrides(r.featureIds,i,s),r.attributeInfo=i,this.loadedGraphics.addNode(e.index,r),this._controller.updateLoadStatus(e.index,!0),this._updateNodeMemory(e),fe(r),this._filterNode(r),this._treeDebugger&&this._treeDebugger.update())}getLoadedNodeIds(){const e=[];return this.loadedGraphics.forEachNode(t=>e.push(t.node.id)),e.sort()}getVisibleNodes(){const e=new Array;return this.loadedGraphics.forEachNode(t=>e.push(t.node)),e}getLoadedNodeIndices(e){this.loadedGraphics.forEachNode((t,r)=>e.push(r))}getLoadedAttributes(e){const t=this.loadedGraphics.getNode(e);if(null!=t?.attributeInfo)return t.attributeInfo.loadedAttributes}getAttributeData(e){const t=this.loadedGraphics.getNode(e);if(null!=t?.attributeInfo)return t.attributeInfo.attributeData}_setAttributeData(e,t){const r=this.loadedGraphics.getNode(e);null!=r?.attributeInfo&&(r.attributeInfo.attributeData=t,this._attributeValuesChanged(r))}async updateAttributes(e,t,r){const i=this.loadedGraphics.getNode(e);null!=i&&(await this._i3sOverrides.applyAttributeOverrides(i.featureIds,t,r),i.attributeInfo=t,this._attributeValuesChanged(i))}_attributeValuesChanged(e){fe(e),this._filterNode(e);const{processor:t}=this,{graphicsCore:r}=t;if(r.labelsEnabled){const t=e.node.index,i=new Array;e.graphics.forEach(e=>e.nodeIndex===t&&i.push(e.uid)),r.updateLabelingInfo(i)}t.refreshFilter()}_updateClippingExtent(e){return this._controller&&this._controller.updateClippingArea(e),!1}_getObjectIdField(){return this.layer.objectIdField||v}_getGlobalIdField(){return this.layer.globalIdField}async _rendererChange(e,t){const{layer:{fieldsIndex:r}}=this,i=new Set;let s,o;e?(await e.collectRequiredFields(i,r),s=Array.from(i).sort()):s=[],i.clear(),t?(await t.collectRequiredFields(i,r),o=Array.from(i).sort()):o=[],s.length===o.length&&s.every((e,t)=>s[t]===o[t])||this._reloadAllNodes()}_rangeInfosChanged(e){null!=e&&e.length>0&&t.getLogger(this).warn("Unsupported property: rangeInfos are currently only serialized to and from web scenes but do not affect rendering.")}_filterChange(){this.loadedGraphics.forEachNode(e=>this._filterNode(e))}_reloadAllNodes(){this._removeAllNodeData(),this._controller&&this._controller.restartNodeLoading()}_filterNode(e){const t=this.parsedDefinitionExpression,r=this._excludeObjectIds,i=this._getObjectIdField();for(const s of e.graphics){const e=s.visible,o=this._evaluateClause(t,s),a=!r.has(s.attributes[i]);s.visible=o&&a,e!==s.visible&&(Ie.graphic=s,Ie.property="visible",Ie.oldValue=e,Ie.newValue=s.visible,this.processor.graphicsCore.graphicUpdateHandler(Ie),xe())}}createQuery(){const e={outFields:["*"],returnGeometry:!0,outSpatialReference:this.view.spatialReference};return this.filter?.createQuery(e)??new j(e)}queryFeatures(e,t){return this._queryEngine.executeQuery(this._ensureQuery(e),t?.signal)}queryObjectIds(e,t){return this._queryEngine.executeQueryForIds(this._ensureQuery(e),t?.signal)}queryFeatureCount(e,t){return this._queryEngine.executeQueryForCount(this._ensureQuery(e),t?.signal)}queryExtent(e,t){return this._queryEngine.executeQueryForExtent(this._ensureQuery(e),t?.signal)}_ensureQuery(e){return this._addDefinitionExpressionToQuery(null==e?this.createQuery():j.from(e))}_setupQueryEngine(){const{layer:e,view:t,hasM:r,hasZ:i}=this,{spatialReference:s,resourceController:o}=t,a=new A(s,e,o,()=>this.processor.featureStore,i,r);this._queryEngine=new G({context:a,priority:de.FEATURE_QUERY_ENGINE})}get usedMemory(){return this.processor?.graphicsCore?.usedMemory??0}get unloadedMemory(){return.8*((this._controller?.unloadedMemoryEstimate??0)+(this.processor?.graphicsCore?.unprocessedMemoryEstimate??0))}get ignoresMemoryFactor(){return this._controller&&this._controller.fixedFeatureTarget}async _handleEdits(e){const t=this._attributeEditingContext,r=await P(t,e);L(t,r)}get _attributeEditingContext(){const e=this._getObjectIdField(),t=this._getGlobalIdField();return{sessions:this._interactiveEditingSessions,fieldsIndex:this.layer.fieldsIndex,objectIdField:e,globalIdField:t,forEachNode:e=>this.loadedGraphics.forEachNode(t=>e(t.node,t.featureIds)),attributeStorageInfo:this.i3slayer.attributeStorageInfo??[],i3sOverrides:this._i3sOverrides,getAttributeData:e=>this.getAttributeData(e),setAttributeData:(t,r,i)=>{this._setAttributeData(t,r);const s=this.loadedGraphics.getNode(t);if(null!=i){const t=this.loadedGraphics.get(i.attributes[e]);null!=t&&this.processor.graphicsCore.recreateGraphics([t])}else null!=s&&this.processor.graphicsCore.recreateGraphics(s.graphics)},clearMemCache:()=>{}}}get performanceInfo(){return new $(this.usedMemory,this.loadedGraphics.length,-1,this.maximumNumberOfFeatures,this.loadedGraphics.nodeCount,this.processor.graphicsCore.performanceInfo)}get test(){}};e([l()],pe.prototype,"processor",void 0),e([l({type:O})],pe.prototype,"filter",void 0),e([l()],pe.prototype,"loadedGraphics",void 0),e([l()],pe.prototype,"i3slayer",null),e([l()],pe.prototype,"layerViewUid",null),e([l()],pe.prototype,"_controller",void 0),e([l()],pe.prototype,"updating",void 0),e([l()],pe.prototype,"suspended",void 0),e([l(re)],pe.prototype,"updatingProgress",void 0),e([l()],pe.prototype,"updatingProgressValue",null),e([l({readOnly:!0})],pe.prototype,"visibleAtCurrentScale",null),e([l(ue.requiredFields)],pe.prototype,"requiredFields",null),e([l(ue.availableFields)],pe.prototype,"availableFields",void 0),e([l()],pe.prototype,"_fieldsHelper",void 0),e([l({type:Number})],pe.prototype,"maximumNumberOfFeatures",null),e([l({readOnly:!0})],pe.prototype,"maximumNumberOfFeaturesExceeded",null),e([l()],pe.prototype,"_excludeObjectIds",null),e([l({readOnly:!0})],pe.prototype,"lodFactor",null),e([l({readOnly:!0})],pe.prototype,"hasM",null),e([l({readOnly:!0})],pe.prototype,"hasZ",null),e([l()],pe.prototype,"contentVisible",null),e([l({readOnly:!0})],pe.prototype,"legendEnabled",null),e([l()],pe.prototype,"_graphicOrigin",null),pe=e([d("esri.views.3d.layers.SceneLayerGraphicsView3D")],pe);const ce=pe;function ge(e){return"pointData"in e}function me(e){return"geometryBuffer"in e&&null!==e.geometryBuffer}function ye(e,t,r){const i=t.attributeInfo;if(null==i?.loadedAttributes||null==i.attributeData)return!1;let s=!1;for(const{name:o}of i.loadedAttributes)if(i.attributeData[o]){const t=R(i.attributeData[o],r);t!==e.attributes[o]&&(e.attributes[o]=t,s=!0)}return s}function fe(e){const t=e.attributeInfo;if(null==t?.loadedAttributes||null==t.attributeData)return;const r=e.node.index;for(let i=0;i<e.graphics.length;i++){const s=e.graphics[i];if(s.nodeIndex===r){s.attributes||(s.attributes={});for(const{name:e}of t.loadedAttributes)t.attributeData[e]&&(s.attributes[e]=R(t.attributeData[e],i))}}}function _e(e,t){return e.xmin-=t,e.ymin-=t,e.xmax+=t,e.ymax+=t,null!=e.zmin&&null!=e.zmax&&(e.zmin-=t,e.zmax+=t),null!=e.mmin&&null!=e.mmax&&(e.mmin-=t,e.mmax+=t),e}const be={2:{type:"Embedded",params:{type:"points",vertexAttributes:{position:[0,0]}}},3:{type:"Embedded",params:{type:"points",vertexAttributes:{position:[0,0,0]}}}},ve=h(),Ie={graphic:null,property:null,oldValue:null,newValue:null};function xe(){Ie.graphic=null,Ie.property=null,Ie.oldValue=null,Ie.newValue=null}export{ce as default};
5
+ import{__decorate as e}from"tslib";import"../../../core/has.js";import t from"../../../core/Logger.js";import{destroyMaybe as r}from"../../../core/maybe.js";import{estimateNumberArrayMemory as i}from"../../../core/memoryEstimations.js";import{throwIfAborted as s}from"../../../core/promiseUtils.js";import{initial as o,watch as a}from"../../../core/reactiveUtils.js";import{generateUID as n}from"../../../core/uid.js";import{property as l,subclass as d}from"../../../core/accessorSupport/decorators.js";import{h as u}from"../../../chunks/vec32.js";import{create as h,ZEROS as p}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{projectBuffer as c}from"../../../geometry/projection/projectBuffer.js";import{projectVectorToVector as g}from"../../../geometry/projection/projectVectorToVector.js";import{extentContainsCoords3D as m,extentContainsCoords2D as y}from"../../../geometry/support/contains.js";import{newDoubleArray as f,doubleArrayFrom as _}from"../../../geometry/support/DoubleArray.js";import{getGeometryZScaler as b}from"../../../geometry/support/zscale.js";import{fallbackObjectIDAttribute as v}from"../../../layers/LayerConstants.js";import{estimateSize as I}from"../../../layers/graphics/dehydratedFeatures.js";import{ImmutableDehydratedPoint as x}from"../../../layers/graphics/dehydratedPoint.js";import{hydrateGraphic as E}from"../../../layers/graphics/hydratedFeatures.js";import w from"../../../layers/graphics/controllers/I3SOnDemandController.js";import O from"../../../layers/support/FeatureFilter.js";import j from"../../../rest/support/Query.js";import{isBasemapLayerView as N}from"../../../support/basemapUtils.js";import{isGraphic as C}from"../../../support/guards.js";import{I3SPointsWorkerHandle as D}from"./I3SPointsWorkerHandle.js";import{LayerView3D as F}from"./LayerView3D.js";import{Graphics3DFeatureProcessor as S}from"./graphics/Graphics3DFeatureProcessor.js";import{QueryEngine as G}from"./graphics/QueryEngine.js";import{QueryEngineContext as A}from"./graphics/QueryEngineContext.js";import{createInteractiveEditSession as V,normalizeEditResultsEvent as P,processAttributeEdits as L}from"./i3s/featureEditing.js";import{getCachedAttributeValue as R}from"./i3s/I3SBinaryReader.js";import{I3SGraphicsMap as H}from"./i3s/I3SGraphicsMap.js";import{I3SOverrides as M}from"./i3s/I3SOverrides.js";import{checkRecyclable as U,checkSpatialReferences as Q,containsDraco as q,whenGraphicAttributes as T}from"./i3s/I3SUtil.js";import{attributeLookup as B}from"./support/attributeUtils.js";import{DefinitionExpressionSceneLayerView as k}from"./support/DefinitionExpressionSceneLayerView.js";import{defineFieldProperties as z}from"./support/fieldProperties.js";import{normalizeHighlightTarget as W,emptyHighlightHandle as K,isObjectId as Z}from"./support/highlightUtils.js";import{LayerViewPerformanceInfo as $}from"./support/LayerViewPerformanceInfo.js";import{PopupSceneLayerView as Y}from"./support/PopupSceneLayerView.js";import{SceneLayerViewRequiredFields as J}from"./support/SceneLayerViewRequiredFields.js";import{TemporalSceneLayerView as X}from"./support/TemporalSceneLayerView.js";import{debugFlags as ee}from"../support/debugFlags.js";import{compute as te}from"../support/orientedBoundingBox.js";import{updatingProgress as re}from"../support/updatingProperties.js";import{Vertices as ie}from"../webgl-engine/lib/Attribute.js";import se from"../../layers/SceneLayerView.js";import{hasPopupTemplate as oe}from"../../layers/support/popupUtils.js";import{getHighlightName as ae}from"../../support/highlightOptionsUtils.js";import{hasLayerBasedScaleVisibility as ne,isInEffectiveScaleRange as le}from"../../support/layerViewUtils.js";import{TaskPriority as de}from"../../support/Scheduler.js";const ue=z();class he{constructor(e,t,r,i){this.graphics=e,this.featureIds=t,this.attributeInfo=r,this.node=i}get usedMemory(){return this.graphics.reduce((e,t)=>I(t)+e,i(this.featureIds)+1024)}}let pe=class extends(X(k(Y(F(se))))){constructor(){super(...arguments),this.type="scene-layer-graphics-3d",this._queryEngine=null,this._memCache=null,this._interactiveEditingSessions=new Map,this._pendingEditsQueue=Promise.resolve(),this.loadedGraphics=new H((e,t,r)=>ye(e,t,r),e=>this.processor.graphicsCore.recreateGraphics(e),this.logError),this.holeFilling="always",this.progressiveLoadFactor=1,this.supportsHeightUnitConversion=!0,this._coordinatesOutsideExtentErrors=0,this._maxCoordinatesOutsideExtentErrors=20}tryRecycleWith(e,t){return e.url===this.layer.url&&this._i3sOverrides.isEmpty?e.load(t).then(()=>{s(t),U(this.layer,e,this._i3sOverrides),this.layer=e,this._i3sOverrides.destroy();const i=this.view.resourceController?.memoryController;this._i3sOverrides=new M({view:this.view,layer:e,memoryController:i}),r(this._queryEngine),this._setupQueryEngine(),this.processor.resetObjectStates()}):null}initialize(){this.addResolvingPromise(this.layer.indexInfo);const e=this.view.resourceController?.memoryController;this._i3sOverrides=new M({view:this.view,layer:this.layer,memoryController:e}),Q(this.layer,this.view.spatialReference,this.view.viewingMode),this._fieldsHelper=new J({layerView:this}),this._updatingHandles.add(()=>this.layer.rangeInfos,e=>this._rangeInfosChanged(e),o),this._updatingHandles.add(()=>this.layer.renderer,(e,t)=>this._rendererChange(e,t)),this._updatingHandles.add(()=>[this.parsedDefinitionExpression,this.layer.excludeObjectIds],()=>this._filterChange()),this._set("processor",new S({owner:this,preferredUpdatePolicy:0,scaleVisibilityEnabled:!ne(),filterVisibilityEnabled:!0,timeExtentEnabled:!1,frustumVisibilityEnabled:!1,elevationAlignmentEnabled:!0,elevationFeatureExpressionEnabled:!1,setUidToIdOnAdd:!1,dataExtent:this.layer.fullExtent,updateClippingExtent:e=>this._updateClippingExtent(e)})),this.processor.elevationAlignment?.events.on("invalidate-elevation",({extent:e,spatialReference:t})=>this._controller.updateElevationChanged(e,t)),this.supportsHeightUnitConversion&&(this._verticalScale=b("point",this.layer.spatialReference,this.view.spatialReference)),this.addResolvingPromise(this.processor.when()),this._memCache=this.view.resourceController.memoryController.newCache(`psl-${this.uid}`),this._controller=new w({layerView:this}),q(this.layer.geometryDefinitions)&&(this._workerHandle=new D(e=>this.view.resourceController.immediate.schedule(e))),this.addHandles(this.layer.on("apply-edits",e=>this._updatingHandles.addPromise(e.result))),this.addHandles([this.layer.on("edits",e=>{const t=this._pendingEditsQueue.then(()=>this._handleEdits(e)).then();this._pendingEditsQueue=t,this._updatingHandles.addPromise(t)}),a(()=>ee.I3S_TREE_SHOW_TILES,e=>{if(e&&!this._treeDebugger){const e=this._controller.crsIndex;import("./support/I3STreeDebugger.js").then(({I3STreeDebugger:t})=>{!this._treeDebugger&&ee.I3S_TREE_SHOW_TILES&&(this._treeDebugger=new t({lv:this,view:this.view,nodeSR:e}))})}else e||!this._treeDebugger||ee.I3S_TREE_SHOW_TILES||(this._treeDebugger.destroy(),this._treeDebugger=null)},o)]),this.when(()=>{this._setupQueryEngine(),this._updatingHandles.add(()=>this.maximumNumberOfFeatures,e=>this._controller.featureTarget=e,o),this._updatingHandles.add(()=>this.suspended,e=>{e&&this._removeAllNodeData()})})}destroy(){this._treeDebugger=r(this._treeDebugger),this._i3sOverrides=r(this._i3sOverrides),this._set("processor",r(this.processor)),this._controller=r(this._controller),this._queryEngine=r(this._queryEngine),this._workerHandle=r(this._workerHandle),this._memCache=r(this._memCache),this.loadedGraphics.clear(),this._fieldsHelper=r(this._fieldsHelper)}get i3slayer(){return this.layer}get layerViewUid(){return this.uid}get updatingProgressValue(){return this._controller?.updatingProgress??1}get visibleAtCurrentScale(){return ne()?le(this.layer.effectiveScaleRange,this.view.scale):!this.processor?.scaleVisibilitySuspended}get requiredFields(){return this._fieldsHelper?.requiredFields??[]}get maximumNumberOfFeatures(){const e=this.processor?.graphicsCore?.displayFeatureLimit;return e?.maximumNumberOfFeatures??0}set maximumNumberOfFeatures(e){null!=e?(this._override("maximumNumberOfFeatures",e),this._controller.fixedFeatureTarget=!0):(this._clearOverride("maximumNumberOfFeatures"),this._controller.fixedFeatureTarget=!1)}get maximumNumberOfFeaturesExceeded(){return!this.suspended&&(!!this._controller?.useMaximumNumberOfFeatures&&!this._controller.leavesReached)}get _excludeObjectIds(){return new Set(this.layer.excludeObjectIds)}get lodFactor(){return"Labels"===this.layer.semantic?1:this.view.qualitySettings.sceneService.pointLoDFactor}get hasM(){return!1}get hasZ(){return!0}get contentVisible(){return!this.suspended&&!!this._controller?.rootNodeVisible}get legendEnabled(){return this.contentVisible&&!0===this.i3slayer?.legendEnabled}get _graphicOrigin(){return this.layer.graphicOrigin}async whenGraphicAttributes(e,t){return T(this.layer,e,this._getObjectIdField(),t,()=>[...this.loadedGraphics.nodes()])}getHit(e){if(!this.loadedGraphics)return null;const t=E(this.loadedGraphics.find(t=>t.uid===e),this.layer,this._graphicOrigin),r=this._getObjectIdField();return null==t?.attributes?.[r]?null:{type:"graphic",graphic:t,layer:t.layer}}whenGraphicBounds(e,t){return this.processor.whenGraphicBounds(e,t)}computeAttachmentOrigin(e,t){return this.processor.computeAttachmentOrigin(e,t)}isUpdating(){return!!(this._controller?.updating||this.processor?.updating||this._fieldsHelper?.updating||this.layerFilterUpdating)}highlight(e,t){const r=ae(t),i=this.layer.objectIdField,s=W(e);if(0===s.length)return K;if(C(s[0])){const e=s;if(null!=B(this.layer.fieldsIndex,e[0].attributes,i)){const t=e.map(e=>B(this.layer.fieldsIndex,e.attributes,i));return this.processor.highlightByObjectIds(t,i,r)}return this.processor.highlightByGraphics(e,r)}return Z(s[0])?this.processor.highlightByObjectIds(s,i,r):K}get updatePolicy(){return this.processor.graphicsCore.effectiveUpdatePolicy}createInteractiveEditSession(e){return V(this._attributeEditingContext,e)}async _decompressBinaryPointData(e,t){const r={geometryBuffer:e.geometryBuffer};null==this._workerHandle&&(this._workerHandle=new D(e=>this.view.resourceController.immediate.schedule(e)));const i=await this._workerHandle.invoke(r,t);if(null==i)throw new Error("Failed to decompress Draco point data");return{positionData:i.positions,featureIds:i.featureIds}}async addNode(e,r,i){if(!me(r)&&!ge(r))throw new Error;if(this.loadedGraphics.hasNode(e.index))return void t.getLogger(this).error("I3S node "+e.id+" already added");const s=null!=this.layer.fullExtent?_e(this.layer.fullExtent.clone(),.5):null,{featureIds:o,pointPositions:a}=me(r)?await this._extractBinaryPointPositions(e,r,i):this._extractLegacyPointPositions(r),n=new Array;this._validatePositions(e,o,a,s,n);const l=this._controller.crsVertex,d=this.view.spatialReference;c(a,l,0,a,d,0,o.length);const u=me(r)?e.level:0,h=this._createGraphics(o,a,e.index,u),p=new he(h,o,r.attributeDataInfo,e);if(await this._i3sOverrides.applyAttributeOverrides(p.featureIds,r.attributeDataInfo,i),e.numFeatures=p.graphics.length,this._updateNodeMemory(e),fe(p),n.length>0&&(this._computeObb(e,n,l),this._controller.updateVisibility(e.index)),!this._controller.isGeometryVisible(e))return void this._cacheNodeData(p);if(null!=this._verticalScale)for(const t of p.graphics)this._verticalScale(t.geometry);const g=this.view.stage.renderView.olidRenderHelper;if(g){const e=N(this.view,this.uid);for(let t=0;t<p.featureIds.length;t++){const r=p.featureIds[t];g.setUidToObjectAndLayerId(r,p.graphics[t].uid,this.layer.id,this.uid,this.layer.popupEnabled&&!e&&oe(this.layer,this.view.popup?.defaultPopupTemplateEnabled),p.node.resources.attributes,t)}}this.loadedGraphics.addNode(e.index,p),this._controller.updateLoadStatus(e.index,!0),this._filterNode(p),this._treeDebugger&&this._treeDebugger.update()}_computeObb(e,t,r){const i=this._controller.crsIndex,s=i.isGeographic?this.view.renderSpatialReference:i;c(t,r,0,t,s,0),e.serviceObbInIndexSR=te(new ie(t,3)),i.isGeographic&&(g(e.serviceObbInIndexSR.center,s,ve,i),e.serviceObbInIndexSR.center=ve)}isNodeLoaded(e){return this.loadedGraphics.hasNode(e)}isNodeReloading(){return!1}updateNodeState(){}getNodeComponentHandle(){}async _extractBinaryPointPositions(e,t,r){const i=await this._decompressBinaryPointData(t,r),s=i.positionData,o=3,a=s.length/o,n=f(3*a),l=null!=e.serviceObbInIndexSR?e.serviceObbInIndexSR.center:p,d=Math.abs(l[2])*2**-20;for(let u=0;u<a;u++){const e=u*o;n[e]=s[e]+l[0],n[e+1]=s[e+1]+l[1],n[e+2]=s[e+2]+l[2],Math.abs(n[e+2])<d&&(n[e+2]=0)}return{featureIds:i.featureIds?_(i.featureIds):[],pointPositions:n}}_extractLegacyPointPositions(e){const t=e.pointData.length,r=f(3*t),i=new Array;for(let s=0;s<t;s++){const t=e.pointData[s],o=t.featureDataPosition,a=o.length,n=t.geometries?.[0]??be[a],l=t.featureIds[0];if("Embedded"!==n.type||"points"!==n.params.type||a<2||a>3)continue;const d=n.params.vertexAttributes?.position??[0,0,0],u=3*i.length;r[u]=o[0]+d[0],r[u+1]=o[1]+d[1],r[u+2]=3===a?o[2]+d[2]:NaN,i.push(l)}return{featureIds:i,pointPositions:r}}_validatePositions(e,r,i,s,o){if(null==s&&e.serviceObbInIndexSR)return;const a=r.length,n=3;for(let l=0;l<a;l++){const r=l*n;u(ve,i[r],i[r+1],i[r+2]);const a=!Number.isNaN(i[2]);null==s||(a?m(s,ve):y(s,ve))||(this._coordinatesOutsideExtentErrors<this._maxCoordinatesOutsideExtentErrors&&t.getLogger(this).error("Service Error: Coordinates outside of layer extent"),this._coordinatesOutsideExtentErrors+1===this._maxCoordinatesOutsideExtentErrors&&t.getLogger(this).error("Maximum number of errors reached. Further errors are ignored."),this._coordinatesOutsideExtentErrors++),e.serviceObbInIndexSR||o.push(ve[0],ve[1],ve[2])}}_createGraphics(e,t,r,i){const s=e.length,o=3,a=this._getObjectIdField(),l=this.processor.graphicsCore,d=new Array,u=this.view.spatialReference;for(let h=0;h<s;h++){const s=e[h],p={};null!=s&&(p[a]=s);const c=s??n(),g=h*o,m=isNaN(t[g+2])?void 0:t[g+2],y=new x(u,t[g],t[g+1],m),f=this.loadedGraphics.get(c);if(null!=f)(null==f.level||f.level<i)&&(Ie.property="geometry",Ie.graphic=f,Ie.oldValue=f.geometry,Ie.newValue=y,f.geometry=y,f.level=i,l.graphicUpdateHandler(Ie),xe()),d.push(f);else{const e=n();d.push({objectId:c,uid:e,geometry:y,attributes:p,visible:!0,nodeIndex:r,level:i})}}return d}_updateNodeMemory(e){e.memory=4096+(e.numFeatures??0)*this.processor.graphicsCore.usedMemoryPerGraphic}_cacheNodeData(e){this._memCache.put(this._getMemCacheKey(e.node),e)}_getMemCacheKey(e){return`${e.index}`}_removeAllNodeData(){this.loadedGraphics.forEachNode((e,t)=>{if(e){const t=e.node;this._updateNodeMemory(t),this._cacheNodeData(e)}this._controller.updateLoadStatus(t,!1)}),this._treeDebugger&&this._treeDebugger.update(),this.loadedGraphics.clear()}removeNode(e){const t=this._removeNodeStageData(e);t&&(this._updateNodeMemory(t.node),this._cacheNodeData(t))}_removeNodeStageData(e){const t=this.loadedGraphics.getNode(e);return null==t?null:(this._controller.updateLoadStatus(e,!1),this.loadedGraphics.removeNode(e),this._treeDebugger&&this._treeDebugger.update(),t)}async loadCachedNodeData(e){return this._memCache?.pop(this._getMemCacheKey(e))}async addCachedNodeData(e,r,i,s){this.loadedGraphics.hasNode(e.index)?t.getLogger(this).error("I3S node "+e.id+" already added"):(await this._i3sOverrides.applyAttributeOverrides(r.featureIds,i,s),r.attributeInfo=i,this.loadedGraphics.addNode(e.index,r),this._controller.updateLoadStatus(e.index,!0),this._updateNodeMemory(e),fe(r),this._filterNode(r),this._treeDebugger&&this._treeDebugger.update())}getLoadedNodeIds(){const e=[];return this.loadedGraphics.forEachNode(t=>e.push(t.node.id)),e.sort()}getVisibleNodes(){const e=new Array;return this.loadedGraphics.forEachNode(t=>e.push(t.node)),e}getLoadedNodeIndices(e){this.loadedGraphics.forEachNode((t,r)=>e.push(r))}getLoadedAttributes(e){const t=this.loadedGraphics.getNode(e);if(null!=t?.attributeInfo)return t.attributeInfo.loadedAttributes}getAttributeData(e){const t=this.loadedGraphics.getNode(e);if(null!=t?.attributeInfo)return t.attributeInfo.attributeData}_setAttributeData(e,t){const r=this.loadedGraphics.getNode(e);null!=r?.attributeInfo&&(r.attributeInfo.attributeData=t,this._attributeValuesChanged(r))}async updateAttributes(e,t,r){const i=this.loadedGraphics.getNode(e);null!=i&&(await this._i3sOverrides.applyAttributeOverrides(i.featureIds,t,r),i.attributeInfo=t,this._attributeValuesChanged(i))}_attributeValuesChanged(e){fe(e),this._filterNode(e);const{processor:t}=this,{graphicsCore:r}=t;if(r.labelsEnabled){const t=e.node.index,i=new Array;e.graphics.forEach(e=>e.nodeIndex===t&&i.push(e.uid)),r.updateLabelingInfo(i)}t.refreshFilter()}_updateClippingExtent(e){return this._controller&&this._controller.updateClippingArea(e),!1}_getObjectIdField(){return this.layer.objectIdField||v}_getGlobalIdField(){return this.layer.globalIdField}async _rendererChange(e,t){const{layer:{fieldsIndex:r}}=this,i=new Set;let s,o;e?(await e.collectRequiredFields(i,r),s=Array.from(i).sort()):s=[],i.clear(),t?(await t.collectRequiredFields(i,r),o=Array.from(i).sort()):o=[],s.length===o.length&&s.every((e,t)=>s[t]===o[t])||this._reloadAllNodes()}_rangeInfosChanged(e){null!=e&&e.length>0&&t.getLogger(this).warn("Unsupported property: rangeInfos are currently only serialized to and from web scenes but do not affect rendering.")}_filterChange(){this.loadedGraphics.forEachNode(e=>this._filterNode(e))}_reloadAllNodes(){this._removeAllNodeData(),this._controller&&this._controller.restartNodeLoading()}_filterNode(e){const t=this.parsedDefinitionExpression,r=this._excludeObjectIds,i=this._getObjectIdField();for(const s of e.graphics){const e=s.visible,o=this._evaluateClause(t,s),a=!r.has(s.attributes[i]);s.visible=o&&a,e!==s.visible&&(Ie.graphic=s,Ie.property="visible",Ie.oldValue=e,Ie.newValue=s.visible,this.processor.graphicsCore.graphicUpdateHandler(Ie),xe())}}createQuery(){const e={outFields:["*"],returnGeometry:!0,outSpatialReference:this.view.spatialReference};return this.filter?.createQuery(e)??new j(e)}queryFeatures(e,t){return this._queryEngine.executeQuery(this._ensureQuery(e),t?.signal)}queryObjectIds(e,t){return this._queryEngine.executeQueryForIds(this._ensureQuery(e),t?.signal)}queryFeatureCount(e,t){return this._queryEngine.executeQueryForCount(this._ensureQuery(e),t?.signal)}queryExtent(e,t){return this._queryEngine.executeQueryForExtent(this._ensureQuery(e),t?.signal)}_ensureQuery(e){return this._addDefinitionExpressionToQuery(null==e?this.createQuery():j.from(e))}_setupQueryEngine(){const{layer:e,view:t,hasM:r,hasZ:i}=this,{spatialReference:s,resourceController:o}=t,a=new A(s,e,o,()=>this.processor.featureStore,i,r);this._queryEngine=new G({context:a,priority:de.FEATURE_QUERY_ENGINE})}get usedMemory(){return this.processor?.graphicsCore?.usedMemory??0}get unloadedMemory(){return.8*((this._controller?.unloadedMemoryEstimate??0)+(this.processor?.graphicsCore?.unprocessedMemoryEstimate??0))}get ignoresMemoryFactor(){return this._controller&&this._controller.fixedFeatureTarget}async _handleEdits(e){const t=this._attributeEditingContext,r=await P(t,e);L(t,r)}get _attributeEditingContext(){const e=this._getObjectIdField(),t=this._getGlobalIdField();return{sessions:this._interactiveEditingSessions,fieldsIndex:this.layer.fieldsIndex,objectIdField:e,globalIdField:t,forEachNode:e=>this.loadedGraphics.forEachNode(t=>e(t.node,t.featureIds)),attributeStorageInfo:this.i3slayer.attributeStorageInfo??[],i3sOverrides:this._i3sOverrides,getAttributeData:e=>this.getAttributeData(e),setAttributeData:(t,r,i)=>{this._setAttributeData(t,r);const s=this.loadedGraphics.getNode(t);if(null!=i){const t=this.loadedGraphics.get(i.attributes[e]);null!=t&&this.processor.graphicsCore.recreateGraphics([t])}else null!=s&&this.processor.graphicsCore.recreateGraphics(s.graphics)},clearMemCache:()=>{}}}get performanceInfo(){return new $(this.usedMemory,this.loadedGraphics.length,-1,this.maximumNumberOfFeatures,this.loadedGraphics.nodeCount,this.processor.graphicsCore.performanceInfo)}get test(){}};e([l()],pe.prototype,"processor",void 0),e([l({type:O})],pe.prototype,"filter",void 0),e([l()],pe.prototype,"loadedGraphics",void 0),e([l()],pe.prototype,"i3slayer",null),e([l()],pe.prototype,"layerViewUid",null),e([l()],pe.prototype,"_controller",void 0),e([l()],pe.prototype,"updating",void 0),e([l()],pe.prototype,"suspended",void 0),e([l(re)],pe.prototype,"updatingProgress",void 0),e([l()],pe.prototype,"updatingProgressValue",null),e([l({readOnly:!0})],pe.prototype,"visibleAtCurrentScale",null),e([l(ue.requiredFields)],pe.prototype,"requiredFields",null),e([l(ue.availableFields)],pe.prototype,"availableFields",void 0),e([l()],pe.prototype,"_fieldsHelper",void 0),e([l({type:Number})],pe.prototype,"maximumNumberOfFeatures",null),e([l({readOnly:!0})],pe.prototype,"maximumNumberOfFeaturesExceeded",null),e([l()],pe.prototype,"_excludeObjectIds",null),e([l({readOnly:!0})],pe.prototype,"lodFactor",null),e([l({readOnly:!0})],pe.prototype,"hasM",null),e([l({readOnly:!0})],pe.prototype,"hasZ",null),e([l()],pe.prototype,"contentVisible",null),e([l({readOnly:!0})],pe.prototype,"legendEnabled",null),e([l()],pe.prototype,"_graphicOrigin",null),pe=e([d("esri.views.3d.layers.SceneLayerGraphicsView3D")],pe);const ce=pe;function ge(e){return"pointData"in e}function me(e){return"geometryBuffer"in e&&null!==e.geometryBuffer}function ye(e,t,r){const i=t.attributeInfo;if(null==i?.loadedAttributes||null==i.attributeData)return!1;let s=!1;for(const{name:o}of i.loadedAttributes)if(i.attributeData[o]){const t=R(i.attributeData[o],r);t!==e.attributes[o]&&(e.attributes[o]=t,s=!0)}return s}function fe(e){const t=e.attributeInfo;if(null==t?.loadedAttributes||null==t.attributeData)return;const r=e.node.index;for(let i=0;i<e.graphics.length;i++){const s=e.graphics[i];if(s.nodeIndex===r){s.attributes||(s.attributes={});for(const{name:e}of t.loadedAttributes)t.attributeData[e]&&(s.attributes[e]=R(t.attributeData[e],i))}}}function _e(e,t){return e.xmin-=t,e.ymin-=t,e.xmax+=t,e.ymax+=t,null!=e.zmin&&null!=e.zmax&&(e.zmin-=t,e.zmax+=t),null!=e.mmin&&null!=e.mmax&&(e.mmin-=t,e.mmax+=t),e}const be={2:{type:"Embedded",params:{type:"points",vertexAttributes:{position:[0,0]}}},3:{type:"Embedded",params:{type:"points",vertexAttributes:{position:[0,0,0]}}}},ve=h(),Ie={graphic:null,property:null,oldValue:null,newValue:null};function xe(){Ie.graphic=null,Ie.property=null,Ie.oldValue=null,Ie.newValue=null}export{ce as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import"../../../../core/has.js";import{clone as t}from"../../../../core/lang.js";import{getMetersPerVerticalUnitForSR as e}from"../../../../core/units.js";import{e as r}from"../../../../chunks/earcut.js";import{normalFromMat4 as s}from"../../../../core/libs/gl-matrix-2/math/mat3.js";import{create as o}from"../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{invert as n,invertOrIdentity as i}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as a}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{h as l,a as c,f as p,i as m,n as h,p as u,d,e as g}from"../../../../chunks/vec32.js";import{ONES as f,create as y}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{computeTranslationToOriginAndRotation as b}from"../../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{create as _,fromBuffer as x,intersectsClippingArea as j}from"../../../../geometry/support/aaBoundingBox.js";import{newDoubleArray as S}from"../../../../geometry/support/DoubleArray.js";import{newIndexArray as w,getZeroIndexArray as P}from"../../../../geometry/support/Indices.js";import{t as v}from"../../../../chunks/vec3.js";import{SnappingCandidateVertex as C,SnappingCandidateEdge as E}from"../../../../layers/graphics/data/SnappingCandidate.js";import{getDriverAxisSizeValue as A}from"../../../../renderers/support/renderingInfoUtils.js";import{needsElevationUpdates3D as D,SampleElevationInfo as I}from"./elevationAlignmentUtils.js";import{Object3DEdgeState as L,Graphics3DObject3DGraphicLayer as U}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as z}from"./Graphics3DSymbolLayer.js";import{computeCentroid as O}from"./graphicUtils.js";import{geometryAsPolygon as M}from"./polygonUtils.js";import{createMaterial as G}from"../support/edgeUtils.js";import{encodeNaNUInt8 as V}from"../support/symbolColorUtils.js";import{debugFlags as T}from"../../support/debugFlags.js";import{SamplePosition as B}from"../../support/ElevationProvider.js";import{polygonToRenderInfo as R}from"../../support/renderInfoUtils/polygon.js";import{Attribute as F}from"../../webgl-engine/lib/Attribute.js";import{Geometry as H}from"../../webgl-engine/lib/Geometry.js";import{isGeometryWithMapPositions as k}from"../../webgl-engine/lib/GeometryWithMapPositions.js";import{compressNormals as N,compressNormal as W}from"../../webgl-engine/lib/Normals.js";import{Object3D as q}from"../../webgl-engine/lib/Object3D.js";import{DefaultMaterial as Z}from"../../webgl-engine/materials/DefaultMaterial.js";const J=["polygon","extent"];class K extends z{constructor(t,e,r,s){super(t,e,r,s,mt(e)),this.ensureDrapedStatus(!1)}async doLoad(){const t=this.symbolLayer,e=t?.material,r=this.symbolLayer.material?.color?.a,s=this.needsDrivenTransparentPass||null!=r&&1!==r,o=e?.emissive,n=!this._hasDrivenColorOrOpacity&&(null==r||0===r),i={usePBR:this._context.physicalBasedRenderingEnabled,isSchematic:!0,ambient:f,diffuse:f,opacity:n?0:1,layerOpacity:this._getLayerOpacity(),drivenOpacity:s,hasSymbolColors:!0,hasSlicePlane:this._context.slicePlaneEnabled,castShadows:t.castShadows,emissiveStrength:o?.strength??0,emissiveSource:1,offsetTransparentBackfaces:!0,normalType:1},a=new Z(i,this._context),l=new Z({...i,cullFace:2},this._context);this._materials[0]=a,this._materials[1]=l,this._updateTransparentDepedentMaterialParameters()}destroy(){super.destroy(),this._materials.length=0}createGraphics3DGraphic(t){const e=t.graphic;if(!this._validateGeometry(e.geometry,J,this.symbolLayer.type))return null;const r=this._getDrivenUInt8ColorWithNaNSupport(t.renderingInfo,this._materialColor,!1);V(r,r);const s=this.createElevationContextForGraphic(e);return this._createAs3DShape(e,t.renderingInfo,r,s,e.uid)}layerOpacityChanged(t,e){const r=this._getLayerOpacity();this._materials[0]?.setParameters({layerOpacity:r}),this._materials[1]?.setParameters({layerOpacity:r}),this._updateTransparentDepedentMaterialParameters(),t?.forEach(t=>e(t)?.layerOpacityChanged(r,this._context.isAsync))}layerScreenSizePerspectiveChanged(){}layerElevationInfoChanged(t,e){return this.updateGraphics3DGraphicElevationInfo(t,e,D)}slicePlaneEnabledChanged(t,e){return this._materials[0]?.setParameters({hasSlicePlane:this._context.slicePlaneEnabled}),this._materials[1]?.setParameters({hasSlicePlane:this._context.slicePlaneEnabled}),t?.forEach(t=>{const r=e(t);null!=r&&r.slicePlaneEnabledChanged(this._context.slicePlaneEnabled,this._context.isAsync)}),!0}physicalBasedRenderingChanged(){const t={usePBR:this._context.physicalBasedRenderingEnabled,isSchematic:!0};return this._materials[0]?.setParameters(t),this._materials[1]?.setParameters(t),!0}_getExtrusionSize(t){let e;return e=t.size&&this._drivenProperties.size?A(t.size,2)??0:this._getSymbolSize(),e/=this._context.renderCoordsHelper.unitInMeters,e}applyRendererDiff(t,e){return this._drivenPropertiesChanged(e)?0:1}async queryForSnapping(r,s,o,n){const i=this._getExtrusionSize(o)*this._context.renderCoordsHelper.unitInMeters/e(s),{objectId:a,target:l}=r,c=t(l);switch(c.z=(c.z??0)+i,r.type){case"edge":{const{start:e,end:s}=r,o=t(e),n=t(s);return o.z=(o.z??0)+i,n.z=(n.z??0)+i,[new E(a,c,1/0,o,n)]}case"vertex":return[new C(a,c,1/0),new E(a,l,1/0,l,c)];default:return[]}}_getSymbolSize(){return this.symbolLayer.size??1}_createAs3DShape(t,e,i,l,c){const p=M(t.geometry);if(null==p)return null;if(0===p.rings.length||!p.rings.some(t=>t.length>0))return this._logGeometryValidationWarnings(p.rings,"rings","ExtrudeSymbol3DLayer"),null;const m=R(p,this._context.elevationProvider,this._context.renderCoordsHelper,l);this._logGeometryCreationWarnings(m,p.rings,"rings","ExtrudeSymbol3DLayer");const h=O(p);if(null==h)return null;const u=new Array,d=new Array,g=_(),f=a(),P=y(),C=1===this._context.renderCoordsHelper.viewingMode;C||this._context.renderCoordsHelper.worldUpAtPosition(null,P),b(p.spatialReference,[h.x,h.y,0],f,this._context.renderCoordsHelper.spatialReference);const E=a();n(E,f);const A=o();s(A,E);const{polygons:I,mapPositions:z,position:V}=m,T=new Map,B=this._materials[0];for(const s of I){const t=s.count;if(this._context.clippingExtent&&(x(s.mapPositions,g),!j(g,this._context.clippingExtent)))continue;const o=r(s.mapPositions,s.holeIndices,3);if(0===o.length)continue;const n=o.length,a=6*t,l=w(a+n),p=w(n),m=S(3*a),h=S(3*a),y=S(3*a),b=S(a);X(V,z,o,s,m,y,h,b,l,p,this._getExtrusionSize(e),P,C),v(m,m,E);const _=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:c,layerViewUid:this._context.layerViewUid}),A=new jt(m,y,N(h),b),D=Q(B,l,l.length-p.length,A,i,_),I=t,L=t,U=2*s.count,O=new St(I,L,U,n/3);pt(D,O,f),T.set(D,O),u.push(D,Q(this._materials[1],p,0,A,i,_)),d.push(A.heights)}if(0===u.length)return null;const F=new q({geometries:u,layerViewUid:this._context.layerViewUid,graphicUid:c,isElevationSource:!0});F.transformation=f;const H=G(this.symbolLayer,{opacity:this._getLayerOpacity()}),k=H?new L(this._materials[0],H,this._context.slicePlaneEnabled):null,W=new U(this,F,null,(t,e,r,s,o)=>ct(t,e,r,s,o,d,T),l,k);return W.alignedSampledElevation=m.sampledElevation,W.needsElevationUpdates=D(l.mode),W}get _materialColor(){return this.symbolLayer.material?.color}_updateTransparentDepedentMaterialParameters(){const t=this._materials[0];t&&t.setParameters({cullFace:t.transparent?0:2})}}function Q(t,e,r,s,o,n){const i=P(e.length),a=[["position",new F(s.positions,e,3,!0)],["normalCompressed",new F(s.normals,e,2,!0)],["symbolColor",new F(o,i,4,!0)]];return new H(t,a,s.elevation,0,n,r)}function X(t,e,r,s,o,n,i,a,l,c,p,m,h){const u=r.length/3;let d=2*s.count;Y(t,e,s.index,s.count,r,0,u,o,n,i,a,l,c,d,p,m,h);let g=0,f=2*s.count;d=0;const y=s.pathLengths[0];et(o,n,a,i,g,y,s.count,f,l,d,p),f+=4*y,d+=2*y,g+=y;for(let b=1;b<s.pathLengths.length;++b){const t=s.pathLengths[b];et(o,n,a,i,g,t,s.count,f,l,d,p),f+=4*t,d+=2*t,g+=t}}function Y(t,e,r,s,o,n,i,a,l,c,p,m,u,g,f,y,b){d(ut,y),l??=[],c??=[],p??=[];const _=f>0?1:-1;let x=3*r,j=0,S=3*j,w=s,P=3*w;for(let d=0;d<s;++d){const r=t[x],s=t[x+1],o=t[x+2];b&&(ut[0]=r,ut[1]=s,ut[2]=o,h(ut,ut)),a[S+0]=r,a[S+1]=s,a[S+2]=o;const n=e[x+0],i=e[x+1],m=e[x+2];l[S+0]=n,l[S+1]=i,l[S+2]=m,c[S+0]=-_*ut[0],c[S+1]=-_*ut[1],c[S+2]=-_*ut[2],p[j]=0,a[P+0]=r+f*ut[0],a[P+1]=s+f*ut[1],a[P+2]=o+f*ut[2],l[P+0]=n,l[P+1]=i,l[P+2]=m,p[w]=f,S+=3,P+=3,x+=3,j+=1,w+=1}x=3*n,S=0,P=3*g;const v=f<0?ft:gt,C=f<0?gt:ft;for(let h=0;h<i;++h)u[S]=o[x+v[0]],u[S+1]=o[x+v[1]],u[S+2]=o[x+v[2]],m[P]=o[x+C[0]]+s,m[P+1]=o[x+C[1]]+s,m[P+2]=o[x+C[2]]+s,S+=3,P+=3,x+=3}function $(t,e,r,s,o,n,i){s[n]=s[i],i*=3,t[n*=3]=t[i],t[n+1]=t[i+1],t[n+2]=t[i+2],e[n]=e[i],e[n+1]=e[i+1],e[n+2]=e[i+2],r[n]=o[0],r[n+1]=o[1],r[n+2]=o[2]}const tt=y();function et(t,e,r,s,o,n,i,a,l,c,p){e??=[],r??=[],s??=[];let m=o,h=o+1,u=o+i,d=o+i+1,g=a,f=a+1,y=a+2*n,b=a+2*n+1;p<0&&(m=o+i+1,d=o);let _=3*c;for(let x=0;x<n;++x)x===n-1&&(h=o,p>0?d=o+i:m=o+i),at(t,m,h,u,tt),$(t,e,s,r,tt,g,m),$(t,e,s,r,tt,f,h),$(t,e,s,r,tt,y,u),$(t,e,s,r,tt,b,d),l[_]=g,l[_+1]=y,l[_+2]=b,l[_+3]=g,l[_+4]=b,l[_+5]=f,_+=6,m++,h++,u++,d++,g+=2,f+=2,y+=2,b+=2}const rt=y(),st=y(),ot=y(),nt=y(),it=y();function at(t,e,r,s,o){e*=3,r*=3,s*=3,l(rt,t[e++],t[e++],t[e++]),l(st,t[r++],t[r++],t[r++]),l(ot,t[s++],t[s++],t[s++]),g(nt,st,rt),g(it,ot,rt),p(o,it,nt),h(o,o)}const lt=y();function ct(t,e,r,s,o,n,c){const p=t.stageObject,m=p.geometries,h=m.length,d="absolute-height"!==e.mode;let g=0;const f=p.transformation,y=i(a(),f);for(let i=0;i<h;i+=2){const t=m[i];if(!k(t))continue;const e=t.getMutableAttribute("position").data,a=n[i/2],h=new B(t.mapPositions),b=e.length/3;let _=!1,x=0;{let t=0;for(let n=0;n<b;n++){lt[0]=e[t],lt[1]=e[t+1],lt[2]=e[t+2],s(h,dt),d&&(x+=dt.sampledElevation),T.TESTS_DISABLE_OPTIMIZATIONS?(l(ht,h.array[h.offset],h.array[h.offset+1],dt.z+a[t/3]),null!=r&&o.toRenderCoords(ht,r,ht),u(ht,ht,y)):(l(ht,e[t],e[t+1],e[t+2]),u(ht,ht,f),o.setAltitude(ht,dt.z+a[t/3]),u(ht,ht,y)),e[t]=ht[0],e[t+1]=ht[1],e[t+2]=ht[2];const n=yt/o.unitInMeters;(Math.abs(lt[0]-e[t])>=n||Math.abs(lt[1]-e[t+1])>=n||Math.abs(lt[2]-e[t+2])>=n)&&(_=!0),h.offset+=3,t+=3}}if(_){const e=c.get(t);e&&pt(t,e,f),p.geometryVertexAttributeUpdated(m[i],"normalCompressed"),t.invalidateBoundingInfo(),p.geometryVertexAttributeUpdated(m[i],"position"),m[i+1].invalidateBoundingInfo(),p.geometryVertexAttributeUpdated(m[i+1],"position")}g+=x/b}return g/h}function pt(t,e,r){const s=t.getMutableAttribute("position"),o=t.getMutableAttribute("normalCompressed").data,n=s.data,i=t.attributes.get("position").indices,{topVertexStart:a,topVertexCount:d,topFaceStart:g,topFaceCount:f}=e,y=g+f,b=a+d,_=bt,x=_t,j=xt,S=ut,w=ht;l(w,0,0,0);const P=(t,e)=>{const s=3*t;l(e,n[s+0],n[s+1],n[s+2]),u(e,e,r)};for(let l=g;l<y;++l){const t=3*l;P(i[t+0],_[0]),P(i[t+1],_[1]),P(i[t+2],_[2]),c(x,_[1],_[0]),c(j,_[2],_[0]),p(S,x,j),m(w,w,S)}h(w,w);for(let l=a;l<b;++l){const t=w[0],e=w[1],r=w[2];W(o,l,t,e,r)}}function mt(t){return 1===(t.material?.color?.a??0)}const ht=y(),ut=y(),dt=new I,gt=[0,2,1],ft=[0,1,2],yt=.01,bt=[y(),y(),y()],_t=y(),xt=y();class jt{constructor(t,e,r,s){this.positions=t,this.elevation=e,this.normals=r,this.heights=s}}class St{constructor(t,e,r,s){this.topVertexStart=t,this.topVertexCount=e,this.topFaceStart=r,this.topFaceCount=s}}export{K as Graphics3DExtrudeSymbolLayer,X as extrudePolygon};
5
+ import"../../../../core/has.js";import{clone as t}from"../../../../core/lang.js";import{getMetersPerVerticalUnitForSR as e}from"../../../../core/units.js";import{e as r}from"../../../../chunks/earcut.js";import{normalFromMat4 as s}from"../../../../core/libs/gl-matrix-2/math/mat3.js";import{create as o}from"../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{invert as n,invertOrIdentity as i}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as a}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{h as l,a as c,f as p,i as m,n as h,p as u,d,e as g}from"../../../../chunks/vec32.js";import{ONES as f,create as y}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{computeTranslationToOriginAndRotation as b}from"../../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{create as _,fromBuffer as x,intersectsClippingArea as j}from"../../../../geometry/support/aaBoundingBox.js";import{newDoubleArray as S}from"../../../../geometry/support/DoubleArray.js";import{newIndexArray as w,getZeroIndexArray as P}from"../../../../geometry/support/Indices.js";import{t as v}from"../../../../chunks/vec3.js";import{SnappingCandidateVertex as C,SnappingCandidateEdge as E}from"../../../../layers/graphics/data/SnappingCandidate.js";import{getDriverAxisSizeValue as A}from"../../../../renderers/support/renderingInfoUtils.js";import{needsElevationUpdates3D as D,SampleElevationInfo as I}from"./elevationAlignmentUtils.js";import{Object3DEdgeState as L,Graphics3DObject3DGraphicLayer as U}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as z}from"./Graphics3DSymbolLayer.js";import{computeCentroid as O}from"./graphicUtils.js";import{geometryAsPolygon as M}from"./polygonUtils.js";import{createMaterial as G}from"../support/edgeUtils.js";import{encodeNaNUInt8 as V}from"../support/symbolColorUtils.js";import{debugFlags as T}from"../../support/debugFlags.js";import{SamplePosition as B}from"../../support/ElevationProvider.js";import{polygonToRenderInfo as F}from"../../support/renderInfoUtils/polygon.js";import{Attribute as R}from"../../webgl-engine/lib/Attribute.js";import{Geometry as H}from"../../webgl-engine/lib/Geometry.js";import{isGeometryWithMapPositions as k}from"../../webgl-engine/lib/GeometryWithMapPositions.js";import{compressNormals as N,compressNormal as W}from"../../webgl-engine/lib/Normals.js";import{Object3D as q}from"../../webgl-engine/lib/Object3D.js";import{DefaultMaterial as Z}from"../../webgl-engine/materials/DefaultMaterial.js";const J=["polygon","extent"];class K extends z{constructor(t,e,r,s){super(t,e,r,s,mt(e)),this.ensureDrapedStatus(!1)}async doLoad(){const t=this.symbolLayer,e=t?.material,r=this.symbolLayer.material?.color?.a,s=this.needsDrivenTransparentPass||null!=r&&1!==r,o=e?.emissive,n=!this._hasDrivenColorOrOpacity&&(null==r||0===r),i={usePBR:this._context.physicalBasedRenderingEnabled,isSchematic:!0,ambient:f,diffuse:f,opacity:n?0:1,layerOpacity:this._getLayerOpacity(),drivenOpacity:s,hasSymbolColors:!0,hasSlicePlane:this._context.slicePlaneEnabled,castShadows:t.castShadows,emissiveStrengthFromSymbol:o?.strength??0,emissiveSource:1,offsetTransparentBackfaces:!0,normalType:1},a=new Z(i,this._context),l=new Z({...i,cullFace:2},this._context);this._materials[0]=a,this._materials[1]=l,this._updateTransparentDepedentMaterialParameters()}destroy(){super.destroy(),this._materials.length=0}createGraphics3DGraphic(t){const e=t.graphic;if(!this._validateGeometry(e.geometry,J,this.symbolLayer.type))return null;const r=this._getDrivenUInt8ColorWithNaNSupport(t.renderingInfo,this._materialColor,!1);V(r,r);const s=this.createElevationContextForGraphic(e);return this._createAs3DShape(e,t.renderingInfo,r,s,e.uid)}layerOpacityChanged(t,e){const r=this._getLayerOpacity();this._materials[0]?.setParameters({layerOpacity:r}),this._materials[1]?.setParameters({layerOpacity:r}),this._updateTransparentDepedentMaterialParameters(),t?.forEach(t=>e(t)?.layerOpacityChanged(r,this._context.isAsync))}layerScreenSizePerspectiveChanged(){}layerElevationInfoChanged(t,e){return this.updateGraphics3DGraphicElevationInfo(t,e,D)}slicePlaneEnabledChanged(t,e){return this._materials[0]?.setParameters({hasSlicePlane:this._context.slicePlaneEnabled}),this._materials[1]?.setParameters({hasSlicePlane:this._context.slicePlaneEnabled}),t?.forEach(t=>{const r=e(t);null!=r&&r.slicePlaneEnabledChanged(this._context.slicePlaneEnabled,this._context.isAsync)}),!0}physicalBasedRenderingChanged(){const t={usePBR:this._context.physicalBasedRenderingEnabled,isSchematic:!0};return this._materials[0]?.setParameters(t),this._materials[1]?.setParameters(t),!0}_getExtrusionSize(t){let e;return e=t.size&&this._drivenProperties.size?A(t.size,2)??0:this._getSymbolSize(),e/=this._context.renderCoordsHelper.unitInMeters,e}applyRendererDiff(t,e){return this._drivenPropertiesChanged(e)?0:1}async queryForSnapping(r,s,o,n){const i=this._getExtrusionSize(o)*this._context.renderCoordsHelper.unitInMeters/e(s),{objectId:a,target:l}=r,c=t(l);switch(c.z=(c.z??0)+i,r.type){case"edge":{const{start:e,end:s}=r,o=t(e),n=t(s);return o.z=(o.z??0)+i,n.z=(n.z??0)+i,[new E(a,c,1/0,o,n)]}case"vertex":return[new C(a,c,1/0),new E(a,l,1/0,l,c)];default:return[]}}_getSymbolSize(){return this.symbolLayer.size??1}_createAs3DShape(t,e,i,l,c){const p=M(t.geometry);if(null==p)return null;if(0===p.rings.length||!p.rings.some(t=>t.length>0))return this._logGeometryValidationWarnings(p.rings,"rings","ExtrudeSymbol3DLayer"),null;const m=F(p,this._context.elevationProvider,this._context.renderCoordsHelper,l);this._logGeometryCreationWarnings(m,p.rings,"rings","ExtrudeSymbol3DLayer");const h=O(p);if(null==h)return null;const u=new Array,d=new Array,g=_(),f=a(),P=y(),C=1===this._context.renderCoordsHelper.viewingMode;C||this._context.renderCoordsHelper.worldUpAtPosition(null,P),b(p.spatialReference,[h.x,h.y,0],f,this._context.renderCoordsHelper.spatialReference);const E=a();n(E,f);const A=o();s(A,E);const{polygons:I,mapPositions:z,position:V}=m,T=new Map,B=this._materials[0];for(const s of I){const t=s.count;if(this._context.clippingExtent&&(x(s.mapPositions,g),!j(g,this._context.clippingExtent)))continue;const o=r(s.mapPositions,s.holeIndices,3);if(0===o.length)continue;const n=o.length,a=6*t,l=w(a+n),p=w(n),m=S(3*a),h=S(3*a),y=S(3*a),b=S(a);X(V,z,o,s,m,y,h,b,l,p,this._getExtrusionSize(e),P,C),v(m,m,E);const _=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:c,layerViewUid:this._context.layerViewUid}),A=new jt(m,y,N(h),b),D=Q(B,l,l.length-p.length,A,i,_),I=t,L=t,U=2*s.count,O=new St(I,L,U,n/3);pt(D,O,f),T.set(D,O),u.push(D,Q(this._materials[1],p,0,A,i,_)),d.push(A.heights)}if(0===u.length)return null;const R=new q({geometries:u,layerViewUid:this._context.layerViewUid,graphicUid:c,isElevationSource:!0});R.transformation=f;const H=G(this.symbolLayer,{opacity:this._getLayerOpacity()}),k=H?new L(this._materials[0],H,this._context.slicePlaneEnabled):null,W=new U(this,R,null,(t,e,r,s,o)=>ct(t,e,r,s,o,d,T),l,k);return W.alignedSampledElevation=m.sampledElevation,W.needsElevationUpdates=D(l.mode),W}get _materialColor(){return this.symbolLayer.material?.color}_updateTransparentDepedentMaterialParameters(){const t=this._materials[0];t&&t.setParameters({cullFace:t.transparent?0:2})}}function Q(t,e,r,s,o,n){const i=P(e.length),a=[["position",new R(s.positions,e,3,!0)],["normalCompressed",new R(s.normals,e,2,!0)],["symbolColor",new R(o,i,4,!0)]];return new H(t,a,s.elevation,0,n,r)}function X(t,e,r,s,o,n,i,a,l,c,p,m,h){const u=r.length/3;let d=2*s.count;Y(t,e,s.index,s.count,r,0,u,o,n,i,a,l,c,d,p,m,h);let g=0,f=2*s.count;d=0;const y=s.pathLengths[0];et(o,n,a,i,g,y,s.count,f,l,d,p),f+=4*y,d+=2*y,g+=y;for(let b=1;b<s.pathLengths.length;++b){const t=s.pathLengths[b];et(o,n,a,i,g,t,s.count,f,l,d,p),f+=4*t,d+=2*t,g+=t}}function Y(t,e,r,s,o,n,i,a,l,c,p,m,u,g,f,y,b){d(ut,y),l??=[],c??=[],p??=[];const _=f>0?1:-1;let x=3*r,j=0,S=3*j,w=s,P=3*w;for(let d=0;d<s;++d){const r=t[x],s=t[x+1],o=t[x+2];b&&(ut[0]=r,ut[1]=s,ut[2]=o,h(ut,ut)),a[S+0]=r,a[S+1]=s,a[S+2]=o;const n=e[x+0],i=e[x+1],m=e[x+2];l[S+0]=n,l[S+1]=i,l[S+2]=m,c[S+0]=-_*ut[0],c[S+1]=-_*ut[1],c[S+2]=-_*ut[2],p[j]=0,a[P+0]=r+f*ut[0],a[P+1]=s+f*ut[1],a[P+2]=o+f*ut[2],l[P+0]=n,l[P+1]=i,l[P+2]=m,p[w]=f,S+=3,P+=3,x+=3,j+=1,w+=1}x=3*n,S=0,P=3*g;const v=f<0?ft:gt,C=f<0?gt:ft;for(let h=0;h<i;++h)u[S]=o[x+v[0]],u[S+1]=o[x+v[1]],u[S+2]=o[x+v[2]],m[P]=o[x+C[0]]+s,m[P+1]=o[x+C[1]]+s,m[P+2]=o[x+C[2]]+s,S+=3,P+=3,x+=3}function $(t,e,r,s,o,n,i){s[n]=s[i],i*=3,t[n*=3]=t[i],t[n+1]=t[i+1],t[n+2]=t[i+2],e[n]=e[i],e[n+1]=e[i+1],e[n+2]=e[i+2],r[n]=o[0],r[n+1]=o[1],r[n+2]=o[2]}const tt=y();function et(t,e,r,s,o,n,i,a,l,c,p){e??=[],r??=[],s??=[];let m=o,h=o+1,u=o+i,d=o+i+1,g=a,f=a+1,y=a+2*n,b=a+2*n+1;p<0&&(m=o+i+1,d=o);let _=3*c;for(let x=0;x<n;++x)x===n-1&&(h=o,p>0?d=o+i:m=o+i),at(t,m,h,u,tt),$(t,e,s,r,tt,g,m),$(t,e,s,r,tt,f,h),$(t,e,s,r,tt,y,u),$(t,e,s,r,tt,b,d),l[_]=g,l[_+1]=y,l[_+2]=b,l[_+3]=g,l[_+4]=b,l[_+5]=f,_+=6,m++,h++,u++,d++,g+=2,f+=2,y+=2,b+=2}const rt=y(),st=y(),ot=y(),nt=y(),it=y();function at(t,e,r,s,o){e*=3,r*=3,s*=3,l(rt,t[e++],t[e++],t[e++]),l(st,t[r++],t[r++],t[r++]),l(ot,t[s++],t[s++],t[s++]),g(nt,st,rt),g(it,ot,rt),p(o,it,nt),h(o,o)}const lt=y();function ct(t,e,r,s,o,n,c){const p=t.stageObject,m=p.geometries,h=m.length,d="absolute-height"!==e.mode;let g=0;const f=p.transformation,y=i(a(),f);for(let i=0;i<h;i+=2){const t=m[i];if(!k(t))continue;const e=t.getMutableAttribute("position").data,a=n[i/2],h=new B(t.mapPositions),b=e.length/3;let _=!1,x=0;{let t=0;for(let n=0;n<b;n++){lt[0]=e[t],lt[1]=e[t+1],lt[2]=e[t+2],s(h,dt),d&&(x+=dt.sampledElevation),T.TESTS_DISABLE_OPTIMIZATIONS?(l(ht,h.array[h.offset],h.array[h.offset+1],dt.z+a[t/3]),null!=r&&o.toRenderCoords(ht,r,ht),u(ht,ht,y)):(l(ht,e[t],e[t+1],e[t+2]),u(ht,ht,f),o.setAltitude(ht,dt.z+a[t/3]),u(ht,ht,y)),e[t]=ht[0],e[t+1]=ht[1],e[t+2]=ht[2];const n=yt/o.unitInMeters;(Math.abs(lt[0]-e[t])>=n||Math.abs(lt[1]-e[t+1])>=n||Math.abs(lt[2]-e[t+2])>=n)&&(_=!0),h.offset+=3,t+=3}}if(_){const e=c.get(t);e&&pt(t,e,f),p.geometryVertexAttributeUpdated(m[i],"normalCompressed"),t.invalidateBoundingInfo(),p.geometryVertexAttributeUpdated(m[i],"position"),m[i+1].invalidateBoundingInfo(),p.geometryVertexAttributeUpdated(m[i+1],"position")}g+=x/b}return g/h}function pt(t,e,r){const s=t.getMutableAttribute("position"),o=t.getMutableAttribute("normalCompressed").data,n=s.data,i=t.attributes.get("position").indices,{topVertexStart:a,topVertexCount:d,topFaceStart:g,topFaceCount:f}=e,y=g+f,b=a+d,_=bt,x=_t,j=xt,S=ut,w=ht;l(w,0,0,0);const P=(t,e)=>{const s=3*t;l(e,n[s+0],n[s+1],n[s+2]),u(e,e,r)};for(let l=g;l<y;++l){const t=3*l;P(i[t+0],_[0]),P(i[t+1],_[1]),P(i[t+2],_[2]),c(x,_[1],_[0]),c(j,_[2],_[0]),p(S,x,j),m(w,w,S)}h(w,w);for(let l=a;l<b;++l){const t=w[0],e=w[1],r=w[2];W(o,l,t,e,r)}}function mt(t){return 1===(t.material?.color?.a??0)}const ht=y(),ut=y(),dt=new I,gt=[0,2,1],ft=[0,1,2],yt=.01,bt=[y(),y(),y()],_t=y(),xt=y();class jt{constructor(t,e,r,s){this.positions=t,this.elevation=e,this.normals=r,this.heights=s}}class St{constructor(t,e,r,s){this.topVertexStart=t,this.topVertexCount=e,this.topFaceStart=r,this.topFaceCount=s}}export{K as Graphics3DExtrudeSymbolLayer,X as extrudePolygon};