@arcgis/core 4.28.0-next.20230920 → 4.28.0-next.20230921

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 (146) hide show
  1. package/WebScene.js +1 -1
  2. package/assets/esri/core/workers/RemoteClient.js +1 -1
  3. package/assets/esri/core/workers/chunks/1cbaba30f55f00f7498b.js +1 -0
  4. package/assets/esri/core/workers/chunks/21a9c8aa2a9e9990df41.js +1 -0
  5. package/assets/esri/core/workers/chunks/24629402c647ef6b5f6b.js +1 -0
  6. package/assets/esri/core/workers/chunks/{b428fcb53ecc82b49e66.js → 332689bf60d246485993.js} +1 -1
  7. package/assets/esri/core/workers/chunks/{b558a402e2ce2616cf37.js → 3ca759f72d3bb29e9ea9.js} +22 -22
  8. package/assets/esri/core/workers/chunks/4339ce8aaf87fabb80cc.js +1 -0
  9. package/assets/esri/core/workers/chunks/4369a6c1e0a82ab4db6a.js +1 -0
  10. package/assets/esri/core/workers/chunks/43ba2bacd0f7d19915f7.js +1 -0
  11. package/assets/esri/core/workers/chunks/44b8e75593b7df1843e1.js +1 -0
  12. package/assets/esri/core/workers/chunks/53097659f31750c03a6d.js +1 -0
  13. package/assets/esri/core/workers/chunks/{7c72d5368bb2d7484b9b.js → 580039dd491854ca325c.js} +1 -1
  14. package/assets/esri/core/workers/chunks/59c00d6fba0fd1c03d01.js +1 -0
  15. package/assets/esri/core/workers/chunks/5edb99b58549cd66b394.js +1 -0
  16. package/assets/esri/core/workers/chunks/6203ddf6caad3d356327.js +1 -0
  17. package/assets/esri/core/workers/chunks/652749dc847fcb887234.js +1 -0
  18. package/assets/esri/core/workers/chunks/74d3ecb1a06d9f81e2c5.js +1 -0
  19. package/assets/esri/core/workers/chunks/7ea33aa455c5143affb1.js +1 -0
  20. package/assets/esri/core/workers/chunks/90771b0de3e520a1df9a.js +1 -0
  21. package/assets/esri/core/workers/chunks/a277c980ba8704939688.js +1 -0
  22. package/assets/esri/core/workers/chunks/bbc0dcd316c5598bc9ad.js +1 -0
  23. package/assets/esri/core/workers/chunks/bc1dc6383e60e7e61d50.js +1 -0
  24. package/assets/esri/core/workers/chunks/c4bb67150ccd01ea6014.js +1 -0
  25. package/assets/esri/core/workers/chunks/{aa021bc97b4a18a749dd.js → cad260881653567bc8f9.js} +1 -1
  26. package/assets/esri/core/workers/chunks/cec607d0138351a4952e.js +1 -0
  27. package/assets/esri/core/workers/chunks/{f147269d85adfb4588ed.js → d9061beaa43065316062.js} +1 -1
  28. package/assets/esri/core/workers/chunks/e55f7fc7eff0074ce0fc.js +1 -0
  29. package/assets/esri/core/workers/chunks/{9c40e7ed387071544f8c.js → ed1fbc1bc8d50453e2f5.js} +1 -1
  30. package/assets/esri/core/workers/chunks/eef27d305023034084a4.js +1 -0
  31. package/assets/esri/images/portal/onlinemedialayer16.png +0 -0
  32. package/chunks/LaserlinePath.glsl.js +5 -1
  33. package/core/sql.js +1 -1
  34. package/interfaces.d.ts +1 -17
  35. package/layers/graphics/sources/WFSSourceWorker.js +1 -1
  36. package/layers/mixins/SceneService.js +1 -1
  37. package/layers/save/utils.js +1 -1
  38. package/layers/support/editableLayers.js +1 -1
  39. package/package.json +1 -1
  40. package/portal/PortalItem.js +1 -1
  41. package/rest/geometryService/cut.js +1 -1
  42. package/rest/query/operations/query.js +1 -1
  43. package/rest/versionManagement/deleteVersion.js +1 -1
  44. package/rest/versionManagement/gdbVersion/alterVersion.js +1 -1
  45. package/rest/versionManagement/gdbVersion/post.js +1 -1
  46. package/rest/versionManagement/gdbVersion/reconcile.js +1 -1
  47. package/rest/versionManagement/gdbVersion/serverVersionUtils.js +5 -0
  48. package/support/revision.js +1 -1
  49. package/views/2d/engine/Stage.js +1 -1
  50. package/views/3d/analysis/Dimension/LengthDimensionSubTool.js +1 -1
  51. package/views/3d/analysis/Dimension/lengthDimensionConstraintUtils.js +1 -1
  52. package/views/3d/analysis/Slice/RotateManipulator.js +1 -1
  53. package/views/3d/environment/LocalAtmosphere.js +1 -1
  54. package/views/3d/interactive/manipulatorUtils.js +1 -1
  55. package/views/3d/interactive/visualElements/MeasurementAreaVisualElement.js +1 -1
  56. package/views/3d/interactive/visualElements/OutlineVisualElement.js +1 -1
  57. package/views/3d/interactive/visualElements/PointVisualElement.js +1 -1
  58. package/views/3d/interactive/visualElements/RightAngleQuadVisualElement.js +1 -1
  59. package/views/3d/layers/MediaLayerView3D.js +1 -1
  60. package/views/3d/layers/SceneLayerGraphicsView3D.js +1 -1
  61. package/views/3d/layers/graphics/Deconflictor.js +1 -1
  62. package/views/3d/layers/graphics/ElevationAligners.js +1 -1
  63. package/views/3d/layers/graphics/Graphics3DExtrudeSymbolLayer.js +1 -1
  64. package/views/3d/layers/graphics/Graphics3DLineCalloutSymbolLayer.js +1 -1
  65. package/views/3d/layers/graphics/Graphics3DMeshFillSymbolLayer.js +1 -1
  66. package/views/3d/layers/graphics/Graphics3DObjectSymbolLayer.js +1 -1
  67. package/views/3d/layers/graphics/objectResourceUtils.js +1 -1
  68. package/views/3d/layers/graphics/polygonUtils.js +1 -1
  69. package/views/3d/layers/graphics/wosrLoader.js +1 -1
  70. package/views/3d/layers/i3s/I3SUtil.js +1 -1
  71. package/views/3d/layers/support/HeatmapFeatureProcessor.js +1 -1
  72. package/views/3d/layers/support/overlayImageUtils.js +1 -1
  73. package/views/3d/layers/support/patternUtils.js +1 -1
  74. package/views/3d/support/dito.js +1 -1
  75. package/views/3d/support/engineContent/line.js +1 -1
  76. package/views/3d/support/pointsOfInterest/CenterOnSurface.js +1 -1
  77. package/views/3d/support/pointsOfInterest/Focus.js +1 -1
  78. package/views/3d/terrain/TerrainRenderer.js +1 -1
  79. package/views/3d/webgl-engine/collections/Component/ComponentIntersectionData.js +1 -1
  80. package/views/3d/webgl-engine/collections/Component/IntersectionGeometry.js +1 -1
  81. package/views/3d/webgl-engine/core/shaderLibrary/attributes/InstancedDoublePrecision.glsl.js +6 -6
  82. package/views/3d/webgl-engine/effects/ssao/SSAO.js +1 -1
  83. package/views/3d/webgl-engine/lib/Attribute.js +1 -1
  84. package/views/3d/webgl-engine/lib/BoundingInfo.js +1 -1
  85. package/views/3d/webgl-engine/lib/Camera.js +1 -1
  86. package/views/3d/webgl-engine/lib/Geometry.js +1 -1
  87. package/views/3d/webgl-engine/lib/GeometryUtil.js +1 -1
  88. package/views/3d/webgl-engine/lib/GridLocalOriginFactory.js +1 -1
  89. package/views/3d/webgl-engine/lib/PathGeometryData.js +1 -1
  90. package/views/3d/webgl-engine/lib/RenderGeometry.js +1 -1
  91. package/views/3d/webgl-engine/lib/edgeRendering/EdgeView.js +1 -1
  92. package/views/3d/webgl-engine/lib/geometryDataUtils.js +1 -1
  93. package/views/3d/webgl-engine/lib/lodRendering/LodResources.js +1 -1
  94. package/views/3d/webgl-engine/materials/DefaultBufferWriter.js +1 -1
  95. package/views/3d/webgl-engine/materials/HUDMaterial.js +1 -1
  96. package/views/3d/webgl-engine/materials/HeatmapDensityMaterial.js +1 -1
  97. package/views/3d/webgl-engine/materials/ImageMaterial.js +1 -1
  98. package/views/3d/webgl-engine/materials/LineCalloutMaterial.js +1 -1
  99. package/views/3d/webgl-engine/materials/LineMarkerMaterial.js +1 -1
  100. package/views/3d/webgl-engine/materials/MeasurementArrowMaterial.js +1 -1
  101. package/views/3d/webgl-engine/materials/NativeLineMaterial.js +1 -1
  102. package/views/3d/webgl-engine/materials/PatternMaterial.js +1 -1
  103. package/views/3d/webgl-engine/materials/RibbonLineMaterial.js +1 -1
  104. package/views/3d/webgl-engine/materials/ShadedColorMaterial.js +1 -1
  105. package/views/3d/webgl-engine/materials/internal/MaterialUtil.js +1 -1
  106. package/views/3d/webgl-engine/materials/internal/bufferWriterUtils.js +1 -1
  107. package/views/draw/DrawGraphicTool.js +1 -1
  108. package/views/interactive/keybindings.js +1 -1
  109. package/views/interactive/tooltip/SketchTooltipInfo.js +1 -1
  110. package/views/interactive/tooltip/TooltipEditableField.js +1 -1
  111. package/views/interactive/tooltip/content/Fields.js +5 -0
  112. package/views/interactive/tooltip/content/TooltipContentDrawPoint.js +1 -1
  113. package/views/interactive/tooltip/content/TooltipContentDrawPolygon.js +1 -1
  114. package/views/interactive/tooltip/content/TooltipContentDrawPolyline.js +1 -1
  115. package/webdoc/saveAPIKeyUtils.js +5 -0
  116. package/webdoc/webdocSaveUtils.js +1 -1
  117. package/widgets/BasemapGallery.js +1 -1
  118. package/widgets/BasemapLayerList.js +1 -1
  119. package/widgets/Expand.js +1 -1
  120. package/widgets/Feature/FeatureRelationship.js +1 -1
  121. package/widgets/Fullscreen.js +1 -1
  122. package/widgets/Legend/support/ActiveLayerInfo.js +1 -1
  123. package/widgets/Swipe.js +1 -1
  124. package/widgets/support/globalCss.js +1 -1
  125. package/assets/esri/core/workers/chunks/034accc7cab6c88a3b31.js +0 -1
  126. package/assets/esri/core/workers/chunks/084a85e2e31b4d5fa924.js +0 -1
  127. package/assets/esri/core/workers/chunks/1a449168d30a688e6128.js +0 -1
  128. package/assets/esri/core/workers/chunks/21f0fafafcd754f5fb88.js +0 -1
  129. package/assets/esri/core/workers/chunks/273167b2dd46e58b8739.js +0 -1
  130. package/assets/esri/core/workers/chunks/2bf58296a6ea4eee960b.js +0 -1
  131. package/assets/esri/core/workers/chunks/3c2c64832fb498bbaa83.js +0 -1
  132. package/assets/esri/core/workers/chunks/4b3a5cc435435c81e6a5.js +0 -1
  133. package/assets/esri/core/workers/chunks/56afd89d08c874f620a1.js +0 -1
  134. package/assets/esri/core/workers/chunks/6108d72faf48a592c8ba.js +0 -1
  135. package/assets/esri/core/workers/chunks/74ddc14e4b576ddbb582.js +0 -1
  136. package/assets/esri/core/workers/chunks/7f680cf24dd97d61bcd2.js +0 -1
  137. package/assets/esri/core/workers/chunks/9b54b5bdb6367c36f6e9.js +0 -1
  138. package/assets/esri/core/workers/chunks/a838dc6653ec29503053.js +0 -1
  139. package/assets/esri/core/workers/chunks/b10a91cae610aba62bf8.js +0 -1
  140. package/assets/esri/core/workers/chunks/b8eb842ea98a9734e161.js +0 -1
  141. package/assets/esri/core/workers/chunks/bbb63392485ed57703e0.js +0 -1
  142. package/assets/esri/core/workers/chunks/bdf13091bd0e1ab0db7e.js +0 -1
  143. package/assets/esri/core/workers/chunks/c88869d2a647c22dc3e6.js +0 -1
  144. package/assets/esri/core/workers/chunks/e54ae2a4281dd58e0707.js +0 -1
  145. package/assets/esri/core/workers/chunks/e5fcfd41f0ec12dcb7f2.js +0 -1
  146. package/assets/esri/core/workers/chunks/f07a0ea10428adecea1a.js +0 -1
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../../../Color.js";import"../../../../core/has.js";import{deg2rad as t}from"../../../../core/mathUtils.js";import{f as r,t as o}from"../../../../chunks/mat3.js";import{a}from"../../../../chunks/mat3f64.js";import{d as s,m as n,i}from"../../../../chunks/mat4.js";import{a as l,I as c,b as u}from"../../../../chunks/mat4f64.js";import{s as m,g as h,i as f,j as p,n as d,f as g,b as x}from"../../../../chunks/vec3.js";import{Z as _,O as T,c as y}from"../../../../chunks/vec3f64.js";import{O as b}from"../../../../chunks/vec4f64.js";import{canProjectWithoutEngine as v}from"../../../../geometry/projection.js";import{computeTranslationToOriginAndRotation as C}from"../../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{projectBuffer as j}from"../../../../geometry/projection/projectBuffer.js";import{projectVectorToDehydratedPoint as w}from"../../../../geometry/projection/projectVectorToDehydratedPoint.js";import{create as O,empty as M,expandWithBuffer as P,intersectsClippingArea as R}from"../../../../geometry/support/aaBoundingBox.js";import{newFloatArray as A}from"../../../../geometry/support/FloatArray.js";import{getContinuousIndexArray as I,getZeroIndexArray as E}from"../../../../geometry/support/Indices.js";import N from"../../../../geometry/support/MeshComponent.js";import B from"../../../../geometry/support/MeshMaterialMetallicRoughness.js";import F from"../../../../geometry/support/MeshTextureTransform.js";import{t as S,a as U}from"../../../../chunks/vec32.js";import{project as L}from"../../../../geometry/support/meshUtils/georeference.js";import{transformNormal as $,projectNormalToPCPF as G,transformTangent as V,projectTangentToPCPF as D}from"../../../../geometry/support/meshUtils/projection.js";import{makeDehydratedPoint as k}from"../../../../layers/graphics/dehydratedPoint.js";import{MeshTransformUpdateAction as H}from"../../../../layers/graphics/sources/interfaces.js";import{ViewingMode as q}from"../../../ViewingMode.js";import{isEncodedMeshTexture as W}from"../../glTF/internal/resourceUtils.js";import{getTransformMatrix as z}from"../../glTF/internal/TextureTransformUtils.js";import{perObjectElevationAligner as Y}from"./ElevationAligners.js";import{needsElevationUpdates3D as Z,evaluateElevationInfoAtPoint as J}from"./elevationAlignmentUtils.js";import{Graphics3DMeshObject3DGraphicLayer as K}from"./Graphics3DMeshObject3DGraphicLayer.js";import{Object3DEdgeState as Q}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as X}from"./Graphics3DSymbolLayer.js";import{MaterialInfoCache as ee,MeshFastUpdateProcessor as te}from"./MeshFastUpdateProcessor.js";import{createMaterial as re}from"../support/edgeUtils.js";import{parseColorMixMode as oe,encodeSymbolColor as ae}from"../support/symbolColorUtils.js";import{debugFlags as se}from"../../support/debugFlags.js";import{Attribute as ne}from"../../webgl-engine/lib/Attribute.js";import{AlphaDiscardMode as ie,CullFaceOptions as le}from"../../webgl-engine/lib/basicInterfaces.js";import{ContentObjectType as ce}from"../../webgl-engine/lib/ContentObjectType.js";import{Geometry as ue}from"../../webgl-engine/lib/Geometry.js";import{Object3D as me}from"../../webgl-engine/lib/Object3D.js";import{Texture as he}from"../../webgl-engine/lib/Texture.js";import{VertexAttribute as fe}from"../../webgl-engine/lib/VertexAttribute.js";import{DefaultMaterial as pe}from"../../webgl-engine/materials/DefaultMaterial.js";import{NativeLineMaterial as de}from"../../webgl-engine/materials/NativeLineMaterial.js";import{useSchematicPBR as ge,defaultSchematicMRRFactors as xe,defaultAdvancedMRRFactors as _e}from"../../webgl-engine/materials/pbrUtils.js";import{TextureWrapMode as Te}from"../../../webgl/enums.js";const ye=["mesh"];class be extends X{constructor(e,t,r,o){super(e,t,r,o),this._materialInfoCache=new ee,this._fastUpdateProcessor=new te,this._textures=new Map,this.ensureDrapedStatus(!1)}async doLoad(){se.DRAW_MESH_GEOMETRY_NORMALS&&(this._debugVertexNormalMaterial=new de({color:[1,0,1,1]}),this._debugFaceNormalMaterial=new de({color:[0,1,1,1]}))}destroy(){super.destroy(),this._textures.forEach((e=>e.unload())),this._context.stage.removeMany(this._materialInfoCache.materials),this._context.stage.removeMany(Array.from(this._textures.values())),this._materialInfoCache.clear(),this._textures.clear(),this._fastUpdateProcessor.destroy(this._context.stage)}get materials(){return this._materialInfoCache.materials}createGraphics3DGraphic(e){const t=e.graphic;if(!this._validateGeometry(t.geometry,ye,"fill on mesh-3d"))return null;const r=this.setGraphicElevationContext(t),o=e.renderingInfo;return this._createAs3DShape(t,o,r,t.uid)}onRemoveGraphic(e){this._fastUpdateProcessor.onRemoveGraphic(e,this._materialInfoCache,this._context)}layerOpacityChanged(e,t){const r=this._getLayerOpacity();this._updateMaterialParameters((e=>{e.material.setParameters({layerOpacity:r});const t=e.material.parameters;this._setMaterialTransparentParameter(t,e),e.material.setParameters({transparent:t.transparent})})),e.forEach((e=>t(e)?.layerOpacityChanged(r,this._context.isAsync)))}layerElevationInfoChanged(e,t){return this.updateGraphics3DGraphicElevationInfo(e,t,Z)}slicePlaneEnabledChanged(e,t){return this._updateMaterialParameters((({material:e})=>{e.setParameters({hasSlicePlane:this._context.slicePlaneEnabled})})),e.forEach((e=>t(e)?.slicePlaneEnabledChanged(this._context.slicePlaneEnabled,this._context.isAsync))),!0}physicalBasedRenderingChanged(){const e=this._usePBR();return this._updateMaterialParameters((({material:t})=>t.setParameters({usePBR:e}))),!0}updateTransform(e,t,r,o){const a=this._context.renderCoordsHelper.spatialReference,s=Ae,{origin:n,transform:i}=r;switch(C(t,m(je,n.x,n.y,n.z??0),s,a),o){case H.EnableFastUpdates:this._fastUpdateProcessor.enable(e,this._materialInfoCache,this._context);break;case H.DisableFastUpdates:this._fastUpdateProcessor.disable(e,this._materialInfoCache,this._context);break;case H.UpdateFastLocalOrigin:e.updateFastLocalOrigin(s,i,this._context.localOriginFactory)}const{elevationContext:l}=e;l.centerPointInElevationSR=this._getCenterPointInElevationSR(s);const{elevationProvider:c,renderCoordsHelper:u}=this._context,h=(e,t)=>J(e,c,l,u,t);return e.alignedSampledElevation=Y(e,l,c.spatialReference,h,u,s),e.updateTransform(s,i,this._context.isAsync),!0}_requiresSymbolVertexColors(){return this._drivenProperties.color||this._drivenProperties.opacity}_colorOrTextureUid(t){return null==t?"-":t instanceof e?t.toHex():t.contentHash}_materialPropertiesDefault(e,t){const r=this._requiresSymbolVertexColors(),o=!!e.vertexAttributes.color,a=!!e.vertexAttributes.tangent;return{hasSymbolVertexColors:r,hasVertexColors:o,hasVertexTangents:a,uid:`vc:${o},vt:${a},vct${t},svc:${r}`}}_textureTransformUid(e){const{offset:t,scale:r,rotation:o}=e??Ne;return`${t[0]},${t[1]},${o},${r[0]},${r[1]}`}_materialProperties(e,t,r){const o=this._materialPropertiesDefault(e,r);if(!t.material)return o;const{color:a,colorTexture:s,colorTextureTransform:n,normalTexture:i,normalTextureTransform:l,doubleSided:c,alphaCutoff:u,alphaMode:m}=t.material,h=this._colorOrTextureUid(a),f=this._colorOrTextureUid(s),p=this._textureTransformUid(n),d=this._colorOrTextureUid(i),g=this._textureTransformUid(l);if(o.color=a,o.colorTexture=s,o.normalTexture=i,o.uid=`${o.uid},cmuid:${h},ctmuid:${f},cttuid:${p},ntmuid:${d},nttuid:${g},ds:${c},ac:${u},am:${m}`,t.material instanceof B){const{metallic:e,roughness:r,metallicRoughnessTexture:a,metallicRoughnessTextureTransform:s,emissiveColor:i,emissiveTexture:c,emissiveTextureTransform:u,occlusionTexture:m,occlusionTextureTransform:h}=t.material,f=this._colorOrTextureUid(a),p=this._textureTransformUid(s),d=this._colorOrTextureUid(i),g=this._colorOrTextureUid(c),x=this._textureTransformUid(u),_=this._colorOrTextureUid(m),T=this._textureTransformUid(h);o.metallic=e,o.roughness=r,o.metallicRoughnessTexture=a,o.emissiveColor=i,o.emissiveTexture=c,o.occlusionTexture=m,o.colorTextureTransform=this._convertTextureTransform(n),o.normalTextureTransform=this._convertTextureTransform(l),o.emissiveTextureTransform=this._convertTextureTransform(u),o.occlusionTextureTransform=this._convertTextureTransform(h),o.metallicRoughnessTextureTransform=this._convertTextureTransform(s),o.uid=`${o.uid},mrm:${e},mrr:${r},mrt:${f},mrtt:${p},emuid:${d},etmuid:${g},ett:${x},otmuid:${_},ott:${T}`}return o}_convertTextureTransform(e){if(!e)return null;const{scale:r,offset:o,rotation:a}=e;return{scale:r,offset:o,rotation:t(a)}}_setInternalColorValueParameters(t,r){r.diffuse=e.toUnitRGB(t),r.opacity=t.a}_getLoadableTextureResource(e){return e.data??e.url}_getInternalTextureId(e){const t=this._getInternalTexture(e,ie.Opaque);return t?.id}_getInternalTexture(e,t){const r=this._getLoadableTextureResource(e);if(!r)return null;const o=`${e.contentHash}/${t}`;let a=this._textures.get(o);return a||(a=new he(W(r)?r.data:r,{mipmap:!0,wrap:this._castTextureWrap(e.wrap),noUnpackFlip:!0,preMultiplyAlpha:!W(r)&&t!==ie.Opaque,encoding:W(r)&&null!=r.encoding?r.encoding:void 0}),this._textures.set(o,a),a.load(this._context.stage.renderView.renderingContext),this._context.stage.add(a)),a}_castTextureWrap(e="repeat"){if("string"==typeof e){const t=this._castTextureWrapIndividual(e);return{s:t,t}}return{s:this._castTextureWrapIndividual(e.horizontal),t:this._castTextureWrapIndividual(e.vertical)}}_castTextureWrapIndividual(e){switch(e){case"clamp":return Te.CLAMP_TO_EDGE;case"mirror":return Te.MIRRORED_REPEAT;default:return Te.REPEAT}}_setInternalMaterialParameters(t,r){if(null!=t.color&&this._setInternalColorValueParameters(t.color,r),null!=t.colorTexture){const e=this._getInternalTexture(t.colorTexture,r.textureAlphaMode);e?(r.textureId=e.id,r.textureAlphaPremultiplied=!!e.parameters.preMultiplyAlpha):r.textureId=void 0}t.normalTexture&&(r.normalTextureId=this._getInternalTextureId(t.normalTexture)),t.emissiveColor&&(r.emissiveFactor=e.toUnitRGB(t.emissiveColor)),t.emissiveTexture&&(r.emissiveTextureId=this._getInternalTextureId(t.emissiveTexture)),t.occlusionTexture&&(r.occlusionTextureId=this._getInternalTextureId(t.occlusionTexture)),t.metallicRoughnessTexture&&(r.metallicRoughnessTextureId=this._getInternalTextureId(t.metallicRoughnessTexture)),r.colorTextureTransformMatrix=z(t.colorTextureTransform),r.normalTextureTransformMatrix=z(t.normalTextureTransform),r.occlusionTextureTransformMatrix=z(t.occlusionTextureTransform),r.emissiveTextureTransformMatrix=z(t.emissiveTextureTransform),r.metallicRoughnessTextureTransformMatrix=z(t.metallicRoughnessTextureTransform)}_setExternalMaterialParameters(t){const r=this._drivenProperties.color;let o=this.symbolLayer.material?.colorMixMode??null;if(r)t.externalColor=b;else{const r=this.symbolLayer.material?.color??null;r?t.externalColor=e.toUnitRGBA(r):(o=null,t.externalColor=b)}o&&(t.colorMixMode=o),t.castShadows=!!this.symbolLayer.castShadows}_hasTransparentVertexColors(e){const t=e.vertexAttributes.color;if(null==t)return!1;for(let r=3;r<t.length;r+=4)if(255!==t[r])return!0;return!1}_getOrCreateMaterial(t,r){const o=r.material?.color,a=r.material?.colorTexture,s=r.material?.alphaMode,n="blend"===s,i=!("opaque"===s)&&(this._hasTransparentVertexColors(t)||null!=o&&o.a<1||a?.transparent||n),l=this._materialProperties(t,r,i),c=this._materialInfoCache.byUid(l.uid);if(c)return c.material;const u={uid:l.uid,material:null,isComponentTransparent:i,alphaMode:r.material?r.material.alphaMode:"opaque"},m=ge({normalTexture:l.normalTexture,metallicRoughnessTexture:l.metallicRoughnessTexture,metallicFactor:l.metallic,roughnessFactor:l.roughness,emissiveTexture:l.emissiveTexture,emissiveFactor:e.toUnitRGB(l.emissiveColor),occlusionTexture:l.occlusionTexture}),h={usePBR:this._usePBR(),isSchematic:m,hasVertexColors:l.hasVertexColors,hasSymbolColors:l.hasSymbolVertexColors,hasVertexTangents:l.hasVertexTangents,ambient:_,diffuse:T,opacity:1,doubleSided:!0,doubleSidedType:"winding-order",cullFace:le.None,layerOpacity:this._getLayerOpacity(),hasSlicePlane:this._context.slicePlaneEnabled,initTextureTransparent:!0};h.mrrFactors=m?[...xe]:[l.metallic,l.roughness,_e[2]],r.material&&(h.doubleSided=r.material.doubleSided,h.cullFace=r.material.doubleSided?le.None:le.Back,h.textureAlphaCutoff=r.material.alphaCutoff),this._setExternalMaterialParameters(h),this._setMaterialTransparentParameter(h,u),this._setInternalMaterialParameters(l,h);const f=new pe(h);return u.material=f,this._materialInfoCache.set(l.uid,u),this._context.stage.add(f),f}_usePBR(){return this._context.physicalBasedRenderingEnabled}_setMaterialTransparentParameter(e,t){e.transparent=this.needsDrivenTransparentPass||t.isComponentTransparent||e.layerOpacity<1||e.opacity<1||e.externalColor&&e.externalColor[3]<1,"auto"===t.alphaMode?e.textureAlphaMode=e.transparent?ie.MaskBlend:ie.Opaque:e.textureAlphaMode="opaque"===t.alphaMode?ie.Opaque:"mask"===t.alphaMode?ie.Mask:ie.Blend}_addDebugNormals(e,t){const r=t.length,o=e.spatialReference.isGeographic?20015077/180:1,a=.1*Math.max(e.extent.width*o,e.extent.height*o,e.extent.zmax-e.extent.zmin),s=[],n=[],i=[],l=[];for(let p=0;p<r;p++){const e=t[p],r=e.vertexAttributes.get(fe.POSITION),o=e.vertexAttributes.get(fe.NORMAL),c=e.indices.get(fe.POSITION),u=e.indices.get(fe.NORMAL),m=r.data,d=o.data;for(let t=0;t<c.length;t++){const e=3*c[t],r=3*u[t];for(let t=0;t<3;t++)s.push(m[e+t]);for(let t=0;t<3;t++)s.push(m[e+t]+d[r+t]*a);if(n.push(n.length),n.push(n.length),t%3==0){this._calculateFaceNormal(m,c,t,Me),this._getFaceVertices(m,c,t,je,we,Oe),h(je,je,we),h(je,je,Oe),f(je,je,1/3);for(let e=0;e<3;e++)i.push(je[e]);for(let e=0;e<3;e++)i.push(je[e]+Me[e]*a);l.push(l.length),l.push(l.length)}}}const c=t[0].transformation,u=new ue(this._debugVertexNormalMaterial,[[fe.POSITION,new ne(s,3,!0),n]],null,ce.Line);t.push(u),u.transformation=c;const m=new ue(this._debugFaceNormalMaterial,[[fe.POSITION,new ne(i,3,!0),l]],null,ce.Line);m.transformation=c,t.push(m)}_createAs3DShape(e,t,r,o){const a=e.geometry;if("mesh"!==a.type)return null;const s=this._createGeometryInfo(a,t,o);if(null==s)return null;const{geometries:n,objectTransformation:i}=s;se.DRAW_MESH_GEOMETRY_NORMALS&&this._addDebugNormals(a,n);const l=new me({geometries:n,layerUid:this._context.layer.uid,graphicUid:o});l.transformation=i;const c=re(this.symbolLayer,{opacity:this._getLayerOpacity()}),u=c?new Q(n[0].material,[c],{mergeGeometries:!0,hasSlicePlane:this._context.slicePlaneEnabled}):null,m=new K(this,l,n,null,null,Y,r,u);this._fastUpdateProcessor.onAddGraphic(),m.needsElevationUpdates=Z(r.mode),m.useObjectOriginAsAttachmentOrigin=!0,r.centerPointInElevationSR=this._getCenterPointInElevationSR(l.transformation);const{elevationProvider:h,renderCoordsHelper:f}=this._context,p=(e,t)=>J(e,h,r,f,t);return m.alignedSampledElevation=Y(m,r,h.spatialReference,p,f),m}_getCenterPointInElevationSR(e){const t=k(0,0,0,null!=this._context.elevationProvider.spatialReference?this._context.elevationProvider.spatialReference:null);return w([e[12],e[13],e[14]],this._context.renderCoordsHelper.spatialReference,t),t}_createComponentNormals(e,t,r,o){switch(r.shading||"flat"){default:case"source":return this._createComponentNormalsSource(e,t,r,o);case"flat":return this._createComponentNormalsFlat(e,o);case"smooth":return this._createComponentNormalsSmooth(e,o)}}_createComponentNormalsSource(e,t,r,o){if(null==t)return this._createComponentNormalsFlat(e,o);let a=!1;if(!r.trustSourceNormals)for(let s=0;s<o.length;s+=3){this._calculateFaceNormal(e,o,s,Me);for(let e=0;e<3;e++){const r=3*o[s+e];je[0]=t[r],je[1]=t[r+1],je[2]=t[r+2],p(Me,je)<0&&(t[r]=-t[r],t[r+1]=-t[r+1],t[r+2]=-t[r+2],a=!0)}}return new ve(t,o,a)}_createComponentNormalsFlat(e,t){const r=A(t.length),o=new Array(3*t.length);for(let a=0;a<t.length;a+=3){const s=this._calculateFaceNormal(e,t,a,Me);for(let e=0;e<3;e++)r[a+e]=s[e],o[a+e]=a/3}return new ve(r,o,!1)}_createComponentNormalsSmooth(e,t){const r={};for(let s=0;s<t.length;s+=3){const o=this._calculateFaceNormal(e,t,s,Me);for(let e=0;e<3;e++){const a=t[s+e];let n=r[a];n||(n={normal:y(),count:0},r[a]=n),h(n.normal,n.normal,o),n.count++}}const o=A(3*t.length),a=new Array(3*t.length);for(let s=0;s<t.length;s++){const e=r[t[s]];1!==e.count&&(d(e.normal,e.normal),e.count=1);for(let t=0;t<3;t++)o[3*s+t]=e.normal[t];a[s]=s}return new ve(o,a,!1)}_getFaceVertices(e,t,r,o,a,s){const n=3*t[r],i=3*t[r+1],l=3*t[r+2];o[0]=e[n],o[1]=e[n+1],o[2]=e[n+2],a[0]=e[i],a[1]=e[i+1],a[2]=e[i+2],s[0]=e[l],s[1]=e[l+1],s[2]=e[l+2]}_calculateFaceNormal(e,t,r,o){return this._getFaceVertices(e,t,r,je,we,Oe),g(we,we,je),g(Oe,Oe,je),x(je,we,Oe),d(o,je),o}_getOrCreateComponents(e){return e.components??Ee}_createPositionBuffer(e,t){let r=e.vertexAttributes.position;const o=t.reprojection===Be.ECEF?t.transformBeforeProject:null;if(o&&(r=S(new Float64Array(r.length),r,o)),t.reprojection===Be.NONE)return t.needsBufferCopy?new Float64Array(r):r;const a=o?r:new Float64Array(r.length);return j(r,e.spatialReference,0,a,this._context.renderCoordsHelper.spatialReference,0,r.length/3),a}_createNormalBuffer(e,t,r){let o=e.vertexAttributes.normal;if(null==o)return null;const a=r.reprojection===Be.ECEF?r.transformBeforeProject:null;a&&(o=$(o,new Float32Array(o.length),a));if("local"===this._context.graphicsCoreOwner.view.viewingMode||r.reprojection===Be.NONE)return r.needsBufferCopy&&e.vertexAttributes.normal===o?new Float32Array(o):o;const s=e.vertexAttributes.position,n=a?o:new Float32Array(o.length);return G(o,s,t,e.spatialReference,n)}_createTangentBuffer(e,t,r){let o=e.vertexAttributes.tangent;if(null==o)return null;const a=r.reprojection===Be.ECEF?r.transformBeforeProject:null;a&&(o=V(o,new Float32Array(o.length),a));if("local"===this._context.graphicsCoreOwner.view.viewingMode||r.reprojection===Be.NONE)return r.needsBufferCopy&&e.vertexAttributes.normal===o?new Float32Array(o):o;const s=e.vertexAttributes.position,n=a?o:new Float32Array(o.length);return D(o,s,t,e.spatialReference,n)}_createColorBuffer(e){return e.vertexAttributes.color}_createSymbolColorBuffer(e){if(this._requiresSymbolVertexColors()){const t=this._getVertexOpacityAndColor(e),r=oe(this.symbolLayer?.material?.colorMixMode),o=new Uint8Array(4);return ae(t,r,o),o}return null}_createBuffers(e,t){const r=e.vertexAttributes&&e.vertexAttributes.position;if(!r)return this.logger.warn("Mesh geometry must contain position vertex attributes"),null;const o=e.vertexAttributes.normal,a=e.vertexAttributes.uv,s=e.vertexAttributes.tangent;if(o&&o.length!==r.length)return this.logger.warn("Mesh normal vertex buffer must contain the same number of elements as the position buffer"),null;if(s&&s.length/4!=r.length/3)return this.logger.warn("Mesh tangent vertex buffer must contain the same number of elements as the position buffer"),null;if(a&&a.length/2!=r.length/3)return this.logger.warn("Mesh uv vertex buffer must contain the same number of elements as the position buffer"),null;const n=this._computeReprojectionInfo(e),i=this._createPositionBuffer(e,n),c=this._createColorBuffer(e),u=this._createSymbolColorBuffer(t),m=this._createNormalBuffer(e,i,n),h=this._createTangentBuffer(e,i,n);return{positionBuffer:i,normalBuffer:m,tangentBuffer:h,uvBuffer:a,colorBuffer:c,symbolColorBuffer:u,objectTransformation:n.reprojection===Be.NONE&&n.objectTransformation?n.objectTransformation:this._transformOriginLocal(e,i,m,h),geometryTransformation:n.reprojection===Be.NONE&&n.geometryTransformation?n.geometryTransformation:l()}}_computeReprojectionInfo(e){const{vertexSpace:t}=e,r=t.isRelative,o=t.isGeoreferenced?this._context.renderCoordsHelper.viewingMode===q.Local?Be.NONE:Be.ECEF:Be.NONE;if(r){const{origin:r}=t,a=l(),i=e.transform?.localMatrix??c;if(o===Be.NONE){C(e.spatialReference,r,a,this._context.renderCoordsHelper.spatialReference);return{reprojection:o,objectTransformation:a,geometryTransformation:u(i),needsBufferCopy:!1}}const m=s(l(),r);return n(m,m,i),{reprojection:o,transformBeforeProject:m,needsBufferCopy:!0}}return{reprojection:o,needsBufferCopy:!0}}_transformOriginLocal(e,t,a,s){const n=this._context.renderCoordsHelper.spatialReference,c=e.anchor;Ce[0]=c.x,Ce[1]=c.y,Ce[2]=c.z??0;const u=l();return C(e.spatialReference,Ce,u,n),i(Pe,u),S(t,t,Pe),(a||s)&&(r(Re,u),o(Re,Re),a&&U(a,a,Re),s&&U(s,s,Re,4)),u}_validateFaces(e,t){const r=e.vertexAttributes.position.length/3,o=t.faces;if(o){let e=-1;for(let t=0;t<o.length;t++){const r=o[t];r>e&&(e=r)}if(r<=e)return this.logger.warn(`Vertex index ${e} is out of bounds of the mesh position buffer`),!1}else if(r%3!=0)return this.logger.warn("Mesh position buffer length must be a multiple of 9 if no component faces are defined (3 values per vertex * 3 vertices per triangle)"),!1;return!0}_getOrCreateFaces(e,t){return t.faces??I(e.vertexAttributes.position.length/3)}_isOutsideClippingArea(e){if(!this._context.clippingExtent)return!1;const t=e.vertexAttributes?.position;if(!t)return!1;const r=this._context.elevationProvider.spatialReference,o=L({positions:t,transform:e.transform,vertexSpace:e.vertexSpace,inSpatialReference:e.spatialReference,outSpatialReference:r??e.spatialReference}),a=o.length/3;return M(Ie),P(Ie,o,0,a),!R(Ie,this._context.clippingExtent)}_createGeometryInfo(e,t,r){if(!v(e.spatialReference,this._context.graphicsCoreOwner.view.spatialReference))return this.logger.warn("Geometry spatial reference is not compatible with the view"),null;if(this._isOutsideClippingArea(e))return null;const o=this._createBuffers(e,t);if(null==o)return null;const{positionBuffer:a,uvBuffer:s,colorBuffer:n,symbolColorBuffer:i,normalBuffer:l,tangentBuffer:c,objectTransformation:u,geometryTransformation:m}=o,h=this._getOrCreateComponents(e),f=new Array;let p=!1;for(const d of h){if(!this._validateFaces(e,d))return null;const t=this._getOrCreateFaces(e,d);if(0===t.length)continue;const o=this._createComponentNormals(a,l,d,t);o.didFlipNormals&&(p=!0);const u=[[fe.POSITION,new ne(a,3,!0),t],[fe.NORMAL,new ne(o.normals,3,!0),o.indices]];n&&u.push([fe.COLOR,new ne(n,4,!0),t]),i&&u.push([fe.SYMBOLCOLOR,new ne(i,4,!0),E(t.length)]),s&&u.push([fe.UV0,new ne(s,2,!0),t]),c&&u.push([fe.TANGENT,new ne(c,4,!0),t]);const h=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:r,layerUid:this._context.layer.uid}),g=this._getOrCreateMaterial(e,d),x=new ue(g,u,null,ce.Mesh,h);x.transformation=m,f.push(x)}return p&&this.logger.warn("Normals have been automatically flipped to be consistent with the counter clock wise face winding order. It is better to generate mesh geometries that have consistent normals."),{geometries:f,objectTransformation:u}}_updateMaterialParameters(e){this._materialInfoCache.forEachMaterialInfo(e),this._fastUpdateProcessor.forEachMaterialInfo(e),this._fastUpdateProcessor.forEachClonedMaterial(((e,t)=>{t.setParameters(e.parameters)}))}test(){return{...super.test(),materials:this._materialInfoCache.materials}}}class ve{constructor(e,t,r){this.normals=e,this.indices=t,this.didFlipNormals=r}}const Ce=y(),je=y(),we=y(),Oe=y(),Me=y(),Pe=l(),Re=a(),Ae=l(),Ie=O(),Ee=[new N],Ne=new F;var Be;!function(e){e[e.NONE=0]="NONE",e[e.ECEF=1]="ECEF"}(Be||(Be={}));export{be as Graphics3DMeshFillSymbolLayer};
5
+ import e from"../../../../Color.js";import"../../../../core/has.js";import{deg2rad as t}from"../../../../core/mathUtils.js";import{f as r,t as o}from"../../../../chunks/mat3.js";import{a}from"../../../../chunks/mat3f64.js";import{d as s,m as n,i}from"../../../../chunks/mat4.js";import{a as l,I as c,b as u}from"../../../../chunks/mat4f64.js";import{s as m,g as h,i as f,j as p,n as d,f as g,b as x}from"../../../../chunks/vec3.js";import{Z as _,O as T,c as y}from"../../../../chunks/vec3f64.js";import{O as b}from"../../../../chunks/vec4f64.js";import{canProjectWithoutEngine as v}from"../../../../geometry/projection.js";import{computeTranslationToOriginAndRotation as C}from"../../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{projectBuffer as j}from"../../../../geometry/projection/projectBuffer.js";import{projectVectorToDehydratedPoint as w}from"../../../../geometry/projection/projectVectorToDehydratedPoint.js";import{create as M,empty as O,expandWithBuffer as P,intersectsClippingArea as R}from"../../../../geometry/support/aaBoundingBox.js";import{newFloatArray as A}from"../../../../geometry/support/FloatArray.js";import{getContinuousIndexArray as E,getZeroIndexArray as I}from"../../../../geometry/support/Indices.js";import N from"../../../../geometry/support/MeshComponent.js";import B from"../../../../geometry/support/MeshMaterialMetallicRoughness.js";import F from"../../../../geometry/support/MeshTextureTransform.js";import{t as S,a as U}from"../../../../chunks/vec32.js";import{project as L}from"../../../../geometry/support/meshUtils/georeference.js";import{transformNormal as $,projectNormalToPCPF as G,transformTangent as V,projectTangentToPCPF as D}from"../../../../geometry/support/meshUtils/projection.js";import{makeDehydratedPoint as k}from"../../../../layers/graphics/dehydratedPoint.js";import{MeshTransformUpdateAction as H}from"../../../../layers/graphics/sources/interfaces.js";import{ViewingMode as q}from"../../../ViewingMode.js";import{isEncodedMeshTexture as W}from"../../glTF/internal/resourceUtils.js";import{getTransformMatrix as z}from"../../glTF/internal/TextureTransformUtils.js";import{perObjectElevationAligner as Y}from"./ElevationAligners.js";import{needsElevationUpdates3D as Z,evaluateElevationInfoAtPoint as J}from"./elevationAlignmentUtils.js";import{Graphics3DMeshObject3DGraphicLayer as K}from"./Graphics3DMeshObject3DGraphicLayer.js";import{Object3DEdgeState as Q}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as X}from"./Graphics3DSymbolLayer.js";import{MaterialInfoCache as ee,MeshFastUpdateProcessor as te}from"./MeshFastUpdateProcessor.js";import{createMaterial as re}from"../support/edgeUtils.js";import{parseColorMixMode as oe,encodeSymbolColor as ae}from"../support/symbolColorUtils.js";import{debugFlags as se}from"../../support/debugFlags.js";import{Attribute as ne}from"../../webgl-engine/lib/Attribute.js";import{AlphaDiscardMode as ie,CullFaceOptions as le}from"../../webgl-engine/lib/basicInterfaces.js";import{ContentObjectType as ce}from"../../webgl-engine/lib/ContentObjectType.js";import{Geometry as ue}from"../../webgl-engine/lib/Geometry.js";import{Object3D as me}from"../../webgl-engine/lib/Object3D.js";import{Texture as he}from"../../webgl-engine/lib/Texture.js";import{VertexAttribute as fe}from"../../webgl-engine/lib/VertexAttribute.js";import{DefaultMaterial as pe}from"../../webgl-engine/materials/DefaultMaterial.js";import{NativeLineMaterial as de}from"../../webgl-engine/materials/NativeLineMaterial.js";import{useSchematicPBR as ge,defaultSchematicMRRFactors as xe,defaultAdvancedMRRFactors as _e}from"../../webgl-engine/materials/pbrUtils.js";import{TextureWrapMode as Te}from"../../../webgl/enums.js";const ye=["mesh"];class be extends X{constructor(e,t,r,o){super(e,t,r,o),this._materialInfoCache=new ee,this._fastUpdateProcessor=new te,this._textures=new Map,this.ensureDrapedStatus(!1)}async doLoad(){se.DRAW_MESH_GEOMETRY_NORMALS&&(this._debugVertexNormalMaterial=new de({color:[1,0,1,1]}),this._debugFaceNormalMaterial=new de({color:[0,1,1,1]}))}destroy(){super.destroy(),this._textures.forEach((e=>e.unload())),this._context.stage.removeMany(this._materialInfoCache.materials),this._context.stage.removeMany(Array.from(this._textures.values())),this._materialInfoCache.clear(),this._textures.clear(),this._fastUpdateProcessor.destroy(this._context.stage)}get materials(){return this._materialInfoCache.materials}createGraphics3DGraphic(e){const t=e.graphic;if(!this._validateGeometry(t.geometry,ye,"fill on mesh-3d"))return null;const r=this.setGraphicElevationContext(t),o=e.renderingInfo;return this._createAs3DShape(t,o,r,t.uid)}onRemoveGraphic(e){this._fastUpdateProcessor.onRemoveGraphic(e,this._materialInfoCache,this._context)}layerOpacityChanged(e,t){const r=this._getLayerOpacity();this._updateMaterialParameters((e=>{e.material.setParameters({layerOpacity:r});const t=e.material.parameters;this._setMaterialTransparentParameter(t,e),e.material.setParameters({transparent:t.transparent})})),e.forEach((e=>t(e)?.layerOpacityChanged(r,this._context.isAsync)))}layerElevationInfoChanged(e,t){return this.updateGraphics3DGraphicElevationInfo(e,t,Z)}slicePlaneEnabledChanged(e,t){return this._updateMaterialParameters((({material:e})=>{e.setParameters({hasSlicePlane:this._context.slicePlaneEnabled})})),e.forEach((e=>t(e)?.slicePlaneEnabledChanged(this._context.slicePlaneEnabled,this._context.isAsync))),!0}physicalBasedRenderingChanged(){const e=this._usePBR();return this._updateMaterialParameters((({material:t})=>t.setParameters({usePBR:e}))),!0}updateTransform(e,t,r,o){const a=this._context.renderCoordsHelper.spatialReference,s=Ae,{origin:n,transform:i}=r;switch(C(t,m(je,n.x,n.y,n.z??0),s,a),o){case H.EnableFastUpdates:this._fastUpdateProcessor.enable(e,this._materialInfoCache,this._context);break;case H.DisableFastUpdates:this._fastUpdateProcessor.disable(e,this._materialInfoCache,this._context);break;case H.UpdateFastLocalOrigin:e.updateFastLocalOrigin(s,i,this._context.localOriginFactory)}const{elevationContext:l}=e;l.centerPointInElevationSR=this._getCenterPointInElevationSR(s);const{elevationProvider:c,renderCoordsHelper:u}=this._context,h=(e,t)=>J(e,c,l,u,t);return e.alignedSampledElevation=Y(e,l,c.spatialReference,h,u,s),e.updateTransform(s,i,this._context.isAsync),!0}_requiresSymbolVertexColors(){return this._drivenProperties.color||this._drivenProperties.opacity}_colorOrTextureUid(t){return null==t?"-":t instanceof e?t.toHex():t.contentHash}_materialPropertiesDefault(e,t){const r=this._requiresSymbolVertexColors(),o=!!e.vertexAttributes.color,a=!!e.vertexAttributes.tangent;return{hasSymbolVertexColors:r,hasVertexColors:o,hasVertexTangents:a,uid:`vc:${o},vt:${a},vct${t},svc:${r}`}}_textureTransformUid(e){const{offset:t,scale:r,rotation:o}=e??Ne;return`${t[0]},${t[1]},${o},${r[0]},${r[1]}`}_materialProperties(e,t,r){const o=this._materialPropertiesDefault(e,r);if(!t.material)return o;const{color:a,colorTexture:s,colorTextureTransform:n,normalTexture:i,normalTextureTransform:l,doubleSided:c,alphaCutoff:u,alphaMode:m}=t.material,h=this._colorOrTextureUid(a),f=this._colorOrTextureUid(s),p=this._textureTransformUid(n),d=this._colorOrTextureUid(i),g=this._textureTransformUid(l);if(o.color=a,o.colorTexture=s,o.normalTexture=i,o.uid=`${o.uid},cmuid:${h},ctmuid:${f},cttuid:${p},ntmuid:${d},nttuid:${g},ds:${c},ac:${u},am:${m}`,t.material instanceof B){const{metallic:e,roughness:r,metallicRoughnessTexture:a,metallicRoughnessTextureTransform:s,emissiveColor:i,emissiveTexture:c,emissiveTextureTransform:u,occlusionTexture:m,occlusionTextureTransform:h}=t.material,f=this._colorOrTextureUid(a),p=this._textureTransformUid(s),d=this._colorOrTextureUid(i),g=this._colorOrTextureUid(c),x=this._textureTransformUid(u),_=this._colorOrTextureUid(m),T=this._textureTransformUid(h);o.metallic=e,o.roughness=r,o.metallicRoughnessTexture=a,o.emissiveColor=i,o.emissiveTexture=c,o.occlusionTexture=m,o.colorTextureTransform=this._convertTextureTransform(n),o.normalTextureTransform=this._convertTextureTransform(l),o.emissiveTextureTransform=this._convertTextureTransform(u),o.occlusionTextureTransform=this._convertTextureTransform(h),o.metallicRoughnessTextureTransform=this._convertTextureTransform(s),o.uid=`${o.uid},mrm:${e},mrr:${r},mrt:${f},mrtt:${p},emuid:${d},etmuid:${g},ett:${x},otmuid:${_},ott:${T}`}return o}_convertTextureTransform(e){if(!e)return null;const{scale:r,offset:o,rotation:a}=e;return{scale:r,offset:o,rotation:t(a)}}_setInternalColorValueParameters(t,r){r.diffuse=e.toUnitRGB(t),r.opacity=t.a}_getLoadableTextureResource(e){return e.data??e.url}_getInternalTextureId(e){const t=this._getInternalTexture(e,ie.Opaque);return t?.id}_getInternalTexture(e,t){const r=this._getLoadableTextureResource(e);if(!r)return null;const o=`${e.contentHash}/${t}`;let a=this._textures.get(o);return a||(a=new he(W(r)?r.data:r,{mipmap:!0,wrap:this._castTextureWrap(e.wrap),noUnpackFlip:!0,preMultiplyAlpha:!W(r)&&t!==ie.Opaque,encoding:W(r)&&null!=r.encoding?r.encoding:void 0}),this._textures.set(o,a),a.load(this._context.stage.renderView.renderingContext),this._context.stage.add(a)),a}_castTextureWrap(e="repeat"){if("string"==typeof e){const t=this._castTextureWrapIndividual(e);return{s:t,t}}return{s:this._castTextureWrapIndividual(e.horizontal),t:this._castTextureWrapIndividual(e.vertical)}}_castTextureWrapIndividual(e){switch(e){case"clamp":return Te.CLAMP_TO_EDGE;case"mirror":return Te.MIRRORED_REPEAT;default:return Te.REPEAT}}_setInternalMaterialParameters(t,r){if(null!=t.color&&this._setInternalColorValueParameters(t.color,r),null!=t.colorTexture){const e=this._getInternalTexture(t.colorTexture,r.textureAlphaMode);e?(r.textureId=e.id,r.textureAlphaPremultiplied=!!e.parameters.preMultiplyAlpha):r.textureId=void 0}t.normalTexture&&(r.normalTextureId=this._getInternalTextureId(t.normalTexture)),t.emissiveColor&&(r.emissiveFactor=e.toUnitRGB(t.emissiveColor)),t.emissiveTexture&&(r.emissiveTextureId=this._getInternalTextureId(t.emissiveTexture)),t.occlusionTexture&&(r.occlusionTextureId=this._getInternalTextureId(t.occlusionTexture)),t.metallicRoughnessTexture&&(r.metallicRoughnessTextureId=this._getInternalTextureId(t.metallicRoughnessTexture)),r.colorTextureTransformMatrix=z(t.colorTextureTransform),r.normalTextureTransformMatrix=z(t.normalTextureTransform),r.occlusionTextureTransformMatrix=z(t.occlusionTextureTransform),r.emissiveTextureTransformMatrix=z(t.emissiveTextureTransform),r.metallicRoughnessTextureTransformMatrix=z(t.metallicRoughnessTextureTransform)}_setExternalMaterialParameters(t){const r=this._drivenProperties.color;let o=this.symbolLayer.material?.colorMixMode??null;if(r)t.externalColor=b;else{const r=this.symbolLayer.material?.color??null;r?t.externalColor=e.toUnitRGBA(r):(o=null,t.externalColor=b)}o&&(t.colorMixMode=o),t.castShadows=!!this.symbolLayer.castShadows}_hasTransparentVertexColors(e){const t=e.vertexAttributes.color;if(null==t)return!1;for(let r=3;r<t.length;r+=4)if(255!==t[r])return!0;return!1}_getOrCreateMaterial(t,r){const o=r.material?.color,a=r.material?.colorTexture,s=r.material?.alphaMode,n="blend"===s,i=!("opaque"===s)&&(this._hasTransparentVertexColors(t)||null!=o&&o.a<1||a?.transparent||n),l=this._materialProperties(t,r,i),c=this._materialInfoCache.byUid(l.uid);if(c)return c.material;const u={uid:l.uid,material:null,isComponentTransparent:i,alphaMode:r.material?r.material.alphaMode:"opaque"},m=ge({normalTexture:l.normalTexture,metallicRoughnessTexture:l.metallicRoughnessTexture,metallicFactor:l.metallic,roughnessFactor:l.roughness,emissiveTexture:l.emissiveTexture,emissiveFactor:e.toUnitRGB(l.emissiveColor),occlusionTexture:l.occlusionTexture}),h={usePBR:this._usePBR(),isSchematic:m,hasVertexColors:l.hasVertexColors,hasSymbolColors:l.hasSymbolVertexColors,hasVertexTangents:l.hasVertexTangents,ambient:_,diffuse:T,opacity:1,doubleSided:!0,doubleSidedType:"winding-order",cullFace:le.None,layerOpacity:this._getLayerOpacity(),hasSlicePlane:this._context.slicePlaneEnabled,initTextureTransparent:!0};h.mrrFactors=m?[...xe]:[l.metallic,l.roughness,_e[2]],r.material&&(h.doubleSided=r.material.doubleSided,h.cullFace=r.material.doubleSided?le.None:le.Back,h.textureAlphaCutoff=r.material.alphaCutoff),this._setExternalMaterialParameters(h),this._setMaterialTransparentParameter(h,u),this._setInternalMaterialParameters(l,h);const f=new pe(h);return u.material=f,this._materialInfoCache.set(l.uid,u),this._context.stage.add(f),f}_usePBR(){return this._context.physicalBasedRenderingEnabled}_setMaterialTransparentParameter(e,t){e.transparent=this.needsDrivenTransparentPass||t.isComponentTransparent||e.layerOpacity<1||e.opacity<1||e.externalColor&&e.externalColor[3]<1,"auto"===t.alphaMode?e.textureAlphaMode=e.transparent?ie.MaskBlend:ie.Opaque:e.textureAlphaMode="opaque"===t.alphaMode?ie.Opaque:"mask"===t.alphaMode?ie.Mask:ie.Blend}_addDebugNormals(e,t){const r=t.length,o=e.spatialReference.isGeographic?20015077/180:1,a=.1*Math.max(e.extent.width*o,e.extent.height*o,e.extent.zmax-e.extent.zmin),s=[],n=[],i=[],l=[];for(let p=0;p<r;p++){const e=t[p],r=e.attributes.get(fe.POSITION),o=e.attributes.get(fe.NORMAL),c=r.indices,u=o.indices,m=r.data,d=o.data;for(let t=0;t<c.length;t++){const e=3*c[t],r=3*u[t];for(let t=0;t<3;t++)s.push(m[e+t]);for(let t=0;t<3;t++)s.push(m[e+t]+d[r+t]*a);if(n.push(n.length),n.push(n.length),t%3==0){this._calculateFaceNormal(m,c,t,Oe),this._getFaceVertices(m,c,t,je,we,Me),h(je,je,we),h(je,je,Me),f(je,je,1/3);for(let e=0;e<3;e++)i.push(je[e]);for(let e=0;e<3;e++)i.push(je[e]+Oe[e]*a);l.push(l.length),l.push(l.length)}}}const c=t[0].transformation,u=new ue(this._debugVertexNormalMaterial,[[fe.POSITION,new ne(s,n,3,!0)]],null,ce.Line);t.push(u),u.transformation=c;const m=new ue(this._debugFaceNormalMaterial,[[fe.POSITION,new ne(i,l,3,!0)]],null,ce.Line);m.transformation=c,t.push(m)}_createAs3DShape(e,t,r,o){const a=e.geometry;if("mesh"!==a.type)return null;const s=this._createGeometryInfo(a,t,o);if(null==s)return null;const{geometries:n,objectTransformation:i}=s;se.DRAW_MESH_GEOMETRY_NORMALS&&this._addDebugNormals(a,n);const l=new me({geometries:n,layerUid:this._context.layer.uid,graphicUid:o});l.transformation=i;const c=re(this.symbolLayer,{opacity:this._getLayerOpacity()}),u=c?new Q(n[0].material,[c],{mergeGeometries:!0,hasSlicePlane:this._context.slicePlaneEnabled}):null,m=new K(this,l,n,null,null,Y,r,u);this._fastUpdateProcessor.onAddGraphic(),m.needsElevationUpdates=Z(r.mode),m.useObjectOriginAsAttachmentOrigin=!0,r.centerPointInElevationSR=this._getCenterPointInElevationSR(l.transformation);const{elevationProvider:h,renderCoordsHelper:f}=this._context,p=(e,t)=>J(e,h,r,f,t);return m.alignedSampledElevation=Y(m,r,h.spatialReference,p,f),m}_getCenterPointInElevationSR(e){const t=k(0,0,0,null!=this._context.elevationProvider.spatialReference?this._context.elevationProvider.spatialReference:null);return w([e[12],e[13],e[14]],this._context.renderCoordsHelper.spatialReference,t),t}_createComponentNormals(e,t,r,o){switch(r.shading||"flat"){default:case"source":return this._createComponentNormalsSource(e,t,r,o);case"flat":return this._createComponentNormalsFlat(e,o);case"smooth":return this._createComponentNormalsSmooth(e,o)}}_createComponentNormalsSource(e,t,r,o){if(null==t)return this._createComponentNormalsFlat(e,o);let a=!1;if(!r.trustSourceNormals)for(let s=0;s<o.length;s+=3){this._calculateFaceNormal(e,o,s,Oe);for(let e=0;e<3;e++){const r=3*o[s+e];je[0]=t[r],je[1]=t[r+1],je[2]=t[r+2],p(Oe,je)<0&&(t[r]=-t[r],t[r+1]=-t[r+1],t[r+2]=-t[r+2],a=!0)}}return new ve(t,o,a)}_createComponentNormalsFlat(e,t){const r=A(t.length),o=new Array(3*t.length);for(let a=0;a<t.length;a+=3){const s=this._calculateFaceNormal(e,t,a,Oe);for(let e=0;e<3;e++)r[a+e]=s[e],o[a+e]=a/3}return new ve(r,o,!1)}_createComponentNormalsSmooth(e,t){const r={};for(let s=0;s<t.length;s+=3){const o=this._calculateFaceNormal(e,t,s,Oe);for(let e=0;e<3;e++){const a=t[s+e];let n=r[a];n||(n={normal:y(),count:0},r[a]=n),h(n.normal,n.normal,o),n.count++}}const o=A(3*t.length),a=new Array(3*t.length);for(let s=0;s<t.length;s++){const e=r[t[s]];1!==e.count&&(d(e.normal,e.normal),e.count=1);for(let t=0;t<3;t++)o[3*s+t]=e.normal[t];a[s]=s}return new ve(o,a,!1)}_getFaceVertices(e,t,r,o,a,s){const n=3*t[r],i=3*t[r+1],l=3*t[r+2];o[0]=e[n],o[1]=e[n+1],o[2]=e[n+2],a[0]=e[i],a[1]=e[i+1],a[2]=e[i+2],s[0]=e[l],s[1]=e[l+1],s[2]=e[l+2]}_calculateFaceNormal(e,t,r,o){return this._getFaceVertices(e,t,r,je,we,Me),g(we,we,je),g(Me,Me,je),x(je,we,Me),d(o,je),o}_getOrCreateComponents(e){return e.components??Ie}_createPositionBuffer(e,t){let r=e.vertexAttributes.position;const o=t.reprojection===Be.ECEF?t.transformBeforeProject:null;if(o&&(r=S(new Float64Array(r.length),r,o)),t.reprojection===Be.NONE)return t.needsBufferCopy?new Float64Array(r):r;const a=o?r:new Float64Array(r.length);return j(r,e.spatialReference,0,a,this._context.renderCoordsHelper.spatialReference,0,r.length/3),a}_createNormalBuffer(e,t,r){let o=e.vertexAttributes.normal;if(null==o)return null;const a=r.reprojection===Be.ECEF?r.transformBeforeProject:null;a&&(o=$(o,new Float32Array(o.length),a));if("local"===this._context.graphicsCoreOwner.view.viewingMode||r.reprojection===Be.NONE)return r.needsBufferCopy&&e.vertexAttributes.normal===o?new Float32Array(o):o;const s=e.vertexAttributes.position,n=a?o:new Float32Array(o.length);return G(o,s,t,e.spatialReference,n)}_createTangentBuffer(e,t,r){let o=e.vertexAttributes.tangent;if(null==o)return null;const a=r.reprojection===Be.ECEF?r.transformBeforeProject:null;a&&(o=V(o,new Float32Array(o.length),a));if("local"===this._context.graphicsCoreOwner.view.viewingMode||r.reprojection===Be.NONE)return r.needsBufferCopy&&e.vertexAttributes.normal===o?new Float32Array(o):o;const s=e.vertexAttributes.position,n=a?o:new Float32Array(o.length);return D(o,s,t,e.spatialReference,n)}_createColorBuffer(e){return e.vertexAttributes.color}_createSymbolColorBuffer(e){if(this._requiresSymbolVertexColors()){const t=this._getVertexOpacityAndColor(e),r=oe(this.symbolLayer?.material?.colorMixMode),o=new Uint8Array(4);return ae(t,r,o),o}return null}_createBuffers(e,t){const r=e.vertexAttributes&&e.vertexAttributes.position;if(!r)return this.logger.warn("Mesh geometry must contain position vertex attributes"),null;const o=e.vertexAttributes.normal,a=e.vertexAttributes.uv,s=e.vertexAttributes.tangent;if(o&&o.length!==r.length)return this.logger.warn("Mesh normal vertex buffer must contain the same number of elements as the position buffer"),null;if(s&&s.length/4!=r.length/3)return this.logger.warn("Mesh tangent vertex buffer must contain the same number of elements as the position buffer"),null;if(a&&a.length/2!=r.length/3)return this.logger.warn("Mesh uv vertex buffer must contain the same number of elements as the position buffer"),null;const n=this._computeReprojectionInfo(e),i=this._createPositionBuffer(e,n),c=this._createColorBuffer(e),u=this._createSymbolColorBuffer(t),m=this._createNormalBuffer(e,i,n),h=this._createTangentBuffer(e,i,n);return{positionBuffer:i,normalBuffer:m,tangentBuffer:h,uvBuffer:a,colorBuffer:c,symbolColorBuffer:u,objectTransformation:n.reprojection===Be.NONE&&n.objectTransformation?n.objectTransformation:this._transformOriginLocal(e,i,m,h),geometryTransformation:n.reprojection===Be.NONE&&n.geometryTransformation?n.geometryTransformation:l()}}_computeReprojectionInfo(e){const{vertexSpace:t}=e,r=t.isRelative,o=t.isGeoreferenced?this._context.renderCoordsHelper.viewingMode===q.Local?Be.NONE:Be.ECEF:Be.NONE;if(r){const{origin:r}=t,a=l(),i=e.transform?.localMatrix??c;if(o===Be.NONE){C(e.spatialReference,r,a,this._context.renderCoordsHelper.spatialReference);return{reprojection:o,objectTransformation:a,geometryTransformation:u(i),needsBufferCopy:!1}}const m=s(l(),r);return n(m,m,i),{reprojection:o,transformBeforeProject:m,needsBufferCopy:!0}}return{reprojection:o,needsBufferCopy:!0}}_transformOriginLocal(e,t,a,s){const n=this._context.renderCoordsHelper.spatialReference,c=e.anchor;Ce[0]=c.x,Ce[1]=c.y,Ce[2]=c.z??0;const u=l();return C(e.spatialReference,Ce,u,n),i(Pe,u),S(t,t,Pe),(a||s)&&(r(Re,u),o(Re,Re),a&&U(a,a,Re),s&&U(s,s,Re,4)),u}_validateFaces(e,t){const r=e.vertexAttributes.position.length/3,o=t.faces;if(o){let e=-1;for(let t=0;t<o.length;t++){const r=o[t];r>e&&(e=r)}if(r<=e)return this.logger.warn(`Vertex index ${e} is out of bounds of the mesh position buffer`),!1}else if(r%3!=0)return this.logger.warn("Mesh position buffer length must be a multiple of 9 if no component faces are defined (3 values per vertex * 3 vertices per triangle)"),!1;return!0}_getOrCreateFaces(e,t){return t.faces??E(e.vertexAttributes.position.length/3)}_isOutsideClippingArea(e){if(!this._context.clippingExtent)return!1;const t=e.vertexAttributes?.position;if(!t)return!1;const r=this._context.elevationProvider.spatialReference,o=L({positions:t,transform:e.transform,vertexSpace:e.vertexSpace,inSpatialReference:e.spatialReference,outSpatialReference:r??e.spatialReference}),a=o.length/3;return O(Ee),P(Ee,o,0,a),!R(Ee,this._context.clippingExtent)}_createGeometryInfo(e,t,r){if(!v(e.spatialReference,this._context.graphicsCoreOwner.view.spatialReference))return this.logger.warn("Geometry spatial reference is not compatible with the view"),null;if(this._isOutsideClippingArea(e))return null;const o=this._createBuffers(e,t);if(null==o)return null;const{positionBuffer:a,uvBuffer:s,colorBuffer:n,symbolColorBuffer:i,normalBuffer:l,tangentBuffer:c,objectTransformation:u,geometryTransformation:m}=o,h=this._getOrCreateComponents(e),f=new Array;let p=!1;for(const d of h){if(!this._validateFaces(e,d))return null;const t=this._getOrCreateFaces(e,d);if(0===t.length)continue;const o=this._createComponentNormals(a,l,d,t);o.didFlipNormals&&(p=!0);const u=[[fe.POSITION,new ne(a,t,3,!0)],[fe.NORMAL,new ne(o.normals,o.indices,3,!0)]];n&&u.push([fe.COLOR,new ne(n,t,4,!0)]),i&&u.push([fe.SYMBOLCOLOR,new ne(i,I(t.length),4,!0)]),s&&u.push([fe.UV0,new ne(s,t,2,!0)]),c&&u.push([fe.TANGENT,new ne(c,t,4,!0)]);const h=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:r,layerUid:this._context.layer.uid}),g=this._getOrCreateMaterial(e,d),x=new ue(g,u,null,ce.Mesh,h);x.transformation=m,f.push(x)}return p&&this.logger.warn("Normals have been automatically flipped to be consistent with the counter clock wise face winding order. It is better to generate mesh geometries that have consistent normals."),{geometries:f,objectTransformation:u}}_updateMaterialParameters(e){this._materialInfoCache.forEachMaterialInfo(e),this._fastUpdateProcessor.forEachMaterialInfo(e),this._fastUpdateProcessor.forEachClonedMaterial(((e,t)=>{t.setParameters(e.parameters)}))}test(){return{...super.test(),materials:this._materialInfoCache.materials}}}class ve{constructor(e,t,r){this.normals=e,this.indices=t,this.didFlipNormals=r}}const Ce=y(),je=y(),we=y(),Me=y(),Oe=y(),Pe=l(),Re=a(),Ae=l(),Ee=M(),Ie=[new N],Ne=new F;var Be;!function(e){e[e.NONE=0]="NONE",e[e.ECEF=1]="ECEF"}(Be||(Be={}));export{be as Graphics3DMeshFillSymbolLayer};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../../../Color.js";import has from"../../../../core/has.js";import{throwIfAborted as t}from"../../../../core/promiseUtils.js";import{pt2px as s}from"../../../../core/screenUtils.js";import{estimateSize as r}from"../../../../core/typedArrayUtil.js";import{g as i,b as a,w as o,h as n}from"../../../../chunks/mat4.js";import{a as l}from"../../../../chunks/mat4f64.js";import{l as c,E as h,c as d,A as m,g as p,s as u}from"../../../../chunks/vec3.js";import{e as y,O as f,Z as _,f as g,c as b}from"../../../../chunks/vec3f64.js";import{O as P,c as R}from"../../../../chunks/vec4f64.js";import{computeTranslationToOriginAndRotation as x}from"../../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{projectPointToVector as v}from"../../../../geometry/projection/projectPointToVector.js";import{create as L,size as C,containsPoint as S,center as j}from"../../../../geometry/support/aaBoundingBox.js";import{defaultPrimitive as E}from"../../../../symbols/support/ObjectSymbol3DLayerResource.js";import{objectSymbolLayerPrimitiveBoundingBox as w,objectSymbolLayerSizeWithResourceSize as T}from"../../../../symbols/support/symbolLayerUtils3D.js";import{estimateNumVerticesForLods as U,defaultSymbolLayerMemoryComplexity as O}from"./defaultSymbolComplexity.js";import{perLodInstanceElevationAligner as B}from"./ElevationAligners.js";import{needsElevationUpdates3D as A,evaluateElevationInfoAtPoint as I,SampleElevationInfo as G}from"./elevationAlignmentUtils.js";import{Graphics3DLodInstanceGraphicLayer as D}from"./Graphics3DLodInstanceGraphicLayer.js";import{Graphics3DSymbolLayer as F}from"./Graphics3DSymbolLayer.js";import{validateSymbolLayerSize as z,mixinColorAndOpacity as V,computeObjectScale as M,computeObjectRotation as k}from"./graphicUtils.js";import{ApplyRendererDiffResult as H}from"./interfaces.js";import{LoadStatus as W}from"./Loadable.js";import{makeLodResources as q}from"./lodResourceUtils.js";import{fetch as N}from"./objectResourceUtils.js";import{placePointOnGeometry as J,extendPointGraphicElevationContext as Y}from"./pointUtils.js";import{isValidPrimitive as $,primitiveLodResources as Z}from"./primitiveObjectSymbolUtils.js";import{SymbolComplexity as K}from"./SymbolComplexity.js";import{getResourceUrlFromSymbolStyle as Q}from"./webStyleUtils.js";import{initFastSymbolUpdatesState as X,updateFastSymbolUpdatesState as ee,ConvertOptions as te,evaluateModelTransform as se,evaluateModelTransformScale as re}from"../support/FastSymbolUpdates.js";import{CullFaceOptions as ie}from"../../webgl-engine/lib/basicInterfaces.js";import{VertexAttribute as ae}from"../../webgl-engine/lib/VertexAttribute.js";import{LodRenderer as oe}from"../../webgl-engine/lib/lodRendering/LodRenderer.js";import{materialsFromLodResources as ne,texturesFromLodResources as le,geometriesFromLodResources 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 F{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(z(this.symbolLayer))throw new Error}if(this._isPrimitive){const t=this.symbolLayer.resource,s=t&&$(t.primitive)?t.primitive:E;this._resources=await this._createResourcesForPrimitive(s,e)}else{const t=await Q(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}get materials(){return this._resources?.stageResources.materials??[]}_setMaterialTransparencyParameters(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?ie.None:ie.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._setMaterialTransparencyParameters(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=X(this._context.renderer,this._fastVisualVariableConvertOptions(a,n,o,null)),m.isInstanced=!0,this._fastUpdates?(Object.assign(m,this._fastUpdates.materialParameters),this._optionalFields.push(ae.FEATUREATTRIBUTE)):this._hasPerInstanceColor()&&(m.hasInstancedColor=!0,this._optionalFields.push(ae.COLOR)),has("enable-feature:objectAndLayerId-rendering")&&this._optionalFields.push(ae.OBJECTANDLAYERIDCOLOR);const _=new he(m),g=Z(t,_);if(!g)throw new Error(`Unknown object symbol primitive: ${t}`);const b=ne(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={materialParameters:{isInstanced:!0,hasSlicePlane:this._context.slicePlaneEnabled,castShadows:this.symbolLayer.castShadows},streamDataRequester:this._context.streamDataRequester,cache:this._context.sharedResources.objectResourceCache};this._fastUpdates=X(this._context.renderer,this._fastVisualVariableConvertOptions(null,null,null,null)),this._fastUpdates?(Object.assign(r.materialParameters,this._fastUpdates.materialParameters),this._optionalFields.push(ae.FEATUREATTRIBUTE)):this._hasPerInstanceColor()&&(r.materialParameters.hasInstancedColor=!0,this._optionalFields.push(ae.COLOR)),has("enable-feature:objectAndLayerId-rendering")&&this._optionalFields.push(ae.OBJECTANDLAYERIDCOLOR);const i=this.symbol;if("point-3d"===i.type&&i.verticalOffset){const{screenLength:e,minWorldLength:t,maxWorldLength:a}=i.verticalOffset;r.materialParameters.verticalOffset={screenLength:s(e),minWorldLength:t||0,maxWorldLength:null!=a?a:1/0},r.materialParameters.castShadows=!1}const a=this._context.physicalBasedRenderingEnabled;r.signal=t,r.usePBR=a,r.skipHighLods=this._context.skipHighSymbolLods;const o=await N(e,r),n=o.isEsriSymbolResource,l=o.isWosr,h=q(o.lods),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=ne(h),b=ne(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;ee(S,this._context.renderer,this._fastVisualVariableConvertOptions(P,v,R,x))&&g.forEach((e=>e.setParameters(S.materialParameters)));const j=await this._createStageResources(h,a,t),E=await this._createLodRenderer(h,t);return new me(h,E,j,b,R,n,l,P,v,L,a,x)}_addDisposeResource(e){this._disposeResourceHandles.push(e)}async _createStageResources(e,s,r){const i=this._context.stage,a=ne(e);s!==this._context.physicalBasedRenderingEnabled&&this.physicalBasedRenderingChanged(),i.addMany(a),this._addDisposeResource((()=>i.removeMany(a)));const o=le(e);i.addMany(o),this._addDisposeResource((()=>{o.forEach((e=>e.unload())),i.removeMany(o)})),await Promise.all(o.map((e=>this._context.stage.schedule((()=>e.load(i.renderView.renderingContext)),r)))),t(r);const n=ce(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,se(i.materialParameters,_e,s))},scaleFactor:(e,t,s)=>{t.getFeatureAttribute(s,_e),re(e,i.materialParameters,_e)}}:null,o=new oe({symbol:e,optionalFields:this._optionalFields,metadata:r,shaderTransformation:a},this._context.scheduler);return o.slicePlaneEnabled=this._context.slicePlaneEnabled,this._addDisposeResource((()=>{s.removeRenderPlugin(o),o.destroy()})),await s.addRenderPlugin(o,t),o}_getExternalColorParameters(t){const s={};return this._drivenProperties.color?s.externalColor=P:null!=t&&null!=t.color?s.externalColor=e.toUnitRGBA(t.color):(s.externalColor=P,s.colorMixMode="ignore"),s}destroy(){super.destroy(),this._cleanupResources()}_cleanupResources(){this._disposeResourceHandles.forEach((e=>e())),this._disposeResourceHandles.length=0,this._resources=null}createGraphics3DGraphic(e){const t=e.graphic;if(!this._validateGeometry(t.geometry))return null;const s=J(t.geometry);if(null==s)return this.logger.warn(`unsupported geometry type for icon symbol: ${t.geometry.type}`),null;const r=this.setGraphicElevationContext(t),i=e.renderingInfo;return this._createAs3DShape(t,s,i,r,t.uid,e.layer.uid)}notifyDestroyGraphicLayer(e){this._instanceIndexToGraphicUid.delete(e.instanceIndex)}graphicLayerToGraphicId(){return 0}layerOpacityChanged(){if(null==this._resources)return;const e=this._drivenProperties.opacity,t=!this._isPrimitive,s=this._resources.stageResources.materials,r=this._resources.originalMaterialParameters;for(let i=0;i<s.length;i++){const a=s[i],o=this.symbolLayer?.material?.color,n=r[i],l=this._getCombinedOpacity(o,{hasIntrinsicColor:t})*n.opacity,c=l<1||e||n.transparent;a.setParameters({opacity:l,transparent:c}),this._isPrimitive&&a.setParameters({cullFace:c?ie.None:ie.Back})}}layerElevationInfoChanged(e,t){return this.updateGraphics3DGraphicElevationInfo(e,t,A)}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 H.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 H.RecreateSymbol;if(!ee(this._fastUpdates,t,this._fastVisualVariableConvertOptions(i,a,o,n)))return H.RecreateSymbol;for(const e of s)e.setParameters(this._fastUpdates.materialParameters);r.notifyShaderTransformationChanged()}return H.FastUpdate}computeComplexity(){if(null==this._resources)return super.computeComplexity();const e=this._resources.lodResources,t=U(e.levels),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=le(e).reduce(((e,t)=>e+t.memoryEstimate),0)+ce(e).reduce(((e,t)=>e+s(t)),0),a={...O(this.symbol,this.symbolLayer),resourceBytes:i};return new K({verticesPerFeature:t,memory:a})}_hasLodRenderer(){return null!=this._resources}_createAs3DShape(e,t,s,r,i,a){if(!this._hasLodRenderer()||null==this._resources)return null;const o=this.getFastUpdateAttrValues(e),n=this._context.clippingExtent;if(v(t,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,V(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 D(this,m,B,r);return l&&(p.alignedSampledElevation=ge.sampledElevation),p.needsElevationUpdates=A(r.mode),Y(p,t,this._context.elevationProvider),p}_computeGlobalTransform(e,t,s,r){return I(e,this._context.elevationProvider,t,this._context.renderCoordsHelper,r),ue[0]=e.x,ue[1]=e.y,ue[2]=r.z,x(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&&J(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),Y(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===W.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._setMaterialTransparencyParameters({},i)):t=this._setMaterialTransparencyParameters({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 k(e.heading,e.tilt,e.roll,s)}_computeAnchor(e,t,s){const r=b();switch(s.anchor){case"center":d(r,j(e)),h(r,r);break;case"top":{const t=j(e);u(r,-t[0],-t[1],-e[5]);break}case"bottom":{const t=j(e);u(r,-t[0],-t[1],-e[2]);break}case"relative":{const t=j(e),i=C(e),a=s.anchorPosition,o=a?g(a.x,a.y,a.z):_;m(r,i,o),p(r,r,t),h(r,r);break}default:null!=t?h(r,t):d(r,_)}return r}_applyAnchor(e,t,s){if(this._fastUpdates?.requiresShaderTransformation)return;const r=this._computeAnchor(e.resourceBoundingBox,e.pivotOffset,t);r&&o(s,s,r)}_hasPerInstanceColor(){return this._drivenProperties.color||this._drivenProperties.opacity}_fastVisualVariableConvertOptions(e,t,s,r){const i=null!=e?y(C(e)):f,a=null!=e?this._computeAnchor(e,r,this.symbolLayer):_,o=this._context.renderCoordsHelper.unitInMeters,n=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 te({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 G;export{pe 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{g as i,b as a,w as o,h as n}from"../../../../chunks/mat4.js";import{a as l}from"../../../../chunks/mat4f64.js";import{l as c,E as h,c as d,A as m,g as p,s as u}from"../../../../chunks/vec3.js";import{e as y,O as f,Z as _,f as g,c as b}from"../../../../chunks/vec3f64.js";import{O as P,c as R}from"../../../../chunks/vec4f64.js";import{computeTranslationToOriginAndRotation as x}from"../../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{projectPointToVector as v}from"../../../../geometry/projection/projectPointToVector.js";import{create as L,size as C,containsPoint as S,center as j}from"../../../../geometry/support/aaBoundingBox.js";import{defaultPrimitive as E}from"../../../../symbols/support/ObjectSymbol3DLayerResource.js";import{objectSymbolLayerPrimitiveBoundingBox as w,objectSymbolLayerSizeWithResourceSize as T}from"../../../../symbols/support/symbolLayerUtils3D.js";import{estimateNumVerticesForLods as U,defaultSymbolLayerMemoryComplexity as O}from"./defaultSymbolComplexity.js";import{perLodInstanceElevationAligner as B}from"./ElevationAligners.js";import{needsElevationUpdates3D as I,evaluateElevationInfoAtPoint as A,SampleElevationInfo as G}from"./elevationAlignmentUtils.js";import{Graphics3DLodInstanceGraphicLayer as D}from"./Graphics3DLodInstanceGraphicLayer.js";import{Graphics3DSymbolLayer as F}from"./Graphics3DSymbolLayer.js";import{validateSymbolLayerSize as z,mixinColorAndOpacity as V,computeObjectScale as M,computeObjectRotation as k}from"./graphicUtils.js";import{ApplyRendererDiffResult as H}from"./interfaces.js";import{LoadStatus as W}from"./Loadable.js";import{makeLodResources as q}from"./lodResourceUtils.js";import{fetch as N}from"./objectResourceUtils.js";import{placePointOnGeometry as J,extendPointGraphicElevationContext as Y}from"./pointUtils.js";import{isValidPrimitive as $,primitiveLodResources as Z}from"./primitiveObjectSymbolUtils.js";import{SymbolComplexity as K}from"./SymbolComplexity.js";import{getResourceUrlFromSymbolStyle as Q}from"./webStyleUtils.js";import{initFastSymbolUpdatesState as X,updateFastSymbolUpdatesState as ee,ConvertOptions as te,evaluateModelTransform as se,evaluateModelTransformScale as re}from"../support/FastSymbolUpdates.js";import{CullFaceOptions as ie}from"../../webgl-engine/lib/basicInterfaces.js";import{VertexAttribute as ae}from"../../webgl-engine/lib/VertexAttribute.js";import{LodRenderer as oe}from"../../webgl-engine/lib/lodRendering/LodRenderer.js";import{materialsFromLodResources as ne,texturesFromLodResources as le,geometriesFromLodResources 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 F{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(z(this.symbolLayer))throw new Error}if(this._isPrimitive){const t=this.symbolLayer.resource,s=t&&$(t.primitive)?t.primitive:E;this._resources=await this._createResourcesForPrimitive(s,e)}else{const t=await Q(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}get materials(){return this._resources?.stageResources.materials??[]}_setMaterialTransparencyParameters(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?ie.None:ie.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._setMaterialTransparencyParameters(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=X(this._context.renderer,this._fastVisualVariableConvertOptions(a,n,o,null)),m.isInstanced=!0,this._fastUpdates?(Object.assign(m,this._fastUpdates.materialParameters),this._optionalFields.push(ae.FEATUREATTRIBUTE)):this._hasPerInstanceColor()&&(m.hasInstancedColor=!0,this._optionalFields.push(ae.COLOR)),has("enable-feature:objectAndLayerId-rendering")&&this._optionalFields.push(ae.OBJECTANDLAYERIDCOLOR);const _=new he(m),g=Z(t,_);if(!g)throw new Error(`Unknown object symbol primitive: ${t}`);const b=ne(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={materialParameters:{isInstanced:!0,hasSlicePlane:this._context.slicePlaneEnabled,castShadows:this.symbolLayer.castShadows},streamDataRequester:this._context.streamDataRequester,cache:this._context.sharedResources.objectResourceCache};this._fastUpdates=X(this._context.renderer,this._fastVisualVariableConvertOptions(null,null,null,null)),this._fastUpdates?(Object.assign(r.materialParameters,this._fastUpdates.materialParameters),this._optionalFields.push(ae.FEATUREATTRIBUTE)):this._hasPerInstanceColor()&&(r.materialParameters.hasInstancedColor=!0,this._optionalFields.push(ae.COLOR)),has("enable-feature:objectAndLayerId-rendering")&&this._optionalFields.push(ae.OBJECTANDLAYERIDCOLOR);const i=this.symbol;if("point-3d"===i.type&&i.verticalOffset){const{screenLength:e,minWorldLength:t,maxWorldLength:a}=i.verticalOffset;r.materialParameters.verticalOffset={screenLength:s(e),minWorldLength:t||0,maxWorldLength:null!=a?a:1/0},r.materialParameters.castShadows=!1}const a=this._context.physicalBasedRenderingEnabled;r.signal=t,r.usePBR=a,r.skipHighLods=this._context.skipHighSymbolLods;const o=await N(e,r),n=o.isEsriSymbolResource,l=o.isWosr,h=q(o.lods),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=ne(h),b=ne(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;ee(S,this._context.renderer,this._fastVisualVariableConvertOptions(P,v,R,x))&&g.forEach((e=>e.setParameters(S.materialParameters)));const j=await this._createStageResources(h,a,t),E=await this._createLodRenderer(h,t);return new me(h,E,j,b,R,n,l,P,v,L,a,x)}_addDisposeResource(e){this._disposeResourceHandles.push(e)}async _createStageResources(e,s,r){const i=this._context.stage,a=ne(e);s!==this._context.physicalBasedRenderingEnabled&&this.physicalBasedRenderingChanged(),i.addMany(a),this._addDisposeResource((()=>i.removeMany(a)));const o=le(e);i.addMany(o),this._addDisposeResource((()=>{o.forEach((e=>e.unload())),i.removeMany(o)})),await Promise.all(o.map((e=>this._context.stage.schedule((()=>e.load(i.renderView.renderingContext)),r)))),t(r);const n=ce(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,se(i.materialParameters,_e,s))},scaleFactor:(e,t,s)=>{t.getFeatureAttribute(s,_e),re(e,i.materialParameters,_e)}}:null,o=new oe({symbol:e,optionalFields:this._optionalFields,metadata:r,shaderTransformation:a},this._context.scheduler);return o.slicePlaneEnabled=this._context.slicePlaneEnabled,this._addDisposeResource((()=>{s.removeRenderPlugin(o),o.destroy()})),await s.addRenderPlugin(o,t),o}_getExternalColorParameters(t){const s={};return this._drivenProperties.color?s.externalColor=P:null!=t&&null!=t.color?s.externalColor=e.toUnitRGBA(t.color):(s.externalColor=P,s.colorMixMode="ignore"),s}destroy(){super.destroy(),this._cleanupResources()}_cleanupResources(){this._disposeResourceHandles.forEach((e=>e())),this._disposeResourceHandles.length=0,this._resources=null}createGraphics3DGraphic(e){const t=e.graphic;if(!this._validateGeometry(t.geometry))return null;const s=J(t.geometry);if(null==s)return this.logger.warn(`unsupported geometry type for icon symbol: ${t.geometry.type}`),null;const r=this.setGraphicElevationContext(t),i=e.renderingInfo;return this._createAs3DShape(t,s,i,r,t.uid,e.layer.uid)}notifyDestroyGraphicLayer(e){this._instanceIndexToGraphicUid.delete(e.instanceIndex)}graphicLayerToGraphicId(){return 0}layerOpacityChanged(){if(null==this._resources)return;const e=this._drivenProperties.opacity,t=!this._isPrimitive,s=this._resources.stageResources.materials,r=this._resources.originalMaterialParameters;for(let i=0;i<s.length;i++){const a=s[i],o=this.symbolLayer?.material?.color,n=r[i],l=this._getCombinedOpacity(o,{hasIntrinsicColor:t})*n.opacity,c=l<1||e||n.transparent;a.setParameters({opacity:l,transparent:c}),this._isPrimitive&&a.setParameters({cullFace:c?ie.None:ie.Back})}}layerElevationInfoChanged(e,t){return this.updateGraphics3DGraphicElevationInfo(e,t,I)}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 H.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 H.RecreateSymbol;if(!ee(this._fastUpdates,t,this._fastVisualVariableConvertOptions(i,a,o,n)))return H.RecreateSymbol;for(const e of s)e.setParameters(this._fastUpdates.materialParameters);r.notifyShaderTransformationChanged()}return H.FastUpdate}computeComplexity(){if(null==this._resources)return super.computeComplexity();const e=this._resources.lodResources,t=U(e.levels),s=e=>Array.from(e.attributes.values()).reduce(((e,t)=>e+r(t.data,t.indices)),0),i=ce(e).reduce(((e,t)=>e+s(t)),0),a=le(e).reduce(((e,t)=>e+t.memoryEstimate),0)+i,o={...O(this.symbol,this.symbolLayer),resourceBytes:a};return new K({verticesPerFeature:t,memory:o})}_hasLodRenderer(){return null!=this._resources}_createAs3DShape(e,t,s,r,i,a){if(!this._hasLodRenderer()||null==this._resources)return null;const o=this.getFastUpdateAttrValues(e),n=this._context.clippingExtent;if(v(t,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,V(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 D(this,m,B,r);return l&&(p.alignedSampledElevation=ge.sampledElevation),p.needsElevationUpdates=I(r.mode),Y(p,t,this._context.elevationProvider),p}_computeGlobalTransform(e,t,s,r){return A(e,this._context.elevationProvider,t,this._context.renderCoordsHelper,r),ue[0]=e.x,ue[1]=e.y,ue[2]=r.z,x(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&&J(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),Y(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===W.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._setMaterialTransparencyParameters({},i)):t=this._setMaterialTransparencyParameters({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 k(e.heading,e.tilt,e.roll,s)}_computeAnchor(e,t,s){const r=b();switch(s.anchor){case"center":d(r,j(e)),h(r,r);break;case"top":{const t=j(e);u(r,-t[0],-t[1],-e[5]);break}case"bottom":{const t=j(e);u(r,-t[0],-t[1],-e[2]);break}case"relative":{const t=j(e),i=C(e),a=s.anchorPosition,o=a?g(a.x,a.y,a.z):_;m(r,i,o),p(r,r,t),h(r,r);break}default:null!=t?h(r,t):d(r,_)}return r}_applyAnchor(e,t,s){if(this._fastUpdates?.requiresShaderTransformation)return;const r=this._computeAnchor(e.resourceBoundingBox,e.pivotOffset,t);r&&o(s,s,r)}_hasPerInstanceColor(){return this._drivenProperties.color||this._drivenProperties.opacity}_fastVisualVariableConvertOptions(e,t,s,r){const i=null!=e?y(C(e)):f,a=null!=e?this._computeAnchor(e,r,this.symbolLayer):_,o=this._context.renderCoordsHelper.unitInMeters,n=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 te({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 G;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.28/esri/copyright.txt for details.
4
4
  */
5
- import{adjustStaticAGOUrl as e}from"../../../../core/devEnvironmentUtils.js";import{n as t}from"../../../../chunks/mat3.js";import{a as r}from"../../../../chunks/mat3f64.js";import{i as o}from"../../../../chunks/mat4.js";import{a as s}from"../../../../chunks/mat4f64.js";import{e as i,f as n,B as l,l as a,n as u,p 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 v}from"../../../../chunks/vec32.js";import{t as j,s as B}from"../../../../chunks/vec42.js";import{n as M}from"../../../../chunks/vec22.js";import{c as F}from"../../../../chunks/vec33.js";import{c as S}from"../../../../chunks/vec43.js";import{DefaultLoadingContext as L}from"../../glTF/DefaultLoadingContext.js";import{loadGLTF as A}from"../../glTF/loader.js";import{convertPrimitiveToTriangles as k}from"../../glTF/internal/indexUtils.js";import{isEncodedMeshTexture as C}from"../../glTF/internal/resourceUtils.js";import{getTransformMatrix as E}from"../../glTF/internal/TextureTransformUtils.js";import{ProcessedObjectResource as I}from"./ProcessedObjectResource.js";import{load as O,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 H}from"../../webgl-engine/lib/Geometry.js";import{Texture as q}from"../../webgl-engine/lib/Texture.js";import{VertexAttribute as G}from"../../webgl-engine/lib/VertexAttribute.js";import{DefaultMaterial as W}from"../../webgl-engine/materials/DefaultMaterial.js";import{colorGamma as $}from"../../webgl-engine/materials/DefaultMaterial_COLOR_GAMMA.js";import{defaultEsriSymbologyMRRFactors as z,defaultAdvancedMRRFactors as K,useSchematicPBR as Q,defaultSchematicMRRFactors as J}from"../../webgl-engine/materials/pbrUtils.js";async function X(t,r){const o=Y(e(t));if("wosr"===o.fileType){const e=await(r.cache?r.cache.loadWOSR(o.url,r):O(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):A(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,a=s.meta.isEsriSymbolResource?{usePBR:l,isSchematic:!1,treeRendering:n,mrrFactors:[...z]}:{usePBR:l,isSchematic:!1,treeRendering:!1,mrrFactors:[...K]},u={...r.materialParameters,treeRendering:n},{engineResources:c,referenceBoundingBox:m}=Z(s,a,u,r.skipHighLods&&null==o.specifiedLodIndex?{skipHighLods:!0}:{skipHighLods:!1,singleLodIndex:o.specifiedLodIndex});return{lods:c,referenceBoundingBox:m,isEsriSymbolResource:s.meta.isEsriSymbolResource,isWosr:!1}}function Y(e){const t=e.match(/(.*\.(gltf|glb))(\?lod=([0-9]+))?$/);if(t)return{fileType:"gltf",url:t[1],specifiedLodIndex:null!=t[4]?Number(t[4]):null};return e.match(/(.*\.(json|json\.gz))$/)?{fileType:"wosr",url:e,specifiedLodIndex:null}:{fileType:"unknown",url:e,specifiedLodIndex:null}}function Z(e,t,r,o){const s=e.model,i=new Array,n=new Map,l=new Map,a=s.lods.length,u=f();return s.lods.forEach(((e,c)=>{const m=!0===o.skipHighLods&&(a>1&&0===c||a>3&&1===c)||!1===o.skipHighLods&&null!=o.singleLodIndex&&c!==o.singleLodIndex;if(m&&0!==c)return;const f=new I(e.name,e.lodThreshold,[0,0,0]);e.parts.forEach((e=>{const o=m?new W({}):ee(s,e,f,t,r,n,l),{geometry:i,vertexCount:a}=te(e,null!=o?o:new W({})),p=i.boundingInfo;null!=p&&0===c&&(d(u,p.bbMin),d(u,p.bbMax)),null!=o&&(f.stageResources.geometries.push(i),f.numberOfVertices+=a)})),m||i.push(f)})),{engineResources:i,referenceBoundingBox:u}}function ee(e,t,r,o,s,i,n){const l=t.material+(t.attributes.normal?"_normal":"")+(t.attributes.color?"_color":"")+(t.attributes.texCoord0?"_texCoord0":"")+(t.attributes.tangent?"_tangent":""),a=e.materials.get(t.material),u=null!=t.attributes.texCoord0,c=null!=t.attributes.normal;if(null==a)return null;const m=oe(a.alphaMode);if(!i.has(l)){if(u){const t=(t,r=!1)=>{if(null!=t&&!n.has(t)){const o=e.textures.get(t);if(null!=o){const e=o.data;n.set(t,new q(C(e)?e.data:e,{...o.parameters,preMultiplyAlpha:!C(e)&&r,encoding:C(e)&&null!=e.encoding?e.encoding:void 0}))}}};t(a.textureColor,m!==V.Opaque),t(a.textureNormal),t(a.textureOcclusion),t(a.textureEmissive),t(a.textureMetallicRoughness)}const r=a.color[0]**(1/$),f=a.color[1]**(1/$),d=a.color[2]**(1/$),p=a.emissiveFactor[0]**(1/$),g=a.emissiveFactor[1]**(1/$),x=a.emissiveFactor[2]**(1/$),b=null!=a.textureColor&&u?n.get(a.textureColor):null,h=Q({normalTexture:a.textureNormal,metallicRoughnessTexture:a.textureMetallicRoughness,metallicFactor:a.metallicFactor,roughnessFactor:a.roughnessFactor,emissiveTexture:a.textureEmissive,emissiveFactor:a.emissiveFactor,occlusionTexture:a.textureOcclusion});i.set(l,new W({...o,transparent:m===V.Blend,customDepthTest:D.Lequal,textureAlphaMode:m,textureAlphaCutoff:a.alphaCutoff,diffuse:[r,f,d],ambient:[r,f,d],opacity:a.opacity,doubleSided:a.doubleSided,doubleSidedType:"winding-order",cullFace:a.doubleSided?_.None:_.Back,hasVertexColors:!!t.attributes.color,hasVertexTangents:!!t.attributes.tangent,normalType:c?P.Attribute:P.ScreenDerivative,castShadows:!0,textureId:null!=b?b.id:void 0,colorMixMode:a.colorMixMode,normalTextureId:null!=a.textureNormal&&u?n.get(a.textureNormal).id:void 0,textureAlphaPremultiplied:null!=b&&!!b.parameters.preMultiplyAlpha,occlusionTextureId:null!=a.textureOcclusion&&u?n.get(a.textureOcclusion).id:void 0,emissiveTextureId:null!=a.textureEmissive&&u?n.get(a.textureEmissive).id:void 0,metallicRoughnessTextureId:null!=a.textureMetallicRoughness&&u?n.get(a.textureMetallicRoughness).id:void 0,emissiveFactor:[p,g,x],mrrFactors:h?[...J]:[a.metallicFactor,a.roughnessFactor,o.mrrFactors[2]],isSchematic:h,colorTextureTransformMatrix:E(a.colorTextureTransform),normalTextureTransformMatrix:E(a.normalTextureTransform),occlusionTextureTransformMatrix:E(a.occlusionTextureTransform),emissiveTextureTransformMatrix:E(a.emissiveTextureTransform),metallicRoughnessTextureTransformMatrix:E(a.metallicRoughnessTextureTransform),...s}))}const f=i.get(l);if(r.stageResources.materials.push(f),u){const e=e=>{null!=e&&r.stageResources.textures.push(n.get(e))};e(a.textureColor),e(a.textureNormal),e(a.textureOcclusion),e(a.textureEmissive),e(a.textureMetallicRoughness)}return f}function te(e,r){const o=e.attributes.position.count,s=k(e.indices||o,e.primitiveType),i=p(3*o),{typedBuffer:n,typedBufferStride:l}=e.attributes.position;w(i,n,e.transform,3,l);const a=[[G.POSITION,new U(i,3,!0),s]];if(null!=e.attributes.normal){const r=p(3*o),{typedBuffer:i,typedBufferStride:n}=e.attributes.normal;t(re,e.transform),R(r,i,re,3,n),a.push([G.NORMAL,new U(r,3,!0),s])}if(null!=e.attributes.tangent){const r=p(4*o),{typedBuffer:i,typedBufferStride:n}=e.attributes.tangent;t(re,e.transform),j(r,i,re,4,n),a.push([G.TANGENT,new U(r,4,!0),s])}if(null!=e.attributes.texCoord0){const t=p(2*o),{typedBuffer:r,typedBufferStride:i}=e.attributes.texCoord0;M(t,r,2,i),a.push([G.UV0,new U(t,2,!0),s])}if(null!=e.attributes.color){const t=new Uint8Array(4*o);4===e.attributes.color.elementCount?e.attributes.color instanceof g?B(t,e.attributes.color,255):e.attributes.color instanceof x?S(t,e.attributes.color):e.attributes.color instanceof b&&B(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?F(t,e.attributes.color.typedBuffer,4,e.attributes.color.typedBufferStride):e.attributes.color instanceof y&&v(t,e.attributes.color,1/256,4)),a.push([G.COLOR,new U(t,4,!0),s])}return{geometry:new H(r,a),vertexCount:o}}const re=r();function oe(e){switch(e){case"BLEND":return V.Blend;case"MASK":return V.Mask;case"OPAQUE":case null:case void 0:return V.Opaque}}function se(e,t){for(let r=0;r<e.model.lods.length;++r){const f=e.model.lods[r];for(const d of f.parts){const f=d.attributes.normal;if(null==f)return;const p=d.attributes.position,g=p.count,b=m(),T=m(),y=m(),w=new Uint8Array(4*g),R=new Float64Array(3*g),v=o(s(),d.transform);let j=0,B=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=a(y),g=Math.min(.45+.55*m*m,1);l(y,y,t.radius),null!==v&&i(y,y,v),u(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[B]=255*g,w[B+1]=255*g,w[B+2]=255*g,w[B+3]=255,B+=4}d.attributes.normal=new h(R),d.attributes.color=new x(w)}}}export{X as fetch,Z as gltfToEngineResources,Y as parseUrl};
5
+ import{adjustStaticAGOUrl as e}from"../../../../core/devEnvironmentUtils.js";import{n as t}from"../../../../chunks/mat3.js";import{a as r}from"../../../../chunks/mat3f64.js";import{i as o}from"../../../../chunks/mat4.js";import{a as s}from"../../../../chunks/mat4f64.js";import{e as i,f as n,B as l,l as a,n as u,p 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 v}from"../../../../chunks/vec32.js";import{t as j,s as B}from"../../../../chunks/vec42.js";import{n as M}from"../../../../chunks/vec22.js";import{c as F}from"../../../../chunks/vec33.js";import{c as S}from"../../../../chunks/vec43.js";import{DefaultLoadingContext as L}from"../../glTF/DefaultLoadingContext.js";import{loadGLTF as A}from"../../glTF/loader.js";import{convertPrimitiveToTriangles as k}from"../../glTF/internal/indexUtils.js";import{isEncodedMeshTexture as C}from"../../glTF/internal/resourceUtils.js";import{getTransformMatrix as E}from"../../glTF/internal/TextureTransformUtils.js";import{ProcessedObjectResource as I}from"./ProcessedObjectResource.js";import{load as O,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 H}from"../../webgl-engine/lib/Geometry.js";import{Texture as q}from"../../webgl-engine/lib/Texture.js";import{VertexAttribute as G}from"../../webgl-engine/lib/VertexAttribute.js";import{DefaultMaterial as W}from"../../webgl-engine/materials/DefaultMaterial.js";import{colorGamma as $}from"../../webgl-engine/materials/DefaultMaterial_COLOR_GAMMA.js";import{defaultEsriSymbologyMRRFactors as z,defaultAdvancedMRRFactors as K,useSchematicPBR as Q,defaultSchematicMRRFactors as J}from"../../webgl-engine/materials/pbrUtils.js";async function X(t,r){const o=Y(e(t));if("wosr"===o.fileType){const e=await(r.cache?r.cache.loadWOSR(o.url,r):O(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):A(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,a=s.meta.isEsriSymbolResource?{usePBR:l,isSchematic:!1,treeRendering:n,mrrFactors:[...z]}:{usePBR:l,isSchematic:!1,treeRendering:!1,mrrFactors:[...K]},u={...r.materialParameters,treeRendering:n},{engineResources:c,referenceBoundingBox:m}=Z(s,a,u,r.skipHighLods&&null==o.specifiedLodIndex?{skipHighLods:!0}:{skipHighLods:!1,singleLodIndex:o.specifiedLodIndex});return{lods:c,referenceBoundingBox:m,isEsriSymbolResource:s.meta.isEsriSymbolResource,isWosr:!1}}function Y(e){const t=e.match(/(.*\.(gltf|glb))(\?lod=([0-9]+))?$/);if(t)return{fileType:"gltf",url:t[1],specifiedLodIndex:null!=t[4]?Number(t[4]):null};return e.match(/(.*\.(json|json\.gz))$/)?{fileType:"wosr",url:e,specifiedLodIndex:null}:{fileType:"unknown",url:e,specifiedLodIndex:null}}function Z(e,t,r,o){const s=e.model,i=new Array,n=new Map,l=new Map,a=s.lods.length,u=f();return s.lods.forEach(((e,c)=>{const m=!0===o.skipHighLods&&(a>1&&0===c||a>3&&1===c)||!1===o.skipHighLods&&null!=o.singleLodIndex&&c!==o.singleLodIndex;if(m&&0!==c)return;const f=new I(e.name,e.lodThreshold,[0,0,0]);e.parts.forEach((e=>{const o=m?new W({}):ee(s,e,f,t,r,n,l),{geometry:i,vertexCount:a}=te(e,null!=o?o:new W({})),p=i.boundingInfo;null!=p&&0===c&&(d(u,p.bbMin),d(u,p.bbMax)),null!=o&&(f.stageResources.geometries.push(i),f.numberOfVertices+=a)})),m||i.push(f)})),{engineResources:i,referenceBoundingBox:u}}function ee(e,t,r,o,s,i,n){const l=t.material+(t.attributes.normal?"_normal":"")+(t.attributes.color?"_color":"")+(t.attributes.texCoord0?"_texCoord0":"")+(t.attributes.tangent?"_tangent":""),a=e.materials.get(t.material),u=null!=t.attributes.texCoord0,c=null!=t.attributes.normal;if(null==a)return null;const m=oe(a.alphaMode);if(!i.has(l)){if(u){const t=(t,r=!1)=>{if(null!=t&&!n.has(t)){const o=e.textures.get(t);if(null!=o){const e=o.data;n.set(t,new q(C(e)?e.data:e,{...o.parameters,preMultiplyAlpha:!C(e)&&r,encoding:C(e)&&null!=e.encoding?e.encoding:void 0}))}}};t(a.textureColor,m!==V.Opaque),t(a.textureNormal),t(a.textureOcclusion),t(a.textureEmissive),t(a.textureMetallicRoughness)}const r=a.color[0]**(1/$),f=a.color[1]**(1/$),d=a.color[2]**(1/$),p=a.emissiveFactor[0]**(1/$),g=a.emissiveFactor[1]**(1/$),x=a.emissiveFactor[2]**(1/$),b=null!=a.textureColor&&u?n.get(a.textureColor):null,h=Q({normalTexture:a.textureNormal,metallicRoughnessTexture:a.textureMetallicRoughness,metallicFactor:a.metallicFactor,roughnessFactor:a.roughnessFactor,emissiveTexture:a.textureEmissive,emissiveFactor:a.emissiveFactor,occlusionTexture:a.textureOcclusion});i.set(l,new W({...o,transparent:m===V.Blend,customDepthTest:D.Lequal,textureAlphaMode:m,textureAlphaCutoff:a.alphaCutoff,diffuse:[r,f,d],ambient:[r,f,d],opacity:a.opacity,doubleSided:a.doubleSided,doubleSidedType:"winding-order",cullFace:a.doubleSided?_.None:_.Back,hasVertexColors:!!t.attributes.color,hasVertexTangents:!!t.attributes.tangent,normalType:c?P.Attribute:P.ScreenDerivative,castShadows:!0,textureId:null!=b?b.id:void 0,colorMixMode:a.colorMixMode,normalTextureId:null!=a.textureNormal&&u?n.get(a.textureNormal).id:void 0,textureAlphaPremultiplied:null!=b&&!!b.parameters.preMultiplyAlpha,occlusionTextureId:null!=a.textureOcclusion&&u?n.get(a.textureOcclusion).id:void 0,emissiveTextureId:null!=a.textureEmissive&&u?n.get(a.textureEmissive).id:void 0,metallicRoughnessTextureId:null!=a.textureMetallicRoughness&&u?n.get(a.textureMetallicRoughness).id:void 0,emissiveFactor:[p,g,x],mrrFactors:h?[...J]:[a.metallicFactor,a.roughnessFactor,o.mrrFactors[2]],isSchematic:h,colorTextureTransformMatrix:E(a.colorTextureTransform),normalTextureTransformMatrix:E(a.normalTextureTransform),occlusionTextureTransformMatrix:E(a.occlusionTextureTransform),emissiveTextureTransformMatrix:E(a.emissiveTextureTransform),metallicRoughnessTextureTransformMatrix:E(a.metallicRoughnessTextureTransform),...s}))}const f=i.get(l);if(r.stageResources.materials.push(f),u){const e=e=>{null!=e&&r.stageResources.textures.push(n.get(e))};e(a.textureColor),e(a.textureNormal),e(a.textureOcclusion),e(a.textureEmissive),e(a.textureMetallicRoughness)}return f}function te(e,r){const o=e.attributes.position.count,s=k(e.indices||o,e.primitiveType),i=p(3*o),{typedBuffer:n,typedBufferStride:l}=e.attributes.position;w(i,n,e.transform,3,l);const a=[[G.POSITION,new U(i,s,3,!0)]];if(null!=e.attributes.normal){const r=p(3*o),{typedBuffer:i,typedBufferStride:n}=e.attributes.normal;t(re,e.transform),R(r,i,re,3,n),a.push([G.NORMAL,new U(r,s,3,!0)])}if(null!=e.attributes.tangent){const r=p(4*o),{typedBuffer:i,typedBufferStride:n}=e.attributes.tangent;t(re,e.transform),j(r,i,re,4,n),a.push([G.TANGENT,new U(r,s,4,!0)])}if(null!=e.attributes.texCoord0){const t=p(2*o),{typedBuffer:r,typedBufferStride:i}=e.attributes.texCoord0;M(t,r,2,i),a.push([G.UV0,new U(t,s,2,!0)])}if(null!=e.attributes.color){const t=new Uint8Array(4*o);4===e.attributes.color.elementCount?e.attributes.color instanceof g?B(t,e.attributes.color,255):e.attributes.color instanceof x?S(t,e.attributes.color):e.attributes.color instanceof b&&B(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?F(t,e.attributes.color.typedBuffer,4,e.attributes.color.typedBufferStride):e.attributes.color instanceof y&&v(t,e.attributes.color,1/256,4)),a.push([G.COLOR,new U(t,s,4,!0)])}return{geometry:new H(r,a),vertexCount:o}}const re=r();function oe(e){switch(e){case"BLEND":return V.Blend;case"MASK":return V.Mask;case"OPAQUE":case null:case void 0:return V.Opaque}}function se(e,t){for(let r=0;r<e.model.lods.length;++r){const f=e.model.lods[r];for(const d of f.parts){const f=d.attributes.normal;if(null==f)return;const p=d.attributes.position,g=p.count,b=m(),T=m(),y=m(),w=new Uint8Array(4*g),R=new Float64Array(3*g),v=o(s(),d.transform);let j=0,B=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=a(y),g=Math.min(.45+.55*m*m,1);l(y,y,t.radius),null!==v&&i(y,y,v),u(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[B]=255*g,w[B+1]=255*g,w[B+2]=255*g,w[B+3]=255,B+=4}d.attributes.normal=new h(R),d.attributes.color=new x(w)}}}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.28/esri/copyright.txt for details.
4
4
  */
5
- import"../../../../geometry.js";import{deg2rad as t}from"../../../../core/mathUtils.js";import{getMetersPerUnitForSR as e,getMetersPerVerticalUnitForSR as r}from"../../../../core/unitUtils.js";import{e as o}from"../../../../chunks/earcut.js";import{s as i}from"../../../../chunks/vec3.js";import{Axis as n}from"../../../../geometry/support/Axis.js";import{getZeroIndexArray as a}from"../../../../geometry/support/Indices.js";import{create as s,fromManyPoints as u,normal as c}from"../../../../geometry/support/plane.js";import{Attribute as m}from"../../webgl-engine/lib/Attribute.js";import{ContentObjectType as p}from"../../webgl-engine/lib/ContentObjectType.js";import{Geometry as l}from"../../webgl-engine/lib/Geometry.js";import{VertexAttribute as b}from"../../webgl-engine/lib/VertexAttribute.js";import f from"../../../../geometry/Extent.js";import g from"../../../../geometry/Polygon.js";function h(t,o,n,a){const s=(t=>!Array.isArray(t[0]))(o)?(t,e)=>o[3*t+e]:(t,e)=>o[t][e],c=a?e(a)/r(a):1;return u(t,((t,e)=>i(t,s(e,0)*c,s(e,1)*c,s(e,2))),n)}function j(e,r,o){const i=h(y,e,r,o)?c(y):[0,0,1];return Math.abs(i[2])>Math.cos(t(80))?n.Z:Math.abs(i[1])>Math.abs(i[0])?n.Y:n.X}const y=s();function w(t,e,r){const i=j(t,(e.length>0?e[0]:t.length/3)-1,r);if(i!==n.Z){t=t.slice();for(let e=0;e<t.length;e+=3)t[e+i]=t[e+2]}return o(t,e,3)}function d(t){const e=[[b.POSITION,new m(t.attributeData.position,3,!0),t.indices]],r=a(t.indices.length);return null!=t.attributeData.colorFeature?e.push([b.COLORFEATUREATTRIBUTE,new m([t.attributeData.colorFeature],1,!0),r]):t.attributeData.color&&e.push([b.COLOR,new m(t.attributeData.color,4,!0),r]),t.attributeData.uvMapSpace&&e.push([b.UVMAPSPACE,new m(t.attributeData.uvMapSpace,4,!0),t.indices]),t.attributeData.boundingRect&&e.push([b.BOUNDINGRECT,new m(t.attributeData.boundingRect,9,!0),t.indices]),new l(t.material,e,t.mapPositions,p.Mesh,t.attributeData.objectAndLayerIdColor)}function D(t,e=null){const r=[[b.POSITION,new m(t.attributeData.position,3,!0),t.indices],[b.UV0,new m(t.attributeData.uv0,2,!0),t.indices]];return new l(t.material,r,t.mapPositions,p.Mesh,e)}function A(t){switch(t.type){case"extent":if(t instanceof f)return g.fromExtent(t);break;case"polygon":return t}return null}class O{constructor(t,e,r){this.renderData=t,this.layerUid=e,this.graphicUid=r,this.outGeometries=new Array}}export{O as PolygonCreationDataBase,d as createColorGeometry,w as createIndices3D,D as createWaterGeometry,h as fitPlane,A as geometryAsPolygon,j as leastSignificantAxis};
5
+ import"../../../../geometry.js";import{deg2rad as t}from"../../../../core/mathUtils.js";import{getMetersPerUnitForSR as e,getMetersPerVerticalUnitForSR as r}from"../../../../core/unitUtils.js";import{e as o}from"../../../../chunks/earcut.js";import{s as i}from"../../../../chunks/vec3.js";import{Axis as n}from"../../../../geometry/support/Axis.js";import{getZeroIndexArray as a}from"../../../../geometry/support/Indices.js";import{create as s,fromManyPoints as u,normal as c}from"../../../../geometry/support/plane.js";import{Attribute as m}from"../../webgl-engine/lib/Attribute.js";import{ContentObjectType as p}from"../../webgl-engine/lib/ContentObjectType.js";import{Geometry as l}from"../../webgl-engine/lib/Geometry.js";import{VertexAttribute as b}from"../../webgl-engine/lib/VertexAttribute.js";import f from"../../../../geometry/Extent.js";import g from"../../../../geometry/Polygon.js";function h(t,o,n,a){const s=(t=>!Array.isArray(t[0]))(o)?(t,e)=>o[3*t+e]:(t,e)=>o[t][e],c=a?e(a)/r(a):1;return u(t,((t,e)=>i(t,s(e,0)*c,s(e,1)*c,s(e,2))),n)}function j(e,r,o){const i=h(y,e,r,o)?c(y):[0,0,1];return Math.abs(i[2])>Math.cos(t(80))?n.Z:Math.abs(i[1])>Math.abs(i[0])?n.Y:n.X}const y=s();function w(t,e,r){const i=j(t,(e.length>0?e[0]:t.length/3)-1,r);if(i!==n.Z){t=t.slice();for(let e=0;e<t.length;e+=3)t[e+i]=t[e+2]}return o(t,e,3)}function d(t){const e=[[b.POSITION,new m(t.attributeData.position,t.indices,3,!0)]],r=a(t.indices.length);return null!=t.attributeData.colorFeature?e.push([b.COLORFEATUREATTRIBUTE,new m([t.attributeData.colorFeature],r,1,!0)]):t.attributeData.color&&e.push([b.COLOR,new m(t.attributeData.color,r,4,!0)]),t.attributeData.uvMapSpace&&e.push([b.UVMAPSPACE,new m(t.attributeData.uvMapSpace,t.indices,4,!0)]),t.attributeData.boundingRect&&e.push([b.BOUNDINGRECT,new m(t.attributeData.boundingRect,t.indices,9,!0)]),new l(t.material,e,t.mapPositions,p.Mesh,t.attributeData.objectAndLayerIdColor)}function D(t,e=null){const r=[[b.POSITION,new m(t.attributeData.position,t.indices,3,!0)],[b.UV0,new m(t.attributeData.uv0,t.indices,2,!0)]];return new l(t.material,r,t.mapPositions,p.Mesh,e)}function A(t){switch(t.type){case"extent":if(t instanceof f)return g.fromExtent(t);break;case"polygon":return t}return null}class O{constructor(t,e,r){this.renderData=t,this.layerUid=e,this.graphicUid=r,this.outGeometries=new Array}}export{O as PolygonCreationDataBase,d as createColorGeometry,w as createIndices3D,D as createWaterGeometry,h as fitPlane,A as geometryAsPolygon,j as leastSignificantAxis};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../../../request.js";import{result as t}from"../../../../core/asyncUtils.js";import{estimateNestedObjectSize as r}from"../../../../core/byteSizeEstimations.js";import n from"../../../../core/Error.js";import s from"../../../../core/Logger.js";import{NestedMap as a}from"../../../../core/NestedMap.js";import{throwIfAbortError as o}from"../../../../core/promiseUtils.js";import{Version as i}from"../../../../core/Version.js";import{e as l}from"../../../../chunks/vec3f64.js";import{empty as u,expandWithVec3 as c}from"../../../../geometry/support/aaBoundingBox.js";import{requestImage as p}from"../../../../support/requestImageUtils.js";import{Attribute as m}from"../../webgl-engine/lib/Attribute.js";import{CullFaceOptions as f,AlphaDiscardMode as d}from"../../webgl-engine/lib/basicInterfaces.js";import{Geometry as g}from"../../webgl-engine/lib/Geometry.js";import{Texture as y}from"../../webgl-engine/lib/Texture.js";import{VertexAttribute as b}from"../../webgl-engine/lib/VertexAttribute.js";import{DefaultMaterial as w}from"../../webgl-engine/materials/DefaultMaterial.js";import{TextureWrapMode as x}from"../../../webgl/enums.js";const h=s.getLogger("esri.views.3d.layers.graphics.objectResourceUtils");async function v(e,t){const n=await A(e,t),s=await T(n.textureDefinitions??{},t);let a=0;for(const r in s)if(s.hasOwnProperty(r)){const e=s[r];a+=e?.image?e.image.width*e.image.height*4:0}return{resource:n,textures:s,size:a+r(n)}}async function A(r,n){const s=null!=n&&n.streamDataRequester;if(s)return j(r,s,n);const a=await t(e(r,n));if(!0===a.ok)return a.value.data;o(a.error),P(a.error)}async function j(e,r,n){const s=await t(r.request(e,"json",n));if(!0===s.ok)return s.value;o(s.error),P(s.error.details.url)}function P(e){throw new n("",`Request for object resource failed: ${e}`)}function I(e){const t=e.params,r=t.topology;let n=!0;switch(t.vertexAttributes||(h.warn("Geometry must specify vertex attributes"),n=!1),t.topology){case"PerAttributeArray":break;case"Indexed":case null:case void 0:{const e=t.faces;if(e){if(t.vertexAttributes)for(const r in t.vertexAttributes){const t=e[r];t&&t.values?(null!=t.valueType&&"UInt32"!==t.valueType&&(h.warn(`Unsupported indexed geometry indices type '${t.valueType}', only UInt32 is currently supported`),n=!1),null!=t.valuesPerElement&&1!==t.valuesPerElement&&(h.warn(`Unsupported indexed geometry values per element '${t.valuesPerElement}', only 1 is currently supported`),n=!1)):(h.warn(`Indexed geometry does not specify face indices for '${r}' attribute`),n=!1)}}else h.warn("Indexed geometries must specify faces"),n=!1;break}default:h.warn(`Unsupported topology '${r}'`),n=!1}e.params.material||(h.warn("Geometry requires material"),n=!1);const s=e.params.vertexAttributes;for(const a in s){s[a].values||(h.warn("Geometries with externally defined attributes are not yet supported"),n=!1)}return n}function M(e,t){const r=new Array,n=new Array,s=new Array,o=new a,u=e.resource,c=i.parse(u.version||"1.0","wosr");O.validate(c);const p=u.model.name,d=u.model.geometries,x=u.materialDefinitions??{},h=e.textures;let v=0;const A=new Map;for(let a=0;a<d.length;a++){const e=d[a];if(!I(e))continue;const i=k(e),u=e.params.vertexAttributes,c=[],p=t=>{if("PerAttributeArray"===e.params.topology)return null;const r=e.params.faces;for(const e in r)if(e===t)return r[e].values;return null};for(const t in u){const e=u[t],r=e.values,n=p(t);c.push([t,new m(r,e.valuesPerElement,!0),n])}const j=i.texture,P=h&&h[j];if(P&&!A.has(j)){const{image:e,parameters:t}=P,r=new y(e,t);n.push(r),A.set(j,r)}const M=A.get(j),U=M?M.id:void 0,T=i.material;let O=o.get(T,j);if(null==O){const e=x[T.substring(T.lastIndexOf("/")+1)].params;1===e.transparency&&(e.transparency=0);const r=P&&P.alphaChannelUsage,n=e.transparency>0||"transparency"===r||"maskAndTransparency"===r,s=P?E(P.alphaChannelUsage):void 0,a={ambient:l(e.diffuse),diffuse:l(e.diffuse),opacity:1-(e.transparency||0),transparent:n,textureAlphaMode:s,textureAlphaCutoff:.33,textureId:U,initTextureTransparent:!0,doubleSided:!0,cullFace:f.None,colorMixMode:e.externalColorMixMode||"tint",textureAlphaPremultiplied:P?.parameters.preMultiplyAlpha??!1};null!=t&&t.materialParameters&&Object.assign(a,t.materialParameters),O=new w(a),o.set(T,j,O)}s.push(O);const q=new g(O,c);v+=c.find((e=>e[0]===b.POSITION))?.[2]?.length??0,r.push(q)}return{engineResources:[{name:p,stageResources:{textures:n,materials:s,geometries:r},pivotOffset:u.model.pivotOffset,numberOfVertices:v,lodThreshold:null}],referenceBoundingBox:U(r)}}function U(e){const t=u();return e.forEach((e=>{const r=e.boundingInfo;null!=r&&(c(t,r.bbMin),c(t,r.bbMax))})),t}async function T(e,t){const r=new Array;for(const a in e){const n=e[a],s=n.images[0].data;if(!s){h.warn("Externally referenced texture data is not yet supported");continue}const o=n.encoding+";base64,"+s,i="/textureDefinitions/"+a,l="rgba"===n.channels?n.alphaChannelUsage||"transparency":"none",u={noUnpackFlip:!0,wrap:{s:x.REPEAT,t:x.REPEAT},preMultiplyAlpha:E(l)!==d.Opaque},c=null!=t&&t.disableTextures?Promise.resolve(null):p(o,t);r.push(c.then((e=>({refId:i,image:e,parameters:u,alphaChannelUsage:l}))))}const n=await Promise.all(r),s={};for(const a of n)s[a.refId]=a;return s}function E(e){switch(e){case"mask":return d.Mask;case"maskAndTransparency":return d.MaskBlend;case"none":return d.Opaque;default:return d.Blend}}function k(e){const t=e.params;return{id:1,material:t.material,texture:t.texture,region:t.texture}}const O=new i(1,2,"wosr");export{T as createTextureResources,v as load,M as processLoadResult};
5
+ import e from"../../../../request.js";import{result as t}from"../../../../core/asyncUtils.js";import{estimateNestedObjectSize as r}from"../../../../core/byteSizeEstimations.js";import n from"../../../../core/Error.js";import s from"../../../../core/Logger.js";import{NestedMap as a}from"../../../../core/NestedMap.js";import{throwIfAbortError as o}from"../../../../core/promiseUtils.js";import{Version as i}from"../../../../core/Version.js";import{e as l}from"../../../../chunks/vec3f64.js";import{empty as u,expandWithVec3 as c}from"../../../../geometry/support/aaBoundingBox.js";import{getContinuousIndexArray as p}from"../../../../geometry/support/Indices.js";import{requestImage as m}from"../../../../support/requestImageUtils.js";import{Attribute as f}from"../../webgl-engine/lib/Attribute.js";import{CullFaceOptions as d,AlphaDiscardMode as g}from"../../webgl-engine/lib/basicInterfaces.js";import{Geometry as y}from"../../webgl-engine/lib/Geometry.js";import{Texture as b}from"../../webgl-engine/lib/Texture.js";import{VertexAttribute as w}from"../../webgl-engine/lib/VertexAttribute.js";import{DefaultMaterial as x}from"../../webgl-engine/materials/DefaultMaterial.js";import{TextureWrapMode as h}from"../../../webgl/enums.js";const v=s.getLogger("esri.views.3d.layers.graphics.objectResourceUtils");async function A(e,t){const n=await j(e,t),s=await E(n.textureDefinitions??{},t);let a=0;for(const r in s)if(s.hasOwnProperty(r)){const e=s[r];a+=e?.image?e.image.width*e.image.height*4:0}return{resource:n,textures:s,size:a+r(n)}}async function j(r,n){const s=null!=n&&n.streamDataRequester;if(s)return I(r,s,n);const a=await t(e(r,n));if(!0===a.ok)return a.value.data;o(a.error),P(a.error)}async function I(e,r,n){const s=await t(r.request(e,"json",n));if(!0===s.ok)return s.value;o(s.error),P(s.error.details.url)}function P(e){throw new n("",`Request for object resource failed: ${e}`)}function M(e){const t=e.params,r=t.topology;let n=!0;switch(t.vertexAttributes||(v.warn("Geometry must specify vertex attributes"),n=!1),t.topology){case"PerAttributeArray":break;case"Indexed":case null:case void 0:{const e=t.faces;if(e){if(t.vertexAttributes)for(const r in t.vertexAttributes){const t=e[r];t&&t.values?(null!=t.valueType&&"UInt32"!==t.valueType&&(v.warn(`Unsupported indexed geometry indices type '${t.valueType}', only UInt32 is currently supported`),n=!1),null!=t.valuesPerElement&&1!==t.valuesPerElement&&(v.warn(`Unsupported indexed geometry values per element '${t.valuesPerElement}', only 1 is currently supported`),n=!1)):(v.warn(`Indexed geometry does not specify face indices for '${r}' attribute`),n=!1)}}else v.warn("Indexed geometries must specify faces"),n=!1;break}default:v.warn(`Unsupported topology '${r}'`),n=!1}e.params.material||(v.warn("Geometry requires material"),n=!1);const s=e.params.vertexAttributes;for(const a in s){s[a].values||(v.warn("Geometries with externally defined attributes are not yet supported"),n=!1)}return n}function T(e,t){const r=new Array,n=new Array,s=new Array,o=new a,u=e.resource,c=i.parse(u.version||"1.0","wosr");q.validate(c);const m=u.model.name,g=u.model.geometries,h=u.materialDefinitions??{},v=e.textures;let A=0;const j=new Map;for(let a=0;a<g.length;a++){const e=g[a];if(!M(e))continue;const i=k(e),u=e.params.vertexAttributes,c=[],m=t=>{if("PerAttributeArray"===e.params.topology)return null;const r=e.params.faces;for(const e in r)if(e===t)return r[e].values;return null},I=u[w.POSITION],P=I.values.length/I.valuesPerElement;for(const t in u){const e=u[t],r=e.values,n=m(t)??p(P);c.push([t,new f(r,n,e.valuesPerElement,!0)])}const T=i.texture,U=v&&v[T];if(U&&!j.has(T)){const{image:e,parameters:t}=U,r=new b(e,t);n.push(r),j.set(T,r)}const E=j.get(T),q=E?E.id:void 0,R=i.material;let B=o.get(R,T);if(null==B){const e=h[R.substring(R.lastIndexOf("/")+1)].params;1===e.transparency&&(e.transparency=0);const r=U&&U.alphaChannelUsage,n=e.transparency>0||"transparency"===r||"maskAndTransparency"===r,s=U?O(U.alphaChannelUsage):void 0,a={ambient:l(e.diffuse),diffuse:l(e.diffuse),opacity:1-(e.transparency||0),transparent:n,textureAlphaMode:s,textureAlphaCutoff:.33,textureId:q,initTextureTransparent:!0,doubleSided:!0,cullFace:d.None,colorMixMode:e.externalColorMixMode||"tint",textureAlphaPremultiplied:U?.parameters.preMultiplyAlpha??!1};null!=t&&t.materialParameters&&Object.assign(a,t.materialParameters),B=new x(a),o.set(R,T,B)}s.push(B);const C=new y(B,c);A+=c.find((e=>e[0]===w.POSITION))?.[1]?.indices.length??0,r.push(C)}return{engineResources:[{name:m,stageResources:{textures:n,materials:s,geometries:r},pivotOffset:u.model.pivotOffset,numberOfVertices:A,lodThreshold:null}],referenceBoundingBox:U(r)}}function U(e){const t=u();return e.forEach((e=>{const r=e.boundingInfo;null!=r&&(c(t,r.bbMin),c(t,r.bbMax))})),t}async function E(e,t){const r=new Array;for(const a in e){const n=e[a],s=n.images[0].data;if(!s){v.warn("Externally referenced texture data is not yet supported");continue}const o=n.encoding+";base64,"+s,i="/textureDefinitions/"+a,l="rgba"===n.channels?n.alphaChannelUsage||"transparency":"none",u={noUnpackFlip:!0,wrap:{s:h.REPEAT,t:h.REPEAT},preMultiplyAlpha:O(l)!==g.Opaque},c=null!=t&&t.disableTextures?Promise.resolve(null):m(o,t);r.push(c.then((e=>({refId:i,image:e,parameters:u,alphaChannelUsage:l}))))}const n=await Promise.all(r),s={};for(const a of n)s[a.refId]=a;return s}function O(e){switch(e){case"mask":return g.Mask;case"maskAndTransparency":return g.MaskBlend;case"none":return g.Opaque;default:return g.Blend}}function k(e){const t=e.params;return{id:1,material:t.material,texture:t.texture,region:t.texture}}const q=new i(1,2,"wosr");export{E as createTextureResources,A as load,T as processLoadResult};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../../../request.js";import{binaryIndexOf as t,splitIntoChunks as r}from"../../../../core/arrayUtils.js";import n from"../../../../core/Error.js";import has from"../../../../core/has.js";import{isInt16Array as o,isInt32Array as a}from"../../../../core/typedArrayUtil.js";import{b as i}from"../../../../chunks/mat3.js";import{a as s}from"../../../../chunks/mat3f64.js";import{i as l}from"../../../../chunks/mat4.js";import{a as c}from"../../../../chunks/mat4f64.js";import{c as u,m as f,a as p}from"../../../../chunks/quat.js";import{a as m}from"../../../../chunks/quatf64.js";import{s as h,c as d,u as y,v as g,i as b,g as S,e as w}from"../../../../chunks/vec3.js";import{c as T}from"../../../../chunks/vec3f64.js";import{getReferenceEllipsoid as E}from"../../../../geometry/ellipsoidUtils.js";import{canProjectWithoutEngine as v}from"../../../../geometry/projection.js";import j from"../../../../geometry/SpatialReference.js";import{getSphericalPCPF as M}from"../../../../geometry/spatialReferenceEllipsoidUtils.js";import{computeTranslationToOriginAndRotation as R}from"../../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{projectBuffer as I}from"../../../../geometry/projection/projectBuffer.js";import{projectVectorToVector as x}from"../../../../geometry/projection/projectVectorToVector.js";import{create as q,empty as k,expandPointInPlace as C,intersects as U}from"../../../../geometry/support/aaBoundingRect.js";import{isPlateCarree as N}from"../../../../geometry/support/spatialReferenceUtils.js";import z from"../../../../rest/support/Query.js";import{readBinaryAttribute as W}from"./I3SBinaryReader.js";import{computeGlobalTransformation as A}from"./I3SProjectionUtil.js";import{createSolidEdgeMaterial as D,createMaterialFromEdges as F}from"../support/edgeUtils.js";import{parseColorMixMode as O,ColorMixModeEnum as _}from"../support/symbolColorUtils.js";import{create as L,compute as G,corners as K}from"../../support/orientedBoundingBox.js";import{Attribute as B}from"../../webgl-engine/lib/Attribute.js";function P(e){return e?parseInt(e.substring(e.lastIndexOf("/")+1,e.length),10):void 0}function $(e){if(has("disable-feature:i3s-draco")||!e)return!1;for(const t of e)for(const e of t.geometryBuffers)if("draco"===e.compressedAttributes?.encoding)return!0;return!1}function V(e,t,r,n){r.traverse(t,(t=>{const r=t.mbs;return(null!=r&&Y(e,r))!==X.OUTSIDE&&(n(t),!0)}))}function Q(e,t,r){let n=0,o=0;for(let a=0;a<t.length&&n<e.length;a++)e[n]===t[a]&&(r(a)&&(e[o]=e[n],o++),n++);e.length=o}function Z(e,r,n){let o=0,a=0;for(;o<n.length;){t(e,n[o])>=0===r&&(n[a]=n[o],a++),o++}n.length=a}const H=q();function J(e,t){if(0===t.rotationScale[1]&&0===t.rotationScale[2]&&0===t.rotationScale[3]&&0===t.rotationScale[5]&&0===t.rotationScale[6]&&0===t.rotationScale[7])return H[0]=(e[0]-t.position[0])/t.rotationScale[0],H[1]=(e[1]-t.position[1])/t.rotationScale[4],H[2]=(e[2]-t.position[0])/t.rotationScale[0],H[3]=(e[3]-t.position[1])/t.rotationScale[4],H}var X;function Y(e,t){const r=t[0],n=t[1],o=t[3],a=e[0]-r,i=r-e[2],s=e[1]-n,l=n-e[3],c=Math.max(a,i,0),u=Math.max(s,l,0),f=c*c+u*u;if(f>o*o)return X.OUTSIDE;if(f>0)return X.INTERSECTS_CENTER_OUTSIDE;return-Math.max(a,i,s,l)>o?X.INSIDE:X.INTERSECTS_CENTER_INSIDE}function ee(e,t,r){const n=[],o=r&&r.missingFields,a=r&&r.originalFields;for(const i of e){const e=i.toLowerCase();let r=!1;for(const o of t)if(e===o.name.toLowerCase()){n.push(o.name),r=!0,a&&a.push(i);break}!r&&o&&o.push(i)}return n}async function te(e,t,r,o,a){if(0===t.length)return[];const i=e.attributeStorageInfo;if(null!=e.associatedLayer)try{return await ne(e.associatedLayer,t,r,o)}catch(s){if(e.associatedLayer.loaded)throw s}if(i){const s=re(t,r,a);if(null==s)throw new n("scenelayer:features-not-loaded","Tried to query attributes for unloaded features");const l=e.parsedUrl.path;return(await Promise.all(s.map((e=>ae(l,i,e.node,e.indices,o).then((t=>{for(let r=0;r<e.graphics.length;r++){const n=e.graphics[r],o=t[r];if(n.attributes)for(const e in n.attributes)e in o||(o[e]=n.attributes[e]);n.attributes=o}return e.graphics})))))).flat()}throw new n("scenelayer:no-attribute-source","This scene layer does not have a source for attributes available")}function re(e,t,r){const n=new Map,o=[],a=r();for(const i of e){const e=i.attributes[t];for(let t=0;t<a.length;t++){const r=a[t],s=r.featureIds.indexOf(e);if(s>=0){let e=n.get(r.node);e||(e={node:r.node,indices:[],graphics:[]},o.push(e),n.set(r.node,e)),e.indices.push(s),e.graphics.push(i);for(let r=t;r>0;r--)a[r]=a[r-1];a[0]=r;break}}}return o}async function ne(e,t,r,n){t.sort(((e,t)=>e.attributes[r]-t.attributes[r]));const o=t.map((e=>e.attributes[r])),a=[],i=ee(n,e.fields,{originalFields:a}),s=await oe(e,o,i);for(let l=0;l<t.length;l++){const e=t[l],r=s[l],n={};if(e.attributes)for(const t in e.attributes)n[t]=e.attributes[t];for(let t=0;t<a.length;t++)n[a[t]]=r[i[t]];e.attributes=n}return t}function oe(e,t,o){const a=e.capabilities.query.maxRecordCount;if(null!=a&&t.length>a){const n=r(t,a);return Promise.all(n.map((t=>oe(e,t,o)))).then((e=>e.flat()))}const i=new z({objectIds:t,outFields:o,orderByFields:[e.objectIdField]});return e.queryFeatures(i).then((e=>{if(e&&e.features&&e.features.length===t.length)return e.features.map((e=>e.attributes));throw new n("scenelayer:feature-not-in-associated-layer","Feature not found in associated feature layer")}))}function ae(e,t,r,n,o){return ie(e,t,r.resources.attributes,n,o)}async function ie(t,r,n,o,a){const i=[];for(const e of r)if(e&&a.includes(e.name)){const r=`${t}/nodes/${n}/attributes/${e.key}/0`;i.push({url:r,storageInfo:e})}const s=await Promise.allSettled(i.map((t=>e(t.url,{responseType:"array-buffer"}).then((e=>W(t.storageInfo,e.data)))))),l=[];for(const e of o){const t={};for(let r=0;r<s.length;r++){const n=s[r];if("fulfilled"===n.status){const o=n.value;t[i[r].storageInfo.name]=ce(o,e)}}l.push(t)}return l}!function(e){e[e.OUTSIDE=0]="OUTSIDE",e[e.INTERSECTS_CENTER_OUTSIDE=1]="INTERSECTS_CENTER_OUTSIDE",e[e.INTERSECTS_CENTER_INSIDE=2]="INTERSECTS_CENTER_INSIDE",e[e.INSIDE=3]="INSIDE"}(X||(X={}));const se=-32768,le=-(2**31);function ce(e,t){if(!e)return null;const r=e[t];if(o(e))return r===se?null:r;if(a(e))return r===le?null:r;return r!=r?null:r}function ue(e){const t=e.store,r=t.indexCRS||t.geographicCRS,o=void 0===r?t.indexWKT:void 0;if(o){if(!e.spatialReference)throw new n("layerview:no-store-spatial-reference-wkt-index-and-no-layer-spatial-reference","Found indeWKT in the scene layer store but no layer spatial reference",{});if(o!==e.spatialReference.wkt)throw new n("layerview:store-spatial-reference-wkt-index-incompatible","The indeWKT of the scene layer store does not match the WKT of the layer spatial reference",{})}const a=r?new j(P(r)):e.spatialReference;return a.equals(e.spatialReference)?e.spatialReference:a}function fe(e){const t=e.store,r=t.vertexCRS||t.projectedCRS,o=void 0===r?t.vertexWKT:void 0;if(o){if(!e.spatialReference)throw new n("layerview:no-store-spatial-reference-wkt-vertex-and-no-layer-spatial-reference","Found vertexWKT in the scene layer store but no layer spatial reference",{});if(o!==e.spatialReference.wkt)throw new n("layerview:store-spatial-reference-wkt-vertex-incompatible","The vertexWKT of the scene layer store does not match the WKT of the layer spatial reference",{})}const a=r?new j(P(r)):e.spatialReference;return a.equals(e.spatialReference)?e.spatialReference:a}function pe(e,t){return null==t?"@null":t===M(t)?"@ECEF":e.equals(t)?"":null!=t.wkid?"@"+t.wkid:null}function me(e,t,r){if(!v(e,t))throw new n("layerview:spatial-reference-incompatible","The spatial reference of this scene layer is incompatible with the spatial reference of the view",{});if("local"===r&&!de(e,t))throw new n("layerview:spatial-reference-incompatible","The spatial reference of this scene layer is incompatible with the spatial reference of the view",{})}function he(e,t,r){if(e.serviceUpdateTimeStamp?.lastUpdate!==t.serviceUpdateTimeStamp?.lastUpdate||!r.isEmpty||e.associatedLayer?.url!==t.associatedLayer?.url)throw new n("layerview:recycle-failed")}function de(e,t){return e.equals(t)||e.isWGS84&&t.isWebMercator||e.isWebMercator&&t.isWGS84}function ye(e,t,r){const n=ue(e),o=fe(e);me(n,t,r),me(o,t,r)}function ge(e){return(null==e.geometryType||"triangles"===e.geometryType)&&((null==e.topology||"PerAttributeArray"===e.topology)&&(null!=e.vertexAttributes&&null!=e.vertexAttributes.position))}function be(e){if(null==e.store||null==e.store.defaultGeometrySchema||!ge(e.store.defaultGeometrySchema))throw new n("scenelayer:unsupported-geometry-schema","The geometry schema of this scene layer is not supported.",{url:e.parsedUrl.path})}function Se(e,t){ye(e,t.spatialReference,t.viewingMode)}function we(e){return null!=e.geometryType&&"points"===e.geometryType&&((null==e.topology||"PerAttributeArray"===e.topology)&&((null==e.encoding||""===e.encoding||"lepcc-xyz"===e.encoding)&&(null!=e.vertexAttributes&&null!=e.vertexAttributes.position)))}function Te(e){if(null==e.store||null==e.store.defaultGeometrySchema||!we(e.store.defaultGeometrySchema))throw new n("pointcloud:unsupported-geometry-schema","The geometry schema of this point cloud scene layer is not supported.",{})}function Ee(e,t){me(e.spatialReference,t.spatialReference,t.viewingMode)}function ve(e){return"simple"===e.type||"class-breaks"===e.type||"unique-value"===e.type}function je(e){return"mesh-3d"===e.type}function Me(e){if(null==e||!ve(e))return!0;if(("unique-value"===e.type||"class-breaks"===e.type)&&null==e.defaultSymbol)return!0;const t=e.getSymbols();if(0===t.length)return!0;for(const r of t){if(!je(r)||0===r.symbolLayers.length)return!0;for(const e of r.symbolLayers.items)if("fill"!==e.type||null==e.material||null==e.material.color||"replace"!==e.material.colorMixMode)return!0}return!1}const Re=D({color:[0,0,0,0],opacity:0});class Ie{constructor(){this.edgeMaterial=null,this.material=null,this.castShadows=!0}}function xe(e){const t=new Ie;let r=!1,n=!1;for(const o of e.symbolLayers.items)if("fill"===o.type&&o.enabled){const e=o.material,a=o.edges;if(null!=e&&!r){const n=e.color,a=O(e.colorMixMode);t.material=null!=n?{color:[n.r/255,n.g/255,n.b/255],alpha:n.a,colorMixMode:a}:{color:[1,1,1],alpha:1,colorMixMode:_.Multiply},t.castShadows=o.castShadows,r=!0}null==a||n||(t.edgeMaterial=F(a,{}),n=!0)}return t.material||(t.material={color:[1,1,1],alpha:1,colorMixMode:_.Multiply}),t}function qe(e,t){return(0|e)+(0|t)|0}function ke(e,t,r,n,o=0){n===M(n)?t.isGeographic?_e(e,r,t,o):Oe(e,r,t,o):t.isWGS84&&(n.isWebMercator||N(n))?Ce(t,e,n,r,o):t.isWebMercator&&N(n)?De(t,e,n,r,o):e===r?(r.center[2]+=o,I(r.center,t,0,r.center,n,0,1)):(h(r.center,e.center[0],e.center[1],e.center[2]+o),I(r.center,t,0,r.center,n,0,1),u(r.quaternion,e.quaternion),d(r.halfSize,e.halfSize))}function Ce(e,t,r,n,o){d(We,t.center),We[2]+=o;const a=M(r);I(We,e,0,We,a,0,1),Fe(a,t,We,r,n)}const Ue=new Array(24),Ne=new B(Ue,3,!0),ze=T(),We=T(),Ae=s();function De(e,t,r,n,o){d(We,t.center),We[2]+=o,Fe(e,t,We,r,n)}function Fe(e,t,r,n,o){const a=i(Ae,t.quaternion);for(let i=0;i<8;++i){for(let e=0;e<3;++e)ze[e]=t.halfSize[e]*(0!=(i&1<<e)?-1:1);for(let e=0;e<3;++e){let t=r[e];for(let r=0;r<3;++r)t+=ze[r]*a[3*r+e];Ue[3*i+e]=t}}I(Ue,e,0,Ue,n,0,8),G(Ne,o)}function Oe(e,t,r,n){K(e,Qe),h(t.center,e.center[0],e.center[1],e.center[2]+n),R(r,t.center,$e,M(r)),h(t.center,$e[12],$e[13],$e[14]);const o=2*Math.sqrt(1+$e[0]+$e[5]+$e[10]);Ve[0]=($e[6]-$e[9])/o,Ve[1]=($e[8]-$e[2])/o,Ve[2]=($e[1]-$e[4])/o,Ve[3]=.25*o,f(t.quaternion,Ve,e.quaternion),p(Ve,t.quaternion);let a=0,i=0,s=0;for(const l of Qe)l[2]+=n,I(l,r,0,l,M(r),0,1),y(Xe,l,t.center),g(Xe,Xe,Ve),a=Math.max(a,Math.abs(Xe[0])),i=Math.max(i,Math.abs(Xe[1])),s=Math.max(s,Math.abs(Xe[2]));h(t.halfSize,a,i,s)}function _e(e,t,r,n){const o=E(r),a=1+Math.max(0,n)/(o.radius+e.center[2]);h(t.center,e.center[0],e.center[1],e.center[2]+n),I(t.center,r,0,t.center,M(r),0,1),u(t.quaternion,e.quaternion),p(Ve,e.quaternion),h(Xe,0,0,1),g(Xe,Xe,Ve),h(Xe,e.halfSize[0]*Math.abs(Xe[0]),e.halfSize[1]*Math.abs(Xe[1]),e.halfSize[2]*Math.abs(Xe[2])),b(Xe,Xe,o.inverseFlattening),S(t.halfSize,e.halfSize,Xe),b(t.halfSize,t.halfSize,a)}function Le(e,t,r,n,o,a){if(!a||0===a.length||null==t||!e.mbs)return null;const i=A(e.mbs,o,r,t);l(et,i);let s=null;const c=()=>{if(!s)if(s=Qe,k(He),null!=e.serviceObb){ke(e.serviceObb,r,Je,t,o),K(Je,s);for(const e of s)w(e,e,et),C(He,e)}else{const n=e.mbs;if(!n)return;const a=n[3];x(n,r,Xe,t),w(Xe,Xe,et),Xe[2]+=o;for(let e=0;e<8;++e){const t=1&e?a:-a,r=2&e?a:-a,n=4&e?a:-a,o=s[e];d(o,[Xe[0]+t,Xe[1]+r,Xe[2]+n]),C(He,o)}}};let u=1/0,f=-1/0;const p=e=>{if("replace"!==e.type)return;const r=e.geometry;if(!r?.hasZ)return;k(Ze);const o=r.spatialReference||n,a=r.rings.reduce(((e,r)=>r.reduce(((e,r)=>(x(r,o,Xe,t),w(Xe,Xe,et),C(Ze,Xe),Math.min(Xe[2],e))),e)),1/0);c(),U(He,Ze)&&(u=Math.min(u,a),f=Math.max(f,a))};if(a.forEach((e=>p(e))),u===1/0)return null;const m=(e,t,r)=>{w(Xe,r,i),e[t]=Xe[0],e[t+1]=Xe[1],e[t+2]=Xe[2],t+=24,r[2]=u,w(Xe,r,i),e[t]=Xe[0],e[t+1]=Xe[1],e[t+2]=Xe[2],t+=24,r[2]=f,w(Xe,r,i),e[t]=Xe[0],e[t+1]=Xe[1],e[t+2]=Xe[2]};for(let l=0;l<8;++l)m(Ye.data,3*l,s[l]);return G(Ye)}function Ge(e){return null!=e&&e.halfSize[0]>=0}function Ke(e){return e[3]>=0}function Be(e){null!=e&&(e.halfSize[0]=-1)}function Pe(e){null!=e&&(e[3]=-1)}const $e=c(),Ve=m(),Qe=[[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0]],Ze=q(),He=q(),Je=L(),Xe=T(),Ye={data:new Array(72),size:3,exclusive:!0,stride:3},et=c();export{X as MbsIntersectResult,Ie as SymbolInfo,qe as addWraparound,Ee as checkPointCloudLayerCompatibleWithView,Te as checkPointCloudLayerValid,he as checkRecyclable,Se as checkSceneLayerCompatibleWithView,be as checkSceneLayerValid,me as checkSpatialReference,ye as checkSpatialReferences,Le as computeVisibilityObb,$ as containsDraco,P as extractWkid,Q as filterInPlace,ee as findFieldsCaseInsensitive,V as findIntersectingNodes,pe as getCacheKeySuffix,ce as getCachedAttributeValue,J as getClipRect,ue as getIndexCrs,xe as getSymbolInfo,fe as getVertexCrs,Y as intersectBoundingRectWithMbs,Pe as invalidateMbs,Be as invalidateObb,de as isSupportedLocalModeProjection,Ke as isValidMbs,Ge as isValidObb,Z as objectIdFilter,ie as queryAttributesFromCachedAttributesId,Me as rendererNeedsTextures,ke as transformObb,Re as transparentEdgeMaterial,te as whenGraphicAttributes};
5
+ import e from"../../../../request.js";import{binaryIndexOf as t,splitIntoChunks as r}from"../../../../core/arrayUtils.js";import n from"../../../../core/Error.js";import has from"../../../../core/has.js";import{isInt16Array as o,isInt32Array as a}from"../../../../core/typedArrayUtil.js";import{b as i}from"../../../../chunks/mat3.js";import{a as s}from"../../../../chunks/mat3f64.js";import{i as l}from"../../../../chunks/mat4.js";import{a as c}from"../../../../chunks/mat4f64.js";import{c as u,m as f,a as p}from"../../../../chunks/quat.js";import{a as m}from"../../../../chunks/quatf64.js";import{s as h,c as d,u as y,v as g,i as b,g as S,e as w}from"../../../../chunks/vec3.js";import{c as T}from"../../../../chunks/vec3f64.js";import{getReferenceEllipsoid as E}from"../../../../geometry/ellipsoidUtils.js";import{canProjectWithoutEngine as v}from"../../../../geometry/projection.js";import j from"../../../../geometry/SpatialReference.js";import{getSphericalPCPF as M}from"../../../../geometry/spatialReferenceEllipsoidUtils.js";import{computeTranslationToOriginAndRotation as R}from"../../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{projectBuffer as I}from"../../../../geometry/projection/projectBuffer.js";import{projectVectorToVector as x}from"../../../../geometry/projection/projectVectorToVector.js";import{create as q,empty as k,expandPointInPlace as C,intersects as U}from"../../../../geometry/support/aaBoundingRect.js";import{isPlateCarree as N}from"../../../../geometry/support/spatialReferenceUtils.js";import z from"../../../../rest/support/Query.js";import{readBinaryAttribute as W}from"./I3SBinaryReader.js";import{computeGlobalTransformation as A}from"./I3SProjectionUtil.js";import{createSolidEdgeMaterial as D,createMaterialFromEdges as F}from"../support/edgeUtils.js";import{parseColorMixMode as O,ColorMixModeEnum as _}from"../support/symbolColorUtils.js";import{create as L,compute as G,corners as K}from"../../support/orientedBoundingBox.js";import{Vertices as B}from"../../webgl-engine/lib/Attribute.js";function P(e){return e?parseInt(e.substring(e.lastIndexOf("/")+1,e.length),10):void 0}function $(e){if(has("disable-feature:i3s-draco")||!e)return!1;for(const t of e)for(const e of t.geometryBuffers)if("draco"===e.compressedAttributes?.encoding)return!0;return!1}function V(e,t,r,n){r.traverse(t,(t=>{const r=t.mbs;return(null!=r&&Y(e,r))!==X.OUTSIDE&&(n(t),!0)}))}function Q(e,t,r){let n=0,o=0;for(let a=0;a<t.length&&n<e.length;a++)e[n]===t[a]&&(r(a)&&(e[o]=e[n],o++),n++);e.length=o}function Z(e,r,n){let o=0,a=0;for(;o<n.length;){t(e,n[o])>=0===r&&(n[a]=n[o],a++),o++}n.length=a}const H=q();function J(e,t){if(0===t.rotationScale[1]&&0===t.rotationScale[2]&&0===t.rotationScale[3]&&0===t.rotationScale[5]&&0===t.rotationScale[6]&&0===t.rotationScale[7])return H[0]=(e[0]-t.position[0])/t.rotationScale[0],H[1]=(e[1]-t.position[1])/t.rotationScale[4],H[2]=(e[2]-t.position[0])/t.rotationScale[0],H[3]=(e[3]-t.position[1])/t.rotationScale[4],H}var X;function Y(e,t){const r=t[0],n=t[1],o=t[3],a=e[0]-r,i=r-e[2],s=e[1]-n,l=n-e[3],c=Math.max(a,i,0),u=Math.max(s,l,0),f=c*c+u*u;if(f>o*o)return X.OUTSIDE;if(f>0)return X.INTERSECTS_CENTER_OUTSIDE;return-Math.max(a,i,s,l)>o?X.INSIDE:X.INTERSECTS_CENTER_INSIDE}function ee(e,t,r){const n=[],o=r&&r.missingFields,a=r&&r.originalFields;for(const i of e){const e=i.toLowerCase();let r=!1;for(const o of t)if(e===o.name.toLowerCase()){n.push(o.name),r=!0,a&&a.push(i);break}!r&&o&&o.push(i)}return n}async function te(e,t,r,o,a){if(0===t.length)return[];const i=e.attributeStorageInfo;if(null!=e.associatedLayer)try{return await ne(e.associatedLayer,t,r,o)}catch(s){if(e.associatedLayer.loaded)throw s}if(i){const s=re(t,r,a);if(null==s)throw new n("scenelayer:features-not-loaded","Tried to query attributes for unloaded features");const l=e.parsedUrl.path;return(await Promise.all(s.map((e=>ae(l,i,e.node,e.indices,o).then((t=>{for(let r=0;r<e.graphics.length;r++){const n=e.graphics[r],o=t[r];if(n.attributes)for(const e in n.attributes)e in o||(o[e]=n.attributes[e]);n.attributes=o}return e.graphics})))))).flat()}throw new n("scenelayer:no-attribute-source","This scene layer does not have a source for attributes available")}function re(e,t,r){const n=new Map,o=[],a=r();for(const i of e){const e=i.attributes[t];for(let t=0;t<a.length;t++){const r=a[t],s=r.featureIds.indexOf(e);if(s>=0){let e=n.get(r.node);e||(e={node:r.node,indices:[],graphics:[]},o.push(e),n.set(r.node,e)),e.indices.push(s),e.graphics.push(i);for(let r=t;r>0;r--)a[r]=a[r-1];a[0]=r;break}}}return o}async function ne(e,t,r,n){t.sort(((e,t)=>e.attributes[r]-t.attributes[r]));const o=t.map((e=>e.attributes[r])),a=[],i=ee(n,e.fields,{originalFields:a}),s=await oe(e,o,i);for(let l=0;l<t.length;l++){const e=t[l],r=s[l],n={};if(e.attributes)for(const t in e.attributes)n[t]=e.attributes[t];for(let t=0;t<a.length;t++)n[a[t]]=r[i[t]];e.attributes=n}return t}function oe(e,t,o){const a=e.capabilities.query.maxRecordCount;if(null!=a&&t.length>a){const n=r(t,a);return Promise.all(n.map((t=>oe(e,t,o)))).then((e=>e.flat()))}const i=new z({objectIds:t,outFields:o,orderByFields:[e.objectIdField]});return e.queryFeatures(i).then((e=>{if(e&&e.features&&e.features.length===t.length)return e.features.map((e=>e.attributes));throw new n("scenelayer:feature-not-in-associated-layer","Feature not found in associated feature layer")}))}function ae(e,t,r,n,o){return ie(e,t,r.resources.attributes,n,o)}async function ie(t,r,n,o,a){const i=[];for(const e of r)if(e&&a.includes(e.name)){const r=`${t}/nodes/${n}/attributes/${e.key}/0`;i.push({url:r,storageInfo:e})}const s=await Promise.allSettled(i.map((t=>e(t.url,{responseType:"array-buffer"}).then((e=>W(t.storageInfo,e.data)))))),l=[];for(const e of o){const t={};for(let r=0;r<s.length;r++){const n=s[r];if("fulfilled"===n.status){const o=n.value;t[i[r].storageInfo.name]=ce(o,e)}}l.push(t)}return l}!function(e){e[e.OUTSIDE=0]="OUTSIDE",e[e.INTERSECTS_CENTER_OUTSIDE=1]="INTERSECTS_CENTER_OUTSIDE",e[e.INTERSECTS_CENTER_INSIDE=2]="INTERSECTS_CENTER_INSIDE",e[e.INSIDE=3]="INSIDE"}(X||(X={}));const se=-32768,le=-(2**31);function ce(e,t){if(!e)return null;const r=e[t];if(o(e))return r===se?null:r;if(a(e))return r===le?null:r;return r!=r?null:r}function ue(e){const t=e.store,r=t.indexCRS||t.geographicCRS,o=void 0===r?t.indexWKT:void 0;if(o){if(!e.spatialReference)throw new n("layerview:no-store-spatial-reference-wkt-index-and-no-layer-spatial-reference","Found indeWKT in the scene layer store but no layer spatial reference",{});if(o!==e.spatialReference.wkt)throw new n("layerview:store-spatial-reference-wkt-index-incompatible","The indeWKT of the scene layer store does not match the WKT of the layer spatial reference",{})}const a=r?new j(P(r)):e.spatialReference;return a.equals(e.spatialReference)?e.spatialReference:a}function fe(e){const t=e.store,r=t.vertexCRS||t.projectedCRS,o=void 0===r?t.vertexWKT:void 0;if(o){if(!e.spatialReference)throw new n("layerview:no-store-spatial-reference-wkt-vertex-and-no-layer-spatial-reference","Found vertexWKT in the scene layer store but no layer spatial reference",{});if(o!==e.spatialReference.wkt)throw new n("layerview:store-spatial-reference-wkt-vertex-incompatible","The vertexWKT of the scene layer store does not match the WKT of the layer spatial reference",{})}const a=r?new j(P(r)):e.spatialReference;return a.equals(e.spatialReference)?e.spatialReference:a}function pe(e,t){return null==t?"@null":t===M(t)?"@ECEF":e.equals(t)?"":null!=t.wkid?"@"+t.wkid:null}function me(e,t,r){if(!v(e,t))throw new n("layerview:spatial-reference-incompatible","The spatial reference of this scene layer is incompatible with the spatial reference of the view",{});if("local"===r&&!de(e,t))throw new n("layerview:spatial-reference-incompatible","The spatial reference of this scene layer is incompatible with the spatial reference of the view",{})}function he(e,t,r){if(e.serviceUpdateTimeStamp?.lastUpdate!==t.serviceUpdateTimeStamp?.lastUpdate||!r.isEmpty||e.associatedLayer?.url!==t.associatedLayer?.url)throw new n("layerview:recycle-failed")}function de(e,t){return e.equals(t)||e.isWGS84&&t.isWebMercator||e.isWebMercator&&t.isWGS84}function ye(e,t,r){const n=ue(e),o=fe(e);me(n,t,r),me(o,t,r)}function ge(e){return(null==e.geometryType||"triangles"===e.geometryType)&&((null==e.topology||"PerAttributeArray"===e.topology)&&(null!=e.vertexAttributes&&null!=e.vertexAttributes.position))}function be(e){if(null==e.store||null==e.store.defaultGeometrySchema||!ge(e.store.defaultGeometrySchema))throw new n("scenelayer:unsupported-geometry-schema","The geometry schema of this scene layer is not supported.",{url:e.parsedUrl.path})}function Se(e,t){ye(e,t.spatialReference,t.viewingMode)}function we(e){return null!=e.geometryType&&"points"===e.geometryType&&((null==e.topology||"PerAttributeArray"===e.topology)&&((null==e.encoding||""===e.encoding||"lepcc-xyz"===e.encoding)&&(null!=e.vertexAttributes&&null!=e.vertexAttributes.position)))}function Te(e){if(null==e.store||null==e.store.defaultGeometrySchema||!we(e.store.defaultGeometrySchema))throw new n("pointcloud:unsupported-geometry-schema","The geometry schema of this point cloud scene layer is not supported.",{})}function Ee(e,t){me(e.spatialReference,t.spatialReference,t.viewingMode)}function ve(e){return"simple"===e.type||"class-breaks"===e.type||"unique-value"===e.type}function je(e){return"mesh-3d"===e.type}function Me(e){if(null==e||!ve(e))return!0;if(("unique-value"===e.type||"class-breaks"===e.type)&&null==e.defaultSymbol)return!0;const t=e.getSymbols();if(0===t.length)return!0;for(const r of t){if(!je(r)||0===r.symbolLayers.length)return!0;for(const e of r.symbolLayers.items)if("fill"!==e.type||null==e.material||null==e.material.color||"replace"!==e.material.colorMixMode)return!0}return!1}const Re=D({color:[0,0,0,0],opacity:0});class Ie{constructor(){this.edgeMaterial=null,this.material=null,this.castShadows=!0}}function xe(e){const t=new Ie;let r=!1,n=!1;for(const o of e.symbolLayers.items)if("fill"===o.type&&o.enabled){const e=o.material,a=o.edges;if(null!=e&&!r){const n=e.color,a=O(e.colorMixMode);t.material=null!=n?{color:[n.r/255,n.g/255,n.b/255],alpha:n.a,colorMixMode:a}:{color:[1,1,1],alpha:1,colorMixMode:_.Multiply},t.castShadows=o.castShadows,r=!0}null==a||n||(t.edgeMaterial=F(a,{}),n=!0)}return t.material||(t.material={color:[1,1,1],alpha:1,colorMixMode:_.Multiply}),t}function qe(e,t){return(0|e)+(0|t)|0}function ke(e,t,r,n,o=0){n===M(n)?t.isGeographic?_e(e,r,t,o):Oe(e,r,t,o):t.isWGS84&&(n.isWebMercator||N(n))?Ce(t,e,n,r,o):t.isWebMercator&&N(n)?De(t,e,n,r,o):e===r?(r.center[2]+=o,I(r.center,t,0,r.center,n,0,1)):(h(r.center,e.center[0],e.center[1],e.center[2]+o),I(r.center,t,0,r.center,n,0,1),u(r.quaternion,e.quaternion),d(r.halfSize,e.halfSize))}function Ce(e,t,r,n,o){d(We,t.center),We[2]+=o;const a=M(r);I(We,e,0,We,a,0,1),Fe(a,t,We,r,n)}const Ue=new Array(24),Ne=new B(Ue,3),ze=T(),We=T(),Ae=s();function De(e,t,r,n,o){d(We,t.center),We[2]+=o,Fe(e,t,We,r,n)}function Fe(e,t,r,n,o){const a=i(Ae,t.quaternion);for(let i=0;i<8;++i){for(let e=0;e<3;++e)ze[e]=t.halfSize[e]*(0!=(i&1<<e)?-1:1);for(let e=0;e<3;++e){let t=r[e];for(let r=0;r<3;++r)t+=ze[r]*a[3*r+e];Ue[3*i+e]=t}}I(Ue,e,0,Ue,n,0,8),G(Ne,o)}function Oe(e,t,r,n){K(e,Qe),h(t.center,e.center[0],e.center[1],e.center[2]+n),R(r,t.center,$e,M(r)),h(t.center,$e[12],$e[13],$e[14]);const o=2*Math.sqrt(1+$e[0]+$e[5]+$e[10]);Ve[0]=($e[6]-$e[9])/o,Ve[1]=($e[8]-$e[2])/o,Ve[2]=($e[1]-$e[4])/o,Ve[3]=.25*o,f(t.quaternion,Ve,e.quaternion),p(Ve,t.quaternion);let a=0,i=0,s=0;for(const l of Qe)l[2]+=n,I(l,r,0,l,M(r),0,1),y(Xe,l,t.center),g(Xe,Xe,Ve),a=Math.max(a,Math.abs(Xe[0])),i=Math.max(i,Math.abs(Xe[1])),s=Math.max(s,Math.abs(Xe[2]));h(t.halfSize,a,i,s)}function _e(e,t,r,n){const o=E(r),a=1+Math.max(0,n)/(o.radius+e.center[2]);h(t.center,e.center[0],e.center[1],e.center[2]+n),I(t.center,r,0,t.center,M(r),0,1),u(t.quaternion,e.quaternion),p(Ve,e.quaternion),h(Xe,0,0,1),g(Xe,Xe,Ve),h(Xe,e.halfSize[0]*Math.abs(Xe[0]),e.halfSize[1]*Math.abs(Xe[1]),e.halfSize[2]*Math.abs(Xe[2])),b(Xe,Xe,o.inverseFlattening),S(t.halfSize,e.halfSize,Xe),b(t.halfSize,t.halfSize,a)}function Le(e,t,r,n,o,a){if(!a||0===a.length||null==t||!e.mbs)return null;const i=A(e.mbs,o,r,t);l(et,i);let s=null;const c=()=>{if(!s)if(s=Qe,k(He),null!=e.serviceObb){ke(e.serviceObb,r,Je,t,o),K(Je,s);for(const e of s)w(e,e,et),C(He,e)}else{const n=e.mbs;if(!n)return;const a=n[3];x(n,r,Xe,t),w(Xe,Xe,et),Xe[2]+=o;for(let e=0;e<8;++e){const t=1&e?a:-a,r=2&e?a:-a,n=4&e?a:-a,o=s[e];d(o,[Xe[0]+t,Xe[1]+r,Xe[2]+n]),C(He,o)}}};let u=1/0,f=-1/0;const p=e=>{if("replace"!==e.type)return;const r=e.geometry;if(!r?.hasZ)return;k(Ze);const o=r.spatialReference||n,a=r.rings.reduce(((e,r)=>r.reduce(((e,r)=>(x(r,o,Xe,t),w(Xe,Xe,et),C(Ze,Xe),Math.min(Xe[2],e))),e)),1/0);c(),U(He,Ze)&&(u=Math.min(u,a),f=Math.max(f,a))};if(a.forEach((e=>p(e))),u===1/0)return null;const m=(e,t,r)=>{w(Xe,r,i),e[t]=Xe[0],e[t+1]=Xe[1],e[t+2]=Xe[2],t+=24,r[2]=u,w(Xe,r,i),e[t]=Xe[0],e[t+1]=Xe[1],e[t+2]=Xe[2],t+=24,r[2]=f,w(Xe,r,i),e[t]=Xe[0],e[t+1]=Xe[1],e[t+2]=Xe[2]};for(let l=0;l<8;++l)m(Ye.data,3*l,s[l]);return G(Ye)}function Ge(e){return null!=e&&e.halfSize[0]>=0}function Ke(e){return e[3]>=0}function Be(e){null!=e&&(e.halfSize[0]=-1)}function Pe(e){null!=e&&(e[3]=-1)}const $e=c(),Ve=m(),Qe=[[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0]],Ze=q(),He=q(),Je=L(),Xe=T(),Ye={data:new Array(72),size:3,exclusive:!0,stride:3},et=c();export{X as MbsIntersectResult,Ie as SymbolInfo,qe as addWraparound,Ee as checkPointCloudLayerCompatibleWithView,Te as checkPointCloudLayerValid,he as checkRecyclable,Se as checkSceneLayerCompatibleWithView,be as checkSceneLayerValid,me as checkSpatialReference,ye as checkSpatialReferences,Le as computeVisibilityObb,$ as containsDraco,P as extractWkid,Q as filterInPlace,ee as findFieldsCaseInsensitive,V as findIntersectingNodes,pe as getCacheKeySuffix,ce as getCachedAttributeValue,J as getClipRect,ue as getIndexCrs,xe as getSymbolInfo,fe as getVertexCrs,Y as intersectBoundingRectWithMbs,Pe as invalidateMbs,Be as invalidateObb,de as isSupportedLocalModeProjection,Ke as isValidMbs,Ge as isValidObb,Z as objectIdFilter,ie as queryAttributesFromCachedAttributesId,Me as rendererNeedsTextures,ke as transformObb,Re as transparentEdgeMaterial,te as whenGraphicAttributes};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../../chunks/tslib.es6.js";import t from"../../../../core/Accessor.js";import{isSome as r}from"../../../../core/arrayUtils.js";import{estimateAttributesObjectSize as i,estimateFixedArraySize as a,estimateNumberByteSize as s}from"../../../../core/byteSizeEstimations.js";import{makeHandle as o}from"../../../../core/handleUtils.js";import n from"../../../../core/Logger.js";import{initial as l,sync as p,watch as d}from"../../../../core/reactiveUtils.js";import{pt2px as u}from"../../../../core/screenUtils.js";import{property as m}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/accessorSupport/ensureType.js";import"../../../../core/has.js";import{subclass as h}from"../../../../core/accessorSupport/decorators/subclass.js";import{c}from"../../../../chunks/vec3f64.js";import{UpdatingHandles as y}from"../../../../core/support/UpdatingHandles.js";import{projectPointToVector as _}from"../../../../geometry/projection/projectPointToVector.js";import{getResolutionForScale as f}from"../../../../geometry/support/scaleUtils.js";import{getObjectId as g}from"../../../../layers/graphics/dehydratedFeatures.js";import{convertFromPoint as F}from"../../../../layers/graphics/featureConversionUtils.js";import{OptimizedFeature as R}from"../../../../layers/graphics/OptimizedFeature.js";import b from"../../../../layers/graphics/OptimizedGeometry.js";import v from"../../../../layers/graphics/data/FeatureStore.js";import{isNumericField as S}from"../../../../layers/support/fieldUtils.js";import{generateGradient as w}from"../../../../renderers/support/heatmapUtils.js";import{DrapeSourceType as P}from"../interfaces.js";import{DisplayFeatureLimit as j}from"../graphics/DisplayFeatureLimit.js";import{FeatureVisibilityFilter as T}from"./FeatureVisibilityFilter.js";import{drapedZ as V}from"../../terrain/OverlayRenderer.js";import{Attribute as G}from"../../webgl-engine/lib/Attribute.js";import{ContentObjectType as M}from"../../webgl-engine/lib/ContentObjectType.js";import{DrapedHeatmapRenderer as x}from"../../webgl-engine/lib/DrapedHeatmapRenderer.js";import{Geometry as I}from"../../webgl-engine/lib/Geometry.js";import{DirtyOperation as A,DirtyState as N}from"../../webgl-engine/lib/ModelDirtyTypes.js";import{RenderGeometry as O}from"../../webgl-engine/lib/RenderGeometry.js";import{UpdatePolicy as H}from"../../webgl-engine/lib/UpdatePolicy.js";import{VertexAttribute as U}from"../../webgl-engine/lib/VertexAttribute.js";import{HeatmapDensityMaterial as E}from"../../webgl-engine/materials/HeatmapDensityMaterial.js";import{scaleBoundsPredicate as D,isScaleRangeActive as L}from"../../../support/layerViewUtils.js";import{PixelType as C,PixelFormat as B}from"../../../webgl/enums.js";import{loadHeatmapTextureConfiguration as W}from"../../../webgl/heatmapTextureUtils.js";const Z="esri.views.3d.layers.support.HeatmapFeatureProcessor",z=n.getLogger(Z),$=112;let q=class extends t{constructor(e){super(e),this.type="heatmap",this.preferredUpdatePolicy=H.ASYNC,this.dataExtent=null,this.drapeSourceType=P.Features,this._renderGeometries=new Map,this._fieldTotal=0,this._drapeSourceRenderer=null,this._dataType=C.HALF_FLOAT,this._pixelFormat=B.RGBA,this._updatingHandles=new y,this.initializePromise=Promise.resolve()}initialize(){this._featureStore=new v({geometryType:"esriGeometryPoint",hasZ:this.hasZ,hasM:this.hasM});const{dataType:e,samplingMode:t,pixelFormat:r,internalFormat:i}=W(this._renderView.renderingContext,z);this._dataType=e,this._pixelFormat=r;const a=e!==C.FLOAT;this._drapeSourceRenderer=this.view.basemapTerrain.overlayManager.registerDrapeSource(this,x,{...this._rendererParameters,dataType:e,samplingMode:t,pixelFormat:r,internalFormat:i}),this._material=new E({usesHalfFloats:a}),this._materialWithField=new E({usesHalfFloats:a,isAttributeDriven:!0}),this._filterVisibility=new T({context:{layerView:this.owner,featureStore:this.featureStore,getFeatureCount:()=>this._loadedPointGraphics.length,setAllFeaturesVisibility:e=>this._setAllFeaturesVisibility(e),clearFeaturesVisibility:()=>this._setAllFeaturesVisibility(!0),updateFeatureVisibilities:e=>this._updateFeatureVisibilities(e)}}),this._updatingHandles.addOnCollectionChange((()=>this._loadedPointGraphics),(e=>this._onLoadedFeaturesChange(e)),l),this._updatingHandles.addWhen((()=>this._materialParameters),(e=>this._forEachMaterial((t=>t.setParameters(e)))),l),this._updatingHandles.add((()=>this._rendererParameters),(e=>this._drapeSourceRenderer.set(e))),this._updatingHandles.add((()=>this._heatmapRendererField),(()=>{this._recreate()}),p),this._updatingHandles.add((()=>({fieldName:this._heatmapRendererFieldName,numeric:this._heatmapRendererFieldIsNumeric})),(({fieldName:e,numeric:t})=>{if(null!=e&&t){let t=0;this._featureStore.forEach((r=>t+=r.attributes[e]??0)),this._fieldTotal=t}else this._fieldTotal=this._featureStore.numFeatures}),l),this.addHandles([d((()=>({fieldName:this._heatmapRendererFieldName,field:this._heatmapRendererField})),(({fieldName:e,field:t})=>{e&&!t&&z.warn(`Heatmap renderer field '${e}' for layer '${this.layer.title??this.layer.id}' not found`)})),d((()=>({field:this._heatmapRendererField,numeric:this._heatmapRendererFieldIsNumeric})),(({field:e,numeric:t})=>{null==e||t||z.warn(`Heatmap renderer field '${e.name}' for layer '${this.layer.title??this.layer.id}' does not contain numeric values and cannot be used to drive the heatmap density`)})),o((()=>this.view.basemapTerrain.overlayManager.unregisterDrapeSource(this)))])}destroy(){this._renderGeometries.clear(),this._material=null,this._materialWithField=null,this._featureStore.clear(),this._featureStore=null,this._updatingHandles.destroy()}get layer(){return this.owner.layer}get featureStore(){return this._featureStore}get updating(){return this._updatingHandles.updating||this.filterVisibility.updating}get updatingRemaining(){return 0}get suspendInfo(){return{}}get legendEnabled(){return!0}get filterVisibility(){return this._filterVisibility}get displayFeatureLimit(){const e=this.owner?.view?.quality??1,t=this.owner?.view?.qualitySettings,r=t?Math.ceil(t.heatmap.maxTotalNumberOfFeatures*e):0;return new j(r*6,r)}get hasZ(){return"hasZ"in this.layer&&this.layer.hasZ}get hasM(){return"hasM"in this.layer&&this.layer.hasM}get view(){return this.owner.view}get fullOpacity(){return this.owner.fullOpacity}get updatePolicy(){return this.owner.updatePolicy}get scaleVisibilitySuspended(){if(!this._isScaleRangeActive)return!1;const{minScale:e,maxScale:t}=this.layer.effectiveScaleRange,{scale:r}=this.view;return!D(r,e??0,t??0)}get usedMemory(){const e=this.usedMemoryPerFeature*this._featureStore.numFeatures,t=this._pixelFormat===B.RED?1:4,r=this._dataType===C.FLOAT?4:2,i=Math.ceil((this._overlayRenderer?.overlays[0]?.resolution??0)*this._densityMapPixelRatio)??0;return i*i*t*r+e}get usedMemoryPerFeature(){const e=this._loadedPointGraphics.find((()=>!0));if(null==e)return 0;const t=i(e),r=s(),o=6;return o*a([0,0,0],r)+o*a([0,0],r)+(this._heatmapRendererFieldIsNumeric?o*r:0)+t}get loadedFeatures(){return this._featureStore.numFeatures}get unprocessedMemoryEstimate(){return 0}get performanceInfo(){return{core:{visible:this._visibleFeatures,missing:0,pending:0},elevationUpdating:!1,visibilityFrustum:!0,visibilityScale:!0}}get renderer(){return this._heatmapRenderer}get _overlayRenderer(){return this.view.basemapTerrain.overlayManager.renderer}get _overlaySpatialReference(){return this._overlayRenderer.spatialReference}get _rendererParameters(){return{...this._radiusParameter,...this._densityParameters,...this._colorRampParameter,...this._pixelRatioParameter}}get _materialParameters(){return{...this._radiusParameter,...this._resolutionForScaleParameter}}get _densityParameters(){const e=this._heatmapRenderer;if(null==e)return null;const{minDensity:t,maxDensity:r}=e;return{minDensity:t,maxDensity:r,fieldTotal:this._fieldTotal}}get _radiusParameter(){const e=this._heatmapRenderer;return e?{searchRadius:u(this._clampSearchRadius(e.radius))}:null}get _resolutionForScaleParameter(){const e=this._heatmapRenderer;if(!e)return null;const{referenceScale:t}=e;return{resolutionForScale:0===t?0:f(t,this.view.spatialReference)}}get _colorRampParameter(){const e=this._heatmapRenderer;return e?{colorRampData:w(e.colorStops)}:null}get _pixelRatioParameter(){return{pixelRatio:this._densityMapPixelRatio}}get _densityMapPixelRatio(){return this.owner?.view?.qualitySettings.heatmap.pixelRatio??1}get _renderView(){return this.view._stage.renderView}get _featuresArePoints(){return"point"===this.layer.geometryType}get _loadedPointGraphics(){return this.owner.loadedGraphics}get _heatmapRenderer(){const e=this.layer.renderer;return"heatmap"===e?.type?e:null}get _heatmapRendererFieldName(){return this._heatmapRenderer?.field}get _heatmapRendererField(){const e=this._heatmapRendererFieldName;return null!=e?this.layer.fieldsIndex.get(e):null}get _heatmapRendererFieldIsNumeric(){const e=this._heatmapRendererField;return null!=e&&S(e)}get _isScaleRangeActive(){const{layer:e}=this;if(!("effectiveScaleRange"in e))return!1;const{minScale:t,maxScale:r}=e.effectiveScaleRange;return L(t,r)}get _visibleFeatures(){let e=0;return this._renderGeometries.forEach((t=>{t.visible&&++e})),e}async whenGraphicBounds(){return null}computeAttachmentOrigin(){return null}highlight(){return o()}maskOccludee(){return o()}setObjectIdVisibility(){}refreshFilter(){this.filterVisibility.reapply()}_onLoadedFeaturesChange(e){if(!this._featuresArePoints)return;const{objectIdField:t}=this.layer;this._featureStore.removeManyById(e.removed.map((e=>g(e,t)))),this._featureStore.addMany(e.added.map((e=>{const{attributes:r,centroid:i,geometry:a}=e,s=new R(F(new b,a),r,i?F(new b,i):null,g(e,t));return s.displayId=e.uid,s})));const i=e.added,a=e.removed;this._fieldTotal+=this._computeFieldTotalChange(i,a);const s=a.map((({uid:e})=>{const t=this._renderGeometries.get(e);return this._renderGeometries.delete(e),t})).filter(r),o=i.map((e=>{const t=this._pointGraphicToRenderGeometry(e);return this._renderGeometries.set(e.uid,t),t}));s.length>0&&this._drapeSourceRenderer.removeGeometries(s,A.REMOVE),o.length>0&&this._drapeSourceRenderer.addGeometries(o,A.ADD),(o.length>0||s.length>0)&&(this.filterVisibility.reapply(),this._renderView.requestRender())}_recreate(){if(!this._loadedPointGraphics)return;const e=this._loadedPointGraphics.toArray();this._onLoadedFeaturesChange({added:e,removed:e})}_pointGraphicToRenderGeometry(e){const t=this._heatmapRendererFieldName,r=null!=t?this._materialWithField:this._material,i=c();_(e.geometry,i,this._overlaySpatialReference),i[2]=V;const a=[[U.POSITION,new G(i,i.length),null]],s=this._heatmapRendererFieldIsNumeric;null!=t&&a.push([U.FEATUREATTRIBUTE,new G([s?e.attributes[t]??0:0],1),null]);const o=new O(new I(r,a,null,M.Point),{layerUid:this.layer.uid,graphicUid:e.uid});return o.visible=this.filterVisibility.defaultVisibility,o}_forEachMaterial(e){e(this._material),e(this._materialWithField)}_computeFieldTotalChange(e,t){if(null==this._heatmapRendererFieldName||!this._heatmapRendererFieldIsNumeric)return e.length-t.length;const r=this._heatmapRendererFieldName,i=(e,t)=>e+(t.attributes[r]??0);return e.reduce(i,0)-t.reduce(i,0)}_clampSearchRadius(e){return e>$&&z.warnOnce(`SceneView supports a maximum radius of ${$} pt for HeatmapRenderer.`),Math.min(e,$)}_updateFeatureVisibilities(e){const t=[];this._featureStore.forEach((({objectId:r,displayId:i})=>{const a=e(r),s=this._renderGeometries.get(i);s&&s.visible!==a&&(t.push(s),s.visible=a)})),this._drapeSourceRenderer.modifyGeometries(t,N.VISIBILITY)}_setAllFeaturesVisibility(e){const t=[];for(const r of this._renderGeometries.values())r.visible!==e&&(t.push(r),r.visible=e);this._drapeSourceRenderer.modifyGeometries(t,N.VISIBILITY)}get test(){return{visibleFeatureCount:this._visibleFeatures}}};e([m()],q.prototype,"type",void 0),e([m({constructOnly:!0})],q.prototype,"owner",void 0),e([m()],q.prototype,"layer",null),e([m()],q.prototype,"featureStore",null),e([m()],q.prototype,"updating",null),e([m()],q.prototype,"updatingRemaining",null),e([m()],q.prototype,"suspendInfo",null),e([m()],q.prototype,"legendEnabled",null),e([m()],q.prototype,"filterVisibility",null),e([m()],q.prototype,"displayFeatureLimit",null),e([m()],q.prototype,"preferredUpdatePolicy",void 0),e([m()],q.prototype,"hasZ",null),e([m()],q.prototype,"hasM",null),e([m()],q.prototype,"dataExtent",void 0),e([m()],q.prototype,"view",null),e([m()],q.prototype,"fullOpacity",null),e([m()],q.prototype,"updatePolicy",null),e([m()],q.prototype,"drapeSourceType",void 0),e([m()],q.prototype,"scaleVisibilitySuspended",null),e([m()],q.prototype,"renderer",null),e([m()],q.prototype,"_featureStore",void 0),e([m()],q.prototype,"_filterVisibility",void 0),e([m()],q.prototype,"_overlayRenderer",null),e([m()],q.prototype,"_overlaySpatialReference",null),e([m()],q.prototype,"_rendererParameters",null),e([m()],q.prototype,"_materialParameters",null),e([m()],q.prototype,"_densityParameters",null),e([m()],q.prototype,"_radiusParameter",null),e([m()],q.prototype,"_resolutionForScaleParameter",null),e([m()],q.prototype,"_colorRampParameter",null),e([m()],q.prototype,"_pixelRatioParameter",null),e([m()],q.prototype,"_densityMapPixelRatio",null),e([m()],q.prototype,"_renderGeometries",void 0),e([m()],q.prototype,"_material",void 0),e([m()],q.prototype,"_materialWithField",void 0),e([m()],q.prototype,"_renderView",null),e([m()],q.prototype,"_featuresArePoints",null),e([m()],q.prototype,"_loadedPointGraphics",null),e([m()],q.prototype,"_heatmapRenderer",null),e([m()],q.prototype,"_heatmapRendererFieldName",null),e([m()],q.prototype,"_heatmapRendererField",null),e([m()],q.prototype,"_heatmapRendererFieldIsNumeric",null),e([m()],q.prototype,"_fieldTotal",void 0),e([m()],q.prototype,"_drapeSourceRenderer",void 0),e([m()],q.prototype,"_isScaleRangeActive",null),q=e([h(Z)],q);export{q as HeatmapFeatureProcessor,$ as maxRadiusPt};
5
+ import{_ as e}from"../../../../chunks/tslib.es6.js";import t from"../../../../core/Accessor.js";import{isSome as r}from"../../../../core/arrayUtils.js";import{estimateAttributesObjectSize as i,estimateFixedArraySize as a,estimateNumberByteSize as s}from"../../../../core/byteSizeEstimations.js";import{makeHandle as o}from"../../../../core/handleUtils.js";import n from"../../../../core/Logger.js";import{initial as l,sync as p,watch as d}from"../../../../core/reactiveUtils.js";import{pt2px as u}from"../../../../core/screenUtils.js";import{property as m}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/accessorSupport/ensureType.js";import"../../../../core/has.js";import{subclass as h}from"../../../../core/accessorSupport/decorators/subclass.js";import{c}from"../../../../chunks/vec3f64.js";import{UpdatingHandles as y}from"../../../../core/support/UpdatingHandles.js";import{projectPointToVector as _}from"../../../../geometry/projection/projectPointToVector.js";import{getContinuousIndexArray as f}from"../../../../geometry/support/Indices.js";import{getResolutionForScale as g}from"../../../../geometry/support/scaleUtils.js";import{getObjectId as F}from"../../../../layers/graphics/dehydratedFeatures.js";import{convertFromPoint as R}from"../../../../layers/graphics/featureConversionUtils.js";import{OptimizedFeature as b}from"../../../../layers/graphics/OptimizedFeature.js";import v from"../../../../layers/graphics/OptimizedGeometry.js";import S from"../../../../layers/graphics/data/FeatureStore.js";import{isNumericField as w}from"../../../../layers/support/fieldUtils.js";import{generateGradient as P}from"../../../../renderers/support/heatmapUtils.js";import{DrapeSourceType as j}from"../interfaces.js";import{DisplayFeatureLimit as T}from"../graphics/DisplayFeatureLimit.js";import{FeatureVisibilityFilter as V}from"./FeatureVisibilityFilter.js";import{drapedZ as G}from"../../terrain/OverlayRenderer.js";import{Attribute as M}from"../../webgl-engine/lib/Attribute.js";import{ContentObjectType as x}from"../../webgl-engine/lib/ContentObjectType.js";import{DrapedHeatmapRenderer as I}from"../../webgl-engine/lib/DrapedHeatmapRenderer.js";import{Geometry as A}from"../../webgl-engine/lib/Geometry.js";import{DirtyOperation as N,DirtyState as O}from"../../webgl-engine/lib/ModelDirtyTypes.js";import{RenderGeometry as H}from"../../webgl-engine/lib/RenderGeometry.js";import{UpdatePolicy as U}from"../../webgl-engine/lib/UpdatePolicy.js";import{VertexAttribute as E}from"../../webgl-engine/lib/VertexAttribute.js";import{HeatmapDensityMaterial as D}from"../../webgl-engine/materials/HeatmapDensityMaterial.js";import{scaleBoundsPredicate as L,isScaleRangeActive as C}from"../../../support/layerViewUtils.js";import{PixelType as B,PixelFormat as W}from"../../../webgl/enums.js";import{loadHeatmapTextureConfiguration as Z}from"../../../webgl/heatmapTextureUtils.js";const z="esri.views.3d.layers.support.HeatmapFeatureProcessor",$=n.getLogger(z),q=112;let k=class extends t{constructor(e){super(e),this.type="heatmap",this.preferredUpdatePolicy=U.ASYNC,this.dataExtent=null,this.drapeSourceType=j.Features,this._renderGeometries=new Map,this._fieldTotal=0,this._drapeSourceRenderer=null,this._dataType=B.HALF_FLOAT,this._pixelFormat=W.RGBA,this._updatingHandles=new y,this.initializePromise=Promise.resolve()}initialize(){this._featureStore=new S({geometryType:"esriGeometryPoint",hasZ:this.hasZ,hasM:this.hasM});const{dataType:e,samplingMode:t,pixelFormat:r,internalFormat:i}=Z(this._renderView.renderingContext,$);this._dataType=e,this._pixelFormat=r;const a=e!==B.FLOAT;this._drapeSourceRenderer=this.view.basemapTerrain.overlayManager.registerDrapeSource(this,I,{...this._rendererParameters,dataType:e,samplingMode:t,pixelFormat:r,internalFormat:i}),this._material=new D({usesHalfFloats:a}),this._materialWithField=new D({usesHalfFloats:a,isAttributeDriven:!0}),this._filterVisibility=new V({context:{layerView:this.owner,featureStore:this.featureStore,getFeatureCount:()=>this._loadedPointGraphics.length,setAllFeaturesVisibility:e=>this._setAllFeaturesVisibility(e),clearFeaturesVisibility:()=>this._setAllFeaturesVisibility(!0),updateFeatureVisibilities:e=>this._updateFeatureVisibilities(e)}}),this._updatingHandles.addOnCollectionChange((()=>this._loadedPointGraphics),(e=>this._onLoadedFeaturesChange(e)),l),this._updatingHandles.addWhen((()=>this._materialParameters),(e=>this._forEachMaterial((t=>t.setParameters(e)))),l),this._updatingHandles.add((()=>this._rendererParameters),(e=>this._drapeSourceRenderer.set(e))),this._updatingHandles.add((()=>this._heatmapRendererField),(()=>{this._recreate()}),p),this._updatingHandles.add((()=>({fieldName:this._heatmapRendererFieldName,numeric:this._heatmapRendererFieldIsNumeric})),(({fieldName:e,numeric:t})=>{if(null!=e&&t){let t=0;this._featureStore.forEach((r=>t+=r.attributes[e]??0)),this._fieldTotal=t}else this._fieldTotal=this._featureStore.numFeatures}),l),this.addHandles([d((()=>({fieldName:this._heatmapRendererFieldName,field:this._heatmapRendererField})),(({fieldName:e,field:t})=>{e&&!t&&$.warn(`Heatmap renderer field '${e}' for layer '${this.layer.title??this.layer.id}' not found`)})),d((()=>({field:this._heatmapRendererField,numeric:this._heatmapRendererFieldIsNumeric})),(({field:e,numeric:t})=>{null==e||t||$.warn(`Heatmap renderer field '${e.name}' for layer '${this.layer.title??this.layer.id}' does not contain numeric values and cannot be used to drive the heatmap density`)})),o((()=>this.view.basemapTerrain.overlayManager.unregisterDrapeSource(this)))])}destroy(){this._renderGeometries.clear(),this._material=null,this._materialWithField=null,this._featureStore.clear(),this._featureStore=null,this._updatingHandles.destroy()}get layer(){return this.owner.layer}get featureStore(){return this._featureStore}get updating(){return this._updatingHandles.updating||this.filterVisibility.updating}get updatingRemaining(){return 0}get suspendInfo(){return{}}get legendEnabled(){return!0}get filterVisibility(){return this._filterVisibility}get displayFeatureLimit(){const e=this.owner?.view?.quality??1,t=this.owner?.view?.qualitySettings,r=t?Math.ceil(t.heatmap.maxTotalNumberOfFeatures*e):0;return new T(r*6,r)}get hasZ(){return"hasZ"in this.layer&&this.layer.hasZ}get hasM(){return"hasM"in this.layer&&this.layer.hasM}get view(){return this.owner.view}get fullOpacity(){return this.owner.fullOpacity}get updatePolicy(){return this.owner.updatePolicy}get scaleVisibilitySuspended(){if(!this._isScaleRangeActive)return!1;const{minScale:e,maxScale:t}=this.layer.effectiveScaleRange,{scale:r}=this.view;return!L(r,e??0,t??0)}get usedMemory(){const e=this.usedMemoryPerFeature*this._featureStore.numFeatures,t=this._pixelFormat===W.RED?1:4,r=this._dataType===B.FLOAT?4:2,i=Math.ceil((this._overlayRenderer?.overlays[0]?.resolution??0)*this._densityMapPixelRatio)??0;return i*i*t*r+e}get usedMemoryPerFeature(){const e=this._loadedPointGraphics.find((()=>!0));if(null==e)return 0;const t=i(e),r=s(),o=6;return o*a([0,0,0],r)+o*a([0,0],r)+(this._heatmapRendererFieldIsNumeric?o*r:0)+t}get loadedFeatures(){return this._featureStore.numFeatures}get unprocessedMemoryEstimate(){return 0}get performanceInfo(){return{core:{visible:this._visibleFeatures,missing:0,pending:0},elevationUpdating:!1,visibilityFrustum:!0,visibilityScale:!0}}get renderer(){return this._heatmapRenderer}get _overlayRenderer(){return this.view.basemapTerrain.overlayManager.renderer}get _overlaySpatialReference(){return this._overlayRenderer.spatialReference}get _rendererParameters(){return{...this._radiusParameter,...this._densityParameters,...this._colorRampParameter,...this._pixelRatioParameter}}get _materialParameters(){return{...this._radiusParameter,...this._resolutionForScaleParameter}}get _densityParameters(){const e=this._heatmapRenderer;if(null==e)return null;const{minDensity:t,maxDensity:r}=e;return{minDensity:t,maxDensity:r,fieldTotal:this._fieldTotal}}get _radiusParameter(){const e=this._heatmapRenderer;return e?{searchRadius:u(this._clampSearchRadius(e.radius))}:null}get _resolutionForScaleParameter(){const e=this._heatmapRenderer;if(!e)return null;const{referenceScale:t}=e;return{resolutionForScale:0===t?0:g(t,this.view.spatialReference)}}get _colorRampParameter(){const e=this._heatmapRenderer;return e?{colorRampData:P(e.colorStops)}:null}get _pixelRatioParameter(){return{pixelRatio:this._densityMapPixelRatio}}get _densityMapPixelRatio(){return this.owner?.view?.qualitySettings.heatmap.pixelRatio??1}get _renderView(){return this.view._stage.renderView}get _featuresArePoints(){return"point"===this.layer.geometryType}get _loadedPointGraphics(){return this.owner.loadedGraphics}get _heatmapRenderer(){const e=this.layer.renderer;return"heatmap"===e?.type?e:null}get _heatmapRendererFieldName(){return this._heatmapRenderer?.field}get _heatmapRendererField(){const e=this._heatmapRendererFieldName;return null!=e?this.layer.fieldsIndex.get(e):null}get _heatmapRendererFieldIsNumeric(){const e=this._heatmapRendererField;return null!=e&&w(e)}get _isScaleRangeActive(){const{layer:e}=this;if(!("effectiveScaleRange"in e))return!1;const{minScale:t,maxScale:r}=e.effectiveScaleRange;return C(t,r)}get _visibleFeatures(){let e=0;return this._renderGeometries.forEach((t=>{t.visible&&++e})),e}async whenGraphicBounds(){return null}computeAttachmentOrigin(){return null}highlight(){return o()}maskOccludee(){return o()}setObjectIdVisibility(){}refreshFilter(){this.filterVisibility.reapply()}_onLoadedFeaturesChange(e){if(!this._featuresArePoints)return;const{objectIdField:t}=this.layer;this._featureStore.removeManyById(e.removed.map((e=>F(e,t)))),this._featureStore.addMany(e.added.map((e=>{const{attributes:r,centroid:i,geometry:a}=e,s=new b(R(new v,a),r,i?R(new v,i):null,F(e,t));return s.displayId=e.uid,s})));const i=e.added,a=e.removed;this._fieldTotal+=this._computeFieldTotalChange(i,a);const s=a.map((({uid:e})=>{const t=this._renderGeometries.get(e);return this._renderGeometries.delete(e),t})).filter(r),o=i.map((e=>{const t=this._pointGraphicToRenderGeometry(e);return this._renderGeometries.set(e.uid,t),t}));s.length>0&&this._drapeSourceRenderer.removeGeometries(s,N.REMOVE),o.length>0&&this._drapeSourceRenderer.addGeometries(o,N.ADD),(o.length>0||s.length>0)&&(this.filterVisibility.reapply(),this._renderView.requestRender())}_recreate(){if(!this._loadedPointGraphics)return;const e=this._loadedPointGraphics.toArray();this._onLoadedFeaturesChange({added:e,removed:e})}_pointGraphicToRenderGeometry(e){const t=this._heatmapRendererFieldName,r=null!=t?this._materialWithField:this._material,i=c();_(e.geometry,i,this._overlaySpatialReference),i[2]=G;const a=f(1),s=[[E.POSITION,new M(i,a,i.length)]],o=this._heatmapRendererFieldIsNumeric;null!=t&&s.push([E.FEATUREATTRIBUTE,new M([o?e.attributes[t]??0:0],a,1)]);const n=new H(new A(r,s,null,x.Point),{layerUid:this.layer.uid,graphicUid:e.uid});return n.visible=this.filterVisibility.defaultVisibility,n}_forEachMaterial(e){e(this._material),e(this._materialWithField)}_computeFieldTotalChange(e,t){if(null==this._heatmapRendererFieldName||!this._heatmapRendererFieldIsNumeric)return e.length-t.length;const r=this._heatmapRendererFieldName,i=(e,t)=>e+(t.attributes[r]??0);return e.reduce(i,0)-t.reduce(i,0)}_clampSearchRadius(e){return e>q&&$.warnOnce(`SceneView supports a maximum radius of ${q} pt for HeatmapRenderer.`),Math.min(e,q)}_updateFeatureVisibilities(e){const t=[];this._featureStore.forEach((({objectId:r,displayId:i})=>{const a=e(r),s=this._renderGeometries.get(i);s&&s.visible!==a&&(t.push(s),s.visible=a)})),this._drapeSourceRenderer.modifyGeometries(t,O.VISIBILITY)}_setAllFeaturesVisibility(e){const t=[];for(const r of this._renderGeometries.values())r.visible!==e&&(t.push(r),r.visible=e);this._drapeSourceRenderer.modifyGeometries(t,O.VISIBILITY)}get test(){return{visibleFeatureCount:this._visibleFeatures}}};e([m()],k.prototype,"type",void 0),e([m({constructOnly:!0})],k.prototype,"owner",void 0),e([m()],k.prototype,"layer",null),e([m()],k.prototype,"featureStore",null),e([m()],k.prototype,"updating",null),e([m()],k.prototype,"updatingRemaining",null),e([m()],k.prototype,"suspendInfo",null),e([m()],k.prototype,"legendEnabled",null),e([m()],k.prototype,"filterVisibility",null),e([m()],k.prototype,"displayFeatureLimit",null),e([m()],k.prototype,"preferredUpdatePolicy",void 0),e([m()],k.prototype,"hasZ",null),e([m()],k.prototype,"hasM",null),e([m()],k.prototype,"dataExtent",void 0),e([m()],k.prototype,"view",null),e([m()],k.prototype,"fullOpacity",null),e([m()],k.prototype,"updatePolicy",null),e([m()],k.prototype,"drapeSourceType",void 0),e([m()],k.prototype,"scaleVisibilitySuspended",null),e([m()],k.prototype,"renderer",null),e([m()],k.prototype,"_featureStore",void 0),e([m()],k.prototype,"_filterVisibility",void 0),e([m()],k.prototype,"_overlayRenderer",null),e([m()],k.prototype,"_overlaySpatialReference",null),e([m()],k.prototype,"_rendererParameters",null),e([m()],k.prototype,"_materialParameters",null),e([m()],k.prototype,"_densityParameters",null),e([m()],k.prototype,"_radiusParameter",null),e([m()],k.prototype,"_resolutionForScaleParameter",null),e([m()],k.prototype,"_colorRampParameter",null),e([m()],k.prototype,"_pixelRatioParameter",null),e([m()],k.prototype,"_densityMapPixelRatio",null),e([m()],k.prototype,"_renderGeometries",void 0),e([m()],k.prototype,"_material",void 0),e([m()],k.prototype,"_materialWithField",void 0),e([m()],k.prototype,"_renderView",null),e([m()],k.prototype,"_featuresArePoints",null),e([m()],k.prototype,"_loadedPointGraphics",null),e([m()],k.prototype,"_heatmapRenderer",null),e([m()],k.prototype,"_heatmapRendererFieldName",null),e([m()],k.prototype,"_heatmapRendererField",null),e([m()],k.prototype,"_heatmapRendererFieldIsNumeric",null),e([m()],k.prototype,"_fieldTotal",void 0),e([m()],k.prototype,"_drapeSourceRenderer",void 0),e([m()],k.prototype,"_isScaleRangeActive",null),k=e([h(z)],k);export{k as HeatmapFeatureProcessor,q as maxRadiusPt};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import{width as t,height as e,intersects as r}from"../../../../geometry/support/aaBoundingRect.js";import{newDoubleArray as o}from"../../../../geometry/support/DoubleArray.js";import{newFloatArray as n}from"../../../../geometry/support/FloatArray.js";import{Attribute as i}from"../../webgl-engine/lib/Attribute.js";import{Geometry as m}from"../../webgl-engine/lib/Geometry.js";import{createSquareGeometry as h}from"../../webgl-engine/lib/GeometryUtil.js";import{VertexAttribute as g}from"../../webgl-engine/lib/VertexAttribute.js";function u(r,o,n){const i=t(r)/e(r),m={width:n,height:n};return i>1.0001?m.height=n/i:i<.9999&&(m.width=n*i),m.width=Math.round(m.width/(t(r)/t(o))),m.height=Math.round(m.height/(e(r)/e(o))),m}function l(t,e){return h(t,[[e[0],e[1],-1],[e[2],e[1],-1],[e[2],e[3],-1],[e[0],e[3],-1]])}function s(t,e,h){if(!r(e,h))return l(t,h);const u=[e[1]-h[1],Math.min(e[3],h[3])-Math.max(e[1],h[1]),h[3]-e[3],123456],s=[e[0]-h[0],Math.min(e[2],h[2])-Math.max(e[0],h[0]),h[2]-e[2],123456],f=h[2]-h[0],p=h[3]-h[1],w=s[0]>0&&s[2]>0?3:2,b=u[0]>0&&u[2]>0?3:2,c=(b+1)*(w+1),y=o(3*c),d=n(2*c),j=new Array(6*(b*w-1));let A=0,M=0,x=0,O=0,G=0;for(let r=0;r<4;r++){const t=u[r];if(t<=0)continue;let e=0;for(let o=0;o<4;o++){const t=s[o];t<=0||(y[M++]=h[0]+e,y[M++]=h[1]+A,y[M++]=-1,d[x++]=e/f,d[x++]=A/p,o<3&&r<3&&(1!==o||1!==r)&&(j[G++]=O,j[G++]=O+1,j[G++]=O+w+1,j[G++]=O+1,j[G++]=O+w+2,j[G++]=O+w+1),O++,e+=t)}A+=t}const I=new Array(j.length);return new m(t,[[g.POSITION,new i(y,3,!0),j],[g.NORMAL,new i(a,3,!0),I],[g.UV0,new i(d,2,!0),j]])}const a=[0,0,1];export{u as computeImageExportSize,l as createGeometryForExtent,s as createOuterImageGeometry};
5
+ import{width as t,height as e,intersects as r}from"../../../../geometry/support/aaBoundingRect.js";import{newDoubleArray as o}from"../../../../geometry/support/DoubleArray.js";import{newFloatArray as n}from"../../../../geometry/support/FloatArray.js";import{Attribute as i}from"../../webgl-engine/lib/Attribute.js";import{Geometry as m}from"../../webgl-engine/lib/Geometry.js";import{createSquareGeometry as h}from"../../webgl-engine/lib/GeometryUtil.js";import{VertexAttribute as g}from"../../webgl-engine/lib/VertexAttribute.js";function u(r,o,n){const i=t(r)/e(r),m={width:n,height:n};return i>1.0001?m.height=n/i:i<.9999&&(m.width=n*i),m.width=Math.round(m.width/(t(r)/t(o))),m.height=Math.round(m.height/(e(r)/e(o))),m}function l(t,e){return h(t,[[e[0],e[1],-1],[e[2],e[1],-1],[e[2],e[3],-1],[e[0],e[3],-1]])}function s(t,e,h){if(!r(e,h))return l(t,h);const u=[e[1]-h[1],Math.min(e[3],h[3])-Math.max(e[1],h[1]),h[3]-e[3],123456],s=[e[0]-h[0],Math.min(e[2],h[2])-Math.max(e[0],h[0]),h[2]-e[2],123456],f=h[2]-h[0],p=h[3]-h[1],w=s[0]>0&&s[2]>0?3:2,b=u[0]>0&&u[2]>0?3:2,c=(b+1)*(w+1),y=o(3*c),d=n(2*c),j=new Array(6*(b*w-1));let A=0,M=0,x=0,O=0,G=0;for(let r=0;r<4;r++){const t=u[r];if(t<=0)continue;let e=0;for(let o=0;o<4;o++){const t=s[o];t<=0||(y[M++]=h[0]+e,y[M++]=h[1]+A,y[M++]=-1,d[x++]=e/f,d[x++]=A/p,o<3&&r<3&&(1!==o||1!==r)&&(j[G++]=O,j[G++]=O+1,j[G++]=O+w+1,j[G++]=O+1,j[G++]=O+w+2,j[G++]=O+w+1),O++,e+=t)}A+=t}const I=new Array(j.length);return new m(t,[[g.POSITION,new i(y,j,3,!0)],[g.NORMAL,new i(a,I,3,!0)],[g.UV0,new i(d,j,2,!0)]])}const a=[0,0,1];export{u as computeImageExportSize,l as createGeometryForExtent,s as createOuterImageGeometry};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import"../../../../core/has.js";import{f as t}from"../../../../chunks/vec4f64.js";import{perVertexElevationAligner as e}from"../graphics/ElevationAligners.js";import{createMapSpaceUVCoords as r}from"./uvUtils.js";import{VertexAttribute as a}from"../../webgl-engine/lib/VertexAttribute.js";import{ColorMaterial as n}from"../../webgl-engine/materials/ColorMaterial.js";import{PatternMaterial as o}from"../../webgl-engine/materials/PatternMaterial.js";import{Style as i}from"../../webgl-engine/materials/PatternStyle.js";function s(e,r){const a=e?.pattern??null;return null==a?new n(r):"none"===a.style||"solid"===a.style?("none"===a.style&&(r.color=t(0,0,0,0),r.forceTransparentMode=!0),new n(r)):(r.style=l(a.style),new o(r))}function l(t){switch(t){case"horizontal":return i.Horizontal;case"vertical":return i.Vertical;case"cross":return i.Cross;case"forward-diagonal":return i.ForwardDiagonal;case"backward-diagonal":return i.BackwardDiagonal;case"diagonal-cross":return i.DiagonalCross;default:return}}function c(t){return t.material instanceof o&&!t.material.parameters.draped}function u(t,e){if(c(t)){const n=t.vertexAttributes.get(a.POSITION).data,o=t.getMutableAttribute(a.UVMAPSPACE).data,i=t.getMutableAttribute(a.BOUNDINGRECT).data;r(o,i,n,e)}}function m(t,r,a,n,o){const i=e(t,r,a,n,o),s=t.stageObject.geometries;for(const e of s)u(e,o);return i}export{s as createMaterial,l as parsePatternStyle,c as requiresUVUpdates,u as updateMapSpaceUVCoords,m as uvElevationAligner};
5
+ import"../../../../core/has.js";import{f as t}from"../../../../chunks/vec4f64.js";import{perVertexElevationAligner as e}from"../graphics/ElevationAligners.js";import{createMapSpaceUVCoords as r}from"./uvUtils.js";import{VertexAttribute as a}from"../../webgl-engine/lib/VertexAttribute.js";import{ColorMaterial as n}from"../../webgl-engine/materials/ColorMaterial.js";import{PatternMaterial as o}from"../../webgl-engine/materials/PatternMaterial.js";import{Style as i}from"../../webgl-engine/materials/PatternStyle.js";function s(e,r){const a=e?.pattern??null;return null==a?new n(r):"none"===a.style||"solid"===a.style?("none"===a.style&&(r.color=t(0,0,0,0),r.forceTransparentMode=!0),new n(r)):(r.style=l(a.style),new o(r))}function l(t){switch(t){case"horizontal":return i.Horizontal;case"vertical":return i.Vertical;case"cross":return i.Cross;case"forward-diagonal":return i.ForwardDiagonal;case"backward-diagonal":return i.BackwardDiagonal;case"diagonal-cross":return i.DiagonalCross;default:return}}function c(t){return t.material instanceof o&&!t.material.parameters.draped}function u(t,e){if(c(t)){const n=t.attributes.get(a.POSITION).data,o=t.getMutableAttribute(a.UVMAPSPACE).data,i=t.getMutableAttribute(a.BOUNDINGRECT).data;r(o,i,n,e)}}function m(t,r,a,n,o){const i=e(t,r,a,n,o),s=t.stageObject.geometries;for(const e of s)u(e,o);return i}export{s as createMaterial,l as parsePatternStyle,c as requiresUVUpdates,u as updateMapSpaceUVCoords,m as uvElevationAligner};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import{Attribute as t}from"../webgl-engine/lib/Attribute.js";const n=1e-6,r=[0,0,0],i=[0,0,0];function o(n,o){const{data:s,size:a}=n,c=s.length/a;if(c<=0)return;const h=new J(n);Q(r,h.minProj,h.maxProj),U(r,r,.5),R(i,h.maxProj,h.minProj);const u=L(i),m=new K;m.quality=u,c<14&&(n=new t(new Float64Array(h.buffer,112,42),3));const f=[0,0,0],l=[0,0,0],j=[0,0,0],b=[0,0,0],x=[0,0,0],I=[0,0,0],N=[0,0,0];switch(e(h,n,N,f,l,j,b,x,I,m)){case 1:return void g(r,i,o);case 2:return void p(n,b,o)}P(n,N,f,l,j,b,x,I,m),O(n,m.b0,m.b1,m.b2,_,S);const V=[0,0,0];R(V,S,_),m.quality=L(V),m.quality<u?D(m.b0,m.b1,m.b2,_,S,V,o):g(r,i,o)}function e(t,r,i,o,e,s,a,c,h,u){if(j(t,o,e),tt(o,e)<n)return 1;R(a,o,e),Z(a,a);return x(r,o,a,s)<n?2:(R(c,e,s),Z(c,c),R(h,s,o),Z(h,h),X(i,c,a),Z(i,i),M(r,i,a,c,h,u),0)}const s=[0,0,0],a=[0,0,0],c=[0,0,0],h=[0,0,0],u=[0,0,0],m=[0,0,0],f=[0,0,0],l=[0,0,0];function P(t,n,r,i,o,e,P,j,b){N(t,n,r,s,a),void 0!==s[0]&&(R(c,s,r),Z(c,c),R(h,s,i),Z(h,h),R(u,s,o),Z(u,u),X(m,h,e),Z(m,m),X(f,u,P),Z(f,f),X(l,c,j),Z(l,l),M(t,m,e,h,c,b),M(t,f,P,u,h,b),M(t,l,j,c,u,b)),void 0!==a[0]&&(R(c,a,r),Z(c,c),R(h,a,i),Z(h,h),R(u,a,o),Z(u,u),X(m,h,e),Z(m,m),X(f,u,P),Z(f,f),X(l,c,j),Z(l,l),M(t,m,e,h,c,b),M(t,f,P,u,h,b),M(t,l,j,c,u,b))}function j(t,n,r){let i=tt(t.maxVert[0],t.minVert[0]),o=0;for(let e=1;e<7;++e){const n=tt(t.maxVert[e],t.minVert[e]);n>i&&(i=n,o=e)}W(n,t.minVert[o]),W(r,t.maxVert[o])}const b=[0,0,0];function x(t,n,r,i){const{data:o,size:e}=t;let s=Number.NEGATIVE_INFINITY,a=0;for(let c=0;c<o.length;c+=e){b[0]=o[c]-n[0],b[1]=o[c+1]-n[1],b[2]=o[c+2]-n[2];const t=r[0]*b[0]+r[1]*b[1]+r[2]*b[2],i=r[0]*r[0]+r[1]*r[1]+r[2]*r[2],e=b[0]*b[0]+b[1]*b[1]+b[2]*b[2]-t*t/i;e>s&&(s=e,a=c)}return W(i,o,a),s}const I=[0,0];function N(t,r,i,o,e){E(t,r,I,e,o);const s=nt(i,r);I[1]-n<=s&&(o[0]=void 0),I[0]+n>=s&&(e[0]=void 0)}const V=[0,0,0],y=[0,0,0],w=[0,0,0],q=[0,0,0],A=[0,0,0],d=[0,0,0];function M(t,r,i,o,e,s){if($(r)<n)return;X(V,i,r),X(y,o,r),X(w,e,r),T(t,r,I),A[1]=I[0],q[1]=I[1],d[1]=q[1]-A[1];const a=[i,o,e],c=[V,y,w];for(let n=0;n<3;++n){T(t,a[n],I),A[0]=I[0],q[0]=I[1],T(t,c[n],I),A[2]=I[0],q[2]=I[1],d[0]=q[0]-A[0],d[2]=q[2]-A[2];const i=L(d);i<s.quality&&(W(s.b0,a[n]),W(s.b1,r),W(s.b2,c[n]),s.quality=i)}}const F=[0,0,0];function T(t,n,r){const{data:i,size:o}=t;r[0]=Number.POSITIVE_INFINITY,r[1]=Number.NEGATIVE_INFINITY;for(let e=0;e<i.length;e+=o){const t=i[e]*n[0]+i[e+1]*n[1]+i[e+2]*n[2];r[0]=Math.min(r[0],t),r[1]=Math.max(r[1],t)}}function E(t,n,r,i,o){const{data:e,size:s}=t;W(i,e),W(o,i),r[0]=nt(F,n),r[1]=r[0];for(let a=s;a<e.length;a+=s){const t=e[a]*n[0]+e[a+1]*n[1]+e[a+2]*n[2];t<r[0]&&(r[0]=t,W(i,e,a)),t>r[1]&&(r[1]=t,W(o,e,a))}}function g(t,n,r){W(r.center,t),U(r.halfSize,n,.5),r.quaternion[0]=0,r.quaternion[1]=0,r.quaternion[2]=0,r.quaternion[3]=1}const z=[0,0,0],v=[0,0,0],Y=[0,0,0],_=[0,0,0],S=[0,0,0],G=[0,0,0];function p(t,r,i){W(z,r),Math.abs(r[0])>Math.abs(r[1])&&Math.abs(r[0])>Math.abs(r[2])?z[0]=0:Math.abs(r[1])>Math.abs(r[2])?z[1]=0:z[2]=0,$(z)<n&&(z[0]=z[1]=z[2]=1),X(v,r,z),Z(v,v),X(Y,r,v),Z(Y,Y),O(t,r,v,Y,_,S),R(G,S,_),D(r,v,Y,_,S,G,i)}function O(t,n,r,i,o,e){T(t,n,I),o[0]=I[0],e[0]=I[1],T(t,r,I),o[1]=I[0],e[1]=I[1],T(t,i,I),o[2]=I[0],e[2]=I[1]}const B=[0,0,0],k=[1,0,0,0,1,0,0,0,1],C=[0,0,0];function D(t,n,r,i,o,e,s){k[0]=t[0],k[1]=t[1],k[2]=t[2],k[3]=n[0],k[4]=n[1],k[5]=n[2],k[6]=r[0],k[7]=r[1],k[8]=r[2],rt(s.quaternion,k),Q(C,i,o),U(C,C,.5),U(s.center,t,C[0]),U(B,n,C[1]),Q(s.center,s.center,B),U(B,r,C[2]),Q(s.center,s.center,B),U(s.halfSize,e,.5)}const H=7;class J{constructor(t){this.minVert=new Array(H),this.maxVert=new Array(H);const n=64*H;this.buffer=new ArrayBuffer(n);let r=0;this.minProj=new Float64Array(this.buffer,r,H),r+=8*H,this.maxProj=new Float64Array(this.buffer,r,H),r+=8*H;for(let a=0;a<H;++a)this.minVert[a]=new Float64Array(this.buffer,r,3),r+=24;for(let a=0;a<H;++a)this.maxVert[a]=new Float64Array(this.buffer,r,3),r+=24;for(let a=0;a<H;++a)this.minProj[a]=Number.POSITIVE_INFINITY,this.maxProj[a]=Number.NEGATIVE_INFINITY;const i=new Array(H),o=new Array(H),{data:e,size:s}=t;for(let a=0;a<e.length;a+=s){let t=e[a];t<this.minProj[0]&&(this.minProj[0]=t,i[0]=a),t>this.maxProj[0]&&(this.maxProj[0]=t,o[0]=a),t=e[a+1],t<this.minProj[1]&&(this.minProj[1]=t,i[1]=a),t>this.maxProj[1]&&(this.maxProj[1]=t,o[1]=a),t=e[a+2],t<this.minProj[2]&&(this.minProj[2]=t,i[2]=a),t>this.maxProj[2]&&(this.maxProj[2]=t,o[2]=a),t=e[a]+e[a+1]+e[a+2],t<this.minProj[3]&&(this.minProj[3]=t,i[3]=a),t>this.maxProj[3]&&(this.maxProj[3]=t,o[3]=a),t=e[a]+e[a+1]-e[a+2],t<this.minProj[4]&&(this.minProj[4]=t,i[4]=a),t>this.maxProj[4]&&(this.maxProj[4]=t,o[4]=a),t=e[a]-e[a+1]+e[a+2],t<this.minProj[5]&&(this.minProj[5]=t,i[5]=a),t>this.maxProj[5]&&(this.maxProj[5]=t,o[5]=a),t=e[a]-e[a+1]-e[a+2],t<this.minProj[6]&&(this.minProj[6]=t,i[6]=a),t>this.maxProj[6]&&(this.maxProj[6]=t,o[6]=a)}for(let a=0;a<H;++a){let t=i[a];W(this.minVert[a],e,t),t=o[a],W(this.maxVert[a],e,t)}}}class K{constructor(){this.b0=[1,0,0],this.b1=[0,1,0],this.b2=[0,0,1],this.quality=0}}function L(t){return t[0]*t[1]+t[0]*t[2]+t[1]*t[2]}function Q(t,n,r){t[0]=n[0]+r[0],t[1]=n[1]+r[1],t[2]=n[2]+r[2]}function R(t,n,r){t[0]=n[0]-r[0],t[1]=n[1]-r[1],t[2]=n[2]-r[2]}function U(t,n,r){t[0]=n[0]*r,t[1]=n[1]*r,t[2]=n[2]*r}function W(t,n,r=0){t[0]=n[r],t[1]=n[r+1],t[2]=n[r+2]}function X(t,n,r){const i=n[0],o=n[1],e=n[2],s=r[0],a=r[1],c=r[2];t[0]=o*c-e*a,t[1]=e*s-i*c,t[2]=i*a-o*s}function Z(t,n){const r=n[0]*n[0]+n[1]*n[1]+n[2]*n[2];if(r>0){const i=1/Math.sqrt(r);t[0]=n[0]*i,t[1]=n[1]*i,t[2]=n[2]*i}}function $(t){return t[0]*t[0]+t[1]*t[1]+t[2]*t[2]}function tt(t,n){const r=n[0]-t[0],i=n[1]-t[1],o=n[2]-t[2];return r*r+i*i+o*o}function nt(t,n){return t[0]*n[0]+t[1]*n[1]+t[2]*n[2]}function rt(t,n){const r=n[0]+n[4]+n[8];if(r>0){let i=Math.sqrt(r+1);t[3]=.5*i,i=.5/i,t[0]=(n[5]-n[7])*i,t[1]=(n[6]-n[2])*i,t[2]=(n[1]-n[3])*i}else{let r=0;n[4]>n[0]&&(r=1),n[8]>n[3*r+r]&&(r=2);const i=(r+1)%3,o=(r+2)%3;let e=Math.sqrt(n[3*r+r]-n[3*i+i]-n[3*o+o]+1);t[r]=.5*e,e=.5/e,t[3]=(n[3*i+o]-n[3*o+i])*e,t[i]=(n[3*i+r]+n[3*r+i])*e,t[o]=(n[3*o+r]+n[3*r+o])*e}}export{o as computeOBB};
5
+ import{Vertices as t}from"../webgl-engine/lib/Attribute.js";const n=1e-6,r=[0,0,0],i=[0,0,0];function o(n,o){const{data:s,size:a}=n,c=s.length/a;if(c<=0)return;const h=new J(n);Q(r,h.minProj,h.maxProj),U(r,r,.5),R(i,h.maxProj,h.minProj);const u=L(i),m=new K;m.quality=u,c<14&&(n=new t(new Float64Array(h.buffer,112,42),3));const f=[0,0,0],l=[0,0,0],j=[0,0,0],b=[0,0,0],x=[0,0,0],I=[0,0,0],N=[0,0,0];switch(e(h,n,N,f,l,j,b,x,I,m)){case 1:return void g(r,i,o);case 2:return void p(n,b,o)}P(n,N,f,l,j,b,x,I,m),O(n,m.b0,m.b1,m.b2,_,S);const V=[0,0,0];R(V,S,_),m.quality=L(V),m.quality<u?D(m.b0,m.b1,m.b2,_,S,V,o):g(r,i,o)}function e(t,r,i,o,e,s,a,c,h,u){if(j(t,o,e),tt(o,e)<n)return 1;R(a,o,e),Z(a,a);return x(r,o,a,s)<n?2:(R(c,e,s),Z(c,c),R(h,s,o),Z(h,h),X(i,c,a),Z(i,i),M(r,i,a,c,h,u),0)}const s=[0,0,0],a=[0,0,0],c=[0,0,0],h=[0,0,0],u=[0,0,0],m=[0,0,0],f=[0,0,0],l=[0,0,0];function P(t,n,r,i,o,e,P,j,b){N(t,n,r,s,a),void 0!==s[0]&&(R(c,s,r),Z(c,c),R(h,s,i),Z(h,h),R(u,s,o),Z(u,u),X(m,h,e),Z(m,m),X(f,u,P),Z(f,f),X(l,c,j),Z(l,l),M(t,m,e,h,c,b),M(t,f,P,u,h,b),M(t,l,j,c,u,b)),void 0!==a[0]&&(R(c,a,r),Z(c,c),R(h,a,i),Z(h,h),R(u,a,o),Z(u,u),X(m,h,e),Z(m,m),X(f,u,P),Z(f,f),X(l,c,j),Z(l,l),M(t,m,e,h,c,b),M(t,f,P,u,h,b),M(t,l,j,c,u,b))}function j(t,n,r){let i=tt(t.maxVert[0],t.minVert[0]),o=0;for(let e=1;e<7;++e){const n=tt(t.maxVert[e],t.minVert[e]);n>i&&(i=n,o=e)}W(n,t.minVert[o]),W(r,t.maxVert[o])}const b=[0,0,0];function x(t,n,r,i){const{data:o,size:e}=t;let s=Number.NEGATIVE_INFINITY,a=0;for(let c=0;c<o.length;c+=e){b[0]=o[c]-n[0],b[1]=o[c+1]-n[1],b[2]=o[c+2]-n[2];const t=r[0]*b[0]+r[1]*b[1]+r[2]*b[2],i=r[0]*r[0]+r[1]*r[1]+r[2]*r[2],e=b[0]*b[0]+b[1]*b[1]+b[2]*b[2]-t*t/i;e>s&&(s=e,a=c)}return W(i,o,a),s}const I=[0,0];function N(t,r,i,o,e){E(t,r,I,e,o);const s=nt(i,r);I[1]-n<=s&&(o[0]=void 0),I[0]+n>=s&&(e[0]=void 0)}const V=[0,0,0],y=[0,0,0],w=[0,0,0],q=[0,0,0],A=[0,0,0],d=[0,0,0];function M(t,r,i,o,e,s){if($(r)<n)return;X(V,i,r),X(y,o,r),X(w,e,r),T(t,r,I),A[1]=I[0],q[1]=I[1],d[1]=q[1]-A[1];const a=[i,o,e],c=[V,y,w];for(let n=0;n<3;++n){T(t,a[n],I),A[0]=I[0],q[0]=I[1],T(t,c[n],I),A[2]=I[0],q[2]=I[1],d[0]=q[0]-A[0],d[2]=q[2]-A[2];const i=L(d);i<s.quality&&(W(s.b0,a[n]),W(s.b1,r),W(s.b2,c[n]),s.quality=i)}}const F=[0,0,0];function T(t,n,r){const{data:i,size:o}=t;r[0]=Number.POSITIVE_INFINITY,r[1]=Number.NEGATIVE_INFINITY;for(let e=0;e<i.length;e+=o){const t=i[e]*n[0]+i[e+1]*n[1]+i[e+2]*n[2];r[0]=Math.min(r[0],t),r[1]=Math.max(r[1],t)}}function E(t,n,r,i,o){const{data:e,size:s}=t;W(i,e),W(o,i),r[0]=nt(F,n),r[1]=r[0];for(let a=s;a<e.length;a+=s){const t=e[a]*n[0]+e[a+1]*n[1]+e[a+2]*n[2];t<r[0]&&(r[0]=t,W(i,e,a)),t>r[1]&&(r[1]=t,W(o,e,a))}}function g(t,n,r){W(r.center,t),U(r.halfSize,n,.5),r.quaternion[0]=0,r.quaternion[1]=0,r.quaternion[2]=0,r.quaternion[3]=1}const z=[0,0,0],v=[0,0,0],Y=[0,0,0],_=[0,0,0],S=[0,0,0],G=[0,0,0];function p(t,r,i){W(z,r),Math.abs(r[0])>Math.abs(r[1])&&Math.abs(r[0])>Math.abs(r[2])?z[0]=0:Math.abs(r[1])>Math.abs(r[2])?z[1]=0:z[2]=0,$(z)<n&&(z[0]=z[1]=z[2]=1),X(v,r,z),Z(v,v),X(Y,r,v),Z(Y,Y),O(t,r,v,Y,_,S),R(G,S,_),D(r,v,Y,_,S,G,i)}function O(t,n,r,i,o,e){T(t,n,I),o[0]=I[0],e[0]=I[1],T(t,r,I),o[1]=I[0],e[1]=I[1],T(t,i,I),o[2]=I[0],e[2]=I[1]}const B=[0,0,0],k=[1,0,0,0,1,0,0,0,1],C=[0,0,0];function D(t,n,r,i,o,e,s){k[0]=t[0],k[1]=t[1],k[2]=t[2],k[3]=n[0],k[4]=n[1],k[5]=n[2],k[6]=r[0],k[7]=r[1],k[8]=r[2],rt(s.quaternion,k),Q(C,i,o),U(C,C,.5),U(s.center,t,C[0]),U(B,n,C[1]),Q(s.center,s.center,B),U(B,r,C[2]),Q(s.center,s.center,B),U(s.halfSize,e,.5)}const H=7;class J{constructor(t){this.minVert=new Array(H),this.maxVert=new Array(H);const n=64*H;this.buffer=new ArrayBuffer(n);let r=0;this.minProj=new Float64Array(this.buffer,r,H),r+=8*H,this.maxProj=new Float64Array(this.buffer,r,H),r+=8*H;for(let a=0;a<H;++a)this.minVert[a]=new Float64Array(this.buffer,r,3),r+=24;for(let a=0;a<H;++a)this.maxVert[a]=new Float64Array(this.buffer,r,3),r+=24;for(let a=0;a<H;++a)this.minProj[a]=Number.POSITIVE_INFINITY,this.maxProj[a]=Number.NEGATIVE_INFINITY;const i=new Array(H),o=new Array(H),{data:e,size:s}=t;for(let a=0;a<e.length;a+=s){let t=e[a];t<this.minProj[0]&&(this.minProj[0]=t,i[0]=a),t>this.maxProj[0]&&(this.maxProj[0]=t,o[0]=a),t=e[a+1],t<this.minProj[1]&&(this.minProj[1]=t,i[1]=a),t>this.maxProj[1]&&(this.maxProj[1]=t,o[1]=a),t=e[a+2],t<this.minProj[2]&&(this.minProj[2]=t,i[2]=a),t>this.maxProj[2]&&(this.maxProj[2]=t,o[2]=a),t=e[a]+e[a+1]+e[a+2],t<this.minProj[3]&&(this.minProj[3]=t,i[3]=a),t>this.maxProj[3]&&(this.maxProj[3]=t,o[3]=a),t=e[a]+e[a+1]-e[a+2],t<this.minProj[4]&&(this.minProj[4]=t,i[4]=a),t>this.maxProj[4]&&(this.maxProj[4]=t,o[4]=a),t=e[a]-e[a+1]+e[a+2],t<this.minProj[5]&&(this.minProj[5]=t,i[5]=a),t>this.maxProj[5]&&(this.maxProj[5]=t,o[5]=a),t=e[a]-e[a+1]-e[a+2],t<this.minProj[6]&&(this.minProj[6]=t,i[6]=a),t>this.maxProj[6]&&(this.maxProj[6]=t,o[6]=a)}for(let a=0;a<H;++a){let t=i[a];W(this.minVert[a],e,t),t=o[a],W(this.maxVert[a],e,t)}}}class K{constructor(){this.b0=[1,0,0],this.b1=[0,1,0],this.b2=[0,0,1],this.quality=0}}function L(t){return t[0]*t[1]+t[0]*t[2]+t[1]*t[2]}function Q(t,n,r){t[0]=n[0]+r[0],t[1]=n[1]+r[1],t[2]=n[2]+r[2]}function R(t,n,r){t[0]=n[0]-r[0],t[1]=n[1]-r[1],t[2]=n[2]-r[2]}function U(t,n,r){t[0]=n[0]*r,t[1]=n[1]*r,t[2]=n[2]*r}function W(t,n,r=0){t[0]=n[r],t[1]=n[r+1],t[2]=n[r+2]}function X(t,n,r){const i=n[0],o=n[1],e=n[2],s=r[0],a=r[1],c=r[2];t[0]=o*c-e*a,t[1]=e*s-i*c,t[2]=i*a-o*s}function Z(t,n){const r=n[0]*n[0]+n[1]*n[1]+n[2]*n[2];if(r>0){const i=1/Math.sqrt(r);t[0]=n[0]*i,t[1]=n[1]*i,t[2]=n[2]*i}}function $(t){return t[0]*t[0]+t[1]*t[1]+t[2]*t[2]}function tt(t,n){const r=n[0]-t[0],i=n[1]-t[1],o=n[2]-t[2];return r*r+i*i+o*o}function nt(t,n){return t[0]*n[0]+t[1]*n[1]+t[2]*n[2]}function rt(t,n){const r=n[0]+n[4]+n[8];if(r>0){let i=Math.sqrt(r+1);t[3]=.5*i,i=.5/i,t[0]=(n[5]-n[7])*i,t[1]=(n[6]-n[2])*i,t[2]=(n[1]-n[3])*i}else{let r=0;n[4]>n[0]&&(r=1),n[8]>n[3*r+r]&&(r=2);const i=(r+1)%3,o=(r+2)%3;let e=Math.sqrt(n[3*r+r]-n[3*i+i]-n[3*o+o]+1);t[r]=.5*e,e=.5/e,t[3]=(n[3*i+o]-n[3*o+i])*e,t[i]=(n[3*i+r]+n[3*r+i])*e,t[o]=(n[3*o+r]+n[3*r+o])*e}}export{o as computeOBB};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import{p as t}from"../../../../chunks/vec2.js";import{s as e}from"../../../../chunks/vec3.js";import{c as r}from"../../../../chunks/vec3f64.js";import{O as o}from"../../../../chunks/vec4f64.js";import{getReferenceEllipsoid as n}from"../../../../geometry/ellipsoidUtils.js";import{lonLatToWebMercatorComparable as a}from"../../../../geometry/projection/projectors.js";import{newDoubleArray as i}from"../../../../geometry/support/DoubleArray.js";import{newFloatArray as u}from"../../../../geometry/support/FloatArray.js";import{getZeroIndexArray as s}from"../../../../geometry/support/Indices.js";import{ViewingMode as l}from"../../../ViewingMode.js";import{Attribute as c}from"../../webgl-engine/lib/Attribute.js";import{ContentObjectType as p}from"../../webgl-engine/lib/ContentObjectType.js";import{Geometry as f}from"../../webgl-engine/lib/Geometry.js";import{VertexAttribute as m}from"../../webgl-engine/lib/VertexAttribute.js";function b(t,e,r=null){const o=[],n=e.mapPositions;g(e,o);const a=o[0][1].data,i=o[0][2]?.length??0,u=s(i);return h(e,o,u),j(e,o,u),T(e,o,u),D(e,o,u),w(e,o,u),y(e,o,u),E(e,o,a),new f(t,o,n,p.Line,r)}function g(t,e){const{attributeData:{position:r},removeDuplicateStartEnd:o}=t,n=A(r)&&o,a=r.length/3-(n?1:0),i=new Array(2*(a-1)),u=n?r.slice(0,-3):r;let s=0;for(let l=0;l<a-1;l++)i[s++]=l,i[s++]=l+1;e.push([m.POSITION,new c(u,3,n),i])}function h(t,e,r){if(null!=t.attributeData.colorFeature)return;const n=t.attributeData.color;e.push([m.COLOR,new c(n??o,4),r])}function T(t,e,r){t.attributeData.normal&&e.push([m.NORMAL,new c(t.attributeData.normal,3),r])}function D(t,e,r){null!=t.attributeData.colorFeature&&e.push([m.COLORFEATUREATTRIBUTE,new c([t.attributeData.colorFeature],1,!0),r])}function j(t,e,r){null==t.attributeData.sizeFeature&&e.push([m.SIZE,new c([t.attributeData.size??1],1,!0),r])}function w(t,e,r){null!=t.attributeData.sizeFeature&&e.push([m.SIZEFEATUREATTRIBUTE,new c([t.attributeData.sizeFeature],1,!0),r])}function y(t,e,r){null!=t.attributeData.opacityFeature&&e.push([m.OPACITYFEATUREATTRIBUTE,new c([t.attributeData.opacityFeature],1,!0),r])}function E(r,o,s){if(null==r.overlayInfo||r.overlayInfo.renderCoordsHelper.viewingMode!==l.Global||!r.overlayInfo.spatialReference.isGeographic)return;const p=i(s.length),f=n(r.overlayInfo.spatialReference);for(let t=0;t<p.length;t+=3)a(s,t,p,t,f);const b=s.length/3,g=u(b+1);let h=I,T=F,D=0,j=0;e(h,p[j++],p[j++],p[j++]),g[0]=0;for(let n=1;n<b+1;++n)n===b&&(j=0),e(T,p[j++],p[j++],p[j++]),D+=t(h,T),g[n]=D,[h,T]=[T,h];o.push([m.DISTANCETOSTART,new c(g,1,!0),o[0][2]])}function A(t){const e=t.length;return t[0]===t[e-3]&&t[1]===t[e-2]&&t[2]===t[e-1]}const I=r(),F=r();function R(t,e){if(null==t||0===t.length)return[];const r=[];return t.forEach((t=>{const o=t.length,n=i(3*o);t.forEach(((t,e)=>{n[3*e]=t[0],n[3*e+1]=t[1],n[3*e+2]=t[2]}));const a={attributeData:{position:n,normal:e},removeDuplicateStartEnd:!1};r.push(a)})),r}export{b as createGeometry,R as lineStripsToParameters};
5
+ import{p as t}from"../../../../chunks/vec2.js";import{s as e}from"../../../../chunks/vec3.js";import{c as r}from"../../../../chunks/vec3f64.js";import{O as o}from"../../../../chunks/vec4f64.js";import{getReferenceEllipsoid as n}from"../../../../geometry/ellipsoidUtils.js";import{lonLatToWebMercatorComparable as i}from"../../../../geometry/projection/projectors.js";import{newDoubleArray as a}from"../../../../geometry/support/DoubleArray.js";import{newFloatArray as u}from"../../../../geometry/support/FloatArray.js";import{getZeroIndexArray as s}from"../../../../geometry/support/Indices.js";import{ViewingMode as l}from"../../../ViewingMode.js";import{Attribute as c}from"../../webgl-engine/lib/Attribute.js";import{ContentObjectType as p}from"../../webgl-engine/lib/ContentObjectType.js";import{Geometry as f}from"../../webgl-engine/lib/Geometry.js";import{VertexAttribute as m}from"../../webgl-engine/lib/VertexAttribute.js";function b(t,e,r=null){const o=[],n=e.mapPositions;g(e,o);const i=o[0][1].data,a=o[0][1].indices.length??0,u=s(a);return h(e,o,u),j(e,o,u),T(e,o,u),D(e,o,u),w(e,o,u),y(e,o,u),E(e,o,i),new f(t,o,n,p.Line,r)}function g(t,e){const{attributeData:{position:r},removeDuplicateStartEnd:o}=t,n=A(r)&&o,i=r.length/3-(n?1:0),a=new Array(2*(i-1)),u=n?r.slice(0,-3):r;let s=0;for(let l=0;l<i-1;l++)a[s++]=l,a[s++]=l+1;e.push([m.POSITION,new c(u,a,3,n)])}function h(t,e,r){if(null!=t.attributeData.colorFeature)return;const n=t.attributeData.color;e.push([m.COLOR,new c(n??o,r,4)])}function T(t,e,r){t.attributeData.normal&&e.push([m.NORMAL,new c(t.attributeData.normal,r,3)])}function D(t,e,r){null!=t.attributeData.colorFeature&&e.push([m.COLORFEATUREATTRIBUTE,new c([t.attributeData.colorFeature],r,1,!0)])}function j(t,e,r){null==t.attributeData.sizeFeature&&e.push([m.SIZE,new c([t.attributeData.size??1],r,1,!0)])}function w(t,e,r){null!=t.attributeData.sizeFeature&&e.push([m.SIZEFEATUREATTRIBUTE,new c([t.attributeData.sizeFeature],r,1,!0)])}function y(t,e,r){null!=t.attributeData.opacityFeature&&e.push([m.OPACITYFEATUREATTRIBUTE,new c([t.attributeData.opacityFeature],r,1,!0)])}function E(r,o,s){if(null==r.overlayInfo||r.overlayInfo.renderCoordsHelper.viewingMode!==l.Global||!r.overlayInfo.spatialReference.isGeographic)return;const p=a(s.length),f=n(r.overlayInfo.spatialReference);for(let t=0;t<p.length;t+=3)i(s,t,p,t,f);const b=s.length/3,g=u(b+1);let h=I,T=F,D=0,j=0;e(h,p[j++],p[j++],p[j++]),g[0]=0;for(let n=1;n<b+1;++n)n===b&&(j=0),e(T,p[j++],p[j++],p[j++]),D+=t(h,T),g[n]=D,[h,T]=[T,h];o.push([m.DISTANCETOSTART,new c(g,o[0][1].indices,1,!0)])}function A(t){const e=t.length;return t[0]===t[e-3]&&t[1]===t[e-2]&&t[2]===t[e-1]}const I=r(),F=r();function R(t,e){if(null==t||0===t.length)return[];const r=[];return t.forEach((t=>{const o=t.length,n=a(3*o);t.forEach(((t,e)=>{n[3*e]=t[0],n[3*e+1]=t[1],n[3*e+2]=t[2]}));const i={attributeData:{position:n,normal:e},removeDuplicateStartEnd:!1};r.push(i)})),r}export{b as createGeometry,R as lineStripsToParameters};