@arcgis/core 4.28.0-next.20230621 → 4.28.0-next.20230622

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 (123) hide show
  1. package/assets/esri/core/workers/RemoteClient.js +1 -1
  2. package/assets/esri/core/workers/chunks/05c0fdbfc82538f2f68d.js +1 -0
  3. package/assets/esri/core/workers/chunks/0bd95f46a0a9005a19f9.js +1 -0
  4. package/assets/esri/core/workers/chunks/19b4f02fb2392d964582.js +1 -0
  5. package/assets/esri/core/workers/chunks/26212a08ea383547335b.js +1 -0
  6. package/assets/esri/core/workers/chunks/{2420ec029236ab31d908.js → 2882a55a971af1f7858b.js} +1 -1
  7. package/assets/esri/core/workers/chunks/303238fc2fcdbb277981.js +1 -0
  8. package/assets/esri/core/workers/chunks/42dfebbe964f2b44ffab.js +1 -0
  9. package/assets/esri/core/workers/chunks/{4b235d1b6a72773cd4f4.js → 57bb8516fa998a0fba78.js} +1 -1
  10. package/assets/esri/core/workers/chunks/6208f2dfa9dfd3bca000.js +1 -0
  11. package/assets/esri/core/workers/chunks/64008bde5d3ffd9f2499.js +1 -0
  12. package/assets/esri/core/workers/chunks/{c1dfbda75abc748a6ca4.js → 6aa42f510969014db3f4.js} +1 -1
  13. package/assets/esri/core/workers/chunks/{cfe379a78a983373b3ac.js → 7304f45f5622a68253e4.js} +1 -1
  14. package/assets/esri/core/workers/chunks/733b70d6e5c466a67e9c.js +1 -0
  15. package/assets/esri/core/workers/chunks/7694521b44681d52b713.js +1 -0
  16. package/assets/esri/core/workers/chunks/80aa79040c0a7d039c3d.js +1 -0
  17. package/assets/esri/core/workers/chunks/91f957cd49a95a8a95f5.js +1 -0
  18. package/assets/esri/core/workers/chunks/{42b6315e21c4c1345ba5.js → 9f5337a80963e0b3c009.js} +1 -1
  19. package/assets/esri/core/workers/chunks/a16458b4653b284b4b80.js +1 -0
  20. package/assets/esri/core/workers/chunks/a54f361506012be46fdb.js +1 -0
  21. package/assets/esri/core/workers/chunks/{cfc3dcca2b69d20d5375.js → c0b9cc091efd5db827de.js} +1 -1
  22. package/assets/esri/core/workers/chunks/ce7f575a6c2053c7ca17.js +1 -0
  23. package/assets/esri/core/workers/chunks/d24f7ef6eca8c91b90b4.js +1 -0
  24. package/assets/esri/core/workers/chunks/dbd86e4b7983873cbe7c.js +1 -0
  25. package/assets/esri/core/workers/chunks/{3c3f65913006b84b2289.js → de20572d334abd4a7d82.js} +1 -1
  26. package/assets/esri/core/workers/chunks/{c8702e53a8ad6cf6ab85.js → dede2b4948f1f07a9859.js} +1 -1
  27. package/assets/esri/core/workers/chunks/e3f7d464f6d74523fc13.js +1 -0
  28. package/assets/esri/core/workers/chunks/f6040205c50e2795a1a0.js +1 -0
  29. package/assets/esri/core/workers/chunks/{915734255a79bff3ef0f.js → fcd54e9e64c2864f183c.js} +1 -1
  30. package/assets/esri/t9n/common.json +1 -1
  31. package/assets/esri/t9n/common_en.json +1 -1
  32. package/assets/esri/themes/base/_core.scss +6 -2
  33. package/assets/esri/themes/base/_mixins.scss +0 -147
  34. package/assets/esri/themes/base/widgets/_AreaMeasurement2D.scss +0 -8
  35. package/assets/esri/themes/base/widgets/_AreaMeasurement3D.scss +0 -8
  36. package/assets/esri/themes/base/widgets/_DirectLineMeasurement3D.scss +0 -1
  37. package/assets/esri/themes/base/widgets/_DistanceMeasurement2D.scss +0 -1
  38. package/assets/esri/themes/base/widgets/_MeasurementWidgetContent.scss +58 -0
  39. package/assets/esri/themes/base/widgets/_UnitSelect.scss +14 -0
  40. package/assets/esri/themes/dark/main.css +1 -1
  41. package/assets/esri/themes/light/main.css +1 -1
  42. package/assets/esri/themes/light/view.css +1 -1
  43. package/assets/esri/widgets/AreaMeasurement2D/t9n/AreaMeasurement2D.json +1 -1
  44. package/assets/esri/widgets/AreaMeasurement2D/t9n/AreaMeasurement2D_en.json +1 -1
  45. package/assets/esri/widgets/AreaMeasurement3D/t9n/AreaMeasurement3D.json +1 -1
  46. package/assets/esri/widgets/AreaMeasurement3D/t9n/AreaMeasurement3D_en.json +1 -1
  47. package/assets/esri/widgets/DirectLineMeasurement3D/t9n/DirectLineMeasurement3D.json +1 -1
  48. package/assets/esri/widgets/DirectLineMeasurement3D/t9n/DirectLineMeasurement3D_en.json +1 -1
  49. package/assets/esri/widgets/DistanceMeasurement2D/t9n/DistanceMeasurement2D.json +1 -1
  50. package/assets/esri/widgets/DistanceMeasurement2D/t9n/DistanceMeasurement2D_en.json +1 -1
  51. package/core/promiseUtils.js +1 -1
  52. package/geometry/projection.js +1 -1
  53. package/interfaces.d.ts +270 -5
  54. package/layers/LinkChartLayer.d.ts +4 -0
  55. package/layers/LinkChartLayer.js +1 -1
  56. package/layers/support/TileInfoTilemapCache.js +1 -1
  57. package/package.json +1 -1
  58. package/support/revision.js +1 -1
  59. package/symbols/cim/cimAnalyzer.js +1 -1
  60. package/views/2d/layers/imagery/BaseImageryTileSubView2D.js +1 -1
  61. package/views/2d/layers/imagery/ImageryTileView2D.js +1 -1
  62. package/views/3d/environment/ChapmanAtmosphere.js +1 -1
  63. package/views/3d/environment/CloudsGenerator.js +1 -1
  64. package/views/3d/environment/EnvironmentRenderer.js +1 -1
  65. package/views/3d/environment/SceneViewEnvironmentManager.js +1 -1
  66. package/views/3d/layers/graphics/Graphics3DExtrudeSymbolLayer.js +1 -1
  67. package/views/3d/layers/graphics/Graphics3DIconSymbolLayer.js +1 -1
  68. package/views/3d/layers/graphics/Graphics3DLineCalloutSymbolLayer.js +1 -1
  69. package/views/3d/layers/graphics/Graphics3DLineSymbolLayer.js +1 -1
  70. package/views/3d/layers/graphics/Graphics3DMeshFillSymbolLayer.js +1 -1
  71. package/views/3d/layers/graphics/Graphics3DObjectSymbolLayer.js +1 -1
  72. package/views/3d/layers/graphics/Graphics3DPathSymbolLayer.js +1 -1
  73. package/views/3d/layers/graphics/Graphics3DPolygonFillSymbolLayer.js +1 -1
  74. package/views/3d/layers/graphics/Graphics3DSymbolLayer.js +1 -1
  75. package/views/3d/layers/graphics/Graphics3DTextSymbolLayer.js +1 -1
  76. package/views/3d/layers/graphics/Graphics3DWaterSymbolLayer.js +1 -1
  77. package/views/3d/layers/graphics/Labeler.js +1 -1
  78. package/views/3d/layers/graphics/labelPlacement.js +1 -1
  79. package/views/3d/state/ViewState.js +1 -1
  80. package/views/3d/state/ViewStateManager.js +1 -1
  81. package/views/3d/support/DisplayQualityProfile.js +1 -1
  82. package/views/3d/support/MemoryController.js +1 -1
  83. package/views/3d/support/SceneViewPerformanceInfo.js +1 -1
  84. package/views/3d/support/cameraUtils.js +1 -1
  85. package/views/3d/support/viewpointUtils.js +1 -1
  86. package/views/3d/terrain/OverlayFramebufferObject.js +1 -1
  87. package/views/3d/terrain/OverlayRenderer.js +1 -1
  88. package/views/3d/webgl-engine/Stage.js +1 -1
  89. package/views/3d/webgl-engine/core/FBOCache.js +1 -1
  90. package/views/3d/webgl-engine/core/shaderLibrary/hud/HUDOcclusionPass.glsl.js +0 -1
  91. package/views/3d/webgl-engine/lib/Highlight.js +1 -1
  92. package/views/3d/webgl-engine/lib/OffscreenRendering.js +1 -1
  93. package/views/3d/webgl-engine/lib/Renderer.js +1 -1
  94. package/views/3d/webgl-engine/lib/SSAOHelper.js +1 -1
  95. package/views/3d/webgl-engine/lib/SmaaRenderPass.js +1 -1
  96. package/views/webgl/Texture.js +1 -1
  97. package/widgets/AreaMeasurement2D.js +1 -1
  98. package/widgets/AreaMeasurement3D.js +1 -1
  99. package/widgets/DirectLineMeasurement3D.js +1 -1
  100. package/widgets/DistanceMeasurement2D.js +1 -1
  101. package/widgets/FeatureForm/FieldInput.js +1 -1
  102. package/widgets/support/MeasurementWidgetContent.js +5 -0
  103. package/widgets/support/UnitSelect.js +5 -0
  104. package/assets/esri/core/workers/chunks/07f16ea775b39a1a4a7b.js +0 -1
  105. package/assets/esri/core/workers/chunks/1bbc868d2430103951eb.js +0 -1
  106. package/assets/esri/core/workers/chunks/1d2ef88a8d028adef102.js +0 -1
  107. package/assets/esri/core/workers/chunks/39ae4b9b766f674bc6f2.js +0 -1
  108. package/assets/esri/core/workers/chunks/3b3d676b609c47a77164.js +0 -1
  109. package/assets/esri/core/workers/chunks/3d9a8cb638cf9b8ca4b3.js +0 -1
  110. package/assets/esri/core/workers/chunks/45629ff775e77234b227.js +0 -1
  111. package/assets/esri/core/workers/chunks/642510b0371311ff8e16.js +0 -1
  112. package/assets/esri/core/workers/chunks/7e4013f8c31c9a9438c6.js +0 -1
  113. package/assets/esri/core/workers/chunks/82939ead43848a13f765.js +0 -1
  114. package/assets/esri/core/workers/chunks/8b6b963230df56850580.js +0 -1
  115. package/assets/esri/core/workers/chunks/a9e9297267614c4c4f3b.js +0 -1
  116. package/assets/esri/core/workers/chunks/b31974524932e638df8c.js +0 -1
  117. package/assets/esri/core/workers/chunks/b75b4b132dbd9cb9d372.js +0 -1
  118. package/assets/esri/core/workers/chunks/cad7a2092ea7f51dbd8b.js +0 -1
  119. package/assets/esri/core/workers/chunks/d2a127f7bb0e2ba14a13.js +0 -1
  120. package/assets/esri/core/workers/chunks/e097f41bbfac00250477.js +0 -1
  121. package/assets/esri/core/workers/chunks/e55f80b774e090a0aa04.js +0 -1
  122. package/assets/esri/core/workers/chunks/e668c7e2e61aae6ca6e0.js +0 -1
  123. package/assets/esri/core/workers/chunks/f0299d93a95f40ea7cf7.js +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arcgis/core",
3
- "version": "4.28.0-next.20230621",
3
+ "version": "4.28.0-next.20230622",
4
4
  "homepage": "https://js.arcgis.com",
5
5
  "description": "ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API",
6
6
  "keywords": [
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- const c="20230621",b="28bc5ecdbc419774a35993abc003f6d83d30f1e3";export{c as buildDate,b as commitHash};
5
+ const a="20230622",b="54d2f4ba38aa67bb192970f64eaae4752d0ba6c5";export{a as buildDate,b as commitHash};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../Color.js";import{getFontFamily as t}from"../../core/fontUtils.js";import{clone as i}from"../../core/lang.js";import r from"../../core/Logger.js";import{pt2px as o,px2pt as n}from"../../core/screenUtils.js";import{numericHash as a}from"../../core/string.js";import{createRendererExpression as s,ArcadeExpression as l}from"../../support/arcadeOnDemand.js";import{DEFAULT_PICTURE_FILL_HEIGHT as c,DEFAULT_HATCH_FILL_SEPARATION as m,DEFAULT_STROKE_WIDTH as f,DEFAULT_MARKER_SIZE as h,DEFAULT_TEXT_HEIGHT as p}from"./CIMSymbolDrawHelper.js";import{CIMSymbolHelper as u,OverrideHelper as y}from"./CIMSymbolHelper.js";import{Alignment as d,CapType as v,JoinType as _}from"./enums.js";import{quantizeIfNeeded as O}from"./quantizeTime.js";import{getExtent as S,getSDFMetrics as g}from"./SDFHelper.js";import{fromCIMColor as M,getTintColor as k,getValue as b,getFillColor as N,getStrokeColor as P,getStrokeWidth as z,isFeatureValueFn as L,fromCIMFontDecoration as C,fromCIMFontStyle as F,adjustTextCase as I,createLabelOverrideFunction as w,evaluateValueOrFunction as x,fromCIMHorizontalAlignment as A,fromCIMVerticalAlignment as R}from"./utils.js";import{CIMEffectHelper as X}from"./effects/CIMEffectHelper.js";import H from"../../views/2d/arcade/callExpressionWithFeature.js";import{RANDOM_INSIDE_POLYGON_TEXTURE_SIZE as J}from"../../views/2d/engine/webgl/definitions.js";import{getMaterialGroup as Y}from"../../views/2d/engine/webgl/grouping.js";const E=r.getLogger("esri.symbols.cim.cimAnalyzer");function T(e){switch(e){case"Butt":return v.BUTT;case"Square":return v.SQUARE;default:return v.ROUND}}function $(e){switch(e){case"Bevel":return _.BEVEL;case"Miter":return _.MITER;default:return _.ROUND}}function j(e){const t=e.markerPlacement;return t&&t.angleToLine?d.MAP:d.SCREEN}class G{constructor(e,t){this._cimLayers=[],this._poMap={},this._primitiveOverrides=[],this._resourceManager=e,this._info=t}async analyzeSymbolReference(e,t,i){if(this._cimLayers=i??[],!e)return this._cimLayers;if(e.primitiveOverrides){this._primitiveOverrides=e.primitiveOverrides,this._poMap={};const t=[],i=this._info;for(const e of this._primitiveOverrides){const r=e.valueExpressionInfo;if(r&&i){const o=r.expression,n=s(o,i.spatialReference,i.fields).then((t=>{null!=t&&this._setPoMap(e.primitiveName,e.propertyName,t)}));t.push(n)}else null!=e.value&&this._setPoMap(e.primitiveName,e.propertyName,e.value);t.length>0&&await Promise.all(t)}}const r=e.symbol,o=[];return u.fetchResources(r,this._resourceManager,o),o.length>0&&await Promise.all(o),this._analyzeSymbol(r,t),this._cimLayers}_analyzeSymbol(e,t){switch(e?.type){case"CIMPointSymbol":case"CIMLineSymbol":case"CIMPolygonSymbol":this._analyzeMultiLayerSymbol(e,t,1,0,0,0)}}_analyzeMultiLayerSymbol(e,t,i,r,o,n){const a=e?.symbolLayers;if(!a)return;const s=e.effects;let l=d.SCREEN;const c=u.getSize(e)??0;"CIMPointSymbol"===e.type&&"Map"===e.angleAlignment&&(l=d.MAP);const m="CIMPolygonSymbol"===e.type;let f=a.length;for(;f--;){const h=a[f];if(!h||!1===h.enable)continue;let p;s&&s.length&&(p=[...s]);const u=h.effects;u&&u.length&&(s?p.push(...u):p=[...u]);const d=[];let v;y.findEffectOverrides(p,this._primitiveOverrides,d),v=d.length>0?this._createEffectsOverrideFunction(p,d):p;const _=[];switch(y.findApplicableOverrides(h,this._primitiveOverrides,_),h.type){case"CIMSolidFill":this._analyzeSolidFill(h,v);break;case"CIMPictureFill":this._analyzePictureFill(h,v);break;case"CIMHatchFill":this._analyzeHatchFill(h,v);break;case"CIMGradientFill":this._analyzeGradientFill(h,v);break;case"CIMSolidStroke":this._analyzeSolidStroke(h,v,m,c);break;case"CIMPictureStroke":this._analyzePictureStroke(h,v,m,c);break;case"CIMGradientStroke":this._analyzeGradientStroke(h,v,m,c);break;case"CIMCharacterMarker":case"CIMPictureMarker":case"CIMVectorMarker":{"CIMLineSymbol"===e.type&&(l=j(h));const a=[],s=h.primitiveName;s&&a.push(s),this._analyzeMarker(h,v,null,a,l,c,1,t,i,r,o,n);break}default:E.error("Cannot analyze CIM layer",h.type)}}}_analyzeSolidFill(e,t){const i=e.primitiveName,r=M(e.color),[o,n]=this._analyzePrimitiveOverrides(i,t,null,null),s=a(JSON.stringify(e)+n).toString();this._cimLayers.push({type:"fill",templateHash:s,materialHash:o?()=>s:s,cim:e,materialOverrides:null,colorLocked:!!e.colorLocked,color:this._createOverrideFunction(i,"Color",r,U),height:0,angle:0,offsetX:0,offsetY:0,scaleX:1,effects:t,applyRandomOffset:!1,sampleAlphaOnly:!0})}_analyzePictureFill(e,t){const i=e.primitiveName,r=k(e),[o,n]=this._analyzePrimitiveOverrides(i,t,null,null),s=a(JSON.stringify(e)+n).toString(),l=a(`${e.url}${JSON.stringify(e.colorSubstitutions)}`).toString(),m=b(e.height,c);let f=b(e.scaleX,1);if("width"in e&&"number"==typeof e.width){const t=e.width;let i=1;const r=this._resourceManager.getResource(e.url);null!=r&&(i=r.width/r.height),f/=i*(m/t)}this._cimLayers.push({type:"fill",templateHash:s,materialHash:o?()=>l:l,cim:e,materialOverrides:null,colorLocked:!!e.colorLocked,effects:t,color:this._createOverrideFunction(i,"TintColor",r,U),height:this._createOverrideFunction(i,"Height",m),scaleX:this._createOverrideFunction(i,"ScaleX",f),angle:this._createOverrideFunction(i,"Rotation",b(e.rotation)),offsetX:this._createOverrideFunction(i,"OffsetX",b(e.offsetX)),offsetY:this._createOverrideFunction(i,"OffsetY",b(e.offsetY)),url:e.url,applyRandomOffset:!1,sampleAlphaOnly:!1})}_analyzeHatchFill(e,t){const i=e.primitiveName,r=this._analyzeMaterialOverrides(i,["Rotation","OffsetX","OffsetY"]);let[o,n]=this._analyzePrimitiveOverrides(i,t,null,null);const s=a(JSON.stringify(e)+n).toString(),l=a(`${e.separation}${JSON.stringify(e.lineSymbol)}`).toString();let c={r:255,g:255,b:255,a:1},f=!1;const h=e.lineSymbol?.symbolLayers?.find((e=>"CIMSolidStroke"===e.type&&null!=this._poMap[e.primitiveName]?.Color));if(h){c=M(h.color),c=this._createOverrideFunction(h.primitiveName,"Color",c,U);const e="function"==typeof c;o=o||e,f=null!=h.color||e}this._cimLayers.push({type:"fill",templateHash:s,materialHash:o&&r?this._createMaterialHashFunction(l,r):l,cim:e,materialOverrides:r,colorLocked:!!e.colorLocked,effects:t,color:c,height:this._createOverrideFunction(i,"Separation",b(e.separation,m)),scaleX:1,angle:this._createOverrideFunction(i,"Rotation",b(e.rotation)),offsetX:this._createOverrideFunction(i,"OffsetX",b(e.offsetX)),offsetY:this._createOverrideFunction(i,"OffsetY",b(e.offsetY)),applyRandomOffset:!1,sampleAlphaOnly:!0,hasUnresolvedReplacementColor:!f})}_analyzeGradientFill(e,t){const i=e.primitiveName,[r,o]=this._analyzePrimitiveOverrides(i,t,null,null),n=a(JSON.stringify(e)+o).toString();this._cimLayers.push({type:"fill",templateHash:n,materialHash:r?()=>n:n,cim:e,materialOverrides:null,colorLocked:!!e.colorLocked,effects:t,color:{r:128,g:128,b:128,a:1},height:0,angle:0,offsetX:0,offsetY:0,scaleX:1,applyRandomOffset:!1,sampleAlphaOnly:!1})}_analyzeSolidStroke(e,t,i,r){const o=e.primitiveName,n=M(e.color),s=b(e.width,f),l=T(e.capStyle),c=$(e.joinStyle),m=e.miterLimit,[h,p]=this._analyzePrimitiveOverrides(o,t,null,null),u=a(JSON.stringify(e)+p).toString();let y,d;if(t&&t instanceof Array&&t.length>0){const e=t[t.length-1];if("CIMGeometricEffectDashes"===e.type&&"NoConstraint"===e.lineDashEnding&&null===e.offsetAlongLine){const e=(t=[...t]).pop();y=e.dashTemplate,d=e.scaleDash}}this._cimLayers.push({type:"line",templateHash:u,materialHash:h?()=>u:u,cim:e,materialOverrides:null,isOutline:i,colorLocked:!!e.colorLocked,effects:t,color:this._createOverrideFunction(o,"Color",n,U),width:this._createOverrideFunction(o,"Width",s),cap:this._createOverrideFunction(o,"CapStyle",l),join:this._createOverrideFunction(o,"JoinStyle",c),miterLimit:m&&this._createOverrideFunction(o,"MiterLimit",m),referenceWidth:r,zOrder:D(e.name),dashTemplate:y,scaleDash:d,sampleAlphaOnly:!0})}_analyzePictureStroke(e,t,i,r){const o=a(`${e.url}${JSON.stringify(e.colorSubstitutions)}`).toString(),n=e.primitiveName,s=k(e),l=b(e.width,f),c=T(e.capStyle),m=$(e.joinStyle),h=e.miterLimit,[p,u]=this._analyzePrimitiveOverrides(n,t,null,null),y=a(JSON.stringify(e)+u).toString();this._cimLayers.push({type:"line",templateHash:y,materialHash:p?()=>o:o,cim:e,materialOverrides:null,isOutline:i,colorLocked:!!e.colorLocked,effects:t,color:this._createOverrideFunction(n,"TintColor",s,U),width:this._createOverrideFunction(n,"Width",l),cap:this._createOverrideFunction(n,"CapStyle",c),join:this._createOverrideFunction(n,"JoinStyle",m),miterLimit:h&&this._createOverrideFunction(n,"MiterLimit",h),referenceWidth:r,zOrder:D(e.name),dashTemplate:null,scaleDash:!1,url:e.url,sampleAlphaOnly:!1})}_analyzeGradientStroke(e,t,i,r){const o=e.primitiveName,n=b(e.width,f),s=T(e.capStyle),l=$(e.joinStyle),c=e.miterLimit,[m,h]=this._analyzePrimitiveOverrides(o,t,null,null),p=a(JSON.stringify(e)+h).toString();this._cimLayers.push({type:"line",templateHash:p,materialHash:m?()=>p:p,cim:e,materialOverrides:null,isOutline:i,colorLocked:!!e.colorLocked,effects:t,color:{r:128,g:128,b:128,a:1},width:this._createOverrideFunction(o,"Width",n),cap:this._createOverrideFunction(o,"CapStyle",s),join:this._createOverrideFunction(o,"JoinStyle",l),miterLimit:c&&this._createOverrideFunction(o,"MiterLimit",c),referenceWidth:r,zOrder:D(e.name),dashTemplate:null,scaleDash:!1,sampleAlphaOnly:!1})}_analyzeMarker(e,t,i,r,o,n,a,s,l,c,m,f,p=!1){if(this._analyzeMarkerInsidePolygon(e,t))return;const u=b(e.size,h),y=b(e.rotation),d=b(e.offsetX),v=b(e.offsetY);let _=this._createOverrideFunction(e.primitiveName,"Size",u),O=this._createOverrideFunction(e.primitiveName,"Rotation",y),S=this._createOverrideFunction(e.primitiveName,"OffsetX",d),g=this._createOverrideFunction(e.primitiveName,"OffsetY",v);_=this._transformSize(_,a),O=this._transformRotation(O,!!e.rotateClockwise,c);const M=this._transformOffsetX(S,g,c,a,m),k=this._transformOffsetY(S,g,c,a,f);switch(S=M,g=k,e.type){case"CIMPictureMarker":this._analyzePictureMarker(e,t,i,r,o,n,_,O,S,g,e.colorLocked||p);break;case"CIMVectorMarker":this._analyzeVectorMarker(e,t,i,r,o,n,a,s,_,O,S,g,e.colorLocked||p)}}_analyzeMarkerInsidePolygon(e,t){const{markerPlacement:i,type:r}=e;if(!i||"CIMMarkerPlacementInsidePolygon"!==i.type)return!1;if("CIMVectorMarker"===r||"CIMPictureMarker"===r){const o=e.primitiveName;if(o){const[e,i]=this._analyzePrimitiveOverrides([o],t,null,null);if(e)return!1}const n=i.primitiveName;if(n){const[e,i]=this._analyzePrimitiveOverrides([n],t,null,null);if(e)return!1}if("CIMVectorMarker"===r){const{markerGraphics:t}=e;if(t)for(const e of t){const{symbol:t}=e;if("CIMPolygonSymbol"===t?.type&&t.symbolLayers){const{symbolLayers:e}=t;for(const t of e)if("CIMSolidStroke"===t.type)return!1}}}else{const{animatedSymbolProperties:t}=e;if(t)return!1}}const o=i,s=Math.abs(o.stepX),l=Math.abs(o.stepY);if(0===s||0===l)return!0;const c=["Rotation","OffsetX","OffsetY"],m=this._primitiveOverrides.filter((t=>t.primitiveName!==e.primitiveName||!c.includes(t.propertyName))),f="url"in e&&"string"==typeof e.url?e.url:void 0,h=a(JSON.stringify(e)).toString();let p,u,y=null;if("Random"===i.gridType){const e=n(J),t=Math.max(Math.floor(e/s),1),i=Math.max(Math.floor(e/l),1);p=l*i,y=e=>e?e*i:0;u=t*s/p}else i.shiftOddRows?(p=2*l,y=e=>e?2*e:0,u=s/l*.5):(p=l,y=null,u=s/l);const d=k(e);return this._cimLayers.push({type:"fill",templateHash:h,materialHash:h,cim:e,materialOverrides:m,colorLocked:!!e.colorLocked,effects:t,color:d,height:this._createOverrideFunction(o.primitiveName,"StepY",p,y),scaleX:u,angle:o.gridAngle,offsetX:b(o.offsetX),offsetY:b(o.offsetY),url:f,applyRandomOffset:"Random"===i.gridType,sampleAlphaOnly:!f,hasUnresolvedReplacementColor:!0}),!0}_analyzePictureMarker(e,t,i,r,o,n,s,l,c,m,f){let h=b(e.scaleX,1);const p=k(e),u=a(`${e.url}${JSON.stringify(e.colorSubstitutions)}${JSON.stringify(e.animatedSymbolProperties)}`).toString();i||(i=this._createMarkerPlacementOverrideFunction(e.markerPlacement));const y=this._createAnimatedSymbolPropertiesOverrideFunction(e.animatedSymbolProperties),[d,v]=this._analyzePrimitiveOverrides(r,t,i,y),_=a(JSON.stringify(e)+v).toString(),O=e.anchorPoint??{x:0,y:0};if("width"in e&&"number"==typeof e.width){const t=e.width;let i=1;const r=this._resourceManager.getResource(e.url);null!=r&&(i=r.width/r.height);h/=i*(b(e.size)/t)}function S(e,t){return null!=y?x(y,e,t):null}const g=e.animatedSymbolProperties&&!0===e.animatedSymbolProperties.randomizeStartTime?(e,t,i,r)=>{const o=Y(r??0),n=S(e,t);return u+`-MATERIALGROUP(${o})`+`-ASP(${JSON.stringify(n)})`}:d?(e,t)=>{const i=S(e,t);return u+`-ASP(${JSON.stringify(i)})`}:u;this._cimLayers.push({type:"marker",templateHash:_,materialHash:g,cim:e,materialOverrides:null,colorLocked:!!e.colorLocked||!!f,effects:t,scaleSymbolsProportionally:!1,alignment:o,size:s,scaleX:this._createOverrideFunction(e.primitiveName,"ScaleX",h),rotation:l,offsetX:c,offsetY:m,color:this._createOverrideFunction(e.primitiveName,"TintColor",p,U),anchorPoint:{x:O.x,y:O.y},isAbsoluteAnchorPoint:"Relative"!==e.anchorPointUnits,outlineColor:{r:0,g:0,b:0,a:0},outlineWidth:0,frameHeight:0,rotateClockwise:!1,referenceSize:n,sizeRatio:1,markerPlacement:i,url:e.url,animatedSymbolProperties:y})}_analyzeVectorMarker(e,t,i,r,o,n,a,s,l,c,m,f,h){const p=e.markerGraphics;if(!p)return;let u,y=0,d=1;e.scaleSymbolsProportionally&&(u=e.frame,u&&(y=u.ymax-u.ymin,d=this._transformSize(l,1/y))),d=this._transformSize(d,a),i||(i=this._createMarkerPlacementOverrideFunction(e.markerPlacement));for(const v of p)if(v){const a=v.symbol;if(!a)continue;const p=v.primitiveName;p&&r.push(p);let _=m,O=f;if(("CIMPointSymbol"===a.type||"CIMTextSymbol"===a.type)&&u){let t=0,i=0;const r=v.geometry;"x"in r&&"y"in r&&(t+=r.x-.5*(u.xmin+u.xmax),i+=r.y-.5*(u.ymin+u.ymax));const o=e.anchorPoint;o&&("Absolute"===e.anchorPointUnits?(t-=o.x,i-=o.y):u&&(t-=(u.xmax-u.xmin)*o.x,i-=(u.ymax-u.ymin)*o.y)),_=this._transformOffsetX(t,i,c,d,m),O=this._transformOffsetY(t,i,c,d,f)}switch(a.type){case"CIMPointSymbol":case"CIMLineSymbol":case"CIMPolygonSymbol":s?this._analyzeMultiLayerGraphicNonSDF(e,t,i,null,v,r,o,n,y,!!h||!!e.colorLocked):this._analyzeMultiLayerGraphic(e,t,i,null,v,r,o,n,y,d,l,c,_,O,!!h||!!e.colorLocked);break;case"CIMTextSymbol":this._analyzeTextGraphic(e,t,i,v,r,o,n,y,d,l,c,_,O,h)}p&&r.pop()}}_analyzeMultiLayerGraphic(e,t,i,r,o,n,s,l,c,m,f,h,p,u,y){const d=o.symbol,v=d.symbolLayers;if(!v)return;let _=v.length;if(B(v))return void this._analyzeCompositeMarkerGraphic(e,t,i,r,o,v,n,s,l,c,f,h,p,u,!!y||!!e.colorLocked);const O=this._resourceManager.geometryEngine,k=X.applyEffects(d.effects,o.geometry,O);if(k)for(;_--;){const d=v[_];if(!d||!1===d.enable)continue;const b=d.primitiveName;switch(b&&n.push(b),d.type){case"CIMSolidFill":case"CIMSolidStroke":{const m=X.applyEffects(d.effects,k,O),v=S(m);if(!v)continue;const _="Relative"!==e.anchorPointUnits,[C,F,I]=g(v,e.frame,e.size,e.anchorPoint,_),w="CIMSolidFill"===d.type,x={type:"sdf",geom:m,asFill:w},A=d.path,R=M(w?N(d):P(d)),H=w?{r:0,g:0,b:0,a:0}:M(P(d)),J=z(d)??0;if(!w&&!J)break;const Y=o.primitiveName;let E=null;!w||d.colorLocked||y||(E=this._createOverrideFunction(Y,"FillColor",R,U));let T=null;d.colorLocked||y||(T=this._createOverrideFunction(Y,"StrokeColor",H,U));const $=this._createOverrideFunction(Y,"StrokeWidth",J);let j=!1,G="";for(const e of this._primitiveOverrides)n.includes(e.primitiveName)&&(null!=e.value?G+=`-${e.primitiveName}-${e.propertyName}-${JSON.stringify(e.value)}`:e.valueExpressionInfo&&(j=!0));(null!=t&&"function"==typeof t||null!=i&&"function"==typeof i)&&(j=!0),(L(f)||L(h)||L(p)||L(u))&&(j=!0);const D=JSON.stringify({...e,markerGraphics:null}),W=a(JSON.stringify(x)+A).toString(),V=a(JSON.stringify(o)+JSON.stringify(d)+D+G).toString();this._cimLayers.push({type:"marker",templateHash:V,materialHash:j?()=>W:W,cim:x,materialOverrides:null,colorLocked:!!d.colorLocked||!!y,effects:t,scaleSymbolsProportionally:!!e.scaleSymbolsProportionally,alignment:s,anchorPoint:{x:F,y:I},isAbsoluteAnchorPoint:_,size:f,rotation:h,offsetX:p,offsetY:u,scaleX:1,frameHeight:c,rotateClockwise:!1,referenceSize:l,sizeRatio:C,color:L(E)?E:this._createOverrideFunction(b,"Color",R,U),outlineColor:L(T)?T:this._createOverrideFunction(b,"Color",H,U),outlineWidth:L($)?$:this._createOverrideFunction(b,"Width",J),markerPlacement:i,animatedSymbolProperties:r,path:A});break}case"CIMVectorMarker":d.markerPlacement?this._analyzeMultiLayerGraphicNonSDF(e,t,i,r,o,n,s,l,c,!!y||!!d.colorLocked):this._analyzeMarker(d,t,i,n,s,l,m,!1,f,h,p,u,!!y||!!e.colorLocked);break;default:this._analyzeMultiLayerGraphicNonSDF(e,t,i,r,o,n,s,l,c,!!y||!!e.colorLocked)}b&&n.pop()}}_analyzeTextGraphic(e,i,r,o,n,s,l,c,m,h,u,d,v,_){const O=[];y.findApplicableOverrides(o,this._primitiveOverrides,O);const S=o.geometry;if(!("x"in S)||!("y"in S))return;const g=o.symbol,k=C(g),L=F(g.fontStyleName),X=t(g.fontFamilyName);g.font={family:X,decoration:k,...L};let H=b(g.height,p),J=b(g.angle),Y=b(g.offsetX),E=b(g.offsetY);H=this._transformSize(H,m),J=this._transformRotation(J,!1,u);const T=this._transformOffsetX(Y,E,u,m,d),$=this._transformOffsetY(Y,E,u,m,v);Y=T,E=$;const j=M(N(g));let G=M(P(g)),D=z(g)??0;D||(G=M(N(g.haloSymbol)),D=b(g.haloSize)),D=this._transformSize(D,m);let U=null,W=null,V=0;if(g.callout&&"CIMBackgroundCallout"===g.callout.type){const e=g.callout;if(e.backgroundSymbol){const t=e.backgroundSymbol.symbolLayers;if(t)for(const e of t)"CIMSolidFill"===e.type?U=M(e.color):"CIMSolidStroke"===e.type&&(W=M(e.color),V=b(e.width,f))}}const[B,q]=this._analyzePrimitiveOverrides(n,i,r,null),K=JSON.stringify(e.effects)+Number(e.colorLocked||_).toString()+JSON.stringify(e.anchorPoint)+e.anchorPointUnits+JSON.stringify(e.markerPlacement)+e.size.toString(),Q=a(JSON.stringify(o)+K+q).toString();let Z=this._createOverrideFunction(o.primitiveName,"TextString",o.textString??"",I,g.textCase);if(null==Z)return;const{fontStyleName:ee}=g,te=X+(ee?"-"+ee.toLowerCase():"-regular"),ie=te;"string"==typeof Z&&Z.includes("[")&&g.fieldMap&&(Z=w(g.fieldMap,Z,g.textCase)),this._cimLayers.push({type:"text",templateHash:Q,materialHash:B||"function"==typeof Z||/\[(.*?)\]/.test(Z)?(e,t,i)=>ie+"-"+x(Z,e,t,i):ie+"-"+a(Z),cim:g,materialOverrides:null,colorLocked:!!e.colorLocked||!!_,effects:i,alignment:s,anchorPoint:{x:0,y:0},isAbsoluteAnchorPoint:"Relative"!==e.anchorPointUnits,fontName:te,decoration:k,weight:L.weight,style:L.style,size:H,angle:J,offsetX:Y,offsetY:E,horizontalAlignment:A(g.horizontalAlignment),verticalAlignment:R(g.verticalAlignment),text:Z,color:j,outlineColor:G,outlineSize:D,backgroundColor:U,borderLineColor:W,borderLineWidth:V,referenceSize:l,sizeRatio:1,markerPlacement:r})}_analyzeMultiLayerGraphicNonSDF(e,t,i,r,n,s,l,c,m,f){const p=this._buildSimpleMarker(e,n),y=e.primitiveName,d=this._analyzeMaterialOverrides(y,["Rotation","OffsetX","OffsetY"]),[v,_]=this._analyzePrimitiveOverrides(s,null,null,null),[O,S,g]=u.getTextureAnchor(p,this._resourceManager),M=b(e.rotation),k=b(e.offsetX),N=b(e.offsetY),P=a(JSON.stringify(p)+_).toString(),z=d&&d.length>0||null!=t&&"function"==typeof t;this._cimLayers.push({type:"marker",templateHash:P,materialHash:z&&d?this._createMaterialHashFunction(P,d):P,cim:p,materialOverrides:d,colorLocked:!!e.colorLocked||!!f,effects:t,scaleSymbolsProportionally:!!e.scaleSymbolsProportionally,alignment:l,anchorPoint:{x:O,y:S},isAbsoluteAnchorPoint:!1,size:b(e.size,h),rotation:this._createOverrideFunction(y,"Rotation",M),offsetX:this._createOverrideFunction(y,"OffsetX",k),offsetY:this._createOverrideFunction(y,"OffsetY",N),color:{r:255,g:255,b:255,a:1},outlineColor:{r:0,g:0,b:0,a:0},outlineWidth:0,scaleX:1,frameHeight:m,rotateClockwise:!!e.rotateClockwise,referenceSize:c,sizeRatio:g/o(e.size),markerPlacement:i,animatedSymbolProperties:r,avoidSDFRasterization:!0})}_buildSimpleMarker(e,t){return{type:e.type,enable:!0,name:e.name,colorLocked:e.colorLocked,primitiveName:e.primitiveName,anchorPoint:e.anchorPoint,anchorPointUnits:e.anchorPointUnits,offsetX:0,offsetY:0,rotateClockwise:e.rotateClockwise,rotation:0,size:e.size,billboardMode3D:e.billboardMode3D,depth3D:e.depth3D,frame:e.frame,markerGraphics:[t],scaleSymbolsProportionally:e.scaleSymbolsProportionally,respectFrame:e.respectFrame,clippingPath:e.clippingPath}}_analyzeCompositeMarkerGraphic(e,t,i,r,o,n,s,l,c,m,h,p,u,y,d){const v=o.geometry,_=n[0],O=n[1],k=S(v);if(!k)return;const N="Relative"!==e.anchorPointUnits,[P,z,C]=g(k,e.frame,e.size,e.anchorPoint,N),F={type:"sdf",geom:v,asFill:!0},I=O.path,w=O.primitiveName,x=_.primitiveName,A=M(O.color),R=M(_.color),X=b(_.width,f),H=o.primitiveName;let J=null;O.colorLocked||d||(J=this._createOverrideFunction(H,"FillColor",A,U));let Y=null;_.colorLocked||d||(Y=this._createOverrideFunction(H,"StrokeColor",R,U));const E=this._createOverrideFunction(H,"StrokeWidth",X);let T=!1,$="";for(const a of this._primitiveOverrides)(a.primitiveName===w||a.primitiveName===x||s.includes(a.primitiveName))&&(null!=a.value?$+=`-${a.primitiveName}-${a.propertyName}-${JSON.stringify(a.value)}`:a.valueExpressionInfo&&(T=!0));null!=i&&"function"==typeof i&&(T=!0),(L(h)||L(p)||L(u)||L(y))&&(T=!0);const j=JSON.stringify({...e,markerGraphics:null}),G=a(JSON.stringify(F)+I).toString(),D=a(JSON.stringify(o)+JSON.stringify(O)+JSON.stringify(_)+j+$).toString();this._cimLayers.push({type:"marker",templateHash:D,materialHash:T?()=>G:G,cim:F,materialOverrides:null,colorLocked:!!d,effects:t,scaleSymbolsProportionally:!!e.scaleSymbolsProportionally,alignment:l,anchorPoint:{x:z,y:C},isAbsoluteAnchorPoint:N,size:h,rotation:p,offsetX:u,offsetY:y,scaleX:1,frameHeight:m,rotateClockwise:!1,referenceSize:c,sizeRatio:P,color:L(J)?J:this._createOverrideFunction(w,"Color",A,U),outlineColor:L(Y)?Y:this._createOverrideFunction(x,"Color",R,U),outlineWidth:L(E)?E:this._createOverrideFunction(x,"Width",X),markerPlacement:i,path:I,animatedSymbolProperties:r})}_createMaterialHashFunction(e,t){const i=this._info?.geometryType;if(i){const e=this._poMap;for(const r of t){if(r.valueExpressionInfo){const t=e[r.primitiveName]&&e[r.primitiveName][r.propertyName];t instanceof l&&(r.fn=(e,r,o)=>H(t,e,{$view:o},i,r))}}}return(i,r,o)=>{for(const e of t)e.fn&&(e.value=e.fn(i,r,o));return a(e+y.buildOverrideKey(t)).toString()}}_setPoMap(e,t,i){let r;this._poMap[e]?r=this._poMap[e]:(r={},this._poMap[e]=r),r[t]=i}_createOverrideFunction(e,t,i,r,o){if(null==e)return i;const n=this._poMap[e];if(null==n)return i;const a=n[t];if("string"==typeof a||"number"==typeof a||a instanceof Array)return r?r.call(null,a,o):a;const s=this._info?.geometryType;return null!=a&&a instanceof l&&null!=s?(e,t,n)=>{let l=H(a,e,{$view:n},s,t);return null!==l&&r&&(l=r.call(null,l,o)),null!==l?l:i}:i}_createEffectsOverrideFunction(e,t){const r=this._poMap,o=this._info?.geometryType;for(const i of t){if(i.valueExpressionInfo&&o){const e=r[i.primitiveName]&&r[i.primitiveName][i.propertyName];e instanceof l&&(i.fn=(t,i,r)=>H(e,t,{$view:r},o,i))}}return(r,o,n)=>{for(const e of t)e.fn&&(e.value=e.fn(r,o,n));const a=[];for(let s of e){const e=s?.primitiveName;if(e){let r=!1;for(const o of t)if(o.primitiveName===e){const e=W(o.propertyName);null!=o.value&&o.value!==s[e]&&(r||(s=i(s),r=!0),s[e]=o.value)}}a.push(s)}return a}}_createMarkerPlacementOverrideFunction(e){const t=[];if(y.findApplicableOverrides(e,this._primitiveOverrides,t),null==e||0===t.length)return e;const r=this._poMap,o=this._info?.geometryType;for(const i of t){if(i.valueExpressionInfo&&o){const e=r[i.primitiveName]&&r[i.primitiveName][i.propertyName];e instanceof l&&(i.fn=(t,i,r)=>H(e,t,{$view:r},o,i))}}return(r,o,n)=>{for(const e of t)e.fn&&(e.value=e.fn(r,o,n));const a=i(e),s=e.primitiveName;for(const e of t)if(e.primitiveName===s){const t=W(e.propertyName);null!=e.value&&e.value!==a[t]&&(a[t]=e.value)}return a}}_createAnimatedSymbolPropertiesOverrideFunction(e){const t=[];if(y.findApplicableOverrides(e,this._primitiveOverrides,t),null==e||0===t.length)return e;const r=this._info?.geometryType;if(r){const e=this._poMap;for(const i of t){if(i.valueExpressionInfo){const t=e[i.primitiveName]&&e[i.primitiveName][i.propertyName];t instanceof l&&(i.fn=(e,i,o)=>H(t,e,{$view:o},r,i))}}}return(r,o,n)=>{for(const e of t)e.fn&&(e.value=e.fn(r,o,n));const a=i(e),s=e.primitiveName;for(const e of t)if(e.primitiveName===s){const t=W(e.propertyName);if(null!=e.value){const i=O(e.value,e.propertyName);i!==a[t]&&(a[t]=i)}}return a}}_analyzePrimitiveOverrides(e,t,i,r){let o=!1,n="";"string"==typeof e&&(e=[e]);for(const a of this._primitiveOverrides)e?.includes(a.primitiveName)&&(null!=a.value?n+=`-${a.primitiveName}-${a.propertyName}-${JSON.stringify(a.value)}`:a.valueExpressionInfo&&(o=!0));return null!=t&&"function"==typeof t&&(o=!0),null!=i&&"function"==typeof i&&(o=!0),null!=r&&"function"==typeof r&&(o=!0),[o,n]}_analyzeMaterialOverrides(e,t){return this._primitiveOverrides.filter((i=>i.primitiveName!==e||!t.includes(i.propertyName)))}_transformSize(e,t){return L(e)||L(t)?(i,r,o)=>(L(e)?e(i,r,o):e)*(L(t)?t(i,r,o):t):e*t}_transformRotation(e,t,i){return L(e)||L(i)?(r,o,n)=>{const a=L(e)?e(r,o,n):e,s=L(i)?i(r,o,n):i;return t?s-a:s+a}:t?i-e:i+e}_transformOffsetX(e,t,i,r,o){if(!(L(e)||L(t)||L(i)||L(r)||L(o))){const n=i*Math.PI/180;if(n){const i=Math.cos(n),a=Math.sin(n);return(i*e-a*t)*r+o}return e*r+o}return(n,a,s)=>{let l=L(i)?i(n,a,s):i;const c=L(r)?r(n,a,s):r,m=L(e)?e(n,a,s):e,f=L(o)?o(n,a,s):o;if(l){l*=Math.PI/180;return(Math.cos(l)*m-Math.sin(l)*(L(t)?t(n,a,s):t))*c+f}return m*c+f}}_transformOffsetY(e,t,i,r,o){if(!(L(e)||L(t)||L(i)||L(r)||L(o))){const n=i*Math.PI/180;if(n){const i=Math.cos(n);return(Math.sin(n)*e+i*t)*r+o}return t*r+o}return(n,a,s)=>{let l=L(i)?i(n,a,s):i;const c=L(r)?r(n,a,s):r,m=L(t)?t(n,a,s):t,f=L(o)?o(n,a,s):o;if(l){l*=Math.PI/180;const t=Math.cos(l);return(Math.sin(l)*(L(e)?e(n,a,s):e)+t*m)*c+f}return m*c+f}}}function D(e){if(e&&0===e.indexOf("Level_")){const t=parseInt(e.substr(6),10);if(!isNaN(t))return t}return 0}function U(t){if(!t||0===t.length)return null;const i=new e(t).toRgba();return{r:i[0],g:i[1],b:i[2],a:i[3]}}function W(e){return e?e.charAt(0).toLowerCase()+e.substr(1):e}function V(e,t){if(!t||0===t.length)return e;const r=i(e);return y.applyOverrides(r,t),r}const B=e=>e&&2===e.length&&e[0].enable&&e[1].enable&&"CIMSolidStroke"===e[0].type&&"CIMSolidFill"===e[1].type&&!e[0].effects&&!e[1].effects;export{G as CIMAnalyzer,V as analyzeCIMResource};
5
+ import e from"../../Color.js";import{getFontFamily as t}from"../../core/fontUtils.js";import{clone as i}from"../../core/lang.js";import r from"../../core/Logger.js";import{pt2px as o,px2pt as n}from"../../core/screenUtils.js";import{numericHash as a}from"../../core/string.js";import{createRendererExpression as s,ArcadeExpression as l}from"../../support/arcadeOnDemand.js";import{DEFAULT_PICTURE_FILL_HEIGHT as c,DEFAULT_HATCH_FILL_SEPARATION as m,DEFAULT_STROKE_WIDTH as f,DEFAULT_MARKER_SIZE as h,DEFAULT_TEXT_HEIGHT as u}from"./CIMSymbolDrawHelper.js";import{CIMSymbolHelper as p,OverrideHelper as y}from"./CIMSymbolHelper.js";import{Alignment as d,CapType as v,JoinType as _}from"./enums.js";import{quantizeIfNeeded as O}from"./quantizeTime.js";import{getExtent as S,getSDFMetrics as g}from"./SDFHelper.js";import{fromCIMColor as M,getTintColor as k,getValue as b,getFillColor as N,getStrokeColor as P,getStrokeWidth as z,isFeatureValueFn as L,fromCIMFontDecoration as C,fromCIMFontStyle as F,adjustTextCase as I,createLabelOverrideFunction as w,evaluateValueOrFunction as x,fromCIMHorizontalAlignment as A,fromCIMVerticalAlignment as R}from"./utils.js";import{CIMEffectHelper as X}from"./effects/CIMEffectHelper.js";import H from"../../views/2d/arcade/callExpressionWithFeature.js";import{RANDOM_INSIDE_POLYGON_TEXTURE_SIZE as J}from"../../views/2d/engine/webgl/definitions.js";import{getMaterialGroup as Y}from"../../views/2d/engine/webgl/grouping.js";const E=r.getLogger("esri.symbols.cim.cimAnalyzer");function T(e){switch(e){case"Butt":return v.BUTT;case"Square":return v.SQUARE;default:return v.ROUND}}function $(e){switch(e){case"Bevel":return _.BEVEL;case"Miter":return _.MITER;default:return _.ROUND}}function j(e){const t=e.markerPlacement;return t&&t.angleToLine?d.MAP:d.SCREEN}class G{constructor(e,t){this._cimLayers=[],this._poMap={},this._primitiveOverrides=[],this._resourceManager=e,this._info=t}async analyzeSymbolReference(e,t,i){if(this._cimLayers=i??[],!e)return this._cimLayers;if(e.primitiveOverrides){this._primitiveOverrides=e.primitiveOverrides,this._poMap={};const t=[],i=this._info;for(const e of this._primitiveOverrides){const r=e.valueExpressionInfo;if(r&&i){const o=r.expression,n=s(o,i.spatialReference,i.fields).then((t=>{null!=t&&this._setPoMap(e.primitiveName,e.propertyName,t)}));t.push(n)}else null!=e.value&&this._setPoMap(e.primitiveName,e.propertyName,e.value);t.length>0&&await Promise.all(t)}}const r=e.symbol,o=[];return p.fetchResources(r,this._resourceManager,o),o.length>0&&await Promise.all(o),this._analyzeSymbol(r,t),this._cimLayers}_analyzeSymbol(e,t){switch(e?.type){case"CIMPointSymbol":case"CIMLineSymbol":case"CIMPolygonSymbol":this._analyzeMultiLayerSymbol(e,t,1,0,0,0)}}_analyzeMultiLayerSymbol(e,t,i,r,o,n){const a=e?.symbolLayers;if(!a)return;const s=e.effects;let l=d.SCREEN;const c=p.getSize(e)??0;"CIMPointSymbol"===e.type&&"Map"===e.angleAlignment&&(l=d.MAP);const m="CIMPolygonSymbol"===e.type;let f=a.length;for(;f--;){const h=a[f];if(!h||!1===h.enable)continue;let u;s&&s.length&&(u=[...s]);const p=h.effects;p&&p.length&&(s?u.push(...p):u=[...p]);const d=[];let v;y.findEffectOverrides(u,this._primitiveOverrides,d),v=d.length>0?this._createEffectsOverrideFunction(u,d):u;const _=[];switch(y.findApplicableOverrides(h,this._primitiveOverrides,_),h.type){case"CIMSolidFill":this._analyzeSolidFill(h,v);break;case"CIMPictureFill":this._analyzePictureFill(h,v);break;case"CIMHatchFill":this._analyzeHatchFill(h,v);break;case"CIMGradientFill":this._analyzeGradientFill(h,v);break;case"CIMSolidStroke":this._analyzeSolidStroke(h,v,m,c);break;case"CIMPictureStroke":this._analyzePictureStroke(h,v,m,c);break;case"CIMGradientStroke":this._analyzeGradientStroke(h,v,m,c);break;case"CIMCharacterMarker":case"CIMPictureMarker":case"CIMVectorMarker":{"CIMLineSymbol"===e.type&&(l=j(h));const a=[],s=h.primitiveName;s&&a.push(s),this._analyzeMarker(h,v,null,a,l,c,1,t,i,r,o,n);break}default:E.error("Cannot analyze CIM layer",h.type)}}}_analyzeSolidFill(e,t){const i=e.primitiveName,r=M(e.color),[o,n]=this._analyzePrimitiveOverrides(i,t,null,null),s=a(JSON.stringify(e)+n).toString();this._cimLayers.push({type:"fill",templateHash:s,materialHash:o?()=>s:s,cim:e,materialOverrides:null,colorLocked:!!e.colorLocked,color:this._createOverrideFunction(i,"Color",r,U),height:0,angle:0,offsetX:0,offsetY:0,scaleX:1,effects:t,applyRandomOffset:!1,sampleAlphaOnly:!0})}_analyzePictureFill(e,t){const i=e.primitiveName,r=k(e),[o,n]=this._analyzePrimitiveOverrides(i,t,null,null),s=a(JSON.stringify(e)+n).toString(),l=a(`${e.url}${JSON.stringify(e.colorSubstitutions)}`).toString(),m=b(e.height,c);let f=b(e.scaleX,1);if("width"in e&&"number"==typeof e.width){const t=e.width;let i=1;const r=this._resourceManager.getResource(e.url);null!=r&&(i=r.width/r.height),f/=i*(m/t)}this._cimLayers.push({type:"fill",templateHash:s,materialHash:o?()=>l:l,cim:e,materialOverrides:null,colorLocked:!!e.colorLocked,effects:t,color:this._createOverrideFunction(i,"TintColor",r,U),height:this._createOverrideFunction(i,"Height",m),scaleX:this._createOverrideFunction(i,"ScaleX",f),angle:this._createOverrideFunction(i,"Rotation",b(e.rotation)),offsetX:this._createOverrideFunction(i,"OffsetX",b(e.offsetX)),offsetY:this._createOverrideFunction(i,"OffsetY",b(e.offsetY)),url:e.url,applyRandomOffset:!1,sampleAlphaOnly:!1})}_analyzeHatchFill(e,t){const i=e.primitiveName,r=this._analyzeMaterialOverrides(i,["Rotation","OffsetX","OffsetY"]);let[o,n]=this._analyzePrimitiveOverrides(i,t,null,null);const s=a(JSON.stringify(e)+n).toString(),l=a(`${e.separation}${JSON.stringify(e.lineSymbol)}`).toString();let c={r:255,g:255,b:255,a:1},f=!1;const h=e.lineSymbol?.symbolLayers?.find((e=>"CIMSolidStroke"===e.type&&null!=this._poMap[e.primitiveName]?.Color));if(h){c=M(h.color),c=this._createOverrideFunction(h.primitiveName,"Color",c,U);const e="function"==typeof c;o=o||e,f=null!=h.color||e}this._cimLayers.push({type:"fill",templateHash:s,materialHash:o&&r?this._createMaterialHashFunction(l,r):l,cim:e,materialOverrides:r,colorLocked:!!e.colorLocked,effects:t,color:c,height:this._createOverrideFunction(i,"Separation",b(e.separation,m)),scaleX:1,angle:this._createOverrideFunction(i,"Rotation",b(e.rotation)),offsetX:this._createOverrideFunction(i,"OffsetX",b(e.offsetX)),offsetY:this._createOverrideFunction(i,"OffsetY",b(e.offsetY)),applyRandomOffset:!1,sampleAlphaOnly:!0,hasUnresolvedReplacementColor:!f})}_analyzeGradientFill(e,t){const i=e.primitiveName,[r,o]=this._analyzePrimitiveOverrides(i,t,null,null),n=a(JSON.stringify(e)+o).toString();this._cimLayers.push({type:"fill",templateHash:n,materialHash:r?()=>n:n,cim:e,materialOverrides:null,colorLocked:!!e.colorLocked,effects:t,color:{r:128,g:128,b:128,a:1},height:0,angle:0,offsetX:0,offsetY:0,scaleX:1,applyRandomOffset:!1,sampleAlphaOnly:!1})}_analyzeSolidStroke(e,t,i,r){const o=e.primitiveName,n=M(e.color),s=b(e.width,f),l=T(e.capStyle),c=$(e.joinStyle),m=e.miterLimit,[h,u]=this._analyzePrimitiveOverrides(o,t,null,null),p=a(JSON.stringify(e)+u).toString();let y,d;if(t&&t instanceof Array&&t.length>0){const e=t[t.length-1];if("CIMGeometricEffectDashes"===e.type&&"NoConstraint"===e.lineDashEnding&&null===e.offsetAlongLine){const e=(t=[...t]).pop();y=e.dashTemplate,d=e.scaleDash}}this._cimLayers.push({type:"line",templateHash:p,materialHash:h?()=>p:p,cim:e,materialOverrides:null,isOutline:i,colorLocked:!!e.colorLocked,effects:t,color:this._createOverrideFunction(o,"Color",n,U),width:this._createOverrideFunction(o,"Width",s),cap:this._createOverrideFunction(o,"CapStyle",l),join:this._createOverrideFunction(o,"JoinStyle",c),miterLimit:m&&this._createOverrideFunction(o,"MiterLimit",m),referenceWidth:r,zOrder:D(e.name),dashTemplate:y,scaleDash:d,sampleAlphaOnly:!0})}_analyzePictureStroke(e,t,i,r){const o=a(`${e.url}${JSON.stringify(e.colorSubstitutions)}`).toString(),n=e.primitiveName,s=k(e),l=b(e.width,f),c=T(e.capStyle),m=$(e.joinStyle),h=e.miterLimit,[u,p]=this._analyzePrimitiveOverrides(n,t,null,null),y=a(JSON.stringify(e)+p).toString();this._cimLayers.push({type:"line",templateHash:y,materialHash:u?()=>o:o,cim:e,materialOverrides:null,isOutline:i,colorLocked:!!e.colorLocked,effects:t,color:this._createOverrideFunction(n,"TintColor",s,U),width:this._createOverrideFunction(n,"Width",l),cap:this._createOverrideFunction(n,"CapStyle",c),join:this._createOverrideFunction(n,"JoinStyle",m),miterLimit:h&&this._createOverrideFunction(n,"MiterLimit",h),referenceWidth:r,zOrder:D(e.name),dashTemplate:null,scaleDash:!1,url:e.url,sampleAlphaOnly:!1})}_analyzeGradientStroke(e,t,i,r){const o=e.primitiveName,n=b(e.width,f),s=T(e.capStyle),l=$(e.joinStyle),c=e.miterLimit,[m,h]=this._analyzePrimitiveOverrides(o,t,null,null),u=a(JSON.stringify(e)+h).toString();this._cimLayers.push({type:"line",templateHash:u,materialHash:m?()=>u:u,cim:e,materialOverrides:null,isOutline:i,colorLocked:!!e.colorLocked,effects:t,color:{r:128,g:128,b:128,a:1},width:this._createOverrideFunction(o,"Width",n),cap:this._createOverrideFunction(o,"CapStyle",s),join:this._createOverrideFunction(o,"JoinStyle",l),miterLimit:c&&this._createOverrideFunction(o,"MiterLimit",c),referenceWidth:r,zOrder:D(e.name),dashTemplate:null,scaleDash:!1,sampleAlphaOnly:!1})}_analyzeMarker(e,t,i,r,o,n,a,s,l,c,m,f,u=!1){if(this._analyzeMarkerInsidePolygon(e,t))return;const p=b(e.size,h),y=b(e.rotation),d=b(e.offsetX),v=b(e.offsetY);let _=this._createOverrideFunction(e.primitiveName,"Size",p),O=this._createOverrideFunction(e.primitiveName,"Rotation",y),S=this._createOverrideFunction(e.primitiveName,"OffsetX",d),g=this._createOverrideFunction(e.primitiveName,"OffsetY",v);_=this._transformSize(_,a),O=this._transformRotation(O,!!e.rotateClockwise,c);const M=this._transformOffsetX(S,g,c,a,m),k=this._transformOffsetY(S,g,c,a,f);switch(S=M,g=k,e.type){case"CIMPictureMarker":this._analyzePictureMarker(e,t,i,r,o,n,_,O,S,g,e.colorLocked||u);break;case"CIMVectorMarker":this._analyzeVectorMarker(e,t,i,r,o,n,a,s,_,O,S,g,e.colorLocked||u)}}_analyzeMarkerInsidePolygon(e,t){const{markerPlacement:i,type:r}=e;if(!i||"CIMMarkerPlacementInsidePolygon"!==i.type)return!1;if("CIMVectorMarker"===r||"CIMPictureMarker"===r){const o=e.primitiveName;if(o){const[e,i]=this._analyzePrimitiveOverrides([o],t,null,null);if(e)return!1}const n=i.primitiveName;if(n){const[e,i]=this._analyzePrimitiveOverrides([n],t,null,null);if(e)return!1}if("CIMVectorMarker"===r){const{markerGraphics:t}=e;if(t)for(const e of t){const{symbol:t}=e;if("CIMPolygonSymbol"===t?.type&&t.symbolLayers){const{symbolLayers:e}=t;for(const t of e)if("CIMSolidStroke"===t.type)return!1}}}else{const{animatedSymbolProperties:t}=e;if(t)return!1}}const o=i,s=Math.abs(o.stepX),l=Math.abs(o.stepY);if(0===s||0===l)return!0;const c=["Rotation","OffsetX","OffsetY"],m=this._primitiveOverrides.filter((t=>t.primitiveName!==e.primitiveName||!c.includes(t.propertyName))),f="url"in e&&"string"==typeof e.url?e.url:void 0,h=a(JSON.stringify(e)).toString();let u,p,y=null;if("Random"===i.gridType){const e=n(J),t=Math.max(Math.floor(e/s),1),i=Math.max(Math.floor(e/l),1);u=l*i,y=e=>e?e*i:0;p=t*s/u}else i.shiftOddRows?(u=2*l,y=e=>e?2*e:0,p=s/l*.5):(u=l,y=null,p=s/l);const d=k(e);return this._cimLayers.push({type:"fill",templateHash:h,materialHash:h,cim:e,materialOverrides:m,colorLocked:!!e.colorLocked,effects:t,color:d,height:this._createOverrideFunction(o.primitiveName,"StepY",u,y),scaleX:p,angle:o.gridAngle,offsetX:b(o.offsetX),offsetY:b(o.offsetY),url:f,applyRandomOffset:"Random"===i.gridType,sampleAlphaOnly:!f,hasUnresolvedReplacementColor:!0}),!0}_analyzePictureMarker(e,t,i,r,o,n,s,l,c,m,f){let h=b(e.scaleX,1);const u=k(e),p=a(`${e.url}${JSON.stringify(e.colorSubstitutions)}${JSON.stringify(e.animatedSymbolProperties)}`).toString();i||(i=this._createMarkerPlacementOverrideFunction(e.markerPlacement));const y=this._createAnimatedSymbolPropertiesOverrideFunction(e.animatedSymbolProperties),[d,v]=this._analyzePrimitiveOverrides(r,t,i,y),_=a(JSON.stringify(e)+v).toString(),O=e.anchorPoint??{x:0,y:0};if("width"in e&&"number"==typeof e.width){const t=e.width;let i=1;const r=this._resourceManager.getResource(e.url);null!=r&&(i=r.width/r.height);h/=i*(b(e.size)/t)}function S(e,t){return null!=y?x(y,e,t):null}const g=e.animatedSymbolProperties&&!0===e.animatedSymbolProperties.randomizeStartTime?(e,t,i,r)=>{const o=Y(r??0),n=S(e,t);return p+`-MATERIALGROUP(${o})`+`-ASP(${JSON.stringify(n)})`}:d?(e,t)=>{const i=S(e,t);return p+`-ASP(${JSON.stringify(i)})`}:p;this._cimLayers.push({type:"marker",templateHash:_,materialHash:g,cim:e,materialOverrides:null,colorLocked:!!e.colorLocked||!!f,effects:t,scaleSymbolsProportionally:!1,alignment:o,size:s,scaleX:this._createOverrideFunction(e.primitiveName,"ScaleX",h),rotation:l,offsetX:c,offsetY:m,color:this._createOverrideFunction(e.primitiveName,"TintColor",u,U),anchorPoint:{x:O.x,y:O.y},isAbsoluteAnchorPoint:"Relative"!==e.anchorPointUnits,outlineColor:{r:0,g:0,b:0,a:0},outlineWidth:0,frameHeight:0,rotateClockwise:!1,referenceSize:n,sizeRatio:1,markerPlacement:i,url:e.url,animatedSymbolProperties:y})}_analyzeVectorMarker(e,t,i,r,o,n,a,s,l,c,m,f,h){const u=e.markerGraphics;if(!u)return;const p=e.frame;let y=0,d=1;e.scaleSymbolsProportionally&&p&&(y=p.ymax-p.ymin,d=this._transformSize(l,1/y)),d=this._transformSize(d,a),i||(i=this._createMarkerPlacementOverrideFunction(e.markerPlacement));for(const v of u)if(v){const a=v.symbol;if(!a)continue;const u=v.primitiveName;u&&r.push(u);let _=m,O=f;if(("CIMPointSymbol"===a.type||"CIMTextSymbol"===a.type)&&p){let t=0,i=0;const r=v.geometry;"x"in r&&"y"in r&&(t+=r.x-.5*(p.xmin+p.xmax),i+=r.y-.5*(p.ymin+p.ymax));const o=e.anchorPoint;o&&("Absolute"===e.anchorPointUnits?(t-=o.x,i-=o.y):p&&(t-=(p.xmax-p.xmin)*o.x,i-=(p.ymax-p.ymin)*o.y)),_=this._transformOffsetX(t,i,c,d,m),O=this._transformOffsetY(t,i,c,d,f)}switch(a.type){case"CIMPointSymbol":case"CIMLineSymbol":case"CIMPolygonSymbol":s?this._analyzeMultiLayerGraphicNonSDF(e,t,i,null,v,r,o,n,y,!!h||!!e.colorLocked):this._analyzeMultiLayerGraphic(e,t,i,null,v,r,o,n,y,d,l,c,_,O,!!h||!!e.colorLocked);break;case"CIMTextSymbol":this._analyzeTextGraphic(e,t,i,v,r,o,n,y,d,l,c,_,O,!!h||!!e.colorLocked)}u&&r.pop()}}_analyzeMultiLayerGraphic(e,t,i,r,o,n,s,l,c,m,f,h,u,p,y){const d=o.symbol,v=d.symbolLayers;if(!v)return;let _=v.length;if(B(v))return void this._analyzeCompositeMarkerGraphic(e,t,i,r,o,v,n,s,l,c,f,h,u,p,!!y||!!e.colorLocked);const O=this._resourceManager.geometryEngine,k=X.applyEffects(d.effects,o.geometry,O);if(k)for(;_--;){const d=v[_];if(!d||!1===d.enable)continue;const b=d.primitiveName;switch(b&&n.push(b),d.type){case"CIMSolidFill":case"CIMSolidStroke":{const m=X.applyEffects(d.effects,k,O),v=S(m);if(!v)continue;const _="Relative"!==e.anchorPointUnits,[C,F,I]=g(v,e.frame,e.size,e.anchorPoint,_),w="CIMSolidFill"===d.type,x={type:"sdf",geom:m,asFill:w},A=d.path,R=M(w?N(d):P(d)),H=w?{r:0,g:0,b:0,a:0}:M(P(d)),J=z(d)??0;if(!w&&!J)break;const Y=o.primitiveName;let E=null;w&&!d.colorLocked&&(E=this._createOverrideFunction(Y,"FillColor",R,U));let T=null;w||d.colorLocked||(T=this._createOverrideFunction(Y,"StrokeColor",H,U));const $=this._createOverrideFunction(Y,"StrokeWidth",J);let j=!1,G="";for(const e of this._primitiveOverrides)n.includes(e.primitiveName)&&(null!=e.value?G+=`-${e.primitiveName}-${e.propertyName}-${JSON.stringify(e.value)}`:e.valueExpressionInfo&&(j=!0));(null!=t&&"function"==typeof t||null!=i&&"function"==typeof i)&&(j=!0),(L(f)||L(h)||L(u)||L(p))&&(j=!0);const D=JSON.stringify({...e,markerGraphics:null}),W=a(JSON.stringify(x)+A).toString(),V=a(JSON.stringify(o)+JSON.stringify(d)+D+G).toString();this._cimLayers.push({type:"marker",templateHash:V,materialHash:j?()=>W:W,cim:x,materialOverrides:null,colorLocked:!!d.colorLocked||!!y,effects:t,scaleSymbolsProportionally:!!e.scaleSymbolsProportionally,alignment:s,anchorPoint:{x:F,y:I},isAbsoluteAnchorPoint:_,size:f,rotation:h,offsetX:u,offsetY:p,scaleX:1,frameHeight:c,rotateClockwise:!1,referenceSize:l,sizeRatio:C,color:L(E)?E:this._createOverrideFunction(b,"Color",R,U),outlineColor:L(T)?T:this._createOverrideFunction(b,"Color",H,U),outlineWidth:L($)?$:this._createOverrideFunction(b,"Width",J),markerPlacement:i,animatedSymbolProperties:r,path:A});break}case"CIMVectorMarker":d.markerPlacement?this._analyzeMultiLayerGraphicNonSDF(e,t,i,r,o,n,s,l,c,!!y||!!d.colorLocked):this._analyzeMarker(d,t,i,n,s,l,m,!1,f,h,u,p,!!y||!!e.colorLocked);break;default:this._analyzeMultiLayerGraphicNonSDF(e,t,i,r,o,n,s,l,c,!!y||!!e.colorLocked)}b&&n.pop()}}_analyzeTextGraphic(e,i,r,o,n,s,l,c,m,h,p,d,v,_){const O=[];y.findApplicableOverrides(o,this._primitiveOverrides,O);const S=o.geometry;if(!("x"in S)||!("y"in S))return;const g=o.symbol,k=C(g),X=F(g.fontStyleName),H=t(g.fontFamilyName);g.font={family:H,decoration:k,...X};let J=b(g.height,u),Y=b(g.angle),E=b(g.offsetX),T=b(g.offsetY);J=this._transformSize(J,m),Y=this._transformRotation(Y,!1,p);const $=this._transformOffsetX(E,T,p,m,d),j=this._transformOffsetY(E,T,p,m,v);E=$,T=j;const G=M(N(g));let D=M(P(g)),W=z(g)??0;W||(D=M(N(g.haloSymbol)),W=b(g.haloSize)),W=this._transformSize(W,m);let V=!1;if(g.symbol?.symbolLayers)for(const t of g.symbol.symbolLayers){null!=N(t)&&(V=!!t.colorLocked)}const B=o.primitiveName;let q=null;V||(q=this._createOverrideFunction(B,"Color",G,U));let K=null,Q=null,Z=0;if(g.callout&&"CIMBackgroundCallout"===g.callout.type){const e=g.callout;if(e.backgroundSymbol){const t=e.backgroundSymbol.symbolLayers;if(t)for(const e of t)"CIMSolidFill"===e.type?K=M(e.color):"CIMSolidStroke"===e.type&&(Q=M(e.color),Z=b(e.width,f))}}const[ee,te]=this._analyzePrimitiveOverrides(n,i,r,null),ie=JSON.stringify(e.effects)+Number(e.colorLocked||_).toString()+JSON.stringify(e.anchorPoint)+e.anchorPointUnits+JSON.stringify(e.markerPlacement)+e.size.toString(),re=a(JSON.stringify(o)+ie+te).toString();let oe=this._createOverrideFunction(o.primitiveName,"TextString",o.textString??"",I,g.textCase);if(null==oe)return;const{fontStyleName:ne}=g,ae=H+(ne?"-"+ne.toLowerCase():"-regular"),se=ae;"string"==typeof oe&&oe.includes("[")&&g.fieldMap&&(oe=w(g.fieldMap,oe,g.textCase)),this._cimLayers.push({type:"text",templateHash:re,materialHash:ee||"function"==typeof oe||/\[(.*?)\]/.test(oe)?(e,t,i)=>se+"-"+x(oe,e,t,i):se+"-"+a(oe),cim:g,materialOverrides:null,colorLocked:!!_||!!V,effects:i,alignment:s,anchorPoint:{x:0,y:0},isAbsoluteAnchorPoint:"Relative"!==e.anchorPointUnits,fontName:ae,decoration:k,weight:X.weight,style:X.style,size:J,angle:Y,offsetX:E,offsetY:T,horizontalAlignment:A(g.horizontalAlignment),verticalAlignment:R(g.verticalAlignment),text:oe,color:L(q)?q:G,outlineColor:D,outlineSize:W,backgroundColor:K,borderLineColor:Q,borderLineWidth:Z,referenceSize:l,sizeRatio:1,markerPlacement:r})}_analyzeMultiLayerGraphicNonSDF(e,t,i,r,n,s,l,c,m,f){const u=this._buildSimpleMarker(e,n),y=e.primitiveName,d=this._analyzeMaterialOverrides(y,["Rotation","OffsetX","OffsetY"]),[v,_]=this._analyzePrimitiveOverrides(s,null,null,null),[O,S,g]=p.getTextureAnchor(u,this._resourceManager),M=b(e.rotation),k=b(e.offsetX),N=b(e.offsetY),P=a(JSON.stringify(u)+_).toString(),z=d&&d.length>0||null!=t&&"function"==typeof t;this._cimLayers.push({type:"marker",templateHash:P,materialHash:z&&d?this._createMaterialHashFunction(P,d):P,cim:u,materialOverrides:d,colorLocked:!!e.colorLocked||!!f,effects:t,scaleSymbolsProportionally:!!e.scaleSymbolsProportionally,alignment:l,anchorPoint:{x:O,y:S},isAbsoluteAnchorPoint:!1,size:b(e.size,h),rotation:this._createOverrideFunction(y,"Rotation",M),offsetX:this._createOverrideFunction(y,"OffsetX",k),offsetY:this._createOverrideFunction(y,"OffsetY",N),color:{r:255,g:255,b:255,a:1},outlineColor:{r:0,g:0,b:0,a:0},outlineWidth:0,scaleX:1,frameHeight:m,rotateClockwise:!!e.rotateClockwise,referenceSize:c,sizeRatio:g/o(e.size),markerPlacement:i,animatedSymbolProperties:r,avoidSDFRasterization:!0})}_buildSimpleMarker(e,t){return{type:e.type,enable:!0,name:e.name,colorLocked:e.colorLocked,primitiveName:e.primitiveName,anchorPoint:e.anchorPoint,anchorPointUnits:e.anchorPointUnits,offsetX:0,offsetY:0,rotateClockwise:e.rotateClockwise,rotation:0,size:e.size,billboardMode3D:e.billboardMode3D,depth3D:e.depth3D,frame:e.frame,markerGraphics:[t],scaleSymbolsProportionally:e.scaleSymbolsProportionally,respectFrame:e.respectFrame,clippingPath:e.clippingPath}}_analyzeCompositeMarkerGraphic(e,t,i,r,o,n,s,l,c,m,h,u,p,y,d){const v=o.geometry,_=n[0],O=n[1],k=S(v);if(!k)return;const N="Relative"!==e.anchorPointUnits,[P,z,C]=g(k,e.frame,e.size,e.anchorPoint,N),F={type:"sdf",geom:v,asFill:!0},I=O.path,w=O.primitiveName,x=_.primitiveName,A=M(O.color),R=M(_.color),X=b(_.width,f),H=o.primitiveName;let J=null;O.colorLocked||d||(J=this._createOverrideFunction(H,"FillColor",A,U));let Y=null;_.colorLocked||d||(Y=this._createOverrideFunction(H,"StrokeColor",R,U));const E=this._createOverrideFunction(H,"StrokeWidth",X);let T=!1,$="";for(const a of this._primitiveOverrides)(a.primitiveName===w||a.primitiveName===x||s.includes(a.primitiveName))&&(null!=a.value?$+=`-${a.primitiveName}-${a.propertyName}-${JSON.stringify(a.value)}`:a.valueExpressionInfo&&(T=!0));null!=i&&"function"==typeof i&&(T=!0),(L(h)||L(u)||L(p)||L(y))&&(T=!0);const j=JSON.stringify({...e,markerGraphics:null}),G=a(JSON.stringify(F)+I).toString(),D=a(JSON.stringify(o)+JSON.stringify(O)+JSON.stringify(_)+j+$).toString();this._cimLayers.push({type:"marker",templateHash:D,materialHash:T?()=>G:G,cim:F,materialOverrides:null,colorLocked:!!d,effects:t,scaleSymbolsProportionally:!!e.scaleSymbolsProportionally,alignment:l,anchorPoint:{x:z,y:C},isAbsoluteAnchorPoint:N,size:h,rotation:u,offsetX:p,offsetY:y,scaleX:1,frameHeight:m,rotateClockwise:!1,referenceSize:c,sizeRatio:P,color:L(J)?J:this._createOverrideFunction(w,"Color",A,U),outlineColor:L(Y)?Y:this._createOverrideFunction(x,"Color",R,U),outlineWidth:L(E)?E:this._createOverrideFunction(x,"Width",X),markerPlacement:i,path:I,animatedSymbolProperties:r})}_createMaterialHashFunction(e,t){const i=this._info?.geometryType;if(i){const e=this._poMap;for(const r of t){if(r.valueExpressionInfo){const t=e[r.primitiveName]&&e[r.primitiveName][r.propertyName];t instanceof l&&(r.fn=(e,r,o)=>H(t,e,{$view:o},i,r))}}}return(i,r,o)=>{for(const e of t)e.fn&&(e.value=e.fn(i,r,o));return a(e+y.buildOverrideKey(t)).toString()}}_setPoMap(e,t,i){let r;this._poMap[e]?r=this._poMap[e]:(r={},this._poMap[e]=r),r[t]=i}_createOverrideFunction(e,t,i,r,o){if(null==e)return i;const n=this._poMap[e];if(null==n)return i;const a=n[t];if("string"==typeof a||"number"==typeof a||a instanceof Array)return r?r.call(null,a,o):a;const s=this._info?.geometryType;return null!=a&&a instanceof l&&null!=s?(e,t,n)=>{let l=H(a,e,{$view:n},s,t);return null!==l&&r&&(l=r.call(null,l,o)),null!==l?l:i}:i}_createEffectsOverrideFunction(e,t){const r=this._poMap,o=this._info?.geometryType;for(const i of t){if(i.valueExpressionInfo&&o){const e=r[i.primitiveName]&&r[i.primitiveName][i.propertyName];e instanceof l&&(i.fn=(t,i,r)=>H(e,t,{$view:r},o,i))}}return(r,o,n)=>{for(const e of t)e.fn&&(e.value=e.fn(r,o,n));const a=[];for(let s of e){const e=s?.primitiveName;if(e){let r=!1;for(const o of t)if(o.primitiveName===e){const e=W(o.propertyName);null!=o.value&&o.value!==s[e]&&(r||(s=i(s),r=!0),s[e]=o.value)}}a.push(s)}return a}}_createMarkerPlacementOverrideFunction(e){const t=[];if(y.findApplicableOverrides(e,this._primitiveOverrides,t),null==e||0===t.length)return e;const r=this._poMap,o=this._info?.geometryType;for(const i of t){if(i.valueExpressionInfo&&o){const e=r[i.primitiveName]&&r[i.primitiveName][i.propertyName];e instanceof l&&(i.fn=(t,i,r)=>H(e,t,{$view:r},o,i))}}return(r,o,n)=>{for(const e of t)e.fn&&(e.value=e.fn(r,o,n));const a=i(e),s=e.primitiveName;for(const e of t)if(e.primitiveName===s){const t=W(e.propertyName);null!=e.value&&e.value!==a[t]&&(a[t]=e.value)}return a}}_createAnimatedSymbolPropertiesOverrideFunction(e){const t=[];if(y.findApplicableOverrides(e,this._primitiveOverrides,t),null==e||0===t.length)return e;const r=this._info?.geometryType;if(r){const e=this._poMap;for(const i of t){if(i.valueExpressionInfo){const t=e[i.primitiveName]&&e[i.primitiveName][i.propertyName];t instanceof l&&(i.fn=(e,i,o)=>H(t,e,{$view:o},r,i))}}}return(r,o,n)=>{for(const e of t)e.fn&&(e.value=e.fn(r,o,n));const a=i(e),s=e.primitiveName;for(const e of t)if(e.primitiveName===s){const t=W(e.propertyName);if(null!=e.value){const i=O(e.value,e.propertyName);i!==a[t]&&(a[t]=i)}}return a}}_analyzePrimitiveOverrides(e,t,i,r){let o=!1,n="";"string"==typeof e&&(e=[e]);for(const a of this._primitiveOverrides)e?.includes(a.primitiveName)&&(null!=a.value?n+=`-${a.primitiveName}-${a.propertyName}-${JSON.stringify(a.value)}`:a.valueExpressionInfo&&(o=!0));return null!=t&&"function"==typeof t&&(o=!0),null!=i&&"function"==typeof i&&(o=!0),null!=r&&"function"==typeof r&&(o=!0),[o,n]}_analyzeMaterialOverrides(e,t){return this._primitiveOverrides.filter((i=>i.primitiveName!==e||!t.includes(i.propertyName)))}_transformSize(e,t){return L(e)||L(t)?(i,r,o)=>(L(e)?e(i,r,o):e)*(L(t)?t(i,r,o):t):e*t}_transformRotation(e,t,i){return L(e)||L(i)?(r,o,n)=>{const a=L(e)?e(r,o,n):e,s=L(i)?i(r,o,n):i;return t?s-a:s+a}:t?i-e:i+e}_transformOffsetX(e,t,i,r,o){if(!(L(e)||L(t)||L(i)||L(r)||L(o))){const n=i*Math.PI/180;if(n){const i=Math.cos(n),a=Math.sin(n);return(i*e-a*t)*r+o}return e*r+o}return(n,a,s)=>{let l=L(i)?i(n,a,s):i;const c=L(r)?r(n,a,s):r,m=L(e)?e(n,a,s):e,f=L(o)?o(n,a,s):o;if(l){l*=Math.PI/180;return(Math.cos(l)*m-Math.sin(l)*(L(t)?t(n,a,s):t))*c+f}return m*c+f}}_transformOffsetY(e,t,i,r,o){if(!(L(e)||L(t)||L(i)||L(r)||L(o))){const n=i*Math.PI/180;if(n){const i=Math.cos(n);return(Math.sin(n)*e+i*t)*r+o}return t*r+o}return(n,a,s)=>{let l=L(i)?i(n,a,s):i;const c=L(r)?r(n,a,s):r,m=L(t)?t(n,a,s):t,f=L(o)?o(n,a,s):o;if(l){l*=Math.PI/180;const t=Math.cos(l);return(Math.sin(l)*(L(e)?e(n,a,s):e)+t*m)*c+f}return m*c+f}}}function D(e){if(e&&0===e.indexOf("Level_")){const t=parseInt(e.substr(6),10);if(!isNaN(t))return t}return 0}function U(t){if(!t||0===t.length)return null;const i=new e(t).toRgba();return{r:i[0],g:i[1],b:i[2],a:i[3]}}function W(e){return e?e.charAt(0).toLowerCase()+e.substr(1):e}function V(e,t){if(!t||0===t.length)return e;const r=i(e);return y.applyOverrides(r,t),r}const B=e=>e&&2===e.length&&e[0].enable&&e[1].enable&&"CIMSolidStroke"===e[0].type&&"CIMSolidFill"===e[1].type&&!e[0].effects&&!e[1].effects;export{G as CIMAnalyzer,V as analyzeCIMResource};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../../chunks/tslib.es6.js";import"../../../../geometry.js";import t from"../../../../core/Accessor.js";import i from"../../../../core/Logger.js";import{debounce as s,isAbortError as r,eachAlways as a}from"../../../../core/promiseUtils.js";import{property as o}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/accessorSupport/ensureType.js";import"../../../../core/arrayUtils.js";import"../../../../core/has.js";import{subclass as l}from"../../../../core/accessorSupport/decorators/subclass.js";import{WatchUpdatingTracking as n}from"../../../../core/support/WatchUpdatingTracking.js";import h from"../../../../geometry/Point.js";import c from"../../../../layers/support/PixelBlock.js";import u from"../../../../layers/support/TileInfo.js";import{update as p,unregister as d,register as y,getRasterId as g}from"../../../../layers/support/rasterDatasets/RawBlockCache.js";import{getWorldWidth as m,computeProjectedScales as _}from"../../../../layers/support/rasterFunctions/rasterProjectionHelper.js";import{isShadedReliefRendererSupported as f}from"../../../../renderers/support/rasterRendererChecks.js";import"../../tiling/PagedTileQueue.js";import b from"../../tiling/TileInfoView.js";import"../../tiling/TileKey.js";import w from"../../tiling/TileQueue.js";import I from"../../tiling/TileStrategy.js";import{TILE_SIZE as P}from"../../engine/webgl/definitions.js";import{getWebGLCapabilities as R}from"../../../webgl/capabilities.js";import C from"../../../../geometry/Extent.js";const S=[0,0];let T=class extends t{constructor(){super(...arguments),this._updatingHandles=new n,this._emptyTilePixelBlock=null,this._tileStrategy=null,this._tileInfoView=null,this._fetchQueue=null,this._blockCacheRegistryUrl=null,this._blockCacheRegistryId=null,this._srcResolutions=[],this.previousLOD=null,this._needBlockCacheUpdate=!1,this._globalSymbolizerParams=null,this._symbolizerParams=null,this._abortController=null,this._isCustomTilingScheme=!1,this._rasterFunctionState="na",this._globalUpdateRequested=!1,this.attached=!1,this.timeExtent=null,this.redrawOrRefetch=s((async(e={})=>{if(!this.previousLOD||this.layerView.suspended)return;const t=this._rasterFunctionState;e.reprocess&&(await this._updatingHandles.addPromise(this.layer.updateRasterFunction()),this.updateRasterFunctionParameters());const i=this._rasterFunctionState,{type:s}=this;return e.refetch||"raster"!==s&&!!e.reprocess||"cpu"===i||"cpu"===t?this._updatingHandles.addPromise(this.doRefresh()):this._updatingHandles.addPromise(this._redrawImage(e.signal))}))}destroy(){this._updatingHandles.destroy()}get useWebGLForProcessing(){return this._get("useWebGLForProcessing")??!0}set useWebGLForProcessing(e){this._set("useWebGLForProcessing",e)}get useProgressiveUpdate(){return this._get("useProgressiveUpdate")??!0}set useProgressiveUpdate(e){if(this._tileStrategy&&this.useProgressiveUpdate!==e){this._tileStrategy.destroy(),this.container.removeAllChildren();const t=this._getCacheSize(e);this._tileStrategy=new I({cachePolicy:"purge",acquireTile:e=>this.acquireTile(e),releaseTile:e=>this.releaseTile(e),cacheSize:t,tileInfoView:this._tileInfoView}),this._set("useProgressiveUpdate",e),this.layerView.requestUpdate()}}update(e){this._fetchQueue.pause(),this._fetchQueue.state=e.state,this._tileStrategy.update(e),this._fetchQueue.resume();const{extent:t,resolution:i,scale:s}=e.state,r=this._tileInfoView.getClosestInfoForScale(s);if(this.layer.raster){if(!this.useProgressiveUpdate||this._needBlockCacheUpdate){const e=this._srcResolutions[r.level],s=t.toJSON?t:C.fromJSON(t);p(this._blockCacheRegistryUrl,this._blockCacheRegistryId,s,i,e,this.layer.raster.ioConfig.sampling)}this._needBlockCacheUpdate=!1,this.previousLOD?.level!==r.level&&(this.previousLOD=r,null==this._symbolizerParams||this.layerView.hasTilingEffects||this._updateSymbolizerParams(),this._tileStrategy.updateCacheSize(0))}}moveEnd(){!this.layerView.hasTilingEffects&&this.useProgressiveUpdate||(this._abortController&&this._abortController.abort(),this._abortController=new AbortController,0===this._fetchQueue.length&&this._redrawImage(this._abortController.signal).then((()=>{this._globalUpdateRequested=!1,this.layerView.requestUpdate()})));const e=this._getCacheSize(this.useProgressiveUpdate);this._tileStrategy.updateCacheSize(e),this.layerView.requestUpdate()}get updating(){return this._fetchQueue?.updating||this._globalUpdateRequested||!(!this._updatingHandles||!this._updatingHandles.updating)}attach(){R("2d").supportsTextureFloat||(this.useWebGLForProcessing=!1),this._initializeTileInfo(),this._tileInfoView=new b(this.layerView.tileInfo,this.layerView.fullExtent);const e=this._computeFetchConcurrency();this._fetchQueue=new w({tileInfoView:this._tileInfoView,concurrency:e,process:(e,t)=>this._fetchTile1(e,t)});const t=this._getCacheSize(this.useProgressiveUpdate);this._tileStrategy=new I({cachePolicy:"purge",acquireTile:e=>this.acquireTile(e),releaseTile:e=>this.releaseTile(e),cacheSize:t,tileInfoView:this._tileInfoView}),this._updateBlockCacheRegistry()}detach(){this._tileStrategy.destroy(),this._fetchQueue.clear(),this.container.removeAllChildren(),this._fetchQueue=this._tileStrategy=this._tileInfoView=null,d(this._blockCacheRegistryUrl,this._blockCacheRegistryId),this._blockCacheRegistryUrl=this._blockCacheRegistryId=null}acquireTile(e){const t=this.container.createTile(e);return this._enqueueTileFetch(t),this.layerView.requestUpdate(),this._needBlockCacheUpdate=!0,this._globalUpdateRequested=this.layerView.hasTilingEffects||!this.useProgressiveUpdate,t}releaseTile(e){this._fetchQueue.abort(e.key.id),this.container.removeChild(e),e.once("detach",(()=>{e.destroy(),this.layerView.requestUpdate()})),this.layerView.requestUpdate()}createEmptyTilePixelBlock(e=null){const t=null==e||e.join(",")===this._tileInfoView.tileInfo.size.join(",");if(t&&null!=this._emptyTilePixelBlock)return this._emptyTilePixelBlock;e=e||this._tileInfoView.tileInfo.size;const[i,s]=e,r=new c({width:i,height:s,pixels:[new Uint8Array(i*s)],mask:new Uint8Array(i*s),pixelType:"u8"});return t&&(this._emptyTilePixelBlock=r),r}_getBandIds(){if(!("rasterFunctionChain"in this.container)||!this.container.rasterFunctionChain)return this.layer.bandIds;const{bandIds:e,raster:t}=this.layer,i="rasterFunction"in t?t.rasterFunction.rawInputBandIds:null;return e?.length&&i?.length&&1!==t.rasterInfo.bandCount?e.map((e=>i[Math.min(e,i.length-1)])):e||i}updateRasterFunctionParameters(){}_fetchTile1(e,t){const i=null!=t?t.signal:null,s=this.canUseWebGLForProcessing(),{layerView:r}=this,{tileInfo:a}=r,o=!a.isWrappable&&null!=m(r.view.spatialReference),l=s&&this.layer.raster.hasUniqueSourceStorageInfo,n={allowPartialFill:!0,datumTransformation:r.datumTransformation,interpolation:s?"nearest":this.layer.interpolation,registryId:this._blockCacheRegistryId,requestRawData:l,skipRasterFunction:"raster"===this.type&&null!=this.container.rasterFunctionChain,signal:i,srcResolution:this._srcResolutions[e.level],timeExtent:r.timeExtent,tileInfo:a,disableWrapAround:o};return this.fetchTile(e,n)}_getCacheSize(e){return e?40:0}_initializeTileInfo(){const{layerView:e}=this,t=e.view.spatialReference;if(this._canUseLayerLODs()){const{origin:i,lods:s}=this.layer.tileInfo,r=s.map((({scale:e})=>e)),a=u.create({spatialReference:t,size:P,scales:r,origin:i});return e.set("tileInfo",a),void(this._srcResolutions=s.map((({resolution:e})=>({x:e,y:e}))))}const i=f(this.layer.rasterInfo),{scales:s,srcResolutions:r,isCustomTilingScheme:a}=_(this.layer.rasterInfo,t,{tileSize:P,alignGlobalDatasetWithAGOL:!0,limitToSrcResolution:i}),o=u.create({spatialReference:t,size:P,scales:s}),l=new h({x:e.fullExtent.xmin,y:e.fullExtent.ymax,spatialReference:t});(0===o.origin.x||o.origin.x>l.x)&&(o.origin=l),this._isCustomTilingScheme=a,e.set("tileInfo",o),this._srcResolutions=r??[]}_canUseLayerLODs(){const{layer:e,layerView:t}=this;if("Map"!==e.raster.tileType)return!1;const{lods:i}=e.tileInfo,s=t.view.constraints?.effectiveLODs;return s?.length===i.length&&s.every((({scale:e},t)=>Math.abs(e-i[t].scale)<.001))}_computeFetchConcurrency(){const{blockBoundary:e}=this.layer.rasterInfo.storageInfo,t=e[e.length-1];return(t.maxCol-t.minCol+1)*(t.maxRow-t.minRow+1)>64?2:10}async _enqueueTileFetch(e,t){this._updatingHandles.addPromise(this._enqueueTileFetch1(e,t))}async _enqueueTileFetch1(e,t){if(!this._fetchQueue.has(e.key.id)){try{const t=await this._fetchQueue.push(e.key),a=this._getBandIds();let o=!this.useProgressiveUpdate||this.layerView.hasTilingEffects&&!this._globalSymbolizerParams;if(this._globalUpdateRequested&&!this.layerView.moving&&0===this._fetchQueue.length){o=!1;try{await this._redrawImage(this._abortController?.signal)}catch(s){r(s)&&i.getLogger(this).error(s)}this._globalUpdateRequested=!1}!this.canUseWebGLForProcessing()&&"rasterVF"!==this.type||this.layerView.hasTilingEffects||null!=this._symbolizerParams||this._updateSymbolizerParams();const l=this._tileInfoView.getTileCoords(S,e.key),n=this._tileInfoView.getTileResolution(e.key);await this.updateTileSource(e,{source:t,symbolizerParams:this._symbolizerParams,globalSymbolizerParams:this._globalSymbolizerParams,suspended:o,bandIds:a,coords:l,resolution:n}),e.once("attach",(()=>this.layerView.requestUpdate())),this.container.addChild(e)}catch(s){r(s)||i.getLogger(this).error(s)}this.layerView.requestUpdate()}}async _redrawImage(e){if(0===this.container.children.length)return;await this.layer.updateRenderer(),this.layerView.hasTilingEffects?await this._updateGlobalSymbolizerParams(e):(this._updateSymbolizerParams(),this._globalSymbolizerParams=null);const t=this.container.children.map((async e=>this.updateTileSymbolizerParameters(e,{local:this._symbolizerParams,global:this._globalSymbolizerParams})));await a(t),this.container.requestRender()}async _updateGlobalSymbolizerParams(e){const t={srcResolution:this._srcResolutions[this.previousLOD.level],registryId:this._blockCacheRegistryId,signal:e},i=await this.layer.fetchPixels(this.layerView.view.extent,this.layerView.view.width,this.layerView.view.height,t);if(!i||!i.pixelBlock)return;const{resolution:s}=this.previousLOD,r=this._getBandIds(),a=this.layer.symbolizer.generateWebGLParameters({pixelBlock:i.pixelBlock.extractBands(r),isGCS:this.layerView.view.spatialReference.isGeographic,resolution:{x:s,y:s},bandIds:r});!this.canUseWebGLForProcessing()&&a&&"stretch"===a.type&&this.layer.renderer&&"raster-stretch"===this.layer.renderer.type&&(a.factor=a.factor.map((e=>255*e)),a.outMin=Math.round(255*a.outMin),a.outMax=Math.round(255*a.outMax)),this._globalSymbolizerParams=a}_updateSymbolizerParams(){const{resolution:e}=this.previousLOD,t=this._getBandIds();this._symbolizerParams=this.layer.symbolizer.generateWebGLParameters({pixelBlock:null,isGCS:this.layerView.view.spatialReference.isGeographic,resolution:{x:e,y:e},bandIds:t})}_updateBlockCacheRegistry(e=!1){const{layer:t,layerView:i}=this,{url:s,raster:r}=t,{multidimensionalDefinition:a}=t.normalizeRasterFetchOptions({multidimensionalDefinition:t.multidimensionalDefinition,timeExtent:i.timeExtent}),o=r.rasterInfo.multidimensionalInfo?r.getSliceIndex(a):null,l=g(s,o);if(l!==this._blockCacheRegistryUrl){if(null!=this._blockCacheRegistryUrl&&d(this._blockCacheRegistryUrl,this._blockCacheRegistryId),this._blockCacheRegistryId=y(l,r.rasterInfo),e){const{view:e}=i,t=this._tileInfoView.getClosestInfoForScale(e.scale),s=this._srcResolutions[t.level];p(l,this._blockCacheRegistryId,e.extent,e.resolution,s,r.ioConfig.sampling)}this._blockCacheRegistryUrl=l}}async doRefresh(){if(!this.attached)return;await this.layer.updateRenderer(),this.layerView.hasTilingEffects||this._updateSymbolizerParams(),this._updateBlockCacheRegistry(!0),this._fetchQueue.reset();const e=[];this._globalUpdateRequested=this.layerView.hasTilingEffects||!this.useProgressiveUpdate,this._tileStrategy.refresh((t=>e.push(this._enqueueTileFetch(t)))),await a(e)}};e([o()],T.prototype,"_fetchQueue",void 0),e([o()],T.prototype,"_globalUpdateRequested",void 0),e([o()],T.prototype,"attached",void 0),e([o()],T.prototype,"container",void 0),e([o()],T.prototype,"layer",void 0),e([o()],T.prototype,"layerView",void 0),e([o()],T.prototype,"type",void 0),e([o()],T.prototype,"useWebGLForProcessing",null),e([o()],T.prototype,"useProgressiveUpdate",null),e([o()],T.prototype,"timeExtent",void 0),e([o()],T.prototype,"updating",null),T=e([l("esri.views.2d.layers.imagery.BaseImageryTileSubView2D")],T);export{T as BaseImageryTileSubView2D};
5
+ import{_ as e}from"../../../../chunks/tslib.es6.js";import"../../../../geometry.js";import t from"../../../../core/Accessor.js";import i from"../../../../core/Logger.js";import{debounce as s,isAbortError as r,eachAlways as a}from"../../../../core/promiseUtils.js";import{property as o}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/accessorSupport/ensureType.js";import"../../../../core/arrayUtils.js";import"../../../../core/has.js";import{subclass as l}from"../../../../core/accessorSupport/decorators/subclass.js";import{WatchUpdatingTracking as n}from"../../../../core/support/WatchUpdatingTracking.js";import h from"../../../../geometry/Point.js";import c from"../../../../layers/support/PixelBlock.js";import u from"../../../../layers/support/TileInfo.js";import{update as p,unregister as d,register as y,getRasterId as g}from"../../../../layers/support/rasterDatasets/RawBlockCache.js";import{getWorldWidth as m,computeProjectedScales as _}from"../../../../layers/support/rasterFunctions/rasterProjectionHelper.js";import{isShadedReliefRendererSupported as f}from"../../../../renderers/support/rasterRendererChecks.js";import"../../tiling/PagedTileQueue.js";import b from"../../tiling/TileInfoView.js";import"../../tiling/TileKey.js";import w from"../../tiling/TileQueue.js";import I from"../../tiling/TileStrategy.js";import{TILE_SIZE as P}from"../../engine/webgl/definitions.js";import{getWebGLCapabilities as C}from"../../../webgl/capabilities.js";import R from"../../../../geometry/Extent.js";const S=[0,0];let T=class extends t{constructor(){super(...arguments),this._updatingHandles=new n,this._emptyTilePixelBlock=null,this._tileStrategy=null,this._tileInfoView=null,this._fetchQueue=null,this._blockCacheRegistryUrl=null,this._blockCacheRegistryId=null,this._srcResolutions=[],this.previousLOD=null,this._needBlockCacheUpdate=!1,this._globalSymbolizerParams=null,this._symbolizerParams=null,this._abortController=null,this._isCustomTilingScheme=!1,this._maxIndexedColormapSize=0,this._rasterFunctionState="na",this._globalUpdateRequested=!1,this.attached=!1,this.timeExtent=null,this.redrawOrRefetch=s((async(e={})=>{if(!this.previousLOD||this.layerView.suspended)return;const t=this._rasterFunctionState;e.reprocess&&(await this._updatingHandles.addPromise(this.layer.updateRasterFunction()),this.updateRasterFunctionParameters());const i=this._rasterFunctionState,{type:s}=this;return e.refetch||"raster"!==s&&!!e.reprocess||"cpu"===i||"cpu"===t?this._updatingHandles.addPromise(this.doRefresh()):this._updatingHandles.addPromise(this._redrawImage(e.signal))}))}destroy(){this._updatingHandles.destroy()}get useWebGLForProcessing(){return this._get("useWebGLForProcessing")??!0}set useWebGLForProcessing(e){this._set("useWebGLForProcessing",e)}get useProgressiveUpdate(){return this._get("useProgressiveUpdate")??!0}set useProgressiveUpdate(e){if(this._tileStrategy&&this.useProgressiveUpdate!==e){this._tileStrategy.destroy(),this.container.removeAllChildren();const t=this._getCacheSize(e);this._tileStrategy=new I({cachePolicy:"purge",acquireTile:e=>this.acquireTile(e),releaseTile:e=>this.releaseTile(e),cacheSize:t,tileInfoView:this._tileInfoView}),this._set("useProgressiveUpdate",e),this.layerView.requestUpdate()}}update(e){this._fetchQueue.pause(),this._fetchQueue.state=e.state,this._tileStrategy.update(e),this._fetchQueue.resume();const{extent:t,resolution:i,scale:s}=e.state,r=this._tileInfoView.getClosestInfoForScale(s);if(this.layer.raster){if(!this.useProgressiveUpdate||this._needBlockCacheUpdate){const e=this._srcResolutions[r.level],s=t.toJSON?t:R.fromJSON(t);p(this._blockCacheRegistryUrl,this._blockCacheRegistryId,s,i,e,this.layer.raster.ioConfig.sampling)}this._needBlockCacheUpdate=!1,this.previousLOD?.level!==r.level&&(this.previousLOD=r,null==this._symbolizerParams||this.layerView.hasTilingEffects||this._updateSymbolizerParams(),this._tileStrategy.updateCacheSize(0))}}moveEnd(){!this.layerView.hasTilingEffects&&this.useProgressiveUpdate||(this._abortController&&this._abortController.abort(),this._abortController=new AbortController,0===this._fetchQueue.length&&this._redrawImage(this._abortController.signal).then((()=>{this._globalUpdateRequested=!1,this.layerView.requestUpdate()})));const e=this._getCacheSize(this.useProgressiveUpdate);this._tileStrategy.updateCacheSize(e),this.layerView.requestUpdate()}get updating(){return this._fetchQueue?.updating||this._globalUpdateRequested||!(!this._updatingHandles||!this._updatingHandles.updating)}attach(){const e=C("2d");this._maxIndexedColormapSize=4*(e.maxTextureSize||4096),e.supportsTextureFloat||(this.useWebGLForProcessing=!1),this._initializeTileInfo(),this._tileInfoView=new b(this.layerView.tileInfo,this.layerView.fullExtent);const t=this._computeFetchConcurrency();this._fetchQueue=new w({tileInfoView:this._tileInfoView,concurrency:t,process:(e,t)=>this._fetchTile1(e,t)});const i=this._getCacheSize(this.useProgressiveUpdate);this._tileStrategy=new I({cachePolicy:"purge",acquireTile:e=>this.acquireTile(e),releaseTile:e=>this.releaseTile(e),cacheSize:i,tileInfoView:this._tileInfoView}),this._updateBlockCacheRegistry()}detach(){this._tileStrategy.destroy(),this._fetchQueue.clear(),this.container.removeAllChildren(),this._fetchQueue=this._tileStrategy=this._tileInfoView=null,d(this._blockCacheRegistryUrl,this._blockCacheRegistryId),this._blockCacheRegistryUrl=this._blockCacheRegistryId=null}acquireTile(e){const t=this.container.createTile(e);return this._enqueueTileFetch(t),this.layerView.requestUpdate(),this._needBlockCacheUpdate=!0,this._globalUpdateRequested=this.layerView.hasTilingEffects||!this.useProgressiveUpdate,t}releaseTile(e){this._fetchQueue.abort(e.key.id),this.container.removeChild(e),e.once("detach",(()=>{e.destroy(),this.layerView.requestUpdate()})),this.layerView.requestUpdate()}createEmptyTilePixelBlock(e=null){const t=null==e||e.join(",")===this._tileInfoView.tileInfo.size.join(",");if(t&&null!=this._emptyTilePixelBlock)return this._emptyTilePixelBlock;e=e||this._tileInfoView.tileInfo.size;const[i,s]=e,r=new c({width:i,height:s,pixels:[new Uint8Array(i*s)],mask:new Uint8Array(i*s),pixelType:"u8"});return t&&(this._emptyTilePixelBlock=r),r}_getBandIds(){if(!("rasterFunctionChain"in this.container)||!this.container.rasterFunctionChain)return this.layer.bandIds;const{bandIds:e,raster:t}=this.layer,i="rasterFunction"in t?t.rasterFunction.rawInputBandIds:null;return e?.length&&i?.length&&1!==t.rasterInfo.bandCount?e.map((e=>i[Math.min(e,i.length-1)])):e||i}updateRasterFunctionParameters(){}_fetchTile1(e,t){const i=null!=t?t.signal:null,s=this.canUseWebGLForProcessing(),{layerView:r}=this,{tileInfo:a}=r,o=!a.isWrappable&&null!=m(r.view.spatialReference),l=s&&this.layer.raster.hasUniqueSourceStorageInfo,n={allowPartialFill:!0,datumTransformation:r.datumTransformation,interpolation:s?"nearest":this.layer.interpolation,registryId:this._blockCacheRegistryId,requestRawData:l,skipRasterFunction:"raster"===this.type&&null!=this.container.rasterFunctionChain,signal:i,srcResolution:this._srcResolutions[e.level],timeExtent:r.timeExtent,tileInfo:a,disableWrapAround:o};return this.fetchTile(e,n)}_getCacheSize(e){return e?40:0}_initializeTileInfo(){const{layerView:e}=this,t=e.view.spatialReference;if(this._canUseLayerLODs()){const{origin:i,lods:s}=this.layer.tileInfo,r=s.map((({scale:e})=>e)),a=u.create({spatialReference:t,size:P,scales:r,origin:i});return e.set("tileInfo",a),void(this._srcResolutions=s.map((({resolution:e})=>({x:e,y:e}))))}const i=f(this.layer.rasterInfo),{scales:s,srcResolutions:r,isCustomTilingScheme:a}=_(this.layer.rasterInfo,t,{tileSize:P,alignGlobalDatasetWithAGOL:!0,limitToSrcResolution:i}),o=u.create({spatialReference:t,size:P,scales:s}),l=new h({x:e.fullExtent.xmin,y:e.fullExtent.ymax,spatialReference:t});(0===o.origin.x||o.origin.x>l.x)&&(o.origin=l),this._isCustomTilingScheme=a,e.set("tileInfo",o),this._srcResolutions=r??[]}_canUseLayerLODs(){const{layer:e,layerView:t}=this;if("Map"!==e.raster.tileType)return!1;const{lods:i}=e.tileInfo,s=t.view.constraints?.effectiveLODs;return s?.length===i.length&&s.every((({scale:e},t)=>Math.abs(e-i[t].scale)<.001))}_computeFetchConcurrency(){const{blockBoundary:e}=this.layer.rasterInfo.storageInfo,t=e[e.length-1];return(t.maxCol-t.minCol+1)*(t.maxRow-t.minRow+1)>64?2:10}async _enqueueTileFetch(e,t){this._updatingHandles.addPromise(this._enqueueTileFetch1(e,t))}async _enqueueTileFetch1(e,t){if(!this._fetchQueue.has(e.key.id)){try{const t=await this._fetchQueue.push(e.key),a=this._getBandIds();let o=!this.useProgressiveUpdate||this.layerView.hasTilingEffects&&!this._globalSymbolizerParams;if(this._globalUpdateRequested&&!this.layerView.moving&&0===this._fetchQueue.length){o=!1;try{await this._redrawImage(this._abortController?.signal)}catch(s){r(s)&&i.getLogger(this).error(s)}this._globalUpdateRequested=!1}!this.canUseWebGLForProcessing()&&"rasterVF"!==this.type||this.layerView.hasTilingEffects||null!=this._symbolizerParams||this._updateSymbolizerParams();const l=this._tileInfoView.getTileCoords(S,e.key),n=this._tileInfoView.getTileResolution(e.key);await this.updateTileSource(e,{source:t,symbolizerParams:this._symbolizerParams,globalSymbolizerParams:this._globalSymbolizerParams,suspended:o,bandIds:a,coords:l,resolution:n}),e.once("attach",(()=>this.layerView.requestUpdate())),this.container.addChild(e)}catch(s){r(s)||i.getLogger(this).error(s)}this.layerView.requestUpdate()}}async _redrawImage(e){if(0===this.container.children.length)return;await this.layer.updateRenderer(),this.layerView.hasTilingEffects?await this._updateGlobalSymbolizerParams(e):(this._updateSymbolizerParams(),this._globalSymbolizerParams=null);const t=this.container.children.map((async e=>this.updateTileSymbolizerParameters(e,{local:this._symbolizerParams,global:this._globalSymbolizerParams})));await a(t),this.container.requestRender()}async _updateGlobalSymbolizerParams(e){const t={srcResolution:this._srcResolutions[this.previousLOD.level],registryId:this._blockCacheRegistryId,signal:e},i=await this.layer.fetchPixels(this.layerView.view.extent,this.layerView.view.width,this.layerView.view.height,t);if(!i||!i.pixelBlock)return;const{resolution:s}=this.previousLOD,r=this._getBandIds(),a=this.layer.symbolizer.generateWebGLParameters({pixelBlock:i.pixelBlock.extractBands(r),isGCS:this.layerView.view.spatialReference.isGeographic,resolution:{x:s,y:s},bandIds:r});!this.canUseWebGLForProcessing()&&a&&"stretch"===a.type&&this.layer.renderer&&"raster-stretch"===this.layer.renderer.type&&(a.factor=a.factor.map((e=>255*e)),a.outMin=Math.round(255*a.outMin),a.outMax=Math.round(255*a.outMax)),this._globalSymbolizerParams=a}_updateSymbolizerParams(){const{resolution:e}=this.previousLOD,t=this._getBandIds();this._symbolizerParams=this.layer.symbolizer.generateWebGLParameters({pixelBlock:null,isGCS:this.layerView.view.spatialReference.isGeographic,resolution:{x:e,y:e},bandIds:t})}_updateBlockCacheRegistry(e=!1){const{layer:t,layerView:i}=this,{url:s,raster:r}=t,{multidimensionalDefinition:a}=t.normalizeRasterFetchOptions({multidimensionalDefinition:t.multidimensionalDefinition,timeExtent:i.timeExtent}),o=r.rasterInfo.multidimensionalInfo?r.getSliceIndex(a):null,l=g(s,o);if(l!==this._blockCacheRegistryUrl){if(null!=this._blockCacheRegistryUrl&&d(this._blockCacheRegistryUrl,this._blockCacheRegistryId),this._blockCacheRegistryId=y(l,r.rasterInfo),e){const{view:e}=i,t=this._tileInfoView.getClosestInfoForScale(e.scale),s=this._srcResolutions[t.level];p(l,this._blockCacheRegistryId,e.extent,e.resolution,s,r.ioConfig.sampling)}this._blockCacheRegistryUrl=l}}async doRefresh(){if(!this.attached)return;await this.layer.updateRenderer(),this.layerView.hasTilingEffects||this._updateSymbolizerParams(),this._updateBlockCacheRegistry(!0),this._fetchQueue.reset();const e=[];this._globalUpdateRequested=this.layerView.hasTilingEffects||!this.useProgressiveUpdate,this._tileStrategy.refresh((t=>e.push(this._enqueueTileFetch(t)))),await a(e)}};e([o()],T.prototype,"_fetchQueue",void 0),e([o()],T.prototype,"_globalUpdateRequested",void 0),e([o()],T.prototype,"attached",void 0),e([o()],T.prototype,"container",void 0),e([o()],T.prototype,"layer",void 0),e([o()],T.prototype,"layerView",void 0),e([o()],T.prototype,"type",void 0),e([o()],T.prototype,"useWebGLForProcessing",null),e([o()],T.prototype,"useProgressiveUpdate",null),e([o()],T.prototype,"timeExtent",void 0),e([o()],T.prototype,"updating",null),T=e([l("esri.views.2d.layers.imagery.BaseImageryTileSubView2D")],T);export{T as BaseImageryTileSubView2D};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../../chunks/tslib.es6.js";import{property as r}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/accessorSupport/ensureType.js";import"../../../../core/arrayUtils.js";import"../../../../core/has.js";import{subclass as t}from"../../../../core/accessorSupport/decorators/subclass.js";import{RasterTileContainer as s}from"../../engine/imagery/RasterTileContainer.js";import{BaseImageryTileSubView2D as i}from"./BaseImageryTileSubView2D.js";import{canUseMajorityInterpolationOnDataSource as n}from"../support/util.js";let o=class extends i{constructor(){super(...arguments),this.type="raster"}attach(){super.attach(),this.container=new s(this._tileInfoView),this.container.isCustomTilingScheme=this._isCustomTilingScheme,this.updateRasterFunctionParameters()}detach(){super.detach(),this.container.removeAllChildren(),this.container=null}canUseWebGLForProcessing(){return this.useWebGLForProcessing&&this.layer.symbolizer.canRenderInWebGL&&!("majority"===this.layer.interpolation&&n(this.layer))}fetchTile(e,r){return this.layer.fetchTile(e.level,e.row,e.col,r)}updateRasterFunctionParameters(){const{raster:e,type:r}=this.layer,{container:t}=this;if("Function"!==e.datasetFormat||"wcs"===r)return t.rasterFunctionChain=null,t.children.forEach((e=>{const{bitmap:r}=e;r&&(r.suspended=!0,r.processed=!1,r.projected&&(r.invalidateTexture(),r.rasterTexture=null))})),void(this._rasterFunctionState="na");const s=this._rasterFunctionState,{rasterFunction:i,primaryRasters:n}=e,o=i.supportsGPU&&(!n||n.rasters.length<=1),a=o?i.flatWebGLFunctionChain:null,{renderer:l}=this.layer,c=!o||!a?.functions.length||"raster-stretch"===l?.type&&l.dynamicRangeAdjustment||!this.canUseWebGLForProcessing();t.rasterFunctionChain=c?null:a;const u=null==i?"na":t.rasterFunctionChain?"gpu":"cpu";t.children.forEach((e=>{const{bitmap:r}=e;r&&(r.suspended=s!==u,r.processed=!1,r.processedTexture=null)})),this._rasterFunctionState=u}async updateTileSource(e,r){const t=this._getBandIds(),s=this._getLayerInterpolation(),i=this.canUseWebGLForProcessing(),{source:n,globalSymbolizerParams:o,suspended:a,coords:l,resolution:c}=r,u=this.layerView.hasTilingEffects?o:r.symbolizerParams,{bitmap:p}=e;if([p.x,p.y]=l,p.resolution=c,n&&null!=n&&null!=n.pixelBlock){const e={extent:n.extent,pixelBlock:n.pixelBlock};if(p.rawPixelData=e,i)p.source=n.pixelBlock,p.isRendereredSource=!1;else{const r=await this.layer.applyRenderer(e,"stretch"===o?.type?o:void 0);p.source=r,p.isRendereredSource=!0}p.symbolizerParameters=i?u:null,i?p.transformGrid||(p.transformGrid=n.transformGrid):p.transformGrid=null}else{const e=this.createEmptyTilePixelBlock();p.source=e,p.symbolizerParameters=i?u:null,p.transformGrid=null}p.bandIds=i?t:null,p.width=this._tileInfoView.tileInfo.size[0],p.height=this._tileInfoView.tileInfo.size[1],p.interpolation=s,p.suspended=a,p.invalidateTexture()}async updateTileSymbolizerParameters(e,r){const{local:t,global:s}=r,i=this._getBandIds(),n=this._getLayerInterpolation(),o=this.canUseWebGLForProcessing(),{bitmap:a}=e,{rawPixelData:l}=a;o||null==l?(a.isRendereredSource&&null!=l&&(a.source=l.pixelBlock),a.isRendereredSource=!1):(a.source=await this.layer.applyRenderer(l,"stretch"===s?.type?s:void 0),a.isRendereredSource=!0),a.symbolizerParameters=o?this.layerView.hasTilingEffects?s:t:null,a.bandIds=o?i:null,a.interpolation=n,a.suspended=!1}_getLayerInterpolation(){const{interpolation:e,renderer:r}=this.layer;if(!r)return e;const t=r.type;return"raster-colormap"===t||"unique-value"===t||"class-breaks"===t?"nearest":"raster-stretch"===r.type&&null!=r.colorRamp?"bilinear"===e||"cubic"===e?"bilinear":"nearest":e}};e([r()],o.prototype,"container",void 0),e([r()],o.prototype,"layer",void 0),e([r()],o.prototype,"type",void 0),o=e([t("esri.views.2d.layers.imagery.ImageryTileView2D")],o);const a=o;export{a as default};
5
+ import{_ as e}from"../../../../chunks/tslib.es6.js";import{property as r}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/accessorSupport/ensureType.js";import"../../../../core/arrayUtils.js";import"../../../../core/has.js";import{subclass as t}from"../../../../core/accessorSupport/decorators/subclass.js";import{RasterTileContainer as s}from"../../engine/imagery/RasterTileContainer.js";import{BaseImageryTileSubView2D as i}from"./BaseImageryTileSubView2D.js";import{canUseMajorityInterpolationOnDataSource as o}from"../support/util.js";let n=class extends i{constructor(){super(...arguments),this.type="raster"}attach(){super.attach(),this.container=new s(this._tileInfoView),this.container.isCustomTilingScheme=this._isCustomTilingScheme,this.updateRasterFunctionParameters()}detach(){super.detach(),this.container.removeAllChildren(),this.container=null}canUseWebGLForProcessing(){const{symbolizer:e}=this.layer,r=e.lookup?.colormapLut?.indexedColormap,t=r&&r.length>this._maxIndexedColormapSize;return this.useWebGLForProcessing&&e.canRenderInWebGL&&!t&&!("majority"===this.layer.interpolation&&o(this.layer))}fetchTile(e,r){return this.layer.fetchTile(e.level,e.row,e.col,r)}updateRasterFunctionParameters(){const{raster:e,type:r}=this.layer,{container:t}=this;if("Function"!==e.datasetFormat||"wcs"===r)return t.rasterFunctionChain=null,t.children.forEach((e=>{const{bitmap:r}=e;r&&(r.suspended=!0,r.processed=!1,r.projected&&(r.invalidateTexture(),r.rasterTexture=null))})),void(this._rasterFunctionState="na");const s=this._rasterFunctionState,{rasterFunction:i,primaryRasters:o}=e,n=i.supportsGPU&&(!o||o.rasters.length<=1),a=n?i.flatWebGLFunctionChain:null,{renderer:l}=this.layer,c=!n||!a?.functions.length||"raster-stretch"===l?.type&&l.dynamicRangeAdjustment||!this.canUseWebGLForProcessing();t.rasterFunctionChain=c?null:a;const u=null==i?"na":t.rasterFunctionChain?"gpu":"cpu";t.children.forEach((e=>{const{bitmap:r}=e;r&&(r.suspended=s!==u,r.processed=!1,r.processedTexture=null)})),this._rasterFunctionState=u}async updateTileSource(e,r){const t=this._getBandIds(),s=this._getLayerInterpolation(),i=this.canUseWebGLForProcessing(),{source:o,globalSymbolizerParams:n,suspended:a,coords:l,resolution:c}=r,u=this.layerView.hasTilingEffects?n:r.symbolizerParams,{bitmap:p}=e;if([p.x,p.y]=l,p.resolution=c,o&&null!=o&&null!=o.pixelBlock){const e={extent:o.extent,pixelBlock:o.pixelBlock};if(p.rawPixelData=e,i)p.source=o.pixelBlock,p.isRendereredSource=!1;else{const r=await this.layer.applyRenderer(e,"stretch"===n?.type?n:void 0);p.source=r,p.isRendereredSource=!0}p.symbolizerParameters=i?u:null,i?p.transformGrid||(p.transformGrid=o.transformGrid):p.transformGrid=null}else{const e=this.createEmptyTilePixelBlock();p.source=e,p.symbolizerParameters=i?u:null,p.transformGrid=null}p.bandIds=i?t:null,p.width=this._tileInfoView.tileInfo.size[0],p.height=this._tileInfoView.tileInfo.size[1],p.interpolation=s,p.suspended=a,p.invalidateTexture()}async updateTileSymbolizerParameters(e,r){const{local:t,global:s}=r,i=this._getBandIds(),o=this._getLayerInterpolation(),n=this.canUseWebGLForProcessing(),{bitmap:a}=e,{rawPixelData:l}=a;n||null==l?(a.isRendereredSource&&null!=l&&(a.source=l.pixelBlock),a.isRendereredSource=!1):(a.source=await this.layer.applyRenderer(l,"stretch"===s?.type?s:void 0),a.isRendereredSource=!0),a.symbolizerParameters=n?this.layerView.hasTilingEffects?s:t:null,a.bandIds=n?i:null,a.interpolation=o,a.suspended=!1}_getLayerInterpolation(){const{interpolation:e,renderer:r}=this.layer;if(!r)return e;const t=r.type;return"raster-colormap"===t||"unique-value"===t||"class-breaks"===t?"nearest":"raster-stretch"===r.type&&null!=r.colorRamp?"bilinear"===e||"cubic"===e?"bilinear":"nearest":e}};e([r()],n.prototype,"container",void 0),e([r()],n.prototype,"layer",void 0),e([r()],n.prototype,"type",void 0),n=e([t("esri.views.2d.layers.imagery.ImageryTileView2D")],n);const a=n;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/4.28/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../../core/Handles.js";import{clamp as t,lerp as s,smoothstep as i}from"../../../core/mathUtils.js";import{watch as r}from"../../../core/reactiveUtils.js";import{s as a}from"../../../chunks/vec2.js";import{s as o,l as n,p as h}from"../../../chunks/vec3.js";import{s as d}from"../../../chunks/vec4.js";import{earth as u}from"../../../geometry/support/Ellipsoid.js";import{AtmosphereType as m}from"./AtmosphereType.js";import{atmosphereHeight as p,innerAtmosphereDepth as l,computeInnerAltitudeFade as c}from"./atmosphereUtils.js";import{ChapmanAtmospherePassParameters as _,ChapmanAtmosphereTechnique as T}from"./ChapmanAtmosphereTechnique.js";import{ChapmanAtmosphereTechniqueConfiguration as b}from"./ChapmanAtmosphereTechniqueConfiguration.js";import{Pos2Tex as f}from"../webgl-engine/lib/DefaultVertexBufferLayouts.js";import{createQuadVAO as v}from"../webgl-engine/lib/glUtil3D.js";import{applyTextureResizeModulo as R}from"../webgl-engine/lib/textureUtils.js";import{PrimitiveType as w}from"../../webgl/enums.js";class q{constructor(t,s){this._view=t,this.type=m.Realistic,this._handles=new e,this._passParameters=new _,this._rootTileElevationMin=NaN,this._lowerBoundEarthRadius=u.radius,this._fadeHaze=0,this._updateRadius(u.radius);const i=s.renderContext.rctx;this._updateRootTileElevationBounds(),this._handles.add([r((()=>this._view?.basemapTerrain?.rootTileElevationBounds),(()=>this._view?.basemapTerrain?this._updateRootTileElevationBounds():null)),r((()=>this._view?.basemapTerrain?.visibleElevationBounds),(()=>this._view?.basemapTerrain?this._updateVisibleElevationBounds():null))]);const a=new b;a.haze=!1,this._atmosphereTechnique=s.techniqueRepository.acquire(T,a),a.haze=!0,this._atmosphereHazeTechnique=s.techniqueRepository.acquire(T,a),a.reduced=!0,a.haze=!1,this._atmosphereReducedTechnique=s.techniqueRepository.acquire(T,a),a.haze=!0,this._atmosphereHazeReducedTechnique=s.techniqueRepository.acquire(T,a),this._vao=v(i,f)}destroy(){this._handles.destroy(),this._atmosphereTechnique.release(),this._atmosphereHazeTechnique.release(),this._atmosphereReducedTechnique.release(),this._atmosphereHazeReducedTechnique.release(),this._vao.dispose()}render(e,t){this._render(e,t?this._atmosphereTechnique:this._atmosphereReducedTechnique,e.offscreenRenderingHelper.depthTexture,t,!1)}renderHaze(e,t,s){this._fadeHaze=t,this._render(e,s?this._atmosphereHazeTechnique:this._atmosphereHazeReducedTechnique,e.bindParameters.linearDepth?.colorTexture,s,!0)}_render(e,t,i,r,a){if(null==i)return;const h=e.offscreenRenderingHelper;this._update(e.bindParameters.camera),this._passParameters.depthTexture=i;const d=h.backgroundColor;o(this._passParameters.backgroundColor,d[0]*d[3],d[1]*d[3],d[2]*d[3]);const m=e.rctx.bindTechnique(t,this._passParameters,e.bindParameters);if(r)h.renderDepthDetached((()=>this._renderCommon(m,e)));else{const t=e.rctx.getViewport(),r=n(e.bindParameters.camera.eye)-u.radius;let o;if(r<p){const e=Math.min(1,Math.max(0,r/p));o=a?s(.4,.5,e):s(.2,.3,e)}else{const e=Math.min(1,Math.max(0,(r-p)/(15*p)));o=a?s(.5,1,e):s(.3,.6,e)}const d=R(Math.round(o*e.bindParameters.camera.fullViewport[2])),l=R(Math.round(o*e.bindParameters.camera.fullViewport[3]));e.rctx.setViewport(0,0,d,l);const c=h.renderToCachedFBO(null,(()=>this._renderCommon(m,e)),[0,0,0,1],null,d,l);e.rctx.setViewport(t.x,t.y,t.width,t.height),h.compositeAtmosphereToMain(e.bindParameters,a,c.colorTexture,i),c.release()}}_renderCommon(e,t){null!=this._vao&&(t.rctx.bindVAO(this._vao),e.assertCompatibleVertexAttributeLocations(this._vao),t.rctx.drawArrays(w.TRIANGLE_STRIP,0,4))}_adjustRadiusForTesselation(e){return e*Math.cos(Math.PI/16/16)}_updateRootTileElevationBounds(){const e=this._view.basemapTerrain.rootTileElevationBounds.min;e!==this._rootTileElevationMin&&(this._rootTileElevationMin=e,this._lowerBoundEarthRadius=u.radius,this._updateVisibleElevationBounds())}_updateVisibleElevationBounds(){const e=this._adjustRadiusForTesselation(u.radius+this._view.basemapTerrain.visibleElevationBounds.min);e<this._lowerBoundEarthRadius&&this._updateRadius(e)}_updateRadius(e){this._lowerBoundEarthRadius=e,a(this._passParameters.radii,e,e+p),this._passParameters.innerFadeDistance=2*Math.sqrt((2*e-l)*l)}_update(e){if(!e)return;const r=h(e.eye),a=Math.sqrt(r),o=r-this._passParameters.radii[1]*this._passParameters.radii[1],n=t((a-this._passParameters.radii[0])/p,0,1);d(this._passParameters.heightParameters,a,r,o,n),this._passParameters.altitudeFade=c(a-this._lowerBoundEarthRadius),this._passParameters.hazeStrength=s(s(.6,1,i(9500,10500,a-u.radius)),1,this._fadeHaze)}static isSupported(e){return e.renderContext.rctx.capabilities.depthTexture}}export{q as ChapmanAtmosphere};
5
+ import e from"../../../core/Handles.js";import{clamp as t,lerp as s,smoothstep as i}from"../../../core/mathUtils.js";import{watch as r}from"../../../core/reactiveUtils.js";import{s as a}from"../../../chunks/vec2.js";import{s as o,l as n,p as h}from"../../../chunks/vec3.js";import{s as d}from"../../../chunks/vec4.js";import{earth as u}from"../../../geometry/support/Ellipsoid.js";import{AtmosphereType as m}from"./AtmosphereType.js";import{atmosphereHeight as p,innerAtmosphereDepth as l,computeInnerAltitudeFade as c}from"./atmosphereUtils.js";import{ChapmanAtmospherePassParameters as _,ChapmanAtmosphereTechnique as T}from"./ChapmanAtmosphereTechnique.js";import{ChapmanAtmosphereTechniqueConfiguration as b}from"./ChapmanAtmosphereTechniqueConfiguration.js";import{ColorFormat as f}from"../webgl-engine/core/FBOCache.js";import{Pos2Tex as v}from"../webgl-engine/lib/DefaultVertexBufferLayouts.js";import{createQuadVAO as R}from"../webgl-engine/lib/glUtil3D.js";import{applyTextureResizeModulo as w}from"../webgl-engine/lib/textureUtils.js";import{PrimitiveType as q}from"../../webgl/enums.js";class x{constructor(t,s){this._view=t,this.type=m.Realistic,this._handles=new e,this._passParameters=new _,this._rootTileElevationMin=NaN,this._lowerBoundEarthRadius=u.radius,this._fadeHaze=0,this._updateRadius(u.radius);const i=s.renderContext.rctx;this._updateRootTileElevationBounds(),this._handles.add([r((()=>this._view?.basemapTerrain?.rootTileElevationBounds),(()=>this._view?.basemapTerrain?this._updateRootTileElevationBounds():null)),r((()=>this._view?.basemapTerrain?.visibleElevationBounds),(()=>this._view?.basemapTerrain?this._updateVisibleElevationBounds():null))]);const a=new b;a.haze=!1,this._atmosphereTechnique=s.techniqueRepository.acquire(T,a),a.haze=!0,this._atmosphereHazeTechnique=s.techniqueRepository.acquire(T,a),a.reduced=!0,a.haze=!1,this._atmosphereReducedTechnique=s.techniqueRepository.acquire(T,a),a.haze=!0,this._atmosphereHazeReducedTechnique=s.techniqueRepository.acquire(T,a),this._vao=R(i,v)}destroy(){this._handles.destroy(),this._atmosphereTechnique.release(),this._atmosphereHazeTechnique.release(),this._atmosphereReducedTechnique.release(),this._atmosphereHazeReducedTechnique.release(),this._vao.dispose()}render(e,t){this._render(e,t?this._atmosphereTechnique:this._atmosphereReducedTechnique,e.offscreenRenderingHelper.depthTexture,t,!1)}renderHaze(e,t,s){this._fadeHaze=t,this._render(e,s?this._atmosphereHazeTechnique:this._atmosphereHazeReducedTechnique,e.bindParameters.linearDepth?.colorTexture,s,!0)}_render(e,t,i,r,a){if(null==i)return;const h=e.offscreenRenderingHelper;this._update(e.bindParameters.camera),this._passParameters.depthTexture=i;const d=h.backgroundColor;o(this._passParameters.backgroundColor,d[0]*d[3],d[1]*d[3],d[2]*d[3]);const m=e.rctx.bindTechnique(t,this._passParameters,e.bindParameters);if(r)h.renderDepthDetached((()=>this._renderCommon(m,e)));else{const t=e.rctx.getViewport(),r=n(e.bindParameters.camera.eye)-u.radius;let o;if(r<p){const e=Math.min(1,Math.max(0,r/p));o=a?s(.4,.5,e):s(.2,.3,e)}else{const e=Math.min(1,Math.max(0,(r-p)/(15*p)));o=a?s(.5,1,e):s(.3,.6,e)}const d=w(Math.round(o*e.bindParameters.camera.fullViewport[2])),l=w(Math.round(o*e.bindParameters.camera.fullViewport[3]));e.rctx.setViewport(0,0,d,l);const c=h.renderToCachedFBO(null,(()=>this._renderCommon(m,e)),[0,0,0,1],f.RGBA,null,d,l);e.rctx.setViewport(t.x,t.y,t.width,t.height),h.compositeAtmosphereToMain(e.bindParameters,a,c.colorTexture,i),c.release()}}_renderCommon(e,t){null!=this._vao&&(t.rctx.bindVAO(this._vao),e.assertCompatibleVertexAttributeLocations(this._vao),t.rctx.drawArrays(q.TRIANGLE_STRIP,0,4))}_adjustRadiusForTesselation(e){return e*Math.cos(Math.PI/16/16)}_updateRootTileElevationBounds(){const e=this._view.basemapTerrain.rootTileElevationBounds.min;e!==this._rootTileElevationMin&&(this._rootTileElevationMin=e,this._lowerBoundEarthRadius=u.radius,this._updateVisibleElevationBounds())}_updateVisibleElevationBounds(){const e=this._adjustRadiusForTesselation(u.radius+this._view.basemapTerrain.visibleElevationBounds.min);e<this._lowerBoundEarthRadius&&this._updateRadius(e)}_updateRadius(e){this._lowerBoundEarthRadius=e,a(this._passParameters.radii,e,e+p),this._passParameters.innerFadeDistance=2*Math.sqrt((2*e-l)*l)}_update(e){if(!e)return;const r=h(e.eye),a=Math.sqrt(r),o=r-this._passParameters.radii[1]*this._passParameters.radii[1],n=t((a-this._passParameters.radii[0])/p,0,1);d(this._passParameters.heightParameters,a,r,o,n),this._passParameters.altitudeFade=c(a-this._lowerBoundEarthRadius),this._passParameters.hazeStrength=s(s(.6,1,i(9500,10500,a-u.radius)),1,this._fadeHaze)}static isSupported(e){return e.renderContext.rctx.capabilities.depthTexture}}export{x 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/4.28/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../core/Accessor.js";import s from"../../../core/Handles.js";import{lerp as i}from"../../../core/mathUtils.js";import{releaseMaybe as r,disposeMaybe as a,destroyMaybe as o}from"../../../core/maybe.js";import{watch as n,initial as h}from"../../../core/reactiveUtils.js";import{property as u}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import"../../../core/arrayUtils.js";import"../../../core/has.js";import{subclass as l}from"../../../core/accessorSupport/decorators/subclass.js";import{f as d}from"../../../chunks/mat3.js";import{v as c}from"../../../chunks/mat4.js";import{c as m}from"../../../chunks/mat4f64.js";import{s as p,o as _,j as f}from"../../../chunks/vec2.js";import{a as g}from"../../../chunks/vec2f64.js";import{f as w,z as x}from"../../../chunks/vec3f32.js";import{getReferenceEllipsoid as T}from"../../../geometry/ellipsoidUtils.js";import{C as v,a as C}from"../../../chunks/Clouds.glsl.js";import{CloudsTextureChannels as y,CloudsRenderingStages as b}from"./CloudsData.js";import{cloudPresets as P}from"./CloudsPresets.js";import{CloudsTechnique as S}from"./CloudsTechnique.js";import{CloudsTechniqueConfiguration as j,RayMarchingSteps as I}from"./CloudsTechniqueConfiguration.js";import{NoiseTextureAtlas as E}from"./NoiseTextureAtlas.js";import{BindParameters as D}from"../webgl-engine/lib/BindParameters.js";import{createQuadVAO as z}from"../webgl-engine/lib/glUtil3D.js";import{TaskPriority as M,Task as U}from"../../support/Scheduler.js";import{TextureType as q,TextureWrapMode as F}from"../../webgl/enums.js";import{FramebufferObject as R}from"../../webgl/FramebufferObject.js";import{TextureDescriptor as H}from"../../webgl/TextureDescriptor.js";let B=class extends t{constructor(e){super(e),this._handles=new s,this._techniques=new Array,this._techniqueConfiguration=new j,this._bindParameters=new D(null,null,null),this._passParameters=new v,this._drawParameters=new C,this._weatherTile=g(),this._weatherTileCount=128,this._faceIndex=0,this._tileIndex=0,this.coverage=i(P.default.coverage[0],P.default.coverage[1],.5),this.density=i(P.default.density[0],P.default.density[1],.5),this.absorption=i(P.default.absorption[0],P.default.absorption[1],.5),this.cloudSize=i(P.default.cloudSize[0],P.default.cloudSize[1],.5),this.detailSize=i(P.default.detailSize[0],P.default.detailSize[1],.5),this.smoothness=i(P.default.smoothness[0],P.default.smoothness[1],.5),this.cloudHeight=i(P.default.cloudHeight[0],P.default.cloudHeight[1],.5),this.raymarchingSteps=P.default.raymarchingSteps,this._viewMatrix=m(),this._dirty=!1,this.running=!1,this._vao=z(e.context.renderContext.rctx)}_getTechnique(e){const t=1-this.context.renderContext.bindParameters.cloudsFade.readChannels,s=t===y.RG?2*e:2*e+1,i=this._techniques[s];return i||(this._techniqueConfiguration.writeTextureChannels=t,this._techniqueConfiguration.steps=e,this._techniques[s]=new S({rctx:this.context.renderContext.rctx,viewingMode:this.view.state.viewingMode},this._techniqueConfiguration),this._techniques[s])}updateWeatherTile(){const e=this.view.camera.position.latitude,t=this.view.camera.position.longitude;if(null==e||null==t)return;p(this._weatherTile,(e+90)/180,(t+180)/360);const s=Math.floor(this._weatherTileCount*Math.abs(2*this._weatherTile[0]-1));this._weatherTile[0]=Math.floor(2*this._weatherTileCount*this._weatherTile[0]),this._weatherTile[1]=Math.floor(4*(this._weatherTileCount-s)*this._weatherTile[1]);let i=0,r=0;if(null!=this.view.environment&&"virtual"!==this.view.environment.lighting.type&&null!=this.view.environment.lighting.date){const e=new Date(this.view.environment.lighting.date);e.setUTCHours(this.view.environment.lighting.date.getUTCHours()+(this.view.environment.lighting.displayUTCOffset??0)),i=31*e.getUTCMonth()+e.getUTCDate(),r=e.getUTCFullYear()}this._weatherTile[0]=(this._weatherTile[0]+i)%(2*this._weatherTileCount),this._weatherTile[1]=(this._weatherTile[1]+r%100)%(4*this._weatherTileCount),_(this._passParameters.weatherTile,this._weatherTile)||this.setDirty()}initialize(){const e=T(this.view.spatialReference);this._passParameters.cloudRadius=.5*e.radius,this.setDirty(),this.updateWeatherTile(),this._handles.add([this.view.resourceController.scheduler.registerTask(M.CLOUDS_GENERATOR,this),n((()=>[this.coverage,this.density,this.absorption,this.cloudSize,this.detailSize,this.smoothness,this.cloudHeight,this.raymarchingSteps]),(()=>this.setDirty()),h)])}destroy(){this._handles.destroy(),this._techniques.forEach((e=>r(e))),this._frameBufferCube=a(this._frameBufferCube),this._techniques.length=0,this._vao.dispose(),this._passParameters.noiseTexture=o(this._passParameters.noiseTexture)}get _tilesPerFace(){switch(this._techniqueConfiguration.steps){case I.SIXTEEN:return 1;case I.HUNDRED:return 4;case I.COUNT:case I.TWOHUNDRED:return 8}}_ensureNoiseTexture(){if(null!=this._passParameters.noiseTexture)this._passParameters.noiseTexture.updateWeatherMap(this._passParameters.weatherTile);else{const e=this.context;this._passParameters.noiseTexture=new E({context:e}),this._passParameters.noiseTexture.updateWeatherMap(this._passParameters.weatherTile)}return null!=this._passParameters.noiseTexture.textureAtlas}_ensureFrameBufferCube(e){if(null==this._frameBufferCube){const t=new H(e);t.target=q.TEXTURE_CUBE_MAP,t.wrapMode=F.CLAMP_TO_EDGE,this._frameBufferCube=new R(this.context.renderContext.rctx,t)}return this._frameBufferCube}get cubeMap(){return this._frameBufferCube}destroyFrameBufferCube(){this._frameBufferCube=a(this._frameBufferCube)}applyPreset(e,t){const s=e.median,r=e=>{const r=i(e[0],e[1],s);return t<.5?i(e[0],r,2*t):i(r,e[1],2*(t-.5))};this.coverage=r(e.coverage),this.density=r(e.density),this.absorption=r(e.absorption),this.cloudSize=r(e.cloudSize),this.detailSize=r(e.detailSize),this.smoothness=r(e.smoothness),this.cloudHeight=r(e.cloudHeight),this.raymarchingSteps=e.raymarchingSteps}setDirty(){this._dirty=this.running=!0}runTask(e){0===this._faceIndex&&0===this._tileIndex&&(this._passParameters.raymarchingSteps=this.raymarchingSteps,this.updateWeatherTile(),f(this._passParameters.weatherTile,this._weatherTile));const t=this._getTechnique(this._passParameters.raymarchingSteps);if(!t.compiled)return U.YIELD;if(!this.context.renderContext.bindParameters.cloudsFade.isCameraPositionFinal||this.context.renderContext.bindParameters.cloudsFade.isFading||!this._ensureNoiseTexture())return U.YIELD;0===this._faceIndex&&0===this._tileIndex&&(this.context.renderContext.bindParameters.cloudsFade.renderingStage=b.RENDERING,this._passParameters.absorption=this.absorption,this._passParameters.density=this.density,this._passParameters.cloudSize=this.cloudSize,this._passParameters.detailSize=this.detailSize,this._passParameters.smoothness=this.smoothness,this._passParameters.cloudHeight=this.cloudHeight,this._passParameters.coverage=this.coverage,this._dirty=!1);const s=this.context.renderContext.rctx,i=s.bindTechnique(t,this._passParameters,this._bindParameters);s.bindVAO(this._vao),i.assertCompatibleVertexAttributeLocations(this._vao);const r=s.getViewport(),a=t.configuration.cubeMapSize,o=a/this._tilesPerFace,n=this._tileIndex*o;s.setViewport(0,n,a,o);const h=this._ensureFrameBufferCube(a);s.bindFramebuffer(h);const u=N[this._faceIndex],l=A[this._faceIndex];c(this._viewMatrix,O,u,l),d(this._drawParameters.viewMatrix,this._viewMatrix);const m=q.TEXTURE_CUBE_MAP_POSITIVE_X+this._faceIndex;return h.setColorTextureTarget(m),i.bindDraw(this._drawParameters,this._bindParameters,this._passParameters),s.gl.drawArrays(s.gl.TRIANGLE_STRIP,0,4),s.gl.flush(),s.setViewport(r.x,r.y,r.width,r.height),this.requestRender(),++this._tileIndex,4===this._faceIndex&&this._tileIndex===this._tilesPerFace?(this.running=this._dirty,this._faceIndex=0,this._tileIndex=0,this.context.renderContext.bindParameters.cloudsFade.renderingStage=b.FINISHED_RENDERING):this._tileIndex===this._tilesPerFace&&(++this._faceIndex,this._tileIndex=0),e.madeProgress(),U.YIELD}};e([u({constructOnly:!0})],B.prototype,"context",void 0),e([u({constructOnly:!0})],B.prototype,"view",void 0),e([u({constructOnly:!0})],B.prototype,"requestRender",void 0),e([u()],B.prototype,"coverage",void 0),e([u()],B.prototype,"density",void 0),e([u()],B.prototype,"absorption",void 0),e([u()],B.prototype,"cloudSize",void 0),e([u()],B.prototype,"detailSize",void 0),e([u()],B.prototype,"smoothness",void 0),e([u()],B.prototype,"cloudHeight",void 0),e([u()],B.prototype,"raymarchingSteps",void 0),e([u()],B.prototype,"running",void 0),B=e([l("esri.views.3d.environment.CloudsGenerator")],B);const N=[w(1,0,0),w(-1,0,0),w(0,1,0),w(0,-1,0),w(0,0,1)],A=[w(0,1,0),w(0,1,0),w(0,0,-1),w(0,0,1),w(0,1,0)],O=x();export{B as CloudsGenerator};
5
+ import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../core/Accessor.js";import s from"../../../core/Handles.js";import{lerp as i}from"../../../core/mathUtils.js";import{releaseMaybe as r,disposeMaybe as a,destroyMaybe as o}from"../../../core/maybe.js";import{watch as n,initial as h}from"../../../core/reactiveUtils.js";import{property as u}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import"../../../core/arrayUtils.js";import"../../../core/has.js";import{subclass as l}from"../../../core/accessorSupport/decorators/subclass.js";import{f as d}from"../../../chunks/mat3.js";import{v as c}from"../../../chunks/mat4.js";import{c as m}from"../../../chunks/mat4f64.js";import{s as p,o as _,j as f}from"../../../chunks/vec2.js";import{a as g}from"../../../chunks/vec2f64.js";import{f as w,z as x}from"../../../chunks/vec3f32.js";import{getReferenceEllipsoid as T}from"../../../geometry/ellipsoidUtils.js";import{C as y,a as v}from"../../../chunks/Clouds.glsl.js";import{CloudsTextureChannels as C,CloudsRenderingStages as b}from"./CloudsData.js";import{cloudPresets as P}from"./CloudsPresets.js";import{CloudsTechnique as S}from"./CloudsTechnique.js";import{CloudsTechniqueConfiguration as j,RayMarchingSteps as I}from"./CloudsTechniqueConfiguration.js";import{NoiseTextureAtlas as E}from"./NoiseTextureAtlas.js";import{BindParameters as D}from"../webgl-engine/lib/BindParameters.js";import{createQuadVAO as M}from"../webgl-engine/lib/glUtil3D.js";import{TaskPriority as z,Task as U}from"../../support/Scheduler.js";import{TextureType as q,TextureWrapMode as F}from"../../webgl/enums.js";import{FramebufferObject as R}from"../../webgl/FramebufferObject.js";import{TextureDescriptor as B}from"../../webgl/TextureDescriptor.js";let H=class extends t{constructor(e){super(e),this._handles=new s,this._techniques=new Array,this._techniqueConfiguration=new j,this._bindParameters=new D(null,null,null),this._passParameters=new y,this._drawParameters=new v,this._weatherTile=g(),this._weatherTileCount=128,this._faceIndex=0,this._tileIndex=0,this.coverage=i(P.default.coverage[0],P.default.coverage[1],.5),this.density=i(P.default.density[0],P.default.density[1],.5),this.absorption=i(P.default.absorption[0],P.default.absorption[1],.5),this.cloudSize=i(P.default.cloudSize[0],P.default.cloudSize[1],.5),this.detailSize=i(P.default.detailSize[0],P.default.detailSize[1],.5),this.smoothness=i(P.default.smoothness[0],P.default.smoothness[1],.5),this.cloudHeight=i(P.default.cloudHeight[0],P.default.cloudHeight[1],.5),this.raymarchingSteps=P.default.raymarchingSteps,this._viewMatrix=m(),this._dirty=!1,this.running=!1,this._vao=M(e.context.renderContext.rctx)}_getTechnique(e){const t=1-this.context.renderContext.bindParameters.cloudsFade.readChannels,s=t===C.RG?2*e:2*e+1,i=this._techniques[s];return i||(this._techniqueConfiguration.writeTextureChannels=t,this._techniqueConfiguration.steps=e,this._techniques[s]=new S({rctx:this.context.renderContext.rctx,viewingMode:this.view.state.viewingMode},this._techniqueConfiguration),this._techniques[s])}updateWeatherTile(){const e=this.view.camera.position.latitude,t=this.view.camera.position.longitude;if(null==e||null==t)return;p(this._weatherTile,(e+90)/180,(t+180)/360);const s=Math.floor(this._weatherTileCount*Math.abs(2*this._weatherTile[0]-1));this._weatherTile[0]=Math.floor(2*this._weatherTileCount*this._weatherTile[0]),this._weatherTile[1]=Math.floor(4*(this._weatherTileCount-s)*this._weatherTile[1]);let i=0,r=0;if(null!=this.view.environment&&"virtual"!==this.view.environment.lighting.type&&null!=this.view.environment.lighting.date){const e=new Date(this.view.environment.lighting.date);e.setUTCHours(this.view.environment.lighting.date.getUTCHours()+(this.view.environment.lighting.displayUTCOffset??0)),i=31*e.getUTCMonth()+e.getUTCDate(),r=e.getUTCFullYear()}this._weatherTile[0]=(this._weatherTile[0]+i)%(2*this._weatherTileCount),this._weatherTile[1]=(this._weatherTile[1]+r%100)%(4*this._weatherTileCount),_(this._passParameters.weatherTile,this._weatherTile)||this.setDirty()}initialize(){const e=T(this.view.spatialReference);this._passParameters.cloudRadius=.5*e.radius,this.setDirty(),this.updateWeatherTile(),this._handles.add([this.view.resourceController.scheduler.registerTask(z.CLOUDS_GENERATOR,this),n((()=>[this.coverage,this.density,this.absorption,this.cloudSize,this.detailSize,this.smoothness,this.cloudHeight,this.raymarchingSteps]),(()=>this.setDirty()),h)])}destroy(){this._handles.destroy(),this._techniques.forEach((e=>r(e))),this._frameBufferCube=a(this._frameBufferCube),this._techniques.length=0,this._vao.dispose(),this._passParameters.noiseTexture=o(this._passParameters.noiseTexture)}get _tilesPerFace(){switch(this._techniqueConfiguration.steps){case I.SIXTEEN:return 1;case I.HUNDRED:return 4;case I.COUNT:case I.TWOHUNDRED:return 8}}get usedMemory(){return(this._frameBufferCube?.gpuMemoryUsage??0)+(this._passParameters.noiseTexture?.textureAtlas?.gpuMemoryUsage??0)}_ensureNoiseTexture(){if(null!=this._passParameters.noiseTexture)this._passParameters.noiseTexture.updateWeatherMap(this._passParameters.weatherTile);else{const e=this.context;this._passParameters.noiseTexture=new E({context:e}),this._passParameters.noiseTexture.updateWeatherMap(this._passParameters.weatherTile)}return null!=this._passParameters.noiseTexture.textureAtlas}_ensureFrameBufferCube(e){if(null==this._frameBufferCube){const t=new B(e);t.target=q.TEXTURE_CUBE_MAP,t.wrapMode=F.CLAMP_TO_EDGE,this._frameBufferCube=new R(this.context.renderContext.rctx,t)}return this._frameBufferCube}get cubeMap(){return this._frameBufferCube}destroyFrameBufferCube(){this._frameBufferCube=a(this._frameBufferCube)}applyPreset(e,t){const s=e.median,r=e=>{const r=i(e[0],e[1],s);return t<.5?i(e[0],r,2*t):i(r,e[1],2*(t-.5))};this.coverage=r(e.coverage),this.density=r(e.density),this.absorption=r(e.absorption),this.cloudSize=r(e.cloudSize),this.detailSize=r(e.detailSize),this.smoothness=r(e.smoothness),this.cloudHeight=r(e.cloudHeight),this.raymarchingSteps=e.raymarchingSteps}setDirty(){this._dirty=this.running=!0}runTask(e){0===this._faceIndex&&0===this._tileIndex&&(this._passParameters.raymarchingSteps=this.raymarchingSteps,this.updateWeatherTile(),f(this._passParameters.weatherTile,this._weatherTile));const t=this._getTechnique(this._passParameters.raymarchingSteps);if(!t.compiled)return U.YIELD;if(!this.context.renderContext.bindParameters.cloudsFade.isCameraPositionFinal||this.context.renderContext.bindParameters.cloudsFade.isFading||!this._ensureNoiseTexture())return U.YIELD;0===this._faceIndex&&0===this._tileIndex&&(this.context.renderContext.bindParameters.cloudsFade.renderingStage=b.RENDERING,this._passParameters.absorption=this.absorption,this._passParameters.density=this.density,this._passParameters.cloudSize=this.cloudSize,this._passParameters.detailSize=this.detailSize,this._passParameters.smoothness=this.smoothness,this._passParameters.cloudHeight=this.cloudHeight,this._passParameters.coverage=this.coverage,this._dirty=!1);const s=this.context.renderContext.rctx,i=s.bindTechnique(t,this._passParameters,this._bindParameters);s.bindVAO(this._vao),i.assertCompatibleVertexAttributeLocations(this._vao);const r=s.getViewport(),a=t.configuration.cubeMapSize,o=a/this._tilesPerFace,n=this._tileIndex*o;s.setViewport(0,n,a,o);const h=this._ensureFrameBufferCube(a);s.bindFramebuffer(h);const u=N[this._faceIndex],l=A[this._faceIndex];c(this._viewMatrix,O,u,l),d(this._drawParameters.viewMatrix,this._viewMatrix);const m=q.TEXTURE_CUBE_MAP_POSITIVE_X+this._faceIndex;return h.setColorTextureTarget(m),i.bindDraw(this._drawParameters,this._bindParameters,this._passParameters),s.gl.drawArrays(s.gl.TRIANGLE_STRIP,0,4),s.gl.flush(),s.setViewport(r.x,r.y,r.width,r.height),this.requestRender(),++this._tileIndex,4===this._faceIndex&&this._tileIndex===this._tilesPerFace?(this.running=this._dirty,this._faceIndex=0,this._tileIndex=0,this.context.renderContext.bindParameters.cloudsFade.renderingStage=b.FINISHED_RENDERING):this._tileIndex===this._tilesPerFace&&(++this._faceIndex,this._tileIndex=0),e.madeProgress(),U.YIELD}};e([u({constructOnly:!0})],H.prototype,"context",void 0),e([u({constructOnly:!0})],H.prototype,"view",void 0),e([u({constructOnly:!0})],H.prototype,"requestRender",void 0),e([u()],H.prototype,"coverage",void 0),e([u()],H.prototype,"density",void 0),e([u()],H.prototype,"absorption",void 0),e([u()],H.prototype,"cloudSize",void 0),e([u()],H.prototype,"detailSize",void 0),e([u()],H.prototype,"smoothness",void 0),e([u()],H.prototype,"cloudHeight",void 0),e([u()],H.prototype,"raymarchingSteps",void 0),e([u()],H.prototype,"running",void 0),H=e([l("esri.views.3d.environment.CloudsGenerator")],H);const N=[w(1,0,0),w(-1,0,0),w(0,1,0),w(0,-1,0),w(0,0,1)],A=[w(0,1,0),w(0,1,0),w(0,0,-1),w(0,0,1),w(0,1,0)],O=x();export{H as CloudsGenerator};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../core/Accessor.js";import"../../../core/has.js";import{lerp as s}from"../../../core/mathUtils.js";import{destroyMaybe as r}from"../../../core/maybe.js";import{watch as i,syncAndInitial as a,initial as o,sync as n}from"../../../core/reactiveUtils.js";import{property as h}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import"../../../core/arrayUtils.js";import{subclass as l}from"../../../core/accessorSupport/decorators/subclass.js";import{l as d,c as p,h as u}from"../../../chunks/vec3.js";import{f as m}from"../../../chunks/vec3f64.js";import{getReferenceEllipsoid as c}from"../../../geometry/ellipsoidUtils.js";import{isMoon as _,isEarth as g,isMars as f}from"../../../geometry/support/spatialReferenceUtils.js";import{ViewingMode as w}from"../../ViewingMode.js";import{AtmosphereType as y}from"./AtmosphereType.js";import{ChapmanAtmosphere as v}from"./ChapmanAtmosphere.js";import{CloudsComposition as P}from"./CloudsComposition.js";import{FadeInStages as b,FadeInOutStages as R}from"./CloudsCompositionParameters.js";import{isReadyCloudsData as x,CloudsRenderingStages as A}from"./CloudsData.js";import{CloudsGenerator as N}from"./CloudsGenerator.js";import{cloudPresets as C}from"./CloudsPresets.js";import{Fog as W,FogParameters as j}from"./Fog.js";import{LocalAtmosphere as E}from"./LocalAtmosphere.js";import F from"./MarsAtmosphere.js";import{Precipitation as O}from"./Precipitation.js";import{Stars as S}from"./Stars.js";import{weatherHeightLimit as M}from"./weather.js";import{updateWeatherFading as T,weatherFadingNeedsRender as z}from"./weatherUtils.js";import{ShaderOutput as I}from"../webgl-engine/core/shaderLibrary/ShaderOutput.js";import{RenderSlot as L}from"../webgl-engine/lib/RenderSlot.js";import{Update as U}from"../webgl-engine/lib/Update.js";var V;const k=[L.POSTPROCESSING_ENVIRONMENT_OPAQUE,L.POSTPROCESSING_ENVIRONMENT_TRANSPARENT];let q=V=class extends t{constructor(e){super(e),this._context=null,this._atmosphere=null,this._oldWeatherParameters=new G,this._newWeatherParameters=new G,this._fadedWeatherParameters=new G,this._weatherParameters=this._newWeatherParameters}initialize(){this.view._stage.addRenderPlugin(k,this)}destroy(){this.removeHandles(),this.uninitializeRenderContext(),null!=this.view?._stage&&this.view._stage.removeRenderPlugin(this),this._set("view",null)}get atmosphere(){return this._atmosphere}get _atmosphereType(){return null!=this.atmosphere?this.atmosphere.type:y.None}get canRender(){return!(null===this._atmosphere&&null===this._stars)}get needsLinearDepth(){return this._atmosphereType===y.Realistic}updateAnimation(e){return null!=this._precipitation&&this._precipitation.update(e)}get updating(){return null!=this._stars&&this._stars.updating||null!=this._clouds&&this._clouds.running}get weatherVisible(){return d(this.view.state.camera.eye)-c(this.view.spatialReference).radius<=M}get _stars(){const e=this.view,t=e.environment?.starsEnabled??!1,s=this._get("_stars");return t&&null!=this._context?null!=s?s:new S({view:e,requestRender:()=>this._setNeedsRender()}):(r(s),null)}get _precipitation(){const e=this._get("_precipitation");if(!this._precipitationEnabled||null==this._context)return r(e),null;const t=this.view,s=this._context;return null!=e&&e.context===s?e:(r(e),new O({context:s,view:t}))}get _clouds(){const e=this._get("_clouds");if(!this.weatherEnabled||null==this._context)return r(e),null;if(null!=e)return e;const t=this.view,s=this._context;return r(e),new N({context:s,view:t,requestRender:()=>this._setNeedsRender()})}get _cloudsComposition(){const e=this._get("_cloudsComposition");if(!this.weatherEnabled||null==this._context)return r(e),null;const t=this.view.state.viewingMode,s=this._context.renderContext.rctx,i=c(this.view.spatialReference).radius;return null!=e&&e.viewingMode===t&&e.planetRadius===i?e:(r(e),new P({rctx:s,viewingMode:t,planetRadius:i,requestRender:()=>this._setNeedsRender()}))}get _fog(){const e=this._get("_fog");if(!this.weatherEnabled||null==this._context)return r(e),null;if(null!=e)return e;const t=this.view,s=this._context,i=this._context.renderContext.rctx,a=this.view.state.viewingMode;return new W({context:s,view:t,rctx:i,viewingMode:a})}get weatherEnabled(){return!!this.view?.environmentManager?.weatherEnabled}get _precipitationEnabled(){return this.weatherEnabled&&("rainy"===this.view.environment.weather.type||"snowy"===this.view.environment.weather.type)}initializeRenderContext(e=null){this._context=e;const t=()=>this._setNeedsRender();this.addHandles([i((()=>({viewingMode:this.view.state.viewingMode,enabled:this.view.environment.atmosphereEnabled})),(e=>this._updateAtmosphere(e)),a),i((()=>this._stars),t),i((()=>this._precipitation),t),i((()=>this._clouds),(()=>this._updateWeather()),o),i((()=>this._fog),(()=>this._updateFogHaze()),o),i((()=>this.view.state.mode),(()=>{this._setNeedsRender()}),n),i((()=>this._weatherUpdateParameters),(()=>{this._updateWeather(),this._updateFogHaze()}),a)])}uninitializeRenderContext(){this._context=null,this._atmosphere=r(this._atmosphere),this._set("_stars",r(this._stars)),this._set("_precipitation",r(this._precipitation)),this._set("_clouds",r(this._clouds)),this._set("_cloudsComposition",r(this._cloudsComposition)),this._set("_fog",r(this._fog))}prepareRender(e){e.bindParameters.cloudsFade.data=x(this._clouds)?this._clouds:null,"local"!==this.view.viewingMode&&null!=e.bindParameters.cloudsFade.data?.cubeMap&&(T(e.bindParameters.cloudsFade,e.bindParameters.camera,this.view.state.mode,e.time,this.view.qualitySettings.fadeDuration),this._updateWeatherFading(e.bindParameters),e.bindParameters.cloudsFade.renderingStage===A.FINISHED&&null!=this._clouds&&0===this._clouds.coverage&&!1===this._clouds.running&&(this._clouds.destroyFrameBufferCube(),e.bindParameters.cloudsFade.data=null))}render(e){if(e.output===I.Color)switch(e.bindParameters.slot){case L.POSTPROCESSING_ENVIRONMENT_OPAQUE:null!=this._stars&&this._stars.render(e),null!=this.atmosphere&&(this.atmosphere.render(e,this.view?._stage?.renderer?.fullResolutionAtmosphere),null!=this._cloudsComposition&&null!=e.bindParameters.cloudsFade.data&&(this.weatherVisible&&null!=this._clouds&&this._clouds.updateWeatherTile(),this._cloudsComposition.render(e)),z(e.bindParameters.cloudsFade)&&null!=this._context&&null!=e.bindParameters.cloudsFade.data?.cubeMap&&this._context.requestRender());break;case L.POSTPROCESSING_ENVIRONMENT_TRANSPARENT:if(null!=this.atmosphere&&(this.atmosphere.renderHaze(e,this._weatherParameters.hazeAmount,this.view?._stage?.renderer?.fullResolutionAtmosphere),this._weatherParameters.fog.amount>0&&null!=this._fog&&this._fog.render(e,this._weatherParameters.fog),null!=this._precipitation)){const t=this.view.environment.weather;"rainy"!==t.type&&"snowy"!==t.type||this._precipitation.render(e,t.precipitation,t.type)}}}updateLightSources(e,t,s,r){if(null!=this._context){const i=this._context.renderContext;i.bindParameters.oldLighting.copyFrom(i.bindParameters.lighting),i.bindParameters.newLighting.noonFactor=t,i.bindParameters.newLighting.globalFactor=s,i.bindParameters.newLighting.set(e);r===U.Faded||i.bindParameters.weatherFading?i.bindParameters.fadeLighting(0):i.bindParameters.fadeLighting(1),this._context.requestRender()}}get _weatherUpdateParameters(){const e=this.weatherEnabled?this.view.environment.weather:null;return null==e?null:"rainy"===e.type||"snowy"===e.type?{type:e.type,weatherAdjustment:e.cloudCover,effect:e.precipitation}:{type:e.type,weatherAdjustment:"foggy"===e.type?e.fogStrength:e.cloudCover}}_updateWeatherFading(e){if(!e.weatherFading)return;const t=e.cloudsFade;return t.fadeIn.stage===b.FADE_IN?(e.fadeLighting(t.fadeIn.factor),void this._fadeWeather(t.fadeIn.factor)):t.fadeInOut.stage===R.FADE_IN?(e.fadeLighting(t.fadeInOut.factor),void this._fadeWeather(t.fadeInOut.factor)):t.crossFade.enabled?(e.fadeLighting(t.crossFade.factor),void this._fadeWeather(t.crossFade.factor)):(e.fadeLighting(0),void this._fadeWeather(0))}_fadeWeather(e){const{_newWeatherParameters:t,_oldWeatherParameters:s}=this;e>=1?this._weatherParameters=t:(this._fadedWeatherParameters.lerp(s,t,e),this._weatherParameters=this._fadedWeatherParameters)}_updateWeather(){const e=this._weatherUpdateParameters;null!=e&&null!=this._clouds&&(this._clouds.applyPreset(C[e.type],e.weatherAdjustment),this._setNeedsRender())}_setNeedsRender(){null!=this._context&&this._context.requestRender()}_updateFogHaze(){const e=this._weatherUpdateParameters;if(null==this._fog||null==e||null==this._context)return;const t=this._context.renderContext.bindParameters;switch(this._oldWeatherParameters.copyFrom(this._weatherParameters),e.type){case"foggy":this._newWeatherParameters.fog.strength=s(3e-5,.005,e.weatherAdjustment**3),p(this._newWeatherParameters.fog.color,D),this._newWeatherParameters.fog.amount=1,this._newWeatherParameters.hazeAmount=1,this._setNeedsRender();break;case"rainy":this._newWeatherParameters.fog.strength=s(4e-6,2e-4,(e.effect??0)**3),p(this._newWeatherParameters.fog.color,H),this._newWeatherParameters.fog.amount=1,this._newWeatherParameters.hazeAmount=0,this._setNeedsRender();break;case"snowy":this._newWeatherParameters.fog.strength=s(4e-6,2e-4,(e.effect??0)**3),p(this._newWeatherParameters.fog.color,D),this._newWeatherParameters.fog.amount=1,this._newWeatherParameters.hazeAmount=1,this._setNeedsRender();break;default:this._newWeatherParameters.fog.strength=0,this._newWeatherParameters.fog.amount=0,this._newWeatherParameters.hazeAmount=1,this._setNeedsRender()}t.weatherFading?this._fadeWeather(0):this._fadeWeather(1)}_updateAtmosphere(e){const t=this._selectAtmosphereType(e);if(t!==y.None&&this._context){if(!this._atmosphere||this._atmosphere.type!==t){this._atmosphere=r(this._atmosphere);const e=this._getAtmosphereClass(t);e&&(this._atmosphere=new e(this.view,this._context))}}else this._atmosphere=r(this._atmosphere);this._setNeedsRender()}_getAtmosphereClass(e){switch(e){case y.Realistic:return v;case y.Local:return E;case y.Mars:return F;default:case y.None:return null}}_selectAtmosphereType(e){const{enabled:t,viewingMode:s}=e;return!t||_(this.view.spatialReference)?y.None:s===w.Local?y.Local:null!=this._context&&v.isSupported(this._context)&&g(this.view.spatialReference)?y.Realistic:f(this.view.spatialReference)?y.Mars:y.None}get test(){return{atmosphere:this._atmosphere,clouds:this._clouds,selectAtmosphereType:()=>this._selectAtmosphereType({viewingMode:this.view.state.viewingMode,enabled:this.view.environment.atmosphereEnabled}),stubGetAtmosphereClass:e=>{B=V.prototype._getAtmosphereClass,V.prototype._getAtmosphereClass=e},restoreGetAtmosphereClass:()=>{V.prototype._getAtmosphereClass=B}}}};e([h({constructOnly:!0})],q.prototype,"view",void 0),e([h({readOnly:!0})],q.prototype,"atmosphere",null),e([h({readOnly:!0})],q.prototype,"_atmosphereType",null),e([h({type:Boolean,readOnly:!0})],q.prototype,"updating",null),e([h({readOnly:!0})],q.prototype,"weatherVisible",null),e([h()],q.prototype,"_context",void 0),e([h()],q.prototype,"_atmosphere",void 0),e([h({readOnly:!0})],q.prototype,"_stars",null),e([h({readOnly:!0})],q.prototype,"_precipitation",null),e([h({readOnly:!0})],q.prototype,"_clouds",null),e([h({readOnly:!0})],q.prototype,"_cloudsComposition",null),e([h({readOnly:!0})],q.prototype,"_fog",null),e([h({readOnly:!0})],q.prototype,"weatherEnabled",null),e([h({readOnly:!0})],q.prototype,"_precipitationEnabled",null),e([h({readOnly:!0})],q.prototype,"_weatherUpdateParameters",null),q=V=e([l("esri.views.3d.environment.EnvironmentRenderer")],q);class G{constructor(){this.fog=new j,this.hazeAmount=1}copyFrom(e){this.fog.amount=e.fog.amount,this.hazeAmount=e.hazeAmount,this.fog.strength=e.fog.strength,p(this.fog.color,e.fog.color)}lerp(e,t,r){this.fog.amount=s(e.fog.amount,t.fog.amount,r),this.hazeAmount=s(e.hazeAmount,t.hazeAmount,r),this.fog.strength=s(e.fog.strength,t.fog.strength,r),u(this.fog.color,e.fog.color,t.fog.color,r)}}const H=m(.5,.5,.5),D=m(1.5,1.5,1.5);let B;export{q as EnvironmentRenderer,G as WeatherParameters};
5
+ import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../core/Accessor.js";import"../../../core/has.js";import{lerp as s}from"../../../core/mathUtils.js";import{destroyMaybe as r}from"../../../core/maybe.js";import{watch as i,syncAndInitial as a,initial as o,sync as n}from"../../../core/reactiveUtils.js";import{property as h}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import"../../../core/arrayUtils.js";import{subclass as l}from"../../../core/accessorSupport/decorators/subclass.js";import{l as d,c as p,h as u}from"../../../chunks/vec3.js";import{f as m}from"../../../chunks/vec3f64.js";import{getReferenceEllipsoid as c}from"../../../geometry/ellipsoidUtils.js";import{isMoon as _,isEarth as g,isMars as f}from"../../../geometry/support/spatialReferenceUtils.js";import{ViewingMode as w}from"../../ViewingMode.js";import{AtmosphereType as y}from"./AtmosphereType.js";import{ChapmanAtmosphere as v}from"./ChapmanAtmosphere.js";import{CloudsComposition as P}from"./CloudsComposition.js";import{FadeInStages as b,FadeInOutStages as R}from"./CloudsCompositionParameters.js";import{isReadyCloudsData as x,CloudsRenderingStages as A}from"./CloudsData.js";import{CloudsGenerator as N}from"./CloudsGenerator.js";import{cloudPresets as C}from"./CloudsPresets.js";import{Fog as W,FogParameters as j}from"./Fog.js";import{LocalAtmosphere as E}from"./LocalAtmosphere.js";import F from"./MarsAtmosphere.js";import{Precipitation as O}from"./Precipitation.js";import{Stars as S}from"./Stars.js";import{weatherHeightLimit as M}from"./weather.js";import{updateWeatherFading as T,weatherFadingNeedsRender as z}from"./weatherUtils.js";import{ShaderOutput as I}from"../webgl-engine/core/shaderLibrary/ShaderOutput.js";import{RenderSlot as L}from"../webgl-engine/lib/RenderSlot.js";import{Update as U}from"../webgl-engine/lib/Update.js";var V;const k=[L.POSTPROCESSING_ENVIRONMENT_OPAQUE,L.POSTPROCESSING_ENVIRONMENT_TRANSPARENT];let q=V=class extends t{constructor(e){super(e),this._context=null,this._atmosphere=null,this._oldWeatherParameters=new G,this._newWeatherParameters=new G,this._fadedWeatherParameters=new G,this._weatherParameters=this._newWeatherParameters}initialize(){this.view._stage.addRenderPlugin(k,this)}destroy(){this.removeHandles(),this.uninitializeRenderContext(),null!=this.view?._stage&&this.view._stage.removeRenderPlugin(this),this._set("view",null)}get atmosphere(){return this._atmosphere}get _atmosphereType(){return null!=this.atmosphere?this.atmosphere.type:y.None}get canRender(){return!(null===this._atmosphere&&null===this._stars)}get needsLinearDepth(){return this._atmosphereType===y.Realistic}updateAnimation(e){return null!=this._precipitation&&this._precipitation.update(e)}get updating(){return null!=this._stars&&this._stars.updating||null!=this._clouds&&this._clouds.running}get weatherVisible(){return d(this.view.state.camera.eye)-c(this.view.spatialReference).radius<=M}get usedMemory(){return this._clouds?.usedMemory??0}get _stars(){const e=this.view,t=e.environment?.starsEnabled??!1,s=this._get("_stars");return t&&null!=this._context?null!=s?s:new S({view:e,requestRender:()=>this._setNeedsRender()}):(r(s),null)}get _precipitation(){const e=this._get("_precipitation");if(!this._precipitationEnabled||null==this._context)return r(e),null;const t=this.view,s=this._context;return null!=e&&e.context===s?e:(r(e),new O({context:s,view:t}))}get _clouds(){const e=this._get("_clouds");if(!this.weatherEnabled||null==this._context)return r(e),null;if(null!=e)return e;const t=this.view,s=this._context;return r(e),new N({context:s,view:t,requestRender:()=>this._setNeedsRender()})}get _cloudsComposition(){const e=this._get("_cloudsComposition");if(!this.weatherEnabled||null==this._context)return r(e),null;const t=this.view.state.viewingMode,s=this._context.renderContext.rctx,i=c(this.view.spatialReference).radius;return null!=e&&e.viewingMode===t&&e.planetRadius===i?e:(r(e),new P({rctx:s,viewingMode:t,planetRadius:i,requestRender:()=>this._setNeedsRender()}))}get _fog(){const e=this._get("_fog");if(!this.weatherEnabled||null==this._context)return r(e),null;if(null!=e)return e;const t=this.view,s=this._context,i=this._context.renderContext.rctx,a=this.view.state.viewingMode;return new W({context:s,view:t,rctx:i,viewingMode:a})}get weatherEnabled(){return!!this.view?.environmentManager?.weatherEnabled}get _precipitationEnabled(){return this.weatherEnabled&&("rainy"===this.view.environment.weather.type||"snowy"===this.view.environment.weather.type)}initializeRenderContext(e=null){this._context=e;const t=()=>this._setNeedsRender();this.addHandles([i((()=>({viewingMode:this.view.state.viewingMode,enabled:this.view.environment.atmosphereEnabled})),(e=>this._updateAtmosphere(e)),a),i((()=>this._stars),t),i((()=>this._precipitation),t),i((()=>this._clouds),(()=>this._updateWeather()),o),i((()=>this._fog),(()=>this._updateFogHaze()),o),i((()=>this.view.state.mode),(()=>{this._setNeedsRender()}),n),i((()=>this._weatherUpdateParameters),(()=>{this._updateWeather(),this._updateFogHaze()}),a)])}uninitializeRenderContext(){this._context=null,this._atmosphere=r(this._atmosphere),this._set("_stars",r(this._stars)),this._set("_precipitation",r(this._precipitation)),this._set("_clouds",r(this._clouds)),this._set("_cloudsComposition",r(this._cloudsComposition)),this._set("_fog",r(this._fog))}prepareRender(e){e.bindParameters.cloudsFade.data=x(this._clouds)?this._clouds:null,"local"!==this.view.viewingMode&&null!=e.bindParameters.cloudsFade.data?.cubeMap&&(T(e.bindParameters.cloudsFade,e.bindParameters.camera,this.view.state.mode,e.time,this.view.qualitySettings.fadeDuration),this._updateWeatherFading(e.bindParameters),e.bindParameters.cloudsFade.renderingStage===A.FINISHED&&null!=this._clouds&&0===this._clouds.coverage&&!1===this._clouds.running&&(this._clouds.destroyFrameBufferCube(),e.bindParameters.cloudsFade.data=null))}render(e){if(e.output===I.Color)switch(e.bindParameters.slot){case L.POSTPROCESSING_ENVIRONMENT_OPAQUE:null!=this._stars&&this._stars.render(e),null!=this.atmosphere&&(this.atmosphere.render(e,this.view?._stage?.renderer?.fullResolutionAtmosphere),null!=this._cloudsComposition&&null!=e.bindParameters.cloudsFade.data&&(this.weatherVisible&&null!=this._clouds&&this._clouds.updateWeatherTile(),this._cloudsComposition.render(e)),z(e.bindParameters.cloudsFade)&&null!=this._context&&null!=e.bindParameters.cloudsFade.data?.cubeMap&&this._context.requestRender());break;case L.POSTPROCESSING_ENVIRONMENT_TRANSPARENT:if(null!=this.atmosphere&&(this.atmosphere.renderHaze(e,this._weatherParameters.hazeAmount,this.view?._stage?.renderer?.fullResolutionAtmosphere),this._weatherParameters.fog.amount>0&&null!=this._fog&&this._fog.render(e,this._weatherParameters.fog),null!=this._precipitation)){const t=this.view.environment.weather;"rainy"!==t.type&&"snowy"!==t.type||this._precipitation.render(e,t.precipitation,t.type)}}}updateLightSources(e,t,s,r){if(null!=this._context){const i=this._context.renderContext;i.bindParameters.oldLighting.copyFrom(i.bindParameters.lighting),i.bindParameters.newLighting.noonFactor=t,i.bindParameters.newLighting.globalFactor=s,i.bindParameters.newLighting.set(e);r===U.Faded||i.bindParameters.weatherFading?i.bindParameters.fadeLighting(0):i.bindParameters.fadeLighting(1),this._context.requestRender()}}get _weatherUpdateParameters(){const e=this.weatherEnabled?this.view.environment.weather:null;return null==e?null:"rainy"===e.type||"snowy"===e.type?{type:e.type,weatherAdjustment:e.cloudCover,effect:e.precipitation}:{type:e.type,weatherAdjustment:"foggy"===e.type?e.fogStrength:e.cloudCover}}_updateWeatherFading(e){if(!e.weatherFading)return;const t=e.cloudsFade;return t.fadeIn.stage===b.FADE_IN?(e.fadeLighting(t.fadeIn.factor),void this._fadeWeather(t.fadeIn.factor)):t.fadeInOut.stage===R.FADE_IN?(e.fadeLighting(t.fadeInOut.factor),void this._fadeWeather(t.fadeInOut.factor)):t.crossFade.enabled?(e.fadeLighting(t.crossFade.factor),void this._fadeWeather(t.crossFade.factor)):(e.fadeLighting(0),void this._fadeWeather(0))}_fadeWeather(e){const{_newWeatherParameters:t,_oldWeatherParameters:s}=this;e>=1?this._weatherParameters=t:(this._fadedWeatherParameters.lerp(s,t,e),this._weatherParameters=this._fadedWeatherParameters)}_updateWeather(){const e=this._weatherUpdateParameters;null!=e&&null!=this._clouds&&(this._clouds.applyPreset(C[e.type],e.weatherAdjustment),this._setNeedsRender())}_setNeedsRender(){null!=this._context&&this._context.requestRender()}_updateFogHaze(){const e=this._weatherUpdateParameters;if(null==this._fog||null==e||null==this._context)return;const t=this._context.renderContext.bindParameters;switch(this._oldWeatherParameters.copyFrom(this._weatherParameters),e.type){case"foggy":this._newWeatherParameters.fog.strength=s(3e-5,.005,e.weatherAdjustment**3),p(this._newWeatherParameters.fog.color,D),this._newWeatherParameters.fog.amount=1,this._newWeatherParameters.hazeAmount=1,this._setNeedsRender();break;case"rainy":this._newWeatherParameters.fog.strength=s(4e-6,2e-4,(e.effect??0)**3),p(this._newWeatherParameters.fog.color,H),this._newWeatherParameters.fog.amount=1,this._newWeatherParameters.hazeAmount=0,this._setNeedsRender();break;case"snowy":this._newWeatherParameters.fog.strength=s(4e-6,2e-4,(e.effect??0)**3),p(this._newWeatherParameters.fog.color,D),this._newWeatherParameters.fog.amount=1,this._newWeatherParameters.hazeAmount=1,this._setNeedsRender();break;default:this._newWeatherParameters.fog.strength=0,this._newWeatherParameters.fog.amount=0,this._newWeatherParameters.hazeAmount=1,this._setNeedsRender()}t.weatherFading?this._fadeWeather(0):this._fadeWeather(1)}_updateAtmosphere(e){const t=this._selectAtmosphereType(e);if(t!==y.None&&this._context){if(!this._atmosphere||this._atmosphere.type!==t){this._atmosphere=r(this._atmosphere);const e=this._getAtmosphereClass(t);e&&(this._atmosphere=new e(this.view,this._context))}}else this._atmosphere=r(this._atmosphere);this._setNeedsRender()}_getAtmosphereClass(e){switch(e){case y.Realistic:return v;case y.Local:return E;case y.Mars:return F;default:case y.None:return null}}_selectAtmosphereType(e){const{enabled:t,viewingMode:s}=e;return!t||_(this.view.spatialReference)?y.None:s===w.Local?y.Local:null!=this._context&&v.isSupported(this._context)&&g(this.view.spatialReference)?y.Realistic:f(this.view.spatialReference)?y.Mars:y.None}get test(){return{atmosphere:this._atmosphere,clouds:this._clouds,selectAtmosphereType:()=>this._selectAtmosphereType({viewingMode:this.view.state.viewingMode,enabled:this.view.environment.atmosphereEnabled}),stubGetAtmosphereClass:e=>{B=V.prototype._getAtmosphereClass,V.prototype._getAtmosphereClass=e},restoreGetAtmosphereClass:()=>{V.prototype._getAtmosphereClass=B}}}};e([h({constructOnly:!0})],q.prototype,"view",void 0),e([h({readOnly:!0})],q.prototype,"atmosphere",null),e([h({readOnly:!0})],q.prototype,"_atmosphereType",null),e([h({type:Boolean,readOnly:!0})],q.prototype,"updating",null),e([h({readOnly:!0})],q.prototype,"weatherVisible",null),e([h()],q.prototype,"_context",void 0),e([h()],q.prototype,"_atmosphere",void 0),e([h({readOnly:!0})],q.prototype,"_stars",null),e([h({readOnly:!0})],q.prototype,"_precipitation",null),e([h({readOnly:!0})],q.prototype,"_clouds",null),e([h({readOnly:!0})],q.prototype,"_cloudsComposition",null),e([h({readOnly:!0})],q.prototype,"_fog",null),e([h({readOnly:!0})],q.prototype,"weatherEnabled",null),e([h({readOnly:!0})],q.prototype,"_precipitationEnabled",null),e([h({readOnly:!0})],q.prototype,"_weatherUpdateParameters",null),q=V=e([l("esri.views.3d.environment.EnvironmentRenderer")],q);class G{constructor(){this.fog=new j,this.hazeAmount=1}copyFrom(e){this.fog.amount=e.fog.amount,this.hazeAmount=e.hazeAmount,this.fog.strength=e.fog.strength,p(this.fog.color,e.fog.color)}lerp(e,t,r){this.fog.amount=s(e.fog.amount,t.fog.amount,r),this.hazeAmount=s(e.hazeAmount,t.hazeAmount,r),this.fog.strength=s(e.fog.strength,t.fog.strength,r),u(this.fog.color,e.fog.color,t.fog.color,r)}}const H=m(.5,.5,.5),D=m(1.5,1.5,1.5);let B;export{q as EnvironmentRenderer,G as WeatherParameters};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../Color.js";import r from"../../../core/Evented.js";import i from"../../../core/Handles.js";import{destroyMaybe as s}from"../../../core/maybe.js";import{after as n}from"../../../core/promiseUtils.js";import{watch as o,sync as a,syncAndInitial as h}from"../../../core/reactiveUtils.js";import{property as c}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import"../../../core/arrayUtils.js";import"../../../core/has.js";import{subclass as l}from"../../../core/accessorSupport/decorators/subclass.js";import{s as d,g as p,c as _,h as u}from"../../../chunks/vec3.js";import{c as m,f}from"../../../chunks/vec3f64.js";import{b as g,f as P}from"../../../chunks/vec4f64.js";import{canProjectToWGS84ComparableLonLat as v,projectPointToWGS84ComparableLonLat as b}from"../../../geometry/projection.js";import{isEarth as w}from"../../../geometry/support/spatialReferenceUtils.js";import{ViewingMode as C}from"../../ViewingMode.js";import{EnvironmentRenderer as y}from"./EnvironmentRenderer.js";import{positionToTimezoneInfo as U}from"../support/earthUtils.js";import{computeColorAndIntensity as S,computeVirtualLightDirection as T,computeShadowsEnabled as R,ColorAndIntensity as M}from"../support/sunUtils.js";import{Update as W}from"../webgl-engine/lib/Update.js";import{MainLight as H,AmbientLight as G,FillLight as j}from"../webgl-engine/lighting/Lightsources.js";import L from"../../../webscene/background/ColorBackground.js";let k=class extends r.EventedAccessor{constructor(){super(),this._referencePointUpdateDelay=200,this._referencePointUpdateInterval=3e3,this._referencePointUpdateDistThreshold=1e6,this._referencePosUpdateQuery=null,this._referencePosMapCoordsRequested=null,this._viewHandles=new i,this._preserveAbsoluteDateTime=!1,this._trackingEnabled=!1,this._referencePosResetPreserveAbsoluteTime=!1,this._referencePosUpdateTimer=null,this._referencePosMapCoords=null,this._mainLight=new H,this._ambientLight=new G,this._moonLight=new j,this.disableQueries=!1,this._disableWeather=!1,this._renderer=null,this._referencePosWGS84Comparable=null,this._resetReferencePosition()}destroy(){this.disconnectView(),this._viewHandles.destroy()}get _view(){return this._renderer?.view}get updating(){return!((this.disableQueries||!this._referencePosUpdateQuery&&!this._referencePosMapCoordsRequested)&&!this._renderer?.updating)}get weatherEnabled(){return this._view?.environment.atmosphereEnabled&&!this._disableWeather&&this._view?.state?.viewingMode===C.Global&&w(this._view.spatialReference)}get weatherVisible(){return this.weatherEnabled&&this._renderer?.weatherVisible}get referencePositionWGS84Comparable(){return this._referencePosWGS84Comparable}connectView(e){if(this._renderer)return;this._renderer=new y({view:e});const t=()=>this._updateRenderParameters(),r=()=>this._cameraHandler();this._viewHandles.add([o((()=>e.environment.lighting),(e=>this._updateLightingHandler(e)),a),o((()=>"virtual"!==e.environment.lighting.type?e.environment.lighting.date:null),(e=>this._lightingDateHandler(e)),a),o((()=>e.stationary),(()=>this._interactingStationaryHandler())),o((()=>e.environment.lighting.directShadowsEnabled),t,a),o((()=>e.qualitySettings.ambientOcclusion),t,a),o((()=>e.qualitySettings.reflections),t,a),o((()=>e.environment.background?.color),t,a),o((()=>e.spatialReference),(()=>this._resetReferencePosition(!0)),a),o((()=>e.environment.weather.type),(()=>this._updateLighting(null,W.Faded)),a),o((()=>this.weatherEnabled),(()=>this._updateLighting(null,W.Faded)),a),o((()=>e.viewingMode),(()=>this._resetReferencePosition(!0)),h),o((()=>"virtual"!==e.environment.lighting.type&&e.environment.lighting.cameraTrackingEnabled),(e=>this._updateCameraTracking(e)),h),o((()=>e.state.camera),r,h),o((()=>this.disableQueries),r)]),this._updateRenderParameters(),this._updateLighting(),this._cameraHandler(),this.notifyChange("updating")}disconnectView(){this._viewHandles.removeAll(),this._resetReferencePosition(),this._renderer=s(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._preserveAbsoluteDateTime=!0;const r=this._view.spatialReference;if(!v(r)){const e=this._view.camera.position;if(!this._referencePosMapCoords||!this._referencePosMapCoords.equals(e))return void this._requestReferencePositionUpdate(e)}if(this._preupdateTracking(e),null!=this._referencePosWGS84Comparable){const e=U(this._referencePosWGS84Comparable,D);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 r=t.stateManager.camera;r&&(this._cameraHandlerClientSide(r,e)||this._cameraHandlerServerSide(r))}_cameraHandlerClientSide(e,t){const r=w(this._view.spatialReference);if(r&&!v(this._view.spatialReference))return"virtual"===this._view.environment.lighting.type&&this._updateLighting(),!1;const i=e.position;return null==this._referencePosWGS84Comparable&&(this._referencePosWGS84Comparable=m()),r?b(i,this._referencePosWGS84Comparable):d(this._referencePosWGS84Comparable,i.longitude??0,i.latitude??0,i.z??0),this.notifyChange("referencePositionWGS84Comparable"),this._autoUpdateTimezone(this._referencePosWGS84Comparable,t)||this._updateLighting(t),!0}_cameraHandlerServerSide(e){const t=e.position;(!this._referencePosMapCoords||this._referencePosMapCoordsRequested||this._exceedsReferencePosDistThreshold(t))&&this._requestReferencePositionUpdate(t,!0),this._view.mapCoordsHelper&&this._referencePosWGS84Comparable&&(this._referencePosWGS84Comparable[2]=(t.z??0)*this._view.mapCoordsHelper.unitInMeters,this._referencePosChanged())}_interactingStationaryHandler(){this._view.stationary&&this._executePendingReferencePositionUpdate()}_updateLighting(e,t=W.Immediate){const r=this._view;e=e||("virtual"===r.environment.lighting.type?null:r.environment.lighting.date);const i=this._referencePosWGS84Comparable,s=null!=i?q:E,n=this.weatherVisible?r.environment.weather.type:"disabled";null!=i?S(e,i,r.state.viewingMode,n,r.state.camera,s):"virtual"===r.environment.lighting.type&&T(r.state.camera,r.state.viewingMode,s.direct.directionToLightSource);const o=this._mainLight,a=s.direct;p(o.intensity,a.color,a.intensity*Math.PI),_(o.direction,a.directionToLightSource),o.specularStrength=s.specularStrength,o.environmentStrength=s.environmentStrength;const h=this._ambientLight;p(h.intensity,s.ambient.color,s.ambient.intensity);const c=this._moonLight;u(c.intensity,A,I,s.globalFactor);const l=(1-.5*s.globalFactor)*(1-.4*s.noonFactor*(1-s.globalFactor));p(c.intensity,c.intensity,l),_(c.direction,a.directionToLightSource),this._renderer.updateLightSources([o,h,c],s.noonFactor,s.globalFactor,t),this._updateRenderParameters()}_autoUpdateTimezone(e,t=null){if("virtual"===this._view.environment.lighting.type||!this._view.environment.lighting.cameraTrackingEnabled||null==e)return!1;const r=Q;r.setTime((t||this._view.environment.lighting.date).getTime());const i=U(e,D);if(null==i)return!1;let s=this._view.environment.lighting.positionTimezoneInfo;if(s.autoUpdated){if(s.hours===i.hours&&s.minutes===i.minutes&&s.seconds===i.seconds)return!1}else s=i;const n=r.getUTCHours()-(i.hours-s.hours),o=r.getUTCMinutes()-(i.minutes-s.minutes),a=r.getUTCSeconds()-(i.seconds-s.seconds);return r.setUTCHours(n),r.setUTCMinutes(o),r.setUTCSeconds(a),!t&&this._view.environment.lighting.autoUpdate(r,i)}_updateRenderParameters(){const e=this._view._stage;if(!e)return;const r=null==this._referencePosWGS84Comparable||R(this._referencePosWGS84Comparable[2],this._view.state.viewingMode),i=this._view.environment.background,s=i instanceof L?g(t.toUnitRGBA(i.color)):P(0,0,0,1);e.renderer.setParameters({shadowMap:this._view.environment.lighting.directShadowsEnabled&&r,backgroundColor:s,environment:this._view.environment,weatherVisible:this._view.environmentManager.weatherVisible,qualitySettings:this._view.qualitySettings})}_resetReferencePosition(e=!1){this._cancelReferencePosUpdates(),this._referencePosMapCoords=null,this._referencePosMapCoordsRequested=null,this._referencePosResetPreserveAbsoluteTime=null,this._referencePosWGS84Comparable=null,this.notifyChange("updating"),e&&this._cameraHandler()}_requestReferencePositionUpdate(e,t=!1){if(!this.disableQueries&&(this._referencePosMapCoordsRequested?this._referencePosMapCoordsRequested.copy(e):this._referencePosMapCoordsRequested=e.clone(),this._referencePosResetPreserveAbsoluteTime=!!t,!this._referencePosUpdateQuery&&!this._referencePosUpdateTimer&&this._view.stationary)){const e=this._referencePosUpdateQuery=n(this._referencePointUpdateDelay).then((()=>{if(this._referencePosUpdateQuery===e){const t=()=>this._referencePosUpdateQuery!==e;return this._doReferencePositionUpdateQuery(t)}})).catch((e=>{"mapcoordshelper:missing-geometry-service"===e.name&&(this.disableQueries=!0)})).then((()=>{this._referencePosUpdateQuery===e&&(this._referencePosUpdateQuery=null,this._referencePosUpdateTimer||this._executePendingReferencePositionUpdate(),this.notifyChange("updating"))})),t=this._referencePosUpdateTimer=n(this._referencePointUpdateInterval).then((()=>{this._referencePosUpdateTimer===t&&(this._referencePosUpdateTimer=null,this._referencePosUpdateQuery||this._executePendingReferencePositionUpdate())}));this.notifyChange("updating")}}async _doReferencePositionUpdateQuery(e){this._referencePosResetPreserveAbsoluteTime&&(this._preserveAbsoluteDateTime=!1),this._referencePosMapCoords?this._referencePosMapCoords.copy(this._referencePosMapCoordsRequested):this._referencePosMapCoords=this._referencePosMapCoordsRequested.clone(),this._referencePosResetPreserveAbsoluteTime=null,this._referencePosMapCoordsRequested=null;const t=await this._view.mapCoordsHelper.toGeographic(this._referencePosMapCoords);if(!e()&&!isNaN(t[0])&&!isNaN(t[1])){const e=(this._referencePosMapCoords.z??0)*this._view.mapCoordsHelper.unitInMeters;this._referencePosWGS84Comparable?(this._referencePosWGS84Comparable[0]=t[0],this._referencePosWGS84Comparable[1]=t[1],this._referencePosWGS84Comparable[2]=e):this._referencePosWGS84Comparable=[t[0],t[1],e],this._referencePosChanged()}}_executePendingReferencePositionUpdate(){const e=this._referencePosMapCoordsRequested;e&&this._requestReferencePositionUpdate(e,this._referencePosResetPreserveAbsoluteTime)}_referencePosChanged(){this._preserveAbsoluteDateTime?this._updateLighting():this._autoUpdateTimezone(this._referencePosWGS84Comparable)||this._updateLighting(),this.notifyChange("referencePositionWGS84Comparable")}_exceedsReferencePosDistThreshold(e){if(this._referencePosMapCoords){let t=this._referencePosMapCoords.distance(e);return this._view.mapCoordsHelper&&(t*=this._view.mapCoordsHelper.unitInMeters),t>this._referencePointUpdateDistThreshold}return!0}_cancelReferencePosUpdates(){const e=!!this._referencePosUpdateQuery;return this._referencePosUpdateQuery=null,this._referencePosUpdateTimer=null,e}get test(){const e=this;return{get renderer(){return e._renderer},set referencePointUpdateInterval(t){e._referencePointUpdateInterval=t},set referencePointUpdateDistThreshold(t){e._referencePointUpdateDistThreshold=t},set referencePosUpdateTimer(t){e._referencePosUpdateTimer=t},set referencePointUpdateDelay(t){e._referencePointUpdateDelay=t},set disableWeather(t){e._disableWeather=t}}}};e([c({type:Boolean,readOnly:!0})],k.prototype,"updating",null),e([c()],k.prototype,"disableQueries",void 0),e([c()],k.prototype,"_disableWeather",void 0),e([c()],k.prototype,"weatherEnabled",null),e([c()],k.prototype,"weatherVisible",null),e([c()],k.prototype,"referencePositionWGS84Comparable",null),e([c()],k.prototype,"_renderer",void 0),e([c()],k.prototype,"_referencePosWGS84Comparable",void 0),k=e([l("esri.views.3d.environment.SceneViewEnvironmentManager")],k);const q=new M,E=new M,Q=new Date,D={hours:0,minutes:0,seconds:0},A=f(.22,.22,.33),I=f(.22,.22,.22);export{k as SceneViewEnvironmentManager};
5
+ import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../Color.js";import r from"../../../core/Evented.js";import i from"../../../core/Handles.js";import{destroyMaybe as s}from"../../../core/maybe.js";import{after as n}from"../../../core/promiseUtils.js";import{watch as o,sync as a,syncAndInitial as h}from"../../../core/reactiveUtils.js";import{property as c}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import"../../../core/arrayUtils.js";import"../../../core/has.js";import{subclass as d}from"../../../core/accessorSupport/decorators/subclass.js";import{s as l,g as p,c as _,h as u}from"../../../chunks/vec3.js";import{c as m,f}from"../../../chunks/vec3f64.js";import{b as g,f as P}from"../../../chunks/vec4f64.js";import{canProjectToWGS84ComparableLonLat as v,projectPointToWGS84ComparableLonLat as b}from"../../../geometry/projection.js";import{isEarth as w}from"../../../geometry/support/spatialReferenceUtils.js";import{ViewingMode as C}from"../../ViewingMode.js";import{EnvironmentRenderer as y}from"./EnvironmentRenderer.js";import{positionToTimezoneInfo as U}from"../support/earthUtils.js";import{computeColorAndIntensity as S,computeVirtualLightDirection as T,computeShadowsEnabled as R,ColorAndIntensity as M}from"../support/sunUtils.js";import{Update as W}from"../webgl-engine/lib/Update.js";import{MainLight as H,AmbientLight as G,FillLight as j}from"../webgl-engine/lighting/Lightsources.js";import L from"../../../webscene/background/ColorBackground.js";let k=class extends r.EventedAccessor{constructor(){super(),this._referencePointUpdateDelay=200,this._referencePointUpdateInterval=3e3,this._referencePointUpdateDistThreshold=1e6,this._referencePosUpdateQuery=null,this._referencePosMapCoordsRequested=null,this._viewHandles=new i,this._preserveAbsoluteDateTime=!1,this._trackingEnabled=!1,this._referencePosResetPreserveAbsoluteTime=!1,this._referencePosUpdateTimer=null,this._referencePosMapCoords=null,this._mainLight=new H,this._ambientLight=new G,this._moonLight=new j,this.disableQueries=!1,this._disableWeather=!1,this._renderer=null,this._referencePosWGS84Comparable=null,this._resetReferencePosition()}destroy(){this.disconnectView(),this._viewHandles.destroy()}get _view(){return this._renderer?.view}get updating(){return!((this.disableQueries||!this._referencePosUpdateQuery&&!this._referencePosMapCoordsRequested)&&!this._renderer?.updating)}get usedMemory(){return this._renderer?.usedMemory??0}get weatherEnabled(){return this._view?.environment.atmosphereEnabled&&!this._disableWeather&&this._view?.state?.viewingMode===C.Global&&w(this._view.spatialReference)}get weatherVisible(){return this.weatherEnabled&&this._renderer?.weatherVisible}get referencePositionWGS84Comparable(){return this._referencePosWGS84Comparable}connectView(e){if(this._renderer)return;this._renderer=new y({view:e});const t=()=>this._updateRenderParameters(),r=()=>this._cameraHandler();this._viewHandles.add([o((()=>e.environment.lighting),(e=>this._updateLightingHandler(e)),a),o((()=>"virtual"!==e.environment.lighting.type?e.environment.lighting.date:null),(e=>this._lightingDateHandler(e)),a),o((()=>e.stationary),(()=>this._interactingStationaryHandler())),o((()=>e.environment.lighting.directShadowsEnabled),t,a),o((()=>e.qualitySettings.ambientOcclusion),t,a),o((()=>e.qualitySettings.reflections),t,a),o((()=>e.environment.background?.color),t,a),o((()=>e.spatialReference),(()=>this._resetReferencePosition(!0)),a),o((()=>e.environment.weather.type),(()=>this._updateLighting(null,W.Faded)),a),o((()=>this.weatherEnabled),(()=>this._updateLighting(null,W.Faded)),a),o((()=>e.viewingMode),(()=>this._resetReferencePosition(!0)),h),o((()=>"virtual"!==e.environment.lighting.type&&e.environment.lighting.cameraTrackingEnabled),(e=>this._updateCameraTracking(e)),h),o((()=>e.state.camera),r,h),o((()=>this.disableQueries),r)]),this._updateRenderParameters(),this._updateLighting(),this._cameraHandler(),this.notifyChange("updating")}disconnectView(){this._viewHandles.removeAll(),this._resetReferencePosition(),this._renderer=s(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._preserveAbsoluteDateTime=!0;const r=this._view.spatialReference;if(!v(r)){const e=this._view.camera.position;if(!this._referencePosMapCoords||!this._referencePosMapCoords.equals(e))return void this._requestReferencePositionUpdate(e)}if(this._preupdateTracking(e),null!=this._referencePosWGS84Comparable){const e=U(this._referencePosWGS84Comparable,D);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 r=t.stateManager.camera;r&&(this._cameraHandlerClientSide(r,e)||this._cameraHandlerServerSide(r))}_cameraHandlerClientSide(e,t){const r=w(this._view.spatialReference);if(r&&!v(this._view.spatialReference))return"virtual"===this._view.environment.lighting.type&&this._updateLighting(),!1;const i=e.position;return null==this._referencePosWGS84Comparable&&(this._referencePosWGS84Comparable=m()),r?b(i,this._referencePosWGS84Comparable):l(this._referencePosWGS84Comparable,i.longitude??0,i.latitude??0,i.z??0),this.notifyChange("referencePositionWGS84Comparable"),this._autoUpdateTimezone(this._referencePosWGS84Comparable,t)||this._updateLighting(t),!0}_cameraHandlerServerSide(e){const t=e.position;(!this._referencePosMapCoords||this._referencePosMapCoordsRequested||this._exceedsReferencePosDistThreshold(t))&&this._requestReferencePositionUpdate(t,!0),this._view.mapCoordsHelper&&this._referencePosWGS84Comparable&&(this._referencePosWGS84Comparable[2]=(t.z??0)*this._view.mapCoordsHelper.unitInMeters,this._referencePosChanged())}_interactingStationaryHandler(){this._view.stationary&&this._executePendingReferencePositionUpdate()}_updateLighting(e,t=W.Immediate){const r=this._view;e=e||("virtual"===r.environment.lighting.type?null:r.environment.lighting.date);const i=this._referencePosWGS84Comparable,s=null!=i?q:E,n=this.weatherVisible?r.environment.weather.type:"disabled";null!=i?S(e,i,r.state.viewingMode,n,r.state.camera,s):"virtual"===r.environment.lighting.type&&T(r.state.camera,r.state.viewingMode,s.direct.directionToLightSource);const o=this._mainLight,a=s.direct;p(o.intensity,a.color,a.intensity*Math.PI),_(o.direction,a.directionToLightSource),o.specularStrength=s.specularStrength,o.environmentStrength=s.environmentStrength;const h=this._ambientLight;p(h.intensity,s.ambient.color,s.ambient.intensity);const c=this._moonLight;u(c.intensity,A,I,s.globalFactor);const d=(1-.5*s.globalFactor)*(1-.4*s.noonFactor*(1-s.globalFactor));p(c.intensity,c.intensity,d),_(c.direction,a.directionToLightSource),this._renderer.updateLightSources([o,h,c],s.noonFactor,s.globalFactor,t),this._updateRenderParameters()}_autoUpdateTimezone(e,t=null){if("virtual"===this._view.environment.lighting.type||!this._view.environment.lighting.cameraTrackingEnabled||null==e)return!1;const r=Q;r.setTime((t||this._view.environment.lighting.date).getTime());const i=U(e,D);if(null==i)return!1;let s=this._view.environment.lighting.positionTimezoneInfo;if(s.autoUpdated){if(s.hours===i.hours&&s.minutes===i.minutes&&s.seconds===i.seconds)return!1}else s=i;const n=r.getUTCHours()-(i.hours-s.hours),o=r.getUTCMinutes()-(i.minutes-s.minutes),a=r.getUTCSeconds()-(i.seconds-s.seconds);return r.setUTCHours(n),r.setUTCMinutes(o),r.setUTCSeconds(a),!t&&this._view.environment.lighting.autoUpdate(r,i)}_updateRenderParameters(){const e=this._view._stage;if(!e)return;const r=null==this._referencePosWGS84Comparable||R(this._referencePosWGS84Comparable[2],this._view.state.viewingMode),i=this._view.environment.background,s=i instanceof L?g(t.toUnitRGBA(i.color)):P(0,0,0,1);e.renderer.setParameters({shadowMap:this._view.environment.lighting.directShadowsEnabled&&r,backgroundColor:s,environment:this._view.environment,weatherVisible:this._view.environmentManager.weatherVisible,qualitySettings:this._view.qualitySettings})}_resetReferencePosition(e=!1){this._cancelReferencePosUpdates(),this._referencePosMapCoords=null,this._referencePosMapCoordsRequested=null,this._referencePosResetPreserveAbsoluteTime=null,this._referencePosWGS84Comparable=null,this.notifyChange("updating"),e&&this._cameraHandler()}_requestReferencePositionUpdate(e,t=!1){if(!this.disableQueries&&(this._referencePosMapCoordsRequested?this._referencePosMapCoordsRequested.copy(e):this._referencePosMapCoordsRequested=e.clone(),this._referencePosResetPreserveAbsoluteTime=!!t,!this._referencePosUpdateQuery&&!this._referencePosUpdateTimer&&this._view.stationary)){const e=this._referencePosUpdateQuery=n(this._referencePointUpdateDelay).then((()=>{if(this._referencePosUpdateQuery===e){const t=()=>this._referencePosUpdateQuery!==e;return this._doReferencePositionUpdateQuery(t)}})).catch((e=>{"mapcoordshelper:missing-geometry-service"===e.name&&(this.disableQueries=!0)})).then((()=>{this._referencePosUpdateQuery===e&&(this._referencePosUpdateQuery=null,this._referencePosUpdateTimer||this._executePendingReferencePositionUpdate(),this.notifyChange("updating"))})),t=this._referencePosUpdateTimer=n(this._referencePointUpdateInterval).then((()=>{this._referencePosUpdateTimer===t&&(this._referencePosUpdateTimer=null,this._referencePosUpdateQuery||this._executePendingReferencePositionUpdate())}));this.notifyChange("updating")}}async _doReferencePositionUpdateQuery(e){this._referencePosResetPreserveAbsoluteTime&&(this._preserveAbsoluteDateTime=!1),this._referencePosMapCoords?this._referencePosMapCoords.copy(this._referencePosMapCoordsRequested):this._referencePosMapCoords=this._referencePosMapCoordsRequested.clone(),this._referencePosResetPreserveAbsoluteTime=null,this._referencePosMapCoordsRequested=null;const t=await this._view.mapCoordsHelper.toGeographic(this._referencePosMapCoords);if(!e()&&!isNaN(t[0])&&!isNaN(t[1])){const e=(this._referencePosMapCoords.z??0)*this._view.mapCoordsHelper.unitInMeters;this._referencePosWGS84Comparable?(this._referencePosWGS84Comparable[0]=t[0],this._referencePosWGS84Comparable[1]=t[1],this._referencePosWGS84Comparable[2]=e):this._referencePosWGS84Comparable=[t[0],t[1],e],this._referencePosChanged()}}_executePendingReferencePositionUpdate(){const e=this._referencePosMapCoordsRequested;e&&this._requestReferencePositionUpdate(e,this._referencePosResetPreserveAbsoluteTime)}_referencePosChanged(){this._preserveAbsoluteDateTime?this._updateLighting():this._autoUpdateTimezone(this._referencePosWGS84Comparable)||this._updateLighting(),this.notifyChange("referencePositionWGS84Comparable")}_exceedsReferencePosDistThreshold(e){if(this._referencePosMapCoords){let t=this._referencePosMapCoords.distance(e);return this._view.mapCoordsHelper&&(t*=this._view.mapCoordsHelper.unitInMeters),t>this._referencePointUpdateDistThreshold}return!0}_cancelReferencePosUpdates(){const e=!!this._referencePosUpdateQuery;return this._referencePosUpdateQuery=null,this._referencePosUpdateTimer=null,e}get test(){const e=this;return{get renderer(){return e._renderer},set referencePointUpdateInterval(t){e._referencePointUpdateInterval=t},set referencePointUpdateDistThreshold(t){e._referencePointUpdateDistThreshold=t},set referencePosUpdateTimer(t){e._referencePosUpdateTimer=t},set referencePointUpdateDelay(t){e._referencePointUpdateDelay=t},set disableWeather(t){e._disableWeather=t}}}};e([c({type:Boolean,readOnly:!0})],k.prototype,"updating",null),e([c()],k.prototype,"disableQueries",void 0),e([c()],k.prototype,"_disableWeather",void 0),e([c()],k.prototype,"weatherEnabled",null),e([c()],k.prototype,"weatherVisible",null),e([c()],k.prototype,"referencePositionWGS84Comparable",null),e([c()],k.prototype,"_renderer",void 0),e([c()],k.prototype,"_referencePosWGS84Comparable",void 0),k=e([d("esri.views.3d.environment.SceneViewEnvironmentManager")],k);const q=new M,E=new M,Q=new Date,D={hours:0,minutes:0,seconds:0},A=f(.22,.22,.33),I=f(.22,.22,.22);export{k as SceneViewEnvironmentManager};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import"../../../../core/has.js";import e from"../../../../core/Error.js";import{clone as t}from"../../../../core/lang.js";import{getMetersPerVerticalUnitForSR as s}from"../../../../core/unitUtils.js";import{e as r}from"../../../../chunks/earcut.js";import{d as n}from"../../../../chunks/mat3.js";import{c as i}from"../../../../chunks/mat3f64.js";import{a as o,p as a}from"../../../../chunks/mat4.js";import{c as l}from"../../../../chunks/mat4f64.js";import{c,n as h,s as m,b as p,f as g,m as d}from"../../../../chunks/vec3.js";import{g as u,c as f}from"../../../../chunks/vec3f64.js";import{computeTranslationToOriginAndRotation as y}from"../../../../geometry/projection.js";import{create as b,empty as _,expandWithBuffer as x,intersectsClippingArea as j}from"../../../../geometry/support/aaBoundingBox.js";import{newDoubleArray as S}from"../../../../geometry/support/DoubleArray.js";import{newIndexArray as P,getZeroIndexArray as E}from"../../../../geometry/support/Indices.js";import{t as w}from"../../../../chunks/vec32.js";import{makeVertexCandidate as v,makeEdgeCandidate as C}from"../../../../layers/graphics/data/SnappingCandidate.js";import{getDriverAxisSizeValue as L}from"../../../../renderers/support/renderingInfoUtils.js";import{ViewingMode as O}from"../../../ViewingMode.js";import{needsElevationUpdates3D as I,SampleElevationInfo as M}from"./elevationAlignmentUtils.js";import{ElevationContext as A}from"./ElevationContext.js";import{Graphics3DObject3DGraphicLayer as z}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as D}from"./Graphics3DSymbolLayer.js";import{validateSymbolLayerSize as R,computeCentroid as G}from"./graphicUtils.js";import{ApplyRendererDiffResult as B}from"./interfaces.js";import{geometryAsPolygon as U}from"./polygonUtils.js";import{createMaterial as T}from"../support/edgeUtils.js";import k from"../../support/debugFlags.js";import{SamplePosition as N}from"../../support/ElevationProvider.js";import{geometryToRenderInfo as V}from"../../support/renderInfoUtils/polygon.js";import{NormalType as H}from"../../webgl-engine/core/shaderLibrary/attributes/NormalAttribute.glsl.js";import{Attribute as F}from"../../webgl-engine/lib/Attribute.js";import{CullFaceOptions as W}from"../../webgl-engine/lib/basicInterfaces.js";import{ContentObjectType as q}from"../../webgl-engine/lib/ContentObjectType.js";import{Geometry as Z}from"../../webgl-engine/lib/Geometry.js";import{isGeometryWithMapPositions as J}from"../../webgl-engine/lib/GeometryWithMapPositions.js";import{compressNormals as K}from"../../webgl-engine/lib/Normals.js";import{Object3D as Q}from"../../webgl-engine/lib/Object3D.js";import{VertexAttribute as X}from"../../webgl-engine/lib/VertexAttribute.js";import{DefaultMaterial as Y}from"../../webgl-engine/materials/DefaultMaterial.js";const $=["polygon","extent"];class ee extends D{constructor(e,t,s,r){super(e,t,s,r),this.ensureDrapedStatus(!1)}async doLoad(){if(!this._drivenProperties.size){const t=R(this._getSymbolSize());if(t)throw new e("graphics3dextrudesymbollayer:invalid-size",t)}const t=this.symbolLayer?.material?.color,s=this._getCombinedOpacityAndColor(t),r=u(s),n=s[3],i=n<1||this.needsDrivenTransparentPass,o={usePBR:this._context.physicalBasedRenderingEnabled,isSchematic:!0,diffuse:r,ambient:r,opacity:n,transparent:i,cullFace:i?W.None:W.Back,hasVertexColors:!0,hasSlicePlane:this._context.slicePlaneEnabled,castShadows:this.symbolLayer.castShadows,offsetTransparentBackfaces:!0,normalType:H.Compressed};this._material=new Y(o),this._bottomMaterial=new Y({...o,cullFace:W.Back}),this._context.stage.add(this._material),this._context.stage.add(this._bottomMaterial)}destroy(){super.destroy(),this._material&&(this._context.stage.remove(this._material),this._context.stage.remove(this._bottomMaterial))}createGraphics3DGraphic(e){const t=e.graphic;if(!this._validateGeometry(t.geometry,$,this.symbolLayer.type))return null;const s=this._getVertexOpacityAndColor(e.renderingInfo,255),r=this.setGraphicElevationContext(t,new A);return this._createAs3DShape(t,e.renderingInfo,s,r,t.uid)}layerOpacityChanged(e,t){const s=this.symbolLayer?.material?.color,r=this._getCombinedOpacity(s),n=r<1||this.needsDrivenTransparentPass;this._material.setParameters({opacity:r,transparent:n}),this._bottomMaterial.setParameters({opacity:r,transparent:n});const i=this._getLayerOpacity();e.forEach((e=>{const s=t(e);null!=s&&s.layerOpacityChanged(i,this._context.isAsync)}))}layerElevationInfoChanged(e,t){return this.updateGraphics3DGraphicElevationInfo(e,t,I)}slicePlaneEnabledChanged(e,t){return this._material.setParameters({hasSlicePlane:this._context.slicePlaneEnabled}),this._bottomMaterial.setParameters({hasSlicePlane:this._context.slicePlaneEnabled}),e.forEach((e=>{const s=t(e);null!=s&&s.slicePlaneEnabledChanged(this._context.slicePlaneEnabled,this._context.isAsync)})),!0}physicalBasedRenderingChanged(){return this._material.setParameters({usePBR:this._context.physicalBasedRenderingEnabled,isSchematic:!0}),this._bottomMaterial.setParameters({usePBR:this._context.physicalBasedRenderingEnabled,isSchematic:!0}),!0}_getExtrusionSize(e){let t;return t=e.size&&this._drivenProperties.size?L(e.size,2)??0:this._getSymbolSize(),t/=this._context.renderCoordsHelper.unitInMeters,t}applyRendererDiff(e,t){return this._drivenPropertiesChanged(t)?B.RecreateSymbol:B.RecreateGraphics}async queryForSnapping(e,r,n,i){const o=this._getExtrusionSize(n)*this._context.renderCoordsHelper.unitInMeters/s(r),{objectId:a,target:l}=e,c=t(l);switch(c.z=(c.z??0)+o,e.type){case"edge":{const{start:s,end:r}=e,n=t(s),i=t(r);return n.z=(n.z??0)+o,i.z=(i.z??0)+o,[C(a,c,1/0,n,i)]}case"vertex":return[v(a,c,1/0),C(a,l,1/0,l,c)];default:return[]}}_getSymbolSize(){return this.symbolLayer.size??1}_createAs3DShape(e,t,s,a,c){const h=U(e.geometry);if(null==h)return null;if(0===h.rings.length||!h.rings.some((e=>e.length>0)))return this._logGeometryValidationWarnings(h.rings,"rings","ExtrudeSymbol3DLayer"),null;const m=V(h,this._context.elevationProvider,this._context.renderCoordsHelper,a);this._logGeometryCreationWarnings(m,h.rings,"rings","ExtrudeSymbol3DLayer");const p=G(h);if(null==p)return null;const g=new Array,d=new Array,u=b(),E=l(),v=f(),C=this._context.renderCoordsHelper.viewingMode===O.Global;C||this._context.renderCoordsHelper.worldUpAtPosition(null,v),y(h.spatialReference,[p.x,p.y,0],E,this._context.renderCoordsHelper.spatialReference);const L=l();o(L,E);const M=i();n(M,L);const{polygons:A,mapPositions:D,position:R}=m;for(const n of A){const e=n.count;if(this._context.clippingExtent&&(_(u),x(u,n.mapPositions),!j(u,this._context.clippingExtent)))continue;const i=r(n.mapPositions,n.holeIndices,3);if(0===i.length)continue;const o=i.length,a=6*e,l=P(a+o),h=P(o),m=S(3*a),p=S(3*a),f=S(3*a),y=S(a);se(R,D,i,n,m,f,p,y,l,h,this._getExtrusionSize(t),v,C),w(m,m,L);const b=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:c,layerUid:this._context.layer.uid}),E=new je(m,f,K(p),y);g.push(te(this._material,l,l.length-h.length,E,s,b),te(this._bottomMaterial,h,0,E,s,b)),d.push(E.heights)}if(0===g.length)return null;const B=new Q({geometries:g,layerUid:this._context.layer.uid,graphicUid:c,isElevationSource:!0});B.transformation=E;const k=T(this.symbolLayer,{opacity:this._getLayerOpacity()}),N=null!=k?{baseMaterial:this._material,edgeMaterials:[k],properties:{mergeGeometries:!0,hasSlicePlane:this._context.slicePlaneEnabled}}:null,H=new z(this,B,g,null,null,((e,t,s,r,n)=>de(e,t,s,r,n,d)),a,N);return H.alignedSampledElevation=m.sampledElevation,H.needsElevationUpdates=I(a.mode),H}}function te(e,t,s,r,n,i){const o=E(t.length),a=[[X.POSITION,new F(r.positions,3,!0)],[X.NORMALCOMPRESSED,new F(r.normals,2,!0)],[X.COLOR,new F(n,4,!0)]],l=[[X.POSITION,t],[X.NORMALCOMPRESSED,t],[X.COLOR,o]];return new Z(e,a,l,r.elevation,q.Mesh,i,s)}function se(e,t,s,r,n,i,o,a,l,c,h,m,p){const g=s.length/3;let d=0,u=2*r.count;re(e,t,r.index,r.count,s,0,g,n,i,o,a,l,c,u,h,m,p);let f=2*r.count;u=0,oe(n,i,a,o,d,r.pathLengths[0],r.count,f,l,u,h),f+=4*r.pathLengths[0],u+=2*r.pathLengths[0],d+=r.pathLengths[0];for(let y=1;y<r.pathLengths.length;++y)oe(n,i,a,o,d,r.pathLengths[y],r.count,f,l,u,h),f+=4*r.pathLengths[y],u+=2*r.pathLengths[y],d+=r.pathLengths[y]}function re(e,t,s,r,n,i,o,a,l,m,p,g,d,u,f,y,b){c(fe,y);const _=f>0?1:-1;let x=3*s,j=0,S=3*j,P=r,E=3*P;for(let c=0;c<r;++c)b&&(fe[0]=e[x],fe[1]=e[x+1],fe[2]=e[x+2],h(fe,fe)),a[S]=e[x],a[S+1]=e[x+1],a[S+2]=e[x+2],l[S]=t[x],l[S+1]=t[x+1],l[S+2]=t[x+2],m[S]=-_*fe[0],m[S+1]=-_*fe[1],m[S+2]=-_*fe[2],p[j]=0,a[E]=e[x]+f*fe[0],a[E+1]=e[x+1]+f*fe[1],a[E+2]=e[x+2]+f*fe[2],l[E]=t[x],l[E+1]=t[x+1],l[E+2]=t[x+2],m[E]=_*fe[0],m[E+1]=_*fe[1],m[E+2]=_*fe[2],p[P]=f,S+=3,E+=3,x+=3,j+=1,P+=1;x=3*i,S=0,E=3*u;const w=f<0?_e:be,v=f<0?be:_e;for(let c=0;c<o;++c)d[S]=n[x+w[0]],d[S+1]=n[x+w[1]],d[S+2]=n[x+w[2]],g[E]=n[x+v[0]]+r,g[E+1]=n[x+v[1]]+r,g[E+2]=n[x+v[2]]+r,S+=3,E+=3,x+=3}function ne(e,t,s,r,n,i,o){r[i]=r[o],o*=3,e[i*=3]=e[o],e[i+1]=e[o+1],e[i+2]=e[o+2],t[i]=t[o],t[i+1]=t[o+1],t[i+2]=t[o+2],s[i]=n[0],s[i+1]=n[1],s[i+2]=n[2]}const ie=f();function oe(e,t,s,r,n,i,o,a,l,c,h){let m=n,p=n+1,g=n+o,d=n+o+1,u=a,f=a+1,y=a+2*i,b=a+2*i+1;h<0&&(m=n+o+1,d=n),c*=3;for(let _=0;_<i;++_)_===i-1&&(h>0?(p=n,d=n+o):(p=n,m=n+o)),pe(e,m,p,g,ie),ne(e,t,r,s,ie,u,m),ne(e,t,r,s,ie,f,p),ne(e,t,r,s,ie,y,g),ne(e,t,r,s,ie,b,d),l[c++]=u,l[c++]=y,l[c++]=b,l[c++]=u,l[c++]=b,l[c++]=f,m++,p++,g++,d++,u+=2,f+=2,y+=2,b+=2}const ae=f(),le=f(),ce=f(),he=f(),me=f();function pe(e,t,s,r,n){t*=3,s*=3,r*=3,m(ae,e[t++],e[t++],e[t++]),m(le,e[s++],e[s++],e[s++]),m(ce,e[r++],e[r++],e[r++]),p(he,le,ae),p(me,ce,ae),g(n,me,he),h(n,n)}const ge=f();function de(e,t,s,r,n,i){const o=e.stageObject,c=o.geometries,h=c.length,p="absolute-height"!==t.mode;let g=0;const u=o.transformation,f=a(l(),u);for(let a=0;a<h;a+=2){const e=c[a];if(!J(e))continue;const t=e.getMutableAttribute(X.POSITION).data,l=i[a/2],h=new N(e.mapPositions),y=t.length/3;let b=0,_=!1,x=0;for(let i=0;i<y;i++){ge[0]=t[b],ge[1]=t[b+1],ge[2]=t[b+2],r(h,ye),p&&(x+=ye.sampledElevation),k.TESTS_DISABLE_OPTIMIZATIONS?(m(ue,h.array[h.offset],h.array[h.offset+1],ye.z+l[b/3]),null!=s&&n.toRenderCoords(ue,s,ue),d(ue,ue,f)):(m(ue,t[b],t[b+1],t[b+2]),d(ue,ue,u),n.setAltitude(ue,ye.z+l[b/3]),d(ue,ue,f)),t[b]=ue[0],t[b+1]=ue[1],t[b+2]=ue[2];const e=xe/n.unitInMeters;(Math.abs(ge[0]-t[b])>=e||Math.abs(ge[1]-t[b+1])>=e||Math.abs(ge[2]-t[b+2])>=e)&&(_=!0),h.offset+=3,b+=3}_&&(e.invalidateBoundingInfo(),o.geometryVertexAttrsUpdated(c[a]),c[a+1].invalidateBoundingInfo(),o.geometryVertexAttrsUpdated(c[a+1])),g+=x/y}return g/h}const ue=f(),fe=f(),ye=new M,be=[0,2,1],_e=[0,1,2],xe=.01;class je{constructor(e,t,s,r){this.positions=e,this.elevation=t,this.normals=s,this.heights=r}}export{ee as Graphics3DExtrudeSymbolLayer};
5
+ import"../../../../core/has.js";import e from"../../../../core/Error.js";import{clone as t}from"../../../../core/lang.js";import{getMetersPerVerticalUnitForSR as s}from"../../../../core/unitUtils.js";import{e as r}from"../../../../chunks/earcut.js";import{d as n}from"../../../../chunks/mat3.js";import{c as i}from"../../../../chunks/mat3f64.js";import{a as o,p as a}from"../../../../chunks/mat4.js";import{c as l}from"../../../../chunks/mat4f64.js";import{c,n as h,s as m,b as p,f as g,m as d}from"../../../../chunks/vec3.js";import{g as u,c as f}from"../../../../chunks/vec3f64.js";import{computeTranslationToOriginAndRotation as y}from"../../../../geometry/projection.js";import{create as b,empty as _,expandWithBuffer as x,intersectsClippingArea as j}from"../../../../geometry/support/aaBoundingBox.js";import{newDoubleArray as S}from"../../../../geometry/support/DoubleArray.js";import{newIndexArray as P,getZeroIndexArray as E}from"../../../../geometry/support/Indices.js";import{t as w}from"../../../../chunks/vec32.js";import{makeVertexCandidate as v,makeEdgeCandidate as C}from"../../../../layers/graphics/data/SnappingCandidate.js";import{getDriverAxisSizeValue as L}from"../../../../renderers/support/renderingInfoUtils.js";import{ViewingMode as O}from"../../../ViewingMode.js";import{needsElevationUpdates3D as I,SampleElevationInfo as M}from"./elevationAlignmentUtils.js";import{Graphics3DObject3DGraphicLayer as A}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as z}from"./Graphics3DSymbolLayer.js";import{validateSymbolLayerSize as D,computeCentroid as R}from"./graphicUtils.js";import{ApplyRendererDiffResult as G}from"./interfaces.js";import{geometryAsPolygon as B}from"./polygonUtils.js";import{createMaterial as U}from"../support/edgeUtils.js";import T from"../../support/debugFlags.js";import{SamplePosition as k}from"../../support/ElevationProvider.js";import{geometryToRenderInfo as N}from"../../support/renderInfoUtils/polygon.js";import{NormalType as V}from"../../webgl-engine/core/shaderLibrary/attributes/NormalAttribute.glsl.js";import{Attribute as H}from"../../webgl-engine/lib/Attribute.js";import{CullFaceOptions as F}from"../../webgl-engine/lib/basicInterfaces.js";import{ContentObjectType as W}from"../../webgl-engine/lib/ContentObjectType.js";import{Geometry as q}from"../../webgl-engine/lib/Geometry.js";import{isGeometryWithMapPositions as Z}from"../../webgl-engine/lib/GeometryWithMapPositions.js";import{compressNormals as J}from"../../webgl-engine/lib/Normals.js";import{Object3D as K}from"../../webgl-engine/lib/Object3D.js";import{VertexAttribute as Q}from"../../webgl-engine/lib/VertexAttribute.js";import{DefaultMaterial as X}from"../../webgl-engine/materials/DefaultMaterial.js";const Y=["polygon","extent"];class $ extends z{constructor(e,t,s,r){super(e,t,s,r),this.ensureDrapedStatus(!1)}async doLoad(){if(!this._drivenProperties.size){const t=D(this._getSymbolSize());if(t)throw new e("graphics3dextrudesymbollayer:invalid-size",t)}const t=this.symbolLayer?.material?.color,s=this._getCombinedOpacityAndColor(t),r=u(s),n=s[3],i=n<1||this.needsDrivenTransparentPass,o={usePBR:this._context.physicalBasedRenderingEnabled,isSchematic:!0,diffuse:r,ambient:r,opacity:n,transparent:i,cullFace:i?F.None:F.Back,hasVertexColors:!0,hasSlicePlane:this._context.slicePlaneEnabled,castShadows:this.symbolLayer.castShadows,offsetTransparentBackfaces:!0,normalType:V.Compressed};this._material=new X(o),this._bottomMaterial=new X({...o,cullFace:F.Back}),this._context.stage.add(this._material),this._context.stage.add(this._bottomMaterial)}destroy(){super.destroy(),this._material&&(this._context.stage.remove(this._material),this._context.stage.remove(this._bottomMaterial))}createGraphics3DGraphic(e){const t=e.graphic;if(!this._validateGeometry(t.geometry,Y,this.symbolLayer.type))return null;const s=this._getVertexOpacityAndColor(e.renderingInfo,255),r=this.setGraphicElevationContext(t);return this._createAs3DShape(t,e.renderingInfo,s,r,t.uid)}layerOpacityChanged(e,t){const s=this.symbolLayer?.material?.color,r=this._getCombinedOpacity(s),n=r<1||this.needsDrivenTransparentPass;this._material.setParameters({opacity:r,transparent:n}),this._bottomMaterial.setParameters({opacity:r,transparent:n});const i=this._getLayerOpacity();e.forEach((e=>{const s=t(e);null!=s&&s.layerOpacityChanged(i,this._context.isAsync)}))}layerElevationInfoChanged(e,t){return this.updateGraphics3DGraphicElevationInfo(e,t,I)}slicePlaneEnabledChanged(e,t){return this._material.setParameters({hasSlicePlane:this._context.slicePlaneEnabled}),this._bottomMaterial.setParameters({hasSlicePlane:this._context.slicePlaneEnabled}),e.forEach((e=>{const s=t(e);null!=s&&s.slicePlaneEnabledChanged(this._context.slicePlaneEnabled,this._context.isAsync)})),!0}physicalBasedRenderingChanged(){return this._material.setParameters({usePBR:this._context.physicalBasedRenderingEnabled,isSchematic:!0}),this._bottomMaterial.setParameters({usePBR:this._context.physicalBasedRenderingEnabled,isSchematic:!0}),!0}_getExtrusionSize(e){let t;return t=e.size&&this._drivenProperties.size?L(e.size,2)??0:this._getSymbolSize(),t/=this._context.renderCoordsHelper.unitInMeters,t}applyRendererDiff(e,t){return this._drivenPropertiesChanged(t)?G.RecreateSymbol:G.RecreateGraphics}async queryForSnapping(e,r,n,i){const o=this._getExtrusionSize(n)*this._context.renderCoordsHelper.unitInMeters/s(r),{objectId:a,target:l}=e,c=t(l);switch(c.z=(c.z??0)+o,e.type){case"edge":{const{start:s,end:r}=e,n=t(s),i=t(r);return n.z=(n.z??0)+o,i.z=(i.z??0)+o,[C(a,c,1/0,n,i)]}case"vertex":return[v(a,c,1/0),C(a,l,1/0,l,c)];default:return[]}}_getSymbolSize(){return this.symbolLayer.size??1}_createAs3DShape(e,t,s,a,c){const h=B(e.geometry);if(null==h)return null;if(0===h.rings.length||!h.rings.some((e=>e.length>0)))return this._logGeometryValidationWarnings(h.rings,"rings","ExtrudeSymbol3DLayer"),null;const m=N(h,this._context.elevationProvider,this._context.renderCoordsHelper,a);this._logGeometryCreationWarnings(m,h.rings,"rings","ExtrudeSymbol3DLayer");const p=R(h);if(null==p)return null;const g=new Array,d=new Array,u=b(),E=l(),v=f(),C=this._context.renderCoordsHelper.viewingMode===O.Global;C||this._context.renderCoordsHelper.worldUpAtPosition(null,v),y(h.spatialReference,[p.x,p.y,0],E,this._context.renderCoordsHelper.spatialReference);const L=l();o(L,E);const M=i();n(M,L);const{polygons:z,mapPositions:D,position:G}=m;for(const n of z){const e=n.count;if(this._context.clippingExtent&&(_(u),x(u,n.mapPositions),!j(u,this._context.clippingExtent)))continue;const i=r(n.mapPositions,n.holeIndices,3);if(0===i.length)continue;const o=i.length,a=6*e,l=P(a+o),h=P(o),m=S(3*a),p=S(3*a),f=S(3*a),y=S(a);te(G,D,i,n,m,f,p,y,l,h,this._getExtrusionSize(t),v,C),w(m,m,L);const b=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:c,layerUid:this._context.layer.uid}),E=new xe(m,f,J(p),y);g.push(ee(this._material,l,l.length-h.length,E,s,b),ee(this._bottomMaterial,h,0,E,s,b)),d.push(E.heights)}if(0===g.length)return null;const T=new K({geometries:g,layerUid:this._context.layer.uid,graphicUid:c,isElevationSource:!0});T.transformation=E;const k=U(this.symbolLayer,{opacity:this._getLayerOpacity()}),V=null!=k?{baseMaterial:this._material,edgeMaterials:[k],properties:{mergeGeometries:!0,hasSlicePlane:this._context.slicePlaneEnabled}}:null,H=new A(this,T,g,null,null,((e,t,s,r,n)=>ge(e,t,s,r,n,d)),a,V);return H.alignedSampledElevation=m.sampledElevation,H.needsElevationUpdates=I(a.mode),H}}function ee(e,t,s,r,n,i){const o=E(t.length),a=[[Q.POSITION,new H(r.positions,3,!0)],[Q.NORMALCOMPRESSED,new H(r.normals,2,!0)],[Q.COLOR,new H(n,4,!0)]],l=[[Q.POSITION,t],[Q.NORMALCOMPRESSED,t],[Q.COLOR,o]];return new q(e,a,l,r.elevation,W.Mesh,i,s)}function te(e,t,s,r,n,i,o,a,l,c,h,m,p){const g=s.length/3;let d=0,u=2*r.count;se(e,t,r.index,r.count,s,0,g,n,i,o,a,l,c,u,h,m,p);let f=2*r.count;u=0,ie(n,i,a,o,d,r.pathLengths[0],r.count,f,l,u,h),f+=4*r.pathLengths[0],u+=2*r.pathLengths[0],d+=r.pathLengths[0];for(let y=1;y<r.pathLengths.length;++y)ie(n,i,a,o,d,r.pathLengths[y],r.count,f,l,u,h),f+=4*r.pathLengths[y],u+=2*r.pathLengths[y],d+=r.pathLengths[y]}function se(e,t,s,r,n,i,o,a,l,m,p,g,d,u,f,y,b){c(ue,y);const _=f>0?1:-1;let x=3*s,j=0,S=3*j,P=r,E=3*P;for(let c=0;c<r;++c)b&&(ue[0]=e[x],ue[1]=e[x+1],ue[2]=e[x+2],h(ue,ue)),a[S]=e[x],a[S+1]=e[x+1],a[S+2]=e[x+2],l[S]=t[x],l[S+1]=t[x+1],l[S+2]=t[x+2],m[S]=-_*ue[0],m[S+1]=-_*ue[1],m[S+2]=-_*ue[2],p[j]=0,a[E]=e[x]+f*ue[0],a[E+1]=e[x+1]+f*ue[1],a[E+2]=e[x+2]+f*ue[2],l[E]=t[x],l[E+1]=t[x+1],l[E+2]=t[x+2],m[E]=_*ue[0],m[E+1]=_*ue[1],m[E+2]=_*ue[2],p[P]=f,S+=3,E+=3,x+=3,j+=1,P+=1;x=3*i,S=0,E=3*u;const w=f<0?be:ye,v=f<0?ye:be;for(let c=0;c<o;++c)d[S]=n[x+w[0]],d[S+1]=n[x+w[1]],d[S+2]=n[x+w[2]],g[E]=n[x+v[0]]+r,g[E+1]=n[x+v[1]]+r,g[E+2]=n[x+v[2]]+r,S+=3,E+=3,x+=3}function re(e,t,s,r,n,i,o){r[i]=r[o],o*=3,e[i*=3]=e[o],e[i+1]=e[o+1],e[i+2]=e[o+2],t[i]=t[o],t[i+1]=t[o+1],t[i+2]=t[o+2],s[i]=n[0],s[i+1]=n[1],s[i+2]=n[2]}const ne=f();function ie(e,t,s,r,n,i,o,a,l,c,h){let m=n,p=n+1,g=n+o,d=n+o+1,u=a,f=a+1,y=a+2*i,b=a+2*i+1;h<0&&(m=n+o+1,d=n),c*=3;for(let _=0;_<i;++_)_===i-1&&(h>0?(p=n,d=n+o):(p=n,m=n+o)),me(e,m,p,g,ne),re(e,t,r,s,ne,u,m),re(e,t,r,s,ne,f,p),re(e,t,r,s,ne,y,g),re(e,t,r,s,ne,b,d),l[c++]=u,l[c++]=y,l[c++]=b,l[c++]=u,l[c++]=b,l[c++]=f,m++,p++,g++,d++,u+=2,f+=2,y+=2,b+=2}const oe=f(),ae=f(),le=f(),ce=f(),he=f();function me(e,t,s,r,n){t*=3,s*=3,r*=3,m(oe,e[t++],e[t++],e[t++]),m(ae,e[s++],e[s++],e[s++]),m(le,e[r++],e[r++],e[r++]),p(ce,ae,oe),p(he,le,oe),g(n,he,ce),h(n,n)}const pe=f();function ge(e,t,s,r,n,i){const o=e.stageObject,c=o.geometries,h=c.length,p="absolute-height"!==t.mode;let g=0;const u=o.transformation,f=a(l(),u);for(let a=0;a<h;a+=2){const e=c[a];if(!Z(e))continue;const t=e.getMutableAttribute(Q.POSITION).data,l=i[a/2],h=new k(e.mapPositions),y=t.length/3;let b=0,_=!1,x=0;for(let i=0;i<y;i++){pe[0]=t[b],pe[1]=t[b+1],pe[2]=t[b+2],r(h,fe),p&&(x+=fe.sampledElevation),T.TESTS_DISABLE_OPTIMIZATIONS?(m(de,h.array[h.offset],h.array[h.offset+1],fe.z+l[b/3]),null!=s&&n.toRenderCoords(de,s,de),d(de,de,f)):(m(de,t[b],t[b+1],t[b+2]),d(de,de,u),n.setAltitude(de,fe.z+l[b/3]),d(de,de,f)),t[b]=de[0],t[b+1]=de[1],t[b+2]=de[2];const e=_e/n.unitInMeters;(Math.abs(pe[0]-t[b])>=e||Math.abs(pe[1]-t[b+1])>=e||Math.abs(pe[2]-t[b+2])>=e)&&(_=!0),h.offset+=3,b+=3}_&&(e.invalidateBoundingInfo(),o.geometryVertexAttrsUpdated(c[a]),c[a+1].invalidateBoundingInfo(),o.geometryVertexAttrsUpdated(c[a+1])),g+=x/y}return g/h}const de=f(),ue=f(),fe=new M,ye=[0,2,1],be=[0,1,2],_e=.01;class xe{constructor(e,t,s,r){this.positions=e,this.elevation=t,this.normals=s,this.heights=r}}export{$ as Graphics3DExtrudeSymbolLayer};