@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
6 lines (5 loc) • 7.07 kB
JavaScript
/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
*/
import{disposeMaybe as t}from"../../../../core/maybe.js";import{estimateNumberArrayMemory as e}from"../../../../core/memoryEstimations.js";import"../../tiling/TileInfoView.js";import r from"../../tiling/TileKey.js";import"../../tiling/TileQueue.js";import"../../tiling/TileStrategy.js";import{BucketType as n}from"./enums.js";import{deserializeSymbols as i}from"./decluttering/util.js";import{BufferObject as s}from"../../../webgl/BufferObject.js";import{Usage as a}from"../../../webgl/enums.js";import{VertexArrayObject as o}from"../../../webgl/VertexArrayObject.js";class h{constructor(t,e){this.layerUIDs=[],this.isDestroyed=!1,this._data=t;let r=1;const n=new Uint32Array(t);this.layerUIDs=[];const i=n[r++];for(let s=0;s<i;s++)this.layerUIDs[s]=n[r++];this.bufferDataOffset=r,e&&(this.layer=e.getStyleLayerByUID(this.layerUIDs[0]))}get isPreparedForRendering(){return null==this._data}get offset(){return this.bufferDataOffset}get data(){return this._data}destroy(){this.isDestroyed||(this.doDestroy(),this._data=null,this.isDestroyed=!0)}prepareForRendering(t){null!=this._data&&(this.doPrepareForRendering(t,this._data,this.bufferDataOffset),this._data=null)}}class c extends h{constructor(t,e){super(t,e),this.type=n.LINE,this.lineIndexStart=0,this.lineIndexCount=0;const r=new Uint32Array(t);let i=this.bufferDataOffset;this.lineIndexStart=r[i++],this.lineIndexCount=r[i++];const s=r[i++];if(s>0){this.patternMap=new Map;for(let t=0;t<s;t++){const t=r[i++],e=r[i++],n=r[i++];this.patternMap.set(t,[e,n])}}this.bufferDataOffset=i}get usedMemory(){return(this.data?.byteLength??0)+(this.vao?.cachedMemory??0)}hasData(){return this.lineIndexCount>0}triangleCount(){return this.lineIndexCount/3}doDestroy(){this.vao=t(this.vao)}doPrepareForRendering(t,e,r){const n=new Uint32Array(e),i=new Int32Array(n.buffer),h=n[r++],c=s.createVertex(t,a.STATIC_DRAW,new Int32Array(i.buffer,4*r,h));r+=h;const f=n[r++],l=s.createIndex(t,a.STATIC_DRAW,new Uint32Array(n.buffer,4*r,f));r+=f;const u=this.layer.lineMaterial;this.vao=new o(t,u.getAttributeLocations(),u.getLayoutInfo(),new Map([["geometry",c]]),l)}}class f extends h{constructor(t,e){super(t,e),this.type=n.FILL,this.fillIndexStart=0,this.fillIndexCount=0,this.outlineIndexStart=0,this.outlineIndexCount=0;const r=new Uint32Array(t);let i=this.bufferDataOffset;this.fillIndexStart=r[i++],this.fillIndexCount=r[i++],this.outlineIndexStart=r[i++],this.outlineIndexCount=r[i++];const s=r[i++];if(s>0){this.patternMap=new Map;for(let t=0;t<s;t++){const t=r[i++],e=r[i++],n=r[i++];this.patternMap.set(t,[e,n])}}this.bufferDataOffset=i}get usedMemory(){return(this.data?.byteLength??0)+(this.fillVAO?.cachedMemory??0)+(this.outlineVAO?.cachedMemory??0)}hasData(){return this.fillIndexCount>0||this.outlineIndexCount>0}triangleCount(){return(this.fillIndexCount+this.outlineIndexCount)/3}doDestroy(){this.fillVAO=t(this.fillVAO),this.outlineVAO=t(this.outlineVAO)}doPrepareForRendering(t,e,r){const n=new Uint32Array(e),i=new Int32Array(n.buffer),h=n[r++],c=s.createVertex(t,a.STATIC_DRAW,new Int32Array(i.buffer,4*r,h));r+=h;const f=n[r++],l=s.createIndex(t,a.STATIC_DRAW,new Uint32Array(n.buffer,4*r,f));r+=f;const u=n[r++],y=s.createVertex(t,a.STATIC_DRAW,new Int32Array(i.buffer,4*r,u));r+=u;const d=n[r++],A=s.createIndex(t,a.STATIC_DRAW,new Uint32Array(n.buffer,4*r,d));r+=d;const p=this.layer,I=p.fillMaterial,g=p.outlineMaterial;this.fillVAO=new o(t,I.getAttributeLocations(),I.getLayoutInfo(),new Map([["geometry",c]]),l),this.outlineVAO=new o(t,g.getAttributeLocations(),g.getLayoutInfo(),new Map([["geometry",y]]),A)}}class l extends h{constructor(t,e,s){super(t,e),this.type=n.SYMBOL,this.iconPerPageElementsMap=new Map,this.glyphPerPageElementsMap=new Map,this.symbolInstances=[],this.isIconSDF=!1,this.opacityChanged=!1,this.lastOpacityUpdate=0,this.symbols=[];const a=new Uint32Array(t),o=new Int32Array(t),h=new Float32Array(t);let c=this.bufferDataOffset;this.isIconSDF=!!a[c++];const f=a[c++],l=a[c++],u=a[c++],y=new r(f,l,u,0),d=a[c++];for(let r=0;r<d;r++){const t=a[c++],e=a[c++],r=a[c++];this.iconPerPageElementsMap.set(t,[e,r])}const A=a[c++];for(let r=0;r<A;r++){const t=a[c++],e=a[c++],r=a[c++];this.glyphPerPageElementsMap.set(t,[e,r])}const p=a[c++],I=a[c++];this.iconOpacity=new Int32Array(p),this.textOpacity=new Int32Array(I),c=i(a,o,h,c,this.symbols,s,y),this.bufferDataOffset=c}get usedMemory(){return(this.data?.byteLength??0)+(this.iconVAO?.cachedMemory??0)+(this.textVAO?.cachedMemory??0)+e(this.iconOpacity)+e(this.textOpacity)}hasData(){return this.iconPerPageElementsMap.size>0||this.glyphPerPageElementsMap.size>0}triangleCount(){let t=0;for(const e of this.iconPerPageElementsMap.values())t+=e[1];for(const e of this.glyphPerPageElementsMap.values())t+=e[1];return t/3}doDestroy(){this.iconVAO=t(this.iconVAO),this.textVAO=t(this.textVAO)}updateOpacityInfo(){if(!this.opacityChanged)return;this.opacityChanged=!1;const t=this.iconOpacity,e=this.iconVAO.vertexBuffers.get("opacity");t.length>0&&t.byteLength===e.usedMemory&&e.setSubData(t,0,0,t.length);const r=this.textOpacity,n=this.textVAO.vertexBuffers.get("opacity");r.length>0&&r.byteLength===n.usedMemory&&n.setSubData(r,0,0,r.length)}doPrepareForRendering(t,e,r){const n=new Uint32Array(e),i=new Int32Array(n.buffer),h=n[r++],c=s.createVertex(t,a.STATIC_DRAW,new Int32Array(i.buffer,4*r,h));r+=h;const f=n[r++],l=s.createIndex(t,a.STATIC_DRAW,new Uint32Array(n.buffer,4*r,f));r+=f;const u=n[r++],y=s.createVertex(t,a.STATIC_DRAW,new Int32Array(i.buffer,4*r,u));r+=u;const d=n[r++],A=s.createIndex(t,a.STATIC_DRAW,new Uint32Array(n.buffer,4*r,d));r+=d;const p=s.createVertex(t,a.STATIC_DRAW,this.iconOpacity.buffer),I=s.createVertex(t,a.STATIC_DRAW,this.textOpacity.buffer),g=this.layer,x=g.iconMaterial,m=g.textMaterial;this.iconVAO=new o(t,x.getAttributeLocations(),x.getLayoutInfo(),new Map([["geometry",c],["opacity",p]]),l),this.textVAO=new o(t,m.getAttributeLocations(),m.getLayoutInfo(),new Map([["geometry",y],["opacity",I]]),A)}}class u extends h{constructor(t,e){super(t,e),this.type=n.CIRCLE,this.circleIndexStart=0,this.circleIndexCount=0;const r=new Uint32Array(t);let i=this.bufferDataOffset;this.circleIndexStart=r[i++],this.circleIndexCount=r[i++],this.bufferDataOffset=i}get usedMemory(){return(this.data?.byteLength??0)+(this.vao?.cachedMemory??0)}hasData(){return this.circleIndexCount>0}triangleCount(){return this.circleIndexCount/3}doDestroy(){this.vao=t(this.vao)}doPrepareForRendering(t,e,r){const n=new Uint32Array(e),i=new Int32Array(n.buffer),h=n[r++],c=s.createVertex(t,a.STATIC_DRAW,new Int32Array(i.buffer,4*r,h));r+=h;const f=n[r++],l=s.createIndex(t,a.STATIC_DRAW,new Uint32Array(n.buffer,4*r,f));r+=f;const u=this.layer.circleMaterial;this.vao=new o(t,u.getAttributeLocations(),u.getLayoutInfo(),new Map([["geometry",c]]),l)}}export{u as CircleRenderBucket,f as FillRenderBucket,c as LineRenderBucket,h as RenderBucketBase,l as SymbolRenderBucket};