@arcgis/core 5.0.0-next.17 → 5.0.0-next.18

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 (95) hide show
  1. package/assets/esri/core/workers/RemoteClient.js +1 -1
  2. package/assets/esri/core/workers/chunks/{adf7ccf4ef629211c7ee.js → 08aacbfb651cc2e1c054.js} +1 -1
  3. package/assets/esri/core/workers/chunks/{658cd45b5fb304fd840a.js → 3aa77696c5ea54a238da.js} +1 -1
  4. package/assets/esri/core/workers/chunks/{49571d6875de1f2e7e25.js → 4b9dfdc23ba3d6ebcc1b.js} +2 -2
  5. package/assets/esri/core/workers/chunks/{888f188541f8bd68e33e.js → 72f1c3d97e7b9546c113.js} +1 -1
  6. package/assets/esri/core/workers/chunks/{a4518f25b9f8fe704286.js → 76e945da8f30d8641c3d.js} +4 -4
  7. package/chunks/ImageMaterial.glsl.js +1 -1
  8. package/config.js +1 -1
  9. package/interfaces.d.ts +47 -28
  10. package/intl/locale.js +1 -1
  11. package/kernel.js +1 -1
  12. package/layers/Lyr3DWasmPerSceneView.js +1 -1
  13. package/package.json +1 -1
  14. package/support/revision.js +1 -1
  15. package/views/2d/LabelManager.js +1 -1
  16. package/views/2d/engine/webgl/FeatureTile.js +1 -1
  17. package/views/2d/engine/webgl/OverlayMultipoint.js +1 -1
  18. package/views/2d/engine/webgl/VideoScreenRenderer.js +1 -1
  19. package/views/2d/engine/webgl/animations/store/AnimationStore.js +1 -1
  20. package/views/2d/engine/webgl/shaderGraph/techniques/colorize/ColorizeTechnique.js +1 -1
  21. package/views/2d/engine/webgl/shaderGraph/techniques/dotDensity/DotDensityResources.js +1 -1
  22. package/views/2d/engine/webgl/shaderGraph/techniques/drop-shadow/DropShadowTechnique.js +1 -1
  23. package/views/2d/engine/webgl/shaderGraph/techniques/opacity/OpacityTechnique.js +1 -1
  24. package/views/2d/engine/webgl/shaderGraph/techniques/raster/RasterColorizerTechnique.js +1 -1
  25. package/views/2d/engine/webgl/shaderGraph/techniques/raster/RasterHighlightTechnique.js +1 -1
  26. package/views/2d/engine/webgl/textureUtils.js +1 -1
  27. package/views/2d/layers/features/FeatureContainer.js +1 -1
  28. package/views/3d/GroundView3D.js +1 -1
  29. package/views/3d/analysis/Dimension/LengthDimensionSubTool.js +1 -1
  30. package/views/3d/analysis/Slice/RotateManipulator.js +1 -1
  31. package/views/3d/analysis/images/Factory.js +1 -1
  32. package/views/3d/environment/ChapmanAtmosphere.js +1 -1
  33. package/views/3d/environment/EnvironmentManager.js +1 -1
  34. package/views/3d/layers/BuildingComponentSublayerView3D.js +1 -1
  35. package/views/3d/layers/DrapedSubView3D.js +1 -1
  36. package/views/3d/layers/FlowSubView3D.js +1 -1
  37. package/views/3d/layers/IntegratedMesh3DTilesLayerView3D.js +1 -1
  38. package/views/3d/layers/IntegratedMeshLayerView3D.js +1 -1
  39. package/views/3d/layers/MediaLayerView3D.js +1 -1
  40. package/views/3d/layers/PointCloudLayerView3D.js +1 -1
  41. package/views/3d/layers/SceneLayerGraphicsView3D.js +1 -1
  42. package/views/3d/layers/SceneLayerView3D.js +1 -1
  43. package/views/3d/layers/graphics/Graphics3DIconSymbolLayer.js +1 -1
  44. package/views/3d/layers/graphics/Graphics3DMeshFillSymbolLayer.js +1 -1
  45. package/views/3d/layers/graphics/Graphics3DTextSymbolLayer.js +1 -1
  46. package/views/3d/layers/graphics/objectResourceUtils.js +1 -1
  47. package/views/3d/layers/graphics/pipeline/rendering/FeaturePipelineRenderManager.js +1 -1
  48. package/views/3d/layers/graphics/wosrLoader.js +1 -1
  49. package/views/3d/layers/i3s/I3SMaterialUtil.js +1 -1
  50. package/views/3d/support/QualityProfile.js +5 -0
  51. package/views/3d/support/QualitySettings.js +1 -1
  52. package/views/3d/support/StreamTextureCollection.js +1 -1
  53. package/views/3d/support/TextureCollection.js +1 -1
  54. package/views/3d/support/engineContent/marker.js +1 -1
  55. package/views/3d/support/engineContent/sdfPrimitives.js +1 -1
  56. package/views/3d/support/gaussianSplatting/GaussianSplatOrderTexture.js +1 -1
  57. package/views/3d/terrain/OverlayRenderer.js +1 -1
  58. package/views/3d/terrain/TerrainSurface.js +1 -1
  59. package/views/3d/terrain/TileCompositor.js +1 -1
  60. package/views/3d/webgl-engine/Stage.js +1 -1
  61. package/views/3d/webgl-engine/collections/Component/ComponentObjectCollection.js +1 -1
  62. package/views/3d/webgl-engine/collections/Component/Material/ComponentMaterial.js +1 -1
  63. package/views/3d/webgl-engine/collections/Component/Material/ComponentTechniqueConfiguration.js +1 -1
  64. package/views/3d/webgl-engine/core/material/MaterialBase.js +1 -1
  65. package/views/3d/webgl-engine/core/material/RenderTexture.js +1 -1
  66. package/views/3d/webgl-engine/effects/haze/Haze.js +1 -1
  67. package/views/3d/webgl-engine/effects/smaa/SMAA.js +1 -1
  68. package/views/3d/webgl-engine/effects/ssao/SSAO.js +1 -1
  69. package/views/3d/webgl-engine/lib/AnimationTimeStep.js +1 -1
  70. package/views/3d/webgl-engine/lib/BasisUtil.js +1 -1
  71. package/views/3d/webgl-engine/lib/DDSUtil.js +1 -1
  72. package/views/3d/webgl-engine/lib/GLTextureMaterial.js +1 -1
  73. package/views/3d/webgl-engine/lib/ManagedTexture.js +5 -0
  74. package/views/3d/webgl-engine/lib/OrderIndependentTransparency.js +1 -1
  75. package/views/3d/webgl-engine/lib/RenderFeature.js +1 -1
  76. package/views/3d/webgl-engine/lib/Renderer.js +1 -1
  77. package/views/3d/webgl-engine/lib/TextTextureAtlas.js +1 -1
  78. package/views/3d/webgl-engine/lib/TextTextureFactory.js +1 -1
  79. package/views/3d/webgl-engine/lib/TextureRepository.js +1 -1
  80. package/views/3d/webgl-engine/lib/glUtil3D.js +1 -1
  81. package/views/3d/webgl-engine/materials/ImageMaterial.js +1 -1
  82. package/views/3d/webgl-engine/materials/internal/WaterTextureRepository.js +1 -1
  83. package/views/3d/webgl-engine/materials/stippleTextureRepository.js +1 -1
  84. package/views/3d/webgl-engine/parts/RenderView.js +1 -1
  85. package/views/GroundView.js +1 -1
  86. package/views/SceneView.js +1 -1
  87. package/views/support/layerViewUtils.js +1 -1
  88. package/views/webgl/Texture.js +1 -1
  89. package/views/webgl/testSVGPremultipliedAlpha.js +1 -1
  90. package/widgets/FeatureForm/FeatureFormUtilityNetworkAssociations/FeatureFormUtilityNetworkAssociationList.js +1 -1
  91. package/widgets/FeatureForm/FeatureFormUtilityNetworkAssociations/UtilityNetworkAssociationSettings.js +1 -1
  92. package/widgets/support/UtilityNetworkAssociations/FeatureUtilityNetworkAssociationsViewModel.js +1 -1
  93. package/views/3d/support/DisplayQualityProfile.js +0 -5
  94. package/views/3d/webgl-engine/lib/Texture.js +0 -5
  95. /package/views/3d/webgl-engine/lib/{ITexture.js → IManagedTexture.js} +0 -0
@@ -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{generateStyledTexture as t}from"./generateTextures.js";import o from"./heading-rotate-svg.js";import r from"./tilt-rotate-svg.js";import{Texture as e}from"../../webgl-engine/lib/Texture.js";const a=64;function l(r,l){const{accentColor:n,contrastColor:c,preMultiplyAlpha:i}=l;return r.fromData(`heading-rotate:[accent:${n},contrast:${c},size:${a}]`,()=>new e(t(o,{accentColor:n,contrastColor:c,size:a}),{mipmap:!0,reloadable:!0,preMultiplyAlpha:i}))}function n(o,l){const{accentColor:n,contrastColor:c,preMultiplyAlpha:i}=l;return o.fromData(`tilt-rotate:[accent:${n},contrast:${c},size:${a}]`,()=>new e(t(r,{accentColor:n,contrastColor:c,size:a}),{mipmap:!0,reloadable:!0,preMultiplyAlpha:i}))}export{l as getRotateHeadingTexture,n as getTiltRotateTexture};
5
+ import{generateStyledTexture as t}from"./generateTextures.js";import o from"./heading-rotate-svg.js";import r from"./tilt-rotate-svg.js";import{ManagedTexture as e}from"../../webgl-engine/lib/ManagedTexture.js";const a=64;function n(r,n){const{accentColor:l,contrastColor:c,preMultiplyAlpha:i}=n;return r.fromData(`heading-rotate:[accent:${l},contrast:${c},size:${a}]`,()=>new e(t(o,{accentColor:l,contrastColor:c,size:a}),{mipmap:!0,reloadable:!0,preMultiplyAlpha:i}))}function l(o,n){const{accentColor:l,contrastColor:c,preMultiplyAlpha:i}=n;return o.fromData(`tilt-rotate:[accent:${l},contrast:${c},size:${a}]`,()=>new e(t(r,{accentColor:l,contrastColor:c,size:a}),{mipmap:!0,reloadable:!0,preMultiplyAlpha:i}))}export{n as getRotateHeadingTexture,l as getTiltRotateTexture};
@@ -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{unitRGBAFromColor as t}from"../../../core/colorUtils.js";import{clamp as r,lerp as s}from"../../../core/mathUtils.js";import{disposeMaybe as i}from"../../../core/maybe.js";import{watch as o,syncAndInitial as a}from"../../../core/reactiveUtils.js";import"../../../core/Logger.js";import"../../../core/has.js";import"../../../core/RandomLCG.js";import"../../../core/Error.js";import{subclass as n}from"../../../core/accessorSupport/decorators/subclass.js";import{set as m}from"../../../core/libs/gl-matrix-2/math/vec2.js";import{j as h,b as c,m as p}from"../../../chunks/vec32.js";import{s as u}from"../../../chunks/vec42.js";import{ZEROS as d}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{earth as f}from"../../../geometry/support/Ellipsoid.js";import{InternalRenderCategory as l}from"../webgl.js";import{innerAtmosphereDepth as g,computeInnerAltitudeFade as b}from"./atmosphereUtils.js";import{ChapmanAtmospherePassParameters as _,ChapmanAtmosphereTechnique as j}from"./ChapmanAtmosphereTechnique.js";import{ChapmanAtmosphereTechniqueConfiguration as P}from"./ChapmanAtmosphereTechniqueConfiguration.js";import{OpaqueEnvironment as w}from"../webgl-engine/effects/OpaqueEnvironment.js";import{createQuadVAO as v}from"../webgl-engine/lib/glUtil3D.js";import{applyTextureResizeModulo as q}from"../webgl-engine/lib/textureUtils.js";import{A}from"../../../chunks/AtmosphereCompositing.glsl.js";import{AtmosphereCompositingTechnique as T}from"../webgl-engine/shaders/AtmosphereCompositingTechnique.js";import{DepthStencilAttachment as x,PrimitiveType as C}from"../../webgl/enums.js";import R from"../../../webscene/background/ColorBackground.js";let y=class extends w{constructor(){super(...arguments),this.requireGeometryDepth=!0,this._compositingPassParameters=new A,this._vao=null,this._passParameters=new _,this._configuration=new P}initialize(){this.techniques.precompile(j,this._configuration),this.techniques.precompile(T),this._configuration.reduced=!0,this.techniques.precompile(j,this._configuration),this._configuration.reduced=!1,this.addHandles([o(()=>this.view.environment.background,e=>{const r=e instanceof R?t(e.color):d;h(this._passParameters.backgroundColor,r[0]*r[3],r[1]*r[3],r[2]*r[3])},a),o(()=>this.view.stage?.renderer?.fullResolutionAtmosphere,e=>this._configuration.reduced=!e,a),o(()=>this.view.environment.atmosphereEnabled,e=>e?this._enable():this._disable(),a)])}destroy(){this._vao=i(this._vao)}render(e){const t=e.find(({name:e})=>e===l.OPAQUE_ENVIRONMENT);if(!this.bindParameters.mainDepth)return t;const r=this.renderingContext;this._vao??=v(r,1);const i=t.getAttachment(x);this._update();const o=this.techniques.get(j,this._configuration);if(!o.compiled)return this.requestRender(1),t;if(!this._configuration.reduced)return t.detachDepth(),r.bindFramebuffer(t.fbo),r.bindTechnique(o,this.bindParameters,this._passParameters),r.bindVAO(this._vao),r.drawArrays(C.TRIANGLE_STRIP,0,4),t.attachDepth(i),t;const a=this.techniques.get(T);if(!a.compiled)return this.requestRender(1),t;const n=r.getViewport(),m=this.bindParameters.camera,h=c(m.eye)-f.radius;let p;const u=f.atmosphereHeight;if(h<u){const e=Math.min(1,Math.max(0,h/u));p=s(.2,.3,e)}else{const e=Math.min(1,Math.max(0,(h-u)/(15*u)));p=s(.3,.6,e)}const d=this.renderingContext.parameters.maxTextureSize,g=q(Math.round(p*m.fullViewport[2]),d),b=q(Math.round(p*m.fullViewport[3]),d);r.setViewport(0,0,g,b);const _=this.fboCache.acquire(g,b,"chapman",5);return r.bindFramebuffer(_.fbo),r.clearFramebuffer([0,0,0,1],!0,!0),r.bindTechnique(o,this.bindParameters,this._passParameters),r.bindVAO(this._vao),r.drawArrays(C.TRIANGLE_STRIP,0,4),r.setViewport(n.x,n.y,n.width,n.height),this._compositingPassParameters.color=_.getTexture(),t.detachDepth(),r.bindFramebuffer(t.fbo),r.bindTechnique(a,this.bindParameters,this._compositingPassParameters),r.screen.draw(),t.attachDepth(i),_.release(),t}_update(){const e=this.bindParameters.camera,t=p(e.eye),s=Math.sqrt(t),i=t-this._passParameters.radii[1]**2,o=r((s-this._passParameters.radii[0])/f.atmosphereHeight,0,1);u(this._passParameters.heightParameters,s,t,i,o);const a=this.view.basemapTerrain?.getLowerBoundRadius()??0;m(this._passParameters.radii,a,a+f.atmosphereHeight),this._passParameters.innerFadeDistance=2*Math.sqrt((2*a-g)*g),this._passParameters.altitudeFade=b(s-a)}};y=e([n("esri.views.3d.environment.ChapmanAtmosphere")],y);export{y as ChapmanAtmosphere};
5
+ import{__decorate as e}from"tslib";import{unitRGBAFromColor as t}from"../../../core/colorUtils.js";import{clamp as r,lerp as s}from"../../../core/mathUtils.js";import{disposeMaybe as i}from"../../../core/maybe.js";import{watch as o,syncAndInitial as a}from"../../../core/reactiveUtils.js";import"../../../core/Logger.js";import"../../../core/has.js";import"../../../core/RandomLCG.js";import"../../../core/Error.js";import{subclass as n}from"../../../core/accessorSupport/decorators/subclass.js";import{set as m}from"../../../core/libs/gl-matrix-2/math/vec2.js";import{j as h,b as c,m as p}from"../../../chunks/vec32.js";import{s as d}from"../../../chunks/vec42.js";import{ZEROS as u}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{earth as f}from"../../../geometry/support/Ellipsoid.js";import{InternalRenderCategory as l}from"../webgl.js";import{innerAtmosphereDepth as g,computeInnerAltitudeFade as b}from"./atmosphereUtils.js";import{ChapmanAtmospherePassParameters as _,ChapmanAtmosphereTechnique as j}from"./ChapmanAtmosphereTechnique.js";import{ChapmanAtmosphereTechniqueConfiguration as P}from"./ChapmanAtmosphereTechniqueConfiguration.js";import{OpaqueEnvironment as w}from"../webgl-engine/effects/OpaqueEnvironment.js";import{createQuadVAO as v}from"../webgl-engine/lib/glUtil3D.js";import{applyTextureResizeModulo as q}from"../webgl-engine/lib/textureUtils.js";import{A}from"../../../chunks/AtmosphereCompositing.glsl.js";import{AtmosphereCompositingTechnique as T}from"../webgl-engine/shaders/AtmosphereCompositingTechnique.js";import{DepthStencilAttachment as x,PrimitiveType as C}from"../../webgl/enums.js";import R from"../../../webscene/background/ColorBackground.js";let y=class extends w{constructor(){super(...arguments),this.requireGeometryDepth=!0,this._compositingPassParameters=new A,this._vao=null,this._passParameters=new _,this._configuration=new P}initialize(){this.techniques.precompile(j,this._configuration),this.techniques.precompile(T),this._configuration.reduced=!0,this.techniques.precompile(j,this._configuration),this._configuration.reduced=!1,this.addHandles([o(()=>this.view.environment.background,e=>{const r=e instanceof R?t(e.color):u;h(this._passParameters.backgroundColor,r[0]*r[3],r[1]*r[3],r[2]*r[3])},a),o(()=>this.view.stage?.renderer?.highResolutionAtmosphere,e=>this._configuration.reduced=!e,a),o(()=>this.view.environment.atmosphereEnabled,e=>e?this._enable():this._disable(),a)])}destroy(){this._vao=i(this._vao)}render(e){const t=e.find(({name:e})=>e===l.OPAQUE_ENVIRONMENT);if(!this.bindParameters.mainDepth)return t;const r=this.renderingContext;this._vao??=v(r,1);const i=t.getAttachment(x);this._update();const o=this.techniques.get(j,this._configuration);if(!o.compiled)return this.requestRender(1),t;if(!this._configuration.reduced)return t.detachDepth(),r.bindFramebuffer(t.fbo),r.bindTechnique(o,this.bindParameters,this._passParameters),r.bindVAO(this._vao),r.drawArrays(C.TRIANGLE_STRIP,0,4),t.attachDepth(i),t;const a=this.techniques.get(T);if(!a.compiled)return this.requestRender(1),t;const n=r.getViewport(),m=this.bindParameters.camera,h=c(m.eye)-f.radius;let p;const d=f.atmosphereHeight;if(h<d){const e=Math.min(1,Math.max(0,h/d));p=s(.2,.3,e)}else{const e=Math.min(1,Math.max(0,(h-d)/(15*d)));p=s(.3,.6,e)}const u=this.renderingContext.parameters.maxTextureSize,g=q(Math.round(p*m.fullViewport[2]),u),b=q(Math.round(p*m.fullViewport[3]),u);r.setViewport(0,0,g,b);const _=this.fboCache.acquire(g,b,"chapman",5);return r.bindFramebuffer(_.fbo),r.clearFramebuffer([0,0,0,1],!0,!0),r.bindTechnique(o,this.bindParameters,this._passParameters),r.bindVAO(this._vao),r.drawArrays(C.TRIANGLE_STRIP,0,4),r.setViewport(n.x,n.y,n.width,n.height),this._compositingPassParameters.color=_.getTexture(),t.detachDepth(),r.bindFramebuffer(t.fbo),r.bindTechnique(a,this.bindParameters,this._compositingPassParameters),r.screen.draw(),t.attachDepth(i),_.release(),t}_update(){const e=this.bindParameters.camera,t=p(e.eye),s=Math.sqrt(t),i=t-this._passParameters.radii[1]**2,o=r((s-this._passParameters.radii[0])/f.atmosphereHeight,0,1);d(this._passParameters.heightParameters,s,t,i,o);const a=this.view.basemapTerrain?.getLowerBoundRadius()??0;m(this._passParameters.radii,a,a+f.atmosphereHeight),this._passParameters.innerFadeDistance=2*Math.sqrt((2*a-g)*g),this._passParameters.altitudeFade=b(s-a)}};y=e([n("esri.views.3d.environment.ChapmanAtmosphere")],y);export{y as ChapmanAtmosphere};
@@ -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{EventedAccessor as t}from"../../../core/Evented.js";import"../../../core/has.js";import{destroyMaybe as i}from"../../../core/maybe.js";import{watch as n,when as r,sync as o,syncAndInitial as s}from"../../../core/reactiveUtils.js";import{property as a}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as h}from"../../../core/accessorSupport/decorators/subclass.js";import{G as l,d as c,h as g,l as p}from"../../../chunks/vec32.js";import{create as m,clone as d,fromValues as u}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{isLoadedOrLoadFor as _}from"../../../geometry/projectionUtils.js";import v from"../../../geometry/SpatialReference.js";import{projectPointToVector as f}from"../../../geometry/projection/projectPointToVector.js";import{getGCSForPlanet as w}from"../../../geometry/support/planetGCSUtils.js";import{isEarth as y}from"../../../geometry/support/spatialReferenceUtils.js";import{EnvironmentRenderer as P}from"./EnvironmentRenderer.js";import{positionToTimezoneInfo as b}from"../support/earthUtils.js";import{ColorAndIntensity as T,computeColorAndIntensity as j,computeVirtualLightDirection as L,computeShadowsEnabled as G}from"../support/sunUtils.js";import{MainLight as S,AmbientLight as U,FillLight as C}from"../webgl-engine/lighting/Lightsources.js";let H=class extends t{constructor(e){super(e),this._tmpLightParameters=new T,this._defaultLightParameters=new T,this._tmpDate=new Date,this._tmpTz={hours:0,minutes:0,seconds:0},this._viewHandlesKey="viewHandles",this._trackingEnabled=!1,this._mainLight=new S,this._ambientLight=new U,this._moonLight=new C,this._disableWeather=!1,this._renderer=null,this._resetReferencePosition()}destroy(){this.disconnectView()}get _view(){return this._renderer?.view}get updating(){return!!this._renderer?.updating||!this._canProjectCameraPosition}get weatherEnabled(){return this._view?.environment.atmosphereEnabled&&!this._disableWeather&&1===this._view?.state?.viewingMode&&y(this._view.spatialReference)}get _weatherAvailable(){return this.weatherEnabled&&this._renderer?.weatherAvailable}get referencePositionGeographic(){return this._referencePositionGeographic}get _canProjectCameraPosition(){const e=this._view?.stateManager?.camera?.position?.spatialReference??v.WGS84,t=w(e);return _(e,t)}connectView(e){if(this._renderer)return;this._renderer=new P({view:e});const t=()=>this._updateRenderParameters(),i=()=>this._cameraHandler();this.addHandles([n(()=>e.environment.lighting,e=>this._updateLightingHandler(e),o),n(()=>"virtual"!==e.environment.lighting.type?e.environment.lighting.date:null,e=>this._lightingDateHandler(e),o),n(()=>e.environment.lighting.directShadowsEnabled,t,o),n(()=>e.qualitySettings.ambientOcclusion,t,o),n(()=>e.qualitySettings.reflections,t,o),n(()=>e.spatialReference,()=>this._resetReferencePosition(!0),o),n(()=>[e.environment.weather.type,this.weatherEnabled],()=>this._updateLighting(null,1),o),n(()=>"snowy"===e.environment.weather.type&&e.environment.weather.snowCover,t,o),n(()=>e.environment,e=>e.setComputeWeatherAvailable(()=>this._weatherAvailable),s),n(()=>e.viewingMode,()=>this._resetReferencePosition(!0),s),n(()=>"virtual"!==e.environment.lighting.type&&e.environment.lighting.cameraTrackingEnabled,e=>this._updateCameraTracking(e),s),n(()=>e.state.camera,i,s),r(()=>this._canProjectCameraPosition,i,o)],this._viewHandlesKey),this._updateRenderParameters(),this._updateLighting(),this._cameraHandler(),this.notifyChange("updating")}disconnectView(){this.removeHandles(this._viewHandlesKey),this._resetReferencePosition(),this._renderer=i(this._renderer)}_updateLightingHandler(e){this._updateCameraTracking("virtual"!==e.type&&e.cameraTrackingEnabled),this._lightingDateHandler("virtual"!==e.type?e.date:null),this._updateRenderParameters()}_updateCameraTracking(e){if(this._trackingEnabled=e,e)this._cameraHandler();else{const e=this._view.environment.lighting;"virtual"!==e?.type&&(e.positionTimezoneInfo.autoUpdated=!1)}}_lightingDateHandler(e){const t=this._view.environment.lighting;if("virtual"!==t?.type){if(e){if(!t.positionTimezoneInfo.autoUpdated&&(this._preupdateTracking(e),null!=this._referencePositionGeographic)){const e=b(this._referencePositionGeographic,this._tmpTz);null!=e&&(t.autoUpdate(null,e),this._trackingEnabled&&(t.positionTimezoneInfo.autoUpdated=!0))}this._updateLighting(e)}}else this._updateLighting()}_preupdateTracking(e){!this._trackingEnabled&&"virtual"!==this._view.environment.lighting.type&&this._view.environment.lighting.cameraTrackingEnabled&&this._cameraHandler(e)}_cameraHandler(e=null){const t=this._view;if(!t.ready)return;const i=t.stateManager.camera;if(!i)return;const{position:n}=i,r=n.spatialReference??v.WGS84,o=w(r);if(!f(n,k,o)){if(null==this._referencePositionGeographic)return;return this._referencePositionGeographic=null,void this._updateLighting()}this._referencePositionGeographic?l(this._referencePositionGeographic,k)||(c(this._referencePositionGeographic,k),this.notifyChange("referencePositionGeographic")):this._referencePositionGeographic=d(k),this._autoUpdateTimezone(this._referencePositionGeographic,e)||this._updateLighting(e)}_updateLighting(e,t=0){const i=this._view,{lighting:n}=i.environment,r="virtual"===n.type,o=this._referencePositionGeographic,s=null!=o?this._tmpLightParameters:this._defaultLightParameters;if(o){e??=r?null:n.date;const t=this._weatherAvailable?i.environment.weather.type:"disabled";j(e,o,i.state.viewingMode,t,i.state.camera,s)}else r&&L(i.state.camera,i.state.viewingMode,s.direct.directionToLightSource);const a=this._mainLight,h=s.direct;g(a.intensity,h.color,h.intensity*Math.PI),c(a.direction,h.directionToLightSource),a.specularStrength=s.specularStrength,a.environmentStrength=s.environmentStrength;const l=this._ambientLight;g(l.intensity,s.ambient.color,s.ambient.intensity);const m=this._moonLight;p(m.intensity,E,R,s.globalFactor);const d=(1-.5*s.globalFactor)*(1-.4*s.noonFactor*(1-s.globalFactor));g(m.intensity,m.intensity,d),c(m.direction,h.directionToLightSource),this._view.stage?.renderer.updateLighting([a,l,m],s.noonFactor,s.globalFactor,this._weatherAvailable?t:0),this._updateRenderParameters()}_autoUpdateTimezone(e,t=null){if("virtual"===this._view.environment.lighting.type||!this._view.environment.lighting.cameraTrackingEnabled||null==e)return!1;const i=this._tmpDate;i.setTime((t||this._view.environment.lighting.date).getTime());const n=b(e,this._tmpTz);if(null==n)return!1;let r=this._view.environment.lighting.positionTimezoneInfo;if(r.autoUpdated){if(r.hours===n.hours&&r.minutes===n.minutes&&r.seconds===n.seconds)return!1}else r=n;const o=i.getUTCHours()-(n.hours-r.hours),s=i.getUTCMinutes()-(n.minutes-r.minutes),a=i.getUTCSeconds()-(n.seconds-r.seconds);return i.setUTCHours(o),i.setUTCMinutes(s),i.setUTCSeconds(a),!t&&this._view.environment.lighting.autoUpdate(i,n)}_updateRenderParameters(){const e=this._view.stage;if(!e)return;const t=null==this._referencePositionGeographic||G(this._referencePositionGeographic[2],this._view.state.viewingMode);e.renderer.setParameters({shadowMap:this._view.environment.lighting.directShadowsEnabled&&t,environment:this._view.environment,weatherVisible:this._weatherAvailable,qualitySettings:this._view.qualitySettings})}_resetReferencePosition(e=!1){this._referencePositionGeographic=null,e&&this._cameraHandler()}get test(){}};e([a({type:Boolean,readOnly:!0})],H.prototype,"updating",null),e([a()],H.prototype,"_disableWeather",void 0),e([a()],H.prototype,"weatherEnabled",null),e([a()],H.prototype,"_weatherAvailable",null),e([a()],H.prototype,"referencePositionGeographic",null),e([a()],H.prototype,"_referencePositionGeographic",void 0),e([a()],H.prototype,"_renderer",void 0),e([a()],H.prototype,"_canProjectCameraPosition",null),H=e([h("esri.views.3d.environment.EnvironmentManager")],H);const E=u(.22,.22,.33),R=u(.22,.22,.22),k=m();export{H as EnvironmentManager};
5
+ import{__decorate as e}from"tslib";import{EventedAccessor as t}from"../../../core/Evented.js";import"../../../core/has.js";import{destroyMaybe as i}from"../../../core/maybe.js";import{watch as n,when as r,sync as o,syncAndInitial as s}from"../../../core/reactiveUtils.js";import{property as a}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as h}from"../../../core/accessorSupport/decorators/subclass.js";import{G as l,d as c,h as g,l as p}from"../../../chunks/vec32.js";import{create as d,clone as m,fromValues as _}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{isLoadedOrLoadFor as u}from"../../../geometry/projectionUtils.js";import v from"../../../geometry/SpatialReference.js";import{projectPointToVector as f}from"../../../geometry/projection/projectPointToVector.js";import{getGCSForPlanet as w}from"../../../geometry/support/planetGCSUtils.js";import{isEarth as y}from"../../../geometry/support/spatialReferenceUtils.js";import{EnvironmentRenderer as P}from"./EnvironmentRenderer.js";import{positionToTimezoneInfo as b}from"../support/earthUtils.js";import{ColorAndIntensity as T,computeColorAndIntensity as j,computeVirtualLightDirection as L,computeShadowsEnabled as G}from"../support/sunUtils.js";import{MainLight as U,AmbientLight as C,FillLight as H}from"../webgl-engine/lighting/Lightsources.js";let E=class extends t{constructor(e){super(e),this._tmpLightParameters=new T,this._defaultLightParameters=new T,this._tmpDate=new Date,this._tmpTz={hours:0,minutes:0,seconds:0},this._viewHandlesKey="viewHandles",this._trackingEnabled=!1,this._mainLight=new U,this._ambientLight=new C,this._moonLight=new H,this._disableWeather=!1,this._renderer=null,this._resetReferencePosition()}destroy(){this.disconnectView()}get _view(){return this._renderer?.view}get updating(){return!!this._renderer?.updating||!this._canProjectCameraPosition}get weatherEnabled(){return this._view?.environment.atmosphereEnabled&&!this._disableWeather&&1===this._view?.state?.viewingMode&&y(this._view.spatialReference)}get _weatherAvailable(){return this.weatherEnabled&&this._renderer?.weatherAvailable}get referencePositionGeographic(){return this._referencePositionGeographic}get _canProjectCameraPosition(){const e=this._view?.stateManager?.camera?.position?.spatialReference??v.WGS84,t=w(e);return u(e,t)}connectView(e){if(this._renderer)return;this._renderer=new P({view:e});const t=()=>this._updateRenderParameters(),i=()=>this._cameraHandler();this.addHandles([n(()=>e.environment.lighting,e=>this._updateLightingHandler(e),o),n(()=>"virtual"!==e.environment.lighting.type?e.environment.lighting.date:null,e=>this._lightingDateHandler(e),o),n(()=>e.environment.lighting.directShadowsEnabled,t,o),n(()=>e.spatialReference,()=>this._resetReferencePosition(!0),o),n(()=>[e.environment.weather.type,this.weatherEnabled],()=>this._updateLighting(null,1),o),n(()=>"snowy"===e.environment.weather.type&&e.environment.weather.snowCover,t,o),n(()=>e.environment,e=>e.setComputeWeatherAvailable(()=>this._weatherAvailable),s),n(()=>e.viewingMode,()=>this._resetReferencePosition(!0),s),n(()=>"virtual"!==e.environment.lighting.type&&e.environment.lighting.cameraTrackingEnabled,e=>this._updateCameraTracking(e),s),n(()=>e.state.camera,i,s),r(()=>this._canProjectCameraPosition,i,o)],this._viewHandlesKey),this._updateRenderParameters(),this._updateLighting(),this._cameraHandler(),this.notifyChange("updating")}disconnectView(){this.removeHandles(this._viewHandlesKey),this._resetReferencePosition(),this._renderer=i(this._renderer)}_updateLightingHandler(e){this._updateCameraTracking("virtual"!==e.type&&e.cameraTrackingEnabled),this._lightingDateHandler("virtual"!==e.type?e.date:null),this._updateRenderParameters()}_updateCameraTracking(e){if(this._trackingEnabled=e,e)this._cameraHandler();else{const e=this._view.environment.lighting;"virtual"!==e?.type&&(e.positionTimezoneInfo.autoUpdated=!1)}}_lightingDateHandler(e){const t=this._view.environment.lighting;if("virtual"!==t?.type){if(e){if(!t.positionTimezoneInfo.autoUpdated&&(this._preupdateTracking(e),null!=this._referencePositionGeographic)){const e=b(this._referencePositionGeographic,this._tmpTz);null!=e&&(t.autoUpdate(null,e),this._trackingEnabled&&(t.positionTimezoneInfo.autoUpdated=!0))}this._updateLighting(e)}}else this._updateLighting()}_preupdateTracking(e){!this._trackingEnabled&&"virtual"!==this._view.environment.lighting.type&&this._view.environment.lighting.cameraTrackingEnabled&&this._cameraHandler(e)}_cameraHandler(e=null){const t=this._view;if(!t.ready)return;const i=t.stateManager.camera;if(!i)return;const{position:n}=i,r=n.spatialReference??v.WGS84,o=w(r);if(!f(n,k,o)){if(null==this._referencePositionGeographic)return;return this._referencePositionGeographic=null,void this._updateLighting()}this._referencePositionGeographic?l(this._referencePositionGeographic,k)||(c(this._referencePositionGeographic,k),this.notifyChange("referencePositionGeographic")):this._referencePositionGeographic=m(k),this._autoUpdateTimezone(this._referencePositionGeographic,e)||this._updateLighting(e)}_updateLighting(e,t=0){const i=this._view,{lighting:n}=i.environment,r="virtual"===n.type,o=this._referencePositionGeographic,s=null!=o?this._tmpLightParameters:this._defaultLightParameters;if(o){e??=r?null:n.date;const t=this._weatherAvailable?i.environment.weather.type:"disabled";j(e,o,i.state.viewingMode,t,i.state.camera,s)}else r&&L(i.state.camera,i.state.viewingMode,s.direct.directionToLightSource);const a=this._mainLight,h=s.direct;g(a.intensity,h.color,h.intensity*Math.PI),c(a.direction,h.directionToLightSource),a.specularStrength=s.specularStrength,a.environmentStrength=s.environmentStrength;const l=this._ambientLight;g(l.intensity,s.ambient.color,s.ambient.intensity);const d=this._moonLight;p(d.intensity,R,S,s.globalFactor);const m=(1-.5*s.globalFactor)*(1-.4*s.noonFactor*(1-s.globalFactor));g(d.intensity,d.intensity,m),c(d.direction,h.directionToLightSource),this._view.stage?.renderer.updateLighting([a,l,d],s.noonFactor,s.globalFactor,this._weatherAvailable?t:0),this._updateRenderParameters()}_autoUpdateTimezone(e,t=null){if("virtual"===this._view.environment.lighting.type||!this._view.environment.lighting.cameraTrackingEnabled||null==e)return!1;const i=this._tmpDate;i.setTime((t||this._view.environment.lighting.date).getTime());const n=b(e,this._tmpTz);if(null==n)return!1;let r=this._view.environment.lighting.positionTimezoneInfo;if(r.autoUpdated){if(r.hours===n.hours&&r.minutes===n.minutes&&r.seconds===n.seconds)return!1}else r=n;const o=i.getUTCHours()-(n.hours-r.hours),s=i.getUTCMinutes()-(n.minutes-r.minutes),a=i.getUTCSeconds()-(n.seconds-r.seconds);return i.setUTCHours(o),i.setUTCMinutes(s),i.setUTCSeconds(a),!t&&this._view.environment.lighting.autoUpdate(i,n)}_updateRenderParameters(){const e=this._view.stage;if(!e)return;const t=null==this._referencePositionGeographic||G(this._referencePositionGeographic[2],this._view.state.viewingMode);e.renderer.setParameters({shadowMap:this._view.environment.lighting.directShadowsEnabled&&t,environment:this._view.environment,weatherVisible:this._weatherAvailable})}_resetReferencePosition(e=!1){this._referencePositionGeographic=null,e&&this._cameraHandler()}get test(){}};e([a({type:Boolean,readOnly:!0})],E.prototype,"updating",null),e([a()],E.prototype,"_disableWeather",void 0),e([a()],E.prototype,"weatherEnabled",null),e([a()],E.prototype,"_weatherAvailable",null),e([a()],E.prototype,"referencePositionGeographic",null),e([a()],E.prototype,"_referencePositionGeographic",void 0),e([a()],E.prototype,"_renderer",void 0),e([a()],E.prototype,"_canProjectCameraPosition",null),E=e([h("esri.views.3d.environment.EnvironmentManager")],E);const R=_(.22,.22,.33),S=_(.22,.22,.22),k=d();export{E as EnvironmentManager};
@@ -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 r from"../../../Graphic.js";import t from"../../../core/Error.js";import i from"../../../core/Logger.js";import{destroyMaybe as s}from"../../../core/maybe.js";import{throwIfAborted as l,throwIfAbortError as a}from"../../../core/promiseUtils.js";import{syncAndInitial as o,initial as n}from"../../../core/reactiveUtils.js";import{property as u}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/RandomLCG.js";import{subclass as d}from"../../../core/accessorSupport/decorators/subclass.js";import p from"../../../core/sql/WhereClause.js";import"../../../layers/buildingSublayers/BuildingComponentSublayer.js";import h from"../../../layers/support/FeatureFilter.js";import{fixFields as y,unpackFieldNames as c,populateMissingFields as g}from"../../../layers/support/fieldUtils.js";import f from"../../../rest/support/Query.js";import{isNumber as m}from"../../../support/guards.js";import{BuildingSublayerView3DMixin as F}from"./BuildingSublayerView3D.js";import{I3SMeshView3D as b}from"./I3SMeshView3D.js";import{applyFilterMode as _}from"./i3s/BuildingFilterUtil.js";import{createGetFeatureExtent as w}from"./i3s/I3SGeometryUtil.js";import{I3SMeshViewFilter as E}from"./i3s/I3SMeshViewFilter.js";import{I3SQueryEngine as x}from"./i3s/I3SQueryEngine.js";import{I3SQueryFeatureAdapter as S,I3SQueryFeature as j}from"./i3s/I3SQueryFeatureAdapter.js";import{I3SQueryFeatureStore as v}from"./i3s/I3SQueryFeatureStore.js";import{findFieldsCaseInsensitive as I,getIndexCrs as Q}from"./i3s/I3SUtil.js";import{DefinitionExpressionSceneLayerView as q}from"./support/DefinitionExpressionSceneLayerView.js";import{TemporalSceneLayerView as R}from"./support/TemporalSceneLayerView.js";import L from"../../layers/BuildingComponentSublayerView.js";import{hasPopupTemplate as O,getRequiredFields as V,getFetchPopupTemplate as U}from"../../layers/support/popupUtils.js";import{isInEffectiveScaleRange as C}from"../../support/layerViewUtils.js";import{TaskPriority as A}from"../../support/Scheduler.js";let H=class extends(R(q(b(F(L))))){constructor(e){super(e),this.type="building-component-sublayer-3d",this._elevationContext=2,this._supportsLabeling=!1,this.requiredFields=[],this.progressiveLoadFactor=1,this._queryEngine=null}get i3slayer(){return this.sublayer}get layerViewUid(){return this.layerView.uid}get layerId(){return this.sublayer.layer.id}get sublayerId(){return this.sublayer.id}get layerPopupEnabledAndHasTemplate(){return this.sublayer.popupEnabled&&O(this.sublayer,this.layerView.view.popup?.defaultPopupTemplateEnabled)}initialize(){this._updatingHandles.add(()=>this.mergedFilter,e=>{null!=e&&E.checkSupport(e)?null==this._i3sFilter?this._i3sFilter=new E({viewFilter:e,layerFieldsIndex:this.sublayer.fieldsIndex,loadAsyncModule:e=>this._loadAsyncModule(e),addSqlFilter:(e,r)=>this.addSqlFilter(e,r,this.logError),addTimeFilter:(e,r)=>this.addTimeFilter(e,r)}):this._i3sFilter.viewFilter=e:this._i3sFilter=s(this._i3sFilter)},o),this._updatingHandles.add(()=>[this.sublayer.renderer,this.definitionExpressionFields,this.filterExpressionFields],()=>this._updateRequiredFields()),this._updatingHandles.add(()=>this.sublayer.renderer,e=>this._rendererChange(e),n);const e=()=>this._filterChange();this._updatingHandles.add(()=>this.parsedDefinitionExpression,e),this._updatingHandles.add(()=>this._i3sFilter?.sortedObjectIds,e),this._updatingHandles.add(()=>this._i3sFilter?.parsedWhereClause,e),this._updatingHandles.add(()=>this.getTimeFilterDependencies(),e),this._updatingHandles.add(()=>this.mergedFilter,e),this._updatingHandles.add(()=>[this._i3sFilter?.parsedGeometry,this.filter?.spatialRelationship],()=>this._geometryFilterChange()),this._updatingHandles.add(()=>this.parsedFilterExpressions,()=>this._updateSymbologyOverride(),n),this.addResolvingPromise(this._updateRequiredFields())}get lodFactor(){return this.view.qualitySettings.sceneService.object.lodFactor}get parsedFilterExpressions(){return"Overview"===this.sublayer.modelName?[]:this.layerView.filterExpressions.map(([e,r])=>{let t;try{t=p.create(e,{fieldsIndex:this.sublayer.fieldsIndex})}catch(a){return i.getLogger(this).error("Failed to parse filterExpression: "+a),null}if(!t.isStandardized)return i.getLogger(this).error("filterExpression is using non standard function"),null;const s=[],l=t.fieldNames;return I(l,this.sublayer.fieldsIndex,{missingFields:s}),s.length>0?(i.getLogger(this).error(`filterExpression references unknown fields: ${s.join(", ")}`),null):[t,r]}).filter(e=>null!=e)}get filter(){return this._get("filter")}set filter(e){this._set("filter",E.checkSupport(e)?e:null)}isUpdating(){return super.isUpdating()||(this._i3sFilter?.updating??!1)}_updateSymbologyOverride(){const e=this.parsedFilterExpressions;e.length>0?this._setSymbologyOverride((r,t)=>{for(const[s,l]of e)try{if(s.testFeature(r))return _(t,l)}catch(i){this.logError(i)}return _(t,null)},this.filterExpressionFields):this._setSymbologyOverride(null,null)}get filterExpressionFields(){return y(this.sublayer.fieldsIndex,this.parsedFilterExpressions.reduce((e,[r])=>e.concat(r.fieldNames),new Array))}get availableFields(){const e=this.sublayer,r=e.fieldsIndex;let t=this.requiredFields;if(e.outFields||e.layer.outFields){const i=[...e.outFields||[],...e.layer.outFields||[]];t=[...c(r,i),...t]}return y(r,t)}get _graphicOrigin(){return this.sublayer.graphicOrigin}_createLayerGraphic(e){return new r({attributes:e,layer:this.sublayer.layer,sourceLayer:this.sublayer,origin:this._graphicOrigin})}canResume(){return super.canResume()&&C(this.i3slayer.effectiveScaleRange,this.view.scale)&&(!this._controller||this._controller.rootNodeVisible)}async fetchPopupFeaturesFromGraphics(e,r){const t=this._validateFetchPopupFeatures(r);if(t)throw t;if(0===e.length)return[];const s=[],o=[],n=null!=this.sublayer.associatedLayer?await this.sublayer.associatedLayer.load(r):this.sublayer,u=c(this.sublayer.fieldsIndex,await V(n,U(this.sublayer,r)));l(r);const d=new Set;for(const i of e)g(i,u,d)?o.push(i):s.push(i);return 0===o.length?s:(null!=this.sublayer.associatedLayer&&await this.sublayer.associatedLayer.load().catch(()=>i.getLogger(this).warn("Failed to load associated feature layer. Displaying popup attributes from cached attributes.")),this.whenGraphicAttributes(o,Array.from(d)).catch(e=>(a(e),o)).then(e=>s.concat(e)))}async _updateRequiredFields(){const e=y(this.sublayer.fieldsIndex,[...this.sublayer.renderer?await this.sublayer.renderer.getRequiredFields(this.sublayer.fieldsIndex):[],...this.definitionExpressionFields,...this.filterExpressionFields]);this._set("requiredFields",e)}_validateFetchPopupFeatures(e){const{sublayer:r}=this,{popupEnabled:i}=r;return i?U(r,e)?void 0:new t("buildingscenelayerview3d:fetchPopupFeatures","Layer does not define a popup template",{sublayer:r}):new t("buildingscenelayerview3d:fetchPopupFeatures","Popups are disabled",{sublayer:r})}getFilters(){const e=super.getFilters();return this.addSqlFilter(e,this.parsedDefinitionExpression,this.logError),this._i3sFilter?.addFilters(e,this.view,this._controller.crsIndex,this._collection),e}createQuery(){const e={outFields:["*"],returnGeometry:!1,outSpatialReference:this.view.spatialReference};return null!=this.filter?this.filter.createQuery(e):new f(e)}queryExtent(e,r){return this._ensureQueryEngine().executeQueryForExtent(this._ensureQuery(e),r?.signal)}queryFeatureCount(e,r){return this._ensureQueryEngine().executeQueryForCount(this._ensureQuery(e),r?.signal)}queryFeatures(e,r){return this._ensureQueryEngine().executeQuery(this._ensureQuery(e),r?.signal).then(e=>{if(!e?.features)return e;const r=this.sublayer,t=r.layer,i=this._graphicOrigin;for(const s of e.features)s.layer=t,s.sourceLayer=r,s.origin=i;return e})}async queryObjectIds(e,r){return(await this._ensureQueryEngine().executeQueryForIds(this._ensureQuery(e),r?.signal)).filter(m)}_ensureQueryEngine(){return this._queryEngine??=this._createQueryEngine(),this._queryEngine}_createQueryEngine(){const e=w(this.view.spatialReference,this.view.renderSpatialReference,this._collection);return new x({layerView:this,priority:A.FEATURE_QUERY_ENGINE,spatialIndex:new v({featureAdapter:new S({objectIdField:this.sublayer.objectIdField,attributeStorageInfo:this.sublayer.attributeStorageInfo,getFeatureExtent:e}),forAllFeatures:(e,r)=>this._forAllFeatures((r,t,i)=>e(new j(r,t,i)),r,2),getFeatureExtent:e,sourceSpatialReference:Q(this.sublayer),viewSpatialReference:this.view.spatialReference})})}_ensureQuery(e){return this._addDefinitionExpressionToQuery(null==e?this.createQuery():f.from(e))}};e([u()],H.prototype,"i3slayer",null),e([u()],H.prototype,"layerView",void 0),e([u()],H.prototype,"lodFactor",null),e([u({readOnly:!0})],H.prototype,"parsedFilterExpressions",null),e([u({type:h})],H.prototype,"filter",null),e([u()],H.prototype,"_i3sFilter",void 0),e([u({type:[String],readOnly:!0})],H.prototype,"filterExpressionFields",null),e([u({type:[String],readOnly:!0})],H.prototype,"requiredFields",void 0),e([u({type:[String],readOnly:!0})],H.prototype,"availableFields",null),e([u()],H.prototype,"_graphicOrigin",null),H=e([d("esri.views.3d.layers.BuildingComponentSublayerView3D")],H);export{H as default};
5
+ import{__decorate as e}from"tslib";import r from"../../../Graphic.js";import t from"../../../core/Error.js";import i from"../../../core/Logger.js";import{destroyMaybe as s}from"../../../core/maybe.js";import{throwIfAborted as l,throwIfAbortError as a}from"../../../core/promiseUtils.js";import{syncAndInitial as o,initial as n}from"../../../core/reactiveUtils.js";import{property as u}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/RandomLCG.js";import{subclass as d}from"../../../core/accessorSupport/decorators/subclass.js";import p from"../../../core/sql/WhereClause.js";import"../../../layers/buildingSublayers/BuildingComponentSublayer.js";import h from"../../../layers/support/FeatureFilter.js";import{fixFields as y,unpackFieldNames as c,populateMissingFields as g}from"../../../layers/support/fieldUtils.js";import f from"../../../rest/support/Query.js";import{isNumber as m}from"../../../support/guards.js";import{BuildingSublayerView3DMixin as F}from"./BuildingSublayerView3D.js";import{I3SMeshView3D as b}from"./I3SMeshView3D.js";import{applyFilterMode as _}from"./i3s/BuildingFilterUtil.js";import{createGetFeatureExtent as w}from"./i3s/I3SGeometryUtil.js";import{I3SMeshViewFilter as E}from"./i3s/I3SMeshViewFilter.js";import{I3SQueryEngine as x}from"./i3s/I3SQueryEngine.js";import{I3SQueryFeatureAdapter as S,I3SQueryFeature as j}from"./i3s/I3SQueryFeatureAdapter.js";import{I3SQueryFeatureStore as v}from"./i3s/I3SQueryFeatureStore.js";import{findFieldsCaseInsensitive as I,getIndexCrs as Q}from"./i3s/I3SUtil.js";import{DefinitionExpressionSceneLayerView as q}from"./support/DefinitionExpressionSceneLayerView.js";import{TemporalSceneLayerView as L}from"./support/TemporalSceneLayerView.js";import R from"../../layers/BuildingComponentSublayerView.js";import{hasPopupTemplate as O,getRequiredFields as V,getFetchPopupTemplate as U}from"../../layers/support/popupUtils.js";import{isInEffectiveScaleRange as C}from"../../support/layerViewUtils.js";import{TaskPriority as A}from"../../support/Scheduler.js";let H=class extends(L(q(b(F(R))))){constructor(e){super(e),this.type="building-component-sublayer-3d",this._elevationContext=2,this._supportsLabeling=!1,this.requiredFields=[],this.progressiveLoadFactor=1,this._queryEngine=null}get i3slayer(){return this.sublayer}get layerViewUid(){return this.layerView.uid}get layerId(){return this.sublayer.layer.id}get sublayerId(){return this.sublayer.id}get layerPopupEnabledAndHasTemplate(){return this.sublayer.popupEnabled&&O(this.sublayer,this.layerView.view.popup?.defaultPopupTemplateEnabled)}initialize(){this._updatingHandles.add(()=>this.mergedFilter,e=>{null!=e&&E.checkSupport(e)?null==this._i3sFilter?this._i3sFilter=new E({viewFilter:e,layerFieldsIndex:this.sublayer.fieldsIndex,loadAsyncModule:e=>this._loadAsyncModule(e),addSqlFilter:(e,r)=>this.addSqlFilter(e,r,this.logError),addTimeFilter:(e,r)=>this.addTimeFilter(e,r)}):this._i3sFilter.viewFilter=e:this._i3sFilter=s(this._i3sFilter)},o),this._updatingHandles.add(()=>[this.sublayer.renderer,this.definitionExpressionFields,this.filterExpressionFields],()=>this._updateRequiredFields()),this._updatingHandles.add(()=>this.sublayer.renderer,e=>this._rendererChange(e),n);const e=()=>this._filterChange();this._updatingHandles.add(()=>this.parsedDefinitionExpression,e),this._updatingHandles.add(()=>this._i3sFilter?.sortedObjectIds,e),this._updatingHandles.add(()=>this._i3sFilter?.parsedWhereClause,e),this._updatingHandles.add(()=>this.getTimeFilterDependencies(),e),this._updatingHandles.add(()=>this.mergedFilter,e),this._updatingHandles.add(()=>[this._i3sFilter?.parsedGeometry,this.filter?.spatialRelationship],()=>this._geometryFilterChange()),this._updatingHandles.add(()=>this.parsedFilterExpressions,()=>this._updateSymbologyOverride(),n),this.addResolvingPromise(this._updateRequiredFields())}get lodFactor(){return this.view.qualitySettings.sceneService.objectLoDFactor}get parsedFilterExpressions(){return"Overview"===this.sublayer.modelName?[]:this.layerView.filterExpressions.map(([e,r])=>{let t;try{t=p.create(e,{fieldsIndex:this.sublayer.fieldsIndex})}catch(a){return i.getLogger(this).error("Failed to parse filterExpression: "+a),null}if(!t.isStandardized)return i.getLogger(this).error("filterExpression is using non standard function"),null;const s=[],l=t.fieldNames;return I(l,this.sublayer.fieldsIndex,{missingFields:s}),s.length>0?(i.getLogger(this).error(`filterExpression references unknown fields: ${s.join(", ")}`),null):[t,r]}).filter(e=>null!=e)}get filter(){return this._get("filter")}set filter(e){this._set("filter",E.checkSupport(e)?e:null)}isUpdating(){return super.isUpdating()||(this._i3sFilter?.updating??!1)}_updateSymbologyOverride(){const e=this.parsedFilterExpressions;e.length>0?this._setSymbologyOverride((r,t)=>{for(const[s,l]of e)try{if(s.testFeature(r))return _(t,l)}catch(i){this.logError(i)}return _(t,null)},this.filterExpressionFields):this._setSymbologyOverride(null,null)}get filterExpressionFields(){return y(this.sublayer.fieldsIndex,this.parsedFilterExpressions.reduce((e,[r])=>e.concat(r.fieldNames),new Array))}get availableFields(){const e=this.sublayer,r=e.fieldsIndex;let t=this.requiredFields;if(e.outFields||e.layer.outFields){const i=[...e.outFields||[],...e.layer.outFields||[]];t=[...c(r,i),...t]}return y(r,t)}get _graphicOrigin(){return this.sublayer.graphicOrigin}_createLayerGraphic(e){return new r({attributes:e,layer:this.sublayer.layer,sourceLayer:this.sublayer,origin:this._graphicOrigin})}canResume(){return super.canResume()&&C(this.i3slayer.effectiveScaleRange,this.view.scale)&&(!this._controller||this._controller.rootNodeVisible)}async fetchPopupFeaturesFromGraphics(e,r){const t=this._validateFetchPopupFeatures(r);if(t)throw t;if(0===e.length)return[];const s=[],o=[],n=null!=this.sublayer.associatedLayer?await this.sublayer.associatedLayer.load(r):this.sublayer,u=c(this.sublayer.fieldsIndex,await V(n,U(this.sublayer,r)));l(r);const d=new Set;for(const i of e)g(i,u,d)?o.push(i):s.push(i);return 0===o.length?s:(null!=this.sublayer.associatedLayer&&await this.sublayer.associatedLayer.load().catch(()=>i.getLogger(this).warn("Failed to load associated feature layer. Displaying popup attributes from cached attributes.")),this.whenGraphicAttributes(o,Array.from(d)).catch(e=>(a(e),o)).then(e=>s.concat(e)))}async _updateRequiredFields(){const e=y(this.sublayer.fieldsIndex,[...this.sublayer.renderer?await this.sublayer.renderer.getRequiredFields(this.sublayer.fieldsIndex):[],...this.definitionExpressionFields,...this.filterExpressionFields]);this._set("requiredFields",e)}_validateFetchPopupFeatures(e){const{sublayer:r}=this,{popupEnabled:i}=r;return i?U(r,e)?void 0:new t("buildingscenelayerview3d:fetchPopupFeatures","Layer does not define a popup template",{sublayer:r}):new t("buildingscenelayerview3d:fetchPopupFeatures","Popups are disabled",{sublayer:r})}getFilters(){const e=super.getFilters();return this.addSqlFilter(e,this.parsedDefinitionExpression,this.logError),this._i3sFilter?.addFilters(e,this.view,this._controller.crsIndex,this._collection),e}createQuery(){const e={outFields:["*"],returnGeometry:!1,outSpatialReference:this.view.spatialReference};return null!=this.filter?this.filter.createQuery(e):new f(e)}queryExtent(e,r){return this._ensureQueryEngine().executeQueryForExtent(this._ensureQuery(e),r?.signal)}queryFeatureCount(e,r){return this._ensureQueryEngine().executeQueryForCount(this._ensureQuery(e),r?.signal)}queryFeatures(e,r){return this._ensureQueryEngine().executeQuery(this._ensureQuery(e),r?.signal).then(e=>{if(!e?.features)return e;const r=this.sublayer,t=r.layer,i=this._graphicOrigin;for(const s of e.features)s.layer=t,s.sourceLayer=r,s.origin=i;return e})}async queryObjectIds(e,r){return(await this._ensureQueryEngine().executeQueryForIds(this._ensureQuery(e),r?.signal)).filter(m)}_ensureQueryEngine(){return this._queryEngine??=this._createQueryEngine(),this._queryEngine}_createQueryEngine(){const e=w(this.view.spatialReference,this.view.renderSpatialReference,this._collection);return new x({layerView:this,priority:A.FEATURE_QUERY_ENGINE,spatialIndex:new v({featureAdapter:new S({objectIdField:this.sublayer.objectIdField,attributeStorageInfo:this.sublayer.attributeStorageInfo,getFeatureExtent:e}),forAllFeatures:(e,r)=>this._forAllFeatures((r,t,i)=>e(new j(r,t,i)),r,2),getFeatureExtent:e,sourceSpatialReference:Q(this.sublayer),viewSpatialReference:this.view.spatialReference})})}_ensureQuery(e){return this._addDefinitionExpressionToQuery(null==e?this.createQuery():f.from(e))}};e([u()],H.prototype,"i3slayer",null),e([u()],H.prototype,"layerView",void 0),e([u()],H.prototype,"lodFactor",null),e([u({readOnly:!0})],H.prototype,"parsedFilterExpressions",null),e([u({type:h})],H.prototype,"filter",null),e([u()],H.prototype,"_i3sFilter",void 0),e([u({type:[String],readOnly:!0})],H.prototype,"filterExpressionFields",null),e([u({type:[String],readOnly:!0})],H.prototype,"requiredFields",void 0),e([u({type:[String],readOnly:!0})],H.prototype,"availableFields",null),e([u()],H.prototype,"_graphicOrigin",null),H=e([d("esri.views.3d.layers.BuildingComponentSublayerView3D")],H);export{H 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{forEach as t,result as r}from"../../../core/asyncUtils.js";import{makeHandle as i}from"../../../core/handleUtils.js";import a from"../../../core/Logger.js";import{abortMaybe as s}from"../../../core/maybe.js";import{isAbortError as o,onAbort as n,throwIfAborted as l,isAborted as h,createAbortError as m}from"../../../core/promiseUtils.js";import{whenOnce as d}from"../../../core/reactiveUtils.js";import{property as g}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/RandomLCG.js";import{subclass as c}from"../../../core/accessorSupport/decorators/subclass.js";import u from"../../../geometry/Extent.js";import{create as p,equals as x,width as y,height as f,copy as w,intersection as _}from"../../../geometry/support/aaBoundingRect.js";import v from"./SubView3D.js";import{computeImageExportSize as b,createGeometryForExtent as R,createOuterImageGeometry as S}from"./support/overlayImageUtils.js";import{debugFlags as j}from"../support/debugFlags.js";import{RenderGeometry as E}from"../webgl-engine/lib/RenderGeometry.js";import{Texture as M}from"../webgl-engine/lib/Texture.js";import{ImageMaterial as I}from"../webgl-engine/materials/ImageMaterial.js";let A=class extends v{constructor(e){super(e),this.drapeSourceType=0,this.updatePolicy=1,this.type="draped",this.maximumDataResolution=null,this._images=new Array,this._extents=new Array,this._overlays=new Array,this._drapeSourceRenderer=null}initialize(){this._drapeSourceRenderer=this.view.overlayManager.registerGeometryDrapeSource(this),this.addHandles(i(()=>this.view.overlayManager.unregisterDrapeSource(this)))}setDrapingExtent(e,t){this._spatialReference=t,e.forEach((e,t)=>{this._overlays[t]=e,this._updateImageExtent(e,t)})}destroy(){this.clear()}get spatialReference(){return this._spatialReference}_updateImageExtent(e,t){const r=this._clippedExtent(e.extent,G);if(null==r)return;const i=b(e.extent,r,e.resolution);let s=e.pixelRatio*this.view.state.pixelRatio;const{layer:n}=this;if("imageMaxWidth"in n&&null!=n.imageMaxWidth||"imageMaxHeight"in n&&null!=n.imageMaxHeight){const e=n.imageMaxWidth,t=n.imageMaxHeight;if(i.width>e){const t=e/i.width;i.height=Math.floor(i.height*t),i.width=e,s*=t}if(i.height>t){const e=t/i.height;i.width=Math.floor(i.width*e),i.height=t,s*=e}}const l=this._extents[t];l&&x(l.extent,r)&&this._imageSizeEquals(r,l.imageSize,i)||(this._extents[t]={extent:p(r),imageSize:i,pixelRatio:s},this.suspended||this._fetch(t).catch(e=>{o(e)||a.getLogger(this).error(e)}))}clear(){for(let e=0;e<this._images.length;e++)this._clearImage(e)}async doRefresh(e){const t=[];for(let r=0;r<this._extents.length;r++)this._extents[r]&&t.push(this._fetch(r,e));await Promise.allSettled(t)}async processResult(e,t,r){(t instanceof HTMLImageElement||t instanceof HTMLCanvasElement)&&(e.image=t)}findExtentInfoAt(e){for(const t of this._extents){const r=t.extent;if(new u(r[0],r[1],r[2],r[3],this._spatialReference).contains(e))return t}return null}async redraw(e,r){await t(this._images,async(t,i)=>{t&&(await e(t,r),await this._createStageObjects(i,t.image,r))})}_imageSizeEquals(e,t,r){if(!this.maximumDataResolution)return!1;const i=y(e)/this.maximumDataResolution.x,a=f(e)/this.maximumDataResolution.y,s=i/t.width,o=a/t.height,n=i/r.width,l=a/r.height,h=Math.abs(s-n),m=Math.abs(o-l),d=j.TESTS_DISABLE_OPTIMIZATIONS?0:1.5;return h<=d&&m<=d}async _fetch(e,t){if(this.suspended)return;const r=this._extents[e],i=r.extent;this._images[e]||(this._images[e]={texture:null,material:null,renderGeometry:null,loadingPromise:null,loadingAbortController:null,image:null,pixelData:null,renderExtent:p(i)});const d=this._images[e];d.loadingAbortController=s(d.loadingAbortController);const g=new u(i[0],i[1],i[2],i[3],this._spatialReference);if(0===g.width||0===g.height)return void this._clearImage(e);const c=new AbortController;d.loadingAbortController=c,n(t,()=>c.abort());const x=c.signal,y=this._waitFetchReady(x).then(async()=>{l(x);const t={requestAsImageElement:!0,pixelRatio:this._overlays[e].pixelRatio,...this.layerView.getFetchOptions(),signal:x},{height:i,width:a}=r.imageSize;return this.layer?"imagery"===this.layer.type?this.layer.internalFetchImage(g,a,i,t):this.layer.fetchImage(g,a,i,t):null}).then(e=>{if(h(x))throw a.getLogger(this).warnOnce("A call to fetchImage resolved even though the request was aborted. fetchImage should not resolve if options.signal.aborted is true."),m();return this.processResult(d,e)}).then(()=>{w(d.renderExtent,i)});d.loadingPromise=y,await this.updatingHandles.addPromise(y.then(async()=>{l(x),await this._createStageObjects(e,d.image,x)}).catch(e=>{throw e&&!o(e)&&a.getLogger(this).error(e),e}).finally(()=>{y===d.loadingPromise&&(d.loadingPromise=null,d.loadingAbortController=null)}))}_clearImage(e){const t=this._images[e];if(t){null!=t.renderGeometry&&(this._drapeSourceRenderer.removeGeometries([t.renderGeometry],1),t.renderGeometry=null);const e=this.view.stage,r=t.texture;r?.unload(),e.removeTexture(r),t.texture=null,t.material=null,t.loadingAbortController=s(t.loadingAbortController),t.loadingPromise=null,t.image=null,t.pixelData=null}}async _createStageObjects(e,t,i){const a=this.view.stage,s=this._images[e],o=()=>{s.texture?.unload(),a.removeTexture(s.texture),s.texture=null,s.renderGeometry&&(this._drapeSourceRenderer.removeGeometries([s.renderGeometry],1),s.renderGeometry=null)};if(t){const n=new M(t,{width:t.width,height:t.height,preMultiplyAlpha:!0,wrap:{s:33071,t:33071}});if(await r(this._images[0===e?1:0].loadingPromise),l(i),o(),await a.schedule(()=>n.load(a.renderView.renderingContext),i),!n.loaded)return void o();let h;if(a.addTexture(n),s.texture=n,s.material??=new I({draped:!0,texture:n}),s.material.setParameters({texture:n}),0===e)h=R(s.material,s.renderExtent);else{const e=this._images[0].renderExtent;if(!e)return void o();h=S(s.material,e,s.renderExtent)}s.renderGeometry=new E(h),s.renderGeometry.localOrigin=this._overlays[e].renderLocalOrigin,this._drapeSourceRenderer.addGeometries([s.renderGeometry],1)}else o(),s.material=null}_clippedExtent(e,t){if("local"!==this.view.viewingMode)return w(t,e);const r=this.view.basemapTerrain;return r.ready?_(e,r.extent,t):w(t,e)}async _waitFetchReady(e){await d(()=>this.view.stationary,e),l(e)}get usedMemory(){return this._images.reduce((e,t)=>e+(t.texture?.usedMemory??0),0)}};e([g()],A.prototype,"type",void 0),A=e([c("esri.views.3d.layers.DrapedSubView3D")],A);const G=p();export{A as default};
5
+ import{__decorate as e}from"tslib";import{forEach as t,result as r}from"../../../core/asyncUtils.js";import{makeHandle as i}from"../../../core/handleUtils.js";import a from"../../../core/Logger.js";import{abortMaybe as s}from"../../../core/maybe.js";import{isAbortError as o,onAbort as n,throwIfAborted as l,isAborted as h,createAbortError as m}from"../../../core/promiseUtils.js";import{whenOnce as d}from"../../../core/reactiveUtils.js";import{property as g}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/RandomLCG.js";import{subclass as c}from"../../../core/accessorSupport/decorators/subclass.js";import u from"../../../geometry/Extent.js";import{create as p,equals as x,width as y,height as f,copy as w,intersection as _}from"../../../geometry/support/aaBoundingRect.js";import v from"./SubView3D.js";import{computeImageExportSize as b,createGeometryForExtent as R,createOuterImageGeometry as S}from"./support/overlayImageUtils.js";import{debugFlags as j}from"../support/debugFlags.js";import{ManagedTexture as M}from"../webgl-engine/lib/ManagedTexture.js";import{RenderGeometry as E}from"../webgl-engine/lib/RenderGeometry.js";import{ImageMaterial as I}from"../webgl-engine/materials/ImageMaterial.js";let A=class extends v{constructor(e){super(e),this.drapeSourceType=0,this.updatePolicy=1,this.type="draped",this.maximumDataResolution=null,this._images=new Array,this._extents=new Array,this._overlays=new Array,this._drapeSourceRenderer=null}initialize(){this._drapeSourceRenderer=this.view.overlayManager.registerGeometryDrapeSource(this),this.addHandles(i(()=>this.view.overlayManager.unregisterDrapeSource(this)))}setDrapingExtent(e,t){this._spatialReference=t,e.forEach((e,t)=>{this._overlays[t]=e,this._updateImageExtent(e,t)})}destroy(){this.clear()}get spatialReference(){return this._spatialReference}_updateImageExtent(e,t){const r=this._clippedExtent(e.extent,G);if(null==r)return;const i=b(e.extent,r,e.resolution);let s=e.pixelRatio*this.view.state.pixelRatio;const{layer:n}=this;if("imageMaxWidth"in n&&null!=n.imageMaxWidth||"imageMaxHeight"in n&&null!=n.imageMaxHeight){const e=n.imageMaxWidth,t=n.imageMaxHeight;if(i.width>e){const t=e/i.width;i.height=Math.floor(i.height*t),i.width=e,s*=t}if(i.height>t){const e=t/i.height;i.width=Math.floor(i.width*e),i.height=t,s*=e}}const l=this._extents[t];l&&x(l.extent,r)&&this._imageSizeEquals(r,l.imageSize,i)||(this._extents[t]={extent:p(r),imageSize:i,pixelRatio:s},this.suspended||this._fetch(t).catch(e=>{o(e)||a.getLogger(this).error(e)}))}clear(){for(let e=0;e<this._images.length;e++)this._clearImage(e)}async doRefresh(e){const t=[];for(let r=0;r<this._extents.length;r++)this._extents[r]&&t.push(this._fetch(r,e));await Promise.allSettled(t)}async processResult(e,t,r){(t instanceof HTMLImageElement||t instanceof HTMLCanvasElement)&&(e.image=t)}findExtentInfoAt(e){for(const t of this._extents){const r=t.extent;if(new u(r[0],r[1],r[2],r[3],this._spatialReference).contains(e))return t}return null}async redraw(e,r){await t(this._images,async(t,i)=>{t&&(await e(t,r),await this._createStageObjects(i,t.image,r))})}_imageSizeEquals(e,t,r){if(!this.maximumDataResolution)return!1;const i=y(e)/this.maximumDataResolution.x,a=f(e)/this.maximumDataResolution.y,s=i/t.width,o=a/t.height,n=i/r.width,l=a/r.height,h=Math.abs(s-n),m=Math.abs(o-l),d=j.TESTS_DISABLE_OPTIMIZATIONS?0:1.5;return h<=d&&m<=d}async _fetch(e,t){if(this.suspended)return;const r=this._extents[e],i=r.extent;this._images[e]||(this._images[e]={texture:null,material:null,renderGeometry:null,loadingPromise:null,loadingAbortController:null,image:null,pixelData:null,renderExtent:p(i)});const d=this._images[e];d.loadingAbortController=s(d.loadingAbortController);const g=new u(i[0],i[1],i[2],i[3],this._spatialReference);if(0===g.width||0===g.height)return void this._clearImage(e);const c=new AbortController;d.loadingAbortController=c,n(t,()=>c.abort());const x=c.signal,y=this._waitFetchReady(x).then(async()=>{l(x);const t={requestAsImageElement:!0,pixelRatio:this._overlays[e].pixelRatio,...this.layerView.getFetchOptions(),signal:x},{height:i,width:a}=r.imageSize;return this.layer?"imagery"===this.layer.type?this.layer.internalFetchImage(g,a,i,t):this.layer.fetchImage(g,a,i,t):null}).then(e=>{if(h(x))throw a.getLogger(this).warnOnce("A call to fetchImage resolved even though the request was aborted. fetchImage should not resolve if options.signal.aborted is true."),m();return this.processResult(d,e)}).then(()=>{w(d.renderExtent,i)});d.loadingPromise=y,await this.updatingHandles.addPromise(y.then(async()=>{l(x),await this._createStageObjects(e,d.image,x)}).catch(e=>{throw e&&!o(e)&&a.getLogger(this).error(e),e}).finally(()=>{y===d.loadingPromise&&(d.loadingPromise=null,d.loadingAbortController=null)}))}_clearImage(e){const t=this._images[e];if(t){null!=t.renderGeometry&&(this._drapeSourceRenderer.removeGeometries([t.renderGeometry],1),t.renderGeometry=null);const e=this.view.stage,r=t.texture;r?.unload(),e.removeTexture(r),t.texture=null,t.material=null,t.loadingAbortController=s(t.loadingAbortController),t.loadingPromise=null,t.image=null,t.pixelData=null}}async _createStageObjects(e,t,i){const a=this.view.stage,s=this._images[e],o=()=>{s.texture?.unload(),a.removeTexture(s.texture),s.texture=null,s.renderGeometry&&(this._drapeSourceRenderer.removeGeometries([s.renderGeometry],1),s.renderGeometry=null)};if(t){const n=new M(t,{width:t.width,height:t.height,preMultiplyAlpha:!0,wrap:{s:33071,t:33071}});if(await r(this._images[0===e?1:0].loadingPromise),l(i),o(),await a.schedule(()=>n.load(a.renderView.renderingContext),i),!n.loaded)return void o();let h;if(a.addTexture(n),s.texture=n,s.material??=new I({draped:!0,managedTexture:n}),s.material.setParameters({managedTexture:n}),0===e)h=R(s.material,s.renderExtent);else{const e=this._images[0].renderExtent;if(!e)return void o();h=S(s.material,e,s.renderExtent)}s.renderGeometry=new E(h),s.renderGeometry.localOrigin=this._overlays[e].renderLocalOrigin,this._drapeSourceRenderer.addGeometries([s.renderGeometry],1)}else o(),s.material=null}_clippedExtent(e,t){if("local"!==this.view.viewingMode)return w(t,e);const r=this.view.basemapTerrain;return r.ready?_(e,r.extent,t):w(t,e)}async _waitFetchReady(e){await d(()=>this.view.stationary,e),l(e)}get usedMemory(){return this._images.reduce((e,t)=>e+(t.texture?.usedMemory??0),0)}};e([g()],A.prototype,"type",void 0),A=e([c("esri.views.3d.layers.DrapedSubView3D")],A);const G=p();export{A 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{equals as t}from"../../../core/arrayUtils.js";import"../../../core/has.js";import{removeMaybe as i,abortMaybe as r}from"../../../core/maybe.js";import{debounce as s,ignoreAbortErrors as n,throwIfAborted as o}from"../../../core/promiseUtils.js";import{watch as l,when as a,sync as u,whenOnce as d}from"../../../core/reactiveUtils.js";import{addFrameTask as h}from"../../../core/scheduling.js";import{Seconds as p,secondsFromMilliseconds as c}from"../../../core/time.js";import{getMetersPerVerticalUnitForSR as m}from"../../../core/unitUtils.js";import{property as g}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/Logger.js";import{subclass as _}from"../../../core/accessorSupport/decorators/subclass.js";import{getReferenceEllipsoid as f}from"../../../geometry/ellipsoidUtils.js";import{projectOrLoad as y}from"../../../geometry/projectionUtils.js";import{fromExtent as v,intersection as w,toExtent as T,contains as S,area as b,intersects as R}from"../../../geometry/support/aaBoundingRect.js";import{getInfo as j}from"../../../geometry/support/spatialReferenceUtils.js";import x from"../../../symbols/support/ElevationInfo.js";import{simulationSettingsEqual as A,getPositions as L,getFlowSimulationSettings as M}from"../../2d/engine/flow/utils.js";import U from"./SubView3D.js";import{makeScheduleFunction as P}from"./support/makeScheduleFunction.js";import{tileFilterDistance as E,thresholdForLoadingAllTiles as I,fadeOutTime as q,fadeInTime as F,defaultTransitionDuration as V,transitionDurationFactor as k,seamlessTransitionEnabled as C,averageLoadingTimeSmoothingFactor as D,minimumTracingResolution as B}from"../support/flow/constants.js";import{wrappedWidth as W,isFullExtent as z,FlowQuery3D as G}from"../support/flow/FlowQuery3D.js";import{FlowWorkerHandle as H}from"../support/flow/FlowWorkerHandle.js";import{materialParametersFromRenderer as O,createStreamlineGeometry as N}from"../support/flow/geometryUtils.js";import{boundingRectOfTiles as Q}from"../support/flow/loadUtils.js";import{StreamlineResources3DOverlay as J}from"../support/flow/StreamlineResources3DOverlay.js";import{StreamlineResources3DShape as K}from"../support/flow/StreamlineResources3DShape.js";import{tilesAreRelated as X}from"../terrain/tileUtils.js";import{isScreenSizePerspectiveEnabled as Y}from"../webgl-engine/lib/screenSizePerspectiveUtils.js";import{RibbonLineMaterial as Z}from"../webgl-engine/materials/RibbonLineMaterial.js";import{isInEffectiveScaleRange as $,hasLayerBasedScaleVisibility as ee}from"../../support/layerViewUtils.js";import{TaskPriority as te}from"../../support/Scheduler.js";let ie=class extends U{constructor(e){super(e),this.type="flow",this.renderedTiles=null,this.requireLoad=!1,this.workerHandle=null,this.frameTask=null,this._averageLoadingTime=p(0),this._abortController=null,this._loadingState="ready-to-load",this._tilesUpdateIsWaiting=!1,this._debugAllowAutoLoading=!0,this.emissiveStrength=0,this._overrideMaterialParameters=null,this._overrideSimulationSettings=null,this._overrideTransitionEnabled=null,this._updateTask=null,this._debouncedTileUpdate=s(async()=>{const{allTiles:e}=this.surface,t=this._getTileFilterFunction(),i=new Set;function*r(r){for(let s=0;s<e.length;++s){const n=e.at(s);t(n)&&i.add(n),r.madeProgress(),r.done&&(r=yield)}}await this.frameTask.scheduleGenerator(r),this.renderedTiles=i})}initialize(){const{surface:e,view:t}=this,{resourceController:i}=t;this.workerHandle=new H(P(i)),this.frameTask=i.scheduler.registerTask(te.FLOW_GENERATOR),this._updateTask=h({update:e=>this._update(e)}),this.addHandles([l(()=>this._simulationSettings,()=>this.triggerLoad(),{sync:!0,equals:(e,t)=>null==e&&null==t||null!=e&&null!=t&&A(e,t)}),l(()=>{const{elevationInfo:e}=this;return[this._clippingArea,this._visible,this._draped,this.view.state.contentPixelRatio,this.view.viewingMode,e?.mode,e?.offset,e?.unit,this._effectiveDensity]},()=>this.triggerLoad(),u),l(()=>this._materialParameters,e=>{this._resources?.setMaterialParameters(e),this._lastResources?.setMaterialParameters(e)}),e.on("tiles-changed",()=>{this.loadByTileTreesAllowed&&this._triggerTilesUpdate()}),t.enableFeatureTiles(),l(()=>[this._dataBounds,this._featureTilesBounds,this.loadAllTiles],()=>this._triggerTilesUpdate()),l(()=>this._flowRenderer,(e,t)=>{const i=t?.visualVariables??[],r=e?.visualVariables??[];r.length===i.length&&r.every((e,t)=>e.type===i[t].type)||this.clear()}),a(()=>!t.featureTiles?.updating,()=>{this.loadByTileTreesAllowed&&this._triggerTilesUpdate()})]),this._triggerTilesUpdate()}destroy(){this._updateTask=i(this._updateTask),this.abort(),this.clear()}abort(){this._abortController=r(this._abortController),this.requireLoad=!1}get _clippingArea(){const e=y(this.view.clippingArea,this.surface.spatialReference).geometry;return null==e?null:v(e)}get _dataBounds(){const e=y(this.layer.fullExtent,this.surface.spatialReference).geometry;return null==e?null:v(e)}get _draped(){return"on-the-ground"===this.elevationInfo.mode}get _ellipsoidRadius(){return f(this.view.spatialReference).radius}get extent(){const{spatialReference:e}=this.surface;let t=this.renderedTiles;if(null==e||null==t)return null;const i=this.view.terrainLevel;if(null!=i){const e=new Set;t.forEach(t=>{Math.abs(i-t.level)<E&&e.add(t)}),t=e}const r=Q(t,this.spatialReferenceInfo);return null==r?null:(w(r,this._clippingArea,r),T(r,e))}get loadAllTiles(){const{position:e}=this.view.camera,t=e.z;if(null==t)return!1;return t*m(e.spatialReference)/this._ellipsoidRadius>=I}get loadByTileTreesAllowed(){return!this.loadAllTiles||!this.loadRequirementsMet}get _featureTilesBounds(){const e=this.view.featureTiles?.filterExtent,t=y(e,this.surface.spatialReference).geometry;return null==t?null:v(t)}get _flowRenderer(){const e=this.layer.renderer;return"flow"!==e?.type?null:e}get _materialParameters(){return{...O(this._flowRenderer,this.layerView.fullOpacity,this.emissiveStrength),fadeInTime:F,fadeOutTime:q,...this._overrideMaterialParameters,hasSlicePlane:this.layerView.slicePlaneEnabled,screenSizePerspective:!this._draped&&Y(this.layer.screenSizePerspectiveEnabled)?this.view.screenSizePerspective.parameters:null}}get _opacity(){return this.layerView.fullOpacity}get _seamlessTransitionWaitingTime(){const{_averageLoadingTime:e}=this;return p(0===e?V:this._averageLoadingTime*k)}get _seamlessTransitionEnabled(){return null!=this._overrideTransitionEnabled?this._overrideTransitionEnabled:C}get _tracingResolution(){const{extent:e}=this;if(!e)return[0,0];const t=W(e.xmin,e.xmax,this.spatialReferenceInfo?.valid)/(e.ymax-e.ymin),[i,r]=this.view.size;let s,n;i<r?(s=i,n=i/t):(s=r*t,n=r);const o=B,l=this.view.qualitySettings.flow3D.maxTracingResolution,a=Math.max(1,o/Math.min(s,n)),u=a*Math.min(1,l/Math.max(s*a,n*a));return[Math.round(s*u),Math.round(n*u)]}get _visible(){const e=this._flowRenderer?.color;return this.visibleAtCurrentScale&&this.layer.effectiveVisible&&this._opacity>0&&(null==e||e.a>0)}get _estimatedStreamlines(){const{extent:e,_simulationSettings:t,renderedTiles:i}=this;if(null==t||null==i)return 0;const r=this._tracingResolution[0]*this._tracingResolution[1]/t.lineSpacing**2*t.density,s=null==e?null:v(e);if(null==s)return 0;let n=0;for(const a of i)S(s,a.extent)&&(n+=b(a.extent));const o=b(s),l=0===o?0:n/o;return 2*Math.round(r*l)}get _effectiveDensity(){const{_estimatedStreamlines:e,_simulationSettings:t}=this,{qualitySettings:i,quality:r}=this.view;if(null==t)return 0;const s=i.flow3D.maxTotalNumberOfStreamlines,n=e>=s?s/e:1,o=t.density*n*r;return t.lineSpacing/Math.sqrt(o)<t.lineCollisionWidth?4*t.lineSpacing:o}get elevationInfo(){return this.layer.elevationInfo??re}startPositions(e){if(!this._seamlessTransitionEnabled)return[];const{_flowRenderer:t,_resources:i}=this;return null==t||null==i?[]:L(i.streamlines,i.query,e,t.flowSpeed)}get needsMagnitude(){return this._flowRenderer?.hasVisualVariables()??!1}get spatialReferenceInfo(){return j(this.surface.spatialReference)}get layer(){return this.layerView.layer}get loadingState(){return this._loadingState}get loadRequirementsMet(){return null!=this.renderedTiles&&this.renderedTiles.size>0}getUpdating(){return this.updatingHandles.updating||this.requireLoad||"before-transition"===this._loadingState}get updating(){return this.getUpdating()}get visibleAtCurrentScale(){return!ee()||$(this.layer.effectiveScaleRange,this.view.scale)}get _simulationSettings(){const{_flowRenderer:e,_overrideSimulationSettings:t}=this;if(null==e)return null;let i=M(e);return i.segmentLength=i.lineCollisionWidth/2,i.onlyForwardTracing=!1,null!=t&&(i={...i,...t}),i}getSimulationSettings(e){const{_simulationSettings:t,spatialReferenceInfo:i}=this;if(null==t)return null;const r="global"===this.view.viewingMode&&null!=i&&z(e.extent.xmin,e.extent.xmax,i);return{...t,wrapAround:r,density:this._effectiveDensity}}get surface(){return this.view.basemapTerrain}doRefresh(){this.triggerLoad()}clear(){this._resources?.detach(),this._resources=null,this._lastResources?.detach(),this._lastResources=null,this._loadingState="ready-to-load"}_update(e){const t=c(e.time);this._lastResources?.hasFadedOut(t)&&this._lastResources.detach();const i=this._nextStateForTransition(t);if(!this.requireLoad||this.updatingHandles.updating||"ready-to-load"!==i||!this.loadRequirementsMet)return void(this._loadingState=i);this._loadingState="loading";const r=async()=>{const e=performance.now(),i=this._seamlessTransitionEnabled&&null!=this._resources?p(t+this._seamlessTransitionWaitingTime):t;await this._load(i);const r=p((performance.now()-e)/1e3);this._updateAverageLoadingTime(r)};this.updatingHandles.addPromise(n(r())),this.requireLoad=!1}_updateAverageLoadingTime(e){const t=D;this._averageLoadingTime=p(t*e+(1-t)*this._averageLoadingTime)}triggerLoad(){this._debugAllowAutoLoading&&(this.requireLoad=!0)}async _load(e){const{extent:t,view:i}=this;if(!this._visible)return this.clear(),void(this._loadingState="ready-to-load");if(null==t)return void(this._loadingState="ready-to-load");const r=new G(t,this.layerView.timeExtent,this._tracingResolution,i.state.contentPixelRatio,e);null==this._abortController&&(this._abortController=new AbortController);const s=this._abortController,n=await this._loadStreamlines(r,s.signal);if(o(s.signal),this._visible&&null!=n){this._lastResources?.detach(),this._lastResources=this._resources,this._resources=n;const t=performance.now()/1e3,i=t>e?t:e;null!=this._lastResources&&(this._lastResources.endTime=i),this._resources.startTime=i,await n.attach(),this._loadingState=this._seamlessTransitionEnabled?"before-transition":"transitioning"}else this._loadingState="ready-to-load"}async _loadStreamlines(e,t){const i=await this.fetchDataAndGenerateStreamlines(e,t);if(null==i)return null;const{geometries:r,material:s}=await this._createGeometry(e,i);return this._draped?new J(e,i,s,r,this.layerView):new K(e,i,s,r,this.view)}async fetchDataAndGenerateStreamlines(e,t){return null}async _createGeometry(e,t){const i=new Z(this._materialParameters,this.view.state.isGlobal),r=new Array,{elevationInfo:s,_draped:n,view:o}=this;function*l(l){for(let a=0;a<t.length;++a)r.push(N(o,e,t[a],s,i,n)),l.madeProgress(),l.done&&(l=yield)}return await this.frameTask.scheduleGenerator(l),{geometries:r,material:i}}_triggerTilesUpdate(){if(this._tilesUpdateIsWaiting)return;this._tilesUpdateIsWaiting=!0;const e=async()=>{await d(()=>this.view.stationary),this._tilesUpdateIsWaiting=!1,await this._debouncedTileUpdate()};this.updatingHandles.addPromise(n(e()))}_getTileFilterFunction(){const{_dataBounds:e,view:i,_featureTilesBounds:r}=this;if(this.loadAllTiles)return t=>t.leaf&&se(e,t.extent);const s=t=>t.rendered&&t.visible&&se(e,t.extent),{featureTiles:n}=i;if(!n)return s;const o=n.tiles.filter(e=>e.measures.visible);return e=>s(e)&&se(r,e.extent)&&o.some(({lij:i})=>t(i,e.lij)||X(i,e.lij))}_nextStateForTransition(e){const{_resources:t}=this;if(null==this._flowRenderer||null==t||"ready-to-load"===this._loadingState||"loading"===this._loadingState)return this._loadingState;const i=t.startTime;return e<i?"before-transition":e<i+q?"transitioning":"ready-to-load"}get usedMemory(){return(this._lastResources?.usedMemory??0)+(this._resources?.usedMemory??0)}get test(){}};e([g()],ie.prototype,"type",void 0),e([g()],ie.prototype,"renderedTiles",void 0),e([g()],ie.prototype,"_resources",void 0),e([g()],ie.prototype,"_lastResources",void 0),e([g()],ie.prototype,"requireLoad",void 0),e([g()],ie.prototype,"_averageLoadingTime",void 0),e([g()],ie.prototype,"_loadingState",void 0),e([g()],ie.prototype,"emissiveStrength",void 0),e([g()],ie.prototype,"_clippingArea",null),e([g()],ie.prototype,"_dataBounds",null),e([g()],ie.prototype,"_draped",null),e([g()],ie.prototype,"_ellipsoidRadius",null),e([g()],ie.prototype,"extent",null),e([g()],ie.prototype,"loadAllTiles",null),e([g()],ie.prototype,"_featureTilesBounds",null),e([g()],ie.prototype,"_flowRenderer",null),e([g()],ie.prototype,"_materialParameters",null),e([g()],ie.prototype,"_opacity",null),e([g()],ie.prototype,"_seamlessTransitionWaitingTime",null),e([g()],ie.prototype,"_seamlessTransitionEnabled",null),e([g()],ie.prototype,"_tracingResolution",null),e([g()],ie.prototype,"_visible",null),e([g()],ie.prototype,"_estimatedStreamlines",null),e([g()],ie.prototype,"_effectiveDensity",null),e([g()],ie.prototype,"elevationInfo",null),e([g()],ie.prototype,"needsMagnitude",null),e([g()],ie.prototype,"spatialReferenceInfo",null),e([g()],ie.prototype,"layer",null),e([g()],ie.prototype,"loadingState",null),e([g()],ie.prototype,"updating",null),e([g()],ie.prototype,"visibleAtCurrentScale",null),e([g()],ie.prototype,"_overrideMaterialParameters",void 0),e([g()],ie.prototype,"_overrideSimulationSettings",void 0),e([g()],ie.prototype,"_overrideTransitionEnabled",void 0),e([g()],ie.prototype,"_simulationSettings",null),e([g()],ie.prototype,"surface",null),ie=e([_("esri.views.3d.layers.FlowSubView3D")],ie);const re=new x({mode:"on-the-ground"});function se(e,t){return null==e||null==t||R(e,t)}export{ie as default};
5
+ import{__decorate as e}from"tslib";import{equals as t}from"../../../core/arrayUtils.js";import"../../../core/has.js";import{removeMaybe as i,abortMaybe as r}from"../../../core/maybe.js";import{debounce as s,ignoreAbortErrors as n,throwIfAborted as o}from"../../../core/promiseUtils.js";import{watch as l,when as a,sync as u,whenOnce as d}from"../../../core/reactiveUtils.js";import{addFrameTask as h}from"../../../core/scheduling.js";import{Seconds as p,secondsFromMilliseconds as c}from"../../../core/time.js";import{getMetersPerVerticalUnitForSR as m}from"../../../core/unitUtils.js";import{property as g}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/Logger.js";import{subclass as _}from"../../../core/accessorSupport/decorators/subclass.js";import{getReferenceEllipsoid as f}from"../../../geometry/ellipsoidUtils.js";import{projectOrLoad as y}from"../../../geometry/projectionUtils.js";import{fromExtent as v,intersection as w,toExtent as T,contains as S,area as b,intersects as R}from"../../../geometry/support/aaBoundingRect.js";import{getInfo as j}from"../../../geometry/support/spatialReferenceUtils.js";import x from"../../../symbols/support/ElevationInfo.js";import{simulationSettingsEqual as A,getPositions as L,getFlowSimulationSettings as M}from"../../2d/engine/flow/utils.js";import U from"./SubView3D.js";import{makeScheduleFunction as P}from"./support/makeScheduleFunction.js";import{tileFilterDistance as E,thresholdForLoadingAllTiles as I,fadeOutTime as q,fadeInTime as F,defaultTransitionDuration as V,transitionDurationFactor as k,seamlessTransitionEnabled as C,averageLoadingTimeSmoothingFactor as B,minimumTracingResolution as D}from"../support/flow/constants.js";import{wrappedWidth as W,isFullExtent as z,FlowQuery3D as G}from"../support/flow/FlowQuery3D.js";import{FlowWorkerHandle as H}from"../support/flow/FlowWorkerHandle.js";import{materialParametersFromRenderer as O,createStreamlineGeometry as N}from"../support/flow/geometryUtils.js";import{boundingRectOfTiles as Q}from"../support/flow/loadUtils.js";import{StreamlineResources3DOverlay as J}from"../support/flow/StreamlineResources3DOverlay.js";import{StreamlineResources3DShape as K}from"../support/flow/StreamlineResources3DShape.js";import{tilesAreRelated as X}from"../terrain/tileUtils.js";import{isScreenSizePerspectiveEnabled as Y}from"../webgl-engine/lib/screenSizePerspectiveUtils.js";import{RibbonLineMaterial as Z}from"../webgl-engine/materials/RibbonLineMaterial.js";import{isInEffectiveScaleRange as $,hasLayerBasedScaleVisibility as ee}from"../../support/layerViewUtils.js";import{TaskPriority as te}from"../../support/Scheduler.js";let ie=class extends U{constructor(e){super(e),this.type="flow",this.renderedTiles=null,this.requireLoad=!1,this.workerHandle=null,this.frameTask=null,this._averageLoadingTime=p(0),this._abortController=null,this._loadingState="ready-to-load",this._tilesUpdateIsWaiting=!1,this._debugAllowAutoLoading=!0,this.emissiveStrength=0,this._overrideMaterialParameters=null,this._overrideSimulationSettings=null,this._overrideTransitionEnabled=null,this._updateTask=null,this._debouncedTileUpdate=s(async()=>{const{allTiles:e}=this.surface,t=this._getTileFilterFunction(),i=new Set;function*r(r){for(let s=0;s<e.length;++s){const n=e.at(s);t(n)&&i.add(n),r.madeProgress(),r.done&&(r=yield)}}await this.frameTask.scheduleGenerator(r),this.renderedTiles=i})}initialize(){const{surface:e,view:t}=this,{resourceController:i}=t;this.workerHandle=new H(P(i)),this.frameTask=i.scheduler.registerTask(te.FLOW_GENERATOR),this._updateTask=h({update:e=>this._update(e)}),this.addHandles([l(()=>this._simulationSettings,()=>this.triggerLoad(),{sync:!0,equals:(e,t)=>null==e&&null==t||null!=e&&null!=t&&A(e,t)}),l(()=>{const{elevationInfo:e}=this;return[this._clippingArea,this._visible,this._draped,this.view.state.contentPixelRatio,this.view.viewingMode,e?.mode,e?.offset,e?.unit,this._effectiveDensity]},()=>this.triggerLoad(),u),l(()=>this._materialParameters,e=>{this._resources?.setMaterialParameters(e),this._lastResources?.setMaterialParameters(e)}),e.on("tiles-changed",()=>{this.loadByTileTreesAllowed&&this._triggerTilesUpdate()}),t.enableFeatureTiles(),l(()=>[this._dataBounds,this._featureTilesBounds,this.loadAllTiles],()=>this._triggerTilesUpdate()),l(()=>this._flowRenderer,(e,t)=>{const i=t?.visualVariables??[],r=e?.visualVariables??[];r.length===i.length&&r.every((e,t)=>e.type===i[t].type)||this.clear()}),a(()=>!t.featureTiles?.updating,()=>{this.loadByTileTreesAllowed&&this._triggerTilesUpdate()})]),this._triggerTilesUpdate()}destroy(){this._updateTask=i(this._updateTask),this.abort(),this.clear()}abort(){this._abortController=r(this._abortController),this.requireLoad=!1}get _clippingArea(){const e=y(this.view.clippingArea,this.surface.spatialReference).geometry;return null==e?null:v(e)}get _dataBounds(){const e=y(this.layer.fullExtent,this.surface.spatialReference).geometry;return null==e?null:v(e)}get _draped(){return"on-the-ground"===this.elevationInfo.mode}get _ellipsoidRadius(){return f(this.view.spatialReference).radius}get extent(){const{spatialReference:e}=this.surface;let t=this.renderedTiles;if(null==e||null==t)return null;const i=this.view.terrainLevel;if(null!=i){const e=new Set;t.forEach(t=>{Math.abs(i-t.level)<E&&e.add(t)}),t=e}const r=Q(t,this.spatialReferenceInfo);return null==r?null:(w(r,this._clippingArea,r),T(r,e))}get loadAllTiles(){const{position:e}=this.view.camera,t=e.z;if(null==t)return!1;return t*m(e.spatialReference)/this._ellipsoidRadius>=I}get loadByTileTreesAllowed(){return!this.loadAllTiles||!this.loadRequirementsMet}get _featureTilesBounds(){const e=this.view.featureTiles?.filterExtent,t=y(e,this.surface.spatialReference).geometry;return null==t?null:v(t)}get _flowRenderer(){const e=this.layer.renderer;return"flow"!==e?.type?null:e}get _materialParameters(){return{...O(this._flowRenderer,this.layerView.fullOpacity,this.emissiveStrength),fadeInTime:F,fadeOutTime:q,...this._overrideMaterialParameters,hasSlicePlane:this.layerView.slicePlaneEnabled,screenSizePerspective:!this._draped&&Y(this.layer.screenSizePerspectiveEnabled)?this.view.screenSizePerspective.parameters:null}}get _opacity(){return this.layerView.fullOpacity}get _seamlessTransitionWaitingTime(){const{_averageLoadingTime:e}=this;return p(0===e?V:this._averageLoadingTime*k)}get _seamlessTransitionEnabled(){return null!=this._overrideTransitionEnabled?this._overrideTransitionEnabled:C}get _tracingResolution(){const{extent:e}=this;if(!e)return[0,0];const t=W(e.xmin,e.xmax,this.spatialReferenceInfo?.valid)/(e.ymax-e.ymin),[i,r]=this.view.size;let s,n;i<r?(s=i,n=i/t):(s=r*t,n=r);const o=D,l=this.view.qualitySettings.flow.maxTracingResolution,a=Math.max(1,o/Math.min(s,n)),u=a*Math.min(1,l/Math.max(s*a,n*a));return[Math.round(s*u),Math.round(n*u)]}get _visible(){const e=this._flowRenderer?.color;return this.visibleAtCurrentScale&&this.layer.effectiveVisible&&this._opacity>0&&(null==e||e.a>0)}get _estimatedStreamlines(){const{extent:e,_simulationSettings:t,renderedTiles:i}=this;if(null==t||null==i)return 0;const r=this._tracingResolution[0]*this._tracingResolution[1]/t.lineSpacing**2*t.density,s=null==e?null:v(e);if(null==s)return 0;let n=0;for(const a of i)S(s,a.extent)&&(n+=b(a.extent));const o=b(s),l=0===o?0:n/o;return 2*Math.round(r*l)}get _effectiveDensity(){const{_estimatedStreamlines:e,_simulationSettings:t}=this,{qualitySettings:i,quality:r}=this.view;if(null==t)return 0;const s=i.flow.maxTotalNumberOfStreamlines,n=e>=s?s/e:1,o=t.density*n*r;return t.lineSpacing/Math.sqrt(o)<t.lineCollisionWidth?4*t.lineSpacing:o}get elevationInfo(){return this.layer.elevationInfo??re}startPositions(e){if(!this._seamlessTransitionEnabled)return[];const{_flowRenderer:t,_resources:i}=this;return null==t||null==i?[]:L(i.streamlines,i.query,e,t.flowSpeed)}get needsMagnitude(){return this._flowRenderer?.hasVisualVariables()??!1}get spatialReferenceInfo(){return j(this.surface.spatialReference)}get layer(){return this.layerView.layer}get loadingState(){return this._loadingState}get loadRequirementsMet(){return null!=this.renderedTiles&&this.renderedTiles.size>0}getUpdating(){return this.updatingHandles.updating||this.requireLoad||"before-transition"===this._loadingState}get updating(){return this.getUpdating()}get visibleAtCurrentScale(){return!ee()||$(this.layer.effectiveScaleRange,this.view.scale)}get _simulationSettings(){const{_flowRenderer:e,_overrideSimulationSettings:t}=this;if(null==e)return null;let i=M(e);return i.segmentLength=i.lineCollisionWidth/2,i.onlyForwardTracing=!1,null!=t&&(i={...i,...t}),i}getSimulationSettings(e){const{_simulationSettings:t,spatialReferenceInfo:i}=this;if(null==t)return null;const r="global"===this.view.viewingMode&&null!=i&&z(e.extent.xmin,e.extent.xmax,i);return{...t,wrapAround:r,density:this._effectiveDensity}}get surface(){return this.view.basemapTerrain}doRefresh(){this.triggerLoad()}clear(){this._resources?.detach(),this._resources=null,this._lastResources?.detach(),this._lastResources=null,this._loadingState="ready-to-load"}_update(e){const t=c(e.time);this._lastResources?.hasFadedOut(t)&&this._lastResources.detach();const i=this._nextStateForTransition(t);if(!this.requireLoad||this.updatingHandles.updating||"ready-to-load"!==i||!this.loadRequirementsMet)return void(this._loadingState=i);this._loadingState="loading";const r=async()=>{const e=performance.now(),i=this._seamlessTransitionEnabled&&null!=this._resources?p(t+this._seamlessTransitionWaitingTime):t;await this._load(i);const r=p((performance.now()-e)/1e3);this._updateAverageLoadingTime(r)};this.updatingHandles.addPromise(n(r())),this.requireLoad=!1}_updateAverageLoadingTime(e){const t=B;this._averageLoadingTime=p(t*e+(1-t)*this._averageLoadingTime)}triggerLoad(){this._debugAllowAutoLoading&&(this.requireLoad=!0)}async _load(e){const{extent:t,view:i}=this;if(!this._visible)return this.clear(),void(this._loadingState="ready-to-load");if(null==t)return void(this._loadingState="ready-to-load");const r=new G(t,this.layerView.timeExtent,this._tracingResolution,i.state.contentPixelRatio,e);null==this._abortController&&(this._abortController=new AbortController);const s=this._abortController,n=await this._loadStreamlines(r,s.signal);if(o(s.signal),this._visible&&null!=n){this._lastResources?.detach(),this._lastResources=this._resources,this._resources=n;const t=performance.now()/1e3,i=t>e?t:e;null!=this._lastResources&&(this._lastResources.endTime=i),this._resources.startTime=i,await n.attach(),this._loadingState=this._seamlessTransitionEnabled?"before-transition":"transitioning"}else this._loadingState="ready-to-load"}async _loadStreamlines(e,t){const i=await this.fetchDataAndGenerateStreamlines(e,t);if(null==i)return null;const{geometries:r,material:s}=await this._createGeometry(e,i);return this._draped?new J(e,i,s,r,this.layerView):new K(e,i,s,r,this.view)}async fetchDataAndGenerateStreamlines(e,t){return null}async _createGeometry(e,t){const i=new Z(this._materialParameters,this.view.state.isGlobal),r=new Array,{elevationInfo:s,_draped:n,view:o}=this;function*l(l){for(let a=0;a<t.length;++a)r.push(N(o,e,t[a],s,i,n)),l.madeProgress(),l.done&&(l=yield)}return await this.frameTask.scheduleGenerator(l),{geometries:r,material:i}}_triggerTilesUpdate(){if(this._tilesUpdateIsWaiting)return;this._tilesUpdateIsWaiting=!0;const e=async()=>{await d(()=>this.view.stationary),this._tilesUpdateIsWaiting=!1,await this._debouncedTileUpdate()};this.updatingHandles.addPromise(n(e()))}_getTileFilterFunction(){const{_dataBounds:e,view:i,_featureTilesBounds:r}=this;if(this.loadAllTiles)return t=>t.leaf&&se(e,t.extent);const s=t=>t.rendered&&t.visible&&se(e,t.extent),{featureTiles:n}=i;if(!n)return s;const o=n.tiles.filter(e=>e.measures.visible);return e=>s(e)&&se(r,e.extent)&&o.some(({lij:i})=>t(i,e.lij)||X(i,e.lij))}_nextStateForTransition(e){const{_resources:t}=this;if(null==this._flowRenderer||null==t||"ready-to-load"===this._loadingState||"loading"===this._loadingState)return this._loadingState;const i=t.startTime;return e<i?"before-transition":e<i+q?"transitioning":"ready-to-load"}get usedMemory(){return(this._lastResources?.usedMemory??0)+(this._resources?.usedMemory??0)}get test(){}};e([g()],ie.prototype,"type",void 0),e([g()],ie.prototype,"renderedTiles",void 0),e([g()],ie.prototype,"_resources",void 0),e([g()],ie.prototype,"_lastResources",void 0),e([g()],ie.prototype,"requireLoad",void 0),e([g()],ie.prototype,"_averageLoadingTime",void 0),e([g()],ie.prototype,"_loadingState",void 0),e([g()],ie.prototype,"emissiveStrength",void 0),e([g()],ie.prototype,"_clippingArea",null),e([g()],ie.prototype,"_dataBounds",null),e([g()],ie.prototype,"_draped",null),e([g()],ie.prototype,"_ellipsoidRadius",null),e([g()],ie.prototype,"extent",null),e([g()],ie.prototype,"loadAllTiles",null),e([g()],ie.prototype,"_featureTilesBounds",null),e([g()],ie.prototype,"_flowRenderer",null),e([g()],ie.prototype,"_materialParameters",null),e([g()],ie.prototype,"_opacity",null),e([g()],ie.prototype,"_seamlessTransitionWaitingTime",null),e([g()],ie.prototype,"_seamlessTransitionEnabled",null),e([g()],ie.prototype,"_tracingResolution",null),e([g()],ie.prototype,"_visible",null),e([g()],ie.prototype,"_estimatedStreamlines",null),e([g()],ie.prototype,"_effectiveDensity",null),e([g()],ie.prototype,"elevationInfo",null),e([g()],ie.prototype,"needsMagnitude",null),e([g()],ie.prototype,"spatialReferenceInfo",null),e([g()],ie.prototype,"layer",null),e([g()],ie.prototype,"loadingState",null),e([g()],ie.prototype,"updating",null),e([g()],ie.prototype,"visibleAtCurrentScale",null),e([g()],ie.prototype,"_overrideMaterialParameters",void 0),e([g()],ie.prototype,"_overrideSimulationSettings",void 0),e([g()],ie.prototype,"_overrideTransitionEnabled",void 0),e([g()],ie.prototype,"_simulationSettings",null),e([g()],ie.prototype,"surface",null),ie=e([_("esri.views.3d.layers.FlowSubView3D")],ie);const re=new x({mode:"on-the-ground"});function se(e,t){return null==e||null==t||R(e,t)}export{ie 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 has from"../../../core/has.js";import t from"../../../core/Logger.js";import{destroyMaybe as i,removeMaybe as s}from"../../../core/maybe.js";import{initial as r,watch as o,when as n}from"../../../core/reactiveUtils.js";import{schedule as a}from"../../../core/scheduling.js";import{property as l}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/RandomLCG.js";import{subclass as c}from"../../../core/accessorSupport/decorators/subclass.js";import{fromMat4 as d,invert as h}from"../../../core/libs/gl-matrix-2/math/mat3.js";import{create as m,IDENTITY as u}from"../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{create as p}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{fromValues as f}from"../../../core/libs/gl-matrix-2/factories/quatf64.js";import{o as g,g as b,a as y,f as _}from"../../../chunks/vec32.js";import{fromArray as w,clone as v,create as j}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{fromValues as x}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{SphericalECEFSpatialReferenceLike as M}from"../../../geometry/ellipsoidUtils.js";import{computeTranslationToOriginAndRotation as C}from"../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{localLinearScaleFactors as O}from"../../../geometry/projection/localLinearScaleFactors.js";import{projectVectorToVector as T}from"../../../geometry/projection/projectVectorToVector.js";import{create as P}from"../../../geometry/support/aaBoundingRect.js";import{BufferViewVec2f as U,BufferViewVec4f as H,BufferViewVec4u8 as S,BufferViewVec4u16 as E,BufferViewVec3f as R,BufferViewVec3u8 as V,BufferViewVec3u16 as A,BufferViewInt16 as k,BufferViewUint32 as F,BufferViewUint16 as I}from"../../../geometry/support/buffer/BufferView.js";import L from"../../../layers/support/SceneModification.js";import{getElevationOffsetInMeters as D}from"../../../support/elevationInfoUtils.js";import{toWasmModification as B}from"./I3SMeshWorkerHandle.js";import{LayerView3D as G}from"./LayerView3D.js";import{Lyr3DViewPerformanceInfo as z}from"./Lyr3DViewPerformanceInfo.js";import{addLayerViewToWasm as N,removeLayerViewFromWasm as W,getLyr3DWasm as $}from"./Lyr3DWasm.js";import{LayerElevationProvider as q}from"./i3s/LayerElevationProvider.js";import{primTypeConversion as J,wrapModeConversion as K,lyr3DTypeToByteSize as Q,alphaModeConversion as X,faceCullingConversion as Y}from"./support/lyr3dTypeConversions.js";import{Tiles3DIntersectionHandler as Z}from"./support/Tiles3DIntersectionHandler.js";import{ElevationRange as ee}from"../support/ElevationRange.js";import{toBoundingRect as te}from"../support/extentUtils.js";import{Obb as ie,compute as se}from"../support/orientedBoundingBox.js";import{ObjectParameters as re}from"../webgl-engine/collections/Component/ObjectParameters.js";import{GeometryParameters as oe,createVertexBufferLayout as ne,SourceGeometry as ae}from"../webgl-engine/collections/Component/SourceGeometry.js";import{Transform as le}from"../webgl-engine/collections/Component/Transform.js";import{RenderTexture as ce}from"../webgl-engine/core/material/RenderTexture.js";import{getEllipsoidMode as de}from"../webgl-engine/core/shaderLibrary/util/EllipsoidMode.js";import{Attribute as he}from"../webgl-engine/lib/Attribute.js";import{compressAndTransformNormals as me}from"../webgl-engine/lib/Normals.js";import{Texture as ue}from"../webgl-engine/lib/Texture.js";import{writeAttribute as pe,writeBufferVec2 as fe}from"../webgl-engine/materials/internal/bufferWriterUtils.js";import ge from"../../layers/LayerView.js";import{spatialReferenceIncompatibleError as be,isInEffectiveScaleRange as ye}from"../../support/layerViewUtils.js";import{TextureCompressionTracker as _e}from"../../support/TextureCompressionTracker.js";import{alphaCutoff as we}from"../../../webscene/support/AlphaCutoff.js";class ve{constructor(e,t,i,s,r,o,n){this.handle=e,this.componentObjects=t,this.textures=i,this.cpuMemoryUsage=s,this.vboMemoryUsage=r,this.textureMemoryUsage=o,this.obb=n,this.isVisible=!1,this.usedMemory=this.textureMemoryUsage+this.vboMemoryUsage+this.cpuMemoryUsage;const a=j();n?.getCenter(a),this._obbCenter=a,this._obbRadiusSquared=n?n?.radius**2:0}boundingVolumeIntersectsRay(e,t){if(!this.obb)return!0;const i=y(je,this._obbCenter,e),s=_(i,t);return _(i,i)-s*s<=this._obbRadiusSquared&&this.obb.intersectRay(e,t)}}const je=j();function xe(e){return Math.round(e/1048.576)/1e3}let Me=class extends(G(ge)){get hasModifications(){return this._modifications&&this._modifications.length>0}constructor(e){super(e),this.type="integrated-mesh-3dtiles",this._compressionTracker=new _e,this._modifications=new Array,this._visibleGeometryChangedSchedulerHandle=null,this._wasmLayerId=-1,this.ignoresMemoryFactor=!1,this._usedMemory=0,this._cacheMemory=0,this.drapeTargetType=1,this._applySSAO=!has("disable-feature:im-ssao"),this._shadeNormals=!!has("enable-feature:im-shading"),this._lyrHandleToObjects=new Map,this._visibleObjects=new Set,this._suspendedHandle=null,this._dbgFlags=new Set,this._memCache=e.view.resourceController.memoryController.newCache(`IM3DTiles-${this.uid}`,e=>this._deletePerObjectData(e))}initialize(){this._dbgFlags.add(3),this._dbg(2,"Tiles3DLayerView3D initialize() called");const{view:e}=this;if(this._updatingHandles.add(()=>this.layer.modifications,()=>this._loadModifications(),r),!this._canProjectWithoutEngine())throw be("layer",this.layer.spatialReference.wkid,e.renderSpatialReference?.wkid);const t=N(this).then(t=>{this._wasmLayerId=t,this._intersectionHandler=new Z(this),e.sceneIntersectionHelper.addIntersectionHandler(this._intersectionHandler),this._updatingHandles.add(()=>this.slicePlaneEnabled,e=>this._slicePlaneEnabledChange(e)),this._updatingHandles.add(()=>this._modifications,()=>this._modificationsChanged(),r),this._updatingHandles.add(()=>this.fullOpacity,()=>this._opacityChange()),this._updatingHandles.add(()=>e.clippingArea,()=>this._clippingAreaChanged(),r),this._elevationProvider=new q({view:e,layerElevationSource:this,intersectionHandler:this._intersectionHandler}),e.elevationProvider.register(1,this._elevationProvider),e.overlayManager.registerDrapeTarget(this),this.addHandles([o(()=>this.layer.elevationInfo,e=>this._elevationInfoChanged(e))]),this._suspendedHandle=o(()=>this.suspended,e=>this._wasm?.setEnabled(this,!e),r)});this.addResolvingPromise(t),this._replacesTerrain&&this.addHandles(n(()=>this.view.map.ground.opacity,()=>{this._opacityChange()}))}get _replacesTerrain(){return this.layer.replacesTerrain&&!!this.view.map.basemap?.groundLayers.includes(this.layer)}get fullOpacity(){return this._replacesTerrain?this.view.map.ground.opacity:1}get opacity(){return 1}_opacityChange(){const{fullOpacity:e}=this;this.forEachComponentObject(t=>{this._collection.getMaterial(t).objectOpacity=e})}intersect(e,t,i,s){this._intersectionHandler.intersect(e,t,i,s,null,!1)}get ready(){return!0}destroy(){this._dbg(2,"Tiles3DLayerView3D destroy() called"),W(this),this._suspendedHandle&&(this._suspendedHandle.remove(),this._suspendedHandle=null),this._intersectionHandler&&(this.view.sceneIntersectionHelper.removeIntersectionHandler(this._intersectionHandler),this._intersectionHandler=null),this._elevationProvider&&(this._elevationProvider.notifyObjectsChangedFunctional(e=>this.forEachComponentObject(t=>e(t.obb))),this.view.elevationProvider.unregister(this._elevationProvider),this._elevationProvider=null),this.view.overlayManager.unregisterDrapeTarget(this),this._lyrHandleToObjects.forEach(e=>this.freeObject(e)),this._lyrHandleToObjects.clear(),this._visibleObjects.clear(),this._usedMemory=this._cacheMemory=0,this._memCache.destroy(),this._updatingHandles=i(this._updatingHandles),this.emit("visible-geometry-changed"),this._visibleGeometryChangedSchedulerHandle=s(this._visibleGeometryChangedSchedulerHandle)}_modificationsChanged(){const e=this.layer.spatialReference,t=B(this._layerClippingArea,this._modifications,e);this._wasm?.setMeshModifications(this,t,e.wkid)}_clippingAreaChanged(){const e=this.layer.spatialReference,t=P();this._layerClippingArea=te(this.view.clippingArea,t,e)?t:null,this._modificationsChanged()}_visibleGeometryChanged(){this._visibleGeometryChangedSchedulerHandle??=a(()=>{this.emit("visible-geometry-changed"),this._visibleGeometryChangedSchedulerHandle=null})}_slicePlaneEnabledChange(e){this._intersectionHandler&&(this._intersectionHandler.slicePlaneEnabled=e),this.forEachComponentObject(t=>this._collection.getMaterial(t).commonMaterialParameters.hasSlicePlane=e)}_elevationInfoChanged(e){this._wasm?.setLayerOffset(this,D(e))}get _wasm(){return $(this.view)}get wasmLayerId(){return this._wasmLayerId}get usedMemory(){return this._usedMemory}get unloadedMemory(){return 0}get cachedMemory(){return this._cacheMemory}get visibleAtCurrentScale(){return ye(this.layer.effectiveScaleRange,this.view.scale)}get performanceInfo(){let e=0,t=0,i=0,s=0,r=0,o=0;return this._lyrHandleToObjects.forEach(n=>{n.isVisible?(e+=n.textureMemoryUsage,t+=n.vboMemoryUsage,r++):(i+=n.textureMemoryUsage,s+=n.vboMemoryUsage,o++)}),new z(this.usedMemory,r,o,xe(t),xe(e),xe(s),xe(i))}_canProjectWithoutEngine(){if(2===this.view.state.viewingMode){const e=this.view.renderSpatialReference?.isWebMercator?3857:this.view.renderSpatialReference?.wkid??-1;if(3857!==e&&32662!==e)return!1}return!0}get _stage(){return this.view.stage}get _collection(){return this._stage.renderView.componentObjectCollection}get elevationProvider(){return this._elevationProvider}get elevationOffset(){return D(this.layer.elevationInfo)}get elevationRange(){const e=this.fullExtent;return e?.zmin&&e?.zmax?new ee(e.zmin,e.zmax):null}getElevationRange(e){return null}get fullExtent(){return this.layer.fullExtent}forEachComponentObject(e){this._forEachObject(this._lyrHandleToObjects.values(),e)}forEachVisibleTile(e){for(const t of this._visibleObjects)e(t)}forEachVisibleComponentObject(e){this._forEachObject(this._visibleObjects,e)}_forEachObject(e,t){for(const i of e)for(const e of i.componentObjects)t(e)}isUpdating(){const e=this._wasm;return!(this._wasmLayerId<0||null==e)&&(e.isUpdating(this._wasmLayerId)||this._compressionTracker.compressing)}updatingFlagChanged(){this.notifyChange("updating")}async createRenderable(e){const t=e.meshData;if(null==t.data)throw new Error("meshData.data undefined");if(t.desc=JSON.parse(t.desc),null==t.desc)throw new Error("meshData.desc undefined");const i=w(t.desc.origin),s=new Array,r=this.view.basemapTerrain.spatialReference;let o,n;if("global"===this.view.viewingMode){const e=p();C(M,i,e,r),o=d(m(),e),n=h(m(),o)}else o=u,n=u;const a=v(i),l=j(),c=Pe(t.desc.obb);let f=0,b=0;const y={textureMemoryUsage:0},_=new Array,P=new Map,H=t.desc.prims.length;for(let d=0;d<H;d++){const e=t.desc.prims[d];this._dbg(2,JSON.stringify(e));if(null==J[e.ptype]||null==t.data){this._dbg(2,"[Unsupported Feature] Unsupported primitive mode ("+e.ptype+"). Skipping primitive.");continue}const h=t.desc?.materials&&null!=e.materialId?t.desc.materials[e.materialId]:null,m=null!=h?h.lightingModel:"Unlit",{positionView:p,positionAttr:w,normalsView:v,normalsAttr:M,colorAttr:C,texCoord0Attr:H,indicesView:S}=this.getBufferViews(e,t.data.buffer,o);if(null==w||null==p||null==S)continue;const E=new oe(null!=C,H?1:0,null!=v,this._shadeNormals||this._replacesTerrain,this._applySSAO),R=w.data.length/w.size,V=(e,t)=>!e||e.data.length/e.size===R||(this._dbg(3,`${t} !== numPos. Skipping primitive.`),!1);if(!V(H,"numTexcoord")||!V(C,"numColors")||!V(M,"normals"))continue;const A=ne(E),k=c?.clone()??Te(w,i);if(o!==u)for(let t=0;t<p.count;t++)p.getVec(t,l),g(l,l,o),p.setVec(t,l);const F=A.createBuffer(w.data.length);if(pe("position",w,null,null,F,0),null!=H){const e=F.getField("uv0",U);fe(H,e,0)}null!=C&&pe("color",C,null,null,F,0),null!=M&&pe("normalCompressed",M,null,null,F,0);const I=new Uint32Array([0,S.typedBuffer.length]),L=new ae({data:F.buffer,count:F.byteLength/A.stride,layoutParameters:E},{positions:p.typedBuffer,indices:S.typedBuffer},S.typedBuffer,I);f+=p.count+S.count;const D=this.view.renderSpatialReference,B=j(),G=[1,1,1];O(a,D,G,r)||this._dbg(3,"Unsupported coordinate system for IM overlay"),T(a,D,B,r);const z=this._collection.createObject(new re(x(B[0],B[1],G[0],G[1]),new le(a,n),k,L,!1));if(h){const e=e=>{e.baseColor=h.baseColorFactor,e.usePBR="Pbr"===m,e.hasParametersFromSource=!1,e.baseColorTexture=this._getTexture(h.baseColorTex,t,P,y),e.usePBR&&(e.mrrFactors=[h.metallicFactor,h.roughnessFactor,0],e.emissiveBaseColor=h.emissiveFactor??[0,0,0],e.metallicRoughnessTexture=this._getTexture(h.metalTex,t,P,y),e.emissionTexture=this._getTexture(h.emissiveTex,t,P,y),e.occlusionTexture=this._getTexture(h.occlusionTex,t,P,y),e.normalTexture=this._getTexture(h.normalTex,t,P,y)),e.objectOpacity=0,e.alphaDiscardMode=2;const i=[];e.baseColorTexture&&i.push(e.baseColorTexture.loadPromise),e.usePBR&&(e.metallicRoughnessTexture&&i.push(e.metallicRoughnessTexture.loadPromise),e.emissionTexture&&i.push(e.emissionTexture.loadPromise),e.occlusionTexture&&i.push(e.occlusionTexture.loadPromise),e.normalTexture&&i.push(e.normalTexture.loadPromise));const r=Promise.all(i);s.push(r),r.then(()=>{e.alphaDiscardMode=X[h.alphaMode],e.objectOpacity=this.fullOpacity,y.textureMemoryUsage+=e.baseColorTexture?.glTexture?.usedMemory??0,e.usePBR&&(y.textureMemoryUsage+=(e.metallicRoughnessTexture?.glTexture?.usedMemory??0)+(e.emissionTexture?.glTexture?.usedMemory??0)+(e.occlusionTexture?.glTexture?.usedMemory??0)+(e.normalTexture?.glTexture?.usedMemory??0))}),e.commonMaterialParameters.doubleSided=h.isDoubleSided,e.commonMaterialParameters.cullFace=Y[h.faceCulling??"NotSet"],e.commonMaterialParameters.hasSlicePlane=this.slicePlaneEnabled,e.componentParameters.castShadows=0,e.textureAlphaCutoff=h.alphaCutoff??we,e.alphaDiscardMode=X[h.alphaMode],e.isIntegratedMesh=!0,e.sphereDepthInterpolate=this.layer.hasGoogleUrl,e.polygonOffsetEnabled=!1,e.hasOccludees=!1,e.ellipsoidMode=de(this.view.spatialReference)};this._collection.updateMaterial(z,e)}_.push(z),b+=this._collection.getObjectGPUMemoryUsage(z)}await Promise.all(s);const S=new Array;P.forEach(e=>{S.push(e)});const E=new ve(e.handle,_,S,f,b,y.textureMemoryUsage,c);return this._memCache.put(`${E.handle}`,E),this._lyrHandleToObjects.set(e.handle,E),this._cacheMemory+=E.usedMemory,{memUsageBytes:E.usedMemory}}freeRenderable(e){const t=this._lyrHandleToObjects.get(e);t&&(t.isVisible?(this._visibleObjects.delete(t),this._usedMemory-=t.usedMemory):this._cacheMemory-=t.usedMemory,this.freeObject(t),this._lyrHandleToObjects.delete(e))}freeObject(e){this._memCache.pop(`${e.handle}`),e.textures.forEach(e=>this._stage.removeTexture(e)),e.componentObjects.forEach(e=>this._collection.destroyObject(e))}setRenderableVisibility(e,t,i){for(let s=0;s<i;++s){const i=t[s];if(!i)continue;const r=e[s],o=this._lyrHandleToObjects.get(r);if(o){if(o.isVisible)continue;this._visibleGeometryChanged(),o.isVisible=!0,this._visibleObjects.add(o),this._usedMemory+=o.usedMemory,this._cacheMemory-=o.usedMemory,o.componentObjects.forEach(e=>{this._collection.setObjectVisibility(e,i),this._elevationProvider.notifyObjectChanged(this._collection.getComponentObb(e))}),this._memCache.pop(`${r}`)}}for(let s=0;s<i;++s){const i=e[s],r=t[s];if(r)continue;const o=this._lyrHandleToObjects.get(i);if(o){if(!o.isVisible)continue;this._visibleGeometryChanged(),o.isVisible=!1,this._visibleObjects.delete(o),this._usedMemory-=o.usedMemory,this._cacheMemory+=o.usedMemory,o.componentObjects.forEach(e=>{this._collection.setObjectVisibility(e,r),this._elevationProvider.notifyObjectChanged(this._collection.getComponentObb(e))}),this._memCache.put(`${i}`,o)}}}setLodPixelThreshold(e){this._wasm?.setLodPixelThreshold(this,e)}_getTexture(e,t,i,s){let r=null;if(e&&t.desc?.images&&t.data?.buffer){const o=t.desc.images[e?.imageId];if(r=i.get(o),!r&&o){const n=this._stage.renderView.renderingContext.parameters.maxMaxAnisotropy,a=!!o.mipCount||n>1,l=K[e.wrapMode??"None"];let c=o.alpha?6408:6407;const d=new Uint8Array(t.data.buffer,o.data.byteOffset,o.data.byteCount);let h=null,m=null,u=null;switch(o.format){case"Raw":"R8"===o.pixelFormat?(h=d,c=6403,m=""):"Rgb8"===o.pixelFormat?(h=d,c=6407,m=""):"Rgba8"===o.pixelFormat&&(h=d,c=6408,m="");break;case"Dxt1":h=d,c=6407,m="image/vnd-ms.dds";break;case"Dxt5":h=d,c=6408,m="image/vnd-ms.dds";break;case"Basis":h=d,c=6407,m="image/ktx2";break;case"Png":m="image/png",u=document.createElement("img");break;case"Jpeg":m="image/jpeg",u=document.createElement("img");break;case"Etc2":m="image/ktx",u=document.createElement("img");break;case"Astc":this._dbg(3,"Astc texture not supported");break;case"Pvrtc":this._dbg(3,"Pvrtc texture not supported")}if(u&&m){const e=new Blob([d],{type:m});u.src=URL.createObjectURL(e),h=u}if(h&&null!=m){const e=has("enable-feature:esri-compress-IM-textures")?{compressionTracker:this._compressionTracker,compressionCallback:e=>{e&&e>0&&(s.textureMemoryUsage-=e)}}:void 0;r=new ue(h,{mipmap:a,maxAnisotropy:n,encoding:m,wrap:l,pixelFormat:c,compressionOptions:e,noUnpackFlip:!0,width:o.mip0Width,height:o.mip0Height}),this._stage.addTexture(r),i.set(o,r)}}}return r?new ce(this.view.stage.renderView.textures,r.id):null}getBufferViews(e,t,i){let s,r,o,n,a,l,c,d=null;for(let m=0;m<e.atrbs.length;m++){const c=e.atrbs[m],u=c.view,p=void 0,f=u.byteOffset+u.byteCount,g=u.byteCount/Q[u.type],b=[...Array(g).keys()].map(e=>e);try{switch(c.sem){case"Position":3!==u.ncomp||"F32"!==u.type?this._dbg(3,"[Unsupported Feature] Unsupported view for Position ("+u+")"):(s=new R(t,u.byteOffset,p,f),r=new he(s.typedBuffer,b,3));break;case"Normal":if(3!==u.ncomp||"F32"!==u.type)this._dbg(3,"[Unsupported Feature] Unsupported view for Normal ("+u+")");else{const e=new R(t,u.byteOffset,p,f),s=me(e.typedBuffer,i);a=new k(s.buffer),l=new he(a.typedBuffer,b,2)}break;case"TexCoord":2!==u.ncomp||"F32"!==u.type?this._dbg(3,"[Unsupported Feature] Unsupported view for Texcoord ("+u+")"):void 0===n&&(n=new he(new U(t,u.byteOffset,p,f).typedBuffer,b,2));break;case"Color":4===u.ncomp?("F32"===u.type&&(d=new H(t,u.byteOffset,p,f)),"U8"===u.type&&(d=new S(t,u.byteOffset,p,f)),"U16"===u.type&&(d=new E(t,u.byteOffset,p,f))):3===u.ncomp&&("F32"===u.type&&(d=new R(t,u.byteOffset,p,f)),"U8"===u.type&&(d=new V(t,u.byteOffset,p,f)),"U16"===u.type&&(d=new A(t,u.byteOffset,p,f))),null==d?this._dbg(2,"[Unsupported Feature] Unsupported view for Color ("+u+")"):o=new he(d.typedBuffer,b,u.ncomp);break;case"FeatureIndex":break;default:this._dbg(2,"[Unsupported Feature] Unsupported semantic ("+c.sem+"). Skipping vertex attribute.")}}catch(h){this._dbg(2,"Error Creating buffer ("+h+"). Skipping vertex attribute.")}}if(e.index){const i=e.index.view,s=void 0,r=i.byteOffset+i.byteCount;switch(e.index.view.type){case"U16":c=new I(t,i.byteOffset,s,r);break;case"U32":c=new F(t,i.byteOffset,s,r);break;default:this._dbg(3,"[Unsupported Feature] index type not supported ("+i.type+").")}}if(null==c&&null!=s){const e=s.count;if(e<65535){const t=new Uint16Array(e);c=new I(t.buffer)}else{const t=new Uint32Array(e);c=new F(t.buffer)}for(let t=0;t<e;t++)c.set(t,t)}return{positionView:s,positionAttr:r,colorAttr:o,texCoord0Attr:n,indicesView:c,normalsView:a,normalsAttr:l}}_loadModifications(){if(this.removeHandles("modifications"),null==this.layer.modifications)return void(this._modifications=[]);const e=this.layer.modifications;this.addHandles(this._updatingHandles.addOnCollectionChange(()=>e,()=>this._modifications=e.toArray(),r),"modifications")}_deletePerObjectData(e){this._wasm?.onRenderableEvicted(this,e.handle,e.usedMemory),this.freeRenderable(e.handle)}_dbg(e,i){this._dbgFlags.has(e)&&(3===e?t.getLogger(this).error(i):t.getLogger(this).warn(i))}};e([l()],Me.prototype,"fullOpacity",null),e([l({type:[L]})],Me.prototype,"_modifications",void 0),e([l()],Me.prototype,"_visibleGeometryChangedSchedulerHandle",void 0),e([l()],Me.prototype,"layer",void 0),e([l({readOnly:!0})],Me.prototype,"visibleAtCurrentScale",null),e([l()],Me.prototype,"elevationOffset",null),Me=e([c("esri.views.3d.layers.IntegratedMesh3DTilesLayerView3D")],Me);const Ce=Me,Oe=j();function Te(e,t){const i=se(e);return b(Oe,i.center,t),i.center=Oe,i}function Pe(e){return e?new ie(e.center,e.halfSize,f(...e.quaternion)):null}export{Ce as default};
5
+ import{__decorate as e}from"tslib";import has from"../../../core/has.js";import t from"../../../core/Logger.js";import{destroyMaybe as i,removeMaybe as r}from"../../../core/maybe.js";import{initial as s,watch as o,when as n}from"../../../core/reactiveUtils.js";import{schedule as a}from"../../../core/scheduling.js";import{property as l}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/RandomLCG.js";import{subclass as c}from"../../../core/accessorSupport/decorators/subclass.js";import{fromMat4 as d,invert as h}from"../../../core/libs/gl-matrix-2/math/mat3.js";import{create as m,IDENTITY as u}from"../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{create as p}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{fromValues as f}from"../../../core/libs/gl-matrix-2/factories/quatf64.js";import{o as g,g as y,a as b,f as _}from"../../../chunks/vec32.js";import{fromArray as w,clone as v,create as j}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{fromValues as M}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{SphericalECEFSpatialReferenceLike as x}from"../../../geometry/ellipsoidUtils.js";import{computeTranslationToOriginAndRotation as C}from"../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{localLinearScaleFactors as O}from"../../../geometry/projection/localLinearScaleFactors.js";import{projectVectorToVector as T}from"../../../geometry/projection/projectVectorToVector.js";import{create as U}from"../../../geometry/support/aaBoundingRect.js";import{BufferViewVec2f as P,BufferViewVec4f as H,BufferViewVec4u8 as E,BufferViewVec4u16 as S,BufferViewVec3f as R,BufferViewVec3u8 as V,BufferViewVec3u16 as A,BufferViewInt16 as k,BufferViewUint32 as F,BufferViewUint16 as I}from"../../../geometry/support/buffer/BufferView.js";import L from"../../../layers/support/SceneModification.js";import{getElevationOffsetInMeters as D}from"../../../support/elevationInfoUtils.js";import{toWasmModification as B}from"./I3SMeshWorkerHandle.js";import{LayerView3D as G}from"./LayerView3D.js";import{Lyr3DViewPerformanceInfo as z}from"./Lyr3DViewPerformanceInfo.js";import{addLayerViewToWasm as N,removeLayerViewFromWasm as W,getLyr3DWasm as $}from"./Lyr3DWasm.js";import{LayerElevationProvider as q}from"./i3s/LayerElevationProvider.js";import{primTypeConversion as J,alphaModeConversion as K,faceCullingConversion as Q,wrapModeConversion as X,lyr3DTypeToByteSize as Y}from"./support/lyr3dTypeConversions.js";import{Tiles3DIntersectionHandler as Z}from"./support/Tiles3DIntersectionHandler.js";import{ElevationRange as ee}from"../support/ElevationRange.js";import{toBoundingRect as te}from"../support/extentUtils.js";import{Obb as ie,compute as re}from"../support/orientedBoundingBox.js";import{ObjectParameters as se}from"../webgl-engine/collections/Component/ObjectParameters.js";import{GeometryParameters as oe,createVertexBufferLayout as ne,SourceGeometry as ae}from"../webgl-engine/collections/Component/SourceGeometry.js";import{Transform as le}from"../webgl-engine/collections/Component/Transform.js";import{RenderTexture as ce}from"../webgl-engine/core/material/RenderTexture.js";import{getEllipsoidMode as de}from"../webgl-engine/core/shaderLibrary/util/EllipsoidMode.js";import{Attribute as he}from"../webgl-engine/lib/Attribute.js";import{ManagedTexture as me}from"../webgl-engine/lib/ManagedTexture.js";import{compressAndTransformNormals as ue}from"../webgl-engine/lib/Normals.js";import{writeAttribute as pe,writeBufferVec2 as fe}from"../webgl-engine/materials/internal/bufferWriterUtils.js";import ge from"../../layers/LayerView.js";import{spatialReferenceIncompatibleError as ye,isInEffectiveScaleRange as be}from"../../support/layerViewUtils.js";import{TextureCompressionTracker as _e}from"../../support/TextureCompressionTracker.js";import{alphaCutoff as we}from"../../../webscene/support/AlphaCutoff.js";class ve{constructor(e,t,i,r,s,o,n){this.handle=e,this.componentObjects=t,this.textures=i,this.cpuMemoryUsage=r,this.vboMemoryUsage=s,this.textureMemoryUsage=o,this.obb=n,this.isVisible=!1,this.usedMemory=this.textureMemoryUsage+this.vboMemoryUsage+this.cpuMemoryUsage;const a=j();n?.getCenter(a),this._obbCenter=a,this._obbRadiusSquared=n?n?.radius**2:0}boundingVolumeIntersectsRay(e,t){if(!this.obb)return!0;const i=b(je,this._obbCenter,e),r=_(i,t);return _(i,i)-r*r<=this._obbRadiusSquared&&this.obb.intersectRay(e,t)}}const je=j();function Me(e){return Math.round(e/1048.576)/1e3}let xe=class extends(G(ge)){get hasModifications(){return this._modifications&&this._modifications.length>0}constructor(e){super(e),this.type="integrated-mesh-3dtiles",this._compressionTracker=new _e,this._modifications=new Array,this._visibleGeometryChangedSchedulerHandle=null,this._wasmLayerId=-1,this.ignoresMemoryFactor=!1,this._usedMemory=0,this._cacheMemory=0,this.drapeTargetType=1,this._applySSAO=!has("disable-feature:im-ssao"),this._shadeNormals=!!has("enable-feature:im-shading"),this._lyrHandleToObjects=new Map,this._visibleObjects=new Set,this._suspendedHandle=null,this._dbgFlags=new Set,this._memCache=e.view.resourceController.memoryController.newCache(`IM3DTiles-${this.uid}`,e=>this._deletePerObjectData(e))}initialize(){this._dbgFlags.add(3),this._dbg(2,"Tiles3DLayerView3D initialize() called");const{view:e}=this;if(this._updatingHandles.add(()=>this.layer.modifications,()=>this._loadModifications(),s),!this._canProjectWithoutEngine())throw ye("layer",this.layer.spatialReference.wkid,e.renderSpatialReference?.wkid);const t=N(this).then(t=>{this._wasmLayerId=t,this._intersectionHandler=new Z(this),e.sceneIntersectionHelper.addIntersectionHandler(this._intersectionHandler),this._updatingHandles.add(()=>this.slicePlaneEnabled,e=>this._slicePlaneEnabledChange(e)),this._updatingHandles.add(()=>this._modifications,()=>this._modificationsChanged(),s),this._updatingHandles.add(()=>this.fullOpacity,()=>this._opacityChange()),this._updatingHandles.add(()=>e.clippingArea,()=>this._clippingAreaChanged(),s),this._elevationProvider=new q({view:e,layerElevationSource:this,intersectionHandler:this._intersectionHandler}),e.elevationProvider.register(1,this._elevationProvider),e.overlayManager.registerDrapeTarget(this),this.addHandles([o(()=>this.layer.elevationInfo,e=>this._elevationInfoChanged(e))]),this._suspendedHandle=o(()=>this.suspended,e=>this._wasm?.setEnabled(this,!e),s)});this.addResolvingPromise(t),this._replacesTerrain&&this.addHandles(n(()=>this.view.map.ground.opacity,()=>{this._opacityChange()}))}get _replacesTerrain(){return this.layer.replacesTerrain&&!!this.view.map.basemap?.groundLayers.includes(this.layer)}get fullOpacity(){return this._replacesTerrain?this.view.map.ground.opacity:1}get opacity(){return 1}_opacityChange(){const{fullOpacity:e}=this;this.forEachComponentObject(t=>{this._collection.getMaterial(t).objectOpacity=e})}intersect(e,t,i,r){this._intersectionHandler.intersect(e,t,i,r,null,!1)}get ready(){return!0}destroy(){this._dbg(2,"Tiles3DLayerView3D destroy() called"),W(this),this._suspendedHandle&&(this._suspendedHandle.remove(),this._suspendedHandle=null),this._intersectionHandler&&(this.view.sceneIntersectionHelper.removeIntersectionHandler(this._intersectionHandler),this._intersectionHandler=null),this._elevationProvider&&(this._elevationProvider.notifyObjectsChangedFunctional(e=>this.forEachComponentObject(t=>e(t.obb))),this.view.elevationProvider.unregister(this._elevationProvider),this._elevationProvider=null),this.view.overlayManager.unregisterDrapeTarget(this),this._lyrHandleToObjects.forEach(e=>this.freeObject(e)),this._lyrHandleToObjects.clear(),this._visibleObjects.clear(),this._usedMemory=this._cacheMemory=0,this._memCache.destroy(),this._updatingHandles=i(this._updatingHandles),this.emit("visible-geometry-changed"),this._visibleGeometryChangedSchedulerHandle=r(this._visibleGeometryChangedSchedulerHandle)}_modificationsChanged(){const e=this.layer.spatialReference,t=B(this._layerClippingArea,this._modifications,e);this._wasm?.setMeshModifications(this,t,e.wkid)}_clippingAreaChanged(){const e=this.layer.spatialReference,t=U();this._layerClippingArea=te(this.view.clippingArea,t,e)?t:null,this._modificationsChanged()}_visibleGeometryChanged(){this._visibleGeometryChangedSchedulerHandle??=a(()=>{this.emit("visible-geometry-changed"),this._visibleGeometryChangedSchedulerHandle=null})}_slicePlaneEnabledChange(e){this._intersectionHandler&&(this._intersectionHandler.slicePlaneEnabled=e),this.forEachComponentObject(t=>this._collection.getMaterial(t).commonMaterialParameters.hasSlicePlane=e)}_elevationInfoChanged(e){this._wasm?.setLayerOffset(this,D(e))}get _wasm(){return $(this.view)}get wasmLayerId(){return this._wasmLayerId}get usedMemory(){return this._usedMemory}get unloadedMemory(){return 0}get cachedMemory(){return this._cacheMemory}get visibleAtCurrentScale(){return be(this.layer.effectiveScaleRange,this.view.scale)}get performanceInfo(){let e=0,t=0,i=0,r=0,s=0,o=0;return this._lyrHandleToObjects.forEach(n=>{n.isVisible?(e+=n.textureMemoryUsage,t+=n.vboMemoryUsage,s++):(i+=n.textureMemoryUsage,r+=n.vboMemoryUsage,o++)}),new z(this.usedMemory,s,o,Me(t),Me(e),Me(r),Me(i))}_canProjectWithoutEngine(){if(2===this.view.state.viewingMode){const e=this.view.renderSpatialReference?.isWebMercator?3857:this.view.renderSpatialReference?.wkid??-1;if(3857!==e&&32662!==e)return!1}return!0}get _stage(){return this.view.stage}get _collection(){return this._stage.renderView.componentObjectCollection}get elevationProvider(){return this._elevationProvider}get elevationOffset(){return D(this.layer.elevationInfo)}get elevationRange(){const e=this.fullExtent;return e?.zmin&&e?.zmax?new ee(e.zmin,e.zmax):null}getElevationRange(e){return null}get fullExtent(){return this.layer.fullExtent}forEachComponentObject(e){this._forEachObject(this._lyrHandleToObjects.values(),e)}forEachVisibleTile(e){for(const t of this._visibleObjects)e(t)}forEachVisibleComponentObject(e){this._forEachObject(this._visibleObjects,e)}_forEachObject(e,t){for(const i of e)for(const e of i.componentObjects)t(e)}isUpdating(){const e=this._wasm;return!(this._wasmLayerId<0||null==e)&&(e.isUpdating(this._wasmLayerId)||this._compressionTracker.compressing)}updatingFlagChanged(){this.notifyChange("updating")}async createRenderable(e){if(this.destroyed){const e=`IntegratedMesh3DTilesLayerView3D[${this.layer?.title}]: createRenderable called on destroyed instance`;throw new Error(e)}let t=0;const{meshData:i}=e;if(null==i.data)throw new Error("meshData.data undefined");if(i.desc=JSON.parse(i.desc),null==i.desc)throw new Error("meshData.desc undefined");const r=w(i.desc.origin),s=new Array,o=this.view.basemapTerrain.spatialReference;let n,a;if("global"===this.view.viewingMode){const e=p();C(x,r,e,o),n=d(m(),e),a=h(m(),n)}else n=u,a=u;const l=v(r),c=j(),f=Ue(i.desc.obb);let y=0,b=0;const _={textureMemoryUsage:0},U=new Map,H=i.desc.prims.length,E=new Array;try{for(let e=0;e<H;e++){const t=i.desc.prims[e];this._dbg(2,JSON.stringify(t));if(null==J[t.ptype]||null==i.data){this._dbg(2,"[Unsupported Feature] Unsupported primitive mode ("+t.ptype+"). Skipping primitive.");continue}const d=i.desc?.materials&&null!=t.materialId?i.desc.materials[t.materialId]:null,h=null!=d?d.lightingModel:"Unlit",{positionView:m,positionAttr:p,normalsView:w,normalsAttr:v,colorAttr:x,texCoord0Attr:C,indicesView:H}=this.getBufferViews(t,i.data.buffer,n);if(null==p||null==m||null==H)continue;const E=new oe(null!=x,C?1:0,null!=w,this._shadeNormals||this._replacesTerrain,this._applySSAO),S=p.data.length/p.size,R=(e,t)=>!e||e.data.length/e.size===S||(this._dbg(3,`${t} !== numPos. Skipping primitive.`),!1);if(!R(C,"numTexcoord")||!R(x,"numColors")||!R(v,"normals"))continue;const V=ne(E),A=f?.clone()??Te(p,r);if(n!==u)for(let e=0;e<m.count;e++)m.getVec(e,c),g(c,c,n),m.setVec(e,c);const k=V.createBuffer(p.data.length);if(pe("position",p,null,null,k,0),null!=C){const e=k.getField("uv0",P);fe(C,e,0)}null!=x&&pe("color",x,null,null,k,0),null!=v&&pe("normalCompressed",v,null,null,k,0);const F=new Uint32Array([0,H.typedBuffer.length]),I=new ae({data:k.buffer,count:k.byteLength/V.stride,layoutParameters:E},{positions:m.typedBuffer,indices:H.typedBuffer},H.typedBuffer,F);y+=m.count+H.count;const L=this.view.renderSpatialReference,D=j(),B=[1,1,1];O(l,L,B,o)||this._dbg(3,"Unsupported coordinate system for IM overlay"),T(l,L,D,o);let G=()=>{},z=Promise.resolve(He);if(d){const e=e=>this._getTexture(e,i,U,_),t=e(d.baseColorTex),r="Pbr"===h,s=r?e(d.metalTex):null,o=r?e(d.emissiveTex):null,n=r?e(d.occlusionTex):null,a=r?e(d.normalTex):null,l=[t,s,o,n,a].map(e=>e?.loadPromise??null);z=Promise.all(l),G=e=>{e.baseColor=d.baseColorFactor,e.usePBR="Pbr"===h,e.hasParametersFromSource=!1,e.baseColorTexture=t,e.usePBR&&(e.mrrFactors=[d.metallicFactor,d.roughnessFactor,0],e.emissiveBaseColor=d.emissiveFactor??[0,0,0],e.metallicRoughnessTexture=s,e.emissionTexture=o,e.occlusionTexture=n,e.normalTexture=a),e.alphaDiscardMode=K[d.alphaMode],e.objectOpacity=this.fullOpacity,_.textureMemoryUsage+=e.baseColorTexture?.texture?.usedMemory??0,e.usePBR&&(_.textureMemoryUsage+=(e.metallicRoughnessTexture?.texture?.usedMemory??0)+(e.emissionTexture?.texture?.usedMemory??0)+(e.occlusionTexture?.texture?.usedMemory??0)+(e.normalTexture?.texture?.usedMemory??0)),e.commonMaterialParameters.doubleSided=d.isDoubleSided,e.commonMaterialParameters.cullFace=Q[d.faceCulling??"NotSet"],e.commonMaterialParameters.hasSlicePlane=this.slicePlaneEnabled,e.componentParameters.castShadows=0,e.textureAlphaCutoff=d.alphaCutoff??we,e.alphaDiscardMode=K[d.alphaMode],e.isIntegratedMesh=!0,e.sphereDepthInterpolate=this.layer.hasGoogleUrl,e.polygonOffsetEnabled=!1,e.hasOccludees=!1,e.ellipsoidMode=de(this.view.spatialReference)}}const N=z.then(()=>()=>{if(this.destroyed){const e="Trying to add object to destroyed layer view";throw this._dbg(3,`${e} !== numPos. Skipping primitive.`),new Error(e)}const e=this._collection.createObject(new se(M(D[0],D[1],B[0],B[1]),new le(l,a),A,I,!1));return this._collection.updateMaterial(e,G),b+=this._collection.getObjectGPUMemoryUsage(e),e});s.push(N)}if(E.push(...await Promise.all(s)),this.destroyed){throw new Error("IntegratedMesh3DTilesLayerView3D: createRenderable object destroyed during call")}}catch(A){throw U.forEach(e=>this._stage.removeTexture(e)),A}const S=E.map(e=>e()),R=new Array;U.forEach(e=>R.push(e));const V=new ve(e.handle,S,R,y,b,_.textureMemoryUsage,f);return this._lyrHandleToObjects.set(e.handle,V),this._memCache.put(Pe(V.handle),V),t=V.usedMemory,this._cacheMemory+=t,{memUsageBytes:V.usedMemory}}freeRenderable(e){const t=this._lyrHandleToObjects.get(e);t&&(t.isVisible?(this._visibleObjects.delete(t),this._usedMemory-=t.usedMemory):this._cacheMemory-=t.usedMemory,this.freeObject(t),this._lyrHandleToObjects.delete(e))}freeObject(e){const t=Pe(e.handle);this._memCache.pop(t),e.textures.forEach(e=>this._stage.removeTexture(e)),e.componentObjects.forEach(e=>this._collection.destroyObject(e))}setRenderableVisibility(e,t,i){for(let r=0;r<i;++r){const i=t[r];if(!i)continue;const s=e[r],o=this._lyrHandleToObjects.get(s);if(o){if(o.isVisible)continue;this._visibleGeometryChanged(),o.isVisible=!0,this._visibleObjects.add(o),this._usedMemory+=o.usedMemory,this._cacheMemory-=o.usedMemory,o.componentObjects.forEach(e=>{this._collection.setObjectVisibility(e,i),this._elevationProvider.notifyObjectChanged(this._collection.getComponentObb(e))}),this._memCache.pop(Pe(s))}}for(let r=0;r<i;++r){const i=e[r],s=t[r];if(s)continue;const o=this._lyrHandleToObjects.get(i);if(o){if(!o.isVisible)continue;this._visibleGeometryChanged(),o.isVisible=!1,this._visibleObjects.delete(o),this._usedMemory-=o.usedMemory,this._cacheMemory+=o.usedMemory,o.componentObjects.forEach(e=>{this._collection.setObjectVisibility(e,s),this._elevationProvider.notifyObjectChanged(this._collection.getComponentObb(e))}),this._memCache.put(Pe(i),o)}}}setLodPixelThreshold(e){this._wasm?.setLodPixelThreshold(this,e)}_getTexture(e,t,i,r){const s=e&&t.desc?.images?.[e.imageId];if(!s||!t.data?.buffer)return null;const o=i.get(s)??this._createTexture(e,t,i,r);return o?new ce(this._stage.renderView.textures,o.id):null}_createTexture(e,t,i,r){const s=e&&t.desc?.images?.[e.imageId];if(!s||!t.data?.buffer)return null;const o=this._stage,{renderView:n}=o,a=n.renderingContext.parameters.maxMaxAnisotropy,l=!!s.mipCount||a>1,c=X[e.wrapMode??"None"];let d=s.alpha?6408:6407;const h=new Uint8Array(t.data.buffer,s.data.byteOffset,s.data.byteCount);let m=null,u=null,p=null;switch(s.format){case"Raw":"R8"===s.pixelFormat?(m=h,d=6403,u=""):"Rgb8"===s.pixelFormat?(m=h,d=6407,u=""):"Rgba8"===s.pixelFormat&&(m=h,d=6408,u="");break;case"Dxt1":m=h,d=6407,u="image/vnd-ms.dds";break;case"Dxt5":m=h,d=6408,u="image/vnd-ms.dds";break;case"Basis":m=h,d=6407,u="image/ktx2";break;case"Png":u="image/png",p=document.createElement("img");break;case"Jpeg":u="image/jpeg",p=document.createElement("img");break;case"Etc2":u="image/ktx",p=document.createElement("img");break;case"Astc":this._dbg(3,"Astc texture not supported");break;case"Pvrtc":this._dbg(3,"Pvrtc texture not supported")}if(p&&u){const e=new Blob([h],{type:u});p.src=URL.createObjectURL(e),m=p}if(m&&null!=u){const e=has("enable-feature:esri-compress-IM-textures")?{compressionTracker:this._compressionTracker,compressionCallback:e=>{e&&e>0&&(r.textureMemoryUsage-=e)}}:void 0,t=new me(m,{mipmap:l,maxAnisotropy:a,encoding:u,wrap:c,pixelFormat:d,compressionOptions:e,noUnpackFlip:!0,width:s.mip0Width,height:s.mip0Height});return this._stage.addTexture(t),i.set(s,t),t}return null}getBufferViews(e,t,i){let r,s,o,n,a,l,c,d=null;for(let m=0;m<e.atrbs.length;m++){const c=e.atrbs[m],u=c.view,p=void 0,f=u.byteOffset+u.byteCount,g=u.byteCount/Y[u.type],y=[...Array(g).keys()].map(e=>e);try{switch(c.sem){case"Position":3!==u.ncomp||"F32"!==u.type?this._dbg(3,"[Unsupported Feature] Unsupported view for Position ("+u+")"):(r=new R(t,u.byteOffset,p,f),s=new he(r.typedBuffer,y,3));break;case"Normal":if(3!==u.ncomp||"F32"!==u.type)this._dbg(3,"[Unsupported Feature] Unsupported view for Normal ("+u+")");else{const e=new R(t,u.byteOffset,p,f),r=ue(e.typedBuffer,i);a=new k(r.buffer),l=new he(a.typedBuffer,y,2)}break;case"TexCoord":2!==u.ncomp||"F32"!==u.type?this._dbg(3,"[Unsupported Feature] Unsupported view for Texcoord ("+u+")"):void 0===n&&(n=new he(new P(t,u.byteOffset,p,f).typedBuffer,y,2));break;case"Color":4===u.ncomp?("F32"===u.type&&(d=new H(t,u.byteOffset,p,f)),"U8"===u.type&&(d=new E(t,u.byteOffset,p,f)),"U16"===u.type&&(d=new S(t,u.byteOffset,p,f))):3===u.ncomp&&("F32"===u.type&&(d=new R(t,u.byteOffset,p,f)),"U8"===u.type&&(d=new V(t,u.byteOffset,p,f)),"U16"===u.type&&(d=new A(t,u.byteOffset,p,f))),null==d?this._dbg(2,"[Unsupported Feature] Unsupported view for Color ("+u+")"):o=new he(d.typedBuffer,y,u.ncomp);break;case"FeatureIndex":break;default:this._dbg(2,"[Unsupported Feature] Unsupported semantic ("+c.sem+"). Skipping vertex attribute.")}}catch(h){this._dbg(2,"Error Creating buffer ("+h+"). Skipping vertex attribute.")}}if(e.index){const i=e.index.view,r=void 0,s=i.byteOffset+i.byteCount;switch(e.index.view.type){case"U16":c=new I(t,i.byteOffset,r,s);break;case"U32":c=new F(t,i.byteOffset,r,s);break;default:this._dbg(3,"[Unsupported Feature] index type not supported ("+i.type+").")}}if(null==c&&null!=r){const e=r.count;if(e<65535){const t=new Uint16Array(e);c=new I(t.buffer)}else{const t=new Uint32Array(e);c=new F(t.buffer)}for(let t=0;t<e;t++)c.set(t,t)}return{positionView:r,positionAttr:s,colorAttr:o,texCoord0Attr:n,indicesView:c,normalsView:a,normalsAttr:l}}_loadModifications(){if(this.removeHandles("modifications"),null==this.layer.modifications)return void(this._modifications=[]);const e=this.layer.modifications;this.addHandles(this._updatingHandles.addOnCollectionChange(()=>e,()=>this._modifications=e.toArray(),s),"modifications")}_deletePerObjectData(e){this._wasm?.onRenderableEvicted(this,e.handle,e.usedMemory),this.freeRenderable(e.handle)}_dbg(e,i){this._dbgFlags.has(e)&&(3===e?t.getLogger(this).error(i):t.getLogger(this).warn(i))}};e([l()],xe.prototype,"fullOpacity",null),e([l({type:[L]})],xe.prototype,"_modifications",void 0),e([l()],xe.prototype,"_visibleGeometryChangedSchedulerHandle",void 0),e([l()],xe.prototype,"layer",void 0),e([l({readOnly:!0})],xe.prototype,"visibleAtCurrentScale",null),e([l({readOnly:!0})],xe.prototype,"_collection",null),e([l()],xe.prototype,"elevationOffset",null),xe=e([c("esri.views.3d.layers.IntegratedMesh3DTilesLayerView3D")],xe);const Ce=xe,Oe=j();function Te(e,t){const i=re(e);return y(Oe,i.center,t),i.center=Oe,i}function Ue(e){return e?new ie(e.center,e.halfSize,f(...e.quaternion)):null}function Pe(e){return`${e}`}const He=new Array;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{__decorate as e}from"tslib";import has from"../../../core/has.js";import{initial as t}from"../../../core/reactiveUtils.js";import{property as r}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as i}from"../../../core/accessorSupport/decorators/subclass.js";import{I3SMeshView3D as o}from"./I3SMeshView3D.js";import{LayerView3D as s}from"./LayerView3D.js";import{updatingProgress as a}from"../support/updatingProperties.js";import l from"../../layers/LayerView.js";import{isInEffectiveScaleRange as n}from"../../support/layerViewUtils.js";const p=.2;let d=class extends(o(s(l))){constructor(){super(...arguments),this.type="integrated-mesh-3d",this._elevationContext=1,this._supportsLabeling=!1,this._applySSAO=!has("disable-feature:im-ssao"),this._shadeNormals=!!has("enable-feature:im-shading"),this.drapeTargetType=1}get i3slayer(){return this.layer}get updatingProgressValue(){return this._controller?.updatingProgress??0}get lodFactor(){return this.view?.qualitySettings?.sceneService?.integratedMesh?.lodFactor??1}get progressiveLoadFactor(){return this.lodFactor>=1?p:1}get visibleAtCurrentScale(){return n(this.i3slayer.effectiveScaleRange,this.view.scale)}get fullOpacity(){return 1}get layerPopupEnabledAndHasTemplate(){return!1}initialize(){this._updatingHandles.add(()=>this.layer.modifications,()=>this._loadModifications(),t),this.view.overlayManager.registerDrapeTarget(this)}destroy(){this.view.overlayManager.unregisterDrapeTarget(this)}get ready(){return this.layer.loaded}_createLayerGraphic(){}canResume(){return super.canResume()&&(!this._controller||this._controller.rootNodeVisible)}_loadModifications(){if(this.removeHandles("modifications"),null==this.layer.modifications)return void(this._modifications=[]);const e=this.layer.modifications;this.addHandles(this._updatingHandles.addOnCollectionChange(()=>e,()=>this._modifications=e.toArray(),t),"modifications")}};e([r()],d.prototype,"layer",void 0),e([r()],d.prototype,"i3slayer",null),e([r(a)],d.prototype,"updatingProgress",void 0),e([r()],d.prototype,"updatingProgressValue",null),e([r()],d.prototype,"lodFactor",null),e([r({readOnly:!0})],d.prototype,"progressiveLoadFactor",null),e([r({readOnly:!0})],d.prototype,"visibleAtCurrentScale",null),e([r()],d.prototype,"fullOpacity",null),d=e([i("esri.views.3d.layers.IntegratedMeshLayerView3D")],d);const c=d;export{c as default};
5
+ import{__decorate as e}from"tslib";import has from"../../../core/has.js";import{initial as r}from"../../../core/reactiveUtils.js";import{property as t}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as o}from"../../../core/accessorSupport/decorators/subclass.js";import{I3SMeshView3D as i}from"./I3SMeshView3D.js";import{LayerView3D as s}from"./LayerView3D.js";import{updatingProgress as a}from"../support/updatingProperties.js";import l from"../../layers/LayerView.js";import{isInEffectiveScaleRange as n}from"../../support/layerViewUtils.js";const p=.2;let d=class extends(i(s(l))){constructor(){super(...arguments),this.type="integrated-mesh-3d",this._elevationContext=1,this._supportsLabeling=!1,this._applySSAO=!has("disable-feature:im-ssao"),this._shadeNormals=!!has("enable-feature:im-shading"),this.drapeTargetType=1}get i3slayer(){return this.layer}get updatingProgressValue(){return this._controller?.updatingProgress??0}get lodFactor(){return this.view?.qualitySettings?.sceneService?.meshLoDFactor??1}get progressiveLoadFactor(){return this.lodFactor>=1?p:1}get visibleAtCurrentScale(){return n(this.i3slayer.effectiveScaleRange,this.view.scale)}get fullOpacity(){return 1}get layerPopupEnabledAndHasTemplate(){return!1}initialize(){this._updatingHandles.add(()=>this.layer.modifications,()=>this._loadModifications(),r),this.view.overlayManager.registerDrapeTarget(this)}destroy(){this.view.overlayManager.unregisterDrapeTarget(this)}get ready(){return this.layer.loaded}_createLayerGraphic(){}canResume(){return super.canResume()&&(!this._controller||this._controller.rootNodeVisible)}_loadModifications(){if(this.removeHandles("modifications"),null==this.layer.modifications)return void(this._modifications=[]);const e=this.layer.modifications;this.addHandles(this._updatingHandles.addOnCollectionChange(()=>e,()=>this._modifications=e.toArray(),r),"modifications")}};e([t()],d.prototype,"layer",void 0),e([t()],d.prototype,"i3slayer",null),e([t(a)],d.prototype,"updatingProgress",void 0),e([t()],d.prototype,"updatingProgressValue",null),e([t()],d.prototype,"lodFactor",null),e([t({readOnly:!0})],d.prototype,"progressiveLoadFactor",null),e([t({readOnly:!0})],d.prototype,"visibleAtCurrentScale",null),e([t()],d.prototype,"fullOpacity",null),d=e([o("esri.views.3d.layers.IntegratedMeshLayerView3D")],d);const c=d;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 t from"../../../core/Error.js";import{makeHandle as r,handlesGroup as i,destroyHandle as n}from"../../../core/handleUtils.js";import"../../../core/has.js";import{isIterable as s}from"../../../core/iteratorUtils.js";import{getProjectiveTransform as a}from"../../../core/perspectiveUtils.js";import{debounce as o,isPromiseLike as d}from"../../../core/promiseUtils.js";import{watch as l,syncAndInitial as h,on as m}from"../../../core/reactiveUtils.js";import{property as c}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as p}from"../../../core/accessorSupport/decorators/subclass.js";import{create as g}from"../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{toExtent as u}from"../../../geometry/support/aaBoundingRect.js";import{MediaElementView as y}from"../../../layers/support/MediaElementView.js";import{LayerView3D as _}from"./LayerView3D.js";import{MediaLayerInteraction as f}from"./support/MediaLayerInteraction.js";import{drapedZ as v}from"../terrain/OverlayRenderer.js";import{Attribute as w}from"../webgl-engine/lib/Attribute.js";import{Geometry as E}from"../webgl-engine/lib/Geometry.js";import{Object3DHighlightStateID as R}from"../webgl-engine/lib/Object3DStateID.js";import{RenderGeometry as D}from"../webgl-engine/lib/RenderGeometry.js";import{Texture as b}from"../webgl-engine/lib/Texture.js";import{ImageMaterial as j}from"../webgl-engine/materials/ImageMaterial.js";import x from"../../layers/LayerView.js";import A from"../../layers/MediaLayerView.js";import{getHighlightName as H}from"../../support/highlightOptionsUtils.js";import{isInEffectiveScaleRange as G}from"../../support/layerViewUtils.js";let M=class extends(_(A(x))){get interactive(){return this._interaction.enabled}set interactive(e){this._interaction&&(this._interaction.enabled=e)}get selectedElement(){return this._interaction.selectedElement}set selectedElement(e){this._interaction&&(this._interaction.selectedElement=e)}get visibleAtCurrentScale(){return G(this.layer.effectiveScaleRange,this.view.scale)}get usedMemory(){return Array.from(this._renderElements.values()).reduce((e,t)=>e+(t.getRenderData()?.texture.usedMemory??0),0)}constructor(e){super(e),this.type="media-3d",this.drapeSourceType=1,this.updatePolicy=1,this.ignoresMemoryFactor=!0,this.unloadedMemory=0,this._uidToElement=new Map,this._highlightedElements=new Map,this._elementsInHighlightedId=new Map,this._renderElements=new Map,this._lastDrapingExtent=null,this._update=o(async(e,t,r)=>{const i=await this._collectMediaElements(e,t,r);this._synchronizeRenderElements(i)},0);const{view:t,layer:r}=e;this._interaction=new f({view:t,layer:r}),this.addHandles(l(()=>this.interactionOptions,e=>this._interaction.options=e,h))}initialize(){const{view:e,layer:t}=this;this._renderer=e.overlayManager.registerGeometryDrapeSource(this);const i=()=>this._updateWithLastDrapingExtent();this.addHandles([r(()=>e.overlayManager.unregisterDrapeSource(this)),m(()=>t.effectiveSource,"change",i),m(()=>t.effectiveSource,"refresh",i)]),this._updatingHandles.add(()=>this.suspended,i)}destroy(){this._synchronizeRenderElements(new Set)}setDrapingExtent(e,t){this._lastDrapingExtent={overlays:e,spatialReference:t},this._updateWithLastDrapingExtent()}getHit(e){const t=this._uidToElement.get(e);return t?{type:"media",element:t,layer:this.layer}:null}highlight(e,t){const i=H(t),n=new R(i),a=s(e)?Array.from(e):[e];this._elementsInHighlightedId.set(n,a);for(const r of a){const e=this._highlightedElements.get(r);e?e.add(n):this._highlightedElements.set(r,new Set([n]));const t=this._renderElements.get(r)?.getRenderData();t&&(t.renderGeometry.geometry.addHighlight(n),this._renderer.modifyGeometries([t.renderGeometry],8))}return r(()=>{const e=this._elementsInHighlightedId.get(n);if(e){for(const t of e){const e=this._highlightedElements.get(t);if(!e)continue;e.delete(n);const r=this._renderElements.get(t)?.getRenderData();r&&(r.renderGeometry.geometry.removeHighlight(n),this._renderer.modifyGeometries([r.renderGeometry],8)),0===e.size&&this._highlightedElements.delete(t)}this._elementsInHighlightedId.delete(n)}})}isUpdating(){return super.isUpdating()||this._interaction.updating}_updateWithLastDrapingExtent(){if(null==this._lastDrapingExtent||this.suspended)return void(this._renderer&&this._synchronizeRenderElements(new Set));const{overlays:e,spatialReference:t}=this._lastDrapingExtent;this._updatingHandles.addPromise(this._update(e,t).catch(()=>{}))}async _collectMediaElements(e,t,r){const i=this.layer.effectiveSource;return null==i?new Set:new Set((await Promise.all(e.map(e=>i.queryElements(u(e.extent,t),{signal:r})))).flat())}_synchronizeRenderElements(e){this._synchronizeRenderElementsRemove(e),this._synchronizeRenderElementsAdd(e)}_synchronizeRenderElementsRemove(e){this._renderElements.forEach((t,r)=>{e.has(r)||(this._removeElement(r,t),this.emit("element-render-changed",{element:r}))})}_synchronizeRenderElementsAdd(e){for(const t of e)this._renderElements.has(t)||this._createRenderElement(t)}_removeElement(e,t){this._destroyRenderData(e,t),this._renderElements.delete(e),this._uidToElement.delete(e.uid),t.handle.remove()}_createRenderElement(e){const t=new y({spatialReference:this.view.spatialReference,element:e}),r=new I(i([this._updatingHandles.add(()=>e.opacity,e=>r.getRenderData()?.material.setParameters({opacity:e})),this._updatingHandles.add(()=>t.coords,()=>{r.data?this._updateGeometry(t,r):this._initializeRenderData(t,r)}),this._updatingHandles.add(()=>e.content,()=>this._initializeRenderData(t,r)),n(t)]));this._renderElements.set(e,r),this._uidToElement.set(e.uid,e),this._updatingHandles.addPromise(e.load().catch(()=>{})),this._initializeRenderData(t,r)}_initializeRenderData(e,t){const{coords:r,element:i}=e,{contentWidth:n,contentHeight:s}=i;if(null==r||null==i.content)return void this._destroyRenderData(i,t);if(t.data)return;const a=this._createTexture(i.content),o=a.load(this.view.stage.renderView.renderingContext),l=()=>{if(!a.loaded)return;this.view.stage.addTexture(a);const e=new j({draped:!0,texture:a,opacity:i.opacity,perspectiveInterpolation:!0}),o=this._getPositionAttributeArray(r),d=[0,0,1,0,1,1,0,1],l=this._getPerspectiveDivideAttributeArray(o,n,s),h=[0,1,2,0,2,3],m=new E(e,[["position",new w(o,h,3,!0)],["uv0",new w(d,h,2,!0)],["perspectiveDivide",new w(l,h,1,!0)]]),c=new D(m,{layerViewUid:this.uid,graphicUid:i.uid}),p=this._highlightedElements.get(i);p?.forEach(e=>c.geometry.addHighlight(e)),this._renderer.addGeometries([c],0),t.data=new z(c,a,e),this.emit("element-render-changed",{element:i})};d(o)?(t.data=a,this._updatingHandles.addPromise(o),o.then(l).catch(()=>a.dispose())):l()}_updateGeometry(e,t){const{coords:r,element:i}=e;if(null==r||null==i.content)return void this._destroyRenderData(i,t);const n=t.getRenderData();if(!n)return;const s=this._getPositionAttributeArray(r);n.renderGeometry.geometry.setAttributeData("position",s);const a=this._getPerspectiveDivideAttributeArray(s,i.contentWidth,i.contentHeight);n.renderGeometry.geometry.setAttributeData("perspectiveDivide",a),n.renderGeometry.geometry.invalidateBoundingInfo(),this._renderer.modifyGeometries([n.renderGeometry],2),this.emit("element-render-changed",{element:i})}_getPositionAttributeArray(e){const[t,r,i,n]=e.rings[0];return[t[0],t[1],v,n[0],n[1],v,i[0],i[1],v,r[0],r[1],v]}_getPerspectiveDivideAttributeArray(e,t,r){a(S,[0,0,t,0,t,r,0,r],[e[0],e[1],e[3],e[4],e[6],e[7],e[9],e[10]]);const i=S[6]/S[8]*t,n=S[7]/S[8]*r;return[1,1+i,1+i+n,1+n]}_destroyRenderData(e,t){const r=t.data;if(null==r)return;if(t.data=null,"dispose"in r)return void r.dispose();const i=r.texture;i.unload(),this.view.stage.removeTexture(i),this._renderer.removeGeometries([r.renderGeometry],2),this.emit("element-render-changed",{element:e})}_createTexture(e){const r=e instanceof HTMLImageElement?e.naturalWidth:e.width,i=e instanceof HTMLImageElement?e.naturalHeight:e.height;if("getFrame"in e)throw new t("media-layer-view-3d","animation is not supported");return new b(e,{wrap:{s:33071,t:33071},preMultiplyAlpha:!0,width:r,height:i,mipmap:!0,updateCallback:()=>this.view.overlayManager.requestRender()})}get test(){}};e([c({readOnly:!0})],M.prototype,"type",void 0),e([c()],M.prototype,"layer",void 0),e([c()],M.prototype,"interactive",null),e([c()],M.prototype,"selectedElement",null),e([c({readOnly:!0})],M.prototype,"visibleAtCurrentScale",null),M=e([p("esri.views.3d.layers.MediaLayerView3D")],M);const S=g();class I{constructor(e){this.handle=e}getRenderData(){return this.data&&"type"in this.data&&"RenderData"===this.data.type?this.data:null}}class z{constructor(e,t,r){this.renderGeometry=e,this.texture=t,this.material=r,this.type="RenderData"}}const L=M;export{L as default};
5
+ import{__decorate as e}from"tslib";import t from"../../../core/Error.js";import{makeHandle as r,handlesGroup as i,destroyHandle as n}from"../../../core/handleUtils.js";import"../../../core/has.js";import{isIterable as s}from"../../../core/iteratorUtils.js";import{getProjectiveTransform as a}from"../../../core/perspectiveUtils.js";import{debounce as o,isPromiseLike as d}from"../../../core/promiseUtils.js";import{watch as l,syncAndInitial as h,on as m}from"../../../core/reactiveUtils.js";import{property as c}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as p}from"../../../core/accessorSupport/decorators/subclass.js";import{create as g}from"../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{toExtent as u}from"../../../geometry/support/aaBoundingRect.js";import{MediaElementView as y}from"../../../layers/support/MediaElementView.js";import{LayerView3D as _}from"./LayerView3D.js";import{MediaLayerInteraction as f}from"./support/MediaLayerInteraction.js";import{drapedZ as v}from"../terrain/OverlayRenderer.js";import{Attribute as w}from"../webgl-engine/lib/Attribute.js";import{Geometry as E}from"../webgl-engine/lib/Geometry.js";import{ManagedTexture as R}from"../webgl-engine/lib/ManagedTexture.js";import{Object3DHighlightStateID as D}from"../webgl-engine/lib/Object3DStateID.js";import{RenderGeometry as b}from"../webgl-engine/lib/RenderGeometry.js";import{ImageMaterial as j}from"../webgl-engine/materials/ImageMaterial.js";import x from"../../layers/LayerView.js";import A from"../../layers/MediaLayerView.js";import{getHighlightName as H}from"../../support/highlightOptionsUtils.js";import{isInEffectiveScaleRange as M}from"../../support/layerViewUtils.js";let G=class extends(_(A(x))){get interactive(){return this._interaction.enabled}set interactive(e){this._interaction&&(this._interaction.enabled=e)}get selectedElement(){return this._interaction.selectedElement}set selectedElement(e){this._interaction&&(this._interaction.selectedElement=e)}get visibleAtCurrentScale(){return M(this.layer.effectiveScaleRange,this.view.scale)}get usedMemory(){return Array.from(this._renderElements.values()).reduce((e,t)=>e+(t.getRenderData()?.texture.usedMemory??0),0)}constructor(e){super(e),this.type="media-3d",this.drapeSourceType=1,this.updatePolicy=1,this.ignoresMemoryFactor=!0,this.unloadedMemory=0,this._uidToElement=new Map,this._highlightedElements=new Map,this._elementsInHighlightedId=new Map,this._renderElements=new Map,this._lastDrapingExtent=null,this._update=o(async(e,t,r)=>{const i=await this._collectMediaElements(e,t,r);this._synchronizeRenderElements(i)},0);const{view:t,layer:r}=e;this._interaction=new f({view:t,layer:r}),this.addHandles(l(()=>this.interactionOptions,e=>this._interaction.options=e,h))}initialize(){const{view:e,layer:t}=this;this._renderer=e.overlayManager.registerGeometryDrapeSource(this);const i=()=>this._updateWithLastDrapingExtent();this.addHandles([r(()=>e.overlayManager.unregisterDrapeSource(this)),m(()=>t.effectiveSource,"change",i),m(()=>t.effectiveSource,"refresh",i)]),this._updatingHandles.add(()=>this.suspended,i)}destroy(){this._synchronizeRenderElements(new Set)}setDrapingExtent(e,t){this._lastDrapingExtent={overlays:e,spatialReference:t},this._updateWithLastDrapingExtent()}getHit(e){const t=this._uidToElement.get(e);return t?{type:"media",element:t,layer:this.layer}:null}highlight(e,t){const i=H(t),n=new D(i),a=s(e)?Array.from(e):[e];this._elementsInHighlightedId.set(n,a);for(const r of a){const e=this._highlightedElements.get(r);e?e.add(n):this._highlightedElements.set(r,new Set([n]));const t=this._renderElements.get(r)?.getRenderData();t&&(t.renderGeometry.geometry.addHighlight(n),this._renderer.modifyGeometries([t.renderGeometry],8))}return r(()=>{const e=this._elementsInHighlightedId.get(n);if(e){for(const t of e){const e=this._highlightedElements.get(t);if(!e)continue;e.delete(n);const r=this._renderElements.get(t)?.getRenderData();r&&(r.renderGeometry.geometry.removeHighlight(n),this._renderer.modifyGeometries([r.renderGeometry],8)),0===e.size&&this._highlightedElements.delete(t)}this._elementsInHighlightedId.delete(n)}})}isUpdating(){return super.isUpdating()||this._interaction.updating}_updateWithLastDrapingExtent(){if(null==this._lastDrapingExtent||this.suspended)return void(this._renderer&&this._synchronizeRenderElements(new Set));const{overlays:e,spatialReference:t}=this._lastDrapingExtent;this._updatingHandles.addPromise(this._update(e,t).catch(()=>{}))}async _collectMediaElements(e,t,r){const i=this.layer.effectiveSource;return null==i?new Set:new Set((await Promise.all(e.map(e=>i.queryElements(u(e.extent,t),{signal:r})))).flat())}_synchronizeRenderElements(e){this._synchronizeRenderElementsRemove(e),this._synchronizeRenderElementsAdd(e)}_synchronizeRenderElementsRemove(e){this._renderElements.forEach((t,r)=>{e.has(r)||(this._removeElement(r,t),this.emit("element-render-changed",{element:r}))})}_synchronizeRenderElementsAdd(e){for(const t of e)this._renderElements.has(t)||this._createRenderElement(t)}_removeElement(e,t){this._destroyRenderData(e,t),this._renderElements.delete(e),this._uidToElement.delete(e.uid),t.handle.remove()}_createRenderElement(e){const t=new y({spatialReference:this.view.spatialReference,element:e}),r=new I(i([this._updatingHandles.add(()=>e.opacity,e=>r.getRenderData()?.material.setParameters({opacity:e})),this._updatingHandles.add(()=>t.coords,()=>{r.data?this._updateGeometry(t,r):this._initializeRenderData(t,r)}),this._updatingHandles.add(()=>e.content,()=>this._initializeRenderData(t,r)),n(t)]));this._renderElements.set(e,r),this._uidToElement.set(e.uid,e),this._updatingHandles.addPromise(e.load().catch(()=>{})),this._initializeRenderData(t,r)}_initializeRenderData(e,t){const{coords:r,element:i}=e,{contentWidth:n,contentHeight:s}=i;if(null==r||null==i.content)return void this._destroyRenderData(i,t);if(t.data)return;const a=this._createTexture(i.content),o=a.load(this.view.stage.renderView.renderingContext),l=()=>{if(!a.loaded)return;this.view.stage.addTexture(a);const e=new j({draped:!0,managedTexture:a,opacity:i.opacity,perspectiveInterpolation:!0}),o=this._getPositionAttributeArray(r),d=[0,0,1,0,1,1,0,1],l=this._getPerspectiveDivideAttributeArray(o,n,s),h=[0,1,2,0,2,3],m=new E(e,[["position",new w(o,h,3,!0)],["uv0",new w(d,h,2,!0)],["perspectiveDivide",new w(l,h,1,!0)]]),c=new b(m,{layerViewUid:this.uid,graphicUid:i.uid}),p=this._highlightedElements.get(i);p?.forEach(e=>c.geometry.addHighlight(e)),this._renderer.addGeometries([c],0),t.data=new z(c,a,e),this.emit("element-render-changed",{element:i})};d(o)?(t.data=a,this._updatingHandles.addPromise(o),o.then(l).catch(()=>a.dispose())):l()}_updateGeometry(e,t){const{coords:r,element:i}=e;if(null==r||null==i.content)return void this._destroyRenderData(i,t);const n=t.getRenderData();if(!n)return;const s=this._getPositionAttributeArray(r);n.renderGeometry.geometry.setAttributeData("position",s);const a=this._getPerspectiveDivideAttributeArray(s,i.contentWidth,i.contentHeight);n.renderGeometry.geometry.setAttributeData("perspectiveDivide",a),n.renderGeometry.geometry.invalidateBoundingInfo(),this._renderer.modifyGeometries([n.renderGeometry],2),this.emit("element-render-changed",{element:i})}_getPositionAttributeArray(e){const[t,r,i,n]=e.rings[0];return[t[0],t[1],v,n[0],n[1],v,i[0],i[1],v,r[0],r[1],v]}_getPerspectiveDivideAttributeArray(e,t,r){a(S,[0,0,t,0,t,r,0,r],[e[0],e[1],e[3],e[4],e[6],e[7],e[9],e[10]]);const i=S[6]/S[8]*t,n=S[7]/S[8]*r;return[1,1+i,1+i+n,1+n]}_destroyRenderData(e,t){const r=t.data;if(null==r)return;if(t.data=null,"dispose"in r)return void r.dispose();const i=r.texture;i.unload(),this.view.stage.removeTexture(i),this._renderer.removeGeometries([r.renderGeometry],2),this.emit("element-render-changed",{element:e})}_createTexture(e){const r=e instanceof HTMLImageElement?e.naturalWidth:e.width,i=e instanceof HTMLImageElement?e.naturalHeight:e.height;if("getFrame"in e)throw new t("media-layer-view-3d","animation is not supported");return new R(e,{wrap:{s:33071,t:33071},preMultiplyAlpha:!0,width:r,height:i,mipmap:!0,updateCallback:()=>this.view.overlayManager.requestRender()})}get test(){}};e([c({readOnly:!0})],G.prototype,"type",void 0),e([c()],G.prototype,"layer",void 0),e([c()],G.prototype,"interactive",null),e([c()],G.prototype,"selectedElement",null),e([c({readOnly:!0})],G.prototype,"visibleAtCurrentScale",null),G=e([p("esri.views.3d.layers.MediaLayerView3D")],G);const S=g();class I{constructor(e){this.handle=e}getRenderData(){return this.data&&"type"in this.data&&"RenderData"===this.data.type?this.data:null}}class z{constructor(e,t,r){this.renderGeometry=e,this.texture=t,this.material=r,this.type="RenderData"}}const T=G;export{T as default};