@arcgis/core 4.33.0-next.20250430 → 4.33.0-next.20250501

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 (94) hide show
  1. package/assets/esri/core/workers/RemoteClient.js +1 -1
  2. package/assets/esri/core/workers/chunks/02b38423276536596aba.js +1 -0
  3. package/assets/esri/core/workers/chunks/3cee3ff926f47aae476f.js +1 -0
  4. package/assets/esri/core/workers/chunks/{cb25b45a6b385e60c68d.js → 653ff3e631fea8ad393a.js} +122 -121
  5. package/assets/esri/core/workers/chunks/6d89d42bcba213be2d9d.js +1 -0
  6. package/assets/esri/core/workers/chunks/6ecc3a3737ae8622dfa4.js +1 -0
  7. package/assets/esri/core/workers/chunks/6fef5a07f75b2a5736ad.js +1 -0
  8. package/assets/esri/core/workers/chunks/6ff46126c82354e6c78e.js +1 -0
  9. package/assets/esri/core/workers/chunks/71dc9d78dec981078a1a.js +1 -0
  10. package/assets/esri/core/workers/chunks/{ab6ecd8eeec5ff761b34.js → 73bca519c93920bc8c9f.js} +1 -1
  11. package/assets/esri/core/workers/chunks/7a282674d77875c58acd.js +1 -0
  12. package/assets/esri/core/workers/chunks/9652cfd4668b95036c87.js +39 -0
  13. package/assets/esri/core/workers/chunks/9f07919ade6707b103da.js +1 -0
  14. package/assets/esri/core/workers/chunks/{d3174ff4dd5acd16485a.js → c041f4a1d18d42e27ad7.js} +1 -1
  15. package/assets/esri/core/workers/chunks/c9a2c4fd169b943db4b4.js +1 -0
  16. package/chunks/SSAO.glsl.js +43 -42
  17. package/core/NestedMap.js +1 -1
  18. package/core/deprecate.js +1 -1
  19. package/interfaces.d.ts +232 -39
  20. package/layers/MapImageLayer.js +1 -1
  21. package/layers/RouteLayer.js +1 -1
  22. package/layers/mixins/operationalLayers.js +1 -1
  23. package/layers/save/mapImageLayerUtils.js +5 -0
  24. package/package.json +1 -1
  25. package/portal/support/portalItemUtils.js +1 -1
  26. package/support/revision.js +1 -1
  27. package/views/3d/environment/EnvironmentManager.js +1 -1
  28. package/views/3d/glTF/LoaderResult.js +1 -1
  29. package/views/3d/glTF/loader.js +1 -1
  30. package/views/3d/interactive/Manipulator3D.js +1 -1
  31. package/views/3d/interactive/visualElements/Object3DVisualElement.js +1 -1
  32. package/views/3d/interactive/visualElements/VisualElementResources.js +1 -1
  33. package/views/3d/layers/I3SMeshView3D.js +1 -1
  34. package/views/3d/layers/SceneLayerGraphicsView3D.js +1 -1
  35. package/views/3d/layers/graphics/DeconflictAABR.js +5 -0
  36. package/views/3d/layers/graphics/Deconflictor.js +1 -1
  37. package/views/3d/layers/graphics/Graphics3DDrapedGraphicLayer.js +1 -1
  38. package/views/3d/layers/graphics/Graphics3DGraphic.js +1 -1
  39. package/views/3d/layers/graphics/Graphics3DObject3DGraphicLayer.js +1 -1
  40. package/views/3d/layers/graphics/Labeler.js +1 -1
  41. package/views/3d/layers/graphics/objectResourceUtils.js +1 -1
  42. package/views/3d/layers/graphics/pipeline/rendering/DirectRenderer.js +1 -1
  43. package/views/3d/layers/support/StageLayerElevationProvider.js +1 -1
  44. package/views/3d/webgl-engine/Stage.js +1 -1
  45. package/views/3d/webgl-engine/core/FBOCacheFormats.js +1 -1
  46. package/views/3d/webgl-engine/core/renderPasses/AllRenderPasses.js +1 -1
  47. package/views/3d/webgl-engine/core/shaderLibrary/shading/ReadShadowMap.glsl.js +2 -2
  48. package/views/3d/webgl-engine/lib/ContentObjectType.js +1 -1
  49. package/views/3d/webgl-engine/lib/GPUPointOcclusionQuery.js +5 -0
  50. package/views/3d/webgl-engine/lib/GridLocalOriginFactory.js +1 -1
  51. package/views/3d/webgl-engine/lib/Intersector.js +1 -1
  52. package/views/3d/webgl-engine/lib/IntersectorTarget.js +1 -1
  53. package/views/3d/webgl-engine/lib/ModelDirtySet.js +1 -1
  54. package/views/3d/webgl-engine/lib/Object3D.js +1 -1
  55. package/views/3d/webgl-engine/lib/Octree.js +1 -1
  56. package/views/3d/webgl-engine/lib/OrderIndependentTransparency.js +1 -1
  57. package/views/3d/webgl-engine/lib/RendererBase.js +1 -1
  58. package/views/3d/webgl-engine/lib/ShadowMap.js +1 -1
  59. package/views/3d/webgl-engine/lib/WebGLLayer.js +1 -1
  60. package/views/3d/webgl-engine/lib/depthRangeUtils.js +1 -1
  61. package/views/3d/webgl-engine/materials/DefaultMaterial.js +1 -1
  62. package/views/3d/webgl-engine/materials/WaterTechnique.js +1 -1
  63. package/views/3d/webgl-engine/parts/Model.js +1 -1
  64. package/views/3d/webgl-engine/shaders/ColorMaterialTechnique.js +1 -1
  65. package/views/3d/webgl-engine/shaders/DefaultMaterialTechnique.js +1 -1
  66. package/views/3d/webgl-engine/shaders/ImageMaterialTechnique.js +1 -1
  67. package/views/3d/webgl-engine/shaders/PatternTechnique.js +1 -1
  68. package/views/SelectionManager.js +1 -1
  69. package/views/ui/DefaultUI.js +1 -1
  70. package/views/webgl/Sync.js +5 -0
  71. package/widgets/Directions/DirectionsViewModel.js +1 -1
  72. package/widgets/Directions.js +1 -1
  73. package/widgets/FeatureTable/FeatureTableViewModel.js +1 -1
  74. package/widgets/FeatureTable/support/AttachmentsViewOptions.d.ts +4 -0
  75. package/widgets/FeatureTable.js +1 -1
  76. package/widgets/Fullscreen/FullscreenViewModel.js +1 -1
  77. package/widgets/Fullscreen.js +1 -1
  78. package/widgets/LayerList/LayerListItem.js +1 -1
  79. package/widgets/LayerList/ListItemPanel.js +1 -1
  80. package/widgets/NavigationToggle/NavigationToggleViewModel.js +1 -1
  81. package/widgets/NavigationToggle.js +1 -1
  82. package/widgets/TableList/ListItemPanel.js +1 -1
  83. package/widgets/Weather/WeatherViewModel.js +1 -1
  84. package/widgets/Weather.js +1 -1
  85. package/assets/esri/core/workers/chunks/25142d431dd1e5e82234.js +0 -1
  86. package/assets/esri/core/workers/chunks/2c92f6f268aa2de5432c.js +0 -1
  87. package/assets/esri/core/workers/chunks/7fce62ef3f0b011e0d35.js +0 -1
  88. package/assets/esri/core/workers/chunks/8c8d812a7f2d29c29676.js +0 -1
  89. package/assets/esri/core/workers/chunks/b780c7062b1b18a5ae19.js +0 -1
  90. package/assets/esri/core/workers/chunks/b8248939373e25a8d6db.js +0 -1
  91. package/assets/esri/core/workers/chunks/baa9fd23414f03ef90bc.js +0 -1
  92. package/assets/esri/core/workers/chunks/c819535525e9a27bae1f.js +0 -39
  93. package/assets/esri/core/workers/chunks/e08bff9f8247909776a4.js +0 -1
  94. package/assets/esri/core/workers/chunks/f2bc75a718a10065011d.js +0 -1
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{c as e,t,g as i}from"../../../../chunks/vec32.js";import{create as s}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{setMin as a,setMax as n,create as r,isPoint as o,empty as l,center as c,offset as g}from"../../../../geometry/support/aaBoundingBox.js";import{a as h}from"../../../../chunks/sphere.js";import{evaluateElevationInfoAtPoint as d}from"./elevationAlignmentUtils.js";import{setContextFeature as b}from"./featureExpressionInfoUtils.js";import{demResolutionForBoundingBox as u}from"./graphicUtils.js";import{Object3DState as O}from"../../webgl-engine/lib/basicInterfaces.js";import{Transparency as j}from"../../webgl-engine/lib/edgeRendering/interfaces.js";class m{constructor(e,t,i){this.baseMaterial=e,this.edgeMaterial=t,this.hasSlicePlane=i}}class p{get isElevationSource(){return!!this.stageObject.lastValidElevationBB}constructor(e,t,i,s,a,n=null){this.graphics3DSymbolLayer=e,this.stageObject=t,this._sharedResource=i,this.elevationAligner=s,this.elevationContext=a,this._edgeState=n,this.type="object3d",this._stageLayer=null,this._visible=!1,this._addedToStage=!1,this.alignedSampledElevation=0,this.needsElevationUpdates=!1,this.useObjectOriginAsAttachmentOrigin=!1}initialize(e){this._stageLayer=e;e.stage.add(this.stageObject)}destroy(){if(!this._stageLayer)return;const e=this._stageLayer.stage;e.remove(this.stageObject),this._addedToStage&&(this._stageLayer.remove(this.stageObject),this._addedToStage=!1),e.renderer.edgeView?.removeObject(this.stageObject),this.stageObject.dispose(),this._sharedResource?.release(),this._visible=!1,this._stageLayer=null}get usedMemory(){return this.graphics3DSymbolLayer.usedMemory}layerOpacityChanged(e,t){const{stageObject:i,_edgeState:s,_stageLayer:a}=this;if(null==s)return;const n=v(s.baseMaterial);s.edgeMaterial.objectTransparency!==n&&(s.edgeMaterial.objectTransparency=n,this.resetEdgeObject(t)),a.stage.renderer.withEdgeView((t=>t.updateAllComponentOpacities(i,[e])))}updateHighlights(e){}slicePlaneEnabledChanged(e,t){const{stageObject:i,_edgeState:s,_stageLayer:a}=this;null!=s&&a.stage.renderer.withEdgeView((a=>{a.updateAllComponentMaterials(i,s.edgeMaterial,e,!t),s.hasSlicePlane=e}))}setVisibility(e){const{_edgeState:t,stageObject:i,_stageLayer:s}=this;null!=s&&this.visible!==e&&(this._visible=e,i.visible=e,e&&!this._addedToStage&&(s.add(i),this._addedToStage=!0),null!=t&&s.stage.renderer.withEdgeView((s=>{s.hasObject(i)?s.updateObjectVisibility(i,e):e&&this._addOrUpdateEdgeObject(t,s,!1)})))}get visible(){return this._visible}alignWithElevation(e,t,i,s){if(null==this.elevationAligner)return;null!=i&&b(this.elevationContext.featureExpressionInfoContext,i);const a=(i,s)=>d(i,e,this.elevationContext,t,s);this.alignedSampledElevation=this.elevationAligner(this,this.elevationContext,e.spatialReference,a,t),this.resetEdgeObject(s)}alignWithAbsoluteElevation(e,t,i){const s=(t,i)=>{i.sampledElevation=e,i.verticalDistanceToGround=0,i.z=e};this.alignedSampledElevation=this.elevationAligner(this,this.elevationContext,null,s,t),this.resetEdgeObject(i)}getCenterObjectSpace(t=s()){return e(t,h(this.stageObject.boundingVolumeObjectSpace.bounds))}getBoundingBoxObjectSpace(e=r()){const t=this.stageObject.boundingVolumeObjectSpace;return a(e,t.min),n(e,t.max),e}computeAttachmentOrigin(e){const s=this.stageObject.effectiveTransformation;if(this.useObjectOriginAsAttachmentOrigin)e.render.origin[0]+=s[12],e.render.origin[1]+=s[13],e.render.origin[2]+=s[14],e.render.num++;else for(const a of this.stageObject.geometries)a.computeAttachmentOrigin(S)&&(t(S,S,s),i(e.render.origin,e.render.origin,S),e.render.num++)}async getProjectedBoundingBox(e,i,s,a,n){const r=this.getBoundingBoxObjectSpace(n),h=_,d=o(r)?1:h.length;for(let o=0;o<d;o++){const e=h[o];y[0]=r[e[0]],y[1]=r[e[1]],y[2]=r[e[2]],t(y,y,this.stageObject.transformation),f[3*o]=y[0],f[3*o+1]=y[1],f[3*o+2]=y[2]}if(!e(f,0,d))return null;l(r);let b=null;this.calculateRelativeScreenBounds&&(b=this.calculateRelativeScreenBounds());for(let t=0;t<3*d;t+=3){for(let e=0;e<3;e++)r[e]=Math.min(r[e],f[t+e]),r[e+3]=Math.max(r[e+3],f[t+e]);b&&s.push({location:f.slice(t,t+3),screenSpaceBoundingRect:b})}if(i?.service&&"absolute-height"!==this.elevationContext.mode){c(r,S);const e="relative-to-scene"===this.elevationContext.mode?"scene":"ground";let t=0;if(i.useViewElevation)t=i.service.getElevation(S[0],S[1],e)??0;else try{const s=u(r,i.service.spatialReference,i);t=await i.service.queryElevation(S[0],S[1],a,s,e)??0}catch(O){}g(r,0,0,-this.alignedSampledElevation+t)}return r}addObjectState(e){e.stateType===O.Highlight&&e.addObject(this.stageObject,this.stageObject.highlight(e.highlightName)),e.stateType===O.MaskOccludee&&e.addObject(this.stageObject,this.stageObject.maskOccludee())}removeObjectState(e){e.removeByObject(this.stageObject)}resetEdgeObject(e){const{_edgeState:t,stageObject:i,_stageLayer:s,_visible:a}=this;null!=t&&s.stage.renderer.withEdgeView((s=>{a?this._addOrUpdateEdgeObject(t,s,e):s.removeObject(i)}))}_addOrUpdateEdgeObject(e,t,i){const s=v(e.baseMaterial);e.edgeMaterial.objectTransparency=s,t.addOrUpdateObject3D(this.stageObject,e.edgeMaterial,e.hasSlicePlane,!i).then((()=>this._stageLayer?.sync()))}}function v(e){return e.transparent?j.TRANSPARENT:j.OPAQUE}const f=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],y=s(),S=s(),_=[[0,1,2],[3,1,2],[0,4,2],[3,4,2],[0,1,5],[3,1,5],[0,4,5],[3,4,5]];export{p as Graphics3DObject3DGraphicLayer,m as Object3DEdgeState};
5
+ import{c as e,t,g as i}from"../../../../chunks/vec32.js";import{create as s}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{setMin as a,setMax as n,create as r,isPoint as o,empty as l,center as c,offset as g}from"../../../../geometry/support/aaBoundingBox.js";import{a as h}from"../../../../chunks/sphere.js";import{evaluateElevationInfoAtPoint as d}from"./elevationAlignmentUtils.js";import{setContextFeature as b}from"./featureExpressionInfoUtils.js";import{demResolutionForBoundingBox as u}from"./graphicUtils.js";import{Object3DState as O}from"../../webgl-engine/lib/basicInterfaces.js";import{Transparency as j}from"../../webgl-engine/lib/edgeRendering/interfaces.js";class m{constructor(e,t,i){this.baseMaterial=e,this.edgeMaterial=t,this.hasSlicePlane=i}}class p{get isElevationSource(){return!!this.stageObject.lastValidElevationBB}constructor(e,t,i,s,a,n=null){this.graphics3DSymbolLayer=e,this.stageObject=t,this._sharedResource=i,this.elevationAligner=s,this.elevationContext=a,this._edgeState=n,this.type="object3d",this._stageLayer=null,this._visible=!1,this._addedToStage=!1,this.alignedSampledElevation=0,this.needsElevationUpdates=!1,this.useObjectOriginAsAttachmentOrigin=!1}initialize(e){this._stageLayer=e}destroy(){if(!this._stageLayer)return;const e=this._stageLayer.stage;this._addedToStage&&(this._stageLayer.remove(this.stageObject),this._addedToStage=!1),e.renderer.edgeView?.removeObject(this.stageObject),this.stageObject.dispose(),this._sharedResource?.release(),this._visible=!1,this._stageLayer=null}get usedMemory(){return this.graphics3DSymbolLayer.usedMemory}layerOpacityChanged(e,t){const{stageObject:i,_edgeState:s,_stageLayer:a}=this;if(null==s)return;const n=v(s.baseMaterial);s.edgeMaterial.objectTransparency!==n&&(s.edgeMaterial.objectTransparency=n,this.resetEdgeObject(t)),a.stage.renderer.withEdgeView((t=>t.updateAllComponentOpacities(i,[e])))}updateHighlights(e){}slicePlaneEnabledChanged(e,t){const{stageObject:i,_edgeState:s,_stageLayer:a}=this;null!=s&&a.stage.renderer.withEdgeView((a=>{a.updateAllComponentMaterials(i,s.edgeMaterial,e,!t),s.hasSlicePlane=e}))}setVisibility(e){const{_edgeState:t,stageObject:i,_stageLayer:s}=this;null!=s&&this.visible!==e&&(this._visible=e,i.visible=e,e&&!this._addedToStage&&(s.add(i),this._addedToStage=!0),null!=t&&s.stage.renderer.withEdgeView((s=>{s.hasObject(i)?s.updateObjectVisibility(i,e):e&&this._addOrUpdateEdgeObject(t,s,!1)})))}get visible(){return this._visible}alignWithElevation(e,t,i,s){if(null==this.elevationAligner)return;null!=i&&b(this.elevationContext.featureExpressionInfoContext,i);const a=(i,s)=>d(i,e,this.elevationContext,t,s);this.alignedSampledElevation=this.elevationAligner(this,this.elevationContext,e.spatialReference,a,t),this.resetEdgeObject(s)}alignWithAbsoluteElevation(e,t,i){const s=(t,i)=>{i.sampledElevation=e,i.verticalDistanceToGround=0,i.z=e};this.alignedSampledElevation=this.elevationAligner(this,this.elevationContext,null,s,t),this.resetEdgeObject(i)}getCenterObjectSpace(t=s()){return e(t,h(this.stageObject.boundingVolumeObjectSpace.bounds))}getBoundingBoxObjectSpace(e=r()){const t=this.stageObject.boundingVolumeObjectSpace;return a(e,t.min),n(e,t.max),e}computeAttachmentOrigin(e){const s=this.stageObject.effectiveTransformation;if(this.useObjectOriginAsAttachmentOrigin)e.render.origin[0]+=s[12],e.render.origin[1]+=s[13],e.render.origin[2]+=s[14],e.render.num++;else for(const a of this.stageObject.geometries)a.computeAttachmentOrigin(S)&&(t(S,S,s),i(e.render.origin,e.render.origin,S),e.render.num++)}async getProjectedBoundingBox(e,i,s,a,n){const r=this.getBoundingBoxObjectSpace(n),h=_,d=o(r)?1:h.length;for(let o=0;o<d;o++){const e=h[o];y[0]=r[e[0]],y[1]=r[e[1]],y[2]=r[e[2]],t(y,y,this.stageObject.transformation),f[3*o]=y[0],f[3*o+1]=y[1],f[3*o+2]=y[2]}if(!e(f,0,d))return null;l(r);let b=null;this.calculateRelativeScreenBounds&&(b=this.calculateRelativeScreenBounds());for(let t=0;t<3*d;t+=3){for(let e=0;e<3;e++)r[e]=Math.min(r[e],f[t+e]),r[e+3]=Math.max(r[e+3],f[t+e]);b&&s.push({location:f.slice(t,t+3),screenSpaceBoundingRect:b})}if(i?.service&&"absolute-height"!==this.elevationContext.mode){c(r,S);const e="relative-to-scene"===this.elevationContext.mode?"scene":"ground";let t=0;if(i.useViewElevation)t=i.service.getElevation(S[0],S[1],e)??0;else try{const s=u(r,i.service.spatialReference,i);t=await i.service.queryElevation(S[0],S[1],a,s,e)??0}catch(O){}g(r,0,0,-this.alignedSampledElevation+t)}return r}addObjectState(e){e.stateType===O.Highlight&&e.addObject(this.stageObject,this.stageObject.highlight(e.highlightName)),e.stateType===O.MaskOccludee&&e.addObject(this.stageObject,this.stageObject.maskOccludee())}removeObjectState(e){e.removeByObject(this.stageObject)}resetEdgeObject(e){const{_edgeState:t,stageObject:i,_stageLayer:s,_visible:a}=this;null!=t&&s.stage.renderer.withEdgeView((s=>{a?this._addOrUpdateEdgeObject(t,s,e):s.removeObject(i)}))}_addOrUpdateEdgeObject(e,t,i){const s=v(e.baseMaterial);e.edgeMaterial.objectTransparency=s,t.addOrUpdateObject3D(this.stageObject,e.edgeMaterial,e.hasSlicePlane,!i).then((()=>this._stageLayer?.sync()))}}function v(e){return e.transparent?j.TRANSPARENT:j.OPAQUE}const f=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],y=s(),S=s(),_=[[0,1,2],[3,1,2],[0,4,2],[3,4,2],[0,1,5],[3,1,5],[0,4,5],[3,4,5]];export{p as Graphics3DObject3DGraphicLayer,m as Object3DEdgeState};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../../chunks/tslib.es6.js";import t from"../../../../core/Accessor.js";import{forEach as s,result as i}from"../../../../core/asyncUtils.js";import"../../../../core/has.js";import r from"../../../../core/Logger.js";import{disposeMaybe as a,abortMaybe as l}from"../../../../core/maybe.js";import{throwIfAborted as o,isAbortError as n}from"../../../../core/promiseUtils.js";import{watch as c}from"../../../../core/reactiveUtils.js";import{property as h}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/RandomLCG.js";import{subclass as b}from"../../../../core/accessorSupport/decorators/subclass.js";import{fromValues as p}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{hydrateGraphic as u}from"../../../../layers/graphics/hydratedFeatures.js";import{createLabelFunction as d}from"../../../../layers/support/labelFormatUtils.js";import{hasCalloutSupport as y}from"../../../../symbols/callouts/calloutUtils.js";import{VisibilityGroup as g,VisibilityFlag as m}from"./enums.js";import{make as f}from"./Graphics3DCalloutSymbolLayerFactory.js";import{LineCalloutSymbolLayerRenderingInfo as x,LineCalloutCreationContext as C}from"./Graphics3DLineCalloutSymbolLayer.js";import{getGraphics3DSymbol as _}from"./graphicSymbolUtils.js";import{LabelInfo as L}from"./LabelInfo.js";import{LabelParameters as v}from"./LabelParameters.js";import{horizontalPlacementFromAnchor as G,verticalPlacementFromAnchor as D,textRenderAlignmentFromHorizontalPlacement as w}from"./placementUtils.js";import{placePointOnGeometry as A}from"./pointUtils.js";import{TextRenderer as I}from"../../webgl-engine/lib/TextRenderer.js";import{TextRenderParameters as T}from"../../webgl-engine/lib/TextRenderParameters.js";import{TextTextureAtlas as S}from"../../webgl-engine/lib/TextTextureAtlas.js";import{VertexAttribute as R}from"../../webgl-engine/lib/VertexAttribute.js";import{WebGLLayer as P}from"../../webgl-engine/lib/WebGLLayer.js";import{TaskPriority as j}from"../../../support/Scheduler.js";import{Yield as E}from"../../../support/Yield.js";class O{constructor(e,t){this.labelingContext=e,this.graphics3DGraphic=t,this.hasGraphics3DResources=!1,this.visible=!1,this.textureAtlasHandles=[],this.textInitialized=!1,this.textRenderers=new Array,this.textLabelPlacements=new Array}}class V{constructor(e,t,s,i,r){this.labelClass=e,this.graphics3DSymbol=t,this.graphics3DCalloutSymbolLayer=s,this.textRenderParameters=i,this.labelFunction=r,this.calloutSymbolLayerIndex=0}}class F{constructor(e,t,s,i,r,a,l,o){this.layer=t,this.graphics3DCore=s,this.scaleVisibility=i,this.emptySymbolLabelSupported=r,this.elevationInfoOverride=a,this.disablePlacement=l,this.active=o,this.labelClassAbortController=new AbortController,this.labelClassContexts=new Array,this.graphics=new Map,this.labelsToInitialize=new Map,this.stageLayer=new P(e,{pickable:!0},s.owner.layerViewUid)}destroy(){this.stageLayer.destroy()}}let U=class extends t{constructor(e){super(e),this._hudMaterials=new Map,this._calloutMaterials=new Map,this._dirty=!1,this._labels=new Map,this._labelingContexts=new Array}setup(){this.dispose(),this.addHandles([c((()=>this.view.state?.camera),(()=>this.setDirty())),c((()=>this.view.state?.rasterPixelRatio),(()=>this._resetAllLabels())),c((()=>this.view.focusAreas.activePolygons),(()=>this._updateFocus())),this.view.resourceController.scheduler.registerTask(j.LABELER,this)]),this._textTextureAtlas=new S({view:this.view})}dispose(){this.removeAllHandles(),this._textTextureAtlas=a(this._textTextureAtlas),this._hudMaterials.clear(),this._calloutMaterials.clear(),this._labelingContexts.length=0,this._labels.clear()}destroy(){this.dispose(),W.graphic=null,W.renderingInfo=null,W.layer=null}_updateFocus(){this._labelingContexts.forEach((e=>{e.graphics.forEach((t=>{if(0===t.labelLayers.length)return;const s=A(t.graphic.geometry);if(null==s)return;const i=this.view.focusAreas.containsGeometry(s);t.labelLayers.forEach((s=>{const r=s.stageObject.geometries.some((e=>e.material.parameters.isFocused!==i));r&&(this._removeGraphic(e,t),this._addGraphic(e,t),this.setDirty())}))}))}))}_activateLabelingContext(e){e.graphics.forEach(((t,s)=>{const i=new O(e,t);this._labels.set(s,i),e.labelsToInitialize.set(s,i),t.setVisibilityFlag(g.LABEL,m.USER,!0)})),e.active=!0}_deactivateLabelingContext(e){e.graphics.forEach(((e,t)=>{e.setVisibilityFlag(g.LABEL,m.USER,!1),this.setLabelGraphicVisibility(e,!1),e.clearLabelGraphics(),this._labels.delete(t)})),e.active=!1}_addLabelTextureToAtlas(e){for(const t of e.graphics3DGraphic.labelLayers){if(!t._labelClass)continue;const s=e.textRenderers[t._labelIndex];s&&(e.textureAtlasHandles.push(this._textTextureAtlas.addText(s,(e=>H(t.stageObject,e)))),z(t.stageObject,s))}}_removeLabelTextureFromAtlas(e){e.textureAtlasHandles.forEach((e=>e.remove())),e.textureAtlasHandles.length=0}get running(){return this.view.ready&&(this._dirty||this.deconflictor.running)}runTask(e){return this._updateLabels(e),!this._dirty&&this.deconflictor.running&&this.deconflictor.runTask(e),E}_updateLabels(e){if(this._dirty){this._dirty=!1;for(const t of this._labelingContexts)if(t.active)if(M(t))this._dirty=!0;else if(k(t.labelClassContexts)){if(null===t.labelClassContexts){this._deactivateLabelingContext(t);continue}this._createLabelClassContext(t),this._dirty=!0}else for(const[s,i]of t.labelsToInitialize)if(this._ensureGraphics3DResources(i)&&(this._labels.set(s,i),this.deconflictor.setDirty(),e.madeProgress()),(i.visible&&i.textInitialized||!i.visible&&i.hasGraphics3DResources)&&(t.labelsToInitialize.delete(s),e.madeProgress()),e.done){this._dirty=!0;break}this._dirty||this.notifyChange("updating")}}async _createLabelClassContextAsync(e){const t=e.labelClassAbortController?.signal;e.layer.when&&await e.layer.when(),o(t),e.scaleVisibility?.updateScaleRangeActive();const a=e.graphics3DCore,l=a.layer,n=l.labelingInfo?.filter((e=>!!e.symbol));if(!n||0===n.length)return;let c=!1;await s(n,(async(s,l)=>{const n=s.symbol,h=_(a.getOrCreateGraphics3DSymbol(n));if(null==h)return void r.getLogger(this).error("Failed to create Graphics3DSymbol for label");await h.load(),o(t);let b=null;y(n)&&n.hasVisibleCallout()&&(b=f(n,a.symbolCreationContext),await b.load(),o(t));const p=await i(d(s,e.layer.fieldsIndex,this.view.spatialReference));if(o(t),!0===p.ok){const i=await this._createTextRenderParameters(h.symbol);o(t),e.labelClassContexts[l]=new V(s,h,b,i,p.value)}else r.getLogger(this).error(`Label expression failed to evaluate: ${p.error}`),c=!0})),o(t)}async _createLabelClassContext(e){return null==e.labelClassPromise&&(e.labelClassPromise=this._createLabelClassContextAsync(e).catch((t=>{if(n(t))throw t;e.labelClassContexts.length=0})).then((()=>{e.labelClassAbortController=null,this.notifyChange("updating")})).catch((()=>{})),this.notifyChange("updating")),e.labelClassPromise}async _createTextRenderParameters(e){const t=e.symbolLayers.at(0);return"text"!==t?.type?null:T.fromSymbol(t,this.view.state.rasterPixelRatio)}_destroyLabelClassContext(e){for(const s of e.labelClassContexts)--s.graphics3DSymbol.referenced;const t=e.labelClassAbortController;e.labelClassAbortController=new AbortController,l(t),e.labelClassContexts.length=0,e.labelClassPromise=null,this.notifyChange("updating")}_createTextSymbolGraphic(e,t,s,i,r,a){const l=new v(s,G(s.anchor),D(s.anchor),e.text,p(e.displayWidth,e.displayHeight));return W.graphic=t,W.layer=i,W.renderingInfo=null,r.createLabel(W,l,this._hudMaterials,this._textTextureAtlas,(()=>a.placement?.elevationOffset??null))}_createLineCalloutGraphic(e,t,s,i,r){W.graphic=e,W.layer=r;const a=i.screenOffset[0];return W.renderingInfo=new x(null,t,i.translation,i.centerOffset,a,i.centerOffsetUnits,i.elevationOffset),s.createGraphics3DGraphic(W,this._calloutMaterials)}_ensureGraphics3DResources(e){if(e.hasGraphics3DResources)return!1;const t=e.graphics3DGraphic;if(t.destroyed)return!1;this._ensureTextTextureResources(e);const s=e.labelingContext,i=s.labelClassContexts;if(k(i)||!s.emptySymbolLabelSupported&&0===t.layers.length)return!1;let r=!1;const a=t.graphic,l=s.layer,o=N(s.layer);for(let n=0;n<i.length;n++){const c=e.textRenderers[n],h=e.textLabelPlacements[n];if(null==c||null==h)continue;const b=i[n],p=b.graphics3DSymbol,u=B(p),d=p.symbolLayers[0];if(!d)continue;d.setElevationInfoOverride(s.elevationInfoOverride);const y=new L(t,u,b.labelClass),f=this._createTextSymbolGraphic(c,a,h,l,d,y);if(null==f)return!1;f._labelClass=b.labelClass,f._labelIndex=n,t.addLabelGraphic(f,s.stageLayer),t.deconflictionPriority=b.textRenderParameters?.definition.size??0,t.setVisibilityFlag(g.LABEL,m.USER,o),t.setVisibilityFlag(g.LABEL,m.SCALE_RANGE,!0),t.setVisibilityFlag(g.LABEL,m.DECONFLICTION,!1),r=!0;const x=b.graphics3DCalloutSymbolLayer;if(x&&h.hasLabelVerticalOffset){x.setElevationInfoOverride(s.elevationInfoOverride);const e=this._createLineCalloutGraphic(a,u,x,h,l);null!=e&&(b.calloutSymbolLayerIndex=t.labelLayers.length,t.addLabelGraphic(e,s.stageLayer))}break}return r&&s.scaleVisibility?.updateGraphicLabelScaleVisibility(t),e.hasGraphics3DResources=!0,!0}_destroyGraphics3DResources(e){const t=e.labelingContext.labelClassContexts;for(const s of e.graphics3DGraphic.labelLayers){if(null==s._labelClass)continue;const e=t[s._labelIndex].graphics3DSymbol.symbolLayers[0];e?.onRemoveGraphic(s)}e.graphics3DGraphic.deconflictionPriority=0,e.graphics3DGraphic.clearLabelGraphics(),e.hasGraphics3DResources=!1}_ensureTextTextureResources(e){if(e.textInitialized)return;const t=e.labelingContext,s=t.labelClassContexts;if(k(s))return;const i=e.graphics3DGraphic.graphic;for(let a=0;a<s.length;a++){const l=s[a];if(e.textRenderers[a]=null,e.textLabelPlacements[a]=null,null==l?.textRenderParameters)continue;const o=l.labelFunction;let n;if("arcade"===o.type)try{const e=o.needsHydrationToEvaluate()?u(i,t.layer):i;n=o.evaluate(e)}catch(r){n=null}else n=o.evaluate(i);if(null==n||""===n||/^\s+$/.test(n))continue;const c=l.graphics3DSymbol;if(!c.symbolLayers[0])continue;const h=e.graphics3DGraphic,b="label-3d"===c.symbol?.type?c.symbol:null,p=l.labelClass,d=t.disablePlacement,y=new L(h,b,p,d).placement;if(null==y)continue;const g=G(y.anchor),m=w(g);e.textRenderers[a]=new I(n,m,l.textRenderParameters,S.maxSize),e.textLabelPlacements[a]=y}e.textInitialized=!0}_destroyTextTextureResources(e){e.textInitialized=!1,e.textRenderers.length=0,e.textLabelPlacements.length=0}_addGraphic(e,t){const s=t.graphic.uid;if(e.graphics.set(s,t),e.active){const i=new O(e,t);this._labels.set(s,i),e.labelsToInitialize.set(s,i)}this.setDirty(),this.deconflictor.setDirty()}_updateGraphicGeometry(e,t){const s=t.graphic.uid,i=this._labels.get(s);if(!i)return!0;for(const r of i.graphics3DGraphic.labelLayers){if(null==r._labelClass)continue;if(!e.labelClassContexts[r._labelIndex].graphics3DSymbol.symbolLayers[0].updateGeometry(r,t.graphic.geometry))return!1}return this.setDirty(),this.deconflictor.setDirty(),!0}_removeGraphic(e,t){const s=t.graphic.uid,i=this._labels.get(s);e.graphics.delete(s),i&&(this._destroyGraphic(i,s),e.labelsToInitialize.delete(s),this.setDirty(),this.deconflictor.setDirty())}_destroyGraphic(e,t){this._labels.delete(t),e.textureAtlasHandles.length&&this._removeLabelTextureFromAtlas(e),this._destroyTextTextureResources(e),e.hasGraphics3DResources&&this._destroyGraphics3DResources(e)}async _labelingInfoChange(e,t){if(!t)return this._visibilityInfoChange(e),this._resetLabels(e),this._createLabelClassContext(e);for(const s of t){const t=e.graphics.get(s);t&&(this._removeGraphic(e,t),this._addGraphic(e,t))}}_globalPropertyChanged(e,t){for(const s of t.labelClassContexts){const i=new Map;t.graphics.forEach((e=>i.set(e.graphic.uid,e)));const r=e=>e.labelLayers[0];if(s.graphics3DSymbol.symbolLayers[0].globalPropertyChanged(e,i,r),s.graphics3DCalloutSymbolLayer){const t=e=>e.labelLayers[s.calloutSymbolLayerIndex];s.graphics3DCalloutSymbolLayer.globalPropertyChanged(e,i,t)}}}_visibilityInfoChange(e){const t=N(e.layer);t&&!e.active&&this._activateLabelingContext(e),!t&&e.active&&this._deactivateLabelingContext(e),this.setDirty()}_resetAllLabels(){for(const e of this._labelingContexts)this._resetLabels(e)}_resetLabels(e){e.graphics.forEach(((t,s)=>{const i=this._labels.get(s);i&&(this._destroyGraphic(i,s),i.visible=!1,e.labelsToInitialize.set(s,i))})),this._destroyLabelClassContext(e),this.setDirty(),this.deconflictor.setDirty()}_findLabelingContext(e){for(const t of this._labelingContexts)if(t.graphics3DCore===e)return t;return null}addGraphicsOwner(e,t,s){const i=s?.emptySymbolLabelSupported||!1,r=s?.elevationInfoOverride||null,a=s?.disablePlacement||null;if(this._findLabelingContext(e))return;const l=e.layer,o=new F(this.view.stage,l,e,t,i,r,a,N(l));return this._labelingContexts.push(o),this.setDirty(),{addGraphic:e=>this._addGraphic(o,e),removeGraphic:e=>this._removeGraphic(o,e),updateGraphicGeometry:e=>this._updateGraphicGeometry(o,e),layerLabelsEnabled:()=>N(o.layer),labelingInfoChange:e=>this._labelingInfoChange(o,e),elevationInfoChange:()=>this._globalPropertyChanged("elevationInfo",o),slicePlaneEnabledChange:()=>this._globalPropertyChanged("slicePlaneEnabled",o),visibilityInfoChange:()=>this._visibilityInfoChange(o),reset:()=>this._resetLabels(o),remove:()=>this._removeGraphicsOwner(e),setDirty:()=>this.setDirty()}}_removeGraphicsOwner(e){const t=this._findLabelingContext(e);if(!t)return;const s=this._labelingContexts.indexOf(t);this._labelingContexts.splice(s,1),t.graphics.forEach((e=>this._removeGraphic(t,e))),t.destroy(),this.setDirty()}setLabelGraphicVisibility(e,t){const s=e.graphic.uid,i=this._labels.get(s);i&&i.visible!==t&&(t&&!i.textureAtlasHandles.length?(this._addLabelTextureToAtlas(i),i.textInitialized||i.labelingContext.labelsToInitialize.set(s,i)):!t&&i.textureAtlasHandles.length&&this._removeLabelTextureFromAtlas(i),i.visible=t,this.setDirty())}setDirty(){!this._dirty&&this._labelingContexts.length>0&&(this._dirty=!0,this.notifyChange("updating"))}get updating(){return this._dirty||this._textTextureAtlas?.updating||this.deconflictor.updating||this._labelingContexts.some((e=>M(e)))}get updatingProgress(){if(!this.updating||!this._textTextureAtlas)return 1;const e=this._labelingContexts.length>0?this._labelingContexts.reduce(((e,t)=>e+(M(t)?0:1)),0)/this._labelingContexts.length:1;return(this._dirty?0:.3)+(this._textTextureAtlas.updating?0:.1)+.1*e+.5*this.deconflictor.updatingProgress}get test(){}};function z(e,t){e.geometries[0].setAttributeData(R.SIZE,[t.displayWidth,t.displayHeight]),e.geometryVertexAttributeUpdated(e.geometries[0],R.SIZE)}function H(e,t){e.geometries[0].setAttributeData(R.UVI,t),e.geometryVertexAttributeUpdated(e.geometries[0],R.UVI,!0)}function M(e){return!!e.labelClassPromise&&!!e.labelClassAbortController}function k(e){return!e||0===e.length}function B(e){return"label-3d"===e.symbol?.type?e.symbol:null}function N(e){return!0===e.labelsVisible&&!!e.labelingInfo?.some((e=>!!e.symbol))}e([h({constructOnly:!0})],U.prototype,"view",void 0),e([h({constructOnly:!0})],U.prototype,"deconflictor",void 0),e([h()],U.prototype,"_textTextureAtlas",void 0),e([h({type:Boolean,readOnly:!0})],U.prototype,"updating",null),U=e([b("esri.views.3d.layers.graphics.Labeler")],U);const W=new C(null,null,null);export{U as Labeler,N as areLabelsVisible};
5
+ import{_ as e}from"../../../../chunks/tslib.es6.js";import t from"../../../../core/Accessor.js";import{forEach as s,result as i}from"../../../../core/asyncUtils.js";import"../../../../core/has.js";import r from"../../../../core/Logger.js";import{disposeMaybe as a,abortMaybe as l}from"../../../../core/maybe.js";import{throwIfAborted as o,isAbortError as n}from"../../../../core/promiseUtils.js";import{watch as c}from"../../../../core/reactiveUtils.js";import{property as h}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/RandomLCG.js";import{subclass as b}from"../../../../core/accessorSupport/decorators/subclass.js";import{fromValues as p}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{hydrateGraphic as u}from"../../../../layers/graphics/hydratedFeatures.js";import{createLabelFunction as d}from"../../../../layers/support/labelFormatUtils.js";import{hasCalloutSupport as y}from"../../../../symbols/callouts/calloutUtils.js";import{VisibilityGroup as g,VisibilityFlag as m}from"./enums.js";import{make as f}from"./Graphics3DCalloutSymbolLayerFactory.js";import{LineCalloutSymbolLayerRenderingInfo as x,LineCalloutCreationContext as C}from"./Graphics3DLineCalloutSymbolLayer.js";import{getGraphics3DSymbol as _}from"./graphicSymbolUtils.js";import{LabelInfo as L}from"./LabelInfo.js";import{LabelParameters as v}from"./LabelParameters.js";import{horizontalPlacementFromAnchor as G,verticalPlacementFromAnchor as D,textRenderAlignmentFromHorizontalPlacement as w}from"./placementUtils.js";import{placePointOnGeometry as A}from"./pointUtils.js";import{TextRenderer as I}from"../../webgl-engine/lib/TextRenderer.js";import{TextRenderParameters as T}from"../../webgl-engine/lib/TextRenderParameters.js";import{TextTextureAtlas as S}from"../../webgl-engine/lib/TextTextureAtlas.js";import{VertexAttribute as R}from"../../webgl-engine/lib/VertexAttribute.js";import{WebGLLayer as P}from"../../webgl-engine/lib/WebGLLayer.js";import{TaskPriority as j}from"../../../support/Scheduler.js";import{Yield as E}from"../../../support/Yield.js";class O{constructor(e,t){this.labelingContext=e,this.graphics3DGraphic=t,this.hasGraphics3DResources=!1,this.visible=!1,this.textureAtlasHandles=[],this.textInitialized=!1,this.textRenderers=new Array,this.textLabelPlacements=new Array}}class V{constructor(e,t,s,i,r){this.labelClass=e,this.graphics3DSymbol=t,this.graphics3DCalloutSymbolLayer=s,this.textRenderParameters=i,this.labelFunction=r,this.calloutSymbolLayerIndex=0}}class F{constructor(e,t,s,i,r,a,l,o){this.layer=t,this.graphics3DCore=s,this.scaleVisibility=i,this.emptySymbolLabelSupported=r,this.elevationInfoOverride=a,this.disablePlacement=l,this.active=o,this.labelClassAbortController=new AbortController,this.labelClassContexts=new Array,this.graphics=new Map,this.labelsToInitialize=new Map,this.stageLayer=new P(e,{pickable:!0},s.owner.layerViewUid)}destroy(){this.stageLayer.destroy()}}let U=class extends t{constructor(e){super(e),this._hudMaterials=new Map,this._calloutMaterials=new Map,this._dirty=!1,this._labels=new Map,this._labelingContexts=new Array}setup(){this.dispose(),this.addHandles([c((()=>this.view.state?.camera),(()=>this.setDirty())),c((()=>this.view.state?.rasterPixelRatio),(()=>this._resetAllLabels())),c((()=>this.view.focusAreas.activePolygons),(()=>this._updateFocus())),this.view.resourceController.scheduler.registerTask(j.LABELER,this)]),this._textTextureAtlas=new S({view:this.view})}dispose(){this.removeAllHandles(),this._textTextureAtlas=a(this._textTextureAtlas),this._hudMaterials.clear(),this._calloutMaterials.clear(),this._labelingContexts.length=0,this._labels.clear()}destroy(){this.dispose(),W.graphic=null,W.renderingInfo=null,W.layer=null}_updateFocus(){this._labelingContexts.forEach((e=>{e.graphics.forEach((t=>{if(0===t.labelLayers.length)return;const s=A(t.graphic.geometry);if(null==s)return;const i=this.view.focusAreas.containsGeometry(s);t.labelLayers.forEach((s=>{const r=s.stageObject.geometries.some((e=>e.material.parameters.isFocused!==i));r&&(this._removeGraphic(e,t),this._addGraphic(e,t),this.setDirty())}))}))}))}_activateLabelingContext(e){e.graphics.forEach(((t,s)=>{const i=new O(e,t);this._labels.set(s,i),e.labelsToInitialize.set(s,i),t.setVisibilityFlag(g.LABEL,m.USER,!0)})),e.active=!0}_deactivateLabelingContext(e){e.graphics.forEach(((e,t)=>{e.setVisibilityFlag(g.LABEL,m.USER,!1),this.setLabelGraphicVisibility(e,!1),e.clearLabelGraphics(),this._labels.delete(t)})),e.active=!1}_addLabelTextureToAtlas(e){for(const t of e.graphics3DGraphic.labelLayers){if(!t._labelClass)continue;const s=e.textRenderers[t._labelIndex];s&&(e.textureAtlasHandles.push(this._textTextureAtlas.addText(s,(e=>H(t.stageObject,e)))),z(t.stageObject,s))}}_removeLabelTextureFromAtlas(e){e.textureAtlasHandles.forEach((e=>e.remove())),e.textureAtlasHandles.length=0}get running(){return this.view.ready&&(this._dirty||this.deconflictor.running)}runTask(e){return this._updateLabels(e),!this._dirty&&this.deconflictor.running&&this.deconflictor.runTask(e),E}_updateLabels(e){if(this._dirty){this._dirty=!1;for(const t of this._labelingContexts)if(t.active)if(M(t))this._dirty=!0;else if(k(t.labelClassContexts)){if(null===t.labelClassContexts){this._deactivateLabelingContext(t);continue}this._createLabelClassContext(t),this._dirty=!0}else for(const[s,i]of t.labelsToInitialize)if(this._ensureGraphics3DResources(i)&&(this._labels.set(s,i),this.deconflictor.setDirty(),e.madeProgress()),(i.visible&&i.textInitialized||!i.visible&&i.hasGraphics3DResources)&&(t.labelsToInitialize.delete(s),e.madeProgress()),e.done){this._dirty=!0;break}this._dirty||this.notifyChange("updating")}}async _createLabelClassContextAsync(e){const t=e.labelClassAbortController?.signal;e.layer.when&&await e.layer.when(),o(t),e.scaleVisibility?.updateScaleRangeActive();const a=e.graphics3DCore,l=a.layer,n=l.labelingInfo?.filter((e=>!!e.symbol));if(!n||0===n.length)return;let c=!1;await s(n,(async(s,l)=>{const n=s.symbol,h=_(a.getOrCreateGraphics3DSymbol(n));if(null==h)return void r.getLogger(this).error("Failed to create Graphics3DSymbol for label");await h.load(),o(t);let b=null;y(n)&&n.hasVisibleCallout()&&(b=f(n,a.symbolCreationContext),await b.load(),o(t));const p=await i(d(s,e.layer.fieldsIndex,this.view.spatialReference));if(o(t),!0===p.ok){const i=await this._createTextRenderParameters(h.symbol);o(t),e.labelClassContexts[l]=new V(s,h,b,i,p.value)}else r.getLogger(this).error(`Label expression failed to evaluate: ${p.error}`),c=!0})),o(t)}async _createLabelClassContext(e){return null==e.labelClassPromise&&(e.labelClassPromise=this._createLabelClassContextAsync(e).catch((t=>{if(n(t))throw t;e.labelClassContexts.length=0})).then((()=>{e.labelClassAbortController=null,this.notifyChange("updating")})).catch((()=>{})),this.notifyChange("updating")),e.labelClassPromise}async _createTextRenderParameters(e){const t=e.symbolLayers.at(0);return"text"!==t?.type?null:T.fromSymbol(t,this.view.state.rasterPixelRatio)}_destroyLabelClassContext(e){for(const s of e.labelClassContexts)--s.graphics3DSymbol.referenced;const t=e.labelClassAbortController;e.labelClassAbortController=new AbortController,l(t),e.labelClassContexts.length=0,e.labelClassPromise=null,this.notifyChange("updating")}_createTextSymbolGraphic(e,t,s,i,r,a){const l=new v(s,G(s.anchor),D(s.anchor),e.text,p(e.displayWidth,e.displayHeight));return W.graphic=t,W.layer=i,W.renderingInfo=null,r.createLabel(W,l,this._hudMaterials,this._textTextureAtlas,(()=>a.placement?.elevationOffset??null))}_createLineCalloutGraphic(e,t,s,i,r){W.graphic=e,W.layer=r;const a=i.screenOffset[0];return W.renderingInfo=new x(null,t,i.translation,i.centerOffset,a,i.centerOffsetUnits,i.elevationOffset),s.createGraphics3DGraphic(W,this._calloutMaterials)}_ensureGraphics3DResources(e){if(e.hasGraphics3DResources)return!1;const t=e.graphics3DGraphic;if(t.destroyed)return!1;this._ensureTextTextureResources(e);const s=e.labelingContext,i=s.labelClassContexts;if(k(i)||!s.emptySymbolLabelSupported&&0===t.layers.length)return!1;let r=!1;const a=t.graphic,l=s.layer,o=N(s.layer);for(let n=0;n<i.length;n++){const c=e.textRenderers[n],h=e.textLabelPlacements[n];if(null==c||null==h)continue;const b=i[n],p=b.graphics3DSymbol,u=B(p),d=p.symbolLayers[0];if(!d)continue;d.setElevationInfoOverride(s.elevationInfoOverride);const y=new L(t,u,b.labelClass),f=this._createTextSymbolGraphic(c,a,h,l,d,y);if(null==f)return!1;f._labelClass=b.labelClass,f._labelIndex=n,t.addLabelGraphic(f,s.stageLayer),this.deconflictor.setPriority(t,b.textRenderParameters?.definition.size??0),t.setVisibilityFlag(g.LABEL,m.USER,o),t.setVisibilityFlag(g.LABEL,m.SCALE_RANGE,!0),t.setVisibilityFlag(g.LABEL,m.DECONFLICTION,!1),r=!0;const x=b.graphics3DCalloutSymbolLayer;if(x&&h.hasLabelVerticalOffset){x.setElevationInfoOverride(s.elevationInfoOverride);const e=this._createLineCalloutGraphic(a,u,x,h,l);null!=e&&(b.calloutSymbolLayerIndex=t.labelLayers.length,t.addLabelGraphic(e,s.stageLayer))}break}return r&&s.scaleVisibility?.updateGraphicLabelScaleVisibility(t),e.hasGraphics3DResources=!0,!0}_destroyGraphics3DResources(e){const t=e.labelingContext.labelClassContexts;for(const s of e.graphics3DGraphic.labelLayers){if(null==s._labelClass)continue;const e=t[s._labelIndex].graphics3DSymbol.symbolLayers[0];e?.onRemoveGraphic(s)}e.graphics3DGraphic.clearLabelGraphics(),e.hasGraphics3DResources=!1}_ensureTextTextureResources(e){if(e.textInitialized)return;const t=e.labelingContext,s=t.labelClassContexts;if(k(s))return;const i=e.graphics3DGraphic.graphic;for(let a=0;a<s.length;a++){const l=s[a];if(e.textRenderers[a]=null,e.textLabelPlacements[a]=null,null==l?.textRenderParameters)continue;const o=l.labelFunction;let n;if("arcade"===o.type)try{const e=o.needsHydrationToEvaluate()?u(i,t.layer):i;n=o.evaluate(e)}catch(r){n=null}else n=o.evaluate(i);if(null==n||""===n||/^\s+$/.test(n))continue;const c=l.graphics3DSymbol;if(!c.symbolLayers[0])continue;const h=e.graphics3DGraphic,b="label-3d"===c.symbol?.type?c.symbol:null,p=l.labelClass,d=t.disablePlacement,y=new L(h,b,p,d).placement;if(null==y)continue;const g=G(y.anchor),m=w(g);e.textRenderers[a]=new I(n,m,l.textRenderParameters,S.maxSize),e.textLabelPlacements[a]=y}e.textInitialized=!0}_destroyTextTextureResources(e){e.textInitialized=!1,e.textRenderers.length=0,e.textLabelPlacements.length=0}_addGraphic(e,t){const s=t.graphic.uid;if(e.graphics.set(s,t),e.active){const i=new O(e,t);this._labels.set(s,i),e.labelsToInitialize.set(s,i)}this.setDirty(),this.deconflictor.setDirty()}_updateGraphicGeometry(e,t){const s=t.graphic.uid,i=this._labels.get(s);if(!i)return!0;for(const r of i.graphics3DGraphic.labelLayers){if(null==r._labelClass)continue;if(!e.labelClassContexts[r._labelIndex].graphics3DSymbol.symbolLayers[0].updateGeometry(r,t.graphic.geometry))return!1}return this.setDirty(),this.deconflictor.setDirty(),!0}_removeGraphic(e,t){const s=t.graphic.uid,i=this._labels.get(s);e.graphics.delete(s),i&&(this._destroyGraphic(i,s),e.labelsToInitialize.delete(s),this.setDirty(),this.deconflictor.setDirty())}_destroyGraphic(e,t){this._labels.delete(t),e.textureAtlasHandles.length&&this._removeLabelTextureFromAtlas(e),this._destroyTextTextureResources(e),e.hasGraphics3DResources&&this._destroyGraphics3DResources(e)}async _labelingInfoChange(e,t){if(!t)return this._visibilityInfoChange(e),this._resetLabels(e),this._createLabelClassContext(e);for(const s of t){const t=e.graphics.get(s);t&&(this._removeGraphic(e,t),this._addGraphic(e,t))}}_globalPropertyChanged(e,t){for(const s of t.labelClassContexts){const i=new Map;t.graphics.forEach((e=>i.set(e.graphic.uid,e)));const r=e=>e.labelLayers[0];if(s.graphics3DSymbol.symbolLayers[0].globalPropertyChanged(e,i,r),s.graphics3DCalloutSymbolLayer){const t=e=>e.labelLayers[s.calloutSymbolLayerIndex];s.graphics3DCalloutSymbolLayer.globalPropertyChanged(e,i,t)}}}_visibilityInfoChange(e){const t=N(e.layer);t&&!e.active&&this._activateLabelingContext(e),!t&&e.active&&this._deactivateLabelingContext(e),this.setDirty()}_resetAllLabels(){for(const e of this._labelingContexts)this._resetLabels(e)}_resetLabels(e){e.graphics.forEach(((t,s)=>{const i=this._labels.get(s);i&&(this._destroyGraphic(i,s),i.visible=!1,e.labelsToInitialize.set(s,i))})),this._destroyLabelClassContext(e),this.setDirty(),this.deconflictor.setDirty()}_findLabelingContext(e){for(const t of this._labelingContexts)if(t.graphics3DCore===e)return t;return null}addGraphicsOwner(e,t,s){const i=s?.emptySymbolLabelSupported||!1,r=s?.elevationInfoOverride||null,a=s?.disablePlacement||null;if(this._findLabelingContext(e))return;const l=e.layer,o=new F(this.view.stage,l,e,t,i,r,a,N(l));return this._labelingContexts.push(o),this.setDirty(),{addGraphic:e=>this._addGraphic(o,e),removeGraphic:e=>this._removeGraphic(o,e),updateGraphicGeometry:e=>this._updateGraphicGeometry(o,e),layerLabelsEnabled:()=>N(o.layer),labelingInfoChange:e=>this._labelingInfoChange(o,e),elevationInfoChange:()=>this._globalPropertyChanged("elevationInfo",o),slicePlaneEnabledChange:()=>this._globalPropertyChanged("slicePlaneEnabled",o),visibilityInfoChange:()=>this._visibilityInfoChange(o),reset:()=>this._resetLabels(o),remove:()=>this._removeGraphicsOwner(e),setDirty:()=>this.setDirty()}}_removeGraphicsOwner(e){const t=this._findLabelingContext(e);if(!t)return;const s=this._labelingContexts.indexOf(t);this._labelingContexts.splice(s,1),t.graphics.forEach((e=>this._removeGraphic(t,e))),t.destroy(),this.setDirty()}setLabelGraphicVisibility(e,t){const s=e.graphic.uid,i=this._labels.get(s);i&&i.visible!==t&&(t&&!i.textureAtlasHandles.length?(this._addLabelTextureToAtlas(i),i.textInitialized||i.labelingContext.labelsToInitialize.set(s,i)):!t&&i.textureAtlasHandles.length&&this._removeLabelTextureFromAtlas(i),i.visible=t,this.setDirty())}setDirty(){!this._dirty&&this._labelingContexts.length>0&&(this._dirty=!0,this.notifyChange("updating"))}get updating(){return this._dirty||this._textTextureAtlas?.updating||this.deconflictor.updating||this._labelingContexts.some((e=>M(e)))}get updatingProgress(){if(!this.updating||!this._textTextureAtlas)return 1;const e=this._labelingContexts.length>0?this._labelingContexts.reduce(((e,t)=>e+(M(t)?0:1)),0)/this._labelingContexts.length:1;return(this._dirty?0:.3)+(this._textTextureAtlas.updating?0:.1)+.1*e+.5*this.deconflictor.updatingProgress}get test(){}};function z(e,t){e.geometries[0].setAttributeData(R.SIZE,[t.displayWidth,t.displayHeight]),e.geometryVertexAttributeUpdated(e.geometries[0],R.SIZE)}function H(e,t){e.geometries[0].setAttributeData(R.UVI,t),e.geometryVertexAttributeUpdated(e.geometries[0],R.UVI,!0)}function M(e){return!!e.labelClassPromise&&!!e.labelClassAbortController}function k(e){return!e||0===e.length}function B(e){return"label-3d"===e.symbol?.type?e.symbol:null}function N(e){return!0===e.labelsVisible&&!!e.labelingInfo?.some((e=>!!e.symbol))}e([h({constructOnly:!0})],U.prototype,"view",void 0),e([h({constructOnly:!0})],U.prototype,"deconflictor",void 0),e([h()],U.prototype,"_textTextureAtlas",void 0),e([h({type:Boolean,readOnly:!0})],U.prototype,"updating",null),U=e([b("esri.views.3d.layers.graphics.Labeler")],U);const W=new C(null,null,null);export{U as Labeler,N as areLabelsVisible};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{colorGamma as e}from"../../../../colorUtils.js";import{adjustStaticAGOUrl as r}from"../../../../core/devEnvironmentUtils.js";import{hasScaling as t}from"../../../../core/mathUtils.js";import{normalFromMat4 as o,fromMat4 as s}from"../../../../core/libs/gl-matrix-2/math/mat3.js";import{create as i}from"../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{invert as n}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as l}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{ONES as a}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{t as u,d as c,E as m,l as f,n as d,m as p}from"../../../../chunks/vec32.js";import{create as g}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{empty as x,expandWithVec3 as b}from"../../../../geometry/support/aaBoundingBox.js";import{newFloatArray as T}from"../../../../geometry/support/FloatArray.js";import{BufferViewVec4f as h,BufferViewVec4u8 as y,BufferViewVec4u16 as w,BufferViewVec3f as v,BufferViewVec3u8 as R,BufferViewVec3u16 as j}from"../../../../geometry/support/buffer/BufferView.js";import{t as B,b as S,n as M,f as A}from"../../../../chunks/vec3.js";import{t as F,b as E}from"../../../../chunks/vec4.js";import{a as C}from"../../../../chunks/vec2.js";import{DefaultLoadingContext as I}from"../../glTF/DefaultLoadingContext.js";import{convertPrimitiveToTriangles as L}from"../../glTF/internal/indexUtils.js";import{isEncodedMeshTexture as O}from"../../glTF/internal/resourceUtils.js";import{getTransformMatrix as k}from"../../glTF/internal/TextureTransformUtils.js";import{ProcessedObjectResource as P}from"./ProcessedObjectResource.js";import{load as U,processLoadResult as N}from"./wosrLoader.js";import{NormalType as V}from"../../webgl-engine/core/shaderLibrary/attributes/NormalAttribute.glsl.js";import{Attribute as D}from"../../webgl-engine/lib/Attribute.js";import{AlphaDiscardMode as _,DepthTestFunction as q,CullFaceOptions as G}from"../../webgl-engine/lib/basicInterfaces.js";import{Geometry as H}from"../../webgl-engine/lib/Geometry.js";import{Texture as W}from"../../webgl-engine/lib/Texture.js";import{VertexAttribute as Q}from"../../webgl-engine/lib/VertexAttribute.js";import{DefaultMaterial as $}from"../../webgl-engine/materials/DefaultMaterial.js";import{esriSymbologyMRRFactors as z,advancedMRRFactors as K,useSchematicPBR as J,schematicMRRFactors as X}from"../../webgl-engine/materials/pbrUtils.js";async function Y(e,t){const o=Z(r(e));if("wosr"===o.fileType){const e=await(t.cache?t.cache.loadWOSR(o.url,t):U(o.url,t)),{engineResources:r,referenceBoundingBox:s}=N(e,t);return{lods:r,referenceBoundingBox:s,isEsriSymbolResource:!1,isWosr:!0}}let s;if(t.cache)s=await t.cache.loadGLTF(o.url,t,!!t.usePBR);else{const{loadGLTF:e}=await import("../../glTF/loader.js");s=await e(new I(t.streamDataRequester),o.url,t,t.usePBR)}const i=s.model.meta?.ESRI_proxyEllipsoid,n=s.meta.isEsriSymbolResource&&null!=i&&"EsriRealisticTreesStyle"===s.meta.ESRI_webstyle;n&&!s.customMeta.esriTreeRendering&&(s.customMeta.esriTreeRendering=!0,ie(s,i));const l=!!t.usePBR,a=s.meta.isEsriSymbolResource?{usePBR:l,isSchematic:!1,treeRendering:n,mrrFactors:z}:{usePBR:l,isSchematic:!1,treeRendering:!1,mrrFactors:K},u={...t.materialParameters,treeRendering:n},{engineResources:c,referenceBoundingBox:m}=ee(s,a,u,t,o.specifiedLodIndex,n);return{lods:c,referenceBoundingBox:m,isEsriSymbolResource:s.meta.isEsriSymbolResource,isWosr:!1}}function Z(e){const r=e.match(/(.*\.(gltf|glb))(\?lod=([0-9]+))?$/);if(r)return{fileType:"gltf",url:r[1],specifiedLodIndex:null!=r[4]?Number(r[4]):null};return e.match(/(.*\.(json|json\.gz))$/)?{fileType:"wosr",url:e,specifiedLodIndex:null}:{fileType:"unknown",url:e,specifiedLodIndex:null}}function ee(e,r,t,o,s,i){const n=e.model,l=new Array,a=new Map,u=new Map,c=n.lods.length,m=x();return n.lods.forEach(((e,f)=>{const d=!0===o.skipHighLods&&(c>1&&0===f||c>3&&1===f)||!1===o.skipHighLods&&null!=s&&f!==s;if(d&&0!==f)return;const p=new P(e.name,e.lodThreshold,[0,0,0]);e.parts.forEach((e=>{const s=d?new $({},o):re(n,e,p,r,t,a,u,o,i),{geometry:l,vertexCount:c}=te(e,s??new $({},o)),g=l.boundingInfo;null!=g&&0===f&&(b(m,g.bbMin),b(m,g.bbMax)),null!=s&&(p.stageResources.geometries.push(l),p.numberOfVertices+=c)})),d||l.push(p)})),{engineResources:l,referenceBoundingBox:m}}function re(r,t,o,s,i,n,l,u,c){const m=r.materials.get(t.material);if(null==m)return null;const{normal:f,color:d,texCoord0:p,tangent:g}=t.attributes,x=t.material+(f?"_normal":"")+(d?"_color":"")+(p?"_texCoord0":"")+(g?"_tangent":""),b=null!=t.attributes.texCoord0,T=null!=t.attributes.normal,h=se(m.alphaMode);if(!n.has(x)){if(b){const e=(e,t=!1,o=!1)=>{if(null!=e&&!l.has(e)){const s=r.textures.get(e);if(s){const r=s.data,i=t&&!O(r);l.set(e,new W(O(r)?r.data:r,{...s.parameters,preMultiplyAlpha:!O(r)&&o,encoding:O(r)?r.encoding:void 0,compressionHandle:i?u.compressionHandle:void 0,compressionCallback:i?u.compressionCallback:void 0}))}}},t=h!==_.Opaque&&!c;e(m.colorTexture,t,h!==_.Opaque),e(m.normalTexture),e(m.occlusionTexture,!0),e(m.emissiveTexture),e(m.metallicRoughnessTexture,!0)}const o=1/e,f=m.color[0]**o,d=m.color[1]**o,p=m.color[2]**o,g=m.emissiveFactor[0]**o,y=m.emissiveFactor[1]**o,w=m.emissiveFactor[2]**o,v=null!=m.colorTexture&&b?l.get(m.colorTexture):null,R=J(m),j=null!=m.normalTextureTransform?.scale?m.normalTextureTransform?.scale:a;n.set(x,new $({...s,customDepthTest:q.Lequal,textureAlphaMode:h,textureAlphaCutoff:m.alphaCutoff,diffuse:[f,d,p],ambient:[f,d,p],opacity:"OPAQUE"===m.alphaMode?1:m.opacity,doubleSided:m.doubleSided,doubleSidedType:"winding-order",cullFace:m.doubleSided?G.None:G.Back,hasVertexColors:!!t.attributes.color,hasVertexTangents:!!t.attributes.tangent,normalType:T?V.Attribute:V.ScreenDerivative,castShadows:!0,receiveShadows:m.receiveShadows,receiveAmbientOcclusion:m.receiveAmbientOcclustion,textureId:null!=v?v.id:void 0,colorMixMode:m.colorMixMode,normalTextureId:null!=m.normalTexture&&b?l.get(m.normalTexture).id:void 0,textureAlphaPremultiplied:null!=v&&!!v.parameters.preMultiplyAlpha,occlusionTextureId:null!=m.occlusionTexture&&b?l.get(m.occlusionTexture).id:void 0,emissiveTextureId:null!=m.emissiveTexture&&b?l.get(m.emissiveTexture).id:void 0,metallicRoughnessTextureId:null!=m.metallicRoughnessTexture&&b?l.get(m.metallicRoughnessTexture).id:void 0,emissiveBaseColor:[g,y,w],mrrFactors:R?X:[m.metallicFactor,m.roughnessFactor,s.mrrFactors[2]],isSchematic:R,colorTextureTransformMatrix:k(m.colorTextureTransform),normalTextureTransformMatrix:k(m.normalTextureTransform),scale:[j[0],j[1]],occlusionTextureTransformMatrix:k(m.occlusionTextureTransform),emissiveTextureTransformMatrix:k(m.emissiveTextureTransform),metallicRoughnessTextureTransformMatrix:k(m.metallicRoughnessTextureTransform),...i},u))}const y=n.get(x);if(o.stageResources.materials.push(y),b){const e=e=>{null!=e&&o.stageResources.textures.push(l.get(e))};e(m.colorTexture),e(m.normalTexture),e(m.occlusionTexture),e(m.emissiveTexture),e(m.metallicRoughnessTexture)}return y}function te(e,r){const i=e.attributes.position.count,n=L(e.indices||i,e.primitiveType),l=T(3*i),{typedBuffer:a,typedBufferStride:u}=e.attributes.position;B(l,a,e.transform,3,u);const c=[[Q.POSITION,new D(l,n,3,!0)]];if(null!=e.attributes.normal){const r=T(3*i),{typedBuffer:s,typedBufferStride:l}=e.attributes.normal;o(oe,e.transform),S(r,s,oe,3,l),t(oe)&&M(r,r),c.push([Q.NORMAL,new D(r,n,3,!0)])}if(null!=e.attributes.tangent){const r=T(4*i),{typedBuffer:o,typedBufferStride:l}=e.attributes.tangent;s(oe,e.transform),F(r,o,oe,4,l),t(oe)&&M(r,r,4),c.push([Q.TANGENT,new D(r,n,4,!0)])}if(null!=e.attributes.texCoord0){const r=T(2*i),{typedBuffer:t,typedBufferStride:o}=e.attributes.texCoord0;C(r,t,2,o),c.push([Q.UV0,new D(r,n,2,!0)])}const m=e.attributes.color;if(null!=m){const r=new Uint8Array(4*i);4===m.elementCount?m instanceof h?E(r,m,1,255):(m instanceof y||m instanceof w)&&E(r,m,1/255,255):(r.fill(255),m instanceof v?A(r,m.typedBuffer,1,255,4,m.typedBufferStride):(e.attributes.color instanceof R||e.attributes.color instanceof j)&&A(r,m.typedBuffer,1/255,255,4,e.attributes.color.typedBufferStride)),c.push([Q.COLOR,new D(r,n,4,!0)])}return{geometry:new H(r,c),vertexCount:i}}const oe=i();function se(e){switch(e){case"BLEND":return _.Blend;case"MASK":return _.Mask;case"OPAQUE":case null:case void 0:return _.Opaque}}function ie(r,t){for(let o=0;o<r.model.lods.length;++o){const s=r.model.lods[o];for(const i of s.parts){const s=i.attributes.normal;if(null==s)return;const a=i.attributes.position,x=a.count,b=g(),T=g(),y=g(),w=new Float32Array(4*x),R=new Float32Array(3*x),j=n(l(),i.transform);let B=0,S=0;for(let n=0;n<x;n++){a.getVec(n,T),s.getVec(n,b),u(T,T,i.transform),c(y,T,t.center),m(y,y,t.radius);const l=y[2],g=f(y),x=Math.min(.45+.55*g*g,1)**e;m(y,y,t.radius),null!==j&&u(y,y,j),d(y,y),o+1!==r.model.lods.length&&r.model.lods.length>1&&p(y,y,b,l>-1?.2:Math.min(-4*l-3.8,1)),R[B]=y[0],R[B+1]=y[1],R[B+2]=y[2],B+=3,w[S]=x,w[S+1]=x,w[S+2]=x,w[S+3]=1,S+=4}i.attributes.normal=new v(R),i.attributes.color=new h(w)}}}export{Y as fetch,Z as parseUrl};
5
+ import{colorGamma as e}from"../../../../colorUtils.js";import{adjustStaticAGOUrl as r}from"../../../../core/devEnvironmentUtils.js";import{hasScaling as t}from"../../../../core/mathUtils.js";import{normalFromMat4 as o,fromMat4 as s}from"../../../../core/libs/gl-matrix-2/math/mat3.js";import{create as i}from"../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{invert as n}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as l}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{ONES as a}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{t as u,d as c,E as m,l as f,n as d,m as p}from"../../../../chunks/vec32.js";import{create as g}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{empty as x,expandWithVec3 as b}from"../../../../geometry/support/aaBoundingBox.js";import{newFloatArray as T}from"../../../../geometry/support/FloatArray.js";import{BufferViewVec4f as h,BufferViewVec4u8 as y,BufferViewVec4u16 as w,BufferViewVec3f as v,BufferViewVec3u8 as R,BufferViewVec3u16 as j}from"../../../../geometry/support/buffer/BufferView.js";import{t as B,b as S,n as M,f as A}from"../../../../chunks/vec3.js";import{t as F,b as E}from"../../../../chunks/vec4.js";import{a as C}from"../../../../chunks/vec2.js";import{DefaultLoadingContext as I}from"../../glTF/DefaultLoadingContext.js";import{convertPrimitiveToTriangles as L}from"../../glTF/internal/indexUtils.js";import{isEncodedMeshTexture as O}from"../../glTF/internal/resourceUtils.js";import{getTransformMatrix as k}from"../../glTF/internal/TextureTransformUtils.js";import{ProcessedObjectResource as P}from"./ProcessedObjectResource.js";import{load as U,processLoadResult as N}from"./wosrLoader.js";import{NormalType as V}from"../../webgl-engine/core/shaderLibrary/attributes/NormalAttribute.glsl.js";import{Attribute as D}from"../../webgl-engine/lib/Attribute.js";import{AlphaDiscardMode as _,DepthTestFunction as q,CullFaceOptions as G}from"../../webgl-engine/lib/basicInterfaces.js";import{Geometry as H}from"../../webgl-engine/lib/Geometry.js";import{Texture as W}from"../../webgl-engine/lib/Texture.js";import{VertexAttribute as Q}from"../../webgl-engine/lib/VertexAttribute.js";import{DefaultMaterial as $}from"../../webgl-engine/materials/DefaultMaterial.js";import{esriSymbologyMRRFactors as z,advancedMRRFactors as K,useSchematicPBR as J,schematicMRRFactors as X}from"../../webgl-engine/materials/pbrUtils.js";async function Y(e,t){const o=Z(r(e));if("wosr"===o.fileType){const e=await(t.cache?t.cache.loadWOSR(o.url,t):U(o.url,t)),{engineResources:r,referenceBoundingBox:s}=N(e,t);return{lods:r,referenceBoundingBox:s,isEsriSymbolResource:!1,isWosr:!0}}let s;if(t.cache)s=await t.cache.loadGLTF(o.url,t,!!t.usePBR);else{const{loadGLTF:e}=await import("../../glTF/loader.js");s=await e(new I(t.streamDataRequester),o.url,t,t.usePBR)}const i=s.model.meta?.ESRI_proxyEllipsoid,n=s.meta.isEsriSymbolResource&&null!=i&&"EsriRealisticTreesStyle"===s.meta.ESRI_webstyle;n&&!s.customMeta.esriTreeRendering&&(s.customMeta.esriTreeRendering=!0,ie(s,i));const l=!!t.usePBR,a=s.meta.isEsriSymbolResource?{usePBR:l,isSchematic:!1,treeRendering:n,mrrFactors:z}:{usePBR:l,isSchematic:!1,treeRendering:!1,mrrFactors:K},u={...t.materialParameters,treeRendering:n},{engineResources:c,referenceBoundingBox:m}=ee(s,a,u,t,o.specifiedLodIndex,n);return{lods:c,referenceBoundingBox:m,isEsriSymbolResource:s.meta.isEsriSymbolResource,isWosr:!1}}function Z(e){const r=e.match(/(.*\.(gltf|glb))(\?lod=([0-9]+))?$/);if(r)return{fileType:"gltf",url:r[1],specifiedLodIndex:null!=r[4]?Number(r[4]):null};return e.match(/(.*\.(json|json\.gz))$/)?{fileType:"wosr",url:e,specifiedLodIndex:null}:{fileType:"unknown",url:e,specifiedLodIndex:null}}function ee(e,r,t,o,s,i){const n=e.model,l=new Array,a=new Map,u=new Map,c=n.lods.length,m=x();return n.lods.forEach(((e,f)=>{const d=!0===o.skipHighLods&&(c>1&&0===f||c>3&&1===f)||!1===o.skipHighLods&&null!=s&&f!==s;if(d&&0!==f)return;const p=new P(e.name,e.lodThreshold,[0,0,0]);e.parts.forEach((e=>{const s=d?new $({},o):re(n,e,p,r,t,a,u,o,i),{geometry:l,vertexCount:c}=te(e,s??new $({},o)),g=l.boundingInfo;null!=g&&0===f&&(b(m,g.bbMin),b(m,g.bbMax)),null!=s&&(p.stageResources.geometries.push(l),p.numberOfVertices+=c)})),d||l.push(p)})),{engineResources:l,referenceBoundingBox:m}}function re(r,t,o,s,i,n,l,u,c){const m=r.materials.get(t.material);if(null==m)return null;const{normal:f,color:d,texCoord0:p,tangent:g}=t.attributes,x=t.material+(f?"_normal":"")+(d?"_color":"")+(p?"_texCoord0":"")+(g?"_tangent":""),b=null!=t.attributes.texCoord0,T=null!=t.attributes.normal,h=se(m.alphaMode);if(!n.has(x)){if(b){const e=(e,t=!1,o=!1)=>{if(null!=e&&!l.has(e)){const s=r.textures.get(e);if(s){const r=s.data,i=t&&!O(r);l.set(e,new W(O(r)?r.data:r,{...s.parameters,preMultiplyAlpha:!O(r)&&o,encoding:O(r)?r.encoding:void 0,compressionHandle:i?u.compressionHandle:void 0,compressionCallback:i?u.compressionCallback:void 0}))}}},t=h!==_.Opaque&&!c;e(m.colorTexture,t,h!==_.Opaque),e(m.normalTexture),e(m.occlusionTexture,!0),e(m.emissiveTexture),e(m.metallicRoughnessTexture,!0)}const o=1/e,f=m.color[0]**o,d=m.color[1]**o,p=m.color[2]**o,g=m.emissiveFactor[0]**o,y=m.emissiveFactor[1]**o,w=m.emissiveFactor[2]**o,v=null!=m.colorTexture&&b?l.get(m.colorTexture):null,R=J(m),j=null!=m.normalTextureTransform?.scale?m.normalTextureTransform?.scale:a;n.set(x,new $({...s,customDepthTest:q.Lequal,textureAlphaMode:h,textureAlphaCutoff:m.alphaCutoff,diffuse:[f,d,p],ambient:[f,d,p],opacity:"OPAQUE"===m.alphaMode?1:m.opacity,doubleSided:m.doubleSided,doubleSidedType:"winding-order",cullFace:m.doubleSided?G.None:G.Back,hasVertexColors:!!t.attributes.color,hasVertexTangents:!!t.attributes.tangent,normalType:T?V.Attribute:V.ScreenDerivative,castShadows:!0,receiveShadows:m.receiveShadows,receiveAmbientOcclusion:m.receiveAmbientOcclusion,textureId:null!=v?v.id:void 0,colorMixMode:m.colorMixMode,normalTextureId:null!=m.normalTexture&&b?l.get(m.normalTexture).id:void 0,textureAlphaPremultiplied:null!=v&&!!v.parameters.preMultiplyAlpha,occlusionTextureId:null!=m.occlusionTexture&&b?l.get(m.occlusionTexture).id:void 0,emissiveTextureId:null!=m.emissiveTexture&&b?l.get(m.emissiveTexture).id:void 0,metallicRoughnessTextureId:null!=m.metallicRoughnessTexture&&b?l.get(m.metallicRoughnessTexture).id:void 0,emissiveBaseColor:[g,y,w],mrrFactors:R?X:[m.metallicFactor,m.roughnessFactor,s.mrrFactors[2]],isSchematic:R,colorTextureTransformMatrix:k(m.colorTextureTransform),normalTextureTransformMatrix:k(m.normalTextureTransform),scale:[j[0],j[1]],occlusionTextureTransformMatrix:k(m.occlusionTextureTransform),emissiveTextureTransformMatrix:k(m.emissiveTextureTransform),metallicRoughnessTextureTransformMatrix:k(m.metallicRoughnessTextureTransform),...i},u))}const y=n.get(x);if(o.stageResources.materials.push(y),b){const e=e=>{null!=e&&o.stageResources.textures.push(l.get(e))};e(m.colorTexture),e(m.normalTexture),e(m.occlusionTexture),e(m.emissiveTexture),e(m.metallicRoughnessTexture)}return y}function te(e,r){const i=e.attributes.position.count,n=L(e.indices||i,e.primitiveType),l=T(3*i),{typedBuffer:a,typedBufferStride:u}=e.attributes.position;B(l,a,e.transform,3,u);const c=[[Q.POSITION,new D(l,n,3,!0)]];if(null!=e.attributes.normal){const r=T(3*i),{typedBuffer:s,typedBufferStride:l}=e.attributes.normal;o(oe,e.transform),S(r,s,oe,3,l),t(oe)&&M(r,r),c.push([Q.NORMAL,new D(r,n,3,!0)])}if(null!=e.attributes.tangent){const r=T(4*i),{typedBuffer:o,typedBufferStride:l}=e.attributes.tangent;s(oe,e.transform),F(r,o,oe,4,l),t(oe)&&M(r,r,4),c.push([Q.TANGENT,new D(r,n,4,!0)])}if(null!=e.attributes.texCoord0){const r=T(2*i),{typedBuffer:t,typedBufferStride:o}=e.attributes.texCoord0;C(r,t,2,o),c.push([Q.UV0,new D(r,n,2,!0)])}const m=e.attributes.color;if(null!=m){const r=new Uint8Array(4*i);4===m.elementCount?m instanceof h?E(r,m,1,255):(m instanceof y||m instanceof w)&&E(r,m,1/255,255):(r.fill(255),m instanceof v?A(r,m.typedBuffer,1,255,4,m.typedBufferStride):(e.attributes.color instanceof R||e.attributes.color instanceof j)&&A(r,m.typedBuffer,1/255,255,4,e.attributes.color.typedBufferStride)),c.push([Q.COLOR,new D(r,n,4,!0)])}return{geometry:new H(r,c),vertexCount:i}}const oe=i();function se(e){switch(e){case"BLEND":return _.Blend;case"MASK":return _.Mask;case"OPAQUE":case null:case void 0:return _.Opaque}}function ie(r,t){for(let o=0;o<r.model.lods.length;++o){const s=r.model.lods[o];for(const i of s.parts){const s=i.attributes.normal;if(null==s)return;const a=i.attributes.position,x=a.count,b=g(),T=g(),y=g(),w=new Float32Array(4*x),R=new Float32Array(3*x),j=n(l(),i.transform);let B=0,S=0;for(let n=0;n<x;n++){a.getVec(n,T),s.getVec(n,b),u(T,T,i.transform),c(y,T,t.center),m(y,y,t.radius);const l=y[2],g=f(y),x=Math.min(.45+.55*g*g,1)**e;m(y,y,t.radius),null!==j&&u(y,y,j),d(y,y),o+1!==r.model.lods.length&&r.model.lods.length>1&&p(y,y,b,l>-1?.2:Math.min(-4*l-3.8,1)),R[B]=y[0],R[B+1]=y[1],R[B+2]=y[2],B+=3,w[S]=x,w[S+1]=x,w[S+2]=x,w[S+3]=1,S+=4}i.attributes.normal=new v(R),i.attributes.color=new h(w)}}}export{Y as fetch,Z as parseUrl};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../../../../chunks/tslib.es6.js";import{nullUid as t}from"../../../../../../core/uid.js";import{property as r}from"../../../../../../core/accessorSupport/decorators/property.js";import"../../../../../../core/has.js";import"../../../../../../core/Logger.js";import"../../../../../../core/RandomLCG.js";import{subclass as i}from"../../../../../../core/accessorSupport/decorators/subclass.js";import{glLayout as s}from"../../../../support/buffer/glUtil.js";import{ShaderOutput as n}from"../../../../webgl-engine/core/shaderLibrary/ShaderOutput.js";import{SyncRenderPlugin as o}from"../../../../webgl-engine/effects/RenderPlugin.js";import{GLMaterials as a}from"../../../../webgl-engine/lib/GLMaterials.js";import{IntersectorType as l}from"../../../../webgl-engine/lib/IntersectorInterfaces.js";import{BoundingVolume as u}from"../../../../webgl-engine/lib/Object3D.js";import{RenderSlot as c}from"../../../../webgl-engine/lib/RenderSlot.js";import{DrawParameters as m}from"../../../../webgl-engine/materials/DrawParameters.js";import{HUDMaterial as d}from"../../../../webgl-engine/materials/HUDMaterial.js";let h=class extends o{constructor(e){super(e),this._glMaterials=null,this._produces=new Map,this._renderGeometries=new Map,this._vaoCache=null,this._drawParameters=new m,this._bufferWriter=null,this.slicePlaneEnabled=!1,this.isGround=!1,this.type=e.material instanceof d?l.HUD:l.OBJECT,this.layerViewUid=e.layerViewUid}get produces(){return this._produces}get numFeatures(){const e=6;let t=0;return this._renderGeometries.forEach((r=>t+=r.numElements/e)),t}get usedMemory(){let e=0;return this._renderGeometries.forEach((t=>{e+=t.vao.usedMemory})),e}intersect(e,r,i,s,n,o){const{material:a,_bufferWriter:l,layerViewUid:c}=this,m=this._renderGeometries;if(0!==m.size&&null!=l.intersect)for(const[d,h]of m){const{buffer:r,localOrigin:n,items:o}=h;l.intersect(r.data,a.parameters,n,e,i,s,((r,i,s,n,l,m)=>{const d=o.objectIds[s];o.visibilities[s]&&e.handleObjectIntersection({object:{id:t,graphicUid:d,layerViewUid:c,boundingVolumeWorldSpace:new u,geometries:[{material:a}]},geometryId:0,primIndex:s},r,i,n,null,l,m)}))}}initialize(){this._bufferWriter=this.material.createBufferWriter(),this.material.produces.forEach(((e,t)=>{this._produces.set(t,(t=>t!==n.Highlight&&t!==n.ShadowHighlight&&e(t)))}))}destroy(){this._glMaterials.dispose();const e=this._renderGeometries.keys();for(const t of e)this.removeRenderGeometryBuffer(t)}acquireTechniques(e){const t=this.material;if(!t.shouldRender(e))return null;const{output:r,bind:i}=e,s=t.produces.get(i.slot);if(!s?.(r))return null;if(r===n.Highlight||r===n.ShadowHighlight)return null;const o=this._glMaterials.load(e.rctx,i.slot,r);return o?.beginSlot(i)}render(e,t){const r=this._renderGeometries;if(0===r.size)return;const{bind:i}=e,s=i.slot===c.OCCLUDER_MATERIAL||i.slot===c.TRANSPARENT_OCCLUDER_MATERIAL?i.slot:null,n=e.rctx;n.runAppleAmdDriverHelper(),n.bindTechnique(t,i,this.material.parameters);const o=t.program;for(const[a,l]of r){const{vao:e,localOrigin:r,drawCalls:a}=l;this._drawParameters.origin=r,o.bindDraw(i,this.material.parameters,this._drawParameters),t.ensureAttributeLocations(e),n.bindVAO(e),n.setPipelineState(t.getPipeline(!1,s));for(const i of a)n.drawArrays(t.primitiveType,i.start,i.count)}}initializeRenderContext(e){this._glMaterials=new a(this.material,e.materials),this._vaoCache=e.renderContext.rctx.getVaoCache(this.material.vertexAttributeLocations,s(this._bufferWriter.vertexBufferLayout))}uninitializeRenderContext(){}addRenderGeometryBuffer(e,t,r,i){this.removeRenderGeometryBuffer(e);const{data:s,elementCount:n}=t,o=this._vaoCache.newVao(s.byteLength);o.vertexBuffers.get("geometry").setSubData(new Uint8Array(s),0,0,s.byteLength);const a={localOrigin:i,numElements:n,buffer:t,items:r,vao:o,drawCalls:this._produceDrawCalls(r)};this._renderGeometries.set(e,a)}updateRenderGeometryBuffer(e,t,r,i){const{data:s,elementCount:n}=t,o=this._renderGeometries.get(e);if(null==o)return;this._vaoCache.deleteVao(o.vao);const a=this._vaoCache.newVao(s.byteLength);a.vertexBuffers.get("geometry").setSubData(new Uint8Array(s),0,0,s.byteLength),o.localOrigin=i,o.numElements=n,o.buffer=t,o.items=r,o.vao=a,o.drawCalls=this._produceDrawCalls(r)}removeRenderGeometryBuffer(e){const t=this._renderGeometries.get(e);null!=t&&(this._vaoCache.deleteVao(t.vao),this._renderGeometries.delete(e))}updateVisibility(e,t){const r=this._renderGeometries.get(e);if(null==r)return;const{items:i}=r;if(i.visibilities.length!==t.length)throw new Error("Unexpected mismatch between old and new visibility flag buffer length.");i.visibilities=t,r.drawCalls=this._produceDrawCalls(i)}hasHighlight(){return!1}_produceDrawCalls(e){const{visibilities:t,ranges:r}=e,i=[];if(f(r)){if(0===r.numItems)return[];const e=r.numVertices;let s=null;for(let n=0;n<r.numItems;++n){t[n]?null==s?(s={start:n*e,count:e},i.push(s)):s.count+=e:s=null}}else{const e=r.counts,s=e.length;if(0===s)return[];let n=null,o=0;for(let r=0;r<s;++r){const s=t[r],a=e[r];s?null==n?(n={start:o,count:a},i.push(n)):n.count+=a:n=null,o+=a}}return i}};function f(e){return"numItems"in e}e([r({constructOnly:!0})],h.prototype,"material",void 0),h=e([i("esri.views.3d.layers.graphics.pipeline.rendering.DirectRenderer")],h);export{h as DirectRenderer};
5
+ import{_ as e}from"../../../../../../chunks/tslib.es6.js";import{nullUid as t}from"../../../../../../core/uid.js";import{property as r}from"../../../../../../core/accessorSupport/decorators/property.js";import"../../../../../../core/has.js";import"../../../../../../core/Logger.js";import"../../../../../../core/RandomLCG.js";import{subclass as i}from"../../../../../../core/accessorSupport/decorators/subclass.js";import{glLayout as s}from"../../../../support/buffer/glUtil.js";import{ShaderOutput as n}from"../../../../webgl-engine/core/shaderLibrary/ShaderOutput.js";import{SyncRenderPlugin as o}from"../../../../webgl-engine/effects/RenderPlugin.js";import{GLMaterials as a}from"../../../../webgl-engine/lib/GLMaterials.js";import{IntersectorType as l}from"../../../../webgl-engine/lib/IntersectorInterfaces.js";import{BoundingVolume as u}from"../../../../webgl-engine/lib/Object3D.js";import{RenderSlot as c}from"../../../../webgl-engine/lib/RenderSlot.js";import{DrawParameters as m}from"../../../../webgl-engine/materials/DrawParameters.js";import{HUDMaterial as d}from"../../../../webgl-engine/materials/HUDMaterial.js";let h=class extends o{constructor(e){super(e),this._glMaterials=null,this._produces=new Map,this._renderGeometries=new Map,this._vaoCache=null,this._drawParameters=new m,this._bufferWriter=null,this.slicePlaneEnabled=!1,this.isGround=!1,this.type=e.material instanceof d?l.HUD:l.OBJECT,this.layerViewUid=e.layerViewUid}get produces(){return this._produces}get numFeatures(){const e=6;let t=0;return this._renderGeometries.forEach((r=>t+=r.numElements/e)),t}get usedMemory(){let e=0;return this._renderGeometries.forEach((t=>{e+=t.vao.usedMemory})),e}intersect(e,r,i,s,n,o){const{material:a,_bufferWriter:l,layerViewUid:c}=this,m=this._renderGeometries;if(0!==m.size&&null!=l.intersect)for(const[d,h]of m){const{buffer:r,localOrigin:n,items:o}=h;l.intersect(r.data,a.parameters,n,e,i,s,((r,i,s,n,l,m)=>{const d=o.objectIds[s];o.visibilities[s]&&e.handleObjectIntersection({object:{id:t,graphicUid:d,layerViewUid:c,boundingVolumeWorldSpace:new u,geometries:[{material:a}]},geometryId:0,primitiveIndex:s},r,i,n,null,l,m)}))}}initialize(){this._bufferWriter=this.material.createBufferWriter(),this.material.produces.forEach(((e,t)=>{this._produces.set(t,(t=>t!==n.Highlight&&t!==n.ShadowHighlight&&e(t)))}))}destroy(){this._glMaterials.dispose();const e=this._renderGeometries.keys();for(const t of e)this.removeRenderGeometryBuffer(t)}acquireTechniques(e){const t=this.material;if(!t.shouldRender(e))return null;const{output:r,bind:i}=e,s=t.produces.get(i.slot);if(!s?.(r))return null;if(r===n.Highlight||r===n.ShadowHighlight)return null;const o=this._glMaterials.load(e.rctx,i.slot,r);return o?.beginSlot(i)}render(e,t){const r=this._renderGeometries;if(0===r.size)return;const{bind:i}=e,s=i.slot===c.OCCLUDER_MATERIAL||i.slot===c.TRANSPARENT_OCCLUDER_MATERIAL?i.slot:null,n=e.rctx;n.runAppleAmdDriverHelper(),n.bindTechnique(t,i,this.material.parameters);const o=t.program;for(const[a,l]of r){const{vao:e,localOrigin:r,drawCalls:a}=l;this._drawParameters.origin=r,o.bindDraw(i,this.material.parameters,this._drawParameters),t.ensureAttributeLocations(e),n.bindVAO(e),n.setPipelineState(t.getPipeline(!1,s));for(const i of a)n.drawArrays(t.primitiveType,i.start,i.count)}}initializeRenderContext(e){this._glMaterials=new a(this.material,e.materials),this._vaoCache=e.renderContext.rctx.getVaoCache(this.material.vertexAttributeLocations,s(this._bufferWriter.vertexBufferLayout))}uninitializeRenderContext(){}addRenderGeometryBuffer(e,t,r,i){this.removeRenderGeometryBuffer(e);const{data:s,elementCount:n}=t,o=this._vaoCache.newVao(s.byteLength);o.vertexBuffers.get("geometry").setSubData(new Uint8Array(s),0,0,s.byteLength);const a={localOrigin:i,numElements:n,buffer:t,items:r,vao:o,drawCalls:this._produceDrawCalls(r)};this._renderGeometries.set(e,a)}updateRenderGeometryBuffer(e,t,r,i){const{data:s,elementCount:n}=t,o=this._renderGeometries.get(e);if(null==o)return;this._vaoCache.deleteVao(o.vao);const a=this._vaoCache.newVao(s.byteLength);a.vertexBuffers.get("geometry").setSubData(new Uint8Array(s),0,0,s.byteLength),o.localOrigin=i,o.numElements=n,o.buffer=t,o.items=r,o.vao=a,o.drawCalls=this._produceDrawCalls(r)}removeRenderGeometryBuffer(e){const t=this._renderGeometries.get(e);null!=t&&(this._vaoCache.deleteVao(t.vao),this._renderGeometries.delete(e))}updateVisibility(e,t){const r=this._renderGeometries.get(e);if(null==r)return;const{items:i}=r;if(i.visibilities.length!==t.length)throw new Error("Unexpected mismatch between old and new visibility flag buffer length.");i.visibilities=t,r.drawCalls=this._produceDrawCalls(i)}hasHighlight(){return!1}_produceDrawCalls(e){const{visibilities:t,ranges:r}=e,i=[];if(f(r)){if(0===r.numItems)return[];const e=r.numVertices;let s=null;for(let n=0;n<r.numItems;++n){t[n]?null==s?(s={start:n*e,count:e},i.push(s)):s.count+=e:s=null}}else{const e=r.counts,s=e.length;if(0===s)return[];let n=null,o=0;for(let r=0;r<s;++r){const s=t[r],a=e[r];s?null==n?(n={start:o,count:a},i.push(n)):n.count+=a:n=null,o+=a}}return i}};function f(e){return"numItems"in e}e([r({constructOnly:!0})],h.prototype,"material",void 0),h=e([i("esri.views.3d.layers.graphics.pipeline.rendering.DirectRenderer")],h);export{h as DirectRenderer};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../../chunks/tslib.es6.js";import t from"../../../../core/Accessor.js";import r from"../../../../core/Evented.js";import o from"../../../../core/Logger.js";import{getMetersPerVerticalUnitForSR as s}from"../../../../core/unitUtils.js";import{property as i}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/has.js";import"../../../../core/RandomLCG.js";import{subclass as n}from"../../../../core/accessorSupport/decorators/subclass.js";import{c as a}from"../../../../chunks/vec32.js";import{create as l}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{empty as c,toRect as d,expandWithVec3 as m}from"../../../../geometry/support/aaBoundingBox.js";import{getMetersPerUnit as p}from"../../../../symbols/support/unitConversionUtils.js";import{ElevationUpdateEvent as h}from"../../support/ElevationUpdateEvent.js";import{newIntersector as u}from"../../webgl-engine/lib/Intersector.js";import{StoreResults as f}from"../../webgl-engine/lib/IntersectorInterfaces.js";import{affectsGeometry as g}from"../../webgl-engine/lib/VertexAttribute.js";const _=1,v=Symbol("layerHandles");let y=class extends(r.EventedMixin(t)){get spatialReference(){return this.view?.spatialReference}constructor(e){super(e),this._elevationOffset=0}initialize(){this._renderCoordsHelper=this.view.renderCoordsHelper,this._intersectLayers=[this.stageLayer],this._intersector=u(this.view.state.viewingMode),this._intersector.options.store=f.MIN;const e=this._computeLayerExtent(this.spatialReference,this.stageLayer);this._zmin=e[2],this._zmax=e[5];const t=this.stageLayer.events;this.addHandles([t.on(["layerObjectAdded","layerObjectRemoved","geometryAdded","geometryRemoved"],(({object:e})=>this._objectChanged(e))),t.on("attributesChanged",(({attribute:e,object:t})=>g(e)&&this._objectChanged(t))),t.on(["transformationChanged","shaderTransformationChanged"],(e=>this._objectChanged(e)))],v)}dispose(){this.removeHandles(v)}elevationInfoChanged(){const e=null!=this.layer?this.layer.elevationInfo:null;if(null!=e&&"on-the-ground"!==e.mode){const t=s(this.layer.spatialReference),r=p(e.unit??"meters");this._elevationOffset=(e.offset??0)*r/t}else this._elevationOffset=0}getElevation(e,t,r,s){if(x[0]=e,x[1]=t,x[2]=r,!this._renderCoordsHelper.toRenderCoords(x,s,x))return o.getLogger(this).error("could not project point for elevation alignment"),null;const i=this._elevationOffset,n=this._zmin+i,a=this._zmax+i;this._renderCoordsHelper.setAltitude(C,a,x),this._renderCoordsHelper.setAltitude(E,n,x);const l=e=>!!e.lastValidElevationBB;return this._intersector.reset(C,E,null),this._intersector.intersect(this._intersectLayers,null,_,null,l),this._intersector.results.min.getIntersectionPoint(x)?this._renderCoordsHelper.getAltitude(x):null}_objectChanged(e){const t=this.spatialReference;if(!e.lastValidElevationBB||!t)return;c(j);const r=e.lastValidElevationBB;r.isEmpty()||this._expandExtent(t,r.min,r.max,j);const{min:o,max:s}=e.boundingVolumeWorldSpace;this._expandExtent(t,o,s,j),d(j,b.extent),this._zmin=Math.min(this._zmin,j[2]),this._zmax=Math.max(this._zmax,j[5]),b.spatialReference=t,this.emit("elevation-change",b),a(r.min,o),a(r.max,s)}_computeLayerExtent(e,t){return c(j),null!=e&&t.objects.forAll((t=>this._expandExtent(e,t.boundingVolumeWorldSpace.min,t.boundingVolumeWorldSpace.max,j))),j}_expandExtent(e,t,r,o){for(let s=0;s<8;++s)x[0]=1&s?t[0]:r[0],x[1]=2&s?t[1]:r[1],x[2]=4&s?t[2]:r[2],this._renderCoordsHelper.fromRenderCoords(x,x,e),m(o,x);return o}};e([i({constructOnly:!0})],y.prototype,"layer",void 0),e([i({constructOnly:!0})],y.prototype,"stageLayer",void 0),e([i({constructOnly:!0})],y.prototype,"view",void 0),e([i()],y.prototype,"spatialReference",null),y=e([n("esri.views.3d.layers.support.StageLayerElevationProvider")],y);const j=c(),b=new h,x=l(),C=l(),E=l();export{y as StageLayerElevationProvider};
5
+ import{_ as e}from"../../../../chunks/tslib.es6.js";import t from"../../../../core/Accessor.js";import r from"../../../../core/Evented.js";import o from"../../../../core/Logger.js";import{getMetersPerVerticalUnitForSR as s}from"../../../../core/unitUtils.js";import{property as i}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/has.js";import"../../../../core/RandomLCG.js";import{subclass as n}from"../../../../core/accessorSupport/decorators/subclass.js";import{c as a}from"../../../../chunks/vec32.js";import{create as l}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{empty as c,toRect as d,expandWithVec3 as m}from"../../../../geometry/support/aaBoundingBox.js";import{getMetersPerUnit as p}from"../../../../symbols/support/unitConversionUtils.js";import{ElevationUpdateEvent as h}from"../../support/ElevationUpdateEvent.js";import{newIntersector as u}from"../../webgl-engine/lib/Intersector.js";import{StoreResults as f}from"../../webgl-engine/lib/IntersectorInterfaces.js";import{affectsGeometry as g}from"../../webgl-engine/lib/VertexAttribute.js";const _=1,v=Symbol("layerHandles");let y=class extends(r.EventedMixin(t)){get spatialReference(){return this.view?.spatialReference}constructor(e){super(e),this._elevationOffset=0}initialize(){this._renderCoordsHelper=this.view.renderCoordsHelper,this._intersectLayers=[this.stageLayer],this._intersector=u(this.view.state.viewingMode),this._intersector.options.store=f.MIN;const e=this._computeLayerExtent(this.spatialReference,this.stageLayer);this._zmin=e[2],this._zmax=e[5];const t=this.stageLayer.events;this.addHandles([t.on(["layerObjectAdded","layerObjectRemoved","transformationChanged","shaderTransformationChanged"],(e=>this._objectChanged(e))),t.on(["geometryAdded","geometryRemoved"],(({object:e})=>this._objectChanged(e))),t.on("attributesChanged",(({attribute:e,object:t})=>g(e)&&this._objectChanged(t)))],v)}dispose(){this.removeHandles(v)}elevationInfoChanged(){const e=null!=this.layer?this.layer.elevationInfo:null;if(null!=e&&"on-the-ground"!==e.mode){const t=s(this.layer.spatialReference),r=p(e.unit??"meters");this._elevationOffset=(e.offset??0)*r/t}else this._elevationOffset=0}getElevation(e,t,r,s){if(x[0]=e,x[1]=t,x[2]=r,!this._renderCoordsHelper.toRenderCoords(x,s,x))return o.getLogger(this).error("could not project point for elevation alignment"),null;const i=this._elevationOffset,n=this._zmin+i,a=this._zmax+i;this._renderCoordsHelper.setAltitude(C,a,x),this._renderCoordsHelper.setAltitude(E,n,x);const l=e=>!!e.lastValidElevationBB;return this._intersector.reset(C,E,null),this._intersector.intersect(this._intersectLayers,null,_,null,l),this._intersector.results.min.getIntersectionPoint(x)?this._renderCoordsHelper.getAltitude(x):null}_objectChanged(e){const t=this.spatialReference;if(!e.lastValidElevationBB||!t)return;c(j);const r=e.lastValidElevationBB;r.isEmpty()||this._expandExtent(t,r.min,r.max,j);const{min:o,max:s}=e.boundingVolumeWorldSpace;this._expandExtent(t,o,s,j),d(j,b.extent),this._zmin=Math.min(this._zmin,j[2]),this._zmax=Math.max(this._zmax,j[5]),b.spatialReference=t,this.emit("elevation-change",b),a(r.min,o),a(r.max,s)}_computeLayerExtent(e,t){return c(j),null!=e&&t.objects.forEach((t=>this._expandExtent(e,t.boundingVolumeWorldSpace.min,t.boundingVolumeWorldSpace.max,j))),j}_expandExtent(e,t,r,o){for(let s=0;s<8;++s)x[0]=1&s?t[0]:r[0],x[1]=2&s?t[1]:r[1],x[2]=4&s?t[2]:r[2],this._renderCoordsHelper.fromRenderCoords(x,x,e),m(o,x);return o}};e([i({constructOnly:!0})],y.prototype,"layer",void 0),e([i({constructOnly:!0})],y.prototype,"stageLayer",void 0),e([i({constructOnly:!0})],y.prototype,"view",void 0),e([i()],y.prototype,"spatialReference",null),y=e([n("esri.views.3d.layers.support.StageLayerElevationProvider")],y);const j=c(),b=new h,x=l(),C=l(),E=l();export{y as StageLayerElevationProvider};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../core/Accessor.js";import"../../../core/has.js";import r from"../../../core/PooledArray.js";import{isPromiseLike as s}from"../../../core/promiseUtils.js";import{signal as i}from"../../../core/signal.js";import{property as n}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as o}from"../../../core/accessorSupport/decorators/subclass.js";import{isIntersectionHandler as d}from"../state/helpers/SceneIntersectionHelper.js";import{TextureCollection as a}from"../support/TextureCollection.js";import{ChangeSet as h}from"./lib/ChangeSet.js";import{UpdatePolicy as c}from"./lib/UpdatePolicy.js";import{isWebGLLayer as m}from"./lib/WebGLLayer.js";import{Model as y}from"./parts/Model.js";import{RenderView as l}from"./parts/RenderView.js";import{TaskPriority as p,noBudget as u}from"../../support/Scheduler.js";import{Yield as _}from"../../support/Yield.js";let g=class extends t{constructor(e){super(e),this._model=new y,this._canCompact=i(!1),this._layers=new r,this._asyncChangeSet=new h,this._syncChangeSet=new h,this._layerSyncSet=new Set,this.textures=new a(this,e.view.resourceController.scheduler),this._frameTask=e.view.resourceController.scheduler.registerTask(p.STAGE,this),this.addHandles(this._frameTask)}initialize(){this._renderView=new l({stage:this})}destroy(){this.textures.destroy(),this.renderView.destroy()}get viewingMode(){return this.view.state.viewingMode}get updating(){return this.running||this.renderView.updating||this._frameTask.updating||this.textures.updating}get renderView(){return this._renderView}get renderer(){return this.renderView.renderer}add(e){this._model.add(e),m(e)&&this._addLayer(e),this.renderView.requestRender()}remove(e){null!=e&&!this.destroyed&&this._model.remove(e)&&(m(e)&&this._removeLayer(e),this.renderView.requestRender())}addMany(e){null!=e&&(this._model.addMany(e),this.renderView.requestRender())}removeMany(e){null!=e&&(this._model?.removeMany(e),this.renderView.requestRender())}forEachOfType(e,t){this._model.forEachOfType(e,t)}handleEvent(e,t){this.destroyed||(this._model.dirtySet[e](t),this.renderView.requestRender())}get running(){return this._model.dirtySet.dirty||!this._asyncChangeSet.empty||this._canCompact.value}runTask(e){if(this._frameTask.processQueue(e),this._commit(e),this.renderer.compact(e),this._canCompact.value=this.renderer.canCompact,!e.hasProgressed)return _}compact(e){return this._canCompact.value=!1,this.renderer.compact(e)}_commit(e){const t=this._model.dirtySet;this._asyncChangeSet.empty||e.done||(this.renderer.commit(this._asyncChangeSet,e),this.renderView.requestRender(),e.madeProgress()),this._layers.forAll((r=>{if(e.done)return;const s=this._layerSyncSet.has(r.id)||r.updatePolicy===c.SYNC,i=s?this._syncChangeSet:this._asyncChangeSet;t.commitLayer(r.id,i),this._layerSyncSet.delete(r.id),i.empty||(this.renderer.commit(i,s?u:e),this.renderView.requestRender(),e.madeProgress())})),this._syncChangeSet.empty||(this.renderer.commit(this._syncChangeSet,u),this.renderView.requestRender(),e.madeProgress()),this._layers.forAll((r=>{e.done||this._layerSyncSet.has(r.id)||r.updatePolicy!==c.ASYNC||(t.commitLayer(r.id,this._asyncChangeSet),this._asyncChangeSet.empty||(this.renderer.commit(this._asyncChangeSet,e),this.renderView.requestRender(),e.madeProgress()))})),this._layerSyncSet.clear(),this.notifyChange("running")}commitSyncLayers(){const e=this._model.dirtySet;this._layers.forAll((t=>{this._layerSyncSet.has(t.id)||t.updatePolicy===c.SYNC?(e.commitLayer(t.id,this._syncChangeSet),this._layerSyncSet.delete(t.id)):e.commitSyncUpdates(t.id,this._syncChangeSet)}));for(const t of this._layerSyncSet)e.commitLayer(t,this._syncChangeSet);this._layerSyncSet.clear(),this._syncChangeSet.empty||(this.renderer.commit(this._syncChangeSet,u),this.renderView.requestRender())}_commitLayer(e){this._model.dirtySet.commitLayer(e.id,this._syncChangeSet),this._layerSyncSet.delete(e.id),this._syncChangeSet.empty||(this.renderer.commit(this._syncChangeSet,u),this.renderView.requestRender())}schedule(e,t){return this._frameTask.schedule(e,t)}reschedule(e,t){return this._frameTask.reschedule(e,t)}syncLayer(e){this._layerSyncSet.add(e),this.renderView.requestRender()}getObject(e){return this._model.getObject(e)}get layers(){return this._layers}_addLayer(e){this._layers.includes(e)||this._layers.push(e)}_removeLayer(e){this._commitLayer(e),null!=this._layers.removeUnordered(e)&&(this._model.dirtySet.getResidentRenderGeometries(e.id,this._syncChangeSet.removes),this.renderer.commit(this._syncChangeSet,u))}addRenderPlugin(e,t){const r=this.renderer.plugins.add(e,t),i=()=>{d(e)&&this.view.sceneIntersectionHelper.addIntersectionHandler(e)};if(s(r))return r.then(i);i()}removeRenderPlugin(e){this.destroyed||(d(e)&&this.view.sceneIntersectionHelper.removeIntersectionHandler(e),this.renderer.plugins.remove(e))}get performanceInfo(){return this._model.getStats()}get test(){}};e([n({constructOnly:!0})],g.prototype,"view",void 0),e([n({constructOnly:!0})],g.prototype,"options",void 0),e([n({readOnly:!0})],g.prototype,"viewingMode",null),e([n({constructOnly:!0})],g.prototype,"container",void 0),e([n({readOnly:!0})],g.prototype,"updating",null),e([n({constructOnly:!0})],g.prototype,"_model",void 0),e([n()],g.prototype,"_renderView",void 0),e([n({readOnly:!0})],g.prototype,"renderer",null),e([n()],g.prototype,"textures",void 0),e([n({readOnly:!0})],g.prototype,"running",null),g=e([o("esri.views.3d.webgl-engine.Stage")],g);export{g as Stage};
5
+ import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../core/Accessor.js";import"../../../core/has.js";import r from"../../../core/PooledArray.js";import{isPromiseLike as s}from"../../../core/promiseUtils.js";import{signal as i}from"../../../core/signal.js";import{property as n}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as o}from"../../../core/accessorSupport/decorators/subclass.js";import{isIntersectionHandler as d}from"../state/helpers/SceneIntersectionHelper.js";import{TextureCollection as a}from"../support/TextureCollection.js";import{ChangeSet as h}from"./lib/ChangeSet.js";import{UpdatePolicy as c}from"./lib/UpdatePolicy.js";import{isWebGLLayer as m}from"./lib/WebGLLayer.js";import{Model as y}from"./parts/Model.js";import{RenderView as l}from"./parts/RenderView.js";import{TaskPriority as p,noBudget as u}from"../../support/Scheduler.js";import{Yield as _}from"../../support/Yield.js";let S=class extends t{constructor(e){super(e),this._model=new y,this._canCompact=i(!1),this._layers=new r,this._asyncChangeSet=new h,this._syncChangeSet=new h,this._layerSyncSet=new Set,this.textures=new a(this,e.view.resourceController.scheduler),this._frameTask=e.view.resourceController.scheduler.registerTask(p.STAGE,this),this.addHandles(this._frameTask)}initialize(){this._renderView=new l({stage:this})}destroy(){this.textures.destroy(),this.renderView.destroy()}get viewingMode(){return this.view.state.viewingMode}get updating(){return this.running||this.renderView.updating||this._frameTask.updating||this.textures.updating}get renderView(){return this._renderView}get renderer(){return this.renderView.renderer}add(e){this._model.add(e),m(e)&&this._addLayer(e),this.renderView.requestRender()}remove(e){null!=e&&!this.destroyed&&this._model.has(e)&&(m(e)&&this._removeLayer(e),this._model.remove(e),this.renderView.requestRender())}addMany(e){null!=e&&(this._model.addMany(e),this.renderView.requestRender())}removeMany(e){null!=e&&(this._model?.removeMany(e),this.renderView.requestRender())}forEachOfType(e,t){this._model.forEachOfType(e,t)}handleEvent(e,t){this.destroyed||(this._model.dirtySet[e](t),this.renderView.requestRender())}get running(){return this._model.dirtySet.dirty||!this._asyncChangeSet.empty||this._canCompact.value}runTask(e){if(this._frameTask.processQueue(e),this._commit(e),this.renderer.compact(e),this._canCompact.value=this.renderer.canCompact,!e.hasProgressed)return _}compact(e){return this._canCompact.value=!1,this.renderer.compact(e)}_commit(e){const t=this._model.dirtySet;this._asyncChangeSet.empty||e.done||(this.renderer.commit(this._asyncChangeSet,e),this.renderView.requestRender(),e.madeProgress()),this._layers.forAll((r=>{if(e.done)return;const s=this._layerSyncSet.has(r.id)||r.updatePolicy===c.SYNC,i=s?this._syncChangeSet:this._asyncChangeSet;t.commitLayer(r.id,i),this._layerSyncSet.delete(r.id),i.empty||(this.renderer.commit(i,s?u:e),this.renderView.requestRender(),e.madeProgress())})),this._syncChangeSet.empty||(this.renderer.commit(this._syncChangeSet,u),this.renderView.requestRender(),e.madeProgress()),this._layers.forAll((r=>{e.done||this._layerSyncSet.has(r.id)||r.updatePolicy!==c.ASYNC||(t.commitLayer(r.id,this._asyncChangeSet),this._asyncChangeSet.empty||(this.renderer.commit(this._asyncChangeSet,e),this.renderView.requestRender(),e.madeProgress()))})),this._layerSyncSet.clear(),this.notifyChange("running")}commitSyncLayers(){const e=this._model.dirtySet;this._layers.forAll((t=>{this._layerSyncSet.has(t.id)||t.updatePolicy===c.SYNC?(e.commitLayer(t.id,this._syncChangeSet),this._layerSyncSet.delete(t.id)):e.commitSyncUpdates(t.id,this._syncChangeSet)}));for(const t of this._layerSyncSet)e.commitLayer(t,this._syncChangeSet);this._layerSyncSet.clear(),this._syncChangeSet.empty||(this.renderer.commit(this._syncChangeSet,u),this.renderView.requestRender())}_commitLayer(e){this._model.dirtySet.commitLayer(e.id,this._syncChangeSet),this._layerSyncSet.delete(e.id),this._syncChangeSet.empty||(this.renderer.commit(this._syncChangeSet,u),this.renderView.requestRender())}schedule(e,t){return this._frameTask.schedule(e,t)}reschedule(e,t){return this._frameTask.reschedule(e,t)}syncLayer(e){this._layerSyncSet.add(e),this.renderView.requestRender()}getObject(e){return this._model.getObject(e)}get layers(){return this._layers}_addLayer(e){this._layers.includes(e)||(this._layers.push(e),this._model.dirtySet.layerAdded(e))}_removeLayer(e){this._model.dirtySet.layerRemoved(e),this._commitLayer(e),this._layers.removeUnordered(e),this._model.dirtySet.assertLayerClean(e.id)}addRenderPlugin(e,t){const r=this.renderer.plugins.add(e,t),i=()=>{d(e)&&this.view.sceneIntersectionHelper.addIntersectionHandler(e)};if(s(r))return r.then(i);i()}removeRenderPlugin(e){this.destroyed||(d(e)&&this.view.sceneIntersectionHelper.removeIntersectionHandler(e),this.renderer.plugins.remove(e))}get performanceInfo(){return this._model.getStats()}get test(){}};e([n({constructOnly:!0})],S.prototype,"view",void 0),e([n({constructOnly:!0})],S.prototype,"options",void 0),e([n({readOnly:!0})],S.prototype,"viewingMode",null),e([n({constructOnly:!0})],S.prototype,"container",void 0),e([n({readOnly:!0})],S.prototype,"updating",null),e([n({constructOnly:!0})],S.prototype,"_model",void 0),e([n()],S.prototype,"_renderView",void 0),e([n({readOnly:!0})],S.prototype,"renderer",null),e([n()],S.prototype,"textures",void 0),e([n({readOnly:!0})],S.prototype,"running",null),S=e([o("esri.views.3d.webgl-engine.Stage")],S);export{S as Stage};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{PixelFormat as T,SizedPixelFormat as E,TextureWrapMode as N,TextureSamplingMode as R,PixelType as n,SizedDepthFormat as e,SizedDepthStencilFormat as t,UnsizedDepthFormat as o}from"../../../webgl/enums.js";import{RenderbufferDescriptor as r}from"../../../webgl/RenderbufferDescriptor.js";import{TextureDescriptor as _}from"../../../webgl/TextureDescriptor.js";import{isSizedDepthFormat as O}from"../../../webgl/textureUtils.js";var M,a,A;function G(T){return T>=M.COUNT}function P(T){return T>=a.COUNT}!function(T){T[T.R8UNORM=0]="R8UNORM",T[T.R8UINT=1]="R8UINT",T[T.RG8UNORM=2]="RG8UNORM",T[T.RG8UINT=3]="RG8UINT",T[T.RGBA4UNORM=4]="RGBA4UNORM",T[T.RGBA8UNORM=5]="RGBA8UNORM",T[T.RGBA8UNORM_MIPMAP=6]="RGBA8UNORM_MIPMAP",T[T.R16FLOAT=7]="R16FLOAT",T[T.RGBA16FLOAT=8]="RGBA16FLOAT",T[T.COUNT=9]="COUNT"}(M||(M={})),function(T){T[T.DEPTH16=9]="DEPTH16",T[T.COUNT=10]="COUNT"}(a||(a={})),function(T){T[T.DEPTH24_STENCIL8=10]="DEPTH24_STENCIL8"}(A||(A={}));const U=new _;U.pixelFormat=T.RED,U.internalFormat=E.R8,U.wrapMode=N.CLAMP_TO_EDGE;const i=new _;i.pixelFormat=T.RED_INTEGER,i.internalFormat=E.R8UI,i.wrapMode=N.CLAMP_TO_EDGE,i.samplingMode=R.NEAREST;const p=new _;p.pixelFormat=T.RG,p.internalFormat=E.RG8,p.wrapMode=N.CLAMP_TO_EDGE;const D=new _;D.pixelFormat=T.RG_INTEGER,D.internalFormat=E.RG8UI,D.wrapMode=N.CLAMP_TO_EDGE,D.samplingMode=R.NEAREST;const m=new _;m.internalFormat=E.RGBA4,m.dataType=n.UNSIGNED_SHORT_4_4_4_4,m.wrapMode=N.CLAMP_TO_EDGE;const I=new _;I.wrapMode=N.CLAMP_TO_EDGE;const F=new _;F.wrapMode=N.CLAMP_TO_EDGE,F.samplingMode=R.LINEAR_MIPMAP_LINEAR,F.hasMipmap=!0,F.maxAnisotropy=8;const L=new _;L.pixelFormat=T.RED,L.dataType=n.HALF_FLOAT,L.internalFormat=E.R16F,L.samplingMode=R.NEAREST;const l=new _;l.dataType=n.HALF_FLOAT,l.internalFormat=E.RGBA16F,l.wrapMode=N.CLAMP_TO_EDGE;const C={[M.R8UNORM]:U,[M.R8UINT]:i,[M.RG8UNORM]:p,[M.RG8UINT]:D,[M.RGBA4UNORM]:m,[M.RGBA8UNORM]:I,[M.RGBA8UNORM_MIPMAP]:F,[M.R16FLOAT]:L,[M.RGBA16FLOAT]:l,[M.COUNT]:null},s={[e.DEPTH_COMPONENT16]:n.UNSIGNED_SHORT,[e.DEPTH_COMPONENT24]:n.UNSIGNED_INT,[e.DEPTH_COMPONENT32F]:n.FLOAT,[t.DEPTH24_STENCIL8]:n.UNSIGNED_INT_24_8,[t.DEPTH32F_STENCIL8]:n.FLOAT_32_UNSIGNED_INT_24_8_REV},w={[a.DEPTH16]:new r(e.DEPTH_COMPONENT16),[a.COUNT]:null},c={[A.DEPTH24_STENCIL8]:d(t.DEPTH24_STENCIL8)};function d(T){const E=new _;return E.pixelFormat=O(T)?o.DEPTH_COMPONENT:o.DEPTH_STENCIL,E.dataType=s[T],E.samplingMode=R.NEAREST,E.wrapMode=N.CLAMP_TO_EDGE,E.internalFormat=T,E.hasMipmap=!1,E.isImmutable=!0,E}export{M as ColorFormat,C as ColorFormats,a as DepthRenderbufferFormat,w as DepthRenderbufferFormats,A as DepthTextureFormat,c as DepthTextureFormats,G as isDepthFormat,P as isDepthTextureFormat};
5
+ import{PixelFormat as T,SizedPixelFormat as R,TextureWrapMode as E,TextureSamplingMode as n,PixelType as N,SizedDepthFormat as e,SizedDepthStencilFormat as t,UnsizedDepthFormat as o}from"../../../webgl/enums.js";import{RenderbufferDescriptor as r}from"../../../webgl/RenderbufferDescriptor.js";import{TextureDescriptor as O}from"../../../webgl/TextureDescriptor.js";import{isSizedDepthFormat as a}from"../../../webgl/textureUtils.js";var _,M,A;function G(T){return T>=_.COUNT}function i(T){return T>=M.COUNT}!function(T){T[T.R8UNORM=0]="R8UNORM",T[T.R8UINT=1]="R8UINT",T[T.RG8UNORM=2]="RG8UNORM",T[T.RG8UINT=3]="RG8UINT",T[T.RGBA4UNORM=4]="RGBA4UNORM",T[T.RGBA8UNORM=5]="RGBA8UNORM",T[T.RGBA8UNORM_MIPMAP=6]="RGBA8UNORM_MIPMAP",T[T.R16FLOAT=7]="R16FLOAT",T[T.RGBA16FLOAT=8]="RGBA16FLOAT",T[T.R32FLOAT=9]="R32FLOAT",T[T.COUNT=10]="COUNT"}(_||(_={})),function(T){T[T.DEPTH16=10]="DEPTH16",T[T.COUNT=11]="COUNT"}(M||(M={})),function(T){T[T.DEPTH24_STENCIL8=11]="DEPTH24_STENCIL8"}(A||(A={}));const p=new O;p.pixelFormat=T.RED,p.internalFormat=R.R8,p.wrapMode=E.CLAMP_TO_EDGE;const F=new O;F.pixelFormat=T.RED_INTEGER,F.internalFormat=R.R8UI,F.wrapMode=E.CLAMP_TO_EDGE,F.samplingMode=n.NEAREST;const P=new O;P.pixelFormat=T.RG,P.internalFormat=R.RG8,P.wrapMode=E.CLAMP_TO_EDGE;const U=new O;U.pixelFormat=T.RG_INTEGER,U.internalFormat=R.RG8UI,U.wrapMode=E.CLAMP_TO_EDGE,U.samplingMode=n.NEAREST;const m=new O;m.internalFormat=R.RGBA4,m.dataType=N.UNSIGNED_SHORT_4_4_4_4,m.wrapMode=E.CLAMP_TO_EDGE;const D=new O;D.wrapMode=E.CLAMP_TO_EDGE;const L=new O;L.wrapMode=E.CLAMP_TO_EDGE,L.samplingMode=n.LINEAR_MIPMAP_LINEAR,L.hasMipmap=!0,L.maxAnisotropy=8;const l=new O;l.pixelFormat=T.RED,l.dataType=N.HALF_FLOAT,l.internalFormat=R.R16F,l.samplingMode=n.NEAREST;const I=new O;I.dataType=N.HALF_FLOAT,I.internalFormat=R.RGBA16F,I.wrapMode=E.CLAMP_TO_EDGE;const s=new O;s.pixelFormat=T.RED,s.dataType=N.FLOAT,s.internalFormat=R.R32F,s.samplingMode=n.NEAREST;const C={[_.R8UNORM]:p,[_.R8UINT]:F,[_.RG8UNORM]:P,[_.RG8UINT]:U,[_.RGBA4UNORM]:m,[_.RGBA8UNORM]:D,[_.RGBA8UNORM_MIPMAP]:L,[_.R16FLOAT]:l,[_.RGBA16FLOAT]:I,[_.R32FLOAT]:s,[_.COUNT]:null},w={[e.DEPTH_COMPONENT16]:N.UNSIGNED_SHORT,[e.DEPTH_COMPONENT24]:N.UNSIGNED_INT,[e.DEPTH_COMPONENT32F]:N.FLOAT,[t.DEPTH24_STENCIL8]:N.UNSIGNED_INT_24_8,[t.DEPTH32F_STENCIL8]:N.FLOAT_32_UNSIGNED_INT_24_8_REV},d={[M.DEPTH16]:new r(e.DEPTH_COMPONENT16),[M.COUNT]:null},c={[A.DEPTH24_STENCIL8]:H(t.DEPTH24_STENCIL8)};function H(T){const R=new O;return R.pixelFormat=a(T)?o.DEPTH_COMPONENT:o.DEPTH_STENCIL,R.dataType=w[T],R.samplingMode=n.NEAREST,R.wrapMode=E.CLAMP_TO_EDGE,R.internalFormat=T,R.hasMipmap=!1,R.isImmutable=!0,R}export{_ as ColorFormat,C as ColorFormats,M as DepthRenderbufferFormat,d as DepthRenderbufferFormats,A as DepthTextureFormat,c as DepthTextureFormats,G as isDepthFormat,i as isDepthTextureFormat};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{create as t}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{RenderPass as s,RenderPassSorting as e}from"./RenderPass.js";import{RenderPassIdentifier as i}from"./RenderPassIdentifier.js";import{ShaderOutput as r}from"../shaderLibrary/ShaderOutput.js";import{VertexNormalPassParameters as a,VertexNormalDrawParameters as n}from"../shaderLibrary/attributes/VertexNormal.glsl.js";class o{constructor(t){const i=t.renderContext.rctx,r=t.techniques;this.opaque=new s(i,r),this.transparent=new s(i,r,e.BackToFront),this.integratedMesh=new s(i,r),this.shadowMap=new s(i,r),this.highlight=new s(i,r),this.highlightIntegratedMesh=new s(i,r),this.highlightShadowMap=new s(i,r),this.viewshedShadowMap=new s(i,r),this.defaultShadowMap=new s(i,r)}}class h extends a{constructor(){super(...arguments),this.slicePlaneLocalOrigin=t(),this.origin=this.slicePlaneLocalOrigin,this.modelTransformation=null}}class c extends n{}class d extends h{constructor(){super(...arguments),this.identifier=i.Material,this.output=r.Color,this.transparent=!1}}class l extends h{constructor(){super(...arguments),this.identifier=i.ShadowMap}}class p extends h{constructor(){super(...arguments),this.identifier=i.Highlight}}class u extends h{constructor(){super(...arguments),this.identifier=i.ViewshedShadowMap}}export{o as AllRenderPasses,c as DrawParameters,p as HighlightPassParameters,d as MaterialPassParameters,h as PassParameters,l as ShadowMapPassParameters,u as ViewshedShadowMapPassParameters};
5
+ import{create as t}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{RenderPass as s,RenderPassSorting as e}from"./RenderPass.js";import{RenderPassIdentifier as i}from"./RenderPassIdentifier.js";import{ShaderOutput as r}from"../shaderLibrary/ShaderOutput.js";import{VertexNormalPassParameters as a,VertexNormalDrawParameters as n}from"../shaderLibrary/attributes/VertexNormal.glsl.js";class h{constructor(t){const i=t.renderContext.rctx,r=t.techniques;this.opaque=new s(i,r),this.transparent=new s(i,r,e.BackToFront),this.integratedMesh=new s(i,r),this.shadowMap=new s(i,r),this.highlight=new s(i,r),this.highlightIntegratedMesh=new s(i,r),this.highlightShadowMap=new s(i,r),this.viewshedShadowMap=new s(i,r),this.defaultShadowMap=new s(i,r)}}class o extends a{constructor(){super(...arguments),this.slicePlaneLocalOrigin=t(),this.origin=this.slicePlaneLocalOrigin}}class c extends n{}class d extends o{constructor(){super(...arguments),this.identifier=i.Material,this.output=r.Color,this.transparent=!1}}class l extends o{constructor(){super(...arguments),this.identifier=i.ShadowMap}}class p extends o{constructor(){super(...arguments),this.identifier=i.Highlight}}class u extends o{constructor(){super(...arguments),this.identifier=i.ViewshedShadowMap}}export{h as AllRenderPasses,c as DrawParameters,p as HighlightPassParameters,d as MaterialPassParameters,o as PassParameters,l as ShadowMapPassParameters,u as ViewshedShadowMapPassParameters};
@@ -2,7 +2,7 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{IDENTITY as a}from"../../../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{create as e}from"../../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ReadShadowMapOrigin as o,calculateUVZShadowPass as s,calculateUVZShadowDraw as t}from"./calculateUVZShadow.glsl.js";import{Rgba4FloatEncoding as d}from"../util/RgbaFloat16Encoding.glsl.js";import{glsl as r}from"../../shaderModules/glsl.js";import{Texture2DBindUniform as h}from"../../shaderModules/Texture2DBindUniform.js";import{NoParameters as i}from"../../../../../webgl/NoParameters.js";class c extends o{}class w extends i{constructor(){super(...arguments),this.modelTransformation=a}}class l extends w{constructor(){super(...arguments),this.origin=e()}}function p(a,e){e.receiveShadows&&(a.include(s),u(a))}function v(a,e){e.receiveShadows&&(a.include(t),u(a))}function u(a){const{fragment:e}=a;e.include(d),e.uniforms.add(new h("shadowMap",(a=>a.shadowMap.depthTexture))).code.add(r`float readShadowMapDepth(ivec2 uv, sampler2D _shadowMap) {
5
+ import{create as a}from"../../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ReadShadowMapOrigin as e,calculateUVZShadowPass as o,calculateUVZShadowDraw as s}from"./calculateUVZShadow.glsl.js";import{Rgba4FloatEncoding as d}from"../util/RgbaFloat16Encoding.glsl.js";import{glsl as t}from"../../shaderModules/glsl.js";import{Texture2DBindUniform as r}from"../../shaderModules/Texture2DBindUniform.js";import{NoParameters as h}from"../../../../../webgl/NoParameters.js";class i extends e{}class w extends h{constructor(){super(...arguments),this.origin=a()}}function p(a,e){e.receiveShadows&&(a.include(o),c(a))}function v(a,e){e.receiveShadows&&(a.include(s),c(a))}function c(a){const{fragment:e}=a;e.include(d),e.uniforms.add(new r("shadowMap",(a=>a.shadowMap.depthTexture))).code.add(t`float readShadowMapDepth(ivec2 uv, sampler2D _shadowMap) {
6
6
  return rgba4ToFloat(texelFetch(_shadowMap, uv, 0));
7
7
  }
8
8
  float posIsInShadow(ivec2 uv, float lvposZ, sampler2D _shadowMap) {
@@ -31,4 +31,4 @@ if (uvzShadow.z < 0.0) {
31
31
  return 0.0;
32
32
  }
33
33
  return filterShadow(uvzShadow, shadowMap);
34
- }`)}export{v as ReadShadowMapDraw,c as ReadShadowMapDrawParameters,w as ReadShadowMapParameters,p as ReadShadowMapPass,l as ReadShadowMapPassParameters};
34
+ }`)}export{v as ReadShadowMapDraw,i as ReadShadowMapDrawParameters,p as ReadShadowMapPass,w as ReadShadowMapPassParameters};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- var e;!function(e){e[e.Layer=0]="Layer",e[e.Object=1]="Object",e[e.Texture=2]="Texture",e[e.COUNT=3]="COUNT"}(e||(e={}));export{e as ContentObjectType};
5
+ var e;!function(e){e[e.Layer=0]="Layer",e[e.Texture=1]="Texture",e[e.COUNT=2]="COUNT"}(e||(e={}));export{e as ContentObjectType};
@@ -0,0 +1,5 @@
1
+ /*
2
+ All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
+ See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
+ */
5
+ import{_ as t}from"../../../../chunks/tslib.es6.js";import{disposeMaybe as e,destroyMaybe as i}from"../../../../core/maybe.js";import{property as r}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/has.js";import"../../../../core/Logger.js";import"../../../../core/RandomLCG.js";import{subclass as s}from"../../../../core/accessorSupport/decorators/subclass.js";import{multiply as o,fromTranslation as n}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as h}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{i as u,a as p}from"../../../../chunks/vec32.js";import{create as c}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{RenderCategory as a}from"../../webgl.js";import f from"../../webgl/RenderNode.js";import{ColorFormat as _}from"../core/FBOCacheFormats.js";import{Default3D as l}from"./DefaultVertexAttributeLocations.js";import{TaskPriority as d}from"../../../support/Scheduler.js";import{Yield as m}from"../../../support/Yield.js";import{PixelFormat as g,PixelType as x,TextureSamplingMode as v}from"../../../webgl/enums.js";import{makePipelineState as w,defaultColorWrite as y}from"../../../webgl/renderState.js";import{Sync as j}from"../../../webgl/Sync.js";import{Texture as b}from"../../../webgl/Texture.js";import{TextureDescriptor as B}from"../../../webgl/TextureDescriptor.js";let P=class extends f{constructor(){super(...arguments),this.produces=a.OPAQUE,this.consumes={required:[a.OPAQUE]},this.running=!1,this.done=!0,this._startQuery=!1,this._origin=c(),this._textureWidth=256,this._uploadBuffer=new Float32Array(3*this._textureWidth),this._counter=0,this._width=0,this._height=0,this._pipeline=w({colorWrite:y})}initialize(){this.view.resourceController.scheduler.registerTask(d.GRAPHICS_CORE,this)}destroy(){this._program=e(this._program);const t=this.gl;this._sync=i(this._sync),this._pixelBuffer&&(t.deleteBuffer(this._pixelBuffer),this._pixelBuffer=null),this._texture=e(this._texture)}precompile(){this._startQuery&&this._ensureShader(this.renderingContext)}render(t){const e=t.find((({name:t})=>t===a.OPAQUE));if(this._sync||!this._startQuery)return e;this._startQuery=!1;const i=this.renderingContext,r=this.gl,s=e.getTexture(r.DEPTH_STENCIL_ATTACHMENT);if(!s)return e;const h=this.view.stage.renderer.fboCache.acquire(this._width,this._height,"hud visibility",_.R32FLOAT);i.bindFramebuffer(h.fbo),i.setPipelineState(this._pipeline);const u=this._ensureShader(i);i.useProgram(u);const p=0;i.bindTexture(s,p),u.setUniform1i("depthTex",p);const c=1;return i.bindTexture(this._texture,c),u.setUniform1i("positionTex",c),o(F,this.camera.viewMatrix,n(F,this._origin)),u.setUniformMatrix4fv("view",F),u.setUniformMatrix4fv("proj",this.camera.projectionMatrix),u.setUniform1i("count",this._counter),i.screen.draw(),this._pixelBuffer||(this._pixelBuffer=r.createBuffer()),r.bindBuffer(r.PIXEL_PACK_BUFFER,this._pixelBuffer),r.bufferData(r.PIXEL_PACK_BUFFER,4*this._width*this._height,r.STREAM_READ),r.readPixels(0,0,this._width,this._height,r.RED,r.FLOAT,0),this._sync=new j(r),h.free(),setTimeout((()=>this.running=!0),0),e}runTask(){if(!this._sync)return void(this.running=!1);try{if(!this._sync.poll())return m}catch(e){return this.running=!1,void(this._sync=i(this._sync))}this.running=!1,this._sync=i(this._sync);const t=this.gl;t.bindBuffer(t.PIXEL_PACK_BUFFER,this._pixelBuffer),this._cpuBuffer=new Float32Array(this._width*this._height),t.getBufferSubData(t.PIXEL_PACK_BUFFER,0,this._cpuBuffer),t.bindBuffer(t.PIXEL_PACK_BUFFER,null),this.done=!0}init(t,e){const i=this._textureWidth;if(this._width=i,this._height=Math.ceil(t/i),this._counter=0,this._texture?.dispose(),0===this._height)return;const r=new B(this._width,this._height);r.pixelFormat=g.RGB,r.dataType=x.FLOAT,r.samplingMode=v.NEAREST,this._texture=new b(this.renderingContext,r),this.done=!1,u(this._origin,Math.fround(e[0]),Math.fround(e[1]),Math.fround(e[2]))}addPosition(t){const e=this._width;if(this._counter>=e*this._height)return-1;const i=this._counter%e;return p(E,t,this._origin),this._uploadBuffer[3*i+0]=E[0],this._uploadBuffer[3*i+1]=E[1],this._uploadBuffer[3*i+2]=E[2],i===e-1&&this._flush(),this._counter++}start(){if(0===this._width||0===this._height)return;const t=this._width;this._counter%t>0&&this._flush(),this._startQuery=!0,this.requestRender()}getOcclusion(t){return this._cpuBuffer?.[t]??-1}_flush(){const t=this._width,e=Math.floor(this._counter/t);this._texture?.updateData(0,0,e,t,1,this._uploadBuffer)}_ensureShader(t){return null!=this._program||(this._program=t.programCache.acquire(T,C,l)),this._program}};t([r()],P.prototype,"running",void 0),t([r()],P.prototype,"done",void 0),P=t([s("esri.views.3d.webgl-engine.lib.GPUPointOcclusionQuery")],P);const T="#version 300 es\nprecision highp float;\nin vec2 position;\n\nvoid main() {\n gl_Position = vec4(position, 0.0, 1.0);\n}",C="#version 300 es\nprecision highp float;\nout highp vec4 fragColor;\n\nuniform highp mat4 proj;\nuniform highp mat4 view;\n\nuniform highp int count;\n\nuniform highp sampler2D depthTex;\nuniform highp sampler2D positionTex;\n\nfloat linearizeDepth(float depth) {\n float depthNdc = depth * 2.0 - 1.0;\n float c1 = proj[3][2];\n float c2 = proj[2][2];\n return -c1 / (depthNdc + c2 + 1e-7);\n}\n\nvoid main() {\n int u = int(floor(gl_FragCoord.x));\n int v = int(floor(gl_FragCoord.y));\n if (u + v * textureSize(positionTex, 0).x >= count) {\n fragColor = vec4(-1);\n return;\n }\n vec4 posWorld = vec4(texelFetch(positionTex, ivec2(u, v), 0).rgb, 1.0);\n\n vec4 posView = view * posWorld;\n vec4 projected = proj * posView;\n\n vec3 clipPos = projected.xyz / projected.w;\n\n if (clipPos.x < -1.0 || clipPos.x > 1.0 || clipPos.y < -1.0 || clipPos.y > 1.0) {\n fragColor = vec4(-1);\n return;\n }\n\n vec3 uvDepth = 0.5 * clipPos + vec3(0.5);\n\n float depth = texture(depthTex, uvDepth.xy).r;\n\n if (uvDepth.z <= depth) {\n fragColor = vec4(0);\n return;\n }\n\n fragColor = vec4(linearizeDepth(depth) - linearizeDepth(uvDepth.z));\n}\n",E=c(),F=h();export{P as GPUPointOcclusionQuery};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import"../../../../core/has.js";import{generateUID as t}from"../../../../core/uid.js";import{d as r}from"../../../../chunks/vec32.js";import{create as i}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{fromValues as o}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{projectBuffer as s}from"../../../../geometry/projection/projectBuffer.js";import{Attribute as e}from"./Attribute.js";import{Geometry as n}from"./Geometry.js";import{fromValues as a}from"./LocalOriginFactory.js";import{Object3D as h}from"./Object3D.js";import{gridLocalOriginFactory as m}from"./testUtils.js";import{VertexAttribute as c}from"./VertexAttribute.js";import{WebGLLayer as g}from"./WebGLLayer.js";import{RibbonLineMaterial as f}from"../materials/RibbonLineMaterial.js";import{GeometryType as d}from"./IntersectableGeometry.js";class l{constructor(r){this._originSR=r,this._rootOriginId="root/"+t(),this._origins=new Map,this._objects=new Map,this._gridSize=5e5}getOrigin(t){const i=this._origins.get(this._rootOriginId);if(null==i){const r=m.rootOrigin;if(null!=r)return this._origins.set(this._rootOriginId,a(r[0],r[1],r[2],this._rootOriginId)),this.getOrigin(t);const i=a(t[0]+Math.random()-.5,t[1]+Math.random()-.5,t[2]+Math.random()-.5,this._rootOriginId);return this._origins.set(this._rootOriginId,i),i}const o=this._gridSize,s=Math.round(t[0]/o),e=Math.round(t[1]/o),n=Math.round(t[2]/o),h=`${s}/${e}/${n}`;let c=this._origins.get(h);const g=.5*o;if(r(_,t,i.vec3),_[0]=Math.abs(_[0]),_[1]=Math.abs(_[1]),_[2]=Math.abs(_[2]),_[0]<g&&_[1]<g&&_[2]<g){if(c){const i=Math.max(..._);r(_,t,c.vec3),_[0]=Math.abs(_[0]),_[1]=Math.abs(_[1]),_[2]=Math.abs(_[2]);if(Math.max(..._)<i)return c}return i}return c||(c=a(s*o,e*o,n*o,h),this._origins.set(h,c)),c}_drawOriginBox(t,r=o(1,1,0,1)){const i=window.view,a=i.stage,m=r.toString();if(!this._objects.has(m)){this._material=new f({width:2,color:r});const t=new g(a,{pickable:!1}),i=new h({castShadow:!1});a.add(i),t.add(i),this._objects.set(m,i)}const l=this._objects.get(m),_=[0,1,5,4,0,2,1,7,6,2,0,1,3,7,5,4,6,2,0],p=_.length,j=new Array(3*p),b=new Array,u=.5*this._gridSize;for(let o=0;o<p;o++)j[3*o]=t[0]+(1&_[o]?u:-u),j[3*o+1]=t[1]+(2&_[o]?u:-u),j[3*o+2]=t[2]+(4&_[o]?u:-u),o>0&&b.push(o-1,o);s(j,this._originSR,0,j,i.renderSpatialReference,0,p);const M=new n(this._material,[[c.POSITION,new e(j,b,3,!0)]],null,d.Line);l.addGeometry(M)}get test(){}}const _=i();export{l as GridLocalOriginFactory};
5
+ import"../../../../core/has.js";import{generateUID as t}from"../../../../core/uid.js";import{d as r}from"../../../../chunks/vec32.js";import{create as i}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{fromValues as o}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{projectBuffer as s}from"../../../../geometry/projection/projectBuffer.js";import{Attribute as e}from"./Attribute.js";import{Geometry as n}from"./Geometry.js";import{fromValues as a}from"./LocalOriginFactory.js";import{Object3D as h}from"./Object3D.js";import{gridLocalOriginFactory as m}from"./testUtils.js";import{VertexAttribute as c}from"./VertexAttribute.js";import{WebGLLayer as g}from"./WebGLLayer.js";import{RibbonLineMaterial as f}from"../materials/RibbonLineMaterial.js";import{GeometryType as d}from"./IntersectableGeometry.js";class l{constructor(r){this._originSR=r,this._rootOriginId="root/"+t(),this._origins=new Map,this._objects=new Map,this._gridSize=5e5}getOrigin(t){const i=this._origins.get(this._rootOriginId);if(null==i){const r=m.rootOrigin;if(null!=r)return this._origins.set(this._rootOriginId,a(r[0],r[1],r[2],this._rootOriginId)),this.getOrigin(t);const i=a(t[0]+Math.random()-.5,t[1]+Math.random()-.5,t[2]+Math.random()-.5,this._rootOriginId);return this._origins.set(this._rootOriginId,i),i}const o=this._gridSize,s=Math.round(t[0]/o),e=Math.round(t[1]/o),n=Math.round(t[2]/o),h=`${s}/${e}/${n}`;let c=this._origins.get(h);const g=.5*o;if(r(_,t,i.vec3),_[0]=Math.abs(_[0]),_[1]=Math.abs(_[1]),_[2]=Math.abs(_[2]),_[0]<g&&_[1]<g&&_[2]<g){if(c){const i=Math.max(..._);r(_,t,c.vec3),_[0]=Math.abs(_[0]),_[1]=Math.abs(_[1]),_[2]=Math.abs(_[2]);if(Math.max(..._)<i)return c}return i}return c||(c=a(s*o,e*o,n*o,h),this._origins.set(h,c)),c}_drawOriginBox(t,r=o(1,1,0,1)){const i=window.view,a=i.stage,m=r.toString();if(!this._objects.has(m)){this._material=new f({width:2,color:r});const t=new g(a,{pickable:!1}),i=new h({castShadow:!1});t.add(i),this._objects.set(m,i)}const l=this._objects.get(m),_=[0,1,5,4,0,2,1,7,6,2,0,1,3,7,5,4,6,2,0],p=_.length,j=new Array(3*p),b=new Array,u=.5*this._gridSize;for(let o=0;o<p;o++)j[3*o]=t[0]+(1&_[o]?u:-u),j[3*o+1]=t[1]+(2&_[o]?u:-u),j[3*o+2]=t[2]+(4&_[o]?u:-u),o>0&&b.push(o-1,o);s(j,this._originSR,0,j,i.renderSpatialReference,0,p);const M=new n(this._material,[[c.POSITION,new e(j,b,3,!0)]],null,d.Line);l.addGeometry(M)}get test(){}}const _=i();export{l as GridLocalOriginFactory};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{copy as t}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as r,IDENTITY as i}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{g as s,t as e,h as n,l as a,c as o,n as h}from"../../../../chunks/vec32.js";import{create as d,UNIT_Z as c}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{t as l}from"../../../../chunks/vec42.js";import{create as m}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{create as f,fromPoints as y,copy as u}from"../../../../geometry/support/ray.js";import{ViewingMode as p}from"../../../ViewingMode.js";import{IntersectorOptions as g,StoreResults as _,IntersectorType as O}from"./IntersectorInterfaces.js";import{HudTarget as L}from"./IntersectorTarget.js";import{isValidIntersectorResult as j}from"./intersectorUtils.js";import{IntersectorTransform as v,getVerticalOffsetObject3D as b}from"./verticalOffsetUtils.js";const w=1e-5;class x{constructor(t){this.options=new g,this._results=new T,this.transform=new v,this.tolerance=w,this.verticalOffset=null,this._ray=f(),this._rayEnd=d(),this._rayBeginTransformed=d(),this._rayEndTransformed=d(),this.viewingMode=t??p.Global}get results(){return this._results}get ray(){return this._ray}get rayBegin(){return this._ray.origin}get rayEnd(){return this._rayEnd}reset(t,r,i){this.resetWithRay(y(t,r,this._ray),i)}resetWithRay(t,r){this.camera=r,t!==this._ray&&u(t,this._ray),0!==this.options.verticalOffset?this.viewingMode===p.Local?this._ray.origin[2]-=this.options.verticalOffset:this.verticalOffset=this.options.verticalOffset:this.verticalOffset=null,s(this._rayEnd,this._ray.origin,this._ray.direction),this._results.init(this._ray)}intersect(t=null,r,i,s,e){this.point=r,this.filterPredicate=s,this.tolerance=i??w;const n=b(this.verticalOffset);if(t&&t.length>0){const r=e?t=>{e(t)&&this.intersectObject(t)}:t=>{this.intersectObject(t)};for(const i of t){const t=i.getSpatialQueryAccelerator?.();null!=t?(null!=n?t.forEachAlongRayWithVerticalOffset(this._ray.origin,this._ray.direction,r,n):t.forEachAlongRay(this._ray.origin,this._ray.direction,r),this.options.selectionMode&&this.options.hud&&t.forEachDegenerateObject(r)):i.objects.forAll((t=>r(t)))}}this.sortResults()}intersectObject(t){const r=t.geometries;if(!r)return;const i=t.effectiveTransformation,s=b(this.verticalOffset);for(const n of r){if(!n.visible)continue;const{material:r,id:a}=n;if(!r.visible)continue;this.transform.setAndInvalidateLazyTransforms(i,n.transformation),e(this._rayBeginTransformed,this.rayBegin,this.transform.inverse),e(this._rayEndTransformed,this.rayEnd,this.transform.inverse);const o=this.transform.transform;null!=s&&(s.objectTransform=this.transform),r.intersect(n,this.transform.transform,this,this._rayBeginTransformed,this._rayEndTransformed,((r,i,s,e,n,h)=>this.handleObjectIntersection({object:t,geometryId:a,primIndex:s},r,i,e,o,n,h)))}}handleObjectIntersection(t,r,s,e,n,a,o){if(r<0)return;if(null!=this.filterPredicate&&!this.filterPredicate(this._ray.origin,this._rayEnd,r))return;const h=e?this._results.hud:this._results,d=e?e=>{const n=new L(t.object,t.geometryId,t.primIndex,o);e.set(O.HUD,n,r,s,i,a)}:i=>i.set(O.OBJECT,t,r,s,n,a);if((null==h.min.drapedLayerOrder||a>=h.min.drapedLayerOrder)&&(null==h.min.dist||r<h.min.dist)&&d(h.min),this.options.store!==_.MIN&&(null==h.max.drapedLayerOrder||a<h.max.drapedLayerOrder)&&(null==h.max.dist||r>h.max.dist)&&d(h.max),this.options.store===_.ALL)if(e){const t=new B(this._ray);d(t),this._results.hud.all.push(t)}else{const t=new A(this._ray);d(t),this._results.all.push(t)}}sortResults(t=this._results.all){t.sort(((t,r)=>t.dist!==r.dist?(t.dist??0)-(r.dist??0):t.drapedLayerOrder!==r.drapedLayerOrder?E(t.drapedLayerOrder,r.drapedLayerOrder):E(t.drapedLayerGraphicOrder,r.drapedLayerGraphicOrder)))}}function E(t,r){return(r??-Number.MAX_VALUE)-(t??-Number.MAX_VALUE)}function I(t){return new x(t)}class T{constructor(){this.min=new A(f()),this.max=new A(f()),this.hud={min:new B(f()),max:new B(f()),all:new Array},this.ground=new A(f()),this.all=[]}init(t){this.min.init(t),this.max.init(t),this.ground.init(t),this.all.length=0,this.hud.min.init(t),this.hud.max.init(t),this.hud.all.length=0}}class A{get ray(){return this._ray}get distanceInRenderSpace(){return null!=this.dist?(n(G,this.ray.direction,this.dist),a(G)):null}withinDistance(t){return!!j(this)&&this.distanceInRenderSpace<=t}getIntersectionPoint(t){return!!j(this)&&(n(G,this.ray.direction,this.dist),s(t,this.ray.origin,G),!0)}getTransformedNormal(t){return o(M,this.normal),M[3]=0,l(M,M,this.transformation),o(t,M),h(t,t)}constructor(t){this.intersector=O.OBJECT,this.normal=d(),this.transformation=r(),this._ray=f(),this.init(t)}init(t){this.dist=null,this.target=null,this.drapedLayerOrder=null,this.drapedLayerGraphicOrder=null,this.intersector=O.OBJECT,u(t,this._ray)}set(r,s,e,n,a,h,d){this.intersector=r,this.dist=e,o(this.normal,n??c),t(this.transformation,a??i),this.target=s,this.drapedLayerOrder=h,this.drapedLayerGraphicOrder=d}copy(r){u(r.ray,this._ray),this.intersector=r.intersector,this.dist=r.dist,this.target=r.target,this.drapedLayerOrder=r.drapedLayerOrder,this.drapedLayerGraphicOrder=r.drapedLayerGraphicOrder,o(this.normal,r.normal),t(this.transformation,r.transformation)}}class B extends A{constructor(){super(...arguments),this.intersector=O.HUD}}function R(t){return new A(t)}const G=d(),M=m();export{w as defaultTolerance,I as newIntersector,R as newIntersectorResult};
5
+ import{copy as t}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as r,IDENTITY as i}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{g as s,t as e,h as n,l as a,c as o,n as h}from"../../../../chunks/vec32.js";import{create as c,UNIT_Z as d}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{t as l}from"../../../../chunks/vec42.js";import{create as m}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{create as f,fromPoints as y,copy as u}from"../../../../geometry/support/ray.js";import{ViewingMode as p}from"../../../ViewingMode.js";import{IntersectorOptions as g,StoreResults as _,IntersectorType as O}from"./IntersectorInterfaces.js";import{HudTarget as L}from"./IntersectorTarget.js";import{isValidIntersectorResult as v}from"./intersectorUtils.js";import{IntersectorTransform as j,getVerticalOffsetObject3D as b}from"./verticalOffsetUtils.js";const w=1e-5;class E{constructor(t){this.options=new g,this._results=new T,this.transform=new j,this.tolerance=w,this.verticalOffset=null,this._ray=f(),this._rayEnd=c(),this._rayBeginTransformed=c(),this._rayEndTransformed=c(),this.viewingMode=t??p.Global}get results(){return this._results}get ray(){return this._ray}get rayBegin(){return this._ray.origin}get rayEnd(){return this._rayEnd}reset(t,r,i){this.resetWithRay(y(t,r,this._ray),i)}resetWithRay(t,r){this.camera=r,t!==this._ray&&u(t,this._ray),0!==this.options.verticalOffset?this.viewingMode===p.Local?this._ray.origin[2]-=this.options.verticalOffset:this.verticalOffset=this.options.verticalOffset:this.verticalOffset=null,s(this._rayEnd,this._ray.origin,this._ray.direction),this._results.init(this._ray)}intersect(t=null,r,i,s,e){this.point=r,this.filterPredicate=s,this.tolerance=i??w;const n=b(this.verticalOffset);if(t&&t.length>0){const r=e?t=>{e(t)&&this.intersectObject(t)}:t=>{this.intersectObject(t)};for(const i of t){const t=i.getSpatialQueryAccelerator?.();null!=t?(null!=n?t.forEachAlongRayWithVerticalOffset(this._ray.origin,this._ray.direction,r,n):t.forEachAlongRay(this._ray.origin,this._ray.direction,r),this.options.selectionMode&&this.options.hud&&t.forEachDegenerateObject(r)):i.objects.forEach((t=>r(t)))}}this.sortResults()}intersectObject(t){const r=t.geometries;if(!r)return;const i=t.effectiveTransformation,s=b(this.verticalOffset);for(const n of r){if(!n.visible)continue;const{material:r,id:a}=n;if(!r.visible)continue;this.transform.setAndInvalidateLazyTransforms(i,n.transformation),e(this._rayBeginTransformed,this.rayBegin,this.transform.inverse),e(this._rayEndTransformed,this.rayEnd,this.transform.inverse);const o=this.transform.transform;null!=s&&(s.objectTransform=this.transform),r.intersect(n,this.transform.transform,this,this._rayBeginTransformed,this._rayEndTransformed,((r,i,s,e,n,h)=>this.handleObjectIntersection({object:t,geometryId:a,primitiveIndex:s},r,i,e,o,n,h)))}}handleObjectIntersection(t,r,s,e,n,a,o){if(r<0)return;if(null!=this.filterPredicate&&!this.filterPredicate(this._ray.origin,this._rayEnd,r))return;const h=e?this._results.hud:this._results,c=e?e=>{const n=new L(t.object,t.geometryId,t.primitiveIndex,o);e.set(O.HUD,n,r,s,i,a)}:i=>i.set(O.OBJECT,t,r,s,n,a);if((null==h.min.drapedLayerOrder||a>=h.min.drapedLayerOrder)&&(null==h.min.dist||r<h.min.dist)&&c(h.min),this.options.store!==_.MIN&&(null==h.max.drapedLayerOrder||a<h.max.drapedLayerOrder)&&(null==h.max.dist||r>h.max.dist)&&c(h.max),this.options.store===_.ALL)if(e){const t=new B(this._ray);c(t),this._results.hud.all.push(t)}else{const t=new A(this._ray);c(t),this._results.all.push(t)}}sortResults(t=this._results.all){t.sort(((t,r)=>t.dist!==r.dist?(t.dist??0)-(r.dist??0):t.drapedLayerOrder!==r.drapedLayerOrder?x(t.drapedLayerOrder,r.drapedLayerOrder):x(t.drapedLayerGraphicOrder,r.drapedLayerGraphicOrder)))}}function x(t,r){return(r??-Number.MAX_VALUE)-(t??-Number.MAX_VALUE)}function I(t){return new E(t)}class T{constructor(){this.min=new A(f()),this.max=new A(f()),this.hud={min:new B(f()),max:new B(f()),all:new Array},this.ground=new A(f()),this.all=[]}init(t){this.min.init(t),this.max.init(t),this.ground.init(t),this.all.length=0,this.hud.min.init(t),this.hud.max.init(t),this.hud.all.length=0}}class A{get ray(){return this._ray}get distanceInRenderSpace(){return null!=this.dist?(n(G,this.ray.direction,this.dist),a(G)):null}withinDistance(t){return!!v(this)&&this.distanceInRenderSpace<=t}getIntersectionPoint(t){return!!v(this)&&(n(G,this.ray.direction,this.dist),s(t,this.ray.origin,G),!0)}getTransformedNormal(t){return o(M,this.normal),M[3]=0,l(M,M,this.transformation),o(t,M),h(t,t)}constructor(t){this.intersector=O.OBJECT,this.normal=c(),this.transformation=r(),this._ray=f(),this.init(t)}init(t){this.dist=null,this.target=null,this.drapedLayerOrder=null,this.drapedLayerGraphicOrder=null,this.intersector=O.OBJECT,u(t,this._ray)}set(r,s,e,n,a,h,c){this.intersector=r,this.dist=e,o(this.normal,n??d),t(this.transformation,a??i),this.target=s,this.drapedLayerOrder=h,this.drapedLayerGraphicOrder=c}copy(r){u(r.ray,this._ray),this.intersector=r.intersector,this.dist=r.dist,this.target=r.target,this.drapedLayerOrder=r.drapedLayerOrder,this.drapedLayerGraphicOrder=r.drapedLayerGraphicOrder,o(this.normal,r.normal),t(this.transformation,r.transformation)}}class B extends A{constructor(){super(...arguments),this.intersector=O.HUD}}function R(t){return new A(t)}const G=c(),M=m();export{w as defaultTolerance,I as newIntersector,R as newIntersectorResult};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{clone as s}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";class t{constructor(s,t,r){this.object=s,this.geometryId=t,this.primIndex=r}}class r extends t{constructor(t,r,e,c){super(t,r,e),this.center=null!=c?s(c):null}}class e extends r{}class c{constructor(s){this.layerViewUid=s}}class i extends c{constructor(s,t){super(s),this.graphicUid=t}}export{i as Graphic3DTarget,r as HudTarget,c as LayerTarget,t as ObjectTarget,e as ValidHudTarget};
5
+ import{clone as s}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";class t{constructor(s,t,e){this.object=s,this.geometryId=t,this.primitiveIndex=e}}class e extends t{constructor(t,e,r,c){super(t,e,r),this.center=null!=c?s(c):null}}class r extends e{}class c{constructor(s){this.layerViewUid=s}}class i extends c{constructor(s,t){super(s),this.graphicUid=t}}export{i as Graphic3DTarget,e as HudTarget,c as LayerTarget,t as ObjectTarget,r as ValidHudTarget};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../../chunks/tslib.es6.js";import t from"../../../../core/Accessor.js";import"../../../../core/has.js";import{nullUid as o}from"../../../../core/uid.js";import{property as r}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/Logger.js";import"../../../../core/RandomLCG.js";import{subclass as s}from"../../../../core/accessorSupport/decorators/subclass.js";import{DirtyOperation as d,DirtyState as i}from"./ModelDirtyTypes.js";import{assert as c}from"./Util.js";class n{constructor(e,t,o,r){this.operation=e,this.geometry=t,this.states=o,this.sync=r}}let a=class extends t{constructor(e){super(e),this._residentGeomRecords=new Map,this._dirtyGeomRecords=new Map,this._dirtyRecordCount=0}get dirty(){return this._dirtyRecordCount>0}commitLayer(e,t){const o=this._dirtyGeomRecords.get(e);if(!o)return;let r=0;o.forEach(((o,s)=>{const n=this._ensureGeomRecord(e,s);r+=o.size,o.forEach((({geometry:e,operation:o,states:r},a)=>{let m=!1;if(o===d.UPDATE){const o=n.get(a);if(o){if(r&i.TRANSFORMATION){const t=this.model.getObject(s);this.model.updateRenderGeometryTransformation(t,e,o)&&(m=!0)}m||t.updates.push({renderGeometry:o,updateType:r})}else c(!1,"ModelDirtySet.commitLayer: invalid update")}if(o===d.REMOVE||m){const e=n.get(a);e?(t.removes.push(e),n.delete(a)):o===d.REMOVE&&c(!1,"ModelDirtySet.commitLayer: invalid remove")}if(o===d.ADD||m){const o=this.model.getObject(s);if(null!=o){const r=this.model.getRenderGeometry(o,e);t.adds.push(r),n.set(a,r)}}})),0===n.size&&this._residentGeomRecords.get(e).delete(s)})),0===this._residentGeomRecords.get(e).size&&this._residentGeomRecords.delete(e),this._dirtyGeomRecords.delete(e),this._dirtyRecordCount-=r}commitSyncUpdates(e,t){const o=this._dirtyGeomRecords.get(e);o&&o.forEach(((o,r)=>{const s=this._ensureGeomRecord(e,r);o.forEach((({geometry:e,operation:o,states:n,sync:a},m)=>{let h=!1;if(o===d.UPDATE&&a){const o=s.get(m);if(o){if(n&i.TRANSFORMATION){const t=this.model.getObject(r);this.model.updateRenderGeometryTransformation(t,e,o)&&(h=!0)}h||t.updates.push({renderGeometry:o,updateType:n})}else c(!1,"ModelDirtySet.commitSyncUpdates: invalid update")}}))}))}getResidentRenderGeometries(e,t){const o=this._residentGeomRecords.get(e);o&&o.forEach((e=>e.forEach((e=>t.push(e)))))}_objectStateChanged(e,t){for(const o of t.geometries)this._updateOrCreateDirtyRecord(t,o,null,d.UPDATE,e)}visibilityChanged(e){this._objectStateChanged(i.VISIBILITY,e)}highlightChanged(e){this._objectStateChanged(i.HIGHLIGHT,e)}occlusionChanged(e){this._objectStateChanged(i.OCCLUDEE,e)}attributesChanged({object:e,geometry:t,sync:o}){this._updateOrCreateDirtyRecord(e,t,null,d.UPDATE,i.GEOMETRY,o)}layerAdded(e){e.objects.forAll((t=>this._layerObjectAdded(e,t)))}layerRemoved(e){e.objects.forAll((t=>this._layerObjectRemoved(e,t)))}layerObjectAdded(e){this._layerObjectAdded(e.layer,e.object)}_layerObjectAdded(e,t){const o=e.id;for(const r of t.geometries)this._geometryAdded(t,r,o)}layerObjectRemoved(e){this._layerObjectRemoved(e.layer,e.object)}layerObjectsAdded(e){for(const t of e.objects)this._layerObjectAdded(e.layer,t)}layerObjectsRemoved(e){for(const t of e.objects)this._layerObjectRemoved(e.layer,t)}_layerObjectRemoved(e,t){const o=e.id;for(const r of t.geometries)this._geometryRemoved(t,r,o)}transformationChanged(e){const t=this._getParentLayerId(e),o=e.id;this._ensureGeomRecord(t,o).forEach((o=>{this._updateOrCreateDirtyRecord(e,o.geometry,t,d.UPDATE,i.TRANSFORMATION)}))}shaderTransformationChanged(e){const t=this._getParentLayerId(e),o=e.id;this._ensureGeomRecord(t,o).forEach((t=>{t.objectShaderTransformationChanged(e.shaderTransformation)}))}geometryAdded(e){this._geometryAdded(e.object,e.geometry)}_geometryAdded(e,t,o=null){this._updateOrCreateDirtyRecord(e,t,o,d.ADD)}geometryRemoved(e){this._geometryRemoved(e.object,e.geometry)}_geometryRemoved(e,t,o=null){this._updateOrCreateDirtyRecord(e,t,o,d.REMOVE)}_updateOrCreateDirtyRecord(e,t,o,r,s=i.NONE,a=!1){o=o??this._getParentLayerId(e);const m=e.id,h=t.id,y=this._ensureDirtyRecord(o,m),l=y.get(h);if(l){const e=l.operation;e===d.REMOVE&&r===d.ADD&&l.states!==i.NONE?l.operation=d.UPDATE:e===d.REMOVE&&r===d.ADD||e===d.ADD&&r===d.REMOVE?(y.delete(h),this._dirtyRecordCount--):e!==d.UPDATE||r!==d.REMOVE&&r!==d.UPDATE?(c((e===d.REMOVE||e===d.ADD)&&r===d.UPDATE,"ModelDirtySet.objectGeometryAdded: inconsistent state"),l.states|=s):(l.operation=r,l.states|=s),l.sync=l.sync||a}else y.set(h,new n(r,t,s,a)),this._dirtyRecordCount++}_ensureGeomRecord(e,t){let o=this._residentGeomRecords.get(e);o||(o=new Map,this._residentGeomRecords.set(e,o));let r=o.get(t);return r||(r=new Map,o.set(t,r)),r}_ensureDirtyRecord(e,t){let o=this._dirtyGeomRecords.get(e);o||(o=new Map,this._dirtyGeomRecords.set(e,o));let r=o.get(t);return r||(r=new Map,o.set(t,r)),r}_getParentLayerId(e){return e.parentLayer?e.parentLayer.id:o}formatDebugInfo(){const e=["ADD","UPD",void 0,"REM"];let t="";return this._dirtyGeomRecords.forEach(((o,r)=>{o.forEach(((o,s)=>{t.length>0&&(t+="\n"),t+=r+"."+s;const d=[];o.forEach((e=>{const t=e.operation;d[t]||(d[t]=[]),d[t].push(e.geometry.id)}));for(let r=0;r<d.length;r++)if(d[r]){t+=" "+e[r-1]+": ";for(let e=0;e<d[r].length;e++)t+=d[r][e]+", "}}))})),t}get test(){}};e([r()],a.prototype,"_dirtyRecordCount",void 0),e([r({constructOnly:!0})],a.prototype,"model",void 0),a=e([s("esri.views.3d.webgl-engine.lib.ModelDirtySet")],a);const m=a;export{m as default};
5
+ import{_ as e}from"../../../../chunks/tslib.es6.js";import t from"../../../../core/Accessor.js";import"../../../../core/has.js";import{NestedMap as o}from"../../../../core/NestedMap.js";import{nullUid as r}from"../../../../core/uid.js";import{property as s}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/Logger.js";import"../../../../core/RandomLCG.js";import{subclass as d}from"../../../../core/accessorSupport/decorators/subclass.js";import{DirtyOperation as i,DirtyState as c}from"./ModelDirtyTypes.js";import{assert as n}from"./Util.js";class a{constructor(e,t,o,r){this.operation=e,this.geometry=t,this.states=o,this.sync=r}}let m=class extends t{constructor(e){super(e),this._residentGeomRecords=new o,this._dirtyGeomRecords=new o,this._dirtyRecordCount=0}get dirty(){return this._dirtyRecordCount>0}commitLayer(e,t){const o=this._dirtyGeomRecords.getInner(e),r=this.model.getObject(e);if(!o||!r)return;let s=0;o.forEach(((o,d)=>{const a=this._ensureGeomRecord(e,d);this._dirtyGeomRecords.delete(e,d),s+=o.size,o.forEach((({geometry:e,operation:o,states:s},m)=>{let y=!1;if(o===i.UPDATE){const o=a.get(m);if(o){if(s&c.TRANSFORMATION){const t=r.getObject(d);this.model.updateRenderGeometryTransformation(t,e,o)&&(y=!0)}y||t.updates.push({renderGeometry:o,updateType:s})}else n(!1,"ModelDirtySet.commitLayer: invalid update")}if(o===i.REMOVE||y){const e=a.get(m);e?(t.removes.push(e),a.delete(m)):o===i.REMOVE&&n(!1,"ModelDirtySet.commitLayer: invalid remove")}if(o===i.ADD||y){const o=r.getObject(d);if(null!=o){const r=this.model.getRenderGeometry(o,e);t.adds.push(r),a.set(m,r)}}})),0===a.size&&this._residentGeomRecords.delete(e,d)})),this._dirtyRecordCount-=s}commitSyncUpdates(e,t){const o=this._dirtyGeomRecords.getInner(e),r=this.model.getObject(e);o&&r&&o.forEach(((o,s)=>{const d=this._ensureGeomRecord(e,s);o.forEach((({geometry:e,operation:o,states:a,sync:m},y)=>{let h=!1;if(o===i.UPDATE&&m){const o=d.get(y);if(o){if(a&c.TRANSFORMATION){const t=r.getObject(s);this.model.updateRenderGeometryTransformation(t,e,o)&&(h=!0)}h||t.updates.push({renderGeometry:o,updateType:a})}else n(!1,"ModelDirtySet.commitSyncUpdates: invalid update")}}))}))}_objectStateChanged(e,t){for(const o of t.geometries)this._updateOrCreateDirtyRecord(t,o,i.UPDATE,e)}visibilityChanged(e){this._objectStateChanged(c.VISIBILITY,e)}highlightChanged(e){this._objectStateChanged(c.HIGHLIGHT,e)}occlusionChanged(e){this._objectStateChanged(c.OCCLUDEE,e)}attributesChanged({object:e,geometry:t,sync:o}){this._updateOrCreateDirtyRecord(e,t,i.UPDATE,c.GEOMETRY,o)}layerAdded(e){e.objects.forEach((e=>this.layerObjectAdded(e)))}layerRemoved(e){e.objects.forEach((e=>this.layerObjectRemoved(e)))}layerObjectAdded(e){for(const t of e.geometries)this._geometryAdded(e,t)}layerObjectRemoved(e){for(const t of e.geometries)this._geometryRemoved(e,t)}layerObjectsAdded(e){for(const t of e)this.layerObjectAdded(t)}layerObjectsRemoved(e){for(const t of e)this.layerObjectRemoved(t)}transformationChanged(e){const t=this._getLayerId(e),o=e.id;this._ensureGeomRecord(t,o).forEach((({geometry:t})=>this._updateOrCreateDirtyRecord(e,t,i.UPDATE,c.TRANSFORMATION)))}shaderTransformationChanged(e){const t=this._getLayerId(e),o=e.id;this._ensureGeomRecord(t,o).forEach((t=>t.objectShaderTransformationChanged(e.shaderTransformation)))}geometryAdded(e){this._geometryAdded(e.object,e.geometry)}_geometryAdded(e,t){this._updateOrCreateDirtyRecord(e,t,i.ADD)}geometryRemoved(e){this._geometryRemoved(e.object,e.geometry)}_geometryRemoved(e,t){this._updateOrCreateDirtyRecord(e,t,i.REMOVE)}_updateOrCreateDirtyRecord(e,t,o,r=c.NONE,s=!1){const d=this._getLayerId(e),m=e.id,y=t.id,h=this._ensureDirtyRecord(d,m),l=h.get(y);if(l){const e=l.operation;e===i.REMOVE&&o===i.ADD&&l.states!==c.NONE?l.operation=i.UPDATE:e===i.REMOVE&&o===i.ADD||e===i.ADD&&o===i.REMOVE?(h.delete(y),this._dirtyRecordCount--):e!==i.UPDATE||o!==i.REMOVE&&o!==i.UPDATE?(n((e===i.REMOVE||e===i.ADD)&&o===i.UPDATE,"ModelDirtySet.objectGeometryAdded: inconsistent state"),l.states|=r):(l.operation=o,l.states|=r),l.sync=l.sync||s}else h.set(y,new a(o,t,r,s)),this._dirtyRecordCount++}_ensureGeomRecord(e,t){let o=this._residentGeomRecords.get(e,t);return o||(o=new Map,this._residentGeomRecords.set(e,t,o)),o}assertLayerClean(e){n(null==this._dirtyGeomRecords.getInner(e),"Dirty geometry records for removed layer")}_ensureDirtyRecord(e,t){const o=this.model.getObject(e);n(null!=o,"Updating geometry record for an unregistered layer");let r=this._dirtyGeomRecords.get(e,t);return r||(r=new Map,this._dirtyGeomRecords.set(e,t,r)),r}_getLayerId(e){return e.layer?.id??r}formatDebugInfo(){const e=["ADD","UPD",void 0,"REM"];let t="";return this._dirtyGeomRecords.forAll(((o,r,s)=>{t.length>0&&(t+="\n"),t+=r+"."+s;const d=[];o.forEach((e=>{const t=e.operation;d[t]||(d[t]=[]),d[t].push(e.geometry.id)}));for(let i=0;i<d.length;i++)if(d[i]){t+=" "+e[i-1]+": ";for(let e=0;e<d[i].length;e++)t+=d[i][e]+", "}})),t}get test(){}};e([s({constructOnly:!0})],m.prototype,"model",void 0),e([s()],m.prototype,"_dirtyRecordCount",void 0),m=e([d("esri.views.3d.webgl-engine.lib.ModelDirtySet")],m);const y=m;export{y as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import"../../../../core/has.js";import{copy as t,multiply as e,hasIdentityRotation as i}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{IDENTITY as s,create as r}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{m as o,t as a,j as n,i as h,g as m,p as c,c as l}from"../../../../chunks/vec32.js";import{fromValues as d,create as g}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{a as u,c as f}from"../../../../chunks/sphere.js";import{maxScale as _}from"../../support/mathUtils.js";import{Object3DState as b}from"./basicInterfaces.js";import{ContentObject as p}from"./ContentObject.js";import{ContentObjectType as v}from"./ContentObjectType.js";import{Object3DOccludeeStateID as j,Object3DHighlightStateID as y}from"./Object3DStateID.js";import{assert as S}from"./Util.js";import{affectsGeometry as x}from"./VertexAttribute.js";import{addObject3DStateID as V,removeObject3DStateID as O}from"../materials/renderers/utils.js";class A extends p{get geometries(){return this._geometries}get transformation(){return this._transformation??s}set transformation(e){this._transformation=t(this._transformation??r(),e),this._invalidateBoundingVolume(),this._emit("transformationChanged",this)}get shaderTransformation(){return this._shaderTransformation}set shaderTransformation(e){this._shaderTransformation=e?t(this._shaderTransformation??r(),e):null,this._invalidateBoundingVolume(),this._emit("shaderTransformationChanged",this)}get effectiveTransformation(){return this.shaderTransformation??this.transformation}constructor(t={}){super(),this.type=v.Object,this._shaderTransformation=null,this._parentLayer=null,this._visible=!0,this._highlightIds=new Set,this.castShadow=t.castShadow??!0,this.usesVerticalDistanceToGround=t.usesVerticalDistanceToGround??!1,this.graphicUid=t.graphicUid,this.layerViewUid=t.layerViewUid,t.isElevationSource&&(this.lastValidElevationBB=new C),this._geometries=t.geometries?Array.from(t.geometries):new Array}dispose(){this._geometries.length=0}get parentLayer(){return this._parentLayer}set parentLayer(t){S(null==this._parentLayer||null==t,"Object3D can only be added to a single Layer"),this._parentLayer=t}addGeometry(t){t.visible=this._visible,this._geometries.push(t);for(const e of this._highlightIds)t.addHighlight(e);this._emit("geometryAdded",{object:this,geometry:t}),this._highlightIds.size&&this._emit("highlightChanged",this),this._invalidateBoundingVolume()}removeGeometry(t){const e=this._geometries.splice(t,1)[0];if(e){for(const t of this._highlightIds)e.removeHighlight(t);this._emit("geometryRemoved",{object:this,geometry:e}),this._highlightIds.size&&this._emit("highlightChanged",this),this._invalidateBoundingVolume()}}removeAllGeometries(){for(;this._geometries.length>0;)this.removeGeometry(0)}geometryVertexAttributeUpdated(t,e,i=!1){this._emit("attributesChanged",{object:this,geometry:t,attribute:e,sync:i}),x(e)&&this._invalidateBoundingVolume()}get visible(){return this._visible}set visible(t){if(this._visible!==t){this._visible=t;for(const t of this._geometries)t.visible=this._visible;this._emit("visibilityChanged",this)}}maskOccludee(){const t=new j;for(const e of this._geometries)e.occludees=V(e.occludees,t);return this._emit("occlusionChanged",this),t}removeOcclude(t){for(const e of this._geometries)e.occludees=O(e.occludees,t);this._emit("occlusionChanged",this)}highlight(t){const e=new y(t);for(const i of this._geometries)i.addHighlight(e);return this._emit("highlightChanged",this),this._highlightIds.add(e),e}removeHighlight(t){this._highlightIds.delete(t);for(const e of this._geometries)e.removeHighlight(t);this._emit("highlightChanged",this)}removeStateID(t){t.channel===b.Highlight?this.removeHighlight(t):this.removeOcclude(t)}getCombinedStaticTransformation(t,i){return e(i,this.transformation,t.transformation)}getCombinedShaderTransformation(t,i=r()){return e(i,this.effectiveTransformation,t.transformation)}get boundingVolumeWorldSpace(){return this._bvWorldSpace||(this._bvWorldSpace=this._bvWorldSpace||new L,this._validateBoundingVolume(this._bvWorldSpace,w.WorldSpace)),this._bvWorldSpace}get boundingVolumeObjectSpace(){return this._bvObjectSpace||(this._bvObjectSpace=this._bvObjectSpace||new L,this._validateBoundingVolume(this._bvObjectSpace,w.ObjectSpace)),this._bvObjectSpace}_validateBoundingVolume(t,e){const i=e===w.ObjectSpace;for(const s of this._geometries){const e=s.boundingInfo;e&&M(e,t,i?s.transformation:this.getCombinedShaderTransformation(s))}o(u(t.bounds),t.min,t.max,.5);for(const s of this._geometries){const e=s.boundingInfo;if(null==e)continue;const r=i?s.transformation:this.getCombinedShaderTransformation(s),o=_(r);a(I,e.center,r);const h=n(I,u(t.bounds)),m=e.radius*o;t.bounds[3]=Math.max(t.bounds[3],h+m)}}_invalidateBoundingVolume(){const t=this._bvWorldSpace?.bounds;this._bvObjectSpace=this._bvWorldSpace=void 0,this._parentLayer&&t&&this._parentLayer.notifyObjectBBChanged(this,t)}_emit(t,e){this._parentLayer&&this._parentLayer.events.emit(t,e)}get test(){}}class C{constructor(){this.min=d(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),this.max=d(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE)}isEmpty(){return this.max[0]<this.min[0]&&this.max[1]<this.min[1]&&this.max[2]<this.min[2]}}class L extends C{constructor(){super(...arguments),this.bounds=f()}}function M(t,e,s){const r=t.bbMin,o=t.bbMax;if(i(s)){const t=h(T,s[12],s[13],s[14]);m(B,r,t),m(U,o,t);for(let i=0;i<3;++i)e.min[i]=Math.min(e.min[i],B[i]),e.max[i]=Math.max(e.max[i],U[i])}else if(a(B,r,s),c(r,o))for(let i=0;i<3;++i)e.min[i]=Math.min(e.min[i],B[i]),e.max[i]=Math.max(e.max[i],B[i]);else{a(U,o,s);for(let t=0;t<3;++t)e.min[t]=Math.min(e.min[t],B[t],U[t]),e.max[t]=Math.max(e.max[t],B[t],U[t]);for(let t=0;t<3;++t){l(B,r),l(U,o),B[t]=o[t],U[t]=r[t],a(B,B,s),a(U,U,s);for(let t=0;t<3;++t)e.min[t]=Math.min(e.min[t],B[t],U[t]),e.max[t]=Math.max(e.max[t],B[t],U[t])}}}const T=g(),B=g(),U=g(),I=g();var w;function W(t){return t?.type===v.Object}!function(t){t[t.WorldSpace=0]="WorldSpace",t[t.ObjectSpace=1]="ObjectSpace"}(w||(w={}));export{L as BoundingVolume,A as Object3D,W as isObject3D};
5
+ import"../../../../core/has.js";import{generateUID as t}from"../../../../core/uid.js";import{multiply as i,copy as e,hasIdentityRotation as s}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as o,IDENTITY as r}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{m as a,t as n,j as h,i as m,g as l,p as c,c as d}from"../../../../chunks/vec32.js";import{fromValues as g,create as u}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{a as f,c as _}from"../../../../chunks/sphere.js";import{maxScale as b}from"../../support/mathUtils.js";import{Object3DState as v}from"./basicInterfaces.js";import{Object3DOccludeeStateID as p,Object3DHighlightStateID as S}from"./Object3DStateID.js";import{assert as j}from"./Util.js";import{affectsGeometry as y}from"./VertexAttribute.js";import{addObject3DStateID as x,removeObject3DStateID as V}from"../materials/renderers/utils.js";class A{constructor(i={}){this.id=t(),this._highlightIds=new Set,this._shaderTransformation=null,this._visible=!0,this.castShadow=i.castShadow??!0,this.usesVerticalDistanceToGround=i.usesVerticalDistanceToGround??!1,this.graphicUid=i.graphicUid,this.layerViewUid=i.layerViewUid,i.isElevationSource&&(this.lastValidElevationBB=new M),this._geometries=i.geometries?Array.from(i.geometries):new Array}dispose(){this._geometries.length=0}get layer(){return this._layer}set layer(t){j(null==this._layer||null==t,"Object3D can only be added to a single Layer"),this._layer=t}addGeometry(t){t.visible=this._visible,this._geometries.push(t);for(const i of this._highlightIds)t.addHighlight(i);this._emit("geometryAdded",{object:this,geometry:t}),this._highlightIds.size&&this._emit("highlightChanged",this),this._invalidateBoundingVolume()}removeGeometry(t){const i=this._geometries.splice(t,1)[0];if(i){for(const t of this._highlightIds)i.removeHighlight(t);this._emit("geometryRemoved",{object:this,geometry:i}),this._highlightIds.size&&this._emit("highlightChanged",this),this._invalidateBoundingVolume()}}removeAllGeometries(){for(;this._geometries.length>0;)this.removeGeometry(0)}geometryVertexAttributeUpdated(t,i,e=!1){this._emit("attributesChanged",{object:this,geometry:t,attribute:i,sync:e}),y(i)&&this._invalidateBoundingVolume()}get visible(){return this._visible}set visible(t){if(this._visible!==t){this._visible=t;for(const t of this._geometries)t.visible=this._visible;this._emit("visibilityChanged",this)}}maskOccludee(){const t=new p;for(const i of this._geometries)i.occludees=x(i.occludees,t);return this._emit("occlusionChanged",this),t}removeOcclude(t){for(const i of this._geometries)i.occludees=V(i.occludees,t);this._emit("occlusionChanged",this)}highlight(t){const i=new S(t);for(const e of this._geometries)e.addHighlight(i);return this._emit("highlightChanged",this),this._highlightIds.add(i),i}removeHighlight(t){this._highlightIds.delete(t);for(const i of this._geometries)i.removeHighlight(t);this._emit("highlightChanged",this)}removeStateID(t){t.channel===v.Highlight?this.removeHighlight(t):this.removeOcclude(t)}getCombinedStaticTransformation(t,e){return i(e,this.transformation,t.transformation)}getCombinedShaderTransformation(t,e=o()){return i(e,this.effectiveTransformation,t.transformation)}get boundingVolumeWorldSpace(){return this._bvWorldSpace||(this._bvWorldSpace=this._bvWorldSpace||new O,this._validateBoundingVolume(this._bvWorldSpace,w.WorldSpace)),this._bvWorldSpace}get boundingVolumeObjectSpace(){return this._bvObjectSpace||(this._bvObjectSpace=this._bvObjectSpace||new O,this._validateBoundingVolume(this._bvObjectSpace,w.ObjectSpace)),this._bvObjectSpace}_validateBoundingVolume(t,i){const e=i===w.ObjectSpace;for(const s of this._geometries){const i=s.boundingInfo;i&&T(i,t,e?s.transformation:this.getCombinedShaderTransformation(s))}a(f(t.bounds),t.min,t.max,.5);for(const s of this._geometries){const i=s.boundingInfo;if(null==i)continue;const o=e?s.transformation:this.getCombinedShaderTransformation(s),r=b(o);n(I,i.center,o);const a=h(I,f(t.bounds)),m=i.radius*r;t.bounds[3]=Math.max(t.bounds[3],a+m)}}_invalidateBoundingVolume(){const t=this._bvWorldSpace?.bounds;this._bvObjectSpace=this._bvWorldSpace=void 0,this.layer&&t&&this.layer.notifyObjectBBChanged(this,t)}_emit(t,i){this.layer?.events.emit(t,i)}get geometries(){return this._geometries}get transformation(){return this._transformation??r}set transformation(t){this._transformation=e(this._transformation??o(),t),this._invalidateBoundingVolume(),this._emit("transformationChanged",this)}get shaderTransformation(){return this._shaderTransformation}set shaderTransformation(t){this._shaderTransformation=t?e(this._shaderTransformation??o(),t):null,this._invalidateBoundingVolume(),this._emit("shaderTransformationChanged",this)}get effectiveTransformation(){return this.shaderTransformation??this.transformation}get test(){}}class M{constructor(){this.min=g(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),this.max=g(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE)}isEmpty(){return this.max[0]<this.min[0]&&this.max[1]<this.min[1]&&this.max[2]<this.min[2]}}class O extends M{constructor(){super(...arguments),this.bounds=_()}}function T(t,i,e){const o=t.bbMin,r=t.bbMax;if(s(e)){const t=m(C,e[12],e[13],e[14]);l(B,o,t),l(U,r,t);for(let e=0;e<3;++e)i.min[e]=Math.min(i.min[e],B[e]),i.max[e]=Math.max(i.max[e],U[e])}else if(n(B,o,e),c(o,r))for(let s=0;s<3;++s)i.min[s]=Math.min(i.min[s],B[s]),i.max[s]=Math.max(i.max[s],B[s]);else{n(U,r,e);for(let t=0;t<3;++t)i.min[t]=Math.min(i.min[t],B[t],U[t]),i.max[t]=Math.max(i.max[t],B[t],U[t]);for(let t=0;t<3;++t){d(B,o),d(U,r),B[t]=r[t],U[t]=o[t],n(B,B,e),n(U,U,e);for(let t=0;t<3;++t)i.min[t]=Math.min(i.min[t],B[t],U[t]),i.max[t]=Math.max(i.max[t],B[t],U[t])}}}const C=u(),B=u(),U=u(),I=u();var w;!function(t){t[t.WorldSpace=0]="WorldSpace",t[t.ObjectSpace=1]="ObjectSpace"}(w||(w={}));export{O as BoundingVolume,A as Object3D};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import t from"../../../../core/ObjectPool.js";import e from"../../../../core/PooledArray.js";import{c as n,m as o,h as i,g as s,s as r}from"../../../../chunks/vec32.js";import{fromValues as h,create as a}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{intersectsSphere as l}from"../../../../geometry/support/frustum.js";import{wrap as d}from"../../../../geometry/support/ray.js";import{c as u,e as c,g as f,i as m,a as _}from"../../../../chunks/sphere.js";import{rayBoxTest as p}from"./Util.js";class b{get bounds(){return this._root.bounds}get halfSize(){return this._root.halfSize}get root(){return this._root.node}get maximumObjectsPerNode(){return this._maximumObjectsPerNode}get maximumDepth(){return this._maximumDepth}get objectCount(){return this._objectCount}constructor(t,e){this.objectToBoundingSphere=t,this._maximumObjectsPerNode=10,this._maximumDepth=20,this._degenerateObjects=new Set,this._root=new g,this._objectCount=0,e&&(void 0!==e.maximumObjectsPerNode&&(this._maximumObjectsPerNode=e.maximumObjectsPerNode),void 0!==e.maximumDepth&&(this._maximumDepth=e.maximumDepth))}destroy(){this._degenerateObjects.clear(),g.clearPool(),q[0]=null,K.prune(),Q.prune()}add(t,e=t.length){this._objectCount+=e,this._grow(t,e);const n=g.acquire();for(let o=0;o<e;o++){const e=t[o];this._isDegenerate(e)?this._degenerateObjects.add(e):(n.init(this._root),this._add(e,n))}g.release(n)}remove(t,e=null){this._objectCount-=t.length;const n=g.acquire();for(const o of t){const t=e??c(this.objectToBoundingSphere(o),J);C(t[3])?(n.init(this._root),O(o,t,n)):this._degenerateObjects.delete(o)}g.release(n),this._shrink()}update(t,e){if(!C(e[3])&&this._isDegenerate(t))return;const n=y(t);this.remove(n,e),this.add(n)}forEachAlongRay(t,e,n){const o=d(t,e);S(this._root,(t=>{if(!T(o,t))return!1;const e=t.node;return e.terminals.forAll((t=>{this._intersectsObject(o,t)&&n(t)})),null!==e.residents&&e.residents.forAll((t=>{this._intersectsObject(o,t)&&n(t)})),!0}))}forEachAlongRayWithVerticalOffset(t,e,n,o){const i=d(t,e);S(this._root,(t=>{if(!z(i,t,o))return!1;const e=t.node;return e.terminals.forAll((t=>{this._intersectsObjectWithOffset(i,t,o)&&n(t)})),null!==e.residents&&e.residents.forAll((t=>{this._intersectsObjectWithOffset(i,t,o)&&n(t)})),!0}))}forEach(t){S(this._root,(e=>{const n=e.node;return n.terminals.forAll(t),null!==n.residents&&n.residents.forAll(t),!0})),this._degenerateObjects.forEach(t)}forEachDegenerateObject(t){this._degenerateObjects.forEach(t)}findClosest(t,e,n,o=()=>!0,r=1/0){let h=1/0,a=1/0,d=null;const u=F(t,e),c=i=>{if(--r,!o(i))return;const s=this.objectToBoundingSphere(i);if(!l(n,s))return;const u=v(t,e,_(s)),c=u-s[3],f=u+s[3];c<h&&(h=c,a=f,d=i)};return j(this._root,(o=>{if(r<=0||!l(n,o.bounds))return!1;i(I,u,o.halfSize),s(I,I,_(o.bounds));if(v(t,e,I)>a)return!1;const h=o.node;return h.terminals.forAll((t=>c(t))),null!==h.residents&&h.residents.forAll((t=>c(t))),!0}),t,e),d}forEachInDepthRange(t,e,n,o,r,h,a){let d=-1/0,u=1/0;const c={setRange:t=>{n===b.DepthOrder.FRONT_TO_BACK?(d=Math.max(d,t.near),u=Math.min(u,t.far)):(d=Math.max(d,-t.far),u=Math.min(u,-t.near))}};c.setRange(o);const f=v(e,n,t),m=F(e,n),p=F(e,-n),g=t=>{if(!a(t))return;const o=this.objectToBoundingSphere(t),i=_(o),s=v(e,n,i)-f,m=s-o[3],p=s+o[3];m>u||p<d||!l(h,o)||r(t,c)};j(this._root,(t=>{if(!l(h,t.bounds))return!1;i(I,m,t.halfSize),s(I,I,_(t.bounds));if(v(e,n,I)-f>u)return!1;i(I,p,t.halfSize),s(I,I,_(t.bounds));if(v(e,n,I)-f<d)return!1;const o=t.node;return o.terminals.forAll((t=>g(t))),null!==o.residents&&o.residents.forAll((t=>g(t))),!0}),e,n)}forEachNode(t){S(this._root,(e=>t(e.node,e.bounds,e.halfSize,e.depth)))}forEachNeighbor(t,e){const n=f(e),o=_(e),i=e=>{const i=this.objectToBoundingSphere(e),s=f(i),h=n+s;return!(r(_(i),o)-h*h<=0)||t(e)};let s=!0;const h=t=>{s&&(s=i(t))};S(this._root,(t=>{const e=f(t.bounds),i=n+e;if(r(_(t.bounds),o)-i*i>0)return!1;const a=t.node;return a.terminals.forAll(h),s&&null!==a.residents&&a.residents.forAll(h),s})),s&&this.forEachDegenerateObject(h)}_intersectsObject(t,e){const n=this.objectToBoundingSphere(e);return!(n[3]>0)||m(n,t)}_intersectsObjectWithOffset(t,e,n){const o=this.objectToBoundingSphere(e);return!(o[3]>0)||m(n.applyToBoundingSphere(o),t)}_add(t,e){e.advanceTo(this.objectToBoundingSphere(t))?e.node.terminals.push(t):(e.node.residents.push(t),e.node.residents.length>this._maximumObjectsPerNode&&e.depth<this._maximumDepth&&this._split(e))}_split(t){const e=t.node.residents;t.node.residents=null;for(let n=0;n<e.length;n++){const o=g.acquire().init(t);this._add(e.at(n),o),g.release(o)}}_grow(t,e){if(0!==e&&(D(t,e,(t=>this.objectToBoundingSphere(t)),W),C(W[3])&&!this._fitsInsideTree(W)))if(N(this._root.node))c(W,this._root.bounds),this._root.halfSize=1.25*this._root.bounds[3],this._root.updateBoundsRadiusFromHalfSize();else{const t=this._rootBoundsForRootAsSubNode(W);this._placingRootViolatesMaxDepth(t)?this._rebuildTree(W,t):this._growRootAsSubNode(t),g.release(t)}}_rebuildTree(t,e){n(_(V),_(e.bounds)),V[3]=e.halfSize,D([t,V],2,(t=>t),G);const o=g.acquire().init(this._root);this._root.initFrom(null,G,G[3]),this._root.increaseHalfSize(1.25),S(o,(t=>(this.add(t.node.terminals.data,t.node.terminals.length),null!==t.node.residents&&this.add(t.node.residents.data,t.node.residents.length),!0))),g.release(o)}_placingRootViolatesMaxDepth(t){const e=Math.log(t.halfSize/this._root.halfSize)*Math.LOG2E;let n=0;return S(this._root,(t=>(n=Math.max(n,t.depth),n+e<=this._maximumDepth))),n+e>this._maximumDepth}_rootBoundsForRootAsSubNode(t){const e=t[3],n=t;let o=-1/0;const i=this._root.bounds,s=this._root.halfSize;for(let h=0;h<3;h++){const t=i[h]-s-(n[h]-e),r=n[h]+e-(i[h]+s),a=Math.max(0,Math.ceil(t/(2*s))),l=Math.max(0,Math.ceil(r/(2*s)))+1,d=2**Math.ceil(Math.log(a+l)*Math.LOG2E);o=Math.max(o,d),U[h].min=a,U[h].max=l}for(let h=0;h<3;h++){let t=U[h].min,e=U[h].max;const n=(o-(t+e))/2;t+=Math.ceil(n),e+=Math.floor(n);const r=i[h]-s-t*s*2;k[h]=r+(e+t)*s}const r=o*s;return k[3]=r*w,g.acquire().initFrom(null,k,r,0)}_growRootAsSubNode(t){const e=this._root.node;n(_(W),_(this._root.bounds)),W[3]=this._root.halfSize,this._root.init(t),t.advanceTo(W,null,!0),t.node.children=e.children,t.node.residents=e.residents,t.node.terminals=e.terminals}_shrink(){for(;;){const t=this._findShrinkIndex();if(-1===t)break;this._root.advance(t),this._root.depth=0}}_findShrinkIndex(){if(0!==this._root.node.terminals.length||this._root.isLeaf())return-1;let t=null;const e=this._root.node.children;let n=0,o=0;for(;o<e.length&&null==t;)n=o++,t=e[n];for(;o<e.length;)if(e[o++])return-1;return n}_isDegenerate(t){return!C(this.objectToBoundingSphere(t)[3])}_fitsInsideTree(t){const e=this._root.bounds,n=this._root.halfSize;return t[3]<=n&&t[0]>=e[0]-n&&t[0]<=e[0]+n&&t[1]>=e[1]-n&&t[1]<=e[1]+n&&t[2]>=e[2]-n&&t[2]<=e[2]+n}toJSON(){const{maximumDepth:t,maximumObjectsPerNode:e,_objectCount:n}=this,o=this._nodeToJSON(this._root.node);return{maximumDepth:t,maximumObjectsPerNode:e,objectCount:n,root:{bounds:this._root.bounds,halfSize:this._root.halfSize,depth:this._root.depth,node:o}}}_nodeToJSON(t){const e=t.children.map((t=>t?this._nodeToJSON(t):null)),n=t.residents?.map((t=>this.objectToBoundingSphere(t))),o=t.terminals?.map((t=>this.objectToBoundingSphere(t)));return{children:e,residents:n,terminals:o}}static fromJSON(t){const e=new b((t=>t),{maximumDepth:t.maximumDepth,maximumObjectsPerNode:t.maximumObjectsPerNode});return e._objectCount=t.objectCount,e._root.initFrom(t.root.node,t.root.bounds,t.root.halfSize,t.root.depth),e}}class g{constructor(){this.bounds=u(),this.halfSize=0,this.initFrom(null,null,0,0)}init(t){return this.initFrom(t.node,t.bounds,t.halfSize,t.depth)}initFrom(t,e,n,o=this.depth){return this.node=null!=t?t:g.createEmptyNode(),e&&c(e,this.bounds),this.halfSize=n,this.depth=o,this}increaseHalfSize(t){this.halfSize*=t,this.updateBoundsRadiusFromHalfSize()}updateBoundsRadiusFromHalfSize(){this.bounds[3]=this.halfSize*w}advance(t){let e=this.node.children[t];e||(e=g.createEmptyNode(),this.node.children[t]=e),this.node=e,this.halfSize/=2,this.depth++;const n=E[t];return this.bounds[0]+=n[0]*this.halfSize,this.bounds[1]+=n[1]*this.halfSize,this.bounds[2]+=n[2]*this.halfSize,this.updateBoundsRadiusFromHalfSize(),this}advanceTo(t,e,n=!1){for(;;){if(this.isTerminalFor(t))return e&&e(this,-1),!0;if(this.isLeaf()){if(!n)return e&&e(this,-1),!1;this.node.residents=null}const o=this._childIndex(t);e&&e(this,o),this.advance(o)}}isLeaf(){return null!=this.node.residents}isTerminalFor(t){return t[3]>this.halfSize/2}_childIndex(t){const e=this.bounds;return(e[0]<t[0]?1:0)+(e[1]<t[1]?2:0)+(e[2]<t[2]?4:0)}static createEmptyNode(){return{children:[null,null,null,null,null,null,null,null],terminals:new e({shrink:!0}),residents:new e({shrink:!0})}}static{this._pool=new t(g)}static acquire(){return g._pool.acquire()}static release(t){g._pool.release(t)}static clearPool(){g._pool.prune()}}function S(t,e){let n=g.acquire().init(t);const o=[n];for(;0!==o.length;){if(n=o.pop(),e(n)&&!n.isLeaf())for(let t=0;t<n.node.children.length;t++){n.node.children[t]&&o.push(g.acquire().init(n).advance(t))}g.release(n)}}function j(t,e,n,o=b.DepthOrder.FRONT_TO_BACK){let i=g.acquire().init(t);const s=[i];for(R(n,o,X);0!==s.length;){if(i=s.pop(),e(i)&&!i.isLeaf())for(let t=7;t>=0;--t){const e=X[t];i.node.children[e]&&s.push(g.acquire().init(i).advance(e))}g.release(i)}}function O(t,e,n){K.clear();const o=n.advanceTo(e,((t,e)=>{K.push(t.node),K.push(e)}))?n.node.terminals:n.node.residents;if(o.removeUnordered(t),0===o.length)for(let i=K.length-2;i>=0;i-=2){if(!x(K.data[i],K.data[i+1]))break}}function x(t,n){return n>=0&&(t.children[n]=null),!!N(t)&&(null===t.residents&&(t.residents=new e({shrink:!0})),!0)}function T(t,e){return B(_(e.bounds),2*-e.halfSize,L),B(_(e.bounds),2*e.halfSize,H),p(t.origin,t.direction,L,H)}function z(t,e,n){return B(_(e.bounds),2*-e.halfSize,L),B(_(e.bounds),2*e.halfSize,H),n.applyToMinMax(L,H),p(t.origin,t.direction,L,H)}function N(t){if(0!==t.terminals.length)return!1;if(null!==t.residents)return 0===t.residents.length;for(let e=0;e<t.children.length;e++)if(t.children[e])return!1;return!0}function M(t,e){t[0]=Math.min(t[0],e[0]-e[3]),t[1]=Math.min(t[1],e[1]-e[3]),t[2]=Math.min(t[2],e[2]-e[3])}function A(t,e){t[0]=Math.max(t[0],e[0]+e[3]),t[1]=Math.max(t[1],e[1]+e[3]),t[2]=Math.max(t[2],e[2]+e[3])}function B(t,e,n){n[0]=t[0]+e,n[1]=t[1]+e,n[2]=t[2]+e}function D(t,e,n,i){if(1===e){const e=n(t[0]);c(e,i)}else{L[0]=1/0,L[1]=1/0,L[2]=1/0,H[0]=-1/0,H[1]=-1/0,H[2]=-1/0;for(let o=0;o<e;o++){const e=n(t[o]);C(e[3])&&(M(L,e),A(H,e))}o(_(i),L,H,.5),i[3]=Math.max(H[0]-L[0],H[1]-L[1],H[2]-L[2])/2}}function R(t,e,n){if(!Q.length)for(let o=0;o<8;++o)Q.push({index:0,distance:0});for(let o=0;o<8;++o){const n=E[o];Q.data[o].index=o,Q.data[o].distance=v(t,e,n)}Q.sort(((t,e)=>t.distance-e.distance));for(let o=0;o<8;++o)n[o]=Q.data[o].index}function F(t,e){let n,o=1/0;for(let i=0;i<8;++i){const s=v(t,e,P[i]);s<o&&(o=s,n=P[i])}return n}function v(t,e,n){return e*(t[0]*n[0]+t[1]*n[1]+t[2]*n[2])}function C(t){return!isNaN(t)&&t!==-1/0&&t!==1/0&&t>0}!function(t){var e;(e=t.DepthOrder||(t.DepthOrder={}))[e.FRONT_TO_BACK=1]="FRONT_TO_BACK",e[e.BACK_TO_FRONT=-1]="BACK_TO_FRONT"}(b);const E=[h(-1,-1,-1),h(1,-1,-1),h(-1,1,-1),h(1,1,-1),h(-1,-1,1),h(1,-1,1),h(-1,1,1),h(1,1,1)],P=[h(-1,-1,-1),h(-1,-1,1),h(-1,1,-1),h(-1,1,1),h(1,-1,-1),h(1,-1,1),h(1,1,-1),h(1,1,1)],w=Math.sqrt(3),q=[null];function y(t){return q[0]=t,q}const k=u(),I=a(),L=a(),H=a(),K=new e,J=u(),W=u(),V=u(),G=u(),U=[{min:0,max:0},{min:0,max:0},{min:0,max:0}],Q=new e,X=[0,0,0,0,0,0,0,0];export{b as default};
5
+ import t from"../../../../core/ObjectPool.js";import e from"../../../../core/PooledArray.js";import{c as n,m as o,h as i,g as r,s}from"../../../../chunks/vec32.js";import{fromValues as h,create as a}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{intersectsSphere as l}from"../../../../geometry/support/frustum.js";import{wrap as d}from"../../../../geometry/support/ray.js";import{c as u,e as c,g as f,i as m,a as _}from"../../../../chunks/sphere.js";import{rayBoxTest as p}from"./Util.js";class b{get bounds(){return this._root.bounds}get halfSize(){return this._root.halfSize}get root(){return this._root.node}get maximumObjectsPerNode(){return this._maximumObjectsPerNode}get maximumDepth(){return this._maximumDepth}get objectCount(){return this._objectCount}constructor(t,e){this.objectToBoundingSphere=t,this._maximumObjectsPerNode=10,this._maximumDepth=20,this._degenerateObjects=new Set,this._root=new g,this._objectCount=0,e&&(void 0!==e.maximumObjectsPerNode&&(this._maximumObjectsPerNode=e.maximumObjectsPerNode),void 0!==e.maximumDepth&&(this._maximumDepth=e.maximumDepth))}destroy(){this._degenerateObjects.clear(),g.clearPool(),y[0]=null,K.prune(),Q.prune()}add(t){const e=Array.from(t);this._grow(e);const n=g.acquire();for(const o of e)++this._objectCount,this._isDegenerate(o)?this._degenerateObjects.add(o):(n.init(this._root),this._add(o,n));g.release(n)}remove(t,e=null){this._objectCount-=t.length;const n=g.acquire();for(const o of t){const t=e??c(this.objectToBoundingSphere(o),J);C(t[3])?(n.init(this._root),O(o,t,n)):this._degenerateObjects.delete(o)}g.release(n),this._shrink()}update(t,e){if(!C(e[3])&&this._isDegenerate(t))return;const n=q(t);this.remove(n,e),this.add(n)}forEachAlongRay(t,e,n){const o=d(t,e);S(this._root,(t=>{if(!T(o,t))return!1;const e=t.node;return e.terminals.forAll((t=>{this._intersectsObject(o,t)&&n(t)})),null!==e.residents&&e.residents.forAll((t=>{this._intersectsObject(o,t)&&n(t)})),!0}))}forEachAlongRayWithVerticalOffset(t,e,n,o){const i=d(t,e);S(this._root,(t=>{if(!z(i,t,o))return!1;const e=t.node;return e.terminals.forAll((t=>{this._intersectsObjectWithOffset(i,t,o)&&n(t)})),null!==e.residents&&e.residents.forAll((t=>{this._intersectsObjectWithOffset(i,t,o)&&n(t)})),!0}))}forEach(t){S(this._root,(e=>{const n=e.node;return n.terminals.forAll(t),null!==n.residents&&n.residents.forAll(t),!0})),this._degenerateObjects.forEach(t)}forEachDegenerateObject(t){this._degenerateObjects.forEach(t)}findClosest(t,e,n,o=()=>!0,s=1/0){let h=1/0,a=1/0,d=null;const u=F(t,e),c=i=>{if(--s,!o(i))return;const r=this.objectToBoundingSphere(i);if(!l(n,r))return;const u=v(t,e,_(r)),c=u-r[3],f=u+r[3];c<h&&(h=c,a=f,d=i)};return j(this._root,(o=>{if(s<=0||!l(n,o.bounds))return!1;i(I,u,o.halfSize),r(I,I,_(o.bounds));if(v(t,e,I)>a)return!1;const h=o.node;return h.terminals.forAll((t=>c(t))),null!==h.residents&&h.residents.forAll((t=>c(t))),!0}),t,e),d}forEachInDepthRange(t,e,n,o,s,h,a){let d=-1/0,u=1/0;const c={setRange:t=>{n===b.DepthOrder.FRONT_TO_BACK?(d=Math.max(d,t.near),u=Math.min(u,t.far)):(d=Math.max(d,-t.far),u=Math.min(u,-t.near))}};c.setRange(o);const f=v(e,n,t),m=F(e,n),p=F(e,-n),g=t=>{if(!a(t))return;const o=this.objectToBoundingSphere(t),i=_(o),r=v(e,n,i)-f,m=r-o[3],p=r+o[3];m>u||p<d||!l(h,o)||s(t,c)};j(this._root,(t=>{if(!l(h,t.bounds))return!1;i(I,m,t.halfSize),r(I,I,_(t.bounds));if(v(e,n,I)-f>u)return!1;i(I,p,t.halfSize),r(I,I,_(t.bounds));if(v(e,n,I)-f<d)return!1;const o=t.node;return o.terminals.forAll((t=>g(t))),null!==o.residents&&o.residents.forAll((t=>g(t))),!0}),e,n)}forEachNode(t){S(this._root,(e=>t(e.node,e.bounds,e.halfSize,e.depth)))}forEachNeighbor(t,e){const n=f(e),o=_(e),i=e=>{const i=this.objectToBoundingSphere(e),r=f(i),h=n+r;return!(s(_(i),o)-h*h<=0)||t(e)};let r=!0;const h=t=>{r&&(r=i(t))};S(this._root,(t=>{const e=f(t.bounds),i=n+e;if(s(_(t.bounds),o)-i*i>0)return!1;const a=t.node;return a.terminals.forAll(h),r&&null!==a.residents&&a.residents.forAll(h),r})),r&&this.forEachDegenerateObject(h)}_intersectsObject(t,e){const n=this.objectToBoundingSphere(e);return!(n[3]>0)||m(n,t)}_intersectsObjectWithOffset(t,e,n){const o=this.objectToBoundingSphere(e);return!(o[3]>0)||m(n.applyToBoundingSphere(o),t)}_add(t,e){e.advanceTo(this.objectToBoundingSphere(t))?e.node.terminals.push(t):(e.node.residents.push(t),e.node.residents.length>this._maximumObjectsPerNode&&e.depth<this._maximumDepth&&this._split(e))}_split(t){const e=t.node.residents;t.node.residents=null;for(let n=0;n<e.length;n++){const o=g.acquire().init(t);this._add(e.at(n),o),g.release(o)}}_grow(t){if(D(t,(t=>this.objectToBoundingSphere(t)),W),C(W[3])&&!this._fitsInsideTree(W))if(N(this._root.node))c(W,this._root.bounds),this._root.halfSize=1.25*this._root.bounds[3],this._root.updateBoundsRadiusFromHalfSize();else{const t=this._rootBoundsForRootAsSubNode(W);this._placingRootViolatesMaxDepth(t)?this._rebuildTree(W,t):this._growRootAsSubNode(t),g.release(t)}}_rebuildTree(t,e){n(_(V),_(e.bounds)),V[3]=e.halfSize,D([t,V],(t=>t),G);const o=g.acquire().init(this._root);this._root.initFrom(null,G,G[3]),this._root.increaseHalfSize(1.25),S(o,(t=>(this.add(t.node.terminals.data),null!==t.node.residents&&this.add(t.node.residents.data),!0))),g.release(o)}_placingRootViolatesMaxDepth(t){const e=Math.log(t.halfSize/this._root.halfSize)*Math.LOG2E;let n=0;return S(this._root,(t=>(n=Math.max(n,t.depth),n+e<=this._maximumDepth))),n+e>this._maximumDepth}_rootBoundsForRootAsSubNode(t){const e=t[3],n=t;let o=-1/0;const i=this._root.bounds,r=this._root.halfSize;for(let h=0;h<3;h++){const t=i[h]-r-(n[h]-e),s=n[h]+e-(i[h]+r),a=Math.max(0,Math.ceil(t/(2*r))),l=Math.max(0,Math.ceil(s/(2*r)))+1,d=2**Math.ceil(Math.log(a+l)*Math.LOG2E);o=Math.max(o,d),U[h].min=a,U[h].max=l}for(let h=0;h<3;h++){let t=U[h].min,e=U[h].max;const n=(o-(t+e))/2;t+=Math.ceil(n),e+=Math.floor(n);const s=i[h]-r-t*r*2;k[h]=s+(e+t)*r}const s=o*r;return k[3]=s*w,g.acquire().initFrom(null,k,s,0)}_growRootAsSubNode(t){const e=this._root.node;n(_(W),_(this._root.bounds)),W[3]=this._root.halfSize,this._root.init(t),t.advanceTo(W,null,!0),t.node.children=e.children,t.node.residents=e.residents,t.node.terminals=e.terminals}_shrink(){for(;;){const t=this._findShrinkIndex();if(-1===t)break;this._root.advance(t),this._root.depth=0}}_findShrinkIndex(){if(0!==this._root.node.terminals.length||this._root.isLeaf())return-1;let t=null;const e=this._root.node.children;let n=0,o=0;for(;o<e.length&&null==t;)n=o++,t=e[n];for(;o<e.length;)if(e[o++])return-1;return n}_isDegenerate(t){return!C(this.objectToBoundingSphere(t)[3])}_fitsInsideTree(t){const e=this._root.bounds,n=this._root.halfSize;return t[3]<=n&&t[0]>=e[0]-n&&t[0]<=e[0]+n&&t[1]>=e[1]-n&&t[1]<=e[1]+n&&t[2]>=e[2]-n&&t[2]<=e[2]+n}toJSON(){const{maximumDepth:t,maximumObjectsPerNode:e,_objectCount:n}=this,o=this._nodeToJSON(this._root.node);return{maximumDepth:t,maximumObjectsPerNode:e,objectCount:n,root:{bounds:this._root.bounds,halfSize:this._root.halfSize,depth:this._root.depth,node:o}}}_nodeToJSON(t){const e=t.children.map((t=>t?this._nodeToJSON(t):null)),n=t.residents?.map((t=>this.objectToBoundingSphere(t))),o=t.terminals?.map((t=>this.objectToBoundingSphere(t)));return{children:e,residents:n,terminals:o}}static fromJSON(t){const e=new b((t=>t),{maximumDepth:t.maximumDepth,maximumObjectsPerNode:t.maximumObjectsPerNode});return e._objectCount=t.objectCount,e._root.initFrom(t.root.node,t.root.bounds,t.root.halfSize,t.root.depth),e}}class g{constructor(){this.bounds=u(),this.halfSize=0,this.initFrom(null,null,0,0)}init(t){return this.initFrom(t.node,t.bounds,t.halfSize,t.depth)}initFrom(t,e,n,o=this.depth){return this.node=null!=t?t:g.createEmptyNode(),e&&c(e,this.bounds),this.halfSize=n,this.depth=o,this}increaseHalfSize(t){this.halfSize*=t,this.updateBoundsRadiusFromHalfSize()}updateBoundsRadiusFromHalfSize(){this.bounds[3]=this.halfSize*w}advance(t){let e=this.node.children[t];e||(e=g.createEmptyNode(),this.node.children[t]=e),this.node=e,this.halfSize/=2,this.depth++;const n=E[t];return this.bounds[0]+=n[0]*this.halfSize,this.bounds[1]+=n[1]*this.halfSize,this.bounds[2]+=n[2]*this.halfSize,this.updateBoundsRadiusFromHalfSize(),this}advanceTo(t,e,n=!1){for(;;){if(this.isTerminalFor(t))return e&&e(this,-1),!0;if(this.isLeaf()){if(!n)return e&&e(this,-1),!1;this.node.residents=null}const o=this._childIndex(t);e&&e(this,o),this.advance(o)}}isLeaf(){return null!=this.node.residents}isTerminalFor(t){return t[3]>this.halfSize/2}_childIndex(t){const e=this.bounds;return(e[0]<t[0]?1:0)+(e[1]<t[1]?2:0)+(e[2]<t[2]?4:0)}static createEmptyNode(){return{children:[null,null,null,null,null,null,null,null],terminals:new e({shrink:!0}),residents:new e({shrink:!0})}}static{this._pool=new t(g)}static acquire(){return g._pool.acquire()}static release(t){g._pool.release(t)}static clearPool(){g._pool.prune()}}function S(t,e){let n=g.acquire().init(t);const o=[n];for(;0!==o.length;){if(n=o.pop(),e(n)&&!n.isLeaf())for(let t=0;t<n.node.children.length;t++){n.node.children[t]&&o.push(g.acquire().init(n).advance(t))}g.release(n)}}function j(t,e,n,o=b.DepthOrder.FRONT_TO_BACK){let i=g.acquire().init(t);const r=[i];for(R(n,o,X);0!==r.length;){if(i=r.pop(),e(i)&&!i.isLeaf())for(let t=7;t>=0;--t){const e=X[t];i.node.children[e]&&r.push(g.acquire().init(i).advance(e))}g.release(i)}}function O(t,e,n){K.clear();const o=n.advanceTo(e,((t,e)=>{K.push(t.node),K.push(e)}))?n.node.terminals:n.node.residents;if(o.removeUnordered(t),0===o.length)for(let i=K.length-2;i>=0;i-=2){if(!x(K.data[i],K.data[i+1]))break}}function x(t,n){return n>=0&&(t.children[n]=null),!!N(t)&&(null===t.residents&&(t.residents=new e({shrink:!0})),!0)}function T(t,e){return B(_(e.bounds),2*-e.halfSize,L),B(_(e.bounds),2*e.halfSize,H),p(t.origin,t.direction,L,H)}function z(t,e,n){return B(_(e.bounds),2*-e.halfSize,L),B(_(e.bounds),2*e.halfSize,H),n.applyToMinMax(L,H),p(t.origin,t.direction,L,H)}function N(t){if(0!==t.terminals.length)return!1;if(null!==t.residents)return 0===t.residents.length;for(let e=0;e<t.children.length;e++)if(t.children[e])return!1;return!0}function M(t,e){t[0]=Math.min(t[0],e[0]-e[3]),t[1]=Math.min(t[1],e[1]-e[3]),t[2]=Math.min(t[2],e[2]-e[3])}function A(t,e){t[0]=Math.max(t[0],e[0]+e[3]),t[1]=Math.max(t[1],e[1]+e[3]),t[2]=Math.max(t[2],e[2]+e[3])}function B(t,e,n){n[0]=t[0]+e,n[1]=t[1]+e,n[2]=t[2]+e}function D(t,e,n){L[0]=1/0,L[1]=1/0,L[2]=1/0,H[0]=-1/0,H[1]=-1/0,H[2]=-1/0;for(const o of t){const t=e(o);C(t[3])&&(M(L,t),A(H,t))}o(_(n),L,H,.5),n[3]=Math.max(H[0]-L[0],H[1]-L[1],H[2]-L[2])/2}function R(t,e,n){if(!Q.length)for(let o=0;o<8;++o)Q.push({index:0,distance:0});for(let o=0;o<8;++o){const n=E[o];Q.data[o].index=o,Q.data[o].distance=v(t,e,n)}Q.sort(((t,e)=>t.distance-e.distance));for(let o=0;o<8;++o)n[o]=Q.data[o].index}function F(t,e){let n,o=1/0;for(let i=0;i<8;++i){const r=v(t,e,P[i]);r<o&&(o=r,n=P[i])}return n}function v(t,e,n){return e*(t[0]*n[0]+t[1]*n[1]+t[2]*n[2])}function C(t){return!isNaN(t)&&t!==-1/0&&t!==1/0&&t>0}!function(t){var e;(e=t.DepthOrder||(t.DepthOrder={}))[e.FRONT_TO_BACK=1]="FRONT_TO_BACK",e[e.BACK_TO_FRONT=-1]="BACK_TO_FRONT"}(b);const E=[h(-1,-1,-1),h(1,-1,-1),h(-1,1,-1),h(1,1,-1),h(-1,-1,1),h(1,-1,1),h(-1,1,1),h(1,1,1)],P=[h(-1,-1,-1),h(-1,-1,1),h(-1,1,-1),h(-1,1,1),h(1,-1,-1),h(1,-1,1),h(1,1,-1),h(1,1,1)],w=Math.sqrt(3),y=[null];function q(t){return y[0]=t,y}const k=u(),I=a(),L=a(),H=a(),K=new e,J=u(),W=u(),V=u(),G=u(),U=[{min:0,max:0},{min:0,max:0},{min:0,max:0}],Q=new e,X=[0,0,0,0,0,0,0,0];export{b as default};