1import{Color as ut,Matrix3 as ft,Vector3 as dt,ColorManagement as ot,SRGBColorSpace as st}from"./PDSP0dbZ.js";class bt{parse(l,f,t={}){function A(o){l.traverse(function(m){if(m.isMesh===!0||m.isPoints){const n=m,s=n.geometry;s.hasAttribute("position")===!0&&o(n,s)}})}t=Object.assign({binary:!1,excludeAttributes:[],littleEndian:!1,customPropertyMapping:{}},t);const H=t.excludeAttributes,R=t.customPropertyMapping,P=Object.keys(R);let W=!0,B=!1,O=!1,X=!1,_="float",N="float",Z="float",I="uchar";const j={};for(const o of P)j[o]="float";let J=0,q=0;l.traverse(function(o){if(o.isMesh===!0){const n=o.geometry,s=n.getAttribute("position"),a=n.getAttribute("normal"),h=n.getAttribute("uv"),y=n.getAttribute("color"),x=n.getIndex();if(s===void 0)return;J+=s.count,q+=x?x.count/3:s.count/3,_=L(s.array),a!==void 0&&(B=!0,N=L(a.array)),h!==void 0&&(X=!0,Z=L(h.array)),y!==void 0&&(O=!0,I=L(y.array));for(const Y of P){const w=n.getAttribute(Y);w!==void 0&&(j[Y]=L(w.array))}}else if(o.isPoints){const n=o.geometry,s=n.getAttribute("position"),a=n.getAttribute("normal"),h=n.getAttribute("color");J+=s.count,_=L(s.array),a!==void 0&&(B=!0,N=L(a.array)),h!==void 0&&(O=!0,I=L(h.array));for(const y of P){const x=n.getAttribute(y);x!==void 0&&(j[y]=L(x.array))}W=!1}});const b=new ut;if(W=W&&H.indexOf("index")===-1,B=B&&H.indexOf("normal")===-1,O=O&&H.indexOf("color")===-1,X=X&&H.indexOf("uv")===-1,W&&q!==Math.floor(q))return console.error("PLYExporter: Failed to generate a valid PLY file with triangle indices because the number of indices is not divisible by 3."),null;const V=4;let S=`ply 2format ${t.binary?t.littleEndian?"binary_little_endian":"binary_big_endian":"ascii"} 1.0 3element vertex ${J} 4property ${_} x 5property ${_} y 6property ${_} z 7`;B===!0&&(S+=`property ${N} nx 8property ${N} ny 9property ${N} nz 10`),X===!0&&(S+=`property ${Z} s 11property ${Z} t 12`),O===!0&&(S+=`property ${I} red 13property ${I} green 14property ${I} blue 15`);for(const o of P){const m=j[o];for(const n of R[o])S+=`property ${m} ${n} 16`}W===!0&&(S+=`element face ${q} 17property list uchar int vertex_index 18`),S+=`end_header 19`;const d=new dt,K=new ft;let Q=null;if(t.binary===!0){const o=new TextEncoder().encode(S),m=D(_),n=B?D(N):null,s=X?D(Z):null,a=O?D(I):null,h=k(I),y=at(I),x={},Y={};let w=0;for(const p of P){const i=j[p],z=D(i);x[p]=z,Y[p]=k(i),w+=R[p].length*z.size}const v=J*(3*m.size+(B?3*n.size:0)+(X?2*s.size:0)+(O?3*a.size:0)+w),U=W?q*(V*3+1):0,r=new DataView(new ArrayBuffer(o.length+v+U));new Uint8Array(r.buffer).set(o,0);let e=o.length,g=o.length+v,F=0;A(function(p,i){const z=i.getAttribute("position"),M=i.getAttribute("normal"),$=i.getAttribute("uv"),G=i.getAttribute("color"),C=i.getIndex();K.getNormalMatrix(p.matrixWorld);for(let u=0,T=z.count;u<T;u++){if(d.fromBufferAttribute(z,u),d.applyMatrix4(p.matrixWorld),m.write(r,e,d.x,t.littleEndian),e+=m.size,m.write(r,e,d.y,t.littleEndian),e+=m.size,m.write(r,e,d.z,t.littleEndian),e+=m.size,B===!0&&(M!=null?(d.fromBufferAttribute(M,u),d.applyMatrix3(K).normalize(),n.write(r,e,d.x,t.littleEndian),e+=n.size,n.write(r,e,d.y,t.littleEndian),e+=n.size,n.write(r,e,d.z,t.littleEndian),e+=n.size):(n.write(r,e,0,t.littleEndian),e+=n.size,n.write(r,e,0,t.littleEndian),e+=n.size,n.write(r,e,0,t.littleEndian),e+=n.size)),X===!0&&($!=null?(s.write(r,e,$.getX(u),t.littleEndian),e+=s.size,s.write(r,e,$.getY(u),t.littleEndian),e+=s.size):(s.write(r,e,0,t.littleEndian),e+=s.size,s.write(r,e,0,t.littleEndian),e+=s.size)),O===!0)if(G!=null){b.fromBufferAttribute(G,u),ot.workingToColorSpace(b,st);const E=h?b.r:Math.round(b.r*y),tt=h?b.g:Math.round(b.g*y),et=h?b.b:Math.round(b.b*y);a.write(r,e,E,t.littleEndian),e+=a.size,a.write(r,e,tt,t.littleEndian),e+=a.size,a.write(r,e,et,t.littleEndian),e+=a.size}else{const E=h?1:y;a.write(r,e,E,t.littleEndian),e+=a.size,a.write(r,e,E,t.littleEndian),e+=a.size,a.write(r,e,E,t.littleEndian),e+=a.size}for(const E of P){const tt=x[E],et=R[E].length,rt=i.getAttribute(E),ct=Y[E];for(let nt=0;nt<et;nt++){const it=rt!=null?lt(rt,u,nt):0;tt.write(r,e,ct?it:Math.round(it),t.littleEndian),e+=tt.size}}}if(W===!0)if(C!==null)for(let u=0,T=C.count;u<T;
19u+=3)r.setUint8(g,3),g+=1,r.setUint32(g,C.getX(u+0)+F,t.littleEndian),g+=V,r.setUint32(g,C.getX(u+1)+F,t.littleEndian),g+=V,r.setUint32(g,C.getX(u+2)+F,t.littleEndian),g+=V;else for(let u=0,T=z.count;u<T;u+=3)r.setUint8(g,3),g+=1,r.setUint32(g,F+u,t.littleEndian),g+=V,r.setUint32(g,F+u+1,t.littleEndian),g+=V,r.setUint32(g,F+u+2,t.littleEndian),g+=V;F+=z.count}),Q=r.buffer}else{let o=0,m="",n="";const s=k(_),a=k(N),h=k(Z),y=k(I),x=at(I),Y={};for(const v of P)Y[v]=k(j[v]);const w=(v,U)=>U?v:Math.round(v);A(function(v,U){const r=U.getAttribute("position"),e=U.getAttribute("normal"),g=U.getAttribute("uv"),F=U.getAttribute("color"),p=U.getIndex();K.getNormalMatrix(v.matrixWorld);for(let i=0,z=r.count;i<z;i++){d.fromBufferAttribute(r,i),d.applyMatrix4(v.matrixWorld);let M=w(d.x,s)+" "+w(d.y,s)+" "+w(d.z,s);if(B===!0&&(e!=null?(d.fromBufferAttribute(e,i),d.applyMatrix3(K).normalize(),M+=" "+w(d.x,a)+" "+w(d.y,a)+" "+w(d.z,a)):M+=" 0 0 0"),X===!0&&(g!=null?M+=" "+w(g.getX(i),h)+" "+w(g.getY(i),h):M+=" 0 0"),O===!0)if(F!=null){b.fromBufferAttribute(F,i),ot.workingToColorSpace(b,st);const $=y?b.r:Math.round(b.r*x),G=y?b.g:Math.round(b.g*x),C=y?b.b:Math.round(b.b*x);M+=` ${$} ${G} ${C}`}else{const $=y?1:x;M+=` ${$} ${$} ${$}`}for(const $ of P){const G=R[$].length,C=U.getAttribute($),u=Y[$];for(let T=0;T<G;T++){const E=C!=null?lt(C,i,T):0;M+=" "+w(E,u)}}m+=M+` 20`}if(W===!0){if(p!==null)for(let i=0,z=p.count;i<z;i+=3)n+=`3 ${p.getX(i+0)+o}`,n+=` ${p.getX(i+1)+o}`,n+=` ${p.getX(i+2)+o} 21`;else for(let i=0,z=r.count;i<z;i+=3)n+=`3 ${o+i} ${o+i+1} ${o+i+2} 22`;q+=p?p.count/3:r.count/3}o+=r.count}),Q=`${S}${m}${W?`${n} 23`:` 24`}`}return typeof f=="function"&&requestAnimationFrame(()=>f(Q)),Q}}function L(c){return c instanceof Int8Array?"char":c instanceof Uint8Array||c instanceof Uint8ClampedArray?"uchar":c instanceof Int16Array?"short":c instanceof Uint16Array?"ushort":c instanceof Int32Array?"int":c instanceof Uint32Array?"uint":c instanceof Float32Array?"float":c instanceof Float64Array?"double":"float"}function D(c){switch(c){case"char":return{write:(l,f,t)=>l.setInt8(f,t),size:1};case"uchar":return{write:(l,f,t)=>l.setUint8(f,t),size:1};case"short":return{write:(l,f,t,A)=>l.setInt16(f,t,A),size:2};case"ushort":return{write:(l,f,t,A)=>l.setUint16(f,t,A),size:2};case"int":return{write:(l,f,t,A)=>l.setInt32(f,t,A),size:4};case"uint":return{write:(l,f,t,A)=>l.setUint32(f,t,A),size:4};case"float":return{write:(l,f,t,A)=>l.setFloat32(f,t,A),size:4};case"double":return{write:(l,f,t,A)=>l.setFloat64(f,t,A),size:8}}}function k(c){return c==="float"||c==="double"}function lt(c,l,f){switch(f){case 0:return c.getX(l);case 1:return c.getY(l);case 2:return c.getZ(l);case 3:return c.getW(l)}}function at(c){switch(c){case"uchar":return 255;case"ushort":return 65535;default:return 1}}export{bt as PLYExporter};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.