@loaders.gl/obj
Advanced tools
Comparing version
@@ -7,9 +7,9 @@ (function webpackUniversalModuleDefinition(root, factory) { | ||
else root['loaders'] = factory();})(globalThis, function () { | ||
"use strict";var __exports__=(()=>{var U=Object.create;var I=Object.defineProperty;var z=Object.getOwnPropertyDescriptor;var E=Object.getOwnPropertyNames;var _=Object.getPrototypeOf,J=Object.prototype.hasOwnProperty;var P=(o,e)=>()=>(e||o((e={exports:{}}).exports,e),e.exports),X=(o,e)=>{for(var r in e)I(o,r,{get:e[r],enumerable:!0})},A=(o,e,r,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of E(e))!J.call(o,s)&&s!==r&&I(o,s,{get:()=>e[s],enumerable:!(t=z(e,s))||t.enumerable});return o},L=(o,e,r)=>(A(o,e,"default"),r&&A(r,e,"default")),G=(o,e,r)=>(r=o!=null?U(_(o)):{},A(e||!o||!o.__esModule?I(r,"default",{value:o,enumerable:!0}):r,o)),Y=o=>A(I({},"__esModule",{value:!0}),o);var V=P((ae,D)=>{D.exports=globalThis.loaders});var v={};X(v,{MTLLoader:()=>ne,OBJLoader:()=>oe,OBJWorkerLoader:()=>S});L(v,G(V(),1));function W(o,e="float32"){return o instanceof Date?"date-millisecond":o instanceof Number?e:typeof o=="string"?"utf8":(o===null||o==="undefined","null")}function O(o){let e=Z(o);return e!=="null"?{type:e,nullable:!1}:o.length>0?(e=W(o[0]),{type:e,nullable:!0}):{type:"null",nullable:!0}}function Z(o){switch(o.constructor){case Int8Array:return"int8";case Uint8Array:case Uint8ClampedArray:return"uint8";case Int16Array:return"int16";case Uint16Array:return"uint16";case Int32Array:return"int32";case Uint32Array:return"uint32";case Float32Array:return"float32";case Float64Array:return"float64";default:return"null"}}function j(o){let e=1/0,r=1/0,t=1/0,s=-1/0,n=-1/0,l=-1/0,c=o.POSITION?o.POSITION.value:[],u=c&&c.length;for(let f=0;f<u;f+=3){let m=c[f],a=c[f+1],i=c[f+2];e=m<e?m:e,r=a<r?a:r,t=i<t?i:t,s=m>s?m:s,n=a>n?a:n,l=i>l?i:l}return[[e,r,t],[s,n,l]]}var Q=/^[og]\s*(.+)?/,$=/^mtllib /,q=/^usemtl /,T=class{constructor({index:e,name:r="",mtllib:t,smooth:s,groupStart:n}){this.index=e,this.name=r,this.mtllib=t,this.smooth=s,this.groupStart=n,this.groupEnd=-1,this.groupCount=-1,this.inherited=!1}clone(e=this.index){return new T({index:e,name:this.name,mtllib:this.mtllib,smooth:this.smooth,groupStart:0})}},k=class{constructor(e=""){this.name=e,this.geometry={vertices:[],normals:[],colors:[],uvs:[]},this.materials=[],this.smooth=!0,this.fromDeclaration=null}startMaterial(e,r){let t=this._finalize(!1);t&&(t.inherited||t.groupCount<=0)&&this.materials.splice(t.index,1);let s=new T({index:this.materials.length,name:e,mtllib:Array.isArray(r)&&r.length>0?r[r.length-1]:"",smooth:t!==void 0?t.smooth:this.smooth,groupStart:t!==void 0?t.groupEnd:0});return this.materials.push(s),s}currentMaterial(){if(this.materials.length>0)return this.materials[this.materials.length-1]}_finalize(e){let r=this.currentMaterial();if(r&&r.groupEnd===-1&&(r.groupEnd=this.geometry.vertices.length/3,r.groupCount=r.groupEnd-r.groupStart,r.inherited=!1),e&&this.materials.length>1)for(let t=this.materials.length-1;t>=0;t--)this.materials[t].groupCount<=0&&this.materials.splice(t,1);return e&&this.materials.length===0&&this.materials.push({name:"",smooth:this.smooth}),r}},w=class{constructor(){this.objects=[],this.object=null,this.vertices=[],this.normals=[],this.colors=[],this.uvs=[],this.materialLibraries=[],this.startObject("",!1)}startObject(e,r=!0){if(this.object&&!this.object.fromDeclaration){this.object.name=e,this.object.fromDeclaration=r;return}let t=this.object&&typeof this.object.currentMaterial=="function"?this.object.currentMaterial():void 0;if(this.object&&typeof this.object._finalize=="function"&&this.object._finalize(!0),this.object=new k(e),this.object.fromDeclaration=r,t&&t.name&&typeof t.clone=="function"){let s=t.clone(0);s.inherited=!0,this.object.materials.push(s)}this.objects.push(this.object)}finalize(){this.object&&typeof this.object._finalize=="function"&&this.object._finalize(!0)}parseVertexIndex(e,r){let t=parseInt(e);return(t>=0?t-1:t+r/3)*3}parseNormalIndex(e,r){let t=parseInt(e);return(t>=0?t-1:t+r/3)*3}parseUVIndex(e,r){let t=parseInt(e);return(t>=0?t-1:t+r/2)*2}addVertex(e,r,t){let s=this.vertices,n=this.object.geometry.vertices;n.push(s[e+0],s[e+1],s[e+2]),n.push(s[r+0],s[r+1],s[r+2]),n.push(s[t+0],s[t+1],s[t+2])}addVertexPoint(e){let r=this.vertices;this.object.geometry.vertices.push(r[e+0],r[e+1],r[e+2])}addVertexLine(e){let r=this.vertices;this.object.geometry.vertices.push(r[e+0],r[e+1],r[e+2])}addNormal(e,r,t){let s=this.normals,n=this.object.geometry.normals;n.push(s[e+0],s[e+1],s[e+2]),n.push(s[r+0],s[r+1],s[r+2]),n.push(s[t+0],s[t+1],s[t+2])}addColor(e,r,t){let s=this.colors,n=this.object.geometry.colors;n.push(s[e+0],s[e+1],s[e+2]),n.push(s[r+0],s[r+1],s[r+2]),n.push(s[t+0],s[t+1],s[t+2])}addUV(e,r,t){let s=this.uvs,n=this.object.geometry.uvs;n.push(s[e+0],s[e+1]),n.push(s[r+0],s[r+1]),n.push(s[t+0],s[t+1])}addUVLine(e){let r=this.uvs;this.object.geometry.uvs.push(r[e+0],r[e+1])}addFace(e,r,t,s,n,l,c,u,f){let m=this.vertices.length,a=this.parseVertexIndex(e,m),i=this.parseVertexIndex(r,m),h=this.parseVertexIndex(t,m);if(this.addVertex(a,i,h),s!==void 0&&s!==""){let p=this.uvs.length;a=this.parseUVIndex(s,p),i=this.parseUVIndex(n,p),h=this.parseUVIndex(l,p),this.addUV(a,i,h)}if(c!==void 0&&c!==""){let p=this.normals.length;a=this.parseNormalIndex(c,p),i=c===u?a:this.parseNormalIndex(u,p),h=c===f?a:this.parseNormalIndex(f,p),this.addNormal(a,i,h)}this.colors.length>0&&this.addColor(a,i,h)}addPointGeometry(e){this.object.geometry.type="Points";let r=this.vertices.length;for(let t of e)this.addVertexPoint(this.parseVertexIndex(t,r))}addLineGeometry(e,r){this.object.geometry.type="Line";let t=this.vertices.length,s=this.uvs.length;for(let n of e)this.addVertexLine(this.parseVertexIndex(n,t));for(let n of r)this.addUVLine(this.parseUVIndex(n,s))}};function R(o){let e=new w;o.indexOf(`\r | ||
"use strict";var __exports__=(()=>{var U=Object.create;var I=Object.defineProperty;var z=Object.getOwnPropertyDescriptor;var E=Object.getOwnPropertyNames;var _=Object.getPrototypeOf,J=Object.prototype.hasOwnProperty;var P=(o,e)=>()=>(e||o((e={exports:{}}).exports,e),e.exports),X=(o,e)=>{for(var r in e)I(o,r,{get:e[r],enumerable:!0})},A=(o,e,r,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of E(e))!J.call(o,s)&&s!==r&&I(o,s,{get:()=>e[s],enumerable:!(t=z(e,s))||t.enumerable});return o},L=(o,e,r)=>(A(o,e,"default"),r&&A(r,e,"default")),G=(o,e,r)=>(r=o!=null?U(_(o)):{},A(e||!o||!o.__esModule?I(r,"default",{value:o,enumerable:!0}):r,o)),Y=o=>A(I({},"__esModule",{value:!0}),o);var V=P((ae,D)=>{D.exports=globalThis.loaders});var v={};X(v,{MTLLoader:()=>ne,OBJLoader:()=>oe,OBJWorkerLoader:()=>S});L(v,G(V(),1));function W(o,e="float32"){return o instanceof Date?"date-millisecond":o instanceof Number?e:typeof o=="string"?"utf8":(o===null||o==="undefined","null")}function O(o){let e=Z(o);return e!=="null"?{type:e,nullable:!1}:o.length>0?(e=W(o[0]),{type:e,nullable:!0}):{type:"null",nullable:!0}}function Z(o){switch(o.constructor){case Int8Array:return"int8";case Uint8Array:case Uint8ClampedArray:return"uint8";case Int16Array:return"int16";case Uint16Array:return"uint16";case Int32Array:return"int32";case Uint32Array:return"uint32";case Float32Array:return"float32";case Float64Array:return"float64";default:return"null"}}function j(o){let e=1/0,r=1/0,t=1/0,s=-1/0,n=-1/0,l=-1/0,c=o.POSITION?o.POSITION.value:[],u=c&&c.length;for(let f=0;f<u;f+=3){let m=c[f],a=c[f+1],i=c[f+2];e=m<e?m:e,r=a<r?a:r,t=i<t?i:t,s=m>s?m:s,n=a>n?a:n,l=i>l?i:l}return[[e,r,t],[s,n,l]]}var Q=/^[og]\s*(.+)?/,$=/^mtllib /,q=/^usemtl /,T=class{constructor({index:e,name:r="",mtllib:t,smooth:s,groupStart:n}){this.index=e,this.name=r,this.mtllib=t,this.smooth=s,this.groupStart=n,this.groupEnd=-1,this.groupCount=-1,this.inherited=!1}clone(e=this.index){return new T({index:e,name:this.name,mtllib:this.mtllib,smooth:this.smooth,groupStart:0})}},k=class{constructor(e=""){this.name=e,this.geometry={vertices:[],normals:[],colors:[],uvs:[]},this.materials=[],this.smooth=!0,this.fromDeclaration=null}startMaterial(e,r){let t=this._finalize(!1);t&&(t.inherited||t.groupCount<=0)&&this.materials.splice(t.index,1);let s=new T({index:this.materials.length,name:e,mtllib:Array.isArray(r)&&r.length>0?r[r.length-1]:"",smooth:t!==void 0?t.smooth:this.smooth,groupStart:t!==void 0?t.groupEnd:0});return this.materials.push(s),s}currentMaterial(){if(this.materials.length>0)return this.materials[this.materials.length-1]}_finalize(e){let r=this.currentMaterial();if(r&&r.groupEnd===-1&&(r.groupEnd=this.geometry.vertices.length/3,r.groupCount=r.groupEnd-r.groupStart,r.inherited=!1),e&&this.materials.length>1)for(let t=this.materials.length-1;t>=0;t--)this.materials[t].groupCount<=0&&this.materials.splice(t,1);return e&&this.materials.length===0&&this.materials.push({name:"",smooth:this.smooth}),r}},w=class{constructor(){this.objects=[],this.object=null,this.vertices=[],this.normals=[],this.colors=[],this.uvs=[],this.materialLibraries=[],this.startObject("",!1)}startObject(e,r=!0){if(this.object&&!this.object.fromDeclaration){this.object.name=e,this.object.fromDeclaration=r;return}let t=this.object&&typeof this.object.currentMaterial=="function"?this.object.currentMaterial():void 0;if(this.object&&typeof this.object._finalize=="function"&&this.object._finalize(!0),this.object=new k(e),this.object.fromDeclaration=r,t&&t.name&&typeof t.clone=="function"){let s=t.clone(0);s.inherited=!0,this.object.materials.push(s)}this.objects.push(this.object)}finalize(){this.object&&typeof this.object._finalize=="function"&&this.object._finalize(!0)}parseVertexIndex(e,r){let t=parseInt(e);return(t>=0?t-1:t+r/3)*3}parseNormalIndex(e,r){let t=parseInt(e);return(t>=0?t-1:t+r/3)*3}parseUVIndex(e,r){let t=parseInt(e);return(t>=0?t-1:t+r/2)*2}addVertex(e,r,t){let s=this.vertices,n=this.object.geometry.vertices;n.push(s[e+0],s[e+1],s[e+2]),n.push(s[r+0],s[r+1],s[r+2]),n.push(s[t+0],s[t+1],s[t+2])}addVertexPoint(e){let r=this.vertices;this.object.geometry.vertices.push(r[e+0],r[e+1],r[e+2])}addVertexLine(e){let r=this.vertices;this.object.geometry.vertices.push(r[e+0],r[e+1],r[e+2])}addNormal(e,r,t){let s=this.normals,n=this.object.geometry.normals;n.push(s[e+0],s[e+1],s[e+2]),n.push(s[r+0],s[r+1],s[r+2]),n.push(s[t+0],s[t+1],s[t+2])}addColor(e,r,t){let s=this.colors,n=this.object.geometry.colors;n.push(s[e+0],s[e+1],s[e+2]),n.push(s[r+0],s[r+1],s[r+2]),n.push(s[t+0],s[t+1],s[t+2])}addUV(e,r,t){let s=this.uvs,n=this.object.geometry.uvs;n.push(s[e+0],s[e+1]),n.push(s[r+0],s[r+1]),n.push(s[t+0],s[t+1])}addUVLine(e){let r=this.uvs;this.object.geometry.uvs.push(r[e+0],r[e+1])}addFace(e,r,t,s,n,l,c,u,f){let m=this.vertices.length,a=this.parseVertexIndex(e,m),i=this.parseVertexIndex(r,m),h=this.parseVertexIndex(t,m);if(this.addVertex(a,i,h),s!==void 0&&s!==""){let p=this.uvs.length;a=this.parseUVIndex(s,p),i=this.parseUVIndex(n,p),h=this.parseUVIndex(l,p),this.addUV(a,i,h)}if(c!==void 0&&c!==""){let p=this.normals.length;a=this.parseNormalIndex(c,p),i=c===u?a:this.parseNormalIndex(u,p),h=c===f?a:this.parseNormalIndex(f,p),this.addNormal(a,i,h)}this.colors.length>0&&this.addColor(a,i,h)}addPointGeometry(e){this.object.geometry.type="Points";let r=this.vertices.length;for(let t of e)this.addVertexPoint(this.parseVertexIndex(t,r))}addLineGeometry(e,r){this.object.geometry.type="Line";let t=this.vertices.length,s=this.uvs.length;for(let n of e)this.addVertexLine(this.parseVertexIndex(n,t));for(let n of r)this.addUVLine(this.parseUVIndex(n,s))}};function C(o){let e=new w;o.indexOf(`\r | ||
`)!==-1&&(o=o.replace(/\r\n/g,` | ||
`)),o.indexOf(`\\ | ||
`)!==-1&&(o=o.replace(/\\\n/g,""));let r=o.split(` | ||
`),t="",s="",n=0,l=[],c=typeof"".trimLeft=="function";for(let m=0,a=r.length;m<a;m++)if(t=r[m],t=c?t.trimLeft():t.trim(),n=t.length,n!==0&&(s=t.charAt(0),s!=="#"))if(s==="v"){let i=t.split(/\s+/);switch(i[0]){case"v":e.vertices.push(parseFloat(i[1]),parseFloat(i[2]),parseFloat(i[3])),i.length>=7&&e.colors.push(parseFloat(i[4]),parseFloat(i[5]),parseFloat(i[6]));break;case"vn":e.normals.push(parseFloat(i[1]),parseFloat(i[2]),parseFloat(i[3]));break;case"vt":e.uvs.push(parseFloat(i[1]),parseFloat(i[2]));break;default:}}else if(s==="f"){let h=t.substr(1).trim().split(/\s+/),p=[];for(let d=0,g=h.length;d<g;d++){let y=h[d];if(y.length>0){let x=y.split("/");p.push(x)}}let b=p[0];for(let d=1,g=p.length-1;d<g;d++){let y=p[d],x=p[d+1];e.addFace(b[0],y[0],x[0],b[1],y[1],x[1],b[2],y[2],x[2])}}else if(s==="l"){let i=t.substring(1).trim().split(" "),h,p=[];if(t.indexOf("/")===-1)h=i;else{h=[];for(let b=0,d=i.length;b<d;b++){let g=i[b].split("/");g[0]!==""&&h.push(g[0]),g[1]!==""&&p.push(g[1])}}e.addLineGeometry(h,p)}else if(s==="p"){let h=t.substr(1).trim().split(" ");e.addPointGeometry(h)}else if((l=Q.exec(t))!==null){let i=(" "+l[0].substr(1).trim()).substr(1);e.startObject(i)}else if(q.test(t))e.object.startMaterial(t.substring(7).trim(),e.materialLibraries);else if($.test(t))e.materialLibraries.push(t.substring(7).trim());else if(s==="s"){if(l=t.split(" "),l.length>1){let h=l[1].trim().toLowerCase();e.object.smooth=h!=="0"&&h!=="off"}else e.object.smooth=!0;let i=e.object.currentMaterial();i&&(i.smooth=e.object.smooth)}else{if(t==="\0")continue;throw new Error(`Unexpected line: "${t}"`)}e.finalize();let u=[],f=[];for(let m of e.objects){let{geometry:a}=m;if(a.vertices.length===0)continue;let i={header:{vertexCount:a.vertices.length/3},attributes:{}};switch(a.type){case"Points":i.mode=0;break;case"Line":i.mode=1;break;default:i.mode=4;break}i.attributes.POSITION={value:new Float32Array(a.vertices),size:3},a.normals.length>0&&(i.attributes.NORMAL={value:new Float32Array(a.normals),size:3}),a.colors.length>0&&(i.attributes.COLOR_0={value:new Float32Array(a.colors),size:3}),a.uvs.length>0&&(i.attributes.TEXCOORD_0={value:new Float32Array(a.uvs),size:2}),i.materials=[];for(let h of m.materials){let p={name:h.name,flatShading:!h.smooth};i.materials.push(p),f.push(p)}i.name=m.name,u.push(i)}return{meshes:u,materials:f}}function C(o,e={}){let r={};for(let s in e)s!=="value"&&(r[s]=JSON.stringify(e[s]));let t=[];for(let s in o){let n=o[s],l=H(s,n);t.push(l)}return{fields:t,metadata:r}}function H(o,e){let r={};for(let n in e)n!=="value"&&(r[n]=JSON.stringify(e[n]));let{type:t}=O(e.value);return e.size===1||e.size===void 0||(t={type:"fixed-size-list",listSize:e.size,children:[{name:"values",type:t}]}),{name:o,type:t,nullable:!1,metadata:r}}function M(o,e){let{meshes:r}=R(o),t=r.reduce((c,u)=>c+u.header.vertexCount,0),s=K(r,t),n={vertexCount:t,boundingBox:j(s)},l=C(s,{mode:4,boundingBox:n.boundingBox});return{loaderData:{header:{}},schema:l,header:n,mode:4,topology:"point-list",attributes:s}}function K(o,e){let r=new Float32Array(e*3),t,s,n,l=0;for(let u of o){let{POSITION:f,NORMAL:m,COLOR_0:a,TEXCOORD_0:i}=u.attributes;r.set(f.value,l*3),m&&(t=t||new Float32Array(e*3),t.set(m.value,l*3)),a&&(s=s||new Float32Array(e*3),s.set(a.value,l*3)),i&&(n=n||new Float32Array(e*2),n.set(i.value,l*2)),l+=f.value.length/3}let c={};return c.POSITION={value:r,size:3},t&&(c.NORMAL={value:t,size:3}),s&&(c.COLOR_0={value:s,size:3}),n&&(c.TEXCOORD_0={value:n,size:2}),c}var ee="4.3.0-alpha.7",S={dataType:null,batchType:null,name:"OBJ",id:"obj",module:"obj",version:ee,worker:!0,extensions:["obj"],mimeTypes:["text/plain"],testText:te,options:{obj:{}}};function te(o){return o[0]==="v"}var re=/\s+/;function B(o,e){let r=[],t={name:"placeholder"},s=o.split(` | ||
`);for(let n of s){if(n=n.trim(),n.length===0||n.charAt(0)==="#")continue;let l=n.indexOf(" "),c=l>=0?n.substring(0,l):n;c=c.toLowerCase();let u=l>=0?n.substring(l+1):"";switch(u=u.trim(),c){case"newmtl":t={name:u},r.push(t);break;case"ka":t.ambientColor=F(u);break;case"kd":t.diffuseColor=F(u);break;case"map_kd":t.diffuseTextureUrl=u;break;case"ks":t.specularColor=F(u);break;case"map_ks":t.specularTextureUrl=u;break;case"ke":t.emissiveColor=F(u);break;case"map_ke":t.emissiveTextureUrl=u;break;case"ns":t.shininess=parseFloat(u);break;case"map_ns":break;case"ni":t.refraction=parseFloat(u);break;case"illum":t.illumination=parseFloat(u);break;default:break}}return r}function F(o,e){let r=o.split(re,3);return[parseFloat(r[0]),parseFloat(r[1]),parseFloat(r[2])]}var se="4.3.0-alpha.7",N={dataType:null,batchType:null,name:"MTL",id:"mtl",module:"mtl",version:se,worker:!0,extensions:["mtl"],mimeTypes:["text/plain"],testText:o=>o.includes("newmtl"),options:{mtl:{}}};var oe={...S,parse:async(o,e)=>M(new TextDecoder().decode(o),e),parseTextSync:(o,e)=>M(o,e)},ne={...N,parse:async(o,e)=>B(new TextDecoder().decode(o),e?.mtl),parseTextSync:(o,e)=>B(o,e?.mtl)};return Y(v);})(); | ||
`),t="",s="",n=0,l=[],c=typeof"".trimLeft=="function";for(let m=0,a=r.length;m<a;m++)if(t=r[m],t=c?t.trimLeft():t.trim(),n=t.length,n!==0&&(s=t.charAt(0),s!=="#"))if(s==="v"){let i=t.split(/\s+/);switch(i[0]){case"v":e.vertices.push(parseFloat(i[1]),parseFloat(i[2]),parseFloat(i[3])),i.length>=7&&e.colors.push(parseFloat(i[4]),parseFloat(i[5]),parseFloat(i[6]));break;case"vn":e.normals.push(parseFloat(i[1]),parseFloat(i[2]),parseFloat(i[3]));break;case"vt":e.uvs.push(parseFloat(i[1]),parseFloat(i[2]));break;default:}}else if(s==="f"){let h=t.substr(1).trim().split(/\s+/),p=[];for(let d=0,g=h.length;d<g;d++){let y=h[d];if(y.length>0){let x=y.split("/");p.push(x)}}let b=p[0];for(let d=1,g=p.length-1;d<g;d++){let y=p[d],x=p[d+1];e.addFace(b[0],y[0],x[0],b[1],y[1],x[1],b[2],y[2],x[2])}}else if(s==="l"){let i=t.substring(1).trim().split(" "),h,p=[];if(t.indexOf("/")===-1)h=i;else{h=[];for(let b=0,d=i.length;b<d;b++){let g=i[b].split("/");g[0]!==""&&h.push(g[0]),g[1]!==""&&p.push(g[1])}}e.addLineGeometry(h,p)}else if(s==="p"){let h=t.substr(1).trim().split(" ");e.addPointGeometry(h)}else if((l=Q.exec(t))!==null){let i=(" "+l[0].substr(1).trim()).substr(1);e.startObject(i)}else if(q.test(t))e.object.startMaterial(t.substring(7).trim(),e.materialLibraries);else if($.test(t))e.materialLibraries.push(t.substring(7).trim());else if(s==="s"){if(l=t.split(" "),l.length>1){let h=l[1].trim().toLowerCase();e.object.smooth=h!=="0"&&h!=="off"}else e.object.smooth=!0;let i=e.object.currentMaterial();i&&(i.smooth=e.object.smooth)}else{if(t==="\0")continue;throw new Error(`Unexpected line: "${t}"`)}e.finalize();let u=[],f=[];for(let m of e.objects){let{geometry:a}=m;if(a.vertices.length===0)continue;let i={header:{vertexCount:a.vertices.length/3},attributes:{}};switch(a.type){case"Points":i.mode=0;break;case"Line":i.mode=1;break;default:i.mode=4;break}i.attributes.POSITION={value:new Float32Array(a.vertices),size:3},a.normals.length>0&&(i.attributes.NORMAL={value:new Float32Array(a.normals),size:3}),a.colors.length>0&&(i.attributes.COLOR_0={value:new Float32Array(a.colors),size:3}),a.uvs.length>0&&(i.attributes.TEXCOORD_0={value:new Float32Array(a.uvs),size:2}),i.materials=[];for(let h of m.materials){let p={name:h.name,flatShading:!h.smooth};i.materials.push(p),f.push(p)}i.name=m.name,u.push(i)}return{meshes:u,materials:f}}function R(o,e={}){let r={};for(let s in e)s!=="value"&&(r[s]=JSON.stringify(e[s]));let t=[];for(let s in o){let n=o[s],l=H(s,n);t.push(l)}return{fields:t,metadata:r}}function H(o,e){let r={};for(let n in e)n!=="value"&&(r[n]=JSON.stringify(e[n]));let{type:t}=O(e.value);return e.size===1||e.size===void 0||(t={type:"fixed-size-list",listSize:e.size,children:[{name:"values",type:t}]}),{name:o,type:t,nullable:!1,metadata:r}}function M(o,e){let{meshes:r}=C(o),t=r.reduce((c,u)=>c+u.header.vertexCount,0),s=K(r,t),n={vertexCount:t,boundingBox:j(s)},l=R(s,{mode:4,boundingBox:n.boundingBox});return{loaderData:{header:{}},schema:l,header:n,mode:4,topology:"point-list",attributes:s}}function K(o,e){let r=new Float32Array(e*3),t,s,n,l=0;for(let u of o){let{POSITION:f,NORMAL:m,COLOR_0:a,TEXCOORD_0:i}=u.attributes;r.set(f.value,l*3),m&&(t=t||new Float32Array(e*3),t.set(m.value,l*3)),a&&(s=s||new Float32Array(e*3),s.set(a.value,l*3)),i&&(n=n||new Float32Array(e*2),n.set(i.value,l*2)),l+=f.value.length/3}let c={};return c.POSITION={value:r,size:3},t&&(c.NORMAL={value:t,size:3}),s&&(c.COLOR_0={value:s,size:3}),n&&(c.TEXCOORD_0={value:n,size:2}),c}var ee="4.3.0-alpha.8",S={dataType:null,batchType:null,name:"OBJ",id:"obj",module:"obj",version:ee,worker:!0,extensions:["obj"],mimeTypes:["text/plain"],testText:te,options:{obj:{}}};function te(o){return o[0]==="v"}var re=/\s+/;function B(o,e){let r=[],t={name:"placeholder"},s=o.split(` | ||
`);for(let n of s){if(n=n.trim(),n.length===0||n.charAt(0)==="#")continue;let l=n.indexOf(" "),c=l>=0?n.substring(0,l):n;c=c.toLowerCase();let u=l>=0?n.substring(l+1):"";switch(u=u.trim(),c){case"newmtl":t={name:u},r.push(t);break;case"ka":t.ambientColor=F(u);break;case"kd":t.diffuseColor=F(u);break;case"map_kd":t.diffuseTextureUrl=u;break;case"ks":t.specularColor=F(u);break;case"map_ks":t.specularTextureUrl=u;break;case"ke":t.emissiveColor=F(u);break;case"map_ke":t.emissiveTextureUrl=u;break;case"ns":t.shininess=parseFloat(u);break;case"map_ns":break;case"ni":t.refraction=parseFloat(u);break;case"illum":t.illumination=parseFloat(u);break;default:break}}return r}function F(o,e){let r=o.split(re,3);return[parseFloat(r[0]),parseFloat(r[1]),parseFloat(r[2])]}var se="4.3.0-alpha.8",N={dataType:null,batchType:null,name:"MTL",id:"mtl",module:"mtl",version:se,worker:!0,extensions:["mtl"],mimeTypes:["text/plain"],testText:o=>o.includes("newmtl"),options:{mtl:{}}};var oe={...S,parse:async(o,e)=>M(new TextDecoder().decode(o),e),parseTextSync:(o,e)=>M(o,e)},ne={...N,parse:async(o,e)=>B(new TextDecoder().decode(o),e?.mtl),parseTextSync:(o,e)=>B(o,e?.mtl)};return Y(v);})(); | ||
return __exports__; | ||
}); |
// __VERSION__ is injected by babel-plugin-version-inline | ||
// @ts-ignore TS2304: Cannot find name '__VERSION__'. | ||
const VERSION = typeof "4.3.0-alpha.7" !== 'undefined' ? "4.3.0-alpha.7" : 'latest'; | ||
const VERSION = typeof "4.3.0-alpha.8" !== 'undefined' ? "4.3.0-alpha.8" : 'latest'; | ||
/** | ||
@@ -5,0 +5,0 @@ * Loader for the MTL material format |
// __VERSION__ is injected by babel-plugin-version-inline | ||
// @ts-ignore TS2304: Cannot find name '__VERSION__'. | ||
const VERSION = typeof "4.3.0-alpha.7" !== 'undefined' ? "4.3.0-alpha.7" : 'latest'; | ||
const VERSION = typeof "4.3.0-alpha.8" !== 'undefined' ? "4.3.0-alpha.8" : 'latest'; | ||
/** | ||
@@ -5,0 +5,0 @@ * Worker loader for the OBJ geometry format |
@@ -744,3 +744,3 @@ "use strict"; | ||
// src/obj-loader.ts | ||
var VERSION = true ? "4.3.0-alpha.7" : "latest"; | ||
var VERSION = true ? "4.3.0-alpha.8" : "latest"; | ||
var OBJLoader = { | ||
@@ -835,3 +835,3 @@ dataType: null, | ||
// src/mtl-loader.ts | ||
var VERSION2 = true ? "4.3.0-alpha.7" : "latest"; | ||
var VERSION2 = true ? "4.3.0-alpha.8" : "latest"; | ||
var MTLLoader = { | ||
@@ -838,0 +838,0 @@ dataType: null, |
{ | ||
"name": "@loaders.gl/obj", | ||
"version": "4.3.0-alpha.8", | ||
"version": "4.3.0-beta.1", | ||
"description": "Framework-independent loader for the OBJ format", | ||
@@ -45,4 +45,4 @@ "license": "MIT", | ||
"dependencies": { | ||
"@loaders.gl/loader-utils": "4.3.0-alpha.8", | ||
"@loaders.gl/schema": "4.3.0-alpha.8" | ||
"@loaders.gl/loader-utils": "4.3.0-beta.1", | ||
"@loaders.gl/schema": "4.3.0-beta.1" | ||
}, | ||
@@ -52,3 +52,3 @@ "peerDependencies": { | ||
}, | ||
"gitHead": "c458e0c3a09543cd7c4a293d3c3f08c12acf78c0" | ||
"gitHead": "992d24e7d4e3015a91fa1cbfe87ee7dc1b333322" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
196912
0.02%+ Added
+ Added
+ Added
- Removed
- Removed
- Removed