UNPKG

@doegis/core

Version:

DOE GIS API

3 lines (1 loc) 856 B
import{allocateTypedArrayBufferwithData as e}from"../Utils.js";class t{constructor(e,t){this.data=e,this.stride=t}static decode(r){const s=e(r.data,r.stride),n=r.stride;return new t(s,n)}static fromVertexVector(r){const s=e(r.data.buffer(),r.stride),n=r.stride;return new t(s,n)}}class r{constructor(e,t,r){this.geometryType=e,this.indexBuffer=new Uint32Array(t),this.namedBuffers=r}static decode(e){const s=e.geometryType,n=e.indexBuffer,o={};for(const r in e.namedBuffers)o[r]=t.decode(e.namedBuffers[r]);return new r(s,n,o)}static fromVertexData(s,n){const o=s.indices,c=e(s.vertices,s.stride),i=s.stride,d={geometry:new t(c,i)};return new r(n,o,d)}static fromVertexVectors(e){const s=e.geometryType,n=e.indexVector.buffer(),o={};for(const r in e.namedVectors)o[r]=t.fromVertexVector(e.namedVectors[r]);return new r(s,n,o)}}export{r as VertexBuffers};