@babylonjs/viewer
Version:
The Babylon Viewer aims to simplify a specific but common Babylon.js use case: loading, viewing, and interacting with a 3D model.
3 lines (2 loc) • 2.1 kB
JavaScript
import{ag as e,j as t,T as n,ak as s}from"./index-DFZFpUG-.esm.min.js";const c=5121,r=5123,o=5125,f={5120:1,5121:1,5122:2,5123:2,5125:4,5126:4};function a(e){return e+3&-4}function u(e){const t=f[e];return t||n(88,e),t}function i(e,t,s){switch(s){case c:return e.getUint8(t);case r:return e.getUint16(t,!0);case o:return e.getUint32(t,!0);default:n(89,s)}}function b(e,t,s){switch(s){case 5120:return e.getInt8(t);case c:return e.getUint8(t);case 5122:return e.getInt16(t,!0);case r:return e.getUint16(t,!0);case o:return e.getUint32(t,!0);case 5126:return e.getFloat32(t,!0);default:n(90,s)}}function p(e,t,n,s){switch(n){case 5120:e.setInt8(t,s);break;case c:e.setUint8(t,s);break;case 5122:e.setInt16(t,s,!0);break;case r:e.setUint16(t,s,!0);break;case o:e.setUint32(t,s,!0);break;case 5126:e.setFloat32(t,s,!0)}}const y={id:"_sparse",async preParse(c,r){const o=c.accessors??[],f=c.bufferViews??[],y=[];let l=0;for(let t=0;t<o.length;t++){const n=o[t];if(n.sparse){y.push(t);const s=e[n.type]??1;l=a(l+n.count*s*u(n.componentType))}}if(0===y.length)return;const g=a(r.byteLength),w=new ArrayBuffer(g+l);new t(w).set(new t(r.buffer,r.byteOffset,r.byteLength));const d=new s(w);let h=g;for(const t of y){const s=o[t],c=s.sparse,y=e[s.type]??1,l=u(s.componentType),g=y*l,w=h;if(void 0!==s.bufferView){const e=f[s.bufferView],t=e.byteStride??g,n=(e.byteOffset??0)+(s.byteOffset??0);for(let e=0;e<s.count;e++)for(let c=0;c<y;c++){const o=b(r,n+e*t+c*l,s.componentType);p(d,w+(e*y+c)*l,s.componentType,o)}}const m=c.indices.componentType;void 0===m&&n(91);const O=(f[c.indices.bufferView].byteOffset??0)+(c.indices.byteOffset??0),U=u(m),T=(f[c.values.bufferView].byteOffset??0)+(c.values.byteOffset??0);for(let e=0;e<c.count;e++){const t=i(r,O+e*U,m);(t<0||t>=s.count)&&n(92,t,s.count);for(let n=0;n<y;n++){const c=b(r,T+(e*y+n)*l,s.componentType);p(d,w+(t*y+n)*l,s.componentType,c)}}const k=g*s.count;s.bufferView=f.length,s.byteOffset=0,f.push({buffer:0,byteOffset:w,byteLength:k}),delete s.sparse,h=a(h+k)}return d}};export{y as default};
//# sourceMappingURL=gltf-feature-sparse-DzE4ccOX.esm.min.js.map