UNPKG

@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) 1.79 kB
import{j as e,ak as t}from"./index-DFZFpUG-.esm.min.js";const n=5126,o={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},r={5120:1,5121:1,5122:2,5123:2,5125:4,5126:4};function s(e){return e+3&-4}function c(e,t,o,r){switch(o){case 5120:{const n=e.getInt8(t);return r?Math.max(n/127,-1):n}case 5121:{const n=e.getUint8(t);return r?n/255:n}case 5122:{const n=e.getInt16(t,!0);return r?Math.max(n/32767,-1):n}case 5123:{const n=e.getUint16(t,!0);return r?n/65535:n}case n:return e.getFloat32(t,!0);default:throw new Error(`KHR_mesh_quantization: unsupported componentType ${o}`)}}const f={id:"KHR_mesh_quantization",async preParse(f,i){const p=f.accessors??[],u=f.bufferViews??[],a=[];let y=0;for(let e=0;e<p.length;e++){const t=p[e];if(void 0===t.bufferView)continue;const c=o[t.type]??1,f=u[t.bufferView]?.byteStride,i=r[t.componentType],m=5120===t.componentType||5122===t.componentType,b=t.componentType===n&&void 0!==f&&f!==4*c,l=(5121===t.componentType||5123===t.componentType)&&!0!==t.normalized&&"VEC4"!==t.type&&void 0!==f&&void 0!==i&&f!==c*i;(m||!0===t.normalized||b||l)&&(a.push(e),y=s(y+t.count*c*4))}if(0===a.length)return;const m=s(i.byteLength),b=new ArrayBuffer(m+y);new e(b).set(new e(i.buffer,i.byteOffset,i.byteLength));const l=new t(b);let d=m;for(const e of a){const t=p[e],f=u[t.bufferView],a=o[t.type]??1,y=r[t.componentType],m=f.byteStride??a*y,b=(f.byteOffset??0)+(t.byteOffset??0),h=d;for(let e=0;e<t.count;e++)for(let n=0;n<a;n++){const o=c(i,b+e*m+n*y,t.componentType,!!t.normalized);l.setFloat32(h+4*(e*a+n),o,!0)}const T=t.count*a*4,w=u.length;u.push({buffer:0,byteOffset:h,byteLength:T}),t.bufferView=w,t.byteOffset=0,t.componentType=n,t.normalized=!1,d=s(d+T)}return l}};export{f as default}; //# sourceMappingURL=gltf-ext-quantization-BLW3sHuw.esm.min.js.map