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.76 kB
import{p as e,ar as t}from"./index-B8IgtevW.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,p){const u=f.accessors??[],a=f.bufferViews??[],i=[];let y=0;for(let e=0;e<u.length;e++){const t=u[e];if(void 0===t.bufferView)continue;const r=o[t.type]??1,c=a[t.bufferView]?.byteStride,f=5120===t.componentType||5122===t.componentType,p=t.componentType===n&&void 0!==c&&c!==4*r,m=(5121===t.componentType||5123===t.componentType)&&!0!==t.normalized&&("VEC2"===t.type||"VEC3"===t.type);(f||!0===t.normalized||p||m)&&(i.push(e),y=s(y+t.count*r*4))}if(0===i.length)return;const m=s(p.byteLength),b=new ArrayBuffer(m+y);new e(b).set(new e(p.buffer,p.byteOffset,p.byteLength));const l=new t(b);let h=m;for(const e of i){const t=u[e],f=a[t.bufferView],i=o[t.type]??1,y=r[t.componentType],m=f.byteStride??i*y,b=(f.byteOffset??0)+(t.byteOffset??0),d=h;for(let e=0;e<t.count;e++)for(let n=0;n<i;n++){const o=c(p,b+e*m+n*y,t.componentType,!!t.normalized);l.setFloat32(d+4*(e*i+n),o,!0)}const w=t.count*i*4,T=a.length;a.push({buffer:0,byteOffset:d,byteLength:w}),t.bufferView=T,t.byteOffset=0,t.componentType=n,t.normalized=!1,h=s(h+w)}return l}};export{f as default}; //# sourceMappingURL=gltf-ext-quantization-rcbiVm3q.esm.min.js.map