babylonjs-loaders 8.47.0 → 8.47.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/babylon.glTF1FileLoader.js +1 -1
- package/babylon.glTF1FileLoader.min.js +1 -1
- package/babylon.glTF1FileLoader.min.js.map +1 -1
- package/babylon.glTF2FileLoader.js +1 -1
- package/babylon.glTF2FileLoader.min.js +1 -1
- package/babylon.glTF2FileLoader.min.js.map +1 -1
- package/babylon.glTFFileLoader.js +1 -1
- package/babylon.glTFFileLoader.min.js +1 -1
- package/babylon.glTFFileLoader.min.js.map +1 -1
- package/babylonjs.loaders.d.ts +290 -28
- package/babylonjs.loaders.js +1 -1
- package/babylonjs.loaders.min.js +1 -1
- package/babylonjs.loaders.min.js.map +1 -1
- package/babylonjs.loaders.module.d.ts +587 -56
- package/package.json +4 -4
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("babylonjs")):"function"==typeof define&&define.amd?define("babylonjs-loaders",["babylonjs"],t):"object"==typeof exports?exports["babylonjs-loaders"]=t(require("babylonjs")):e.LOADERS=t(e.BABYLON)}("undefined"!=typeof self?self:"undefined"!=typeof global?global:this,(e=>(()=>{"use strict";var t={597:t=>{t.exports=e}},n={};function r(e){var o=n[e];if(void 0!==o)return o.exports;var a=n[e]={exports:{}};return t[e](a,a.exports,r),a.exports}r.d=(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var o={};r.d(o,{default:()=>de});var a={};r.r(a),r.d(a,{GLTFValidation:()=>y});var i={};r.r(i),r.d(i,{GLTFFileLoader:()=>T,GLTFLoaderAnimationStartMode:()=>v,GLTFLoaderCoordinateSystemMode:()=>m,GLTFLoaderDefaultOptions:()=>L,GLTFLoaderState:()=>b});var s={};r.r(s),r.d(s,{EBlendingFunction:()=>P,EComponentType:()=>N,ECullingType:()=>w,EParameterType:()=>C,EShaderType:()=>S,ETextureFilterType:()=>x,ETextureFormat:()=>R,ETextureWrapMode:()=>M,GLTFBinaryExtension:()=>se,GLTFLoader:()=>ae,GLTFLoaderBase:()=>oe,GLTFLoaderExtension:()=>ie,GLTFMaterialsCommonExtension:()=>le,GLTFUtils:()=>V});var l={};r.r(l),r.d(l,{GLTF1:()=>s,GLTFFileLoader:()=>T,GLTFLoaderAnimationStartMode:()=>v,GLTFLoaderCoordinateSystemMode:()=>m,GLTFLoaderDefaultOptions:()=>L,GLTFLoaderState:()=>b,GLTFValidation:()=>y});var u=function(e,t){return u=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},u(e,t)};function c(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}u(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}var d=function(){return d=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},d.apply(this,arguments)};Object.create,Object.create,"function"==typeof SuppressedError&&SuppressedError;var f=r(597);function p(e,t,n,r){var o={externalResourceFunction:r};return n&&(o.uri="file:"===t?n:t+n),ArrayBuffer.isView(e)?GLTFValidator.validateBytes(e,o):GLTFValidator.validateString(e,o)}function h(){var e=[];onmessage=function(t){var n=t.data;switch(n.id){case"init":importScripts(n.url);break;case"validate":p(n.data,n.rootUrl,n.fileName,(function(t){return new Promise((function(n,r){var o=e.length;e.push({resolve:n,reject:r}),postMessage({id:"getExternalResource",index:o,uri:t})}))})).then((function(e){postMessage({id:"validate.resolve",value:e})}),(function(e){postMessage({id:"validate.reject",reason:e})}));break;case"getExternalResource.resolve":e[n.index].resolve(n.value);break;case"getExternalResource.reject":e[n.index].reject(n.reason)}}}var m,v,b,y=function(){function e(){}return e.ValidateAsync=function(e,t,n,r){var o=this;return"function"==typeof Worker?new Promise((function(a,i){var s="".concat(p,"(").concat(h,")()"),l=URL.createObjectURL(new Blob([s],{type:"application/javascript"})),u=new Worker(l),c=function(e){u.removeEventListener("error",c),u.removeEventListener("message",d),i(e)},d=function(e){var t=e.data;switch(t.id){case"getExternalResource":r(t.uri).then((function(e){u.postMessage({id:"getExternalResource.resolve",index:t.index,value:e},[e.buffer])}),(function(e){u.postMessage({id:"getExternalResource.reject",index:t.index,reason:e})}));break;case"validate.resolve":u.removeEventListener("error",c),u.removeEventListener("message",d),a(t.value),u.terminate();break;case"validate.reject":u.removeEventListener("error",c),u.removeEventListener("message",d),i(t.reason),u.terminate()}};if(u.addEventListener("error",c),u.addEventListener("message",d),u.postMessage({id:"init",url:f.Tools.GetBabylonScriptURL(o.Configuration.url)}),ArrayBuffer.isView(e)){var m=e.slice();u.postMessage({id:"validate",data:m,rootUrl:t,fileName:n},[m.buffer])}else u.postMessage({id:"validate",data:e,rootUrl:t,fileName:n})})):(this._LoadScriptPromise||(this._LoadScriptPromise=f.Tools.LoadBabylonScriptAsync(this.Configuration.url)),this._LoadScriptPromise.then((function(){return p(e,t,n,r)})))},e.Configuration={url:"".concat(f.Tools._DefaultCdnUrl,"/gltf_validator.js")},e}(),A="Z2xURg",_="gltf",g={".gltf":{isBinary:!1,mimeType:"model/gltf+json"},".glb":{isBinary:!0,mimeType:"model/gltf-binary"}};function O(e,t,n){try{return Promise.resolve(new Uint8Array(e,t,n))}catch(e){return Promise.reject(e)}}!function(e){e[e.AUTO=0]="AUTO",e[e.FORCE_RIGHT_HANDED=1]="FORCE_RIGHT_HANDED"}(m||(m={})),function(e){e[e.NONE=0]="NONE",e[e.FIRST=1]="FIRST",e[e.ALL=2]="ALL"}(v||(v={})),function(e){e[e.LOADING=0]="LOADING",e[e.READY=1]="READY",e[e.COMPLETE=2]="COMPLETE"}(b||(b={}));var E=function(){this.alwaysComputeBoundingBox=!1,this.alwaysComputeSkeletonRootNode=!1,this.animationStartMode=v.FIRST,this.compileMaterials=!1,this.compileShadowGenerators=!1,this.coordinateSystemMode=m.AUTO,this.createInstances=!0,this.loadAllMaterials=!1,this.loadMorphTargets=!0,this.loadNodeAnimations=!0,this.loadOnlyMaterials=!1,this.loadSkins=!0,this.skipMaterials=!1,this.targetFps=60,this.transparencyAsCoverage=!1,this.useClipPlane=!1,this.useGltfTextureNames=!1,this.useRangeRequests=!1,this.useSRGBBuffers=!0,this.validate=!1,this.useOpenPBR=!1,this.dontUseTransmissionHelper=!1},L=new E,T=function(e){function t(t){var n=e.call(this)||this;return n.onParsedObservable=new f.Observable,n.onMeshLoadedObservable=new f.Observable,n.onSkinLoadedObservable=new f.Observable,n.onTextureLoadedObservable=new f.Observable,n.onMaterialLoadedObservable=new f.Observable,n.onCameraLoadedObservable=new f.Observable,n.onCompleteObservable=new f.Observable,n.onErrorObservable=new f.Observable,n.onDisposeObservable=new f.Observable,n.onExtensionLoadedObservable=new f.Observable,n.onValidatedObservable=new f.Observable,n._loader=null,n._state=null,n._requests=new Array,n.name=_,n.extensions=g,n.onLoaderStateChangedObservable=new f.Observable,n._logIndentLevel=0,n._loggingEnabled=!1,n._log=n._logDisabled,n._capturePerformanceCounters=!1,n._startPerformanceCounter=n._startPerformanceCounterDisabled,n._endPerformanceCounter=n._endPerformanceCounterDisabled,n.copyFrom(Object.assign(d({},L),t)),n}return c(t,e),Object.defineProperty(t.prototype,"onParsed",{set:function(e){this._onParsedObserver&&this.onParsedObservable.remove(this._onParsedObserver),e&&(this._onParsedObserver=this.onParsedObservable.add(e))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"onMeshLoaded",{set:function(e){this._onMeshLoadedObserver&&this.onMeshLoadedObservable.remove(this._onMeshLoadedObserver),e&&(this._onMeshLoadedObserver=this.onMeshLoadedObservable.add(e))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"onSkinLoaded",{set:function(e){this._onSkinLoadedObserver&&this.onSkinLoadedObservable.remove(this._onSkinLoadedObserver),e&&(this._onSkinLoadedObserver=this.onSkinLoadedObservable.add((function(t){return e(t.node,t.skinnedNode)})))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"onTextureLoaded",{set:function(e){this._onTextureLoadedObserver&&this.onTextureLoadedObservable.remove(this._onTextureLoadedObserver),e&&(this._onTextureLoadedObserver=this.onTextureLoadedObservable.add(e))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"onMaterialLoaded",{set:function(e){this._onMaterialLoadedObserver&&this.onMaterialLoadedObservable.remove(this._onMaterialLoadedObserver),e&&(this._onMaterialLoadedObserver=this.onMaterialLoadedObservable.add(e))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"onCameraLoaded",{set:function(e){this._onCameraLoadedObserver&&this.onCameraLoadedObservable.remove(this._onCameraLoadedObserver),e&&(this._onCameraLoadedObserver=this.onCameraLoadedObservable.add(e))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"onComplete",{set:function(e){this._onCompleteObserver&&this.onCompleteObservable.remove(this._onCompleteObserver),this._onCompleteObserver=this.onCompleteObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"onError",{set:function(e){this._onErrorObserver&&this.onErrorObservable.remove(this._onErrorObserver),this._onErrorObserver=this.onErrorObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"onDispose",{set:function(e){this._onDisposeObserver&&this.onDisposeObservable.remove(this._onDisposeObserver),this._onDisposeObserver=this.onDisposeObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"onExtensionLoaded",{set:function(e){this._onExtensionLoadedObserver&&this.onExtensionLoadedObservable.remove(this._onExtensionLoadedObserver),this._onExtensionLoadedObserver=this.onExtensionLoadedObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.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(t.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(t.prototype,"onValidated",{set:function(e){this._onValidatedObserver&&this.onValidatedObservable.remove(this._onValidatedObserver),this._onValidatedObserver=this.onValidatedObservable.add(e)},enumerable:!1,configurable:!0}),t.prototype.dispose=function(){this._loader&&(this._loader.dispose(),this._loader=null);for(var e=0,t=this._requests;e<t.length;e++)t[e].abort();this._requests.length=0,delete this._progressCallback,this.preprocessUrlAsync=function(e){return Promise.resolve(e)},this.onMeshLoadedObservable.clear(),this.onSkinLoadedObservable.clear(),this.onTextureLoadedObservable.clear(),this.onMaterialLoadedObservable.clear(),this.onCameraLoadedObservable.clear(),this.onCompleteObservable.clear(),this.onExtensionLoadedObservable.clear(),this.onDisposeObservable.notifyObservers(void 0),this.onDisposeObservable.clear()},t.prototype.loadFile=function(e,t,n,r,o,a,i,s){var l=this;if(ArrayBuffer.isView(t))return this._loadBinary(e,t,n,r,i,s),null;this._progressCallback=o;var u=t.name||f.Tools.GetFilename(t);if(a){if(this.useRangeRequests){this.validate&&f.Logger.Warn("glTF validation is not supported when range requests are enabled");var c={abort:function(){},onCompleteObservable:new f.Observable},d={readAsync:function(n,r){return new Promise((function(o,a){l._loadFile(e,t,(function(e){o(new Uint8Array(e))}),!0,(function(e){a(e)}),(function(e){e.setRequestHeader("Range","bytes=".concat(n,"-").concat(n+r-1))}))}))},byteLength:0};return this._unpackBinaryAsync(new f.DataReader(d)).then((function(e){c.onCompleteObservable.notifyObservers(c),r(e)}),i?function(e){return i(void 0,e)}:void 0),c}return this._loadFile(e,t,(function(t){l._validate(e,new Uint8Array(t,0,t.byteLength),n,u),l._unpackBinaryAsync(new f.DataReader({readAsync:function(e,n){return O(t,e,n)},byteLength:t.byteLength})).then((function(e){r(e)}),i?function(e){return i(void 0,e)}:void 0)}),!0,i)}return this._loadFile(e,t,(function(t){try{l._validate(e,t,n,u),r({json:l._parseJson(t)})}catch(e){i&&i()}}),!1,i)},t.prototype._loadBinary=function(e,t,n,r,o,a){this._validate(e,new Uint8Array(t.buffer,t.byteOffset,t.byteLength),n,a),this._unpackBinaryAsync(new f.DataReader({readAsync:function(e,n){return function(e,t,n){try{if(t<0||t>=e.byteLength)throw new RangeError("Offset is out of range.");if(t+n>e.byteLength)throw new RangeError("Length is out of range.");return Promise.resolve(new Uint8Array(e.buffer,e.byteOffset+t,n))}catch(e){return Promise.reject(e)}}(t,e,n)},byteLength:t.byteLength})).then((function(e){r(e)}),o?function(e){return o(void 0,e)}:void 0)},t.prototype.importMeshAsync=function(e,t,n,r,o,a){var i=this;return Promise.resolve().then((function(){return i.onParsedObservable.notifyObservers(n),i.onParsedObservable.clear(),i._log("Loading ".concat(a||"")),i._loader=i._getLoader(n),i._loader.importMeshAsync(e,t,null,n,r,o,a)}))},t.prototype.loadAsync=function(e,t,n,r,o){var a=this;return Promise.resolve().then((function(){return a.onParsedObservable.notifyObservers(t),a.onParsedObservable.clear(),a._log("Loading ".concat(o||"")),a._loader=a._getLoader(t),a._loader.loadAsync(e,t,n,r,o)}))},t.prototype.loadAssetContainerAsync=function(e,t,n,r,o){var a=this;return Promise.resolve().then((function(){a.onParsedObservable.notifyObservers(t),a.onParsedObservable.clear(),a._log("Loading ".concat(o||"")),a._loader=a._getLoader(t);var i=new f.AssetContainer(e),s=[];a.onMaterialLoadedObservable.add((function(e){s.push(e)}));var l=[];a.onTextureLoadedObservable.add((function(e){l.push(e)}));var u=[];a.onCameraLoadedObservable.add((function(e){u.push(e)}));var c=[];return a.onMeshLoadedObservable.add((function(e){e.morphTargetManager&&c.push(e.morphTargetManager)})),a._loader.importMeshAsync(null,e,i,t,n,r,o).then((function(e){return Array.prototype.push.apply(i.geometries,e.geometries),Array.prototype.push.apply(i.meshes,e.meshes),Array.prototype.push.apply(i.particleSystems,e.particleSystems),Array.prototype.push.apply(i.skeletons,e.skeletons),Array.prototype.push.apply(i.animationGroups,e.animationGroups),Array.prototype.push.apply(i.materials,s),Array.prototype.push.apply(i.textures,l),Array.prototype.push.apply(i.lights,e.lights),Array.prototype.push.apply(i.transformNodes,e.transformNodes),Array.prototype.push.apply(i.cameras,u),Array.prototype.push.apply(i.morphTargetManagers,c),i}))}))},t.prototype.canDirectLoad=function(e){return function(e){return-1!==e.indexOf("asset")&&-1!==e.indexOf("version")||e.startsWith("data:base64,"+A)||e.startsWith("data:;base64,"+A)||e.startsWith("data:application/octet-stream;base64,"+A)||e.startsWith("data:model/gltf-binary;base64,"+A)}(e)},t.prototype.directLoad=function(e,t){if(t.startsWith("base64,"+A)||t.startsWith(";base64,"+A)||t.startsWith("application/octet-stream;base64,"+A)||t.startsWith("model/gltf-binary;base64,"+A)){var n=(0,f.DecodeBase64UrlToBinary)(t);return this._validate(e,new Uint8Array(n,0,n.byteLength)),this._unpackBinaryAsync(new f.DataReader({readAsync:function(e,t){return O(n,e,t)},byteLength:n.byteLength}))}return this._validate(e,t),Promise.resolve({json:this._parseJson(t)})},t.prototype.createPlugin=function(e){return new t(e[_])},Object.defineProperty(t.prototype,"loaderState",{get:function(){return this._state},enumerable:!1,configurable:!0}),t.prototype.whenCompleteAsync=function(){var e=this;return new Promise((function(t,n){e.onCompleteObservable.addOnce((function(){t()})),e.onErrorObservable.addOnce((function(e){n(e)}))}))},t.prototype._setState=function(e){this._state!==e&&(this._state=e,this.onLoaderStateChangedObservable.notifyObservers(this._state),this._log(b[this._state]))},t.prototype._loadFile=function(e,t,n,r,o,a){var i=this,s=e._loadFile(t,n,(function(e){i._onProgress(e,s)}),!0,r,o,a);return s.onCompleteObservable.add((function(){s._lengthComputable=!0,s._total=s._loaded})),this._requests.push(s),s},t.prototype._onProgress=function(e,t){if(this._progressCallback){t._lengthComputable=e.lengthComputable,t._loaded=e.loaded,t._total=e.total;for(var n=!0,r=0,o=0,a=0,i=this._requests;a<i.length;a++){var s=i[a];if(void 0===s._lengthComputable||void 0===s._loaded||void 0===s._total)return;n=n&&s._lengthComputable,r+=s._loaded,o+=s._total}this._progressCallback({lengthComputable:n,loaded:r,total:n?o:0})}},t.prototype._validate=function(e,t,n,r){var o=this;void 0===n&&(n=""),void 0===r&&(r=""),this.validate&&(this._startPerformanceCounter("Validate JSON"),y.ValidateAsync(t,n,r,(function(t){return o.preprocessUrlAsync(n+t).then((function(t){return e._loadFileAsync(t,void 0,!0,!0).then((function(e){return new Uint8Array(e,0,e.byteLength)}))}))})).then((function(e){o._endPerformanceCounter("Validate JSON"),o.onValidatedObservable.notifyObservers(e),o.onValidatedObservable.clear()}),(function(e){o._endPerformanceCounter("Validate JSON"),f.Tools.Warn("Failed to validate: ".concat(e.message)),o.onValidatedObservable.clear()})))},t.prototype._getLoader=function(e){var n=e.json.asset||{};this._log("Asset version: ".concat(n.version)),n.minVersion&&this._log("Asset minimum version: ".concat(n.minVersion)),n.generator&&this._log("Asset generator: ".concat(n.generator));var r=t._parseVersion(n.version);if(!r)throw new Error("Invalid version: "+n.version);if(void 0!==n.minVersion){var o=t._parseVersion(n.minVersion);if(!o)throw new Error("Invalid minimum version: "+n.minVersion);if(t._compareVersion(o,{major:2,minor:0})>0)throw new Error("Incompatible minimum version: "+n.minVersion)}var a={1:t._CreateGLTF1Loader,2:t._CreateGLTF2Loader}[r.major];if(!a)throw new Error("Unsupported version: "+n.version);return a(this)},t.prototype._parseJson=function(e){this._startPerformanceCounter("Parse JSON"),this._log("JSON length: ".concat(e.length));var t=JSON.parse(e);return this._endPerformanceCounter("Parse JSON"),t},t.prototype._unpackBinaryAsync=function(e){var t=this;return this._startPerformanceCounter("Unpack Binary"),e.loadAsync(20).then((function(){var n=e.readUint32();if(1179937895!==n)throw new f.RuntimeError("Unexpected magic: "+n,f.ErrorCodes.GLTFLoaderUnexpectedMagicError);var r=e.readUint32();t.loggingEnabled&&t._log("Binary version: ".concat(r));var o,a=e.readUint32();switch(t.useRangeRequests||a===e.buffer.byteLength||f.Logger.Warn("Length in header does not match actual data length: ".concat(a," != ").concat(e.buffer.byteLength)),r){case 1:o=t._unpackBinaryV1Async(e,a);break;case 2:o=t._unpackBinaryV2Async(e,a);break;default:throw new Error("Unsupported version: "+r)}return t._endPerformanceCounter("Unpack Binary"),o}))},t.prototype._unpackBinaryV1Async=function(e,t){var n=e.readUint32(),r=e.readUint32();if(0!==r)throw new Error("Unexpected content format: ".concat(r));var o=t-e.byteOffset,a={json:this._parseJson(e.readString(n)),bin:null};if(0!==o){var i=e.byteOffset;a.bin={readAsync:function(t,n){return e.buffer.readAsync(i+t,n)},byteLength:o}}return Promise.resolve(a)},t.prototype._unpackBinaryV2Async=function(e,t){var n=this,r=1313821514,o=e.readUint32();if(e.readUint32()!==r)throw new Error("First chunk format is not JSON");return e.byteOffset+o===t?e.loadAsync(o).then((function(){return{json:n._parseJson(e.readString(o)),bin:null}})):e.loadAsync(o+8).then((function(){var a={json:n._parseJson(e.readString(o)),bin:null},i=function(){var n=e.readUint32();switch(e.readUint32()){case r:throw new Error("Unexpected JSON chunk");case 5130562:var o=e.byteOffset;a.bin={readAsync:function(t,n){return e.buffer.readAsync(o+t,n)},byteLength:n},e.skipBytes(n);break;default:e.skipBytes(n)}return e.byteOffset!==t?e.loadAsync(8).then(i):Promise.resolve(a)};return i()}))},t._parseVersion=function(e){if("1.0"===e||"1.0.1"===e)return{major:1,minor:0};var t=(e+"").match(/^(\d+)\.(\d+)/);return t?{major:parseInt(t[1]),minor:parseInt(t[2])}:null},t._compareVersion=function(e,t){return e.major>t.major?1:e.major<t.major?-1:e.minor>t.minor?1:e.minor<t.minor?-1:0},t.prototype._logOpen=function(e){this._log(e),this._logIndentLevel++},t.prototype._logClose=function(){--this._logIndentLevel},t.prototype._logEnabled=function(e){var n=t._logSpaces.substring(0,2*this._logIndentLevel);f.Logger.Log("".concat(n).concat(e))},t.prototype._logDisabled=function(e){},t.prototype._startPerformanceCounterEnabled=function(e){f.Tools.StartPerformanceCounter(e)},t.prototype._startPerformanceCounterDisabled=function(e){},t.prototype._endPerformanceCounterEnabled=function(e){f.Tools.EndPerformanceCounter(e)},t.prototype._endPerformanceCounterDisabled=function(e){},t.IncrementalLoading=!0,t.HomogeneousCoordinates=!1,t._logSpaces=" ",t}(function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.extensionOptions={},t.preprocessUrlAsync=function(e){return Promise.resolve(e)},t}return c(t,e),t.prototype.copyFrom=function(e){var t,n,r,o,a,i,s,l,u,c,d,f,p,h,m,v,b,y,A,_,g,O,E,L,T,N;e&&(this.alwaysComputeBoundingBox=null!==(t=e.alwaysComputeBoundingBox)&&void 0!==t?t:this.alwaysComputeBoundingBox,this.alwaysComputeSkeletonRootNode=null!==(n=e.alwaysComputeSkeletonRootNode)&&void 0!==n?n:this.alwaysComputeSkeletonRootNode,this.animationStartMode=null!==(r=e.animationStartMode)&&void 0!==r?r:this.animationStartMode,this.capturePerformanceCounters=null!==(o=e.capturePerformanceCounters)&&void 0!==o?o:this.capturePerformanceCounters,this.compileMaterials=null!==(a=e.compileMaterials)&&void 0!==a?a:this.compileMaterials,this.compileShadowGenerators=null!==(i=e.compileShadowGenerators)&&void 0!==i?i:this.compileShadowGenerators,this.coordinateSystemMode=null!==(s=e.coordinateSystemMode)&&void 0!==s?s:this.coordinateSystemMode,this.createInstances=null!==(l=e.createInstances)&&void 0!==l?l:this.createInstances,this.customRootNode=e.customRootNode,this.extensionOptions=null!==(u=e.extensionOptions)&&void 0!==u?u:this.extensionOptions,this.loadAllMaterials=null!==(c=e.loadAllMaterials)&&void 0!==c?c:this.loadAllMaterials,this.loadMorphTargets=null!==(d=e.loadMorphTargets)&&void 0!==d?d:this.loadMorphTargets,this.loadNodeAnimations=null!==(f=e.loadNodeAnimations)&&void 0!==f?f:this.loadNodeAnimations,this.loadOnlyMaterials=null!==(p=e.loadOnlyMaterials)&&void 0!==p?p:this.loadOnlyMaterials,this.loadSkins=null!==(h=e.loadSkins)&&void 0!==h?h:this.loadSkins,this.loggingEnabled=null!==(m=e.loggingEnabled)&&void 0!==m?m:this.loggingEnabled,this.onCameraLoaded=e.onCameraLoaded,this.onMaterialLoaded=e.onMaterialLoaded,this.onMeshLoaded=e.onMeshLoaded,this.onParsed=e.onParsed,this.onSkinLoaded=e.onSkinLoaded,this.onTextureLoaded=e.onTextureLoaded,this.onValidated=e.onValidated,this.preprocessUrlAsync=null!==(v=e.preprocessUrlAsync)&&void 0!==v?v:this.preprocessUrlAsync,this.skipMaterials=null!==(b=e.skipMaterials)&&void 0!==b?b:this.skipMaterials,this.targetFps=null!==(y=e.targetFps)&&void 0!==y?y:this.targetFps,this.transparencyAsCoverage=null!==(A=e.transparencyAsCoverage)&&void 0!==A?A:this.transparencyAsCoverage,this.useClipPlane=null!==(_=e.useClipPlane)&&void 0!==_?_:this.useClipPlane,this.useGltfTextureNames=null!==(g=e.useGltfTextureNames)&&void 0!==g?g:this.useGltfTextureNames,this.useOpenPBR=null!==(O=e.useOpenPBR)&&void 0!==O?O:this.useOpenPBR,this.useRangeRequests=null!==(E=e.useRangeRequests)&&void 0!==E?E:this.useRangeRequests,this.useSRGBBuffers=null!==(L=e.useSRGBBuffers)&&void 0!==L?L:this.useSRGBBuffers,this.validate=null!==(T=e.validate)&&void 0!==T?T:this.validate,this.dontUseTransmissionHelper=null!==(N=e.dontUseTransmissionHelper)&&void 0!==N?N:this.dontUseTransmissionHelper)},t}(E));(0,f.RegisterSceneLoaderPlugin)(new T);var N,S,C,M,x,R,w,P,I=void 0!==r.g?r.g:"undefined"!=typeof window?window:void 0;if(void 0!==I){for(var B in I.BABYLON=I.BABYLON||{},i)I.BABYLON[B]=i[B];for(var B in a)I.BABYLON[B]=a[B]}!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"}(N||(N={})),function(e){e[e.FRAGMENT=35632]="FRAGMENT",e[e.VERTEX=35633]="VERTEX"}(S||(S={})),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"}(C||(C={})),function(e){e[e.CLAMP_TO_EDGE=33071]="CLAMP_TO_EDGE",e[e.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",e[e.REPEAT=10497]="REPEAT"}(M||(M={})),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"}(x||(x={})),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"}(R||(R={})),function(e){e[e.FRONT=1028]="FRONT",e[e.BACK=1029]="BACK",e[e.FRONT_AND_BACK=1032]="FRONT_AND_BACK"}(w||(w={})),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"}(P||(P={}));var F,V=function(){function e(){}return e.SetMatrix=function(e,t,n,r,o){var a=null;if("MODEL"===n.semantic?a=t.getWorldMatrix():"PROJECTION"===n.semantic?a=e.getProjectionMatrix():"VIEW"===n.semantic?a=e.getViewMatrix():"MODELVIEWINVERSETRANSPOSE"===n.semantic?a=f.Matrix.Transpose(t.getWorldMatrix().multiply(e.getViewMatrix()).invert()):"MODELVIEW"===n.semantic?a=t.getWorldMatrix().multiply(e.getViewMatrix()):"MODELVIEWPROJECTION"===n.semantic?a=t.getWorldMatrix().multiply(e.getTransformMatrix()):"MODELINVERSE"===n.semantic?a=t.getWorldMatrix().invert():"VIEWINVERSE"===n.semantic?a=e.getViewMatrix().invert():"PROJECTIONINVERSE"===n.semantic?a=e.getProjectionMatrix().invert():"MODELVIEWINVERSE"===n.semantic?a=t.getWorldMatrix().multiply(e.getViewMatrix()).invert():"MODELVIEWPROJECTIONINVERSE"===n.semantic?a=t.getWorldMatrix().multiply(e.getTransformMatrix()).invert():"MODELINVERSETRANSPOSE"===n.semantic&&(a=f.Matrix.Transpose(t.getWorldMatrix().invert())),a)switch(n.type){case C.FLOAT_MAT2:o.setMatrix2x2(r,f.Matrix.GetAsMatrix2x2(a));break;case C.FLOAT_MAT3:o.setMatrix3x3(r,f.Matrix.GetAsMatrix3x3(a));break;case C.FLOAT_MAT4:o.setMatrix(r,a)}},e.SetUniform=function(e,t,n,r){switch(r){case C.FLOAT:return e.setFloat(t,n),!0;case C.FLOAT_VEC2:return e.setVector2(t,f.Vector2.FromArray(n)),!0;case C.FLOAT_VEC3:return e.setVector3(t,f.Vector3.FromArray(n)),!0;case C.FLOAT_VEC4:return e.setVector4(t,f.Vector4.FromArray(n)),!0;default:return!1}},e.GetWrapMode=function(e){switch(e){case M.CLAMP_TO_EDGE:return f.Texture.CLAMP_ADDRESSMODE;case M.MIRRORED_REPEAT:return f.Texture.MIRROR_ADDRESSMODE;case M.REPEAT:default:return f.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 x.LINEAR:case x.LINEAR_MIPMAP_NEAREST:case x.LINEAR_MIPMAP_LINEAR:return f.Texture.TRILINEAR_SAMPLINGMODE;case x.NEAREST:case x.NEAREST_MIPMAP_NEAREST:return f.Texture.NEAREST_SAMPLINGMODE;default:return f.Texture.BILINEAR_SAMPLINGMODE}},e.GetBufferFromBufferView=function(e,t,n,r,o){n=t.byteOffset+n;var a=e.loadedBufferViews[t.buffer];if(n+r>a.byteLength)throw new Error("Buffer access is out of range");var i=a.buffer;switch(n+=a.byteOffset,o){case N.BYTE:return new Int8Array(i,n,r);case N.UNSIGNED_BYTE:return new Uint8Array(i,n,r);case N.SHORT:return new Int16Array(i,n,r);case N.UNSIGNED_SHORT:return new Uint16Array(i,n,r);default:return new Float32Array(i,n,r)}},e.GetBufferFromAccessor=function(t,n){var r=t.bufferViews[n.bufferView],o=n.count*e.GetByteStrideFromType(n);return e.GetBufferFromBufferView(t,r,n.byteOffset,o,n.componentType)},e.DecodeBufferToText=function(e){for(var t="",n=e.byteLength,r=0;r<n;++r)t+=String.fromCharCode(e[r]);return t},e.GetDefaultMaterial=function(t){if(!e._DefaultMaterial){f.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"),f.Effect.ShadersStore.GLTFDefaultMaterialPixelShader=["precision highp float;","","uniform vec4 u_emission;","","void main(void)","{"," gl_FragColor = u_emission;","}"].join("\n");var n={attributes:["position"],uniforms:["worldView","projection","u_emission"],samplers:new Array,needAlphaBlending:!1};e._DefaultMaterial=new f.ShaderMaterial("GLTFDefaultMaterial",t,{vertex:"GLTFDefaultMaterial",fragment:"GLTFDefaultMaterial"},n),e._DefaultMaterial.setColor4("u_emission",new f.Color4(.5,.5,.5,1))}return e._DefaultMaterial},e._DefaultMaterial=null,e}();!function(e){e[e.IDENTIFIER=1]="IDENTIFIER",e[e.UNKNOWN=2]="UNKNOWN",e[e.END_OF_INPUT=3]="END_OF_INPUT"}(F||(F={}));var D=function(){function e(e){this._pos=0,this.currentToken=F.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 F.END_OF_INPUT;if(this.currentString=this.read(),this.currentToken=F.UNKNOWN,"_"===this.currentString||this.isLetterOrDigitPattern.test(this.currentString))for(this.currentToken=F.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}(),k=["MODEL","VIEW","PROJECTION","MODELVIEW","MODELVIEWPROJECTION","JOINTMATRIX"],U=["world","view","projection","worldView","worldViewProjection","mBones"],G=["translation","rotation","scale"],j=["position","rotationQuaternion","scaling"],H=function(e,t,n){for(var r in e){var o=e[r];n[t][r]=o}},W=function(e){if(e)for(var t=0;t<e.length/2;t++)e[2*t+1]=1-e[2*t+1]},Y=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 t=Number(e.semantic.split("_")[1]);return"uv"+(0===t?"":t+1)}return null},J=function(e){var t=null;if(e.translation||e.rotation||e.scale){var n=f.Vector3.FromArray(e.scale||[1,1,1]),r=f.Quaternion.FromArray(e.rotation||[0,0,0,1]),o=f.Vector3.FromArray(e.translation||[0,0,0]);t=f.Matrix.Compose(n,r,o)}else t=f.Matrix.FromArray(e.matrix);return t},q=function(e,t,n,r){for(var o=0;o<r.bones.length;o++)if(r.bones[o].name===n)return r.bones[o];var a=e.nodes;for(var i in a){var s=a[i];if(s.jointName){var l=s.children;for(o=0;o<l.length;o++){var u=e.nodes[l[o]];if(u.jointName&&u.jointName===n){var c=J(s),d=new f.Bone(s.name||"",r,q(e,t,s.jointName,r),c);return d.id=i,d}}}}return null},Z=function(e,t){for(var n=0;n<e.length;n++)for(var r=e[n],o=0;o<r.node.children.length;o++)if(r.node.children[o]===t)return r.bone;return null},K=function(e,t){var n=e.nodes,r=n[t];if(r)return{node:r,id:t};for(var o in n)if((r=n[o]).jointName===t)return{node:r,id:o};return null},Q=function(e,t){for(var n=0;n<e.jointNames.length;n++)if(e.jointNames[n]===t)return!0;return!1},X=function(e,t,n,r,o){if(o||(e.scene._blockEntityCollection=!!e.assetContainer,(o=new f.Mesh(t.name||"",e.scene))._parentContainer=e.assetContainer,e.scene._blockEntityCollection=!1,o.id=r),!t.babylonNode)return o;for(var a,i=[],s=null,l=[],u=[],c=[],d=[],p=0;p<n.length;p++){var h=n[p];if(x=e.meshes[h])for(var m=0;m<x.primitives.length;m++){var v=new f.VertexData,b=x.primitives[m];b.mode;var y=b.attributes,A=null,_=null;for(var g in y)if(A=e.accessors[y[g]],_=V.GetBufferFromAccessor(e,A),"NORMAL"===g)v.normals=new Float32Array(_.length),v.normals.set(_);else if("POSITION"===g){if(T.HomogeneousCoordinates){v.positions=new Float32Array(_.length-_.length/4);for(var O=0;O<_.length;O+=4)v.positions[O]=_[O],v.positions[O+1]=_[O+1],v.positions[O+2]=_[O+2]}else v.positions=new Float32Array(_.length),v.positions.set(_);u.push(v.positions.length)}else if(-1!==g.indexOf("TEXCOORD_")){var E=Number(g.split("_")[1]),L=f.VertexBuffer.UVKind+(0===E?"":E+1),N=new Float32Array(_.length);N.set(_),W(N),v.set(N,L)}else"JOINT"===g?(v.matricesIndices=new Float32Array(_.length),v.matricesIndices.set(_)):"WEIGHT"===g?(v.matricesWeights=new Float32Array(_.length),v.matricesWeights.set(_)):"COLOR"===g&&(v.colors=new Float32Array(_.length),v.colors.set(_));if(A=e.accessors[b.indices])_=V.GetBufferFromAccessor(e,A),v.indices=new Int32Array(_.length),v.indices.set(_),d.push(v.indices.length);else{var S=[];for(O=0;O<v.positions.length/3;O++)S.push(O);v.indices=new Int32Array(S),d.push(v.indices.length)}s?s.merge(v):s=v;var C=e.scene.getMaterialById(b.material);i.push(null===C?V.GetDefaultMaterial(e.scene):C),l.push(0===l.length?0:l[l.length-1]+u[u.length-2]),c.push(0===c.length?0:c[c.length-1]+d[d.length-2])}}e.scene._blockEntityCollection=!!e.assetContainer,i.length>1?(a=new f.MultiMaterial("multimat"+r,e.scene)).subMaterials=i:a=new f.StandardMaterial("multimat"+r,e.scene),1===i.length&&(a=i[0]),a._parentContainer=e.assetContainer,o.material||(o.material=a),new f.Geometry(r,e.scene,s,!1,o),o.computeWorldMatrix(!0),e.scene._blockEntityCollection=!1,o.subMeshes=[];var M=0;for(p=0;p<n.length;p++){var x;if(h=n[p],x=e.meshes[h])for(m=0;m<x.primitives.length;m++)x.primitives[m].mode,f.SubMesh.AddToMesh(M,l[M],u[M],c[M],d[M],o,o,!0),M++}return o},z=function(e,t,n,r){e.position&&(e.position=t),(e.rotationQuaternion||e.rotation)&&(e.rotationQuaternion=n),e.scaling&&(e.scaling=r)},$=function(e,t,n){var r=null;if(e.importOnlyMeshes&&(t.skin||t.meshes)&&e.importMeshesNames&&e.importMeshesNames.length>0&&-1===e.importMeshesNames.indexOf(t.name||""))return null;if(t.skin){if(t.meshes){var o=e.skins[t.skin];(a=X(e,t,t.meshes,n,t.babylonNode)).skeleton=e.scene.getLastSkeletonById(t.skin),null===a.skeleton&&(a.skeleton=function(e,t,n,r){if(r||(r=new f.Skeleton(t.name||"","",e.scene)),!t.babylonSkeleton)return r;var o=[],a=[];!function(e,t,n,r){for(var o in e.nodes){var a=e.nodes[o],i=o;if(a.jointName&&!Q(n,a.jointName)){var s=J(a),l=new f.Bone(a.name||"",t,null,s);l.id=i,r.push({bone:l,node:a,id:i})}}for(var u=0;u<r.length;u++)for(var c=r[u],d=c.node.children,p=0;p<d.length;p++){for(var h=null,m=0;m<r.length;m++)if(r[m].id===d[p]){h=r[m];break}h&&(h.bone._parent=c.bone,c.bone.children.push(h.bone))}}(e,r,t,o),r.bones=[];for(var i=0;i<t.jointNames.length;i++)if(_=K(e,t.jointNames[i])){var s=_.node;if(s){var l=_.id,u=e.scene.getBoneById(l);if(u)r.bones.push(u);else{for(var c=!1,d=null,p=0;p<i;p++){var h=K(e,t.jointNames[p]);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]===l){d=q(e,t,t.jointNames[p],r),c=!0;break}if(c)break}}else f.Tools.Warn("Joint named "+t.jointNames[p]+" does not exist when looking for parent")}}var y=J(s);!d&&o.length>0&&(d=Z(o,l))&&-1===a.indexOf(d)&&a.push(d),new f.Bone(s.jointName||"",r,d,y).id=l}}else f.Tools.Warn("Joint named "+t.jointNames[i]+" does not exist")}var A=r.bones;for(r.bones=[],i=0;i<t.jointNames.length;i++){var _;if(_=K(e,t.jointNames[i]))for(p=0;p<A.length;p++)if(A[p].id===_.id){r.bones.push(A[p]);break}}for(r.prepare(),i=0;i<a.length;i++)r.bones.push(a[i]);return r}(e,o,0,o.babylonSkeleton),o.babylonSkeleton||(o.babylonSkeleton=a.skeleton)),r=a}}else if(t.meshes){var a;r=a=X(e,t,t.mesh?[t.mesh]:t.meshes,n,t.babylonNode)}else if(!t.light||t.babylonNode||e.importOnlyMeshes){if(t.camera&&!t.babylonNode&&!e.importOnlyMeshes){var i=e.cameras[t.camera];if(i){if(e.scene._blockEntityCollection=!!e.assetContainer,"orthographic"===i.type){var s=new f.FreeCamera(t.camera,f.Vector3.Zero(),e.scene,!1);s.name=t.name||"",s.mode=f.Camera.ORTHOGRAPHIC_CAMERA,s.attachControl(),r=s,s._parentContainer=e.assetContainer}else if("perspective"===i.type){var l=i[i.type],u=new f.FreeCamera(t.camera,f.Vector3.Zero(),e.scene,!1);u.name=t.name||"",u.attachControl(),l.aspectRatio||(l.aspectRatio=e.scene.getEngine().getRenderWidth()/e.scene.getEngine().getRenderHeight()),l.znear&&l.zfar&&(u.maxZ=l.zfar,u.minZ=l.znear),r=u,u._parentContainer=e.assetContainer}e.scene._blockEntityCollection=!1}}}else{var c=e.lights[t.light];if(c)if("ambient"===c.type){var d=c[c.type],p=new f.HemisphericLight(t.light,f.Vector3.Zero(),e.scene);p.name=t.name||"",d.color&&(p.diffuse=f.Color3.FromArray(d.color)),r=p}else if("directional"===c.type){var h=c[c.type],m=new f.DirectionalLight(t.light,f.Vector3.Zero(),e.scene);m.name=t.name||"",h.color&&(m.diffuse=f.Color3.FromArray(h.color)),r=m}else if("point"===c.type){var v=c[c.type],b=new f.PointLight(t.light,f.Vector3.Zero(),e.scene);b.name=t.name||"",v.color&&(b.diffuse=f.Color3.FromArray(v.color)),r=b}else if("spot"===c.type){var y=c[c.type],A=new f.SpotLight(t.light,f.Vector3.Zero(),f.Vector3.Zero(),0,0,e.scene);A.name=t.name||"",y.color&&(A.diffuse=f.Color3.FromArray(y.color)),y.fallOfAngle&&(A.angle=y.fallOfAngle),y.fallOffExponent&&(A.exponent=y.fallOffExponent),r=A}}if(!t.jointName){if(t.babylonNode)return t.babylonNode;if(null===r){e.scene._blockEntityCollection=!!e.assetContainer;var _=new f.Mesh(t.name||"",e.scene);_._parentContainer=e.assetContainer,e.scene._blockEntityCollection=!1,t.babylonNode=_,r=_}}if(null!==r){if(t.matrix&&r instanceof f.Mesh)!function(e,t){if(t.matrix){var n=new f.Vector3(0,0,0),r=new f.Quaternion,o=new f.Vector3(0,0,0);f.Matrix.FromArray(t.matrix).decompose(o,r,n),z(e,n,r,o)}else t.translation&&t.rotation&&t.scale&&z(e,f.Vector3.FromArray(t.translation),f.Quaternion.FromArray(t.rotation),f.Vector3.FromArray(t.scale));e.computeWorldMatrix(!0)}(r,t);else{var g=t.translation||[0,0,0],O=t.rotation||[0,0,0,1],E=t.scale||[1,1,1];z(r,f.Vector3.FromArray(g),f.Quaternion.FromArray(O),f.Vector3.FromArray(E))}r.updateCache(!0),t.babylonNode=r}return r},ee=function(e,t,n,r){void 0===r&&(r=!1);var o=e.nodes[t],a=null;if(r=!(e.importOnlyMeshes&&!r&&e.importMeshesNames)||-1!==e.importMeshesNames.indexOf(o.name||"")||0===e.importMeshesNames.length,!o.jointName&&r&&null!==(a=$(e,o,t))&&(a.id=t,a.parent=n),o.children)for(var i=0;i<o.children.length;i++)ee(e,o.children[i],a,r)},te=function(e){var t=e.currentScene;if(t)for(var n=0;n<t.nodes.length;n++)ee(e,t.nodes[n],null);else for(var r in e.scenes)for(t=e.scenes[r],n=0;n<t.nodes.length;n++)ee(e,t.nodes[n],null);for(function(e){for(var t in e.animations){var n=e.animations[t];if(n.channels&&n.samplers)for(var r=null,o=0;o<n.channels.length;o++){var a=n.channels[o],i=n.samplers[a.sampler];if(i){var s=null,l=null;n.parameters?(s=n.parameters[i.input],l=n.parameters[i.output]):(s=i.input,l=i.output);var u=V.GetBufferFromAccessor(e,e.accessors[s]),c=V.GetBufferFromAccessor(e,e.accessors[l]),d=a.target.id,p=e.scene.getNodeById(d);if(null===p&&(p=e.scene.getNodeByName(d)),null!==p){var h=p instanceof f.Bone,m=a.target.path,v=G.indexOf(m);-1!==v&&(m=j[v]);var b=f.Animation.ANIMATIONTYPE_MATRIX;h||("rotationQuaternion"===m?(b=f.Animation.ANIMATIONTYPE_QUATERNION,p.rotationQuaternion=new f.Quaternion):b=f.Animation.ANIMATIONTYPE_VECTOR3);var y=null,A=[],_=0,g=!1;h&&r&&r.getKeys().length===u.length&&(y=r,g=!0),g||(e.scene._blockEntityCollection=!!e.assetContainer,y=new f.Animation(t,h?"_matrix":m,1,b,f.Animation.ANIMATIONLOOPMODE_CYCLE),e.scene._blockEntityCollection=!1);for(var O=0;O<u.length;O++){var E=null;if("rotationQuaternion"===m?(E=f.Quaternion.FromArray([c[_],c[_+1],c[_+2],c[_+3]]),_+=4):(E=f.Vector3.FromArray([c[_],c[_+1],c[_+2]]),_+=3),h){var L=p,T=f.Vector3.Zero(),N=new f.Quaternion,S=f.Vector3.Zero(),C=L.getBaseMatrix();g&&r&&(C=r.getKeys()[O].value),C.decompose(S,N,T),"position"===m?T=E:"rotationQuaternion"===m?N=E:S=E,E=f.Matrix.Compose(S,N,T)}g?r&&(r.getKeys()[O].value=E):A.push({frame:u[O],value:E})}!g&&y&&(y.setKeys(A),p.animations.push(y)),r=y,e.scene.stopAnimation(p),e.scene.beginAnimation(p,0,u[u.length-1],!0,1)}else f.Tools.Warn("Creating animation named "+t+". But cannot find node named "+d+" to attach to")}}}}(e),n=0;n<e.scene.skeletons.length;n++){var o=e.scene.skeletons[n];e.scene.beginAnimation(o,0,Number.MAX_VALUE,!0,1)}},ne=function(e,t,n){for(var r in t.uniforms){var o=t.uniforms[r],a=t.parameters[o];if(e.currentIdentifier===r&&a.semantic&&!a.source&&!a.node){var i=k.indexOf(a.semantic);if(-1!==i)return delete n[r],U[i]}}return e.currentIdentifier},re=function(e){for(var t in e.materials)ie.LoadMaterialAsync(e,t,(function(){}),(function(){}))},oe=function(){function e(){}return e.CreateRuntime=function(e,t,n){var r={extensions:{},accessors:{},buffers:{},bufferViews:{},meshes:{},lights:{},cameras:{},nodes:{},images:{},textures:{},shaders:{},programs:{},samplers:{},techniques:{},materials:{},animations:{},skins:{},extensionsUsed:[],scenes:{},buffersCount:0,shaderscount:0,scene:t,rootUrl:n,loadedBufferCount:0,loadedBufferViews:{},loadedShaderCount:0,importOnlyMeshes:!1,dummyNodes:[],assetContainer:null};return e.extensions&&H(e.extensions,"extensions",r),e.extensionsUsed&&H(e.extensionsUsed,"extensionsUsed",r),e.buffers&&function(e,t){for(var n in e){var r=e[n];t.buffers[n]=r,t.buffersCount++}}(e.buffers,r),e.bufferViews&&H(e.bufferViews,"bufferViews",r),e.accessors&&H(e.accessors,"accessors",r),e.meshes&&H(e.meshes,"meshes",r),e.lights&&H(e.lights,"lights",r),e.cameras&&H(e.cameras,"cameras",r),e.nodes&&H(e.nodes,"nodes",r),e.images&&H(e.images,"images",r),e.textures&&H(e.textures,"textures",r),e.shaders&&function(e,t){for(var n in e){var r=e[n];t.shaders[n]=r,t.shaderscount++}}(e.shaders,r),e.programs&&H(e.programs,"programs",r),e.samplers&&H(e.samplers,"samplers",r),e.techniques&&H(e.techniques,"techniques",r),e.materials&&H(e.materials,"materials",r),e.animations&&H(e.animations,"animations",r),e.skins&&H(e.skins,"skins",r),e.scenes&&(r.scenes=e.scenes),e.scene&&e.scenes&&(r.currentScene=e.scenes[e.scene]),r},e.LoadBufferAsync=function(e,t,n,r,o){var a=e.buffers[t];f.Tools.IsBase64(a.uri)?setTimeout((function(){return n(new Uint8Array(f.Tools.DecodeBase64(a.uri)))})):f.Tools.LoadFile(e.rootUrl+a.uri,(function(e){return n(new Uint8Array(e))}),o,void 0,!0,(function(e){e&&r(e.status+" "+e.statusText)}))},e.LoadTextureBufferAsync=function(e,t,n,r){var o=e.textures[t];if(o&&o.source)if(o.babylonTexture)n(null);else{var a=e.images[o.source];f.Tools.IsBase64(a.uri)?setTimeout((function(){return n(new Uint8Array(f.Tools.DecodeBase64(a.uri)))})):f.Tools.LoadFile(e.rootUrl+a.uri,(function(e){return n(new Uint8Array(e))}),void 0,void 0,!0,(function(e){e&&r(e.status+" "+e.statusText)}))}else r("")},e.CreateTextureAsync=function(e,t,n,r){var o=e.textures[t];if(o.babylonTexture)r(o.babylonTexture);else{var a=e.samplers[o.sampler],i=a.minFilter===x.NEAREST_MIPMAP_NEAREST||a.minFilter===x.NEAREST_MIPMAP_LINEAR||a.minFilter===x.LINEAR_MIPMAP_NEAREST||a.minFilter===x.LINEAR_MIPMAP_LINEAR,s=f.Texture.BILINEAR_SAMPLINGMODE,l=null==n?new Blob:new Blob([n]),u=URL.createObjectURL(l),c=function(){return URL.revokeObjectURL(u)},d=new f.Texture(u,e.scene,!i,!0,s,c,c);void 0!==a.wrapS&&(d.wrapU=V.GetWrapMode(a.wrapS)),void 0!==a.wrapT&&(d.wrapV=V.GetWrapMode(a.wrapT)),d.name=t,o.babylonTexture=d,r(d)}},e.LoadShaderStringAsync=function(e,t,n,r){var o=e.shaders[t];if(f.Tools.IsBase64(o.uri)){var a=atob(o.uri.split(",")[1]);n&&n(a)}else f.Tools.LoadFile(e.rootUrl+o.uri,n,void 0,void 0,!1,(function(e){e&&r&&r(e.status+" "+e.statusText)}))},e.LoadMaterialAsync=function(e,t,n,r){var o=e.materials[t];if(o.technique){var a=e.techniques[o.technique];if(!a){e.scene._blockEntityCollection=!!e.assetContainer;var i=new f.StandardMaterial(t,e.scene);return i._parentContainer=e.assetContainer,e.scene._blockEntityCollection=!1,i.diffuseColor=new f.Color3(.5,.5,.5),i.sideOrientation=f.Material.CounterClockWiseSideOrientation,void n(i)}var s=e.programs[a.program],l=a.states,u=f.Effect.ShadersStore[s.vertexShader+"VertexShader"],c=f.Effect.ShadersStore[s.fragmentShader+"PixelShader"],d="",p="",h=new D(u),m=new D(c),v={},b=[],y=[],A=[];for(var _ in a.uniforms){var g=a.uniforms[_],O=a.parameters[g];if(v[_]=O,!O.semantic||O.node||O.source)O.type===C.SAMPLER_2D?A.push(_):b.push(_);else{var E=k.indexOf(O.semantic);-1!==E?(b.push(U[E]),delete v[_]):b.push(_)}}for(var L in a.attributes){var T=a.attributes[L];if((M=a.parameters[T]).semantic){var N=Y(M);N&&y.push(N)}}for(;!h.isEnd()&&h.getNextToken();)if(h.currentToken===F.IDENTIFIER){var S=!1;for(var L in a.attributes){T=a.attributes[L];var M=a.parameters[T];if(h.currentIdentifier===L&&M.semantic){d+=Y(M),S=!0;break}}S||(d+=ne(h,a,v))}else d+=h.currentString;for(;!m.isEnd()&&m.getNextToken();)m.currentToken===F.IDENTIFIER?p+=ne(m,a,v):p+=m.currentString;var x={vertex:s.vertexShader+t,fragment:s.fragmentShader+t},R={attributes:y,uniforms:b,samplers:A,needAlphaBlending:l&&l.enable&&-1!==l.enable.indexOf(3042)};f.Effect.ShadersStore[s.vertexShader+t+"VertexShader"]=d,f.Effect.ShadersStore[s.fragmentShader+t+"PixelShader"]=p;var I=new f.ShaderMaterial(t,e.scene,x,R);if(I.onError=function(e,t,n){return function(r,o){t.dispose(!0),n("Cannot compile program named "+e.name+". Error: "+o+". Default material will be applied")}}(s,I,r),I.onCompiled=function(e,t,n,r,o,a){return function(i){!function(e,t,n,r,o){var a=r.values||n.parameters,i=n.uniforms,s=function(n){var s=o[n],l=s.type,u=a[i[n]];if(void 0===u&&(u=s.value),!u)return"continue";var c=function(e){return function(n){s.value&&e&&(t.setTexture(e,n),delete o[e])}};l===C.SAMPLER_2D?ie.LoadTextureAsync(e,r.values?u:s.value,c(n),(function(){return c(null)})):s.value&&V.SetUniform(t,n,r.values?u:s.value,l)&&delete o[n]};for(var l in o)s(l)}(e,t,n,r,o),t.onBind=function(i){!function(e,t,n,r,o,a,i){var s=a.values||o.parameters;for(var l in n){var u=n[l],c=u.type;if(c===C.FLOAT_MAT2||c===C.FLOAT_MAT3||c===C.FLOAT_MAT4)if(!u.semantic||u.source||u.node){if(u.semantic&&(u.source||u.node)){var d=t.scene.getNodeByName(u.source||u.node||"");if(null===d&&(d=t.scene.getNodeById(u.source||u.node||"")),null===d)continue;V.SetMatrix(t.scene,d,u,l,r.getEffect())}}else V.SetMatrix(t.scene,e,u,l,r.getEffect());else{var f=s[o.uniforms[l]];if(!f)continue;if(c===C.SAMPLER_2D){var p=t.textures[a.values?f:u.value].babylonTexture;if(null==p)continue;r.getEffect().setTexture(l,p)}else V.SetUniform(r.getEffect(),l,f,c)}}i(r)}(i,e,o,t,n,r,a)}}}(e,I,a,o,v,n),I.sideOrientation=f.Material.CounterClockWiseSideOrientation,l&&l.functions){var B=l.functions;B.cullFace&&B.cullFace[0]!==w.BACK&&(I.backFaceCulling=!1);var G=B.blendFuncSeparate;G&&(G[0]===P.SRC_ALPHA&&G[1]===P.ONE_MINUS_SRC_ALPHA&&G[2]===P.ONE&&G[3]===P.ONE?I.alphaMode=f.Constants.ALPHA_COMBINE:G[0]===P.ONE&&G[1]===P.ONE&&G[2]===P.ZERO&&G[3]===P.ONE?I.alphaMode=f.Constants.ALPHA_ONEONE:G[0]===P.SRC_ALPHA&&G[1]===P.ONE&&G[2]===P.ZERO&&G[3]===P.ONE?I.alphaMode=f.Constants.ALPHA_ADD:G[0]===P.ZERO&&G[1]===P.ONE_MINUS_SRC_COLOR&&G[2]===P.ONE&&G[3]===P.ONE?I.alphaMode=f.Constants.ALPHA_SUBTRACT:G[0]===P.DST_COLOR&&G[1]===P.ZERO&&G[2]===P.ONE&&G[3]===P.ONE?I.alphaMode=f.Constants.ALPHA_MULTIPLY:G[0]===P.SRC_ALPHA&&G[1]===P.ONE_MINUS_SRC_COLOR&&G[2]===P.ONE&&G[3]===P.ONE&&(I.alphaMode=f.Constants.ALPHA_MAXIMIZED))}}else r&&r("No technique found.")},e}(),ae=function(){function e(){}return e.RegisterExtension=function(t){e.Extensions[t.name]?f.Tools.Error('Tool with the same name "'+t.name+'" already exists'):e.Extensions[t.name]=t},e.prototype.dispose=function(){},e.prototype._importMeshAsync=function(e,t,n,r,o,a,i,s){var l=this;return t.useRightHandedSystem=!0,ie.LoadRuntimeAsync(t,n,r,(function(t){t.assetContainer=o,t.importOnlyMeshes=!0,""===e?t.importMeshesNames=[]:"string"==typeof e?t.importMeshesNames=[e]:!e||e instanceof Array?(t.importMeshesNames=[],f.Tools.Warn("Argument meshesNames must be of type string or string[]")):t.importMeshesNames=[e],l._createNodes(t);var n=[],r=[];for(var i in t.nodes){var s=t.nodes[i];s.babylonNode instanceof f.AbstractMesh&&n.push(s.babylonNode)}for(var u in t.skins){var c=t.skins[u];c.babylonSkeleton instanceof f.Skeleton&&r.push(c.babylonSkeleton)}l._loadBuffersAsync(t,(function(){l._loadShadersAsync(t,(function(){re(t),te(t),!T.IncrementalLoading&&a&&a(n,r)}))})),T.IncrementalLoading&&a&&a(n,r)}),s),!0},e.prototype.importMeshAsync=function(e,t,n,r,o,a){var i=this;return new Promise((function(s,l){i._importMeshAsync(e,t,r,o,n,(function(e,t){s({meshes:e,particleSystems:[],skeletons:t,animationGroups:[],lights:[],transformNodes:[],geometries:[],spriteManagers:[]})}),a,(function(e){l(new Error(e))}))}))},e.prototype._loadAsync=function(e,t,n,r,o,a){var i=this;e.useRightHandedSystem=!0,ie.LoadRuntimeAsync(e,t,n,(function(e){ie.LoadRuntimeExtensionsAsync(e,(function(){i._createNodes(e),i._loadBuffersAsync(e,(function(){i._loadShadersAsync(e,(function(){re(e),te(e),T.IncrementalLoading||r()}))})),T.IncrementalLoading&&r()}),a)}),a)},e.prototype.loadAsync=function(e,t,n,r){return o=this,a=void 0,s=function(){var o=this;return function(e,t){var n,r,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=s(0),i.throw=s(1),i.return=s(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(l){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(n=1,r&&(o=2&s[0]?r.return:s[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,s[1])).done)return o;switch(r=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,r=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){a.label=s[1];break}if(6===s[0]&&a.label<o[1]){a.label=o[1],o=s;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(s);break}o[2]&&a.ops.pop(),a.trys.pop();continue}s=t.call(e,a)}catch(e){s=[6,e],r=0}finally{n=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,l])}}}(this,(function(a){switch(a.label){case 0:return[4,new Promise((function(a,i){o._loadAsync(e,t,n,(function(){a()}),r,(function(e){i(new Error(e))}))}))];case 1:return[2,a.sent()]}}))},new((i=void 0)||(i=Promise))((function(e,t){function n(e){try{l(s.next(e))}catch(e){t(e)}}function r(e){try{l(s.throw(e))}catch(e){t(e)}}function l(t){var o;t.done?e(t.value):(o=t.value,o instanceof i?o:new i((function(e){e(o)}))).then(n,r)}l((s=s.apply(o,a||[])).next())}));var o,a,i,s},e.prototype._loadShadersAsync=function(e,t){var n=!1,r=function(n,r){ie.LoadShaderStringAsync(e,n,(function(o){o instanceof ArrayBuffer||(e.loadedShaderCount++,o&&(f.Effect.ShadersStore[n+(r.type===S.VERTEX?"VertexShader":"PixelShader")]=o),e.loadedShaderCount===e.shaderscount&&t())}),(function(){f.Tools.Error("Error when loading shader program named "+n+" located at "+r.uri)}))};for(var o in e.shaders){n=!0;var a=e.shaders[o];a?r.bind(this,o,a)():f.Tools.Error("No shader named: "+o)}n||t()},e.prototype._loadBuffersAsync=function(e,t){var n=!1,r=function(n,r){ie.LoadBufferAsync(e,n,(function(o){e.loadedBufferCount++,o&&(o.byteLength!=e.buffers[n].byteLength&&f.Tools.Error("Buffer named "+n+" is length "+o.byteLength+". Expected: "+r.byteLength),e.loadedBufferViews[n]=o),e.loadedBufferCount===e.buffersCount&&t()}),(function(){f.Tools.Error("Error when loading buffer named "+n+" located at "+r.uri)}))};for(var o in e.buffers){n=!0;var a=e.buffers[o];a?r.bind(this,o,a)():f.Tools.Error("No buffer named: "+o)}n||t()},e.prototype._createNodes=function(e){var t=e.currentScene;if(t)for(var n=0;n<t.nodes.length;n++)ee(e,t.nodes[n],null);else for(var r in e.scenes)for(t=e.scenes[r],n=0;n<t.nodes.length;n++)ee(e,t.nodes[n],null)},e.Extensions={},e}(),ie=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,t,n,r,o){return!1},e.prototype.loadRuntimeExtensionsAsync=function(e,t,n){return!1},e.prototype.loadBufferAsync=function(e,t,n,r,o){return!1},e.prototype.loadTextureBufferAsync=function(e,t,n,r){return!1},e.prototype.createTextureAsync=function(e,t,n,r,o){return!1},e.prototype.loadShaderStringAsync=function(e,t,n,r){return!1},e.prototype.loadMaterialAsync=function(e,t,n,r){return!1},e.LoadRuntimeAsync=function(t,n,r,o,a){e._ApplyExtensions((function(e){return e.loadRuntimeAsync(t,n,r,o,a)}),(function(){setTimeout((function(){o&&o(oe.CreateRuntime(n.json,t,r))}))}))},e.LoadRuntimeExtensionsAsync=function(t,n,r){e._ApplyExtensions((function(e){return e.loadRuntimeExtensionsAsync(t,n,r)}),(function(){setTimeout((function(){n()}))}))},e.LoadBufferAsync=function(t,n,r,o,a){e._ApplyExtensions((function(e){return e.loadBufferAsync(t,n,r,o,a)}),(function(){oe.LoadBufferAsync(t,n,r,o,a)}))},e.LoadTextureAsync=function(t,n,r,o){e._LoadTextureBufferAsync(t,n,(function(a){a&&e._CreateTextureAsync(t,n,a,r,o)}),o)},e.LoadShaderStringAsync=function(t,n,r,o){e._ApplyExtensions((function(e){return e.loadShaderStringAsync(t,n,r,o)}),(function(){oe.LoadShaderStringAsync(t,n,r,o)}))},e.LoadMaterialAsync=function(t,n,r,o){e._ApplyExtensions((function(e){return e.loadMaterialAsync(t,n,r,o)}),(function(){oe.LoadMaterialAsync(t,n,r,o)}))},e._LoadTextureBufferAsync=function(t,n,r,o){e._ApplyExtensions((function(e){return e.loadTextureBufferAsync(t,n,r,o)}),(function(){oe.LoadTextureBufferAsync(t,n,r,o)}))},e._CreateTextureAsync=function(t,n,r,o,a){e._ApplyExtensions((function(e){return e.createTextureAsync(t,n,r,o,a)}),(function(){oe.CreateTextureAsync(t,n,r,o)}))},e._ApplyExtensions=function(e,t){for(var n in ae.Extensions)if(e(ae.Extensions[n]))return;t()},e}();T._CreateGLTF1Loader=function(){return new ae};var se=function(e){function t(){return e.call(this,"KHR_binary_glTF")||this}return c(t,e),t.prototype.loadRuntimeAsync=function(e,t,n,r){var o=t.json.extensionsUsed;return!(!o||-1===o.indexOf(this.name)||!t.bin||(this._bin=t.bin,r(oe.CreateRuntime(t.json,e,n)),0))},t.prototype.loadBufferAsync=function(e,t,n,r){return-1!==e.extensionsUsed.indexOf(this.name)&&"binary_glTF"===t&&(this._bin.readAsync(0,this._bin.byteLength).then(n,(function(e){return r(e.message)})),!0)},t.prototype.loadTextureBufferAsync=function(e,t,n){var r=e.textures[t],o=e.images[r.source];if(!o.extensions||!(this.name in o.extensions))return!1;var a=o.extensions[this.name],i=e.bufferViews[a.bufferView];return n(V.GetBufferFromBufferView(e,i,0,i.byteLength,N.UNSIGNED_BYTE)),!0},t.prototype.loadShaderStringAsync=function(e,t,n){var r=e.shaders[t];if(!r.extensions||!(this.name in r.extensions))return!1;var o=r.extensions[this.name],a=e.bufferViews[o.bufferView],i=V.GetBufferFromBufferView(e,a,0,a.byteLength,N.UNSIGNED_BYTE);return setTimeout((function(){var e=V.DecodeBufferToText(i);n(e)})),!0},t}(ie);ae.RegisterExtension(new se);var le=function(e){function t(){return e.call(this,"KHR_materials_common")||this}return c(t,e),t.prototype.loadRuntimeExtensionsAsync=function(e){if(!e.extensions)return!1;var t=e.extensions[this.name];if(!t)return!1;var n=t.lights;if(n)for(var r in n){var o=n[r];switch(o.type){case"ambient":var a=new f.HemisphericLight(o.name,new f.Vector3(0,1,0),e.scene),i=o.ambient;i&&(a.diffuse=f.Color3.FromArray(i.color||[1,1,1]));break;case"point":var s=new f.PointLight(o.name,new f.Vector3(10,10,10),e.scene),l=o.point;l&&(s.diffuse=f.Color3.FromArray(l.color||[1,1,1]));break;case"directional":var u=new f.DirectionalLight(o.name,new f.Vector3(0,-1,0),e.scene),c=o.directional;c&&(u.diffuse=f.Color3.FromArray(c.color||[1,1,1]));break;case"spot":var d=o.spot;d&&(new f.SpotLight(o.name,new f.Vector3(0,10,0),new f.Vector3(0,-1,0),d.fallOffAngle||Math.PI,d.fallOffExponent||0,e.scene).diffuse=f.Color3.FromArray(d.color||[1,1,1]));break;default:f.Tools.Warn('GLTF Material Common extension: light type "'+o.type+"” not supported")}}return!1},t.prototype.loadMaterialAsync=function(e,t,n,r){var o=e.materials[t];if(!o||!o.extensions)return!1;var a=o.extensions[this.name];if(!a)return!1;var i=new f.StandardMaterial(t,e.scene);return i.sideOrientation=f.Material.CounterClockWiseSideOrientation,"CONSTANT"===a.technique&&(i.disableLighting=!0),i.backFaceCulling=void 0!==a.doubleSided&&!a.doubleSided,i.alpha=void 0===a.values.transparency?1:a.values.transparency,i.specularPower=void 0===a.values.shininess?0:a.values.shininess,"string"==typeof a.values.ambient?this._loadTexture(e,a.values.ambient,i,"ambientTexture",r):i.ambientColor=f.Color3.FromArray(a.values.ambient||[0,0,0]),"string"==typeof a.values.diffuse?this._loadTexture(e,a.values.diffuse,i,"diffuseTexture",r):i.diffuseColor=f.Color3.FromArray(a.values.diffuse||[0,0,0]),"string"==typeof a.values.emission?this._loadTexture(e,a.values.emission,i,"emissiveTexture",r):i.emissiveColor=f.Color3.FromArray(a.values.emission||[0,0,0]),"string"==typeof a.values.specular?this._loadTexture(e,a.values.specular,i,"specularTexture",r):i.specularColor=f.Color3.FromArray(a.values.specular||[0,0,0]),!0},t.prototype._loadTexture=function(e,t,n,r,o){oe.LoadTextureBufferAsync(e,t,(function(o){oe.CreateTextureAsync(e,t,o,(function(e){return n[r]=e}))}),o)},t}(ie);ae.RegisterExtension(new le);var ue=void 0!==r.g?r.g:"undefined"!=typeof window?window:void 0;if(void 0!==ue)for(var ce in ue.BABYLON=ue.BABYLON||{},ue.BABYLON.GLTF1=ue.BABYLON.GLTF1||{},s)ue.BABYLON.GLTF1[ce]=s[ce];const de=l;return o.default})()));
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("babylonjs")):"function"==typeof define&&define.amd?define("babylonjs-loaders",["babylonjs"],t):"object"==typeof exports?exports["babylonjs-loaders"]=t(require("babylonjs")):e.LOADERS=t(e.BABYLON)}("undefined"!=typeof self?self:"undefined"!=typeof global?global:this,(e=>(()=>{"use strict";var t={597:t=>{t.exports=e}},n={};function r(e){var o=n[e];if(void 0!==o)return o.exports;var a=n[e]={exports:{}};return t[e](a,a.exports,r),a.exports}r.d=(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var o={};r.d(o,{default:()=>de});var a={};r.r(a),r.d(a,{GLTFValidation:()=>y});var i={};r.r(i),r.d(i,{GLTFFileLoader:()=>T,GLTFLoaderAnimationStartMode:()=>v,GLTFLoaderCoordinateSystemMode:()=>m,GLTFLoaderDefaultOptions:()=>L,GLTFLoaderState:()=>b});var s={};r.r(s),r.d(s,{EBlendingFunction:()=>P,EComponentType:()=>N,ECullingType:()=>w,EParameterType:()=>C,EShaderType:()=>S,ETextureFilterType:()=>x,ETextureFormat:()=>R,ETextureWrapMode:()=>M,GLTFBinaryExtension:()=>se,GLTFLoader:()=>ae,GLTFLoaderBase:()=>oe,GLTFLoaderExtension:()=>ie,GLTFMaterialsCommonExtension:()=>le,GLTFUtils:()=>V});var l={};r.r(l),r.d(l,{GLTF1:()=>s,GLTFFileLoader:()=>T,GLTFLoaderAnimationStartMode:()=>v,GLTFLoaderCoordinateSystemMode:()=>m,GLTFLoaderDefaultOptions:()=>L,GLTFLoaderState:()=>b,GLTFValidation:()=>y});var u=function(e,t){return u=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},u(e,t)};function c(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}u(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}var d=function(){return d=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},d.apply(this,arguments)};Object.create,Object.create,"function"==typeof SuppressedError&&SuppressedError;var f=r(597);function p(e,t,n,r){var o={externalResourceFunction:r};return n&&(o.uri="file:"===t?n:t+n),ArrayBuffer.isView(e)?GLTFValidator.validateBytes(e,o):GLTFValidator.validateString(e,o)}function h(){var e=[];onmessage=function(t){var n=t.data;switch(n.id){case"init":importScripts(n.url);break;case"validate":p(n.data,n.rootUrl,n.fileName,(function(t){return new Promise((function(n,r){var o=e.length;e.push({resolve:n,reject:r}),postMessage({id:"getExternalResource",index:o,uri:t})}))})).then((function(e){postMessage({id:"validate.resolve",value:e})}),(function(e){postMessage({id:"validate.reject",reason:e})}));break;case"getExternalResource.resolve":e[n.index].resolve(n.value);break;case"getExternalResource.reject":e[n.index].reject(n.reason)}}}var m,v,b,y=function(){function e(){}return e.ValidateAsync=function(t,n,r,o){var a=this;return"function"==typeof Worker?new Promise((function(i,s){var l="".concat(p,"(").concat(h,")()"),u=URL.createObjectURL(new Blob([l],{type:"application/javascript"})),c=new Worker(u),d=function(e){c.removeEventListener("error",d),c.removeEventListener("message",m),s(e)},m=function(t){var n=t.data;switch(n.id){case"getExternalResource":o(n.uri).then((function(e){c.postMessage({id:"getExternalResource.resolve",index:n.index,value:e},[e.buffer])}),(function(e){c.postMessage({id:"getExternalResource.reject",index:n.index,reason:e})}));break;case"validate.resolve":c.removeEventListener("error",d),c.removeEventListener("message",m),e._LastResults=n.value,i(n.value),c.terminate();break;case"validate.reject":c.removeEventListener("error",d),c.removeEventListener("message",m),s(n.reason),c.terminate()}};if(c.addEventListener("error",d),c.addEventListener("message",m),c.postMessage({id:"init",url:f.Tools.GetBabylonScriptURL(a.Configuration.url)}),ArrayBuffer.isView(t)){var v=t.slice();c.postMessage({id:"validate",data:v,rootUrl:n,fileName:r},[v.buffer])}else c.postMessage({id:"validate",data:t,rootUrl:n,fileName:r})})):(this._LoadScriptPromise||(this._LoadScriptPromise=f.Tools.LoadBabylonScriptAsync(this.Configuration.url)),this._LoadScriptPromise.then((function(){return p(t,n,r,o)})))},e.Configuration={url:"".concat(f.Tools._DefaultCdnUrl,"/gltf_validator.js")},e._LastResults=null,e}(),A="Z2xURg",_="gltf",g={".gltf":{isBinary:!1,mimeType:"model/gltf+json"},".glb":{isBinary:!0,mimeType:"model/gltf-binary"}};function O(e,t,n){try{return Promise.resolve(new Uint8Array(e,t,n))}catch(e){return Promise.reject(e)}}!function(e){e[e.AUTO=0]="AUTO",e[e.FORCE_RIGHT_HANDED=1]="FORCE_RIGHT_HANDED"}(m||(m={})),function(e){e[e.NONE=0]="NONE",e[e.FIRST=1]="FIRST",e[e.ALL=2]="ALL"}(v||(v={})),function(e){e[e.LOADING=0]="LOADING",e[e.READY=1]="READY",e[e.COMPLETE=2]="COMPLETE"}(b||(b={}));var E=function(){this.alwaysComputeBoundingBox=!1,this.alwaysComputeSkeletonRootNode=!1,this.animationStartMode=v.FIRST,this.compileMaterials=!1,this.compileShadowGenerators=!1,this.coordinateSystemMode=m.AUTO,this.createInstances=!0,this.loadAllMaterials=!1,this.loadMorphTargets=!0,this.loadNodeAnimations=!0,this.loadOnlyMaterials=!1,this.loadSkins=!0,this.skipMaterials=!1,this.targetFps=60,this.transparencyAsCoverage=!1,this.useClipPlane=!1,this.useGltfTextureNames=!1,this.useRangeRequests=!1,this.useSRGBBuffers=!0,this.validate=!1,this.useOpenPBR=!1,this.dontUseTransmissionHelper=!1},L=new E,T=function(e){function t(t){var n=e.call(this)||this;return n.onParsedObservable=new f.Observable,n.onMeshLoadedObservable=new f.Observable,n.onSkinLoadedObservable=new f.Observable,n.onTextureLoadedObservable=new f.Observable,n.onMaterialLoadedObservable=new f.Observable,n.onCameraLoadedObservable=new f.Observable,n.onCompleteObservable=new f.Observable,n.onErrorObservable=new f.Observable,n.onDisposeObservable=new f.Observable,n.onExtensionLoadedObservable=new f.Observable,n.onValidatedObservable=new f.Observable,n._loader=null,n._state=null,n._requests=new Array,n.name=_,n.extensions=g,n.onLoaderStateChangedObservable=new f.Observable,n._logIndentLevel=0,n._loggingEnabled=!1,n._log=n._logDisabled,n._capturePerformanceCounters=!1,n._startPerformanceCounter=n._startPerformanceCounterDisabled,n._endPerformanceCounter=n._endPerformanceCounterDisabled,n.copyFrom(Object.assign(d({},L),t)),n}return c(t,e),Object.defineProperty(t.prototype,"onParsed",{set:function(e){this._onParsedObserver&&this.onParsedObservable.remove(this._onParsedObserver),e&&(this._onParsedObserver=this.onParsedObservable.add(e))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"onMeshLoaded",{set:function(e){this._onMeshLoadedObserver&&this.onMeshLoadedObservable.remove(this._onMeshLoadedObserver),e&&(this._onMeshLoadedObserver=this.onMeshLoadedObservable.add(e))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"onSkinLoaded",{set:function(e){this._onSkinLoadedObserver&&this.onSkinLoadedObservable.remove(this._onSkinLoadedObserver),e&&(this._onSkinLoadedObserver=this.onSkinLoadedObservable.add((function(t){return e(t.node,t.skinnedNode)})))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"onTextureLoaded",{set:function(e){this._onTextureLoadedObserver&&this.onTextureLoadedObservable.remove(this._onTextureLoadedObserver),e&&(this._onTextureLoadedObserver=this.onTextureLoadedObservable.add(e))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"onMaterialLoaded",{set:function(e){this._onMaterialLoadedObserver&&this.onMaterialLoadedObservable.remove(this._onMaterialLoadedObserver),e&&(this._onMaterialLoadedObserver=this.onMaterialLoadedObservable.add(e))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"onCameraLoaded",{set:function(e){this._onCameraLoadedObserver&&this.onCameraLoadedObservable.remove(this._onCameraLoadedObserver),e&&(this._onCameraLoadedObserver=this.onCameraLoadedObservable.add(e))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"onComplete",{set:function(e){this._onCompleteObserver&&this.onCompleteObservable.remove(this._onCompleteObserver),this._onCompleteObserver=this.onCompleteObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"onError",{set:function(e){this._onErrorObserver&&this.onErrorObservable.remove(this._onErrorObserver),this._onErrorObserver=this.onErrorObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"onDispose",{set:function(e){this._onDisposeObserver&&this.onDisposeObservable.remove(this._onDisposeObserver),this._onDisposeObserver=this.onDisposeObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"onExtensionLoaded",{set:function(e){this._onExtensionLoadedObserver&&this.onExtensionLoadedObservable.remove(this._onExtensionLoadedObserver),this._onExtensionLoadedObserver=this.onExtensionLoadedObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.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(t.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(t.prototype,"onValidated",{set:function(e){this._onValidatedObserver&&this.onValidatedObservable.remove(this._onValidatedObserver),this._onValidatedObserver=this.onValidatedObservable.add(e)},enumerable:!1,configurable:!0}),t.prototype.dispose=function(){this._loader&&(this._loader.dispose(),this._loader=null);for(var e=0,t=this._requests;e<t.length;e++)t[e].abort();this._requests.length=0,delete this._progressCallback,this.preprocessUrlAsync=function(e){return Promise.resolve(e)},this.onMeshLoadedObservable.clear(),this.onSkinLoadedObservable.clear(),this.onTextureLoadedObservable.clear(),this.onMaterialLoadedObservable.clear(),this.onCameraLoadedObservable.clear(),this.onCompleteObservable.clear(),this.onExtensionLoadedObservable.clear(),this.onDisposeObservable.notifyObservers(void 0),this.onDisposeObservable.clear()},t.prototype.loadFile=function(e,t,n,r,o,a,i,s){var l=this;if(ArrayBuffer.isView(t))return this._loadBinary(e,t,n,r,i,s),null;this._progressCallback=o;var u=t.name||f.Tools.GetFilename(t);if(a){if(this.useRangeRequests){this.validate&&f.Logger.Warn("glTF validation is not supported when range requests are enabled");var c={abort:function(){},onCompleteObservable:new f.Observable},d={readAsync:function(n,r){return new Promise((function(o,a){l._loadFile(e,t,(function(e){o(new Uint8Array(e))}),!0,(function(e){a(e)}),(function(e){e.setRequestHeader("Range","bytes=".concat(n,"-").concat(n+r-1))}))}))},byteLength:0};return this._unpackBinaryAsync(new f.DataReader(d)).then((function(e){c.onCompleteObservable.notifyObservers(c),r(e)}),i?function(e){return i(void 0,e)}:void 0),c}return this._loadFile(e,t,(function(t){l._validate(e,new Uint8Array(t,0,t.byteLength),n,u),l._unpackBinaryAsync(new f.DataReader({readAsync:function(e,n){return O(t,e,n)},byteLength:t.byteLength})).then((function(e){r(e)}),i?function(e){return i(void 0,e)}:void 0)}),!0,i)}return this._loadFile(e,t,(function(t){try{l._validate(e,t,n,u),r({json:l._parseJson(t)})}catch(e){i&&i()}}),!1,i)},t.prototype._loadBinary=function(e,t,n,r,o,a){this._validate(e,new Uint8Array(t.buffer,t.byteOffset,t.byteLength),n,a),this._unpackBinaryAsync(new f.DataReader({readAsync:function(e,n){return function(e,t,n){try{if(t<0||t>=e.byteLength)throw new RangeError("Offset is out of range.");if(t+n>e.byteLength)throw new RangeError("Length is out of range.");return Promise.resolve(new Uint8Array(e.buffer,e.byteOffset+t,n))}catch(e){return Promise.reject(e)}}(t,e,n)},byteLength:t.byteLength})).then((function(e){r(e)}),o?function(e){return o(void 0,e)}:void 0)},t.prototype.importMeshAsync=function(e,t,n,r,o,a){var i=this;return Promise.resolve().then((function(){return i.onParsedObservable.notifyObservers(n),i.onParsedObservable.clear(),i._log("Loading ".concat(a||"")),i._loader=i._getLoader(n),i._loader.importMeshAsync(e,t,null,n,r,o,a)}))},t.prototype.loadAsync=function(e,t,n,r,o){var a=this;return Promise.resolve().then((function(){return a.onParsedObservable.notifyObservers(t),a.onParsedObservable.clear(),a._log("Loading ".concat(o||"")),a._loader=a._getLoader(t),a._loader.loadAsync(e,t,n,r,o)}))},t.prototype.loadAssetContainerAsync=function(e,t,n,r,o){var a=this;return Promise.resolve().then((function(){a.onParsedObservable.notifyObservers(t),a.onParsedObservable.clear(),a._log("Loading ".concat(o||"")),a._loader=a._getLoader(t);var i=new f.AssetContainer(e),s=[];a.onMaterialLoadedObservable.add((function(e){s.push(e)}));var l=[];a.onTextureLoadedObservable.add((function(e){l.push(e)}));var u=[];a.onCameraLoadedObservable.add((function(e){u.push(e)}));var c=[];return a.onMeshLoadedObservable.add((function(e){e.morphTargetManager&&c.push(e.morphTargetManager)})),a._loader.importMeshAsync(null,e,i,t,n,r,o).then((function(e){return Array.prototype.push.apply(i.geometries,e.geometries),Array.prototype.push.apply(i.meshes,e.meshes),Array.prototype.push.apply(i.particleSystems,e.particleSystems),Array.prototype.push.apply(i.skeletons,e.skeletons),Array.prototype.push.apply(i.animationGroups,e.animationGroups),Array.prototype.push.apply(i.materials,s),Array.prototype.push.apply(i.textures,l),Array.prototype.push.apply(i.lights,e.lights),Array.prototype.push.apply(i.transformNodes,e.transformNodes),Array.prototype.push.apply(i.cameras,u),Array.prototype.push.apply(i.morphTargetManagers,c),i}))}))},t.prototype.canDirectLoad=function(e){return function(e){return-1!==e.indexOf("asset")&&-1!==e.indexOf("version")||e.startsWith("data:base64,"+A)||e.startsWith("data:;base64,"+A)||e.startsWith("data:application/octet-stream;base64,"+A)||e.startsWith("data:model/gltf-binary;base64,"+A)}(e)},t.prototype.directLoad=function(e,t){if(t.startsWith("base64,"+A)||t.startsWith(";base64,"+A)||t.startsWith("application/octet-stream;base64,"+A)||t.startsWith("model/gltf-binary;base64,"+A)){var n=(0,f.DecodeBase64UrlToBinary)(t);return this._validate(e,new Uint8Array(n,0,n.byteLength)),this._unpackBinaryAsync(new f.DataReader({readAsync:function(e,t){return O(n,e,t)},byteLength:n.byteLength}))}return this._validate(e,t),Promise.resolve({json:this._parseJson(t)})},t.prototype.createPlugin=function(e){return new t(e[_])},Object.defineProperty(t.prototype,"loaderState",{get:function(){return this._state},enumerable:!1,configurable:!0}),t.prototype.whenCompleteAsync=function(){var e=this;return new Promise((function(t,n){e.onCompleteObservable.addOnce((function(){t()})),e.onErrorObservable.addOnce((function(e){n(e)}))}))},t.prototype._setState=function(e){this._state!==e&&(this._state=e,this.onLoaderStateChangedObservable.notifyObservers(this._state),this._log(b[this._state]))},t.prototype._loadFile=function(e,t,n,r,o,a){var i=this,s=e._loadFile(t,n,(function(e){i._onProgress(e,s)}),!0,r,o,a);return s.onCompleteObservable.add((function(){s._lengthComputable=!0,s._total=s._loaded})),this._requests.push(s),s},t.prototype._onProgress=function(e,t){if(this._progressCallback){t._lengthComputable=e.lengthComputable,t._loaded=e.loaded,t._total=e.total;for(var n=!0,r=0,o=0,a=0,i=this._requests;a<i.length;a++){var s=i[a];if(void 0===s._lengthComputable||void 0===s._loaded||void 0===s._total)return;n=n&&s._lengthComputable,r+=s._loaded,o+=s._total}this._progressCallback({lengthComputable:n,loaded:r,total:n?o:0})}},t.prototype._validate=function(e,t,n,r){var o=this;void 0===n&&(n=""),void 0===r&&(r=""),this.validate&&(this._startPerformanceCounter("Validate JSON"),y.ValidateAsync(t,n,r,(function(t){return o.preprocessUrlAsync(n+t).then((function(t){return e._loadFileAsync(t,void 0,!0,!0).then((function(e){return new Uint8Array(e,0,e.byteLength)}))}))})).then((function(e){o._endPerformanceCounter("Validate JSON"),o.onValidatedObservable.notifyObservers(e),o.onValidatedObservable.clear()}),(function(e){o._endPerformanceCounter("Validate JSON"),f.Tools.Warn("Failed to validate: ".concat(e.message)),o.onValidatedObservable.clear()})))},t.prototype._getLoader=function(e){var n=e.json.asset||{};this._log("Asset version: ".concat(n.version)),n.minVersion&&this._log("Asset minimum version: ".concat(n.minVersion)),n.generator&&this._log("Asset generator: ".concat(n.generator));var r=t._parseVersion(n.version);if(!r)throw new Error("Invalid version: "+n.version);if(void 0!==n.minVersion){var o=t._parseVersion(n.minVersion);if(!o)throw new Error("Invalid minimum version: "+n.minVersion);if(t._compareVersion(o,{major:2,minor:0})>0)throw new Error("Incompatible minimum version: "+n.minVersion)}var a={1:t._CreateGLTF1Loader,2:t._CreateGLTF2Loader}[r.major];if(!a)throw new Error("Unsupported version: "+n.version);return a(this)},t.prototype._parseJson=function(e){this._startPerformanceCounter("Parse JSON"),this._log("JSON length: ".concat(e.length));var t=JSON.parse(e);return this._endPerformanceCounter("Parse JSON"),t},t.prototype._unpackBinaryAsync=function(e){var t=this;return this._startPerformanceCounter("Unpack Binary"),e.loadAsync(20).then((function(){var n=e.readUint32();if(1179937895!==n)throw new f.RuntimeError("Unexpected magic: "+n,f.ErrorCodes.GLTFLoaderUnexpectedMagicError);var r=e.readUint32();t.loggingEnabled&&t._log("Binary version: ".concat(r));var o,a=e.readUint32();switch(t.useRangeRequests||a===e.buffer.byteLength||f.Logger.Warn("Length in header does not match actual data length: ".concat(a," != ").concat(e.buffer.byteLength)),r){case 1:o=t._unpackBinaryV1Async(e,a);break;case 2:o=t._unpackBinaryV2Async(e,a);break;default:throw new Error("Unsupported version: "+r)}return t._endPerformanceCounter("Unpack Binary"),o}))},t.prototype._unpackBinaryV1Async=function(e,t){var n=e.readUint32(),r=e.readUint32();if(0!==r)throw new Error("Unexpected content format: ".concat(r));var o=t-e.byteOffset,a={json:this._parseJson(e.readString(n)),bin:null};if(0!==o){var i=e.byteOffset;a.bin={readAsync:function(t,n){return e.buffer.readAsync(i+t,n)},byteLength:o}}return Promise.resolve(a)},t.prototype._unpackBinaryV2Async=function(e,t){var n=this,r=1313821514,o=e.readUint32();if(e.readUint32()!==r)throw new Error("First chunk format is not JSON");return e.byteOffset+o===t?e.loadAsync(o).then((function(){return{json:n._parseJson(e.readString(o)),bin:null}})):e.loadAsync(o+8).then((function(){var a={json:n._parseJson(e.readString(o)),bin:null},i=function(){var n=e.readUint32();switch(e.readUint32()){case r:throw new Error("Unexpected JSON chunk");case 5130562:var o=e.byteOffset;a.bin={readAsync:function(t,n){return e.buffer.readAsync(o+t,n)},byteLength:n},e.skipBytes(n);break;default:e.skipBytes(n)}return e.byteOffset!==t?e.loadAsync(8).then(i):Promise.resolve(a)};return i()}))},t._parseVersion=function(e){if("1.0"===e||"1.0.1"===e)return{major:1,minor:0};var t=(e+"").match(/^(\d+)\.(\d+)/);return t?{major:parseInt(t[1]),minor:parseInt(t[2])}:null},t._compareVersion=function(e,t){return e.major>t.major?1:e.major<t.major?-1:e.minor>t.minor?1:e.minor<t.minor?-1:0},t.prototype._logOpen=function(e){this._log(e),this._logIndentLevel++},t.prototype._logClose=function(){--this._logIndentLevel},t.prototype._logEnabled=function(e){var n=t._logSpaces.substring(0,2*this._logIndentLevel);f.Logger.Log("".concat(n).concat(e))},t.prototype._logDisabled=function(e){},t.prototype._startPerformanceCounterEnabled=function(e){f.Tools.StartPerformanceCounter(e)},t.prototype._startPerformanceCounterDisabled=function(e){},t.prototype._endPerformanceCounterEnabled=function(e){f.Tools.EndPerformanceCounter(e)},t.prototype._endPerformanceCounterDisabled=function(e){},t.IncrementalLoading=!0,t.HomogeneousCoordinates=!1,t._logSpaces=" ",t}(function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.extensionOptions={},t.preprocessUrlAsync=function(e){return Promise.resolve(e)},t}return c(t,e),t.prototype.copyFrom=function(e){var t,n,r,o,a,i,s,l,u,c,d,f,p,h,m,v,b,y,A,_,g,O,E,L,T,N;e&&(this.alwaysComputeBoundingBox=null!==(t=e.alwaysComputeBoundingBox)&&void 0!==t?t:this.alwaysComputeBoundingBox,this.alwaysComputeSkeletonRootNode=null!==(n=e.alwaysComputeSkeletonRootNode)&&void 0!==n?n:this.alwaysComputeSkeletonRootNode,this.animationStartMode=null!==(r=e.animationStartMode)&&void 0!==r?r:this.animationStartMode,this.capturePerformanceCounters=null!==(o=e.capturePerformanceCounters)&&void 0!==o?o:this.capturePerformanceCounters,this.compileMaterials=null!==(a=e.compileMaterials)&&void 0!==a?a:this.compileMaterials,this.compileShadowGenerators=null!==(i=e.compileShadowGenerators)&&void 0!==i?i:this.compileShadowGenerators,this.coordinateSystemMode=null!==(s=e.coordinateSystemMode)&&void 0!==s?s:this.coordinateSystemMode,this.createInstances=null!==(l=e.createInstances)&&void 0!==l?l:this.createInstances,this.customRootNode=e.customRootNode,this.extensionOptions=null!==(u=e.extensionOptions)&&void 0!==u?u:this.extensionOptions,this.loadAllMaterials=null!==(c=e.loadAllMaterials)&&void 0!==c?c:this.loadAllMaterials,this.loadMorphTargets=null!==(d=e.loadMorphTargets)&&void 0!==d?d:this.loadMorphTargets,this.loadNodeAnimations=null!==(f=e.loadNodeAnimations)&&void 0!==f?f:this.loadNodeAnimations,this.loadOnlyMaterials=null!==(p=e.loadOnlyMaterials)&&void 0!==p?p:this.loadOnlyMaterials,this.loadSkins=null!==(h=e.loadSkins)&&void 0!==h?h:this.loadSkins,this.loggingEnabled=null!==(m=e.loggingEnabled)&&void 0!==m?m:this.loggingEnabled,this.onCameraLoaded=e.onCameraLoaded,this.onMaterialLoaded=e.onMaterialLoaded,this.onMeshLoaded=e.onMeshLoaded,this.onParsed=e.onParsed,this.onSkinLoaded=e.onSkinLoaded,this.onTextureLoaded=e.onTextureLoaded,this.onValidated=e.onValidated,this.preprocessUrlAsync=null!==(v=e.preprocessUrlAsync)&&void 0!==v?v:this.preprocessUrlAsync,this.skipMaterials=null!==(b=e.skipMaterials)&&void 0!==b?b:this.skipMaterials,this.targetFps=null!==(y=e.targetFps)&&void 0!==y?y:this.targetFps,this.transparencyAsCoverage=null!==(A=e.transparencyAsCoverage)&&void 0!==A?A:this.transparencyAsCoverage,this.useClipPlane=null!==(_=e.useClipPlane)&&void 0!==_?_:this.useClipPlane,this.useGltfTextureNames=null!==(g=e.useGltfTextureNames)&&void 0!==g?g:this.useGltfTextureNames,this.useOpenPBR=null!==(O=e.useOpenPBR)&&void 0!==O?O:this.useOpenPBR,this.useRangeRequests=null!==(E=e.useRangeRequests)&&void 0!==E?E:this.useRangeRequests,this.useSRGBBuffers=null!==(L=e.useSRGBBuffers)&&void 0!==L?L:this.useSRGBBuffers,this.validate=null!==(T=e.validate)&&void 0!==T?T:this.validate,this.dontUseTransmissionHelper=null!==(N=e.dontUseTransmissionHelper)&&void 0!==N?N:this.dontUseTransmissionHelper)},t}(E));(0,f.RegisterSceneLoaderPlugin)(new T);var N,S,C,M,x,R,w,P,I=void 0!==r.g?r.g:"undefined"!=typeof window?window:void 0;if(void 0!==I){for(var B in I.BABYLON=I.BABYLON||{},i)I.BABYLON[B]=i[B];for(var B in a)I.BABYLON[B]=a[B]}!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"}(N||(N={})),function(e){e[e.FRAGMENT=35632]="FRAGMENT",e[e.VERTEX=35633]="VERTEX"}(S||(S={})),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"}(C||(C={})),function(e){e[e.CLAMP_TO_EDGE=33071]="CLAMP_TO_EDGE",e[e.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",e[e.REPEAT=10497]="REPEAT"}(M||(M={})),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"}(x||(x={})),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"}(R||(R={})),function(e){e[e.FRONT=1028]="FRONT",e[e.BACK=1029]="BACK",e[e.FRONT_AND_BACK=1032]="FRONT_AND_BACK"}(w||(w={})),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"}(P||(P={}));var F,V=function(){function e(){}return e.SetMatrix=function(e,t,n,r,o){var a=null;if("MODEL"===n.semantic?a=t.getWorldMatrix():"PROJECTION"===n.semantic?a=e.getProjectionMatrix():"VIEW"===n.semantic?a=e.getViewMatrix():"MODELVIEWINVERSETRANSPOSE"===n.semantic?a=f.Matrix.Transpose(t.getWorldMatrix().multiply(e.getViewMatrix()).invert()):"MODELVIEW"===n.semantic?a=t.getWorldMatrix().multiply(e.getViewMatrix()):"MODELVIEWPROJECTION"===n.semantic?a=t.getWorldMatrix().multiply(e.getTransformMatrix()):"MODELINVERSE"===n.semantic?a=t.getWorldMatrix().invert():"VIEWINVERSE"===n.semantic?a=e.getViewMatrix().invert():"PROJECTIONINVERSE"===n.semantic?a=e.getProjectionMatrix().invert():"MODELVIEWINVERSE"===n.semantic?a=t.getWorldMatrix().multiply(e.getViewMatrix()).invert():"MODELVIEWPROJECTIONINVERSE"===n.semantic?a=t.getWorldMatrix().multiply(e.getTransformMatrix()).invert():"MODELINVERSETRANSPOSE"===n.semantic&&(a=f.Matrix.Transpose(t.getWorldMatrix().invert())),a)switch(n.type){case C.FLOAT_MAT2:o.setMatrix2x2(r,f.Matrix.GetAsMatrix2x2(a));break;case C.FLOAT_MAT3:o.setMatrix3x3(r,f.Matrix.GetAsMatrix3x3(a));break;case C.FLOAT_MAT4:o.setMatrix(r,a)}},e.SetUniform=function(e,t,n,r){switch(r){case C.FLOAT:return e.setFloat(t,n),!0;case C.FLOAT_VEC2:return e.setVector2(t,f.Vector2.FromArray(n)),!0;case C.FLOAT_VEC3:return e.setVector3(t,f.Vector3.FromArray(n)),!0;case C.FLOAT_VEC4:return e.setVector4(t,f.Vector4.FromArray(n)),!0;default:return!1}},e.GetWrapMode=function(e){switch(e){case M.CLAMP_TO_EDGE:return f.Texture.CLAMP_ADDRESSMODE;case M.MIRRORED_REPEAT:return f.Texture.MIRROR_ADDRESSMODE;case M.REPEAT:default:return f.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 x.LINEAR:case x.LINEAR_MIPMAP_NEAREST:case x.LINEAR_MIPMAP_LINEAR:return f.Texture.TRILINEAR_SAMPLINGMODE;case x.NEAREST:case x.NEAREST_MIPMAP_NEAREST:return f.Texture.NEAREST_SAMPLINGMODE;default:return f.Texture.BILINEAR_SAMPLINGMODE}},e.GetBufferFromBufferView=function(e,t,n,r,o){n=t.byteOffset+n;var a=e.loadedBufferViews[t.buffer];if(n+r>a.byteLength)throw new Error("Buffer access is out of range");var i=a.buffer;switch(n+=a.byteOffset,o){case N.BYTE:return new Int8Array(i,n,r);case N.UNSIGNED_BYTE:return new Uint8Array(i,n,r);case N.SHORT:return new Int16Array(i,n,r);case N.UNSIGNED_SHORT:return new Uint16Array(i,n,r);default:return new Float32Array(i,n,r)}},e.GetBufferFromAccessor=function(t,n){var r=t.bufferViews[n.bufferView],o=n.count*e.GetByteStrideFromType(n);return e.GetBufferFromBufferView(t,r,n.byteOffset,o,n.componentType)},e.DecodeBufferToText=function(e){for(var t="",n=e.byteLength,r=0;r<n;++r)t+=String.fromCharCode(e[r]);return t},e.GetDefaultMaterial=function(t){if(!e._DefaultMaterial){f.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"),f.Effect.ShadersStore.GLTFDefaultMaterialPixelShader=["precision highp float;","","uniform vec4 u_emission;","","void main(void)","{"," gl_FragColor = u_emission;","}"].join("\n");var n={attributes:["position"],uniforms:["worldView","projection","u_emission"],samplers:new Array,needAlphaBlending:!1};e._DefaultMaterial=new f.ShaderMaterial("GLTFDefaultMaterial",t,{vertex:"GLTFDefaultMaterial",fragment:"GLTFDefaultMaterial"},n),e._DefaultMaterial.setColor4("u_emission",new f.Color4(.5,.5,.5,1))}return e._DefaultMaterial},e._DefaultMaterial=null,e}();!function(e){e[e.IDENTIFIER=1]="IDENTIFIER",e[e.UNKNOWN=2]="UNKNOWN",e[e.END_OF_INPUT=3]="END_OF_INPUT"}(F||(F={}));var D=function(){function e(e){this._pos=0,this.currentToken=F.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 F.END_OF_INPUT;if(this.currentString=this.read(),this.currentToken=F.UNKNOWN,"_"===this.currentString||this.isLetterOrDigitPattern.test(this.currentString))for(this.currentToken=F.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}(),k=["MODEL","VIEW","PROJECTION","MODELVIEW","MODELVIEWPROJECTION","JOINTMATRIX"],U=["world","view","projection","worldView","worldViewProjection","mBones"],G=["translation","rotation","scale"],j=["position","rotationQuaternion","scaling"],H=function(e,t,n){for(var r in e){var o=e[r];n[t][r]=o}},W=function(e){if(e)for(var t=0;t<e.length/2;t++)e[2*t+1]=1-e[2*t+1]},Y=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 t=Number(e.semantic.split("_")[1]);return"uv"+(0===t?"":t+1)}return null},J=function(e){var t=null;if(e.translation||e.rotation||e.scale){var n=f.Vector3.FromArray(e.scale||[1,1,1]),r=f.Quaternion.FromArray(e.rotation||[0,0,0,1]),o=f.Vector3.FromArray(e.translation||[0,0,0]);t=f.Matrix.Compose(n,r,o)}else t=f.Matrix.FromArray(e.matrix);return t},q=function(e,t,n,r){for(var o=0;o<r.bones.length;o++)if(r.bones[o].name===n)return r.bones[o];var a=e.nodes;for(var i in a){var s=a[i];if(s.jointName){var l=s.children;for(o=0;o<l.length;o++){var u=e.nodes[l[o]];if(u.jointName&&u.jointName===n){var c=J(s),d=new f.Bone(s.name||"",r,q(e,t,s.jointName,r),c);return d.id=i,d}}}}return null},Z=function(e,t){for(var n=0;n<e.length;n++)for(var r=e[n],o=0;o<r.node.children.length;o++)if(r.node.children[o]===t)return r.bone;return null},K=function(e,t){var n=e.nodes,r=n[t];if(r)return{node:r,id:t};for(var o in n)if((r=n[o]).jointName===t)return{node:r,id:o};return null},Q=function(e,t){for(var n=0;n<e.jointNames.length;n++)if(e.jointNames[n]===t)return!0;return!1},X=function(e,t,n,r,o){if(o||(e.scene._blockEntityCollection=!!e.assetContainer,(o=new f.Mesh(t.name||"",e.scene))._parentContainer=e.assetContainer,e.scene._blockEntityCollection=!1,o.id=r),!t.babylonNode)return o;for(var a,i=[],s=null,l=[],u=[],c=[],d=[],p=0;p<n.length;p++){var h=n[p];if(x=e.meshes[h])for(var m=0;m<x.primitives.length;m++){var v=new f.VertexData,b=x.primitives[m];b.mode;var y=b.attributes,A=null,_=null;for(var g in y)if(A=e.accessors[y[g]],_=V.GetBufferFromAccessor(e,A),"NORMAL"===g)v.normals=new Float32Array(_.length),v.normals.set(_);else if("POSITION"===g){if(T.HomogeneousCoordinates){v.positions=new Float32Array(_.length-_.length/4);for(var O=0;O<_.length;O+=4)v.positions[O]=_[O],v.positions[O+1]=_[O+1],v.positions[O+2]=_[O+2]}else v.positions=new Float32Array(_.length),v.positions.set(_);u.push(v.positions.length)}else if(-1!==g.indexOf("TEXCOORD_")){var E=Number(g.split("_")[1]),L=f.VertexBuffer.UVKind+(0===E?"":E+1),N=new Float32Array(_.length);N.set(_),W(N),v.set(N,L)}else"JOINT"===g?(v.matricesIndices=new Float32Array(_.length),v.matricesIndices.set(_)):"WEIGHT"===g?(v.matricesWeights=new Float32Array(_.length),v.matricesWeights.set(_)):"COLOR"===g&&(v.colors=new Float32Array(_.length),v.colors.set(_));if(A=e.accessors[b.indices])_=V.GetBufferFromAccessor(e,A),v.indices=new Int32Array(_.length),v.indices.set(_),d.push(v.indices.length);else{var S=[];for(O=0;O<v.positions.length/3;O++)S.push(O);v.indices=new Int32Array(S),d.push(v.indices.length)}s?s.merge(v):s=v;var C=e.scene.getMaterialById(b.material);i.push(null===C?V.GetDefaultMaterial(e.scene):C),l.push(0===l.length?0:l[l.length-1]+u[u.length-2]),c.push(0===c.length?0:c[c.length-1]+d[d.length-2])}}e.scene._blockEntityCollection=!!e.assetContainer,i.length>1?(a=new f.MultiMaterial("multimat"+r,e.scene)).subMaterials=i:a=new f.StandardMaterial("multimat"+r,e.scene),1===i.length&&(a=i[0]),a._parentContainer=e.assetContainer,o.material||(o.material=a),new f.Geometry(r,e.scene,s,!1,o),o.computeWorldMatrix(!0),e.scene._blockEntityCollection=!1,o.subMeshes=[];var M=0;for(p=0;p<n.length;p++){var x;if(h=n[p],x=e.meshes[h])for(m=0;m<x.primitives.length;m++)x.primitives[m].mode,f.SubMesh.AddToMesh(M,l[M],u[M],c[M],d[M],o,o,!0),M++}return o},z=function(e,t,n,r){e.position&&(e.position=t),(e.rotationQuaternion||e.rotation)&&(e.rotationQuaternion=n),e.scaling&&(e.scaling=r)},$=function(e,t,n){var r=null;if(e.importOnlyMeshes&&(t.skin||t.meshes)&&e.importMeshesNames&&e.importMeshesNames.length>0&&-1===e.importMeshesNames.indexOf(t.name||""))return null;if(t.skin){if(t.meshes){var o=e.skins[t.skin];(a=X(e,t,t.meshes,n,t.babylonNode)).skeleton=e.scene.getLastSkeletonById(t.skin),null===a.skeleton&&(a.skeleton=function(e,t,n,r){if(r||(r=new f.Skeleton(t.name||"","",e.scene)),!t.babylonSkeleton)return r;var o=[],a=[];!function(e,t,n,r){for(var o in e.nodes){var a=e.nodes[o],i=o;if(a.jointName&&!Q(n,a.jointName)){var s=J(a),l=new f.Bone(a.name||"",t,null,s);l.id=i,r.push({bone:l,node:a,id:i})}}for(var u=0;u<r.length;u++)for(var c=r[u],d=c.node.children,p=0;p<d.length;p++){for(var h=null,m=0;m<r.length;m++)if(r[m].id===d[p]){h=r[m];break}h&&(h.bone._parent=c.bone,c.bone.children.push(h.bone))}}(e,r,t,o),r.bones=[];for(var i=0;i<t.jointNames.length;i++)if(_=K(e,t.jointNames[i])){var s=_.node;if(s){var l=_.id,u=e.scene.getBoneById(l);if(u)r.bones.push(u);else{for(var c=!1,d=null,p=0;p<i;p++){var h=K(e,t.jointNames[p]);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]===l){d=q(e,t,t.jointNames[p],r),c=!0;break}if(c)break}}else f.Tools.Warn("Joint named "+t.jointNames[p]+" does not exist when looking for parent")}}var y=J(s);!d&&o.length>0&&(d=Z(o,l))&&-1===a.indexOf(d)&&a.push(d),new f.Bone(s.jointName||"",r,d,y).id=l}}else f.Tools.Warn("Joint named "+t.jointNames[i]+" does not exist")}var A=r.bones;for(r.bones=[],i=0;i<t.jointNames.length;i++){var _;if(_=K(e,t.jointNames[i]))for(p=0;p<A.length;p++)if(A[p].id===_.id){r.bones.push(A[p]);break}}for(r.prepare(),i=0;i<a.length;i++)r.bones.push(a[i]);return r}(e,o,0,o.babylonSkeleton),o.babylonSkeleton||(o.babylonSkeleton=a.skeleton)),r=a}}else if(t.meshes){var a;r=a=X(e,t,t.mesh?[t.mesh]:t.meshes,n,t.babylonNode)}else if(!t.light||t.babylonNode||e.importOnlyMeshes){if(t.camera&&!t.babylonNode&&!e.importOnlyMeshes){var i=e.cameras[t.camera];if(i){if(e.scene._blockEntityCollection=!!e.assetContainer,"orthographic"===i.type){var s=new f.FreeCamera(t.camera,f.Vector3.Zero(),e.scene,!1);s.name=t.name||"",s.mode=f.Camera.ORTHOGRAPHIC_CAMERA,s.attachControl(),r=s,s._parentContainer=e.assetContainer}else if("perspective"===i.type){var l=i[i.type],u=new f.FreeCamera(t.camera,f.Vector3.Zero(),e.scene,!1);u.name=t.name||"",u.attachControl(),l.aspectRatio||(l.aspectRatio=e.scene.getEngine().getRenderWidth()/e.scene.getEngine().getRenderHeight()),l.znear&&l.zfar&&(u.maxZ=l.zfar,u.minZ=l.znear),r=u,u._parentContainer=e.assetContainer}e.scene._blockEntityCollection=!1}}}else{var c=e.lights[t.light];if(c)if("ambient"===c.type){var d=c[c.type],p=new f.HemisphericLight(t.light,f.Vector3.Zero(),e.scene);p.name=t.name||"",d.color&&(p.diffuse=f.Color3.FromArray(d.color)),r=p}else if("directional"===c.type){var h=c[c.type],m=new f.DirectionalLight(t.light,f.Vector3.Zero(),e.scene);m.name=t.name||"",h.color&&(m.diffuse=f.Color3.FromArray(h.color)),r=m}else if("point"===c.type){var v=c[c.type],b=new f.PointLight(t.light,f.Vector3.Zero(),e.scene);b.name=t.name||"",v.color&&(b.diffuse=f.Color3.FromArray(v.color)),r=b}else if("spot"===c.type){var y=c[c.type],A=new f.SpotLight(t.light,f.Vector3.Zero(),f.Vector3.Zero(),0,0,e.scene);A.name=t.name||"",y.color&&(A.diffuse=f.Color3.FromArray(y.color)),y.fallOfAngle&&(A.angle=y.fallOfAngle),y.fallOffExponent&&(A.exponent=y.fallOffExponent),r=A}}if(!t.jointName){if(t.babylonNode)return t.babylonNode;if(null===r){e.scene._blockEntityCollection=!!e.assetContainer;var _=new f.Mesh(t.name||"",e.scene);_._parentContainer=e.assetContainer,e.scene._blockEntityCollection=!1,t.babylonNode=_,r=_}}if(null!==r){if(t.matrix&&r instanceof f.Mesh)!function(e,t){if(t.matrix){var n=new f.Vector3(0,0,0),r=new f.Quaternion,o=new f.Vector3(0,0,0);f.Matrix.FromArray(t.matrix).decompose(o,r,n),z(e,n,r,o)}else t.translation&&t.rotation&&t.scale&&z(e,f.Vector3.FromArray(t.translation),f.Quaternion.FromArray(t.rotation),f.Vector3.FromArray(t.scale));e.computeWorldMatrix(!0)}(r,t);else{var g=t.translation||[0,0,0],O=t.rotation||[0,0,0,1],E=t.scale||[1,1,1];z(r,f.Vector3.FromArray(g),f.Quaternion.FromArray(O),f.Vector3.FromArray(E))}r.updateCache(!0),t.babylonNode=r}return r},ee=function(e,t,n,r){void 0===r&&(r=!1);var o=e.nodes[t],a=null;if(r=!(e.importOnlyMeshes&&!r&&e.importMeshesNames)||-1!==e.importMeshesNames.indexOf(o.name||"")||0===e.importMeshesNames.length,!o.jointName&&r&&null!==(a=$(e,o,t))&&(a.id=t,a.parent=n),o.children)for(var i=0;i<o.children.length;i++)ee(e,o.children[i],a,r)},te=function(e){var t=e.currentScene;if(t)for(var n=0;n<t.nodes.length;n++)ee(e,t.nodes[n],null);else for(var r in e.scenes)for(t=e.scenes[r],n=0;n<t.nodes.length;n++)ee(e,t.nodes[n],null);for(function(e){for(var t in e.animations){var n=e.animations[t];if(n.channels&&n.samplers)for(var r=null,o=0;o<n.channels.length;o++){var a=n.channels[o],i=n.samplers[a.sampler];if(i){var s=null,l=null;n.parameters?(s=n.parameters[i.input],l=n.parameters[i.output]):(s=i.input,l=i.output);var u=V.GetBufferFromAccessor(e,e.accessors[s]),c=V.GetBufferFromAccessor(e,e.accessors[l]),d=a.target.id,p=e.scene.getNodeById(d);if(null===p&&(p=e.scene.getNodeByName(d)),null!==p){var h=p instanceof f.Bone,m=a.target.path,v=G.indexOf(m);-1!==v&&(m=j[v]);var b=f.Animation.ANIMATIONTYPE_MATRIX;h||("rotationQuaternion"===m?(b=f.Animation.ANIMATIONTYPE_QUATERNION,p.rotationQuaternion=new f.Quaternion):b=f.Animation.ANIMATIONTYPE_VECTOR3);var y=null,A=[],_=0,g=!1;h&&r&&r.getKeys().length===u.length&&(y=r,g=!0),g||(e.scene._blockEntityCollection=!!e.assetContainer,y=new f.Animation(t,h?"_matrix":m,1,b,f.Animation.ANIMATIONLOOPMODE_CYCLE),e.scene._blockEntityCollection=!1);for(var O=0;O<u.length;O++){var E=null;if("rotationQuaternion"===m?(E=f.Quaternion.FromArray([c[_],c[_+1],c[_+2],c[_+3]]),_+=4):(E=f.Vector3.FromArray([c[_],c[_+1],c[_+2]]),_+=3),h){var L=p,T=f.Vector3.Zero(),N=new f.Quaternion,S=f.Vector3.Zero(),C=L.getBaseMatrix();g&&r&&(C=r.getKeys()[O].value),C.decompose(S,N,T),"position"===m?T=E:"rotationQuaternion"===m?N=E:S=E,E=f.Matrix.Compose(S,N,T)}g?r&&(r.getKeys()[O].value=E):A.push({frame:u[O],value:E})}!g&&y&&(y.setKeys(A),p.animations.push(y)),r=y,e.scene.stopAnimation(p),e.scene.beginAnimation(p,0,u[u.length-1],!0,1)}else f.Tools.Warn("Creating animation named "+t+". But cannot find node named "+d+" to attach to")}}}}(e),n=0;n<e.scene.skeletons.length;n++){var o=e.scene.skeletons[n];e.scene.beginAnimation(o,0,Number.MAX_VALUE,!0,1)}},ne=function(e,t,n){for(var r in t.uniforms){var o=t.uniforms[r],a=t.parameters[o];if(e.currentIdentifier===r&&a.semantic&&!a.source&&!a.node){var i=k.indexOf(a.semantic);if(-1!==i)return delete n[r],U[i]}}return e.currentIdentifier},re=function(e){for(var t in e.materials)ie.LoadMaterialAsync(e,t,(function(){}),(function(){}))},oe=function(){function e(){}return e.CreateRuntime=function(e,t,n){var r={extensions:{},accessors:{},buffers:{},bufferViews:{},meshes:{},lights:{},cameras:{},nodes:{},images:{},textures:{},shaders:{},programs:{},samplers:{},techniques:{},materials:{},animations:{},skins:{},extensionsUsed:[],scenes:{},buffersCount:0,shaderscount:0,scene:t,rootUrl:n,loadedBufferCount:0,loadedBufferViews:{},loadedShaderCount:0,importOnlyMeshes:!1,dummyNodes:[],assetContainer:null};return e.extensions&&H(e.extensions,"extensions",r),e.extensionsUsed&&H(e.extensionsUsed,"extensionsUsed",r),e.buffers&&function(e,t){for(var n in e){var r=e[n];t.buffers[n]=r,t.buffersCount++}}(e.buffers,r),e.bufferViews&&H(e.bufferViews,"bufferViews",r),e.accessors&&H(e.accessors,"accessors",r),e.meshes&&H(e.meshes,"meshes",r),e.lights&&H(e.lights,"lights",r),e.cameras&&H(e.cameras,"cameras",r),e.nodes&&H(e.nodes,"nodes",r),e.images&&H(e.images,"images",r),e.textures&&H(e.textures,"textures",r),e.shaders&&function(e,t){for(var n in e){var r=e[n];t.shaders[n]=r,t.shaderscount++}}(e.shaders,r),e.programs&&H(e.programs,"programs",r),e.samplers&&H(e.samplers,"samplers",r),e.techniques&&H(e.techniques,"techniques",r),e.materials&&H(e.materials,"materials",r),e.animations&&H(e.animations,"animations",r),e.skins&&H(e.skins,"skins",r),e.scenes&&(r.scenes=e.scenes),e.scene&&e.scenes&&(r.currentScene=e.scenes[e.scene]),r},e.LoadBufferAsync=function(e,t,n,r,o){var a=e.buffers[t];f.Tools.IsBase64(a.uri)?setTimeout((function(){return n(new Uint8Array(f.Tools.DecodeBase64(a.uri)))})):f.Tools.LoadFile(e.rootUrl+a.uri,(function(e){return n(new Uint8Array(e))}),o,void 0,!0,(function(e){e&&r(e.status+" "+e.statusText)}))},e.LoadTextureBufferAsync=function(e,t,n,r){var o=e.textures[t];if(o&&o.source)if(o.babylonTexture)n(null);else{var a=e.images[o.source];f.Tools.IsBase64(a.uri)?setTimeout((function(){return n(new Uint8Array(f.Tools.DecodeBase64(a.uri)))})):f.Tools.LoadFile(e.rootUrl+a.uri,(function(e){return n(new Uint8Array(e))}),void 0,void 0,!0,(function(e){e&&r(e.status+" "+e.statusText)}))}else r("")},e.CreateTextureAsync=function(e,t,n,r){var o=e.textures[t];if(o.babylonTexture)r(o.babylonTexture);else{var a=e.samplers[o.sampler],i=a.minFilter===x.NEAREST_MIPMAP_NEAREST||a.minFilter===x.NEAREST_MIPMAP_LINEAR||a.minFilter===x.LINEAR_MIPMAP_NEAREST||a.minFilter===x.LINEAR_MIPMAP_LINEAR,s=f.Texture.BILINEAR_SAMPLINGMODE,l=null==n?new Blob:new Blob([n]),u=URL.createObjectURL(l),c=function(){return URL.revokeObjectURL(u)},d=new f.Texture(u,e.scene,!i,!0,s,c,c);void 0!==a.wrapS&&(d.wrapU=V.GetWrapMode(a.wrapS)),void 0!==a.wrapT&&(d.wrapV=V.GetWrapMode(a.wrapT)),d.name=t,o.babylonTexture=d,r(d)}},e.LoadShaderStringAsync=function(e,t,n,r){var o=e.shaders[t];if(f.Tools.IsBase64(o.uri)){var a=atob(o.uri.split(",")[1]);n&&n(a)}else f.Tools.LoadFile(e.rootUrl+o.uri,n,void 0,void 0,!1,(function(e){e&&r&&r(e.status+" "+e.statusText)}))},e.LoadMaterialAsync=function(e,t,n,r){var o=e.materials[t];if(o.technique){var a=e.techniques[o.technique];if(!a){e.scene._blockEntityCollection=!!e.assetContainer;var i=new f.StandardMaterial(t,e.scene);return i._parentContainer=e.assetContainer,e.scene._blockEntityCollection=!1,i.diffuseColor=new f.Color3(.5,.5,.5),i.sideOrientation=f.Material.CounterClockWiseSideOrientation,void n(i)}var s=e.programs[a.program],l=a.states,u=f.Effect.ShadersStore[s.vertexShader+"VertexShader"],c=f.Effect.ShadersStore[s.fragmentShader+"PixelShader"],d="",p="",h=new D(u),m=new D(c),v={},b=[],y=[],A=[];for(var _ in a.uniforms){var g=a.uniforms[_],O=a.parameters[g];if(v[_]=O,!O.semantic||O.node||O.source)O.type===C.SAMPLER_2D?A.push(_):b.push(_);else{var E=k.indexOf(O.semantic);-1!==E?(b.push(U[E]),delete v[_]):b.push(_)}}for(var L in a.attributes){var T=a.attributes[L];if((M=a.parameters[T]).semantic){var N=Y(M);N&&y.push(N)}}for(;!h.isEnd()&&h.getNextToken();)if(h.currentToken===F.IDENTIFIER){var S=!1;for(var L in a.attributes){T=a.attributes[L];var M=a.parameters[T];if(h.currentIdentifier===L&&M.semantic){d+=Y(M),S=!0;break}}S||(d+=ne(h,a,v))}else d+=h.currentString;for(;!m.isEnd()&&m.getNextToken();)m.currentToken===F.IDENTIFIER?p+=ne(m,a,v):p+=m.currentString;var x={vertex:s.vertexShader+t,fragment:s.fragmentShader+t},R={attributes:y,uniforms:b,samplers:A,needAlphaBlending:l&&l.enable&&-1!==l.enable.indexOf(3042)};f.Effect.ShadersStore[s.vertexShader+t+"VertexShader"]=d,f.Effect.ShadersStore[s.fragmentShader+t+"PixelShader"]=p;var I=new f.ShaderMaterial(t,e.scene,x,R);if(I.onError=function(e,t,n){return function(r,o){t.dispose(!0),n("Cannot compile program named "+e.name+". Error: "+o+". Default material will be applied")}}(s,I,r),I.onCompiled=function(e,t,n,r,o,a){return function(i){!function(e,t,n,r,o){var a=r.values||n.parameters,i=n.uniforms,s=function(n){var s=o[n],l=s.type,u=a[i[n]];if(void 0===u&&(u=s.value),!u)return"continue";var c=function(e){return function(n){s.value&&e&&(t.setTexture(e,n),delete o[e])}};l===C.SAMPLER_2D?ie.LoadTextureAsync(e,r.values?u:s.value,c(n),(function(){return c(null)})):s.value&&V.SetUniform(t,n,r.values?u:s.value,l)&&delete o[n]};for(var l in o)s(l)}(e,t,n,r,o),t.onBind=function(i){!function(e,t,n,r,o,a,i){var s=a.values||o.parameters;for(var l in n){var u=n[l],c=u.type;if(c===C.FLOAT_MAT2||c===C.FLOAT_MAT3||c===C.FLOAT_MAT4)if(!u.semantic||u.source||u.node){if(u.semantic&&(u.source||u.node)){var d=t.scene.getNodeByName(u.source||u.node||"");if(null===d&&(d=t.scene.getNodeById(u.source||u.node||"")),null===d)continue;V.SetMatrix(t.scene,d,u,l,r.getEffect())}}else V.SetMatrix(t.scene,e,u,l,r.getEffect());else{var f=s[o.uniforms[l]];if(!f)continue;if(c===C.SAMPLER_2D){var p=t.textures[a.values?f:u.value].babylonTexture;if(null==p)continue;r.getEffect().setTexture(l,p)}else V.SetUniform(r.getEffect(),l,f,c)}}i(r)}(i,e,o,t,n,r,a)}}}(e,I,a,o,v,n),I.sideOrientation=f.Material.CounterClockWiseSideOrientation,l&&l.functions){var B=l.functions;B.cullFace&&B.cullFace[0]!==w.BACK&&(I.backFaceCulling=!1);var G=B.blendFuncSeparate;G&&(G[0]===P.SRC_ALPHA&&G[1]===P.ONE_MINUS_SRC_ALPHA&&G[2]===P.ONE&&G[3]===P.ONE?I.alphaMode=f.Constants.ALPHA_COMBINE:G[0]===P.ONE&&G[1]===P.ONE&&G[2]===P.ZERO&&G[3]===P.ONE?I.alphaMode=f.Constants.ALPHA_ONEONE:G[0]===P.SRC_ALPHA&&G[1]===P.ONE&&G[2]===P.ZERO&&G[3]===P.ONE?I.alphaMode=f.Constants.ALPHA_ADD:G[0]===P.ZERO&&G[1]===P.ONE_MINUS_SRC_COLOR&&G[2]===P.ONE&&G[3]===P.ONE?I.alphaMode=f.Constants.ALPHA_SUBTRACT:G[0]===P.DST_COLOR&&G[1]===P.ZERO&&G[2]===P.ONE&&G[3]===P.ONE?I.alphaMode=f.Constants.ALPHA_MULTIPLY:G[0]===P.SRC_ALPHA&&G[1]===P.ONE_MINUS_SRC_COLOR&&G[2]===P.ONE&&G[3]===P.ONE&&(I.alphaMode=f.Constants.ALPHA_MAXIMIZED))}}else r&&r("No technique found.")},e}(),ae=function(){function e(){}return e.RegisterExtension=function(t){e.Extensions[t.name]?f.Tools.Error('Tool with the same name "'+t.name+'" already exists'):e.Extensions[t.name]=t},e.prototype.dispose=function(){},e.prototype._importMeshAsync=function(e,t,n,r,o,a,i,s){var l=this;return t.useRightHandedSystem=!0,ie.LoadRuntimeAsync(t,n,r,(function(t){t.assetContainer=o,t.importOnlyMeshes=!0,""===e?t.importMeshesNames=[]:"string"==typeof e?t.importMeshesNames=[e]:!e||e instanceof Array?(t.importMeshesNames=[],f.Tools.Warn("Argument meshesNames must be of type string or string[]")):t.importMeshesNames=[e],l._createNodes(t);var n=[],r=[];for(var i in t.nodes){var s=t.nodes[i];s.babylonNode instanceof f.AbstractMesh&&n.push(s.babylonNode)}for(var u in t.skins){var c=t.skins[u];c.babylonSkeleton instanceof f.Skeleton&&r.push(c.babylonSkeleton)}l._loadBuffersAsync(t,(function(){l._loadShadersAsync(t,(function(){re(t),te(t),!T.IncrementalLoading&&a&&a(n,r)}))})),T.IncrementalLoading&&a&&a(n,r)}),s),!0},e.prototype.importMeshAsync=function(e,t,n,r,o,a){var i=this;return new Promise((function(s,l){i._importMeshAsync(e,t,r,o,n,(function(e,t){s({meshes:e,particleSystems:[],skeletons:t,animationGroups:[],lights:[],transformNodes:[],geometries:[],spriteManagers:[]})}),a,(function(e){l(new Error(e))}))}))},e.prototype._loadAsync=function(e,t,n,r,o,a){var i=this;e.useRightHandedSystem=!0,ie.LoadRuntimeAsync(e,t,n,(function(e){ie.LoadRuntimeExtensionsAsync(e,(function(){i._createNodes(e),i._loadBuffersAsync(e,(function(){i._loadShadersAsync(e,(function(){re(e),te(e),T.IncrementalLoading||r()}))})),T.IncrementalLoading&&r()}),a)}),a)},e.prototype.loadAsync=function(e,t,n,r){return o=this,a=void 0,s=function(){var o=this;return function(e,t){var n,r,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=s(0),i.throw=s(1),i.return=s(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(l){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(n=1,r&&(o=2&s[0]?r.return:s[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,s[1])).done)return o;switch(r=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,r=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){a.label=s[1];break}if(6===s[0]&&a.label<o[1]){a.label=o[1],o=s;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(s);break}o[2]&&a.ops.pop(),a.trys.pop();continue}s=t.call(e,a)}catch(e){s=[6,e],r=0}finally{n=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,l])}}}(this,(function(a){switch(a.label){case 0:return[4,new Promise((function(a,i){o._loadAsync(e,t,n,(function(){a()}),r,(function(e){i(new Error(e))}))}))];case 1:return[2,a.sent()]}}))},new((i=void 0)||(i=Promise))((function(e,t){function n(e){try{l(s.next(e))}catch(e){t(e)}}function r(e){try{l(s.throw(e))}catch(e){t(e)}}function l(t){var o;t.done?e(t.value):(o=t.value,o instanceof i?o:new i((function(e){e(o)}))).then(n,r)}l((s=s.apply(o,a||[])).next())}));var o,a,i,s},e.prototype._loadShadersAsync=function(e,t){var n=!1,r=function(n,r){ie.LoadShaderStringAsync(e,n,(function(o){o instanceof ArrayBuffer||(e.loadedShaderCount++,o&&(f.Effect.ShadersStore[n+(r.type===S.VERTEX?"VertexShader":"PixelShader")]=o),e.loadedShaderCount===e.shaderscount&&t())}),(function(){f.Tools.Error("Error when loading shader program named "+n+" located at "+r.uri)}))};for(var o in e.shaders){n=!0;var a=e.shaders[o];a?r.bind(this,o,a)():f.Tools.Error("No shader named: "+o)}n||t()},e.prototype._loadBuffersAsync=function(e,t){var n=!1,r=function(n,r){ie.LoadBufferAsync(e,n,(function(o){e.loadedBufferCount++,o&&(o.byteLength!=e.buffers[n].byteLength&&f.Tools.Error("Buffer named "+n+" is length "+o.byteLength+". Expected: "+r.byteLength),e.loadedBufferViews[n]=o),e.loadedBufferCount===e.buffersCount&&t()}),(function(){f.Tools.Error("Error when loading buffer named "+n+" located at "+r.uri)}))};for(var o in e.buffers){n=!0;var a=e.buffers[o];a?r.bind(this,o,a)():f.Tools.Error("No buffer named: "+o)}n||t()},e.prototype._createNodes=function(e){var t=e.currentScene;if(t)for(var n=0;n<t.nodes.length;n++)ee(e,t.nodes[n],null);else for(var r in e.scenes)for(t=e.scenes[r],n=0;n<t.nodes.length;n++)ee(e,t.nodes[n],null)},e.Extensions={},e}(),ie=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,t,n,r,o){return!1},e.prototype.loadRuntimeExtensionsAsync=function(e,t,n){return!1},e.prototype.loadBufferAsync=function(e,t,n,r,o){return!1},e.prototype.loadTextureBufferAsync=function(e,t,n,r){return!1},e.prototype.createTextureAsync=function(e,t,n,r,o){return!1},e.prototype.loadShaderStringAsync=function(e,t,n,r){return!1},e.prototype.loadMaterialAsync=function(e,t,n,r){return!1},e.LoadRuntimeAsync=function(t,n,r,o,a){e._ApplyExtensions((function(e){return e.loadRuntimeAsync(t,n,r,o,a)}),(function(){setTimeout((function(){o&&o(oe.CreateRuntime(n.json,t,r))}))}))},e.LoadRuntimeExtensionsAsync=function(t,n,r){e._ApplyExtensions((function(e){return e.loadRuntimeExtensionsAsync(t,n,r)}),(function(){setTimeout((function(){n()}))}))},e.LoadBufferAsync=function(t,n,r,o,a){e._ApplyExtensions((function(e){return e.loadBufferAsync(t,n,r,o,a)}),(function(){oe.LoadBufferAsync(t,n,r,o,a)}))},e.LoadTextureAsync=function(t,n,r,o){e._LoadTextureBufferAsync(t,n,(function(a){a&&e._CreateTextureAsync(t,n,a,r,o)}),o)},e.LoadShaderStringAsync=function(t,n,r,o){e._ApplyExtensions((function(e){return e.loadShaderStringAsync(t,n,r,o)}),(function(){oe.LoadShaderStringAsync(t,n,r,o)}))},e.LoadMaterialAsync=function(t,n,r,o){e._ApplyExtensions((function(e){return e.loadMaterialAsync(t,n,r,o)}),(function(){oe.LoadMaterialAsync(t,n,r,o)}))},e._LoadTextureBufferAsync=function(t,n,r,o){e._ApplyExtensions((function(e){return e.loadTextureBufferAsync(t,n,r,o)}),(function(){oe.LoadTextureBufferAsync(t,n,r,o)}))},e._CreateTextureAsync=function(t,n,r,o,a){e._ApplyExtensions((function(e){return e.createTextureAsync(t,n,r,o,a)}),(function(){oe.CreateTextureAsync(t,n,r,o)}))},e._ApplyExtensions=function(e,t){for(var n in ae.Extensions)if(e(ae.Extensions[n]))return;t()},e}();T._CreateGLTF1Loader=function(){return new ae};var se=function(e){function t(){return e.call(this,"KHR_binary_glTF")||this}return c(t,e),t.prototype.loadRuntimeAsync=function(e,t,n,r){var o=t.json.extensionsUsed;return!(!o||-1===o.indexOf(this.name)||!t.bin||(this._bin=t.bin,r(oe.CreateRuntime(t.json,e,n)),0))},t.prototype.loadBufferAsync=function(e,t,n,r){return-1!==e.extensionsUsed.indexOf(this.name)&&"binary_glTF"===t&&(this._bin.readAsync(0,this._bin.byteLength).then(n,(function(e){return r(e.message)})),!0)},t.prototype.loadTextureBufferAsync=function(e,t,n){var r=e.textures[t],o=e.images[r.source];if(!o.extensions||!(this.name in o.extensions))return!1;var a=o.extensions[this.name],i=e.bufferViews[a.bufferView];return n(V.GetBufferFromBufferView(e,i,0,i.byteLength,N.UNSIGNED_BYTE)),!0},t.prototype.loadShaderStringAsync=function(e,t,n){var r=e.shaders[t];if(!r.extensions||!(this.name in r.extensions))return!1;var o=r.extensions[this.name],a=e.bufferViews[o.bufferView],i=V.GetBufferFromBufferView(e,a,0,a.byteLength,N.UNSIGNED_BYTE);return setTimeout((function(){var e=V.DecodeBufferToText(i);n(e)})),!0},t}(ie);ae.RegisterExtension(new se);var le=function(e){function t(){return e.call(this,"KHR_materials_common")||this}return c(t,e),t.prototype.loadRuntimeExtensionsAsync=function(e){if(!e.extensions)return!1;var t=e.extensions[this.name];if(!t)return!1;var n=t.lights;if(n)for(var r in n){var o=n[r];switch(o.type){case"ambient":var a=new f.HemisphericLight(o.name,new f.Vector3(0,1,0),e.scene),i=o.ambient;i&&(a.diffuse=f.Color3.FromArray(i.color||[1,1,1]));break;case"point":var s=new f.PointLight(o.name,new f.Vector3(10,10,10),e.scene),l=o.point;l&&(s.diffuse=f.Color3.FromArray(l.color||[1,1,1]));break;case"directional":var u=new f.DirectionalLight(o.name,new f.Vector3(0,-1,0),e.scene),c=o.directional;c&&(u.diffuse=f.Color3.FromArray(c.color||[1,1,1]));break;case"spot":var d=o.spot;d&&(new f.SpotLight(o.name,new f.Vector3(0,10,0),new f.Vector3(0,-1,0),d.fallOffAngle||Math.PI,d.fallOffExponent||0,e.scene).diffuse=f.Color3.FromArray(d.color||[1,1,1]));break;default:f.Tools.Warn('GLTF Material Common extension: light type "'+o.type+"” not supported")}}return!1},t.prototype.loadMaterialAsync=function(e,t,n,r){var o=e.materials[t];if(!o||!o.extensions)return!1;var a=o.extensions[this.name];if(!a)return!1;var i=new f.StandardMaterial(t,e.scene);return i.sideOrientation=f.Material.CounterClockWiseSideOrientation,"CONSTANT"===a.technique&&(i.disableLighting=!0),i.backFaceCulling=void 0!==a.doubleSided&&!a.doubleSided,i.alpha=void 0===a.values.transparency?1:a.values.transparency,i.specularPower=void 0===a.values.shininess?0:a.values.shininess,"string"==typeof a.values.ambient?this._loadTexture(e,a.values.ambient,i,"ambientTexture",r):i.ambientColor=f.Color3.FromArray(a.values.ambient||[0,0,0]),"string"==typeof a.values.diffuse?this._loadTexture(e,a.values.diffuse,i,"diffuseTexture",r):i.diffuseColor=f.Color3.FromArray(a.values.diffuse||[0,0,0]),"string"==typeof a.values.emission?this._loadTexture(e,a.values.emission,i,"emissiveTexture",r):i.emissiveColor=f.Color3.FromArray(a.values.emission||[0,0,0]),"string"==typeof a.values.specular?this._loadTexture(e,a.values.specular,i,"specularTexture",r):i.specularColor=f.Color3.FromArray(a.values.specular||[0,0,0]),!0},t.prototype._loadTexture=function(e,t,n,r,o){oe.LoadTextureBufferAsync(e,t,(function(o){oe.CreateTextureAsync(e,t,o,(function(e){return n[r]=e}))}),o)},t}(ie);ae.RegisterExtension(new le);var ue=void 0!==r.g?r.g:"undefined"!=typeof window?window:void 0;if(void 0!==ue)for(var ce in ue.BABYLON=ue.BABYLON||{},ue.BABYLON.GLTF1=ue.BABYLON.GLTF1||{},s)ue.BABYLON.GLTF1[ce]=s[ce];const de=l;return o.default})()));
|
|
2
2
|
//# sourceMappingURL=babylon.glTF1FileLoader.min.js.map
|