babylon.glTF1FileLoader.min.js 54 KB

12345678910111213141516
  1. !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=17)}([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",h),l(e)},h=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",h),u(n.value);break;case"validate.reject":d.removeEventListener("error",p),d.removeEventListener("message",h),l(n.reason)}};d.addEventListener("error",p),d.addEventListener("message",h),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,r){"use strict";r.d(n,"b",(function(){return o})),r.d(n,"a",(function(){return i}));
  2. /*! *****************************************************************************
  3. Copyright (c) Microsoft Corporation.
  4. Permission to use, copy, modify, and/or distribute this software for any
  5. purpose with or without fee is hereby granted.
  6. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
  7. REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
  8. AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
  9. INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
  10. LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
  11. OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  12. PERFORMANCE OF THIS SOFTWARE.
  13. ***************************************************************************** */
  14. 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)Object.prototype.hasOwnProperty.call(n,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)}var i=function(){return(i=Object.assign||function(e){for(var n,r=1,t=arguments.length;r<t;r++)for(var o in n=arguments[r])Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o]);return e}).apply(this,arguments)};Object.create;Object.create},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 k})),r.d(n,"GLTFLoaderBase",(function(){return D})),r.d(n,"GLTFLoader",(function(){return U})),r.d(n,"GLTFLoaderExtension",(function(){return G})),r.d(n,"EComponentType",(function(){return t})),r.d(n,"EShaderType",(function(){return o})),r.d(n,"EParameterType",(function(){return i})),r.d(n,"ETextureWrapMode",(function(){return a})),r.d(n,"ETextureFilterType",(function(){return s})),r.d(n,"ETextureFormat",(function(){return u})),r.d(n,"ECullingType",(function(){return l})),r.d(n,"EBlendingFunction",(function(){return c})),r.d(n,"GLTFUtils",(function(){return h})),r.d(n,"GLTFMaterialsCommonExtension",(function(){return j}));var t,o,i,a,s,u,l,c,f=r(4);!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"}(t||(t={})),function(e){e[e.FRAGMENT=35632]="FRAGMENT",e[e.VERTEX=35633]="VERTEX"}(o||(o={})),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"}(i||(i={})),function(e){e[e.CLAMP_TO_EDGE=33071]="CLAMP_TO_EDGE",e[e.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",e[e.REPEAT=10497]="REPEAT"}(a||(a={})),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"}(s||(s={})),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"}(u||(u={})),function(e){e[e.FRONT=1028]="FRONT",e[e.BACK=1029]="BACK",e[e.FRONT_AND_BACK=1032]="FRONT_AND_BACK"}(l||(l={})),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"}(c||(c={}));var d,p=r(0),h=function(){function e(){}return e.SetMatrix=function(e,n,r,t,o){var a=null;if("MODEL"===r.semantic?a=n.getWorldMatrix():"PROJECTION"===r.semantic?a=e.getProjectionMatrix():"VIEW"===r.semantic?a=e.getViewMatrix():"MODELVIEWINVERSETRANSPOSE"===r.semantic?a=p.Matrix.Transpose(n.getWorldMatrix().multiply(e.getViewMatrix()).invert()):"MODELVIEW"===r.semantic?a=n.getWorldMatrix().multiply(e.getViewMatrix()):"MODELVIEWPROJECTION"===r.semantic?a=n.getWorldMatrix().multiply(e.getTransformMatrix()):"MODELINVERSE"===r.semantic?a=n.getWorldMatrix().invert():"VIEWINVERSE"===r.semantic?a=e.getViewMatrix().invert():"PROJECTIONINVERSE"===r.semantic?a=e.getProjectionMatrix().invert():"MODELVIEWINVERSE"===r.semantic?a=n.getWorldMatrix().multiply(e.getViewMatrix()).invert():"MODELVIEWPROJECTIONINVERSE"===r.semantic?a=n.getWorldMatrix().multiply(e.getTransformMatrix()).invert():"MODELINVERSETRANSPOSE"===r.semantic&&(a=p.Matrix.Transpose(n.getWorldMatrix().invert())),a)switch(r.type){case i.FLOAT_MAT2:o.setMatrix2x2(t,p.Matrix.GetAsMatrix2x2(a));break;case i.FLOAT_MAT3:o.setMatrix3x3(t,p.Matrix.GetAsMatrix3x3(a));break;case i.FLOAT_MAT4:o.setMatrix(t,a)}},e.SetUniform=function(e,n,r,t){switch(t){case i.FLOAT:return e.setFloat(n,r),!0;case i.FLOAT_VEC2:return e.setVector2(n,p.Vector2.FromArray(r)),!0;case i.FLOAT_VEC3:return e.setVector3(n,p.Vector3.FromArray(r)),!0;case i.FLOAT_VEC4:return e.setVector4(n,p.Vector4.FromArray(r)),!0;default:return!1}},e.GetWrapMode=function(e){switch(e){case a.CLAMP_TO_EDGE:return p.Texture.CLAMP_ADDRESSMODE;case a.MIRRORED_REPEAT:return p.Texture.MIRROR_ADDRESSMODE;case a.REPEAT:default:return p.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 s.LINEAR:case s.LINEAR_MIPMAP_NEAREST:case s.LINEAR_MIPMAP_LINEAR:return p.Texture.TRILINEAR_SAMPLINGMODE;case s.NEAREST:case s.NEAREST_MIPMAP_NEAREST:return p.Texture.NEAREST_SAMPLINGMODE;default:return p.Texture.BILINEAR_SAMPLINGMODE}},e.GetBufferFromBufferView=function(e,n,r,o,i){r=n.byteOffset+r;var a=e.loadedBufferViews[n.buffer];if(r+o>a.byteLength)throw new Error("Buffer access is out of range");var s=a.buffer;switch(r+=a.byteOffset,i){case t.BYTE:return new Int8Array(s,r,o);case t.UNSIGNED_BYTE:return new Uint8Array(s,r,o);case t.SHORT:return new Int16Array(s,r,o);case t.UNSIGNED_SHORT:return new Uint16Array(s,r,o);default:return new Float32Array(s,r,o)}},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){p.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"),p.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 p.ShaderMaterial("GLTFDefaultMaterial",n,{vertex:"GLTFDefaultMaterial",fragment:"GLTFDefaultMaterial"},r),e._DefaultMaterial.setColor4("u_emission",new p.Color4(.5,.5,.5,1))}return e._DefaultMaterial},e._DefaultMaterial=null,e}(),m=r(2);!function(e){e[e.IDENTIFIER=1]="IDENTIFIER",e[e.UNKNOWN=2]="UNKNOWN",e[e.END_OF_INPUT=3]="END_OF_INPUT"}(d||(d={}));var v=function(){function e(e){this._pos=0,this.currentToken=d.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 d.END_OF_INPUT;if(this.currentString=this.read(),this.currentToken=d.UNKNOWN,"_"===this.currentString||this.isLetterOrDigitPattern.test(this.currentString))for(this.currentToken=d.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}(),b=["MODEL","VIEW","PROJECTION","MODELVIEW","MODELVIEWPROJECTION","JOINTMATRIX"],y=["world","view","projection","worldView","worldViewProjection","mBones"],A=["translation","rotation","scale"],_=["position","rotationQuaternion","scaling"],O=function(e,n,r){for(var t in e){var o=e[t];r[n][t]=o}},E=function(e){if(e)for(var n=0;n<e.length/2;n++)e[2*n+1]=1-e[2*n+1]},g=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},L=function(e){var n=null;if(e.translation||e.rotation||e.scale){var r=p.Vector3.FromArray(e.scale||[1,1,1]),t=p.Quaternion.FromArray(e.rotation||[0,0,0,1]),o=p.Vector3.FromArray(e.translation||[0,0,0]);n=p.Matrix.Compose(r,t,o)}else n=p.Matrix.FromArray(e.matrix);return n},T=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=L(s),f=new p.Bone(s.name||"",t,T(e,n,s.jointName,t),c);return f.id=a,f}}}}return null},N=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},S=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},C=function(e,n){for(var r=0;r<e.jointNames.length;r++)if(e.jointNames[r]===n)return!0;return!1},M=function(e,n,r,t,o){if(t||(t=new p.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&&!C(r,i.jointName)){var s=L(i),u=new p.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 h=null,m=0;m<t.length;m++)if(t[m].id===f[d]){h=t[m];break}h&&(h.bone._parent=c.bone,c.bone.children.push(h.bone))}}(e,t,n,i),t.bones=[];for(var s=0;s<n.jointNames.length;s++){if(_=S(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 h=S(e,n.jointNames[d]);if(h){var m=h.node;if(m){var v=m.children;if(v){c=!1;for(var b=0;b<v.length;b++)if(v[b]===o){f=T(e,n,n.jointNames[d],t),c=!0;break}if(c)break}}else p.Tools.Warn("Joint named "+n.jointNames[d]+" does not exist when looking for parent")}}var y=L(u);!f&&i.length>0&&(f=N(i,o))&&-1===a.indexOf(f)&&a.push(f),new p.Bone(u.jointName||"",t,f,y).id=o}}else p.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(_=S(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},x=function(e,n,r,t,o){if(o||(e.scene._blockEntityCollection=e.forAssetContainer,o=new p.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 v=r[d];if(P=e.meshes[v])for(var b=0;b<P.primitives.length;b++){var y=new p.VertexData,A=P.primitives[b];A.mode;var _=A.attributes,O=null,g=null;for(var L in _)if(O=e.accessors[_[L]],g=h.GetBufferFromAccessor(e,O),"NORMAL"===L)y.normals=new Float32Array(g.length),y.normals.set(g);else if("POSITION"===L){if(m.GLTFFileLoader.HomogeneousCoordinates){y.positions=new Float32Array(g.length-g.length/4);for(var T=0;T<g.length;T+=4)y.positions[T]=g[T],y.positions[T+1]=g[T+1],y.positions[T+2]=g[T+2]}else y.positions=new Float32Array(g.length),y.positions.set(g);l.push(y.positions.length)}else if(-1!==L.indexOf("TEXCOORD_")){var N=Number(L.split("_")[1]),S=p.VertexBuffer.UVKind+(0===N?"":N+1),C=new Float32Array(g.length);C.set(g),E(C),y.set(C,S)}else"JOINT"===L?(y.matricesIndices=new Float32Array(g.length),y.matricesIndices.set(g)):"WEIGHT"===L?(y.matricesWeights=new Float32Array(g.length),y.matricesWeights.set(g)):"COLOR"===L&&(y.colors=new Float32Array(g.length),y.colors.set(g));if(O=e.accessors[A.indices])g=h.GetBufferFromAccessor(e,O),y.indices=new Int32Array(g.length),y.indices.set(g),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 p.MultiMaterial("multimat"+t,e.scene)).subMaterials=a:i=new p.StandardMaterial("multimat"+t,e.scene),1===a.length&&(i=a[0]),o.material||(o.material=i),new p.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;v=r[d];if(P=e.meshes[v])for(b=0;b<P.primitives.length;b++)P.primitives[b].mode,p.SubMesh.AddToMesh(R,u[R],l[R],c[R],f[R],o,o,!0),R++}return o},R=function(e,n,r,t){e.position&&(e.position=n),(e.rotationQuaternion||e.rotation)&&(e.rotationQuaternion=r),e.scaling&&(e.scaling=t)},P=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=x(e,n,n.meshes,r,n.babylonNode)).skeleton=e.scene.getLastSkeletonByID(n.skin),null===a.skeleton&&(a.skeleton=M(e,i,0,i.babylonSkeleton,n.skin),i.babylonSkeleton||(i.babylonSkeleton=a.skeleton)),o=a}}else if(n.meshes){var a;o=a=x(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 p.FreeCamera(n.camera,p.Vector3.Zero(),e.scene,!1);u.name=n.name||"",u.mode=p.Camera.ORTHOGRAPHIC_CAMERA,u.attachControl(e.scene.getEngine().getInputElement()),o=u}else if("perspective"===s.type){var l=s[s.type],c=new p.FreeCamera(n.camera,p.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],h=new p.HemisphericLight(n.light,p.Vector3.Zero(),e.scene);h.name=n.name||"",d.color&&(h.diffuse=p.Color3.FromArray(d.color)),o=h}else if("directional"===f.type){var m=f[f.type],v=new p.DirectionalLight(n.light,p.Vector3.Zero(),e.scene);v.name=n.name||"",m.color&&(v.diffuse=p.Color3.FromArray(m.color)),o=v}else if("point"===f.type){var b=f[f.type],y=new p.PointLight(n.light,p.Vector3.Zero(),e.scene);y.name=n.name||"",b.color&&(y.diffuse=p.Color3.FromArray(b.color)),o=y}else if("spot"===f.type){var A=f[f.type],_=new p.SpotLight(n.light,p.Vector3.Zero(),p.Vector3.Zero(),0,0,e.scene);_.name=n.name||"",A.color&&(_.diffuse=p.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 p.Mesh(n.name||"",e.scene);e.scene._blockEntityCollection=!1,n.babylonNode=O,o=O}}if(null!==o){if(n.matrix&&o instanceof p.Mesh)!function(e,n,r){if(n.matrix){var t=new p.Vector3(0,0,0),o=new p.Quaternion,i=new p.Vector3(0,0,0);p.Matrix.FromArray(n.matrix).decompose(i,o,t),R(e,t,o,i)}else n.translation&&n.rotation&&n.scale&&R(e,p.Vector3.FromArray(n.translation),p.Quaternion.FromArray(n.rotation),p.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];R(o,p.Vector3.FromArray(E),p.Quaternion.FromArray(g),p.Vector3.FromArray(L))}o.updateCache(!0),n.babylonNode=o}return o},w=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=P(e,o,n))&&(i.id=n,i.parent=r),o.children)for(var a=0;a<o.children.length;a++)w(e,o.children[a],i,t)},I=function(e){var n=e.currentScene;if(n)for(var r=0;r<n.nodes.length;r++)w(e,n.nodes[r],null);else for(var t in e.scenes){n=e.scenes[t];for(r=0;r<n.nodes.length;r++)w(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 m=d instanceof p.Bone,v=i.target.path,b=A.indexOf(v);-1!==b&&(v=_[b]);var y=p.Animation.ANIMATIONTYPE_MATRIX;m||("rotationQuaternion"===v?(y=p.Animation.ANIMATIONTYPE_QUATERNION,d.rotationQuaternion=new p.Quaternion):y=p.Animation.ANIMATIONTYPE_VECTOR3);var O=null,E=[],g=0,L=!1;m&&t&&t.getKeys().length===l.length&&(O=t,L=!0),L||(e.scene._blockEntityCollection=e.forAssetContainer,O=new p.Animation(n,m?"_matrix":v,1,y,p.Animation.ANIMATIONLOOPMODE_CYCLE),e.scene._blockEntityCollection=!1);for(var T=0;T<l.length;T++){var N=null;if("rotationQuaternion"===v?(N=p.Quaternion.FromArray([c[g],c[g+1],c[g+2],c[g+3]]),g+=4):(N=p.Vector3.FromArray([c[g],c[g+1],c[g+2]]),g+=3),m){var S=d,C=p.Vector3.Zero(),M=new p.Quaternion,x=p.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=p.Matrix.Compose(x,M,C)}L?t&&(t.getKeys()[T].value=N):E.push({frame:l[T],value:N})}!L&&O&&(O.setKeys(E),d.animations.push(O)),t=O,e.scene.stopAnimation(d),e.scene.beginAnimation(d,0,l[l.length-1],!0,1)}else p.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)}},F=function(e,n,r,t,o,a){return function(s){!function(e,n,r,t,o){var a=t.values||r.parameters,s=r.uniforms;for(var u in o){var l=o[u],c=l.type,f=a[s[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===i.SAMPLER_2D?G.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(s){!function(e,n,r,t,o,a,s){var u=a.values||o.parameters;for(var l in r){var c=r[l],f=c.type;if(f===i.FLOAT_MAT2||f===i.FLOAT_MAT3||f===i.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===i.SAMPLER_2D){var m=n.textures[a.values?p:c.value].babylonTexture;if(null==m)continue;t.getEffect().setTexture(l,m)}else h.SetUniform(t.getEffect(),l,p,f)}}s(t)}(s,e,o,n,r,t,a)}}},B=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=b.indexOf(i.semantic);if(-1!==a)return delete r[t],y[a]}}return e.currentIdentifier},V=function(e){for(var n in e.materials)G.LoadMaterialAsync(e,n,(function(e){}),(function(){}))},D=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&&O(e.extensions,"extensions",t),e.extensionsUsed&&O(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&&O(e.bufferViews,"bufferViews",t),e.accessors&&O(e.accessors,"accessors",t),e.meshes&&O(e.meshes,"meshes",t),e.lights&&O(e.lights,"lights",t),e.cameras&&O(e.cameras,"cameras",t),e.nodes&&O(e.nodes,"nodes",t),e.images&&O(e.images,"images",t),e.textures&&O(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&&O(e.programs,"programs",t),e.samplers&&O(e.samplers,"samplers",t),e.techniques&&O(e.techniques,"techniques",t),e.materials&&O(e.materials,"materials",t),e.animations&&O(e.animations,"animations",t),e.skins&&O(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];p.Tools.IsBase64(i.uri)?setTimeout((function(){return r(new Uint8Array(p.Tools.DecodeBase64(i.uri)))})):p.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];p.Tools.IsBase64(i.uri)?setTimeout((function(){return r(new Uint8Array(p.Tools.DecodeBase64(i.uri)))})):p.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],u=a.minFilter===s.NEAREST_MIPMAP_NEAREST||a.minFilter===s.NEAREST_MIPMAP_LINEAR||a.minFilter===s.LINEAR_MIPMAP_NEAREST||a.minFilter===s.LINEAR_MIPMAP_LINEAR,l=p.Texture.BILINEAR_SAMPLINGMODE,c=null==r?new Blob:new Blob([r]),f=URL.createObjectURL(c),d=function(){return URL.revokeObjectURL(f)},m=new p.Texture(f,e.scene,!u,!0,l,d,d);void 0!==a.wrapS&&(m.wrapU=h.GetWrapMode(a.wrapS)),void 0!==a.wrapT&&(m.wrapV=h.GetWrapMode(a.wrapT)),m.name=n,i.babylonTexture=m,t(m)}},e.LoadShaderStringAsync=function(e,n,r,t){var o=e.shaders[n];if(p.Tools.IsBase64(o.uri)){var i=atob(o.uri.split(",")[1]);r&&r(i)}else p.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 a=e.techniques[o.technique];if(!a){e.scene._blockEntityCollection=e.forAssetContainer;var s=new p.StandardMaterial(n,e.scene);return e.scene._blockEntityCollection=!1,s.diffuseColor=new p.Color3(.5,.5,.5),s.sideOrientation=p.Material.CounterClockWiseSideOrientation,void r(s)}var u=e.programs[a.program],f=a.states,h=p.Effect.ShadersStore[u.vertexShader+"VertexShader"],m=p.Effect.ShadersStore[u.fragmentShader+"PixelShader"],A="",_="",O=new v(h),E=new v(m),L={},T=[],N=[],S=[];for(var C in a.uniforms){var M=a.uniforms[C],x=a.parameters[M];if(L[C]=x,!x.semantic||x.node||x.source)x.type===i.SAMPLER_2D?S.push(C):T.push(C);else{var R=b.indexOf(x.semantic);-1!==R?(T.push(y[R]),delete L[C]):T.push(C)}}for(var P in a.attributes){var w=a.attributes[P];if((D=a.parameters[w]).semantic){var I=g(D);I&&N.push(I)}}for(;!O.isEnd()&&O.getNextToken();){if(O.currentToken===d.IDENTIFIER){var V=!1;for(var P in a.attributes){w=a.attributes[P];var D=a.parameters[w];if(O.currentIdentifier===P&&D.semantic){A+=g(D),V=!0;break}}V||(A+=B(O,a,L))}else A+=O.currentString}for(;!E.isEnd()&&E.getNextToken();){E.currentToken===d.IDENTIFIER?_+=B(E,a,L):_+=E.currentString}var U={vertex:u.vertexShader+n,fragment:u.fragmentShader+n},G={attributes:N,uniforms:T,samplers:S,needAlphaBlending:f&&f.enable&&-1!==f.enable.indexOf(3042)};p.Effect.ShadersStore[u.vertexShader+n+"VertexShader"]=A,p.Effect.ShadersStore[u.fragmentShader+n+"PixelShader"]=_;var k=new p.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=F(e,k,a,o,L,r),k.sideOrientation=p.Material.CounterClockWiseSideOrientation,f&&f.functions){var j=f.functions;j.cullFace&&j.cullFace[0]!==l.BACK&&(k.backFaceCulling=!1);var H=j.blendFuncSeparate;H&&(H[0]===c.SRC_ALPHA&&H[1]===c.ONE_MINUS_SRC_ALPHA&&H[2]===c.ONE&&H[3]===c.ONE?k.alphaMode=p.Constants.ALPHA_COMBINE:H[0]===c.ONE&&H[1]===c.ONE&&H[2]===c.ZERO&&H[3]===c.ONE?k.alphaMode=p.Constants.ALPHA_ONEONE:H[0]===c.SRC_ALPHA&&H[1]===c.ONE&&H[2]===c.ZERO&&H[3]===c.ONE?k.alphaMode=p.Constants.ALPHA_ADD:H[0]===c.ZERO&&H[1]===c.ONE_MINUS_SRC_COLOR&&H[2]===c.ONE&&H[3]===c.ONE?k.alphaMode=p.Constants.ALPHA_SUBTRACT:H[0]===c.DST_COLOR&&H[1]===c.ZERO&&H[2]===c.ONE&&H[3]===c.ONE?k.alphaMode=p.Constants.ALPHA_MULTIPLY:H[0]===c.SRC_ALPHA&&H[1]===c.ONE_MINUS_SRC_COLOR&&H[2]===c.ONE&&H[3]===c.ONE&&(k.alphaMode=p.Constants.ALPHA_MAXIMIZED))}}else t&&t("No technique found.")},e}(),U=function(){function e(){this.state=null}return e.RegisterExtension=function(n){e.Extensions[n.name]?p.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,G.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=[],p.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 p.AbstractMesh&&r.push(l.babylonNode)}for(var c in n.skins){var f=n.skins[c];f.babylonSkeleton instanceof p.Skeleton&&t.push(f.babylonSkeleton)}u._loadBuffersAsync(n,(function(){u._loadShadersAsync(n,(function(){V(n),I(n),!m.GLTFFileLoader.IncrementalLoading&&i&&i(r,t)}))}),a),m.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,G.LoadRuntimeAsync(e,n,r,(function(e){G.LoadRuntimeExtensionsAsync(e,(function(){s._createNodes(e),s._loadBuffersAsync(e,(function(){s._loadShadersAsync(e,(function(){V(e),I(e),m.GLTFFileLoader.IncrementalLoading||o()}))})),m.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){G.LoadShaderStringAsync(e,r,(function(i){i instanceof ArrayBuffer||(e.loadedShaderCount++,i&&(p.Effect.ShadersStore[r+(t.type===o.VERTEX?"VertexShader":"PixelShader")]=i),e.loadedShaderCount===e.shaderscount&&n())}),(function(){p.Tools.Error("Error when loading shader program named "+r+" located at "+t.uri)}))};for(var i in e.shaders){r=!0;var a=e.shaders[i];a?t.bind(this,i,a)():p.Tools.Error("No shader named: "+i)}r||n()},e.prototype._loadBuffersAsync=function(e,n,r){var t=!1,o=function(r,t){G.LoadBufferAsync(e,r,(function(o){e.loadedBufferCount++,o&&(o.byteLength!=e.buffers[r].byteLength&&p.Tools.Error("Buffer named "+r+" is length "+o.byteLength+". Expected: "+t.byteLength),e.loadedBufferViews[r]=o),e.loadedBufferCount===e.buffersCount&&n()}),(function(){p.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)():p.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++)w(e,n.nodes[r],null);else for(var t in e.scenes){n=e.scenes[t];for(r=0;r<n.nodes.length;r++)w(e,n.nodes[r],null)}},e.Extensions={},e}(),G=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(D.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(){D.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(){D.LoadShaderStringAsync(n,r,t,o)}))},e.LoadMaterialAsync=function(n,r,t,o){e.ApplyExtensions((function(e){return e.loadMaterialAsync(n,r,t,o)}),(function(){D.LoadMaterialAsync(n,r,t,o)}))},e.LoadTextureBufferAsync=function(n,r,t,o){e.ApplyExtensions((function(e){return e.loadTextureBufferAsync(n,r,t,o)}),(function(){D.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(){D.CreateTextureAsync(n,r,t,o,i)}))},e.ApplyExtensions=function(e,n){for(var r in U.Extensions){if(e(U.Extensions[r]))return}n()},e}();m.GLTFFileLoader._CreateGLTF1Loader=function(){return new U};var k=function(e){function n(){return e.call(this,"KHR_binary_glTF")||this}return Object(f.b)(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(D.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,o){var i=e.textures[n],a=e.images[i.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,t.UNSIGNED_BYTE)),!0},n.prototype.loadShaderStringAsync=function(e,n,r,o){var i=e.shaders[n];if(!i.extensions||!(this.name in i.extensions))return!1;var a=i.extensions[this.name],s=e.bufferViews[a.bufferView],u=h.GetBufferFromBufferView(e,s,0,s.byteLength,t.UNSIGNED_BYTE);return setTimeout((function(){var e=h.DecodeBufferToText(u);r(e)})),!0},n}(G);U.RegisterExtension(new k);var j=function(e){function n(){return e.call(this,"KHR_materials_common")||this}return Object(f.b)(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 p.HemisphericLight(a.name,new p.Vector3(0,1,0),e.scene),u=a.ambient;u&&(s.diffuse=p.Color3.FromArray(u.color||[1,1,1]));break;case"point":var l=new p.PointLight(a.name,new p.Vector3(10,10,10),e.scene),c=a.point;c&&(l.diffuse=p.Color3.FromArray(c.color||[1,1,1]));break;case"directional":var f=new p.DirectionalLight(a.name,new p.Vector3(0,-1,0),e.scene),d=a.directional;d&&(f.diffuse=p.Color3.FromArray(d.color||[1,1,1]));break;case"spot":var h=a.spot;if(h)new p.SpotLight(a.name,new p.Vector3(0,10,0),new p.Vector3(0,-1,0),h.fallOffAngle||Math.PI,h.fallOffExponent||0,e.scene).diffuse=p.Color3.FromArray(h.color||[1,1,1]);break;default:p.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 p.StandardMaterial(n,e.scene);return a.sideOrientation=p.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=p.Color3.FromArray(i.values.ambient||[0,0,0]),"string"==typeof i.values.diffuse?this._loadTexture(e,i.values.diffuse,a,"diffuseTexture",t):a.diffuseColor=p.Color3.FromArray(i.values.diffuse||[0,0,0]),"string"==typeof i.values.emission?this._loadTexture(e,i.values.emission,a,"emissiveTexture",t):a.emissiveColor=p.Color3.FromArray(i.values.emission||[0,0,0]),"string"==typeof i.values.specular?this._loadTexture(e,i.values.specular,a,"specularTexture",t):a.specularColor=p.Color3.FromArray(i.values.specular||[0,0,0]),!0},n.prototype._loadTexture=function(e,n,r,t,o){D.LoadTextureBufferAsync(e,n,(function(i){D.CreateTextureAsync(e,n,i,(function(e){return r[t]=e}),o)}),o)},n}(G);U.RegisterExtension(new j)},,,,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(5))},function(e,n,r){"use strict";(function(e){var t=r(8);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(5))},,,,function(e,n,r){"use strict";r.r(n);var t=r(12);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(13);r.d(n,"GLTF1",(function(){return o.a}))}])}));