@arcgis/core 4.27.0-rc.0 → 4.27.0-rc.2

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 (207) hide show
  1. package/README.md +2 -2
  2. package/arcade/featureSetUtils.js +1 -1
  3. package/arcade/featureset/actions/GroupBy.js +1 -1
  4. package/arcade/featureset/actions/OrderBy.js +1 -1
  5. package/arcade/functions/featuresetbase.js +1 -1
  6. package/arcade/functions/featuresetstring.js +1 -1
  7. package/arcade/languageUtils.js +1 -1
  8. package/arcade/treeAnalysis.js +1 -1
  9. package/assets/esri/core/workers/RemoteClient.js +1 -1
  10. package/assets/esri/core/workers/chunks/0407bf97ad621c89a734.js +1 -0
  11. package/assets/esri/core/workers/chunks/0610691a0c0d9fbbd6d2.js +1 -0
  12. package/assets/esri/core/workers/chunks/0a86c458916e83d6c523.js +1 -0
  13. package/assets/esri/core/workers/chunks/14145959a3dab1437818.js +1 -0
  14. package/assets/esri/core/workers/chunks/16db0bc87d87a7313dc4.js +1 -0
  15. package/assets/esri/core/workers/chunks/183e2e0cb86c1c640d94.js +1 -0
  16. package/assets/esri/core/workers/chunks/19d329b9d4ec2eff1d13.js +1 -0
  17. package/assets/esri/core/workers/chunks/1b8074269800b384ecf6.js +1 -0
  18. package/assets/esri/core/workers/chunks/1f69fb9687de9ebfcf90.js +1 -0
  19. package/assets/esri/core/workers/chunks/2154d395f405be3cd3ba.js +1 -0
  20. package/assets/esri/core/workers/chunks/{33dbba3b7fc648437e50.js → 21e1f3b11e7d363b727a.js} +1 -1
  21. package/assets/esri/core/workers/chunks/{31a158c73994603c169d.js → 2446e336b1f7256d4fde.js} +1 -1
  22. package/assets/esri/core/workers/chunks/29290a44fd3b183c24e3.js +1 -0
  23. package/assets/esri/core/workers/chunks/2b55295590b4a0503749.js +1 -0
  24. package/assets/esri/core/workers/chunks/{f498c4d4831141125781.js → 2f5639886f577baedbca.js} +1 -1
  25. package/assets/esri/core/workers/chunks/33901eb1574e46abd9af.js +1 -0
  26. package/assets/esri/core/workers/chunks/{9c78ad5ab57e0d47ac43.js → 3ba2fcb9110230f8790c.js} +1 -1
  27. package/assets/esri/core/workers/chunks/3e239bfad611985e50fb.js +1 -0
  28. package/assets/esri/core/workers/chunks/42f3421740a5479559dc.js +1 -0
  29. package/assets/esri/core/workers/chunks/471f6eba213412b82840.js +1 -0
  30. package/assets/esri/core/workers/chunks/53ad34bf32f5f3d4fe18.js +1 -0
  31. package/assets/esri/core/workers/chunks/{97cdbec7532cfcdf9ad2.js → 595a2baa04d92de59558.js} +1 -1
  32. package/assets/esri/core/workers/chunks/{2e627c94e57c924e5917.js → 5e6471dd2a08e66b47d0.js} +79 -81
  33. package/assets/esri/core/workers/chunks/624521961fe1f2c4f2c5.js +1 -0
  34. package/assets/esri/core/workers/chunks/{212d59764c275c763941.js → 659b7bad7281c0e2aed3.js} +1 -1
  35. package/assets/esri/core/workers/chunks/6a3d611e8842afbb50ab.js.LICENSE.txt +1 -1
  36. package/assets/esri/core/workers/chunks/6cd248d065f6d1616294.js +1 -0
  37. package/assets/esri/core/workers/chunks/6e562fa57c0347091154.js +1 -0
  38. package/assets/esri/core/workers/chunks/6f510f28526c73ab453c.js +1 -0
  39. package/assets/esri/core/workers/chunks/7479dc0c790337af7597.js +1 -0
  40. package/assets/esri/core/workers/chunks/{e88cff2537be52da6531.js → 74fd2059ddda9083cbcc.js} +1 -1
  41. package/assets/esri/core/workers/chunks/7dc6774c77c822b68c99.js +1 -0
  42. package/assets/esri/core/workers/chunks/82a103a8b5382300889d.js +1 -0
  43. package/assets/esri/core/workers/chunks/83e3d104886b48f00397.js +1 -0
  44. package/assets/esri/core/workers/chunks/{9849f64793f2ad39366b.js → 9290b0d330f02233d803.js} +1 -1
  45. package/assets/esri/core/workers/chunks/{3c5a64a545272f148e93.js → 9621b7d8d951aa881686.js} +1 -1
  46. package/assets/esri/core/workers/chunks/{36df72362b38759b895b.js → 9648a8f2b24f1ca3d637.js} +1 -1
  47. package/assets/esri/core/workers/chunks/{ad18fb7bb54a0c4bdb38.js → a20361b4d3bdd7d196ca.js} +1 -1
  48. package/assets/esri/core/workers/chunks/a7fd2a95fde197c06828.js +1 -0
  49. package/assets/esri/core/workers/chunks/b0cda39b53ecd6c44cd0.js +1 -0
  50. package/assets/esri/core/workers/chunks/b2a423d9ce8bb784267c.js +1 -0
  51. package/assets/esri/core/workers/chunks/{b6e173eddaad4244cb5f.js → b31974524932e638df8c.js} +1 -1
  52. package/assets/esri/core/workers/chunks/{df0453cdfe685d6436cc.js → b6dc41fce601b9d3480e.js} +1 -1
  53. package/assets/esri/core/workers/chunks/b8e6c64792a512df4c4d.js +1 -0
  54. package/assets/esri/core/workers/chunks/c6617a937440701c0180.js +1 -0
  55. package/assets/esri/core/workers/chunks/d8607326a199dd994844.js +1 -0
  56. package/assets/esri/core/workers/chunks/da57eba2fe25495ea217.js +1 -0
  57. package/assets/esri/core/workers/chunks/dabd889e064c4e7807fa.js +1 -0
  58. package/assets/esri/core/workers/chunks/{39e473586579d11d6732.js → e2432871f1329f47465d.js} +1 -1
  59. package/assets/esri/core/workers/chunks/ee5ee03dd2c7dc940272.js +1 -0
  60. package/assets/esri/core/workers/chunks/{c83669cf08391a62fb72.js → f1da7b29eecad0e9efae.js} +1 -1
  61. package/assets/esri/core/workers/chunks/f35895e03c036d67b3ed.js +1 -0
  62. package/assets/esri/core/workers/chunks/f505ebd4bd3bfb6c790d.js +1 -0
  63. package/assets/esri/core/workers/chunks/f6e68befe2812b90b40d.js +1 -0
  64. package/assets/esri/core/workers/chunks/{3c6c082157c916f8ddba.js → ffe61d5a6a9b34bee9d4.js} +1 -1
  65. package/assets/esri/themes/base/widgets/_Bookmarks.scss +5 -0
  66. package/assets/esri/themes/base/widgets/_Feature.scss +4 -0
  67. package/assets/esri/themes/base/widgets/_FeatureContent.scss +9 -2
  68. package/assets/esri/themes/base/widgets/_Features.scss +5 -7
  69. package/assets/esri/themes/base/widgets/_Popup.scss +3 -3
  70. package/assets/esri/themes/base/widgets/_ScaleRangeSlider.scss +1 -0
  71. package/assets/esri/themes/base/widgets/_Swipe.scss +11 -0
  72. package/assets/esri/themes/dark/main.css +1 -1
  73. package/assets/esri/themes/light/main.css +1 -1
  74. package/assets/esri/themes/light/view.css +1 -1
  75. package/chunks/DefaultMaterial.glsl.js +3 -2
  76. package/chunks/SSAO.glsl.js +1 -1
  77. package/chunks/ShadowCastAccumulate.glsl.js +1 -1
  78. package/chunks/languageUtils.js +1 -1
  79. package/core/timeUtils.js +1 -1
  80. package/geometry/Mesh.js +1 -1
  81. package/geometry/support/DoubleArray.js +1 -1
  82. package/geometry/support/meshUtils/bounds.js +5 -0
  83. package/geometry/support/meshUtils/georeference.js +1 -1
  84. package/geometry/support/meshVertexSpaceUtils.js +5 -0
  85. package/interfaces.d.ts +181 -33
  86. package/kernel.js +1 -1
  87. package/layers/FeatureLayer.js +1 -1
  88. package/layers/StreamLayer.js +1 -1
  89. package/layers/VideoLayer.js +1 -1
  90. package/layers/graphics/controllers/I3SOnDemandController.js +1 -1
  91. package/layers/graphics/controllers/StreamController.js +1 -1
  92. package/layers/graphics/data/QueryEngine.js +1 -1
  93. package/layers/graphics/data/attributeSupport.js +1 -1
  94. package/layers/graphics/editingSupport.js +1 -1
  95. package/layers/graphics/sources/FeatureLayerSource.js +1 -1
  96. package/layers/knowledgeGraph/KnowledgeGraphSublayer.js +1 -1
  97. package/layers/support/FeatureReductionBinning.js +1 -1
  98. package/layers/support/FeatureReductionCluster.js +1 -1
  99. package/layers/support/featureLayerUtils.js +1 -1
  100. package/layers/support/rasterFunctions/colormaps.js +1 -1
  101. package/layers/video/VideoController.js +1 -1
  102. package/layers/video/videoUtils.js +5 -0
  103. package/package.json +2 -2
  104. package/renderers/support/utils.js +1 -1
  105. package/rest/support/meshFeatureSet.js +1 -1
  106. package/smartMapping/symbology/flow.js +1 -1
  107. package/statistics/utils.js +1 -1
  108. package/support/arcadeUtils.js +1 -1
  109. package/support/revision.js +1 -1
  110. package/symbols/cim/CIMSymbolHelper.js +1 -1
  111. package/symbols/cim/effects/EffectBuffer.js +1 -1
  112. package/symbols/cim/effects/EffectDonut.js +1 -1
  113. package/symbols/cim/effects/EffectOffset.js +1 -1
  114. package/views/2d/layers/StreamLayerView2D.js +1 -1
  115. package/views/2d/layers/features/Store2D.js +1 -1
  116. package/views/2d/layers/features/sources/StreamSource.js +1 -1
  117. package/views/3d/environment/ChapmanAtmosphereTechnique.js +1 -1
  118. package/views/3d/interactive/visualElements/OutlineVisualElement.js +1 -1
  119. package/views/3d/layers/BuildingComponentSublayerView3D.js +1 -1
  120. package/views/3d/layers/I3SMeshView3D.js +1 -1
  121. package/views/3d/layers/II3SMeshView3D.js +1 -1
  122. package/views/3d/layers/SceneLayerView3D.js +1 -1
  123. package/views/3d/layers/graphics/Graphics3DMeshFillSymbolLayer.js +1 -1
  124. package/views/3d/layers/graphics/Graphics3DObjectSymbolLayer.js +1 -1
  125. package/views/3d/layers/graphics/objectResourceUtils.js +1 -1
  126. package/views/3d/layers/graphics/webStyleUtils.js +1 -1
  127. package/views/3d/layers/i3s/I3SClientNodeLoader.js +1 -1
  128. package/views/3d/layers/i3s/I3SMaterialUtil.js +1 -1
  129. package/views/3d/layers/i3s/I3SOverrides.js +1 -1
  130. package/views/3d/webgl-engine/collections/Component/Material/ComponentMaterial.js +1 -1
  131. package/views/3d/webgl-engine/core/renderPasses/AllRenderPasses.js +1 -1
  132. package/views/3d/webgl-engine/core/shaderLibrary/Transform.glsl.js +3 -9
  133. package/views/3d/webgl-engine/core/shaderLibrary/default/DefaultMaterialAuxiliaryPasses.glsl.js +12 -9
  134. package/views/3d/webgl-engine/core/shaderLibrary/shading/PhysicallyBasedRenderingParameters.glsl.js +10 -10
  135. package/views/3d/webgl-engine/core/shaderLibrary/shading/ReadShadowMap.glsl.js +2 -2
  136. package/views/3d/webgl-engine/core/shaderLibrary/shading/WaterDistortion.glsl.js +2 -2
  137. package/views/3d/webgl-engine/core/shaderLibrary/terrain/TerrainTexture.glsl.js +8 -8
  138. package/views/3d/webgl-engine/core/shaderModules/Matrix4sDrawUniform.js +1 -1
  139. package/views/3d/webgl-engine/lib/Camera.js +1 -1
  140. package/views/3d/webgl-engine/lib/ShadowHighlight.js +1 -1
  141. package/views/3d/webgl-engine/lib/ShadowMap.js +1 -1
  142. package/views/3d/webgl-engine/materials/PathTechnique.js +1 -1
  143. package/views/3d/webgl-engine/materials/WaterMaterial.js +1 -1
  144. package/views/3d/webgl-engine/materials/pbrUtils.js +5 -0
  145. package/views/3d/webgl-engine/shaders/AtmosphereCompositingTechnique.js +1 -1
  146. package/views/3d/webgl-engine/shaders/DefaultMaterialTechnique.js +1 -1
  147. package/views/3d/webgl-engine/shaders/ShadowHighlightTechnique.js +1 -1
  148. package/views/draw/DrawGraphicTool.js +1 -1
  149. package/views/layers/GroupLayerView.js +1 -1
  150. package/webdoc/support/writeUtils.js +1 -1
  151. package/widgets/Bookmarks/css.js +1 -1
  152. package/widgets/Bookmarks.js +1 -1
  153. package/widgets/Daylight/DaylightViewModel.js +1 -1
  154. package/widgets/Editor/EditorViewModel.js +1 -1
  155. package/widgets/Editor/UpdateWorkflow.js +1 -1
  156. package/widgets/Editor/Workflow.js +1 -1
  157. package/widgets/Editor/workflowUtils.js +1 -1
  158. package/widgets/Editor.js +1 -1
  159. package/widgets/Feature/FeatureRelationship/FeatureRelationshipViewModel.js +1 -1
  160. package/widgets/Feature/FeatureRelationship.js +1 -1
  161. package/widgets/FeatureForm/EditableInput.d.ts +2 -2
  162. package/widgets/FeatureTable/FieldColumn.js +1 -1
  163. package/widgets/Features.js +1 -1
  164. package/widgets/UtilityNetworkTrace/UtilityNetworkTraceViewModel.js +1 -1
  165. package/widgets/UtilityNetworkTrace/support/GeometryHandler.js +1 -1
  166. package/widgets/UtilityNetworkTrace/support/ResultAreaHandler.js +1 -1
  167. package/widgets/UtilityNetworkTrace.js +1 -1
  168. package/widgets/UtilityNetworkValidateTopology/UtilityNetworkValidateTopologyViewModel.js +1 -1
  169. package/widgets/UtilityNetworkValidateTopology.js +1 -1
  170. package/widgets/ValuePicker/ValuePickerBaseComponent.js +1 -1
  171. package/widgets/ValuePicker.js +1 -1
  172. package/assets/esri/core/workers/chunks/0b03165dbf289797cefa.js +0 -1
  173. package/assets/esri/core/workers/chunks/0c1c0024879f944f44c4.js +0 -1
  174. package/assets/esri/core/workers/chunks/13a48796905613bc1679.js +0 -1
  175. package/assets/esri/core/workers/chunks/1ea1104651ab15f9a13c.js +0 -1
  176. package/assets/esri/core/workers/chunks/2108cfc7921430f0b805.js +0 -1
  177. package/assets/esri/core/workers/chunks/2eacca322737aafd8f0c.js +0 -1
  178. package/assets/esri/core/workers/chunks/39577683e334eb4d904c.js +0 -1
  179. package/assets/esri/core/workers/chunks/39714837f9d3708e3806.js +0 -1
  180. package/assets/esri/core/workers/chunks/3fe357df92afa1bee70a.js +0 -1
  181. package/assets/esri/core/workers/chunks/4d3deeb0ebd0ce8c1215.js +0 -1
  182. package/assets/esri/core/workers/chunks/576bddc3fa7d91a7e5bd.js +0 -1
  183. package/assets/esri/core/workers/chunks/623d6710a4f800c622ce.js +0 -1
  184. package/assets/esri/core/workers/chunks/6782cc3feb713676d544.js +0 -1
  185. package/assets/esri/core/workers/chunks/6e7178de0b2c3d2f7e6b.js +0 -1
  186. package/assets/esri/core/workers/chunks/785a6c925f29bc962992.js +0 -1
  187. package/assets/esri/core/workers/chunks/78ce0b1af62435d8ebf4.js +0 -1
  188. package/assets/esri/core/workers/chunks/79d2baf392589588ef9b.js +0 -1
  189. package/assets/esri/core/workers/chunks/7bbdba52157da13a01fc.js +0 -1
  190. package/assets/esri/core/workers/chunks/7ec6be2bc0f354011e46.js +0 -1
  191. package/assets/esri/core/workers/chunks/84860b535a70ec448cfe.js +0 -1
  192. package/assets/esri/core/workers/chunks/9035d9e09a4e7cb94d37.js +0 -1
  193. package/assets/esri/core/workers/chunks/956b0fef7bc849415354.js +0 -1
  194. package/assets/esri/core/workers/chunks/9ab98321a4a7eaeeb018.js +0 -1
  195. package/assets/esri/core/workers/chunks/9cb7a68ff46e5c43e1d2.js +0 -1
  196. package/assets/esri/core/workers/chunks/a0f7f7f578521970c714.js +0 -1
  197. package/assets/esri/core/workers/chunks/a60eac45d3c65bd0216f.js +0 -1
  198. package/assets/esri/core/workers/chunks/aca5260f6984952a6e3d.js +0 -1
  199. package/assets/esri/core/workers/chunks/b05be356743fa5d24573.js +0 -1
  200. package/assets/esri/core/workers/chunks/ba6024465308c248170b.js +0 -1
  201. package/assets/esri/core/workers/chunks/d0983f808008920514f2.js +0 -1
  202. package/assets/esri/core/workers/chunks/dab832799bc06b0fec34.js +0 -1
  203. package/assets/esri/core/workers/chunks/e45d36aef2bc69ee9132.js +0 -1
  204. package/assets/esri/core/workers/chunks/e5bbd4cc5edbf7ab3624.js +0 -1
  205. package/assets/esri/core/workers/chunks/e700cf4d1f99291a4396.js +0 -1
  206. package/assets/esri/core/workers/chunks/f398a5cf33c3fd2522a5.js +0 -1
  207. package/assets/esri/core/workers/chunks/f4ee94a6cde4ea8837f1.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.27/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../../../Color.js";import has from"../../../../core/has.js";import{throwIfAborted as t}from"../../../../core/promiseUtils.js";import{pt2px as s}from"../../../../core/screenUtils.js";import{estimateSize as r}from"../../../../core/typedArrayUtil.js";import{i,k as a,w as o,c as n}from"../../../../chunks/mat4.js";import{c as l}from"../../../../chunks/mat4f64.js";import{l as c,o as h,c as d,C as m,a as p,s as u}from"../../../../chunks/vec3.js";import{g as y,O as _,Z as f,f as g,c as b}from"../../../../chunks/vec3f64.js";import{O as P,c as R}from"../../../../chunks/vec4f64.js";import{projectPointToVector as x,computeTranslationToOriginAndRotation as v}from"../../../../geometry/projection.js";import{create as L,size as C,containsPoint as S,center as E}from"../../../../geometry/support/aaBoundingBox.js";import{defaultPrimitive as j}from"../../../../symbols/support/ObjectSymbol3DLayerResource.js";import{objectSymbolLayerPrimitiveBoundingBox as w,objectSymbolLayerSizeWithResourceSize as T}from"../../../../symbols/support/symbolLayerUtils3D.js";import{perLodInstanceElevationAligner as U}from"./ElevationAligners.js";import{needsElevationUpdates3D as O,evaluateElevationInfoAtPoint as B,SampleElevationInfo as I}from"./elevationAlignmentUtils.js";import{ElevationContext as A}from"./ElevationContext.js";import G from"./Graphics3DLodInstanceGraphicLayer.js";import{Graphics3DSymbolLayer as D}from"./Graphics3DSymbolLayer.js";import{validateSymbolLayerSize as F,mixinColorAndOpacity as z,computeObjectScale as M,computeObjectRotation as V}from"./graphicUtils.js";import{ApplyRendererDiffResult as k}from"./interfaces.js";import{LoadStatus as H}from"./Loadable.js";import{makeLodResources as W}from"./lodResourceUtils.js";import{fetch as q}from"./objectResourceUtils.js";import{placePointOnGeometry as N,extendPointGraphicElevationContext as J}from"./pointUtils.js";import{isValidPrimitive as Y,primitiveLodResources as $}from"./primitiveObjectSymbolUtils.js";import{defaultSymbolLayerMemoryComplexity as Z}from"./symbolComplexity.js";import{getResourceUrlFromSymbolStyle as K}from"./webStyleUtils.js";import{initFastSymbolUpdatesState as Q,updateFastSymbolUpdatesState as X,ConvertOptions as ee,evaluateModelTransform as te,evaluateModelTransformScale as se}from"../support/FastSymbolUpdates.js";import{CullFaceOptions as re}from"../../webgl-engine/lib/basicInterfaces.js";import{VertexAttribute as ie}from"../../webgl-engine/lib/VertexAttribute.js";import{LodRenderer as ae}from"../../webgl-engine/lib/lodRendering/LodRenderer.js";import{materialsFromLodResources as oe,texturesFromLodResources as ne,geometriesFromLodResources as le,geometriesFromLodLevelResources as ce}from"../../webgl-engine/lib/lodRendering/LodResources.js";import{DefaultMaterial as he}from"../../webgl-engine/materials/DefaultMaterial.js";class de{constructor(e,t,s,r,i,a,o,n,l,c,h,d){this.lodResources=e,this.lodRenderer=t,this.stageResources=s,this.originalMaterialParameters=r,this.resourceSize=i,this.isEsriSymbolResource=a,this.isWosr=o,this.resourceBoundingBox=n,this.symbolSize=l,this.extentPadding=c,this.physicalBasedRenderingEnabled=h,this.pivotOffset=d}}class me extends D{getCachedSize(){const[e,t,s]=null!=this._resources?this._resources.symbolSize:[1,1,1];return{width:e,depth:t,height:s}}constructor(e,t,s,r){super(e,t,s,r),this._resources=null,this._optionalFields=new Array,this._instanceIndexToGraphicUid=new Map,this._hasLoadedPBRTextures=!1,this._disposeResourceHandles=new Array,this.skipHighSymbolLodsChanged=!1,this.ensureDrapedStatus(!1),this._hasLoadedPBRTextures=s.physicalBasedRenderingEnabled}async doLoad(e){if(!this._drivenProperties.size){if(F(this.symbolLayer))throw new Error}if(this._isPrimitive){const t=this.symbolLayer.resource,s=t&&Y(t.primitive)?t.primitive:j;this._resources=await this._createResourcesForPrimitive(s,e)}else{const t=await K(this.symbol.styleOrigin),s=t?.href??this.symbolLayer.resource.href;this._resources=await this._createResourcesForUrl(s,e)}this.layerOpacityChanged(),this.slicePlaneEnabledChanged(),this.physicalBasedRenderingChanged(),this.complexity=this.computeComplexity()}get extentPadding(){return null!=this._resources?this._resources.extentPadding:0}get _isPrimitive(){return!this.symbolLayer.resource?.href}get lodRenderer(){return this._resources?.lodRenderer}_setMaterialTransparencyParams(e,t=this.symbolLayer?.material?.color){const s=this._getCombinedOpacity(t),r=s<1||this.needsDrivenTransparentPass;return e.transparent=r,e.opacity=s,e.cullFace=r?re.None:re.Back,e}async _createResourcesForPrimitive(t,r){const i=this.symbolLayer,a=L(w(t)),o=y(C(a)),n=y(T(o,i)),l=c(n),h=!1,d=!1,m={usePBR:this._context.physicalBasedRenderingEnabled,isSchematic:!0,ambient:_,diffuse:_,hasSlicePlane:this._context.slicePlaneEnabled,hasSliceHighlight:!1,castShadows:this.symbolLayer.castShadows,offsetTransparentBackfaces:!this.symbolLayer.isPrimitive},p=!!m.usePBR;this._setMaterialTransparencyParams(m);const u=this.symbol;if("point-3d"===u.type&&u.verticalOffset){const{screenLength:e,minWorldLength:t,maxWorldLength:r}=u.verticalOffset;m.verticalOffset={screenLength:s(e),minWorldLength:t||0,maxWorldLength:null!=r?r:1/0},m.castShadows=!1}if(this._context.screenSizePerspectiveEnabled&&(m.screenSizePerspective=this._context.sharedResources.screenSizePerspectiveSettings),this._drivenProperties.color)m.externalColor=P;else{const t=null!=i.material?i.material.color:null,s=null!=t?e.toUnitRGBA(t):P;m.externalColor=s}this._fastUpdates=Q(this._context.renderer,this._fastVisualVariableConvertOptions(a,n,o,null)),m.isInstanced=!0,this._fastUpdates?(Object.assign(m,this._fastUpdates.materialParameters),this._optionalFields.push(ie.FEATUREATTRIBUTE)):this._hasPerInstanceColor()&&(m.hasInstancedColor=!0,this._optionalFields.push(ie.COLOR)),has("enable-feature:objectAndLayerId-rendering")&&this._optionalFields.push(ie.OBJECTANDLAYERIDCOLOR);const f=new he(m),g=$(t,f);if(!g)throw new Error(`Unknown object symbol primitive: ${t}`);const b=oe(g).map((e=>({opacity:1,transparent:e.parameters.transparent}))),R=await this._createStageResources(g,p,r),x=await this._createLodRenderer(g,r);return new de(g,x,R,b,o,h,d,a,n,l,p,null)}async _createResourcesForUrl(e,t){const r={materialParamsMixin:{isInstanced:!0,hasSlicePlane:this._context.slicePlaneEnabled,castShadows:this.symbolLayer.castShadows},streamDataRequester:this._context.streamDataRequester,cache:this._context.sharedResources.objectResourceCache};this._fastUpdates=Q(this._context.renderer,this._fastVisualVariableConvertOptions(null,null,null,null)),this._fastUpdates?(Object.assign(r.materialParamsMixin,this._fastUpdates.materialParameters),this._optionalFields.push(ie.FEATUREATTRIBUTE)):this._hasPerInstanceColor()&&(r.materialParamsMixin.hasInstancedColor=!0,this._optionalFields.push(ie.COLOR)),has("enable-feature:objectAndLayerId-rendering")&&this._optionalFields.push(ie.OBJECTANDLAYERIDCOLOR);const i=this.symbol;if("point-3d"===i.type&&i.verticalOffset){const{screenLength:e,minWorldLength:t,maxWorldLength:a}=i.verticalOffset;r.materialParamsMixin.verticalOffset={screenLength:s(e),minWorldLength:t||0,maxWorldLength:null!=a?a:1/0},r.materialParamsMixin.castShadows=!1}r.signal=t,r.usePBR=this._context.physicalBasedRenderingEnabled,r.skipHighLods=this._context.skipHighSymbolLods;const a=r.usePBR,o=await q(e,r),n=o.isEsriSymbolResource,l=o.isWosr,h=W(o.lods);h.levels.sort(((e,t)=>e.minScreenSpaceRadius-t.minScreenSpaceRadius));const d=this._context,m=this.symbolLayer.material,p=this._getExternalColorParameters(m),u=this.symbolLayer?.material?.color,_=this._getCombinedOpacity(u,{hasIntrinsicColor:!0}),f=this.needsDrivenTransparentPass,g=oe(h),b=oe(h).map((e=>({opacity:e.parameters.opacity||1,transparent:e.parameters.transparent})));g.forEach((e=>{const t=e.parameters;e.setParameters(p);const s=t.opacity*_,r=s<1||f||t.transparent;e.setParameters({opacity:s,transparent:r}),d.screenSizePerspectiveEnabled&&e.setParameters({screenSizePerspective:d.sharedResources.screenSizePerspectiveSettings})}));const P=o.referenceBoundingBox,R=y(C(P)),x=y(h.levels[0].pivotOffset),v=y(T(R,this.symbolLayer)),L=c(v),S=this._fastUpdates;X(S,this._context.renderer,this._fastVisualVariableConvertOptions(P,v,R,x))&&g.forEach((e=>e.setParameters(S.materialParameters)));const E=await this._createStageResources(h,a,t),j=await this._createLodRenderer(h,t);return new de(h,j,E,b,R,n,l,P,v,L,a,x)}_addDisposeResource(e){this._disposeResourceHandles.push(e)}async _createStageResources(e,s,r){const i=this._context.stage,a=oe(e);s!==this._context.physicalBasedRenderingEnabled&&this.physicalBasedRenderingChanged(),i.addMany(a),this._addDisposeResource((()=>i.removeMany(a)));const o=ne(e);i.addMany(o),this._addDisposeResource((()=>i.removeMany(o))),await i.load(o,r),t(r);const n=le(e);return i.addMany(n),this._addDisposeResource((()=>i.removeMany(n))),{materials:a,textures:o,geometries:n}}async _createLodRenderer(e,t){const s=this._context.stage,r={layerUid:this._context.layer.uid,graphicUid:e=>this._instanceIndexToGraphicUid.get(e),notifyGraphicGeometryChanged:e=>this._context.notifyGraphicGeometryChanged(this._instanceIndexToGraphicUid.get(e)),notifyGraphicVisibilityChanged:e=>this._context.notifyGraphicVisibilityChanged(this._instanceIndexToGraphicUid.get(e))},i=this._fastUpdates,a=i?{applyTransform:(e,t,s)=>{e.getFeatureAttribute(t,_e),n(s,te(i.materialParameters,_e,s))},scaleFactor:(e,t,s)=>{t.getFeatureAttribute(s,_e),se(e,i.materialParameters,_e)}}:null,o=new ae({symbol:e,optionalFields:this._optionalFields,metadata:r,shaderTransformation:a},this._context.scheduler);return o.slicePlaneEnabled=this._context.slicePlaneEnabled,this._addDisposeResource((()=>{s.removeRenderPlugin(o),o.destroy()})),await s.addRenderPlugin(o.slots,o,t),o}_getExternalColorParameters(t){const s={};return this._drivenProperties.color?s.externalColor=P:null!=t&&null!=t.color?s.externalColor=e.toUnitRGBA(t.color):(s.externalColor=P,s.colorMixMode="ignore"),s}destroy(){super.destroy(),this._cleanupResources()}_cleanupResources(){this._disposeResourceHandles.forEach((e=>e())),this._disposeResourceHandles.length=0,this._resources=null}createGraphics3DGraphic(e){const t=e.graphic;if(!this._validateGeometry(t.geometry))return null;const s=N(t.geometry);if(null==s)return this.logger.warn(`unsupported geometry type for icon symbol: ${t.geometry.type}`),null;const r=this.setGraphicElevationContext(t,new A),i=e.renderingInfo;return this._createAs3DShape(t,s,i,r,t.uid,e.layer.uid)}notifyDestroyGraphicLayer(e){this._instanceIndexToGraphicUid.delete(e.instanceIndex)}graphicLayerToGraphicId(){return 0}layerOpacityChanged(){if(null==this._resources)return;const e=this._drivenProperties.opacity,t=!this._isPrimitive,s=this._resources.stageResources.materials,r=this._resources.originalMaterialParameters;for(let i=0;i<s.length;i++){const a=s[i],o=this.symbolLayer?.material?.color,n=r[i],l=this._getCombinedOpacity(o,{hasIntrinsicColor:t})*n.opacity,c=l<1||e||n.transparent;a.setParameters({opacity:l,transparent:c}),this._isPrimitive&&a.setParameters({cullFace:c?re.None:re.Back})}}layerElevationInfoChanged(e,t){return this.updateGraphics3DGraphicElevationInfo(e,t,O)}slicePlaneEnabledChanged(){if(null==this._resources)return!0;this._resources.lodRenderer.slicePlaneEnabled=this._context.slicePlaneEnabled;for(const e of this._resources.stageResources.materials)e.setParameters({hasSlicePlane:this._context.slicePlaneEnabled});return!0}physicalBasedRenderingChanged(){if(null==this._resources)return!0;const{stageResources:e,isWosr:t}=this._resources;for(const s of e.materials)this._isPrimitive?s.setParameters({usePBR:this._context.physicalBasedRenderingEnabled,isSchematic:!0}):t||s.setParameters({usePBR:this._context.physicalBasedRenderingEnabled,isSchematic:!1});return!1!==this._hasLoadedPBRTextures||!0!==this._context.physicalBasedRenderingEnabled||(this._hasLoadedPBRTextures=!0,!1)}applyRendererDiff(e,t){if(null==this._resources)return k.RecreateSymbol;const{stageResources:{materials:s},lodRenderer:r,resourceBoundingBox:i,symbolSize:a,resourceSize:o,pivotOffset:n}=this._resources;for(const l in e.diff){if("visualVariables"!==l)return k.RecreateSymbol;if(!X(this._fastUpdates,t,this._fastVisualVariableConvertOptions(i,a,o,n)))return k.RecreateSymbol;for(const e of s)e.setParameters(this._fastUpdates.materialParameters);r.notifyShaderTransformationChanged()}return k.FastUpdate}computeComplexity(){if(null==this._resources)return super.computeComplexity();const e=this._resources.lodResources,t=ce(e.levels[0]).reduce(((e,t)=>e+t.indices.get(ie.POSITION).length),0)/3,s=e=>Array.from(e.vertexAttributes.values()).reduce(((e,t)=>e+r(t.data)),0)+Array.from(e.indices.values()).reduce(((e,t)=>e+r(t)),0),i=ne(e).reduce(((e,t)=>e+(t.parameters.encoding&&"image/ktx2"===t.parameters.encoding?t.memoryEstimate:t.memoryEstimate/4)),0)+le(e).reduce(((e,t)=>e+s(t)),0);return{primitivesPerFeature:t,primitivesPerCoordinate:0,drawCallsPerFeature:0,estimated:!1,memory:{...Z(this.symbol,this.symbolLayer),resourceBytes:i}}}_hasLodRenderer(){return null!=this._resources}_createAs3DShape(e,t,s,r,i,a){if(!this._hasLodRenderer()||null==this._resources)return null;const o=this.getFastUpdateAttrValues(e),n=this._context.clippingExtent;if(x(t,pe,this._context.elevationProvider.spatialReference),null!=n&&!S(n,pe))return null;const l=this._requiresTerrainElevation(r),c=this._computeGlobalTransform(t,r,ye,fe),h=this._computeLocalTransform(this._resources,this.symbolLayer,s,ue),d=this._resources.lodRenderer.instanceData,m=d.addInstance();this._instanceIndexToGraphicUid.set(m,i),d.setLocalTransform(m,h,!1),d.setGlobalTransform(m,c),o&&d.setFeatureAttribute(m,o),null==this._fastUpdates&&this._hasPerInstanceColor()&&d.setColor(m,z(s.color,s.opacity,255)),null!=this._context.stage.renderView.objectAndLayerIdRenderHelper&&d.setObjectAndLayerIdColor(m,this._context.stage.renderView.objectAndLayerIdRenderHelper.getObjectAndLayerIdColor({graphicUid:i,layerUid:a}));const p=new G(this,m,U,r);return l&&(p.alignedSampledElevation=fe.sampledElevation),p.needsElevationUpdates=O(r.mode),J(p,t,this._context.elevationProvider),p}_computeGlobalTransform(e,t,s,r){return B(e,this._context.elevationProvider,t,this._context.renderCoordsHelper,r),pe[0]=e.x,pe[1]=e.y,pe[2]=r.z,v(e.spatialReference,pe,s,this._context.renderCoordsHelper.spatialReference),s}_computeLocalTransform(e,t,s,r){return i(r),this._applyObjectRotation(s,!1,r),this._applyObjectRotation(t,!0,r),this._applyObjectScale(e,s,r),this._applyAnchor(e,t,r),r}_applyObjectScale(e,t,s){if(this._fastUpdates?.requiresShaderTransformation)return;const r=this._drivenProperties.size&&t.size?t.size:e.symbolSize,i=M(r,e.symbolSize,e.resourceSize,this._context.renderCoordsHelper.unitInMeters);1===i[0]&&1===i[1]&&1===i[2]||a(s,s,i)}prepareSymbolLayerPatch(e){if("partial"!==e.diff.type)return;const t=e.diff.diff;this._preparePatchTransform(e,t),this._preparePatchColor(e,t)}updateGeometry(e,t){if(null==this._resources)return!0;const s=t&&N(t);if(null==s)return!1;const r=this.getGeometryElevationMode(t);return e.elevationContext.mode===r&&(this._computeGlobalTransform(s,e.elevationContext,ye,fe),this._requiresTerrainElevation(e.elevationContext)&&(e.alignedSampledElevation=fe.sampledElevation),this._resources.lodRenderer.instanceData.setGlobalTransform(e.instanceIndex,ye,!0),J(e,s,this._context.elevationProvider),!0)}_preparePatchTransform(e,t){if(!(t.heading||t.tilt||t.roll||t.width||t.height||t.depth||t.anchor||t.anchorPosition))return;if(null==this._resources)return;const s=(e,t,s)=>(null!=e&&"complete"===e.type?e.newValue:t)??s,r=s(t.heading,this.symbolLayer.heading,0),i=s(t.tilt,this.symbolLayer.tilt,0),a=s(t.roll,this.symbolLayer.roll,0),o=s(t.width,this.symbolLayer.width,void 0),n=s(t.height,this.symbolLayer.height,void 0),l=s(t.depth,this.symbolLayer.depth,void 0),c=s(t.anchor,this.symbolLayer.anchor,void 0),h=s(t.anchorPosition,this.symbolLayer.anchorPosition,void 0);delete t.heading,delete t.tilt,delete t.roll,delete t.width,delete t.height,delete t.depth,delete t.anchor,delete t.anchorPosition;const d={heading:r,tilt:i,roll:a,anchor:c,anchorPosition:h},m=this._resources;this.loadStatus===H.LOADED&&e.symbolLayerStatePatches.push((()=>{m.symbolSize=y(T(m.resourceSize,{width:o,height:n,depth:l,isPrimitive:this.symbolLayer.isPrimitive}))})),e.graphics3DGraphicPatches.push(((e,t)=>{const s=this._computeLocalTransform(m,d,t,ue),r=e.instanceIndex;m.lodRenderer.instanceData.setLocalTransform(r,s,!0)}))}_preparePatchColor(t,s){if(!s.material||"partial"!==s.material.type)return;const r=s.material.diff;if(!r.color||"complete"!==r.color.type||null==r.color.newValue||null==r.color.oldValue)return;const i=r.color.newValue,a=null!=i?e.toUnitRGBA(i):P;delete r.color;const o=this._resources;null!=o&&t.graphics3DGraphicPatches.push((e=>{let t;this._hasPerInstanceColor()?(o.lodRenderer.instanceData.setColor(e.instanceIndex,a),t=this._setMaterialTransparencyParams({},i)):t=this._setMaterialTransparencyParams({externalColor:a},i);for(const s of o.stageResources.materials)s.setParameters(t)}))}_requiresTerrainElevation(e){return"absolute-height"!==e.mode}_applyObjectRotation(e,t,s){if(!this._fastUpdates?.requiresShaderTransformation||!t)return V(e.heading,e.tilt,e.roll,s)}_computeAnchor(e,t,s){const r=b();switch(s.anchor){case"center":d(r,E(e)),h(r,r);break;case"top":{const t=E(e);u(r,-t[0],-t[1],-e[5]);break}case"bottom":{const t=E(e);u(r,-t[0],-t[1],-e[2]);break}case"relative":{const t=E(e),i=C(e),a=s.anchorPosition,o=a?g(a.x,a.y,a.z):f;m(r,i,o),p(r,r,t),h(r,r);break}default:null!=t?h(r,t):d(r,f)}return r}_applyAnchor(e,t,s){if(this._fastUpdates?.requiresShaderTransformation)return;const r=this._computeAnchor(e.resourceBoundingBox,e.pivotOffset,t);r&&o(s,s,r)}_hasPerInstanceColor(){return this._drivenProperties.color||this._drivenProperties.opacity}_fastVisualVariableConvertOptions(e,t,s,r){const i=null!=e?y(C(e)):_,a=null!=e?this._computeAnchor(e,r,this.symbolLayer):f,o=this._context.renderCoordsHelper.unitInMeters,n=M(null!=t?t:void 0,t,s,o),l=g(this.symbolLayer.tilt||0,this.symbolLayer.roll||0,this.symbolLayer.heading||0);return new ee({size:!0,color:!0,rotation:!0,opacity:!1},i,t??_,o,a,n,l)}}const pe=b(),ue=l(),ye=l(),_e=R(),fe=new I;export{me as Graphics3DObjectSymbolLayer};
5
+ import e from"../../../../Color.js";import has from"../../../../core/has.js";import{throwIfAborted as t}from"../../../../core/promiseUtils.js";import{pt2px as s}from"../../../../core/screenUtils.js";import{estimateSize as r}from"../../../../core/typedArrayUtil.js";import{i,k as a,w as o,c as n}from"../../../../chunks/mat4.js";import{c as l}from"../../../../chunks/mat4f64.js";import{l as c,o as h,c as d,C as m,a as p,s as u}from"../../../../chunks/vec3.js";import{g as y,O as f,Z as _,f as g,c as b}from"../../../../chunks/vec3f64.js";import{O as P,c as R}from"../../../../chunks/vec4f64.js";import{projectPointToVector as x,computeTranslationToOriginAndRotation as v}from"../../../../geometry/projection.js";import{create as L,size as C,containsPoint as S,center as E}from"../../../../geometry/support/aaBoundingBox.js";import{defaultPrimitive as j}from"../../../../symbols/support/ObjectSymbol3DLayerResource.js";import{objectSymbolLayerPrimitiveBoundingBox as w,objectSymbolLayerSizeWithResourceSize as T}from"../../../../symbols/support/symbolLayerUtils3D.js";import{perLodInstanceElevationAligner as U}from"./ElevationAligners.js";import{needsElevationUpdates3D as O,evaluateElevationInfoAtPoint as B,SampleElevationInfo as I}from"./elevationAlignmentUtils.js";import{ElevationContext as A}from"./ElevationContext.js";import G from"./Graphics3DLodInstanceGraphicLayer.js";import{Graphics3DSymbolLayer as D}from"./Graphics3DSymbolLayer.js";import{validateSymbolLayerSize as F,mixinColorAndOpacity as z,computeObjectScale as M,computeObjectRotation as V}from"./graphicUtils.js";import{ApplyRendererDiffResult as k}from"./interfaces.js";import{LoadStatus as H}from"./Loadable.js";import{makeLodResources as W}from"./lodResourceUtils.js";import{fetch as q}from"./objectResourceUtils.js";import{placePointOnGeometry as N,extendPointGraphicElevationContext as J}from"./pointUtils.js";import{isValidPrimitive as Y,primitiveLodResources as $}from"./primitiveObjectSymbolUtils.js";import{defaultSymbolLayerMemoryComplexity as Z}from"./symbolComplexity.js";import{getResourceUrlFromSymbolStyle as K}from"./webStyleUtils.js";import{initFastSymbolUpdatesState as Q,updateFastSymbolUpdatesState as X,ConvertOptions as ee,evaluateModelTransform as te,evaluateModelTransformScale as se}from"../support/FastSymbolUpdates.js";import{CullFaceOptions as re}from"../../webgl-engine/lib/basicInterfaces.js";import{VertexAttribute as ie}from"../../webgl-engine/lib/VertexAttribute.js";import{LodRenderer as ae}from"../../webgl-engine/lib/lodRendering/LodRenderer.js";import{materialsFromLodResources as oe,texturesFromLodResources as ne,geometriesFromLodResources as le,geometriesFromLodLevelResources as ce}from"../../webgl-engine/lib/lodRendering/LodResources.js";import{DefaultMaterial as he}from"../../webgl-engine/materials/DefaultMaterial.js";import{defaultSchematicMRRFactors as de}from"../../webgl-engine/materials/pbrUtils.js";class me{constructor(e,t,s,r,i,a,o,n,l,c,h,d){this.lodResources=e,this.lodRenderer=t,this.stageResources=s,this.originalMaterialParameters=r,this.resourceSize=i,this.isEsriSymbolResource=a,this.isWosr=o,this.resourceBoundingBox=n,this.symbolSize=l,this.extentPadding=c,this.physicalBasedRenderingEnabled=h,this.pivotOffset=d}}class pe extends D{getCachedSize(){const[e,t,s]=null!=this._resources?this._resources.symbolSize:[1,1,1];return{width:e,depth:t,height:s}}constructor(e,t,s,r){super(e,t,s,r),this._resources=null,this._optionalFields=new Array,this._instanceIndexToGraphicUid=new Map,this._hasLoadedPBRTextures=!1,this._disposeResourceHandles=new Array,this.skipHighSymbolLodsChanged=!1,this.ensureDrapedStatus(!1),this._hasLoadedPBRTextures=s.physicalBasedRenderingEnabled}async doLoad(e){if(!this._drivenProperties.size){if(F(this.symbolLayer))throw new Error}if(this._isPrimitive){const t=this.symbolLayer.resource,s=t&&Y(t.primitive)?t.primitive:j;this._resources=await this._createResourcesForPrimitive(s,e)}else{const t=await K(this.symbol.styleOrigin),s=t?.href??this.symbolLayer.resource.href;this._resources=await this._createResourcesForUrl(s,e)}this.layerOpacityChanged(),this.slicePlaneEnabledChanged(),this.physicalBasedRenderingChanged(),this.complexity=this.computeComplexity()}get extentPadding(){return null!=this._resources?this._resources.extentPadding:0}get _isPrimitive(){return!this.symbolLayer.resource?.href}get lodRenderer(){return this._resources?.lodRenderer}_setMaterialTransparencyParams(e,t=this.symbolLayer?.material?.color){const s=this._getCombinedOpacity(t),r=s<1||this.needsDrivenTransparentPass;return e.transparent=r,e.opacity=s,e.cullFace=r?re.None:re.Back,e}async _createResourcesForPrimitive(t,r){const i=this.symbolLayer,a=L(w(t)),o=y(C(a)),n=y(T(o,i)),l=c(n),h=!1,d=!1,m={usePBR:this._context.physicalBasedRenderingEnabled,isSchematic:!0,mrrFactors:[...de],ambient:f,diffuse:f,hasSlicePlane:this._context.slicePlaneEnabled,hasSliceHighlight:!1,castShadows:this.symbolLayer.castShadows,offsetTransparentBackfaces:!this.symbolLayer.isPrimitive},p=!!m.usePBR;this._setMaterialTransparencyParams(m);const u=this.symbol;if("point-3d"===u.type&&u.verticalOffset){const{screenLength:e,minWorldLength:t,maxWorldLength:r}=u.verticalOffset;m.verticalOffset={screenLength:s(e),minWorldLength:t||0,maxWorldLength:null!=r?r:1/0},m.castShadows=!1}if(this._context.screenSizePerspectiveEnabled&&(m.screenSizePerspective=this._context.sharedResources.screenSizePerspectiveSettings),this._drivenProperties.color)m.externalColor=P;else{const t=null!=i.material?i.material.color:null,s=null!=t?e.toUnitRGBA(t):P;m.externalColor=s}this._fastUpdates=Q(this._context.renderer,this._fastVisualVariableConvertOptions(a,n,o,null)),m.isInstanced=!0,this._fastUpdates?(Object.assign(m,this._fastUpdates.materialParameters),this._optionalFields.push(ie.FEATUREATTRIBUTE)):this._hasPerInstanceColor()&&(m.hasInstancedColor=!0,this._optionalFields.push(ie.COLOR)),has("enable-feature:objectAndLayerId-rendering")&&this._optionalFields.push(ie.OBJECTANDLAYERIDCOLOR);const _=new he(m),g=$(t,_);if(!g)throw new Error(`Unknown object symbol primitive: ${t}`);const b=oe(g).map((e=>({opacity:1,transparent:e.parameters.transparent}))),R=await this._createStageResources(g,p,r),x=await this._createLodRenderer(g,r);return new me(g,x,R,b,o,h,d,a,n,l,p,null)}async _createResourcesForUrl(e,t){const r={materialParamsMixin:{isInstanced:!0,hasSlicePlane:this._context.slicePlaneEnabled,castShadows:this.symbolLayer.castShadows},streamDataRequester:this._context.streamDataRequester,cache:this._context.sharedResources.objectResourceCache};this._fastUpdates=Q(this._context.renderer,this._fastVisualVariableConvertOptions(null,null,null,null)),this._fastUpdates?(Object.assign(r.materialParamsMixin,this._fastUpdates.materialParameters),this._optionalFields.push(ie.FEATUREATTRIBUTE)):this._hasPerInstanceColor()&&(r.materialParamsMixin.hasInstancedColor=!0,this._optionalFields.push(ie.COLOR)),has("enable-feature:objectAndLayerId-rendering")&&this._optionalFields.push(ie.OBJECTANDLAYERIDCOLOR);const i=this.symbol;if("point-3d"===i.type&&i.verticalOffset){const{screenLength:e,minWorldLength:t,maxWorldLength:a}=i.verticalOffset;r.materialParamsMixin.verticalOffset={screenLength:s(e),minWorldLength:t||0,maxWorldLength:null!=a?a:1/0},r.materialParamsMixin.castShadows=!1}r.signal=t,r.usePBR=this._context.physicalBasedRenderingEnabled,r.skipHighLods=this._context.skipHighSymbolLods;const a=r.usePBR,o=await q(e,r),n=o.isEsriSymbolResource,l=o.isWosr,h=W(o.lods);h.levels.sort(((e,t)=>e.minScreenSpaceRadius-t.minScreenSpaceRadius));const d=this._context,m=this.symbolLayer.material,p=this._getExternalColorParameters(m),u=this.symbolLayer?.material?.color,f=this._getCombinedOpacity(u,{hasIntrinsicColor:!0}),_=this.needsDrivenTransparentPass,g=oe(h),b=oe(h).map((e=>({opacity:e.parameters.opacity||1,transparent:e.parameters.transparent})));g.forEach((e=>{const t=e.parameters;e.setParameters(p);const s=t.opacity*f,r=s<1||_||t.transparent;e.setParameters({opacity:s,transparent:r}),d.screenSizePerspectiveEnabled&&e.setParameters({screenSizePerspective:d.sharedResources.screenSizePerspectiveSettings})}));const P=o.referenceBoundingBox,R=y(C(P)),x=y(h.levels[0].pivotOffset),v=y(T(R,this.symbolLayer)),L=c(v),S=this._fastUpdates;X(S,this._context.renderer,this._fastVisualVariableConvertOptions(P,v,R,x))&&g.forEach((e=>e.setParameters(S.materialParameters)));const E=await this._createStageResources(h,a,t),j=await this._createLodRenderer(h,t);return new me(h,j,E,b,R,n,l,P,v,L,a,x)}_addDisposeResource(e){this._disposeResourceHandles.push(e)}async _createStageResources(e,s,r){const i=this._context.stage,a=oe(e);s!==this._context.physicalBasedRenderingEnabled&&this.physicalBasedRenderingChanged(),i.addMany(a),this._addDisposeResource((()=>i.removeMany(a)));const o=ne(e);i.addMany(o),this._addDisposeResource((()=>i.removeMany(o))),await i.load(o,r),t(r);const n=le(e);return i.addMany(n),this._addDisposeResource((()=>i.removeMany(n))),{materials:a,textures:o,geometries:n}}async _createLodRenderer(e,t){const s=this._context.stage,r={layerUid:this._context.layer.uid,graphicUid:e=>this._instanceIndexToGraphicUid.get(e),notifyGraphicGeometryChanged:e=>this._context.notifyGraphicGeometryChanged(this._instanceIndexToGraphicUid.get(e)),notifyGraphicVisibilityChanged:e=>this._context.notifyGraphicVisibilityChanged(this._instanceIndexToGraphicUid.get(e))},i=this._fastUpdates,a=i?{applyTransform:(e,t,s)=>{e.getFeatureAttribute(t,_e),n(s,te(i.materialParameters,_e,s))},scaleFactor:(e,t,s)=>{t.getFeatureAttribute(s,_e),se(e,i.materialParameters,_e)}}:null,o=new ae({symbol:e,optionalFields:this._optionalFields,metadata:r,shaderTransformation:a},this._context.scheduler);return o.slicePlaneEnabled=this._context.slicePlaneEnabled,this._addDisposeResource((()=>{s.removeRenderPlugin(o),o.destroy()})),await s.addRenderPlugin(o.slots,o,t),o}_getExternalColorParameters(t){const s={};return this._drivenProperties.color?s.externalColor=P:null!=t&&null!=t.color?s.externalColor=e.toUnitRGBA(t.color):(s.externalColor=P,s.colorMixMode="ignore"),s}destroy(){super.destroy(),this._cleanupResources()}_cleanupResources(){this._disposeResourceHandles.forEach((e=>e())),this._disposeResourceHandles.length=0,this._resources=null}createGraphics3DGraphic(e){const t=e.graphic;if(!this._validateGeometry(t.geometry))return null;const s=N(t.geometry);if(null==s)return this.logger.warn(`unsupported geometry type for icon symbol: ${t.geometry.type}`),null;const r=this.setGraphicElevationContext(t,new A),i=e.renderingInfo;return this._createAs3DShape(t,s,i,r,t.uid,e.layer.uid)}notifyDestroyGraphicLayer(e){this._instanceIndexToGraphicUid.delete(e.instanceIndex)}graphicLayerToGraphicId(){return 0}layerOpacityChanged(){if(null==this._resources)return;const e=this._drivenProperties.opacity,t=!this._isPrimitive,s=this._resources.stageResources.materials,r=this._resources.originalMaterialParameters;for(let i=0;i<s.length;i++){const a=s[i],o=this.symbolLayer?.material?.color,n=r[i],l=this._getCombinedOpacity(o,{hasIntrinsicColor:t})*n.opacity,c=l<1||e||n.transparent;a.setParameters({opacity:l,transparent:c}),this._isPrimitive&&a.setParameters({cullFace:c?re.None:re.Back})}}layerElevationInfoChanged(e,t){return this.updateGraphics3DGraphicElevationInfo(e,t,O)}slicePlaneEnabledChanged(){if(null==this._resources)return!0;this._resources.lodRenderer.slicePlaneEnabled=this._context.slicePlaneEnabled;for(const e of this._resources.stageResources.materials)e.setParameters({hasSlicePlane:this._context.slicePlaneEnabled});return!0}physicalBasedRenderingChanged(){if(null==this._resources)return!0;const{stageResources:e,isWosr:t}=this._resources;for(const s of e.materials)this._isPrimitive?s.setParameters({usePBR:this._context.physicalBasedRenderingEnabled,isSchematic:!0}):t||s.setParameters({usePBR:this._context.physicalBasedRenderingEnabled,isSchematic:!1});return!1!==this._hasLoadedPBRTextures||!0!==this._context.physicalBasedRenderingEnabled||(this._hasLoadedPBRTextures=!0,!1)}applyRendererDiff(e,t){if(null==this._resources)return k.RecreateSymbol;const{stageResources:{materials:s},lodRenderer:r,resourceBoundingBox:i,symbolSize:a,resourceSize:o,pivotOffset:n}=this._resources;for(const l in e.diff){if("visualVariables"!==l)return k.RecreateSymbol;if(!X(this._fastUpdates,t,this._fastVisualVariableConvertOptions(i,a,o,n)))return k.RecreateSymbol;for(const e of s)e.setParameters(this._fastUpdates.materialParameters);r.notifyShaderTransformationChanged()}return k.FastUpdate}computeComplexity(){if(null==this._resources)return super.computeComplexity();const e=this._resources.lodResources,t=ce(e.levels[0]).reduce(((e,t)=>e+t.indices.get(ie.POSITION).length),0)/3,s=e=>Array.from(e.vertexAttributes.values()).reduce(((e,t)=>e+r(t.data)),0)+Array.from(e.indices.values()).reduce(((e,t)=>e+r(t)),0),i=ne(e).reduce(((e,t)=>e+(t.parameters.encoding&&"image/ktx2"===t.parameters.encoding?t.memoryEstimate:t.memoryEstimate/4)),0)+le(e).reduce(((e,t)=>e+s(t)),0);return{primitivesPerFeature:t,primitivesPerCoordinate:0,drawCallsPerFeature:0,estimated:!1,memory:{...Z(this.symbol,this.symbolLayer),resourceBytes:i}}}_hasLodRenderer(){return null!=this._resources}_createAs3DShape(e,t,s,r,i,a){if(!this._hasLodRenderer()||null==this._resources)return null;const o=this.getFastUpdateAttrValues(e),n=this._context.clippingExtent;if(x(t,ue,this._context.elevationProvider.spatialReference),null!=n&&!S(n,ue))return null;const l=this._requiresTerrainElevation(r),c=this._computeGlobalTransform(t,r,fe,ge),h=this._computeLocalTransform(this._resources,this.symbolLayer,s,ye),d=this._resources.lodRenderer.instanceData,m=d.addInstance();this._instanceIndexToGraphicUid.set(m,i),d.setLocalTransform(m,h,!1),d.setGlobalTransform(m,c),o&&d.setFeatureAttribute(m,o),null==this._fastUpdates&&this._hasPerInstanceColor()&&d.setColor(m,z(s.color,s.opacity,255)),null!=this._context.stage.renderView.objectAndLayerIdRenderHelper&&d.setObjectAndLayerIdColor(m,this._context.stage.renderView.objectAndLayerIdRenderHelper.getObjectAndLayerIdColor({graphicUid:i,layerUid:a}));const p=new G(this,m,U,r);return l&&(p.alignedSampledElevation=ge.sampledElevation),p.needsElevationUpdates=O(r.mode),J(p,t,this._context.elevationProvider),p}_computeGlobalTransform(e,t,s,r){return B(e,this._context.elevationProvider,t,this._context.renderCoordsHelper,r),ue[0]=e.x,ue[1]=e.y,ue[2]=r.z,v(e.spatialReference,ue,s,this._context.renderCoordsHelper.spatialReference),s}_computeLocalTransform(e,t,s,r){return i(r),this._applyObjectRotation(s,!1,r),this._applyObjectRotation(t,!0,r),this._applyObjectScale(e,s,r),this._applyAnchor(e,t,r),r}_applyObjectScale(e,t,s){if(this._fastUpdates?.requiresShaderTransformation)return;const r=this._drivenProperties.size&&t.size?t.size:e.symbolSize,i=M(r,e.symbolSize,e.resourceSize,this._context.renderCoordsHelper.unitInMeters);1===i[0]&&1===i[1]&&1===i[2]||a(s,s,i)}prepareSymbolLayerPatch(e){if("partial"!==e.diff.type)return;const t=e.diff.diff;this._preparePatchTransform(e,t),this._preparePatchColor(e,t)}updateGeometry(e,t){if(null==this._resources)return!0;const s=t&&N(t);if(null==s)return!1;const r=this.getGeometryElevationMode(t);return e.elevationContext.mode===r&&(this._computeGlobalTransform(s,e.elevationContext,fe,ge),this._requiresTerrainElevation(e.elevationContext)&&(e.alignedSampledElevation=ge.sampledElevation),this._resources.lodRenderer.instanceData.setGlobalTransform(e.instanceIndex,fe,!0),J(e,s,this._context.elevationProvider),!0)}_preparePatchTransform(e,t){if(!(t.heading||t.tilt||t.roll||t.width||t.height||t.depth||t.anchor||t.anchorPosition))return;if(null==this._resources)return;const s=(e,t,s)=>(null!=e&&"complete"===e.type?e.newValue:t)??s,r=s(t.heading,this.symbolLayer.heading,0),i=s(t.tilt,this.symbolLayer.tilt,0),a=s(t.roll,this.symbolLayer.roll,0),o=s(t.width,this.symbolLayer.width,void 0),n=s(t.height,this.symbolLayer.height,void 0),l=s(t.depth,this.symbolLayer.depth,void 0),c=s(t.anchor,this.symbolLayer.anchor,void 0),h=s(t.anchorPosition,this.symbolLayer.anchorPosition,void 0);delete t.heading,delete t.tilt,delete t.roll,delete t.width,delete t.height,delete t.depth,delete t.anchor,delete t.anchorPosition;const d={heading:r,tilt:i,roll:a,anchor:c,anchorPosition:h},m=this._resources;this.loadStatus===H.LOADED&&e.symbolLayerStatePatches.push((()=>{m.symbolSize=y(T(m.resourceSize,{width:o,height:n,depth:l,isPrimitive:this.symbolLayer.isPrimitive}))})),e.graphics3DGraphicPatches.push(((e,t)=>{const s=this._computeLocalTransform(m,d,t,ye),r=e.instanceIndex;m.lodRenderer.instanceData.setLocalTransform(r,s,!0)}))}_preparePatchColor(t,s){if(!s.material||"partial"!==s.material.type)return;const r=s.material.diff;if(!r.color||"complete"!==r.color.type||null==r.color.newValue||null==r.color.oldValue)return;const i=r.color.newValue,a=null!=i?e.toUnitRGBA(i):P;delete r.color;const o=this._resources;null!=o&&t.graphics3DGraphicPatches.push((e=>{let t;this._hasPerInstanceColor()?(o.lodRenderer.instanceData.setColor(e.instanceIndex,a),t=this._setMaterialTransparencyParams({},i)):t=this._setMaterialTransparencyParams({externalColor:a},i);for(const s of o.stageResources.materials)s.setParameters(t)}))}_requiresTerrainElevation(e){return"absolute-height"!==e.mode}_applyObjectRotation(e,t,s){if(!this._fastUpdates?.requiresShaderTransformation||!t)return V(e.heading,e.tilt,e.roll,s)}_computeAnchor(e,t,s){const r=b();switch(s.anchor){case"center":d(r,E(e)),h(r,r);break;case"top":{const t=E(e);u(r,-t[0],-t[1],-e[5]);break}case"bottom":{const t=E(e);u(r,-t[0],-t[1],-e[2]);break}case"relative":{const t=E(e),i=C(e),a=s.anchorPosition,o=a?g(a.x,a.y,a.z):_;m(r,i,o),p(r,r,t),h(r,r);break}default:null!=t?h(r,t):d(r,_)}return r}_applyAnchor(e,t,s){if(this._fastUpdates?.requiresShaderTransformation)return;const r=this._computeAnchor(e.resourceBoundingBox,e.pivotOffset,t);r&&o(s,s,r)}_hasPerInstanceColor(){return this._drivenProperties.color||this._drivenProperties.opacity}_fastVisualVariableConvertOptions(e,t,s,r){const i=null!=e?y(C(e)):f,a=null!=e?this._computeAnchor(e,r,this.symbolLayer):_,o=this._context.renderCoordsHelper.unitInMeters,n=M(null!=t?t:void 0,t,s,o),l=g(this.symbolLayer.tilt||0,this.symbolLayer.roll||0,this.symbolLayer.heading||0);return new ee({size:!0,color:!0,rotation:!0,opacity:!1},i,t??f,o,a,n,l)}}const ue=b(),ye=l(),fe=l(),_e=R(),ge=new I;export{pe as Graphics3DObjectSymbolLayer};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
4
  */
5
- import{adjustStaticAGOUrl as e}from"../../../../core/devEnvironmentUtils.js";import{b as t}from"../../../../chunks/mat3.js";import{c as r}from"../../../../chunks/mat3f64.js";import{a as o}from"../../../../chunks/mat4.js";import{c as s}from"../../../../chunks/mat4f64.js";import{m as n,b as i,D as l,l as u,n as a,h as c}from"../../../../chunks/vec3.js";import{c as m}from"../../../../chunks/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 y}from"../../../../geometry/support/buffer/BufferView.js";import{t as w,a as R,s as M}from"../../../../chunks/vec32.js";import{t as j,s as v}from"../../../../chunks/vec42.js";import{n as B}from"../../../../chunks/vec22.js";import{c as S}from"../../../../chunks/vec33.js";import{c as L}from"../../../../chunks/vec43.js";import{DefaultLoadingContext as A}from"../../glTF/DefaultLoadingContext.js";import{loadGLTF as O}from"../../glTF/loader.js";import{convertPrimitiveToTriangles as I}from"../../glTF/internal/indexUtils.js";import{isEncodedMeshTexture as k}from"../../glTF/internal/resourceUtils.js";import{getTransformMatrix as C}from"../../glTF/internal/TextureTransformUtils.js";import{ProcessedObjectResource as F}from"./ProcessedObjectResource.js";import{load as E,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 D,CullFaceOptions as _}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{COLOR_GAMMA as $}from"../../webgl-engine/materials/DefaultMaterial_COLOR_GAMMA.js";async function z(t,r){const o=K(e(t));if("wosr"===o.fileType){const e=await(r.cache?r.cache.loadWOSR(o.url,r):E(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):O(new A(r.streamDataRequester),o.url,r,r.usePBR)),n=s.model.meta?.ESRI_proxyEllipsoid,i=s.meta.isEsriSymbolResource&&null!=n&&s.meta.uri.includes("/RealisticTrees/");i&&!s.customMeta.esriTreeRendering&&(s.customMeta.esriTreeRendering=!0,ee(s,n));const l=!!r.usePBR,u=s.meta.isEsriSymbolResource?{usePBR:l,isSchematic:!1,treeRendering:i,mrrFactors:[0,1,.2]}:{usePBR:l,isSchematic:!1,treeRendering:!1,mrrFactors:[0,1,.5]},a={...r.materialParamsMixin,treeRendering:i},{engineResources:c,referenceBoundingBox:m}=Q(s,u,a,r.skipHighLods&&null==o.specifiedLodIndex?{skipHighLods:!0}:{skipHighLods:!1,singleLodIndex:o.specifiedLodIndex});return{lods:c,referenceBoundingBox:m,isEsriSymbolResource:s.meta.isEsriSymbolResource,isWosr:!1}}function K(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 Q(e,t,r,o){const s=e.model,n=new Array,i=new Map,l=new Map,u=s.lods.length,a=f();return s.lods.forEach(((e,c)=>{const m=!0===o.skipHighLods&&(u>1&&0===c||u>3&&1===c)||!1===o.skipHighLods&&null!=o.singleLodIndex&&c!==o.singleLodIndex;if(m&&0!==c)return;const f=new F(e.name,e.lodThreshold,[0,0,0]);e.parts.forEach((e=>{const o=m?new W({}):J(s,e,f,t,r,i,l),{geometry:n,vertexCount:u}=X(e,null!=o?o:new W({})),p=n.boundingInfo;null!=p&&0===c&&(d(a,p.bbMin),d(a,p.bbMax)),null!=o&&(f.stageResources.geometries.push(n),f.numberOfVertices+=u)})),m||n.push(f)})),{engineResources:n,referenceBoundingBox:a}}function J(e,t,r,o,s,n,i){const l=t.material+(t.attributes.normal?"_normal":"")+(t.attributes.color?"_color":"")+(t.attributes.texCoord0?"_texCoord0":"")+(t.attributes.tangent?"_tangent":""),u=e.materials.get(t.material),a=null!=t.attributes.texCoord0,c=null!=t.attributes.normal;if(null==u)return null;const m=Z(u.alphaMode);if(!n.has(l)){if(a){const t=(t,r=!1)=>{if(null!=t&&!i.has(t)){const o=e.textures.get(t);if(null!=o){const e=o.data;i.set(t,new H(k(e)?e.data:e,{...o.parameters,preMultiplyAlpha:!k(e)&&r,encoding:k(e)&&null!=e.encoding?e.encoding:void 0}))}}};t(u.textureColor,m!==V.Opaque),t(u.textureNormal),t(u.textureOcclusion),t(u.textureEmissive),t(u.textureMetallicRoughness)}const r=u.color[0]**(1/$),f=u.color[1]**(1/$),d=u.color[2]**(1/$),p=u.emissiveFactor[0]**(1/$),g=u.emissiveFactor[1]**(1/$),x=u.emissiveFactor[2]**(1/$),b=null!=u.textureColor&&a?i.get(u.textureColor):null;n.set(l,new W({...o,transparent:m===V.Blend,customDepthTest:D.Lequal,textureAlphaMode:m,textureAlphaCutoff:u.alphaCutoff,diffuse:[r,f,d],ambient:[r,f,d],opacity:u.opacity,doubleSided:u.doubleSided,doubleSidedType:"winding-order",cullFace:u.doubleSided?_.None:_.Back,hasVertexColors:!!t.attributes.color,hasVertexTangents:!!t.attributes.tangent,normalType:c?P.Attribute:P.ScreenDerivative,castShadows:!0,receiveSSAO:!0,textureId:null!=b?b.id:void 0,colorMixMode:u.colorMixMode,normalTextureId:null!=u.textureNormal&&a?i.get(u.textureNormal).id:void 0,textureAlphaPremultiplied:null!=b&&!!b.parameters.preMultiplyAlpha,occlusionTextureId:null!=u.textureOcclusion&&a?i.get(u.textureOcclusion).id:void 0,emissiveTextureId:null!=u.textureEmissive&&a?i.get(u.textureEmissive).id:void 0,metallicRoughnessTextureId:null!=u.textureMetallicRoughness&&a?i.get(u.textureMetallicRoughness).id:void 0,emissiveFactor:[p,g,x],mrrFactors:[u.metallicFactor,u.roughnessFactor,o.mrrFactors[2]],isSchematic:!1,colorTextureTransformMatrix:C(u.colorTextureTransform),normalTextureTransformMatrix:C(u.normalTextureTransform),occlusionTextureTransformMatrix:C(u.occlusionTextureTransform),emissiveTextureTransformMatrix:C(u.emissiveTextureTransform),metallicRoughnessTextureTransformMatrix:C(u.metallicRoughnessTextureTransform),...s}))}const f=n.get(l);if(r.stageResources.materials.push(f),a){const e=e=>{null!=e&&r.stageResources.textures.push(i.get(e))};e(u.textureColor),e(u.textureNormal),e(u.textureOcclusion),e(u.textureEmissive),e(u.textureMetallicRoughness)}return f}function X(e,r){const o=e.attributes.position.count,s=I(e.indices||o,e.primitiveType),n=p(3*o),{typedBuffer:i,typedBufferStride:l}=e.attributes.position;w(n,i,e.transform,3,l);const u=[[q.POSITION,new U(n,3,!0)]],a=[[q.POSITION,s]];if(null!=e.attributes.normal){const r=p(3*o),{typedBuffer:n,typedBufferStride:i}=e.attributes.normal;t(Y,e.transform),R(r,n,Y,3,i),u.push([q.NORMAL,new U(r,3,!0)]),a.push([q.NORMAL,s])}if(null!=e.attributes.tangent){const r=p(4*o),{typedBuffer:n,typedBufferStride:i}=e.attributes.tangent;t(Y,e.transform),j(r,n,Y,4,i),u.push([q.TANGENT,new U(r,4,!0)]),a.push([q.TANGENT,s])}if(null!=e.attributes.texCoord0){const t=p(2*o),{typedBuffer:r,typedBufferStride:n}=e.attributes.texCoord0;B(t,r,2,n),u.push([q.UV0,new U(t,2,!0)]),a.push([q.UV0,s])}if(null!=e.attributes.color){const t=new Uint8Array(4*o);4===e.attributes.color.elementCount?e.attributes.color instanceof g?v(t,e.attributes.color,255):e.attributes.color instanceof x?L(t,e.attributes.color):e.attributes.color instanceof b&&v(t,e.attributes.color,1/256):(t.fill(255),e.attributes.color instanceof h?M(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 y&&M(t,e.attributes.color,1/256,4)),u.push([q.COLOR,new U(t,4,!0)]),a.push([q.COLOR,s])}return{geometry:new G(r,u,a),vertexCount:o}}const Y=r();function Z(e){switch(e){case"BLEND":return V.Blend;case"MASK":return V.Mask;case"OPAQUE":case null:case void 0:return V.Opaque}}function ee(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(),y=m(),w=new Uint8Array(4*g),R=new Float64Array(3*g),M=o(s(),d.transform);let j=0,v=0;for(let o=0;o<g;o++){p.getVec(o,T),f.getVec(o,b),n(T,T,d.transform),i(y,T,t.center),l(y,y,t.radius);const s=y[2],m=u(y),g=Math.min(.45+.55*m*m,1);l(y,y,t.radius),null!==M&&n(y,y,M),a(y,y),r+1!==e.model.lods.length&&e.model.lods.length>1&&c(y,y,b,s>-1?.2:Math.min(-4*s-3.8,1)),R[j]=y[0],R[j+1]=y[1],R[j+2]=y[2],j+=3,w[v]=255*g,w[v+1]=255*g,w[v+2]=255*g,w[v+3]=255,v+=4}d.attributes.normal=new h(R),d.attributes.color=new x(w)}}}export{z as fetch,Q as gltfToEngineResources,K as parseUrl};
5
+ import{adjustStaticAGOUrl as e}from"../../../../core/devEnvironmentUtils.js";import{b as t}from"../../../../chunks/mat3.js";import{c as r}from"../../../../chunks/mat3f64.js";import{a as o}from"../../../../chunks/mat4.js";import{c as s}from"../../../../chunks/mat4f64.js";import{m as i,b as n,D as l,l as u,n as a,h as c}from"../../../../chunks/vec3.js";import{c as m}from"../../../../chunks/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 y}from"../../../../geometry/support/buffer/BufferView.js";import{t as R,a as w,s as v}from"../../../../chunks/vec32.js";import{t as M,s as j}from"../../../../chunks/vec42.js";import{n as B}from"../../../../chunks/vec22.js";import{c as S}from"../../../../chunks/vec33.js";import{c as F}from"../../../../chunks/vec43.js";import{DefaultLoadingContext as L}from"../../glTF/DefaultLoadingContext.js";import{loadGLTF as O}from"../../glTF/loader.js";import{convertPrimitiveToTriangles as A}from"../../glTF/internal/indexUtils.js";import{isEncodedMeshTexture as I}from"../../glTF/internal/resourceUtils.js";import{getTransformMatrix as k}from"../../glTF/internal/TextureTransformUtils.js";import{ProcessedObjectResource as C}from"./ProcessedObjectResource.js";import{load as E,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 D,CullFaceOptions as _}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{COLOR_GAMMA 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):E(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):O(new L(r.streamDataRequester),o.url,r,r.usePBR)),i=s.model.meta?.ESRI_proxyEllipsoid,n=s.meta.isEsriSymbolResource&&null!=i&&s.meta.uri.includes("/RealisticTrees/");n&&!s.customMeta.esriTreeRendering&&(s.customMeta.esriTreeRendering=!0,se(s,i));const l=!!r.usePBR,u=s.meta.isEsriSymbolResource?{usePBR:l,isSchematic:!1,treeRendering:n,mrrFactors:[...z]}:{usePBR:l,isSchematic:!1,treeRendering:!1,mrrFactors:[...K]},a={...r.materialParamsMixin,treeRendering:n},{engineResources:c,referenceBoundingBox:m}=Z(s,u,a,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,u=s.lods.length,a=f();return s.lods.forEach(((e,c)=>{const m=!0===o.skipHighLods&&(u>1&&0===c||u>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:u}=te(e,null!=o?o:new W({})),p=i.boundingInfo;null!=p&&0===c&&(d(a,p.bbMin),d(a,p.bbMax)),null!=o&&(f.stageResources.geometries.push(i),f.numberOfVertices+=u)})),m||i.push(f)})),{engineResources:i,referenceBoundingBox:a}}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":""),u=e.materials.get(t.material),a=null!=t.attributes.texCoord0,c=null!=t.attributes.normal;if(null==u)return null;const m=oe(u.alphaMode);if(!i.has(l)){if(a){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(I(e)?e.data:e,{...o.parameters,preMultiplyAlpha:!I(e)&&r,encoding:I(e)&&null!=e.encoding?e.encoding:void 0}))}}};t(u.textureColor,m!==V.Opaque),t(u.textureNormal),t(u.textureOcclusion),t(u.textureEmissive),t(u.textureMetallicRoughness)}const r=u.color[0]**(1/$),f=u.color[1]**(1/$),d=u.color[2]**(1/$),p=u.emissiveFactor[0]**(1/$),g=u.emissiveFactor[1]**(1/$),x=u.emissiveFactor[2]**(1/$),b=null!=u.textureColor&&a?n.get(u.textureColor):null,h=Q({normalTexture:u.textureNormal,metallicRoughnessTexture:u.textureMetallicRoughness,metallicFactor:u.metallicFactor,roughnessFactor:u.roughnessFactor,emissiveTexture:u.textureEmissive,emissiveFactor:u.emissiveFactor,occlusionTexture:u.textureOcclusion});i.set(l,new W({...o,transparent:m===V.Blend,customDepthTest:D.Lequal,textureAlphaMode:m,textureAlphaCutoff:u.alphaCutoff,diffuse:[r,f,d],ambient:[r,f,d],opacity:u.opacity,doubleSided:u.doubleSided,doubleSidedType:"winding-order",cullFace:u.doubleSided?_.None:_.Back,hasVertexColors:!!t.attributes.color,hasVertexTangents:!!t.attributes.tangent,normalType:c?P.Attribute:P.ScreenDerivative,castShadows:!0,receiveSSAO:!0,textureId:null!=b?b.id:void 0,colorMixMode:u.colorMixMode,normalTextureId:null!=u.textureNormal&&a?n.get(u.textureNormal).id:void 0,textureAlphaPremultiplied:null!=b&&!!b.parameters.preMultiplyAlpha,occlusionTextureId:null!=u.textureOcclusion&&a?n.get(u.textureOcclusion).id:void 0,emissiveTextureId:null!=u.textureEmissive&&a?n.get(u.textureEmissive).id:void 0,metallicRoughnessTextureId:null!=u.textureMetallicRoughness&&a?n.get(u.textureMetallicRoughness).id:void 0,emissiveFactor:[p,g,x],mrrFactors:h?[...J]:[u.metallicFactor,u.roughnessFactor,o.mrrFactors[2]],isSchematic:h,colorTextureTransformMatrix:k(u.colorTextureTransform),normalTextureTransformMatrix:k(u.normalTextureTransform),occlusionTextureTransformMatrix:k(u.occlusionTextureTransform),emissiveTextureTransformMatrix:k(u.emissiveTextureTransform),metallicRoughnessTextureTransformMatrix:k(u.metallicRoughnessTextureTransform),...s}))}const f=i.get(l);if(r.stageResources.materials.push(f),a){const e=e=>{null!=e&&r.stageResources.textures.push(n.get(e))};e(u.textureColor),e(u.textureNormal),e(u.textureOcclusion),e(u.textureEmissive),e(u.textureMetallicRoughness)}return f}function te(e,r){const o=e.attributes.position.count,s=A(e.indices||o,e.primitiveType),i=p(3*o),{typedBuffer:n,typedBufferStride:l}=e.attributes.position;R(i,n,e.transform,3,l);const u=[[q.POSITION,new U(i,3,!0)]],a=[[q.POSITION,s]];if(null!=e.attributes.normal){const r=p(3*o),{typedBuffer:i,typedBufferStride:n}=e.attributes.normal;t(re,e.transform),w(r,i,re,3,n),u.push([q.NORMAL,new U(r,3,!0)]),a.push([q.NORMAL,s])}if(null!=e.attributes.tangent){const r=p(4*o),{typedBuffer:i,typedBufferStride:n}=e.attributes.tangent;t(re,e.transform),M(r,i,re,4,n),u.push([q.TANGENT,new U(r,4,!0)]),a.push([q.TANGENT,s])}if(null!=e.attributes.texCoord0){const t=p(2*o),{typedBuffer:r,typedBufferStride:i}=e.attributes.texCoord0;B(t,r,2,i),u.push([q.UV0,new U(t,2,!0)]),a.push([q.UV0,s])}if(null!=e.attributes.color){const t=new Uint8Array(4*o);4===e.attributes.color.elementCount?e.attributes.color instanceof g?j(t,e.attributes.color,255):e.attributes.color instanceof x?F(t,e.attributes.color):e.attributes.color instanceof b&&j(t,e.attributes.color,1/256):(t.fill(255),e.attributes.color instanceof h?v(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 y&&v(t,e.attributes.color,1/256,4)),u.push([q.COLOR,new U(t,4,!0)]),a.push([q.COLOR,s])}return{geometry:new G(r,u,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(),y=m(),R=new Uint8Array(4*g),w=new Float64Array(3*g),v=o(s(),d.transform);let M=0,j=0;for(let o=0;o<g;o++){p.getVec(o,T),f.getVec(o,b),i(T,T,d.transform),n(y,T,t.center),l(y,y,t.radius);const s=y[2],m=u(y),g=Math.min(.45+.55*m*m,1);l(y,y,t.radius),null!==v&&i(y,y,v),a(y,y),r+1!==e.model.lods.length&&e.model.lods.length>1&&c(y,y,b,s>-1?.2:Math.min(-4*s-3.8,1)),w[M]=y[0],w[M+1]=y[1],w[M+2]=y[2],M+=3,R[j]=255*g,R[j+1]=255*g,R[j+2]=255*g,R[j+3]=255,j+=4}d.attributes.normal=new h(w),d.attributes.color=new x(R)}}}export{X as fetch,Z as gltfToEngineResources,Y 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.27/esri/copyright.txt for details.
4
4
  */
5
- import l from"../../../../core/Error.js";import{fetchStyle as t,symbolUrlFromStyleItem as s}from"../../../../symbols/support/styleUtils.js";import{getStyleItemFromStyle as e,fetchSymbolFromStyle as n}from"../../../../symbols/support/webStyleSymbolUtils.js";async function r(r){if(null===r||null==r.styleName&&null==r.styleUrl)return null;const o=r.name;if(null==o)throw new l("symbolstyleutils:style-symbol-reference-name-missing","Missing name in style symbol reference");const u={portal:r.portal},i=await t(r,u).catch((()=>null));if(null===i)return null;const m=e(o,i.data);if(m&&!m.formatInfos.some((l=>"gltf_basisu"===l.type)))return null;const a=await n(i,o,u,"webRef",((l,t)=>s(l,t,["gltf_basisu","gltf"]))).catch((()=>null));if(null===a||"point-3d"!==a.type)return null;const y=a.symbolLayers.items[0];return"object"===y.type?y.resource:null}export{r as getResourceUrlFromSymbolStyle};
5
+ import l from"../../../../core/Error.js";import{fetchStyle as t,symbolUrlFromStyleItem as s}from"../../../../symbols/support/styleUtils.js";import{getStyleItemFromStyle as e,fetchSymbolFromStyle as n}from"../../../../symbols/support/webStyleSymbolUtils.js";async function r(r){if(null===r||null==r.styleName&&null==r.styleUrl)return null;const o=r.name;if(null==o)throw new l("symbolstyleutils:style-symbol-reference-name-missing","Missing name in style symbol reference");const u={portal:r.portal},i=await t(r,u).catch((()=>null));if(null===i)return null;const m=e(o,i.data);if(m&&!m.formatInfos?.some((l=>"gltf_basisu"===l.type)))return null;const a=await n(i,o,u,"webRef",((l,t)=>s(l,t,["gltf_basisu","gltf"]))).catch((()=>null));if(null===a||"point-3d"!==a.type)return null;const y=a.symbolLayers.items[0];return"object"===y.type?y.resource:null}export{r as getResourceUrlFromSymbolStyle};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../../../Color.js";import t from"../../../../core/Error.js";import{MIN_PRIORITY as o}from"../../../../core/MemCache.js";import{generateUUID as n}from"../../../../core/uuid.js";import{projectBoundingSphere as r,projectBuffer as s,canProjectWithoutEngine as a,isLoaded as l,load as i}from"../../../../geometry/projection.js";import{newDoubleArray as u}from"../../../../geometry/support/DoubleArray.js";import{k as d}from"../../../../chunks/sphere.js";import{project as c}from"../../../../geometry/support/meshUtils/georeference.js";import{loadImageAsync as m}from"../../../../support/requestUtils.js";import{EncodedMeshTexture as h}from"../../glTF/internal/resourceUtils.js";import{TextureUsage as f,TextureEncoding as p}from"./enums.js";import{hasAdvancedMaterialParameters as g}from"./I3SMaterialUtil.js";import{CullFaceOptions as x}from"../../webgl-engine/lib/basicInterfaces.js";class y{constructor(e,t,o,n){this._id2Meta=new Map,this._oid2Meta=new Map,this._nextMeshNodeId=2,this._uid=e,this._indexSR=t,this._renderSR=o,this._memoryController=n,this._memCache=this._memoryController.newCache(`sl-client-mesh-data-${this._uid}`)}get indexSR(){return this._indexSR}get renderSR(){return this._renderSR}createMeshNodeInfo(e,t){const o="mesh"+this._nextMeshNodeId++,n=e.extent,s=n.spatialReference,a=this._indexSR,l=M(n,e.origin);r(l,s,l,a);return{type:"mesh",id:o,version:S(e),oid:t,mbs:l,componentNodeIds:[],unloadedMesh:e,nodeIndex:null,loadMeshPromise:null}}addMeshNode(e,t){t.nodeIndex=e,this._id2Meta.set(t.id,t),this._oid2Meta.set(t.oid,t)}getMeshNodeIndex(e){const t=this._oid2Meta.get(e);return null==t||"mesh"!==t.type?null:t.nodeIndex}removeNode(e){if(null==e)return;const t=this._id2Meta.get(e);null!=t&&(this._id2Meta.delete(e),"mesh"===t.type&&this._oid2Meta.delete(t.oid))}async loadNodeJSON(e){const o=this._id2Meta.get(e);if(null==o)throw new t(`I3SClientNodeLoader::loadNodeJSON unable to find node ${e}`);switch(o.type){case"mesh":return this._loadMeshNodeJSON(o);case"mesh-component":return this._loadMeshComponentNodeJSON(o);default:throw new t(`I3SClientNodeLoader::loadNodeJSON unable to handle node ${e}`)}}async _loadMeshNodeJSON(e){const t=e.id,o=(await this._getMeshData(e)).loadedMesh;if(null==o.components||0===o.components.length)return{id:t,version:null,mbs:e.mbs,obb:null,sharedResource:null,geometryData:null,attributeData:null,featureData:null,children:null};const n=[],r=o.components;for(let s=0;s<r.length;++s){const o=`${t}-component${s}`,r={type:"mesh-component",id:o,mbs:e.mbs,componentIndex:s,meshNodeInfo:e,textureData:new Map};this._id2Meta.set(r.id,r),e.componentNodeIds.push(o),n.push({id:r.id,href:null,mbs:r.mbs,obb:null})}return{id:t,version:null,mbs:e.mbs,obb:null,sharedResource:null,geometryData:null,attributeData:null,featureData:null,children:n}}updateNodeIndex(e,t,o){if(null==e)return;const n=this._id2Meta.get(e);n&&"mesh"===n.type&&(n.nodeIndex=o)}async _loadMeshComponentNodeJSON(e){return{id:e.id,version:e.meshNodeInfo.version,mbs:e.mbs,obb:null,sharedResource:null,geometryData:null,attributeData:null,featureData:null,children:null,isEmpty:!1}}async loadNodeData(e,o){const n=e.id,r=this._id2Meta.get(n);if(null==r||"mesh-component"!==r.type)throw new t(`Failed to load client node data for node ${e.id} (unexpected node info)`);const a=r.meshNodeInfo,l=await this._getMeshData(a),i=l.loadedMesh,d=a.oid;if(null==i.components)throw new t(`Failed to load client node data for node ${e.id} (unexpected null reference)`);const m=i.components[r.componentIndex],{material:h,requiredTextures:f,textureData:p}=await w(m.material);if(null!=p)for(const t of p)null!=t&&r.textureData.set(t.id,t);const g={params:{material:h},type:"ArrayBufferView"},{vertexSpace:x,origin:y,transform:M}=i,b=y.x,I=y.y,_=y.z??0,T={featureDataPosition:[b,I,_],featureIds:[],geometries:[g]},S={attributeData:{},loadedAttributes:[]};let v=null;if(null==l.projectedVertices){const e=i.vertexAttributes.position;x.isRelative?v=c(i.spatialReference,M,x,e,this._indexSR):(v=u(e.length),s(e,i.spatialReference,0,v,this._indexSR,0,v.length/3));for(let t=0;t<v.length;t+=3)v[t]-=b,v[t+1]-=I,v[t+2]-=_;l.projectedVertices=v,l.usedMemoryInBytes+=8*v.length,this._memCache.updateSize(a.version,l,l.usedMemoryInBytes)}else v=l.projectedVertices;const{geometryBuffer:R,geometryDescriptor:D}=N(v,m.faces,i.vertexAttributes.normal,i.vertexAttributes.uv,i.vertexAttributes.color,d);return{geometryData:T,attributeDataInfo:S,geometryBuffer:R,geometryDescriptor:D,requiredTextures:f,textureData:p}}async loadTextures(e,t,o){const n=e.id,r=this._id2Meta.get(n);if(null==r||"mesh-component"!==r.type)throw new Error(`Failed to load textures for node ${e.id} (unexpected node info)`);const s=[];for(const a of t)s.push(r.textureData.get(a.id)||null);return s}async _getMeshData(e){const t=e.version,n=this._memCache.get(t);if(null==n){if(null!=e.loadMeshPromise)return e.loadMeshPromise;const n=async(n,r)=>{const s=e.unloadedMesh.clone();try{await s.load()}catch(c){r(c)}s.vertexSpace.isRelative||a(s.spatialReference,this._indexSR)||l()||await i();const u=s.memoryUsage,d={loadedMesh:s,projectedVertices:null,usedMemoryInBytes:u};this._memCache.put(t,d,u,o),e.loadMeshPromise=null,n(d)};return e.loadMeshPromise=new Promise(((e,t)=>n(e,t))),e.loadMeshPromise}return n}}function M(e,t){const o=[1,-1],n=[.5*e.width,.5*e.height,e.hasZ?.5*(e.zmax-e.zmin):0],r=e.center;let s=0;if(e.hasZ)for(let a=0;a<2;++a)for(let e=0;e<2;++e)for(let l=0;l<2;++l){const i=r.x+o[a]*n[0]-t.x,u=r.y+o[e]*n[1]-t.y,d=r.z+o[l]*n[2]-t.z;s=Math.max(i*i+u*u+d*d,s)}else for(let a=0;a<2;++a)for(let e=0;e<2;++e){const l=r.x+o[a]*n[0]-t.x,i=r.y+o[e]*n[1]-t.y;s=Math.max(l*l+i*i,s)}return d([t.x,t.y,t.z],Math.sqrt(s))}async function w(t){const o=[],n=[];if(null==t){return{material:{alphaMode:"opaque",alphaCutoff:.1,doubleSided:!0,cullFace:0,normalTextureId:-1,emissiveTextureId:-1,occlusionTextureId:-1,emissiveFactor:[0,0,0],metallicRoughness:{baseColorFactor:[1,1,1,1],baseColorTextureId:-1,metallicRoughnessTextureId:-1,metallicFactor:0,roughnessFactor:.6000000238418579},wrapTextures:!1,hasParametersFromSource:!0},requiredTextures:o,textureData:n}}const r=_(t);"auto"===t.alphaMode&&console.warn('alphaMode "auto" not supported by I3S PBRMaterial - defaulting to "blend".');return{material:{alphaMode:"auto"===t.alphaMode?"blend":t.alphaMode,alphaCutoff:t.alphaCutoff,doubleSided:t.doubleSided,cullFace:t.doubleSided?x.None:x.Back,normalTextureId:await b(t.normalTexture,o,n,f.Normal),emissiveTextureId:r?await b(t.emissiveTexture,o,n,f.Emissive):-1,occlusionTextureId:r?await b(t.occlusionTexture,o,n,f.Occlusion):-1,emissiveFactor:r&&null!=t.emissiveColor?e.toUnitRGB(t.emissiveColor):[0,0,0],metallicRoughness:{baseColorFactor:null!=t.color?e.toUnitRGBA(t.color):[1,1,1,1],baseColorTextureId:await b(t.colorTexture,o,n,f.Color),metallicRoughnessTextureId:r?await b(t.metallicRoughnessTexture,o,n,f.MetallicRoughness):-1,metallicFactor:r?t.metallic:0,roughnessFactor:r?t.roughness:0},wrapTextures:!0,hasParametersFromSource:!g({normalTexture:t.normalTexture,emissiveTexture:r?t.emissiveTexture:null,occlusionTexture:r?t.occlusionTexture:null,metallicRoughnessTexture:r?t.metallicRoughnessTexture:null,metallicFactor:r?t.metallic:null,roughnessFactor:r?t.roughness:null})},requiredTextures:o,textureData:n}}async function b(e,o,n,r){if(null==e)return-1;const s=n.length,a=e.data,l=e.url;if(null!=a){if(a instanceof HTMLImageElement||a instanceof HTMLCanvasElement){const{data:e,downsampled:t}=I(a);return n.push({id:s,usage:r,data:e,encoding:p.PNG,downsampled:t}),o.push({id:s,usage:r,encodings:[{name:void 0,encoding:p.PNG}]}),s}if(a instanceof HTMLVideoElement)return-1;if(a instanceof ImageData)throw new t("ImageData textures not supported yet for client side I3S nodes");if(a instanceof h)throw new t("EncodedMeshTexture textures not supported yet for client side I3S nodes")}else if(null!=l){const e=new Image;e.src=l;const t=await m(e,e.src,!1,void 0),{data:a,downsampled:i}=I(t);return n.push({id:s,usage:r,data:a,encoding:p.PNG,downsampled:i}),o.push({id:s,usage:r,encodings:[{name:void 0,encoding:p.PNG}]}),s}return-1}function I(e){const t=1048576,o=4096,n=2;let r=e.width*e.height;if(r>=o){let o=e.width,s=e.height;do{o=Math.ceil(o/n),s=Math.ceil(s/n),r=o*s}while(r>t);const a=document.createElement("canvas");a.width=o,a.height=s;return a.getContext("2d").drawImage(e,0,0,o,s),{data:a,downsampled:!0}}return{data:e,downsampled:!1}}function _(e){return e.hasOwnProperty("metallicRoughnessTexture")}function N(e,t,o,n,r,s){const a=1,l=t.length/3,i=3*l;let u=0,d=0,c=!1,m=0,h=!1,f=0,p=!1,g=0,x=0,y=0;u+=v,u+=v,d=u,u+=3*i*R,null!=o&&(c=!0,m=u,u+=3*i*R),null!=n&&(h=!0,f=u,u+=2*i*R),null!=r&&(p=!0,g=u,u+=4*i*D),x=u,u+=a*C,y=u,u+=2*a*v;const M=new ArrayBuffer(u),w=new Uint8Array(M);T(w,0,i),T(w,v,a);const b=new Float32Array(M,d),I=null!=o?new Float32Array(M,m):null,_=null!=n?new Float32Array(M,f):null,N=null!=r?new Uint8Array(M,g):null;for(let T=0;T<l;++T){const s=3*T;for(let a=0;a<3;++a){const l=t[s+a],i=3*l,u=9*T+3*a;if(b[u]=e[i],b[u+1]=e[i+1],b[u+2]=e[i+2],null!=I&&(I[u]=o[i],I[u+1]=o[i+1],I[u+2]=o[i+2]),null!=_){const e=2*l,t=6*T+2*a;_[t]=n[e],_[t+1]=n[e+1]}if(null!=N){const e=4*l,t=12*T+4*a;N[t]=r[e],N[t+1]=r[e+1],N[t+2]=r[e+2],N[t+3]=r[e+3]}}}T(w,x,s),T(w,x+v,s/2**32),T(w,y,0),T(w,y+v,l-1);return{geometryBuffer:M,geometryDescriptor:{isDraco:!1,isLegacy:!0,color:p,normal:c,uv0:h,uvRegion:!1,featureIndex:!0}}}function T(e,t,o){e[t]=255&o,e[t+1]=255&o>>8,e[t+2]=255&o>>16,e[t+3]=255&o>>24}function S(e){const t=e.metadata.displaySource?.source;if(null==t||!Array.isArray(t)||!t.length||t[0]instanceof File)return n();const o=t;let r="";for(const n of o)r+=n.makeHash();return r+JSON.stringify(null!=e.transform?e.transform.toJSON():"")}const v=4,R=4,D=1,C=8;export{y as I3SClientNodeLoader,N as createGeometryData};
5
+ import e from"../../../../Color.js";import t from"../../../../core/Error.js";import{MIN_PRIORITY as o}from"../../../../core/MemCache.js";import{generateUUID as n}from"../../../../core/uuid.js";import{projectBoundingSphere as r,projectBuffer as s,canProjectWithoutEngine as a,isLoaded as l,load as i}from"../../../../geometry/projection.js";import{newDoubleArray as u}from"../../../../geometry/support/DoubleArray.js";import{k as d}from"../../../../chunks/sphere.js";import{project as c}from"../../../../geometry/support/meshUtils/georeference.js";import{loadImageAsync as m}from"../../../../support/requestUtils.js";import{EncodedMeshTexture as h}from"../../glTF/internal/resourceUtils.js";import{TextureUsage as f,TextureEncoding as p}from"./enums.js";import{CullFaceOptions as g}from"../../webgl-engine/lib/basicInterfaces.js";import{useSchematicPBR as x}from"../../webgl-engine/materials/pbrUtils.js";class y{constructor(e,t,o,n){this._uid=e,this._indexSR=t,this._renderSR=o,this._id2Meta=new Map,this._oid2Meta=new Map,this._nextMeshNodeId=2,this._memCache=n.newCache(`sl-client-mesh-data-${this._uid}`)}get indexSR(){return this._indexSR}get renderSR(){return this._renderSR}createMeshNodeInfo(e,t){const o="mesh"+this._nextMeshNodeId++,n=e.extent,s=n.spatialReference,a=this._indexSR,l=M(n,e.origin);r(l,s,l,a);return{type:"mesh",id:o,version:_(e),oid:t,mbs:l,componentNodeIds:[],unloadedMesh:e,nodeIndex:null,loadMeshPromise:null}}addMeshNode(e,t){t.nodeIndex=e,this._id2Meta.set(t.id,t),this._oid2Meta.set(t.oid,t)}getMeshNodeIndex(e){const t=this._oid2Meta.get(e);return null==t||"mesh"!==t.type?null:t.nodeIndex}removeNode(e){if(null==e)return;const t=this._id2Meta.get(e);null!=t&&(this._id2Meta.delete(e),"mesh"===t.type&&this._oid2Meta.delete(t.oid))}async loadNodeJSON(e){const o=this._id2Meta.get(e);if(null==o)throw new t(`I3SClientNodeLoader::loadNodeJSON unable to find node ${e}`);switch(o.type){case"mesh":return this._loadMeshNodeJSON(o);case"mesh-component":return this._loadMeshComponentNodeJSON(o);default:throw new t(`I3SClientNodeLoader::loadNodeJSON unable to handle node ${e}`)}}async _loadMeshNodeJSON(e){const t=e.id,o=(await this._getMeshData(e)).loadedMesh;if(null==o.components||0===o.components.length)return{id:t,version:null,mbs:e.mbs,obb:null,sharedResource:null,geometryData:null,attributeData:null,featureData:null,children:null};const n=[],r=o.components;for(let s=0;s<r.length;++s){const o=`${t}-component${s}`,r={type:"mesh-component",id:o,mbs:e.mbs,componentIndex:s,meshNodeInfo:e,textureData:new Map};this._id2Meta.set(r.id,r),e.componentNodeIds.push(o),n.push({id:r.id,href:null,mbs:r.mbs,obb:null})}return{id:t,version:null,mbs:e.mbs,obb:null,sharedResource:null,geometryData:null,attributeData:null,featureData:null,children:n}}updateNodeIndex(e,t,o){if(null==e)return;const n=this._id2Meta.get(e);n&&"mesh"===n.type&&(n.nodeIndex=o)}async _loadMeshComponentNodeJSON(e){return{id:e.id,version:e.meshNodeInfo.version,mbs:e.mbs,obb:null,sharedResource:null,geometryData:null,attributeData:null,featureData:null,children:null,isEmpty:!1}}async loadNodeData(e,o){const n=e.id,r=this._id2Meta.get(n);if(null==r||"mesh-component"!==r.type)throw new t(`Failed to load client node data for node ${e.id} (unexpected node info)`);const a=r.meshNodeInfo,l=await this._getMeshData(a),i=l.loadedMesh,d=a.oid;if(null==i.components)throw new t(`Failed to load client node data for node ${e.id} (unexpected null reference)`);const m=i.components[r.componentIndex],{material:h,requiredTextures:f,textureData:p}=await w(m.material);if(null!=p)for(const t of p)null!=t&&r.textureData.set(t.id,t);const g={params:{material:h},type:"ArrayBufferView"},{vertexSpace:x,origin:y,transform:M}=i,b=y.x,I=y.y,N=y.z??0,T={featureDataPosition:[b,I,N],featureIds:[],geometries:[g]},_={attributeData:{},loadedAttributes:[]};let S=null;if(null==l.projectedVertices){const e=i.vertexAttributes.position;x.isRelative?S=c(i.spatialReference,M,x,e,this._indexSR):(S=u(e.length),s(e,i.spatialReference,0,S,this._indexSR,0,S.length/3));for(let t=0;t<S.length;t+=3)S[t]-=b,S[t+1]-=I,S[t+2]-=N;l.projectedVertices=S,l.usedMemoryInBytes+=8*S.length,this._memCache.updateSize(a.version,l,l.usedMemoryInBytes)}else S=l.projectedVertices;const{geometryBuffer:R,geometryDescriptor:D}=v(S,m.faces,i.vertexAttributes.normal,i.vertexAttributes.uv,i.vertexAttributes.color,d);return{geometryData:T,attributeDataInfo:_,geometryBuffer:R,geometryDescriptor:D,requiredTextures:f,textureData:p}}async loadAttributes(e,t,o){const n=e.numFeatures;for(const{field:{name:r}}of t)new Array(n);return{}}async loadTextures(e,t,o){const n=e.id,r=this._id2Meta.get(n);if(null==r||"mesh-component"!==r.type)throw new Error(`Failed to load textures for node ${e.id} (unexpected node info)`);const s=[];for(const a of t)s.push(r.textureData.get(a.id)||null);return s}async _getMeshData(e){const t=e.version,n=this._memCache.get(t);if(null==n){if(null!=e.loadMeshPromise)return e.loadMeshPromise;const n=async(n,r)=>{const s=e.unloadedMesh.clone();try{await s.load()}catch(c){r(c)}s.vertexSpace.isRelative||a(s.spatialReference,this._indexSR)||l()||await i();const u=s.memoryUsage,d={loadedMesh:s,projectedVertices:null,usedMemoryInBytes:u};this._memCache.put(t,d,u,o),e.loadMeshPromise=null,n(d)};return e.loadMeshPromise=new Promise(((e,t)=>n(e,t))),e.loadMeshPromise}return n}}function M(e,t){const o=[1,-1],n=[.5*e.width,.5*e.height,e.hasZ?.5*(e.zmax-e.zmin):0],r=e.center;let s=0;if(e.hasZ)for(let a=0;a<2;++a)for(let e=0;e<2;++e)for(let l=0;l<2;++l){const i=r.x+o[a]*n[0]-t.x,u=r.y+o[e]*n[1]-t.y,d=r.z+o[l]*n[2]-t.z;s=Math.max(i*i+u*u+d*d,s)}else for(let a=0;a<2;++a)for(let e=0;e<2;++e){const l=r.x+o[a]*n[0]-t.x,i=r.y+o[e]*n[1]-t.y;s=Math.max(l*l+i*i,s)}return d([t.x,t.y,t.z],Math.sqrt(s))}async function w(t){const o=[],n=[];if(null==t){return{material:{alphaMode:"opaque",alphaCutoff:.1,doubleSided:!0,cullFace:0,normalTextureId:-1,emissiveTextureId:-1,occlusionTextureId:-1,emissiveFactor:[0,0,0],metallicRoughness:{baseColorFactor:[1,1,1,1],baseColorTextureId:-1,metallicRoughnessTextureId:-1,metallicFactor:0,roughnessFactor:.6000000238418579},wrapTextures:!1,hasParametersFromSource:!0},requiredTextures:o,textureData:n}}const r=N(t);"auto"===t.alphaMode&&console.warn('alphaMode "auto" not supported by I3S PBRMaterial - defaulting to "blend".');return{material:{alphaMode:"auto"===t.alphaMode?"blend":t.alphaMode,alphaCutoff:t.alphaCutoff,doubleSided:t.doubleSided,cullFace:t.doubleSided?g.None:g.Back,normalTextureId:await b(t.normalTexture,o,n,f.Normal),emissiveTextureId:r?await b(t.emissiveTexture,o,n,f.Emissive):-1,occlusionTextureId:r?await b(t.occlusionTexture,o,n,f.Occlusion):-1,emissiveFactor:r&&null!=t.emissiveColor?e.toUnitRGB(t.emissiveColor):[0,0,0],metallicRoughness:{baseColorFactor:null!=t.color?e.toUnitRGBA(t.color):[1,1,1,1],baseColorTextureId:await b(t.colorTexture,o,n,f.Color),metallicRoughnessTextureId:r?await b(t.metallicRoughnessTexture,o,n,f.MetallicRoughness):-1,metallicFactor:r?t.metallic:0,roughnessFactor:r?t.roughness:0},wrapTextures:!0,hasParametersFromSource:x({normalTexture:t.normalTexture,emissiveTexture:r?t.emissiveTexture:null,emissiveFactor:r?e.toUnitRGBA(t.emissiveColor):null,occlusionTexture:r?t.occlusionTexture:null,metallicRoughnessTexture:r?t.metallicRoughnessTexture:null,metallicFactor:r?t.metallic:null,roughnessFactor:r?t.roughness:null})},requiredTextures:o,textureData:n}}async function b(e,o,n,r){if(null==e)return-1;const s=n.length,a=e.data,l=e.url;if(null!=a){if(a instanceof HTMLImageElement||a instanceof HTMLCanvasElement){const e=I(a);return n.push({id:s,usage:r,data:e,encoding:p.PNG,downsampled:!1}),o.push({id:s,usage:r,encodings:[{name:void 0,encoding:p.PNG}]}),s}if(a instanceof HTMLVideoElement)return-1;if(a instanceof ImageData)throw new t("ImageData textures not supported yet for client side I3S nodes");if(a instanceof h)throw new t("EncodedMeshTexture textures not supported yet for client side I3S nodes")}else if(null!=l){const e=new Image;e.src=l;const t=I(await m(e,e.src,!1,void 0));return n.push({id:s,usage:r,data:t,encoding:p.PNG,downsampled:!1}),o.push({id:s,usage:r,encodings:[{name:void 0,encoding:p.PNG}]}),s}return-1}function I(e){const t=1048576,o=4096,n=2;let r=e.width*e.height;if(r>=o){let o=e.width,s=e.height;do{o=Math.ceil(o/n),s=Math.ceil(s/n),r=o*s}while(r>t);const a=document.createElement("canvas");a.width=o,a.height=s;return a.getContext("2d").drawImage(e,0,0,o,s),a}return e}function N(e){return e.hasOwnProperty("metallicRoughnessTexture")}function v(e,t,o,n,r,s){const a=1,l=t.length/3,i=3*l;let u=0,d=0,c=!1,m=0,h=!1,f=0,p=!1,g=0,x=0,y=0;u+=S,u+=S,d=u,u+=3*i*R,null!=o&&(c=!0,m=u,u+=3*i*R),null!=n&&(h=!0,f=u,u+=2*i*R),null!=r&&(p=!0,g=u,u+=4*i*D),x=u,u+=a*C,y=u,u+=2*a*S;const M=new ArrayBuffer(u),w=new Uint8Array(M);T(w,0,i),T(w,S,a);const b=new Float32Array(M,d),I=null!=o?new Float32Array(M,m):null,N=null!=n?new Float32Array(M,f):null,v=null!=r?new Uint8Array(M,g):null;for(let T=0;T<l;++T){const s=3*T;for(let a=0;a<3;++a){const l=t[s+a],i=3*l,u=9*T+3*a;if(b[u]=e[i],b[u+1]=e[i+1],b[u+2]=e[i+2],null!=I&&(I[u]=o[i],I[u+1]=o[i+1],I[u+2]=o[i+2]),null!=N){const e=2*l,t=6*T+2*a;N[t]=n[e],N[t+1]=n[e+1]}if(null!=v){const e=4*l,t=12*T+4*a;v[t]=r[e],v[t+1]=r[e+1],v[t+2]=r[e+2],v[t+3]=r[e+3]}}}T(w,x,s),T(w,x+S,s/2**32),T(w,y,0),T(w,y+S,l-1);return{geometryBuffer:M,geometryDescriptor:{isDraco:!1,isLegacy:!0,color:p,normal:c,uv0:h,uvRegion:!1,featureIndex:!0}}}function T(e,t,o){e[t]=255&o,e[t+1]=255&o>>8,e[t+2]=255&o>>16,e[t+3]=255&o>>24}function _(e){const t=e.metadata.displaySource?.source;if(null==t||!Array.isArray(t)||!t.length||t[0]instanceof File)return n();const o=t;let r="";for(const n of o)r+=n.makeHash();return r+JSON.stringify(null!=e.transform?e.transform.toJSON():"")}const S=4,R=4,D=1,C=8;export{y as I3SClientNodeLoader,v as createGeometryData};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
4
  */
5
- import has from"../../../../core/has.js";import{clamp as e}from"../../../../core/mathUtils.js";import{TextureEncoding as o,TextureUsage as r}from"./enums.js";import{RenderTexture as a}from"../../webgl-engine/core/material/RenderTexture.js";import{PBRSchematicMRRValues as s}from"../../webgl-engine/core/shaderLibrary/shading/PhysicallyBasedRenderingParameters.glsl.js";import{defaultMaskAlphaCutoff as l}from"../../webgl-engine/core/shaderLibrary/util/AlphaCutoff.js";import{getEllipsoidMode as n}from"../../webgl-engine/core/shaderLibrary/util/EllipsoidMode.js";import{TextureEncodingMimeType as t,CullFaceOptions as i,AlphaDiscardMode as u}from"../../webgl-engine/lib/basicInterfaces.js";import{Texture as c}from"../../webgl-engine/lib/Texture.js";import{TextureWrapMode as m}from"../../../webgl/enums.js";function d(e,o){const a=new Map,l=(e,o)=>{if(null==e)return-1;const r=a.get(e.id);if(r)return r.usage|=o,r.id;const s=a.size;return a.set(e.id,{id:s,usage:o}),s},n=o.pbrMetallicRoughness,t=n&&n.baseColorFactor,u=o.emissiveFactor,c=!D({normalTexture:o.normalTexture,emissiveTexture:o.emissiveTexture,occlusionTexture:o.occlusionTexture,metallicRoughnessTexture:n?.metallicRoughnessTexture,metallicFactor:n?.metallicFactor,roughnessFactor:n?.roughnessFactor}),m=c?s[0]:n?n.metallicFactor:1,d=c?s[1]:n?n.roughnessFactor:1,h="mask"===o.alphaMode?r.Color|r.AlphaMask:r.Color,T={baseColorFactor:t?[t[0],t[1],t[2],t[3]]:[1,1,1,1],baseColorTextureId:l(n&&n.baseColorTexture,h),metallicRoughnessTextureId:l(n&&n.metallicRoughnessTexture,r.MetallicRoughness),metallicFactor:m,roughnessFactor:d},f={alphaMode:o.alphaMode,alphaCutoff:o.alphaCutoff,doubleSided:o.doubleSided,cullFace:"none"===o.cullFace?i.None:"back"===o.cullFace?i.Back:"front"===o.cullFace?i.Front:i.None,normalTextureId:l(o.normalTexture,r.Normal),emissiveTextureId:l(o.emissiveTexture,r.Emissive),occlusionTextureId:l(o.occlusionTexture,r.Occlusion),emissiveFactor:u?[u[0],u[1],u[2]]:[0,0,0],metallicRoughness:T,wrapTextures:!1,hasParametersFromSource:c},x=[];return a.forEach((({usage:o},r)=>{const a=null!=e&&e[r]&&e[r].formats,s=a?g(a.map((({name:e,format:o})=>({name:e,encoding:p[o]})))):[];x.push({id:r,usage:o,encodings:s})})),{material:f,textures:x}}function g(e){return e.sort(((e,o)=>e.encoding-o.encoding))}const p={ktx2:o.KTX2,basis:o.Basis,dds:o.DDS_S3TC,png:o.PNG,jpg:o.JPG,"ktx-etc2":o.KTX_ETC2},h={[t.KTX2_ENCODING]:o.Basis,[t.BASIS_ENCODING]:o.Basis,[t.DDS_ENCODING]:o.DDS_S3TC,"image/png":o.PNG,"image/jpg":o.JPG,"image/jpeg":o.JPG,"image/ktx":o.KTX_ETC2};function T(o){const a=o&&o.materialDefinitions?Object.keys(o.materialDefinitions)[0]:null,s=o&&o.textureDefinitions?Object.keys(o.textureDefinitions)[0]:null,l=a?o.materialDefinitions?.[a]:null,n=s?o.textureDefinitions?.[s]:null,t=f();if(null!=l){const o=l.params;o.diffuse&&(t.metallicRoughness.baseColorFactor=[o.diffuse[0],o.diffuse[1],o.diffuse[2],1]),null!=o.doubleSided&&(t.doubleSided=o.doubleSided,t.cullFace=o.doubleSided?i.None:i.Back),"none"!==o.cullFace&&"front"!==o.cullFace&&"back"!==o.cullFace||(t.cullFace="none"===o.cullFace?i.None:"back"===o.cullFace?i.Back:i.Front),o.transparency&&(t.metallicRoughness.baseColorFactor[3]=e(1-o.transparency,0,1)),(o.useVertexColorAlpha||t.metallicRoughness.baseColorFactor[3]<1)&&(t.alphaMode="blend")}const u=[];if(null!=n){const e=0;!n.wrap||"repeat"!==n.wrap[0]&&"repeat"!==n.wrap[1]||(t.wrapTextures=!0);let o=r.Color;"rgba"===n.channels&&(t.alphaMode="blend",o|=r.AlphaMask);const a=n.images.length-1,s=n.images[a],l=e=>e&&e.split("/").pop(),i=Array.isArray(n.encoding)?g(n.encoding.map(((e,o)=>({name:l(s.href[o]),encoding:h[e]||0})))):[{name:l(s.href),encoding:h[n.encoding]||0}];u.push({id:e,usage:o,encodings:i}),t.metallicRoughness.baseColorTextureId=e}return{material:t,textures:u}}const f=()=>({alphaMode:"opaque",alphaCutoff:l,doubleSided:!0,cullFace:i.None,normalTextureId:-1,emissiveTextureId:-1,occlusionTextureId:-1,emissiveFactor:[0,0,0],metallicRoughness:{baseColorFactor:[.8,.8,.8,1],baseColorTextureId:-1,metallicRoughnessTextureId:-1,metallicFactor:0,roughnessFactor:.6},wrapTextures:!1,hasParametersFromSource:!0});function x(e,o,a,s){if(null==e||null==e.data)return null;const l=e.data,n=s.renderingContext.parameters.maxMaxAnisotropy,t=!e.downsampled&&n>1,i=a||!o.wrapTextures?b:F,u=R(e.encoding),m=e.usage&r.Color?"opaque"===o.alphaMode?3:4:3;return new c(l,{mipmap:t,maxAnisotropy:n,encoding:u,wrap:i,components:m,noUnpackFlip:!0})}const b={s:m.CLAMP_TO_EDGE,t:m.CLAMP_TO_EDGE},F={s:m.REPEAT,t:m.REPEAT};function C(o,s,t,i,c,m){const d=m.rendererTextureUsage,g=e=>M(i,t,e&d),p=s.metallicRoughness.baseColorFactor,h=e(s.metallicRoughness.baseColorFactor[3],0,1);o.baseColor=[p[0],p[1],p[2],h],o.hasParametersFromSource=!!s.hasParametersFromSource,o.usePBR=m.usePBR,o.mrrFactors=[s.metallicRoughness.metallicFactor,s.metallicRoughness.roughnessFactor,s.hasParametersFromSource?.2:.5],o.emissiveFactor=s.emissiveFactor,o.isIntegratedMesh=m.isIntegratedMesh,o.textureAlphaCutoff="mask"===s.alphaMode?s.alphaCutoff:l,o.alphaDiscardMode="opaque"===s.alphaMode?u.Opaque:"mask"===s.alphaMode?u.Mask:u.MaskBlend;const T=[],f=g(r.Color|r.AlphaMask);null!=f&&(o.baseColorTexture=new a(c,f),T.push(o.baseColorTexture.loadPromise));const x=g(r.MetallicRoughness);null!=x&&(o.metallicRoughnessTexture=new a(c,x),T.push(o.metallicRoughnessTexture.loadPromise));const b=g(r.Emissive);null!=b&&(o.emissionTexture=new a(c,b),T.push(o.emissionTexture.loadPromise));const F=g(r.Occlusion);null!=F&&(o.occlusionTexture=new a(c,F),T.push(o.occlusionTexture.loadPromise));const C=g(r.Normal);return null!=C&&(o.normalTexture=new a(c,C),T.push(o.normalTexture.loadPromise)),o.commonMaterialParameters.hasSlicePlane=m.slicePlaneEnabled,o.commonMaterialParameters.doubleSided=s.doubleSided,o.commonMaterialParameters.cullFace=s.cullFace,o.ellipsoidMode=n(m.viewSpatialReference),Promise.all(T)}function P(e){const r=!!e.compressedTextureS3TC,a=!!e.compressedTextureETC,s=has("disable-feature:i3s-basis")?0:o.Basis|o.KTX2,l=o.JPG|o.PNG,n=s|o.DDS_S3TC;return l|(r?n:0)|(a?s:0)}function S(e,o){if(null!=o)return e.find((e=>0!=(e.encoding&o)))}function M(e,o,a){if(null==e||a===r.None)return null;for(let r=0;r<e.length;r++){const s=e[r];if(null!=s&&0!=(s.usage&a)){const e=o[r];return null!=e?e.id:null}}return null}function R(e){switch(e){case o.KTX2:return t.KTX2_ENCODING;case o.Basis:return t.BASIS_ENCODING;case o.DDS_S3TC:return t.DDS_ENCODING;case o.PNG:return"image/png";case o.JPG:return"image/jpeg";case o.KTX_ETC2:return"image/ktx";default:return""}}function D({normalTexture:e,metallicRoughnessTexture:o,metallicFactor:r,roughnessFactor:a,emissiveTexture:s,occlusionTexture:l}){return null!=e||null!=o||null!=s||null!=l||null!=a&&1!==a||null!=r&&1!==r&&0!==r}export{C as configureMaterial,x as createTexture,f as defaultMaterial,d as getMaterialAndTextures,T as getMaterialAndTexturesFromShared,P as getSupportedEncodings,D as hasAdvancedMaterialParameters,S as selectEncoding};
5
+ import has from"../../../../core/has.js";import{clamp as e}from"../../../../core/mathUtils.js";import{TextureEncoding as o,TextureUsage as a}from"./enums.js";import{RenderTexture as r}from"../../webgl-engine/core/material/RenderTexture.js";import{defaultMaskAlphaCutoff as s}from"../../webgl-engine/core/shaderLibrary/util/AlphaCutoff.js";import{getEllipsoidMode as t}from"../../webgl-engine/core/shaderLibrary/util/EllipsoidMode.js";import{TextureEncodingMimeType as l,CullFaceOptions as n,AlphaDiscardMode as i}from"../../webgl-engine/lib/basicInterfaces.js";import{Texture as u}from"../../webgl-engine/lib/Texture.js";import{useSchematicPBR as c,defaultSchematicMRRFactors as m,defaultAdvancedMRRFactors as d}from"../../webgl-engine/materials/pbrUtils.js";import{TextureWrapMode as p}from"../../../webgl/enums.js";function g(e,o){const r=new Map,s=(e,o)=>{if(null==e)return-1;const a=r.get(e.id);if(a)return a.usage|=o,a.id;const s=r.size;return r.set(e.id,{id:s,usage:o}),s},t=o.pbrMetallicRoughness,l=t?.baseColorFactor,i=o.emissiveFactor,u=c({normalTexture:o.normalTexture,emissiveTexture:o.emissiveTexture,emissiveFactor:o.emissiveFactor,occlusionTexture:o.occlusionTexture,metallicRoughnessTexture:t?.metallicRoughnessTexture,metallicFactor:t?.metallicFactor,roughnessFactor:t?.roughnessFactor}),p=u?m[0]:t?.metallicFactor??d[0],g=u?m[1]:t?.roughnessFactor??d[1],T="mask"===o.alphaMode?a.Color|a.AlphaMask:a.Color,x={baseColorFactor:l?[l[0],l[1],l[2],l[3]]:[1,1,1,1],baseColorTextureId:s(t&&t.baseColorTexture,T),metallicRoughnessTextureId:s(t&&t.metallicRoughnessTexture,a.MetallicRoughness),metallicFactor:p,roughnessFactor:g},b={alphaMode:o.alphaMode,alphaCutoff:o.alphaCutoff,doubleSided:o.doubleSided,cullFace:"none"===o.cullFace?n.None:"back"===o.cullFace?n.Back:"front"===o.cullFace?n.Front:n.None,normalTextureId:s(o.normalTexture,a.Normal),emissiveTextureId:s(o.emissiveTexture,a.Emissive),occlusionTextureId:s(o.occlusionTexture,a.Occlusion),emissiveFactor:i?[i[0],i[1],i[2]]:[0,0,0],metallicRoughness:x,wrapTextures:!1,hasParametersFromSource:u},F=[];return r.forEach((({usage:o},a)=>{const r=null!=e&&e[a]&&e[a].formats,s=r?h(r.map((({name:e,format:o})=>({name:e,encoding:f[o]})))):[];F.push({id:a,usage:o,encodings:s})})),{material:b,textures:F}}function h(e){return e.sort(((e,o)=>e.encoding-o.encoding))}const f={ktx2:o.KTX2,basis:o.Basis,dds:o.DDS_S3TC,png:o.PNG,jpg:o.JPG,"ktx-etc2":o.KTX_ETC2},T={[l.KTX2_ENCODING]:o.Basis,[l.BASIS_ENCODING]:o.Basis,[l.DDS_ENCODING]:o.DDS_S3TC,"image/png":o.PNG,"image/jpg":o.JPG,"image/jpeg":o.JPG,"image/ktx":o.KTX_ETC2};function x(o){const r=o&&o.materialDefinitions?Object.keys(o.materialDefinitions)[0]:null,s=o&&o.textureDefinitions?Object.keys(o.textureDefinitions)[0]:null,t=r?o.materialDefinitions?.[r]:null,l=s?o.textureDefinitions?.[s]:null,i=b();if(null!=t){const o=t.params;o.diffuse&&(i.metallicRoughness.baseColorFactor=[o.diffuse[0],o.diffuse[1],o.diffuse[2],1]),null!=o.doubleSided&&(i.doubleSided=o.doubleSided,i.cullFace=o.doubleSided?n.None:n.Back),"none"!==o.cullFace&&"front"!==o.cullFace&&"back"!==o.cullFace||(i.cullFace="none"===o.cullFace?n.None:"back"===o.cullFace?n.Back:n.Front),o.transparency&&(i.metallicRoughness.baseColorFactor[3]=e(1-o.transparency,0,1)),(o.useVertexColorAlpha||i.metallicRoughness.baseColorFactor[3]<1)&&(i.alphaMode="blend")}const u=[];if(null!=l){const e=0;!l.wrap||"repeat"!==l.wrap[0]&&"repeat"!==l.wrap[1]||(i.wrapTextures=!0);let o=a.Color;"rgba"===l.channels&&(i.alphaMode="blend",o|=a.AlphaMask);const r=l.images.length-1,s=l.images[r],t=e=>e&&e.split("/").pop(),n=Array.isArray(l.encoding)?h(l.encoding.map(((e,o)=>({name:t(s.href[o]),encoding:T[e]||0})))):[{name:t(s.href),encoding:T[l.encoding]||0}];u.push({id:e,usage:o,encodings:n}),i.metallicRoughness.baseColorTextureId=e}return{material:i,textures:u}}const b=()=>({alphaMode:"opaque",alphaCutoff:s,doubleSided:!0,cullFace:n.None,normalTextureId:-1,emissiveTextureId:-1,occlusionTextureId:-1,emissiveFactor:[0,0,0],metallicRoughness:{baseColorFactor:[.8,.8,.8,1],baseColorTextureId:-1,metallicRoughnessTextureId:-1,metallicFactor:0,roughnessFactor:.6},wrapTextures:!1,hasParametersFromSource:!0});function F(e,o,r,s){if(null==e||null==e.data)return null;const t=e.data,l=s.renderingContext.parameters.maxMaxAnisotropy,n=!e.downsampled&&l>1,i=r||!o.wrapTextures?C:P,c=w(e.encoding),m=e.usage&a.Color?"opaque"===o.alphaMode?3:4:3;return new u(t,{mipmap:n,maxAnisotropy:l,encoding:c,wrap:i,components:m,noUnpackFlip:!0})}const C={s:p.CLAMP_TO_EDGE,t:p.CLAMP_TO_EDGE},P={s:p.REPEAT,t:p.REPEAT};function S(o,l,n,u,c,p){const g=p.rendererTextureUsage,h=e=>R(u,n,e&g),f=l.metallicRoughness.baseColorFactor,T=e(l.metallicRoughness.baseColorFactor[3],0,1);o.baseColor=[f[0],f[1],f[2],T],o.hasParametersFromSource=!!l.hasParametersFromSource,o.usePBR=p.usePBR,o.mrrFactors=[l.metallicRoughness.metallicFactor,l.metallicRoughness.roughnessFactor,l.hasParametersFromSource?m[2]:d[2]],o.emissiveFactor=l.emissiveFactor,o.isIntegratedMesh=p.isIntegratedMesh,o.textureAlphaCutoff="mask"===l.alphaMode?l.alphaCutoff:s,o.alphaDiscardMode="opaque"===l.alphaMode?i.Opaque:"mask"===l.alphaMode?i.Mask:i.MaskBlend;const x=[],b=h(a.Color|a.AlphaMask);null!=b&&(o.baseColorTexture=new r(c,b),x.push(o.baseColorTexture.loadPromise));const F=h(a.MetallicRoughness);null!=F&&(o.metallicRoughnessTexture=new r(c,F),x.push(o.metallicRoughnessTexture.loadPromise));const C=h(a.Emissive);null!=C&&(o.emissionTexture=new r(c,C),x.push(o.emissionTexture.loadPromise));const P=h(a.Occlusion);null!=P&&(o.occlusionTexture=new r(c,P),x.push(o.occlusionTexture.loadPromise));const S=h(a.Normal);return null!=S&&(o.normalTexture=new r(c,S),x.push(o.normalTexture.loadPromise)),o.commonMaterialParameters.hasSlicePlane=p.slicePlaneEnabled,o.commonMaterialParameters.doubleSided=l.doubleSided,o.commonMaterialParameters.cullFace=l.cullFace,o.ellipsoidMode=t(p.viewSpatialReference),Promise.all(x)}function M(e){const a=!!e.compressedTextureS3TC,r=!!e.compressedTextureETC,s=has("disable-feature:i3s-basis")?0:o.Basis|o.KTX2,t=o.JPG|o.PNG,l=s|o.DDS_S3TC;return t|(a?l:0)|(r?s:0)}function D(e,o){if(null!=o)return e.find((e=>0!=(e.encoding&o)))}function R(e,o,r){if(null==e||r===a.None)return null;for(let a=0;a<e.length;a++){const s=e[a];if(null!=s&&0!=(s.usage&r)){const e=o[a];return null!=e?e.id:null}}return null}function w(e){switch(e){case o.KTX2:return l.KTX2_ENCODING;case o.Basis:return l.BASIS_ENCODING;case o.DDS_S3TC:return l.DDS_ENCODING;case o.PNG:return"image/png";case o.JPG:return"image/jpeg";case o.KTX_ETC2:return"image/ktx";default:return""}}export{S as configureMaterial,F as createTexture,b as defaultMaterial,g as getMaterialAndTextures,x as getMaterialAndTexturesFromShared,M as getSupportedEncodings,D as selectEncoding};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../../chunks/tslib.es6.js";import t from"../../../../request.js";import s from"../../../../core/Accessor.js";import{splitIntoChunks as i}from"../../../../core/arrayUtils.js";import{resultOrAbort as r,result as o}from"../../../../core/asyncUtils.js";import{estimateStringByteSize as n,estimateNumberByteSize as a}from"../../../../core/byteSizeEstimations.js";import d from"../../../../core/Collection.js";import c from"../../../../core/Logger.js";import{destroyMaybe as h,abortMaybe as l}from"../../../../core/maybe.js";import{whenOrAbort as u}from"../../../../core/promiseUtils.js";import{watch as m,initial as g}from"../../../../core/reactiveUtils.js";import{property as y}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/accessorSupport/ensureType.js";import"../../../../core/has.js";import{subclass as p}from"../../../../core/accessorSupport/decorators/subclass.js";import{formatNumber as _}from"../../../../intl/number.js";import{getMaximumQuerySize as b,queryAllJSON as f}from"../../../../layers/support/featureQueryAll.js";import{assetMapFromAssetMapsJSON as O,extractMesh as C}from"../../../../rest/support/meshFeatureSet.js";import{direct3DObjectFeatureLayerDisplayEnabled as j,i3sPatchingEnabled as v,sceneLayerEditingEnabled as I}from"../../../../support/featureFlags.js";import F from"../FeatureLayerView3D.js";let A=class extends s{constructor(e){super(e),this._warnMaximumChangedObjectsExceeded=!1,this._maximumNumberOfEditOVerrides=x,this._original3DOFLDefinitionExpression=null,this._interactiveEditingSessions=new d,this.geometryOverrides=new d,this._clientGeometryCache=new Map,this._associatedLayerView=null,this._attributeChangedObjectIds=new Set,this._geometryChangedObjectIds=new Set,this._pendingFetchChangedObjectIds=null,this._pendingFetchAbortController=new AbortController}initialize(){this._memCache=this.memoryController.newCache(`i3s-attribute-overrides-${this.layer.uid}`),this._pendingFetchChangedObjectIds=this._fetchChangedObjectIds(this._pendingFetchAbortController?.signal),this._pendingFetchChangedObjectIds.then((async()=>{this._pendingFetchAbortController=null,this._pendingFetchChangedObjectIds=null})),this.is3DOFL&&null!=this._associatedLayer&&(j()?this._associatedLayer.load().then((e=>{this.destroyed||(this._original3DOFLDefinitionExpression=e.definitionExpression,this.addHandles(m((()=>this._definitionExpression),(t=>e.definitionExpression=t),g)),this._associatedLayerView=new F({layer:this._associatedLayer,view:this.view}))})):v())}destroy(){this.is3DOFL&&null!=this._associatedLayer&&(j()?null!=this._associatedLayerView&&(this._associatedLayer.definitionExpression=this._original3DOFLDefinitionExpression):v()),this._set("layer",null),this._memCache=h(this._memCache),this._pendingFetchAbortController=l(this._pendingFetchAbortController),this._pendingFetchChangedObjectIds=null}get is3DOFL(){return I()&&null!=this._associatedLayer&&null!=this._associatedLayer.infoFor3D}get sortedGeometryChangedObjectIds(){return this.is3DOFL?[...this._geometryChangedObjectIds].sort(((e,t)=>e-t)):[]}get _associatedLayer(){return null==this.layer?null:this.layer.associatedLayer}get _definitionExpression(){const e=this.sortedGeometryChangedObjectIds;return 0===e.length?"1 = 0":`OBJECTID IN (${e.join(",")})`}get updating(){if(!this.is3DOFL)return!1;if(j()){return!(null!=this._associatedLayerView)||null!=this._associatedLayerView&&this._associatedLayerView.updating}return v(),!1}get isEmpty(){return null==this._pendingFetchChangedObjectIds&&0===this._attributeChangedObjectIds.size&&0===this._geometryChangedObjectIds.size}createInteractiveEditSession(e){this._attributeChangedObjectIds.add(e),this.notifyChange("_attributeChangedObjectIds");const t=I()&&v()&&null!=this.is3DOFL,s=this._clientGeometryCache.get(e),i=this._interactiveEditingSessions,r=new L(e,{rollback:()=>{i.remove(r),t&&s?.mesh&&this.updateGeometry(e,s.mesh)},commit:(s,i)=>{for(const[t,r]of s)this.updateAttributeValue(e,t,r);t&&void 0!==i&&this.updateGeometry(e,i)}});return i.unshift(r),r}async applyAttributeOverrides(e,t,s){if(null==t)return;const{loadedAttributes:i,attributeData:r}=t;if(null==i||0===i.length||null==r)return;if(this._pendingFetchChangedObjectIds&&await u(this._pendingFetchChangedObjectIds,s),0===this._attributeChangedObjectIds.size)return;const o={loadedAttributes:i,attributeData:r},n=this._getOverridesFromCache(e,o,this._attributeChangedObjectIds),{objectIds:a,fieldNames:d}=n;if(0===a.length||0===d.length)return;const c=await this._queryOverridesFromAssociatedLayer(a,d,!1,s);null!=c&&this._processOverridesFromAssociatedLayer(e,c,d,o)}updateGeometry(e,t){this._geometryChangedObjectIds.add(e);const s=this._clientGeometryCache.get(e);if(null!=s&&(this.geometryOverrides.remove(s),this._clientGeometryCache.delete(e)),null!=t){const s={oid:e,mesh:t};this.geometryOverrides.add(s),this._clientGeometryCache.set(e,s)}this.notifyChange("_geometryChangedObjectIds")}updateAttributeValue(e,t,s){this._attributeChangedObjectIds.add(e),this._cacheAttributeValue(e,t,s),this.notifyChange("_attributeChangedObjectIds")}_cacheAttributeValue(e,t,s){this._memCache.put(this._getAttributeCacheKey(e,t),s,this._memCacheAttributeValueSize(s))}_cacheGeometry(e,t){this._memCache.put(this._getGeometryCacheKey(e),t,this._memCacheGeometrySize(t))}_getOverridesFromCache(e,{loadedAttributes:t,attributeData:s},i){const r=new Set,o=new Array;if(this.is3DOFL&&0===Object.keys(s).length)return{objectIds:Array.from(e),fieldNames:t.map((e=>e.name))};for(const a of t)o[a.index]=s[a.name];const n=new Set;for(let a=0;a<e.length;a++){const s=e[a];if(i.has(s))for(const e of t){const t=this._attributeFromCache(s,e.index);void 0===t?(r.add(s),n.add(e.name)):o[e.index][a]=t}}return{objectIds:Array.from(r),fieldNames:Array.from(n)}}_attributeFromCache(e,t){const s=this._fromInteractiveEditingSession(e,t);if(void 0!==s)return s;const i=this._getAttributeCacheKey(e,t);return this._memCache.get(i)}_fromInteractiveEditingSession(e,t){if(null!=this._interactiveEditingSessions)for(const s of this._interactiveEditingSessions){if(s.objectId!==e)continue;const i=s.getAttribute(t);if(void 0!==i)return i}}_getAttributeCacheKey(e,t){return`${e}-${t}`}_getGeometryCacheKey(e){return`${e}-geometry`}async _queryOverridesFromAssociatedLayer(e,t,s,o){if(0===e.length||!1===s&&0===t.length)return null;e=e.sort(((e,t)=>e-t)),this._warnMaximumChangedObjectsExceeded&&(this._warnMaximumChangedObjectsExceeded=!1,this._logMaximumObjectsExceededWarning());const n=this.layer.associatedLayer;if(null==n)return null;const a=s&&this.is3DOFL&&v(),d=[n.objectIdField,...t];a&&null!=n.globalIdField&&d.push(n.globalIdField);const c=n.createQuery();c.where="1=1",c.returnGeometry=s,c.outFields=d,c.cacheHint=!0,c.objectIds=e;const h=b(n),l=e.length>h?i(e,h).map((e=>{const t=c.clone();return t.objectIds=e,r(f(n,t,{signal:o}))})):[r(f(n,c,{signal:o}))],u=await Promise.all(l);if(a&&null!=n.infoFor3D){const e=n.infoFor3D,t=n.spatialReference,s=[];for(const i of u){if(!i.ok)continue;const r=i.value;if(null==r.assetMaps)continue;const o=O(e,r.assetMaps);for(const i of r.features){const n=C(i,r.globalIdFieldName,t,e,o),a=i;null!=n?(a.geometry=n,s.push(a)):a.geometry=null}}return s}return u.reduce(((e,t)=>e.concat(t.ok?t.value.features:[])),[])}_logMaximumObjectsExceededWarning(){let e=`The number of edited objects that are not yet cached in the scene service exceeds the maximum limit. Attribute changes will only be available for the first ${_(this._maximumNumberOfEditOVerrides)} objects. Please consider re-caching the scene service`;const t=this.layer.portalItem;t&&t.loaded?e+=` (${t.portal.url}/home/item.html?id=${t.id}#settings)`:e+=` (${this.layer.parsedUrl.path})`,c.getLogger("esri.views.3d.layers.i3s.I3SOverrides").warn("#queryOverrides()",this.layer.title,`${e}.`)}_processOverridesFromAssociatedLayer(e,t,s,{loadedAttributes:i,attributeData:r}){const o=this._associatedLayer;if(null==o)return;const n=o.objectIdField,a=s.map((t=>(t in r||(r[t]=new Array(e.length)),r[t]))),d=new Map(i.map((e=>[e.name,e.index]))),c=s.map((e=>d.get(e))),h=new Map(Array.from(e,((e,t)=>[e,t])));for(const l of t){const e=l.attributes[n];for(let t=0;t<s.length;t++){const i=c[t],r=h.get(e),o=l.attributes[s[t]];a[t][r]=o,this._cacheAttributeValue(e,i,o)}}}_memCacheAttributeValueSize(e){return"string"==typeof e?n(e):a()}_memCacheGeometrySize(e){return 256}async _fetchChangedObjectIds(e){const s=this.layer;await s.load({signal:e}),this._geometryChangedObjectIds.clear(),this._attributeChangedObjectIds.clear();const{associatedLayer:i}=s;if(null==i||!i.capabilities?.operations?.supportsChangeTracking)return;const r=this._getFetchChangedObjectIdsServerGen();if(null==r)return;const n=i.layerId,a=this.is3DOFL,d={f:"json",returnIdsOnly:!0,layers:`[${n}]`,returnUpdates:!0,returnDeletes:a,returnInserts:a,layerServerGens:JSON.stringify([{id:n,serverGen:r}])};if(a){const e=i.infoFor3D;d.fieldsToCompare=JSON.stringify({fields:[...Object.values(e.transformFieldRoles),e.sourceHashField]})}const c=await o(t(`${i.url}/extractChanges`,{method:"post",query:d,timeout:w,signal:e}));if(c.ok&&1===c.value.data?.edits?.length){const t=c.value.data.edits[0],s=t?.objectIds,r=t?.fieldUpdates,o=s?.adds??[],n=s?.updates??[],a=s?.deletes??[],d=[...o,...n,...a],h=[...o,...r??n,...a],l=Math.min(this._maximumNumberOfEditOVerrides,d.length);l<d.length&&(this._warnMaximumChangedObjectsExceeded=!0);const u=d.sort(((e,t)=>e-t));for(let e=0;e<l;++e){const t=u[e];this._attributeChangedObjectIds.add(t)}for(const e of h)this._geometryChangedObjectIds.add(e);if(this.is3DOFL&&v()&&this._geometryChangedObjectIds.size>0){const t=await this._queryOverridesFromAssociatedLayer(Array.from(this._geometryChangedObjectIds),[],!0,e);if(null!=t)for(const e of t)null!=e.geometry&&this.updateGeometry(e.attributes[i.objectIdField],e.geometry)}}this.notifyChange("_attributeChangedObjectIds"),this.notifyChange("_geometryChangedObjectIds")}_getFetchChangedObjectIdsServerGen(){const e=this.layer;if(null!=e.serviceUpdateTimeStamp&&null!=e.serviceUpdateTimeStamp.lastUpdate)return e.serviceUpdateTimeStamp.lastUpdate;const t=e.associatedLayer;return null!=t&&null!=t.serverGens&&null!=t.serverGens.minServerGen?t.serverGens.minServerGen:null}get test(){const e=Array.from(this._attributeChangedObjectIds),t=this._pendingFetchChangedObjectIds,s=this;return{changedObjectIds:e,pendingFetchChangedObjectIds:t,get maximumNumberOfEditOVerrides(){return s._maximumNumberOfEditOVerrides},set maximumNumberOfEditOVerrides(e){s._maximumNumberOfEditOVerrides=e}}}};e([y({constructOnly:!0})],A.prototype,"view",void 0),e([y({constructOnly:!0})],A.prototype,"layer",void 0),e([y({readOnly:!0})],A.prototype,"is3DOFL",null),e([y()],A.prototype,"_interactiveEditingSessions",void 0),e([y({readOnly:!0})],A.prototype,"sortedGeometryChangedObjectIds",null),e([y({readOnly:!0})],A.prototype,"geometryOverrides",void 0),e([y()],A.prototype,"_clientGeometryCache",void 0),e([y()],A.prototype,"_associatedLayer",null),e([y()],A.prototype,"_associatedLayerView",void 0),e([y({constructOnly:!0})],A.prototype,"memoryController",void 0),e([y()],A.prototype,"_attributeChangedObjectIds",void 0),e([y()],A.prototype,"_geometryChangedObjectIds",void 0),e([y()],A.prototype,"_pendingFetchChangedObjectIds",void 0),e([y()],A.prototype,"_definitionExpression",null),e([y()],A.prototype,"updating",null),e([y()],A.prototype,"isEmpty",null),A=e([p("esri.views.3d.layers.i3s.I3SOverrides")],A);class L{constructor(e,t){this.objectId=e,this._options=t,this._updates=new Map,this._updatedGeometry=void 0,this._state=E.ACTIVE}getAttribute(e){return this._updates.get(e)}setAttribute(e,t){this.isActive&&this._updates.set(e,t)}getGeometry(){return this._updatedGeometry}setGeometry(e){this.isActive&&(this._updatedGeometry=e)}rollback(){this.isActive&&(this._state=E.ROLLED_BACK,this._options.rollback(),this._updatedGeometry=void 0)}commit(){this.isActive&&(this._state=E.COMMITTED,this._options.commit(this._updates,this._updatedGeometry),this._updates.clear(),this._updatedGeometry=void 0)}get isActive(){return this._state===E.ACTIVE}}var E;!function(e){e[e.ACTIVE=0]="ACTIVE",e[e.COMMITTED=1]="COMMITTED",e[e.ROLLED_BACK=2]="ROLLED_BACK"}(E||(E={}));const w=1e4,x=5e4;export{A as I3SOverrides};
5
+ import{_ as e}from"../../../../chunks/tslib.es6.js";import t from"../../../../request.js";import s from"../../../../core/Accessor.js";import{splitIntoChunks as i}from"../../../../core/arrayUtils.js";import{resultOrAbort as r,result as o}from"../../../../core/asyncUtils.js";import{estimateStringByteSize as n,estimateNumberByteSize as a}from"../../../../core/byteSizeEstimations.js";import d from"../../../../core/Collection.js";import c from"../../../../core/Logger.js";import{destroyMaybe as h,abortMaybe as l}from"../../../../core/maybe.js";import{whenOrAbort as u}from"../../../../core/promiseUtils.js";import{watch as m,initial as g}from"../../../../core/reactiveUtils.js";import{property as p}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/accessorSupport/ensureType.js";import"../../../../core/has.js";import{subclass as y}from"../../../../core/accessorSupport/decorators/subclass.js";import{formatNumber as _}from"../../../../intl/number.js";import{getMaximumQuerySize as b,queryAllJSON as f}from"../../../../layers/support/featureQueryAll.js";import{assetMapFromAssetMapsJSON as O,extractMesh as C}from"../../../../rest/support/meshFeatureSet.js";import{direct3DObjectFeatureLayerDisplayEnabled as j,i3sPatchingEnabled as I,sceneLayerEditingEnabled as v}from"../../../../support/featureFlags.js";import F from"../FeatureLayerView3D.js";let A=class extends s{constructor(e){super(e),this._warnMaximumChangedObjectsExceeded=!1,this._maximumNumberOfEditOVerrides=x,this._original3DOFLDefinitionExpression=null,this._interactiveEditingSessions=new d,this.geometryOverrides=new d,this._clientGeometryCache=new Map,this._associatedLayerView=null,this._attributeChangedObjectIds=new Set,this._geometryChangedObjectIds=new Set,this._pendingFetchChangedObjectIds=null,this._pendingFetchAbortController=new AbortController}initialize(){this._memCache=this.memoryController.newCache(`i3s-attribute-overrides-${this.layer.uid}`),this._pendingFetchChangedObjectIds=this._fetchChangedObjectIds(this._pendingFetchAbortController?.signal),this._pendingFetchChangedObjectIds.then((async()=>{this._pendingFetchAbortController=null,this._pendingFetchChangedObjectIds=null})),this.is3DOFL&&null!=this._associatedLayer&&(j()?this._associatedLayer.load().then((e=>{this.destroyed||(this._original3DOFLDefinitionExpression=e.definitionExpression,this.addHandles(m((()=>this._definitionExpression),(t=>e.definitionExpression=t),g)),this._associatedLayerView=new F({layer:this._associatedLayer,view:this.view}))})):I())}destroy(){this.is3DOFL&&null!=this._associatedLayer&&(j()?null!=this._associatedLayerView&&(this._associatedLayer.definitionExpression=this._original3DOFLDefinitionExpression):I()),this._set("layer",null),this._memCache=h(this._memCache),this._pendingFetchAbortController=l(this._pendingFetchAbortController),this._pendingFetchChangedObjectIds=null}get is3DOFL(){return v()&&null!=this._associatedLayer&&null!=this._associatedLayer.infoFor3D}get sortedGeometryChangedObjectIds(){return this.is3DOFL?[...this._geometryChangedObjectIds].sort(((e,t)=>e-t)):[]}get _associatedLayer(){return null==this.layer?null:this.layer.associatedLayer}get _definitionExpression(){const e=this.sortedGeometryChangedObjectIds;return 0===e.length?"1 = 0":`OBJECTID IN (${e.join(",")})`}get updating(){if(!this.is3DOFL)return!1;if(j()){return!(null!=this._associatedLayerView)||null!=this._associatedLayerView&&this._associatedLayerView.updating}return I(),!1}get isEmpty(){return null==this._pendingFetchChangedObjectIds&&0===this._attributeChangedObjectIds.size&&0===this._geometryChangedObjectIds.size}createInteractiveEditSession(e){this._attributeChangedObjectIds.add(e),this.notifyChange("_attributeChangedObjectIds");const t=v()&&I()&&null!=this.is3DOFL,s=this._interactiveEditingSessions,i=new L(e,{rollback:()=>{s.remove(i)},commit:(s,i)=>{for(const[t,r]of s)this.updateAttributeValue(e,t,r);t&&null!=i&&this.updateGeometry(e,i)}});return s.unshift(i),i}async applyAttributeOverrides(e,t,s){if(null==t)return;const{loadedAttributes:i,attributeData:r}=t;if(null==i||0===i.length||null==r)return;if(this._pendingFetchChangedObjectIds&&await u(this._pendingFetchChangedObjectIds,s),0===this._attributeChangedObjectIds.size)return;const o={loadedAttributes:i,attributeData:r},n=this._getOverridesFromCache(e,o,this._attributeChangedObjectIds),{objectIds:a,fieldNames:d}=n;if(0===a.length||0===d.length)return;const c=await this._queryOverridesFromAssociatedLayer(a,d,!1,s);null!=c&&this._processOverridesFromAssociatedLayer(e,c,d,o)}updateGeometry(e,t){this._geometryChangedObjectIds.add(e);const s=this._clientGeometryCache.get(e);if(null!=s&&(this.geometryOverrides.remove(s),this._clientGeometryCache.delete(e)),null!=t){const s={oid:e,mesh:t};this.geometryOverrides.add(s),this._clientGeometryCache.set(e,s)}this.notifyChange("_geometryChangedObjectIds")}updateAttributeValue(e,t,s){this._attributeChangedObjectIds.add(e),this._cacheAttributeValue(e,t,s),this.notifyChange("_attributeChangedObjectIds")}_cacheAttributeValue(e,t,s){this._memCache.put(this._getAttributeCacheKey(e,t),s,this._memCacheAttributeValueSize(s))}_cacheGeometry(e,t){this._memCache.put(this._getGeometryCacheKey(e),t,this._memCacheGeometrySize(t))}_getOverridesFromCache(e,{loadedAttributes:t,attributeData:s},i){const r=new Set,o=new Array;if(this.is3DOFL&&0===Object.keys(s).length)return{objectIds:Array.from(e),fieldNames:t.map((e=>e.name))};for(const a of t)o[a.index]=s[a.name];const n=new Set;for(let a=0;a<e.length;a++){const s=e[a];if(i.has(s))for(const e of t){const t=this._attributeFromCache(s,e.index);void 0===t?(r.add(s),n.add(e.name)):o[e.index][a]=t}}return{objectIds:Array.from(r),fieldNames:Array.from(n)}}_attributeFromCache(e,t){const s=this._fromInteractiveEditingSession(e,t);if(void 0!==s)return s;const i=this._getAttributeCacheKey(e,t);return this._memCache.get(i)}_fromInteractiveEditingSession(e,t){if(null!=this._interactiveEditingSessions)for(const s of this._interactiveEditingSessions){if(s.objectId!==e)continue;const i=s.getAttribute(t);if(void 0!==i)return i}}_getAttributeCacheKey(e,t){return`${e}-${t}`}_getGeometryCacheKey(e){return`${e}-geometry`}async _queryOverridesFromAssociatedLayer(e,t,s,o){if(0===e.length||!1===s&&0===t.length)return null;e=e.sort(((e,t)=>e-t)),this._warnMaximumChangedObjectsExceeded&&(this._warnMaximumChangedObjectsExceeded=!1,this._logMaximumObjectsExceededWarning());const n=this.layer.associatedLayer;if(null==n)return null;const a=s&&this.is3DOFL&&I(),d=[n.objectIdField,...t];a&&null!=n.globalIdField&&d.push(n.globalIdField);const c=n.createQuery();c.where="1=1",c.returnGeometry=s,c.outFields=d,c.cacheHint=!0,c.objectIds=e;const h=b(n),l=e.length>h?i(e,h).map((e=>{const t=c.clone();return t.objectIds=e,r(f(n,t,{signal:o}))})):[r(f(n,c,{signal:o}))],u=await Promise.all(l);if(a&&null!=n.infoFor3D){const e=n.infoFor3D,t=n.spatialReference,s=[];for(const i of u){if(!i.ok)continue;const r=i.value;if(null==r.assetMaps)continue;const o=O(e,r.assetMaps);for(const i of r.features){const n=C(i,r.globalIdFieldName,t,e,o),a=i;null!=n?(a.geometry=n,s.push(a)):a.geometry=null}}return s}return u.reduce(((e,t)=>e.concat(t.ok?t.value.features:[])),[])}_logMaximumObjectsExceededWarning(){let e=`The number of edited objects that are not yet cached in the scene service exceeds the maximum limit. Attribute changes will only be available for the first ${_(this._maximumNumberOfEditOVerrides)} objects. Please consider re-caching the scene service`;const t=this.layer.portalItem;t&&t.loaded?e+=` (${t.portal.url}/home/item.html?id=${t.id}#settings)`:e+=` (${this.layer.parsedUrl.path})`,c.getLogger("esri.views.3d.layers.i3s.I3SOverrides").warn("#queryOverrides()",this.layer.title,`${e}.`)}_processOverridesFromAssociatedLayer(e,t,s,{loadedAttributes:i,attributeData:r}){const o=this._associatedLayer;if(null==o)return;const n=o.objectIdField,a=s.map((t=>(t in r||(r[t]=new Array(e.length)),r[t]))),d=new Map(i.map((e=>[e.name,e.index]))),c=s.map((e=>d.get(e))),h=new Map(Array.from(e,((e,t)=>[e,t])));for(const l of t){const e=l.attributes[n];for(let t=0;t<s.length;t++){const i=c[t],r=h.get(e),o=l.attributes[s[t]];a[t][r]=o,this._cacheAttributeValue(e,i,o)}}}_memCacheAttributeValueSize(e){return"string"==typeof e?n(e):a()}_memCacheGeometrySize(e){return 256}async _fetchChangedObjectIds(e){const s=this.layer;await s.load({signal:e}),this._geometryChangedObjectIds.clear(),this._attributeChangedObjectIds.clear();const{associatedLayer:i}=s;if(null==i||!i.capabilities?.operations?.supportsChangeTracking)return;const r=this._getFetchChangedObjectIdsServerGen();if(null==r)return;const n=i.layerId,a=this.is3DOFL,d={f:"json",returnIdsOnly:!0,layers:`[${n}]`,returnUpdates:!0,returnDeletes:a,returnInserts:a,layerServerGens:JSON.stringify([{id:n,serverGen:r}])};if(a){const e=i.infoFor3D;d.fieldsToCompare=JSON.stringify({fields:[...Object.values(e.transformFieldRoles),e.sourceHashField]})}const c=await o(t(`${i.url}/extractChanges`,{method:"post",query:d,timeout:w,signal:e}));if(c.ok&&1===c.value.data?.edits?.length){const t=c.value.data.edits[0],s=t?.objectIds,r=t?.fieldUpdates,o=s?.adds??[],n=s?.updates??[],d=s?.deletes??[],h=[...o,...n,...d],l=a?[...o,...r??n,...d]:[],u=Math.min(this._maximumNumberOfEditOVerrides,h.length);u<h.length&&(this._warnMaximumChangedObjectsExceeded=!0);const m=h.sort(((e,t)=>e-t));for(let e=0;e<u;++e){const t=m[e];this._attributeChangedObjectIds.add(t)}for(const e of l)this._geometryChangedObjectIds.add(e);if(this.is3DOFL&&I()&&this._geometryChangedObjectIds.size>0){const t=await this._queryOverridesFromAssociatedLayer(Array.from(this._geometryChangedObjectIds),[],!0,e);if(null!=t)for(const e of t)null!=e.geometry&&this.updateGeometry(e.attributes[i.objectIdField],e.geometry)}}this.notifyChange("_attributeChangedObjectIds"),this.notifyChange("_geometryChangedObjectIds")}_getFetchChangedObjectIdsServerGen(){const e=this.layer;if(null!=e.serviceUpdateTimeStamp&&null!=e.serviceUpdateTimeStamp.lastUpdate)return e.serviceUpdateTimeStamp.lastUpdate;const t=e.associatedLayer;return null!=t&&null!=t.serverGens&&null!=t.serverGens.minServerGen?t.serverGens.minServerGen:null}get test(){const e=Array.from(this._attributeChangedObjectIds),t=this._pendingFetchChangedObjectIds,s=this;return{changedObjectIds:e,pendingFetchChangedObjectIds:t,get maximumNumberOfEditOVerrides(){return s._maximumNumberOfEditOVerrides},set maximumNumberOfEditOVerrides(e){s._maximumNumberOfEditOVerrides=e}}}};e([p({constructOnly:!0})],A.prototype,"view",void 0),e([p({constructOnly:!0})],A.prototype,"layer",void 0),e([p({readOnly:!0})],A.prototype,"is3DOFL",null),e([p()],A.prototype,"_interactiveEditingSessions",void 0),e([p({readOnly:!0})],A.prototype,"sortedGeometryChangedObjectIds",null),e([p({readOnly:!0})],A.prototype,"geometryOverrides",void 0),e([p()],A.prototype,"_clientGeometryCache",void 0),e([p()],A.prototype,"_associatedLayer",null),e([p()],A.prototype,"_associatedLayerView",void 0),e([p({constructOnly:!0})],A.prototype,"memoryController",void 0),e([p()],A.prototype,"_attributeChangedObjectIds",void 0),e([p()],A.prototype,"_geometryChangedObjectIds",void 0),e([p()],A.prototype,"_pendingFetchChangedObjectIds",void 0),e([p()],A.prototype,"_definitionExpression",null),e([p()],A.prototype,"updating",null),e([p()],A.prototype,"isEmpty",null),A=e([y("esri.views.3d.layers.i3s.I3SOverrides")],A);class L{constructor(e,t){this.objectId=e,this._options=t,this._updates=new Map,this._updatedGeometry=void 0,this._state=E.ACTIVE}getAttribute(e){return this._updates.get(e)}setAttribute(e,t){this.isActive&&this._updates.set(e,t)}getGeometry(){return this._updatedGeometry}setGeometry(e){this.isActive&&(this._updatedGeometry=e)}rollback(){this.isActive&&(this._state=E.ROLLED_BACK,this._options.rollback(),this._updatedGeometry=void 0)}commit(){this.isActive&&(this._state=E.COMMITTED,this._options.commit(this._updates,this._updatedGeometry),this._updates.clear(),this._updatedGeometry=void 0)}get isActive(){return this._state===E.ACTIVE}}var E;!function(e){e[e.ACTIVE=0]="ACTIVE",e[e.COMMITTED=1]="COMMITTED",e[e.ROLLED_BACK=2]="ROLLED_BACK"}(E||(E={}));const w=1e4,x=5e4;export{A as I3SOverrides};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../../../../chunks/tslib.es6.js";import{releaseMaybe as t}from"../../../../../../core/maybe.js";import{e as r,t as s}from"../../../../../../chunks/mat3.js";import{a as o}from"../../../../../../chunks/mat3f32.js";import{b as a}from"../../../../../../chunks/mat3f64.js";import{G as i}from"../../../../../../chunks/vec3.js";import{f as l}from"../../../../../../chunks/vec3f64.js";import{v as n}from"../../../../../../chunks/vec4.js";import{f as u}from"../../../../../../chunks/vec4f64.js";import{ColorMixModeEnum as h}from"../../../../layers/support/symbolColorUtils.js";import{OverlayIndex as p,RenderTargetType as c}from"../../../../terrain/interfaces.js";import{ComponentTechnique as d}from"./ComponentTechnique.js";import{ComponentTechniqueConfiguration as m,IntegratedMeshMode as g}from"./ComponentTechniqueConfiguration.js";import{ComponentDataType as y}from"./shader/ComponentData.glsl.js";import{g as T}from"../../../../../../chunks/ComponentShader.glsl.js";import{VertexDiscardMode as x}from"./shader/VertexDiscardByOpacity.glsl.js";import{MaterialBase as f,parameter as v,parameterBlock as b,MaterialParameterBlock as M}from"../../../core/material/MaterialBase.js";import{RenderPassIdentifier as O}from"../../../core/renderPasses/AllRenderPasses.js";import{ShaderOutput as C}from"../../../core/shaderLibrary/ShaderOutput.js";import{NormalType as w}from"../../../core/shaderLibrary/attributes/NormalAttribute.glsl.js";import{NormalsDoubleSidedMode as S}from"../../../core/shaderLibrary/shading/Normals.glsl.js";import{PBRMode as P}from"../../../core/shaderLibrary/shading/PhysicallyBasedRenderingParameters.glsl.js";import{defaultMaskAlphaCutoff as j}from"../../../core/shaderLibrary/util/AlphaCutoff.js";import{EllipsoidMode as N}from"../../../core/shaderLibrary/util/EllipsoidMode.js";import{TwoVectorPosition as q}from"../../../core/util/TwoVectorPosition.js";import{AlphaDiscardMode as A,CullFaceOptions as D}from"../../../lib/basicInterfaces.js";import{TransparencyPassType as R}from"../../../lib/TransparencyPassType.js";class I extends f{constructor(e,t){super(),this.toMapSpace=t,this.baseColor=u(1,1,1,1),this.usePBR=!1,this.hasParametersFromSource=!1,this.mrrFactors=l(1,1,.5),this.emissiveFactor=l(0,0,0),this.baseColorTexture=null,this.metallicRoughnessTexture=null,this.emissionTexture=null,this.occlusionTexture=null,this.normalTexture=null,this.objectOpacity=1,this.commonMaterialParameters=new _,this.componentParameters=new W,this.textureAlphaCutoff=j,this.alphaDiscardMode=A.Opaque,this.isIntegratedMesh=!1,this.polygonOffsetEnabled=!1,this.ellipsoidMode=N.Earth,this.hasOccludees=!1,this._techniqueConfiguration=new m;const i=new q(e.position),n=o(e.rotationScale);r(n,n),this.transformNormalGlobalFromModel=a(s(n,n)),this.transformWorldFromModelTL=i.low,this.transformWorldFromModelTH=i.high,this.transformWorldFromModelRS=e.rotationScale}dispose(){this._technique=t(this._technique),this.baseColorTexture=null,this.metallicRoughnessTexture=null,this.emissionTexture=null,this.occlusionTexture=null,this.normalTexture=null}get texture(){return null!=this.baseColorTexture?this.baseColorTexture.glTexture:null}get textureMetallicRoughness(){return null!=this.metallicRoughnessTexture?this.metallicRoughnessTexture.glTexture:null}get textureEmissive(){return null!=this.emissionTexture?this.emissionTexture.glTexture:null}get textureOcclusion(){return null!=this.occlusionTexture?this.occlusionTexture.glTexture:null}get textureNormal(){return null!=this.normalTexture?this.normalTexture.glTexture:null}prepareTechnique(e,t,r,s){const o=this._techniqueConfiguration;o.hasVertexColors=s.colors,o.hasNormals=s.normals,o.textureCoordinateType=s.textureCoordinates,o.hasMetallicRoughnessTexture=null!=this.metallicRoughnessTexture,o.hasEmissionTexture=null!=this.emissionTexture,o.hasOcclusionTexture=null!=this.occlusionTexture,o.hasNormalTexture=null!=this.normalTexture,o.transparencyPassType=t.identifier===O.Material&&null!=r.transparencyPassType?r.transparencyPassType:R.NONE,o.hasMultipassTerrain=t.identifier===O.Material&&null!=r.multipassTerrain&&r.multipassTerrain.enabled,o.cullAboveGround=t.identifier===O.Material&&null!=r.multipassTerrain&&r.multipassTerrain.cullAboveGround,o.ellipsoidMode=this.ellipsoidMode,o.componentData=this.componentParameters.type,o.cullFace=this.commonMaterialParameters.cullFace,o.doubleSidedMode=this.commonMaterialParameters.doubleSided?S.View:S.None,o.hasBaseColorTexture=null!=this.baseColorTexture;const a=this._computeWhichMaterialPass();o.blendingEnabled=a===k.Transparent||a===k.OpaqueAndTransparent,o.alphaDiscardMode=this.alphaDiscardMode,o.integratedMeshMode=this.isIntegratedMesh?L(r)?T(r)?g.ColorOverlayWithWater:g.ColorOverlay:g.NoOverlay:g.None,o.hasPolygonOffset=this.polygonOffsetEnabled;const i=this.hasParametersFromSource&&null==this.baseColorTexture;if(o.pbrMode=o.integratedMeshMode===g.ColorOverlayWithWater?P.WaterOnIntegratedMesh:this.usePBR?i?P.Schematic:P.Normal:P.Disabled,o.normalType=o.integratedMeshMode===g.None?o.hasNormals?w.Compressed:w.ScreenDerivative:w.Ground,o.hasSlicePlane=null!=r.slicePlane&&this.commonMaterialParameters.hasSlicePlane,t.identifier===O.ShadowMap)o.output=C.Shadow,o.vertexDiscardMode=x.None;else if(t.identifier===O.Highlight)o.output=C.Highlight,o.vertexDiscardMode=x.None;else{switch(this._computeWhichMaterialPass()===k.OpaqueAndTransparent?o.vertexDiscardMode=t.transparent?x.Opaque:x.Transparent:o.vertexDiscardMode=x.None,o.output=t.output,o.receiveAmbientOcclusion=!1,o.receiveShadows=!1,t.output){case C.Color:o.receiveAmbientOcclusion=r.ssaoHelper.active,o.hasOccludees=r.hasOccludees,o.receiveShadows=r.shadowMap.ready,o.hasScreenSpaceReflections=r.ssr.enabled,o.hasCloudsReflections=null!=r.cloudsFade.data;break;case C.Alpha:o.hasOccludees=r.hasOccludees;break;case C.ObjectAndLayerIdColor:o.objectAndLayerIdColor=!0}o.snowCover=this.hasSnowCover(r)}return this._technique=e.releaseAndAcquire(d,o,this._technique),this._setClean(),this._technique}hasSnowCover(e){return null!=e.weather&&e.weatherVisible&&"snowy"===e.weather.type&&"enabled"===e.weather.snowCover}submit(e,t,r){if(0===this.objectOpacity)return;const s=r.renderable.geometry,o=r.components,a=r.renderable.meta.cameraDepthSquared,i=o.geometryRanges,l=o.highlightRanges,n=o.defaultShadowMapRanges;switch(this._computeWhichMaterialPass()){case k.Opaque:e.materialOpaque.submitDraw(this,s,i,a);break;case k.Transparent:e.materialTransparent.submitDraw(this,s,i,a);break;case k.OpaqueAndTransparent:e.materialOpaque.submitDraw(this,s,i,a),e.materialTransparent.submitDraw(this,s,i,a);break;case k.IntegratedMesh:e.materialIntegratedMesh.submitDraw(this,s,i,a),B(t)&&e.highlightIntegratedMesh.submitDraw(this,s,i,a)}const u=this.componentParameters.castShadows!==F.None;u&&e.shadowMap.submitDraw(this,s,i,a),null!=l&&(e.highlight.submitDraw(this,s,l,a),u&&e.highlightShadowMap.submitDraw(this,s,l,a)),u&&null!=n&&e.defaultShadowMap.submitDraw(this,s,n,a)}_computeWhichMaterialPass(){return this.isIntegratedMesh?k.IntegratedMesh:this.objectOpacity<1?k.Transparent:this.componentParameters.opaqueOverride===F.All?k.Opaque:this.baseColor[3]<1||this.alphaDiscardMode===A.Blend||this.alphaDiscardMode===A.MaskBlend?k.Transparent:this.componentParameters.transparent===F.None?k.Opaque:this.componentParameters.transparent===F.All?k.Transparent:k.OpaqueAndTransparent}}var k,F;e([v({vectorOps:n})],I.prototype,"baseColor",void 0),e([v()],I.prototype,"usePBR",void 0),e([v()],I.prototype,"hasParametersFromSource",void 0),e([v({vectorOps:i})],I.prototype,"mrrFactors",void 0),e([v({vectorOps:i})],I.prototype,"emissiveFactor",void 0),e([v({dispose:!0})],I.prototype,"baseColorTexture",void 0),e([v({dispose:!0})],I.prototype,"metallicRoughnessTexture",void 0),e([v({dispose:!0})],I.prototype,"emissionTexture",void 0),e([v({dispose:!0})],I.prototype,"occlusionTexture",void 0),e([v({dispose:!0})],I.prototype,"normalTexture",void 0),e([v()],I.prototype,"objectOpacity",void 0),e([b()],I.prototype,"commonMaterialParameters",void 0),e([b()],I.prototype,"componentParameters",void 0),e([v()],I.prototype,"textureAlphaCutoff",void 0),e([v()],I.prototype,"alphaDiscardMode",void 0),e([v()],I.prototype,"isIntegratedMesh",void 0),e([v()],I.prototype,"polygonOffsetEnabled",void 0),e([v()],I.prototype,"ellipsoidMode",void 0),e([v()],I.prototype,"hasOccludees",void 0),function(e){e[e.Opaque=0]="Opaque",e[e.Transparent=1]="Transparent",e[e.OpaqueAndTransparent=2]="OpaqueAndTransparent",e[e.IntegratedMesh=3]="IntegratedMesh"}(k||(k={}));class _ extends M{constructor(){super(...arguments),this.doubleSided=!1,this.cullFace=D.Back,this.hasSlicePlane=!0}}e([v()],_.prototype,"doubleSided",void 0),e([v()],_.prototype,"cullFace",void 0),e([v()],_.prototype,"hasSlicePlane",void 0);class W extends M{constructor(){super(...arguments),this.externalColor=u(1,1,1,1),this.externalColorMixMode=h.Multiply,this.castShadows=F.All}get transparent(){return this.externalColor[3]<1?F.All:F.None}get opaqueOverride(){return this.externalColorMixMode===h.Replace&&1===this.externalColor[3]?F.All:F.None}get visible(){return this.externalColor[3]>0?F.All:F.None}get type(){return y.Uniform}}e([v({vectorOps:n})],W.prototype,"externalColor",void 0),e([v()],W.prototype,"externalColorMixMode",void 0),e([v()],W.prototype,"castShadows",void 0),function(e){e[e.All=0]="All",e[e.Some=1]="Some",e[e.None=2]="None"}(F||(F={}));class E extends M{constructor(){super(...arguments),this.texture=null,this.transparent=F.None,this.opaqueOverride=F.None,this.castShadows=F.None}get type(){return y.Varying}}function B(e){return 0!==e.overlays.length&&null!=e.overlays[p.INNER].getValidTexture(c.Highlight)}function L(e){return 0!==e.overlays.length&&null!=e.overlays[p.INNER].getColorTextureNoRasterImage()}e([v()],E.prototype,"texture",void 0),e([v()],E.prototype,"transparent",void 0),e([v()],E.prototype,"opaqueOverride",void 0),e([v()],E.prototype,"castShadows",void 0);export{_ as CommonMaterialParameters,I as ComponentMaterial,F as ComponentParameterSummary,W as ComponentParametersUniform,E as ComponentParametersVarying};
5
+ import{_ as e}from"../../../../../../chunks/tslib.es6.js";import{releaseMaybe as t}from"../../../../../../core/maybe.js";import{e as r,t as s}from"../../../../../../chunks/mat3.js";import{a as o}from"../../../../../../chunks/mat3f32.js";import{b as a}from"../../../../../../chunks/mat3f64.js";import{G as i}from"../../../../../../chunks/vec3.js";import{g as l,f as n}from"../../../../../../chunks/vec3f64.js";import{v as u}from"../../../../../../chunks/vec4.js";import{f as h}from"../../../../../../chunks/vec4f64.js";import{ColorMixModeEnum as p}from"../../../../layers/support/symbolColorUtils.js";import{OverlayIndex as c,RenderTargetType as d}from"../../../../terrain/interfaces.js";import{ComponentTechnique as m}from"./ComponentTechnique.js";import{ComponentTechniqueConfiguration as g,IntegratedMeshMode as y}from"./ComponentTechniqueConfiguration.js";import{ComponentDataType as T}from"./shader/ComponentData.glsl.js";import{g as x}from"../../../../../../chunks/ComponentShader.glsl.js";import{VertexDiscardMode as f}from"./shader/VertexDiscardByOpacity.glsl.js";import{MaterialBase as v,parameter as b,parameterBlock as M,MaterialParameterBlock as O}from"../../../core/material/MaterialBase.js";import{RenderPassIdentifier as C}from"../../../core/renderPasses/AllRenderPasses.js";import{ShaderOutput as w}from"../../../core/shaderLibrary/ShaderOutput.js";import{NormalType as S}from"../../../core/shaderLibrary/attributes/NormalAttribute.glsl.js";import{NormalsDoubleSidedMode as P}from"../../../core/shaderLibrary/shading/Normals.glsl.js";import{PBRMode as j}from"../../../core/shaderLibrary/shading/PhysicallyBasedRenderingParameters.glsl.js";import{defaultMaskAlphaCutoff as N}from"../../../core/shaderLibrary/util/AlphaCutoff.js";import{EllipsoidMode as q}from"../../../core/shaderLibrary/util/EllipsoidMode.js";import{TwoVectorPosition as A}from"../../../core/util/TwoVectorPosition.js";import{AlphaDiscardMode as D,CullFaceOptions as R}from"../../../lib/basicInterfaces.js";import{TransparencyPassType as I}from"../../../lib/TransparencyPassType.js";import{defaultAdvancedMRRFactors as k}from"../../../materials/pbrUtils.js";class F extends v{constructor(e,t){super(),this.toMapSpace=t,this.baseColor=h(1,1,1,1),this.usePBR=!1,this.hasParametersFromSource=!1,this.mrrFactors=l(k),this.emissiveFactor=n(0,0,0),this.baseColorTexture=null,this.metallicRoughnessTexture=null,this.emissionTexture=null,this.occlusionTexture=null,this.normalTexture=null,this.objectOpacity=1,this.commonMaterialParameters=new E,this.componentParameters=new B,this.textureAlphaCutoff=N,this.alphaDiscardMode=D.Opaque,this.isIntegratedMesh=!1,this.polygonOffsetEnabled=!1,this.ellipsoidMode=q.Earth,this.hasOccludees=!1,this._techniqueConfiguration=new g;const i=new A(e.position),u=o(e.rotationScale);r(u,u),this.transformNormalGlobalFromModel=a(s(u,u)),this.transformWorldFromModelTL=i.low,this.transformWorldFromModelTH=i.high,this.transformWorldFromModelRS=e.rotationScale}dispose(){this._technique=t(this._technique),this.baseColorTexture=null,this.metallicRoughnessTexture=null,this.emissionTexture=null,this.occlusionTexture=null,this.normalTexture=null}get texture(){return null!=this.baseColorTexture?this.baseColorTexture.glTexture:null}get textureMetallicRoughness(){return null!=this.metallicRoughnessTexture?this.metallicRoughnessTexture.glTexture:null}get textureEmissive(){return null!=this.emissionTexture?this.emissionTexture.glTexture:null}get textureOcclusion(){return null!=this.occlusionTexture?this.occlusionTexture.glTexture:null}get textureNormal(){return null!=this.normalTexture?this.normalTexture.glTexture:null}prepareTechnique(e,t,r,s){const o=this._techniqueConfiguration;o.hasVertexColors=s.colors,o.hasNormals=s.normals,o.textureCoordinateType=s.textureCoordinates,o.hasMetallicRoughnessTexture=null!=this.metallicRoughnessTexture,o.hasEmissionTexture=null!=this.emissionTexture,o.hasOcclusionTexture=null!=this.occlusionTexture,o.hasNormalTexture=null!=this.normalTexture,o.transparencyPassType=t.identifier===C.Material&&null!=r.transparencyPassType?r.transparencyPassType:I.NONE,o.hasMultipassTerrain=t.identifier===C.Material&&null!=r.multipassTerrain&&r.multipassTerrain.enabled,o.cullAboveGround=t.identifier===C.Material&&null!=r.multipassTerrain&&r.multipassTerrain.cullAboveGround,o.ellipsoidMode=this.ellipsoidMode,o.componentData=this.componentParameters.type,o.cullFace=this.commonMaterialParameters.cullFace,o.doubleSidedMode=this.commonMaterialParameters.doubleSided?P.View:P.None,o.hasBaseColorTexture=null!=this.baseColorTexture;const a=this._computeWhichMaterialPass();o.blendingEnabled=a===_.Transparent||a===_.OpaqueAndTransparent,o.alphaDiscardMode=this.alphaDiscardMode,o.integratedMeshMode=this.isIntegratedMesh?G(r)?x(r)?y.ColorOverlayWithWater:y.ColorOverlay:y.NoOverlay:y.None,o.hasPolygonOffset=this.polygonOffsetEnabled;const i=this.hasParametersFromSource&&null==this.baseColorTexture;if(o.pbrMode=o.integratedMeshMode===y.ColorOverlayWithWater?j.WaterOnIntegratedMesh:this.usePBR?i?j.Schematic:j.Normal:j.Disabled,o.normalType=o.integratedMeshMode===y.None?o.hasNormals?S.Compressed:S.ScreenDerivative:S.Ground,o.hasSlicePlane=null!=r.slicePlane&&this.commonMaterialParameters.hasSlicePlane,t.identifier===C.ShadowMap)o.output=w.Shadow,o.vertexDiscardMode=f.None;else if(t.identifier===C.Highlight)o.output=w.Highlight,o.vertexDiscardMode=f.None;else{switch(this._computeWhichMaterialPass()===_.OpaqueAndTransparent?o.vertexDiscardMode=t.transparent?f.Opaque:f.Transparent:o.vertexDiscardMode=f.None,o.output=t.output,o.receiveAmbientOcclusion=!1,o.receiveShadows=!1,t.output){case w.Color:o.receiveAmbientOcclusion=r.ssaoHelper.active,o.hasOccludees=r.hasOccludees,o.receiveShadows=r.shadowMap.ready,o.hasScreenSpaceReflections=r.ssr.enabled,o.hasCloudsReflections=null!=r.cloudsFade.data;break;case w.Alpha:o.hasOccludees=r.hasOccludees;break;case w.ObjectAndLayerIdColor:o.objectAndLayerIdColor=!0}o.snowCover=this.hasSnowCover(r)}return this._technique=e.releaseAndAcquire(m,o,this._technique),this._setClean(),this._technique}hasSnowCover(e){return null!=e.weather&&e.weatherVisible&&"snowy"===e.weather.type&&"enabled"===e.weather.snowCover}submit(e,t,r){if(0===this.objectOpacity)return;const s=r.renderable.geometry,o=r.components,a=r.renderable.meta.cameraDepthSquared,i=o.geometryRanges,l=o.highlightRanges,n=o.defaultShadowMapRanges;switch(this._computeWhichMaterialPass()){case _.Opaque:e.materialOpaque.submitDraw(this,s,i,a);break;case _.Transparent:e.materialTransparent.submitDraw(this,s,i,a);break;case _.OpaqueAndTransparent:e.materialOpaque.submitDraw(this,s,i,a),e.materialTransparent.submitDraw(this,s,i,a);break;case _.IntegratedMesh:e.materialIntegratedMesh.submitDraw(this,s,i,a),V(t)&&e.highlightIntegratedMesh.submitDraw(this,s,i,a)}const u=this.componentParameters.castShadows!==W.None;u&&e.shadowMap.submitDraw(this,s,i,a),null!=l&&(e.highlight.submitDraw(this,s,l,a),u&&e.highlightShadowMap.submitDraw(this,s,l,a)),u&&null!=n&&e.defaultShadowMap.submitDraw(this,s,n,a)}_computeWhichMaterialPass(){return this.isIntegratedMesh?_.IntegratedMesh:this.objectOpacity<1?_.Transparent:this.componentParameters.opaqueOverride===W.All?_.Opaque:this.baseColor[3]<1||this.alphaDiscardMode===D.Blend||this.alphaDiscardMode===D.MaskBlend?_.Transparent:this.componentParameters.transparent===W.None?_.Opaque:this.componentParameters.transparent===W.All?_.Transparent:_.OpaqueAndTransparent}}var _,W;e([b({vectorOps:u})],F.prototype,"baseColor",void 0),e([b()],F.prototype,"usePBR",void 0),e([b()],F.prototype,"hasParametersFromSource",void 0),e([b({vectorOps:i})],F.prototype,"mrrFactors",void 0),e([b({vectorOps:i})],F.prototype,"emissiveFactor",void 0),e([b({dispose:!0})],F.prototype,"baseColorTexture",void 0),e([b({dispose:!0})],F.prototype,"metallicRoughnessTexture",void 0),e([b({dispose:!0})],F.prototype,"emissionTexture",void 0),e([b({dispose:!0})],F.prototype,"occlusionTexture",void 0),e([b({dispose:!0})],F.prototype,"normalTexture",void 0),e([b()],F.prototype,"objectOpacity",void 0),e([M()],F.prototype,"commonMaterialParameters",void 0),e([M()],F.prototype,"componentParameters",void 0),e([b()],F.prototype,"textureAlphaCutoff",void 0),e([b()],F.prototype,"alphaDiscardMode",void 0),e([b()],F.prototype,"isIntegratedMesh",void 0),e([b()],F.prototype,"polygonOffsetEnabled",void 0),e([b()],F.prototype,"ellipsoidMode",void 0),e([b()],F.prototype,"hasOccludees",void 0),function(e){e[e.Opaque=0]="Opaque",e[e.Transparent=1]="Transparent",e[e.OpaqueAndTransparent=2]="OpaqueAndTransparent",e[e.IntegratedMesh=3]="IntegratedMesh"}(_||(_={}));class E extends O{constructor(){super(...arguments),this.doubleSided=!1,this.cullFace=R.Back,this.hasSlicePlane=!0}}e([b()],E.prototype,"doubleSided",void 0),e([b()],E.prototype,"cullFace",void 0),e([b()],E.prototype,"hasSlicePlane",void 0);class B extends O{constructor(){super(...arguments),this.externalColor=h(1,1,1,1),this.externalColorMixMode=p.Multiply,this.castShadows=W.All}get transparent(){return this.externalColor[3]<1?W.All:W.None}get opaqueOverride(){return this.externalColorMixMode===p.Replace&&1===this.externalColor[3]?W.All:W.None}get visible(){return this.externalColor[3]>0?W.All:W.None}get type(){return T.Uniform}}e([b({vectorOps:u})],B.prototype,"externalColor",void 0),e([b()],B.prototype,"externalColorMixMode",void 0),e([b()],B.prototype,"castShadows",void 0),function(e){e[e.All=0]="All",e[e.Some=1]="Some",e[e.None=2]="None"}(W||(W={}));class L extends O{constructor(){super(...arguments),this.texture=null,this.transparent=W.None,this.opaqueOverride=W.None,this.castShadows=W.None}get type(){return T.Varying}}function V(e){return 0!==e.overlays.length&&null!=e.overlays[c.INNER].getValidTexture(d.Highlight)}function G(e){return 0!==e.overlays.length&&null!=e.overlays[c.INNER].getColorTextureNoRasterImage()}e([b()],L.prototype,"texture",void 0),e([b()],L.prototype,"transparent",void 0),e([b()],L.prototype,"opaqueOverride",void 0),e([b()],L.prototype,"castShadows",void 0);export{E as CommonMaterialParameters,F as ComponentMaterial,W as ComponentParameterSummary,B as ComponentParametersUniform,L as ComponentParametersVarying};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
4
  */
5
- import{c as t}from"../../../../../chunks/vec3f64.js";import{ShaderOutput as s}from"../shaderLibrary/ShaderOutput.js";import{VertexNormalPassParameters as i,VertexNormalDrawParameters as r}from"../shaderLibrary/attributes/VertexNormal.glsl.js";class e extends i{constructor(){super(...arguments),this.slicePlaneLocalOrigin=t(),this.origin=this.slicePlaneLocalOrigin}}class a extends r{}var o;!function(t){t[t.Material=0]="Material",t[t.ShadowMap=1]="ShadowMap",t[t.Highlight=2]="Highlight"}(o||(o={}));class h extends e{constructor(){super(...arguments),this.identifier=o.Material,this.output=s.Color,this.transparent=!1,this.integratedMesh=!1}}class n extends e{constructor(){super(...arguments),this.identifier=o.ShadowMap}}class c extends e{constructor(){super(...arguments),this.identifier=o.Highlight}}export{a as DrawParameters,c as HighlightPassParameters,h as MaterialPassParameters,e as PassParameters,o as RenderPassIdentifier,n as ShadowMapPassParameters};
5
+ import{c as t}from"../../../../../chunks/vec3f64.js";import{ShaderOutput as s}from"../shaderLibrary/ShaderOutput.js";import{VertexNormalPassParameters as i,VertexNormalDrawParameters as r}from"../shaderLibrary/attributes/VertexNormal.glsl.js";class e extends i{constructor(){super(...arguments),this.slicePlaneLocalOrigin=t(),this.origin=this.slicePlaneLocalOrigin,this.modelTransformation=null}}class a extends r{}var o;!function(t){t[t.Material=0]="Material",t[t.ShadowMap=1]="ShadowMap",t[t.Highlight=2]="Highlight"}(o||(o={}));class n extends e{constructor(){super(...arguments),this.identifier=o.Material,this.output=s.Color,this.transparent=!1,this.integratedMesh=!1}}class h extends e{constructor(){super(...arguments),this.identifier=o.ShadowMap}}class l extends e{constructor(){super(...arguments),this.identifier=o.Highlight}}export{a as DrawParameters,l as HighlightPassParameters,n as MaterialPassParameters,e as PassParameters,o as RenderPassIdentifier,h as ShadowMapPassParameters};
@@ -2,16 +2,10 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
4
  */
5
- import{addCalculateLinearDepth as e}from"./ForwardLinearDepth.glsl.js";import{glsl as o}from"../shaderModules/interfaces.js";function r(r,t){if(e(r),t.hasModelTransformation)return r.vertex.code.add(o`vec4 transformPositionWithDepth(mat4 proj, mat4 view, mat4 model, vec3 pos, vec2 nearFar, out float depth) {
6
- vec4 eye = view * (model * vec4(pos, 1.0));
7
- depth = calculateLinearDepth(nearFar, eye.z);
8
- return proj * eye;
9
- }`),void r.vertex.code.add(o`vec4 transformPosition(mat4 proj, mat4 view, mat4 model, vec3 pos) {
10
- return proj * (view * (model * vec4(pos, 1.0)));
11
- }`);r.vertex.code.add(o`vec4 transformPositionWithDepth(mat4 proj, mat4 view, vec3 pos, vec2 nearFar, out float depth) {
5
+ import{addCalculateLinearDepth as e}from"./ForwardLinearDepth.glsl.js";import{glsl as r}from"../shaderModules/interfaces.js";function o(o){e(o),o.vertex.code.add(r`vec4 transformPositionWithDepth(mat4 proj, mat4 view, vec3 pos, vec2 nearFar, out float depth) {
12
6
  vec4 eye = view * vec4(pos, 1.0);
13
7
  depth = calculateLinearDepth(nearFar,eye.z);
14
8
  return proj * eye;
15
- }`),r.vertex.code.add(o`vec4 transformPosition(mat4 proj, mat4 view, vec3 pos) {
9
+ }`),o.vertex.code.add(r`vec4 transformPosition(mat4 proj, mat4 view, vec3 pos) {
16
10
  return proj * (view * vec4(pos, 1.0));
17
- }`)}export{r as Transform};
11
+ }`)}export{o as Transform};
@@ -2,12 +2,13 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
4
  */
5
- import{I as o}from"../../../../../../chunks/mat4f64.js";import{addNearFar as r}from"../ForwardLinearDepth.glsl.js";import{ShaderOutput as e}from"../ShaderOutput.js";import{SliceDraw as t}from"../Slice.glsl.js";import{Transform as i}from"../Transform.glsl.js";import{NormalAttribute as a,NormalType as s}from"../attributes/NormalAttribute.glsl.js";import{ObjectAndLayerIdColor as l}from"../attributes/ObjectAndLayerIdColor.glsl.js";import{TextureCoordinateAttribute as d}from"../attributes/TextureCoordinateAttribute.glsl.js";import{VertexNormal as n}from"../attributes/VertexNormal.glsl.js";import{OutputDepth as c}from"../output/OutputDepth.glsl.js";import{OutputHighlight as m}from"../output/OutputHighlight.glsl.js";import{VisualVariables as u}from"../shading/VisualVariables.glsl.js";import{DiscardOrAdjustAlphaPass as p}from"../util/AlphaDiscard.glsl.js";import{addProjViewLocalOrigin as v}from"../util/View.glsl.js";import{glsl as f}from"../../shaderModules/interfaces.js";import{Matrix4PassUniform as h}from"../../shaderModules/Matrix4PassUniform.js";import{Texture2DPassUniform as g}from"../../shaderModules/Texture2DPassUniform.js";import{AlphaDiscardMode as x}from"../../../lib/basicInterfaces.js";function j(j,w){const{vertex:C,fragment:O}=j,b=w.hasModelTransformation;b&&C.uniforms.add(new h("model",(r=>null!=r.modelTransformation?r.modelTransformation:o)));const T=w.hasColorTexture&&w.alphaDiscardMode!==x.Opaque;switch(w.output){case e.Depth:case e.Shadow:case e.ShadowHighlight:case e.ShadowExcludeHighlight:case e.ObjectAndLayerIdColor:v(C,w),j.include(i,w),j.include(d,w),j.include(u,w),j.include(c,w),j.include(t,w),j.include(l,w),r(j),j.varyings.add("depth","float"),T&&O.uniforms.add(new g("tex",(o=>o.texture))),C.code.add(f`
5
+ import{I as o}from"../../../../../../chunks/mat4f64.js";import{addNearFar as e}from"../ForwardLinearDepth.glsl.js";import{ShaderOutput as r}from"../ShaderOutput.js";import{SliceDraw as t}from"../Slice.glsl.js";import{Transform as i}from"../Transform.glsl.js";import{NormalAttribute as a,NormalType as s}from"../attributes/NormalAttribute.glsl.js";import{ObjectAndLayerIdColor as l}from"../attributes/ObjectAndLayerIdColor.glsl.js";import{TextureCoordinateAttribute as d}from"../attributes/TextureCoordinateAttribute.glsl.js";import{VertexNormal as n}from"../attributes/VertexNormal.glsl.js";import{OutputDepth as c}from"../output/OutputDepth.glsl.js";import{OutputHighlight as u}from"../output/OutputHighlight.glsl.js";import{VisualVariables as m}from"../shading/VisualVariables.glsl.js";import{DiscardOrAdjustAlphaPass as p}from"../util/AlphaDiscard.glsl.js";import{addProjViewLocalOrigin as v}from"../util/View.glsl.js";import{glsl as f}from"../../shaderModules/interfaces.js";import{Matrix4PassUniform as h}from"../../shaderModules/Matrix4PassUniform.js";import{Texture2DPassUniform as g}from"../../shaderModules/Texture2DPassUniform.js";import{AlphaDiscardMode as x}from"../../../lib/basicInterfaces.js";function j(j,w){const{vertex:C,fragment:O}=j,b=w.hasModelTransformation;b&&C.uniforms.add(new h("model",(e=>e.modelTransformation??o)));const T=w.hasColorTexture&&w.alphaDiscardMode!==x.Opaque;switch(w.output){case r.Depth:case r.Shadow:case r.ShadowHighlight:case r.ShadowExcludeHighlight:case r.ObjectAndLayerIdColor:v(C,w),j.include(i,w),j.include(d,w),j.include(m,w),j.include(c,w),j.include(t,w),j.include(l,w),e(j),j.varyings.add("depth","float"),T&&O.uniforms.add(new g("tex",(o=>o.texture))),C.code.add(f`
6
6
  void main(void) {
7
7
  vpos = calculateVPos();
8
+ ${b?"vpos = (model * vec4(vpos, 1.0)).xyz;":""}
8
9
  vpos = subtractOrigin(vpos);
9
10
  vpos = addVerticalOffset(vpos, localOrigin);
10
- gl_Position = transformPositionWithDepth(proj, view, ${b?"model,":""} vpos, nearFar, depth);
11
+ gl_Position = transformPositionWithDepth(proj, view, vpos, nearFar, depth);
11
12
  forwardTextureCoordinates();
12
13
  forwardObjectAndLayerIdColor();
13
14
  }
@@ -17,20 +18,21 @@ import{I as o}from"../../../../../../chunks/mat4f64.js";import{addNearFar as r}f
17
18
  ${T?f`
18
19
  vec4 texColor = texture(tex, ${w.hasColorTextureTransform?f`colorUV`:f`vuv0`});
19
20
  discardOrAdjustAlpha(texColor);`:""}
20
- ${w.output===e.ObjectAndLayerIdColor?f`outputObjectAndLayerIdColor();`:f`outputDepth(depth);`}
21
+ ${w.output===r.ObjectAndLayerIdColor?f`outputObjectAndLayerIdColor();`:f`outputDepth(depth);`}
21
22
  }
22
- `);break;case e.Normal:{v(C,w),j.include(i,w),j.include(a,w),j.include(n,w),j.include(d,w),j.include(u,w),T&&O.uniforms.add(new g("tex",(o=>o.texture))),w.normalType===s.ScreenDerivative&&j.varyings.add("vPositionView","vec3");const o=w.normalType===s.Attribute||w.normalType===s.Compressed;C.code.add(f`
23
+ `);break;case r.Normal:{v(C,w),j.include(i,w),j.include(a,w),j.include(n,w),j.include(d,w),j.include(m,w),T&&O.uniforms.add(new g("tex",(o=>o.texture))),w.normalType===s.ScreenDerivative&&j.varyings.add("vPositionView","vec3");const o=w.normalType===s.Attribute||w.normalType===s.Compressed;C.code.add(f`
23
24
  void main(void) {
24
25
  vpos = calculateVPos();
26
+ ${b?"vpos = (model * vec4(vpos, 1.0)).xyz;":""}
25
27
 
26
28
  ${o?f`
27
29
  vNormalWorld = dpNormalView(vvLocalNormal(normalModel()));`:f`
28
30
  // Get vertex position in camera space for screen-space derivative normals
29
- vPositionView = (view * (${b?"model *":""} vec4(vpos, 1.0))).xyz;
31
+ vPositionView = (view * vec4(vpos, 1.0)).xyz;
30
32
  `}
31
33
  vpos = subtractOrigin(vpos);
32
34
  vpos = addVerticalOffset(vpos, localOrigin);
33
- gl_Position = transformPosition(proj, view, ${b?"model,":""} vpos);
35
+ gl_Position = transformPosition(proj, view, vpos);
34
36
  forwardTextureCoordinates();
35
37
  }
36
38
  `),j.include(t,w),j.include(p,w),O.code.add(f`
@@ -47,15 +49,16 @@ import{I as o}from"../../../../../../chunks/mat4f64.js";import{addNearFar as r}f
47
49
  }`}
48
50
  fragColor = vec4(0.5 + 0.5 * normal, 1.0);
49
51
  }
50
- `);break}case e.Highlight:v(C,w),j.include(i,w),j.include(d,w),j.include(u,w),T&&O.uniforms.add(new g("tex",(o=>o.texture))),C.code.add(f`
52
+ `);break}case r.Highlight:v(C,w),j.include(i,w),j.include(d,w),j.include(m,w),T&&O.uniforms.add(new g("tex",(o=>o.texture))),C.code.add(f`
51
53
  void main(void) {
52
54
  vpos = calculateVPos();
55
+ ${b?"vpos = (model * vec4(vpos, 1.0)).xyz;":""}
53
56
  vpos = subtractOrigin(vpos);
54
57
  vpos = addVerticalOffset(vpos, localOrigin);
55
- gl_Position = transformPosition(proj, view, ${b?"model,":""} vpos);
58
+ gl_Position = transformPosition(proj, view, vpos);
56
59
  forwardTextureCoordinates();
57
60
  }
58
- `),j.include(t,w),j.include(p,w),j.include(m,w),O.code.add(f`
61
+ `),j.include(t,w),j.include(p,w),j.include(u,w),O.code.add(f`
59
62
  void main() {
60
63
  discardBySlice(vpos);
61
64
  ${T?f`
@@ -2,33 +2,33 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
4
  */
5
- import{f as e}from"../../../../../../chunks/vec3f32.js";import{VertexTextureCoordinates as s}from"../attributes/VertexTextureCoordinates.glsl.js";import{Float3DrawUniform as o}from"../../shaderModules/Float3DrawUniform.js";import{Float3PassUniform as r}from"../../shaderModules/Float3PassUniform.js";import{glsl as t}from"../../shaderModules/interfaces.js";import{Texture2DDrawUniform as i}from"../../shaderModules/Texture2DDrawUniform.js";import{Texture2DPassUniform as a}from"../../shaderModules/Texture2DPassUniform.js";import{BindType as n}from"../../shaderTechnique/BindType.js";import{GLTextureMaterialBindParameters as c}from"../../../lib/GLTextureMaterial.js";const u=e(0,.6,.2);var l;!function(e){e[e.Disabled=0]="Disabled",e[e.Normal=1]="Normal",e[e.Schematic=2]="Schematic",e[e.Water=3]="Water",e[e.WaterOnIntegratedMesh=4]="WaterOnIntegratedMesh",e[e.Terrain=5]="Terrain",e[e.TerrainWithWater=6]="TerrainWithWater",e[e.COUNT=7]="COUNT"}(l||(l={}));class m extends c{}function d(e,c){const u=e.fragment,m=c.hasMetallicRoughnessTexture||c.hasEmissionTexture||c.hasOcclusionTexture;if(c.pbrMode===l.Normal&&m&&e.include(s,c),c.pbrMode!==l.Schematic)if(c.pbrMode!==l.Disabled){if(c.pbrMode===l.Normal){u.code.add(t`vec3 mrr;
5
+ import{VertexTextureCoordinates as e}from"../attributes/VertexTextureCoordinates.glsl.js";import{Float3DrawUniform as s}from"../../shaderModules/Float3DrawUniform.js";import{Float3PassUniform as o}from"../../shaderModules/Float3PassUniform.js";import{glsl as r}from"../../shaderModules/interfaces.js";import{Texture2DDrawUniform as i}from"../../shaderModules/Texture2DDrawUniform.js";import{Texture2DPassUniform as t}from"../../shaderModules/Texture2DPassUniform.js";import{BindType as a}from"../../shaderTechnique/BindType.js";import{GLTextureMaterialBindParameters as n}from"../../../lib/GLTextureMaterial.js";var c;!function(e){e[e.Disabled=0]="Disabled",e[e.Normal=1]="Normal",e[e.Schematic=2]="Schematic",e[e.Water=3]="Water",e[e.WaterOnIntegratedMesh=4]="WaterOnIntegratedMesh",e[e.Terrain=5]="Terrain",e[e.TerrainWithWater=6]="TerrainWithWater",e[e.COUNT=7]="COUNT"}(c||(c={}));class u extends n{}function l(n,u){const l=n.fragment,m=u.hasMetallicRoughnessTexture||u.hasEmissionTexture||u.hasOcclusionTexture;if(u.pbrMode===c.Normal&&m&&n.include(e,u),u.pbrMode!==c.Schematic)if(u.pbrMode!==c.Disabled){if(u.pbrMode===c.Normal){l.code.add(r`vec3 mrr;
6
6
  vec3 emission;
7
- float occlusion;`);const e=c.pbrTextureBindType;c.hasMetallicRoughnessTexture&&(u.uniforms.add(e===n.Pass?new a("texMetallicRoughness",(e=>e.textureMetallicRoughness)):new i("texMetallicRoughness",(e=>e.textureMetallicRoughness))),u.code.add(t`void applyMetallnessAndRoughness(vec2 uv) {
7
+ float occlusion;`);const e=u.pbrTextureBindType;u.hasMetallicRoughnessTexture&&(l.uniforms.add(e===a.Pass?new t("texMetallicRoughness",(e=>e.textureMetallicRoughness)):new i("texMetallicRoughness",(e=>e.textureMetallicRoughness))),l.code.add(r`void applyMetallnessAndRoughness(vec2 uv) {
8
8
  vec3 metallicRoughness = textureLookup(texMetallicRoughness, uv).rgb;
9
9
  mrr[0] *= metallicRoughness.b;
10
10
  mrr[1] *= metallicRoughness.g;
11
- }`)),c.hasEmissionTexture&&(u.uniforms.add(e===n.Pass?new a("texEmission",(e=>e.textureEmissive)):new i("texEmission",(e=>e.textureEmissive))),u.code.add(t`void applyEmission(vec2 uv) {
11
+ }`)),u.hasEmissionTexture&&(l.uniforms.add(e===a.Pass?new t("texEmission",(e=>e.textureEmissive)):new i("texEmission",(e=>e.textureEmissive))),l.code.add(r`void applyEmission(vec2 uv) {
12
12
  emission *= textureLookup(texEmission, uv).rgb;
13
- }`)),c.hasOcclusionTexture?(u.uniforms.add(e===n.Pass?new a("texOcclusion",(e=>e.textureOcclusion)):new i("texOcclusion",(e=>e.textureOcclusion))),u.code.add(t`void applyOcclusion(vec2 uv) {
13
+ }`)),u.hasOcclusionTexture?(l.uniforms.add(e===a.Pass?new t("texOcclusion",(e=>e.textureOcclusion)):new i("texOcclusion",(e=>e.textureOcclusion))),l.code.add(r`void applyOcclusion(vec2 uv) {
14
14
  occlusion *= textureLookup(texOcclusion, uv).r;
15
15
  }
16
16
  float getBakedOcclusion() {
17
17
  return occlusion;
18
- }`)):u.code.add(t`float getBakedOcclusion() { return 1.0; }`),e===n.Pass?u.uniforms.add(new r("emissionFactor",(e=>e.emissiveFactor)),new r("mrrFactors",(e=>e.mrrFactors))):u.uniforms.add(new o("emissionFactor",(e=>e.emissiveFactor)),new o("mrrFactors",(e=>e.mrrFactors))),u.code.add(t`
18
+ }`)):l.code.add(r`float getBakedOcclusion() { return 1.0; }`),e===a.Pass?l.uniforms.add(new o("emissionFactor",(e=>e.emissiveFactor)),new o("mrrFactors",(e=>e.mrrFactors))):l.uniforms.add(new s("emissionFactor",(e=>e.emissiveFactor)),new s("mrrFactors",(e=>e.mrrFactors))),l.code.add(r`
19
19
  void applyPBRFactors() {
20
20
  mrr = mrrFactors;
21
21
  emission = emissionFactor;
22
22
  occlusion = 1.0;
23
23
 
24
- ${c.hasMetallicRoughnessTexture?t`applyMetallnessAndRoughness(${c.hasMetallicRoughnessTextureTransform?t`metallicRoughnessUV`:"vuv0"});`:""}
24
+ ${u.hasMetallicRoughnessTexture?r`applyMetallnessAndRoughness(${u.hasMetallicRoughnessTextureTransform?r`metallicRoughnessUV`:"vuv0"});`:""}
25
25
 
26
- ${c.hasEmissionTexture?t`applyEmission(${c.hasEmissiveTextureTransform?t`emissiveUV`:"vuv0"});`:""}
26
+ ${u.hasEmissionTexture?r`applyEmission(${u.hasEmissiveTextureTransform?r`emissiveUV`:"vuv0"});`:""}
27
27
 
28
- ${c.hasOcclusionTexture?t`applyOcclusion(${c.hasOcclusionTextureTransform?t`occlusionUV`:"vuv0"});`:""}
28
+ ${u.hasOcclusionTexture?r`applyOcclusion(${u.hasOcclusionTextureTransform?r`occlusionUV`:"vuv0"});`:""}
29
29
  }
30
- `)}}else u.code.add(t`float getBakedOcclusion() { return 1.0; }`);else u.code.add(t`vec3 mrr = vec3(0.0, 0.6, 0.2);
30
+ `)}}else l.code.add(r`float getBakedOcclusion() { return 1.0; }`);else l.code.add(r`vec3 mrr = vec3(0.0, 0.6, 0.2);
31
31
  vec3 emission = vec3(0.0);
32
32
  float occlusion = 1.0;
33
33
  void applyPBRFactors() {}
34
- float getBakedOcclusion() { return 1.0; }`)}export{m as PBRBindParameters,l as PBRMode,u as PBRSchematicMRRValues,d as PhysicallyBasedRenderingParameters};
34
+ float getBakedOcclusion() { return 1.0; }`)}export{u as PBRBindParameters,c as PBRMode,l as PhysicallyBasedRenderingParameters};