text: !function(e,n){"object"==typeof exports&&"object"==typeof module?module.exports=n(require("babylonjs")):"function"==typeof define&&define.amd?define("babylonjs-loaders",["babylonjs"],n):"object"==typeof exports?exports["babylonjs-loaders"]=n(require("babylonjs")):e.LOADERS=n(e.BABYLON)}("undefined"!=typeof self?self:"undefined"!=typeof global?global:this,(function(e){return function(e){var n={};function r(t){if(n[t])return n[t].exports;var o=n[t]={i:t,l:!1,exports:{}};return e[t].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=e,r.c=n,r.d=function(e,n,t){r.o(e,n)||Object.defineProperty(e,n,{enumerable:!0,get:t})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,n){if(1&n&&(e=r(e)),8&n)return e;if(4&n&&"object"==typeof e&&e&&e.__esModule)return e;var t=Object.create(null);if(r.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:e}),2&n&&"string"!=typeof e)for(var o in e)r.d(t,o,function(n){return e[n]}.bind(null,o));return t},r.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(n,"a",n),n},r.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},r.p="",r(r.s=16)}([function(n,r){n.exports=e},,function(e,n,r){"use strict";r.r(n),r.d(n,"GLTFLoaderCoordinateSystemMode",(function(){return t})),r.d(n,"GLTFLoaderAnimationStartMode",(function(){return o})),r.d(n,"GLTFLoaderState",(function(){return i})),r.d(n,"GLTFFileLoader",(function(){return u}));var t,o,i,a=r(0),s=r(3);!function(e){e[e.AUTO=0]="AUTO",e[e.FORCE_RIGHT_HANDED=1]="FORCE_RIGHT_HANDED"}(t||(t={})),function(e){e[e.NONE=0]="NONE",e[e.FIRST=1]="FIRST",e[e.ALL=2]="ALL"}(o||(o={})),function(e){e[e.LOADING=0]="LOADING",e[e.READY=1]="READY",e[e.COMPLETE=2]="COMPLETE"}(i||(i={}));var u=function(){function e(){this.onParsedObservable=new a.Observable,this.coordinateSystemMode=t.AUTO,this.animationStartMode=o.FIRST,this.compileMaterials=!1,this.useClipPlane=!1,this.compileShadowGenerators=!1,this.transparencyAsCoverage=!1,this.useRangeRequests=!1,this.createInstances=!0,this.alwaysComputeBoundingBox=!1,this.loadAllMaterials=!1,this.preprocessUrlAsync=function(e){return Promise.resolve(e)},this.onMeshLoadedObservable=new a.Observable,this.onTextureLoadedObservable=new a.Observable,this.onMaterialLoadedObservable=new a.Observable,this.onCameraLoadedObservable=new a.Observable,this.onCompleteObservable=new a.Observable,this.onErrorObservable=new a.Observable,this.onDisposeObservable=new a.Observable,this.onExtensionLoadedObservable=new a.Observable,this.validate=!1,this.onValidatedObservable=new a.Observable,this._loader=null,this._requests=new Array,this.name="gltf",this.extensions={".gltf":{isBinary:!1},".glb":{isBinary:!0}},this._logIndentLevel=0,this._loggingEnabled=!1,this._log=this._logDisabled,this._capturePerformanceCounters=!1,this._startPerformanceCounter=this._startPerformanceCounterDisabled,this._endPerformanceCounter=this._endPerformanceCounterDisabled}return Object.defineProperty(e.prototype,"onParsed",{set:function(e){this._onParsedObserver&&this.onParsedObservable.remove(this._onParsedObserver),this._onParsedObserver=this.onParsedObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onMeshLoaded",{set:function(e){this._onMeshLoadedObserver&&this.onMeshLoadedObservable.remove(this._onMeshLoadedObserver),this._onMeshLoadedObserver=this.onMeshLoadedObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onTextureLoaded",{set:function(e){this._onTextureLoadedObserver&&this.onTextureLoadedObservable.remove(this._onTextureLoadedObserver),this._onTextureLoadedObserver=this.onTextureLoadedObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onMaterialLoaded",{set:function(e){this._onMaterialLoadedObserver&&this.onMaterialLoadedObservable.remove(this._onMaterialLoadedObserver),this._onMaterialLoadedObserver=this.onMaterialLoadedObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onCameraLoaded",{set:function(e){this._onCameraLoadedObserver&&this.onCameraLoadedObservable.remove(this._onCameraLoadedObserver),this._onCameraLoadedObserver=this.onCameraLoadedObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onComplete",{set:function(e){this._onCompleteObserver&&this.onCompleteObservable.remove(this._onCompleteObserver),this._onCompleteObserver=this.onCompleteObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onError",{set:function(e){this._onErrorObserver&&this.onErrorObservable.remove(this._onErrorObserver),this._onErrorObserver=this.onErrorObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onDispose",{set:function(e){this._onDisposeObserver&&this.onDisposeObservable.remove(this._onDisposeObserver),this._onDisposeObserver=this.onDisposeObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onExtensionLoaded",{set:function(e){this._onExtensionLoadedObserver&&this.onExtensionLoadedObservable.remove(this._onExtensionLoadedObserver),this._onExtensionLoadedObserver=this.onExtensionLoadedObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"loggingEnabled",{get:function(){return this._loggingEnabled},set:function(e){this._loggingEnabled!==e&&(this._loggingEnabled=e,this._loggingEnabled?this._log=this._logEnabled:this._log=this._logDisabled)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"capturePerformanceCounters",{get:function(){return this._capturePerformanceCounters},set:function(e){this._capturePerformanceCounters!==e&&(this._capturePerformanceCounters=e,this._capturePerformanceCounters?(this._startPerformanceCounter=this._startPerformanceCounterEnabled,this._endPerformanceCounter=this._endPerformanceCounterEnabled):(this._startPerformanceCounter=this._startPerformanceCounterDisabled,this._endPerformanceCounter=this._endPerformanceCounterDisabled))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onValidated",{set:function(e){this._onValidatedObserver&&this.onValidatedObservable.remove(this._onValidatedObserver),this._onValidatedObserver=this.onValidatedObservable.add(e)},enumerable:!1,configurable:!0}),e.prototype.dispose=function(){this._loader&&(this._loader.dispose(),this._loader=null);for(var e=0,n=this._requests;e<n.length;e++){n[e].abort()}this._requests.length=0,delete this._progressCallback,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(void 0),this.onDisposeObservable.clear()},e.prototype.requestFile=function(e,n,r,t,o,i){var s=this;if(this._progressCallback=t,o){if(this.useRangeRequests){this.validate&&a.Logger.Warn("glTF validation is not supported when range requests are enabled");var u={abort:function(){},onCompleteObservable:new a.Observable},l={readAsync:function(r,t){return new Promise((function(o,i){s._requestFile(n,e,(function(e){o(new Uint8Array(e))}),!0,(function(e){i(e)}),(function(e){e.setRequestHeader("Range","bytes="+r+"-"+(r+t-1))}))}))},byteLength:0};return this._unpackBinaryAsync(new a.DataReader(l)).then((function(e){u.onCompleteObservable.notifyObservers(u),r(e)}),i),u}return this._requestFile(n,e,(function(e,n){var t=e;s._unpackBinaryAsync(new a.DataReader({readAsync:function(e,n){return Promise.resolve(new Uint8Array(t,e,n))},byteLength:t.byteLength})).then((function(e){r(e,n)}),i)}),!0,i)}return this._requestFile(n,e,(function(t,o){s._validate(e,t,a.Tools.GetFolderPath(n),a.Tools.GetFilename(n)),r({json:s._parseJson(t)},o)}),o,i)},e.prototype.readFile=function(e,n,r,t,o,i){var s=this;return e._readFile(n,(function(t){if(s._validate(e,t,"file:",n.name),o){var u=t;s._unpackBinaryAsync(new a.DataReader({readAsync:function(e,n){return Promise.resolve(new Uint8Array(u,e,n))},byteLength:u.byteLength})).then(r,i)}else r({json:s._parseJson(t)})}),t,o,i)},e.prototype.importMeshAsync=function(e,n,r,t,o,i){var a=this;return Promise.resolve().then((function(){return a.onParsedObservable.notifyObservers(r),a.onParsedObservable.clear(),a._log("Loading "+(i||"")),a._loader=a._getLoader(r),a._loader.importMeshAsync(e,n,!1,r,t,o,i)}))},e.prototype.loadAsync=function(e,n,r,t,o){var i=this;return Promise.resolve().then((function(){return i.onParsedObservable.notifyObservers(n),i.onParsedObservable.clear(),i._log("Loading "+(o||"")),i._loader=i._getLoader(n),i._loader.loadAsync(e,n,r,t,o)}))},e.prototype.loadAssetContainerAsync=function(e,n,r,t,o){var i=this;return Promise.resolve().then((function(){i.onParsedObservable.notifyObservers(n),i.onParsedObservable.clear(),i._log("Loading "+(o||"")),i._loader=i._getLoader(n);var s=new a.AssetContainer(e),u=[];i.onMaterialLoadedObservable.add((function(e){u.push(e),e.onDisposeObservable.addOnce((function(){var n=s.materials.indexOf(e);n>-1&&s.materials.splice(n,1),(n=u.indexOf(e))>-1&&u.splice(n,1)}))}));var l=[];i.onTextureLoadedObservable.add((function(e){l.push(e),e.onDisposeObservable.addOnce((function(){var n=s.textures.indexOf(e);n>-1&&s.textures.splice(n,1),(n=l.indexOf(e))>-1&&l.splice(n,1)}))}));var c=[];return i.onCameraLoadedObservable.add((function(e){c.push(e)})),i._loader.importMeshAsync(null,e,!0,n,r,t,o).then((function(e){return Array.prototype.push.apply(s.meshes,e.meshes),Array.prototype.push.apply(s.particleSystems,e.particleSystems),Array.prototype.push.apply(s.skeletons,e.skeletons),Array.prototype.push.apply(s.animationGroups,e.animationGroups),Array.prototype.push.apply(s.materials,u),Array.prototype.push.apply(s.textures,l),Array.prototype.push.apply(s.lights,e.lights),Array.prototype.push.apply(s.transformNodes,e.transformNodes),Array.prototype.push.apply(s.cameras,c),s}))}))},e.prototype.canDirectLoad=function(n){return-1!==n.indexOf("asset")&&-1!==n.indexOf("version")||a.StringTools.StartsWith(n,"data:base64,"+e.magicBase64Encoded)||a.StringTools.StartsWith(n,"data:application/octet-stream;base64,"+e.magicBase64Encoded)||a.StringTools.StartsWith(n,"data:model/gltf-binary;base64,"+e.magicBase64Encoded)},e.prototype.directLoad=function(n,r){if(a.StringTools.StartsWith(r,"base64,"+e.magicBase64Encoded)||a.StringTools.StartsWith(r,"application/octet-stream;base64,"+e.magicBase64Encoded)||a.StringTools.StartsWith(r,"model/gltf-binary;base64,"+e.magicBase64Encoded)){var t=a.Tools.DecodeBase64(r);return this._validate(n,t),this._unpackBinaryAsync(new a.DataReader({readAsync:function(e,n){return Promise.resolve(new Uint8Array(t,e,n))},byteLength:t.byteLength}))}return this._validate(n,r),Promise.resolve({json:this._parseJson(r)})},e.prototype.createPlugin=function(){return new e},Object.defineProperty(e.prototype,"loaderState",{get:function(){return this._loader?this._loader.state:null},enumerable:!1,configurable:!0}),e.prototype.whenCompleteAsync=function(){var e=this;return new Promise((function(n,r){e.onCompleteObservable.addOnce((function(){n()})),e.onErrorObservable.addOnce((function(e){r(e)}))}))},e.prototype._loadFile=function(e,n,r,t,o){var i=this,a=n._loadFile(e,r,(function(e){i._onProgress(e,a)}),void 0,t,o);return a.onCompleteObservable.add((function(e){i._requests.splice(i._requests.indexOf(e),1)})),this._requests.push(a),a},e.prototype._requestFile=function(e,n,r,t,o,i){var a=this,s=n._requestFile(e,r,(function(e){a._onProgress(e,s)}),void 0,t,o,i);return s.onCompleteObservable.add((function(e){a._requests.splice(a._requests.indexOf(e),1)})),this._requests.push(s),s},e.prototype._onProgress=function(e,n){if(this._progressCallback){n._lengthComputable=e.lengthComputable,n._loaded=e.loaded,n._total=e.total;for(var r=!0,t=0,o=0,i=0,a=this._requests;i<a.length;i++){var s=a[i];if(void 0===s._lengthComputable||void 0===s._loaded||void 0===s._total)return;r=r&&s._lengthComputable,t+=s._loaded,o+=s._total}this._progressCallback({lengthComputable:r,loaded:t,total:r?o:0})}},e.prototype._validate=function(e,n,r,t){var o=this;void 0===r&&(r=""),void 0===t&&(t=""),this.validate&&(this._startPerformanceCounter("Validate JSON"),s.GLTFValidation.ValidateAsync(n,r,t,(function(n){return o.preprocessUrlAsync(r+n).then((function(n){return e._loadFileAsync(n,void 0,!0,!0)}))})).then((function(e){o._endPerformanceCounter("Validate JSON"),o.onValidatedObservable.notifyObservers(e),o.onValidatedObservable.clear()}),(function(e){o._endPerformanceCounter("Validate JSON"),a.Tools.Warn("Failed to validate: "+e.message),o.onValidatedObservable.clear()})))},e.prototype._getLoader=function(n){var r=n.json.asset||{};this._log("Asset version: "+r.version),r.minVersion&&this._log("Asset minimum version: "+r.minVersion),r.generator&&this._log("Asset generator: "+r.generator);var t=e._parseVersion(r.version);if(!t)throw new Error("Invalid version: "+r.version);if(void 0!==r.minVersion){var o=e._parseVersion(r.minVersion);if(!o)throw new Error("Invalid minimum version: "+r.minVersion);if(e._compareVersion(o,{major:2,minor:0})>0)throw new Error("Incompatible minimum version: "+r.minVersion)}var i={1:e._CreateGLTF1Loader,2:e._CreateGLTF2Loader}[t.major];if(!i)throw new Error("Unsupported version: "+r.version);return i(this)},e.prototype._parseJson=function(e){this._startPerformanceCounter("Parse JSON"),this._log("JSON length: "+e.length);var n=JSON.parse(e);return this._endPerformanceCounter("Parse JSON"),n},e.prototype._unpackBinaryAsync=function(e){var n=this;return this._startPerformanceCounter("Unpack Binary"),e.loadAsync(20).then((function(){var r=e.readUint32();if(1179937895!==r)throw new Error("Unexpected magic: "+r);var t=e.readUint32();n.loggingEnabled&&n._log("Binary version: "+t);var o,i=e.readUint32();if(0!==e.buffer.byteLength&&i!==e.buffer.byteLength)throw new Error("Length in header does not match actual data length: "+i+" != "+e.buffer.byteLength);switch(t){case 1:o=n._unpackBinaryV1Async(e,i);break;case 2:o=n._unpackBinaryV2Async(e,i);break;default:throw new Error("Unsupported version: "+t)}return n._endPerformanceCounter("Unpack Binary"),o}))},e.prototype._unpackBinaryV1Async=function(e,n){var r=e.readUint32(),t=e.readUint32();if(0!==t)throw new Error("Unexpected content format: "+t);var o=n-e.byteOffset,i={json:this._parseJson(e.readString(r)),bin:null};if(0!==o){var a=e.byteOffset;i.bin={readAsync:function(n,r){return e.buffer.readAsync(a+n,r)},byteLength:o}}return Promise.resolve(i)},e.prototype._unpackBinaryV2Async=function(e,n){var r=this,t=1313821514,o=5130562,i=e.readUint32();if(e.readUint32()!==t)throw new Error("First chunk format is not JSON");return e.byteOffset+i===n?e.loadAsync(i).then((function(){return{json:r._parseJson(e.readString(i)),bin:null}})):e.loadAsync(i+8).then((function(){var a={json:r._parseJson(e.readString(i)),bin:null},s=function(){var r=e.readUint32();switch(e.readUint32()){case t:throw new Error("Unexpected JSON chunk");case o:var i=e.byteOffset;a.bin={readAsync:function(n,r){return e.buffer.readAsync(i+n,r)},byteLength:r},e.skipBytes(r);break;default:e.skipBytes(r)}return e.byteOffset!==n?e.loadAsync(8).then(s):Promise.resolve(a)};return s()}))},e._parseVersion=function(e){if("1.0"===e||"1.0.1"===e)return{major:1,minor:0};var n=(e+"").match(/^(\d+)\.(\d+)/);return n?{major:parseInt(n[1]),minor:parseInt(n[2])}:null},e._compareVersion=function(e,n){return e.major>n.major?1:e.major<n.major?-1:e.minor>n.minor?1:e.minor<n.minor?-1:0},e.prototype._logOpen=function(e){this._log(e),this._logIndentLevel++},e.prototype._logClose=function(){--this._logIndentLevel},e.prototype._logEnabled=function(n){var r=e._logSpaces.substr(0,2*this._logIndentLevel);a.Logger.Log(""+r+n)},e.prototype._logDisabled=function(e){},e.prototype._startPerformanceCounterEnabled=function(e){a.Tools.StartPerformanceCounter(e)},e.prototype._startPerformanceCounterDisabled=function(e){},e.prototype._endPerformanceCounterEnabled=function(e){a.Tools.EndPerformanceCounter(e)},e.prototype._endPerformanceCounterDisabled=function(e){},e.IncrementalLoading=!0,e.HomogeneousCoordinates=!1,e.magicBase64Encoded="Z2xURg",e._logSpaces="                                ",e}();a.SceneLoader&&a.SceneLoader.RegisterPlugin(new u)},function(e,n,r){"use strict";r.r(n),r.d(n,"GLTFValidation",(function(){return a}));var t=r(0);function o(e,n,r,t){var o={externalResourceFunction:function(e){return t(e).then((function(e){return new Uint8Array(e)}))}};return r&&(o.uri="file:"===n?r:n+r),e instanceof ArrayBuffer?GLTFValidator.validateBytes(new Uint8Array(e),o):GLTFValidator.validateString(e,o)}function i(){var e=[];onmessage=function(n){var r=n.data;switch(r.id){case"init":importScripts(r.url);break;case"validate":o(r.data,r.rootUrl,r.fileName,(function(n){return new Promise((function(r,t){var o=e.length;e.push({resolve:r,reject:t}),postMessage({id:"getExternalResource",index:o,uri:n})}))})).then((function(e){postMessage({id:"validate.resolve",value:e})}),(function(e){postMessage({id:"validate.reject",reason:e})}));break;case"getExternalResource.resolve":e[r.index].resolve(r.value);break;case"getExternalResource.reject":e[r.index].reject(r.reason)}}}var a=function(){function e(){}return e.ValidateAsync=function(e,n,r,a){var s=this;return"function"==typeof Worker?new Promise((function(u,l){var c=o+"("+i+")()",f=URL.createObjectURL(new Blob([c],{type:"application/javascript"})),d=new Worker(f),p=function(e){d.removeEventListener("error",p),d.removeEventListener("message",m),l(e)},m=function(e){var n=e.data;switch(n.id){case"getExternalResource":a(n.uri).then((function(e){d.postMessage({id:"getExternalResource.resolve",index:n.index,value:e},[e])}),(function(e){d.postMessage({id:"getExternalResource.reject",index:n.index,reason:e})}));break;case"validate.resolve":d.removeEventListener("error",p),d.removeEventListener("message",m),u(n.value);break;case"validate.reject":d.removeEventListener("error",p),d.removeEventListener("message",m),l(n.reason)}};d.addEventListener("error",p),d.addEventListener("message",m),d.postMessage({id:"init",url:t.Tools.GetAbsoluteUrl(s.Configuration.url)}),d.postMessage({id:"validate",data:e,rootUrl:n,fileName:r})})):(this._LoadScriptPromise||(this._LoadScriptPromise=t.Tools.LoadScriptAsync(this.Configuration.url)),this._LoadScriptPromise.then((function(){return o(e,n,r,a)})))},e.Configuration={url:"https://preview.babylonjs.com/gltf_validator.js"},e}()},function(e,n){var r;r=function(){return this}();try{r=r||new Function("return this")()}catch(e){"object"==typeof window&&(r=window)}e.exports=r},,,function(e,n,r){"use strict";r.r(n),r.d(n,"GLTFBinaryExtension",(function(){return j})),r.d(n,"GLTFLoaderBase",(function(){return U})),r.d(n,"GLTFLoader",(function(){return G})),r.d(n,"GLTFLoaderExtension",(function(){return k})),r.d(n,"EComponentType",(function(){return i})),r.d(n,"EShaderType",(function(){return a})),r.d(n,"EParameterType",(function(){return s})),r.d(n,"ETextureWrapMode",(function(){return u})),r.d(n,"ETextureFilterType",(function(){return l})),r.d(n,"ETextureFormat",(function(){return c})),r.d(n,"ECullingType",(function(){return f})),r.d(n,"EBlendingFunction",(function(){return d})),r.d(n,"GLTFUtils",(function(){return h})),r.d(n,"GLTFMaterialsCommonExtension",(function(){return H}));
  /*! *****************************************************************************
  Copyright (c) Microsoft Corporation.
  
  Permission to use, copy, modify, and/or distribute this software for any
  purpose with or without fee is hereby granted.
  
  THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
  REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
  AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
  INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
  LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  PERFORMANCE OF THIS SOFTWARE.
  ***************************************************************************** */
  var t=function(e,n){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,n){e.__proto__=n}||function(e,n){for(var r in n)n.hasOwnProperty(r)&&(e[r]=n[r])})(e,n)};function o(e,n){function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}Object.create;var i,a,s,u,l,c,f,d;Object.create;!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"}(i||(i={})),function(e){e[e.FRAGMENT=35632]="FRAGMENT",e[e.VERTEX=35633]="VERTEX"}(a||(a={})),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"}(s||(s={})),function(e){e[e.CLAMP_TO_EDGE=33071]="CLAMP_TO_EDGE",e[e.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",e[e.REPEAT=10497]="REPEAT"}(u||(u={})),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"}(l||(l={})),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"}(c||(c={})),function(e){e[e.FRONT=1028]="FRONT",e[e.BACK=1029]="BACK",e[e.FRONT_AND_BACK=1032]="FRONT_AND_BACK"}(f||(f={})),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"}(d||(d={}));var p,m=r(0),h=function(){function e(){}return e.SetMatrix=function(e,n,r,t,o){var i=null;if("MODEL"===r.semantic?i=n.getWorldMatrix():"PROJECTION"===r.semantic?i=e.getProjectionMatrix():"VIEW"===r.semantic?i=e.getViewMatrix():"MODELVIEWINVERSETRANSPOSE"===r.semantic?i=m.Matrix.Transpose(n.getWorldMatrix().multiply(e.getViewMatrix()).invert()):"MODELVIEW"===r.semantic?i=n.getWorldMatrix().multiply(e.getViewMatrix()):"MODELVIEWPROJECTION"===r.semantic?i=n.getWorldMatrix().multiply(e.getTransformMatrix()):"MODELINVERSE"===r.semantic?i=n.getWorldMatrix().invert():"VIEWINVERSE"===r.semantic?i=e.getViewMatrix().invert():"PROJECTIONINVERSE"===r.semantic?i=e.getProjectionMatrix().invert():"MODELVIEWINVERSE"===r.semantic?i=n.getWorldMatrix().multiply(e.getViewMatrix()).invert():"MODELVIEWPROJECTIONINVERSE"===r.semantic?i=n.getWorldMatrix().multiply(e.getTransformMatrix()).invert():"MODELINVERSETRANSPOSE"===r.semantic&&(i=m.Matrix.Transpose(n.getWorldMatrix().invert())),i)switch(r.type){case s.FLOAT_MAT2:o.setMatrix2x2(t,m.Matrix.GetAsMatrix2x2(i));break;case s.FLOAT_MAT3:o.setMatrix3x3(t,m.Matrix.GetAsMatrix3x3(i));break;case s.FLOAT_MAT4:o.setMatrix(t,i)}},e.SetUniform=function(e,n,r,t){switch(t){case s.FLOAT:return e.setFloat(n,r),!0;case s.FLOAT_VEC2:return e.setVector2(n,m.Vector2.FromArray(r)),!0;case s.FLOAT_VEC3:return e.setVector3(n,m.Vector3.FromArray(r)),!0;case s.FLOAT_VEC4:return e.setVector4(n,m.Vector4.FromArray(r)),!0;default:return!1}},e.GetWrapMode=function(e){switch(e){case u.CLAMP_TO_EDGE:return m.Texture.CLAMP_ADDRESSMODE;case u.MIRRORED_REPEAT:return m.Texture.MIRROR_ADDRESSMODE;case u.REPEAT:default:return m.Texture.WRAP_ADDRESSMODE}},e.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}},e.GetTextureFilterMode=function(e){switch(e){case l.LINEAR:case l.LINEAR_MIPMAP_NEAREST:case l.LINEAR_MIPMAP_LINEAR:return m.Texture.TRILINEAR_SAMPLINGMODE;case l.NEAREST:case l.NEAREST_MIPMAP_NEAREST:return m.Texture.NEAREST_SAMPLINGMODE;default:return m.Texture.BILINEAR_SAMPLINGMODE}},e.GetBufferFromBufferView=function(e,n,r,t,o){r=n.byteOffset+r;var a=e.loadedBufferViews[n.buffer];if(r+t>a.byteLength)throw new Error("Buffer access is out of range");var s=a.buffer;switch(r+=a.byteOffset,o){case i.BYTE:return new Int8Array(s,r,t);case i.UNSIGNED_BYTE:return new Uint8Array(s,r,t);case i.SHORT:return new Int16Array(s,r,t);case i.UNSIGNED_SHORT:return new Uint16Array(s,r,t);default:return new Float32Array(s,r,t)}},e.GetBufferFromAccessor=function(n,r){var t=n.bufferViews[r.bufferView],o=r.count*e.GetByteStrideFromType(r);return e.GetBufferFromBufferView(n,t,r.byteOffset,o,r.componentType)},e.DecodeBufferToText=function(e){for(var n="",r=e.byteLength,t=0;t<r;++t)n+=String.fromCharCode(e[t]);return n},e.GetDefaultMaterial=function(n){if(!e._DefaultMaterial){m.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"),m.Effect.ShadersStore.GLTFDefaultMaterialPixelShader=["precision highp float;","","uniform vec4 u_emission;","","void main(void)","{","    gl_FragColor = u_emission;","}"].join("\n");var r={attributes:["position"],uniforms:["worldView","projection","u_emission"],samplers:new Array,needAlphaBlending:!1};e._DefaultMaterial=new m.ShaderMaterial("GLTFDefaultMaterial",n,{vertex:"GLTFDefaultMaterial",fragment:"GLTFDefaultMaterial"},r),e._DefaultMaterial.setColor4("u_emission",new m.Color4(.5,.5,.5,1))}return e._DefaultMaterial},e._DefaultMaterial=null,e}(),v=r(2);!function(e){e[e.IDENTIFIER=1]="IDENTIFIER",e[e.UNKNOWN=2]="UNKNOWN",e[e.END_OF_INPUT=3]="END_OF_INPUT"}(p||(p={}));var b=function(){function e(e){this._pos=0,this.currentToken=p.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 p.END_OF_INPUT;if(this.currentString=this.read(),this.currentToken=p.UNKNOWN,"_"===this.currentString||this.isLetterOrDigitPattern.test(this.currentString))for(this.currentToken=p.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}(),y=["MODEL","VIEW","PROJECTION","MODELVIEW","MODELVIEWPROJECTION","JOINTMATRIX"],A=["world","view","projection","worldView","worldViewProjection","mBones"],_=["translation","rotation","scale"],O=["position","rotationQuaternion","scaling"],E=function(e,n,r){for(var t in e){var o=e[t];r[n][t]=o}},g=function(e){if(e)for(var n=0;n<e.length/2;n++)e[2*n+1]=1-e[2*n+1]},L=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 n=Number(e.semantic.split("_")[1]);return"uv"+(0===n?"":n+1)}return null},T=function(e){var n=null;if(e.translation||e.rotation||e.scale){var r=m.Vector3.FromArray(e.scale||[1,1,1]),t=m.Quaternion.FromArray(e.rotation||[0,0,0,1]),o=m.Vector3.FromArray(e.translation||[0,0,0]);n=m.Matrix.Compose(r,t,o)}else n=m.Matrix.FromArray(e.matrix);return n},N=function(e,n,r,t){for(var o=0;o<t.bones.length;o++)if(t.bones[o].name===r)return t.bones[o];var i=e.nodes;for(var a in i){var s=i[a];if(s.jointName){var u=s.children;for(o=0;o<u.length;o++){var l=e.nodes[u[o]];if(l.jointName&&l.jointName===r){var c=T(s),f=new m.Bone(s.name||"",t,N(e,n,s.jointName,t),c);return f.id=a,f}}}}return null},S=function(e,n){for(var r=0;r<e.length;r++)for(var t=e[r],o=0;o<t.node.children.length;o++){if(t.node.children[o]===n)return t.bone}return null},C=function(e,n){var r=e.nodes,t=r[n];if(t)return{node:t,id:n};for(var o in r)if((t=r[o]).jointName===n)return{node:t,id:o};return null},M=function(e,n){for(var r=0;r<e.jointNames.length;r++)if(e.jointNames[r]===n)return!0;return!1},x=function(e,n,r,t,o){if(t||(t=new m.Skeleton(n.name||"","",e.scene)),!n.babylonSkeleton)return t;var i=[],a=[];!function(e,n,r,t){for(var o in e.nodes){var i=e.nodes[o],a=o;if(i.jointName&&!M(r,i.jointName)){var s=T(i),u=new m.Bone(i.name||"",n,null,s);u.id=a,t.push({bone:u,node:i,id:a})}}for(var l=0;l<t.length;l++)for(var c=t[l],f=c.node.children,d=0;d<f.length;d++){for(var p=null,h=0;h<t.length;h++)if(t[h].id===f[d]){p=t[h];break}p&&(p.bone._parent=c.bone,c.bone.children.push(p.bone))}}(e,t,n,i),t.bones=[];for(var s=0;s<n.jointNames.length;s++){if(_=C(e,n.jointNames[s])){var u=_.node;if(u){o=_.id;var l=e.scene.getBoneByID(o);if(l)t.bones.push(l);else{for(var c=!1,f=null,d=0;d<s;d++){var p=C(e,n.jointNames[d]);if(p){var h=p.node;if(h){var v=h.children;if(v){c=!1;for(var b=0;b<v.length;b++)if(v[b]===o){f=N(e,n,n.jointNames[d],t),c=!0;break}if(c)break}}else m.Tools.Warn("Joint named "+n.jointNames[d]+" does not exist when looking for parent")}}var y=T(u);!f&&i.length>0&&(f=S(i,o))&&-1===a.indexOf(f)&&a.push(f),new m.Bone(u.jointName||"",t,f,y).id=o}}else m.Tools.Warn("Joint named "+n.jointNames[s]+" does not exist")}}var A=t.bones;t.bones=[];for(s=0;s<n.jointNames.length;s++){var _;if(_=C(e,n.jointNames[s]))for(d=0;d<A.length;d++)if(A[d].id===_.id){t.bones.push(A[d]);break}}t.prepare();for(s=0;s<a.length;s++)t.bones.push(a[s]);return t},R=function(e,n,r,t,o){if(o||(e.scene._blockEntityCollection=e.forAssetContainer,o=new m.Mesh(n.name||"",e.scene),e.scene._blockEntityCollection=!1,o.id=t),!n.babylonNode)return o;for(var i,a=[],s=null,u=new Array,l=new Array,c=new Array,f=new Array,d=0;d<r.length;d++){var p=r[d];if(P=e.meshes[p])for(var b=0;b<P.primitives.length;b++){var y=new m.VertexData,A=P.primitives[b];A.mode;var _=A.attributes,O=null,E=null;for(var L in _)if(O=e.accessors[_[L]],E=h.GetBufferFromAccessor(e,O),"NORMAL"===L)y.normals=new Float32Array(E.length),y.normals.set(E);else if("POSITION"===L){if(v.GLTFFileLoader.HomogeneousCoordinates){y.positions=new Float32Array(E.length-E.length/4);for(var T=0;T<E.length;T+=4)y.positions[T]=E[T],y.positions[T+1]=E[T+1],y.positions[T+2]=E[T+2]}else y.positions=new Float32Array(E.length),y.positions.set(E);l.push(y.positions.length)}else if(-1!==L.indexOf("TEXCOORD_")){var N=Number(L.split("_")[1]),S=m.VertexBuffer.UVKind+(0===N?"":N+1),C=new Float32Array(E.length);C.set(E),g(C),y.set(C,S)}else"JOINT"===L?(y.matricesIndices=new Float32Array(E.length),y.matricesIndices.set(E)):"WEIGHT"===L?(y.matricesWeights=new Float32Array(E.length),y.matricesWeights.set(E)):"COLOR"===L&&(y.colors=new Float32Array(E.length),y.colors.set(E));if(O=e.accessors[A.indices])E=h.GetBufferFromAccessor(e,O),y.indices=new Int32Array(E.length),y.indices.set(E),f.push(y.indices.length);else{var M=[];for(T=0;T<y.positions.length/3;T++)M.push(T);y.indices=new Int32Array(M),f.push(y.indices.length)}s?s.merge(y):s=y;var x=e.scene.getMaterialByID(A.material);a.push(null===x?h.GetDefaultMaterial(e.scene):x),u.push(0===u.length?0:u[u.length-1]+l[l.length-2]),c.push(0===c.length?0:c[c.length-1]+f[f.length-2])}}e.scene._blockEntityCollection=e.forAssetContainer,a.length>1?(i=new m.MultiMaterial("multimat"+t,e.scene)).subMaterials=a:i=new m.StandardMaterial("multimat"+t,e.scene),1===a.length&&(i=a[0]),o.material||(o.material=i),new m.Geometry(t,e.scene,s,!1,o),o.computeWorldMatrix(!0),e.scene._blockEntityCollection=!1,o.subMeshes=[];var R=0;for(d=0;d<r.length;d++){var P;p=r[d];if(P=e.meshes[p])for(b=0;b<P.primitives.length;b++)P.primitives[b].mode,m.SubMesh.AddToMesh(R,u[R],l[R],c[R],f[R],o,o,!0),R++}return o},P=function(e,n,r,t){e.position&&(e.position=n),(e.rotationQuaternion||e.rotation)&&(e.rotationQuaternion=r),e.scaling&&(e.scaling=t)},w=function(e,n,r,t){var o=null;if(e.importOnlyMeshes&&(n.skin||n.meshes)&&e.importMeshesNames&&e.importMeshesNames.length>0&&-1===e.importMeshesNames.indexOf(n.name||""))return null;if(n.skin){if(n.meshes){var i=e.skins[n.skin];(a=R(e,n,n.meshes,r,n.babylonNode)).skeleton=e.scene.getLastSkeletonByID(n.skin),null===a.skeleton&&(a.skeleton=x(e,i,0,i.babylonSkeleton,n.skin),i.babylonSkeleton||(i.babylonSkeleton=a.skeleton)),o=a}}else if(n.meshes){var a;o=a=R(e,n,n.mesh?[n.mesh]:n.meshes,r,n.babylonNode)}else if(!n.light||n.babylonNode||e.importOnlyMeshes){if(n.camera&&!n.babylonNode&&!e.importOnlyMeshes){var s=e.cameras[n.camera];if(s){if(e.scene._blockEntityCollection=e.forAssetContainer,"orthographic"===s.type){var u=new m.FreeCamera(n.camera,m.Vector3.Zero(),e.scene,!1);u.name=n.name||"",u.mode=m.Camera.ORTHOGRAPHIC_CAMERA,u.attachControl(e.scene.getEngine().getInputElement()),o=u}else if("perspective"===s.type){var l=s[s.type],c=new m.FreeCamera(n.camera,m.Vector3.Zero(),e.scene,!1);c.name=n.name||"",c.attachControl(e.scene.getEngine().getInputElement()),l.aspectRatio||(l.aspectRatio=e.scene.getEngine().getRenderWidth()/e.scene.getEngine().getRenderHeight()),l.znear&&l.zfar&&(c.maxZ=l.zfar,c.minZ=l.znear),o=c}e.scene._blockEntityCollection=!1}}}else{var f=e.lights[n.light];if(f)if("ambient"===f.type){var d=f[f.type],p=new m.HemisphericLight(n.light,m.Vector3.Zero(),e.scene);p.name=n.name||"",d.color&&(p.diffuse=m.Color3.FromArray(d.color)),o=p}else if("directional"===f.type){var h=f[f.type],v=new m.DirectionalLight(n.light,m.Vector3.Zero(),e.scene);v.name=n.name||"",h.color&&(v.diffuse=m.Color3.FromArray(h.color)),o=v}else if("point"===f.type){var b=f[f.type],y=new m.PointLight(n.light,m.Vector3.Zero(),e.scene);y.name=n.name||"",b.color&&(y.diffuse=m.Color3.FromArray(b.color)),o=y}else if("spot"===f.type){var A=f[f.type],_=new m.SpotLight(n.light,m.Vector3.Zero(),m.Vector3.Zero(),0,0,e.scene);_.name=n.name||"",A.color&&(_.diffuse=m.Color3.FromArray(A.color)),A.fallOfAngle&&(_.angle=A.fallOfAngle),A.fallOffExponent&&(_.exponent=A.fallOffExponent),o=_}}if(!n.jointName){if(n.babylonNode)return n.babylonNode;if(null===o){e.scene._blockEntityCollection=e.forAssetContainer;var O=new m.Mesh(n.name||"",e.scene);e.scene._blockEntityCollection=!1,n.babylonNode=O,o=O}}if(null!==o){if(n.matrix&&o instanceof m.Mesh)!function(e,n,r){if(n.matrix){var t=new m.Vector3(0,0,0),o=new m.Quaternion,i=new m.Vector3(0,0,0);m.Matrix.FromArray(n.matrix).decompose(i,o,t),P(e,t,o,i)}else n.translation&&n.rotation&&n.scale&&P(e,m.Vector3.FromArray(n.translation),m.Quaternion.FromArray(n.rotation),m.Vector3.FromArray(n.scale));e.computeWorldMatrix(!0)}(o,n);else{var E=n.translation||[0,0,0],g=n.rotation||[0,0,0,1],L=n.scale||[1,1,1];P(o,m.Vector3.FromArray(E),m.Quaternion.FromArray(g),m.Vector3.FromArray(L))}o.updateCache(!0),n.babylonNode=o}return o},I=function(e,n,r,t){void 0===t&&(t=!1);var o=e.nodes[n],i=null;if(t=!(e.importOnlyMeshes&&!t&&e.importMeshesNames)||(-1!==e.importMeshesNames.indexOf(o.name||"")||0===e.importMeshesNames.length),!o.jointName&&t&&null!==(i=w(e,o,n))&&(i.id=n,i.parent=r),o.children)for(var a=0;a<o.children.length;a++)I(e,o.children[a],i,t)},F=function(e){var n=e.currentScene;if(n)for(var r=0;r<n.nodes.length;r++)I(e,n.nodes[r],null);else for(var t in e.scenes){n=e.scenes[t];for(r=0;r<n.nodes.length;r++)I(e,n.nodes[r],null)}!function(e){for(var n in e.animations){var r=e.animations[n];if(r.channels&&r.samplers)for(var t=null,o=0;o<r.channels.length;o++){var i=r.channels[o],a=r.samplers[i.sampler];if(a){var s=null,u=null;r.parameters?(s=r.parameters[a.input],u=r.parameters[a.output]):(s=a.input,u=a.output);var l=h.GetBufferFromAccessor(e,e.accessors[s]),c=h.GetBufferFromAccessor(e,e.accessors[u]),f=i.target.id,d=e.scene.getNodeByID(f);if(null===d&&(d=e.scene.getNodeByName(f)),null!==d){var p=d instanceof m.Bone,v=i.target.path,b=_.indexOf(v);-1!==b&&(v=O[b]);var y=m.Animation.ANIMATIONTYPE_MATRIX;p||("rotationQuaternion"===v?(y=m.Animation.ANIMATIONTYPE_QUATERNION,d.rotationQuaternion=new m.Quaternion):y=m.Animation.ANIMATIONTYPE_VECTOR3);var A=null,E=[],g=0,L=!1;p&&t&&t.getKeys().length===l.length&&(A=t,L=!0),L||(e.scene._blockEntityCollection=e.forAssetContainer,A=new m.Animation(n,p?"_matrix":v,1,y,m.Animation.ANIMATIONLOOPMODE_CYCLE),e.scene._blockEntityCollection=!1);for(var T=0;T<l.length;T++){var N=null;if("rotationQuaternion"===v?(N=m.Quaternion.FromArray([c[g],c[g+1],c[g+2],c[g+3]]),g+=4):(N=m.Vector3.FromArray([c[g],c[g+1],c[g+2]]),g+=3),p){var S=d,C=m.Vector3.Zero(),M=new m.Quaternion,x=m.Vector3.Zero(),R=S.getBaseMatrix();L&&t&&(R=t.getKeys()[T].value),R.decompose(x,M,C),"position"===v?C=N:"rotationQuaternion"===v?M=N:x=N,N=m.Matrix.Compose(x,M,C)}L?t&&(t.getKeys()[T].value=N):E.push({frame:l[T],value:N})}!L&&A&&(A.setKeys(E),d.animations.push(A)),t=A,e.scene.stopAnimation(d),e.scene.beginAnimation(d,0,l[l.length-1],!0,1)}else m.Tools.Warn("Creating animation named "+n+". But cannot find node named "+f+" to attach to")}}}}(e);for(r=0;r<e.scene.skeletons.length;r++){var o=e.scene.skeletons[r];e.scene.beginAnimation(o,0,Number.MAX_VALUE,!0,1)}},B=function(e,n,r,t,o,i){return function(a){!function(e,n,r,t,o){var i=t.values||r.parameters,a=r.uniforms;for(var u in o){var l=o[u],c=l.type,f=i[a[u]];if(void 0===f&&(f=l.value),f){var d=function(e){return function(r){l.value&&e&&(n.setTexture(e,r),delete o[e])}};c===s.SAMPLER_2D?k.LoadTextureAsync(e,t.values?f:l.value,d(u),(function(){return d(null)})):l.value&&h.SetUniform(n,u,t.values?f:l.value,c)&&delete o[u]}}}(e,n,r,t,o),n.onBind=function(a){!function(e,n,r,t,o,i,a){var u=i.values||o.parameters;for(var l in r){var c=r[l],f=c.type;if(f===s.FLOAT_MAT2||f===s.FLOAT_MAT3||f===s.FLOAT_MAT4)if(!c.semantic||c.source||c.node){if(c.semantic&&(c.source||c.node)){var d=n.scene.getNodeByName(c.source||c.node||"");if(null===d&&(d=n.scene.getNodeByID(c.source||c.node||"")),null===d)continue;h.SetMatrix(n.scene,d,c,l,t.getEffect())}}else h.SetMatrix(n.scene,e,c,l,t.getEffect());else{var p=u[o.uniforms[l]];if(!p)continue;if(f===s.SAMPLER_2D){var m=n.textures[i.values?p:c.value].babylonTexture;if(null==m)continue;t.getEffect().setTexture(l,m)}else h.SetUniform(t.getEffect(),l,p,f)}}a(t)}(a,e,o,n,r,t,i)}}},V=function(e,n,r){for(var t in n.uniforms){var o=n.uniforms[t],i=n.parameters[o];if(e.currentIdentifier===t&&i.semantic&&!i.source&&!i.node){var a=y.indexOf(i.semantic);if(-1!==a)return delete r[t],A[a]}}return e.currentIdentifier},D=function(e){for(var n in e.materials)k.LoadMaterialAsync(e,n,(function(e){}),(function(){}))},U=function(){function e(){}return e.CreateRuntime=function(e,n,r){var t={extensions:{},accessors:{},buffers:{},bufferViews:{},meshes:{},lights:{},cameras:{},nodes:{},images:{},textures:{},shaders:{},programs:{},samplers:{},techniques:{},materials:{},animations:{},skins:{},extensionsUsed:[],scenes:{},buffersCount:0,shaderscount:0,scene:n,rootUrl:r,loadedBufferCount:0,loadedBufferViews:{},loadedShaderCount:0,importOnlyMeshes:!1,dummyNodes:[],forAssetContainer:!1};return e.extensions&&E(e.extensions,"extensions",t),e.extensionsUsed&&E(e.extensionsUsed,"extensionsUsed",t),e.buffers&&function(e,n){for(var r in e){var t=e[r];n.buffers[r]=t,n.buffersCount++}}(e.buffers,t),e.bufferViews&&E(e.bufferViews,"bufferViews",t),e.accessors&&E(e.accessors,"accessors",t),e.meshes&&E(e.meshes,"meshes",t),e.lights&&E(e.lights,"lights",t),e.cameras&&E(e.cameras,"cameras",t),e.nodes&&E(e.nodes,"nodes",t),e.images&&E(e.images,"images",t),e.textures&&E(e.textures,"textures",t),e.shaders&&function(e,n){for(var r in e){var t=e[r];n.shaders[r]=t,n.shaderscount++}}(e.shaders,t),e.programs&&E(e.programs,"programs",t),e.samplers&&E(e.samplers,"samplers",t),e.techniques&&E(e.techniques,"techniques",t),e.materials&&E(e.materials,"materials",t),e.animations&&E(e.animations,"animations",t),e.skins&&E(e.skins,"skins",t),e.scenes&&(t.scenes=e.scenes),e.scene&&e.scenes&&(t.currentScene=e.scenes[e.scene]),t},e.LoadBufferAsync=function(e,n,r,t,o){var i=e.buffers[n];m.Tools.IsBase64(i.uri)?setTimeout((function(){return r(new Uint8Array(m.Tools.DecodeBase64(i.uri)))})):m.Tools.LoadFile(e.rootUrl+i.uri,(function(e){return r(new Uint8Array(e))}),o,void 0,!0,(function(e){e&&t(e.status+" "+e.statusText)}))},e.LoadTextureBufferAsync=function(e,n,r,t){var o=e.textures[n];if(o&&o.source)if(o.babylonTexture)r(null);else{var i=e.images[o.source];m.Tools.IsBase64(i.uri)?setTimeout((function(){return r(new Uint8Array(m.Tools.DecodeBase64(i.uri)))})):m.Tools.LoadFile(e.rootUrl+i.uri,(function(e){return r(new Uint8Array(e))}),void 0,void 0,!0,(function(e){e&&t(e.status+" "+e.statusText)}))}else t("")},e.CreateTextureAsync=function(e,n,r,t,o){var i=e.textures[n];if(i.babylonTexture)t(i.babylonTexture);else{var a=e.samplers[i.sampler],s=a.minFilter===l.NEAREST_MIPMAP_NEAREST||a.minFilter===l.NEAREST_MIPMAP_LINEAR||a.minFilter===l.LINEAR_MIPMAP_NEAREST||a.minFilter===l.LINEAR_MIPMAP_LINEAR,u=m.Texture.BILINEAR_SAMPLINGMODE,c=null==r?new Blob:new Blob([r]),f=URL.createObjectURL(c),d=function(){return URL.revokeObjectURL(f)},p=new m.Texture(f,e.scene,!s,!0,u,d,d);void 0!==a.wrapS&&(p.wrapU=h.GetWrapMode(a.wrapS)),void 0!==a.wrapT&&(p.wrapV=h.GetWrapMode(a.wrapT)),p.name=n,i.babylonTexture=p,t(p)}},e.LoadShaderStringAsync=function(e,n,r,t){var o=e.shaders[n];if(m.Tools.IsBase64(o.uri)){var i=atob(o.uri.split(",")[1]);r&&r(i)}else m.Tools.LoadFile(e.rootUrl+o.uri,r,void 0,void 0,!1,(function(e){e&&t&&t(e.status+" "+e.statusText)}))},e.LoadMaterialAsync=function(e,n,r,t){var o=e.materials[n];if(o.technique){var i=e.techniques[o.technique];if(!i){e.scene._blockEntityCollection=e.forAssetContainer;var a=new m.StandardMaterial(n,e.scene);return e.scene._blockEntityCollection=!1,a.diffuseColor=new m.Color3(.5,.5,.5),a.sideOrientation=m.Material.CounterClockWiseSideOrientation,void r(a)}var u=e.programs[i.program],l=i.states,c=m.Effect.ShadersStore[u.vertexShader+"VertexShader"],h=m.Effect.ShadersStore[u.fragmentShader+"PixelShader"],v="",_="",O=new b(c),E=new b(h),g={},T=[],N=[],S=[];for(var C in i.uniforms){var M=i.uniforms[C],x=i.parameters[M];if(g[C]=x,!x.semantic||x.node||x.source)x.type===s.SAMPLER_2D?S.push(C):T.push(C);else{var R=y.indexOf(x.semantic);-1!==R?(T.push(A[R]),delete g[C]):T.push(C)}}for(var P in i.attributes){var w=i.attributes[P];if((D=i.parameters[w]).semantic){var I=L(D);I&&N.push(I)}}for(;!O.isEnd()&&O.getNextToken();){if(O.currentToken===p.IDENTIFIER){var F=!1;for(var P in i.attributes){w=i.attributes[P];var D=i.parameters[w];if(O.currentIdentifier===P&&D.semantic){v+=L(D),F=!0;break}}F||(v+=V(O,i,g))}else v+=O.currentString}for(;!E.isEnd()&&E.getNextToken();){E.currentToken===p.IDENTIFIER?_+=V(E,i,g):_+=E.currentString}var U={vertex:u.vertexShader+n,fragment:u.fragmentShader+n},G={attributes:N,uniforms:T,samplers:S,needAlphaBlending:l&&l.enable&&-1!==l.enable.indexOf(3042)};m.Effect.ShadersStore[u.vertexShader+n+"VertexShader"]=v,m.Effect.ShadersStore[u.fragmentShader+n+"PixelShader"]=_;var k=new m.ShaderMaterial(n,e.scene,U,G);if(k.onError=function(e,n,r){return function(t,o){n.dispose(!0),r("Cannot compile program named "+e.name+". Error: "+o+". Default material will be applied")}}(u,k,t),k.onCompiled=B(e,k,i,o,g,r),k.sideOrientation=m.Material.CounterClockWiseSideOrientation,l&&l.functions){var j=l.functions;j.cullFace&&j.cullFace[0]!==f.BACK&&(k.backFaceCulling=!1);var H=j.blendFuncSeparate;H&&(H[0]===d.SRC_ALPHA&&H[1]===d.ONE_MINUS_SRC_ALPHA&&H[2]===d.ONE&&H[3]===d.ONE?k.alphaMode=m.Constants.ALPHA_COMBINE:H[0]===d.ONE&&H[1]===d.ONE&&H[2]===d.ZERO&&H[3]===d.ONE?k.alphaMode=m.Constants.ALPHA_ONEONE:H[0]===d.SRC_ALPHA&&H[1]===d.ONE&&H[2]===d.ZERO&&H[3]===d.ONE?k.alphaMode=m.Constants.ALPHA_ADD:H[0]===d.ZERO&&H[1]===d.ONE_MINUS_SRC_COLOR&&H[2]===d.ONE&&H[3]===d.ONE?k.alphaMode=m.Constants.ALPHA_SUBTRACT:H[0]===d.DST_COLOR&&H[1]===d.ZERO&&H[2]===d.ONE&&H[3]===d.ONE?k.alphaMode=m.Constants.ALPHA_MULTIPLY:H[0]===d.SRC_ALPHA&&H[1]===d.ONE_MINUS_SRC_COLOR&&H[2]===d.ONE&&H[3]===d.ONE&&(k.alphaMode=m.Constants.ALPHA_MAXIMIZED))}}else t&&t("No technique found.")},e}(),G=function(){function e(){this.state=null}return e.RegisterExtension=function(n){e.Extensions[n.name]?m.Tools.Error('Tool with the same name "'+n.name+'" already exists'):e.Extensions[n.name]=n},e.prototype.dispose=function(){},e.prototype._importMeshAsync=function(e,n,r,t,o,i,a,s){var u=this;return n.useRightHandedSystem=!0,k.LoadRuntimeAsync(n,r,t,(function(n){n.forAssetContainer=o,n.importOnlyMeshes=!0,""===e?n.importMeshesNames=[]:"string"==typeof e?n.importMeshesNames=[e]:!e||e instanceof Array?(n.importMeshesNames=[],m.Tools.Warn("Argument meshesNames must be of type string or string[]")):n.importMeshesNames=[e],u._createNodes(n);var r=new Array,t=new Array;for(var s in n.nodes){var l=n.nodes[s];l.babylonNode instanceof m.AbstractMesh&&r.push(l.babylonNode)}for(var c in n.skins){var f=n.skins[c];f.babylonSkeleton instanceof m.Skeleton&&t.push(f.babylonSkeleton)}u._loadBuffersAsync(n,(function(){u._loadShadersAsync(n,(function(){D(n),F(n),!v.GLTFFileLoader.IncrementalLoading&&i&&i(r,t)}))}),a),v.GLTFFileLoader.IncrementalLoading&&i&&i(r,t)}),s),!0},e.prototype.importMeshAsync=function(e,n,r,t,o,i){var a=this;return new Promise((function(s,u){a._importMeshAsync(e,n,t,o,r,(function(e,n){s({meshes:e,particleSystems:[],skeletons:n,animationGroups:[],lights:[],transformNodes:[]})}),i,(function(e){u(new Error(e))}))}))},e.prototype._loadAsync=function(e,n,r,t,o,i,a){var s=this;e.useRightHandedSystem=!0,k.LoadRuntimeAsync(e,n,r,(function(e){k.LoadRuntimeExtensionsAsync(e,(function(){s._createNodes(e),s._loadBuffersAsync(e,(function(){s._loadShadersAsync(e,(function(){D(e),F(e),v.GLTFFileLoader.IncrementalLoading||o()}))})),v.GLTFFileLoader.IncrementalLoading&&o()}),a)}),a)},e.prototype.loadAsync=function(e,n,r,t){var o=this;return new Promise((function(i,a){o._loadAsync(e,n,r,!1,(function(){i()}),t,(function(e){a(new Error(e))}))}))},e.prototype._loadShadersAsync=function(e,n){var r=!1,t=function(r,t){k.LoadShaderStringAsync(e,r,(function(o){o instanceof ArrayBuffer||(e.loadedShaderCount++,o&&(m.Effect.ShadersStore[r+(t.type===a.VERTEX?"VertexShader":"PixelShader")]=o),e.loadedShaderCount===e.shaderscount&&n())}),(function(){m.Tools.Error("Error when loading shader program named "+r+" located at "+t.uri)}))};for(var o in e.shaders){r=!0;var i=e.shaders[o];i?t.bind(this,o,i)():m.Tools.Error("No shader named: "+o)}r||n()},e.prototype._loadBuffersAsync=function(e,n,r){var t=!1,o=function(r,t){k.LoadBufferAsync(e,r,(function(o){e.loadedBufferCount++,o&&(o.byteLength!=e.buffers[r].byteLength&&m.Tools.Error("Buffer named "+r+" is length "+o.byteLength+". Expected: "+t.byteLength),e.loadedBufferViews[r]=o),e.loadedBufferCount===e.buffersCount&&n()}),(function(){m.Tools.Error("Error when loading buffer named "+r+" located at "+t.uri)}))};for(var i in e.buffers){t=!0;var a=e.buffers[i];a?o.bind(this,i,a)():m.Tools.Error("No buffer named: "+i)}t||n()},e.prototype._createNodes=function(e){var n=e.currentScene;if(n)for(var r=0;r<n.nodes.length;r++)I(e,n.nodes[r],null);else for(var t in e.scenes){n=e.scenes[t];for(r=0;r<n.nodes.length;r++)I(e,n.nodes[r],null)}},e.Extensions={},e}(),k=function(){function e(e){this._name=e}return Object.defineProperty(e.prototype,"name",{get:function(){return this._name},enumerable:!1,configurable:!0}),e.prototype.loadRuntimeAsync=function(e,n,r,t,o){return!1},e.prototype.loadRuntimeExtensionsAsync=function(e,n,r){return!1},e.prototype.loadBufferAsync=function(e,n,r,t,o){return!1},e.prototype.loadTextureBufferAsync=function(e,n,r,t){return!1},e.prototype.createTextureAsync=function(e,n,r,t,o){return!1},e.prototype.loadShaderStringAsync=function(e,n,r,t){return!1},e.prototype.loadMaterialAsync=function(e,n,r,t){return!1},e.LoadRuntimeAsync=function(n,r,t,o,i){e.ApplyExtensions((function(e){return e.loadRuntimeAsync(n,r,t,o,i)}),(function(){setTimeout((function(){o&&o(U.CreateRuntime(r.json,n,t))}))}))},e.LoadRuntimeExtensionsAsync=function(n,r,t){e.ApplyExtensions((function(e){return e.loadRuntimeExtensionsAsync(n,r,t)}),(function(){setTimeout((function(){r()}))}))},e.LoadBufferAsync=function(n,r,t,o,i){e.ApplyExtensions((function(e){return e.loadBufferAsync(n,r,t,o,i)}),(function(){U.LoadBufferAsync(n,r,t,o,i)}))},e.LoadTextureAsync=function(n,r,t,o){e.LoadTextureBufferAsync(n,r,(function(i){i&&e.CreateTextureAsync(n,r,i,t,o)}),o)},e.LoadShaderStringAsync=function(n,r,t,o){e.ApplyExtensions((function(e){return e.loadShaderStringAsync(n,r,t,o)}),(function(){U.LoadShaderStringAsync(n,r,t,o)}))},e.LoadMaterialAsync=function(n,r,t,o){e.ApplyExtensions((function(e){return e.loadMaterialAsync(n,r,t,o)}),(function(){U.LoadMaterialAsync(n,r,t,o)}))},e.LoadTextureBufferAsync=function(n,r,t,o){e.ApplyExtensions((function(e){return e.loadTextureBufferAsync(n,r,t,o)}),(function(){U.LoadTextureBufferAsync(n,r,t,o)}))},e.CreateTextureAsync=function(n,r,t,o,i){e.ApplyExtensions((function(e){return e.createTextureAsync(n,r,t,o,i)}),(function(){U.CreateTextureAsync(n,r,t,o,i)}))},e.ApplyExtensions=function(e,n){for(var r in G.Extensions){if(e(G.Extensions[r]))return}n()},e}();v.GLTFFileLoader._CreateGLTF1Loader=function(){return new G};var j=function(e){function n(){return e.call(this,"KHR_binary_glTF")||this}return o(n,e),n.prototype.loadRuntimeAsync=function(e,n,r,t,o){var i=n.json.extensionsUsed;return!(!i||-1===i.indexOf(this.name)||!n.bin)&&(this._bin=n.bin,t(U.CreateRuntime(n.json,e,r)),!0)},n.prototype.loadBufferAsync=function(e,n,r,t){return-1!==e.extensionsUsed.indexOf(this.name)&&("binary_glTF"===n&&(this._bin.readAsync(0,this._bin.byteLength).then(r,(function(e){return t(e.message)})),!0))},n.prototype.loadTextureBufferAsync=function(e,n,r,t){var o=e.textures[n],a=e.images[o.source];if(!a.extensions||!(this.name in a.extensions))return!1;var s=a.extensions[this.name],u=e.bufferViews[s.bufferView];return r(h.GetBufferFromBufferView(e,u,0,u.byteLength,i.UNSIGNED_BYTE)),!0},n.prototype.loadShaderStringAsync=function(e,n,r,t){var o=e.shaders[n];if(!o.extensions||!(this.name in o.extensions))return!1;var a=o.extensions[this.name],s=e.bufferViews[a.bufferView],u=h.GetBufferFromBufferView(e,s,0,s.byteLength,i.UNSIGNED_BYTE);return setTimeout((function(){var e=h.DecodeBufferToText(u);r(e)})),!0},n}(k);G.RegisterExtension(new j);var H=function(e){function n(){return e.call(this,"KHR_materials_common")||this}return o(n,e),n.prototype.loadRuntimeExtensionsAsync=function(e,n,r){if(!e.extensions)return!1;var t=e.extensions[this.name];if(!t)return!1;var o=t.lights;if(o)for(var i in o){var a=o[i];switch(a.type){case"ambient":var s=new m.HemisphericLight(a.name,new m.Vector3(0,1,0),e.scene),u=a.ambient;u&&(s.diffuse=m.Color3.FromArray(u.color||[1,1,1]));break;case"point":var l=new m.PointLight(a.name,new m.Vector3(10,10,10),e.scene),c=a.point;c&&(l.diffuse=m.Color3.FromArray(c.color||[1,1,1]));break;case"directional":var f=new m.DirectionalLight(a.name,new m.Vector3(0,-1,0),e.scene),d=a.directional;d&&(f.diffuse=m.Color3.FromArray(d.color||[1,1,1]));break;case"spot":var p=a.spot;if(p)new m.SpotLight(a.name,new m.Vector3(0,10,0),new m.Vector3(0,-1,0),p.fallOffAngle||Math.PI,p.fallOffExponent||0,e.scene).diffuse=m.Color3.FromArray(p.color||[1,1,1]);break;default:m.Tools.Warn('GLTF Material Common extension: light type "'+a.type+"” not supported")}}return!1},n.prototype.loadMaterialAsync=function(e,n,r,t){var o=e.materials[n];if(!o||!o.extensions)return!1;var i=o.extensions[this.name];if(!i)return!1;var a=new m.StandardMaterial(n,e.scene);return a.sideOrientation=m.Material.CounterClockWiseSideOrientation,"CONSTANT"===i.technique&&(a.disableLighting=!0),a.backFaceCulling=void 0!==i.doubleSided&&!i.doubleSided,a.alpha=void 0===i.values.transparency?1:i.values.transparency,a.specularPower=void 0===i.values.shininess?0:i.values.shininess,"string"==typeof i.values.ambient?this._loadTexture(e,i.values.ambient,a,"ambientTexture",t):a.ambientColor=m.Color3.FromArray(i.values.ambient||[0,0,0]),"string"==typeof i.values.diffuse?this._loadTexture(e,i.values.diffuse,a,"diffuseTexture",t):a.diffuseColor=m.Color3.FromArray(i.values.diffuse||[0,0,0]),"string"==typeof i.values.emission?this._loadTexture(e,i.values.emission,a,"emissiveTexture",t):a.emissiveColor=m.Color3.FromArray(i.values.emission||[0,0,0]),"string"==typeof i.values.specular?this._loadTexture(e,i.values.specular,a,"specularTexture",t):a.specularColor=m.Color3.FromArray(i.values.specular||[0,0,0]),!0},n.prototype._loadTexture=function(e,n,r,t,o){U.LoadTextureBufferAsync(e,n,(function(i){U.CreateTextureAsync(e,n,i,(function(e){return r[t]=e}),o)}),o)},n}(k);G.RegisterExtension(new H)},,,,function(e,n,r){"use strict";(function(e){var t=r(2),o=r(3);r.d(n,"a",(function(){return t.GLTFFileLoader})),r.d(n,"b",(function(){return t.GLTFLoaderAnimationStartMode})),r.d(n,"c",(function(){return t.GLTFLoaderCoordinateSystemMode})),r.d(n,"d",(function(){return t.GLTFLoaderState})),r.d(n,"e",(function(){return o.GLTFValidation}));var i=void 0!==e?e:"undefined"!=typeof window?window:void 0;if(void 0!==i){for(var a in i.BABYLON=i.BABYLON||{},t)i.BABYLON[a]=t[a];for(var a in o)i.BABYLON[a]=o[a]}}).call(this,r(4))},function(e,n,r){"use strict";(function(e){var t=r(7);r.d(n,"a",(function(){return t}));var o=void 0!==e?e:"undefined"!=typeof window?window:void 0;if(void 0!==o)for(var i in o.BABYLON=o.BABYLON||{},o.BABYLON.GLTF1=o.BABYLON.GLTF1||{},t)o.BABYLON.GLTF1[i]=t[i]}).call(this,r(4))},,,,function(e,n,r){"use strict";r.r(n);var t=r(11);r.d(n,"GLTFLoaderCoordinateSystemMode",(function(){return t.c})),r.d(n,"GLTFLoaderAnimationStartMode",(function(){return t.b})),r.d(n,"GLTFLoaderState",(function(){return t.d})),r.d(n,"GLTFFileLoader",(function(){return t.a})),r.d(n,"GLTFValidation",(function(){return t.e}));var o=r(12);r.d(n,"GLTF1",(function(){return o.a}))}])}));