@arcgis/core 4.30.0-next.20240213 → 4.30.0-next.20240215

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 (193) hide show
  1. package/TimeExtent.js +1 -1
  2. package/assets/esri/core/workers/RemoteClient.js +1 -1
  3. package/assets/esri/core/workers/chunks/08ba549f9c4afc42a21c.js +1 -0
  4. package/assets/esri/core/workers/chunks/114afcee6a66415cd123.js +1 -0
  5. package/assets/esri/core/workers/chunks/1320562881294ce93806.js +1 -0
  6. package/assets/esri/core/workers/chunks/13451fa3e4b02ca2beb0.js +1 -0
  7. package/assets/esri/core/workers/chunks/{a384f29cb3256401962a.js → 1629a8c2085dce59cd1b.js} +1 -1
  8. package/assets/esri/core/workers/chunks/18512caeeb03b9759ab1.js +1 -0
  9. package/assets/esri/core/workers/chunks/{cc1c958aad790a44048b.js → 1ca28af7c516d8283bb0.js} +1 -1
  10. package/assets/esri/core/workers/chunks/1f8a0fb32b96e50f5909.js +1 -0
  11. package/assets/esri/core/workers/chunks/{abab3abb8ea7610d9fb8.js → 21e7a88478f5d15e0e71.js} +1 -1
  12. package/assets/esri/core/workers/chunks/24452a26b0c5322c7d2b.js +1 -0
  13. package/assets/esri/core/workers/chunks/25b88787ead0cc44cda4.js +1 -0
  14. package/assets/esri/core/workers/chunks/2649166d1a462c7f8338.js +1 -0
  15. package/assets/esri/core/workers/chunks/2c96771a365f8f70e996.js +1 -0
  16. package/assets/esri/core/workers/chunks/352e7f8d694f3f217a2d.js +1 -0
  17. package/assets/esri/core/workers/chunks/392214a3a1d712eda155.js +1 -0
  18. package/assets/esri/core/workers/chunks/397f15b5bce6838db084.js +1 -0
  19. package/assets/esri/core/workers/chunks/3bf281e979408b9363ed.js +1 -0
  20. package/assets/esri/core/workers/chunks/4edc667148d023b5b5af.js +1 -0
  21. package/assets/esri/core/workers/chunks/51e4f771bfe352967c97.js +1 -0
  22. package/assets/esri/core/workers/chunks/55cd747e06bb59d1a328.js +1 -0
  23. package/assets/esri/core/workers/chunks/5638d95e600ff271c5b1.js +1 -0
  24. package/assets/esri/core/workers/chunks/563d172caa15ea1b510d.js +1108 -0
  25. package/assets/esri/core/workers/chunks/58f088b08e12c5435dbc.js +1 -0
  26. package/assets/esri/core/workers/chunks/5aef1e898618f8dda2c9.js +1 -0
  27. package/assets/esri/core/workers/chunks/608be8ebf772aefc36a5.js +1 -0
  28. package/assets/esri/core/workers/chunks/64df2521b2814d2fb918.js +1 -0
  29. package/assets/esri/core/workers/chunks/65070fb591f6ef8313c3.js +1 -0
  30. package/assets/esri/core/workers/chunks/656ec8a14df0e4b68433.js +1 -0
  31. package/assets/esri/core/workers/chunks/6601fe99d587b9dff3c7.js +1 -0
  32. package/assets/esri/core/workers/chunks/{274e623323e24250ca46.js → 6ac424af4f2825fabceb.js} +1 -1
  33. package/assets/esri/core/workers/chunks/{eb2d6f1ee63b40ae0736.js → 774b655498289b1b36bb.js} +1 -1
  34. package/assets/esri/core/workers/chunks/781bb63af571568358e3.js +1 -0
  35. package/assets/esri/core/workers/chunks/9e54d2cbe42f5552aaca.js +1 -0
  36. package/assets/esri/core/workers/chunks/{f03d62ab7806b68d0b62.js → 9fbf61675e2a5374f754.js} +1 -1
  37. package/assets/esri/core/workers/chunks/a5253543eae1708d11b9.js +1 -0
  38. package/assets/esri/core/workers/chunks/aa9b46bcb75c96731de3.js +1 -0
  39. package/assets/esri/core/workers/chunks/cfb8b6b5e9c21d582cf4.js +1 -0
  40. package/assets/esri/core/workers/chunks/d1b2372084c1e8c60f79.js +1 -0
  41. package/assets/esri/core/workers/chunks/{1c6914ded7db720f7bf7.js → daf6eab5dd198ca9a67b.js} +1 -1
  42. package/assets/esri/core/workers/chunks/e03edeaf3af46495449e.js +1 -0
  43. package/assets/esri/core/workers/chunks/e685214698fbc84276dd.js +1 -0
  44. package/assets/esri/core/workers/chunks/ebb294c82207f3ff9f04.js +1 -0
  45. package/assets/esri/core/workers/chunks/ec20e23aec9370df8a55.js +1 -0
  46. package/assets/esri/core/workers/chunks/{e4da908079417cc2f495.js → ee0c77889059815a31b2.js} +1 -1
  47. package/assets/esri/core/workers/chunks/f68b7bb88c444a7cbbd2.js +1 -0
  48. package/assets/esri/core/workers/chunks/f90bbebd2dc07a77ce09.js +1 -0
  49. package/assets/esri/core/workers/chunks/fa388680ff976a6b30f6.js +1 -0
  50. package/chunks/vec32.js +1 -1
  51. package/interfaces.d.ts +135 -68
  52. package/layers/WFSLayer.js +1 -1
  53. package/layers/buildingSublayers/BuildingComponentSublayer.js +1 -1
  54. package/layers/graphics/applyEditsUtils.js +1 -1
  55. package/layers/graphics/editingSupport.js +1 -1
  56. package/layers/graphics/sources/FeatureLayerSource.js +1 -1
  57. package/layers/mixins/ArcGISImageService.js +1 -1
  58. package/layers/save/featureLayerUtils.js +1 -1
  59. package/layers/support/arcgisLayers.js +1 -1
  60. package/layers/support/fetchService.js +1 -1
  61. package/layers/support/fromPortalItem.js +1 -1
  62. package/networks/Network.js +1 -1
  63. package/package.json +1 -1
  64. package/portal/Portal.js +1 -1
  65. package/portal/PortalGroup.js +1 -1
  66. package/portal/PortalUser.js +1 -1
  67. package/portal/support/geometryServiceUtils.js +1 -1
  68. package/portal/support/layersLoader.js +1 -1
  69. package/portal/support/loadUtils.js +1 -1
  70. package/portal/support/portalLayers.js +1 -1
  71. package/renderers/visualVariables/SizeVariable.js +1 -1
  72. package/rest/knowledgeGraph/wasmInterface/wasmToUpdateResponseFactories.js +1 -1
  73. package/rest/networks/support/Association.js +1 -1
  74. package/rest/places.js +1 -1
  75. package/rest/query/operations/pbfJSONFeatureSet.js +1 -1
  76. package/rest/support/ImageSampleParameters.js +1 -1
  77. package/smartMapping/support/adapters/FeatureLayerAdapter.js +1 -1
  78. package/smartMapping/support/adapters/SceneLayerAdapter.js +1 -1
  79. package/support/elevationInfoUtils.js +1 -1
  80. package/support/revision.js +1 -1
  81. package/symbols/cim/cimAnalyzer.js +1 -1
  82. package/symbols/cim/defaultCIMValues.js +1 -1
  83. package/symbols/cim/utils.js +1 -1
  84. package/views/2d/engine/vectorTiles/VectorTileContainer.js +1 -1
  85. package/views/2d/engine/webgl/AttributeStoreView.js +1 -1
  86. package/views/2d/engine/webgl/collisions/CollisionEngine.js +1 -1
  87. package/views/2d/engine/webgl/definitions.js +1 -1
  88. package/views/2d/engine/webgl/shaderGraph/techniques/labels/LabelMeshWriter.js +1 -1
  89. package/views/2d/engine/webgl/shaderGraph/techniques/markers/MarkerMeshWriter.js +1 -1
  90. package/views/2d/engine/webgl/shaderGraph/techniques/text/TextMeshWriter.js +1 -1
  91. package/views/2d/engine/webgl/shaders/sources/shaderRepository.js +1 -1
  92. package/views/2d/layers/FeatureLayerView2D.js +1 -1
  93. package/views/2d/layers/features/FeaturePipelineWorker.js +1 -1
  94. package/views/2d/layers/features/Processor.js +1 -1
  95. package/views/2d/layers/features/processor/BinningStrategy.js +1 -1
  96. package/views/2d/layers/features/processor/ClusterStrategy.js +1 -1
  97. package/views/2d/layers/features/processor/FeatureUpdateStrategy.js +1 -1
  98. package/views/2d/layers/features/schema/processor/VisualVariablesSchema.js +1 -1
  99. package/views/2d/layers/features/sources/strategies/SnapshotLoadStrategy.js +1 -1
  100. package/views/2d/layers/features/support/AttributeStore.js +1 -1
  101. package/views/2d/layers/features/support/DisplayIdGenerator.js +1 -1
  102. package/views/2d/layers/graphics/GraphicsView2D.js +1 -1
  103. package/views/3d/interactive/measurementTools/directLineMeasurement3D/DirectLineMeasurement3DView.js +1 -1
  104. package/views/3d/layers/BuildingComponentSublayerView3D.js +1 -1
  105. package/views/3d/layers/IntegratedMeshLayerView3D.js +1 -1
  106. package/views/3d/layers/SceneLayerView3D.js +1 -1
  107. package/views/3d/layers/graphics/Graphics3DMeshFillSymbolLayer.js +1 -1
  108. package/views/3d/layers/graphics/objectResourceUtils.js +1 -1
  109. package/views/3d/layers/support/FastSymbolUpdates.js +1 -1
  110. package/views/3d/layers/support/FeatureTileVisibility3D.js +1 -1
  111. package/views/3d/state/helpers/SceneIntersectionHelper.js +1 -1
  112. package/views/3d/support/orientedBoundingBox.js +1 -1
  113. package/views/3d/terrain/OverlayFramebufferObject.js +1 -1
  114. package/views/3d/terrain/OverlayRenderer.js +1 -1
  115. package/views/3d/webgl/RenderNode.js +1 -1
  116. package/views/3d/webgl-engine/collections/Component/Material/ComponentTechniqueConfiguration.js +1 -1
  117. package/views/3d/webgl-engine/core/FBOCache.js +1 -1
  118. package/views/3d/webgl-engine/core/shaderLibrary/shading/ComputeNormalTexture.glsl.js +9 -7
  119. package/views/3d/webgl-engine/core/shaderLibrary/shading/ScreenSpaceConstants.js +5 -0
  120. package/views/3d/webgl-engine/core/shaderLibrary/shading/Water.glsl.js +8 -8
  121. package/views/3d/webgl-engine/effects/debug/RenderNodeVisualizerNode.js +1 -1
  122. package/views/3d/webgl-engine/effects/highlight/Highlight.js +1 -1
  123. package/views/3d/webgl-engine/effects/smaa/SMAA.js +1 -1
  124. package/views/3d/webgl-engine/effects/ssao/SSAO.js +1 -1
  125. package/views/3d/webgl-engine/lib/GLTextureMaterial.js +1 -1
  126. package/views/3d/webgl-engine/lib/ObjectAndLayerIdRenderHelper.js +1 -1
  127. package/views/draw/DrawGraphicTool.js +1 -1
  128. package/views/draw/DrawOperation.js +1 -1
  129. package/views/draw/drawSurfaces.js +1 -1
  130. package/views/interactive/snapping/SnappingManager.js +1 -1
  131. package/views/interactive/snapping/SnappingOptions.js +1 -1
  132. package/views/interactive/snapping/featureSources/FeatureServiceSnappingSource.js +1 -1
  133. package/views/interactive/snapping/featureSources/featureServiceSource/FeatureServiceSnappingSourceWorker.js +1 -1
  134. package/views/layers/ImageryTileLayerView.js +1 -1
  135. package/webdoc/support/webdocLoadUtils.js +1 -1
  136. package/webdoc/support/webdocSaveUtils.js +1 -1
  137. package/widgets/Editor/CreateFeaturesWorkflow.js +1 -1
  138. package/widgets/Editor/EditorViewModel.js +1 -1
  139. package/widgets/Editor/UpdateFeatureWorkflow.js +1 -1
  140. package/widgets/Editor/UpdateWorkflow.js +1 -1
  141. package/widgets/Editor/components/FooterActions.js +1 -1
  142. package/widgets/Editor/support/EditorItem.js +1 -1
  143. package/widgets/Editor.js +1 -1
  144. package/widgets/FeatureForm.js +1 -1
  145. package/widgets/FeatureTable/FeatureTableViewModel.js +1 -1
  146. package/widgets/FeatureTable/Grid/Grid.js +1 -1
  147. package/widgets/FeatureTable/Grid/GridViewModel.js +1 -1
  148. package/widgets/FeatureTable.js +1 -1
  149. package/widgets/Features/FeaturesViewModel.js +1 -1
  150. package/widgets/Legend/support/ActiveLayerInfo.js +1 -1
  151. package/widgets/Print/PrintViewModel.js +1 -1
  152. package/widgets/Print.js +1 -1
  153. package/widgets/Search/support/locatorUtils.js +1 -1
  154. package/widgets/Sketch/SketchViewModel.js +1 -1
  155. package/assets/esri/core/workers/chunks/00b9e92f8df245a83921.js +0 -1
  156. package/assets/esri/core/workers/chunks/02a6c43ec17e7223fac5.js +0 -1
  157. package/assets/esri/core/workers/chunks/02ee044597c89c86b934.js +0 -1
  158. package/assets/esri/core/workers/chunks/05ebb9cec0e1826b283f.js +0 -1
  159. package/assets/esri/core/workers/chunks/143ccb14c9e915dd1412.js +0 -1
  160. package/assets/esri/core/workers/chunks/24649b410b757599a549.js +0 -1
  161. package/assets/esri/core/workers/chunks/24d19abc680b341d13bb.js +0 -1
  162. package/assets/esri/core/workers/chunks/2519b207894132d5ea91.js +0 -1
  163. package/assets/esri/core/workers/chunks/30f9b2a3417cbcfeecca.js +0 -1
  164. package/assets/esri/core/workers/chunks/42ab9c282bb267c3db03.js +0 -1
  165. package/assets/esri/core/workers/chunks/478815fc19b452d8317d.js +0 -1
  166. package/assets/esri/core/workers/chunks/49afeac45250b15b5f36.js +0 -1
  167. package/assets/esri/core/workers/chunks/50bb67f2eeace5d50673.js +0 -1
  168. package/assets/esri/core/workers/chunks/50cdc59426ba859027e2.js +0 -1
  169. package/assets/esri/core/workers/chunks/5401ec9c9fd62dcac6ec.js +0 -1
  170. package/assets/esri/core/workers/chunks/554d86df71821d671d2c.js +0 -1
  171. package/assets/esri/core/workers/chunks/58c5861d060c808813a1.js +0 -1
  172. package/assets/esri/core/workers/chunks/5dbb3ef6fdd25ac632ad.js +0 -1
  173. package/assets/esri/core/workers/chunks/61c4bb58ef9f2d99c75e.js +0 -1
  174. package/assets/esri/core/workers/chunks/6e50220f8e2d392e2855.js +0 -1
  175. package/assets/esri/core/workers/chunks/6fd8047741a0df006ddd.js +0 -1
  176. package/assets/esri/core/workers/chunks/7709248f59520aee6f51.js +0 -1
  177. package/assets/esri/core/workers/chunks/8852a64918caf80fc414.js +0 -1
  178. package/assets/esri/core/workers/chunks/8d119dc0a92ad3612daa.js +0 -1
  179. package/assets/esri/core/workers/chunks/94dfb80ab23dda92918b.js +0 -1
  180. package/assets/esri/core/workers/chunks/9ebbc75ba5c623a322aa.js +0 -1
  181. package/assets/esri/core/workers/chunks/a5babc10f47c24651d15.js +0 -1
  182. package/assets/esri/core/workers/chunks/a74c59cf5d1c4e63a4e1.js +0 -1
  183. package/assets/esri/core/workers/chunks/ada5d6fd70bd3e403442.js +0 -1
  184. package/assets/esri/core/workers/chunks/b95d69d84d60ac9828b9.js +0 -1
  185. package/assets/esri/core/workers/chunks/be562536212360943388.js +0 -1
  186. package/assets/esri/core/workers/chunks/ce823fc2d0e0095f398c.js +0 -1
  187. package/assets/esri/core/workers/chunks/d06d36815c2121484a13.js +0 -1
  188. package/assets/esri/core/workers/chunks/d5f06a7b0ea7951c8dd0.js +0 -1
  189. package/assets/esri/core/workers/chunks/ddc71fe66c7a49082920.js +0 -1
  190. package/assets/esri/core/workers/chunks/de6d54df7ae32694fd70.js +0 -1
  191. package/assets/esri/core/workers/chunks/f13c4b9692dad5802a32.js +0 -1106
  192. package/assets/esri/core/workers/chunks/f1e8f7d1a98b9e207b1b.js +0 -1
  193. package/assets/esri/core/workers/chunks/f9e9675f1c2287231653.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.30/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../chunks/tslib.es6.js";import r from"../../../Graphic.js";import has from"../../../core/has.js";import{initial as t}from"../../../core/reactiveUtils.js";import{property as o}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as s}from"../../../core/accessorSupport/decorators/subclass.js";import{I3SMeshView3D as i}from"./I3SMeshView3D.js";import{DrapeTargetType as a}from"./interfaces.js";import{LayerView3D as n}from"./LayerView3D.js";import{updatingProgress as l}from"../support/updatingProperties.js";import p from"../../layers/LayerView.js";const d=.2;let c=class extends(i(n(p))){constructor(){super(...arguments),this.type="integrated-mesh-3d",this._elevationContext="im",this._isIntegratedMesh=!0,this._supportsLabeling=!1,this._needsNormals=has("enable-feature:im-shading"),this.drapeTargetType=a.WithoutRasterImage}get i3slayer(){return this.layer}get updatingProgressValue(){return this._controller?.updatingProgress??0}get lodFactor(){return this.view?.qualitySettings?.sceneService?.integratedMesh?.lodFactor??1}get progressiveLoadFactor(){return this.lodFactor>=1?d:1}get layerPopupEnabledAndHasTemplate(){return!1}initialize(){this._updatingHandles.add((()=>this.layer.modifications),(()=>this._loadModifications()),t),this.view.basemapTerrain.overlayManager.registerDrapeTarget(this)}destroy(){this.view.basemapTerrain.overlayManager.unregisterDrapeTarget(this)}_createLayerGraphic(){const e=new r;return e.layer=this.layer,e.sourceLayer=this.layer,e}canResume(){return super.canResume()&&(!this._controller||this._controller.rootNodeVisible)}_loadModifications(){if(this.removeHandles("modifications"),null==this.layer.modifications)return void(this._modifications=[]);const e=this.layer.modifications;this.addHandles(this._updatingHandles.addOnCollectionChange((()=>e),(()=>this._modifications=e.toArray()),t),"modifications")}};e([o()],c.prototype,"layer",void 0),e([o()],c.prototype,"i3slayer",null),e([o(l)],c.prototype,"updatingProgress",void 0),e([o()],c.prototype,"updatingProgressValue",null),e([o()],c.prototype,"lodFactor",null),e([o({readOnly:!0})],c.prototype,"progressiveLoadFactor",null),c=e([s("esri.views.3d.layers.SceneLayerView3D")],c);const m=c;export{m as default};
5
+ import{_ as e}from"../../../chunks/tslib.es6.js";import r from"../../../Graphic.js";import has from"../../../core/has.js";import{initial as t}from"../../../core/reactiveUtils.js";import{property as o}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as s}from"../../../core/accessorSupport/decorators/subclass.js";import{I3SMeshView3D as i}from"./I3SMeshView3D.js";import{DrapeTargetType as a}from"./interfaces.js";import{LayerView3D as n}from"./LayerView3D.js";import{updatingProgress as l}from"../support/updatingProperties.js";import p from"../../layers/LayerView.js";const d=.2;let c=class extends(i(n(p))){constructor(){super(...arguments),this.type="integrated-mesh-3d",this._elevationContext="im",this._isIntegratedMesh=!0,this._supportsLabeling=!1,this._needsNormals=has("enable-feature:im-shading"),this.drapeTargetType=a.WithoutRasterImage}get i3slayer(){return this.layer}get updatingProgressValue(){return this._controller?.updatingProgress??0}get lodFactor(){return this.view?.qualitySettings?.sceneService?.integratedMesh?.lodFactor??1}get progressiveLoadFactor(){return this.lodFactor>=1?d:1}get layerPopupEnabledAndHasTemplate(){return!1}initialize(){this._updatingHandles.add((()=>this.layer.modifications),(()=>this._loadModifications()),t),this.view.basemapTerrain.overlayManager.registerDrapeTarget(this)}destroy(){this.view.basemapTerrain.overlayManager.unregisterDrapeTarget(this)}_createLayerGraphic(){return new r({layer:this.layer,sourceLayer:this.layer})}canResume(){return super.canResume()&&(!this._controller||this._controller.rootNodeVisible)}_loadModifications(){if(this.removeHandles("modifications"),null==this.layer.modifications)return void(this._modifications=[]);const e=this.layer.modifications;this.addHandles(this._updatingHandles.addOnCollectionChange((()=>e),(()=>this._modifications=e.toArray()),t),"modifications")}};e([o()],c.prototype,"layer",void 0),e([o()],c.prototype,"i3slayer",null),e([o(l)],c.prototype,"updatingProgress",void 0),e([o()],c.prototype,"updatingProgressValue",null),e([o()],c.prototype,"lodFactor",null),e([o({readOnly:!0})],c.prototype,"progressiveLoadFactor",null),c=e([s("esri.views.3d.layers.SceneLayerView3D")],c);const m=c;export{m 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.30/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../Graphic.js";import i from"../../../core/Logger.js";import{destroyMaybe as r}from"../../../core/maybe.js";import s from"../../../core/ReactiveSet.js";import{initial as l}from"../../../core/reactiveUtils.js";import{property as n}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/RandomLCG.js";import{subclass as o}from"../../../core/accessorSupport/decorators/subclass.js";import{WhereClause as d}from"../../../core/sql/WhereClause.js";import a from"../../../layers/support/FeatureFilter.js";import{getFloorFilterClause as u}from"../../../layers/support/floorFilterUtils.js";import h from"../../../rest/support/Query.js";import{sceneLayerEditingEnabled as p}from"../../../support/featureFlags.js";import{I3SMeshView3D as c}from"./I3SMeshView3D.js";import{ForAllFeaturesMode as y}from"./II3SMeshView3D.js";import{LayerView3D as g}from"./LayerView3D.js";import{createInteractiveEditSession as m,normalizeEditResultsEvent as f,processGeometryEdits as _,processAttributeEdits as F}from"./i3s/featureEditing.js";import{createGetFeatureExtent as b}from"./i3s/I3SGeometryUtil.js";import{I3SMeshViewFilter as j}from"./i3s/I3SMeshViewFilter.js";import{NodeFilterImpact as I}from"./i3s/I3SNode.js";import{I3SOverrides as v}from"./i3s/I3SOverrides.js";import{I3SQueryEngine as w}from"./i3s/I3SQueryEngine.js";import{I3SQueryFeatureAdapter as S}from"./i3s/I3SQueryFeatureAdapter.js";import{I3SQueryFeatureStore as E}from"./i3s/I3SQueryFeatureStore.js";import{checkRecyclable as O,getIndexCrs as H,objectIdFilter as x}from"./i3s/I3SUtil.js";import{DefinitionExpressionSceneLayerView as C}from"./support/DefinitionExpressionSceneLayerView.js";import{defineFieldProperties as Q}from"./support/fieldProperties.js";import{PopupSceneLayerView as V}from"./support/PopupSceneLayerView.js";import{SceneLayerViewRequiredFields as q}from"./support/SceneLayerViewRequiredFields.js";import{TemporalSceneLayerView as L}from"./support/TemporalSceneLayerView.js";import{updatingProgress as R}from"../support/updatingProperties.js";import D from"../../layers/SceneLayerView.js";import{hasPopupTemplate as A}from"../../layers/support/popupUtils.js";import{TaskPriority as G}from"../../support/Scheduler.js";const U=Q();let P=class extends(c(L(C(V(g(D)))))){constructor(){super(...arguments),this.type="scene-layer-3d",this._setVisibilityHiddenObjectIds=new s,this.progressiveLoadFactor=1,this._elevationContext="scene",this._isIntegratedMesh=!1,this._supportsLabeling=!0,this._pendingEditsQueue=Promise.resolve(),this._interactiveEditingSessions=new Map,this._queryEngine=null}get i3slayer(){return this.layer}tryRecycleWith(e,t){return e.url===this.layer.url&&this.i3sOverrides.isEmpty?e.load(t).then((()=>{O(this.layer,e,this.i3sOverrides),this.layer=e,this.i3sOverrides.destroy();const t=this.view.resourceController?.memoryController;this.i3sOverrides=new v({view:this.view,layer:e,memoryController:t}),this.resetHighlights()})):null}get layerPopupEnabledAndHasTemplate(){return this.layer.popupEnabled&&A(this.layer,this.view.popup?.defaultPopupTemplateEnabled)}get filter(){return this._get("filter")}set filter(e){this._set("filter",j.checkSupport(e)?e:null)}get viewFilter(){const e=this.mergedFilter,t=this.layerFilter;if(null==e&&null==t)return null;const i=this._get("viewFilter");return null==i?new j({layerFilter:t,viewFilter:e,layerFieldsIndex:this.layer.fieldsIndex,loadAsyncModule:e=>this._loadAsyncModule(e),addSqlFilter:(e,t)=>this.addSqlFilter(e,t,this.logError),addTimeFilter:(e,t)=>this.addTimeFilter(e,t)}):(i.viewFilter=e,i.layerFilter=t,i)}get requiredFields(){return this._fieldsHelper?.requiredFields??[]}get _floorFilterClause(){const e=u(this);return null!=e?d.create(e,this.layer.fieldsIndex):null}get _excludeObjectIdsSorted(){const e=this.layer.excludeObjectIds.toArray();return e.length?e.sort(((e,t)=>e-t)):null}get _setVisibilityHiddenObjectIdsSorted(){return this._setVisibilityHiddenObjectIds.size?Array.from(this._setVisibilityHiddenObjectIds).sort(((e,t)=>e-t)):null}get lodFactor(){return this.view?.qualitySettings?.sceneService?.object?.lodFactor??1}get lodCrossfadeUncoveredDuration(){return this.view?.qualitySettings?.fadeDuration??0}get updatingProgressValue(){return this._controller?.updatingProgress??0}initialize(){this._fieldsHelper=new q({layerView:this}),this._updatingHandles.add((()=>this.layer.rangeInfos),(e=>this._rangeInfosChanged(e)),l),this._updatingHandles.add((()=>this.layer.renderer),(e=>this._updatingHandles.addPromise(this._rendererChange(e))),l);const e=()=>this._filterChange();this._updatingHandles.add((()=>this.parsedDefinitionExpression),e),this._updatingHandles.add((()=>this.mergedFilter),e),this._updatingHandles.add((()=>this._floorFilterClause),e),this._updatingHandles.add((()=>this._excludeObjectIdsSorted),e),this._updatingHandles.add((()=>this._setVisibilityHiddenObjectIdsSorted),e),this._updatingHandles.add((()=>this.viewFilter?.sortedObjectIds),e),this._updatingHandles.add((()=>this.viewFilter?.parsedWhereClause),e),this._updatingHandles.add((()=>this.getTimeFilterDependencies()),e),this._updatingHandles.add((()=>[this.viewFilter?.parsedGeometry,this.mergedFilter?.spatialRelationship,this.layer.filter?.spatialRelationship]),(()=>this._geometryFilterChange())),p()&&this.i3sOverrides.is3DOFL&&this._updatingHandles.add((()=>this.i3sOverrides.sortedGeometryChangedObjectIds),e),this.addHandles(this.layer.on("apply-edits",(e=>this._updatingHandles.addPromise(e.result)))),this.addHandles(this.layer.on("edits",(e=>{const t=this._pendingEditsQueue.then((()=>this._handleEdits(e))).then();this._pendingEditsQueue=t,this._updatingHandles.addPromise(t)})))}destroy(){this._fieldsHelper=r(this._fieldsHelper)}_rangeInfosChanged(e){null!=e&&e.length>0&&i.getLogger(this).warn("Unsupported property: rangeInfos are currently only serialized to and from web scenes but do not affect rendering.")}createQuery(){const e={outFields:["*"],returnGeometry:!1,outSpatialReference:this.view.spatialReference};return this.mergedFilter?.createQuery(e)??new h(e)}queryExtent(e,t){return this._ensureQueryEngine().executeQueryForExtent(this._ensureQuery(e),t?.signal)}queryFeatureCount(e,t){return this._ensureQueryEngine().executeQueryForCount(this._ensureQuery(e),t?.signal)}queryFeatures(e,t){return this._ensureQueryEngine().executeQuery(this._ensureQuery(e),t?.signal).then((e=>{if(!e?.features)return e;const t=this.layer;for(const i of e.features)i.layer=t,i.sourceLayer=t;return e}))}queryObjectIds(e,t){return this._ensureQueryEngine().executeQueryForIds(this._ensureQuery(e),t?.signal)}_ensureQueryEngine(){return this._queryEngine||(this._queryEngine=this._createQueryEngine()),this._queryEngine}_createQueryEngine(){const e=b(this.view.spatialReference,this.view.renderSpatialReference,this._collection);return new w({layerView:this,priority:G.FEATURE_QUERY_ENGINE,spatialIndex:new E({featureAdapter:new S({objectIdField:this.layer.objectIdField,attributeStorageInfo:this.layer.attributeStorageInfo??[],getFeatureExtent:e}),forAllFeatures:(e,t)=>this._forAllFeatures(((t,i,r)=>e({id:t,index:i,meta:r})),t,y.QUERYABLE),getFeatureExtent:e,sourceSpatialReference:H(this.layer),viewSpatialReference:this.view.spatialReference})})}highlight(e){const t=this._highlights;if(e instanceof h){const{set:i,handle:r}=t.acquireSet();return this.queryObjectIds(e).then((e=>t.setFeatureIds(i,e))),r}return super.highlight(e)}createInteractiveEditSession(e){return m(this._attributeEditingContext,e)}_createLayerGraphic(e){const i=new t(null,null,e);return i.layer=this.layer,i.sourceLayer=this.layer,i}getFilters(){const e=super.getFilters();p()&&this.i3sOverrides.is3DOFL&&this.i3sOverrides.sortedGeometryChangedObjectIds.length>0&&e.push(((e,t)=>{t.node.index>=0&&x(this.i3sOverrides.sortedGeometryChangedObjectIds,!1,e)}));const t=this._setVisibilityHiddenObjectIdsSorted;null!=t&&e.push((e=>x(t,!1,e)));const i=this._excludeObjectIdsSorted;return null!=i&&e.push((e=>x(i,!1,e))),this._floorFilterClause&&this.addSqlFilter(e,this._floorFilterClause,this.logError),this.addSqlFilter(e,this.parsedDefinitionExpression,this.logError),null!=this.viewFilter&&this.viewFilter.addFilters(e,this.view,this._controller.crsIndex,this._collection),e}setVisibility(e,t){t?this._setVisibilityHiddenObjectIds.delete(e):this._setVisibilityHiddenObjectIds.add(e)}isUpdating(){return super.isUpdating()||this.layerFilterUpdating||null!=this.viewFilter&&this.viewFilter.updating||null!=this.i3sOverrides&&this.i3sOverrides.updating}_ensureQuery(e){return this._addDefinitionExpressionToQuery(null==e?this.createQuery():h.from(e))}get _attributeEditingContext(){return{sessions:this._interactiveEditingSessions,fieldsIndex:this.layer.fieldsIndex,objectIdField:this._getObjectIdField(),globalIdField:this._getGlobalIdField(),forEachNode:e=>this._forAllNodes((t=>null!=t?e(t.node,t.featureIds):null)),attributeStorageInfo:this.i3slayer.attributeStorageInfo??[],i3sOverrides:this.i3sOverrides,getAttributeData:e=>this.getAttributeData(e),setAttributeData:(e,t)=>this.setAttributeData(e,t),clearMemCache:()=>this.clearMemCache()}}async _handleEdits(e){const t=p(),i=this._attributeEditingContext,r=await f(i,e);t&&_(i,r),F(i,r)}get hasGeometryFilter(){const e=this.viewFilter;return null!=e?.parsedGeometry}computeNodeFiltering(e){const t=this.viewFilter;return null==t||!this.view.spatialReference||t.isMBSGeometryVisible(e,this.view.spatialReference,this._controller.crsIndex)?I.Unmodified:I.Culled}};e([n()],P.prototype,"i3slayer",null),e([n(R)],P.prototype,"updatingProgress",void 0),e([n({type:a})],P.prototype,"filter",null),e([n({readOnly:!0})],P.prototype,"viewFilter",null),e([n(U.requiredFields)],P.prototype,"requiredFields",null),e([n(U.availableFields)],P.prototype,"availableFields",void 0),e([n()],P.prototype,"_fieldsHelper",void 0),e([n()],P.prototype,"_floorFilterClause",null),e([n()],P.prototype,"_excludeObjectIdsSorted",null),e([n()],P.prototype,"_setVisibilityHiddenObjectIds",void 0),e([n()],P.prototype,"_setVisibilityHiddenObjectIdsSorted",null),e([n()],P.prototype,"lodFactor",null),e([n()],P.prototype,"updatingProgressValue",null),P=e([o("esri.views.3d.layers.SceneLayerView3D")],P);const M=P;export{M as default};
5
+ import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../Graphic.js";import i from"../../../core/Logger.js";import{destroyMaybe as r}from"../../../core/maybe.js";import s from"../../../core/ReactiveSet.js";import{initial as l}from"../../../core/reactiveUtils.js";import{property as n}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/RandomLCG.js";import{subclass as o}from"../../../core/accessorSupport/decorators/subclass.js";import{WhereClause as d}from"../../../core/sql/WhereClause.js";import a from"../../../layers/support/FeatureFilter.js";import{getFloorFilterClause as u}from"../../../layers/support/floorFilterUtils.js";import h from"../../../rest/support/Query.js";import{sceneLayerEditingEnabled as p}from"../../../support/featureFlags.js";import{I3SMeshView3D as c}from"./I3SMeshView3D.js";import{ForAllFeaturesMode as y}from"./II3SMeshView3D.js";import{LayerView3D as g}from"./LayerView3D.js";import{createInteractiveEditSession as m,normalizeEditResultsEvent as f,processGeometryEdits as _,processAttributeEdits as F}from"./i3s/featureEditing.js";import{createGetFeatureExtent as b}from"./i3s/I3SGeometryUtil.js";import{I3SMeshViewFilter as j}from"./i3s/I3SMeshViewFilter.js";import{NodeFilterImpact as I}from"./i3s/I3SNode.js";import{I3SOverrides as v}from"./i3s/I3SOverrides.js";import{I3SQueryEngine as w}from"./i3s/I3SQueryEngine.js";import{I3SQueryFeatureAdapter as S}from"./i3s/I3SQueryFeatureAdapter.js";import{I3SQueryFeatureStore as E}from"./i3s/I3SQueryFeatureStore.js";import{checkRecyclable as O,getIndexCrs as H,objectIdFilter as x}from"./i3s/I3SUtil.js";import{DefinitionExpressionSceneLayerView as C}from"./support/DefinitionExpressionSceneLayerView.js";import{defineFieldProperties as Q}from"./support/fieldProperties.js";import{PopupSceneLayerView as V}from"./support/PopupSceneLayerView.js";import{SceneLayerViewRequiredFields as q}from"./support/SceneLayerViewRequiredFields.js";import{TemporalSceneLayerView as L}from"./support/TemporalSceneLayerView.js";import{updatingProgress as R}from"../support/updatingProperties.js";import D from"../../layers/SceneLayerView.js";import{hasPopupTemplate as A}from"../../layers/support/popupUtils.js";import{TaskPriority as G}from"../../support/Scheduler.js";const U=Q();let P=class extends(c(L(C(V(g(D)))))){constructor(){super(...arguments),this.type="scene-layer-3d",this._setVisibilityHiddenObjectIds=new s,this.progressiveLoadFactor=1,this._elevationContext="scene",this._isIntegratedMesh=!1,this._supportsLabeling=!0,this._pendingEditsQueue=Promise.resolve(),this._interactiveEditingSessions=new Map,this._queryEngine=null}get i3slayer(){return this.layer}tryRecycleWith(e,t){return e.url===this.layer.url&&this.i3sOverrides.isEmpty?e.load(t).then((()=>{O(this.layer,e,this.i3sOverrides),this.layer=e,this.i3sOverrides.destroy();const t=this.view.resourceController?.memoryController;this.i3sOverrides=new v({view:this.view,layer:e,memoryController:t}),this.resetHighlights()})):null}get layerPopupEnabledAndHasTemplate(){return this.layer.popupEnabled&&A(this.layer,this.view.popup?.defaultPopupTemplateEnabled)}get filter(){return this._get("filter")}set filter(e){this._set("filter",j.checkSupport(e)?e:null)}get viewFilter(){const e=this.mergedFilter,t=this.layerFilter;if(null==e&&null==t)return null;const i=this._get("viewFilter");return null==i?new j({layerFilter:t,viewFilter:e,layerFieldsIndex:this.layer.fieldsIndex,loadAsyncModule:e=>this._loadAsyncModule(e),addSqlFilter:(e,t)=>this.addSqlFilter(e,t,this.logError),addTimeFilter:(e,t)=>this.addTimeFilter(e,t)}):(i.viewFilter=e,i.layerFilter=t,i)}get requiredFields(){return this._fieldsHelper?.requiredFields??[]}get _floorFilterClause(){const e=u(this);return null!=e?d.create(e,this.layer.fieldsIndex):null}get _excludeObjectIdsSorted(){const e=this.layer.excludeObjectIds.toArray();return e.length?e.sort(((e,t)=>e-t)):null}get _setVisibilityHiddenObjectIdsSorted(){return this._setVisibilityHiddenObjectIds.size?Array.from(this._setVisibilityHiddenObjectIds).sort(((e,t)=>e-t)):null}get lodFactor(){return this.view?.qualitySettings?.sceneService?.object?.lodFactor??1}get lodCrossfadeUncoveredDuration(){return this.view?.qualitySettings?.fadeDuration??0}get updatingProgressValue(){return this._controller?.updatingProgress??0}initialize(){this._fieldsHelper=new q({layerView:this}),this._updatingHandles.add((()=>this.layer.rangeInfos),(e=>this._rangeInfosChanged(e)),l),this._updatingHandles.add((()=>this.layer.renderer),(e=>this._updatingHandles.addPromise(this._rendererChange(e))),l);const e=()=>this._filterChange();this._updatingHandles.add((()=>this.parsedDefinitionExpression),e),this._updatingHandles.add((()=>this.mergedFilter),e),this._updatingHandles.add((()=>this._floorFilterClause),e),this._updatingHandles.add((()=>this._excludeObjectIdsSorted),e),this._updatingHandles.add((()=>this._setVisibilityHiddenObjectIdsSorted),e),this._updatingHandles.add((()=>this.viewFilter?.sortedObjectIds),e),this._updatingHandles.add((()=>this.viewFilter?.parsedWhereClause),e),this._updatingHandles.add((()=>this.getTimeFilterDependencies()),e),this._updatingHandles.add((()=>[this.viewFilter?.parsedGeometry,this.mergedFilter?.spatialRelationship,this.layer.filter?.spatialRelationship]),(()=>this._geometryFilterChange())),p()&&this.i3sOverrides.is3DOFL&&this._updatingHandles.add((()=>this.i3sOverrides.sortedGeometryChangedObjectIds),e),this.addHandles(this.layer.on("apply-edits",(e=>this._updatingHandles.addPromise(e.result)))),this.addHandles(this.layer.on("edits",(e=>{const t=this._pendingEditsQueue.then((()=>this._handleEdits(e))).then();this._pendingEditsQueue=t,this._updatingHandles.addPromise(t)})))}destroy(){this._fieldsHelper=r(this._fieldsHelper)}_rangeInfosChanged(e){null!=e&&e.length>0&&i.getLogger(this).warn("Unsupported property: rangeInfos are currently only serialized to and from web scenes but do not affect rendering.")}createQuery(){const e={outFields:["*"],returnGeometry:!1,outSpatialReference:this.view.spatialReference};return this.mergedFilter?.createQuery(e)??new h(e)}queryExtent(e,t){return this._ensureQueryEngine().executeQueryForExtent(this._ensureQuery(e),t?.signal)}queryFeatureCount(e,t){return this._ensureQueryEngine().executeQueryForCount(this._ensureQuery(e),t?.signal)}queryFeatures(e,t){return this._ensureQueryEngine().executeQuery(this._ensureQuery(e),t?.signal).then((e=>{if(!e?.features)return e;const t=this.layer;for(const i of e.features)i.layer=t,i.sourceLayer=t;return e}))}queryObjectIds(e,t){return this._ensureQueryEngine().executeQueryForIds(this._ensureQuery(e),t?.signal)}_ensureQueryEngine(){return this._queryEngine||(this._queryEngine=this._createQueryEngine()),this._queryEngine}_createQueryEngine(){const e=b(this.view.spatialReference,this.view.renderSpatialReference,this._collection);return new w({layerView:this,priority:G.FEATURE_QUERY_ENGINE,spatialIndex:new E({featureAdapter:new S({objectIdField:this.layer.objectIdField,attributeStorageInfo:this.layer.attributeStorageInfo??[],getFeatureExtent:e}),forAllFeatures:(e,t)=>this._forAllFeatures(((t,i,r)=>e({id:t,index:i,meta:r})),t,y.QUERYABLE),getFeatureExtent:e,sourceSpatialReference:H(this.layer),viewSpatialReference:this.view.spatialReference})})}highlight(e){const t=this._highlights;if(e instanceof h){const{set:i,handle:r}=t.acquireSet();return this.queryObjectIds(e).then((e=>t.setFeatureIds(i,e))),r}return super.highlight(e)}createInteractiveEditSession(e){return m(this._attributeEditingContext,e)}_createLayerGraphic(e){return new t({attributes:e,layer:this.layer,sourceLayer:this.layer})}getFilters(){const e=super.getFilters();p()&&this.i3sOverrides.is3DOFL&&this.i3sOverrides.sortedGeometryChangedObjectIds.length>0&&e.push(((e,t)=>{t.node.index>=0&&x(this.i3sOverrides.sortedGeometryChangedObjectIds,!1,e)}));const t=this._setVisibilityHiddenObjectIdsSorted;null!=t&&e.push((e=>x(t,!1,e)));const i=this._excludeObjectIdsSorted;return null!=i&&e.push((e=>x(i,!1,e))),this._floorFilterClause&&this.addSqlFilter(e,this._floorFilterClause,this.logError),this.addSqlFilter(e,this.parsedDefinitionExpression,this.logError),null!=this.viewFilter&&this.viewFilter.addFilters(e,this.view,this._controller.crsIndex,this._collection),e}setVisibility(e,t){t?this._setVisibilityHiddenObjectIds.delete(e):this._setVisibilityHiddenObjectIds.add(e)}isUpdating(){return super.isUpdating()||this.layerFilterUpdating||null!=this.viewFilter&&this.viewFilter.updating||null!=this.i3sOverrides&&this.i3sOverrides.updating}_ensureQuery(e){return this._addDefinitionExpressionToQuery(null==e?this.createQuery():h.from(e))}get _attributeEditingContext(){return{sessions:this._interactiveEditingSessions,fieldsIndex:this.layer.fieldsIndex,objectIdField:this._getObjectIdField(),globalIdField:this._getGlobalIdField(),forEachNode:e=>this._forAllNodes((t=>null!=t?e(t.node,t.featureIds):null)),attributeStorageInfo:this.i3slayer.attributeStorageInfo??[],i3sOverrides:this.i3sOverrides,getAttributeData:e=>this.getAttributeData(e),setAttributeData:(e,t)=>this.setAttributeData(e,t),clearMemCache:()=>this.clearMemCache()}}async _handleEdits(e){const t=p(),i=this._attributeEditingContext,r=await f(i,e);t&&_(i,r),F(i,r)}get hasGeometryFilter(){const e=this.viewFilter;return null!=e?.parsedGeometry}computeNodeFiltering(e){const t=this.viewFilter;return null==t||!this.view.spatialReference||t.isMBSGeometryVisible(e,this.view.spatialReference,this._controller.crsIndex)?I.Unmodified:I.Culled}};e([n()],P.prototype,"i3slayer",null),e([n(R)],P.prototype,"updatingProgress",void 0),e([n({type:a})],P.prototype,"filter",null),e([n({readOnly:!0})],P.prototype,"viewFilter",null),e([n(U.requiredFields)],P.prototype,"requiredFields",null),e([n(U.availableFields)],P.prototype,"availableFields",void 0),e([n()],P.prototype,"_fieldsHelper",void 0),e([n()],P.prototype,"_floorFilterClause",null),e([n()],P.prototype,"_excludeObjectIdsSorted",null),e([n()],P.prototype,"_setVisibilityHiddenObjectIds",void 0),e([n()],P.prototype,"_setVisibilityHiddenObjectIdsSorted",null),e([n()],P.prototype,"lodFactor",null),e([n()],P.prototype,"updatingProgressValue",null),P=e([o("esri.views.3d.layers.SceneLayerView3D")],P);const M=P;export{M 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.30/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{fromMat4 as r,transpose as o}from"../../../../core/libs/gl-matrix-2/math/mat3.js";import{create as a}from"../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{fromTranslation as s,multiply as n,invert as i,getTranslation as l}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as c,IDENTITY as u,clone as m}from"../../../../core/libs/gl-matrix-2/factories/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/vec32.js";import{ZEROS as T,ONES as b,create as y}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ONES as v}from"../../../../core/libs/gl-matrix-2/factories/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{projectVectorToPoint as M}from"../../../../geometry/projection/projectVectorToPoint.js";import{create as O,empty as P,expandWithBuffer as A,intersectsClippingArea as R}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 S from"../../../../geometry/support/MeshComponent.js";import F from"../../../../geometry/support/MeshMaterialMetallicRoughness.js";import B from"../../../../geometry/support/MeshTextureTransform.js";import{isRelativeVertexSpace as U}from"../../../../geometry/support/meshVertexSpaceUtils.js";import{a as L,b as $}from"../../../../chunks/vec3.js";import{project as V}from"../../../../geometry/support/meshUtils/georeference.js";import{transformNormal as G,projectNormalToPCPF as D,transformTangent as H,projectTangentToPCPF as q}from"../../../../geometry/support/meshUtils/projection.js";import{makeDehydratedPoint as k}from"../../../../layers/graphics/dehydratedPoint.js";import{MeshTransformUpdateAction as W}from"../../../../layers/graphics/sources/interfaces.js";import{ViewingMode as z}from"../../../ViewingMode.js";import{isEncodedMeshTexture as Y}from"../../glTF/internal/resourceUtils.js";import{getTransformMatrix as J}from"../../glTF/internal/TextureTransformUtils.js";import{perObjectElevationAligner as K}from"./ElevationAligners.js";import{needsElevationUpdates3D as Q,evaluateElevationInfoAtPoint as X}from"./elevationAlignmentUtils.js";import{Graphics3DMeshObject3DGraphicLayer as Z}from"./Graphics3DMeshObject3DGraphicLayer.js";import{Object3DEdgeState as ee}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as te}from"./Graphics3DSymbolLayer.js";import{MaterialInfoCache as re,MeshFastUpdateProcessor as oe}from"./MeshFastUpdateProcessor.js";import{createMaterial as ae}from"../support/edgeUtils.js";import{parseColorMixMode as se,encodeSymbolColor as ne}from"../support/symbolColorUtils.js";import{debugFlags as ie}from"../../support/debugFlags.js";import{Attribute as le}from"../../webgl-engine/lib/Attribute.js";import{AlphaDiscardMode as ce,CullFaceOptions as ue}from"../../webgl-engine/lib/basicInterfaces.js";import{ContentObjectType as me}from"../../webgl-engine/lib/ContentObjectType.js";import{Geometry as he}from"../../webgl-engine/lib/Geometry.js";import{Object3D as fe}from"../../webgl-engine/lib/Object3D.js";import{Texture as pe}from"../../webgl-engine/lib/Texture.js";import{VertexAttribute as de}from"../../webgl-engine/lib/VertexAttribute.js";import{DefaultMaterial as ge}from"../../webgl-engine/materials/DefaultMaterial.js";import{NativeLineMaterial as xe}from"../../webgl-engine/materials/NativeLineMaterial.js";import{useSchematicPBR as _e,defaultSchematicMRRFactors as Te,defaultAdvancedMRRFactors as be}from"../../webgl-engine/materials/pbrUtils.js";import{TextureWrapMode as ye}from"../../../webgl/enums.js";const ve=["mesh"];class Ce extends te{constructor(e,t,r,o){super(e,t,r,o),this._materialInfoCache=new re,this._fastUpdateProcessor=new oe,this._textures=new Map,this.ensureDrapedStatus(!1)}async doLoad(){ie.DRAW_MESH_GEOMETRY_NORMALS&&(this._debugVertexNormalMaterial=new xe({color:[1,0,1,1]}),this._debugFaceNormalMaterial=new xe({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,ve,"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,Q)}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=Ie,{origin:n,transform:i}=r;switch(w(t,h(Me,n.x,n.y,n.z??0),s,a),o){case W.EnableFastUpdates:this._fastUpdateProcessor.enable(e,this._materialInfoCache,this._context);break;case W.DisableFastUpdates:this._fastUpdateProcessor.disable(e,this._materialInfoCache,this._context);break;case W.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)=>X(e,c,l,u,t);return e.alignedSampledElevation=K(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??Fe;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,ce.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};Y(r)?(s=r.data,i.preMultiplyAlpha=!1,i.encoding=r.encoding):(s=r,i.preMultiplyAlpha=t!==ce.Opaque,i.downsampleUncompressed=this._context.graphicsCoreOwner.view.qualitySettings.graphics3D.uncompressedTextureDownsamplingEnabled),a=new pe(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=J(t.colorTextureTransform),r.normalTextureTransformMatrix=J(t.normalTextureTransform),r.occlusionTextureTransformMatrix=J(t.occlusionTextureTransform),r.emissiveTextureTransformMatrix=J(t.emissiveTextureTransform),r.metallicRoughnessTextureTransformMatrix=J(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=_e({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:b,opacity:1,doubleSided:!0,doubleSidedType:"winding-order",cullFace:ue.None,layerOpacity:this._getLayerOpacity(),hasSlicePlane:this._context.slicePlaneEnabled,initTextureTransparent:!0};h.mrrFactors=m?[...Te]:[l.metallic,l.roughness,be[2]],r.material&&(h.doubleSided=r.material.doubleSided,h.cullFace=r.material.doubleSided?ue.None:ue.Back,h.textureAlphaCutoff=r.material.alphaCutoff),this._setExternalMaterialParameters(h),this._setMaterialTransparentParameter(h,u),this._setInternalMaterialParameters(l,h);const f=new ge(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?ce.MaskBlend:ce.Opaque:e.textureAlphaMode="opaque"===t.alphaMode?ce.Opaque:"mask"===t.alphaMode?ce.Mask:ce.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(de.POSITION),o=e.attributes.get(de.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,Ae),this._getFaceVertices(c,u,t,Me,Oe,Pe),f(Me,Me,Oe),f(Me,Me,Pe),p(Me,Me,1/3);for(let e=0;e<3;e++)i.push(Me[e]);for(let e=0;e<3;e++)i.push(Me[e]+Ae[e]*a);l.push(l.length),l.push(l.length)}}}const c=t[0].transformation,u=new he(this._debugVertexNormalMaterial,[[de.POSITION,new le(s,n,3,!0)]],null,me.Line);t.push(u),u.transformation=c;const m=new he(this._debugFaceNormalMaterial,[[de.POSITION,new le(i,l,3,!0)]],null,me.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;ie.DRAW_MESH_GEOMETRY_NORMALS&&this._addDebugNormals(a,n);const l=new fe({geometries:n,layerUid:this._context.layer.uid,graphicUid:o,isElevationSource:!0});l.transformation=i;const c=ae(this.symbolLayer,{opacity:this._getLayerOpacity()}),u=c?new ee(n[0].material,[c],{mergeGeometries:!0,hasSlicePlane:this._context.slicePlaneEnabled}):null,m=new Z(this,l,n,null,null,K,r,u);this._fastUpdateProcessor.onAddGraphic(),m.needsElevationUpdates=Q(r.mode),m.useObjectOriginAsAttachmentOrigin=!0,r.centerPointInElevationSR=this._getCenterPointInElevationSR(l.transformation);const{elevationProvider:h,renderCoordsHelper:f}=this._context,p=(e,t)=>X(e,h,r,f,t);return m.alignedSampledElevation=K(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 M([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,Ae);for(let e=0;e<3;e++){const r=3*o[s+e];Me[0]=t[r],Me[1]=t[r+1],Me[2]=t[r+2],d(Ae,Me)<0&&(t[r]=-t[r],t[r+1]=-t[r+1],t[r+2]=-t[r+2],a=!0)}}return new we(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,Ae);for(let e=0;e<3;e++)r[a+e]=s[e],o[a+e]=a/3}return new we(r,o,!1)}_createComponentNormalsSmooth(e,t){const r={};for(let s=0;s<t.length;s+=3){const o=this._calculateFaceNormal(e,t,s,Ae);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),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 we(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,Me,Oe,Pe),x(Oe,Oe,Me),x(Pe,Pe,Me),_(Me,Oe,Pe),g(o,Me),o}_getOrCreateComponents(e){return e.components??Se}_createPositionBuffer(e,t){let r=e.vertexAttributes.position;const o=t.reprojection===Be.ECEF?t.transformBeforeProject:null;if(o&&(r=L(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 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===Be.ECEF?r.transformBeforeProject:null;a&&(o=G(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)}_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=H(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 q(o,s,t,e.spatialReference,n)}_createColorBuffer(e){return e.vertexAttributes.color}_createSymbolColorBuffer(e){if(this._requiresSymbolVertexColors()){const t=this._getVertexOpacityAndColor(e),r=se(this.symbolLayer?.material?.colorMixMode),o=new Uint8Array(4);return ne(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===Be.NONE&&n.objectTransformation?n.objectTransformation:this._transformOriginLocal(e,i,m,h),geometryTransformation:n.reprojection===Be.NONE&&n.geometryTransformation?n.geometryTransformation:c()}}_computeReprojectionInfo(e){const{vertexSpace:t}=e,r="georeferenced"===t.type?this._context.renderCoordsHelper.viewingMode===z.Local?Be.NONE:Be.ECEF:Be.NONE;if(U(t)){const o=t.origin,a=c(),i=e.transform?.localMatrix??u;if(r===Be.NONE){w(e.spatialReference,o,a,this._context.renderCoordsHelper.spatialReference);return{reprojection:r,objectTransformation:a,geometryTransformation:m(i),needsBufferCopy:!1}}const l=s(c(),o);return n(l,l,i),{reprojection:r,transformBeforeProject:l,needsBufferCopy:!0}}return{reprojection:r,needsBufferCopy:!0}}_transformOriginLocal(e,t,a,s){const n=this._context.renderCoordsHelper.spatialReference,l=e.anchor;je[0]=l.x,je[1]=l.y,je[2]=l.z??0;const u=c();return w(e.spatialReference,je,u,n),i(Re,u),L(t,t,Re),(a||s)&&(r(Ee,u),o(Ee,Ee),a&&$(a,a,Ee),s&&$(s,s,Ee,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=V({positions:t,transform:e.transform,vertexSpace:e.vertexSpace,inSpatialReference:e.spatialReference,outSpatialReference:r??e.spatialReference,localMode:this._context.stage.viewingMode===z.Local}),a=o.length/3;return P(Ne),A(Ne,o,0,a),!R(Ne,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(Me,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=[[de.POSITION,new le(a,t,3,!0)],[de.NORMAL,new le(o.normals,o.indices,3,!0)]];n&&m.push([de.COLOR,new le(n,t,4,!0)]),i&&m.push([de.SYMBOLCOLOR,new le(i,N(t.length),4,!0)]),s&&m.push([de.UV0,new le(s,t,2,!0)]),u&&m.push([de.TANGENT,new le(u,t,4,!0)]);const f=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:r,layerUid:this._context.layer.uid}),g=this._getOrCreateMaterial(e,l),_=new he(g,m,null,me.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 we{constructor(e,t,r){this.normals=e,this.indices=t,this.didFlipNormals=r}}const je=y(),Me=y(),Oe=y(),Pe=y(),Ae=y(),Re=c(),Ee=a(),Ie=c(),Ne=O(),Se=[new S],Fe=new B;var Be;!function(e){e[e.NONE=0]="NONE",e[e.ECEF=1]="ECEF"}(Be||(Be={}));export{Ce as Graphics3DMeshFillSymbolLayer};
5
+ import e from"../../../../Color.js";import"../../../../core/has.js";import{deg2rad as t}from"../../../../core/mathUtils.js";import{fromMat4 as r,transpose as o}from"../../../../core/libs/gl-matrix-2/math/mat3.js";import{create as a}from"../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{fromTranslation as s,multiply as n,invert as i,getTranslation as l}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as c,IDENTITY as u,clone as m}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{ONES as h}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{s as f,g as p,i as d,j as g,n as x,f as _,b as T}from"../../../../chunks/vec32.js";import{ZEROS as b,ONES as y,create as v}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ONES as C}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{canProjectWithoutEngine as w}from"../../../../geometry/projection.js";import{computeTranslationToOriginAndRotation as j}from"../../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{projectBuffer as M}from"../../../../geometry/projection/projectBuffer.js";import{projectVectorToPoint as O}from"../../../../geometry/projection/projectVectorToPoint.js";import{create as P,empty as A,expandWithBuffer as R,intersectsClippingArea as E}from"../../../../geometry/support/aaBoundingBox.js";import{newFloatArray as I}from"../../../../geometry/support/FloatArray.js";import{getContinuousIndexArray as N,getZeroIndexArray as S}from"../../../../geometry/support/Indices.js";import F from"../../../../geometry/support/MeshComponent.js";import B from"../../../../geometry/support/MeshMaterialMetallicRoughness.js";import U from"../../../../geometry/support/MeshTextureTransform.js";import{isRelativeVertexSpace as L}from"../../../../geometry/support/meshVertexSpaceUtils.js";import{a as $,b as V}from"../../../../chunks/vec3.js";import{project as G}from"../../../../geometry/support/meshUtils/georeference.js";import{transformNormal as D,projectNormalToPCPF as H,transformTangent as q,projectTangentToPCPF as k}from"../../../../geometry/support/meshUtils/projection.js";import{makeDehydratedPoint as W}from"../../../../layers/graphics/dehydratedPoint.js";import{MeshTransformUpdateAction as z}from"../../../../layers/graphics/sources/interfaces.js";import{ViewingMode as Y}from"../../../ViewingMode.js";import{isEncodedMeshTexture as J}from"../../glTF/internal/resourceUtils.js";import{getTransformMatrix as K}from"../../glTF/internal/TextureTransformUtils.js";import{perObjectElevationAligner as Q}from"./ElevationAligners.js";import{needsElevationUpdates3D as X,evaluateElevationInfoAtPoint as Z}from"./elevationAlignmentUtils.js";import{Graphics3DMeshObject3DGraphicLayer as ee}from"./Graphics3DMeshObject3DGraphicLayer.js";import{Object3DEdgeState as te}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as re}from"./Graphics3DSymbolLayer.js";import{MaterialInfoCache as oe,MeshFastUpdateProcessor as ae}from"./MeshFastUpdateProcessor.js";import{createMaterial as se}from"../support/edgeUtils.js";import{parseColorMixMode as ne,encodeSymbolColor as ie}from"../support/symbolColorUtils.js";import{debugFlags as le}from"../../support/debugFlags.js";import{Attribute as ce}from"../../webgl-engine/lib/Attribute.js";import{AlphaDiscardMode as ue,CullFaceOptions as me}from"../../webgl-engine/lib/basicInterfaces.js";import{ContentObjectType as he}from"../../webgl-engine/lib/ContentObjectType.js";import{Geometry as fe}from"../../webgl-engine/lib/Geometry.js";import{Object3D as pe}from"../../webgl-engine/lib/Object3D.js";import{Texture as de}from"../../webgl-engine/lib/Texture.js";import{VertexAttribute as ge}from"../../webgl-engine/lib/VertexAttribute.js";import{DefaultMaterial as xe}from"../../webgl-engine/materials/DefaultMaterial.js";import{NativeLineMaterial as _e}from"../../webgl-engine/materials/NativeLineMaterial.js";import{useSchematicPBR as Te,defaultSchematicMRRFactors as be,defaultAdvancedMRRFactors as ye}from"../../webgl-engine/materials/pbrUtils.js";import{TextureWrapMode as ve}from"../../../webgl/enums.js";const Ce=["mesh"];class we extends re{constructor(e,t,r,o){super(e,t,r,o),this._materialInfoCache=new oe,this._fastUpdateProcessor=new ae,this._textures=new Map,this.ensureDrapedStatus(!1)}async doLoad(){le.DRAW_MESH_GEOMETRY_NORMALS&&(this._debugVertexNormalMaterial=new _e({color:[1,0,1,1]}),this._debugFaceNormalMaterial=new _e({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,Ce,"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,X)}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=Ne,{origin:n,transform:i}=r;switch(j(t,f(Oe,n.x,n.y,n.z??0),s,a),o){case z.EnableFastUpdates:this._fastUpdateProcessor.enable(e,this._materialInfoCache,this._context);break;case z.DisableFastUpdates:this._fastUpdateProcessor.disable(e,this._materialInfoCache,this._context);break;case z.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)=>Z(e,c,l,u,t);return e.alignedSampledElevation=Q(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 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,ue.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};J(r)?(s=r.data,i.preMultiplyAlpha=!1,i.encoding=r.encoding):(s=r,i.preMultiplyAlpha=t!==ue.Opaque,i.downsampleUncompressed=this._context.graphicsCoreOwner.view.qualitySettings.graphics3D.uncompressedTextureDownsamplingEnabled),a=new de(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 ve.CLAMP_TO_EDGE;case"mirror":return ve.MIRRORED_REPEAT;default:return ve.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=K(t.colorTextureTransform),r.normalTextureTransformMatrix=K(t.normalTextureTransform);const o=null!=t.normalTextureTransform?.scale?t.normalTextureTransform?.scale:h;r.scale=[o[0],o[1]],r.occlusionTextureTransformMatrix=K(t.occlusionTextureTransform),r.emissiveTextureTransformMatrix=K(t.emissiveTextureTransform),r.metallicRoughnessTextureTransformMatrix=K(t.metallicRoughnessTextureTransform)}_setExternalMaterialParameters(t){const r=this._drivenProperties.color;let o=this.symbolLayer.material?.colorMixMode??null;if(r)t.externalColor=C;else{const r=this.symbolLayer.material?.color??null;r?t.externalColor=e.toUnitRGBA(r):(o=null,t.externalColor=C)}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=Te({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:b,diffuse:y,opacity:1,doubleSided:!0,doubleSidedType:"winding-order",cullFace:me.None,layerOpacity:this._getLayerOpacity(),hasSlicePlane:this._context.slicePlaneEnabled,initTextureTransparent:!0};h.mrrFactors=m?[...be]:[l.metallic,l.roughness,ye[2]],r.material&&(h.doubleSided=r.material.doubleSided,h.cullFace=r.material.doubleSided?me.None:me.Back,h.textureAlphaCutoff=r.material.alphaCutoff),this._setExternalMaterialParameters(h),this._setMaterialTransparentParameter(h,u),this._setInternalMaterialParameters(l,h);const f=new xe(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?ue.MaskBlend:ue.Opaque:e.textureAlphaMode="opaque"===t.alphaMode?ue.Opaque:"mask"===t.alphaMode?ue.Mask:ue.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(ge.POSITION),o=e.attributes.get(ge.NORMAL),c=r.data,u=r.indices,m=o.data,f=o.indices;for(let t=0;t<u.length;t++){const e=3*u[t],r=3*f[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,Re),this._getFaceVertices(c,u,t,Oe,Pe,Ae),p(Oe,Oe,Pe),p(Oe,Oe,Ae),d(Oe,Oe,1/3);for(let e=0;e<3;e++)i.push(Oe[e]);for(let e=0;e<3;e++)i.push(Oe[e]+Re[e]*a);l.push(l.length),l.push(l.length)}}}const c=t[0].transformation,u=new fe(this._debugVertexNormalMaterial,[[ge.POSITION,new ce(s,n,3,!0)]],null,he.Line);t.push(u),u.transformation=c;const m=new fe(this._debugFaceNormalMaterial,[[ge.POSITION,new ce(i,l,3,!0)]],null,he.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;le.DRAW_MESH_GEOMETRY_NORMALS&&this._addDebugNormals(a,n);const l=new pe({geometries:n,layerUid:this._context.layer.uid,graphicUid:o,isElevationSource:!0});l.transformation=i;const c=se(this.symbolLayer,{opacity:this._getLayerOpacity()}),u=c?new te(n[0].material,[c],{mergeGeometries:!0,hasSlicePlane:this._context.slicePlaneEnabled}):null,m=new ee(this,l,n,null,null,Q,r,u);this._fastUpdateProcessor.onAddGraphic(),m.needsElevationUpdates=X(r.mode),m.useObjectOriginAsAttachmentOrigin=!0,r.centerPointInElevationSR=this._getCenterPointInElevationSR(l.transformation);const{elevationProvider:h,renderCoordsHelper:f}=this._context,p=(e,t)=>Z(e,h,r,f,t);return m.alignedSampledElevation=Q(m,r,h.spatialReference,p,f),m}_getCenterPointInElevationSR(e){const t=W(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,Re);for(let e=0;e<3;e++){const r=3*o[s+e];Oe[0]=t[r],Oe[1]=t[r+1],Oe[2]=t[r+2],g(Re,Oe)<0&&(t[r]=-t[r],t[r+1]=-t[r+1],t[r+2]=-t[r+2],a=!0)}}return new je(t,o,a)}_createComponentNormalsFlat(e,t){const r=I(t.length),o=new Array(3*t.length);for(let a=0;a<t.length;a+=3){const s=this._calculateFaceNormal(e,t,a,Re);for(let e=0;e<3;e++)r[a+e]=s[e],o[a+e]=a/3}return new je(r,o,!1)}_createComponentNormalsSmooth(e,t){const r={};for(let s=0;s<t.length;s+=3){const o=this._calculateFaceNormal(e,t,s,Re);for(let e=0;e<3;e++){const a=t[s+e];let n=r[a];n||(n={normal:v(),count:0},r[a]=n),p(n.normal,n.normal,o),n.count++}}const o=I(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&&(x(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 je(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,Oe,Pe,Ae),_(Pe,Pe,Oe),_(Ae,Ae,Oe),T(Oe,Pe,Ae),x(o,Oe),o}_getOrCreateComponents(e){return e.components??Fe}_createPositionBuffer(e,t){let r=e.vertexAttributes.position;const o=t.reprojection===Ue.ECEF?t.transformBeforeProject:null;if(o&&(r=$(new Float64Array(r.length),r,o)),t.reprojection===Ue.NONE)return t.needsBufferCopy?new Float64Array(r):r;const a=o?r:new Float64Array(r.length);return M(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===Ue.ECEF?r.transformBeforeProject:null;a&&(o=D(o,new Float32Array(o.length),a));if("local"===this._context.graphicsCoreOwner.view.viewingMode||r.reprojection===Ue.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 H(o,s,t,e.spatialReference,n)}_createTangentBuffer(e,t,r){let o=e.vertexAttributes.tangent;if(null==o)return null;const a=r.reprojection===Ue.ECEF?r.transformBeforeProject:null;a&&(o=q(o,new Float32Array(o.length),a));if("local"===this._context.graphicsCoreOwner.view.viewingMode||r.reprojection===Ue.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=ne(this.symbolLayer?.material?.colorMixMode),o=new Uint8Array(4);return ie(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===Ue.NONE&&n.objectTransformation?n.objectTransformation:this._transformOriginLocal(e,i,m,h),geometryTransformation:n.reprojection===Ue.NONE&&n.geometryTransformation?n.geometryTransformation:c()}}_computeReprojectionInfo(e){const{vertexSpace:t}=e,r="georeferenced"===t.type?this._context.renderCoordsHelper.viewingMode===Y.Local?Ue.NONE:Ue.ECEF:Ue.NONE;if(L(t)){const o=t.origin,a=c(),i=e.transform?.localMatrix??u;if(r===Ue.NONE){j(e.spatialReference,o,a,this._context.renderCoordsHelper.spatialReference);return{reprojection:r,objectTransformation:a,geometryTransformation:m(i),needsBufferCopy:!1}}const l=s(c(),o);return n(l,l,i),{reprojection:r,transformBeforeProject:l,needsBufferCopy:!0}}return{reprojection:r,needsBufferCopy:!0}}_transformOriginLocal(e,t,a,s){const n=this._context.renderCoordsHelper.spatialReference,l=e.anchor;Me[0]=l.x,Me[1]=l.y,Me[2]=l.z??0;const u=c();return j(e.spatialReference,Me,u,n),i(Ee,u),$(t,t,Ee),(a||s)&&(r(Ie,u),o(Ie,Ie),a&&V(a,a,Ie),s&&V(s,s,Ie,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??N(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=G({positions:t,transform:e.transform,vertexSpace:e.vertexSpace,inSpatialReference:e.spatialReference,outSpatialReference:r??e.spatialReference,localMode:this._context.stage.viewingMode===Y.Local}),a=o.length/3;return A(Se),R(Se,o,0,a),!E(Se,this._context.clippingExtent)}_createGeometryInfo(e,t,r){if(!w(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(Oe,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=[[ge.POSITION,new ce(a,t,3,!0)],[ge.NORMAL,new ce(o.normals,o.indices,3,!0)]];n&&m.push([ge.COLOR,new ce(n,t,4,!0)]),i&&m.push([ge.SYMBOLCOLOR,new ce(i,S(t.length),4,!0)]),s&&m.push([ge.UV0,new ce(s,t,2,!0)]),u&&m.push([ge.TANGENT,new ce(u,t,4,!0)]);const f=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:r,layerUid:this._context.layer.uid}),g=this._getOrCreateMaterial(e,l),_=new fe(g,m,null,he.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 je{constructor(e,t,r){this.normals=e,this.indices=t,this.didFlipNormals=r}}const Me=v(),Oe=v(),Pe=v(),Ae=v(),Re=v(),Ee=c(),Ie=a(),Ne=c(),Se=P(),Fe=[new F],Be=new U;var Ue;!function(e){e[e.NONE=0]="NONE",e[e.ECEF=1]="ECEF"}(Ue||(Ue={}));export{we 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.30/esri/copyright.txt for details.
4
4
  */
5
- import{adjustStaticAGOUrl as e}from"../../../../core/devEnvironmentUtils.js";import{normalFromMat4 as t}from"../../../../core/libs/gl-matrix-2/math/mat3.js";import{create as r}from"../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{invert as o}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as s}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{e as i,f as n,G as l,l as a,n as u,k as c}from"../../../../chunks/vec32.js";import{create as m}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{empty as f,expandWithVec3 as d}from"../../../../geometry/support/aaBoundingBox.js";import{newFloatArray as p}from"../../../../geometry/support/FloatArray.js";import{BufferViewVec4f as g,BufferViewVec4u8 as x,BufferViewVec4u16 as b,BufferViewVec3f as h,BufferViewVec3u8 as T,BufferViewVec3u16 as w}from"../../../../geometry/support/buffer/BufferView.js";import{a as y,b as v,s as R}from"../../../../chunks/vec3.js";import{t as j,s as M}from"../../../../chunks/vec4.js";import{n as B}from"../../../../chunks/vec2.js";import{c as S}from"../../../../chunks/vec33.js";import{c as F}from"../../../../chunks/vec43.js";import{DefaultLoadingContext as A}from"../../glTF/DefaultLoadingContext.js";import{loadGLTF as L}from"../../glTF/loader.js";import{convertPrimitiveToTriangles as E}from"../../glTF/internal/indexUtils.js";import{isEncodedMeshTexture as O}from"../../glTF/internal/resourceUtils.js";import{getTransformMatrix as I}from"../../glTF/internal/TextureTransformUtils.js";import{ProcessedObjectResource as C}from"./ProcessedObjectResource.js";import{load as k,processLoadResult as N}from"./wosrLoader.js";import{NormalType as P}from"../../webgl-engine/core/shaderLibrary/attributes/NormalAttribute.glsl.js";import{Attribute as U}from"../../webgl-engine/lib/Attribute.js";import{AlphaDiscardMode as V,DepthTestFunction as _,CullFaceOptions as D}from"../../webgl-engine/lib/basicInterfaces.js";import{Geometry as G}from"../../webgl-engine/lib/Geometry.js";import{Texture as H}from"../../webgl-engine/lib/Texture.js";import{VertexAttribute as q}from"../../webgl-engine/lib/VertexAttribute.js";import{DefaultMaterial as W}from"../../webgl-engine/materials/DefaultMaterial.js";import{colorGamma as $}from"../../webgl-engine/materials/DefaultMaterial_COLOR_GAMMA.js";import{defaultEsriSymbologyMRRFactors as z,defaultAdvancedMRRFactors as K,useSchematicPBR as Q,defaultSchematicMRRFactors as J}from"../../webgl-engine/materials/pbrUtils.js";async function X(t,r){const o=Y(e(t));if("wosr"===o.fileType){const e=await(r.cache?r.cache.loadWOSR(o.url,r):k(o.url,r)),{engineResources:t,referenceBoundingBox:s}=N(e,r);return{lods:t,referenceBoundingBox:s,isEsriSymbolResource:!1,isWosr:!0}}const s=await(r.cache?r.cache.loadGLTF(o.url,r,!!r.usePBR):L(new A(r.streamDataRequester),o.url,r,r.usePBR)),i=s.model.meta?.ESRI_proxyEllipsoid,n=s.meta.isEsriSymbolResource&&null!=i&&"EsriRealisticTreesStyle"===s.meta.ESRI_webstyle;n&&!s.customMeta.esriTreeRendering&&(s.customMeta.esriTreeRendering=!0,se(s,i));const l=!!r.usePBR,a=s.meta.isEsriSymbolResource?{usePBR:l,isSchematic:!1,treeRendering:n,mrrFactors:[...z]}:{usePBR:l,isSchematic:!1,treeRendering:!1,mrrFactors:[...K]},u={...r.materialParameters,treeRendering:n},{engineResources:c,referenceBoundingBox:m}=Z(s,a,u,r.skipHighLods&&null==o.specifiedLodIndex?{skipHighLods:!0}:{skipHighLods:!1,singleLodIndex:o.specifiedLodIndex});return{lods:c,referenceBoundingBox:m,isEsriSymbolResource:s.meta.isEsriSymbolResource,isWosr:!1}}function Y(e){const t=e.match(/(.*\.(gltf|glb))(\?lod=([0-9]+))?$/);if(t)return{fileType:"gltf",url:t[1],specifiedLodIndex:null!=t[4]?Number(t[4]):null};return e.match(/(.*\.(json|json\.gz))$/)?{fileType:"wosr",url:e,specifiedLodIndex:null}:{fileType:"unknown",url:e,specifiedLodIndex:null}}function Z(e,t,r,o){const s=e.model,i=new Array,n=new Map,l=new Map,a=s.lods.length,u=f();return s.lods.forEach(((e,c)=>{const m=!0===o.skipHighLods&&(a>1&&0===c||a>3&&1===c)||!1===o.skipHighLods&&null!=o.singleLodIndex&&c!==o.singleLodIndex;if(m&&0!==c)return;const f=new C(e.name,e.lodThreshold,[0,0,0]);e.parts.forEach((e=>{const o=m?new W({}):ee(s,e,f,t,r,n,l),{geometry:i,vertexCount:a}=te(e,null!=o?o:new W({})),p=i.boundingInfo;null!=p&&0===c&&(d(u,p.bbMin),d(u,p.bbMax)),null!=o&&(f.stageResources.geometries.push(i),f.numberOfVertices+=a)})),m||i.push(f)})),{engineResources:i,referenceBoundingBox:u}}function ee(e,t,r,o,s,i,n){const l=t.material+(t.attributes.normal?"_normal":"")+(t.attributes.color?"_color":"")+(t.attributes.texCoord0?"_texCoord0":"")+(t.attributes.tangent?"_tangent":""),a=e.materials.get(t.material),u=null!=t.attributes.texCoord0,c=null!=t.attributes.normal;if(null==a)return null;const m=oe(a.alphaMode);if(!i.has(l)){if(u){const t=(t,r=!1)=>{if(null!=t&&!n.has(t)){const o=e.textures.get(t);if(null!=o){const e=o.data;n.set(t,new H(O(e)?e.data:e,{...o.parameters,preMultiplyAlpha:!O(e)&&r,encoding:O(e)&&null!=e.encoding?e.encoding:void 0}))}}};t(a.textureColor,m!==V.Opaque),t(a.textureNormal),t(a.textureOcclusion),t(a.textureEmissive),t(a.textureMetallicRoughness)}const r=a.color[0]**(1/$),f=a.color[1]**(1/$),d=a.color[2]**(1/$),p=a.emissiveFactor[0]**(1/$),g=a.emissiveFactor[1]**(1/$),x=a.emissiveFactor[2]**(1/$),b=null!=a.textureColor&&u?n.get(a.textureColor):null,h=Q({normalTexture:a.textureNormal,metallicRoughnessTexture:a.textureMetallicRoughness,metallicFactor:a.metallicFactor,roughnessFactor:a.roughnessFactor,emissiveTexture:a.textureEmissive,emissiveFactor:a.emissiveFactor,occlusionTexture:a.textureOcclusion});i.set(l,new W({...o,transparent:m===V.Blend,customDepthTest:_.Lequal,textureAlphaMode:m,textureAlphaCutoff:a.alphaCutoff,diffuse:[r,f,d],ambient:[r,f,d],opacity:a.opacity,doubleSided:a.doubleSided,doubleSidedType:"winding-order",cullFace:a.doubleSided?D.None:D.Back,hasVertexColors:!!t.attributes.color,hasVertexTangents:!!t.attributes.tangent,normalType:c?P.Attribute:P.ScreenDerivative,castShadows:!0,receiveShadows:a.receiveShadows,receiveAmbientOcclusion:a.receiveAmbientOcclustion,textureId:null!=b?b.id:void 0,colorMixMode:a.colorMixMode,normalTextureId:null!=a.textureNormal&&u?n.get(a.textureNormal).id:void 0,textureAlphaPremultiplied:null!=b&&!!b.parameters.preMultiplyAlpha,occlusionTextureId:null!=a.textureOcclusion&&u?n.get(a.textureOcclusion).id:void 0,emissiveTextureId:null!=a.textureEmissive&&u?n.get(a.textureEmissive).id:void 0,metallicRoughnessTextureId:null!=a.textureMetallicRoughness&&u?n.get(a.textureMetallicRoughness).id:void 0,emissiveFactor:[p,g,x],mrrFactors:h?[...J]:[a.metallicFactor,a.roughnessFactor,o.mrrFactors[2]],isSchematic:h,colorTextureTransformMatrix:I(a.colorTextureTransform),normalTextureTransformMatrix:I(a.normalTextureTransform),occlusionTextureTransformMatrix:I(a.occlusionTextureTransform),emissiveTextureTransformMatrix:I(a.emissiveTextureTransform),metallicRoughnessTextureTransformMatrix:I(a.metallicRoughnessTextureTransform),...s}))}const f=i.get(l);if(r.stageResources.materials.push(f),u){const e=e=>{null!=e&&r.stageResources.textures.push(n.get(e))};e(a.textureColor),e(a.textureNormal),e(a.textureOcclusion),e(a.textureEmissive),e(a.textureMetallicRoughness)}return f}function te(e,r){const o=e.attributes.position.count,s=E(e.indices||o,e.primitiveType),i=p(3*o),{typedBuffer:n,typedBufferStride:l}=e.attributes.position;y(i,n,e.transform,3,l);const a=[[q.POSITION,new U(i,s,3,!0)]];if(null!=e.attributes.normal){const r=p(3*o),{typedBuffer:i,typedBufferStride:n}=e.attributes.normal;t(re,e.transform),v(r,i,re,3,n),a.push([q.NORMAL,new U(r,s,3,!0)])}if(null!=e.attributes.tangent){const r=p(4*o),{typedBuffer:i,typedBufferStride:n}=e.attributes.tangent;t(re,e.transform),j(r,i,re,4,n),a.push([q.TANGENT,new U(r,s,4,!0)])}if(null!=e.attributes.texCoord0){const t=p(2*o),{typedBuffer:r,typedBufferStride:i}=e.attributes.texCoord0;B(t,r,2,i),a.push([q.UV0,new U(t,s,2,!0)])}if(null!=e.attributes.color){const t=new Uint8Array(4*o);4===e.attributes.color.elementCount?e.attributes.color instanceof g?M(t,e.attributes.color,255):e.attributes.color instanceof x?F(t,e.attributes.color):e.attributes.color instanceof b&&M(t,e.attributes.color,1/256):(t.fill(255),e.attributes.color instanceof h?R(t,e.attributes.color,255,4):e.attributes.color instanceof T?S(t,e.attributes.color.typedBuffer,4,e.attributes.color.typedBufferStride):e.attributes.color instanceof w&&R(t,e.attributes.color,1/256,4)),a.push([q.COLOR,new U(t,s,4,!0)])}return{geometry:new G(r,a),vertexCount:o}}const re=r();function oe(e){switch(e){case"BLEND":return V.Blend;case"MASK":return V.Mask;case"OPAQUE":case null:case void 0:return V.Opaque}}function se(e,t){for(let r=0;r<e.model.lods.length;++r){const f=e.model.lods[r];for(const d of f.parts){const f=d.attributes.normal;if(null==f)return;const p=d.attributes.position,g=p.count,b=m(),T=m(),w=m(),y=new Uint8Array(4*g),v=new Float64Array(3*g),R=o(s(),d.transform);let j=0,M=0;for(let o=0;o<g;o++){p.getVec(o,T),f.getVec(o,b),i(T,T,d.transform),n(w,T,t.center),l(w,w,t.radius);const s=w[2],m=a(w),g=Math.min(.45+.55*m*m,1);l(w,w,t.radius),null!==R&&i(w,w,R),u(w,w),r+1!==e.model.lods.length&&e.model.lods.length>1&&c(w,w,b,s>-1?.2:Math.min(-4*s-3.8,1)),v[j]=w[0],v[j+1]=w[1],v[j+2]=w[2],j+=3,y[M]=255*g,y[M+1]=255*g,y[M+2]=255*g,y[M+3]=255,M+=4}d.attributes.normal=new h(v),d.attributes.color=new x(y)}}}export{X as fetch,Z as gltfToEngineResources,Y as parseUrl};
5
+ import{adjustStaticAGOUrl as e}from"../../../../core/devEnvironmentUtils.js";import{normalFromMat4 as t}from"../../../../core/libs/gl-matrix-2/math/mat3.js";import{create as r}from"../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{invert as o}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as s}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{ONES as i}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{e as n,f as l,G as a,l as u,n as c,k as m}from"../../../../chunks/vec32.js";import{create as f}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{empty as d,expandWithVec3 as p}from"../../../../geometry/support/aaBoundingBox.js";import{newFloatArray as g}from"../../../../geometry/support/FloatArray.js";import{BufferViewVec4f as x,BufferViewVec4u8 as b,BufferViewVec4u16 as h,BufferViewVec3f as T,BufferViewVec3u8 as w,BufferViewVec3u16 as y}from"../../../../geometry/support/buffer/BufferView.js";import{a as v,b as R,s as j}from"../../../../chunks/vec3.js";import{t as M,s as B}from"../../../../chunks/vec4.js";import{n as S}from"../../../../chunks/vec2.js";import{c as F}from"../../../../chunks/vec33.js";import{c as A}from"../../../../chunks/vec43.js";import{DefaultLoadingContext as L}from"../../glTF/DefaultLoadingContext.js";import{loadGLTF as E}from"../../glTF/loader.js";import{convertPrimitiveToTriangles as O}from"../../glTF/internal/indexUtils.js";import{isEncodedMeshTexture as I}from"../../glTF/internal/resourceUtils.js";import{getTransformMatrix as C}from"../../glTF/internal/TextureTransformUtils.js";import{ProcessedObjectResource as k}from"./ProcessedObjectResource.js";import{load as N,processLoadResult as P}from"./wosrLoader.js";import{NormalType as U}from"../../webgl-engine/core/shaderLibrary/attributes/NormalAttribute.glsl.js";import{Attribute as V}from"../../webgl-engine/lib/Attribute.js";import{AlphaDiscardMode as _,DepthTestFunction as D,CullFaceOptions as G}from"../../webgl-engine/lib/basicInterfaces.js";import{Geometry as H}from"../../webgl-engine/lib/Geometry.js";import{Texture as q}from"../../webgl-engine/lib/Texture.js";import{VertexAttribute as W}from"../../webgl-engine/lib/VertexAttribute.js";import{DefaultMaterial as $}from"../../webgl-engine/materials/DefaultMaterial.js";import{colorGamma as z}from"../../webgl-engine/materials/DefaultMaterial_COLOR_GAMMA.js";import{defaultEsriSymbologyMRRFactors as K,defaultAdvancedMRRFactors as Q,useSchematicPBR as J,defaultSchematicMRRFactors as X}from"../../webgl-engine/materials/pbrUtils.js";async function Y(t,r){const o=Z(e(t));if("wosr"===o.fileType){const e=await(r.cache?r.cache.loadWOSR(o.url,r):N(o.url,r)),{engineResources:t,referenceBoundingBox:s}=P(e,r);return{lods:t,referenceBoundingBox:s,isEsriSymbolResource:!1,isWosr:!0}}const s=await(r.cache?r.cache.loadGLTF(o.url,r,!!r.usePBR):E(new L(r.streamDataRequester),o.url,r,r.usePBR)),i=s.model.meta?.ESRI_proxyEllipsoid,n=s.meta.isEsriSymbolResource&&null!=i&&"EsriRealisticTreesStyle"===s.meta.ESRI_webstyle;n&&!s.customMeta.esriTreeRendering&&(s.customMeta.esriTreeRendering=!0,ie(s,i));const l=!!r.usePBR,a=s.meta.isEsriSymbolResource?{usePBR:l,isSchematic:!1,treeRendering:n,mrrFactors:[...K]}:{usePBR:l,isSchematic:!1,treeRendering:!1,mrrFactors:[...Q]},u={...r.materialParameters,treeRendering:n},{engineResources:c,referenceBoundingBox:m}=ee(s,a,u,r.skipHighLods&&null==o.specifiedLodIndex?{skipHighLods:!0}:{skipHighLods:!1,singleLodIndex:o.specifiedLodIndex});return{lods:c,referenceBoundingBox:m,isEsriSymbolResource:s.meta.isEsriSymbolResource,isWosr:!1}}function Z(e){const t=e.match(/(.*\.(gltf|glb))(\?lod=([0-9]+))?$/);if(t)return{fileType:"gltf",url:t[1],specifiedLodIndex:null!=t[4]?Number(t[4]):null};return e.match(/(.*\.(json|json\.gz))$/)?{fileType:"wosr",url:e,specifiedLodIndex:null}:{fileType:"unknown",url:e,specifiedLodIndex:null}}function ee(e,t,r,o){const s=e.model,i=new Array,n=new Map,l=new Map,a=s.lods.length,u=d();return s.lods.forEach(((e,c)=>{const m=!0===o.skipHighLods&&(a>1&&0===c||a>3&&1===c)||!1===o.skipHighLods&&null!=o.singleLodIndex&&c!==o.singleLodIndex;if(m&&0!==c)return;const f=new k(e.name,e.lodThreshold,[0,0,0]);e.parts.forEach((e=>{const o=m?new $({}):te(s,e,f,t,r,n,l),{geometry:i,vertexCount:a}=re(e,null!=o?o:new $({})),d=i.boundingInfo;null!=d&&0===c&&(p(u,d.bbMin),p(u,d.bbMax)),null!=o&&(f.stageResources.geometries.push(i),f.numberOfVertices+=a)})),m||i.push(f)})),{engineResources:i,referenceBoundingBox:u}}function te(e,t,r,o,s,n,l){const a=t.material+(t.attributes.normal?"_normal":"")+(t.attributes.color?"_color":"")+(t.attributes.texCoord0?"_texCoord0":"")+(t.attributes.tangent?"_tangent":""),u=e.materials.get(t.material),c=null!=t.attributes.texCoord0,m=null!=t.attributes.normal;if(null==u)return null;const f=se(u.alphaMode);if(!n.has(a)){if(c){const t=(t,r=!1)=>{if(null!=t&&!l.has(t)){const o=e.textures.get(t);if(null!=o){const e=o.data;l.set(t,new q(I(e)?e.data:e,{...o.parameters,preMultiplyAlpha:!I(e)&&r,encoding:I(e)&&null!=e.encoding?e.encoding:void 0}))}}};t(u.textureColor,f!==_.Opaque),t(u.textureNormal),t(u.textureOcclusion),t(u.textureEmissive),t(u.textureMetallicRoughness)}const r=u.color[0]**(1/z),d=u.color[1]**(1/z),p=u.color[2]**(1/z),g=u.emissiveFactor[0]**(1/z),x=u.emissiveFactor[1]**(1/z),b=u.emissiveFactor[2]**(1/z),h=null!=u.textureColor&&c?l.get(u.textureColor):null,T=J({normalTexture:u.textureNormal,metallicRoughnessTexture:u.textureMetallicRoughness,metallicFactor:u.metallicFactor,roughnessFactor:u.roughnessFactor,emissiveTexture:u.textureEmissive,emissiveFactor:u.emissiveFactor,occlusionTexture:u.textureOcclusion}),w=null!=u.normalTextureTransform?.scale?u.normalTextureTransform?.scale:i;n.set(a,new $({...o,transparent:f===_.Blend,customDepthTest:D.Lequal,textureAlphaMode:f,textureAlphaCutoff:u.alphaCutoff,diffuse:[r,d,p],ambient:[r,d,p],opacity:u.opacity,doubleSided:u.doubleSided,doubleSidedType:"winding-order",cullFace:u.doubleSided?G.None:G.Back,hasVertexColors:!!t.attributes.color,hasVertexTangents:!!t.attributes.tangent,normalType:m?U.Attribute:U.ScreenDerivative,castShadows:!0,receiveShadows:u.receiveShadows,receiveAmbientOcclusion:u.receiveAmbientOcclustion,textureId:null!=h?h.id:void 0,colorMixMode:u.colorMixMode,normalTextureId:null!=u.textureNormal&&c?l.get(u.textureNormal).id:void 0,textureAlphaPremultiplied:null!=h&&!!h.parameters.preMultiplyAlpha,occlusionTextureId:null!=u.textureOcclusion&&c?l.get(u.textureOcclusion).id:void 0,emissiveTextureId:null!=u.textureEmissive&&c?l.get(u.textureEmissive).id:void 0,metallicRoughnessTextureId:null!=u.textureMetallicRoughness&&c?l.get(u.textureMetallicRoughness).id:void 0,emissiveFactor:[g,x,b],mrrFactors:T?[...X]:[u.metallicFactor,u.roughnessFactor,o.mrrFactors[2]],isSchematic:T,colorTextureTransformMatrix:C(u.colorTextureTransform),normalTextureTransformMatrix:C(u.normalTextureTransform),scale:[w[0],w[1]],occlusionTextureTransformMatrix:C(u.occlusionTextureTransform),emissiveTextureTransformMatrix:C(u.emissiveTextureTransform),metallicRoughnessTextureTransformMatrix:C(u.metallicRoughnessTextureTransform),...s}))}const d=n.get(a);if(r.stageResources.materials.push(d),c){const e=e=>{null!=e&&r.stageResources.textures.push(l.get(e))};e(u.textureColor),e(u.textureNormal),e(u.textureOcclusion),e(u.textureEmissive),e(u.textureMetallicRoughness)}return d}function re(e,r){const o=e.attributes.position.count,s=O(e.indices||o,e.primitiveType),i=g(3*o),{typedBuffer:n,typedBufferStride:l}=e.attributes.position;v(i,n,e.transform,3,l);const a=[[W.POSITION,new V(i,s,3,!0)]];if(null!=e.attributes.normal){const r=g(3*o),{typedBuffer:i,typedBufferStride:n}=e.attributes.normal;t(oe,e.transform),R(r,i,oe,3,n),a.push([W.NORMAL,new V(r,s,3,!0)])}if(null!=e.attributes.tangent){const r=g(4*o),{typedBuffer:i,typedBufferStride:n}=e.attributes.tangent;t(oe,e.transform),M(r,i,oe,4,n),a.push([W.TANGENT,new V(r,s,4,!0)])}if(null!=e.attributes.texCoord0){const t=g(2*o),{typedBuffer:r,typedBufferStride:i}=e.attributes.texCoord0;S(t,r,2,i),a.push([W.UV0,new V(t,s,2,!0)])}if(null!=e.attributes.color){const t=new Uint8Array(4*o);4===e.attributes.color.elementCount?e.attributes.color instanceof x?B(t,e.attributes.color,255):e.attributes.color instanceof b?A(t,e.attributes.color):e.attributes.color instanceof h&&B(t,e.attributes.color,1/256):(t.fill(255),e.attributes.color instanceof T?j(t,e.attributes.color,255,4):e.attributes.color instanceof w?F(t,e.attributes.color.typedBuffer,4,e.attributes.color.typedBufferStride):e.attributes.color instanceof y&&j(t,e.attributes.color,1/256,4)),a.push([W.COLOR,new V(t,s,4,!0)])}return{geometry:new H(r,a),vertexCount:o}}const oe=r();function se(e){switch(e){case"BLEND":return _.Blend;case"MASK":return _.Mask;case"OPAQUE":case null:case void 0:return _.Opaque}}function ie(e,t){for(let r=0;r<e.model.lods.length;++r){const i=e.model.lods[r];for(const d of i.parts){const i=d.attributes.normal;if(null==i)return;const p=d.attributes.position,g=p.count,x=f(),h=f(),w=f(),y=new Uint8Array(4*g),v=new Float64Array(3*g),R=o(s(),d.transform);let j=0,M=0;for(let o=0;o<g;o++){p.getVec(o,h),i.getVec(o,x),n(h,h,d.transform),l(w,h,t.center),a(w,w,t.radius);const s=w[2],f=u(w),g=Math.min(.45+.55*f*f,1);a(w,w,t.radius),null!==R&&n(w,w,R),c(w,w),r+1!==e.model.lods.length&&e.model.lods.length>1&&m(w,w,x,s>-1?.2:Math.min(-4*s-3.8,1)),v[j]=w[0],v[j+1]=w[1],v[j+2]=w[2],j+=3,y[M]=255*g,y[M+1]=255*g,y[M+2]=255*g,y[M+3]=255,M+=4}d.attributes.normal=new T(v),d.attributes.color=new b(y)}}}export{Y as fetch,ee as gltfToEngineResources,Z as parseUrl};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.30/esri/copyright.txt for details.
4
4
  */
5
- import"../../../../core/has.js";import{clamp as e}from"../../../../core/mathUtils.js";import{fromMat4 as t}from"../../../../core/libs/gl-matrix-2/math/mat3.js";import{create as o}from"../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{identity as i,copy as n,set as s,multiply as r,scale as l,translate as a,rotateZ as u,rotateX as f,rotateY as c}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as p}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{s as d}from"../../../../chunks/vec32.js";import{create as z}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{meterIn as m}from"../../../../renderers/support/lengthUtils.js";import{debugFlags as v}from"../../support/debugFlags.js";import{NoParameters as S}from"../../webgl-engine/core/shaderModules/interfaces.js";var h,y;!function(e){e[e.Undefined=0]="Undefined",e[e.DefinedSize=1]="DefinedSize",e[e.DefinedScale=2]="DefinedScale"}(h||(h={})),function(e){e[e.Undefined=0]="Undefined",e[e.DefinedAngle=1]="DefinedAngle"}(y||(y={}));class x{constructor(e){this.field=e}}class g extends x{constructor(e){super(e),this.minSize=[0,0,0],this.maxSize=[0,0,0],this.offset=[0,0,0],this.factor=[0,0,0],this.type=[h.Undefined,h.Undefined,h.Undefined]}}class b extends x{constructor(e){super(e),this.colors=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],this.values=[0,0,0,0,0,0,0,0]}}class C extends x{constructor(e){super(e),this.values=[0,0,0,0,0,0,0,0],this.opacityValues=[0,0,0,0,0,0,0,0]}}class D extends x{constructor(e){super(e),this.offset=[0,0,0],this.factor=[1,1,1],this.type=[0,0,0]}}class U{}function w(e){return null!=e}function V(e){return"number"==typeof e}function M(e){return"string"==typeof e}function j(e){return null==e||M(e)}function A(e,t){e&&e.push(t)}function I(e,t,o,i=p()){const n=e||0,s=t||0,r=o||0;return 0!==n&&u(i,i,-n/180*Math.PI),0!==s&&f(i,i,s/180*Math.PI),0!==r&&c(i,i,r/180*Math.PI),i}function T(e,t,o,i,n){const s=e.minSize,r=e.maxSize;if(e.expression)return A(n,"Could not convert size info: expression not supported"),!1;if(e.useSymbolValue){const e=i.symbolSize[o];return t.minSize[o]=e,t.maxSize[o]=e,t.offset[o]=t.minSize[o],t.factor[o]=0,t.type[o]=h.DefinedSize,!0}if(w(e.field))return w(e.stops)?2===e.stops.length&&V(e.stops[0].size)&&V(e.stops[1].size)?(F(e.stops[0].size,e.stops[1].size,e.stops[0].value,e.stops[1].value,t,o),t.type[o]=h.DefinedSize,!0):(A(n,"Could not convert size info: stops only supported with 2 elements"),!1):V(s)&&V(r)&&w(e.minDataValue)&&w(e.maxDataValue)?(F(s,r,e.minDataValue,e.maxDataValue,t,o),t.type[o]=h.DefinedSize,!0):"unknown"===e.valueUnit?(A(n,"Could not convert size info: proportional size not supported"),!1):null!=m[e.valueUnit]?(t.minSize[o]=-1/0,t.maxSize[o]=1/0,t.offset[o]=0,t.factor[o]=1/m[e.valueUnit],t.type[o]=h.DefinedSize,!0):(A(n,"Could not convert size info: scale-dependent size not supported"),!1);if(!w(e.field)){if(e.stops?.[0]&&V(e.stops[0].size))return t.minSize[o]=e.stops[0].size,t.maxSize[o]=e.stops[0].size,t.offset[o]=t.minSize[o],t.factor[o]=0,t.type[o]=h.DefinedSize,!0;if(V(s))return t.minSize[o]=s,t.maxSize[o]=s,t.offset[o]=s,t.factor[o]=0,t.type[o]=h.DefinedSize,!0}return A(n,"Could not convert size info: unsupported variant of sizeInfo"),!1}function F(e,t,o,i,n,s){const r=Math.abs(i-o)>0?(t-e)/(i-o):0;n.minSize[s]=r>0?e:t,n.maxSize[s]=r>0?t:e,n.offset[s]=e-o*r,n.factor[s]=r}function P(e,t,o,i){if(e.normalizationField||e.valueRepresentation)return A(i,"Could not convert size info: unsupported property"),null;if(!j(e.field))return A(i,"Could not convert size info: field is not a string"),null;if(t.size){if(e.field)if(t.size.field){if(e.field!==t.size.field)return A(i,"Could not convert size info: multiple fields in use"),null}else t.size.field=e.field}else t.size=new g(e.field);let n;switch(e.axis){case"width":return n=T(e,t.size,0,o,i),n?t:null;case"height":return n=T(e,t.size,2,o,i),n?t:null;case"depth":return n=T(e,t.size,1,o,i),n?t:null;case"width-and-depth":return n=T(e,t.size,0,o,i),n&&T(e,t.size,1,o,i),n?t:null;case null:case void 0:case"all":return n=T(e,t.size,0,o,i),n=n&&T(e,t.size,1,o,i),n=n&&T(e,t.size,2,o,i),n?t:null;default:return A(i,`Could not convert size info: unknown axis "${e.axis}""`),null}}function R(e,t,o){for(let n=0;n<3;++n){let o=t.unitInMeters;e.type[n]===h.DefinedSize&&(o*=t.modelSize[n],e.type[n]=h.DefinedScale),e.minSize[n]=e.minSize[n]/o,e.maxSize[n]=e.maxSize[n]/o,e.offset[n]=e.offset[n]/o,e.factor[n]=e.factor[n]/o}let i;if(e.type[0]!==h.Undefined)i=0;else if(e.type[1]!==h.Undefined)i=1;else{if(e.type[2]===h.Undefined)return A(o,"No size axis contains a valid size or scale"),!1;i=2}for(let n=0;n<3;++n)e.type[n]===h.Undefined&&(e.minSize[n]=e.minSize[i],e.maxSize[n]=e.maxSize[i],e.offset[n]=e.offset[i],e.factor[n]=e.factor[i],e.type[n]=e.type[i]);return!0}function k(e,t,o){e[4*t]=o.r/255,e[4*t+1]=o.g/255,e[4*t+2]=o.b/255,e[4*t+3]=o.a}function E(e,t,o){if(e.normalizationField)return A(o,"Could not convert color info: unsupported property"),null;if(M(e.field)){if(!e.stops)return A(o,"Could not convert color info: missing stops or colors"),null;{if(e.stops.length>8)return A(o,"Could not convert color info: too many color stops"),null;t.color=new b(e.field);const i=e.stops;for(let e=0;e<8;++e){const o=i[Math.min(e,i.length-1)];t.color.values[e]=o.value,k(t.color.colors,e,o.color)}}}else{if(!(e.stops&&e.stops.length>=0))return A(o,"Could not convert color info: no field and no colors/stops"),null;{const o=e.stops&&e.stops.length>=0&&e.stops[0].color;t.color={field:null,values:[0,0,0,0,0,0,0,0],colors:[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]};for(let e=0;e<8;e++)t.color.values[e]=1/0,k(t.color.colors,e,o)}}return t}function _(e,t,o){if(e.normalizationField)return A(o,"Could not convert opacity info: unsupported property"),null;if(M(e.field)){if(!e.stops)return A(o,"Could not convert opacity info: missing stops or opacities"),null;{if(e.stops.length>8)return A(o,"Could not convert opacity info: too many opacity stops"),null;t.opacity=new C(e.field);const i=e.stops;for(let e=0;e<8;++e){const o=i[Math.min(e,i.length-1)];t.opacity.values[e]=o.value,t.opacity.opacityValues[e]=o.opacity}}}else{if(!(e.stops&&e.stops.length>=0))return A(o,"Could not convert opacity info: no field and no opacities/stops"),null;{const o=e.stops&&e.stops.length>=0?e.stops[0].opacity:0;t.opacity={field:null,values:[0,0,0,0,0,0,0,0],opacityValues:[0,0,0,0,0,0,0,0]};for(let e=0;e<8;e++)t.opacity.values[e]=1/0,t.opacity.opacityValues[e]=o}}return t}function q(e,t,o){const i=2===o&&"arithmetic"===e.rotationType;t.offset[o]=i?90:0,t.factor[o]=i?-1:1,t.type[o]=1}function $(e,t,o){if(!M(e.field))return A(o,"Could not convert rotation info: field is not a string"),null;if(t.rotation){if(e.field)if(t.rotation.field){if(e.field!==t.rotation.field)return A(o,"Could not convert rotation info: multiple fields in use"),null}else t.rotation.field=e.field}else t.rotation={field:e.field,offset:[0,0,0],factor:[1,1,1],type:[0,0,0]};switch(e.axis){case"tilt":return q(e,t.rotation,0),t;case"roll":return q(e,t.rotation,1),t;case null:case void 0:case"heading":return q(e,t.rotation,2),t;default:return A(o,`Could not convert rotation info: unknown axis "${e.axis}""`),null}}class B{constructor(e,t=[1,1,1],o=[1,1,1],i=1,n=[0,0,0],s=[1,1,1],r=[0,0,0]){this.supports=e,this.modelSize=t,this.symbolSize=o,this.unitInMeters=i,this.anchor=n,this.scale=s,this.rotation=r}}function L(e,t,o){if(!e)return null;const i=e.reduce(((e,i)=>{if(!e)return e;if(i.valueExpression)return A(o,"Could not convert visual variables: arcade expressions not supported"),null;switch(i.type){case"size":return t.supports.size?P(i,e,t,o):e;case"color":return t.supports.color?E(i,e,o):e;case"opacity":return t.supports.opacity?_(i,e,o):null;case"rotation":return t.supports.rotation?$(i,e,o):e;default:return null}}),new U);return!(e.length>0&&i)||i.size||i.color||i.opacity||i.rotation?i?.size&&!R(i.size,t,o)?null:i:null}class N{constructor(e,t,o){this.visualVariables=e,this.materialParameters=t,this.requiresShaderTransformation=o}}function O(e,t){if(!e)return null;if(v.TESTS_DISABLE_FAST_UPDATES)return null;const o=L(e.visualVariables,t);return o?new N(o,K(o,t),!!o.size):null}function G(e,t,o){if(!t||!e)return!1;const i=e.visualVariables,n=L(t.visualVariables,o);return!!n&&(!!(H(i.size,n.size,"size")&&H(i.color,n.color,"color")&&H(i.rotation,n.rotation,"rotation")&&H(i.opacity,n.opacity,"opacity"))&&(e.visualVariables=n,e.materialParameters=K(n,o),e.requiresShaderTransformation=!!n.size,!0))}function H(e,t,o){if(!!e!=!!t)return!1;if(e&&e.field!==t?.field)return!1;if(e&&"rotation"===o){const o=e,i=t;for(let e=0;e<3;e++)if(o.type[e]!==i.type[e]||o.offset[e]!==i.offset[e]||o.factor[e]!==i.factor[e])return!1}return!0}class J extends S{constructor(e){super(),this.vvSize=e?.size??null,this.vvColor=e?.color??null,this.vvOpacity=e?.opacity??null}}function K(e,n){const s=new J(e);return s.vvSize&&(s.vvSymbolAnchor=n.anchor,i(ee),I(n.rotation[2],n.rotation[0],n.rotation[1],ee),s.vvSymbolRotationMatrix=s.vvSymbolRotationMatrix||o(),t(s.vvSymbolRotationMatrix,ee)),s}function Q(t,o,i){if(!t.vvSize)return i;n(Y,i);const u=t.vvSymbolRotationMatrix;s(ee,u[0],u[1],u[2],0,u[3],u[4],u[5],0,u[6],u[7],u[8],0,0,0,0,1),r(Y,Y,ee);for(let n=0;n<3;++n){const i=t.vvSize.offset[n]+o[0]*t.vvSize.factor[n];Z[n]=e(i,t.vvSize.minSize[n],t.vvSize.maxSize[n])}return l(Y,Y,Z),a(Y,Y,t.vvSymbolAnchor),Y}function W(t,o,i){if(!o.vvSize)return d(t,1,1,1),t;for(let n=0;n<3;++n){const s=o.vvSize.offset[n]+i[0]*o.vvSize.factor[n];t[n]=e(s,o.vvSize.minSize[n],o.vvSize.maxSize[n])}return t}function X(e,t){const o=null==e?0:t.attributes[e];return"number"==typeof o&&isFinite(o)?o:0}const Y=p(),Z=z(),ee=p();export{B as ConvertOptions,b as FastColorInfo,C as FastOpacityInfo,D as FastRotationInfo,y as FastRotationType,g as FastSizeInfo,h as FastSizeType,N as FastSymbolUpdatesState,U as FastVisualVariables,J as VisualVariablesParameters,L as convertVisualVariables,Q as evaluateModelTransform,W as evaluateModelTransformScale,X as getAttributeValue,K as getMaterialParameters,O as initFastSymbolUpdatesState,G as updateFastSymbolUpdatesState};
5
+ import"../../../../core/has.js";import{clamp as e}from"../../../../core/mathUtils.js";import{fromMat4 as t}from"../../../../core/libs/gl-matrix-2/math/mat3.js";import{create as o}from"../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{identity as i,copy as n,set as s,multiply as r,scale as l,translate as a,rotateZ as u,rotateX as f,rotateY as c}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as p}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{s as d}from"../../../../chunks/vec32.js";import{create as z}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{meterIn as m}from"../../../../renderers/support/lengthUtils.js";import{debugFlags as v}from"../../support/debugFlags.js";import{NoParameters as S}from"../../webgl-engine/core/shaderModules/interfaces.js";var h,y;!function(e){e[e.Undefined=0]="Undefined",e[e.DefinedSize=1]="DefinedSize",e[e.DefinedScale=2]="DefinedScale"}(h||(h={})),function(e){e[e.Undefined=0]="Undefined",e[e.DefinedAngle=1]="DefinedAngle"}(y||(y={}));class x{constructor(e){this.field=e}}class g extends x{constructor(e){super(e),this.minSize=[0,0,0],this.maxSize=[0,0,0],this.offset=[0,0,0],this.factor=[0,0,0],this.type=[h.Undefined,h.Undefined,h.Undefined]}}class b extends x{constructor(e){super(e),this.colors=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],this.values=[0,0,0,0,0,0,0,0]}}class C extends x{constructor(e){super(e),this.values=[0,0,0,0,0,0,0,0],this.opacityValues=[0,0,0,0,0,0,0,0]}}class D extends x{constructor(e){super(e),this.offset=[0,0,0],this.factor=[1,1,1],this.type=[0,0,0]}}class U{}function w(e){return null!=e}function V(e){return"number"==typeof e}function M(e){return"string"==typeof e}function j(e){return null==e||M(e)}function A(e,t){e&&e.push(t)}function I(e,t,o,i=p()){const n=e||0,s=t||0,r=o||0;return 0!==n&&u(i,i,-n/180*Math.PI),0!==s&&f(i,i,s/180*Math.PI),0!==r&&c(i,i,r/180*Math.PI),i}function T(e,t,o,i,n){const s=e.minSize,r=e.maxSize;if(e.useSymbolValue){const e=i.symbolSize[o];return t.minSize[o]=e,t.maxSize[o]=e,t.offset[o]=t.minSize[o],t.factor[o]=0,t.type[o]=h.DefinedSize,!0}if(w(e.field))return w(e.stops)?2===e.stops.length&&V(e.stops[0].size)&&V(e.stops[1].size)?(F(e.stops[0].size,e.stops[1].size,e.stops[0].value,e.stops[1].value,t,o),t.type[o]=h.DefinedSize,!0):(A(n,"Could not convert size info: stops only supported with 2 elements"),!1):V(s)&&V(r)&&w(e.minDataValue)&&w(e.maxDataValue)?(F(s,r,e.minDataValue,e.maxDataValue,t,o),t.type[o]=h.DefinedSize,!0):"unknown"===e.valueUnit?(A(n,"Could not convert size info: proportional size not supported"),!1):null!=m[e.valueUnit]?(t.minSize[o]=-1/0,t.maxSize[o]=1/0,t.offset[o]=0,t.factor[o]=1/m[e.valueUnit],t.type[o]=h.DefinedSize,!0):(A(n,"Could not convert size info: scale-dependent size not supported"),!1);if(!w(e.field)){if(e.stops?.[0]&&V(e.stops[0].size))return t.minSize[o]=e.stops[0].size,t.maxSize[o]=e.stops[0].size,t.offset[o]=t.minSize[o],t.factor[o]=0,t.type[o]=h.DefinedSize,!0;if(V(s))return t.minSize[o]=s,t.maxSize[o]=s,t.offset[o]=s,t.factor[o]=0,t.type[o]=h.DefinedSize,!0}return A(n,"Could not convert size info: unsupported variant of sizeInfo"),!1}function F(e,t,o,i,n,s){const r=Math.abs(i-o)>0?(t-e)/(i-o):0;n.minSize[s]=r>0?e:t,n.maxSize[s]=r>0?t:e,n.offset[s]=e-o*r,n.factor[s]=r}function P(e,t,o,i){if(e.normalizationField||e.valueRepresentation)return A(i,"Could not convert size info: unsupported property"),null;if(!j(e.field))return A(i,"Could not convert size info: field is not a string"),null;if(t.size){if(e.field)if(t.size.field){if(e.field!==t.size.field)return A(i,"Could not convert size info: multiple fields in use"),null}else t.size.field=e.field}else t.size=new g(e.field);let n;switch(e.axis){case"width":return n=T(e,t.size,0,o,i),n?t:null;case"height":return n=T(e,t.size,2,o,i),n?t:null;case"depth":return n=T(e,t.size,1,o,i),n?t:null;case"width-and-depth":return n=T(e,t.size,0,o,i),n&&T(e,t.size,1,o,i),n?t:null;case null:case void 0:case"all":return n=T(e,t.size,0,o,i),n=n&&T(e,t.size,1,o,i),n=n&&T(e,t.size,2,o,i),n?t:null;default:return A(i,`Could not convert size info: unknown axis "${e.axis}""`),null}}function R(e,t,o){for(let n=0;n<3;++n){let o=t.unitInMeters;e.type[n]===h.DefinedSize&&(o*=t.modelSize[n],e.type[n]=h.DefinedScale),e.minSize[n]=e.minSize[n]/o,e.maxSize[n]=e.maxSize[n]/o,e.offset[n]=e.offset[n]/o,e.factor[n]=e.factor[n]/o}let i;if(e.type[0]!==h.Undefined)i=0;else if(e.type[1]!==h.Undefined)i=1;else{if(e.type[2]===h.Undefined)return A(o,"No size axis contains a valid size or scale"),!1;i=2}for(let n=0;n<3;++n)e.type[n]===h.Undefined&&(e.minSize[n]=e.minSize[i],e.maxSize[n]=e.maxSize[i],e.offset[n]=e.offset[i],e.factor[n]=e.factor[i],e.type[n]=e.type[i]);return!0}function k(e,t,o){e[4*t]=o.r/255,e[4*t+1]=o.g/255,e[4*t+2]=o.b/255,e[4*t+3]=o.a}function E(e,t,o){if(e.normalizationField)return A(o,"Could not convert color info: unsupported property"),null;if(M(e.field)){if(!e.stops)return A(o,"Could not convert color info: missing stops or colors"),null;{if(e.stops.length>8)return A(o,"Could not convert color info: too many color stops"),null;t.color=new b(e.field);const i=e.stops;for(let e=0;e<8;++e){const o=i[Math.min(e,i.length-1)];t.color.values[e]=o.value,k(t.color.colors,e,o.color)}}}else{if(!(e.stops&&e.stops.length>=0))return A(o,"Could not convert color info: no field and no colors/stops"),null;{const o=e.stops&&e.stops.length>=0&&e.stops[0].color;t.color={field:null,values:[0,0,0,0,0,0,0,0],colors:[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]};for(let e=0;e<8;e++)t.color.values[e]=1/0,k(t.color.colors,e,o)}}return t}function _(e,t,o){if(e.normalizationField)return A(o,"Could not convert opacity info: unsupported property"),null;if(M(e.field)){if(!e.stops)return A(o,"Could not convert opacity info: missing stops or opacities"),null;{if(e.stops.length>8)return A(o,"Could not convert opacity info: too many opacity stops"),null;t.opacity=new C(e.field);const i=e.stops;for(let e=0;e<8;++e){const o=i[Math.min(e,i.length-1)];t.opacity.values[e]=o.value,t.opacity.opacityValues[e]=o.opacity}}}else{if(!(e.stops&&e.stops.length>=0))return A(o,"Could not convert opacity info: no field and no opacities/stops"),null;{const o=e.stops&&e.stops.length>=0?e.stops[0].opacity:0;t.opacity={field:null,values:[0,0,0,0,0,0,0,0],opacityValues:[0,0,0,0,0,0,0,0]};for(let e=0;e<8;e++)t.opacity.values[e]=1/0,t.opacity.opacityValues[e]=o}}return t}function q(e,t,o){const i=2===o&&"arithmetic"===e.rotationType;t.offset[o]=i?90:0,t.factor[o]=i?-1:1,t.type[o]=1}function $(e,t,o){if(!M(e.field))return A(o,"Could not convert rotation info: field is not a string"),null;if(t.rotation){if(e.field)if(t.rotation.field){if(e.field!==t.rotation.field)return A(o,"Could not convert rotation info: multiple fields in use"),null}else t.rotation.field=e.field}else t.rotation={field:e.field,offset:[0,0,0],factor:[1,1,1],type:[0,0,0]};switch(e.axis){case"tilt":return q(e,t.rotation,0),t;case"roll":return q(e,t.rotation,1),t;case null:case void 0:case"heading":return q(e,t.rotation,2),t;default:return A(o,`Could not convert rotation info: unknown axis "${e.axis}""`),null}}class B{constructor(e,t=[1,1,1],o=[1,1,1],i=1,n=[0,0,0],s=[1,1,1],r=[0,0,0]){this.supports=e,this.modelSize=t,this.symbolSize=o,this.unitInMeters=i,this.anchor=n,this.scale=s,this.rotation=r}}function L(e,t,o){if(!e)return null;const i=e.reduce(((e,i)=>{if(!e)return e;if(i.valueExpression)return A(o,"Could not convert visual variables: arcade expressions not supported"),null;switch(i.type){case"size":return t.supports.size?P(i,e,t,o):e;case"color":return t.supports.color?E(i,e,o):e;case"opacity":return t.supports.opacity?_(i,e,o):null;case"rotation":return t.supports.rotation?$(i,e,o):e;default:return null}}),new U);return!(e.length>0&&i)||i.size||i.color||i.opacity||i.rotation?i?.size&&!R(i.size,t,o)?null:i:null}class N{constructor(e,t,o){this.visualVariables=e,this.materialParameters=t,this.requiresShaderTransformation=o}}function O(e,t){if(!e)return null;if(v.TESTS_DISABLE_FAST_UPDATES)return null;const o=L(e.visualVariables,t);return o?new N(o,K(o,t),!!o.size):null}function G(e,t,o){if(!t||!e)return!1;const i=e.visualVariables,n=L(t.visualVariables,o);return!!n&&(!!(H(i.size,n.size,"size")&&H(i.color,n.color,"color")&&H(i.rotation,n.rotation,"rotation")&&H(i.opacity,n.opacity,"opacity"))&&(e.visualVariables=n,e.materialParameters=K(n,o),e.requiresShaderTransformation=!!n.size,!0))}function H(e,t,o){if(!!e!=!!t)return!1;if(e&&e.field!==t?.field)return!1;if(e&&"rotation"===o){const o=e,i=t;for(let e=0;e<3;e++)if(o.type[e]!==i.type[e]||o.offset[e]!==i.offset[e]||o.factor[e]!==i.factor[e])return!1}return!0}class J extends S{constructor(e){super(),this.vvSize=e?.size??null,this.vvColor=e?.color??null,this.vvOpacity=e?.opacity??null}}function K(e,n){const s=new J(e);return s.vvSize&&(s.vvSymbolAnchor=n.anchor,i(ee),I(n.rotation[2],n.rotation[0],n.rotation[1],ee),s.vvSymbolRotationMatrix=s.vvSymbolRotationMatrix||o(),t(s.vvSymbolRotationMatrix,ee)),s}function Q(t,o,i){if(!t.vvSize)return i;n(Y,i);const u=t.vvSymbolRotationMatrix;s(ee,u[0],u[1],u[2],0,u[3],u[4],u[5],0,u[6],u[7],u[8],0,0,0,0,1),r(Y,Y,ee);for(let n=0;n<3;++n){const i=t.vvSize.offset[n]+o[0]*t.vvSize.factor[n];Z[n]=e(i,t.vvSize.minSize[n],t.vvSize.maxSize[n])}return l(Y,Y,Z),a(Y,Y,t.vvSymbolAnchor),Y}function W(t,o,i){if(!o.vvSize)return d(t,1,1,1),t;for(let n=0;n<3;++n){const s=o.vvSize.offset[n]+i[0]*o.vvSize.factor[n];t[n]=e(s,o.vvSize.minSize[n],o.vvSize.maxSize[n])}return t}function X(e,t){const o=null==e?0:t.attributes[e];return"number"==typeof o&&isFinite(o)?o:0}const Y=p(),Z=z(),ee=p();export{B as ConvertOptions,b as FastColorInfo,C as FastOpacityInfo,D as FastRotationInfo,y as FastRotationType,g as FastSizeInfo,h as FastSizeType,N as FastSymbolUpdatesState,U as FastVisualVariables,J as VisualVariablesParameters,L as convertVisualVariables,Q as evaluateModelTransform,W as evaluateModelTransformScale,X as getAttributeValue,K as getMaterialParameters,O as initFastSymbolUpdatesState,G as updateFastSymbolUpdatesState};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.30/esri/copyright.txt for details.
4
4
  */
5
- import{acosClamped as e}from"../../../../core/mathUtils.js";import t from"../../../../core/ObjectPool.js";import{f as s,i as r,g as i,n,y as o,j as u,q as c,s as a,m as l,b as d,E as _,C as h}from"../../../../chunks/vec32.js";import{create as f,fromValues as m}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{getReferenceEllipsoid as p}from"../../../../geometry/ellipsoidUtils.js";import{projectBuffer as T}from"../../../../geometry/projection/projectBuffer.js";import{projectVec3Array as F}from"../../../../geometry/projection/projectVec3Array.js";import{PlaneIndex as E,PointIndex as g}from"../../../../geometry/support/frustum.js";import{create as I,projectVector as R,fromPoints as A,getNormal as O,signedDistance as S}from"../../../../geometry/support/plane.js";import{wrap as b}from"../../../../geometry/support/ray.js";import{ViewingMode as P}from"../../../ViewingMode.js";import{FeatureTileDescriptor3D as B,Visibility as j}from"./FeatureTileDescriptor3D.js";import{Frustum as H}from"../../state/Frustum.js";import{FrustumExtentIntersection as x}from"../../support/FrustumExtentIntersection.js";class N{constructor(e){this._renderCoordsHelper=e,this._surfaceElevation=0,this._cache=new Map,this._frustumBoundingSphereCenter=f(),this._frustumBoundingSphereRadius=0,this._frustum=new H(e),this._extendedFrustum=new H(e),this._intersector=new x({renderCoordsHelper:e}),this._renderCoordsHelper=e}begin(e,t){this._surfaceElevation=t,this._aboveGround=this._renderCoordsHelper.getAltitude(e.eye)>t,this._frustum.update(e),this._shortenFrustumFarPlane(this._frustum),this._updateExtendedFrustum(e),this._updateFrustumBoundingSphere()}end(){this._cache.clear()}calculate(e){const t=this._renderCoordsHelper.viewingMode===P.Global&&e.lij[0]>=V&&e.lij[0]<C,s=this._getOrCalculateSingleTileVisibility(e,!t);return s!==j.INVISIBLE&&t?this._calculateAggregatedChildrenVisibility(e):s}_shortenFrustumFarPlane(e){const t=H.nearFarLineIndices,n=e.mutablePoints;for(const o of t){const[e,t]=o,u=n[e],c=n[t];s(y,c,u),r(y,y,M),i(n[t],u,y)}e.updatePoints(n)}_calculateAggregatedChildrenVisibility(e){let t=j.INVISIBLE;const s=this._cache.get(e.id);if(null!=s)return s;const r=U.acquire();e.getChildren(r);for(const i of r){const e=this.calculate(i);if(e!==j.INVISIBLE&&(t=e,e===j.VISIBLE_ON_SURFACE))break}return U.release(r),this._cache.set(e.id,t),t}_getOrCalculateSingleTileVisibility(e,t){const s=this._cache.get(e.id);if(null!=s)return s;const r=this._calculateSingleTileVisibility(e);return t&&this._cache.set(e.id,r),r}_calculateSingleTileVisibility(e){if(!this._aboveGround&&this._renderCoordsHelper.viewingMode===P.Global&&e.lij[0]<G){return this._calculateSingleTileVisibilitySided(e,!1)===j.INVISIBLE?this._calculateSingleTileVisibilitySided(e,!0):void 0}return this._calculateSingleTileVisibilitySided(e,this._aboveGround)}_isTileVisibleInFrustum(e){return this._renderCoordsHelper.viewingMode===P.Local?this._isTileVisibleInFrustumLocal(e):this._isTileVisibleInFrustumGlobal(e)}_updateFrustumBoundingSphere(){const e=this._frustum,t=e.origin,s=ae;n(s,e.direction);const r=e.points,i=le;o(i,r[4],t);const a=.5*u(i,i)/u(s,i),l=this._frustumBoundingSphereCenter;c(l,t,s,a);const d=1+a;this._frustumBoundingSphereRadius=d}_isTileVisibleInFrustumLocal(e){const t=e.tilingScheme.spatialReference,s=e.extent,r=this._renderCoordsHelper.spatialReference,i=Z;if(i[0]=s[0],i[1]=s[1],i[2]=0,i[3]=s[2],i[4]=s[3],i[5]=0,!T(i,t,0,i,r,0,2))return!1;const n=$;a(n[0],i[0],i[1],0),a(n[1],i[3],i[1],0),a(n[2],i[3],i[4],0),a(n[3],i[0],i[4],0);const d=ee;a(d,.5*(i[0]+i[3]),.5*(i[1]+i[4]),.5*(i[2]+i[5]));const _=te;a(_,0,0,1);const h=.5*l(n[0],n[2]),f=this._frustum,m=this._frustumBoundingSphereRadius,p=this._frustumBoundingSphereCenter,F=_e;o(F,p,d);const E=u(_,F),g=de;c(g,d,_,E);if(l(g,p)>h+m)return!1;const I=Q,R=E+m,A=E-m;for(let o=0;o<4;++o)c(I[o],n[o],_,R),c(I[o+4],n[o],_,A);return!X(f.planes,I,8)}_isTileVisibleInFrustumGlobal(e){const t=e.tilingScheme.spatialReference,s=e.extent,_=this._renderCoordsHelper.spatialReference;if(e.lij[0]<Y)return!0;const h=$,f=.5*(s[0]+s[2]),T=h[0][2]>0,E=h[3][2]<0,g=T||E,I=s[T?1:3];if(a(h[0],s[0],s[1],0),a(h[1],s[2],s[1],0),a(h[2],s[2],s[3],0),a(h[3],s[0],s[3],0),a(h[4],f,I,0),!F(h,t,0,h,_,0,g?5:4))return!1;const R=p(_).radius;if(g){const e=m(0,0,1),t=re;W(t,e,h[0]);const s=ie;if(W(s,e,h[1]),T){const r=se,i=h[4],n=ne;W(n,i,e),W(r,n,i);const o=h[0];d(o,t,r),k(o,R);const u=h[1];d(u,s,r),k(u,R)}else if(E){const r=se,i=h[4],n=ne;W(n,i,e),W(r,i,n);const o=h[3];d(o,r,t),k(o,R);const u=h[2];d(u,r,s),k(u,R)}}const A=ee;{const e=Te;o(e,h[3],h[0]),n(e,e);const t=Fe;i(t,h[0],h[3]),r(t,t,.5);const s=-u(t,e),a=Ee,l=ge;i(a,h[0],h[1]),r(a,a,.5),i(l,h[2],h[3]),r(l,l,.5);const d=Ie;o(d,l,a),n(d,d);const _=-(s+u(e,a))/u(e,d);c(A,a,d,_),k(A,R)}r(te,A,1/R);const O=he,S=this._frustumBoundingSphereRadius,b=this._frustumBoundingSphereCenter,P=this._frustum,B=P.planes;if(h.some((e=>P.intersectsPoint(e))))return!0;if(P.intersectsPoint(A))return!0;const j=oe;n(j,A);const H=fe;o(H,b,O);const x=u(H,j);if(x<-S)return!1;const N=ce;n(N,h[0]);const V=u(N,j);if(V<=0)return!0;const C=ue;r(C,j,x);const G=l(C,b),M=t.isWGS84,L=e.lij,y=M&&L[2]===2**L[0]-1,v=M&&0===L[2],w=v?xe:y?je:Pe,U=v?Ne:y?He:Be,z=P.points;{const e=h,t=Ve;for(const s of w){const r=Re,i=Ae,n=e[s],o=O;if(D(r,e[(s+1)%4],n),D(i,o,n),W(t,i,r),K(t,z))return!1}}let q=null;if(x<2*S){const e=2.5*S;if(G>V*e+S)return!1;const t=pe,s=e/V;for(let i=0;i<4;++i)r(t[i],h[i],s/R);a(t[4],0,0,0),q=t}else{const e=(x+S)/V,t=(x-S)/V,s=me;for(let i=0;i<4;++i){const n=h[i];r(s[i+4],n,t/R),r(s[i],n,e/R)}q=s}if(X(B,q,q.length))return!1;const J=P.lines,Q=Oe,Z=Se;for(const r of U){n(Q,h[r]);for(const e of J)if(n(Z,e.direction),Le(Z,Q,q,z))return!1}return!0}_calculateSingleTileVisibilitySided(e,t){if(this._isTileVisibleInFrustum(e)){this._intersector.update(e.extent,e.tilingScheme.spatialReference,this._surfaceElevation,t);const s=p(e.tilingScheme.spatialReference).radius;return this._intersector.isVisibleInFrustum(this._frustum,s,!0)?j.VISIBLE_ON_SURFACE:j.VISIBLE_WHEN_EXTENDED}return j.INVISIBLE}_updateExtendedFrustum(t){this._extendedFrustum.update(t),this._shortenFrustumFarPlane(this._extendedFrustum);const s=this._renderCoordsHelper.worldUpAtPosition(t.eye,y);this._aboveGround||_(s,s);const i=e(-u(s,t.viewForward));if(this._hasExtendedFrustum=i>t.fovY/2,!this._hasExtendedFrustum)return;const n=this._extendedFrustumParameters(),o=this._extendedFrustum.mutablePoints;for(let e=0;e<4;e++){const t=n.pointIndices[e],s=o[t],i=this._renderCoordsHelper.getAltitude(s);if(n.needsAltitudeAdjustment(i)){switch(this._renderCoordsHelper.worldUpAtPosition(s,y),t){case g.FAR_BOTTOM_LEFT:case g.FAR_TOP_LEFT:case g.NEAR_BOTTOM_LEFT:case g.NEAR_TOP_LEFT:R(this._extendedFrustum.planes[E.LEFT],y,y);break;case g.FAR_BOTTOM_RIGHT:case g.FAR_TOP_RIGHT:case g.NEAR_BOTTOM_RIGHT:case g.NEAR_TOP_RIGHT:R(this._extendedFrustum.planes[E.RIGHT],y,y)}r(y,y,n.direction),this._renderCoordsHelper.intersectInfiniteManifold(b(s,y),n.zWithMargin,s)}}if(this._extendedFrustum.updatePoints(o),A(o[g.NEAR_BOTTOM_LEFT],o[g.NEAR_BOTTOM_RIGHT],o[g.NEAR_TOP_RIGHT],v),A(o[g.NEAR_BOTTOM_RIGHT],o[g.NEAR_TOP_RIGHT],o[g.NEAR_TOP_LEFT],w),u(O(v),O(w))<0){const e=this._extendedFrustum.mutablePoints;this._aboveGround?[e[g.NEAR_BOTTOM_LEFT],e[g.NEAR_BOTTOM_RIGHT]]=[e[g.NEAR_BOTTOM_RIGHT],e[g.NEAR_BOTTOM_LEFT]]:[e[g.NEAR_TOP_LEFT],e[g.NEAR_TOP_RIGHT]]=[e[g.NEAR_TOP_RIGHT],e[g.NEAR_TOP_LEFT]],this._extendedFrustum.updatePoints(e)}}_extendedFrustumParameters(){return this._aboveGround?this._extendedFrustumParametersAboveSurface():this._extendedFrustumParametersBelowSurface()}_extendedFrustumParametersAboveSurface(){const e=this._surfaceElevation-L;return{zWithMargin:e,pointIndices:H.planePointIndices.bottom,direction:-1,needsAltitudeAdjustment:t=>t>e}}_extendedFrustumParametersBelowSurface(){const e=this._surfaceElevation+L;return{zWithMargin:e,pointIndices:H.planePointIndices.top,direction:1,needsAltitudeAdjustment:t=>t<e}}}const V=2,C=6,G=12,M=.95,L=1,y=f(),v=I(),w=I(),U=new t(Array,(e=>{4!==e.length&&(e[0]=new B,e[1]=new B,e[2]=new B,e[3]=new B)}),(e=>{e[0].release(),e[1].release(),e[2].release(),e[3].release()}));function W(e,t,s){return d(e,t,s),n(e,e),e}function D(e,t,s){return o(e,t,s),n(e,e),e}function k(e,t){return r(e,e,t/h(e)),e}const z=[E.LEFT,E.RIGHT,E.BOTTOM,E.TOP,E.FAR];function q(e,t,s){for(let r=0;r<s;++r)if(S(e,t[r])<0)return!1;return!0}function X(e,t,s){for(const r of z)if(q(e[r],t,s))return!0;return!1}const Y=3,J=1e-5;function K(e,t){for(const s of t)if(u(s,e)<J)return!1;return!0}const Q=[f(),f(),f(),f(),f(),f(),f(),f()],Z=[0,0,0,0,0,0],$=[f(),f(),f(),f(),f()],ee=f(),te=f(),se=f(),re=f(),ie=f(),ne=f(),oe=f(),ue=f(),ce=f(),ae=f(),le=f(),de=f(),_e=f(),he=m(0,0,0),fe=f(),me=[f(),f(),f(),f(),f(),f(),f(),f()],pe=[f(),f(),f(),f(),f()],Te=f(),Fe=f(),Ee=f(),ge=f(),Ie=f(),Re=f(),Ae=f(),Oe=f(),Se=f(),be=f(),Pe=[0,1,2,3],Be=[0,1,2,3],je=[0,1,3],He=[0,1,3],xe=[1,2,3],Ne=[1,2,3],Ve=f();function Ce(e,t,s){let r=1/0,i=-1/0;for(const n of s){const e=u(t,n);r=Math.min(r,e),i=Math.max(i,e)}e[0]=r,e[1]=i}function Ge(e,t,s,r){let i=1/0,n=-1/0;for(const o of r){const r=u(s,o);if(i=Math.min(i,r),n=Math.max(n,r),i<=t&&n>=e)return!1}return!0}const Me=[0,0];function Le(e,t,s,r){const i=be;W(i,e,t);const n=Me;return Ce(n,i,s),Ge(n[0],n[1],i,r)}export{N as FeatureTileVisibility3D,Y as globalTileLevelThreshold,X as isConvexHullOutsideOfFrustum};
5
+ import{acosClamped as e}from"../../../../core/mathUtils.js";import t from"../../../../core/ObjectPool.js";import{f as s,i as r,g as i,n,y as o,j as u,q as c,s as a,m as l,b as d,E as _,C as h}from"../../../../chunks/vec32.js";import{create as f,fromValues as m}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{getReferenceEllipsoid as p}from"../../../../geometry/ellipsoidUtils.js";import{projectBuffer as T}from"../../../../geometry/projection/projectBuffer.js";import{projectVec3Array as F}from"../../../../geometry/projection/projectVec3Array.js";import{PlaneIndex as E,PointIndex as g}from"../../../../geometry/support/frustum.js";import{create as I,projectVector as R,fromPoints as A,getNormal as O,signedDistance as S}from"../../../../geometry/support/plane.js";import{wrap as b}from"../../../../geometry/support/ray.js";import{ViewingMode as P}from"../../../ViewingMode.js";import{FeatureTileDescriptor3D as B,Visibility as j}from"./FeatureTileDescriptor3D.js";import{Frustum as H}from"../../state/Frustum.js";import{FrustumExtentIntersection as x}from"../../support/FrustumExtentIntersection.js";class N{constructor(e){this._renderCoordsHelper=e,this._surfaceElevation=0,this._cache=new Map,this._frustumBoundingSphereCenter=f(),this._frustumBoundingSphereRadius=0,this._frustum=new H(e),this._extendedFrustum=new H(e),this._intersector=new x({renderCoordsHelper:e}),this._renderCoordsHelper=e}begin(e,t){this._surfaceElevation=t,this._aboveGround=this._renderCoordsHelper.getAltitude(e.eye)>t,this._frustum.update(e),this._shortenFrustumFarPlane(this._frustum),this._updateExtendedFrustum(e),this._updateFrustumBoundingSphere()}end(){this._cache.clear()}calculate(e){const t=this._renderCoordsHelper.viewingMode===P.Global&&e.lij[0]>=V&&e.lij[0]<C,s=this._getOrCalculateSingleTileVisibility(e,!t);return s!==j.INVISIBLE&&t?this._calculateAggregatedChildrenVisibility(e):s}_shortenFrustumFarPlane(e){const t=H.nearFarLineIndices,n=e.mutablePoints;for(const o of t){const[e,t]=o,u=n[e],c=n[t];s(y,c,u),r(y,y,M),i(n[t],u,y)}e.updatePoints(n)}_calculateAggregatedChildrenVisibility(e){let t=j.INVISIBLE;const s=this._cache.get(e.id);if(null!=s)return s;const r=U.acquire();e.getChildren(r);for(const i of r){const e=this.calculate(i);if(e!==j.INVISIBLE&&(t=e,e===j.VISIBLE_ON_SURFACE))break}return U.release(r),this._cache.set(e.id,t),t}_getOrCalculateSingleTileVisibility(e,t){const s=this._cache.get(e.id);if(null!=s)return s;const r=this._calculateSingleTileVisibility(e);return t&&this._cache.set(e.id,r),r}_calculateSingleTileVisibility(e){if(!this._aboveGround&&this._renderCoordsHelper.viewingMode===P.Global&&e.lij[0]<G){return this._calculateSingleTileVisibilitySided(e,!1)===j.INVISIBLE?this._calculateSingleTileVisibilitySided(e,!0):void 0}return this._calculateSingleTileVisibilitySided(e,this._aboveGround)}_isTileVisibleInFrustum(e){return this._renderCoordsHelper.viewingMode===P.Local?this._isTileVisibleInFrustumLocal(e):this._isTileVisibleInFrustumGlobal(e)}_updateFrustumBoundingSphere(){const e=this._frustum,t=e.origin,s=ce;n(s,e.direction);const r=e.points,i=ae;o(i,r[4],t);const a=.5*u(i,i)/u(s,i),l=this._frustumBoundingSphereCenter;c(l,t,s,a);const d=1+a;this._frustumBoundingSphereRadius=d}_isTileVisibleInFrustumLocal(e){const t=e.tilingScheme.spatialReference,s=e.extent,r=this._renderCoordsHelper.spatialReference,i=Q;if(i[0]=s[0],i[1]=s[1],i[2]=0,i[3]=s[2],i[4]=s[3],i[5]=0,!T(i,t,0,i,r,0,2))return!1;const n=Z;a(n[0],i[0],i[1],0),a(n[1],i[3],i[1],0),a(n[2],i[3],i[4],0),a(n[3],i[0],i[4],0);const d=$;a(d,.5*(i[0]+i[3]),.5*(i[1]+i[4]),.5*(i[2]+i[5]));const _=ee;a(_,0,0,1);const h=.5*l(n[0],n[2]),f=this._frustum,m=this._frustumBoundingSphereRadius,p=this._frustumBoundingSphereCenter,F=de;o(F,p,d);const E=u(_,F),g=le;c(g,d,_,E);if(l(g,p)>h+m)return!1;const I=K,R=E+m,A=E-m;for(let o=0;o<4;++o)c(I[o],n[o],_,R),c(I[o+4],n[o],_,A);return!X(f.planes,I,8)}_isTileVisibleInFrustumGlobal(e){const t=e.tilingScheme.spatialReference,s=e.extent,_=this._renderCoordsHelper.spatialReference;if(e.lij[0]<Y)return!0;const h=Z,f=.5*(s[0]+s[2]);if(a(h[0],s[0],s[1],0),a(h[1],s[2],s[1],0),a(h[2],s[2],s[3],0),a(h[3],s[0],s[3],0),a(h[4],f,s[1],0),a(h[5],f,s[3],0),!F(h,t,0,h,_,0,6))return!1;const T=h[0][2]>0,E=h[3][2]<0,g=T||E,I=p(_).radius;if(g){const e=m(0,0,1),t=se;W(t,e,h[0]);const s=re;if(W(s,e,h[1]),T){const r=te,i=h[4],n=ie;W(n,i,e),W(r,n,i);const o=h[0];d(o,t,r),k(o,I);const u=h[1];d(u,s,r),k(u,I)}else if(E){const r=te,i=h[5],n=ie;W(n,i,e),W(r,i,n);const o=h[3];d(o,r,t),k(o,I);const u=h[2];d(u,r,s),k(u,I)}}const R=$;{const e=pe;o(e,h[3],h[0]),n(e,e);const t=Te;i(t,h[0],h[3]),r(t,t,.5);const s=-u(t,e),a=Fe,l=Ee;i(a,h[0],h[1]),r(a,a,.5),i(l,h[2],h[3]),r(l,l,.5);const d=ge;o(d,l,a),n(d,d);const _=-(s+u(e,a))/u(e,d);c(R,a,d,_),k(R,I)}const A=this._frustumBoundingSphereRadius,O=this._frustumBoundingSphereCenter,S=this._frustum,b=S.planes;if(h.some((e=>S.intersectsPoint(e))))return!0;if(S.intersectsPoint(R))return!0;const P=ne;n(P,R);const B=he;o(B,O,_e);const j=u(B,P);if(j<-A)return!1;const H=ue;n(H,h[0]);const x=u(H,P);if(x<=0)return!0;const N=oe;r(N,P,j);const V=l(N,O),C=t.isWGS84,G=e.lij,M=C&&G[2]===2**G[0]-1,L=C&&0===G[2],y=L?He:M?Be:be,v=L?xe:M?je:Pe,w=S.points;{const e=h,t=Ne,s=Ie,r=Re,i=_e;for(const n of y){const o=e[n];if(D(s,e[(n+1)%4],o),D(r,i,o),W(t,r,s),J(t,w,1))return!1}}let U=null;if(j<2*A){const e=2.5*A;if(V>x*e+A)return!1;const t=me,s=e/x;for(let i=0;i<4;++i)r(t[i],h[i],s/I);a(t[4],0,0,0),U=t}else{const e=(j+A)/x,t=(j-A)/x,s=fe;for(let i=0;i<4;++i){const n=h[i];r(s[i+4],n,t/I),r(s[i],n,e/I)}U=s}if(X(b,U,U.length))return!1;const z=S.lines,q=Ae,K=Oe;for(const r of v){n(q,h[r]);for(const e of z)if(n(K,e.direction),Me(K,q,U,w))return!1}return!0}_calculateSingleTileVisibilitySided(e,t){if(this._isTileVisibleInFrustum(e)){this._intersector.update(e.extent,e.tilingScheme.spatialReference,this._surfaceElevation,t);const s=p(e.tilingScheme.spatialReference).radius;return this._intersector.isVisibleInFrustum(this._frustum,s,!0)?j.VISIBLE_ON_SURFACE:j.VISIBLE_WHEN_EXTENDED}return j.INVISIBLE}_updateExtendedFrustum(t){this._extendedFrustum.update(t),this._shortenFrustumFarPlane(this._extendedFrustum);const s=this._renderCoordsHelper.worldUpAtPosition(t.eye,y);this._aboveGround||_(s,s);const i=e(-u(s,t.viewForward));if(this._hasExtendedFrustum=i>t.fovY/2,!this._hasExtendedFrustum)return;const n=this._extendedFrustumParameters(),o=this._extendedFrustum.mutablePoints;for(let e=0;e<4;e++){const t=n.pointIndices[e],s=o[t],i=this._renderCoordsHelper.getAltitude(s);if(n.needsAltitudeAdjustment(i)){switch(this._renderCoordsHelper.worldUpAtPosition(s,y),t){case g.FAR_BOTTOM_LEFT:case g.FAR_TOP_LEFT:case g.NEAR_BOTTOM_LEFT:case g.NEAR_TOP_LEFT:R(this._extendedFrustum.planes[E.LEFT],y,y);break;case g.FAR_BOTTOM_RIGHT:case g.FAR_TOP_RIGHT:case g.NEAR_BOTTOM_RIGHT:case g.NEAR_TOP_RIGHT:R(this._extendedFrustum.planes[E.RIGHT],y,y)}r(y,y,n.direction),this._renderCoordsHelper.intersectInfiniteManifold(b(s,y),n.zWithMargin,s)}}if(this._extendedFrustum.updatePoints(o),A(o[g.NEAR_BOTTOM_LEFT],o[g.NEAR_BOTTOM_RIGHT],o[g.NEAR_TOP_RIGHT],v),A(o[g.NEAR_BOTTOM_RIGHT],o[g.NEAR_TOP_RIGHT],o[g.NEAR_TOP_LEFT],w),u(O(v),O(w))<0){const e=this._extendedFrustum.mutablePoints;this._aboveGround?[e[g.NEAR_BOTTOM_LEFT],e[g.NEAR_BOTTOM_RIGHT]]=[e[g.NEAR_BOTTOM_RIGHT],e[g.NEAR_BOTTOM_LEFT]]:[e[g.NEAR_TOP_LEFT],e[g.NEAR_TOP_RIGHT]]=[e[g.NEAR_TOP_RIGHT],e[g.NEAR_TOP_LEFT]],this._extendedFrustum.updatePoints(e)}}_extendedFrustumParameters(){return this._aboveGround?this._extendedFrustumParametersAboveSurface():this._extendedFrustumParametersBelowSurface()}_extendedFrustumParametersAboveSurface(){const e=this._surfaceElevation-L;return{zWithMargin:e,pointIndices:H.planePointIndices.bottom,direction:-1,needsAltitudeAdjustment:t=>t>e}}_extendedFrustumParametersBelowSurface(){const e=this._surfaceElevation+L;return{zWithMargin:e,pointIndices:H.planePointIndices.top,direction:1,needsAltitudeAdjustment:t=>t<e}}}const V=2,C=6,G=12,M=.95,L=1,y=f(),v=I(),w=I(),U=new t(Array,(e=>{4!==e.length&&(e[0]=new B,e[1]=new B,e[2]=new B,e[3]=new B)}),(e=>{e[0].release(),e[1].release(),e[2].release(),e[3].release()}));function W(e,t,s){return d(e,t,s),n(e,e),e}function D(e,t,s){return o(e,t,s),n(e,e),e}function k(e,t){return r(e,e,t/h(e)),e}const z=[E.LEFT,E.RIGHT,E.BOTTOM,E.TOP,E.FAR];function q(e,t,s){for(let r=0;r<s;++r)if(S(e,t[r])<0)return!1;return!0}function X(e,t,s){for(const r of z)if(q(e[r],t,s))return!0;return!1}const Y=3;function J(e,t,s){for(const r of t)if(u(r,e)<s)return!1;return!0}const K=[f(),f(),f(),f(),f(),f(),f(),f()],Q=[0,0,0,0,0,0],Z=[f(),f(),f(),f(),f(),f()],$=f(),ee=f(),te=f(),se=f(),re=f(),ie=f(),ne=f(),oe=f(),ue=f(),ce=f(),ae=f(),le=f(),de=f(),_e=m(0,0,0),he=f(),fe=[f(),f(),f(),f(),f(),f(),f(),f()],me=[f(),f(),f(),f(),f()],pe=f(),Te=f(),Fe=f(),Ee=f(),ge=f(),Ie=f(),Re=f(),Ae=f(),Oe=f(),Se=f(),be=[0,1,2,3],Pe=[0,1,2,3],Be=[0,1,3],je=[0,1,3],He=[1,2,3],xe=[1,2,3],Ne=f();function Ve(e,t,s){let r=1/0,i=-1/0;for(const n of s){const e=u(t,n);r=Math.min(r,e),i=Math.max(i,e)}e[0]=r,e[1]=i}function Ce(e,t,s,r){let i=1/0,n=-1/0;for(const o of r){const r=u(s,o);if(i=Math.min(i,r),n=Math.max(n,r),i<=t&&n>=e)return!1}return!0}const Ge=[0,0];function Me(e,t,s,r){const i=Se;W(i,e,t);const n=Ge;return Ve(n,i,s),Ce(n[0],n[1],i,r)}export{N as FeatureTileVisibility3D,Y as globalTileLevelThreshold,X as isConvexHullOutsideOfFrustum};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.30/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../../../core/PooledArray.js";import{castRenderScreenPointArray3 as t,createRenderScreenPointArray3 as r}from"../../../../core/screenUtils.js";import{g as n,n as i}from"../../../../chunks/vec32.js";import{create as s}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{create as o,copy as l,negativeInfinity as c,width as a,height as u,expandPointInPlace as h}from"../../../../geometry/support/aaBoundingRect.js";import{create as d}from"../../../../geometry/support/ray.js";import{sv3d as p}from"../../../../geometry/support/vectorStacks.js";import{ViewingMode as m}from"../../../ViewingMode.js";import{computeMapPointFromVec3d as y}from"../../support/hitTest.js";import{fromRenderAtEye as g,fromScreen as f}from"../../support/geometryUtils/ray.js";import{defaultTolerance as _,newIntersector as R}from"../../webgl-engine/lib/Intersector.js";import{StoreResults as v,IntersectorType as I}from"../../webgl-engine/lib/IntersectorInterfaces.js";import{isValidIntersectorResult as b,sliceFilterPredicate as w}from"../../webgl-engine/lib/intersectorUtils.js";class P{constructor(t,r,n){this.viewingMode=t,this._forEachLayer=r,this._view=n,this._externalIntersectionHandlers=new e,this._tolerance=_,this._tmpRay=d(),this._tmpRegion=o(),this._validateHUDIntersector=R(this.viewingMode),this._validateHUDIntersector.options.hud=!1}intersectScreen(e,t,r){return this.intersectRay(this._getPickRay(e,this._tmpRay),E(this.viewingMode),t,r)}intersectScreenFreePointFallback(e,t,r){return this.intersectRayFreePointFallback(this._getPickRay(e,this._tmpRay),t,r)}intersectRayFreePointFallback(e,t,r){return this.intersectRay(e,E(this.viewingMode),t,r)||this._intersectRayFreePointLocal(e,t)}intersectRay(e,t,r,n){return t.options.selectionMode=!1,t.options.store=v.MIN,this.computeIntersection(e,t,n),!!t.results.min&&t.results.min.getIntersectionPoint(r)}getCenterRayWithSubpixelOffset(e,t,r=.5,n=.5){return e.getRenderCenter(A,r,n),A[0]+=.0466,A[1]-=.0123,g(e,A,t)}intersectIntersectorScreen(e,t,r){this.computeIntersection(this._getPickRay(e,this._tmpRay),t,r)}intersectToolIntersectorScreen(e,t,r){const n=this._getPickRay(e,this._tmpRay);this.intersectToolIntersectorRay(n,t,r)}intersectToolIntersectorRay(e,t,r){t.options.selectionMode=!0,this.computeIntersection(e,t,r);const n=t.results.min;!!this._view.basemapTerrain&&this._view.basemapTerrain.opaque||b(n)&&n.intersector!==I.TERRAIN||(t.options.selectionMode=!1,this.computeIntersection(e,t,r))}setTolerance(e=_){this._tolerance=e}addIntersectionHandler(e){this._externalIntersectionHandlers.push(e),this._externalIntersectionHandlers.sort(((e,t)=>e.type===I.TERRAIN?1:t.type===I.TERRAIN?-1:0))}removeIntersectionHandler(e){null!=this._externalIntersectionHandlers.removeUnordered(e)&&this._externalIntersectionHandlers.sort(((e,t)=>e.type===I.TERRAIN?1:t.type===I.TERRAIN?-1:0))}_getPickRay(e,t){const r=this._view.state.camera;return f(r,e,t)}_intersectRayFreePointLocal(e,t){return this.viewingMode!==m.Local||null==e||n(t,e.origin,i(p.get(),e.direction)),!1}intersectElevationFromScreen(e,t,r=0,n=null){return this._intersectElevation(this._getPickRay(e,this._tmpRay),t,r,n)}_intersectElevation(e,r,i=0,s=null){if(null==e)return null;const o=null!=r?r.mode:"absolute-height",l=r?.offset??0,c="on-the-ground"!==o?l+i:0,a=c/this._view.renderCoordsHelper.unitInMeters;if("absolute-height"===o){if(this._view.renderCoordsHelper.intersectInfiniteManifold(e,c,T)){const e=y(this._view,T);return e.z??=0,e.z-=l,e}return null}const u=this._view.state.camera,h=t(p.get());u.projectToRenderScreen(e.origin,h);const d=new H(null,this._forEachLayer),m=this._view.slicePlane,g=null!=m?w(m):null,f=R(this.viewingMode);f.options.store=v.MIN,f.options.verticalOffset=a;const _=e.origin,b=n(p.get(),_,e.direction);f.reset(_,b,u),f.point=h;const P=s?"type"in s&&"graphics"===s.type?e=>e.layerUid!==s.uid:e=>e.graphicUid!==s.uid:null;switch(o){case"relative-to-scene":{const e=e=>(!P||P(e))&&!!e.lastValidElevationBB;f.intersect(d.layers,h,this._tolerance,null,e),this._externalIntersectionHandlers.forAll((e=>{if(e.type===I.I3S||e.type===I.TERRAIN||e.type===I.TILES3D){const t=e.slicePlaneEnabled?g:null;e.intersect(f,t,f.rayBegin,f.rayEnd,h)}}));break}case"on-the-ground":case"relative-to-ground":this._externalIntersectionHandlers.forAll((e=>{if(e.isGround){const t=e.slicePlaneEnabled?g:null;e.intersect(f,t,f.rayBegin,f.rayEnd,h)}}))}if(f.results.min.getIntersectionPoint(T)){const e=y(this._view,T);return e.z=i,e}return null}computeIntersection(e,r,i,s){if(null==e)return;const o=this._view.state.camera,l=t(p.get());o.projectToRenderScreen(e.origin,l);const c=new H(i,this._forEachLayer);r.options.selectOpaqueTerrainOnly=!i||!("include"in i||"exclude"in i);const a=e.origin,u=n(p.get(),e.origin,e.direction);r.reset(a,u,o),r.intersect(c.layers,l,this._tolerance);const h=this._view.slicePlane,d=null!=h?w(h):null;r.intersect(c.sliceableLayers,l,this._tolerance,d);const m=i&&(i.requiresGroundFeedback||i.enableDraped);this._externalIntersectionHandlers.forAll((e=>{const t=e.layerUid,n=Array.isArray(t),i=n?t:[t];n&&(r.options.filteredLayerUids=[]);let o=!1;for(const s of i){!c.filterLayerUid(s)?n&&r.options.filteredLayerUids.push(s):o=!0}if(r.options.isFiltered=!o,e.isGround&&m||!r.options.isFiltered){const t=e.slicePlaneEnabled?d:null;e.intersect(r,t,a,u,l,s)}}));const y=p.get(),g=this._view.basemapTerrain;if(i&&i.enableDraped&&null!=g.spatialReference&&r.results.ground.getIntersectionPoint(y)){const e=g.overlayManager.renderer,t=this._view.renderCoordsHelper.spatialReference,n=p.get();this._view.renderCoordsHelper.fromRenderCoords(y,n,g.spatialReference),n[2]=this._view.elevationProvider?.getElevation(y[0],y[1],y[2],t,"ground")??0,e.intersect(r,n,r.results.ground,(e=>c.filterRenderGeometry(e)))}r.sortResults(),this._processHUDResults(r)}_processHUDResults(e){const t=e.results.hud;l(this._tmpRegion,c);const r=this._view.state.camera,n=[],i=this._tmpRegion,s=e=>{const t=new x(e);r.projectToRenderScreen(e.target.center,t.screenPoint),t.screenPoint[0]=Math.floor(t.screenPoint[0]),t.screenPoint[1]=Math.floor(t.screenPoint[1]),n.push(t),h(i,t.screenPoint)};e.sortResults(t.all),null!=t.min.dist&&s(t.min);for(const l of t.all)t.min.target.object!==l.target.object&&t.max.target.object!==l.target.object&&s(l);if(null!=t.max.dist&&t.max.target.object!==t.min.target.object&&s(t.max),!n.length)return;i[0]===i[2]&&(i[2]+=1),i[1]===i[3]&&(i[3]+=1);const o=r.fullWidth,d=r.fullHeight,p=Math.max(0,i[0]-M),m=Math.max(0,i[1]-M),y=Math.min(a(i)+2*M,o-p),g=Math.min(u(i)+2*M,d-m);if(y<=0||g<=0)return;const f=new Uint8Array(y*g*4);this._view._stage.renderer.readHUDVisibility(p,m,y,g,f);let _=!0;const R=null==e.results.max.dist;let I=0;for(const l of n)for(const t of j){const r=4*(Math.min(l.screenPoint[0]+t[0],o)-i[0]+(Math.min(l.screenPoint[1]+t[1],d)-i[1])*y);if(!(r<0||r>=f.length)&&f[r]){_&&(e.results.min.copy(l.result),_=!1),R&&e.results.max.copy(l.result),e.options.store===v.ALL&&e.results.all.splice(I++,0,l.result);break}}}}const M=1,j=(()=>{const e=[],t=M;for(let r=-t;r<=t;r++)for(let n=-t;n<=t;n++)e.push([n+t,r+t]);return e})();class x{constructor(e){this.result=e,this.screenPoint=r()}}let U;function E(e){return U&&U.viewingMode===e||(U=R(e)),U}class H{constructor(e,t){this.layers=new Array,this.sliceableLayers=new Array,this.include=e?.include,this.exclude=e?.exclude,t((e=>{e.pickable&&this.filterLayerUid(e.apiLayerUid)&&(e.sliceable?this.sliceableLayers:this.layers).push(e)}))}filterLayerUid(e){const{include:t,exclude:r}=this;return null==e?null==t&&null==r:(null==t||t.has(e))&&(null==r||!r.has(e))}filterRenderGeometry(e){return this.filterLayerUid(e.layerUid)}}function L(e){return"object"==typeof e&&"intersect"in e}const T=s(),A=r();export{P as SceneIntersectionHelper,L as isIntersectionHandler};
5
+ import e from"../../../../core/PooledArray.js";import{castRenderScreenPointArray3 as t,createRenderScreenPointArray3 as r}from"../../../../core/screenUtils.js";import{getMetersPerVerticalUnitForSR as n}from"../../../../core/unitUtils.js";import{g as i,n as s}from"../../../../chunks/vec32.js";import{create as o}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{create as l,copy as c,negativeInfinity as a,width as u,height as h,expandPointInPlace as d}from"../../../../geometry/support/aaBoundingRect.js";import{create as p}from"../../../../geometry/support/ray.js";import{sv3d as m}from"../../../../geometry/support/vectorStacks.js";import{getElevationOffsetInMeters as y}from"../../../../support/elevationInfoUtils.js";import{ViewingMode as f}from"../../../ViewingMode.js";import{computeMapPointFromVec3d as g}from"../../support/hitTest.js";import{fromRenderAtEye as R,fromScreen as _}from"../../support/geometryUtils/ray.js";import{defaultTolerance as I,newIntersector as v}from"../../webgl-engine/lib/Intersector.js";import{StoreResults as b,IntersectorType as w}from"../../webgl-engine/lib/IntersectorInterfaces.js";import{isValidIntersectorResult as P,sliceFilterPredicate as j}from"../../webgl-engine/lib/intersectorUtils.js";class M{constructor(t,r,n){this.viewingMode=t,this._forEachLayer=r,this._view=n,this._externalIntersectionHandlers=new e,this._tolerance=I,this._tmpRay=p(),this._tmpRegion=l(),this._validateHUDIntersector=v(this.viewingMode),this._validateHUDIntersector.options.hud=!1}intersectScreen(e,t,r){return this.intersectRay(this._getPickRay(e,this._tmpRay),L(this.viewingMode),t,r)}intersectScreenFreePointFallback(e,t,r){return this.intersectRayFreePointFallback(this._getPickRay(e,this._tmpRay),t,r)}intersectRayFreePointFallback(e,t,r){return this.intersectRay(e,L(this.viewingMode),t,r)||this._intersectRayFreePointLocal(e,t)}intersectRay(e,t,r,n){return t.options.selectionMode=!1,t.options.store=b.MIN,this.computeIntersection(e,t,n),!!t.results.min&&t.results.min.getIntersectionPoint(r)}getCenterRayWithSubpixelOffset(e,t,r=.5,n=.5){return e.getRenderCenter(F,r,n),F[0]+=.0466,F[1]-=.0123,R(e,F,t)}intersectIntersectorScreen(e,t,r){this.computeIntersection(this._getPickRay(e,this._tmpRay),t,r)}intersectToolIntersectorScreen(e,t,r){const n=this._getPickRay(e,this._tmpRay);this.intersectToolIntersectorRay(n,t,r)}intersectToolIntersectorRay(e,t,r){t.options.selectionMode=!0,this.computeIntersection(e,t,r);const n=t.results.min;!!this._view.basemapTerrain&&this._view.basemapTerrain.opaque||P(n)&&n.intersector!==w.TERRAIN||(t.options.selectionMode=!1,this.computeIntersection(e,t,r))}setTolerance(e=I){this._tolerance=e}addIntersectionHandler(e){this._externalIntersectionHandlers.push(e),this._externalIntersectionHandlers.sort(((e,t)=>e.type===w.TERRAIN?1:t.type===w.TERRAIN?-1:0))}removeIntersectionHandler(e){null!=this._externalIntersectionHandlers.removeUnordered(e)&&this._externalIntersectionHandlers.sort(((e,t)=>e.type===w.TERRAIN?1:t.type===w.TERRAIN?-1:0))}_getPickRay(e,t){const r=this._view.state.camera;return _(r,e,t)}_intersectRayFreePointLocal(e,t){return this.viewingMode!==f.Local||null==e||i(t,e.origin,s(m.get(),e.direction)),!1}intersectElevationFromScreen(e,t,r=0,n=null){return this._intersectElevation(this._getPickRay(e,this._tmpRay),t,r,n)}_intersectElevation(e,r,s=0,o=null){if(null==e)return null;const l=this._view,c=n(l.spatialReference),a=null!=r?r.mode:"absolute-height",u=y(r)/c,h=("on-the-ground"!==a?u+s:0)*c/l.renderCoordsHelper.unitInMeters;if("absolute-height"===a){if(l.renderCoordsHelper.intersectInfiniteManifold(e,h,k)){const e=g(l,k);return e.z??=0,e.z-=u,e}return null}const{camera:d}=l.state,p=t(m.get());d.projectToRenderScreen(e.origin,p);const f=new T(null,this._forEachLayer),R=l.slicePlane,_=null!=R?j(R):null,I=v(this.viewingMode);I.options.store=b.MIN,I.options.verticalOffset=h;const P=e.origin,M=i(m.get(),P,e.direction);I.reset(P,M,d),I.point=p;const x=o?"type"in o&&"graphics"===o.type?e=>e.layerUid!==o.uid:e=>e.graphicUid!==o.uid:null;switch(a){case"relative-to-scene":{const e=e=>(!x||x(e))&&!!e.lastValidElevationBB;I.intersect(f.layers,p,this._tolerance,null,e),this._externalIntersectionHandlers.forAll((e=>{if(e.type===w.I3S||e.type===w.TERRAIN||e.type===w.TILES3D){const t=e.slicePlaneEnabled?_:null;e.intersect(I,t,I.rayBegin,I.rayEnd,p)}}));break}case"on-the-ground":case"relative-to-ground":this._externalIntersectionHandlers.forAll((e=>{if(e.isGround){const t=e.slicePlaneEnabled?_:null;e.intersect(I,t,I.rayBegin,I.rayEnd,p)}}))}if(I.results.min.getIntersectionPoint(k)){const e=g(l,k);return e.z=s,e}return null}computeIntersection(e,r,n,s){if(null==e)return;const o=this._view.state.camera,l=t(m.get());o.projectToRenderScreen(e.origin,l);const c=new T(n,this._forEachLayer);r.options.selectOpaqueTerrainOnly=!n||!("include"in n||"exclude"in n);const a=e.origin,u=i(m.get(),e.origin,e.direction);r.reset(a,u,o),r.intersect(c.layers,l,this._tolerance);const h=this._view.slicePlane,d=null!=h?j(h):null;r.intersect(c.sliceableLayers,l,this._tolerance,d);const p=n&&(n.requiresGroundFeedback||n.enableDraped);this._externalIntersectionHandlers.forAll((e=>{const t=e.layerUid,n=Array.isArray(t),i=n?t:[t];n&&(r.options.filteredLayerUids=[]);let o=!1;for(const s of i){!c.filterLayerUid(s)?n&&r.options.filteredLayerUids.push(s):o=!0}if(r.options.isFiltered=!o,e.isGround&&p||!r.options.isFiltered){const t=e.slicePlaneEnabled?d:null;e.intersect(r,t,a,u,l,s)}}));const y=m.get(),f=this._view.basemapTerrain;if(n&&n.enableDraped&&null!=f.spatialReference&&r.results.ground.getIntersectionPoint(y)){const e=f.overlayManager.renderer,t=this._view.renderCoordsHelper.spatialReference,n=m.get();this._view.renderCoordsHelper.fromRenderCoords(y,n,f.spatialReference),n[2]=this._view.elevationProvider?.getElevation(y[0],y[1],y[2],t,"ground")??0,e.intersect(r,n,r.results.ground,(e=>c.filterRenderGeometry(e)))}r.sortResults(),this._processHUDResults(r)}_processHUDResults(e){const t=e.results.hud;c(this._tmpRegion,a);const r=this._view.state.camera,n=[],i=this._tmpRegion,s=e=>{const t=new E(e);r.projectToRenderScreen(e.target.center,t.screenPoint),t.screenPoint[0]=Math.floor(t.screenPoint[0]),t.screenPoint[1]=Math.floor(t.screenPoint[1]),n.push(t),d(i,t.screenPoint)};e.sortResults(t.all),null!=t.min.dist&&s(t.min);for(const c of t.all)t.min.target.object!==c.target.object&&t.max.target.object!==c.target.object&&s(c);if(null!=t.max.dist&&t.max.target.object!==t.min.target.object&&s(t.max),!n.length)return;i[0]===i[2]&&(i[2]+=1),i[1]===i[3]&&(i[3]+=1);const o=r.fullWidth,l=r.fullHeight,p=Math.max(0,i[0]-x),m=Math.max(0,i[1]-x),y=Math.min(u(i)+2*x,o-p),f=Math.min(h(i)+2*x,l-m);if(y<=0||f<=0)return;const g=new Uint8Array(y*f*4);this._view._stage.renderer.readHUDVisibility(p,m,y,f,g);let R=!0;const _=null==e.results.max.dist;let I=0;for(const c of n)for(const t of U){const r=4*(Math.min(c.screenPoint[0]+t[0],o)-i[0]+(Math.min(c.screenPoint[1]+t[1],l)-i[1])*y);if(!(r<0||r>=g.length)&&g[r]){R&&(e.results.min.copy(c.result),R=!1),_&&e.results.max.copy(c.result),e.options.store===b.ALL&&e.results.all.splice(I++,0,c.result);break}}}}const x=1,U=(()=>{const e=[],t=x;for(let r=-t;r<=t;r++)for(let n=-t;n<=t;n++)e.push([n+t,r+t]);return e})();class E{constructor(e){this.result=e,this.screenPoint=r()}}let H;function L(e){return H&&H.viewingMode===e||(H=v(e)),H}class T{constructor(e,t){this.layers=new Array,this.sliceableLayers=new Array,this.include=e?.include,this.exclude=e?.exclude,t((e=>{e.pickable&&this.filterLayerUid(e.apiLayerUid)&&(e.sliceable?this.sliceableLayers:this.layers).push(e)}))}filterLayerUid(e){const{include:t,exclude:r}=this;return null==e?null==t&&null==r:(null==t||t.has(e))&&(null==r||!r.has(e))}filterRenderGeometry(e){return this.filterLayerUid(e.layerUid)}}function A(e){return"object"==typeof e&&"intersect"in e}const k=o(),F=r();export{M as SceneIntersectionHelper,A as isIntersectionHandler};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.30/esri/copyright.txt for details.
4
4
  */
5
- import{fromQuat as t,scale as a}from"../../../core/libs/gl-matrix-2/math/mat3.js";import{create as e}from"../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{create as s}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{set as i,conjugate as r,multiply as n}from"../../../core/libs/gl-matrix-2/math/quat.js";import{IDENTITY as o,create as h}from"../../../core/libs/gl-matrix-2/factories/quatf64.js";import{s as c,r as d,u as l,v as _,w as m,t as f,g as u,x as g,y as p,l as M,i as b,q as j,z as S,A as z,B as x}from"../../../chunks/vec32.js";import{ZEROS as y,create as C,UNIT_Z as q,fromValues as Q}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{t as w}from"../../../chunks/vec42.js";import{create as P}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{getReferenceEllipsoid as v}from"../../../geometry/ellipsoidUtils.js";import{getSphericalPCPF as R}from"../../../geometry/spatialReferenceEllipsoidUtils.js";import{computeTranslationToOriginAndRotation as A}from"../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{projectBuffer as H}from"../../../geometry/projection/projectBuffer.js";import{getProjector as B}from"../../../geometry/projection/projectors.js";import{getNormal as W}from"../../../geometry/support/plane.js";import{isPlateCarree as k}from"../../../geometry/support/spatialReferenceUtils.js";import{sv3d as D,sq4d as G}from"../../../geometry/support/vectorStacks.js";import{ViewingMode as U}from"../../ViewingMode.js";import{computeOBB as V}from"./dito.js";import{Vertices as Z}from"../webgl-engine/lib/Attribute.js";class O{constructor(t=y,a=gt,e=o){this._data=[t[0],t[1],t[2],a[0],a[1],a[2],e[0],e[1],e[2],e[3]]}clone(){const t=new O;return t._data=this._data.slice(),t}invalidate(){this._data[3]=-1}get isValid(){return this._data[3]>=0}static fromData(t){const a=new O;return a._data=t.slice(),a}static fromJSON(t){return new O(t.center,t.halfSize,t.quaternion)}copy(t){this._data=t.data.slice()}get center(){return c(D.get(),this._data[0],this._data[1],this._data[2])}get centerX(){return this._data[0]}get centerY(){return this._data[1]}get centerZ(){return this._data[2]}getCenter(t){return t[0]=this._data[0],t[1]=this._data[1],t[2]=this._data[2],t}set center(t){this._data[0]=t[0],this._data[1]=t[1],this._data[2]=t[2]}setCenter(t,a,e){this._data[0]=t,this._data[1]=a,this._data[2]=e}get halfSize(){return c(D.get(),this._data[3],this._data[4],this._data[5])}get halfSizeX(){return this._data[3]}get halfSizeY(){return this._data[4]}get halfSizeZ(){return this._data[5]}getHalfSize(t){return t[0]=this._data[3],t[1]=this._data[4],t[2]=this._data[5],t}set halfSize(t){this._data[3]=t[0],this._data[4]=t[1],this._data[5]=t[2]}get quaternion(){return i(G.get(),this._data[6],this._data[7],this._data[8],this._data[9])}getQuaternion(t){return t[0]=this._data[6],t[1]=this._data[7],t[2]=this._data[8],t[3]=this._data[9],t}set quaternion(t){this._data[6]=t[0],this._data[7]=t[1],this._data[8]=t[2],this._data[9]=t[3]}get data(){return this._data}getCorners(t){const a=T,e=this._data;a[0]=e[6],a[1]=e[7],a[2]=e[8],a[3]=e[9];for(let s=0;s<8;++s){const i=t[s];i[0]=(1&s?-1:1)*e[3],i[1]=(2&s?-1:1)*e[4],i[2]=(4&s?-1:1)*e[5],d(i,i,a),i[0]+=e[0],i[1]+=e[1],i[2]+=e[2]}}isVisible(t){return this.intersectPlane(t[0])<=0&&this.intersectPlane(t[1])<=0&&this.intersectPlane(t[2])<=0&&this.intersectPlane(t[3])<=0&&this.intersectPlane(t[4])<=0&&this.intersectPlane(t[5])<=0}get radius(){const t=this._data[3],a=this._data[4],e=this._data[5];return Math.sqrt(t*t+a*a+e*e)}intersectSphere(t){E[0]=this._data[0]-t[0],E[1]=this._data[1]-t[1],E[2]=this._data[2]-t[2];const a=this.getQuaternion(X);return r(T,a),d(E,E,T),l(E,E),F[0]=Math.min(E[0],this._data[3]),F[1]=Math.min(E[1],this._data[4]),F[2]=Math.min(E[2],this._data[5]),_(F,E)<t[3]*t[3]}intersectSphereWithMBS(t,a=this.radius){const e=this._data;E[0]=e[0]-t[0],E[1]=e[1]-t[1],E[2]=e[2]-t[2];const s=t[3],i=s+a;return!(m(E)>i*i)&&(T[0]=-e[6],T[1]=-e[7],T[2]=-e[8],T[3]=e[9],d(E,E,T),l(E,E),F[0]=Math.min(E[0],e[3]),F[1]=Math.min(E[1],e[4]),F[2]=Math.min(E[2],e[5]),_(F,E)<s*s)}intersectPlane(t){const a=t[0]*this._data[0]+t[1]*this._data[1]+t[2]*this._data[2]+t[3],e=this.projectedRadius(W(t));return a>e?1:a<-e?-1:0}intersectRay(t,a,e=0){const s=this._data,i=T;i[0]=-s[6],i[1]=-s[7],i[2]=-s[8],i[3]=s[9],E[0]=t[0]-s[0],E[1]=t[1]-s[1],E[2]=t[2]-s[2];const r=d(E,E,T),n=d(F,a,T);let o=-1/0,h=1/0;const c=this.getHalfSize(ct);for(let d=0;d<3;d++){const t=r[d],a=n[d],s=c[d]+e;if(Math.abs(a)>1e-6){const e=(s-t)/a,i=(-s-t)/a;o=Math.max(o,Math.min(e,i)),h=Math.min(h,Math.max(e,i))}else if(t>s||t<-s)return!1}return o<=h}projectedArea(e,s,i,n){const o=this.getQuaternion(X);r(T,o),E[0]=e[0]-this._data[0],E[1]=e[1]-this._data[1],E[2]=e[2]-this._data[2],d(E,E,T);const h=this.getHalfSize(ct),l=E[0]<-h[0]?-1:E[0]>h[0]?1:0,_=E[1]<-h[1]?-1:E[1]>h[1]?1:0,m=E[2]<-h[2]?-1:E[2]>h[2]?1:0,g=Math.abs(l)+Math.abs(_)+Math.abs(m);if(0===g)return 1/0;const p=1===g?4:6,M=6*(l+3*_+9*m+13);t(dt,o),a(dt,dt,h);const b=this.getCenter(ot);for(let t=0;t<p;t++){const a=K[M+t];c(E,((1&a)<<1)-1,(2&a)-1,((4&a)>>1)-1),f(E,E,dt),u(I,b,E),I[3]=1,w(I,I,s);const e=1/Math.max(1e-6,I[3]);N[2*t]=I[0]*e,N[2*t+1]=I[1]*e}const j=2*p-2;let S=N[0]*(N[3]-N[j+1])+N[j]*(N[1]-N[j-1]);for(let t=2;t<j;t+=2)S+=N[t]*(N[t+3]-N[t-1]);return Math.abs(S)*i*n*.125}projectedRadius(t){const a=this.getQuaternion(X);return r(T,a),d(E,t,T),Math.abs(E[0]*this._data[3])+Math.abs(E[1]*this._data[4])+Math.abs(E[2]*this._data[5])}minimumDistancePlane(t){return t[0]*this._data[0]+t[1]*this._data[1]+t[2]*this._data[2]+t[3]-this.projectedRadius(W(t))}maximumDistancePlane(t){return t[0]*this._data[0]+t[1]*this._data[1]+t[2]*this._data[2]+t[3]+this.projectedRadius(W(t))}toAaBoundingBox(a){const e=this.getQuaternion(X),s=t(dt,e),i=this._data[3]*Math.abs(s[0])+this._data[4]*Math.abs(s[3])+this._data[5]*Math.abs(s[6]),r=this._data[3]*Math.abs(s[1])+this._data[4]*Math.abs(s[4])+this._data[5]*Math.abs(s[7]),n=this._data[3]*Math.abs(s[2])+this._data[4]*Math.abs(s[5])+this._data[5]*Math.abs(s[8]);a[0]=this._data[0]-i,a[1]=this._data[1]-r,a[2]=this._data[2]-n,a[3]=this._data[0]+i,a[4]=this._data[1]+r,a[5]=this._data[2]+n}transform(t,a,e,s=0,i=R(e),r=R(a),n=B(a,r)){if(e===i)a.isGeographic?st(this,t,a,s,r):et(this,t,a,s,r,n);else if(a.isWGS84&&(e.isWebMercator||k(e)))$(a,this,e,t,s);else if(a.isWebMercator&&k(e))tt(a,this,e,t,s);else{const i=this.getCenter(ot);i[2]+=s,H(i,a,0,i,e,0,1),t.center=i,this!==t&&(t.quaternion=this.getQuaternion(X),t.halfSize=this.getHalfSize(ct))}}}const T=h(),X=h(),Y=h(),E=C(),F=C(),I=P();function J(t,a=new O){return V(t,a),a}const N=[.1,.2,.3,.4,.5,.6,.7,.8,.9,1,1.1,1.2],K=(()=>{const t=new Int8Array(162);let a=0;const e=e=>{for(let s=0;s<e.length;s++)t[a+s]=e[s];a+=6};return e([6,2,3,1,5,4]),e([0,2,3,1,5,4]),e([0,2,3,7,5,4]),e([0,1,3,2,6,4]),e([0,1,3,2,0,0]),e([0,1,5,7,3,2]),e([0,1,3,7,6,4]),e([0,1,3,7,6,2]),e([0,1,5,7,6,2]),e([0,1,5,4,6,2]),e([0,1,5,4,0,0]),e([0,1,3,7,5,4]),e([0,2,6,4,0,0]),e([0,0,0,0,0,0]),e([1,3,7,5,0,0]),e([2,3,7,6,4,0]),e([2,3,7,6,0,0]),e([2,3,1,5,7,6]),e([0,1,5,7,6,2]),e([0,1,5,7,6,4]),e([0,1,3,7,6,4]),e([4,5,7,6,2,0]),e([4,5,7,6,0,0]),e([4,5,1,3,7,6]),e([0,2,3,7,5,4]),e([6,2,3,7,5,4]),e([6,2,3,1,5,4]),t})();function L(t,a,e,s,i){const n=t.getQuaternion(X);i.quaternion=n,r(T,n);const o=t.getCenter(ot),h=t.getHalfSize(ct);if(s===U.Global){d(mt,o,T),l(ft,mt),g(ut,ft,h),p(ut,ft,ut);const s=M(ut);u(ut,ft,h);const r=M(ut);if(s<e)i.center=o,c(mt,e,e,e),i.halfSize=u(mt,h,mt);else{const n=r>0?1+a/r:1,o=s>0?1+e/s:1,c=(o+n)/2,l=(o-n)/2;b(ut,ft,l),i.halfSize=j(ut,ut,h,c),b(ut,ft,c),j(ut,ut,h,l),S(mt,mt),z(mt,ut,mt);const _=t.getQuaternion(Y);i.center=d(mt,mt,_)}}else{i.center=j(mt,o,q,(e+a)/2);const t=d(mt,q,T);l(t,t),i.halfSize=j(ft,h,t,(e-a)/2)}return i}function $(t,a,e,s,i){a.getCenter(ot),ot[2]+=i;const r=R(e);H(ot,t,0,ot,r,0,1),at(r,a,ot,e,s)}function tt(t,a,e,s,i){a.getCenter(ot),ot[2]+=i,at(t,a,ot,e,s)}function at(a,e,s,i,r){const n=e.getQuaternion(X),o=t(dt,n),h=e.getHalfSize(ct);for(let t=0;t<8;++t){for(let a=0;a<3;++a)nt[a]=h[a]*(0!=(t&1<<a)?-1:1);for(let a=0;a<3;++a){let e=s[a];for(let t=0;t<3;++t)e+=nt[t]*o[3*t+a];it[3*t+a]=e}}H(it,a,0,it,i,0,8),J(rt,r)}function et(t,a,e,s,i=R(e),o=B(e,i)){t.getCorners(_t),t.getCenter(nt),nt[2]+=s,A(e,nt,lt,i),a.setCenter(lt[12],lt[13],lt[14]);const h=2*Math.sqrt(1+lt[0]+lt[5]+lt[10]);T[0]=(lt[6]-lt[9])/h,T[1]=(lt[8]-lt[2])/h,T[2]=(lt[1]-lt[4])/h,T[3]=.25*h;const l=t.getQuaternion(X);a.quaternion=n(T,T,l),r(T,T),c(ft,0,0,0);const _=a.getCenter(ht);for(const r of _t)r[2]+=s,o(r,0,r,0),p(mt,r,_),d(mt,mt,T),x(ft,ft,mt);a.halfSize=ft}function st(t,a,e,s,i=R(e)){const n=v(e),o=1+Math.max(0,s)/(n.radius+t.centerZ);t.getCenter(nt),nt[2]+=s,H(nt,e,0,nt,i,0,1),a.center=nt;const h=t.getQuaternion(X);a.quaternion=h,r(T,h),c(mt,0,0,1),d(mt,mt,T);const l=t.getHalfSize(ct);c(mt,l[0]*Math.abs(mt[0]),l[1]*Math.abs(mt[1]),l[2]*Math.abs(mt[2])),b(mt,mt,n.inverseFlattening),u(mt,l,mt),a.halfSize=b(mt,mt,o)}const it=new Array(24),rt=new Z(it,3),nt=C(),ot=C(),ht=C(),ct=C(),dt=e(),lt=s(),_t=[[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0]],mt=C(),ft=C(),ut=C(),gt=Q(-1,-1,-1);export{O as Obb,J as compute,L as computeOffsetObb};
5
+ import{fromQuat as t,scale as a}from"../../../core/libs/gl-matrix-2/math/mat3.js";import{create as e}from"../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{create as s}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{set as i,conjugate as r,multiply as n}from"../../../core/libs/gl-matrix-2/math/quat.js";import{IDENTITY as o,create as h}from"../../../core/libs/gl-matrix-2/factories/quatf64.js";import{s as c,r as d,u as l,v as _,w as m,t as f,g as u,x as g,y as p,l as M,i as b,q as j,z as S,A as z,B as x}from"../../../chunks/vec32.js";import{ZEROS as y,create as C,UNIT_Z as q,fromValues as Q}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{t as w}from"../../../chunks/vec42.js";import{create as P}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{getReferenceEllipsoid as v}from"../../../geometry/ellipsoidUtils.js";import{getSphericalPCPF as R}from"../../../geometry/spatialReferenceEllipsoidUtils.js";import{computeTranslationToOriginAndRotation as A}from"../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{projectBuffer as H}from"../../../geometry/projection/projectBuffer.js";import{getProjector as B}from"../../../geometry/projection/projectors.js";import{getNormal as W}from"../../../geometry/support/plane.js";import{isPlateCarree as k}from"../../../geometry/support/spatialReferenceUtils.js";import{sv3d as D,sq4d as G}from"../../../geometry/support/vectorStacks.js";import{ViewingMode as U}from"../../ViewingMode.js";import{computeOBB as V}from"./dito.js";import{Vertices as Z}from"../webgl-engine/lib/Attribute.js";class O{constructor(t=y,a=gt,e=o){this._data=[t[0],t[1],t[2],a[0],a[1],a[2],e[0],e[1],e[2],e[3]]}clone(){const t=new O;return t._data=this._data.slice(),t}invalidate(){this._data[3]=-1}get isValid(){return this._data[3]>=0}static fromData(t){const a=new O;return a._data=t.slice(),a}static fromJSON(t){return new O(t.center,t.halfSize,t.quaternion)}copy(t){this._data=t.data.slice()}get center(){return c(D.get(),this._data[0],this._data[1],this._data[2])}get centerX(){return this._data[0]}get centerY(){return this._data[1]}get centerZ(){return this._data[2]}getCenter(t){return t[0]=this._data[0],t[1]=this._data[1],t[2]=this._data[2],t}set center(t){this._data[0]=t[0],this._data[1]=t[1],this._data[2]=t[2]}setCenter(t,a,e){this._data[0]=t,this._data[1]=a,this._data[2]=e}get halfSize(){return c(D.get(),this._data[3],this._data[4],this._data[5])}get halfSizeX(){return this._data[3]}get halfSizeY(){return this._data[4]}get halfSizeZ(){return this._data[5]}getHalfSize(t){return t[0]=this._data[3],t[1]=this._data[4],t[2]=this._data[5],t}set halfSize(t){this._data[3]=t[0],this._data[4]=t[1],this._data[5]=t[2]}get quaternion(){return i(G.get(),this._data[6],this._data[7],this._data[8],this._data[9])}getQuaternion(t){return t[0]=this._data[6],t[1]=this._data[7],t[2]=this._data[8],t[3]=this._data[9],t}set quaternion(t){this._data[6]=t[0],this._data[7]=t[1],this._data[8]=t[2],this._data[9]=t[3]}get data(){return this._data}getCorners(t){const a=T,e=this._data;a[0]=e[6],a[1]=e[7],a[2]=e[8],a[3]=e[9];for(let s=0;s<8;++s){const i=t[s];i[0]=(1&s?-1:1)*e[3],i[1]=(2&s?-1:1)*e[4],i[2]=(4&s?-1:1)*e[5],d(i,i,a),i[0]+=e[0],i[1]+=e[1],i[2]+=e[2]}}isVisible(t){return this.intersectPlane(t[0])<=0&&this.intersectPlane(t[1])<=0&&this.intersectPlane(t[2])<=0&&this.intersectPlane(t[3])<=0&&this.intersectPlane(t[4])<=0&&this.intersectPlane(t[5])<=0}get radius(){const t=this._data[3],a=this._data[4],e=this._data[5];return Math.sqrt(t*t+a*a+e*e)}intersectSphere(t){E[0]=this._data[0]-t[0],E[1]=this._data[1]-t[1],E[2]=this._data[2]-t[2];const a=this.getQuaternion(X);return r(T,a),d(E,E,T),l(E,E),F[0]=Math.min(E[0],this._data[3]),F[1]=Math.min(E[1],this._data[4]),F[2]=Math.min(E[2],this._data[5]),_(F,E)<t[3]*t[3]}intersectSphereWithMBS(t,a=this.radius){const e=this._data;E[0]=e[0]-t[0],E[1]=e[1]-t[1],E[2]=e[2]-t[2];const s=t[3],i=s+a;return!(m(E)>i*i)&&(T[0]=-e[6],T[1]=-e[7],T[2]=-e[8],T[3]=e[9],d(E,E,T),l(E,E),F[0]=Math.min(E[0],e[3]),F[1]=Math.min(E[1],e[4]),F[2]=Math.min(E[2],e[5]),_(F,E)<s*s)}intersectPlane(t){const a=t[0]*this._data[0]+t[1]*this._data[1]+t[2]*this._data[2]+t[3],e=this.projectedRadius(W(t));return a>e?1:a<-e?-1:0}intersectRay(t,a,e=0){const s=this._data,i=T;i[0]=-s[6],i[1]=-s[7],i[2]=-s[8],i[3]=s[9],E[0]=t[0]-s[0],E[1]=t[1]-s[1],E[2]=t[2]-s[2];const r=d(E,E,T),n=d(F,a,T);let o=-1/0,h=1/0;const c=this.getHalfSize(ct);for(let d=0;d<3;d++){const t=r[d],a=n[d],s=c[d]+e;if(Math.abs(a)>1e-6){const e=(s-t)/a,i=(-s-t)/a;o=Math.max(o,Math.min(e,i)),h=Math.min(h,Math.max(e,i))}else if(t>s||t<-s)return!1}return o<=h}projectedArea(e,s,i,n){const o=this.getQuaternion(X);r(T,o),E[0]=e[0]-this._data[0],E[1]=e[1]-this._data[1],E[2]=e[2]-this._data[2],d(E,E,T);const h=this.getHalfSize(ct),l=E[0]<-h[0]?-1:E[0]>h[0]?1:0,_=E[1]<-h[1]?-1:E[1]>h[1]?1:0,m=E[2]<-h[2]?-1:E[2]>h[2]?1:0,g=Math.abs(l)+Math.abs(_)+Math.abs(m);if(0===g)return 1/0;const p=1===g?4:6,M=6*(l+3*_+9*m+13);t(dt,o),a(dt,dt,h);const b=this.getCenter(ot);for(let t=0;t<p;t++){const a=K[M+t];c(E,((1&a)<<1)-1,(2&a)-1,((4&a)>>1)-1),f(E,E,dt),u(I,b,E),I[3]=1,w(I,I,s);const e=1/Math.max(1e-6,I[3]);N[2*t]=I[0]*e,N[2*t+1]=I[1]*e}const j=2*p-2;let S=N[0]*(N[3]-N[j+1])+N[j]*(N[1]-N[j-1]);for(let t=2;t<j;t+=2)S+=N[t]*(N[t+3]-N[t-1]);return Math.abs(S)*i*n*.125}projectedRadius(t){const a=this.getQuaternion(X);return r(T,a),d(E,t,T),Math.abs(E[0]*this._data[3])+Math.abs(E[1]*this._data[4])+Math.abs(E[2]*this._data[5])}minimumDistancePlane(t){return t[0]*this._data[0]+t[1]*this._data[1]+t[2]*this._data[2]+t[3]-this.projectedRadius(W(t))}maximumDistancePlane(t){return t[0]*this._data[0]+t[1]*this._data[1]+t[2]*this._data[2]+t[3]+this.projectedRadius(W(t))}toAaBoundingBox(a){const e=this.getQuaternion(X),s=t(dt,e),i=this._data[3]*Math.abs(s[0])+this._data[4]*Math.abs(s[3])+this._data[5]*Math.abs(s[6]),r=this._data[3]*Math.abs(s[1])+this._data[4]*Math.abs(s[4])+this._data[5]*Math.abs(s[7]),n=this._data[3]*Math.abs(s[2])+this._data[4]*Math.abs(s[5])+this._data[5]*Math.abs(s[8]);a[0]=this._data[0]-i,a[1]=this._data[1]-r,a[2]=this._data[2]-n,a[3]=this._data[0]+i,a[4]=this._data[1]+r,a[5]=this._data[2]+n}transform(t,a,e,s=0,i=R(e),r=R(a),n=B(a,r)){if(e===i)a.isGeographic?st(this,t,a,s,r):et(this,t,a,s,r,n);else if(a.isWGS84&&(e.isWebMercator||k(e)))$(a,this,e,t,s);else if(a.isWebMercator&&k(e))tt(a,this,e,t,s);else{const i=this.getCenter(ot);i[2]+=s,H(i,a,0,i,e,0,1),t.center=i,this!==t&&(t.quaternion=this.getQuaternion(X),t.halfSize=this.getHalfSize(ct))}}}const T=h(),X=h(),Y=h(),E=C(),F=C(),I=P();function J(t,a=new O){return V(t,a),a}const N=[.1,.2,.3,.4,.5,.6,.7,.8,.9,1,1.1,1.2],K=(()=>{const t=new Int8Array(162);let a=0;const e=e=>{for(let s=0;s<e.length;s++)t[a+s]=e[s];a+=6};return e([6,2,3,1,5,4]),e([0,2,3,1,5,4]),e([0,2,3,7,5,4]),e([0,1,3,2,6,4]),e([0,1,3,2,0,0]),e([0,1,5,7,3,2]),e([0,1,3,7,6,4]),e([0,1,3,7,6,2]),e([0,1,5,7,6,2]),e([0,1,5,4,6,2]),e([0,1,5,4,0,0]),e([0,1,3,7,5,4]),e([0,2,6,4,0,0]),e([0,0,0,0,0,0]),e([1,3,7,5,0,0]),e([2,3,7,6,4,0]),e([2,3,7,6,0,0]),e([2,3,1,5,7,6]),e([0,1,5,7,6,2]),e([0,1,5,7,6,4]),e([0,1,3,7,6,4]),e([4,5,7,6,2,0]),e([4,5,7,6,0,0]),e([4,5,1,3,7,6]),e([0,2,3,7,5,4]),e([6,2,3,7,5,4]),e([6,2,3,1,5,4]),t})();function L(t,a,e,s,i){const n=t.getQuaternion(X);i.quaternion=n,r(T,n);const o=t.getCenter(ot),h=t.getHalfSize(ct);if(s===U.Global){d(mt,o,T),l(ft,mt),g(ut,ft,h),p(ut,ft,ut);const s=M(ut);u(ut,ft,h);const r=M(ut);if(s<e)i.center=o,c(mt,e,e,e),i.halfSize=u(mt,h,mt);else{const n=r>0?1+a/r:1,o=s>0?1+e/s:1,c=(o+n)/2,l=(o-n)/2;b(ut,ft,l),i.halfSize=j(ut,ut,h,c),b(ut,ft,c),j(ut,ut,h,l),S(mt,mt),z(mt,ut,mt);const _=t.getQuaternion(Y);i.center=d(mt,mt,_)}}else{i.center=j(mt,o,q,(e+a)/2);const t=d(mt,q,T);l(t,t),i.halfSize=j(ft,h,t,(e-a)/2)}return i}function $(t,a,e,s,i){a.getCenter(ot),ot[2]+=i;const r=R(e);H(ot,t,0,ot,r,0,1),at(r,a,ot,e,s)}function tt(t,a,e,s,i){a.getCenter(ot),ot[2]+=i,at(t,a,ot,e,s)}function at(a,e,s,i,r){const n=e.getQuaternion(X),o=t(dt,n),h=e.getHalfSize(ct);for(let t=0;t<8;++t){for(let a=0;a<3;++a)nt[a]=h[a]*(0!=(t&1<<a)?-1:1);for(let a=0;a<3;++a){let e=s[a];for(let t=0;t<3;++t)e+=nt[t]*o[3*t+a];it[3*t+a]=e}}H(it,a,0,it,i,0,8),J(rt,r)}function et(t,a,e,s,i=R(e),o=B(e,i)){t.getCorners(_t),t.getCenter(nt),nt[2]+=s,A(e,nt,lt,i),a.setCenter(lt[12],lt[13],lt[14]);const h=2*Math.sqrt(1+lt[0]+lt[5]+lt[10]);T[0]=(lt[6]-lt[9])/h,T[1]=(lt[8]-lt[2])/h,T[2]=(lt[1]-lt[4])/h,T[3]=.25*h;const _=t.getQuaternion(X);a.quaternion=n(T,T,_),r(T,T),c(ft,0,0,0);const m=a.getCenter(ht);for(const r of _t)r[2]+=s,o(r,0,r,0),p(mt,r,m),d(mt,mt,T),l(mt,mt),x(ft,ft,mt);a.halfSize=ft}function st(t,a,e,s,i=R(e)){const n=v(e),o=1+Math.max(0,s)/(n.radius+t.centerZ);t.getCenter(nt),nt[2]+=s,H(nt,e,0,nt,i,0,1),a.center=nt;const h=t.getQuaternion(X);a.quaternion=h,r(T,h),c(mt,0,0,1),d(mt,mt,T);const l=t.getHalfSize(ct);c(mt,l[0]*Math.abs(mt[0]),l[1]*Math.abs(mt[1]),l[2]*Math.abs(mt[2])),b(mt,mt,n.inverseFlattening),u(mt,l,mt),a.halfSize=b(mt,mt,o)}const it=new Array(24),rt=new Z(it,3),nt=C(),ot=C(),ht=C(),ct=C(),dt=e(),lt=s(),_t=[[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0]],mt=C(),ft=C(),ut=C(),gt=Q(-1,-1,-1);export{O as Obb,J as compute,L as computeOffsetObb};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.30/esri/copyright.txt for details.
4
4
  */
5
- import{releaseMaybe as e}from"../../../core/maybe.js";class t{constructor(e,t,h){this._fbos=e,this._format=t,this._name=h}get valid(){return null!=this._handle?.getTexture()}dispose(){this._handle=e(this._handle)}get texture(){return this._handle?.getTexture()}bind(e,t,h){this._handle&&this._handle.fbo.width===t&&this._handle.fbo.height===h?e.bindFramebuffer(this._handle?.fbo):(this._handle?.release(),this._handle=this._fbos.acquire(t,h,this._name,this._format))}generateMipMap(){this._handle?.getTexture()?.descriptor?.hasMipmap&&this._handle?.getTexture()?.generateMipmap()}}export{t as OverlayFramebufferObject};
5
+ import{releaseMaybe as e}from"../../../core/maybe.js";class t{constructor(e,t,h){this._fbos=e,this._format=t,this._name=h}get valid(){return null!=this._handle?.getTexture()}dispose(){this._handle=e(this._handle)}get texture(){return this._handle?.getTexture()}bind(e,t,h){this._handle&&this._handle.fbo.width===t&&this._handle.fbo.height===h||(this._handle?.release(),this._handle=this._fbos.acquire(t,h,this._name,this._format)),e.unbindTexture(this._handle?.fbo.colorTexture),e.bindFramebuffer(this._handle?.fbo)}generateMipMap(){this._handle?.getTexture()?.descriptor?.hasMipmap&&this._handle?.getTexture()?.generateMipmap()}}export{t as OverlayFramebufferObject};