@arcgis/core 4.28.0-next.20230821 → 4.28.0-next.20230822

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 (183) hide show
  1. package/arcade/functions/geomasync.js +1 -1
  2. package/arcade/portalUtils.js +1 -1
  3. package/assets/esri/core/workers/RemoteClient.js +1 -1
  4. package/assets/esri/core/workers/chunks/0746319459dbcd3ab6f7.js +1 -0
  5. package/assets/esri/core/workers/chunks/217910f88fe2c03e6bdd.js +1 -0
  6. package/assets/esri/core/workers/chunks/54aaa21144431b29b6ed.js +1 -0
  7. package/assets/esri/core/workers/chunks/{46f6b77e586d78aeb75c.js → 6866dee1c7e2f230ad08.js} +1 -1
  8. package/assets/esri/core/workers/chunks/{d6c96a20e9640b433719.js → 7dad40179a9767ea9087.js} +56 -56
  9. package/assets/esri/core/workers/chunks/{05ab09713d599687afa3.js → c6bd9c400615107591ec.js} +1 -1
  10. package/assets/esri/core/workers/chunks/{4922a0fed7cbc6895882.js → f701a5afa1b730c51a49.js} +1 -1
  11. package/assets/esri/widgets/DirectionalPad/t9n/DirectionalPad_ar.json +1 -0
  12. package/assets/esri/widgets/DirectionalPad/t9n/DirectionalPad_bg.json +1 -0
  13. package/assets/esri/widgets/DirectionalPad/t9n/DirectionalPad_bs.json +1 -0
  14. package/assets/esri/widgets/DirectionalPad/t9n/DirectionalPad_ca.json +1 -0
  15. package/assets/esri/widgets/DirectionalPad/t9n/DirectionalPad_cs.json +1 -0
  16. package/assets/esri/widgets/DirectionalPad/t9n/DirectionalPad_da.json +1 -0
  17. package/assets/esri/widgets/DirectionalPad/t9n/DirectionalPad_de.json +1 -0
  18. package/assets/esri/widgets/DirectionalPad/t9n/DirectionalPad_el.json +1 -0
  19. package/assets/esri/widgets/DirectionalPad/t9n/DirectionalPad_es.json +1 -0
  20. package/assets/esri/widgets/DirectionalPad/t9n/DirectionalPad_et.json +1 -0
  21. package/assets/esri/widgets/DirectionalPad/t9n/DirectionalPad_fi.json +1 -0
  22. package/assets/esri/widgets/DirectionalPad/t9n/DirectionalPad_fr.json +1 -0
  23. package/assets/esri/widgets/DirectionalPad/t9n/DirectionalPad_he.json +1 -0
  24. package/assets/esri/widgets/DirectionalPad/t9n/DirectionalPad_hr.json +1 -0
  25. package/assets/esri/widgets/DirectionalPad/t9n/DirectionalPad_hu.json +1 -0
  26. package/assets/esri/widgets/DirectionalPad/t9n/DirectionalPad_id.json +1 -0
  27. package/assets/esri/widgets/DirectionalPad/t9n/DirectionalPad_it.json +1 -0
  28. package/assets/esri/widgets/DirectionalPad/t9n/DirectionalPad_ja.json +1 -0
  29. package/assets/esri/widgets/DirectionalPad/t9n/DirectionalPad_ko.json +1 -0
  30. package/assets/esri/widgets/DirectionalPad/t9n/DirectionalPad_lt.json +1 -0
  31. package/assets/esri/widgets/DirectionalPad/t9n/DirectionalPad_lv.json +1 -0
  32. package/assets/esri/widgets/DirectionalPad/t9n/DirectionalPad_nb.json +1 -0
  33. package/assets/esri/widgets/DirectionalPad/t9n/DirectionalPad_nl.json +1 -0
  34. package/assets/esri/widgets/DirectionalPad/t9n/DirectionalPad_pl.json +1 -0
  35. package/assets/esri/widgets/DirectionalPad/t9n/DirectionalPad_pt-BR.json +1 -0
  36. package/assets/esri/widgets/DirectionalPad/t9n/DirectionalPad_pt-PT.json +1 -0
  37. package/assets/esri/widgets/DirectionalPad/t9n/DirectionalPad_ro.json +1 -0
  38. package/assets/esri/widgets/DirectionalPad/t9n/DirectionalPad_ru.json +1 -0
  39. package/assets/esri/widgets/DirectionalPad/t9n/DirectionalPad_sk.json +1 -0
  40. package/assets/esri/widgets/DirectionalPad/t9n/DirectionalPad_sl.json +1 -0
  41. package/assets/esri/widgets/DirectionalPad/t9n/DirectionalPad_sr.json +1 -0
  42. package/assets/esri/widgets/DirectionalPad/t9n/DirectionalPad_sv.json +1 -0
  43. package/assets/esri/widgets/DirectionalPad/t9n/DirectionalPad_th.json +1 -0
  44. package/assets/esri/widgets/DirectionalPad/t9n/DirectionalPad_tr.json +1 -0
  45. package/assets/esri/widgets/DirectionalPad/t9n/DirectionalPad_uk.json +1 -0
  46. package/assets/esri/widgets/DirectionalPad/t9n/DirectionalPad_vi.json +1 -0
  47. package/assets/esri/widgets/DirectionalPad/t9n/DirectionalPad_zh-CN.json +1 -0
  48. package/assets/esri/widgets/DirectionalPad/t9n/DirectionalPad_zh-HK.json +1 -0
  49. package/assets/esri/widgets/DirectionalPad/t9n/DirectionalPad_zh-TW.json +1 -0
  50. package/assets/esri/widgets/Editor/t9n/Editor_ar.json +1 -1
  51. package/assets/esri/widgets/Editor/t9n/Editor_bg.json +1 -1
  52. package/assets/esri/widgets/Editor/t9n/Editor_bs.json +1 -1
  53. package/assets/esri/widgets/Editor/t9n/Editor_ca.json +1 -1
  54. package/assets/esri/widgets/Editor/t9n/Editor_cs.json +1 -1
  55. package/assets/esri/widgets/Editor/t9n/Editor_da.json +1 -1
  56. package/assets/esri/widgets/Editor/t9n/Editor_de.json +1 -1
  57. package/assets/esri/widgets/Editor/t9n/Editor_el.json +1 -1
  58. package/assets/esri/widgets/Editor/t9n/Editor_es.json +1 -1
  59. package/assets/esri/widgets/Editor/t9n/Editor_et.json +1 -1
  60. package/assets/esri/widgets/Editor/t9n/Editor_fi.json +1 -1
  61. package/assets/esri/widgets/Editor/t9n/Editor_fr.json +1 -1
  62. package/assets/esri/widgets/Editor/t9n/Editor_he.json +1 -1
  63. package/assets/esri/widgets/Editor/t9n/Editor_hr.json +1 -1
  64. package/assets/esri/widgets/Editor/t9n/Editor_hu.json +1 -1
  65. package/assets/esri/widgets/Editor/t9n/Editor_id.json +1 -1
  66. package/assets/esri/widgets/Editor/t9n/Editor_it.json +1 -1
  67. package/assets/esri/widgets/Editor/t9n/Editor_ja.json +1 -1
  68. package/assets/esri/widgets/Editor/t9n/Editor_ko.json +1 -1
  69. package/assets/esri/widgets/Editor/t9n/Editor_lt.json +1 -1
  70. package/assets/esri/widgets/Editor/t9n/Editor_lv.json +1 -1
  71. package/assets/esri/widgets/Editor/t9n/Editor_nb.json +1 -1
  72. package/assets/esri/widgets/Editor/t9n/Editor_nl.json +1 -1
  73. package/assets/esri/widgets/Editor/t9n/Editor_pl.json +1 -1
  74. package/assets/esri/widgets/Editor/t9n/Editor_pt-BR.json +1 -1
  75. package/assets/esri/widgets/Editor/t9n/Editor_pt-PT.json +1 -1
  76. package/assets/esri/widgets/Editor/t9n/Editor_ro.json +1 -1
  77. package/assets/esri/widgets/Editor/t9n/Editor_ru.json +1 -1
  78. package/assets/esri/widgets/Editor/t9n/Editor_sk.json +1 -1
  79. package/assets/esri/widgets/Editor/t9n/Editor_sl.json +1 -1
  80. package/assets/esri/widgets/Editor/t9n/Editor_sr.json +1 -1
  81. package/assets/esri/widgets/Editor/t9n/Editor_sv.json +1 -1
  82. package/assets/esri/widgets/Editor/t9n/Editor_th.json +1 -1
  83. package/assets/esri/widgets/Editor/t9n/Editor_tr.json +1 -1
  84. package/assets/esri/widgets/Editor/t9n/Editor_uk.json +1 -1
  85. package/assets/esri/widgets/Editor/t9n/Editor_vi.json +1 -1
  86. package/assets/esri/widgets/Editor/t9n/Editor_zh-CN.json +1 -1
  87. package/assets/esri/widgets/Editor/t9n/Editor_zh-HK.json +1 -1
  88. package/assets/esri/widgets/Editor/t9n/Editor_zh-TW.json +1 -1
  89. package/assets/esri/widgets/UtilityNetworkAssociations/t9n/UtilityNetworkAssociations_ar.json +1 -1
  90. package/assets/esri/widgets/UtilityNetworkAssociations/t9n/UtilityNetworkAssociations_bg.json +1 -1
  91. package/assets/esri/widgets/UtilityNetworkAssociations/t9n/UtilityNetworkAssociations_bs.json +1 -1
  92. package/assets/esri/widgets/UtilityNetworkAssociations/t9n/UtilityNetworkAssociations_ca.json +1 -1
  93. package/assets/esri/widgets/UtilityNetworkAssociations/t9n/UtilityNetworkAssociations_cs.json +1 -1
  94. package/assets/esri/widgets/UtilityNetworkAssociations/t9n/UtilityNetworkAssociations_da.json +1 -1
  95. package/assets/esri/widgets/UtilityNetworkAssociations/t9n/UtilityNetworkAssociations_de.json +1 -1
  96. package/assets/esri/widgets/UtilityNetworkAssociations/t9n/UtilityNetworkAssociations_el.json +1 -1
  97. package/assets/esri/widgets/UtilityNetworkAssociations/t9n/UtilityNetworkAssociations_es.json +1 -1
  98. package/assets/esri/widgets/UtilityNetworkAssociations/t9n/UtilityNetworkAssociations_et.json +1 -1
  99. package/assets/esri/widgets/UtilityNetworkAssociations/t9n/UtilityNetworkAssociations_fi.json +1 -1
  100. package/assets/esri/widgets/UtilityNetworkAssociations/t9n/UtilityNetworkAssociations_fr.json +1 -1
  101. package/assets/esri/widgets/UtilityNetworkAssociations/t9n/UtilityNetworkAssociations_he.json +1 -1
  102. package/assets/esri/widgets/UtilityNetworkAssociations/t9n/UtilityNetworkAssociations_hr.json +1 -1
  103. package/assets/esri/widgets/UtilityNetworkAssociations/t9n/UtilityNetworkAssociations_hu.json +1 -1
  104. package/assets/esri/widgets/UtilityNetworkAssociations/t9n/UtilityNetworkAssociations_id.json +1 -1
  105. package/assets/esri/widgets/UtilityNetworkAssociations/t9n/UtilityNetworkAssociations_it.json +1 -1
  106. package/assets/esri/widgets/UtilityNetworkAssociations/t9n/UtilityNetworkAssociations_ja.json +1 -1
  107. package/assets/esri/widgets/UtilityNetworkAssociations/t9n/UtilityNetworkAssociations_ko.json +1 -1
  108. package/assets/esri/widgets/UtilityNetworkAssociations/t9n/UtilityNetworkAssociations_lt.json +1 -1
  109. package/assets/esri/widgets/UtilityNetworkAssociations/t9n/UtilityNetworkAssociations_lv.json +1 -1
  110. package/assets/esri/widgets/UtilityNetworkAssociations/t9n/UtilityNetworkAssociations_nb.json +1 -1
  111. package/assets/esri/widgets/UtilityNetworkAssociations/t9n/UtilityNetworkAssociations_nl.json +1 -1
  112. package/assets/esri/widgets/UtilityNetworkAssociations/t9n/UtilityNetworkAssociations_pl.json +1 -1
  113. package/assets/esri/widgets/UtilityNetworkAssociations/t9n/UtilityNetworkAssociations_pt-BR.json +1 -1
  114. package/assets/esri/widgets/UtilityNetworkAssociations/t9n/UtilityNetworkAssociations_pt-PT.json +1 -1
  115. package/assets/esri/widgets/UtilityNetworkAssociations/t9n/UtilityNetworkAssociations_ro.json +1 -1
  116. package/assets/esri/widgets/UtilityNetworkAssociations/t9n/UtilityNetworkAssociations_ru.json +1 -1
  117. package/assets/esri/widgets/UtilityNetworkAssociations/t9n/UtilityNetworkAssociations_sk.json +1 -1
  118. package/assets/esri/widgets/UtilityNetworkAssociations/t9n/UtilityNetworkAssociations_sl.json +1 -1
  119. package/assets/esri/widgets/UtilityNetworkAssociations/t9n/UtilityNetworkAssociations_sr.json +1 -1
  120. package/assets/esri/widgets/UtilityNetworkAssociations/t9n/UtilityNetworkAssociations_sv.json +1 -1
  121. package/assets/esri/widgets/UtilityNetworkAssociations/t9n/UtilityNetworkAssociations_th.json +1 -1
  122. package/assets/esri/widgets/UtilityNetworkAssociations/t9n/UtilityNetworkAssociations_tr.json +1 -1
  123. package/assets/esri/widgets/UtilityNetworkAssociations/t9n/UtilityNetworkAssociations_uk.json +1 -1
  124. package/assets/esri/widgets/UtilityNetworkAssociations/t9n/UtilityNetworkAssociations_vi.json +1 -1
  125. package/assets/esri/widgets/UtilityNetworkAssociations/t9n/UtilityNetworkAssociations_zh-CN.json +1 -1
  126. package/assets/esri/widgets/UtilityNetworkAssociations/t9n/UtilityNetworkAssociations_zh-HK.json +1 -1
  127. package/assets/esri/widgets/UtilityNetworkAssociations/t9n/UtilityNetworkAssociations_zh-TW.json +1 -1
  128. package/chunks/LineSeries.js +1 -1
  129. package/chunks/Theme.js +1 -1
  130. package/chunks/chartUtilsAm5.js +1 -1
  131. package/layers/support/layerUtils.js +1 -1
  132. package/package.json +1 -1
  133. package/portal/support/utils.js +5 -0
  134. package/smartMapping/popup/support/utils.js +1 -1
  135. package/support/revision.js +1 -1
  136. package/symbols/cim/CIMImageColorSubstitutionHelper.js +1 -1
  137. package/symbols/support/previewSymbol3D.js +1 -1
  138. package/views/3d/analysis/Dimension/DimensionTool.js +1 -1
  139. package/views/3d/analysis/Dimension/LengthDimensionSubTool.js +1 -1
  140. package/views/3d/analysis/Slice/SliceTool.js +1 -1
  141. package/views/3d/analysis/images/Factory.js +5 -0
  142. package/views/3d/interactive/Manipulator3D.js +1 -1
  143. package/views/3d/interactive/editingTools/transformGraphic/ExtentTransformTool.js +1 -1
  144. package/views/3d/interactive/visualElements/PointVisualElement.js +1 -1
  145. package/views/3d/interactive/visualElements/VisualElementResources.js +1 -1
  146. package/views/3d/layers/DynamicLayerView3D.js +1 -1
  147. package/views/3d/layers/I3SMeshView3D.js +1 -1
  148. package/views/3d/layers/MediaLayerView3D.js +1 -1
  149. package/views/3d/layers/graphics/Graphics3DIconSymbolLayer.js +1 -1
  150. package/views/3d/layers/graphics/Graphics3DMeshFillSymbolLayer.js +1 -1
  151. package/views/3d/layers/graphics/Graphics3DObject3DGraphicLayer.js +1 -1
  152. package/views/3d/layers/graphics/Graphics3DObjectSymbolLayer.js +1 -1
  153. package/views/3d/layers/graphics/Graphics3DTextSymbolLayer.js +1 -1
  154. package/views/3d/support/StreamTextureCollection.js +1 -1
  155. package/views/3d/support/TextureCollection.js +1 -1
  156. package/views/3d/support/engineContent/sdfPrimitives.js +1 -1
  157. package/views/3d/webgl-engine/Stage.js +1 -1
  158. package/views/3d/webgl-engine/lib/ContentObject.js +1 -1
  159. package/views/3d/webgl-engine/lib/GLMaterialRepository.js +1 -1
  160. package/views/3d/webgl-engine/lib/GLTextureMaterial.js +1 -1
  161. package/views/3d/webgl-engine/lib/GridLocalOriginFactory.js +1 -1
  162. package/views/3d/webgl-engine/lib/ITexture.js +5 -0
  163. package/views/3d/webgl-engine/lib/TextTextureAtlas.js +1 -1
  164. package/views/3d/webgl-engine/lib/Texture.js +1 -1
  165. package/views/3d/webgl-engine/lib/TextureRepository.js +1 -1
  166. package/views/3d/webgl-engine/parts/Model.js +1 -1
  167. package/views/draw/DrawManipulator.js +1 -1
  168. package/views/interactive/GraphicManipulator.js +1 -1
  169. package/views/interactive/ManipulatorCollection.js +1 -1
  170. package/views/interactive/ToolViewManagerManipulatorState.js +1 -1
  171. package/views/support/layerViewUtils.js +1 -1
  172. package/widgets/Sketch.js +1 -1
  173. package/widgets/support/SelectionToolbar/SelectionToolbarViewModel.js +1 -1
  174. package/widgets/support/Selector2D/selectorUtils.js +1 -1
  175. package/assets/esri/core/workers/chunks/4e39252f40bc57be9d12.js +0 -1
  176. package/assets/esri/core/workers/chunks/c99fa4189a114370b004.js +0 -1
  177. package/assets/esri/core/workers/chunks/ebd006fcd568a7731115.js +0 -1
  178. package/views/3d/analysis/Slice/images/Factory.js +0 -5
  179. /package/assets/esri/views/3d/analysis/{Slice/images → images}/heading-rotate.ts.svg +0 -0
  180. /package/assets/esri/views/3d/analysis/{Slice/images → images}/tilt-rotate.ts.svg +0 -0
  181. /package/views/3d/analysis/{Slice/images → images}/generateTextures.js +0 -0
  182. /package/views/3d/analysis/{Slice/images → images}/heading-rotate-svg.js +0 -0
  183. /package/views/3d/analysis/{Slice/images → images}/tilt-rotate-svg.js +0 -0
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../../../Color.js";import"../../../../symbols.js";import{result as t}from"../../../../core/asyncUtils.js";import r from"../../../../core/Error.js";import{releaseMaybe as i}from"../../../../core/maybe.js";import{throwIfAbortError as s,throwIfAborted as a}from"../../../../core/promiseUtils.js";import{pt2px as o,px2pt as n}from"../../../../core/screenUtils.js";import{dataComponents as l}from"../../../../core/urlUtils.js";import{f as c,a as h}from"../../../../chunks/vec2f64.js";import{c as m,f as u}from"../../../../chunks/vec3f64.js";import{f as d,c as _}from"../../../../chunks/vec4f64.js";import{projectPointToVector as p}from"../../../../geometry/projection/projectPointToVector.js";import{containsPoint as f}from"../../../../geometry/support/aaBoundingBox.js";import{createRendererExpression as y}from"../../../../support/arcadeOnDemand.js";import{defaultPrimitive as g}from"../../../../symbols/support/IconSymbol3DLayerResource.js";import{getIconHref as x}from"../../../../symbols/support/utils.js";import S from"../../../2d/arcade/callExpressionWithFeature.js";import{TRANSPARENT_UNIT as b}from"./constants.js";import{perObjectElevationAligner as v}from"./ElevationAligners.js";import{SymbolUpdateType as z,elevationModeChangeUpdateType as P,needsElevationUpdates2D as R}from"./elevationAlignmentUtils.js";import{Graphics3DDrapedGraphicLayer as C}from"./Graphics3DDrapedGraphicLayer.js";import{Graphics3DObject3DGraphicLayer as M}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as I}from"./Graphics3DSymbolLayer.js";import{validateSymbolLayerSize as j}from"./graphicUtils.js";import{ApplyRendererDiffResult as w}from"./interfaces.js";import{namedAnchorToHUDMaterialAnchorPos as O}from"./placementUtils.js";import{placePointOnGeometry as T,createStageObject as E,extendPointGraphicElevationContext as U}from"./pointUtils.js";import{initFastSymbolUpdatesState as D,updateFastSymbolUpdatesState as F,evaluateModelTransformScale as L,ConvertOptions as A}from"../support/FastSymbolUpdates.js";import{createTexture as G,requiresHalfTexelOffset as V,DEFAULT_SYMBOL_SIZE_RATIO as B,DEFAULT_TEX_SIZE as N}from"../../support/engineContent/sdfPrimitives.js";import{DRAPED_Z as q}from"../../terrain/OverlayRenderer.js";import{createPointGeometry as H}from"../../webgl-engine/lib/GeometryUtil.js";import{RenderGeometry as W}from"../../webgl-engine/lib/RenderGeometry.js";import{Texture as k}from"../../webgl-engine/lib/Texture.js";import{HUDMaterial as $}from"../../webgl-engine/materials/HUDMaterial.js";import J from"../../../../symbols/CIMSymbol.js";const Z=u(0,0,1),K=16,Q=1.5,X=B,Y=[X/2,X/2,1-X/2,1-X/2],ee=[N*X,N*X];class te extends I{getCachedSize(){return{size:this._getIconSize()}}constructor(e,t,r,i){super(e,t,r,i),this._cimLayers=null,this._cimSymbolMaterials=new Map,this._cimSymbolTextures=new Map,this._cimMaterialParametersInfo=null,this._cimRequiredFields=null,this._cimScaleFactorOrFunction=null,this._size=null,this._symbolTextureRatio=1,this._outlineSize=0,this._elevationOptions={supportsOffsetAdjustment:!0,supportsOnTheGround:!0}}async doLoad(e){this._validateOrThrow();const t=this._prepareMaterialParameters(),r=this._getPrimitive();if(null!=r)this._prepareResourcesPrimitive(t,r);else{const r=x(this.symbolLayer),i=l(r);i&&"application/json"===i.mediaType?await this._prepareResourcesCIM(t,JSON.parse(i.data),e):await this._prepareResourcesHref(t,r,e)}}_validateOrThrow(){if(this._drivenProperties.size)return;const e=j(this._getIconSize());if(e)throw new r("graphics3diconsymbollayer:invalid-size",e)}_getIconSize(){const e=this.symbolLayer,t=Math.round(null!=e.size?o(e.size):K);return this._drivenProperties.size?Math.max(t,64):t}_generateTextureCIM(e){const t=this._getGraphicHash(e);let r=""===t?null:this._cimSymbolTextures.get(t);if(!r){const i={scaleFactor:this._cimScaleFactorOrFunction},s=this._context.sharedResources.cimSymbolRasterizer.rasterizeCIMSymbol3D(this._cimLayers,e,"esriGeometryPoint",i,void 0,void 0);this._cimMaterialParametersInfo.anchorPosition=this._getAnchorPos("relative",s.anchorPosition);const a={width:s.imageData.width,height:s.imageData.height};r=new k(s.imageData,a),this._cimSymbolTextures.set(t,r),this._context.stage.add(r)}return r}_prepareMaterialParameters(){const e={anchorPosition:this._getAnchorPos(this.symbolLayer.anchor,this.symbolLayer.anchorPosition)},t=this.symbol;if(re(t)){const{screenLength:r,minWorldLength:i,maxWorldLength:s}=t.verticalOffset;e.verticalOffset={screenLength:o(r),minWorldLength:i||0,maxWorldLength:null!=s?s:1/0}}return this._context.screenSizePerspectiveEnabled&&(e.screenSizePerspective=this._context.sharedResources.screenSizePerspectiveSettings),e.occlusionTest=!0,e.hasSlicePlane=this._context.slicePlaneEnabled,e}_prepareResourcesPrimitive(e,t){const r=this._getOutlineSize();if(ie(t)&&0===r)throw new Error("Nothing to render");if(this._outlineSize=r,e.color=this._getFillColor(),e.outlineColor=this._getOutlineColor(),e.outlineSize=this._outlineSize,null!=this._context.sharedResources.textures){const r=this._context.sharedResources.textures.fromData(`${t}-icon`,(()=>G(t)));this._texture=r.texture,this._releaseTexture=r,e.textureId=this._texture.id}e.textureIsSignedDistanceField=!0,e.sampleSignedDistanceFieldTexelCenter=V(t),e.distanceFieldBoundingBox=Y;const i=this._getIconSize();this._size=[i,i],this._symbolTextureRatio=1/X,this._createMaterialAndAddToStage(e,this._context.stage)}async _prepareResourcesHref(e,i,a){this._outlineSize=this._getOutlineSize(),e.color=this._getFillColor(),e.outlineColor=this._getOutlineColor(),e.outlineSize=this._outlineSize,e.textureIsSignedDistanceField=!1;const o=this._getIconSize(),n=o*this._context.graphicsCoreOwner.view.state.rasterPixelRatio;if(null!=this._context.sharedResources.textures){const l=await t(this._context.sharedResources.textures.fromUrl(i,n,{signal:a}));if(!1===l.ok){s(l.error);throw new r("graphics3diconsymbollayer:request-failed",`Failed to load (Request for icon resource failed: ${i})`)}this._releaseTexture=l.value;const c=l.value.texture,h=c.parameters.width/c.parameters.height;this._size=h>1?[o,Math.round(o/h)]:[Math.round(o*h),o],e.textureId=c.id}this._createMaterialAndAddToStage(e,this._context.stage)}async _prepareResourcesCIM(e,t,r){const i=new J({data:t});if(!this._context.sharedResources.cimSymbolRasterizer){const e=(await import("../../../../symbols/cim/CIMSymbolRasterizer.js")).CIMSymbolRasterizer;a(r),this._context.sharedResources.cimSymbolRasterizer||(this._context.sharedResources.cimSymbolRasterizer=new e(this._context.renderCoordsHelper.spatialReference,!0))}const s=this._context.layer.fields?this._context.layer.fields.map((e=>e.toJSON())):null;let o,n;if(this._cimLayers=await this._context.sharedResources.cimSymbolRasterizer.analyzeCIMSymbol3D(i,s,this._context.renderer&&"dictionary"===this._context.renderer.type?this._context.renderer.fieldMap:null,"esriGeometryPoint",{signal:r}),this._context.renderer&&"dictionary"===this._context.renderer.type&&this._context.renderer.scaleExpression){const e=this._context.renderer;if(isNaN(e.scaleExpression)){const t=e.scaleExpression,r=await y(t,this._context.layer.spatialReference,s);n=(e,t,i)=>{const s=S(r,e,{$view:i},"esriGeometryPoint",t);return null!==s?s:1}}else o=Number(e.scaleExpression)}this._cimScaleFactorOrFunction=o||n||1;const l=this._context.renderer?await this._context.renderer.getRequiredFields(this._context.layer.fieldsIndex):[];a(r);const c=this._context.layer.fieldsIndex;this._cimRequiredFields=l.map((e=>c.get(e).name)),this._cimMaterialParametersInfo=e,this._cimMaterialParametersInfo.color=this._getFillColor(),this._cimMaterialParametersInfo.outlineColor=[0,0,0,0],this._cimMaterialParametersInfo.outlineSize=0,this._cimMaterialParametersInfo.textureIsSignedDistanceField=!1}_getPrimitive(){return this.symbolLayer.resource&&this.symbolLayer.resource.href?null:this.symbolLayer.resource&&this.symbolLayer.resource.primitive||g}_getOutlineSize(){let e=0;const t=this.symbolLayer;if(null!=t.outline&&null!=t.outline.size)return Math.max(o(t.outline.size),0);return e=ie(this._getPrimitive())?Q:0,Math.max(e,0)}_getOutlineColor(){const t=this._getLayerOpacity(),r=this.symbolLayer,i=r?.outline?.color;if(null!=i){const r=e.toUnitRGB(i),s=i.a*t;return[r[0],r[1],r[2],s]}return[0,0,0,0]}_getFillColor(){if(ie(this._getPrimitive()))return b;const e=null==this._getPrimitive(),t=this.symbolLayer?.material?.color;return this._getCombinedOpacityAndColor(t,{hasIntrinsicColor:e})}_getAnchorPos(e,t){return"relative"===e?c((t.x||0)+.5,.5-(t.y||0)):e in O?O[e]:O.center}_createMaterialAndAddToStage(e,t){if(this._cimLayers){this._fastUpdates=null;let r=e.textureId?this._cimSymbolMaterials.get(e.textureId):null;return r||(r=new $(e),this._cimSymbolMaterials.set(e.textureId??0,r),t.add(r)),r}return this._fastUpdates=D(this._context.renderer,this._fastVisualVariableConvertOptions()),this._fastUpdates&&(e={...e,...this._fastUpdates.materialParameters}),this._material=new $(e),t.add(this._material),this._material}_setDrapingDependentMaterialParameters(){this.draped&&(this._forEachMaterial((e=>{e.setParameters({verticalOffset:null,screenSizePerspective:null,occlusionTest:!1,hasSlicePlane:!1,shaderPolygonOffset:0,isDraped:this.draped})})),this.layerOpacityChanged())}destroy(){super.destroy(),this._forEachMaterial((e=>this._context.stage.remove(e))),this._material=null,this._cimSymbolMaterials.clear(),this._cimSymbolTextures.forEach((e=>this._context.stage.remove(e))),this._cimSymbolTextures.clear(),this._releaseTexture=i(this._releaseTexture)}_getScaleFactor(e,t){if(this._drivenProperties.size&&e.size){for(let t=0;t<3;t++){const r=e.size[t];r&&"symbol-value"!==r&&"proportional"!==r&&(e.size[t]=o(r))}if("symbol-value"===e.size[0])return 1;if(isFinite(+e.size[0]))return+e.size[0]/t;if(isFinite(+e.size[2]))return+e.size[2]/t}return 1}createGraphics3DGraphic(e){const t=e.graphic;if(!this._validateGeometry(t.geometry))return null;let r,i=[0,0];if(this._cimLayers){if(!this._cimLayers.length)return null;const e=this._generateTextureCIM(t),s={textureId:e.id,...this._cimMaterialParametersInfo};r=this._createMaterialAndAddToStage(s,this._context.stage),i=[e.parameters.width,e.parameters.height]}else i=this._size,r=this._material;const s=T(t.geometry);if(null==s)return this.logger.warn(`unsupported geometry type for icon symbol: ${t.geometry.type}`),null;const a=e.renderingInfo,o=this._getVertexOpacityAndColor(a);let n=1;if(!this._fastUpdates?.visualVariables.size){const e=i[0]>i[1]?i[0]:i[1];n=this._getScaleFactor(a,e)}n*=this._symbolTextureRatio;const l=c(i[0]*n,i[1]*n),h=this.setGraphicElevationContext(t);return this.ensureDrapedStatus("on-the-ground"===h.mode)&&this._setDrapingDependentMaterialParameters(),this.draped?this._createAsOverlay(t,s,r,o,l,e.layer.uid):this._createAs3DShape(t,s,r,o,l,h,t.uid)}layerOpacityChanged(){const e=this._getFillColor(),t=this._getOutlineColor();this._forEachMaterial((r=>{r.setParameters({color:e}),r.setParameters({outlineColor:t})}))}layerElevationInfoChanged(e,t,r){const i=this._elevationContext.mode,s=P(te.elevationModeChangeTypes,r,i);if(s!==z.UPDATE)return s;const a=R(i)||"absolute-height"===i;return this.updateGraphics3DGraphicElevationInfo(e,t,(()=>a))}slicePlaneEnabledChanged(){return this.draped||this._forEachMaterial((e=>{e.setParameters({hasSlicePlane:this._context.slicePlaneEnabled})})),!0}physicalBasedRenderingChanged(){return!0}get pixelRatioChanged(){return null!=this._getPrimitive()}applyRendererDiff(e,t){for(const r in e.diff){if("visualVariables"!==r)return w.RecreateSymbol;if(!F(this._fastUpdates,t,this._fastVisualVariableConvertOptions()))return w.RecreateSymbol;null!=this._material&&this._material.setParameters(this._fastUpdates.materialParameters)}return w.FastUpdate}_defaultElevationInfoNoZ(){return se}_createAs3DShape(e,t,r,i,s,a,o){const n=this.getFastUpdateAttrValues(e),l=this._context.layer.uid,c=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:o,layerUid:l}),h=H(r,Z,null,i,s,ae,null,n,c),m=E(this._context,t,h,a,o);if(null==m)return null;const u=new M(this,m.object,[h],null,null,v,a);return u.alignedSampledElevation=m.sampledElevation,u.needsElevationUpdates=R(a.mode)||"absolute-height"===a.mode,u.getScreenSize=this._createScreenSizeGetter(s,n),u.calculateRelativeScreenBounds=e=>r.calculateRelativeScreenBounds(u.getScreenSize(),1,e),U(u,t,this._context.elevationProvider),u}_createAsOverlay(e,t,r,i,s,a){r.renderPriority=this._renderPriority;const o=_();p(t,o,this._context.overlaySR),o[2]=q;const n=this._context.clippingExtent;if(null!=n&&!f(n,o))return null;const l=this.getFastUpdateAttrValues(e),c=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:e.uid,layerUid:this._context.layer.uid}),h=H(r,Z,o,i,s,null,null,l,c),m=new W(h,{layerUid:a,graphicUid:e.uid}),u=new C(this,[m],null,this._context.drapeSourceRenderer);return u.getScreenSize=this._createScreenSizeGetter(s,l),u.calculateRelativeScreenBounds=e=>r.calculateRelativeScreenBounds(u.getScreenSize(),1,e),u}_createScreenSizeGetter(e,t){const r=this._outlineSize+2;if(this._fastUpdates&&t){const i=e[0]/this._symbolTextureRatio,s=e[1]/this._symbolTextureRatio;return(e=h())=>{const[a,o]=L(oe,this._fastUpdates.materialParameters,t);return e[0]=a*i+r,e[1]=o*s+r,e}}{const t=e[0]/this._symbolTextureRatio+r,i=e[1]/this._symbolTextureRatio+r;return(e=h())=>(e[0]=t,e[1]=i,e)}}_fastVisualVariableConvertOptions(){const e=Math.max(this._size[0],this._size[1]),t=u(e,e,e),r=n(1),i=e*r,s=u(i,i,i);return new A({size:!0,color:!0,rotation:!0,opacity:!1},t,s,r)}_getGraphicHash(e){let t="";for(const r of this._cimRequiredFields)t+=r+e.attributes[r];return t}_forEachMaterial(e){null!=this._material&&e(this._material),this._cimSymbolMaterials.forEach(e)}test(){return{...super.test(),material:this._material}}}function re(e){return e&&"point-3d"===e.type&&e.hasVisibleVerticalOffset()}function ie(e){return null!=e&&("cross"===e||"x"===e)}te.PRIMITIVE_SIZE=ee,te.elevationModeChangeTypes={definedChanged:z.UPDATE,staysOnTheGround:z.NONE,onTheGroundChanged:z.RECREATE};const se={mode:"relative-to-ground",offset:0},ae=d(0,0,0,1),oe=m();export{te as Graphics3DIconSymbolLayer};
5
+ import e from"../../../../Color.js";import"../../../../symbols.js";import{result as t}from"../../../../core/asyncUtils.js";import r from"../../../../core/Error.js";import{releaseMaybe as i}from"../../../../core/maybe.js";import{throwIfAbortError as s,throwIfAborted as a}from"../../../../core/promiseUtils.js";import{pt2px as o,px2pt as n}from"../../../../core/screenUtils.js";import{dataComponents as l}from"../../../../core/urlUtils.js";import{f as c,a as h}from"../../../../chunks/vec2f64.js";import{c as m,f as u}from"../../../../chunks/vec3f64.js";import{f as d,c as _}from"../../../../chunks/vec4f64.js";import{projectPointToVector as p}from"../../../../geometry/projection/projectPointToVector.js";import{containsPoint as f}from"../../../../geometry/support/aaBoundingBox.js";import{createRendererExpression as y}from"../../../../support/arcadeOnDemand.js";import{defaultPrimitive as g}from"../../../../symbols/support/IconSymbol3DLayerResource.js";import{getIconHref as x}from"../../../../symbols/support/utils.js";import S from"../../../2d/arcade/callExpressionWithFeature.js";import{TRANSPARENT_UNIT as b}from"./constants.js";import{perObjectElevationAligner as v}from"./ElevationAligners.js";import{SymbolUpdateType as z,elevationModeChangeUpdateType as P,needsElevationUpdates2D as R}from"./elevationAlignmentUtils.js";import{Graphics3DDrapedGraphicLayer as C}from"./Graphics3DDrapedGraphicLayer.js";import{Graphics3DObject3DGraphicLayer as M}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as I}from"./Graphics3DSymbolLayer.js";import{validateSymbolLayerSize as j}from"./graphicUtils.js";import{ApplyRendererDiffResult as w}from"./interfaces.js";import{namedAnchorToHUDMaterialAnchorPos as O}from"./placementUtils.js";import{placePointOnGeometry as E,createStageObject as T,extendPointGraphicElevationContext as U}from"./pointUtils.js";import{initFastSymbolUpdatesState as D,updateFastSymbolUpdatesState as F,evaluateModelTransformScale as L,ConvertOptions as A}from"../support/FastSymbolUpdates.js";import{createTexture as G,requiresHalfTexelOffset as V,DEFAULT_SYMBOL_SIZE_RATIO as B,DEFAULT_TEX_SIZE as H}from"../../support/engineContent/sdfPrimitives.js";import{DRAPED_Z as N}from"../../terrain/OverlayRenderer.js";import{createPointGeometry as q}from"../../webgl-engine/lib/GeometryUtil.js";import{RenderGeometry as W}from"../../webgl-engine/lib/RenderGeometry.js";import{Texture as k}from"../../webgl-engine/lib/Texture.js";import{HUDMaterial as $}from"../../webgl-engine/materials/HUDMaterial.js";import J from"../../../../symbols/CIMSymbol.js";const Z=u(0,0,1),K=16,Q=1.5,X=B,Y=[X/2,X/2,1-X/2,1-X/2],ee=[H*X,H*X];class te extends I{getCachedSize(){return{size:this._getIconSize()}}constructor(e,t,r,i){super(e,t,r,i),this._cimLayers=null,this._cimSymbolMaterials=new Map,this._cimSymbolTextures=new Map,this._cimMaterialParametersInfo=null,this._cimRequiredFields=null,this._cimScaleFactorOrFunction=null,this._size=null,this._symbolTextureRatio=1,this._outlineSize=0,this._elevationOptions={supportsOffsetAdjustment:!0,supportsOnTheGround:!0}}async doLoad(e){this._validateOrThrow();const t=this._prepareMaterialParameters(),r=this._getPrimitive();if(null!=r)this._prepareResourcesPrimitive(t,r);else{const r=x(this.symbolLayer),i=l(r);i&&"application/json"===i.mediaType?await this._prepareResourcesCIM(t,JSON.parse(i.data),e):await this._prepareResourcesHref(t,r,e)}}_validateOrThrow(){if(this._drivenProperties.size)return;const e=j(this._getIconSize());if(e)throw new r("graphics3diconsymbollayer:invalid-size",e)}_getIconSize(){const e=this.symbolLayer,t=Math.round(null!=e.size?o(e.size):K);return this._drivenProperties.size?Math.max(t,64):t}_generateTextureCIM(e){const t=this._getGraphicHash(e);let r=""===t?null:this._cimSymbolTextures.get(t);if(!r){const i={scaleFactor:this._cimScaleFactorOrFunction},s=this._context.sharedResources.cimSymbolRasterizer.rasterizeCIMSymbol3D(this._cimLayers,e,"esriGeometryPoint",i,void 0,void 0);this._cimMaterialParametersInfo.anchorPosition=this._getAnchorPos("relative",s.anchorPosition);const a={width:s.imageData.width,height:s.imageData.height};r=new k(s.imageData,a),this._cimSymbolTextures.set(t,r),this._context.stage.add(r)}return r}_prepareMaterialParameters(){const e={anchorPosition:this._getAnchorPos(this.symbolLayer.anchor,this.symbolLayer.anchorPosition)},t=this.symbol;if(re(t)){const{screenLength:r,minWorldLength:i,maxWorldLength:s}=t.verticalOffset;e.verticalOffset={screenLength:o(r),minWorldLength:i||0,maxWorldLength:null!=s?s:1/0}}return this._context.screenSizePerspectiveEnabled&&(e.screenSizePerspective=this._context.sharedResources.screenSizePerspectiveSettings),e.occlusionTest=!0,e.hasSlicePlane=this._context.slicePlaneEnabled,e}_prepareResourcesPrimitive(e,t){const r=this._getOutlineSize();if(ie(t)&&0===r)throw new Error("Nothing to render");if(this._outlineSize=r,e.color=this._getFillColor(),e.outlineColor=this._getOutlineColor(),e.outlineSize=this._outlineSize,null!=this._context.sharedResources.textures){const r=this._context.sharedResources.textures.fromData(`${t}-icon`,(()=>G(t)));this._textureHandle=r,e.textureId=r.texture.id}e.textureIsSignedDistanceField=!0,e.sampleSignedDistanceFieldTexelCenter=V(t),e.distanceFieldBoundingBox=Y;const i=this._getIconSize();this._size=[i,i],this._symbolTextureRatio=1/X,this._createMaterialAndAddToStage(e,this._context.stage)}async _prepareResourcesHref(e,i,a){this._outlineSize=this._getOutlineSize(),e.color=this._getFillColor(),e.outlineColor=this._getOutlineColor(),e.outlineSize=this._outlineSize,e.textureIsSignedDistanceField=!1;const o=this._getIconSize(),n=o*this._context.graphicsCoreOwner.view.state.rasterPixelRatio;if(null!=this._context.sharedResources.textures){const l=await t(this._context.sharedResources.textures.fromUrl(i,n,{signal:a}));if(!1===l.ok){s(l.error);throw new r("graphics3diconsymbollayer:request-failed",`Failed to load (Request for icon resource failed: ${i})`)}this._textureHandle=l.value;const c=l.value.texture,h=c.parameters.width/c.parameters.height;this._size=h>1?[o,Math.round(o/h)]:[Math.round(o*h),o],e.textureId=c.id}this._createMaterialAndAddToStage(e,this._context.stage)}async _prepareResourcesCIM(e,t,r){const i=new J({data:t});if(!this._context.sharedResources.cimSymbolRasterizer){const e=(await import("../../../../symbols/cim/CIMSymbolRasterizer.js")).CIMSymbolRasterizer;a(r),this._context.sharedResources.cimSymbolRasterizer||(this._context.sharedResources.cimSymbolRasterizer=new e(this._context.renderCoordsHelper.spatialReference,!0))}const s=this._context.layer.fields?this._context.layer.fields.map((e=>e.toJSON())):null;let o,n;if(this._cimLayers=await this._context.sharedResources.cimSymbolRasterizer.analyzeCIMSymbol3D(i,s,this._context.renderer&&"dictionary"===this._context.renderer.type?this._context.renderer.fieldMap:null,"esriGeometryPoint",{signal:r}),this._context.renderer&&"dictionary"===this._context.renderer.type&&this._context.renderer.scaleExpression){const e=this._context.renderer;if(isNaN(e.scaleExpression)){const t=e.scaleExpression,r=await y(t,this._context.layer.spatialReference,s);n=(e,t,i)=>{const s=S(r,e,{$view:i},"esriGeometryPoint",t);return null!==s?s:1}}else o=Number(e.scaleExpression)}this._cimScaleFactorOrFunction=o||n||1;const l=this._context.renderer?await this._context.renderer.getRequiredFields(this._context.layer.fieldsIndex):[];a(r);const c=this._context.layer.fieldsIndex;this._cimRequiredFields=l.map((e=>c.get(e).name)),this._cimMaterialParametersInfo=e,this._cimMaterialParametersInfo.color=this._getFillColor(),this._cimMaterialParametersInfo.outlineColor=[0,0,0,0],this._cimMaterialParametersInfo.outlineSize=0,this._cimMaterialParametersInfo.textureIsSignedDistanceField=!1}_getPrimitive(){return this.symbolLayer.resource&&this.symbolLayer.resource.href?null:this.symbolLayer.resource&&this.symbolLayer.resource.primitive||g}_getOutlineSize(){let e=0;const t=this.symbolLayer;if(null!=t.outline&&null!=t.outline.size)return Math.max(o(t.outline.size),0);return e=ie(this._getPrimitive())?Q:0,Math.max(e,0)}_getOutlineColor(){const t=this._getLayerOpacity(),r=this.symbolLayer,i=r?.outline?.color;if(null!=i){const r=e.toUnitRGB(i),s=i.a*t;return[r[0],r[1],r[2],s]}return[0,0,0,0]}_getFillColor(){if(ie(this._getPrimitive()))return b;const e=null==this._getPrimitive(),t=this.symbolLayer?.material?.color;return this._getCombinedOpacityAndColor(t,{hasIntrinsicColor:e})}_getAnchorPos(e,t){return"relative"===e?c((t.x||0)+.5,.5-(t.y||0)):e in O?O[e]:O.center}_createMaterialAndAddToStage(e,t){if(this._cimLayers){this._fastUpdates=null;let r=e.textureId?this._cimSymbolMaterials.get(e.textureId):null;return r||(r=new $(e),this._cimSymbolMaterials.set(e.textureId??0,r),t.add(r)),r}return this._fastUpdates=D(this._context.renderer,this._fastVisualVariableConvertOptions()),this._fastUpdates&&(e={...e,...this._fastUpdates.materialParameters}),this._material=new $(e),t.add(this._material),this._material}_setDrapingDependentMaterialParameters(){this.draped&&(this._forEachMaterial((e=>{e.setParameters({verticalOffset:null,screenSizePerspective:null,occlusionTest:!1,hasSlicePlane:!1,shaderPolygonOffset:0,isDraped:this.draped})})),this.layerOpacityChanged())}destroy(){super.destroy(),this._forEachMaterial((e=>this._context.stage.remove(e))),this._material=null,this._cimSymbolMaterials.clear(),this._cimSymbolTextures.forEach((e=>this._context.stage.remove(e))),this._cimSymbolTextures.clear(),this._textureHandle=i(this._textureHandle)}_getScaleFactor(e,t){if(this._drivenProperties.size&&e.size){for(let t=0;t<3;t++){const r=e.size[t];r&&"symbol-value"!==r&&"proportional"!==r&&(e.size[t]=o(r))}if("symbol-value"===e.size[0])return 1;if(isFinite(+e.size[0]))return+e.size[0]/t;if(isFinite(+e.size[2]))return+e.size[2]/t}return 1}createGraphics3DGraphic(e){const t=e.graphic;if(!this._validateGeometry(t.geometry))return null;let r,i=[0,0];if(this._cimLayers){if(!this._cimLayers.length)return null;const e=this._generateTextureCIM(t),s={textureId:e.id,...this._cimMaterialParametersInfo};r=this._createMaterialAndAddToStage(s,this._context.stage),i=[e.parameters.width,e.parameters.height]}else i=this._size,r=this._material;const s=E(t.geometry);if(null==s)return this.logger.warn(`unsupported geometry type for icon symbol: ${t.geometry.type}`),null;const a=e.renderingInfo,o=this._getVertexOpacityAndColor(a);let n=1;if(!this._fastUpdates?.visualVariables.size){const e=i[0]>i[1]?i[0]:i[1];n=this._getScaleFactor(a,e)}n*=this._symbolTextureRatio;const l=c(i[0]*n,i[1]*n),h=this.setGraphicElevationContext(t);return this.ensureDrapedStatus("on-the-ground"===h.mode)&&this._setDrapingDependentMaterialParameters(),this.draped?this._createAsOverlay(t,s,r,o,l,e.layer.uid):this._createAs3DShape(t,s,r,o,l,h,t.uid)}layerOpacityChanged(){const e=this._getFillColor(),t=this._getOutlineColor();this._forEachMaterial((r=>{r.setParameters({color:e}),r.setParameters({outlineColor:t})}))}layerElevationInfoChanged(e,t,r){const i=this._elevationContext.mode,s=P(te.elevationModeChangeTypes,r,i);if(s!==z.UPDATE)return s;const a=R(i)||"absolute-height"===i;return this.updateGraphics3DGraphicElevationInfo(e,t,(()=>a))}slicePlaneEnabledChanged(){return this.draped||this._forEachMaterial((e=>{e.setParameters({hasSlicePlane:this._context.slicePlaneEnabled})})),!0}physicalBasedRenderingChanged(){return!0}get pixelRatioChanged(){return null!=this._getPrimitive()}applyRendererDiff(e,t){for(const r in e.diff){if("visualVariables"!==r)return w.RecreateSymbol;if(!F(this._fastUpdates,t,this._fastVisualVariableConvertOptions()))return w.RecreateSymbol;null!=this._material&&this._material.setParameters(this._fastUpdates.materialParameters)}return w.FastUpdate}_defaultElevationInfoNoZ(){return se}_createAs3DShape(e,t,r,i,s,a,o){const n=this.getFastUpdateAttrValues(e),l=this._context.layer.uid,c=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:o,layerUid:l}),h=q(r,Z,null,i,s,ae,null,n,c),m=T(this._context,t,h,a,o);if(null==m)return null;const u=new M(this,m.object,[h],null,null,v,a);return u.alignedSampledElevation=m.sampledElevation,u.needsElevationUpdates=R(a.mode)||"absolute-height"===a.mode,u.getScreenSize=this._createScreenSizeGetter(s,n),u.calculateRelativeScreenBounds=e=>r.calculateRelativeScreenBounds(u.getScreenSize(),1,e),U(u,t,this._context.elevationProvider),u}_createAsOverlay(e,t,r,i,s,a){r.renderPriority=this._renderPriority;const o=_();p(t,o,this._context.overlaySR),o[2]=N;const n=this._context.clippingExtent;if(null!=n&&!f(n,o))return null;const l=this.getFastUpdateAttrValues(e),c=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:e.uid,layerUid:this._context.layer.uid}),h=q(r,Z,o,i,s,null,null,l,c),m=new W(h,{layerUid:a,graphicUid:e.uid}),u=new C(this,[m],null,this._context.drapeSourceRenderer);return u.getScreenSize=this._createScreenSizeGetter(s,l),u.calculateRelativeScreenBounds=e=>r.calculateRelativeScreenBounds(u.getScreenSize(),1,e),u}_createScreenSizeGetter(e,t){const r=this._outlineSize+2;if(this._fastUpdates&&t){const i=e[0]/this._symbolTextureRatio,s=e[1]/this._symbolTextureRatio;return(e=h())=>{const[a,o]=L(oe,this._fastUpdates.materialParameters,t);return e[0]=a*i+r,e[1]=o*s+r,e}}{const t=e[0]/this._symbolTextureRatio+r,i=e[1]/this._symbolTextureRatio+r;return(e=h())=>(e[0]=t,e[1]=i,e)}}_fastVisualVariableConvertOptions(){const e=Math.max(this._size[0],this._size[1]),t=u(e,e,e),r=n(1),i=e*r,s=u(i,i,i);return new A({size:!0,color:!0,rotation:!0,opacity:!1},t,s,r)}_getGraphicHash(e){let t="";for(const r of this._cimRequiredFields)t+=r+e.attributes[r];return t}_forEachMaterial(e){null!=this._material&&e(this._material),this._cimSymbolMaterials.forEach(e)}test(){return{...super.test(),material:this._material}}}function re(e){return e&&"point-3d"===e.type&&e.hasVisibleVerticalOffset()}function ie(e){return null!=e&&("cross"===e||"x"===e)}te.PRIMITIVE_SIZE=ee,te.elevationModeChangeTypes={definedChanged:z.UPDATE,staysOnTheGround:z.NONE,onTheGroundChanged:z.RECREATE};const se={mode:"relative-to-ground",offset:0},ae=d(0,0,0,1),oe=m();export{te as Graphics3DIconSymbolLayer};
@@ -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"../../../../core/has.js";import{deg2rad as t}from"../../../../core/mathUtils.js";import{f as r,t as o}from"../../../../chunks/mat3.js";import{c as a}from"../../../../chunks/mat3f64.js";import{f as n,m as s,a as i}from"../../../../chunks/mat4.js";import{c as l,I as c,b as u}from"../../../../chunks/mat4f64.js";import{s as m,e as h,b as f,d as p,n as d,g,c as x}from"../../../../chunks/vec3.js";import{Z as _,O as T,c as y}from"../../../../chunks/vec3f64.js";import{O as b}from"../../../../chunks/vec4f64.js";import{canProjectWithoutEngine as v}from"../../../../geometry/projection.js";import{computeTranslationToOriginAndRotation as C}from"../../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{projectBuffer as O}from"../../../../geometry/projection/projectBuffer.js";import{projectVectorToDehydratedPoint as j}from"../../../../geometry/projection/projectVectorToDehydratedPoint.js";import{create as w,empty as M,expandWithBuffer as P,intersectsClippingArea as R}from"../../../../geometry/support/aaBoundingBox.js";import{newFloatArray as A}from"../../../../geometry/support/FloatArray.js";import{getContinuousIndexArray as I,getZeroIndexArray as N}from"../../../../geometry/support/Indices.js";import E from"../../../../geometry/support/MeshComponent.js";import S from"../../../../geometry/support/MeshMaterialMetallicRoughness.js";import B from"../../../../geometry/support/MeshTextureTransform.js";import{t as F,a as U}from"../../../../chunks/vec32.js";import{project as L}from"../../../../geometry/support/meshUtils/georeference.js";import{transformNormal as $,projectNormalToPCPF as G,transformTangent as V,projectTangentToPCPF as D}from"../../../../geometry/support/meshUtils/projection.js";import{makeDehydratedPoint as k}from"../../../../layers/graphics/dehydratedPoint.js";import{MeshTransformUpdateAction as H}from"../../../../layers/graphics/sources/interfaces.js";import{ViewingMode as q}from"../../../ViewingMode.js";import{isEncodedMeshTexture as W}from"../../glTF/internal/resourceUtils.js";import{getTransformMatrix as z}from"../../glTF/internal/TextureTransformUtils.js";import{perObjectElevationAligner as Y}from"./ElevationAligners.js";import{needsElevationUpdates3D as Z,evaluateElevationInfoAtPoint as J}from"./elevationAlignmentUtils.js";import{Graphics3DMeshObject3DGraphicLayer as K}from"./Graphics3DMeshObject3DGraphicLayer.js";import{Object3DEdgeState as Q}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as X}from"./Graphics3DSymbolLayer.js";import{MaterialInfoCache as ee,MeshFastUpdateProcessor as te}from"./MeshFastUpdateProcessor.js";import{createMaterial as re}from"../support/edgeUtils.js";import{parseColorMixMode as oe,encodeSymbolColor as ae}from"../support/symbolColorUtils.js";import{debugFlags as ne}from"../../support/debugFlags.js";import{Attribute as se}from"../../webgl-engine/lib/Attribute.js";import{AlphaDiscardMode as ie,CullFaceOptions as le}from"../../webgl-engine/lib/basicInterfaces.js";import{ContentObjectType as ce}from"../../webgl-engine/lib/ContentObjectType.js";import{Geometry as ue}from"../../webgl-engine/lib/Geometry.js";import{Object3D as me}from"../../webgl-engine/lib/Object3D.js";import{Texture as he}from"../../webgl-engine/lib/Texture.js";import{VertexAttribute as fe}from"../../webgl-engine/lib/VertexAttribute.js";import{DefaultMaterial as pe}from"../../webgl-engine/materials/DefaultMaterial.js";import{NativeLineMaterial as de}from"../../webgl-engine/materials/NativeLineMaterial.js";import{useSchematicPBR as ge,defaultSchematicMRRFactors as xe,defaultAdvancedMRRFactors as _e}from"../../webgl-engine/materials/pbrUtils.js";import{TextureWrapMode as Te}from"../../../webgl/enums.js";const ye=["mesh"];class be extends X{constructor(e,t,r,o){super(e,t,r,o),this._materialInfoCache=new ee,this._fastUpdateProcessor=new te,this._textures=new Map,this.ensureDrapedStatus(!1)}async doLoad(){ne.DRAW_MESH_GEOMETRY_NORMALS&&(this._debugVertexNormalMaterial=new de({color:[1,0,1,1]}),this._debugFaceNormalMaterial=new de({color:[0,1,1,1]}))}destroy(){super.destroy(),this._context.stage.removeMany(this._materialInfoCache.materials),this._context.stage.removeMany(Array.from(this._textures.values())),this._materialInfoCache.clear(),this._textures.clear(),this._fastUpdateProcessor.destroy(this._context.stage)}createGraphics3DGraphic(e){const t=e.graphic;if(!this._validateGeometry(t.geometry,ye,"fill on mesh-3d"))return null;const r=this.setGraphicElevationContext(t),o=e.renderingInfo;return this._createAs3DShape(t,o,r,t.uid)}onRemoveGraphic(e){this._fastUpdateProcessor.onRemoveGraphic(e,this._materialInfoCache,this._context)}layerOpacityChanged(e,t){const r=this._getLayerOpacity();this._updateMaterialParameters((e=>{e.material.setParameters({layerOpacity:r});const t=e.material.parameters;this._setMaterialTransparentParameter(t,e),e.material.setParameters({transparent:t.transparent})})),e.forEach((e=>{const o=t(e);null!=o&&o.layerOpacityChanged(r,this._context.isAsync)}))}layerElevationInfoChanged(e,t){return this.updateGraphics3DGraphicElevationInfo(e,t,Z)}slicePlaneEnabledChanged(e,t){return this._updateMaterialParameters((({material:e})=>{e.setParameters({hasSlicePlane:this._context.slicePlaneEnabled})})),e.forEach((e=>{const r=t(e);null!=r&&r.slicePlaneEnabledChanged(this._context.slicePlaneEnabled,this._context.isAsync)})),!0}physicalBasedRenderingChanged(){const e=this._usePBR();return this._updateMaterialParameters((({material:t})=>t.setParameters({usePBR:e}))),!0}updateTransform(e,t,r,o){const a=this._context.renderCoordsHelper.spatialReference,n=Ae,{origin:s,transform:i}=r;switch(C(t,m(Oe,s.x,s.y,s.z??0),n,a),o){case H.EnableFastUpdates:this._fastUpdateProcessor.enable(e,this._materialInfoCache,this._context);break;case H.DisableFastUpdates:this._fastUpdateProcessor.disable(e,this._materialInfoCache,this._context);break;case H.UpdateFastLocalOrigin:e.updateFastLocalOrigin(n,i,this._context.localOriginFactory)}const{elevationContext:l}=e;l.centerPointInElevationSR=this._getCenterPointInElevationSR(n);const{elevationProvider:c,renderCoordsHelper:u}=this._context,h=(e,t)=>J(e,c,l,u,t);return e.alignedSampledElevation=Y(e,l,c.spatialReference,h,u,n),e.updateTransform(n,i,this._context.isAsync),!0}_requiresSymbolVertexColors(){return this._drivenProperties.color||this._drivenProperties.opacity}_colorOrTextureUid(t){return null==t?"-":t instanceof e?t.toHex():t.contentHash}_materialPropertiesDefault(e,t){const r=this._requiresSymbolVertexColors(),o=!!e.vertexAttributes.color,a=!!e.vertexAttributes.tangent;return{hasSymbolVertexColors:r,hasVertexColors:o,hasVertexTangents:a,uid:`vc:${o},vt:${a},vct${t},svc:${r}`}}_textureTransformUid(e){const{offset:t,scale:r,rotation:o}=e??Ee;return`${t[0]},${t[1]},${o},${r[0]},${r[1]}`}_materialProperties(e,t,r){const o=this._materialPropertiesDefault(e,r);if(!t.material)return o;const{color:a,colorTexture:n,colorTextureTransform:s,normalTexture:i,normalTextureTransform:l,doubleSided:c,alphaCutoff:u,alphaMode:m}=t.material,h=this._colorOrTextureUid(a),f=this._colorOrTextureUid(n),p=this._textureTransformUid(s),d=this._colorOrTextureUid(i),g=this._textureTransformUid(l);if(o.color=a,o.colorTexture=n,o.normalTexture=i,o.uid=`${o.uid},cmuid:${h},ctmuid:${f},cttuid:${p},ntmuid:${d},nttuid:${g},ds:${c},ac:${u},am:${m}`,t.material instanceof S){const{metallic:e,roughness:r,metallicRoughnessTexture:a,metallicRoughnessTextureTransform:n,emissiveColor:i,emissiveTexture:c,emissiveTextureTransform:u,occlusionTexture:m,occlusionTextureTransform:h}=t.material,f=this._colorOrTextureUid(a),p=this._textureTransformUid(n),d=this._colorOrTextureUid(i),g=this._colorOrTextureUid(c),x=this._textureTransformUid(u),_=this._colorOrTextureUid(m),T=this._textureTransformUid(h);o.metallic=e,o.roughness=r,o.metallicRoughnessTexture=a,o.emissiveColor=i,o.emissiveTexture=c,o.occlusionTexture=m,o.colorTextureTransform=this._convertTextureTransform(s),o.normalTextureTransform=this._convertTextureTransform(l),o.emissiveTextureTransform=this._convertTextureTransform(u),o.occlusionTextureTransform=this._convertTextureTransform(h),o.metallicRoughnessTextureTransform=this._convertTextureTransform(n),o.uid=`${o.uid},mrm:${e},mrr:${r},mrt:${f},mrtt:${p},emuid:${d},etmuid:${g},ett:${x},otmuid:${_},ott:${T}`}return o}_convertTextureTransform(e){if(!e)return null;const{scale:r,offset:o,rotation:a}=e;return{scale:r,offset:o,rotation:t(a)}}_setInternalColorValueParameters(t,r){r.diffuse=e.toUnitRGB(t),r.opacity=t.a}_getLoadableTextureResource(e){return e.data?e.data:e.url}_getInternalTextureId(e){const t=this._getInternalTexture(e,ie.Opaque);return null!=t?t.id:null}_getInternalTexture(e,t){const r=this._getLoadableTextureResource(e);if(!r)return null;const o=`${e.contentHash}/${t}`;let a=this._textures.get(o);return a||(a=new he(W(r)?r.data:r,{mipmap:!0,wrap:this._castTextureWrap(e.wrap),noUnpackFlip:!0,preMultiplyAlpha:!W(r)&&t!==ie.Opaque,encoding:W(r)&&null!=r.encoding?r.encoding:void 0}),this._textures.set(o,a),this._context.stage.add(a),this._context.stage.loadImmediate(a)),a}_castTextureWrap(e="repeat"){if("string"==typeof e){const t=this._castTextureWrapIndividual(e);return{s:t,t}}return{s:this._castTextureWrapIndividual(e.horizontal),t:this._castTextureWrapIndividual(e.vertical)}}_castTextureWrapIndividual(e){switch(e){case"clamp":return Te.CLAMP_TO_EDGE;case"mirror":return Te.MIRRORED_REPEAT;default:return Te.REPEAT}}_setInternalMaterialParameters(t,r){if(null!=t.color&&this._setInternalColorValueParameters(t.color,r),null!=t.colorTexture){const e=this._getInternalTexture(t.colorTexture,r.textureAlphaMode);null!=e?(r.textureId=e.id,r.textureAlphaPremultiplied=!!e.parameters.preMultiplyAlpha):r.textureId=void 0}null!=t.normalTexture&&(r.normalTextureId=this._getInternalTextureId(t.normalTexture)),null!=t.emissiveColor&&(r.emissiveFactor=e.toUnitRGB(t.emissiveColor)),null!=t.emissiveTexture&&(r.emissiveTextureId=this._getInternalTextureId(t.emissiveTexture)),null!=t.occlusionTexture&&(r.occlusionTextureId=this._getInternalTextureId(t.occlusionTexture)),null!=t.metallicRoughnessTexture&&(r.metallicRoughnessTextureId=this._getInternalTextureId(t.metallicRoughnessTexture)),r.colorTextureTransformMatrix=z(t.colorTextureTransform),r.normalTextureTransformMatrix=z(t.normalTextureTransform),r.occlusionTextureTransformMatrix=z(t.occlusionTextureTransform),r.emissiveTextureTransformMatrix=z(t.emissiveTextureTransform),r.metallicRoughnessTextureTransformMatrix=z(t.metallicRoughnessTextureTransform)}_setExternalMaterialParameters(t){const r=this._drivenProperties.color;let o=null!=this.symbolLayer.material?this.symbolLayer.material.colorMixMode:null;if(r)t.externalColor=b;else{const r=null!=this.symbolLayer.material?this.symbolLayer.material.color:null;null!=r?t.externalColor=e.toUnitRGBA(r):(o=null,t.externalColor=b)}o&&(t.colorMixMode=o),t.castShadows=!!this.symbolLayer.castShadows}_hasTransparentVertexColors(e){const t=e.vertexAttributes.color;if(null==t)return!1;for(let r=3;r<t.length;r+=4)if(255!==t[r])return!0;return!1}_getOrCreateMaterial(t,r){const o=r.material?.color,a=r.material?.colorTexture,n=r.material?.alphaMode,s="blend"===n,i=!("opaque"===n)&&(this._hasTransparentVertexColors(t)||null!=o&&o.a<1||null!=a&&a.transparent||s),l=this._materialProperties(t,r,i),c=this._materialInfoCache.byUid(l.uid);if(c)return c.material;const u={uid:l.uid,material:null,isComponentTransparent:i,alphaMode:r.material?r.material.alphaMode:"opaque"},m=ge({normalTexture:l.normalTexture,metallicRoughnessTexture:l.metallicRoughnessTexture,metallicFactor:l.metallic,roughnessFactor:l.roughness,emissiveTexture:l.emissiveTexture,emissiveFactor:e.toUnitRGB(l.emissiveColor),occlusionTexture:l.occlusionTexture}),h={usePBR:this._usePBR(),isSchematic:m,hasVertexColors:l.hasVertexColors,hasSymbolColors:l.hasSymbolVertexColors,hasVertexTangents:l.hasVertexTangents,ambient:_,diffuse:T,opacity:1,doubleSided:!0,doubleSidedType:"winding-order",cullFace:le.None,layerOpacity:this._getLayerOpacity(),hasSlicePlane:this._context.slicePlaneEnabled,initTextureTransparent:!0};h.mrrFactors=m?[...xe]:[l.metallic,l.roughness,_e[2]],r.material&&(h.doubleSided=r.material.doubleSided,h.cullFace=r.material.doubleSided?le.None:le.Back,h.textureAlphaCutoff=r.material.alphaCutoff),this._setExternalMaterialParameters(h),this._setMaterialTransparentParameter(h,u),this._setInternalMaterialParameters(l,h);const f=new pe(h);return u.material=f,this._materialInfoCache.set(l.uid,u),this._context.stage.add(f),f}_usePBR(){return this._context.physicalBasedRenderingEnabled}_setMaterialTransparentParameter(e,t){e.transparent=this.needsDrivenTransparentPass||t.isComponentTransparent||e.layerOpacity<1||e.opacity<1||e.externalColor&&e.externalColor[3]<1,"auto"===t.alphaMode?e.textureAlphaMode=e.transparent?ie.MaskBlend:ie.Opaque:e.textureAlphaMode="opaque"===t.alphaMode?ie.Opaque:"mask"===t.alphaMode?ie.Mask:ie.Blend}_addDebugNormals(e,t){const r=t.length,o=e.spatialReference.isGeographic?20015077/180:1,a=.1*Math.max(e.extent.width*o,e.extent.height*o,e.extent.zmax-e.extent.zmin),n=[],s=[],i=[],l=[];for(let p=0;p<r;p++){const e=t[p],r=e.vertexAttributes.get(fe.POSITION),o=e.vertexAttributes.get(fe.NORMAL),c=e.indices.get(fe.POSITION),u=e.indices.get(fe.NORMAL),m=r.data,d=o.data;for(let t=0;t<c.length;t++){const e=3*c[t],r=3*u[t];for(let t=0;t<3;t++)n.push(m[e+t]);for(let t=0;t<3;t++)n.push(m[e+t]+d[r+t]*a);if(s.push(s.length),s.push(s.length),t%3==0){this._calculateFaceNormal(m,c,t,Me),this._getFaceVertices(m,c,t,Oe,je,we),h(Oe,Oe,je),h(Oe,Oe,we),f(Oe,Oe,1/3);for(let e=0;e<3;e++)i.push(Oe[e]);for(let e=0;e<3;e++)i.push(Oe[e]+Me[e]*a);l.push(l.length),l.push(l.length)}}}const c=t[0].transformation,u=new ue(this._debugVertexNormalMaterial,[[fe.POSITION,new se(n,3,!0)]],[[fe.POSITION,s]],null,ce.Line);t.push(u),u.transformation=c;const m=new ue(this._debugFaceNormalMaterial,[[fe.POSITION,new se(i,3,!0)]],[[fe.POSITION,l]],null,ce.Line);m.transformation=c,t.push(m)}_createAs3DShape(e,t,r,o){const a=e.geometry;if("mesh"!==a.type)return null;const n=this._createGeometryInfo(a,t,o);if(null==n)return null;const{geometries:s,objectTransformation:i}=n;ne.DRAW_MESH_GEOMETRY_NORMALS&&this._addDebugNormals(a,s);const l=new me({geometries:s,layerUid:this._context.layer.uid,graphicUid:o});l.transformation=i;const c=re(this.symbolLayer,{opacity:this._getLayerOpacity()}),u=null!=c?new Q(s[0].material,[c],{mergeGeometries:!0,hasSlicePlane:this._context.slicePlaneEnabled}):null,m=new K(this,l,s,null,null,Y,r,u);this._fastUpdateProcessor.onAddGraphic(),m.needsElevationUpdates=Z(r.mode),m.useObjectOriginAsAttachmentOrigin=!0,r.centerPointInElevationSR=this._getCenterPointInElevationSR(l.transformation);const{elevationProvider:h,renderCoordsHelper:f}=this._context,p=(e,t)=>J(e,h,r,f,t);return m.alignedSampledElevation=Y(m,r,h.spatialReference,p,f),m}_getCenterPointInElevationSR(e){const t=k(0,0,0,null!=this._context.elevationProvider.spatialReference?this._context.elevationProvider.spatialReference:null);return j([e[12],e[13],e[14]],this._context.renderCoordsHelper.spatialReference,t),t}_createComponentNormals(e,t,r,o){switch(r.shading||"flat"){default:case"source":return this._createComponentNormalsSource(e,t,r,o);case"flat":return this._createComponentNormalsFlat(e,o);case"smooth":return this._createComponentNormalsSmooth(e,o)}}_createComponentNormalsSource(e,t,r,o){if(null==t)return this._createComponentNormalsFlat(e,o);let a=!1;if(!r.trustSourceNormals)for(let n=0;n<o.length;n+=3){this._calculateFaceNormal(e,o,n,Me);for(let e=0;e<3;e++){const r=3*o[n+e];Oe[0]=t[r],Oe[1]=t[r+1],Oe[2]=t[r+2],p(Me,Oe)<0&&(t[r]=-t[r],t[r+1]=-t[r+1],t[r+2]=-t[r+2],a=!0)}}return new ve(t,o,a)}_createComponentNormalsFlat(e,t){const r=A(t.length),o=new Array(3*t.length);for(let a=0;a<t.length;a+=3){const n=this._calculateFaceNormal(e,t,a,Me);for(let e=0;e<3;e++)r[a+e]=n[e],o[a+e]=a/3}return new ve(r,o,!1)}_createComponentNormalsSmooth(e,t){const r={};for(let n=0;n<t.length;n+=3){const o=this._calculateFaceNormal(e,t,n,Me);for(let e=0;e<3;e++){const a=t[n+e];let s=r[a];s||(s={normal:y(),count:0},r[a]=s),h(s.normal,s.normal,o),s.count++}}const o=A(3*t.length),a=new Array(3*t.length);for(let n=0;n<t.length;n++){const e=r[t[n]];1!==e.count&&(d(e.normal,e.normal),e.count=1);for(let t=0;t<3;t++)o[3*n+t]=e.normal[t];a[n]=n}return new ve(o,a,!1)}_getFaceVertices(e,t,r,o,a,n){const s=3*t[r],i=3*t[r+1],l=3*t[r+2];o[0]=e[s],o[1]=e[s+1],o[2]=e[s+2],a[0]=e[i],a[1]=e[i+1],a[2]=e[i+2],n[0]=e[l],n[1]=e[l+1],n[2]=e[l+2]}_calculateFaceNormal(e,t,r,o){return this._getFaceVertices(e,t,r,Oe,je,we),g(je,je,Oe),g(we,we,Oe),x(Oe,je,we),d(o,Oe),o}_getOrCreateComponents(e){return e.components??Ne}_createPositionBuffer(e,t){let r=e.vertexAttributes.position;const o=t.reprojection===Se.ECEF?t.transformBeforeProject:null;if(null!=o&&(r=F(new Float64Array(r.length),r,o)),t.reprojection===Se.NONE)return t.needsBufferCopy?new Float64Array(r):r;const a=null!=o?r:new Float64Array(r.length);return O(r,e.spatialReference,0,a,this._context.renderCoordsHelper.spatialReference,0,r.length/3),a}_createNormalBuffer(e,t,r){let o=e.vertexAttributes.normal;if(null==o)return null;const a=r.reprojection===Se.ECEF?r.transformBeforeProject:null;null!=a&&(o=$(o,new Float32Array(o.length),a));if("local"===this._context.graphicsCoreOwner.view.viewingMode||r.reprojection===Se.NONE)return r.needsBufferCopy&&e.vertexAttributes.normal===o?new Float32Array(o):o;const n=e.vertexAttributes.position,s=null!=a?o:new Float32Array(o.length);return G(o,n,t,e.spatialReference,s)}_createTangentBuffer(e,t,r){let o=e.vertexAttributes.tangent;if(null==o)return null;const a=r.reprojection===Se.ECEF?r.transformBeforeProject:null;null!=a&&(o=V(o,new Float32Array(o.length),a));if("local"===this._context.graphicsCoreOwner.view.viewingMode||r.reprojection===Se.NONE)return r.needsBufferCopy&&e.vertexAttributes.normal===o?new Float32Array(o):o;const n=e.vertexAttributes.position,s=null!=a?o:new Float32Array(o.length);return D(o,n,t,e.spatialReference,s)}_createColorBuffer(e){return e.vertexAttributes.color}_createSymbolColorBuffer(e){if(this._requiresSymbolVertexColors()){const t=this._getVertexOpacityAndColor(e),r=oe(this.symbolLayer?.material?.colorMixMode),o=new Uint8Array(4);return ae(t,r,o),o}return null}_createBuffers(e,t){const r=e.vertexAttributes&&e.vertexAttributes.position;if(!r)return this.logger.warn("Mesh geometry must contain position vertex attributes"),null;const o=e.vertexAttributes.normal,a=e.vertexAttributes.uv,n=e.vertexAttributes.tangent;if(null!=o&&o.length!==r.length)return this.logger.warn("Mesh normal vertex buffer must contain the same number of elements as the position buffer"),null;if(null!=n&&n.length/4!=r.length/3)return this.logger.warn("Mesh tangent vertex buffer must contain the same number of elements as the position buffer"),null;if(null!=a&&a.length/2!=r.length/3)return this.logger.warn("Mesh uv vertex buffer must contain the same number of elements as the position buffer"),null;const s=this._computeReprojectionInfo(e),i=this._createPositionBuffer(e,s),c=this._createColorBuffer(e),u=this._createSymbolColorBuffer(t),m=this._createNormalBuffer(e,i,s),h=this._createTangentBuffer(e,i,s);return{positionBuffer:i,normalBuffer:m,tangentBuffer:h,uvBuffer:a,colorBuffer:c,symbolColorBuffer:u,objectTransformation:s.reprojection===Se.NONE&&null!=s.objectTransformation?s.objectTransformation:this._transformOriginLocal(e,i,m,h),geometryTransformation:s.reprojection===Se.NONE&&null!=s.geometryTransformation?s.geometryTransformation:l()}}_computeReprojectionInfo(e){const{vertexSpace:t}=e,r=t.isRelative,o=t.isGeoreferenced?this._context.renderCoordsHelper.viewingMode===q.Local?Se.NONE:Se.ECEF:Se.NONE;if(r){const{origin:r}=t,a=l(),i=e.transform?.localMatrix??c;if(o===Se.NONE){C(e.spatialReference,r,a,this._context.renderCoordsHelper.spatialReference);return{reprojection:o,objectTransformation:a,geometryTransformation:u(i),needsBufferCopy:!1}}const m=n(l(),r);return s(m,m,i),{reprojection:o,transformBeforeProject:m,needsBufferCopy:!0}}return{reprojection:o,needsBufferCopy:!0}}_transformOriginLocal(e,t,a,n){const s=this._context.renderCoordsHelper.spatialReference,c=e.anchor;Ce[0]=c.x,Ce[1]=c.y,Ce[2]=c.z??0;const u=l();return C(e.spatialReference,Ce,u,s),i(Pe,u),F(t,t,Pe),null==a&&null==n||(r(Re,u),o(Re,Re),null!=a&&U(a,a,Re),null!=n&&U(n,n,Re,4)),u}_validateFaces(e,t){const r=e.vertexAttributes.position.length/3,o=t.faces;if(o){let e=-1;for(let t=0;t<o.length;t++){const r=o[t];r>e&&(e=r)}if(r<=e)return this.logger.warn(`Vertex index ${e} is out of bounds of the mesh position buffer`),!1}else if(r%3!=0)return this.logger.warn("Mesh position buffer length must be a multiple of 9 if no component faces are defined (3 values per vertex * 3 vertices per triangle)"),!1;return!0}_getOrCreateFaces(e,t){return t.faces??I(e.vertexAttributes.position.length/3)}_isOutsideClippingArea(e){if(!this._context.clippingExtent)return!1;const t=e.vertexAttributes?.position;if(!t)return!1;const r=this._context.elevationProvider.spatialReference,o=L({positions:t,transform:e.transform,vertexSpace:e.vertexSpace,inSpatialReference:e.spatialReference,outSpatialReference:r??e.spatialReference}),a=o.length/3;return M(Ie),P(Ie,o,0,a),!R(Ie,this._context.clippingExtent)}_createGeometryInfo(e,t,r){if(!v(e.spatialReference,this._context.graphicsCoreOwner.view.spatialReference))return this.logger.warn("Geometry spatial reference is not compatible with the view"),null;if(this._isOutsideClippingArea(e))return null;const o=this._createBuffers(e,t);if(null==o)return null;const{positionBuffer:a,uvBuffer:n,colorBuffer:s,symbolColorBuffer:i,normalBuffer:l,tangentBuffer:c,objectTransformation:u,geometryTransformation:m}=o,h=this._getOrCreateComponents(e),f=new Array;let p=!1;for(const d of h){if(!this._validateFaces(e,d))return null;const t=this._getOrCreateFaces(e,d);if(0===t.length)continue;const o=this._createComponentNormals(a,l,d,t);o.didFlipNormals&&(p=!0);const u=[[fe.POSITION,new se(a,3,!0)],[fe.NORMAL,new se(o.normals,3,!0)]],h=[[fe.POSITION,t],[fe.NORMAL,o.indices]];null!=s&&(u.push([fe.COLOR,new se(s,4,!0)]),h.push([fe.COLOR,t])),null!=i&&(u.push([fe.SYMBOLCOLOR,new se(i,4,!0)]),h.push([fe.SYMBOLCOLOR,N(t.length)])),null!=n&&(u.push([fe.UV0,new se(n,2,!0)]),h.push([fe.UV0,t])),null!=c&&(u.push([fe.TANGENT,new se(c,4,!0)]),h.push([fe.TANGENT,t]));const g=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:r,layerUid:this._context.layer.uid}),x=this._getOrCreateMaterial(e,d),_=new ue(x,u,h,null,ce.Mesh,g);_.transformation=m,f.push(_)}return p&&this.logger.warn("Normals have been automatically flipped to be consistent with the counter clock wise face winding order. It is better to generate mesh geometries that have consistent normals."),{geometries:f,objectTransformation:u}}_updateMaterialParameters(e){this._materialInfoCache.forEachMaterialInfo(e),this._fastUpdateProcessor.forEachMaterialInfo(e),this._fastUpdateProcessor.forEachClonedMaterial(((e,t)=>{t.setParameters(e.parameters)}))}test(){return{...super.test(),materials:this._materialInfoCache.materials}}}class ve{constructor(e,t,r){this.normals=e,this.indices=t,this.didFlipNormals=r}}const Ce=y(),Oe=y(),je=y(),we=y(),Me=y(),Pe=l(),Re=a(),Ae=l(),Ie=w(),Ne=[new E],Ee=new B;var Se;!function(e){e[e.NONE=0]="NONE",e[e.ECEF=1]="ECEF"}(Se||(Se={}));export{be as Graphics3DMeshFillSymbolLayer};
5
+ import e from"../../../../Color.js";import"../../../../core/has.js";import{deg2rad as t}from"../../../../core/mathUtils.js";import{f as r,t as o}from"../../../../chunks/mat3.js";import{c as a}from"../../../../chunks/mat3f64.js";import{f as n,m as s,a as i}from"../../../../chunks/mat4.js";import{c as l,I as c,b as u}from"../../../../chunks/mat4f64.js";import{s as m,e as h,b as f,d as p,n as d,g,c as x}from"../../../../chunks/vec3.js";import{Z as _,O as T,c as y}from"../../../../chunks/vec3f64.js";import{O as b}from"../../../../chunks/vec4f64.js";import{canProjectWithoutEngine as v}from"../../../../geometry/projection.js";import{computeTranslationToOriginAndRotation as C}from"../../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{projectBuffer as O}from"../../../../geometry/projection/projectBuffer.js";import{projectVectorToDehydratedPoint as j}from"../../../../geometry/projection/projectVectorToDehydratedPoint.js";import{create as w,empty as M,expandWithBuffer as P,intersectsClippingArea as R}from"../../../../geometry/support/aaBoundingBox.js";import{newFloatArray as A}from"../../../../geometry/support/FloatArray.js";import{getContinuousIndexArray as I,getZeroIndexArray as E}from"../../../../geometry/support/Indices.js";import N from"../../../../geometry/support/MeshComponent.js";import S from"../../../../geometry/support/MeshMaterialMetallicRoughness.js";import B from"../../../../geometry/support/MeshTextureTransform.js";import{t as F,a as U}from"../../../../chunks/vec32.js";import{project as L}from"../../../../geometry/support/meshUtils/georeference.js";import{transformNormal as $,projectNormalToPCPF as G,transformTangent as V,projectTangentToPCPF as D}from"../../../../geometry/support/meshUtils/projection.js";import{makeDehydratedPoint as k}from"../../../../layers/graphics/dehydratedPoint.js";import{MeshTransformUpdateAction as H}from"../../../../layers/graphics/sources/interfaces.js";import{ViewingMode as q}from"../../../ViewingMode.js";import{isEncodedMeshTexture as W}from"../../glTF/internal/resourceUtils.js";import{getTransformMatrix as z}from"../../glTF/internal/TextureTransformUtils.js";import{perObjectElevationAligner as Y}from"./ElevationAligners.js";import{needsElevationUpdates3D as Z,evaluateElevationInfoAtPoint as J}from"./elevationAlignmentUtils.js";import{Graphics3DMeshObject3DGraphicLayer as K}from"./Graphics3DMeshObject3DGraphicLayer.js";import{Object3DEdgeState as Q}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as X}from"./Graphics3DSymbolLayer.js";import{MaterialInfoCache as ee,MeshFastUpdateProcessor as te}from"./MeshFastUpdateProcessor.js";import{createMaterial as re}from"../support/edgeUtils.js";import{parseColorMixMode as oe,encodeSymbolColor as ae}from"../support/symbolColorUtils.js";import{debugFlags as ne}from"../../support/debugFlags.js";import{Attribute as se}from"../../webgl-engine/lib/Attribute.js";import{AlphaDiscardMode as ie,CullFaceOptions as le}from"../../webgl-engine/lib/basicInterfaces.js";import{ContentObjectType as ce}from"../../webgl-engine/lib/ContentObjectType.js";import{Geometry as ue}from"../../webgl-engine/lib/Geometry.js";import{Object3D as me}from"../../webgl-engine/lib/Object3D.js";import{Texture as he}from"../../webgl-engine/lib/Texture.js";import{VertexAttribute as fe}from"../../webgl-engine/lib/VertexAttribute.js";import{DefaultMaterial as pe}from"../../webgl-engine/materials/DefaultMaterial.js";import{NativeLineMaterial as de}from"../../webgl-engine/materials/NativeLineMaterial.js";import{useSchematicPBR as ge,defaultSchematicMRRFactors as xe,defaultAdvancedMRRFactors as _e}from"../../webgl-engine/materials/pbrUtils.js";import{TextureWrapMode as Te}from"../../../webgl/enums.js";const ye=["mesh"];class be extends X{constructor(e,t,r,o){super(e,t,r,o),this._materialInfoCache=new ee,this._fastUpdateProcessor=new te,this._textures=new Map,this.ensureDrapedStatus(!1)}async doLoad(){ne.DRAW_MESH_GEOMETRY_NORMALS&&(this._debugVertexNormalMaterial=new de({color:[1,0,1,1]}),this._debugFaceNormalMaterial=new de({color:[0,1,1,1]}))}destroy(){super.destroy(),this._textures.forEach((e=>e.unload())),this._context.stage.removeMany(this._materialInfoCache.materials),this._context.stage.removeMany(Array.from(this._textures.values())),this._materialInfoCache.clear(),this._textures.clear(),this._fastUpdateProcessor.destroy(this._context.stage)}createGraphics3DGraphic(e){const t=e.graphic;if(!this._validateGeometry(t.geometry,ye,"fill on mesh-3d"))return null;const r=this.setGraphicElevationContext(t),o=e.renderingInfo;return this._createAs3DShape(t,o,r,t.uid)}onRemoveGraphic(e){this._fastUpdateProcessor.onRemoveGraphic(e,this._materialInfoCache,this._context)}layerOpacityChanged(e,t){const r=this._getLayerOpacity();this._updateMaterialParameters((e=>{e.material.setParameters({layerOpacity:r});const t=e.material.parameters;this._setMaterialTransparentParameter(t,e),e.material.setParameters({transparent:t.transparent})})),e.forEach((e=>{const o=t(e);null!=o&&o.layerOpacityChanged(r,this._context.isAsync)}))}layerElevationInfoChanged(e,t){return this.updateGraphics3DGraphicElevationInfo(e,t,Z)}slicePlaneEnabledChanged(e,t){return this._updateMaterialParameters((({material:e})=>{e.setParameters({hasSlicePlane:this._context.slicePlaneEnabled})})),e.forEach((e=>{const r=t(e);null!=r&&r.slicePlaneEnabledChanged(this._context.slicePlaneEnabled,this._context.isAsync)})),!0}physicalBasedRenderingChanged(){const e=this._usePBR();return this._updateMaterialParameters((({material:t})=>t.setParameters({usePBR:e}))),!0}updateTransform(e,t,r,o){const a=this._context.renderCoordsHelper.spatialReference,n=Ae,{origin:s,transform:i}=r;switch(C(t,m(Oe,s.x,s.y,s.z??0),n,a),o){case H.EnableFastUpdates:this._fastUpdateProcessor.enable(e,this._materialInfoCache,this._context);break;case H.DisableFastUpdates:this._fastUpdateProcessor.disable(e,this._materialInfoCache,this._context);break;case H.UpdateFastLocalOrigin:e.updateFastLocalOrigin(n,i,this._context.localOriginFactory)}const{elevationContext:l}=e;l.centerPointInElevationSR=this._getCenterPointInElevationSR(n);const{elevationProvider:c,renderCoordsHelper:u}=this._context,h=(e,t)=>J(e,c,l,u,t);return e.alignedSampledElevation=Y(e,l,c.spatialReference,h,u,n),e.updateTransform(n,i,this._context.isAsync),!0}_requiresSymbolVertexColors(){return this._drivenProperties.color||this._drivenProperties.opacity}_colorOrTextureUid(t){return null==t?"-":t instanceof e?t.toHex():t.contentHash}_materialPropertiesDefault(e,t){const r=this._requiresSymbolVertexColors(),o=!!e.vertexAttributes.color,a=!!e.vertexAttributes.tangent;return{hasSymbolVertexColors:r,hasVertexColors:o,hasVertexTangents:a,uid:`vc:${o},vt:${a},vct${t},svc:${r}`}}_textureTransformUid(e){const{offset:t,scale:r,rotation:o}=e??Ne;return`${t[0]},${t[1]},${o},${r[0]},${r[1]}`}_materialProperties(e,t,r){const o=this._materialPropertiesDefault(e,r);if(!t.material)return o;const{color:a,colorTexture:n,colorTextureTransform:s,normalTexture:i,normalTextureTransform:l,doubleSided:c,alphaCutoff:u,alphaMode:m}=t.material,h=this._colorOrTextureUid(a),f=this._colorOrTextureUid(n),p=this._textureTransformUid(s),d=this._colorOrTextureUid(i),g=this._textureTransformUid(l);if(o.color=a,o.colorTexture=n,o.normalTexture=i,o.uid=`${o.uid},cmuid:${h},ctmuid:${f},cttuid:${p},ntmuid:${d},nttuid:${g},ds:${c},ac:${u},am:${m}`,t.material instanceof S){const{metallic:e,roughness:r,metallicRoughnessTexture:a,metallicRoughnessTextureTransform:n,emissiveColor:i,emissiveTexture:c,emissiveTextureTransform:u,occlusionTexture:m,occlusionTextureTransform:h}=t.material,f=this._colorOrTextureUid(a),p=this._textureTransformUid(n),d=this._colorOrTextureUid(i),g=this._colorOrTextureUid(c),x=this._textureTransformUid(u),_=this._colorOrTextureUid(m),T=this._textureTransformUid(h);o.metallic=e,o.roughness=r,o.metallicRoughnessTexture=a,o.emissiveColor=i,o.emissiveTexture=c,o.occlusionTexture=m,o.colorTextureTransform=this._convertTextureTransform(s),o.normalTextureTransform=this._convertTextureTransform(l),o.emissiveTextureTransform=this._convertTextureTransform(u),o.occlusionTextureTransform=this._convertTextureTransform(h),o.metallicRoughnessTextureTransform=this._convertTextureTransform(n),o.uid=`${o.uid},mrm:${e},mrr:${r},mrt:${f},mrtt:${p},emuid:${d},etmuid:${g},ett:${x},otmuid:${_},ott:${T}`}return o}_convertTextureTransform(e){if(!e)return null;const{scale:r,offset:o,rotation:a}=e;return{scale:r,offset:o,rotation:t(a)}}_setInternalColorValueParameters(t,r){r.diffuse=e.toUnitRGB(t),r.opacity=t.a}_getLoadableTextureResource(e){return e.data?e.data:e.url}_getInternalTextureId(e){const t=this._getInternalTexture(e,ie.Opaque);return t?.id}_getInternalTexture(e,t){const r=this._getLoadableTextureResource(e);if(!r)return null;const o=`${e.contentHash}/${t}`;let a=this._textures.get(o);return a||(a=new he(W(r)?r.data:r,{mipmap:!0,wrap:this._castTextureWrap(e.wrap),noUnpackFlip:!0,preMultiplyAlpha:!W(r)&&t!==ie.Opaque,encoding:W(r)&&null!=r.encoding?r.encoding:void 0}),this._textures.set(o,a),a.load(this._context.stage.renderView.renderingContext),this._context.stage.add(a)),a}_castTextureWrap(e="repeat"){if("string"==typeof e){const t=this._castTextureWrapIndividual(e);return{s:t,t}}return{s:this._castTextureWrapIndividual(e.horizontal),t:this._castTextureWrapIndividual(e.vertical)}}_castTextureWrapIndividual(e){switch(e){case"clamp":return Te.CLAMP_TO_EDGE;case"mirror":return Te.MIRRORED_REPEAT;default:return Te.REPEAT}}_setInternalMaterialParameters(t,r){if(null!=t.color&&this._setInternalColorValueParameters(t.color,r),null!=t.colorTexture){const e=this._getInternalTexture(t.colorTexture,r.textureAlphaMode);null!=e?(r.textureId=e.id,r.textureAlphaPremultiplied=!!e.parameters.preMultiplyAlpha):r.textureId=void 0}null!=t.normalTexture&&(r.normalTextureId=this._getInternalTextureId(t.normalTexture)),null!=t.emissiveColor&&(r.emissiveFactor=e.toUnitRGB(t.emissiveColor)),null!=t.emissiveTexture&&(r.emissiveTextureId=this._getInternalTextureId(t.emissiveTexture)),null!=t.occlusionTexture&&(r.occlusionTextureId=this._getInternalTextureId(t.occlusionTexture)),null!=t.metallicRoughnessTexture&&(r.metallicRoughnessTextureId=this._getInternalTextureId(t.metallicRoughnessTexture)),r.colorTextureTransformMatrix=z(t.colorTextureTransform),r.normalTextureTransformMatrix=z(t.normalTextureTransform),r.occlusionTextureTransformMatrix=z(t.occlusionTextureTransform),r.emissiveTextureTransformMatrix=z(t.emissiveTextureTransform),r.metallicRoughnessTextureTransformMatrix=z(t.metallicRoughnessTextureTransform)}_setExternalMaterialParameters(t){const r=this._drivenProperties.color;let o=null!=this.symbolLayer.material?this.symbolLayer.material.colorMixMode:null;if(r)t.externalColor=b;else{const r=null!=this.symbolLayer.material?this.symbolLayer.material.color:null;null!=r?t.externalColor=e.toUnitRGBA(r):(o=null,t.externalColor=b)}o&&(t.colorMixMode=o),t.castShadows=!!this.symbolLayer.castShadows}_hasTransparentVertexColors(e){const t=e.vertexAttributes.color;if(null==t)return!1;for(let r=3;r<t.length;r+=4)if(255!==t[r])return!0;return!1}_getOrCreateMaterial(t,r){const o=r.material?.color,a=r.material?.colorTexture,n=r.material?.alphaMode,s="blend"===n,i=!("opaque"===n)&&(this._hasTransparentVertexColors(t)||null!=o&&o.a<1||null!=a&&a.transparent||s),l=this._materialProperties(t,r,i),c=this._materialInfoCache.byUid(l.uid);if(c)return c.material;const u={uid:l.uid,material:null,isComponentTransparent:i,alphaMode:r.material?r.material.alphaMode:"opaque"},m=ge({normalTexture:l.normalTexture,metallicRoughnessTexture:l.metallicRoughnessTexture,metallicFactor:l.metallic,roughnessFactor:l.roughness,emissiveTexture:l.emissiveTexture,emissiveFactor:e.toUnitRGB(l.emissiveColor),occlusionTexture:l.occlusionTexture}),h={usePBR:this._usePBR(),isSchematic:m,hasVertexColors:l.hasVertexColors,hasSymbolColors:l.hasSymbolVertexColors,hasVertexTangents:l.hasVertexTangents,ambient:_,diffuse:T,opacity:1,doubleSided:!0,doubleSidedType:"winding-order",cullFace:le.None,layerOpacity:this._getLayerOpacity(),hasSlicePlane:this._context.slicePlaneEnabled,initTextureTransparent:!0};h.mrrFactors=m?[...xe]:[l.metallic,l.roughness,_e[2]],r.material&&(h.doubleSided=r.material.doubleSided,h.cullFace=r.material.doubleSided?le.None:le.Back,h.textureAlphaCutoff=r.material.alphaCutoff),this._setExternalMaterialParameters(h),this._setMaterialTransparentParameter(h,u),this._setInternalMaterialParameters(l,h);const f=new pe(h);return u.material=f,this._materialInfoCache.set(l.uid,u),this._context.stage.add(f),f}_usePBR(){return this._context.physicalBasedRenderingEnabled}_setMaterialTransparentParameter(e,t){e.transparent=this.needsDrivenTransparentPass||t.isComponentTransparent||e.layerOpacity<1||e.opacity<1||e.externalColor&&e.externalColor[3]<1,"auto"===t.alphaMode?e.textureAlphaMode=e.transparent?ie.MaskBlend:ie.Opaque:e.textureAlphaMode="opaque"===t.alphaMode?ie.Opaque:"mask"===t.alphaMode?ie.Mask:ie.Blend}_addDebugNormals(e,t){const r=t.length,o=e.spatialReference.isGeographic?20015077/180:1,a=.1*Math.max(e.extent.width*o,e.extent.height*o,e.extent.zmax-e.extent.zmin),n=[],s=[],i=[],l=[];for(let p=0;p<r;p++){const e=t[p],r=e.vertexAttributes.get(fe.POSITION),o=e.vertexAttributes.get(fe.NORMAL),c=e.indices.get(fe.POSITION),u=e.indices.get(fe.NORMAL),m=r.data,d=o.data;for(let t=0;t<c.length;t++){const e=3*c[t],r=3*u[t];for(let t=0;t<3;t++)n.push(m[e+t]);for(let t=0;t<3;t++)n.push(m[e+t]+d[r+t]*a);if(s.push(s.length),s.push(s.length),t%3==0){this._calculateFaceNormal(m,c,t,Me),this._getFaceVertices(m,c,t,Oe,je,we),h(Oe,Oe,je),h(Oe,Oe,we),f(Oe,Oe,1/3);for(let e=0;e<3;e++)i.push(Oe[e]);for(let e=0;e<3;e++)i.push(Oe[e]+Me[e]*a);l.push(l.length),l.push(l.length)}}}const c=t[0].transformation,u=new ue(this._debugVertexNormalMaterial,[[fe.POSITION,new se(n,3,!0)]],[[fe.POSITION,s]],null,ce.Line);t.push(u),u.transformation=c;const m=new ue(this._debugFaceNormalMaterial,[[fe.POSITION,new se(i,3,!0)]],[[fe.POSITION,l]],null,ce.Line);m.transformation=c,t.push(m)}_createAs3DShape(e,t,r,o){const a=e.geometry;if("mesh"!==a.type)return null;const n=this._createGeometryInfo(a,t,o);if(null==n)return null;const{geometries:s,objectTransformation:i}=n;ne.DRAW_MESH_GEOMETRY_NORMALS&&this._addDebugNormals(a,s);const l=new me({geometries:s,layerUid:this._context.layer.uid,graphicUid:o});l.transformation=i;const c=re(this.symbolLayer,{opacity:this._getLayerOpacity()}),u=null!=c?new Q(s[0].material,[c],{mergeGeometries:!0,hasSlicePlane:this._context.slicePlaneEnabled}):null,m=new K(this,l,s,null,null,Y,r,u);this._fastUpdateProcessor.onAddGraphic(),m.needsElevationUpdates=Z(r.mode),m.useObjectOriginAsAttachmentOrigin=!0,r.centerPointInElevationSR=this._getCenterPointInElevationSR(l.transformation);const{elevationProvider:h,renderCoordsHelper:f}=this._context,p=(e,t)=>J(e,h,r,f,t);return m.alignedSampledElevation=Y(m,r,h.spatialReference,p,f),m}_getCenterPointInElevationSR(e){const t=k(0,0,0,null!=this._context.elevationProvider.spatialReference?this._context.elevationProvider.spatialReference:null);return j([e[12],e[13],e[14]],this._context.renderCoordsHelper.spatialReference,t),t}_createComponentNormals(e,t,r,o){switch(r.shading||"flat"){default:case"source":return this._createComponentNormalsSource(e,t,r,o);case"flat":return this._createComponentNormalsFlat(e,o);case"smooth":return this._createComponentNormalsSmooth(e,o)}}_createComponentNormalsSource(e,t,r,o){if(null==t)return this._createComponentNormalsFlat(e,o);let a=!1;if(!r.trustSourceNormals)for(let n=0;n<o.length;n+=3){this._calculateFaceNormal(e,o,n,Me);for(let e=0;e<3;e++){const r=3*o[n+e];Oe[0]=t[r],Oe[1]=t[r+1],Oe[2]=t[r+2],p(Me,Oe)<0&&(t[r]=-t[r],t[r+1]=-t[r+1],t[r+2]=-t[r+2],a=!0)}}return new ve(t,o,a)}_createComponentNormalsFlat(e,t){const r=A(t.length),o=new Array(3*t.length);for(let a=0;a<t.length;a+=3){const n=this._calculateFaceNormal(e,t,a,Me);for(let e=0;e<3;e++)r[a+e]=n[e],o[a+e]=a/3}return new ve(r,o,!1)}_createComponentNormalsSmooth(e,t){const r={};for(let n=0;n<t.length;n+=3){const o=this._calculateFaceNormal(e,t,n,Me);for(let e=0;e<3;e++){const a=t[n+e];let s=r[a];s||(s={normal:y(),count:0},r[a]=s),h(s.normal,s.normal,o),s.count++}}const o=A(3*t.length),a=new Array(3*t.length);for(let n=0;n<t.length;n++){const e=r[t[n]];1!==e.count&&(d(e.normal,e.normal),e.count=1);for(let t=0;t<3;t++)o[3*n+t]=e.normal[t];a[n]=n}return new ve(o,a,!1)}_getFaceVertices(e,t,r,o,a,n){const s=3*t[r],i=3*t[r+1],l=3*t[r+2];o[0]=e[s],o[1]=e[s+1],o[2]=e[s+2],a[0]=e[i],a[1]=e[i+1],a[2]=e[i+2],n[0]=e[l],n[1]=e[l+1],n[2]=e[l+2]}_calculateFaceNormal(e,t,r,o){return this._getFaceVertices(e,t,r,Oe,je,we),g(je,je,Oe),g(we,we,Oe),x(Oe,je,we),d(o,Oe),o}_getOrCreateComponents(e){return e.components??Ee}_createPositionBuffer(e,t){let r=e.vertexAttributes.position;const o=t.reprojection===Se.ECEF?t.transformBeforeProject:null;if(null!=o&&(r=F(new Float64Array(r.length),r,o)),t.reprojection===Se.NONE)return t.needsBufferCopy?new Float64Array(r):r;const a=null!=o?r:new Float64Array(r.length);return O(r,e.spatialReference,0,a,this._context.renderCoordsHelper.spatialReference,0,r.length/3),a}_createNormalBuffer(e,t,r){let o=e.vertexAttributes.normal;if(null==o)return null;const a=r.reprojection===Se.ECEF?r.transformBeforeProject:null;null!=a&&(o=$(o,new Float32Array(o.length),a));if("local"===this._context.graphicsCoreOwner.view.viewingMode||r.reprojection===Se.NONE)return r.needsBufferCopy&&e.vertexAttributes.normal===o?new Float32Array(o):o;const n=e.vertexAttributes.position,s=null!=a?o:new Float32Array(o.length);return G(o,n,t,e.spatialReference,s)}_createTangentBuffer(e,t,r){let o=e.vertexAttributes.tangent;if(null==o)return null;const a=r.reprojection===Se.ECEF?r.transformBeforeProject:null;null!=a&&(o=V(o,new Float32Array(o.length),a));if("local"===this._context.graphicsCoreOwner.view.viewingMode||r.reprojection===Se.NONE)return r.needsBufferCopy&&e.vertexAttributes.normal===o?new Float32Array(o):o;const n=e.vertexAttributes.position,s=null!=a?o:new Float32Array(o.length);return D(o,n,t,e.spatialReference,s)}_createColorBuffer(e){return e.vertexAttributes.color}_createSymbolColorBuffer(e){if(this._requiresSymbolVertexColors()){const t=this._getVertexOpacityAndColor(e),r=oe(this.symbolLayer?.material?.colorMixMode),o=new Uint8Array(4);return ae(t,r,o),o}return null}_createBuffers(e,t){const r=e.vertexAttributes&&e.vertexAttributes.position;if(!r)return this.logger.warn("Mesh geometry must contain position vertex attributes"),null;const o=e.vertexAttributes.normal,a=e.vertexAttributes.uv,n=e.vertexAttributes.tangent;if(null!=o&&o.length!==r.length)return this.logger.warn("Mesh normal vertex buffer must contain the same number of elements as the position buffer"),null;if(null!=n&&n.length/4!=r.length/3)return this.logger.warn("Mesh tangent vertex buffer must contain the same number of elements as the position buffer"),null;if(null!=a&&a.length/2!=r.length/3)return this.logger.warn("Mesh uv vertex buffer must contain the same number of elements as the position buffer"),null;const s=this._computeReprojectionInfo(e),i=this._createPositionBuffer(e,s),c=this._createColorBuffer(e),u=this._createSymbolColorBuffer(t),m=this._createNormalBuffer(e,i,s),h=this._createTangentBuffer(e,i,s);return{positionBuffer:i,normalBuffer:m,tangentBuffer:h,uvBuffer:a,colorBuffer:c,symbolColorBuffer:u,objectTransformation:s.reprojection===Se.NONE&&null!=s.objectTransformation?s.objectTransformation:this._transformOriginLocal(e,i,m,h),geometryTransformation:s.reprojection===Se.NONE&&null!=s.geometryTransformation?s.geometryTransformation:l()}}_computeReprojectionInfo(e){const{vertexSpace:t}=e,r=t.isRelative,o=t.isGeoreferenced?this._context.renderCoordsHelper.viewingMode===q.Local?Se.NONE:Se.ECEF:Se.NONE;if(r){const{origin:r}=t,a=l(),i=e.transform?.localMatrix??c;if(o===Se.NONE){C(e.spatialReference,r,a,this._context.renderCoordsHelper.spatialReference);return{reprojection:o,objectTransformation:a,geometryTransformation:u(i),needsBufferCopy:!1}}const m=n(l(),r);return s(m,m,i),{reprojection:o,transformBeforeProject:m,needsBufferCopy:!0}}return{reprojection:o,needsBufferCopy:!0}}_transformOriginLocal(e,t,a,n){const s=this._context.renderCoordsHelper.spatialReference,c=e.anchor;Ce[0]=c.x,Ce[1]=c.y,Ce[2]=c.z??0;const u=l();return C(e.spatialReference,Ce,u,s),i(Pe,u),F(t,t,Pe),null==a&&null==n||(r(Re,u),o(Re,Re),null!=a&&U(a,a,Re),null!=n&&U(n,n,Re,4)),u}_validateFaces(e,t){const r=e.vertexAttributes.position.length/3,o=t.faces;if(o){let e=-1;for(let t=0;t<o.length;t++){const r=o[t];r>e&&(e=r)}if(r<=e)return this.logger.warn(`Vertex index ${e} is out of bounds of the mesh position buffer`),!1}else if(r%3!=0)return this.logger.warn("Mesh position buffer length must be a multiple of 9 if no component faces are defined (3 values per vertex * 3 vertices per triangle)"),!1;return!0}_getOrCreateFaces(e,t){return t.faces??I(e.vertexAttributes.position.length/3)}_isOutsideClippingArea(e){if(!this._context.clippingExtent)return!1;const t=e.vertexAttributes?.position;if(!t)return!1;const r=this._context.elevationProvider.spatialReference,o=L({positions:t,transform:e.transform,vertexSpace:e.vertexSpace,inSpatialReference:e.spatialReference,outSpatialReference:r??e.spatialReference}),a=o.length/3;return M(Ie),P(Ie,o,0,a),!R(Ie,this._context.clippingExtent)}_createGeometryInfo(e,t,r){if(!v(e.spatialReference,this._context.graphicsCoreOwner.view.spatialReference))return this.logger.warn("Geometry spatial reference is not compatible with the view"),null;if(this._isOutsideClippingArea(e))return null;const o=this._createBuffers(e,t);if(null==o)return null;const{positionBuffer:a,uvBuffer:n,colorBuffer:s,symbolColorBuffer:i,normalBuffer:l,tangentBuffer:c,objectTransformation:u,geometryTransformation:m}=o,h=this._getOrCreateComponents(e),f=new Array;let p=!1;for(const d of h){if(!this._validateFaces(e,d))return null;const t=this._getOrCreateFaces(e,d);if(0===t.length)continue;const o=this._createComponentNormals(a,l,d,t);o.didFlipNormals&&(p=!0);const u=[[fe.POSITION,new se(a,3,!0)],[fe.NORMAL,new se(o.normals,3,!0)]],h=[[fe.POSITION,t],[fe.NORMAL,o.indices]];null!=s&&(u.push([fe.COLOR,new se(s,4,!0)]),h.push([fe.COLOR,t])),null!=i&&(u.push([fe.SYMBOLCOLOR,new se(i,4,!0)]),h.push([fe.SYMBOLCOLOR,E(t.length)])),null!=n&&(u.push([fe.UV0,new se(n,2,!0)]),h.push([fe.UV0,t])),null!=c&&(u.push([fe.TANGENT,new se(c,4,!0)]),h.push([fe.TANGENT,t]));const g=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:r,layerUid:this._context.layer.uid}),x=this._getOrCreateMaterial(e,d),_=new ue(x,u,h,null,ce.Mesh,g);_.transformation=m,f.push(_)}return p&&this.logger.warn("Normals have been automatically flipped to be consistent with the counter clock wise face winding order. It is better to generate mesh geometries that have consistent normals."),{geometries:f,objectTransformation:u}}_updateMaterialParameters(e){this._materialInfoCache.forEachMaterialInfo(e),this._fastUpdateProcessor.forEachMaterialInfo(e),this._fastUpdateProcessor.forEachClonedMaterial(((e,t)=>{t.setParameters(e.parameters)}))}test(){return{...super.test(),materials:this._materialInfoCache.materials}}}class ve{constructor(e,t,r){this.normals=e,this.indices=t,this.didFlipNormals=r}}const Ce=y(),Oe=y(),je=y(),we=y(),Me=y(),Pe=l(),Re=a(),Ae=l(),Ie=w(),Ee=[new N],Ne=new B;var Se;!function(e){e[e.NONE=0]="NONE",e[e.ECEF=1]="ECEF"}(Se||(Se={}));export{be as Graphics3DMeshFillSymbolLayer};
@@ -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{i as e,m as t,e as i}from"../../../../chunks/vec3.js";import{c as s}from"../../../../chunks/vec3f64.js";import{setMin as a,setMax as n,create as r,isPoint as o,empty as c,center as l,offset as h}from"../../../../geometry/support/aaBoundingBox.js";import{g}from"../../../../chunks/sphere.js";import{evaluateElevationInfoAtPoint as d}from"./elevationAlignmentUtils.js";import{setContextFeature as u}from"./featureExpressionInfoUtils.js";import{demResolutionForBoundingBox as b}from"./graphicUtils.js";import{Object3DState as O}from"../../webgl-engine/lib/basicInterfaces.js";import{Transparency as j}from"../../webgl-engine/lib/edgeRendering/interfaces.js";class m{constructor(e,t,i){this.baseMaterial=e,this.edgeMaterials=t,this.properties=i}}class p{get isElevationSource(){return!!this.stageObject.lastValidElevationBB}constructor(e,t,i,s,a,n,r,o=null){this.graphics3DSymbolLayer=e,this.stageObject=t,this._uniqueGeometries=i,this._uniqueMaterials=s,this._sharedResource=a,this.elevationAligner=n,this.elevationContext=r,this._edgeState=o,this.type="object3d",this._stageLayer=null,this._visible=!1,this._addedToStage=!1,this.alignedSampledElevation=0,this.needsElevationUpdates=!1,this.useObjectOriginAsAttachmentOrigin=!1}initialize(e){this._stageLayer=e;const t=e.stage;t.addMany(this._uniqueMaterials),t.addMany(this._uniqueGeometries),t.add(this.stageObject)}destroy(){if(!this._stageLayer)return;const e=this._stageLayer.stage;e.removeMany(this._uniqueMaterials),e.removeMany(this._uniqueGeometries),e.remove(this.stageObject),this._addedToStage&&(this._stageLayer.remove(this.stageObject),this._addedToStage=!1);const t=e.renderer.ensureEdgeView();t.hasObject(this.stageObject)&&t.removeObject(this.stageObject),this.stageObject.dispose(),null!=this._sharedResource&&this._sharedResource.release(),this._visible=!1,this._stageLayer=null}layerOpacityChanged(e,t){if(null==this._edgeState)return;const i=v(this._edgeState.baseMaterial);let s=!1;for(const a of this._edgeState.edgeMaterials)a.objectTransparency!==i&&(a.objectTransparency=i,s=!0);s&&this.resetEdgeObject(t);this._stageLayer.stage.renderer.ensureEdgeView().updateAllComponentOpacities(this.stageObject,[e])}slicePlaneEnabledChanged(e,t){if(null==this._edgeState)return;this._stageLayer.stage.renderer.ensureEdgeView().updateAllComponentMaterials(this.stageObject,this._edgeState.edgeMaterials,{hasSlicePlane:e},!t),this._edgeState.properties.hasSlicePlane=e}setVisibility(e){if(null!=this._stageLayer&&this._visible!==e&&(this._visible=e,this.stageObject.visible=e,this._visible&&!this._addedToStage&&(this._stageLayer.add(this.stageObject),this._addedToStage=!0),this._edgeState)){const t=this._stageLayer.stage.renderer.ensureEdgeView();t.hasObject(this.stageObject)?t.updateObjectVisibility(this.stageObject,e):e&&this._addOrUpdateEdgeObject(t,!1)}}get visible(){return this._visible}alignWithElevation(e,t,i,s){if(null==this.elevationAligner)return;null!=i&&u(this.elevationContext.featureExpressionInfoContext,i);const a=(i,s)=>d(i,e,this.elevationContext,t,s);this.alignedSampledElevation=this.elevationAligner(this,this.elevationContext,e.spatialReference,a,t),this.resetEdgeObject(s)}alignWithAbsoluteElevation(e,t,i){const s=(t,i)=>{i.sampledElevation=e,i.verticalDistanceToGround=0,i.z=e};this.alignedSampledElevation=this.elevationAligner(this,this.elevationContext,null,s,t),this.resetEdgeObject(i)}getCenterObjectSpace(t=s()){return e(t,g(this.stageObject.boundingVolumeObjectSpace.bounds))}getBoundingBoxObjectSpace(e=r()){const t=this.stageObject.boundingVolumeObjectSpace;return a(e,t.min),n(e,t.max),e}computeAttachmentOrigin(e){const s=this.stageObject.effectiveTransformation;if(this.useObjectOriginAsAttachmentOrigin)e.render.origin[0]+=s[12],e.render.origin[1]+=s[13],e.render.origin[2]+=s[14],e.render.num++;else for(const a of this.stageObject.geometries)a.computeAttachmentOrigin(S)&&(t(S,S,s),i(e.render.origin,e.render.origin,S),e.render.num++)}async getProjectedBoundingBox(e,i,s,a,n){const r=this.getBoundingBoxObjectSpace(n),g=y,d=o(r)?1:g.length;for(let o=0;o<d;o++){const e=g[o];f[0]=r[e[0]],f[1]=r[e[1]],f[2]=r[e[2]],t(f,f,this.stageObject.transformation),_[3*o]=f[0],_[3*o+1]=f[1],_[3*o+2]=f[2]}if(!e(_,0,d))return null;c(r);let u=null;this.calculateRelativeScreenBounds&&(u=this.calculateRelativeScreenBounds());for(let t=0;t<3*d;t+=3){for(let e=0;e<3;e++)r[e]=Math.min(r[e],_[t+e]),r[e+3]=Math.max(r[e+3],_[t+e]);u&&s.push({location:_.slice(t,t+3),screenSpaceBoundingRect:u})}if(i&&i.service&&"absolute-height"!==this.elevationContext.mode){l(r,S);const e="relative-to-scene"===this.elevationContext.mode?"scene":"ground";let t=0;if(i.useViewElevation)t=i.service.getElevation(S[0],S[1],e)??0;else try{const s=b(r,i.service.spatialReference,i);t=await i.service.queryElevation(S[0],S[1],a,s,e)??0}catch(O){}h(r,0,0,-this.alignedSampledElevation+t)}return r}addObjectState(e,t){e===O.Highlight&&t.addObject(this.stageObject,this.stageObject.highlight()),e===O.MaskOccludee&&t.addObject(this.stageObject,this.stageObject.maskOccludee())}removeObjectState(e){e.removeObject(this.stageObject)}resetEdgeObject(e){if(null==this._edgeState)return;const t=this._stageLayer.stage.renderer.ensureEdgeView();this._visible?this._addOrUpdateEdgeObject(t,e):t.removeObject(this.stageObject)}_addOrUpdateEdgeObject(e,t){const i=this._edgeState;if(null==i)return;const s=v(i.baseMaterial);for(const a of i.edgeMaterials)a.objectTransparency=s;e.addOrUpdateObject3D(this.stageObject,i.edgeMaterials,i.properties,!t).then((()=>this._stageLayer?.sync()))}}function v(e){return e.isVisible()?e.parameters.transparent?j.TRANSPARENT:j.OPAQUE:j.INVISIBLE}const _=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],f=s(),S=s(),y=[[0,1,2],[3,1,2],[0,4,2],[3,4,2],[0,1,5],[3,1,5],[0,4,5],[3,4,5]];export{p as Graphics3DObject3DGraphicLayer,m as Object3DEdgeState};
5
+ import{i as e,m as t,e as i}from"../../../../chunks/vec3.js";import{c as s}from"../../../../chunks/vec3f64.js";import{setMin as a,setMax as n,create as r,isPoint as o,empty as c,center as l,offset as h}from"../../../../geometry/support/aaBoundingBox.js";import{g}from"../../../../chunks/sphere.js";import{evaluateElevationInfoAtPoint as d}from"./elevationAlignmentUtils.js";import{setContextFeature as u}from"./featureExpressionInfoUtils.js";import{demResolutionForBoundingBox as b}from"./graphicUtils.js";import{Object3DState as O}from"../../webgl-engine/lib/basicInterfaces.js";import{Transparency as j}from"../../webgl-engine/lib/edgeRendering/interfaces.js";class m{constructor(e,t,i){this.baseMaterial=e,this.edgeMaterials=t,this.properties=i}}class p{get isElevationSource(){return!!this.stageObject.lastValidElevationBB}constructor(e,t,i,s,a,n,r,o=null){this.graphics3DSymbolLayer=e,this.stageObject=t,this._uniqueGeometries=i,this._uniqueMaterials=s,this._sharedResource=a,this.elevationAligner=n,this.elevationContext=r,this._edgeState=o,this.type="object3d",this._stageLayer=null,this._visible=!1,this._addedToStage=!1,this.alignedSampledElevation=0,this.needsElevationUpdates=!1,this.useObjectOriginAsAttachmentOrigin=!1}initialize(e){this._stageLayer=e;const t=e.stage;t.addMany(this._uniqueMaterials),t.addMany(this._uniqueGeometries),t.add(this.stageObject)}destroy(){if(!this._stageLayer)return;const e=this._stageLayer.stage;e.removeMany(this._uniqueMaterials),e.removeMany(this._uniqueGeometries),e.remove(this.stageObject),this._addedToStage&&(this._stageLayer.remove(this.stageObject),this._addedToStage=!1);const t=e.renderer.ensureEdgeView();t.hasObject(this.stageObject)&&t.removeObject(this.stageObject),this.stageObject.dispose(),this._sharedResource?.release(),this._visible=!1,this._stageLayer=null}layerOpacityChanged(e,t){if(null==this._edgeState)return;const i=v(this._edgeState.baseMaterial);let s=!1;for(const a of this._edgeState.edgeMaterials)a.objectTransparency!==i&&(a.objectTransparency=i,s=!0);s&&this.resetEdgeObject(t);this._stageLayer.stage.renderer.ensureEdgeView().updateAllComponentOpacities(this.stageObject,[e])}slicePlaneEnabledChanged(e,t){if(null==this._edgeState)return;this._stageLayer.stage.renderer.ensureEdgeView().updateAllComponentMaterials(this.stageObject,this._edgeState.edgeMaterials,{hasSlicePlane:e},!t),this._edgeState.properties.hasSlicePlane=e}setVisibility(e){if(null!=this._stageLayer&&this._visible!==e&&(this._visible=e,this.stageObject.visible=e,this._visible&&!this._addedToStage&&(this._stageLayer.add(this.stageObject),this._addedToStage=!0),this._edgeState)){const t=this._stageLayer.stage.renderer.ensureEdgeView();t.hasObject(this.stageObject)?t.updateObjectVisibility(this.stageObject,e):e&&this._addOrUpdateEdgeObject(t,!1)}}get visible(){return this._visible}alignWithElevation(e,t,i,s){if(null==this.elevationAligner)return;null!=i&&u(this.elevationContext.featureExpressionInfoContext,i);const a=(i,s)=>d(i,e,this.elevationContext,t,s);this.alignedSampledElevation=this.elevationAligner(this,this.elevationContext,e.spatialReference,a,t),this.resetEdgeObject(s)}alignWithAbsoluteElevation(e,t,i){const s=(t,i)=>{i.sampledElevation=e,i.verticalDistanceToGround=0,i.z=e};this.alignedSampledElevation=this.elevationAligner(this,this.elevationContext,null,s,t),this.resetEdgeObject(i)}getCenterObjectSpace(t=s()){return e(t,g(this.stageObject.boundingVolumeObjectSpace.bounds))}getBoundingBoxObjectSpace(e=r()){const t=this.stageObject.boundingVolumeObjectSpace;return a(e,t.min),n(e,t.max),e}computeAttachmentOrigin(e){const s=this.stageObject.effectiveTransformation;if(this.useObjectOriginAsAttachmentOrigin)e.render.origin[0]+=s[12],e.render.origin[1]+=s[13],e.render.origin[2]+=s[14],e.render.num++;else for(const a of this.stageObject.geometries)a.computeAttachmentOrigin(S)&&(t(S,S,s),i(e.render.origin,e.render.origin,S),e.render.num++)}async getProjectedBoundingBox(e,i,s,a,n){const r=this.getBoundingBoxObjectSpace(n),g=y,d=o(r)?1:g.length;for(let o=0;o<d;o++){const e=g[o];f[0]=r[e[0]],f[1]=r[e[1]],f[2]=r[e[2]],t(f,f,this.stageObject.transformation),_[3*o]=f[0],_[3*o+1]=f[1],_[3*o+2]=f[2]}if(!e(_,0,d))return null;c(r);let u=null;this.calculateRelativeScreenBounds&&(u=this.calculateRelativeScreenBounds());for(let t=0;t<3*d;t+=3){for(let e=0;e<3;e++)r[e]=Math.min(r[e],_[t+e]),r[e+3]=Math.max(r[e+3],_[t+e]);u&&s.push({location:_.slice(t,t+3),screenSpaceBoundingRect:u})}if(i&&i.service&&"absolute-height"!==this.elevationContext.mode){l(r,S);const e="relative-to-scene"===this.elevationContext.mode?"scene":"ground";let t=0;if(i.useViewElevation)t=i.service.getElevation(S[0],S[1],e)??0;else try{const s=b(r,i.service.spatialReference,i);t=await i.service.queryElevation(S[0],S[1],a,s,e)??0}catch(O){}h(r,0,0,-this.alignedSampledElevation+t)}return r}addObjectState(e,t){e===O.Highlight&&t.addObject(this.stageObject,this.stageObject.highlight()),e===O.MaskOccludee&&t.addObject(this.stageObject,this.stageObject.maskOccludee())}removeObjectState(e){e.removeObject(this.stageObject)}resetEdgeObject(e){if(null==this._edgeState)return;const t=this._stageLayer.stage.renderer.ensureEdgeView();this._visible?this._addOrUpdateEdgeObject(t,e):t.removeObject(this.stageObject)}_addOrUpdateEdgeObject(e,t){const i=this._edgeState;if(null==i)return;const s=v(i.baseMaterial);for(const a of i.edgeMaterials)a.objectTransparency=s;e.addOrUpdateObject3D(this.stageObject,i.edgeMaterials,i.properties,!t).then((()=>this._stageLayer?.sync()))}}function v(e){return e.isVisible()?e.parameters.transparent?j.TRANSPARENT:j.OPAQUE:j.INVISIBLE}const _=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],f=s(),S=s(),y=[[0,1,2],[3,1,2],[0,4,2],[3,4,2],[0,1,5],[3,1,5],[0,4,5],[3,4,5]];export{p as Graphics3DObject3DGraphicLayer,m as Object3DEdgeState};
@@ -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 has from"../../../../core/has.js";import{throwIfAborted as t}from"../../../../core/promiseUtils.js";import{pt2px as s}from"../../../../core/screenUtils.js";import{estimateSize as r}from"../../../../core/typedArrayUtil.js";import{i,k as a,w as o,c as n}from"../../../../chunks/mat4.js";import{c as l}from"../../../../chunks/mat4f64.js";import{l as c,o as h,i as d,C as m,e as p,s as u}from"../../../../chunks/vec3.js";import{g as y,O as f,Z as _,f as g,c as b}from"../../../../chunks/vec3f64.js";import{O as P,c as R}from"../../../../chunks/vec4f64.js";import{computeTranslationToOriginAndRotation as x}from"../../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{projectPointToVector as v}from"../../../../geometry/projection/projectPointToVector.js";import{create as L,size as C,containsPoint as S,center as j}from"../../../../geometry/support/aaBoundingBox.js";import{defaultPrimitive as E}from"../../../../symbols/support/ObjectSymbol3DLayerResource.js";import{objectSymbolLayerPrimitiveBoundingBox as w,objectSymbolLayerSizeWithResourceSize as T}from"../../../../symbols/support/symbolLayerUtils3D.js";import{perLodInstanceElevationAligner as U}from"./ElevationAligners.js";import{needsElevationUpdates3D as O,evaluateElevationInfoAtPoint as B,SampleElevationInfo as I}from"./elevationAlignmentUtils.js";import{Graphics3DLodInstanceGraphicLayer as A}from"./Graphics3DLodInstanceGraphicLayer.js";import{Graphics3DSymbolLayer as G}from"./Graphics3DSymbolLayer.js";import{validateSymbolLayerSize as D,mixinColorAndOpacity as F,computeObjectScale as z,computeObjectRotation as M}from"./graphicUtils.js";import{ApplyRendererDiffResult as V}from"./interfaces.js";import{LoadStatus as k}from"./Loadable.js";import{makeLodResources as H}from"./lodResourceUtils.js";import{fetch as W}from"./objectResourceUtils.js";import{placePointOnGeometry as q,extendPointGraphicElevationContext as N}from"./pointUtils.js";import{isValidPrimitive as J,primitiveLodResources as Y}from"./primitiveObjectSymbolUtils.js";import{defaultSymbolLayerMemoryComplexity as $}from"./symbolComplexity.js";import{getResourceUrlFromSymbolStyle as Z}from"./webStyleUtils.js";import{initFastSymbolUpdatesState as K,updateFastSymbolUpdatesState as Q,ConvertOptions as X,evaluateModelTransform as ee,evaluateModelTransformScale as te}from"../support/FastSymbolUpdates.js";import{CullFaceOptions as se}from"../../webgl-engine/lib/basicInterfaces.js";import{VertexAttribute as re}from"../../webgl-engine/lib/VertexAttribute.js";import{LodRenderer as ie}from"../../webgl-engine/lib/lodRendering/LodRenderer.js";import{materialsFromLodResources as ae,texturesFromLodResources as oe,geometriesFromLodResources as ne,geometriesFromLodLevelResources as le}from"../../webgl-engine/lib/lodRendering/LodResources.js";import{DefaultMaterial as ce}from"../../webgl-engine/materials/DefaultMaterial.js";import{defaultSchematicMRRFactors as he}from"../../webgl-engine/materials/pbrUtils.js";class de{constructor(e,t,s,r,i,a,o,n,l,c,h,d){this.lodResources=e,this.lodRenderer=t,this.stageResources=s,this.originalMaterialParameters=r,this.resourceSize=i,this.isEsriSymbolResource=a,this.isWosr=o,this.resourceBoundingBox=n,this.symbolSize=l,this.extentPadding=c,this.physicalBasedRenderingEnabled=h,this.pivotOffset=d}}class me extends G{getCachedSize(){const[e,t,s]=null!=this._resources?this._resources.symbolSize:[1,1,1];return{width:e,depth:t,height:s}}constructor(e,t,s,r){super(e,t,s,r),this._resources=null,this._optionalFields=new Array,this._instanceIndexToGraphicUid=new Map,this._hasLoadedPBRTextures=!1,this._disposeResourceHandles=new Array,this.skipHighSymbolLodsChanged=!1,this.ensureDrapedStatus(!1),this._hasLoadedPBRTextures=s.physicalBasedRenderingEnabled}async doLoad(e){if(!this._drivenProperties.size){if(D(this.symbolLayer))throw new Error}if(this._isPrimitive){const t=this.symbolLayer.resource,s=t&&J(t.primitive)?t.primitive:E;this._resources=await this._createResourcesForPrimitive(s,e)}else{const t=await Z(this.symbol.styleOrigin),s=t?.href??this.symbolLayer.resource.href;this._resources=await this._createResourcesForUrl(s,e)}this.layerOpacityChanged(),this.slicePlaneEnabledChanged(),this.physicalBasedRenderingChanged(),this.complexity=this.computeComplexity()}get extentPadding(){return null!=this._resources?this._resources.extentPadding:0}get _isPrimitive(){return!this.symbolLayer.resource?.href}get lodRenderer(){return this._resources?.lodRenderer}_setMaterialTransparencyParams(e,t=this.symbolLayer?.material?.color){const s=this._getCombinedOpacity(t),r=s<1||this.needsDrivenTransparentPass;return e.transparent=r,e.opacity=s,e.cullFace=r?se.None:se.Back,e}async _createResourcesForPrimitive(t,r){const i=this.symbolLayer,a=L(w(t)),o=y(C(a)),n=y(T(o,i)),l=c(n),h=!1,d=!1,m={usePBR:this._context.physicalBasedRenderingEnabled,isSchematic:!0,mrrFactors:[...he],ambient:f,diffuse:f,hasSlicePlane:this._context.slicePlaneEnabled,hasSliceHighlight:!1,castShadows:this.symbolLayer.castShadows,offsetTransparentBackfaces:!this.symbolLayer.isPrimitive},p=!!m.usePBR;this._setMaterialTransparencyParams(m);const u=this.symbol;if("point-3d"===u.type&&u.verticalOffset){const{screenLength:e,minWorldLength:t,maxWorldLength:r}=u.verticalOffset;m.verticalOffset={screenLength:s(e),minWorldLength:t||0,maxWorldLength:null!=r?r:1/0},m.castShadows=!1}if(this._context.screenSizePerspectiveEnabled&&(m.screenSizePerspective=this._context.sharedResources.screenSizePerspectiveSettings),this._drivenProperties.color)m.externalColor=P;else{const t=null!=i.material?i.material.color:null,s=null!=t?e.toUnitRGBA(t):P;m.externalColor=s}this._fastUpdates=K(this._context.renderer,this._fastVisualVariableConvertOptions(a,n,o,null)),m.isInstanced=!0,this._fastUpdates?(Object.assign(m,this._fastUpdates.materialParameters),this._optionalFields.push(re.FEATUREATTRIBUTE)):this._hasPerInstanceColor()&&(m.hasInstancedColor=!0,this._optionalFields.push(re.COLOR)),has("enable-feature:objectAndLayerId-rendering")&&this._optionalFields.push(re.OBJECTANDLAYERIDCOLOR);const _=new ce(m),g=Y(t,_);if(!g)throw new Error(`Unknown object symbol primitive: ${t}`);const b=ae(g).map((e=>({opacity:1,transparent:e.parameters.transparent}))),R=await this._createStageResources(g,p,r),x=await this._createLodRenderer(g,r);return new de(g,x,R,b,o,h,d,a,n,l,p,null)}async _createResourcesForUrl(e,t){const r={materialParamsMixin:{isInstanced:!0,hasSlicePlane:this._context.slicePlaneEnabled,castShadows:this.symbolLayer.castShadows},streamDataRequester:this._context.streamDataRequester,cache:this._context.sharedResources.objectResourceCache};this._fastUpdates=K(this._context.renderer,this._fastVisualVariableConvertOptions(null,null,null,null)),this._fastUpdates?(Object.assign(r.materialParamsMixin,this._fastUpdates.materialParameters),this._optionalFields.push(re.FEATUREATTRIBUTE)):this._hasPerInstanceColor()&&(r.materialParamsMixin.hasInstancedColor=!0,this._optionalFields.push(re.COLOR)),has("enable-feature:objectAndLayerId-rendering")&&this._optionalFields.push(re.OBJECTANDLAYERIDCOLOR);const i=this.symbol;if("point-3d"===i.type&&i.verticalOffset){const{screenLength:e,minWorldLength:t,maxWorldLength:a}=i.verticalOffset;r.materialParamsMixin.verticalOffset={screenLength:s(e),minWorldLength:t||0,maxWorldLength:null!=a?a:1/0},r.materialParamsMixin.castShadows=!1}r.signal=t,r.usePBR=this._context.physicalBasedRenderingEnabled,r.skipHighLods=this._context.skipHighSymbolLods;const a=r.usePBR,o=await W(e,r),n=o.isEsriSymbolResource,l=o.isWosr,h=H(o.lods);h.levels.sort(((e,t)=>e.minScreenSpaceRadius-t.minScreenSpaceRadius));const d=this._context,m=this.symbolLayer.material,p=this._getExternalColorParameters(m),u=this.symbolLayer?.material?.color,f=this._getCombinedOpacity(u,{hasIntrinsicColor:!0}),_=this.needsDrivenTransparentPass,g=ae(h),b=ae(h).map((e=>({opacity:e.parameters.opacity||1,transparent:e.parameters.transparent})));g.forEach((e=>{const t=e.parameters;e.setParameters(p);const s=t.opacity*f,r=s<1||_||t.transparent;e.setParameters({opacity:s,transparent:r}),d.screenSizePerspectiveEnabled&&e.setParameters({screenSizePerspective:d.sharedResources.screenSizePerspectiveSettings})}));const P=o.referenceBoundingBox,R=y(C(P)),x=y(h.levels[0].pivotOffset),v=y(T(R,this.symbolLayer)),L=c(v),S=this._fastUpdates;Q(S,this._context.renderer,this._fastVisualVariableConvertOptions(P,v,R,x))&&g.forEach((e=>e.setParameters(S.materialParameters)));const j=await this._createStageResources(h,a,t),E=await this._createLodRenderer(h,t);return new de(h,E,j,b,R,n,l,P,v,L,a,x)}_addDisposeResource(e){this._disposeResourceHandles.push(e)}async _createStageResources(e,s,r){const i=this._context.stage,a=ae(e);s!==this._context.physicalBasedRenderingEnabled&&this.physicalBasedRenderingChanged(),i.addMany(a),this._addDisposeResource((()=>i.removeMany(a)));const o=oe(e);i.addMany(o),this._addDisposeResource((()=>i.removeMany(o))),await i.load(o,r),t(r);const n=ne(e);return i.addMany(n),this._addDisposeResource((()=>i.removeMany(n))),{materials:a,textures:o,geometries:n}}async _createLodRenderer(e,t){const s=this._context.stage,r={layerUid:this._context.layer.uid,graphicUid:e=>this._instanceIndexToGraphicUid.get(e),notifyGraphicGeometryChanged:e=>this._context.notifyGraphicGeometryChanged(this._instanceIndexToGraphicUid.get(e)),notifyGraphicVisibilityChanged:e=>this._context.notifyGraphicVisibilityChanged(this._instanceIndexToGraphicUid.get(e))},i=this._fastUpdates,a=i?{applyTransform:(e,t,s)=>{e.getFeatureAttribute(t,fe),n(s,ee(i.materialParameters,fe,s))},scaleFactor:(e,t,s)=>{t.getFeatureAttribute(s,fe),te(e,i.materialParameters,fe)}}:null,o=new ie({symbol:e,optionalFields:this._optionalFields,metadata:r,shaderTransformation:a},this._context.scheduler);return o.slicePlaneEnabled=this._context.slicePlaneEnabled,this._addDisposeResource((()=>{s.removeRenderPlugin(o),o.destroy()})),await s.addRenderPlugin(o,t),o}_getExternalColorParameters(t){const s={};return this._drivenProperties.color?s.externalColor=P:null!=t&&null!=t.color?s.externalColor=e.toUnitRGBA(t.color):(s.externalColor=P,s.colorMixMode="ignore"),s}destroy(){super.destroy(),this._cleanupResources()}_cleanupResources(){this._disposeResourceHandles.forEach((e=>e())),this._disposeResourceHandles.length=0,this._resources=null}createGraphics3DGraphic(e){const t=e.graphic;if(!this._validateGeometry(t.geometry))return null;const s=q(t.geometry);if(null==s)return this.logger.warn(`unsupported geometry type for icon symbol: ${t.geometry.type}`),null;const r=this.setGraphicElevationContext(t),i=e.renderingInfo;return this._createAs3DShape(t,s,i,r,t.uid,e.layer.uid)}notifyDestroyGraphicLayer(e){this._instanceIndexToGraphicUid.delete(e.instanceIndex)}graphicLayerToGraphicId(){return 0}layerOpacityChanged(){if(null==this._resources)return;const e=this._drivenProperties.opacity,t=!this._isPrimitive,s=this._resources.stageResources.materials,r=this._resources.originalMaterialParameters;for(let i=0;i<s.length;i++){const a=s[i],o=this.symbolLayer?.material?.color,n=r[i],l=this._getCombinedOpacity(o,{hasIntrinsicColor:t})*n.opacity,c=l<1||e||n.transparent;a.setParameters({opacity:l,transparent:c}),this._isPrimitive&&a.setParameters({cullFace:c?se.None:se.Back})}}layerElevationInfoChanged(e,t){return this.updateGraphics3DGraphicElevationInfo(e,t,O)}slicePlaneEnabledChanged(){if(null==this._resources)return!0;this._resources.lodRenderer.slicePlaneEnabled=this._context.slicePlaneEnabled;for(const e of this._resources.stageResources.materials)e.setParameters({hasSlicePlane:this._context.slicePlaneEnabled});return!0}physicalBasedRenderingChanged(){if(null==this._resources)return!0;const{stageResources:e,isWosr:t}=this._resources;for(const s of e.materials)this._isPrimitive?s.setParameters({usePBR:this._context.physicalBasedRenderingEnabled,isSchematic:!0}):t||s.setParameters({usePBR:this._context.physicalBasedRenderingEnabled,isSchematic:!1});return!1!==this._hasLoadedPBRTextures||!0!==this._context.physicalBasedRenderingEnabled||(this._hasLoadedPBRTextures=!0,!1)}applyRendererDiff(e,t){if(null==this._resources)return V.RecreateSymbol;const{stageResources:{materials:s},lodRenderer:r,resourceBoundingBox:i,symbolSize:a,resourceSize:o,pivotOffset:n}=this._resources;for(const l in e.diff){if("visualVariables"!==l)return V.RecreateSymbol;if(!Q(this._fastUpdates,t,this._fastVisualVariableConvertOptions(i,a,o,n)))return V.RecreateSymbol;for(const e of s)e.setParameters(this._fastUpdates.materialParameters);r.notifyShaderTransformationChanged()}return V.FastUpdate}computeComplexity(){if(null==this._resources)return super.computeComplexity();const e=this._resources.lodResources,t=le(e.levels[0]).reduce(((e,t)=>e+t.indices.get(re.POSITION).length),0)/3,s=e=>Array.from(e.vertexAttributes.values()).reduce(((e,t)=>e+r(t.data)),0)+Array.from(e.indices.values()).reduce(((e,t)=>e+r(t)),0),i=oe(e).reduce(((e,t)=>e+t.memoryEstimate),0)+ne(e).reduce(((e,t)=>e+s(t)),0);return{primitivesPerFeature:t,primitivesPerCoordinate:0,drawCallsPerFeature:0,estimated:!1,memory:{...$(this.symbol,this.symbolLayer),resourceBytes:i}}}_hasLodRenderer(){return null!=this._resources}_createAs3DShape(e,t,s,r,i,a){if(!this._hasLodRenderer()||null==this._resources)return null;const o=this.getFastUpdateAttrValues(e),n=this._context.clippingExtent;if(v(t,pe,this._context.elevationProvider.spatialReference),null!=n&&!S(n,pe))return null;const l=this._requiresTerrainElevation(r),c=this._computeGlobalTransform(t,r,ye,_e),h=this._computeLocalTransform(this._resources,this.symbolLayer,s,ue),d=this._resources.lodRenderer.instanceData,m=d.addInstance();this._instanceIndexToGraphicUid.set(m,i),d.setLocalTransform(m,h,!1),d.setGlobalTransform(m,c),o&&d.setFeatureAttribute(m,o),null==this._fastUpdates&&this._hasPerInstanceColor()&&d.setColor(m,F(s.color,s.opacity,255)),null!=this._context.stage.renderView.objectAndLayerIdRenderHelper&&d.setObjectAndLayerIdColor(m,this._context.stage.renderView.objectAndLayerIdRenderHelper.getObjectAndLayerIdColor({graphicUid:i,layerUid:a}));const p=new A(this,m,U,r);return l&&(p.alignedSampledElevation=_e.sampledElevation),p.needsElevationUpdates=O(r.mode),N(p,t,this._context.elevationProvider),p}_computeGlobalTransform(e,t,s,r){return B(e,this._context.elevationProvider,t,this._context.renderCoordsHelper,r),pe[0]=e.x,pe[1]=e.y,pe[2]=r.z,x(e.spatialReference,pe,s,this._context.renderCoordsHelper.spatialReference),s}_computeLocalTransform(e,t,s,r){return i(r),this._applyObjectRotation(s,!1,r),this._applyObjectRotation(t,!0,r),this._applyObjectScale(e,s,r),this._applyAnchor(e,t,r),r}_applyObjectScale(e,t,s){if(this._fastUpdates?.requiresShaderTransformation)return;const r=this._drivenProperties.size&&t.size?t.size:e.symbolSize,i=z(r,e.symbolSize,e.resourceSize,this._context.renderCoordsHelper.unitInMeters);1===i[0]&&1===i[1]&&1===i[2]||a(s,s,i)}prepareSymbolLayerPatch(e){if("partial"!==e.diff.type)return;const t=e.diff.diff;this._preparePatchTransform(e,t),this._preparePatchColor(e,t)}updateGeometry(e,t){if(null==this._resources)return!0;const s=t&&q(t);if(null==s)return!1;const r=this.getGeometryElevationMode(t);return e.elevationContext.mode===r&&(this._computeGlobalTransform(s,e.elevationContext,ye,_e),this._requiresTerrainElevation(e.elevationContext)&&(e.alignedSampledElevation=_e.sampledElevation),this._resources.lodRenderer.instanceData.setGlobalTransform(e.instanceIndex,ye,!0),N(e,s,this._context.elevationProvider),!0)}_preparePatchTransform(e,t){if(!(t.heading||t.tilt||t.roll||t.width||t.height||t.depth||t.anchor||t.anchorPosition))return;if(null==this._resources)return;const s=(e,t,s)=>(null!=e&&"complete"===e.type?e.newValue:t)??s,r=s(t.heading,this.symbolLayer.heading,0),i=s(t.tilt,this.symbolLayer.tilt,0),a=s(t.roll,this.symbolLayer.roll,0),o=s(t.width,this.symbolLayer.width,void 0),n=s(t.height,this.symbolLayer.height,void 0),l=s(t.depth,this.symbolLayer.depth,void 0),c=s(t.anchor,this.symbolLayer.anchor,void 0),h=s(t.anchorPosition,this.symbolLayer.anchorPosition,void 0);delete t.heading,delete t.tilt,delete t.roll,delete t.width,delete t.height,delete t.depth,delete t.anchor,delete t.anchorPosition;const d={heading:r,tilt:i,roll:a,anchor:c,anchorPosition:h},m=this._resources;this.loadStatus===k.LOADED&&e.symbolLayerStatePatches.push((()=>{m.symbolSize=y(T(m.resourceSize,{width:o,height:n,depth:l,isPrimitive:this.symbolLayer.isPrimitive}))})),e.graphics3DGraphicPatches.push(((e,t)=>{const s=this._computeLocalTransform(m,d,t,ue),r=e.instanceIndex;m.lodRenderer.instanceData.setLocalTransform(r,s,!0)}))}_preparePatchColor(t,s){if(!s.material||"partial"!==s.material.type)return;const r=s.material.diff;if(!r.color||"complete"!==r.color.type||null==r.color.newValue||null==r.color.oldValue)return;const i=r.color.newValue,a=null!=i?e.toUnitRGBA(i):P;delete r.color;const o=this._resources;null!=o&&t.graphics3DGraphicPatches.push((e=>{let t;this._hasPerInstanceColor()?(o.lodRenderer.instanceData.setColor(e.instanceIndex,a),t=this._setMaterialTransparencyParams({},i)):t=this._setMaterialTransparencyParams({externalColor:a},i);for(const s of o.stageResources.materials)s.setParameters(t)}))}_requiresTerrainElevation(e){return"absolute-height"!==e.mode}_applyObjectRotation(e,t,s){if(!this._fastUpdates?.requiresShaderTransformation||!t)return M(e.heading,e.tilt,e.roll,s)}_computeAnchor(e,t,s){const r=b();switch(s.anchor){case"center":d(r,j(e)),h(r,r);break;case"top":{const t=j(e);u(r,-t[0],-t[1],-e[5]);break}case"bottom":{const t=j(e);u(r,-t[0],-t[1],-e[2]);break}case"relative":{const t=j(e),i=C(e),a=s.anchorPosition,o=a?g(a.x,a.y,a.z):_;m(r,i,o),p(r,r,t),h(r,r);break}default:null!=t?h(r,t):d(r,_)}return r}_applyAnchor(e,t,s){if(this._fastUpdates?.requiresShaderTransformation)return;const r=this._computeAnchor(e.resourceBoundingBox,e.pivotOffset,t);r&&o(s,s,r)}_hasPerInstanceColor(){return this._drivenProperties.color||this._drivenProperties.opacity}_fastVisualVariableConvertOptions(e,t,s,r){const i=null!=e?y(C(e)):f,a=null!=e?this._computeAnchor(e,r,this.symbolLayer):_,o=this._context.renderCoordsHelper.unitInMeters,n=z(null!=t?t:void 0,t,s,o),l=g(this.symbolLayer.tilt||0,this.symbolLayer.roll||0,this.symbolLayer.heading||0);return new X({size:!0,color:!0,rotation:!0,opacity:!1},i,t??f,o,a,n,l)}}const pe=b(),ue=l(),ye=l(),fe=R(),_e=new I;export{me as Graphics3DObjectSymbolLayer};
5
+ import e from"../../../../Color.js";import has from"../../../../core/has.js";import{throwIfAborted as t}from"../../../../core/promiseUtils.js";import{pt2px as s}from"../../../../core/screenUtils.js";import{estimateSize as r}from"../../../../core/typedArrayUtil.js";import{i,k as a,w as o,c as n}from"../../../../chunks/mat4.js";import{c as l}from"../../../../chunks/mat4f64.js";import{l as c,o as h,i as d,C as m,e as p,s as u}from"../../../../chunks/vec3.js";import{g as y,O as f,Z as _,f as g,c as b}from"../../../../chunks/vec3f64.js";import{O as P,c as R}from"../../../../chunks/vec4f64.js";import{computeTranslationToOriginAndRotation as x}from"../../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{projectPointToVector as v}from"../../../../geometry/projection/projectPointToVector.js";import{create as L,size as C,containsPoint as S,center as j}from"../../../../geometry/support/aaBoundingBox.js";import{defaultPrimitive as E}from"../../../../symbols/support/ObjectSymbol3DLayerResource.js";import{objectSymbolLayerPrimitiveBoundingBox as w,objectSymbolLayerSizeWithResourceSize as T}from"../../../../symbols/support/symbolLayerUtils3D.js";import{perLodInstanceElevationAligner as U}from"./ElevationAligners.js";import{needsElevationUpdates3D as O,evaluateElevationInfoAtPoint as B,SampleElevationInfo as I}from"./elevationAlignmentUtils.js";import{Graphics3DLodInstanceGraphicLayer as A}from"./Graphics3DLodInstanceGraphicLayer.js";import{Graphics3DSymbolLayer as G}from"./Graphics3DSymbolLayer.js";import{validateSymbolLayerSize as D,mixinColorAndOpacity as F,computeObjectScale as z,computeObjectRotation as M}from"./graphicUtils.js";import{ApplyRendererDiffResult as V}from"./interfaces.js";import{LoadStatus as k}from"./Loadable.js";import{makeLodResources as H}from"./lodResourceUtils.js";import{fetch as W}from"./objectResourceUtils.js";import{placePointOnGeometry as q,extendPointGraphicElevationContext as N}from"./pointUtils.js";import{isValidPrimitive as J,primitiveLodResources as Y}from"./primitiveObjectSymbolUtils.js";import{defaultSymbolLayerMemoryComplexity as $}from"./symbolComplexity.js";import{getResourceUrlFromSymbolStyle as Z}from"./webStyleUtils.js";import{initFastSymbolUpdatesState as K,updateFastSymbolUpdatesState as Q,ConvertOptions as X,evaluateModelTransform as ee,evaluateModelTransformScale as te}from"../support/FastSymbolUpdates.js";import{CullFaceOptions as se}from"../../webgl-engine/lib/basicInterfaces.js";import{VertexAttribute as re}from"../../webgl-engine/lib/VertexAttribute.js";import{LodRenderer as ie}from"../../webgl-engine/lib/lodRendering/LodRenderer.js";import{materialsFromLodResources as ae,texturesFromLodResources as oe,geometriesFromLodResources as ne,geometriesFromLodLevelResources as le}from"../../webgl-engine/lib/lodRendering/LodResources.js";import{DefaultMaterial as ce}from"../../webgl-engine/materials/DefaultMaterial.js";import{defaultSchematicMRRFactors as he}from"../../webgl-engine/materials/pbrUtils.js";class de{constructor(e,t,s,r,i,a,o,n,l,c,h,d){this.lodResources=e,this.lodRenderer=t,this.stageResources=s,this.originalMaterialParameters=r,this.resourceSize=i,this.isEsriSymbolResource=a,this.isWosr=o,this.resourceBoundingBox=n,this.symbolSize=l,this.extentPadding=c,this.physicalBasedRenderingEnabled=h,this.pivotOffset=d}}class me extends G{getCachedSize(){const[e,t,s]=null!=this._resources?this._resources.symbolSize:[1,1,1];return{width:e,depth:t,height:s}}constructor(e,t,s,r){super(e,t,s,r),this._resources=null,this._optionalFields=new Array,this._instanceIndexToGraphicUid=new Map,this._hasLoadedPBRTextures=!1,this._disposeResourceHandles=new Array,this.skipHighSymbolLodsChanged=!1,this.ensureDrapedStatus(!1),this._hasLoadedPBRTextures=s.physicalBasedRenderingEnabled}async doLoad(e){if(!this._drivenProperties.size){if(D(this.symbolLayer))throw new Error}if(this._isPrimitive){const t=this.symbolLayer.resource,s=t&&J(t.primitive)?t.primitive:E;this._resources=await this._createResourcesForPrimitive(s,e)}else{const t=await Z(this.symbol.styleOrigin),s=t?.href??this.symbolLayer.resource.href;this._resources=await this._createResourcesForUrl(s,e)}this.layerOpacityChanged(),this.slicePlaneEnabledChanged(),this.physicalBasedRenderingChanged(),this.complexity=this.computeComplexity()}get extentPadding(){return null!=this._resources?this._resources.extentPadding:0}get _isPrimitive(){return!this.symbolLayer.resource?.href}get lodRenderer(){return this._resources?.lodRenderer}_setMaterialTransparencyParams(e,t=this.symbolLayer?.material?.color){const s=this._getCombinedOpacity(t),r=s<1||this.needsDrivenTransparentPass;return e.transparent=r,e.opacity=s,e.cullFace=r?se.None:se.Back,e}async _createResourcesForPrimitive(t,r){const i=this.symbolLayer,a=L(w(t)),o=y(C(a)),n=y(T(o,i)),l=c(n),h=!1,d=!1,m={usePBR:this._context.physicalBasedRenderingEnabled,isSchematic:!0,mrrFactors:[...he],ambient:f,diffuse:f,hasSlicePlane:this._context.slicePlaneEnabled,hasSliceHighlight:!1,castShadows:this.symbolLayer.castShadows,offsetTransparentBackfaces:!this.symbolLayer.isPrimitive},p=!!m.usePBR;this._setMaterialTransparencyParams(m);const u=this.symbol;if("point-3d"===u.type&&u.verticalOffset){const{screenLength:e,minWorldLength:t,maxWorldLength:r}=u.verticalOffset;m.verticalOffset={screenLength:s(e),minWorldLength:t||0,maxWorldLength:null!=r?r:1/0},m.castShadows=!1}if(this._context.screenSizePerspectiveEnabled&&(m.screenSizePerspective=this._context.sharedResources.screenSizePerspectiveSettings),this._drivenProperties.color)m.externalColor=P;else{const t=null!=i.material?i.material.color:null,s=null!=t?e.toUnitRGBA(t):P;m.externalColor=s}this._fastUpdates=K(this._context.renderer,this._fastVisualVariableConvertOptions(a,n,o,null)),m.isInstanced=!0,this._fastUpdates?(Object.assign(m,this._fastUpdates.materialParameters),this._optionalFields.push(re.FEATUREATTRIBUTE)):this._hasPerInstanceColor()&&(m.hasInstancedColor=!0,this._optionalFields.push(re.COLOR)),has("enable-feature:objectAndLayerId-rendering")&&this._optionalFields.push(re.OBJECTANDLAYERIDCOLOR);const _=new ce(m),g=Y(t,_);if(!g)throw new Error(`Unknown object symbol primitive: ${t}`);const b=ae(g).map((e=>({opacity:1,transparent:e.parameters.transparent}))),R=await this._createStageResources(g,p,r),x=await this._createLodRenderer(g,r);return new de(g,x,R,b,o,h,d,a,n,l,p,null)}async _createResourcesForUrl(e,t){const r={materialParamsMixin:{isInstanced:!0,hasSlicePlane:this._context.slicePlaneEnabled,castShadows:this.symbolLayer.castShadows},streamDataRequester:this._context.streamDataRequester,cache:this._context.sharedResources.objectResourceCache};this._fastUpdates=K(this._context.renderer,this._fastVisualVariableConvertOptions(null,null,null,null)),this._fastUpdates?(Object.assign(r.materialParamsMixin,this._fastUpdates.materialParameters),this._optionalFields.push(re.FEATUREATTRIBUTE)):this._hasPerInstanceColor()&&(r.materialParamsMixin.hasInstancedColor=!0,this._optionalFields.push(re.COLOR)),has("enable-feature:objectAndLayerId-rendering")&&this._optionalFields.push(re.OBJECTANDLAYERIDCOLOR);const i=this.symbol;if("point-3d"===i.type&&i.verticalOffset){const{screenLength:e,minWorldLength:t,maxWorldLength:a}=i.verticalOffset;r.materialParamsMixin.verticalOffset={screenLength:s(e),minWorldLength:t||0,maxWorldLength:null!=a?a:1/0},r.materialParamsMixin.castShadows=!1}r.signal=t,r.usePBR=this._context.physicalBasedRenderingEnabled,r.skipHighLods=this._context.skipHighSymbolLods;const a=r.usePBR,o=await W(e,r),n=o.isEsriSymbolResource,l=o.isWosr,h=H(o.lods);h.levels.sort(((e,t)=>e.minScreenSpaceRadius-t.minScreenSpaceRadius));const d=this._context,m=this.symbolLayer.material,p=this._getExternalColorParameters(m),u=this.symbolLayer?.material?.color,f=this._getCombinedOpacity(u,{hasIntrinsicColor:!0}),_=this.needsDrivenTransparentPass,g=ae(h),b=ae(h).map((e=>({opacity:e.parameters.opacity||1,transparent:e.parameters.transparent})));g.forEach((e=>{const t=e.parameters;e.setParameters(p);const s=t.opacity*f,r=s<1||_||t.transparent;e.setParameters({opacity:s,transparent:r}),d.screenSizePerspectiveEnabled&&e.setParameters({screenSizePerspective:d.sharedResources.screenSizePerspectiveSettings})}));const P=o.referenceBoundingBox,R=y(C(P)),x=y(h.levels[0].pivotOffset),v=y(T(R,this.symbolLayer)),L=c(v),S=this._fastUpdates;Q(S,this._context.renderer,this._fastVisualVariableConvertOptions(P,v,R,x))&&g.forEach((e=>e.setParameters(S.materialParameters)));const j=await this._createStageResources(h,a,t),E=await this._createLodRenderer(h,t);return new de(h,E,j,b,R,n,l,P,v,L,a,x)}_addDisposeResource(e){this._disposeResourceHandles.push(e)}async _createStageResources(e,s,r){const i=this._context.stage,a=ae(e);s!==this._context.physicalBasedRenderingEnabled&&this.physicalBasedRenderingChanged(),i.addMany(a),this._addDisposeResource((()=>i.removeMany(a)));const o=oe(e);i.addMany(o),this._addDisposeResource((()=>{o.forEach((e=>e.unload())),i.removeMany(o)})),await Promise.all(o.map((e=>this._context.stage.schedule((()=>e.load(i.renderView.renderingContext)),r)))),t(r);const n=ne(e);return i.addMany(n),this._addDisposeResource((()=>i.removeMany(n))),{materials:a,textures:o,geometries:n}}async _createLodRenderer(e,t){const s=this._context.stage,r={layerUid:this._context.layer.uid,graphicUid:e=>this._instanceIndexToGraphicUid.get(e),notifyGraphicGeometryChanged:e=>this._context.notifyGraphicGeometryChanged(this._instanceIndexToGraphicUid.get(e)),notifyGraphicVisibilityChanged:e=>this._context.notifyGraphicVisibilityChanged(this._instanceIndexToGraphicUid.get(e))},i=this._fastUpdates,a=i?{applyTransform:(e,t,s)=>{e.getFeatureAttribute(t,fe),n(s,ee(i.materialParameters,fe,s))},scaleFactor:(e,t,s)=>{t.getFeatureAttribute(s,fe),te(e,i.materialParameters,fe)}}:null,o=new ie({symbol:e,optionalFields:this._optionalFields,metadata:r,shaderTransformation:a},this._context.scheduler);return o.slicePlaneEnabled=this._context.slicePlaneEnabled,this._addDisposeResource((()=>{s.removeRenderPlugin(o),o.destroy()})),await s.addRenderPlugin(o,t),o}_getExternalColorParameters(t){const s={};return this._drivenProperties.color?s.externalColor=P:null!=t&&null!=t.color?s.externalColor=e.toUnitRGBA(t.color):(s.externalColor=P,s.colorMixMode="ignore"),s}destroy(){super.destroy(),this._cleanupResources()}_cleanupResources(){this._disposeResourceHandles.forEach((e=>e())),this._disposeResourceHandles.length=0,this._resources=null}createGraphics3DGraphic(e){const t=e.graphic;if(!this._validateGeometry(t.geometry))return null;const s=q(t.geometry);if(null==s)return this.logger.warn(`unsupported geometry type for icon symbol: ${t.geometry.type}`),null;const r=this.setGraphicElevationContext(t),i=e.renderingInfo;return this._createAs3DShape(t,s,i,r,t.uid,e.layer.uid)}notifyDestroyGraphicLayer(e){this._instanceIndexToGraphicUid.delete(e.instanceIndex)}graphicLayerToGraphicId(){return 0}layerOpacityChanged(){if(null==this._resources)return;const e=this._drivenProperties.opacity,t=!this._isPrimitive,s=this._resources.stageResources.materials,r=this._resources.originalMaterialParameters;for(let i=0;i<s.length;i++){const a=s[i],o=this.symbolLayer?.material?.color,n=r[i],l=this._getCombinedOpacity(o,{hasIntrinsicColor:t})*n.opacity,c=l<1||e||n.transparent;a.setParameters({opacity:l,transparent:c}),this._isPrimitive&&a.setParameters({cullFace:c?se.None:se.Back})}}layerElevationInfoChanged(e,t){return this.updateGraphics3DGraphicElevationInfo(e,t,O)}slicePlaneEnabledChanged(){if(null==this._resources)return!0;this._resources.lodRenderer.slicePlaneEnabled=this._context.slicePlaneEnabled;for(const e of this._resources.stageResources.materials)e.setParameters({hasSlicePlane:this._context.slicePlaneEnabled});return!0}physicalBasedRenderingChanged(){if(null==this._resources)return!0;const{stageResources:e,isWosr:t}=this._resources;for(const s of e.materials)this._isPrimitive?s.setParameters({usePBR:this._context.physicalBasedRenderingEnabled,isSchematic:!0}):t||s.setParameters({usePBR:this._context.physicalBasedRenderingEnabled,isSchematic:!1});return!1!==this._hasLoadedPBRTextures||!0!==this._context.physicalBasedRenderingEnabled||(this._hasLoadedPBRTextures=!0,!1)}applyRendererDiff(e,t){if(null==this._resources)return V.RecreateSymbol;const{stageResources:{materials:s},lodRenderer:r,resourceBoundingBox:i,symbolSize:a,resourceSize:o,pivotOffset:n}=this._resources;for(const l in e.diff){if("visualVariables"!==l)return V.RecreateSymbol;if(!Q(this._fastUpdates,t,this._fastVisualVariableConvertOptions(i,a,o,n)))return V.RecreateSymbol;for(const e of s)e.setParameters(this._fastUpdates.materialParameters);r.notifyShaderTransformationChanged()}return V.FastUpdate}computeComplexity(){if(null==this._resources)return super.computeComplexity();const e=this._resources.lodResources,t=le(e.levels[0]).reduce(((e,t)=>e+t.indices.get(re.POSITION).length),0)/3,s=e=>Array.from(e.vertexAttributes.values()).reduce(((e,t)=>e+r(t.data)),0)+Array.from(e.indices.values()).reduce(((e,t)=>e+r(t)),0),i=oe(e).reduce(((e,t)=>e+t.memoryEstimate),0)+ne(e).reduce(((e,t)=>e+s(t)),0);return{primitivesPerFeature:t,primitivesPerCoordinate:0,drawCallsPerFeature:0,estimated:!1,memory:{...$(this.symbol,this.symbolLayer),resourceBytes:i}}}_hasLodRenderer(){return null!=this._resources}_createAs3DShape(e,t,s,r,i,a){if(!this._hasLodRenderer()||null==this._resources)return null;const o=this.getFastUpdateAttrValues(e),n=this._context.clippingExtent;if(v(t,pe,this._context.elevationProvider.spatialReference),null!=n&&!S(n,pe))return null;const l=this._requiresTerrainElevation(r),c=this._computeGlobalTransform(t,r,ye,_e),h=this._computeLocalTransform(this._resources,this.symbolLayer,s,ue),d=this._resources.lodRenderer.instanceData,m=d.addInstance();this._instanceIndexToGraphicUid.set(m,i),d.setLocalTransform(m,h,!1),d.setGlobalTransform(m,c),o&&d.setFeatureAttribute(m,o),null==this._fastUpdates&&this._hasPerInstanceColor()&&d.setColor(m,F(s.color,s.opacity,255)),null!=this._context.stage.renderView.objectAndLayerIdRenderHelper&&d.setObjectAndLayerIdColor(m,this._context.stage.renderView.objectAndLayerIdRenderHelper.getObjectAndLayerIdColor({graphicUid:i,layerUid:a}));const p=new A(this,m,U,r);return l&&(p.alignedSampledElevation=_e.sampledElevation),p.needsElevationUpdates=O(r.mode),N(p,t,this._context.elevationProvider),p}_computeGlobalTransform(e,t,s,r){return B(e,this._context.elevationProvider,t,this._context.renderCoordsHelper,r),pe[0]=e.x,pe[1]=e.y,pe[2]=r.z,x(e.spatialReference,pe,s,this._context.renderCoordsHelper.spatialReference),s}_computeLocalTransform(e,t,s,r){return i(r),this._applyObjectRotation(s,!1,r),this._applyObjectRotation(t,!0,r),this._applyObjectScale(e,s,r),this._applyAnchor(e,t,r),r}_applyObjectScale(e,t,s){if(this._fastUpdates?.requiresShaderTransformation)return;const r=this._drivenProperties.size&&t.size?t.size:e.symbolSize,i=z(r,e.symbolSize,e.resourceSize,this._context.renderCoordsHelper.unitInMeters);1===i[0]&&1===i[1]&&1===i[2]||a(s,s,i)}prepareSymbolLayerPatch(e){if("partial"!==e.diff.type)return;const t=e.diff.diff;this._preparePatchTransform(e,t),this._preparePatchColor(e,t)}updateGeometry(e,t){if(null==this._resources)return!0;const s=t&&q(t);if(null==s)return!1;const r=this.getGeometryElevationMode(t);return e.elevationContext.mode===r&&(this._computeGlobalTransform(s,e.elevationContext,ye,_e),this._requiresTerrainElevation(e.elevationContext)&&(e.alignedSampledElevation=_e.sampledElevation),this._resources.lodRenderer.instanceData.setGlobalTransform(e.instanceIndex,ye,!0),N(e,s,this._context.elevationProvider),!0)}_preparePatchTransform(e,t){if(!(t.heading||t.tilt||t.roll||t.width||t.height||t.depth||t.anchor||t.anchorPosition))return;if(null==this._resources)return;const s=(e,t,s)=>(null!=e&&"complete"===e.type?e.newValue:t)??s,r=s(t.heading,this.symbolLayer.heading,0),i=s(t.tilt,this.symbolLayer.tilt,0),a=s(t.roll,this.symbolLayer.roll,0),o=s(t.width,this.symbolLayer.width,void 0),n=s(t.height,this.symbolLayer.height,void 0),l=s(t.depth,this.symbolLayer.depth,void 0),c=s(t.anchor,this.symbolLayer.anchor,void 0),h=s(t.anchorPosition,this.symbolLayer.anchorPosition,void 0);delete t.heading,delete t.tilt,delete t.roll,delete t.width,delete t.height,delete t.depth,delete t.anchor,delete t.anchorPosition;const d={heading:r,tilt:i,roll:a,anchor:c,anchorPosition:h},m=this._resources;this.loadStatus===k.LOADED&&e.symbolLayerStatePatches.push((()=>{m.symbolSize=y(T(m.resourceSize,{width:o,height:n,depth:l,isPrimitive:this.symbolLayer.isPrimitive}))})),e.graphics3DGraphicPatches.push(((e,t)=>{const s=this._computeLocalTransform(m,d,t,ue),r=e.instanceIndex;m.lodRenderer.instanceData.setLocalTransform(r,s,!0)}))}_preparePatchColor(t,s){if(!s.material||"partial"!==s.material.type)return;const r=s.material.diff;if(!r.color||"complete"!==r.color.type||null==r.color.newValue||null==r.color.oldValue)return;const i=r.color.newValue,a=null!=i?e.toUnitRGBA(i):P;delete r.color;const o=this._resources;null!=o&&t.graphics3DGraphicPatches.push((e=>{let t;this._hasPerInstanceColor()?(o.lodRenderer.instanceData.setColor(e.instanceIndex,a),t=this._setMaterialTransparencyParams({},i)):t=this._setMaterialTransparencyParams({externalColor:a},i);for(const s of o.stageResources.materials)s.setParameters(t)}))}_requiresTerrainElevation(e){return"absolute-height"!==e.mode}_applyObjectRotation(e,t,s){if(!this._fastUpdates?.requiresShaderTransformation||!t)return M(e.heading,e.tilt,e.roll,s)}_computeAnchor(e,t,s){const r=b();switch(s.anchor){case"center":d(r,j(e)),h(r,r);break;case"top":{const t=j(e);u(r,-t[0],-t[1],-e[5]);break}case"bottom":{const t=j(e);u(r,-t[0],-t[1],-e[2]);break}case"relative":{const t=j(e),i=C(e),a=s.anchorPosition,o=a?g(a.x,a.y,a.z):_;m(r,i,o),p(r,r,t),h(r,r);break}default:null!=t?h(r,t):d(r,_)}return r}_applyAnchor(e,t,s){if(this._fastUpdates?.requiresShaderTransformation)return;const r=this._computeAnchor(e.resourceBoundingBox,e.pivotOffset,t);r&&o(s,s,r)}_hasPerInstanceColor(){return this._drivenProperties.color||this._drivenProperties.opacity}_fastVisualVariableConvertOptions(e,t,s,r){const i=null!=e?y(C(e)):f,a=null!=e?this._computeAnchor(e,r,this.symbolLayer):_,o=this._context.renderCoordsHelper.unitInMeters,n=z(null!=t?t:void 0,t,s,o),l=g(this.symbolLayer.tilt||0,this.symbolLayer.roll||0,this.symbolLayer.heading||0);return new X({size:!0,color:!0,rotation:!0,opacity:!1},i,t??f,o,a,n,l)}}const pe=b(),ue=l(),ye=l(),fe=R(),_e=new I;export{me as Graphics3DObjectSymbolLayer};
@@ -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/Error.js";import{isPromiseLike as t}from"../../../../core/promiseUtils.js";import{pt2px as n}from"../../../../core/screenUtils.js";import{f as r,Z as s,a as i}from"../../../../chunks/vec2f64.js";import{hasCalloutSupport as l,textSymbolLayerSupportsVerticalOffset as o}from"../../../../symbols/callouts/calloutUtils.js";import{perObjectElevationAligner as a}from"./ElevationAligners.js";import{SymbolUpdateType as c,needsElevationUpdates2D as m}from"./elevationAlignmentUtils.js";import{ElevationContext as h}from"./ElevationContext.js";import{Graphics3DObject3DGraphicLayer as p}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DObjectMetadata as u}from"./Graphics3DObjectMetadata.js";import{Graphics3DSymbolLayer as f}from"./Graphics3DSymbolLayer.js";import{validateSymbolLayerSize as d}from"./graphicUtils.js";import{LabelPlacement as g,LabelParameters as y}from"./LabelParameters.js";import{verticalScreenOffsetFromAlignment as x,verticalPlacementFromAlignment as v,textRenderAlignmentFromHorizontalPlacement as b,horizontalPlacementToAnchorX as P,anchorFromPlacements as O,namedAnchorToHUDMaterialAnchorPos as w}from"./placementUtils.js";import{placePointOnGeometry as j,createStageObject as S,extendPointGraphicElevationContext as E}from"./pointUtils.js";import{getFontMetrics as _}from"../../webgl-engine/lib/FontMetrics.js";import{createPointGeometry as L}from"../../webgl-engine/lib/GeometryUtil.js";import{TextRenderParameters as z}from"../../webgl-engine/lib/TextRenderParameters.js";import C from"../../webgl-engine/lib/TextTextureFactory.js";import{HUDMaterial as G}from"../../webgl-engine/materials/HUDMaterial.js";const U=[0,0,1];class R extends f{constructor(e,t,n,r){super(e,t,n,r),this._elevationOptions={supportsOffsetAdjustment:!0,supportsOnTheGround:!1},this.ensureDrapedStatus(!1)}async doLoad(){if(!this._drivenProperties.size){const t=d(this.symbolLayer.size);if(t)throw new e("graphics3dtextsymbollayer:invalid-size",t)}await this._createTextRenderParameters()}async _createTextRenderParameters(){const e=this._context.graphicsCoreOwner.view.state.rasterPixelRatio;this._textRenderParameters=await z.fromSymbol(this.symbolLayer,e)}destroy(){super.destroy()}createGraphics3DGraphic(e){const t=e.graphic,n=j(t.geometry);if(null==n)return this.logger.warn(`unsupported geometry type for text symbol: ${t.geometry.type}`),null;const r=this.symbolLayer.text;if(null==r||""===r)return null;const s=l(this.symbol)&&this.symbol.hasVisibleVerticalOffset()?this.symbol.verticalOffset:null;if(null!=s&&!o(this.symbolLayer))return this.logger.errorOncePerTick(`Callouts and vertical offset on text symbols are currently only supported with 'center' horizontal alignment (not with '${this.symbolLayer.horizontalAlignment}' alignment)`),null;const{verticalAlignment:i}=this.symbolLayer,a=new g(s);x(i,a.screenOffset);const c=new y(a,this.symbolLayer.horizontalAlignment,v(i));return this._createAs3DShape(t,n,r,c)}createLabel(e,t,n,r,s){const i=e.graphic,l=j(i.geometry);if(null==l)return this.logger.warn(`unsupported geometry type for label: ${i.geometry.type}`),null;const o=t.text;return!o||/^\s+$/.test(o)?null:this._createAs3DShape(i,l,o,t,n,r,s)}setGraphicElevationContext(e,t,n=0){return super.setGraphicElevationContext(e,t),t.addOffsetRenderUnits(n),t}layerOpacityChanged(){return this.logger.warn("layer opacity change not yet implemented in Graphics3DTextSymbolLayer"),!1}layerElevationInfoChanged(e,t){return D(e,t,((e,t)=>{this.updateGraphicElevationContext(t,e)})),c.UPDATE}slicePlaneEnabledChanged(e,t){return D(e,t,(e=>{for(const t of e.stageObject.geometries)t.material.setParameters({hasSlicePlane:this._context.slicePlaneEnabled})})),!0}physicalBasedRenderingChanged(){return!0}get pixelRatioChanged(){return!1}updateGraphicElevationContext(e,t){const n=t.elevationContext;this.setGraphicElevationContext(e,n,null!=t.metadata?t.metadata.elevationOffset:0),t.needsElevationUpdates=m(n.mode)||"absolute-height"===n.mode}_defaultElevationInfoNoZ(){return T}_createAs3DShape(e,l,o,c,f=null,d=null,g=(()=>c.placement.elevationOffset)){const y=this.setGraphicElevationContext(e,new h,c.placement.elevationOffset),x="polyline"===e.geometry?.type,v=e.uid;let P=null,O=null;if(null==d){const e=b(c.horizontalPlacement);P=new C(o,e,this._textRenderParameters);let n=null;if(null!=this._context.sharedResources.textures){O=this._context.sharedResources.textures.fromData(P.key,(()=>P.create()),(()=>{null!=n&&n.release()}));const e=this._context.stage.renderView.textureRepository.acquire(O.texture.id);if(null==e||t(e))return O.release(),null;n=e}}const w=A(P,c),j={occlusionTest:!0,screenOffset:c.placement.screenOffset,anchorPosition:w,polygonOffset:!0,color:[1,1,1,1],centerOffsetUnits:c.placement.centerOffsetUnits,drawInSecondSlot:!0};if(null!=d?j.textureId=d.id:null!=O&&(j.textureId=O.texture.id),null!=c.placement.verticalOffset){const{screenLength:e,minWorldLength:t,maxWorldLength:r}=c.placement.verticalOffset;j.verticalOffset={screenLength:n(e),minWorldLength:t||0,maxWorldLength:null!=r?r:1/0}}if(this._context.screenSizePerspectiveEnabled){const{screenSizePerspectiveSettings:e,screenSizePerspectiveSettingsLabels:t}=this._context.sharedResources,n=_(this._textRenderParameters);j.screenSizePerspective=t.overrideFontHeight(n.maxHeight),j.screenSizePerspectiveAlignment=e}x&&(j.shaderPolygonOffset=1e-4),j.hasSlicePlane=this._context.slicePlaneEnabled;const z=(e,t)=>{const n=JSON.stringify(t);let r=e.get(n);return null==r&&(r=new G(t),e.add(n,r)),r},R=f?z(f,j):new G(j),D=c.placement.translation,T=P?r(P.displayWidth,P.displayHeight):s,W=c.placement.centerOffset,H=L(R,U,D,null,T,W,[0,0],null),I=S(this._context,l,H,y,v);if(null==I)return null;const $=(t,n,r,s,i,l)=>{const o=g()||c.placement.elevationOffset,m=this.setGraphicElevationContext(e,n,o);return a(t,m,r,s,i,l)},k=new p(this,I.object,[H],null==f?[R]:null,O,$,y);k.alignedSampledElevation=I.sampledElevation,k.needsElevationUpdates=m(y.mode)||"absolute-height"===y.mode,k.getScreenSize=(e=i())=>(e[0]=P?P.displayWidth:c.displaySize[0],e[1]=P?P.displayHeight:c.displaySize[1],e);const F=new u(c.placement.elevationOffset,o);return k.metadata=F,E(k,l,this._context.elevationProvider),k}}function D(e,t,n){e&&e.forEach((e=>{const r=t(e);null!=r&&n(r,e.graphic)}))}function A(e,t){if("baseline"===t.verticalPlacement){const n=P[t.horizontalPlacement],s=null!=e?e.baselineAnchorY:0;return r(n,s)}const n=O(t.horizontalPlacement,t.verticalPlacement);return w[n]}const T={mode:"relative-to-ground",offset:0};export{R as Graphics3DTextSymbolLayer};
5
+ import e from"../../../../core/Error.js";import{isPromiseLike as t}from"../../../../core/promiseUtils.js";import{pt2px as n}from"../../../../core/screenUtils.js";import{f as r,Z as s,a as i}from"../../../../chunks/vec2f64.js";import{hasCalloutSupport as o,textSymbolLayerSupportsVerticalOffset as l}from"../../../../symbols/callouts/calloutUtils.js";import{perObjectElevationAligner as a}from"./ElevationAligners.js";import{SymbolUpdateType as c,needsElevationUpdates2D as m}from"./elevationAlignmentUtils.js";import{ElevationContext as h}from"./ElevationContext.js";import{Graphics3DObject3DGraphicLayer as p}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DObjectMetadata as u}from"./Graphics3DObjectMetadata.js";import{Graphics3DSymbolLayer as f}from"./Graphics3DSymbolLayer.js";import{validateSymbolLayerSize as d}from"./graphicUtils.js";import{LabelPlacement as g,LabelParameters as y}from"./LabelParameters.js";import{verticalScreenOffsetFromAlignment as x,verticalPlacementFromAlignment as v,textRenderAlignmentFromHorizontalPlacement as b,horizontalPlacementToAnchorX as P,anchorFromPlacements as O,namedAnchorToHUDMaterialAnchorPos as w}from"./placementUtils.js";import{placePointOnGeometry as j,createStageObject as S,extendPointGraphicElevationContext as E}from"./pointUtils.js";import{getFontMetrics as _}from"../../webgl-engine/lib/FontMetrics.js";import{createPointGeometry as L}from"../../webgl-engine/lib/GeometryUtil.js";import{TextRenderParameters as z}from"../../webgl-engine/lib/TextRenderParameters.js";import C from"../../webgl-engine/lib/TextTextureFactory.js";import{HUDMaterial as G}from"../../webgl-engine/materials/HUDMaterial.js";const U=[0,0,1];class R extends f{constructor(e,t,n,r){super(e,t,n,r),this._elevationOptions={supportsOffsetAdjustment:!0,supportsOnTheGround:!1},this.ensureDrapedStatus(!1)}async doLoad(){if(!this._drivenProperties.size){const t=d(this.symbolLayer.size);if(t)throw new e("graphics3dtextsymbollayer:invalid-size",t)}await this._createTextRenderParameters()}async _createTextRenderParameters(){const e=this._context.graphicsCoreOwner.view.state.rasterPixelRatio;this._textRenderParameters=await z.fromSymbol(this.symbolLayer,e)}destroy(){super.destroy()}createGraphics3DGraphic(e){const t=e.graphic,n=j(t.geometry);if(null==n)return this.logger.warn(`unsupported geometry type for text symbol: ${t.geometry.type}`),null;const r=this.symbolLayer.text;if(null==r||""===r)return null;const s=o(this.symbol)&&this.symbol.hasVisibleVerticalOffset()?this.symbol.verticalOffset:null;if(null!=s&&!l(this.symbolLayer))return this.logger.errorOncePerTick(`Callouts and vertical offset on text symbols are currently only supported with 'center' horizontal alignment (not with '${this.symbolLayer.horizontalAlignment}' alignment)`),null;const{verticalAlignment:i}=this.symbolLayer,a=new g(s);x(i,a.screenOffset);const c=new y(a,this.symbolLayer.horizontalAlignment,v(i));return this._createAs3DShape(t,n,r,c)}createLabel(e,t,n,r,s){const i=e.graphic,o=j(i.geometry);if(null==o)return this.logger.warn(`unsupported geometry type for label: ${i.geometry.type}`),null;const l=t.text;return!l||/^\s+$/.test(l)?null:this._createAs3DShape(i,o,l,t,n,r,s)}setGraphicElevationContext(e,t,n=0){return super.setGraphicElevationContext(e,t),t.addOffsetRenderUnits(n),t}layerOpacityChanged(){return this.logger.warn("layer opacity change not yet implemented in Graphics3DTextSymbolLayer"),!1}layerElevationInfoChanged(e,t){return D(e,t,((e,t)=>{this.updateGraphicElevationContext(t,e)})),c.UPDATE}slicePlaneEnabledChanged(e,t){return D(e,t,(e=>{for(const t of e.stageObject.geometries)t.material.setParameters({hasSlicePlane:this._context.slicePlaneEnabled})})),!0}physicalBasedRenderingChanged(){return!0}get pixelRatioChanged(){return!1}updateGraphicElevationContext(e,t){const n=t.elevationContext;this.setGraphicElevationContext(e,n,null!=t.metadata?t.metadata.elevationOffset:0),t.needsElevationUpdates=m(n.mode)||"absolute-height"===n.mode}_defaultElevationInfoNoZ(){return T}_createAs3DShape(e,o,l,c,f=null,d=null,g=(()=>c.placement.elevationOffset)){const y=this.setGraphicElevationContext(e,new h,c.placement.elevationOffset),x="polyline"===e.geometry?.type,v=e.uid;let P=null,O=null;if(null==d){const e=b(c.horizontalPlacement);P=new C(l,e,this._textRenderParameters);let n=null;if(null!=this._context.sharedResources.textures){O=this._context.sharedResources.textures.fromData(P.key,(()=>P.create())),O.texture.events.on("unloaded",(()=>n?.release()));const e=this._context.stage.renderView.textureRepository.acquire(O.texture.id);if(null==e||t(e))return O.release(),null;n=e}}const w=A(P,c),j={occlusionTest:!0,screenOffset:c.placement.screenOffset,anchorPosition:w,polygonOffset:!0,color:[1,1,1,1],centerOffsetUnits:c.placement.centerOffsetUnits,drawInSecondSlot:!0};if(d?j.textureId=d.id:O&&(j.textureId=O.texture.id),null!=c.placement.verticalOffset){const{screenLength:e,minWorldLength:t,maxWorldLength:r}=c.placement.verticalOffset;j.verticalOffset={screenLength:n(e),minWorldLength:t||0,maxWorldLength:null!=r?r:1/0}}if(this._context.screenSizePerspectiveEnabled){const{screenSizePerspectiveSettings:e,screenSizePerspectiveSettingsLabels:t}=this._context.sharedResources,n=_(this._textRenderParameters);j.screenSizePerspective=t.overrideFontHeight(n.maxHeight),j.screenSizePerspectiveAlignment=e}x&&(j.shaderPolygonOffset=1e-4),j.hasSlicePlane=this._context.slicePlaneEnabled;const z=(e,t)=>{const n=JSON.stringify(t);let r=e.get(n);return null==r&&(r=new G(t),e.add(n,r)),r},R=f?z(f,j):new G(j),D=c.placement.translation,T=P?r(P.displayWidth,P.displayHeight):s,W=c.placement.centerOffset,H=L(R,U,D,null,T,W,[0,0],null),I=S(this._context,o,H,y,v);if(null==I)return null;const $=(t,n,r,s,i,o)=>{const l=g()||c.placement.elevationOffset,m=this.setGraphicElevationContext(e,n,l);return a(t,m,r,s,i,o)},k=new p(this,I.object,[H],null==f?[R]:null,O,$,y);k.alignedSampledElevation=I.sampledElevation,k.needsElevationUpdates=m(y.mode)||"absolute-height"===y.mode,k.getScreenSize=(e=i())=>(e[0]=P?P.displayWidth:c.displaySize[0],e[1]=P?P.displayHeight:c.displaySize[1],e);const F=new u(c.placement.elevationOffset,l);return k.metadata=F,E(k,o,this._context.elevationProvider),k}}function D(e,t,n){e&&e.forEach((e=>{const r=t(e);null!=r&&n(r,e.graphic)}))}function A(e,t){if("baseline"===t.verticalPlacement){const n=P[t.horizontalPlacement],s=null!=e?e.baselineAnchorY:0;return r(n,s)}const n=O(t.horizontalPlacement,t.verticalPlacement);return w[n]}const T={mode:"relative-to-ground",offset:0};export{R as Graphics3DTextSymbolLayer};
@@ -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{throwIfAborted as t,whenOrAbort as e}from"../../../core/promiseUtils.js";import{isSVG as r}from"../../../core/urlUtils.js";import{TextureCollection as s,TextureRequest as i}from"./TextureCollection.js";import{Texture as l}from"../webgl-engine/lib/Texture.js";import{TextureWrapMode as o}from"../../webgl/enums.js";class n extends s{constructor(t,e,r){super(e,r),this._streamDataRequester=t}async fromUrl(r,s,l){t(l);const o=null!=l?l.signal:null,n=this.makeUid(r,s);let h=this._textureRequests.get(n);if(!h){const t=new AbortController,e=this._streamDataRequester.request(r,"image",{uid:n,signal:t.signal});h=new i,h.abortController=t;const l=h;this._textureRequests.set(n,h),h.textureAsync=e.then((async t=>{const e=this._createTexture(r,t,s);return l.texture=e,l.abortController=null,this._stage.add(e),await this._stage.load(e),{uid:n,texture:e,release:()=>this._release(n)}}),(t=>{throw l.abortController=null,t}))}h.referenceCount++;try{return await e(h.textureAsync,o)}catch(a){throw this._release(n),a}}_createTexture(t,e,s){const i={width:e.width,height:e.height,wrap:{s:o.CLAMP_TO_EDGE,t:o.CLAMP_TO_EDGE},preMultiplyAlpha:!0};if(r(t)){if(s||0===e.width&&0===e.height){const t=e.width?e.height/e.width:1;s=s||64,t>1?(e.width=Math.round(s/t),e.height=s):(e.width=s,e.height=Math.round(s*t))}this._stage.renderView?.renderingContext.driverTest.svgPremultipliesAlpha.result&&(i.preMultiplyAlpha=!1)}return new l(e,i)}}export{n as StreamTextureCollection};
5
+ import{throwIfAborted as e,whenOrAbort as t}from"../../../core/promiseUtils.js";import{isSVG as r}from"../../../core/urlUtils.js";import{TextureCollection as s,TextureRequest as i}from"./TextureCollection.js";import{Texture as l}from"../webgl-engine/lib/Texture.js";import{TextureWrapMode as n}from"../../webgl/enums.js";class o extends s{constructor(e,t,r){super(t,r),this._streamDataRequester=e}async fromUrl(r,s,l){e(l);const n=null!=l?l.signal:null,o=this.makeUid(r,s);let a=this._textureRequests.get(o);if(!a){const e=new AbortController,t=this._streamDataRequester.request(r,"image",{uid:o,signal:e.signal});a=new i,a.abortController=e;const l=a;this._textureRequests.set(o,a),a.textureAsync=t.then((async e=>{const t=this._createTexture(r,e,s);return l.texture=t,l.abortController=null,await t.load(this._stage.renderView.renderingContext),this._stage.add(t),{uid:o,texture:t,release:()=>this._release(o)}}),(e=>{throw l.abortController=null,e}))}a.referenceCount++;try{return await t(a.textureAsync,n)}catch(h){throw this._release(o),h}}_createTexture(e,t,s){const i={width:t.width,height:t.height,wrap:{s:n.CLAMP_TO_EDGE,t:n.CLAMP_TO_EDGE},preMultiplyAlpha:!0,reloadable:!0};if(r(e)){if(s||0===t.width&&0===t.height){const e=t.width?t.height/t.width:1;s=s||64,e>1?(t.width=Math.round(s/e),t.height=s):(t.width=s,t.height=Math.round(s*e))}this._stage.renderView?.renderingContext.driverTest.svgPremultipliesAlpha.result&&(i.preMultiplyAlpha=!1)}return new l(t,i)}}export{o as StreamTextureCollection};
@@ -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{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 s}from"../../../core/accessorSupport/decorators/subclass.js";import{TaskPriority as o,ImmediateTask as u}from"../../support/Scheduler.js";let a=class extends t{constructor(e,t){super({}),this._stage=e,this._textureRequests=new Map,this._frameTask=t?.registerTask(o.TEXTURE_UNLOAD)??u}normalizeCtorArgs(){return{}}destroy(){super.destroy(),this._frameTask?.remove(),this._textureRequests?.forEach((e=>this._releaseTextureRequest(e))),this._textureRequests?.clear()}get updating(){return this._frameTask.updating}fromData(e,t,r){const s=this.makeUid(e);let o=this._textureRequests.get(s);if(!o){const e=new i(r);e.texture=t(),this._stage?.add(e.texture),this._stage?.loadImmediate(e.texture),this._textureRequests.set(s,e),o=e}return o.referenceCount++,{uid:s,texture:o.texture,release:()=>this._release(s)}}_release(e){const t=this._textureRequests.get(e);t?(t.referenceCount<1&&console.warn("TextureCollection: reference count is < 1 for "+e),t.referenceCount--,t.referenceCount<1&&this._frameTask.schedule((()=>this._releaseNow(e)))):console.warn(`TextureCollection: texture doesn't exist: '${e}'`)}get test(){return{textureRequests:this._textureRequests}}_releaseNow(e){if(!this._textureRequests)return;const t=this._textureRequests.get(e);!t||t.referenceCount>0||(this._releaseTextureRequest(t),this._textureRequests.delete(e))}_releaseTextureRequest(e){e.onRemove&&e.onRemove(),e.texture?this._stage?.remove(e.texture):e.abortController&&(e.abortController.abort(),e.abortController=null)}makeUid(e,t=null){return null!=t?`${e}.${t}px`:e}};e([r()],a.prototype,"_frameTask",void 0),e([r()],a.prototype,"updating",null),a=e([s("esri.views.3d.support.TextureCollection")],a);class i{constructor(e){this.onRemove=e,this.referenceCount=0}}export{a as TextureCollection,i as TextureRequest};
5
+ import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../core/Accessor.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 s}from"../../../core/accessorSupport/decorators/subclass.js";import{TaskPriority as o,ImmediateTask as u}from"../../support/Scheduler.js";let a=class extends t{constructor(e,t){super({}),this._stage=e,this._textureRequests=new Map,this._frameTask=t?.registerTask(o.TEXTURE_UNLOAD)??u}normalizeCtorArgs(){return{}}destroy(){super.destroy(),this._frameTask?.remove(),this._textureRequests?.forEach((e=>this._releaseTextureRequest(e))),this._textureRequests?.clear()}get updating(){return this._frameTask.updating}fromData(e,t){const r=this.makeUid(e);let s=this._textureRequests.get(r);if(!s){const e=new i;e.texture=t(),this._stage&&(e.texture.load(this._stage.renderView.renderingContext),this._stage.add(e.texture)),this._textureRequests.set(r,e),s=e}return s.referenceCount++,{uid:r,texture:s.texture,release:()=>this._release(r)}}_release(e){const t=this._textureRequests.get(e);t?(t.referenceCount<1&&console.warn("TextureCollection: reference count is < 1 for "+e),t.referenceCount--,t.referenceCount<1&&this._frameTask.schedule((()=>this._releaseNow(e)))):console.warn(`TextureCollection: texture doesn't exist: '${e}'`)}get test(){return{textureRequests:this._textureRequests}}_releaseNow(e){if(!this._textureRequests)return;const t=this._textureRequests.get(e);!t||t.referenceCount>0||(t.texture?.unload(),this._releaseTextureRequest(t),this._textureRequests.delete(e))}_releaseTextureRequest(e){e.texture?this._stage?.remove(e.texture):e.abortController&&(e.abortController.abort(),e.abortController=null)}makeUid(e,t=null){return null!=t?`${e}.${t}px`:e}};e([r()],a.prototype,"_frameTask",void 0),e([r()],a.prototype,"updating",null),a=e([s("esri.views.3d.support.TextureCollection")],a);class i{constructor(){this.referenceCount=0}}export{a as TextureCollection,i as TextureRequest};
@@ -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{packFloatRGBA as t}from"../../../../core/floatRGBA.js";import{Texture as n}from"../../webgl-engine/lib/Texture.js";import{TextureWrapMode as r}from"../../../webgl/enums.js";const e=128,o=.5;function a(t){return"cross"===t||"x"===t}function u(t,a=e,u=a*o,s=0){const i=c(t,a,u,s);return new n(i,{mipmap:!1,wrap:{s:r.CLAMP_TO_EDGE,t:r.CLAMP_TO_EDGE},width:a,height:a,components:4,noUnpackFlip:!0})}function c(t,n=e,r=n*o,a=0){switch(t){case"circle":default:return s(n,r);case"square":return i(n,r);case"cross":return h(n,r,a);case"x":return M(n,r,a);case"kite":return f(n,r);case"triangle":return m(n,r);case"arrow":return l(n,r)}}function s(t,n){const r=t/2-.5;return x(t,b(r,r,n/2))}function i(t,n){return p(t,n,!1)}function f(t,n){return p(t,n,!0)}function h(t,n,r=0){return T(t,n,!1,r)}function M(t,n,r=0){return T(t,n,!0,r)}function m(t,n){return x(t,w(t/2,n,n/2))}function l(t,n){const r=n,e=n/2,o=t/2,a=.8*r,u=b(o,(t-n)/2-a,Math.sqrt(a*a+e*e)),c=w(o,r,e);return x(t,((t,n)=>Math.max(c(t,n),-u(t,n))))}function p(t,n,r){return r&&(n/=Math.SQRT2),x(t,((e,o)=>{let a=e-.5*t+.25,u=.5*t-o-.75;if(r){const t=(a+u)/Math.SQRT2;u=(u-a)/Math.SQRT2,a=t}return Math.max(Math.abs(a),Math.abs(u))-.5*n}))}function T(t,n,r,e=0){n-=e,r&&(n*=Math.SQRT2);const o=.5*n;return x(t,((n,a)=>{let u,c=n-.5*t,s=.5*t-a-1;if(r){const t=(c+s)/Math.SQRT2;s=(s-c)/Math.SQRT2,c=t}return c=Math.abs(c),s=Math.abs(s),u=c>s?c>o?Math.sqrt((c-o)*(c-o)+s*s):s:s>o?Math.sqrt(c*c+(s-o)*(s-o)):c,u-=e/2,u}))}function b(t,n,r){return(e,o)=>{const a=e-t,u=o-n;return Math.sqrt(a*a+u*u)-r}}function w(t,n,r){const e=Math.sqrt(n*n+r*r);return(o,a)=>{const u=Math.abs(o-t)-r,c=a-t+n/2+.75,s=(n*u+r*c)/e,i=-c;return Math.max(s,i)}}function x(n,r){const e=new Uint8Array(4*n*n);for(let o=0;o<n;o++)for(let a=0;a<n;a++){const u=a+n*o;let c=r(a,o);c=c/n+.5,t(c,e,4*u)}return e}export{o as DEFAULT_SYMBOL_SIZE_RATIO,e as DEFAULT_TEX_SIZE,l as createArrow,s as createCircle,h as createCross,f as createKite,c as createPrimitive,i as createSquare,u as createTexture,m as createTriangle,M as createX,a as requiresHalfTexelOffset};
5
+ import"../../../../core/has.js";import{packFloatRGBA as t}from"../../../../core/floatRGBA.js";import{Texture as r}from"../../webgl-engine/lib/Texture.js";import{TextureWrapMode as n}from"../../../webgl/enums.js";const e=128,o=.5;function a(t){return"cross"===t||"x"===t}function u(t,a=e,u=a*o,s=0){const i=c(t,a,u,s);return new r(i,{mipmap:!1,wrap:{s:n.CLAMP_TO_EDGE,t:n.CLAMP_TO_EDGE},width:a,height:a,components:4,noUnpackFlip:!0,reloadable:!0})}function c(t,r=e,n=r*o,a=0){switch(t){case"circle":default:return s(r,n);case"square":return i(r,n);case"cross":return h(r,n,a);case"x":return M(r,n,a);case"kite":return f(r,n);case"triangle":return l(r,n);case"arrow":return m(r,n)}}function s(t,r){const n=t/2-.5;return x(t,T(n,n,r/2))}function i(t,r){return p(t,r,!1)}function f(t,r){return p(t,r,!0)}function h(t,r,n=0){return b(t,r,!1,n)}function M(t,r,n=0){return b(t,r,!0,n)}function l(t,r){return x(t,w(t/2,r,r/2))}function m(t,r){const n=r,e=r/2,o=t/2,a=.8*n,u=T(o,(t-r)/2-a,Math.sqrt(a*a+e*e)),c=w(o,n,e);return x(t,((t,r)=>Math.max(c(t,r),-u(t,r))))}function p(t,r,n){return n&&(r/=Math.SQRT2),x(t,((e,o)=>{let a=e-.5*t+.25,u=.5*t-o-.75;if(n){const t=(a+u)/Math.SQRT2;u=(u-a)/Math.SQRT2,a=t}return Math.max(Math.abs(a),Math.abs(u))-.5*r}))}function b(t,r,n,e=0){r-=e,n&&(r*=Math.SQRT2);const o=.5*r;return x(t,((r,a)=>{let u,c=r-.5*t,s=.5*t-a-1;if(n){const t=(c+s)/Math.SQRT2;s=(s-c)/Math.SQRT2,c=t}return c=Math.abs(c),s=Math.abs(s),u=c>s?c>o?Math.sqrt((c-o)*(c-o)+s*s):s:s>o?Math.sqrt(c*c+(s-o)*(s-o)):c,u-=e/2,u}))}function T(t,r,n){return(e,o)=>{const a=e-t,u=o-r;return Math.sqrt(a*a+u*u)-n}}function w(t,r,n){const e=Math.sqrt(r*r+n*n);return(o,a)=>{const u=Math.abs(o-t)-n,c=a-t+r/2+.75,s=(r*u+n*c)/e,i=-c;return Math.max(s,i)}}function x(r,n){const e=new Uint8Array(4*r*r);for(let o=0;o<r;o++)for(let a=0;a<r;a++){const u=a+r*o;let c=n(a,o);c=c/r+.5,t(c,e,4*u)}return e}export{o as DEFAULT_SYMBOL_SIZE_RATIO,e as DEFAULT_TEX_SIZE,m as createArrow,s as createCircle,h as createCross,f as createKite,c as createPrimitive,i as createSquare,u as createTexture,l as createTriangle,M as createX,a as requiresHalfTexelOffset};
@@ -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 r from"../../../core/PooledArray.js";import{isPromiseLike as s}from"../../../core/promiseUtils.js";import{property as i}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import"../../../core/arrayUtils.js";import"../../../core/has.js";import{subclass as n}from"../../../core/accessorSupport/decorators/subclass.js";import{isIntersectionHandler as o}from"../state/helpers/SceneIntersectionHelper.js";import{ChangeSet as d}from"./lib/ChangeSet.js";import{UpdatePolicy as a}from"./lib/UpdatePolicy.js";import{isWebGLLayer as h}from"./lib/WebGLLayer.js";import{Model as l}from"./parts/Model.js";import{RenderView as y}from"./parts/RenderView.js";import{TaskPriority as c,noBudget as m}from"../../support/Scheduler.js";let u=class extends t{constructor(e){super(e),this._model=new l,this._layers=new r,this._asyncChangeSet=new d,this._syncChangeSet=new d,this._layerSyncSet=new Set}initialize(){this._set("renderView",new y(this)),this._frameTask=this.view.resourceController.scheduler.registerTask(c.STAGE,this),this.addHandles(this._frameTask)}get viewingMode(){return this.view.state.viewingMode}get updating(){return this.running||this.renderView.updating||this._frameTask.updating}get renderer(){return this.renderView?.renderer}add(e){this._model.add(e),h(e)&&this._addLayer(e),this.renderView.requestRender()}remove(e){null==e||this.destroyed||(this._model.remove(e),h(e)&&this._removeLayer(e),this.renderView.requestRender())}addMany(e){null!=e&&(this._model.addMany(e),this.renderView.requestRender())}removeMany(e){null!=e&&(this._model?.removeMany(e),this.renderView?.requestRender())}async load(e,t){null!=e&&(Array.isArray(e)||(e=[e]),await Promise.all(e.filter((e=>null==e.glTexture)).map((e=>this.schedule((()=>this._model.has(e)?e.load(this.renderView.renderingContext):null))),t)))}loadImmediate(e){return e.load(this.renderView.renderingContext)}forEachOfType(e,t){this._model.forEachOfType(e,t)}handleEvent(e,t){this.destroyed||(this._model.dirtySet[e](t),this.renderView.requestRender())}get running(){return this._model.dirtySet.dirty||!this._asyncChangeSet.empty}runTask(e){this._frameTask.processQueue(e),this._commit(e)}_commit(e){const t=this._model.dirtySet;this._asyncChangeSet.empty||e.done||(this.renderer.modify(this._asyncChangeSet,e),this.renderView.requestRender(),e.madeProgress()),this._layers.forAll((r=>{if(e.done)return;const s=this._layerSyncSet.has(r.id)||r.updatePolicy===a.SYNC,i=s?this._syncChangeSet:this._asyncChangeSet;t.commitLayer(r.id,i),this._layerSyncSet.delete(r.id),i.empty||(this.renderer.modify(i,s?m:e),this.renderView.requestRender(),e.madeProgress())})),this._syncChangeSet.empty||(this.renderer.modify(this._syncChangeSet,m),this.renderView.requestRender(),e.madeProgress()),this._layers.forAll((r=>{e.done||this._layerSyncSet.has(r.id)||r.updatePolicy!==a.ASYNC||(t.commitLayer(r.id,this._asyncChangeSet),this._asyncChangeSet.empty||(this.renderer.modify(this._asyncChangeSet,e),this.renderView.requestRender(),e.madeProgress()))})),this._layerSyncSet.clear(),this.notifyChange("running")}commitSyncLayers(){const e=this._model.dirtySet;this._layers.forAll((t=>{(this._layerSyncSet.has(t.id)||t.updatePolicy===a.SYNC)&&(e.commitLayer(t.id,this._syncChangeSet),this._layerSyncSet.delete(t.id))}));for(const t of this._layerSyncSet)e.commitLayer(t,this._syncChangeSet);this._layerSyncSet.clear(),this._syncChangeSet.empty||(this.renderer.modify(this._syncChangeSet,m),this.renderView.requestRender())}_commitLayer(e){this._model.dirtySet.commitLayer(e.id,this._syncChangeSet),this._layerSyncSet.delete(e.id),this._syncChangeSet.empty||(this.renderer.modify(this._syncChangeSet,m),this.renderView.requestRender())}schedule(e,t){return this._frameTask.schedule(e,t)}reschedule(e,t){return this._frameTask.reschedule(e,t)}syncLayer(e){this._layerSyncSet.add(e),this.renderView.requestRender()}getObject(e){return this._model.getObject(e)}get layers(){return this._layers}_addLayer(e){this._layers.includes(e)||this._layers.push(e)}_removeLayer(e){this._commitLayer(e),null!=this._layers.removeUnordered(e)&&(this._model.dirtySet.getResidentRenderGeometries(e.id,this._syncChangeSet.removes),this.renderer.modify(this._syncChangeSet,m))}addRenderPlugin(e,t){const r=this.renderer.renderPlugins.add(e,t),i=()=>{o(e)&&this.view.sceneIntersectionHelper.addIntersectionHandler(e)};if(s(r))return r.then(i);i()}removeRenderPlugin(e){this.destroyed||(o(e)&&this.view.sceneIntersectionHelper.removeIntersectionHandler(e),this.renderer.renderPlugins.remove(e))}get performanceInfo(){return this._model.getStats()}get test(){const e=this;return{getCount:t=>e._model.test.content.filter((e=>e.type===t)).length,model:e._model}}};u.DebugSettings={endFrameContentValidation:!1},e([i({constructOnly:!0})],u.prototype,"view",void 0),e([i({constructOnly:!0})],u.prototype,"options",void 0),e([i({readOnly:!0})],u.prototype,"viewingMode",null),e([i({constructOnly:!0})],u.prototype,"container",void 0),e([i({readOnly:!0})],u.prototype,"updating",null),e([i({constructOnly:!0})],u.prototype,"_model",void 0),e([i({autoDestroy:!0})],u.prototype,"renderView",void 0),e([i({readOnly:!0})],u.prototype,"renderer",null),e([i({readOnly:!0})],u.prototype,"running",null),u=e([n("esri.views.3d.webgl-engine.Stage")],u);export{u as Stage};
5
+ import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../core/Accessor.js";import r from"../../../core/PooledArray.js";import{isPromiseLike as s}from"../../../core/promiseUtils.js";import{property as i}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import"../../../core/arrayUtils.js";import"../../../core/has.js";import{subclass as n}from"../../../core/accessorSupport/decorators/subclass.js";import{isIntersectionHandler as o}from"../state/helpers/SceneIntersectionHelper.js";import{ChangeSet as d}from"./lib/ChangeSet.js";import{UpdatePolicy as a}from"./lib/UpdatePolicy.js";import{isWebGLLayer as h}from"./lib/WebGLLayer.js";import{Model as y}from"./parts/Model.js";import{RenderView as l}from"./parts/RenderView.js";import{TaskPriority as c,noBudget as m}from"../../support/Scheduler.js";let p=class extends t{constructor(e){super(e),this._model=new y,this._layers=new r,this._asyncChangeSet=new d,this._syncChangeSet=new d,this._layerSyncSet=new Set}initialize(){this._set("renderView",new l(this)),this._frameTask=this.view.resourceController.scheduler.registerTask(c.STAGE,this),this.addHandles(this._frameTask)}get viewingMode(){return this.view.state.viewingMode}get updating(){return this.running||this.renderView.updating||this._frameTask.updating}get renderer(){return this.renderView?.renderer}add(e){this._model.add(e),h(e)&&this._addLayer(e),this.renderView.requestRender()}remove(e){null!=e&&!this.destroyed&&this._model.remove(e)&&(h(e)&&this._removeLayer(e),this.renderView.requestRender())}addMany(e){null!=e&&(this._model.addMany(e),this.renderView.requestRender())}removeMany(e){null!=e&&(this._model?.removeMany(e),this.renderView?.requestRender())}forEachOfType(e,t){this._model.forEachOfType(e,t)}handleEvent(e,t){this.destroyed||(this._model.dirtySet[e](t),this.renderView.requestRender())}get running(){return this._model.dirtySet.dirty||!this._asyncChangeSet.empty}runTask(e){this._frameTask.processQueue(e),this._commit(e)}_commit(e){const t=this._model.dirtySet;this._asyncChangeSet.empty||e.done||(this.renderer.modify(this._asyncChangeSet,e),this.renderView.requestRender(),e.madeProgress()),this._layers.forAll((r=>{if(e.done)return;const s=this._layerSyncSet.has(r.id)||r.updatePolicy===a.SYNC,i=s?this._syncChangeSet:this._asyncChangeSet;t.commitLayer(r.id,i),this._layerSyncSet.delete(r.id),i.empty||(this.renderer.modify(i,s?m:e),this.renderView.requestRender(),e.madeProgress())})),this._syncChangeSet.empty||(this.renderer.modify(this._syncChangeSet,m),this.renderView.requestRender(),e.madeProgress()),this._layers.forAll((r=>{e.done||this._layerSyncSet.has(r.id)||r.updatePolicy!==a.ASYNC||(t.commitLayer(r.id,this._asyncChangeSet),this._asyncChangeSet.empty||(this.renderer.modify(this._asyncChangeSet,e),this.renderView.requestRender(),e.madeProgress()))})),this._layerSyncSet.clear(),this.notifyChange("running")}commitSyncLayers(){const e=this._model.dirtySet;this._layers.forAll((t=>{(this._layerSyncSet.has(t.id)||t.updatePolicy===a.SYNC)&&(e.commitLayer(t.id,this._syncChangeSet),this._layerSyncSet.delete(t.id))}));for(const t of this._layerSyncSet)e.commitLayer(t,this._syncChangeSet);this._layerSyncSet.clear(),this._syncChangeSet.empty||(this.renderer.modify(this._syncChangeSet,m),this.renderView.requestRender())}_commitLayer(e){this._model.dirtySet.commitLayer(e.id,this._syncChangeSet),this._layerSyncSet.delete(e.id),this._syncChangeSet.empty||(this.renderer.modify(this._syncChangeSet,m),this.renderView.requestRender())}schedule(e,t){return this._frameTask.schedule(e,t)}reschedule(e,t){return this._frameTask.reschedule(e,t)}syncLayer(e){this._layerSyncSet.add(e),this.renderView.requestRender()}getObject(e){return this._model.getObject(e)}get layers(){return this._layers}_addLayer(e){this._layers.includes(e)||this._layers.push(e)}_removeLayer(e){this._commitLayer(e),null!=this._layers.removeUnordered(e)&&(this._model.dirtySet.getResidentRenderGeometries(e.id,this._syncChangeSet.removes),this.renderer.modify(this._syncChangeSet,m))}addRenderPlugin(e,t){const r=this.renderer.renderPlugins.add(e,t),i=()=>{o(e)&&this.view.sceneIntersectionHelper.addIntersectionHandler(e)};if(s(r))return r.then(i);i()}removeRenderPlugin(e){this.destroyed||(o(e)&&this.view.sceneIntersectionHelper.removeIntersectionHandler(e),this.renderer.renderPlugins.remove(e))}get performanceInfo(){return this._model.getStats()}get test(){const e=this;return{getCount:t=>e._model.test.content.filter((e=>e.type===t)).length,model:e._model}}};p.DebugSettings={endFrameContentValidation:!1},e([i({constructOnly:!0})],p.prototype,"view",void 0),e([i({constructOnly:!0})],p.prototype,"options",void 0),e([i({readOnly:!0})],p.prototype,"viewingMode",null),e([i({constructOnly:!0})],p.prototype,"container",void 0),e([i({readOnly:!0})],p.prototype,"updating",null),e([i({constructOnly:!0})],p.prototype,"_model",void 0),e([i({autoDestroy:!0})],p.prototype,"renderView",void 0),e([i({readOnly:!0})],p.prototype,"renderer",null),e([i({readOnly:!0})],p.prototype,"running",null),p=e([n("esri.views.3d.webgl-engine.Stage")],p);export{p as Stage};
@@ -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{generateUID as o}from"../../../../core/uid.js";class r{constructor(){this.id=o()}unload(){}}export{r as ContentObject};
5
+ import{generateUID as o}from"../../../../core/uid.js";class r{constructor(){this.id=o()}}export{r as ContentObject};
@@ -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/Logger.js";import{disposeMaybe as t}from"../../../../core/maybe.js";import{NestedMap as r}from"../../../../core/NestedMap.js";import{assert as i}from"./Util.js";class s{constructor(e,t,i,s){this._textureRepository=e,this._techniqueRepository=t,this.materialChanged=i,this.requestRender=s,this._id2glMaterialRef=new r}dispose(){this._textureRepository.destroy()}acquire(e,t,r){if(this._ownMaterial(e),!e.produces(t,r))return null;let i=this._id2glMaterialRef.get(r,e.id);if(null==i){const t=e.createGLMaterial({material:e,techniqueRep:this._techniqueRepository,textureRep:this._textureRepository,output:r});i=new o(t),this._id2glMaterialRef.set(r,e.id,i)}return i.ref(),i.glMaterial}release(e,r){const i=this._id2glMaterialRef.get(r,e.id);null!=i&&(i.unref(),i.referenced||(t(i.glMaterial),this._id2glMaterialRef.delete(r,e.id)))}_ownMaterial(t){null!=t.repository&&t.repository!==this&&e.getLogger("esri.views.3d.webgl-engine.lib.GLMaterialRepository").error("Material is already owned by a different material repository"),t.repository=this}}class o{constructor(e){this.glMaterial=e,this._refCnt=0}ref(){++this._refCnt}unref(){--this._refCnt,i(this._refCnt>=0)}get referenced(){return this._refCnt>0}}export{s as GLMaterialRepository};
5
+ import e from"../../../../core/Logger.js";import{disposeMaybe as t}from"../../../../core/maybe.js";import{NestedMap as r}from"../../../../core/NestedMap.js";import{assert as i}from"./Util.js";class s{constructor(e,t,i,s){this._textureRepository=e,this._techniqueRepository=t,this.materialChanged=i,this.requestRender=s,this._id2glMaterialRef=new r}dispose(){this._textureRepository.destroy()}acquire(e,t,r){if(this._ownMaterial(e),!e.produces(t,r))return null;let i=this._id2glMaterialRef.get(r,e.id);if(null==i){const t=e.createGLMaterial({material:e,techniqueRep:this._techniqueRepository,textureRepository:this._textureRepository,output:r});i=new o(t),this._id2glMaterialRef.set(r,e.id,i)}return i.ref(),i.glMaterial}release(e,r){const i=this._id2glMaterialRef.get(r,e.id);null!=i&&(i.unref(),i.referenced||(t(i.glMaterial),this._id2glMaterialRef.delete(r,e.id)))}_ownMaterial(t){null!=t.repository&&t.repository!==this&&e.getLogger("esri.views.3d.webgl-engine.lib.GLMaterialRepository").error("Material is already owned by a different material repository"),t.repository=this}}class o{constructor(e){this.glMaterial=e,this._refCnt=0}ref(){++this._refCnt}unref(){--this._refCnt,i(this._refCnt>=0)}get referenced(){return this._refCnt>0}}export{s as GLMaterialRepository};
@@ -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{releaseMaybe as t}from"../../../../core/maybe.js";import{isPromiseLike as e}from"../../../../core/promiseUtils.js";import{NoParameters as s}from"../core/shaderModules/interfaces.js";import{ResourceState as i}from"./basicInterfaces.js";import u from"./GLMaterial.js";class r extends u{constructor(t){super(t),this._numLoading=0,this._disposed=!1,this._textureRepository=t.textureRep,this._textureId=t.textureId,this._acquire(t.textureId,(t=>this._texture=t)),this._acquire(t.normalTextureId,(t=>this._textureNormal=t)),this._acquire(t.emissiveTextureId,(t=>this._textureEmissive=t)),this._acquire(t.occlusionTextureId,(t=>this._textureOcclusion=t)),this._acquire(t.metallicRoughnessTextureId,(t=>this._textureMetallicRoughness=t))}dispose(){this._texture=t(this._texture),this._textureNormal=t(this._textureNormal),this._textureEmissive=t(this._textureEmissive),this._textureOcclusion=t(this._textureOcclusion),this._textureMetallicRoughness=t(this._textureMetallicRoughness),this._disposed=!0}ensureResources(t){return 0===this._numLoading?i.LOADED:i.LOADING}get textureBindParameters(){return new l(null!=this._texture?this._texture.glTexture:null,null!=this._textureNormal?this._textureNormal.glTexture:null,null!=this._textureEmissive?this._textureEmissive.glTexture:null,null!=this._textureOcclusion?this._textureOcclusion.glTexture:null,null!=this._textureMetallicRoughness?this._textureMetallicRoughness.glTexture:null)}updateTexture(e){null!=this._texture&&e===this._texture.id||(this._texture=t(this._texture),this._textureId=e,this._acquire(this._textureId,(t=>this._texture=t)))}_acquire(s,i){if(null==s)return void i(null);const u=this._textureRepository.acquire(s);if(e(u))return++this._numLoading,void u.then((e=>{if(this._disposed)return t(e),void i(null);i(e)})).finally((()=>--this._numLoading));i(u)}}class l extends s{constructor(t=null,e=null,s=null,i=null,u=null){super(),this.texture=t,this.textureNormal=e,this.textureEmissive=s,this.textureOcclusion=i,this.textureMetallicRoughness=u}}export{r as GLTextureMaterial,l as GLTextureMaterialBindParameters};
5
+ import{releaseMaybe as t}from"../../../../core/maybe.js";import{isPromiseLike as e}from"../../../../core/promiseUtils.js";import{NoParameters as s}from"../core/shaderModules/interfaces.js";import{ResourceState as i}from"./basicInterfaces.js";import u from"./GLMaterial.js";class r extends u{constructor(t){super(t),this._numLoading=0,this._disposed=!1,this._textureRepository=t.textureRepository,this._textureId=t.textureId,this._acquire(t.textureId,(t=>this._texture=t)),this._acquire(t.normalTextureId,(t=>this._textureNormal=t)),this._acquire(t.emissiveTextureId,(t=>this._textureEmissive=t)),this._acquire(t.occlusionTextureId,(t=>this._textureOcclusion=t)),this._acquire(t.metallicRoughnessTextureId,(t=>this._textureMetallicRoughness=t))}dispose(){this._texture=t(this._texture),this._textureNormal=t(this._textureNormal),this._textureEmissive=t(this._textureEmissive),this._textureOcclusion=t(this._textureOcclusion),this._textureMetallicRoughness=t(this._textureMetallicRoughness),this._disposed=!0}ensureResources(t){return 0===this._numLoading?i.LOADED:i.LOADING}get textureBindParameters(){return new l(null!=this._texture?this._texture.glTexture:null,null!=this._textureNormal?this._textureNormal.glTexture:null,null!=this._textureEmissive?this._textureEmissive.glTexture:null,null!=this._textureOcclusion?this._textureOcclusion.glTexture:null,null!=this._textureMetallicRoughness?this._textureMetallicRoughness.glTexture:null)}updateTexture(e){null!=this._texture&&e===this._texture.id||(this._texture=t(this._texture),this._textureId=e,this._acquire(this._textureId,(t=>this._texture=t)))}_acquire(s,i){if(null==s)return void i(null);const u=this._textureRepository.acquire(s);if(e(u))return++this._numLoading,void u.then((e=>{if(this._disposed)return t(e),void i(null);i(e)})).finally((()=>--this._numLoading));i(u)}}class l extends s{constructor(t=null,e=null,s=null,i=null,u=null){super(),this.texture=t,this.textureNormal=e,this.textureEmissive=s,this.textureOcclusion=i,this.textureMetallicRoughness=u}}export{r as GLTextureMaterial,l as GLTextureMaterialBindParameters};
@@ -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{generateUID as t}from"../../../../core/uid.js";import{g as i}from"../../../../chunks/vec3.js";import{c as r}from"../../../../chunks/vec3f64.js";import{f as o}from"../../../../chunks/vec4f64.js";import{projectBuffer as s}from"../../../../geometry/projection/projectBuffer.js";import{Attribute as e}from"./Attribute.js";import{ContentObjectType as n}from"./ContentObjectType.js";import{Geometry as a}from"./Geometry.js";import{fromValues as h}from"./LocalOriginFactory.js";import{Object3D as m}from"./Object3D.js";import{gridLocalOriginFactory as c}from"./testUtils.js";import{VertexAttribute as g}from"./VertexAttribute.js";import{WebGLLayer as d}from"./WebGLLayer.js";import{RibbonLineMaterial as f}from"../materials/RibbonLineMaterial.js";class _{constructor(i){this._originSR=i,this._origins=new Map,this._objects=new Map,this._gridSize=5e5,this._rootOriginId="root/"+t()}getOrigin(t){const r=this._origins.get(this._rootOriginId);if(null==r){const i=c.rootOrigin;if(null!=i)return this._origins.set(this._rootOriginId,h(i[0],i[1],i[2],this._rootOriginId)),this.getOrigin(t);const r=h(t[0]+Math.random()-.5,t[1]+Math.random()-.5,t[2]+Math.random()-.5,this._rootOriginId);return this._origins.set(this._rootOriginId,r),r}const o=this._gridSize,s=Math.round(t[0]/o),e=Math.round(t[1]/o),n=Math.round(t[2]/o),a=`${s}/${e}/${n}`;let m=this._origins.get(a);const g=.5*o;if(i(p,t,r.vec3),p[0]=Math.abs(p[0]),p[1]=Math.abs(p[1]),p[2]=Math.abs(p[2]),p[0]<g&&p[1]<g&&p[2]<g){if(m){const r=Math.max(...p);i(p,t,m.vec3),p[0]=Math.abs(p[0]),p[1]=Math.abs(p[1]),p[2]=Math.abs(p[2]);if(Math.max(...p)<r)return m}return r}return m||(m=h(s*o,e*o,n*o,a),this._origins.set(a,m)),m}_drawOriginBox(t,i=o(1,1,0,1)){const r=window.view,h=r._stage,c=i.toString();if(!this._objects.has(c)){this._material=new f({width:2,color:i}),h.add(this._material);const t=new d(h,{pickable:!1}),r=new m({castShadow:!1});h.add(r),t.add(r),this._objects.set(c,r)}const _=this._objects.get(c),p=[0,1,5,4,0,2,1,7,6,2,0,1,3,7,5,4,6,2,0],j=p.length,u=new Array(3*j),l=new Array,b=.5*this._gridSize;for(let o=0;o<j;o++)u[3*o]=t[0]+(1&p[o]?b:-b),u[3*o+1]=t[1]+(2&p[o]?b:-b),u[3*o+2]=t[2]+(4&p[o]?b:-b),o>0&&l.push(o-1,o);s(u,this._originSR,0,u,r.renderSpatialReference,0,j);const M=new a(this._material,[[g.POSITION,new e(u,3,!0)]],[[g.POSITION,l]],null,n.Line);h.add(M),_.addGeometry(M)}get test(){const t=this;return{set gridSize(i){t._gridSize=i}}}}const p=r();export{_ as GridLocalOriginFactory};
5
+ import{generateUID as t}from"../../../../core/uid.js";import{g as i}from"../../../../chunks/vec3.js";import{c as r}from"../../../../chunks/vec3f64.js";import{f as o}from"../../../../chunks/vec4f64.js";import{projectBuffer as s}from"../../../../geometry/projection/projectBuffer.js";import{Attribute as e}from"./Attribute.js";import{ContentObjectType as n}from"./ContentObjectType.js";import{Geometry as a}from"./Geometry.js";import{fromValues as h}from"./LocalOriginFactory.js";import{Object3D as m}from"./Object3D.js";import{gridLocalOriginFactory as c}from"./testUtils.js";import{VertexAttribute as g}from"./VertexAttribute.js";import{WebGLLayer as d}from"./WebGLLayer.js";import{RibbonLineMaterial as f}from"../materials/RibbonLineMaterial.js";class _{constructor(i){this._originSR=i,this._rootOriginId="root/"+t(),this._origins=new Map,this._objects=new Map,this._gridSize=5e5}getOrigin(t){const r=this._origins.get(this._rootOriginId);if(null==r){const i=c.rootOrigin;if(null!=i)return this._origins.set(this._rootOriginId,h(i[0],i[1],i[2],this._rootOriginId)),this.getOrigin(t);const r=h(t[0]+Math.random()-.5,t[1]+Math.random()-.5,t[2]+Math.random()-.5,this._rootOriginId);return this._origins.set(this._rootOriginId,r),r}const o=this._gridSize,s=Math.round(t[0]/o),e=Math.round(t[1]/o),n=Math.round(t[2]/o),a=`${s}/${e}/${n}`;let m=this._origins.get(a);const g=.5*o;if(i(p,t,r.vec3),p[0]=Math.abs(p[0]),p[1]=Math.abs(p[1]),p[2]=Math.abs(p[2]),p[0]<g&&p[1]<g&&p[2]<g){if(m){const r=Math.max(...p);i(p,t,m.vec3),p[0]=Math.abs(p[0]),p[1]=Math.abs(p[1]),p[2]=Math.abs(p[2]);if(Math.max(...p)<r)return m}return r}return m||(m=h(s*o,e*o,n*o,a),this._origins.set(a,m)),m}_drawOriginBox(t,i=o(1,1,0,1)){const r=window.view,h=r._stage,c=i.toString();if(!this._objects.has(c)){this._material=new f({width:2,color:i}),h.add(this._material);const t=new d(h,{pickable:!1}),r=new m({castShadow:!1});h.add(r),t.add(r),this._objects.set(c,r)}const _=this._objects.get(c),p=[0,1,5,4,0,2,1,7,6,2,0,1,3,7,5,4,6,2,0],j=p.length,u=new Array(3*j),l=new Array,b=.5*this._gridSize;for(let o=0;o<j;o++)u[3*o]=t[0]+(1&p[o]?b:-b),u[3*o+1]=t[1]+(2&p[o]?b:-b),u[3*o+2]=t[2]+(4&p[o]?b:-b),o>0&&l.push(o-1,o);s(u,this._originSR,0,u,r.renderSpatialReference,0,j);const M=new a(this._material,[[g.POSITION,new e(u,3,!0)]],[[g.POSITION,l]],null,n.Line);h.add(M),_.addGeometry(M)}get test(){const t=this;return{set gridSize(i){t._gridSize=i}}}}const p=r();export{_ as GridLocalOriginFactory};
@@ -0,0 +1,5 @@
1
+ /*
2
+ All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
+ See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
+ */
5
+ function e(e){return!!e.frameUpdate}export{e as isFrameUpdateTexture};
@@ -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/Evented.js";import{someMap as r}from"../../../../core/MapUtils.js";import{disposeMaybe as i,removeMaybe as n}from"../../../../core/maybe.js";import{generateUID as o}from"../../../../core/uid.js";import{property as a}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/accessorSupport/ensureType.js";import"../../../../core/arrayUtils.js";import"../../../../core/has.js";import{subclass as h}from"../../../../core/accessorSupport/decorators/subclass.js";import{s as l}from"../../../../chunks/vec4.js";import{c as d}from"../../../../chunks/vec4f64.js";import{ContentObjectType as c}from"./ContentObjectType.js";import{textTextureAtlas as m}from"./testUtils.js";import{applyTextureResizeModulo as _}from"./textureUtils.js";import{VertexAttribute as u}from"./VertexAttribute.js";import{TaskPriority as p,Task as g,noBudget as x}from"../../../support/Scheduler.js";import{TextureWrapMode as f,TextureSamplingMode as T}from"../../../webgl/enums.js";import{Texture as v}from"../../../webgl/Texture.js";import{TextureDescriptor as A}from"../../../webgl/TextureDescriptor.js";const R=4096;class y{constructor(){this.offset={x:0,y:0},this.uvMinMax=d()}}class j{constructor(e,t){this.textId=e,this.textRenderer=t,this.placement=new y,this.rendered=!1}}class z{constructor(e,t,s){this.size=e,this.cursor=t,this.lineHeight=s}resetCursor(){this.cursor.x=w,this.cursor.y=w+E,this.lineHeight=0}getUsage(){return(this.cursor.x+this.cursor.y*this.size.width)/(this.size.width*this.size.height)}}let b=class extends t{constructor(e){super(e),this.type=c.Texture,this.id=o(),this.events=new s,this._glTexture=null,this._needsClear=!1,this._elementsToAddOrUpdate=new Map,this._elementsToRemove=new Map,this._elementsToRender=new Map,this._elements=new Map,this._stageObjects=new Map,this.updating=!1}initialize(){this._canvas=document.createElement("canvas"),this._canvas.setAttribute("id","textAtlasCanvas"),this._canvas.setAttribute("style","display:none"),this._ctx=this._canvas.getContext("2d"),this._stage=this.view._stage,this._stage.add(this),this._atlas=new z({width:R,height:256},{x:0,y:0},0),this._updateCanvasElementSize(this._atlas),this._resetAtlasCursor()}unload(){this._glTexture=i(this._glTexture),this.updating=!1,this.events.emit("unloaded")}get requiresFrameUpdates(){return!1}_createDescriptor(e){const t=new A;return t.wrapMode=f.CLAMP_TO_EDGE,t.flipped=!0,t.samplingMode=T.LINEAR_MIPMAP_LINEAR,t.hasMipmap=!0,t.preMultiplyAlpha=!0,t.maxAnisotropy=e.parameters.maxMaxAnisotropy,t}get glTexture(){return this._glTexture}load(e){return null!=this._glTexture||(this._glTexture=new v(e,this._createDescriptor(e),this._canvas),this._frameWorker=this.view.resourceController.scheduler.registerTask(p.TEXT_TEXTURE_ATLAS,this),this.setDirty()),this._glTexture}dispose(){this._elements=null,this._elementsToAddOrUpdate=null,this._elementsToRemove=null,this._elementsToRender=null,this._frameWorker=n(this._frameWorker),this._glTexture&&(this._stage.remove(this),this._glTexture=i(this._glTexture)),this._canvas.width=0,this._canvas.height=0,this._canvas=null,this._ctx=null}_updateCanvasElementSize(e){this._canvas.setAttribute("width",e.size.width.toString()),this._canvas.setAttribute("height",e.size.height.toString())}_resizeAtlas(e){const t=this._atlas;t.size.height=e,null!=this._glTexture&&this._glTexture.resize(t.size.width,t.size.height),this._updateCanvasElementSize(t)}_resetAtlasCursor(){this._atlas.resetCursor(),this._needsClear=!0}_addAtlasElement(e,t,s,r){const i=this._atlas,{renderedWidth:n,renderedHeight:o}=e.textRenderer;e.placement.offset.x=i.cursor.x,e.placement.offset.y=i.cursor.y,l(e.placement.uvMinMax,e.placement.offset.x/i.size.width,1-(e.placement.offset.y+o)/i.size.height,(e.placement.offset.x+n)/i.size.width,1-e.placement.offset.y/i.size.height),i.cursor.x+=s,i.lineHeight=Math.max(i.lineHeight,r),this._elements.set(t,e)}_removeAtlasElement(e){if(e&&this._elements.has(e.textId)){const t=e.placement.offset;this._ctx.clearRect(t.x,t.y,e.textRenderer.renderedWidth,e.textRenderer.renderedHeight),this._elements.delete(e.textId)}}_ensureStageObjects(e){const t=this._stageObjects.get(e);if(t)return t;const s=new Set;return this._stageObjects.set(e,s),s}_addStageObject(e,t){this._ensureStageObjects(e).add(t)}_removeStageObject(e,t){const s=this._stageObjects.get(e);s&&s.delete(t)&&(t.geometries[0].setAttributeData(u.SIZE,[0,0]),t.geometryVertexAttrsUpdated(t.geometries[0]))}_processAddition(e){const t=this._atlas,s=e.textId,r=e.textRenderer.renderedWidth,i=e.textRenderer.renderedHeight,n=r+w,o=i+w+E;if(t.cursor.x+n<t.size.width&&t.cursor.y+o<t.size.height)this._addAtlasElement(e,s,n,o),this._elementsToRender.set(s,e),this._elementsToAddOrUpdate.delete(s);else{if(!(t.cursor.y+o+t.lineHeight<t.size.height)){const e=t.cursor.y+o+t.lineHeight-t.size.height,s=t.size.height+e<R,r=t.size.height<R;if(s){const s=Math.ceil(t.size.height*Math.max(1.3,(e+t.size.height)/t.size.height));this._resizeAtlas(Math.min(_(s),R))}return r?(this._repack(),k.REPACK):(this._processRemovals(),k.OK)}t.cursor.x=w,t.cursor.y+=t.lineHeight,t.lineHeight=0,this._addAtlasElement(e,s,n,o),this._elementsToRender.set(s,e),this._elementsToAddOrUpdate.delete(s)}return k.OK}_processRemovals(){this._elementsToRemove.forEach(((e,t)=>{const s=this._stageObjects.get(t);s&&0!==s.size||this._removeAtlasElement(e),s&&0===s.size&&this._stageObjects.delete(t)})),this._elementsToRemove.clear()}_repack(){this._processRemovals(),this._elements.forEach(((e,t)=>{e.rendered=!1,this._elementsToAddOrUpdate.set(t,e)})),this._elements.clear(),this._resetAtlasCursor(),this._elementsToRender.clear()}_processRenderingRequest(e){this._ctx.clearRect(e.placement.offset.x,e.placement.offset.y,e.textRenderer.renderedWidth,e.textRenderer.renderedHeight),e.textRenderer.render(this._ctx,e.placement.offset.x,e.placement.offset.y);const t=this._stageObjects.get(e.textId);t&&t.forEach((t=>O(t,e))),e.rendered=!0}get running(){return this.updating}runTask(e){if(null==this._glTexture)return g.YIELD;if(r(this._elementsToAddOrUpdate,((t,s)=>{const r=this._elements.get(s);if(r?.rendered){const t=this._stageObjects.get(s);return t&&t.forEach((e=>O(e,r))),this._elementsToAddOrUpdate.delete(s),e.madeProgress(),!1}return this._processAddition(t)===k.REPACK})))return this.runTask(x),void e.madeProgress();let t=!1;this._elementsToRender.size>0&&this._needsClear&&(this._ctx.clearRect(0,0,this._canvas.width,this._canvas.height),this._needsClear=!1),r(this._elementsToRender,((s,r)=>(this._processRenderingRequest(s),this._elementsToRender.delete(r),t=!0,e.madeProgress(),e.done))),t&&this._glTexture.setData(this._canvas),this.updating=this._elementsToRender.size>0,!this.updating&&m.orderedRepackingEnabled&&(this._repackOrdered(),e.madeProgress())}addTextTexture(e,t){const s=e.key;this._elementsToAddOrUpdate.has(s)||this._elementsToAddOrUpdate.set(s,new j(s,e)),this._addStageObject(s,t),this._elementsToRemove.delete(s),this.setDirty()}removeTextTexture(e,t){const s=e.key;this._elementsToRemove.set(s,this._elements.get(s)),this._removeStageObject(s,t)}setDirty(){this._glTexture&&(this.updating=!0)}_repackOrdered(){if(0===this._elements.size)return;const e=[];this._elements.forEach(((t,s)=>e.push({element:t,key:s})));let t=!0;for(let s=0;s<e.length-1;s++)if(e[s].key.localeCompare(e[s+1].key)>0){t=!1;break}if(!t||0!==this._elementsToRemove.size){e.sort(((e,t)=>e.key.localeCompare(t.key))),this._elements.clear();for(const{element:t,key:s}of e)this._elements.set(s,t);this._repack(),this.setDirty()}}get test(){const{_elements:e,_stageObjects:t,_elementsToRemove:s,_atlas:r}=this,i=this;return{elements:e,stageObjects:t,elementsToRemove:s,atlas:r,resizeAtlas:e=>i._resizeAtlas(e),run:e=>i.runTask(e)}}};function O(e,t){e.geometries[0].setAttributeData(u.UV0,t.placement.uvMinMax),e.geometries[0].setAttributeData(u.SIZE,[t.textRenderer.displayWidth,t.textRenderer.displayHeight]),e.geometryVertexAttrsUpdated(e.geometries[0])}e([a({constructOnly:!0})],b.prototype,"view",void 0),e([a({type:Boolean})],b.prototype,"updating",void 0),b=e([h("esri.views.3d.webgl-engine.lib.TextTextureAtlas")],b);const w=2,E=2;var k;!function(e){e[e.OK=0]="OK",e[e.REPACK=1]="REPACK"}(k||(k={}));export{b as TextTextureAtlas};
5
+ import{_ as e}from"../../../../chunks/tslib.es6.js";import t from"../../../../core/Accessor.js";import s from"../../../../core/Evented.js";import{someMap as r}from"../../../../core/MapUtils.js";import{disposeMaybe as i,removeMaybe as n}from"../../../../core/maybe.js";import{generateUID as o}from"../../../../core/uid.js";import{property as h}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/accessorSupport/ensureType.js";import"../../../../core/arrayUtils.js";import"../../../../core/has.js";import{subclass as a}from"../../../../core/accessorSupport/decorators/subclass.js";import{s as l}from"../../../../chunks/vec4.js";import{c as d}from"../../../../chunks/vec4f64.js";import{ContentObjectType as c}from"./ContentObjectType.js";import{textTextureAtlas as m}from"./testUtils.js";import{applyTextureResizeModulo as _}from"./textureUtils.js";import{VertexAttribute as u}from"./VertexAttribute.js";import{TaskPriority as p,Task as g,noBudget as x}from"../../../support/Scheduler.js";import{TextureWrapMode as f,TextureSamplingMode as T}from"../../../webgl/enums.js";import{Texture as v}from"../../../webgl/Texture.js";import{TextureDescriptor as A}from"../../../webgl/TextureDescriptor.js";const R=4096;class y{constructor(){this.offset={x:0,y:0},this.uvMinMax=d()}}class j{constructor(e,t){this.textId=e,this.textRenderer=t,this.placement=new y,this.rendered=!1}}class z{constructor(e,t,s){this.size=e,this.cursor=t,this.lineHeight=s}resetCursor(){this.cursor.x=w,this.cursor.y=w+E,this.lineHeight=0}getUsage(){return(this.cursor.x+this.cursor.y*this.size.width)/(this.size.width*this.size.height)}}let b=class extends t{constructor(e){super(e),this.type=c.Texture,this.id=o(),this.events=new s,this._glTexture=null,this._needsClear=!1,this._elementsToAddOrUpdate=new Map,this._elementsToRemove=new Map,this._elementsToRender=new Map,this._elements=new Map,this._stageObjects=new Map,this.updating=!1}initialize(){this._canvas=document.createElement("canvas"),this._canvas.setAttribute("id","textAtlasCanvas"),this._canvas.setAttribute("style","display:none"),this._ctx=this._canvas.getContext("2d"),this._stage=this.view._stage,this._stage.add(this),this._atlas=new z({width:R,height:256},{x:0,y:0},0),this._updateCanvasElementSize(this._atlas),this._resetAtlasCursor()}unload(){this._glTexture=i(this._glTexture),this.updating=!1,this.events.emit("unloaded")}_createDescriptor(e){const t=new A;return t.wrapMode=f.CLAMP_TO_EDGE,t.flipped=!0,t.samplingMode=T.LINEAR_MIPMAP_LINEAR,t.hasMipmap=!0,t.preMultiplyAlpha=!0,t.maxAnisotropy=e.parameters.maxMaxAnisotropy,t}get glTexture(){return this._glTexture}load(e){return this._glTexture||(this._glTexture=new v(e,this._createDescriptor(e),this._canvas),this._frameWorker=this.view.resourceController.scheduler.registerTask(p.TEXT_TEXTURE_ATLAS,this),this.setDirty()),this._glTexture}dispose(){this._elements=null,this._elementsToAddOrUpdate=null,this._elementsToRemove=null,this._elementsToRender=null,this._frameWorker=n(this._frameWorker),this._glTexture&&(this._stage.remove(this),this._glTexture=i(this._glTexture)),this._canvas.width=0,this._canvas.height=0,this._canvas=null,this._ctx=null}_updateCanvasElementSize(e){this._canvas.setAttribute("width",e.size.width.toString()),this._canvas.setAttribute("height",e.size.height.toString())}_resizeAtlas(e){const t=this._atlas;t.size.height=e,null!=this._glTexture&&this._glTexture.resize(t.size.width,t.size.height),this._updateCanvasElementSize(t)}_resetAtlasCursor(){this._atlas.resetCursor(),this._needsClear=!0}_addAtlasElement(e,t,s,r){const i=this._atlas,{renderedWidth:n,renderedHeight:o}=e.textRenderer;e.placement.offset.x=i.cursor.x,e.placement.offset.y=i.cursor.y,l(e.placement.uvMinMax,e.placement.offset.x/i.size.width,1-(e.placement.offset.y+o)/i.size.height,(e.placement.offset.x+n)/i.size.width,1-e.placement.offset.y/i.size.height),i.cursor.x+=s,i.lineHeight=Math.max(i.lineHeight,r),this._elements.set(t,e)}_removeAtlasElement(e){if(e&&this._elements.has(e.textId)){const t=e.placement.offset;this._ctx.clearRect(t.x,t.y,e.textRenderer.renderedWidth,e.textRenderer.renderedHeight),this._elements.delete(e.textId)}}_ensureStageObjects(e){const t=this._stageObjects.get(e);if(t)return t;const s=new Set;return this._stageObjects.set(e,s),s}_addStageObject(e,t){this._ensureStageObjects(e).add(t)}_removeStageObject(e,t){const s=this._stageObjects.get(e);s&&s.delete(t)&&(t.geometries[0].setAttributeData(u.SIZE,[0,0]),t.geometryVertexAttrsUpdated(t.geometries[0]))}_processAddition(e){const t=this._atlas,s=e.textId,r=e.textRenderer.renderedWidth,i=e.textRenderer.renderedHeight,n=r+w,o=i+w+E;if(t.cursor.x+n<t.size.width&&t.cursor.y+o<t.size.height)this._addAtlasElement(e,s,n,o),this._elementsToRender.set(s,e),this._elementsToAddOrUpdate.delete(s);else{if(!(t.cursor.y+o+t.lineHeight<t.size.height)){const e=t.cursor.y+o+t.lineHeight-t.size.height,s=t.size.height+e<R,r=t.size.height<R;if(s){const s=Math.ceil(t.size.height*Math.max(1.3,(e+t.size.height)/t.size.height));this._resizeAtlas(Math.min(_(s),R))}return r?(this._repack(),k.REPACK):(this._processRemovals(),k.OK)}t.cursor.x=w,t.cursor.y+=t.lineHeight,t.lineHeight=0,this._addAtlasElement(e,s,n,o),this._elementsToRender.set(s,e),this._elementsToAddOrUpdate.delete(s)}return k.OK}_processRemovals(){this._elementsToRemove.forEach(((e,t)=>{const s=this._stageObjects.get(t);s&&0!==s.size||this._removeAtlasElement(e),s&&0===s.size&&this._stageObjects.delete(t)})),this._elementsToRemove.clear()}_repack(){this._processRemovals(),this._elements.forEach(((e,t)=>{e.rendered=!1,this._elementsToAddOrUpdate.set(t,e)})),this._elements.clear(),this._resetAtlasCursor(),this._elementsToRender.clear()}_processRenderingRequest(e){this._ctx.clearRect(e.placement.offset.x,e.placement.offset.y,e.textRenderer.renderedWidth,e.textRenderer.renderedHeight),e.textRenderer.render(this._ctx,e.placement.offset.x,e.placement.offset.y);const t=this._stageObjects.get(e.textId);t&&t.forEach((t=>O(t,e))),e.rendered=!0}get running(){return this.updating}runTask(e){if(null==this._glTexture)return g.YIELD;if(r(this._elementsToAddOrUpdate,((t,s)=>{const r=this._elements.get(s);if(r?.rendered){const t=this._stageObjects.get(s);return t&&t.forEach((e=>O(e,r))),this._elementsToAddOrUpdate.delete(s),e.madeProgress(),!1}return this._processAddition(t)===k.REPACK})))return this.runTask(x),void e.madeProgress();let t=!1;this._elementsToRender.size>0&&this._needsClear&&(this._ctx.clearRect(0,0,this._canvas.width,this._canvas.height),this._needsClear=!1),r(this._elementsToRender,((s,r)=>(this._processRenderingRequest(s),this._elementsToRender.delete(r),t=!0,e.madeProgress(),e.done))),t&&this._glTexture.setData(this._canvas),this.updating=this._elementsToRender.size>0,!this.updating&&m.orderedRepackingEnabled&&(this._repackOrdered(),e.madeProgress())}addTextTexture(e,t){const s=e.key;this._elementsToAddOrUpdate.has(s)||this._elementsToAddOrUpdate.set(s,new j(s,e)),this._addStageObject(s,t),this._elementsToRemove.delete(s),this.setDirty()}removeTextTexture(e,t){const s=e.key;this._elementsToRemove.set(s,this._elements.get(s)),this._removeStageObject(s,t)}setDirty(){this._glTexture&&(this.updating=!0)}_repackOrdered(){if(0===this._elements.size)return;const e=[];this._elements.forEach(((t,s)=>e.push({element:t,key:s})));let t=!0;for(let s=0;s<e.length-1;s++)if(e[s].key.localeCompare(e[s+1].key)>0){t=!1;break}if(!t||0!==this._elementsToRemove.size){e.sort(((e,t)=>e.key.localeCompare(t.key))),this._elements.clear();for(const{element:t,key:s}of e)this._elements.set(s,t);this._repack(),this.setDirty()}}get test(){const{_elements:e,_stageObjects:t,_elementsToRemove:s,_atlas:r}=this,i=this;return{elements:e,stageObjects:t,elementsToRemove:s,atlas:r,resizeAtlas:e=>i._resizeAtlas(e),run:e=>i.runTask(e)}}};function O(e,t){e.geometries[0].setAttributeData(u.UV0,t.placement.uvMinMax),e.geometries[0].setAttributeData(u.SIZE,[t.textRenderer.displayWidth,t.textRenderer.displayHeight]),e.geometryVertexAttrsUpdated(e.geometries[0])}e([h({constructOnly:!0})],b.prototype,"view",void 0),e([h({type:Boolean})],b.prototype,"updating",void 0),b=e([a("esri.views.3d.webgl-engine.lib.TextTextureAtlas")],b);const w=2,E=2;var k;!function(e){e[e.OK=0]="OK",e[e.REPACK=1]="REPACK"}(k||(k={}));export{b as TextTextureAtlas};