@arcgis/core 5.1.0-next.46 → 5.1.0-next.48

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 (131) hide show
  1. package/assets/esri/core/workers/RemoteClient.js +1 -1
  2. package/assets/esri/core/workers/chunks/{521a671182b0f79e3624.js → 193775b3b7de8f5dc578.js} +1 -1
  3. package/assets/esri/core/workers/chunks/{c0ecb68387e342dddf58.js → 25509953f19fbc4949a1.js} +1 -1
  4. package/assets/esri/core/workers/chunks/2669a7195f1de21a9cf3.js +1 -0
  5. package/assets/esri/core/workers/chunks/36425d29aaa5852cb41d.js +1 -0
  6. package/assets/esri/core/workers/chunks/440a650ed0867a16f559.js +1 -0
  7. package/assets/esri/core/workers/chunks/{aa367ca7f8326fd67881.js → 4afddb66242438b38df0.js} +1 -1
  8. package/assets/esri/core/workers/chunks/5344919fc6e8050450f1.js +1 -0
  9. package/assets/esri/core/workers/chunks/53c149bca42595b7dd1e.js +1 -0
  10. package/assets/esri/core/workers/chunks/{6afdaa6c4555c467dca7.js → 54420b66fd53d6e19ba5.js} +1 -1
  11. package/assets/esri/core/workers/chunks/797bf402489b3677a5f7.js +1 -0
  12. package/assets/esri/core/workers/chunks/{5c830cce32710d70dfa6.js → 7dba4121cdd20dbc4b20.js} +1 -1
  13. package/assets/esri/core/workers/chunks/947a715b608c8affd812.js +1 -0
  14. package/assets/esri/core/workers/chunks/{ce0a6bc9df30af778ac9.js → 9f7b5749f3ceca8d5978.js} +12 -9
  15. package/assets/esri/core/workers/chunks/aa69cbaa38b49677ddff.js +1 -0
  16. package/assets/esri/core/workers/chunks/{beb53b372d356800f333.js → ab414a60808ea05a63e6.js} +1 -1
  17. package/assets/esri/core/workers/chunks/b98dd9fc9a7e3ff6bd49.js +1 -0
  18. package/assets/esri/core/workers/chunks/cb8c17daec7055bf99cc.js +1 -0
  19. package/assets/esri/core/workers/chunks/cd491c37ba1ac381178c.js +1 -0
  20. package/assets/esri/core/workers/chunks/{a9f35127c3f5bf42036b.js → de359f89e03da18999fc.js} +1 -1
  21. package/chunks/Fog.glsl.js +3 -3
  22. package/chunks/GlowComposition.glsl.js +5 -3
  23. package/chunks/OITBlend.glsl.js +2 -1
  24. package/config.js +1 -1
  25. package/core/has.js +1 -1
  26. package/core/workers/Connection.js +1 -1
  27. package/core/workers/WorkerHandle.js +1 -1
  28. package/core/workers/workers.js +1 -1
  29. package/geometry/support/curves/bezierCurveUtils.js +1 -1
  30. package/kernel.js +1 -1
  31. package/layers/Layer.d.ts +2 -1
  32. package/layers/Lyr3DWorkerHandle.js +1 -1
  33. package/layers/ParquetLayer.d.ts +23 -1
  34. package/layers/graphics/data/QueryEngineResult.js +1 -1
  35. package/layers/support/LayerContingentValuesCache.js +1 -1
  36. package/layers/support/RasterJobHandler.js +1 -1
  37. package/layers/support/arcgisLayers.js +1 -1
  38. package/layers/support/layerUtils.js +1 -1
  39. package/package.json +1 -1
  40. package/smartMapping/statistics/support/statsWorker.js +1 -1
  41. package/support/revision.js +1 -1
  42. package/time/TimeExtent.d.ts +34 -0
  43. package/time/TimeInterval.d.ts +15 -0
  44. package/views/2d/engine/vectorTiles/TileHandler.js +1 -1
  45. package/views/2d/engine/webgl/shaders/sources/shaderRepository.js +1 -1
  46. package/views/3d/analysis/AreaMeasurement/support/AreaMeasurementVisualization.js +1 -1
  47. package/views/3d/analysis/Dimension/LengthDimensionSubTool.js +1 -1
  48. package/views/3d/analysis/DirectLineMeasurement/DirectLineMeasurementVisualization.js +1 -1
  49. package/views/3d/analysis/Slice/SliceTool.js +1 -1
  50. package/views/3d/analysis/VolumeMeasurement/VolumeMeasurementCutFillVisualization.js +1 -1
  51. package/views/3d/interactive/visualElements/ExtendedLineVisualElement.js +1 -1
  52. package/views/3d/interactive/visualElements/LineVisualElement.js +1 -1
  53. package/views/3d/interactive/visualElements/MeasurementAreaVisualElement.js +1 -1
  54. package/views/3d/interactive/visualElements/OutlineVisualElement.js +1 -1
  55. package/views/3d/interactive/visualElements/RightAngleQuadVisualElement.js +1 -1
  56. package/views/3d/layers/FlowSubView3D.js +1 -1
  57. package/views/3d/layers/GaussianSplatLayerView3D.js +1 -1
  58. package/views/3d/layers/I3SMeshView3D.js +1 -1
  59. package/views/3d/layers/IntegratedMesh3DTilesLayerView3D.js +1 -1
  60. package/views/3d/layers/SceneLayerWorkerHandle.js +1 -1
  61. package/views/3d/layers/graphics/Graphics3DLineSymbolLayer.js +1 -1
  62. package/views/3d/layers/graphics/Graphics3DObjectSymbolLayer.js +1 -1
  63. package/views/3d/layers/graphics/Graphics3DPolygonFillSymbolLayer.js +1 -1
  64. package/views/3d/layers/i3s/Highlights.js +1 -1
  65. package/views/3d/layers/i3s/Intersector.js +1 -1
  66. package/views/3d/layers/support/patternUtils.js +1 -1
  67. package/views/3d/support/gaussianSplatting/GaussianSplatDataStore.js +1 -1
  68. package/views/3d/support/gaussianSplatting/GaussianSplatFadeHelper.js +1 -1
  69. package/views/3d/support/gaussianSplatting/GaussianSplatFadeTexture.js +1 -1
  70. package/views/3d/support/gaussianSplatting/GaussianSplatOrderTexture.js +1 -1
  71. package/views/3d/support/gaussianSplatting/GaussianSplatTextureAtlas.js +1 -1
  72. package/views/3d/terrain/TerrainRenderer.js +1 -1
  73. package/views/3d/webgl-engine/collections/Component/ComponentObject.js +1 -1
  74. package/views/3d/webgl-engine/collections/Component/ComponentObjectCollection.js +1 -1
  75. package/views/3d/webgl-engine/collections/Component/Material/ComponentMaterialGlobalParameters.js +2 -0
  76. package/views/3d/webgl-engine/collections/Component/Material/ComponentMaterialRepository.js +1 -1
  77. package/views/3d/webgl-engine/collections/Component/Material/ComponentTechnique.js +1 -1
  78. package/views/3d/webgl-engine/collections/Component/Material/ComponentTechniqueConfiguration.js +1 -1
  79. package/views/3d/webgl-engine/core/renderPasses/RenderPassManager.js +1 -1
  80. package/views/3d/webgl-engine/effects/fog/Fog.glsl.js +1 -1
  81. package/views/3d/webgl-engine/effects/fog/Fog.js +1 -1
  82. package/views/3d/webgl-engine/effects/fog/FogTechniqueConfiguration.js +1 -1
  83. package/views/3d/webgl-engine/effects/glow/GlowBlurTechniqueConfiguration.js +1 -1
  84. package/views/3d/webgl-engine/effects/glow/GlowComposition.glsl.js +1 -1
  85. package/views/3d/webgl-engine/effects/glow/GlowCompositionTechniqueConfiguration.js +1 -1
  86. package/views/3d/webgl-engine/effects/glow/GlowRenderNode.js +1 -1
  87. package/views/3d/webgl-engine/effects/transparency/OITBlend.js +1 -1
  88. package/views/3d/webgl-engine/lib/BindParameters.js +1 -1
  89. package/views/3d/webgl-engine/lib/GridLocalOriginFactory.js +1 -1
  90. package/views/3d/webgl-engine/lib/MainFramebuffer.js +1 -1
  91. package/views/3d/webgl-engine/lib/Material.js +1 -1
  92. package/views/3d/webgl-engine/lib/OrderIndependentTransparency.js +1 -1
  93. package/views/3d/webgl-engine/lib/Renderer.js +1 -1
  94. package/views/3d/webgl-engine/lib/intersectorUtilsConversions.js +1 -1
  95. package/views/3d/webgl-engine/materials/ColorMaterial.js +1 -1
  96. package/views/3d/webgl-engine/materials/DefaultMaterial.js +1 -1
  97. package/views/3d/webgl-engine/materials/PathMaterial.js +1 -1
  98. package/views/3d/webgl-engine/materials/PathTechnique.js +1 -1
  99. package/views/3d/webgl-engine/materials/PathTechniqueConfiguration.js +1 -1
  100. package/views/3d/webgl-engine/materials/PatternMaterial.js +1 -1
  101. package/views/3d/webgl-engine/materials/PolygonOffset.js +2 -0
  102. package/views/3d/webgl-engine/materials/RibbonLineMaterial.js +1 -1
  103. package/views/3d/webgl-engine/materials/SlicePlaneMaterial.js +1 -1
  104. package/views/3d/webgl-engine/materials/TriangleMaterial.js +1 -1
  105. package/views/3d/webgl-engine/materials/TriangleTechniqueConfiguration.js +1 -1
  106. package/views/3d/webgl-engine/shaders/ColorMaterialTechnique.js +1 -1
  107. package/views/3d/webgl-engine/shaders/DefaultMaterialTechniqueConfiguration.js +1 -1
  108. package/views/3d/webgl-engine/shaders/Dithering.glsl.js +4 -0
  109. package/views/3d/webgl-engine/shaders/HUDMaterialTechnique.js +1 -1
  110. package/views/3d/webgl-engine/shaders/OutputColorHighlightOLID.glsl.js +11 -10
  111. package/views/3d/webgl-engine/shaders/PatternTechnique.js +1 -1
  112. package/views/3d/webgl-engine/shaders/RibbonLineTechnique.js +1 -1
  113. package/views/3d/webgl-engine/shaders/RibbonLineTechniqueConfiguration.js +1 -1
  114. package/views/3d/webgl-engine/shaders/ShadedColorMaterialTechnique.js +1 -1
  115. package/views/3d/webgl-engine/shaders/ShadedColorMaterialTechniqueConfiguration.js +1 -1
  116. package/views/SceneView.d.ts +2 -1
  117. package/views/SceneView.js +1 -1
  118. package/views/support/LayerViewManager.js +1 -1
  119. package/views/types.d.ts +33 -2
  120. package/widgets/FeatureForm/FeatureFormViewModel.js +1 -1
  121. package/assets/esri/core/workers/chunks/0601c316da0256a60538.js +0 -1
  122. package/assets/esri/core/workers/chunks/13d55e3c9aea04116eaa.js +0 -1
  123. package/assets/esri/core/workers/chunks/54c1d31e1efab765ee7a.js +0 -1
  124. package/assets/esri/core/workers/chunks/5b515b5741733bcb4645.js +0 -1
  125. package/assets/esri/core/workers/chunks/7f07f490c6fcc794c8d9.js +0 -1
  126. package/assets/esri/core/workers/chunks/abcb39ad1e2d54710766.js +0 -1
  127. package/assets/esri/core/workers/chunks/c2aa3b1344b42a904234.js +0 -1
  128. package/assets/esri/core/workers/chunks/cf5e4cf9b1aa37eeb6b0.js +0 -1
  129. package/assets/esri/core/workers/chunks/e63046a9567d84228644.js +0 -1
  130. package/assets/esri/core/workers/chunks/f4ec2dcdc4bbf7dbcc94.js +0 -1
  131. package/assets/esri/core/workers/chunks/fce8d4ff920baf8856e6.js +0 -1
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{throwIfAborted as e}from"../../../../core/promiseUtils.js";import{pt2px as t}from"../../../../core/screenUtils.js";import{identity as s,scale as r,translate as i,copy as a}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as o}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{length as n,negate as l,copy as c,multiply as h,add as d,set as m}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{fromArray as u,ONES as p,ZEROS as f,fromValues as y,create as _}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ZEROS as g,ONES as b,create as v}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{computeTranslationToOriginAndRotation as P}from"../../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{projectPointToVector as x}from"../../../../geometry/projection/projectPointToVector.js";import{create as R,size as S,containsPoint as C,center as w}from"../../../../geometry/support/aaBoundingBox.js";import{getEmissiveMode as L}from"../../../../symbols/support/materialUtils.js";import{defaultObjectPrimitive as U}from"../../../../symbols/support/primitives.js";import{objectSymbolLayerPrimitiveBoundingBox as O,objectSymbolLayerSizeWithResourceSize as j}from"../../../../symbols/support/symbolLayerUtils3D.js";import{estimateNumVerticesForLods as E,defaultSymbolLayerMemoryComplexity as T}from"./defaultSymbolComplexity.js";import{perLodInstanceElevationAligner as B}from"./ElevationAligners.js";import{needsElevationUpdates3D as G,SampleElevationInfo as V,evaluateElevationInfoAtPoint as z}from"./elevationAlignmentUtils.js";import{preparePatchEmissiveStrength as D}from"./emissiveUtils.js";import{Graphics3DLodInstanceGraphicLayer as F}from"./Graphics3DLodInstanceGraphicLayer.js";import{Graphics3DSymbolLayer as A,nanFallbackColor as I}from"./Graphics3DSymbolLayer.js";import{validateSymbolLayerSize as k,computeObjectScale as H,computeObjectRotation as M}from"./graphicUtils.js";import{makeLodResources as W}from"./lodResourceUtils.js";import{fetch as N}from"./objectResourceUtils.js";import{placePointOnGeometry as q,extendPointGraphicElevationContext as $}from"./pointUtils.js";import{isValidPrimitive as Z,primitiveLodResources as J}from"./primitiveObjectSymbolUtils.js";import{SymbolComplexity as K}from"./SymbolComplexity.js";import{getResourceUrlFromSymbolStyle as Q}from"./webStyleUtils.js";import{initFastSymbolUpdatesState as X,updateFastSymbolUpdatesState as Y,ConvertOptions as ee,evaluateModelTransformScale as te,evaluateModelTransform as se}from"../support/FastSymbolUpdates.js";import{VerticalOffsetParameters as re}from"../../webgl-engine/core/shaderLibrary/attributes/VerticalOffset.glsl.js";import{LodRenderer as ie}from"../../webgl-engine/lib/lodRendering/LodRenderer.js";import{DefaultMaterial as ae}from"../../webgl-engine/materials/DefaultMaterial.js";import{schematicMRRFactors as oe}from"../../webgl-engine/materials/pbrUtils.js";class ne{constructor(e,t,s,r,i,a,o,n,l,c,h=null){this.lodResources=e,this.lodRenderer=t,this.stageResources=s,this.resourceSize=r,this.isEsriSymbolResource=i,this.isWosr=a,this.resourceBoundingBox=o,this.symbolSize=n,this.extentPadding=l,this.physicalBasedRenderingEnabled=c,this.pivotOffset=h}}class le extends A{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,de(t)),this._resources=null,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){const e=k(this.symbolLayer);if(e)throw new Error(e)}if(this._isPrimitive){const t=this.symbolLayer.resource,s=t&&Z(t?.primitive)?t.primitive:U;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.updateComplexity()}get extentPadding(){return null!=this._resources?this._resources.extentPadding:0}get _isPrimitive(){return null!=this._primitive}get lodRenderer(){return this._resources?.lodRenderer}get materials(){return this._resources?.stageResources.materials??[]}async _createResourcesForPrimitive(e,t){const s=this.symbolLayer,r=R(O(e)),i=u(S(r)),a=u(j(i,s)),o=n(a),l=!1,c=!1,h=s.material?.emissive,d=("color"===h?.source?h?.strength:void 0)??0,m={usePBR:this._context.physicalBasedRenderingEnabled,isSchematic:!0,mrrFactors:oe,ambient:p,diffuse:p,opacity:1,hasSlicePlane:this._context.slicePlaneEnabled,castShadows:s.castShadows,emissiveStrengthFromSymbol:d,emissiveSource:1,offsetTransparentBackfaces:!1,drivenOpacity:this.needsDrivenTransparentPass},f=!!m.usePBR,y=this.symbol;"point-3d"===y.type&&y.verticalOffset&&(m.verticalOffset=new re(y.verticalOffset),m.castShadows=!1),this._context.screenSizePerspectiveEnabled&&(m.screenSizePerspective=this.view.screenSizePerspective.parameters),this._hasDrivenColorOrOpacity?m.externalColor=I:m.externalColor=this._materialColor?.toUnitRGBA()??g,this._fastUpdates=X(this._context.renderer,this._fastVisualVariableConvertOptions(r,a,i,null)),m.instanced=!0,this._fastUpdates?(Object.assign(m,this._fastUpdates.materialParameters),m.instancedFeatureAttribute=!0):this._hasDrivenColorOrOpacity&&(m.instancedColor=!0);const _=new ae(m,this._context);_.setParameters({cullFace:me(_.transparent)});const b=J(e,_);if(!b)throw new Error(`Unknown object symbol primitive: ${e}`);const v=await this._createStageResources(b,f,t),P=await this._createLodRenderer(b,t);return new ne(b,P,v,i,l,c,r,a,o,f)}async _createResourcesForUrl(e,s){const r={instanced:!0,hasSlicePlane:this._context.slicePlaneEnabled,castShadows:this.symbolLayer.castShadows},i={spherical:this._context.spherical,materialParameters:r,cache:this._context.sharedResources.objectResourceCache,compressionOptions:{compressionTracker:this._context.compressionTracker,compressionCallback:()=>this.updateComplexity()}};this._fastUpdates=X(this._context.renderer,this._fastVisualVariableConvertOptions(null,null,null,null)),this._fastUpdates?(Object.assign(i.materialParameters,this._fastUpdates.materialParameters),i.materialParameters.instancedFeatureAttribute=!0):this._hasDrivenColorOrOpacity&&(i.materialParameters.instancedColor=!0);const a=this.symbol;if("point-3d"===a.type&&a.verticalOffset){const{screenLength:e,minWorldLength:s,maxWorldLength:r}=a.verticalOffset;i.materialParameters.verticalOffset={screenLength:t(e),minWorldLength:s||0,maxWorldLength:null!=r?r:1/0},i.materialParameters.castShadows=!1}const o=this._context.physicalBasedRenderingEnabled;i.signal=s,i.usePBR=o,i.useEmissive=this.view.stage.renderView.renderingContext.driverTest.floatBufferBlend.result,i.skipHighLods=this._context.skipHighSymbolLods;const l=this.symbolLayer.material;i.materialParameters.emissiveStrengthFromSymbol=l?.emissive?.strength??1,i.materialParameters.emissiveSource=L(l?.emissive?.source??"emissive");const c=await N(e,i),h=c.isEsriSymbolResource,d=c.isWosr,m=W(c.lods),p=this._context,f=this._getExternalColorParameters(l),y=this.needsDrivenTransparentPass,_=m.getMaterials();_.forEach(e=>{e.setParameters({...f,drivenOpacity:y}),p.screenSizePerspectiveEnabled&&e.setParameters({screenSizePerspective:this.view.screenSizePerspective.parameters})});const g=c.referenceBoundingBox,b=u(S(g)),v=u(m.levels[0].pivotOffset),P=u(j(b,this.symbolLayer)),x=n(P),R=this._fastUpdates;Y(R,this._context.renderer,this._fastVisualVariableConvertOptions(g,P,b,v))&&_.forEach(e=>e.setParameters(R.materialParameters));const C=await this._createStageResources(m,o,s),w=await this._createLodRenderer(m,s);return new ne(m,w,C,b,h,d,g,P,x,o,v)}_addDisposeResource(e){this._disposeResourceHandles.push(e)}async _createStageResources(t,s,r){const i=this._context.stage,a=t.getMaterials();s!==this._context.physicalBasedRenderingEnabled&&this.physicalBasedRenderingChanged();const o=t.getTextures();i.addTextures(o),this._addDisposeResource(()=>{o.forEach(e=>e.unload()),i.removeTextures(o)}),await Promise.all(o.map(e=>this._context.stage.schedule(()=>e.load(i.renderView.renderingContext),r))),e(r);const n=t.getEngineGeometries();return{materials:a,textures:o,geometries:n}}async _createLodRenderer(e,t){const s=this._context.stage,r={layerViewUid:this._context.layerViewUid,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,o=new ie({symbol:e,metadata:r,shaderTransformation:i?{applyTransform:(e,t,s)=>{e.getFeatureAttribute(t,ye),a(s,se(i.materialParameters,ye,s))},scaleFactor:(e,t,s)=>{t.getFeatureAttribute(s,ye),te(e,i.materialParameters,ye)}}:null},this._context.scheduler);return o.slicePlaneEnabled=this._context.slicePlaneEnabled,this._addDisposeResource(()=>{s.removeRenderPlugin(o),o.destroy()}),await s.addRenderPlugin(o,t),o}_getExternalColorParameters(e){const t={};if(t.externalColor=I,!this._drivenProperties.color&&null!=e?.color){const s=e.color.toUnitRGBA();this._drivenProperties.opacity&&(s[3]=NaN),t.externalColor=s}return t}destroy(){super.destroy(),this._cleanupResources()}_cleanupResources(){this._disposeResourceHandles.forEach(e=>e()),this._disposeResourceHandles.length=0,this._resources=null}createGraphics3DGraphic(e){const t=e.graphic;if(!this._validateGeometry(t.geometry))return null;const s=q(t.geometry);if(null==s)return this.logger.warn(`unsupported geometry type for object symbol: ${t.geometry.type}`),null;const r=this.createElevationContextForGraphic(t),i=e.renderingInfo;return this._createAs3DShape(s,i,r,t.uid)}notifyDestroyGraphicLayer(e){this._instanceIndexToGraphicUid.delete(e.instanceIndex)}graphicLayerToGraphicId(){return 0}layerOpacityChanged(){if(null==this._resources)return;const e=this._getLayerOpacity(),t=this._resources.stageResources.materials;for(let s=0;s<t.length;s++){const r=t[s];r.setParameters({layerOpacity:e}),this._isPrimitive&&r.setParameters({cullFace:me(r.transparent)})}}layerScreenSizePerspectiveChanged(){if(null==this._resources)return;const e=this._context.screenSizePerspectiveEnabled?this.view.screenSizePerspective.parameters:null;for(const t of this._resources.stageResources.materials)t.setParameters({screenSizePerspective:e})}layerElevationInfoChanged(e,t){return this.updateGraphics3DGraphicElevationInfo(e,t,G)}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 0;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 0;if(!Y(this._fastUpdates,t,this._fastVisualVariableConvertOptions(i,a,o,n)))return 0;for(const e of s)e.setParameters(this._fastUpdates.materialParameters);r.notifyShaderTransformationChanged()}return 2}computeComplexity(){if(null==this._resources)return super.computeComplexity();const e=this._resources.lodResources,t=E(e.levels),s=e.computeUsedMemory(),r={...T(this.symbol,this.symbolLayer),resourceBytes:s};return new K({verticesPerFeature:t,memory:r})}_hasLodRenderer(){return null!=this._resources}_createAs3DShape(e,t,s,r){if(!this._hasLodRenderer()||null==this._resources)return null;const i=this.getFastUpdateAttrValues(t),a=this._context.clippingExtent;if(x(e,ue,this._context.elevationProvider.spatialReference),null!=a&&!C(a,ue))return null;const o=he(s),n=this._computeGlobalTransform(e,s,fe,_e),l=this._computeLocalTransform(this._resources,this.symbolLayer,t,pe),c=this._resources.lodRenderer.instanceData,h=c.addInstance();this._instanceIndexToGraphicUid.set(h,r),c.setLocalTransform(h,l,!1),c.setGlobalTransform(h,n),i&&c.setFeatureAttribute(h,i),null==this._fastUpdates&&this._hasDrivenColorOrOpacity&&c.setColor(h,this._getDrivenUInt8ColorWithNaNSupport(t,this._materialColor,!this._isPrimitive));const d=this._context.stage.renderView.olidRenderHelper;if(d){const e=d.getObjectAndLayerIdColor({graphicUid:r,layerViewUid:this._context.layerViewUid});c.setObjectAndLayerIdColor(h,e)}const m=new F(this,h,B,s,this._context.stage.view.state.highlightOrderMap);return o&&(m.alignedSampledElevation=_e.sampledElevation),m.needsElevationUpdates=G(s.mode),$(m,e,this._context.elevationProvider),m}_computeGlobalTransform(e,t,s,r){return z(e,this._context.elevationProvider,t,this._context.renderCoordsHelper,r),ue[0]=e.x,ue[1]=e.y,ue[2]=r.z,P(e.spatialReference,ue,s,this._context.renderCoordsHelper.spatialReference),s}_computeLocalTransform(e,t,r,i){return s(i),this._applyObjectRotationVisualVariables(r,!1,i),this._applyObjectRotation(t,!0,i),this._applyObjectScale(e,r,i),this._applyAnchor(e,t,i),i}_applyObjectScale(e,t,s){if(this._fastUpdates?.requiresShaderTransformation)return;const i=this._drivenProperties.size&&t.size?t.size.output:e.symbolSize,a=H(i,e.symbolSize,e.resourceSize,this._context.renderCoordsHelper.unitInMeters);1===a[0]&&1===a[1]&&1===a[2]||r(s,s,a)}prepareSymbolLayerPatch(e){if("partial"!==e.diff.type)return;const t=e.diff.diff;this._preparePatchTransform(e,t),this._preparePatchColor(e,t),this._preparePatchEmissive(e,t)}updateGeometry(e,t){if(null==this._resources)return!0;const s=e.geometry;if(!s)return!1;const r=q(s);if(null==r)return!1;const i=this.getGeometryElevationMode(s),{elevationContext:a}=t;return a.mode===i&&(a.updateFeatureExpressionFeature(e,this._context.layer),this._computeGlobalTransform(r,a,fe,_e),he(a)&&(t.alignedSampledElevation=_e.sampledElevation),this._resources.lodRenderer.instanceData.setGlobalTransform(t.instanceIndex,fe,!0),$(t,r,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;1===this.loadStatus&&e.symbolLayerStatePatches.push(()=>{m.symbolSize=u(j(m.resourceSize,{width:o,height:n,depth:l,isPrimitive:this._isPrimitive}))}),e.graphics3DGraphicPatches.push(({instanceIndex:e},t)=>{const s=this._computeLocalTransform(m,d,t,pe);m.lodRenderer.instanceData.setLocalTransform(e,s,!0)})}_preparePatchColor(e,t){if(!t.material||"partial"!==t.material.type)return;const s=t.material.diff;if(!s.color||"complete"!==s.color.type||null==s.color.newValue||null==s.color.oldValue)return;const r=s.color.newValue,i=null!=r?r.toUnitRGBA():b;delete s.color;const a=this._resources;if(null==a)return;const o=this._isPrimitive;e.graphics3DGraphicPatches.push(({instanceIndex:e})=>{if(this._hasDrivenColorOrOpacity)a.lodRenderer.instanceData.setColor(e,i);else{const e={externalColor:i};for(const t of a.stageResources.materials)t.setParameters(e),o&&t.setParameters({cullFace:me(t.transparent)})}})}_preparePatchEmissive(e,t){return D(e,t,e=>{this._resources?.stageResources.materials.forEach(t=>{if(!this._isPrimitive)return void t.setParameters({emissiveStrengthFromSymbol:e??1});const s=this.symbolLayer.material?.emissive,r="color"===s?.source;t.setParameters({emissiveStrengthFromSymbol:r?e??0:0})})},this.view.stage.renderView.renderingContext.driverTest.floatBufferBlend.result)}_applyObjectRotationVisualVariables(e,t,s){this._fastUpdates?.requiresShaderTransformation&&t||M(e.heading?.output,e.tilt?.output,e.roll?.output,s)}_applyObjectRotation(e,t,s){this._fastUpdates?.requiresShaderTransformation&&t||M(e.heading,e.tilt,e.roll,s)}_applyAnchor(e,t,s){if(this._fastUpdates?.requiresShaderTransformation)return;const r=ce(e.resourceBoundingBox,e.pivotOffset,t);r&&i(s,s,r)}_fastVisualVariableConvertOptions(e,t,s,r){const i=null!=e?u(S(e)):p,a=null!=e?ce(e,r,this.symbolLayer):f,o=this._context.renderCoordsHelper.unitInMeters,n=H(null!=t?t:void 0,t,s,o),l=y(this.symbolLayer.tilt||0,this.symbolLayer.roll||0,this.symbolLayer.heading||0);return new ee({supports:{size:!0,color:!0,rotation:!0,opacity:!1},modelSize:i,symbolSize:t??p,unitInMeters:o,anchor:a,scale:n,rotation:l,fallbackColor:this._getFallbackOpacityAndColor(),fallbackSize:n})}get _primitive(){const{resource:e}=this.symbolLayer;return null!=e?.href?null:e?.primitive??U}_getFallbackOpacityAndColor(){return this._materialColor?.toUnitRGBA()??(this._isPrimitive?g:I)}get _materialColor(){return this.symbolLayer.material?.color}}function ce(e,t,s){const r=_();switch(s.anchor){case"center":c(r,w(e)),l(r,r);break;case"top":{const t=w(e);m(r,-t[0],-t[1],-e[5]);break}case"bottom":{const t=w(e);m(r,-t[0],-t[1],-e[2]);break}case"relative":{const t=w(e),i=S(e),a=s.anchorPosition,o=a?y(a.x,a.y,a.z):f;h(r,i,o),d(r,r,t),l(r,r);break}default:null!=t?l(r,t):c(r,f)}return r}function he(e){return"absolute-height"!==e.mode}function de(e){return 1===(e.material?.color?.a??0)&&null==e.resource?.href}function me(e){return e?0:2}const ue=_(),pe=o(),fe=o(),ye=v(),_e=new V;export{le as Graphics3DObjectSymbolLayer};
2
+ import{throwIfAborted as e}from"../../../../core/promiseUtils.js";import{pt2px as t}from"../../../../core/screenUtils.js";import{identity as s,scale as r,translate as i,copy as a}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as o}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{length as n,negate as l,copy as c,multiply as h,add as d,set as m}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{fromArray as u,ONES as p,ZEROS as f,fromValues as y,create as _}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ZEROS as g,ONES as b,create as v}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{computeTranslationToOriginAndRotation as P}from"../../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{projectPointToVector as x}from"../../../../geometry/projection/projectPointToVector.js";import{create as R,size as S,containsPoint as C,center as w}from"../../../../geometry/support/aaBoundingBox.js";import{getEmissiveMode as L}from"../../../../symbols/support/materialUtils.js";import{defaultObjectPrimitive as U}from"../../../../symbols/support/primitives.js";import{objectSymbolLayerPrimitiveBoundingBox as O,objectSymbolLayerSizeWithResourceSize as j}from"../../../../symbols/support/symbolLayerUtils3D.js";import{estimateNumVerticesForLods as E,defaultSymbolLayerMemoryComplexity as T}from"./defaultSymbolComplexity.js";import{perLodInstanceElevationAligner as B}from"./ElevationAligners.js";import{needsElevationUpdates3D as G,SampleElevationInfo as V,evaluateElevationInfoAtPoint as z}from"./elevationAlignmentUtils.js";import{preparePatchEmissiveStrength as D}from"./emissiveUtils.js";import{Graphics3DLodInstanceGraphicLayer as F}from"./Graphics3DLodInstanceGraphicLayer.js";import{Graphics3DSymbolLayer as A,nanFallbackColor as I}from"./Graphics3DSymbolLayer.js";import{validateSymbolLayerSize as k,computeObjectScale as H,computeObjectRotation as M}from"./graphicUtils.js";import{makeLodResources as W}from"./lodResourceUtils.js";import{fetch as N}from"./objectResourceUtils.js";import{placePointOnGeometry as q,extendPointGraphicElevationContext as $}from"./pointUtils.js";import{isValidPrimitive as Z,primitiveLodResources as J}from"./primitiveObjectSymbolUtils.js";import{SymbolComplexity as K}from"./SymbolComplexity.js";import{getResourceUrlFromSymbolStyle as Q}from"./webStyleUtils.js";import{initFastSymbolUpdatesState as X,updateFastSymbolUpdatesState as Y,ConvertOptions as ee,evaluateModelTransformScale as te,evaluateModelTransform as se}from"../support/FastSymbolUpdates.js";import{VerticalOffsetParameters as re}from"../../webgl-engine/core/shaderLibrary/attributes/VerticalOffset.glsl.js";import{LodRenderer as ie}from"../../webgl-engine/lib/lodRendering/LodRenderer.js";import{DefaultMaterial as ae}from"../../webgl-engine/materials/DefaultMaterial.js";import{schematicMRRFactors as oe}from"../../webgl-engine/materials/pbrUtils.js";class ne{constructor(e,t,s,r,i,a,o,n,l,c,h=null){this.lodResources=e,this.lodRenderer=t,this.stageResources=s,this.resourceSize=r,this.isEsriSymbolResource=i,this.isWosr=a,this.resourceBoundingBox=o,this.symbolSize=n,this.extentPadding=l,this.physicalBasedRenderingEnabled=c,this.pivotOffset=h}}class le extends A{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,de(t)),this._resources=null,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){const e=k(this.symbolLayer);if(e)throw new Error(e)}if(this._isPrimitive){const t=this.symbolLayer.resource,s=t&&Z(t?.primitive)?t.primitive:U;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.updateComplexity()}get extentPadding(){return null!=this._resources?this._resources.extentPadding:0}get _isPrimitive(){return null!=this._primitive}get lodRenderer(){return this._resources?.lodRenderer}get materials(){return this._resources?.stageResources.materials??[]}async _createResourcesForPrimitive(t,s){const r=this.symbolLayer,i=R(O(t)),a=u(S(i)),o=u(j(a,r)),l=n(o),c=!1,h=!1,d=r.material?.emissive,m=("color"===d?.source?d?.strength:void 0)??0,f={usePBR:this._context.physicalBasedRenderingEnabled,isSchematic:!0,mrrFactors:oe,ambient:p,diffuse:p,opacity:1,hasSlicePlane:this._context.slicePlaneEnabled,castShadows:r.castShadows,emissiveStrengthFromSymbol:m,emissiveSource:1,offsetTransparentBackfaces:!1,drivenOpacity:this.needsDrivenTransparentPass},y=!!f.usePBR,_=this.symbol;"point-3d"===_.type&&_.verticalOffset&&(f.verticalOffset=new re(_.verticalOffset),f.castShadows=!1),this._context.screenSizePerspectiveEnabled&&(f.screenSizePerspective=this.view.screenSizePerspective.parameters),this._hasDrivenColorOrOpacity?f.externalColor=I:f.externalColor=this._materialColor?.toUnitRGBA()??g,this._fastUpdates=X(this._context.renderer,this._fastVisualVariableConvertOptions(i,o,a,null)),f.instanced=!0,this._fastUpdates?(Object.assign(f,this._fastUpdates.materialParameters),f.instancedFeatureAttribute=!0):this._hasDrivenColorOrOpacity&&(f.instancedColor=!0);const b=new ae(f,this._context);b.setParameters({cullFace:me(b.transparent)});const v=J(t,b);if(!v)throw new Error(`Unknown object symbol primitive: ${t}`);const P=await this._createStageResources(v,y,s);e(s);const x=await this._createLodRenderer(v,s);return new ne(v,x,P,a,c,h,i,o,l,y)}async _createResourcesForUrl(s,r){const i={instanced:!0,hasSlicePlane:this._context.slicePlaneEnabled,castShadows:this.symbolLayer.castShadows},a={spherical:this._context.spherical,materialParameters:i,cache:this._context.sharedResources.objectResourceCache,compressionOptions:{compressionTracker:this._context.compressionTracker,compressionCallback:()=>this.updateComplexity()}};this._fastUpdates=X(this._context.renderer,this._fastVisualVariableConvertOptions(null,null,null,null)),this._fastUpdates?(Object.assign(a.materialParameters,this._fastUpdates.materialParameters),a.materialParameters.instancedFeatureAttribute=!0):this._hasDrivenColorOrOpacity&&(a.materialParameters.instancedColor=!0);const o=this.symbol;if("point-3d"===o.type&&o.verticalOffset){const{screenLength:e,minWorldLength:s,maxWorldLength:r}=o.verticalOffset;a.materialParameters.verticalOffset={screenLength:t(e),minWorldLength:s||0,maxWorldLength:null!=r?r:1/0},a.materialParameters.castShadows=!1}const l=this._context.physicalBasedRenderingEnabled;a.signal=r,a.usePBR=l,a.useEmissive=this.view.stage.renderView.renderingContext.driverTest.floatBufferBlend.result,a.skipHighLods=this._context.skipHighSymbolLods;const c=this.symbolLayer.material;a.materialParameters.emissiveStrengthFromSymbol=c?.emissive?.strength??1,a.materialParameters.emissiveSource=L(c?.emissive?.source??"emissive");const h=await N(s,a),d=h.isEsriSymbolResource,m=h.isWosr,p=W(h.lods),f=this._context,y=this._getExternalColorParameters(c),_=this.needsDrivenTransparentPass,g=p.getMaterials();g.forEach(e=>{e.setParameters({...y,drivenOpacity:_}),f.screenSizePerspectiveEnabled&&e.setParameters({screenSizePerspective:this.view.screenSizePerspective.parameters})});const b=h.referenceBoundingBox,v=u(S(b)),P=u(p.levels[0].pivotOffset),x=u(j(v,this.symbolLayer)),R=n(x),C=this._fastUpdates;Y(C,this._context.renderer,this._fastVisualVariableConvertOptions(b,x,v,P))&&g.forEach(e=>e.setParameters(C.materialParameters));const w=await this._createStageResources(p,l,r);e(r);const U=await this._createLodRenderer(p,r);return new ne(p,U,w,v,d,m,b,x,R,l,P)}_addDisposeResource(e){this._disposeResourceHandles.push(e)}async _createStageResources(t,s,r){const i=this._context.stage,a=t.getMaterials();s!==this._context.physicalBasedRenderingEnabled&&this.physicalBasedRenderingChanged();const o=t.getTextures();i.addTextures(o),this._addDisposeResource(()=>{o.forEach(e=>e.unload()),i.removeTextures(o)}),await Promise.all(o.map(e=>this._context.stage.schedule(()=>e.load(i.renderView.renderingContext),r))),e(r);const n=t.getEngineGeometries();return{materials:a,textures:o,geometries:n}}async _createLodRenderer(e,t){const s=this._context.stage,r={layerViewUid:this._context.layerViewUid,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,o=new ie({symbol:e,metadata:r,shaderTransformation:i?{applyTransform:(e,t,s)=>{e.getFeatureAttribute(t,ye),a(s,se(i.materialParameters,ye,s))},scaleFactor:(e,t,s)=>{t.getFeatureAttribute(s,ye),te(e,i.materialParameters,ye)}}:null},this._context.scheduler);return o.slicePlaneEnabled=this._context.slicePlaneEnabled,this._addDisposeResource(()=>{s.removeRenderPlugin(o),o.destroy()}),await s.addRenderPlugin(o,t),o}_getExternalColorParameters(e){const t={};if(t.externalColor=I,!this._drivenProperties.color&&null!=e?.color){const s=e.color.toUnitRGBA();this._drivenProperties.opacity&&(s[3]=NaN),t.externalColor=s}return t}destroy(){super.destroy(),this._cleanupResources()}_cleanupResources(){this._disposeResourceHandles.forEach(e=>e()),this._disposeResourceHandles.length=0,this._resources=null}createGraphics3DGraphic(e){const t=e.graphic;if(!this._validateGeometry(t.geometry))return null;const s=q(t.geometry);if(null==s)return this.logger.warn(`unsupported geometry type for object symbol: ${t.geometry.type}`),null;const r=this.createElevationContextForGraphic(t),i=e.renderingInfo;return this._createAs3DShape(s,i,r,t.uid)}notifyDestroyGraphicLayer(e){this._instanceIndexToGraphicUid.delete(e.instanceIndex)}graphicLayerToGraphicId(){return 0}layerOpacityChanged(){if(null==this._resources)return;const e=this._getLayerOpacity(),t=this._resources.stageResources.materials;for(let s=0;s<t.length;s++){const r=t[s];r.setParameters({layerOpacity:e}),this._isPrimitive&&r.setParameters({cullFace:me(r.transparent)})}}layerScreenSizePerspectiveChanged(){if(null==this._resources)return;const e=this._context.screenSizePerspectiveEnabled?this.view.screenSizePerspective.parameters:null;for(const t of this._resources.stageResources.materials)t.setParameters({screenSizePerspective:e})}layerElevationInfoChanged(e,t){return this.updateGraphics3DGraphicElevationInfo(e,t,G)}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 0;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 0;if(!Y(this._fastUpdates,t,this._fastVisualVariableConvertOptions(i,a,o,n)))return 0;for(const e of s)e.setParameters(this._fastUpdates.materialParameters);r.notifyShaderTransformationChanged()}return 2}computeComplexity(){if(null==this._resources)return super.computeComplexity();const e=this._resources.lodResources,t=E(e.levels),s=e.computeUsedMemory(),r={...T(this.symbol,this.symbolLayer),resourceBytes:s};return new K({verticesPerFeature:t,memory:r})}_hasLodRenderer(){return null!=this._resources}_createAs3DShape(e,t,s,r){if(!this._hasLodRenderer()||null==this._resources)return null;const i=this.getFastUpdateAttrValues(t),a=this._context.clippingExtent;if(x(e,ue,this._context.elevationProvider.spatialReference),null!=a&&!C(a,ue))return null;const o=he(s),n=this._computeGlobalTransform(e,s,fe,_e),l=this._computeLocalTransform(this._resources,this.symbolLayer,t,pe),c=this._resources.lodRenderer.instanceData,h=c.addInstance();this._instanceIndexToGraphicUid.set(h,r),c.setLocalTransform(h,l,!1),c.setGlobalTransform(h,n),i&&c.setFeatureAttribute(h,i),null==this._fastUpdates&&this._hasDrivenColorOrOpacity&&c.setColor(h,this._getDrivenUInt8ColorWithNaNSupport(t,this._materialColor,!this._isPrimitive));const d=this._context.stage.renderView.olidRenderHelper;if(d){const e=d.getObjectAndLayerIdColor({graphicUid:r,layerViewUid:this._context.layerViewUid});c.setObjectAndLayerIdColor(h,e)}const m=new F(this,h,B,s,this._context.stage.view.state.highlightOrderMap);return o&&(m.alignedSampledElevation=_e.sampledElevation),m.needsElevationUpdates=G(s.mode),$(m,e,this._context.elevationProvider),m}_computeGlobalTransform(e,t,s,r){return z(e,this._context.elevationProvider,t,this._context.renderCoordsHelper,r),ue[0]=e.x,ue[1]=e.y,ue[2]=r.z,P(e.spatialReference,ue,s,this._context.renderCoordsHelper.spatialReference),s}_computeLocalTransform(e,t,r,i){return s(i),this._applyObjectRotationVisualVariables(r,!1,i),this._applyObjectRotation(t,!0,i),this._applyObjectScale(e,r,i),this._applyAnchor(e,t,i),i}_applyObjectScale(e,t,s){if(this._fastUpdates?.requiresShaderTransformation)return;const i=this._drivenProperties.size&&t.size?t.size.output:e.symbolSize,a=H(i,e.symbolSize,e.resourceSize,this._context.renderCoordsHelper.unitInMeters);1===a[0]&&1===a[1]&&1===a[2]||r(s,s,a)}prepareSymbolLayerPatch(e){if("partial"!==e.diff.type)return;const t=e.diff.diff;this._preparePatchTransform(e,t),this._preparePatchColor(e,t),this._preparePatchEmissive(e,t)}updateGeometry(e,t){if(null==this._resources)return!0;const s=e.geometry;if(!s)return!1;const r=q(s);if(null==r)return!1;const i=this.getGeometryElevationMode(s),{elevationContext:a}=t;return a.mode===i&&(a.updateFeatureExpressionFeature(e,this._context.layer),this._computeGlobalTransform(r,a,fe,_e),he(a)&&(t.alignedSampledElevation=_e.sampledElevation),this._resources.lodRenderer.instanceData.setGlobalTransform(t.instanceIndex,fe,!0),$(t,r,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;1===this.loadStatus&&e.symbolLayerStatePatches.push(()=>{m.symbolSize=u(j(m.resourceSize,{width:o,height:n,depth:l,isPrimitive:this._isPrimitive}))}),e.graphics3DGraphicPatches.push(({instanceIndex:e},t)=>{const s=this._computeLocalTransform(m,d,t,pe);m.lodRenderer.instanceData.setLocalTransform(e,s,!0)})}_preparePatchColor(e,t){if(!t.material||"partial"!==t.material.type)return;const s=t.material.diff;if(!s.color||"complete"!==s.color.type||null==s.color.newValue||null==s.color.oldValue)return;const r=s.color.newValue,i=null!=r?r.toUnitRGBA():b;delete s.color;const a=this._resources;if(null==a)return;const o=this._isPrimitive;e.graphics3DGraphicPatches.push(({instanceIndex:e})=>{if(this._hasDrivenColorOrOpacity)a.lodRenderer.instanceData.setColor(e,i);else{const e={externalColor:i};for(const t of a.stageResources.materials)t.setParameters(e),o&&t.setParameters({cullFace:me(t.transparent)})}})}_preparePatchEmissive(e,t){return D(e,t,e=>{this._resources?.stageResources.materials.forEach(t=>{if(!this._isPrimitive)return void t.setParameters({emissiveStrengthFromSymbol:e??1});const s=this.symbolLayer.material?.emissive,r="color"===s?.source;t.setParameters({emissiveStrengthFromSymbol:r?e??0:0})})},this.view.stage.renderView.renderingContext.driverTest.floatBufferBlend.result)}_applyObjectRotationVisualVariables(e,t,s){this._fastUpdates?.requiresShaderTransformation&&t||M(e.heading?.output,e.tilt?.output,e.roll?.output,s)}_applyObjectRotation(e,t,s){this._fastUpdates?.requiresShaderTransformation&&t||M(e.heading,e.tilt,e.roll,s)}_applyAnchor(e,t,s){if(this._fastUpdates?.requiresShaderTransformation)return;const r=ce(e.resourceBoundingBox,e.pivotOffset,t);r&&i(s,s,r)}_fastVisualVariableConvertOptions(e,t,s,r){const i=null!=e?u(S(e)):p,a=null!=e?ce(e,r,this.symbolLayer):f,o=this._context.renderCoordsHelper.unitInMeters,n=H(null!=t?t:void 0,t,s,o),l=y(this.symbolLayer.tilt||0,this.symbolLayer.roll||0,this.symbolLayer.heading||0);return new ee({supports:{size:!0,color:!0,rotation:!0,opacity:!1},modelSize:i,symbolSize:t??p,unitInMeters:o,anchor:a,scale:n,rotation:l,fallbackColor:this._getFallbackOpacityAndColor(),fallbackSize:n})}get _primitive(){const{resource:e}=this.symbolLayer;return null!=e?.href?null:e?.primitive??U}_getFallbackOpacityAndColor(){return this._materialColor?.toUnitRGBA()??(this._isPrimitive?g:I)}get _materialColor(){return this.symbolLayer.material?.color}}function ce(e,t,s){const r=_();switch(s.anchor){case"center":c(r,w(e)),l(r,r);break;case"top":{const t=w(e);m(r,-t[0],-t[1],-e[5]);break}case"bottom":{const t=w(e);m(r,-t[0],-t[1],-e[2]);break}case"relative":{const t=w(e),i=S(e),a=s.anchorPosition,o=a?y(a.x,a.y,a.z):f;h(r,i,o),d(r,r,t),l(r,r);break}default:null!=t?l(r,t):c(r,f)}return r}function he(e){return"absolute-height"!==e.mode}function de(e){return 1===(e.material?.color?.a??0)&&null==e.resource?.href}function me(e){return e?0:2}const ue=_(),pe=o(),fe=o(),ye=v(),_e=new V;export{le as Graphics3DObjectSymbolLayer};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import has from"../../../../core/has.js";import{pt2px as e}from"../../../../core/screenUtils.js";import{e as t}from"../../../../chunks/earcut.js";import{ZEROS as r}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{fromBuffer as i,intersectsClippingArea as s,empty as o,expandWithAABB as n,create as a}from"../../../../geometry/support/aaBoundingBox.js";import{newDoubleArray as l}from"../../../../geometry/support/DoubleArray.js";import{newFloatArray as c,floatSubArray as p}from"../../../../geometry/support/FloatArray.js";import{elevationModeChangeUpdateType as h,needsElevationUpdates2D as u}from"./elevationAlignmentUtils.js";import{Graphics3DDrapedGraphicLayer as m}from"./Graphics3DDrapedGraphicLayer.js";import{Graphics3DObject3DGraphicLayer as d}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as _}from"./Graphics3DSymbolLayer.js";import{mixinColorAndOpacity as g}from"./graphicUtils.js";import{parseCapType as y}from"./lineUtils.js";import{geometryAsPolygon as f,createIndices3D as v,createColorGeometry as b,PolygonCreationDataBase as S}from"./polygonUtils.js";import{initFastSymbolUpdatesState as x,updateFastSymbolUpdatesState as C,getAttributeValue as P,ConvertOptions as D}from"../support/FastSymbolUpdates.js";import{createMaterial as O,uvElevationAligner as U}from"../support/patternUtils.js";import{createMapSpaceUVCoords as j,createMapSpaceUVCoordsDraped as w}from"../support/uvUtils.js";import{createGeometry as G}from"../../support/engineContent/line.js";import{polygonToRenderInfo as A,polygonToRenderInfoDraped as E}from"../../support/renderInfoUtils/polygon.js";import{Object3D as L}from"../../webgl-engine/lib/Object3D.js";import{RenderGeometry as M}from"../../webgl-engine/lib/RenderGeometry.js";import{isScreenSizePerspectiveEnabled as V}from"../../webgl-engine/lib/screenSizePerspectiveUtils.js";import{getStipplePatternForLinePattern as R}from"../../webgl-engine/materials/lineStippleUtils.js";import{PatternMaterial as I}from"../../webgl-engine/materials/PatternMaterial.js";import{RibbonLineMaterial as z}from"../../webgl-engine/materials/RibbonLineMaterial.js";const B=["polyline","polygon","extent"];class F extends _{static{this.elevationModeChangeTypes={definedChanged:2,staysOnTheGround:0,onTheGroundChanged:2}}constructor(e,t,r,i){super(e,t,r,i,q(t)),this._needsUV=!1,this._materials=[]}async doLoad(){this._fastUpdates=x(this._context.renderer,this._vvConvertOptions)}get _materialColor(){return this.symbolLayer.material?.color}get _emissiveStrength(){if(has("enable-feature:emissive-on-none-volumetrics")){const e=this.symbolLayer.material?.emissive;return("color"===e?.source?e?.strength:void 0)??0}return 0}_createMaterials(){if(this._materials.length>0)return;const t=this._materialColor,r=this._getCombinedOpacityAndColor(t);this._materials[0]=O(this.symbolLayer,{color:r,forceTransparentMode:this.needsDrivenTransparentPass,discardInvisibleFragments:!0,polygonOffset:!1,hasVertexColors:this._drivenProperties.color||this._drivenProperties.opacity,draped:this.draped,hasSlicePlane:this._context.slicePlaneEnabled,emissiveStrength:this._emissiveStrength,...this._fastUpdates?.materialParameters}),this._needsUV=this._materials[0]instanceof I;const i=this.symbolLayer.outline;if(W(i)){const t=R(i.pattern);this._materials[1]=new z({width:e(i.size),color:this._getOutlineColor(),hasPolygonOffset:!0,hasSlicePlane:this._context.slicePlaneEnabled,isClosed:!0,stipplePattern:t,cap:y(i.patternCap||"butt"),screenSizePerspective:this._outlineScreenSizePerspective},this.view.state.isGlobal)}}get _outlineScreenSizePerspective(){return!this.draped&&V(this._context.layer.screenSizePerspectiveEnabled)?this.view.screenSizePerspective.parameters:null}createGraphics3DGraphic(e){const t=e.graphic;if(!this._validateGeometry(t.geometry,B,this.symbolLayer.type))return null;const r=this._getDrivenUInt8Color(e.renderingInfo,this._materialColor,!1),i=this.createElevationContextForGraphic(t);return this.ensureDrapedStatus("on-the-ground"===i.mode),this._createMaterials(),this.draped?this._createAsOverlay(e.renderingInfo,t,r):this._createAs3DShape(e.renderingInfo,t,r,i)}applyRendererDiff(e,t){for(const r in e.diff){if("visualVariables"!==r)return 0;if(!C(this._fastUpdates,t,this._vvConvertOptions))return 0;this._materials[0]?.setParameters(this._fastUpdates.materialParameters)}return 2}layerOpacityChanged(){if(null!=this._materials[0]){const e=this._materials[0].parameters.color,t=this._materialColor,r=this._getCombinedOpacity(t);this._materials[0].setParameters({color:[e[0],e[1],e[2],r],forceTransparentMode:this.needsDrivenTransparentPass})}if(null!=this._materials[1]){const e=this._materials[1].parameters.color;this._materials[1].setParameters({color:[e[0],e[1],e[2],this._getOutlineOpacity()]})}}layerScreenSizePerspectiveChanged(){this._materials[1]?.setParameters({screenSizePerspective:this._outlineScreenSizePerspective})}layerElevationInfoChanged(e,t,r){const i=this._elevationContext.mode,s=h(F.elevationModeChangeTypes,r,i);if(1!==s)return s;const o=u(i);return this.updateGraphics3DGraphicElevationInfo(e,t,()=>o)}slicePlaneEnabledChanged(){if(this._materials[0]?.setParameters({hasSlicePlane:this._context.slicePlaneEnabled}),this._materials[1]){const e={hasSlicePlane:this._context.slicePlaneEnabled};this._materials[1].setParameters(e)}return!0}physicalBasedRenderingChanged(){return!0}_createAs3DShape(e,t,r,i){const s=f(t.geometry);if(!s)return null;const o=A(s,this._context.elevationProvider,this._context.renderCoordsHelper,i),n=new H(o,r,this._context.layerViewUid,t.uid),a=n.renderData.position.length/3;if(this._needsUV&&(n.uvMapSpace=c(4*a,!0),n.boundingRect=l(9),j(n.uvMapSpace,n.boundingRect,n.renderData.position,this._context.renderCoordsHelper)),n.olidColor=this._context.stage.renderView?.getObjectAndLayerIdColor(n),this._createAs3DShapeFill(e,n),this._materials[1]&&this._createAs3DShapeOutline(n),this._logGeometryCreationWarnings(n.renderData,s.rings,"rings","FillSymbol3DLayer"),0===n.outGeometries.length)return null;const p=new L({geometries:n.outGeometries,castShadow:!1,layerViewUid:this._context.layerViewUid,graphicUid:t.uid}),h=new d(this,p,null,U,i);return h.alignedSampledElevation=n.renderData.sampledElevation,h.needsElevationUpdates=u(i.mode),h}_createAs3DShapeFill(e,t){const r=t.renderData.polygons;for(const{position:o,mapPositions:n,holeIndices:a,index:l,count:c}of r){if(null!=this._context.clippingExtent&&(i(n,T),!s(T,this._context.clippingExtent)))continue;const r=v(n,a,this._context.elevationProvider.spatialReference);if(0===r.length)continue;const h=this._fastUpdates?.visualVariables.color,u=b({material:this._materials[0],indices:r,mapPositions:n,attributeData:{position:o,color:h?null:t.color,colorFeature:h?P(h,e.color):null,uvMapSpace:this._needsUV?p(t.uvMapSpace,4*l,4*c):null,boundingRect:this._needsUV?t.boundingRect:null,olidColor:t.olidColor}});t.outGeometries.push(u)}}_createAs3DShapeOutline(e){if(null==this._materials[1])return;const t=e.renderData.outlines;for(const{mapPositions:r,position:o}of t){if(null!=this._context.clippingExtent&&(i(r,T),!s(T,this._context.clippingExtent)))continue;const t=G(this._materials[1],{overlayInfo:null,removeDuplicateStartEnd:!0,mapPositions:r,attributeData:{position:o}},e.olidColor);e.outGeometries.push(t)}}_createAsOverlay(e,t,r){const i=f(t.geometry);if(null==i)return null;this._materials[0].renderPriority=this._renderPriority+this._renderPriorityStep/2,null!=this._materials[1]&&(this._materials[1].renderPriority=this._renderPriority);const s=E(i,this._context.overlaySR),n=new k(s,r,this._context.layerViewUid,t.uid),a=n.renderData.position.length/3;return this._needsUV&&(n.uvMapSpace=c(4*a,!0),w(n.uvMapSpace,n.renderData.position,this._context.overlaySR,this._context.graphicsCoreOwner.view.state.viewingMode)),n.outBoundingBox=o(),n.olidColor=this._context.stage.renderView?.getObjectAndLayerIdColor(n),this._createAsOverlayFill(e,n),this._materials[1]&&this._createAsOverlayOutline(n),this._logGeometryCreationWarnings(n.renderData,i.rings,"rings","FillSymbol3DLayer"),0===n.outGeometries.length?null:new m(this,n.outGeometries,n.outBoundingBox,this._context.drapeSourceRenderer)}_createAsOverlayFill(e,r){const o=r.renderData.polygons;for(const{position:a,holeIndices:l,index:c,count:h}of o){const o=i(a,T);if(!s(o,this._context.clippingExtent))continue;const u=t(a,l,3);if(0===u.length)continue;n(r.outBoundingBox,o);const m=this._fastUpdates?.visualVariables.color,d=b({material:this._materials[0],indices:u,attributeData:{position:a,color:m?null:r.color,colorFeature:m?P(m,e.color):null,uvMapSpace:this._needsUV?p(r.uvMapSpace,4*c,4*h):null,olidColor:r.olidColor}});r.outGeometries.push(new M(d,r))}}_createAsOverlayOutline(e){if(null==this._materials[1])return;const t=e.renderData.outlines;for(let r=0;r<t.length;++r){const{position:o}=t[r];if(i(o,T),!s(T,this._context.clippingExtent))continue;n(e.outBoundingBox,T);const a=G(this._materials[1],{overlayInfo:{spatialReference:this._context.overlaySR,renderCoordsHelper:this._context.renderCoordsHelper},removeDuplicateStartEnd:!0,attributeData:{position:o}},e.olidColor);e.outGeometries.push(new M(a,e))}}_getOutlineOpacity(){const e=this.symbolLayer?.outline?.color;return(this.draped?1:this._getLayerOpacity())*(null!=e?e.a:0)}_getOutlineColor(){const e=this.symbolLayer?.outline?.color,t=this._getOutlineOpacity();return g(e?.toUnitRGB(),t)}test(){return{...super.test(),createAsOverlay:(e,t,r)=>this._createAsOverlay(e,t,r),createAs3DShape:(e,t,r,i)=>this._createAs3DShape(e,t,r,i)}}get _vvConvertOptions(){return new D({supports:{size:!1,color:!0,rotation:!1,opacity:!1},fallbackColor:this._materialColor?.toUnitRGBA()??r})}}const T=a();class H extends S{constructor(e,t,r,i){super(e,r,i),this.color=t}}class k extends S{constructor(e,t,r,i){super(e,r,i),this.color=t}}function W(e){return null!=e?.size&&e.size>0&&null!=e.color&&(null==e.pattern||"style"!==e.pattern.type||"none"!==e.pattern.style)}function q(e){return 1===(e.material?.color?.a??0)}export{F as Graphics3DPolygonFillSymbolLayer};
2
+ import has from"../../../../core/has.js";import{pt2px as e}from"../../../../core/screenUtils.js";import{e as t}from"../../../../chunks/earcut.js";import{ZEROS as r}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{fromBuffer as i,intersectsClippingArea as s,empty as o,expandWithAABB as n,create as a}from"../../../../geometry/support/aaBoundingBox.js";import{newDoubleArray as l}from"../../../../geometry/support/DoubleArray.js";import{newFloatArray as c,floatSubArray as p}from"../../../../geometry/support/FloatArray.js";import{elevationModeChangeUpdateType as h,needsElevationUpdates2D as u}from"./elevationAlignmentUtils.js";import{Graphics3DDrapedGraphicLayer as m}from"./Graphics3DDrapedGraphicLayer.js";import{Graphics3DObject3DGraphicLayer as d}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as _}from"./Graphics3DSymbolLayer.js";import{mixinColorAndOpacity as g}from"./graphicUtils.js";import{parseCapType as y}from"./lineUtils.js";import{geometryAsPolygon as f,createIndices3D as v,createColorGeometry as b,PolygonCreationDataBase as S}from"./polygonUtils.js";import{initFastSymbolUpdatesState as x,updateFastSymbolUpdatesState as C,getAttributeValue as P,ConvertOptions as D}from"../support/FastSymbolUpdates.js";import{createMaterial as O,uvElevationAligner as U}from"../support/patternUtils.js";import{createMapSpaceUVCoords as j,createMapSpaceUVCoordsDraped as w}from"../support/uvUtils.js";import{createGeometry as G}from"../../support/engineContent/line.js";import{polygonToRenderInfo as A,polygonToRenderInfoDraped as E}from"../../support/renderInfoUtils/polygon.js";import{Object3D as L}from"../../webgl-engine/lib/Object3D.js";import{RenderGeometry as M}from"../../webgl-engine/lib/RenderGeometry.js";import{isScreenSizePerspectiveEnabled as V}from"../../webgl-engine/lib/screenSizePerspectiveUtils.js";import{getStipplePatternForLinePattern as R}from"../../webgl-engine/materials/lineStippleUtils.js";import{PatternMaterial as I}from"../../webgl-engine/materials/PatternMaterial.js";import{RibbonLineMaterial as z}from"../../webgl-engine/materials/RibbonLineMaterial.js";const B=["polyline","polygon","extent"];class F extends _{static{this.elevationModeChangeTypes={definedChanged:2,staysOnTheGround:0,onTheGroundChanged:2}}constructor(e,t,r,i){super(e,t,r,i,q(t)),this._needsUV=!1,this._materials=[]}async doLoad(){this._fastUpdates=x(this._context.renderer,this._vvConvertOptions)}get _materialColor(){return this.symbolLayer.material?.color}get _emissiveStrength(){if(has("enable-feature:emissive-on-none-volumetrics")){const e=this.symbolLayer.material?.emissive;return("color"===e?.source?e?.strength:void 0)??0}return 0}_createMaterials(){if(this._materials.length>0)return;const t=this._materialColor,r=this._getCombinedOpacityAndColor(t);this._materials[0]=O(this.symbolLayer,{color:r,forceTransparentMode:this.needsDrivenTransparentPass,discardInvisibleFragments:!0,hasVertexColors:this._drivenProperties.color||this._drivenProperties.opacity,draped:this.draped,hasSlicePlane:this._context.slicePlaneEnabled,emissiveStrength:this._emissiveStrength,...this._fastUpdates?.materialParameters}),this._needsUV=this._materials[0]instanceof I;const i=this.symbolLayer.outline;if(W(i)){const t=R(i.pattern);this._materials[1]=new z({width:e(i.size),color:this._getOutlineColor(),polygonOffset:3,hasSlicePlane:this._context.slicePlaneEnabled,isClosed:!0,stipplePattern:t,cap:y(i.patternCap||"butt"),screenSizePerspective:this._outlineScreenSizePerspective},this.view.state.isGlobal)}}get _outlineScreenSizePerspective(){return!this.draped&&V(this._context.layer.screenSizePerspectiveEnabled)?this.view.screenSizePerspective.parameters:null}createGraphics3DGraphic(e){const t=e.graphic;if(!this._validateGeometry(t.geometry,B,this.symbolLayer.type))return null;const r=this._getDrivenUInt8Color(e.renderingInfo,this._materialColor,!1),i=this.createElevationContextForGraphic(t);return this.ensureDrapedStatus("on-the-ground"===i.mode),this._createMaterials(),this.draped?this._createAsOverlay(e.renderingInfo,t,r):this._createAs3DShape(e.renderingInfo,t,r,i)}applyRendererDiff(e,t){for(const r in e.diff){if("visualVariables"!==r)return 0;if(!C(this._fastUpdates,t,this._vvConvertOptions))return 0;this._materials[0]?.setParameters(this._fastUpdates.materialParameters)}return 2}layerOpacityChanged(){if(null!=this._materials[0]){const e=this._materials[0].parameters.color,t=this._materialColor,r=this._getCombinedOpacity(t);this._materials[0].setParameters({color:[e[0],e[1],e[2],r],forceTransparentMode:this.needsDrivenTransparentPass})}if(null!=this._materials[1]){const e=this._materials[1].parameters.color;this._materials[1].setParameters({color:[e[0],e[1],e[2],this._getOutlineOpacity()]})}}layerScreenSizePerspectiveChanged(){this._materials[1]?.setParameters({screenSizePerspective:this._outlineScreenSizePerspective})}layerElevationInfoChanged(e,t,r){const i=this._elevationContext.mode,s=h(F.elevationModeChangeTypes,r,i);if(1!==s)return s;const o=u(i);return this.updateGraphics3DGraphicElevationInfo(e,t,()=>o)}slicePlaneEnabledChanged(){if(this._materials[0]?.setParameters({hasSlicePlane:this._context.slicePlaneEnabled}),this._materials[1]){const e={hasSlicePlane:this._context.slicePlaneEnabled};this._materials[1].setParameters(e)}return!0}physicalBasedRenderingChanged(){return!0}_createAs3DShape(e,t,r,i){const s=f(t.geometry);if(!s)return null;const o=A(s,this._context.elevationProvider,this._context.renderCoordsHelper,i),n=new H(o,r,this._context.layerViewUid,t.uid),a=n.renderData.position.length/3;if(this._needsUV&&(n.uvMapSpace=c(4*a,!0),n.boundingRect=l(9),j(n.uvMapSpace,n.boundingRect,n.renderData.position,this._context.renderCoordsHelper)),n.olidColor=this._context.stage.renderView?.getObjectAndLayerIdColor(n),this._createAs3DShapeFill(e,n),this._materials[1]&&this._createAs3DShapeOutline(n),this._logGeometryCreationWarnings(n.renderData,s.rings,"rings","FillSymbol3DLayer"),0===n.outGeometries.length)return null;const p=new L({geometries:n.outGeometries,castShadow:!1,layerViewUid:this._context.layerViewUid,graphicUid:t.uid}),h=new d(this,p,null,U,i);return h.alignedSampledElevation=n.renderData.sampledElevation,h.needsElevationUpdates=u(i.mode),h}_createAs3DShapeFill(e,t){const r=t.renderData.polygons;for(const{position:o,mapPositions:n,holeIndices:a,index:l,count:c}of r){if(null!=this._context.clippingExtent&&(i(n,T),!s(T,this._context.clippingExtent)))continue;const r=v(n,a,this._context.elevationProvider.spatialReference);if(0===r.length)continue;const h=this._fastUpdates?.visualVariables.color,u=b({material:this._materials[0],indices:r,mapPositions:n,attributeData:{position:o,color:h?null:t.color,colorFeature:h?P(h,e.color):null,uvMapSpace:this._needsUV?p(t.uvMapSpace,4*l,4*c):null,boundingRect:this._needsUV?t.boundingRect:null,olidColor:t.olidColor}});t.outGeometries.push(u)}}_createAs3DShapeOutline(e){if(null==this._materials[1])return;const t=e.renderData.outlines;for(const{mapPositions:r,position:o}of t){if(null!=this._context.clippingExtent&&(i(r,T),!s(T,this._context.clippingExtent)))continue;const t=G(this._materials[1],{overlayInfo:null,removeDuplicateStartEnd:!0,mapPositions:r,attributeData:{position:o}},e.olidColor);e.outGeometries.push(t)}}_createAsOverlay(e,t,r){const i=f(t.geometry);if(null==i)return null;this._materials[0].renderPriority=this._renderPriority+this._renderPriorityStep/2,null!=this._materials[1]&&(this._materials[1].renderPriority=this._renderPriority);const s=E(i,this._context.overlaySR),n=new k(s,r,this._context.layerViewUid,t.uid),a=n.renderData.position.length/3;return this._needsUV&&(n.uvMapSpace=c(4*a,!0),w(n.uvMapSpace,n.renderData.position,this._context.overlaySR,this._context.graphicsCoreOwner.view.state.viewingMode)),n.outBoundingBox=o(),n.olidColor=this._context.stage.renderView?.getObjectAndLayerIdColor(n),this._createAsOverlayFill(e,n),this._materials[1]&&this._createAsOverlayOutline(n),this._logGeometryCreationWarnings(n.renderData,i.rings,"rings","FillSymbol3DLayer"),0===n.outGeometries.length?null:new m(this,n.outGeometries,n.outBoundingBox,this._context.drapeSourceRenderer)}_createAsOverlayFill(e,r){const o=r.renderData.polygons;for(const{position:a,holeIndices:l,index:c,count:h}of o){const o=i(a,T);if(!s(o,this._context.clippingExtent))continue;const u=t(a,l,3);if(0===u.length)continue;n(r.outBoundingBox,o);const m=this._fastUpdates?.visualVariables.color,d=b({material:this._materials[0],indices:u,attributeData:{position:a,color:m?null:r.color,colorFeature:m?P(m,e.color):null,uvMapSpace:this._needsUV?p(r.uvMapSpace,4*c,4*h):null,olidColor:r.olidColor}});r.outGeometries.push(new M(d,r))}}_createAsOverlayOutline(e){if(null==this._materials[1])return;const t=e.renderData.outlines;for(let r=0;r<t.length;++r){const{position:o}=t[r];if(i(o,T),!s(T,this._context.clippingExtent))continue;n(e.outBoundingBox,T);const a=G(this._materials[1],{overlayInfo:{spatialReference:this._context.overlaySR,renderCoordsHelper:this._context.renderCoordsHelper},removeDuplicateStartEnd:!0,attributeData:{position:o}},e.olidColor);e.outGeometries.push(new M(a,e))}}_getOutlineOpacity(){const e=this.symbolLayer?.outline?.color;return(this.draped?1:this._getLayerOpacity())*(null!=e?e.a:0)}_getOutlineColor(){const e=this.symbolLayer?.outline?.color,t=this._getOutlineOpacity();return g(e?.toUnitRGB(),t)}test(){return{...super.test(),createAsOverlay:(e,t,r)=>this._createAsOverlay(e,t,r),createAs3DShape:(e,t,r,i)=>this._createAs3DShape(e,t,r,i)}}get _vvConvertOptions(){return new D({supports:{size:!1,color:!0,rotation:!1,opacity:!1},fallbackColor:this._materialColor?.toUnitRGBA()??r})}}const T=a();class H extends S{constructor(e,t,r,i){super(e,r,i),this.color=t}}class k extends S{constructor(e,t,r,i){super(e,r,i),this.color=t}}function W(e){return null!=e?.size&&e.size>0&&null!=e.color&&(null==e.pattern||"style"!==e.pattern.type||"none"!==e.pattern.style)}function q(e){return 1===(e.material?.color?.a??0)}export{F as Graphics3DPolygonFillSymbolLayer};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{removeUnordered as t}from"../../../../core/arrayUtils.js";import{makeHandle as e}from"../../../../core/handleUtils.js";import{getOrCreateMapValue as i}from"../../../../core/MapUtils.js";class h{constructor(t){this.highlightName=t,this.ids=new Set}}class s{constructor({collection:t,forAllFeatures:e,forAllFeaturesOfNode:i}){this._highlights=new Map,this._collection=t,this._forAllFeatures=e,this._forAllFeaturesOfNode=i}destroy(){this._highlights.forEach(t=>t.forEach(t=>this._releaseSet(t))),this._highlights=null}acquireSet(s){const l=new h(s);i(this._highlights,s,()=>[]).push(l);const o=e(()=>{const e=this._highlights?.get(s);e&&(this._releaseSet(l),t(e,l))});return{set:l,handle:o}}setFeatureIds(t,e){e.forEach(e=>t.ids.add(e)),this._initializeSet(t)}_initializeSet(t){this._forAllFeatures((e,i,h)=>(t.ids.has(e)&&this._collection.addComponentHighlight(h.objectHandle,i,t.highlightName),0))}_releaseSet(t){this._forAllFeatures((e,i,h)=>(t.ids.has(e)&&this._collection.removeComponentHighlight(h.objectHandle,i,t.highlightName),0))}objectCreated(t){this._highlights.forEach((e,i)=>{e.forEach(e=>{this._forAllFeaturesOfNode(t,(h,s)=>(e.ids.has(h)&&this._collection.addComponentHighlight(t.objectHandle,s,i),0))})})}objectDeleted(t){this._collection.clearHighlights(t.objectHandle)}}export{s as default};
2
+ import{removeUnordered as t}from"../../../../core/arrayUtils.js";import{makeHandle as e}from"../../../../core/handleUtils.js";import{getOrCreateMapValue as i}from"../../../../core/MapUtils.js";class h{constructor(t){this.highlightName=t,this.ids=new Set}}class s{constructor({collection:t,forAllFeatures:e,forAllFeaturesOfNode:i}){this._highlights=new Map,this._collection=t,this._forAllFeatures=e,this._forAllFeaturesOfNode=i}destroy(){this._highlights.forEach(t=>t.forEach(t=>this._releaseSet(t))),this._highlights=null}acquireSet(s){const l=new h(s);i(this._highlights,s,()=>[]).push(l);const o=e(()=>{const e=this._highlights?.get(s);e&&(this._releaseSet(l),t(e,l))});return{set:l,handle:o}}setFeatureIds(t,e){e.forEach(e=>t.ids.add(e)),this._initializeSet(t)}_initializeSet(t){this._forAllFeatures((e,i,h)=>(t.ids.has(e)&&this._collection.addHighlight(h.objectHandle,i,t.highlightName),0))}_releaseSet(t){this._forAllFeatures((e,i,h)=>(t.ids.has(e)&&this._collection.removeHighlight(h.objectHandle,i,t.highlightName),0))}objectCreated(t){this._highlights.forEach((e,i)=>{e.forEach(e=>{this._forAllFeaturesOfNode(t,(h,s)=>(e.ids.has(h)&&this._collection.addHighlight(t.objectHandle,s,i),0))})})}objectDeleted(t){this._collection.clearHighlights(t.objectHandle)}}export{s as default};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{isValidIntersectorResult as t}from"../../webgl-engine/lib/IntersectorResult.js";import{Graphic3DTarget as e,LayerTarget as r}from"../../webgl-engine/lib/IntersectorTarget.js";class s extends e{constructor(t,e){super(e,null),this.point=t}}class n extends e{constructor(t,e,r,s){super(e,r),this.point=t,this.createGraphic=s}}function i(e){return t(e)&&6===e.intersector&&!!e.target}class o extends r{constructor(t,e,r,s,n){super(t),this.layerViewUid=t,this.sublayerId=e,this.nodeIndex=r,this.componentIndex=s,this.triangleNr=n}}class c extends e{constructor(t,e,r){super(e,null),this.point=t,this.createVoxelGraphic=r}}class l extends r{}function u(e){return t(e)&&2===e.intersector&&!!e.target}function a(e){return t(e)&&9===e.intersector&&!!e.target}export{s as GaussianSplatTarget,o as I3sTarget,n as PclTarget,l as Tiles3DTarget,c as VoxelTarget,u as isI3sIntersectorResult,i as isPclIntersectorResult,a as isVoxelIntersectorResult};
2
+ import{isValidIntersectorResult as t}from"../../webgl-engine/lib/IntersectorResult.js";import{Graphic3DTarget as e,LayerTarget as r}from"../../webgl-engine/lib/IntersectorTarget.js";class s extends e{constructor(t,e){super(e,null),this.point=t}}function n(e){return t(e)&&0===e.intersector&&!!e.target}class i extends e{constructor(t,e,r,s){super(e,r),this.point=t,this.createGraphic=s}}function o(e){return t(e)&&6===e.intersector&&!!e.target}class c extends r{constructor(t,e,r,s,n){super(t),this.layerViewUid=t,this.sublayerId=e,this.nodeIndex=r,this.componentIndex=s,this.triangleNr=n}}class u extends e{constructor(t,e,r){super(e,null),this.point=t,this.createVoxelGraphic=r}}class l extends r{}function a(e){return t(e)&&2===e.intersector&&!!e.target}function p(e){return t(e)&&9===e.intersector&&!!e.target}export{s as GaussianSplatTarget,c as I3sTarget,i as PclTarget,l as Tiles3DTarget,u as VoxelTarget,n as isGaussianSplatIntersectorResult,a as isI3sIntersectorResult,o as isPclIntersectorResult,p as isVoxelIntersectorResult};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{fromValues as t}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{perVertexElevationAligner as e}from"../graphics/ElevationAligners.js";import{createMapSpaceUVCoords as r}from"./uvUtils.js";import{ColorMaterial as a}from"../../webgl-engine/materials/ColorMaterial.js";import{PatternMaterial as n}from"../../webgl-engine/materials/PatternMaterial.js";function o(e,r){r.useIndexing=!0;const o=e?.pattern;return null==o?new a(r):"none"===o.style||"solid"===o.style?("none"===o.style&&(r.color=t(0,0,0,0),r.forceTransparentMode=!0),new a(r)):(r.style=i(o.style),new n(r))}function i(t){switch(t){case"horizontal":return 0;case"vertical":return 1;case"cross":return 2;case"forward-diagonal":return 3;case"backward-diagonal":return 4;case"diagonal-cross":return 5;default:return}}function s(t){return t.material instanceof n&&!t.material.parameters.draped}function l(t,e){if(s(t)){const a=t.attributes.get("position").data,n=t.getMutableAttribute("uvMapSpace").data,o=t.getMutableAttribute("boundingRect").data;r(n,o,a,e)}}function c(t,r,a,n,o){const i=e(t,r,a,n,o),s=t.stageObject.geometries;for(const e of s)l(e,o);return i}export{o as createMaterial,i as parsePatternStyle,s as requiresUVUpdates,l as updateMapSpaceUVCoords,c as uvElevationAligner};
2
+ import{fromValues as t}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{perVertexElevationAligner as e}from"../graphics/ElevationAligners.js";import{createMapSpaceUVCoords as r}from"./uvUtils.js";import{ColorMaterial as a}from"../../webgl-engine/materials/ColorMaterial.js";import{PatternMaterial as n}from"../../webgl-engine/materials/PatternMaterial.js";function o(e,r){r.useIndexing=!0;const o=e?.pattern;return null==o||"solid"===o.style?new a(r):"none"===o.style?(r.color=t(0,0,0,0),r.forceTransparentMode=!0,new a(r)):(r.style=i(o.style),new n(r))}function i(t){switch(t){case"horizontal":return 0;case"vertical":return 1;case"cross":return 2;case"forward-diagonal":return 3;case"backward-diagonal":return 4;case"diagonal-cross":return 5;default:return}}function s(t){return t.material instanceof n&&!t.material.parameters.draped}function c(t,e){if(s(t)){const a=t.attributes.get("position").data,n=t.getMutableAttribute("uvMapSpace").data,o=t.getMutableAttribute("boundingRect").data;r(n,o,a,e)}}function l(t,r,a,n,o){const i=e(t,r,a,n,o),s=t.stageObject.geometries;for(const e of s)c(e,o);return i}export{o as createMaterial,i as parsePatternStyle,s as requiresUVUpdates,c as updateMapSpaceUVCoords,l as uvElevationAligner};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{reallocGrowthFactor as e}from"../../../../core/arrayUtils.js";import{signal as t}from"../../../../core/signal.js";import{Milliseconds as r,now as s}from"../../../../core/time.js";import{normalize as i}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as a}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{intersects as n}from"../../../../geometry/support/aaBoundingBox.js";import{intersectsSphere as o}from"../../../../geometry/support/frustum.js";import{Sphere as u}from"../../../../geometry/support/sphere.js";import{makeScheduleFunction as h}from"../../layers/support/makeScheduleFunction.js";import{GaussianSplatSortWorkerHandle as d}from"../GaussianSplatWorkerHandle.js";import{GaussianSplatFadeTexture as l}from"./GaussianSplatFadeTexture.js";import{GaussianSplatOrderTexture as _}from"./GaussianSplatOrderTexture.js";import{GaussianSplatTextureAtlas as c}from"./GaussianSplatTextureAtlas.js";import{TaskPriority as f}from"../../../support/Scheduler.js";class m{constructor(e){this._updating=t(!1),this._useDeterministicSort=!1,this.visibleGaussians=0,this._visibleGaussianTiles=new Array,this._bufferCapacity=0,this._minimumBoundingSphere=new u,this._cameraDirectionNormalized=a(),this._frameTask=null,this._workerHandle=null,this._isSorting=!1,this._pendingSortTask=!1,this._scheduledSortStartTimeout=null,this._lastSortStartTime=r(-1/0),this._sortInterval=r(80),this._renderer=e,this._orderTexture=new _(this._renderer.renderingContext),this._fadingTexture=new l(this._renderer.renderingContext),this._textureAtlas=new c(this._renderer.renderingContext,this._renderer.view.resourceController.memoryController,this._renderer.fboCache);const{resourceController:s}=this._renderer.view;this._workerHandle=new d(h(s)),this._frameTask=s.scheduler.registerTask(f.GAUSSIAN_SPLAT_SORTING)}get textureAtlas(){return this._textureAtlas}get orderTexture(){return this._orderTexture}get fadingTexture(){return this._fadingTexture}get visibleGaussianTiles(){return this._visibleGaussianTiles}forEachTile(e){for(const t of this._visibleGaussianTiles)e(t)}updateGaussianVisibility(e){this._visibleGaussianTiles=e,this.requestSort()}get updating(){return this._updating.value}destroy(){this._pendingSortTask=!1,null!=this._scheduledSortStartTimeout&&(clearTimeout(this._scheduledSortStartTimeout),this._scheduledSortStartTimeout=null),this._frameTask.remove(),this._workerHandle?.destroyWorkerAndSelf(),this._textureAtlas.destroy(),this._orderTexture.destroy(),this._fadingTexture.destroy()}requestSort(){return this._updating.value=!0,!this._pendingSortTask&&(this._pendingSortTask=!0,this._scheduleSortStart(),!0)}_scheduleSortStart(){if(this._isSorting)return;const e=s()-this._lastSortStartTime,t=this._sortInterval-e;t<=0?this._startSortIfRequired():null==this._scheduledSortStartTimeout&&(this._scheduledSortStartTimeout=setTimeout(()=>{this._scheduledSortStartTimeout=null,this._pendingSortTask&&!this._isSorting&&this._scheduleSortStart()},t))}_startSortIfRequired(){!this._isSorting&&this._pendingSortTask&&(this._isSorting=!0,this._pendingSortTask=!1,this._lastSortStartTime=s(),this._sortOnWorker().finally(()=>this._handleSortComplete()))}_handleSortComplete(){this._isSorting=!1,this._pendingSortTask?this._scheduleSortStart():this._updating.value=!1}_clearBuffersAndTextures(){this._atlasIndicesBuffer=void 0,this._sortedAtlasIndicesBuffer=void 0,this._distancesBuffer=void 0,this._sortOrderBuffer=void 0,this._bufferCapacity=0,this._orderTexture.clear(),this._textureAtlas.clear()}_computeExpandedCapacity(t,r){let s=Math.max(1,t);for(;s<r;)s=Math.ceil(s*e);return s}_ensureSortBufferCapacities(e){if(this._bufferCapacity<e){const t=this._computeExpandedCapacity(this._bufferCapacity,e);this._atlasIndicesBuffer=new Uint32Array(t),this._distancesBuffer=new Float64Array(t),this._sortOrderBuffer=new Uint32Array(t),this._bufferCapacity=t}}_ensureSortedAtlasIndicesBufferCapacity(e){if(!(e<=0)&&(!this._sortedAtlasIndicesBuffer||this._sortedAtlasIndicesBuffer.length<e)){const t=this._sortedAtlasIndicesBuffer?.length??0,r=this._computeExpandedCapacity(t,e);this._sortedAtlasIndicesBuffer=new Uint32Array(r)}}_clearAllBuffersAndTextures(){this._clearBuffersAndTextures(),this._workerHandle?.clear()}async _sortOnWorker(){if(0===this._visibleGaussianTiles.length)return this.visibleGaussians=0,this._clearAllBuffersAndTextures(),void this._renderer.requestRender(1);this._useDeterministicSort&&this._visibleGaussianTiles.sort((e,t)=>e.obb.centerX-t.obb.centerX||e.obb.centerY-t.obb.centerY||e.obb.centerZ-t.obb.centerZ);const e=this._visibleGaussianTiles,t=e.length;let r=0;for(let i=0;i<t;i++)r+=e[i].gaussianAtlasIndices.length;this._ensureSortBufferCapacities(r),this._textureAtlas.ensureTextureAtlas();const{frustum:s}=this._renderer.camera;i(this._cameraDirectionNormalized,this._renderer.camera.ray.direction);const a=this._cameraDirectionNormalized[0],u=this._cameraDirectionNormalized[1],h=this._cameraDirectionNormalized[2];let d=0;const l=1.5,_=this._atlasIndicesBuffer,c=this._distancesBuffer,f=this._sortOrderBuffer,m=this._minimumBoundingSphere,S=m.center,p=this._renderer.clippingBox;for(let i=0;i<t;i++){const t=e[i],{gaussianAtlasIndices:r,relativePositions:f,obb:T,maxScale:g}=t,x=r.length;if(null!=p&&null!=t.boundingBox&&!n(t.boundingBox,p))continue;const{centerX:b,centerY:B,centerZ:A}=T;if(S[0]=b,S[1]=B,S[2]=A,m.radius=(T.radius+g)*l,!o(s,m))continue;_.set(r,d);const y=a*b+u*B+h*A,v=d+x;for(let e=d,s=0;e<v;e++,s+=3){const t=f[s],r=f[s+1],i=f[s+2];c[e]=t*a+r*u+i*h+y}d=v}for(let i=0;i<d;i++)f[i]=i;if(0===d)return this.visibleGaussians=0,this._clearAllBuffersAndTextures(),void this._renderer.requestRender(1);const T={distances:this._distancesBuffer,sortOrderIndices:this._sortOrderBuffer,numGaussians:d,preciseSort:this._useDeterministicSort},g=await(this._workerHandle?.sort(T));g&&(this._distancesBuffer=g.distances,this._sortOrderBuffer=g.sortedOrderIndices);const x=async e=>{const{paddedSize:t}=this._orderTexture.ensureCapacity(d);this._ensureSortedAtlasIndicesBufferCapacity(t);const r=this._atlasIndicesBuffer,s=this._sortOrderBuffer,i=this._sortedAtlasIndicesBuffer;for(let a=0;a<d;a++)i[a]=r[s[a]];this._orderTexture.setData(i,d),this.visibleGaussians=d,this._renderer.requestRender(1),e.madeProgress()};await this._frameTask.schedule(x)}set useDeterministicSort(e){this._useDeterministicSort=e}}export{m as GaussianSplatDataStore};
2
+ import{reallocGrowthFactor as t}from"../../../../core/arrayUtils.js";import{abortMaybe as e}from"../../../../core/maybe.js";import{isAbortError as r}from"../../../../core/promiseUtils.js";import{signal as s}from"../../../../core/signal.js";import{Milliseconds as i,now as o}from"../../../../core/time.js";import{normalize as n}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as a}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{intersects as u}from"../../../../geometry/support/aaBoundingBox.js";import{intersectsSphere as l}from"../../../../geometry/support/frustum.js";import{Sphere as h}from"../../../../geometry/support/sphere.js";import{makeScheduleFunction as d}from"../../layers/support/makeScheduleFunction.js";import{GaussianSplatSortWorkerHandle as _}from"../GaussianSplatWorkerHandle.js";import{GaussianSplatFadeTexture as c}from"./GaussianSplatFadeTexture.js";import{GaussianSplatOrderTexture as f}from"./GaussianSplatOrderTexture.js";import{GaussianSplatTextureAtlas as m}from"./GaussianSplatTextureAtlas.js";import{TaskPriority as p}from"../../../support/Scheduler.js";class S{constructor(t){this._updating=s(!1),this._useDeterministicSort=!1,this.visibleGaussians=0,this._visibleGaussianTiles=new Array,this._bufferCapacity=0,this._minimumBoundingSphere=new h,this._cameraDirectionNormalized=a(),this._frameTask=null,this._workerHandle=null,this._sortAbortController=null,this._isSorting=!1,this._pendingSortTask=!1,this._scheduledSortStartTimeout=null,this._lastSortStartTime=i(-1/0),this._sortInterval=i(80),this._renderer=t,this._orderTexture=new f(this._renderer.renderingContext),this._fadingTexture=new c(this._renderer.renderingContext),this._textureAtlas=new m(this._renderer.renderingContext,this._renderer.view.resourceController.memoryController,this._renderer.fboCache);const{resourceController:e}=this._renderer.view;this._workerHandle=new _(d(e)),this._frameTask=e.scheduler.registerTask(p.GAUSSIAN_SPLAT_SORTING)}get textureAtlas(){return this._textureAtlas}get orderTexture(){return this._orderTexture}get fadingTexture(){return this._fadingTexture}get visibleGaussianTiles(){return this._visibleGaussianTiles}forEachTile(t){for(const e of this._visibleGaussianTiles)t(e)}updateGaussianVisibility(t){this._visibleGaussianTiles=t,this.requestSort()}get updating(){return this._updating.value}destroy(){this._sortAbortController=e(this._sortAbortController),this._pendingSortTask=!1,this._updating.value=!1,null!=this._scheduledSortStartTimeout&&(clearTimeout(this._scheduledSortStartTimeout),this._scheduledSortStartTimeout=null),this._frameTask.remove(),this._workerHandle?.destroyWorkerAndSelf(),this._textureAtlas.destroy(),this._orderTexture.destroy(),this._fadingTexture.destroy()}requestSort(){return this._updating.value=!0,!this._pendingSortTask&&(this._pendingSortTask=!0,this._scheduleSortStart(),!0)}_scheduleSortStart(){if(this._isSorting)return;const t=o()-this._lastSortStartTime,e=this._sortInterval-t;e<=0?this._startSortIfRequired():null==this._scheduledSortStartTimeout&&(this._scheduledSortStartTimeout=setTimeout(()=>{this._scheduledSortStartTimeout=null,this._pendingSortTask&&!this._isSorting&&this._scheduleSortStart()},e))}_startSortIfRequired(){if(this._isSorting||!this._pendingSortTask)return;const t=new AbortController;this._sortAbortController=t,this._isSorting=!0,this._pendingSortTask=!1,this._lastSortStartTime=o(),this._sortOnWorker(t.signal).finally(()=>{this._sortAbortController===t&&(this._sortAbortController=null),this._handleSortComplete()})}_handleSortComplete(){this._isSorting=!1,this._pendingSortTask?this._scheduleSortStart():this._updating.value=!1}_clearBuffersAndTextures(){this._atlasIndicesBuffer=void 0,this._sortedAtlasIndicesBuffer=void 0,this._distancesBuffer=void 0,this._sortOrderBuffer=void 0,this._bufferCapacity=0,this._orderTexture.clear(),this._textureAtlas.clear()}_computeExpandedCapacity(e,r){let s=Math.max(1,e);for(;s<r;)s=Math.ceil(s*t);return s}_ensureSortBufferCapacities(t){if(this._bufferCapacity<t){const e=this._computeExpandedCapacity(this._bufferCapacity,t);this._atlasIndicesBuffer=new Uint32Array(e),this._distancesBuffer=new Float64Array(e),this._sortOrderBuffer=new Uint32Array(e),this._bufferCapacity=e}}_ensureSortedAtlasIndicesBufferCapacity(t){if(!(t<=0)&&(!this._sortedAtlasIndicesBuffer||this._sortedAtlasIndicesBuffer.length<t)){const e=this._sortedAtlasIndicesBuffer?.length??0,r=this._computeExpandedCapacity(e,t);this._sortedAtlasIndicesBuffer=new Uint32Array(r)}}_clearAllBuffersAndTextures(){this._clearBuffersAndTextures(),this._workerHandle?.clear()}async _sortOnWorker(t){try{if(0===this._visibleGaussianTiles.length)return this.visibleGaussians=0,this._clearAllBuffersAndTextures(),void this._renderer.requestRender(1);this._useDeterministicSort&&this._visibleGaussianTiles.sort((t,e)=>t.obb.centerX-e.obb.centerX||t.obb.centerY-e.obb.centerY||t.obb.centerZ-e.obb.centerZ);const e=this._visibleGaussianTiles,r=e.length;let s=0;for(let t=0;t<r;t++)s+=e[t].gaussianAtlasIndices.length;this._ensureSortBufferCapacities(s),this._textureAtlas.ensureTextureAtlas();const{frustum:i}=this._renderer.camera;n(this._cameraDirectionNormalized,this._renderer.camera.ray.direction);const o=this._cameraDirectionNormalized[0],a=this._cameraDirectionNormalized[1],h=this._cameraDirectionNormalized[2];let d=0;const _=1.5,c=this._atlasIndicesBuffer,f=this._distancesBuffer,m=this._sortOrderBuffer,p=this._minimumBoundingSphere,S=p.center,T=this._renderer.clippingBox;for(let t=0;t<r;t++){const r=e[t],{gaussianAtlasIndices:s,relativePositions:n,obb:m,maxScale:g}=r,b=s.length;if(null!=T&&null!=r.boundingBox&&!u(r.boundingBox,T))continue;const{centerX:A,centerY:x,centerZ:B}=m;if(S[0]=A,S[1]=x,S[2]=B,p.radius=(m.radius+g)*_,!l(i,p))continue;c.set(s,d);const y=o*A+a*x+h*B,v=d+b;for(let t=d,e=0;t<v;t++,e+=3){const r=n[e],s=n[e+1],i=n[e+2];f[t]=r*o+s*a+i*h+y}d=v}for(let t=0;t<d;t++)m[t]=t;if(0===d)return this.visibleGaussians=0,this._clearAllBuffersAndTextures(),void this._renderer.requestRender(1);const g={distances:this._distancesBuffer,sortOrderIndices:this._sortOrderBuffer,numGaussians:d,preciseSort:this._useDeterministicSort},b=await(this._workerHandle?.sort(g,t));if(t.aborted)return;b&&(this._distancesBuffer=b.distances,this._sortOrderBuffer=b.sortedOrderIndices);const A=async t=>{const{paddedSize:e}=this._orderTexture.ensureCapacity(d);this._ensureSortedAtlasIndicesBufferCapacity(e);const r=this._atlasIndicesBuffer,s=this._sortOrderBuffer,i=this._sortedAtlasIndicesBuffer;for(let o=0;o<d;o++)i[o]=r[s[o]];this._orderTexture.setData(i,d),this.visibleGaussians=d,this._renderer.requestRender(1),t.madeProgress()};await this._frameTask.schedule(A,t)}catch(e){if(r(e))return}}set useDeterministicSort(t){this._useDeterministicSort=t}}export{S as GaussianSplatDataStore};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{signal as i}from"../../../../core/signal.js";class e{static{this.fadeInEase=i=>i*(2-i)}static{this.fadeOutEase=i=>i*i}constructor(e){this.layerView=e,this._numFadingTiles=i(0)}get numFadingTiles(){return this._numFadingTiles.value}fadeTile(i,e){const t=this._getTargetOpacity(e);if(i.fadeDirection=e,0===this.fadeDuration)return void this._instantTileFading(i,t);const a=i.opacityModifier;if(a!==t){const e=1-Math.abs(t-a);this._startTileFading(i,e)}else this._stopTileFading(i)}updateAllTileFading(i){this.layerView.tileHandles.forEach(e=>this._updateTileFading(e,i)),this.layerView.updateGaussians()}onFadeDurationChanged(i){0===i&&this.numFadingTiles>0&&this._instantlyFullyFadeAllTiles()}isTileFadingOut(i){return null!=i.fadeProgress&&1===i.fadeDirection}get updating(){return this._numFadingTiles.value>0}get fadeDuration(){return 0}get fadingEnabled(){return 0!==this.fadeDuration}_startTileFading(i,e){null==i.fadeProgress&&this._numFadingTiles.value++,i.fadeProgress=e}_stopTileFading(i){null!=i.fadeProgress&&(1===i.fadeDirection&&this._onTileFullyFadedOut(i),this._numFadingTiles.value--,i.fadeProgress=null)}_updateTileFading(i,t){const{fadeProgress:a,fadeDirection:s}=i;if(null==a)return;const n=this._fadeDirectionToSign(s),d=n*this.fadeDuration,l=this._getTargetOpacity(s),r=t/Math.abs(d||1),o=Math.min(a+r,1),u=n*(1-(0===s?e.fadeInEase:e.fadeOutEase)(o)),g=1===o;i.opacityModifier=g?l:l-u,g?this._stopTileFading(i):i.fadeProgress=o,this._updateOpacityModifier(i)}_updateOpacityModifier(i){const e=255*i.opacityModifier;for(let t=0;t<i.pageIds.length;t++){const a=i.pageIds[t];this.layerView.data.fadingTexture.updateBuffer(e,a)}}_instantTileFading(i,e){i.fadeProgress=null,i.opacityModifier=e,this._updateOpacityModifier(i),1===i.fadeDirection&&this._onTileFullyFadedOut(i)}_instantlyFullyFadeAllTiles(){this.layerView.tileHandles.forEach(i=>{null!=i.fadeProgress&&this._instantTileFading(i,this._getTargetOpacity(i.fadeDirection))}),this.layerView.updateGaussians(),this._numFadingTiles.value=0}_onTileFullyFadedOut(i){i.isVisible=!1,this.layerView.moveTileToCache(i)}_fadeDirectionToSign(i){return 0===i?1:-1}_getTargetOpacity(i){return 0===i?1:0}}export{e as GaussianSplatFadeHelper};
2
+ import{signal as i}from"../../../../core/signal.js";class e{static{this.fadeInEase=i=>i*(2-i)}static{this.fadeOutEase=i=>i*i}constructor(e){this.layerView=e,this._numFadingTiles=i(0),this._tmpFullyFadedOutTiles=new Array}get numFadingTiles(){return this._numFadingTiles.value}fadeTile(i,e){const t=this._getTargetOpacity(e);if(i.fadeDirection=e,0===this.fadeDuration)return void this._instantTileFading(i,t);const a=i.opacityModifier;if(a!==t){const e=1-Math.abs(t-a);this._startTileFading(i,e)}else this._stopTileFading(i)}updateAllTileFading(i){const e=this._tmpFullyFadedOutTiles;e.length=0,this.layerView.tileHandles.forEach(t=>{this._updateTileFading(t,i)&&e.push(t)}),this.layerView.updateGaussians(),e.length>0&&this.layerView.notifyTileObbsChanged(e)}onFadeDurationChanged(i){0===i&&this.numFadingTiles>0&&this._instantlyFullyFadeAllTiles()}isTileFadingOut(i){return null!=i.fadeProgress&&1===i.fadeDirection}onTileDiscarded(i){null!=i.fadeProgress&&this._numFadingTiles.value--}get updating(){return this._numFadingTiles.value>0}get fadeDuration(){return this.layerView.view.qualitySettings.fadeDuration}get fadingEnabled(){return 0!==this.fadeDuration}_startTileFading(i,e){null==i.fadeProgress&&this._numFadingTiles.value++,i.fadeProgress=e}_stopTileFading(i){null!=i.fadeProgress&&(1===i.fadeDirection&&this._onTileFullyFadedOut(i),this._numFadingTiles.value--,i.fadeProgress=null)}_updateTileFading(i,t){const{fadeProgress:a,fadeDirection:s}=i;if(null==a)return!1;const n=this._fadeDirectionToSign(s),l=n*this.fadeDuration,d=this._getTargetOpacity(s),r=t/Math.abs(l||1),u=Math.min(a+r,1),o=n*(1-(0===s?e.fadeInEase:e.fadeOutEase)(u)),g=1===u;if(i.opacityModifier=g?d:d-o,g){const e=1===s;return this._stopTileFading(i),this._updateOpacityModifier(i),e}return i.fadeProgress=u,this._updateOpacityModifier(i),!1}_updateOpacityModifier(i){const e=255*i.opacityModifier;for(let t=0;t<i.pageIds.length;t++){const a=i.pageIds[t];this.layerView.data.fadingTexture.updateBuffer(e,a)}}_instantTileFading(i,e){i.fadeProgress=null,i.opacityModifier=e,this._updateOpacityModifier(i),1===i.fadeDirection&&this._onTileFullyFadedOut(i)}_instantlyFullyFadeAllTiles(){const i=this._tmpFullyFadedOutTiles;i.length=0,this.layerView.tileHandles.forEach(e=>{if(null!=e.fadeProgress){const t=1===e.fadeDirection;this._instantTileFading(e,this._getTargetOpacity(e.fadeDirection)),t&&i.push(e)}}),this.layerView.updateGaussians(),i.length>0&&this.layerView.notifyTileObbsChanged(i),this._numFadingTiles.value=0}_onTileFullyFadedOut(i){i.isVisible=!1,this.layerView.moveTileToCache(i)}_fadeDirectionToSign(i){return 0===i?1:-1}_getTargetOpacity(i){return 0===i?1:0}}export{e as GaussianSplatFadeHelper};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{reallocGrowthFactor as e}from"../../../../core/arrayUtils.js";import{fromValues as t}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import"../../../webgl/BufferObject.js";import"../../../webgl/FramebufferObject.js";import"../../../webgl/Program.js";import"../../../../core/has.js";import"../../../webgl/Renderbuffer.js";import r from"../../../webgl/Texture.js";import"../../../../core/Logger.js";import{PixelType as i,SizedPixelFormat as s}from"../../../webgl/enums.js";import"../../../webgl/Util.js";import{initialSplatAtlasTexturePages as a}from"./GaussianSplatAtlasPages.js";import{TextureDescriptor as o}from"../../../webgl/TextureDescriptor.js";class u{constructor(e){this.texture=null,this._fadeTextureCapacity=0,this._rctx=e}ensureCapacity(t){if(this._fadeTextureCapacity>t)return;const u=Math.max(Math.ceil(t*e),a),[f,p]=this._evalTextureSize(u),c=f*p,h=this._fadeBuffer,m=new Uint8Array(c);h&&m.set(h.subarray(0,this._fadeTextureCapacity)),this._fadeBuffer=m,this._fadeTextureCapacity=c,this.texture?.dispose();const l=new o;l.width=f,l.height=p,l.pixelFormat=36244,l.dataType=i.UNSIGNED_BYTE,l.internalFormat=s.R8UI,l.unpackAlignment=1,l.wrapMode=33071,l.samplingMode=9728,l.isImmutable=!0,this.texture=new r(this._rctx,l)}updateTexture(e){this.ensureCapacity(e);const t=this.texture.descriptor.width,r=Math.ceil(e/t),i=t*r;this.texture.updateData(0,0,0,t,r,this._fadeBuffer.subarray(0,i))}updateBuffer(e,t){this.ensureCapacity(t+1),this._fadeBuffer&&(this._fadeBuffer[t]=e)}destroy(){this.texture?.dispose()}_evalTextureSize(e){const r=Math.ceil(Math.sqrt(e)),i=Math.ceil(e/r);return t(r,i)}}export{u as GaussianSplatFadeTexture};
2
+ import{reallocGrowthFactor as e}from"../../../../core/arrayUtils.js";import{fromValues as t}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import"../../../webgl/BufferObject.js";import"../../../webgl/FramebufferObject.js";import"../../../webgl/Program.js";import"../../../../core/has.js";import"../../../webgl/Renderbuffer.js";import r from"../../../webgl/Texture.js";import"../../../../core/Logger.js";import{PixelType as i,SizedPixelFormat as s}from"../../../webgl/enums.js";import"../../../webgl/Util.js";import{initialSplatAtlasTexturePages as a}from"./GaussianSplatAtlasPages.js";import{TextureDescriptor as u}from"../../../webgl/TextureDescriptor.js";class o{constructor(e){this.texture=null,this._fadeTextureCapacity=0,this._rctx=e}ensureCapacity(t){const o=this.texture;if(this._fadeTextureCapacity>t&&o?.hasWebGLTextureObject)return;const f=Math.max(Math.ceil(t*e),a),[h,c]=this._evalTextureSize(f),p=h*c,l=this._fadeBuffer,m=new Uint8Array(p);l&&m.set(l.subarray(0,this._fadeTextureCapacity)),this._fadeBuffer=m,this._fadeTextureCapacity=p,this.texture?.dispose();const n=new u;n.width=h,n.height=c,n.pixelFormat=36244,n.dataType=i.UNSIGNED_BYTE,n.internalFormat=s.R8UI,n.unpackAlignment=1,n.wrapMode=33071,n.samplingMode=9728,n.isImmutable=!0,this.texture=new r(this._rctx,n)}updateTexture(e){this.ensureCapacity(e);const t=this.texture.descriptor.width,r=Math.ceil(e/t),i=t*r;this.texture.updateData(0,0,0,t,r,this._fadeBuffer.subarray(0,i))}updateBuffer(e,t){this.ensureCapacity(t+1),this._fadeBuffer&&(this._fadeBuffer[t]=e)}clear(){this._fadeBuffer=void 0,this._fadeTextureCapacity=0,this.texture?.dispose(),this.texture=null}destroy(){this.clear()}_evalTextureSize(e){const r=Math.ceil(Math.sqrt(e)),i=Math.ceil(e/r);return t(r,i)}}export{o as GaussianSplatFadeTexture};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{reallocGrowthFactor as t}from"../../../../core/arrayUtils.js";import{fromValues as e}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import"../../../webgl/BufferObject.js";import"../../../webgl/FramebufferObject.js";import"../../../webgl/Program.js";import"../../../../core/has.js";import"../../../webgl/Renderbuffer.js";import r from"../../../webgl/Texture.js";import"../../../../core/Logger.js";import{PixelType as i,SizedPixelFormat as s}from"../../../webgl/enums.js";import"../../../webgl/Util.js";import{minExpectedGaussianCount as a}from"./GaussianSplatAtlasPages.js";import{TextureDescriptor as o}from"../../../webgl/TextureDescriptor.js";class u{constructor(t){this.texture=null,this._orderTextureCapacity=0,this._rctx=t}ensureCapacity(e){if(e<=0)return{textureWidth:0,rowCount:0,paddedSize:0};if(this._orderTextureCapacity>=e&&this.texture){const t=this.texture.descriptor.width,r=Math.ceil(e/t);return{textureWidth:t,rowCount:r,paddedSize:t*r}}const u=Math.max(Math.ceil(e*t),a),[p,h]=this._evalTextureSize(u),c=p*h;this._orderTextureCapacity=c,this.texture?.dispose();const d=new o;d.width=p,d.height=h,d.pixelFormat=36244,d.dataType=i.UNSIGNED_INT,d.internalFormat=s.R32UI,d.wrapMode=33071,d.samplingMode=9728,d.isImmutable=!0,this.texture=new r(this._rctx,d);const l=Math.ceil(e/p);return{textureWidth:p,rowCount:l,paddedSize:p*l}}setData(t,e){const{textureWidth:r,rowCount:i,paddedSize:s}=this.ensureCapacity(e);if(t.length>=s)return void this.texture.updateData(0,0,0,r,i,t);const a=new Uint32Array(s);a.set(t.subarray(0,e)),this.texture.updateData(0,0,0,r,i,a)}clear(){this._orderTextureCapacity=0,this.texture?.dispose(),this.texture=null}destroy(){this.texture?.dispose()}_evalTextureSize(t){const r=Math.ceil(Math.sqrt(t)),i=Math.ceil(t/r);return e(r,i)}}export{u as GaussianSplatOrderTexture};
2
+ import{reallocGrowthFactor as t}from"../../../../core/arrayUtils.js";import{fromValues as e}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import"../../../webgl/BufferObject.js";import"../../../webgl/FramebufferObject.js";import"../../../webgl/Program.js";import"../../../../core/has.js";import"../../../webgl/Renderbuffer.js";import r from"../../../webgl/Texture.js";import"../../../../core/Logger.js";import{PixelType as i,SizedPixelFormat as s}from"../../../webgl/enums.js";import"../../../webgl/Util.js";import{minExpectedGaussianCount as a}from"./GaussianSplatAtlasPages.js";import{TextureDescriptor as o}from"../../../webgl/TextureDescriptor.js";class u{constructor(t){this.texture=null,this._orderTextureCapacity=0,this._rctx=t}ensureCapacity(e){if(e<=0)return{textureWidth:0,rowCount:0,paddedSize:0};const u=this.texture;if(this._orderTextureCapacity>=e&&u?.hasWebGLTextureObject){const t=u.descriptor.width,r=Math.ceil(e/t);return{textureWidth:t,rowCount:r,paddedSize:t*r}}const c=Math.max(Math.ceil(e*t),a),[h,p]=this._evalTextureSize(c),d=h*p;this._orderTextureCapacity=d,this.texture?.dispose();const l=new o;l.width=h,l.height=p,l.pixelFormat=36244,l.dataType=i.UNSIGNED_INT,l.internalFormat=s.R32UI,l.wrapMode=33071,l.samplingMode=9728,l.isImmutable=!0,this.texture=new r(this._rctx,l);const n=Math.ceil(e/h);return{textureWidth:h,rowCount:n,paddedSize:h*n}}setData(t,e){const{textureWidth:r,rowCount:i,paddedSize:s}=this.ensureCapacity(e);if(t.length>=s)return void this.texture.updateData(0,0,0,r,i,t);const a=new Uint32Array(s);a.set(t.subarray(0,e)),this.texture.updateData(0,0,0,r,i,a)}clear(){this._orderTextureCapacity=0,this.texture?.dispose(),this.texture=null}destroy(){this.clear()}_evalTextureSize(t){const r=Math.ceil(Math.sqrt(t)),i=Math.ceil(t/r);return e(r,i)}}export{u as GaussianSplatOrderTexture};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{reallocGrowthFactor as t}from"../../../../core/arrayUtils.js";import"../../../webgl/BufferObject.js";import{FramebufferObject as e}from"../../../webgl/FramebufferObject.js";import"../../../webgl/Program.js";import"../../../../core/has.js";import"../../../webgl/Renderbuffer.js";import r from"../../../webgl/Texture.js";import"../../../../core/Logger.js";import{PixelType as s,SizedPixelFormat as a}from"../../../webgl/enums.js";import"../../../webgl/Util.js";import{initialSplatAtlasTextureHeight as i,GaussianSplatAtlasPages as o,splatAtlasTextureWidth as l,elementsPerSplatPage as h}from"./GaussianSplatAtlasPages.js";import{TextureDescriptor as u}from"../../../webgl/TextureDescriptor.js";class p{constructor(t,e,r){this._splatAtlasTextureHeight=i,this.texture=null,this._rctx=t,this._fboCache=r,this.pageAllocator=new o,this._cache=e.newCache("gaussian texture cache",t=>t.dispose())}ensureTextureAtlas(){if(this.texture)return;const t=this._cache.pop("splatTextureAtlas");if(t)return void(this.texture=t);const e=new u;e.height=this._splatAtlasTextureHeight,e.width=l,e.pixelFormat=36249,e.dataType=s.UNSIGNED_INT,e.internalFormat=a.RGBA32UI,e.samplingMode=9728,e.wrapMode=33071,e.isImmutable=!0,this.texture=new r(this._rctx,e),this._updatePageAllocator()}grow(){if(!this.texture)return this.ensureTextureAtlas(),!1;const r=Math.floor(this._splatAtlasTextureHeight*t);if(r*l>this._rctx.parameters.maxPreferredTexturePixels)return!1;const s=new e(this._rctx,this.texture),a=this._fboCache.acquire(l,r,"gaussian splat atlas resize",11);return this._rctx.blitFramebuffer(s,a.fbo,16384,9728,0,0,l,this._splatAtlasTextureHeight,0,0,l,this._splatAtlasTextureHeight),this.texture?.dispose(),this.texture=a.fbo?.detachColorTexture(),s.dispose(),a.dispose(),this._splatAtlasTextureHeight=r,this._updatePageAllocator(),!0}requestPage(){let t=this.pageAllocator.findFirstFreePage();return null===t&&this.grow()&&(t=this.pageAllocator.findFirstFreePage()),null!==t&&this.pageAllocator.allocate(t),t}freePage(t){this.pageAllocator.free(t)}update(t,e,r){this.ensureTextureAtlas(),this.texture.updateData(0,t,e,h,1,r)}_updatePageAllocator(){const t=l*this._splatAtlasTextureHeight/h;this.pageAllocator.pageCount!==t&&this.pageAllocator.resize(t)}clear(){this.texture&&(this._cache.put("splatTextureAtlas",this.texture),this.texture=null)}destroy(){this._cache.destroy(),this.texture?.dispose()}}export{p as GaussianSplatTextureAtlas};
2
+ import{reallocGrowthFactor as t}from"../../../../core/arrayUtils.js";import"../../../webgl/BufferObject.js";import{FramebufferObject as e}from"../../../webgl/FramebufferObject.js";import"../../../webgl/Program.js";import"../../../../core/has.js";import"../../../webgl/Renderbuffer.js";import r from"../../../webgl/Texture.js";import"../../../../core/Logger.js";import{PixelType as s,SizedPixelFormat as a}from"../../../webgl/enums.js";import"../../../webgl/Util.js";import{initialSplatAtlasTextureHeight as i,GaussianSplatAtlasPages as l,splatAtlasTextureWidth as o,elementsPerSplatPage as h}from"./GaussianSplatAtlasPages.js";import{TextureDescriptor as u}from"../../../webgl/TextureDescriptor.js";class p{constructor(t,e,r){this._splatAtlasTextureHeight=i,this.texture=null,this._rctx=t,this._fboCache=r,this.pageAllocator=new l,this._cache=e.newCache("gaussian texture cache",t=>t.dispose())}ensureTextureAtlas(){if(this.texture?.hasWebGLTextureObject)return;this.texture=null;const t=this._cache.pop("splatTextureAtlas");if(t)return void(this.texture=t);const e=new u;e.height=this._splatAtlasTextureHeight,e.width=o,e.pixelFormat=36249,e.dataType=s.UNSIGNED_INT,e.internalFormat=a.RGBA32UI,e.samplingMode=9728,e.wrapMode=33071,e.isImmutable=!0,this.texture=new r(this._rctx,e),this._updatePageAllocator()}grow(){if(!this.texture)return this.ensureTextureAtlas(),!1;const r=Math.floor(this._splatAtlasTextureHeight*t);if(r*o>this._rctx.parameters.maxPreferredTexturePixels)return!1;const s=new e(this._rctx,this.texture),a=this._fboCache.acquire(o,r,"gaussian splat atlas resize",11);return this._rctx.blitFramebuffer(s,a.fbo,16384,9728,0,0,o,this._splatAtlasTextureHeight,0,0,o,this._splatAtlasTextureHeight),this.texture?.dispose(),this.texture=a.fbo?.detachColorTexture(),s.dispose(),a.dispose(),this._splatAtlasTextureHeight=r,this._updatePageAllocator(),!0}requestPage(){let t=this.pageAllocator.findFirstFreePage();return null===t&&this.grow()&&(t=this.pageAllocator.findFirstFreePage()),null!==t&&this.pageAllocator.allocate(t),t}freePage(t){this.pageAllocator.free(t)}update(t,e,r){this.ensureTextureAtlas(),this.texture.updateData(0,t,e,h,1,r)}_updatePageAllocator(){const t=o*this._splatAtlasTextureHeight/h;this.pageAllocator.pageCount!==t&&this.pageAllocator.resize(t)}clear(){this.texture&&(this._cache.put("splatTextureAtlas",this.texture),this.texture=null)}destroy(){this._cache.destroy(),this.texture?.dispose(),this.texture=null}}export{p as GaussianSplatTextureAtlas};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import has from"../../../core/has.js";import{disposeMaybe as t}from"../../../core/maybe.js";import{MemCachePool as i}from"../../../core/MemCachePool.js";import r from"../../../core/ObjectPool.js";import{watch as s,sync as n}from"../../../core/reactiveUtils.js";import{property as a,subclass as l}from"../../../core/accessorSupport/decorators.js";import{subtract as o,set as c,dot as d}from"../../../core/libs/gl-matrix-2/math/vec3.js";import{ZEROS as h,fromValues as u,create as _}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{fromValues as g,ZEROS as f}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{create as p,set as m}from"../../../geometry/support/aaBoundingBox.js";import{BufferViewVec3f as y}from"../../../geometry/support/buffer/BufferView.js";import{overlayRenderOccludedFlag as b}from"./OverlayRenderer.js";import{PatchRenderData as x}from"./PatchRenderData.js";import{TerrainAttributesCache as T}from"./TerrainAttributesCache.js";import{enableTerrainInternalChecks as R}from"./terrainUtils.js";import{TileRenderer as v}from"./TileRenderer.js";import{IteratorPreorder as O,fallsWithinLayerView as P,sortTiles as w,compareTiles as D}from"./tileUtils.js";import{getOverlayContentForOutputTerrain as S}from"../webgl-engine/core/shaderLibrary/terrain/Overlay.glsl.js";import{SyncRenderPlugin as B}from"../webgl-engine/effects/RenderPlugin.js";import{Vertices as E}from"../webgl-engine/lib/Attribute.js";import{IntersectorResult as F}from"../webgl-engine/lib/IntersectorResult.js";import{intersectAabbInvDirBefore as j,MeshIntersectionOptions as q,intersectTriangles as C}from"../webgl-engine/lib/RayIntersections.js";import{TriangleIntersectionData as A}from"../webgl-engine/lib/TriangleIntersectionData.js";import{terrainId as M,getVerticalOffsetTerrain as G}from"../webgl-engine/lib/verticalOffsetUtils.js";import{DrawParameters as U}from"../webgl-engine/materials/DrawParameters.js";import{T as k}from"../../../chunks/Terrain.glsl.js";import{TerrainTechnique as I}from"../webgl-engine/shaders/TerrainTechnique.js";import{TerrainTechniqueConfiguration as N}from"../webgl-engine/shaders/TerrainTechniqueConfiguration.js";import{PrimitiveType as L}from"../../webgl/enums.js";const V=7,z=10,H=200,Q=p();let W=class extends B{get visibleTiles(){return Array.from(this._visiblePatchesByOrigin.values()).flat()}get _isGlobal(){return 1===this._stage.viewingMode}get _techniques(){return this._context.techniques}get _rctx(){return this._context.renderContext.rctx}get renderOccludedFlags(){return this._overlayRenderer.renderOccludedFlags}constructor(e,t,s,n,a){super({}),this._overlayRenderer=e,this._stage=t,this._allTiles=s,this._compressionTracker=n,this.type=7,this.isGround=!0,this._passParameters=new k,this._drawParameters=new U,this._renderDataPool=new r(()=>new x),this._visiblePatchesByOrigin=new Map,this._allPatchesByOrigin=new Map,this._patchesByOriginDirty=!0,this._patchSortingDirty=!0,this._tileIterator=new O,this._castShadows=!1,this._inViewshed=!1,this._cutFillEnabled=!1,this._tileRenderer=null,this._stencilEnabledLayerExtents=new Array,this._numTilesRendered=0,this._numTilesCulled=0,this._numOriginsRendered=0,this.produces=new Map([[1,()=>1===this._desiredSlot],[6,()=>6===this._desiredSlot],[7,()=>7===this._desiredSlot],[10,()=>this._produces()&&this.renderOccludedFlags===b]]),this._tileSize=256,this._configuration=new N(1===t.viewingMode),this._tileTextureCache=new i((e,t)=>a.newCache(e,t),"TileTexture"),this.tileGeometryCache=new T(a)}normalizeCtorArgs(){return{}}initialize(){this._stage.addRenderPlugin(this),this.addHandles(s(()=>this._overlayRenderer.renderOccludedFlags,()=>this.setNeedsRender(),n))}destroy(){this._stage.removeRenderPlugin(this),this._tileTextureCache.destroy(),this.tileGeometryCache.destroy(),this._allTiles.prune(),this._tileRenderer=null}get _oitEnabled(){return this._stage.renderer.oitEnabled}_produces(){return this.visible&&!!this._rootTiles&&!this.renderingDisabled}set renderingDisabled(e){this._set("renderingDisabled",!!e),this.setDirty()}set visible(e){this._set("visible",!!e),this.setDirty()}updateHeading(e){this._tileRenderer?.updateHeading(e)}set transparency(e){this._configuration.transparencyMode!==e&&(this._configuration.transparencyMode=e,this.setNeedsRender())}get transparency(){return this._configuration.transparencyMode}get renderPatchBorders(){return this._configuration.tileBorders}set renderPatchBorders(e){this._configuration.tileBorders!==e&&(this._configuration.tileBorders=e,this.setNeedsRender(),this.notifyChange("renderPatchBorders"))}get layerViewUid(){return M}get slicePlaneEnabled(){return this._configuration.hasSlicePlane}set slicePlaneEnabled(e){this._configuration.hasSlicePlane!==e&&(this._configuration.hasSlicePlane=e,this.setNeedsRender())}set textureFadingEnabled(e){this._configuration.textureFadingEnabled!==e&&(this._configuration.textureFadingEnabled=e,this.setNeedsRender())}set pbrMode(e){this._configuration.pbrMode!==e&&(this._configuration.pbrMode=e,this.setNeedsRender())}setRootTiles(e){this._rootTiles=e,this.setDirty()}setStencilEnabledLayerExtents(e){this._stencilEnabledLayerExtents=e,this._setSortingDirty()}set tileSize(e){this._tileSize=e,null!=this._tileRenderer&&(this._tileRenderer.tileSize=e),this.setDirty()}get tileSize(){return this._tileSize}_ensureRenderData(e){e.renderData||(e.renderData=this._renderDataPool.acquire(),e.renderData.init(e,this._getLocalOriginOfTile(e)))}loadTile(e){this._ensureRenderData(e),this.updateTileGeometryState(e),this.reuseTextureFromParent(e)||this.updateTileTexture(e,32)}reuseTextureFromParent(e){const{parent:t}=e;if(!this._canReuseTextureFromParent(t,e))return!1;const i=g(1&e.lij[2]?.5:0,1&e.lij[1]?0:.5,.5,.5);return t.renderData?.reuseTexture(e.renderData,i)??!1}_canReuseTextureFromParent(e,t){if(!e)return!1;const{layerInfo:i,surface:r}=t;for(let s=0;s<i[1].length;s++){const i=r.layerViewByIndex(s,1);if(P(e,i)!==P(t,i))return!1}return!0}updateTileTexture(e,t){null!=this._tileRenderer&&(this._tileRenderer.updateTileTexture(e,32===t?0:2),this.setNeedsRender(),e.resetPendingUpdate(t))}updateTileGeometryState(e){for(const i of e.layerInfo[0])i.pendingUpdates&=-9;e.resetPendingUpdate(8);const t=e.renderData.updateGeometryState();return t&&this.setDirty(),t}updateGeometryIfNeeded(e){e.loaded&&e.renderData.updateGeometryIfNeeded(this._rctx)}unloadTile(e){const t=e.renderData;t&&(t.releaseGeometry(),this._renderDataPool.release(t),t.clear(),e.renderData=null,e.setMemoryDirty(),this.setDirty())}_getLocalOriginOfTile(e){const t=z-V,i=Math.max(0,Math.floor((e.level-t)/V)*V);if(this._isGlobal&&0===i)return h;for(;e.parent&&e.level>i;)e=e.parent;return e.centerAtSeaLevel}getStats(){return{numTilesRendered:this._numTilesRendered,numTilesCulled:this._numTilesCulled,numOriginsRendered:this._numOriginsRendered}}set wireframe(e){this._get("wireframe")!==e&&(this._set("wireframe",e),this.setNeedsRender())}setDirty(e=1){this._patchesByOriginDirty=!0,this._context.requestRender(e)}_setSortingDirty(e=1){this._patchSortingDirty=!0,this._context.requestRender(e)}setNeedsRender(e=1){this._context.requestRender(e)}initializeRenderContext(e){this._context=e,this._tileRenderer=new v(this._rctx,this._tileSize,this._techniques,this._tileTextureCache,this._compressionTracker),this.updateTileBackground()}uninitializeRenderContext(){this._tileRenderer=t(this._tileRenderer)}intersect(e,t,i,r){if(!this._rootTiles||e.options.selectOpaqueTerrainOnly&&e.options.selectionMode&&0!==this.transparency)return;const s=Z,n=J;o(s,r,i),c(n,1/s[0],1/s[1],1/s[2]);const a=e.results.min,l=e.results.max,h=e.results.ground,u=0===e.options.store,_=!!e.results.ground.target,g=G(e.verticalOffset),f=e.tolerance;let p,b=u&&null!=a.distance?a.distance:1/0;const x=e.options,T=x.normalRequired||!x.backfacesTerrain,R=new q(f,!1,T),v=c=>{const _=c.renderData;if(!_?.vao)return;const v=_.geometry;m(Q,v.boundingBox);const O=_.localOrigin;null!=g&&(g.localOrigin=O,g.applyToAabb(Q));const P=Q;if(K[0]=i[0]-O[0],K[1]=i[1]-O[1],K[2]=i[2]-O[2],!j(P,K,n,f,b))return;const w=(e,t,i)=>{e.set(this.type,c,t,i),b=u&&null!=a.distance?a.distance:1/0},D=(n,o,c)=>{if((!T||null!=c)&&n>=0&&(x.backfacesTerrain||d(c,s)<0)&&(x.invisibleTerrain||!x.selectionMode||null==t||t(i,r,n))){if((null==h.distance||n<h.distance)&&w(h,n,c),x.isFiltered)return;2===x.store&&(null==p?(p=new F(e.ray),w(p,n,c),e.results.all.push(p)):n<p.distance&&w(p,n,c)),(null==a.distance||n<a.distance)&&w(a,n,c),0!==x.store&&(null==l.distance||n>l.distance)&&w(l,n,c)}},S=X;o(S,r,O);const{indices:B,indexCount:q}=v,M=v.vertexAttributes,G=M.getField("position",y),U=new E(G.typedBuffer,3,M.stride/4),k=q/3;if(!g&&k>H){const e=c.renderData;e.intersectionData??=new A(B,k,U),e.intersectionData.intersectRay(K,S,R,D)}else C(K,S,0,k,B,U,g,R,D)},O=this._rootTiles;if(null!=O){(()=>{const t=this._tileIterator;t.reset(O);const r=e.options.invisibleTerrain;for(let e=t.next();e;e=t.next())!(e.visible||r&&e.intersectsClippingArea)||null==g&&!e.intersectsRay(i,s,f,b)||_&&this._useStencilForTile(e)?t.skipSubtree():v(e)})()}}processScaleRangeQueries(e,t){if(!t.done&&e)for(this._updatePatchGroups();e.updating&&!t.done;){e.prepare();for(const t of this._visiblePatchesByOrigin.values())for(const i of t)null!=i.renderData?.textureReference&&e.queriesForTile(i);e.process(),t.madeProgress()}}get _desiredSlot(){if(!this._produces())return null;switch(this.transparency){case 0:return 1;case 1:case 2:return this._oitEnabled?7:6;case 3:case 4:return null}}acquireTechniques(e){const{shadowMap:t,viewshedEnabled:i,cutFillEnabled:r,slot:s,hasEmission:n,hasFloatOit:a}=e.bind,l=!!has("enable-feature:terrain-shadows")&&t.enabled;if(l!==this._castShadows&&(this._castShadows=l,this._patchesByOriginDirty=!0),this._inViewshed!==i&&(this._inViewshed=i,this._patchesByOriginDirty=!0),this._cutFillEnabled!==r&&(this._cutFillEnabled=r,this._patchesByOriginDirty=!0),3===this.transparency)return null;if(10===s){if(0===(e.renderOccludedMask&b))return null}else if(s!==this._desiredSlot)return null;const o=this._configuration;switch(o.screenSpaceReflections=o.cloudReflections=o.receiveShadows=o.receiveAmbientOcclusion=o.renderOccluded=o.hasHighlightMixTexture=o.hasEmission=!1,o.overlayMode=this._overlayRenderer.mode,o.hasFloatOit=a,e.output){case 0:case 1:case 2:{const{ssr:i,clouds:r,ssao:a}=e.bind;o.screenSpaceReflections=null!=i.lastFrameColor,o.cloudReflections=null!=r.data;const l=10===s;return o.receiveShadows=t.ready&&!l,o.renderOccluded=l,o.receiveAmbientOcclusion=!l&&null!=a,o.hasEmission=n,this._acquireTechnique(e.output)}case 5:case 7:return this._castShadows?this._acquireTechnique(5):null;case 8:return this._inViewshed?this._acquireTechnique(8):null;case 9:return this._cutFillEnabled?this._acquireTechnique(9):null;case 3:case 4:return this._acquireTechnique(e.output);case 11:return this._acquireTechnique(11);case 10:return o.hasHighlightMixTexture=null!=e.bind.highlightMixTexture,this._overlayRenderer.hasHighlights?this._acquireTechnique(10):null}return null}render(e,t){switch(this._updatePatchGroups(),t.useStencil=!1,this._passParameters.overlayContent=S(e.output,e.bind),e.output){case 0:case 1:case 2:return this._renderMaterialPass(e,t);case 3:case 4:case 11:return this._renderAuxiliaryPass(e,t,this._visiblePatchesByOrigin);case 10:{const i=e.bind.highlight?.name;i&&this._overlayRenderer.hasHighlights&&this._overlayRenderer.renders(2)&&this._overlayRenderer.hasHighlight(i)&&this._renderAuxiliaryPass(e,t,this._visiblePatchesByOrigin);break}case 5:case 7:case 8:case 9:return this._renderAuxiliaryPass(e,t,this._allPatchesByOrigin)}}updateTileBackground(e){if(null==this._tileRenderer)return;const t=this._tileRenderer;let i;if(null!=e){const t=e.toUnitRGBA();i=u(t[0]||0,t[1]||0,t[2]||0)}t.setBackground(i),this._allTiles.forAll(e=>t.updateTileTexture(e,0)),this._configuration.tileBlendInput=t.backgroundIsGrid?2:null!=t.backgroundColor?1:0,this.setNeedsRender()}_updatePatchGroups(){if(this._patchesByOriginDirty&&(this._rebuildPatchGroups(),this._patchesByOriginDirty=!1,this._patchSortingDirty=!0),this._patchSortingDirty){const e=Array.from(this._visiblePatchesByOrigin.values()),t=this._stencilEnabledLayerExtents;for(const i of e)w(i,t);e.sort((e,t)=>D(e[0],t[0])),this._visiblePatchesByOrigin=new Map(e.map(e=>[e[0].renderData.localOrigin,e])),this.notifyChange("visibleTiles"),this._patchSortingDirty=!1}}_rebuildPatchGroups(){const e=this._rootTiles;if(null!=e){e[0]?.surface.checkAllTilesWaterproofness(),this._visiblePatchesByOrigin.clear(),this._allPatchesByOrigin.clear();for(const t of e)this._rebuildPatchGroupsForRootTile(t)}}_rebuildPatchGroupsForRootTile(e){const t=this._tileIterator;for(t.resetOne(e);!t.done;){const e=t.next(),i=e.renderData;if(!i){this._numTilesCulled++;continue}const r=i.localOrigin;if(this._castShadows||this._inViewshed||this._cutFillEnabled){let t=this._allPatchesByOrigin.get(r);t||(t=[],this._allPatchesByOrigin.set(r,t)),t.push(e)}if(!e.visible){this._numTilesCulled++,t.skipSubtree();continue}let s=this._visiblePatchesByOrigin.get(r);s||(s=[],this._visiblePatchesByOrigin.set(r,s)),s.push(e),t.skipSubtree()}}_useStencilForTile(e){for(const t of this._stencilEnabledLayerExtents)if(e.intersectsExtent(t))return!0;return!1}_renderAuxiliaryPass(e,t,i){const{rctx:r,bind:s}=e;r.bindTechnique(t,s,this._passParameters);const n=this._stencilEnabledLayerExtents.length>0;i.forEach(i=>{this._drawParameters.origin=i[0].renderData.localOrigin,t.program.bindDraw(s,this._passParameters,this._drawParameters);for(let r=0;r<i.length;r++)this._renderPatch(e,t,i[r],L.TRIANGLES,n,null===this._passParameters.overlayContent)}),r.bindVAO(null)}_renderMaterialPass(e,t){const{rctx:i,bind:r}=e,s=i.bindTechnique(t,r,this._passParameters);this._numTilesRendered=0,this._numTilesCulled=0,this._numOriginsRendered=0;const n=10===r.slot;n&&(s.bindTexture("tex",i.emptyTexture),s.setUniform3fv("textureOpacities",h),s.setUniform4fv("texOffsetAndScale",f));const a=null!=this._tileRenderer?.backgroundColor?this._tileRenderer.backgroundColor:h;1===this._configuration.tileBlendInput&&s.setUniform3fv("backgroundColor",a);const l=this._stencilEnabledLayerExtents.length>0,o=this.wireframe?L.LINES:L.TRIANGLES;this._configuration.textureFadingEnabled&&s.bindTexture("texNext",i.emptyTexture);const c=this._visiblePatchesByOrigin;for(const d of c.values()){const i=d[0].renderData.localOrigin;this._drawParameters.origin=i,t.program.bindDraw(r,this._passParameters,this._drawParameters),this._numOriginsRendered++;for(const r of d){const i=r.renderData,a=i.textureReference;if(null!=a){if(!n){s.setUniform4fv("texOffsetAndScale",a.offsetAndScale),s.bindTexture("tex",a.texture.texture);const e=i.textureFadeFactor,t=e<1?i.nextTextureReference:null;this._configuration.textureFadingEnabled&&t&&e<1?(s.setUniform1f("fadeFactor",e),s.setUniform4fv("nextTexOffsetAndScale",t.offsetAndScale),s.setUniform3fv("nextTexOpacities",t.opacities),s.bindTexture("texNext",t.texture.texture)):s.setUniform1f("fadeFactor",1),i.textureIsFading&&this.setNeedsRender(2),s.setUniform3fv("textureOpacities",a.opacities)}this._renderPatch(e,t,r,o,l),r.renderOrder=this._numTilesRendered,this._numTilesRendered++}}}i.bindVAO(null)}_renderPatch(e,t,i,r,s,n=!1){const a=i.renderData,l=a.vao,o=l?.indexBuffer;if(!l||null==o)return void(R&&console.error("Rendered tile with no indices: ",i.lij," : ",a));const c=t.program;n||this._overlayRenderer.isEmpty||this._bindOverlayPatchData(c,a.overlay);const{rctx:d,bind:h}=e;s&&(t.useStencil=this._useStencilForTile(i),d.setPipelineState(t.getPipeline(h)));const u=a.geometry.indexCount;d.bindVAO(l),c.assertCompatibleVertexAttributeLocations(l),d.drawElements(r,u,o.indexType,0)}_bindOverlayPatchData(e,t){e.setUniform4fv("overlayTexOffset",t.offsets),e.setUniform4fv("overlayTexScale",t.scales)}_acquireTechnique(e){return this._configuration.output=e,this._techniques.get(I,this._configuration)}get test(){}hasHighlight(e){return this._overlayRenderer.hasHighlight(e)}};e([a({readOnly:!0})],W.prototype,"visibleTiles",null),e([a({readOnly:!0})],W.prototype,"_isGlobal",null),e([a()],W.prototype,"renderOccludedFlags",null),e([a({value:!1})],W.prototype,"renderingDisabled",null),e([a({value:!0})],W.prototype,"visible",null),e([a()],W.prototype,"renderPatchBorders",null),e([a()],W.prototype,"wireframe",null),W=e([l("esri.views.3d.terrain.TerrainRenderer")],W);const Z=_(),J=_(),K=_(),X=_();export{W as TerrainRenderer};
2
+ import{__decorate as e}from"tslib";import has from"../../../core/has.js";import{disposeMaybe as t}from"../../../core/maybe.js";import{MemCachePool as i}from"../../../core/MemCachePool.js";import r from"../../../core/ObjectPool.js";import{watch as s,sync as n}from"../../../core/reactiveUtils.js";import{property as a,subclass as l}from"../../../core/accessorSupport/decorators.js";import{subtract as o,set as c,dot as d}from"../../../core/libs/gl-matrix-2/math/vec3.js";import{ZEROS as h,fromValues as u,create as _}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{fromValues as g,ZEROS as f}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{create as p,set as m}from"../../../geometry/support/aaBoundingBox.js";import{BufferViewVec3f as y}from"../../../geometry/support/buffer/BufferView.js";import{overlayRenderOccludedFlag as b}from"./OverlayRenderer.js";import{PatchRenderData as x}from"./PatchRenderData.js";import{TerrainAttributesCache as T}from"./TerrainAttributesCache.js";import{enableTerrainInternalChecks as R}from"./terrainUtils.js";import{TileRenderer as v}from"./TileRenderer.js";import{IteratorPreorder as O,fallsWithinLayerView as P,sortTiles as w,compareTiles as D}from"./tileUtils.js";import{getOverlayContentForOutputTerrain as S}from"../webgl-engine/core/shaderLibrary/terrain/Overlay.glsl.js";import{SyncRenderPlugin as B}from"../webgl-engine/effects/RenderPlugin.js";import{Vertices as E}from"../webgl-engine/lib/Attribute.js";import{IntersectorResult as F}from"../webgl-engine/lib/IntersectorResult.js";import{intersectAabbInvDirBefore as j,MeshIntersectionOptions as q,intersectTriangles as C}from"../webgl-engine/lib/RayIntersections.js";import{TriangleIntersectionData as A}from"../webgl-engine/lib/TriangleIntersectionData.js";import{terrainId as M,getVerticalOffsetTerrain as G}from"../webgl-engine/lib/verticalOffsetUtils.js";import{DrawParameters as U}from"../webgl-engine/materials/DrawParameters.js";import{T as k}from"../../../chunks/Terrain.glsl.js";import{TerrainTechnique as I}from"../webgl-engine/shaders/TerrainTechnique.js";import{TerrainTechniqueConfiguration as N}from"../webgl-engine/shaders/TerrainTechniqueConfiguration.js";import{PrimitiveType as L}from"../../webgl/enums.js";const V=7,z=10,H=200,Q=p();let W=class extends B{get visibleTiles(){return Array.from(this._visiblePatchesByOrigin.values()).flat()}get _isGlobal(){return 1===this._stage.viewingMode}get _techniques(){return this._context.techniques}get _rctx(){return this._context.renderContext.rctx}get renderOccludedFlags(){return this._overlayRenderer.renderOccludedFlags}constructor(e,t,s,n,a){super({}),this._overlayRenderer=e,this._stage=t,this._allTiles=s,this._compressionTracker=n,this.type=7,this.isGround=!0,this._passParameters=new k,this._drawParameters=new U,this._renderDataPool=new r(()=>new x),this._visiblePatchesByOrigin=new Map,this._allPatchesByOrigin=new Map,this._patchesByOriginDirty=!0,this._patchSortingDirty=!0,this._tileIterator=new O,this._castShadows=!1,this._inViewshed=!1,this._cutFillEnabled=!1,this._tileRenderer=null,this._stencilEnabledLayerExtents=new Array,this._numTilesRendered=0,this._numTilesCulled=0,this._numOriginsRendered=0,this.produces=new Map([[1,()=>1===this._desiredSlot],[6,()=>6===this._desiredSlot],[8,()=>8===this._desiredSlot],[10,()=>this._produces()&&this.renderOccludedFlags===b]]),this._tileSize=256,this._configuration=new N(1===t.viewingMode),this._tileTextureCache=new i((e,t)=>a.newCache(e,t),"TileTexture"),this.tileGeometryCache=new T(a)}normalizeCtorArgs(){return{}}initialize(){this._stage.addRenderPlugin(this),this.addHandles(s(()=>this._overlayRenderer.renderOccludedFlags,()=>this.setNeedsRender(),n))}destroy(){this._stage.removeRenderPlugin(this),this._tileTextureCache.destroy(),this.tileGeometryCache.destroy(),this._allTiles.prune(),this._tileRenderer=null}get _oitEnabled(){return this._stage.renderer.oitEnabled}_produces(){return this.visible&&!!this._rootTiles&&!this.renderingDisabled}set renderingDisabled(e){this._set("renderingDisabled",!!e),this.setDirty()}set visible(e){this._set("visible",!!e),this.setDirty()}updateHeading(e){this._tileRenderer?.updateHeading(e)}set transparency(e){this._configuration.transparencyMode!==e&&(this._configuration.transparencyMode=e,this.setNeedsRender())}get transparency(){return this._configuration.transparencyMode}get renderPatchBorders(){return this._configuration.tileBorders}set renderPatchBorders(e){this._configuration.tileBorders!==e&&(this._configuration.tileBorders=e,this.setNeedsRender(),this.notifyChange("renderPatchBorders"))}get layerViewUid(){return M}get slicePlaneEnabled(){return this._configuration.hasSlicePlane}set slicePlaneEnabled(e){this._configuration.hasSlicePlane!==e&&(this._configuration.hasSlicePlane=e,this.setNeedsRender())}set textureFadingEnabled(e){this._configuration.textureFadingEnabled!==e&&(this._configuration.textureFadingEnabled=e,this.setNeedsRender())}set pbrMode(e){this._configuration.pbrMode!==e&&(this._configuration.pbrMode=e,this.setNeedsRender())}setRootTiles(e){this._rootTiles=e,this.setDirty()}setStencilEnabledLayerExtents(e){this._stencilEnabledLayerExtents=e,this._setSortingDirty()}set tileSize(e){this._tileSize=e,null!=this._tileRenderer&&(this._tileRenderer.tileSize=e),this.setDirty()}get tileSize(){return this._tileSize}_ensureRenderData(e){e.renderData||(e.renderData=this._renderDataPool.acquire(),e.renderData.init(e,this._getLocalOriginOfTile(e)))}loadTile(e){this._ensureRenderData(e),this.updateTileGeometryState(e),this.reuseTextureFromParent(e)||this.updateTileTexture(e,32)}reuseTextureFromParent(e){const{parent:t}=e;if(!this._canReuseTextureFromParent(t,e))return!1;const i=g(1&e.lij[2]?.5:0,1&e.lij[1]?0:.5,.5,.5);return t.renderData?.reuseTexture(e.renderData,i)??!1}_canReuseTextureFromParent(e,t){if(!e)return!1;const{layerInfo:i,surface:r}=t;for(let s=0;s<i[1].length;s++){const i=r.layerViewByIndex(s,1);if(P(e,i)!==P(t,i))return!1}return!0}updateTileTexture(e,t){null!=this._tileRenderer&&(this._tileRenderer.updateTileTexture(e,32===t?0:2),this.setNeedsRender(),e.resetPendingUpdate(t))}updateTileGeometryState(e){for(const i of e.layerInfo[0])i.pendingUpdates&=-9;e.resetPendingUpdate(8);const t=e.renderData.updateGeometryState();return t&&this.setDirty(),t}updateGeometryIfNeeded(e){e.loaded&&e.renderData.updateGeometryIfNeeded(this._rctx)}unloadTile(e){const t=e.renderData;t&&(t.releaseGeometry(),this._renderDataPool.release(t),t.clear(),e.renderData=null,e.setMemoryDirty(),this.setDirty())}_getLocalOriginOfTile(e){const t=z-V,i=Math.max(0,Math.floor((e.level-t)/V)*V);if(this._isGlobal&&0===i)return h;for(;e.parent&&e.level>i;)e=e.parent;return e.centerAtSeaLevel}getStats(){return{numTilesRendered:this._numTilesRendered,numTilesCulled:this._numTilesCulled,numOriginsRendered:this._numOriginsRendered}}set wireframe(e){this._get("wireframe")!==e&&(this._set("wireframe",e),this.setNeedsRender())}setDirty(e=1){this._patchesByOriginDirty=!0,this._context.requestRender(e)}_setSortingDirty(e=1){this._patchSortingDirty=!0,this._context.requestRender(e)}setNeedsRender(e=1){this._context.requestRender(e)}initializeRenderContext(e){this._context=e,this._tileRenderer=new v(this._rctx,this._tileSize,this._techniques,this._tileTextureCache,this._compressionTracker),this.updateTileBackground()}uninitializeRenderContext(){this._tileRenderer=t(this._tileRenderer)}intersect(e,t,i,r){if(!this._rootTiles||e.options.selectOpaqueTerrainOnly&&e.options.selectionMode&&0!==this.transparency)return;const s=Z,n=J;o(s,r,i),c(n,1/s[0],1/s[1],1/s[2]);const a=e.results.min,l=e.results.max,h=e.results.ground,u=0===e.options.store,_=!!e.results.ground.target,g=G(e.verticalOffset),f=e.tolerance;let p,b=u&&null!=a.distance?a.distance:1/0;const x=e.options,T=x.normalRequired||!x.backfacesTerrain,R=new q(f,!1,T),v=c=>{const _=c.renderData;if(!_?.vao)return;const v=_.geometry;m(Q,v.boundingBox);const O=_.localOrigin;null!=g&&(g.localOrigin=O,g.applyToAabb(Q));const P=Q;if(K[0]=i[0]-O[0],K[1]=i[1]-O[1],K[2]=i[2]-O[2],!j(P,K,n,f,b))return;const w=(e,t,i)=>{e.set(this.type,c,t,i),b=u&&null!=a.distance?a.distance:1/0},D=(n,o,c)=>{if((!T||null!=c)&&n>=0&&(x.backfacesTerrain||d(c,s)<0)&&(x.invisibleTerrain||!x.selectionMode||null==t||t(i,r,n))){if((null==h.distance||n<h.distance)&&w(h,n,c),x.isFiltered)return;2===x.store&&(null==p?(p=new F(e.ray),w(p,n,c),e.results.all.push(p)):n<p.distance&&w(p,n,c)),(null==a.distance||n<a.distance)&&w(a,n,c),0!==x.store&&(null==l.distance||n>l.distance)&&w(l,n,c)}},S=X;o(S,r,O);const{indices:B,indexCount:q}=v,M=v.vertexAttributes,G=M.getField("position",y),U=new E(G.typedBuffer,3,M.stride/4),k=q/3;if(!g&&k>H){const e=c.renderData;e.intersectionData??=new A(B,k,U),e.intersectionData.intersectRay(K,S,R,D)}else C(K,S,0,k,B,U,g,R,D)},O=this._rootTiles;if(null!=O){(()=>{const t=this._tileIterator;t.reset(O);const r=e.options.invisibleTerrain;for(let e=t.next();e;e=t.next())!(e.visible||r&&e.intersectsClippingArea)||null==g&&!e.intersectsRay(i,s,f,b)||_&&this._useStencilForTile(e)?t.skipSubtree():v(e)})()}}processScaleRangeQueries(e,t){if(!t.done&&e)for(this._updatePatchGroups();e.updating&&!t.done;){e.prepare();for(const t of this._visiblePatchesByOrigin.values())for(const i of t)null!=i.renderData?.textureReference&&e.queriesForTile(i);e.process(),t.madeProgress()}}get _desiredSlot(){if(!this._produces())return null;switch(this.transparency){case 0:return 1;case 1:case 2:return this._oitEnabled?8:6;case 3:case 4:return null}}acquireTechniques(e){const{shadowMap:t,viewshedEnabled:i,cutFillEnabled:r,slot:s,hasEmission:n,hasFloatOit:a}=e.bind,l=!!has("enable-feature:terrain-shadows")&&t.enabled;if(l!==this._castShadows&&(this._castShadows=l,this._patchesByOriginDirty=!0),this._inViewshed!==i&&(this._inViewshed=i,this._patchesByOriginDirty=!0),this._cutFillEnabled!==r&&(this._cutFillEnabled=r,this._patchesByOriginDirty=!0),3===this.transparency)return null;if(10===s){if(0===(e.renderOccludedMask&b))return null}else if(s!==this._desiredSlot)return null;const o=this._configuration;switch(o.screenSpaceReflections=o.cloudReflections=o.receiveShadows=o.receiveAmbientOcclusion=o.renderOccluded=o.hasHighlightMixTexture=o.hasEmission=!1,o.overlayMode=this._overlayRenderer.mode,o.hasFloatOit=a.value,e.output){case 0:case 1:case 2:{const{ssr:i,clouds:r,ssao:a}=e.bind;o.screenSpaceReflections=null!=i.lastFrameColor,o.cloudReflections=null!=r.data;const l=10===s;return o.receiveShadows=t.ready&&!l,o.renderOccluded=l,o.receiveAmbientOcclusion=!l&&null!=a,o.hasEmission=n,this._acquireTechnique(e.output)}case 5:case 7:return this._castShadows?this._acquireTechnique(5):null;case 8:return this._inViewshed?this._acquireTechnique(8):null;case 9:return this._cutFillEnabled?this._acquireTechnique(9):null;case 3:case 4:return this._acquireTechnique(e.output);case 11:return this._acquireTechnique(11);case 10:return o.hasHighlightMixTexture=null!=e.bind.highlightMixTexture,this._overlayRenderer.hasHighlights?this._acquireTechnique(10):null}return null}render(e,t){switch(this._updatePatchGroups(),t.useStencil=!1,this._passParameters.overlayContent=S(e.output,e.bind),e.output){case 0:case 1:case 2:return this._renderMaterialPass(e,t);case 3:case 4:case 11:return this._renderAuxiliaryPass(e,t,this._visiblePatchesByOrigin);case 10:{const i=e.bind.highlight?.name;i&&this._overlayRenderer.hasHighlights&&this._overlayRenderer.renders(2)&&this._overlayRenderer.hasHighlight(i)&&this._renderAuxiliaryPass(e,t,this._visiblePatchesByOrigin);break}case 5:case 7:case 8:case 9:return this._renderAuxiliaryPass(e,t,this._allPatchesByOrigin)}}updateTileBackground(e){if(null==this._tileRenderer)return;const t=this._tileRenderer;let i;if(null!=e){const t=e.toUnitRGBA();i=u(t[0]||0,t[1]||0,t[2]||0)}t.setBackground(i),this._allTiles.forAll(e=>t.updateTileTexture(e,0)),this._configuration.tileBlendInput=t.backgroundIsGrid?2:null!=t.backgroundColor?1:0,this.setNeedsRender()}_updatePatchGroups(){if(this._patchesByOriginDirty&&(this._rebuildPatchGroups(),this._patchesByOriginDirty=!1,this._patchSortingDirty=!0),this._patchSortingDirty){const e=Array.from(this._visiblePatchesByOrigin.values()),t=this._stencilEnabledLayerExtents;for(const i of e)w(i,t);e.sort((e,t)=>D(e[0],t[0])),this._visiblePatchesByOrigin=new Map(e.map(e=>[e[0].renderData.localOrigin,e])),this.notifyChange("visibleTiles"),this._patchSortingDirty=!1}}_rebuildPatchGroups(){const e=this._rootTiles;if(null!=e){e[0]?.surface.checkAllTilesWaterproofness(),this._visiblePatchesByOrigin.clear(),this._allPatchesByOrigin.clear();for(const t of e)this._rebuildPatchGroupsForRootTile(t)}}_rebuildPatchGroupsForRootTile(e){const t=this._tileIterator;for(t.resetOne(e);!t.done;){const e=t.next(),i=e.renderData;if(!i){this._numTilesCulled++;continue}const r=i.localOrigin;if(this._castShadows||this._inViewshed||this._cutFillEnabled){let t=this._allPatchesByOrigin.get(r);t||(t=[],this._allPatchesByOrigin.set(r,t)),t.push(e)}if(!e.visible){this._numTilesCulled++,t.skipSubtree();continue}let s=this._visiblePatchesByOrigin.get(r);s||(s=[],this._visiblePatchesByOrigin.set(r,s)),s.push(e),t.skipSubtree()}}_useStencilForTile(e){for(const t of this._stencilEnabledLayerExtents)if(e.intersectsExtent(t))return!0;return!1}_renderAuxiliaryPass(e,t,i){const{rctx:r,bind:s}=e;r.bindTechnique(t,s,this._passParameters);const n=this._stencilEnabledLayerExtents.length>0;i.forEach(i=>{this._drawParameters.origin=i[0].renderData.localOrigin,t.program.bindDraw(s,this._passParameters,this._drawParameters);for(let r=0;r<i.length;r++)this._renderPatch(e,t,i[r],L.TRIANGLES,n,null===this._passParameters.overlayContent)}),r.bindVAO(null)}_renderMaterialPass(e,t){const{rctx:i,bind:r}=e,s=i.bindTechnique(t,r,this._passParameters);this._numTilesRendered=0,this._numTilesCulled=0,this._numOriginsRendered=0;const n=10===r.slot;n&&(s.bindTexture("tex",i.emptyTexture),s.setUniform3fv("textureOpacities",h),s.setUniform4fv("texOffsetAndScale",f));const a=null!=this._tileRenderer?.backgroundColor?this._tileRenderer.backgroundColor:h;1===this._configuration.tileBlendInput&&s.setUniform3fv("backgroundColor",a);const l=this._stencilEnabledLayerExtents.length>0,o=this.wireframe?L.LINES:L.TRIANGLES;this._configuration.textureFadingEnabled&&s.bindTexture("texNext",i.emptyTexture);const c=this._visiblePatchesByOrigin;for(const d of c.values()){const i=d[0].renderData.localOrigin;this._drawParameters.origin=i,t.program.bindDraw(r,this._passParameters,this._drawParameters),this._numOriginsRendered++;for(const r of d){const i=r.renderData,a=i.textureReference;if(null!=a){if(!n){s.setUniform4fv("texOffsetAndScale",a.offsetAndScale),s.bindTexture("tex",a.texture.texture);const e=i.textureFadeFactor,t=e<1?i.nextTextureReference:null;this._configuration.textureFadingEnabled&&t&&e<1?(s.setUniform1f("fadeFactor",e),s.setUniform4fv("nextTexOffsetAndScale",t.offsetAndScale),s.setUniform3fv("nextTexOpacities",t.opacities),s.bindTexture("texNext",t.texture.texture)):s.setUniform1f("fadeFactor",1),i.textureIsFading&&this.setNeedsRender(2),s.setUniform3fv("textureOpacities",a.opacities)}this._renderPatch(e,t,r,o,l),r.renderOrder=this._numTilesRendered,this._numTilesRendered++}}}i.bindVAO(null)}_renderPatch(e,t,i,r,s,n=!1){const a=i.renderData,l=a.vao,o=l?.indexBuffer;if(!l||null==o)return void(R&&console.error("Rendered tile with no indices: ",i.lij," : ",a));const c=t.program;n||this._overlayRenderer.isEmpty||this._bindOverlayPatchData(c,a.overlay);const{rctx:d,bind:h}=e;s&&(t.useStencil=this._useStencilForTile(i),d.setPipelineState(t.getPipeline(h)));const u=a.geometry.indexCount;d.bindVAO(l),c.assertCompatibleVertexAttributeLocations(l),d.drawElements(r,u,o.indexType,0)}_bindOverlayPatchData(e,t){e.setUniform4fv("overlayTexOffset",t.offsets),e.setUniform4fv("overlayTexScale",t.scales)}_acquireTechnique(e){return this._configuration.output=e,this._techniques.get(I,this._configuration)}get test(){}hasHighlight(e){return this._overlayRenderer.hasHighlight(e)}};e([a({readOnly:!0})],W.prototype,"visibleTiles",null),e([a({readOnly:!0})],W.prototype,"_isGlobal",null),e([a()],W.prototype,"renderOccludedFlags",null),e([a({value:!1})],W.prototype,"renderingDisabled",null),e([a({value:!0})],W.prototype,"visible",null),e([a()],W.prototype,"renderPatchBorders",null),e([a()],W.prototype,"wireframe",null),W=e([l("esri.views.3d.terrain.TerrainRenderer")],W);const Z=_(),J=_(),K=_(),X=_();export{W as TerrainRenderer};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{destroyMaybe as e}from"../../../../../core/maybe.js";import{set as t,transformMat3 as a,add as r}from"../../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as o}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{create as i}from"../../../../../geometry/support/aaBoundingBox.js";import{encodeSymbolColor as s}from"../../../layers/support/symbolColorUtils.js";import{computeOffsetObb as n}from"../../../support/orientedBoundingBox.js";import{ComponentParametersUniform as l,ComponentParametersVarying as h}from"./ComponentDrawParameters.js";import{UniformComponentParameters as m}from"./UniformComponentParameters.js";import{olidEnabled as c}from"../../effects/geometry/olidUtils.js";import{defaultHighlightName as d}from"../../../../support/HighlightDefaults.js";class p{constructor(e,t,a,r,o,i){this._collection=e,this.transform=t,this.obb=a,this._componentData=r,this._renderable=o,this._intersectionGeometry=i,this.visible=!1,this.offsetObb=null,this._aabbInWorldCoordinates=null}destroy(){this._collection.materialRepository.releaseMaterial(this._renderable.material),this._intersectionGeometry=e(this._intersectionGeometry),this._renderable=e(this._renderable),this._componentData=e(this._componentData)}get componentData(){return this._componentData}get renderable(){return this._renderable}get intersectionGeometry(){return this._intersectionGeometry}updateMaterial(e,t){this._updateMaterial(e,t)}get opacity(){return this.renderable.opacity}updateOpacity(e){this.opacity!==e&&(this._renderable.updateOpacity(e),this._updateMaterial({opacity:e}))}_updateMaterial(e,t){const{_renderable:a}=this,r=a.material,o=this._collection.materialRepository.acquireMaterial({...r.parameters,opacity:a.opacity,...e},a.geometry.parameters,t??a.drawParameters.componentParameters);this._collection.materialRepository.releaseMaterial(r),o!==r&&a.updateMaterial(o)}updateCameraDerivedParameters(e){const{eye:t}=e,{centerX:a,centerY:r,centerZ:o}=this.obb;this._renderable.meta.cameraDepthSquared=(t[0]-a)**2+(t[1]-r)**2+(t[2]-o)**2}setComponentData(e,t){const a=this._componentData,{materialDataBuffer:r,materialDataIndices:o}=a,i=new m,d=r.textureBuffer,p=d.getVec4Field("colorAndCastShadows"),f=d.getScalarField("elevationOffset"),g=d.getScalarField("emissiveStrength"),b=d.getScalarField("emissiveSourceMode"),y=d.getVec4Field("olidColor"),_=new Uint8Array(4),M=new Uint32Array(_.buffer);let v,C=0,w=0,S=0,x=0,D=0,O=a.verticalOffsets,P=1/0,j=-1/0,A=!1,I=!1,k=!1,H=0;for(let n=0;n<a.count;n++){e(n,i),C+=+(i.externalColor[3]<1),w+=+(3===i.externalColorMixMode&&1===i.externalColor[3]),x+=+(i.emissiveStrength>0),D+=+(1===i.emissiveSource),I||=1!==i.emissiveStrength,S+=+i.castShadows,s(i.externalColor,i.externalColorMixMode,_),_[2]=254&_[2]|+i.castShadows,p.setArray(o[n],_),A||=n>0&&H!==M[0],H=M[0],k||=0!==i.elevationOffset,k&&null==O&&(O=new Array(n).fill(0)),null!=O&&(O[n]=i.elevationOffset),P=Math.min(P,i.elevationOffset),j=Math.max(j,i.elevationOffset),f.set(o[n],i.elevationOffset),g.set(o[n],i.emissiveStrength),b.set(o[n],0===i.emissiveSource?0:255);const t=i.olidColor;null!=t&&y.setArray(o[n],t),i.pickable!==a.isPickable(n)&&a.updatePickabilityWithCount(n,i.pickable)}if(a.verticalOffsets=k?O:null,this.offsetObb=k?n(this.obb,P,j,t,this.offsetObb??this.obb.clone()):null,A||k||c()||(I||D>0)&&x>0){const{count:e}=a;v=new h(u(C,e),u(w,e),u(x,e),u(D,e),u(S,e)),d.updateTexture(),this._renderable.updateComponentParametersVarying(v,d)}else v=new l(i.externalColor,i.externalColorMixMode,i.emissiveStrength,i.emissiveSource,i.castShadows?0:2),this._renderable.updateComponentParametersUniform(v);this._updateMaterial({},v)}addComponentHighlight(e,t){return this._componentData.addComponentHighlight(e,t)}removeComponentHighlight(e,t){return this._componentData.removeComponentHighlight(e,t)}clearHighlights(){this._componentData.clearHighlights()}get aabbInWorldCoordinates(){let e=this._aabbInWorldCoordinates;return e||(e=this._computeAabbInWorldCoordinates(),this._aabbInWorldCoordinates=e),e}_computeAabbInWorldCoordinates(){const e=i(),{positions:s}=this._intersectionGeometry;if(Math.floor(s.length/3)>0){const{rotationScale:i,position:n}=this.transform;let l=1/0,h=1/0,m=1/0,c=-1/0,d=-1/0,p=-1/0;const u=o();for(let e=0;e<s.length;e+=3)t(u,s[e+0],s[e+1],s[e+2]),a(u,u,i),r(u,u,n),l=Math.min(l,u[0]),h=Math.min(h,u[1]),m=Math.min(m,u[2]),c=Math.max(c,u[0]),d=Math.max(d,u[1]),p=Math.max(p,u[2]);e[0]=l,e[1]=h,e[2]=m,e[3]=c,e[4]=d,e[5]=p}return e}submit(e,t){const{componentData:a,renderable:r}=this;if(r.drawParameters.opacity<=0)return;const{geometry:o,drawParameters:i,material:s}=r,n=r.meta.cameraDepthSquared;a.updateHighlights(t.highlights);const{geometryRanges:l,highlightRangesMap:h,shadowmapRanges:m}=a,c=e=>e.submitDraw(s,i,o,l,n);switch(s.materialPass){case 0:c(e.opaque);break;case 1:c(e.transparent);break;case 2:c(e.opaque),c(e.transparent);break;case 3:c(e.integratedMesh),f(t)&&c(e.occludedGround),g(t)&&c(e.highlightIntegratedMesh);break;case 4:c(e.transparentIntegratedMesh)}if(i.castAnyShadows){if(null!=h)for(const t of h)t[0]===d&&e.highlightShadowMap.submitDraw(s,i,o,t[1],n,t[0]);null!=m&&e.defaultShadowMap.submitDraw(s,i,o,m,n),c(e.shadowMap)}if(null!=h)for(const d of h)e.highlight.submitDraw(s,i,o,d[1],n,d[0]);t.viewshedEnabled&&c(e.viewshedShadowMap)}}function u(e,t){return e===t?0:0===e?2:1}function f(e){return null!=e.overlay?.getTexture(e.overlay?.allSourcesOccluders?1:4)}function g(e){return null!=e.overlay?.getTexture(2)}export{p as ComponentObject};
2
+ import{destroyMaybe as e}from"../../../../../core/maybe.js";import{set as t,transformMat3 as a,add as r}from"../../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as o}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{create as i}from"../../../../../geometry/support/aaBoundingBox.js";import{encodeSymbolColor as s}from"../../../layers/support/symbolColorUtils.js";import{computeOffsetObb as n}from"../../../support/orientedBoundingBox.js";import{ComponentParametersUniform as l,ComponentParametersVarying as h}from"./ComponentDrawParameters.js";import{UniformComponentParameters as m}from"./UniformComponentParameters.js";import{olidEnabled as c}from"../../effects/geometry/olidUtils.js";import{defaultHighlightName as d}from"../../../../support/HighlightDefaults.js";class p{constructor(e,t,a,r,o,i){this._collection=e,this.transform=t,this.obb=a,this._componentData=r,this._renderable=o,this._intersectionGeometry=i,this.visible=!1,this.offsetObb=null,this._aabbInWorldCoordinates=null}destroy(){this._collection.materials.release(this._renderable.material),this._intersectionGeometry=e(this._intersectionGeometry),this._renderable=e(this._renderable),this._componentData=e(this._componentData)}get componentData(){return this._componentData}get renderable(){return this._renderable}get intersectionGeometry(){return this._intersectionGeometry}updateMaterial(e,t){const{_renderable:a}=this,r=a.material,o=this._collection.materials.acquire({...r.parameters,opacity:a.opacity,...e},a.geometry.parameters,t??a.drawParameters.componentParameters);this._collection.materials.release(r),o!==r&&a.updateMaterial(o)}get opacity(){return this.renderable.opacity}updateOpacity(e){this.opacity!==e&&(this._renderable.updateOpacity(e),this.updateMaterial({opacity:e}))}updateCameraDerivedParameters(e){const{eye:t}=e,{centerX:a,centerY:r,centerZ:o}=this.obb;this._renderable.meta.cameraDepthSquared=(t[0]-a)**2+(t[1]-r)**2+(t[2]-o)**2}setComponentData(e,t){const a=this._componentData,{materialDataBuffer:r,materialDataIndices:o}=a,i=new m,d=r.textureBuffer,p=d.getVec4Field("colorAndCastShadows"),f=d.getScalarField("elevationOffset"),g=d.getScalarField("emissiveStrength"),b=d.getScalarField("emissiveSourceMode"),y=d.getVec4Field("olidColor"),_=new Uint8Array(4),v=new Uint32Array(_.buffer);let M,w=0,C=0,S=0,x=0,D=0,O=a.verticalOffsets,P=1/0,j=-1/0,A=!1,I=!1,k=!1,H=0;for(let n=0;n<a.count;n++){e(n,i),w+=+(i.externalColor[3]<1),C+=+(3===i.externalColorMixMode&&1===i.externalColor[3]),x+=+(i.emissiveStrength>0),D+=+(1===i.emissiveSource),I||=1!==i.emissiveStrength,S+=+i.castShadows,s(i.externalColor,i.externalColorMixMode,_),_[2]=254&_[2]|+i.castShadows,p.setArray(o[n],_),A||=n>0&&H!==v[0],H=v[0],k||=0!==i.elevationOffset,k&&null==O&&(O=new Array(n).fill(0)),null!=O&&(O[n]=i.elevationOffset),P=Math.min(P,i.elevationOffset),j=Math.max(j,i.elevationOffset),f.set(o[n],i.elevationOffset),g.set(o[n],i.emissiveStrength),b.set(o[n],0===i.emissiveSource?0:255);const t=i.olidColor;null!=t&&y.setArray(o[n],t),i.pickable!==a.isPickable(n)&&a.updatePickabilityWithCount(n,i.pickable)}if(a.verticalOffsets=k?O:null,this.offsetObb=k?n(this.obb,P,j,t,this.offsetObb??this.obb.clone()):null,A||k||c()||(I||D>0)&&x>0){const{count:e}=a;M=new h(u(w,e),u(C,e),u(x,e),u(D,e),u(S,e)),d.updateTexture(),this._renderable.updateComponentParametersVarying(M,d)}else M=new l(i.externalColor,i.externalColorMixMode,i.emissiveStrength,i.emissiveSource,i.castShadows?0:2),this._renderable.updateComponentParametersUniform(M);this.updateMaterial({},M)}addHighlight(e,t){return this._componentData.addComponentHighlight(e,t)}removeHighlight(e,t){return this._componentData.removeComponentHighlight(e,t)}clearHighlights(){this._componentData.clearHighlights()}get aabbInWorldCoordinates(){let e=this._aabbInWorldCoordinates;return e||(e=this._computeAabbInWorldCoordinates(),this._aabbInWorldCoordinates=e),e}_computeAabbInWorldCoordinates(){const e=i(),{positions:s}=this._intersectionGeometry;if(Math.floor(s.length/3)>0){const{rotationScale:i,position:n}=this.transform;let l=1/0,h=1/0,m=1/0,c=-1/0,d=-1/0,p=-1/0;const u=o();for(let e=0;e<s.length;e+=3)t(u,s[e+0],s[e+1],s[e+2]),a(u,u,i),r(u,u,n),l=Math.min(l,u[0]),h=Math.min(h,u[1]),m=Math.min(m,u[2]),c=Math.max(c,u[0]),d=Math.max(d,u[1]),p=Math.max(p,u[2]);e[0]=l,e[1]=h,e[2]=m,e[3]=c,e[4]=d,e[5]=p}return e}submit(e,t){const{componentData:a,renderable:r}=this;if(r.drawParameters.opacity<=0)return;const{geometry:o,drawParameters:i,material:s}=r,n=r.meta.cameraDepthSquared;a.updateHighlights(t.highlights);const{geometryRanges:l,highlightRangesMap:h,shadowmapRanges:m}=a,c=e=>e.submitDraw(s,i,o,l,n);switch(s.materialPass){case 0:c(e.opaque);break;case 1:c(e.transparent);break;case 2:c(e.opaque),c(e.transparent);break;case 3:c(e.integratedMesh),f(t)&&c(e.occludedGround),g(t)&&c(e.highlightIntegratedMesh);break;case 4:c(e.transparentIntegratedMesh)}if(i.castAnyShadows){if(null!=h)for(const t of h)t[0]===d&&e.highlightShadowMap.submitDraw(s,i,o,t[1],n,t[0]);null!=m&&e.defaultShadowMap.submitDraw(s,i,o,m,n),c(e.shadowMap)}if(null!=h)for(const d of h)e.highlight.submitDraw(s,i,o,d[1],n,d[0]);t.viewshedEnabled&&c(e.viewshedShadowMap)}}function u(e,t){return e===t?0:0===e?2:1}function f(e){return null!=e.overlay?.getTexture(e.overlay?.allSourcesOccluders?1:4)}function g(e){return null!=e.overlay?.getTexture(2)}export{p as ComponentObject};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import"../../../../../core/has.js";import e from"../../../../../core/Logger.js";import t from"../../../../../core/PooledArray.js";import{isTypedArray as i}from"../../../../../core/typedArrayUtil.js";import{clone as n}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{create as o}from"../../../../../geometry/support/aaBoundingBox.js";import{compactIndices as r}from"../../../../../geometry/support/Indices.js";import{c as s}from"../../../../../chunks/vec3.js";import{c as a}from"../../../../../chunks/vec32.js";import{ComponentData as c}from"./ComponentData.js";import{defaultComponentParameters as l,ComponentDrawParametersImplementation as m}from"./ComponentDrawParameters.js";import{ComponentObject as h}from"./ComponentObject.js";import{IntersectionGeometry as p}from"./IntersectionGeometry.js";import{RenderableMeta as g,Renderable as d}from"./Renderable.js";import{RenderGeometry as f}from"./RenderGeometry.js";import{RenderSubmitSystem as u}from"./RenderSubmitSystem.js";import{ComponentMaterialRepository as b}from"./Material/ComponentMaterialRepository.js";import{VertexArrayObject as v}from"../../lib/VertexArrayObject.js";import{getVerticalOffsetI3S as _}from"../../lib/verticalOffsetUtils.js";import{BufferManager as y}from"../../lib/TextureBackedBuffer/BufferManager.js";import{getComponentDataLayout as C,IndexGlLayout as R}from"../../materials/DefaultLayouts.js";import{BufferObject as M}from"../../../../webgl/BufferObject.js";import{PrimitiveType as j}from"../../../../webgl/enums.js";import{SamplerRepository as w}from"../../../../webgl/Sampler.js";import{VertexBuffer as O}from"../../../../webgl/VertexBuffer.js";const x=()=>e.getLogger("esri.views.3d.webgl-engine.collections.Component.ComponentObjectCollection");class D{constructor(e,i,n){this._renderPassManager=e,this._viewingMode=i,this._elevationRangeCacheVerticalOffset=NaN,this._elevationRangeCacheMin=NaN,this._elevationRangeCacheMax=NaN,this._activeHighlightOptions=new Map,this._visible=new t,this._hidden=new t,this._renderSubmit=new u(this),this._renderPassManager.register(this._renderSubmit);const{rctx:o,bind:r}=e;this._componentBufferManager=new y(o,C());const s=2===this._viewingMode?0:n?1:2;this.materialRepository=new b(r.hasFloatOit,s),this.samplerRepository=new w(o.gl)}destroy(){this._componentBufferManager.destroy(),this._componentBufferManager=null,this._visible.forAll(e=>e.destroy()),this._visible.prune(),this._hidden.forAll(e=>e.destroy()),this._hidden.prune(),this._renderSubmit.destroy(),this.samplerRepository.dispose(),this.materialRepository.destroy()}createObject(e,t){const{geometry:i}=e,n=new c(this._componentBufferManager,r(i.componentOffsets)),o=this._createRenderable(e,t,n),s=new p(this._viewingMode,i.positions,n,e.elevationAlignable),a=new h(this,e.transform,e.obb.clone(),n,o,s);return(a.visible?this._visible:this._hidden).push(a),a}destroyObject(e){const t=e;(t.visible?this._visible:this._hidden).removeUnordered(t),t.destroy(),this._requestRender()}setObjectVisibility(e,t){const i=e;t!==i.visible&&(t?(this._hidden.removeUnordered(i),this._visible.push(i)):(this._visible.removeUnordered(i),this._hidden.push(i)),i.visible=t,this._requestRender())}preSubmit(e){const{camera:t}=e;this._componentBufferManager.updateTextures(),this.visibleObjects.forAll(e=>e.updateCameraDerivedParameters(t))}updateMaterial(e,t){e.updateMaterial(t)}getObjectOpacity(e){return e.renderable.drawParameters.opacity}updateObjectOpacity(e,t){const i=e;i.opacity!==t&&(i.updateOpacity(t),this._requestRender())}isSliceplaneEnabled(e){return e.renderable.material.slicePlaneEnabled}setAllComponentVisibilities(e,t){const i=e;i.componentData.visibility.reset(t),i.componentData.markVisibilityDirty(),this._requestRender()}forEachVisibleComponent(e,t){return e.componentData.visibility.forEachComponent(t)}getComponentCount(e){const t=e,{componentData:i}=t,n=i.visibility.componentCount;return{visible:n,invisible:i.count-n}}setComponentData(e,t){e.setComponentData(t,this._viewingMode),this._elevationRangeCacheVerticalOffset=NaN,this._requestRender()}getComponentAabb(e,t,i,n=!1){e.intersectionGeometry.getComponentAabb(t,i);const o=e,r=o.componentData.verticalOffsets;if(n||null==r)return i;const s=r[t];if(2===this._viewingMode||0===s)return i[2]+=s,i[5]+=s,i;const a=_(s);return a.localOrigin=o.transform.position,a.applyToAabb(i)}getComponentObb(e){return e.obb}getObjectTransform(e){return e.transform}getComponentPositions(e,t,i){return e.intersectionGeometry.getComponentPositions(t,i)}expandRangeWithComponentObjectElevationRange(e,t,i,n){Number.isNaN(this._elevationRangeCacheVerticalOffset)||this._elevationRangeCacheVerticalOffset!==t||n.expandElevationRangeValues(this._elevationRangeCacheMin,this._elevationRangeCacheMax);const o=e,{componentData:r}=o,s=r.count,{verticalOffsets:a}=r,{intersectionGeometry:c}=o,l=2===this._viewingMode,m=c.getComponentAabbs(),h=E;let p=1/0,g=-1/0;for(let d=0;d<s;d++){const e=6*d,r=a?.[d]??0;let s=1/0,c=-1/0;if(l)s=m[e+2]+r+t,c=m[e+5]+r+t;else{if(h[0]=m[e],h[1]=m[e+1],h[2]=m[e+2],h[3]=m[e+3],h[4]=m[e+4],h[5]=m[e+5],0!==r){const e=_(r);e.localOrigin=o.transform.position,e.applyToAabb(h)}const s=Math.max(Math.abs(h[3]),Math.abs(h[0])),a=Math.max(Math.abs(h[4]),Math.abs(h[1])),c=t+h[5]+i;n.expandElevationRangeValues(t+h[2],Math.sqrt(s*s+a*a+c*c)-i)}n.expandElevationRangeValues(s,c),p=Math.min(p,s),g=Math.max(g,c)}this._elevationRangeCacheVerticalOffset=t,this._elevationRangeCacheMin=p,this._elevationRangeCacheMax=g}intersect(e,t,i,n,o,r){const s=e,{transform:a,componentData:c,intersectionGeometry:l}=s;return null!=n&&(n.localOrigin=a.position),l.intersect(t,i,n,c.verticalOffsets,a,o,r)}addEdges(e,t,i,n,o){const r=e,{indices:s,positions:a}=r.intersectionGeometry,c=r.componentData.offsets;return t.addComponentObject(r,a,s,c,i,n,o)}async extractEdgeInformation(e,t,i){const o=e,r=o.componentData.visibility;if(r.allInvisible()){const{extractComponentsEdgeLocationsLayout:e}=await import("../../lib/edgeRendering/edgeProcessing.js");return{buffer:e.createBuffer(0),origin:[0,0,0]}}const{indices:c,positions:l}=o.intersectionGeometry,m=o.componentData.offsets,{EdgeInputBufferLayout:h}=await import("../../lib/edgeRendering/bufferLayouts.js"),p=h.createBuffer(l.length/3);a(p.position.typedBuffer,l,p.position.typedBufferStride,3),s(p.position,p.position,o.transform.rotationScale),this._setComponentIndices(p.componentIndex,c,m);const g=p.count,d=this._computeVisibilityIndices(c,r,m,g);return{origin:n(o.transform.position),buffer:await t.extractComponentsEdgeLocations({indices:d,indicesLength:d.length,skipDeduplicate:!0,data:p,writerSettings:{reducedPrecision:!1,variants:0}},i)}}_setComponentIndices(e,t,i){let n=0;for(let o=0;o<i.length-1;o++){const r=i[o],s=i[o+1];for(let i=r;i<s;i++){const o=t?t[i]:i;e.set(o,n)}n++}}_computeVisibilityIndices(e,t,n,o){if(e&&t.allVisible())return e;let r=0;t.forEachComponentRange((e,t)=>(r+=n[t]-n[e],!0));const s=i(e)?2===e?.BYTES_PER_ELEMENT||o<=65536?new Uint16Array(r):new Uint32Array(r):new Array(r);let a=0;return t.forEachComponentRange((t,i)=>{const o=n[t],r=n[i];for(let n=o;n<r;n++)s[a++]=e?e[n]:n;return!0}),s}addComponentHighlight(e,t,i){const n=e;{const e=this._activeHighlightOptions.get(i)??0;this._activeHighlightOptions.set(i,e+1)}n.addComponentHighlight(t,i)&&this._requestRender()}removeComponentHighlight(e,t,i){const n=e.removeComponentHighlight(t,i);"notfound"!==n&&(this._removeActiveHighlight(i),n&&this._requestRender())}_removeActiveHighlight(e,t=1){const i=this._activeHighlightOptions.get(e);if(void 0===i)x().warn(`Removing non-existing highlight "${e}".`);else{const n=i-t;n<0&&x().warn(`Removing non-existing highlight "${e}".`),n<=0?this._activeHighlightOptions.delete(e):this._activeHighlightOptions.set(e,n)}}clearHighlights(e){const t=e,{componentData:i}=t,{componentHighlights:n}=t.componentData;if(n.size>0){for(const e of n)this._removeActiveHighlight(e[0],e[1][i.count]);t.clearHighlights(),this._requestRender()}}hasHighlight(e){return this._activeHighlightOptions.has(e)}getObjectGPUMemoryUsage(e){return e.renderable.meta.gpuMemoryEstimate}get visibleObjects(){return this._visible}_createRenderable(e,t,i){const n=this._renderPassManager.rctx,o=e.geometry,r=o.parameters.layout,{interleavedVertexData:s,indexData:a,vertexCount:c}=o.renderGeometryData,h=new O(n,r,s),p=a?M.createIndex(n,35044,a):null;let u=0;const b=[["geometry",h]];if(!t.isIntegratedMesh){const e=new Uint16Array(c);for(let n=0;n<i.count;n++){const t=i.offsets[n],o=i.offsets[n+1],r=i.materialDataIndices[n];if(null!=a)for(let i=t;i<o;i++){e[a[i]]=r}else for(let i=t;i<o;i++)e[i]=r}const t=new O(n,R,e.buffer);u+=t.usedMemory,b.push(["componentIndices",t])}const _=new v(n,new Map(b),p),y=new f(_,j.TRIANGLES,o.parameters,null!=p),C=this.materialRepository.acquireMaterial(t,y.parameters,l),w=new g(h.usedMemory+u+(p?.usedMemory??0)),x=this.samplerRepository.addFromTexture(t.baseColorTexture?.texture),D=new m(e,t,x);return new d(C,D,y,w)}_requestRender(){this._renderPassManager.requestRender()}}const E=o();export{D as ComponentObjectCollection};
2
+ import{__decorate as e}from"tslib";import t from"../../../../../core/Accessor.js";import"../../../../../core/has.js";import i from"../../../../../core/Logger.js";import n from"../../../../../core/PooledArray.js";import{watch as o,sync as s}from"../../../../../core/reactiveUtils.js";import{isTypedArray as r}from"../../../../../core/typedArrayUtil.js";import{subclass as a}from"../../../../../core/accessorSupport/decorators/subclass.js";import{clone as l}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{create as c}from"../../../../../geometry/support/aaBoundingBox.js";import{compactIndices as m}from"../../../../../geometry/support/Indices.js";import{c as h}from"../../../../../chunks/vec3.js";import{c as p}from"../../../../../chunks/vec32.js";import{ComponentData as g}from"./ComponentData.js";import{defaultComponentParameters as d,ComponentDrawParametersImplementation as f}from"./ComponentDrawParameters.js";import{ComponentObject as u}from"./ComponentObject.js";import{IntersectionGeometry as b}from"./IntersectionGeometry.js";import{RenderableMeta as v,Renderable as _}from"./Renderable.js";import{RenderGeometry as y}from"./RenderGeometry.js";import{RenderSubmitSystem as j}from"./RenderSubmitSystem.js";import{ComponentMaterialRepository as C}from"./Material/ComponentMaterialRepository.js";import{VertexArrayObject as w}from"../../lib/VertexArrayObject.js";import{getVerticalOffsetI3S as M}from"../../lib/verticalOffsetUtils.js";import{BufferManager as O}from"../../lib/TextureBackedBuffer/BufferManager.js";import{getComponentDataLayout as R,IndexGlLayout as x}from"../../materials/DefaultLayouts.js";import{BufferObject as A}from"../../../../webgl/BufferObject.js";import{PrimitiveType as D}from"../../../../webgl/enums.js";import{SamplerRepository as E}from"../../../../webgl/Sampler.js";import{VertexBuffer as H}from"../../../../webgl/VertexBuffer.js";const B=()=>i.getLogger("esri.views.3d.webgl-engine.collections.Component.ComponentObjectCollection");let V=class extends t{constructor(e,t,i){super({}),this._renderPassManager=e,this._viewingMode=t,this._elevationRangeCacheVerticalOffset=NaN,this._elevationRangeCacheMin=NaN,this._elevationRangeCacheMax=NaN,this._activeHighlightOptions=new Map,this._visible=new n,this._hidden=new n,this._renderSubmit=new j(this),this._renderPassManager.register(this._renderSubmit);const{rctx:r,bind:a}=e;this._componentBufferManager=new O(r,R());const l=2===this._viewingMode?0:i?1:2;this.materials=new C(a,l),this.samplers=new E(r.gl),this.addHandles(o(()=>a.hasFloatOit.value,()=>{this._visible.forAll(e=>e.updateMaterial(this.materials.globals)),this._hidden.forAll(e=>e.updateMaterial(this.materials.globals)),this._requestRender()},s))}destroy(){this._componentBufferManager.destroy(),this._componentBufferManager=null,this._visible.forAll(e=>e.destroy()),this._visible.prune(),this._hidden.forAll(e=>e.destroy()),this._hidden.prune(),this._renderSubmit.destroy(),this.samplers.dispose(),this.materials.destroy()}createObject(e,t){const{geometry:i}=e,n=new g(this._componentBufferManager,m(i.componentOffsets)),o=this._createRenderable(e,t,n),s=new b(this._viewingMode,i.positions,n,e.elevationAlignable),r=new u(this,e.transform,e.obb.clone(),n,o,s);return(r.visible?this._visible:this._hidden).push(r),r}destroyObject(e){const t=e;(t.visible?this._visible:this._hidden).removeUnordered(t),t.destroy(),this._requestRender()}setObjectVisibility(e,t){const i=e;t!==i.visible&&(t?(this._hidden.removeUnordered(i),this._visible.push(i)):(this._visible.removeUnordered(i),this._hidden.push(i)),i.visible=t,this._requestRender())}preSubmit(e){const{camera:t}=e;this._componentBufferManager.updateTextures(),this.visibleObjects.forAll(e=>e.updateCameraDerivedParameters(t))}getObjectOpacity(e){return e.renderable.drawParameters.opacity}updateObjectOpacity(e,t){const i=e;i.opacity!==t&&(i.updateOpacity(t),this._requestRender())}isSliceplaneEnabled(e){return e.renderable.material.slicePlaneEnabled}setAllComponentVisibilities(e,t){const i=e;i.componentData.visibility.reset(t),i.componentData.markVisibilityDirty(),this._requestRender()}forEachVisibleComponent(e,t){return e.componentData.visibility.forEachComponent(t)}getComponentCount(e){const t=e,{componentData:i}=t,n=i.visibility.componentCount;return{visible:n,invisible:i.count-n}}setComponentData(e,t){e.setComponentData(t,this._viewingMode),this._elevationRangeCacheVerticalOffset=NaN,this._requestRender()}getComponentAabb(e,t,i,n=!1){e.intersectionGeometry.getComponentAabb(t,i);const o=e,s=o.componentData.verticalOffsets;if(n||null==s)return i;const r=s[t];if(2===this._viewingMode||0===r)return i[2]+=r,i[5]+=r,i;const a=M(r);return a.localOrigin=o.transform.position,a.applyToAabb(i)}getComponentObb(e){return e.obb}getObjectTransform(e){return e.transform}getComponentPositions(e,t,i){return e.intersectionGeometry.getComponentPositions(t,i)}expandRangeWithComponentObjectElevationRange(e,t,i,n){Number.isNaN(this._elevationRangeCacheVerticalOffset)||this._elevationRangeCacheVerticalOffset!==t||n.expandElevationRangeValues(this._elevationRangeCacheMin,this._elevationRangeCacheMax);const o=e,{componentData:s}=o,r=s.count,{verticalOffsets:a}=s,{intersectionGeometry:l}=o,c=2===this._viewingMode,m=l.getComponentAabbs(),h=I;let p=1/0,g=-1/0;for(let d=0;d<r;d++){const e=6*d,s=a?.[d]??0;let r=1/0,l=-1/0;if(c)r=m[e+2]+s+t,l=m[e+5]+s+t;else{if(h[0]=m[e],h[1]=m[e+1],h[2]=m[e+2],h[3]=m[e+3],h[4]=m[e+4],h[5]=m[e+5],0!==s){const e=M(s);e.localOrigin=o.transform.position,e.applyToAabb(h)}const r=Math.max(Math.abs(h[3]),Math.abs(h[0])),a=Math.max(Math.abs(h[4]),Math.abs(h[1])),l=t+h[5]+i;n.expandElevationRangeValues(t+h[2],Math.sqrt(r*r+a*a+l*l)-i)}n.expandElevationRangeValues(r,l),p=Math.min(p,r),g=Math.max(g,l)}this._elevationRangeCacheVerticalOffset=t,this._elevationRangeCacheMin=p,this._elevationRangeCacheMax=g}intersect(e,t,i,n,o,s){const r=e,{transform:a,componentData:l,intersectionGeometry:c}=r;return null!=n&&(n.localOrigin=a.position),c.intersect(t,i,n,l.verticalOffsets,a,o,s)}addEdges(e,t,i,n,o){const s=e,{indices:r,positions:a}=s.intersectionGeometry,l=s.componentData.offsets;return t.addComponentObject(s,a,r,l,i,n,o)}async extractEdgeInformation(e,t,i){const n=e,o=n.componentData.visibility;if(o.allInvisible()){const{extractComponentsEdgeLocationsLayout:e}=await import("../../lib/edgeRendering/edgeProcessing.js");return{buffer:e.createBuffer(0),origin:[0,0,0]}}const{indices:s,positions:r}=n.intersectionGeometry,a=n.componentData.offsets,{EdgeInputBufferLayout:c}=await import("../../lib/edgeRendering/bufferLayouts.js"),m=c.createBuffer(r.length/3);p(m.position.typedBuffer,r,m.position.typedBufferStride,3),h(m.position,m.position,n.transform.rotationScale),this._setComponentIndices(m.componentIndex,s,a);const g=m.count,d=this._computeVisibilityIndices(s,o,a,g);return{origin:l(n.transform.position),buffer:await t.extractComponentsEdgeLocations({indices:d,indicesLength:d.length,skipDeduplicate:!0,data:m,writerSettings:{reducedPrecision:!1,variants:0}},i)}}_setComponentIndices(e,t,i){let n=0;for(let o=0;o<i.length-1;o++){const s=i[o],r=i[o+1];for(let i=s;i<r;i++){const o=t?t[i]:i;e.set(o,n)}n++}}_computeVisibilityIndices(e,t,i,n){if(e&&t.allVisible())return e;let o=0;t.forEachComponentRange((e,t)=>(o+=i[t]-i[e],!0));const s=r(e)?2===e?.BYTES_PER_ELEMENT||n<=65536?new Uint16Array(o):new Uint32Array(o):new Array(o);let a=0;return t.forEachComponentRange((t,n)=>{const o=i[t],r=i[n];for(let i=o;i<r;i++)s[a++]=e?e[i]:i;return!0}),s}addHighlight(e,t,i){const n=e,o=this._activeHighlightOptions.get(i)??0;this._activeHighlightOptions.set(i,o+1);n.addHighlight(t,i)&&this._requestRender()}removeHighlight(e,t,i){const n=e.removeHighlight(t,i);"notfound"!==n&&(this._removeActiveHighlight(i),n&&this._requestRender())}_removeActiveHighlight(e,t=1){const i=this._activeHighlightOptions.get(e);if(void 0===i)B().warn(`Removing non-existing highlight "${e}".`);else{const n=i-t;n<0&&B().warn(`Removing non-existing highlight "${e}".`),n<=0?this._activeHighlightOptions.delete(e):this._activeHighlightOptions.set(e,n)}}clearHighlights(e){const t=e,{componentData:i}=t,{componentHighlights:n}=t.componentData;if(n.size>0){for(const e of n)this._removeActiveHighlight(e[0],e[1][i.count]);t.clearHighlights(),this._requestRender()}}hasHighlight(e){return this._activeHighlightOptions.has(e)}getObjectGPUMemoryUsage(e){return e.renderable.meta.gpuMemoryEstimate}get visibleObjects(){return this._visible}_createRenderable(e,t,i){const n=this._renderPassManager.rctx,o=e.geometry,s=o.parameters.layout,{interleavedVertexData:r,indexData:a,vertexCount:l}=o.renderGeometryData,c=new H(n,s,r),m=a?A.createIndex(n,35044,a):null;let h=0;const p=[["geometry",c]];if(!t.isIntegratedMesh){const e=new Uint16Array(l);for(let n=0;n<i.count;n++){const t=i.offsets[n],o=i.offsets[n+1],s=i.materialDataIndices[n];if(null!=a)for(let i=t;i<o;i++){e[a[i]]=s}else for(let i=t;i<o;i++)e[i]=s}const t=new H(n,x,e.buffer);h+=t.usedMemory,p.push(["componentIndices",t])}const g=new w(n,new Map(p),m),u=new y(g,D.TRIANGLES,o.parameters,null!=m),b=this.materials.acquire(t,u.parameters,d),j=new v(c.usedMemory+h+(m?.usedMemory??0)),C=this.samplers.addFromTexture(t.baseColorTexture?.texture),M=new f(e,t,C);return new _(b,M,u,j)}_requestRender(){this._renderPassManager.requestRender()}};V=e([a("esri.views.3d.webgl-engine.collections.Component.ComponentObjectCollection")],V);const I=c();export{V as ComponentObjectCollection};
@@ -0,0 +1,2 @@
1
+ /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
+ import has from"../../../../../../core/has.js";class s{constructor(s,i){this._bind=s,this.sphericalSR=i,this._hasOIT8Emissive=!has("disable-feature:oit8-emissive")}get hasEmissionSupport(){return this.hasFloatOit||this._hasOIT8Emissive}get hasFloatOit(){return this._bind.hasFloatOit.value}}export{s as ComponentMaterialGlobalParameters};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import has from"../../../../../../core/has.js";import"../../../../../../core/Logger.js";import{ComponentMaterial as e,computeMaterialPass as t,calculateHasEmissions as r,calculateEmissionSource as a}from"./ComponentMaterial.js";class o{constructor(e,t){this._materialRepository=new Map;const r=e||!has("disable-feature:oit8-emissive");this._globalMaterialParameters={hasFloatOit:e,hasEmissionSupport:r,sphericalSR:t}}destroy(){this._materialRepository.forEach(({material:e})=>e.destroy()),this._materialRepository.clear()}acquireMaterial(t,r,a){const o=i(t,r,a,this._globalMaterialParameters),s=this._materialRepository.get(o);if(s)return s.count++,s.material.key,s.material;const l=new e(t,r,a,this._globalMaterialParameters,o);return this._materialRepository.set(o,{material:l,count:1}),l}releaseMaterial(e){const{key:t}=e,r=this._materialRepository.get(t);if(!r||r.count<1)throw new Error("Internal error in material repository");1===r.count?this._materialRepository.delete(t):r.count--}}function i(e,o,i,s){const l=t(e,i),n=r(e,i,s),m=a(e,i,s);return`|${+e.usePBR}|${+e.hasParametersFromSource}|${+e.isGround}|${+e.slicePlaneEnabled}|${+e.isIntegratedMesh}|${+e.applySSAO}|${+l}|${+i.componentDataType}|${+n}|${+m}|${+e.sphereDepthInterpolate}|${+e.ellipsoidMode}|${+e.doubleSided}|${+e.cullFace}|${+e.alphaDiscardMode}|${+o.hasVertexColors}|${+o.textureCoordinateType}|${+o.shadeNormals}|${+o.hasNormals}|${+e.polygonOffsetEnabled}|${+o.vertexPositionRotationType}|${+o.vertexNormalRotationType}|`+ +(null!=e.baseColorTexture)+"|"+ +(null!=e.emissionTexture)+"|"+ +(null!=e.metallicRoughnessTexture)+"|"+ +(null!=e.occlusionTexture)+"|"+ +(null!=e.normalTexture)+"|"+ +i.emissiveOverride}export{o as ComponentMaterialRepository,i as makeMaterialKey};
2
+ import"../../../../../../core/has.js";import"../../../../../../core/Logger.js";import{ComponentMaterial as e,computeMaterialPass as t,calculateHasEmissions as r,calculateEmissionSource as o}from"./ComponentMaterial.js";import{ComponentMaterialGlobalParameters as s}from"./ComponentMaterialGlobalParameters.js";class a{constructor(e,t){this._store=new Map,this.globals=new s(e,t)}destroy(){this._store.forEach(({material:e})=>e.destroy()),this._store.clear()}acquire(t,r,o){const s=this.globals,a=l(t,r,o,s),n=this._store.get(a);if(n)return n.refCount++,n.material.key,n.material;const i=new e(t,r,o,s,a);return this._store.set(a,{material:i,refCount:1}),i}release(e){const{key:t}=e,r=this._store.get(t);if(!r||r.refCount<1)throw new Error("Internal error in material repository");1===r.refCount?this._store.delete(t):r.refCount--}}function l(e,s,a,l){const n=t(e,a),i=r(e,a,l),u=o(e,a,l);return"|"+ +l.hasFloatOit+`|${+e.usePBR}|${+e.hasParametersFromSource}|${+e.isGround}`+`|${+e.slicePlaneEnabled}|${+e.isIntegratedMesh}|${+e.applySSAO}`+`|${+n}|${+a.componentDataType}|${+i}|${+u}`+`|${+e.sphereDepthInterpolate}|${+e.ellipsoidMode}|${+e.doubleSided}`+`|${+e.cullFace}|${+e.alphaDiscardMode}`+`|${+s.hasVertexColors}|${+s.textureCoordinateType}`+`|${+s.shadeNormals}|${+s.hasNormals}`+`|${+e.polygonOffsetEnabled}|${+s.vertexPositionRotationType}|${+s.vertexNormalRotationType}|`+ +(null!=e.baseColorTexture)+"|"+ +(null!=e.emissionTexture)+"|"+ +(null!=e.metallicRoughnessTexture)+"|"+ +(null!=e.occlusionTexture)+"|"+ +(null!=e.normalTexture)+"|"+ +a.emissiveOverride}export{a as ComponentMaterialRepository,l as makeMaterialKey};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import{subclass as r}from"../../../../../../core/accessorSupport/decorators.js";import{C as t}from"../../../../../../chunks/ComponentShader.glsl.js";import{isOITColor as n,isOITFrontFace as i}from"../../../core/shaderLibrary/ShaderOutput.js";import{ReloadableShader as o}from"../../../core/shaderTechnique/ReloadableShader.js";import{ShaderTechnique as l}from"../../../core/shaderTechnique/ShaderTechnique.js";import{OITPolygonOffset as s,depthTest as a,blending as d}from"../../../lib/OrderIndependentTransparency.js";import{stencilBaseAllZerosParams as p,stencilWriteMaskOn as u,replaceBitWhenDepthTestPasses as c}from"../../../lib/StencilUtils.js";import{IndexGlLayout as m}from"../../../materials/DefaultLayouts.js";import{makePipelineState as h,defaultColorWrite as f,defaultDepthWrite as g,premultipliedAlpha as b,cullingParams as j}from"../../../../../webgl/renderState.js";let P=class extends l{constructor(e,r,n){super(e,r,n.concat(m)),this.shader=new o(t,()=>import("./ComponentShader.glsl.js")),this.ignoreUnused=!0}getPipeline(e){return e.camera.aboveGround||null==this._belowGroundPipeline?super.getPipeline(e):this._belowGroundPipeline}initializePipeline(e){return this._belowGroundPipeline=0===e.integratedMeshMode?null:this._makePipeline(e,!0),this._makePipeline(e,!1)}_makePipeline(e,r){const{integratedMeshMode:t,output:o,blendingEnabled:l,cullFace:m,hasOccludees:P,hasPolygonOffset:S,renderOccluded:w}=e,T=0!==t,O=!n(o),_=i(o);let y=j(m);return r&&y&&(y={...y,mode:2304}),h({blending:w?b:l?d(o):null,culling:y,depthTest:w?null:a(o),depthWrite:w||!O&&!_?null:g,colorWrite:f,stencilWrite:!w&&T||P?u:null,stencilTest:T?c(1):P?p:null,polygonOffset:O||_?S?{factor:2,units:2}:null:s})}};P=e([r("esri.views.3d.webgl-engine.collections.Component.Material.ComponentTechnique")],P);export{P as ComponentTechnique};
2
+ import{__decorate as e}from"tslib";import{subclass as r}from"../../../../../../core/accessorSupport/decorators.js";import{C as t}from"../../../../../../chunks/ComponentShader.glsl.js";import{isOITColor as i,isOITFrontFace as n}from"../../../core/shaderLibrary/ShaderOutput.js";import{ReloadableShader as o}from"../../../core/shaderTechnique/ReloadableShader.js";import{ShaderTechnique as l}from"../../../core/shaderTechnique/ShaderTechnique.js";import{depthTest as s,blending as a}from"../../../lib/OrderIndependentTransparency.js";import{stencilBaseAllZerosParams as p,stencilWriteMaskOn as d,replaceBitWhenDepthTestPasses as u}from"../../../lib/StencilUtils.js";import{IndexGlLayout as m}from"../../../materials/DefaultLayouts.js";import{i3sHolePolygonOffset as c,OITPolygonOffset as h}from"../../../materials/PolygonOffset.js";import{makePipelineState as f,defaultColorWrite as g,defaultDepthWrite as b,premultipliedAlpha as j,cullingParams as P}from"../../../../../webgl/renderState.js";let S=class extends l{constructor(e,r,i){super(e,r,i.concat(m)),this.shader=new o(t,()=>import("./ComponentShader.glsl.js")),this.ignoreUnused=!0}getPipeline(e){return e.camera.aboveGround||null==this._belowGroundPipeline?super.getPipeline(e):this._belowGroundPipeline}initializePipeline(e){return this._belowGroundPipeline=0===e.integratedMeshMode?null:this._makePipeline(e,!0),this._makePipeline(e,!1)}_makePipeline(e,r){const{integratedMeshMode:t,output:o,blendingEnabled:l,cullFace:m,hasOccludees:S,hasPolygonOffset:w,renderOccluded:O}=e,T=0!==t,y=!i(o),_=n(o);let C=P(m);return r&&C&&(C={...C,mode:2304}),f({blending:O?j:l?a(o):null,culling:C,depthTest:O?null:s(o),depthWrite:O||!y&&!_?null:b,colorWrite:g,stencilWrite:!O&&T||S?d:null,stencilTest:T?u(1):S?p:null,polygonOffset:y||_?w?c:null:h})}};S=e([r("esri.views.3d.webgl-engine.collections.Component.Material.ComponentTechnique")],S);export{S as ComponentTechnique};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import{isColorHighlightOrOLID as t}from"../../../core/shaderLibrary/ShaderOutput.js";import{parameter as o}from"../../../core/shaderTechnique/ShaderTechniqueConfiguration.js";import{SphereDepthInterpolateConfiguration as i}from"../../../shaders/SphereDepthInterpolate.glsl.js";class s extends i{constructor(e){super(),this.output=0,this.textureCoordinateType=0,this.componentDataType=0,this.cullFace=2,this.vertexDiscardMode=0,this.doubleSidedMode=2,this.alphaDiscardMode=1,this.integratedMeshMode=0,this.pbrMode=0,this.normalType=0,this.emissionSource=0,this.shadeNormals=1,this.hasEmission=!1,this.hasVertexColors=!1,this.hasSlicePlane=!1,this.isGroundSlice=!1,this.hasColorTexture=!1,this.hasHighlightMixTexture=!1,this.receiveAmbientOcclusion=!0,this.receiveShadows=!0,this.blendingEnabled=!0,this.screenSpaceReflections=!1,this.hasPolygonOffset=!1,this.hasMetallicRoughnessTexture=!1,this.hasOcclusionTexture=!1,this.hasNormalTexture=!1,this.hasOccludees=!1,this.terrainDepthTest=!1,this.cullAboveTerrain=!1,this.hasNormalTextureTransform=!1,this.cloudReflections=!0,this.snowCover=!1,this.renderOccluded=!1,this.sphereDepthInterpolate=!1,this.vertexPositionRotationType=1,this.vertexNormalRotationType=0,this.discardInvisibleFragments=!1,this.oitPremultipliedAlpha=!1,this.occlusionPass=!1,this.bindType=2,this.useCustomDTRExponentForWater=!1,this.hasVertexTangents=!1,this.hasSliceTranslatedView=!1,this.highStepCount=!1,this.instanced=!1,this.instancedDoublePrecision=!1,this.hasModelTransformation=!1,this.useFillLights=!0,this.draped=!1,this.useTransformationTexture=!0,this.sphericalSR=e.sphericalSR,this.hasFloatOit=e.hasFloatOit}get spherical(){return 0!==this.sphericalSR}get overlayEnabled(){return(2===this.integratedMeshMode||3===this.integratedMeshMode)&&t(this.output)}get hasWater(){return 3===this.pbrMode||4===this.pbrMode||6===this.pbrMode}}e([o({count:12})],s.prototype,"output",void 0),e([o({count:3})],s.prototype,"textureCoordinateType",void 0),e([o({count:2})],s.prototype,"componentDataType",void 0),e([o({count:3})],s.prototype,"cullFace",void 0),e([o({count:3})],s.prototype,"vertexDiscardMode",void 0),e([o({count:3})],s.prototype,"doubleSidedMode",void 0),e([o({count:4})],s.prototype,"alphaDiscardMode",void 0),e([o({count:4})],s.prototype,"integratedMeshMode",void 0),e([o({count:7})],s.prototype,"pbrMode",void 0),e([o({count:3})],s.prototype,"normalType",void 0),e([o({count:8})],s.prototype,"emissionSource",void 0),e([o({count:3})],s.prototype,"shadeNormals",void 0),e([o()],s.prototype,"hasEmission",void 0),e([o()],s.prototype,"hasVertexColors",void 0),e([o()],s.prototype,"hasSlicePlane",void 0),e([o()],s.prototype,"isGroundSlice",void 0),e([o()],s.prototype,"hasColorTexture",void 0),e([o()],s.prototype,"hasHighlightMixTexture",void 0),e([o()],s.prototype,"receiveAmbientOcclusion",void 0),e([o()],s.prototype,"receiveShadows",void 0),e([o()],s.prototype,"blendingEnabled",void 0),e([o()],s.prototype,"screenSpaceReflections",void 0),e([o()],s.prototype,"hasPolygonOffset",void 0),e([o()],s.prototype,"hasMetallicRoughnessTexture",void 0),e([o()],s.prototype,"hasOcclusionTexture",void 0),e([o()],s.prototype,"hasNormalTexture",void 0),e([o()],s.prototype,"hasOccludees",void 0),e([o()],s.prototype,"terrainDepthTest",void 0),e([o()],s.prototype,"cullAboveTerrain",void 0),e([o()],s.prototype,"hasNormalTextureTransform",void 0),e([o()],s.prototype,"cloudReflections",void 0),e([o()],s.prototype,"snowCover",void 0),e([o()],s.prototype,"renderOccluded",void 0),e([o()],s.prototype,"sphereDepthInterpolate",void 0),e([o({count:2})],s.prototype,"vertexPositionRotationType",void 0),e([o({count:2})],s.prototype,"vertexNormalRotationType",void 0);export{s as ComponentTechniqueConfiguration};
2
+ import{__decorate as t}from"tslib";import{isColorHighlightOrOLID as e}from"../../../core/shaderLibrary/ShaderOutput.js";import{parameter as o}from"../../../core/shaderTechnique/ShaderTechniqueConfiguration.js";import{SphereDepthInterpolateConfiguration as i}from"../../../shaders/SphereDepthInterpolate.glsl.js";class s extends i{constructor(t){super(),this.output=0,this.textureCoordinateType=0,this.componentDataType=0,this.cullFace=2,this.vertexDiscardMode=0,this.doubleSidedMode=2,this.alphaDiscardMode=1,this.integratedMeshMode=0,this.pbrMode=0,this.normalType=0,this.emissionSource=0,this.shadeNormals=1,this.hasEmission=!1,this.hasVertexColors=!1,this.hasSlicePlane=!1,this.isGroundSlice=!1,this.hasColorTexture=!1,this.hasHighlightMixTexture=!1,this.receiveAmbientOcclusion=!0,this.receiveShadows=!0,this.blendingEnabled=!0,this.screenSpaceReflections=!1,this.hasPolygonOffset=!1,this.hasMetallicRoughnessTexture=!1,this.hasOcclusionTexture=!1,this.hasNormalTexture=!1,this.hasOccludees=!1,this.terrainDepthTest=!1,this.cullAboveTerrain=!1,this.hasNormalTextureTransform=!1,this.cloudReflections=!0,this.snowCover=!1,this.renderOccluded=!1,this.sphereDepthInterpolate=!1,this.vertexPositionRotationType=1,this.vertexNormalRotationType=0,this.discardInvisibleFragments=!1,this.oitPremultipliedAlpha=!1,this.occlusionPass=!1,this.bindType=2,this.useCustomDTRExponentForWater=!1,this.hasVertexTangents=!1,this.hasSliceTranslatedView=!1,this.highStepCount=!1,this.instanced=!1,this.instancedDoublePrecision=!1,this.hasModelTransformation=!1,this.useFillLights=!0,this.draped=!1,this.useTransformationTexture=!0,this.sphericalSR=t.sphericalSR,this.hasFloatOit=t.hasFloatOit}get spherical(){return 0!==this.sphericalSR}get overlayEnabled(){return(2===this.integratedMeshMode||3===this.integratedMeshMode)&&e(this.output)}get hasWater(){return 3===this.pbrMode||4===this.pbrMode||6===this.pbrMode}}t([o()],s.prototype,"hasFloatOit",void 0),t([o({count:12})],s.prototype,"output",void 0),t([o({count:3})],s.prototype,"textureCoordinateType",void 0),t([o({count:2})],s.prototype,"componentDataType",void 0),t([o({count:3})],s.prototype,"cullFace",void 0),t([o({count:3})],s.prototype,"vertexDiscardMode",void 0),t([o({count:3})],s.prototype,"doubleSidedMode",void 0),t([o({count:4})],s.prototype,"alphaDiscardMode",void 0),t([o({count:4})],s.prototype,"integratedMeshMode",void 0),t([o({count:7})],s.prototype,"pbrMode",void 0),t([o({count:3})],s.prototype,"normalType",void 0),t([o({count:8})],s.prototype,"emissionSource",void 0),t([o({count:3})],s.prototype,"shadeNormals",void 0),t([o()],s.prototype,"hasEmission",void 0),t([o()],s.prototype,"hasVertexColors",void 0),t([o()],s.prototype,"hasSlicePlane",void 0),t([o()],s.prototype,"isGroundSlice",void 0),t([o()],s.prototype,"hasColorTexture",void 0),t([o()],s.prototype,"hasHighlightMixTexture",void 0),t([o()],s.prototype,"receiveAmbientOcclusion",void 0),t([o()],s.prototype,"receiveShadows",void 0),t([o()],s.prototype,"blendingEnabled",void 0),t([o()],s.prototype,"screenSpaceReflections",void 0),t([o()],s.prototype,"hasPolygonOffset",void 0),t([o()],s.prototype,"hasMetallicRoughnessTexture",void 0),t([o()],s.prototype,"hasOcclusionTexture",void 0),t([o()],s.prototype,"hasNormalTexture",void 0),t([o()],s.prototype,"hasOccludees",void 0),t([o()],s.prototype,"terrainDepthTest",void 0),t([o()],s.prototype,"cullAboveTerrain",void 0),t([o()],s.prototype,"hasNormalTextureTransform",void 0),t([o()],s.prototype,"cloudReflections",void 0),t([o()],s.prototype,"snowCover",void 0),t([o()],s.prototype,"renderOccluded",void 0),t([o()],s.prototype,"sphereDepthInterpolate",void 0),t([o({count:2})],s.prototype,"vertexPositionRotationType",void 0),t([o({count:2})],s.prototype,"vertexNormalRotationType",void 0);export{s as ComponentTechniqueConfiguration};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{__decorate as s}from"tslib";import{disposeMaybe as e}from"../../../../../core/maybe.js";import{subclass as t}from"../../../../../core/accessorSupport/decorators.js";import{fromMat4 as r,transpose as a,invert as i}from"../../../../../core/libs/gl-matrix-2/math/mat3.js";import{create as o}from"../../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{set as h,copy as n}from"../../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as m}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{MaterialPassParameters as c,ShadowMapPassParameters as d,HighlightPassParameters as u,ViewshedShadowMapPassParameters as p,AllRenderPasses as l}from"./AllRenderPasses.js";import{TwoVectorPosition as _}from"../util/TwoVectorPosition.js";import{SyncRenderPlugin as w}from"../../effects/RenderPlugin.js";import{DepthRange as f}from"../../lib/DepthRange.js";import{SizedPixelFormat as P,DataType as g}from"../../../../webgl/enums.js";import x from"../../../../webgl/Texture.js";import{TextureDescriptor as y}from"../../../../webgl/TextureDescriptor.js";let b=class extends w{constructor(){super(...arguments),this.produces=new Map([[2,s=>this._produces(s,2)],[4,s=>this._produces(s,4)],[0,s=>this._produces(s,0)],[8,s=>this._produces(s,8)],[10,s=>this._produces(s,10)]]),this._drawParametersArray=new Array,this._drawParametersSet=new Set,this._transformationTexture=null,this._materialPassParameters=new c,this._shadowPassParameters=new d,this._highlightPassParameters=new u,this._viewshedPassParameters=new p,this._systems=new Set}initializeRenderContext(s){this._context=s,this._passes=new l(s,this)}get rctx(){return this._context.renderContext.rctx}get bind(){return this._context.renderContext.bind}uninitializeRenderContext(){}dispose(){this._context=null,this._systems.clear(),this._transformationTexture=e(this._transformationTexture),this._passes?.opaque.destroy(),this._passes?.transparent.destroy(),this._passes?.integratedMesh.destroy(),this._passes?.transparentIntegratedMesh.destroy(),this._passes?.occludedGround.destroy(),this._passes?.shadowMap.destroy(),this._passes?.highlight.destroy(),this._passes?.highlightIntegratedMesh.destroy(),this._passes?.highlightShadowMap.destroy(),this._passes?.viewshedShadowMap.destroy(),this._passes?.defaultShadowMap.destroy(),this._passes=null}register(s){this._systems.add(s)}_produces(s,e){return!!this._invoke(s,e,s=>s.count>0)}prepareRender(s){const{_systems:t,_passes:r}=this;if(0!==t.size&&null!=r){this._drawParametersSet.clear(),this._drawParametersArray.length=0,this._transformationTexture=e(this._transformationTexture);for(const s of Object.values(r))s.prepareSubmit();t.forEach(e=>e.submit(r,s.bind)),this._updateTransformationTexture();for(const s of Object.values(r))s.finishSubmit();this._context.techniques.frameUpdate()}}acquireTechniques(s){if(0===this._systems.size)return null;const e=5===s.output||6===s.output||7===s.output?this._shadowPassParameters:8===s.output?this._viewshedPassParameters:10===s.output?this._highlightPassParameters:this._materialPassParameters,{bind:t}=s;return this._updateParameters(t.camera,e,t.slot),this._invoke(s.output,s.bind.slot,(e,t)=>(t.transformationTexture=this._transformationTexture,e.acquire(t,s.bind)))}render(s,e){this._invoke(s.output,s.bind.slot,(t,r)=>t.dispatch(r,s.bind,e))}_invoke(s,e,t){if(null==this._passes)return null;switch(e){case 2:switch(s){case 0:case 1:case 2:case 3:case 4:case 11:return t(this._passes.opaque,this._materialPassParameters);case 10:return t(this._passes.highlight,this._highlightPassParameters);case 5:return t(this._passes.shadowMap,this._shadowPassParameters);case 6:return t(this._passes.highlightShadowMap,this._shadowPassParameters);case 7:return t(this._passes.defaultShadowMap,this._shadowPassParameters);case 8:return t(this._passes.viewshedShadowMap,this._viewshedPassParameters)}break;case 4:switch(s){case 0:case 1:case 2:case 3:case 4:case 11:return t(this._passes.transparent,this._materialPassParameters)}break;case 0:switch(s){case 0:case 1:case 2:case 3:case 4:case 11:case 9:return t(this._passes.integratedMesh,this._materialPassParameters);case 10:return t(this._passes.highlightIntegratedMesh,this._highlightPassParameters)}break;case 8:switch(s){case 0:case 1:case 2:return t(this._passes.transparentIntegratedMesh,this._materialPassParameters)}break;case 10:switch(s){case 0:case 1:case 2:case 3:case 4:case 11:return t(this._passes.occludedGround,this._materialPassParameters)}}return null}requestRender(){this._context.requestRender()}queryDepthRange(s){const e=new f;return this._systems.forEach(t=>e.union(t.queryDepthRange(s))),e}get hasEmitters(){let s=!1;return this._systems.forEach(e=>s=e.hasEmissions||s),s}_updateParameters(s,e,t){const o=s.viewInverseTransposeMatrix,m=4===t,c=10===t;h(T,o[3],o[7],o[11]),v.set(T),n(e.transformWorldFromViewTH,v.high),n(e.transformWorldFromViewTL,v.low),n(e.slicePlaneLocalOrigin,T),r(e.transformViewFromCameraRelativeRS,s.viewMatrix),0===e.identifier&&(this._materialPassParameters.transparent=m,this._materialPassParameters.occludedGround=c,a(M,e.transformViewFromCameraRelativeRS),i(e.transformNormalViewFromGlobal,M))}hasHighlight(s){for(const e of this._systems)if(e.hasHighlight(s))return!0;return!1}registerDrawParameters(s){if(!this._drawParametersSet.has(s)){this._drawParametersSet.add(s);const e=this._drawParametersArray.length;this._drawParametersArray.push(s),s.setTransformationDrawId(e)}}_updateTransformationTexture(){const s=this._drawParametersArray.length;if(0===s)return;const e=5,t=3*e,r=2**Math.ceil(Math.log2(s)),a=new Float32Array(r*t);for(let i=0;i<s;i++){const s=this._drawParametersArray[i];s.setTransformationDrawId(i);const e=i*t;a.set(s.transformationFloats,e)}if(this._transformationTexture&&this._transformationTexture.descriptor.height>=s)this._transformationTexture.updateData(0,0,0,e,s,a);else{this._transformationTexture?.dispose();const s=new y(e,r);s.internalFormat=P.RGB32F,s.dataType=g.FLOAT,s.hasMipmap=!1,s.isImmutable=!0,s.pixelFormat=6407,s.samplingMode=9728,this._transformationTexture=new x(this.rctx,s,a)}}};b=s([t("esri.views.3d.webgl-engine.core.renderPasses.RenderPassManager")],b);const T=m(),M=o(),v=new _;export{b as RenderPassManager};
2
+ import{__decorate as s}from"tslib";import{disposeMaybe as e}from"../../../../../core/maybe.js";import{subclass as t}from"../../../../../core/accessorSupport/decorators.js";import{fromMat4 as r,transpose as a,invert as i}from"../../../../../core/libs/gl-matrix-2/math/mat3.js";import{create as o}from"../../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{set as h,copy as n}from"../../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as m}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{MaterialPassParameters as c,ShadowMapPassParameters as d,HighlightPassParameters as u,ViewshedShadowMapPassParameters as p,AllRenderPasses as l}from"./AllRenderPasses.js";import{TwoVectorPosition as _}from"../util/TwoVectorPosition.js";import{SyncRenderPlugin as w}from"../../effects/RenderPlugin.js";import{DepthRange as f}from"../../lib/DepthRange.js";import{SizedPixelFormat as P,DataType as g}from"../../../../webgl/enums.js";import x from"../../../../webgl/Texture.js";import{TextureDescriptor as y}from"../../../../webgl/TextureDescriptor.js";let b=class extends w{constructor(){super(...arguments),this.produces=new Map([[2,s=>this._produces(s,2)],[4,s=>this._produces(s,4)],[0,s=>this._produces(s,0)],[7,s=>this._produces(s,7)],[10,s=>this._produces(s,10)]]),this._drawParametersArray=new Array,this._drawParametersSet=new Set,this._transformationTexture=null,this._materialPassParameters=new c,this._shadowPassParameters=new d,this._highlightPassParameters=new u,this._viewshedPassParameters=new p,this._systems=new Set}initializeRenderContext(s){this._context=s,this._passes=new l(s,this)}get rctx(){return this._context.renderContext.rctx}get bind(){return this._context.renderContext.bind}uninitializeRenderContext(){}dispose(){this._context=null,this._systems.clear(),this._transformationTexture=e(this._transformationTexture),this._passes?.opaque.destroy(),this._passes?.transparent.destroy(),this._passes?.integratedMesh.destroy(),this._passes?.transparentIntegratedMesh.destroy(),this._passes?.occludedGround.destroy(),this._passes?.shadowMap.destroy(),this._passes?.highlight.destroy(),this._passes?.highlightIntegratedMesh.destroy(),this._passes?.highlightShadowMap.destroy(),this._passes?.viewshedShadowMap.destroy(),this._passes?.defaultShadowMap.destroy(),this._passes=null}register(s){this._systems.add(s)}_produces(s,e){return!!this._invoke(s,e,s=>s.count>0)}prepareRender(s){const{_systems:t,_passes:r}=this;if(0!==t.size&&null!=r){this._drawParametersSet.clear(),this._drawParametersArray.length=0,this._transformationTexture=e(this._transformationTexture);for(const s of Object.values(r))s.prepareSubmit();t.forEach(e=>e.submit(r,s.bind)),this._updateTransformationTexture();for(const s of Object.values(r))s.finishSubmit();this._context.techniques.frameUpdate()}}acquireTechniques(s){if(0===this._systems.size)return null;const e=5===s.output||6===s.output||7===s.output?this._shadowPassParameters:8===s.output?this._viewshedPassParameters:10===s.output?this._highlightPassParameters:this._materialPassParameters,{bind:t}=s;return this._updateParameters(t.camera,e,t.slot),this._invoke(s.output,s.bind.slot,(e,t)=>(t.transformationTexture=this._transformationTexture,e.acquire(t,s.bind)))}render(s,e){this._invoke(s.output,s.bind.slot,(t,r)=>t.dispatch(r,s.bind,e))}_invoke(s,e,t){if(null==this._passes)return null;switch(e){case 2:switch(s){case 0:case 1:case 2:case 3:case 4:case 11:return t(this._passes.opaque,this._materialPassParameters);case 10:return t(this._passes.highlight,this._highlightPassParameters);case 5:return t(this._passes.shadowMap,this._shadowPassParameters);case 6:return t(this._passes.highlightShadowMap,this._shadowPassParameters);case 7:return t(this._passes.defaultShadowMap,this._shadowPassParameters);case 8:return t(this._passes.viewshedShadowMap,this._viewshedPassParameters)}break;case 4:switch(s){case 0:case 1:case 2:case 3:case 4:case 11:return t(this._passes.transparent,this._materialPassParameters)}break;case 0:switch(s){case 0:case 1:case 2:case 3:case 4:case 11:case 9:return t(this._passes.integratedMesh,this._materialPassParameters);case 10:return t(this._passes.highlightIntegratedMesh,this._highlightPassParameters)}break;case 7:switch(s){case 0:case 1:case 2:return t(this._passes.transparentIntegratedMesh,this._materialPassParameters)}break;case 10:switch(s){case 0:case 1:case 2:case 3:case 4:case 11:return t(this._passes.occludedGround,this._materialPassParameters)}}return null}requestRender(){this._context.requestRender()}queryDepthRange(s){const e=new f;return this._systems.forEach(t=>e.union(t.queryDepthRange(s))),e}get hasEmitters(){let s=!1;return this._systems.forEach(e=>s=e.hasEmissions||s),s}_updateParameters(s,e,t){const o=s.viewInverseTransposeMatrix,m=4===t,c=10===t;h(T,o[3],o[7],o[11]),v.set(T),n(e.transformWorldFromViewTH,v.high),n(e.transformWorldFromViewTL,v.low),n(e.slicePlaneLocalOrigin,T),r(e.transformViewFromCameraRelativeRS,s.viewMatrix),0===e.identifier&&(this._materialPassParameters.transparent=m,this._materialPassParameters.occludedGround=c,a(M,e.transformViewFromCameraRelativeRS),i(e.transformNormalViewFromGlobal,M))}hasHighlight(s){for(const e of this._systems)if(e.hasHighlight(s))return!0;return!1}registerDrawParameters(s){if(!this._drawParametersSet.has(s)){this._drawParametersSet.add(s);const e=this._drawParametersArray.length;this._drawParametersArray.push(s),s.setTransformationDrawId(e)}}_updateTransformationTexture(){const s=this._drawParametersArray.length;if(0===s)return;const e=5,t=3*e,r=2**Math.ceil(Math.log2(s)),a=new Float32Array(r*t);for(let i=0;i<s;i++){const s=this._drawParametersArray[i];s.setTransformationDrawId(i);const e=i*t;a.set(s.transformationFloats,e)}if(this._transformationTexture&&this._transformationTexture.descriptor.height>=s)this._transformationTexture.updateData(0,0,0,e,s,a);else{this._transformationTexture?.dispose();const s=new y(e,r);s.internalFormat=P.RGB32F,s.dataType=g.FLOAT,s.hasMipmap=!1,s.isImmutable=!0,s.pixelFormat=6407,s.samplingMode=9728,this._transformationTexture=new x(this.rctx,s,a)}}};b=s([t("esri.views.3d.webgl-engine.core.renderPasses.RenderPassManager")],b);const T=m(),M=o(),v=new _;export{b as RenderPassManager};