@arcgis/core 5.0.0-next.44 → 5.0.0-next.45

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 (39) hide show
  1. package/assets/esri/core/workers/RemoteClient.js +1 -1
  2. package/assets/esri/core/workers/chunks/bf5f9da0837ed09729c6.js +316 -0
  3. package/assets/esri/core/workers/chunks/{7c08c0824ad354177787.js → d7878fba02814adaf19f.js} +1 -1
  4. package/chunks/GaussianSplat.glsl.js +2 -2
  5. package/config.js +1 -1
  6. package/core/urlUtils.d.ts +1 -0
  7. package/core/workers/workerFactory.js +1 -1
  8. package/interfaces.d.ts +26 -7
  9. package/kernel.js +1 -1
  10. package/package.json +2 -2
  11. package/rest/print.js +1 -1
  12. package/rest/support/LegendLayer.js +1 -1
  13. package/support/revision.js +1 -1
  14. package/views/3d/analysis/ShadowCastAnalysisView3D.js +1 -1
  15. package/views/3d/layers/graphics/pipeline/rendering/DirectRenderer.js +1 -1
  16. package/views/3d/layers/graphics/pipeline/rendering/RenderCommandContext.js +1 -1
  17. package/views/3d/layers/graphics/pipeline/symbolization/IconSymbolLayerRenderer.js +1 -1
  18. package/views/3d/webgl-engine/lib/GaussianSplatRenderNode.js +1 -1
  19. package/views/3d/webgl-engine/materials/HUDMaterial.js +1 -1
  20. package/views/3d/webgl-engine/materials/HeatmapDensityMaterial.js +1 -1
  21. package/views/3d/webgl-engine/materials/renderers/MergedBuffer.js +1 -1
  22. package/views/3d/webgl-engine/materials/renderers/PerBufferData.js +1 -1
  23. package/views/3d/webgl-engine/materials/renderers/PerOriginData.js +1 -1
  24. package/views/3d/webgl-engine/materials/renderers/VaoWriter.js +1 -1
  25. package/views/3d/webgl-engine/shaders/GaussianSplatColorTechnique.js +5 -0
  26. package/views/3d/webgl-engine/shaders/GaussianSplatDepthTechnique.js +5 -0
  27. package/views/3d/webgl-engine/shaders/GaussianSplatTechniqueConfiguration.js +1 -1
  28. package/widgets/FeatureTable/AttachmentsColumn.js +1 -1
  29. package/widgets/FeatureTable/FeatureTableViewModel.js +1 -1
  30. package/widgets/FeatureTable/Grid/Column.js +1 -1
  31. package/widgets/FeatureTable/Grid/EditorColumn.js +1 -1
  32. package/widgets/FeatureTable/Grid/Grid.js +1 -1
  33. package/widgets/FeatureTable/Grid/GridViewModel.js +1 -1
  34. package/widgets/FeatureTable/support/FeatureStore.js +1 -1
  35. package/widgets/Print/CustomTemplate.js +1 -1
  36. package/widgets/Print/PrintViewModel.js +1 -1
  37. package/widgets/Print/TemplateOptions.js +1 -1
  38. package/widgets/Print.js +1 -1
  39. package/assets/esri/core/workers/chunks/ea3cba01c60d9bc72719.js +0 -316
@@ -2,4 +2,4 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{copy as e,invert as r,transpose as t}from"../../../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as n}from"../../../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{getContinuousIndexArray as a}from"../../../../../../geometry/support/Indices.js";import{PipelineCommand as i}from"../PipelineCommand.js";import{generateId as s}from"../utils.js";import{BoundingInfo as o}from"../../../../webgl-engine/lib/BoundingInfo.js";import{DefaultMaterial as d}from"../../../../webgl-engine/materials/DefaultMaterial.js";import{HUDMaterial as m}from"../../../../webgl-engine/materials/HUDMaterial.js";class f{constructor(e,r){this._mainThreadDelegate=r,this._bufferWriters=new Map,this.globalViewingMode=1===e}createRenderCommandBuffer(e=[],r=[]){return{commands:e,transferList:r}}mergeRenderCommandBuffers(e){const r=this.createRenderCommandBuffer();for(const t of e)null!=t&&(r.commands.push(...t.commands),r.transferList.push(...t.transferList));return r}async createTexture(e){const{data:r,parameters:t}=e();return await this._mainThreadDelegate.createTexture(r,t)}async releaseTexture(e){const r=this._destroyTexture(e);return new i(this,r,[])}_destroyTexture(e){return{commands:[{id:"destroy-texture",textureId:e}],transferList:[]}}async createMaterial(e){const{type:r,parameters:t}=e,n=s("material");let a,i;switch(r){case"default":a=new d(e.parameters,{spherical:this.globalViewingMode}),i={type:r,materialId:n,parameters:e.parameters};break;case"hud":a=new m(t,this.globalViewingMode),i={type:r,materialId:n,parameters:e.parameters}}return this._bufferWriters.set(n,a.createBufferWriter()),await this._mainThreadDelegate.createMaterial(i),n}destroyMaterial(e){return{commands:[{id:"destroy-material",materialId:e}],transferList:[]}}updateMaterial(e){return{commands:[{...e,id:"update-material"}],transferList:[]}}async createDirectRenderer(e){return await this._mainThreadDelegate.createDirectRenderer(e),e}async destroyDirectRenderer(e){await this._mainThreadDelegate.destroyDirectRenderer(e)}addDirectRendererGeometry(e,r,t,n){const{materialId:a}=r;if(null==this._bufferWriters.get(a))throw new Error(`no bufferwriter found for material ${a}`);const{renderGeometryBuffer:i,renderGeometryBufferItems:s}=this.createRenderGeometryBuffer(r,t,n);return this.addDirectRendererGeometryBuffer(a,e,i,s,t)}updateDirectRendererGeometry(e,r,t,n){const{materialId:a}=r;if(null==this._bufferWriters.get(a))throw new Error(`no bufferwriter found for material ${a}`);const{renderGeometryBuffer:i,renderGeometryBufferItems:s}=this.createRenderGeometryBuffer(r,t,n);return this.updateDirectRendererGeometryBuffer(a,e,i,s,t)}addDirectRendererGeometryBuffer(e,r,t,n,a){const{objectIds:i,visibilities:s}=n;return{commands:[{id:"add-direct-renderer-geometry-buffer",rendererId:e,groupId:r,renderGeometryBuffer:t,renderGeometryBufferItems:n,localOrigin:a}],transferList:[t.data,i.buffer,s.buffer]}}updateDirectRendererGeometryBuffer(e,r,t,n,a){const{objectIds:i,visibilities:s}=n;return{commands:[{id:"update-direct-renderer-geometry-buffer",rendererId:e,groupId:r,renderGeometryBuffer:t,renderGeometryBufferItems:n,localOrigin:a}],transferList:[t.data,i.buffer,s.buffer]}}removeDirectRendererGeometryBuffer(e,r){return{commands:[{id:"remove-direct-renderer-geometry-buffer",rendererId:e,groupId:r}],transferList:[]}}async createLodRenderer(e){const r=s("lod-renderer"),t=new Set,n={levels:e.levels.map(e=>({components:e.components.map(e=>{const r=e.attributes.get("position");if(!r||0===r.indices.length)throw new Error("positions attribute expected");const n=3,i=a(r.indices.length/n),s=new o(i,n,r);if(null==this._bufferWriters.get(e.materialId))throw new Error("writer not found");const{renderGeometryBuffer:d}=this.createRenderGeometryBuffer(e,null);t.add(d.data);return{materialId:e.materialId,renderGeometryBuffer:d,boundingInfo:{bbMax:s.bbMax,bbMin:s.bbMin}}}),minScreenSpaceRadius:e.minScreenSpaceRadius}))};return await this._mainThreadDelegate.createLodRenderer(r,n,Array.from(t)),r}destroyLodRenderer(e){return{commands:[{id:"destroy-lod-renderer",rendererId:e}],transferList:[]}}addLodInstances(e,r,t){return{commands:[{id:"add-lod-instances",rendererId:e,groupId:r,data:t}],transferList:[t.featureIds.buffer,t.globalTransforms.buffer,t.localTransforms.buffer,t.visibility.buffer]}}removeLodInstances(e,r){return{commands:[{id:"remove-lod-instances",rendererId:e,groupId:r}],transferList:[]}}updateLodInstancesData(e,r,t){return{commands:[{id:"update-lod-instance-data",rendererId:e,groupId:r,globalTransforms:t}],transferList:[t.buffer]}}updateVisibility(e,r,t){return{commands:[{id:"update-visibility",rendererId:e,groupId:r,visibility:t}],transferList:[t.buffer]}}async dispatchRenderCommands(e){0!==e.commands.length&&await this._mainThreadDelegate.executeRenderCommands(e)}createRenderGeometryBuffer(n,a,i){const{materialId:s,visibilities:o,objectIds:d}=n,m=this._bufferWriters.get(s);if(null==m)throw new Error("no registered bufferWriter for material found");let f=null;if(n.transformation&&a)e(u,n.transformation),u[12]-=a[0],u[13]-=a[1],u[14]-=a[2],f=u;else{if(a)throw new Error("not implemented");n.transformation&&(f=n.transformation)}let b=null;f&&(r(l,u),t(l,l),b=l);const y=n.attributes,h=m.elementCount(y),p=i?m.instanceLayout:m.layout;if(!p)throw new Error("Missing layout");const g=p.stride/4;h>Math.floor(c/g)&&console.warn("geometry with very large number of elements encountered");const I=p.createBuffer(h),w=0,B=m.write(f,b,y,n.olidColor,I,w);if(null==B)throw new Error("Bufferwriter.write does not provide item information.");if(o.length!==B.numItems||d.length!==B.numItems)throw new Error("Unexpected mismatch between number of RenderGeometryBufferItems and provided objectIds/visibility flags.");return{renderGeometryBuffer:{data:I.buffer,elementCount:h},renderGeometryBufferItems:{objectIds:d,visibilities:o,ranges:{numVertices:B.numVerticesPerItem,numItems:B.numItems}}}}async setBaseInstance(e,r){await this._mainThreadDelegate.setBaseInstance(e,r)}}const u=n(),l=n(),c=16777216/4;export{f as RenderCommandContext};
5
+ import{copy as e,invert as r,transpose as t}from"../../../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as n}from"../../../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{getContinuousIndexArray as a}from"../../../../../../geometry/support/Indices.js";import{PipelineCommand as i}from"../PipelineCommand.js";import{generateId as s}from"../utils.js";import{BoundingInfo as o}from"../../../../webgl-engine/lib/BoundingInfo.js";import{DefaultMaterial as d}from"../../../../webgl-engine/materials/DefaultMaterial.js";import{HUDMaterial as m}from"../../../../webgl-engine/materials/HUDMaterial.js";class f{constructor(e,r){this._mainThreadDelegate=r,this._bufferWriters=new Map,this.globalViewingMode=1===e}createRenderCommandBuffer(e=[],r=[]){return{commands:e,transferList:r}}mergeRenderCommandBuffers(e){const r=this.createRenderCommandBuffer();for(const t of e)null!=t&&(r.commands.push(...t.commands),r.transferList.push(...t.transferList));return r}async createTexture(e){const{data:r,parameters:t}=e();return await this._mainThreadDelegate.createTexture(r,t)}async releaseTexture(e){const r=this._destroyTexture(e);return new i(this,r,[])}_destroyTexture(e){return{commands:[{id:"destroy-texture",textureId:e}],transferList:[]}}async createMaterial(e){const{type:r,parameters:t}=e,n=s("material");let a,i;switch(r){case"default":a=new d(e.parameters,{spherical:this.globalViewingMode}),i={type:r,materialId:n,parameters:e.parameters};break;case"hud":a=new m(t,this.globalViewingMode),i={type:r,materialId:n,parameters:e.parameters}}return this._bufferWriters.set(n,a.createBufferWriter()),await this._mainThreadDelegate.createMaterial(i),n}destroyMaterial(e){return{commands:[{id:"destroy-material",materialId:e}],transferList:[]}}updateMaterial(e){return{commands:[{...e,id:"update-material"}],transferList:[]}}async createDirectRenderer(e){return await this._mainThreadDelegate.createDirectRenderer(e),e}async destroyDirectRenderer(e){await this._mainThreadDelegate.destroyDirectRenderer(e)}addDirectRendererGeometry(e,r,t){const{materialId:n}=r;if(null==this._bufferWriters.get(n))throw new Error(`no bufferwriter found for material ${n}`);const{renderGeometryBuffer:a,renderGeometryBufferItems:i}=this.createRenderGeometryBuffer(r,t);return this.addDirectRendererGeometryBuffer(n,e,a,i,t)}updateDirectRendererGeometry(e,r,t){const{materialId:n}=r;if(null==this._bufferWriters.get(n))throw new Error(`no bufferwriter found for material ${n}`);const{renderGeometryBuffer:a,renderGeometryBufferItems:i}=this.createRenderGeometryBuffer(r,t);return this.updateDirectRendererGeometryBuffer(n,e,a,i,t)}addDirectRendererGeometryBuffer(e,r,t,n,a){const{objectIds:i,visibilities:s}=n;return{commands:[{id:"add-direct-renderer-geometry-buffer",rendererId:e,groupId:r,renderGeometryBuffer:t,renderGeometryBufferItems:n,localOrigin:a}],transferList:[t.data,i.buffer,s.buffer]}}updateDirectRendererGeometryBuffer(e,r,t,n,a){const{objectIds:i,visibilities:s}=n;return{commands:[{id:"update-direct-renderer-geometry-buffer",rendererId:e,groupId:r,renderGeometryBuffer:t,renderGeometryBufferItems:n,localOrigin:a}],transferList:[t.data,i.buffer,s.buffer]}}removeDirectRendererGeometryBuffer(e,r){return{commands:[{id:"remove-direct-renderer-geometry-buffer",rendererId:e,groupId:r}],transferList:[]}}async createLodRenderer(e){const r=s("lod-renderer"),t=new Set,n={levels:e.levels.map(e=>({components:e.components.map(e=>{const r=e.attributes.get("position");if(!r||0===r.indices.length)throw new Error("positions attribute expected");const n=3,i=a(r.indices.length/n),s=new o(i,n,r);if(null==this._bufferWriters.get(e.materialId))throw new Error("writer not found");const{renderGeometryBuffer:d}=this.createRenderGeometryBuffer(e,null);t.add(d.data);return{materialId:e.materialId,renderGeometryBuffer:d,boundingInfo:{bbMax:s.bbMax,bbMin:s.bbMin}}}),minScreenSpaceRadius:e.minScreenSpaceRadius}))};return await this._mainThreadDelegate.createLodRenderer(r,n,Array.from(t)),r}destroyLodRenderer(e){return{commands:[{id:"destroy-lod-renderer",rendererId:e}],transferList:[]}}addLodInstances(e,r,t){return{commands:[{id:"add-lod-instances",rendererId:e,groupId:r,data:t}],transferList:[t.featureIds.buffer,t.globalTransforms.buffer,t.localTransforms.buffer,t.visibility.buffer]}}removeLodInstances(e,r){return{commands:[{id:"remove-lod-instances",rendererId:e,groupId:r}],transferList:[]}}updateLodInstancesData(e,r,t){return{commands:[{id:"update-lod-instance-data",rendererId:e,groupId:r,globalTransforms:t}],transferList:[t.buffer]}}updateVisibility(e,r,t){return{commands:[{id:"update-visibility",rendererId:e,groupId:r,visibility:t}],transferList:[t.buffer]}}async dispatchRenderCommands(e){0!==e.commands.length&&await this._mainThreadDelegate.executeRenderCommands(e)}createRenderGeometryBuffer(n,a){const{materialId:i,visibilities:s,objectIds:o}=n,d=this._bufferWriters.get(i);if(null==d)throw new Error("no registered bufferWriter for material found");let m=null;if(n.transformation&&a)e(u,n.transformation),u[12]-=a[0],u[13]-=a[1],u[14]-=a[2],m=u;else{if(a)throw new Error("not implemented");n.transformation&&(m=n.transformation)}let f=null;m&&(r(l,u),t(l,l),f=l);const b=n.attributes,p=d.elementCount(b),y=d.layout,h=y.stride/4;p>Math.floor(c/h)&&console.warn("geometry with very large number of elements encountered");const g=y.createBuffer(p),I=0,w=d.write(m,f,b,n.olidColor,g,I);if(null==w)throw new Error("Bufferwriter.write does not provide item information.");if(s.length!==w.numItems||o.length!==w.numItems)throw new Error("Unexpected mismatch between number of RenderGeometryBufferItems and provided objectIds/visibility flags.");return{renderGeometryBuffer:{data:g.buffer,elementCount:p},renderGeometryBufferItems:{objectIds:o,visibilities:s,ranges:{numVertices:w.numVerticesPerItem,numItems:w.numItems}}}}async setBaseInstance(e,r){await this._mainThreadDelegate.setBaseInstance(e,r)}}const u=n(),l=n(),c=16777216/4;export{f as RenderCommandContext};
@@ -2,4 +2,4 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../../../../../Color.js";import{create as t}from"../../../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{ONES as r}from"../../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ZEROS as i}from"../../../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{defaultPrimitive as n}from"../../../../../../symbols/support/IconSymbol3DLayerResource.js";import{mixinColorAndOpacity as o}from"../../graphicUtils.js";import{namedAnchorToHUDMaterialAnchorPos as a}from"../../placementUtils.js";import{PipelineCommand as l}from"../PipelineCommand.js";import{computeTileCenterRenderCoordinates as s,readObjectIds as m,readMapCoordinates as c,projectToRenderCoordinates as d}from"../featureData/processingUtils.js";import{inputAttributesToAttributesMap as u}from"./symbolizationUtils.js";import{createTextureInfo as y,requiresHalfTexelOffset as p,defaultBoundingBox as _}from"../../../../support/engineContent/sdfPrimitives.js";import{Attribute as C}from"../../../../webgl-engine/lib/Attribute.js";class h{constructor(e,t){this._context=null,this._symbolLayer=null,this._draped=!1,this._loaded=!1,this._loadingPromise=null,this._iconTextureID=null,this._materialId=null,this._context=t,this._symbolLayer=e}get loaded(){return this._loaded}load(){return null==this._loadingPromise&&(this._loadingPromise=this._load()),this._loadingPromise}_destroy(){this._iconTextureID=null}async _load(){const e=this._context.renderCommandContext,t=await e.createTexture(()=>y("circle"));this._iconTextureID=t;const r={anchorPosition:a.center,occlusionTest:!0,hasSlicePlane:!1,color:this._getFillColor(),outlineColor:this._getOutlineColor(),outlineSize:1,distanceFieldBoundingBox:_,textureId:t,textureIsSignedDistanceField:!0,sampleSignedDistanceFieldTexelCenter:p("circle")},i=new Uint8Array(8),n=0,o=255;i[0]=n,i[1]=n,i[2]=n,i[3]=o,i[4]=o,i[5]=n,i[6]=o,i[7]=o,this._materialId=await e.createMaterial({type:"hud",parameters:r}),await e.createDirectRenderer(this._materialId),await e.setBaseInstance(this._materialId,{data:i.buffer,elementCount:4}),this._loaded=!0}async createAddCommand(e){const{_materialId:t,_context:r}=this,{renderCommandContext:i}=r;if(null==t)throw new Error("expected material not to be null");const n=await this._createGeometry(e);if(null==n)return r.createPipelineCommand();const o=s(e,r),a=!0;return r.createPipelineCommand(i.addDirectRendererGeometry(e.id,n,o,a))}async _createGeometry(e){const{_materialId:r,_context:i}=this,{mainThreadDelegate:n}=i,{featureCount:o}=e;if(0===o||null==r)return null;const a=m(e),l=c(e),s=await n.applyElevationAlignmentTo(l),y=d(s,i),p=new Float64Array([0,0,1]),_=new Float64Array([255,255,255,255]),h=new Float64Array([24,24]),f=new Float64Array([0,0,0,1]),g=new Float64Array([0]),x=new Uint32Array(o);for(let t=0;t<o;++t)x[t]=t;const w=new Uint32Array(o);for(let t=0;t<o;++t)w[t]=0;const b=[["position",new C(y,x,3,!0)],["normal",new C(p,w,3,!0)],["color",new C(_,w,4,!0)],["rotation",new C(g,w,1,!0)],["size",new C(h,w,2,!0)],["centerOffsetAndDistance",new C(f,w,4,!0)]],I=new Uint8Array(o);e.getVisibilityArray(I);return{attributes:u(b),olidColor:void 0,transformation:t(),materialId:r,objectIds:a,visibilities:I}}async createRemoveCommand(e){const{_materialId:t,_context:r}=this,i=r.renderCommandContext;return null==t?r.createPipelineCommand():r.createPipelineCommand(i.removeDirectRendererGeometryBuffer(t,e))}async createUpdateVisibilityCommand(e){const{_materialId:t,_context:r}=this,i=r.renderCommandContext;if(null==t)return r.createPipelineCommand();const n=new Uint8Array(e.featureCount);return e.getVisibilityArray(n),r.createPipelineCommand(i.updateVisibility(t,e.id,n))}async createUpdateLayerViewOpacityCommand(e){const{_context:t,_materialId:r}=this,i=t.renderCommandContext;return null==r?t.createPipelineCommand():t.createPipelineCommand(i.updateMaterial({type:"hud",materialId:r,parameters:{color:this._getFillColor(),outlineColor:this._getOutlineColor()}}))}async createUpdateElevationCommand(e){const{_materialId:t,_context:r}=this,{renderCommandContext:i}=r,{featureCount:n,id:o}=e;if(null==t||0===n)return r.createPipelineCommand();const a=await this._createGeometry(e);if(null==a)return r.createPipelineCommand();const l=s(e,r),m=!0;return r.createPipelineCommand(i.updateDirectRendererGeometry(o,a,l,m))}async createDestroyCommand(){const{_iconTextureID:e,_context:t}=this,r=t.renderCommandContext;let i;return i=null!=e?await r.releaseTexture(e):l.create(r),i.appendPipelineStateCommand(()=>this._destroy()),i}_getOutlineColor(){const t=this._getLayerOpacity(),r=this._symbolLayer,i=r?.outline?.color;if(null!=i){const r=e.toUnitRGB(i),n=i.a*t;return[r[0],r[1],r[2],n]}return[0,0,0,0]}_getFillColor(){if(f(this._getPrimitive()))return w;const e=null==this._getPrimitive(),t=this._symbolLayer?.material?.color;return this._getCombinedOpacityAndColor(t,{hasIntrinsicColor:e})}_getLayerOpacity(){return this._context.layerViewInfo.fullOpacity}_getCombinedOpacity(e,t=x){const r=this._draped?1:this._getLayerOpacity();return e?r*e.a:t.hasIntrinsicColor?r:0}_getCombinedOpacityAndColor(t,i=x){const n=this._getCombinedOpacity(t,i),a=null!=t?e.toUnitRGB(t):r;return o(a,n)}_getPrimitive(){return g(this._symbolLayer)}}function f(e){return null!=e&&("cross"===e||"x"===e)}function g(e){return e.resource?.href?null:e.resource?.primitive??n}const x={hasIntrinsicColor:!1},w=i;export{h as IconSymbolLayerRenderer,x as defaultMaterialOptions,g as getPrimitive,f as isOutlineOnly,w as transparentUnit};
5
+ import e from"../../../../../../Color.js";import{create as t}from"../../../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{ONES as r}from"../../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ZEROS as i}from"../../../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{defaultPrimitive as n}from"../../../../../../symbols/support/IconSymbol3DLayerResource.js";import{mixinColorAndOpacity as o}from"../../graphicUtils.js";import{namedAnchorToHUDMaterialAnchorPos as a}from"../../placementUtils.js";import{PipelineCommand as l}from"../PipelineCommand.js";import{computeTileCenterRenderCoordinates as s,readObjectIds as m,readMapCoordinates as c,projectToRenderCoordinates as d}from"../featureData/processingUtils.js";import{inputAttributesToAttributesMap as u}from"./symbolizationUtils.js";import{createTextureInfo as y,requiresHalfTexelOffset as p,defaultBoundingBox as _}from"../../../../support/engineContent/sdfPrimitives.js";import{Attribute as C}from"../../../../webgl-engine/lib/Attribute.js";class h{constructor(e,t){this._context=null,this._symbolLayer=null,this._draped=!1,this._loaded=!1,this._loadingPromise=null,this._iconTextureID=null,this._materialId=null,this._context=t,this._symbolLayer=e}get loaded(){return this._loaded}load(){return null==this._loadingPromise&&(this._loadingPromise=this._load()),this._loadingPromise}_destroy(){this._iconTextureID=null}async _load(){const e=this._context.renderCommandContext,t=await e.createTexture(()=>y("circle"));this._iconTextureID=t;const r={anchorPosition:a.center,occlusionTest:!0,hasSlicePlane:!1,color:this._getFillColor(),outlineColor:this._getOutlineColor(),outlineSize:1,distanceFieldBoundingBox:_,textureId:t,textureIsSignedDistanceField:!0,sampleSignedDistanceFieldTexelCenter:p("circle")},i=new Uint8Array(8),n=0,o=255;i[0]=n,i[1]=n,i[2]=n,i[3]=o,i[4]=o,i[5]=n,i[6]=o,i[7]=o,this._materialId=await e.createMaterial({type:"hud",parameters:r}),await e.createDirectRenderer(this._materialId),await e.setBaseInstance(this._materialId,{data:i.buffer,elementCount:4}),this._loaded=!0}async createAddCommand(e){const{_materialId:t,_context:r}=this,{renderCommandContext:i}=r;if(null==t)throw new Error("expected material not to be null");const n=await this._createGeometry(e);if(null==n)return r.createPipelineCommand();const o=s(e,r);return r.createPipelineCommand(i.addDirectRendererGeometry(e.id,n,o))}async _createGeometry(e){const{_materialId:r,_context:i}=this,{mainThreadDelegate:n}=i,{featureCount:o}=e;if(0===o||null==r)return null;const a=m(e),l=c(e),s=await n.applyElevationAlignmentTo(l),y=d(s,i),p=new Float64Array([0,0,1]),_=new Float64Array([255,255,255,255]),h=new Float64Array([24,24]),f=new Float64Array([0,0,0,1]),g=new Float64Array([0]),x=new Uint32Array(o);for(let t=0;t<o;++t)x[t]=t;const w=new Uint32Array(o);for(let t=0;t<o;++t)w[t]=0;const b=[["position",new C(y,x,3,!0)],["normal",new C(p,w,3,!0)],["color",new C(_,w,4,!0)],["rotation",new C(g,w,1,!0)],["size",new C(h,w,2,!0)],["centerOffsetAndDistance",new C(f,w,4,!0)]],I=new Uint8Array(o);e.getVisibilityArray(I);return{attributes:u(b),olidColor:void 0,transformation:t(),materialId:r,objectIds:a,visibilities:I}}async createRemoveCommand(e){const{_materialId:t,_context:r}=this,i=r.renderCommandContext;return null==t?r.createPipelineCommand():r.createPipelineCommand(i.removeDirectRendererGeometryBuffer(t,e))}async createUpdateVisibilityCommand(e){const{_materialId:t,_context:r}=this,i=r.renderCommandContext;if(null==t)return r.createPipelineCommand();const n=new Uint8Array(e.featureCount);return e.getVisibilityArray(n),r.createPipelineCommand(i.updateVisibility(t,e.id,n))}async createUpdateLayerViewOpacityCommand(e){const{_context:t,_materialId:r}=this,i=t.renderCommandContext;return null==r?t.createPipelineCommand():t.createPipelineCommand(i.updateMaterial({type:"hud",materialId:r,parameters:{color:this._getFillColor(),outlineColor:this._getOutlineColor()}}))}async createUpdateElevationCommand(e){const{_materialId:t,_context:r}=this,{renderCommandContext:i}=r,{featureCount:n,id:o}=e;if(null==t||0===n)return r.createPipelineCommand();const a=await this._createGeometry(e);if(null==a)return r.createPipelineCommand();const l=s(e,r);return r.createPipelineCommand(i.updateDirectRendererGeometry(o,a,l))}async createDestroyCommand(){const{_iconTextureID:e,_context:t}=this,r=t.renderCommandContext;let i;return i=null!=e?await r.releaseTexture(e):l.create(r),i.appendPipelineStateCommand(()=>this._destroy()),i}_getOutlineColor(){const t=this._getLayerOpacity(),r=this._symbolLayer,i=r?.outline?.color;if(null!=i){const r=e.toUnitRGB(i),n=i.a*t;return[r[0],r[1],r[2],n]}return[0,0,0,0]}_getFillColor(){if(f(this._getPrimitive()))return w;const e=null==this._getPrimitive(),t=this._symbolLayer?.material?.color;return this._getCombinedOpacityAndColor(t,{hasIntrinsicColor:e})}_getLayerOpacity(){return this._context.layerViewInfo.fullOpacity}_getCombinedOpacity(e,t=x){const r=this._draped?1:this._getLayerOpacity();return e?r*e.a:t.hasIntrinsicColor?r:0}_getCombinedOpacityAndColor(t,i=x){const n=this._getCombinedOpacity(t,i),a=null!=t?e.toUnitRGB(t):r;return o(a,n)}_getPrimitive(){return g(this._symbolLayer)}}function f(e){return null!=e&&("cross"===e||"x"===e)}function g(e){return e.resource?.href?null:e.resource?.primitive??n}const x={hasIntrinsicColor:!1},w=i;export{h as IconSymbolLayerRenderer,x as defaultMaterialOptions,g as getPrimitive,f as isOutlineOnly,w as transparentUnit};
@@ -2,4 +2,4 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as t}from"tslib";import e from"../../../../core/Logger.js";import{watch as s}from"../../../../core/reactiveUtils.js";import{property as i,subclass as a}from"../../../../core/accessorSupport/decorators.js";import{set as r}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{e as n,b as o,j as l,q as h,g as p,E as u,d as c,J as m}from"../../../../chunks/vec32.js";import{create as d,clone as _}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{c as f}from"../../../../chunks/vec42.js";import{create as g}from"../../../../geometry/support/plane.js";import{fromPoints as P}from"../../../../geometry/support/ray.js";import{Sphere as b}from"../../../../geometry/support/sphere.js";import{RenderCategory as S}from"../../webgl.js";import{GaussianSplatTarget as C}from"../../layers/i3s/Intersector.js";import{GaussianSplatDataStore as v}from"../../support/gaussianSplatting/GaussianSplatDataStore.js";import w from"../../webgl/RenderNode.js";import{IntersectorResult as D}from"./IntersectorResult.js";import{G as x}from"../../../../chunks/GaussianSplat.glsl.js";import{G as y}from"../../../../chunks/GaussianSplatComposition.glsl.js";import{GaussianSplatCompositionTechnique as E}from"../shaders/GaussianSplatCompositionTechnique.js";import{G as A}from"../../../../chunks/GaussianSplatDepthComposition.glsl.js";import{GaussianSplatDepthCompositionTechnique as q}from"../shaders/GaussianSplatDepthCompositionTechnique.js";import{GaussianSplatTechnique as T}from"../shaders/GaussianSplatTechnique.js";import{GaussianSplatTechniqueConfiguration as j}from"../shaders/GaussianSplatTechniqueConfiguration.js";import{ColorAttachment1 as G,DepthStencilAttachment as N,PrimitiveType as F}from"../../../webgl/enums.js";var O;const H=()=>e.getLogger("esri/views/3d/webgl-engine/lib/GaussianSplatRenderNode");let U=class extends w{static{O=this}constructor(t){super(t),this.gaussianPosition=d(),this.intersectionRayDir=d(),this.intersectionPlane=g(),this._slicePlaneEnabled=!1,this._data=null,this.produces=S.OPAQUE,this.type=0,this.isGround=!1,this.layerViewUid="",this._passParameters=new x,this._compositionPassParameters=new y,this._depthCompositionPassParameters=new A,this._previousCameraPosition=d(),this._previousCameraDirection=d(),this.fadeHelper=null,this._configuration=new j(t.view.state.isGlobal)}async initialize(){this._data=new v(this),this.view.sceneIntersectionHelper.addIntersectionHandler(this),this.addHandles([s(()=>this.view.state.camera,()=>this._onCameraChange())])}precompile(){this._configuration.alphaCutoff=this.view.qualitySettings.gaussianSplat.minimumOpacity,this._configuration.terrainDepthTest=this.bindParameters.terrainDepthTest,this._configuration.fadingEnabled=this.fadeHelper.fadingEnabled,this.techniques.precompile(T,this._configuration),this.techniques.precompile(E),this.techniques.precompile(q)}render(t){const e=t.find(({name:t})=>t===S.OPAQUE),s=this.renderingContext.capabilities.drawBuffersIndexed;if(!s)return H().warnOnce("Gaussian Splatting is not supported on this device."),e;if(this._handleFading(),!this._data.visibleGaussians||!this._data.orderTexture.texture||!this._data.textureAtlas.texture)return e;const i=this.techniques.get(T,this._configuration),a=this.techniques.get(E),n=this.techniques.get(q);if(!i.compiled||!n.compiled||!a.compiled)return this.requestRender(1),e;const{fullWidth:o,fullHeight:l}=this.bindParameters.camera,h=this.fboCache,p=h.acquire(o,l,"gaussian color output");p.acquireColor(G,8,"gaussian depth output"),p.attachDepth(e.getAttachment(N));const u=this.renderingContext;this._passParameters.totalGaussians=this._data.visibleGaussians,this._passParameters.splatOrder=this._data.orderTexture.texture,this._passParameters.splatFading=this._data.fadingTexture.texture,this._passParameters.splatAtlas=this._data.textureAtlas.texture;const c=Math.tan(.5*this.camera.fovY),m=c/l*o;r(this._passParameters.tanFov,m,c),this._passParameters.focalLength=l/(2*c);const d=this.view.qualitySettings.gaussianSplat.minimumSplatPixelRadius;this._passParameters.minSplatRadius=d*Math.sqrt(o*l)/Math.sqrt(2073600),this._prepareHighPrecisionCameraPosition(),u.bindFramebuffer(p.fbo),u.setClearColor(0,0,0,0),u.clear(16384),this.renderingContext.bindTechnique(i,this.bindParameters,this._passParameters);const _=u.gl;s.enableiOES(_.BLEND,0),s.blendEquationSeparateiOES(0,_.FUNC_ADD,_.FUNC_ADD),s.blendFuncSeparateiOES(0,_.ONE_MINUS_DST_ALPHA,_.ONE,_.ONE_MINUS_DST_ALPHA,_.ONE),s.enableiOES(_.BLEND,1),s.blendEquationSeparateiOES(1,_.FUNC_ADD,_.FUNC_ADD),s.blendFuncSeparateiOES(1,_.ONE_MINUS_DST_ALPHA,_.DST_ALPHA,_.ONE_MINUS_DST_ALPHA,_.ONE),this.renderingContext.drawArraysInstanced(F.TRIANGLE_STRIP,0,4,this._data.visibleGaussians);const f=h.acquire(o,l,this.produces);return this._depthCompositionPassParameters.splatDepth=p.getTexture(G),f.attachDepth(e.getAttachment(N)),u.bindFramebuffer(f.fbo),u.bindTechnique(n,this.bindParameters,this._depthCompositionPassParameters),u.screen.draw(),this._compositionPassParameters.color=e.getTexture(),this._compositionPassParameters.splatColor=p.getTexture(),u.bindFramebuffer(f.fbo),u.bindTechnique(a,this.bindParameters,this._compositionPassParameters),u.screen.draw(),p.release(),f}intersect(t,e,s,i){const{gaussianPosition:a,intersectionRayDir:r,intersectionPlane:c,layerViewUid:m}=this,g=P(s,i);n(r,i,s);const S=1/o(r);l(r,r,S);const v=d();h(v,r),f(c,r[0],r[1],r[2],-p(r,s));const w=new I,x=new I,y=new Array;this._data.visibleGaussianTiles.forEach(n=>{const{maxScale:o}=n,l=n.obb.minimumDistancePlane(c),h=n.obb.maximumDistancePlane(c),d=h<0,f=null!=w.dist&&null!=x.dist&&w.dist<l*S&&x.dist>h*S;if(d||f)return;if(!new b(n.obb.center,n.obb.radius+o).intersectRay(g,null))return;if(!n.obb.intersectRay(s,r,o))return;const{positions:P,squaredScales:C,gaussianAtlasIndices:D}=n,E=D.length;for(let c=0;c<E;c++){const n=3*c;a[0]=P[n]-s[0],a[1]=P[n+1]-s[1],a[2]=P[n+2]-s[2];const o=C[c],l=p(a,r),h=l*l;if(u(a)-h>o)continue;const d=l*S,f=t=>(t.point=t.point?t.point.fill(a[0],a[1],a[2]):_(a),t.dist=d,t.normal=v,t.layerViewUid=m,t);if((null==w.dist||d<w.dist)&&(null==e||e(s,i,d))&&f(w),0!==t.options.store&&(null==x.dist||d>x.dist)&&(null==e||e(s,i,d))&&f(x),2===t.options.store&&(null==e||e(s,i,d))){const t=new I;y.push(f(t))}}});const E=(t,e)=>{const{layerViewUid:s}=e,i=new C(e.point,s);t.set(0,i,e.dist,e.normal)};if(R(w)){const e=t.results.min;(null==e.distance||w.dist<e.distance)&&E(e,w)}if(R(x)&&0!==t.options.store){const e=t.results.max;(null==e.distance||x.dist>e.distance)&&E(e,x)}if(2===t.options.store)for(const n of y){const e=new D(g);E(e,n),t.results.all.push(e)}}get slicePlaneEnabled(){return this._slicePlaneEnabled}set slicePlaneEnabled(t){this._slicePlaneEnabled!==t&&(this._slicePlaneEnabled=t,this.requestRender(1))}get data(){return this._data}destroy(){this._data.destroy(),super.destroy()}_onCameraChange(){const t=this.view.state.camera.eye,e=this.view.state.camera.ray.direction,s=.001;(Math.abs(t[0]-this._previousCameraPosition[0])>s||Math.abs(t[1]-this._previousCameraPosition[1])>s||Math.abs(t[2]-this._previousCameraPosition[2])>s||Math.abs(e[0]-this._previousCameraDirection[0])>s||Math.abs(e[1]-this._previousCameraDirection[1])>s||Math.abs(e[2]-this._previousCameraDirection[2])>s)&&(c(this._previousCameraPosition,t),c(this._previousCameraDirection,e),this._data.requestSort())}_prepareHighPrecisionCameraPosition(){l(this._passParameters.tileCameraPosition,this.camera.eye,1/O.tileSize),m(this._passParameters.tileCameraPosition,this._passParameters.tileCameraPosition),l(this._passParameters.cameraDelta,this._passParameters.tileCameraPosition,O.tileSize),n(this._passParameters.cameraDelta,this.camera.eye,this._passParameters.cameraDelta)}_handleFading(){if(0===this.fadeHelper.numFadingTiles)return void(this._previousFrameStart=null);this._previousFrameStart??=this.view.stage.renderer.renderContext.time;const t=this.view.stage?.renderer.renderContext.time-this._previousFrameStart;this.fadeHelper.updateAllTileFading(t),this._previousFrameStart=this.view.stage.renderer.renderContext.time,this._data.fadingTexture.updateTexture(this._data.textureAtlas.pageAllocator.pageCount)}static{this.tileSize=2.048}};function R(t){return null!=t.dist&&null!=t.point}t([i({constructOnly:!0})],U.prototype,"fadeHelper",void 0),U=O=t([a("esri.views.3d.webgl-engine.lib.GaussianSplatRenderNode")],U);class I{constructor(){this.point=null,this.dist=null,this.normal=null,this.layerViewUid=""}}export{U as GaussianSplatRenderNode};
5
+ import{__decorate as e}from"tslib";import{watch as t}from"../../../../core/reactiveUtils.js";import{property as s,subclass as i}from"../../../../core/accessorSupport/decorators.js";import{set as a}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{e as r,b as n,j as o,q as l,g as h,E as u,d as c,J as p}from"../../../../chunks/vec32.js";import{create as d,clone as m}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{c as _}from"../../../../chunks/vec42.js";import{create as f}from"../../../../geometry/support/plane.js";import{fromPoints as g}from"../../../../geometry/support/ray.js";import{Sphere as b}from"../../../../geometry/support/sphere.js";import{RenderCategory as P}from"../../webgl.js";import{GaussianSplatTarget as C}from"../../layers/i3s/Intersector.js";import{GaussianSplatDataStore as S}from"../../support/gaussianSplatting/GaussianSplatDataStore.js";import w from"../../webgl/RenderNode.js";import{IntersectorResult as x}from"./IntersectorResult.js";import{G as v}from"../../../../chunks/GaussianSplat.glsl.js";import{GaussianSplatColorTechnique as y}from"../shaders/GaussianSplatColorTechnique.js";import{G as D}from"../../../../chunks/GaussianSplatComposition.glsl.js";import{GaussianSplatCompositionTechnique as q}from"../shaders/GaussianSplatCompositionTechnique.js";import{G as T}from"../../../../chunks/GaussianSplatDepthComposition.glsl.js";import{GaussianSplatDepthCompositionTechnique as E}from"../shaders/GaussianSplatDepthCompositionTechnique.js";import{GaussianSplatDepthTechnique as A}from"../shaders/GaussianSplatDepthTechnique.js";import{GaussianSplatTechnique as G}from"../shaders/GaussianSplatTechnique.js";import{GaussianSplatTechniqueConfiguration as O}from"../shaders/GaussianSplatTechniqueConfiguration.js";import{DepthStencilAttachment as j,ColorAttachment1 as N,PrimitiveType as F}from"../../../webgl/enums.js";var I;let H=class extends w{static{I=this}constructor(e){super(e),this.gaussianPosition=d(),this.intersectionRayDir=d(),this.intersectionPlane=f(),this._slicePlaneEnabled=!1,this._data=null,this.produces=P.OPAQUE,this.type=0,this.isGround=!1,this.layerViewUid="",this._passParameters=new v,this._compositionPassParameters=new D,this._depthCompositionPassParameters=new T,this._previousCameraPosition=d(),this._previousCameraDirection=d(),this.fadeHelper=null,this._configuration=new O(e.view.state.isGlobal),this._colorOnlyConfiguration=new O(e.view.state.isGlobal,!0),this._depthOnlyConfiguration=new O(e.view.state.isGlobal,!1,!0)}async initialize(){this._data=new S(this),this.view.sceneIntersectionHelper.addIntersectionHandler(this),this.addHandles([t(()=>this.view.state.camera,()=>this._onCameraChange())])}precompile(){const e=this.view.qualitySettings.gaussianSplat.minimumOpacity,t=this.bindParameters.terrainDepthTest,s=this.fadeHelper.fadingEnabled,i=s=>{s.alphaCutoff=e,s.terrainDepthTest=t};this.renderingContext.capabilities.drawBuffersIndexed?(i(this._configuration),this._configuration.fadingEnabled=s,this.techniques.precompile(G,this._configuration)):(i(this._colorOnlyConfiguration),this._colorOnlyConfiguration.fadingEnabled=s,this.techniques.precompile(y,this._colorOnlyConfiguration),i(this._depthOnlyConfiguration),this.techniques.precompile(A,this._depthOnlyConfiguration)),this.techniques.precompile(q),this.techniques.precompile(E)}render(e){const t=e.find(({name:e})=>e===P.OPAQUE);if(this._handleFading(),!this._data.visibleGaussians||!this._data.orderTexture.texture||!this._data.textureAtlas.texture)return t;const s=!!this.renderingContext.capabilities.drawBuffersIndexed,i=s?this.techniques.get(G,this._configuration):null,a=s?null:this.techniques.get(y,this._colorOnlyConfiguration),r=s?null:this.techniques.get(A,this._depthOnlyConfiguration),n=this.techniques.get(q),o=this.techniques.get(E);if(!(i?.compiled||a?.compiled&&r?.compiled)||!o.compiled||!n.compiled)return this.requestRender(1),t;const{fullWidth:l,fullHeight:h}=this.bindParameters.camera;this._prepareParameters(h,l);const u=this.renderingContext,c=this.fboCache,p=c.acquire(l,h,"gaussian color output"),d=t.getAttachment(j);p.attachDepth(d);let m=null;s?this._singlePass(p,i):m=this._multiPass(p,d,a,r);const _=c.acquire(l,h,this.produces);return this._depthCompositionPassParameters.splatDepth=m?m.getTexture():p.getTexture(N),_.attachDepth(t.getAttachment(j)),u.bindFramebuffer(_.fbo),u.bindTechnique(o,this.bindParameters,this._depthCompositionPassParameters),u.screen.draw(),this._compositionPassParameters.color=t.getTexture(),this._compositionPassParameters.splatColor=p.getTexture(),u.bindFramebuffer(_.fbo),u.bindTechnique(n,this.bindParameters,this._compositionPassParameters),u.screen.draw(),p.release(),m?.release(),_}intersect(e,t,s,i){const{gaussianPosition:a,intersectionRayDir:c,intersectionPlane:p,layerViewUid:f}=this,P=g(s,i);r(c,i,s);const S=1/n(c);o(c,c,S);const w=d();l(w,c),_(p,c[0],c[1],c[2],-h(c,s));const v=new U,y=new U,D=new Array;this._data.visibleGaussianTiles.forEach(r=>{const{maxScale:n}=r,o=r.obb.minimumDistancePlane(p),l=r.obb.maximumDistancePlane(p),d=l<0,_=null!=v.dist&&null!=y.dist&&v.dist<o*S&&y.dist>l*S;if(d||_)return;if(!new b(r.obb.center,r.obb.radius+n).intersectRay(P,null))return;if(!r.obb.intersectRay(s,c,n))return;const{positions:g,squaredScales:C,gaussianAtlasIndices:x}=r,q=x.length;for(let p=0;p<q;p++){const r=3*p;a[0]=g[r]-s[0],a[1]=g[r+1]-s[1],a[2]=g[r+2]-s[2];const n=C[p],o=h(a,c),l=o*o;if(u(a)-l>n)continue;const d=o*S,_=e=>(e.point=e.point?e.point.fill(a[0],a[1],a[2]):m(a),e.dist=d,e.normal=w,e.layerViewUid=f,e);if((null==v.dist||d<v.dist)&&(null==t||t(s,i,d))&&_(v),0!==e.options.store&&(null==y.dist||d>y.dist)&&(null==t||t(s,i,d))&&_(y),2===e.options.store&&(null==t||t(s,i,d))){const e=new U;D.push(_(e))}}});const q=(e,t)=>{const{layerViewUid:s}=t,i=new C(t.point,s);e.set(0,i,t.dist,t.normal)};if(R(v)){const t=e.results.min;(null==t.distance||v.dist<t.distance)&&q(t,v)}if(R(y)&&0!==e.options.store){const t=e.results.max;(null==t.distance||y.dist>t.distance)&&q(t,y)}if(2===e.options.store)for(const r of D){const t=new x(P);q(t,r),e.results.all.push(t)}}get slicePlaneEnabled(){return this._slicePlaneEnabled}set slicePlaneEnabled(e){this._slicePlaneEnabled!==e&&(this._slicePlaneEnabled=e,this.requestRender(1))}get data(){return this._data}destroy(){this._data.destroy(),super.destroy()}_onCameraChange(){const e=this.view.state.camera.eye,t=this.view.state.camera.ray.direction,s=.001;(Math.abs(e[0]-this._previousCameraPosition[0])>s||Math.abs(e[1]-this._previousCameraPosition[1])>s||Math.abs(e[2]-this._previousCameraPosition[2])>s||Math.abs(t[0]-this._previousCameraDirection[0])>s||Math.abs(t[1]-this._previousCameraDirection[1])>s||Math.abs(t[2]-this._previousCameraDirection[2])>s)&&(c(this._previousCameraPosition,e),c(this._previousCameraDirection,t),this._data.requestSort())}_prepareParameters(e,t){this._passParameters.totalGaussians=this._data.visibleGaussians,this._passParameters.splatOrder=this._data.orderTexture.texture,this._passParameters.splatFading=this._data.fadingTexture.texture,this._passParameters.splatAtlas=this._data.textureAtlas.texture;const s=Math.tan(.5*this.camera.fovY),i=s/e*t;a(this._passParameters.tanFov,i,s),this._passParameters.focalLength=e/(2*s);const r=this.view.qualitySettings.gaussianSplat.minimumSplatPixelRadius;this._passParameters.minSplatRadius=r*Math.sqrt(t*e)/Math.sqrt(2073600),this._prepareHighPrecisionCameraPosition()}_singlePass(e,t){const s=this.renderingContext,i=this.renderingContext.gl,a=this.renderingContext.capabilities.drawBuffersIndexed;e.acquireColor(N,8,"gaussian depth output"),s.bindFramebuffer(e.fbo),s.setClearColor(0,0,0,0),s.clear(16384),this.renderingContext.bindTechnique(t,this.bindParameters,this._passParameters),a.enableiOES(i.BLEND,0),a.blendEquationSeparateiOES(0,i.FUNC_ADD,i.FUNC_ADD),a.blendFuncSeparateiOES(0,i.ONE_MINUS_DST_ALPHA,i.ONE,i.ONE_MINUS_DST_ALPHA,i.ONE),a.enableiOES(i.BLEND,1),a.blendEquationSeparateiOES(1,i.FUNC_ADD,i.FUNC_ADD),a.blendFuncSeparateiOES(1,i.ONE_MINUS_DST_ALPHA,i.DST_ALPHA,i.ONE_MINUS_DST_ALPHA,i.ONE),this.renderingContext.drawArraysInstanced(F.TRIANGLE_STRIP,0,4,this._data.visibleGaussians)}_multiPass(e,t,s,i){const{fullWidth:a,fullHeight:r}=this.bindParameters.camera,n=this.renderingContext;n.bindFramebuffer(e.fbo),n.setClearColor(0,0,0,0),n.clear(16384),this.renderingContext.bindTechnique(s,this.bindParameters,this._passParameters),this.renderingContext.drawArraysInstanced(F.TRIANGLE_STRIP,0,4,this._data.visibleGaussians);const o=this.fboCache.acquire(a,r,"gaussian depth output",8);return o.attachDepth(t),n.bindFramebuffer(o.fbo),n.setClearColor(0,0,0,0),n.clear(16384),this.renderingContext.bindTechnique(i,this.bindParameters,this._passParameters),this.renderingContext.drawArraysInstanced(F.TRIANGLE_STRIP,0,4,this._data.visibleGaussians),o}_prepareHighPrecisionCameraPosition(){o(this._passParameters.tileCameraPosition,this.camera.eye,1/I.tileSize),p(this._passParameters.tileCameraPosition,this._passParameters.tileCameraPosition),o(this._passParameters.cameraDelta,this._passParameters.tileCameraPosition,I.tileSize),r(this._passParameters.cameraDelta,this.camera.eye,this._passParameters.cameraDelta)}_handleFading(){if(0===this.fadeHelper.numFadingTiles)return void(this._previousFrameStart=null);this._previousFrameStart??=this.view.stage.renderer.renderContext.time;const e=this.view.stage?.renderer.renderContext.time-this._previousFrameStart;this.fadeHelper.updateAllTileFading(e),this._previousFrameStart=this.view.stage.renderer.renderContext.time,this._data.fadingTexture.updateTexture(this._data.textureAtlas.pageAllocator.pageCount)}static{this.tileSize=2.048}};function R(e){return null!=e.dist&&null!=e.point}e([s({constructOnly:!0})],H.prototype,"fadeHelper",void 0),H=I=e([i("esri.views.3d.webgl-engine.lib.GaussianSplatRenderNode")],H);class U{constructor(){this.point=null,this.dist=null,this.normal=null,this.layerViewUid=""}}export{H as GaussianSplatRenderNode};
@@ -2,4 +2,4 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{clamp as e,deg2rad as t}from"../../../../core/mathUtils.js";import{fromMat4 as i}from"../../../../core/libs/gl-matrix-2/math/mat3.js";import{create as s}from"../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{invert as r}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as a}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{set as n,rotate as o}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{fromValues as l,create as c}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{h as u,p as f,n as p,e as h,j as m,d,b as g,C as b,i as v,a as x,t as S,g as y}from"../../../../chunks/vec32.js";import{create as O,fromValues as z}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{fromArray as _,create as P,freeze as j}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{isMat4 as M}from"../../../../core/libs/gl-matrix-2/types/mat4.js";import{create as V}from"../../../../geometry/support/aaBoundingRect.js";import{BufferViewVec4u8 as C}from"../../../../geometry/support/buffer/BufferView.js";import{evaluateModelTransformScale as D}from"../../layers/support/FastSymbolUpdates.js";import{debugFlags as R}from"../../support/debugFlags.js";import{isColorHighlightOrOLID as A,isColor as w}from"../core/shaderLibrary/ShaderOutput.js";import{HUDVerticalPixelOffset as F}from"../core/shaderLibrary/hud/HUD.glsl.js";import{GLTextureMaterialBindParameters as T,GLTextureMaterial as L}from"../lib/GLTextureMaterial.js";import{Material as E}from"../lib/Material.js";import{SeparateScreenSizePerspectiveEvaluators as U}from"../lib/screenSizePerspectiveUtils.js";import{assert as B}from"../lib/Util.js";import{writePosition as I,writeNormal as q,writeColor as G,writeBufferVec2 as W,writeBufferFloat as H,writeBufferVec4 as N,writeBufferVec4Zeros as X,writeOlidColor as Y}from"./internal/bufferWriterUtils.js";import{verticalOffsetAtDistance as k}from"./internal/MaterialUtil.js";import{c as J,f as K}from"../../../../chunks/HUDMaterial.glsl.js";import{baseLayout as Q,getInstanceLayout as Z,HUDMaterialTechnique as $}from"../shaders/HUDMaterialTechnique.js";import{HUDMaterialTechniqueConfiguration as ee}from"../shaders/HUDMaterialTechniqueConfiguration.js";import{alphaCutoff as te}from"../../../../webscene/support/AlphaCutoff.js";class ie extends E{constructor(e,t){super(e,Ve),this.produces=new Map([[14,e=>A(e)&&!this.parameters.drawAsLabel],[15,e=>A(e)&&this.parameters.drawAsLabel],[13,()=>this.parameters.occlusionTest],[19,e=>this.parameters.draped&&A(e)]]),this._visible=!0,this._configuration=new ee(t)}getConfiguration(e,t){const i=this.parameters.draped;return super.getConfiguration(e,t,this._configuration),this._configuration.hasSlicePlane=this.parameters.hasSlicePlane,this._configuration.hasVerticalOffset=!!this.parameters.verticalOffset,this._configuration.hasScreenSizePerspective=!!this.parameters.screenSizePerspective,this._configuration.screenCenterOffsetUnitsEnabled="screen"===this.parameters.centerOffsetUnits,this._configuration.hasPolygonOffset=this.parameters.polygonOffset,this._configuration.draped=i,this._configuration.occlusionTestEnabled=this.parameters.occlusionTest,this._configuration.pixelSnappingEnabled=this.parameters.pixelSnappingEnabled,this._configuration.signedDistanceFieldEnabled=this.parameters.textureIsSignedDistanceField,this._configuration.sampleSignedDistanceFieldTexelCenter=this.parameters.sampleSignedDistanceFieldTexelCenter,this._configuration.hasRotation=this.parameters.hasRotation,this._configuration.hasVVSize=!!this.parameters.vvSize,this._configuration.hasVVColor=!!this.parameters.vvColor,this._configuration.occlusionPass=13===t.slot,this._configuration.occludedFragmentFade=!i&&this.parameters.occludedFragmentFade,this._configuration.horizonCullingEnabled=this.parameters.horizonCullingEnabled,this._configuration.isFocused=this.parameters.isFocused,this._configuration.depthTestEnabled=this.parameters.depthEnabled||13===t.slot,w(e)&&(this._configuration.debugDrawLabelBorder=!!R.LABELS_SHOW_BORDER),this._configuration.oitPass=t.oitPass,this._configuration.terrainDepthTest=t.terrainDepthTest,this._configuration.cullAboveTerrain=t.cullAboveTerrain,this._configuration}intersect(e,t,s,a,n,o){const{options:{selectionMode:l,hud:c,excludeLabels:v},point:x,camera:S}=s,{parameters:y}=this;if(!l||!c||v&&y.isLabel||!e.visible||!x||!S)return;const z=e.attributes.get("featureAttribute"),P=null==z?null:_(z.data,Oe),{scaleX:j,scaleY:M}=De(P,y,S.pixelRatio);i(ge,t),e.attributes.has("featureAttribute")&&ne(ge);const V=e.attributes.get("position"),C=e.attributes.get("size"),D=e.attributes.get("normal"),R=e.attributes.get("rotation"),A=e.attributes.get("centerOffsetAndDistance");B(V.size>=3);const w=J(y),F="screen"===this.parameters.centerOffsetUnits;for(let i=0;i<V.data.length/V.size;i++){const e=i*V.size;u(ce,V.data[e],V.data[e+1],V.data[e+2]),f(ce,ce,t),f(ce,ce,S.viewMatrix);const a=i*A.size;if(u(Se,A.data[a],A.data[a+1],A.data[a+2]),!F&&(ce[0]+=Se[0],ce[1]+=Se[1],0!==Se[2])){const e=Se[2];p(Se,ce),h(ce,ce,m(Se,Se,e))}const n=i*D.size;if(u(ue,D.data[n],D.data[n+1],D.data[n+2]),ae(ue,ge,S,ze),Re(this.parameters,ce,ze,S,le),S.applyProjection(ce,fe),fe[0]>-1){F&&(Se[0]||Se[1])&&(fe[0]+=Se[0]*S.pixelRatio,0!==Se[1]&&(fe[1]+=le.alignmentEvaluator.apply(Se[1])*S.pixelRatio),S.unapplyProjection(fe,ce)),fe[0]+=this.parameters.screenOffset[0]*S.pixelRatio,fe[1]+=this.parameters.screenOffset[1]*S.pixelRatio,fe[0]=Math.floor(fe[0]),fe[1]=Math.floor(fe[1]);const e=i*C.size;je[0]=C.data[e],je[1]=C.data[e+1],le.evaluator.applyVec2(je,je);const t=_e*S.pixelRatio;let a=0;if(y.textureIsSignedDistanceField){a=Math.min(y.outlineSize,.5*je[0])*S.pixelRatio/2}je[0]*=j,je[1]*=M;const n=i*R.size,l=y.rotation+R.data[n];if(oe(x,fe[0],fe[1],je,t,a,l,y,w)){const e=s.ray;if(f(he,ce,r(ve,S.viewMatrix)),fe[0]=x[0],fe[1]=x[1],S.unprojectFromRenderScreen(fe,ce)){const t=O();d(t,e.direction);const i=1/g(t);m(t,t,i);o(b(e.origin,ce)*i,t,-1,he)}}}}}intersectDraped(e,t,i,s,r){const a=e.attributes.get("position"),n=e.attributes.get("size"),o=e.attributes.get("rotation"),l=this.parameters,c=J(l),u=e.attributes.get("featureAttribute"),f=null==u?null:_(u.data,Oe),{scaleX:p,scaleY:h}=De(f,l,e.screenToWorldRatio),m=Pe*e.screenToWorldRatio;for(let d=0;d<a.data.length/a.size;d++){const t=d*a.size,u=a.data[t],f=a.data[t+1],g=d*n.size;je[0]=n.data[g],je[1]=n.data[g+1];let b=0;if(l.textureIsSignedDistanceField){b=Math.min(l.outlineSize,.5*je[0])*e.screenToWorldRatio/2}je[0]*=p,je[1]*=h;const v=d*o.size,x=l.rotation+o.data[v];oe(i,u,f,je,m,b,x,l,c)&&s(r.distance,r.normal,-1)}}createBufferWriter(){return new Ce}applyShaderOffsetsView(e,t,i,s,r,a,n){const o=ae(t,i,r,ze);return this._applyVerticalGroundOffsetView(e,o,r,n),Re(this.parameters,n,o,r,a),this._applyPolygonOffsetView(n,o,s[3],r,n),this._applyCenterOffsetView(n,s,n),n}applyShaderOffsetsNDC(e,t,i,s,r){return this._applyCenterOffsetNDC(e,t,i,s),null!=r&&d(r,s),this._applyPolygonOffsetNDC(s,t,i,s),s}_applyPolygonOffsetView(t,i,s,r,a){const n=r.aboveGround?1:-1;let o=Math.sign(s);0===o&&(o=n);const l=n*o;if(this.parameters.shaderPolygonOffset<=0)return d(a,t);const c=e(Math.abs(i.cosAngle),.01,1),u=1-Math.sqrt(1-c*c)/c/r.viewport[2];return m(a,t,l>0?u:1/u),a}_applyVerticalGroundOffsetView(e,t,i,s){const r=g(e),a=i.aboveGround?1:-1,n=i.computeRenderPixelSizeAtDist(r)*F,o=m(ce,t.normal,a*n);return v(s,e,o),s}_applyCenterOffsetView(e,t,i){const s="screen"!==this.parameters.centerOffsetUnits;return i!==e&&d(i,e),s&&(i[0]+=t[0],i[1]+=t[1],t[2]&&(p(ue,i),x(i,i,m(ue,ue,t[2])))),i}_applyCenterOffsetNDC(e,t,i,s){const r="screen"!==this.parameters.centerOffsetUnits;return s!==e&&d(s,e),r||(s[0]+=t[0]/i.fullWidth*2,s[1]+=t[1]/i.fullHeight*2),s}_applyPolygonOffsetNDC(e,t,i,s){const r=this.parameters.shaderPolygonOffset;if(e!==s&&d(s,e),r){const e=i.aboveGround?1:-1,a=e*Math.sign(t[3]);s[2]-=(a||e)*r}return s}set visible(e){this._visible=e}get visible(){const{color:e,outlineSize:t,outlineColor:i}=this.parameters,s=e[3]>=te||t>=te&&i[3]>=te;return this._visible&&s}createGLMaterial(e){return new se(e)}calculateRelativeScreenBounds(e,t,i=V()){return re(this.parameters,e,t,i),i[2]=i[0]+e[0],i[3]=i[1]+e[1],i}}class se extends L{constructor(e){super({...e,...e.material.parameters})}beginSlot(e){return this.updateTexture(this._material.parameters.textureId),this._material.setParameters(this.textureBindParameters),this.getTechnique($,e)}}function re(e,t,i,s){s[0]=e.anchorPosition[0]*-t[0]+e.screenOffset[0]*i,s[1]=e.anchorPosition[1]*-t[1]+e.screenOffset[1]*i}function ae(e,t,s,r){return M(t)&&(t=i(be,t)),S(r.normal,e,t),f(r.normal,r.normal,s.viewInverseTransposeMatrix),r.cosAngle=y(pe,Me),r}function ne(e){const t=e[0],i=e[1],s=e[2],r=e[3],a=e[4],n=e[5],o=e[6],l=e[7],c=e[8],u=1/Math.sqrt(t*t+i*i+s*s),f=1/Math.sqrt(r*r+a*a+n*n),p=1/Math.sqrt(o*o+l*l+c*c);return e[0]=t*u,e[1]=i*u,e[2]=s*u,e[3]=r*f,e[4]=a*f,e[5]=n*f,e[6]=o*p,e[7]=l*p,e[8]=c*p,e}function oe(e,i,s,r,a,l,c,u,f){let p=i-a-r[0]*f[0],h=p+r[0]+2*a,m=s-a-r[1]*f[1],d=m+r[1]+2*a;const g=u.distanceFieldBoundingBox;return u.textureIsSignedDistanceField&&null!=g&&(p+=r[0]*g[0],m+=r[1]*g[1],h-=r[0]*(1-g[2]),d-=r[1]*(1-g[3]),p-=l,h+=l,m-=l,d+=l),n(de,i,s),o(me,e,de,t(c)),me[0]>p&&me[0]<h&&me[1]>m&&me[1]<d}const le=new U,ce=O(),ue=O(),fe=P(),pe=O(),he=O(),me=c(),de=c(),ge=s(),be=s(),ve=a(),xe=P(),Se=O(),ye=O(),Oe=P(),ze={normal:pe,cosAngle:0},_e=1,Pe=2,je=l(0,0),Me=z(0,0,1);class Ve extends T{constructor(){super(...arguments),this.renderOccluded=1,this.isDecoration=!1,this.color=j(1,1,1,1),this.polygonOffset=!1,this.anchorPosition=l(.5,.5),this.screenOffset=[0,0],this.shaderPolygonOffset=1e-5,this.textureIsSignedDistanceField=!1,this.sampleSignedDistanceFieldTexelCenter=!1,this.outlineColor=j(1,1,1,1),this.outlineSize=0,this.distanceFieldBoundingBox=P(),this.rotation=0,this.hasRotation=!1,this.vvSizeEnabled=!1,this.vvSize=null,this.vvColor=null,this.vvOpacity=null,this.vvSymbolAnchor=null,this.vvSymbolRotationMatrix=null,this.hasSlicePlane=!1,this.pixelSnappingEnabled=!0,this.occlusionTest=!0,this.occludedFragmentFade=!1,this.horizonCullingEnabled=!1,this.centerOffsetUnits="world",this.drawAsLabel=!1,this.depthEnabled=!0,this.isFocused=!0,this.focusStyle="bright",this.draped=!1,this.isLabel=!1}get hasVVSize(){return!!this.vvSize}get hasVVColor(){return!!this.vvColor}get hasVVOpacity(){return!!this.vvOpacity}}class Ce{constructor(){this.layout=Q,this.instanceLayout=Z()}elementCount(e){return e.get("position").indices.length}elementCountBaseInstance(e){return e.get("uv0").indices.length}write(e,t,i,s,r,a){const{position:n,normal:o,color:l,size:c,rotation:u,centerOffsetAndDistance:f,featureAttribute:p,uvi:h}=r;I(i.get("position"),e,n,a),q(i.get("normal"),t,o,a);const m=i.get("position").indices.length;let d=0,g=0,b=K,v=K;const x=i.get("uvi")?.data;x&&x.length>=4&&(d=x[0],g=x[1],b=x[2],v=x[3]);for(let S=0;S<m;++S){const e=a+S;h.setValues(e,d,g,b,v)}if(G(i.get("color"),4,l,a),W(i.get("size"),c,a),H(i.get("rotation"),u,a),i.get("centerOffsetAndDistance")?N(i.get("centerOffsetAndDistance"),f,a):X(f,a,m),i.get("featureAttribute")?N(i.get("featureAttribute"),p,a):X(p,a,m),null!=s){const e=i.get("position")?.indices;if(e){const t=e.length,i=r.getField("olidColor",C);Y(s,i,t,a)}}return{numVerticesPerItem:1,numItems:m}}writeBaseInstance(e,t){const{uv0:i}=t;W(e.get("uv0"),i,0)}intersect(e,t,i,s,a,n,o){const{options:{selectionMode:l,hud:c,excludeLabels:x},point:S,camera:y}=s;if(!l||!c||x&&t.isLabel||!S)return;const z=this.instanceLayout.createView(e),{position:_,normal:P,rotation:j,size:M,featureAttribute:V,centerOffsetAndDistance:C}=z,D="screen"===t.centerOffsetUnits,R=J(t);if(null==_||null==P||null==j||null==M||null==C||null==y)return;const A=null==V?null:V.getVec(0,Oe),{scaleX:w,scaleY:F}=De(A,t,y.pixelRatio),T=_.count;for(let L=0;L<T;L++){if(_.getVec(L,ce),null!=i&&v(ce,ce,i),f(ce,ce,y.viewMatrix),C.getVec(L,xe),u(Se,xe[0],xe[1],xe[2]),!D&&(ce[0]+=Se[0],ce[1]+=Se[1],0!==Se[2])){const e=Se[2];p(Se,ce),h(ce,ce,m(Se,Se,e))}if(P.getVec(L,ue),ae(ue,ge,y,ze),Re(t,ce,ze,y,le),y.applyProjection(ce,fe),fe[0]>-1){D&&(Se[0]||Se[1])&&(fe[0]+=Se[0]*y.pixelRatio,0!==Se[1]&&(fe[1]+=le.alignmentEvaluator.apply(Se[1])*y.pixelRatio),y.unapplyProjection(fe,ce)),fe[0]+=t.screenOffset[0]*y.pixelRatio,fe[1]+=t.screenOffset[1]*y.pixelRatio,fe[0]=Math.floor(fe[0]),fe[1]=Math.floor(fe[1]),M.getVec(L,je),le.evaluator.applyVec2(je,je);const e=_e*y.pixelRatio;let i=0;if(t.textureIsSignedDistanceField){i=Math.min(t.outlineSize,.5*je[0])*y.pixelRatio/2}je[0]*=w,je[1]*=F;const a=j.get(L),n=t.rotation+a;if(oe(S,fe[0],fe[1],je,e,i,n,t,R)){const e=s.ray;if(f(he,ce,r(ve,y.viewMatrix)),fe[0]=S[0],fe[1]=S[1],y.unprojectFromRenderScreen(fe,ce)){const t=O();d(t,e.direction);const i=1/g(t);m(t,t,i);o(b(e.origin,ce)*i,t,L,he)}}}}}}function De(e,t,i){return null==e||null==t.vvSize?{scaleX:i,scaleY:i}:(D(ye,t,e),{scaleX:ye[0]*i,scaleY:ye[1]*i})}function Re(e,t,i,s,r){if(!e.verticalOffset?.screenLength){const s=g(t);return r.update(i.cosAngle,s,e.screenSizePerspective,e.screenSizePerspectiveMinPixelReferenceSize,e.screenSizePerspectiveAlignment,null),t}const a=g(t),n=e.screenSizePerspectiveAlignment??e.screenSizePerspective,o=k(s,a,e.verticalOffset,i.cosAngle,n,e.screenSizePerspectiveMinPixelReferenceSize);return r.update(i.cosAngle,a,e.screenSizePerspective,e.screenSizePerspectiveMinPixelReferenceSize,e.screenSizePerspectiveAlignment,null),m(i.normal,i.normal,o),v(t,t,i.normal)}export{ie as HUDMaterial,Ve as Parameters};
5
+ import{clamp as e,deg2rad as t}from"../../../../core/mathUtils.js";import{fromMat4 as i}from"../../../../core/libs/gl-matrix-2/math/mat3.js";import{create as s}from"../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{invert as r}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as a}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{set as n,rotate as o}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{fromValues as l,create as c}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{h as u,p as f,n as p,e as h,j as m,d,b as g,C as b,i as v,a as x,t as S,g as y}from"../../../../chunks/vec32.js";import{create as O,fromValues as z}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{fromArray as _,create as P,freeze as j}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{isMat4 as M}from"../../../../core/libs/gl-matrix-2/types/mat4.js";import{create as V}from"../../../../geometry/support/aaBoundingRect.js";import{BufferViewVec4u8 as C}from"../../../../geometry/support/buffer/BufferView.js";import{evaluateModelTransformScale as D}from"../../layers/support/FastSymbolUpdates.js";import{debugFlags as R}from"../../support/debugFlags.js";import{isColorHighlightOrOLID as A,isColor as w}from"../core/shaderLibrary/ShaderOutput.js";import{HUDVerticalPixelOffset as F}from"../core/shaderLibrary/hud/HUD.glsl.js";import{GLTextureMaterialBindParameters as T,GLTextureMaterial as E}from"../lib/GLTextureMaterial.js";import{Material as L}from"../lib/Material.js";import{SeparateScreenSizePerspectiveEvaluators as U}from"../lib/screenSizePerspectiveUtils.js";import{assert as B}from"../lib/Util.js";import{writePosition as I,writeNormal as q,writeColor as G,writeBufferVec2 as W,writeBufferFloat as H,writeBufferVec4 as N,writeBufferVec4Zeros as X,writeOlidColor as Y}from"./internal/bufferWriterUtils.js";import{verticalOffsetAtDistance as k}from"./internal/MaterialUtil.js";import{c as J,f as K}from"../../../../chunks/HUDMaterial.glsl.js";import{getInstanceLayout as Q,baseLayout as Z,HUDMaterialTechnique as $}from"../shaders/HUDMaterialTechnique.js";import{HUDMaterialTechniqueConfiguration as ee}from"../shaders/HUDMaterialTechniqueConfiguration.js";import{alphaCutoff as te}from"../../../../webscene/support/AlphaCutoff.js";class ie extends L{constructor(e,t){super(e,Ve),this.produces=new Map([[14,e=>A(e)&&!this.parameters.drawAsLabel],[15,e=>A(e)&&this.parameters.drawAsLabel],[13,()=>this.parameters.occlusionTest],[19,e=>this.parameters.draped&&A(e)]]),this._visible=!0,this._configuration=new ee(t)}getConfiguration(e,t){const i=this.parameters.draped;return super.getConfiguration(e,t,this._configuration),this._configuration.hasSlicePlane=this.parameters.hasSlicePlane,this._configuration.hasVerticalOffset=!!this.parameters.verticalOffset,this._configuration.hasScreenSizePerspective=!!this.parameters.screenSizePerspective,this._configuration.screenCenterOffsetUnitsEnabled="screen"===this.parameters.centerOffsetUnits,this._configuration.hasPolygonOffset=this.parameters.polygonOffset,this._configuration.draped=i,this._configuration.occlusionTestEnabled=this.parameters.occlusionTest,this._configuration.pixelSnappingEnabled=this.parameters.pixelSnappingEnabled,this._configuration.signedDistanceFieldEnabled=this.parameters.textureIsSignedDistanceField,this._configuration.sampleSignedDistanceFieldTexelCenter=this.parameters.sampleSignedDistanceFieldTexelCenter,this._configuration.hasRotation=this.parameters.hasRotation,this._configuration.hasVVSize=!!this.parameters.vvSize,this._configuration.hasVVColor=!!this.parameters.vvColor,this._configuration.occlusionPass=13===t.slot,this._configuration.occludedFragmentFade=!i&&this.parameters.occludedFragmentFade,this._configuration.horizonCullingEnabled=this.parameters.horizonCullingEnabled,this._configuration.isFocused=this.parameters.isFocused,this._configuration.depthTestEnabled=this.parameters.depthEnabled||13===t.slot,w(e)&&(this._configuration.debugDrawLabelBorder=!!R.LABELS_SHOW_BORDER),this._configuration.oitPass=t.oitPass,this._configuration.terrainDepthTest=t.terrainDepthTest,this._configuration.cullAboveTerrain=t.cullAboveTerrain,this._configuration}intersect(e,t,s,a,n,o){const{options:{selectionMode:l,hud:c,excludeLabels:v},point:x,camera:S}=s,{parameters:y}=this;if(!l||!c||v&&y.isLabel||!e.visible||!x||!S)return;const z=e.attributes.get("featureAttribute"),P=null==z?null:_(z.data,Oe),{scaleX:j,scaleY:M}=De(P,y,S.pixelRatio);i(ge,t),e.attributes.has("featureAttribute")&&ne(ge);const V=e.attributes.get("position"),C=e.attributes.get("size"),D=e.attributes.get("normal"),R=e.attributes.get("rotation"),A=e.attributes.get("centerOffsetAndDistance");B(V.size>=3);const w=J(y),F="screen"===this.parameters.centerOffsetUnits;for(let i=0;i<V.data.length/V.size;i++){const e=i*V.size;u(ce,V.data[e],V.data[e+1],V.data[e+2]),f(ce,ce,t),f(ce,ce,S.viewMatrix);const a=i*A.size;if(u(Se,A.data[a],A.data[a+1],A.data[a+2]),!F&&(ce[0]+=Se[0],ce[1]+=Se[1],0!==Se[2])){const e=Se[2];p(Se,ce),h(ce,ce,m(Se,Se,e))}const n=i*D.size;if(u(ue,D.data[n],D.data[n+1],D.data[n+2]),ae(ue,ge,S,ze),Re(this.parameters,ce,ze,S,le),S.applyProjection(ce,fe),fe[0]>-1){F&&(Se[0]||Se[1])&&(fe[0]+=Se[0]*S.pixelRatio,0!==Se[1]&&(fe[1]+=le.alignmentEvaluator.apply(Se[1])*S.pixelRatio),S.unapplyProjection(fe,ce)),fe[0]+=this.parameters.screenOffset[0]*S.pixelRatio,fe[1]+=this.parameters.screenOffset[1]*S.pixelRatio,fe[0]=Math.floor(fe[0]),fe[1]=Math.floor(fe[1]);const e=i*C.size;je[0]=C.data[e],je[1]=C.data[e+1],le.evaluator.applyVec2(je,je);const t=_e*S.pixelRatio;let a=0;if(y.textureIsSignedDistanceField){a=Math.min(y.outlineSize,.5*je[0])*S.pixelRatio/2}je[0]*=j,je[1]*=M;const n=i*R.size,l=y.rotation+R.data[n];if(oe(x,fe[0],fe[1],je,t,a,l,y,w)){const e=s.ray;if(f(he,ce,r(ve,S.viewMatrix)),fe[0]=x[0],fe[1]=x[1],S.unprojectFromRenderScreen(fe,ce)){const t=O();d(t,e.direction);const i=1/g(t);m(t,t,i);o(b(e.origin,ce)*i,t,-1,he)}}}}}intersectDraped(e,t,i,s,r){const a=e.attributes.get("position"),n=e.attributes.get("size"),o=e.attributes.get("rotation"),l=this.parameters,c=J(l),u=e.attributes.get("featureAttribute"),f=null==u?null:_(u.data,Oe),{scaleX:p,scaleY:h}=De(f,l,e.screenToWorldRatio),m=Pe*e.screenToWorldRatio;for(let d=0;d<a.data.length/a.size;d++){const t=d*a.size,u=a.data[t],f=a.data[t+1],g=d*n.size;je[0]=n.data[g],je[1]=n.data[g+1];let b=0;if(l.textureIsSignedDistanceField){b=Math.min(l.outlineSize,.5*je[0])*e.screenToWorldRatio/2}je[0]*=p,je[1]*=h;const v=d*o.size,x=l.rotation+o.data[v];oe(i,u,f,je,m,b,x,l,c)&&s(r.distance,r.normal,-1)}}createBufferWriter(){return new Ce}applyShaderOffsetsView(e,t,i,s,r,a,n){const o=ae(t,i,r,ze);return this._applyVerticalGroundOffsetView(e,o,r,n),Re(this.parameters,n,o,r,a),this._applyPolygonOffsetView(n,o,s[3],r,n),this._applyCenterOffsetView(n,s,n),n}applyShaderOffsetsNDC(e,t,i,s,r){return this._applyCenterOffsetNDC(e,t,i,s),null!=r&&d(r,s),this._applyPolygonOffsetNDC(s,t,i,s),s}_applyPolygonOffsetView(t,i,s,r,a){const n=r.aboveGround?1:-1;let o=Math.sign(s);0===o&&(o=n);const l=n*o;if(this.parameters.shaderPolygonOffset<=0)return d(a,t);const c=e(Math.abs(i.cosAngle),.01,1),u=1-Math.sqrt(1-c*c)/c/r.viewport[2];return m(a,t,l>0?u:1/u),a}_applyVerticalGroundOffsetView(e,t,i,s){const r=g(e),a=i.aboveGround?1:-1,n=i.computeRenderPixelSizeAtDist(r)*F,o=m(ce,t.normal,a*n);return v(s,e,o),s}_applyCenterOffsetView(e,t,i){const s="screen"!==this.parameters.centerOffsetUnits;return i!==e&&d(i,e),s&&(i[0]+=t[0],i[1]+=t[1],t[2]&&(p(ue,i),x(i,i,m(ue,ue,t[2])))),i}_applyCenterOffsetNDC(e,t,i,s){const r="screen"!==this.parameters.centerOffsetUnits;return s!==e&&d(s,e),r||(s[0]+=t[0]/i.fullWidth*2,s[1]+=t[1]/i.fullHeight*2),s}_applyPolygonOffsetNDC(e,t,i,s){const r=this.parameters.shaderPolygonOffset;if(e!==s&&d(s,e),r){const e=i.aboveGround?1:-1,a=e*Math.sign(t[3]);s[2]-=(a||e)*r}return s}set visible(e){this._visible=e}get visible(){const{color:e,outlineSize:t,outlineColor:i}=this.parameters,s=e[3]>=te||t>=te&&i[3]>=te;return this._visible&&s}createGLMaterial(e){return new se(e)}calculateRelativeScreenBounds(e,t,i=V()){return re(this.parameters,e,t,i),i[2]=i[0]+e[0],i[3]=i[1]+e[1],i}}class se extends E{constructor(e){super({...e,...e.material.parameters})}beginSlot(e){return this.updateTexture(this._material.parameters.textureId),this._material.setParameters(this.textureBindParameters),this.getTechnique($,e)}}function re(e,t,i,s){s[0]=e.anchorPosition[0]*-t[0]+e.screenOffset[0]*i,s[1]=e.anchorPosition[1]*-t[1]+e.screenOffset[1]*i}function ae(e,t,s,r){return M(t)&&(t=i(be,t)),S(r.normal,e,t),f(r.normal,r.normal,s.viewInverseTransposeMatrix),r.cosAngle=y(pe,Me),r}function ne(e){const t=e[0],i=e[1],s=e[2],r=e[3],a=e[4],n=e[5],o=e[6],l=e[7],c=e[8],u=1/Math.sqrt(t*t+i*i+s*s),f=1/Math.sqrt(r*r+a*a+n*n),p=1/Math.sqrt(o*o+l*l+c*c);return e[0]=t*u,e[1]=i*u,e[2]=s*u,e[3]=r*f,e[4]=a*f,e[5]=n*f,e[6]=o*p,e[7]=l*p,e[8]=c*p,e}function oe(e,i,s,r,a,l,c,u,f){let p=i-a-r[0]*f[0],h=p+r[0]+2*a,m=s-a-r[1]*f[1],d=m+r[1]+2*a;const g=u.distanceFieldBoundingBox;return u.textureIsSignedDistanceField&&null!=g&&(p+=r[0]*g[0],m+=r[1]*g[1],h-=r[0]*(1-g[2]),d-=r[1]*(1-g[3]),p-=l,h+=l,m-=l,d+=l),n(de,i,s),o(me,e,de,t(c)),me[0]>p&&me[0]<h&&me[1]>m&&me[1]<d}const le=new U,ce=O(),ue=O(),fe=P(),pe=O(),he=O(),me=c(),de=c(),ge=s(),be=s(),ve=a(),xe=P(),Se=O(),ye=O(),Oe=P(),ze={normal:pe,cosAngle:0},_e=1,Pe=2,je=l(0,0),Me=z(0,0,1);class Ve extends T{constructor(){super(...arguments),this.renderOccluded=1,this.isDecoration=!1,this.color=j(1,1,1,1),this.polygonOffset=!1,this.anchorPosition=l(.5,.5),this.screenOffset=[0,0],this.shaderPolygonOffset=1e-5,this.textureIsSignedDistanceField=!1,this.sampleSignedDistanceFieldTexelCenter=!1,this.outlineColor=j(1,1,1,1),this.outlineSize=0,this.distanceFieldBoundingBox=P(),this.rotation=0,this.hasRotation=!1,this.vvSizeEnabled=!1,this.vvSize=null,this.vvColor=null,this.vvOpacity=null,this.vvSymbolAnchor=null,this.vvSymbolRotationMatrix=null,this.hasSlicePlane=!1,this.pixelSnappingEnabled=!0,this.occlusionTest=!0,this.occludedFragmentFade=!1,this.horizonCullingEnabled=!1,this.centerOffsetUnits="world",this.drawAsLabel=!1,this.depthEnabled=!0,this.isFocused=!0,this.focusStyle="bright",this.draped=!1,this.isLabel=!1}get hasVVSize(){return!!this.vvSize}get hasVVColor(){return!!this.vvColor}get hasVVOpacity(){return!!this.vvOpacity}}class Ce{constructor(){this.layout=Q(),this.baseInstanceLayout=Z}elementCount(e){return e.get("position").indices.length}elementCountBaseInstance(e){return e.get("uv0").indices.length}write(e,t,i,s,r,a){const{position:n,normal:o,color:l,size:c,rotation:u,centerOffsetAndDistance:f,featureAttribute:p,uvi:h}=r;I(i.get("position"),e,n,a),q(i.get("normal"),t,o,a);const m=i.get("position").indices.length;let d=0,g=0,b=K,v=K;const x=i.get("uvi")?.data;x&&x.length>=4&&(d=x[0],g=x[1],b=x[2],v=x[3]);for(let S=0;S<m;++S){const e=a+S;h.setValues(e,d,g,b,v)}if(G(i.get("color"),4,l,a),W(i.get("size"),c,a),H(i.get("rotation"),u,a),i.get("centerOffsetAndDistance")?N(i.get("centerOffsetAndDistance"),f,a):X(f,a,m),i.get("featureAttribute")?N(i.get("featureAttribute"),p,a):X(p,a,m),null!=s){const e=i.get("position")?.indices;if(e){const t=e.length,i=r.getField("olidColor",C);Y(s,i,t,a)}}return{numVerticesPerItem:1,numItems:m}}writeBaseInstance(e,t){const{uv0:i}=t;W(e.get("uv0"),i,0)}intersect(e,t,i,s,a,n,o){const{options:{selectionMode:l,hud:c,excludeLabels:x},point:S,camera:y}=s;if(!l||!c||x&&t.isLabel||!S)return;const z=this.layout.createView(e),{position:_,normal:P,rotation:j,size:M,featureAttribute:V,centerOffsetAndDistance:C}=z,D="screen"===t.centerOffsetUnits,R=J(t);if(null==_||null==P||null==j||null==M||null==C||null==y)return;const A=null==V?null:V.getVec(0,Oe),{scaleX:w,scaleY:F}=De(A,t,y.pixelRatio),T=_.count;for(let E=0;E<T;E++){if(_.getVec(E,ce),null!=i&&v(ce,ce,i),f(ce,ce,y.viewMatrix),C.getVec(E,xe),u(Se,xe[0],xe[1],xe[2]),!D&&(ce[0]+=Se[0],ce[1]+=Se[1],0!==Se[2])){const e=Se[2];p(Se,ce),h(ce,ce,m(Se,Se,e))}if(P.getVec(E,ue),ae(ue,ge,y,ze),Re(t,ce,ze,y,le),y.applyProjection(ce,fe),fe[0]>-1){D&&(Se[0]||Se[1])&&(fe[0]+=Se[0]*y.pixelRatio,0!==Se[1]&&(fe[1]+=le.alignmentEvaluator.apply(Se[1])*y.pixelRatio),y.unapplyProjection(fe,ce)),fe[0]+=t.screenOffset[0]*y.pixelRatio,fe[1]+=t.screenOffset[1]*y.pixelRatio,fe[0]=Math.floor(fe[0]),fe[1]=Math.floor(fe[1]),M.getVec(E,je),le.evaluator.applyVec2(je,je);const e=_e*y.pixelRatio;let i=0;if(t.textureIsSignedDistanceField){i=Math.min(t.outlineSize,.5*je[0])*y.pixelRatio/2}je[0]*=w,je[1]*=F;const a=j.get(E),n=t.rotation+a;if(oe(S,fe[0],fe[1],je,e,i,n,t,R)){const e=s.ray;if(f(he,ce,r(ve,y.viewMatrix)),fe[0]=S[0],fe[1]=S[1],y.unprojectFromRenderScreen(fe,ce)){const t=O();d(t,e.direction);const i=1/g(t);m(t,t,i);o(b(e.origin,ce)*i,t,E,he)}}}}}}function De(e,t,i){return null==e||null==t.vvSize?{scaleX:i,scaleY:i}:(D(ye,t,e),{scaleX:ye[0]*i,scaleY:ye[1]*i})}function Re(e,t,i,s,r){if(!e.verticalOffset?.screenLength){const s=g(t);return r.update(i.cosAngle,s,e.screenSizePerspective,e.screenSizePerspectiveMinPixelReferenceSize,e.screenSizePerspectiveAlignment,null),t}const a=g(t),n=e.screenSizePerspectiveAlignment??e.screenSizePerspective,o=k(s,a,e.verticalOffset,i.cosAngle,n,e.screenSizePerspectiveMinPixelReferenceSize);return r.update(i.cosAngle,a,e.screenSizePerspective,e.screenSizePerspectiveMinPixelReferenceSize,e.screenSizePerspectiveAlignment,null),m(i.normal,i.normal,o),v(t,t,i.normal)}export{ie as HUDMaterial,Ve as Parameters};
@@ -2,4 +2,4 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{set as t,squaredDistance as e}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{create as s}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import r from"../lib/GLMaterial.js";import{Material as i}from"../lib/Material.js";import{writePosition as n,writeBufferFloat as a}from"./internal/bufferWriterUtils.js";import{attributeDrivenInstanceLayout as o,instanceLayout as u,HeatmapDensityPassParameters as c,HeatmapDensityTechnique as l,baseLayout as f}from"../shaders/HeatmapDensityTechnique.js";import{HeatmapDensityTechniqueConfiguration as m}from"../shaders/HeatmapDensityTechniqueConfiguration.js";const h=2;class p extends c{constructor(){super(...arguments),this.isAttributeDriven=!1,this.usesHalfFloats=!1}}class g extends i{constructor(t){super(t,p),this.visible=!0,this.produces=new Map([[19,t=>0===t]]),this._configuration=new m}getConfiguration(t,e){return super.getConfiguration(t,e,this._configuration),this._configuration.isAttributeDriven=this.parameters.isAttributeDriven,this._configuration.usesHalfFloat=this.parameters.usesHalfFloats,this._configuration}createGLMaterial(t){return new b(t)}intersect(){}intersectDraped(s,r,i,n,a){const o=s.attributes.get("position"),{parameters:u}=this,{searchRadius:c}=u,{screenToWorldRatio:l}=s,f=c*l+h*l,m=f*f,p=o.data.length/o.size;for(let h=0;h<p;h++){const s=h*o.size,r=t(v,o.data[s],o.data[s+1]);e(r,i)<m&&n(a.distance,a.normal,-1)}}createBufferWriter(){return new d(this.parameters.isAttributeDriven?o:u)}}class b extends r{beginSlot(t){return this.getTechnique(l,t)}}class d{constructor(t){this.instanceLayout=t,this.layout=f}elementCount(t){return t.get("position").indices.length}elementCountBaseInstance(){return 4}write(t,e,s,r,i,o){n(s.get("position"),t,i.position,o);const u="featureAttribute"in i?i.featureAttribute:null;return u&&a(s.get("featureAttribute"),u,o),null}writeBaseInstance(t,e){const s=e.uv0;s.setValues(0,-1,-1),s.setValues(1,-1,1),s.setValues(2,1,-1),s.setValues(3,1,1)}}const v=s();export{g as HeatmapDensityMaterial,p as Parameters};
5
+ import{set as t,squaredDistance as e}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{create as s}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import r from"../lib/GLMaterial.js";import{Material as i}from"../lib/Material.js";import{writePosition as n,writeBufferFloat as a}from"./internal/bufferWriterUtils.js";import{attributeDrivenInstanceLayout as o,instanceLayout as u,HeatmapDensityPassParameters as c,HeatmapDensityTechnique as l,baseLayout as f}from"../shaders/HeatmapDensityTechnique.js";import{HeatmapDensityTechniqueConfiguration as m}from"../shaders/HeatmapDensityTechniqueConfiguration.js";const h=2;class p extends c{constructor(){super(...arguments),this.isAttributeDriven=!1,this.usesHalfFloats=!1}}class g extends i{constructor(t){super(t,p),this.visible=!0,this.produces=new Map([[19,t=>0===t]]),this._configuration=new m}getConfiguration(t,e){return super.getConfiguration(t,e,this._configuration),this._configuration.isAttributeDriven=this.parameters.isAttributeDriven,this._configuration.usesHalfFloat=this.parameters.usesHalfFloats,this._configuration}createGLMaterial(t){return new b(t)}intersect(){}intersectDraped(s,r,i,n,a){const o=s.attributes.get("position"),{parameters:u}=this,{searchRadius:c}=u,{screenToWorldRatio:l}=s,f=c*l+h*l,m=f*f,p=o.data.length/o.size;for(let h=0;h<p;h++){const s=h*o.size,r=t(v,o.data[s],o.data[s+1]);e(r,i)<m&&n(a.distance,a.normal,-1)}}createBufferWriter(){return new d(this.parameters.isAttributeDriven?o:u)}}class b extends r{beginSlot(t){return this.getTechnique(l,t)}}class d{constructor(t){this.layout=t,this.baseInstanceLayout=f}elementCount(t){return t.get("position").indices.length}elementCountBaseInstance(){return 4}write(t,e,s,r,i,o){n(s.get("position"),t,i.position,o);const u="featureAttribute"in i?i.featureAttribute:null;return u&&a(s.get("featureAttribute"),u,o),null}writeBaseInstance(t,e){const s=e.uv0;s.setValues(0,-1,-1),s.setValues(1,-1,1),s.setValues(2,1,-1),s.setValues(3,1,1)}}const v=s();export{g as HeatmapDensityMaterial,p as Parameters};
@@ -2,4 +2,4 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import t from"../../../../../core/Accessor.js";import{removeUnordered as n,filterInPlace as s}from"../../../../../core/arrayUtils.js";import"../../../../../core/has.js";import{getOrCreateMapValue as r}from"../../../../../core/MapUtils.js";import{NestedMap as o}from"../../../../../core/NestedMap.js";import a from"../../../../../core/PooledArray.js";import{nullUid as l}from"../../../../../core/uid.js";import{property as i,subclass as u}from"../../../../../core/accessorSupport/decorators.js";import{assert as c}from"../../lib/Util.js";import{BufferRange as d,mergeAdjacentRanges as f}from"./BufferRange.js";import{Instance as h}from"./Instance.js";import{PerBaseInstanceData as m}from"./PerBaseInstanceData.js";import{PerBufferData as p,getTargetBuffer as g,hasVao as y}from"./PerBufferData.js";import{PerOriginData as v}from"./PerOriginData.js";import{VaoWriter as x}from"./VaoWriter.js";let _=class extends t{constructor(e){super(e),this._vaoWriter=null,this._useMetalWorkaround=!1,this._hasOccludees=!1}destroy(){this.uninitializeRenderContext()}initializeRenderContext(e){this._useMetalWorkaround=e.renderContext.rctx.isAssumedMetalDriver,this._vaoWriter=new x(this.material,e.renderContext.rctx)}uninitializeRenderContext(){this._useMetalWorkaround=!1,this._vaoWriter=null}get hasOccludees(){return this._hasOccludees}modify(e,t){this._applyUpdates(e,t),this._applyAddsAndRemoves(e),this._updateDrawCommands()}get canCompact(){for(const e of this.dataByBaseInstance.values())for(const t of e.dataByOrigin.values())if(t.buffers.some(e=>e.holesVertex.length>1))return!0;return!1}compact(e){if(!this.canCompact)return!1;let t=!1;for(const s of this.dataByBaseInstance.values())for(const r of s.dataByOrigin.values()){const o=new Array;for(let t=0;t<r.buffers.length&&!e.done;){const s=r.buffers[t];s.holesVertex.length<=1?++t:(s.instances.forEach(({geometry:e})=>o.push(e)),this._vaoWriter?.deleteBuffer(s),n(r.buffers,s,void 0,{last:t}),e.madeProgress())}if(o.length>0){const{baseInstanceData:e}=s;r.buffers.forEach(t=>this._applyAdds(e,t,o));const n=g(null!=e);for(;o.length>0;)r.buffers.push(this._applyAndRebuild(e,new p(n),o,null));t=!0}}return t}updateHighlights(e){this.highlightOrderMap=e;for(const t of this.dataByBaseInstance.values())for(const n of t.dataByOrigin.values())for(const t of n.buffers)t.updateHighlights(e)}_applyUpdates(e,t){const s=this._vaoWriter;if(null==s)return void e.clearUpdates();let r;const o=this._useMetalWorkaround?(e,t)=>{r??=new Map;let n=r.get(t);n||(n=[],r.set(t,n)),n.push(e)}:(e,t)=>s.updateInstance(e,t);for(const a of e.updates){if(t.done)return;const{renderGeometry:s,updateType:r}=a;n(e.pending.updates,a),t.madeProgress();const i=this.dataByBaseInstance.get(s.geometry.baseGeometry?.id??l),u=i?.dataByOrigin.get(s.localOrigin.id)?.findBuffer(s.id);if(null==u)return;const c=u.instances.get(s.id);6&r&&o(c,u),25&r&&(u.drawCommandsDirty=!0)}r&&s.updateInstancesMetal(r)}_computeDeltas(e,t){const n=new Map;for(const s of e){const e=s.localOrigin;if(null==e)continue;const t=s.geometry.baseGeometry,o=r(n,t??null,E);let a=o.get(e,null);null==a&&(a=new B(e.vec3,t),o.set(e,null,a)),a.changes.push(s)}for(const s of t){const e=s.localOrigin;if(null==e)continue;const t=s.geometry.baseGeometry,o=this.dataByBaseInstance.get(t?.id??l),a=o?.dataByOrigin.get(e.id)?.findBuffer(s.id);if(null==a)continue;const i=r(n,t??null,E);let u=i.get(e,a);null==u&&(u=new B(e.vec3,t),i.set(e,a,u)),u.changes.push(s)}return n}_applyAddsAndRemoves(e){const{_vaoWriter:t,dataByBaseInstance:s}=this;if(null==t)return void e.clearAddsAndRemoves();const o=this._computeDeltas(e.adds,e.removes);for(const[a,i]of o){const e=r(s,a?.id??l,()=>new m(t.createBaseInstanceData(a))),o=null!=a;for(const[s,a]of i.outerMap()){const l=a.get(null),u=l?.changes??[];i.delete(s,null);const d=r(e.dataByOrigin,s.id,()=>new v(s.vec3,o));for(const[r,o]of a){if(i.delete(s,r),null==r&&c(!1,"No VAO for removed geometries"),r.instances.size===o.changes.length){t.deleteBuffer(r),n(d.buffers,r),0===d.buffers.length&&0===u.length&&e.dataByOrigin.delete(s.id);continue}const a=r.numElementsVertex;switch(t.evaluateBufferAllocation(a,u,o.changes,r)){case 0:o.changes.forEach(({id:e})=>r.deleteInstance(e)),r.instances.forEach(({geometry:e})=>u.push(e)),t.deleteBuffer(r),n(d.buffers,r);break;case 1:this._applyAndRebuild(e.baseInstanceData,r,u,o);break;case 2:this._applyRemoves(r,o)}}if(u.length>0){const{baseInstanceData:t}=e,n=g(o);for(const e of d.buffers)this._applyAdds(t,e,u);for(;u.length>0;)d.buffers.push(this._applyAndRebuild(t,new p(n),u,null))}}0===e.dataByOrigin.size&&(e.dispose(),s.delete(e.id))}e.clearAddsAndRemoves()}_updateDrawCommands(){this._hasOccludees=!1;for(const e of this.dataByBaseInstance.values())for(const t of e.dataByOrigin.values())for(const e of t.buffers)e.updateIfDrawCommandsDirty(this.highlightOrderMap),this._hasOccludees||=e.hasOccludees}_applyAndRebuild(e,t,n,s){if(s)for(const c of s.changes)t.deleteInstance(c.id);const r=this._vaoWriter,o=r.maxElements(t.targetBuffer),a=r.maxElements("texture");let l=t.numElementsVertex,i=t.numElementsTexture;for(;n.length>0;){const e=n.pop(),s=r.vertexElementCount(e.geometry),u=r.textureElementCount(e.geometry);if(l+s>o&&l>0||i+u>a&&i>0){n.push(e);break}l+=s,i+=u;const d=new h(e,0,0,0,0,this.highlightOrderMap);c(null==t.instances.get(e.id)),t.addInstance(e.id,d)}t.resetInstanceSummary(),t.vao=r.reallocateBuffer(e,t,l),t.textureBuffer=r.reallocateTextureBuffer(t,i),t.vaoEndElement=r.endVertexElement(t),t.textureEndElement=r.endTextureElement(t);const[u,d]=r.rebuildInstances(l,i,t.writeableInstances.values(),t);t.updateInstances(),t.holesVertex.clear();const f=t.holesVertex.pushNew(),m=t.holesTexture.pushNew();return f.from=u,f.to=t.vaoEndElement,m.from=d,m.to=t.textureEndElement,t.updateDrawCommands(this.highlightOrderMap),t}_applyRemoves(e,t){const{_vaoWriter:n}=this;if(0===t.changes.length||null==n)return;let s=1/0,r=-1/0,o=1/0,a=-1/0;for(const l of t.changes){const t=l.id,n=e.instances.get(t);if(!n)continue;const{vertexBufferRange:i,textureBufferRange:u}=n;e.deleteInstance(t),this._useMetalWorkaround&&(s=Math.min(s,i.from),r=Math.max(r,i.to),o=Math.min(o,u.from),a=Math.max(a,u.to));const c=b.back();if(c&&c.to===i.from)c.to=i.to;else if(c&&c.from===i.to)c.from=i.from;else{const e=b.pushNew();e.from=i.from,e.to=i.to}const d=M.back();if(d&&d.to===u.from)d.to=u.to;else if(d&&d.from===u.to)d.from=u.from;else{const e=M.pushNew();e.from=u.from,e.to=u.to}}f(b),f(M),this._useMetalWorkaround?n.clearHolesMetal(e.instances.values(),s,r,o,a,e):(n.clearVertexHoles(b,e),n.clearTextureHoles(M,e)),e.holesVertex.pushArray(b.data,b.length),e.holesTexture.pushArray(M.data,M.length),b.forAll((e,t)=>b.data[t]=null),b.clear(),M.forAll((e,t)=>b.data[t]=null),M.clear(),e.drawCommandsDirty=!0}_applyAdds(e,t,n){if(0===n.length||null==this._vaoWriter)return;if(!y(t))return void this._applyAndRebuild(e,t,n,null);const r=this._vaoWriter,o=t.numElementsVertex,a=n.reduce((e,{geometry:t})=>e+r.vertexElementCount(t),0),l=Math.min(o+a,r.maxElements(t.targetBuffer)),i=t.numElementsTexture,u=n.reduce((e,{geometry:t})=>e+r.textureElementCount(t),0),c=Math.min(i+u,r.maxElements("texture"));if(r.canGrow(t,l,c))return void this._applyAndRebuild(e,t,n,null);f(t.holesVertex),f(t.holesTexture);const d=new Array,h=new Array;let m=1/0,p=-1/0,g=1/0,v=-1/0;for(const{geometry:s}of n){const e=r.vertexElementCount(s),n=r.textureElementCount(s),o=w(t.holesVertex,e),a=w(t.holesTexture,n);null!=o&&null!=a?(d.push(o),h.push(a),this._useMetalWorkaround&&(m=Math.min(m,o),p=Math.max(p,o+e),g=Math.min(g,a),v=Math.max(v,a+n))):(d.push(null),h.push(null))}const x=this._addInstances(n,t,d,h);if(this._useMetalWorkaround){for(const e of x);r.writeInstanceRangeMetal(p,m,v,g,t.instances.values(),t)}else r.writeRandomInstances(l,c,x,t);s(n,(e,t)=>null==d[t]||null==h[t])}*_addInstances(e,t,n,s){const r=e.length,o=this._vaoWriter;for(let a=0;a<r;++a){const r=n[a],l=s[a];if(null==r||null==l)continue;const i=e[a],u=o.vertexElementCount(i.geometry),d=o.textureElementCount(i.geometry),f=new h(i,r,r+u,l,l+d,this.highlightOrderMap);c(null==t.instances.get(i.id)),t.addInstance(i.id,f),t.drawCommandsDirty=!0,yield f}}static prune(){x.prune()}get test(){}};e([i({constructOnly:!0})],_.prototype,"dataByBaseInstance",void 0),e([i({constructOnly:!0})],_.prototype,"material",void 0),e([i()],_.prototype,"highlightOrderMap",void 0),_=e([u("esri.views.3d.webgl-engine.materials.renderers.MergedBuffer")],_);class B{constructor(e,t){this.origin=e,this.baseInstance=t,this.changes=new Array}}function w(e,t){if(0===t)return 0;const n=e.find(e=>e.numElements>=t);if(null==n)return null;const s=n.from;return n.from+=t,n.numElements<=0&&e.removeUnordered(n),s}const b=new a({allocator:e=>e??new d,deallocator:null}),M=new a({allocator:e=>e??new d,deallocator:null});function E(){return new o}export{_ as MergedBuffer};
5
+ import{__decorate as e}from"tslib";import t from"../../../../../core/Accessor.js";import{removeUnordered as n,filterInPlace as s}from"../../../../../core/arrayUtils.js";import"../../../../../core/has.js";import{getOrCreateMapValue as r}from"../../../../../core/MapUtils.js";import{NestedMap as o}from"../../../../../core/NestedMap.js";import a from"../../../../../core/PooledArray.js";import{nullUid as l}from"../../../../../core/uid.js";import{property as i,subclass as u}from"../../../../../core/accessorSupport/decorators.js";import{assert as c}from"../../lib/Util.js";import{BufferRange as d,mergeAdjacentRanges as f}from"./BufferRange.js";import{Instance as m}from"./Instance.js";import{PerBaseInstanceData as h}from"./PerBaseInstanceData.js";import{PerBufferData as p,hasVao as g}from"./PerBufferData.js";import{PerOriginData as y}from"./PerOriginData.js";import{VaoWriter as v}from"./VaoWriter.js";let x=class extends t{constructor(e){super(e),this._vaoWriter=null,this._useMetalWorkaround=!1,this._hasOccludees=!1}destroy(){this.uninitializeRenderContext()}initializeRenderContext(e){this._useMetalWorkaround=e.renderContext.rctx.isAssumedMetalDriver,this._vaoWriter=new v(this.material,e.renderContext.rctx)}uninitializeRenderContext(){this._useMetalWorkaround=!1,this._vaoWriter=null}get hasOccludees(){return this._hasOccludees}modify(e,t){this._applyUpdates(e,t),this._applyAddsAndRemoves(e),this._updateDrawCommands()}get canCompact(){for(const e of this.dataByBaseInstance.values())for(const t of e.dataByOrigin.values())if(t.buffers.some(e=>e.holesVertex.length>1))return!0;return!1}compact(e){if(!this.canCompact)return!1;let t=!1;for(const s of this.dataByBaseInstance.values())for(const r of s.dataByOrigin.values()){const o=new Array;for(let t=0;t<r.buffers.length&&!e.done;){const s=r.buffers[t];s.holesVertex.length<=1?++t:(s.instances.forEach(({geometry:e})=>o.push(e)),this._vaoWriter?.deleteBuffer(s),n(r.buffers,s,void 0,{last:t}),e.madeProgress())}if(o.length>0){const{baseInstanceData:e}=s;r.buffers.forEach(t=>this._applyAdds(e,t,o));const n=null!=e;for(;o.length>0;)r.buffers.push(this._applyAndRebuild(e,new p(n),o,null));t=!0}}return t}updateHighlights(e){this.highlightOrderMap=e;for(const t of this.dataByBaseInstance.values())for(const n of t.dataByOrigin.values())for(const t of n.buffers)t.updateHighlights(e)}_applyUpdates(e,t){const s=this._vaoWriter;if(null==s)return void e.clearUpdates();let r;const o=this._useMetalWorkaround?(e,t)=>{r??=new Map;let n=r.get(t);n||(n=[],r.set(t,n)),n.push(e)}:(e,t)=>s.updateInstance(e,t);for(const a of e.updates){if(t.done)return;const{renderGeometry:s,updateType:r}=a;n(e.pending.updates,a),t.madeProgress();const i=this.dataByBaseInstance.get(s.geometry.baseGeometry?.id??l),u=i?.dataByOrigin.get(s.localOrigin.id)?.findBuffer(s.id);if(null==u)return;const c=u.instances.get(s.id);6&r&&o(c,u),25&r&&(u.drawCommandsDirty=!0)}r&&s.updateInstancesMetal(r)}_computeDeltas(e,t){const n=new Map;for(const s of e){const e=s.localOrigin;if(null==e)continue;const t=s.geometry.baseGeometry,o=r(n,t??null,M);let a=o.get(e,null);null==a&&(a=new _(e.vec3,t),o.set(e,null,a)),a.changes.push(s)}for(const s of t){const e=s.localOrigin;if(null==e)continue;const t=s.geometry.baseGeometry,o=this.dataByBaseInstance.get(t?.id??l),a=o?.dataByOrigin.get(e.id)?.findBuffer(s.id);if(null==a)continue;const i=r(n,t??null,M);let u=i.get(e,a);null==u&&(u=new _(e.vec3,t),i.set(e,a,u)),u.changes.push(s)}return n}_applyAddsAndRemoves(e){const{_vaoWriter:t,dataByBaseInstance:s}=this;if(null==t)return void e.clearAddsAndRemoves();const o=this._computeDeltas(e.adds,e.removes);for(const[a,i]of o){const e=r(s,a?.id??l,()=>new h(t.createBaseInstanceData(a)));for(const[s,o]of i.outerMap()){const a=o.get(null),l=a?.changes??[];i.delete(s,null);const u=r(e.dataByOrigin,s.id,()=>new y(s.vec3));for(const[r,d]of o){if(i.delete(s,r),null==r&&c(!1,"No VAO for removed geometries"),r.instances.size===d.changes.length){t.deleteBuffer(r),n(u.buffers,r),0===u.buffers.length&&0===l.length&&e.dataByOrigin.delete(s.id);continue}const o=r.numElementsVertex;switch(t.evaluateBufferAllocation(o,l,d.changes,r)){case 0:d.changes.forEach(({id:e})=>r.deleteInstance(e)),r.instances.forEach(({geometry:e})=>l.push(e)),t.deleteBuffer(r),n(u.buffers,r);break;case 1:this._applyAndRebuild(e.baseInstanceData,r,l,d);break;case 2:this._applyRemoves(r,d)}}if(l.length>0){const{baseInstanceData:t}=e,n=null!=t;for(const e of u.buffers)this._applyAdds(t,e,l);for(;l.length>0;)u.buffers.push(this._applyAndRebuild(t,new p(n),l,null))}}0===e.dataByOrigin.size&&(e.dispose(),s.delete(e.id))}e.clearAddsAndRemoves()}_updateDrawCommands(){this._hasOccludees=!1;for(const e of this.dataByBaseInstance.values())for(const t of e.dataByOrigin.values())for(const e of t.buffers)e.updateIfDrawCommandsDirty(this.highlightOrderMap),this._hasOccludees||=e.hasOccludees}_applyAndRebuild(e,t,n,s){if(s)for(const c of s.changes)t.deleteInstance(c.id);const r=this._vaoWriter,o=r.maxElements("geometry"),a=r.maxElements("texture");let l=t.numElementsVertex,i=t.numElementsTexture;for(;n.length>0;){const e=n.pop(),s=r.vertexElementCount(e.geometry),u=r.textureElementCount(e.geometry);if(l+s>o&&l>0||i+u>a&&i>0){n.push(e);break}l+=s,i+=u;const d=new m(e,0,0,0,0,this.highlightOrderMap);c(null==t.instances.get(e.id)),t.addInstance(e.id,d)}t.resetInstanceSummary(),t.vao=r.reallocateBuffer(e,t,l),t.textureBuffer=r.reallocateTextureBuffer(t,i),t.vaoEndElement=r.endVertexElement(t),t.textureEndElement=r.endTextureElement(t);const[u,d]=r.rebuildInstances(l,i,t.writeableInstances.values(),t);t.updateInstances(),t.holesVertex.clear();const f=t.holesVertex.pushNew(),h=t.holesTexture.pushNew();return f.from=u,f.to=t.vaoEndElement,h.from=d,h.to=t.textureEndElement,t.updateDrawCommands(this.highlightOrderMap),t}_applyRemoves(e,t){const{_vaoWriter:n}=this;if(0===t.changes.length||null==n)return;let s=1/0,r=-1/0,o=1/0,a=-1/0;for(const l of t.changes){const t=l.id,n=e.instances.get(t);if(!n)continue;const{vertexBufferRange:i,textureBufferRange:u}=n;e.deleteInstance(t),this._useMetalWorkaround&&(s=Math.min(s,i.from),r=Math.max(r,i.to),o=Math.min(o,u.from),a=Math.max(a,u.to));const c=w.back();if(c&&c.to===i.from)c.to=i.to;else if(c&&c.from===i.to)c.from=i.from;else{const e=w.pushNew();e.from=i.from,e.to=i.to}const d=b.back();if(d&&d.to===u.from)d.to=u.to;else if(d&&d.from===u.to)d.from=u.from;else{const e=b.pushNew();e.from=u.from,e.to=u.to}}f(w),f(b),this._useMetalWorkaround?n.clearHolesMetal(e.instances.values(),s,r,o,a,e):(n.clearVertexHoles(w,e),n.clearTextureHoles(b,e)),e.holesVertex.pushArray(w.data,w.length),e.holesTexture.pushArray(b.data,b.length),w.forAll((e,t)=>w.data[t]=null),w.clear(),b.forAll((e,t)=>w.data[t]=null),b.clear(),e.drawCommandsDirty=!0}_applyAdds(e,t,n){if(0===n.length||null==this._vaoWriter)return;if(!g(t))return void this._applyAndRebuild(e,t,n,null);const r=this._vaoWriter,o=t.numElementsVertex,a=n.reduce((e,{geometry:t})=>e+r.vertexElementCount(t),0),l=Math.min(o+a,r.maxElements("geometry")),i=t.numElementsTexture,u=n.reduce((e,{geometry:t})=>e+r.textureElementCount(t),0),c=Math.min(i+u,r.maxElements("texture"));if(r.canGrow(t,l,c))return void this._applyAndRebuild(e,t,n,null);f(t.holesVertex),f(t.holesTexture);const d=new Array,m=new Array;let h=1/0,p=-1/0,y=1/0,v=-1/0;for(const{geometry:s}of n){const e=r.vertexElementCount(s),n=r.textureElementCount(s),o=B(t.holesVertex,e),a=B(t.holesTexture,n);null!=o&&null!=a?(d.push(o),m.push(a),this._useMetalWorkaround&&(h=Math.min(h,o),p=Math.max(p,o+e),y=Math.min(y,a),v=Math.max(v,a+n))):(d.push(null),m.push(null))}const x=this._addInstances(n,t,d,m);if(this._useMetalWorkaround){for(const e of x);r.writeInstanceRangeMetal(p,h,v,y,t.instances.values(),t)}else r.writeRandomInstances(l,c,x,t);s(n,(e,t)=>null==d[t]||null==m[t])}*_addInstances(e,t,n,s){const r=e.length,o=this._vaoWriter;for(let a=0;a<r;++a){const r=n[a],l=s[a];if(null==r||null==l)continue;const i=e[a],u=o.vertexElementCount(i.geometry),d=o.textureElementCount(i.geometry),f=new m(i,r,r+u,l,l+d,this.highlightOrderMap);c(null==t.instances.get(i.id)),t.addInstance(i.id,f),t.drawCommandsDirty=!0,yield f}}static prune(){v.prune()}get test(){}};e([i({constructOnly:!0})],x.prototype,"dataByBaseInstance",void 0),e([i({constructOnly:!0})],x.prototype,"material",void 0),e([i()],x.prototype,"highlightOrderMap",void 0),x=e([u("esri.views.3d.webgl-engine.materials.renderers.MergedBuffer")],x);class _{constructor(e,t){this.origin=e,this.baseInstance=t,this.changes=new Array}}function B(e,t){if(0===t)return 0;const n=e.find(e=>e.numElements>=t);if(null==n)return null;const s=n.from;return n.from+=t,n.numElements<=0&&e.removeUnordered(n),s}const w=new a({allocator:e=>e??new d,deallocator:null}),b=new a({allocator:e=>e??new d,deallocator:null});function M(){return new o}export{x as MergedBuffer};
@@ -2,4 +2,4 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{getOrCreateMapValue as t}from"../../../../../core/MapUtils.js";import e from"../../../../../core/PooledArray.js";import{BufferRange as s}from"./BufferRange.js";import{DrawCommand as n}from"./DrawCommand.js";import{InstancedCommandVAO as a}from"./InstancedCommandVAO.js";import{InstancedCommandVAOs as i}from"./InstancedCommandVAOs.js";import{defaultHighlightName as r}from"../../../../support/HighlightDefaults.js";class o{constructor(t){this.targetBuffer=t,this.vao=null,this.textureBuffer=null,this.vaoEndElement=0,this.textureEndElement=0,this._numElementsVertex=0,this._numElementsTexture=0,this._instances=new Map,this.holesVertex=new e({allocator:t=>t??new s,deallocator:null}),this.holesTexture=new e({allocator:t=>t??new s,deallocator:null}),this.hasHiddenInstances=!1,this.hasOccludees=!1,this.drawCommandsDirty=!0,this.highlightNames=new Set,this.drawCommandsDefault=d(),this.drawCommandsHighlights=new Map,this.drawCommandsOccludees=d(),this.drawCommandsShadowHighlightRest=d(),this._instancedCommandVAOs=null}get numElementsVertex(){return this._numElementsVertex}get numElementsTexture(){return this._numElementsTexture}get instances(){return this._instances}get writeableInstances(){return this._instances}get hasHighlights(){return this.highlightNames.size>0}get instancedCommandVAOs(){return this._instancedCommandVAOs}resetInstanceSummary(){this.hasHiddenInstances=!1,this.hasOccludees=!1,this.highlightNames.clear()}updateIfDrawCommandsDirty(t){if(this.drawCommandsDirty){this.resetInstanceSummary();for(const t of this.instances.values())this.updateDrawState(t);this.updateDrawCommands(t)}}addInstance(t,e){this.deleteInstance(t),this._instances.set(t,e),this._numElementsVertex+=e.vertexBufferRange.numElements,this._numElementsTexture+=e.textureBufferRange.numElements}deleteInstance(t){const e=this._instances.get(t);e&&(this._numElementsVertex-=e.vertexBufferRange.numElements,this._numElementsTexture-=e.textureBufferRange.numElements,this._instances.delete(t))}updateInstances(){let t=0,e=0;for(const s of this._instances.values())t+=s.vertexBufferRange.numElements,e+=s.textureBufferRange.numElements,this.updateDrawState(s);this._numElementsVertex=t,this._numElementsTexture=e}updateDrawState(t){if(t.isVisible){const{highlightName:e}=t;e&&this.highlightNames.add(e),t.hasOccludees&&(this.hasOccludees=!0)}else this.hasHiddenInstances=!0}updateDrawCommands(t){this._updateDrawCommands(t),this._updateInstancedCommandVAOs()}_updateDrawCommands(t){if(this.drawCommandsDefault.clear(),this.drawCommandsOccludees.clear(),this.drawCommandsDirty=!1,0===this._instances.size)return;const{sortedInstances:e}=this;if(this._updateHighlightDrawCommands(t,e),!this.needsMultipleCommands){const t=this.drawCommandsDefault.pushNew(),e=this.holesVertex.front();return this.vao&&1===this.holesVertex.length&&e.to===this.vaoEndElement?(t.first=0,void(t.count=e.from)):(t.first=1/0,t.count=0,this._instances.forEach(e=>{t.first=Math.min(t.first,e.vertexBufferRange.from),t.count=Math.max(t.count,e.vertexBufferRange.to)}),void(t.count-=t.first))}for(const s of e)s.isVisible&&u(s.hasOccludees?this.drawCommandsOccludees:this.drawCommandsDefault,s)}get sortedInstances(){return Array.from(this._instances.values()).sort(({vertexBufferRange:t},{vertexBufferRange:e})=>t.from===e.from?t.to-e.to:t.from-e.from)}updateHighlights(t){this.highlightNames.clear();const e=this.sortedInstances;for(const s of e)s.updateHighlightOptions(t),s.isVisible&&s.highlightName&&this.highlightNames.add(s.highlightName);this._updateHighlightDrawCommands(t,e),this._updateInstancedCommandVAOs()}_updateHighlightDrawCommands(e,s){const{drawCommandsHighlights:n,drawCommandsShadowHighlightRest:a}=this;n.clear(),a.clear();for(const i of s){if(i.updateHighlightOptions(e),!i.isVisible)continue;const{highlightName:s}=i;if(s){this.highlightNames.add(s);u(t(n,s,d),i)}s&&s===r||u(a,i)}}_updateInstancedCommandVAOs(){const t=this.vao;if("geometry"===this.targetBuffer||null==t)return;this._instancedCommandVAOs??=new i;const e=this._instancedCommandVAOs,s=e.commandVAOs.copy();e.clear();const n=e.commandVAOs,r=(e,i)=>{for(const r of e){const{first:e,count:o}=r,h=n.get(e,o)??s.pop(e,o)??new a(t.shallowCloneWithBaseInstances(new Map([["instances",r.first]])),r.count);n.set(e,o,h),i.push(h)}};r(this.drawCommandsDefault,e.drawCommandsDefault);for(const[a,i]of this.drawCommandsHighlights){const t=new Array;r(i,t),e.drawCommandsHighlights.set(a,t)}r(this.drawCommandsOccludees,e.drawCommandsOccludees),r(this.drawCommandsShadowHighlightRest,e.drawCommandsShadowHighlightRest);for(const a of s.values())a.dispose();s.clear()}get needsMultipleCommands(){return this.hasOccludees||this.hasHighlights||this.hasHiddenInstances}}function h(t){return null!=t.vao}function m(t){return t?"instances":"geometry"}function d(){return new e({allocator:t=>t||new n,deallocator:t=>t})}function u(t,{vertexBufferRange:e}){const s=t.back();if(null==s){const s=t.pushNew();return s.first=e.from,void(s.count=e.numElements)}if(l(s,e)){const t=e.from-s.first+e.numElements;s.count=t}else{const s=t.pushNew();s.first=e.from,s.count=e.numElements}}function l(t,e){return t.first+t.count>=e.from}export{o as PerBufferData,m as getTargetBuffer,h as hasVao};
5
+ import{getOrCreateMapValue as t}from"../../../../../core/MapUtils.js";import e from"../../../../../core/PooledArray.js";import{BufferRange as s}from"./BufferRange.js";import{DrawCommand as n}from"./DrawCommand.js";import{InstancedCommandVAO as a}from"./InstancedCommandVAO.js";import{InstancedCommandVAOs as i}from"./InstancedCommandVAOs.js";import{defaultHighlightName as r}from"../../../../support/HighlightDefaults.js";class o{constructor(t){this.isInstanced=t,this.vao=null,this.textureBuffer=null,this.vaoEndElement=0,this.textureEndElement=0,this._numElementsVertex=0,this._numElementsTexture=0,this._instances=new Map,this.holesVertex=new e({allocator:t=>t??new s,deallocator:null}),this.holesTexture=new e({allocator:t=>t??new s,deallocator:null}),this.hasHiddenInstances=!1,this.hasOccludees=!1,this.drawCommandsDirty=!0,this.highlightNames=new Set,this.drawCommandsDefault=m(),this.drawCommandsHighlights=new Map,this.drawCommandsOccludees=m(),this.drawCommandsShadowHighlightRest=m(),this._instancedCommandVAOs=null}dispose(){this.isInstanced?(this.vao?.buffer("geometry")?.dispose(),this.vao?.disposeVAOOnly(),this.instancedCommandVAOs?.dispose()):this.vao?.dispose(),this.textureBuffer?.dispose()}get numElementsVertex(){return this._numElementsVertex}get numElementsTexture(){return this._numElementsTexture}get instances(){return this._instances}get writeableInstances(){return this._instances}get hasHighlights(){return this.highlightNames.size>0}get instancedCommandVAOs(){return this._instancedCommandVAOs}resetInstanceSummary(){this.hasHiddenInstances=!1,this.hasOccludees=!1,this.highlightNames.clear()}updateIfDrawCommandsDirty(t){if(this.drawCommandsDirty){this.resetInstanceSummary();for(const t of this.instances.values())this.updateDrawState(t);this.updateDrawCommands(t)}}addInstance(t,e){this.deleteInstance(t),this._instances.set(t,e),this._numElementsVertex+=e.vertexBufferRange.numElements,this._numElementsTexture+=e.textureBufferRange.numElements}deleteInstance(t){const e=this._instances.get(t);e&&(this._numElementsVertex-=e.vertexBufferRange.numElements,this._numElementsTexture-=e.textureBufferRange.numElements,this._instances.delete(t))}updateInstances(){let t=0,e=0;for(const s of this._instances.values())t+=s.vertexBufferRange.numElements,e+=s.textureBufferRange.numElements,this.updateDrawState(s);this._numElementsVertex=t,this._numElementsTexture=e}updateDrawState(t){if(t.isVisible){const{highlightName:e}=t;e&&this.highlightNames.add(e),t.hasOccludees&&(this.hasOccludees=!0)}else this.hasHiddenInstances=!0}updateDrawCommands(t){this._updateDrawCommands(t),this._updateInstancedCommandVAOs()}_updateDrawCommands(t){if(this.drawCommandsDefault.clear(),this.drawCommandsOccludees.clear(),this.drawCommandsDirty=!1,0===this._instances.size)return;const{sortedInstances:e}=this;if(this._updateHighlightDrawCommands(t,e),!this.needsMultipleCommands){const t=this.drawCommandsDefault.pushNew(),e=this.holesVertex.front();return this.vao&&1===this.holesVertex.length&&e.to===this.vaoEndElement?(t.first=0,void(t.count=e.from)):(t.first=1/0,t.count=0,this._instances.forEach(e=>{t.first=Math.min(t.first,e.vertexBufferRange.from),t.count=Math.max(t.count,e.vertexBufferRange.to)}),void(t.count-=t.first))}for(const s of e)s.isVisible&&d(s.hasOccludees?this.drawCommandsOccludees:this.drawCommandsDefault,s)}get sortedInstances(){return Array.from(this._instances.values()).sort(({vertexBufferRange:t},{vertexBufferRange:e})=>t.from===e.from?t.to-e.to:t.from-e.from)}updateHighlights(t){this.highlightNames.clear();const e=this.sortedInstances;for(const s of e)s.updateHighlightOptions(t),s.isVisible&&s.highlightName&&this.highlightNames.add(s.highlightName);this._updateHighlightDrawCommands(t,e),this._updateInstancedCommandVAOs()}_updateHighlightDrawCommands(e,s){const{drawCommandsHighlights:n,drawCommandsShadowHighlightRest:a}=this;n.clear(),a.clear();for(const i of s){if(i.updateHighlightOptions(e),!i.isVisible)continue;const{highlightName:s}=i;if(s){this.highlightNames.add(s);d(t(n,s,m),i)}s&&s===r||d(a,i)}}_updateInstancedCommandVAOs(){const t=this.vao;if(!this.isInstanced||null==t)return;this._instancedCommandVAOs??=new i;const e=this._instancedCommandVAOs,s=e.commandVAOs.copy();e.clear();const n=e.commandVAOs,r=(e,i)=>{for(const r of e){const{first:e,count:o}=r,h=n.get(e,o)??s.pop(e,o)??new a(t.shallowCloneWithBaseInstances(new Map([["geometry",r.first]])),r.count);n.set(e,o,h),i.push(h)}};r(this.drawCommandsDefault,e.drawCommandsDefault);for(const[a,i]of this.drawCommandsHighlights){const t=new Array;r(i,t),e.drawCommandsHighlights.set(a,t)}r(this.drawCommandsOccludees,e.drawCommandsOccludees),r(this.drawCommandsShadowHighlightRest,e.drawCommandsShadowHighlightRest);for(const a of s.values())a.dispose();s.clear()}get needsMultipleCommands(){return this.hasOccludees||this.hasHighlights||this.hasHiddenInstances}}function h(t){return null!=t.vao}function m(){return new e({allocator:t=>t||new n,deallocator:t=>t})}function d(t,{vertexBufferRange:e}){const s=t.back();if(null==s){const s=t.pushNew();return s.first=e.from,void(s.count=e.numElements)}if(u(s,e)){const t=e.from-s.first+e.numElements;s.count=t}else{const s=t.pushNew();s.first=e.from,s.count=e.numElements}}function u(t,e){return t.first+t.count>=e.from}export{o as PerBufferData,h as hasVao};
@@ -2,4 +2,4 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- class s{constructor(s,e){this.origin=s,this.isInstanced=e,this.buffers=new Array}dispose(){if(this.isInstanced)for(const s of this.buffers)s.vao.buffer("instances")?.dispose(),s.vao.disposeVAOOnly(),s.instancedCommandVAOs?.dispose(),s.textureBuffer?.dispose();else for(const s of this.buffers)s.vao.dispose(),s.textureBuffer?.dispose();this.buffers.length=0}findBuffer(s){return this.buffers.find(e=>e.instances.has(s))}}export{s as PerOriginData};
5
+ class s{constructor(s){this.origin=s,this.buffers=new Array}dispose(){for(const s of this.buffers)s.dispose();this.buffers.length=0}findBuffer(s){return this.buffers.find(f=>f.instances.has(s))}}export{s as PerOriginData};
@@ -2,4 +2,4 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{nextHighestPowerOfTwo as e}from"../../../../../core/mathUtils.js";import{disposeMaybe as t}from"../../../../../core/maybe.js";import{copy as r,invert as u,transpose as a}from"../../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as f}from"../../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{glLayout as n}from"../../../support/buffer/glUtil.js";import{assert as s}from"../../lib/Util.js";import{VertexArrayObject as o}from"../../lib/VertexArrayObject.js";import{getMaxItemCount as i,getMaxByteSize as c}from"../../lib/TextureBackedBuffer/TextureBackedBufferUtils.js";import{TextureBuffer as l}from"../../lib/TextureBackedBuffer/TextureBuffer.js";import{DrawCommand as m}from"./DrawCommand.js";import{BaseInstanceData as g}from"./PerBaseInstanceData.js";import{VertexBuffer as h}from"../../../../webgl/VertexBuffer.js";class B{constructor(e,t){this._rctx=t,this._bufferWriter=e.createBufferWriter(),this._vaoCache=t.getVaoCache(n(this._bufferWriter.layout))}maxElements(e){if("texture"===e){const e=this._targetLayout("texture");return null==e?0:i(this._rctx,e)}return Math.floor(d/this._targetStrideBytes(e))}_targetStrideBytes(e){return this._targetLayout(e)?.stride??0}_targetLayout(e){return"geometry"===e?this._bufferWriter.layout:"instances"===e?this._bufferWriter.instanceLayout:this._bufferWriter.textureBufferLayout}endVertexElement(e){return Math.floor((e.vao?.getByteLength(e.targetBuffer)??0)/this._targetStrideBytes(e.targetBuffer))}endTextureElement({textureBuffer:e}){return e?.itemCount??0}evaluateBufferAllocation(e,t,r,u){const a=this._targetStrideBytes(u.targetBuffer),f=t.reduce((e,{geometry:t})=>e+this.vertexElementCount(t),0),n=r.reduce((e,{geometry:t})=>e+this.vertexElementCount(t),0),s=Math.min((e+f-n)*a,d),o=u.vao?.buffer(u.targetBuffer),i=o?.sizeBytes??0;return s>b&&s<i/2?0:s>i?1:2}deleteBuffer(e){if("instances"===e.targetBuffer)return e.instancedCommandVAOs?.dispose(),e.vao?.buffer("instances")?.dispose(),e.vao?.disposeVAOOnly(),void(e.vao=null);this._vaoCache.deleteVao(e.vao),e.vaoEndElement=0}deleteTextureBuffer(e){e.textureBuffer=t(e.textureBuffer),e.textureEndElement=0}createBaseInstanceData(e){const{_bufferWriter:t}=this;if(null==e||null==t.writeBaseInstance||null==t.elementCountBaseInstance)return null;const r=t.layout,u=t.elementCountBaseInstance(e.attributes),a=u*this._targetStrideBytes("geometry"),f=new h(this._rctx,n(r));f.setSize(Math.ceil(a));const s=S(a),o=r.createView(s.buffer);t.writeBaseInstance(e.attributes,o),f.setSubData(s,0,0,a);const i=new m;return i.first=0,i.count=u,new g(e,f,i)}_allocateInstanceBuffer(e){const t=this._bufferWriter.instanceLayout;s(null!=t,"Trying to allocate an instance buffer, but the BufferWriter does not support instancing");const r=e*this._targetStrideBytes("instances"),u=new h(this._rctx,n(t,1));return u.setSize(v(r)),u}_createInstancedVao(e,t){return new o(this._rctx,new Map([["geometry",e],["instances",t]]))}reallocateBuffer(e,t,r){if(this.deleteBuffer(t),null!=e){const t=e.baseInstanceBuffer,u=this._allocateInstanceBuffer(r);return this._createInstancedVao(t,u)}const u=r*this._targetStrideBytes("geometry");return this._vaoCache.newVao(v(u))}reallocateTextureBuffer(e,t){this.deleteTextureBuffer(e);const r=this._targetLayout("texture");return null!=r?new l(this._rctx,r,t):null}vertexElementCount(e){return this._bufferWriter.elementCount(e.attributes)}textureElementCount(e){return this._bufferWriter.elementCountTextureBuffer?.(e.attributes)??0}canGrow(e,t,r){const{targetBuffer:u,vao:a,textureBuffer:f}=e;if(null==a)return!0;const n=t*this._targetStrideBytes(u),s=a.getByteLength(u)<v(d-b)&&n>a.getByteLength(u),o=this._targetLayout("texture");if(!s||null==o||null==f)return s;const i=r*o.byteStride,l=f.byteLength;return l<c(this._rctx,o)&&i>l}clearVertexHoles(e,{vao:t,targetBuffer:r}){const u=this._targetStrideBytes(r),a=e.reduce((e,t)=>Math.max(e,t.numElements),0)*u,f=S(a);f.fill(0,0,a);const n=t.buffer(r);for(const s of e)n?.setSubData(f,s.from*u,0,s.numElements*u)}clearTextureHoles(e,{textureBuffer:t}){const r=this._targetLayout("texture");if(null==t||null==r)return;const u=r.byteStride,a=e.reduce((e,t)=>Math.max(e,t.numElements),0)*u,f=S(a);f.fill(0,0,a);for(const n of e)t.setSubData(f.buffer,n.from,0,n.numElements)}clearHolesMetal(e,t,r,u,a,{vao:f,targetBuffer:n,textureBuffer:s}){const o=this._targetLayout(n),i=this._targetStrideBytes(n),c=(r-t)*i,l=this._targetLayout("texture"),m=(a-u)*this._targetStrideBytes("texture"),g=c+m,h=c,B=S(g),y=o.createView(B.buffer),x=l?.createView(B.buffer,h);B.fill(0,0,g);for(const b of e){const{vertexBufferRange:e,textureBufferRange:a}=b;if(!(e.from>=t&&e.to<=r))continue;const f=e.from-t,n=a.from-u;this._writeGeometry(b.geometry,y,x,f,n,a)}f.buffer(n)?.setSubData(B,t*i,0,c),s?.setSubData(B.buffer,u,h,m)}writeRandomInstances(e,t,r,{vao:u,targetBuffer:a,textureBuffer:f}){const n=this._targetStrideBytes(a),s=e*n,o=t*this._targetStrideBytes("texture"),i=this._targetLayout(a),c=this._targetLayout("texture"),l=s,m=S(s+o),g=i.createView(m.buffer),h=c?.createView(m.buffer,l);let B=0,y=0,x=0,b=0,_=0,d=0;const w=u.buffer(a);for(const S of r){const{vertexBufferRange:e,textureBufferRange:t}=S;if(!(b===e.from)){const t=b-x;t>0&&w?.setSubData(m,x*n,0,t*n),x=e.from,B=0}if(!(d===t.from)&&null!=f){const e=d-_;e>0&&f.setSubData(m.buffer,_,l,e),_=t.from,y=0}this._writeGeometry(S.geometry,g,h,B,y,t),B+=e.numElements,b=e.to,y+=t.numElements,d=t.to}const v=b-x;v>0&&w?.setSubData(m,x*n,0,v*n);const p=d-_;p>0&&null!=f&&f.setSubData(m.buffer,_,l,p)}writeInstanceRangeMetal(e,t,r,u,a,{vao:f,targetBuffer:n,textureBuffer:s}){const o=this._targetLayout(n),i=this._targetStrideBytes(n),c=(e-t)*i,l=this._targetLayout("texture"),m=(r-u)*this._targetStrideBytes("texture"),g=c+m,h=c,B=S(g),y=o.createView(B.buffer),x=l?.createView(B.buffer,h);B.fill(0,0,g);for(const b of a){const{vertexBufferRange:r,textureBufferRange:a}=b;if(!(r.from>=t&&r.to<=e))continue;const f=r.from-t,n=a.from-u;this._writeGeometry(b.geometry,y,x,f,n,a)}c>0&&f.buffer(n)?.setSubData(B,t*i,0,c),m>0&&null!=s&&s.setSubData(B.buffer,u,h,m)}rebuildInstances(e,t,r,{vao:u,targetBuffer:a,textureBuffer:f}){const n=this._targetStrideBytes(a),s=e*n,o=s,i=S(s+t*this._targetStrideBytes("texture")),c=this._targetLayout(a).createView(i.buffer),l=this._targetLayout("texture")?.createView(i.buffer,o);let m=0,g=0;for(const h of r){const e=m,t=g;m+=this.vertexElementCount(h.geometry.geometry),g+=this.textureElementCount(h.geometry.geometry),h.vertexBufferRange.from=e,h.vertexBufferRange.to=m,h.textureBufferRange.from=t,h.textureBufferRange.to=g,this._writeGeometry(h.geometry,c,l,e,t,h.textureBufferRange)}return u?.buffer(a)?.setSubData(i,0,0,m*n),f?.setSubData(i.buffer,0,o,g),[m,g]}updateInstance(e,{vao:t,targetBuffer:r,textureBuffer:u}){const a=this._targetStrideBytes(r),f=this._targetStrideBytes("texture"),n=this.vertexElementCount(e.geometry.geometry)*a,s=n,o=S(n+this.textureElementCount(e.geometry.geometry)*f),i=this._targetLayout(r).createView(o.buffer),c=this._targetLayout("texture")?.createView(o.buffer,s);this._writeGeometry(e.geometry,i,c,0,0,e.textureBufferRange);const{vertexBufferRange:l,textureBufferRange:m}=e;t.buffer(r)?.setSubData(o,l.from*a,0,l.numElements*a),u?.setSubData(o.buffer,m.from,s,m.numElements)}updateInstancesMetal(e){for(const[t,r]of e){let e=1/0,u=-1/0,a=1/0,f=-1/0;for(const t of r){const{vertexBufferRange:r,textureBufferRange:n}=t;e=Math.min(e,r.from),u=Math.max(u,r.to),a=Math.min(a,n.from),f=Math.max(f,n.to)}this.writeInstanceRangeMetal(u,e,u,e,t.instances.values(),t)}}_writeGeometry(e,t,f,n,s,o){const{_bufferWriter:i}=this;null!=i&&(r(y,e.transformation),y[12]-=e.localOrigin.vec3[0],y[13]-=e.localOrigin.vec3[1],y[14]-=e.localOrigin.vec3[2],u(x,y),a(x,x),i.write(y,x,e.geometry.attributes,e.geometry.olidColor,t,n,o),null!=f&&i.writeTextureBuffer&&i.writeTextureBuffer(y,x,e.geometry.attributes,f,s))}static prune(){w=new Uint8Array(b)}}const y=f(),x=f(),b=262144,_=1024,d=16777216;let w=new Uint8Array(b);function S(e){return w.byteLength<e&&(w=new Uint8Array(e)),w}function v(t){return t<=_?_:t<b?e(t):Math.max(Math.min(Math.ceil(1.5*t/b)*b,d),t)}export{B as VaoWriter};
5
+ import{nextHighestPowerOfTwo as e}from"../../../../../core/mathUtils.js";import{disposeMaybe as t}from"../../../../../core/maybe.js";import{copy as r,invert as o,transpose as a}from"../../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as u}from"../../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{glLayout as n}from"../../../support/buffer/glUtil.js";import{VertexArrayObject as s}from"../../lib/VertexArrayObject.js";import{getMaxItemCount as f,getMaxByteSize as i}from"../../lib/TextureBackedBuffer/TextureBackedBufferUtils.js";import{TextureBuffer as m}from"../../lib/TextureBackedBuffer/TextureBuffer.js";import{DrawCommand as c}from"./DrawCommand.js";import{BaseInstanceData as l}from"./PerBaseInstanceData.js";import{VertexBuffer as g}from"../../../../webgl/VertexBuffer.js";class y{constructor(e,t){this._rctx=t,this._bufferWriter=e.createBufferWriter(),this._vaoCache=t.getVaoCache(n(this._bufferWriter.layout))}maxElements(e){if("texture"===e){const e=this._targetLayout("texture");return null==e?0:f(this._rctx,e)}return Math.floor(_/this._targetStrideBytes(e))}_targetStrideBytes(e){return this._targetLayout(e)?.stride??0}_targetLayout(e){return"geometry"===e?this._bufferWriter.layout:"baseInstance"===e?this._bufferWriter.baseInstanceLayout:this._bufferWriter.textureBufferLayout}endVertexElement(e){return Math.floor((e.vao?.getByteLength("geometry")??0)/this._targetStrideBytes("geometry"))}endTextureElement({textureBuffer:e}){return e?.itemCount??0}evaluateBufferAllocation(e,t,r,o){const a=this._targetStrideBytes("geometry"),u=t.reduce((e,{geometry:t})=>e+this.vertexElementCount(t),0),n=r.reduce((e,{geometry:t})=>e+this.vertexElementCount(t),0),s=Math.min((e+u-n)*a,_),f=o.vao?.buffer("geometry"),i=f?.sizeBytes??0;return s>b&&s<i/2?0:s>i?1:2}deleteBuffer(e){if(e.isInstanced)return e.instancedCommandVAOs?.dispose(),e.vao?.buffer("geometry")?.dispose(),e.vao?.disposeVAOOnly(),void(e.vao=null);this._vaoCache.deleteVao(e.vao),e.vaoEndElement=0}deleteTextureBuffer(e){e.textureBuffer=t(e.textureBuffer),e.textureEndElement=0}createBaseInstanceData(e){const{_bufferWriter:t}=this;if(null==e||null==t.baseInstanceLayout||null==t.writeBaseInstance||null==t.elementCountBaseInstance)return null;const r=this._targetLayout("baseInstance"),o=t.elementCountBaseInstance(e.attributes),a=o*r.stride,u=new g(this._rctx,n(r));u.setSize(Math.ceil(a));const s=w(a),f=r.createView(s.buffer);t.writeBaseInstance(e.attributes,f),u.setSubData(s,0,0,a);const i=new c;return i.first=0,i.count=o,new l(e,u,i)}_allocateInstanceBuffer(e){const t=this._bufferWriter.layout,r=e*this._targetStrideBytes("geometry"),o=new g(this._rctx,n(t,1));return o.setSize(S(r)),o}_createInstancedVao(e,t){return new s(this._rctx,new Map([["baseInstance",e],["geometry",t]]))}reallocateBuffer(e,t,r){if(this.deleteBuffer(t),null!=e){const t=e.baseInstanceBuffer,o=this._allocateInstanceBuffer(r);return this._createInstancedVao(t,o)}const o=r*this._targetStrideBytes("geometry");return this._vaoCache.newVao(S(o))}reallocateTextureBuffer(e,t){this.deleteTextureBuffer(e);const r=this._targetLayout("texture");return null!=r?new m(this._rctx,r,t):null}vertexElementCount(e){return this._bufferWriter.elementCount(e.attributes)}textureElementCount(e){return this._bufferWriter.elementCountTextureBuffer?.(e.attributes)??0}canGrow(e,t,r){const{vao:o,textureBuffer:a}=e;if(null==o)return!0;const u=t*this._targetStrideBytes("geometry"),n=o.getByteLength("geometry")<S(_-b)&&u>o.getByteLength("geometry"),s=this._targetLayout("texture");if(!n||null==s||null==a)return n;const f=r*s.byteStride,m=a.byteLength;return m<i(this._rctx,s)&&f>m}clearVertexHoles(e,{vao:t}){const r=this._targetStrideBytes("geometry"),o=e.reduce((e,t)=>Math.max(e,t.numElements),0)*r,a=w(o);a.fill(0,0,o);const u=t.buffer("geometry");for(const n of e)u?.setSubData(a,n.from*r,0,n.numElements*r)}clearTextureHoles(e,{textureBuffer:t}){const r=this._targetLayout("texture");if(null==t||null==r)return;const o=r.byteStride,a=e.reduce((e,t)=>Math.max(e,t.numElements),0)*o,u=w(a);u.fill(0,0,a);for(const n of e)t.setSubData(u.buffer,n.from,0,n.numElements)}clearHolesMetal(e,t,r,o,a,{vao:u,textureBuffer:n}){const s=this._targetLayout("geometry"),f=this._targetStrideBytes("geometry"),i=(r-t)*f,m=this._targetLayout("texture"),c=(a-o)*this._targetStrideBytes("texture"),l=i+c,g=i,y=w(l),h=s.createView(y.buffer),x=m?.createView(y.buffer,g);y.fill(0,0,l);for(const b of e){const{vertexBufferRange:e,textureBufferRange:a}=b;if(!(e.from>=t&&e.to<=r))continue;const u=e.from-t,n=a.from-o;this._writeGeometry(b.geometry,h,x,u,n,a)}u.buffer("geometry")?.setSubData(y,t*f,0,i),n?.setSubData(y.buffer,o,g,c)}writeRandomInstances(e,t,r,{vao:o,textureBuffer:a}){const u=this._targetStrideBytes("geometry"),n=e*u,s=t*this._targetStrideBytes("texture"),f=this._targetLayout("geometry"),i=this._targetLayout("texture"),m=n,c=w(n+s),l=f.createView(c.buffer),g=i?.createView(c.buffer,m);let y=0,h=0,x=0,b=0,B=0,_=0;const d=o.buffer("geometry");for(const w of r){const{vertexBufferRange:e,textureBufferRange:t}=w;if(!(b===e.from)){const t=b-x;t>0&&d?.setSubData(c,x*u,0,t*u),x=e.from,y=0}if(!(_===t.from)&&null!=a){const e=_-B;e>0&&a.setSubData(c.buffer,B,m,e),B=t.from,h=0}this._writeGeometry(w.geometry,l,g,y,h,t),y+=e.numElements,b=e.to,h+=t.numElements,_=t.to}const S=b-x;S>0&&d?.setSubData(c,x*u,0,S*u);const v=_-B;v>0&&null!=a&&a.setSubData(c.buffer,B,m,v)}writeInstanceRangeMetal(e,t,r,o,a,{vao:u,textureBuffer:n}){const s=this._targetLayout("geometry"),f=this._targetStrideBytes("geometry"),i=(e-t)*f,m=this._targetLayout("texture"),c=(r-o)*this._targetStrideBytes("texture"),l=i+c,g=i,y=w(l),h=s.createView(y.buffer),x=m?.createView(y.buffer,g);y.fill(0,0,l);for(const b of a){const{vertexBufferRange:r,textureBufferRange:a}=b;if(!(r.from>=t&&r.to<=e))continue;const u=r.from-t,n=a.from-o;this._writeGeometry(b.geometry,h,x,u,n,a)}i>0&&u.buffer("geometry")?.setSubData(y,t*f,0,i),c>0&&null!=n&&n.setSubData(y.buffer,o,g,c)}rebuildInstances(e,t,r,{vao:o,textureBuffer:a}){const u=this._targetStrideBytes("geometry"),n=e*u,s=n,f=w(n+t*this._targetStrideBytes("texture")),i=this._targetLayout("geometry").createView(f.buffer),m=this._targetLayout("texture")?.createView(f.buffer,s);let c=0,l=0;for(const g of r){const e=c,t=l;c+=this.vertexElementCount(g.geometry.geometry),l+=this.textureElementCount(g.geometry.geometry),g.vertexBufferRange.from=e,g.vertexBufferRange.to=c,g.textureBufferRange.from=t,g.textureBufferRange.to=l,this._writeGeometry(g.geometry,i,m,e,t,g.textureBufferRange)}return o?.buffer("geometry")?.setSubData(f,0,0,c*u),a?.setSubData(f.buffer,0,s,l),[c,l]}updateInstance(e,{vao:t,textureBuffer:r}){const o=this._targetStrideBytes("geometry"),a=this._targetStrideBytes("texture"),u=this.vertexElementCount(e.geometry.geometry)*o,n=u,s=w(u+this.textureElementCount(e.geometry.geometry)*a),f=this._targetLayout("geometry").createView(s.buffer),i=this._targetLayout("texture")?.createView(s.buffer,n);this._writeGeometry(e.geometry,f,i,0,0,e.textureBufferRange);const{vertexBufferRange:m,textureBufferRange:c}=e;t.buffer("geometry")?.setSubData(s,m.from*o,0,m.numElements*o),r?.setSubData(s.buffer,c.from,n,c.numElements)}updateInstancesMetal(e){for(const[t,r]of e){let e=1/0,o=-1/0,a=1/0,u=-1/0;for(const t of r){const{vertexBufferRange:r,textureBufferRange:n}=t;e=Math.min(e,r.from),o=Math.max(o,r.to),a=Math.min(a,n.from),u=Math.max(u,n.to)}this.writeInstanceRangeMetal(o,e,o,e,t.instances.values(),t)}}_writeGeometry(e,t,u,n,s,f){const{_bufferWriter:i}=this;null!=i&&(r(h,e.transformation),h[12]-=e.localOrigin.vec3[0],h[13]-=e.localOrigin.vec3[1],h[14]-=e.localOrigin.vec3[2],o(x,h),a(x,x),i.write(h,x,e.geometry.attributes,e.geometry.olidColor,t,n,f),null!=u&&i.writeTextureBuffer&&i.writeTextureBuffer(h,x,e.geometry.attributes,u,s))}static prune(){d=new Uint8Array(b)}}const h=u(),x=u(),b=262144,B=1024,_=16777216;let d=new Uint8Array(b);function w(e){return d.byteLength<e&&(d=new Uint8Array(e)),d}function S(t){return t<=B?B:t<b?e(t):Math.max(Math.min(Math.ceil(1.5*t/b)*b,_),t)}export{y as VaoWriter};
@@ -0,0 +1,5 @@
1
+ /*
2
+ All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
+ See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
+ */
5
+ import{__decorate as e}from"tslib";import{subclass as r}from"../../../../core/accessorSupport/decorators.js";import{ReloadableShader as s}from"../core/shaderTechnique/ReloadableShader.js";import{ShaderTechnique as o}from"../core/shaderTechnique/ShaderTechnique.js";import{a as i}from"../../../../chunks/GaussianSplat.glsl.js";import{makePipelineState as t,defaultColorWrite as a,separateBlendingParams as n}from"../../../webgl/renderState.js";let l=class extends o{constructor(){super(...arguments),this.shader=new s(i,()=>import("./GaussianSplat.glsl.js"))}initializePipeline(){return t({blending:n(773,773,1,1,32774,32774),depthTest:{func:515},colorWrite:a})}};l=e([r("esri.views.3d.webgl-engine.shaders.GaussianSplatColorTechnique")],l);export{l as GaussianSplatColorTechnique};
@@ -0,0 +1,5 @@
1
+ /*
2
+ All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
+ See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
+ */
5
+ import{__decorate as e}from"tslib";import{subclass as r}from"../../../../core/accessorSupport/decorators.js";import{ReloadableShader as s}from"../core/shaderTechnique/ReloadableShader.js";import{ShaderTechnique as i}from"../core/shaderTechnique/ShaderTechnique.js";import{a as t}from"../../../../chunks/GaussianSplat.glsl.js";import{makePipelineState as o,defaultColorWrite as a,separateBlendingParams as n}from"../../../webgl/renderState.js";let l=class extends i{constructor(){super(...arguments),this.shader=new s(t,()=>import("./GaussianSplat.glsl.js"))}initializePipeline(){return o({blending:n(773,773,772,1,32774,32774),depthTest:{func:515},colorWrite:a})}};l=e([r("esri.views.3d.webgl-engine.shaders.GaussianSplatDepthTechnique")],l);export{l as GaussianSplatDepthTechnique};
@@ -2,4 +2,4 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as t}from"tslib";import{ShaderTechniqueConfiguration as e,parameter as i}from"../core/shaderTechnique/ShaderTechniqueConfiguration.js";class o extends e{constructor(t){super(),this.spherical=t,this.alphaCutoff=1,this.fadingEnabled=!1,this.terrainDepthTest=!1,this.cullAboveTerrain=!1,this.occlusionPass=!1,this.receiveAmbientOcclusion=!1,this.pbrMode=0,this.useCustomDTRExponentForWater=!1,this.useFillLights=!1,this.hasColorTexture=!0}}function r(t){switch(t){case 2:return.005;case 0:return.05;default:return.01}}t([i({count:3})],o.prototype,"alphaCutoff",void 0),t([i()],o.prototype,"fadingEnabled",void 0),t([i()],o.prototype,"terrainDepthTest",void 0),t([i()],o.prototype,"cullAboveTerrain",void 0),t([i()],o.prototype,"receiveAmbientOcclusion",void 0);export{o as GaussianSplatTechniqueConfiguration,r as getGaussianSplatAlphaCutoffValue};
5
+ import{__decorate as t}from"tslib";import{ShaderTechniqueConfiguration as e,parameter as i}from"../core/shaderTechnique/ShaderTechniqueConfiguration.js";class o extends e{constructor(t,e=!1,i=!1){super(),this.spherical=t,this.colorOnlyPass=e,this.dephtOnlyPass=i,this.alphaCutoff=1,this.fadingEnabled=!1,this.terrainDepthTest=!1,this.cullAboveTerrain=!1,this.occlusionPass=!1,this.receiveAmbientOcclusion=!1,this.pbrMode=0,this.useCustomDTRExponentForWater=!1,this.useFillLights=!1,this.hasColorTexture=!0}}function s(t){switch(t){case 2:return.005;case 0:return.05;default:return.01}}t([i({count:3})],o.prototype,"alphaCutoff",void 0),t([i()],o.prototype,"fadingEnabled",void 0),t([i()],o.prototype,"terrainDepthTest",void 0),t([i()],o.prototype,"cullAboveTerrain",void 0),t([i()],o.prototype,"receiveAmbientOcclusion",void 0);export{o as GaussianSplatTechniqueConfiguration,s as getGaussianSplatAlphaCutoffValue};
@@ -2,4 +2,4 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as t}from"tslib";import e from"../../core/ReactiveMap.js";import{renderingSanitizer as n}from"../../core/sanitizerUtils.js";import{property as o,subclass as s}from"../../core/accessorSupport/decorators.js";import{isSupportedImage as a,getCalciteIconForAttachment as i}from"../Attachments/support/attachmentUtils.js";import l from"./Grid/Column.js";import{css as r}from"./Grid/ColumnCSS.js";const c="esri-attachments-column",h={contentContainer:`${c}__content`,showAttachmentsButton:`${c}__button`};let m=class extends l{constructor(t){super(t),this._buttonElements=new e,this._thumbnailElements=new e,this.attachmentsViewEnabled=!0,this.cellValueFormatFunction=({root:t,rowData:e})=>{const{_showAttachmentsViewEnabled:n,formatFunction:o}=this,s=this.getCellValue(e);if(o&&e){const{index:n,item:{attachments:a,feature:i,relatedRecords:l}}=e;return o({attachments:a,column:this,feature:i,index:n,relatedRecords:l,value:s,virtualIndex:this.getVirtualRowIndex(t),field:void 0})}if(!e)return s;const{index:a,item:{attachments:i,objectId:l}}=e,r=`(${s})`;if(!this.thumbnailsEnabled&&!n)return s;const c=document.createElement("span");c.textContent=c.title=r;let m=null;if(this.thumbnailsEnabled&&(m=this._createOrSyncThumbnails(l,i??[])),this._showAttachmentsViewEnabled){const t=document.createElement("div");m&&t.appendChild(m),t.appendChild(c);const e=this._createOrSyncShowAttachmentsButton(l,a);return e.appendChild(t),e}const u=document.createElement("div");return u.classList.add(h.contentContainer),m&&u.appendChild(m),u.appendChild(c),u},this.icon="attachment",this.layer=null,this.onShowAttachments=null,this.sortable=!1,this.store=null,this.textAlign="center",this.thumbnailAppearance="image",this.thumbnailCount=8,this.thumbnailIconScale="m",this.thumbnailsEnabled=!0}get _showAttachmentsViewEnabled(){return!(!this.attachmentsViewEnabled||!this.onShowAttachments)}get _supportsResize(){return!!this.store?.supportsResizeAttachments}get effectiveLabel(){return n.sanitize(this.label??(this.messages?.attachments||this.fieldName))}getCellValue(t){return t?.item?.attachments?.length??0}_createOrSyncThumbnails(t,e){const n=document.createElement("div"),o=this._thumbnailElements.get(t);return o?.length&&o.length===e.length?o.forEach(t=>n.appendChild(t)):this._thumbnailElements.set(t,this._createThumbnailElements(e,n)),n}_createOrSyncShowAttachmentsButton(t,e){const n=this._buttonElements.get(t);if(n)return n.textContent="",n.onclick=n=>this._onShowAttachmentsClick({index:e,objectId:t,event:n}),n;const o=this.createCalciteButton({alignment:"icon-end-space-between",className:`${h.showAttachmentsButton} ${r.contentFull}`,iconEnd:"chevron-right",iconFlipRtl:"both",scale:this.thumbnailIconScale,textContent:"",title:this.messages?.viewAttachments,width:"full",onclick:n=>this._onShowAttachmentsClick({index:e,objectId:t,event:n})});return this._buttonElements.set(t,o),o}_createThumbnailAnchor({name:t,url:e},n){const o=document.createElement("a");return o.href=`${e}`,o.download=t,o.rel="noreferrer",o.target="_blank",o.appendChild(n),o}_createThumbnailElements(t,e){const{thumbnailAppearance:n,thumbnailCount:o,thumbnailIconScale:s}=this,l=[],r=Math.min(o,t.length),c=!this.onShowAttachments,h="image"===n&&!!this.store?.supportsResizeAttachments;for(let m=0;m<r;m++){const n=t[m],{name:o,contentType:r}=n,u=a(r)&&h?this._createThumbnailImage(n):this.createCalciteIcon({icon:i(r),scale:s,textLabel:o}),p=c?this._createThumbnailAnchor(n,u):u;e&&e.appendChild(p),l.push(p)}return l}_createThumbnailImage(t){const{name:e,size:n,url:o}=t,s=document.createElement("img"),a=`${o}${o?.includes("?")?"&":"?"}${this._supportsResize?"w=24":""}&fs=${n}`;return s.alt=this.messages?.attachmentThumbnail??e,s.src=a,s.title=e,s}_onShowAttachmentsClick({index:t,objectId:e,event:n}){n.preventDefault(),n.stopPropagation(),this.onShowAttachments?.({index:t,objectId:e})}};t([o()],m.prototype,"_showAttachmentsViewEnabled",null),t([o()],m.prototype,"_buttonElements",void 0),t([o()],m.prototype,"_supportsResize",null),t([o()],m.prototype,"_thumbnailElements",void 0),t([o()],m.prototype,"attachmentsViewEnabled",void 0),t([o()],m.prototype,"cellValueFormatFunction",void 0),t([o()],m.prototype,"effectiveLabel",null),t([o()],m.prototype,"icon",void 0),t([o()],m.prototype,"layer",void 0),t([o()],m.prototype,"onShowAttachments",void 0),t([o({readOnly:!0})],m.prototype,"sortable",void 0),t([o()],m.prototype,"store",void 0),t([o()],m.prototype,"textAlign",void 0),t([o()],m.prototype,"thumbnailAppearance",void 0),t([o()],m.prototype,"thumbnailCount",void 0),t([o()],m.prototype,"thumbnailIconScale",void 0),t([o()],m.prototype,"thumbnailsEnabled",void 0),m=t([s("esri.widgets.FeatureTable.AttachmentsColumn")],m);const u=m;export{u as default};
5
+ import{__decorate as t}from"tslib";import e from"../../core/ReactiveMap.js";import{renderingSanitizer as n}from"../../core/sanitizerUtils.js";import{property as o,subclass as s}from"../../core/accessorSupport/decorators.js";import{isSupportedImage as a,getCalciteIconForAttachment as i}from"../Attachments/support/attachmentUtils.js";import l from"./Grid/Column.js";import{css as r}from"./Grid/ColumnCSS.js";const c="esri-attachments-column",h={contentContainer:`${c}__content`,showAttachmentsButton:`${c}__button`};let m=class extends l{constructor(t){super(t),this._buttonElements=new e,this._thumbnailElements=new e,this.attachmentsViewEnabled=!0,this.cellValueFormatFunction=({root:t,rowData:e})=>{const{_showAttachmentsViewEnabled:n,formatFunction:o}=this,s=this.getCellValue(e);if(o&&e){const{index:n,item:{attachments:a,feature:i,relatedRecords:l}}=e;return o({attachments:a,column:this,feature:i,index:n,relatedRecords:l,value:s,virtualIndex:this.getVirtualRowIndex(t),field:void 0})}if(!e)return s;const{index:a,item:{attachments:i,objectId:l}}=e,r=`(${s})`;if(!this.thumbnailsEnabled&&!n)return s;const c=document.createElement("span");c.textContent=c.title=r;let m=null;if(this.thumbnailsEnabled&&(m=this._createOrSyncThumbnails(l,i??[])),this._showAttachmentsViewEnabled){const t=document.createElement("div");m&&t.appendChild(m),t.appendChild(c);const e=this._createOrSyncShowAttachmentsButton(l,a);return e.appendChild(t),e}const u=document.createElement("div");return u.classList.add(h.contentContainer),m&&u.appendChild(m),u.appendChild(c),u},this.icon="attachment",this.layer=null,this.onShowAttachments=null,this.sortable=!1,this.store=null,this.textAlign="center",this.thumbnailAppearance="image",this.thumbnailCount=8,this.thumbnailIconScale="m",this.thumbnailsEnabled=!0}get _showAttachmentsViewEnabled(){return!(!this.attachmentsViewEnabled||!this.onShowAttachments)}get _supportsResize(){return this.store.supportsResizeAttachments}get effectiveLabel(){return n.sanitize(this.label??(this.messages?.attachments||this.fieldName))}getCellValue(t){return t?.item?.attachments?.length??0}_createOrSyncThumbnails(t,e){const n=document.createElement("div"),o=this._thumbnailElements.get(t);return o?.length&&o.length===e.length?o.forEach(t=>n.appendChild(t)):this._thumbnailElements.set(t,this._createThumbnailElements(e,n)),n}_createOrSyncShowAttachmentsButton(t,e){const n=this._buttonElements.get(t);if(n)return n.textContent="",n.onclick=n=>this._onShowAttachmentsClick({index:e,objectId:t,event:n}),n;const o=this.createCalciteButton({alignment:"icon-end-space-between",className:`${h.showAttachmentsButton} ${r.contentFull}`,iconEnd:"chevron-right",iconFlipRtl:"both",scale:this.thumbnailIconScale,textContent:"",title:this.messages?.viewAttachments,width:"full",onclick:n=>this._onShowAttachmentsClick({index:e,objectId:t,event:n})});return this._buttonElements.set(t,o),o}_createThumbnailAnchor({name:t,url:e},n){const o=document.createElement("a");return o.href=`${e}`,o.download=t,o.rel="noreferrer",o.target="_blank",o.appendChild(n),o}_createThumbnailElements(t,e){const{thumbnailAppearance:n,thumbnailCount:o,thumbnailIconScale:s}=this,l=[],r=Math.min(o,t.length),c=!this.onShowAttachments,h="image"===n&&this.store.supportsResizeAttachments;for(let m=0;m<r;m++){const n=t[m],{name:o,contentType:r}=n,u=a(r)&&h?this._createThumbnailImage(n):this.createCalciteIcon({icon:i(r),scale:s,textLabel:o}),p=c?this._createThumbnailAnchor(n,u):u;e&&e.appendChild(p),l.push(p)}return l}_createThumbnailImage(t){const{name:e,size:n,url:o}=t,s=document.createElement("img"),a=`${o}${o?.includes("?")?"&":"?"}${this._supportsResize?"w=24":""}&fs=${n}`;return s.alt=this.messages?.attachmentThumbnail??e,s.src=a,s.title=e,s}_onShowAttachmentsClick({index:t,objectId:e,event:n}){n.preventDefault(),n.stopPropagation(),this.onShowAttachments?.({index:t,objectId:e})}};t([o()],m.prototype,"_showAttachmentsViewEnabled",null),t([o()],m.prototype,"_buttonElements",void 0),t([o()],m.prototype,"_supportsResize",null),t([o()],m.prototype,"_thumbnailElements",void 0),t([o()],m.prototype,"attachmentsViewEnabled",void 0),t([o()],m.prototype,"cellValueFormatFunction",void 0),t([o()],m.prototype,"effectiveLabel",null),t([o()],m.prototype,"icon",void 0),t([o()],m.prototype,"layer",void 0),t([o()],m.prototype,"onShowAttachments",void 0),t([o({readOnly:!0})],m.prototype,"sortable",void 0),t([o()],m.prototype,"store",void 0),t([o()],m.prototype,"textAlign",void 0),t([o()],m.prototype,"thumbnailAppearance",void 0),t([o()],m.prototype,"thumbnailCount",void 0),t([o()],m.prototype,"thumbnailIconScale",void 0),t([o()],m.prototype,"thumbnailsEnabled",void 0),m=t([s("esri.widgets.FeatureTable.AttachmentsColumn")],m);const u=m;export{u as default};