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,a=i<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,o):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,o,r);else for(var u=e.length-1;u>=0;u--)(n=e[u])&&(a=(i<3?n(a):i>3?n(t,o,a):n(t,o))||a);return i>3&&a&&Object.defineProperty(t,o,a),a},__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=[],a=1;o&&(r||(r="mat"),i.push("mtllib "+r+".mtl"));for(var u=0;u<t.length;u++){i.push("g object"+u),i.push("o object_"+u);var s=null;if(n){var p=e.Matrix.Translation(t[u].position.x,t[u].position.y,t[u].position.z);s=e.Matrix.Translation(-t[u].position.x,-t[u].position.y,-t[u].position.z),t[u].bakeTransformIntoVertices(p)}if(o){var f=t[u].material;f&&i.push("usemtl "+f.id)}var c=t[u].geometry;if(c){var l=c.getVerticesData("position"),d=c.getVerticesData("normal"),h=c.getVerticesData("uv"),m=c.getIndices(),b=0;if(l&&d&&h&&m){for(var x=0;x<l.length;x+=3)i.push("v "+l[x]+" "+l[x+1]+" "+l[x+2]),b++;for(x=0;x<d.length;x+=3)i.push("vn "+d[x]+" "+d[x+1]+" "+d[x+2]);for(x=0;x<h.length;x+=2)i.push("vt "+h[x]+" "+h[x+1]);for(x=0;x<m.length;x+=3)i.push("f "+(m[x+2]+a)+"/"+(m[x+2]+a)+"/"+(m[x+2]+a)+" "+(m[x+1]+a)+"/"+(m[x+1]+a)+"/"+(m[x+1]+a)+" "+(m[x]+a)+"/"+(m[x]+a)+"/"+(m[x]+a));n&&s&&t[u].bakeTransformIntoVertices(s),a+=b}}}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}));
|