var BABYLON;!(function(e){var t=(function(){function t(){this.materials=[],this.parseMTL=function(s,r,n){for(var i,a,o=r.split("\n"),l=0;l=0?u.substring(0,p):u;h=h.toLowerCase();var f=p>=0?u.substring(p+1).trim():"";"newmtl"===h?(a&&this.materials.push(a),a=new e.StandardMaterial(f,s)):"kd"===h?(i=f.split(/\s+/,3),a.diffuseColor=e.Color3.FromArray(i)):"ka"===h?(i=f.split(/\s+/,3),a.ambientColor=e.Color3.FromArray(i)):"ks"===h?(i=f.split(/\s+/,3),a.specularColor=e.Color3.FromArray(i)):"ns"===h?a.specularPower=f:"d"===h?a.alpha=f:"map_ka"===h?a.ambientTexture=t._getTexture(n,f,s):"map_kd"===h?a.diffuseTexture=t._getTexture(n,f,s):"map_ks"===h?a.specularTexture=t._getTexture(n,f,s):"map_ns"===h||("map_bump"===h?a.bumpTexture=t._getTexture(n,f,s):"map_d"===h&&(a.opacityTexture=t._getTexture(n,f,s)))}}this.materials.push(a)}}return t._getTexture=function(t,s,r){var n=t;if("file:"===t){var i=s.lastIndexOf("\\");-1===i&&(i=s.lastIndexOf("/")),n+=i>-1?s.substr(i+1):s}else n+=s;return new e.Texture(n,r)},t})();e.MTLFileLoader=t;var s=(function(){function s(){this.extensions=".obj",this.obj=/^o/,this.group=/^g/,this.mtllib=/^mtllib /,this.usemtl=/^usemtl /,this.smooth=/^s /,this.vertexPattern=/v( +[\d|\.|\+|\-|e|E]+)( +[\d|\.|\+|\-|e|E]+)( +[\d|\.|\+|\-|e|E]+)/,this.normalPattern=/vn( +[\d|\.|\+|\-|e|E]+)( +[\d|\.|\+|\-|e|E]+)( +[\d|\.|\+|\-|e|E]+)/,this.uvPattern=/vt( +[\d|\.|\+|\-|e|E]+)( +[\d|\.|\+|\-|e|E]+)/,this.facePattern1=/f\s+(([\d]{1,}[\s]?){3,})+/,this.facePattern2=/f\s+((([\d]{1,}\/[\d]{1,}[\s]?){3,})+)/,this.facePattern3=/f\s+((([\d]{1,}\/[\d]{1,}\/[\d]{1,}[\s]?){3,})+)/,this.facePattern4=/f\s+((([\d]{1,}\/\/[\d]{1,}[\s]?){3,})+)/}return s.prototype._loadMTL=function(t,s,r){var n=e.Tools.BaseUrl+s+t;e.Tools.LoadFile(n,r,null,null,!1,(function(){console.warn("Error - Unable to load "+n)}))},s.prototype.importMesh=function(e,t,s,r,n,i,a){var o=this._parseSolid(e,t,s,r);return n&&o.forEach((function(e){n.push(e)})),!0},s.prototype.load=function(e,t,s){return this.importMesh(null,e,t,s,null,null,null)},s.prototype._parseSolid=function(r,n,i,a){for(var o,l=[],u=[],p=[],h=[],f=[],m=[],c=[],d=[],v=[],x=0,g=!1,T=[],_=[],I=[],P=[],b="",y="",F=new t,L=1,O=!0,w=function(e,t){e[t[0]]||(e[t[0]]={normals:[],idx:[]});var s=e[t[0]].normals.indexOf(t[1]);return-1===s?-1:e[t[0]].idx[s]},E=function(e,t){e[t[0]]||(e[t[0]]={normals:[],idx:[],uv:[]});var s=e[t[0]].normals.indexOf(t[1]);return 1!=s&&t[2]==e[t[0]].uv[s]?e[t[0]].idx[s]:-1},M=function(e,t,r,n,i,a){var o;o=s.OPTIMIZE_WITH_UV?E(v,[e,r,t]):w(v,[e,r]),-1==o?(f.push(m.length),m.push(n),c.push(i),d.push(a),v[e].normals.push(r),v[e].idx.push(x++),s.OPTIMIZE_WITH_UV&&v[e].uv.push(t)):f.push(o)},V=function(){for(var e=0;e0&&(o=h[h.length-1],V(),f.reverse(),o.indices=f.slice(),o.positions=T.slice(),o.normals=_.slice(),o.uvs=I.slice(),f=[],T=[],_=[],I=[])},N=i.split("\n"),U=0;U-1;)i.push(s),r=s+1;if(-1==s&&0==i.length)F.materials[t].dispose();else for(var o=0;o