import{C as e,K as t,_t as n,gt as r,j as i,p as a,u as o,w as s,wt as c}from"./three.module-BFsVh7r1.js";var l=class extends t{constructor(e){super(e),this.littleEndian=!0}load(t,n,r,i){let a=this,o=new e(a.manager);o.setPath(a.path),o.setResponseType(`arraybuffer`),o.setRequestHeader(a.requestHeader),o.setWithCredentials(a.withCredentials),o.load(t,function(e){try{n(a.parse(e))}catch(e){i?i(e):console.error(e),a.manager.itemError(t)}},r,i)}_getDataView(e,t,n,r){switch(n){case`F`:return r===8?e.getFloat64(t,this.littleEndian):e.getFloat32(t,this.littleEndian);case`I`:return r===1?e.getInt8(t):r===2?e.getInt16(t,this.littleEndian):e.getInt32(t,this.littleEndian);case`U`:return r===1?e.getUint8(t):r===2?e.getUint16(t,this.littleEndian):e.getUint32(t,this.littleEndian)}}parse(e){function t(e,t){let n=e.length,r=new Uint8Array(t),i=0,a=0,o,s,c;do if(o=e[i++],o<32){if(o++,a+o>t)throw Error(`Output buffer is not large enough`);if(i+o>n)throw Error(`Invalid compressed data`);do r[a++]=e[i++];while(--o)}else{if(s=o>>5,c=a-((o&31)<<8)-1,i>=n||s===7&&(s+=e[i++],i>=n))throw Error(`Invalid compressed data`);if(c-=e[i++],a+s+2>t)throw Error(`Output buffer is not large enough`);if(c<0||c>=a)throw Error(`Invalid compressed data`);do r[a++]=r[c++];while(--s+2)}while(ie===`rgb`),n=u.type[e],i=parseFloat(r[t.rgb]),a=i;if(n===`F`){let e=new Float32Array(1);e[0]=i,a=new Int32Array(e.buffer)[0]}let o=(a>>16&255)/255,s=(a>>8&255)/255,l=(a>>0&255)/255;g.setRGB(o,s,l,c),p.push(g.r,g.g,g.b)}t.normal_x!==void 0&&(f.push(parseFloat(r[t.normal_x])),f.push(parseFloat(r[t.normal_y])),f.push(parseFloat(r[t.normal_z]))),t.intensity!==void 0&&m.push(parseFloat(r[t.intensity])),t.label!==void 0&&h.push(parseInt(r[t.label]))}}if(u.data===`binary_compressed`){let n=new Uint32Array(e.slice(u.headerLen,u.headerLen+8)),r=n[0],i=n[1],a=t(new Uint8Array(e,u.headerLen+8,r),i),o=new DataView(a.buffer),s=u.offset;for(let e=0;e0&&_.setAttribute(`position`,new s(d,3)),f.length>0&&_.setAttribute(`normal`,new s(f,3)),p.length>0&&_.setAttribute(`color`,new s(p,3)),m.length>0&&_.setAttribute(`intensity`,new s(m,1)),h.length>0&&_.setAttribute(`label`,new i(h,1)),_.computeBoundingSphere();let v=new n({size:.005});return p.length>0&&(v.vertexColors=!0),new r(_,v)}};export{l as PCDLoader};