babylonjs-loaders
Advanced tools
Comparing version 7.18.0 to 7.19.0
@@ -1,2 +0,2 @@ | ||
!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}},r={};function n(e){var o=r[e];if(void 0!==o)return o.exports;var a=r[e]={exports:{}};return t[e](a,a.exports,n),a.exports}n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var o={};n.d(o,{default:()=>ae});var a={};n.r(a),n.d(a,{GLTFValidation:()=>m});var i={};n.r(i),n.d(i,{GLTFFileLoader:()=>v,GLTFLoaderAnimationStartMode:()=>h,GLTFLoaderCoordinateSystemMode:()=>d,GLTFLoaderState:()=>p});var s={};n.r(s),n.d(s,{EBlendingFunction:()=>C,EComponentType:()=>A,ECullingType:()=>N,EParameterType:()=>E,EShaderType:()=>g,ETextureFilterType:()=>L,ETextureFormat:()=>T,ETextureWrapMode:()=>O,GLTFBinaryExtension:()=>te,GLTFLoader:()=>$,GLTFLoaderBase:()=>z,GLTFLoaderExtension:()=>ee,GLTFMaterialsCommonExtension:()=>re,GLTFUtils:()=>R});var l={};n.r(l),n.d(l,{GLTF1:()=>s,GLTFFileLoader:()=>v,GLTFLoaderAnimationStartMode:()=>h,GLTFLoaderCoordinateSystemMode:()=>d,GLTFLoaderState:()=>p,GLTFValidation:()=>m});var u=n(597);function c(e,t,r,n){var o={externalResourceFunction:n};return r&&(o.uri="file:"===t?r:t+r),ArrayBuffer.isView(e)?GLTFValidator.validateBytes(e,o):GLTFValidator.validateString(e,o)}function f(){var e=[];onmessage=function(t){var r=t.data;switch(r.id){case"init":importScripts(r.url);break;case"validate":c(r.data,r.rootUrl,r.fileName,(function(t){return new Promise((function(r,n){var o=e.length;e.push({resolve:r,reject:n}),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[r.index].resolve(r.value);break;case"getExternalResource.reject":e[r.index].reject(r.reason)}}}var d,h,p,m=function(){function e(){}return e.ValidateAsync=function(e,t,r,n){var o=this;return"function"==typeof Worker?new Promise((function(a,i){var s="".concat(c,"(").concat(f,")()"),l=URL.createObjectURL(new Blob([s],{type:"application/javascript"})),d=new Worker(l),h=function(e){d.removeEventListener("error",h),d.removeEventListener("message",p),i(e)},p=function(e){var t=e.data;switch(t.id){case"getExternalResource":n(t.uri).then((function(e){d.postMessage({id:"getExternalResource.resolve",index:t.index,value:e},[e.buffer])}),(function(e){d.postMessage({id:"getExternalResource.reject",index:t.index,reason:e})}));break;case"validate.resolve":d.removeEventListener("error",h),d.removeEventListener("message",p),a(t.value),d.terminate();break;case"validate.reject":d.removeEventListener("error",h),d.removeEventListener("message",p),i(t.reason),d.terminate()}};if(d.addEventListener("error",h),d.addEventListener("message",p),d.postMessage({id:"init",url:u.Tools.GetBabylonScriptURL(o.Configuration.url)}),ArrayBuffer.isView(e)){var m=e.slice();d.postMessage({id:"validate",data:m,rootUrl:t,fileName:r},[m.buffer])}else d.postMessage({id:"validate",data:e,rootUrl:t,fileName:r})})):(this._LoadScriptPromise||(this._LoadScriptPromise=u.Tools.LoadBabylonScriptAsync(this.Configuration.url)),this._LoadScriptPromise.then((function(){return c(e,t,r,n)})))},e.Configuration={url:"".concat(u.Tools._DefaultCdnUrl,"/gltf_validator.js")},e}();function b(e,t,r){try{return Promise.resolve(new Uint8Array(e,t,r))}catch(e){return Promise.reject(e)}}!function(e){e[e.AUTO=0]="AUTO",e[e.FORCE_RIGHT_HANDED=1]="FORCE_RIGHT_HANDED"}(d||(d={})),function(e){e[e.NONE=0]="NONE",e[e.FIRST=1]="FIRST",e[e.ALL=2]="ALL"}(h||(h={})),function(e){e[e.LOADING=0]="LOADING",e[e.READY=1]="READY",e[e.COMPLETE=2]="COMPLETE"}(p||(p={}));var v=function(){function e(){this.onParsedObservable=new u.Observable,this.coordinateSystemMode=d.AUTO,this.animationStartMode=h.FIRST,this.compileMaterials=!1,this.useClipPlane=!1,this.compileShadowGenerators=!1,this.transparencyAsCoverage=!1,this.useRangeRequests=!1,this.createInstances=!0,this.alwaysComputeBoundingBox=!1,this.loadAllMaterials=!1,this.loadOnlyMaterials=!1,this.skipMaterials=!1,this.useSRGBBuffers=!0,this.targetFps=60,this.alwaysComputeSkeletonRootNode=!1,this.preprocessUrlAsync=function(e){return Promise.resolve(e)},this.onMeshLoadedObservable=new u.Observable,this.onSkinLoadedObservable=new u.Observable,this.onTextureLoadedObservable=new u.Observable,this.onMaterialLoadedObservable=new u.Observable,this.onCameraLoadedObservable=new u.Observable,this.onCompleteObservable=new u.Observable,this.onErrorObservable=new u.Observable,this.onDisposeObservable=new u.Observable,this.onExtensionLoadedObservable=new u.Observable,this.validate=!1,this.onValidatedObservable=new u.Observable,this._loader=null,this._state=null,this._requests=new Array,this.name="gltf",this.extensions={".gltf":{isBinary:!1},".glb":{isBinary:!0}},this.onLoaderStateChangedObservable=new u.Observable,this._logIndentLevel=0,this._loggingEnabled=!1,this._log=this._logDisabled,this._capturePerformanceCounters=!1,this._startPerformanceCounter=this._startPerformanceCounterDisabled,this._endPerformanceCounter=this._endPerformanceCounterDisabled}return Object.defineProperty(e.prototype,"onParsed",{set:function(e){this._onParsedObserver&&this.onParsedObservable.remove(this._onParsedObserver),this._onParsedObserver=this.onParsedObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onMeshLoaded",{set:function(e){this._onMeshLoadedObserver&&this.onMeshLoadedObservable.remove(this._onMeshLoadedObserver),this._onMeshLoadedObserver=this.onMeshLoadedObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onTextureLoaded",{set:function(e){this._onTextureLoadedObserver&&this.onTextureLoadedObservable.remove(this._onTextureLoadedObserver),this._onTextureLoadedObserver=this.onTextureLoadedObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onMaterialLoaded",{set:function(e){this._onMaterialLoadedObserver&&this.onMaterialLoadedObservable.remove(this._onMaterialLoadedObserver),this._onMaterialLoadedObserver=this.onMaterialLoadedObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onCameraLoaded",{set:function(e){this._onCameraLoadedObserver&&this.onCameraLoadedObservable.remove(this._onCameraLoadedObserver),this._onCameraLoadedObserver=this.onCameraLoadedObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onComplete",{set:function(e){this._onCompleteObserver&&this.onCompleteObservable.remove(this._onCompleteObserver),this._onCompleteObserver=this.onCompleteObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onError",{set:function(e){this._onErrorObserver&&this.onErrorObservable.remove(this._onErrorObserver),this._onErrorObserver=this.onErrorObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onDispose",{set:function(e){this._onDisposeObserver&&this.onDisposeObservable.remove(this._onDisposeObserver),this._onDisposeObserver=this.onDisposeObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onExtensionLoaded",{set:function(e){this._onExtensionLoadedObserver&&this.onExtensionLoadedObservable.remove(this._onExtensionLoadedObserver),this._onExtensionLoadedObserver=this.onExtensionLoadedObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"loggingEnabled",{get:function(){return this._loggingEnabled},set:function(e){this._loggingEnabled!==e&&(this._loggingEnabled=e,this._loggingEnabled?this._log=this._logEnabled:this._log=this._logDisabled)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"capturePerformanceCounters",{get:function(){return this._capturePerformanceCounters},set:function(e){this._capturePerformanceCounters!==e&&(this._capturePerformanceCounters=e,this._capturePerformanceCounters?(this._startPerformanceCounter=this._startPerformanceCounterEnabled,this._endPerformanceCounter=this._endPerformanceCounterEnabled):(this._startPerformanceCounter=this._startPerformanceCounterDisabled,this._endPerformanceCounter=this._endPerformanceCounterDisabled))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onValidated",{set:function(e){this._onValidatedObserver&&this.onValidatedObservable.remove(this._onValidatedObserver),this._onValidatedObserver=this.onValidatedObservable.add(e)},enumerable:!1,configurable:!0}),e.prototype.dispose=function(){this._loader&&(this._loader.dispose(),this._loader=null);for(var e=0,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()},e.prototype.loadFile=function(e,t,r,n,o,a,i,s){var l=this;if(ArrayBuffer.isView(t))return this._loadBinary(e,t,r,n,i,s),null;this._progressCallback=o;var c=t.name||u.Tools.GetFilename(t);if(a){if(this.useRangeRequests){this.validate&&u.Logger.Warn("glTF validation is not supported when range requests are enabled");var f={abort:function(){},onCompleteObservable:new u.Observable},d={readAsync:function(r,n){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(r,"-").concat(r+n-1))}))}))},byteLength:0};return this._unpackBinaryAsync(new u.DataReader(d)).then((function(e){f.onCompleteObservable.notifyObservers(f),n(e)}),i?function(e){return i(void 0,e)}:void 0),f}return this._loadFile(e,t,(function(t){l._validate(e,new Uint8Array(t,0,t.byteLength),r,c),l._unpackBinaryAsync(new u.DataReader({readAsync:function(e,r){return b(t,e,r)},byteLength:t.byteLength})).then((function(e){n(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,r,c),n({json:l._parseJson(t)})}catch(e){i&&i()}}),!1,i)},e.prototype._loadBinary=function(e,t,r,n,o,a){this._validate(e,new Uint8Array(t.buffer,t.byteOffset,t.byteLength),r,a),this._unpackBinaryAsync(new u.DataReader({readAsync:function(e,r){return function(e,t,r){try{if(t<0||t>=e.byteLength)throw new RangeError("Offset is out of range.");if(t+r>e.byteLength)throw new RangeError("Length is out of range.");return Promise.resolve(new Uint8Array(e.buffer,e.byteOffset+t,r))}catch(e){return Promise.reject(e)}}(t,e,r)},byteLength:t.byteLength})).then((function(e){n(e)}),o?function(e){return o(void 0,e)}:void 0)},e.prototype.importMeshAsync=function(e,t,r,n,o,a){var i=this;return Promise.resolve().then((function(){return i.onParsedObservable.notifyObservers(r),i.onParsedObservable.clear(),i._log("Loading ".concat(a||"")),i._loader=i._getLoader(r),i._loader.importMeshAsync(e,t,null,r,n,o,a)}))},e.prototype.loadAsync=function(e,t,r,n,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,r,n,o)}))},e.prototype.loadAssetContainerAsync=function(e,t,r,n,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 u.AssetContainer(e),s=[];a.onMaterialLoadedObservable.add((function(e){s.push(e)}));var l=[];a.onTextureLoadedObservable.add((function(e){l.push(e)}));var c=[];a.onCameraLoadedObservable.add((function(e){c.push(e)}));var f=[];return a.onMeshLoadedObservable.add((function(e){e.morphTargetManager&&f.push(e.morphTargetManager)})),a._loader.importMeshAsync(null,e,i,t,r,n,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,c),Array.prototype.push.apply(i.morphTargetManagers,f),i}))}))},e.prototype.canDirectLoad=function(t){return-1!==t.indexOf("asset")&&-1!==t.indexOf("version")||t.startsWith("data:base64,"+e._MagicBase64Encoded)||t.startsWith("data:;base64,"+e._MagicBase64Encoded)||t.startsWith("data:application/octet-stream;base64,"+e._MagicBase64Encoded)||t.startsWith("data:model/gltf-binary;base64,"+e._MagicBase64Encoded)},e.prototype.directLoad=function(t,r){if(r.startsWith("base64,"+e._MagicBase64Encoded)||r.startsWith(";base64,"+e._MagicBase64Encoded)||r.startsWith("application/octet-stream;base64,"+e._MagicBase64Encoded)||r.startsWith("model/gltf-binary;base64,"+e._MagicBase64Encoded)){var n=(0,u.DecodeBase64UrlToBinary)(r);return this._validate(t,new Uint8Array(n,0,n.byteLength)),this._unpackBinaryAsync(new u.DataReader({readAsync:function(e,t){return b(n,e,t)},byteLength:n.byteLength}))}return this._validate(t,r),Promise.resolve({json:this._parseJson(r)})},e.prototype.createPlugin=function(){return new e},Object.defineProperty(e.prototype,"loaderState",{get:function(){return this._state},enumerable:!1,configurable:!0}),e.prototype.whenCompleteAsync=function(){var e=this;return new Promise((function(t,r){e.onCompleteObservable.addOnce((function(){t()})),e.onErrorObservable.addOnce((function(e){r(e)}))}))},e.prototype._setState=function(e){this._state!==e&&(this._state=e,this.onLoaderStateChangedObservable.notifyObservers(this._state),this._log(p[this._state]))},e.prototype._loadFile=function(e,t,r,n,o,a){var i=this,s=e._loadFile(t,r,(function(e){i._onProgress(e,s)}),!0,n,o,a);return s.onCompleteObservable.add((function(){s._lengthComputable=!0,s._total=s._loaded})),this._requests.push(s),s},e.prototype._onProgress=function(e,t){if(this._progressCallback){t._lengthComputable=e.lengthComputable,t._loaded=e.loaded,t._total=e.total;for(var r=!0,n=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;r=r&&s._lengthComputable,n+=s._loaded,o+=s._total}this._progressCallback({lengthComputable:r,loaded:n,total:r?o:0})}},e.prototype._validate=function(e,t,r,n){var o=this;void 0===r&&(r=""),void 0===n&&(n=""),this.validate&&(this._startPerformanceCounter("Validate JSON"),m.ValidateAsync(t,r,n,(function(t){return o.preprocessUrlAsync(r+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"),u.Tools.Warn("Failed to validate: ".concat(e.message)),o.onValidatedObservable.clear()})))},e.prototype._getLoader=function(t){var r=t.json.asset||{};this._log("Asset version: ".concat(r.version)),r.minVersion&&this._log("Asset minimum version: ".concat(r.minVersion)),r.generator&&this._log("Asset generator: ".concat(r.generator));var n=e._parseVersion(r.version);if(!n)throw new Error("Invalid version: "+r.version);if(void 0!==r.minVersion){var o=e._parseVersion(r.minVersion);if(!o)throw new Error("Invalid minimum version: "+r.minVersion);if(e._compareVersion(o,{major:2,minor:0})>0)throw new Error("Incompatible minimum version: "+r.minVersion)}var a={1:e._CreateGLTF1Loader,2:e._CreateGLTF2Loader}[n.major];if(!a)throw new Error("Unsupported version: "+r.version);return a(this)},e.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},e.prototype._unpackBinaryAsync=function(e){var t=this;return this._startPerformanceCounter("Unpack Binary"),e.loadAsync(20).then((function(){var r=e.readUint32();if(1179937895!==r)throw new u.RuntimeError("Unexpected magic: "+r,u.ErrorCodes.GLTFLoaderUnexpectedMagicError);var n=e.readUint32();t.loggingEnabled&&t._log("Binary version: ".concat(n));var o,a=e.readUint32();switch(t.useRangeRequests||a===e.buffer.byteLength||u.Logger.Warn("Length in header does not match actual data length: ".concat(a," != ").concat(e.buffer.byteLength)),n){case 1:o=t._unpackBinaryV1Async(e,a);break;case 2:o=t._unpackBinaryV2Async(e,a);break;default:throw new Error("Unsupported version: "+n)}return t._endPerformanceCounter("Unpack Binary"),o}))},e.prototype._unpackBinaryV1Async=function(e,t){var r=e.readUint32(),n=e.readUint32();if(0!==n)throw new Error("Unexpected content format: ".concat(n));var o=t-e.byteOffset,a={json:this._parseJson(e.readString(r)),bin:null};if(0!==o){var i=e.byteOffset;a.bin={readAsync:function(t,r){return e.buffer.readAsync(i+t,r)},byteLength:o}}return Promise.resolve(a)},e.prototype._unpackBinaryV2Async=function(e,t){var r=this,n=1313821514,o=e.readUint32();if(e.readUint32()!==n)throw new Error("First chunk format is not JSON");return e.byteOffset+o===t?e.loadAsync(o).then((function(){return{json:r._parseJson(e.readString(o)),bin:null}})):e.loadAsync(o+8).then((function(){var a={json:r._parseJson(e.readString(o)),bin:null},i=function(){var r=e.readUint32();switch(e.readUint32()){case n:throw new Error("Unexpected JSON chunk");case 5130562:var o=e.byteOffset;a.bin={readAsync:function(t,r){return e.buffer.readAsync(o+t,r)},byteLength:r},e.skipBytes(r);break;default:e.skipBytes(r)}return e.byteOffset!==t?e.loadAsync(8).then(i):Promise.resolve(a)};return i()}))},e._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},e._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},e.prototype._logOpen=function(e){this._log(e),this._logIndentLevel++},e.prototype._logClose=function(){--this._logIndentLevel},e.prototype._logEnabled=function(t){var r=e._logSpaces.substr(0,2*this._logIndentLevel);u.Logger.Log("".concat(r).concat(t))},e.prototype._logDisabled=function(e){},e.prototype._startPerformanceCounterEnabled=function(e){u.Tools.StartPerformanceCounter(e)},e.prototype._startPerformanceCounterDisabled=function(e){},e.prototype._endPerformanceCounterEnabled=function(e){u.Tools.EndPerformanceCounter(e)},e.prototype._endPerformanceCounterDisabled=function(e){},e.IncrementalLoading=!0,e.HomogeneousCoordinates=!1,e._MagicBase64Encoded="Z2xURg",e._logSpaces=" ",e}();u.SceneLoader&&u.SceneLoader.RegisterPlugin(new v);var y=void 0!==n.g?n.g:"undefined"!=typeof window?window:void 0;if(void 0!==y){for(var _ in y.BABYLON=y.BABYLON||{},i)y.BABYLON[_]=i[_];for(var _ in a)y.BABYLON[_]=a[_]}var A,g,E,O,L,T,N,C,M=function(e,t){return M=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},M(e,t)};function S(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}M(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}Object.create,Object.create,"function"==typeof SuppressedError&&SuppressedError,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"}(A||(A={})),function(e){e[e.FRAGMENT=35632]="FRAGMENT",e[e.VERTEX=35633]="VERTEX"}(g||(g={})),function(e){e[e.BYTE=5120]="BYTE",e[e.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",e[e.SHORT=5122]="SHORT",e[e.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",e[e.INT=5124]="INT",e[e.UNSIGNED_INT=5125]="UNSIGNED_INT",e[e.FLOAT=5126]="FLOAT",e[e.FLOAT_VEC2=35664]="FLOAT_VEC2",e[e.FLOAT_VEC3=35665]="FLOAT_VEC3",e[e.FLOAT_VEC4=35666]="FLOAT_VEC4",e[e.INT_VEC2=35667]="INT_VEC2",e[e.INT_VEC3=35668]="INT_VEC3",e[e.INT_VEC4=35669]="INT_VEC4",e[e.BOOL=35670]="BOOL",e[e.BOOL_VEC2=35671]="BOOL_VEC2",e[e.BOOL_VEC3=35672]="BOOL_VEC3",e[e.BOOL_VEC4=35673]="BOOL_VEC4",e[e.FLOAT_MAT2=35674]="FLOAT_MAT2",e[e.FLOAT_MAT3=35675]="FLOAT_MAT3",e[e.FLOAT_MAT4=35676]="FLOAT_MAT4",e[e.SAMPLER_2D=35678]="SAMPLER_2D"}(E||(E={})),function(e){e[e.CLAMP_TO_EDGE=33071]="CLAMP_TO_EDGE",e[e.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",e[e.REPEAT=10497]="REPEAT"}(O||(O={})),function(e){e[e.NEAREST=9728]="NEAREST",e[e.LINEAR=9728]="LINEAR",e[e.NEAREST_MIPMAP_NEAREST=9984]="NEAREST_MIPMAP_NEAREST",e[e.LINEAR_MIPMAP_NEAREST=9985]="LINEAR_MIPMAP_NEAREST",e[e.NEAREST_MIPMAP_LINEAR=9986]="NEAREST_MIPMAP_LINEAR",e[e.LINEAR_MIPMAP_LINEAR=9987]="LINEAR_MIPMAP_LINEAR"}(L||(L={})),function(e){e[e.ALPHA=6406]="ALPHA",e[e.RGB=6407]="RGB",e[e.RGBA=6408]="RGBA",e[e.LUMINANCE=6409]="LUMINANCE",e[e.LUMINANCE_ALPHA=6410]="LUMINANCE_ALPHA"}(T||(T={})),function(e){e[e.FRONT=1028]="FRONT",e[e.BACK=1029]="BACK",e[e.FRONT_AND_BACK=1032]="FRONT_AND_BACK"}(N||(N={})),function(e){e[e.ZERO=0]="ZERO",e[e.ONE=1]="ONE",e[e.SRC_COLOR=768]="SRC_COLOR",e[e.ONE_MINUS_SRC_COLOR=769]="ONE_MINUS_SRC_COLOR",e[e.DST_COLOR=774]="DST_COLOR",e[e.ONE_MINUS_DST_COLOR=775]="ONE_MINUS_DST_COLOR",e[e.SRC_ALPHA=770]="SRC_ALPHA",e[e.ONE_MINUS_SRC_ALPHA=771]="ONE_MINUS_SRC_ALPHA",e[e.DST_ALPHA=772]="DST_ALPHA",e[e.ONE_MINUS_DST_ALPHA=773]="ONE_MINUS_DST_ALPHA",e[e.CONSTANT_COLOR=32769]="CONSTANT_COLOR",e[e.ONE_MINUS_CONSTANT_COLOR=32770]="ONE_MINUS_CONSTANT_COLOR",e[e.CONSTANT_ALPHA=32771]="CONSTANT_ALPHA",e[e.ONE_MINUS_CONSTANT_ALPHA=32772]="ONE_MINUS_CONSTANT_ALPHA",e[e.SRC_ALPHA_SATURATE=776]="SRC_ALPHA_SATURATE"}(C||(C={}));var x,R=function(){function e(){}return e.SetMatrix=function(e,t,r,n,o){var a=null;if("MODEL"===r.semantic?a=t.getWorldMatrix():"PROJECTION"===r.semantic?a=e.getProjectionMatrix():"VIEW"===r.semantic?a=e.getViewMatrix():"MODELVIEWINVERSETRANSPOSE"===r.semantic?a=u.Matrix.Transpose(t.getWorldMatrix().multiply(e.getViewMatrix()).invert()):"MODELVIEW"===r.semantic?a=t.getWorldMatrix().multiply(e.getViewMatrix()):"MODELVIEWPROJECTION"===r.semantic?a=t.getWorldMatrix().multiply(e.getTransformMatrix()):"MODELINVERSE"===r.semantic?a=t.getWorldMatrix().invert():"VIEWINVERSE"===r.semantic?a=e.getViewMatrix().invert():"PROJECTIONINVERSE"===r.semantic?a=e.getProjectionMatrix().invert():"MODELVIEWINVERSE"===r.semantic?a=t.getWorldMatrix().multiply(e.getViewMatrix()).invert():"MODELVIEWPROJECTIONINVERSE"===r.semantic?a=t.getWorldMatrix().multiply(e.getTransformMatrix()).invert():"MODELINVERSETRANSPOSE"===r.semantic&&(a=u.Matrix.Transpose(t.getWorldMatrix().invert())),a)switch(r.type){case E.FLOAT_MAT2:o.setMatrix2x2(n,u.Matrix.GetAsMatrix2x2(a));break;case E.FLOAT_MAT3:o.setMatrix3x3(n,u.Matrix.GetAsMatrix3x3(a));break;case E.FLOAT_MAT4:o.setMatrix(n,a)}},e.SetUniform=function(e,t,r,n){switch(n){case E.FLOAT:return e.setFloat(t,r),!0;case E.FLOAT_VEC2:return e.setVector2(t,u.Vector2.FromArray(r)),!0;case E.FLOAT_VEC3:return e.setVector3(t,u.Vector3.FromArray(r)),!0;case E.FLOAT_VEC4:return e.setVector4(t,u.Vector4.FromArray(r)),!0;default:return!1}},e.GetWrapMode=function(e){switch(e){case O.CLAMP_TO_EDGE:return u.Texture.CLAMP_ADDRESSMODE;case O.MIRRORED_REPEAT:return u.Texture.MIRROR_ADDRESSMODE;case O.REPEAT:default:return u.Texture.WRAP_ADDRESSMODE}},e.GetByteStrideFromType=function(e){switch(e.type){case"VEC2":return 2;case"VEC3":return 3;case"VEC4":case"MAT2":return 4;case"MAT3":return 9;case"MAT4":return 16;default:return 1}},e.GetTextureFilterMode=function(e){switch(e){case L.LINEAR:case L.LINEAR_MIPMAP_NEAREST:case L.LINEAR_MIPMAP_LINEAR:return u.Texture.TRILINEAR_SAMPLINGMODE;case L.NEAREST:case L.NEAREST_MIPMAP_NEAREST:return u.Texture.NEAREST_SAMPLINGMODE;default:return u.Texture.BILINEAR_SAMPLINGMODE}},e.GetBufferFromBufferView=function(e,t,r,n,o){r=t.byteOffset+r;var a=e.loadedBufferViews[t.buffer];if(r+n>a.byteLength)throw new Error("Buffer access is out of range");var i=a.buffer;switch(r+=a.byteOffset,o){case A.BYTE:return new Int8Array(i,r,n);case A.UNSIGNED_BYTE:return new Uint8Array(i,r,n);case A.SHORT:return new Int16Array(i,r,n);case A.UNSIGNED_SHORT:return new Uint16Array(i,r,n);default:return new Float32Array(i,r,n)}},e.GetBufferFromAccessor=function(t,r){var n=t.bufferViews[r.bufferView],o=r.count*e.GetByteStrideFromType(r);return e.GetBufferFromBufferView(t,n,r.byteOffset,o,r.componentType)},e.DecodeBufferToText=function(e){for(var t="",r=e.byteLength,n=0;n<r;++n)t+=String.fromCharCode(e[n]);return t},e.GetDefaultMaterial=function(t){if(!e._DefaultMaterial){u.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"),u.Effect.ShadersStore.GLTFDefaultMaterialPixelShader=["precision highp float;","","uniform vec4 u_emission;","","void main(void)","{"," gl_FragColor = u_emission;","}"].join("\n");var r={attributes:["position"],uniforms:["worldView","projection","u_emission"],samplers:new Array,needAlphaBlending:!1};e._DefaultMaterial=new u.ShaderMaterial("GLTFDefaultMaterial",t,{vertex:"GLTFDefaultMaterial",fragment:"GLTFDefaultMaterial"},r),e._DefaultMaterial.setColor4("u_emission",new u.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"}(x||(x={}));var P=function(){function e(e){this._pos=0,this.currentToken=x.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 x.END_OF_INPUT;if(this.currentString=this.read(),this.currentToken=x.UNKNOWN,"_"===this.currentString||this.isLetterOrDigitPattern.test(this.currentString))for(this.currentToken=x.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}(),w=["MODEL","VIEW","PROJECTION","MODELVIEW","MODELVIEWPROJECTION","JOINTMATRIX"],I=["world","view","projection","worldView","worldViewProjection","mBones"],B=["translation","rotation","scale"],F=["position","rotationQuaternion","scaling"],V=function(e,t,r){for(var n in e){var o=e[n];r[t][n]=o}},D=function(e){if(e)for(var t=0;t<e.length/2;t++)e[2*t+1]=1-e[2*t+1]},U=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},k=function(e){var t=null;if(e.translation||e.rotation||e.scale){var r=u.Vector3.FromArray(e.scale||[1,1,1]),n=u.Quaternion.FromArray(e.rotation||[0,0,0,1]),o=u.Vector3.FromArray(e.translation||[0,0,0]);t=u.Matrix.Compose(r,n,o)}else t=u.Matrix.FromArray(e.matrix);return t},G=function(e,t,r,n){for(var o=0;o<n.bones.length;o++)if(n.bones[o].name===r)return n.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 c=e.nodes[l[o]];if(c.jointName&&c.jointName===r){var f=k(s),d=new u.Bone(s.name||"",n,G(e,t,s.jointName,n),f);return d.id=i,d}}}}return null},j=function(e,t){for(var r=0;r<e.length;r++)for(var n=e[r],o=0;o<n.node.children.length;o++)if(n.node.children[o]===t)return n.bone;return null},H=function(e,t){var r=e.nodes,n=r[t];if(n)return{node:n,id:t};for(var o in r)if((n=r[o]).jointName===t)return{node:n,id:o};return null},W=function(e,t){for(var r=0;r<e.jointNames.length;r++)if(e.jointNames[r]===t)return!0;return!1},Y=function(e,t,r,n,o){if(o||(e.scene._blockEntityCollection=!!e.assetContainer,(o=new u.Mesh(t.name||"",e.scene))._parentContainer=e.assetContainer,e.scene._blockEntityCollection=!1,o.id=n),!t.babylonNode)return o;for(var a,i=[],s=null,l=[],c=[],f=[],d=[],h=0;h<r.length;h++){var p=r[h];if(x=e.meshes[p])for(var m=0;m<x.primitives.length;m++){var b=new u.VertexData,y=x.primitives[m];y.mode;var _=y.attributes,A=null,g=null;for(var E in _)if(A=e.accessors[_[E]],g=R.GetBufferFromAccessor(e,A),"NORMAL"===E)b.normals=new Float32Array(g.length),b.normals.set(g);else if("POSITION"===E){if(v.HomogeneousCoordinates){b.positions=new Float32Array(g.length-g.length/4);for(var O=0;O<g.length;O+=4)b.positions[O]=g[O],b.positions[O+1]=g[O+1],b.positions[O+2]=g[O+2]}else b.positions=new Float32Array(g.length),b.positions.set(g);c.push(b.positions.length)}else if(-1!==E.indexOf("TEXCOORD_")){var L=Number(E.split("_")[1]),T=u.VertexBuffer.UVKind+(0===L?"":L+1),N=new Float32Array(g.length);N.set(g),D(N),b.set(N,T)}else"JOINT"===E?(b.matricesIndices=new Float32Array(g.length),b.matricesIndices.set(g)):"WEIGHT"===E?(b.matricesWeights=new Float32Array(g.length),b.matricesWeights.set(g)):"COLOR"===E&&(b.colors=new Float32Array(g.length),b.colors.set(g));if(A=e.accessors[y.indices])g=R.GetBufferFromAccessor(e,A),b.indices=new Int32Array(g.length),b.indices.set(g),d.push(b.indices.length);else{var C=[];for(O=0;O<b.positions.length/3;O++)C.push(O);b.indices=new Int32Array(C),d.push(b.indices.length)}s?s.merge(b):s=b;var M=e.scene.getMaterialById(y.material);i.push(null===M?R.GetDefaultMaterial(e.scene):M),l.push(0===l.length?0:l[l.length-1]+c[c.length-2]),f.push(0===f.length?0:f[f.length-1]+d[d.length-2])}}e.scene._blockEntityCollection=!!e.assetContainer,i.length>1?(a=new u.MultiMaterial("multimat"+n,e.scene)).subMaterials=i:a=new u.StandardMaterial("multimat"+n,e.scene),1===i.length&&(a=i[0]),a._parentContainer=e.assetContainer,o.material||(o.material=a),new u.Geometry(n,e.scene,s,!1,o),o.computeWorldMatrix(!0),e.scene._blockEntityCollection=!1,o.subMeshes=[];var S=0;for(h=0;h<r.length;h++){var x;if(p=r[h],x=e.meshes[p])for(m=0;m<x.primitives.length;m++)x.primitives[m].mode,u.SubMesh.AddToMesh(S,l[S],c[S],f[S],d[S],o,o,!0),S++}return o},J=function(e,t,r,n){e.position&&(e.position=t),(e.rotationQuaternion||e.rotation)&&(e.rotationQuaternion=r),e.scaling&&(e.scaling=n)},q=function(e,t,r){var n=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=Y(e,t,t.meshes,r,t.babylonNode)).skeleton=e.scene.getLastSkeletonById(t.skin),null===a.skeleton&&(a.skeleton=function(e,t,r,n){if(n||(n=new u.Skeleton(t.name||"","",e.scene)),!t.babylonSkeleton)return n;var o=[],a=[];!function(e,t,r,n){for(var o in e.nodes){var a=e.nodes[o],i=o;if(a.jointName&&!W(r,a.jointName)){var s=k(a),l=new u.Bone(a.name||"",t,null,s);l.id=i,n.push({bone:l,node:a,id:i})}}for(var c=0;c<n.length;c++)for(var f=n[c],d=f.node.children,h=0;h<d.length;h++){for(var p=null,m=0;m<n.length;m++)if(n[m].id===d[h]){p=n[m];break}p&&(p.bone._parent=f.bone,f.bone.children.push(p.bone))}}(e,n,t,o),n.bones=[];for(var i=0;i<t.jointNames.length;i++)if(A=H(e,t.jointNames[i])){var s=A.node;if(s){var l=A.id,c=e.scene.getBoneById(l);if(c)n.bones.push(c);else{for(var f=!1,d=null,h=0;h<i;h++){var p=H(e,t.jointNames[h]);if(p){var m=p.node;if(m){var b=m.children;if(b){f=!1;for(var v=0;v<b.length;v++)if(b[v]===l){d=G(e,t,t.jointNames[h],n),f=!0;break}if(f)break}}else u.Tools.Warn("Joint named "+t.jointNames[h]+" does not exist when looking for parent")}}var y=k(s);!d&&o.length>0&&(d=j(o,l))&&-1===a.indexOf(d)&&a.push(d),new u.Bone(s.jointName||"",n,d,y).id=l}}else u.Tools.Warn("Joint named "+t.jointNames[i]+" does not exist")}var _=n.bones;for(n.bones=[],i=0;i<t.jointNames.length;i++){var A;if(A=H(e,t.jointNames[i]))for(h=0;h<_.length;h++)if(_[h].id===A.id){n.bones.push(_[h]);break}}for(n.prepare(),i=0;i<a.length;i++)n.bones.push(a[i]);return n}(e,o,0,o.babylonSkeleton),o.babylonSkeleton||(o.babylonSkeleton=a.skeleton)),n=a}}else if(t.meshes){var a;n=a=Y(e,t,t.mesh?[t.mesh]:t.meshes,r,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 u.FreeCamera(t.camera,u.Vector3.Zero(),e.scene,!1);s.name=t.name||"",s.mode=u.Camera.ORTHOGRAPHIC_CAMERA,s.attachControl(),n=s,s._parentContainer=e.assetContainer}else if("perspective"===i.type){var l=i[i.type],c=new u.FreeCamera(t.camera,u.Vector3.Zero(),e.scene,!1);c.name=t.name||"",c.attachControl(),l.aspectRatio||(l.aspectRatio=e.scene.getEngine().getRenderWidth()/e.scene.getEngine().getRenderHeight()),l.znear&&l.zfar&&(c.maxZ=l.zfar,c.minZ=l.znear),n=c,c._parentContainer=e.assetContainer}e.scene._blockEntityCollection=!1}}}else{var f=e.lights[t.light];if(f)if("ambient"===f.type){var d=f[f.type],h=new u.HemisphericLight(t.light,u.Vector3.Zero(),e.scene);h.name=t.name||"",d.color&&(h.diffuse=u.Color3.FromArray(d.color)),n=h}else if("directional"===f.type){var p=f[f.type],m=new u.DirectionalLight(t.light,u.Vector3.Zero(),e.scene);m.name=t.name||"",p.color&&(m.diffuse=u.Color3.FromArray(p.color)),n=m}else if("point"===f.type){var b=f[f.type],v=new u.PointLight(t.light,u.Vector3.Zero(),e.scene);v.name=t.name||"",b.color&&(v.diffuse=u.Color3.FromArray(b.color)),n=v}else if("spot"===f.type){var y=f[f.type],_=new u.SpotLight(t.light,u.Vector3.Zero(),u.Vector3.Zero(),0,0,e.scene);_.name=t.name||"",y.color&&(_.diffuse=u.Color3.FromArray(y.color)),y.fallOfAngle&&(_.angle=y.fallOfAngle),y.fallOffExponent&&(_.exponent=y.fallOffExponent),n=_}}if(!t.jointName){if(t.babylonNode)return t.babylonNode;if(null===n){e.scene._blockEntityCollection=!!e.assetContainer;var A=new u.Mesh(t.name||"",e.scene);A._parentContainer=e.assetContainer,e.scene._blockEntityCollection=!1,t.babylonNode=A,n=A}}if(null!==n){if(t.matrix&&n instanceof u.Mesh)!function(e,t){if(t.matrix){var r=new u.Vector3(0,0,0),n=new u.Quaternion,o=new u.Vector3(0,0,0);u.Matrix.FromArray(t.matrix).decompose(o,n,r),J(e,r,n,o)}else t.translation&&t.rotation&&t.scale&&J(e,u.Vector3.FromArray(t.translation),u.Quaternion.FromArray(t.rotation),u.Vector3.FromArray(t.scale));e.computeWorldMatrix(!0)}(n,t);else{var g=t.translation||[0,0,0],E=t.rotation||[0,0,0,1],O=t.scale||[1,1,1];J(n,u.Vector3.FromArray(g),u.Quaternion.FromArray(E),u.Vector3.FromArray(O))}n.updateCache(!0),t.babylonNode=n}return n},Z=function(e,t,r,n){void 0===n&&(n=!1);var o=e.nodes[t],a=null;if(n=!(e.importOnlyMeshes&&!n&&e.importMeshesNames)||-1!==e.importMeshesNames.indexOf(o.name||"")||0===e.importMeshesNames.length,!o.jointName&&n&&null!==(a=q(e,o,t))&&(a.id=t,a.parent=r),o.children)for(var i=0;i<o.children.length;i++)Z(e,o.children[i],a,n)},K=function(e){var t=e.currentScene;if(t)for(var r=0;r<t.nodes.length;r++)Z(e,t.nodes[r],null);else for(var n in e.scenes)for(t=e.scenes[n],r=0;r<t.nodes.length;r++)Z(e,t.nodes[r],null);for(function(e){for(var t in e.animations){var r=e.animations[t];if(r.channels&&r.samplers)for(var n=null,o=0;o<r.channels.length;o++){var a=r.channels[o],i=r.samplers[a.sampler];if(i){var s=null,l=null;r.parameters?(s=r.parameters[i.input],l=r.parameters[i.output]):(s=i.input,l=i.output);var c=R.GetBufferFromAccessor(e,e.accessors[s]),f=R.GetBufferFromAccessor(e,e.accessors[l]),d=a.target.id,h=e.scene.getNodeById(d);if(null===h&&(h=e.scene.getNodeByName(d)),null!==h){var p=h instanceof u.Bone,m=a.target.path,b=B.indexOf(m);-1!==b&&(m=F[b]);var v=u.Animation.ANIMATIONTYPE_MATRIX;p||("rotationQuaternion"===m?(v=u.Animation.ANIMATIONTYPE_QUATERNION,h.rotationQuaternion=new u.Quaternion):v=u.Animation.ANIMATIONTYPE_VECTOR3);var y=null,_=[],A=0,g=!1;p&&n&&n.getKeys().length===c.length&&(y=n,g=!0),g||(e.scene._blockEntityCollection=!!e.assetContainer,y=new u.Animation(t,p?"_matrix":m,1,v,u.Animation.ANIMATIONLOOPMODE_CYCLE),e.scene._blockEntityCollection=!1);for(var E=0;E<c.length;E++){var O=null;if("rotationQuaternion"===m?(O=u.Quaternion.FromArray([f[A],f[A+1],f[A+2],f[A+3]]),A+=4):(O=u.Vector3.FromArray([f[A],f[A+1],f[A+2]]),A+=3),p){var L=h,T=u.Vector3.Zero(),N=new u.Quaternion,C=u.Vector3.Zero(),M=L.getBaseMatrix();g&&n&&(M=n.getKeys()[E].value),M.decompose(C,N,T),"position"===m?T=O:"rotationQuaternion"===m?N=O:C=O,O=u.Matrix.Compose(C,N,T)}g?n&&(n.getKeys()[E].value=O):_.push({frame:c[E],value:O})}!g&&y&&(y.setKeys(_),h.animations.push(y)),n=y,e.scene.stopAnimation(h),e.scene.beginAnimation(h,0,c[c.length-1],!0,1)}else u.Tools.Warn("Creating animation named "+t+". But cannot find node named "+d+" to attach to")}}}}(e),r=0;r<e.scene.skeletons.length;r++){var o=e.scene.skeletons[r];e.scene.beginAnimation(o,0,Number.MAX_VALUE,!0,1)}},Q=function(e,t,r){for(var n in t.uniforms){var o=t.uniforms[n],a=t.parameters[o];if(e.currentIdentifier===n&&a.semantic&&!a.source&&!a.node){var i=w.indexOf(a.semantic);if(-1!==i)return delete r[n],I[i]}}return e.currentIdentifier},X=function(e){for(var t in e.materials)ee.LoadMaterialAsync(e,t,(function(){}),(function(){}))},z=function(){function e(){}return e.CreateRuntime=function(e,t,r){var n={extensions:{},accessors:{},buffers:{},bufferViews:{},meshes:{},lights:{},cameras:{},nodes:{},images:{},textures:{},shaders:{},programs:{},samplers:{},techniques:{},materials:{},animations:{},skins:{},extensionsUsed:[],scenes:{},buffersCount:0,shaderscount:0,scene:t,rootUrl:r,loadedBufferCount:0,loadedBufferViews:{},loadedShaderCount:0,importOnlyMeshes:!1,dummyNodes:[],assetContainer:null};return e.extensions&&V(e.extensions,"extensions",n),e.extensionsUsed&&V(e.extensionsUsed,"extensionsUsed",n),e.buffers&&function(e,t){for(var r in e){var n=e[r];t.buffers[r]=n,t.buffersCount++}}(e.buffers,n),e.bufferViews&&V(e.bufferViews,"bufferViews",n),e.accessors&&V(e.accessors,"accessors",n),e.meshes&&V(e.meshes,"meshes",n),e.lights&&V(e.lights,"lights",n),e.cameras&&V(e.cameras,"cameras",n),e.nodes&&V(e.nodes,"nodes",n),e.images&&V(e.images,"images",n),e.textures&&V(e.textures,"textures",n),e.shaders&&function(e,t){for(var r in e){var n=e[r];t.shaders[r]=n,t.shaderscount++}}(e.shaders,n),e.programs&&V(e.programs,"programs",n),e.samplers&&V(e.samplers,"samplers",n),e.techniques&&V(e.techniques,"techniques",n),e.materials&&V(e.materials,"materials",n),e.animations&&V(e.animations,"animations",n),e.skins&&V(e.skins,"skins",n),e.scenes&&(n.scenes=e.scenes),e.scene&&e.scenes&&(n.currentScene=e.scenes[e.scene]),n},e.LoadBufferAsync=function(e,t,r,n,o){var a=e.buffers[t];u.Tools.IsBase64(a.uri)?setTimeout((function(){return r(new Uint8Array(u.Tools.DecodeBase64(a.uri)))})):u.Tools.LoadFile(e.rootUrl+a.uri,(function(e){return r(new Uint8Array(e))}),o,void 0,!0,(function(e){e&&n(e.status+" "+e.statusText)}))},e.LoadTextureBufferAsync=function(e,t,r,n){var o=e.textures[t];if(o&&o.source)if(o.babylonTexture)r(null);else{var a=e.images[o.source];u.Tools.IsBase64(a.uri)?setTimeout((function(){return r(new Uint8Array(u.Tools.DecodeBase64(a.uri)))})):u.Tools.LoadFile(e.rootUrl+a.uri,(function(e){return r(new Uint8Array(e))}),void 0,void 0,!0,(function(e){e&&n(e.status+" "+e.statusText)}))}else n("")},e.CreateTextureAsync=function(e,t,r,n){var o=e.textures[t];if(o.babylonTexture)n(o.babylonTexture);else{var a=e.samplers[o.sampler],i=a.minFilter===L.NEAREST_MIPMAP_NEAREST||a.minFilter===L.NEAREST_MIPMAP_LINEAR||a.minFilter===L.LINEAR_MIPMAP_NEAREST||a.minFilter===L.LINEAR_MIPMAP_LINEAR,s=u.Texture.BILINEAR_SAMPLINGMODE,l=null==r?new Blob:new Blob([r]),c=URL.createObjectURL(l),f=function(){return URL.revokeObjectURL(c)},d=new u.Texture(c,e.scene,!i,!0,s,f,f);void 0!==a.wrapS&&(d.wrapU=R.GetWrapMode(a.wrapS)),void 0!==a.wrapT&&(d.wrapV=R.GetWrapMode(a.wrapT)),d.name=t,o.babylonTexture=d,n(d)}},e.LoadShaderStringAsync=function(e,t,r,n){var o=e.shaders[t];if(u.Tools.IsBase64(o.uri)){var a=atob(o.uri.split(",")[1]);r&&r(a)}else u.Tools.LoadFile(e.rootUrl+o.uri,r,void 0,void 0,!1,(function(e){e&&n&&n(e.status+" "+e.statusText)}))},e.LoadMaterialAsync=function(e,t,r,n){var o=e.materials[t];if(o.technique){var a=e.techniques[o.technique];if(!a){e.scene._blockEntityCollection=!!e.assetContainer;var i=new u.StandardMaterial(t,e.scene);return i._parentContainer=e.assetContainer,e.scene._blockEntityCollection=!1,i.diffuseColor=new u.Color3(.5,.5,.5),i.sideOrientation=u.Material.CounterClockWiseSideOrientation,void r(i)}var s=e.programs[a.program],l=a.states,c=u.Effect.ShadersStore[s.vertexShader+"VertexShader"],f=u.Effect.ShadersStore[s.fragmentShader+"PixelShader"],d="",h="",p=new P(c),m=new P(f),b={},v=[],y=[],_=[];for(var A in a.uniforms){var g=a.uniforms[A],O=a.parameters[g];if(b[A]=O,!O.semantic||O.node||O.source)O.type===E.SAMPLER_2D?_.push(A):v.push(A);else{var L=w.indexOf(O.semantic);-1!==L?(v.push(I[L]),delete b[A]):v.push(A)}}for(var T in a.attributes){var M=a.attributes[T];if((F=a.parameters[M]).semantic){var S=U(F);S&&y.push(S)}}for(;!p.isEnd()&&p.getNextToken();)if(p.currentToken===x.IDENTIFIER){var B=!1;for(var T in a.attributes){M=a.attributes[T];var F=a.parameters[M];if(p.currentIdentifier===T&&F.semantic){d+=U(F),B=!0;break}}B||(d+=Q(p,a,b))}else d+=p.currentString;for(;!m.isEnd()&&m.getNextToken();)m.currentToken===x.IDENTIFIER?h+=Q(m,a,b):h+=m.currentString;var V={vertex:s.vertexShader+t,fragment:s.fragmentShader+t},D={attributes:y,uniforms:v,samplers:_,needAlphaBlending:l&&l.enable&&-1!==l.enable.indexOf(3042)};u.Effect.ShadersStore[s.vertexShader+t+"VertexShader"]=d,u.Effect.ShadersStore[s.fragmentShader+t+"PixelShader"]=h;var k=new u.ShaderMaterial(t,e.scene,V,D);if(k.onError=function(e,t,r){return function(n,o){t.dispose(!0),r("Cannot compile program named "+e.name+". Error: "+o+". Default material will be applied")}}(s,k,n),k.onCompiled=function(e,t,r,n,o,a){return function(i){!function(e,t,r,n,o){var a=n.values||r.parameters,i=r.uniforms,s=function(r){var s=o[r],l=s.type,u=a[i[r]];if(void 0===u&&(u=s.value),!u)return"continue";var c=function(e){return function(r){s.value&&e&&(t.setTexture(e,r),delete o[e])}};l===E.SAMPLER_2D?ee.LoadTextureAsync(e,n.values?u:s.value,c(r),(function(){return c(null)})):s.value&&R.SetUniform(t,r,n.values?u:s.value,l)&&delete o[r]};for(var l in o)s(l)}(e,t,r,n,o),t.onBind=function(i){!function(e,t,r,n,o,a,i){var s=a.values||o.parameters;for(var l in r){var u=r[l],c=u.type;if(c===E.FLOAT_MAT2||c===E.FLOAT_MAT3||c===E.FLOAT_MAT4)if(!u.semantic||u.source||u.node){if(u.semantic&&(u.source||u.node)){var f=t.scene.getNodeByName(u.source||u.node||"");if(null===f&&(f=t.scene.getNodeById(u.source||u.node||"")),null===f)continue;R.SetMatrix(t.scene,f,u,l,n.getEffect())}}else R.SetMatrix(t.scene,e,u,l,n.getEffect());else{var d=s[o.uniforms[l]];if(!d)continue;if(c===E.SAMPLER_2D){var h=t.textures[a.values?d:u.value].babylonTexture;if(null==h)continue;n.getEffect().setTexture(l,h)}else R.SetUniform(n.getEffect(),l,d,c)}}i(n)}(i,e,o,t,r,n,a)}}}(e,k,a,o,b,r),k.sideOrientation=u.Material.CounterClockWiseSideOrientation,l&&l.functions){var G=l.functions;G.cullFace&&G.cullFace[0]!==N.BACK&&(k.backFaceCulling=!1);var j=G.blendFuncSeparate;j&&(j[0]===C.SRC_ALPHA&&j[1]===C.ONE_MINUS_SRC_ALPHA&&j[2]===C.ONE&&j[3]===C.ONE?k.alphaMode=u.Constants.ALPHA_COMBINE:j[0]===C.ONE&&j[1]===C.ONE&&j[2]===C.ZERO&&j[3]===C.ONE?k.alphaMode=u.Constants.ALPHA_ONEONE:j[0]===C.SRC_ALPHA&&j[1]===C.ONE&&j[2]===C.ZERO&&j[3]===C.ONE?k.alphaMode=u.Constants.ALPHA_ADD:j[0]===C.ZERO&&j[1]===C.ONE_MINUS_SRC_COLOR&&j[2]===C.ONE&&j[3]===C.ONE?k.alphaMode=u.Constants.ALPHA_SUBTRACT:j[0]===C.DST_COLOR&&j[1]===C.ZERO&&j[2]===C.ONE&&j[3]===C.ONE?k.alphaMode=u.Constants.ALPHA_MULTIPLY:j[0]===C.SRC_ALPHA&&j[1]===C.ONE_MINUS_SRC_COLOR&&j[2]===C.ONE&&j[3]===C.ONE&&(k.alphaMode=u.Constants.ALPHA_MAXIMIZED))}}else n&&n("No technique found.")},e}(),$=function(){function e(){}return e.RegisterExtension=function(t){e.Extensions[t.name]?u.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,r,n,o,a,i,s){var l=this;return t.useRightHandedSystem=!0,ee.LoadRuntimeAsync(t,r,n,(function(t){t.assetContainer=o,t.importOnlyMeshes=!0,""===e?t.importMeshesNames=[]:"string"==typeof e?t.importMeshesNames=[e]:!e||e instanceof Array?(t.importMeshesNames=[],u.Tools.Warn("Argument meshesNames must be of type string or string[]")):t.importMeshesNames=[e],l._createNodes(t);var r=[],n=[];for(var i in t.nodes){var s=t.nodes[i];s.babylonNode instanceof u.AbstractMesh&&r.push(s.babylonNode)}for(var c in t.skins){var f=t.skins[c];f.babylonSkeleton instanceof u.Skeleton&&n.push(f.babylonSkeleton)}l._loadBuffersAsync(t,(function(){l._loadShadersAsync(t,(function(){X(t),K(t),!v.IncrementalLoading&&a&&a(r,n)}))})),v.IncrementalLoading&&a&&a(r,n)}),s),!0},e.prototype.importMeshAsync=function(e,t,r,n,o,a){var i=this;return new Promise((function(s,l){i._importMeshAsync(e,t,n,o,r,(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,r,n,o,a){var i=this;e.useRightHandedSystem=!0,ee.LoadRuntimeAsync(e,t,r,(function(e){ee.LoadRuntimeExtensionsAsync(e,(function(){i._createNodes(e),i._loadBuffersAsync(e,(function(){i._loadShadersAsync(e,(function(){X(e),K(e),v.IncrementalLoading||n()}))})),v.IncrementalLoading&&n()}),a)}),a)},e.prototype.loadAsync=function(e,t,r,n){var o=this;return new Promise((function(a,i){o._loadAsync(e,t,r,(function(){a()}),n,(function(e){i(new Error(e))}))}))},e.prototype._loadShadersAsync=function(e,t){var r=!1,n=function(r,n){ee.LoadShaderStringAsync(e,r,(function(o){o instanceof ArrayBuffer||(e.loadedShaderCount++,o&&(u.Effect.ShadersStore[r+(n.type===g.VERTEX?"VertexShader":"PixelShader")]=o),e.loadedShaderCount===e.shaderscount&&t())}),(function(){u.Tools.Error("Error when loading shader program named "+r+" located at "+n.uri)}))};for(var o in e.shaders){r=!0;var a=e.shaders[o];a?n.bind(this,o,a)():u.Tools.Error("No shader named: "+o)}r||t()},e.prototype._loadBuffersAsync=function(e,t){var r=!1,n=function(r,n){ee.LoadBufferAsync(e,r,(function(o){e.loadedBufferCount++,o&&(o.byteLength!=e.buffers[r].byteLength&&u.Tools.Error("Buffer named "+r+" is length "+o.byteLength+". Expected: "+n.byteLength),e.loadedBufferViews[r]=o),e.loadedBufferCount===e.buffersCount&&t()}),(function(){u.Tools.Error("Error when loading buffer named "+r+" located at "+n.uri)}))};for(var o in e.buffers){r=!0;var a=e.buffers[o];a?n.bind(this,o,a)():u.Tools.Error("No buffer named: "+o)}r||t()},e.prototype._createNodes=function(e){var t=e.currentScene;if(t)for(var r=0;r<t.nodes.length;r++)Z(e,t.nodes[r],null);else for(var n in e.scenes)for(t=e.scenes[n],r=0;r<t.nodes.length;r++)Z(e,t.nodes[r],null)},e.Extensions={},e}(),ee=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,r,n,o){return!1},e.prototype.loadRuntimeExtensionsAsync=function(e,t,r){return!1},e.prototype.loadBufferAsync=function(e,t,r,n,o){return!1},e.prototype.loadTextureBufferAsync=function(e,t,r,n){return!1},e.prototype.createTextureAsync=function(e,t,r,n,o){return!1},e.prototype.loadShaderStringAsync=function(e,t,r,n){return!1},e.prototype.loadMaterialAsync=function(e,t,r,n){return!1},e.LoadRuntimeAsync=function(t,r,n,o,a){e._ApplyExtensions((function(e){return e.loadRuntimeAsync(t,r,n,o,a)}),(function(){setTimeout((function(){o&&o(z.CreateRuntime(r.json,t,n))}))}))},e.LoadRuntimeExtensionsAsync=function(t,r,n){e._ApplyExtensions((function(e){return e.loadRuntimeExtensionsAsync(t,r,n)}),(function(){setTimeout((function(){r()}))}))},e.LoadBufferAsync=function(t,r,n,o,a){e._ApplyExtensions((function(e){return e.loadBufferAsync(t,r,n,o,a)}),(function(){z.LoadBufferAsync(t,r,n,o,a)}))},e.LoadTextureAsync=function(t,r,n,o){e._LoadTextureBufferAsync(t,r,(function(a){a&&e._CreateTextureAsync(t,r,a,n,o)}),o)},e.LoadShaderStringAsync=function(t,r,n,o){e._ApplyExtensions((function(e){return e.loadShaderStringAsync(t,r,n,o)}),(function(){z.LoadShaderStringAsync(t,r,n,o)}))},e.LoadMaterialAsync=function(t,r,n,o){e._ApplyExtensions((function(e){return e.loadMaterialAsync(t,r,n,o)}),(function(){z.LoadMaterialAsync(t,r,n,o)}))},e._LoadTextureBufferAsync=function(t,r,n,o){e._ApplyExtensions((function(e){return e.loadTextureBufferAsync(t,r,n,o)}),(function(){z.LoadTextureBufferAsync(t,r,n,o)}))},e._CreateTextureAsync=function(t,r,n,o,a){e._ApplyExtensions((function(e){return e.createTextureAsync(t,r,n,o,a)}),(function(){z.CreateTextureAsync(t,r,n,o)}))},e._ApplyExtensions=function(e,t){for(var r in $.Extensions)if(e($.Extensions[r]))return;t()},e}();v._CreateGLTF1Loader=function(){return new $};var te=function(e){function t(){return e.call(this,"KHR_binary_glTF")||this}return S(t,e),t.prototype.loadRuntimeAsync=function(e,t,r,n){var o=t.json.extensionsUsed;return!(!o||-1===o.indexOf(this.name)||!t.bin||(this._bin=t.bin,n(z.CreateRuntime(t.json,e,r)),0))},t.prototype.loadBufferAsync=function(e,t,r,n){return-1!==e.extensionsUsed.indexOf(this.name)&&"binary_glTF"===t&&(this._bin.readAsync(0,this._bin.byteLength).then(r,(function(e){return n(e.message)})),!0)},t.prototype.loadTextureBufferAsync=function(e,t,r){var n=e.textures[t],o=e.images[n.source];if(!o.extensions||!(this.name in o.extensions))return!1;var a=o.extensions[this.name],i=e.bufferViews[a.bufferView];return r(R.GetBufferFromBufferView(e,i,0,i.byteLength,A.UNSIGNED_BYTE)),!0},t.prototype.loadShaderStringAsync=function(e,t,r){var n=e.shaders[t];if(!n.extensions||!(this.name in n.extensions))return!1;var o=n.extensions[this.name],a=e.bufferViews[o.bufferView],i=R.GetBufferFromBufferView(e,a,0,a.byteLength,A.UNSIGNED_BYTE);return setTimeout((function(){var e=R.DecodeBufferToText(i);r(e)})),!0},t}(ee);$.RegisterExtension(new te);var re=function(e){function t(){return e.call(this,"KHR_materials_common")||this}return S(t,e),t.prototype.loadRuntimeExtensionsAsync=function(e){if(!e.extensions)return!1;var t=e.extensions[this.name];if(!t)return!1;var r=t.lights;if(r)for(var n in r){var o=r[n];switch(o.type){case"ambient":var a=new u.HemisphericLight(o.name,new u.Vector3(0,1,0),e.scene),i=o.ambient;i&&(a.diffuse=u.Color3.FromArray(i.color||[1,1,1]));break;case"point":var s=new u.PointLight(o.name,new u.Vector3(10,10,10),e.scene),l=o.point;l&&(s.diffuse=u.Color3.FromArray(l.color||[1,1,1]));break;case"directional":var c=new u.DirectionalLight(o.name,new u.Vector3(0,-1,0),e.scene),f=o.directional;f&&(c.diffuse=u.Color3.FromArray(f.color||[1,1,1]));break;case"spot":var d=o.spot;d&&(new u.SpotLight(o.name,new u.Vector3(0,10,0),new u.Vector3(0,-1,0),d.fallOffAngle||Math.PI,d.fallOffExponent||0,e.scene).diffuse=u.Color3.FromArray(d.color||[1,1,1]));break;default:u.Tools.Warn('GLTF Material Common extension: light type "'+o.type+"” not supported")}}return!1},t.prototype.loadMaterialAsync=function(e,t,r,n){var o=e.materials[t];if(!o||!o.extensions)return!1;var a=o.extensions[this.name];if(!a)return!1;var i=new u.StandardMaterial(t,e.scene);return i.sideOrientation=u.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",n):i.ambientColor=u.Color3.FromArray(a.values.ambient||[0,0,0]),"string"==typeof a.values.diffuse?this._loadTexture(e,a.values.diffuse,i,"diffuseTexture",n):i.diffuseColor=u.Color3.FromArray(a.values.diffuse||[0,0,0]),"string"==typeof a.values.emission?this._loadTexture(e,a.values.emission,i,"emissiveTexture",n):i.emissiveColor=u.Color3.FromArray(a.values.emission||[0,0,0]),"string"==typeof a.values.specular?this._loadTexture(e,a.values.specular,i,"specularTexture",n):i.specularColor=u.Color3.FromArray(a.values.specular||[0,0,0]),!0},t.prototype._loadTexture=function(e,t,r,n,o){z.LoadTextureBufferAsync(e,t,(function(o){z.CreateTextureAsync(e,t,o,(function(e){return r[n]=e}))}),o)},t}(ee);$.RegisterExtension(new re);var ne=void 0!==n.g?n.g:"undefined"!=typeof window?window:void 0;if(void 0!==ne)for(var oe in ne.BABYLON=ne.BABYLON||{},ne.BABYLON.GLTF1=ne.BABYLON.GLTF1||{},s)ne.BABYLON.GLTF1[oe]=s[oe];const ae=l;return o.default})())); | ||
!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}},r={};function n(e){var o=r[e];if(void 0!==o)return o.exports;var a=r[e]={exports:{}};return t[e](a,a.exports,n),a.exports}n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var o={};n.d(o,{default:()=>ae});var a={};n.r(a),n.d(a,{GLTFValidation:()=>m});var i={};n.r(i),n.d(i,{GLTFFileLoader:()=>v,GLTFLoaderAnimationStartMode:()=>h,GLTFLoaderCoordinateSystemMode:()=>d,GLTFLoaderState:()=>p});var s={};n.r(s),n.d(s,{EBlendingFunction:()=>C,EComponentType:()=>A,ECullingType:()=>N,EParameterType:()=>E,EShaderType:()=>g,ETextureFilterType:()=>L,ETextureFormat:()=>T,ETextureWrapMode:()=>O,GLTFBinaryExtension:()=>te,GLTFLoader:()=>$,GLTFLoaderBase:()=>z,GLTFLoaderExtension:()=>ee,GLTFMaterialsCommonExtension:()=>re,GLTFUtils:()=>R});var l={};n.r(l),n.d(l,{GLTF1:()=>s,GLTFFileLoader:()=>v,GLTFLoaderAnimationStartMode:()=>h,GLTFLoaderCoordinateSystemMode:()=>d,GLTFLoaderState:()=>p,GLTFValidation:()=>m});var u=n(597);function c(e,t,r,n){var o={externalResourceFunction:n};return r&&(o.uri="file:"===t?r:t+r),ArrayBuffer.isView(e)?GLTFValidator.validateBytes(e,o):GLTFValidator.validateString(e,o)}function f(){var e=[];onmessage=function(t){var r=t.data;switch(r.id){case"init":importScripts(r.url);break;case"validate":c(r.data,r.rootUrl,r.fileName,(function(t){return new Promise((function(r,n){var o=e.length;e.push({resolve:r,reject:n}),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[r.index].resolve(r.value);break;case"getExternalResource.reject":e[r.index].reject(r.reason)}}}var d,h,p,m=function(){function e(){}return e.ValidateAsync=function(e,t,r,n){var o=this;return"function"==typeof Worker?new Promise((function(a,i){var s="".concat(c,"(").concat(f,")()"),l=URL.createObjectURL(new Blob([s],{type:"application/javascript"})),d=new Worker(l),h=function(e){d.removeEventListener("error",h),d.removeEventListener("message",p),i(e)},p=function(e){var t=e.data;switch(t.id){case"getExternalResource":n(t.uri).then((function(e){d.postMessage({id:"getExternalResource.resolve",index:t.index,value:e},[e.buffer])}),(function(e){d.postMessage({id:"getExternalResource.reject",index:t.index,reason:e})}));break;case"validate.resolve":d.removeEventListener("error",h),d.removeEventListener("message",p),a(t.value),d.terminate();break;case"validate.reject":d.removeEventListener("error",h),d.removeEventListener("message",p),i(t.reason),d.terminate()}};if(d.addEventListener("error",h),d.addEventListener("message",p),d.postMessage({id:"init",url:u.Tools.GetBabylonScriptURL(o.Configuration.url)}),ArrayBuffer.isView(e)){var m=e.slice();d.postMessage({id:"validate",data:m,rootUrl:t,fileName:r},[m.buffer])}else d.postMessage({id:"validate",data:e,rootUrl:t,fileName:r})})):(this._LoadScriptPromise||(this._LoadScriptPromise=u.Tools.LoadBabylonScriptAsync(this.Configuration.url)),this._LoadScriptPromise.then((function(){return c(e,t,r,n)})))},e.Configuration={url:"".concat(u.Tools._DefaultCdnUrl,"/gltf_validator.js")},e}();function b(e,t,r){try{return Promise.resolve(new Uint8Array(e,t,r))}catch(e){return Promise.reject(e)}}!function(e){e[e.AUTO=0]="AUTO",e[e.FORCE_RIGHT_HANDED=1]="FORCE_RIGHT_HANDED"}(d||(d={})),function(e){e[e.NONE=0]="NONE",e[e.FIRST=1]="FIRST",e[e.ALL=2]="ALL"}(h||(h={})),function(e){e[e.LOADING=0]="LOADING",e[e.READY=1]="READY",e[e.COMPLETE=2]="COMPLETE"}(p||(p={}));var v=function(){function e(){this.onParsedObservable=new u.Observable,this.coordinateSystemMode=d.AUTO,this.animationStartMode=h.FIRST,this.loadNodeAnimations=!0,this.loadSkins=!0,this.loadMorphTargets=!0,this.compileMaterials=!1,this.useClipPlane=!1,this.compileShadowGenerators=!1,this.transparencyAsCoverage=!1,this.useRangeRequests=!1,this.createInstances=!0,this.alwaysComputeBoundingBox=!1,this.loadAllMaterials=!1,this.loadOnlyMaterials=!1,this.skipMaterials=!1,this.useSRGBBuffers=!0,this.targetFps=60,this.alwaysComputeSkeletonRootNode=!1,this.preprocessUrlAsync=function(e){return Promise.resolve(e)},this.onMeshLoadedObservable=new u.Observable,this.onSkinLoadedObservable=new u.Observable,this.onTextureLoadedObservable=new u.Observable,this.onMaterialLoadedObservable=new u.Observable,this.onCameraLoadedObservable=new u.Observable,this.onCompleteObservable=new u.Observable,this.onErrorObservable=new u.Observable,this.onDisposeObservable=new u.Observable,this.onExtensionLoadedObservable=new u.Observable,this.validate=!1,this.onValidatedObservable=new u.Observable,this._loader=null,this._state=null,this._requests=new Array,this.name="gltf",this.extensions={".gltf":{isBinary:!1},".glb":{isBinary:!0}},this.onLoaderStateChangedObservable=new u.Observable,this._logIndentLevel=0,this._loggingEnabled=!1,this._log=this._logDisabled,this._capturePerformanceCounters=!1,this._startPerformanceCounter=this._startPerformanceCounterDisabled,this._endPerformanceCounter=this._endPerformanceCounterDisabled}return Object.defineProperty(e.prototype,"onParsed",{set:function(e){this._onParsedObserver&&this.onParsedObservable.remove(this._onParsedObserver),this._onParsedObserver=this.onParsedObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onMeshLoaded",{set:function(e){this._onMeshLoadedObserver&&this.onMeshLoadedObservable.remove(this._onMeshLoadedObserver),this._onMeshLoadedObserver=this.onMeshLoadedObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onTextureLoaded",{set:function(e){this._onTextureLoadedObserver&&this.onTextureLoadedObservable.remove(this._onTextureLoadedObserver),this._onTextureLoadedObserver=this.onTextureLoadedObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onMaterialLoaded",{set:function(e){this._onMaterialLoadedObserver&&this.onMaterialLoadedObservable.remove(this._onMaterialLoadedObserver),this._onMaterialLoadedObserver=this.onMaterialLoadedObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onCameraLoaded",{set:function(e){this._onCameraLoadedObserver&&this.onCameraLoadedObservable.remove(this._onCameraLoadedObserver),this._onCameraLoadedObserver=this.onCameraLoadedObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onComplete",{set:function(e){this._onCompleteObserver&&this.onCompleteObservable.remove(this._onCompleteObserver),this._onCompleteObserver=this.onCompleteObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onError",{set:function(e){this._onErrorObserver&&this.onErrorObservable.remove(this._onErrorObserver),this._onErrorObserver=this.onErrorObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onDispose",{set:function(e){this._onDisposeObserver&&this.onDisposeObservable.remove(this._onDisposeObserver),this._onDisposeObserver=this.onDisposeObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onExtensionLoaded",{set:function(e){this._onExtensionLoadedObserver&&this.onExtensionLoadedObservable.remove(this._onExtensionLoadedObserver),this._onExtensionLoadedObserver=this.onExtensionLoadedObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"loggingEnabled",{get:function(){return this._loggingEnabled},set:function(e){this._loggingEnabled!==e&&(this._loggingEnabled=e,this._loggingEnabled?this._log=this._logEnabled:this._log=this._logDisabled)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"capturePerformanceCounters",{get:function(){return this._capturePerformanceCounters},set:function(e){this._capturePerformanceCounters!==e&&(this._capturePerformanceCounters=e,this._capturePerformanceCounters?(this._startPerformanceCounter=this._startPerformanceCounterEnabled,this._endPerformanceCounter=this._endPerformanceCounterEnabled):(this._startPerformanceCounter=this._startPerformanceCounterDisabled,this._endPerformanceCounter=this._endPerformanceCounterDisabled))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onValidated",{set:function(e){this._onValidatedObserver&&this.onValidatedObservable.remove(this._onValidatedObserver),this._onValidatedObserver=this.onValidatedObservable.add(e)},enumerable:!1,configurable:!0}),e.prototype.dispose=function(){this._loader&&(this._loader.dispose(),this._loader=null);for(var e=0,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()},e.prototype.loadFile=function(e,t,r,n,o,a,i,s){var l=this;if(ArrayBuffer.isView(t))return this._loadBinary(e,t,r,n,i,s),null;this._progressCallback=o;var c=t.name||u.Tools.GetFilename(t);if(a){if(this.useRangeRequests){this.validate&&u.Logger.Warn("glTF validation is not supported when range requests are enabled");var f={abort:function(){},onCompleteObservable:new u.Observable},d={readAsync:function(r,n){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(r,"-").concat(r+n-1))}))}))},byteLength:0};return this._unpackBinaryAsync(new u.DataReader(d)).then((function(e){f.onCompleteObservable.notifyObservers(f),n(e)}),i?function(e){return i(void 0,e)}:void 0),f}return this._loadFile(e,t,(function(t){l._validate(e,new Uint8Array(t,0,t.byteLength),r,c),l._unpackBinaryAsync(new u.DataReader({readAsync:function(e,r){return b(t,e,r)},byteLength:t.byteLength})).then((function(e){n(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,r,c),n({json:l._parseJson(t)})}catch(e){i&&i()}}),!1,i)},e.prototype._loadBinary=function(e,t,r,n,o,a){this._validate(e,new Uint8Array(t.buffer,t.byteOffset,t.byteLength),r,a),this._unpackBinaryAsync(new u.DataReader({readAsync:function(e,r){return function(e,t,r){try{if(t<0||t>=e.byteLength)throw new RangeError("Offset is out of range.");if(t+r>e.byteLength)throw new RangeError("Length is out of range.");return Promise.resolve(new Uint8Array(e.buffer,e.byteOffset+t,r))}catch(e){return Promise.reject(e)}}(t,e,r)},byteLength:t.byteLength})).then((function(e){n(e)}),o?function(e){return o(void 0,e)}:void 0)},e.prototype.importMeshAsync=function(e,t,r,n,o,a){var i=this;return Promise.resolve().then((function(){return i.onParsedObservable.notifyObservers(r),i.onParsedObservable.clear(),i._log("Loading ".concat(a||"")),i._loader=i._getLoader(r),i._loader.importMeshAsync(e,t,null,r,n,o,a)}))},e.prototype.loadAsync=function(e,t,r,n,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,r,n,o)}))},e.prototype.loadAssetContainerAsync=function(e,t,r,n,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 u.AssetContainer(e),s=[];a.onMaterialLoadedObservable.add((function(e){s.push(e)}));var l=[];a.onTextureLoadedObservable.add((function(e){l.push(e)}));var c=[];a.onCameraLoadedObservable.add((function(e){c.push(e)}));var f=[];return a.onMeshLoadedObservable.add((function(e){e.morphTargetManager&&f.push(e.morphTargetManager)})),a._loader.importMeshAsync(null,e,i,t,r,n,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,c),Array.prototype.push.apply(i.morphTargetManagers,f),i}))}))},e.prototype.canDirectLoad=function(t){return-1!==t.indexOf("asset")&&-1!==t.indexOf("version")||t.startsWith("data:base64,"+e._MagicBase64Encoded)||t.startsWith("data:;base64,"+e._MagicBase64Encoded)||t.startsWith("data:application/octet-stream;base64,"+e._MagicBase64Encoded)||t.startsWith("data:model/gltf-binary;base64,"+e._MagicBase64Encoded)},e.prototype.directLoad=function(t,r){if(r.startsWith("base64,"+e._MagicBase64Encoded)||r.startsWith(";base64,"+e._MagicBase64Encoded)||r.startsWith("application/octet-stream;base64,"+e._MagicBase64Encoded)||r.startsWith("model/gltf-binary;base64,"+e._MagicBase64Encoded)){var n=(0,u.DecodeBase64UrlToBinary)(r);return this._validate(t,new Uint8Array(n,0,n.byteLength)),this._unpackBinaryAsync(new u.DataReader({readAsync:function(e,t){return b(n,e,t)},byteLength:n.byteLength}))}return this._validate(t,r),Promise.resolve({json:this._parseJson(r)})},e.prototype.createPlugin=function(){return new e},Object.defineProperty(e.prototype,"loaderState",{get:function(){return this._state},enumerable:!1,configurable:!0}),e.prototype.whenCompleteAsync=function(){var e=this;return new Promise((function(t,r){e.onCompleteObservable.addOnce((function(){t()})),e.onErrorObservable.addOnce((function(e){r(e)}))}))},e.prototype._setState=function(e){this._state!==e&&(this._state=e,this.onLoaderStateChangedObservable.notifyObservers(this._state),this._log(p[this._state]))},e.prototype._loadFile=function(e,t,r,n,o,a){var i=this,s=e._loadFile(t,r,(function(e){i._onProgress(e,s)}),!0,n,o,a);return s.onCompleteObservable.add((function(){s._lengthComputable=!0,s._total=s._loaded})),this._requests.push(s),s},e.prototype._onProgress=function(e,t){if(this._progressCallback){t._lengthComputable=e.lengthComputable,t._loaded=e.loaded,t._total=e.total;for(var r=!0,n=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;r=r&&s._lengthComputable,n+=s._loaded,o+=s._total}this._progressCallback({lengthComputable:r,loaded:n,total:r?o:0})}},e.prototype._validate=function(e,t,r,n){var o=this;void 0===r&&(r=""),void 0===n&&(n=""),this.validate&&(this._startPerformanceCounter("Validate JSON"),m.ValidateAsync(t,r,n,(function(t){return o.preprocessUrlAsync(r+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"),u.Tools.Warn("Failed to validate: ".concat(e.message)),o.onValidatedObservable.clear()})))},e.prototype._getLoader=function(t){var r=t.json.asset||{};this._log("Asset version: ".concat(r.version)),r.minVersion&&this._log("Asset minimum version: ".concat(r.minVersion)),r.generator&&this._log("Asset generator: ".concat(r.generator));var n=e._parseVersion(r.version);if(!n)throw new Error("Invalid version: "+r.version);if(void 0!==r.minVersion){var o=e._parseVersion(r.minVersion);if(!o)throw new Error("Invalid minimum version: "+r.minVersion);if(e._compareVersion(o,{major:2,minor:0})>0)throw new Error("Incompatible minimum version: "+r.minVersion)}var a={1:e._CreateGLTF1Loader,2:e._CreateGLTF2Loader}[n.major];if(!a)throw new Error("Unsupported version: "+r.version);return a(this)},e.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},e.prototype._unpackBinaryAsync=function(e){var t=this;return this._startPerformanceCounter("Unpack Binary"),e.loadAsync(20).then((function(){var r=e.readUint32();if(1179937895!==r)throw new u.RuntimeError("Unexpected magic: "+r,u.ErrorCodes.GLTFLoaderUnexpectedMagicError);var n=e.readUint32();t.loggingEnabled&&t._log("Binary version: ".concat(n));var o,a=e.readUint32();switch(t.useRangeRequests||a===e.buffer.byteLength||u.Logger.Warn("Length in header does not match actual data length: ".concat(a," != ").concat(e.buffer.byteLength)),n){case 1:o=t._unpackBinaryV1Async(e,a);break;case 2:o=t._unpackBinaryV2Async(e,a);break;default:throw new Error("Unsupported version: "+n)}return t._endPerformanceCounter("Unpack Binary"),o}))},e.prototype._unpackBinaryV1Async=function(e,t){var r=e.readUint32(),n=e.readUint32();if(0!==n)throw new Error("Unexpected content format: ".concat(n));var o=t-e.byteOffset,a={json:this._parseJson(e.readString(r)),bin:null};if(0!==o){var i=e.byteOffset;a.bin={readAsync:function(t,r){return e.buffer.readAsync(i+t,r)},byteLength:o}}return Promise.resolve(a)},e.prototype._unpackBinaryV2Async=function(e,t){var r=this,n=1313821514,o=e.readUint32();if(e.readUint32()!==n)throw new Error("First chunk format is not JSON");return e.byteOffset+o===t?e.loadAsync(o).then((function(){return{json:r._parseJson(e.readString(o)),bin:null}})):e.loadAsync(o+8).then((function(){var a={json:r._parseJson(e.readString(o)),bin:null},i=function(){var r=e.readUint32();switch(e.readUint32()){case n:throw new Error("Unexpected JSON chunk");case 5130562:var o=e.byteOffset;a.bin={readAsync:function(t,r){return e.buffer.readAsync(o+t,r)},byteLength:r},e.skipBytes(r);break;default:e.skipBytes(r)}return e.byteOffset!==t?e.loadAsync(8).then(i):Promise.resolve(a)};return i()}))},e._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},e._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},e.prototype._logOpen=function(e){this._log(e),this._logIndentLevel++},e.prototype._logClose=function(){--this._logIndentLevel},e.prototype._logEnabled=function(t){var r=e._logSpaces.substr(0,2*this._logIndentLevel);u.Logger.Log("".concat(r).concat(t))},e.prototype._logDisabled=function(e){},e.prototype._startPerformanceCounterEnabled=function(e){u.Tools.StartPerformanceCounter(e)},e.prototype._startPerformanceCounterDisabled=function(e){},e.prototype._endPerformanceCounterEnabled=function(e){u.Tools.EndPerformanceCounter(e)},e.prototype._endPerformanceCounterDisabled=function(e){},e.IncrementalLoading=!0,e.HomogeneousCoordinates=!1,e._MagicBase64Encoded="Z2xURg",e._logSpaces=" ",e}();u.SceneLoader&&u.SceneLoader.RegisterPlugin(new v);var y=void 0!==n.g?n.g:"undefined"!=typeof window?window:void 0;if(void 0!==y){for(var _ in y.BABYLON=y.BABYLON||{},i)y.BABYLON[_]=i[_];for(var _ in a)y.BABYLON[_]=a[_]}var A,g,E,O,L,T,N,C,M=function(e,t){return M=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},M(e,t)};function S(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function r(){this.constructor=e}M(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}Object.create,Object.create,"function"==typeof SuppressedError&&SuppressedError,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"}(A||(A={})),function(e){e[e.FRAGMENT=35632]="FRAGMENT",e[e.VERTEX=35633]="VERTEX"}(g||(g={})),function(e){e[e.BYTE=5120]="BYTE",e[e.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",e[e.SHORT=5122]="SHORT",e[e.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",e[e.INT=5124]="INT",e[e.UNSIGNED_INT=5125]="UNSIGNED_INT",e[e.FLOAT=5126]="FLOAT",e[e.FLOAT_VEC2=35664]="FLOAT_VEC2",e[e.FLOAT_VEC3=35665]="FLOAT_VEC3",e[e.FLOAT_VEC4=35666]="FLOAT_VEC4",e[e.INT_VEC2=35667]="INT_VEC2",e[e.INT_VEC3=35668]="INT_VEC3",e[e.INT_VEC4=35669]="INT_VEC4",e[e.BOOL=35670]="BOOL",e[e.BOOL_VEC2=35671]="BOOL_VEC2",e[e.BOOL_VEC3=35672]="BOOL_VEC3",e[e.BOOL_VEC4=35673]="BOOL_VEC4",e[e.FLOAT_MAT2=35674]="FLOAT_MAT2",e[e.FLOAT_MAT3=35675]="FLOAT_MAT3",e[e.FLOAT_MAT4=35676]="FLOAT_MAT4",e[e.SAMPLER_2D=35678]="SAMPLER_2D"}(E||(E={})),function(e){e[e.CLAMP_TO_EDGE=33071]="CLAMP_TO_EDGE",e[e.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",e[e.REPEAT=10497]="REPEAT"}(O||(O={})),function(e){e[e.NEAREST=9728]="NEAREST",e[e.LINEAR=9728]="LINEAR",e[e.NEAREST_MIPMAP_NEAREST=9984]="NEAREST_MIPMAP_NEAREST",e[e.LINEAR_MIPMAP_NEAREST=9985]="LINEAR_MIPMAP_NEAREST",e[e.NEAREST_MIPMAP_LINEAR=9986]="NEAREST_MIPMAP_LINEAR",e[e.LINEAR_MIPMAP_LINEAR=9987]="LINEAR_MIPMAP_LINEAR"}(L||(L={})),function(e){e[e.ALPHA=6406]="ALPHA",e[e.RGB=6407]="RGB",e[e.RGBA=6408]="RGBA",e[e.LUMINANCE=6409]="LUMINANCE",e[e.LUMINANCE_ALPHA=6410]="LUMINANCE_ALPHA"}(T||(T={})),function(e){e[e.FRONT=1028]="FRONT",e[e.BACK=1029]="BACK",e[e.FRONT_AND_BACK=1032]="FRONT_AND_BACK"}(N||(N={})),function(e){e[e.ZERO=0]="ZERO",e[e.ONE=1]="ONE",e[e.SRC_COLOR=768]="SRC_COLOR",e[e.ONE_MINUS_SRC_COLOR=769]="ONE_MINUS_SRC_COLOR",e[e.DST_COLOR=774]="DST_COLOR",e[e.ONE_MINUS_DST_COLOR=775]="ONE_MINUS_DST_COLOR",e[e.SRC_ALPHA=770]="SRC_ALPHA",e[e.ONE_MINUS_SRC_ALPHA=771]="ONE_MINUS_SRC_ALPHA",e[e.DST_ALPHA=772]="DST_ALPHA",e[e.ONE_MINUS_DST_ALPHA=773]="ONE_MINUS_DST_ALPHA",e[e.CONSTANT_COLOR=32769]="CONSTANT_COLOR",e[e.ONE_MINUS_CONSTANT_COLOR=32770]="ONE_MINUS_CONSTANT_COLOR",e[e.CONSTANT_ALPHA=32771]="CONSTANT_ALPHA",e[e.ONE_MINUS_CONSTANT_ALPHA=32772]="ONE_MINUS_CONSTANT_ALPHA",e[e.SRC_ALPHA_SATURATE=776]="SRC_ALPHA_SATURATE"}(C||(C={}));var x,R=function(){function e(){}return e.SetMatrix=function(e,t,r,n,o){var a=null;if("MODEL"===r.semantic?a=t.getWorldMatrix():"PROJECTION"===r.semantic?a=e.getProjectionMatrix():"VIEW"===r.semantic?a=e.getViewMatrix():"MODELVIEWINVERSETRANSPOSE"===r.semantic?a=u.Matrix.Transpose(t.getWorldMatrix().multiply(e.getViewMatrix()).invert()):"MODELVIEW"===r.semantic?a=t.getWorldMatrix().multiply(e.getViewMatrix()):"MODELVIEWPROJECTION"===r.semantic?a=t.getWorldMatrix().multiply(e.getTransformMatrix()):"MODELINVERSE"===r.semantic?a=t.getWorldMatrix().invert():"VIEWINVERSE"===r.semantic?a=e.getViewMatrix().invert():"PROJECTIONINVERSE"===r.semantic?a=e.getProjectionMatrix().invert():"MODELVIEWINVERSE"===r.semantic?a=t.getWorldMatrix().multiply(e.getViewMatrix()).invert():"MODELVIEWPROJECTIONINVERSE"===r.semantic?a=t.getWorldMatrix().multiply(e.getTransformMatrix()).invert():"MODELINVERSETRANSPOSE"===r.semantic&&(a=u.Matrix.Transpose(t.getWorldMatrix().invert())),a)switch(r.type){case E.FLOAT_MAT2:o.setMatrix2x2(n,u.Matrix.GetAsMatrix2x2(a));break;case E.FLOAT_MAT3:o.setMatrix3x3(n,u.Matrix.GetAsMatrix3x3(a));break;case E.FLOAT_MAT4:o.setMatrix(n,a)}},e.SetUniform=function(e,t,r,n){switch(n){case E.FLOAT:return e.setFloat(t,r),!0;case E.FLOAT_VEC2:return e.setVector2(t,u.Vector2.FromArray(r)),!0;case E.FLOAT_VEC3:return e.setVector3(t,u.Vector3.FromArray(r)),!0;case E.FLOAT_VEC4:return e.setVector4(t,u.Vector4.FromArray(r)),!0;default:return!1}},e.GetWrapMode=function(e){switch(e){case O.CLAMP_TO_EDGE:return u.Texture.CLAMP_ADDRESSMODE;case O.MIRRORED_REPEAT:return u.Texture.MIRROR_ADDRESSMODE;case O.REPEAT:default:return u.Texture.WRAP_ADDRESSMODE}},e.GetByteStrideFromType=function(e){switch(e.type){case"VEC2":return 2;case"VEC3":return 3;case"VEC4":case"MAT2":return 4;case"MAT3":return 9;case"MAT4":return 16;default:return 1}},e.GetTextureFilterMode=function(e){switch(e){case L.LINEAR:case L.LINEAR_MIPMAP_NEAREST:case L.LINEAR_MIPMAP_LINEAR:return u.Texture.TRILINEAR_SAMPLINGMODE;case L.NEAREST:case L.NEAREST_MIPMAP_NEAREST:return u.Texture.NEAREST_SAMPLINGMODE;default:return u.Texture.BILINEAR_SAMPLINGMODE}},e.GetBufferFromBufferView=function(e,t,r,n,o){r=t.byteOffset+r;var a=e.loadedBufferViews[t.buffer];if(r+n>a.byteLength)throw new Error("Buffer access is out of range");var i=a.buffer;switch(r+=a.byteOffset,o){case A.BYTE:return new Int8Array(i,r,n);case A.UNSIGNED_BYTE:return new Uint8Array(i,r,n);case A.SHORT:return new Int16Array(i,r,n);case A.UNSIGNED_SHORT:return new Uint16Array(i,r,n);default:return new Float32Array(i,r,n)}},e.GetBufferFromAccessor=function(t,r){var n=t.bufferViews[r.bufferView],o=r.count*e.GetByteStrideFromType(r);return e.GetBufferFromBufferView(t,n,r.byteOffset,o,r.componentType)},e.DecodeBufferToText=function(e){for(var t="",r=e.byteLength,n=0;n<r;++n)t+=String.fromCharCode(e[n]);return t},e.GetDefaultMaterial=function(t){if(!e._DefaultMaterial){u.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"),u.Effect.ShadersStore.GLTFDefaultMaterialPixelShader=["precision highp float;","","uniform vec4 u_emission;","","void main(void)","{"," gl_FragColor = u_emission;","}"].join("\n");var r={attributes:["position"],uniforms:["worldView","projection","u_emission"],samplers:new Array,needAlphaBlending:!1};e._DefaultMaterial=new u.ShaderMaterial("GLTFDefaultMaterial",t,{vertex:"GLTFDefaultMaterial",fragment:"GLTFDefaultMaterial"},r),e._DefaultMaterial.setColor4("u_emission",new u.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"}(x||(x={}));var P=function(){function e(e){this._pos=0,this.currentToken=x.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 x.END_OF_INPUT;if(this.currentString=this.read(),this.currentToken=x.UNKNOWN,"_"===this.currentString||this.isLetterOrDigitPattern.test(this.currentString))for(this.currentToken=x.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}(),w=["MODEL","VIEW","PROJECTION","MODELVIEW","MODELVIEWPROJECTION","JOINTMATRIX"],I=["world","view","projection","worldView","worldViewProjection","mBones"],B=["translation","rotation","scale"],F=["position","rotationQuaternion","scaling"],V=function(e,t,r){for(var n in e){var o=e[n];r[t][n]=o}},D=function(e){if(e)for(var t=0;t<e.length/2;t++)e[2*t+1]=1-e[2*t+1]},U=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},k=function(e){var t=null;if(e.translation||e.rotation||e.scale){var r=u.Vector3.FromArray(e.scale||[1,1,1]),n=u.Quaternion.FromArray(e.rotation||[0,0,0,1]),o=u.Vector3.FromArray(e.translation||[0,0,0]);t=u.Matrix.Compose(r,n,o)}else t=u.Matrix.FromArray(e.matrix);return t},G=function(e,t,r,n){for(var o=0;o<n.bones.length;o++)if(n.bones[o].name===r)return n.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 c=e.nodes[l[o]];if(c.jointName&&c.jointName===r){var f=k(s),d=new u.Bone(s.name||"",n,G(e,t,s.jointName,n),f);return d.id=i,d}}}}return null},j=function(e,t){for(var r=0;r<e.length;r++)for(var n=e[r],o=0;o<n.node.children.length;o++)if(n.node.children[o]===t)return n.bone;return null},H=function(e,t){var r=e.nodes,n=r[t];if(n)return{node:n,id:t};for(var o in r)if((n=r[o]).jointName===t)return{node:n,id:o};return null},W=function(e,t){for(var r=0;r<e.jointNames.length;r++)if(e.jointNames[r]===t)return!0;return!1},Y=function(e,t,r,n,o){if(o||(e.scene._blockEntityCollection=!!e.assetContainer,(o=new u.Mesh(t.name||"",e.scene))._parentContainer=e.assetContainer,e.scene._blockEntityCollection=!1,o.id=n),!t.babylonNode)return o;for(var a,i=[],s=null,l=[],c=[],f=[],d=[],h=0;h<r.length;h++){var p=r[h];if(x=e.meshes[p])for(var m=0;m<x.primitives.length;m++){var b=new u.VertexData,y=x.primitives[m];y.mode;var _=y.attributes,A=null,g=null;for(var E in _)if(A=e.accessors[_[E]],g=R.GetBufferFromAccessor(e,A),"NORMAL"===E)b.normals=new Float32Array(g.length),b.normals.set(g);else if("POSITION"===E){if(v.HomogeneousCoordinates){b.positions=new Float32Array(g.length-g.length/4);for(var O=0;O<g.length;O+=4)b.positions[O]=g[O],b.positions[O+1]=g[O+1],b.positions[O+2]=g[O+2]}else b.positions=new Float32Array(g.length),b.positions.set(g);c.push(b.positions.length)}else if(-1!==E.indexOf("TEXCOORD_")){var L=Number(E.split("_")[1]),T=u.VertexBuffer.UVKind+(0===L?"":L+1),N=new Float32Array(g.length);N.set(g),D(N),b.set(N,T)}else"JOINT"===E?(b.matricesIndices=new Float32Array(g.length),b.matricesIndices.set(g)):"WEIGHT"===E?(b.matricesWeights=new Float32Array(g.length),b.matricesWeights.set(g)):"COLOR"===E&&(b.colors=new Float32Array(g.length),b.colors.set(g));if(A=e.accessors[y.indices])g=R.GetBufferFromAccessor(e,A),b.indices=new Int32Array(g.length),b.indices.set(g),d.push(b.indices.length);else{var C=[];for(O=0;O<b.positions.length/3;O++)C.push(O);b.indices=new Int32Array(C),d.push(b.indices.length)}s?s.merge(b):s=b;var M=e.scene.getMaterialById(y.material);i.push(null===M?R.GetDefaultMaterial(e.scene):M),l.push(0===l.length?0:l[l.length-1]+c[c.length-2]),f.push(0===f.length?0:f[f.length-1]+d[d.length-2])}}e.scene._blockEntityCollection=!!e.assetContainer,i.length>1?(a=new u.MultiMaterial("multimat"+n,e.scene)).subMaterials=i:a=new u.StandardMaterial("multimat"+n,e.scene),1===i.length&&(a=i[0]),a._parentContainer=e.assetContainer,o.material||(o.material=a),new u.Geometry(n,e.scene,s,!1,o),o.computeWorldMatrix(!0),e.scene._blockEntityCollection=!1,o.subMeshes=[];var S=0;for(h=0;h<r.length;h++){var x;if(p=r[h],x=e.meshes[p])for(m=0;m<x.primitives.length;m++)x.primitives[m].mode,u.SubMesh.AddToMesh(S,l[S],c[S],f[S],d[S],o,o,!0),S++}return o},J=function(e,t,r,n){e.position&&(e.position=t),(e.rotationQuaternion||e.rotation)&&(e.rotationQuaternion=r),e.scaling&&(e.scaling=n)},q=function(e,t,r){var n=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=Y(e,t,t.meshes,r,t.babylonNode)).skeleton=e.scene.getLastSkeletonById(t.skin),null===a.skeleton&&(a.skeleton=function(e,t,r,n){if(n||(n=new u.Skeleton(t.name||"","",e.scene)),!t.babylonSkeleton)return n;var o=[],a=[];!function(e,t,r,n){for(var o in e.nodes){var a=e.nodes[o],i=o;if(a.jointName&&!W(r,a.jointName)){var s=k(a),l=new u.Bone(a.name||"",t,null,s);l.id=i,n.push({bone:l,node:a,id:i})}}for(var c=0;c<n.length;c++)for(var f=n[c],d=f.node.children,h=0;h<d.length;h++){for(var p=null,m=0;m<n.length;m++)if(n[m].id===d[h]){p=n[m];break}p&&(p.bone._parent=f.bone,f.bone.children.push(p.bone))}}(e,n,t,o),n.bones=[];for(var i=0;i<t.jointNames.length;i++)if(A=H(e,t.jointNames[i])){var s=A.node;if(s){var l=A.id,c=e.scene.getBoneById(l);if(c)n.bones.push(c);else{for(var f=!1,d=null,h=0;h<i;h++){var p=H(e,t.jointNames[h]);if(p){var m=p.node;if(m){var b=m.children;if(b){f=!1;for(var v=0;v<b.length;v++)if(b[v]===l){d=G(e,t,t.jointNames[h],n),f=!0;break}if(f)break}}else u.Tools.Warn("Joint named "+t.jointNames[h]+" does not exist when looking for parent")}}var y=k(s);!d&&o.length>0&&(d=j(o,l))&&-1===a.indexOf(d)&&a.push(d),new u.Bone(s.jointName||"",n,d,y).id=l}}else u.Tools.Warn("Joint named "+t.jointNames[i]+" does not exist")}var _=n.bones;for(n.bones=[],i=0;i<t.jointNames.length;i++){var A;if(A=H(e,t.jointNames[i]))for(h=0;h<_.length;h++)if(_[h].id===A.id){n.bones.push(_[h]);break}}for(n.prepare(),i=0;i<a.length;i++)n.bones.push(a[i]);return n}(e,o,0,o.babylonSkeleton),o.babylonSkeleton||(o.babylonSkeleton=a.skeleton)),n=a}}else if(t.meshes){var a;n=a=Y(e,t,t.mesh?[t.mesh]:t.meshes,r,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 u.FreeCamera(t.camera,u.Vector3.Zero(),e.scene,!1);s.name=t.name||"",s.mode=u.Camera.ORTHOGRAPHIC_CAMERA,s.attachControl(),n=s,s._parentContainer=e.assetContainer}else if("perspective"===i.type){var l=i[i.type],c=new u.FreeCamera(t.camera,u.Vector3.Zero(),e.scene,!1);c.name=t.name||"",c.attachControl(),l.aspectRatio||(l.aspectRatio=e.scene.getEngine().getRenderWidth()/e.scene.getEngine().getRenderHeight()),l.znear&&l.zfar&&(c.maxZ=l.zfar,c.minZ=l.znear),n=c,c._parentContainer=e.assetContainer}e.scene._blockEntityCollection=!1}}}else{var f=e.lights[t.light];if(f)if("ambient"===f.type){var d=f[f.type],h=new u.HemisphericLight(t.light,u.Vector3.Zero(),e.scene);h.name=t.name||"",d.color&&(h.diffuse=u.Color3.FromArray(d.color)),n=h}else if("directional"===f.type){var p=f[f.type],m=new u.DirectionalLight(t.light,u.Vector3.Zero(),e.scene);m.name=t.name||"",p.color&&(m.diffuse=u.Color3.FromArray(p.color)),n=m}else if("point"===f.type){var b=f[f.type],v=new u.PointLight(t.light,u.Vector3.Zero(),e.scene);v.name=t.name||"",b.color&&(v.diffuse=u.Color3.FromArray(b.color)),n=v}else if("spot"===f.type){var y=f[f.type],_=new u.SpotLight(t.light,u.Vector3.Zero(),u.Vector3.Zero(),0,0,e.scene);_.name=t.name||"",y.color&&(_.diffuse=u.Color3.FromArray(y.color)),y.fallOfAngle&&(_.angle=y.fallOfAngle),y.fallOffExponent&&(_.exponent=y.fallOffExponent),n=_}}if(!t.jointName){if(t.babylonNode)return t.babylonNode;if(null===n){e.scene._blockEntityCollection=!!e.assetContainer;var A=new u.Mesh(t.name||"",e.scene);A._parentContainer=e.assetContainer,e.scene._blockEntityCollection=!1,t.babylonNode=A,n=A}}if(null!==n){if(t.matrix&&n instanceof u.Mesh)!function(e,t){if(t.matrix){var r=new u.Vector3(0,0,0),n=new u.Quaternion,o=new u.Vector3(0,0,0);u.Matrix.FromArray(t.matrix).decompose(o,n,r),J(e,r,n,o)}else t.translation&&t.rotation&&t.scale&&J(e,u.Vector3.FromArray(t.translation),u.Quaternion.FromArray(t.rotation),u.Vector3.FromArray(t.scale));e.computeWorldMatrix(!0)}(n,t);else{var g=t.translation||[0,0,0],E=t.rotation||[0,0,0,1],O=t.scale||[1,1,1];J(n,u.Vector3.FromArray(g),u.Quaternion.FromArray(E),u.Vector3.FromArray(O))}n.updateCache(!0),t.babylonNode=n}return n},Z=function(e,t,r,n){void 0===n&&(n=!1);var o=e.nodes[t],a=null;if(n=!(e.importOnlyMeshes&&!n&&e.importMeshesNames)||-1!==e.importMeshesNames.indexOf(o.name||"")||0===e.importMeshesNames.length,!o.jointName&&n&&null!==(a=q(e,o,t))&&(a.id=t,a.parent=r),o.children)for(var i=0;i<o.children.length;i++)Z(e,o.children[i],a,n)},K=function(e){var t=e.currentScene;if(t)for(var r=0;r<t.nodes.length;r++)Z(e,t.nodes[r],null);else for(var n in e.scenes)for(t=e.scenes[n],r=0;r<t.nodes.length;r++)Z(e,t.nodes[r],null);for(function(e){for(var t in e.animations){var r=e.animations[t];if(r.channels&&r.samplers)for(var n=null,o=0;o<r.channels.length;o++){var a=r.channels[o],i=r.samplers[a.sampler];if(i){var s=null,l=null;r.parameters?(s=r.parameters[i.input],l=r.parameters[i.output]):(s=i.input,l=i.output);var c=R.GetBufferFromAccessor(e,e.accessors[s]),f=R.GetBufferFromAccessor(e,e.accessors[l]),d=a.target.id,h=e.scene.getNodeById(d);if(null===h&&(h=e.scene.getNodeByName(d)),null!==h){var p=h instanceof u.Bone,m=a.target.path,b=B.indexOf(m);-1!==b&&(m=F[b]);var v=u.Animation.ANIMATIONTYPE_MATRIX;p||("rotationQuaternion"===m?(v=u.Animation.ANIMATIONTYPE_QUATERNION,h.rotationQuaternion=new u.Quaternion):v=u.Animation.ANIMATIONTYPE_VECTOR3);var y=null,_=[],A=0,g=!1;p&&n&&n.getKeys().length===c.length&&(y=n,g=!0),g||(e.scene._blockEntityCollection=!!e.assetContainer,y=new u.Animation(t,p?"_matrix":m,1,v,u.Animation.ANIMATIONLOOPMODE_CYCLE),e.scene._blockEntityCollection=!1);for(var E=0;E<c.length;E++){var O=null;if("rotationQuaternion"===m?(O=u.Quaternion.FromArray([f[A],f[A+1],f[A+2],f[A+3]]),A+=4):(O=u.Vector3.FromArray([f[A],f[A+1],f[A+2]]),A+=3),p){var L=h,T=u.Vector3.Zero(),N=new u.Quaternion,C=u.Vector3.Zero(),M=L.getBaseMatrix();g&&n&&(M=n.getKeys()[E].value),M.decompose(C,N,T),"position"===m?T=O:"rotationQuaternion"===m?N=O:C=O,O=u.Matrix.Compose(C,N,T)}g?n&&(n.getKeys()[E].value=O):_.push({frame:c[E],value:O})}!g&&y&&(y.setKeys(_),h.animations.push(y)),n=y,e.scene.stopAnimation(h),e.scene.beginAnimation(h,0,c[c.length-1],!0,1)}else u.Tools.Warn("Creating animation named "+t+". But cannot find node named "+d+" to attach to")}}}}(e),r=0;r<e.scene.skeletons.length;r++){var o=e.scene.skeletons[r];e.scene.beginAnimation(o,0,Number.MAX_VALUE,!0,1)}},Q=function(e,t,r){for(var n in t.uniforms){var o=t.uniforms[n],a=t.parameters[o];if(e.currentIdentifier===n&&a.semantic&&!a.source&&!a.node){var i=w.indexOf(a.semantic);if(-1!==i)return delete r[n],I[i]}}return e.currentIdentifier},X=function(e){for(var t in e.materials)ee.LoadMaterialAsync(e,t,(function(){}),(function(){}))},z=function(){function e(){}return e.CreateRuntime=function(e,t,r){var n={extensions:{},accessors:{},buffers:{},bufferViews:{},meshes:{},lights:{},cameras:{},nodes:{},images:{},textures:{},shaders:{},programs:{},samplers:{},techniques:{},materials:{},animations:{},skins:{},extensionsUsed:[],scenes:{},buffersCount:0,shaderscount:0,scene:t,rootUrl:r,loadedBufferCount:0,loadedBufferViews:{},loadedShaderCount:0,importOnlyMeshes:!1,dummyNodes:[],assetContainer:null};return e.extensions&&V(e.extensions,"extensions",n),e.extensionsUsed&&V(e.extensionsUsed,"extensionsUsed",n),e.buffers&&function(e,t){for(var r in e){var n=e[r];t.buffers[r]=n,t.buffersCount++}}(e.buffers,n),e.bufferViews&&V(e.bufferViews,"bufferViews",n),e.accessors&&V(e.accessors,"accessors",n),e.meshes&&V(e.meshes,"meshes",n),e.lights&&V(e.lights,"lights",n),e.cameras&&V(e.cameras,"cameras",n),e.nodes&&V(e.nodes,"nodes",n),e.images&&V(e.images,"images",n),e.textures&&V(e.textures,"textures",n),e.shaders&&function(e,t){for(var r in e){var n=e[r];t.shaders[r]=n,t.shaderscount++}}(e.shaders,n),e.programs&&V(e.programs,"programs",n),e.samplers&&V(e.samplers,"samplers",n),e.techniques&&V(e.techniques,"techniques",n),e.materials&&V(e.materials,"materials",n),e.animations&&V(e.animations,"animations",n),e.skins&&V(e.skins,"skins",n),e.scenes&&(n.scenes=e.scenes),e.scene&&e.scenes&&(n.currentScene=e.scenes[e.scene]),n},e.LoadBufferAsync=function(e,t,r,n,o){var a=e.buffers[t];u.Tools.IsBase64(a.uri)?setTimeout((function(){return r(new Uint8Array(u.Tools.DecodeBase64(a.uri)))})):u.Tools.LoadFile(e.rootUrl+a.uri,(function(e){return r(new Uint8Array(e))}),o,void 0,!0,(function(e){e&&n(e.status+" "+e.statusText)}))},e.LoadTextureBufferAsync=function(e,t,r,n){var o=e.textures[t];if(o&&o.source)if(o.babylonTexture)r(null);else{var a=e.images[o.source];u.Tools.IsBase64(a.uri)?setTimeout((function(){return r(new Uint8Array(u.Tools.DecodeBase64(a.uri)))})):u.Tools.LoadFile(e.rootUrl+a.uri,(function(e){return r(new Uint8Array(e))}),void 0,void 0,!0,(function(e){e&&n(e.status+" "+e.statusText)}))}else n("")},e.CreateTextureAsync=function(e,t,r,n){var o=e.textures[t];if(o.babylonTexture)n(o.babylonTexture);else{var a=e.samplers[o.sampler],i=a.minFilter===L.NEAREST_MIPMAP_NEAREST||a.minFilter===L.NEAREST_MIPMAP_LINEAR||a.minFilter===L.LINEAR_MIPMAP_NEAREST||a.minFilter===L.LINEAR_MIPMAP_LINEAR,s=u.Texture.BILINEAR_SAMPLINGMODE,l=null==r?new Blob:new Blob([r]),c=URL.createObjectURL(l),f=function(){return URL.revokeObjectURL(c)},d=new u.Texture(c,e.scene,!i,!0,s,f,f);void 0!==a.wrapS&&(d.wrapU=R.GetWrapMode(a.wrapS)),void 0!==a.wrapT&&(d.wrapV=R.GetWrapMode(a.wrapT)),d.name=t,o.babylonTexture=d,n(d)}},e.LoadShaderStringAsync=function(e,t,r,n){var o=e.shaders[t];if(u.Tools.IsBase64(o.uri)){var a=atob(o.uri.split(",")[1]);r&&r(a)}else u.Tools.LoadFile(e.rootUrl+o.uri,r,void 0,void 0,!1,(function(e){e&&n&&n(e.status+" "+e.statusText)}))},e.LoadMaterialAsync=function(e,t,r,n){var o=e.materials[t];if(o.technique){var a=e.techniques[o.technique];if(!a){e.scene._blockEntityCollection=!!e.assetContainer;var i=new u.StandardMaterial(t,e.scene);return i._parentContainer=e.assetContainer,e.scene._blockEntityCollection=!1,i.diffuseColor=new u.Color3(.5,.5,.5),i.sideOrientation=u.Material.CounterClockWiseSideOrientation,void r(i)}var s=e.programs[a.program],l=a.states,c=u.Effect.ShadersStore[s.vertexShader+"VertexShader"],f=u.Effect.ShadersStore[s.fragmentShader+"PixelShader"],d="",h="",p=new P(c),m=new P(f),b={},v=[],y=[],_=[];for(var A in a.uniforms){var g=a.uniforms[A],O=a.parameters[g];if(b[A]=O,!O.semantic||O.node||O.source)O.type===E.SAMPLER_2D?_.push(A):v.push(A);else{var L=w.indexOf(O.semantic);-1!==L?(v.push(I[L]),delete b[A]):v.push(A)}}for(var T in a.attributes){var M=a.attributes[T];if((F=a.parameters[M]).semantic){var S=U(F);S&&y.push(S)}}for(;!p.isEnd()&&p.getNextToken();)if(p.currentToken===x.IDENTIFIER){var B=!1;for(var T in a.attributes){M=a.attributes[T];var F=a.parameters[M];if(p.currentIdentifier===T&&F.semantic){d+=U(F),B=!0;break}}B||(d+=Q(p,a,b))}else d+=p.currentString;for(;!m.isEnd()&&m.getNextToken();)m.currentToken===x.IDENTIFIER?h+=Q(m,a,b):h+=m.currentString;var V={vertex:s.vertexShader+t,fragment:s.fragmentShader+t},D={attributes:y,uniforms:v,samplers:_,needAlphaBlending:l&&l.enable&&-1!==l.enable.indexOf(3042)};u.Effect.ShadersStore[s.vertexShader+t+"VertexShader"]=d,u.Effect.ShadersStore[s.fragmentShader+t+"PixelShader"]=h;var k=new u.ShaderMaterial(t,e.scene,V,D);if(k.onError=function(e,t,r){return function(n,o){t.dispose(!0),r("Cannot compile program named "+e.name+". Error: "+o+". Default material will be applied")}}(s,k,n),k.onCompiled=function(e,t,r,n,o,a){return function(i){!function(e,t,r,n,o){var a=n.values||r.parameters,i=r.uniforms,s=function(r){var s=o[r],l=s.type,u=a[i[r]];if(void 0===u&&(u=s.value),!u)return"continue";var c=function(e){return function(r){s.value&&e&&(t.setTexture(e,r),delete o[e])}};l===E.SAMPLER_2D?ee.LoadTextureAsync(e,n.values?u:s.value,c(r),(function(){return c(null)})):s.value&&R.SetUniform(t,r,n.values?u:s.value,l)&&delete o[r]};for(var l in o)s(l)}(e,t,r,n,o),t.onBind=function(i){!function(e,t,r,n,o,a,i){var s=a.values||o.parameters;for(var l in r){var u=r[l],c=u.type;if(c===E.FLOAT_MAT2||c===E.FLOAT_MAT3||c===E.FLOAT_MAT4)if(!u.semantic||u.source||u.node){if(u.semantic&&(u.source||u.node)){var f=t.scene.getNodeByName(u.source||u.node||"");if(null===f&&(f=t.scene.getNodeById(u.source||u.node||"")),null===f)continue;R.SetMatrix(t.scene,f,u,l,n.getEffect())}}else R.SetMatrix(t.scene,e,u,l,n.getEffect());else{var d=s[o.uniforms[l]];if(!d)continue;if(c===E.SAMPLER_2D){var h=t.textures[a.values?d:u.value].babylonTexture;if(null==h)continue;n.getEffect().setTexture(l,h)}else R.SetUniform(n.getEffect(),l,d,c)}}i(n)}(i,e,o,t,r,n,a)}}}(e,k,a,o,b,r),k.sideOrientation=u.Material.CounterClockWiseSideOrientation,l&&l.functions){var G=l.functions;G.cullFace&&G.cullFace[0]!==N.BACK&&(k.backFaceCulling=!1);var j=G.blendFuncSeparate;j&&(j[0]===C.SRC_ALPHA&&j[1]===C.ONE_MINUS_SRC_ALPHA&&j[2]===C.ONE&&j[3]===C.ONE?k.alphaMode=u.Constants.ALPHA_COMBINE:j[0]===C.ONE&&j[1]===C.ONE&&j[2]===C.ZERO&&j[3]===C.ONE?k.alphaMode=u.Constants.ALPHA_ONEONE:j[0]===C.SRC_ALPHA&&j[1]===C.ONE&&j[2]===C.ZERO&&j[3]===C.ONE?k.alphaMode=u.Constants.ALPHA_ADD:j[0]===C.ZERO&&j[1]===C.ONE_MINUS_SRC_COLOR&&j[2]===C.ONE&&j[3]===C.ONE?k.alphaMode=u.Constants.ALPHA_SUBTRACT:j[0]===C.DST_COLOR&&j[1]===C.ZERO&&j[2]===C.ONE&&j[3]===C.ONE?k.alphaMode=u.Constants.ALPHA_MULTIPLY:j[0]===C.SRC_ALPHA&&j[1]===C.ONE_MINUS_SRC_COLOR&&j[2]===C.ONE&&j[3]===C.ONE&&(k.alphaMode=u.Constants.ALPHA_MAXIMIZED))}}else n&&n("No technique found.")},e}(),$=function(){function e(){}return e.RegisterExtension=function(t){e.Extensions[t.name]?u.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,r,n,o,a,i,s){var l=this;return t.useRightHandedSystem=!0,ee.LoadRuntimeAsync(t,r,n,(function(t){t.assetContainer=o,t.importOnlyMeshes=!0,""===e?t.importMeshesNames=[]:"string"==typeof e?t.importMeshesNames=[e]:!e||e instanceof Array?(t.importMeshesNames=[],u.Tools.Warn("Argument meshesNames must be of type string or string[]")):t.importMeshesNames=[e],l._createNodes(t);var r=[],n=[];for(var i in t.nodes){var s=t.nodes[i];s.babylonNode instanceof u.AbstractMesh&&r.push(s.babylonNode)}for(var c in t.skins){var f=t.skins[c];f.babylonSkeleton instanceof u.Skeleton&&n.push(f.babylonSkeleton)}l._loadBuffersAsync(t,(function(){l._loadShadersAsync(t,(function(){X(t),K(t),!v.IncrementalLoading&&a&&a(r,n)}))})),v.IncrementalLoading&&a&&a(r,n)}),s),!0},e.prototype.importMeshAsync=function(e,t,r,n,o,a){var i=this;return new Promise((function(s,l){i._importMeshAsync(e,t,n,o,r,(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,r,n,o,a){var i=this;e.useRightHandedSystem=!0,ee.LoadRuntimeAsync(e,t,r,(function(e){ee.LoadRuntimeExtensionsAsync(e,(function(){i._createNodes(e),i._loadBuffersAsync(e,(function(){i._loadShadersAsync(e,(function(){X(e),K(e),v.IncrementalLoading||n()}))})),v.IncrementalLoading&&n()}),a)}),a)},e.prototype.loadAsync=function(e,t,r,n){var o=this;return new Promise((function(a,i){o._loadAsync(e,t,r,(function(){a()}),n,(function(e){i(new Error(e))}))}))},e.prototype._loadShadersAsync=function(e,t){var r=!1,n=function(r,n){ee.LoadShaderStringAsync(e,r,(function(o){o instanceof ArrayBuffer||(e.loadedShaderCount++,o&&(u.Effect.ShadersStore[r+(n.type===g.VERTEX?"VertexShader":"PixelShader")]=o),e.loadedShaderCount===e.shaderscount&&t())}),(function(){u.Tools.Error("Error when loading shader program named "+r+" located at "+n.uri)}))};for(var o in e.shaders){r=!0;var a=e.shaders[o];a?n.bind(this,o,a)():u.Tools.Error("No shader named: "+o)}r||t()},e.prototype._loadBuffersAsync=function(e,t){var r=!1,n=function(r,n){ee.LoadBufferAsync(e,r,(function(o){e.loadedBufferCount++,o&&(o.byteLength!=e.buffers[r].byteLength&&u.Tools.Error("Buffer named "+r+" is length "+o.byteLength+". Expected: "+n.byteLength),e.loadedBufferViews[r]=o),e.loadedBufferCount===e.buffersCount&&t()}),(function(){u.Tools.Error("Error when loading buffer named "+r+" located at "+n.uri)}))};for(var o in e.buffers){r=!0;var a=e.buffers[o];a?n.bind(this,o,a)():u.Tools.Error("No buffer named: "+o)}r||t()},e.prototype._createNodes=function(e){var t=e.currentScene;if(t)for(var r=0;r<t.nodes.length;r++)Z(e,t.nodes[r],null);else for(var n in e.scenes)for(t=e.scenes[n],r=0;r<t.nodes.length;r++)Z(e,t.nodes[r],null)},e.Extensions={},e}(),ee=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,r,n,o){return!1},e.prototype.loadRuntimeExtensionsAsync=function(e,t,r){return!1},e.prototype.loadBufferAsync=function(e,t,r,n,o){return!1},e.prototype.loadTextureBufferAsync=function(e,t,r,n){return!1},e.prototype.createTextureAsync=function(e,t,r,n,o){return!1},e.prototype.loadShaderStringAsync=function(e,t,r,n){return!1},e.prototype.loadMaterialAsync=function(e,t,r,n){return!1},e.LoadRuntimeAsync=function(t,r,n,o,a){e._ApplyExtensions((function(e){return e.loadRuntimeAsync(t,r,n,o,a)}),(function(){setTimeout((function(){o&&o(z.CreateRuntime(r.json,t,n))}))}))},e.LoadRuntimeExtensionsAsync=function(t,r,n){e._ApplyExtensions((function(e){return e.loadRuntimeExtensionsAsync(t,r,n)}),(function(){setTimeout((function(){r()}))}))},e.LoadBufferAsync=function(t,r,n,o,a){e._ApplyExtensions((function(e){return e.loadBufferAsync(t,r,n,o,a)}),(function(){z.LoadBufferAsync(t,r,n,o,a)}))},e.LoadTextureAsync=function(t,r,n,o){e._LoadTextureBufferAsync(t,r,(function(a){a&&e._CreateTextureAsync(t,r,a,n,o)}),o)},e.LoadShaderStringAsync=function(t,r,n,o){e._ApplyExtensions((function(e){return e.loadShaderStringAsync(t,r,n,o)}),(function(){z.LoadShaderStringAsync(t,r,n,o)}))},e.LoadMaterialAsync=function(t,r,n,o){e._ApplyExtensions((function(e){return e.loadMaterialAsync(t,r,n,o)}),(function(){z.LoadMaterialAsync(t,r,n,o)}))},e._LoadTextureBufferAsync=function(t,r,n,o){e._ApplyExtensions((function(e){return e.loadTextureBufferAsync(t,r,n,o)}),(function(){z.LoadTextureBufferAsync(t,r,n,o)}))},e._CreateTextureAsync=function(t,r,n,o,a){e._ApplyExtensions((function(e){return e.createTextureAsync(t,r,n,o,a)}),(function(){z.CreateTextureAsync(t,r,n,o)}))},e._ApplyExtensions=function(e,t){for(var r in $.Extensions)if(e($.Extensions[r]))return;t()},e}();v._CreateGLTF1Loader=function(){return new $};var te=function(e){function t(){return e.call(this,"KHR_binary_glTF")||this}return S(t,e),t.prototype.loadRuntimeAsync=function(e,t,r,n){var o=t.json.extensionsUsed;return!(!o||-1===o.indexOf(this.name)||!t.bin||(this._bin=t.bin,n(z.CreateRuntime(t.json,e,r)),0))},t.prototype.loadBufferAsync=function(e,t,r,n){return-1!==e.extensionsUsed.indexOf(this.name)&&"binary_glTF"===t&&(this._bin.readAsync(0,this._bin.byteLength).then(r,(function(e){return n(e.message)})),!0)},t.prototype.loadTextureBufferAsync=function(e,t,r){var n=e.textures[t],o=e.images[n.source];if(!o.extensions||!(this.name in o.extensions))return!1;var a=o.extensions[this.name],i=e.bufferViews[a.bufferView];return r(R.GetBufferFromBufferView(e,i,0,i.byteLength,A.UNSIGNED_BYTE)),!0},t.prototype.loadShaderStringAsync=function(e,t,r){var n=e.shaders[t];if(!n.extensions||!(this.name in n.extensions))return!1;var o=n.extensions[this.name],a=e.bufferViews[o.bufferView],i=R.GetBufferFromBufferView(e,a,0,a.byteLength,A.UNSIGNED_BYTE);return setTimeout((function(){var e=R.DecodeBufferToText(i);r(e)})),!0},t}(ee);$.RegisterExtension(new te);var re=function(e){function t(){return e.call(this,"KHR_materials_common")||this}return S(t,e),t.prototype.loadRuntimeExtensionsAsync=function(e){if(!e.extensions)return!1;var t=e.extensions[this.name];if(!t)return!1;var r=t.lights;if(r)for(var n in r){var o=r[n];switch(o.type){case"ambient":var a=new u.HemisphericLight(o.name,new u.Vector3(0,1,0),e.scene),i=o.ambient;i&&(a.diffuse=u.Color3.FromArray(i.color||[1,1,1]));break;case"point":var s=new u.PointLight(o.name,new u.Vector3(10,10,10),e.scene),l=o.point;l&&(s.diffuse=u.Color3.FromArray(l.color||[1,1,1]));break;case"directional":var c=new u.DirectionalLight(o.name,new u.Vector3(0,-1,0),e.scene),f=o.directional;f&&(c.diffuse=u.Color3.FromArray(f.color||[1,1,1]));break;case"spot":var d=o.spot;d&&(new u.SpotLight(o.name,new u.Vector3(0,10,0),new u.Vector3(0,-1,0),d.fallOffAngle||Math.PI,d.fallOffExponent||0,e.scene).diffuse=u.Color3.FromArray(d.color||[1,1,1]));break;default:u.Tools.Warn('GLTF Material Common extension: light type "'+o.type+"” not supported")}}return!1},t.prototype.loadMaterialAsync=function(e,t,r,n){var o=e.materials[t];if(!o||!o.extensions)return!1;var a=o.extensions[this.name];if(!a)return!1;var i=new u.StandardMaterial(t,e.scene);return i.sideOrientation=u.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",n):i.ambientColor=u.Color3.FromArray(a.values.ambient||[0,0,0]),"string"==typeof a.values.diffuse?this._loadTexture(e,a.values.diffuse,i,"diffuseTexture",n):i.diffuseColor=u.Color3.FromArray(a.values.diffuse||[0,0,0]),"string"==typeof a.values.emission?this._loadTexture(e,a.values.emission,i,"emissiveTexture",n):i.emissiveColor=u.Color3.FromArray(a.values.emission||[0,0,0]),"string"==typeof a.values.specular?this._loadTexture(e,a.values.specular,i,"specularTexture",n):i.specularColor=u.Color3.FromArray(a.values.specular||[0,0,0]),!0},t.prototype._loadTexture=function(e,t,r,n,o){z.LoadTextureBufferAsync(e,t,(function(o){z.CreateTextureAsync(e,t,o,(function(e){return r[n]=e}))}),o)},t}(ee);$.RegisterExtension(new re);var ne=void 0!==n.g?n.g:"undefined"!=typeof window?window:void 0;if(void 0!==ne)for(var oe in ne.BABYLON=ne.BABYLON||{},ne.BABYLON.GLTF1=ne.BABYLON.GLTF1||{},s)ne.BABYLON.GLTF1[oe]=s[oe];const ae=l;return o.default})())); | ||
//# sourceMappingURL=babylon.glTF1FileLoader.min.js.map |
{ | ||
"name": "babylonjs-loaders", | ||
"version": "7.18.0", | ||
"version": "7.19.0", | ||
"main": "babylonjs.loaders.js", | ||
@@ -18,4 +18,4 @@ "types": "babylonjs.loaders.module.d.ts", | ||
"dependencies": { | ||
"babylonjs": "^7.18.0", | ||
"babylonjs-gltf2interface": "^7.18.0" | ||
"babylonjs": "^7.19.0", | ||
"babylonjs-gltf2interface": "^7.19.0" | ||
}, | ||
@@ -22,0 +22,0 @@ "devDependencies": { |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
8529852
52108
Updatedbabylonjs@^7.19.0