1 |
- !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("babylonjs")):"function"==typeof define&&define.amd?define("babylonjs-serializers",["babylonjs"],t):"object"==typeof exports?exports["babylonjs-serializers"]=t(require("babylonjs")):e.SERIALIZERS=t(e.BABYLON)}("undefined"!=typeof self?self:"undefined"!=typeof global?global:this,function(e){return function(e){var t={};function o(r){if(t[r])return t[r].exports;var n=t[r]={i:r,l:!1,exports:{}};return e[r].call(n.exports,n,n.exports,o),n.l=!0,n.exports}return o.m=e,o.c=t,o.d=function(e,t,r){o.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},o.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},o.t=function(e,t){if(1&t&&(e=o(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(o.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var n in e)o.d(r,n,function(t){return e[t]}.bind(null,n));return r},o.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return o.d(t,"a",t),t},o.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},o.p="",o(o.s=14)}({0:function(t,o){t.exports=e},11:function(e,t){var o;o=function(){return this}();try{o=o||new Function("return this")()}catch(e){"object"==typeof window&&(o=window)}e.exports=o},14:function(e,t,o){"use strict";o.r(t),function(e){var r=o(5);o.d(t,"OBJExport",function(){return r.OBJExport});var n=void 0!==e?e:"undefined"!=typeof window?window:void 0;if(void 0!==n)for(var i in r)n.BABYLON[i]=r[i]}.call(this,o(11))},5:function(e,t,o){"use strict";o.r(t);var r=o(0),n=function(){function e(){}return e.OBJ=function(e,t,o,n){var i=[],u=1;t&&(o||(o="mat"),i.push("mtllib "+o+".mtl"));for(var s=0;s<e.length;s++){i.push("g object"+s),i.push("o object_"+s);var a=null;if(n){var l=r.Matrix.Translation(e[s].position.x,e[s].position.y,e[s].position.z);a=r.Matrix.Translation(-e[s].position.x,-e[s].position.y,-e[s].position.z),e[s].bakeTransformIntoVertices(l)}if(t){var f=e[s].material;f&&i.push("usemtl "+f.id)}var p=e[s].geometry;if(p){var c=p.getVerticesData("position"),d=p.getVerticesData("normal"),m=p.getVerticesData("uv"),b=p.getIndices(),h=0;if(c&&b){for(var x=0;x<c.length;x+=3)i.push("v "+c[x]+" "+c[x+1]+" "+c[x+2]),h++;if(null!=d)for(x=0;x<d.length;x+=3)i.push("vn "+d[x]+" "+d[x+1]+" "+d[x+2]);if(null!=m)for(x=0;x<m.length;x+=2)i.push("vt "+m[x]+" "+m[x+1]);for(x=0;x<b.length;x+=3){var v=[String(b[x+2]+u),String(b[x+1]+u),String(b[x]+u)],y=["","",""],g=v,T=null!=m?v:y,j=null!=d?v:y;i.push("f "+g[0]+"/"+T[0]+"/"+j[0]+" "+g[1]+"/"+T[1]+"/"+j[1]+" "+g[2]+"/"+T[2]+"/"+j[2])}n&&a&&e[s].bakeTransformIntoVertices(a),u+=h}else r.Tools.Warn("There are no position vertices or indices on the mesh!")}else r.Tools.Warn("No geometry is present on the mesh")}return i.join("\n")},e.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")},e}();o.d(t,"OBJExport",function(){return n})}})});
|