@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
3 lines (2 loc) • 8.13 kB
JavaScript
/* COPYRIGHT Esri - https://js.arcgis.com/5.0.8/LICENSE.txt */
import{destroyMaybe as t}from"../../../../core/maybe.js";import{estimateNumberArrayMemory as e}from"../../../../core/memoryEstimations.js";import"../../tiling/TileInfoView.js";import s from"../../tiling/TileKey.js";import"../../tiling/TileQueue.js";import"../../tiling/TileStrategy.js";import{deserializeSymbols as r}from"./decluttering/util.js";import{Mesh as i}from"../webgl/meshing/Mesh.js";import{PrimitiveType as n}from"../../../webgl/enums.js";class a{constructor(t,e){this.layerUIDs=[],this.isDestroyed=!1,this._mesh=null,this._data=t;let s=1;const r=new Uint32Array(t);this.layerUIDs=[];const i=r[s++];for(let n=0;n<i;n++)this.layerUIDs[n]=r[s++];this.bufferDataOffset=s,e&&(this.layer=e.getStyleLayerByUID(this.layerUIDs[0]))}get isPreparedForRendering(){return null==this._data}get offset(){return this.bufferDataOffset}get data(){return this._data}nullifyData(){this._data=null}destroy(){this.isDestroyed||(this.doDestroy(),this._data=null,t(this._mesh),this.isDestroyed=!0)}}class o extends a{constructor(t,e){super(t,e),this.type=2,this.lineIndexStart=0,this.lineIndexCount=0;const s=new Uint32Array(t);let r=this.bufferDataOffset;this.lineIndexStart=s[r++],this.lineIndexCount=s[r++];const i=s[r++];if(i>0){this.patternMap=new Map;for(let t=0;t<i;t++){const t=s[r++],e=s[r++],i=s[r++];this.patternMap.set(t,[e,i])}}this.bufferDataOffset=r}get usedMemory(){return this.data?.byteLength??0}hasData(){return this.lineIndexCount>0}triangleCount(){return this.lineIndexCount/3}doDestroy(){}getMesh(t){if(this._mesh)return this._mesh;const e=this.data;if(!e)return;const s=this.layer,r=s.getPaintProperty("line-pattern"),a=void 0!==r,o=a&&r.isDataDriven;let h=!1;if(!a){const t=s.getPaintProperty("line-dasharray");h=void 0!==t&&t.isDataDriven}const u=this.patternMap,l=[];if(u&&(o||h))for(const[i,n]of u)l.push({group:0,start:n[0],count:n[1]});else l.push({group:0,start:this.lineIndexStart,count:this.lineIndexCount});const f=new Uint32Array(e),y=new Int32Array(f.buffer);let c=this.bufferDataOffset;const d=f[c++],p=new Int32Array(y.buffer,4*c,d);c+=d;const g=f[c++],m=new Uint32Array(f.buffer,4*c,g),I=this.layer.lineMaterial.geometryLayout;if(!I)return;const x={vertex:{geometryVB:{data:p,layout:I}},index:{geometryIB:{data:m}},groups:[{index:"geometryIB",primitive:n.TRIANGLES}],parts:l};return this._mesh=new i(t,x),this.nullifyData(),this._mesh}}class h extends a{constructor(t,e){super(t,e),this.type=1,this._outlineMesh=null,this.fillIndexStart=0,this.fillIndexCount=0,this.outlineIndexStart=0,this.outlineIndexCount=0;const s=new Uint32Array(t);let r=this.bufferDataOffset;this.fillIndexStart=s[r++],this.fillIndexCount=s[r++],this.outlineIndexStart=s[r++],this.outlineIndexCount=s[r++];const i=s[r++];if(i>0){this.patternMap=new Map;for(let t=0;t<i;t++){const t=s[r++],e=s[r++],i=s[r++];this.patternMap.set(t,[e,i])}}this.bufferDataOffset=r}get usedMemory(){return this.data?.byteLength??0}hasData(){return this.fillIndexCount>0||this.outlineIndexCount>0}triangleCount(){return(this.fillIndexCount+this.outlineIndexCount)/3}doDestroy(){t(this._outlineMesh)}getMesh(t,e){if(0===e.value&&this._mesh)return this._mesh;if(1===e.value&&this._outlineMesh)return this._outlineMesh;if(!this.data)return null;const s=new Uint32Array(this.data),r=new Int32Array(s.buffer);let a=0,o=0,h=0,u=0,l=this.bufferDataOffset;const f=s[l++];a=l,l+=f;const y=s[l++];o=l,l+=y;const c=s[l++];h=l,l+=c;const d=s[l++];u=l;const p=this.layer;if(y>0){const e=p.fillMaterial,h=new Int32Array(r.buffer,4*a,f),u=new Uint32Array(s.buffer,4*o,y),l={vertex:{geometryVB:{data:h,layout:e.geometryLayout}},index:{geometryIB:{data:u}},groups:[{index:"geometryIB",primitive:n.TRIANGLES}],parts:[{group:0,start:this.fillIndexStart,count:this.fillIndexCount}]};this._mesh=new i(t,l)}if(d>0){const e=p.outlineMaterial,a=new Int32Array(r.buffer,4*h,c),o=new Uint32Array(s.buffer,4*u,d),l={vertex:{geometryVB:{data:a,layout:e.geometryLayout}},index:{geometryIB:{data:o}},groups:[{index:"geometryIB",primitive:n.TRIANGLES}],parts:[{group:0,start:this.outlineIndexStart,count:this.outlineIndexCount}]};this._outlineMesh=new i(t,l)}return this.nullifyData(),0===e.value?this._mesh:this._outlineMesh}}class u extends a{constructor(t,e,i){super(t,e),this.type=3,this.iconPerPageElementsMap=new Map,this.glyphPerPageElementsMap=new Map,this.isIconSDF=!1,this.opacityChanged=!1,this.lastOpacityUpdate=0,this.symbols=[],this._textMesh=null;const n=new Uint32Array(t),a=new Int32Array(t),o=new Float32Array(t);let h=this.bufferDataOffset;this.isIconSDF=!!n[h++];const u=n[h++],l=n[h++],f=n[h++],y=new s(u,l,f,0),c=n[h++];for(let s=0;s<c;s++){const t=n[h++],e=n[h++],s=n[h++];this.iconPerPageElementsMap.set(t,[e,s])}const d=n[h++];for(let s=0;s<d;s++){const t=n[h++],e=n[h++],s=n[h++];this.glyphPerPageElementsMap.set(t,[e,s])}const p=n[h++],g=n[h++];this.iconOpacity=new Int32Array(p),this.textOpacity=new Int32Array(g),h=r(n,a,o,h,this.symbols,i,y),this.bufferDataOffset=h}get usedMemory(){return(this.data?.byteLength??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._textMesh=t(this._textMesh)}updateOpacityInfo(){if(!this.opacityChanged)return;this.opacityChanged=!1;const t=this.iconOpacity,e=this._mesh?.vertexBuffers.get("opacity");e&&t.length>0&&t.byteLength===e.usedMemory&&e.setSubData(t,0,0,t.length);const s=this.textOpacity,r=this._textMesh?.vertexBuffers.get("opacity");r&&s.length>0&&s.byteLength===r.usedMemory&&r.setSubData(s,0,0,s.length)}getMesh(t,e){if(0===e.value&&this._mesh)return this._mesh;if(1===e.value&&this._textMesh)return this._textMesh;let s=this.bufferDataOffset;if(!this.data)return null;const r=new Uint32Array(this.data),a=new Int32Array(r.buffer),o=r[s++],h=s;s+=o;const u=r[s++],l=s;s+=u;const f=r[s++],y=s;s+=f;const c=r[s++],d=s;s+=c;const p=this.layer;if(this.iconPerPageElementsMap.size>0){const e=p.iconMaterial,s=[];for(const[t,r]of this.iconPerPageElementsMap)s.push({group:0,start:r[0],count:r[1]});const f=new Int32Array(a.buffer,4*h,o),y=new Uint32Array(r.buffer,4*l,u),c=this.iconOpacity,d=e.opacityLayout,g={vertex:{geometry:{data:f,layout:e.geometryLayout},opacity:{data:c,layout:d}},index:{geometryIB:{data:y}},groups:[{index:"geometryIB",primitive:n.TRIANGLES}],parts:s};this._mesh=new i(t,g)}if(this.glyphPerPageElementsMap.size>0){const e=p.textMaterial,s=[];for(const[t,r]of this.glyphPerPageElementsMap)s.push({group:0,start:r[0],count:r[1]});const o=new Int32Array(a.buffer,4*y,f),h=new Uint32Array(r.buffer,4*d,c),u=this.textOpacity,l=e.opacityLayout,g={vertex:{geometry:{data:o,layout:e.geometryLayout},opacity:{data:u,layout:l}},index:{geometryIB:{data:h}},groups:[{index:"geometryIB",primitive:n.TRIANGLES}],parts:s};this._textMesh=new i(t,g)}return this.nullifyData(),0===e.value?this._mesh:this._textMesh}}class l extends a{constructor(t,e){super(t,e),this.type=4,this.circleIndexStart=0,this.circleIndexCount=0;const s=new Uint32Array(t);let r=this.bufferDataOffset;this.circleIndexStart=s[r++],this.circleIndexCount=s[r++],this.bufferDataOffset=r}get usedMemory(){return this.data?.byteLength??0}hasData(){return this.circleIndexCount>0}triangleCount(){return this.circleIndexCount/3}doDestroy(){}getMesh(t){if(this._mesh)return this._mesh;if(!this.data)return;const e=new Uint32Array(this.data),s=new Int32Array(e.buffer);let r=this.bufferDataOffset;const a=e[r++],o=new Int32Array(s.buffer,4*r,a);r+=a;const h=e[r++],u=new Uint32Array(e.buffer,4*r,h),l=this.layer.circleMaterial.geometryLayout;if(!l)return;const f={vertex:{geometryVB:{data:o,layout:l}},index:{geometryIB:{data:u}},groups:[{index:"geometryIB",primitive:n.TRIANGLES}],parts:[{group:0,start:this.circleIndexStart,count:this.circleIndexCount}]};return this._mesh=new i(t,f),this._mesh}}export{l as CircleRenderBucket,h as FillRenderBucket,o as LineRenderBucket,a as RenderBucketBase,u as SymbolRenderBucket};