1 |
- var babylonDependency;try{babylonDependency=BABYLON||"undefined"!=typeof require&&require("../babylon.max")}catch(e){babylonDependency=BABYLON||"undefined"!=typeof require&&require("babylonjs")}var BABYLON=babylonDependency,__decorate=this&&this.__decorate||function(e,t,o,r){var n,i=arguments.length,u=i<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,o):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)u=Reflect.decorate(e,t,o,r);else for(var s=e.length-1;s>=0;s--)(n=e[s])&&(u=(i<3?n(u):i>3?n(t,o,u):n(t,o))||u);return i>3&&u&&Object.defineProperty(t,o,u),u},__extends=this&&this.__extends||(function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var o in t)t.hasOwnProperty(o)&&(e[o]=t[o])};return function(t,o){function r(){this.constructor=t}e(t,o),t.prototype=null===o?Object.create(o):(r.prototype=o.prototype,new r)}})(),BABYLON;!(function(e){var t=(function(){function t(){}return t.OBJ=function(t,o,r,n){var i=[],u=1;o&&(r||(r="mat"),i.push("mtllib "+r+".mtl"));for(var s=0;s<t.length;s++){if(i.push("g object"+s),i.push("o object_"+s),n){var a=e.Matrix.Translation(t[s].position.x,t[s].position.y,t[s].position.z),p=e.Matrix.Translation(-t[s].position.x,-t[s].position.y,-t[s].position.z);t[s].bakeTransformIntoVertices(a)}o&&i.push("usemtl "+t[s].material.id);for(var c=t[s].geometry,f=c.getVerticesData("position"),l=c.getVerticesData("normal"),d=c.getVerticesData("uv"),h=c.getIndices(),m=0,b=0;b<f.length;b+=3)i.push("v "+f[b]+" "+f[b+1]+" "+f[b+2]),m++;for(b=0;b<l.length;b+=3)i.push("vn "+l[b]+" "+l[b+1]+" "+l[b+2]);for(b=0;b<d.length;b+=2)i.push("vt "+d[b]+" "+d[b+1]);for(b=0;b<h.length;b+=3)i.push("f "+(h[b+2]+u)+"/"+(h[b+2]+u)+"/"+(h[b+2]+u)+" "+(h[b+1]+u)+"/"+(h[b+1]+u)+"/"+(h[b+1]+u)+" "+(h[b]+u)+"/"+(h[b]+u)+"/"+(h[b]+u));n&&t[s].bakeTransformIntoVertices(p),u+=m}return i.join("\n")},t.MTL=function(e){var t=[],o=e.material;t.push("newmtl mat1"),t.push(" Ns "+o.specularPower.toFixed(4)),t.push(" Ni 1.5000"),t.push(" d "+o.alpha.toFixed(4)),t.push(" Tr 0.0000"),t.push(" Tf 1.0000 1.0000 1.0000"),t.push(" illum 2"),t.push(" Ka "+o.ambientColor.r.toFixed(4)+" "+o.ambientColor.g.toFixed(4)+" "+o.ambientColor.b.toFixed(4)),t.push(" Kd "+o.diffuseColor.r.toFixed(4)+" "+o.diffuseColor.g.toFixed(4)+" "+o.diffuseColor.b.toFixed(4)),t.push(" Ks "+o.specularColor.r.toFixed(4)+" "+o.specularColor.g.toFixed(4)+" "+o.specularColor.b.toFixed(4)),t.push(" Ke "+o.emissiveColor.r.toFixed(4)+" "+o.emissiveColor.g.toFixed(4)+" "+o.emissiveColor.b.toFixed(4));return o.ambientTexture&&t.push(" map_Ka "+o.ambientTexture.name),o.diffuseTexture&&t.push(" map_Kd "+o.diffuseTexture.name),o.specularTexture&&t.push(" map_Ks "+o.specularTexture.name),o.bumpTexture&&t.push(" map_bump -imfchan z "+o.bumpTexture.name),o.opacityTexture&&t.push(" map_d "+o.opacityTexture.name),t.join("\n")},t})();e.OBJExport=t})(BABYLON||(BABYLON={})),(function(e,t){e&&e.BABYLON||("object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.BJSSerializers=t():e.BABYLON=t())})(this,(function(){return BABYLON}));
|