@arcgis/core 4.28.0-next.20231003 → 4.28.0-rc.0

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 (211) hide show
  1. package/assets/esri/core/workers/RemoteClient.js +1 -1
  2. package/assets/esri/core/workers/chunks/02120d192eafd7612475.js +1 -0
  3. package/assets/esri/core/workers/chunks/0beebbb0c6dad0e742d7.js +1 -0
  4. package/assets/esri/core/workers/chunks/112e89da628bdea5355c.js +1 -0
  5. package/assets/esri/core/workers/chunks/{5e9edd06e624f385fa4b.js → 121a9e148509f2fe2210.js} +1 -1
  6. package/assets/esri/core/workers/chunks/1856d16d738f44f58084.js +1 -0
  7. package/assets/esri/core/workers/chunks/{0526d623d0b4c12929bd.js → 18ab9cc85a1a7988fdfd.js} +1 -1
  8. package/assets/esri/core/workers/chunks/{7c960a2694c4c3123acf.js → 1a36703ebe934749646e.js} +1 -1
  9. package/assets/esri/core/workers/chunks/24a0cf405195421c0d06.js +1 -0
  10. package/assets/esri/core/workers/chunks/24ff267cf253feac22de.js +1 -0
  11. package/assets/esri/core/workers/chunks/{3c8613596659801fd6ab.js → 29cab345819ec02ed60a.js} +1 -1
  12. package/assets/esri/core/workers/chunks/{169a61c6e128b8a16021.js → 2c560a075d9ef2069ed1.js} +1 -1
  13. package/assets/esri/core/workers/chunks/2f8e71dac98135bbc3e6.js +1 -0
  14. package/assets/esri/core/workers/chunks/341fb51b2165522963b3.js +1 -0
  15. package/assets/esri/core/workers/chunks/{ad8e0f82cb1feafa9e2f.js → 36ab90fb34b9716a9983.js} +1 -1
  16. package/assets/esri/core/workers/chunks/{2688213bbff536da7917.js → 3ea0b872436fce84b927.js} +1 -1
  17. package/assets/esri/core/workers/chunks/40633064c290dc2af9ea.js +1 -0
  18. package/assets/esri/core/workers/chunks/42ec4c80b0c2944cd65c.js +1 -0
  19. package/assets/esri/core/workers/chunks/44b870cb53ba68b17c32.js +1 -0
  20. package/assets/esri/core/workers/chunks/{8a7fa4e8b0d14da7c9eb.js → 4cc680fe4c9c39d2f853.js} +1 -1
  21. package/assets/esri/core/workers/chunks/{6730c9f0890191a95fdb.js → 4d81aa50d90f5701a343.js} +1 -1
  22. package/assets/esri/core/workers/chunks/4e0bf30da4281070e453.js +1 -0
  23. package/assets/esri/core/workers/chunks/4e6bf1efe3b0b474cbb4.js +1 -0
  24. package/assets/esri/core/workers/chunks/52cef7cd3aaaa4f45c94.js +1 -0
  25. package/assets/esri/core/workers/chunks/5e907ec0ee1565b5fbbc.js +1 -0
  26. package/assets/esri/core/workers/chunks/66ba749ab0a631bbfdec.js +1 -0
  27. package/assets/esri/core/workers/chunks/6b14d89d689a21014aec.js +1 -0
  28. package/assets/esri/core/workers/chunks/6b1856303d1562f05100.js +1 -0
  29. package/assets/esri/core/workers/chunks/{576269fd1f9049876aa1.js → 6b7b5544ed1f9a84623f.js} +1 -1
  30. package/assets/esri/core/workers/chunks/710a6268de62003af825.js +1 -0
  31. package/assets/esri/core/workers/chunks/77923afde29ae1ff10ca.js +1 -0
  32. package/assets/esri/core/workers/chunks/784ffd52315a4d55d683.js +1 -0
  33. package/assets/esri/core/workers/chunks/7cf7f2b991a7cbdad2ce.js +1 -0
  34. package/assets/esri/core/workers/chunks/{70dffbf49b0633b1a5f1.js → 8f3680fee85a05839489.js} +1 -1
  35. package/assets/esri/core/workers/chunks/97aecf210938015cc7a3.js +1 -0
  36. package/assets/esri/core/workers/chunks/{c7ebd5d431fb996bfcee.js → 9f8207c82a17508a87a8.js} +1 -1
  37. package/assets/esri/core/workers/chunks/{557305b91f77569ce664.js → a01ffe03b1465c21b9e6.js} +1 -1
  38. package/assets/esri/core/workers/chunks/a298c9031962951e55a9.js +1 -0
  39. package/assets/esri/core/workers/chunks/{329669a9beda89b028dd.js → a5a7bbdd8298016535bc.js} +1 -1
  40. package/assets/esri/core/workers/chunks/a877a4826cd6a46ec99b.js +1 -0
  41. package/assets/esri/core/workers/chunks/ad38e456a7cee940a165.js +1 -0
  42. package/assets/esri/core/workers/chunks/adfbc168be8c49b51e1b.js +1 -0
  43. package/assets/esri/core/workers/chunks/b0526633a93ef69ec47b.js +1 -0
  44. package/assets/esri/core/workers/chunks/b99bc08a01e9250b0a31.js +1 -0
  45. package/assets/esri/core/workers/chunks/{36c4b4c3eca57417da2c.js → c260ad3434bb00ba64a7.js} +1 -1
  46. package/assets/esri/core/workers/chunks/{39922ce232338de076ae.js → c459c8d8630eb4b955b1.js} +1 -1
  47. package/assets/esri/core/workers/chunks/c92e75b79aff7b505b31.js +1 -0
  48. package/assets/esri/core/workers/chunks/ca85e88dad30b5f2956b.js +1 -0
  49. package/assets/esri/core/workers/chunks/{8e56d40691b6bf75d7cc.js → ce409944221a784ddb61.js} +1 -1
  50. package/assets/esri/core/workers/chunks/d13f75f233cf313e5a1d.js +1 -0
  51. package/assets/esri/core/workers/chunks/d60d5f006375f7fcc88c.js +1 -0
  52. package/assets/esri/core/workers/chunks/{77958089748dc31757cf.js → d6ded127949160103f69.js} +1 -1
  53. package/assets/esri/core/workers/chunks/d8c696da42f8f8919b83.js +1 -0
  54. package/assets/esri/core/workers/chunks/{304c81f6297ecba3a324.js → d95eed98316e59f8f35d.js} +1 -1
  55. package/assets/esri/core/workers/chunks/df7267892b6e0493e1d7.js +1 -0
  56. package/assets/esri/core/workers/chunks/{52dca349e1a45555954d.js → e52d5a48e83d8df36f92.js} +1 -1
  57. package/assets/esri/core/workers/chunks/e8688b6cc3b3c1010b43.js +1 -0
  58. package/assets/esri/core/workers/chunks/e8c7cc974420c0b92d0e.js +1 -0
  59. package/assets/esri/core/workers/chunks/{b6847d68c35e7dbf6004.js → e93442c6d92229f3a4b0.js} +1 -1
  60. package/assets/esri/core/workers/chunks/f2718e260f594537f7fd.js +1 -0
  61. package/assets/esri/core/workers/chunks/f6b7036114b1d754fdd9.js +1 -0
  62. package/assets/esri/core/workers/chunks/{c4631241dc777ca77aaa.js → f6c0680c535c5a3c73ee.js} +1 -1
  63. package/assets/esri/core/workers/chunks/fac3e57784d7f37053af.js +1 -0
  64. package/assets/esri/t9n/common.json +1 -1
  65. package/assets/esri/t9n/common_ar.json +1 -1
  66. package/assets/esri/t9n/common_bg.json +1 -1
  67. package/assets/esri/t9n/common_bs.json +1 -1
  68. package/assets/esri/t9n/common_ca.json +1 -1
  69. package/assets/esri/t9n/common_cs.json +1 -1
  70. package/assets/esri/t9n/common_da.json +1 -1
  71. package/assets/esri/t9n/common_de.json +1 -1
  72. package/assets/esri/t9n/common_el.json +1 -1
  73. package/assets/esri/t9n/common_en.json +1 -1
  74. package/assets/esri/t9n/common_es.json +1 -1
  75. package/assets/esri/t9n/common_et.json +1 -1
  76. package/assets/esri/t9n/common_fi.json +1 -1
  77. package/assets/esri/t9n/common_fr.json +1 -1
  78. package/assets/esri/t9n/common_he.json +1 -1
  79. package/assets/esri/t9n/common_hr.json +1 -1
  80. package/assets/esri/t9n/common_hu.json +1 -1
  81. package/assets/esri/t9n/common_id.json +1 -1
  82. package/assets/esri/t9n/common_it.json +1 -1
  83. package/assets/esri/t9n/common_ja.json +1 -1
  84. package/assets/esri/t9n/common_ko.json +1 -1
  85. package/assets/esri/t9n/common_lt.json +1 -1
  86. package/assets/esri/t9n/common_lv.json +1 -1
  87. package/assets/esri/t9n/common_nb.json +1 -1
  88. package/assets/esri/t9n/common_nl.json +1 -1
  89. package/assets/esri/t9n/common_pl.json +1 -1
  90. package/assets/esri/t9n/common_pt-BR.json +1 -1
  91. package/assets/esri/t9n/common_pt-PT.json +1 -1
  92. package/assets/esri/t9n/common_ro.json +1 -1
  93. package/assets/esri/t9n/common_ru.json +1 -1
  94. package/assets/esri/t9n/common_sk.json +1 -1
  95. package/assets/esri/t9n/common_sl.json +1 -1
  96. package/assets/esri/t9n/common_sr.json +1 -1
  97. package/assets/esri/t9n/common_sv.json +1 -1
  98. package/assets/esri/t9n/common_th.json +1 -1
  99. package/assets/esri/t9n/common_tr.json +1 -1
  100. package/assets/esri/t9n/common_uk.json +1 -1
  101. package/assets/esri/t9n/common_vi.json +1 -1
  102. package/assets/esri/t9n/common_zh-CN.json +1 -1
  103. package/assets/esri/t9n/common_zh-HK.json +1 -1
  104. package/assets/esri/t9n/common_zh-TW.json +1 -1
  105. package/assets/esri/themes/base/widgets/_DirectionalPad.scss +2 -1
  106. package/assets/esri/themes/base/widgets/_FeatureForm.scss +0 -1
  107. package/assets/esri/themes/dark/main.css +1 -1
  108. package/assets/esri/themes/light/main.css +1 -1
  109. package/assets/esri/themes/light/view.css +1 -1
  110. package/config.js +1 -1
  111. package/core/pbf.js +1 -1
  112. package/interfaces.d.ts +0 -32
  113. package/kernel.js +1 -1
  114. package/layers/GroupLayer.js +1 -1
  115. package/layers/SceneLayer.js +1 -1
  116. package/layers/graphics/editingSupport.js +1 -1
  117. package/layers/graphics/sources/WFSSourceWorker.js +1 -1
  118. package/layers/graphics/sources/geojson/GeoJSONSourceWorker.js +1 -1
  119. package/layers/graphics/sources/support/CSVSourceWorker.js +1 -1
  120. package/layers/graphics/sources/support/MemorySourceWorker.js +1 -1
  121. package/layers/mixins/OperationalLayer.js +1 -1
  122. package/layers/save/featureLayerUtils.js +1 -1
  123. package/layers/save/groupLayerUtils.js +5 -0
  124. package/layers/save/utils.js +1 -1
  125. package/layers/support/LayerLoadContext.js +5 -0
  126. package/layers/support/featureLayerUtils.js +1 -1
  127. package/layers/support/labelFormatUtils.js +1 -1
  128. package/layers/support/layersCreator.js +1 -1
  129. package/package.json +1 -1
  130. package/portal/schemas/definitions.js +1 -1
  131. package/portal/support/jsonContext.js +1 -1
  132. package/portal/support/layersLoader.js +1 -1
  133. package/portal/support/loadUtils.js +5 -0
  134. package/portal/support/portalItemUtils.js +1 -1
  135. package/portal/support/portalLayers.js +1 -1
  136. package/renderers/support/RasterSymbolizer.js +1 -1
  137. package/support/basemapUtils.js +1 -1
  138. package/support/revision.js +1 -1
  139. package/symbols/PolygonSymbol3D.js +1 -1
  140. package/views/2d/engine/imagery/RasterBitmap.js +1 -1
  141. package/views/2d/engine/imagery/colorizer/shadedrelief.js +1 -1
  142. package/views/2d/engine/imagery/colorizer/stretch.js +1 -1
  143. package/views/2d/input/handlers/KeyPan.js +1 -1
  144. package/views/2d/input/handlers/KeyRotate.js +1 -1
  145. package/views/2d/layers/features/support/FeatureSetReader.js +1 -1
  146. package/views/2d/layers/features/support/FeatureSetReaderPBFIndirect.js +1 -1
  147. package/views/3d/input/handlers/KeyboardNavigation.js +1 -1
  148. package/views/3d/interactive/visualElements/LineVisualElement.js +1 -1
  149. package/views/3d/layers/graphics/Graphics3DMeshFillSymbolLayer.js +1 -1
  150. package/views/3d/layers/graphics/Graphics3DMeshObject3DGraphicLayer.js +1 -1
  151. package/views/3d/layers/i3s/featureEditing.js +1 -1
  152. package/views/3d/webgl-engine/lib/edgeRendering/EdgeView.js +1 -1
  153. package/views/3d/webgl-engine/materials/RibbonLineMaterial.js +1 -1
  154. package/views/DOMContainer.js +1 -1
  155. package/views/input/VisibilityChange.js +5 -0
  156. package/webdoc/support/saveUtils.js +1 -1
  157. package/webdoc/webdocSaveUtils.js +1 -1
  158. package/widgets/DirectionalPad/DirectionalPadViewModel.js +1 -1
  159. package/widgets/DirectionalPad/constants.js +1 -1
  160. package/widgets/DirectionalPad.js +1 -1
  161. package/widgets/FeatureForm/FieldInput.js +1 -1
  162. package/widgets/FeatureForm/featureFormUtils.js +1 -1
  163. package/widgets/FeatureForm.js +1 -1
  164. package/widgets/FeatureTable/FeatureTableViewModel.js +1 -1
  165. package/widgets/FeatureTable/FieldColumn.js +1 -1
  166. package/widgets/support/dateUtils.js +1 -1
  167. package/assets/esri/core/workers/chunks/027f8b57565c65fbccda.js +0 -1
  168. package/assets/esri/core/workers/chunks/048265fb5953350e3e33.js +0 -1
  169. package/assets/esri/core/workers/chunks/0b9cf14f8aafb76c578b.js +0 -1
  170. package/assets/esri/core/workers/chunks/10fd951bd296b2beeeba.js +0 -1
  171. package/assets/esri/core/workers/chunks/1224475f3eefdfd59c76.js +0 -1
  172. package/assets/esri/core/workers/chunks/162b0220e24e9ba72655.js +0 -1
  173. package/assets/esri/core/workers/chunks/1e611cad53b745ee146f.js +0 -1
  174. package/assets/esri/core/workers/chunks/29ed31fd4f9d5cf53686.js +0 -1
  175. package/assets/esri/core/workers/chunks/2b6d1c8e4ed759767827.js +0 -1
  176. package/assets/esri/core/workers/chunks/34b44b0fab88f838885c.js +0 -1
  177. package/assets/esri/core/workers/chunks/364f55294a1d7bf163d7.js +0 -1
  178. package/assets/esri/core/workers/chunks/3714ab435dd5ccf9e694.js +0 -1
  179. package/assets/esri/core/workers/chunks/3788009a5ece453011f3.js +0 -1
  180. package/assets/esri/core/workers/chunks/3aafe8160b3bfbaa6935.js +0 -1
  181. package/assets/esri/core/workers/chunks/3e6255ab48b561af131e.js +0 -1
  182. package/assets/esri/core/workers/chunks/41c002e4c42c581cda8d.js +0 -1
  183. package/assets/esri/core/workers/chunks/47be4c75dd6372b96fe4.js +0 -1
  184. package/assets/esri/core/workers/chunks/4e8d1e6051f6654a5e83.js +0 -1
  185. package/assets/esri/core/workers/chunks/53746e9976758630159b.js +0 -1
  186. package/assets/esri/core/workers/chunks/5449fdd69e12e5cbd12a.js +0 -1
  187. package/assets/esri/core/workers/chunks/57ce4ece0147afb0d43c.js +0 -1
  188. package/assets/esri/core/workers/chunks/5e83d21400a5dec05c81.js +0 -1
  189. package/assets/esri/core/workers/chunks/6047f4487dcd37cca98e.js +0 -1
  190. package/assets/esri/core/workers/chunks/6967d2b3721678b38774.js +0 -1
  191. package/assets/esri/core/workers/chunks/6ac5ca7de651e3d672a1.js +0 -1
  192. package/assets/esri/core/workers/chunks/6b7ee9164149428edb9e.js +0 -1
  193. package/assets/esri/core/workers/chunks/6c495077cc79e1898927.js +0 -1
  194. package/assets/esri/core/workers/chunks/6d43648d5326e01b4474.js +0 -1
  195. package/assets/esri/core/workers/chunks/74fb07de0f990d45af89.js +0 -1
  196. package/assets/esri/core/workers/chunks/8e9a52062ce059153a89.js +0 -1
  197. package/assets/esri/core/workers/chunks/919a57d372419785cd5e.js +0 -1
  198. package/assets/esri/core/workers/chunks/939f0a1a7d605e389e45.js +0 -1
  199. package/assets/esri/core/workers/chunks/9932f23ba6589df14a3d.js +0 -1
  200. package/assets/esri/core/workers/chunks/a25a38c9f338e0beffef.js +0 -1
  201. package/assets/esri/core/workers/chunks/a97581e584336b46ede7.js +0 -1
  202. package/assets/esri/core/workers/chunks/b04eb35e06b1c5759ad0.js +0 -1
  203. package/assets/esri/core/workers/chunks/b1cb932cfadc4dc3f1e4.js +0 -1
  204. package/assets/esri/core/workers/chunks/be3fb6113b0b27b94537.js +0 -1
  205. package/assets/esri/core/workers/chunks/c37119f5692e19aa1ce2.js +0 -1
  206. package/assets/esri/core/workers/chunks/c685f16435d9861bbbd0.js +0 -1
  207. package/assets/esri/core/workers/chunks/e6416a2684866d677b3e.js +0 -1
  208. package/assets/esri/core/workers/chunks/eb01f4cdb9b918cc61e7.js +0 -1
  209. package/assets/esri/core/workers/chunks/eb4aed4fdb44495a4fe6.js +0 -1
  210. package/assets/esri/core/workers/chunks/ec8258c9dc1491e97fc8.js +0 -1
  211. package/assets/esri/core/workers/chunks/eeac53da496de4cd4182.js +0 -1
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/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{a}from"../../../../chunks/mat3f64.js";import{d as s,m as n,i}from"../../../../chunks/mat4.js";import{a as l,I as c,b as u}from"../../../../chunks/mat4f64.js";import{s as m,g as h,i as f,j as p,n as d,f as g,b 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 w}from"../../../../geometry/projection/projectBuffer.js";import{projectVectorToDehydratedPoint as j}from"../../../../geometry/projection/projectVectorToDehydratedPoint.js";import{create as M,empty as O,expandWithBuffer as P,intersectsClippingArea as R}from"../../../../geometry/support/aaBoundingBox.js";import{newFloatArray as A}from"../../../../geometry/support/FloatArray.js";import{getContinuousIndexArray as E,getZeroIndexArray as I}from"../../../../geometry/support/Indices.js";import N from"../../../../geometry/support/MeshComponent.js";import B from"../../../../geometry/support/MeshMaterialMetallicRoughness.js";import F from"../../../../geometry/support/MeshTextureTransform.js";import{t as S,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 se}from"../../support/debugFlags.js";import{Attribute as ne}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(){se.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)}get materials(){return this._materialInfoCache.materials}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=>t(e)?.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=>t(e)?.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,s=Ae,{origin:n,transform:i}=r;switch(C(t,m(we,n.x,n.y,n.z??0),s,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(s,i,this._context.localOriginFactory)}const{elevationContext:l}=e;l.centerPointInElevationSR=this._getCenterPointInElevationSR(s);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,s),e.updateTransform(s,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:s,colorTextureTransform:n,normalTexture:i,normalTextureTransform:l,doubleSided:c,alphaCutoff:u,alphaMode:m}=t.material,h=this._colorOrTextureUid(a),f=this._colorOrTextureUid(s),p=this._textureTransformUid(n),d=this._colorOrTextureUid(i),g=this._textureTransformUid(l);if(o.color=a,o.colorTexture=s,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 B){const{metallic:e,roughness:r,metallicRoughnessTexture:a,metallicRoughnessTextureTransform:s,emissiveColor:i,emissiveTexture:c,emissiveTextureTransform:u,occlusionTexture:m,occlusionTextureTransform:h}=t.material,f=this._colorOrTextureUid(a),p=this._textureTransformUid(s),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(n),o.normalTextureTransform=this._convertTextureTransform(l),o.emissiveTextureTransform=this._convertTextureTransform(u),o.occlusionTextureTransform=this._convertTextureTransform(h),o.metallicRoughnessTextureTransform=this._convertTextureTransform(s),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.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);if(!a){let s=null;const n=this._context.stage.renderView.renderingContext.parameters.maxMaxAnisotropy,i={wrap:this._castTextureWrap(e.wrap),noUnpackFlip:!0,maxAnisotropy:n,mipmap:n>1};W(r)?(s=r.data,i.preMultiplyAlpha=!1,i.encoding=r.encoding):(s=r,i.preMultiplyAlpha=t!==ie.Opaque,i.downsampleUncompressed=this._context.graphicsCoreOwner.view.qualitySettings.graphics3D.uncompressedTextureDownsamplingEnabled),a=new he(s,i),this._textures.set(o,a),a.load(this._context.stage.renderView.renderingContext),this._context.stage.add(a)}return 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);e?(r.textureId=e.id,r.textureAlphaPremultiplied=!!e.parameters.preMultiplyAlpha):r.textureId=void 0}t.normalTexture&&(r.normalTextureId=this._getInternalTextureId(t.normalTexture)),t.emissiveColor&&(r.emissiveFactor=e.toUnitRGB(t.emissiveColor)),t.emissiveTexture&&(r.emissiveTextureId=this._getInternalTextureId(t.emissiveTexture)),t.occlusionTexture&&(r.occlusionTextureId=this._getInternalTextureId(t.occlusionTexture)),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=this.symbolLayer.material?.colorMixMode??null;if(r)t.externalColor=b;else{const r=this.symbolLayer.material?.color??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,s=r.material?.alphaMode,n="blend"===s,i=!("opaque"===s)&&(this._hasTransparentVertexColors(t)||null!=o&&o.a<1||a?.transparent||n),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),s=[],n=[],i=[],l=[];for(let p=0;p<r;p++){const e=t[p],r=e.attributes.get(fe.POSITION),o=e.attributes.get(fe.NORMAL),c=r.data,u=r.indices,m=o.data,d=o.indices;for(let t=0;t<u.length;t++){const e=3*u[t],r=3*d[t];for(let t=0;t<3;t++)s.push(c[e+t]);for(let t=0;t<3;t++)s.push(c[e+t]+m[r+t]*a);if(n.push(n.length),n.push(n.length),t%3==0){this._calculateFaceNormal(c,u,t,Oe),this._getFaceVertices(c,u,t,we,je,Me),h(we,we,je),h(we,we,Me),f(we,we,1/3);for(let e=0;e<3;e++)i.push(we[e]);for(let e=0;e<3;e++)i.push(we[e]+Oe[e]*a);l.push(l.length),l.push(l.length)}}}const c=t[0].transformation,u=new ue(this._debugVertexNormalMaterial,[[fe.POSITION,new ne(s,n,3,!0)]],null,ce.Line);t.push(u),u.transformation=c;const m=new ue(this._debugFaceNormalMaterial,[[fe.POSITION,new ne(i,l,3,!0)]],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 s=this._createGeometryInfo(a,t,o);if(null==s)return null;const{geometries:n,objectTransformation:i}=s;se.DRAW_MESH_GEOMETRY_NORMALS&&this._addDebugNormals(a,n);const l=new me({geometries:n,layerUid:this._context.layer.uid,graphicUid:o});l.transformation=i;const c=re(this.symbolLayer,{opacity:this._getLayerOpacity()}),u=c?new Q(n[0].material,[c],{mergeGeometries:!0,hasSlicePlane:this._context.slicePlaneEnabled}):null,m=new K(this,l,n,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 s=0;s<o.length;s+=3){this._calculateFaceNormal(e,o,s,Oe);for(let e=0;e<3;e++){const r=3*o[s+e];we[0]=t[r],we[1]=t[r+1],we[2]=t[r+2],p(Oe,we)<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 s=this._calculateFaceNormal(e,t,a,Oe);for(let e=0;e<3;e++)r[a+e]=s[e],o[a+e]=a/3}return new ve(r,o,!1)}_createComponentNormalsSmooth(e,t){const r={};for(let s=0;s<t.length;s+=3){const o=this._calculateFaceNormal(e,t,s,Oe);for(let e=0;e<3;e++){const a=t[s+e];let n=r[a];n||(n={normal:y(),count:0},r[a]=n),h(n.normal,n.normal,o),n.count++}}const o=A(3*t.length),a=new Array(3*t.length);for(let s=0;s<t.length;s++){const e=r[t[s]];1!==e.count&&(d(e.normal,e.normal),e.count=1);for(let t=0;t<3;t++)o[3*s+t]=e.normal[t];a[s]=s}return new ve(o,a,!1)}_getFaceVertices(e,t,r,o,a,s){const n=3*t[r],i=3*t[r+1],l=3*t[r+2];o[0]=e[n],o[1]=e[n+1],o[2]=e[n+2],a[0]=e[i],a[1]=e[i+1],a[2]=e[i+2],s[0]=e[l],s[1]=e[l+1],s[2]=e[l+2]}_calculateFaceNormal(e,t,r,o){return this._getFaceVertices(e,t,r,we,je,Me),g(je,je,we),g(Me,Me,we),x(we,je,Me),d(o,we),o}_getOrCreateComponents(e){return e.components??Ie}_createPositionBuffer(e,t){let r=e.vertexAttributes.position;const o=t.reprojection===Be.ECEF?t.transformBeforeProject:null;if(o&&(r=S(new Float64Array(r.length),r,o)),t.reprojection===Be.NONE)return t.needsBufferCopy?new Float64Array(r):r;const a=o?r:new Float64Array(r.length);return w(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===Be.ECEF?r.transformBeforeProject:null;a&&(o=$(o,new Float32Array(o.length),a));if("local"===this._context.graphicsCoreOwner.view.viewingMode||r.reprojection===Be.NONE)return r.needsBufferCopy&&e.vertexAttributes.normal===o?new Float32Array(o):o;const s=e.vertexAttributes.position,n=a?o:new Float32Array(o.length);return G(o,s,t,e.spatialReference,n)}_createTangentBuffer(e,t,r){let o=e.vertexAttributes.tangent;if(null==o)return null;const a=r.reprojection===Be.ECEF?r.transformBeforeProject:null;a&&(o=V(o,new Float32Array(o.length),a));if("local"===this._context.graphicsCoreOwner.view.viewingMode||r.reprojection===Be.NONE)return r.needsBufferCopy&&e.vertexAttributes.normal===o?new Float32Array(o):o;const s=e.vertexAttributes.position,n=a?o:new Float32Array(o.length);return D(o,s,t,e.spatialReference,n)}_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,s=e.vertexAttributes.tangent;if(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(s&&s.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(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 n=this._computeReprojectionInfo(e),i=this._createPositionBuffer(e,n),c=this._createColorBuffer(e),u=this._createSymbolColorBuffer(t),m=this._createNormalBuffer(e,i,n),h=this._createTangentBuffer(e,i,n);return{positionBuffer:i,normalBuffer:m,tangentBuffer:h,uvBuffer:a,colorBuffer:c,symbolColorBuffer:u,objectTransformation:n.reprojection===Be.NONE&&n.objectTransformation?n.objectTransformation:this._transformOriginLocal(e,i,m,h),geometryTransformation:n.reprojection===Be.NONE&&n.geometryTransformation?n.geometryTransformation:l()}}_computeReprojectionInfo(e){const{vertexSpace:t}=e,r=t.isRelative,o=t.isGeoreferenced?this._context.renderCoordsHelper.viewingMode===q.Local?Be.NONE:Be.ECEF:Be.NONE;if(r){const{origin:r}=t,a=l(),i=e.transform?.localMatrix??c;if(o===Be.NONE){C(e.spatialReference,r,a,this._context.renderCoordsHelper.spatialReference);return{reprojection:o,objectTransformation:a,geometryTransformation:u(i),needsBufferCopy:!1}}const m=s(l(),r);return n(m,m,i),{reprojection:o,transformBeforeProject:m,needsBufferCopy:!0}}return{reprojection:o,needsBufferCopy:!0}}_transformOriginLocal(e,t,a,s){const n=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,n),i(Pe,u),S(t,t,Pe),(a||s)&&(r(Re,u),o(Re,Re),a&&U(a,a,Re),s&&U(s,s,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??E(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 O(Ee),P(Ee,o,0,a),!R(Ee,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:s,colorBuffer:n,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 ne(a,t,3,!0)],[fe.NORMAL,new ne(o.normals,o.indices,3,!0)]];n&&u.push([fe.COLOR,new ne(n,t,4,!0)]),i&&u.push([fe.SYMBOLCOLOR,new ne(i,I(t.length),4,!0)]),s&&u.push([fe.UV0,new ne(s,t,2,!0)]),c&&u.push([fe.TANGENT,new ne(c,t,4,!0)]);const h=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:r,layerUid:this._context.layer.uid}),g=this._getOrCreateMaterial(e,d),x=new ue(g,u,null,ce.Mesh,h);x.transformation=m,f.push(x)}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(),we=y(),je=y(),Me=y(),Oe=y(),Pe=l(),Re=a(),Ae=l(),Ee=M(),Ie=[new N],Ne=new F;var Be;!function(e){e[e.NONE=0]="NONE",e[e.ECEF=1]="ECEF"}(Be||(Be={}));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{a}from"../../../../chunks/mat3f64.js";import{d as s,m as n,i,B as l}from"../../../../chunks/mat4.js";import{a as c,I as u,b as m}from"../../../../chunks/mat4f64.js";import{s as h,g as f,i as p,j as d,n as g,f as x,b as _}from"../../../../chunks/vec3.js";import{Z as T,O as y,c as b}from"../../../../chunks/vec3f64.js";import{O as v}from"../../../../chunks/vec4f64.js";import{canProjectWithoutEngine as C}from"../../../../geometry/projection.js";import{computeTranslationToOriginAndRotation as w}from"../../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{projectBuffer as j}from"../../../../geometry/projection/projectBuffer.js";import{projectVectorToDehydratedPoint as O}from"../../../../geometry/projection/projectVectorToDehydratedPoint.js";import{create as M,empty as P,expandWithBuffer as R,intersectsClippingArea as A}from"../../../../geometry/support/aaBoundingBox.js";import{newFloatArray as E}from"../../../../geometry/support/FloatArray.js";import{getContinuousIndexArray as I,getZeroIndexArray as N}from"../../../../geometry/support/Indices.js";import B from"../../../../geometry/support/MeshComponent.js";import F from"../../../../geometry/support/MeshMaterialMetallicRoughness.js";import S from"../../../../geometry/support/MeshTextureTransform.js";import{t as U,a as L}from"../../../../chunks/vec32.js";import{project as $}from"../../../../geometry/support/meshUtils/georeference.js";import{transformNormal as G,projectNormalToPCPF as V,transformTangent as D,projectTangentToPCPF as k}from"../../../../geometry/support/meshUtils/projection.js";import{makeDehydratedPoint as H}from"../../../../layers/graphics/dehydratedPoint.js";import{MeshTransformUpdateAction as q}from"../../../../layers/graphics/sources/interfaces.js";import{ViewingMode as W}from"../../../ViewingMode.js";import{isEncodedMeshTexture as z}from"../../glTF/internal/resourceUtils.js";import{getTransformMatrix as Y}from"../../glTF/internal/TextureTransformUtils.js";import{perObjectElevationAligner as Z}from"./ElevationAligners.js";import{needsElevationUpdates3D as J,evaluateElevationInfoAtPoint as K}from"./elevationAlignmentUtils.js";import{Graphics3DMeshObject3DGraphicLayer as Q}from"./Graphics3DMeshObject3DGraphicLayer.js";import{Object3DEdgeState as X}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as ee}from"./Graphics3DSymbolLayer.js";import{MaterialInfoCache as te,MeshFastUpdateProcessor as re}from"./MeshFastUpdateProcessor.js";import{createMaterial as oe}from"../support/edgeUtils.js";import{parseColorMixMode as ae,encodeSymbolColor as se}from"../support/symbolColorUtils.js";import{debugFlags as ne}from"../../support/debugFlags.js";import{Attribute as ie}from"../../webgl-engine/lib/Attribute.js";import{AlphaDiscardMode as le,CullFaceOptions as ce}from"../../webgl-engine/lib/basicInterfaces.js";import{ContentObjectType as ue}from"../../webgl-engine/lib/ContentObjectType.js";import{Geometry as me}from"../../webgl-engine/lib/Geometry.js";import{Object3D as he}from"../../webgl-engine/lib/Object3D.js";import{Texture as fe}from"../../webgl-engine/lib/Texture.js";import{VertexAttribute as pe}from"../../webgl-engine/lib/VertexAttribute.js";import{DefaultMaterial as de}from"../../webgl-engine/materials/DefaultMaterial.js";import{NativeLineMaterial as ge}from"../../webgl-engine/materials/NativeLineMaterial.js";import{useSchematicPBR as xe,defaultSchematicMRRFactors as _e,defaultAdvancedMRRFactors as Te}from"../../webgl-engine/materials/pbrUtils.js";import{TextureWrapMode as ye}from"../../../webgl/enums.js";const be=["mesh"];class ve extends ee{constructor(e,t,r,o){super(e,t,r,o),this._materialInfoCache=new te,this._fastUpdateProcessor=new re,this._textures=new Map,this.ensureDrapedStatus(!1)}async doLoad(){ne.DRAW_MESH_GEOMETRY_NORMALS&&(this._debugVertexNormalMaterial=new ge({color:[1,0,1,1]}),this._debugFaceNormalMaterial=new ge({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)}get materials(){return this._materialInfoCache.materials}createGraphics3DGraphic(e){const t=e.graphic;if(!this._validateGeometry(t.geometry,be,"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=>t(e)?.layerOpacityChanged(r,this._context.isAsync)))}layerElevationInfoChanged(e,t){return this.updateGraphics3DGraphicElevationInfo(e,t,J)}slicePlaneEnabledChanged(e,t){return this._updateMaterialParameters((({material:e})=>{e.setParameters({hasSlicePlane:this._context.slicePlaneEnabled})})),e.forEach((e=>t(e)?.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,s=Ee,{origin:n,transform:i}=r;switch(w(t,h(je,n.x,n.y,n.z??0),s,a),o){case q.EnableFastUpdates:this._fastUpdateProcessor.enable(e,this._materialInfoCache,this._context);break;case q.DisableFastUpdates:this._fastUpdateProcessor.disable(e,this._materialInfoCache,this._context);break;case q.UpdateFastLocalOrigin:e.updateFastLocalOrigin(s,i,this._context.localOriginFactory)}const{elevationContext:l}=e;l.centerPointInElevationSR=this._getCenterPointInElevationSR(s);const{elevationProvider:c,renderCoordsHelper:u}=this._context,m=(e,t)=>K(e,c,l,u,t);return e.alignedSampledElevation=Z(e,l,c.spatialReference,m,u,s),e.updateTransform(s,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??Be;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:s,colorTextureTransform:n,normalTexture:i,normalTextureTransform:l,doubleSided:c,alphaCutoff:u,alphaMode:m}=t.material,h=this._colorOrTextureUid(a),f=this._colorOrTextureUid(s),p=this._textureTransformUid(n),d=this._colorOrTextureUid(i),g=this._textureTransformUid(l);if(o.color=a,o.colorTexture=s,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 F){const{metallic:e,roughness:r,metallicRoughnessTexture:a,metallicRoughnessTextureTransform:s,emissiveColor:i,emissiveTexture:c,emissiveTextureTransform:u,occlusionTexture:m,occlusionTextureTransform:h}=t.material,f=this._colorOrTextureUid(a),p=this._textureTransformUid(s),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(n),o.normalTextureTransform=this._convertTextureTransform(l),o.emissiveTextureTransform=this._convertTextureTransform(u),o.occlusionTextureTransform=this._convertTextureTransform(h),o.metallicRoughnessTextureTransform=this._convertTextureTransform(s),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.url}_getInternalTextureId(e){const t=this._getInternalTexture(e,le.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);if(!a){let s=null;const n=this._context.stage.renderView.renderingContext.parameters.maxMaxAnisotropy,i={wrap:this._castTextureWrap(e.wrap),noUnpackFlip:!0,maxAnisotropy:n,mipmap:n>1};z(r)?(s=r.data,i.preMultiplyAlpha=!1,i.encoding=r.encoding):(s=r,i.preMultiplyAlpha=t!==le.Opaque,i.downsampleUncompressed=this._context.graphicsCoreOwner.view.qualitySettings.graphics3D.uncompressedTextureDownsamplingEnabled),a=new fe(s,i),this._textures.set(o,a),a.load(this._context.stage.renderView.renderingContext),this._context.stage.add(a)}return 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 ye.CLAMP_TO_EDGE;case"mirror":return ye.MIRRORED_REPEAT;default:return ye.REPEAT}}_setInternalMaterialParameters(t,r){if(null!=t.color&&this._setInternalColorValueParameters(t.color,r),null!=t.colorTexture){const e=this._getInternalTexture(t.colorTexture,r.textureAlphaMode);e?(r.textureId=e.id,r.textureAlphaPremultiplied=!!e.parameters.preMultiplyAlpha):r.textureId=void 0}t.normalTexture&&(r.normalTextureId=this._getInternalTextureId(t.normalTexture)),t.emissiveColor&&(r.emissiveFactor=e.toUnitRGB(t.emissiveColor)),t.emissiveTexture&&(r.emissiveTextureId=this._getInternalTextureId(t.emissiveTexture)),t.occlusionTexture&&(r.occlusionTextureId=this._getInternalTextureId(t.occlusionTexture)),t.metallicRoughnessTexture&&(r.metallicRoughnessTextureId=this._getInternalTextureId(t.metallicRoughnessTexture)),r.colorTextureTransformMatrix=Y(t.colorTextureTransform),r.normalTextureTransformMatrix=Y(t.normalTextureTransform),r.occlusionTextureTransformMatrix=Y(t.occlusionTextureTransform),r.emissiveTextureTransformMatrix=Y(t.emissiveTextureTransform),r.metallicRoughnessTextureTransformMatrix=Y(t.metallicRoughnessTextureTransform)}_setExternalMaterialParameters(t){const r=this._drivenProperties.color;let o=this.symbolLayer.material?.colorMixMode??null;if(r)t.externalColor=v;else{const r=this.symbolLayer.material?.color??null;r?t.externalColor=e.toUnitRGBA(r):(o=null,t.externalColor=v)}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,s=r.material?.alphaMode,n="blend"===s,i=!("opaque"===s)&&(this._hasTransparentVertexColors(t)||null!=o&&o.a<1||a?.transparent||n),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=xe({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:T,diffuse:y,opacity:1,doubleSided:!0,doubleSidedType:"winding-order",cullFace:ce.None,layerOpacity:this._getLayerOpacity(),hasSlicePlane:this._context.slicePlaneEnabled,initTextureTransparent:!0};h.mrrFactors=m?[..._e]:[l.metallic,l.roughness,Te[2]],r.material&&(h.doubleSided=r.material.doubleSided,h.cullFace=r.material.doubleSided?ce.None:ce.Back,h.textureAlphaCutoff=r.material.alphaCutoff),this._setExternalMaterialParameters(h),this._setMaterialTransparentParameter(h,u),this._setInternalMaterialParameters(l,h);const f=new de(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?le.MaskBlend:le.Opaque:e.textureAlphaMode="opaque"===t.alphaMode?le.Opaque:"mask"===t.alphaMode?le.Mask:le.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),s=[],n=[],i=[],l=[];for(let h=0;h<r;h++){const e=t[h],r=e.attributes.get(pe.POSITION),o=e.attributes.get(pe.NORMAL),c=r.data,u=r.indices,m=o.data,d=o.indices;for(let t=0;t<u.length;t++){const e=3*u[t],r=3*d[t];for(let t=0;t<3;t++)s.push(c[e+t]);for(let t=0;t<3;t++)s.push(c[e+t]+m[r+t]*a);if(n.push(n.length),n.push(n.length),t%3==0){this._calculateFaceNormal(c,u,t,Pe),this._getFaceVertices(c,u,t,je,Oe,Me),f(je,je,Oe),f(je,je,Me),p(je,je,1/3);for(let e=0;e<3;e++)i.push(je[e]);for(let e=0;e<3;e++)i.push(je[e]+Pe[e]*a);l.push(l.length),l.push(l.length)}}}const c=t[0].transformation,u=new me(this._debugVertexNormalMaterial,[[pe.POSITION,new ie(s,n,3,!0)]],null,ue.Line);t.push(u),u.transformation=c;const m=new me(this._debugFaceNormalMaterial,[[pe.POSITION,new ie(i,l,3,!0)]],null,ue.Line);m.transformation=c,t.push(m)}_createAs3DShape(e,t,r,o){const a=e.geometry;if("mesh"!==a.type)return null;const s=this._createGeometryInfo(a,t,o);if(null==s)return null;const{geometries:n,objectTransformation:i}=s;ne.DRAW_MESH_GEOMETRY_NORMALS&&this._addDebugNormals(a,n);const l=new he({geometries:n,layerUid:this._context.layer.uid,graphicUid:o});l.transformation=i;const c=oe(this.symbolLayer,{opacity:this._getLayerOpacity()}),u=c?new X(n[0].material,[c],{mergeGeometries:!0,hasSlicePlane:this._context.slicePlaneEnabled}):null,m=new Q(this,l,n,null,null,Z,r,u);this._fastUpdateProcessor.onAddGraphic(),m.needsElevationUpdates=J(r.mode),m.useObjectOriginAsAttachmentOrigin=!0,r.centerPointInElevationSR=this._getCenterPointInElevationSR(l.transformation);const{elevationProvider:h,renderCoordsHelper:f}=this._context,p=(e,t)=>K(e,h,r,f,t);return m.alignedSampledElevation=Z(m,r,h.spatialReference,p,f),m}_getCenterPointInElevationSR(e){const t=H(0,0,0,null!=this._context.elevationProvider.spatialReference?this._context.elevationProvider.spatialReference:null);return O([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 s=0;s<o.length;s+=3){this._calculateFaceNormal(e,o,s,Pe);for(let e=0;e<3;e++){const r=3*o[s+e];je[0]=t[r],je[1]=t[r+1],je[2]=t[r+2],d(Pe,je)<0&&(t[r]=-t[r],t[r+1]=-t[r+1],t[r+2]=-t[r+2],a=!0)}}return new Ce(t,o,a)}_createComponentNormalsFlat(e,t){const r=E(t.length),o=new Array(3*t.length);for(let a=0;a<t.length;a+=3){const s=this._calculateFaceNormal(e,t,a,Pe);for(let e=0;e<3;e++)r[a+e]=s[e],o[a+e]=a/3}return new Ce(r,o,!1)}_createComponentNormalsSmooth(e,t){const r={};for(let s=0;s<t.length;s+=3){const o=this._calculateFaceNormal(e,t,s,Pe);for(let e=0;e<3;e++){const a=t[s+e];let n=r[a];n||(n={normal:b(),count:0},r[a]=n),f(n.normal,n.normal,o),n.count++}}const o=E(3*t.length),a=new Array(3*t.length);for(let s=0;s<t.length;s++){const e=r[t[s]];1!==e.count&&(g(e.normal,e.normal),e.count=1);for(let t=0;t<3;t++)o[3*s+t]=e.normal[t];a[s]=s}return new Ce(o,a,!1)}_getFaceVertices(e,t,r,o,a,s){const n=3*t[r],i=3*t[r+1],l=3*t[r+2];o[0]=e[n],o[1]=e[n+1],o[2]=e[n+2],a[0]=e[i],a[1]=e[i+1],a[2]=e[i+2],s[0]=e[l],s[1]=e[l+1],s[2]=e[l+2]}_calculateFaceNormal(e,t,r,o){return this._getFaceVertices(e,t,r,je,Oe,Me),x(Oe,Oe,je),x(Me,Me,je),_(je,Oe,Me),g(o,je),o}_getOrCreateComponents(e){return e.components??Ne}_createPositionBuffer(e,t){let r=e.vertexAttributes.position;const o=t.reprojection===Fe.ECEF?t.transformBeforeProject:null;if(o&&(r=U(new Float64Array(r.length),r,o)),t.reprojection===Fe.NONE)return t.needsBufferCopy?new Float64Array(r):r;const a=o?r:new Float64Array(r.length);return j(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===Fe.ECEF?r.transformBeforeProject:null;a&&(o=G(o,new Float32Array(o.length),a));if("local"===this._context.graphicsCoreOwner.view.viewingMode||r.reprojection===Fe.NONE)return r.needsBufferCopy&&e.vertexAttributes.normal===o?new Float32Array(o):o;const s=e.vertexAttributes.position,n=a?o:new Float32Array(o.length);return V(o,s,t,e.spatialReference,n)}_createTangentBuffer(e,t,r){let o=e.vertexAttributes.tangent;if(null==o)return null;const a=r.reprojection===Fe.ECEF?r.transformBeforeProject:null;a&&(o=D(o,new Float32Array(o.length),a));if("local"===this._context.graphicsCoreOwner.view.viewingMode||r.reprojection===Fe.NONE)return r.needsBufferCopy&&e.vertexAttributes.normal===o?new Float32Array(o):o;const s=e.vertexAttributes.position,n=a?o:new Float32Array(o.length);return k(o,s,t,e.spatialReference,n)}_createColorBuffer(e){return e.vertexAttributes.color}_createSymbolColorBuffer(e){if(this._requiresSymbolVertexColors()){const t=this._getVertexOpacityAndColor(e),r=ae(this.symbolLayer?.material?.colorMixMode),o=new Uint8Array(4);return se(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,s=e.vertexAttributes.tangent;if(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(s&&s.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(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 n=this._computeReprojectionInfo(e),i=this._createPositionBuffer(e,n),l=this._createColorBuffer(e),u=this._createSymbolColorBuffer(t),m=this._createNormalBuffer(e,i,n),h=this._createTangentBuffer(e,i,n);return{positionBuffer:i,normalBuffer:m,tangentBuffer:h,uvBuffer:a,colorBuffer:l,symbolColorBuffer:u,objectTransformation:n.reprojection===Fe.NONE&&n.objectTransformation?n.objectTransformation:this._transformOriginLocal(e,i,m,h),geometryTransformation:n.reprojection===Fe.NONE&&n.geometryTransformation?n.geometryTransformation:c()}}_computeReprojectionInfo(e){const{vertexSpace:t}=e,r=t.isRelative,o=t.isGeoreferenced?this._context.renderCoordsHelper.viewingMode===W.Local?Fe.NONE:Fe.ECEF:Fe.NONE;if(r){const{origin:r}=t,a=c(),i=e.transform?.localMatrix??u;if(o===Fe.NONE){w(e.spatialReference,r,a,this._context.renderCoordsHelper.spatialReference);return{reprojection:o,objectTransformation:a,geometryTransformation:m(i),needsBufferCopy:!1}}const l=s(c(),r);return n(l,l,i),{reprojection:o,transformBeforeProject:l,needsBufferCopy:!0}}return{reprojection:o,needsBufferCopy:!0}}_transformOriginLocal(e,t,a,s){const n=this._context.renderCoordsHelper.spatialReference,l=e.anchor;we[0]=l.x,we[1]=l.y,we[2]=l.z??0;const u=c();return w(e.spatialReference,we,u,n),i(Re,u),U(t,t,Re),(a||s)&&(r(Ae,u),o(Ae,Ae),a&&L(a,a,Ae),s&&L(s,s,Ae,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=$({positions:t,transform:e.transform,vertexSpace:e.vertexSpace,inSpatialReference:e.spatialReference,outSpatialReference:r??e.spatialReference}),a=o.length/3;return P(Ie),R(Ie,o,0,a),!A(Ie,this._context.clippingExtent)}_createGeometryInfo(e,t,r){if(!C(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:s,colorBuffer:n,symbolColorBuffer:i,normalBuffer:c,tangentBuffer:u,objectTransformation:m,geometryTransformation:h}=o,f=this._getOrCreateComponents(e),p=new Array;let d=!1;const g=l(je,m),x=this._context.localOriginFactory.getOrigin(g);for(const l of f){if(!this._validateFaces(e,l))return null;const t=this._getOrCreateFaces(e,l);if(0===t.length)continue;const o=this._createComponentNormals(a,c,l,t);o.didFlipNormals&&(d=!0);const m=[[pe.POSITION,new ie(a,t,3,!0)],[pe.NORMAL,new ie(o.normals,o.indices,3,!0)]];n&&m.push([pe.COLOR,new ie(n,t,4,!0)]),i&&m.push([pe.SYMBOLCOLOR,new ie(i,N(t.length),4,!0)]),s&&m.push([pe.UV0,new ie(s,t,2,!0)]),u&&m.push([pe.TANGENT,new ie(u,t,4,!0)]);const f=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:r,layerUid:this._context.layer.uid}),g=this._getOrCreateMaterial(e,l),_=new me(g,m,null,ue.Mesh,f);_.transformation=h,_.localOrigin=x,p.push(_)}return d&&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:p,objectTransformation:m}}_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 Ce{constructor(e,t,r){this.normals=e,this.indices=t,this.didFlipNormals=r}}const we=b(),je=b(),Oe=b(),Me=b(),Pe=b(),Re=c(),Ae=a(),Ee=c(),Ie=M(),Ne=[new B],Be=new S;var Fe;!function(e){e[e.NONE=0]="NONE",e[e.ECEF=1]="ECEF"}(Fe||(Fe={}));export{ve 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{B as t,m as e,i as a,h as s,d as r}from"../../../../chunks/mat4.js";import{I as i,a as o}from"../../../../chunks/mat4f64.js";import{i as n}from"../../../../chunks/vec3.js";import{c as m}from"../../../../chunks/vec3f64.js";import{perObjectElevationAligner as f}from"./ElevationAligners.js";import{evaluateElevationInfoAtPoint as l}from"./elevationAlignmentUtils.js";import{setContextFeature as d}from"./featureExpressionInfoUtils.js";import{Graphics3DObject3DGraphicLayer as c}from"./Graphics3DObject3DGraphicLayer.js";class g extends c{constructor(){super(...arguments),this._originalGeometries=[],this._fastTransformUpdatesEnabled=!1}get fastTransformUpdatesEnabled(){return this._fastTransformUpdatesEnabled}enableFastTransformUpdates(e,a){if(this._fastTransformUpdatesEnabled)return;this._fastTransformUpdatesEnabled=!0;const{stageObject:s}=this,r=s.geometries.slice();s.removeAllGeometries();const i=t(h,s.transformation),o=a.getOrigin(i);for(const t of r){const a=e(t.material),r=t.instantiate({material:a});r.localOrigin=o,s.addGeometry(r)}this._originalGeometries=r}disableFastTransformUpdates(t){if(!this._fastTransformUpdatesEnabled)return;this._fastTransformUpdatesEnabled=!1;const{stageObject:e}=this,a=e.geometries.map((e=>t(e.material)));e.removeAllGeometries();for(let s=0;s<this._originalGeometries.length;s++){const t=this._originalGeometries[s],r=a[s];r.setParameters({modelTransformation:null}),r===t.material?e.addGeometry(t):e.addGeometry(t.instantiate({material:r}))}this._originalGeometries.length=0}updateFastLocalOrigin(e,a,s){if(!this._fastTransformUpdatesEnabled)return;const{stageObject:r}=this;if(0===r.geometries.length)return;const o=r.geometries[0].localOrigin,n=t(h,e),m=s.getOrigin(n);if(m===o)return;const f=a?.localMatrix??i;r.shaderTransformation=null,r.transformation=e,r.geometries.forEach((t=>{t.transformation=f,t.localOrigin=m}))}updateTransform(t,s,r){const{stageObject:o}=this,n=s?.localMatrix??i;if(!this._fastTransformUpdatesEnabled)return o.shaderTransformation=null,o.transformation=t,o.geometries.forEach((t=>{t.transformation=n})),void this.resetEdgeObject(r);const m=o.transformation,f=o.geometries[0].transformation,l=t,d=n,c=e(p,m,f),g=e(T,l,d),h=e(E,g,a(E,f));o.shaderTransformation=h,this._setFastMaterialTransformation({matA:c,matB:g}),this._fastUpdateEdgeTransform()||this.resetEdgeObject(r)}alignWithElevation(t,a,r,i){if(!this._fastTransformUpdatesEnabled)return void super.alignWithElevation(t,a,r,i);null!=r&&d(this.elevationContext.featureExpressionInfoContext,r);const o=(e,s)=>l(e,t,this.elevationContext,a,s),{stageObject:n}=this;if(!n.geometries[0].material.parameters.modelTransformation)return;const m=n.transformation,c=n.geometries[0].transformation,g=e(p,m,c),h=n.effectiveTransformation,E=s(u,h);this.alignedSampledElevation=f(this,this.elevationContext,t.spatialReference,o,a,E),n.shaderTransformation=E;const b=n.geometries[0].transformation,_=e(T,E,b);this._setFastMaterialTransformation({matA:g,matB:_}),this._fastUpdateEdgeTransform()||this.resetEdgeObject(i)}_setFastMaterialTransformation({matA:t,matB:s}){const{stageObject:i}=this;if(0===i.geometries.length)return;const o=i.geometries[0].localOrigin,m=r(j,n(h,o.vec3,-1)),f=e(b,m,t),l=e(_,m,s),d=a(b,f),c=e(_,l,d);for(const e of i.geometries)e.material.setParameters({modelTransformation:c})}_fastUpdateEdgeTransform(){return this._stageLayer.stage.renderer.ensureEdgeView().fastUpdateObject3DEdgesTransform(this.stageObject)}}const h=m(),p=o(),T=o(),u=o(),E=o(),b=o(),_=o(),j=o();export{g as Graphics3DMeshObject3DGraphicLayer};
5
+ import{B as t,m as e,i as a,h as s,d as r}from"../../../../chunks/mat4.js";import{I as i,a as o}from"../../../../chunks/mat4f64.js";import{i as n}from"../../../../chunks/vec3.js";import{c as m}from"../../../../chunks/vec3f64.js";import{perObjectElevationAligner as f}from"./ElevationAligners.js";import{evaluateElevationInfoAtPoint as l}from"./elevationAlignmentUtils.js";import{setContextFeature as d}from"./featureExpressionInfoUtils.js";import{Graphics3DObject3DGraphicLayer as c}from"./Graphics3DObject3DGraphicLayer.js";class g extends c{constructor(){super(...arguments),this._originalGeometries=[],this._fastTransformUpdatesEnabled=!1}get fastTransformUpdatesEnabled(){return this._fastTransformUpdatesEnabled}enableFastTransformUpdates(e,a){if(this._fastTransformUpdatesEnabled)return;this._fastTransformUpdatesEnabled=!0;const{stageObject:s}=this,r=s.geometries.slice();s.removeAllGeometries();const i=t(h,s.transformation),o=a.getOrigin(i);for(const t of r){const a=e(t.material),r=t.instantiate({material:a});r.localOrigin=o,s.addGeometry(r)}this._originalGeometries=r}disableFastTransformUpdates(t){if(!this._fastTransformUpdatesEnabled)return;this._fastTransformUpdatesEnabled=!1;const{stageObject:e}=this,a=e.geometries.map((e=>t(e.material)));e.removeAllGeometries();for(let s=0;s<this._originalGeometries.length;s++){const t=this._originalGeometries[s],r=a[s];r.setParameters({modelTransformation:null}),r===t.material?e.addGeometry(t):e.addGeometry(t.instantiate({material:r}))}this._originalGeometries.length=0}updateFastLocalOrigin(e,a,s){if(!this._fastTransformUpdatesEnabled)return;const{stageObject:r}=this;if(0===r.geometries.length)return;const o=r.geometries[0].localOrigin,n=t(h,e),m=s.getOrigin(n);if(m===o)return;const f=a?.localMatrix??i;r.shaderTransformation=null,r.transformation=e,r.geometries.forEach((t=>{t.transformation=f,t.localOrigin=m}))}updateTransform(t,s,r){const{stageObject:o}=this,n=s?.localMatrix??i;if(!this._fastTransformUpdatesEnabled)return o.shaderTransformation=null,o.transformation=t,o.geometries.forEach((t=>{t.transformation=n})),void(this._fastUpdateEdgeTransform()||this.resetEdgeObject(r));const m=o.transformation,f=o.geometries[0].transformation,l=t,d=n,c=e(p,m,f),g=e(T,l,d),h=e(E,g,a(E,f));o.shaderTransformation=h,this._setFastMaterialTransformation({matA:c,matB:g}),this._fastUpdateEdgeTransform()||this.resetEdgeObject(r)}alignWithElevation(t,a,r,i){if(!this._fastTransformUpdatesEnabled)return void super.alignWithElevation(t,a,r,i);null!=r&&d(this.elevationContext.featureExpressionInfoContext,r);const o=(e,s)=>l(e,t,this.elevationContext,a,s),{stageObject:n}=this;if(!n.geometries[0].material.parameters.modelTransformation)return;const m=n.transformation,c=n.geometries[0].transformation,g=e(p,m,c),h=n.effectiveTransformation,E=s(u,h);this.alignedSampledElevation=f(this,this.elevationContext,t.spatialReference,o,a,E),n.shaderTransformation=E;const b=n.geometries[0].transformation,_=e(T,E,b);this._setFastMaterialTransformation({matA:g,matB:_}),this._fastUpdateEdgeTransform()||this.resetEdgeObject(i)}_setFastMaterialTransformation({matA:t,matB:s}){const{stageObject:i}=this;if(0===i.geometries.length)return;const o=i.geometries[0].localOrigin,m=r(j,n(h,o.vec3,-1)),f=e(b,m,t),l=e(_,m,s),d=a(b,f),c=e(_,l,d);for(const e of i.geometries)e.material.setParameters({modelTransformation:c})}_fastUpdateEdgeTransform(){return this._stageLayer.stage.renderer.ensureEdgeView().fastUpdateObject3DEdgesTransform(this.stageObject)}}const h=m(),p=o(),T=o(),u=o(),E=o(),b=o(),_=o(),j=o();export{g as Graphics3DMeshObject3DGraphicLayer};
@@ -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{resultOrAbort as e}from"../../../../core/asyncUtils.js";import{clone as t}from"../../../../core/lang.js";import{queryAllJSON as n}from"../../../../layers/support/featureQueryAll.js";const o={setAttribute(){},rollback(){},commit(){}};var r;function i(e,n){const i=n.attributes[e.objectIdField];if(null==i)return o;const s=e.sessions.get(i);if(s)return s;const l=t(n.attributes),a=new Set,u=e.i3sOverrides.createInteractiveEditSession(i),d=new Map,f=(e,t)=>{const n=d.get(e);if(null==n){const n=t.indexOf(i);return d.set(e,n),n}return n};let c=r.EDITING;const I={setAttribute(t,o){if(c!==r.EDITING)return;const i=e.fieldsIndex.get(t);if(!i)return;const s=e.attributeStorageInfo.findIndex((e=>e.name===i.name));if(s<0)return;if(!(t in l))throw new Error(`Attribute "${t}" is not an attribute of the edited feature.`);u.setAttribute(s,o);const d=e.attributeStorageInfo[s];let I=!1;a.add(t),e.forEachNode(((t,r)=>{const i=f(t,r);if(-1===i)return;const s=e.getAttributeData(t.index);if(s){const r=s[d.name];r&&(r[i]=o,e.setAttributeData(t.index,s,n),I=!0)}})),I&&e.clearMemCache()},rollback(){if(c===r.EDITING){for(const e of a)this.setAttribute(e,l[e]);u.remove(),c=r.ROLLED_BACK,e.sessions.delete(i)}},commit(){c===r.EDITING&&(u.remove(),c=r.COMMITTED,e.sessions.delete(i))}};return e.sessions.set(i,I),I}function s(e,t,n){const{gidToFeatureInfo:o,oidToFeatureInfo:r,fieldsIndex:i,objectIdField:s,globalIdField:l,featureOrIdentifierList:a}=n;if(!n.featuresResolved&&null!=a){for(const e of a){const t={feature:null,oid:-1,gid:null};if("attributes"in e){t.feature=e;const n=e.attributes;if(null!=n)for(const e in n){if(-1!==t.oid&&null!=t.gid)break;const o=i.normalizeFieldName(e);o===s&&(t.oid=n[e]??-1),o===l&&(t.gid=n[e])}}else t.oid=e.objectId??-1,t.gid=e.globalId;null!=t.gid&&o.set(t.gid,t),-1!==t.oid&&r.set(t.oid,t)}n.featuresResolved=!0}return(-1!==e?r.get(e):null)??(null!=t?o.get(t):null)}function l(e,t,n,o,r=!0){const i=[],l={gidToFeatureInfo:new Map,oidToFeatureInfo:new Map,featuresResolved:null==n,fieldsIndex:e.fieldsIndex,objectIdField:e.objectIdField,globalIdField:e.globalIdField,featureOrIdentifierList:n};for(const a of t){if(null!=a.error)continue;const e=a.objectId??-1,t=a.globalId,n=(-1===e||r?s(e,t,l):null)??{feature:null,oid:e,gid:t},u={oid:-1===e?n.oid:e,gid:t??n.gid,feature:n.feature,result:a};if(i.push(u),-1===u.oid&&null!=u.gid){let e=o.get(u.gid);null==e&&(e=[],o.set(u.gid,e)),e.push(u)}}return i}async function a(e,t){const n=new Map,o=l(e,t.addedFeatures,t.edits?.addFeatures,n),r=l(e,t.updatedFeatures,t.edits?.updateFeatures,n),i=l(e,t.deletedFeatures,t.edits?.deleteFeatures,n,!1);return n.size>0&&await u(e,n),{adds:o.filter((e=>-1!==e.oid)),updates:r.filter((e=>-1!==e.oid)),deletes:i.filter((e=>-1!==e.oid))}}async function u(t,o){const r=t.i3sOverrides.layer.associatedLayer;if(null==r?.globalIdField)return;const i=r.createQuery(),{objectIdField:s,globalIdField:l}=r;i.where=Array.from(o.keys()).map((e=>`${l}='${e}'`)).join(" OR "),i.returnGeometry=!1,i.outFields=[s,l],i.cacheHint=!1;const a=await e(n(r,i));if(!a.ok)return;const u=a.value.features;for(const e of u){const t=e.attributes[l],n=e.attributes[s];if(null==t||null==n||-1===n)continue;const r=o.get(t);if(null!=r)for(const e of r)e.oid=n}}function d(e,t){const n=new Map,o=t.adds,r=t.updates,i=t.deletes;if(o.length>0)for(const s of o){const e=s.oid,t=s.feature;"mesh"===t?.geometry?.type&&n.set(e,t.geometry)}if(r.length>0)for(const s of r){const e=s.oid,t=s.feature;"mesh"===t?.geometry?.type&&n.set(e,t.geometry)}if(i.length>0)for(const s of i)n.set(s.oid,null);for(const[s,l]of n)e.i3sOverrides.updateGeometry(s,l)}function f(e,t){const n=I(e,t),o=c(e,t);if(0===n.size&&0===o.size)return;const r=new Map;for(let c=0;c<e.attributeStorageInfo.length;c++)r.set(e.attributeStorageInfo[c].name,c);let i=!1;n.forEach(((t,n)=>{const o=e.getAttributeData(n);let s=!1;t.forEach(((t,n)=>{const l=null!=o?o[n]:null,a=r.get(n);for(const{featureIndex:o,value:r,featureId:u}of t)l&&(l[o]=r,s=!0,i=!0),e.i3sOverrides.updateAttributeValue(u,a,r)})),s&&e.setAttributeData(n,o,null)})),i&&e.clearMemCache();const{fieldsIndex:s,i3sOverrides:l,objectIdField:a,globalIdField:u}=e,d=l.layer.associatedLayer?.infoFor3D,f=new Set(d?[...Object.values(d.assetMapFieldRoles),...Object.values(d.transformFieldRoles)]:[]);for(const[c,I]of o){l.featureAdded(c);const{attributes:e}=I;for(const t in e){if(t!==a&&t!==u&&f.has(t))continue;const n=s.normalizeFieldName(t),o=null!=n?r.get(n):null;if(null==o)continue;const i=e[t];l.updateAttributeValue(c,o,i)}}}function c(e,t){const n=new Map,o=t.adds;if(!o||0===o.length||null==e.globalIdField)return n;for(const r of o){const e=r.oid,t=r.feature;"mesh"===t?.geometry?.type&&n.set(e,t)}return n}function I(e,t){const n=t.updates;if(!n||0===n.length)return new p;const o=new p,r=new Map;for(let i=0;i<e.attributeStorageInfo.length;i++)r.set(e.attributeStorageInfo[i].name,i);return e.forEachNode(((t,r)=>{for(const i of n){if(null==i.feature)continue;const n=i.feature,s=i.oid,l=r.indexOf(s);for(const r in n.attributes){const i=e.fieldsIndex.normalizeFieldName(r),a=g(o,t.index,i),u=n.attributes[r];a.push({featureIndex:l,featureId:s,value:u})}}})),o}function g(e,t,n){const o=b(e,t),r=null!=n&&o.get(n);if(r)return r;const i=new Array;return o.set(n,i),i}function b(e,t){const n=e.get(t);if(n)return n;const o=new m;return e.set(t,o),o}!function(e){e[e.EDITING=0]="EDITING",e[e.ROLLED_BACK=1]="ROLLED_BACK",e[e.COMMITTED=2]="COMMITTED"}(r||(r={}));const m=Map,p=Map;export{i as createInteractiveEditSession,a as normalizeEditResultsEvent,f as processAttributeEdits,d as processGeometryEdits};
5
+ import{resultOrAbort as e}from"../../../../core/asyncUtils.js";import{clone as t}from"../../../../core/lang.js";import{queryAllJSON as n}from"../../../../layers/support/featureQueryAll.js";const o={setAttribute(){},rollback(){},commit(){}};var r;function i(e,n){const i=n.attributes[e.objectIdField];if(null==i)return o;const s=e.sessions.get(i);if(s)return s;const l=t(n.attributes),u=new Set,a=e.i3sOverrides.createInteractiveEditSession(i),d=new Map,f=(e,t)=>{const n=d.get(e);if(null==n){const n=t.indexOf(i);return d.set(e,n),n}return n};let c=r.EDITING;const g={setAttribute(t,o){if(c!==r.EDITING)return;const i=e.fieldsIndex.get(t);if(!i)return;const s=e.attributeStorageInfo.findIndex((e=>e.name===i.name));if(s<0)return;if(!(t in l))throw new Error(`Attribute "${t}" is not an attribute of the edited feature.`);a.setAttribute(s,o);const d=e.attributeStorageInfo[s];let g=!1;u.add(t),e.forEachNode(((t,r)=>{const i=f(t,r);if(-1===i)return;const s=e.getAttributeData(t.index);if(s){const r=s[d.name];r&&(r[i]=o,e.setAttributeData(t.index,s,n),g=!0)}})),g&&e.clearMemCache()},rollback(){if(c===r.EDITING){for(const e of u)this.setAttribute(e,l[e]);a.remove(),c=r.ROLLED_BACK,e.sessions.delete(i)}},commit(){c===r.EDITING&&(a.remove(),c=r.COMMITTED,e.sessions.delete(i))}};return e.sessions.set(i,g),g}function s(e,t,n){const{gidToFeatureInfo:o,oidToFeatureInfo:r,fieldsIndex:i,objectIdField:s,globalIdField:l,featureOrIdentifierList:u}=n;if(!n.featuresResolved&&null!=u){for(const e of u){const t={feature:null,oid:-1,gid:null};if("attributes"in e){t.feature=e;const n=e.attributes;if(null!=n)for(const e in n){if(-1!==t.oid&&null!=t.gid)break;const o=i.normalizeFieldName(e);o===s&&(t.oid=n[e]??-1),o===l&&(t.gid=n[e])}}else t.oid=e.objectId??-1,t.gid=e.globalId;null!=t.gid&&o.set(t.gid,t),-1!==t.oid&&r.set(t.oid,t)}n.featuresResolved=!0}return(-1!==e?r.get(e):null)??(null!=t?o.get(t):null)}function l(e,t,n,o,r=null,i=!0){const l=[],u={gidToFeatureInfo:new Map,oidToFeatureInfo:new Map,featuresResolved:null==n,fieldsIndex:e.fieldsIndex,objectIdField:e.objectIdField,globalIdField:e.globalIdField,featureOrIdentifierList:n};for(const a of t){if(null!=a.error)continue;const e=a.objectId??-1,t=a.globalId,n=(-1===e||i?s(e,t,u):null)??{feature:null,oid:e,gid:t},d={oid:-1===e?n.oid:e,gid:t??n.gid,feature:n.feature,result:a};if(l.push(d),-1===d.oid&&null!=d.gid&&null!=r&&(d.oid=r.get(d.gid)??-1),-1===d.oid&&null!=d.gid){let e=o.get(d.gid);null==e&&(e=[],o.set(d.gid,e)),e.push(d)}}return l}async function u(e,t){const n=new Map,o=l(e,t.addedFeatures,t.edits?.addFeatures,n),r=l(e,t.updatedFeatures,t.edits?.updateFeatures,n),i=l(e,t.deletedFeatures,t.edits?.deleteFeatures,n,t.globalIdToObjectId,!1);return n.size>0&&await a(e,n),{adds:o.filter((e=>-1!==e.oid)),updates:r.filter((e=>-1!==e.oid)),deletes:i.filter((e=>-1!==e.oid))}}async function a(t,o){const r=t.i3sOverrides.layer.associatedLayer;if(null==r?.globalIdField)return;const i=r.createQuery(),{objectIdField:s,globalIdField:l}=r;i.where=Array.from(o.keys()).map((e=>`${l}='${e}'`)).join(" OR "),i.returnGeometry=!1,i.outFields=[s,l],i.cacheHint=!1;const u=await e(n(r,i));if(!u.ok)return;const a=u.value.features;for(const e of a){const t=e.attributes[l],n=e.attributes[s];if(null==t||null==n||-1===n)continue;const r=o.get(t);if(null!=r)for(const e of r)e.oid=n}}function d(e,t){const n=new Map,o=t.adds,r=t.updates,i=t.deletes;if(o.length>0)for(const s of o){const e=s.oid,t=s.feature;"mesh"===t?.geometry?.type&&n.set(e,t.geometry)}if(r.length>0)for(const s of r){const e=s.oid,t=s.feature;"mesh"===t?.geometry?.type&&n.set(e,t.geometry)}if(i.length>0)for(const s of i)n.set(s.oid,null);for(const[s,l]of n)e.i3sOverrides.updateGeometry(s,l)}function f(e,t){const n=g(e,t),o=c(e,t);if(0===n.size&&0===o.size)return;const r=new Map;for(let c=0;c<e.attributeStorageInfo.length;c++)r.set(e.attributeStorageInfo[c].name,c);let i=!1;n.forEach(((t,n)=>{const o=e.getAttributeData(n);let s=!1;t.forEach(((t,n)=>{const l=null!=o?o[n]:null,u=r.get(n);for(const{featureIndex:o,value:r,featureId:a}of t)l&&(l[o]=r,s=!0,i=!0),e.i3sOverrides.updateAttributeValue(a,u,r)})),s&&e.setAttributeData(n,o,null)})),i&&e.clearMemCache();const{fieldsIndex:s,i3sOverrides:l,objectIdField:u,globalIdField:a}=e,d=l.layer.associatedLayer?.infoFor3D,f=new Set(d?[...Object.values(d.assetMapFieldRoles),...Object.values(d.transformFieldRoles)]:[]);for(const[c,g]of o){l.featureAdded(c);const{attributes:e}=g;for(const t in e){if(t!==u&&t!==a&&f.has(t))continue;const n=s.normalizeFieldName(t),o=null!=n?r.get(n):null;if(null==o)continue;const i=e[t];l.updateAttributeValue(c,o,i)}}}function c(e,t){const n=new Map,o=t.adds;if(!o||0===o.length||null==e.globalIdField)return n;for(const r of o){const e=r.oid,t=r.feature;"mesh"===t?.geometry?.type&&n.set(e,t)}return n}function g(e,t){const n=t.updates;if(!n||0===n.length)return new p;const o=new p,r=new Map;for(let i=0;i<e.attributeStorageInfo.length;i++)r.set(e.attributeStorageInfo[i].name,i);return e.forEachNode(((t,r)=>{for(const i of n){if(null==i.feature)continue;const n=i.feature,s=i.oid,l=r.indexOf(s);for(const r in n.attributes){const i=e.fieldsIndex.normalizeFieldName(r),u=I(o,t.index,i),a=n.attributes[r];u.push({featureIndex:l,featureId:s,value:a})}}})),o}function I(e,t,n){const o=b(e,t),r=null!=n&&o.get(n);if(r)return r;const i=new Array;return o.set(n,i),i}function b(e,t){const n=e.get(t);if(n)return n;const o=new m;return e.set(t,o),o}!function(e){e[e.EDITING=0]="EDITING",e[e.ROLLED_BACK=1]="ROLLED_BACK",e[e.COMMITTED=2]="COMMITTED"}(r||(r={}));const m=Map,p=Map;export{i as createInteractiveEditSession,u as normalizeEditResultsEvent,f as processAttributeEdits,d as processGeometryEdits};
@@ -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{equals as r,binaryIndexOf as s}from"../../../../../core/arrayUtils.js";import n from"../../../../../core/Logger.js";import{clamp as o}from"../../../../../core/mathUtils.js";import{disposeMaybe as i,destroyMaybe as a}from"../../../../../core/maybe.js";import{property as c}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/accessorSupport/ensureType.js";import"../../../../../core/has.js";import{subclass as l}from"../../../../../core/accessorSupport/decorators/subclass.js";import{f as d,t as u,d as h}from"../../../../../chunks/mat3.js";import{a as m}from"../../../../../chunks/mat3f64.js";import{a as g}from"../../../../../chunks/mat4f64.js";import{h as p,s as f,c as _,u as b,j as y}from"../../../../../chunks/vec3.js";import{c as j}from"../../../../../chunks/vec3f64.js";import{UpdatingHandles as O}from"../../../../../core/support/UpdatingHandles.js";import{g as w,a as E}from"../../../../../chunks/sphere.js";import{c as v}from"../../../../../chunks/vec33.js";import{ViewingMode as R}from"../../../../ViewingMode.js";import{encodeElevationOffset as x}from"../../collections/Component/Material/shader/ComponentData.glsl.js";import{TwoVectorPosition as T}from"../../core/util/TwoVectorPosition.js";import{Attribute as M}from"../Attribute.js";import{GridLocalOriginFactory as C}from"../GridLocalOriginFactory.js";import{applyToModelMatrix as D}from"../localOriginHelper.js";import{LocalOriginManager as P}from"../LocalOriginManager.js";import{Object3D as S}from"../Object3D.js";import{VertexArrayObject as A}from"../VertexArrayObject.js";import{VertexAttribute as U}from"../VertexAttribute.js";import{VertexLayout as B,EdgeInputBufferLayout as L,EdgeShaderAttributeLocations as k,glVertexLayout as I}from"./bufferLayouts.js";import{RegularEdgeBufferWriter as H,SilhouetteEdgeBufferWriter as V}from"./edgeBufferWriters.js";import{EdgeType as N}from"./edgePreprocessing.js";import{EdgeRenderer as G,lineWidthFractionFactor as W,extensionLengthOffset as q}from"./EdgeRenderer.js";import{EdgePassParameters as z}from"./EdgeShaderParameters.js";import{EdgeWorkerHandle as K}from"./EdgeWorkerHandle.js";import{Transparency as F}from"./interfaces.js";import{generateStrokesTexture as Q}from"./strokes.js";import{determineRendererType as J,determineEdgeTransparency as X,determineObjectTransparency as Y,fillComponenBufferIndices as Z}from"./util.js";import{BufferManager as $}from"../TextureBackedBuffer/BufferManager.js";import{EdgeSilhouette as ee}from"../../shaders/sources/edgeRenderer/EdgeUtil.glsl.js";import{BufferObject as te}from"../../../../webgl/BufferObject.js";import{Usage as re}from"../../../../webgl/enums.js";let se=class extends t{constructor(e){super(e),this._updatingHandles=new O,this._perObjectData=new Map,this._perObjectDataEvictionCache=new Set,this._renderers=new Map,this._gpuMemoryUsage=0,this._workerAbort=new AbortController,this._tmpModelPosition=j(),this._localOrigins=new P(new C(e.renderSR))}initialize(){this._worker=new K(this.schedule),this._componentColorManager=new $(this.rctx,3);const e=B.createBuffer(4);for(let t=0;t<4;t++)e.sideness.set(t,0,0===t||3===t?0:1),e.sideness.set(t,1,0===t||1===t?0:1);this._verticesBufferObject=te.createVertex(this.rctx,re.STATIC_DRAW,e.buffer)}destroy(){this.destroyed||(this._perObjectData.forEach((e=>this._discardObjectEntry(e))),this._perObjectData.clear(),this._strokesTexture=i(this._strokesTexture),this._componentColorManager=a(this._componentColorManager),this._workerAbort.abort(),this._worker.destroy(),this._verticesBufferObject=i(this._verticesBufferObject),this._renderers.clear(),this._updatingHandles.destroy(),this._set("schedule",be))}get updating(){return this._updatingHandles.updating}get usedMemory(){return this._gpuMemoryUsage}shouldRender(){return this._renderers.size>0}async addComponentObject(e,t,r,s,n,o,i,a){if(this.hasObject(e))return this.getObjectMemoryUsage(e);let c;const l=new ie(new Promise((e=>c=e)),r.center,r.radius);this._perObjectData.set(e,l);const d=await this._updatingHandles.addPromise(this._addComponentGeometry(t,l,s,n,o,i,a));return this.setNeedsRender(),c(),d}async addOrUpdateObject3D(e,t,r,s){if(this.destroyed)return void n.getLogger(this).warn("Attempt to add an object to a destroyed instance");const o=this._perObjectData.get(e);let i;o?.renderables.length>0&&this._perObjectDataEvictionCache.add(o);const a=e.boundingVolumeWorldSpace.bounds,c=new ie(new Promise((e=>i=e)),w(a),E(a));this._perObjectData.set(e,c);const l=new Array;if(r.mergeGeometries&&e.geometries.length>1&&oe(e))l.push(this._addObjectMergedGeometries(e,c,t,r,s));else for(let n=0;n<e.geometries.length;n++){const o=e.geometries[n];o.material.supportsEdges&&l.push(this._addGeometry(e,c,o,t[0],r,s))}await this._updatingHandles.addPromise(Promise.all(l)),this._perObjectDataEvictionCache.delete(c),this._discardObjectEntry(o),this.setNeedsRender(),i()}fastUpdateObject3DEdgesTransform(e){if(this.destroyed)return!1;const t=this._perObjectData.get(e);if(!t)return!1;const{geometries:r}=e,{renderables:s}=t;if(0===r.length||0===s.length)return!0;if(s.length>1)return!1;const[n]=s,o=n.transform;if(!(o instanceof le))return!1;const[i]=r,a=o.origin.origin.vec3,c=i.localOrigin?.vec3;if(null==c||!p(a,c))return!1;const l=g(),d=this._computeModelTransformWithLocalOrigin(e,i,l);return n.transform=new le(l,d),this.setNeedsRender(),!0}_discardObjectEntry(e){e&&(e.renderables.length&&(e.renderables.forEach((e=>this._removeRenderable(e))),this.setNeedsRender()),e.loaded=null)}hasObject(e){return this._perObjectData.has(e)}async updateAllComponentOpacities(e,t){const r=await this._updatingHandles.addPromise(this._getObjectEntry(e));if(null==r)return;const s=t instanceof Array?e=>t[e]:()=>t;r.renderables.forEach((e=>{const t=e.components.meta.length;for(let r=0;r<t;r++){const t=s(r),n=e.components.meta[r],o=n.index;n.material.opacity=t,e.components.buffer.textureBuffer.setDataElement(o,1,3,255*t)}this._updateTransparency(e)})),this.setNeedsRender()}async getObjectMemoryUsage(e){const t=await this._getObjectEntry(e);return null!=t?t.renderables.reduce(((e,t)=>e+t.statistics.gpuMemoryUsage),0):0}async updateAllComponentMaterials(e,t,r,s){const n=e instanceof S,o=!!r.hasSlicePlane,i=J(t),a=G.getKey(i,o,n),c=await this._updatingHandles.addPromise(this._getObjectEntry(e));null!=c&&(c.renderables.forEach((e=>{if(a!==e.rendererKey){const t=this._renderers.get(e.rendererKey),r=this._acquireRenderer(i,o,n);t.removeRenderable(e),--t.refCount,e.rendererKey=a,r.addRenderable(e)}for(let r=0;r<t.length;r++)e.components.meta[r].material=t[r];s&&this._updateComponentBuffer(e.components),this._updateTransparency(e)})),this.setNeedsRender())}async updateAllVerticalOffsets(e,t){const r=await this._updatingHandles.addPromise(this._getObjectEntry(e));null!=r&&(r.renderables.forEach((e=>{const r=e.components.meta;for(let s=0;s<r.length;s++)e.components.meta[s].verticalOffset=t?.[s]??0;this._updateComponentBuffer(e.components)})),this.setNeedsRender())}async updateObjectVisibility(e,t){const r=await this._updatingHandles.addPromise(this._getObjectEntry(e));null!=r&&(r.renderables.forEach((e=>e.visible=t)),this.setNeedsRender())}removeObject(e){const t=this._perObjectData.get(e);t&&(this._perObjectData.delete(e),this._discardObjectEntry(t))}async _getObjectEntry(e){const t=this._perObjectData.get(e);if(!t)throw new Error("no object");return await t.loaded,null==t.loaded?null:t}render(e,t){if(null==this._componentColorManager)return;this._localOrigins.updateViewMatrices(e.camera.viewMatrix);const r=e.camera.viewInverseTransposeMatrix,s=j(),n=new T;let o=0,i=0;if(this._renderers.forEach((r=>{if(0===r.refCount)this._renderers.delete(r.key),r.dispose();else{let s=!0,n=!0;r.forEachRenderable((t=>{t.visible&&(o+=t.statistics.averageEdgeLength,i++,s&&t.regular&&(r.updateTechnique(e,!1),s=!1),n&&t.silhouette&&(r.updateTechnique(e,!0),n=!1))}),t)}})),this._componentColorManager.garbageCollect(),this._componentColorManager.updateTextures(),0===i)return;const a=new z(40*o/i,t);f(s,r[3],r[7],r[11]),n.set(s),_(a.transformWorldFromViewTH,n.high),_(a.transformWorldFromViewTL,n.low),d(a.transformViewFromCameraRelativeRS,e.camera.viewMatrix),u(_e,a.transformViewFromCameraRelativeRS),h(a.transformNormalViewFromGlobal,_e),a.transformProjFromView=e.camera.projectionMatrix,this._updateObjectCameraDistances(e),this._renderers.forEach((t=>{this._renderRegularEdges(t,e,a),this._renderSilhouetteEdges(t,e,a)}))}_updateTransparency(e){const t=X(e.components.meta),r=Y(e.components.meta);t===e.edgeTransparency&&r===e.objectTransparency||(e.edgeTransparency=t,e.objectTransparency=r,this._renderers.get(e.rendererKey).setRenderablesDirty())}_computeModelTransformWithLocalOrigin(e,t,r){e.getCombinedShaderTransformation(t,r);const s=null!=t.localOrigin?this._localOrigins.register(t.localOrigin):this._localOrigins.acquire(f(this._tmpModelPosition,r[12],r[13],r[14]));return t.localOrigin=s.origin,D(s.origin.vec3,r),s}_updateComponentBuffer(e){const{meta:t,buffer:r}=e,s=new Uint8Array(4);for(let n=0;n<t.length;n++){const e=t[n].material,i=t[n].index,a=o(Math.round(e.size*W),0,255),c=o(e.extensionLength,-q,255-q)+q,l="solid"===e.type?N.SOLID:N.SKETCH,d=255*e.opacity,u=e.color,h=255*u[0],m=255*u[1],g=255*u[2],p=255*u[3];r.textureBuffer.setData(i,0,h,m,g,p),r.textureBuffer.setData(i,1,a,c,l,d),x(t[n].verticalOffset,s),r.textureBuffer.setData(i,2,s[0],s[1],s[2],s[3])}}_createComponentBuffers(e){if(null==this._componentColorManager)return null;const t=new Array,r=this._componentColorManager.getBuffer(e.length);for(let n=0;n<e.length;n++){const s=e[n],o=r.acquireIndex();t.push({index:o,verticalOffset:0,material:s})}const s=new ae(r,t);return this._updateComponentBuffer(s),s}_extractEdges(e,t,r,s,n,o=n.length){return this._worker.process({data:t,indices:n,indicesLength:o,writerSettings:e,skipDeduplicate:r},this._workerAbort.signal,s)}_createRenderable(e,t,r,s,n){const o=t=>null!=this._verticesBufferObject?new ce(new A(this.rctx,k,{vertices:I,instances:t===ee.REGULAR?H.glLayout:V.glLayout},{vertices:this._verticesBufferObject,instances:te.createVertex(this.rctx,re.STATIC_DRAW,t===ee.REGULAR?e.regular.instancesData.buffer:e.silhouette.instancesData.buffer)}),t===ee.REGULAR?e.regular.lodInfo:e.silhouette.lodInfo):null,i=e.regular.lodInfo.lengths.length>0?o(ee.REGULAR):null,a=e.silhouette.lodInfo.lengths.length>0?o(ee.SILHOUETTE):null,c=(i?.vao.memoryUsage??0)+(a?.vao.memoryUsage??0);return new de(i,a,{gpuMemoryUsage:c,externalMemoryUsage:n,averageEdgeLength:e.averageEdgeLength},r,X(t.meta),Y(t.meta),t,s)}async _addGeometry(e,t,r,s,n,o){if(r.edgeIndicesLength<=0)return;const i=r.attributes.get(U.POSITION),a=g(),c=this._computeModelTransformWithLocalOrigin(e,r,a),l=new fe(i,a,c);return this._addPositionData(t,l,r.edgeIndicesLength,s,n,o)}async _addPositionData(e,t,r,s,n,o=!1){if(null==e.loaded)return;const i=this._createComponentBuffers([s]);if(null==i)return;const a=this._acquireRenderer(s.type,!!n.hasSlicePlane,!0),{modelTransform:c,origin:l}=t,d=t.position.indices,u=t.position,h=u.data.length/u.size,m=L.createBuffer(h);for(let f=0;f<h;f++)m.position.set(f,0,u.data[f*u.size]),m.position.set(f,1,u.data[f*u.size+1]),m.position.set(f,2,u.data[f*u.size+2]);Z(i.meta,[0,m.componentIndex.count],m.componentIndex);const g=await this._updatingHandles.addPromise(this._extractEdges(a.writerSettings,m,!1,o,d,r));if(null==e.loaded)return;const p=this._createRenderable(g,i,new le(c,l),a.key,!1);e.renderables.push(p),a.addRenderable(p),this._gpuMemoryUsage+=p.statistics.gpuMemoryUsage}async _addComponentGeometry(e,t,r,s,n,o,i){if(null==t.loaded)return 0;const a=this._createComponentBuffers(o);if(null==a)return 0;const c=J(o),l=this._acquireRenderer(c,i.hasSlicePlane||!1,!1),d=L.createBuffer(r.length/3);v(d.position.typedBuffer,r,d.position.typedBufferStride,3),Z(a.meta,n,d.componentIndex,s);const u=!0,h=l.writerSettings,m=await this._updatingHandles.addPromise(this._extractEdges(h,d,u,!1,s));if(null==t.loaded)return 0;const g=this._createRenderable(m,a,e,l.key,!0);return t.renderables.push(g),l.addRenderable(g),g.statistics.gpuMemoryUsage}async _addObjectMergedGeometries(e,t,r,s,n){const o=new Map;let i=0,a=null,c=0;const l=e.geometries.filter((e=>{if(e.edgeIndicesLength<=0||!e.material.supportsEdges)return!1;!a&&e.localOrigin&&(a=e);const t=e.attributes.get(U.POSITION);return c+=t.data.length/t.size,i+=e.edgeIndicesLength,!0}));if(0===l.length)return;const d=c>=65536?Uint32Array:Uint16Array,u=i?new d(i):null,h=[];let m=0;l.forEach((e=>{const t=e.attributes.get(U.POSITION),r=t.indices;let s=o.get(t.data);if(null==s){s=h.length/3;for(let e=0;e<t.data.length;e+=t.size)h.push(t.data[e]),h.push(t.data[e+1]),h.push(t.data[e+2]);o.set(t.data,s)}for(let n=0;n<e.edgeIndicesLength;n++)u[m++]=s+r[n]}));const p=a||e.geometries[0],f=g(),_=this._computeModelTransformWithLocalOrigin(e,p,f);for(let g=0;g<e.geometries.length;g++)e.geometries[g].localOrigin=_.origin;const b=new fe(new M(h,u,3),f,_);await this._updatingHandles.addPromise(this._addPositionData(t,b,u.length,r[0],s,n))}_acquireRenderer(e,t,r){const s=G.getKey(e,t,r);let n=this._renderers.get(s);return null==this._strokesTexture&&(this._strokesTexture=Q(this.rctx)),n||(n=new G(this.rctx,this.techniqueRepository,{type:e,hasSlicePlane:t,strokesTexture:this._strokesTexture,legacy:r,spherical:this.viewingMode===R.Global}),this._renderers.set(s,n)),++n.refCount,n}_removeRenderable(e){ne(e.regular),ne(e.silhouette);const t=this._renderers.get(e.rendererKey);if(t){t.removeRenderable(e),--t.refCount,"origin"in e.transform&&this._localOrigins.release(e.transform.origin),this._gpuMemoryUsage-=e.statistics.externalMemoryUsage?0:e.statistics.gpuMemoryUsage;for(const t of e.components.meta)e.components.buffer.releaseIndex(t.index)}}_updateObjectCameraDistances(e){const t=e.camera.eye,r=e.camera.viewForward,s=j(),n=e=>{b(s,e.center,t);const n=y(s,r),o=e.radius,i=n<-o?1/0:n<o?0:n-o;e.renderables.forEach((e=>e.distanceToCamera=i))};this._perObjectData.forEach(n),this._perObjectDataEvictionCache.forEach(n)}_renderRegularEdges(e,t,r){const s=e.bindRegularEdges(r,t),n=r.transparency,o=t.camera.perScreenPixelRatio;e.forEachRenderable((n=>{if(!he(n)||!n.visible)return;const i=pe(n.regular.lod.lengths,n.distanceToCamera,o);e.renderRegularEdges(s,n,r,t,i)}),n)}_renderSilhouetteEdges(e,t,r){const s=e.bindSilhouetteEdges(r,t),n=r.transparency,o=t.camera.perScreenPixelRatio;e.forEachRenderable((n=>{if(!ge(n)||!n.visible)return;const i=pe(n.silhouette.lod.lengths,n.distanceToCamera,o);e.renderSilhouetteEdges(s,n,r,t,i)}),n)}get test(){return{hasRenderedPrimitives:e=>{let t=!1;const r=e.perScreenPixelRatio,s=(e,s)=>e.forEachRenderable((e=>{e.visible&&!t&&(he(e)&&(t=pe(e.regular.lod.lengths,e.distanceToCamera,r)>0),!t&&ge(e)&&(t=pe(e.silhouette.lod.lengths,e.distanceToCamera,r)>0))}),s);return this._renderers.forEach((e=>{t||(s(e,F.OPAQUE),s(e,F.TRANSPARENT))})),t},getObjectData:e=>this._perObjectData.get(e)}}};function ne(e){null!=e&&(e.vao.vertexBuffers.instances.dispose(),e.vao.disposeVAOOnly(),e.vao=null)}function oe(e){let t=null,s=null;for(let n=0;n<e.geometries.length;n++){const o=e.geometries[n];if(o.material.supportsEdges){if(t){if(!r(t,o.transformation))return!1}else t=o.transformation;if(s||null==o.localOrigin){if(null!=s?.localOrigin&&null!=o.localOrigin&&s.localOrigin.id!==o.localOrigin.id)return!1}else s=o}}return!0}e([c({constructOnly:!0})],se.prototype,"rctx",void 0),e([c({constructOnly:!0})],se.prototype,"renderSR",void 0),e([c({constructOnly:!0})],se.prototype,"viewingMode",void 0),e([c({constructOnly:!0})],se.prototype,"techniqueRepository",void 0),e([c({constructOnly:!0})],se.prototype,"setNeedsRender",void 0),e([c({constructOnly:!0})],se.prototype,"schedule",void 0),e([c({readOnly:!0})],se.prototype,"_updatingHandles",void 0),e([c({readOnly:!0})],se.prototype,"updating",null),se=e([l("esri.views.3d.webgl-engine.lib.edgeRendering.EdgeView")],se);class ie{constructor(e,t,r){this.center=t,this.radius=r,this.renderables=new Array,this.loaded=e,this.loaded.then((()=>{null!=this.loaded&&(this.loaded=!0)}))}}class ae{constructor(e,t){this.buffer=e,this.meta=t}}class ce{constructor(e,t){this.vao=e,this.lod=t}}class le{constructor(e,t){this.modelMatrix=e,this.origin=t}}class de{constructor(e,t,r,s,n,o,i,a){this.regular=e,this.silhouette=t,this.statistics=r,this.transform=s,this.edgeTransparency=n,this.objectTransparency=o,this.components=i,this.rendererKey=a,this.distanceToCamera=0,this.visible=!0}}class ue extends de{}function he(e){return null!=e.regular}class me extends de{}function ge(e){return null!=e.silhouette}function pe(e,t,r){const n=t*r,o=s(e,n,!0);return-1===o?n<e[0]?e.length:0:e.length-o}class fe{constructor(e,t,r){this.position=e,this.modelTransform=t,this.origin=r}}const _e=m(),be=()=>Promise.reject();export{se as EdgeView,le as LegacyTransform,ue as RegularRenderable,de as Renderable,me as SilhouetteRenderable};
5
+ import{_ as e}from"../../../../../chunks/tslib.es6.js";import t from"../../../../../core/Accessor.js";import{equals as r,binaryIndexOf as s}from"../../../../../core/arrayUtils.js";import n from"../../../../../core/Logger.js";import{clamp as o}from"../../../../../core/mathUtils.js";import{disposeMaybe as i,destroyMaybe as a}from"../../../../../core/maybe.js";import{property as c}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/accessorSupport/ensureType.js";import"../../../../../core/has.js";import{subclass as l}from"../../../../../core/accessorSupport/decorators/subclass.js";import{f as d,t as u,d as h}from"../../../../../chunks/mat3.js";import{a as m}from"../../../../../chunks/mat3f64.js";import{a as g}from"../../../../../chunks/mat4f64.js";import{s as p,c as f,u as _,j as b}from"../../../../../chunks/vec3.js";import{c as y}from"../../../../../chunks/vec3f64.js";import{UpdatingHandles as j}from"../../../../../core/support/UpdatingHandles.js";import{g as O,a as w}from"../../../../../chunks/sphere.js";import{c as E}from"../../../../../chunks/vec33.js";import{ViewingMode as R}from"../../../../ViewingMode.js";import{encodeElevationOffset as v}from"../../collections/Component/Material/shader/ComponentData.glsl.js";import{TwoVectorPosition as x}from"../../core/util/TwoVectorPosition.js";import{Attribute as T}from"../Attribute.js";import{GridLocalOriginFactory as M}from"../GridLocalOriginFactory.js";import{applyToModelMatrix as C}from"../localOriginHelper.js";import{LocalOriginManager as D}from"../LocalOriginManager.js";import{Object3D as P}from"../Object3D.js";import{VertexArrayObject as S}from"../VertexArrayObject.js";import{VertexAttribute as A}from"../VertexAttribute.js";import{VertexLayout as U,EdgeInputBufferLayout as B,EdgeShaderAttributeLocations as L,glVertexLayout as k}from"./bufferLayouts.js";import{RegularEdgeBufferWriter as I,SilhouetteEdgeBufferWriter as H}from"./edgeBufferWriters.js";import{EdgeType as V}from"./edgePreprocessing.js";import{EdgeRenderer as N,lineWidthFractionFactor as G,extensionLengthOffset as W}from"./EdgeRenderer.js";import{EdgePassParameters as q}from"./EdgeShaderParameters.js";import{EdgeWorkerHandle as z}from"./EdgeWorkerHandle.js";import{Transparency as K}from"./interfaces.js";import{generateStrokesTexture as F}from"./strokes.js";import{determineRendererType as Q,determineEdgeTransparency as J,determineObjectTransparency as X,fillComponenBufferIndices as Y}from"./util.js";import{BufferManager as Z}from"../TextureBackedBuffer/BufferManager.js";import{EdgeSilhouette as $}from"../../shaders/sources/edgeRenderer/EdgeUtil.glsl.js";import{BufferObject as ee}from"../../../../webgl/BufferObject.js";import{Usage as te}from"../../../../webgl/enums.js";let re=class extends t{constructor(e){super(e),this._updatingHandles=new j,this._perObjectData=new Map,this._perObjectDataEvictionCache=new Set,this._renderers=new Map,this._gpuMemoryUsage=0,this._workerAbort=new AbortController,this._tmpModelPosition=y(),this._localOrigins=new D(new M(e.renderSR))}initialize(){this._worker=new z(this.schedule),this._componentColorManager=new Z(this.rctx,3);const e=U.createBuffer(4);for(let t=0;t<4;t++)e.sideness.set(t,0,0===t||3===t?0:1),e.sideness.set(t,1,0===t||1===t?0:1);this._verticesBufferObject=ee.createVertex(this.rctx,te.STATIC_DRAW,e.buffer)}destroy(){this.destroyed||(this._perObjectData.forEach((e=>this._discardObjectEntry(e))),this._perObjectData.clear(),this._strokesTexture=i(this._strokesTexture),this._componentColorManager=a(this._componentColorManager),this._workerAbort.abort(),this._worker.destroy(),this._verticesBufferObject=i(this._verticesBufferObject),this._renderers.clear(),this._updatingHandles.destroy(),this._set("schedule",_e))}get updating(){return this._updatingHandles.updating}get usedMemory(){return this._gpuMemoryUsage}shouldRender(){return this._renderers.size>0}async addComponentObject(e,t,r,s,n,o,i,a){if(this.hasObject(e))return this.getObjectMemoryUsage(e);let c;const l=new oe(new Promise((e=>c=e)),r.center,r.radius);this._perObjectData.set(e,l);const d=await this._updatingHandles.addPromise(this._addComponentGeometry(t,l,s,n,o,i,a));return this.setNeedsRender(),c(),d}async addOrUpdateObject3D(e,t,r,s){if(this.destroyed)return void n.getLogger(this).warn("Attempt to add an object to a destroyed instance");const o=this._perObjectData.get(e);let i;o?.renderables.length>0&&this._perObjectDataEvictionCache.add(o);const a=e.boundingVolumeWorldSpace.bounds,c=new oe(new Promise((e=>i=e)),O(a),w(a));this._perObjectData.set(e,c);const l=new Array;if(r.mergeGeometries&&e.geometries.length>1&&ne(e))l.push(this._addObjectMergedGeometries(e,c,t,r,s));else for(let n=0;n<e.geometries.length;n++){const o=e.geometries[n];o.material.supportsEdges&&l.push(this._addGeometry(e,c,o,t[0],r,s))}await this._updatingHandles.addPromise(Promise.all(l)),this._perObjectDataEvictionCache.delete(c),this._discardObjectEntry(o),this.setNeedsRender(),i()}fastUpdateObject3DEdgesTransform(e){if(this.destroyed)return!1;const t=this._perObjectData.get(e);if(!t)return!1;const{geometries:r}=e,{renderables:s}=t;if(0===r.length||0===s.length)return!0;if(s.length>1)return!1;const[n]=s,o=n.transform;if(!(o instanceof ce))return!1;const[i]=r;if(i.localOrigin!==o.origin.origin)return!1;const a=g(),c=this._computeModelTransformWithLocalOrigin(e,i,a);return n.transform=new ce(a,c),this.setNeedsRender(),!0}_discardObjectEntry(e){e&&(e.renderables.length&&(e.renderables.forEach((e=>this._removeRenderable(e))),this.setNeedsRender()),e.loaded=null)}hasObject(e){return this._perObjectData.has(e)}async updateAllComponentOpacities(e,t){const r=await this._updatingHandles.addPromise(this._getObjectEntry(e));if(null==r)return;const s=t instanceof Array?e=>t[e]:()=>t;r.renderables.forEach((e=>{const t=e.components.meta.length;for(let r=0;r<t;r++){const t=s(r),n=e.components.meta[r],o=n.index;n.material.opacity=t,e.components.buffer.textureBuffer.setDataElement(o,1,3,255*t)}this._updateTransparency(e)})),this.setNeedsRender()}async getObjectMemoryUsage(e){const t=await this._getObjectEntry(e);return null!=t?t.renderables.reduce(((e,t)=>e+t.statistics.gpuMemoryUsage),0):0}async updateAllComponentMaterials(e,t,r,s){const n=e instanceof P,o=!!r.hasSlicePlane,i=Q(t),a=N.getKey(i,o,n),c=await this._updatingHandles.addPromise(this._getObjectEntry(e));null!=c&&(c.renderables.forEach((e=>{if(a!==e.rendererKey){const t=this._renderers.get(e.rendererKey),r=this._acquireRenderer(i,o,n);t.removeRenderable(e),--t.refCount,e.rendererKey=a,r.addRenderable(e)}for(let r=0;r<t.length;r++)e.components.meta[r].material=t[r];s&&this._updateComponentBuffer(e.components),this._updateTransparency(e)})),this.setNeedsRender())}async updateAllVerticalOffsets(e,t){const r=await this._updatingHandles.addPromise(this._getObjectEntry(e));null!=r&&(r.renderables.forEach((e=>{const r=e.components.meta;for(let s=0;s<r.length;s++)e.components.meta[s].verticalOffset=t?.[s]??0;this._updateComponentBuffer(e.components)})),this.setNeedsRender())}async updateObjectVisibility(e,t){const r=await this._updatingHandles.addPromise(this._getObjectEntry(e));null!=r&&(r.renderables.forEach((e=>e.visible=t)),this.setNeedsRender())}removeObject(e){const t=this._perObjectData.get(e);t&&(this._perObjectData.delete(e),this._discardObjectEntry(t))}async _getObjectEntry(e){const t=this._perObjectData.get(e);if(!t)throw new Error("no object");return await t.loaded,null==t.loaded?null:t}render(e,t){if(null==this._componentColorManager)return;this._localOrigins.updateViewMatrices(e.camera.viewMatrix);const r=e.camera.viewInverseTransposeMatrix,s=y(),n=new x;let o=0,i=0;if(this._renderers.forEach((r=>{if(0===r.refCount)this._renderers.delete(r.key),r.dispose();else{let s=!0,n=!0;r.forEachRenderable((t=>{t.visible&&(o+=t.statistics.averageEdgeLength,i++,s&&t.regular&&(r.updateTechnique(e,!1),s=!1),n&&t.silhouette&&(r.updateTechnique(e,!0),n=!1))}),t)}})),this._componentColorManager.garbageCollect(),this._componentColorManager.updateTextures(),0===i)return;const a=new q(40*o/i,t);p(s,r[3],r[7],r[11]),n.set(s),f(a.transformWorldFromViewTH,n.high),f(a.transformWorldFromViewTL,n.low),d(a.transformViewFromCameraRelativeRS,e.camera.viewMatrix),u(fe,a.transformViewFromCameraRelativeRS),h(a.transformNormalViewFromGlobal,fe),a.transformProjFromView=e.camera.projectionMatrix,this._updateObjectCameraDistances(e),this._renderers.forEach((t=>{this._renderRegularEdges(t,e,a),this._renderSilhouetteEdges(t,e,a)}))}_updateTransparency(e){const t=J(e.components.meta),r=X(e.components.meta);t===e.edgeTransparency&&r===e.objectTransparency||(e.edgeTransparency=t,e.objectTransparency=r,this._renderers.get(e.rendererKey).setRenderablesDirty())}_computeModelTransformWithLocalOrigin(e,t,r){e.getCombinedShaderTransformation(t,r);const s=null!=t.localOrigin?this._localOrigins.register(t.localOrigin):this._localOrigins.acquire(p(this._tmpModelPosition,r[12],r[13],r[14]));return t.localOrigin=s.origin,C(s.origin.vec3,r),s}_updateComponentBuffer(e){const{meta:t,buffer:r}=e,s=new Uint8Array(4);for(let n=0;n<t.length;n++){const e=t[n].material,i=t[n].index,a=o(Math.round(e.size*G),0,255),c=o(e.extensionLength,-W,255-W)+W,l="solid"===e.type?V.SOLID:V.SKETCH,d=255*e.opacity,u=e.color,h=255*u[0],m=255*u[1],g=255*u[2],p=255*u[3];r.textureBuffer.setData(i,0,h,m,g,p),r.textureBuffer.setData(i,1,a,c,l,d),v(t[n].verticalOffset,s),r.textureBuffer.setData(i,2,s[0],s[1],s[2],s[3])}}_createComponentBuffers(e){if(null==this._componentColorManager)return null;const t=new Array,r=this._componentColorManager.getBuffer(e.length);for(let n=0;n<e.length;n++){const s=e[n],o=r.acquireIndex();t.push({index:o,verticalOffset:0,material:s})}const s=new ie(r,t);return this._updateComponentBuffer(s),s}_extractEdges(e,t,r,s,n,o=n.length){return this._worker.process({data:t,indices:n,indicesLength:o,writerSettings:e,skipDeduplicate:r},this._workerAbort.signal,s)}_createRenderable(e,t,r,s,n){const o=t=>null!=this._verticesBufferObject?new ae(new S(this.rctx,L,{vertices:k,instances:t===$.REGULAR?I.glLayout:H.glLayout},{vertices:this._verticesBufferObject,instances:ee.createVertex(this.rctx,te.STATIC_DRAW,t===$.REGULAR?e.regular.instancesData.buffer:e.silhouette.instancesData.buffer)}),t===$.REGULAR?e.regular.lodInfo:e.silhouette.lodInfo):null,i=e.regular.lodInfo.lengths.length>0?o($.REGULAR):null,a=e.silhouette.lodInfo.lengths.length>0?o($.SILHOUETTE):null,c=(i?.vao.memoryUsage??0)+(a?.vao.memoryUsage??0);return new le(i,a,{gpuMemoryUsage:c,externalMemoryUsage:n,averageEdgeLength:e.averageEdgeLength},r,J(t.meta),X(t.meta),t,s)}async _addGeometry(e,t,r,s,n,o){if(r.edgeIndicesLength<=0)return;const i=r.attributes.get(A.POSITION),a=g(),c=this._computeModelTransformWithLocalOrigin(e,r,a),l=new pe(i,a,c);return this._addPositionData(t,l,r.edgeIndicesLength,s,n,o)}async _addPositionData(e,t,r,s,n,o=!1){if(null==e.loaded)return;const i=this._createComponentBuffers([s]);if(null==i)return;const a=this._acquireRenderer(s.type,!!n.hasSlicePlane,!0),{modelTransform:c,origin:l}=t,d=t.position.indices,u=t.position,h=u.data.length/u.size,m=B.createBuffer(h);for(let f=0;f<h;f++)m.position.set(f,0,u.data[f*u.size]),m.position.set(f,1,u.data[f*u.size+1]),m.position.set(f,2,u.data[f*u.size+2]);Y(i.meta,[0,m.componentIndex.count],m.componentIndex);const g=await this._updatingHandles.addPromise(this._extractEdges(a.writerSettings,m,!1,o,d,r));if(null==e.loaded)return;const p=this._createRenderable(g,i,new ce(c,l),a.key,!1);e.renderables.push(p),a.addRenderable(p),this._gpuMemoryUsage+=p.statistics.gpuMemoryUsage}async _addComponentGeometry(e,t,r,s,n,o,i){if(null==t.loaded)return 0;const a=this._createComponentBuffers(o);if(null==a)return 0;const c=Q(o),l=this._acquireRenderer(c,i.hasSlicePlane||!1,!1),d=B.createBuffer(r.length/3);E(d.position.typedBuffer,r,d.position.typedBufferStride,3),Y(a.meta,n,d.componentIndex,s);const u=!0,h=l.writerSettings,m=await this._updatingHandles.addPromise(this._extractEdges(h,d,u,!1,s));if(null==t.loaded)return 0;const g=this._createRenderable(m,a,e,l.key,!0);return t.renderables.push(g),l.addRenderable(g),g.statistics.gpuMemoryUsage}async _addObjectMergedGeometries(e,t,r,s,n){const o=new Map;let i=0,a=null,c=0;const l=e.geometries.filter((e=>{if(e.edgeIndicesLength<=0||!e.material.supportsEdges)return!1;!a&&e.localOrigin&&(a=e);const t=e.attributes.get(A.POSITION);return c+=t.data.length/t.size,i+=e.edgeIndicesLength,!0}));if(0===l.length)return;const d=c>=65536?Uint32Array:Uint16Array,u=i?new d(i):null,h=[];let m=0;l.forEach((e=>{const t=e.attributes.get(A.POSITION),r=t.indices;let s=o.get(t.data);if(null==s){s=h.length/3;for(let e=0;e<t.data.length;e+=t.size)h.push(t.data[e]),h.push(t.data[e+1]),h.push(t.data[e+2]);o.set(t.data,s)}for(let n=0;n<e.edgeIndicesLength;n++)u[m++]=s+r[n]}));const p=a||e.geometries[0],f=g(),_=this._computeModelTransformWithLocalOrigin(e,p,f);for(let g=0;g<e.geometries.length;g++)e.geometries[g].localOrigin=_.origin;const b=new pe(new T(h,u,3),f,_);await this._updatingHandles.addPromise(this._addPositionData(t,b,u.length,r[0],s,n))}_acquireRenderer(e,t,r){const s=N.getKey(e,t,r);let n=this._renderers.get(s);return null==this._strokesTexture&&(this._strokesTexture=F(this.rctx)),n||(n=new N(this.rctx,this.techniqueRepository,{type:e,hasSlicePlane:t,strokesTexture:this._strokesTexture,legacy:r,spherical:this.viewingMode===R.Global}),this._renderers.set(s,n)),++n.refCount,n}_removeRenderable(e){se(e.regular),se(e.silhouette);const t=this._renderers.get(e.rendererKey);if(t){t.removeRenderable(e),--t.refCount,"origin"in e.transform&&this._localOrigins.release(e.transform.origin),this._gpuMemoryUsage-=e.statistics.externalMemoryUsage?0:e.statistics.gpuMemoryUsage;for(const t of e.components.meta)e.components.buffer.releaseIndex(t.index)}}_updateObjectCameraDistances(e){const t=e.camera.eye,r=e.camera.viewForward,s=y(),n=e=>{_(s,e.center,t);const n=b(s,r),o=e.radius,i=n<-o?1/0:n<o?0:n-o;e.renderables.forEach((e=>e.distanceToCamera=i))};this._perObjectData.forEach(n),this._perObjectDataEvictionCache.forEach(n)}_renderRegularEdges(e,t,r){const s=e.bindRegularEdges(r,t),n=r.transparency,o=t.camera.perScreenPixelRatio;e.forEachRenderable((n=>{if(!ue(n)||!n.visible)return;const i=ge(n.regular.lod.lengths,n.distanceToCamera,o);e.renderRegularEdges(s,n,r,t,i)}),n)}_renderSilhouetteEdges(e,t,r){const s=e.bindSilhouetteEdges(r,t),n=r.transparency,o=t.camera.perScreenPixelRatio;e.forEachRenderable((n=>{if(!me(n)||!n.visible)return;const i=ge(n.silhouette.lod.lengths,n.distanceToCamera,o);e.renderSilhouetteEdges(s,n,r,t,i)}),n)}get test(){return{hasRenderedPrimitives:e=>{let t=!1;const r=e.perScreenPixelRatio,s=(e,s)=>e.forEachRenderable((e=>{e.visible&&!t&&(ue(e)&&(t=ge(e.regular.lod.lengths,e.distanceToCamera,r)>0),!t&&me(e)&&(t=ge(e.silhouette.lod.lengths,e.distanceToCamera,r)>0))}),s);return this._renderers.forEach((e=>{t||(s(e,K.OPAQUE),s(e,K.TRANSPARENT))})),t},getObjectData:e=>this._perObjectData.get(e)}}};function se(e){null!=e&&(e.vao.vertexBuffers.instances.dispose(),e.vao.disposeVAOOnly(),e.vao=null)}function ne(e){let t=null,s=null;for(let n=0;n<e.geometries.length;n++){const o=e.geometries[n];if(o.material.supportsEdges){if(t){if(!r(t,o.transformation))return!1}else t=o.transformation;if(s||null==o.localOrigin){if(null!=s?.localOrigin&&null!=o.localOrigin&&s.localOrigin.id!==o.localOrigin.id)return!1}else s=o}}return!0}e([c({constructOnly:!0})],re.prototype,"rctx",void 0),e([c({constructOnly:!0})],re.prototype,"renderSR",void 0),e([c({constructOnly:!0})],re.prototype,"viewingMode",void 0),e([c({constructOnly:!0})],re.prototype,"techniqueRepository",void 0),e([c({constructOnly:!0})],re.prototype,"setNeedsRender",void 0),e([c({constructOnly:!0})],re.prototype,"schedule",void 0),e([c({readOnly:!0})],re.prototype,"_updatingHandles",void 0),e([c({readOnly:!0})],re.prototype,"updating",null),re=e([l("esri.views.3d.webgl-engine.lib.edgeRendering.EdgeView")],re);class oe{constructor(e,t,r){this.center=t,this.radius=r,this.renderables=new Array,this.loaded=e,this.loaded.then((()=>{null!=this.loaded&&(this.loaded=!0)}))}}class ie{constructor(e,t){this.buffer=e,this.meta=t}}class ae{constructor(e,t){this.vao=e,this.lod=t}}class ce{constructor(e,t){this.modelMatrix=e,this.origin=t}}class le{constructor(e,t,r,s,n,o,i,a){this.regular=e,this.silhouette=t,this.statistics=r,this.transform=s,this.edgeTransparency=n,this.objectTransparency=o,this.components=i,this.rendererKey=a,this.distanceToCamera=0,this.visible=!0}}class de extends le{}function ue(e){return null!=e.regular}class he extends le{}function me(e){return null!=e.silhouette}function ge(e,t,r){const n=t*r,o=s(e,n,!0);return-1===o?n<e[0]?e.length:0:e.length-o}class pe{constructor(e,t,r){this.position=e,this.modelTransform=t,this.origin=r}}const fe=m(),_e=()=>Promise.reject();export{re as EdgeView,ce as LegacyTransform,de as RegularRenderable,le as Renderable,he as SilhouetteRenderable};
@@ -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 has from"../../../../core/has.js";import e from"../../../../core/Logger.js";import{clamp as t}from"../../../../core/mathUtils.js";import{createRenderScreenPointArray3 as r}from"../../../../core/screenUtils.js";import{j as s}from"../../../../chunks/vec2.js";import{s as i,f as a,j as n,i as o,g as l,c as u,l as c,o as h,e as p}from"../../../../chunks/vec3.js";import{c as f}from"../../../../chunks/vec3f64.js";import{O as m}from"../../../../chunks/vec4f64.js";import{PlaneIndex as T}from"../../../../geometry/support/frustum.js";import{create as d,distance2 as _,fromPoints as E,closestLineSegmentPoint as A}from"../../../../geometry/support/lineSegment.js";import{create as R,fromPoints as I,signedDistance as S,normal as g}from"../../../../geometry/support/plane.js";import{newLayout as O}from"../../support/buffer/InterleavedLayout.js";import{ShaderOutput as b}from"../core/shaderLibrary/ShaderOutput.js";import v from"../lib/GLMaterial.js";import{Material as L,RenderOccludedFlag as P}from"../lib/Material.js";import{RenderSlot as N}from"../lib/RenderSlot.js";import{isTranslationMatrix as C}from"../lib/Util.js";import{VertexAttribute as y}from"../lib/VertexAttribute.js";import{VisualVariablePassParameters as j}from"./VisualVariablePassParameters.js";import{LineMarkerAnchor as U}from"../shaders/LineMarkerTechniqueConfiguration.js";import{r as D}from"../../../../chunks/RibbonLine.glsl.js";import{vertexAttributeLocations as F,RibbonLineTechnique as w}from"../shaders/RibbonLineTechnique.js";import{RibbonLineTechniqueConfiguration as B,CapType as J}from"../shaders/RibbonLineTechniqueConfiguration.js";var M;!function(e){e[e.LEFT_JOIN_START=-2]="LEFT_JOIN_START",e[e.LEFT_JOIN_END=-1]="LEFT_JOIN_END",e[e.LEFT_CAP_START=-4]="LEFT_CAP_START",e[e.LEFT_CAP_END=-5]="LEFT_CAP_END",e[e.RIGHT_JOIN_START=2]="RIGHT_JOIN_START",e[e.RIGHT_JOIN_END=1]="RIGHT_JOIN_END",e[e.RIGHT_CAP_START=4]="RIGHT_CAP_START",e[e.RIGHT_CAP_END=5]="RIGHT_CAP_END"}(M||(M={}));class x extends L{constructor(e){super(e,new z),this._configuration=new B,this._vertexAttributeLocations=F}getConfiguration(e,t){this._configuration.output=e,this._configuration.draped=t.slot===N.DRAPED_MATERIAL;const r=null!=this.parameters.stipplePattern&&e!==b.Highlight;return this._configuration.stippleEnabled=r,this._configuration.stippleOffColorEnabled=r&&null!=this.parameters.stippleOffColor,this._configuration.stipplePreferContinuous=r&&this.parameters.stipplePreferContinuous,this._configuration.hasSlicePlane=this.parameters.hasSlicePlane,this._configuration.hasOccludees=this.parameters.hasOccludees,this._configuration.roundJoins="round"===this.parameters.join,this._configuration.capType=this.parameters.cap,this._configuration.applyMarkerOffset=null!=this.parameters.markerParameters&&V(this.parameters.markerParameters),this._configuration.hasPolygonOffset=this.parameters.hasPolygonOffset,this._configuration.writeDepth=this.parameters.writeDepth,this._configuration.vvSize=!!this.parameters.vvSize,this._configuration.vvColor=!!this.parameters.vvColor,this._configuration.vvOpacity=!!this.parameters.vvOpacity,this._configuration.innerColorEnabled=this.parameters.innerWidth>0&&null!=this.parameters.innerColor,this._configuration.falloffEnabled=this.parameters.falloff>0,this._configuration.occluder=this.parameters.renderOccluded===P.OccludeAndTransparentStencil,this._configuration.transparencyPassType=t.transparencyPassType,this._configuration.multipassEnabled=t.multipassEnabled,this._configuration.cullAboveGround=t.multipassTerrain.cullAboveGround,this._configuration.wireframe=this.parameters.wireframe,this._configuration}intersectDraped(e,r,s,i,a,n){if(!s.options.selectionMode)return;const o=e.attributes.get(y.POSITION).data,l=e.attributes.get(y.SIZE);let u=this.parameters.width;if(this.parameters.vvSize){const r=e.attributes.get(y.SIZEFEATUREATTRIBUTE).data[0];u*=t(this.parameters.vvSize.offset[0]+r*this.parameters.vvSize.factor[0],this.parameters.vvSize.minSize[0],this.parameters.vvSize.maxSize[0])}else l&&(u*=l.data[0]);const c=i[0],h=i[1],p=(u/2+4)*e.screenToWorldRatio;let f=Number.MAX_VALUE,m=0;for(let T=0;T<o.length-5;T+=3){const e=o[T],r=o[T+1],s=c-e,i=h-r,a=o[T+3]-e,n=o[T+4]-r,l=t((a*s+n*i)/(a*a+n*n),0,1),u=a*l-s,p=n*l-i,d=u*u+p*p;d<f&&(f=d,m=T/3)}f<p*p&&a(n.dist,n.normal,m,!1)}intersect(r,p,f,m,d,R){if(!f.options.selectionMode||!r.visible)return;if(!C(p))return void e.getLogger("esri.views.3d.webgl-engine.materials.RibbonLineMaterial").error("intersection assumes a translation-only matrix");const O=r.attributes,b=O.get(y.POSITION).data;let v=this.parameters.width;if(this.parameters.vvSize){const e=O.get(y.SIZEFEATUREATTRIBUTE).data[0];v*=t(this.parameters.vvSize.offset[0]+e*this.parameters.vvSize.factor[0],this.parameters.vvSize.minSize[0],this.parameters.vvSize.maxSize[0])}else O.has(y.SIZE)&&(v*=O.get(y.SIZE).data[0]);const L=f.camera,P=Q;s(P,f.point);const N=v*L.pixelRatio/2+4*L.pixelRatio;i(oe[0],P[0]-N,P[1]+N,0),i(oe[1],P[0]+N,P[1]+N,0),i(oe[2],P[0]+N,P[1]-N,0),i(oe[3],P[0]-N,P[1]-N,0);for(let e=0;e<4;e++)if(!L.unprojectFromRenderScreen(oe[e],le[e]))return;I(L.eye,le[0],le[1],ue),I(L.eye,le[1],le[2],ce),I(L.eye,le[2],le[3],he),I(L.eye,le[3],le[0],pe);let j=Number.MAX_VALUE,U=0;const D=Z(this.parameters,O)?b.length-2:b.length-5;for(let e=0;e<D;e+=3){W[0]=b[e]+p[12],W[1]=b[e+1]+p[13],W[2]=b[e+2]+p[14];const t=(e+3)%b.length;if(Y[0]=b[t]+p[12],Y[1]=b[t+1]+p[13],Y[2]=b[t+2]+p[14],S(ue,W)<0&&S(ue,Y)<0||S(ce,W)<0&&S(ce,Y)<0||S(he,W)<0&&S(he,Y)<0||S(pe,W)<0&&S(pe,Y)<0)continue;if(L.projectToRenderScreen(W,K),L.projectToRenderScreen(Y,$),K[2]<0&&$[2]>0){a(X,W,Y);const e=L.frustum,t=-S(e[T.NEAR],W)/n(X,g(e[T.NEAR]));o(X,X,t),l(W,W,X),L.projectToRenderScreen(W,K)}else if(K[2]>0&&$[2]<0){a(X,Y,W);const e=L.frustum,t=-S(e[T.NEAR],Y)/n(X,g(e[T.NEAR]));o(X,X,t),l(Y,Y,X),L.projectToRenderScreen(Y,$)}else if(K[2]<0&&$[2]<0)continue;K[2]=0,$[2]=0;const r=_(E(K,$,re),P);r<j&&(j=r,u(ee,W),u(te,Y),U=e/3)}const F=f.rayBegin,w=f.rayEnd;if(j<N*N){let e=Number.MAX_VALUE;if(A(E(ee,te,re),E(F,w,se),q)){a(q,q,F);const t=c(q);o(q,q,1/t),e=t/h(F,w)}R(e,q,U,!1)}}get _layout(){const e=O().vec3f(y.POSITION).f32(y.SUBDIVISIONFACTOR).vec2f(y.UV0).vec3f(y.AUXPOS1).vec3f(y.AUXPOS2);return this.parameters.vvSize?e.f32(y.SIZEFEATUREATTRIBUTE):e.f32(y.SIZE),this.parameters.vvColor?e.f32(y.COLORFEATUREATTRIBUTE):e.vec4f(y.COLOR),this.parameters.vvOpacity&&e.f32(y.OPACITYFEATUREATTRIBUTE),has("enable-feature:objectAndLayerId-rendering")&&e.vec4u8(y.OBJECTANDLAYERIDCOLOR),e}createBufferWriter(){return new H(this._layout,this.parameters)}produces(e,t){if(t===b.Color||t===b.Alpha||t===b.Highlight||t===b.Depth||t===b.ObjectAndLayerIdColor){if(e===N.DRAPED_MATERIAL)return!0;if(this.parameters.renderOccluded===P.OccludeAndTransparentStencil)return e===N.OPAQUE_MATERIAL||e===N.OCCLUDER_MATERIAL||e===N.TRANSPARENT_OCCLUDER_MATERIAL;if(t===b.Color||t===b.Alpha){return e===(this.parameters.writeDepth?N.TRANSPARENT_MATERIAL:N.TRANSPARENT_DEPTH_WRITE_DISABLED_MATERIAL)}return e===N.OPAQUE_MATERIAL}return!1}createGLMaterial(e){return new G(e)}validateParameters(e){"miter"!==e.join&&(e.miterLimit=0),null!=e.markerParameters&&(e.markerScale=e.markerParameters.width/e.width)}}class G extends v{constructor(){super(...arguments),this._stipplePattern=null}dispose(){super.dispose(),this._stippleTextureRepository.release(this._stipplePattern),this._stipplePattern=null}_updateOccludeeState(e){e.hasOccludees!==this._material.parameters.hasOccludees&&this._material.setParameters({hasOccludees:e.hasOccludees})}beginSlot(e){this._output!==b.Color&&this._output!==b.Alpha||this._updateOccludeeState(e);const t=this._material.parameters.stipplePattern;return this._stipplePattern!==t&&(this._material.setParameters({stippleTexture:this._stippleTextureRepository.swap(t,this._stipplePattern)}),this._stipplePattern=t),this.ensureTechnique(w,e)}}class z extends j{constructor(){super(...arguments),this.width=0,this.color=m,this.join="miter",this.cap=J.BUTT,this.miterLimit=5,this.writeDepth=!0,this.hasPolygonOffset=!1,this.stippleTexture=null,this.stipplePreferContinuous=!0,this.markerParameters=null,this.markerScale=1,this.hasSlicePlane=!1,this.vvFastUpdate=!1,this.isClosed=!1,this.falloff=0,this.innerWidth=0,this.hasOccludees=!1,this.wireframe=!1}}class H{constructor(e,t){this.vertexBufferLayout=e,this._parameters=t,this.numJoinSubdivisions=0;const r=t.stipplePattern?1:0;switch(this._parameters.join){case"miter":case"bevel":this.numJoinSubdivisions=r;break;case"round":this.numJoinSubdivisions=D+r}}_isClosed(e){return Z(this._parameters,e.attributes)}allocate(e){return this.vertexBufferLayout.createBuffer(e)}elementCount(e){const t=2,r=e.attributes.get(y.POSITION).indices.length/2+1,s=this._isClosed(e);let i=s?2:2*t;return i+=((s?r:r-1)-(s?0:1))*(2*this.numJoinSubdivisions+4),i+=2,this._parameters.wireframe&&(i=2+4*(i-2)),i}write(e,t,r,s,a){const n=ie,o=ae,l=ne,c=r.attributes.get(y.POSITION),f=c.indices,m=c.data.length/3,T=r.attributes.get(y.DISTANCETOSTART)?.data;f&&f.length!==2*(m-1)&&console.warn("RibbonLineMaterial does not support indices");let d=1,_=0;const E=this.vertexBufferLayout.fields.has(y.SIZEFEATUREATTRIBUTE);E?_=r.attributes.get(y.SIZEFEATUREATTRIBUTE).data[0]:r.attributes.has(y.SIZE)&&(d=r.attributes.get(y.SIZE).data[0]);let A=[1,1,1,1],R=0;const I=this.vertexBufferLayout.fields.has(y.COLORFEATUREATTRIBUTE);I?R=r.attributes.get(y.COLORFEATUREATTRIBUTE).data[0]:r.attributes.has(y.COLOR)&&(A=r.attributes.get(y.COLOR).data);const S=has("enable-feature:objectAndLayerId-rendering")?r.objectAndLayerIdColor:null;let g=0;const O=this.vertexBufferLayout.fields.has(y.OPACITYFEATUREATTRIBUTE);O&&(g=r.attributes.get(y.OPACITYFEATUREATTRIBUTE).data[0]);const b=new Float32Array(s.buffer),v=has("enable-feature:objectAndLayerId-rendering")?new Uint8Array(s.buffer):null,L=this.vertexBufferLayout.stride/4;let P=a*L;const N=P;let C=0;const j=T?(e,t,r)=>C=T[r]:(e,t,r)=>C+=h(e,t),U=has("enable-feature:objectAndLayerId-rendering"),D=(e,t,r,s,i,a,n)=>{if(b[P++]=t[0],b[P++]=t[1],b[P++]=t[2],b[P++]=s,b[P++]=n,b[P++]=i,b[P++]=e[0],b[P++]=e[1],b[P++]=e[2],b[P++]=r[0],b[P++]=r[1],b[P++]=r[2],b[P++]=E?_:d,I)b[P++]=R;else{const e=Math.min(4*a,A.length-4);b[P++]=A[e],b[P++]=A[e+1],b[P++]=A[e+2],b[P++]=A[e+3]}O&&(b[P++]=g),U&&(null!=S&&(v[4*P]=S[0],v[4*P+1]=S[1],v[4*P+2]=S[2],v[4*P+3]=S[3]),P++)};P+=L,i(o,c.data[0],c.data[1],c.data[2]),e&&p(o,o,e);const F=this._isClosed(r);if(F){const t=c.data.length-3;i(n,c.data[t],c.data[t+1],c.data[t+2]),e&&p(n,n,e)}else i(l,c.data[3],c.data[4],c.data[5]),e&&p(l,l,e),D(o,o,l,1,M.LEFT_CAP_START,0,0),D(o,o,l,1,M.RIGHT_CAP_START,0,0),u(n,o),u(o,l);const w=F?0:1,B=F?m:m-1;for(let h=w;h<B;h++){const t=(h+1)%m*3;i(l,c.data[t],c.data[t+1],c.data[t+2]),e&&p(l,l,e),j(n,o,h),D(n,o,l,0,M.LEFT_JOIN_END,h,C),D(n,o,l,0,M.RIGHT_JOIN_END,h,C);const r=this.numJoinSubdivisions;for(let e=0;e<r;++e){const t=(e+1)/(r+1);D(n,o,l,t,M.LEFT_JOIN_END,h,C),D(n,o,l,t,M.RIGHT_JOIN_END,h,C)}D(n,o,l,1,M.LEFT_JOIN_START,h,C),D(n,o,l,1,M.RIGHT_JOIN_START,h,C),u(n,o),u(o,l)}F?(i(l,c.data[3],c.data[4],c.data[5]),e&&p(l,l,e),C=j(n,o,B),D(n,o,l,0,M.LEFT_JOIN_END,w,C),D(n,o,l,0,M.RIGHT_JOIN_END,w,C)):(C=j(n,o,B),D(n,o,o,0,M.LEFT_CAP_END,B,C),D(n,o,o,0,M.RIGHT_CAP_END,B,C)),k(b,N+L,b,N,L);P=k(b,P-L,b,P,L),this._parameters.wireframe&&this._addWireframeVertices(s,N,P,L)}_addWireframeVertices(e,t,r,s){const i=new Float32Array(e.buffer,r*Float32Array.BYTES_PER_ELEMENT),a=new Float32Array(e.buffer,t*Float32Array.BYTES_PER_ELEMENT,r-t);let n=0;const o=e=>n=k(a,e,i,n,s);for(let l=0;l<a.length-1;l+=2*s)o(l),o(l+2*s),o(l+1*s),o(l+2*s),o(l+1*s),o(l+3*s)}}function k(e,t,r,s,i){for(let a=0;a<i;a++)r[s++]=e[t++];return s}function Z(e,t){if(!e.isClosed)return!1;return t.get(y.POSITION).indices.length>2}function V(e){return e.anchor===U.Tip&&e.hideOnShortSegments&&"begin-end"===e.placement&&e.worldSpace}const W=f(),Y=f(),X=f(),q=f(),Q=f(),K=r(),$=r(),ee=f(),te=f(),re=d(),se=d(),ie=f(),ae=f(),ne=f(),oe=[r(),r(),r(),r()],le=[f(),f(),f(),f()],ue=R(),ce=R(),he=R(),pe=R();export{z as Parameters,x as RibbonLineMaterial};
5
+ import has from"../../../../core/has.js";import e from"../../../../core/Logger.js";import{clamp as t}from"../../../../core/mathUtils.js";import{createRenderScreenPointArray3 as r}from"../../../../core/screenUtils.js";import{j as s}from"../../../../chunks/vec2.js";import{s as i,f as a,j as n,i as o,g as l,c as u,l as c,o as h,e as p}from"../../../../chunks/vec3.js";import{c as f}from"../../../../chunks/vec3f64.js";import{O as m}from"../../../../chunks/vec4f64.js";import{PlaneIndex as T}from"../../../../geometry/support/frustum.js";import{create as d,distance2 as _,fromPoints as E,closestLineSegmentPoint as A}from"../../../../geometry/support/lineSegment.js";import{create as R,fromPoints as I,signedDistance as S,normal as g}from"../../../../geometry/support/plane.js";import{newLayout as O}from"../../support/buffer/InterleavedLayout.js";import{ShaderOutput as b}from"../core/shaderLibrary/ShaderOutput.js";import v from"../lib/GLMaterial.js";import{Material as L,RenderOccludedFlag as P}from"../lib/Material.js";import{RenderSlot as N}from"../lib/RenderSlot.js";import{isTranslationMatrix as C}from"../lib/Util.js";import{VertexAttribute as y}from"../lib/VertexAttribute.js";import{VisualVariablePassParameters as j}from"./VisualVariablePassParameters.js";import{LineMarkerAnchor as U}from"../shaders/LineMarkerTechniqueConfiguration.js";import{r as D}from"../../../../chunks/RibbonLine.glsl.js";import{vertexAttributeLocations as F,RibbonLineTechnique as w}from"../shaders/RibbonLineTechnique.js";import{RibbonLineTechniqueConfiguration as B,CapType as J}from"../shaders/RibbonLineTechniqueConfiguration.js";var M;!function(e){e[e.LEFT_JOIN_START=-2]="LEFT_JOIN_START",e[e.LEFT_JOIN_END=-1]="LEFT_JOIN_END",e[e.LEFT_CAP_START=-4]="LEFT_CAP_START",e[e.LEFT_CAP_END=-5]="LEFT_CAP_END",e[e.RIGHT_JOIN_START=2]="RIGHT_JOIN_START",e[e.RIGHT_JOIN_END=1]="RIGHT_JOIN_END",e[e.RIGHT_CAP_START=4]="RIGHT_CAP_START",e[e.RIGHT_CAP_END=5]="RIGHT_CAP_END"}(M||(M={}));class x extends L{constructor(e){super(e,new z),this._configuration=new B,this._vertexAttributeLocations=F}getConfiguration(e,t){this._configuration.output=e,this._configuration.draped=t.slot===N.DRAPED_MATERIAL;const r=null!=this.parameters.stipplePattern&&e!==b.Highlight;return this._configuration.stippleEnabled=r,this._configuration.stippleOffColorEnabled=r&&null!=this.parameters.stippleOffColor,this._configuration.stipplePreferContinuous=r&&this.parameters.stipplePreferContinuous,this._configuration.hasSlicePlane=this.parameters.hasSlicePlane,this._configuration.hasOccludees=this.parameters.hasOccludees,this._configuration.roundJoins="round"===this.parameters.join,this._configuration.capType=this.parameters.cap,this._configuration.applyMarkerOffset=null!=this.parameters.markerParameters&&V(this.parameters.markerParameters),this._configuration.hasPolygonOffset=this.parameters.hasPolygonOffset,this._configuration.writeDepth=this.parameters.writeDepth,this._configuration.vvSize=!!this.parameters.vvSize,this._configuration.vvColor=!!this.parameters.vvColor,this._configuration.vvOpacity=!!this.parameters.vvOpacity,this._configuration.innerColorEnabled=this.parameters.innerWidth>0&&null!=this.parameters.innerColor,this._configuration.falloffEnabled=this.parameters.falloff>0,this._configuration.occluder=this.parameters.renderOccluded===P.OccludeAndTransparentStencil,this._configuration.transparencyPassType=t.transparencyPassType,this._configuration.multipassEnabled=t.multipassEnabled,this._configuration.cullAboveGround=t.multipassTerrain.cullAboveGround,this._configuration.wireframe=this.parameters.wireframe,this._configuration}intersectDraped(e,r,s,i,a,n){if(!s.options.selectionMode)return;const o=e.attributes.get(y.POSITION).data,l=e.attributes.get(y.SIZE);let u=this.parameters.width;if(this.parameters.vvSize){const r=e.attributes.get(y.SIZEFEATUREATTRIBUTE).data[0];u*=t(this.parameters.vvSize.offset[0]+r*this.parameters.vvSize.factor[0],this.parameters.vvSize.minSize[0],this.parameters.vvSize.maxSize[0])}else l&&(u*=l.data[0]);const c=i[0],h=i[1],p=(u/2+4)*e.screenToWorldRatio;let f=Number.MAX_VALUE,m=0;for(let T=0;T<o.length-5;T+=3){const e=o[T],r=o[T+1],s=c-e,i=h-r,a=o[T+3]-e,n=o[T+4]-r,l=t((a*s+n*i)/(a*a+n*n),0,1),u=a*l-s,p=n*l-i,d=u*u+p*p;d<f&&(f=d,m=T/3)}f<p*p&&a(n.dist,n.normal,m,!1)}intersect(r,p,f,m,d,R){if(!f.options.selectionMode||!r.visible)return;if(!C(p))return void e.getLogger("esri.views.3d.webgl-engine.materials.RibbonLineMaterial").error("intersection assumes a translation-only matrix");const O=r.attributes,b=O.get(y.POSITION).data;let v=this.parameters.width;if(this.parameters.vvSize){const e=O.get(y.SIZEFEATUREATTRIBUTE).data[0];v*=t(this.parameters.vvSize.offset[0]+e*this.parameters.vvSize.factor[0],this.parameters.vvSize.minSize[0],this.parameters.vvSize.maxSize[0])}else O.has(y.SIZE)&&(v*=O.get(y.SIZE).data[0]);const L=f.camera,P=Q;s(P,f.point);const N=v*L.pixelRatio/2+4*L.pixelRatio;i(oe[0],P[0]-N,P[1]+N,0),i(oe[1],P[0]+N,P[1]+N,0),i(oe[2],P[0]+N,P[1]-N,0),i(oe[3],P[0]-N,P[1]-N,0);for(let e=0;e<4;e++)if(!L.unprojectFromRenderScreen(oe[e],le[e]))return;I(L.eye,le[0],le[1],ue),I(L.eye,le[1],le[2],ce),I(L.eye,le[2],le[3],he),I(L.eye,le[3],le[0],pe);let j=Number.MAX_VALUE,U=0;const D=Z(this.parameters,O)?b.length-2:b.length-5;for(let e=0;e<D;e+=3){W[0]=b[e]+p[12],W[1]=b[e+1]+p[13],W[2]=b[e+2]+p[14];const t=(e+3)%b.length;if(Y[0]=b[t]+p[12],Y[1]=b[t+1]+p[13],Y[2]=b[t+2]+p[14],S(ue,W)<0&&S(ue,Y)<0||S(ce,W)<0&&S(ce,Y)<0||S(he,W)<0&&S(he,Y)<0||S(pe,W)<0&&S(pe,Y)<0)continue;if(L.projectToRenderScreen(W,K),L.projectToRenderScreen(Y,$),K[2]<0&&$[2]>0){a(X,W,Y);const e=L.frustum,t=-S(e[T.NEAR],W)/n(X,g(e[T.NEAR]));o(X,X,t),l(W,W,X),L.projectToRenderScreen(W,K)}else if(K[2]>0&&$[2]<0){a(X,Y,W);const e=L.frustum,t=-S(e[T.NEAR],Y)/n(X,g(e[T.NEAR]));o(X,X,t),l(Y,Y,X),L.projectToRenderScreen(Y,$)}else if(K[2]<0&&$[2]<0)continue;K[2]=0,$[2]=0;const r=_(E(K,$,re),P);r<j&&(j=r,u(ee,W),u(te,Y),U=e/3)}const F=f.rayBegin,w=f.rayEnd;if(j<N*N){let e=Number.MAX_VALUE;if(A(E(ee,te,re),E(F,w,se),q)){a(q,q,F);const t=c(q);o(q,q,1/t),e=t/h(F,w)}R(e,q,U,!1)}}get _layout(){const e=O().vec3f(y.POSITION).f32(y.SUBDIVISIONFACTOR).vec2f(y.UV0).vec3f(y.AUXPOS1).vec3f(y.AUXPOS2);return this.parameters.vvSize?e.f32(y.SIZEFEATUREATTRIBUTE):e.f32(y.SIZE),this.parameters.vvColor?e.f32(y.COLORFEATUREATTRIBUTE):e.vec4f(y.COLOR),this.parameters.vvOpacity&&e.f32(y.OPACITYFEATUREATTRIBUTE),has("enable-feature:objectAndLayerId-rendering")&&e.vec4u8(y.OBJECTANDLAYERIDCOLOR),e}createBufferWriter(){return new H(this._layout,this.parameters)}produces(e,t){if(t===b.Depth&&!this.parameters.writeLinearDepth)return!1;if(t===b.Color||t===b.Alpha||t===b.Highlight||t===b.Depth||t===b.ObjectAndLayerIdColor){if(e===N.DRAPED_MATERIAL)return!0;if(this.parameters.renderOccluded===P.OccludeAndTransparentStencil)return e===N.OPAQUE_MATERIAL||e===N.OCCLUDER_MATERIAL||e===N.TRANSPARENT_OCCLUDER_MATERIAL;if(t===b.Color||t===b.Alpha){return e===(this.parameters.writeDepth?N.TRANSPARENT_MATERIAL:N.TRANSPARENT_DEPTH_WRITE_DISABLED_MATERIAL)}return e===N.OPAQUE_MATERIAL}return!1}createGLMaterial(e){return new G(e)}validateParameters(e){"miter"!==e.join&&(e.miterLimit=0),null!=e.markerParameters&&(e.markerScale=e.markerParameters.width/e.width)}}class G extends v{constructor(){super(...arguments),this._stipplePattern=null}dispose(){super.dispose(),this._stippleTextureRepository.release(this._stipplePattern),this._stipplePattern=null}_updateOccludeeState(e){e.hasOccludees!==this._material.parameters.hasOccludees&&this._material.setParameters({hasOccludees:e.hasOccludees})}beginSlot(e){this._output!==b.Color&&this._output!==b.Alpha||this._updateOccludeeState(e);const t=this._material.parameters.stipplePattern;return this._stipplePattern!==t&&(this._material.setParameters({stippleTexture:this._stippleTextureRepository.swap(t,this._stipplePattern)}),this._stipplePattern=t),this.ensureTechnique(w,e)}}class z extends j{constructor(){super(...arguments),this.width=0,this.color=m,this.join="miter",this.cap=J.BUTT,this.miterLimit=5,this.writeDepth=!0,this.writeLinearDepth=!0,this.hasPolygonOffset=!1,this.stippleTexture=null,this.stipplePreferContinuous=!0,this.markerParameters=null,this.markerScale=1,this.hasSlicePlane=!1,this.vvFastUpdate=!1,this.isClosed=!1,this.falloff=0,this.innerWidth=0,this.hasOccludees=!1,this.wireframe=!1}}class H{constructor(e,t){this.vertexBufferLayout=e,this._parameters=t,this.numJoinSubdivisions=0;const r=t.stipplePattern?1:0;switch(this._parameters.join){case"miter":case"bevel":this.numJoinSubdivisions=r;break;case"round":this.numJoinSubdivisions=D+r}}_isClosed(e){return Z(this._parameters,e.attributes)}allocate(e){return this.vertexBufferLayout.createBuffer(e)}elementCount(e){const t=2,r=e.attributes.get(y.POSITION).indices.length/2+1,s=this._isClosed(e);let i=s?2:2*t;return i+=((s?r:r-1)-(s?0:1))*(2*this.numJoinSubdivisions+4),i+=2,this._parameters.wireframe&&(i=2+4*(i-2)),i}write(e,t,r,s,a){const n=ie,o=ae,l=ne,c=r.attributes.get(y.POSITION),f=c.indices,m=c.data.length/3,T=r.attributes.get(y.DISTANCETOSTART)?.data;f&&f.length!==2*(m-1)&&console.warn("RibbonLineMaterial does not support indices");let d=1,_=0;const E=this.vertexBufferLayout.fields.has(y.SIZEFEATUREATTRIBUTE);E?_=r.attributes.get(y.SIZEFEATUREATTRIBUTE).data[0]:r.attributes.has(y.SIZE)&&(d=r.attributes.get(y.SIZE).data[0]);let A=[1,1,1,1],R=0;const I=this.vertexBufferLayout.fields.has(y.COLORFEATUREATTRIBUTE);I?R=r.attributes.get(y.COLORFEATUREATTRIBUTE).data[0]:r.attributes.has(y.COLOR)&&(A=r.attributes.get(y.COLOR).data);const S=has("enable-feature:objectAndLayerId-rendering")?r.objectAndLayerIdColor:null;let g=0;const O=this.vertexBufferLayout.fields.has(y.OPACITYFEATUREATTRIBUTE);O&&(g=r.attributes.get(y.OPACITYFEATUREATTRIBUTE).data[0]);const b=new Float32Array(s.buffer),v=has("enable-feature:objectAndLayerId-rendering")?new Uint8Array(s.buffer):null,L=this.vertexBufferLayout.stride/4;let P=a*L;const N=P;let C=0;const j=T?(e,t,r)=>C=T[r]:(e,t,r)=>C+=h(e,t),U=has("enable-feature:objectAndLayerId-rendering"),D=(e,t,r,s,i,a,n)=>{if(b[P++]=t[0],b[P++]=t[1],b[P++]=t[2],b[P++]=s,b[P++]=n,b[P++]=i,b[P++]=e[0],b[P++]=e[1],b[P++]=e[2],b[P++]=r[0],b[P++]=r[1],b[P++]=r[2],b[P++]=E?_:d,I)b[P++]=R;else{const e=Math.min(4*a,A.length-4);b[P++]=A[e],b[P++]=A[e+1],b[P++]=A[e+2],b[P++]=A[e+3]}O&&(b[P++]=g),U&&(null!=S&&(v[4*P]=S[0],v[4*P+1]=S[1],v[4*P+2]=S[2],v[4*P+3]=S[3]),P++)};P+=L,i(o,c.data[0],c.data[1],c.data[2]),e&&p(o,o,e);const F=this._isClosed(r);if(F){const t=c.data.length-3;i(n,c.data[t],c.data[t+1],c.data[t+2]),e&&p(n,n,e)}else i(l,c.data[3],c.data[4],c.data[5]),e&&p(l,l,e),D(o,o,l,1,M.LEFT_CAP_START,0,0),D(o,o,l,1,M.RIGHT_CAP_START,0,0),u(n,o),u(o,l);const w=F?0:1,B=F?m:m-1;for(let h=w;h<B;h++){const t=(h+1)%m*3;i(l,c.data[t],c.data[t+1],c.data[t+2]),e&&p(l,l,e),j(n,o,h),D(n,o,l,0,M.LEFT_JOIN_END,h,C),D(n,o,l,0,M.RIGHT_JOIN_END,h,C);const r=this.numJoinSubdivisions;for(let e=0;e<r;++e){const t=(e+1)/(r+1);D(n,o,l,t,M.LEFT_JOIN_END,h,C),D(n,o,l,t,M.RIGHT_JOIN_END,h,C)}D(n,o,l,1,M.LEFT_JOIN_START,h,C),D(n,o,l,1,M.RIGHT_JOIN_START,h,C),u(n,o),u(o,l)}F?(i(l,c.data[3],c.data[4],c.data[5]),e&&p(l,l,e),C=j(n,o,B),D(n,o,l,0,M.LEFT_JOIN_END,w,C),D(n,o,l,0,M.RIGHT_JOIN_END,w,C)):(C=j(n,o,B),D(n,o,o,0,M.LEFT_CAP_END,B,C),D(n,o,o,0,M.RIGHT_CAP_END,B,C)),k(b,N+L,b,N,L);P=k(b,P-L,b,P,L),this._parameters.wireframe&&this._addWireframeVertices(s,N,P,L)}_addWireframeVertices(e,t,r,s){const i=new Float32Array(e.buffer,r*Float32Array.BYTES_PER_ELEMENT),a=new Float32Array(e.buffer,t*Float32Array.BYTES_PER_ELEMENT,r-t);let n=0;const o=e=>n=k(a,e,i,n,s);for(let l=0;l<a.length-1;l+=2*s)o(l),o(l+2*s),o(l+1*s),o(l+2*s),o(l+1*s),o(l+3*s)}}function k(e,t,r,s,i){for(let a=0;a<i;a++)r[s++]=e[t++];return s}function Z(e,t){if(!e.isClosed)return!1;return t.get(y.POSITION).indices.length>2}function V(e){return e.anchor===U.Tip&&e.hideOnShortSegments&&"begin-end"===e.placement&&e.worldSpace}const W=f(),Y=f(),X=f(),q=f(),Q=f(),K=r(),$=r(),ee=f(),te=f(),re=d(),se=d(),ie=f(),ae=f(),ne=f(),oe=[r(),r(),r(),r()],le=[f(),f(),f(),f()],ue=R(),ce=R(),he=R(),pe=R();export{z as Parameters,x as RibbonLineMaterial};
@@ -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{byId as t,reparent as s,empty as i}from"../core/domUtils.js";import{on as r}from"../core/events.js";import o from"../core/Logger.js";import{destroyMaybe as n,removeMaybe as a}from"../core/maybe.js";import{watch as h,initial as d}from"../core/reactiveUtils.js";import{addFrameTask as l}from"../core/scheduling.js";import{property as u}from"../core/accessorSupport/decorators/property.js";import"../core/accessorSupport/ensureType.js";import"../core/arrayUtils.js";import"../core/has.js";import{subclass as c}from"../core/accessorSupport/decorators/subclass.js";import p from"./overlay/ViewOverlay.js";const f=[0,0];function m(e){const t=(e.ownerDocument||window.document).defaultView,s=e.getBoundingClientRect();return f[0]=s.left+(t?.pageXOffset??0),f[1]=s.top+(t?.pageYOffset??0),f}function y(e){e&&(i(e),e.parentNode&&e.parentNode.removeChild(e))}function g(e){const t=document.createElement("div");return e.appendChild(t),t}const _=16,v=750,w=512,C=2,H=i=>{let f=class extends i{constructor(...e){super(...e),this._freqInfo={freq:_,time:v},this._overlayRenderTaskHandle=null,this.height=0,this.overlay=null,this.position=null,this.resizing=!1,this.root=null,this.surface=null,this.suspended=!0,this.ui=null,this.userContent=null,this.width=0,this.widthBreakpoint=null,this.addHandles([h((()=>this.cursor),(e=>{const{surface:t}=this;t&&t.setAttribute("data-cursor",e)})),h((()=>this.navigating),(e=>{const{surface:t}=this;t&&t.setAttribute("data-navigating",e.toString())}))])}initialize(){this.addHandles([h((()=>this.ui),((e,t)=>this._handleUIChange(e,t)),d),this.on("focus",(()=>this.notifyChange("focused"))),this.on("blur",(()=>this.notifyChange("focused")))])}destroy(){this.destroyed||(this.ui=n(this.ui),this.container=null)}get container(){return this._get("container")??null}set container(e){const i=this._get("container"),r=t(e);if(r||"string"!=typeof e||o.getLogger(this).error("#container",`element with id '${e}' not found`),i===r)return;if(this._stopMeasuring(),i&&(i.classList.remove("esri-view"),this._overlayRenderTaskHandle&&(this._overlayRenderTaskHandle.remove(),this._overlayRenderTaskHandle=null),this.overlay&&(this.overlay.destroy(),this._set("overlay",null)),this.root&&(y(this.root),this._set("root",null)),this.userContent&&(s(this.userContent,i),y(this.userContent),this._set("userContent",null))),!r)return this._set("width",0),this._set("height",0),this._set("position",null),this._set("suspended",!0),this._set("surface",null),void this._set("container",null);r.classList.add("esri-view");const n=document.createElement("div");n.className="esri-view-user-storage",s(r,n),r.appendChild(n),this._set("userContent",n);const d=document.createElement("div");d.className="esri-view-root",r.insertBefore(d,r.firstChild),this._set("root",d);const u=document.createElement("div");u.className="esri-view-surface",u.setAttribute("role","application"),u.tabIndex=0,d.appendChild(u),this._set("surface",u);const c=new p;d.appendChild(c.surface),this._set("overlay",c),this.addHandles(h((()=>c.needsRender),(e=>{e&&!this._overlayRenderTaskHandle?this._overlayRenderTaskHandle=l({render:()=>this.overlay?.render()}):this._overlayRenderTaskHandle=a(this._overlayRenderTaskHandle)}))),this.forceDOMReadyCycle(),this._set("container",r),this._startMeasuring()}get focused(){const e=document.activeElement===this.surface;return document.hasFocus()&&e}get size(){return[this.width,this.height]}blur(){this.surface?.blur()}focus(){this.surface?.focus()}pageToContainer(e,t,s){const i=this.position;return e-=i?i[0]:0,t-=i?i[1]:0,s?(s[0]=e,s[1]=t):s=[e,t],s}containerToPage(e,t,s){const i=this.position;return e+=i?i[0]:0,t+=i?i[1]:0,s?(s[0]=e,s[1]=t):s=[e,t],s}_handleUIChange(e,t){this.removeHandles("ui"),t&&t!==e&&t.destroy(),e&&(e.view=this,this.addHandles(h((()=>this.root),(t=>{e.container=t?g(t):null}),d),"ui")),this._set("ui",e)}_stopMeasuring(){this.removeHandles("measuring"),this._get("resizing")&&this._set("resizing",!1)}_startMeasuring(){const e=this._freqInfo;e.freq=_,e.time=v,this.addHandles([r(window,"resize",(()=>{e.freq=_,e.time=v})),l({prepare:e=>{const t=this._measure(),s=this._freqInfo;if(s.time+=e.deltaTime,t&&(s.freq=_,this._get("resizing")||this._set("resizing",!0)),s.time<s.freq)return;s.time=0;const i=this._position();s.freq=i||t?_:Math.min(v,s.freq*C),!t&&s.freq>=w&&this._get("resizing")&&this._set("resizing",!1)}})],"measuring"),this._measure(),this._position()}_measure(){const e=this.container,t=e?e.clientWidth:0,s=e?e.clientHeight:0;if(0===t||0===s)return this.suspended||this._set("suspended",!0),!1;const i=this.width,r=this.height;return t===i&&s===r?(this.suspended&&this._set("suspended",!1),!1):(this._set("width",t),this._set("height",s),this.suspended&&this._set("suspended",!1),this.emit("resize",{oldWidth:i,oldHeight:r,width:t,height:s}),!0)}_position(){const e=this.container,t=this.position,s=e&&m(e);return!!s&&((!t||s[0]!==t[0]||s[1]!==t[1])&&(this._set("position",[s[0],s[1]]),!0))}forceDOMReadyCycle(){}};return e([u()],f.prototype,"container",null),e([u({readOnly:!0})],f.prototype,"focused",null),e([u({readOnly:!0})],f.prototype,"height",void 0),e([u({type:p})],f.prototype,"overlay",void 0),e([u({readOnly:!0})],f.prototype,"position",void 0),e([u({readOnly:!0})],f.prototype,"resizing",void 0),e([u({readOnly:!0})],f.prototype,"root",void 0),e([u({value:null,readOnly:!0})],f.prototype,"size",null),e([u({readOnly:!0})],f.prototype,"surface",void 0),e([u({readOnly:!0})],f.prototype,"suspended",void 0),e([u()],f.prototype,"ui",void 0),e([u({readOnly:!0})],f.prototype,"userContent",void 0),e([u({readOnly:!0})],f.prototype,"width",void 0),e([u()],f.prototype,"widthBreakpoint",void 0),f=e([c("esri.views.DOMContainer")],f),f};export{H as DOMContainer};
5
+ import{_ as e}from"../chunks/tslib.es6.js";import"../intl.js";import{byId as t,reparent as s,empty as i}from"../core/domUtils.js";import{on as r}from"../core/events.js";import has from"../core/has.js";import o from"../core/Logger.js";import{destroyMaybe as n,removeMaybe as a}from"../core/maybe.js";import{watch as h,initial as d,whenOnce as l}from"../core/reactiveUtils.js";import{addFrameTask as u}from"../core/scheduling.js";import{property as c}from"../core/accessorSupport/decorators/property.js";import"../core/accessorSupport/ensureType.js";import"../core/arrayUtils.js";import{subclass as p}from"../core/accessorSupport/decorators/subclass.js";import m from"./overlay/ViewOverlay.js";import{onLocaleChange as f}from"../intl/locale.js";import{fetchMessageBundle as g}from"../intl/messages.js";const y=[0,0];function v(e){const t=(e.ownerDocument||window.document).defaultView,s=e.getBoundingClientRect();return y[0]=s.left+(t?.pageXOffset??0),y[1]=s.top+(t?.pageYOffset??0),y}function _(e){e&&(i(e),e.parentNode&&e.parentNode.removeChild(e))}function w(e){const t=document.createElement("div");return e.appendChild(t),t}const C=16,H=750,O=512,j=2,b=i=>{let y=class extends i{constructor(...e){super(...e),this._freqInfo={freq:C,time:H},this._overlayRenderTaskHandle=null,this.height=0,this.messagesCommon=null,this.overlay=null,this.position=null,this.resizing=!1,this.root=null,this.surface=null,this.suspended=!0,this.ui=null,this.userContent=null,this.width=0,this.widthBreakpoint=null,this.addHandles([h((()=>this.cursor),(e=>{const{surface:t}=this;t&&t.setAttribute("data-cursor",e)})),h((()=>this.navigating),(e=>{const{surface:t}=this;t&&t.setAttribute("data-navigating",e.toString())}))])}initialize(){const e=has("mac"),t=async()=>{e&&(await l((()=>this.ready)),this.messagesCommon=await g("esri/t9n/common").catch((()=>{})))};t(),this.addHandles([h((()=>this.ui),((e,t)=>this._handleUIChange(e,t)),d),this.on("focus",(()=>this.notifyChange("focused"))),this.on("blur",(()=>this.notifyChange("focused"))),f(t),h((()=>[this.surface,this.messagesCommon]),(()=>{e&&this.surface?.setAttribute("aria-label",this.messagesCommon?.ariaLabels.navigationMacVoceOver??"")}))])}destroy(){this.destroyed||(this.ui=n(this.ui),this.container=null)}get container(){return this._get("container")??null}set container(e){const i=this._get("container"),r=t(e);if(r||"string"!=typeof e||o.getLogger(this).error("#container",`element with id '${e}' not found`),i===r)return;if(this._stopMeasuring(),i&&(i.classList.remove("esri-view"),this._overlayRenderTaskHandle&&(this._overlayRenderTaskHandle.remove(),this._overlayRenderTaskHandle=null),this.overlay&&(this.overlay.destroy(),this._set("overlay",null)),this.root&&(_(this.root),this._set("root",null)),this.userContent&&(s(this.userContent,i),_(this.userContent),this._set("userContent",null))),!r)return this._set("width",0),this._set("height",0),this._set("position",null),this._set("suspended",!0),this._set("surface",null),void this._set("container",null);r.classList.add("esri-view");const n=document.createElement("div");n.className="esri-view-user-storage",s(r,n),r.appendChild(n),this._set("userContent",n);const d=document.createElement("div");d.className="esri-view-root",r.insertBefore(d,r.firstChild),this._set("root",d);const l=document.createElement("div");l.className="esri-view-surface",l.setAttribute("role","application"),l.tabIndex=0,d.appendChild(l),this._set("surface",l);const c=new m;d.appendChild(c.surface),this._set("overlay",c),this.addHandles(h((()=>c.needsRender),(e=>{e&&!this._overlayRenderTaskHandle?this._overlayRenderTaskHandle=u({render:()=>this.overlay?.render()}):this._overlayRenderTaskHandle=a(this._overlayRenderTaskHandle)}))),this.forceDOMReadyCycle(),this._set("container",r),this._startMeasuring()}get focused(){const e=document.activeElement===this.surface;return document.hasFocus()&&e}get size(){return[this.width,this.height]}blur(){this.surface?.blur()}focus(){this.surface?.focus()}pageToContainer(e,t,s){const i=this.position;return e-=i?i[0]:0,t-=i?i[1]:0,s?(s[0]=e,s[1]=t):s=[e,t],s}containerToPage(e,t,s){const i=this.position;return e+=i?i[0]:0,t+=i?i[1]:0,s?(s[0]=e,s[1]=t):s=[e,t],s}_handleUIChange(e,t){this.removeHandles("ui"),t&&t!==e&&t.destroy(),e&&(e.view=this,this.addHandles(h((()=>this.root),(t=>{e.container=t?w(t):null}),d),"ui")),this._set("ui",e)}_stopMeasuring(){this.removeHandles("measuring"),this._get("resizing")&&this._set("resizing",!1)}_startMeasuring(){const e=this._freqInfo;e.freq=C,e.time=H,this.addHandles([r(window,"resize",(()=>{e.freq=C,e.time=H})),u({prepare:e=>{const t=this._measure(),s=this._freqInfo;if(s.time+=e.deltaTime,t&&(s.freq=C,this._get("resizing")||this._set("resizing",!0)),s.time<s.freq)return;s.time=0;const i=this._position();s.freq=i||t?C:Math.min(H,s.freq*j),!t&&s.freq>=O&&this._get("resizing")&&this._set("resizing",!1)}})],"measuring"),this._measure(),this._position()}_measure(){const e=this.container,t=e?e.clientWidth:0,s=e?e.clientHeight:0;if(0===t||0===s)return this.suspended||this._set("suspended",!0),!1;const i=this.width,r=this.height;return t===i&&s===r?(this.suspended&&this._set("suspended",!1),!1):(this._set("width",t),this._set("height",s),this.suspended&&this._set("suspended",!1),this.emit("resize",{oldWidth:i,oldHeight:r,width:t,height:s}),!0)}_position(){const e=this.container,t=this.position,s=e&&v(e);return!!s&&((!t||s[0]!==t[0]||s[1]!==t[1])&&(this._set("position",[s[0],s[1]]),!0))}forceDOMReadyCycle(){}};return e([c()],y.prototype,"container",null),e([c({readOnly:!0})],y.prototype,"focused",null),e([c({readOnly:!0})],y.prototype,"height",void 0),e([c()],y.prototype,"messagesCommon",void 0),e([c({type:m})],y.prototype,"overlay",void 0),e([c({readOnly:!0})],y.prototype,"position",void 0),e([c({readOnly:!0})],y.prototype,"resizing",void 0),e([c({readOnly:!0})],y.prototype,"root",void 0),e([c({value:null,readOnly:!0})],y.prototype,"size",null),e([c({readOnly:!0})],y.prototype,"surface",void 0),e([c({readOnly:!0})],y.prototype,"suspended",void 0),e([c()],y.prototype,"ui",void 0),e([c({readOnly:!0})],y.prototype,"userContent",void 0),e([c({readOnly:!0})],y.prototype,"width",void 0),e([c()],y.prototype,"widthBreakpoint",void 0),y=e([p("esri.views.DOMContainer")],y),y};export{b as DOMContainer};
@@ -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){const i=()=>e("visible"===document.visibilityState);return document.addEventListener("visibilitychange",i),{remove:()=>document.addEventListener("visibilitychange",i)}}export{e as onVisibilityChange};
@@ -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{result as r}from"../../core/asyncUtils.js";import e from"../../core/Error.js";import{allSettledErrors as o,throwIfAborted as t,eachAlways as s}from"../../core/promiseUtils.js";import{generateUUID as a}from"../../core/uuid.js";import{getSiblingOfSameTypeI as c,contentToBlob as n}from"../../portal/support/resourceUtils.js";async function u(r,e,o=null){const t=await i(r,e,o);await h(t,e,o)}async function p(r,e,o,t,s=null){const a=await i(o,t,s);await r.update({data:e}),await h(a,t,s)}async function i(r,s,n=null){if(!s?.resources)return;const u=s.portalItem===r.portalItem?new Set(r.paths):new Set;r.paths.length=0,r.portalItem=s.portalItem;const p=new Set(s.resources.toKeep.map((r=>r.resource.path))),i=new Set,h=[];p.forEach((e=>{u.delete(e),r.paths.push(e)}));for(const e of s.resources.toUpdate)if(u.delete(e.resource.path),p.has(e.resource.path)||i.has(e.resource.path)){const{resource:o,content:t,finish:s,error:u}=e,p=c(o,a());r.paths.push(p.path),h.push(l({resource:p,content:t,compress:e.compress,finish:s,error:u},n))}else r.paths.push(e.resource.path),h.push(f(e,n)),i.add(e.resource.path);for(const e of s.resources.toAdd)r.paths.push(e.resource.path),u.has(e.resource.path)?u.delete(e.resource.path):h.push(l(e,n));if(0===h.length)return u;const m=await o(h);if(t(n),m.length>0)throw new e("save:resources","Failed to save one or more resources",{errors:m});return u}async function h(r,e,o=null){if(!r||!e.portalItem)return;const t=[];for(const s of r){const r=e.portalItem.resourceFromPath(s);t.push(r.portalItem.removeResource(r,o))}await s(t)}async function l(e,o){const t={...null!=o?o:{},compress:e.compress},s=await r(e.resource.portalItem.addResource(e.resource,await n(e.content),t));if(!0!==s.ok)throw e.error?.(s.error),s.error;e.finish?.(e.resource)}async function f(e,o){const t=await r(e.resource.update(await n(e.content),o));if(!0!==t.ok)throw e.error?.(t.error),t.error;e.finish?.(e.resource)}export{u as saveResources,p as updateItemWithResources};
5
+ import{result as e}from"../../core/asyncUtils.js";import r from"../../core/Error.js";import{allSettledErrors as o,throwIfAborted as t,eachAlways as s}from"../../core/promiseUtils.js";import{generateUUID as a}from"../../core/uuid.js";import{getSiblingOfSameTypeI as c,contentToBlob as n}from"../../portal/support/resourceUtils.js";async function u(e,r,o=null){const t=await i(e,r,o);await h(t,r,o)}async function p(e,r,o,t,s=null){const a=await i(o,t,s);await e.update({data:r}),await h(a,t,s)}async function i(e,s,n=null){if(!s?.resources)return;const u=s.portalItem===e.portalItem?new Set(e.paths):new Set;e.paths.length=0,e.portalItem=s.portalItem;const p=new Set(s.resources.toKeep.map((e=>e.resource.path))),i=new Set,h=[];p.forEach((r=>{u.delete(r),e.paths.push(r)}));for(const r of s.resources.toUpdate)if(u.delete(r.resource.path),p.has(r.resource.path)||i.has(r.resource.path)){const{resource:o,content:t,finish:s,error:u}=r,p=c(o,a());e.paths.push(p.path),h.push(f({resource:p,content:t,compress:r.compress,finish:s,error:u},n))}else e.paths.push(r.resource.path),h.push(l(r,n)),i.add(r.resource.path);for(const r of s.resources.toAdd)e.paths.push(r.resource.path),u.has(r.resource.path)?u.delete(r.resource.path):h.push(f(r,n));if(0===h.length)return u;const m=await o(h);if(t(n),m.length>0)throw new r("save:resources","Failed to save one or more resources",{errors:m});return u}async function h(e,r,o=null){if(!e||!r.portalItem)return;const t=[];for(const s of e){const e=r.portalItem.resourceFromPath(s);t.push(e.portalItem.removeResource(e,o))}await s(t)}async function f(r,o){const t={...null!=o?o:{},compress:r.compress},s=await e(r.resource.portalItem.addResource(r.resource,await n(r.content),t));if(!0!==s.ok)throw r.error?.(s.error),s.error;r.finish?.(r.resource)}async function l(r,o){const t=await e(r.resource.update(await n(r.content),o));if(!0!==t.ok)throw r.error?.(t.error),t.error;r.finish?.(r.resource)}async function m(e){const r=[];for(const o of e.allLayers)if("beforeSave"in o&&"function"==typeof o.beforeSave){const e=o.beforeSave();e&&r.push(e)}await Promise.allSettled(r)}export{m as beforeSave,u as saveResources,p as updateItemWithResources};
@@ -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{MultiOriginJSONSupport as t}from"../core/MultiOriginJSONSupport.js";import{whenOnce as r}from"../core/reactiveUtils.js";import{urlToObject as o,hasSameCanonicalPortal as a}from"../core/urlUtils.js";import{updateOrigins as i}from"../core/accessorSupport/originUtils.js";import n from"../geometry/SpatialReference.js";import{equals as s}from"../geometry/support/spatialReferenceUtils.js";import{webMercatorToGeographic as l}from"../geometry/support/webMercatorUtils.js";import{isServerOrServicesAGOLUrl as p}from"../layers/support/arcgisLayerUrl.js";import{isLayerWithFeatureLayerSource as c,isFeatureCollectionLayer as u}from"../layers/support/layerUtils.js";import m from"../portal/Portal.js";import d from"../portal/PortalItem.js";import{TypeKeyword as f,removeTypeKeyword as w,addTypeKeyword as y,hasTypeKeyword as g}from"../portal/support/portalItemUtils.js";import{project as h}from"../rest/geometryService/project.js";import b from"../rest/support/ProjectParameters.js";import{hasDeveloperBasemapLayer as v,findSpatialReference as _,isDeveloperBasemapLayer as R}from"../support/basemapUtils.js";import{validateSaveAPIKey as P}from"./saveAPIKeyUtils.js";import{saveResources as U}from"./support/saveUtils.js";const S=["NatGeo_World_Map","Ocean_Basemap","USA_Topo_Maps","World_Imagery","World_Street_Map","World_Terrain_Base","World_Topo_Map","World_Hillshade","Canvas/World_Light_Gray_Base","Canvas/World_Light_Gray_Reference","Canvas/World_Dark_Gray_Base","Canvas/World_Dark_Gray_Reference","Ocean/World_Ocean_Base","Ocean/World_Ocean_Reference","Reference/World_Boundaries_and_Places","Reference/World_Reference_Overlay","Reference/World_Transportation"].map((e=>e.toLowerCase()));async function W(e,t,a){a??={},j(e,t),await r((()=>!t.updatingFromView)),await t.load(),await M(t),await k(t),await O(e,t);const i=t.portalItem,n=o(i.itemUrl),s={origin:"web-map",messages:[],writtenProperties:[],url:n,portal:i.portal||m.getDefault(),portalItem:i,verifyItemRelativeUrls:n?{rootPath:n.path,writtenUrls:[]}:null,blockedRelativeUrls:[],resources:{toAdd:[],toUpdate:[],toKeep:[],pendingOperations:[]}},l=t.write({},s);return await Promise.all(s.resources.pendingOperations),D(e,s,a),await E(t,i),await ue(e,t,i,l,s),await Promise.all([t.updateItemThumbnail(),U(t.resourceReferences,s,null)]),i}async function I(e,t,o,a){a??={};const i=T(e,o);await r((()=>!t.updatingFromView)),await t.load(),await M(t),await k(t),await O(e,t);const n={origin:"web-map",messages:[],writtenProperties:[],url:null,portal:i.portal,portalItem:i,blockedRelativeUrls:[],resources:{toAdd:[],toUpdate:[],toKeep:[],pendingOperations:[]}},s=t.write({},n);await Promise.all(n.resources.pendingOperations),D(e,n,a),await z(t,i);const l=t.getThumbnailState();return await me(e,t,i,s,n,a)&&(t.resourceReferences.portalItem=i),t.restoreThumbnailFromState(l),await Promise.all([t.updateItemThumbnail(),U(t.resourceReferences,n,null)]),i}function j(t,r){if(!r.portalItem)throw new e(`${t.name}:portal-item-not-set`,"Portal item to save to has not been set on the WebMap");P(r.portalItem),A(t,r.portalItem)}function A(t,r){if(r.type!==t.itemType)throw new e(`${t.name}:portal-item-wrong-type`,`Portal item needs to have type "${t.itemType}"`)}async function O(t,o){if(!o.basemap?.baseLayers.length)throw new e(`${t.name}:save`,"Map does not have a valid basemap with a base layer.");let a=null;if(await r((()=>{const e=_(o.initialViewProperties,o.basemap);return a=e.spatialReference,!e.updating})),!s(a,o.initialViewProperties.spatialReference))throw new e(`${t.name}:save`,"The spatial reference of the basemap is not compatible with the one from the map.",{expected:o.initialViewProperties.spatialReference,actual:a})}function T(e,t){let r=d.from(t);return r.id&&(r=r.clone(),r.id=null),r.type||(r.type=e.itemType),r.portal||(r.portal=m.getDefault()),P(r),A(e,r),r}function M(e){const t=[];return e.basemap&&t.push(e.basemap.load()),e.ground&&t.push(e.ground.load()),Promise.allSettled(t).then((()=>{}))}async function k(e){const t=[];for(const r of e.allLayers)if("beforeSave"in r&&"function"==typeof r.beforeSave){const e=r.beforeSave();e&&t.push(e)}await Promise.allSettled(t)}function D(t,r,o){let a=(r.messages??[]).filter((e=>"error"===e.type)).map((t=>new e(t.name,t.message,t.details)));if(r.blockedRelativeUrls&&(a=a.concat(r.blockedRelativeUrls.map((t=>new e("url:unsupported",`Relative url '${t}' is not supported in Web Map`))))),o.ignoreUnsupported&&(a=a.filter((e=>"layer:unsupported"!==e.name&&"symbol:unsupported"!==e.name&&"symbol-layer:unsupported"!==e.name&&"property:unsupported"!==e.name&&"url:unsupported"!==e.name))),a.length>0)throw new e(`${t.name}:save`,"Failed to save webmap due to unsupported or invalid content. See 'details.errors' for more detailed information",{errors:a})}async function E(e,t){t.extent=await ne(e.portalItem,e.initialViewProperties.viewpoint.targetGeometry),await Q(e,t)}const V=f.JSAPI,C="CollectorDisabled",L="Collector",G="Data Editing",$="OfflineDisabled",B="Offline",K="Workforce Project",x="Workforce Worker",F="Workforce Dispatcher",N="Offline Map Areas",H="FieldMapsDisabled",J=f.DEVELOPER_BASEMAP,q="UtilityNetwork";async function z(e,t){w(t,C),w(t,H),w(t,f.METADATA),w(t,$),w(t,N),w(t,F),w(t,K),w(t,x),await E(e,t)}async function Q(e,t){y(t,V),await X(e),te(e,t),re(e,t),oe(e,t),ae(e,t),ie(e,t),t.typeKeywords&&(t.typeKeywords=t.typeKeywords.filter(((e,t,r)=>r.indexOf(e)===t)))}function X(e){const t=Y(e).map((e=>e.load())).toArray();return Promise.allSettled(t).then((()=>{}))}function Y(e){return e.allLayers.concat(e.allTables)}function Z(e){return Y(e).some((e=>e.loaded&&c(e)&&e.capabilities.operations.supportsEditing&&e.editingEnabled&&("subtype-group"!==e.type||e.sublayers.some((e=>e.editingEnabled)))))}function ee(e){return Y(e).filter((e=>"group"!==e.type)).every((t=>t.loaded&&pe(e,t)))}function te(e,t){g(t,C)||g(t,K)||g(t,x)||g(t,F)||!Z(e)?w(t,L):y(t,L)}function re(e,t){Z(e)?y(t,G):w(t,G)}function oe(e,t){!g(t,$)&&ee(e)?y(t,B):w(t,B)}function ae(e,t){v(e.basemap)?y(t,J):w(t,J)}function ie(e,t){e.utilityNetworks?.length?y(t,q):w(t,q)}async function ne(e,t){const r=t.clone().normalize();let o;if(r.length>1)for(const a of r)o?a.width>o.width&&(o=a):o=a;else o=r[0];return se(e,o)}async function se(e,t){const r=t.spatialReference;if(r.isWGS84)return t.clone();if(r.isWebMercator)return l(t);const{getGeometryServiceURL:o}=await import("../portal/support/geometryServiceUtils.js"),a=await o(e),i=new b;i.geometries=[t],i.outSpatialReference=n.WGS84;return(await h(a,i))[0]}function le(e){return u(e)||"map-notes"===e.type||"route"===e.type}function pe(e,t){return c(t)&&t.capabilities.operations.supportsSync||le(t)&&!t.portalItem||("tile"===t.type||"vector-tile"===t.type)&&(t.capabilities.operations.supportsExportTiles||ce(t)||R(t))&&t.spatialReference.equals(e.initialViewProperties.spatialReference)}function ce(e){return"tile"===e.type&&(p(e.url)&&S.some((t=>e.url?.toLowerCase().includes("/"+t+"/"))))}async function ue(e,t,r,o,a){await r.update({data:o}),we(e,t,r,o,a)}async function me(t,r,o,a,i,n){const s=r.portalItem,l={item:s,authenticated:!(!s?.id||!s.portal.user)},p=o.portal;await p.signIn();const{copyAllowed:c,itemReloaded:u}=await de(l,p);if(l.authenticated||=u,!c)throw new e(`${t.name}:save-as-copy-not-allowed`,"Owner of this map does not allow others to save a copy");const m=await fe(o,l,a,n);return r.portalItem=o,we(t,r,o,a,i),m}async function de(e,t){const{item:r,authenticated:o}=e;return r?.id&&r.typeKeywords?.includes("useOnly")?r.portal.portalHostname!==t.portalHostname?{copyAllowed:!1,itemReloaded:!1}:(o||await r.reload(),{copyAllowed:"admin"===r.itemControl||"update"===r.itemControl,itemReloaded:!0}):{copyAllowed:!0,itemReloaded:!1}}async function fe(e,t,r,o){const i=e.portal,{item:n}=t,{folder:s,copyAllResources:l}=o;let p=!1;if(l&&n?.id&&a(n.portal.url,i.url)&&parseInt(n.portal.currentVersion,10)>=2023){const{total:e}=await n.fetchResources();p=!!e}if(p){const t=await n.copy({copyResources:"all",folder:s});e.id=t.id,e.portal=t.portal;const o=e.toJSON();await e.load(),e.read(o),await e.update({data:r})}else await(i.user?.addItem({item:e,folder:s,data:r}));return p}function we(e,r,a,n,s){t.prototype.read.call(r,{version:n.version,authoringApp:n.authoringApp,authoringAppVersion:n.authoringAppVersion},{origin:e.origin,ignoreDefaults:!0,url:a.itemUrl?o(a.itemUrl):void 0}),i(s),r.resourceInfo=n}export{W as save,I as saveAs};
5
+ import e from"../core/Error.js";import{MultiOriginJSONSupport as t}from"../core/MultiOriginJSONSupport.js";import{whenOnce as r}from"../core/reactiveUtils.js";import{urlToObject as o,hasSameCanonicalPortal as a}from"../core/urlUtils.js";import{updateOrigins as i}from"../core/accessorSupport/originUtils.js";import n from"../geometry/SpatialReference.js";import{equals as s}from"../geometry/support/spatialReferenceUtils.js";import{webMercatorToGeographic as l}from"../geometry/support/webMercatorUtils.js";import{isServerOrServicesAGOLUrl as p}from"../layers/support/arcgisLayerUrl.js";import{isLayerWithFeatureLayerSource as c,isFeatureCollectionLayer as u}from"../layers/support/layerUtils.js";import m from"../portal/Portal.js";import d from"../portal/PortalItem.js";import{TypeKeyword as f,removeTypeKeyword as w,addTypeKeyword as y,hasTypeKeyword as g}from"../portal/support/portalItemUtils.js";import{project as h}from"../rest/geometryService/project.js";import b from"../rest/support/ProjectParameters.js";import{hasDeveloperBasemapLayer as _,findSpatialReference as v,isDeveloperBasemapLayer as R}from"../support/basemapUtils.js";import{validateSaveAPIKey as U}from"./saveAPIKeyUtils.js";import{beforeSave as P,saveResources as W}from"./support/saveUtils.js";const I=["NatGeo_World_Map","Ocean_Basemap","USA_Topo_Maps","World_Imagery","World_Street_Map","World_Terrain_Base","World_Topo_Map","World_Hillshade","Canvas/World_Light_Gray_Base","Canvas/World_Light_Gray_Reference","Canvas/World_Dark_Gray_Base","Canvas/World_Dark_Gray_Reference","Ocean/World_Ocean_Base","Ocean/World_Ocean_Reference","Reference/World_Boundaries_and_Places","Reference/World_Reference_Overlay","Reference/World_Transportation"].map((e=>e.toLowerCase()));async function j(e,t,a){a??={},S(e,t),await r((()=>!t.updatingFromView)),await t.load(),await k(t),await P(t),await T(e,t);const i=t.portalItem,n=o(i.itemUrl),s={origin:"web-map",messages:[],writtenProperties:[],url:n,portal:i.portal||m.getDefault(),portalItem:i,verifyItemRelativeUrls:n?{rootPath:n.path,writtenUrls:[]}:null,blockedRelativeUrls:[],resources:{toAdd:[],toUpdate:[],toKeep:[],pendingOperations:[]}},l=t.write({},s);return await Promise.all(s.resources.pendingOperations),D(e,s,a),await E(t,i),await ue(e,t,i,l,s),await Promise.all([t.updateItemThumbnail(),W(t.resourceReferences,s,null)]),i}async function A(e,t,o,a){a??={};const i=M(e,o);await r((()=>!t.updatingFromView)),await t.load(),await k(t),await P(t),await T(e,t);const n={origin:"web-map",messages:[],writtenProperties:[],url:null,portal:i.portal,portalItem:i,blockedRelativeUrls:[],resources:{toAdd:[],toUpdate:[],toKeep:[],pendingOperations:[]}},s=t.write({},n);await Promise.all(n.resources.pendingOperations),D(e,n,a),await z(t,i);const l=t.getThumbnailState();return await me(e,t,i,s,n,a)&&(t.resourceReferences.portalItem=i),t.restoreThumbnailFromState(l),await Promise.all([t.updateItemThumbnail(),W(t.resourceReferences,n,null)]),i}function S(t,r){if(!r.portalItem)throw new e(`${t.name}:portal-item-not-set`,"Portal item to save to has not been set on the WebMap");U(r.portalItem),O(t,r.portalItem)}function O(t,r){if(r.type!==t.itemType)throw new e(`${t.name}:portal-item-wrong-type`,`Portal item needs to have type "${t.itemType}"`)}async function T(t,o){if(!o.basemap?.baseLayers.length)throw new e(`${t.name}:save`,"Map does not have a valid basemap with a base layer.");let a=null;if(await r((()=>{const e=v(o.initialViewProperties,o.basemap);return a=e.spatialReference,!e.updating})),!s(a,o.initialViewProperties.spatialReference))throw new e(`${t.name}:save`,"The spatial reference of the basemap is not compatible with the one from the map.",{expected:o.initialViewProperties.spatialReference,actual:a})}function M(e,t){let r=d.from(t);return r.id&&(r=r.clone(),r.id=null),r.type||(r.type=e.itemType),r.portal||(r.portal=m.getDefault()),U(r),O(e,r),r}function k(e){const t=[];return e.basemap&&t.push(e.basemap.load()),e.ground&&t.push(e.ground.load()),Promise.allSettled(t).then((()=>{}))}function D(t,r,o){let a=(r.messages??[]).filter((e=>"error"===e.type)).map((t=>new e(t.name,t.message,t.details)));if(r.blockedRelativeUrls&&(a=a.concat(r.blockedRelativeUrls.map((t=>new e("url:unsupported",`Relative url '${t}' is not supported in Web Map`))))),o.ignoreUnsupported&&(a=a.filter((e=>"layer:unsupported"!==e.name&&"symbol:unsupported"!==e.name&&"symbol-layer:unsupported"!==e.name&&"property:unsupported"!==e.name&&"url:unsupported"!==e.name))),a.length>0)throw new e(`${t.name}:save`,"Failed to save webmap due to unsupported or invalid content. See 'details.errors' for more detailed information",{errors:a})}async function E(e,t){t.extent=await ne(e.portalItem,e.initialViewProperties.viewpoint.targetGeometry),await Q(e,t)}const V=f.JSAPI,C="CollectorDisabled",G="Collector",L="Data Editing",$="OfflineDisabled",B="Offline",K="Workforce Project",x="Workforce Worker",F="Workforce Dispatcher",N="Offline Map Areas",H="FieldMapsDisabled",J=f.DEVELOPER_BASEMAP,q="UtilityNetwork";async function z(e,t){w(t,C),w(t,H),w(t,f.METADATA),w(t,$),w(t,N),w(t,F),w(t,K),w(t,x),await E(e,t)}async function Q(e,t){y(t,V),await X(e),te(e,t),re(e,t),oe(e,t),ae(e,t),ie(e,t),t.typeKeywords&&(t.typeKeywords=t.typeKeywords.filter(((e,t,r)=>r.indexOf(e)===t)))}function X(e){const t=Y(e).map((e=>e.load())).toArray();return Promise.allSettled(t).then((()=>{}))}function Y(e){return e.allLayers.concat(e.allTables)}function Z(e){return Y(e).some((e=>e.loaded&&c(e)&&e.capabilities.operations.supportsEditing&&e.editingEnabled&&("subtype-group"!==e.type||e.sublayers.some((e=>e.editingEnabled)))))}function ee(e){return Y(e).filter((e=>"group"!==e.type)).every((t=>t.loaded&&pe(e,t)))}function te(e,t){g(t,C)||g(t,K)||g(t,x)||g(t,F)||!Z(e)?w(t,G):y(t,G)}function re(e,t){Z(e)?y(t,L):w(t,L)}function oe(e,t){!g(t,$)&&ee(e)?y(t,B):w(t,B)}function ae(e,t){_(e.basemap)?y(t,J):w(t,J)}function ie(e,t){e.utilityNetworks?.length?y(t,q):w(t,q)}async function ne(e,t){const r=t.clone().normalize();let o;if(r.length>1)for(const a of r)o?a.width>o.width&&(o=a):o=a;else o=r[0];return se(e,o)}async function se(e,t){const r=t.spatialReference;if(r.isWGS84)return t.clone();if(r.isWebMercator)return l(t);const{getGeometryServiceURL:o}=await import("../portal/support/geometryServiceUtils.js"),a=await o(e),i=new b;i.geometries=[t],i.outSpatialReference=n.WGS84;return(await h(a,i))[0]}function le(e){return u(e)||"map-notes"===e.type||"route"===e.type}function pe(e,t){return c(t)&&t.capabilities.operations.supportsSync||le(t)&&!t.portalItem||("tile"===t.type||"vector-tile"===t.type)&&(t.capabilities.operations.supportsExportTiles||ce(t)||R(t))&&t.spatialReference.equals(e.initialViewProperties.spatialReference)}function ce(e){return"tile"===e.type&&(p(e.url)&&I.some((t=>e.url?.toLowerCase().includes("/"+t+"/"))))}async function ue(e,t,r,o,a){await r.update({data:o}),we(e,t,r,o,a)}async function me(t,r,o,a,i,n){const s=r.portalItem,l={item:s,authenticated:!(!s?.id||!s.portal.user)},p=o.portal;await p.signIn();const{copyAllowed:c,itemReloaded:u}=await de(l,p);if(l.authenticated||=u,!c)throw new e(`${t.name}:save-as-copy-not-allowed`,"Owner of this map does not allow others to save a copy");const m=await fe(o,l,a,n);return r.portalItem=o,we(t,r,o,a,i),m}async function de(e,t){const{item:r,authenticated:o}=e;return r?.id&&r.typeKeywords?.includes("useOnly")?r.portal.portalHostname!==t.portalHostname?{copyAllowed:!1,itemReloaded:!1}:(o||await r.reload(),{copyAllowed:"admin"===r.itemControl||"update"===r.itemControl,itemReloaded:!0}):{copyAllowed:!0,itemReloaded:!1}}async function fe(e,t,r,o){const i=e.portal,{item:n}=t,{folder:s,copyAllResources:l}=o;let p=!1;if(l&&n?.id&&a(n.portal.url,i.url)&&parseInt(n.portal.currentVersion,10)>=2023){const{total:e}=await n.fetchResources();p=!!e}if(p){const t=await n.copy({copyResources:"all",folder:s});e.id=t.id,e.portal=t.portal;const o=e.toJSON();await e.load(),e.read(o),await e.update({data:r})}else await(i.user?.addItem({item:e,folder:s,data:r}));return p}function we(e,r,a,n,s){t.prototype.read.call(r,{version:n.version,authoringApp:n.authoringApp,authoringAppVersion:n.authoringAppVersion},{origin:e.origin,ignoreDefaults:!0,url:a.itemUrl?o(a.itemUrl):void 0}),i(s),r.resourceInfo=n}export{j as save,A as saveAs};
@@ -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 t}from"../../chunks/tslib.es6.js";import e from"../../core/Evented.js";import{property as o}from"../../core/accessorSupport/decorators/property.js";import{subclass as i}from"../../core/accessorSupport/decorators/subclass.js";import{directionalPadMoveOnceDuration as s}from"./constants.js";import{css as n}from"./css.js";import{angleToUnitVector as r,toUnitVector as v,vectorToClosestAngle as m}from"./utils.js";import{GoToMixin as a}from"../support/GoTo.js";let d=class extends(a(e.EventedAccessor)){constructor(t){super(t),this._initialAngle=void 0,this._movementVector=void 0,this._widgetCenter=void 0,this._anyAngleMovementEnabled=!1,this._movementTimeout=void 0,this._disabled=!1,this._moveOnceDuration=s,this.angle=void 0,this.speed=1,this.beginFollowingPointer=(t,e)=>{if(this.disabled)return;this._widgetCenter=e;const o=this._pointerLocationToVector(t);if(void 0===o)return;const i=this._resolveClosestAngle(t,o);void 0!==i&&(this._emitMove(r(i)),this.angle=i,this._initialAngle=i,this._setMovementTimeout((()=>{void 0===this._widgetCenter&&this._stopMovement()})),document.addEventListener("pointermove",this._onPointerMove,{passive:!0}),document.addEventListener("pointerup",this._onPointerUp,{passive:!0,once:!0}))},this.moveOnce=t=>{const e=r(t);this._emitMove(e),this._setMovementTimeout(this._stopMovement)},this._pointerLocationToVector=t=>{if(void 0===this._widgetCenter)return;const{x:e,y:o}=v(this._widgetCenter,t);return{x:e,y:-o}},this._resolveClosestAngle=(t,e)=>{const o=t.target,i=o?.getAttribute?.("data-angle"),s=o?.classList?.contains(n.compassButton);if(s)return;const r=Number.parseInt(i??"",10);return Number.isNaN(r)?m(e):r},this._onPointerMove=t=>{if(0===t.buttons)return void this._stopMovement();const e=this._pointerLocationToVector(t);if(void 0===e)return;this._setMovementTimeout(void 0);const o=this._resolveClosestAngle(t,e);if(void 0===o)return void this._emitStop();const i=r(o),s=null!=this._initialAngle&&this._initialAngle!==o;this._anyAngleMovementEnabled||=s;const n=this._anyAngleMovementEnabled?e:i;(n.x!==this._movementVector?.x||n.y!==this._movementVector?.y)&&(this.angle=o,this._emitMove(n))},this._onPointerUp=()=>{void 0===this._movementTimeout?this._stopMovement():this._widgetCenter=void 0},this._stopMovement=()=>{this._emitStop(),this._widgetCenter=void 0,this._initialAngle=void 0,this._anyAngleMovementEnabled=!1,document.removeEventListener("pointermove",this._onPointerMove),document.removeEventListener("pointerup",this._stopMovement),this._setMovementTimeout(void 0)},this.on("move-start",(()=>this.view?.mapViewNavigation.begin())),this.on("move-direction-change",(({vector:{x:t,y:e}})=>this.view?.mapViewNavigation.continuousPanVector({x:t*this.speed,y:e*this.speed}))),this.on("move-stop",(()=>this.view?.mapViewNavigation.stop()))}destroy(){this._stopMovement()}get disabled(){const{view:t,_disabled:e,supported:o}=this;return!1===t?.ready||e||!o}set disabled(t){this._disabled=t}get rotation(){return this.view?.rotation??this._get("rotation")??0}set rotation(t){this.view?this.view.constraints.rotationEnabled&&this.callGoTo({target:{rotation:t}}):this._set("rotation",t)}get supported(){return null==this.view||"2d"===this.view.type}get state(){const{disabled:t,angle:e}=this;return t?"disabled":null!=e?"moving":"ready"}_setMovementTimeout(t){clearTimeout(this._movementTimeout),this._movementTimeout=void 0===t?void 0:setTimeout((()=>{this._movementTimeout=void 0,t()}),this._moveOnceDuration)}_emitMove(t){null==this._movementVector&&this._emitMoveStartEvent({vector:t});const e=this._movementVector;this._movementVector=t,this._emitMoveDirectionChangeEvent({vector:t,oldVector:e})}_emitStop(){this.angle=void 0,void 0!==this._movementVector&&(this._emitMoveStopEvent({oldVector:this._movementVector}),this._movementVector=void 0)}_emitMoveStartEvent(t){this.emit("move-start",{...t,type:"move-start"})}_emitMoveDirectionChangeEvent(t){this.emit("move-direction-change",{...t,type:"move-direction-change"})}_emitMoveStopEvent(t){this.emit("move-stop",{...t,type:"move-stop"})}};t([o()],d.prototype,"_initialAngle",void 0),t([o()],d.prototype,"_movementVector",void 0),t([o()],d.prototype,"_widgetCenter",void 0),t([o()],d.prototype,"_anyAngleMovementEnabled",void 0),t([o()],d.prototype,"_movementTimeout",void 0),t([o()],d.prototype,"_disabled",void 0),t([o()],d.prototype,"_moveOnceDuration",void 0),t([o()],d.prototype,"disabled",null),t([o()],d.prototype,"angle",void 0),t([o({type:Number,range:{min:0,max:100}})],d.prototype,"speed",void 0),t([o()],d.prototype,"rotation",null),t([o()],d.prototype,"supported",null),t([o({readOnly:!0})],d.prototype,"state",null),t([o()],d.prototype,"view",void 0),d=t([i("esri.widgets.DirectionalPad.DirectionalPadViewModel")],d);const h=d;export{h as default};
5
+ import{_ as t}from"../../chunks/tslib.es6.js";import e from"../../core/Evented.js";import{property as o}from"../../core/accessorSupport/decorators/property.js";import{subclass as i}from"../../core/accessorSupport/decorators/subclass.js";import{directionalPadMoveOnceDuration as s}from"./constants.js";import{css as n}from"./css.js";import{angleToUnitVector as r,toUnitVector as v,vectorToClosestAngle as m}from"./utils.js";import{GoToMixin as a}from"../support/GoTo.js";let d=class extends(a(e.EventedAccessor)){constructor(t){super(t),this._initialAngle=void 0,this._movementVector=void 0,this._widgetCenter=void 0,this._anyAngleMovementEnabled=!1,this._movementTimeout=void 0,this._disabled=!1,this._moveOnceDuration=s,this.angle=void 0,this.speed=1,this.beginFollowingPointer=(t,e)=>{if(this.disabled)return;this._widgetCenter=e;const o=this._pointerLocationToVector(t);if(void 0===o)return;const i=this._resolveClosestAngle(t,o);void 0!==i&&(this._emitMove(r(i)),this.angle=i,this._initialAngle=i,this._setMovementTimeout((()=>{void 0===this._widgetCenter&&this._stopMovement()})),document.addEventListener("pointermove",this._onPointerMove,{passive:!0}),document.addEventListener("pointerup",this._onPointerUp,{passive:!0,once:!0}))},this.moveOnce=t=>{const e=r(t);this._emitMove(e),this._setMovementTimeout(this._stopMovement)},this._pointerLocationToVector=t=>{if(void 0===this._widgetCenter)return;const{x:e,y:o}=v(this._widgetCenter,t);return{x:e,y:-o}},this._resolveClosestAngle=(t,e)=>{const o=t.target,i=o?.getAttribute?.("data-angle"),s=o?.classList?.contains(n.compassButton);if(s)return;const r=Number.parseInt(i??"",10);return Number.isNaN(r)?m(e):r},this._onPointerMove=t=>{if(0===t.buttons)return void this._stopMovement();const e=this._pointerLocationToVector(t);if(void 0===e)return;this._setMovementTimeout(void 0);const o=this._resolveClosestAngle(t,e);if(void 0===o)return void this._emitStop();const i=r(o),s=null!=this._initialAngle&&this._initialAngle!==o;this._anyAngleMovementEnabled||=s;const n=this._anyAngleMovementEnabled?e:i;(n.x!==this._movementVector?.x||n.y!==this._movementVector?.y)&&(this.angle=o,this._emitMove(n))},this._onPointerUp=()=>{void 0===this._movementTimeout?this._stopMovement():this._widgetCenter=void 0},this._stopMovement=()=>{this._emitStop(),this._widgetCenter=void 0,this._initialAngle=void 0,this._anyAngleMovementEnabled=!1,document.removeEventListener("pointermove",this._onPointerMove),document.removeEventListener("pointerup",this._stopMovement),this._setMovementTimeout(void 0)},this.on("move-start",(()=>this.view?.mapViewNavigation.begin())),this.on("move-direction-change",(({vector:{x:t,y:e}})=>this.view?.mapViewNavigation.continuousPanVector({x:t*this.speed,y:e*this.speed}))),this.on("move-stop",(()=>this.view?.mapViewNavigation.stop()))}destroy(){this._stopMovement()}get disabled(){const{view:t,_disabled:e,supported:o}=this;return!1===t?.ready||e||!o}set disabled(t){this._disabled=t}get rotation(){return this.view?.rotation??this._get("rotation")??0}set rotation(t){this.view?this.view.constraints.rotationEnabled&&this.callGoTo({target:{rotation:t},options:{animate:0===t}}):this._set("rotation",t)}get supported(){return null==this.view||"2d"===this.view.type}get state(){const{disabled:t,angle:e}=this;return t?"disabled":null!=e?"moving":"ready"}_setMovementTimeout(t){clearTimeout(this._movementTimeout),this._movementTimeout=void 0===t?void 0:setTimeout((()=>{this._movementTimeout=void 0,t()}),this._moveOnceDuration)}_emitMove(t){null==this._movementVector&&this._emitMoveStartEvent({vector:t});const e=this._movementVector;this._movementVector=t,this._emitMoveDirectionChangeEvent({vector:t,oldVector:e})}_emitStop(){this.angle=void 0,void 0!==this._movementVector&&(this._emitMoveStopEvent({oldVector:this._movementVector}),this._movementVector=void 0)}_emitMoveStartEvent(t){this.emit("move-start",{...t,type:"move-start"})}_emitMoveDirectionChangeEvent(t){this.emit("move-direction-change",{...t,type:"move-direction-change"})}_emitMoveStopEvent(t){this.emit("move-stop",{...t,type:"move-stop"})}};t([o()],d.prototype,"_initialAngle",void 0),t([o()],d.prototype,"_movementVector",void 0),t([o()],d.prototype,"_widgetCenter",void 0),t([o()],d.prototype,"_anyAngleMovementEnabled",void 0),t([o()],d.prototype,"_movementTimeout",void 0),t([o()],d.prototype,"_disabled",void 0),t([o()],d.prototype,"_moveOnceDuration",void 0),t([o()],d.prototype,"disabled",null),t([o()],d.prototype,"angle",void 0),t([o({type:Number,range:{min:0,max:100}})],d.prototype,"speed",void 0),t([o()],d.prototype,"rotation",null),t([o()],d.prototype,"supported",null),t([o({readOnly:!0})],d.prototype,"state",null),t([o()],d.prototype,"view",void 0),d=t([i("esri.widgets.DirectionalPad.DirectionalPadViewModel")],d);const h=d;export{h as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- const o=[-45,0,45,-90,90,-135,180,135],n=[...o,-180],e={0:{label:"north",iconName:"chevron-up"},45:{label:"northEast",iconName:"chevron-up",iconRotation:45},90:{label:"east",iconName:"chevron-right"},135:{label:"southEast",iconName:"chevron-down",iconRotation:-45},180:{label:"south",iconName:"chevron-down"},"-135":{label:"southWest",iconName:"chevron-down",iconRotation:45},"-90":{label:"west",iconName:"chevron-left"},"-45":{label:"northWest",iconName:"chevron-up",iconRotation:-45}},t=200,a="";export{o as directionalPadAngles,e as directionalPadArrows,a as directionalPadCenterAngle,n as directionalPadCyclicalAngles,t as directionalPadMoveOnceDuration};
5
+ const e=[-45,0,45,-90,90,-135,180,135],o=[...e,-180],n={0:{label:"north",iconName:"chevron-up"},45:{label:"northEast",iconName:"chevron-up-right"},90:{label:"east",iconName:"chevron-right"},135:{label:"southEast",iconName:"chevron-down-right"},180:{label:"south",iconName:"chevron-down"},"-135":{label:"southWest",iconName:"chevron-down-left"},"-90":{label:"west",iconName:"chevron-left"},"-45":{label:"northWest",iconName:"chevron-up-left"}},t=200,a="";export{e as directionalPadAngles,n as directionalPadArrows,a as directionalPadCenterAngle,o as directionalPadCyclicalAngles,t as directionalPadMoveOnceDuration};
@@ -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 t}from"../chunks/tslib.es6.js";import{eventKey as e}from"../core/events.js";import{watch as i}from"../core/reactiveUtils.js";import{property as o}from"../core/accessorSupport/decorators/property.js";import"../core/accessorSupport/ensureType.js";import"../core/arrayUtils.js";import"../core/has.js";import{subclass as s}from"../core/accessorSupport/decorators/subclass.js";import n from"./Widget.js";import{canShowNorth as r}from"./Compass/utils.js";import{directionalPadAngles as a,directionalPadArrows as l}from"./DirectionalPad/constants.js";import{css as c}from"./DirectionalPad/css.js";import d from"./DirectionalPad/DirectionalPadViewModel.js";import{findElementCenter as p}from"./DirectionalPad/utils.js";import u from"./DirectionalPad/VisibleElements.js";import{loadCalciteComponents as h}from"./support/componentsUtils.js";import{globalCss as m}from"./support/globalCss.js";import{isActivationKey as v}from"./support/widgetUtils.js";import{messageBundle as b}from"./support/decorators/messageBundle.js";import{tsx as _}from"./support/jsxFactory.js";const g="esri.widgets.DirectionalPad";let w=class extends n{constructor(t,i){super(t,i),this._buttonsContainer=null,this._buttons={},this.iconClass=c.widgetIcon,this.icon=null,this.messages=null,this.visibleElements=new u,this.viewModel=new d,this.visualScale="s",this._rotateIcon=t=>({"--rotation":`rotate(${t}deg)`}),this._afterButtonContainerCreate=t=>{this._buttonsContainer=t,this._buttonsContainer.addEventListener("contextmenu",this._onContextMenu,{capture:!0})},this._afterButtonContainerRemoved=()=>{this._buttonsContainer?.removeEventListener("contextmenu",this._onContextMenu,{capture:!0}),this._buttonsContainer=null},this._afterButtonCreate=(t,e)=>{this._buttons[t]=e},this._afterButtonRemoved=t=>{this._buttons[t]=void 0},this._onContextMenu=t=>t.preventDefault(),this._onButtonPointerDown=t=>{if(null===this._buttonsContainer)return;const e=t.target,i=e?.shadowRoot?.querySelector("button");i?.hasPointerCapture(t.pointerId)&&i.releasePointerCapture(t.pointerId);const o=p(this._buttonsContainer);this.viewModel.beginFollowingPointer(t,o)},this._onKeyDown=(t,i)=>{const o=e(i);v(o)&&this.viewModel.moveOnce(t)},this._onSliderInput=({target:t})=>{"number"==typeof t.value&&(this.viewModel.rotation=t.value)},this._onRotationReset=()=>{this.viewModel.rotation=0}}loadDependencies(){return h({action:()=>import("@esri/calcite-components/dist/components/calcite-action.js"),"action-group":()=>import("@esri/calcite-components/dist/components/calcite-action-group.js"),"action-pad":()=>import("@esri/calcite-components/dist/components/calcite-action-pad.js"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon.js"),slider:()=>import("@esri/calcite-components/dist/components/calcite-slider.js")})}initialize(){this.addHandles(i((()=>this.viewModel.angle),(()=>{const t=this._buttonsContainer?.contains(document.activeElement);t&&(null==this.viewModel.angle?this.container?.focus():this._buttons[this.viewModel.angle]?.setFocus())})))}get disabled(){return this.viewModel.disabled}set disabled(t){this.viewModel.disabled=t}get label(){return this.messages?.widgetLabel??""}set label(t){this._overrideIfSome("label",t)}get view(){return this.viewModel.view}set view(t){this.viewModel.view=t}get speed(){return this.viewModel.speed}set speed(t){this.viewModel.speed=t}get _rotationEnabled(){return!this.view?.ready||this.view.constraints.rotationEnabled}render(){const{label:t,disabled:e,viewModel:i}=this,o=this.classes(c.base,m.widget,e?m.disabled:null);return _("div",{"aria-label":t,class:o,tabIndex:-1},i.supported?this._renderContent():this._renderUnsupportedMessage)}_renderUnsupportedMessage(){return _("section",{class:c.error,key:"unsupported"},_("p",null,this.messages.unsupported))}_renderContent(){return[this.visibleElements.directionalButtons?this._renderDirectionalButtons():void 0,this.visibleElements.rotationSlider?this._renderRotation():void 0]}_renderDirectionalButtons(){return _("calcite-action-pad",{expandDisabled:!0,key:"directional-buttons-container",layout:"grid"},_("calcite-action-group",{afterCreate:this._afterButtonContainerCreate,afterRemoved:this._afterButtonContainerRemoved,class:c.buttonsContainer},a.slice(0,4).map((t=>this._renderButton(t))),this._renderCompass(),a.slice(4).map((t=>this._renderButton(t)))))}_renderButton(t){const{label:e,iconName:i,iconRotation:o=0}=l[t];return _("calcite-action",{active:this.viewModel.angle===t,afterCreate:this._afterButtonCreate.bind(this,t),afterRemoved:this._afterButtonRemoved.bind(this,t),alignment:"center",class:c.button,"data-angle":t.toString(),disabled:this.disabled,key:t,onkeydown:this._onKeyDown.bind(void 0,t),onpointerdown:this._onButtonPointerDown,scale:this.visualScale,styles:this._rotateIcon(o),text:this.messages[e]},_("calcite-icon",{icon:i,scale:this.visualScale}))}_renderCompass(){const t=this.disabled||r(this.view)?"compass-needle":"arrow-up",e=0===this.viewModel.rotation;return _("calcite-action",{alignment:"center",class:c.compassButton,disabled:this.disabled||!this._rotationEnabled||e,key:"compass",onclick:this._onRotationReset,scale:this.visualScale,styles:this._rotateIcon(this.viewModel.rotation),text:this.messages.resetHeading},!e&&_("calcite-icon",{icon:t,scale:this.visualScale}))}_renderRotation(){return _("calcite-action-pad",{expandDisabled:!0,key:"slider-container",layout:"horizontal"},_("calcite-action-group",{class:c.rotationContainer},this.visibleElements.rotationResetButton?this._renderRotationResetButton():null,this._renderRotationSlider()))}_renderRotationResetButton(){return _("calcite-action",{alignment:"center",class:c.rotationReset,disabled:this.disabled||!this._rotationEnabled,onclick:this._onRotationReset,scale:this.visualScale,text:this.messages.resetHeading},_("calcite-icon",{flipRtl:!0,icon:"rotate",scale:this.visualScale}))}_renderRotationSlider(){return _("div",{class:c.rotationSliderContainer},_("calcite-slider",{"aria-label":this.messages.heading,disabled:this.disabled||!this._rotationEnabled,labelHandles:!0,max:360,min:0,required:!0,scale:this.visualScale,value:Math.round(this.viewModel.rotation),onCalciteSliderInput:this._onSliderInput}))}};t([o()],w.prototype,"_buttonsContainer",void 0),t([o()],w.prototype,"_buttons",void 0),t([o()],w.prototype,"disabled",null),t([o()],w.prototype,"iconClass",void 0),t([o()],w.prototype,"icon",void 0),t([o()],w.prototype,"label",null),t([o(),b("esri/widgets/DirectionalPad/t9n/DirectionalPad")],w.prototype,"messages",void 0),t([o({type:u,nonNullable:!0})],w.prototype,"visibleElements",void 0),t([o()],w.prototype,"view",null),t([o()],w.prototype,"viewModel",void 0),t([o()],w.prototype,"visualScale",void 0),t([o()],w.prototype,"speed",null),t([o({readOnly:!0})],w.prototype,"_rotationEnabled",null),w=t([s(g)],w);const f=w;export{f as default};
5
+ import{_ as t}from"../chunks/tslib.es6.js";import{eventKey as e}from"../core/events.js";import{watch as i}from"../core/reactiveUtils.js";import{property as o}from"../core/accessorSupport/decorators/property.js";import"../core/accessorSupport/ensureType.js";import"../core/arrayUtils.js";import"../core/has.js";import{subclass as s}from"../core/accessorSupport/decorators/subclass.js";import n from"./Widget.js";import{canShowNorth as r}from"./Compass/utils.js";import{directionalPadAngles as a,directionalPadArrows as l}from"./DirectionalPad/constants.js";import{css as c}from"./DirectionalPad/css.js";import d from"./DirectionalPad/DirectionalPadViewModel.js";import{findElementCenter as p}from"./DirectionalPad/utils.js";import u from"./DirectionalPad/VisibleElements.js";import{loadCalciteComponents as h}from"./support/componentsUtils.js";import{globalCss as m}from"./support/globalCss.js";import{isActivationKey as v}from"./support/widgetUtils.js";import{messageBundle as b}from"./support/decorators/messageBundle.js";import{tsx as _}from"./support/jsxFactory.js";const g="esri.widgets.DirectionalPad";let w=class extends n{constructor(t,i){super(t,i),this._buttonsContainer=null,this._buttons={},this.iconClass=c.widgetIcon,this.icon=null,this.messages=null,this.visibleElements=new u,this.viewModel=new d,this.visualScale="s",this._rotateIcon=t=>({"--rotation":`rotate(${t}deg)`}),this._afterButtonContainerCreate=t=>{this._buttonsContainer=t,this._buttonsContainer.addEventListener("contextmenu",this._onContextMenu,{capture:!0})},this._afterButtonContainerRemoved=()=>{this._buttonsContainer?.removeEventListener("contextmenu",this._onContextMenu,{capture:!0}),this._buttonsContainer=null},this._afterButtonCreate=(t,e)=>{this._buttons[t]=e},this._afterButtonRemoved=t=>{this._buttons[t]=void 0},this._onContextMenu=t=>t.preventDefault(),this._onButtonPointerDown=t=>{if(null===this._buttonsContainer)return;const e=t.target,i=e?.shadowRoot?.querySelector("button");i?.hasPointerCapture(t.pointerId)&&i.releasePointerCapture(t.pointerId);const o=p(this._buttonsContainer);this.viewModel.beginFollowingPointer(t,o)},this._onKeyDown=(t,i)=>{const o=e(i);v(o)&&this.viewModel.moveOnce(t)},this._onSliderInput=({target:t})=>{"number"==typeof t.value&&(this.viewModel.rotation=t.value)},this._onRotationReset=()=>{this.viewModel.rotation=0}}loadDependencies(){return h({action:()=>import("@esri/calcite-components/dist/components/calcite-action.js"),"action-group":()=>import("@esri/calcite-components/dist/components/calcite-action-group.js"),"action-pad":()=>import("@esri/calcite-components/dist/components/calcite-action-pad.js"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon.js"),slider:()=>import("@esri/calcite-components/dist/components/calcite-slider.js")})}initialize(){this.addHandles(i((()=>this.viewModel.angle),(()=>{const t=this._buttonsContainer?.contains(document.activeElement);t&&(null==this.viewModel.angle?this.container?.focus():this._buttons[this.viewModel.angle]?.setFocus())})))}get disabled(){return this.viewModel.disabled}set disabled(t){this.viewModel.disabled=t}get label(){return this.messages?.widgetLabel??""}set label(t){this._overrideIfSome("label",t)}get view(){return this.viewModel.view}set view(t){this.viewModel.view=t}get speed(){return this.viewModel.speed}set speed(t){this.viewModel.speed=t}get _rotationEnabled(){return!this.view?.ready||this.view.constraints.rotationEnabled}render(){const{label:t,disabled:e,viewModel:i}=this,o=this.classes(c.base,m.widget,e?m.disabled:null);return _("div",{"aria-label":t,class:o,tabIndex:-1},i.supported?this._renderContent():this._renderUnsupportedMessage)}_renderUnsupportedMessage(){return _("section",{class:c.error,key:"unsupported"},_("p",null,this.messages.unsupported))}_renderContent(){return[this.visibleElements.directionalButtons?this._renderDirectionalButtons():void 0,this.visibleElements.rotationSlider?this._renderRotation():void 0]}_renderDirectionalButtons(){return _("calcite-action-pad",{expandDisabled:!0,key:"directional-buttons-container",layout:"grid"},_("calcite-action-group",{afterCreate:this._afterButtonContainerCreate,afterRemoved:this._afterButtonContainerRemoved,class:c.buttonsContainer},a.slice(0,4).map((t=>this._renderButton(t))),this._renderCompass(),a.slice(4).map((t=>this._renderButton(t)))))}_renderButton(t){const{label:e,iconName:i}=l[t];return _("calcite-action",{active:this.viewModel.angle===t,afterCreate:this._afterButtonCreate.bind(this,t),afterRemoved:this._afterButtonRemoved.bind(this,t),alignment:"center",class:c.button,"data-angle":t.toString(),disabled:this.disabled,key:t,onkeydown:this._onKeyDown.bind(void 0,t),onpointerdown:this._onButtonPointerDown,scale:this.visualScale,text:this.messages[e]},_("calcite-icon",{icon:i,scale:this.visualScale}))}_renderCompass(){const t=this.disabled||r(this.view)?"compass-needle":"arrow-up",e=0===this.viewModel.rotation;return _("calcite-action",{alignment:"center",class:c.compassButton,disabled:this.disabled||!this._rotationEnabled||e,key:"compass",onclick:this._onRotationReset,scale:this.visualScale,styles:this._rotateIcon(this.viewModel.rotation),text:this.messages.resetHeading},!e&&_("calcite-icon",{icon:t,scale:this.visualScale}))}_renderRotation(){return _("calcite-action-pad",{expandDisabled:!0,key:"slider-container",layout:"horizontal"},_("calcite-action-group",{class:c.rotationContainer},this.visibleElements.rotationResetButton?this._renderRotationResetButton():null,this._renderRotationSlider()))}_renderRotationResetButton(){return _("calcite-action",{alignment:"center",class:c.rotationReset,disabled:this.disabled||!this._rotationEnabled,onclick:this._onRotationReset,scale:this.visualScale,text:this.messages.resetHeading},_("calcite-icon",{flipRtl:!0,icon:"rotate",scale:this.visualScale}))}_renderRotationSlider(){return _("div",{class:c.rotationSliderContainer},_("calcite-slider",{"aria-label":this.messages.heading,disabled:this.disabled||!this._rotationEnabled,labelHandles:!0,max:360,min:0,required:!0,scale:this.visualScale,value:Math.round(this.viewModel.rotation),onCalciteSliderInput:this._onSliderInput}))}};t([o()],w.prototype,"_buttonsContainer",void 0),t([o()],w.prototype,"_buttons",void 0),t([o()],w.prototype,"disabled",null),t([o()],w.prototype,"iconClass",void 0),t([o()],w.prototype,"icon",void 0),t([o()],w.prototype,"label",null),t([o(),b("esri/widgets/DirectionalPad/t9n/DirectionalPad")],w.prototype,"messages",void 0),t([o({type:u,nonNullable:!0})],w.prototype,"visibleElements",void 0),t([o()],w.prototype,"view",null),t([o()],w.prototype,"viewModel",void 0),t([o()],w.prototype,"visualScale",void 0),t([o()],w.prototype,"speed",null),t([o({readOnly:!0})],w.prototype,"_rotationEnabled",null),w=t([s(g)],w);const f=w;export{f as default};