UNPKG

@doegis/core

Version:

DOE GIS API

3 lines (1 loc) 1.43 kB
const t=-1;class e{constructor(){this._dirties=[{vertexFrom:t,vertexCount:t,indexFrom:t,indexCount:t,allDirty:!1},{vertexFrom:t,vertexCount:t,indexFrom:t,indexCount:t,allDirty:!1},{vertexFrom:t,vertexCount:t,indexFrom:t,indexCount:t,allDirty:!1},{vertexFrom:t,vertexCount:t,indexFrom:t,indexCount:t,allDirty:!1},{vertexFrom:t,vertexCount:t,indexFrom:t,indexCount:t,allDirty:!1}]}hasDirty(){return this._dirties.some((e=>e.indexCount!==t||e.allDirty))}markAllClean(){for(const e of this._dirties)e.indexFrom=t,e.indexCount=t,e.vertexFrom=t,e.vertexCount=t,e.allDirty=!1}markAllDirty(){for(const t of this._dirties)t.allDirty=!0}forEach(e){for(let r=0;r<this._dirties.length;++r){const{indexCount:i,indexFrom:o,vertexCount:n,vertexFrom:x,allDirty:l}=this._dirties[r],s={};let d,m=!1;(l||x!==t&&n>0)&&(s.geometry={count:n,from:x,allDirty:l},m=!0),(l||o!==t&&i>0)&&(d={count:i,from:o,allDirty:l},m=!0),m&&e({indices:d,vertices:s},r)}}markDirtyIndices(e,r,i){const o=this._dirties[e],n=r,x=i;if(!o.allDirty)if(o.indexCount!==t){const t=Math.min(o.indexFrom,n),e=Math.max(o.indexFrom+o.indexCount,n+x)-t;o.indexFrom=t,o.indexCount=e}else o.indexFrom=n,o.indexCount=x}markDirtyVertices(e,r,i,o){const n=this._dirties[e],x=i,l=o;if(!n.allDirty)if(n.vertexCount!==t){const t=Math.min(n.vertexFrom,x),e=Math.max(n.vertexFrom+n.vertexCount,x+l)-t;n.vertexFrom=t,n.vertexCount=e}else n.vertexFrom=x,n.vertexCount=l}}export{e as default};