1234 |
- !(function(e,r){var t=[],n=e.BABYLON||this.BABYLON;"object"==typeof exports&&"object"==typeof module?(n=n||require("babylonjs"),module.exports=r(n)):"function"==typeof define&&define.amd?(t.push("babylonjs"),define("babylonjs-loaders",t,r)):"object"==typeof exports?(n=n||require("babylonjs"),exports["babylonjs-loaders"]=r(n)):e.BABYLON=r(n)})(this,(function(e){e=e||this.BABYLON;var e,r=(this&&this.__decorate,this&&this.__extends||(function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,r){e.__proto__=r}||function(e,r){for(var t in r)r.hasOwnProperty(t)&&(e[t]=r[t])};return function(r,t){function n(){this.constructor=r}e(r,t),r.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}})());!(function(e){var r=(function(){function r(){this.solidPattern=/solid (\S*)([\S\s]*)endsolid[ ]*(\S*)/g,this.facetsPattern=/facet([\s\S]*?)endfacet/g,this.normalPattern=/normal[\s]+([\-+]?[0-9]+\.?[0-9]*([eE][\-+]?[0-9]+)?)+[\s]+([\-+]?[0-9]*\.?[0-9]+([eE][\-+]?[0-9]+)?)+[\s]+([\-+]?[0-9]*\.?[0-9]+([eE][\-+]?[0-9]+)?)+/g,this.vertexPattern=/vertex[\s]+([\-+]?[0-9]+\.?[0-9]*([eE][\-+]?[0-9]+)?)+[\s]+([\-+]?[0-9]*\.?[0-9]+([eE][\-+]?[0-9]+)?)+[\s]+([\-+]?[0-9]*\.?[0-9]+([eE][\-+]?[0-9]+)?)+/g,this.name="stl",this.extensions={".stl":{isBinary:!0}}}return r.prototype.importMesh=function(r,t,n,o,a,i,s){var l;if(this.isBinary(n)){var u=new e.Mesh("stlmesh",t);return this.parseBinary(u,n),a&&a.push(u),!0}for(var c=new Uint8Array(n),d="",f=0;f<n.byteLength;f++)d+=String.fromCharCode(c[f]);for(n=d;l=this.solidPattern.exec(n);){var h=l[1];if(h!=l[3])return e.Tools.Error("Error in STL, solid name != endsolid name"),!1;if(r&&h)if(r instanceof Array){if(!r.indexOf(h))continue}else if(h!==r)continue;h=h||"stlmesh";var u=new e.Mesh(h,t);this.parseASCII(u,l[2]),a&&a.push(u)}return!0},r.prototype.load=function(e,r,t){var n=this.importMesh(null,e,r,t,null,null,null);return n&&e.createDefaultCameraOrLight(),n},r.prototype.loadAssetContainer=function(r,t,n,o){var a=new e.AssetContainer(r);return this.importMesh(null,r,t,n,a.meshes,null,null),a.removeAllFromScene(),a},r.prototype.isBinary=function(e){var r,t;if(t=new DataView(e),r=50,84+t.getUint32(80,!0)*r===t.byteLength)return!0;for(var n=t.byteLength,o=0;o<n;o++)if(t.getUint8(o)>127)return!0;return!1},r.prototype.parseBinary=function(r,t){for(var n=new DataView(t),o=n.getUint32(80,!0),a=0,i=new Float32Array(3*o*3),s=new Float32Array(3*o*3),l=new Uint32Array(3*o),u=0,c=0;c<o;c++){for(var d=84+50*c,f=n.getFloat32(d,!0),h=n.getFloat32(d+4,!0),p=n.getFloat32(d+8,!0),m=1;m<=3;m++){var _=d+12*m;i[a]=n.getFloat32(_,!0),i[a+2]=n.getFloat32(_+4,!0),i[a+1]=n.getFloat32(_+8,!0),s[a]=f,s[a+2]=h,s[a+1]=p,a+=3}l[u]=u++,l[u]=u++,l[u]=u++}r.setVerticesData(e.VertexBuffer.PositionKind,i),r.setVerticesData(e.VertexBuffer.NormalKind,s),r.setIndices(l),r.computeWorldMatrix(!0)},r.prototype.parseASCII=function(r,t){for(var n,o=[],a=[],i=[],s=0;n=this.facetsPattern.exec(t);){var l=n[1],u=this.normalPattern.exec(l);if(this.normalPattern.lastIndex=0,u){for(var c,d=[Number(u[1]),Number(u[5]),Number(u[3])];c=this.vertexPattern.exec(l);)o.push(Number(c[1]),Number(c[5]),Number(c[3])),a.push(d[0],d[1],d[2]);i.push(s++,s++,s++),this.vertexPattern.lastIndex=0}}this.facetsPattern.lastIndex=0,r.setVerticesData(e.VertexBuffer.PositionKind,o),r.setVerticesData(e.VertexBuffer.NormalKind,a),r.setIndices(i),r.computeWorldMatrix(!0)},r})();e.STLFileLoader=r,e.SceneLoader&&e.SceneLoader.RegisterPlugin(new r)})(e||(e={}));var e;!(function(e){var r=(function(){function r(){this.materials=[]}return r.prototype.parseMTL=function(t,n,o){if(!(n instanceof ArrayBuffer)){for(var a,i=n.split("\n"),s=/\s+/,l=null,u=0;u<i.length;u++){var c=i[u].trim();if(0!==c.length&&"#"!==c.charAt(0)){var d=c.indexOf(" "),f=d>=0?c.substring(0,d):c;f=f.toLowerCase();var h=d>=0?c.substring(d+1).trim():"";"newmtl"===f?(l&&this.materials.push(l),l=new e.StandardMaterial(h,t)):"kd"===f&&l?(a=h.split(s,3).map(parseFloat),l.diffuseColor=e.Color3.FromArray(a)):"ka"===f&&l?(a=h.split(s,3).map(parseFloat),l.ambientColor=e.Color3.FromArray(a)):"ks"===f&&l?(a=h.split(s,3).map(parseFloat),l.specularColor=e.Color3.FromArray(a)):"ke"===f&&l?(a=h.split(s,3).map(parseFloat),l.emissiveColor=e.Color3.FromArray(a)):"ns"===f&&l?l.specularPower=parseFloat(h):"d"===f&&l?l.alpha=parseFloat(h):"map_ka"===f&&l?l.ambientTexture=r._getTexture(o,h,t):"map_kd"===f&&l?l.diffuseTexture=r._getTexture(o,h,t):"map_ks"===f&&l?l.specularTexture=r._getTexture(o,h,t):"map_ns"===f||("map_bump"===f&&l?l.bumpTexture=r._getTexture(o,h,t):"map_d"===f&&l&&(l.opacityTexture=r._getTexture(o,h,t)))}}l&&this.materials.push(l)}},r._getTexture=function(r,t,n){if(!t)return null;var o=r;if("file:"===r){var a=t.lastIndexOf("\\");-1===a&&(a=t.lastIndexOf("/")),o+=a>-1?t.substr(a+1):t}else o+=t;return new e.Texture(o,n)},r})();e.MTLFileLoader=r;var t=(function(){function t(){this.name="obj",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 t.prototype._loadMTL=function(r,t,n){var o=e.Tools.BaseUrl+t+r;e.Tools.LoadFile(o,n,void 0,void 0,!1,(function(){console.warn("Error - Unable to load "+o)}))},t.prototype.importMesh=function(e,r,t,n,o,a,i){var s=this._parseSolid(e,r,t,n);return o&&s.forEach((function(e){o.push(e)})),!0},t.prototype.load=function(e,r,t){return this.importMesh(null,e,r,t,null,null,null)},t.prototype.loadAssetContainer=function(r,t,n,o){var a=new e.AssetContainer(r);return this.importMesh(null,r,t,n,a.meshes,null,null),a.removeAllFromScene(),a},t.prototype._parseSolid=function(n,o,a,i){for(var s,l=[],u=[],c=[],d=[],f=[],h=[],p=[],m=[],_=[],y=0,v=!1,b=[],A=[],T=[],g=[],E="",L="",x=new r,M=1,O=!0,S=function(e,r){e[r[0]]||(e[r[0]]={normals:[],idx:[]});var t=e[r[0]].normals.indexOf(r[1]);return-1===t?-1:e[r[0]].idx[t]},w=function(e,r){e[r[0]]||(e[r[0]]={normals:[],idx:[],uv:[]});var t=e[r[0]].normals.indexOf(r[1]);return 1!=t&&r[2]==e[r[0]].uv[t]?e[r[0]].idx[t]:-1},N=function(e,r,n,o,a,i){var s;s=t.OPTIMIZE_WITH_UV?w(_,[e,n,r]):S(_,[e,n]),-1==s?(f.push(h.length),h.push(o),p.push(a),m.push(i),_[e].normals.push(n),_[e].idx.push(y++),t.OPTIMIZE_WITH_UV&&_[e].uv.push(r)):f.push(s)},F=function(){for(var e=0;e<h.length;e++)b.push(h[e].x,h[e].y,h[e].z),A.push(m[e].x,m[e].y,m[e].z),T.push(p[e].x,p[e].y);h=[],m=[],p=[],_=[],y=0},I=function(e,r){r+1<e.length&&(g.push(e[0],e[r],e[r+1]),r+=1,I(e,r))},P=function(){d.length>0&&(s=d[d.length-1],F(),f.reverse(),s.indices=f.slice(),s.positions=b.slice(),s.normals=A.slice(),s.uvs=T.slice(),f=[],b=[],A=[],T=[])},C=a.split("\n"),R=0;R<C.length;R++){var B,G=C[R].trim();if(0!==G.length&&"#"!==G.charAt(0))if(null!==(B=this.vertexPattern.exec(G)))l.push(new e.Vector3(parseFloat(B[1]),parseFloat(B[2]),parseFloat(B[3])));else if(null!==(B=this.normalPattern.exec(G)))u.push(new e.Vector3(parseFloat(B[1]),parseFloat(B[2]),parseFloat(B[3])));else if(null!==(B=this.uvPattern.exec(G)))c.push(new e.Vector2(parseFloat(B[1]),parseFloat(B[2])));else if(null!==(B=this.facePattern3.exec(G)))!(function(e,r){I(e,r);for(var t=0;t<g.length;t++){var n=g[t].split("/"),o=parseInt(n[0])-1,a=parseInt(n[1])-1,i=parseInt(n[2])-1;N(o,a,i,l[o],c[a],u[i])}g=[]})(B[1].trim().split(" "),1);else if(null!==(B=this.facePattern4.exec(G)))!(function(r,t){I(r,t);for(var n=0;n<g.length;n++){var o=g[n].split("//"),a=parseInt(o[0])-1,i=parseInt(o[1])-1;N(a,1,i,l[a],e.Vector2.Zero(),u[i])}g=[]})(B[1].trim().split(" "),1);else if(null!==(B=this.facePattern2.exec(G)))!(function(r,t){I(r,t);for(var n=0;n<g.length;n++){var o=g[n].split("/"),a=parseInt(o[0])-1,i=parseInt(o[1])-1;N(a,i,0,l[a],c[i],e.Vector3.Up())}g=[]})(B[1].trim().split(" "),1);else if(null!==(B=this.facePattern1.exec(G)))!(function(r,t){I(r,t);for(var n=0;n<g.length;n++){var o=parseInt(g[n])-1;N(o,0,0,l[o],e.Vector2.Zero(),e.Vector3.Up())}g=[]})(B[1].trim().split(" "),1);else if(this.group.test(G)||this.obj.test(G)){var V={name:G.substring(2).trim(),indices:void 0,positions:void 0,normals:void 0,uvs:void 0,materialName:""};P(),d.push(V),v=!0,O=!0,M=1}else if(this.usemtl.test(G)){if(E=G.substring(7).trim(),!O){P();var V={name:"_mm"+M.toString(),indices:void 0,positions:void 0,normals:void 0,uvs:void 0,materialName:E};M++,d.push(V)}v&&O&&(d[d.length-1].materialName=E,O=!1)}else this.mtllib.test(G)?L=G.substring(7).trim():this.smooth.test(G)||console.log("Unhandled expression at line : "+G)}v&&(s=d[d.length-1],f.reverse(),F(),s.indices=f,s.positions=b,s.normals=A,s.uvs=T),v||(f.reverse(),F(),d.push({name:e.Geometry.RandomId(),indices:f,positions:b,normals:A,uvs:T,materialName:E}));for(var D=[],U=new Array,k=0;k<d.length;k++){if(n&&d[k].name)if(n instanceof Array){if(-1==n.indexOf(d[k].name))continue}else if(d[k].name!==n)continue;s=d[k];var j=new e.Mesh(d[k].name,o);U.push(d[k].materialName);var H=new e.VertexData;H.positions=s.positions,H.normals=s.normals,H.uvs=s.uvs,H.indices=s.indices,H.applyToMesh(j),t.INVERT_Y&&(j.scaling.y*=-1),D.push(j)}return""!==L&&this._loadMTL(L,i,(function(e){x.parseMTL(o,e,i);for(var r=0;r<x.materials.length;r++){for(var t,n=0,a=[];(t=U.indexOf(x.materials[r].name,n))>-1;)a.push(t),n=t+1;if(-1==t&&0==a.length)x.materials[r].dispose();else for(var s=0;s<a.length;s++)D[a[s]].material=x.materials[r]}})),D},t.OPTIMIZE_WITH_UV=!1,t.INVERT_Y=!1,t})();e.OBJFileLoader=t,e.SceneLoader&&e.SceneLoader.RegisterPlugin(new t)})(e||(e={}));var e;!(function(e){var r;!(function(e){e[e.AUTO=0]="AUTO",e[e.FORCE_RIGHT_HANDED=1]="FORCE_RIGHT_HANDED"})(r=e.GLTFLoaderCoordinateSystemMode||(e.GLTFLoaderCoordinateSystemMode={}));var t;!(function(e){e[e.NONE=0]="NONE",e[e.FIRST=1]="FIRST",e[e.ALL=2]="ALL"})(t=e.GLTFLoaderAnimationStartMode||(e.GLTFLoaderAnimationStartMode={}));!(function(e){e[e.LOADING=0]="LOADING",e[e.READY=1]="READY",e[e.COMPLETE=2]="COMPLETE"})(e.GLTFLoaderState||(e.GLTFLoaderState={}));var n=(function(){function n(){this.onParsedObservable=new e.Observable,this.coordinateSystemMode=r.AUTO,this.animationStartMode=t.FIRST,this.compileMaterials=!1,this.useClipPlane=!1,this.compileShadowGenerators=!1,this.transparencyAsCoverage=!1,this._normalizeAnimationGroupsToBeginAtZero=!0,this.preprocessUrlAsync=function(e){return Promise.resolve(e)},this.onMeshLoadedObservable=new e.Observable,this.onTextureLoadedObservable=new e.Observable,this.onMaterialLoadedObservable=new e.Observable,this.onCameraLoadedObservable=new e.Observable,this.onCompleteObservable=new e.Observable,this.onDisposeObservable=new e.Observable,this.onExtensionLoadedObservable=new e.Observable,this._loader=null,this.name="gltf",this.extensions={".gltf":{isBinary:!1},".glb":{isBinary:!0}}}return Object.defineProperty(n.prototype,"onParsed",{set:function(e){this._onParsedObserver&&this.onParsedObservable.remove(this._onParsedObserver),this._onParsedObserver=this.onParsedObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"onMeshLoaded",{set:function(e){this._onMeshLoadedObserver&&this.onMeshLoadedObservable.remove(this._onMeshLoadedObserver),this._onMeshLoadedObserver=this.onMeshLoadedObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"onTextureLoaded",{set:function(e){this._onTextureLoadedObserver&&this.onTextureLoadedObservable.remove(this._onTextureLoadedObserver),this._onTextureLoadedObserver=this.onTextureLoadedObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"onMaterialLoaded",{set:function(e){this._onMaterialLoadedObserver&&this.onMaterialLoadedObservable.remove(this._onMaterialLoadedObserver),this._onMaterialLoadedObserver=this.onMaterialLoadedObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"onCameraLoaded",{set:function(e){this._onCameraLoadedObserver&&this.onCameraLoadedObservable.remove(this._onCameraLoadedObserver),this._onCameraLoadedObserver=this.onCameraLoadedObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"onComplete",{set:function(e){this._onCompleteObserver&&this.onCompleteObservable.remove(this._onCompleteObserver),this._onCompleteObserver=this.onCompleteObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"onDispose",{set:function(e){this._onDisposeObserver&&this.onDisposeObservable.remove(this._onDisposeObserver),this._onDisposeObserver=this.onDisposeObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"onExtensionLoaded",{set:function(e){this._onExtensionLoadedObserver&&this.onExtensionLoadedObservable.remove(this._onExtensionLoadedObserver),this._onExtensionLoadedObserver=this.onExtensionLoadedObservable.add(e)},enumerable:!0,configurable:!0}),n.prototype.whenCompleteAsync=function(){var e=this;return new Promise(function(r){e.onCompleteObservable.add((function(){r()}),void 0,void 0,void 0,!0)})},Object.defineProperty(n.prototype,"loaderState",{get:function(){return this._loader?this._loader.state:null},enumerable:!0,configurable:!0}),n.prototype.dispose=function(){this._loader&&(this._loader.dispose(),this._loader=null),this.preprocessUrlAsync=function(e){return Promise.resolve(e)},this.onMeshLoadedObservable.clear(),this.onTextureLoadedObservable.clear(),this.onMaterialLoadedObservable.clear(),this.onCameraLoadedObservable.clear(),this.onCompleteObservable.clear(),this.onExtensionLoadedObservable.clear(),this.onDisposeObservable.notifyObservers(this),this.onDisposeObservable.clear()},n.prototype.importMeshAsync=function(e,r,t,n,o){var a=this;return Promise.resolve().then((function(){var i=a._parse(t);return a._loader=a._getLoader(i),a._loader.importMeshAsync(e,r,i,n,o)}))},n.prototype.loadAsync=function(e,r,t,n){var o=this;return Promise.resolve().then((function(){var a=o._parse(r);return o._loader=o._getLoader(a),o._loader.loadAsync(e,a,t,n)}))},n.prototype.loadAssetContainerAsync=function(r,t,n,o){var a=this;return Promise.resolve().then((function(){var i=a._parse(t);return a._loader=a._getLoader(i),a._loader.importMeshAsync(null,r,i,n,o).then((function(t){var n=new e.AssetContainer(r);return Array.prototype.push.apply(n.meshes,t.meshes),Array.prototype.push.apply(n.particleSystems,t.particleSystems),Array.prototype.push.apply(n.skeletons,t.skeletons),Array.prototype.push.apply(n.animationGroups,t.animationGroups),n.removeAllFromScene(),n}))}))},n.prototype.canDirectLoad=function(e){return-1!==e.indexOf("scene")&&-1!==e.indexOf("node")},n.prototype.createPlugin=function(){return new n},n.prototype._parse=function(e){var r;return r=e instanceof ArrayBuffer?n._parseBinary(e):{json:JSON.parse(e),bin:null},this.onParsedObservable.notifyObservers(r),this.onParsedObservable.clear(),r},n.prototype._getLoader=function(e){var r=this,t={major:2,minor:0},o=e.json.asset||{},a=n._parseVersion(o.version);if(!a)throw new Error("Invalid version: "+o.version);if(void 0!==o.minVersion){var i=n._parseVersion(o.minVersion);if(!i)throw new Error("Invalid minimum version: "+o.minVersion);if(n._compareVersion(i,t)>0)throw new Error("Incompatible minimum version: "+o.minVersion)}var s={1:n.CreateGLTFLoaderV1,2:n.CreateGLTFLoaderV2},l=s[a.major];if(!l)throw new Error("Unsupported version: "+o.version);var u=l();return u.coordinateSystemMode=this.coordinateSystemMode,u.animationStartMode=this.animationStartMode,u.compileMaterials=this.compileMaterials,u.useClipPlane=this.useClipPlane,u.compileShadowGenerators=this.compileShadowGenerators,u.transparencyAsCoverage=this.transparencyAsCoverage,u._normalizeAnimationGroupsToBeginAtZero=this._normalizeAnimationGroupsToBeginAtZero,u.preprocessUrlAsync=this.preprocessUrlAsync,u.onMeshLoadedObservable.add((function(e){return r.onMeshLoadedObservable.notifyObservers(e)})),u.onTextureLoadedObservable.add((function(e){return r.onTextureLoadedObservable.notifyObservers(e)})),u.onMaterialLoadedObservable.add((function(e){return r.onMaterialLoadedObservable.notifyObservers(e)})),u.onCameraLoadedObservable.add((function(e){return r.onCameraLoadedObservable.notifyObservers(e)})),u.onExtensionLoadedObservable.add((function(e){return r.onExtensionLoadedObservable.notifyObservers(e)})),u.onCompleteObservable.add((function(){r.onMeshLoadedObservable.clear(),r.onTextureLoadedObservable.clear(),r.onMaterialLoadedObservable.clear(),r.onCameraLoadedObservable.clear(),r.onExtensionLoadedObservable.clear(),r.onCompleteObservable.notifyObservers(r),r.onCompleteObservable.clear()})),u},n._parseBinary=function(e){var r={Magic:1179937895},t=new o(e),a=t.readUint32();if(a!==r.Magic)throw new Error("Unexpected magic: "+a);var i=t.readUint32();switch(i){case 1:return n._parseV1(t);case 2:return n._parseV2(t)}throw new Error("Unsupported version: "+i)},n._parseV1=function(e){var r={JSON:0},t=e.readUint32();if(t!=e.getLength())throw new Error("Length in header does not match actual data length: "+t+" != "+e.getLength());var o,a=e.readUint32(),i=e.readUint32();switch(i){case r.JSON:o=JSON.parse(n._decodeBufferToText(e.readUint8Array(a)));break;default:throw new Error("Unexpected content format: "+i)}var s=e.getLength()-e.getPosition();return{json:o,bin:e.readUint8Array(s)}},n._parseV2=function(e){var r={JSON:1313821514,BIN:5130562},t=e.readUint32();if(t!==e.getLength())throw new Error("Length in header does not match actual data length: "+t+" != "+e.getLength());var o=e.readUint32();if(e.readUint32()!==r.JSON)throw new Error("First chunk format is not JSON");for(var a=JSON.parse(n._decodeBufferToText(e.readUint8Array(o))),i=null;e.getPosition()<e.getLength();){var s=e.readUint32();switch(e.readUint32()){case r.JSON:throw new Error("Unexpected JSON chunk");case r.BIN:i=e.readUint8Array(s);break;default:e.skipBytes(s)}}return{json:a,bin:i}},n._parseVersion=function(e){if("1.0"===e||"1.0.1"===e)return{major:1,minor:0};var r=(e+"").match(/^(\d+)\.(\d+)/);return r?{major:parseInt(r[1]),minor:parseInt(r[2])}:null},n._compareVersion=function(e,r){return e.major>r.major?1:e.major<r.major?-1:e.minor>r.minor?1:e.minor<r.minor?-1:0},n._decodeBufferToText=function(e){for(var r="",t=e.byteLength,n=0;n<t;n++)r+=String.fromCharCode(e[n]);return r},n.IncrementalLoading=!0,n.HomogeneousCoordinates=!1,n})();e.GLTFFileLoader=n;var o=(function(){function e(e){this._arrayBuffer=e,this._dataView=new DataView(e),this._byteOffset=0}return e.prototype.getPosition=function(){return this._byteOffset},e.prototype.getLength=function(){return this._arrayBuffer.byteLength},e.prototype.readUint32=function(){var e=this._dataView.getUint32(this._byteOffset,!0);return this._byteOffset+=4,e},e.prototype.readUint8Array=function(e){var r=new Uint8Array(this._arrayBuffer,this._byteOffset,e);return this._byteOffset+=e,r},e.prototype.skipBytes=function(e){this._byteOffset+=e},e})();e.SceneLoader&&e.SceneLoader.RegisterPlugin(new n)})(e||(e={}));var e;!(function(e){!(function(e){!(function(e){e[e.BYTE=5120]="BYTE",e[e.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",e[e.SHORT=5122]="SHORT",e[e.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",e[e.FLOAT=5126]="FLOAT"})(e.EComponentType||(e.EComponentType={}));!(function(e){e[e.FRAGMENT=35632]="FRAGMENT",e[e.VERTEX=35633]="VERTEX"})(e.EShaderType||(e.EShaderType={}));!(function(e){e[e.BYTE=5120]="BYTE",e[e.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",e[e.SHORT=5122]="SHORT",e[e.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",e[e.INT=5124]="INT",e[e.UNSIGNED_INT=5125]="UNSIGNED_INT",e[e.FLOAT=5126]="FLOAT",e[e.FLOAT_VEC2=35664]="FLOAT_VEC2",e[e.FLOAT_VEC3=35665]="FLOAT_VEC3",e[e.FLOAT_VEC4=35666]="FLOAT_VEC4",e[e.INT_VEC2=35667]="INT_VEC2",e[e.INT_VEC3=35668]="INT_VEC3",e[e.INT_VEC4=35669]="INT_VEC4",e[e.BOOL=35670]="BOOL",e[e.BOOL_VEC2=35671]="BOOL_VEC2",e[e.BOOL_VEC3=35672]="BOOL_VEC3",e[e.BOOL_VEC4=35673]="BOOL_VEC4",e[e.FLOAT_MAT2=35674]="FLOAT_MAT2",e[e.FLOAT_MAT3=35675]="FLOAT_MAT3",e[e.FLOAT_MAT4=35676]="FLOAT_MAT4",e[e.SAMPLER_2D=35678]="SAMPLER_2D"})(e.EParameterType||(e.EParameterType={}));!(function(e){e[e.CLAMP_TO_EDGE=33071]="CLAMP_TO_EDGE",e[e.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",e[e.REPEAT=10497]="REPEAT"})(e.ETextureWrapMode||(e.ETextureWrapMode={}));!(function(e){e[e.NEAREST=9728]="NEAREST",e[e.LINEAR=9728]="LINEAR",e[e.NEAREST_MIPMAP_NEAREST=9984]="NEAREST_MIPMAP_NEAREST",e[e.LINEAR_MIPMAP_NEAREST=9985]="LINEAR_MIPMAP_NEAREST",e[e.NEAREST_MIPMAP_LINEAR=9986]="NEAREST_MIPMAP_LINEAR",e[e.LINEAR_MIPMAP_LINEAR=9987]="LINEAR_MIPMAP_LINEAR"})(e.ETextureFilterType||(e.ETextureFilterType={}));!(function(e){e[e.ALPHA=6406]="ALPHA",e[e.RGB=6407]="RGB",e[e.RGBA=6408]="RGBA",e[e.LUMINANCE=6409]="LUMINANCE",e[e.LUMINANCE_ALPHA=6410]="LUMINANCE_ALPHA"})(e.ETextureFormat||(e.ETextureFormat={}));!(function(e){e[e.FRONT=1028]="FRONT",e[e.BACK=1029]="BACK",e[e.FRONT_AND_BACK=1032]="FRONT_AND_BACK"})(e.ECullingType||(e.ECullingType={}));!(function(e){e[e.ZERO=0]="ZERO",e[e.ONE=1]="ONE",e[e.SRC_COLOR=768]="SRC_COLOR",e[e.ONE_MINUS_SRC_COLOR=769]="ONE_MINUS_SRC_COLOR",e[e.DST_COLOR=774]="DST_COLOR",e[e.ONE_MINUS_DST_COLOR=775]="ONE_MINUS_DST_COLOR",e[e.SRC_ALPHA=770]="SRC_ALPHA",e[e.ONE_MINUS_SRC_ALPHA=771]="ONE_MINUS_SRC_ALPHA",e[e.DST_ALPHA=772]="DST_ALPHA",e[e.ONE_MINUS_DST_ALPHA=773]="ONE_MINUS_DST_ALPHA",e[e.CONSTANT_COLOR=32769]="CONSTANT_COLOR",e[e.ONE_MINUS_CONSTANT_COLOR=32770]="ONE_MINUS_CONSTANT_COLOR",e[e.CONSTANT_ALPHA=32771]="CONSTANT_ALPHA",e[e.ONE_MINUS_CONSTANT_ALPHA=32772]="ONE_MINUS_CONSTANT_ALPHA",e[e.SRC_ALPHA_SATURATE=776]="SRC_ALPHA_SATURATE"})(e.EBlendingFunction||(e.EBlendingFunction={}))})(e.GLTF1||(e.GLTF1={}))})(e||(e={}));var e;!(function(e){!(function(r){var t;!(function(e){e[e.IDENTIFIER=1]="IDENTIFIER",e[e.UNKNOWN=2]="UNKNOWN",e[e.END_OF_INPUT=3]="END_OF_INPUT"})(t||(t={}));var n=(function(){function e(e){this._pos=0,this.currentToken=t.UNKNOWN,this.currentIdentifier="",this.currentString="",this.isLetterOrDigitPattern=/^[a-zA-Z0-9]+$/,this._toParse=e,this._maxPos=e.length}return e.prototype.getNextToken=function(){if(this.isEnd())return t.END_OF_INPUT;if(this.currentString=this.read(),this.currentToken=t.UNKNOWN,"_"===this.currentString||this.isLetterOrDigitPattern.test(this.currentString))for(this.currentToken=t.IDENTIFIER,this.currentIdentifier=this.currentString;!this.isEnd()&&(this.isLetterOrDigitPattern.test(this.currentString=this.peek())||"_"===this.currentString);)this.currentIdentifier+=this.currentString,this.forward();return this.currentToken},e.prototype.peek=function(){return this._toParse[this._pos]},e.prototype.read=function(){return this._toParse[this._pos++]},e.prototype.forward=function(){this._pos++},e.prototype.isEnd=function(){return this._pos>=this._maxPos},e})(),o=["MODEL","VIEW","PROJECTION","MODELVIEW","MODELVIEWPROJECTION","JOINTMATRIX"],a=["world","view","projection","worldView","worldViewProjection","mBones"],i=["translation","rotation","scale"],s=["position","rotationQuaternion","scaling"],l=function(e,r){for(var t in e){var n=e[t];r.buffers[t]=n,r.buffersCount++}},u=function(e,r){for(var t in e){var n=e[t];r.shaders[t]=n,r.shaderscount++}},c=function(e,r,t){for(var n in e){var o=e[n];t[r][n]=o}},d=function(e){if(e)for(var r=0;r<e.length/2;r++)e[2*r+1]=1-e[2*r+1]},f=function(e){if("NORMAL"===e.semantic)return"normal";if("POSITION"===e.semantic)return"position";if("JOINT"===e.semantic)return"matricesIndices";if("WEIGHT"===e.semantic)return"matricesWeights";if("COLOR"===e.semantic)return"color";if(e.semantic&&-1!==e.semantic.indexOf("TEXCOORD_")){var r=Number(e.semantic.split("_")[1]);return"uv"+(0===r?"":r+1)}return null},h=function(t){for(var n in t.animations){var o=t.animations[n];if(o.channels&&o.samplers)for(var a=null,l=0;l<o.channels.length;l++){var u=o.channels[l],c=o.samplers[u.sampler];if(c){var d=null,f=null;o.parameters?(d=o.parameters[c.input],f=o.parameters[c.output]):(d=c.input,f=c.output);var h=r.GLTFUtils.GetBufferFromAccessor(t,t.accessors[d]),p=r.GLTFUtils.GetBufferFromAccessor(t,t.accessors[f]),m=u.target.id,_=t.scene.getNodeByID(m);if(null===_&&(_=t.scene.getNodeByName(m)),null!==_){var y=_ instanceof e.Bone,v=u.target.path,b=i.indexOf(v);-1!==b&&(v=s[b]);var A=e.Animation.ANIMATIONTYPE_MATRIX;y||("rotationQuaternion"===v?(A=e.Animation.ANIMATIONTYPE_QUATERNION,_.rotationQuaternion=new e.Quaternion):A=e.Animation.ANIMATIONTYPE_VECTOR3);var T=null,g=[],E=0,L=!1;y&&a&&a.getKeys().length===h.length&&(T=a,L=!0),L||(T=new e.Animation(n,y?"_matrix":v,1,A,e.Animation.ANIMATIONLOOPMODE_CYCLE));for(var x=0;x<h.length;x++){var M=null;if("rotationQuaternion"===v?(M=e.Quaternion.FromArray([p[E],p[E+1],p[E+2],p[E+3]]),E+=4):(M=e.Vector3.FromArray([p[E],p[E+1],p[E+2]]),E+=3),y){var O=_,S=e.Vector3.Zero(),w=new e.Quaternion,N=e.Vector3.Zero(),F=O.getBaseMatrix();L&&a&&(F=a.getKeys()[x].value),F.decompose(N,w,S),"position"===v?S=M:"rotationQuaternion"===v?w=M:N=M,M=e.Matrix.Compose(N,w,S)}L?a&&(a.getKeys()[x].value=M):g.push({frame:h[x],value:M})}!L&&T&&(T.setKeys(g),_.animations.push(T)),a=T,t.scene.stopAnimation(_),t.scene.beginAnimation(_,0,h[h.length-1],!0,1)}else e.Tools.Warn("Creating animation named "+n+". But cannot find node named "+m+" to attach to")}}}},p=function(r){var t=null;if(r.translation||r.rotation||r.scale){var n=e.Vector3.FromArray(r.scale||[1,1,1]),o=e.Quaternion.FromArray(r.rotation||[0,0,0,1]),a=e.Vector3.FromArray(r.translation||[0,0,0]);t=e.Matrix.Compose(n,o,a)}else t=e.Matrix.FromArray(r.matrix);return t},m=function(r,t,n,o){for(var a=0;a<o.bones.length;a++)if(o.bones[a].name===n)return o.bones[a];var i=r.nodes;for(var s in i){var l=i[s];if(l.jointName)for(var u=l.children,a=0;a<u.length;a++){var c=r.nodes[u[a]];if(c.jointName&&c.jointName===n){var d=p(l),f=new e.Bone(l.name||"",o,m(r,t,l.jointName,o),d);return f.id=s,f}}}return null},_=function(e,r){for(var t=0;t<e.length;t++)for(var n=e[t],o=0;o<n.node.children.length;o++){var a=n.node.children[o];if(a===r)return n.bone}return null},y=function(e,r){var t=e.nodes,n=t[r];if(n)return{node:n,id:r};for(var o in t)if(n=t[o],n.jointName===r)return{node:n,id:o};return null},v=function(e,r){for(var t=0;t<e.jointNames.length;t++)if(e.jointNames[t]===r)return!0;return!1},b=function(r,t,n,o){for(var a in r.nodes){var i=r.nodes[a],s=a;if(i.jointName&&!v(n,i.jointName)){var l=p(i),u=new e.Bone(i.name||"",t,null,l);u.id=s,o.push({bone:u,node:i,id:s})}}for(var c=0;c<o.length;c++)for(var d=o[c],f=d.node.children,h=0;h<f.length;h++){for(var m=null,_=0;_<o.length;_++)if(o[_].id===f[h]){m=o[_];break}m&&(m.bone._parent=d.bone,d.bone.children.push(m.bone))}},A=function(r,t,n,o,a){if(o||(o=new e.Skeleton(t.name||"","",r.scene)),!t.babylonSkeleton)return o;var i=[],s=[];b(r,o,t,i),o.bones=[];for(var l=0;l<t.jointNames.length;l++){var u=y(r,t.jointNames[l]);if(u){var c=u.node;if(c){var a=u.id,d=r.scene.getBoneByID(a);if(d)o.bones.push(d);else{for(var f=!1,h=null,v=0;v<l;v++){var A=y(r,t.jointNames[v]);if(A){var T=A.node;if(T){var g=T.children;if(g){f=!1;for(var E=0;E<g.length;E++)if(g[E]===a){h=m(r,t,t.jointNames[v],o),f=!0;break}if(f)break}}else e.Tools.Warn("Joint named "+t.jointNames[v]+" does not exist when looking for parent")}}var L=p(c);!h&&i.length>0&&(h=_(i,a))&&-1===s.indexOf(h)&&s.push(h);new e.Bone(c.jointName||"",o,h,L).id=a}}else e.Tools.Warn("Joint named "+t.jointNames[l]+" does not exist")}}var x=o.bones;o.bones=[];for(var l=0;l<t.jointNames.length;l++){var u=y(r,t.jointNames[l]);if(u)for(var v=0;v<x.length;v++)if(x[v].id===u.id){o.bones.push(x[v]);break}}o.prepare();for(var l=0;l<s.length;l++)o.bones.push(s[l]);return o},T=function(t,n,o,a,i){if(i||(i=new e.Mesh(n.name||"",t.scene),i.id=a),!n.babylonNode)return i;for(var s=[],l=null,u=new Array,c=new Array,f=new Array,h=new Array,p=0;p<o.length;p++){var m=o[p],_=t.meshes[m];if(_)for(var y=0;y<_.primitives.length;y++){var v=new e.VertexData,b=_.primitives[y];b.mode;var A=b.attributes,T=null,g=null;for(var E in A)if(T=t.accessors[A[E]],g=r.GLTFUtils.GetBufferFromAccessor(t,T),"NORMAL"===E)v.normals=new Float32Array(g.length),v.normals.set(g);else if("POSITION"===E){if(e.GLTFFileLoader.HomogeneousCoordinates){v.positions=new Float32Array(g.length-g.length/4);for(var L=0;L<g.length;L+=4)v.positions[L]=g[L],v.positions[L+1]=g[L+1],v.positions[L+2]=g[L+2]}else v.positions=new Float32Array(g.length),v.positions.set(g);c.push(v.positions.length)}else if(-1!==E.indexOf("TEXCOORD_")){var x=Number(E.split("_")[1]),M=e.VertexBuffer.UVKind+(0===x?"":x+1),O=new Float32Array(g.length);O.set(g),d(O),v.set(O,M)}else"JOINT"===E?(v.matricesIndices=new Float32Array(g.length),v.matricesIndices.set(g)):"WEIGHT"===E?(v.matricesWeights=new Float32Array(g.length),v.matricesWeights.set(g)):"COLOR"===E&&(v.colors=new Float32Array(g.length),v.colors.set(g));if(T=t.accessors[b.indices])g=r.GLTFUtils.GetBufferFromAccessor(t,T),v.indices=new Int32Array(g.length),v.indices.set(g),h.push(v.indices.length);else{for(var S=[],L=0;L<v.positions.length/3;L++)S.push(L);v.indices=new Int32Array(S),h.push(v.indices.length)}l?l.merge(v):l=v;var w=t.scene.getMaterialByID(b.material);s.push(null===w?r.GLTFUtils.GetDefaultMaterial(t.scene):w),u.push(0===u.length?0:u[u.length-1]+c[c.length-2]),f.push(0===f.length?0:f[f.length-1]+h[h.length-2])}}var N;s.length>1?(N=new e.MultiMaterial("multimat"+a,t.scene),N.subMaterials=s):N=new e.StandardMaterial("multimat"+a,t.scene),1===s.length&&(N=s[0]),i.material||(i.material=N),new e.Geometry(a,t.scene,l,!1,i),i.computeWorldMatrix(!0),i.subMeshes=[];for(var F=0,p=0;p<o.length;p++){var m=o[p],_=t.meshes[m];if(_)for(var y=0;y<_.primitives.length;y++)_.primitives[y].mode,e.SubMesh.AddToMesh(F,u[F],c[F],f[F],h[F],i,i,!0),F++}return i},g=function(e,r,t,n){e.position&&(e.position=r),(e.rotationQuaternion||e.rotation)&&(e.rotationQuaternion=t),e.scaling&&(e.scaling=n)},E=function(r,t,n){if(t.matrix){var o=new e.Vector3(0,0,0),a=new e.Quaternion,i=new e.Vector3(0,0,0);e.Matrix.FromArray(t.matrix).decompose(i,a,o),g(r,o,a,i)}else t.translation&&t.rotation&&t.scale&&g(r,e.Vector3.FromArray(t.translation),e.Quaternion.FromArray(t.rotation),e.Vector3.FromArray(t.scale));r.computeWorldMatrix(!0)},L=function(r,t,n,o){var a=null;if(r.importOnlyMeshes&&(t.skin||t.meshes)&&r.importMeshesNames&&r.importMeshesNames.length>0&&-1===r.importMeshesNames.indexOf(t.name||""))return null;if(t.skin){if(t.meshes){var i=r.skins[t.skin],s=T(r,t,t.meshes,n,t.babylonNode);s.skeleton=r.scene.getLastSkeletonByID(t.skin),null===s.skeleton&&(s.skeleton=A(r,i,0,i.babylonSkeleton,t.skin),i.babylonSkeleton||(i.babylonSkeleton=s.skeleton)),a=s}}else if(t.meshes){var s=T(r,t,t.mesh?[t.mesh]:t.meshes,n,t.babylonNode);a=s}else if(!t.light||t.babylonNode||r.importOnlyMeshes){if(t.camera&&!t.babylonNode&&!r.importOnlyMeshes){var l=r.cameras[t.camera];if(l)if("orthographic"===l.type){var u=new e.FreeCamera(t.camera,e.Vector3.Zero(),r.scene,!1);u.name=t.name||"",u.mode=e.Camera.ORTHOGRAPHIC_CAMERA,u.attachControl(r.scene.getEngine().getRenderingCanvas()),a=u}else if("perspective"===l.type){var c=l[l.type],d=new e.FreeCamera(t.camera,e.Vector3.Zero(),r.scene,!1);d.name=t.name||"",d.attachControl(r.scene.getEngine().getRenderingCanvas()),c.aspectRatio||(c.aspectRatio=r.scene.getEngine().getRenderWidth()/r.scene.getEngine().getRenderHeight()),c.znear&&c.zfar&&(d.maxZ=c.zfar,d.minZ=c.znear),a=d}}}else{var f=r.lights[t.light];if(f)if("ambient"===f.type){var h=f[f.type],p=new e.HemisphericLight(t.light,e.Vector3.Zero(),r.scene);p.name=t.name||"",h.color&&(p.diffuse=e.Color3.FromArray(h.color)),a=p}else if("directional"===f.type){var m=f[f.type],_=new e.DirectionalLight(t.light,e.Vector3.Zero(),r.scene);_.name=t.name||"",m.color&&(_.diffuse=e.Color3.FromArray(m.color)),a=_}else if("point"===f.type){var y=f[f.type],v=new e.PointLight(t.light,e.Vector3.Zero(),r.scene);v.name=t.name||"",
- y.color&&(v.diffuse=e.Color3.FromArray(y.color)),a=v}else if("spot"===f.type){var b=f[f.type],L=new e.SpotLight(t.light,e.Vector3.Zero(),e.Vector3.Zero(),0,0,r.scene);L.name=t.name||"",b.color&&(L.diffuse=e.Color3.FromArray(b.color)),b.fallOfAngle&&(L.angle=b.fallOfAngle),b.fallOffExponent&&(L.exponent=b.fallOffExponent),a=L}}if(!t.jointName){if(t.babylonNode)return t.babylonNode;if(null===a){var x=new e.Mesh(t.name||"",r.scene);t.babylonNode=x,a=x}}if(null!==a){if(t.matrix&&a instanceof e.Mesh)E(a,t);else{var M=t.translation||[0,0,0],O=t.rotation||[0,0,0,1],S=t.scale||[1,1,1];g(a,e.Vector3.FromArray(M),e.Quaternion.FromArray(O),e.Vector3.FromArray(S))}a.updateCache(!0),t.babylonNode=a}return a},x=function(e,r,t,n){void 0===n&&(n=!1);var o=e.nodes[r],a=null;if(n=!(e.importOnlyMeshes&&!n&&e.importMeshesNames)||(-1!==e.importMeshesNames.indexOf(o.name||"")||0===e.importMeshesNames.length),!o.jointName&&n&&null!==(a=L(e,o,r))&&(a.id=r,a.parent=t),o.children)for(var i=0;i<o.children.length;i++)x(e,o.children[i],a,n)},M=function(e){var r=e.currentScene;if(r)for(var t=0;t<r.nodes.length;t++)x(e,r.nodes[t],null);else for(var n in e.scenes){r=e.scenes[n];for(var t=0;t<r.nodes.length;t++)x(e,r.nodes[t],null)}h(e);for(var t=0;t<e.scene.skeletons.length;t++){var o=e.scene.skeletons[t];e.scene.beginAnimation(o,0,Number.MAX_VALUE,!0,1)}},O=function(e,t,n,o,a,i,s){var l=i.values||a.parameters;for(var u in n){var c=n[u],d=c.type;if(d===r.EParameterType.FLOAT_MAT2||d===r.EParameterType.FLOAT_MAT3||d===r.EParameterType.FLOAT_MAT4)if(!c.semantic||c.source||c.node){if(c.semantic&&(c.source||c.node)){var f=t.scene.getNodeByName(c.source||c.node||"");if(null===f&&(f=t.scene.getNodeByID(c.source||c.node||"")),null===f)continue;r.GLTFUtils.SetMatrix(t.scene,f,c,u,o.getEffect())}}else r.GLTFUtils.SetMatrix(t.scene,e,c,u,o.getEffect());else{var h=l[a.uniforms[u]];if(!h)continue;if(d===r.EParameterType.SAMPLER_2D){var p=t.textures[i.values?h:c.value].babylonTexture;if(null===p||void 0===p)continue;o.getEffect().setTexture(u,p)}else r.GLTFUtils.SetUniform(o.getEffect(),u,h,d)}}s(o)},S=function(e,t,n,o,a){var i=o.values||n.parameters,s=n.uniforms;for(var l in a){var u=a[l],c=u.type,d=i[s[l]];if(void 0===d&&(d=u.value),d){var f=function(e){return function(r){u.value&&e&&(t.setTexture(e,r),delete a[e])}};c===r.EParameterType.SAMPLER_2D?r.GLTFLoaderExtension.LoadTextureAsync(e,o.values?d:u.value,f(l),(function(){return f(null)})):u.value&&r.GLTFUtils.SetUniform(t,l,o.values?d:u.value,c)&&delete a[l]}}},w=function(e,r,t){return function(n,o){r.dispose(!0),t("Cannot compile program named "+e.name+". Error: "+o+". Default material will be applied")}},N=function(e,r,t,n,o,a){return function(i){S(e,r,t,n,o),r.onBind=function(i){O(i,e,o,r,t,n,a)}}},F=function(e,r,t){for(var n in r.uniforms){var i=r.uniforms[n],s=r.parameters[i];if(e.currentIdentifier===n&&s.semantic&&!s.source&&!s.node){var l=o.indexOf(s.semantic);if(-1!==l)return delete t[n],a[l]}}return e.currentIdentifier},I=function(e){for(var t in e.materials)r.GLTFLoaderExtension.LoadMaterialAsync(e,t,(function(e){}),(function(){}))},P=(function(){function i(){}return i.CreateRuntime=function(e,r,t){var n={extensions:{},accessors:{},buffers:{},bufferViews:{},meshes:{},lights:{},cameras:{},nodes:{},images:{},textures:{},shaders:{},programs:{},samplers:{},techniques:{},materials:{},animations:{},skins:{},extensionsUsed:[],scenes:{},buffersCount:0,shaderscount:0,scene:r,rootUrl:t,loadedBufferCount:0,loadedBufferViews:{},loadedShaderCount:0,importOnlyMeshes:!1,dummyNodes:[]};return e.extensions&&c(e.extensions,"extensions",n),e.extensionsUsed&&c(e.extensionsUsed,"extensionsUsed",n),e.buffers&&l(e.buffers,n),e.bufferViews&&c(e.bufferViews,"bufferViews",n),e.accessors&&c(e.accessors,"accessors",n),e.meshes&&c(e.meshes,"meshes",n),e.lights&&c(e.lights,"lights",n),e.cameras&&c(e.cameras,"cameras",n),e.nodes&&c(e.nodes,"nodes",n),e.images&&c(e.images,"images",n),e.textures&&c(e.textures,"textures",n),e.shaders&&u(e.shaders,n),e.programs&&c(e.programs,"programs",n),e.samplers&&c(e.samplers,"samplers",n),e.techniques&&c(e.techniques,"techniques",n),e.materials&&c(e.materials,"materials",n),e.animations&&c(e.animations,"animations",n),e.skins&&c(e.skins,"skins",n),e.scenes&&(n.scenes=e.scenes),e.scene&&e.scenes&&(n.currentScene=e.scenes[e.scene]),n},i.LoadBufferAsync=function(r,t,n,o,a){var i=r.buffers[t];e.Tools.IsBase64(i.uri)?setTimeout((function(){return n(new Uint8Array(e.Tools.DecodeBase64(i.uri)))})):e.Tools.LoadFile(r.rootUrl+i.uri,(function(e){return n(new Uint8Array(e))}),a,void 0,!0,(function(e){e&&o(e.status+" "+e.statusText)}))},i.LoadTextureBufferAsync=function(r,t,n,o){var a=r.textures[t];if(!a||!a.source)return void o("");if(a.babylonTexture)return void n(null);var i=r.images[a.source];e.Tools.IsBase64(i.uri)?setTimeout((function(){return n(new Uint8Array(e.Tools.DecodeBase64(i.uri)))})):e.Tools.LoadFile(r.rootUrl+i.uri,(function(e){return n(new Uint8Array(e))}),void 0,void 0,!0,(function(e){e&&o(e.status+" "+e.statusText)}))},i.CreateTextureAsync=function(t,n,o,a,i){var s=t.textures[n];if(s.babylonTexture)return void a(s.babylonTexture);var l=t.samplers[s.sampler],u=l.minFilter===r.ETextureFilterType.NEAREST_MIPMAP_NEAREST||l.minFilter===r.ETextureFilterType.NEAREST_MIPMAP_LINEAR||l.minFilter===r.ETextureFilterType.LINEAR_MIPMAP_NEAREST||l.minFilter===r.ETextureFilterType.LINEAR_MIPMAP_LINEAR,c=e.Texture.BILINEAR_SAMPLINGMODE,d=new Blob([o]),f=URL.createObjectURL(d),h=function(){return URL.revokeObjectURL(f)},p=new e.Texture(f,t.scene,!u,!0,c,h,h);void 0!==l.wrapS&&(p.wrapU=r.GLTFUtils.GetWrapMode(l.wrapS)),void 0!==l.wrapT&&(p.wrapV=r.GLTFUtils.GetWrapMode(l.wrapT)),p.name=n,s.babylonTexture=p,a(p)},i.LoadShaderStringAsync=function(r,t,n,o){var a=r.shaders[t];if(e.Tools.IsBase64(a.uri)){var i=atob(a.uri.split(",")[1]);n&&n(i)}else e.Tools.LoadFile(r.rootUrl+a.uri,n,void 0,void 0,!1,(function(e){e&&o&&o(e.status+" "+e.statusText)}))},i.LoadMaterialAsync=function(i,s,l,u){var c=i.materials[s];if(!c.technique)return void(u&&u("No technique found."));var d=i.techniques[c.technique];if(!d){var h=new e.StandardMaterial(s,i.scene);return h.diffuseColor=new e.Color3(.5,.5,.5),h.sideOrientation=e.Material.CounterClockWiseSideOrientation,void l(h)}var p=i.programs[d.program],m=d.states,_=e.Effect.ShadersStore[p.vertexShader+"VertexShader"],y=e.Effect.ShadersStore[p.fragmentShader+"PixelShader"],v="",b="",A=new n(_),T=new n(y),g={},E=[],L=[],x=[];for(var M in d.uniforms){var O=d.uniforms[M],S=d.parameters[O];if(g[M]=S,!S.semantic||S.node||S.source)S.type===r.EParameterType.SAMPLER_2D?x.push(M):E.push(M);else{var I=o.indexOf(S.semantic);-1!==I?(E.push(a[I]),delete g[M]):E.push(M)}}for(var P in d.attributes){var C=d.attributes[P],R=d.parameters[C];R.semantic&&L.push(f(R))}for(;!A.isEnd()&&A.getNextToken();){var B=A.currentToken;if(B===t.IDENTIFIER){var G=!1;for(var P in d.attributes){var C=d.attributes[P],R=d.parameters[C];if(A.currentIdentifier===P&&R.semantic){v+=f(R),G=!0;break}}G||(v+=F(A,d,g))}else v+=A.currentString}for(;!T.isEnd()&&T.getNextToken();){var B=T.currentToken;B===t.IDENTIFIER?b+=F(T,d,g):b+=T.currentString}var V={vertex:p.vertexShader+s,fragment:p.fragmentShader+s},D={attributes:L,uniforms:E,samplers:x,needAlphaBlending:m&&m.enable&&-1!==m.enable.indexOf(3042)};e.Effect.ShadersStore[p.vertexShader+s+"VertexShader"]=v,e.Effect.ShadersStore[p.fragmentShader+s+"PixelShader"]=b;var U=new e.ShaderMaterial(s,i.scene,V,D);if(U.onError=w(p,U,u),U.onCompiled=N(i,U,d,c,g,l),U.sideOrientation=e.Material.CounterClockWiseSideOrientation,m&&m.functions){var k=m.functions;k.cullFace&&k.cullFace[0]!==r.ECullingType.BACK&&(U.backFaceCulling=!1);var j=k.blendFuncSeparate;j&&(j[0]===r.EBlendingFunction.SRC_ALPHA&&j[1]===r.EBlendingFunction.ONE_MINUS_SRC_ALPHA&&j[2]===r.EBlendingFunction.ONE&&j[3]===r.EBlendingFunction.ONE?U.alphaMode=e.Engine.ALPHA_COMBINE:j[0]===r.EBlendingFunction.ONE&&j[1]===r.EBlendingFunction.ONE&&j[2]===r.EBlendingFunction.ZERO&&j[3]===r.EBlendingFunction.ONE?U.alphaMode=e.Engine.ALPHA_ONEONE:j[0]===r.EBlendingFunction.SRC_ALPHA&&j[1]===r.EBlendingFunction.ONE&&j[2]===r.EBlendingFunction.ZERO&&j[3]===r.EBlendingFunction.ONE?U.alphaMode=e.Engine.ALPHA_ADD:j[0]===r.EBlendingFunction.ZERO&&j[1]===r.EBlendingFunction.ONE_MINUS_SRC_COLOR&&j[2]===r.EBlendingFunction.ONE&&j[3]===r.EBlendingFunction.ONE?U.alphaMode=e.Engine.ALPHA_SUBTRACT:j[0]===r.EBlendingFunction.DST_COLOR&&j[1]===r.EBlendingFunction.ZERO&&j[2]===r.EBlendingFunction.ONE&&j[3]===r.EBlendingFunction.ONE?U.alphaMode=e.Engine.ALPHA_MULTIPLY:j[0]===r.EBlendingFunction.SRC_ALPHA&&j[1]===r.EBlendingFunction.ONE_MINUS_SRC_COLOR&&j[2]===r.EBlendingFunction.ONE&&j[3]===r.EBlendingFunction.ONE&&(U.alphaMode=e.Engine.ALPHA_MAXIMIZED))}},i})();r.GLTFLoaderBase=P;var C=(function(){function t(){this.coordinateSystemMode=e.GLTFLoaderCoordinateSystemMode.AUTO,this.animationStartMode=e.GLTFLoaderAnimationStartMode.FIRST,this.compileMaterials=!1,this.useClipPlane=!1,this.compileShadowGenerators=!1,this.transparencyAsCoverage=!1,this._normalizeAnimationGroupsToBeginAtZero=!0,this.preprocessUrlAsync=function(e){return Promise.resolve(e)},this.onMeshLoadedObservable=new e.Observable,this.onTextureLoadedObservable=new e.Observable,this.onMaterialLoadedObservable=new e.Observable,this.onCameraLoadedObservable=new e.Observable,this.onCompleteObservable=new e.Observable,this.onDisposeObservable=new e.Observable,this.onExtensionLoadedObservable=new e.Observable,this.state=null}return t.RegisterExtension=function(r){if(t.Extensions[r.name])return void e.Tools.Error('Tool with the same name "'+r.name+'" already exists');t.Extensions[r.name]=r},t.prototype.dispose=function(){},t.prototype._importMeshAsync=function(t,n,o,a,i,s,l){var u=this;return n.useRightHandedSystem=!0,r.GLTFLoaderExtension.LoadRuntimeAsync(n,o,a,(function(r){r.importOnlyMeshes=!0,""===t?r.importMeshesNames=[]:"string"==typeof t?r.importMeshesNames=[t]:!t||t instanceof Array?(r.importMeshesNames=[],e.Tools.Warn("Argument meshesNames must be of type string or string[]")):r.importMeshesNames=[t],u._createNodes(r);var n=new Array,o=new Array;for(var a in r.nodes){var l=r.nodes[a];l.babylonNode instanceof e.AbstractMesh&&n.push(l.babylonNode)}for(var c in r.skins){var d=r.skins[c];d.babylonSkeleton instanceof e.Skeleton&&o.push(d.babylonSkeleton)}u._loadBuffersAsync(r,(function(){u._loadShadersAsync(r,(function(){I(r),M(r),!e.GLTFFileLoader.IncrementalLoading&&i&&i(n,o)}))}),s),e.GLTFFileLoader.IncrementalLoading&&i&&i(n,o)}),l),!0},t.prototype.importMeshAsync=function(e,r,t,n,o){var a=this;return new Promise(function(i,s){a._importMeshAsync(e,r,t,n,(function(e,r){i({meshes:e,particleSystems:[],skeletons:r,animationGroups:[]})}),o,(function(e){s(new Error(e))}))})},t.prototype._loadAsync=function(t,n,o,a,i,s){var l=this;t.useRightHandedSystem=!0,r.GLTFLoaderExtension.LoadRuntimeAsync(t,n,o,(function(t){r.GLTFLoaderExtension.LoadRuntimeExtensionsAsync(t,(function(){l._createNodes(t),l._loadBuffersAsync(t,(function(){l._loadShadersAsync(t,(function(){I(t),M(t),e.GLTFFileLoader.IncrementalLoading||a()}))})),e.GLTFFileLoader.IncrementalLoading&&a()}),s)}),s)},t.prototype.loadAsync=function(e,r,t,n){var o=this;return new Promise(function(a,i){o._loadAsync(e,r,t,(function(){a()}),n,(function(e){i(new Error(e))}))})},t.prototype._loadShadersAsync=function(t,n){var o=!1,a=function(o,a){r.GLTFLoaderExtension.LoadShaderStringAsync(t,o,(function(i){i instanceof ArrayBuffer||(t.loadedShaderCount++,i&&(e.Effect.ShadersStore[o+(a.type===r.EShaderType.VERTEX?"VertexShader":"PixelShader")]=i),t.loadedShaderCount===t.shaderscount&&n())}),(function(){e.Tools.Error("Error when loading shader program named "+o+" located at "+a.uri)}))};for(var i in t.shaders){o=!0;var s=t.shaders[i];s?a.bind(this,i,s)():e.Tools.Error("No shader named: "+i)}o||n()},t.prototype._loadBuffersAsync=function(t,n,o){var a=!1,i=function(o,a){r.GLTFLoaderExtension.LoadBufferAsync(t,o,(function(r){t.loadedBufferCount++,r&&(r.byteLength!=t.buffers[o].byteLength&&e.Tools.Error("Buffer named "+o+" is length "+r.byteLength+". Expected: "+a.byteLength),t.loadedBufferViews[o]=r),t.loadedBufferCount===t.buffersCount&&n()}),(function(){e.Tools.Error("Error when loading buffer named "+o+" located at "+a.uri)}))};for(var s in t.buffers){a=!0;var l=t.buffers[s];l?i.bind(this,s,l)():e.Tools.Error("No buffer named: "+s)}a||n()},t.prototype._createNodes=function(e){var r=e.currentScene;if(r)for(var t=0;t<r.nodes.length;t++)x(e,r.nodes[t],null);else for(var n in e.scenes){r=e.scenes[n];for(var t=0;t<r.nodes.length;t++)x(e,r.nodes[t],null)}},t.Extensions={},t})();r.GLTFLoader=C,e.GLTFFileLoader.CreateGLTFLoaderV1=function(){return new C}})(e.GLTF1||(e.GLTF1={}))})(e||(e={}));var e;!(function(e){!(function(r){var t=(function(){function t(){}return t.SetMatrix=function(t,n,o,a,i){var s=null;if("MODEL"===o.semantic?s=n.getWorldMatrix():"PROJECTION"===o.semantic?s=t.getProjectionMatrix():"VIEW"===o.semantic?s=t.getViewMatrix():"MODELVIEWINVERSETRANSPOSE"===o.semantic?s=e.Matrix.Transpose(n.getWorldMatrix().multiply(t.getViewMatrix()).invert()):"MODELVIEW"===o.semantic?s=n.getWorldMatrix().multiply(t.getViewMatrix()):"MODELVIEWPROJECTION"===o.semantic?s=n.getWorldMatrix().multiply(t.getTransformMatrix()):"MODELINVERSE"===o.semantic?s=n.getWorldMatrix().invert():"VIEWINVERSE"===o.semantic?s=t.getViewMatrix().invert():"PROJECTIONINVERSE"===o.semantic?s=t.getProjectionMatrix().invert():"MODELVIEWINVERSE"===o.semantic?s=n.getWorldMatrix().multiply(t.getViewMatrix()).invert():"MODELVIEWPROJECTIONINVERSE"===o.semantic?s=n.getWorldMatrix().multiply(t.getTransformMatrix()).invert():"MODELINVERSETRANSPOSE"===o.semantic&&(s=e.Matrix.Transpose(n.getWorldMatrix().invert())),s)switch(o.type){case r.EParameterType.FLOAT_MAT2:i.setMatrix2x2(a,e.Matrix.GetAsMatrix2x2(s));break;case r.EParameterType.FLOAT_MAT3:i.setMatrix3x3(a,e.Matrix.GetAsMatrix3x3(s));break;case r.EParameterType.FLOAT_MAT4:i.setMatrix(a,s)}},t.SetUniform=function(t,n,o,a){switch(a){case r.EParameterType.FLOAT:return t.setFloat(n,o),!0;case r.EParameterType.FLOAT_VEC2:return t.setVector2(n,e.Vector2.FromArray(o)),!0;case r.EParameterType.FLOAT_VEC3:return t.setVector3(n,e.Vector3.FromArray(o)),!0;case r.EParameterType.FLOAT_VEC4:return t.setVector4(n,e.Vector4.FromArray(o)),!0;default:return!1}},t.GetWrapMode=function(t){switch(t){case r.ETextureWrapMode.CLAMP_TO_EDGE:return e.Texture.CLAMP_ADDRESSMODE;case r.ETextureWrapMode.MIRRORED_REPEAT:return e.Texture.MIRROR_ADDRESSMODE;case r.ETextureWrapMode.REPEAT:default:return e.Texture.WRAP_ADDRESSMODE}},t.GetByteStrideFromType=function(e){switch(e.type){case"VEC2":return 2;case"VEC3":return 3;case"VEC4":case"MAT2":return 4;case"MAT3":return 9;case"MAT4":return 16;default:return 1}},t.GetTextureFilterMode=function(t){switch(t){case r.ETextureFilterType.LINEAR:case r.ETextureFilterType.LINEAR_MIPMAP_NEAREST:case r.ETextureFilterType.LINEAR_MIPMAP_LINEAR:return e.Texture.TRILINEAR_SAMPLINGMODE;case r.ETextureFilterType.NEAREST:case r.ETextureFilterType.NEAREST_MIPMAP_NEAREST:return e.Texture.NEAREST_SAMPLINGMODE;default:return e.Texture.BILINEAR_SAMPLINGMODE}},t.GetBufferFromBufferView=function(e,t,n,o,a){var n=t.byteOffset+n,i=e.loadedBufferViews[t.buffer];if(n+o>i.byteLength)throw new Error("Buffer access is out of range");var s=i.buffer;switch(n+=i.byteOffset,a){case r.EComponentType.BYTE:return new Int8Array(s,n,o);case r.EComponentType.UNSIGNED_BYTE:return new Uint8Array(s,n,o);case r.EComponentType.SHORT:return new Int16Array(s,n,o);case r.EComponentType.UNSIGNED_SHORT:return new Uint16Array(s,n,o);default:return new Float32Array(s,n,o)}},t.GetBufferFromAccessor=function(e,r){var n=e.bufferViews[r.bufferView],o=r.count*t.GetByteStrideFromType(r);return t.GetBufferFromBufferView(e,n,r.byteOffset,o,r.componentType)},t.DecodeBufferToText=function(e){for(var r="",t=e.byteLength,n=0;n<t;++n)r+=String.fromCharCode(e[n]);return r},t.GetDefaultMaterial=function(r){if(!t._DefaultMaterial){e.Effect.ShadersStore.GLTFDefaultMaterialVertexShader=["precision highp float;","","uniform mat4 worldView;","uniform mat4 projection;","","attribute vec3 position;","","void main(void)","{"," gl_Position = projection * worldView * vec4(position, 1.0);","}"].join("\n"),e.Effect.ShadersStore.GLTFDefaultMaterialPixelShader=["precision highp float;","","uniform vec4 u_emission;","","void main(void)","{"," gl_FragColor = u_emission;","}"].join("\n");var n={vertex:"GLTFDefaultMaterial",fragment:"GLTFDefaultMaterial"},o={attributes:["position"],uniforms:["worldView","projection","u_emission"],samplers:new Array,needAlphaBlending:!1};t._DefaultMaterial=new e.ShaderMaterial("GLTFDefaultMaterial",r,n,o),t._DefaultMaterial.setColor4("u_emission",new e.Color4(.5,.5,.5,1))}return t._DefaultMaterial},t._DefaultMaterial=null,t})();r.GLTFUtils=t})(e.GLTF1||(e.GLTF1={}))})(e||(e={}));var e;!(function(e){!(function(e){var r=(function(){function r(e){this._name=e}return Object.defineProperty(r.prototype,"name",{get:function(){return this._name},enumerable:!0,configurable:!0}),r.prototype.loadRuntimeAsync=function(e,r,t,n,o){return!1},r.prototype.loadRuntimeExtensionsAsync=function(e,r,t){return!1},r.prototype.loadBufferAsync=function(e,r,t,n,o){return!1},r.prototype.loadTextureBufferAsync=function(e,r,t,n){return!1},r.prototype.createTextureAsync=function(e,r,t,n,o){return!1},r.prototype.loadShaderStringAsync=function(e,r,t,n){return!1},r.prototype.loadMaterialAsync=function(e,r,t,n){return!1},r.LoadRuntimeAsync=function(t,n,o,a,i){r.ApplyExtensions((function(e){return e.loadRuntimeAsync(t,n,o,a,i)}),(function(){setTimeout((function(){a&&a(e.GLTFLoaderBase.CreateRuntime(n.json,t,o))}))}))},r.LoadRuntimeExtensionsAsync=function(e,t,n){r.ApplyExtensions((function(r){return r.loadRuntimeExtensionsAsync(e,t,n)}),(function(){setTimeout((function(){t()}))}))},r.LoadBufferAsync=function(t,n,o,a,i){r.ApplyExtensions((function(e){return e.loadBufferAsync(t,n,o,a,i)}),(function(){e.GLTFLoaderBase.LoadBufferAsync(t,n,o,a,i)}))},r.LoadTextureAsync=function(e,t,n,o){r.LoadTextureBufferAsync(e,t,(function(a){a&&r.CreateTextureAsync(e,t,a,n,o)}),o)},r.LoadShaderStringAsync=function(t,n,o,a){r.ApplyExtensions((function(e){return e.loadShaderStringAsync(t,n,o,a)}),(function(){e.GLTFLoaderBase.LoadShaderStringAsync(t,n,o,a)}))},r.LoadMaterialAsync=function(t,n,o,a){r.ApplyExtensions((function(e){return e.loadMaterialAsync(t,n,o,a)}),(function(){e.GLTFLoaderBase.LoadMaterialAsync(t,n,o,a)}))},r.LoadTextureBufferAsync=function(t,n,o,a){r.ApplyExtensions((function(e){return e.loadTextureBufferAsync(t,n,o,a)}),(function(){e.GLTFLoaderBase.LoadTextureBufferAsync(t,n,o,a)}))},r.CreateTextureAsync=function(t,n,o,a,i){r.ApplyExtensions((function(e){return e.createTextureAsync(t,n,o,a,i)}),(function(){e.GLTFLoaderBase.CreateTextureAsync(t,n,o,a,i)}))},r.ApplyExtensions=function(r,t){for(var n in e.GLTFLoader.Extensions){if(r(e.GLTFLoader.Extensions[n]))return}t()},r})();e.GLTFLoaderExtension=r})(e.GLTF1||(e.GLTF1={}))})(e||(e={}));var e;!(function(e){!(function(e){var t=(function(t){function n(){return t.call(this,"KHR_binary_glTF")||this}return r(n,t),n.prototype.loadRuntimeAsync=function(r,t,n,o,a){var i=t.json.extensionsUsed;return!(!i||-1===i.indexOf(this.name)||!t.bin)&&(this._bin=t.bin,o(e.GLTFLoaderBase.CreateRuntime(t.json,r,n)),!0)},n.prototype.loadBufferAsync=function(e,r,t,n){return-1!==e.extensionsUsed.indexOf(this.name)&&("binary_glTF"===r&&(t(this._bin),!0))},n.prototype.loadTextureBufferAsync=function(r,t,n,o){var a=r.textures[t],i=r.images[a.source];if(!(i.extensions&&this.name in i.extensions))return!1;var s=i.extensions[this.name],l=r.bufferViews[s.bufferView];return n(e.GLTFUtils.GetBufferFromBufferView(r,l,0,l.byteLength,e.EComponentType.UNSIGNED_BYTE)),!0},n.prototype.loadShaderStringAsync=function(r,t,n,o){var a=r.shaders[t];if(!(a.extensions&&this.name in a.extensions))return!1;var i=a.extensions[this.name],s=r.bufferViews[i.bufferView],l=e.GLTFUtils.GetBufferFromBufferView(r,s,0,s.byteLength,e.EComponentType.UNSIGNED_BYTE);return setTimeout((function(){var r=e.GLTFUtils.DecodeBufferToText(l);n(r)})),!0},n})(e.GLTFLoaderExtension);e.GLTFBinaryExtension=t,e.GLTFLoader.RegisterExtension(new t)})(e.GLTF1||(e.GLTF1={}))})(e||(e={}));var e;!(function(e){!(function(t){var n=(function(n){function o(){return n.call(this,"KHR_materials_common")||this}return r(o,n),o.prototype.loadRuntimeExtensionsAsync=function(r,t,n){if(!r.extensions)return!1;var o=r.extensions[this.name];if(!o)return!1;var a=o.lights;if(a)for(var i in a){var s=a[i];switch(s.type){case"ambient":var l=new e.HemisphericLight(s.name,new e.Vector3(0,1,0),r.scene),u=s.ambient;u&&(l.diffuse=e.Color3.FromArray(u.color||[1,1,1]));break;case"point":var c=new e.PointLight(s.name,new e.Vector3(10,10,10),r.scene),d=s.point;d&&(c.diffuse=e.Color3.FromArray(d.color||[1,1,1]));break;case"directional":var f=new e.DirectionalLight(s.name,new e.Vector3(0,-1,0),r.scene),h=s.directional;h&&(f.diffuse=e.Color3.FromArray(h.color||[1,1,1]));break;case"spot":var p=s.spot;if(p){var m=new e.SpotLight(s.name,new e.Vector3(0,10,0),new e.Vector3(0,-1,0),p.fallOffAngle||Math.PI,p.fallOffExponent||0,r.scene);m.diffuse=e.Color3.FromArray(p.color||[1,1,1])}break;default:e.Tools.Warn('GLTF Material Common extension: light type "'+s.type+"” not supported")}}return!1},o.prototype.loadMaterialAsync=function(r,t,n,o){var a=r.materials[t];if(!a||!a.extensions)return!1;var i=a.extensions[this.name];if(!i)return!1;var s=new e.StandardMaterial(t,r.scene);return s.sideOrientation=e.Material.CounterClockWiseSideOrientation,"CONSTANT"===i.technique&&(s.disableLighting=!0),s.backFaceCulling=void 0!==i.doubleSided&&!i.doubleSided,s.alpha=void 0===i.values.transparency?1:i.values.transparency,s.specularPower=void 0===i.values.shininess?0:i.values.shininess,"string"==typeof i.values.ambient?this._loadTexture(r,i.values.ambient,s,"ambientTexture",o):s.ambientColor=e.Color3.FromArray(i.values.ambient||[0,0,0]),"string"==typeof i.values.diffuse?this._loadTexture(r,i.values.diffuse,s,"diffuseTexture",o):s.diffuseColor=e.Color3.FromArray(i.values.diffuse||[0,0,0]),"string"==typeof i.values.emission?this._loadTexture(r,i.values.emission,s,"emissiveTexture",o):s.emissiveColor=e.Color3.FromArray(i.values.emission||[0,0,0]),"string"==typeof i.values.specular?this._loadTexture(r,i.values.specular,s,"specularTexture",o):s.specularColor=e.Color3.FromArray(i.values.specular||[0,0,0]),!0},o.prototype._loadTexture=function(e,r,n,o,a){t.GLTFLoaderBase.LoadTextureBufferAsync(e,r,(function(i){t.GLTFLoaderBase.CreateTextureAsync(e,r,i,(function(e){return n[o]=e}),a)}),a)},o})(t.GLTFLoaderExtension);t.GLTFMaterialsCommonExtension=n,t.GLTFLoader.RegisterExtension(new n)})(e.GLTF1||(e.GLTF1={}))})(e||(e={}));var e;!(function(e){!(function(e){var r=(function(){function e(){}return e.Assign=function(e){if(e)for(var r=0;r<e.length;r++)e[r]._index=r},e})();e._ArrayItem=r})(e.GLTF2||(e.GLTF2={}))})(e||(e={}));var e;!(function(e){!(function(r){var t=(function(){function t(){this._completePromises=new Array,this._disposed=!1,this._state=null,this._extensions={},this._defaultSampler={},this._defaultBabylonMaterials={},this._requests=new Array,this.coordinateSystemMode=e.GLTFLoaderCoordinateSystemMode.AUTO,this.animationStartMode=e.GLTFLoaderAnimationStartMode.FIRST,this.compileMaterials=!1,this.useClipPlane=!1,this.compileShadowGenerators=!1,this.transparencyAsCoverage=!1,this._normalizeAnimationGroupsToBeginAtZero=!0,this.preprocessUrlAsync=function(e){return Promise.resolve(e)},this.onMeshLoadedObservable=new e.Observable,this.onTextureLoadedObservable=new e.Observable,this.onMaterialLoadedObservable=new e.Observable,this.onCameraLoadedObservable=new e.Observable,this.onCompleteObservable=new e.Observable,this.onDisposeObservable=new e.Observable,this.onExtensionLoadedObservable=new e.Observable}return t._Register=function(r,n){if(t._ExtensionFactories[r])return void e.Tools.Error("Extension with the name '"+r+"' already exists");t._ExtensionFactories[r]=n,t._ExtensionNames.push(r)},Object.defineProperty(t.prototype,"state",{get:function(){return this._state},enumerable:!0,configurable:!0}),t.prototype.dispose=function(){this._disposed||(this._disposed=!0,this.onDisposeObservable.notifyObservers(this),this.onDisposeObservable.clear(),this._clear())},t.prototype.importMeshAsync=function(e,r,t,n,o){var a=this;return Promise.resolve().then((function(){var i=null;if(e){var s={};if(a._gltf.nodes)for(var l=0,u=a._gltf.nodes;l<u.length;l++){var c=u[l];c.name&&(s[c.name]=c)}i=(e instanceof Array?e:[e]).map((function(e){var r=s[e];if(!r)throw new Error("Failed to find node '"+e+"'");return r}))}return a._loadAsync(i,r,t,n,o).then((function(){return{meshes:a._getMeshes(),particleSystems:[],skeletons:a._getSkeletons(),animationGroups:a._getAnimationGroups()}}))}))},t.prototype.loadAsync=function(e,r,t,n){return this._loadAsync(null,e,r,t,n)},t.prototype._loadAsync=function(r,n,o,a,i){var s=this;return Promise.resolve().then((function(){s._babylonScene=n,s._rootUrl=a,s._progressCallback=i,s._state=e.GLTFLoaderState.LOADING,s._loadData(o),s._loadExtensions(),s._checkExtensions();var l=new Array;if(r)l.push(s._loadNodesAsync(r));else{var u=t._GetProperty("#/scene",s._gltf.scenes,s._gltf.scene||0);l.push(s._loadSceneAsync("#/scenes/"+u._index,u))}s.compileMaterials&&l.push(s._compileMaterialsAsync()),s.compileShadowGenerators&&l.push(s._compileShadowGeneratorsAsync());var c=Promise.all(l).then((function(){s._state=e.GLTFLoaderState.READY,s._startAnimations()}));return c.then((function(){s._rootBabylonMesh.setEnabled(!0),e.Tools.SetImmediate((function(){s._disposed||Promise.all(s._completePromises).then((function(){s._state=e.GLTFLoaderState.COMPLETE,s.onCompleteObservable.notifyObservers(s),s.onCompleteObservable.clear(),s._clear()})).catch((function(r){e.Tools.Error("glTF Loader: "+r.message),s._clear()}))}))})),c})).catch((function(r){if(!s._disposed)throw e.Tools.Error("glTF Loader: "+r.message),s._clear(),r}))},t.prototype._loadData=function(r){if(this._gltf=r.json,this._setupData(),r.bin){var t=this._gltf.buffers;if(t&&t[0]&&!t[0].uri){var n=t[0];(n.byteLength<r.bin.byteLength-3||n.byteLength>r.bin.byteLength)&&e.Tools.Warn("Binary buffer length ("+n.byteLength+") from JSON does not match chunk length ("+r.bin.byteLength+")"),n._data=Promise.resolve(r.bin)}else e.Tools.Warn("Unexpected BIN chunk")}},t.prototype._setupData=function(){if(r._ArrayItem.Assign(this._gltf.accessors),r._ArrayItem.Assign(this._gltf.animations),r._ArrayItem.Assign(this._gltf.buffers),r._ArrayItem.Assign(this._gltf.bufferViews),r._ArrayItem.Assign(this._gltf.cameras),r._ArrayItem.Assign(this._gltf.images),r._ArrayItem.Assign(this._gltf.materials),r._ArrayItem.Assign(this._gltf.meshes),r._ArrayItem.Assign(this._gltf.nodes),r._ArrayItem.Assign(this._gltf.samplers),r._ArrayItem.Assign(this._gltf.scenes),r._ArrayItem.Assign(this._gltf.skins),r._ArrayItem.Assign(this._gltf.textures),this._gltf.nodes){for(var e={},t=0,n=this._gltf.nodes;t<n.length;t++){var o=n[t];if(o.children)for(var a=0,i=o.children;a<i.length;a++){var s=i[a];e[s]=o._index}}for(var l=this._createRootNode(),u=0,c=this._gltf.nodes;u<c.length;u++){var o=c[u],d=e[o._index];o._parent=void 0===d?l:this._gltf.nodes[d]}}},t.prototype._loadExtensions=function(){for(var e=0,r=t._ExtensionNames;e<r.length;e++){var n=r[e],o=t._ExtensionFactories[n](this);this._extensions[n]=o,this.onExtensionLoadedObservable.notifyObservers(o)}this.onExtensionLoadedObservable.clear()},t.prototype._checkExtensions=function(){if(this._gltf.extensionsRequired)for(var e=0,r=this._gltf.extensionsRequired;e<r.length;e++){var t=r[e],n=this._extensions[t];if(!n||!n.enabled)throw new Error("Require extension "+t+" is not available")}},t.prototype._createRootNode=function(){this._rootBabylonMesh=new e.Mesh("__root__",this._babylonScene),this._rootBabylonMesh.setEnabled(!1);var r={_babylonMesh:this._rootBabylonMesh};switch(this.coordinateSystemMode){case e.GLTFLoaderCoordinateSystemMode.AUTO:this._babylonScene.useRightHandedSystem||(r.rotation=[0,1,0,0],r.scale=[1,1,-1],t._LoadTransform(r,this._rootBabylonMesh));break;case e.GLTFLoaderCoordinateSystemMode.FORCE_RIGHT_HANDED:this._babylonScene.useRightHandedSystem=!0;break;default:throw new Error("Invalid coordinate system mode ("+this.coordinateSystemMode+")")}return this.onMeshLoadedObservable.notifyObservers(this._rootBabylonMesh),r},t.prototype._loadNodesAsync=function(e){for(var r=new Array,t=0,n=e;t<n.length;t++){var o=n[t];r.push(this._loadNodeAsync("#/nodes/"+o._index,o))}return r.push(this._loadAnimationsAsync()),Promise.all(r).then((function(){}))},t.prototype._loadSceneAsync=function(e,n){var o=r.GLTFLoaderExtension._LoadSceneAsync(this,e,n);if(o)return o;for(var a=new Array,i=0,s=n.nodes;i<s.length;i++){var l=s[i],u=t._GetProperty(e+"/nodes/"+l,this._gltf.nodes,l);a.push(this._loadNodeAsync("#/nodes/"+u._index,u))}return a.push(this._loadAnimationsAsync()),Promise.all(a).then((function(){}))},t.prototype._forEachPrimitive=function(e,r){if(e._primitiveBabylonMeshes)for(var t=0,n=e._primitiveBabylonMeshes;t<n.length;t++){var o=n[t];r(o)}else r(e._babylonMesh)},t.prototype._getMeshes=function(){var e=new Array;e.push(this._rootBabylonMesh);var r=this._gltf.nodes;if(r)for(var t=0,n=r;t<n.length;t++){var o=n[t];if(o._babylonMesh&&e.push(o._babylonMesh),o._primitiveBabylonMeshes)for(var a=0,i=o._primitiveBabylonMeshes;a<i.length;a++){var s=i[a];e.push(s)}}return e},t.prototype._getSkeletons=function(){var e=new Array,r=this._gltf.skins;if(r)for(var t=0,n=r;t<n.length;t++){var o=n[t];o._babylonSkeleton&&e.push(o._babylonSkeleton)}return e},t.prototype._getAnimationGroups=function(){var e=new Array,r=this._gltf.animations;if(r)for(var t=0,n=r;t<n.length;t++){var o=n[t];o._babylonAnimationGroup&&e.push(o._babylonAnimationGroup)}return e},t.prototype._startAnimations=function(){switch(this.animationStartMode){case e.GLTFLoaderAnimationStartMode.NONE:break;case e.GLTFLoaderAnimationStartMode.FIRST:var r=this._getAnimationGroups();0!==r.length&&r[0].start(!0);break;case e.GLTFLoaderAnimationStartMode.ALL:for(var r=this._getAnimationGroups(),t=0,n=r;t<n.length;t++){n[t].start(!0)}break;default:return void e.Tools.Error("Invalid animation start mode ("+this.animationStartMode+")")}},t.prototype._loadNodeAsync=function(n,o){var a=r.GLTFLoaderExtension._LoadNodeAsync(this,n,o);if(a)return a;if(o._babylonMesh)throw new Error(n+": Invalid recursive node hierarchy");var i=new Array,s=new e.Mesh(o.name||"node"+o._index,this._babylonScene,o._parent._babylonMesh);if(o._babylonMesh=s,t._LoadTransform(o,s),void 0!=o.mesh){var l=t._GetProperty(n+"/mesh",this._gltf.meshes,o.mesh);i.push(this._loadMeshAsync("#/meshes/"+l._index,o,l,s))}if(void 0!=o.camera){var u=t._GetProperty(n+"/camera",this._gltf.cameras,o.camera);this._loadCamera("#/cameras/"+u._index,u,s)}if(o.children)for(var c=0,d=o.children;c<d.length;c++){var f=d[c],h=t._GetProperty(n+"/children/"+f,this._gltf.nodes,f);i.push(this._loadNodeAsync("#/nodes/"+f,h))}return this.onMeshLoadedObservable.notifyObservers(s),Promise.all(i).then((function(){}))},t.prototype._loadMeshAsync=function(n,o,a,i){var s=this,l=new Array,u=a.primitives;if(!u||0===u.length)throw new Error(n+": Primitives are missing");if(r._ArrayItem.Assign(u),1===u.length){var c=u[0];l.push(this._loadPrimitiveAsync(n+"/primitives/"+c._index,o,a,c,i))}else{o._primitiveBabylonMeshes=[];for(var d=0,f=u;d<f.length;d++){var c=f[d],h=new e.Mesh((a.name||i.name)+"_"+c._index,this._babylonScene,i);o._primitiveBabylonMeshes.push(h),l.push(this._loadPrimitiveAsync(n+"/primitives/"+c._index,o,a,c,h)),this.onMeshLoadedObservable.notifyObservers(i)}}if(void 0!=o.skin){var p=t._GetProperty(n+"/skin",this._gltf.skins,o.skin);l.push(this._loadSkinAsync("#/skins/"+p._index,o,a,p))}return Promise.all(l).then((function(){s._forEachPrimitive(o,(function(e){e._refreshBoundingInfo(!0)}))}))},t.prototype._loadPrimitiveAsync=function(e,r,n,o,a){var i=this,s=new Array
- ;this._createMorphTargets(e,r,n,o,a),s.push(this._loadVertexDataAsync(e,o,a).then((function(r){return i._loadMorphTargetsAsync(e,o,a,r).then((function(){r.applyToMesh(a)}))})));var l=t._GetDrawMode(e,o.mode);if(void 0==o.material)a.material=this._getDefaultMaterial(l);else{var u=t._GetProperty(e+"/material}",this._gltf.materials,o.material);s.push(this._loadMaterialAsync("#/materials/"+u._index,u,a,l,(function(e){a.material=e})))}return Promise.all(s).then((function(){}))},t.prototype._loadVertexDataAsync=function(n,o,a){var i=this,s=r.GLTFLoaderExtension._LoadVertexDataAsync(this,n,o,a);if(s)return s;var l=o.attributes;if(!l)throw new Error(n+": Attributes are missing");var u=new Array,c=new e.Geometry(a.name,this._babylonScene);if(void 0==o.indices)a.isUnIndexed=!0;else{var d=t._GetProperty(n+"/indices",this._gltf.accessors,o.indices);u.push(this._loadIndicesAccessorAsync("#/accessors/"+d._index,d).then((function(e){c.setIndices(e)})))}var f=function(e,r,o){if(void 0!=l[e]){a._delayInfo=a._delayInfo||[],-1===a._delayInfo.indexOf(r)&&a._delayInfo.push(r);var s=t._GetProperty(n+"/attributes/"+e,i._gltf.accessors,l[e]);u.push(i._loadVertexAccessorAsync("#/accessors/"+s._index,s,r).then((function(e){c.setVerticesBuffer(e,s.count)}))),o&&o(s)}};return f("POSITION",e.VertexBuffer.PositionKind),f("NORMAL",e.VertexBuffer.NormalKind),f("TANGENT",e.VertexBuffer.TangentKind),f("TEXCOORD_0",e.VertexBuffer.UVKind),f("TEXCOORD_1",e.VertexBuffer.UV2Kind),f("JOINTS_0",e.VertexBuffer.MatricesIndicesKind),f("WEIGHTS_0",e.VertexBuffer.MatricesWeightsKind),f("COLOR_0",e.VertexBuffer.ColorKind,(function(e){"VEC4"===e.type&&(a.hasVertexAlpha=!0)})),Promise.all(u).then((function(){return c}))},t.prototype._createMorphTargets=function(r,t,n,o,a){if(o.targets){if(void 0==t._numMorphTargets)t._numMorphTargets=o.targets.length;else if(o.targets.length!==t._numMorphTargets)throw new Error(r+": Primitives do not have the same number of targets");a.morphTargetManager=new e.MorphTargetManager;for(var i=0;i<o.targets.length;i++){var s=t.weights?t.weights[i]:n.weights?n.weights[i]:0;a.morphTargetManager.addTarget(new e.MorphTarget("morphTarget"+i,s))}}},t.prototype._loadMorphTargetsAsync=function(e,r,t,n){if(!r.targets)return Promise.resolve();for(var o=new Array,a=t.morphTargetManager,i=0;i<a.numTargets;i++){var s=a.getTarget(i);o.push(this._loadMorphTargetVertexDataAsync(e+"/targets/"+i,n,r.targets[i],s))}return Promise.all(o).then((function(){}))},t.prototype._loadMorphTargetVertexDataAsync=function(r,n,o,a){var i=this,s=new Array,l=function(e,a,l){if(void 0!=o[e]){var u=n.getVertexBuffer(a);if(u){var c=t._GetProperty(r+"/"+e,i._gltf.accessors,o[e]);s.push(i._loadFloatAccessorAsync("#/accessors/"+c._index,c).then((function(e){l(u,e)})))}}};return l("POSITION",e.VertexBuffer.PositionKind,(function(e,r){e.forEach(r.length,(function(e,t){r[t]+=e})),a.setPositions(r)})),l("NORMAL",e.VertexBuffer.NormalKind,(function(e,r){e.forEach(r.length,(function(e,t){r[t]+=e})),a.setNormals(r)})),l("TANGENT",e.VertexBuffer.TangentKind,(function(e,r){var t=0;e.forEach(r.length/3*4,(function(e,n){(n+1)%4!=0&&(r[t++]+=e)})),a.setTangents(r)})),Promise.all(s).then((function(){}))},t._LoadTransform=function(r,t){var n=e.Vector3.Zero(),o=e.Quaternion.Identity(),a=e.Vector3.One();if(r.matrix){e.Matrix.FromArray(r.matrix).decompose(a,o,n)}else r.translation&&(n=e.Vector3.FromArray(r.translation)),r.rotation&&(o=e.Quaternion.FromArray(r.rotation)),r.scale&&(a=e.Vector3.FromArray(r.scale));t.position=n,t.rotationQuaternion=o,t.scaling=a},t.prototype._loadSkinAsync=function(r,t,n,o){var a=this,i=function(r){a._forEachPrimitive(t,(function(e){e.skeleton=r})),t._babylonMesh.parent=a._rootBabylonMesh,t._babylonMesh.position=e.Vector3.Zero(),t._babylonMesh.rotationQuaternion=e.Quaternion.Identity(),t._babylonMesh.scaling=e.Vector3.One()};if(o._loaded)return o._loaded.then((function(){i(o._babylonSkeleton)}));var s="skeleton"+o._index,l=new e.Skeleton(o.name||s,s,this._babylonScene);return o._babylonSkeleton=l,this._loadBones(r,o),i(l),o._loaded=this._loadSkinInverseBindMatricesDataAsync(r,o).then((function(e){a._updateBoneMatrices(l,e)}))},t.prototype._loadBones=function(e,r){for(var n={},o=0,a=r.joints;o<a.length;o++){var i=a[o],s=t._GetProperty(e+"/joints/"+i,this._gltf.nodes,i);this._loadBone(s,r,n)}},t.prototype._loadBone=function(r,t,n){var o=n[r._index];if(o)return o;var a=null;r._parent._babylonMesh!==this._rootBabylonMesh&&(a=this._loadBone(r._parent,t,n));var i=t.joints.indexOf(r._index);return o=new e.Bone(r.name||"joint"+r._index,t._babylonSkeleton,a,this._getNodeMatrix(r),null,null,i),n[r._index]=o,r._babylonBones=r._babylonBones||[],r._babylonBones.push(o),o},t.prototype._loadSkinInverseBindMatricesDataAsync=function(e,r){if(void 0==r.inverseBindMatrices)return Promise.resolve(null);var n=t._GetProperty(e+"/inverseBindMatrices",this._gltf.accessors,r.inverseBindMatrices);return this._loadFloatAccessorAsync("#/accessors/"+n._index,n)},t.prototype._updateBoneMatrices=function(r,t){for(var n=0,o=r.bones;n<o.length;n++){var a=o[n],i=e.Matrix.Identity(),s=a._index;t&&-1!==s&&(e.Matrix.FromArrayToRef(t,16*s,i),i.invertToRef(i));var l=a.getParent();l&&i.multiplyToRef(l.getInvertedAbsoluteTransform(),i),a.updateMatrix(i,!1,!1),a._updateDifferenceMatrix(void 0,!1)}},t.prototype._getNodeMatrix=function(r){return r.matrix?e.Matrix.FromArray(r.matrix):e.Matrix.Compose(r.scale?e.Vector3.FromArray(r.scale):e.Vector3.One(),r.rotation?e.Quaternion.FromArray(r.rotation):e.Quaternion.Identity(),r.translation?e.Vector3.FromArray(r.translation):e.Vector3.Zero())},t.prototype._loadCamera=function(r,t,n){var o=new e.FreeCamera(t.name||"camera"+t._index,e.Vector3.Zero(),this._babylonScene,!1);switch(o.parent=n,o.rotation=new e.Vector3(0,Math.PI,0),t.type){case"perspective":var a=t.perspective;if(!a)throw new Error(r+": Camera perspective properties are missing");o.fov=a.yfov,o.minZ=a.znear,o.maxZ=a.zfar||Number.MAX_VALUE;break;case"orthographic":if(!t.orthographic)throw new Error(r+": Camera orthographic properties are missing");o.mode=e.Camera.ORTHOGRAPHIC_CAMERA,o.orthoLeft=-t.orthographic.xmag,o.orthoRight=t.orthographic.xmag,o.orthoBottom=-t.orthographic.ymag,o.orthoTop=t.orthographic.ymag,o.minZ=t.orthographic.znear,o.maxZ=t.orthographic.zfar;break;default:throw new Error(r+": Invalid camera type ("+t.type+")")}this.onCameraLoadedObservable.notifyObservers(o)},t.prototype._loadAnimationsAsync=function(){var e=this._gltf.animations;if(!e)return Promise.resolve();for(var r=new Array,t=0;t<e.length;t++){var n=e[t];r.push(this._loadAnimationAsync("#/animations/"+t,n))}return Promise.all(r).then((function(){}))},t.prototype._loadAnimationAsync=function(t,n){var o=this,a=new e.AnimationGroup(n.name||"animation"+n._index,this._babylonScene);n._babylonAnimationGroup=a;var i=new Array;r._ArrayItem.Assign(n.channels),r._ArrayItem.Assign(n.samplers);for(var s=0,l=n.channels;s<l.length;s++){var u=l[s];i.push(this._loadAnimationChannelAsync(t+"/channels/"+u._index,t,n,u,a))}return Promise.all(i).then((function(){a.normalize(o._normalizeAnimationGroupsToBeginAtZero?0:null)}))},t.prototype._loadAnimationChannelAsync=function(r,n,o,a,i){var s=this,l=t._GetProperty(r+"/target/node",this._gltf.nodes,a.target.node);if("weights"===a.target.path&&!l._numMorphTargets||"weights"!==a.target.path&&!l._babylonMesh)return Promise.resolve();if(void 0!=l.skin&&"weights"!==a.target.path)return Promise.resolve();var u=t._GetProperty(r+"/sampler",o.samplers,a.sampler);return this._loadAnimationSamplerAsync(n+"/samplers/"+a.sampler,u).then((function(t){var n,o;switch(a.target.path){case"translation":n="position",o=e.Animation.ANIMATIONTYPE_VECTOR3;break;case"rotation":n="rotationQuaternion",o=e.Animation.ANIMATIONTYPE_QUATERNION;break;case"scale":n="scaling",o=e.Animation.ANIMATIONTYPE_VECTOR3;break;case"weights":n="influence",o=e.Animation.ANIMATIONTYPE_FLOAT;break;default:throw new Error(r+": Invalid target path ("+a.target.path+")")}var u,c=0;switch(n){case"position":u=function(){var r=e.Vector3.FromArray(t.output,c);return c+=3,r};break;case"rotationQuaternion":u=function(){var r=e.Quaternion.FromArray(t.output,c);return c+=4,r};break;case"scaling":u=function(){var r=e.Vector3.FromArray(t.output,c);return c+=3,r};break;case"influence":u=function(){for(var e=new Array(l._numMorphTargets),r=0;r<l._numMorphTargets;r++)e[r]=t.output[c++];return e}}var d;switch(t.interpolation){case"STEP":d=function(r){return{frame:t.input[r],value:u(),interpolation:e.AnimationKeyInterpolation.STEP}};break;case"LINEAR":d=function(e){return{frame:t.input[e],value:u()}};break;case"CUBICSPLINE":d=function(e){return{frame:t.input[e],inTangent:u(),value:u(),outTangent:u()}}}for(var f=new Array(t.input.length),h=0;h<t.input.length;h++)f[h]=d(h);if("influence"===n)for(var p=0;p<l._numMorphTargets;p++)!(function(r){var t=i.name+"_channel"+i.targetedAnimations.length,a=new e.Animation(t,n,1,o);a.setKeys(f.map((function(e){return{frame:e.frame,inTangent:e.inTangent?e.inTangent[r]:void 0,value:e.value[r],outTangent:e.outTangent?e.outTangent[r]:void 0}}))),s._forEachPrimitive(l,(function(e){var t=e.morphTargetManager.getTarget(r),n=a.clone();t.animations.push(n),i.addTargetedAnimation(n,t)}))})(p);else{var m=i.name+"_channel"+i.targetedAnimations.length,_=new e.Animation(m,n,1,o);if(_.setKeys(f),l._babylonBones){for(var y=[l._babylonMesh].concat(l._babylonBones),v=0,b=y;v<b.length;v++){b[v].animations.push(_)}i.addTargetedAnimation(_,y)}else l._babylonMesh.animations.push(_),i.addTargetedAnimation(_,l._babylonMesh)}}))},t.prototype._loadAnimationSamplerAsync=function(e,r){if(r._data)return r._data;var n=r.interpolation||"LINEAR";switch(n){case"STEP":case"LINEAR":case"CUBICSPLINE":break;default:throw new Error(e+": Invalid interpolation ("+r.interpolation+")")}var o=t._GetProperty(e+"/input",this._gltf.accessors,r.input),a=t._GetProperty(e+"/output",this._gltf.accessors,r.output);return r._data=Promise.all([this._loadFloatAccessorAsync("#/accessors/"+o._index,o),this._loadFloatAccessorAsync("#/accessors/"+a._index,a)]).then((function(e){var r=e[0],t=e[1];return{input:r,interpolation:n,output:t}})),r._data},t.prototype._loadBufferAsync=function(e,r){if(r._data)return r._data;if(!r.uri)throw new Error(e+": Uri is missing");return r._data=this._loadUriAsync(e,r.uri),r._data},t.prototype._loadBufferViewAsync=function(e,r){if(r._data)return r._data;var n=t._GetProperty(e+"/buffer",this._gltf.buffers,r.buffer);return r._data=this._loadBufferAsync("#/buffers/"+n._index,n).then((function(t){try{return new Uint8Array(t.buffer,t.byteOffset+(r.byteOffset||0),r.byteLength)}catch(r){throw new Error(e+": "+r.message)}})),r._data},t.prototype._loadIndicesAccessorAsync=function(e,r){if("SCALAR"!==r.type)throw new Error(e+": Invalid type "+r.type);if(5121!==r.componentType&&5123!==r.componentType&&5125!==r.componentType)throw new Error(e+": Invalid component type "+r.componentType);if(r._data)return r._data;var n=t._GetProperty(e+"/bufferView",this._gltf.bufferViews,r.bufferView);return r._data=this._loadBufferViewAsync("#/bufferViews/"+n._index,n).then((function(n){return t._GetTypedArray(e,r.componentType,n,r.byteOffset,r.count)})),r._data},t.prototype._loadFloatAccessorAsync=function(e,r){var n=this;if(5126!==r.componentType)throw new Error("Invalid component type "+r.componentType);if(r._data)return r._data;var o=t._GetNumComponents(e,r.type),a=o*r.count;if(void 0==r.bufferView)r._data=Promise.resolve(new Float32Array(a));else{var i=t._GetProperty(e+"/bufferView",this._gltf.bufferViews,r.bufferView);r._data=this._loadBufferViewAsync("#/bufferViews/"+i._index,i).then((function(n){return t._GetTypedArray(e,r.componentType,n,r.byteOffset,a)}))}if(r.sparse){var s=r.sparse;r._data=r._data.then((function(a){var i=t._GetProperty(e+"/sparse/indices/bufferView",n._gltf.bufferViews,s.indices.bufferView),l=t._GetProperty(e+"/sparse/values/bufferView",n._gltf.bufferViews,s.values.bufferView);return Promise.all([n._loadBufferViewAsync("#/bufferViews/"+i._index,i),n._loadBufferViewAsync("#/bufferViews/"+l._index,l)]).then((function(n){for(var i=n[0],l=n[1],u=t._GetTypedArray(e+"/sparse/indices",s.indices.componentType,i,s.indices.byteOffset,s.count),c=t._GetTypedArray(e+"/sparse/values",r.componentType,l,s.values.byteOffset,o*s.count),d=0,f=0;f<u.length;f++)for(var h=u[f]*o,p=0;p<o;p++)a[h++]=c[d++];return a}))}))}return r._data},t.prototype._loadVertexBufferViewAsync=function(r,t,n){var o=this;return t._babylonBuffer?t._babylonBuffer:(t._babylonBuffer=this._loadBufferViewAsync(r,t).then((function(r){return new e.Buffer(o._babylonScene.getEngine(),r,!1)})),t._babylonBuffer)},t.prototype._loadVertexAccessorAsync=function(r,n,o){var a=this;if(n._babylonVertexBuffer)return n._babylonVertexBuffer;if(n.sparse)n._babylonVertexBuffer=this._loadFloatAccessorAsync(r,n).then((function(r){return new e.VertexBuffer(a._babylonScene.getEngine(),r,o,!1)}));else{var i=t._GetProperty(r+"/bufferView",this._gltf.bufferViews,n.bufferView);n._babylonVertexBuffer=this._loadVertexBufferViewAsync("#/bufferViews/"+i._index,i,o).then((function(s){var l=t._GetNumComponents(r,n.type);return new e.VertexBuffer(a._babylonScene.getEngine(),s,o,!1,!1,i.byteStride,!1,n.byteOffset,l,n.componentType,n.normalized,!0)}))}return n._babylonVertexBuffer},t.prototype._getDefaultMaterial=function(r){var t=this._defaultBabylonMaterials[r];return t||(t=this._createMaterial("__gltf_default",r),t.transparencyMode=e.PBRMaterial.PBRMATERIAL_OPAQUE,t.metallic=1,t.roughness=1,this.onMaterialLoadedObservable.notifyObservers(t)),t},t.prototype._loadMaterialMetallicRoughnessPropertiesAsync=function(r,t,n){var o=new Array;n.metallic=1,n.roughness=1;var a=t.pbrMetallicRoughness;return a&&(a.baseColorFactor?(n.albedoColor=e.Color3.FromArray(a.baseColorFactor),n.alpha=a.baseColorFactor[3]):n.albedoColor=e.Color3.White(),n.metallic=void 0==a.metallicFactor?1:a.metallicFactor,n.roughness=void 0==a.roughnessFactor?1:a.roughnessFactor,a.baseColorTexture&&o.push(this._loadTextureAsync(r+"/baseColorTexture",a.baseColorTexture,(function(e){n.albedoTexture=e}))),a.metallicRoughnessTexture&&(o.push(this._loadTextureAsync(r+"/metallicRoughnessTexture",a.metallicRoughnessTexture,(function(e){n.metallicTexture=e}))),n.useMetallnessFromMetallicTextureBlue=!0,n.useRoughnessFromMetallicTextureGreen=!0,n.useRoughnessFromMetallicTextureAlpha=!1)),this._loadMaterialAlphaProperties(r,t,n),Promise.all(o).then((function(){}))},t.prototype._loadMaterialAsync=function(e,t,n,o,a){var i=r.GLTFLoaderExtension._LoadMaterialAsync(this,e,t,n,o,a);if(i)return i;t._babylonData=t._babylonData||{};var s=t._babylonData[o];if(!s){var l=new Array,u=t.name||"materialSG_"+t._index,c=this._createMaterial(u,o);l.push(this._loadMaterialBasePropertiesAsync(e,t,c)),l.push(this._loadMaterialMetallicRoughnessPropertiesAsync(e,t,c)),this.onMaterialLoadedObservable.notifyObservers(c),s={material:c,meshes:[],loaded:Promise.all(l).then((function(){}))},t._babylonData[o]=s}return s.meshes.push(n),a(s.material),s.loaded},t.prototype._createMaterial=function(r,t){var n=new e.PBRMaterial(r,this._babylonScene);return n.sideOrientation=this._babylonScene.useRightHandedSystem?e.Material.CounterClockWiseSideOrientation:e.Material.ClockWiseSideOrientation,n.fillMode=t,n.enableSpecularAntiAliasing=!0,n.useRadianceOverAlpha=!this.transparencyAsCoverage,n.useSpecularOverAlpha=!this.transparencyAsCoverage,n},t.prototype._loadMaterialBasePropertiesAsync=function(r,t,n){var o=new Array;return n.emissiveColor=t.emissiveFactor?e.Color3.FromArray(t.emissiveFactor):new e.Color3(0,0,0),t.doubleSided&&(n.backFaceCulling=!1,n.twoSidedLighting=!0),t.normalTexture&&(o.push(this._loadTextureAsync(r+"/normalTexture",t.normalTexture,(function(e){n.bumpTexture=e}))),n.invertNormalMapX=!this._babylonScene.useRightHandedSystem,n.invertNormalMapY=this._babylonScene.useRightHandedSystem,void 0!=t.normalTexture.scale&&(n.bumpTexture.level=t.normalTexture.scale)),t.occlusionTexture&&(o.push(this._loadTextureAsync(r+"/occlusionTexture",t.occlusionTexture,(function(e){n.ambientTexture=e}))),n.useAmbientInGrayScale=!0,void 0!=t.occlusionTexture.strength&&(n.ambientTextureStrength=t.occlusionTexture.strength)),t.emissiveTexture&&o.push(this._loadTextureAsync(r+"/emissiveTexture",t.emissiveTexture,(function(e){n.emissiveTexture=e}))),Promise.all(o).then((function(){}))},t.prototype._loadMaterialAlphaProperties=function(r,t,n){switch(t.alphaMode||"OPAQUE"){case"OPAQUE":n.transparencyMode=e.PBRMaterial.PBRMATERIAL_OPAQUE;break;case"MASK":n.transparencyMode=e.PBRMaterial.PBRMATERIAL_ALPHATEST,n.alphaCutOff=void 0==t.alphaCutoff?.5:t.alphaCutoff,n.albedoTexture&&(n.albedoTexture.hasAlpha=!0);break;case"BLEND":n.transparencyMode=e.PBRMaterial.PBRMATERIAL_ALPHABLEND,n.albedoTexture&&(n.albedoTexture.hasAlpha=!0,n.useAlphaFromAlbedoTexture=!0);break;default:throw new Error(r+": Invalid alpha mode ("+t.alphaMode+")")}},t.prototype._loadTextureAsync=function(r,n,o){var a=this,i=t._GetProperty(r+"/index",this._gltf.textures,n.index);r="#/textures/"+n.index;var s=new Array,l=void 0==i.sampler?this._defaultSampler:t._GetProperty(r+"/sampler",this._gltf.samplers,i.sampler),u=this._loadSampler("#/samplers/"+l._index,l),c=new e.Deferred,d=new e.Texture(null,this._babylonScene,u.noMipMaps,!1,u.samplingMode,function(){a._disposed||c.resolve()},function(e,t){a._disposed||c.reject(new Error(r+": "+(t&&t.message?t.message:e||"Failed to load texture")))});s.push(c.promise),d.name=i.name||"texture"+i._index,d.wrapU=u.wrapU,d.wrapV=u.wrapV,d.coordinatesIndex=n.texCoord||0;var f=t._GetProperty(r+"/source",this._gltf.images,i.source);return s.push(this._loadImageAsync("#/images/"+f._index,f).then((function(e){d.updateURL(e)}))),o(d),this.onTextureLoadedObservable.notifyObservers(d),Promise.all(s).then((function(){}))},t.prototype._loadSampler=function(e,r){return r._data||(r._data={noMipMaps:9728===r.minFilter||9729===r.minFilter,samplingMode:t._GetTextureSamplingMode(e,r.magFilter,r.minFilter),wrapU:t._GetTextureWrapMode(e,r.wrapS),wrapV:t._GetTextureWrapMode(e,r.wrapT)}),r._data},t.prototype._loadImageAsync=function(e,r){if(r._objectURL)return r._objectURL;var n;if(r.uri)n=this._loadUriAsync(e,r.uri);else{var o=t._GetProperty(e+"/bufferView",this._gltf.bufferViews,r.bufferView);n=this._loadBufferViewAsync("#/bufferViews/"+o._index,o)}return r._objectURL=n.then((function(e){return URL.createObjectURL(new Blob([e],{type:r.mimeType}))})),r._objectURL},t.prototype._loadUriAsync=function(n,o){var a=this,i=r.GLTFLoaderExtension._LoadUriAsync(this,n,o);if(i)return i;if(!t._ValidateUri(o))throw new Error(n+": Uri '"+o+"' is invalid");return e.Tools.IsBase64(o)?Promise.resolve(new Uint8Array(e.Tools.DecodeBase64(o))):this.preprocessUrlAsync(this._rootUrl+o).then((function(r){return new Promise(function(t,i){if(!a._disposed){var s=e.Tools.LoadFile(r,(function(e){a._disposed||t(new Uint8Array(e))}),(function(r){if(!a._disposed)try{s&&a._state===e.GLTFLoaderState.LOADING&&(s._lengthComputable=r.lengthComputable,s._loaded=r.loaded,s._total=r.total,a._onProgress())}catch(e){i(e)}}),a._babylonScene.database,!0,(function(r,t){a._disposed||i(new e.LoadFileError(n+": Failed to load '"+o+"'"+(r?": "+r.status+" "+r.statusText:""),r))}));a._requests.push(s)}})}))},t.prototype._onProgress=function(){if(this._progressCallback){for(var r=!0,t=0,n=0,o=0,a=this._requests;o<a.length;o++){var i=a[o];if(void 0===i._lengthComputable||void 0===i._loaded||void 0===i._total)return;r=r&&i._lengthComputable,t+=i._loaded,n+=i._total}this._progressCallback(new e.SceneLoaderProgressEvent(r,t,r?n:0))}},t._GetProperty=function(e,r,t){if(!r||void 0==t||!r[t])throw new Error(e+": Failed to find index ("+t+")");return r[t]},t._GetTextureWrapMode=function(r,t){switch(t=void 0==t?10497:t){case 33071:return e.Texture.CLAMP_ADDRESSMODE;case 33648:return e.Texture.MIRROR_ADDRESSMODE;case 10497:return e.Texture.WRAP_ADDRESSMODE;default:return e.Tools.Warn(r+": Invalid texture wrap mode ("+t+")"),e.Texture.WRAP_ADDRESSMODE}},t._GetTextureSamplingMode=function(r,t,n){if(t=void 0==t?9729:t,n=void 0==n?9987:n,9729===t)switch(n){case 9728:return e.Texture.LINEAR_NEAREST;case 9729:return e.Texture.LINEAR_LINEAR;case 9984:return e.Texture.LINEAR_NEAREST_MIPNEAREST;case 9985:return e.Texture.LINEAR_LINEAR_MIPNEAREST;case 9986:return e.Texture.LINEAR_NEAREST_MIPLINEAR;case 9987:return e.Texture.LINEAR_LINEAR_MIPLINEAR;default:return e.Tools.Warn(r+": Invalid texture minification filter ("+n+")"),e.Texture.LINEAR_LINEAR_MIPLINEAR}else switch(9728!==t&&e.Tools.Warn(r+": Invalid texture magnification filter ("+t+")"),n){case 9728:return e.Texture.NEAREST_NEAREST;case 9729:return e.Texture.NEAREST_LINEAR;case 9984:return e.Texture.NEAREST_NEAREST_MIPNEAREST;case 9985:return e.Texture.NEAREST_LINEAR_MIPNEAREST;case 9986:return e.Texture.NEAREST_NEAREST_MIPLINEAR;case 9987:return e.Texture.NEAREST_LINEAR_MIPLINEAR;default:return e.Tools.Warn(r+": Invalid texture minification filter ("+n+")"),e.Texture.NEAREST_NEAREST_MIPNEAREST}},t._GetTypedArray=function(e,r,t,n,o){var a=t.buffer;n=t.byteOffset+(n||0);try{switch(r){case 5120:return new Int8Array(a,n,o);case 5121:return new Uint8Array(a,n,o);case 5122:return new Int16Array(a,n,o);case 5123:return new Uint16Array(a,n,o);case 5125:return new Uint32Array(a,n,o);case 5126:return new Float32Array(a,n,o);default:throw new Error("Invalid component type "+r)}}catch(r){throw new Error(e+": "+r)}},t._GetNumComponents=function(e,r){switch(r){case"SCALAR":return 1;case"VEC2":return 2;case"VEC3":return 3;case"VEC4":case"MAT2":return 4;case"MAT3":return 9;case"MAT4":return 16}throw new Error(e+": Invalid type ("+r+")")},t._ValidateUri=function(r){return e.Tools.IsBase64(r)||-1===r.indexOf("..")},t._GetDrawMode=function(r,t){switch(void 0==t&&(t=4),t){case 0:return e.Material.PointListDrawMode;case 1:return e.Material.LineListDrawMode;case 2:return e.Material.LineLoopDrawMode;case 3:return e.Material.LineStripDrawMode;case 4:return e.Material.TriangleFillMode;case 5:return e.Material.TriangleStripDrawMode;case 6:return e.Material.TriangleFanDrawMode}throw new Error(r+": Invalid mesh primitive mode ("+t+")")},t.prototype._compileMaterialsAsync=function(){var e=new Array;if(this._gltf.materials)for(var r=0,t=this._gltf.materials;r<t.length;r++){var n=t[r];if(n._babylonData)for(var o in n._babylonData)for(var a=n._babylonData[o],i=0,s=a.meshes;i<s.length;i++){var l=s[i];l.computeWorldMatrix(!0);var u=a.material;e.push(u.forceCompilationAsync(l)),this.useClipPlane&&e.push(u.forceCompilationAsync(l,{clipPlane:!0}))}}return Promise.all(e).then((function(){}))},t.prototype._compileShadowGeneratorsAsync=function(){for(var e=new Array,r=this._babylonScene.lights,t=0,n=r;t<n.length;t++){var o=n[t],a=o.getShadowGenerator();a&&e.push(a.forceCompilationAsync())}return Promise.all(e).then((function(){}))},t.prototype._clear=function(){for(var e=0,r=this._requests;e<r.length;e++){r[e].abort()}if(this._requests.length=0,this._gltf&&this._gltf.images)for(var t=0,n=this._gltf.images;t<n.length;t++){var o=n[t];o._objectURL&&(o._objectURL.then((function(e){URL.revokeObjectURL(e)})),o._objectURL=void 0)}delete this._gltf,delete this._babylonScene,this._completePromises.length=0;for(var a in this._extensions)this._extensions[a].dispose();this._extensions={},delete this._rootBabylonMesh,delete this._progressCallback,this.onMeshLoadedObservable.clear(),this.onTextureLoadedObservable.clear(),this.onMaterialLoadedObservable.clear(),this.onCameraLoadedObservable.clear()},t.prototype._applyExtensions=function(e){for(var r=0,n=t._ExtensionNames;r<n.length;r++){var o=n[r],a=this._extensions[o];if(a.enabled){var i=e(a);if(i)return i}}return null},t._ExtensionNames=new Array,t._ExtensionFactories={},t})();r.GLTFLoader=t,e.GLTFFileLoader.CreateGLTFLoaderV2=function(){return new t}})(e.GLTF2||(e.GLTF2={}))})(e||(e={}));var e;!(function(e){!(function(e){var r=(function(){function e(e){this.enabled=!0,this._loader=e}return e.prototype.dispose=function(){delete this._loader},e.prototype._loadSceneAsync=function(e,r){return null},e.prototype._loadNodeAsync=function(e,r){return null},e.prototype._loadVertexDataAsync=function(e,r,t){return null},e.prototype._loadMaterialAsync=function(e,r,t,n,o){return null},e.prototype._loadUriAsync=function(e,r){return null},e.prototype._loadExtensionAsync=function(e,r,t){if(!r.extensions)return null;var n=r.extensions,o=n[this.name];if(!o)return null;delete n[this.name];try{return t(e+"/extensions/"+this.name,o)}finally{n[this.name]=o}},e._LoadSceneAsync=function(e,r,t){return e._applyExtensions((function(e){return e._loadSceneAsync(r,t)}))},e._LoadNodeAsync=function(e,r,t){return e._applyExtensions((function(e){return e._loadNodeAsync(r,t)}))},e._LoadVertexDataAsync=function(e,r,t,n){return e._applyExtensions((function(e){return e._loadVertexDataAsync(r,t,n)}))},e._LoadMaterialAsync=function(e,r,t,n,o,a){return e._applyExtensions((function(e){return e._loadMaterialAsync(r,t,n,o,a)}))},e._LoadUriAsync=function(e,r,t){return e._applyExtensions((function(e){return e._loadUriAsync(r,t)}))},e})();e.GLTFLoaderExtension=r})(e.GLTF2||(e.GLTF2={}))})(e||(e={}));var e;!(function(e){!(function(t){!(function(n){var o="MSFT_lod",a=(function(n){function a(){var e=null!==n&&n.apply(this,arguments)||this;return e.name=o,e.maxLODsToLoad=Number.MAX_VALUE,e._loadingNodeLOD=null,e._loadNodeSignals={},e._loadingMaterialLOD=null,e._loadMaterialSignals={},e}return r(a,n),a.prototype._loadNodeAsync=function(r,t){var n=this;return this._loadExtensionAsync(r,t,(function(r,o){for(var a,i=n._getLODs(r,t,n._loader._gltf.nodes,o.ids),s=0;s<i.length;s++)!(function(r){var t=i[r];0!==r&&(n._loadingNodeLOD=t,n._loadNodeSignals[t._index]||(n._loadNodeSignals[t._index]=new e.Deferred));var o=n._loader._loadNodeAsync("#/nodes/"+t._index,t).then((function(){if(0!==r){var e=i[r-1];e._babylonMesh&&(e._babylonMesh.dispose(!1,!0),delete e._babylonMesh)}if(r!==i.length-1){var t=i[r+1]._index;n._loadNodeSignals[t]&&(n._loadNodeSignals[t].resolve(),delete n._loadNodeSignals[t])}}));0===r?a=o:(n._loader._completePromises.push(o),n._loadingNodeLOD=null)})(s);return a}))},a.prototype._loadMaterialAsync=function(r,t,n,o,a){var i=this;return this._loadingNodeLOD?null:this._loadExtensionAsync(r,t,(function(r,s){for(var l,u=i._getLODs(r,t,i._loader._gltf.materials,s.ids),c=0;c<u.length;c++)!(function(r){var t=u[r];0!==r&&(i._loadingMaterialLOD=t,i._loadMaterialSignals[t._index]||(i._loadMaterialSignals[t._index]=new e.Deferred));var s=i._loader._loadMaterialAsync("#/materials/"+t._index,t,n,o,0===r?a:function(){}).then((function(){if(0!==r){var e=t._babylonData;a(e[o].material);var n=u[r-1]._babylonData;n[o]&&(n[o].material.dispose(),delete n[o])}if(r!==u.length-1){var s=u[r+1]._index;i._loadMaterialSignals[s]&&(i._loadMaterialSignals[s].resolve(),delete i._loadMaterialSignals[s])}}));0===r?l=s:(i._loader._completePromises.push(s),i._loadingMaterialLOD=null)})(c);return l}))},a.prototype._loadUriAsync=function(e,r){var t=this;if(this._loadingMaterialLOD){var n=this._loadingMaterialLOD._index;return this._loadMaterialSignals[n].promise.then((function(){return t._loader._loadUriAsync(e,r)}))}if(this._loadingNodeLOD){var n=this._loadingNodeLOD._index;return this._loadNodeSignals[n].promise.then((function(){return t._loader._loadUriAsync(e,r)}))}return null},a.prototype._getLODs=function(e,r,n,o){if(this.maxLODsToLoad<=0)throw new Error("maxLODsToLoad must be greater than zero");for(var a=new Array,i=o.length-1;i>=0;i--)if(a.push(t.GLTFLoader._GetProperty(e+"/ids/"+o[i],n,o[i])),a.length===this.maxLODsToLoad)return a;return a.push(r),a},a})(t.GLTFLoaderExtension);n.MSFT_lod=a,t.GLTFLoader._Register(o,(function(e){return new a(e)}))})(t.Extensions||(t.Extensions={}))})(e.GLTF2||(e.GLTF2={}))})(e||(e={}));var e;!(function(e){!(function(e){!(function(t){var n="MSFT_minecraftMesh",o=(function(e){function t(r){var t=e.call(this,r)||this;t.name=n,t._onMaterialLoaded=function(e){e.needAlphaBlending()&&(e.forceDepthWrite=!0,e.separateCullingPass=!0),e.backFaceCulling=e.forceDepthWrite,e.twoSidedLighting=!0};var o=r._gltf.meshes;if(o&&o.length)for(var a=0,i=o;a<i.length;a++){var s=i[a];if(s&&s.extras&&s.extras.MSFT_minecraftMesh){t._loader.onMaterialLoadedObservable.add(t._onMaterialLoaded);break}}return t}return r(t,e),t})(e.GLTFLoaderExtension);t.MSFT_minecraftMesh=o,e.GLTFLoader._Register(n,(function(e){return new o(e)}))})(e.Extensions||(e.Extensions={}))})(e.GLTF2||(e.GLTF2={}))})(e||(e={}));var e;!(function(e){!(function(e){!(function(t){var n="MSFT_sRGBFactors",o=(function(e){function t(r){var t=e.call(this,r)||this;t.name=n,t._onMaterialLoaded=function(e){e.albedoTexture||e.albedoColor.toLinearSpaceToRef(e.albedoColor),e.reflectivityTexture||e.reflectivityColor.toLinearSpaceToRef(e.reflectivityColor)};var o=r._gltf.materials;if(o&&o.length)for(var a=0,i=o;a<i.length;a++){var s=i[a];if(s&&s.extras&&s.extras.MSFT_sRGBFactors){t._loader.onMaterialLoadedObservable.add(t._onMaterialLoaded);break}}return t}return r(t,e),t})(e.GLTFLoaderExtension);t.MSFT_sRGBFactors=o,e.GLTFLoader._Register(n,(function(e){return new o(e)}))})(e.Extensions||(e.Extensions={}))})(e.GLTF2||(e.GLTF2={}))})(e||(e={}));var e;!(function(e){!(function(t){!(function(n){var o="KHR_draco_mesh_compression",a=(function(n){function a(r){var t=n.call(this,r)||this;return t.name=o,t._dracoCompression=null,e.DracoCompression.DecoderAvailable||(t.enabled=!1),t}return r(a,n),a.prototype.dispose=function(){this._dracoCompression&&this._dracoCompression.dispose(),n.prototype.dispose.call(this)},a.prototype._loadVertexDataAsync=function(r,n,o){var a=this;return this._loadExtensionAsync(r,n,(function(i,s){if(void 0!=n.mode){if(5!==n.mode&&4!==n.mode)throw new Error(r+": Unsupported mode "+n.mode);if(5===n.mode)throw new Error(r+": Mode "+n.mode+" is not currently supported")}var l={},u=function(e,r){var t=s.attributes[e];void 0!=t&&(o._delayInfo=o._delayInfo||[],-1===o._delayInfo.indexOf(r)&&o._delayInfo.push(r),l[r]=t)};u("POSITION",e.VertexBuffer.PositionKind),u("NORMAL",e.VertexBuffer.NormalKind),u("TANGENT",e.VertexBuffer.TangentKind),u("TEXCOORD_0",e.VertexBuffer.UVKind),u("TEXCOORD_1",e.VertexBuffer.UV2Kind),u("JOINTS_0",e.VertexBuffer.MatricesIndicesKind),u("WEIGHTS_0",e.VertexBuffer.MatricesWeightsKind),u("COLOR_0",e.VertexBuffer.ColorKind);var c=t.GLTFLoader._GetProperty(i,a._loader._gltf.bufferViews,s.bufferView);return c._dracoBabylonGeometry||(c._dracoBabylonGeometry=a._loader._loadBufferViewAsync("#/bufferViews/"+c._index,c).then((function(t){return a._dracoCompression||(a._dracoCompression=new e.DracoCompression),a._dracoCompression.decodeMeshAsync(t,l).then((function(r){var t=new e.Geometry(o.name,a._loader._babylonScene);return r.applyToGeometry(t),t})).catch((function(e){throw new Error(r+": "+e.message)}))}))),c._dracoBabylonGeometry}))},a})(t.GLTFLoaderExtension);n.KHR_draco_mesh_compression=a,t.GLTFLoader._Register(o,(function(e){return new a(e)}))})(t.Extensions||(t.Extensions={}))})(e.GLTF2||(e.GLTF2={}))})(e||(e={}));var e;!(function(e){!(function(t){!(function(n){var o="KHR_materials_pbrSpecularGlossiness",a=(function(t){function n(){var e=null!==t&&t.apply(this,arguments)||this;return e.name=o,e}return r(n,t),n.prototype._loadMaterialAsync=function(e,r,t,n,o){var a=this;return this._loadExtensionAsync(e,r,(function(i,s){r._babylonData=r._babylonData||{};var l=r._babylonData[n];if(!l){var u=new Array,c=r.name||"materialSG_"+r._index,d=a._loader._createMaterial(c,n);u.push(a._loader._loadMaterialBasePropertiesAsync(e,r,d)),u.push(a._loadSpecularGlossinessPropertiesAsync(i,r,s,d)),a._loader.onMaterialLoadedObservable.notifyObservers(d),l={material:d,meshes:[],loaded:Promise.all(u).then((function(){}))},r._babylonData[n]=l}return l.meshes.push(t),o(l.material),l.loaded}))},n.prototype._loadSpecularGlossinessPropertiesAsync=function(r,t,n,o){var a=new Array;return n.diffuseFactor?(o.albedoColor=e.Color3.FromArray(n.diffuseFactor),o.alpha=n.diffuseFactor[3]):o.albedoColor=e.Color3.White(),o.reflectivityColor=n.specularFactor?e.Color3.FromArray(n.specularFactor):e.Color3.White(),
- o.microSurface=void 0==n.glossinessFactor?1:n.glossinessFactor,n.diffuseTexture&&a.push(this._loader._loadTextureAsync(r+"/diffuseTexture",n.diffuseTexture,(function(e){o.albedoTexture=e}))),n.specularGlossinessTexture&&(a.push(this._loader._loadTextureAsync(r+"/specularGlossinessTexture",n.specularGlossinessTexture,(function(e){o.reflectivityTexture=e}))),o.reflectivityTexture.hasAlpha=!0,o.useMicroSurfaceFromReflectivityMapAlpha=!0),this._loader._loadMaterialAlphaProperties(r,t,o),Promise.all(a).then((function(){}))},n})(t.GLTFLoaderExtension);n.KHR_materials_pbrSpecularGlossiness=a,t.GLTFLoader._Register(o,(function(e){return new a(e)}))})(t.Extensions||(t.Extensions={}))})(e.GLTF2||(e.GLTF2={}))})(e||(e={}));var e;!(function(e){!(function(t){!(function(n){var o="KHR_materials_unlit",a=(function(t){function n(){var e=null!==t&&t.apply(this,arguments)||this;return e.name=o,e}return r(n,t),n.prototype._loadMaterialAsync=function(e,r,t,n,o){var a=this;return this._loadExtensionAsync(e,r,(function(){r._babylonData=r._babylonData||{};var i=r._babylonData[n];if(!i){var s=r.name||"materialUnlit_"+r._index,l=a._loader._createMaterial(s,n);l.unlit=!0;var u=a._loadUnlitPropertiesAsync(e,r,l);a._loader.onMaterialLoadedObservable.notifyObservers(l),i={material:l,meshes:[],loaded:u},r._babylonData[n]=i}return i.meshes.push(t),o(i.material),i.loaded}))},n.prototype._loadUnlitPropertiesAsync=function(r,t,n){var o=new Array;n.metallic=1,n.roughness=1;var a=t.pbrMetallicRoughness;return a&&(a.baseColorFactor?(n.albedoColor=e.Color3.FromArray(a.baseColorFactor),n.alpha=a.baseColorFactor[3]):n.albedoColor=e.Color3.White(),a.baseColorTexture&&o.push(this._loader._loadTextureAsync(r+"/baseColorTexture",a.baseColorTexture,(function(e){n.albedoTexture=e})))),t.doubleSided&&(n.backFaceCulling=!1,n.twoSidedLighting=!0),this._loader._loadMaterialAlphaProperties(r,t,n),Promise.all(o).then((function(){}))},n})(t.GLTFLoaderExtension);n.KHR_materials_unlit=a,t.GLTFLoader._Register(o,(function(e){return new a(e)}))})(t.Extensions||(t.Extensions={}))})(e.GLTF2||(e.GLTF2={}))})(e||(e={}));var e;return (function(e){!(function(t){!(function(n){var o,a="KHR_lights";!(function(e){e.AMBIENT="ambient",e.DIRECTIONAL="directional",e.POINT="point",e.SPOT="spot"})(o||(o={}));var i=(function(n){function i(){var e=null!==n&&n.apply(this,arguments)||this;return e.name=a,e}return r(i,n),i.prototype._loadSceneAsync=function(r,n){var a=this;return this._loadExtensionAsync(r,n,(function(r,i){var s=a._loader._loadSceneAsync(r,n),l=t.GLTFLoader._GetProperty(r,a._lights,i.light);if(l.type!==o.AMBIENT)throw new Error(r+": Only ambient lights are allowed on a scene");return a._loader._babylonScene.ambientColor=l.color?e.Color3.FromArray(l.color):e.Color3.Black(),s}))},i.prototype._loadNodeAsync=function(r,n){var a=this;return this._loadExtensionAsync(r,n,(function(r,i){var s,l=a._loader._loadNodeAsync(r,n),u=t.GLTFLoader._GetProperty(r,a._lights,i.light),c=n._babylonMesh.name;switch(u.type){case o.AMBIENT:throw new Error(r+": Ambient lights are not allowed on a node");case o.DIRECTIONAL:s=new e.DirectionalLight(c,e.Vector3.Forward(),a._loader._babylonScene);break;case o.POINT:s=new e.PointLight(c,e.Vector3.Zero(),a._loader._babylonScene);break;case o.SPOT:var d=u,f=d.outerConeAngle||Math.PI/4;s=new e.SpotLight(c,e.Vector3.Zero(),e.Vector3.Forward(),f,2,a._loader._babylonScene);break;default:throw new Error(r+": Invalid light type ("+u.type+")")}return s.diffuse=u.color?e.Color3.FromArray(u.color):e.Color3.White(),s.intensity=void 0==u.intensity?1:u.intensity,s.parent=n._babylonMesh,l}))},Object.defineProperty(i.prototype,"_lights",{get:function(){var e=this._loader._gltf.extensions;if(!e||!e[this.name])throw new Error("#/extensions: '"+this.name+"' not found");return e[this.name].lights},enumerable:!0,configurable:!0}),i})(t.GLTFLoaderExtension);n.KHR_lights=i,t.GLTFLoader._Register(a,(function(e){return new i(e)}))})(t.Extensions||(t.Extensions={}))})(e.GLTF2||(e.GLTF2={}))})(e||(e={})),e}));
|