babylonjs-loaders 9.8.0 → 9.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("babylonjs")):"function"==typeof define&&define.amd?define(["exports","babylonjs"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).BABYLON=e.BABYLON||{},e.BABYLON)}(this,function(e,t){"use strict";var n=function(e,t){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},n(e,t)};function r(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}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}var o=function(){return o=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},o.apply(this,arguments)};function a(e,t,n,r){return new(n||(n=Promise))(function(o,a){function i(e){try{l(r.next(e))}catch(e){a(e)}}function s(e){try{l(r.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(i,s)}l((r=r.apply(e,t||[])).next())})}function i(e,t){var n,r,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=s(0),i.throw=s(1),i.return=s(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(l){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(n=1,r&&(o=2&s[0]?r.return:s[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,s[1])).done)return o;switch(r=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,r=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){a.label=s[1];break}if(6===s[0]&&a.label<o[1]){a.label=o[1],o=s;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(s);break}o[2]&&a.ops.pop(),a.trys.pop();continue}s=t.call(e,a)}catch(e){s=[6,e],r=0}finally{n=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,l])}}}function s(e,t,n,r){var o={externalResourceFunction:r};return n&&(o.uri="file:"===t?n:t+n),ArrayBuffer.isView(e)?GLTFValidator.validateBytes(e,o):GLTFValidator.validateString(e,o)}function l(){var e=[];onmessage=function(t){var n=t.data;switch(n.id){case"init":importScripts(n.url);break;case"validate":s(n.data,n.rootUrl,n.fileName,function(t){return new Promise(function(n,r){var o=e.length;e.push({resolve:n,reject:r}),postMessage({id:"getExternalResource",index:o,uri:t})})}).then(function(e){postMessage({id:"validate.resolve",value:e})},function(e){postMessage({id:"validate.reject",reason:e})});break;case"getExternalResource.resolve":e[n.index].resolve(n.value);break;case"getExternalResource.reject":e[n.index].reject(n.reason)}}}Object.create,Object.create,"function"==typeof SuppressedError&&SuppressedError;var u,c,f,h=function(){function e(){}return e.ValidateAsync=function(n,r,o,a){var i=this;return"function"==typeof Worker?new Promise(function(u,c){var f="".concat(s,"(").concat(l,")()"),h=URL.createObjectURL(new Blob([f],{type:"application/javascript"})),p=new Worker(h),d=function(e){p.removeEventListener("error",d),p.removeEventListener("message",m),c(e)},m=function(t){var n=t.data;switch(n.id){case"getExternalResource":a(n.uri).then(function(e){p.postMessage({id:"getExternalResource.resolve",index:n.index,value:e},[e.buffer])},function(e){p.postMessage({id:"getExternalResource.reject",index:n.index,reason:e})});break;case"validate.resolve":p.removeEventListener("error",d),p.removeEventListener("message",m),e._LastResults=n.value,u(n.value),p.terminate();break;case"validate.reject":p.removeEventListener("error",d),p.removeEventListener("message",m),c(n.reason),p.terminate()}};if(p.addEventListener("error",d),p.addEventListener("message",m),p.postMessage({id:"init",url:t.Tools.GetBabylonScriptURL(i.Configuration.url)}),ArrayBuffer.isView(n)){var _=n.slice();p.postMessage({id:"validate",data:_,rootUrl:r,fileName:o},[_.buffer])}else p.postMessage({id:"validate",data:n,rootUrl:r,fileName:o})}):(this._LoadScriptPromise||(this._LoadScriptPromise=t.Tools.LoadBabylonScriptAsync(this.Configuration.url)),this._LoadScriptPromise.then(function(){return s(n,r,o,a)}))},e.Configuration={url:"".concat(t.Tools._DefaultCdnUrl,"/gltf_validator.js")},e._LastResults=null,e}(),p={__proto__:null,GLTFValidation:h},d="Z2xURg",m="gltf",_={".gltf":{isBinary:!1,mimeType:"model/gltf+json"},".glb":{isBinary:!0,mimeType:"model/gltf-binary"}};function b(e,t,n){try{return Promise.resolve(new Uint8Array(e,t,n))}catch(e){return Promise.reject(e)}}e.GLTFLoaderCoordinateSystemMode=void 0,(u=e.GLTFLoaderCoordinateSystemMode||(e.GLTFLoaderCoordinateSystemMode={}))[u.AUTO=0]="AUTO",u[u.FORCE_RIGHT_HANDED=1]="FORCE_RIGHT_HANDED",e.GLTFLoaderAnimationStartMode=void 0,(c=e.GLTFLoaderAnimationStartMode||(e.GLTFLoaderAnimationStartMode={}))[c.NONE=0]="NONE",c[c.FIRST=1]="FIRST",c[c.ALL=2]="ALL",e.GLTFLoaderState=void 0,(f=e.GLTFLoaderState||(e.GLTFLoaderState={}))[f.LOADING=0]="LOADING",f[f.READY=1]="READY",f[f.COMPLETE=2]="COMPLETE";var g=function(){this.alwaysComputeBoundingBox=!1,this.alwaysComputeSkeletonRootNode=!1,this.animationStartMode=e.GLTFLoaderAnimationStartMode.FIRST,this.compileMaterials=!1,this.compileShadowGenerators=!1,this.coordinateSystemMode=e.GLTFLoaderCoordinateSystemMode.AUTO,this.createInstances=!0,this.loadAllMaterials=!1,this.loadMorphTargets=!0,this.loadNodeAnimations=!0,this.loadOnlyMaterials=!1,this.loadSkins=!0,this.skipMaterials=!1,this.targetFps=60,this.transparencyAsCoverage=!1,this.useClipPlane=!1,this.useGltfTextureNames=!1,this.useRangeRequests=!1,this.useSRGBBuffers=!0,this.validate=!1,this.useOpenPBR=!1,this.dontUseTransmissionHelper=!1},y=new g,v=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.extensionOptions={},t.preprocessUrlAsync=function(e){return Promise.resolve(e)},t}return r(t,e),t.prototype.copyFrom=function(e){var t,n,r,o,a,i,s,l,u,c,f,h,p,d,m,_,b,g,y,v,T,x,A,C,w,O;e&&(this.alwaysComputeBoundingBox=null!==(t=e.alwaysComputeBoundingBox)&&void 0!==t?t:this.alwaysComputeBoundingBox,this.alwaysComputeSkeletonRootNode=null!==(n=e.alwaysComputeSkeletonRootNode)&&void 0!==n?n:this.alwaysComputeSkeletonRootNode,this.animationStartMode=null!==(r=e.animationStartMode)&&void 0!==r?r:this.animationStartMode,this.capturePerformanceCounters=null!==(o=e.capturePerformanceCounters)&&void 0!==o?o:this.capturePerformanceCounters,this.compileMaterials=null!==(a=e.compileMaterials)&&void 0!==a?a:this.compileMaterials,this.compileShadowGenerators=null!==(i=e.compileShadowGenerators)&&void 0!==i?i:this.compileShadowGenerators,this.coordinateSystemMode=null!==(s=e.coordinateSystemMode)&&void 0!==s?s:this.coordinateSystemMode,this.createInstances=null!==(l=e.createInstances)&&void 0!==l?l:this.createInstances,this.customRootNode=e.customRootNode,this.extensionOptions=null!==(u=e.extensionOptions)&&void 0!==u?u:this.extensionOptions,this.loadAllMaterials=null!==(c=e.loadAllMaterials)&&void 0!==c?c:this.loadAllMaterials,this.loadMorphTargets=null!==(f=e.loadMorphTargets)&&void 0!==f?f:this.loadMorphTargets,this.loadNodeAnimations=null!==(h=e.loadNodeAnimations)&&void 0!==h?h:this.loadNodeAnimations,this.loadOnlyMaterials=null!==(p=e.loadOnlyMaterials)&&void 0!==p?p:this.loadOnlyMaterials,this.loadSkins=null!==(d=e.loadSkins)&&void 0!==d?d:this.loadSkins,this.loggingEnabled=null!==(m=e.loggingEnabled)&&void 0!==m?m:this.loggingEnabled,this.onCameraLoaded=e.onCameraLoaded,this.onMaterialLoaded=e.onMaterialLoaded,this.onMeshLoaded=e.onMeshLoaded,this.onParsed=e.onParsed,this.onSkinLoaded=e.onSkinLoaded,this.onTextureLoaded=e.onTextureLoaded,this.onValidated=e.onValidated,this.preprocessUrlAsync=null!==(_=e.preprocessUrlAsync)&&void 0!==_?_:this.preprocessUrlAsync,this.skipMaterials=null!==(b=e.skipMaterials)&&void 0!==b?b:this.skipMaterials,this.targetFps=null!==(g=e.targetFps)&&void 0!==g?g:this.targetFps,this.transparencyAsCoverage=null!==(y=e.transparencyAsCoverage)&&void 0!==y?y:this.transparencyAsCoverage,this.useClipPlane=null!==(v=e.useClipPlane)&&void 0!==v?v:this.useClipPlane,this.useGltfTextureNames=null!==(T=e.useGltfTextureNames)&&void 0!==T?T:this.useGltfTextureNames,this.useOpenPBR=null!==(x=e.useOpenPBR)&&void 0!==x?x:this.useOpenPBR,this.useRangeRequests=null!==(A=e.useRangeRequests)&&void 0!==A?A:this.useRangeRequests,this.useSRGBBuffers=null!==(C=e.useSRGBBuffers)&&void 0!==C?C:this.useSRGBBuffers,this.validate=null!==(w=e.validate)&&void 0!==w?w:this.validate,this.dontUseTransmissionHelper=null!==(O=e.dontUseTransmissionHelper)&&void 0!==O?O:this.dontUseTransmissionHelper)},t}(g),T=function(n){function a(e){var r=n.call(this)||this;return r.onParsedObservable=new t.Observable,r.onMeshLoadedObservable=new t.Observable,r.onSkinLoadedObservable=new t.Observable,r.onTextureLoadedObservable=new t.Observable,r.onMaterialLoadedObservable=new t.Observable,r.onCameraLoadedObservable=new t.Observable,r.onCompleteObservable=new t.Observable,r.onErrorObservable=new t.Observable,r.onDisposeObservable=new t.Observable,r.onExtensionLoadedObservable=new t.Observable,r.onValidatedObservable=new t.Observable,r._loader=null,r._state=null,r._requests=new Array,r.name=m,r.extensions=_,r.onLoaderStateChangedObservable=new t.Observable,r._logIndentLevel=0,r._loggingEnabled=!1,r._log=r._logDisabled,r._capturePerformanceCounters=!1,r._startPerformanceCounter=r._startPerformanceCounterDisabled,r._endPerformanceCounter=r._endPerformanceCounterDisabled,r.copyFrom(Object.assign(o({},y),e)),r}return r(a,n),Object.defineProperty(a.prototype,"onParsed",{set:function(e){this._onParsedObserver&&this.onParsedObservable.remove(this._onParsedObserver),e&&(this._onParsedObserver=this.onParsedObservable.add(e))},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"onMeshLoaded",{set:function(e){this._onMeshLoadedObserver&&this.onMeshLoadedObservable.remove(this._onMeshLoadedObserver),e&&(this._onMeshLoadedObserver=this.onMeshLoadedObservable.add(e))},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"onSkinLoaded",{set:function(e){this._onSkinLoadedObserver&&this.onSkinLoadedObservable.remove(this._onSkinLoadedObserver),e&&(this._onSkinLoadedObserver=this.onSkinLoadedObservable.add(function(t){return e(t.node,t.skinnedNode)}))},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"onTextureLoaded",{set:function(e){this._onTextureLoadedObserver&&this.onTextureLoadedObservable.remove(this._onTextureLoadedObserver),e&&(this._onTextureLoadedObserver=this.onTextureLoadedObservable.add(e))},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"onMaterialLoaded",{set:function(e){this._onMaterialLoadedObserver&&this.onMaterialLoadedObservable.remove(this._onMaterialLoadedObserver),e&&(this._onMaterialLoadedObserver=this.onMaterialLoadedObservable.add(e))},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"onCameraLoaded",{set:function(e){this._onCameraLoadedObserver&&this.onCameraLoadedObservable.remove(this._onCameraLoadedObserver),e&&(this._onCameraLoadedObserver=this.onCameraLoadedObservable.add(e))},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"onComplete",{set:function(e){this._onCompleteObserver&&this.onCompleteObservable.remove(this._onCompleteObserver),this._onCompleteObserver=this.onCompleteObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"onError",{set:function(e){this._onErrorObserver&&this.onErrorObservable.remove(this._onErrorObserver),this._onErrorObserver=this.onErrorObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"onDispose",{set:function(e){this._onDisposeObserver&&this.onDisposeObservable.remove(this._onDisposeObserver),this._onDisposeObserver=this.onDisposeObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"onExtensionLoaded",{set:function(e){this._onExtensionLoadedObserver&&this.onExtensionLoadedObservable.remove(this._onExtensionLoadedObserver),this._onExtensionLoadedObserver=this.onExtensionLoadedObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(a.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(a.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(a.prototype,"onValidated",{set:function(e){this._onValidatedObserver&&this.onValidatedObservable.remove(this._onValidatedObserver),this._onValidatedObserver=this.onValidatedObservable.add(e)},enumerable:!1,configurable:!0}),a.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()},a.prototype.loadFile=function(e,n,r,o,a,i,s,l){var u=this;if(ArrayBuffer.isView(n))return this._loadBinary(e,n,r,o,s,l),null;this._progressCallback=a;var c=n.name||t.Tools.GetFilename(n);if(i){if(this.useRangeRequests){this.validate&&t.Logger.Warn("glTF validation is not supported when range requests are enabled");var f={abort:function(){},onCompleteObservable:new t.Observable},h={readAsync:function(t,r){return new Promise(function(o,a){u._loadFile(e,n,function(e){o(new Uint8Array(e))},!0,function(e){a(e)},function(e){e.setRequestHeader("Range","bytes=".concat(t,"-").concat(t+r-1))})})},byteLength:0};return this._unpackBinaryAsync(new t.DataReader(h)).then(function(e){f.onCompleteObservable.notifyObservers(f),o(e)},s?function(e){return s(void 0,e)}:void 0),f}return this._loadFile(e,n,function(n){u._validate(e,new Uint8Array(n,0,n.byteLength),r,c),u._unpackBinaryAsync(new t.DataReader({readAsync:function(e,t){return b(n,e,t)},byteLength:n.byteLength})).then(function(e){o(e)},s?function(e){return s(void 0,e)}:void 0)},!0,s)}return this._loadFile(e,n,function(t){try{u._validate(e,t,r,c),o({json:u._parseJson(t)})}catch(e){s&&s()}},!1,s)},a.prototype._loadBinary=function(e,n,r,o,a,i){this._validate(e,new Uint8Array(n.buffer,n.byteOffset,n.byteLength),r,i),this._unpackBinaryAsync(new t.DataReader({readAsync:function(e,t){return function(e,t,n){try{if(t<0||t>=e.byteLength)throw new RangeError("Offset is out of range.");if(t+n>e.byteLength)throw new RangeError("Length is out of range.");return Promise.resolve(new Uint8Array(e.buffer,e.byteOffset+t,n))}catch(e){return Promise.reject(e)}}(n,e,t)},byteLength:n.byteLength})).then(function(e){o(e)},a?function(e){return a(void 0,e)}:void 0)},a.prototype.importMeshAsync=function(e,t,n,r,o,a){var i=this;return Promise.resolve().then(function(){return i.onParsedObservable.notifyObservers(n),i.onParsedObservable.clear(),i._log("Loading ".concat(a||"")),i._loader=i._getLoader(n),i._loader.importMeshAsync(e,t,null,n,r,o,a)})},a.prototype.loadAsync=function(e,t,n,r,o){var a=this;return Promise.resolve().then(function(){return a.onParsedObservable.notifyObservers(t),a.onParsedObservable.clear(),a._log("Loading ".concat(o||"")),a._loader=a._getLoader(t),a._loader.loadAsync(e,t,n,r,o)})},a.prototype.loadAssetContainerAsync=function(e,n,r,o,a){var i=this;return Promise.resolve().then(function(){i.onParsedObservable.notifyObservers(n),i.onParsedObservable.clear(),i._log("Loading ".concat(a||"")),i._loader=i._getLoader(n);var s=new t.AssetContainer(e),l=[];i.onMaterialLoadedObservable.add(function(e){l.push(e)});var u=[];i.onTextureLoadedObservable.add(function(e){u.push(e)});var c=[];i.onCameraLoadedObservable.add(function(e){c.push(e)});var f=[];return i.onMeshLoadedObservable.add(function(e){e.morphTargetManager&&f.push(e.morphTargetManager)}),i._loader.importMeshAsync(null,e,s,n,r,o,a).then(function(e){return Array.prototype.push.apply(s.geometries,e.geometries),Array.prototype.push.apply(s.meshes,e.meshes),Array.prototype.push.apply(s.particleSystems,e.particleSystems),Array.prototype.push.apply(s.skeletons,e.skeletons),Array.prototype.push.apply(s.animationGroups,e.animationGroups),Array.prototype.push.apply(s.materials,l),Array.prototype.push.apply(s.textures,u),Array.prototype.push.apply(s.lights,e.lights),Array.prototype.push.apply(s.transformNodes,e.transformNodes),Array.prototype.push.apply(s.cameras,c),Array.prototype.push.apply(s.morphTargetManagers,f),s})})},a.prototype.canDirectLoad=function(e){return function(e){return-1!==e.indexOf("asset")&&-1!==e.indexOf("version")||e.startsWith("data:base64,"+d)||e.startsWith("data:;base64,"+d)||e.startsWith("data:application/octet-stream;base64,"+d)||e.startsWith("data:model/gltf-binary;base64,"+d)}(e)},a.prototype.directLoad=function(e,n){if(n.startsWith("base64,"+d)||n.startsWith(";base64,"+d)||n.startsWith("application/octet-stream;base64,"+d)||n.startsWith("model/gltf-binary;base64,"+d)){var r=t.DecodeBase64UrlToBinary(n);return this._validate(e,new Uint8Array(r,0,r.byteLength)),this._unpackBinaryAsync(new t.DataReader({readAsync:function(e,t){return b(r,e,t)},byteLength:r.byteLength}))}return this._validate(e,n),Promise.resolve({json:this._parseJson(n)})},a.prototype.createPlugin=function(e){return new a(e[m])},Object.defineProperty(a.prototype,"loaderState",{get:function(){return this._state},enumerable:!1,configurable:!0}),a.prototype.whenCompleteAsync=function(){var e=this;return new Promise(function(t,n){e.onCompleteObservable.addOnce(function(){t()}),e.onErrorObservable.addOnce(function(e){n(e)})})},a.prototype._setState=function(t){this._state!==t&&(this._state=t,this.onLoaderStateChangedObservable.notifyObservers(this._state),this._log(e.GLTFLoaderState[this._state]))},a.prototype._loadFile=function(e,t,n,r,o,a){var i=this,s=e._loadFile(t,n,function(e){i._onProgress(e,s)},!0,r,o,a);return s.onCompleteObservable.add(function(){s._lengthComputable=!0,s._total=s._loaded}),this._requests.push(s),s},a.prototype._onProgress=function(e,t){if(this._progressCallback){t._lengthComputable=e.lengthComputable,t._loaded=e.loaded,t._total=e.total;for(var n=!0,r=0,o=0,a=0,i=this._requests;a<i.length;a++){var s=i[a];if(void 0===s._lengthComputable||void 0===s._loaded||void 0===s._total)return;n=n&&s._lengthComputable,r+=s._loaded,o+=s._total}this._progressCallback({lengthComputable:n,loaded:r,total:n?o:0})}},a.prototype._validate=function(e,n,r,o){var a=this;void 0===r&&(r=""),void 0===o&&(o=""),this.validate&&(this._startPerformanceCounter("Validate JSON"),h.ValidateAsync(n,r,o,function(t){return a.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){a._endPerformanceCounter("Validate JSON"),a.onValidatedObservable.notifyObservers(e),a.onValidatedObservable.clear()},function(e){a._endPerformanceCounter("Validate JSON"),t.Tools.Warn("Failed to validate: ".concat(e.message)),a.onValidatedObservable.clear()}))},a.prototype._getLoader=function(e){var t=e.json.asset||{};this._log("Asset version: ".concat(t.version)),t.minVersion&&this._log("Asset minimum version: ".concat(t.minVersion)),t.generator&&this._log("Asset generator: ".concat(t.generator));var n=a._parseVersion(t.version);if(!n)throw new Error("Invalid version: "+t.version);if(void 0!==t.minVersion){var r=a._parseVersion(t.minVersion);if(!r)throw new Error("Invalid minimum version: "+t.minVersion);if(a._compareVersion(r,{major:2,minor:0})>0)throw new Error("Incompatible minimum version: "+t.minVersion)}var o={1:a._CreateGLTF1Loader,2:a._CreateGLTF2Loader}[n.major];if(!o)throw new Error("Unsupported version: "+t.version);return o(this)},a.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},a.prototype._unpackBinaryAsync=function(e){var n=this;return this._startPerformanceCounter("Unpack Binary"),e.loadAsync(20).then(function(){var r=e.readUint32();if(1179937895!==r)throw new t.RuntimeError("Unexpected magic: "+r,t.ErrorCodes.GLTFLoaderUnexpectedMagicError);var o=e.readUint32();n.loggingEnabled&&n._log("Binary version: ".concat(o));var a,i=e.readUint32();switch(n.useRangeRequests||i===e.buffer.byteLength||t.Logger.Warn("Length in header does not match actual data length: ".concat(i," != ").concat(e.buffer.byteLength)),o){case 1:a=n._unpackBinaryV1Async(e,i);break;case 2:a=n._unpackBinaryV2Async(e,i);break;default:throw new Error("Unsupported version: "+o)}return n._endPerformanceCounter("Unpack Binary"),a})},a.prototype._unpackBinaryV1Async=function(e,t){var n=e.readUint32(),r=e.readUint32();if(0!==r)throw new Error("Unexpected content format: ".concat(r));var o=t-e.byteOffset,a={json:this._parseJson(e.readString(n)),bin:null};if(0!==o){var i=e.byteOffset;a.bin={readAsync:function(t,n){return e.buffer.readAsync(i+t,n)},byteLength:o}}return Promise.resolve(a)},a.prototype._unpackBinaryV2Async=function(e,t){var n=this,r=1313821514,o=e.readUint32();if(e.readUint32()!==r)throw new Error("First chunk format is not JSON");return e.byteOffset+o===t?e.loadAsync(o).then(function(){return{json:n._parseJson(e.readString(o)),bin:null}}):e.loadAsync(o+8).then(function(){var a={json:n._parseJson(e.readString(o)),bin:null},i=function(){var n=e.readUint32();switch(e.readUint32()){case r:throw new Error("Unexpected JSON chunk");case 5130562:var o=e.byteOffset;a.bin={readAsync:function(t,n){return e.buffer.readAsync(o+t,n)},byteLength:n},e.skipBytes(n);break;default:e.skipBytes(n)}return e.byteOffset!==t?e.loadAsync(8).then(i):Promise.resolve(a)};return i()})},a._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},a._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},a.prototype._logOpen=function(e){this._log(e),this._logIndentLevel++},a.prototype._logClose=function(){--this._logIndentLevel},a.prototype._logEnabled=function(e){var n=a._logSpaces.substring(0,2*this._logIndentLevel);t.Logger.Log("".concat(n).concat(e))},a.prototype._logDisabled=function(e){},a.prototype._startPerformanceCounterEnabled=function(e){t.Tools.StartPerformanceCounter(e)},a.prototype._startPerformanceCounterDisabled=function(e){},a.prototype._endPerformanceCounterEnabled=function(e){t.Tools.EndPerformanceCounter(e)},a.prototype._endPerformanceCounterDisabled=function(e){},a.IncrementalLoading=!0,a.HomogeneousCoordinates=!1,a._logSpaces=" ",a}(v);t.RegisterSceneLoaderPlugin(new T);var x={__proto__:null,GLTFFileLoader:T,get GLTFLoaderAnimationStartMode(){return e.GLTFLoaderAnimationStartMode},get GLTFLoaderCoordinateSystemMode(){return e.GLTFLoaderCoordinateSystemMode},GLTFLoaderDefaultOptions:y,get GLTFLoaderState(){return e.GLTFLoaderState}},A="undefined"!=typeof global?global:"undefined"!=typeof window?window:void 0;if(void 0!==A){for(var C in A.BABYLON=A.BABYLON||{},x)A.BABYLON[C]=x[C];for(var C in p)A.BABYLON[C]=p[C]}var w=[{regex:new RegExp("^/nodes/\\d+/extensions/")}],O=function(){function e(e,t){this._gltf=e,this._infoTree=t}return e.prototype.convert=function(e){var t=this._gltf,n=this._infoTree,r=void 0;if(!e.startsWith("/"))throw new Error("Path must start with a /");var o=e.split("/");if(o.shift(),o[o.length-1].includes(".length")){var a=o[o.length-1].split(".");o.pop(),o.push.apply(o,a)}for(var i=!1,s=0,l=o;s<l.length;s++){var u=l[s],c="length"===u;if(c&&!n.__array__)throw new Error("Path ".concat(e," is invalid"));if(n.__ignoreObjectTree__&&(i=!0),n.__array__&&!c)n=n.__array__;else if(!(n=n[u]))throw new Error("Path ".concat(e," is invalid"));if(!i)if(void 0===t){if(!w.find(function(t){return t.regex.test(e)}))throw new Error("Path ".concat(e," is invalid"))}else c||(t=null==t?void 0:t[u]);(n.__target__||c)&&(r=t)}return{object:r,info:n}},e}(),M={length:{type:"number",get:function(e){return e.length},getTarget:function(e){return e.map(function(e){return e._babylonTransformNode})},getPropertyName:[function(){return"length"}]},__array__:{__target__:!0,translation:{type:"Vector3",get:function(e){var t;return null===(t=e._babylonTransformNode)||void 0===t?void 0:t.position},set:function(e,t){var n;return null===(n=t._babylonTransformNode)||void 0===n?void 0:n.position.copyFrom(e)},getTarget:function(e){return e._babylonTransformNode},getPropertyName:[function(){return"position"}]},rotation:{type:"Quaternion",get:function(e){var t;return null===(t=e._babylonTransformNode)||void 0===t?void 0:t.rotationQuaternion},set:function(e,t){var n,r;return null===(r=null===(n=t._babylonTransformNode)||void 0===n?void 0:n.rotationQuaternion)||void 0===r?void 0:r.copyFrom(e)},getTarget:function(e){return e._babylonTransformNode},getPropertyName:[function(){return"rotationQuaternion"}]},scale:{type:"Vector3",get:function(e){var t;return null===(t=e._babylonTransformNode)||void 0===t?void 0:t.scaling},set:function(e,t){var n;return null===(n=t._babylonTransformNode)||void 0===n?void 0:n.scaling.copyFrom(e)},getTarget:function(e){return e._babylonTransformNode},getPropertyName:[function(){return"scaling"}]},weights:{length:{type:"number",get:function(e){return e._numMorphTargets},getTarget:function(e){return e._babylonTransformNode},getPropertyName:[function(){return"influence"}]},__array__:{__target__:!0,type:"number",get:function(e,t){var n,r;return void 0!==t?null===(r=null===(n=e._primitiveBabylonMeshes)||void 0===n?void 0:n[0].morphTargetManager)||void 0===r?void 0:r.getTarget(t).influence:void 0},getTarget:function(e){return e._babylonTransformNode},getPropertyName:[function(){return"influence"}]},type:"number[]",get:function(e,t){return[0]},getTarget:function(e){return e._babylonTransformNode},getPropertyName:[function(){return"influence"}]},matrix:{type:"Matrix",get:function(e){var n,r,o;return t.Matrix.Compose(null===(n=e._babylonTransformNode)||void 0===n?void 0:n.scaling,null===(r=e._babylonTransformNode)||void 0===r?void 0:r.rotationQuaternion,null===(o=e._babylonTransformNode)||void 0===o?void 0:o.position)},getTarget:function(e){return e._babylonTransformNode},isReadOnly:!0},globalMatrix:{type:"Matrix",get:function(e){for(var n,r,o,a,i,s,l,u=t.Matrix.Identity(),c=e.parent;c&&c.parent;)c=c.parent;var f=(null===(n=e._babylonTransformNode)||void 0===n?void 0:n.position._isDirty)||(null===(o=null===(r=e._babylonTransformNode)||void 0===r?void 0:r.rotationQuaternion)||void 0===o?void 0:o._isDirty)||(null===(a=e._babylonTransformNode)||void 0===a?void 0:a.scaling._isDirty);if(c){var h=null===(i=c._babylonTransformNode)||void 0===i?void 0:i.computeWorldMatrix(!0).invert();h&&(null===(l=null===(s=e._babylonTransformNode)||void 0===s?void 0:s.computeWorldMatrix(f))||void 0===l||l.multiplyToRef(h,u))}else e._babylonTransformNode&&u.copyFrom(e._babylonTransformNode.computeWorldMatrix(f));return u},getTarget:function(e){return e._babylonTransformNode},isReadOnly:!0},extensions:{EXT_lights_ies:{multiplier:{type:"number",get:function(e){var n,r;return null===(r=null===(n=e._babylonTransformNode)||void 0===n?void 0:n.getChildren(function(e){return e instanceof t.SpotLight},!0)[0])||void 0===r?void 0:r.intensity},getTarget:function(e){var n;return null===(n=e._babylonTransformNode)||void 0===n?void 0:n.getChildren(function(e){return e instanceof t.SpotLight},!0)[0]},set:function(e,n){if(n._babylonTransformNode){var r=n._babylonTransformNode.getChildren(function(e){return e instanceof t.SpotLight},!0)[0];r&&(r.intensity=e)}}},color:{type:"Color3",get:function(e){var n,r;return null===(r=null===(n=e._babylonTransformNode)||void 0===n?void 0:n.getChildren(function(e){return e instanceof t.SpotLight},!0)[0])||void 0===r?void 0:r.diffuse},getTarget:function(e){var n;return null===(n=e._babylonTransformNode)||void 0===n?void 0:n.getChildren(function(e){return e instanceof t.SpotLight},!0)[0]},set:function(e,n){if(n._babylonTransformNode){var r=n._babylonTransformNode.getChildren(function(e){return e instanceof t.SpotLight},!0)[0];r&&(r.diffuse=e)}}}},KHR_node_visibility:{visible:{type:"boolean",get:function(e){return!!e._primitiveBabylonMeshes&&e._primitiveBabylonMeshes[0].isVisible},getTarget:function(){},set:function(e,t){t._primitiveBabylonMeshes&&t._primitiveBabylonMeshes.forEach(function(t){return t.isVisible=e})}}}}}},R={__array__:{__target__:!0,orthographic:{xmag:{componentsCount:2,type:"Vector2",get:function(e){var n,r,o,a;return new t.Vector2(null!==(r=null===(n=e._babylonCamera)||void 0===n?void 0:n.orthoLeft)&&void 0!==r?r:0,null!==(a=null===(o=e._babylonCamera)||void 0===o?void 0:o.orthoRight)&&void 0!==a?a:0)},set:function(e,t){t._babylonCamera&&(t._babylonCamera.orthoLeft=e.x,t._babylonCamera.orthoRight=e.y)},getTarget:function(e){return e},getPropertyName:[function(){return"orthoLeft"},function(){return"orthoRight"}]},ymag:{componentsCount:2,type:"Vector2",get:function(e){var n,r,o,a;return new t.Vector2(null!==(r=null===(n=e._babylonCamera)||void 0===n?void 0:n.orthoBottom)&&void 0!==r?r:0,null!==(a=null===(o=e._babylonCamera)||void 0===o?void 0:o.orthoTop)&&void 0!==a?a:0)},set:function(e,t){t._babylonCamera&&(t._babylonCamera.orthoBottom=e.x,t._babylonCamera.orthoTop=e.y)},getTarget:function(e){return e},getPropertyName:[function(){return"orthoBottom"},function(){return"orthoTop"}]},zfar:{type:"number",get:function(e){var t;return null===(t=e._babylonCamera)||void 0===t?void 0:t.maxZ},set:function(e,t){t._babylonCamera&&(t._babylonCamera.maxZ=e)},getTarget:function(e){return e},getPropertyName:[function(){return"maxZ"}]},znear:{type:"number",get:function(e){var t;return null===(t=e._babylonCamera)||void 0===t?void 0:t.minZ},set:function(e,t){t._babylonCamera&&(t._babylonCamera.minZ=e)},getTarget:function(e){return e},getPropertyName:[function(){return"minZ"}]}},perspective:{aspectRatio:{type:"number",get:function(e){var t;return null===(t=e._babylonCamera)||void 0===t?void 0:t.getEngine().getAspectRatio(e._babylonCamera)},getTarget:function(e){return e},getPropertyName:[function(){return"aspectRatio"}],isReadOnly:!0},yfov:{type:"number",get:function(e){var t;return null===(t=e._babylonCamera)||void 0===t?void 0:t.fov},set:function(e,t){t._babylonCamera&&(t._babylonCamera.fov=e)},getTarget:function(e){return e},getPropertyName:[function(){return"fov"}]},zfar:{type:"number",get:function(e){var t;return null===(t=e._babylonCamera)||void 0===t?void 0:t.maxZ},set:function(e,t){t._babylonCamera&&(t._babylonCamera.maxZ=e)},getTarget:function(e){return e},getPropertyName:[function(){return"maxZ"}]},znear:{type:"number",get:function(e){var t;return null===(t=e._babylonCamera)||void 0===t?void 0:t.minZ},set:function(e,t){t._babylonCamera&&(t._babylonCamera.minZ=e)},getTarget:function(e){return e},getPropertyName:[function(){return"minZ"}]}}}},P={__array__:{__target__:!0,emissiveFactor:{type:"Color3",get:function(e,t,n){return E(e,0,n).emissiveColor},set:function(e,t,n,r){return E(t,0,r).emissiveColor.copyFrom(e)},getTarget:function(e,t,n){return E(e,0,n)},getPropertyName:[function(){return"emissiveColor"}]},emissiveTexture:{extensions:{KHR_texture_transform:S("emissiveTexture")}},normalTexture:{scale:{type:"number",get:function(e,t,n){var r;return null===(r=F(e,n,"bumpTexture"))||void 0===r?void 0:r.level},set:function(e,t,n,r){var o=F(t,r,"bumpTexture");o&&(o.level=e)},getTarget:function(e,t,n){return E(e,0,n)},getPropertyName:[function(){return"level"}]},extensions:{KHR_texture_transform:S("bumpTexture")}},occlusionTexture:{strength:{type:"number",get:function(e,t,n){return E(e,0,n).ambientTextureStrength},set:function(e,t,n,r){var o=E(t,0,r);o&&(o.ambientTextureStrength=e)},getTarget:function(e,t,n){return E(e,0,n)},getPropertyName:[function(){return"ambientTextureStrength"}]},extensions:{KHR_texture_transform:S("ambientTexture")}},pbrMetallicRoughness:{baseColorFactor:{type:"Color4",get:function(e,n,r){var o=E(e,0,r);return t.Color4.FromColor3(o.albedoColor,o.alpha)},set:function(e,t,n,r){var o=E(t,0,r);o.albedoColor.set(e.r,e.g,e.b),o.alpha=e.a},getTarget:function(e,t,n){return E(e,0,n)},getPropertyName:[function(){return"albedoColor"},function(){return"alpha"}]},baseColorTexture:{extensions:{KHR_texture_transform:S("albedoTexture")}},metallicFactor:{type:"number",get:function(e,t,n){return E(e,0,n).metallic},set:function(e,t,n,r){var o=E(t,0,r);o&&(o.metallic=e)},getTarget:function(e,t,n){return E(e,0,n)},getPropertyName:[function(){return"metallic"}]},roughnessFactor:{type:"number",get:function(e,t,n){return E(e,0,n).roughness},set:function(e,t,n,r){var o=E(t,0,r);o&&(o.roughness=e)},getTarget:function(e,t,n){return E(e,0,n)},getPropertyName:[function(){return"roughness"}]},metallicRoughnessTexture:{extensions:{KHR_texture_transform:S("metallicTexture")}}},extensions:{KHR_materials_anisotropy:{anisotropyStrength:{type:"number",get:function(e,t,n){return E(e,0,n).anisotropy.intensity},set:function(e,t,n,r){E(t,0,r).anisotropy.intensity=e},getTarget:function(e,t,n){return E(e,0,n)},getPropertyName:[function(){return"anisotropy.intensity"}]},anisotropyRotation:{type:"number",get:function(e,t,n){return E(e,0,n).anisotropy.angle},set:function(e,t,n,r){E(t,0,r).anisotropy.angle=e},getTarget:function(e,t,n){return E(e,0,n)},getPropertyName:[function(){return"anisotropy.angle"}]},anisotropyTexture:{extensions:{KHR_texture_transform:S("anisotropy","texture")}}},KHR_materials_clearcoat:{clearcoatFactor:{type:"number",get:function(e,t,n){return E(e,0,n).clearCoat.intensity},set:function(e,t,n,r){E(t,0,r).clearCoat.intensity=e},getTarget:function(e,t,n){return E(e,0,n)},getPropertyName:[function(){return"clearCoat.intensity"}]},clearcoatRoughnessFactor:{type:"number",get:function(e,t,n){return E(e,0,n).clearCoat.roughness},set:function(e,t,n,r){E(t,0,r).clearCoat.roughness=e},getTarget:function(e,t,n){return E(e,0,n)},getPropertyName:[function(){return"clearCoat.roughness"}]},clearcoatTexture:{extensions:{KHR_texture_transform:S("clearCoat","texture")}},clearcoatNormalTexture:{scale:{type:"number",get:function(e,t,n){var r;return null===(r=E(e,0,n).clearCoat.bumpTexture)||void 0===r?void 0:r.level},getTarget:E,set:function(e,t,n,r){return E(t,0,r).clearCoat.bumpTexture.level=e}},extensions:{KHR_texture_transform:S("clearCoat","bumpTexture")}},clearcoatRoughnessTexture:{extensions:{KHR_texture_transform:S("clearCoat","textureRoughness")}}},KHR_materials_dispersion:{dispersion:{type:"number",get:function(e,t,n){return E(e,0,n).subSurface.dispersion},getTarget:E,set:function(e,t,n,r){return E(t,0,r).subSurface.dispersion=e}}},KHR_materials_emissive_strength:{emissiveStrength:{type:"number",get:function(e,t,n){return E(e,0,n).emissiveIntensity},getTarget:E,set:function(e,t,n,r){return E(t,0,r).emissiveIntensity=e}}},KHR_materials_ior:{ior:{type:"number",get:function(e,t,n){return E(e,0,n).indexOfRefraction},getTarget:E,set:function(e,t,n,r){return E(t,0,r).indexOfRefraction=e}}},KHR_materials_iridescence:{iridescenceFactor:{type:"number",get:function(e,t,n){return E(e,0,n).iridescence.intensity},getTarget:E,set:function(e,t,n,r){return E(t,0,r).iridescence.intensity=e}},iridescenceIor:{type:"number",get:function(e,t,n){return E(e,0,n).iridescence.indexOfRefraction},getTarget:E,set:function(e,t,n,r){return E(t,0,r).iridescence.indexOfRefraction=e}},iridescenceTexture:{extensions:{KHR_texture_transform:S("iridescence","texture")}},iridescenceThicknessMaximum:{type:"number",get:function(e,t,n){return E(e,0,n).iridescence.maximumThickness},getTarget:E,set:function(e,t,n,r){return E(t,0,r).iridescence.maximumThickness=e}},iridescenceThicknessMinimum:{type:"number",get:function(e,t,n){return E(e,0,n).iridescence.minimumThickness},getTarget:E,set:function(e,t,n,r){return E(t,0,r).iridescence.minimumThickness=e}},iridescenceThicknessTexture:{extensions:{KHR_texture_transform:S("iridescence","thicknessTexture")}}},KHR_materials_sheen:{sheenColorFactor:{type:"Color3",get:function(e,t,n){return E(e,0,n).sheen.color},getTarget:E,set:function(e,t,n,r){return E(t,0,r).sheen.color.copyFrom(e)}},sheenColorTexture:{extensions:{KHR_texture_transform:S("sheen","texture")}},sheenRoughnessFactor:{type:"number",get:function(e,t,n){return E(e,0,n).sheen.intensity},getTarget:E,set:function(e,t,n,r){return E(t,0,r).sheen.intensity=e}},sheenRoughnessTexture:{extensions:{KHR_texture_transform:S("sheen","thicknessTexture")}}},KHR_materials_specular:{specularFactor:{type:"number",get:function(e,t,n){return E(e,0,n).metallicF0Factor},getTarget:E,set:function(e,t,n,r){return E(t,0,r).metallicF0Factor=e},getPropertyName:[function(){return"metallicF0Factor"}]},specularColorFactor:{type:"Color3",get:function(e,t,n){return E(e,0,n).metallicReflectanceColor},getTarget:E,set:function(e,t,n,r){return E(t,0,r).metallicReflectanceColor.copyFrom(e)},getPropertyName:[function(){return"metallicReflectanceColor"}]},specularTexture:{extensions:{KHR_texture_transform:S("metallicReflectanceTexture")}},specularColorTexture:{extensions:{KHR_texture_transform:S("reflectanceTexture")}}},KHR_materials_transmission:{transmissionFactor:{type:"number",get:function(e,t,n){return E(e,0,n).subSurface.refractionIntensity},getTarget:E,set:function(e,t,n,r){return E(t,0,r).subSurface.refractionIntensity=e},getPropertyName:[function(){return"subSurface.refractionIntensity"}]},transmissionTexture:{extensions:{KHR_texture_transform:S("subSurface","refractionIntensityTexture")}}},KHR_materials_diffuse_transmission:{diffuseTransmissionFactor:{type:"number",get:function(e,t,n){return E(e,0,n).subSurface.translucencyIntensity},getTarget:E,set:function(e,t,n,r){return E(t,0,r).subSurface.translucencyIntensity=e}},diffuseTransmissionTexture:{extensions:{KHR_texture_transform:S("subSurface","translucencyIntensityTexture")}},diffuseTransmissionColorFactor:{type:"Color3",get:function(e,t,n){return E(e,0,n).subSurface.translucencyColor},getTarget:E,set:function(e,t,n,r){var o;return e&&(null===(o=E(t,0,r).subSurface.translucencyColor)||void 0===o?void 0:o.copyFrom(e))}},diffuseTransmissionColorTexture:{extensions:{KHR_texture_transform:S("subSurface","translucencyColorTexture")}}},KHR_materials_volume:{attenuationColor:{type:"Color3",get:function(e,t,n){return E(e,0,n).subSurface.tintColor},getTarget:E,set:function(e,t,n,r){return E(t,0,r).subSurface.tintColor.copyFrom(e)}},attenuationDistance:{type:"number",get:function(e,t,n){return E(e,0,n).subSurface.tintColorAtDistance},getTarget:E,set:function(e,t,n,r){return E(t,0,r).subSurface.tintColorAtDistance=e}},thicknessFactor:{type:"number",get:function(e,t,n){return E(e,0,n).subSurface.maximumThickness},getTarget:E,set:function(e,t,n,r){return E(t,0,r).subSurface.maximumThickness=e}},thicknessTexture:{extensions:{KHR_texture_transform:S("subSurface","thicknessTexture")}}}}}},L={KHR_lights_punctual:{lights:{length:{type:"number",get:function(e){return e.length},getTarget:function(e){return e.map(function(e){return e._babylonLight})},getPropertyName:[function(e){return"length"}]},__array__:{__target__:!0,color:{type:"Color3",get:function(e){var t;return null===(t=e._babylonLight)||void 0===t?void 0:t.diffuse},set:function(e,t){var n;return null===(n=t._babylonLight)||void 0===n?void 0:n.diffuse.copyFrom(e)},getTarget:function(e){return e._babylonLight},getPropertyName:[function(e){return"diffuse"}]},intensity:{type:"number",get:function(e){var t;return null===(t=e._babylonLight)||void 0===t?void 0:t.intensity},set:function(e,t){return t._babylonLight?t._babylonLight.intensity=e:void 0},getTarget:function(e){return e._babylonLight},getPropertyName:[function(e){return"intensity"}]},range:{type:"number",get:function(e){var t;return null===(t=e._babylonLight)||void 0===t?void 0:t.range},set:function(e,t){return t._babylonLight?t._babylonLight.range=e:void 0},getTarget:function(e){return e._babylonLight},getPropertyName:[function(e){return"range"}]},spot:{innerConeAngle:{type:"number",get:function(e){var t;return null===(t=e._babylonLight)||void 0===t?void 0:t.innerAngle},set:function(e,t){return t._babylonLight?t._babylonLight.innerAngle=e:void 0},getTarget:function(e){return e._babylonLight},getPropertyName:[function(e){return"innerConeAngle"}]},outerConeAngle:{type:"number",get:function(e){var t;return null===(t=e._babylonLight)||void 0===t?void 0:t.angle},set:function(e,t){return t._babylonLight?t._babylonLight.angle=e:void 0},getTarget:function(e){return e._babylonLight},getPropertyName:[function(e){return"outerConeAngle"}]}}}}},EXT_lights_area:{lights:{length:{type:"number",get:function(e){return e.length},getTarget:function(e){return e.map(function(e){return e._babylonLight})},getPropertyName:[function(e){return"length"}]},__array__:{__target__:!0,color:{type:"Color3",get:function(e){var t;return null===(t=e._babylonLight)||void 0===t?void 0:t.diffuse},set:function(e,t){var n;return null===(n=t._babylonLight)||void 0===n?void 0:n.diffuse.copyFrom(e)},getTarget:function(e){return e._babylonLight},getPropertyName:[function(e){return"diffuse"}]},intensity:{type:"number",get:function(e){var t;return null===(t=e._babylonLight)||void 0===t?void 0:t.intensity},set:function(e,t){return t._babylonLight?t._babylonLight.intensity=e:void 0},getTarget:function(e){return e._babylonLight},getPropertyName:[function(e){return"intensity"}]},size:{type:"number",get:function(e){var t;return null===(t=e._babylonLight)||void 0===t?void 0:t.height},set:function(e,t){return t._babylonLight?t._babylonLight.height=e:void 0},getTarget:function(e){return e._babylonLight},getPropertyName:[function(e){return"size"}]},rect:{aspect:{type:"number",get:function(e){var t,n;return(null===(t=e._babylonLight)||void 0===t?void 0:t.width)/(null===(n=e._babylonLight)||void 0===n?void 0:n.height)},set:function(e,t){return t._babylonLight?t._babylonLight.width=e*t._babylonLight.height:void 0},getTarget:function(e){return e._babylonLight},getPropertyName:[function(e){return"aspect"}]}}}}},EXT_lights_ies:{lights:{length:{type:"number",get:function(e){return e.length},getTarget:function(e){return e.map(function(e){return e._babylonLight})},getPropertyName:[function(e){return"length"}]}}},EXT_lights_image_based:{lights:{length:{type:"number",get:function(e){return e.length},getTarget:function(e){return e.map(function(e){return e._babylonTexture})},getPropertyName:[function(e){return"length"}]},__array__:{__target__:!0,intensity:{type:"number",get:function(e){var t;return null===(t=e._babylonTexture)||void 0===t?void 0:t.level},set:function(e,t){t._babylonTexture&&(t._babylonTexture.level=e)},getTarget:function(e){return e._babylonTexture}},rotation:{type:"Quaternion",get:function(e){var n;return e._babylonTexture&&t.Quaternion.FromRotationMatrix(null===(n=e._babylonTexture)||void 0===n?void 0:n.getReflectionTextureMatrix())},set:function(e,n){var r;n._babylonTexture&&((null===(r=n._babylonTexture.getScene())||void 0===r?void 0:r.useRightHandedSystem)||(e=t.Quaternion.Inverse(e)),t.Matrix.FromQuaternionToRef(e,n._babylonTexture.getReflectionTextureMatrix()))},getTarget:function(e){return e._babylonTexture}}}}}};function F(e,t,n,r){var o=E(e);return r?o[n][r]:o[n]}function E(e,n,r){var o,a,i;return null===(i=null===(o=e._data)||void 0===o?void 0:o[null!==(a=null==r?void 0:r.fillMode)&&void 0!==a?a:t.Constants.MATERIAL_TriangleFillMode])||void 0===i?void 0:i.babylonMaterial}function S(e,n){return{offset:{componentsCount:2,type:"Vector2",get:function(r,o,a){var i=F(r,0,e,n);return new t.Vector2(null==i?void 0:i.uOffset,null==i?void 0:i.vOffset)},getTarget:E,set:function(t,r,o,a){var i=F(r,0,e,n);i.uOffset=t.x,i.vOffset=t.y},getPropertyName:[function(){return"".concat(e).concat(n?"."+n:"",".uOffset")},function(){return"".concat(e).concat(n?"."+n:"",".vOffset")}]},rotation:{type:"number",get:function(t,r,o){var a;return null===(a=F(t,0,e,n))||void 0===a?void 0:a.wAng},getTarget:E,set:function(t,r,o,a){return F(r,0,e,n).wAng=t},getPropertyName:[function(){return"".concat(e).concat(n?"."+n:"",".wAng")}]},scale:{componentsCount:2,type:"Vector2",get:function(r,o,a){var i=F(r,0,e,n);return new t.Vector2(null==i?void 0:i.uScale,null==i?void 0:i.vScale)},getTarget:E,set:function(t,r,o,a){var i=F(r,0,e,n);i.uScale=t.x,i.vScale=t.y},getPropertyName:[function(){return"".concat(e).concat(n?"."+n:"",".uScale")},function(){return"".concat(e).concat(n?"."+n:"",".vScale")}]}}}var k={cameras:R,nodes:M,materials:P,extensions:L,animations:{length:{type:"number",get:function(e){return e.length},getTarget:function(e){return e.map(function(e){return e._babylonAnimationGroup})},getPropertyName:[function(){return"length"}]},__array__:{}},meshes:{length:{type:"number",get:function(e){return e.length},getTarget:function(e){return e.map(function(e){var t;return null===(t=e.primitives[0]._instanceData)||void 0===t?void 0:t.babylonSourceMesh})},getPropertyName:[function(){return"length"}]},__array__:{}}};function I(e){return new O(e,k)}function B(e){for(var t=e.split("/").map(function(e){return e.replace(/{}/g,"__array__")}),n=k,r=0,o=t;r<o.length;r++){var a=o[r];a&&(n=n[a])}if(n&&n.type&&n.get)return n}function N(e,t){for(var n=e.split("/").map(function(e){return e.replace(/{}/g,"__array__")}),r=k,o=0,a=n;o<a.length;o++){var i=a[o];i&&(r=r[i])}r&&r.type&&r.get&&(r.interpolation=t)}function G(e,t){for(var n=e.split("/").map(function(e){return e.replace(/{}/g,"__array__")}),r=k,o=0,a=n;o<a.length;o++){var i=a[o];if(i){if(!r[i]){if("?"===i){r.__ignoreObjectTree__=!0;continue}r[i]={},"__array__"===i&&(r[i].__target__=!0)}r=r[i]}}Object.assign(r,t)}var D=new Map,V=D;function H(e,n,r){K(e)&&t.Logger.Warn("Extension with the name '".concat(e,"' already exists")),D.set(e,{isGLTFExtension:n,factory:r})}function K(e){return D.delete(e)}var j=new t.Lazy(function(){return Promise.resolve(BABYLON)}),W=new t.Lazy(function(){return Promise.resolve().then(function(){return ut})}),U=function(){function e(){}return e.Get=function(e,t,n){if(!t||null==n||!t[n])throw new Error("".concat(e,": Failed to find index (").concat(n,")"));return t[n]},e.TryGet=function(e,t){return e&&null!=t&&e[t]?e[t]:null},e.Assign=function(e){if(e)for(var t=0;t<e.length;t++)e[t].index=t},e}();function z(e){if(e.min&&e.max){var n=e.min,r=e.max,o=t.TmpVectors.Vector3[0].copyFromFloats(n[0],n[1],n[2]),a=t.TmpVectors.Vector3[1].copyFromFloats(r[0],r[1],r[2]);if(e.normalized&&5126!==e.componentType){var i=1;switch(e.componentType){case 5120:i=127;break;case 5121:i=255;break;case 5122:i=32767;break;case 5123:i=65535}var s=1/i;o.scaleInPlace(s),a.scaleInPlace(s)}return new t.BoundingInfo(o,a)}return null}var q=function(){function n(e){this._completePromises=new Array,this._assetContainer=null,this._babylonLights=[],this._disableInstancedMesh=0,this._allMaterialsDirtyRequired=!1,this._skipStartAnimationStep=!1,this._extensions=new Array,this._disposed=!1,this._rootUrl=null,this._fileName=null,this._uniqueRootUrl=null,this._bin=null,this._rootBabylonMesh=null,this._defaultBabylonMaterialData={},this._postSceneLoadActions=new Array,this._materialAdapterCache=new WeakMap,this._materialAdapters=new Set,this._pbrMaterialImpl=null,this._parent=e}return n.prototype.isMatchingMaterialType=function(e){return!(!e||!this._pbrMaterialImpl)&&e instanceof this._pbrMaterialImpl.materialClass},n.RegisterExtension=function(e,t){H(e,!1,t)},n.UnregisterExtension=function(e){return K(e)},Object.defineProperty(n.prototype,"gltf",{get:function(){if(!this._gltf)throw new Error("glTF JSON is not available");return this._gltf},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"bin",{get:function(){return this._bin},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"parent",{get:function(){return this._parent},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"babylonScene",{get:function(){if(!this._babylonScene)throw new Error("Scene is not available");return this._babylonScene},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"rootBabylonMesh",{get:function(){return this._rootBabylonMesh},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"rootUrl",{get:function(){return this._rootUrl},enumerable:!1,configurable:!0}),n.prototype._getOrCreateMaterialAdapter=function(e){var t=this._materialAdapterCache.get(e);if(!t){if(!this._pbrMaterialImpl)throw new Error("Appropriate material adapter class not found");var n=t=new this._pbrMaterialImpl.adapterClass(e);this._materialAdapterCache.set(e,n),this._materialAdapters.add(n)}return t},n.prototype.dispose=function(){this._disposed||(this._disposed=!0,this._completePromises.length=0,this._extensions.forEach(function(e){return e.dispose&&e.dispose()}),this._extensions.length=0,this._materialAdapters.clear(),this._gltf=null,this._bin=null,this._babylonScene=null,this._rootBabylonMesh=null,this._defaultBabylonMaterialData={},this._postSceneLoadActions.length=0,this._parent.dispose())},n.prototype.importMeshAsync=function(e,t,n,r,o,s){return a(this,arguments,void 0,function(e,t,n,r,o,s,l){var u=this;return void 0===l&&(l=""),i(this,function(s){switch(s.label){case 0:return[4,Promise.resolve().then(function(){return a(u,void 0,void 0,function(){var a,s,u,c,f,h=this;return i(this,function(i){switch(i.label){case 0:if(this._babylonScene=t,this._assetContainer=n,this._loadData(r),a=null,e){if(s={},this._gltf.nodes)for(u=0,c=this._gltf.nodes;u<c.length;u++)(f=c[u]).name&&(s[f.name]=f.index);a=(e instanceof Array?e:[e]).map(function(e){var t=s[e];if(void 0===t)throw new Error("Failed to find node '".concat(e,"'"));return t})}return[4,this._loadAsync(o,l,a,function(){return{meshes:h._getMeshes(),particleSystems:[],skeletons:h._getSkeletons(),animationGroups:h._getAnimationGroups(),lights:h._babylonLights,transformNodes:h._getTransformNodes(),geometries:h._getGeometries(),spriteManagers:[]}})];case 1:return[2,i.sent()]}})})})];case 1:return[2,s.sent()]}})})},n.prototype.loadAsync=function(e,t,n,r){return a(this,arguments,void 0,function(e,t,n,r,o){return void 0===o&&(o=""),i(this,function(r){switch(r.label){case 0:return this._babylonScene=e,this._loadData(t),[4,this._loadAsync(n,o,null,function(){})];case 1:return[2,r.sent()]}})})},n.prototype._loadAsync=function(n,r,o,s){return a(this,void 0,void 0,function(){var l=this;return i(this,function(u){switch(u.label){case 0:return[4,Promise.resolve().then(function(){return a(l,void 0,void 0,function(){var a,l,u,c,f,h,p,d,m,_,b,g,y,v,T=this;return i(this,function(i){switch(i.label){case 0:return this._rootUrl=n,this._uniqueRootUrl=!n.startsWith("file:")&&r?n:"".concat(n).concat(Date.now(),"/"),this._fileName=r,this._allMaterialsDirtyRequired=!1,[4,this._loadExtensionsAsync()];case 1:return i.sent(),this.parent.skipMaterials||null!=this._pbrMaterialImpl?[3,7]:this.parent.useOpenPBR||this.isExtensionUsed("KHR_materials_openpbr")?(a=this,y={},[4,Promise.resolve(BABYLON)]):[3,4];case 2:return y.materialClass=i.sent().OpenPBRMaterial,[4,Promise.resolve().then(function(){return wn})];case 3:return a._pbrMaterialImpl=(y.adapterClass=i.sent().OpenPBRMaterialLoadingAdapter,y),[3,7];case 4:return l=this,v={},[4,Promise.resolve(BABYLON)];case 5:return v.materialClass=i.sent().PBRMaterial,[4,Promise.resolve().then(function(){return Mn})];case 6:l._pbrMaterialImpl=(v.adapterClass=i.sent().PBRMaterialLoadingAdapter,v),i.label=7;case 7:if(u="".concat(e.GLTFLoaderState[e.GLTFLoaderState.LOADING]," => ").concat(e.GLTFLoaderState[e.GLTFLoaderState.READY]),c="".concat(e.GLTFLoaderState[e.GLTFLoaderState.LOADING]," => ").concat(e.GLTFLoaderState[e.GLTFLoaderState.COMPLETE]),this._parent._startPerformanceCounter(u),this._parent._startPerformanceCounter(c),this._parent._setState(e.GLTFLoaderState.LOADING),this._extensionsOnLoading(),f=new Array,h=this._babylonScene.blockMaterialDirtyMechanism,this._babylonScene.blockMaterialDirtyMechanism=!0,this.parent.loadOnlyMaterials||(o?f.push(this.loadSceneAsync("/nodes",{nodes:o,index:-1})):(null!=this._gltf.scene||this._gltf.scenes&&this._gltf.scenes[0])&&(p=U.Get("/scene",this._gltf.scenes,this._gltf.scene||0),f.push(this.loadSceneAsync("/scenes/".concat(p.index),p)))),!this.parent.skipMaterials&&this.parent.loadAllMaterials&&this._gltf.materials)for(d=0;d<this._gltf.materials.length;++d)m=this._gltf.materials[d],_="/materials/"+d,b=t.Material.TriangleFillMode,f.push(this._loadMaterialAsync(_,m,null,b,function(){}));return this._allMaterialsDirtyRequired?this._babylonScene.blockMaterialDirtyMechanism=h:this._babylonScene._forceBlockMaterialDirtyMechanism(h),this._parent.compileMaterials&&f.push(this._compileMaterialsAsync()),this._parent.compileShadowGenerators&&f.push(this._compileShadowGeneratorsAsync()),g=Promise.all(f).then(function(){T._rootBabylonMesh&&T._rootBabylonMesh!==T._parent.customRootNode&&T._rootBabylonMesh.setEnabled(!0);for(var t=0,n=T._babylonScene.materials;t<n.length;t++){var r=n[t];void 0!==r.maxSimultaneousLights&&(r.maxSimultaneousLights=Math.max(r.maxSimultaneousLights,T._babylonScene.lights.length))}for(var o=0,a=Array.from(T._materialAdapters);o<a.length;o++){var i=a[o];T._completePromises.push(i.finalizeAsync(T))}return T._extensionsOnReady(),T._parent._setState(e.GLTFLoaderState.READY),T._skipStartAnimationStep||T._startAnimations(),s()}),[4,g.then(function(n){return T._parent._endPerformanceCounter(u),t.Tools.SetImmediate(function(){T._disposed||Promise.all(T._completePromises).then(function(){T._parent._endPerformanceCounter(c),T._parent._setState(e.GLTFLoaderState.COMPLETE),T._parent.onCompleteObservable.notifyObservers(void 0),T._parent.onCompleteObservable.clear(),T.dispose()},function(e){T._parent.onErrorObservable.notifyObservers(e),T._parent.onErrorObservable.clear(),T.dispose()})}),n})];case 8:return[2,i.sent()]}})})}).catch(function(e){throw l._disposed||(l._parent.onErrorObservable.notifyObservers(e),l._parent.onErrorObservable.clear(),l.dispose()),e})];case 1:return[2,u.sent()]}})})},n.prototype._loadData=function(e){if(this._gltf=e.json,this._setupData(),e.bin){var n=this._gltf.buffers;if(n&&n[0]&&!n[0].uri){var r=n[0];(r.byteLength<e.bin.byteLength-3||r.byteLength>e.bin.byteLength)&&t.Logger.Warn("Binary buffer length (".concat(r.byteLength,") from JSON does not match chunk length (").concat(e.bin.byteLength,")")),this._bin=e.bin}else t.Logger.Warn("Unexpected BIN chunk")}},n.prototype._setupData=function(){if(U.Assign(this._gltf.accessors),U.Assign(this._gltf.animations),U.Assign(this._gltf.buffers),U.Assign(this._gltf.bufferViews),U.Assign(this._gltf.cameras),U.Assign(this._gltf.images),U.Assign(this._gltf.materials),U.Assign(this._gltf.meshes),U.Assign(this._gltf.nodes),U.Assign(this._gltf.samplers),U.Assign(this._gltf.scenes),U.Assign(this._gltf.skins),U.Assign(this._gltf.textures),this._gltf.nodes){for(var e={},t=0,n=this._gltf.nodes;t<n.length;t++)if((l=n[t]).children)for(var r=0,o=l.children;r<o.length;r++)e[o[r]]=l.index;for(var a=this._createRootNode(),i=0,s=this._gltf.nodes;i<s.length;i++){var l,u=e[(l=s[i]).index];l.parent=void 0===u?a:this._gltf.nodes[u]}}},n.prototype._loadExtensionsAsync=function(){return a(this,void 0,void 0,function(){var e,n,r,o,s,l,u,c,f,h,p,d=this;return i(this,function(m){switch(m.label){case 0:return e=[],V.forEach(function(n,r){var o;!1===(null===(o=d.parent.extensionOptions[r])||void 0===o?void 0:o.enabled)?n.isGLTFExtension&&d.isExtensionUsed(r)&&t.Logger.Warn("Extension ".concat(r," is used but has been explicitly disabled.")):n.isGLTFExtension&&!d.isExtensionUsed(r)||e.push(a(d,void 0,void 0,function(){var e;return i(this,function(o){switch(o.label){case 0:return[4,n.factory(this)];case 1:return(e=o.sent()).name!==r&&t.Logger.Warn("The name of the glTF loader extension instance does not match the registered name: ".concat(e.name," !== ").concat(r)),this._parent.onExtensionLoadedObservable.notifyObservers(e),[2,e]}})}))}),r=(n=(h=this._extensions).push).apply,o=[h],[4,Promise.all(e)];case 1:if(r.apply(n,o.concat([m.sent()])),this._extensions.sort(function(e,t){return(e.order||Number.MAX_VALUE)-(t.order||Number.MAX_VALUE)}),this._parent.onExtensionLoadedObservable.clear(),this._gltf.extensionsRequired)for(s=function(e){if(!l._extensions.some(function(t){return t.name===e&&t.enabled})){if(!1===(null===(p=l.parent.extensionOptions[e])||void 0===p?void 0:p.enabled))throw new Error("Required extension ".concat(e," is disabled"));throw new Error("Required extension ".concat(e," is not available"))}},l=this,u=0,c=this._gltf.extensionsRequired;u<c.length;u++)f=c[u],s(f);return[2]}})})},n.prototype._createRootNode=function(){if(void 0!==this._parent.customRootNode)return this._rootBabylonMesh=this._parent.customRootNode,{_babylonTransformNode:null===this._rootBabylonMesh?void 0:this._rootBabylonMesh,index:-1};this._babylonScene._blockEntityCollection=!!this._assetContainer;var r=new t.Mesh("__root__",this._babylonScene);this._rootBabylonMesh=r,this._rootBabylonMesh._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,this._rootBabylonMesh.setEnabled(!1);var o={_babylonTransformNode:this._rootBabylonMesh,index:-1};switch(this._parent.coordinateSystemMode){case e.GLTFLoaderCoordinateSystemMode.AUTO:this._babylonScene.useRightHandedSystem||(o.rotation=[0,1,0,0],o.scale=[1,1,-1],n._LoadTransform(o,this._rootBabylonMesh));break;case e.GLTFLoaderCoordinateSystemMode.FORCE_RIGHT_HANDED:this._babylonScene.useRightHandedSystem=!0;break;default:throw new Error("Invalid coordinate system mode (".concat(this._parent.coordinateSystemMode,")"))}return this._parent.onMeshLoadedObservable.notifyObservers(r),o},n.prototype.loadSceneAsync=function(e,t){var n=this,r=this._extensionsLoadSceneAsync(e,t);if(r)return r;var o=new Array;if(this.logOpen("".concat(e," ").concat(t.name||"")),t.nodes)for(var a=0,i=t.nodes;a<i.length;a++){var s=i[a],l=U.Get("".concat(e,"/nodes/").concat(s),this._gltf.nodes,s);o.push(this.loadNodeAsync("/nodes/".concat(l.index),l,function(e){e.parent=n._rootBabylonMesh}))}for(var u=0,c=this._postSceneLoadActions;u<c.length;u++)(0,c[u])();return o.push(this._loadAnimationsAsync()),this.logClose(),Promise.all(o).then(function(){})},n.prototype._forEachPrimitive=function(e,t){if(e._primitiveBabylonMeshes)for(var n=0,r=e._primitiveBabylonMeshes;n<r.length;n++)t(r[n])},n.prototype._getGeometries=function(){var e=[],t=this._gltf.nodes;if(t)for(var n=0,r=t;n<r.length;n++){var o=r[n];this._forEachPrimitive(o,function(t){var n=t.geometry;n&&-1===e.indexOf(n)&&e.push(n)})}return e},n.prototype._getMeshes=function(){var e=[];this._rootBabylonMesh instanceof t.AbstractMesh&&e.push(this._rootBabylonMesh);var n=this._gltf.nodes;if(n)for(var r=0,o=n;r<o.length;r++){var a=o[r];this._forEachPrimitive(a,function(t){e.push(t)})}return e},n.prototype._getTransformNodes=function(){var e=[],t=this._gltf.nodes;if(t)for(var n=0,r=t;n<r.length;n++){var o=r[n];o._babylonTransformNode&&"TransformNode"===o._babylonTransformNode.getClassName()&&e.push(o._babylonTransformNode),o._babylonTransformNodeForSkin&&e.push(o._babylonTransformNodeForSkin)}return e},n.prototype._getSkeletons=function(){var e=[],t=this._gltf.skins;if(t)for(var n=0,r=t;n<r.length;n++){var o=r[n];o._data&&e.push(o._data.babylonSkeleton)}return e},n.prototype._getAnimationGroups=function(){var e=[],t=this._gltf.animations;if(t)for(var n=0,r=t;n<r.length;n++){var o=r[n];o._babylonAnimationGroup&&e.push(o._babylonAnimationGroup)}return e},n.prototype._startAnimations=function(){switch(this._parent.animationStartMode){case e.GLTFLoaderAnimationStartMode.NONE:break;case e.GLTFLoaderAnimationStartMode.FIRST:0!==(n=this._getAnimationGroups()).length&&n[0].start(!0);break;case e.GLTFLoaderAnimationStartMode.ALL:for(var n,r=0,o=n=this._getAnimationGroups();r<o.length;r++)o[r].start(!0);break;default:return void t.Logger.Error("Invalid animation start mode (".concat(this._parent.animationStartMode,")"))}},n.prototype.loadNodeAsync=function(e,r,o){var a=this;void 0===o&&(o=function(){});var i=this._extensionsLoadNodeAsync(e,r,o);if(i)return i;if(r._babylonTransformNode)throw new Error("".concat(e,": Invalid recursive node hierarchy"));var s=new Array;this.logOpen("".concat(e," ").concat(r.name||""));var l=function(t){if(n.AddPointerMetadata(t,e),n._LoadTransform(r,t),null!=r.camera){var i=U.Get("".concat(e,"/camera"),a._gltf.cameras,r.camera);s.push(a.loadCameraAsync("/cameras/".concat(i.index),i,function(e){e.parent=t,a._babylonScene.useRightHandedSystem||(t.scaling.x=-1)}))}if(r.children)for(var l=0,u=r.children;l<u.length;l++){var c=u[l],f=U.Get("".concat(e,"/children/").concat(c),a._gltf.nodes,c);s.push(a.loadNodeAsync("/nodes/".concat(f.index),f,function(e){e.parent=t}))}o(t)},u=null!=r.mesh,c=this._parent.loadSkins&&null!=r.skin;if(!u||c){var f=r.name||"node".concat(r.index);this._babylonScene._blockEntityCollection=!!this._assetContainer;var h=new t.TransformNode(f,this._babylonScene);h._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,null==r.mesh?r._babylonTransformNode=h:r._babylonTransformNodeForSkin=h,l(h)}if(u)if(c){var p=U.Get("".concat(e,"/mesh"),this._gltf.meshes,r.mesh);s.push(this._loadMeshAsync("/meshes/".concat(p.index),r,p,function(n){var o=r._babylonTransformNodeForSkin;n.metadata=t.deepMerge(o.metadata,n.metadata||{});var i=U.Get("".concat(e,"/skin"),a._gltf.skins,r.skin);s.push(a._loadSkinAsync("/skins/".concat(i.index),r,i,function(e){a._forEachPrimitive(r,function(t){t.skeleton=e}),a._postSceneLoadActions.push(function(){if(null!=i.skeleton){var e=U.Get("/skins/".concat(i.index,"/skeleton"),a._gltf.nodes,i.skeleton).parent;r.index===e.index?n.parent=o.parent:n.parent=e._babylonTransformNode}else n.parent=a._rootBabylonMesh;a._parent.onSkinLoadedObservable.notifyObservers({node:o,skinnedNode:n})})}))}))}else p=U.Get("".concat(e,"/mesh"),this._gltf.meshes,r.mesh),s.push(this._loadMeshAsync("/meshes/".concat(p.index),r,p,l));return this.logClose(),Promise.all(s).then(function(){return a._forEachPrimitive(r,function(e){var t=e;!t.isAnInstance&&t.geometry&&t.geometry.useBoundingInfoFromGeometry?e._updateBoundingInfo():e.refreshBoundingInfo(!0,!0)}),r._babylonTransformNode})},n.prototype._loadMeshAsync=function(e,n,r,o){var a=r.primitives;if(!a||!a.length)throw new Error("".concat(e,": Primitives are missing"));null==a[0].index&&U.Assign(a);var i=new Array;this.logOpen("".concat(e," ").concat(r.name||""));var s=n.name||"node".concat(n.index);if(1===a.length){var l=r.primitives[0];i.push(this._loadMeshPrimitiveAsync("".concat(e,"/primitives/").concat(l.index),s,n,r,l,function(e){n._babylonTransformNode=e,n._primitiveBabylonMeshes=[e]}))}else{this._babylonScene._blockEntityCollection=!!this._assetContainer,n._babylonTransformNode=new t.TransformNode(s,this._babylonScene),n._babylonTransformNode._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,n._primitiveBabylonMeshes=[];for(var u=0,c=a;u<c.length;u++)l=c[u],i.push(this._loadMeshPrimitiveAsync("".concat(e,"/primitives/").concat(l.index),"".concat(s,"_primitive").concat(l.index),n,r,l,function(e){e.parent=n._babylonTransformNode,n._primitiveBabylonMeshes.push(e)}))}return o(n._babylonTransformNode),this.logClose(),Promise.all(i).then(function(){return n._babylonTransformNode})},n.prototype._loadMeshPrimitiveAsync=function(e,r,o,s,l,u){var c=this,f=this._extensionsLoadMeshPrimitiveAsync(e,r,o,s,l,u);if(f)return f;this.logOpen("".concat(e));var h,p,d=0===this._disableInstancedMesh&&this._parent.createInstances&&null==o.skin&&!s.primitives[0].targets;if(d&&l._instanceData)this._babylonScene._blockEntityCollection=!!this._assetContainer,(h=l._instanceData.babylonSourceMesh.createInstance(r))._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,p=l._instanceData.promise;else{var m=new Array;this._babylonScene._blockEntityCollection=!!this._assetContainer;var _=new t.Mesh(r,this._babylonScene);if(_._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,_.sideOrientation=this._babylonScene.useRightHandedSystem?t.Material.CounterClockWiseSideOrientation:t.Material.ClockWiseSideOrientation,this._createMorphTargets(e,o,s,l,_),m.push(this._loadVertexDataAsync(e,l,_).then(function(t){return a(c,void 0,void 0,function(){var n=this;return i(this,function(r){switch(r.label){case 0:return[4,this._loadMorphTargetsAsync(e,l,_,t).then(function(){n._disposed||(n._babylonScene._blockEntityCollection=!!n._assetContainer,t.applyToMesh(_),t._parentContainer=n._assetContainer,n._babylonScene._blockEntityCollection=!1)})];case 1:return[2,r.sent()]}})})})),!this.parent.skipMaterials){var b=n._GetDrawMode(e,l.mode);if(null==l.material){var g=this._defaultBabylonMaterialData[b];g||(g=this._createDefaultMaterial("__GLTFLoader._default",b),this._parent.onMaterialLoadedObservable.notifyObservers(g),this._defaultBabylonMaterialData[b]=g),_.material=g}else{var y=U.Get("".concat(e,"/material"),this._gltf.materials,l.material);m.push(this._loadMaterialAsync("/materials/".concat(y.index),y,_,b,function(e){_.material=e}))}}p=Promise.all(m),d&&(l._instanceData={babylonSourceMesh:_,promise:p}),h=_}return n.AddPointerMetadata(h,e),this._parent.onMeshLoadedObservable.notifyObservers(h),u(h),this.logClose(),p.then(function(){return h})},n.prototype._loadVertexDataAsync=function(e,n,r){var o=this,a=this._extensionsLoadVertexDataAsync(e,n,r);if(a)return a;var i=n.attributes;if(!i)throw new Error("".concat(e,": Attributes are missing"));var s=new Array,l=new t.Geometry(r.name,this._babylonScene);if(null==n.indices)r.isUnIndexed=!0;else{var u=U.Get("".concat(e,"/indices"),this._gltf.accessors,n.indices);s.push(this._loadIndicesAccessorAsync("/accessors/".concat(u.index),u).then(function(e){l.setIndices(e)}))}var c=function(n,a,u){if(null!=i[n]){r._delayInfo=r._delayInfo||[],-1===r._delayInfo.indexOf(a)&&r._delayInfo.push(a);var c=U.Get("".concat(e,"/attributes/").concat(n),o._gltf.accessors,i[n]);s.push(o._loadVertexAccessorAsync("/accessors/".concat(c.index),c,a).then(function(e){if(e.getKind()===t.VertexBuffer.PositionKind&&!o.parent.alwaysComputeBoundingBox&&!r.skeleton){var n=z(c);n&&(l._boundingInfo=n,l.useBoundingInfoFromGeometry=!0)}l.setVerticesBuffer(e,c.count)})),a==t.VertexBuffer.MatricesIndicesExtraKind&&(r.numBoneInfluencers=8),u&&u(c)}};return c("POSITION",t.VertexBuffer.PositionKind),c("NORMAL",t.VertexBuffer.NormalKind),c("TANGENT",t.VertexBuffer.TangentKind),c("TEXCOORD_0",t.VertexBuffer.UVKind),c("TEXCOORD_1",t.VertexBuffer.UV2Kind),c("TEXCOORD_2",t.VertexBuffer.UV3Kind),c("TEXCOORD_3",t.VertexBuffer.UV4Kind),c("TEXCOORD_4",t.VertexBuffer.UV5Kind),c("TEXCOORD_5",t.VertexBuffer.UV6Kind),c("JOINTS_0",t.VertexBuffer.MatricesIndicesKind),c("WEIGHTS_0",t.VertexBuffer.MatricesWeightsKind),c("JOINTS_1",t.VertexBuffer.MatricesIndicesExtraKind),c("WEIGHTS_1",t.VertexBuffer.MatricesWeightsExtraKind),c("COLOR_0",t.VertexBuffer.ColorKind,function(e){"VEC4"===e.type&&(r.hasVertexAlpha=!0)}),Promise.all(s).then(function(){return l})},n.prototype._createMorphTargets=function(e,n,r,o,a){if(o.targets&&this._parent.loadMorphTargets){if(null==n._numMorphTargets)n._numMorphTargets=o.targets.length;else if(o.targets.length!==n._numMorphTargets)throw new Error("".concat(e,": Primitives do not have the same number of targets"));var i=r.extras?r.extras.targetNames:null;this._babylonScene._blockEntityCollection=!!this._assetContainer,a.morphTargetManager=new t.MorphTargetManager(this._babylonScene),a.morphTargetManager._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,a.morphTargetManager.areUpdatesFrozen=!0;for(var s=0;s<o.targets.length;s++){var l=n.weights?n.weights[s]:r.weights?r.weights[s]:0,u=i?i[s]:"morphTarget".concat(s);a.morphTargetManager.addTarget(new t.MorphTarget(u,l,a.getScene()))}}},n.prototype._loadMorphTargetsAsync=function(e,t,n,r){if(!t.targets||!this._parent.loadMorphTargets)return Promise.resolve();for(var o=new Array,a=n.morphTargetManager,i=0;i<a.numTargets;i++){var s=a.getTarget(i);o.push(this._loadMorphTargetVertexDataAsync("".concat(e,"/targets/").concat(i),r,t.targets[i],s))}return Promise.all(o).then(function(){a.areUpdatesFrozen=!1})},n.prototype._loadMorphTargetVertexDataAsync=function(e,n,r,o){return a(this,void 0,void 0,function(){var a,s,l=this;return i(this,function(i){switch(i.label){case 0:return a=new Array,(s=function(t,o,i){if(null!=r[t]){var s=n.getVertexBuffer(o);if(s){var u=U.Get("".concat(e,"/").concat(t),l._gltf.accessors,r[t]);a.push(l._loadFloatAccessorAsync("/accessors/".concat(u.index),u).then(function(e){i(s,e)}))}}})("POSITION",t.VertexBuffer.PositionKind,function(e,t){var n=new Float32Array(t.length);e.forEach(t.length,function(e,r){n[r]=t[r]+e}),o.setPositions(n)}),s("NORMAL",t.VertexBuffer.NormalKind,function(e,t){var n=new Float32Array(t.length);e.forEach(n.length,function(e,r){n[r]=t[r]+e}),o.setNormals(n)}),s("TANGENT",t.VertexBuffer.TangentKind,function(e,t){var n=new Float32Array(t.length/3*4),r=0;e.forEach(t.length/3*4,function(e,o){(o+1)%4!=0&&(n[r]=t[r]+e,r++)}),o.setTangents(n)}),s("TEXCOORD_0",t.VertexBuffer.UVKind,function(e,t){var n=new Float32Array(t.length);e.forEach(t.length,function(e,r){n[r]=t[r]+e}),o.setUVs(n)}),s("TEXCOORD_1",t.VertexBuffer.UV2Kind,function(e,t){var n=new Float32Array(t.length);e.forEach(t.length,function(e,r){n[r]=t[r]+e}),o.setUV2s(n)}),s("COLOR_0",t.VertexBuffer.ColorKind,function(t,n){var r=null,a=t.getSize();if(3===a){r=new Float32Array(n.length/3*4),t.forEach(n.length,function(e,t){var o=Math.floor(t/3),a=t%3;r[4*o+a]=n[3*o+a]+e});for(var i=0;i<n.length/3;++i)r[4*i+3]=1}else{if(4!==a)throw new Error("".concat(e,": Invalid number of components (").concat(a,") for COLOR_0 attribute"));r=new Float32Array(n.length),t.forEach(n.length,function(e,t){r[t]=n[t]+e})}o.setColors(r)}),[4,Promise.all(a).then(function(){})];case 1:return[2,i.sent()]}})})},n._LoadTransform=function(e,n){if(null==e.skin){var r=t.Vector3.Zero(),o=t.Quaternion.Identity(),a=t.Vector3.One();e.matrix?t.Matrix.FromArray(e.matrix).decompose(a,o,r):(e.translation&&(r=t.Vector3.FromArray(e.translation)),e.rotation&&(o=t.Quaternion.FromArray(e.rotation)),e.scale&&(a=t.Vector3.FromArray(e.scale))),n.position=r,n.rotationQuaternion=o,n.scaling=a}},n.prototype._loadSkinAsync=function(e,n,r,o){var a=this;if(!this._parent.loadSkins)return Promise.resolve();var i=this._extensionsLoadSkinAsync(e,n,r);if(i)return i;if(r._data)return o(r._data.babylonSkeleton),r._data.promise;var s="skeleton".concat(r.index);this._babylonScene._blockEntityCollection=!!this._assetContainer;var l=new t.Skeleton(r.name||s,s,this._babylonScene);l._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,this._loadBones(e,r,l);var u=this._loadSkinInverseBindMatricesDataAsync(e,r).then(function(e){a._updateBoneMatrices(l,e)});return r._data={babylonSkeleton:l,promise:u},o(l),u},n.prototype._loadBones=function(e,n,r){if(null==n.skeleton||this._parent.alwaysComputeSkeletonRootNode){var o=this._findSkeletonRootNode("".concat(e,"/joints"),n.joints);if(o)if(void 0===n.skeleton)n.skeleton=o.index;else{var a=U.Get("".concat(e,"/skeleton"),this._gltf.nodes,n.skeleton);a===o||function(e,t){for(;t.parent;t=t.parent)if(t.parent===e)return!0;return!1}(a,o)||(t.Logger.Warn("".concat(e,"/skeleton: Overriding with nearest common ancestor as skeleton node is not a common root")),n.skeleton=o.index)}else t.Logger.Warn("".concat(e,": Failed to find common root"))}for(var i={},s=0,l=n.joints;s<l.length;s++){var u=l[s],c=U.Get("".concat(e,"/joints/").concat(u),this._gltf.nodes,u);this._loadBone(c,n,r,i)}},n.prototype._findSkeletonRootNode=function(e,t){if(0===t.length)return null;for(var n={},r=0,o=t;r<o.length;r++){for(var a=o[r],i=[],s=U.Get("".concat(e,"/").concat(a),this._gltf.nodes,a);-1!==s.index;)i.unshift(s),s=s.parent;n[a]=i}for(var l=null,u=0;;++u){if(u>=(i=n[t[0]]).length)return l;s=i[u];for(var c=1;c<t.length;++c)if(u>=(i=n[t[c]]).length||s!==i[u])return l;l=s}},n.prototype._loadBone=function(e,n,r,o){e._isJoint=!0;var a=o[e.index];if(a)return a;var i=null;e.index!==n.skeleton&&(e.parent&&-1!==e.parent.index?i=this._loadBone(e.parent,n,r,o):void 0!==n.skeleton&&t.Logger.Warn("/skins/".concat(n.index,"/skeleton: Skeleton node is not a common root")));var s=n.joints.indexOf(e.index);return a=new t.Bone(e.name||"joint".concat(e.index),r,i,this._getNodeMatrix(e),null,null,s),o[e.index]=a,this._postSceneLoadActions.push(function(){a.linkTransformNode(e._babylonTransformNode)}),a},n.prototype._loadSkinInverseBindMatricesDataAsync=function(e,t){if(null==t.inverseBindMatrices)return Promise.resolve(null);var n=U.Get("".concat(e,"/inverseBindMatrices"),this._gltf.accessors,t.inverseBindMatrices);return this._loadFloatAccessorAsync("/accessors/".concat(n.index),n)},n.prototype._updateBoneMatrices=function(e,n){for(var r=0,o=e.bones;r<o.length;r++){var a=o[r],i=t.Matrix.Identity(),s=a._index;n&&-1!==s&&(t.Matrix.FromArrayToRef(n,16*s,i),i.invertToRef(i));var l=a.getParent();l&&i.multiplyToRef(l.getAbsoluteInverseBindMatrix(),i),a.updateMatrix(i,!1,!1),a._updateAbsoluteBindMatrices(void 0,!1)}},n.prototype._getNodeMatrix=function(e){return e.matrix?t.Matrix.FromArray(e.matrix):t.Matrix.Compose(e.scale?t.Vector3.FromArray(e.scale):t.Vector3.One(),e.rotation?t.Quaternion.FromArray(e.rotation):t.Quaternion.Identity(),e.translation?t.Vector3.FromArray(e.translation):t.Vector3.Zero())},n.prototype.loadCameraAsync=function(e,r,o){void 0===o&&(o=function(){});var a=this._extensionsLoadCameraAsync(e,r,o);if(a)return a;var i=new Array;this.logOpen("".concat(e," ").concat(r.name||"")),this._babylonScene._blockEntityCollection=!!this._assetContainer;var s=new t.FreeCamera(r.name||"camera".concat(r.index),t.Vector3.Zero(),this._babylonScene,!1);switch(s._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,r._babylonCamera=s,s.setTarget(new t.Vector3(0,0,-1)),r.type){case"perspective":var l=r.perspective;if(!l)throw new Error("".concat(e,": Camera perspective properties are missing"));s.fov=l.yfov,s.minZ=l.znear,s.maxZ=l.zfar||0;break;case"orthographic":if(!r.orthographic)throw new Error("".concat(e,": Camera orthographic properties are missing"));s.mode=t.Camera.ORTHOGRAPHIC_CAMERA,s.orthoLeft=-r.orthographic.xmag,s.orthoRight=r.orthographic.xmag,s.orthoBottom=-r.orthographic.ymag,s.orthoTop=r.orthographic.ymag,s.minZ=r.orthographic.znear,s.maxZ=r.orthographic.zfar;break;default:throw new Error("".concat(e,": Invalid camera type (").concat(r.type,")"))}return n.AddPointerMetadata(s,e),this._parent.onCameraLoadedObservable.notifyObservers(s),o(s),this.logClose(),Promise.all(i).then(function(){return s})},n.prototype._loadAnimationsAsync=function(){var e=this;this._parent._startPerformanceCounter("Load animations");var t=this._gltf.animations;if(!t)return Promise.resolve();for(var n=new Array,r=0;r<t.length;r++){var o=t[r];n.push(this.loadAnimationAsync("/animations/".concat(o.index),o).then(function(e){0===e.targetedAnimations.length&&e.dispose()}))}return Promise.all(n).then(function(){e._parent._endPerformanceCounter("Load animations")})},n.prototype.loadAnimationAsync=function(e,t){var n=this;return this._parent._startPerformanceCounter("Load animation"),this._extensionsLoadAnimationAsync(e,t)||j.value.then(function(r){var o=r.AnimationGroup;n._babylonScene._blockEntityCollection=!!n._assetContainer;var a=new o(t.name||"animation".concat(t.index),n._babylonScene);a._parentContainer=n._assetContainer,n._babylonScene._blockEntityCollection=!1,t._babylonAnimationGroup=a;var i=new Array;U.Assign(t.channels),U.Assign(t.samplers);for(var s=0,l=t.channels;s<l.length;s++){var u=l[s];i.push(n._loadAnimationChannelAsync("".concat(e,"/channels/").concat(u.index),e,t,u,function(e,t){e.animations=e.animations||[],e.animations.push(t),a.addTargetedAnimation(t,e)}))}return n._parent._endPerformanceCounter("Load animation"),Promise.all(i).then(function(){return a.normalize(0),a})})},n.prototype._loadAnimationChannelAsync=function(e,t,n,r,o){var a=this,i=this._extensionsLoadAnimationChannelAsync(e,t,n,r,o);if(i)return i;if(null==r.target.node)return Promise.resolve();var s=U.Get("".concat(e,"/target/node"),this._gltf.nodes,r.target.node),l=r.target.path,u="weights"===l;return u&&!s._numMorphTargets||!u&&!s._babylonTransformNode?Promise.resolve():this._parent.loadNodeAnimations||u||s._isJoint?W.value.then(function(){var i,u,c,f,h;switch(l){case"translation":h=null===(i=B("/nodes/{}/translation"))||void 0===i?void 0:i.interpolation;break;case"rotation":h=null===(u=B("/nodes/{}/rotation"))||void 0===u?void 0:u.interpolation;break;case"scale":h=null===(c=B("/nodes/{}/scale"))||void 0===c?void 0:c.interpolation;break;case"weights":h=null===(f=B("/nodes/{}/weights"))||void 0===f?void 0:f.interpolation;break;default:throw new Error("".concat(e,"/target/path: Invalid value (").concat(r.target.path,")"))}if(!h)throw new Error("".concat(e,"/target/path: Could not find interpolation properties for target path (").concat(r.target.path,")"));var p={object:s,info:h};return a._loadAnimationChannelFromTargetInfoAsync(e,t,n,r,p,o)}):Promise.resolve()},n.prototype._loadAnimationChannelFromTargetInfoAsync=function(e,t,n,r,o,a){var i=this.parent.targetFps,s=1/i,l=U.Get("".concat(e,"/sampler"),n.samplers,r.sampler);return this._loadAnimationSamplerAsync("".concat(t,"/samplers/").concat(r.sampler),l).then(function(e){for(var t=0,l=o.object,u=0,c=o.info;u<c.length;u++){var f=c[u],h=f.getStride(l),p=e.input,d=e.output,m=new Array(p.length),_=0;switch(e.interpolation){case"STEP":for(var b=0;b<p.length;b++){var g=f.getValue(l,d,_,1);_+=h,m[b]={frame:p[b]*i,value:g,interpolation:1}}break;case"CUBICSPLINE":for(b=0;b<p.length;b++){var y=f.getValue(l,d,_,s);_+=h,g=f.getValue(l,d,_,1),_+=h;var v=f.getValue(l,d,_,s);_+=h,m[b]={frame:p[b]*i,inTangent:y,value:g,outTangent:v}}break;case"LINEAR":for(b=0;b<p.length;b++)g=f.getValue(l,d,_,1),_+=h,m[b]={frame:p[b]*i,value:g}}if(_>0)for(var T="".concat(n.name||"animation".concat(n.index),"_channel").concat(r.index,"_").concat(t),x=0,A=f.buildAnimations(l,T,i,m);x<A.length;x++){var C=A[x];t++,a(C.babylonAnimatable,C.babylonAnimation)}}})},n.prototype._loadAnimationSamplerAsync=function(e,t){if(t._data)return t._data;var n=t.interpolation||"LINEAR";switch(n){case"STEP":case"LINEAR":case"CUBICSPLINE":break;default:throw new Error("".concat(e,"/interpolation: Invalid value (").concat(t.interpolation,")"))}var r=U.Get("".concat(e,"/input"),this._gltf.accessors,t.input),o=U.Get("".concat(e,"/output"),this._gltf.accessors,t.output);return t._data=Promise.all([this._loadFloatAccessorAsync("/accessors/".concat(r.index),r),this._loadFloatAccessorAsync("/accessors/".concat(o.index),o)]).then(function(e){var t=e[0],r=e[1];return{input:t,interpolation:n,output:r}}),t._data},n.prototype.loadBufferAsync=function(e,t,n,r){var o=this._extensionsLoadBufferAsync(e,t,n,r);if(o)return o;if(!t._data)if(t.uri)t._data=this.loadUriAsync("".concat(e,"/uri"),t,t.uri);else{if(!this._bin)throw new Error("".concat(e,": Uri is missing or the binary glTF is missing its binary chunk"));t._data=this._bin.readAsync(0,t.byteLength)}return t._data.then(function(t){try{return new Uint8Array(t.buffer,t.byteOffset+n,r)}catch(t){throw new Error("".concat(e,": ").concat(t.message),{cause:t})}})},n.prototype.loadBufferViewAsync=function(e,t){var n=this._extensionsLoadBufferViewAsync(e,t);if(n)return n;if(t._data)return t._data;var r=U.Get("".concat(e,"/buffer"),this._gltf.buffers,t.buffer);return t._data=this.loadBufferAsync("/buffers/".concat(r.index),r,t.byteOffset||0,t.byteLength),t._data},n.prototype._loadAccessorAsync=function(e,r,o){var a=this;if(r._data)return r._data;var i=n._GetNumComponents(e,r.type),s=i*t.VertexBufferGetTypeByteLength(r.componentType),l=i*r.count;if(null==r.bufferView)r._data=Promise.resolve(new o(l));else{var u=U.Get("".concat(e,"/bufferView"),this._gltf.bufferViews,r.bufferView);r._data=this.loadBufferViewAsync("/bufferViews/".concat(u.index),u).then(function(a){if(5126!==r.componentType||r.normalized||u.byteStride&&u.byteStride!==s){var c=new o(l);return t.VertexBufferForEach(a,r.byteOffset||0,u.byteStride||s,i,r.componentType,c.length,r.normalized||!1,function(e,t){c[t]=e}),c}return n._GetTypedArray(e,r.componentType,a,r.byteOffset,l)})}if(r.sparse){var c=r.sparse;r._data=r._data.then(function(l){var u=l,f=U.Get("".concat(e,"/sparse/indices/bufferView"),a._gltf.bufferViews,c.indices.bufferView),h=U.Get("".concat(e,"/sparse/values/bufferView"),a._gltf.bufferViews,c.values.bufferView);return Promise.all([a.loadBufferViewAsync("/bufferViews/".concat(f.index),f),a.loadBufferViewAsync("/bufferViews/".concat(h.index),h)]).then(function(a){var l,f=a[0],h=a[1],p=n._GetTypedArray("".concat(e,"/sparse/indices"),c.indices.componentType,f,c.indices.byteOffset,c.count),d=i*c.count;if(5126!==r.componentType||r.normalized){var m=n._GetTypedArray("".concat(e,"/sparse/values"),r.componentType,h,c.values.byteOffset,d);l=new o(d),t.VertexBufferForEach(m,0,s,i,r.componentType,l.length,r.normalized||!1,function(e,t){l[t]=e})}else l=n._GetTypedArray("".concat(e,"/sparse/values"),r.componentType,h,c.values.byteOffset,d);for(var _=0,b=0;b<p.length;b++)for(var g=p[b]*i,y=0;y<i;y++)u[g++]=l[_++];return u})})}return r._data},n.prototype._loadFloatAccessorAsync=function(e,t){return this._loadAccessorAsync(e,t,Float32Array)},n.prototype._loadIndicesAccessorAsync=function(e,t){if("SCALAR"!==t.type)throw new Error("".concat(e,"/type: Invalid value ").concat(t.type));if(5121!==t.componentType&&5123!==t.componentType&&5125!==t.componentType)throw new Error("".concat(e,"/componentType: Invalid value ").concat(t.componentType));if(t._data)return t._data;if(t.sparse){var r=n._GetTypedArrayConstructor("".concat(e,"/componentType"),t.componentType);t._data=this._loadAccessorAsync(e,t,r)}else{var o=U.Get("".concat(e,"/bufferView"),this._gltf.bufferViews,t.bufferView);t._data=this.loadBufferViewAsync("/bufferViews/".concat(o.index),o).then(function(r){return n._GetTypedArray(e,t.componentType,r,t.byteOffset,t.count)})}return t._data},n.prototype._loadVertexBufferViewAsync=function(e){if(e._babylonBuffer)return e._babylonBuffer;var n=this._babylonScene.getEngine();return e._babylonBuffer=this.loadBufferViewAsync("/bufferViews/".concat(e.index),e).then(function(e){return new t.Buffer(n,e,!1)}),e._babylonBuffer},n.prototype._loadVertexAccessorAsync=function(e,r,o){var a;if(null===(a=r._babylonVertexBuffer)||void 0===a?void 0:a[o])return r._babylonVertexBuffer[o];r._babylonVertexBuffer||(r._babylonVertexBuffer={});var i=this._babylonScene.getEngine();if(r.sparse||null==r.bufferView)r._babylonVertexBuffer[o]=this._loadFloatAccessorAsync(e,r).then(function(e){return new t.VertexBuffer(i,e,o,!1)});else{var s=U.Get("".concat(e,"/bufferView"),this._gltf.bufferViews,r.bufferView);r._babylonVertexBuffer[o]=this._loadVertexBufferViewAsync(s).then(function(a){var l=n._GetNumComponents(e,r.type);return new t.VertexBuffer(i,a,o,!1,void 0,s.byteStride,void 0,r.byteOffset,l,r.componentType,r.normalized,!0,void 0,!0)})}return r._babylonVertexBuffer[o]},n.prototype._loadMaterialMetallicRoughnessPropertiesAsync=function(e,n,r){var o=new Array,a=this._getOrCreateMaterialAdapter(r);return n&&(n.baseColorFactor?(a.baseColor=t.Color3.FromArray(n.baseColorFactor),a.geometryOpacity=n.baseColorFactor[3]):a.baseColor=t.Color3.White(),a.baseMetalness=null==n.metallicFactor?1:n.metallicFactor,a.specularRoughness=null==n.roughnessFactor?1:n.roughnessFactor,n.baseColorTexture&&o.push(this.loadTextureInfoAsync("".concat(e,"/baseColorTexture"),n.baseColorTexture,function(e){e.name="".concat(r.name," (Base Color)"),a.baseColorTexture=e})),n.metallicRoughnessTexture&&(n.metallicRoughnessTexture.nonColorData=!0,o.push(this.loadTextureInfoAsync("".concat(e,"/metallicRoughnessTexture"),n.metallicRoughnessTexture,function(e){e.name="".concat(r.name," (Metallic Roughness)"),a.baseMetalnessTexture=e,a.specularRoughnessTexture=e})),a.useRoughnessFromMetallicTextureGreen=!0,a.useMetallicFromMetallicTextureBlue=!0)),Promise.all(o).then(function(){})},n.prototype._loadMaterialAsync=function(e,t,r,o,a){void 0===a&&(a=function(){});var i=this._extensionsLoadMaterialAsync(e,t,r,o,a);if(i)return i;t._data=t._data||{};var s=t._data[o];if(!s){this.logOpen("".concat(e," ").concat(t.name||""));var l=this.createMaterial(e,t,o);s={babylonMaterial:l,babylonMeshes:[],promise:this.loadMaterialPropertiesAsync(e,t,l)},t._data[o]=s,n.AddPointerMetadata(l,e),this._parent.onMaterialLoadedObservable.notifyObservers(l),this.logClose()}return r&&(s.babylonMeshes.push(r),r.onDisposeObservable.addOnce(function(){var e=s.babylonMeshes.indexOf(r);-1!==e&&s.babylonMeshes.splice(e,1)})),a(s.babylonMaterial),s.promise.then(function(){return s.babylonMaterial})},n.prototype._createDefaultMaterial=function(e,t){if(!this._pbrMaterialImpl)throw new Error("PBR Material class not loaded");this._babylonScene._blockEntityCollection=!!this._assetContainer;var n=new this._pbrMaterialImpl.materialClass(e,this._babylonScene);n._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,n.fillMode=t,n.transparencyMode=this._pbrMaterialImpl.materialClass.MATERIAL_OPAQUE;var r=this._getOrCreateMaterialAdapter(n);return r.transparencyAsAlphaCoverage=this._parent.transparencyAsCoverage,r.baseMetalness=1,r.specularRoughness=1,n},n.prototype.createMaterial=function(e,t,n){var r=this._extensionsCreateMaterial(e,t,n);if(r)return r;var o=t.name||"material".concat(t.index);return this._createDefaultMaterial(o,n)},n.prototype.loadMaterialPropertiesAsync=function(e,t,n){var r=this._extensionsLoadMaterialPropertiesAsync(e,t,n);if(r)return r;var o=new Array;return o.push(this.loadMaterialBasePropertiesAsync(e,t,n)),t.pbrMetallicRoughness&&o.push(this._loadMaterialMetallicRoughnessPropertiesAsync("".concat(e,"/pbrMetallicRoughness"),t.pbrMetallicRoughness,n)),this.loadMaterialAlphaProperties(e,t,n),Promise.all(o).then(function(){})},n.prototype.loadMaterialBasePropertiesAsync=function(e,n,r){var o,a=new Array,i=this._getOrCreateMaterialAdapter(r);i.emissionColor=n.emissiveFactor?t.Color3.FromArray(n.emissiveFactor):new t.Color3(0,0,0),n.doubleSided&&(i.backFaceCulling=!1,i.twoSidedLighting=!0),n.normalTexture&&(n.normalTexture.nonColorData=!0,a.push(this.loadTextureInfoAsync("".concat(e,"/normalTexture"),n.normalTexture,function(e){var t;e.name="".concat(r.name," (Normal)"),i.geometryNormalTexture=e,null!=(null===(t=n.normalTexture)||void 0===t?void 0:t.scale)&&(e.level=n.normalTexture.scale)})),i.setNormalMapInversions(!this._babylonScene.useRightHandedSystem,this._babylonScene.useRightHandedSystem));var s,l=1;return n.occlusionTexture&&(n.occlusionTexture.nonColorData=!0,a.push(this.loadTextureInfoAsync("".concat(e,"/occlusionTexture"),n.occlusionTexture,function(e){e.name="".concat(r.name," (Occlusion)"),o=e})),null!=n.occlusionTexture.strength&&(l=n.occlusionTexture.strength)),n.emissiveTexture&&a.push(this.loadTextureInfoAsync("".concat(e,"/emissiveTexture"),n.emissiveTexture,function(e){e.name="".concat(r.name," (Emissive)"),s=e})),Promise.all(a).then(function(){o&&(i.ambientOcclusionTexture=o,i.ambientOcclusionTextureStrength=l),s&&(i.emissionColorTexture=s)})},n.prototype.loadMaterialAlphaProperties=function(e,t,n){if(!this._pbrMaterialImpl)throw new Error("".concat(e,": Material type not supported"));var r=this._getOrCreateMaterialAdapter(n),o=r.baseColorTexture;switch(t.alphaMode||"OPAQUE"){case"OPAQUE":n.transparencyMode=this._pbrMaterialImpl.materialClass.MATERIAL_OPAQUE,n.alpha=1;break;case"MASK":n.transparencyMode=this._pbrMaterialImpl.materialClass.MATERIAL_ALPHATEST,r.alphaCutOff=null==t.alphaCutoff?.5:t.alphaCutoff,o&&(o.hasAlpha=!0);break;case"BLEND":n.transparencyMode=this._pbrMaterialImpl.materialClass.MATERIAL_ALPHABLEND,o&&(o.hasAlpha=!0,r.useAlphaFromBaseColorTexture=!0);break;default:throw new Error("".concat(e,"/alphaMode: Invalid value (").concat(t.alphaMode,")"))}},n.prototype.loadTextureInfoAsync=function(e,t,r){var o=this;void 0===r&&(r=function(){});var a=this._extensionsLoadTextureInfoAsync(e,t,r);if(a)return a;if(this.logOpen("".concat(e)),t.texCoord>=6)throw new Error("".concat(e,"/texCoord: Invalid value (").concat(t.texCoord,")"));var i=U.Get("".concat(e,"/index"),this._gltf.textures,t.index);i._textureInfo=t;var s=this._loadTextureAsync("/textures/".concat(t.index),i,function(a){a.coordinatesIndex=t.texCoord||0,n.AddPointerMetadata(a,e),o._parent.onTextureLoadedObservable.notifyObservers(a),r(a)});return this.logClose(),s},n.prototype._loadTextureAsync=function(e,t,r){void 0===r&&(r=function(){});var o=this._extensionsLoadTextureAsync(e,t,r);if(o)return o;this.logOpen("".concat(e," ").concat(t.name||""));var a=null==t.sampler?n.DefaultSampler:U.Get("".concat(e,"/sampler"),this._gltf.samplers,t.sampler),i=U.Get("".concat(e,"/source"),this._gltf.images,t.source),s=this._createTextureAsync(e,a,i,r,void 0,!t._textureInfo.nonColorData);return this.logClose(),s},n.prototype._createTextureAsync=function(e,n,r,o,a,i){var s,l,u=this;void 0===o&&(o=function(){});var c=this._loadSampler("/samplers/".concat(n.index),n),f=new Array,h=new t.Deferred;this._babylonScene._blockEntityCollection=!!this._assetContainer;var p={noMipmap:c.noMipMaps,invertY:!1,samplingMode:c.samplingMode,onLoad:function(){u._disposed||h.resolve()},onError:function(t,n){u._disposed||h.reject(new Error("".concat(e,": ").concat(n&&n.message?n.message:t||"Failed to load texture")))},mimeType:null!==(s=r.mimeType)&&void 0!==s?s:t.GetMimeType(null!==(l=r.uri)&&void 0!==l?l:""),loaderOptions:a,useSRGBBuffer:!!i&&this._parent.useSRGBBuffers},d=new t.Texture(null,this._babylonScene,p);d._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,f.push(h.promise);var m=r.uri&&!t.IsBase64DataUrl(r.uri)?r.uri:void 0,_=null!=m?m:"".concat(this._fileName,"#image").concat(r.index);if(f.push(this.loadImageAsync("/images/".concat(r.index),r).then(function(e){var t="data:".concat(u._uniqueRootUrl).concat(_);d.updateURL(t,e);var n=d.getInternalTexture();n&&(n.label=r.name)})),d.wrapU=c.wrapU,d.wrapV=c.wrapV,o(d),this._parent.useGltfTextureNames){var b=r.name||m||"image".concat(r.index);d.name=b}return Promise.all(f).then(function(){return d})},n.prototype._loadSampler=function(e,t){return t._data||(t._data={noMipMaps:9728===t.minFilter||9729===t.minFilter,samplingMode:n._GetTextureSamplingMode(e,t),wrapU:n._GetTextureWrapMode("".concat(e,"/wrapS"),t.wrapS),wrapV:n._GetTextureWrapMode("".concat(e,"/wrapT"),t.wrapT)}),t._data},n.prototype.loadImageAsync=function(e,t){if(!t._data){if(this.logOpen("".concat(e," ").concat(t.name||"")),t.uri)t._data=this.loadUriAsync("".concat(e,"/uri"),t,t.uri);else{var n=U.Get("".concat(e,"/bufferView"),this._gltf.bufferViews,t.bufferView);t._data=this.loadBufferViewAsync("/bufferViews/".concat(n.index),n)}this.logClose()}return t._data},n.prototype.loadUriAsync=function(e,r,o){var a=this,i=this._extensionsLoadUriAsync(e,r,o);if(i)return i;if(!n._ValidateUri(o))throw new Error("".concat(e,": '").concat(o,"' is invalid"));if(t.IsBase64DataUrl(o)){var s=new Uint8Array(t.DecodeBase64UrlToBinary(o));return this.log("".concat(e,": Decoded ").concat(o.substring(0,64),"... (").concat(s.length," bytes)")),Promise.resolve(s)}return this.log("".concat(e,": Loading ").concat(o)),this._parent.preprocessUrlAsync(this._rootUrl+o).then(function(n){return new Promise(function(r,i){a._parent._loadFile(a._babylonScene,n,function(t){a._disposed||(a.log("".concat(e,": Loaded ").concat(o," (").concat(t.byteLength," bytes)")),r(new Uint8Array(t)))},!0,function(n){i(new t.LoadFileError("".concat(e,": Failed to load '").concat(o,"'").concat(n?": "+n.status+" "+n.statusText:""),n))})})})},n.AddPointerMetadata=function(e,t){e.metadata=e.metadata||{};var n=e._internalMetadata=e._internalMetadata||{},r=n.gltf=n.gltf||{};(r.pointers=r.pointers||[]).push(t)},n._GetTextureWrapMode=function(e,n){switch(n=null==n?10497:n){case 33071:return t.Texture.CLAMP_ADDRESSMODE;case 33648:return t.Texture.MIRROR_ADDRESSMODE;case 10497:return t.Texture.WRAP_ADDRESSMODE;default:return t.Logger.Warn("".concat(e,": Invalid value (").concat(n,")")),t.Texture.WRAP_ADDRESSMODE}},n._GetTextureSamplingMode=function(e,n){var r=null==n.magFilter?9729:n.magFilter,o=null==n.minFilter?9987:n.minFilter;if(9729===r)switch(o){case 9728:return t.Texture.LINEAR_NEAREST;case 9729:return t.Texture.LINEAR_LINEAR;case 9984:return t.Texture.LINEAR_NEAREST_MIPNEAREST;case 9985:return t.Texture.LINEAR_LINEAR_MIPNEAREST;case 9986:return t.Texture.LINEAR_NEAREST_MIPLINEAR;case 9987:return t.Texture.LINEAR_LINEAR_MIPLINEAR;default:return t.Logger.Warn("".concat(e,"/minFilter: Invalid value (").concat(o,")")),t.Texture.LINEAR_LINEAR_MIPLINEAR}else switch(9728!==r&&t.Logger.Warn("".concat(e,"/magFilter: Invalid value (").concat(r,")")),o){case 9728:return t.Texture.NEAREST_NEAREST;case 9729:return t.Texture.NEAREST_LINEAR;case 9984:return t.Texture.NEAREST_NEAREST_MIPNEAREST;case 9985:return t.Texture.NEAREST_LINEAR_MIPNEAREST;case 9986:return t.Texture.NEAREST_NEAREST_MIPLINEAR;case 9987:return t.Texture.NEAREST_LINEAR_MIPLINEAR;default:return t.Logger.Warn("".concat(e,"/minFilter: Invalid value (").concat(o,")")),t.Texture.NEAREST_NEAREST_MIPNEAREST}},n._GetTypedArrayConstructor=function(e,n){try{return t.GetTypedArrayConstructor(n)}catch(t){throw new Error("".concat(e,": ").concat(t.message),{cause:t})}},n._GetTypedArray=function(e,r,o,a,i){var s=o.buffer;a=o.byteOffset+(a||0);var l=n._GetTypedArrayConstructor("".concat(e,"/componentType"),r),u=t.VertexBufferGetTypeByteLength(r);return a%u!==0?(t.Logger.Warn("".concat(e,": Copying buffer as byte offset (").concat(a,") is not a multiple of component type byte length (").concat(u,")")),new l(s.slice(a,a+i*u),0)):new l(s,a,i)},n._GetNumComponents=function(e,t){switch(t){case"SCALAR":return 1;case"VEC2":return 2;case"VEC3":return 3;case"VEC4":case"MAT2":return 4;case"MAT3":return 9;case"MAT4":return 16}throw new Error("".concat(e,": Invalid type (").concat(t,")"))},n._ValidateUri=function(e){return t.Tools.IsBase64(e)||-1===e.indexOf("..")},n._GetDrawMode=function(e,n){switch(null==n&&(n=4),n){case 0:return t.Material.PointListDrawMode;case 1:return t.Material.LineListDrawMode;case 2:return t.Material.LineLoopDrawMode;case 3:return t.Material.LineStripDrawMode;case 4:return t.Material.TriangleFillMode;case 5:return t.Material.TriangleStripDrawMode;case 6:return t.Material.TriangleFanDrawMode}throw new Error("".concat(e,": Invalid mesh primitive mode (").concat(n,")"))},n.prototype._compileMaterialsAsync=function(){var e=this;this._parent._startPerformanceCounter("Compile materials");var t=new Array;if(this._gltf.materials)for(var n=0,r=this._gltf.materials;n<r.length;n++){var o=r[n];if(o._data)for(var a in o._data)for(var i=o._data[a],s=0,l=i.babylonMeshes;s<l.length;s++){var u=l[s];u.computeWorldMatrix(!0);var c=i.babylonMaterial;t.push(c.forceCompilationAsync(u)),t.push(c.forceCompilationAsync(u,{useInstances:!0})),this._parent.useClipPlane&&(t.push(c.forceCompilationAsync(u,{clipPlane:!0})),t.push(c.forceCompilationAsync(u,{clipPlane:!0,useInstances:!0})))}}return Promise.all(t).then(function(){e._parent._endPerformanceCounter("Compile materials")})},n.prototype._compileShadowGeneratorsAsync=function(){var e=this;this._parent._startPerformanceCounter("Compile shadow generators");for(var t=new Array,n=0,r=this._babylonScene.lights;n<r.length;n++){var o=r[n].getShadowGenerator();o&&t.push(o.forceCompilationAsync())}return Promise.all(t).then(function(){e._parent._endPerformanceCounter("Compile shadow generators")})},n.prototype._forEachExtensions=function(e){for(var t=0,n=this._extensions;t<n.length;t++){var r=n[t];r.enabled&&e(r)}},n.prototype._applyExtensions=function(e,t,n){for(var r=0,o=this._extensions;r<o.length;r++){var a=o[r];if(a.enabled){var i="".concat(a.name,".").concat(t),s=e;s._activeLoaderExtensionFunctions=s._activeLoaderExtensionFunctions||{};var l=s._activeLoaderExtensionFunctions;if(!l[i]){l[i]=!0;try{var u=n(a);if(u)return u}finally{delete l[i]}}}}return null},n.prototype._extensionsOnLoading=function(){this._forEachExtensions(function(e){return e.onLoading&&e.onLoading()})},n.prototype._extensionsOnReady=function(){this._forEachExtensions(function(e){return e.onReady&&e.onReady()})},n.prototype._extensionsLoadSceneAsync=function(e,t){return this._applyExtensions(t,"loadScene",function(n){return n.loadSceneAsync&&n.loadSceneAsync(e,t)})},n.prototype._extensionsLoadNodeAsync=function(e,t,n){return this._applyExtensions(t,"loadNode",function(r){return r.loadNodeAsync&&r.loadNodeAsync(e,t,n)})},n.prototype._extensionsLoadCameraAsync=function(e,t,n){return this._applyExtensions(t,"loadCamera",function(r){return r.loadCameraAsync&&r.loadCameraAsync(e,t,n)})},n.prototype._extensionsLoadVertexDataAsync=function(e,t,n){return this._applyExtensions(t,"loadVertexData",function(r){return r._loadVertexDataAsync&&r._loadVertexDataAsync(e,t,n)})},n.prototype._extensionsLoadMeshPrimitiveAsync=function(e,t,n,r,o,a){return this._applyExtensions(o,"loadMeshPrimitive",function(i){return i._loadMeshPrimitiveAsync&&i._loadMeshPrimitiveAsync(e,t,n,r,o,a)})},n.prototype._extensionsLoadMaterialAsync=function(e,t,n,r,o){return this._applyExtensions(t,"loadMaterial",function(a){return a._loadMaterialAsync&&a._loadMaterialAsync(e,t,n,r,o)})},n.prototype._extensionsCreateMaterial=function(e,t,n){return this._applyExtensions(t,"createMaterial",function(r){return r.createMaterial&&r.createMaterial(e,t,n)})},n.prototype._extensionsLoadMaterialPropertiesAsync=function(e,t,n){return this._applyExtensions(t,"loadMaterialProperties",function(r){return r.loadMaterialPropertiesAsync&&r.loadMaterialPropertiesAsync(e,t,n)})},n.prototype._extensionsLoadTextureInfoAsync=function(e,t,n){return this._applyExtensions(t,"loadTextureInfo",function(r){return r.loadTextureInfoAsync&&r.loadTextureInfoAsync(e,t,n)})},n.prototype._extensionsLoadTextureAsync=function(e,t,n){return this._applyExtensions(t,"loadTexture",function(r){return r._loadTextureAsync&&r._loadTextureAsync(e,t,n)})},n.prototype._extensionsLoadAnimationAsync=function(e,t){return this._applyExtensions(t,"loadAnimation",function(n){return n.loadAnimationAsync&&n.loadAnimationAsync(e,t)})},n.prototype._extensionsLoadAnimationChannelAsync=function(e,t,n,r,o){return this._applyExtensions(n,"loadAnimationChannel",function(a){return a._loadAnimationChannelAsync&&a._loadAnimationChannelAsync(e,t,n,r,o)})},n.prototype._extensionsLoadSkinAsync=function(e,t,n){return this._applyExtensions(n,"loadSkin",function(r){return r._loadSkinAsync&&r._loadSkinAsync(e,t,n)})},n.prototype._extensionsLoadUriAsync=function(e,t,n){return this._applyExtensions(t,"loadUri",function(r){return r._loadUriAsync&&r._loadUriAsync(e,t,n)})},n.prototype._extensionsLoadBufferViewAsync=function(e,t){return this._applyExtensions(t,"loadBufferView",function(n){return n.loadBufferViewAsync&&n.loadBufferViewAsync(e,t)})},n.prototype._extensionsLoadBufferAsync=function(e,t,n,r){return this._applyExtensions(t,"loadBuffer",function(o){return o.loadBufferAsync&&o.loadBufferAsync(e,t,n,r)})},n.LoadExtensionAsync=function(e,t,n,r){if(!t.extensions)return null;var o=t.extensions[n];return o?r("".concat(e,"/extensions/").concat(n),o):null},n.LoadExtraAsync=function(e,t,n,r){if(!t.extras)return null;var o=t.extras[n];return o?r("".concat(e,"/extras/").concat(n),o):null},n.prototype.isExtensionUsed=function(e){return!!this._gltf.extensionsUsed&&-1!==this._gltf.extensionsUsed.indexOf(e)},n.prototype.logOpen=function(e){this._parent._logOpen(e)},n.prototype.logClose=function(){this._parent._logClose()},n.prototype.log=function(e){this._parent._log(e)},n.prototype.startPerformanceCounter=function(e){this._parent._startPerformanceCounter(e)},n.prototype.endPerformanceCounter=function(e){this._parent._endPerformanceCounter(e)},n.DefaultSampler={index:-1},n}();T._CreateGLTF2Loader=function(e){return new q(e)};var Y="EXT_lights_image_based",X=function(){function e(e){this.name=Y,this._loader=e,this.enabled=this._loader.isExtensionUsed(Y)}return e.prototype.dispose=function(){this._loader=null,delete this._lights},e.prototype.onLoading=function(){var e=this._loader.gltf.extensions;if(e&&e[this.name]){var t=e[this.name];this._lights=t.lights}},e.prototype.loadSceneAsync=function(e,t){var n=this;return q.LoadExtensionAsync(e,t,this.name,function(r,o){return a(n,void 0,void 0,function(){var n,a,s=this;return i(this,function(i){switch(i.label){case 0:return this._loader._allMaterialsDirtyRequired=!0,(n=new Array).push(this._loader.loadSceneAsync(e,t)),this._loader.logOpen("".concat(r)),a=U.Get("".concat(r,"/light"),this._lights,o.light),n.push(this._loadLightAsync("/extensions/".concat(this.name,"/lights/").concat(o.light),a).then(function(e){s._loader.babylonScene.environmentTexture=e})),this._loader.logClose(),[4,Promise.all(n).then(function(){})];case 1:return[2,i.sent()]}})})})},e.prototype._loadLightAsync=function(e,n){var r=this;if(!n._loaded){var o=new Array;this._loader.logOpen("".concat(e));for(var s=new Array(n.specularImages.length),l=function(t){var r=n.specularImages[t];s[t]=new Array(r.length);for(var a=function(n){var a="".concat(e,"/specularImages/").concat(t,"/").concat(n);u._loader.logOpen("".concat(a));var i=r[n],l=U.Get(a,u._loader.gltf.images,i);o.push(u._loader.loadImageAsync("/images/".concat(i),l).then(function(e){s[t][n]=e})),u._loader.logClose()},i=0;i<r.length;i++)a(i)},u=this,c=0;c<n.specularImages.length;c++)l(c);this._loader.logClose(),n._loaded=Promise.all(o).then(function(){return a(r,void 0,void 0,function(){var r,o,a,l,u;return i(this,function(i){switch(i.label){case 0:if((r=new t.RawCubeTexture(this._loader.babylonScene,null,n.specularImageSize)).name=n.name||"environment",n._babylonTexture=r,null!=n.intensity&&(r.level=n.intensity),n.rotation&&(o=t.Quaternion.FromArray(n.rotation),this._loader.babylonScene.useRightHandedSystem||(o=t.Quaternion.Inverse(o)),t.Matrix.FromQuaternionToRef(o,r.getReflectionTextureMatrix())),!n.irradianceCoefficients)throw new Error("".concat(e,": Irradiance coefficients are missing"));return(a=t.SphericalHarmonics.FromArray(n.irradianceCoefficients)).scaleInPlace(n.intensity),a.convertIrradianceToLambertianRadiance(),l=t.SphericalPolynomial.FromHarmonics(a),u=(s.length-1)/Math.log2(n.specularImageSize),[4,r.updateRGBDAsync(s,l,u)];case 1:return[2,i.sent()]}})})})}return n._loaded.then(function(){return n._babylonTexture})},e}();K(Y),H(Y,!0,function(e){return new X(e)});var Q="EXT_mesh_gpu_instancing",J=function(){function e(e){this.name=Q,this._loader=e,this.enabled=this._loader.isExtensionUsed(Q)}return e.prototype.dispose=function(){this._loader=null},e.prototype.loadNodeAsync=function(e,n,r){var o=this;return q.LoadExtensionAsync(e,n,this.name,function(e,s){return a(o,void 0,void 0,function(){var o,l,u,c,f=this;return i(this,function(h){switch(h.label){case 0:return this._loader._disableInstancedMesh++,o=this._loader.loadNodeAsync("/nodes/".concat(n.index),n,r),this._loader._disableInstancedMesh--,n._primitiveBabylonMeshes?[3,2]:[4,o];case 1:case 3:return[2,h.sent()];case 2:return l=new Array,u=0,(c=function(t){if(null!=s.attributes[t]){var n=U.Get("".concat(e,"/attributes/").concat(t),f._loader.gltf.accessors,s.attributes[t]);if(l.push(f._loader._loadFloatAccessorAsync("/accessors/".concat(n.bufferView),n)),0===u)u=n.count;else if(u!==n.count)throw new Error("".concat(e,"/attributes: Instance buffer accessors do not have the same count."))}else l.push(Promise.resolve(null))})("TRANSLATION"),c("ROTATION"),c("SCALE"),c("_COLOR_0"),[4,o.then(function(e){return a(f,void 0,void 0,function(){var r,o,a,s,c,f,h,p,d,m;return i(this,function(i){switch(i.label){case 0:return[4,Promise.all(l)];case 1:for(r=i.sent(),o=r[0],a=r[1],s=r[2],c=r[3],f=new Float32Array(16*u),t.TmpVectors.Vector3[0].copyFromFloats(0,0,0),t.TmpVectors.Quaternion[0].copyFromFloats(0,0,0,1),t.TmpVectors.Vector3[1].copyFromFloats(1,1,1),h=0;h<u;++h)o&&t.Vector3.FromArrayToRef(o,3*h,t.TmpVectors.Vector3[0]),a&&t.Quaternion.FromArrayToRef(a,4*h,t.TmpVectors.Quaternion[0]),s&&t.Vector3.FromArrayToRef(s,3*h,t.TmpVectors.Vector3[1]),t.Matrix.ComposeToRef(t.TmpVectors.Vector3[1],t.TmpVectors.Quaternion[0],t.TmpVectors.Vector3[0],t.TmpVectors.Matrix[0]),t.TmpVectors.Matrix[0].copyToArray(f,16*h);for(p=0,d=n._primitiveBabylonMeshes;p<d.length;p++)(m=d[p]).thinInstanceSetBuffer("matrix",f,16,!0),c&&(c.length===3*u?m.thinInstanceSetBuffer("color",c,3,!0):c.length===4*u?m.thinInstanceSetBuffer("color",c,4,!0):t.Logger.Warn("Unexpected size of _COLOR_0 attribute for mesh "+m.name));return[2,e]}})})})]}})})})},e}();K(Q),H(Q,!0,function(e){return new J(e)});var Z="EXT_meshopt_compression",$=function(){function e(e){this.name=Z,this.enabled=e.isExtensionUsed(Z),this._loader=e}return e.prototype.dispose=function(){this._loader=null},e.prototype.loadBufferViewAsync=function(e,n){var r=this;return q.LoadExtensionAsync(e,n,this.name,function(o,s){return a(r,void 0,void 0,function(){var r,o,l=this;return i(this,function(u){switch(u.label){case 0:return(r=n)._meshOptData?[4,r._meshOptData]:[3,2];case 1:case 3:return[2,u.sent()];case 2:return o=U.Get("".concat(e,"/buffer"),this._loader.gltf.buffers,s.buffer),r._meshOptData=this._loader.loadBufferAsync("/buffers/".concat(o.index),o,s.byteOffset||0,s.byteLength).then(function(e){return a(l,void 0,void 0,function(){return i(this,function(n){switch(n.label){case 0:return[4,t.MeshoptCompression.Default.decodeGltfBufferAsync(e,s.count,s.byteStride,s.mode,s.filter)];case 1:return[2,n.sent()]}})})}),[4,r._meshOptData]}})})})},e}();K(Z),H(Z,!0,function(e){return new $(e)});var ee="EXT_texture_webp",te=function(){function e(e){this.name=ee,this._loader=e,this.enabled=e.isExtensionUsed(ee)}return e.prototype.dispose=function(){this._loader=null},e.prototype._loadTextureAsync=function(e,t,n){var r=this;return q.LoadExtensionAsync(e,t,this.name,function(o,s){return a(r,void 0,void 0,function(){var r,a;return i(this,function(i){switch(i.label){case 0:return r=null==t.sampler?q.DefaultSampler:U.Get("".concat(e,"/sampler"),this._loader.gltf.samplers,t.sampler),a=U.Get("".concat(o,"/source"),this._loader.gltf.images,s.source),[4,this._loader._createTextureAsync(e,r,a,function(e){n(e)},void 0,!t._textureInfo.nonColorData)];case 1:return[2,i.sent()]}})})})},e}();K(ee),H(ee,!0,function(e){return new te(e)});var ne="EXT_texture_avif",re=function(){function e(e){this.name=ne,this._loader=e,this.enabled=e.isExtensionUsed(ne)}return e.prototype.dispose=function(){this._loader=null},e.prototype._loadTextureAsync=function(e,t,n){var r=this;return q.LoadExtensionAsync(e,t,this.name,function(o,s){return a(r,void 0,void 0,function(){var r,a;return i(this,function(i){switch(i.label){case 0:return r=null==t.sampler?q.DefaultSampler:U.Get("".concat(e,"/sampler"),this._loader.gltf.samplers,t.sampler),a=U.Get("".concat(o,"/source"),this._loader.gltf.images,s.source),[4,this._loader._createTextureAsync(e,r,a,function(e){n(e)},void 0,!t._textureInfo.nonColorData)];case 1:return[2,i.sent()]}})})})},e}();K(ne),H(ne,!0,function(e){return new re(e)});var oe="EXT_lights_ies",ae=function(){function e(e){this.name=oe,this._loader=e,this.enabled=this._loader.isExtensionUsed(oe)}return e.prototype.dispose=function(){this._loader=null,delete this._lights},e.prototype.onLoading=function(){var e=this._loader.gltf.extensions;if(e&&e[this.name]){var t=e[this.name];this._lights=t.lights,U.Assign(this._lights)}},e.prototype.loadNodeAsync=function(e,n,r){var o=this;return q.LoadExtensionAsync(e,n,this.name,function(s,l){return a(o,void 0,void 0,function(){var o,a,u,c,f,h=this;return i(this,function(i){switch(i.label){case 0:return this._loader._allMaterialsDirtyRequired=!0,[4,this._loader.loadNodeAsync(e,n,function(e){var n=(a=U.Get(s,h._lights,l.light)).name||e.name;h._loader.babylonScene._blockEntityCollection=!!h._loader._assetContainer,(o=new t.SpotLight(n,t.Vector3.Zero(),t.Vector3.Backward(),0,1,h._loader.babylonScene)).angle=Math.PI/2,o.innerAngle=0,o._parentContainer=h._loader._assetContainer,h._loader.babylonScene._blockEntityCollection=!1,a._babylonLight=o,o.falloffType=t.Light.FALLOFF_GLTF,o.diffuse=l.color?t.Color3.FromArray(l.color):t.Color3.White(),o.intensity=l.multiplier||1,o.range=Number.MAX_VALUE,o.parent=e,h._loader._babylonLights.push(o),q.AddPointerMetadata(o,s),r(e)})];case 1:return u=i.sent(),a.uri?[4,this._loader.loadUriAsync(e,a,a.uri)]:[3,3];case 2:return c=i.sent(),[3,5];case 3:return f=U.Get("".concat(e,"/bufferView"),this._loader.gltf.bufferViews,a.bufferView),[4,this._loader.loadBufferViewAsync("/bufferViews/".concat(f.index),f)];case 4:c=i.sent(),i.label=5;case 5:return o.iesProfileTexture=new t.Texture(name+"_iesProfile",this._loader.babylonScene,!0,!1,void 0,null,null,c,!0,void 0,void 0,void 0,void 0,".ies"),[2,u]}})})})},e}();K(oe),H(oe,!0,function(e){return new ae(e)});var ie="KHR_draco_mesh_compression",se=function(){function e(e){this.name=ie,this.useNormalizedFlagFromAccessor=!0,this._loader=e,this.enabled=t.DracoDecoder.DefaultAvailable&&this._loader.isExtensionUsed(ie)}return e.prototype.dispose=function(){delete this.dracoDecoder,this._loader=null},e.prototype._loadVertexDataAsync=function(e,n,r){var o=this;return q.LoadExtensionAsync(e,n,this.name,function(s,l){return a(o,void 0,void 0,function(){var o,u,c,f,h=this;return i(this,function(p){switch(p.label){case 0:if(null!=n.mode&&4!==n.mode&&5!==n.mode)throw new Error("".concat(e,": Unsupported mode ").concat(n.mode));return o={},u={},(c=function(e,t){var a=l.attributes[e];if(null!=a&&(r._delayInfo=r._delayInfo||[],-1===r._delayInfo.indexOf(t)&&r._delayInfo.push(t),o[t]=a,h.useNormalizedFlagFromAccessor)){var i=U.TryGet(h._loader.gltf.accessors,n.attributes[e]);i&&(u[t]=i.normalized||!1)}})("POSITION",t.VertexBuffer.PositionKind),c("NORMAL",t.VertexBuffer.NormalKind),c("TANGENT",t.VertexBuffer.TangentKind),c("TEXCOORD_0",t.VertexBuffer.UVKind),c("TEXCOORD_1",t.VertexBuffer.UV2Kind),c("TEXCOORD_2",t.VertexBuffer.UV3Kind),c("TEXCOORD_3",t.VertexBuffer.UV4Kind),c("TEXCOORD_4",t.VertexBuffer.UV5Kind),c("TEXCOORD_5",t.VertexBuffer.UV6Kind),c("JOINTS_0",t.VertexBuffer.MatricesIndicesKind),c("WEIGHTS_0",t.VertexBuffer.MatricesWeightsKind),c("COLOR_0",t.VertexBuffer.ColorKind),(f=U.Get(s,this._loader.gltf.bufferViews,l.bufferView))._dracoBabylonGeometry||(f._dracoBabylonGeometry=this._loader.loadBufferViewAsync("/bufferViews/".concat(f.index),f).then(function(s){return a(h,void 0,void 0,function(){var a,l,c;return i(this,function(i){switch(i.label){case 0:return a=this.dracoDecoder||t.DracoDecoder.Default,l=U.TryGet(this._loader.gltf.accessors,n.attributes.POSITION),c=this._loader.parent.alwaysComputeBoundingBox||r.skeleton||!l?null:z(l),[4,a._decodeMeshToGeometryForGltfAsync(r.name,this._loader.babylonScene,s,o,u,c).catch(function(t){throw new Error("".concat(e,": ").concat(t.message))})];case 1:return[2,i.sent()]}})})})),[4,f._dracoBabylonGeometry];case 1:return[2,p.sent()]}})})})},e}();K(ie),H(ie,!0,function(e){return new se(e)});var le="KHR_lights_punctual",ue=function(){function e(e){this.name=le,this._loader=e,this.enabled=this._loader.isExtensionUsed(le)}return e.prototype.dispose=function(){this._loader=null,delete this._lights},e.prototype.onLoading=function(){var e=this._loader.gltf.extensions;if(e&&e[this.name]){var t=e[this.name];this._lights=t.lights,U.Assign(this._lights)}},e.prototype.loadNodeAsync=function(e,n,r){var o=this;return q.LoadExtensionAsync(e,n,this.name,function(s,l){return a(o,void 0,void 0,function(){var o=this;return i(this,function(a){switch(a.label){case 0:return this._loader._allMaterialsDirtyRequired=!0,[4,this._loader.loadNodeAsync(e,n,function(e){var n,a=U.Get(s,o._lights,l.light),i=a.name||e.name;switch(o._loader.babylonScene._blockEntityCollection=!!o._loader._assetContainer,a.type){case"directional":var u=new t.DirectionalLight(i,t.Vector3.Backward(),o._loader.babylonScene);u.position.setAll(0),n=u;break;case"point":n=new t.PointLight(i,t.Vector3.Zero(),o._loader.babylonScene);break;case"spot":var c=new t.SpotLight(i,t.Vector3.Zero(),t.Vector3.Backward(),0,1,o._loader.babylonScene);c.angle=2*(a.spot&&a.spot.outerConeAngle||Math.PI/4),c.innerAngle=2*(a.spot&&a.spot.innerConeAngle||0),n=c;break;default:throw o._loader.babylonScene._blockEntityCollection=!1,new Error("".concat(s,": Invalid light type (").concat(a.type,")"))}n._parentContainer=o._loader._assetContainer,o._loader.babylonScene._blockEntityCollection=!1,a._babylonLight=n,n.falloffType=t.Light.FALLOFF_GLTF,n.diffuse=a.color?t.Color3.FromArray(a.color):t.Color3.White(),n.intensity=null==a.intensity?1:a.intensity,n.range=null==a.range?Number.MAX_VALUE:a.range,n.parent=e,o._loader._babylonLights.push(n),q.AddPointerMetadata(n,s),r(e)})];case 1:return[2,a.sent()]}})})})},e}();K(le),H(le,!0,function(e){return new ue(e)});var ce="EXT_lights_area",fe=function(){function e(e){this.name=ce,this._loader=e,this.enabled=this._loader.isExtensionUsed(ce)}return e.prototype.dispose=function(){this._loader=null,delete this._lights},e.prototype.onLoading=function(){var e=this._loader.gltf.extensions;if(e&&e[this.name]){var t=e[this.name];this._lights=t.lights,U.Assign(this._lights)}},e.prototype.loadNodeAsync=function(e,n,r){var o=this;return q.LoadExtensionAsync(e,n,this.name,function(s,l){return a(o,void 0,void 0,function(){var o=this;return i(this,function(a){switch(a.label){case 0:return this._loader._allMaterialsDirtyRequired=!0,[4,this._loader.loadNodeAsync(e,n,function(e){var n,a,i=U.Get(s,o._lights,l.light),u=i.name||e.name;o._loader.babylonScene._blockEntityCollection=!!o._loader._assetContainer;var c=void 0!==i.size?i.size:1;switch(i.type){case"rect":var f=void 0!==(null===(n=i.rect)||void 0===n?void 0:n.aspect)?i.rect.aspect*c:c,h=c;a=new t.RectAreaLight(u,t.Vector3.Zero(),f,h,o._loader.babylonScene);break;case"disk":var p=Math.sqrt(c*c*.25*Math.PI);a=new t.RectAreaLight(u,t.Vector3.Zero(),p,p,o._loader.babylonScene);break;default:throw o._loader.babylonScene._blockEntityCollection=!1,new Error("".concat(s,": Invalid area light type (").concat(i.type,")"))}a._parentContainer=o._loader._assetContainer,o._loader.babylonScene._blockEntityCollection=!1,i._babylonLight=a,a.falloffType=t.Light.FALLOFF_GLTF,a.diffuse=i.color?t.Color3.FromArray(i.color):t.Color3.White(),a.intensity=null==i.intensity?1:i.intensity;var d=new t.TransformNode("".concat(u,"_orientation"),o._loader.babylonScene);d.rotationQuaternion=t.Quaternion.RotationAxis(t.Vector3.Up(),Math.PI),d.parent=e,a.parent=d,o._loader._babylonLights.push(a),q.AddPointerMetadata(a,s),r(e)})];case 1:return[2,a.sent()]}})})})},e}();K(ce),H(ce,!0,function(e){return new fe(e)});var he="KHR_materials_pbrSpecularGlossiness",pe=function(){function e(e){this.name=he,this.order=200,this._loader=e,this.enabled=this._loader.isExtensionUsed(he)}return e.prototype.dispose=function(){this._loader=null},e.prototype.loadMaterialPropertiesAsync=function(e,t,n){var r=this;return q.LoadExtensionAsync(e,t,this.name,function(o,s){return a(r,void 0,void 0,function(){var r;return i(this,function(a){switch(a.label){case 0:return(r=new Array).push(this._loader.loadMaterialBasePropertiesAsync(e,t,n)),r.push(this._loadSpecularGlossinessPropertiesAsync(o,s,n)),this._loader.loadMaterialAlphaProperties(e,t,n),[4,Promise.all(r).then(function(){})];case 1:return[2,a.sent()]}})})})},e.prototype._loadSpecularGlossinessPropertiesAsync=function(e,n,r){var o=this._loader._getOrCreateMaterialAdapter(r),a=new Array;return o.configureSpecularGlossiness(),n.diffuseFactor?(o.baseColor=t.Color3.FromArray(n.diffuseFactor),r.alpha=n.diffuseFactor[3]):o.baseColor=t.Color3.White(),o.specularColor=n.specularFactor?t.Color3.FromArray(n.specularFactor):t.Color3.White(),o.glossiness=null==n.glossinessFactor?1:n.glossinessFactor,n.diffuseTexture&&a.push(this._loader.loadTextureInfoAsync("".concat(e,"/diffuseTexture"),n.diffuseTexture,function(e){e.name="".concat(r.name," (Diffuse)"),o.baseColorTexture=e})),n.specularGlossinessTexture&&a.push(this._loader.loadTextureInfoAsync("".concat(e,"/specularGlossinessTexture"),n.specularGlossinessTexture,function(e){e.name="".concat(r.name," (Specular Glossiness)"),o.specularColorTexture=e})),Promise.all(a).then(function(){})},e}();K(he),H(he,!0,function(e){return new pe(e)});var de="KHR_materials_unlit",me=function(){function e(e){this.name=de,this.order=210,this._loader=e,this.enabled=this._loader.isExtensionUsed(de)}return e.prototype.dispose=function(){this._loader=null},e.prototype.loadMaterialPropertiesAsync=function(e,t,n){var r=this;return q.LoadExtensionAsync(e,t,this.name,function(){return a(r,void 0,void 0,function(){return i(this,function(r){switch(r.label){case 0:return[4,this._loadUnlitPropertiesAsync(e,t,n)];case 1:return[2,r.sent()]}})})})},e.prototype._loadUnlitPropertiesAsync=function(e,n,r){var o=this._loader._getOrCreateMaterialAdapter(r),a=new Array,i=n.pbrMetallicRoughness;return i&&(i.baseColorFactor&&(o.baseColor=t.Color3.FromArray(i.baseColorFactor),o.geometryOpacity=i.baseColorFactor[3]),i.baseColorTexture&&a.push(this._loader.loadTextureInfoAsync("".concat(e,"/baseColorTexture"),i.baseColorTexture,function(e){e.name="".concat(r.name," (Base Color)"),o.baseColorTexture=e}))),o.isUnlit=!0,n.doubleSided&&(o.backFaceCulling=!1,o.twoSidedLighting=!0),this._loader.loadMaterialAlphaProperties(e,n,r),Promise.all(a).then(function(){})},e}();K(de),H(de,!0,function(e){return new me(e)});var _e="KHR_materials_clearcoat",be=function(){function e(e){this.name=_e,this.order=190,this._loader=e,this.enabled=this._loader.isExtensionUsed(_e)}return e.prototype.dispose=function(){this._loader=null},e.prototype.loadMaterialPropertiesAsync=function(e,t,n){var r=this;return q.LoadExtensionAsync(e,t,this.name,function(o,s){return a(r,void 0,void 0,function(){var r;return i(this,function(a){switch(a.label){case 0:return(r=new Array).push(this._loader.loadMaterialPropertiesAsync(e,t,n)),r.push(this._loadClearCoatPropertiesAsync(o,s,n)),[4,Promise.all(r)];case 1:return a.sent(),[2]}})})})},e.prototype._loadClearCoatPropertiesAsync=function(e,t,n){var r=this._loader._getOrCreateMaterialAdapter(n),o=new Array;return r.configureCoat(),r.coatWeight=void 0!==t.clearcoatFactor?t.clearcoatFactor:0,r.coatRoughness=void 0!==t.clearcoatRoughnessFactor?t.clearcoatRoughnessFactor:0,t.clearcoatTexture&&o.push(this._loader.loadTextureInfoAsync("".concat(e,"/clearcoatTexture"),t.clearcoatTexture,function(e){e.name="".concat(n.name," (ClearCoat)"),r.coatWeightTexture=e})),t.clearcoatRoughnessTexture&&(t.clearcoatRoughnessTexture.nonColorData=!0,o.push(this._loader.loadTextureInfoAsync("".concat(e,"/clearcoatRoughnessTexture"),t.clearcoatRoughnessTexture,function(e){e.name="".concat(n.name," (ClearCoat Roughness)"),r.coatRoughnessTexture=e}))),t.clearcoatNormalTexture&&(t.clearcoatNormalTexture.nonColorData=!0,o.push(this._loader.loadTextureInfoAsync("".concat(e,"/clearcoatNormalTexture"),t.clearcoatNormalTexture,function(e){var o;e.name="".concat(n.name," (ClearCoat Normal)"),r.geometryCoatNormalTexture=e,null!=(null===(o=t.clearcoatNormalTexture)||void 0===o?void 0:o.scale)&&(r.geometryCoatNormalTextureScale=t.clearcoatNormalTexture.scale)})),r.setNormalMapInversions(!n.getScene().useRightHandedSystem,n.getScene().useRightHandedSystem)),Promise.all(o).then(function(){})},e}();K(_e),H(_e,!0,function(e){return new be(e)});var ge="KHR_materials_coat",ye=function(){function e(e){this.name=ge,this.order=191,this.useOpenPBR=!1,this._loader=e,this.enabled=this._loader.isExtensionUsed(ge)}return e.prototype.dispose=function(){this._loader=null},e.prototype.loadMaterialPropertiesAsync=function(e,t,n){var r=this;return q.LoadExtensionAsync(e,t,this.name,function(o,s){return a(r,void 0,void 0,function(){var r;return i(this,function(a){switch(a.label){case 0:return(r=new Array).push(this._loader.loadMaterialPropertiesAsync(e,t,n)),t.extensions&&t.extensions.KHR_materials_openpbr&&(this.useOpenPBR=!0),r.push(this._loadCoatPropertiesAsync(o,s,n)),[4,Promise.all(r)];case 1:return a.sent(),[2]}})})})},e.prototype._loadCoatPropertiesAsync=function(e,n,r){var o,a,i=this._loader._getOrCreateMaterialAdapter(r),s=new Array;i.configureCoat(),i.coatWeight=void 0!==n.coatFactor?n.coatFactor:0,i.coatRoughness=void 0!==n.coatRoughnessFactor?n.coatRoughnessFactor:0,n.coatTexture&&s.push(this._loader.loadTextureInfoAsync("".concat(e,"/coatTexture"),n.coatTexture,function(e){e.name="".concat(r.name," (Coat)"),i.coatWeightTexture=e})),n.coatRoughnessTexture&&(n.coatRoughnessTexture.nonColorData=!0,s.push(this._loader.loadTextureInfoAsync("".concat(e,"/coatRoughnessTexture"),n.coatRoughnessTexture,function(e){e.name="".concat(r.name," (Coat Roughness)"),i.coatRoughnessTexture=e}))),n.coatNormalTexture&&(n.coatNormalTexture.nonColorData=!0,s.push(this._loader.loadTextureInfoAsync("".concat(e,"/coatNormalTexture"),n.coatNormalTexture,function(e){var t;e.name="".concat(r.name," (Coat Normal)"),i.geometryCoatNormalTexture=e,null!=(null===(t=n.coatNormalTexture)||void 0===t?void 0:t.scale)&&(i.geometryCoatNormalTextureScale=n.coatNormalTexture.scale)})),i.setNormalMapInversions(!r.getScene().useRightHandedSystem,r.getScene().useRightHandedSystem)),i.coatDarkening=void 0!==n.coatDarkeningFactor?n.coatDarkeningFactor:1,i.coatIor=void 0!==n.coatIor?n.coatIor:1.5;var l=t.Color3.White();void 0!==n.coatColorFactor&&l.fromArray(n.coatColorFactor),i.coatColor=l,n.coatColorTexture&&s.push(this._loader.loadTextureInfoAsync("".concat(e,"/coatColorTexture"),n.coatColorTexture,function(e){e.name="".concat(r.name," (Coat Color)"),i.coatColorTexture=e}));var u=null!==(o=n.coatAnisotropyStrength)&&void 0!==o?o:0,c=null!==(a=n.coatAnisotropyRotation)&&void 0!==a?a:0;return i.coatRoughnessAnisotropy=u,i.geometryCoatTangentAngle=c,this.useOpenPBR||i.configureGltfStyleAnisotropy(!0),n.coatAnisotropyTexture&&(n.coatAnisotropyTexture.nonColorData=!0,s.push(this._loader.loadTextureInfoAsync("".concat(e,"/coatAnisotropyTexture"),n.coatAnisotropyTexture,function(e){e.name="".concat(r.name," (Coat Anisotropy)"),i.geometryCoatTangentTexture=e}))),Promise.all(s).then(function(){})},e}();K(ge),H(ge,!0,function(e){return new ye(e)});var ve="KHR_materials_iridescence",Te=function(){function e(e){this.name=ve,this.order=195,this._loader=e,this.enabled=this._loader.isExtensionUsed(ve)}return e.prototype.dispose=function(){this._loader=null},e.prototype.loadMaterialPropertiesAsync=function(e,t,n){var r=this;return q.LoadExtensionAsync(e,t,this.name,function(o,s){return a(r,void 0,void 0,function(){var r;return i(this,function(a){switch(a.label){case 0:return(r=new Array).push(this._loader.loadMaterialPropertiesAsync(e,t,n)),r.push(this._loadIridescencePropertiesAsync(o,s,n)),[4,Promise.all(r).then(function(){})];case 1:return[2,a.sent()]}})})})},e.prototype._loadIridescencePropertiesAsync=function(e,t,n){var r,o,a,i,s,l=this._loader._getOrCreateMaterialAdapter(n),u=new Array;return l.thinFilmWeight=null!==(r=t.iridescenceFactor)&&void 0!==r?r:0,l.thinFilmIor=null!==(a=null!==(o=t.iridescenceIor)&&void 0!==o?o:t.iridescenceIOR)&&void 0!==a?a:1.3,l.thinFilmThicknessMinimum=null!==(i=t.iridescenceThicknessMinimum)&&void 0!==i?i:100,l.thinFilmThicknessMaximum=null!==(s=t.iridescenceThicknessMaximum)&&void 0!==s?s:400,t.iridescenceTexture&&u.push(this._loader.loadTextureInfoAsync("".concat(e,"/iridescenceTexture"),t.iridescenceTexture,function(e){e.name="".concat(n.name," (Iridescence)"),l.thinFilmWeightTexture=e})),t.iridescenceThicknessTexture&&u.push(this._loader.loadTextureInfoAsync("".concat(e,"/iridescenceThicknessTexture"),t.iridescenceThicknessTexture,function(e){e.name="".concat(n.name," (Iridescence Thickness)"),l.thinFilmThicknessTexture=e})),Promise.all(u).then(function(){})},e}();K(ve),H(ve,!0,function(e){return new Te(e)});var xe="KHR_materials_anisotropy",Ae=function(){function e(e){this.name=xe,this.order=195,this._loader=e,this.enabled=this._loader.isExtensionUsed(xe)}return e.prototype.dispose=function(){this._loader=null},e.prototype.loadMaterialPropertiesAsync=function(e,t,n){var r=this;return q.LoadExtensionAsync(e,t,this.name,function(o,s){return a(r,void 0,void 0,function(){var r;return i(this,function(a){switch(a.label){case 0:return(r=new Array).push(this._loader.loadMaterialPropertiesAsync(e,t,n)),r.push(this._loadAnisotropyPropertiesAsync(o,s,n)),[4,Promise.all(r)];case 1:return a.sent(),[2]}})})})},e.prototype._loadAnisotropyPropertiesAsync=function(e,t,n){return a(this,void 0,void 0,function(){var r,o,a,s,l,u,c,f;return i(this,function(i){switch(i.label){case 0:return r=this._loader._getOrCreateMaterialAdapter(n),o=new Array,a=null!==(u=t.anisotropyStrength)&&void 0!==u?u:0,s=null!==(c=t.anisotropyRotation)&&void 0!==c?c:0,r.specularRoughnessAnisotropy=a,r.geometryTangentAngle=s,(l=null!==(f=t.extensions)&&void 0!==f?f:{}).EXT_materials_anisotropy_openpbr&&l.EXT_materials_anisotropy_openpbr.openPbrAnisotropyEnabled||r.configureGltfStyleAnisotropy(!0),t.anisotropyTexture&&(t.anisotropyTexture.nonColorData=!0,o.push(this._loader.loadTextureInfoAsync("".concat(e,"/anisotropyTexture"),t.anisotropyTexture,function(e){e.name="".concat(n.name," (Anisotropy Intensity)"),r.geometryTangentTexture=e}))),[4,Promise.all(o)];case 1:return i.sent(),[2]}})})},e}();K(xe),H(xe,!0,function(e){return new Ae(e)});var Ce="KHR_materials_emissive_strength",we=function(){function e(e){this.name=Ce,this.order=170,this._loader=e,this.enabled=this._loader.isExtensionUsed(Ce)}return e.prototype.dispose=function(){this._loader=null},e.prototype.loadMaterialPropertiesAsync=function(e,t,n){var r=this;return q.LoadExtensionAsync(e,t,this.name,function(o,s){return a(r,void 0,void 0,function(){return i(this,function(r){switch(r.label){case 0:return[4,this._loader.loadMaterialPropertiesAsync(e,t,n)];case 1:return r.sent(),this._loadEmissiveProperties(o,s,n),[4,Promise.resolve()];case 2:return[2,r.sent()]}})})})},e.prototype._loadEmissiveProperties=function(e,t,n){void 0!==t.emissiveStrength&&(this._loader._getOrCreateMaterialAdapter(n).emissionLuminance=t.emissiveStrength)},e}();K(Ce),H(Ce,!0,function(e){return new we(e)});var Oe="KHR_materials_sheen",Me=function(){function e(e){this.name=Oe,this.order=190,this._loader=e,this.enabled=this._loader.isExtensionUsed(Oe)}return e.prototype.dispose=function(){this._loader=null},e.prototype.loadMaterialPropertiesAsync=function(e,t,n){var r=this;return q.LoadExtensionAsync(e,t,this.name,function(o,s){return a(r,void 0,void 0,function(){var r;return i(this,function(a){switch(a.label){case 0:return(r=new Array).push(this._loader.loadMaterialPropertiesAsync(e,t,n)),r.push(this._loadSheenPropertiesAsync(o,s,n)),[4,Promise.all(r).then(function(){})];case 1:return[2,a.sent()]}})})})},e.prototype._loadSheenPropertiesAsync=function(e,n,r){var o=this._loader._getOrCreateMaterialAdapter(r),a=new Array;o.configureFuzz();var i=void 0!==n.sheenColorFactor?t.Color3.FromArray(n.sheenColorFactor):t.Color3.Black(),s=void 0!==n.sheenRoughnessFactor?n.sheenRoughnessFactor:0;return o.fuzzWeight=1,o.fuzzColor=i,o.fuzzRoughness=s,n.sheenColorTexture&&a.push(this._loader.loadTextureInfoAsync("".concat(e,"/sheenColorTexture"),n.sheenColorTexture,function(e){e.name="".concat(r.name," (Sheen Color)"),o.fuzzColorTexture=e})),n.sheenRoughnessTexture&&(n.sheenRoughnessTexture.nonColorData=!0,a.push(this._loader.loadTextureInfoAsync("".concat(e,"/sheenRoughnessTexture"),n.sheenRoughnessTexture,function(e){e.name="".concat(r.name," (Sheen Roughness)"),o.fuzzRoughnessTexture=e}))),Promise.all(a).then(function(){})},e}();K(Oe),H(Oe,!0,function(e){return new Me(e)});var Re="KHR_materials_fuzz",Pe=function(){function e(e){this.name=Re,this.order=190,this._loader=e,this.enabled=this._loader.isExtensionUsed(Re)}return e.prototype.dispose=function(){this._loader=null},e.prototype.loadMaterialPropertiesAsync=function(e,t,n){var r=this;return q.LoadExtensionAsync(e,t,this.name,function(o,s){return a(r,void 0,void 0,function(){var r;return i(this,function(a){switch(a.label){case 0:return(r=new Array).push(this._loader.loadMaterialPropertiesAsync(e,t,n)),r.push(this._loadFuzzPropertiesAsync(o,s,n)),[4,Promise.all(r).then(function(){})];case 1:return[2,a.sent()]}})})})},e.prototype._loadFuzzPropertiesAsync=function(e,n,r){var o=this._loader._getOrCreateMaterialAdapter(r),a=new Array;return o.configureFuzz(),o.fuzzWeight=void 0!==n.fuzzFactor?n.fuzzFactor:0,o.fuzzColor=void 0!==n.fuzzColorFactor?t.Color3.FromArray(n.fuzzColorFactor):t.Color3.White(),o.fuzzRoughness=void 0!==n.fuzzRoughnessFactor?n.fuzzRoughnessFactor:.5,n.fuzzTexture&&a.push(this._loader.loadTextureInfoAsync("".concat(e,"/fuzzTexture"),n.fuzzTexture,function(e){e.name="".concat(r.name," (Fuzz)"),o.fuzzWeightTexture=e})),n.fuzzColorTexture&&a.push(this._loader.loadTextureInfoAsync("".concat(e,"/fuzzColorTexture"),n.fuzzColorTexture,function(e){e.name="".concat(r.name," (Fuzz Color)"),o.fuzzColorTexture=e})),n.fuzzRoughnessTexture&&(n.fuzzRoughnessTexture.nonColorData=!0,a.push(this._loader.loadTextureInfoAsync("".concat(e,"/fuzzRoughnessTexture"),n.fuzzRoughnessTexture,function(e){e.name="".concat(r.name," (Fuzz Roughness)"),o.fuzzRoughnessTexture=e}))),Promise.all(a).then(function(){})},e}();K(Re),H(Re,!0,function(e){return new Pe(e)});var Le="KHR_materials_specular",Fe=function(){function e(e){this.name=Le,this.order=190,this._loader=e,this.enabled=this._loader.isExtensionUsed(Le)}return e.prototype.dispose=function(){this._loader=null},e.prototype.loadMaterialPropertiesAsync=function(e,t,n){var r=this;return q.LoadExtensionAsync(e,t,this.name,function(o,s){return a(r,void 0,void 0,function(){var r,a;return i(this,function(i){switch(i.label){case 0:return(r=new Array).push(this._loader.loadMaterialPropertiesAsync(e,t,n)),r.push(this._loadSpecularPropertiesAsync(o,s,n)),a=this._loader._getOrCreateMaterialAdapter(n),s.extensions&&s.extensions.EXT_materials_specular_edge_color&&s.extensions.EXT_materials_specular_edge_color.specularEdgeColorEnabled&&a.enableSpecularEdgeColor(!0),[4,Promise.all(r).then(function(){})];case 1:return[2,i.sent()]}})})})},e.prototype._loadSpecularPropertiesAsync=function(e,n,r){var o,a=this._loader._getOrCreateMaterialAdapter(r),i=new Array;return a.specularWeight=null!==(o=n.specularFactor)&&void 0!==o?o:1,a.specularColor=void 0!==n.specularColorFactor?t.Color3.FromArray(n.specularColorFactor):new t.Color3(1,1,1),n.specularTexture&&(n.specularTexture.nonColorData=!0,i.push(this._loader.loadTextureInfoAsync("".concat(e,"/specularTexture"),n.specularTexture,function(e){e.name="".concat(r.name," (Specular)"),a.specularWeightTexture=e}))),n.specularColorTexture&&i.push(this._loader.loadTextureInfoAsync("".concat(e,"/specularColorTexture"),n.specularColorTexture,function(e){e.name="".concat(r.name," (Specular Color)"),a.specularColorTexture=e})),Promise.all(i).then(function(){})},e}();K(Le),H(Le,!0,function(e){return new Fe(e)});var Ee="KHR_materials_ior",Se=function(){function e(e){this.name=Ee,this.order=180,this._loader=e,this.enabled=this._loader.isExtensionUsed(Ee)}return e.prototype.dispose=function(){this._loader=null},e.prototype.loadMaterialPropertiesAsync=function(e,t,n){var r=this;return q.LoadExtensionAsync(e,t,this.name,function(o,s){return a(r,void 0,void 0,function(){var r;return i(this,function(a){switch(a.label){case 0:return(r=new Array).push(this._loader.loadMaterialPropertiesAsync(e,t,n)),r.push(this._loadIorPropertiesAsync(o,s,n)),[4,Promise.all(r).then(function(){})];case 1:return[2,a.sent()]}})})})},e.prototype._loadIorPropertiesAsync=function(t,n,r){var o=this._loader._getOrCreateMaterialAdapter(r),a=void 0!==n.ior?n.ior:e._DEFAULT_IOR;return o.specularIor=a,Promise.resolve()},e._DEFAULT_IOR=1.5,e}();K(Ee),H(Ee,!0,function(e){return new Se(e)});var ke="KHR_materials_variants",Ie=function(){function e(e){this.name=ke,this._loader=e,this.enabled=this._loader.isExtensionUsed(ke)&&!this._loader.parent.skipMaterials}return e.prototype.dispose=function(){this._loader=null},e.GetAvailableVariants=function(e){var t=this._GetExtensionMetadata(e);return t?Object.keys(t.variants):[]},e.prototype.getAvailableVariants=function(t){return e.GetAvailableVariants(t)},e.SelectVariant=function(e,t){var n=this._GetExtensionMetadata(e);if(!n)throw new Error("Cannot select variant on a glTF mesh that does not have the ".concat(ke," extension"));var r=function(e){var t=n.variants[e];if(t)for(var r=0,o=t;r<o.length;r++){var a=o[r];a.mesh.material=a.material}};if(t instanceof Array)for(var o=0,a=t;o<a.length;o++)r(a[o]);else r(t);n.lastSelected=t},e.prototype.selectVariant=function(t,n){e.SelectVariant(t,n)},e.Reset=function(e){var t=this._GetExtensionMetadata(e);if(!t)throw new Error("Cannot reset on a glTF mesh that does not have the ".concat(ke," extension"));for(var n=0,r=t.original;n<r.length;n++){var o=r[n];o.mesh.material=o.material}t.lastSelected=null},e.prototype.reset=function(t){e.Reset(t)},e.GetLastSelectedVariant=function(e){var t=this._GetExtensionMetadata(e);if(!t)throw new Error("Cannot get the last selected variant on a glTF mesh that does not have the ".concat(ke," extension"));return t.lastSelected},e.prototype.getLastSelectedVariant=function(t){return e.GetLastSelectedVariant(t)},e._GetExtensionMetadata=function(e){var t,n;return(null===(n=null===(t=null==e?void 0:e._internalMetadata)||void 0===t?void 0:t.gltf)||void 0===n?void 0:n[ke])||null},e.prototype.onLoading=function(){var e=this._loader.gltf.extensions;if(e&&e[this.name]){var t=e[this.name];this._variants=t.variants}},e.prototype.onReady=function(){var t,n=this._loader.rootBabylonMesh;if(n){var r=this._loader.parent.extensionOptions[ke];(null==r?void 0:r.defaultVariant)&&e.SelectVariant(n,r.defaultVariant),null===(t=null==r?void 0:r.onLoaded)||void 0===t||t.call(r,{get variants(){return e.GetAvailableVariants(n)},get selectedVariant(){var t=e.GetLastSelectedVariant(n);return t?Array.isArray(t)?t[0]:t:e.GetAvailableVariants(n)[0]},set selectedVariant(t){e.SelectVariant(n,t)}})}},e.prototype._loadMeshPrimitiveAsync=function(n,r,o,s,l,u){var c=this;return q.LoadExtensionAsync(n,l,this.name,function(f,h){return a(c,void 0,void 0,function(){var a,c=this;return i(this,function(i){switch(i.label){case 0:return(a=new Array).push(this._loader._loadMeshPrimitiveAsync(n,r,o,s,l,function(r){if(u(r),r instanceof t.Mesh){var o=q._GetDrawMode(n,l.mode),i=c._loader.rootBabylonMesh,s=i?i._internalMetadata=i._internalMetadata||{}:{},p=s.gltf=s.gltf||{},d=p[ke]=p[ke]||{lastSelected:null,original:[],variants:{}};d.original.push({mesh:r,material:r.material});for(var m=function(t){var n=h.mappings[t],s=U.Get("".concat(f,"/mappings/").concat(t,"/material"),c._loader.gltf.materials,n.material);a.push(c._loader._loadMaterialAsync("#/materials/".concat(n.material),s,r,o,function(t){for(var o=function(o){var a=n.variants[o],s=U.Get("/extensions/".concat(ke,"/variants/").concat(a),c._variants,a);d.variants[s.name]=d.variants[s.name]||[],d.variants[s.name].push({mesh:r,material:t}),r.onClonedObservable.add(function(t){var n,o=t,a=o;do{if(!(a=a.parent))return;n=e._GetExtensionMetadata(a)}while(null===n);if(i&&n===e._GetExtensionMetadata(i)){for(var l in a._internalMetadata={},i._internalMetadata)a._internalMetadata[l]=i._internalMetadata[l];for(var l in a._internalMetadata.gltf=[],i._internalMetadata.gltf)a._internalMetadata.gltf[l]=i._internalMetadata.gltf[l];a._internalMetadata.gltf[ke]={lastSelected:null,original:[],variants:{}};for(var u=0,c=n.original;u<c.length;u++){var f=c[u];a._internalMetadata.gltf[ke].original.push({mesh:f.mesh,material:f.material})}for(var l in n.variants)if(Object.prototype.hasOwnProperty.call(n.variants,l)){a._internalMetadata.gltf[ke].variants[l]=[];for(var h=0,p=n.variants[l];h<p.length;h++){var d=p[h];a._internalMetadata.gltf[ke].variants[l].push({mesh:d.mesh,material:d.material})}}n=a._internalMetadata.gltf[ke]}for(var m=0,_=n.original;m<_.length;m++)(y=_[m]).mesh===r&&(y.mesh=o);for(var b=0,g=n.variants[s.name];b<g.length;b++){var y;(y=g[b]).mesh===r&&(y.mesh=o)}})},a=0;a<n.variants.length;++a)o(a)}))},_=0;_<h.mappings.length;++_)m(_)}})),[4,Promise.all(a).then(function(e){return e[0]})];case 1:return[2,i.sent()]}})})})},e}();K(ke),H(ke,!0,function(e){return new Ie(e)});var Be=function(){function e(n,r,a){var i=this;this._opaqueRenderTarget=null,this._opaqueMeshesCache=[],this._transparentMeshesCache=[],this._materialObservers={},this._translucentMaterialIndices=new Map,this._opaqueOnlySubMeshes=new Map,this._savedSubMeshes=new Map,this._options=o(o({},e._GetDefaultOptions()),n),this._scene=r,this._scene._transmissionHelper=this,this._loader=a,this.onErrorObservable=new t.Observable,this._scene.onDisposeObservable.addOnce(function(){i.dispose()}),this._parseScene(),this._setupRenderTargets()}return e._GetDefaultOptions=function(){return{renderSize:1024,samples:4,lodGenerationScale:1,lodGenerationOffset:-4,renderTargetTextureType:t.Constants.TEXTURETYPE_HALF_FLOAT,generateMipmaps:!0}},e.prototype.updateOptions=function(e){var t=this,n=Object.keys(e).filter(function(n){return t._options[n]!==e[n]});if(n.length){var r=o(o({},this._options),e),a=this._options;this._options=r,r.renderSize===a.renderSize&&r.renderTargetTextureType===a.renderTargetTextureType&&r.generateMipmaps===a.generateMipmaps&&this._opaqueRenderTarget?(this._opaqueRenderTarget.samples=r.samples,this._opaqueRenderTarget.lodGenerationScale=r.lodGenerationScale,this._opaqueRenderTarget.lodGenerationOffset=r.lodGenerationOffset):this._setupRenderTargets()}},e.prototype.getOpaqueTarget=function(){return this._opaqueRenderTarget},e.prototype._classifyMeshMaterials=function(e){var n=e.material;if(!n)return"opaque";if(!(n instanceof t.MultiMaterial))return this._loader.isMatchingMaterialType(n)&&(s=this._loader._getOrCreateMaterialAdapter(n)).isTranslucent()?(s.refractionBackgroundTexture=this._opaqueRenderTarget,"transparent"):"opaque";for(var r=!1,o=!1,a=new Set,i=0;i<n.subMaterials.length;i++){var s,l=n.subMaterials[i];l&&this._loader.isMatchingMaterialType(l)&&(s=this._loader._getOrCreateMaterialAdapter(l)).isTranslucent()?(s.refractionBackgroundTexture=this._opaqueRenderTarget,r=!0,a.add(i)):o=!0}return r&&o?(this._translucentMaterialIndices.set(e,a),this._rebuildOpaqueOnlySubMeshes(e,a),"mixed"):(this._translucentMaterialIndices.delete(e),this._opaqueOnlySubMeshes.delete(e),r?"transparent":"opaque")},e.prototype._rebuildOpaqueOnlySubMeshes=function(e,t){e.subMeshes&&this._opaqueOnlySubMeshes.set(e,e.subMeshes.filter(function(e){return!t.has(e.materialIndex)}))},e.prototype._addMesh=function(e){var n=this;this._materialObservers[e.uniqueId]=e.onMaterialChangedObservable.add(this._onMeshMaterialChanged.bind(this)),t.Tools.SetImmediate(function(){e.material&&("transparent"===n._classifyMeshMaterials(e)?-1===n._transparentMeshesCache.indexOf(e)&&n._transparentMeshesCache.push(e):-1===n._opaqueMeshesCache.indexOf(e)&&n._opaqueMeshesCache.push(e))})},e.prototype._removeMesh=function(e){e.onMaterialChangedObservable.remove(this._materialObservers[e.uniqueId]),delete this._materialObservers[e.uniqueId];var t=this._transparentMeshesCache.indexOf(e);-1!==t&&this._transparentMeshesCache.splice(t,1),-1!==(t=this._opaqueMeshesCache.indexOf(e))&&this._opaqueMeshesCache.splice(t,1),this._translucentMaterialIndices.delete(e),this._opaqueOnlySubMeshes.delete(e)},e.prototype._parseScene=function(){this._scene.meshes.forEach(this._addMesh.bind(this)),this._scene.onNewMeshAddedObservable.add(this._addMesh.bind(this)),this._scene.onMeshRemovedObservable.add(this._removeMesh.bind(this))},e.prototype._onMeshMaterialChanged=function(e){var t=this._transparentMeshesCache.indexOf(e),n=this._opaqueMeshesCache.indexOf(e);"transparent"===this._classifyMeshMaterials(e)?-1!==n?(this._opaqueMeshesCache.splice(n,1),this._transparentMeshesCache.push(e)):-1===t&&this._transparentMeshesCache.push(e):-1!==t?(this._transparentMeshesCache.splice(t,1),this._opaqueMeshesCache.push(e)):-1===n&&this._opaqueMeshesCache.push(e)},e.prototype._isRenderTargetValid=function(){var e;return null!==(null===(e=this._opaqueRenderTarget)||void 0===e?void 0:e.getInternalTexture())},e.prototype._setupRenderTargets=function(){var e,n,r,o=this;this._opaqueRenderTarget&&this._opaqueRenderTarget.dispose(),this._opaqueRenderTarget=new t.RenderTargetTexture("opaqueSceneTexture",this._options.renderSize,this._scene,this._options.generateMipmaps,void 0,this._options.renderTargetTextureType),this._opaqueRenderTarget.ignoreCameraViewport=!0,this._opaqueRenderTarget.renderList=this._opaqueMeshesCache,this._opaqueRenderTarget.clearColor=null!==(n=null===(e=this._options.clearColor)||void 0===e?void 0:e.clone())&&void 0!==n?n:this._scene.clearColor.clone(),this._opaqueRenderTarget.clearColor.a=0,this._opaqueRenderTarget.gammaSpace=!1,this._opaqueRenderTarget.lodGenerationScale=this._options.lodGenerationScale,this._opaqueRenderTarget.lodGenerationOffset=this._options.lodGenerationOffset,this._opaqueRenderTarget.samples=this._options.samples,this._opaqueRenderTarget.renderSprites=!0,this._opaqueRenderTarget.renderParticles=!0,this._opaqueRenderTarget.disableImageProcessing=!0,this._opaqueRenderTarget.onBeforeBindObservable.add(function(e){r=o._scene.environmentIntensity,o._scene.environmentIntensity=1,o._options.clearColor?e.clearColor.copyFrom(o._options.clearColor):o._scene.clearColor.toLinearSpaceToRef(e.clearColor,o._scene.getEngine().useExactSrgbConversions),e.clearColor.a=0;for(var t=o._opaqueOnlySubMeshes.entries(),n=t.next();!n.done;n=t.next()){var a=n.value[0],i=n.value[1];a.subMeshes&&(o._savedSubMeshes.set(a,a.subMeshes),a.subMeshes=i)}}),this._opaqueRenderTarget.onAfterUnbindObservable.add(function(){o._scene.environmentIntensity=r;for(var e=o._savedSubMeshes.entries(),t=e.next();!t.done;t=e.next())t.value[0].subMeshes=t.value[1];o._savedSubMeshes.clear()});for(var a=0,i=this._transparentMeshesCache;a<i.length;a++)(u=i[a]).material&&this._classifyMeshMaterials(u);for(var s=this._translucentMaterialIndices.entries(),l=s.next();!l.done;l=s.next()){var u;(u=l.value[0]).material&&this._classifyMeshMaterials(u)}},e.prototype.dispose=function(){this._scene._transmissionHelper=void 0,this._opaqueRenderTarget&&(this._opaqueRenderTarget.dispose(),this._opaqueRenderTarget=null),this._transparentMeshesCache=[],this._opaqueMeshesCache=[],this._translucentMaterialIndices.clear(),this._opaqueOnlySubMeshes.clear(),this._savedSubMeshes.clear()},e}(),Ne="KHR_materials_transmission",Ge=function(){function e(e){this.name=Ne,this.order=175,this._loader=e,this.enabled=this._loader.isExtensionUsed(Ne),this.enabled&&(e.parent.transparencyAsCoverage=!0)}return e.prototype.dispose=function(){this._loader=null},e.prototype.loadMaterialPropertiesAsync=function(e,t,n){var r=this;return q.LoadExtensionAsync(e,t,this.name,function(o,s){return a(r,void 0,void 0,function(){var r;return i(this,function(a){switch(a.label){case 0:return(r=new Array).push(this._loader.loadMaterialPropertiesAsync(e,t,n)),r.push(this._loadTransparentPropertiesAsync(o,t,n,s)),[4,Promise.all(r).then(function(){})];case 1:return[2,a.sent()]}})})})},e.prototype._loadTransparentPropertiesAsync=function(e,t,n,r){var o,a,i=this._loader._getOrCreateMaterialAdapter(n),s=void 0!==r.transmissionFactor?r.transmissionFactor:0;if(0===s||!i)return Promise.resolve();if(i.configureTransmission(),i.transmissionWeight=s,s>0&&!this._loader.parent.dontUseTransmissionHelper){var l=n.getScene();l._transmissionHelper?(null===(o=l._transmissionHelper)||void 0===o?void 0:o._isRenderTargetValid())||null===(a=l._transmissionHelper)||void 0===a||a._setupRenderTargets():new Be({},n.getScene(),this._loader)}var u=Promise.resolve(null);return r.transmissionTexture&&(r.transmissionTexture.nonColorData=!0,u=this._loader.loadTextureInfoAsync("".concat(e,"/transmissionTexture"),r.transmissionTexture,function(e){e.name="".concat(n.name," (Transmission)"),i.transmissionWeightTexture=e})),u.then(function(){})},e}();K(Ne),H(Ne,!0,function(e){return new Ge(e)});var De="KHR_materials_diffuse_transmission",Ve=function(){function e(e){this.name=De,this.order=174,this._loader=e,this.enabled=this._loader.isExtensionUsed(De),this.enabled&&(e.parent.transparencyAsCoverage=!0)}return e.prototype.dispose=function(){this._loader=null},e.prototype.loadMaterialPropertiesAsync=function(e,t,n){var r=this;return q.LoadExtensionAsync(e,t,this.name,function(o,s){return a(r,void 0,void 0,function(){var r;return i(this,function(a){switch(a.label){case 0:return(r=new Array).push(this._loader.loadMaterialPropertiesAsync(e,t,n)),r.push(this._loadTranslucentPropertiesAsync(o,t,n,s)),[4,Promise.all(r).then(function(){})];case 1:return[2,a.sent()]}})})})},e.prototype._loadTranslucentPropertiesAsync=function(e,n,r,o){var a,i=this._loader._getOrCreateMaterialAdapter(r);i.configureSubsurface(),i.subsurfaceWeight=null!==(a=o.diffuseTransmissionFactor)&&void 0!==a?a:0,i.diffuseTransmissionTint=void 0!==o.diffuseTransmissionColorFactor?t.Color3.FromArray(o.diffuseTransmissionColorFactor):t.Color3.White();var s=new Array;return o.diffuseTransmissionTexture&&(o.diffuseTransmissionTexture.nonColorData=!0,s.push(this._loader.loadTextureInfoAsync("".concat(e,"/diffuseTransmissionTexture"),o.diffuseTransmissionTexture).then(function(e){e.name="".concat(r.name," (Diffuse Transmission)"),i.subsurfaceWeightTexture=e}))),o.diffuseTransmissionColorTexture&&s.push(this._loader.loadTextureInfoAsync("".concat(e,"/diffuseTransmissionColorTexture"),o.diffuseTransmissionColorTexture).then(function(e){e.name="".concat(r.name," (Diffuse Transmission Color)"),i.diffuseTransmissionTintTexture=e})),Promise.all(s).then(function(){})},e}();K(De),H(De,!0,function(e){return new Ve(e)});var He="KHR_materials_volume",Ke=function(){function e(e){this.name=He,this.order=173,this._loader=e,this.enabled=this._loader.isExtensionUsed(He),this.enabled&&this._loader._disableInstancedMesh++}return e.prototype.dispose=function(){this.enabled&&this._loader._disableInstancedMesh--,this._loader=null},e.prototype.loadMaterialPropertiesAsync=function(e,t,n){var r=this;return q.LoadExtensionAsync(e,t,this.name,function(o,s){return a(r,void 0,void 0,function(){var r;return i(this,function(a){switch(a.label){case 0:return(r=new Array).push(this._loader.loadMaterialPropertiesAsync(e,t,n)),r.push(this._loadVolumePropertiesAsync(o,t,n,s)),[4,Promise.all(r).then(function(){})];case 1:return[2,a.sent()]}})})})},e.prototype._loadVolumePropertiesAsync=function(e,n,r,o){var a,i=this._loader._getOrCreateMaterialAdapter(r);if(0===i.transmissionWeight&&0===i.subsurfaceWeight||!o.thicknessFactor)return Promise.resolve();i.geometryThinWalled=!1;var s=void 0!==o.attenuationDistance?o.attenuationDistance:Number.MAX_VALUE,l=void 0!==o.attenuationColor&&3==o.attenuationColor.length?t.Color3.FromArray(o.attenuationColor):t.Color3.White();i.configureVolume(),i.transmissionColor=l,i.transmissionDepth=s,i.volumeThickness=null!==(a=o.thicknessFactor)&&void 0!==a?a:0;var u=new Array;return o.thicknessTexture&&(o.thicknessTexture.nonColorData=!0,u.push(this._loader.loadTextureInfoAsync("".concat(e,"/thicknessTexture"),o.thicknessTexture,function(e){e.name="".concat(r.name," (Thickness)"),i.volumeThicknessTexture=e}))),Promise.all(u).then(function(){})},e}();K(He),H(He,!0,function(e){return new Ke(e)});var je="KHR_materials_volume_scatter",We=function(){function e(e){this.name=je,this.order=172,this._loader=e,this.enabled=this._loader.isExtensionUsed(je),this.enabled&&this._loader._disableInstancedMesh++}return e.prototype.dispose=function(){this.enabled&&this._loader._disableInstancedMesh--,this._loader=null},e.prototype.loadMaterialPropertiesAsync=function(e,t,n){var r=this;return q.LoadExtensionAsync(e,t,this.name,function(o,s){return a(r,void 0,void 0,function(){var r;return i(this,function(a){switch(a.label){case 0:return(r=new Array).push(this._loader.loadMaterialPropertiesAsync(e,t,n)),r.push(this._loadVolumePropertiesAsync(o,t,n,s)),[4,Promise.all(r).then(function(){})];case 1:return[2,a.sent()]}})})})},e.prototype._loadVolumePropertiesAsync=function(e,n,r,o){var a=this._loader._getOrCreateMaterialAdapter(r);if(0===a.transmissionWeight&&0===a.subsurfaceWeight||a.geometryThinWalled)return Promise.resolve();var i=void 0!==o.multiscatterColorFactor&&3==o.multiscatterColorFactor.length?t.Color3.FromArray(o.multiscatterColorFactor):t.Color3.Black(),s=void 0!==o.scatterAnisotropy?o.scatterAnisotropy:0,l=Promise.resolve(null);o.multiscatterColorTexture&&(o.multiscatterColorTexture.nonColorData=!0,l=this._loader.loadTextureInfoAsync("".concat(e,"/multiscatterColorTexture"),o.multiscatterColorTexture,function(e){e.name="".concat(r.name," (Scatter Color)"),a.transmissionWeight>0&&(a.transmissionScatterTexture=e),a.subsurfaceWeight>0&&(a.subsurfaceColorTexture=e)}));var u=new t.Vector3(-Math.log(a.transmissionColor.r),-Math.log(a.transmissionColor.g),-Math.log(a.transmissionColor.b));if(u.scaleInPlace(1/Math.max(a.transmissionDepth,1e-6)),a.transmissionWeight>0){var c=function(e){var n=new t.Vector3(e.r,e.g,e.b),r=new t.Vector3(4.09712,4.09712,4.09712);r.addInPlace(new t.Vector3(4.20863,4.20863,4.20863).multiplyInPlace(n));var o=new t.Vector3(9.59217,9.59217,9.59217);return o.addInPlace(new t.Vector3(41.6808,41.6808,41.6808).multiplyInPlace(n)),o.addInPlace(new t.Vector3(17.7126,17.7126,17.7126).multiplyInPlace(n.multiply(n))),r.subtractInPlace(new t.Vector3(Math.sqrt(o.x),Math.sqrt(o.y),Math.sqrt(o.z))),new t.Vector3(1,1,1).subtract(r.multiply(r))}(i),f=u.multiply(c);f.scaleInPlace(a.transmissionDepth),a.transmissionScatter.set(f.x,f.y,f.z),a.transmissionScatterAnisotropy=s}if(a.subsurfaceWeight>0){a.subsurfaceScatterAnisotropy=s,a.subsurfaceColor=i;var h=new t.Vector3(0!==u.x?1/u.x:1,0!==u.y?1/u.y:1,0!==u.z?1/u.z:1);a.subsurfaceRadius=Math.max(h.x,h.y,h.z),a.subsurfaceRadiusScale=new t.Color3(h.x/a.subsurfaceRadius,h.y/a.subsurfaceRadius,h.z/a.subsurfaceRadius)}return l.then(function(){})},e}();K(je),H(je,!0,function(e){return new We(e)});var Ue="KHR_materials_dispersion",ze=function(){function e(e){this.name=Ue,this.order=174,this._loader=e,this.enabled=this._loader.isExtensionUsed(Ue)}return e.prototype.dispose=function(){this._loader=null},e.prototype.loadMaterialPropertiesAsync=function(e,t,n){var r=this;return q.LoadExtensionAsync(e,t,this.name,function(o,s){return a(r,void 0,void 0,function(){var r;return i(this,function(a){switch(a.label){case 0:return(r=new Array).push(this._loader.loadMaterialPropertiesAsync(e,t,n)),r.push(this._loadDispersionPropertiesAsync(o,t,n,s)),[4,Promise.all(r).then(function(){})];case 1:return[2,a.sent()]}})})})},e.prototype._loadDispersionPropertiesAsync=function(e,t,n,r){var o=this._loader._getOrCreateMaterialAdapter(n);return 0!=o.transmissionWeight&&r.dispersion?(o.transmissionDispersionAbbeNumber=20,o.transmissionDispersionScale=r.dispersion,Promise.resolve()):Promise.resolve()},e}();K(Ue),H(Ue,!0,function(e){return new ze(e)});var qe="KHR_materials_diffuse_roughness",Ye=function(){function e(e){this.name=qe,this.order=190,this._loader=e,this.enabled=this._loader.isExtensionUsed(qe)}return e.prototype.dispose=function(){this._loader=null},e.prototype.loadMaterialPropertiesAsync=function(e,t,n){var r=this;return q.LoadExtensionAsync(e,t,this.name,function(o,s){return a(r,void 0,void 0,function(){var r;return i(this,function(a){switch(a.label){case 0:return(r=new Array).push(this._loader.loadMaterialPropertiesAsync(e,t,n)),r.push(this._loadDiffuseRoughnessPropertiesAsync(o,s,n)),[4,Promise.all(r).then(function(){})];case 1:return[2,a.sent()]}})})})},e.prototype._loadDiffuseRoughnessPropertiesAsync=function(e,t,n){var r,o=this._loader._getOrCreateMaterialAdapter(n),a=new Array;return o.baseDiffuseRoughness=null!==(r=t.diffuseRoughnessFactor)&&void 0!==r?r:0,t.diffuseRoughnessTexture&&a.push(this._loader.loadTextureInfoAsync("".concat(e,"/diffuseRoughnessTexture"),t.diffuseRoughnessTexture,function(e){e.name="".concat(n.name," (Diffuse Roughness)"),o.baseDiffuseRoughnessTexture=e})),Promise.all(a).then(function(){})},e}();K(qe),H(qe,!0,function(e){return new Ye(e)});var Xe="KHR_mesh_quantization",Qe=function(){function e(e){this.name=Xe,this.enabled=e.isExtensionUsed(Xe)}return e.prototype.dispose=function(){},e}();K(Xe),H(Xe,!0,function(e){return new Qe(e)});var Je="KHR_texture_basisu",Ze=function(){function e(e){this.name=Je,this._loader=e,this.enabled=e.isExtensionUsed(Je)}return e.prototype.dispose=function(){this._loader=null},e.prototype._loadTextureAsync=function(e,t,n){var r=this;return q.LoadExtensionAsync(e,t,this.name,function(o,s){return a(r,void 0,void 0,function(){var r,a;return i(this,function(i){switch(i.label){case 0:return r=null==t.sampler?q.DefaultSampler:U.Get("".concat(e,"/sampler"),this._loader.gltf.samplers,t.sampler),a=U.Get("".concat(o,"/source"),this._loader.gltf.images,s.source),[4,this._loader._createTextureAsync(e,r,a,function(e){n(e)},t._textureInfo.nonColorData?{useRGBAIfASTCBC7NotAvailableWhenUASTC:!0}:void 0,!t._textureInfo.nonColorData)];case 1:return[2,i.sent()]}})})})},e}();K(Je),H(Je,!0,function(e){return new Ze(e)});var $e="KHR_texture_transform",et=function(){function e(e){this.name=$e,this._loader=e,this.enabled=this._loader.isExtensionUsed($e)}return e.prototype.dispose=function(){this._loader=null},e.prototype.loadTextureInfoAsync=function(e,n,r){var o=this;return q.LoadExtensionAsync(e,n,this.name,function(s,l){return a(o,void 0,void 0,function(){return i(this,function(o){switch(o.label){case 0:return[4,this._loader.loadTextureInfoAsync(e,n,function(e){if(!(e instanceof t.Texture))throw new Error("".concat(s,": Texture type not supported"));l.offset&&(e.uOffset=l.offset[0],e.vOffset=l.offset[1]),e.uRotationCenter=0,e.vRotationCenter=0,l.rotation&&(e.wAng=-l.rotation),l.scale&&(e.uScale=l.scale[0],e.vScale=l.scale[1]),null!=l.texCoord&&(e.coordinatesIndex=l.texCoord),r(e)})];case 1:return[2,o.sent()]}})})})},e}();K($e),H($e,!0,function(e){return new et(e)});var tt="KHR_xmp_json_ld",nt=function(){function e(e){this.name=tt,this.order=100,this._loader=e,this.enabled=this._loader.isExtensionUsed(tt)}return e.prototype.dispose=function(){this._loader=null},e.prototype.onLoading=function(){var e,t,n;if(null!==this._loader.rootBabylonMesh){var r=null===(e=this._loader.gltf.extensions)||void 0===e?void 0:e.KHR_xmp_json_ld,o=null===(n=null===(t=this._loader.gltf.asset)||void 0===t?void 0:t.extensions)||void 0===n?void 0:n.KHR_xmp_json_ld;if(r&&o){var a=+o.packet;r.packets&&a<r.packets.length&&(this._loader.rootBabylonMesh.metadata=this._loader.rootBabylonMesh.metadata||{},this._loader.rootBabylonMesh.metadata.xmp=r.packets[a])}}},e}();function rt(e,n,r,o){return t.Vector3.FromArray(n,r).scaleInPlace(o)}function ot(e,n,r,o){return t.Quaternion.FromArray(n,r).scaleInPlace(o)}function at(e,t,n,r){for(var o=new Array(e._numMorphTargets),a=0;a<o.length;a++)o[a]=t[n++]*r;return o}K(tt),H(tt,!0,function(e){return new nt(e)});var it=function(){function e(e,t,n,r){this.type=e,this.name=t,this.getValue=n,this.getStride=r}return e.prototype._buildAnimation=function(e,n,r){var o=new t.Animation(e,this.name,n,this.type);return o.setKeys(r,!0),o},e}(),st=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return r(t,e),t.prototype.buildAnimations=function(e,t,n,r){var o=[];return o.push({babylonAnimatable:e._babylonTransformNode,babylonAnimation:this._buildAnimation(t,n,r)}),o},t}(it),lt=function(e){function n(){return null!==e&&e.apply(this,arguments)||this}return r(n,e),n.prototype.buildAnimations=function(e,n,r,o){var a=[];if(e._numMorphTargets)for(var i=function(i){var l=new t.Animation("".concat(n,"_").concat(i),s.name,r,s.type);if(l.setKeys(o.map(function(e){return{frame:e.frame,inTangent:e.inTangent?e.inTangent[i]:void 0,value:e.value[i],outTangent:e.outTangent?e.outTangent[i]:void 0,interpolation:e.interpolation}}),!0),e._primitiveBabylonMeshes)for(var u=0,c=e._primitiveBabylonMeshes;u<c.length;u++){var f=c[u];if(f.morphTargetManager){var h=f.morphTargetManager.getTarget(i),p=l.clone();h.animations.push(p),a.push({babylonAnimatable:h,babylonAnimation:p})}}},s=this,l=0;l<e._numMorphTargets;l++)i(l);return a},n}(it);N("/nodes/{}/translation",[new st(t.Animation.ANIMATIONTYPE_VECTOR3,"position",rt,function(){return 3})]),N("/nodes/{}/rotation",[new st(t.Animation.ANIMATIONTYPE_QUATERNION,"rotationQuaternion",ot,function(){return 4})]),N("/nodes/{}/scale",[new st(t.Animation.ANIMATIONTYPE_VECTOR3,"scaling",rt,function(){return 3})]),N("/nodes/{}/weights",[new lt(t.Animation.ANIMATIONTYPE_FLOAT,"influence",at,function(e){return e._numMorphTargets})]);var ut={__proto__:null,AnimationPropertyInfo:it,TransformNodeAnimationPropertyInfo:st,WeightAnimationPropertyInfo:lt,getQuaternion:ot,getVector3:rt,getWeights:at};function ct(e,n,r,o){return t.Color3.FromArray(n,r).scale(o)}function ft(e,t,n,r){return t[n]*r}function ht(e,t,n,r){return-t[n]*r}function pt(e,t,n,r){return t[n+1]*r}function dt(e,t,n,r){return t[n]*r*2}function mt(e){return{scale:[new bt(t.Animation.ANIMATIONTYPE_FLOAT,"".concat(e,".uScale"),ft,function(){return 2}),new bt(t.Animation.ANIMATIONTYPE_FLOAT,"".concat(e,".vScale"),pt,function(){return 2})],offset:[new bt(t.Animation.ANIMATIONTYPE_FLOAT,"".concat(e,".uOffset"),ft,function(){return 2}),new bt(t.Animation.ANIMATIONTYPE_FLOAT,"".concat(e,".vOffset"),pt,function(){return 2})],rotation:[new bt(t.Animation.ANIMATIONTYPE_FLOAT,"".concat(e,".wAng"),ht,function(){return 1})]}}var _t=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return r(t,e),t.prototype.buildAnimations=function(e,t,n,r){return[{babylonAnimatable:e._babylonCamera,babylonAnimation:this._buildAnimation(t,n,r)}]},t}(it),bt=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return r(t,e),t.prototype.buildAnimations=function(e,t,n,r){var o=[];for(var a in e._data)o.push({babylonAnimatable:e._data[a].babylonMaterial,babylonAnimation:this._buildAnimation(t,n,r)});return o},t}(it),gt=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return r(t,e),t.prototype.buildAnimations=function(e,t,n,r){return[{babylonAnimatable:e._babylonLight,babylonAnimation:this._buildAnimation(t,n,r)}]},t}(it),yt=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return r(t,e),t.prototype.buildAnimations=function(e,t,n,r){var o=this;return e._primitiveBabylonMeshes?e._primitiveBabylonMeshes.map(function(e){return{babylonAnimatable:e,babylonAnimation:o._buildAnimation(t,n,r)}}):[]},t}(it);N("/cameras/{}/orthographic/xmag",[new _t(t.Animation.ANIMATIONTYPE_FLOAT,"orthoLeft",ht,function(){return 1}),new _t(t.Animation.ANIMATIONTYPE_FLOAT,"orthoRight",pt,function(){return 1})]),N("/cameras/{}/orthographic/ymag",[new _t(t.Animation.ANIMATIONTYPE_FLOAT,"orthoBottom",ht,function(){return 1}),new _t(t.Animation.ANIMATIONTYPE_FLOAT,"orthoTop",pt,function(){return 1})]),N("/cameras/{}/orthographic/zfar",[new _t(t.Animation.ANIMATIONTYPE_FLOAT,"maxZ",ft,function(){return 1})]),N("/cameras/{}/orthographic/znear",[new _t(t.Animation.ANIMATIONTYPE_FLOAT,"minZ",ft,function(){return 1})]),N("/cameras/{}/perspective/yfov",[new _t(t.Animation.ANIMATIONTYPE_FLOAT,"fov",ft,function(){return 1})]),N("/cameras/{}/perspective/zfar",[new _t(t.Animation.ANIMATIONTYPE_FLOAT,"maxZ",ft,function(){return 1})]),N("/cameras/{}/perspective/znear",[new _t(t.Animation.ANIMATIONTYPE_FLOAT,"minZ",ft,function(){return 1})]),N("/materials/{}/pbrMetallicRoughness/baseColorFactor",[new bt(t.Animation.ANIMATIONTYPE_COLOR3,"albedoColor",ct,function(){return 4}),new bt(t.Animation.ANIMATIONTYPE_FLOAT,"alpha",function(e,t,n,r){return t[n+3]*r},function(){return 4})]),N("/materials/{}/pbrMetallicRoughness/metallicFactor",[new bt(t.Animation.ANIMATIONTYPE_FLOAT,"metallic",ft,function(){return 1})]),N("/materials/{}/pbrMetallicRoughness/metallicFactor",[new bt(t.Animation.ANIMATIONTYPE_FLOAT,"roughness",ft,function(){return 1})]);var vt=mt("albedoTexture");N("/materials/{}/pbrMetallicRoughness/baseColorTexture/extensions/KHR_texture_transform/scale",vt.scale),N("/materials/{}/pbrMetallicRoughness/baseColorTexture/extensions/KHR_texture_transform/offset",vt.offset),N("/materials/{}/pbrMetallicRoughness/baseColorTexture/extensions/KHR_texture_transform/rotation",vt.rotation);var Tt=mt("metallicTexture");N("//materials/{}/pbrMetallicRoughness/metallicRoughnessTexture/scale",Tt.scale),N("//materials/{}/pbrMetallicRoughness/metallicRoughnessTexture/offset",Tt.offset),N("//materials/{}/pbrMetallicRoughness/metallicRoughnessTexture/rotation",Tt.rotation),N("/materials/{}/emissiveFactor",[new bt(t.Animation.ANIMATIONTYPE_COLOR3,"emissiveColor",ct,function(){return 3})]);var xt=mt("bumpTexture");N("/materials/{}/normalTexture/scale",[new bt(t.Animation.ANIMATIONTYPE_FLOAT,"bumpTexture.level",ft,function(){return 1})]),N("/materials/{}/normalTexture/extensions/KHR_texture_transform/scale",xt.scale),N("/materials/{}/normalTexture/extensions/KHR_texture_transform/offset",xt.offset),N("/materials/{}/normalTexture/extensions/KHR_texture_transform/rotation",xt.rotation),N("/materials/{}/occlusionTexture/strength",[new bt(t.Animation.ANIMATIONTYPE_FLOAT,"ambientTextureStrength",ft,function(){return 1})]);var At=mt("ambientTexture");N("/materials/{}/occlusionTexture/extensions/KHR_texture_transform/scale",At.scale),N("/materials/{}/occlusionTexture/extensions/KHR_texture_transform/offset",At.offset),N("/materials/{}/occlusionTexture/extensions/KHR_texture_transform/rotation",At.rotation);var Ct=mt("emissiveTexture");N("/materials/{}/emissiveTexture/extensions/KHR_texture_transform/scale",Ct.scale),N("/materials/{}/emissiveTexture/extensions/KHR_texture_transform/offset",Ct.offset),N("/materials/{}/emissiveTexture/extensions/KHR_texture_transform/rotation",Ct.rotation),N("/materials/{}/extensions/KHR_materials_anisotropy/anisotropyStrength",[new bt(t.Animation.ANIMATIONTYPE_FLOAT,"anisotropy.intensity",ft,function(){return 1})]),N("/materials/{}/extensions/KHR_materials_anisotropy/anisotropyRotation",[new bt(t.Animation.ANIMATIONTYPE_FLOAT,"anisotropy.angle",ft,function(){return 1})]);var wt=mt("anisotropy.texture");N("/materials/{}/extensions/KHR_materials_anisotropy/anisotropyTexture/extensions/KHR_texture_transform/scale",wt.scale),N("/materials/{}/extensions/KHR_materials_anisotropy/anisotropyTexture/extensions/KHR_texture_transform/offset",wt.offset),N("/materials/{}/extensions/KHR_materials_anisotropy/anisotropyTexture/extensions/KHR_texture_transform/rotation",wt.rotation),N("/materials/{}/extensions/KHR_materials_clearcoat/clearcoatFactor",[new bt(t.Animation.ANIMATIONTYPE_FLOAT,"clearCoat.intensity",ft,function(){return 1})]),N("/materials/{}/extensions/KHR_materials_clearcoat/clearcoatRoughnessFactor",[new bt(t.Animation.ANIMATIONTYPE_FLOAT,"clearCoat.roughness",ft,function(){return 1})]);var Ot=mt("clearCoat.texture");N("/materials/{}/extensions/KHR_materials_clearcoat/clearcoatTexture/extensions/KHR_texture_transform/scale",Ot.scale),N("/materials/{}/extensions/KHR_materials_clearcoat/clearcoatTexture/extensions/KHR_texture_transform/offset",Ot.offset),N("/materials/{}/extensions/KHR_materials_clearcoat/clearcoatTexture/extensions/KHR_texture_transform/rotation",Ot.rotation);var Mt=mt("clearCoat.bumpTexture");N("/materials/{}/extensions/KHR_materials_clearcoat/clearcoatNormalTexture/scale",[new bt(t.Animation.ANIMATIONTYPE_FLOAT,"clearCoat.bumpTexture.level",ft,function(){return 1})]),N("/materials/{}/extensions/KHR_materials_clearcoat/clearcoatNormalTexture/extensions/KHR_texture_transform/scale",Mt.scale),N("/materials/{}/extensions/KHR_materials_clearcoat/clearcoatNormalTexture/extensions/KHR_texture_transform/offset",Mt.offset),N("/materials/{}/extensions/KHR_materials_clearcoat/clearcoatNormalTexture/extensions/KHR_texture_transform/rotation",Mt.rotation);var Rt=mt("clearCoat.textureRoughness");N("/materials/{}/extensions/KHR_materials_clearcoat/clearcoatRoughnessTexture/extensions/KHR_texture_transform/scale",Rt.scale),N("/materials/{}/extensions/KHR_materials_clearcoat/clearcoatRoughnessTexture/extensions/KHR_texture_transform/offset",Rt.offset),N("/materials/{}/extensions/KHR_materials_clearcoat/clearcoatRoughnessTexture/extensions/KHR_texture_transform/rotation",Rt.rotation),N("/materials/{}/extensions/KHR_materials_dispersion/dispersionFactor",[new bt(t.Animation.ANIMATIONTYPE_FLOAT,"subSurface.dispersion",ft,function(){return 1})]),N("/materials/{}/extensions/KHR_materials_emissive_strength/emissiveStrength",[new bt(t.Animation.ANIMATIONTYPE_FLOAT,"emissiveIntensity",ft,function(){return 1})]),N("/materials/{}/extensions/KHR_materials_ior/ior",[new bt(t.Animation.ANIMATIONTYPE_FLOAT,"indexOfRefraction",ft,function(){return 1})]),N("/materials/{}/extensions/KHR_materials_iridescence/iridescenceFactor",[new bt(t.Animation.ANIMATIONTYPE_FLOAT,"iridescence.intensity",ft,function(){return 1})]),N("/materials/{}/extensions/KHR_materials_iridescence/iridescenceIor",[new bt(t.Animation.ANIMATIONTYPE_FLOAT,"iridescence.indexOfRefraction",ft,function(){return 1})]),N("/materials/{}/extensions/KHR_materials_iridescence/iridescenceThicknessMinimum",[new bt(t.Animation.ANIMATIONTYPE_FLOAT,"iridescence.minimumThickness",ft,function(){return 1})]),N("/materials/{}/extensions/KHR_materials_iridescence/iridescenceThicknessMaximum",[new bt(t.Animation.ANIMATIONTYPE_FLOAT,"iridescence.maximumThickness",ft,function(){return 1})]);var Pt=mt("iridescence.texture");N("/materials/{}/extensions/KHR_materials_iridescence/iridescenceTexture/extensions/KHR_texture_transform/scale",Pt.scale),N("/materials/{}/extensions/KHR_materials_iridescence/iridescenceTexture/extensions/KHR_texture_transform/offset",Pt.offset),N("/materials/{}/extensions/KHR_materials_iridescence/iridescenceTexture/extensions/KHR_texture_transform/rotation",Pt.rotation);var Lt=mt("iridescence.thicknessTexture");N("/materials/{}/extensions/KHR_materials_iridescence/iridescenceThicknessTexture/extensions/KHR_texture_transform/scale",Lt.scale),N("/materials/{}/extensions/KHR_materials_iridescence/iridescenceThicknessTexture/extensions/KHR_texture_transform/offset",Lt.offset),N("/materials/{}/extensions/KHR_materials_iridescence/iridescenceThicknessTexture/extensions/KHR_texture_transform/rotation",Lt.rotation),N("/materials/{}/extensions/KHR_materials_sheen/sheenColorFactor",[new bt(t.Animation.ANIMATIONTYPE_COLOR3,"sheen.color",ct,function(){return 3})]),N("/materials/{}/extensions/KHR_materials_sheen/sheenRoughnessFactor",[new bt(t.Animation.ANIMATIONTYPE_FLOAT,"sheen.roughness",ft,function(){return 1})]);var Ft=mt("sheen.texture");N("/materials/{}/extensions/KHR_materials_sheen/sheenColorTexture/extensions/KHR_texture_transform/scale",Ft.scale),N("/materials/{}/extensions/KHR_materials_sheen/sheenColorTexture/extensions/KHR_texture_transform/offset",Ft.offset),N("/materials/{}/extensions/KHR_materials_sheen/sheenColorTexture/extensions/KHR_texture_transform/rotation",Ft.rotation);var Et=mt("sheen.textureRoughness");N("/materials/{}/extensions/KHR_materials_sheen/sheenRoughnessTexture/extensions/KHR_texture_transform/scale",Et.scale),N("/materials/{}/extensions/KHR_materials_sheen/sheenRoughnessTexture/extensions/KHR_texture_transform/offset",Et.offset),N("/materials/{}/extensions/KHR_materials_sheen/sheenRoughnessTexture/extensions/KHR_texture_transform/rotation",Et.rotation),N("/materials/{}/extensions/KHR_materials_specular/specularFactor",[new bt(t.Animation.ANIMATIONTYPE_FLOAT,"metallicF0Factor",ft,function(){return 1})]),N("/materials/{}/extensions/KHR_materials_specular/specularColorFactor",[new bt(t.Animation.ANIMATIONTYPE_COLOR3,"metallicReflectanceColor",ct,function(){return 3})]);var St=mt("metallicReflectanceTexture");N("/materials/{}/extensions/KHR_materials_specular/specularTexture/extensions/KHR_texture_transform/scale",St.scale),N("/materials/{}/extensions/KHR_materials_specular/specularTexture/extensions/KHR_texture_transform/offset",St.offset),N("/materials/{}/extensions/KHR_materials_specular/specularTexture/extensions/KHR_texture_transform/rotation",St.rotation);var kt=mt("reflectanceTexture");N("/materials/{}/extensions/KHR_materials_specular/specularColorTexture/extensions/KHR_texture_transform/scale",kt.scale),N("/materials/{}/extensions/KHR_materials_specular/specularColorTexture/extensions/KHR_texture_transform/offset",kt.offset),N("/materials/{}/extensions/KHR_materials_specular/specularColorTexture/extensions/KHR_texture_transform/rotation",kt.rotation),N("/materials/{}/extensions/KHR_materials_transmission/transmissionFactor",[new bt(t.Animation.ANIMATIONTYPE_FLOAT,"subSurface.refractionIntensity",ft,function(){return 1})]);var It=mt("subSurface.refractionIntensityTexture");N("/materials/{}/extensions/KHR_materials_transmission/transmissionTexture/extensions/KHR_texture_transform/scale",It.scale),N("/materials/{}/extensions/KHR_materials_transmission/transmissionTexture/extensions/KHR_texture_transform/offset",It.offset),N("/materials/{}/extensions/KHR_materials_transmission/transmissionTexture/extensions/KHR_texture_transform/rotation",It.rotation),N("/materials/{}/extensions/KHR_materials_volume/attenuationColor",[new bt(t.Animation.ANIMATIONTYPE_COLOR3,"subSurface.tintColor",ct,function(){return 3})]),N("/materials/{}/extensions/KHR_materials_volume/attenuationDistance",[new bt(t.Animation.ANIMATIONTYPE_FLOAT,"subSurface.tintColorAtDistance",ft,function(){return 1})]),N("/materials/{}/extensions/KHR_materials_volume/thicknessFactor",[new bt(t.Animation.ANIMATIONTYPE_FLOAT,"subSurface.maximumThickness",ft,function(){return 1})]);var Bt=mt("subSurface.thicknessTexture");N("/materials/{}/extensions/KHR_materials_volume/thicknessTexture/extensions/KHR_texture_transform/scale",Bt.scale),N("/materials/{}/extensions/KHR_materials_volume/thicknessTexture/extensions/KHR_texture_transform/offset",Bt.offset),N("/materials/{}/extensions/KHR_materials_volume/thicknessTexture/extensions/KHR_texture_transform/rotation",Bt.rotation),N("/materials/{}/extensions/KHR_materials_diffuse_transmission/diffuseTransmissionFactor",[new bt(t.Animation.ANIMATIONTYPE_FLOAT,"subSurface.translucencyIntensity",ft,function(){return 1})]);var Nt=mt("subSurface.translucencyIntensityTexture");N("materials/{}/extensions/KHR_materials_diffuse_transmission/diffuseTransmissionTexture/extensions/KHR_texture_transform/scale",Nt.scale),N("materials/{}/extensions/KHR_materials_diffuse_transmission/diffuseTransmissionTexture/extensions/KHR_texture_transform/offset",Nt.offset),N("materials/{}/extensions/KHR_materials_diffuse_transmission/diffuseTransmissionTexture/extensions/KHR_texture_transform/rotation",Nt.rotation),N("/materials/{}/extensions/KHR_materials_diffuse_transmission/diffuseTransmissionColorFactor",[new bt(t.Animation.ANIMATIONTYPE_COLOR3,"subSurface.translucencyColor",ct,function(){return 3})]);var Gt=mt("subSurface.translucencyColorTexture");N("materials/{}/extensions/KHR_materials_diffuse_transmission/diffuseTransmissionColorTexture/extensions/KHR_texture_transform/scale",Gt.scale),N("materials/{}/extensions/KHR_materials_diffuse_transmission/diffuseTransmissionColorTexture/extensions/KHR_texture_transform/offset",Gt.offset),N("materials/{}/extensions/KHR_materials_diffuse_transmission/diffuseTransmissionColorTexture/extensions/KHR_texture_transform/rotation",Gt.rotation),N("/extensions/KHR_lights_punctual/lights/{}/color",[new gt(t.Animation.ANIMATIONTYPE_COLOR3,"diffuse",ct,function(){return 3})]),N("/extensions/KHR_lights_punctual/lights/{}/intensity",[new gt(t.Animation.ANIMATIONTYPE_FLOAT,"intensity",ft,function(){return 1})]),N("/extensions/KHR_lights_punctual/lights/{}/range",[new gt(t.Animation.ANIMATIONTYPE_FLOAT,"range",ft,function(){return 1})]),N("/extensions/KHR_lights_punctual/lights/{}/spot/innerConeAngle",[new gt(t.Animation.ANIMATIONTYPE_FLOAT,"innerAngle",dt,function(){return 1})]),N("/extensions/KHR_lights_punctual/lights/{}/spot/outerConeAngle",[new gt(t.Animation.ANIMATIONTYPE_FLOAT,"angle",dt,function(){return 1})]),N("/extensions/EXT_lights_area/lights/{}/color",[new gt(t.Animation.ANIMATIONTYPE_COLOR3,"diffuse",ct,function(){return 3})]),N("/extensions/EXT_lights_area/lights/{}/intensity",[new gt(t.Animation.ANIMATIONTYPE_FLOAT,"intensity",ft,function(){return 1})]),N("/extensions/EXT_lights_area/lights/{}/size",[new gt(t.Animation.ANIMATIONTYPE_FLOAT,"radius",ft,function(){return 1})]),N("/extensions/EXT_lights_area/lights/{}/rect/aspect",[new gt(t.Animation.ANIMATIONTYPE_FLOAT,"radius",ft,function(){return 1})]),N("/nodes/{}/extensions/EXT_lights_ies/color",[new gt(t.Animation.ANIMATIONTYPE_COLOR3,"diffuse",ct,function(){return 3})]),N("/nodes/{}/extensions/EXT_lights_ies/multiplier",[new gt(t.Animation.ANIMATIONTYPE_FLOAT,"intensity",ft,function(){return 1})]),N("/nodes/{}/extensions/KHR_node_visibility/visible",[new yt(t.Animation.ANIMATIONTYPE_FLOAT,"isVisible",ft,function(){return 1})]);var Dt="KHR_animation_pointer",Vt=function(){function e(e){this.name=Dt,this._loader=e,this._pathToObjectConverter=I(this._loader.gltf)}return Object.defineProperty(e.prototype,"enabled",{get:function(){return this._loader.isExtensionUsed(Dt)},enumerable:!1,configurable:!0}),e.prototype.dispose=function(){this._loader=null,delete this._pathToObjectConverter},e.prototype._loadAnimationChannelAsync=function(e,n,r,o,a){var i,s=null===(i=o.target.extensions)||void 0===i?void 0:i.KHR_animation_pointer;if(!s||!this._pathToObjectConverter)return null;"pointer"!==o.target.path&&t.Logger.Warn("".concat(e,"/target/path: Value (").concat(o.target.path,") must be (").concat("pointer",") when using the ").concat(this.name," extension")),null!=o.target.node&&t.Logger.Warn("".concat(e,"/target/node: Value (").concat(o.target.node,") must not be present when using the ").concat(this.name," extension"));var l="".concat(e,"/extensions/").concat(this.name),u=s.pointer;if(!u)throw new Error("".concat(l,": Pointer is missing"));try{var c=this._pathToObjectConverter.convert(u);if(!c.info.interpolation)throw new Error("".concat(l,"/pointer: Interpolation is missing"));return this._loader._loadAnimationChannelFromTargetInfoAsync(e,n,r,o,{object:c.object,info:c.info.interpolation},a)}catch(e){return t.Logger.Warn("".concat(l,"/pointer: Invalid pointer (").concat(u,") skipped")),null}},e}();K(Dt),H(Dt,!0,function(e){return new Vt(e)});var Ht="MSFT_audio_emitter",Kt=function(){function e(e){this.name=Ht,this._loader=e,this.enabled=this._loader.isExtensionUsed(Ht)}return e.prototype.dispose=function(){this._loader=null,this._clips=null,this._emitters=null},e.prototype.onLoading=function(){var e=this._loader.gltf.extensions;if(e&&e[this.name]){var t=e[this.name];this._clips=t.clips,this._emitters=t.emitters,U.Assign(this._clips),U.Assign(this._emitters)}},e.prototype.loadSceneAsync=function(e,t){var n=this;return q.LoadExtensionAsync(e,t,this.name,function(r,o){return a(n,void 0,void 0,function(){var n,a,s,l,u;return i(this,function(i){switch(i.label){case 0:for((n=new Array).push(this._loader.loadSceneAsync(e,t)),a=0,s=o.emitters;a<s.length;a++){if(l=s[a],null!=(u=U.Get("".concat(r,"/emitters"),this._emitters,l)).refDistance||null!=u.maxDistance||null!=u.rolloffFactor||null!=u.distanceModel||null!=u.innerAngle||null!=u.outerAngle)throw new Error("".concat(r,": Direction or Distance properties are not allowed on emitters attached to a scene"));n.push(this._loadEmitterAsync("".concat(r,"/emitters/").concat(u.index),u))}return[4,Promise.all(n)];case 1:return i.sent(),[2]}})})})},e.prototype.loadNodeAsync=function(e,n,r){var o=this;return q.LoadExtensionAsync(e,n,this.name,function(e,s){return a(o,void 0,void 0,function(){var o,a,l=this;return i(this,function(i){switch(i.label){case 0:return o=new Array,[4,this._loader.loadNodeAsync(e,n,function(n){for(var a=function(r){var a=U.Get("".concat(e,"/emitters"),l._emitters,r);o.push(l._loadEmitterAsync("".concat(e,"/emitters/").concat(a.index),a).then(function(){for(var e=0,r=a._babylonSounds;e<r.length;e++){var o=r[e];o.attachToMesh(n),null==a.innerAngle&&null==a.outerAngle||(o.setLocalDirectionToMesh(t.Vector3.Forward()),o.setDirectionalCone(2*t.Tools.ToDegrees(null==a.innerAngle?Math.PI:a.innerAngle),2*t.Tools.ToDegrees(null==a.outerAngle?Math.PI:a.outerAngle),0))}}))},i=0,u=s.emitters;i<u.length;i++)a(u[i]);r(n)})];case 1:return a=i.sent(),[4,Promise.all(o)];case 2:return i.sent(),[2,a]}})})})},e.prototype.loadAnimationAsync=function(e,t){var n=this;return q.LoadExtensionAsync(e,t,this.name,function(r,o){return a(n,void 0,void 0,function(){var n,a,s,l,u;return i(this,function(i){switch(i.label){case 0:return[4,this._loader.loadAnimationAsync(e,t)];case 1:for(n=i.sent(),a=new Array,U.Assign(o.events),s=0,l=o.events;s<l.length;s++)u=l[s],a.push(this._loadAnimationEventAsync("".concat(r,"/events/").concat(u.index),e,t,u,n));return[4,Promise.all(a)];case 2:return i.sent(),[2,n]}})})})},e.prototype._loadClipAsync=function(e,n){if(n._objectURL)return n._objectURL;var r;if(n.uri)r=this._loader.loadUriAsync(e,n,n.uri);else{var o=U.Get("".concat(e,"/bufferView"),this._loader.gltf.bufferViews,n.bufferView);r=this._loader.loadBufferViewAsync("/bufferViews/".concat(o.index),o)}return n._objectURL=r.then(function(e){var r=t.GetBlobBufferSource(e);return URL.createObjectURL(new Blob([r],{type:n.mimeType}))}),n._objectURL},e.prototype._loadEmitterAsync=function(e,n){var r=this;if(n._babylonSounds=n._babylonSounds||[],!n._babylonData){for(var o=new Array,a=n.name||"emitter".concat(n.index),i={loop:!1,autoplay:!1,volume:null==n.volume?1:n.volume},s=function(e){var s="/extensions/".concat(l.name,"/clips"),u=U.Get(s,l._clips,n.clips[e].clip);o.push(l._loadClipAsync("".concat(s,"/").concat(n.clips[e].clip),u).then(function(o){var s=n._babylonSounds[e]=new t.Sound(a,o,r._loader.babylonScene,null,i);s.refDistance=n.refDistance||1,s.maxDistance=n.maxDistance||256,s.rolloffFactor=n.rolloffFactor||1,s.distanceModel=n.distanceModel||"exponential"}))},l=this,u=0;u<n.clips.length;u++)s(u);var c=Promise.all(o).then(function(){var e=n.clips.map(function(e){return e.weight||1}),r=new t.WeightedSound(n.loop||!1,n._babylonSounds,e);n.innerAngle&&(r.directionalConeInnerAngle=2*t.Tools.ToDegrees(n.innerAngle)),n.outerAngle&&(r.directionalConeOuterAngle=2*t.Tools.ToDegrees(n.outerAngle)),n.volume&&(r.volume=n.volume),n._babylonData.sound=r});n._babylonData={loaded:c}}return n._babylonData.loaded},e.prototype._getEventAction=function(e,t,n,r,o){switch(n){case"play":return function(e){var n=(o||0)+(e-r);t.play(n)};case"stop":return function(){t.stop()};case"pause":return function(){t.pause()};default:throw new Error("".concat(e,": Unsupported action ").concat(n))}},e.prototype._loadAnimationEventAsync=function(e,n,r,o,a){var i=this;if(0==a.targetedAnimations.length)return Promise.resolve();var s=a.targetedAnimations[0],l=o.emitter,u=U.Get("/extensions/".concat(this.name,"/emitters"),this._emitters,l);return this._loadEmitterAsync(e,u).then(function(){var n=u._babylonData.sound;if(n){var r=new t.AnimationEvent(o.time,i._getEventAction(e,n,o.action,o.time,o.startOffset));s.animation.addEvent(r),a.onAnimationGroupEndObservable.add(function(){n.stop()}),a.onAnimationGroupPauseObservable.add(function(){n.pause()})}})},e}();K(Ht),H(Ht,!0,function(e){return new Kt(e)});var jt="MSFT_lod",Wt=function(){function e(e){var n,r;this.name=jt,this.order=100,this.maxLODsToLoad=10,this.onNodeLODsLoadedObservable=new t.Observable,this.onMaterialLODsLoadedObservable=new t.Observable,this._bufferLODs=new Array,this._nodeIndexLOD=null,this._nodeSignalLODs=new Array,this._nodePromiseLODs=new Array,this._nodeBufferLODs=new Array,this._materialIndexLOD=null,this._materialSignalLODs=new Array,this._materialPromiseLODs=new Array,this._materialBufferLODs=new Array,this._loader=e,this.maxLODsToLoad=null!==(r=null===(n=this._loader.parent.extensionOptions[jt])||void 0===n?void 0:n.maxLODsToLoad)&&void 0!==r?r:this.maxLODsToLoad,this.enabled=this._loader.isExtensionUsed(jt)}return e.prototype.dispose=function(){this._loader=null,this._nodeIndexLOD=null,this._nodeSignalLODs.length=0,this._nodePromiseLODs.length=0,this._nodeBufferLODs.length=0,this._materialIndexLOD=null,this._materialSignalLODs.length=0,this._materialPromiseLODs.length=0,this._materialBufferLODs.length=0,this.onMaterialLODsLoadedObservable.clear(),this.onNodeLODsLoadedObservable.clear()},e.prototype.onReady=function(){for(var e=this,t=function(t){var r=Promise.all(n._nodePromiseLODs[t]).then(function(){0!==t&&(e._loader.endPerformanceCounter("Node LOD ".concat(t)),e._loader.log("Loaded node LOD ".concat(t))),e.onNodeLODsLoadedObservable.notifyObservers(t),t!==e._nodePromiseLODs.length-1&&(e._loader.startPerformanceCounter("Node LOD ".concat(t+1)),e._loadBufferLOD(e._nodeBufferLODs,t+1),e._nodeSignalLODs[t]&&e._nodeSignalLODs[t].resolve())});n._loader._completePromises.push(r)},n=this,r=0;r<this._nodePromiseLODs.length;r++)t(r);var o=function(t){var n=Promise.all(a._materialPromiseLODs[t]).then(function(){0!==t&&(e._loader.endPerformanceCounter("Material LOD ".concat(t)),e._loader.log("Loaded material LOD ".concat(t))),e.onMaterialLODsLoadedObservable.notifyObservers(t),t!==e._materialPromiseLODs.length-1&&(e._loader.startPerformanceCounter("Material LOD ".concat(t+1)),e._loadBufferLOD(e._materialBufferLODs,t+1),e._materialSignalLODs[t]&&e._materialSignalLODs[t].resolve())});a._loader._completePromises.push(n)},a=this;for(r=0;r<this._materialPromiseLODs.length;r++)o(r)},e.prototype.loadSceneAsync=function(e,t){var n=this._loader.loadSceneAsync(e,t);return this._loadBufferLOD(this._bufferLODs,0),n},e.prototype.loadNodeAsync=function(e,n,r){var o=this;return q.LoadExtensionAsync(e,n,this.name,function(e,s){return a(o,void 0,void 0,function(){var o,a,l,u,c,f=this;return i(this,function(i){switch(i.label){case 0:for(a=this._getLODs(e,n,this._loader.gltf.nodes,s.ids),this._loader.logOpen("".concat(e)),l=function(e){var n=a[e];0!==e&&(u._nodeIndexLOD=e,u._nodeSignalLODs[e]=u._nodeSignalLODs[e]||new t.Deferred);var i=u._loader.loadNodeAsync("/nodes/".concat(n.index),n,function(e){r(e),e.setEnabled(!1)}).then(function(t){if(0!==e){var n=a[e-1];n._babylonTransformNode&&(f._disposeTransformNode(n._babylonTransformNode),delete n._babylonTransformNode)}return t.setEnabled(!0),t});u._nodePromiseLODs[e]=u._nodePromiseLODs[e]||[],0===e?o=i:(u._nodeIndexLOD=null,u._nodePromiseLODs[e].push(i))},u=this,c=0;c<a.length;c++)l(c);return this._loader.logClose(),[4,o];case 1:return[2,i.sent()]}})})})},e.prototype._loadMaterialAsync=function(e,t,n,r,o){var s=this;return this._nodeIndexLOD?null:q.LoadExtensionAsync(e,t,this.name,function(e,l){return a(s,void 0,void 0,function(){var a,s,u,c,f,h=this;return i(this,function(i){switch(i.label){case 0:for(s=this._getLODs(e,t,this._loader.gltf.materials,l.ids),this._loader.logOpen("".concat(e)),u=function(e){var t=s[e];0!==e&&(c._materialIndexLOD=e);var i=c._loader._loadMaterialAsync("/materials/".concat(t.index),t,n,r,function(t){0===e&&o(t)}).then(function(t){if(0!==e){o(t);var n=s[e-1]._data;n[r]&&(h._disposeMaterials([n[r].babylonMaterial]),delete n[r])}return t});c._materialPromiseLODs[e]=c._materialPromiseLODs[e]||[],0===e?a=i:(c._materialIndexLOD=null,c._materialPromiseLODs[e].push(i))},c=this,f=0;f<s.length;f++)u(f);return this._loader.logClose(),[4,a];case 1:return[2,i.sent()]}})})})},e.prototype._loadUriAsync=function(e,n,r){var o=this;if(null!==this._nodeIndexLOD){this._loader.log("deferred");var s=this._nodeIndexLOD-1;return this._nodeSignalLODs[s]=this._nodeSignalLODs[s]||new t.Deferred,this._nodeSignalLODs[this._nodeIndexLOD-1].promise.then(function(){return a(o,void 0,void 0,function(){return i(this,function(t){switch(t.label){case 0:return[4,this._loader.loadUriAsync(e,n,r)];case 1:return[2,t.sent()]}})})})}return null!==this._materialIndexLOD?(this._loader.log("deferred"),s=this._materialIndexLOD-1,this._materialSignalLODs[s]=this._materialSignalLODs[s]||new t.Deferred,this._materialSignalLODs[s].promise.then(function(){return a(o,void 0,void 0,function(){return i(this,function(t){switch(t.label){case 0:return[4,this._loader.loadUriAsync(e,n,r)];case 1:return[2,t.sent()]}})})})):null},e.prototype.loadBufferAsync=function(e,n,r,o){var s=this;if(this._loader.parent.useRangeRequests&&!n.uri){if(!this._loader.bin)throw new Error("".concat(e,": Uri is missing or the binary glTF is missing its binary chunk"));var l=function(e,n){return a(s,void 0,void 0,function(){var a,s,l;return i(this,function(i){switch(i.label){case 0:return s=(a=r)+o-1,(l=e[n])?(l.start=Math.min(l.start,a),l.end=Math.max(l.end,s)):(l={start:a,end:s,loaded:new t.Deferred},e[n]=l),[4,l.loaded.promise.then(function(e){return new Uint8Array(e.buffer,e.byteOffset+r-l.start,o)})];case 1:return[2,i.sent()]}})})};return this._loader.log("deferred"),null!==this._nodeIndexLOD?l(this._nodeBufferLODs,this._nodeIndexLOD):null!==this._materialIndexLOD?l(this._materialBufferLODs,this._materialIndexLOD):l(this._bufferLODs,0)}return null},e.prototype._loadBufferLOD=function(e,t){var n=e[t];n&&(this._loader.log("Loading buffer range [".concat(n.start,"-").concat(n.end,"]")),this._loader.bin.readAsync(n.start,n.end-n.start+1).then(function(e){n.loaded.resolve(e)},function(e){n.loaded.reject(e)}))},e.prototype._getLODs=function(e,t,n,r){if(this.maxLODsToLoad<=0)throw new Error("maxLODsToLoad must be greater than zero");for(var o=[],a=r.length-1;a>=0;a--)if(o.push(U.Get("".concat(e,"/ids/").concat(r[a]),n,r[a])),o.length===this.maxLODsToLoad)return o;return o.push(t),o},e.prototype._disposeTransformNode=function(e){var t=this,n=[],r=e.material;r&&n.push(r);for(var o=0,a=e.getChildMeshes();o<a.length;o++){var i=a[o];i.material&&n.push(i.material)}e.dispose();var s=n.filter(function(e){return t._loader.babylonScene.meshes.every(function(t){return t.material!=e})});this._disposeMaterials(s)},e.prototype._disposeMaterials=function(e){for(var t={},n=0,r=e;n<r.length;n++){for(var o=0,a=(c=r[n]).getActiveTextures();o<a.length;o++){var i=a[o];t[i.uniqueId]=i}c.dispose()}for(var s in t)for(var l=0,u=this._loader.babylonScene.materials;l<u.length;l++){var c;(c=u[l]).hasTexture(t[s])&&delete t[s]}for(var s in t)t[s].dispose()},e}();K(jt),H(jt,!0,function(e){return new Wt(e)});var Ut="MSFT_minecraftMesh",zt=function(){function e(e){this.name=Ut,this._loader=e,this.enabled=this._loader.isExtensionUsed(Ut)}return e.prototype.dispose=function(){this._loader=null},e.prototype.loadMaterialPropertiesAsync=function(e,t,n){var r=this;return q.LoadExtraAsync(e,t,this.name,function(o,s){return a(r,void 0,void 0,function(){var r;return i(this,function(a){switch(a.label){case 0:if(!s)return[3,2];if(!this._loader._pbrMaterialImpl)throw new Error("".concat(o,": Material type not supported"));return r=this._loader.loadMaterialPropertiesAsync(e,t,n),n.needAlphaBlending()&&(n.forceDepthWrite=!0,n.separateCullingPass=!0),n.backFaceCulling=n.forceDepthWrite,n.twoSidedLighting=!0,[4,r];case 1:return[2,a.sent()];case 2:return[2]}})})})},e}();K(Ut),H(Ut,!0,function(e){return new zt(e)});var qt="MSFT_sRGBFactors",Yt=function(){function e(e){this.name=qt,this._loader=e,this.enabled=this._loader.isExtensionUsed(qt)}return e.prototype.dispose=function(){this._loader=null},e.prototype.loadMaterialPropertiesAsync=function(e,t,n){var r=this;return q.LoadExtraAsync(e,t,this.name,function(o,s){return a(r,void 0,void 0,function(){var r,o,a;return i(this,function(i){switch(i.label){case 0:return s?(r=this._loader._getOrCreateMaterialAdapter(n),o=this._loader.loadMaterialPropertiesAsync(e,t,n),a=n.getScene().getEngine().useExactSrgbConversions,r.baseColorTexture||r.baseColor.toLinearSpaceToRef(r.baseColor,a),r.specularColorTexture||r.specularColor.toLinearSpaceToRef(r.specularColor,a),[4,o]):[3,2];case 1:return[2,i.sent()];case 2:return[2]}})})})},e}();function Xt(e){var t=e.split(":");return Qt({op:t[0],extension:t[1]})}function Qt(e,n){var r;void 0===n&&(n=!0);var o=e.extension?null===(r=Zt[e.extension])||void 0===r?void 0:r[e.op]:$t[e.op];if(!o&&(t.Logger.Warn("No mapping found for operation ".concat(e.op," and extension ").concat(e.extension||"KHR_interactivity")),n)){var a={},i={flows:{}};if(e.inputValueSockets)for(var s in a.values={},e.inputValueSockets)a.values[s]={name:s};return e.outputValueSockets&&(i.values={},Object.keys(e.outputValueSockets).forEach(function(e){i.values[e]={name:e}})),{blocks:[],inputs:a,outputs:i}}return o}function Jt(e,t,n){Zt[t]||(Zt[t]={}),Zt[t][e]=n}K(qt),H(qt,!0,function(e){return new Yt(e)});var Zt={BABYLON:{"flow/log":{blocks:["FlowGraphConsoleLogBlock"],inputs:{values:{message:{name:"message"}}}}}},$t={"event/onStart":{blocks:["FlowGraphSceneReadyEventBlock"],outputs:{flows:{out:{name:"done"}}}},"event/onTick":{blocks:["FlowGraphSceneTickEventBlock"],inputs:{},outputs:{values:{timeSinceLastTick:{name:"deltaTime",gltfType:"number"}},flows:{out:{name:"done"}}}},"event/send":{blocks:["FlowGraphSendCustomEventBlock"],extraProcessor:function(e,t,n,r,o){var a;if("event/send"!==t.op||!e.configuration||1!==Object.keys(e.configuration).length)throw new Error("Receive event should have a single configuration object, the event itself");var i=null===(a=e.configuration.event.value)||void 0===a?void 0:a[0];if("number"!=typeof i)throw new Error("Event id should be a number");var s=r.arrays.events[i],l=o[0];return l.config||(l.config={}),l.config.eventId=s.eventId,l.config.eventData=s.eventData,o}},"event/receive":{blocks:["FlowGraphReceiveCustomEventBlock"],outputs:{flows:{out:{name:"done"}}},validation:function(e,n){var r,o;if(!e.configuration)return t.Logger.Error("Receive event should have a configuration object"),{valid:!1,error:"Receive event should have a configuration object"};var a=e.configuration.event;if(!a)return t.Logger.Error("Receive event should have a single configuration object, the event itself"),{valid:!1,error:"Receive event should have a single configuration object, the event itself"};var i=null===(r=a.value)||void 0===r?void 0:r[0];return"number"!=typeof i?(t.Logger.Error("Event id should be a number"),{valid:!1,error:"Event id should be a number"}):(null===(o=n.events)||void 0===o?void 0:o[i])?{valid:!0}:(t.Logger.Error("Event with id ".concat(i," not found")),{valid:!1,error:"Event with id ".concat(i," not found")})},extraProcessor:function(e,t,n,r,o){var a;if("event/receive"!==t.op||!e.configuration||1!==Object.keys(e.configuration).length)throw new Error("Receive event should have a single configuration object, the event itself");var i=null===(a=e.configuration.event.value)||void 0===a?void 0:a[0];if("number"!=typeof i)throw new Error("Event id should be a number");var s=r.arrays.events[i],l=o[0];return l.config||(l.config={}),l.config.eventId=s.eventId,l.config.eventData=s.eventData,o}},"math/E":en("FlowGraphEBlock"),"math/Pi":en("FlowGraphPIBlock"),"math/Inf":en("FlowGraphInfBlock"),"math/NaN":en("FlowGraphNaNBlock"),"math/abs":en("FlowGraphAbsBlock"),"math/sign":en("FlowGraphSignBlock"),"math/trunc":en("FlowGraphTruncBlock"),"math/floor":en("FlowGraphFloorBlock"),"math/ceil":en("FlowGraphCeilBlock"),"math/round":{blocks:["FlowGraphRoundBlock"],configuration:{},inputs:{values:{a:{name:"a"}}},outputs:{values:{value:{name:"value"}}},extraProcessor:function(e,t,n,r,o){var a;return(a=o[0]).config||(a.config={}),o[0].config.roundHalfAwayFromZero=!0,o}},"math/fract":en("FlowGraphFractBlock"),"math/neg":en("FlowGraphNegationBlock"),"math/add":en("FlowGraphAddBlock",["a","b"],!0),"math/sub":en("FlowGraphSubtractBlock",["a","b"],!0),"math/mul":{blocks:["FlowGraphMultiplyBlock"],extraProcessor:function(e,t,n,r,o){var a;(a=o[0]).config||(a.config={}),o[0].config.useMatrixPerComponent=!0,o[0].config.preventIntegerFloatArithmetic=!0;var i=-1;return Object.keys(e.values||{}).find(function(t){var n;return void 0!==(null===(n=e.values)||void 0===n?void 0:n[t].type)&&(i=e.values[t].type,!0)}),-1!==i&&(o[0].config.type=r.arrays.types[i].flowGraphType),o},validation:function(e){return e.values?tn(e):{valid:!0}}},"math/div":en("FlowGraphDivideBlock",["a","b"],!0),"math/rem":en("FlowGraphModuloBlock",["a","b"]),"math/min":en("FlowGraphMinBlock",["a","b"]),"math/max":en("FlowGraphMaxBlock",["a","b"]),"math/clamp":en("FlowGraphClampBlock",["a","b","c"]),"math/saturate":en("FlowGraphSaturateBlock"),"math/mix":en("FlowGraphMathInterpolationBlock",["a","b","c"]),"math/eq":en("FlowGraphEqualityBlock",["a","b"]),"math/lt":en("FlowGraphLessThanBlock",["a","b"]),"math/le":en("FlowGraphLessThanOrEqualBlock",["a","b"]),"math/gt":en("FlowGraphGreaterThanBlock",["a","b"]),"math/ge":en("FlowGraphGreaterThanOrEqualBlock",["a","b"]),"math/isNaN":en("FlowGraphIsNaNBlock"),"math/isInf":en("FlowGraphIsInfBlock"),"math/select":{blocks:["FlowGraphConditionalBlock"],inputs:{values:{condition:{name:"condition"},a:{name:"onTrue"},b:{name:"onFalse"}}},outputs:{values:{value:{name:"output"}}}},"math/random":{blocks:["FlowGraphRandomBlock"],outputs:{values:{value:{name:"value"}}}},"math/sin":en("FlowGraphSinBlock"),"math/cos":en("FlowGraphCosBlock"),"math/tan":en("FlowGraphTanBlock"),"math/asin":en("FlowGraphASinBlock"),"math/acos":en("FlowGraphACosBlock"),"math/atan":en("FlowGraphATanBlock"),"math/atan2":en("FlowGraphATan2Block",["a","b"]),"math/sinh":en("FlowGraphSinhBlock"),"math/cosh":en("FlowGraphCoshBlock"),"math/tanh":en("FlowGraphTanhBlock"),"math/asinh":en("FlowGraphASinhBlock"),"math/acosh":en("FlowGraphACoshBlock"),"math/atanh":en("FlowGraphATanhBlock"),"math/exp":en("FlowGraphExponentialBlock"),"math/log":en("FlowGraphLogBlock"),"math/log2":en("FlowGraphLog2Block"),"math/log10":en("FlowGraphLog10Block"),"math/sqrt":en("FlowGraphSquareRootBlock"),"math/cbrt":en("FlowGraphCubeRootBlock"),"math/pow":en("FlowGraphPowerBlock",["a","b"]),"math/length":en("FlowGraphLengthBlock"),"math/normalize":en("FlowGraphNormalizeBlock"),"math/dot":en("FlowGraphDotBlock",["a","b"]),"math/cross":en("FlowGraphCrossBlock",["a","b"]),"math/rotate2D":{blocks:["FlowGraphRotate2DBlock"],inputs:{values:{a:{name:"a"},angle:{name:"b"}}},outputs:{values:{value:{name:"value"}}}},"math/rotate3D":{blocks:["FlowGraphRotate3DBlock"],inputs:{values:{a:{name:"a"},rotation:{name:"b"}}},outputs:{values:{value:{name:"value"}}}},"math/transform":{blocks:["FlowGraphTransformVectorBlock"],inputs:{values:{a:{name:"a"},b:{name:"b"}}},outputs:{values:{value:{name:"value"}}}},"math/combine2":{blocks:["FlowGraphCombineVector2Block"],inputs:{values:{a:{name:"input_0",gltfType:"number"},b:{name:"input_1",gltfType:"number"}}},outputs:{values:{value:{name:"value"}}}},"math/combine3":{blocks:["FlowGraphCombineVector3Block"],inputs:{values:{a:{name:"input_0",gltfType:"number"},b:{name:"input_1",gltfType:"number"},c:{name:"input_2",gltfType:"number"}}},outputs:{values:{value:{name:"value"}}}},"math/combine4":{blocks:["FlowGraphCombineVector4Block"],inputs:{values:{a:{name:"input_0",gltfType:"number"},b:{name:"input_1",gltfType:"number"},c:{name:"input_2",gltfType:"number"},d:{name:"input_3",gltfType:"number"}}},outputs:{values:{value:{name:"value"}}}},"math/extract2":{blocks:["FlowGraphExtractVector2Block"],inputs:{values:{a:{name:"input",gltfType:"number"}}},outputs:{values:{0:{name:"output_0"},1:{name:"output_1"}}}},"math/extract3":{blocks:["FlowGraphExtractVector3Block"],inputs:{values:{a:{name:"input",gltfType:"number"}}},outputs:{values:{0:{name:"output_0"},1:{name:"output_1"},2:{name:"output_2"}}}},"math/extract4":{blocks:["FlowGraphExtractVector4Block"],inputs:{values:{a:{name:"input",gltfType:"number"}}},outputs:{values:{0:{name:"output_0"},1:{name:"output_1"},2:{name:"output_2"},3:{name:"output_3"}}}},"math/transpose":en("FlowGraphTransposeBlock"),"math/determinant":en("FlowGraphDeterminantBlock"),"math/inverse":en("FlowGraphInvertMatrixBlock"),"math/matMul":en("FlowGraphMatrixMultiplicationBlock",["a","b"]),"math/matCompose":{blocks:["FlowGraphMatrixCompose"],inputs:{values:{translation:{name:"position",gltfType:"float3"},rotation:{name:"rotationQuaternion",gltfType:"float4"},scale:{name:"scaling",gltfType:"float3"}}},outputs:{values:{value:{name:"value"}}},extraProcessor:function(e,t,n,r,o,a){var i=o[0].dataInputs.find(function(e){return"rotationQuaternion"===e.name});if(!i)throw new Error("Rotation quaternion input not found");return a._connectionValues[i.uniqueId]&&(a._connectionValues[i.uniqueId].type="Quaternion"),o}},"math/matDecompose":{blocks:["FlowGraphMatrixDecompose"],inputs:{values:{a:{name:"input",gltfType:"number"}}},outputs:{values:{translation:{name:"position"},rotation:{name:"rotationQuaternion"},scale:{name:"scaling"}}}},"math/quatConjugate":en("FlowGraphConjugateBlock",["a"]),"math/quatMul":{blocks:["FlowGraphMultiplyBlock"],inputs:{values:{a:{name:"a",gltfType:"vector4"},b:{name:"b",gltfType:"vector4"}}},outputs:{values:{value:{name:"value"}}},extraProcessor:function(e,t,n,r,o){var a;return(a=o[0]).config||(a.config={}),o[0].config.type="Quaternion",o}},"math/quatAngleBetween":en("FlowGraphAngleBetweenBlock",["a","b"]),"math/quatFromAxisAngle":{blocks:["FlowGraphQuaternionFromAxisAngleBlock"],inputs:{values:{axis:{name:"a",gltfType:"float3"},angle:{name:"b",gltfType:"number"}}},outputs:{values:{value:{name:"value"}}}},"math/quatToAxisAngle":en("FlowGraphAxisAngleFromQuaternionBlock",["a"]),"math/quatFromDirections":en("FlowGraphQuaternionFromDirectionsBlock",["a","b"]),"math/combine2x2":{blocks:["FlowGraphCombineMatrix2DBlock"],inputs:{values:{a:{name:"input_0",gltfType:"number"},b:{name:"input_1",gltfType:"number"},c:{name:"input_2",gltfType:"number"},d:{name:"input_3",gltfType:"number"}}},outputs:{values:{value:{name:"value"}}},extraProcessor:function(e,t,n,r,o){var a;return(a=o[0]).config||(a.config={}),o[0].config.inputIsColumnMajor=!0,o}},"math/extract2x2":{blocks:["FlowGraphExtractMatrix2DBlock"],inputs:{values:{a:{name:"input",gltfType:"float2x2"}}},outputs:{values:{0:{name:"output_0"},1:{name:"output_1"},2:{name:"output_2"},3:{name:"output_3"}}}},"math/combine3x3":{blocks:["FlowGraphCombineMatrix3DBlock"],inputs:{values:{a:{name:"input_0",gltfType:"number"},b:{name:"input_1",gltfType:"number"},c:{name:"input_2",gltfType:"number"},d:{name:"input_3",gltfType:"number"},e:{name:"input_4",gltfType:"number"},f:{name:"input_5",gltfType:"number"},g:{name:"input_6",gltfType:"number"},h:{name:"input_7",gltfType:"number"},i:{name:"input_8",gltfType:"number"}}},outputs:{values:{value:{name:"value"}}},extraProcessor:function(e,t,n,r,o){var a;return(a=o[0]).config||(a.config={}),o[0].config.inputIsColumnMajor=!0,o}},"math/extract3x3":{blocks:["FlowGraphExtractMatrix3DBlock"],inputs:{values:{a:{name:"input",gltfType:"float3x3"}}},outputs:{values:{0:{name:"output_0"},1:{name:"output_1"},2:{name:"output_2"},3:{name:"output_3"},4:{name:"output_4"},5:{name:"output_5"},6:{name:"output_6"},7:{name:"output_7"},8:{name:"output_8"}}}},"math/combine4x4":{blocks:["FlowGraphCombineMatrixBlock"],inputs:{values:{a:{name:"input_0",gltfType:"number"},b:{name:"input_1",gltfType:"number"},c:{name:"input_2",gltfType:"number"},d:{name:"input_3",gltfType:"number"},e:{name:"input_4",gltfType:"number"},f:{name:"input_5",gltfType:"number"},g:{name:"input_6",gltfType:"number"},h:{name:"input_7",gltfType:"number"},i:{name:"input_8",gltfType:"number"},j:{name:"input_9",gltfType:"number"},k:{name:"input_10",gltfType:"number"},l:{name:"input_11",gltfType:"number"},m:{name:"input_12",gltfType:"number"},n:{name:"input_13",gltfType:"number"},o:{name:"input_14",gltfType:"number"},p:{name:"input_15",gltfType:"number"}}},outputs:{values:{value:{name:"value"}}},extraProcessor:function(e,t,n,r,o){var a;return(a=o[0]).config||(a.config={}),o[0].config.inputIsColumnMajor=!0,o}},"math/extract4x4":{blocks:["FlowGraphExtractMatrixBlock"],configuration:{},inputs:{values:{a:{name:"input",gltfType:"number"}}},outputs:{values:{0:{name:"output_0"},1:{name:"output_1"},2:{name:"output_2"},3:{name:"output_3"},4:{name:"output_4"},5:{name:"output_5"},6:{name:"output_6"},7:{name:"output_7"},8:{name:"output_8"},9:{name:"output_9"},10:{name:"output_10"},11:{name:"output_11"},12:{name:"output_12"},13:{name:"output_13"},14:{name:"output_14"},15:{name:"output_15"}}}},"math/not":{blocks:["FlowGraphBitwiseNotBlock"],inputs:{values:{a:{name:"a"}}},outputs:{values:{value:{name:"value"}}},extraProcessor:function(e,t,n,r,o,a){var i,s,l;(l=o[0]).config||(l.config={});var u=o[0].dataInputs[0];return o[0].config.valueType=null!==(s=null===(i=a._connectionValues[u.uniqueId])||void 0===i?void 0:i.type)&&void 0!==s?s:"FlowGraphInteger",o}},"math/and":{blocks:["FlowGraphBitwiseAndBlock"],inputs:{values:{a:{name:"a"},b:{name:"b"}}},outputs:{values:{value:{name:"value"}}},extraProcessor:function(e,t,n,r,o,a){var i,s,l,u,c;(c=o[0]).config||(c.config={});var f=o[0].dataInputs[0],h=o[0].dataInputs[1];return o[0].config.valueType=null!==(u=null!==(s=null===(i=a._connectionValues[f.uniqueId])||void 0===i?void 0:i.type)&&void 0!==s?s:null===(l=a._connectionValues[h.uniqueId])||void 0===l?void 0:l.type)&&void 0!==u?u:"FlowGraphInteger",o}},"math/or":{blocks:["FlowGraphBitwiseOrBlock"],inputs:{values:{a:{name:"a"},b:{name:"b"}}},outputs:{values:{value:{name:"value"}}},extraProcessor:function(e,t,n,r,o,a){var i,s,l,u,c;(c=o[0]).config||(c.config={});var f=o[0].dataInputs[0],h=o[0].dataInputs[1];return o[0].config.valueType=null!==(u=null!==(s=null===(i=a._connectionValues[f.uniqueId])||void 0===i?void 0:i.type)&&void 0!==s?s:null===(l=a._connectionValues[h.uniqueId])||void 0===l?void 0:l.type)&&void 0!==u?u:"FlowGraphInteger",o}},"math/xor":{blocks:["FlowGraphBitwiseXorBlock"],inputs:{values:{a:{name:"a"},b:{name:"b"}}},outputs:{values:{value:{name:"value"}}},extraProcessor:function(e,t,n,r,o,a){var i,s,l,u,c;(c=o[0]).config||(c.config={});var f=o[0].dataInputs[0],h=o[0].dataInputs[1];return o[0].config.valueType=null!==(u=null!==(s=null===(i=a._connectionValues[f.uniqueId])||void 0===i?void 0:i.type)&&void 0!==s?s:null===(l=a._connectionValues[h.uniqueId])||void 0===l?void 0:l.type)&&void 0!==u?u:"FlowGraphInteger",o}},"math/asr":en("FlowGraphBitwiseRightShiftBlock",["a","b"]),"math/lsl":en("FlowGraphBitwiseLeftShiftBlock",["a","b"]),"math/clz":en("FlowGraphLeadingZerosBlock"),"math/ctz":en("FlowGraphTrailingZerosBlock"),"math/popcnt":en("FlowGraphOneBitsCounterBlock"),"math/rad":en("FlowGraphDegToRadBlock"),"math/deg":en("FlowGraphRadToDegBlock"),"type/boolToInt":en("FlowGraphBooleanToInt"),"type/boolToFloat":en("FlowGraphBooleanToFloat"),"type/intToBool":en("FlowGraphIntToBoolean"),"type/intToFloat":en("FlowGraphIntToFloat"),"type/floatToInt":en("FlowGraphFloatToInt"),"type/floatToBool":en("FlowGraphFloatToBoolean"),"flow/sequence":{blocks:["FlowGraphSequenceBlock"],extraProcessor:function(e,t,n,r,o){var a=o[0];return a.config||(a.config={}),a.config.outputSignalCount=Object.keys(e.flows||[]).length,a.signalOutputs.forEach(function(e,t){e.name="out_"+t}),o}},"flow/branch":{blocks:["FlowGraphBranchBlock"],outputs:{flows:{true:{name:"onTrue"},false:{name:"onFalse"}}}},"flow/switch":{blocks:["FlowGraphSwitchBlock"],configuration:{cases:{name:"cases",isArray:!0,inOptions:!0,defaultValue:[]}},inputs:{values:{selection:{name:"case"},default:{name:"default"}}},validation:function(e){var n,r=null===(n=e.configuration)||void 0===n?void 0:n.cases;if(r&&r.value){if(!r.value.every(function(e){return"number"==typeof e&&/^-?\d+$/.test(e.toString())}))return t.Logger.Warn("Switch cases should be integers. Using empty array instead."),r.value=[],{valid:!0};var o=new Set(r.value);r.value=Array.from(o)}return{valid:!0}},extraProcessor:function(e,t,n,r,o){if("flow/switch"!==t.op||!e.flows||0===Object.keys(e.flows).length)throw new Error("Switch should have a single configuration object, the cases array");return o[0].signalOutputs.forEach(function(e){"default"!==e.name&&(e.name="out_"+e.name)}),o}},"flow/while":{blocks:["FlowGraphWhileLoopBlock"],outputs:{flows:{loopBody:{name:"executionFlow"}}}},"flow/for":{blocks:["FlowGraphForLoopBlock"],configuration:{initialIndex:{name:"initialIndex",gltfType:"number",inOptions:!0,defaultValue:0}},inputs:{values:{startIndex:{name:"startIndex",gltfType:"number"},endIndex:{name:"endIndex",gltfType:"number"}}},outputs:{values:{index:{name:"index"}},flows:{loopBody:{name:"executionFlow"}}},extraProcessor:function(e,t,n,r,o){var a=o[0];return a.config||(a.config={}),a.config.incrementIndexWhenLoopDone=!0,o}},"flow/doN":{blocks:["FlowGraphDoNBlock"],configuration:{},inputs:{values:{n:{name:"maxExecutions",gltfType:"number"}}},outputs:{values:{currentCount:{name:"executionCount"}}}},"flow/multiGate":{blocks:["FlowGraphMultiGateBlock"],configuration:{isRandom:{name:"isRandom",gltfType:"boolean",inOptions:!0,defaultValue:!1},isLoop:{name:"isLoop",gltfType:"boolean",inOptions:!0,defaultValue:!1}},extraProcessor:function(e,t,n,r,o){if("flow/multiGate"!==t.op||!e.flows||0===Object.keys(e.flows).length)throw new Error("MultiGate should have a single configuration object, the number of output flows");var a=o[0];return a.config||(a.config={}),a.config.outputSignalCount=Object.keys(e.flows).length,a.signalOutputs.forEach(function(e,t){e.name="out_"+t}),o}},"flow/waitAll":{blocks:["FlowGraphWaitAllBlock"],configuration:{inputFlows:{name:"inputSignalCount",gltfType:"number",inOptions:!0,defaultValue:0}},inputs:{flows:{reset:{name:"reset"},"[segment]":{name:"in_$1"}}},validation:function(e){var t,n,r;return"number"!=typeof(null===(r=null===(n=null===(t=e.configuration)||void 0===t?void 0:t.inputFlows)||void 0===n?void 0:n.value)||void 0===r?void 0:r[0])&&(e.configuration=e.configuration||{inputFlows:{value:[0]}},e.configuration.inputFlows.value=[0]),{valid:!0}}},"flow/throttle":{blocks:["FlowGraphThrottleBlock"],outputs:{flows:{err:{name:"error"}}}},"flow/setDelay":{blocks:["FlowGraphSetDelayBlock"],outputs:{flows:{err:{name:"error"}}}},"flow/cancelDelay":{blocks:["FlowGraphCancelDelayBlock"]},"variable/get":{blocks:["FlowGraphGetVariableBlock"],validation:function(e){var n,r;return(null===(r=null===(n=e.configuration)||void 0===n?void 0:n.variable)||void 0===r?void 0:r.value)?{valid:!0}:(t.Logger.Error("Variable get block should have a variable configuration"),{valid:!1,error:"Variable get block should have a variable configuration"})},configuration:{variable:{name:"variable",gltfType:"number",flowGraphType:"string",inOptions:!0,isVariable:!0,dataTransformer:function(e,t){return t.getVariableName(e)}}}},"variable/set":{blocks:["FlowGraphSetVariableBlock"],configuration:{variables:{name:"variables",gltfType:"number",flowGraphType:"string",inOptions:!0,isArray:!0,dataTransformer:function(e,t){return e.map(function(e){return t.getVariableName(e)})}}},extraProcessor:function(e,t,n,r,o){return o[0].dataInputs.forEach(function(e){e.name=r.getVariableName(+e.name)}),o}},"variable/interpolate":{blocks:["FlowGraphInterpolationBlock","FlowGraphContextBlock","FlowGraphPlayAnimationBlock","FlowGraphBezierCurveEasing","FlowGraphGetVariableBlock"],configuration:{variable:{name:"propertyName",inOptions:!0,isVariable:!0,dataTransformer:function(e,t){return t.getVariableName(e)}},useSlerp:{name:"animationType",inOptions:!0,defaultValue:!1,dataTransformer:function(e){return!0===e?"Quaternion":void 0}}},inputs:{values:{value:{name:"value_1"},duration:{name:"duration_1",gltfType:"number"},p1:{name:"controlPoint1",toBlock:"FlowGraphBezierCurveEasing"},p2:{name:"controlPoint2",toBlock:"FlowGraphBezierCurveEasing"}},flows:{in:{name:"in",toBlock:"FlowGraphPlayAnimationBlock"}}},outputs:{flows:{err:{name:"error",toBlock:"FlowGraphPlayAnimationBlock"},out:{name:"out",toBlock:"FlowGraphPlayAnimationBlock"},done:{name:"done",toBlock:"FlowGraphPlayAnimationBlock"}}},interBlockConnectors:[{input:"object",output:"userVariables",inputBlockIndex:2,outputBlockIndex:1,isVariable:!0},{input:"animation",output:"animation",inputBlockIndex:2,outputBlockIndex:0,isVariable:!0},{input:"easingFunction",output:"easingFunction",inputBlockIndex:0,outputBlockIndex:3,isVariable:!0},{input:"value_0",output:"value",inputBlockIndex:0,outputBlockIndex:4,isVariable:!0}],extraProcessor:function(e,n,r,o,a){var i,s,l,u,c,f,h=a[0],p=null===(s=null===(i=e.configuration)||void 0===i?void 0:i.variable.value)||void 0===s?void 0:s[0];if("number"!=typeof p)throw t.Logger.Error("Variable index is not defined for variable interpolation block"),new Error("Variable index is not defined for variable interpolation block");var d=o.arrays.staticVariables[p];void 0===(null===(u=null===(l=h.config)||void 0===l?void 0:l.animationType)||void 0===u?void 0:u.value)&&(h.config||(h.config={}),(c=h.config).animationType||(c.animationType={}),h.config.animationType.value=t.getAnimationTypeByFlowGraphType(d.type));var m=a[4];return m.config||(m.config={}),(f=m.config).variable||(f.variable={}),m.config.variable.value=o.getVariableName(p),a}},"pointer/get":{blocks:["FlowGraphGetPropertyBlock","FlowGraphJsonPointerParserBlock"],configuration:{pointer:{name:"jsonPointer",toBlock:"FlowGraphJsonPointerParserBlock"}},inputs:{values:{"[segment]":{name:"$1",toBlock:"FlowGraphJsonPointerParserBlock"}}},interBlockConnectors:[{input:"object",output:"object",inputBlockIndex:0,outputBlockIndex:1,isVariable:!0},{input:"propertyName",output:"propertyName",inputBlockIndex:0,outputBlockIndex:1,isVariable:!0},{input:"customGetFunction",output:"getFunction",inputBlockIndex:0,outputBlockIndex:1,isVariable:!0}],extraProcessor:function(e,t,n,r,o){return o.forEach(function(e){"FlowGraphJsonPointerParserBlock"===e.className&&(e.config||(e.config={}),e.config.outputValue=!0)}),o}},"pointer/set":{blocks:["FlowGraphSetPropertyBlock","FlowGraphJsonPointerParserBlock"],configuration:{pointer:{name:"jsonPointer",toBlock:"FlowGraphJsonPointerParserBlock"}},inputs:{values:{value:{name:"value"},"[segment]":{name:"$1",toBlock:"FlowGraphJsonPointerParserBlock"}}},outputs:{flows:{err:{name:"error"}}},interBlockConnectors:[{input:"object",output:"object",inputBlockIndex:0,outputBlockIndex:1,isVariable:!0},{input:"propertyName",output:"propertyName",inputBlockIndex:0,outputBlockIndex:1,isVariable:!0},{input:"customSetFunction",output:"setFunction",inputBlockIndex:0,outputBlockIndex:1,isVariable:!0}],extraProcessor:function(e,t,n,r,o){return o.forEach(function(e){"FlowGraphJsonPointerParserBlock"===e.className&&(e.config||(e.config={}),e.config.outputValue=!0)}),o}},"pointer/interpolate":{blocks:["FlowGraphInterpolationBlock","FlowGraphJsonPointerParserBlock","FlowGraphPlayAnimationBlock","FlowGraphBezierCurveEasing"],configuration:{pointer:{name:"jsonPointer",toBlock:"FlowGraphJsonPointerParserBlock"}},inputs:{values:{value:{name:"value_1"},"[segment]":{name:"$1",toBlock:"FlowGraphJsonPointerParserBlock"},duration:{name:"duration_1",gltfType:"number"},p1:{name:"controlPoint1",toBlock:"FlowGraphBezierCurveEasing"},p2:{name:"controlPoint2",toBlock:"FlowGraphBezierCurveEasing"}},flows:{in:{name:"in",toBlock:"FlowGraphPlayAnimationBlock"}}},outputs:{flows:{err:{name:"error",toBlock:"FlowGraphPlayAnimationBlock"},out:{name:"out",toBlock:"FlowGraphPlayAnimationBlock"},done:{name:"done",toBlock:"FlowGraphPlayAnimationBlock"}}},interBlockConnectors:[{input:"object",output:"object",inputBlockIndex:2,outputBlockIndex:1,isVariable:!0},{input:"propertyName",output:"propertyName",inputBlockIndex:0,outputBlockIndex:1,isVariable:!0},{input:"customBuildAnimation",output:"generateAnimationsFunction",inputBlockIndex:0,outputBlockIndex:1,isVariable:!0},{input:"animation",output:"animation",inputBlockIndex:2,outputBlockIndex:0,isVariable:!0},{input:"easingFunction",output:"easingFunction",inputBlockIndex:0,outputBlockIndex:3,isVariable:!0},{input:"value_0",output:"value",inputBlockIndex:0,outputBlockIndex:1,isVariable:!0}],extraProcessor:function(e,t,n,r,o){return o.forEach(function(t){"FlowGraphJsonPointerParserBlock"===t.className?(t.config||(t.config={}),t.config.outputValue=!0):"FlowGraphInterpolationBlock"===t.className&&(t.config||(t.config={}),Object.keys(e.values||[]).forEach(function(n){var o,a=null===(o=e.values)||void 0===o?void 0:o[n];if("value"===n&&a){var i=a.type;void 0!==i&&(t.config.animationType=r.arrays.types[i].flowGraphType)}}))}),o}},"animation/start":{blocks:["FlowGraphPlayAnimationBlock","FlowGraphArrayIndexBlock","KHR_interactivity/FlowGraphGLTFDataProvider"],inputs:{values:{animation:{name:"index",gltfType:"number",toBlock:"FlowGraphArrayIndexBlock"},speed:{name:"speed",gltfType:"number"},startTime:{name:"from",gltfType:"number",dataTransformer:function(e,t){return[e[0]*t._animationTargetFps]}},endTime:{name:"to",gltfType:"number",dataTransformer:function(e,t){return[e[0]*t._animationTargetFps]}}}},outputs:{flows:{err:{name:"error"}}},interBlockConnectors:[{input:"animationGroup",output:"value",inputBlockIndex:0,outputBlockIndex:1,isVariable:!0},{input:"array",output:"animationGroups",inputBlockIndex:1,outputBlockIndex:2,isVariable:!0}],extraProcessor:function(e,t,n,r,o,a,i){var s=o[o.length-1];return s.config||(s.config={}),s.config.glTF=i,o}},"animation/stop":{blocks:["FlowGraphStopAnimationBlock","FlowGraphArrayIndexBlock","KHR_interactivity/FlowGraphGLTFDataProvider"],inputs:{values:{animation:{name:"index",gltfType:"number",toBlock:"FlowGraphArrayIndexBlock"}}},outputs:{flows:{err:{name:"error"}}},interBlockConnectors:[{input:"animationGroup",output:"value",inputBlockIndex:0,outputBlockIndex:1,isVariable:!0},{input:"array",output:"animationGroups",inputBlockIndex:1,outputBlockIndex:2,isVariable:!0}],extraProcessor:function(e,t,n,r,o,a,i){var s=o[o.length-1];return s.config||(s.config={}),s.config.glTF=i,o}},"animation/stopAt":{blocks:["FlowGraphStopAnimationBlock","FlowGraphArrayIndexBlock","KHR_interactivity/FlowGraphGLTFDataProvider"],configuration:{},inputs:{values:{animation:{name:"index",gltfType:"number",toBlock:"FlowGraphArrayIndexBlock"},stopTime:{name:"stopAtFrame",gltfType:"number",dataTransformer:function(e,t){return[e[0]*t._animationTargetFps]}}}},outputs:{flows:{err:{name:"error"}}},interBlockConnectors:[{input:"animationGroup",output:"value",inputBlockIndex:0,outputBlockIndex:1,isVariable:!0},{input:"array",output:"animationGroups",inputBlockIndex:1,outputBlockIndex:2,isVariable:!0}],extraProcessor:function(e,t,n,r,o,a,i){var s=o[o.length-1];return s.config||(s.config={}),s.config.glTF=i,o}},"math/switch":{blocks:["FlowGraphDataSwitchBlock"],configuration:{cases:{name:"cases",isArray:!0,inOptions:!0,defaultValue:[]}},inputs:{values:{selection:{name:"case"}}},validation:function(e){var n,r=null===(n=e.configuration)||void 0===n?void 0:n.cases;if(r&&r.value){if(!r.value.every(function(e){return"number"==typeof e&&/^-?\d+$/.test(e.toString())}))return t.Logger.Warn("Switch cases should be integers. Using empty array instead."),r.value=[],{valid:!0};var o=new Set(r.value);r.value=Array.from(o)}return{valid:!0}},extraProcessor:function(e,t,n,r,o){var a=o[0];return a.dataInputs.forEach(function(e){"default"!==e.name&&"case"!==e.name&&(e.name="in_"+e.name)}),a.config||(a.config={}),a.config.treatCasesAsIntegers=!0,o}},"debug/log":{blocks:["FlowGraphConsoleLogBlock"],configuration:{message:{name:"messageTemplate",inOptions:!0}}}};function en(e,t,n){return void 0===t&&(t=["a"]),{blocks:[e],inputs:{values:t.reduce(function(e,t){return e[t]={name:t},e},{})},outputs:{values:{value:{name:"value"}}},extraProcessor:function(e,t,r,o,a){var i;if(n){(i=a[0]).config||(i.config={}),a[0].config.preventIntegerFloatArithmetic=!0;var s=-1;Object.keys(e.values||{}).find(function(t){var n;return void 0!==(null===(n=e.values)||void 0===n?void 0:n[t].type)&&(s=e.values[t].type,!0)}),-1!==s&&(a[0].config.type=o.arrays.types[s].flowGraphType)}return a},validation:function(e){return n?tn(e):{valid:!0}}}}function tn(e){if(e.values){var t=Object.keys(e.values).map(function(t){return e.values[t].type}).filter(function(e){return void 0!==e});if(!t.every(function(e){return e===t[0]}))return{valid:!1,error:"All inputs must be of the same type"}}return{valid:!0}}function nn(){return Object.keys($t)}var rn={float:{length:1,flowGraphType:"number",elementType:"number"},bool:{length:1,flowGraphType:"boolean",elementType:"boolean"},float2:{length:2,flowGraphType:"Vector2",elementType:"number"},float3:{length:3,flowGraphType:"Vector3",elementType:"number"},float4:{length:4,flowGraphType:"Vector4",elementType:"number"},float4x4:{length:16,flowGraphType:"Matrix",elementType:"number"},float2x2:{length:4,flowGraphType:"Matrix2D",elementType:"number"},float3x3:{length:9,flowGraphType:"Matrix3D",elementType:"number"},int:{length:1,flowGraphType:"FlowGraphInteger",elementType:"number"}},on=function(){function e(e,t,n){void 0===n&&(n=60),this._interactivityGraph=e,this._gltf=t,this._animationTargetFps=n,this._types=[],this._mappings=[],this._staticVariables=[],this._events=[],this._internalEventsCounter=0,this._nodes=[],this._parseTypes(),this._parseDeclarations(),this._parseVariables(),this._parseEvents(),this._parseNodes()}return Object.defineProperty(e.prototype,"arrays",{get:function(){return{types:this._types,mappings:this._mappings,staticVariables:this._staticVariables,events:this._events,nodes:this._nodes}},enumerable:!1,configurable:!0}),e.prototype._parseTypes=function(){if(this._interactivityGraph.types)for(var e=0,t=this._interactivityGraph.types;e<t.length;e++){var n=t[e];this._types.push(rn[n.signature])}},e.prototype._parseDeclarations=function(){if(this._interactivityGraph.declarations)for(var e=0,n=this._interactivityGraph.declarations;e<n.length;e++){var r=n[e],o=Qt(r);if(!o)throw t.Logger.Error(["No mapping found for declaration",r]),new Error("Error parsing declarations");this._mappings.push({flowGraphMapping:o,fullOperationName:r.extension?r.op+":"+r.extension:r.op})}},e.prototype._parseVariables=function(){if(this._interactivityGraph.variables)for(var e=0,t=this._interactivityGraph.variables;e<t.length;e++){var n=t[e],r=this._parseVariable(n);this._staticVariables.push(r)}},e.prototype._parseVariable=function(e,n){var r=this._types[e.type];if(!r)throw t.Logger.Error(["No type found for variable",e]),new Error("Error parsing variables");if(e.value&&e.value.length!==r.length)throw t.Logger.Error(["Invalid value length for variable",e,r]),new Error("Error parsing variables");var o=e.value||[];if(!o.length)switch(r.flowGraphType){case"boolean":o.push(!1);break;case"FlowGraphInteger":o.push(0);break;case"number":o.push(NaN);break;case"Vector2":o.push(NaN,NaN);break;case"Vector3":o.push(NaN,NaN,NaN);break;case"Vector4":case"Matrix2D":case"Quaternion":o.fill(NaN,0,4);break;case"Matrix":o.fill(NaN,0,16);break;case"Matrix3D":o.fill(NaN,0,9)}return"number"===r.elementType&&"string"==typeof o[0]&&(o[0]=parseFloat(o[0])),{type:r.flowGraphType,value:n?n(o,this):o}},e.prototype._parseEvents=function(){var e=this;if(this._interactivityGraph.events)for(var n=function(n){var o={eventId:n.id||"internalEvent_"+r._internalEventsCounter++};n.values&&(o.eventData=Object.keys(n.values).map(function(r){var o,a=null===(o=n.values)||void 0===o?void 0:o[r];if(!a)throw t.Logger.Error(["No value found for event key",r]),new Error("Error parsing events");var i=e._types[a.type];if(!i)throw t.Logger.Error(["No type found for event value",a]),new Error("Error parsing events");var s=void 0!==a.value?e._parseVariable(a):void 0;return{id:r,type:i.flowGraphType,eventData:!0,value:s}})),r._events.push(o)},r=this,o=0,a=this._interactivityGraph.events;o<a.length;o++)n(a[o])},e.prototype._parseNodes=function(){var e;if(this._interactivityGraph.nodes)for(var n=0,r=this._interactivityGraph.nodes;n<r.length;n++){var o=r[n];if("number"!=typeof o.declaration)throw t.Logger.Error(["No declaration found for node",o]),new Error("Error parsing nodes");var a=this._mappings[o.declaration];if(!a)throw t.Logger.Error(["No mapping found for node",o]),new Error("Error parsing nodes");if(a.flowGraphMapping.validation){var i=a.flowGraphMapping.validation(o,this._interactivityGraph,this._gltf);if(!i.valid)throw new Error("Error validating interactivity node ".concat(null===(e=this._interactivityGraph.declarations)||void 0===e?void 0:e[o.declaration].op," - ").concat(i.error))}for(var s=[],l=0,u=a.flowGraphMapping.blocks;l<u.length;l++){var c=u[l],f=this._getEmptyBlock(c,a.fullOperationName);this._parseNodeConfiguration(o,f,a.flowGraphMapping,c),s.push(f)}this._nodes.push({blocks:s,fullOperationName:a.fullOperationName})}},e.prototype._getEmptyBlock=function(e,n){return{uniqueId:t.RandomGUID(),className:e,dataInputs:[],dataOutputs:[],signalInputs:[],signalOutputs:[],config:{},type:n,metadata:{}}},e.prototype._parseNodeConfiguration=function(e,n,r,o){var a,i=e.configuration;if(i)for(var s in i){var l=i[s];if(!l)throw new Error("Error parsing node configuration");var u=null===(a=r.configuration)||void 0===a?void 0:a[s];if(u&&u.toBlock?u.toBlock===o:0===r.blocks.indexOf(o)){var c=null==u?void 0:u.defaultValue;(null==l?void 0:l.value)&&(c=l.value),(null==u?void 0:u.isArray)||(1!==c.length&&t.Logger.Warn("Invalid non-array value length: ".concat(c.length)),c=c[0]),(null==u?void 0:u.dataTransformer)&&(c=u.dataTransformer(c,this)),void 0!==c&&(n.config[(null==u?void 0:u.name)||s]={value:c})}}},e.prototype._parseNodeConnections=function(e){for(var n,r,o,a,i,s,l,u,c,f,h,p,d,m,_,b,g,y,v,T=0;T<this._nodes.length;T++){var x=null===(n=this._interactivityGraph.nodes)||void 0===n?void 0:n[T];if(!x)throw t.Logger.Error(["No node found for interactivity node",this._nodes[T]]),new Error("Error parsing node connections");var A=this._nodes[T],C=this._mappings[x.declaration];if(!C)throw t.Logger.Error(["No mapping found for node",x]),new Error("Error parsing node connections");for(var w=x.flows||{},O=Object.keys(w).sort(),M=function(e){var n=w[e],c=null===(o=null===(r=C.flowGraphMapping.outputs)||void 0===r?void 0:r.flows)||void 0===o?void 0:o[e],f=(null==c?void 0:c.name)||e,h=R._createNewSocketConnection(f,!0);(c&&c.toBlock&&A.blocks.find(function(e){return e.className===c.toBlock})||A.blocks[0]).signalOutputs.push(h);var p=n.node,d=R._nodes[p];if(!d)throw t.Logger.Error(["No node found for input node id",p]),new Error("Error parsing node connections");var m=Xt(d.fullOperationName);if(!m)throw t.Logger.Error(["No mapping found for input node",d]),new Error("Error parsing node connections");var _=null===(i=null===(a=m.inputs)||void 0===a?void 0:a.flows)||void 0===i?void 0:i[n.socket||"in"],b=!1;if(!_)for(var g in null===(s=m.inputs)||void 0===s?void 0:s.flows)g.startsWith("[")&&g.endsWith("]")&&(b=!0,_=null===(u=null===(l=m.inputs)||void 0===l?void 0:l.flows)||void 0===u?void 0:u[g]);var y=_?b?_.name.replace("$1",n.socket||""):_.name:n.socket||"in",v=_&&_.toBlock&&d.blocks.find(function(e){return e.className===_.toBlock})||d.blocks[0],T=v.signalInputs.find(function(e){return e.name===y});T||(T=R._createNewSocketConnection(y),v.signalInputs.push(T)),T.connectedPointIds.push(h.uniqueId),h.connectedPointIds.push(T.uniqueId)},R=this,P=0,L=O;P<L.length;P++)M(L[P]);for(var F=x.values||{},E=Object.keys(F),S=function(n){var r=F[n],o=null===(f=null===(c=C.flowGraphMapping.inputs)||void 0===c?void 0:c.values)||void 0===f?void 0:f[n],a=!1;if(!o)for(var i in null===(h=C.flowGraphMapping.inputs)||void 0===h?void 0:h.values)i.startsWith("[")&&i.endsWith("]")&&(a=!0,o=null===(d=null===(p=C.flowGraphMapping.inputs)||void 0===p?void 0:p.values)||void 0===d?void 0:d[i]);var s=o?a?o.name.replace("$1",n):o.name:n,l=k._createNewSocketConnection(s);if((o&&o.toBlock&&A.blocks.find(function(e){return e.className===o.toBlock})||A.blocks[0]).dataInputs.push(l),void 0!==r.value){var u=k._parseVariable(r,o&&o.dataTransformer);e._connectionValues[l.uniqueId]=u}else{if(void 0===r.node)throw t.Logger.Error(["Invalid value for value connection",r]),new Error("Error parsing node connections");var v=r.node,T=r.socket||"value",x=k._nodes[v];if(!x)throw t.Logger.Error(["No node found for output socket reference",r]),new Error("Error parsing node connections");var w=Xt(x.fullOperationName);if(!w)throw t.Logger.Error(["No mapping found for output socket reference",r]),new Error("Error parsing node connections");var O=null===(_=null===(m=w.outputs)||void 0===m?void 0:m.values)||void 0===_?void 0:_[T],M=!1;if(!O)for(var i in null===(b=w.outputs)||void 0===b?void 0:b.values)i.startsWith("[")&&i.endsWith("]")&&(M=!0,O=null===(y=null===(g=w.outputs)||void 0===g?void 0:g.values)||void 0===y?void 0:y[i]);var R=O?M?O.name.replace("$1",T):null==O?void 0:O.name:T,P=O&&O.toBlock&&x.blocks.find(function(e){return e.className===O.toBlock})||x.blocks[0],L=P.dataOutputs.find(function(e){return e.name===R});L||(L=k._createNewSocketConnection(R,!0),P.dataOutputs.push(L)),l.connectedPointIds.push(L.uniqueId),L.connectedPointIds.push(l.uniqueId)}},k=this,I=0,B=E;I<B.length;I++)S(B[I]);if(C.flowGraphMapping.interBlockConnectors)for(var N=0,G=C.flowGraphMapping.interBlockConnectors;N<G.length;N++){var D=G[N],V=D.input,H=D.output,K=D.isVariable;this._connectFlowGraphNodes(V,H,A.blocks[D.inputBlockIndex],A.blocks[D.outputBlockIndex],K)}if(C.flowGraphMapping.extraProcessor){var j=null===(v=this._interactivityGraph.declarations)||void 0===v?void 0:v[x.declaration];if(!j)throw t.Logger.Error(["No declaration found for extra processor",x]),new Error("Error parsing node connections");A.blocks=C.flowGraphMapping.extraProcessor(x,j,C.flowGraphMapping,this,A.blocks,e,this._gltf)}}},e.prototype._createNewSocketConnection=function(e,n){return{uniqueId:t.RandomGUID(),name:e,_connectionType:n?1:0,connectedPointIds:[]}},e.prototype._connectFlowGraphNodes=function(e,t,n,r,o){var a=o?n.dataInputs:n.signalInputs,i=o?r.dataOutputs:r.signalOutputs,s=a.find(function(t){return t.name===e})||this._createNewSocketConnection(e),l=i.find(function(e){return e.name===t})||this._createNewSocketConnection(t,!0);a.find(function(t){return t.name===e})||a.push(s),i.find(function(e){return e.name===t})||i.push(l),s.connectedPointIds.push(l.uniqueId),l.connectedPointIds.push(s.uniqueId)},e.prototype.getVariableName=function(e){return"staticVariable_"+e},e.prototype.serializeToFlowGraph=function(){var e={uniqueId:t.RandomGUID(),_userVariables:{},_connectionValues:{}};this._parseNodeConnections(e);for(var n=0;n<this._staticVariables.length;n++){var r=this._staticVariables[n];e._userVariables[this.getVariableName(n)]=r}return{rightHanded:!0,allBlocks:this._nodes.reduce(function(e,t){return e.concat(t.blocks)},[]),executionContexts:[e]}},e}(),an="KHR_interactivity",sn=function(){function e(e){this._loader=e,this.name=an,this.enabled=this._loader.isExtensionUsed(an),this._pathConverter=I(this._loader.gltf),e._skipStartAnimationStep=!0;var t=e.babylonScene;t&&ln(t)}return e.prototype.dispose=function(){this._loader=null,delete this._pathConverter},e.prototype.onReady=function(){return a(this,void 0,void 0,function(){var e,n,r,o,s,l=this;return i(this,function(u){switch(u.label){case 0:return this._loader.babylonScene&&this._pathConverter?(e=this._loader.babylonScene,(n=null===(s=this._loader.gltf.extensions)||void 0===s?void 0:s.KHR_interactivity)?((r=new t.FlowGraphCoordinator({scene:e})).dispatchEventsSynchronously=!1,o=n.graphs.map(function(e){return new on(e,l._loader.gltf,l._loader.parent.targetFps).serializeToFlowGraph()}),[4,Promise.all(o.map(function(e){return a(l,void 0,void 0,function(){return i(this,function(n){switch(n.label){case 0:return[4,t.ParseFlowGraphAsync(e,{coordinator:r,pathConverter:this._pathConverter})];case 1:return[2,n.sent()]}})})}))]):[2]):[2];case 1:return u.sent(),r.start(),[2]}})})},e}();function ln(e){G("/extensions/KHR_interactivity/?/activeCamera/rotation",{get:function(){if(!e.activeCamera)return new t.Quaternion(NaN,NaN,NaN,NaN);var n=t.Quaternion.FromRotationMatrix(e.activeCamera.getWorldMatrix()).normalize();return e.useRightHandedSystem||(n.w*=-1,n.x*=-1),n},type:"Quaternion",getTarget:function(){return e.activeCamera}}),G("/extensions/KHR_interactivity/?/activeCamera/position",{get:function(){if(!e.activeCamera)return new t.Vector3(NaN,NaN,NaN);var n=e.activeCamera.getWorldMatrix().getTranslation();return e.useRightHandedSystem||(n.x*=-1),n},type:"Vector3",getTarget:function(){return e.activeCamera}}),G("/animations/{}/extensions/KHR_interactivity/isPlaying",{get:function(e){var t,n;return null!==(n=null===(t=e._babylonAnimationGroup)||void 0===t?void 0:t.isPlaying)&&void 0!==n&&n},type:"boolean",getTarget:function(e){return e._babylonAnimationGroup}}),G("/animations/{}/extensions/KHR_interactivity/minTime",{get:function(e){var t,n;return(null!==(n=null===(t=e._babylonAnimationGroup)||void 0===t?void 0:t.from)&&void 0!==n?n:0)/60},type:"number",getTarget:function(e){return e._babylonAnimationGroup}}),G("/animations/{}/extensions/KHR_interactivity/maxTime",{get:function(e){var t,n;return(null!==(n=null===(t=e._babylonAnimationGroup)||void 0===t?void 0:t.to)&&void 0!==n?n:0)/60},type:"number",getTarget:function(e){return e._babylonAnimationGroup}}),G("/animations/{}/extensions/KHR_interactivity/playhead",{get:function(e){var t,n;return(null!==(n=null===(t=e._babylonAnimationGroup)||void 0===t?void 0:t.getCurrentFrame())&&void 0!==n?n:0)/60},type:"number",getTarget:function(e){return e._babylonAnimationGroup}}),G("/animations/{}/extensions/KHR_interactivity/virtualPlayhead",{get:function(e){var t,n;return(null!==(n=null===(t=e._babylonAnimationGroup)||void 0===t?void 0:t.getCurrentFrame())&&void 0!==n?n:0)/60},type:"number",getTarget:function(e){return e._babylonAnimationGroup}})}t.addToBlockFactory(an,"FlowGraphGLTFDataProvider",function(){return a(void 0,void 0,void 0,function(){return i(this,function(e){switch(e.label){case 0:return[4,Promise.resolve().then(function(){return xn})];case 1:return[2,e.sent().FlowGraphGLTFDataProvider]}})})}),K(an),H(an,!0,function(e){return new sn(e)});var un="KHR_node_visibility";G("/nodes/{}/extensions/KHR_node_visibility/visible",{get:function(e){var t=e._babylonTransformNode;return!t||void 0===t.isVisible||t.isVisible},set:function(e,t){var n,r;null===(n=t._primitiveBabylonMeshes)||void 0===n||n.forEach(function(e){e.inheritVisibility=!0}),t._babylonTransformNode&&(t._babylonTransformNode.isVisible=e),null===(r=t._primitiveBabylonMeshes)||void 0===r||r.forEach(function(t){t.isVisible=e})},getTarget:function(e){return e._babylonTransformNode},getPropertyName:[function(){return"isVisible"}],type:"boolean"});var cn=function(){function e(e){this.name=un,this._loader=e,this.enabled=e.isExtensionUsed(un)}return e.prototype.onReady=function(){if(this._loader){var e=this._loader.gltf.nodes;if(e)for(var t=0,n=e;t<n.length;t++){var r=n[t],o=r._babylonTransformNode;o&&(o.inheritVisibility=!0,r.extensions&&r.extensions.KHR_node_visibility&&!1===r.extensions.KHR_node_visibility.visible&&(o.isVisible=!1))}}},e.prototype.dispose=function(){delete this._loader},e}();K(un),H(un,!0,function(e){return new cn(e)});var fn="KHR_node_selectability";Jt("event/onSelect",fn,{blocks:["FlowGraphMeshPickEventBlock","FlowGraphGetVariableBlock","FlowGraphIndexOfBlock","KHR_interactivity/FlowGraphGLTFDataProvider"],configuration:{stopPropagation:{name:"stopPropagation"},nodeIndex:{name:"variable",toBlock:"FlowGraphGetVariableBlock",dataTransformer:function(e){return"pickedMesh_"+e}}},outputs:{values:{selectedNodeIndex:{name:"index",toBlock:"FlowGraphIndexOfBlock"},controllerIndex:{name:"pointerId"},selectionPoint:{name:"pickedPoint"},selectionRayOrigin:{name:"pickOrigin"}},flows:{out:{name:"done"}}},interBlockConnectors:[{input:"asset",output:"value",inputBlockIndex:0,outputBlockIndex:1,isVariable:!0},{input:"array",output:"nodes",inputBlockIndex:2,outputBlockIndex:3,isVariable:!0},{input:"object",output:"pickedMesh",inputBlockIndex:2,outputBlockIndex:0,isVariable:!0}],extraProcessor:function(e,t,n,r,o,a,i){var s,l,u,c,f,h,p,d=o[o.length-1];d.config=d.config||{},d.config.glTF=i;var m=null===(u=null===(l=null===(s=e.configuration)||void 0===s?void 0:s.nodeIndex)||void 0===l?void 0:l.value)||void 0===u?void 0:u[0];if(void 0===m||"number"!=typeof m)throw new Error("nodeIndex not found in configuration");var _="pickedMesh_"+m;return o[1].config.variable=_,a._userVariables[_]={className:"Mesh",id:null===(f=null===(c=null==i?void 0:i.nodes)||void 0===c?void 0:c[m]._babylonTransformNode)||void 0===f?void 0:f.id,uniqueId:null===(p=null===(h=null==i?void 0:i.nodes)||void 0===h?void 0:h[m]._babylonTransformNode)||void 0===p?void 0:p.uniqueId},o}}),G("/nodes/{}/extensions/KHR_node_selectability/selectable",{get:function(e){var t=e._babylonTransformNode;return!t||void 0===t.isPickable||t.isPickable},set:function(e,t){var n;null===(n=t._primitiveBabylonMeshes)||void 0===n||n.forEach(function(t){t.isPickable=e})},getTarget:function(e){return e._babylonTransformNode},getPropertyName:[function(){return"isPickable"}],type:"boolean"});var hn=function(){function e(e){this.name=fn,this._loader=e,this.enabled=e.isExtensionUsed(fn)}return e.prototype.onReady=function(){return a(this,void 0,void 0,function(){var e;return i(this,function(t){return null===(e=this._loader.gltf.nodes)||void 0===e||e.forEach(function(e){var t,n,r;(null===(t=e.extensions)||void 0===t?void 0:t.KHR_node_selectability)&&!1===(null===(n=e.extensions)||void 0===n?void 0:n.KHR_node_selectability.selectable)&&(null===(r=e._babylonTransformNode)||void 0===r||r.getChildMeshes().forEach(function(e){e.isPickable=!1}))}),[2]})})},e.prototype.dispose=function(){this._loader=null},e}();K(fn),H(fn,!0,function(e){return new hn(e)});var pn="KHR_node_hoverability",dn="targetMeshPointerOver_";Jt("event/onHoverIn",pn,{blocks:["FlowGraphPointerOverEventBlock","FlowGraphGetVariableBlock","FlowGraphIndexOfBlock","KHR_interactivity/FlowGraphGLTFDataProvider"],configuration:{stopPropagation:{name:"stopPropagation"},nodeIndex:{name:"variable",toBlock:"FlowGraphGetVariableBlock",dataTransformer:function(e){return dn+e}}},outputs:{values:{hoverNodeIndex:{name:"index",toBlock:"FlowGraphIndexOfBlock"},controllerIndex:{name:"pointerId"}},flows:{out:{name:"done"}}},interBlockConnectors:[{input:"targetMesh",output:"value",inputBlockIndex:0,outputBlockIndex:1,isVariable:!0},{input:"array",output:"nodes",inputBlockIndex:2,outputBlockIndex:3,isVariable:!0},{input:"object",output:"meshUnderPointer",inputBlockIndex:2,outputBlockIndex:0,isVariable:!0}],extraProcessor:function(e,t,n,r,o,a,i){var s,l,u,c,f,h,p,d=o[o.length-1];d.config=d.config||{},d.config.glTF=i;var m=null===(u=null===(l=null===(s=e.configuration)||void 0===s?void 0:s.nodeIndex)||void 0===l?void 0:l.value)||void 0===u?void 0:u[0];if(void 0===m||"number"!=typeof m)throw new Error("nodeIndex not found in configuration");var _=dn+m;return o[1].config.variable=_,a._userVariables[_]={className:"Mesh",id:null===(f=null===(c=null==i?void 0:i.nodes)||void 0===c?void 0:c[m]._babylonTransformNode)||void 0===f?void 0:f.id,uniqueId:null===(p=null===(h=null==i?void 0:i.nodes)||void 0===h?void 0:h[m]._babylonTransformNode)||void 0===p?void 0:p.uniqueId},o}});var mn="targetMeshPointerOut_";Jt("event/onHoverOut",pn,{blocks:["FlowGraphPointerOutEventBlock","FlowGraphGetVariableBlock","FlowGraphIndexOfBlock","KHR_interactivity/FlowGraphGLTFDataProvider"],configuration:{stopPropagation:{name:"stopPropagation"},nodeIndex:{name:"variable",toBlock:"FlowGraphGetVariableBlock",dataTransformer:function(e){return mn+e}}},outputs:{values:{hoverNodeIndex:{name:"index",toBlock:"FlowGraphIndexOfBlock"},controllerIndex:{name:"pointerId"}},flows:{out:{name:"done"}}},interBlockConnectors:[{input:"targetMesh",output:"value",inputBlockIndex:0,outputBlockIndex:1,isVariable:!0},{input:"array",output:"nodes",inputBlockIndex:2,outputBlockIndex:3,isVariable:!0},{input:"object",output:"meshOutOfPointer",inputBlockIndex:2,outputBlockIndex:0,isVariable:!0}],extraProcessor:function(e,t,n,r,o,a,i){var s,l,u,c,f,h,p,d=o[o.length-1];d.config=d.config||{},d.config.glTF=i;var m=null===(u=null===(l=null===(s=e.configuration)||void 0===s?void 0:s.nodeIndex)||void 0===l?void 0:l.value)||void 0===u?void 0:u[0];if(void 0===m||"number"!=typeof m)throw new Error("nodeIndex not found in configuration");var _=mn+m;return o[1].config.variable=_,a._userVariables[_]={className:"Mesh",id:null===(f=null===(c=null==i?void 0:i.nodes)||void 0===c?void 0:c[m]._babylonTransformNode)||void 0===f?void 0:f.id,uniqueId:null===(p=null===(h=null==i?void 0:i.nodes)||void 0===h?void 0:h[m]._babylonTransformNode)||void 0===p?void 0:p.uniqueId},o}}),G("/nodes/{}/extensions/KHR_node_hoverability/hoverable",{get:function(e){var t=e._babylonTransformNode;return!t||void 0===t.pointerOverDisableMeshTesting||t.pointerOverDisableMeshTesting},set:function(e,t){var n;null===(n=t._primitiveBabylonMeshes)||void 0===n||n.forEach(function(t){t.pointerOverDisableMeshTesting=!e})},getTarget:function(e){return e._babylonTransformNode},getPropertyName:[function(){return"pointerOverDisableMeshTesting"}],type:"boolean"});var _n=function(){function e(e){this.name=pn,this._loader=e,this.enabled=e.isExtensionUsed(pn)}return e.prototype.onReady=function(){return a(this,void 0,void 0,function(){var e;return i(this,function(t){return null===(e=this._loader.gltf.nodes)||void 0===e||e.forEach(function(e){var t,n,r;(null===(t=e.extensions)||void 0===t?void 0:t.KHR_node_hoverability)&&!1===(null===(n=e.extensions)||void 0===n?void 0:n.KHR_node_hoverability.hoverable)&&(null===(r=e._babylonTransformNode)||void 0===r||r.getChildMeshes().forEach(function(e){e.pointerOverDisableMeshTesting=!0}))}),[2]})})},e.prototype.dispose=function(){this._loader=null},e}();K(pn),H(pn,!0,function(e){return new _n(e)});var bn="ExtrasAsMetadata",gn=function(){function e(e){this.name=bn,this.enabled=!0,this._loader=e}return e.prototype._assignExtras=function(e,t){if(t.extras&&Object.keys(t.extras).length>0){var n=e.metadata=e.metadata||{};(n.gltf=n.gltf||{}).extras=t.extras}},e.prototype.dispose=function(){this._loader=null},e.prototype.loadNodeAsync=function(e,t,n){var r=this;return this._loader.loadNodeAsync(e,t,function(e){r._assignExtras(e,t),n(e)})},e.prototype.loadCameraAsync=function(e,t,n){var r=this;return this._loader.loadCameraAsync(e,t,function(e){r._assignExtras(e,t),n(e)})},e.prototype.createMaterial=function(e,t,n){var r=this._loader.createMaterial(e,t,n);return this._assignExtras(r,t),r},e.prototype.loadAnimationAsync=function(e,t){var n=this;return this._loader.loadAnimationAsync(e,t).then(function(e){return n._assignExtras(e,t),e})},e}();K(bn),H(bn,!1,function(e){return new gn(e)});var yn,vn,Tn=function(e){function n(n){var r,o,a=e.call(this,n)||this,i=n.glTF,s=(null===(r=null==i?void 0:i.animations)||void 0===r?void 0:r.map(function(e){return e._babylonAnimationGroup}))||[];a.animationGroups=a.registerDataOutput("animationGroups",t.RichTypeAny,s);var l=(null===(o=null==i?void 0:i.nodes)||void 0===o?void 0:o.map(function(e){return e._babylonTransformNode}))||[];return a.nodes=a.registerDataOutput("nodes",t.RichTypeAny,l),a}return r(n,e),n.prototype.getClassName=function(){return"FlowGraphGLTFDataProvider"},n}(t.FlowGraphBlock),xn={__proto__:null,FlowGraphGLTFDataProvider:Tn},An={__proto__:null,AddObjectAccessorToKey:G,EXT_lights_area:fe,EXT_lights_ies:ae,EXT_lights_image_based:X,EXT_mesh_gpu_instancing:J,EXT_meshopt_compression:$,EXT_texture_avif:re,EXT_texture_webp:te,ExtrasAsMetadata:gn,FlowGraphGLTFDataProvider:Tn,GetMappingForKey:B,GetPathToObjectConverter:I,InteractivityGraphToFlowGraphParser:on,KHR_animation_pointer:Vt,KHR_draco_mesh_compression:se,KHR_interactivity:sn,KHR_lights:ue,KHR_materials_anisotropy:Ae,KHR_materials_clearcoat:be,KHR_materials_coat:ye,KHR_materials_diffuse_roughness:Ye,KHR_materials_diffuse_transmission:Ve,KHR_materials_dispersion:ze,KHR_materials_emissive_strength:we,KHR_materials_fuzz:Pe,KHR_materials_ior:Se,KHR_materials_iridescence:Te,KHR_materials_pbrSpecularGlossiness:pe,KHR_materials_sheen:Me,KHR_materials_specular:Fe,KHR_materials_transmission:Ge,KHR_materials_unlit:me,KHR_materials_variants:Ie,KHR_materials_volume:Ke,KHR_materials_volume_scatter:We,KHR_mesh_quantization:Qe,KHR_node_hoverability:_n,KHR_node_selectability:hn,KHR_node_visibility:cn,KHR_texture_basisu:Ze,KHR_texture_transform:et,KHR_xmp_json_ld:nt,MSFT_audio_emitter:Kt,MSFT_lod:Wt,MSFT_minecraftMesh:zt,MSFT_sRGBFactors:Yt,SetInterpolationForKey:N,_AddInteractivityObjectModel:ln,addNewInteractivityFlowGraphMapping:Jt,getAllSupportedNativeNodeTypes:nn,getMappingForDeclaration:Qt,getMappingForFullOperationName:Xt,gltfTypeToBabylonType:rn},Cn=function(){function e(e){this._specWorkflow=!1,this._diffuseTransmissionTint=t.Color3.White(),this._diffuseTransmissionTintTexture=null,this._material=e}return Object.defineProperty(e.prototype,"material",{get:function(){return this._material},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isUnlit",{get:function(){return this._material.unlit},set:function(e){this._material.unlit=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"backFaceCulling",{get:function(){return this._material.backFaceCulling},set:function(e){this._material.backFaceCulling=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"twoSidedLighting",{get:function(){return this._material.twoSidedLighting},set:function(e){this._material.twoSidedLighting=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"alphaCutOff",{get:function(){return.5},set:function(e){},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"useAlphaFromBaseColorTexture",{get:function(){return!1},set:function(e){this._material._useAlphaFromBaseColorTexture=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"transparencyAsAlphaCoverage",{get:function(){return!1},set:function(e){},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"baseColor",{get:function(){return this._material.baseColor},set:function(e){this._material.baseColor=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"baseColorTexture",{get:function(){return this._material.baseColorTexture},set:function(e){this._material.baseColorTexture=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"baseDiffuseRoughness",{get:function(){return this._material.baseDiffuseRoughness},set:function(e){this._material.baseDiffuseRoughness=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"baseDiffuseRoughnessTexture",{get:function(){return this._material.baseDiffuseRoughnessTexture},set:function(e){this._material.baseDiffuseRoughnessTexture=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"baseMetalness",{get:function(){return this._material.baseMetalness},set:function(e){this._material.baseMetalness=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"baseMetalnessTexture",{get:function(){return this._material.baseMetalnessTexture},set:function(e){this._material.baseMetalnessTexture=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"useRoughnessFromMetallicTextureGreen",{set:function(e){this._material._useRoughnessFromMetallicTextureGreen=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"useMetallicFromMetallicTextureBlue",{set:function(e){this._material._useMetallicFromMetallicTextureBlue=e},enumerable:!1,configurable:!0}),e.prototype.enableSpecularEdgeColor=function(e){void 0===e&&(e=!1)},e.prototype.configureSpecularGlossiness=function(){this._specWorkflow=!0},Object.defineProperty(e.prototype,"specularWeight",{get:function(){return this._material.specularWeight},set:function(e){this._material.specularWeight=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"specularWeightTexture",{get:function(){return this._material.specularWeightTexture},set:function(e){this._material.specularColorTexture===e?(this._material.specularWeightTexture=null,this._material._useSpecularWeightFromSpecularColorTexture=!0,this._material._useSpecularWeightFromAlpha=!0):this._material.specularWeightTexture=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"specularColor",{get:function(){return this._material.specularColor},set:function(e){this._material.specularColor=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"specularColorTexture",{get:function(){return this._material.specularColorTexture},set:function(e){this._material.specularColorTexture=e,this._material.specularWeightTexture===this._material.specularColorTexture&&(this._material.specularWeightTexture=null,this._material._useSpecularWeightFromSpecularColorTexture=!0,this._material._useSpecularWeightFromAlpha=!0)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"specularRoughness",{get:function(){return this._material.specularRoughness},set:function(e){this._material.specularRoughness=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"specularRoughnessTexture",{get:function(){return this._material.specularRoughnessTexture},set:function(e){this._material.specularRoughnessTexture=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"specularIor",{get:function(){return this._material.specularIor},set:function(e){this._material.specularIor=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"glossiness",{get:function(){return 1-this._material.specularRoughness},set:function(e){this._material.specularRoughness=Math.max(1-e,0)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"emissionColor",{get:function(){return this._material.emissionColor},set:function(e){this._material.emissionColor=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"emissionLuminance",{get:function(){return this._material.emissionLuminance},set:function(e){this._material.emissionLuminance=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"emissionColorTexture",{get:function(){return this._material.emissionColorTexture},set:function(e){this._material.emissionColorTexture=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"ambientOcclusionTexture",{get:function(){return this._material.ambientOcclusionTexture},set:function(e){this._material.ambientOcclusionTexture=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"ambientOcclusionTextureStrength",{get:function(){var e,t=this._material.ambientOcclusionTexture;return null!==(e=null==t?void 0:t.level)&&void 0!==e?e:1},set:function(e){var t=this._material.ambientOcclusionTexture;t&&(t.level=e)},enumerable:!1,configurable:!0}),e.prototype.configureCoat=function(){},Object.defineProperty(e.prototype,"coatWeight",{get:function(){return this._material.coatWeight},set:function(e){this._material.coatWeight=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"coatWeightTexture",{get:function(){return this._material.coatWeightTexture},set:function(e){this._material.coatWeightTexture=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"coatColor",{get:function(){return this._material.coatColor},set:function(e){this._material.coatColor=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"coatColorTexture",{set:function(e){this._material.coatColorTexture=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"coatRoughness",{get:function(){return this._material.coatRoughness},set:function(e){this._material.coatRoughness=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"coatRoughnessTexture",{get:function(){return this._material.coatRoughnessTexture},set:function(e){this._material.coatRoughnessTexture=e,e&&(this._material._useCoatRoughnessFromGreenChannel=!0)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"coatIor",{get:function(){return this._material.coatIor},set:function(e){this._material.coatIor=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"coatDarkening",{get:function(){return this._material.coatDarkening},set:function(e){this._material.coatDarkening=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"coatDarkeningTexture",{set:function(e){this._material.coatDarkeningTexture=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"coatRoughnessAnisotropy",{get:function(){return this._material.coatRoughnessAnisotropy},set:function(e){this._material.coatRoughnessAnisotropy=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"geometryCoatTangentAngle",{set:function(e){this._material.geometryCoatTangentAngle=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"geometryCoatTangentTexture",{get:function(){return this._material.geometryCoatTangentTexture},set:function(e){this._material.geometryCoatTangentTexture=e,e&&(this._material._useCoatRoughnessAnisotropyFromTangentTexture=!0)},enumerable:!1,configurable:!0}),e.prototype.configureTransmission=function(){this._material.geometryThinWalled=1,this._material.transmissionDepth=0},Object.defineProperty(e.prototype,"transmissionWeight",{get:function(){return this._material.transmissionWeight},set:function(e){this._material.transmissionWeight=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"transmissionWeightTexture",{get:function(){return this._material.transmissionWeightTexture},set:function(e){this._material.transmissionWeightTexture=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"transmissionScatter",{get:function(){return this._material.transmissionScatter},set:function(e){this._material.transmissionScatter=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"transmissionScatterTexture",{get:function(){return this._material.transmissionScatterTexture},set:function(e){this._material.transmissionScatterTexture=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"transmissionScatterAnisotropy",{set:function(e){this._material.transmissionScatterAnisotropy=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"transmissionDispersionAbbeNumber",{set:function(e){this._material.transmissionDispersionAbbeNumber=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"transmissionDispersionScale",{set:function(e){this._material.transmissionDispersionScale=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"transmissionDepth",{get:function(){return this._material.transmissionDepth},set:function(e){e!==Number.MAX_VALUE||0!==this._material.transmissionDepth?this._material.transmissionDepth=e:this._material.transmissionDepth=0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"transmissionColor",{get:function(){return this._material.transmissionColor},set:function(e){e.equals(t.Color3.White())||(this._material.transmissionColor=e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"refractionBackgroundTexture",{get:function(){return this._material.backgroundRefractionTexture},set:function(e){this._material.backgroundRefractionTexture=e},enumerable:!1,configurable:!0}),e.prototype.configureVolume=function(){this._material.geometryThinWalled=0},Object.defineProperty(e.prototype,"geometryThinWalled",{get:function(){return!!this._material.geometryThinWalled},set:function(e){this._material.geometryThinWalled=e?1:0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"volumeThicknessTexture",{set:function(e){this._material.geometryThicknessTexture=e,this._material._useGeometryThicknessFromGreenChannel=!0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"volumeThickness",{set:function(e){this._material.geometryThickness=e},enumerable:!1,configurable:!0}),e.prototype.configureSubsurface=function(){this._material.geometryThinWalled=1,this._material.subsurfaceScatterAnisotropy=1},Object.defineProperty(e.prototype,"subsurfaceWeight",{get:function(){return this._material.subsurfaceWeight},set:function(e){this._material.subsurfaceWeight=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"subsurfaceWeightTexture",{get:function(){return this._material.subsurfaceWeightTexture},set:function(e){this._material.subsurfaceWeightTexture=e,this._material._useSubsurfaceWeightFromTextureAlpha=!0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"subsurfaceColor",{set:function(e){this._material.subsurfaceColor=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"subsurfaceColorTexture",{set:function(e){this._material.subsurfaceColorTexture=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"diffuseTransmissionTint",{get:function(){return this._diffuseTransmissionTint},set:function(e){this._diffuseTransmissionTint=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"diffuseTransmissionTintTexture",{set:function(e){this._diffuseTransmissionTintTexture=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"subsurfaceRadius",{get:function(){return this._material.subsurfaceRadius},set:function(e){this._material.subsurfaceRadius=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"subsurfaceRadiusScale",{get:function(){return this._material.subsurfaceRadiusScale},set:function(e){this._material.subsurfaceRadiusScale=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"subsurfaceScatterAnisotropy",{set:function(e){this._material.subsurfaceScatterAnisotropy=e},enumerable:!1,configurable:!0}),e.prototype.isTranslucent=function(){return this.transmissionWeight>0||this.subsurfaceWeight>0},e.prototype.configureFuzz=function(){},Object.defineProperty(e.prototype,"fuzzWeight",{set:function(e){this._material.fuzzWeight=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"fuzzWeightTexture",{set:function(e){this._material.fuzzWeightTexture=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"fuzzColor",{set:function(e){this._material.fuzzColor=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"fuzzColorTexture",{set:function(e){this._material.fuzzColorTexture=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"fuzzRoughness",{set:function(e){this._material.fuzzRoughness=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"fuzzRoughnessTexture",{set:function(e){this._material.fuzzRoughnessTexture=e,this._material._useFuzzRoughnessFromTextureAlpha=!0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"specularRoughnessAnisotropy",{get:function(){return this._material.specularRoughnessAnisotropy},set:function(e){this._material.specularRoughnessAnisotropy=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"geometryTangentAngle",{set:function(e){this._material.geometryTangentAngle=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"geometryTangentTexture",{get:function(){return this._material.geometryTangentTexture},set:function(e){this._material.geometryTangentTexture=e,this._material._useSpecularRoughnessAnisotropyFromTangentTexture=!0},enumerable:!1,configurable:!0}),e.prototype.configureGltfStyleAnisotropy=function(e){void 0===e&&(e=!0),this._material._useGltfStyleAnisotropy=e},Object.defineProperty(e.prototype,"thinFilmWeight",{set:function(e){this._material.thinFilmWeight=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"thinFilmIor",{set:function(e){this._material.thinFilmIor=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"thinFilmThicknessMinimum",{set:function(e){this._material.thinFilmThicknessMin=e/1e3},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"thinFilmThicknessMaximum",{set:function(e){this._material.thinFilmThickness=e/1e3},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"thinFilmWeightTexture",{set:function(e){this._material.thinFilmWeightTexture=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"thinFilmThicknessTexture",{set:function(e){this._material.thinFilmThicknessTexture=e,this._material._useThinFilmThicknessFromTextureGreen=!0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"unlit",{set:function(e){this._material.unlit=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"geometryOpacity",{get:function(){return this._material.geometryOpacity},set:function(e){this._material.geometryOpacity=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"geometryNormalTexture",{get:function(){return this._material.geometryNormalTexture},set:function(e){this._material.geometryNormalTexture=e},enumerable:!1,configurable:!0}),e.prototype.setNormalMapInversions=function(e,t){},Object.defineProperty(e.prototype,"geometryCoatNormalTexture",{get:function(){return this._material.geometryCoatNormalTexture},set:function(e){this._material.geometryCoatNormalTexture=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"geometryCoatNormalTextureScale",{set:function(e){this._material.geometryCoatNormalTexture&&(this._material.geometryCoatNormalTexture.level=e)},enumerable:!1,configurable:!0}),e.prototype.finalizeAsync=function(e){return a(this,void 0,void 0,function(){var n,r,a,s,l,u,c,f,h,p;return i(this,function(i){switch(i.label){case 0:return this._diffuseTransmissionTint&&!this._diffuseTransmissionTint.equals(t.Color3.White())||this._diffuseTransmissionTintTexture?this._material.geometryThinWalled?(this.subsurfaceColor=this._diffuseTransmissionTint,this.subsurfaceColorTexture=this._diffuseTransmissionTintTexture,[3,3]):[3,1]:[3,3];case 1:return[4,this.copySurfaceToCoatAsync(e,this.subsurfaceWeight,this.subsurfaceWeightTexture,t.TextureChannel.A,this._diffuseTransmissionTint,this._diffuseTransmissionTintTexture,!0)];case 2:if(i.sent(),e._disposed)return[2];i.label=3;case 3:return this.transmissionWeight>0?this._material.geometryThinWalled||0===this._material.transmissionDepth?(this._material.transmissionColor=this._material.baseColor,this._material.transmissionColorTexture=this._material.baseColorTexture,[3,6]):[3,4]:[3,6];case 4:return this.baseColor.equals(t.Color3.White())&&null===this.baseColorTexture?[3,6]:[4,this.copySurfaceToCoatAsync(e,this.transmissionWeight,this.transmissionWeightTexture,t.TextureChannel.R,this.baseColor,this.baseColorTexture,!1)];case 5:if(i.sent(),e._disposed)return[2];i.label=6;case 6:return this._specWorkflow?(r=t.InvertTextureAsync,a=["newRoughnessTexture ("+this._material.name+")"],[4,t.ExtractChannelAsync("glossiness ("+this._material.name+")",t.CreateTextureWithFactorOperand(this.specularColorTexture,new t.Color4(this.specularColor.r,this.specularColor.g,this.specularColor.b,this.glossiness),t.TextureChannel.A,t.TextureColorSpace.Linear),t.TextureChannel.A,this._material.getScene(),t.TextureColorSpace.Linear,t.ChannelMask.R)]):[3,11];case 7:return[4,r.apply(void 0,a.concat([i.sent(),this._material.getScene(),t.ChannelMask.R,t.TextureColorSpace.Linear,t.ChannelMask.R]))];case 8:return n=i.sent(),e._disposed?(null===(f=n.texture)||void 0===f||f.dispose(),[2]):(this.specularRoughnessTexture=n.texture,this.specularRoughness=n.factor?n.factor.r:1,[4,t.ExtractMaxChannelAsync("metallicTexture ("+this._material.name+")",t.CreateTextureWithFactorOperand(this.specularColorTexture,this.specularColor.toColor4(),t.TextureChannel.RGBA,t.TextureColorSpace.Linear),this._material.getScene(),!1,t.TextureColorSpace.SRGB,t.ChannelMask.RGB)]);case 9:return s=i.sent(),e._disposed?(null===(h=s.texture)||void 0===h||h.dispose(),[2]):(this.baseMetalnessTexture=s.texture,this.baseMetalness=s.factor?s.factor.r:1,[4,t.LerpTexturesAsync("newBaseColor ("+this._material.name+")",t.CreateTextureWithFactorOperand(this.baseColorTexture,this.baseColor.toColor4(),t.TextureChannel.RGBA,t.TextureColorSpace.Linear),t.CreateTextureWithFactorOperand(this.specularColorTexture,this.specularColor.toColor4(),t.TextureChannel.RGBA,t.TextureColorSpace.Linear),o(o({},s),{dispose:void 0,colorSpace:t.TextureColorSpace.Linear}),this._material.getScene(),t.TextureColorSpace.SRGB,t.ChannelMask.RGB)]);case 10:if(l=i.sent(),e._disposed)return null===(p=l.texture)||void 0===p||p.dispose(),[2];null==(u=this.baseColorTexture)||u.dispose(),this.baseColorTexture=l.texture,this.baseColor=l.factor?new t.Color3(l.factor.r,l.factor.g,l.factor.b):t.Color3.White(),null==(c=this.specularColorTexture)||c.dispose(),this.specularColorTexture=null,i.label=11;case 11:return[2]}})})},e.prototype.copySurfaceToCoatAsync=function(e,n,r,o,s,l){return a(this,arguments,void 0,function(e,n,r,o,a,s,l){var u,c,f,h,p,d,m,_,b,g,y,v,T,x,A,C,w,O,M,R,P,L,F,E,S,k,I,B,N,G;return void 0===l&&(l=!1),i(this,function(i){switch(i.label){case 0:return u=this._material.coatWeight,c=this._material.coatWeightTexture,f=this._material.coatColor.clone(),h=this._material.coatColorTexture,p=this._material.geometryCoatNormalTexture,d=new t.Color4(u,u,u,u),m=new t.Color4(n,n,n,n),this.coatWeightTexture=null,this.coatWeight=1,[4,Promise.allSettled([t.LerpTexturesAsync("lerpExistingCoat",t.CreateTextureWithFactorOperand(null,new t.Color4(1,1,1,1)),t.CreateTextureWithFactorOperand(h,f.toColor4(),t.TextureChannel.RGBA,t.TextureColorSpace.SRGB),t.CreateTextureWithFactorOperand(c,d,t.TextureChannel.R),this._material.getScene(),t.TextureColorSpace.SRGB),t.LerpTexturesAsync("lerpSurfaceColor",t.CreateTextureWithFactorOperand(null,new t.Color4(1,1,1,1)),t.CreateTextureWithFactorOperand(s,a.toColor4(),t.TextureChannel.RGBA,t.TextureColorSpace.SRGB),t.CreateTextureWithFactorOperand(r,m,o),this._material.getScene(),t.TextureColorSpace.SRGB)])];case 1:if(_=i.sent(),b=_.find(function(e){return"rejected"===e.status}),b){for(g=0,y=_;g<y.length;g++)"fulfilled"===(v=y[g]).status&&(null===(L=v.value.texture)||void 0===L||L.dispose());throw b.reason}return T=_.map(function(e){return e.value}),x=T[0],A=T[1],e._disposed?(null===(F=x.texture)||void 0===F||F.dispose(),null===(E=A.texture)||void 0===E||E.dispose(),[2]):[4,t.MultiplyTexturesAsync("newCoatColor ("+this._material.name+")",x,A,this._material.getScene(),t.TextureColorSpace.SRGB)];case 2:return C=i.sent(),e._disposed?(null===(S=C.texture)||void 0===S||S.dispose(),[2]):(C.texture?(this.coatColorTexture=C.texture,this.coatColor=t.Color3.White()):C.factor&&(this.coatColorTexture=null,this.coatColor.fromArray([C.factor.r,C.factor.g,C.factor.b])),[4,t.LerpTexturesAsync("newCoatIor ("+this._material.name+")",t.CreateTextureWithFactorOperand(null,new t.Color4(this._material.specularIor,this._material.specularIor,this._material.specularIor,1),t.TextureChannel.R),t.CreateTextureWithFactorOperand(null,new t.Color4(this.coatIor,this.coatIor,this.coatIor,1),t.TextureChannel.R),t.CreateTextureWithFactorOperand(c,d,t.TextureChannel.R),this._material.getScene())]);case 3:return w=i.sent(),e._disposed?(null===(k=w.texture)||void 0===k||k.dispose(),[2]):(this.coatIor=w.factor?w.factor.r:this.coatIor,[4,t.LerpTexturesAsync("newCoatRoughness ("+this._material.name+")",t.CreateTextureWithFactorOperand(this.specularRoughnessTexture,new t.Color4(this.specularRoughness,this.specularRoughness,this.specularRoughness,1),t.TextureChannel.G),t.CreateTextureWithFactorOperand(this.coatRoughnessTexture,new t.Color4(this.coatRoughness,this.coatRoughness,this.coatRoughness,1),t.TextureChannel.G),t.CreateTextureWithFactorOperand(c,d,t.TextureChannel.R),this._material.getScene())]);case 4:return O=i.sent(),e._disposed?(null===(I=O.texture)||void 0===I||I.dispose(),[2]):(this.coatRoughness=O.factor?O.factor.r:1,this.coatRoughnessTexture=O.texture,[4,t.LerpTexturesAsync("newCoatDarkening ("+this._material.name+")",t.CreateTextureWithFactorOperand(null,new t.Color4(0,0,0,1),t.TextureChannel.R),t.CreateTextureWithFactorOperand(null,new t.Color4(this.coatDarkening,this.coatDarkening,this.coatDarkening,1),t.TextureChannel.R),t.CreateTextureWithFactorOperand(c,d,t.TextureChannel.R),this._material.getScene())]);case 5:return M=i.sent(),e._disposed?(null===(B=M.texture)||void 0===B||B.dispose(),[2]):(this.coatDarkening=M.factor?M.factor.r:this.coatDarkening,l?[4,t.LerpTexturesAsync("newSpecularRoughness ("+this._material.name+")",t.CreateTextureWithFactorOperand(this.specularRoughnessTexture,new t.Color4(this._material.specularRoughness,this._material.specularRoughness,this._material.specularRoughness,1),t.TextureChannel.G),t.CreateTextureWithFactorOperand(null,new t.Color4(1,1,1,1),t.TextureChannel.R),t.CreateTextureWithFactorOperand(r,m,o),this._material.getScene())]:[3,7]);case 6:if(R=i.sent(),e._disposed)return null===(N=R.texture)||void 0===N||N.dispose(),[2];this.specularRoughness=R.factor?R.factor.r:1,this.specularRoughnessTexture=R.texture,i.label=7;case 7:return p||this.geometryNormalTexture?[4,t.LerpTexturesAsync("newCoatNormal ("+this._material.name+")",t.CreateTextureWithFactorOperand(this.geometryNormalTexture,this.geometryNormalTexture?new t.Color4(1,1,1,1):new t.Color4(.5,.5,1,1),t.TextureChannel.RGBA),t.CreateTextureWithFactorOperand(p,p?new t.Color4(1,1,1,1):new t.Color4(.5,.5,1,1),t.TextureChannel.RGBA),t.CreateTextureWithFactorOperand(c,d,t.TextureChannel.R),this._material.getScene())]:[3,9];case 8:if(P=i.sent(),e._disposed)return null===(G=P.texture)||void 0===G||G.dispose(),[2];P.texture&&(this.geometryCoatNormalTexture=P.texture),i.label=9;case 9:return[2]}})})},e}(),wn={__proto__:null,OpenPBRMaterialLoadingAdapter:Cn},On=function(){function e(e){this._specWorkflow=!1,this._material=e,this._material.enableSpecularAntiAliasing=!0}return Object.defineProperty(e.prototype,"material",{get:function(){return this._material},enumerable:!1,configurable:!0}),e.prototype.finalizeAsync=function(e){return a(this,void 0,void 0,function(){return i(this,function(e){return[2]})})},Object.defineProperty(e.prototype,"isUnlit",{get:function(){return this._material.unlit},set:function(e){this._material.unlit=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"backFaceCulling",{get:function(){return this._material.backFaceCulling},set:function(e){this._material.backFaceCulling=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"twoSidedLighting",{get:function(){return this._material.twoSidedLighting},set:function(e){this._material.twoSidedLighting=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"alphaCutOff",{get:function(){return this._material.alphaCutOff},set:function(e){this._material.alphaCutOff=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"useAlphaFromBaseColorTexture",{get:function(){return this._material.useAlphaFromAlbedoTexture},set:function(e){this._material.useAlphaFromAlbedoTexture=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"transparencyAsAlphaCoverage",{get:function(){return this._material.useRadianceOverAlpha||this._material.useSpecularOverAlpha},set:function(e){this._material.useRadianceOverAlpha=!e,this._material.useSpecularOverAlpha=!e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"baseColor",{get:function(){return this._material.albedoColor},set:function(e){this._material.albedoColor=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"baseColorTexture",{get:function(){return this._material.albedoTexture},set:function(e){this._material.albedoTexture=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"baseDiffuseRoughness",{get:function(){var e;return null!==(e=this._material.baseDiffuseRoughness)&&void 0!==e?e:0},set:function(e){this._material.baseDiffuseRoughness=e,e>0&&(this._material.brdf.baseDiffuseModel=t.Constants.MATERIAL_DIFFUSE_MODEL_E_OREN_NAYAR)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"baseDiffuseRoughnessTexture",{get:function(){return this._material.baseDiffuseRoughnessTexture},set:function(e){this._material.baseDiffuseRoughnessTexture=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"baseMetalness",{get:function(){var e;return null!==(e=this._material.metallic)&&void 0!==e?e:1},set:function(e){this._material.metallic=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"baseMetalnessTexture",{get:function(){return this._material.metallicTexture},set:function(e){this._material.metallicTexture=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"useRoughnessFromMetallicTextureGreen",{set:function(e){this._material.useRoughnessFromMetallicTextureGreen=e,this._material.useRoughnessFromMetallicTextureAlpha=!e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"useMetallicFromMetallicTextureBlue",{set:function(e){this._material.useMetallnessFromMetallicTextureBlue=e},enumerable:!1,configurable:!0}),e.prototype.enableSpecularEdgeColor=function(e){void 0===e&&(e=!1),e&&(this._material.brdf.dielectricSpecularModel=t.Constants.MATERIAL_DIELECTRIC_SPECULAR_MODEL_OPENPBR,this._material.brdf.conductorSpecularModel=t.Constants.MATERIAL_CONDUCTOR_SPECULAR_MODEL_OPENPBR)},e.prototype.configureSpecularGlossiness=function(){this._specWorkflow=!0,this._material.metallic=null,this._material.roughness=null,this._material.useMicroSurfaceFromReflectivityMapAlpha=!0},Object.defineProperty(e.prototype,"specularWeight",{get:function(){var e;return null!==(e=this._material.metallicF0Factor)&&void 0!==e?e:1},set:function(e){this._material.metallicF0Factor=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"specularWeightTexture",{get:function(){return this._material.metallicReflectanceTexture},set:function(e){e?(this._material.metallicReflectanceTexture=e,this._material.useOnlyMetallicFromMetallicReflectanceTexture=!0):(this._material.metallicReflectanceTexture=null,this._material.useOnlyMetallicFromMetallicReflectanceTexture=!1)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"specularColor",{get:function(){return this._specWorkflow?this._material.reflectivityColor:this._material.metallicReflectanceColor},set:function(e){this._specWorkflow?this._material.reflectivityColor=e:this._material.metallicReflectanceColor=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"specularColorTexture",{get:function(){return this._specWorkflow?this._material.reflectivityTexture:this._material.reflectanceTexture},set:function(e){this._specWorkflow?(this._material.reflectivityTexture=e,this._material.reflectivityTexture&&(this._material.reflectivityTexture.hasAlpha=!0)):this._material.reflectanceTexture=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"specularRoughness",{get:function(){var e;return null!==(e=this._material.roughness)&&void 0!==e?e:1},set:function(e){this._material.roughness=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"specularRoughnessTexture",{get:function(){return this._material.metallicTexture},set:function(e){this.baseMetalnessTexture||(this._material.metallicTexture=e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"specularIor",{get:function(){return this._material.indexOfRefraction},set:function(e){this._material.indexOfRefraction=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"glossiness",{get:function(){var e;return null!==(e=this._material.microSurface)&&void 0!==e?e:1},set:function(e){this._material.microSurface=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"emissionColor",{get:function(){return this._material.emissiveColor},set:function(e){this._material.emissiveColor=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"emissionLuminance",{get:function(){return this._material.emissiveIntensity},set:function(e){this._material.emissiveIntensity=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"emissionColorTexture",{get:function(){return this._material.emissiveTexture},set:function(e){this._material.emissiveTexture=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"ambientOcclusionTexture",{get:function(){return this._material.ambientTexture},set:function(e){this._material.ambientTexture=e,e&&(this._material.useAmbientInGrayScale=!0)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"ambientOcclusionTextureStrength",{get:function(){var e;return null!==(e=this._material.ambientTextureStrength)&&void 0!==e?e:1},set:function(e){this._material.ambientTextureStrength=e},enumerable:!1,configurable:!0}),e.prototype.configureCoat=function(){this._material.clearCoat.isEnabled=!0,this._material.clearCoat.useRoughnessFromMainTexture=!1,this._material.clearCoat.remapF0OnInterfaceChange=!1},Object.defineProperty(e.prototype,"coatWeight",{get:function(){return this._material.clearCoat.intensity},set:function(e){this._material.clearCoat.isEnabled=!0,this._material.clearCoat.intensity=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"coatWeightTexture",{get:function(){return this._material.clearCoat.texture},set:function(e){this._material.clearCoat.isEnabled=!0,this._material.clearCoat.texture=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"coatColor",{set:function(e){this._material.clearCoat.isTintEnabled=e!=t.Color3.White(),this._material.clearCoat.tintColor=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"coatColorTexture",{set:function(e){this._material.clearCoat.tintTexture=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"coatRoughness",{get:function(){var e;return null!==(e=this._material.clearCoat.roughness)&&void 0!==e?e:0},set:function(e){this._material.clearCoat.isEnabled=!0,this._material.clearCoat.roughness=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"coatRoughnessTexture",{get:function(){return this._material.clearCoat.textureRoughness},set:function(e){this._material.clearCoat.isEnabled=!0,this._material.clearCoat.useRoughnessFromMainTexture=!1,this._material.clearCoat.textureRoughness=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"coatIor",{set:function(e){this._material.clearCoat.indexOfRefraction=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"coatDarkening",{set:function(e){},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"coatDarkeningTexture",{set:function(e){},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"coatRoughnessAnisotropy",{get:function(){return 0},set:function(e){},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"geometryCoatTangentAngle",{set:function(e){},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"geometryCoatTangentTexture",{get:function(){return null},set:function(e){},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"transmissionWeight",{get:function(){return this._material.subSurface.isRefractionEnabled?this._material.subSurface.refractionIntensity:0},set:function(e){this._material.subSurface.isRefractionEnabled=e>0,this._material.subSurface.refractionIntensity=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"transmissionWeightTexture",{set:function(e){this._material.subSurface.isRefractionEnabled=!0,this._material.subSurface.refractionIntensityTexture=e,this._material.subSurface.useGltfStyleTextures=!0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"transmissionDepth",{get:function(){return this.transmissionWeight>0?this._material.subSurface.tintColorAtDistance:0},set:function(e){this.transmissionWeight>0?this._material.subSurface.tintColorAtDistance=e:this.subsurfaceWeight>0&&this._material.subSurface.diffusionDistance.multiplyInPlace(new t.Color3(e,e,e))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"transmissionColor",{get:function(){return this.transmissionWeight>0?this._material.subSurface.tintColor:this.subsurfaceWeight>0?this._material.subSurface.diffusionDistance:new t.Color3(0,0,0)},set:function(e){this.transmissionWeight>0?this._material.subSurface.tintColor=e:this.subsurfaceWeight>0&&this._material.subSurface.diffusionDistance.multiplyInPlace(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"transmissionScatter",{get:function(){return this._material.subSurface.diffusionDistance},set:function(e){this._material.subSurface.diffusionDistance=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"transmissionScatterTexture",{set:function(e){},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"transmissionScatterAnisotropy",{set:function(e){},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"transmissionDispersionAbbeNumber",{set:function(e){},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"transmissionDispersionScale",{set:function(e){e>0?(this._material.subSurface.isDispersionEnabled=!0,this._material.subSurface.dispersion=20/e):(this._material.subSurface.isDispersionEnabled=!1,this._material.subSurface.dispersion=0)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"refractionBackgroundTexture",{get:function(){return this._material.subSurface.refractionTexture},set:function(e){this._material.subSurface.refractionTexture=e},enumerable:!1,configurable:!0}),e.prototype.configureTransmission=function(){this._material.subSurface.volumeIndexOfRefraction=1,this._material.subSurface.useAlbedoToTintRefraction=!0,this._material.subSurface.minimumThickness=0,this._material.subSurface.maximumThickness=0},e.prototype.configureVolume=function(){},Object.defineProperty(e.prototype,"geometryThinWalled",{get:function(){return 0===this._material.subSurface.maximumThickness},set:function(e){},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"volumeThicknessTexture",{set:function(e){this._material.subSurface.thicknessTexture=e,this._material.subSurface.useGltfStyleTextures=!0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"volumeThickness",{set:function(e){this._material.subSurface.minimumThickness=0,this._material.subSurface.maximumThickness=e,this._material.subSurface.useThicknessAsDepth=!0,e>0&&(this._material.subSurface.volumeIndexOfRefraction=this._material.indexOfRefraction)},enumerable:!1,configurable:!0}),e.prototype.configureSubsurface=function(){this._material.subSurface.useGltfStyleTextures=!0,this._material.subSurface.volumeIndexOfRefraction=1,this._material.subSurface.minimumThickness=0,this._material.subSurface.maximumThickness=0,this._material.subSurface.useAlbedoToTintTranslucency=!1},Object.defineProperty(e.prototype,"subsurfaceWeight",{get:function(){return this._material.subSurface.isTranslucencyEnabled?this._material.subSurface.translucencyIntensity:0},set:function(e){this._material.subSurface.isTranslucencyEnabled=e>0,this._material.subSurface.translucencyIntensity=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"subsurfaceWeightTexture",{set:function(e){this._material.subSurface.translucencyIntensityTexture=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"subsurfaceColor",{set:function(e){var n=new t.Vector3(-Math.log(this.transmissionColor.r),-Math.log(this.transmissionColor.g),-Math.log(this.transmissionColor.b));n.scaleInPlace(1/Math.max(this.transmissionDepth,.001));var r=n,o=Math.max(r.x,Math.max(r.y,r.z)),a=o>0?1/o:1;this._material.subSurface.diffusionDistance=new t.Color3(Math.exp(-r.x*a),Math.exp(-r.y*a),Math.exp(-r.z*a))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"subsurfaceColorTexture",{set:function(e){},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"diffuseTransmissionTint",{get:function(){return this._material.subSurface.tintColor},set:function(e){this._material.subSurface.tintColor=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"diffuseTransmissionTintTexture",{set:function(e){this._material.subSurface.translucencyColorTexture=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"subsurfaceRadius",{get:function(){return 1},set:function(e){},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"subsurfaceRadiusScale",{get:function(){var e;return null!==(e=this._material.subSurface.scatteringDiffusionProfile)&&void 0!==e?e:t.Color3.White()},set:function(e){this._material.subSurface.scatteringDiffusionProfile=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"subsurfaceScatterAnisotropy",{set:function(e){},enumerable:!1,configurable:!0}),e.prototype.isTranslucent=function(){return this.transmissionWeight>0||this.subsurfaceWeight>0},e.prototype.configureFuzz=function(){this._material.sheen.isEnabled=!0,this._material.sheen.useRoughnessFromMainTexture=!1,this._material.sheen.albedoScaling=!0},Object.defineProperty(e.prototype,"fuzzWeight",{set:function(e){this._material.sheen.isEnabled=!0,this._material.sheen.intensity=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"fuzzWeightTexture",{set:function(e){this._material.sheen.texture||(this._material.sheen.texture=e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"fuzzColor",{set:function(e){this._material.sheen.isEnabled=!0,this._material.sheen.color=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"fuzzColorTexture",{set:function(e){this._material.sheen.texture=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"fuzzRoughness",{set:function(e){this._material.sheen.isEnabled=!0,this._material.sheen.roughness=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"fuzzRoughnessTexture",{set:function(e){this._material.sheen.isEnabled=!0,this._material.sheen.textureRoughness=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"specularRoughnessAnisotropy",{get:function(){return this._material.anisotropy.intensity},set:function(e){this._material.anisotropy.isEnabled=!0,this._material.anisotropy.intensity=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"geometryTangentAngle",{set:function(e){this._material.anisotropy.isEnabled=!0,this._material.anisotropy.angle=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"geometryTangentTexture",{get:function(){return this._material.anisotropy.texture},set:function(e){this._material.anisotropy.isEnabled=!0,this._material.anisotropy.texture=e},enumerable:!1,configurable:!0}),e.prototype.configureGltfStyleAnisotropy=function(e){void 0===e&&(e=!0)},Object.defineProperty(e.prototype,"thinFilmWeight",{set:function(e){this._material.iridescence.isEnabled=e>0,this._material.iridescence.intensity=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"thinFilmIor",{set:function(e){this._material.iridescence.indexOfRefraction=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"thinFilmThicknessMinimum",{set:function(e){this._material.iridescence.minimumThickness=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"thinFilmThicknessMaximum",{set:function(e){this._material.iridescence.maximumThickness=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"thinFilmWeightTexture",{set:function(e){this._material.iridescence.texture=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"thinFilmThicknessTexture",{set:function(e){this._material.iridescence.thicknessTexture=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"unlit",{set:function(e){this._material.unlit=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"geometryOpacity",{get:function(){return this._material.alpha},set:function(e){this._material.alpha=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"geometryNormalTexture",{get:function(){return this._material.bumpTexture},set:function(e){this._material.bumpTexture=e,this._material.forceIrradianceInFragment=!0},enumerable:!1,configurable:!0}),e.prototype.setNormalMapInversions=function(e,t){this._material.invertNormalMapX=e,this._material.invertNormalMapY=t},Object.defineProperty(e.prototype,"geometryCoatNormalTexture",{get:function(){return this._material.clearCoat.bumpTexture},set:function(e){this._material.clearCoat.isEnabled=!0,this._material.clearCoat.bumpTexture=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"geometryCoatNormalTextureScale",{set:function(e){this._material.clearCoat.bumpTexture&&(this._material.clearCoat.bumpTexture.level=e)},enumerable:!1,configurable:!0}),e}(),Mn={__proto__:null,PBRMaterialLoadingAdapter:On},Rn={__proto__:null,AddObjectAccessorToKey:G,AnimationPropertyInfo:it,ArrayItem:U,EXT_lights_area:fe,EXT_lights_ies:ae,EXT_lights_image_based:X,EXT_mesh_gpu_instancing:J,EXT_meshopt_compression:$,EXT_texture_avif:re,EXT_texture_webp:te,ExtrasAsMetadata:gn,FlowGraphGLTFDataProvider:Tn,GLTFFileLoader:T,GLTFLoader:q,GetMappingForKey:B,GetPathToObjectConverter:I,InteractivityGraphToFlowGraphParser:on,KHR_animation_pointer:Vt,KHR_draco_mesh_compression:se,KHR_interactivity:sn,KHR_lights:ue,KHR_materials_anisotropy:Ae,KHR_materials_clearcoat:be,KHR_materials_coat:ye,KHR_materials_diffuse_roughness:Ye,KHR_materials_diffuse_transmission:Ve,KHR_materials_dispersion:ze,KHR_materials_emissive_strength:we,KHR_materials_fuzz:Pe,KHR_materials_ior:Se,KHR_materials_iridescence:Te,KHR_materials_pbrSpecularGlossiness:pe,KHR_materials_sheen:Me,KHR_materials_specular:Fe,KHR_materials_transmission:Ge,KHR_materials_unlit:me,KHR_materials_variants:Ie,KHR_materials_volume:Ke,KHR_materials_volume_scatter:We,KHR_mesh_quantization:Qe,KHR_node_hoverability:_n,KHR_node_selectability:hn,KHR_node_visibility:cn,KHR_texture_basisu:Ze,KHR_texture_transform:et,KHR_xmp_json_ld:nt,LoadBoundingInfoFromPositionAccessor:z,MSFT_audio_emitter:Kt,MSFT_lod:Wt,MSFT_minecraftMesh:zt,MSFT_sRGBFactors:Yt,OpenPBRMaterialLoadingAdapter:Cn,PBRMaterialLoadingAdapter:On,SetInterpolationForKey:N,TransformNodeAnimationPropertyInfo:st,WeightAnimationPropertyInfo:lt,_AddInteractivityObjectModel:ln,addNewInteractivityFlowGraphMapping:Jt,getAllSupportedNativeNodeTypes:nn,getMappingForDeclaration:Qt,getMappingForFullOperationName:Xt,getQuaternion:ot,getVector3:rt,getWeights:at,gltfTypeToBabylonType:rn,registerGLTFExtension:H,registeredGLTFExtensions:V,unregisterGLTFExtension:K},Pn=o({},An),Ln=o(o({},{__proto__:null}),((yn={}).Extensions=Pn,yn)),Fn=o(o({},Rn),((vn={}).Loader=Ln,vn)),En="undefined"!=typeof global?global:"undefined"!=typeof window?window:void 0;if(void 0!==En){En.BABYLON=En.BABYLON||{};var Sn=En.BABYLON;Sn.GLTF2=Sn.GLTF2||{},Sn.GLTF2.Loader=Sn.GLTF2.Loader||{},Sn.GLTF2.Loader.Extensions=Sn.GLTF2.Loader.Extensions||{};var kn=["Loader"];for(var In in Pn)Sn.GLTF2.Loader.Extensions[In]=Pn[In],kn.push(In);for(var In in Ln)"Extensions"!==In&&(Sn.GLTF2.Loader[In]=Ln[In],kn.push(In));for(var In in Fn)kn.indexOf(In)>-1||(Sn.GLTF2[In]=Fn[In])}e.GLTF2=Fn,e.GLTFFileLoader=T,e.GLTFLoaderDefaultOptions=y,e.GLTFValidation=h});
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("babylonjs")):"function"==typeof define&&define.amd?define(["exports","babylonjs"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).BABYLON=e.BABYLON||{},e.BABYLON)}(this,function(e,t){"use strict";var n=function(e,t){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},n(e,t)};function r(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}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}var o=function(){return o=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},o.apply(this,arguments)};function a(e,t,n,r){return new(n||(n=Promise))(function(o,a){function i(e){try{l(r.next(e))}catch(e){a(e)}}function s(e){try{l(r.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(i,s)}l((r=r.apply(e,t||[])).next())})}function i(e,t){var n,r,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=s(0),i.throw=s(1),i.return=s(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(l){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(n=1,r&&(o=2&s[0]?r.return:s[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,s[1])).done)return o;switch(r=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,r=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){a.label=s[1];break}if(6===s[0]&&a.label<o[1]){a.label=o[1],o=s;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(s);break}o[2]&&a.ops.pop(),a.trys.pop();continue}s=t.call(e,a)}catch(e){s=[6,e],r=0}finally{n=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,l])}}}function s(e,t,n,r){var o={externalResourceFunction:r};return n&&(o.uri="file:"===t?n:t+n),ArrayBuffer.isView(e)?GLTFValidator.validateBytes(e,o):GLTFValidator.validateString(e,o)}function l(){var e=[];onmessage=function(t){var n=t.data;switch(n.id){case"init":importScripts(n.url);break;case"validate":s(n.data,n.rootUrl,n.fileName,function(t){return new Promise(function(n,r){var o=e.length;e.push({resolve:n,reject:r}),postMessage({id:"getExternalResource",index:o,uri:t})})}).then(function(e){postMessage({id:"validate.resolve",value:e})},function(e){postMessage({id:"validate.reject",reason:e})});break;case"getExternalResource.resolve":e[n.index].resolve(n.value);break;case"getExternalResource.reject":e[n.index].reject(n.reason)}}}Object.create,Object.create,"function"==typeof SuppressedError&&SuppressedError;var u,c,f,h=function(){function e(){}return e.ValidateAsync=function(n,r,o,a){var i=this;return"function"==typeof Worker?new Promise(function(u,c){var f="".concat(s,"(").concat(l,")()"),h=URL.createObjectURL(new Blob([f],{type:"application/javascript"})),p=new Worker(h),d=function(e){p.removeEventListener("error",d),p.removeEventListener("message",m),c(e)},m=function(t){var n=t.data;switch(n.id){case"getExternalResource":a(n.uri).then(function(e){p.postMessage({id:"getExternalResource.resolve",index:n.index,value:e},[e.buffer])},function(e){p.postMessage({id:"getExternalResource.reject",index:n.index,reason:e})});break;case"validate.resolve":p.removeEventListener("error",d),p.removeEventListener("message",m),e._LastResults=n.value,u(n.value),p.terminate();break;case"validate.reject":p.removeEventListener("error",d),p.removeEventListener("message",m),c(n.reason),p.terminate()}};if(p.addEventListener("error",d),p.addEventListener("message",m),p.postMessage({id:"init",url:t.Tools.GetBabylonScriptURL(i.Configuration.url)}),ArrayBuffer.isView(n)){var _=n.slice();p.postMessage({id:"validate",data:_,rootUrl:r,fileName:o},[_.buffer])}else p.postMessage({id:"validate",data:n,rootUrl:r,fileName:o})}):(this._LoadScriptPromise||(this._LoadScriptPromise=t.Tools.LoadBabylonScriptAsync(this.Configuration.url)),this._LoadScriptPromise.then(function(){return s(n,r,o,a)}))},e.Configuration={url:"".concat(t.Tools._DefaultCdnUrl,"/gltf_validator.js")},e._LastResults=null,e}(),p={__proto__:null,GLTFValidation:h},d="Z2xURg",m="gltf",_={".gltf":{isBinary:!1,mimeType:"model/gltf+json"},".glb":{isBinary:!0,mimeType:"model/gltf-binary"}};function b(e,t,n){try{return Promise.resolve(new Uint8Array(e,t,n))}catch(e){return Promise.reject(e)}}e.GLTFLoaderCoordinateSystemMode=void 0,(u=e.GLTFLoaderCoordinateSystemMode||(e.GLTFLoaderCoordinateSystemMode={}))[u.AUTO=0]="AUTO",u[u.FORCE_RIGHT_HANDED=1]="FORCE_RIGHT_HANDED",e.GLTFLoaderAnimationStartMode=void 0,(c=e.GLTFLoaderAnimationStartMode||(e.GLTFLoaderAnimationStartMode={}))[c.NONE=0]="NONE",c[c.FIRST=1]="FIRST",c[c.ALL=2]="ALL",e.GLTFLoaderState=void 0,(f=e.GLTFLoaderState||(e.GLTFLoaderState={}))[f.LOADING=0]="LOADING",f[f.READY=1]="READY",f[f.COMPLETE=2]="COMPLETE";var g=function(){this.alwaysComputeBoundingBox=!1,this.alwaysComputeSkeletonRootNode=!1,this.animationStartMode=e.GLTFLoaderAnimationStartMode.FIRST,this.compileMaterials=!1,this.compileShadowGenerators=!1,this.coordinateSystemMode=e.GLTFLoaderCoordinateSystemMode.AUTO,this.createInstances=!0,this.loadAllMaterials=!1,this.loadMorphTargets=!0,this.loadNodeAnimations=!0,this.loadOnlyMaterials=!1,this.loadSkins=!0,this.skipMaterials=!1,this.targetFps=60,this.transparencyAsCoverage=!1,this.useClipPlane=!1,this.useGltfTextureNames=!1,this.useRangeRequests=!1,this.useSRGBBuffers=!0,this.validate=!1,this.useOpenPBR=!1,this.dontUseTransmissionHelper=!1},y=new g,v=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.extensionOptions={},t.preprocessUrlAsync=function(e){return Promise.resolve(e)},t}return r(t,e),t.prototype.copyFrom=function(e){var t,n,r,o,a,i,s,l,u,c,f,h,p,d,m,_,b,g,y,v,T,x,A,C,w,O;e&&(this.alwaysComputeBoundingBox=null!==(t=e.alwaysComputeBoundingBox)&&void 0!==t?t:this.alwaysComputeBoundingBox,this.alwaysComputeSkeletonRootNode=null!==(n=e.alwaysComputeSkeletonRootNode)&&void 0!==n?n:this.alwaysComputeSkeletonRootNode,this.animationStartMode=null!==(r=e.animationStartMode)&&void 0!==r?r:this.animationStartMode,this.capturePerformanceCounters=null!==(o=e.capturePerformanceCounters)&&void 0!==o?o:this.capturePerformanceCounters,this.compileMaterials=null!==(a=e.compileMaterials)&&void 0!==a?a:this.compileMaterials,this.compileShadowGenerators=null!==(i=e.compileShadowGenerators)&&void 0!==i?i:this.compileShadowGenerators,this.coordinateSystemMode=null!==(s=e.coordinateSystemMode)&&void 0!==s?s:this.coordinateSystemMode,this.createInstances=null!==(l=e.createInstances)&&void 0!==l?l:this.createInstances,this.customRootNode=e.customRootNode,this.extensionOptions=null!==(u=e.extensionOptions)&&void 0!==u?u:this.extensionOptions,this.loadAllMaterials=null!==(c=e.loadAllMaterials)&&void 0!==c?c:this.loadAllMaterials,this.loadMorphTargets=null!==(f=e.loadMorphTargets)&&void 0!==f?f:this.loadMorphTargets,this.loadNodeAnimations=null!==(h=e.loadNodeAnimations)&&void 0!==h?h:this.loadNodeAnimations,this.loadOnlyMaterials=null!==(p=e.loadOnlyMaterials)&&void 0!==p?p:this.loadOnlyMaterials,this.loadSkins=null!==(d=e.loadSkins)&&void 0!==d?d:this.loadSkins,this.loggingEnabled=null!==(m=e.loggingEnabled)&&void 0!==m?m:this.loggingEnabled,this.onCameraLoaded=e.onCameraLoaded,this.onMaterialLoaded=e.onMaterialLoaded,this.onMeshLoaded=e.onMeshLoaded,this.onParsed=e.onParsed,this.onSkinLoaded=e.onSkinLoaded,this.onTextureLoaded=e.onTextureLoaded,this.onValidated=e.onValidated,this.preprocessUrlAsync=null!==(_=e.preprocessUrlAsync)&&void 0!==_?_:this.preprocessUrlAsync,this.skipMaterials=null!==(b=e.skipMaterials)&&void 0!==b?b:this.skipMaterials,this.targetFps=null!==(g=e.targetFps)&&void 0!==g?g:this.targetFps,this.transparencyAsCoverage=null!==(y=e.transparencyAsCoverage)&&void 0!==y?y:this.transparencyAsCoverage,this.useClipPlane=null!==(v=e.useClipPlane)&&void 0!==v?v:this.useClipPlane,this.useGltfTextureNames=null!==(T=e.useGltfTextureNames)&&void 0!==T?T:this.useGltfTextureNames,this.useOpenPBR=null!==(x=e.useOpenPBR)&&void 0!==x?x:this.useOpenPBR,this.useRangeRequests=null!==(A=e.useRangeRequests)&&void 0!==A?A:this.useRangeRequests,this.useSRGBBuffers=null!==(C=e.useSRGBBuffers)&&void 0!==C?C:this.useSRGBBuffers,this.validate=null!==(w=e.validate)&&void 0!==w?w:this.validate,this.dontUseTransmissionHelper=null!==(O=e.dontUseTransmissionHelper)&&void 0!==O?O:this.dontUseTransmissionHelper)},t}(g),T=function(n){function a(e){var r=n.call(this)||this;return r.onParsedObservable=new t.Observable,r.onMeshLoadedObservable=new t.Observable,r.onSkinLoadedObservable=new t.Observable,r.onTextureLoadedObservable=new t.Observable,r.onMaterialLoadedObservable=new t.Observable,r.onCameraLoadedObservable=new t.Observable,r.onCompleteObservable=new t.Observable,r.onErrorObservable=new t.Observable,r.onDisposeObservable=new t.Observable,r.onExtensionLoadedObservable=new t.Observable,r.onValidatedObservable=new t.Observable,r._loader=null,r._state=null,r._requests=new Array,r.name=m,r.extensions=_,r.onLoaderStateChangedObservable=new t.Observable,r._logIndentLevel=0,r._loggingEnabled=!1,r._log=r._logDisabled,r._capturePerformanceCounters=!1,r._startPerformanceCounter=r._startPerformanceCounterDisabled,r._endPerformanceCounter=r._endPerformanceCounterDisabled,r.copyFrom(Object.assign(o({},y),e)),r}return r(a,n),Object.defineProperty(a.prototype,"onParsed",{set:function(e){this._onParsedObserver&&this.onParsedObservable.remove(this._onParsedObserver),e&&(this._onParsedObserver=this.onParsedObservable.add(e))},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"onMeshLoaded",{set:function(e){this._onMeshLoadedObserver&&this.onMeshLoadedObservable.remove(this._onMeshLoadedObserver),e&&(this._onMeshLoadedObserver=this.onMeshLoadedObservable.add(e))},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"onSkinLoaded",{set:function(e){this._onSkinLoadedObserver&&this.onSkinLoadedObservable.remove(this._onSkinLoadedObserver),e&&(this._onSkinLoadedObserver=this.onSkinLoadedObservable.add(function(t){return e(t.node,t.skinnedNode)}))},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"onTextureLoaded",{set:function(e){this._onTextureLoadedObserver&&this.onTextureLoadedObservable.remove(this._onTextureLoadedObserver),e&&(this._onTextureLoadedObserver=this.onTextureLoadedObservable.add(e))},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"onMaterialLoaded",{set:function(e){this._onMaterialLoadedObserver&&this.onMaterialLoadedObservable.remove(this._onMaterialLoadedObserver),e&&(this._onMaterialLoadedObserver=this.onMaterialLoadedObservable.add(e))},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"onCameraLoaded",{set:function(e){this._onCameraLoadedObserver&&this.onCameraLoadedObservable.remove(this._onCameraLoadedObserver),e&&(this._onCameraLoadedObserver=this.onCameraLoadedObservable.add(e))},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"onComplete",{set:function(e){this._onCompleteObserver&&this.onCompleteObservable.remove(this._onCompleteObserver),this._onCompleteObserver=this.onCompleteObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"onError",{set:function(e){this._onErrorObserver&&this.onErrorObservable.remove(this._onErrorObserver),this._onErrorObserver=this.onErrorObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"onDispose",{set:function(e){this._onDisposeObserver&&this.onDisposeObservable.remove(this._onDisposeObserver),this._onDisposeObserver=this.onDisposeObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"onExtensionLoaded",{set:function(e){this._onExtensionLoadedObserver&&this.onExtensionLoadedObservable.remove(this._onExtensionLoadedObserver),this._onExtensionLoadedObserver=this.onExtensionLoadedObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(a.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(a.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(a.prototype,"onValidated",{set:function(e){this._onValidatedObserver&&this.onValidatedObservable.remove(this._onValidatedObserver),this._onValidatedObserver=this.onValidatedObservable.add(e)},enumerable:!1,configurable:!0}),a.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()},a.prototype.loadFile=function(e,n,r,o,a,i,s,l){var u=this;if(ArrayBuffer.isView(n))return this._loadBinary(e,n,r,o,s,l),null;this._progressCallback=a;var c=n.name||t.Tools.GetFilename(n);if(i){if(this.useRangeRequests){this.validate&&t.Logger.Warn("glTF validation is not supported when range requests are enabled");var f={abort:function(){},onCompleteObservable:new t.Observable},h={readAsync:function(t,r){return new Promise(function(o,a){u._loadFile(e,n,function(e){o(new Uint8Array(e))},!0,function(e){a(e)},function(e){e.setRequestHeader("Range","bytes=".concat(t,"-").concat(t+r-1))})})},byteLength:0};return this._unpackBinaryAsync(new t.DataReader(h)).then(function(e){f.onCompleteObservable.notifyObservers(f),o(e)},s?function(e){return s(void 0,e)}:void 0),f}return this._loadFile(e,n,function(n){u._validate(e,new Uint8Array(n,0,n.byteLength),r,c),u._unpackBinaryAsync(new t.DataReader({readAsync:function(e,t){return b(n,e,t)},byteLength:n.byteLength})).then(function(e){o(e)},s?function(e){return s(void 0,e)}:void 0)},!0,s)}return this._loadFile(e,n,function(t){try{u._validate(e,t,r,c),o({json:u._parseJson(t)})}catch(e){s&&s()}},!1,s)},a.prototype._loadBinary=function(e,n,r,o,a,i){this._validate(e,new Uint8Array(n.buffer,n.byteOffset,n.byteLength),r,i),this._unpackBinaryAsync(new t.DataReader({readAsync:function(e,t){return function(e,t,n){try{if(t<0||t>=e.byteLength)throw new RangeError("Offset is out of range.");if(t+n>e.byteLength)throw new RangeError("Length is out of range.");return Promise.resolve(new Uint8Array(e.buffer,e.byteOffset+t,n))}catch(e){return Promise.reject(e)}}(n,e,t)},byteLength:n.byteLength})).then(function(e){o(e)},a?function(e){return a(void 0,e)}:void 0)},a.prototype.importMeshAsync=function(e,t,n,r,o,a){var i=this;return Promise.resolve().then(function(){return i.onParsedObservable.notifyObservers(n),i.onParsedObservable.clear(),i._log("Loading ".concat(a||"")),i._loader=i._getLoader(n),i._loader.importMeshAsync(e,t,null,n,r,o,a)})},a.prototype.loadAsync=function(e,t,n,r,o){var a=this;return Promise.resolve().then(function(){return a.onParsedObservable.notifyObservers(t),a.onParsedObservable.clear(),a._log("Loading ".concat(o||"")),a._loader=a._getLoader(t),a._loader.loadAsync(e,t,n,r,o)})},a.prototype.loadAssetContainerAsync=function(e,n,r,o,a){var i=this;return Promise.resolve().then(function(){i.onParsedObservable.notifyObservers(n),i.onParsedObservable.clear(),i._log("Loading ".concat(a||"")),i._loader=i._getLoader(n);var s=new t.AssetContainer(e),l=[];i.onMaterialLoadedObservable.add(function(e){l.push(e)});var u=[];i.onTextureLoadedObservable.add(function(e){u.push(e)});var c=[];i.onCameraLoadedObservable.add(function(e){c.push(e)});var f=[];return i.onMeshLoadedObservable.add(function(e){e.morphTargetManager&&f.push(e.morphTargetManager)}),i._loader.importMeshAsync(null,e,s,n,r,o,a).then(function(e){return Array.prototype.push.apply(s.geometries,e.geometries),Array.prototype.push.apply(s.meshes,e.meshes),Array.prototype.push.apply(s.particleSystems,e.particleSystems),Array.prototype.push.apply(s.skeletons,e.skeletons),Array.prototype.push.apply(s.animationGroups,e.animationGroups),Array.prototype.push.apply(s.materials,l),Array.prototype.push.apply(s.textures,u),Array.prototype.push.apply(s.lights,e.lights),Array.prototype.push.apply(s.transformNodes,e.transformNodes),Array.prototype.push.apply(s.cameras,c),Array.prototype.push.apply(s.morphTargetManagers,f),s})})},a.prototype.canDirectLoad=function(e){return function(e){return-1!==e.indexOf("asset")&&-1!==e.indexOf("version")||e.startsWith("data:base64,"+d)||e.startsWith("data:;base64,"+d)||e.startsWith("data:application/octet-stream;base64,"+d)||e.startsWith("data:model/gltf-binary;base64,"+d)}(e)},a.prototype.directLoad=function(e,n){if(n.startsWith("base64,"+d)||n.startsWith(";base64,"+d)||n.startsWith("application/octet-stream;base64,"+d)||n.startsWith("model/gltf-binary;base64,"+d)){var r=t.DecodeBase64UrlToBinary(n);return this._validate(e,new Uint8Array(r,0,r.byteLength)),this._unpackBinaryAsync(new t.DataReader({readAsync:function(e,t){return b(r,e,t)},byteLength:r.byteLength}))}return this._validate(e,n),Promise.resolve({json:this._parseJson(n)})},a.prototype.createPlugin=function(e){return new a(e[m])},Object.defineProperty(a.prototype,"loaderState",{get:function(){return this._state},enumerable:!1,configurable:!0}),a.prototype.whenCompleteAsync=function(){var e=this;return new Promise(function(t,n){e.onCompleteObservable.addOnce(function(){t()}),e.onErrorObservable.addOnce(function(e){n(e)})})},a.prototype._setState=function(t){this._state!==t&&(this._state=t,this.onLoaderStateChangedObservable.notifyObservers(this._state),this._log(e.GLTFLoaderState[this._state]))},a.prototype._loadFile=function(e,t,n,r,o,a){var i=this,s=e._loadFile(t,n,function(e){i._onProgress(e,s)},!0,r,o,a);return s.onCompleteObservable.add(function(){s._lengthComputable=!0,s._total=s._loaded}),this._requests.push(s),s},a.prototype._onProgress=function(e,t){if(this._progressCallback){t._lengthComputable=e.lengthComputable,t._loaded=e.loaded,t._total=e.total;for(var n=!0,r=0,o=0,a=0,i=this._requests;a<i.length;a++){var s=i[a];if(void 0===s._lengthComputable||void 0===s._loaded||void 0===s._total)return;n=n&&s._lengthComputable,r+=s._loaded,o+=s._total}this._progressCallback({lengthComputable:n,loaded:r,total:n?o:0})}},a.prototype._validate=function(e,n,r,o){var a=this;void 0===r&&(r=""),void 0===o&&(o=""),this.validate&&(this._startPerformanceCounter("Validate JSON"),h.ValidateAsync(n,r,o,function(t){return a.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){a._endPerformanceCounter("Validate JSON"),a.onValidatedObservable.notifyObservers(e),a.onValidatedObservable.clear()},function(e){a._endPerformanceCounter("Validate JSON"),t.Tools.Warn("Failed to validate: ".concat(e.message)),a.onValidatedObservable.clear()}))},a.prototype._getLoader=function(e){var t=e.json.asset||{};this._log("Asset version: ".concat(t.version)),t.minVersion&&this._log("Asset minimum version: ".concat(t.minVersion)),t.generator&&this._log("Asset generator: ".concat(t.generator));var n=a._parseVersion(t.version);if(!n)throw new Error("Invalid version: "+t.version);if(void 0!==t.minVersion){var r=a._parseVersion(t.minVersion);if(!r)throw new Error("Invalid minimum version: "+t.minVersion);if(a._compareVersion(r,{major:2,minor:0})>0)throw new Error("Incompatible minimum version: "+t.minVersion)}var o={1:a._CreateGLTF1Loader,2:a._CreateGLTF2Loader}[n.major];if(!o)throw new Error("Unsupported version: "+t.version);return o(this)},a.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},a.prototype._unpackBinaryAsync=function(e){var n=this;return this._startPerformanceCounter("Unpack Binary"),e.loadAsync(20).then(function(){var r=e.readUint32();if(1179937895!==r)throw new t.RuntimeError("Unexpected magic: "+r,t.ErrorCodes.GLTFLoaderUnexpectedMagicError);var o=e.readUint32();n.loggingEnabled&&n._log("Binary version: ".concat(o));var a,i=e.readUint32();switch(n.useRangeRequests||i===e.buffer.byteLength||t.Logger.Warn("Length in header does not match actual data length: ".concat(i," != ").concat(e.buffer.byteLength)),o){case 1:a=n._unpackBinaryV1Async(e,i);break;case 2:a=n._unpackBinaryV2Async(e,i);break;default:throw new Error("Unsupported version: "+o)}return n._endPerformanceCounter("Unpack Binary"),a})},a.prototype._unpackBinaryV1Async=function(e,t){var n=e.readUint32(),r=e.readUint32();if(0!==r)throw new Error("Unexpected content format: ".concat(r));var o=t-e.byteOffset,a={json:this._parseJson(e.readString(n)),bin:null};if(0!==o){var i=e.byteOffset;a.bin={readAsync:function(t,n){return e.buffer.readAsync(i+t,n)},byteLength:o}}return Promise.resolve(a)},a.prototype._unpackBinaryV2Async=function(e,t){var n=this,r=1313821514,o=e.readUint32();if(e.readUint32()!==r)throw new Error("First chunk format is not JSON");return e.byteOffset+o===t?e.loadAsync(o).then(function(){return{json:n._parseJson(e.readString(o)),bin:null}}):e.loadAsync(o+8).then(function(){var a={json:n._parseJson(e.readString(o)),bin:null},i=function(){var n=e.readUint32();switch(e.readUint32()){case r:throw new Error("Unexpected JSON chunk");case 5130562:var o=e.byteOffset;a.bin={readAsync:function(t,n){return e.buffer.readAsync(o+t,n)},byteLength:n},e.skipBytes(n);break;default:e.skipBytes(n)}return e.byteOffset!==t?e.loadAsync(8).then(i):Promise.resolve(a)};return i()})},a._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},a._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},a.prototype._logOpen=function(e){this._log(e),this._logIndentLevel++},a.prototype._logClose=function(){--this._logIndentLevel},a.prototype._logEnabled=function(e){var n=a._logSpaces.substring(0,2*this._logIndentLevel);t.Logger.Log("".concat(n).concat(e))},a.prototype._logDisabled=function(e){},a.prototype._startPerformanceCounterEnabled=function(e){t.Tools.StartPerformanceCounter(e)},a.prototype._startPerformanceCounterDisabled=function(e){},a.prototype._endPerformanceCounterEnabled=function(e){t.Tools.EndPerformanceCounter(e)},a.prototype._endPerformanceCounterDisabled=function(e){},a.IncrementalLoading=!0,a.HomogeneousCoordinates=!1,a._logSpaces=" ",a}(v);t.RegisterSceneLoaderPlugin(new T);var x={__proto__:null,GLTFFileLoader:T,get GLTFLoaderAnimationStartMode(){return e.GLTFLoaderAnimationStartMode},get GLTFLoaderCoordinateSystemMode(){return e.GLTFLoaderCoordinateSystemMode},GLTFLoaderDefaultOptions:y,get GLTFLoaderState(){return e.GLTFLoaderState}},A="undefined"!=typeof global?global:"undefined"!=typeof window?window:void 0;if(void 0!==A){for(var C in A.BABYLON=A.BABYLON||{},x)A.BABYLON[C]=x[C];for(var C in p)A.BABYLON[C]=p[C]}var w=[{regex:new RegExp("^/nodes/\\d+/extensions/")}],O=function(){function e(e,t){this._gltf=e,this._infoTree=t}return e.prototype.convert=function(e){var t=this._gltf,n=this._infoTree,r=void 0;if(!e.startsWith("/"))throw new Error("Path must start with a /");var o=e.split("/");if(o.shift(),o[o.length-1].includes(".length")){var a=o[o.length-1].split(".");o.pop(),o.push.apply(o,a)}for(var i=!1,s=0,l=o;s<l.length;s++){var u=l[s],c="length"===u;if(c&&!n.__array__)throw new Error("Path ".concat(e," is invalid"));if(n.__ignoreObjectTree__&&(i=!0),n.__array__&&!c)n=n.__array__;else if(!(n=n[u]))throw new Error("Path ".concat(e," is invalid"));if(!i)if(void 0===t){if(!w.find(function(t){return t.regex.test(e)}))throw new Error("Path ".concat(e," is invalid"))}else c||(t=null==t?void 0:t[u]);(n.__target__||c)&&(r=t)}return{object:r,info:n}},e}(),M={length:{type:"number",get:function(e){return e.length},getTarget:function(e){return e.map(function(e){return e._babylonTransformNode})},getPropertyName:[function(){return"length"}]},__array__:{__target__:!0,translation:{type:"Vector3",get:function(e){var t;return null===(t=e._babylonTransformNode)||void 0===t?void 0:t.position},set:function(e,t){var n;return null===(n=t._babylonTransformNode)||void 0===n?void 0:n.position.copyFrom(e)},getTarget:function(e){return e._babylonTransformNode},getPropertyName:[function(){return"position"}]},rotation:{type:"Quaternion",get:function(e){var t;return null===(t=e._babylonTransformNode)||void 0===t?void 0:t.rotationQuaternion},set:function(e,t){var n,r;return null===(r=null===(n=t._babylonTransformNode)||void 0===n?void 0:n.rotationQuaternion)||void 0===r?void 0:r.copyFrom(e)},getTarget:function(e){return e._babylonTransformNode},getPropertyName:[function(){return"rotationQuaternion"}]},scale:{type:"Vector3",get:function(e){var t;return null===(t=e._babylonTransformNode)||void 0===t?void 0:t.scaling},set:function(e,t){var n;return null===(n=t._babylonTransformNode)||void 0===n?void 0:n.scaling.copyFrom(e)},getTarget:function(e){return e._babylonTransformNode},getPropertyName:[function(){return"scaling"}]},weights:{length:{type:"number",get:function(e){return e._numMorphTargets},getTarget:function(e){return e._babylonTransformNode},getPropertyName:[function(){return"influence"}]},__array__:{__target__:!0,type:"number",get:function(e,t){var n,r;return void 0!==t?null===(r=null===(n=e._primitiveBabylonMeshes)||void 0===n?void 0:n[0].morphTargetManager)||void 0===r?void 0:r.getTarget(t).influence:void 0},getTarget:function(e){return e._babylonTransformNode},getPropertyName:[function(){return"influence"}]},type:"number[]",get:function(e,t){return[0]},getTarget:function(e){return e._babylonTransformNode},getPropertyName:[function(){return"influence"}]},matrix:{type:"Matrix",get:function(e){var n,r,o;return t.Matrix.Compose(null===(n=e._babylonTransformNode)||void 0===n?void 0:n.scaling,null===(r=e._babylonTransformNode)||void 0===r?void 0:r.rotationQuaternion,null===(o=e._babylonTransformNode)||void 0===o?void 0:o.position)},getTarget:function(e){return e._babylonTransformNode},isReadOnly:!0},globalMatrix:{type:"Matrix",get:function(e){for(var n,r,o,a,i,s,l,u=t.Matrix.Identity(),c=e.parent;c&&c.parent;)c=c.parent;var f=(null===(n=e._babylonTransformNode)||void 0===n?void 0:n.position._isDirty)||(null===(o=null===(r=e._babylonTransformNode)||void 0===r?void 0:r.rotationQuaternion)||void 0===o?void 0:o._isDirty)||(null===(a=e._babylonTransformNode)||void 0===a?void 0:a.scaling._isDirty);if(c){var h=null===(i=c._babylonTransformNode)||void 0===i?void 0:i.computeWorldMatrix(!0).invert();h&&(null===(l=null===(s=e._babylonTransformNode)||void 0===s?void 0:s.computeWorldMatrix(f))||void 0===l||l.multiplyToRef(h,u))}else e._babylonTransformNode&&u.copyFrom(e._babylonTransformNode.computeWorldMatrix(f));return u},getTarget:function(e){return e._babylonTransformNode},isReadOnly:!0},extensions:{EXT_lights_ies:{multiplier:{type:"number",get:function(e){var n,r;return null===(r=null===(n=e._babylonTransformNode)||void 0===n?void 0:n.getChildren(function(e){return e instanceof t.SpotLight},!0)[0])||void 0===r?void 0:r.intensity},getTarget:function(e){var n;return null===(n=e._babylonTransformNode)||void 0===n?void 0:n.getChildren(function(e){return e instanceof t.SpotLight},!0)[0]},set:function(e,n){if(n._babylonTransformNode){var r=n._babylonTransformNode.getChildren(function(e){return e instanceof t.SpotLight},!0)[0];r&&(r.intensity=e)}}},color:{type:"Color3",get:function(e){var n,r;return null===(r=null===(n=e._babylonTransformNode)||void 0===n?void 0:n.getChildren(function(e){return e instanceof t.SpotLight},!0)[0])||void 0===r?void 0:r.diffuse},getTarget:function(e){var n;return null===(n=e._babylonTransformNode)||void 0===n?void 0:n.getChildren(function(e){return e instanceof t.SpotLight},!0)[0]},set:function(e,n){if(n._babylonTransformNode){var r=n._babylonTransformNode.getChildren(function(e){return e instanceof t.SpotLight},!0)[0];r&&(r.diffuse=e)}}}},KHR_node_visibility:{visible:{type:"boolean",get:function(e){return!!e._primitiveBabylonMeshes&&e._primitiveBabylonMeshes[0].isVisible},getTarget:function(){},set:function(e,t){t._primitiveBabylonMeshes&&t._primitiveBabylonMeshes.forEach(function(t){return t.isVisible=e})}}}}}},R={__array__:{__target__:!0,orthographic:{xmag:{componentsCount:2,type:"Vector2",get:function(e){var n,r,o,a;return new t.Vector2(null!==(r=null===(n=e._babylonCamera)||void 0===n?void 0:n.orthoLeft)&&void 0!==r?r:0,null!==(a=null===(o=e._babylonCamera)||void 0===o?void 0:o.orthoRight)&&void 0!==a?a:0)},set:function(e,t){t._babylonCamera&&(t._babylonCamera.orthoLeft=e.x,t._babylonCamera.orthoRight=e.y)},getTarget:function(e){return e},getPropertyName:[function(){return"orthoLeft"},function(){return"orthoRight"}]},ymag:{componentsCount:2,type:"Vector2",get:function(e){var n,r,o,a;return new t.Vector2(null!==(r=null===(n=e._babylonCamera)||void 0===n?void 0:n.orthoBottom)&&void 0!==r?r:0,null!==(a=null===(o=e._babylonCamera)||void 0===o?void 0:o.orthoTop)&&void 0!==a?a:0)},set:function(e,t){t._babylonCamera&&(t._babylonCamera.orthoBottom=e.x,t._babylonCamera.orthoTop=e.y)},getTarget:function(e){return e},getPropertyName:[function(){return"orthoBottom"},function(){return"orthoTop"}]},zfar:{type:"number",get:function(e){var t;return null===(t=e._babylonCamera)||void 0===t?void 0:t.maxZ},set:function(e,t){t._babylonCamera&&(t._babylonCamera.maxZ=e)},getTarget:function(e){return e},getPropertyName:[function(){return"maxZ"}]},znear:{type:"number",get:function(e){var t;return null===(t=e._babylonCamera)||void 0===t?void 0:t.minZ},set:function(e,t){t._babylonCamera&&(t._babylonCamera.minZ=e)},getTarget:function(e){return e},getPropertyName:[function(){return"minZ"}]}},perspective:{aspectRatio:{type:"number",get:function(e){var t;return null===(t=e._babylonCamera)||void 0===t?void 0:t.getEngine().getAspectRatio(e._babylonCamera)},getTarget:function(e){return e},getPropertyName:[function(){return"aspectRatio"}],isReadOnly:!0},yfov:{type:"number",get:function(e){var t;return null===(t=e._babylonCamera)||void 0===t?void 0:t.fov},set:function(e,t){t._babylonCamera&&(t._babylonCamera.fov=e)},getTarget:function(e){return e},getPropertyName:[function(){return"fov"}]},zfar:{type:"number",get:function(e){var t;return null===(t=e._babylonCamera)||void 0===t?void 0:t.maxZ},set:function(e,t){t._babylonCamera&&(t._babylonCamera.maxZ=e)},getTarget:function(e){return e},getPropertyName:[function(){return"maxZ"}]},znear:{type:"number",get:function(e){var t;return null===(t=e._babylonCamera)||void 0===t?void 0:t.minZ},set:function(e,t){t._babylonCamera&&(t._babylonCamera.minZ=e)},getTarget:function(e){return e},getPropertyName:[function(){return"minZ"}]}}}},P={__array__:{__target__:!0,emissiveFactor:{type:"Color3",get:function(e,t,n){return E(e,0,n).emissiveColor},set:function(e,t,n,r){return E(t,0,r).emissiveColor.copyFrom(e)},getTarget:function(e,t,n){return E(e,0,n)},getPropertyName:[function(){return"emissiveColor"}]},emissiveTexture:{extensions:{KHR_texture_transform:S("emissiveTexture")}},normalTexture:{scale:{type:"number",get:function(e,t,n){var r;return null===(r=F(e,n,"bumpTexture"))||void 0===r?void 0:r.level},set:function(e,t,n,r){var o=F(t,r,"bumpTexture");o&&(o.level=e)},getTarget:function(e,t,n){return E(e,0,n)},getPropertyName:[function(){return"level"}]},extensions:{KHR_texture_transform:S("bumpTexture")}},occlusionTexture:{strength:{type:"number",get:function(e,t,n){return E(e,0,n).ambientTextureStrength},set:function(e,t,n,r){var o=E(t,0,r);o&&(o.ambientTextureStrength=e)},getTarget:function(e,t,n){return E(e,0,n)},getPropertyName:[function(){return"ambientTextureStrength"}]},extensions:{KHR_texture_transform:S("ambientTexture")}},pbrMetallicRoughness:{baseColorFactor:{type:"Color4",get:function(e,n,r){var o=E(e,0,r);return t.Color4.FromColor3(o.albedoColor,o.alpha)},set:function(e,t,n,r){var o=E(t,0,r);o.albedoColor.set(e.r,e.g,e.b),o.alpha=e.a},getTarget:function(e,t,n){return E(e,0,n)},getPropertyName:[function(){return"albedoColor"},function(){return"alpha"}]},baseColorTexture:{extensions:{KHR_texture_transform:S("albedoTexture")}},metallicFactor:{type:"number",get:function(e,t,n){return E(e,0,n).metallic},set:function(e,t,n,r){var o=E(t,0,r);o&&(o.metallic=e)},getTarget:function(e,t,n){return E(e,0,n)},getPropertyName:[function(){return"metallic"}]},roughnessFactor:{type:"number",get:function(e,t,n){return E(e,0,n).roughness},set:function(e,t,n,r){var o=E(t,0,r);o&&(o.roughness=e)},getTarget:function(e,t,n){return E(e,0,n)},getPropertyName:[function(){return"roughness"}]},metallicRoughnessTexture:{extensions:{KHR_texture_transform:S("metallicTexture")}}},extensions:{KHR_materials_anisotropy:{anisotropyStrength:{type:"number",get:function(e,t,n){return E(e,0,n).anisotropy.intensity},set:function(e,t,n,r){E(t,0,r).anisotropy.intensity=e},getTarget:function(e,t,n){return E(e,0,n)},getPropertyName:[function(){return"anisotropy.intensity"}]},anisotropyRotation:{type:"number",get:function(e,t,n){return E(e,0,n).anisotropy.angle},set:function(e,t,n,r){E(t,0,r).anisotropy.angle=e},getTarget:function(e,t,n){return E(e,0,n)},getPropertyName:[function(){return"anisotropy.angle"}]},anisotropyTexture:{extensions:{KHR_texture_transform:S("anisotropy","texture")}}},KHR_materials_clearcoat:{clearcoatFactor:{type:"number",get:function(e,t,n){return E(e,0,n).clearCoat.intensity},set:function(e,t,n,r){E(t,0,r).clearCoat.intensity=e},getTarget:function(e,t,n){return E(e,0,n)},getPropertyName:[function(){return"clearCoat.intensity"}]},clearcoatRoughnessFactor:{type:"number",get:function(e,t,n){return E(e,0,n).clearCoat.roughness},set:function(e,t,n,r){E(t,0,r).clearCoat.roughness=e},getTarget:function(e,t,n){return E(e,0,n)},getPropertyName:[function(){return"clearCoat.roughness"}]},clearcoatTexture:{extensions:{KHR_texture_transform:S("clearCoat","texture")}},clearcoatNormalTexture:{scale:{type:"number",get:function(e,t,n){var r;return null===(r=E(e,0,n).clearCoat.bumpTexture)||void 0===r?void 0:r.level},getTarget:E,set:function(e,t,n,r){return E(t,0,r).clearCoat.bumpTexture.level=e}},extensions:{KHR_texture_transform:S("clearCoat","bumpTexture")}},clearcoatRoughnessTexture:{extensions:{KHR_texture_transform:S("clearCoat","textureRoughness")}}},KHR_materials_dispersion:{dispersion:{type:"number",get:function(e,t,n){return E(e,0,n).subSurface.dispersion},getTarget:E,set:function(e,t,n,r){return E(t,0,r).subSurface.dispersion=e}}},KHR_materials_emissive_strength:{emissiveStrength:{type:"number",get:function(e,t,n){return E(e,0,n).emissiveIntensity},getTarget:E,set:function(e,t,n,r){return E(t,0,r).emissiveIntensity=e}}},KHR_materials_ior:{ior:{type:"number",get:function(e,t,n){return E(e,0,n).indexOfRefraction},getTarget:E,set:function(e,t,n,r){return E(t,0,r).indexOfRefraction=e}}},KHR_materials_iridescence:{iridescenceFactor:{type:"number",get:function(e,t,n){return E(e,0,n).iridescence.intensity},getTarget:E,set:function(e,t,n,r){return E(t,0,r).iridescence.intensity=e}},iridescenceIor:{type:"number",get:function(e,t,n){return E(e,0,n).iridescence.indexOfRefraction},getTarget:E,set:function(e,t,n,r){return E(t,0,r).iridescence.indexOfRefraction=e}},iridescenceTexture:{extensions:{KHR_texture_transform:S("iridescence","texture")}},iridescenceThicknessMaximum:{type:"number",get:function(e,t,n){return E(e,0,n).iridescence.maximumThickness},getTarget:E,set:function(e,t,n,r){return E(t,0,r).iridescence.maximumThickness=e}},iridescenceThicknessMinimum:{type:"number",get:function(e,t,n){return E(e,0,n).iridescence.minimumThickness},getTarget:E,set:function(e,t,n,r){return E(t,0,r).iridescence.minimumThickness=e}},iridescenceThicknessTexture:{extensions:{KHR_texture_transform:S("iridescence","thicknessTexture")}}},KHR_materials_sheen:{sheenColorFactor:{type:"Color3",get:function(e,t,n){return E(e,0,n).sheen.color},getTarget:E,set:function(e,t,n,r){return E(t,0,r).sheen.color.copyFrom(e)}},sheenColorTexture:{extensions:{KHR_texture_transform:S("sheen","texture")}},sheenRoughnessFactor:{type:"number",get:function(e,t,n){return E(e,0,n).sheen.intensity},getTarget:E,set:function(e,t,n,r){return E(t,0,r).sheen.intensity=e}},sheenRoughnessTexture:{extensions:{KHR_texture_transform:S("sheen","thicknessTexture")}}},KHR_materials_specular:{specularFactor:{type:"number",get:function(e,t,n){return E(e,0,n).metallicF0Factor},getTarget:E,set:function(e,t,n,r){return E(t,0,r).metallicF0Factor=e},getPropertyName:[function(){return"metallicF0Factor"}]},specularColorFactor:{type:"Color3",get:function(e,t,n){return E(e,0,n).metallicReflectanceColor},getTarget:E,set:function(e,t,n,r){return E(t,0,r).metallicReflectanceColor.copyFrom(e)},getPropertyName:[function(){return"metallicReflectanceColor"}]},specularTexture:{extensions:{KHR_texture_transform:S("metallicReflectanceTexture")}},specularColorTexture:{extensions:{KHR_texture_transform:S("reflectanceTexture")}}},KHR_materials_transmission:{transmissionFactor:{type:"number",get:function(e,t,n){return E(e,0,n).subSurface.refractionIntensity},getTarget:E,set:function(e,t,n,r){return E(t,0,r).subSurface.refractionIntensity=e},getPropertyName:[function(){return"subSurface.refractionIntensity"}]},transmissionTexture:{extensions:{KHR_texture_transform:S("subSurface","refractionIntensityTexture")}}},KHR_materials_diffuse_transmission:{diffuseTransmissionFactor:{type:"number",get:function(e,t,n){return E(e,0,n).subSurface.translucencyIntensity},getTarget:E,set:function(e,t,n,r){return E(t,0,r).subSurface.translucencyIntensity=e}},diffuseTransmissionTexture:{extensions:{KHR_texture_transform:S("subSurface","translucencyIntensityTexture")}},diffuseTransmissionColorFactor:{type:"Color3",get:function(e,t,n){return E(e,0,n).subSurface.translucencyColor},getTarget:E,set:function(e,t,n,r){var o;return e&&(null===(o=E(t,0,r).subSurface.translucencyColor)||void 0===o?void 0:o.copyFrom(e))}},diffuseTransmissionColorTexture:{extensions:{KHR_texture_transform:S("subSurface","translucencyColorTexture")}}},KHR_materials_volume:{attenuationColor:{type:"Color3",get:function(e,t,n){return E(e,0,n).subSurface.tintColor},getTarget:E,set:function(e,t,n,r){return E(t,0,r).subSurface.tintColor.copyFrom(e)}},attenuationDistance:{type:"number",get:function(e,t,n){return E(e,0,n).subSurface.tintColorAtDistance},getTarget:E,set:function(e,t,n,r){return E(t,0,r).subSurface.tintColorAtDistance=e}},thicknessFactor:{type:"number",get:function(e,t,n){return E(e,0,n).subSurface.maximumThickness},getTarget:E,set:function(e,t,n,r){return E(t,0,r).subSurface.maximumThickness=e}},thicknessTexture:{extensions:{KHR_texture_transform:S("subSurface","thicknessTexture")}}}}}},L={KHR_lights_punctual:{lights:{length:{type:"number",get:function(e){return e.length},getTarget:function(e){return e.map(function(e){return e._babylonLight})},getPropertyName:[function(e){return"length"}]},__array__:{__target__:!0,color:{type:"Color3",get:function(e){var t;return null===(t=e._babylonLight)||void 0===t?void 0:t.diffuse},set:function(e,t){var n;return null===(n=t._babylonLight)||void 0===n?void 0:n.diffuse.copyFrom(e)},getTarget:function(e){return e._babylonLight},getPropertyName:[function(e){return"diffuse"}]},intensity:{type:"number",get:function(e){var t;return null===(t=e._babylonLight)||void 0===t?void 0:t.intensity},set:function(e,t){return t._babylonLight?t._babylonLight.intensity=e:void 0},getTarget:function(e){return e._babylonLight},getPropertyName:[function(e){return"intensity"}]},range:{type:"number",get:function(e){var t;return null===(t=e._babylonLight)||void 0===t?void 0:t.range},set:function(e,t){return t._babylonLight?t._babylonLight.range=e:void 0},getTarget:function(e){return e._babylonLight},getPropertyName:[function(e){return"range"}]},spot:{innerConeAngle:{type:"number",get:function(e){var t;return null===(t=e._babylonLight)||void 0===t?void 0:t.innerAngle},set:function(e,t){return t._babylonLight?t._babylonLight.innerAngle=e:void 0},getTarget:function(e){return e._babylonLight},getPropertyName:[function(e){return"innerConeAngle"}]},outerConeAngle:{type:"number",get:function(e){var t;return null===(t=e._babylonLight)||void 0===t?void 0:t.angle},set:function(e,t){return t._babylonLight?t._babylonLight.angle=e:void 0},getTarget:function(e){return e._babylonLight},getPropertyName:[function(e){return"outerConeAngle"}]}}}}},EXT_lights_area:{lights:{length:{type:"number",get:function(e){return e.length},getTarget:function(e){return e.map(function(e){return e._babylonLight})},getPropertyName:[function(e){return"length"}]},__array__:{__target__:!0,color:{type:"Color3",get:function(e){var t;return null===(t=e._babylonLight)||void 0===t?void 0:t.diffuse},set:function(e,t){var n;return null===(n=t._babylonLight)||void 0===n?void 0:n.diffuse.copyFrom(e)},getTarget:function(e){return e._babylonLight},getPropertyName:[function(e){return"diffuse"}]},intensity:{type:"number",get:function(e){var t;return null===(t=e._babylonLight)||void 0===t?void 0:t.intensity},set:function(e,t){return t._babylonLight?t._babylonLight.intensity=e:void 0},getTarget:function(e){return e._babylonLight},getPropertyName:[function(e){return"intensity"}]},size:{type:"number",get:function(e){var t;return null===(t=e._babylonLight)||void 0===t?void 0:t.height},set:function(e,t){return t._babylonLight?t._babylonLight.height=e:void 0},getTarget:function(e){return e._babylonLight},getPropertyName:[function(e){return"size"}]},rect:{aspect:{type:"number",get:function(e){var t,n;return(null===(t=e._babylonLight)||void 0===t?void 0:t.width)/(null===(n=e._babylonLight)||void 0===n?void 0:n.height)},set:function(e,t){return t._babylonLight?t._babylonLight.width=e*t._babylonLight.height:void 0},getTarget:function(e){return e._babylonLight},getPropertyName:[function(e){return"aspect"}]}}}}},EXT_lights_ies:{lights:{length:{type:"number",get:function(e){return e.length},getTarget:function(e){return e.map(function(e){return e._babylonLight})},getPropertyName:[function(e){return"length"}]}}},EXT_lights_image_based:{lights:{length:{type:"number",get:function(e){return e.length},getTarget:function(e){return e.map(function(e){return e._babylonTexture})},getPropertyName:[function(e){return"length"}]},__array__:{__target__:!0,intensity:{type:"number",get:function(e){var t;return null===(t=e._babylonTexture)||void 0===t?void 0:t.level},set:function(e,t){t._babylonTexture&&(t._babylonTexture.level=e)},getTarget:function(e){return e._babylonTexture}},rotation:{type:"Quaternion",get:function(e){var n;return e._babylonTexture&&t.Quaternion.FromRotationMatrix(null===(n=e._babylonTexture)||void 0===n?void 0:n.getReflectionTextureMatrix())},set:function(e,n){var r;n._babylonTexture&&((null===(r=n._babylonTexture.getScene())||void 0===r?void 0:r.useRightHandedSystem)||(e=t.Quaternion.Inverse(e)),t.Matrix.FromQuaternionToRef(e,n._babylonTexture.getReflectionTextureMatrix()))},getTarget:function(e){return e._babylonTexture}}}}}};function F(e,t,n,r){var o=E(e);return r?o[n][r]:o[n]}function E(e,n,r){var o,a,i;return null===(i=null===(o=e._data)||void 0===o?void 0:o[null!==(a=null==r?void 0:r.fillMode)&&void 0!==a?a:t.Constants.MATERIAL_TriangleFillMode])||void 0===i?void 0:i.babylonMaterial}function S(e,n){return{offset:{componentsCount:2,type:"Vector2",get:function(r,o,a){var i=F(r,0,e,n);return new t.Vector2(null==i?void 0:i.uOffset,null==i?void 0:i.vOffset)},getTarget:E,set:function(t,r,o,a){var i=F(r,0,e,n);i.uOffset=t.x,i.vOffset=t.y},getPropertyName:[function(){return"".concat(e).concat(n?"."+n:"",".uOffset")},function(){return"".concat(e).concat(n?"."+n:"",".vOffset")}]},rotation:{type:"number",get:function(t,r,o){var a;return null===(a=F(t,0,e,n))||void 0===a?void 0:a.wAng},getTarget:E,set:function(t,r,o,a){return F(r,0,e,n).wAng=t},getPropertyName:[function(){return"".concat(e).concat(n?"."+n:"",".wAng")}]},scale:{componentsCount:2,type:"Vector2",get:function(r,o,a){var i=F(r,0,e,n);return new t.Vector2(null==i?void 0:i.uScale,null==i?void 0:i.vScale)},getTarget:E,set:function(t,r,o,a){var i=F(r,0,e,n);i.uScale=t.x,i.vScale=t.y},getPropertyName:[function(){return"".concat(e).concat(n?"."+n:"",".uScale")},function(){return"".concat(e).concat(n?"."+n:"",".vScale")}]}}}var k={cameras:R,nodes:M,materials:P,extensions:L,animations:{length:{type:"number",get:function(e){return e.length},getTarget:function(e){return e.map(function(e){return e._babylonAnimationGroup})},getPropertyName:[function(){return"length"}]},__array__:{}},meshes:{length:{type:"number",get:function(e){return e.length},getTarget:function(e){return e.map(function(e){var t;return null===(t=e.primitives[0]._instanceData)||void 0===t?void 0:t.babylonSourceMesh})},getPropertyName:[function(){return"length"}]},__array__:{}}};function I(e){return new O(e,k)}function B(e){for(var t=e.split("/").map(function(e){return e.replace(/{}/g,"__array__")}),n=k,r=0,o=t;r<o.length;r++){var a=o[r];a&&(n=n[a])}if(n&&n.type&&n.get)return n}function N(e,t){for(var n=e.split("/").map(function(e){return e.replace(/{}/g,"__array__")}),r=k,o=0,a=n;o<a.length;o++){var i=a[o];i&&(r=r[i])}r&&r.type&&r.get&&(r.interpolation=t)}function G(e,t){for(var n=e.split("/").map(function(e){return e.replace(/{}/g,"__array__")}),r=k,o=0,a=n;o<a.length;o++){var i=a[o];if(i){if(!r[i]){if("?"===i){r.__ignoreObjectTree__=!0;continue}r[i]={},"__array__"===i&&(r[i].__target__=!0)}r=r[i]}}Object.assign(r,t)}var D=new Map,V=D;function H(e,n,r){K(e)&&t.Logger.Warn("Extension with the name '".concat(e,"' already exists")),D.set(e,{isGLTFExtension:n,factory:r})}function K(e){return D.delete(e)}var j=new t.Lazy(function(){return Promise.resolve(BABYLON)}),W=new t.Lazy(function(){return Promise.resolve().then(function(){return ct})}),U=function(){function e(){}return e.Get=function(e,t,n){if(!t||null==n||!t[n])throw new Error("".concat(e,": Failed to find index (").concat(n,")"));return t[n]},e.TryGet=function(e,t){return e&&null!=t&&e[t]?e[t]:null},e.Assign=function(e){if(e)for(var t=0;t<e.length;t++)e[t].index=t},e}();function z(e){if(e.min&&e.max){var n=e.min,r=e.max,o=t.TmpVectors.Vector3[0].copyFromFloats(n[0],n[1],n[2]),a=t.TmpVectors.Vector3[1].copyFromFloats(r[0],r[1],r[2]);if(e.normalized&&5126!==e.componentType){var i=1;switch(e.componentType){case 5120:i=127;break;case 5121:i=255;break;case 5122:i=32767;break;case 5123:i=65535}var s=1/i;o.scaleInPlace(s),a.scaleInPlace(s)}return new t.BoundingInfo(o,a)}return null}var q=function(){function n(e){this._completePromises=new Array,this._assetContainer=null,this._babylonLights=[],this._disableInstancedMesh=0,this._allMaterialsDirtyRequired=!1,this._skipStartAnimationStep=!1,this._extensions=new Array,this._disposed=!1,this._rootUrl=null,this._fileName=null,this._uniqueRootUrl=null,this._bin=null,this._rootBabylonMesh=null,this._defaultBabylonMaterialData={},this._postSceneLoadActions=new Array,this._materialAdapterCache=new WeakMap,this._materialAdapters=new Set,this._pbrMaterialImpls=new Map,this._parent=e}return n.prototype.isMatchingMaterialType=function(e){if(!e)return!1;for(var t=0,n=Array.from(this._pbrMaterialImpls.values());t<n.length;t++)if(e instanceof n[t].materialClass)return!0;return!1},n.RegisterExtension=function(e,t){H(e,!1,t)},n.UnregisterExtension=function(e){return K(e)},Object.defineProperty(n.prototype,"gltf",{get:function(){if(!this._gltf)throw new Error("glTF JSON is not available");return this._gltf},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"bin",{get:function(){return this._bin},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"parent",{get:function(){return this._parent},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"babylonScene",{get:function(){if(!this._babylonScene)throw new Error("Scene is not available");return this._babylonScene},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"rootBabylonMesh",{get:function(){return this._rootBabylonMesh},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"rootUrl",{get:function(){return this._rootUrl},enumerable:!1,configurable:!0}),n.prototype._getOrCreateMaterialAdapter=function(e){var t=this._materialAdapterCache.get(e);if(!t){for(var n=0,r=Array.from(this._pbrMaterialImpls.values());n<r.length;n++){var o=r[n];if(e instanceof o.materialClass){t=new o.adapterClass(e);break}}if(!t)throw new Error("Appropriate material adapter class not found");var a=t;this._materialAdapterCache.set(e,a),this._materialAdapters.add(a)}return t},n.prototype.dispose=function(){this._disposed||(this._disposed=!0,this._completePromises.length=0,this._extensions.forEach(function(e){return e.dispose&&e.dispose()}),this._extensions.length=0,this._materialAdapters.clear(),this._gltf=null,this._bin=null,this._babylonScene=null,this._rootBabylonMesh=null,this._defaultBabylonMaterialData={},this._postSceneLoadActions.length=0,this._parent.dispose())},n.prototype.importMeshAsync=function(e,t,n,r,o,s){return a(this,arguments,void 0,function(e,t,n,r,o,s,l){var u=this;return void 0===l&&(l=""),i(this,function(s){switch(s.label){case 0:return[4,Promise.resolve().then(function(){return a(u,void 0,void 0,function(){var a,s,u,c,f,h=this;return i(this,function(i){switch(i.label){case 0:if(this._babylonScene=t,this._assetContainer=n,this._loadData(r),a=null,e){if(s={},this._gltf.nodes)for(u=0,c=this._gltf.nodes;u<c.length;u++)(f=c[u]).name&&(s[f.name]=f.index);a=(e instanceof Array?e:[e]).map(function(e){var t=s[e];if(void 0===t)throw new Error("Failed to find node '".concat(e,"'"));return t})}return[4,this._loadAsync(o,l,a,function(){return{meshes:h._getMeshes(),particleSystems:[],skeletons:h._getSkeletons(),animationGroups:h._getAnimationGroups(),lights:h._babylonLights,transformNodes:h._getTransformNodes(),geometries:h._getGeometries(),spriteManagers:[]}})];case 1:return[2,i.sent()]}})})})];case 1:return[2,s.sent()]}})})},n.prototype.loadAsync=function(e,t,n,r){return a(this,arguments,void 0,function(e,t,n,r,o){return void 0===o&&(o=""),i(this,function(r){switch(r.label){case 0:return this._babylonScene=e,this._loadData(t),[4,this._loadAsync(n,o,null,function(){})];case 1:return[2,r.sent()]}})})},n.prototype._loadAsync=function(n,r,o,s){return a(this,void 0,void 0,function(){var l=this;return i(this,function(u){switch(u.label){case 0:return[4,Promise.resolve().then(function(){return a(l,void 0,void 0,function(){var a,l,u,c,f,h,p,d,m,_,b,g,y,v,T=this;return i(this,function(i){switch(i.label){case 0:return this._rootUrl=n,this._uniqueRootUrl=!n.startsWith("file:")&&r?n:"".concat(n).concat(Date.now(),"/"),this._fileName=r,this._allMaterialsDirtyRequired=!1,[4,this._loadExtensionsAsync()];case 1:return i.sent(),this.parent.skipMaterials?[3,3]:(a=this.parent.useOpenPBR||this.isExtensionUsed("KHR_materials_openpbr"),l=!1,this.parent.useOpenPBR?(null===(v=this._gltf.materials)||void 0===v?void 0:v.length)&&this._gltf.materials.some(function(e){var t;return!(null===(t=e.extensions)||void 0===t?void 0:t.KHR_materials_openpbr)})&&(l=!0):l=!0,u=[],a&&!this._pbrMaterialImpls.has("openpbr")&&u.push(Promise.all([Promise.resolve(BABYLON),Promise.resolve().then(function(){return On})]).then(function(e){var t=e[0].OpenPBRMaterial,n=e[1].OpenPBRMaterialLoadingAdapter;T._pbrMaterialImpls.set("openpbr",{materialClass:t,adapterClass:n})})),l&&!this._pbrMaterialImpls.has("pbr")&&u.push(Promise.all([Promise.resolve(BABYLON),Promise.resolve().then(function(){return Rn})]).then(function(e){var t=e[0].PBRMaterial,n=e[1].PBRMaterialLoadingAdapter;T._pbrMaterialImpls.set("pbr",{materialClass:t,adapterClass:n})})),[4,Promise.all(u)]);case 2:i.sent(),i.label=3;case 3:if(c="".concat(e.GLTFLoaderState[e.GLTFLoaderState.LOADING]," => ").concat(e.GLTFLoaderState[e.GLTFLoaderState.READY]),f="".concat(e.GLTFLoaderState[e.GLTFLoaderState.LOADING]," => ").concat(e.GLTFLoaderState[e.GLTFLoaderState.COMPLETE]),this._parent._startPerformanceCounter(c),this._parent._startPerformanceCounter(f),this._parent._setState(e.GLTFLoaderState.LOADING),this._extensionsOnLoading(),h=new Array,p=this._babylonScene.blockMaterialDirtyMechanism,this._babylonScene.blockMaterialDirtyMechanism=!0,this.parent.loadOnlyMaterials||(o?h.push(this.loadSceneAsync("/nodes",{nodes:o,index:-1})):(null!=this._gltf.scene||this._gltf.scenes&&this._gltf.scenes[0])&&(d=U.Get("/scene",this._gltf.scenes,this._gltf.scene||0),h.push(this.loadSceneAsync("/scenes/".concat(d.index),d)))),!this.parent.skipMaterials&&this.parent.loadAllMaterials&&this._gltf.materials)for(m=0;m<this._gltf.materials.length;++m)_=this._gltf.materials[m],b="/materials/"+m,g=t.Material.TriangleFillMode,h.push(this._loadMaterialAsync(b,_,null,g,function(){}));return this._allMaterialsDirtyRequired?this._babylonScene.blockMaterialDirtyMechanism=p:this._babylonScene._forceBlockMaterialDirtyMechanism(p),this._parent.compileMaterials&&h.push(this._compileMaterialsAsync()),this._parent.compileShadowGenerators&&h.push(this._compileShadowGeneratorsAsync()),y=Promise.all(h).then(function(){T._rootBabylonMesh&&T._rootBabylonMesh!==T._parent.customRootNode&&T._rootBabylonMesh.setEnabled(!0);for(var t=0,n=T._babylonScene.materials;t<n.length;t++){var r=n[t];void 0!==r.maxSimultaneousLights&&(r.maxSimultaneousLights=Math.max(r.maxSimultaneousLights,T._babylonScene.lights.length))}for(var o=0,a=Array.from(T._materialAdapters);o<a.length;o++){var i=a[o];T._completePromises.push(i.finalizeAsync(T))}return T._extensionsOnReady(),T._parent._setState(e.GLTFLoaderState.READY),T._skipStartAnimationStep||T._startAnimations(),s()}),[4,y.then(function(n){return T._parent._endPerformanceCounter(c),t.Tools.SetImmediate(function(){T._disposed||Promise.all(T._completePromises).then(function(){T._parent._endPerformanceCounter(f),T._parent._setState(e.GLTFLoaderState.COMPLETE),T._parent.onCompleteObservable.notifyObservers(void 0),T._parent.onCompleteObservable.clear(),T.dispose()},function(e){T._parent.onErrorObservable.notifyObservers(e),T._parent.onErrorObservable.clear(),T.dispose()})}),n})];case 4:return[2,i.sent()]}})})}).catch(function(e){throw l._disposed||(l._parent.onErrorObservable.notifyObservers(e),l._parent.onErrorObservable.clear(),l.dispose()),e})];case 1:return[2,u.sent()]}})})},n.prototype._loadData=function(e){if(this._gltf=e.json,this._setupData(),e.bin){var n=this._gltf.buffers;if(n&&n[0]&&!n[0].uri){var r=n[0];(r.byteLength<e.bin.byteLength-3||r.byteLength>e.bin.byteLength)&&t.Logger.Warn("Binary buffer length (".concat(r.byteLength,") from JSON does not match chunk length (").concat(e.bin.byteLength,")")),this._bin=e.bin}else t.Logger.Warn("Unexpected BIN chunk")}},n.prototype._setupData=function(){if(U.Assign(this._gltf.accessors),U.Assign(this._gltf.animations),U.Assign(this._gltf.buffers),U.Assign(this._gltf.bufferViews),U.Assign(this._gltf.cameras),U.Assign(this._gltf.images),U.Assign(this._gltf.materials),U.Assign(this._gltf.meshes),U.Assign(this._gltf.nodes),U.Assign(this._gltf.samplers),U.Assign(this._gltf.scenes),U.Assign(this._gltf.skins),U.Assign(this._gltf.textures),this._gltf.nodes){for(var e={},t=0,n=this._gltf.nodes;t<n.length;t++)if((l=n[t]).children)for(var r=0,o=l.children;r<o.length;r++)e[o[r]]=l.index;for(var a=this._createRootNode(),i=0,s=this._gltf.nodes;i<s.length;i++){var l,u=e[(l=s[i]).index];l.parent=void 0===u?a:this._gltf.nodes[u]}}},n.prototype._loadExtensionsAsync=function(){return a(this,void 0,void 0,function(){var e,n,r,o,s,l,u,c,f,h,p,d=this;return i(this,function(m){switch(m.label){case 0:return e=[],V.forEach(function(n,r){var o;!1===(null===(o=d.parent.extensionOptions[r])||void 0===o?void 0:o.enabled)?n.isGLTFExtension&&d.isExtensionUsed(r)&&t.Logger.Warn("Extension ".concat(r," is used but has been explicitly disabled.")):n.isGLTFExtension&&!d.isExtensionUsed(r)||e.push(a(d,void 0,void 0,function(){var e;return i(this,function(o){switch(o.label){case 0:return[4,n.factory(this)];case 1:return(e=o.sent()).name!==r&&t.Logger.Warn("The name of the glTF loader extension instance does not match the registered name: ".concat(e.name," !== ").concat(r)),this._parent.onExtensionLoadedObservable.notifyObservers(e),[2,e]}})}))}),r=(n=(h=this._extensions).push).apply,o=[h],[4,Promise.all(e)];case 1:if(r.apply(n,o.concat([m.sent()])),this._extensions.sort(function(e,t){return(e.order||Number.MAX_VALUE)-(t.order||Number.MAX_VALUE)}),this._parent.onExtensionLoadedObservable.clear(),this._gltf.extensionsRequired)for(s=function(e){if(!l._extensions.some(function(t){return t.name===e&&t.enabled})){if(!1===(null===(p=l.parent.extensionOptions[e])||void 0===p?void 0:p.enabled))throw new Error("Required extension ".concat(e," is disabled"));throw new Error("Required extension ".concat(e," is not available"))}},l=this,u=0,c=this._gltf.extensionsRequired;u<c.length;u++)f=c[u],s(f);return[2]}})})},n.prototype._createRootNode=function(){if(void 0!==this._parent.customRootNode)return this._rootBabylonMesh=this._parent.customRootNode,{_babylonTransformNode:null===this._rootBabylonMesh?void 0:this._rootBabylonMesh,index:-1};this._babylonScene._blockEntityCollection=!!this._assetContainer;var r=new t.Mesh("__root__",this._babylonScene);this._rootBabylonMesh=r,this._rootBabylonMesh._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,this._rootBabylonMesh.setEnabled(!1);var o={_babylonTransformNode:this._rootBabylonMesh,index:-1};switch(this._parent.coordinateSystemMode){case e.GLTFLoaderCoordinateSystemMode.AUTO:this._babylonScene.useRightHandedSystem||(o.rotation=[0,1,0,0],o.scale=[1,1,-1],n._LoadTransform(o,this._rootBabylonMesh));break;case e.GLTFLoaderCoordinateSystemMode.FORCE_RIGHT_HANDED:this._babylonScene.useRightHandedSystem=!0;break;default:throw new Error("Invalid coordinate system mode (".concat(this._parent.coordinateSystemMode,")"))}return this._parent.onMeshLoadedObservable.notifyObservers(r),o},n.prototype.loadSceneAsync=function(e,t){var n=this,r=this._extensionsLoadSceneAsync(e,t);if(r)return r;var o=new Array;if(this.logOpen("".concat(e," ").concat(t.name||"")),t.nodes)for(var a=0,i=t.nodes;a<i.length;a++){var s=i[a],l=U.Get("".concat(e,"/nodes/").concat(s),this._gltf.nodes,s);o.push(this.loadNodeAsync("/nodes/".concat(l.index),l,function(e){e.parent=n._rootBabylonMesh}))}for(var u=0,c=this._postSceneLoadActions;u<c.length;u++)(0,c[u])();return o.push(this._loadAnimationsAsync()),this.logClose(),Promise.all(o).then(function(){})},n.prototype._forEachPrimitive=function(e,t){if(e._primitiveBabylonMeshes)for(var n=0,r=e._primitiveBabylonMeshes;n<r.length;n++)t(r[n])},n.prototype._getGeometries=function(){var e=[],t=this._gltf.nodes;if(t)for(var n=0,r=t;n<r.length;n++){var o=r[n];this._forEachPrimitive(o,function(t){var n=t.geometry;n&&-1===e.indexOf(n)&&e.push(n)})}return e},n.prototype._getMeshes=function(){var e=[];this._rootBabylonMesh instanceof t.AbstractMesh&&e.push(this._rootBabylonMesh);var n=this._gltf.nodes;if(n)for(var r=0,o=n;r<o.length;r++){var a=o[r];this._forEachPrimitive(a,function(t){e.push(t)})}return e},n.prototype._getTransformNodes=function(){var e=[],t=this._gltf.nodes;if(t)for(var n=0,r=t;n<r.length;n++){var o=r[n];o._babylonTransformNode&&"TransformNode"===o._babylonTransformNode.getClassName()&&e.push(o._babylonTransformNode),o._babylonTransformNodeForSkin&&e.push(o._babylonTransformNodeForSkin)}return e},n.prototype._getSkeletons=function(){var e=[],t=this._gltf.skins;if(t)for(var n=0,r=t;n<r.length;n++){var o=r[n];o._data&&e.push(o._data.babylonSkeleton)}return e},n.prototype._getAnimationGroups=function(){var e=[],t=this._gltf.animations;if(t)for(var n=0,r=t;n<r.length;n++){var o=r[n];o._babylonAnimationGroup&&e.push(o._babylonAnimationGroup)}return e},n.prototype._startAnimations=function(){switch(this._parent.animationStartMode){case e.GLTFLoaderAnimationStartMode.NONE:break;case e.GLTFLoaderAnimationStartMode.FIRST:0!==(n=this._getAnimationGroups()).length&&n[0].start(!0);break;case e.GLTFLoaderAnimationStartMode.ALL:for(var n,r=0,o=n=this._getAnimationGroups();r<o.length;r++)o[r].start(!0);break;default:return void t.Logger.Error("Invalid animation start mode (".concat(this._parent.animationStartMode,")"))}},n.prototype.loadNodeAsync=function(e,r,o){var a=this;void 0===o&&(o=function(){});var i=this._extensionsLoadNodeAsync(e,r,o);if(i)return i;if(r._babylonTransformNode)throw new Error("".concat(e,": Invalid recursive node hierarchy"));var s=new Array;this.logOpen("".concat(e," ").concat(r.name||""));var l=function(t){if(n.AddPointerMetadata(t,e),n._LoadTransform(r,t),null!=r.camera){var i=U.Get("".concat(e,"/camera"),a._gltf.cameras,r.camera);s.push(a.loadCameraAsync("/cameras/".concat(i.index),i,function(e){e.parent=t,a._babylonScene.useRightHandedSystem||(t.scaling.x=-1)}))}if(r.children)for(var l=0,u=r.children;l<u.length;l++){var c=u[l],f=U.Get("".concat(e,"/children/").concat(c),a._gltf.nodes,c);s.push(a.loadNodeAsync("/nodes/".concat(f.index),f,function(e){e.parent=t}))}o(t)},u=null!=r.mesh,c=this._parent.loadSkins&&null!=r.skin;if(!u||c){var f=r.name||"node".concat(r.index);this._babylonScene._blockEntityCollection=!!this._assetContainer;var h=new t.TransformNode(f,this._babylonScene);h._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,null==r.mesh?r._babylonTransformNode=h:r._babylonTransformNodeForSkin=h,l(h)}if(u)if(c){var p=U.Get("".concat(e,"/mesh"),this._gltf.meshes,r.mesh);s.push(this._loadMeshAsync("/meshes/".concat(p.index),r,p,function(n){var o=r._babylonTransformNodeForSkin;n.metadata=t.deepMerge(o.metadata,n.metadata||{});var i=U.Get("".concat(e,"/skin"),a._gltf.skins,r.skin);s.push(a._loadSkinAsync("/skins/".concat(i.index),r,i,function(e){a._forEachPrimitive(r,function(t){t.skeleton=e}),a._postSceneLoadActions.push(function(){if(null!=i.skeleton){var e=U.Get("/skins/".concat(i.index,"/skeleton"),a._gltf.nodes,i.skeleton).parent;r.index===e.index?n.parent=o.parent:n.parent=e._babylonTransformNode}else n.parent=a._rootBabylonMesh;a._parent.onSkinLoadedObservable.notifyObservers({node:o,skinnedNode:n})})}))}))}else p=U.Get("".concat(e,"/mesh"),this._gltf.meshes,r.mesh),s.push(this._loadMeshAsync("/meshes/".concat(p.index),r,p,l));return this.logClose(),Promise.all(s).then(function(){return a._forEachPrimitive(r,function(e){var t=e;!t.isAnInstance&&t.geometry&&t.geometry.useBoundingInfoFromGeometry?e._updateBoundingInfo():e.refreshBoundingInfo(!0,!0)}),r._babylonTransformNode})},n.prototype._loadMeshAsync=function(e,n,r,o){var a=r.primitives;if(!a||!a.length)throw new Error("".concat(e,": Primitives are missing"));null==a[0].index&&U.Assign(a);var i=new Array;this.logOpen("".concat(e," ").concat(r.name||""));var s=n.name||"node".concat(n.index);if(1===a.length){var l=r.primitives[0];i.push(this._loadMeshPrimitiveAsync("".concat(e,"/primitives/").concat(l.index),s,n,r,l,function(e){n._babylonTransformNode=e,n._primitiveBabylonMeshes=[e]}))}else{this._babylonScene._blockEntityCollection=!!this._assetContainer,n._babylonTransformNode=new t.TransformNode(s,this._babylonScene),n._babylonTransformNode._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,n._primitiveBabylonMeshes=[];for(var u=0,c=a;u<c.length;u++)l=c[u],i.push(this._loadMeshPrimitiveAsync("".concat(e,"/primitives/").concat(l.index),"".concat(s,"_primitive").concat(l.index),n,r,l,function(e){e.parent=n._babylonTransformNode,n._primitiveBabylonMeshes.push(e)}))}return o(n._babylonTransformNode),this.logClose(),Promise.all(i).then(function(){return n._babylonTransformNode})},n.prototype._loadMeshPrimitiveAsync=function(e,r,o,s,l,u){var c=this,f=this._extensionsLoadMeshPrimitiveAsync(e,r,o,s,l,u);if(f)return f;this.logOpen("".concat(e));var h,p,d=0===this._disableInstancedMesh&&this._parent.createInstances&&null==o.skin&&!s.primitives[0].targets;if(d&&l._instanceData)this._babylonScene._blockEntityCollection=!!this._assetContainer,(h=l._instanceData.babylonSourceMesh.createInstance(r))._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,p=l._instanceData.promise;else{var m=new Array;this._babylonScene._blockEntityCollection=!!this._assetContainer;var _=new t.Mesh(r,this._babylonScene);if(_._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,_.sideOrientation=this._babylonScene.useRightHandedSystem?t.Material.CounterClockWiseSideOrientation:t.Material.ClockWiseSideOrientation,this._createMorphTargets(e,o,s,l,_),m.push(this._loadVertexDataAsync(e,l,_).then(function(t){return a(c,void 0,void 0,function(){var n=this;return i(this,function(r){switch(r.label){case 0:return[4,this._loadMorphTargetsAsync(e,l,_,t).then(function(){n._disposed||(n._babylonScene._blockEntityCollection=!!n._assetContainer,t.applyToMesh(_),t._parentContainer=n._assetContainer,n._babylonScene._blockEntityCollection=!1)})];case 1:return[2,r.sent()]}})})})),!this.parent.skipMaterials){var b=n._GetDrawMode(e,l.mode);if(null==l.material){var g=this._defaultBabylonMaterialData[b];g||(g=this._createDefaultMaterial("__GLTFLoader._default",b,this._getDefaultImpl()),this._parent.onMaterialLoadedObservable.notifyObservers(g),this._defaultBabylonMaterialData[b]=g),_.material=g}else{var y=U.Get("".concat(e,"/material"),this._gltf.materials,l.material);m.push(this._loadMaterialAsync("/materials/".concat(y.index),y,_,b,function(e){_.material=e}))}}p=Promise.all(m),d&&(l._instanceData={babylonSourceMesh:_,promise:p}),h=_}return n.AddPointerMetadata(h,e),this._parent.onMeshLoadedObservable.notifyObservers(h),u(h),this.logClose(),p.then(function(){return h})},n.prototype._loadVertexDataAsync=function(e,n,r){var o=this,a=this._extensionsLoadVertexDataAsync(e,n,r);if(a)return a;var i=n.attributes;if(!i)throw new Error("".concat(e,": Attributes are missing"));var s=new Array,l=new t.Geometry(r.name,this._babylonScene);if(null==n.indices)r.isUnIndexed=!0;else{var u=U.Get("".concat(e,"/indices"),this._gltf.accessors,n.indices);s.push(this._loadIndicesAccessorAsync("/accessors/".concat(u.index),u).then(function(e){l.setIndices(e)}))}var c=function(n,a,u){if(null!=i[n]){r._delayInfo=r._delayInfo||[],-1===r._delayInfo.indexOf(a)&&r._delayInfo.push(a);var c=U.Get("".concat(e,"/attributes/").concat(n),o._gltf.accessors,i[n]);s.push(o._loadVertexAccessorAsync("/accessors/".concat(c.index),c,a).then(function(e){if(e.getKind()===t.VertexBuffer.PositionKind&&!o.parent.alwaysComputeBoundingBox&&!r.skeleton){var n=z(c);n&&(l._boundingInfo=n,l.useBoundingInfoFromGeometry=!0)}l.setVerticesBuffer(e,c.count)})),a==t.VertexBuffer.MatricesIndicesExtraKind&&(r.numBoneInfluencers=8),u&&u(c)}};return c("POSITION",t.VertexBuffer.PositionKind),c("NORMAL",t.VertexBuffer.NormalKind),c("TANGENT",t.VertexBuffer.TangentKind),c("TEXCOORD_0",t.VertexBuffer.UVKind),c("TEXCOORD_1",t.VertexBuffer.UV2Kind),c("TEXCOORD_2",t.VertexBuffer.UV3Kind),c("TEXCOORD_3",t.VertexBuffer.UV4Kind),c("TEXCOORD_4",t.VertexBuffer.UV5Kind),c("TEXCOORD_5",t.VertexBuffer.UV6Kind),c("JOINTS_0",t.VertexBuffer.MatricesIndicesKind),c("WEIGHTS_0",t.VertexBuffer.MatricesWeightsKind),c("JOINTS_1",t.VertexBuffer.MatricesIndicesExtraKind),c("WEIGHTS_1",t.VertexBuffer.MatricesWeightsExtraKind),c("COLOR_0",t.VertexBuffer.ColorKind,function(e){"VEC4"===e.type&&(r.hasVertexAlpha=!0)}),Promise.all(s).then(function(){return l})},n.prototype._createMorphTargets=function(e,n,r,o,a){if(o.targets&&this._parent.loadMorphTargets){if(null==n._numMorphTargets)n._numMorphTargets=o.targets.length;else if(o.targets.length!==n._numMorphTargets)throw new Error("".concat(e,": Primitives do not have the same number of targets"));var i=r.extras?r.extras.targetNames:null;this._babylonScene._blockEntityCollection=!!this._assetContainer,a.morphTargetManager=new t.MorphTargetManager(this._babylonScene),a.morphTargetManager._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,a.morphTargetManager.areUpdatesFrozen=!0;for(var s=0;s<o.targets.length;s++){var l=n.weights?n.weights[s]:r.weights?r.weights[s]:0,u=i?i[s]:"morphTarget".concat(s);a.morphTargetManager.addTarget(new t.MorphTarget(u,l,a.getScene()))}}},n.prototype._loadMorphTargetsAsync=function(e,t,n,r){if(!t.targets||!this._parent.loadMorphTargets)return Promise.resolve();for(var o=new Array,a=n.morphTargetManager,i=0;i<a.numTargets;i++){var s=a.getTarget(i);o.push(this._loadMorphTargetVertexDataAsync("".concat(e,"/targets/").concat(i),r,t.targets[i],s))}return Promise.all(o).then(function(){a.areUpdatesFrozen=!1})},n.prototype._loadMorphTargetVertexDataAsync=function(e,n,r,o){return a(this,void 0,void 0,function(){var a,s,l=this;return i(this,function(i){switch(i.label){case 0:return a=new Array,(s=function(t,o,i){if(null!=r[t]){var s=n.getVertexBuffer(o);if(s){var u=U.Get("".concat(e,"/").concat(t),l._gltf.accessors,r[t]);a.push(l._loadFloatAccessorAsync("/accessors/".concat(u.index),u).then(function(e){i(s,e)}))}}})("POSITION",t.VertexBuffer.PositionKind,function(e,t){var n=new Float32Array(t.length);e.forEach(t.length,function(e,r){n[r]=t[r]+e}),o.setPositions(n)}),s("NORMAL",t.VertexBuffer.NormalKind,function(e,t){var n=new Float32Array(t.length);e.forEach(n.length,function(e,r){n[r]=t[r]+e}),o.setNormals(n)}),s("TANGENT",t.VertexBuffer.TangentKind,function(e,t){var n=new Float32Array(t.length/3*4),r=0;e.forEach(t.length/3*4,function(e,o){(o+1)%4!=0&&(n[r]=t[r]+e,r++)}),o.setTangents(n)}),s("TEXCOORD_0",t.VertexBuffer.UVKind,function(e,t){var n=new Float32Array(t.length);e.forEach(t.length,function(e,r){n[r]=t[r]+e}),o.setUVs(n)}),s("TEXCOORD_1",t.VertexBuffer.UV2Kind,function(e,t){var n=new Float32Array(t.length);e.forEach(t.length,function(e,r){n[r]=t[r]+e}),o.setUV2s(n)}),s("COLOR_0",t.VertexBuffer.ColorKind,function(t,n){var r=null,a=t.getSize();if(3===a){r=new Float32Array(n.length/3*4),t.forEach(n.length,function(e,t){var o=Math.floor(t/3),a=t%3;r[4*o+a]=n[3*o+a]+e});for(var i=0;i<n.length/3;++i)r[4*i+3]=1}else{if(4!==a)throw new Error("".concat(e,": Invalid number of components (").concat(a,") for COLOR_0 attribute"));r=new Float32Array(n.length),t.forEach(n.length,function(e,t){r[t]=n[t]+e})}o.setColors(r)}),[4,Promise.all(a).then(function(){})];case 1:return[2,i.sent()]}})})},n._LoadTransform=function(e,n){if(null==e.skin){var r=t.Vector3.Zero(),o=t.Quaternion.Identity(),a=t.Vector3.One();e.matrix?t.Matrix.FromArray(e.matrix).decompose(a,o,r):(e.translation&&(r=t.Vector3.FromArray(e.translation)),e.rotation&&(o=t.Quaternion.FromArray(e.rotation)),e.scale&&(a=t.Vector3.FromArray(e.scale))),n.position=r,n.rotationQuaternion=o,n.scaling=a}},n.prototype._loadSkinAsync=function(e,n,r,o){var a=this;if(!this._parent.loadSkins)return Promise.resolve();var i=this._extensionsLoadSkinAsync(e,n,r);if(i)return i;if(r._data)return o(r._data.babylonSkeleton),r._data.promise;var s="skeleton".concat(r.index);this._babylonScene._blockEntityCollection=!!this._assetContainer;var l=new t.Skeleton(r.name||s,s,this._babylonScene);l._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,this._loadBones(e,r,l);var u=this._loadSkinInverseBindMatricesDataAsync(e,r).then(function(e){a._updateBoneMatrices(l,e)});return r._data={babylonSkeleton:l,promise:u},o(l),u},n.prototype._loadBones=function(e,n,r){if(null==n.skeleton||this._parent.alwaysComputeSkeletonRootNode){var o=this._findSkeletonRootNode("".concat(e,"/joints"),n.joints);if(o)if(void 0===n.skeleton)n.skeleton=o.index;else{var a=U.Get("".concat(e,"/skeleton"),this._gltf.nodes,n.skeleton);a===o||function(e,t){for(;t.parent;t=t.parent)if(t.parent===e)return!0;return!1}(a,o)||(t.Logger.Warn("".concat(e,"/skeleton: Overriding with nearest common ancestor as skeleton node is not a common root")),n.skeleton=o.index)}else t.Logger.Warn("".concat(e,": Failed to find common root"))}for(var i={},s=0,l=n.joints;s<l.length;s++){var u=l[s],c=U.Get("".concat(e,"/joints/").concat(u),this._gltf.nodes,u);this._loadBone(c,n,r,i)}},n.prototype._findSkeletonRootNode=function(e,t){if(0===t.length)return null;for(var n={},r=0,o=t;r<o.length;r++){for(var a=o[r],i=[],s=U.Get("".concat(e,"/").concat(a),this._gltf.nodes,a);-1!==s.index;)i.unshift(s),s=s.parent;n[a]=i}for(var l=null,u=0;;++u){if(u>=(i=n[t[0]]).length)return l;s=i[u];for(var c=1;c<t.length;++c)if(u>=(i=n[t[c]]).length||s!==i[u])return l;l=s}},n.prototype._loadBone=function(e,n,r,o){e._isJoint=!0;var a=o[e.index];if(a)return a;var i=null;e.index!==n.skeleton&&(e.parent&&-1!==e.parent.index?i=this._loadBone(e.parent,n,r,o):void 0!==n.skeleton&&t.Logger.Warn("/skins/".concat(n.index,"/skeleton: Skeleton node is not a common root")));var s=n.joints.indexOf(e.index);return a=new t.Bone(e.name||"joint".concat(e.index),r,i,this._getNodeMatrix(e),null,null,s),o[e.index]=a,this._postSceneLoadActions.push(function(){a.linkTransformNode(e._babylonTransformNode)}),a},n.prototype._loadSkinInverseBindMatricesDataAsync=function(e,t){if(null==t.inverseBindMatrices)return Promise.resolve(null);var n=U.Get("".concat(e,"/inverseBindMatrices"),this._gltf.accessors,t.inverseBindMatrices);return this._loadFloatAccessorAsync("/accessors/".concat(n.index),n)},n.prototype._updateBoneMatrices=function(e,n){for(var r=0,o=e.bones;r<o.length;r++){var a=o[r],i=t.Matrix.Identity(),s=a._index;n&&-1!==s&&(t.Matrix.FromArrayToRef(n,16*s,i),i.invertToRef(i));var l=a.getParent();l&&i.multiplyToRef(l.getAbsoluteInverseBindMatrix(),i),a.updateMatrix(i,!1,!1),a._updateAbsoluteBindMatrices(void 0,!1)}},n.prototype._getNodeMatrix=function(e){return e.matrix?t.Matrix.FromArray(e.matrix):t.Matrix.Compose(e.scale?t.Vector3.FromArray(e.scale):t.Vector3.One(),e.rotation?t.Quaternion.FromArray(e.rotation):t.Quaternion.Identity(),e.translation?t.Vector3.FromArray(e.translation):t.Vector3.Zero())},n.prototype.loadCameraAsync=function(e,r,o){void 0===o&&(o=function(){});var a=this._extensionsLoadCameraAsync(e,r,o);if(a)return a;var i=new Array;this.logOpen("".concat(e," ").concat(r.name||"")),this._babylonScene._blockEntityCollection=!!this._assetContainer;var s=new t.FreeCamera(r.name||"camera".concat(r.index),t.Vector3.Zero(),this._babylonScene,!1);switch(s._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,r._babylonCamera=s,s.setTarget(new t.Vector3(0,0,-1)),r.type){case"perspective":var l=r.perspective;if(!l)throw new Error("".concat(e,": Camera perspective properties are missing"));s.fov=l.yfov,s.minZ=l.znear,s.maxZ=l.zfar||0;break;case"orthographic":if(!r.orthographic)throw new Error("".concat(e,": Camera orthographic properties are missing"));s.mode=t.Camera.ORTHOGRAPHIC_CAMERA,s.orthoLeft=-r.orthographic.xmag,s.orthoRight=r.orthographic.xmag,s.orthoBottom=-r.orthographic.ymag,s.orthoTop=r.orthographic.ymag,s.minZ=r.orthographic.znear,s.maxZ=r.orthographic.zfar;break;default:throw new Error("".concat(e,": Invalid camera type (").concat(r.type,")"))}return n.AddPointerMetadata(s,e),this._parent.onCameraLoadedObservable.notifyObservers(s),o(s),this.logClose(),Promise.all(i).then(function(){return s})},n.prototype._loadAnimationsAsync=function(){var e=this;this._parent._startPerformanceCounter("Load animations");var t=this._gltf.animations;if(!t)return Promise.resolve();for(var n=new Array,r=0;r<t.length;r++){var o=t[r];n.push(this.loadAnimationAsync("/animations/".concat(o.index),o).then(function(e){0===e.targetedAnimations.length&&e.dispose()}))}return Promise.all(n).then(function(){e._parent._endPerformanceCounter("Load animations")})},n.prototype.loadAnimationAsync=function(e,t){var n=this;return this._parent._startPerformanceCounter("Load animation"),this._extensionsLoadAnimationAsync(e,t)||j.value.then(function(r){var o=r.AnimationGroup;n._babylonScene._blockEntityCollection=!!n._assetContainer;var a=new o(t.name||"animation".concat(t.index),n._babylonScene);a._parentContainer=n._assetContainer,n._babylonScene._blockEntityCollection=!1,t._babylonAnimationGroup=a;var i=new Array;U.Assign(t.channels),U.Assign(t.samplers);for(var s=0,l=t.channels;s<l.length;s++){var u=l[s];i.push(n._loadAnimationChannelAsync("".concat(e,"/channels/").concat(u.index),e,t,u,function(e,t){e.animations=e.animations||[],e.animations.push(t),a.addTargetedAnimation(t,e)}))}return n._parent._endPerformanceCounter("Load animation"),Promise.all(i).then(function(){return a.normalize(0),a})})},n.prototype._loadAnimationChannelAsync=function(e,t,n,r,o){var a=this,i=this._extensionsLoadAnimationChannelAsync(e,t,n,r,o);if(i)return i;if(null==r.target.node)return Promise.resolve();var s=U.Get("".concat(e,"/target/node"),this._gltf.nodes,r.target.node),l=r.target.path,u="weights"===l;return u&&!s._numMorphTargets||!u&&!s._babylonTransformNode?Promise.resolve():this._parent.loadNodeAnimations||u||s._isJoint?W.value.then(function(){var i,u,c,f,h;switch(l){case"translation":h=null===(i=B("/nodes/{}/translation"))||void 0===i?void 0:i.interpolation;break;case"rotation":h=null===(u=B("/nodes/{}/rotation"))||void 0===u?void 0:u.interpolation;break;case"scale":h=null===(c=B("/nodes/{}/scale"))||void 0===c?void 0:c.interpolation;break;case"weights":h=null===(f=B("/nodes/{}/weights"))||void 0===f?void 0:f.interpolation;break;default:throw new Error("".concat(e,"/target/path: Invalid value (").concat(r.target.path,")"))}if(!h)throw new Error("".concat(e,"/target/path: Could not find interpolation properties for target path (").concat(r.target.path,")"));var p={object:s,info:h};return a._loadAnimationChannelFromTargetInfoAsync(e,t,n,r,p,o)}):Promise.resolve()},n.prototype._loadAnimationChannelFromTargetInfoAsync=function(e,t,n,r,o,a){var i=this.parent.targetFps,s=1/i,l=U.Get("".concat(e,"/sampler"),n.samplers,r.sampler);return this._loadAnimationSamplerAsync("".concat(t,"/samplers/").concat(r.sampler),l).then(function(e){for(var t=0,l=o.object,u=0,c=o.info;u<c.length;u++){var f=c[u],h=f.getStride(l),p=e.input,d=e.output,m=new Array(p.length),_=0;switch(e.interpolation){case"STEP":for(var b=0;b<p.length;b++){var g=f.getValue(l,d,_,1);_+=h,m[b]={frame:p[b]*i,value:g,interpolation:1}}break;case"CUBICSPLINE":for(b=0;b<p.length;b++){var y=f.getValue(l,d,_,s);_+=h,g=f.getValue(l,d,_,1),_+=h;var v=f.getValue(l,d,_,s);_+=h,m[b]={frame:p[b]*i,inTangent:y,value:g,outTangent:v}}break;case"LINEAR":for(b=0;b<p.length;b++)g=f.getValue(l,d,_,1),_+=h,m[b]={frame:p[b]*i,value:g}}if(_>0)for(var T="".concat(n.name||"animation".concat(n.index),"_channel").concat(r.index,"_").concat(t),x=0,A=f.buildAnimations(l,T,i,m);x<A.length;x++){var C=A[x];t++,a(C.babylonAnimatable,C.babylonAnimation)}}})},n.prototype._loadAnimationSamplerAsync=function(e,t){if(t._data)return t._data;var n=t.interpolation||"LINEAR";switch(n){case"STEP":case"LINEAR":case"CUBICSPLINE":break;default:throw new Error("".concat(e,"/interpolation: Invalid value (").concat(t.interpolation,")"))}var r=U.Get("".concat(e,"/input"),this._gltf.accessors,t.input),o=U.Get("".concat(e,"/output"),this._gltf.accessors,t.output);return t._data=Promise.all([this._loadFloatAccessorAsync("/accessors/".concat(r.index),r),this._loadFloatAccessorAsync("/accessors/".concat(o.index),o)]).then(function(e){var t=e[0],r=e[1];return{input:t,interpolation:n,output:r}}),t._data},n.prototype.loadBufferAsync=function(e,t,n,r){var o=this._extensionsLoadBufferAsync(e,t,n,r);if(o)return o;if(!t._data)if(t.uri)t._data=this.loadUriAsync("".concat(e,"/uri"),t,t.uri);else{if(!this._bin)throw new Error("".concat(e,": Uri is missing or the binary glTF is missing its binary chunk"));t._data=this._bin.readAsync(0,t.byteLength)}return t._data.then(function(t){try{return new Uint8Array(t.buffer,t.byteOffset+n,r)}catch(t){throw new Error("".concat(e,": ").concat(t.message),{cause:t})}})},n.prototype.loadBufferViewAsync=function(e,t){var n=this._extensionsLoadBufferViewAsync(e,t);if(n)return n;if(t._data)return t._data;var r=U.Get("".concat(e,"/buffer"),this._gltf.buffers,t.buffer);return t._data=this.loadBufferAsync("/buffers/".concat(r.index),r,t.byteOffset||0,t.byteLength),t._data},n.prototype._loadAccessorAsync=function(e,r,o){var a=this;if(r._data)return r._data;var i=n._GetNumComponents(e,r.type),s=i*t.VertexBufferGetTypeByteLength(r.componentType),l=i*r.count;if(null==r.bufferView)r._data=Promise.resolve(new o(l));else{var u=U.Get("".concat(e,"/bufferView"),this._gltf.bufferViews,r.bufferView);r._data=this.loadBufferViewAsync("/bufferViews/".concat(u.index),u).then(function(a){if(5126!==r.componentType||r.normalized||u.byteStride&&u.byteStride!==s){var c=new o(l);return t.VertexBufferForEach(a,r.byteOffset||0,u.byteStride||s,i,r.componentType,c.length,r.normalized||!1,function(e,t){c[t]=e}),c}return n._GetTypedArray(e,r.componentType,a,r.byteOffset,l)})}if(r.sparse){var c=r.sparse;r._data=r._data.then(function(l){var u=l,f=U.Get("".concat(e,"/sparse/indices/bufferView"),a._gltf.bufferViews,c.indices.bufferView),h=U.Get("".concat(e,"/sparse/values/bufferView"),a._gltf.bufferViews,c.values.bufferView);return Promise.all([a.loadBufferViewAsync("/bufferViews/".concat(f.index),f),a.loadBufferViewAsync("/bufferViews/".concat(h.index),h)]).then(function(a){var l,f=a[0],h=a[1],p=n._GetTypedArray("".concat(e,"/sparse/indices"),c.indices.componentType,f,c.indices.byteOffset,c.count),d=i*c.count;if(5126!==r.componentType||r.normalized){var m=n._GetTypedArray("".concat(e,"/sparse/values"),r.componentType,h,c.values.byteOffset,d);l=new o(d),t.VertexBufferForEach(m,0,s,i,r.componentType,l.length,r.normalized||!1,function(e,t){l[t]=e})}else l=n._GetTypedArray("".concat(e,"/sparse/values"),r.componentType,h,c.values.byteOffset,d);for(var _=0,b=0;b<p.length;b++)for(var g=p[b]*i,y=0;y<i;y++)u[g++]=l[_++];return u})})}return r._data},n.prototype._loadFloatAccessorAsync=function(e,t){return this._loadAccessorAsync(e,t,Float32Array)},n.prototype._loadIndicesAccessorAsync=function(e,t){if("SCALAR"!==t.type)throw new Error("".concat(e,"/type: Invalid value ").concat(t.type));if(5121!==t.componentType&&5123!==t.componentType&&5125!==t.componentType)throw new Error("".concat(e,"/componentType: Invalid value ").concat(t.componentType));if(t._data)return t._data;if(t.sparse){var r=n._GetTypedArrayConstructor("".concat(e,"/componentType"),t.componentType);t._data=this._loadAccessorAsync(e,t,r)}else{var o=U.Get("".concat(e,"/bufferView"),this._gltf.bufferViews,t.bufferView);t._data=this.loadBufferViewAsync("/bufferViews/".concat(o.index),o).then(function(r){return n._GetTypedArray(e,t.componentType,r,t.byteOffset,t.count)})}return t._data},n.prototype._loadVertexBufferViewAsync=function(e){if(e._babylonBuffer)return e._babylonBuffer;var n=this._babylonScene.getEngine();return e._babylonBuffer=this.loadBufferViewAsync("/bufferViews/".concat(e.index),e).then(function(e){return new t.Buffer(n,e,!1)}),e._babylonBuffer},n.prototype._loadVertexAccessorAsync=function(e,r,o){var a;if(null===(a=r._babylonVertexBuffer)||void 0===a?void 0:a[o])return r._babylonVertexBuffer[o];r._babylonVertexBuffer||(r._babylonVertexBuffer={});var i=this._babylonScene.getEngine();if(r.sparse||null==r.bufferView)r._babylonVertexBuffer[o]=this._loadFloatAccessorAsync(e,r).then(function(e){return new t.VertexBuffer(i,e,o,!1)});else{var s=U.Get("".concat(e,"/bufferView"),this._gltf.bufferViews,r.bufferView);r._babylonVertexBuffer[o]=this._loadVertexBufferViewAsync(s).then(function(a){var l=n._GetNumComponents(e,r.type);return new t.VertexBuffer(i,a,o,!1,void 0,s.byteStride,void 0,r.byteOffset,l,r.componentType,r.normalized,!0,void 0,!0)})}return r._babylonVertexBuffer[o]},n.prototype._loadMaterialMetallicRoughnessPropertiesAsync=function(e,n,r){var o=new Array,a=this._getOrCreateMaterialAdapter(r);return n&&(n.baseColorFactor?(a.baseColor=t.Color3.FromArray(n.baseColorFactor),a.geometryOpacity=n.baseColorFactor[3]):a.baseColor=t.Color3.White(),a.baseMetalness=null==n.metallicFactor?1:n.metallicFactor,a.specularRoughness=null==n.roughnessFactor?1:n.roughnessFactor,n.baseColorTexture&&o.push(this.loadTextureInfoAsync("".concat(e,"/baseColorTexture"),n.baseColorTexture,function(e){e.name="".concat(r.name," (Base Color)"),a.baseColorTexture=e})),n.metallicRoughnessTexture&&(n.metallicRoughnessTexture.nonColorData=!0,o.push(this.loadTextureInfoAsync("".concat(e,"/metallicRoughnessTexture"),n.metallicRoughnessTexture,function(e){e.name="".concat(r.name," (Metallic Roughness)"),a.baseMetalnessTexture=e,a.specularRoughnessTexture=e})),a.useRoughnessFromMetallicTextureGreen=!0,a.useMetallicFromMetallicTextureBlue=!0)),Promise.all(o).then(function(){})},n.prototype._loadMaterialAsync=function(e,t,r,o,a){void 0===a&&(a=function(){});var i=this._extensionsLoadMaterialAsync(e,t,r,o,a);if(i)return i;t._data=t._data||{};var s=t._data[o];if(!s){this.logOpen("".concat(e," ").concat(t.name||""));var l=this.createMaterial(e,t,o);s={babylonMaterial:l,babylonMeshes:[],promise:this.loadMaterialPropertiesAsync(e,t,l)},t._data[o]=s,n.AddPointerMetadata(l,e),this._parent.onMaterialLoadedObservable.notifyObservers(l),this.logClose()}return r&&(s.babylonMeshes.push(r),r.onDisposeObservable.addOnce(function(){var e=s.babylonMeshes.indexOf(r);-1!==e&&s.babylonMeshes.splice(e,1)})),a(s.babylonMaterial),s.promise.then(function(){return s.babylonMaterial})},n.prototype._selectImplForGltfMaterial=function(e){var t;if(this.parent.useOpenPBR||(null===(t=e.extensions)||void 0===t?void 0:t.KHR_materials_openpbr)){var n=this._pbrMaterialImpls.get("openpbr");if(n)return n}var r=this._pbrMaterialImpls.get("pbr");if(r)return r;throw new Error("No PBR material implementation loaded")},n.prototype._getDefaultImpl=function(){var e;if(this.parent.useOpenPBR){var t=this._pbrMaterialImpls.get("openpbr");if(t)return t}var n=null!==(e=this._pbrMaterialImpls.get("pbr"))&&void 0!==e?e:this._pbrMaterialImpls.values().next().value;if(n)return n;throw new Error("No PBR material implementation loaded")},n.prototype._createDefaultMaterial=function(e,t,n){this._babylonScene._blockEntityCollection=!!this._assetContainer;var r=new n.materialClass(e,this._babylonScene);r._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,r.fillMode=t,r.transparencyMode=n.materialClass.MATERIAL_OPAQUE;var o=this._getOrCreateMaterialAdapter(r);return o.transparencyAsAlphaCoverage=this._parent.transparencyAsCoverage,o.baseMetalness=1,o.specularRoughness=1,r},n.prototype.createMaterial=function(e,t,n){var r=this._extensionsCreateMaterial(e,t,n);if(r)return r;var o=t.name||"material".concat(t.index);return this._createDefaultMaterial(o,n,this._selectImplForGltfMaterial(t))},n.prototype.loadMaterialPropertiesAsync=function(e,t,n){var r=this._extensionsLoadMaterialPropertiesAsync(e,t,n);if(r)return r;var o=new Array;return o.push(this.loadMaterialBasePropertiesAsync(e,t,n)),t.pbrMetallicRoughness&&o.push(this._loadMaterialMetallicRoughnessPropertiesAsync("".concat(e,"/pbrMetallicRoughness"),t.pbrMetallicRoughness,n)),this.loadMaterialAlphaProperties(e,t,n),Promise.all(o).then(function(){})},n.prototype.loadMaterialBasePropertiesAsync=function(e,n,r){var o,a=new Array,i=this._getOrCreateMaterialAdapter(r);i.emissionColor=n.emissiveFactor?t.Color3.FromArray(n.emissiveFactor):new t.Color3(0,0,0),n.doubleSided&&(i.backFaceCulling=!1,i.twoSidedLighting=!0),n.normalTexture&&(n.normalTexture.nonColorData=!0,a.push(this.loadTextureInfoAsync("".concat(e,"/normalTexture"),n.normalTexture,function(e){var t;e.name="".concat(r.name," (Normal)"),i.geometryNormalTexture=e,null!=(null===(t=n.normalTexture)||void 0===t?void 0:t.scale)&&(e.level=n.normalTexture.scale)})),i.setNormalMapInversions(!this._babylonScene.useRightHandedSystem,this._babylonScene.useRightHandedSystem));var s,l=1;return n.occlusionTexture&&(n.occlusionTexture.nonColorData=!0,a.push(this.loadTextureInfoAsync("".concat(e,"/occlusionTexture"),n.occlusionTexture,function(e){e.name="".concat(r.name," (Occlusion)"),o=e})),null!=n.occlusionTexture.strength&&(l=n.occlusionTexture.strength)),n.emissiveTexture&&a.push(this.loadTextureInfoAsync("".concat(e,"/emissiveTexture"),n.emissiveTexture,function(e){e.name="".concat(r.name," (Emissive)"),s=e})),Promise.all(a).then(function(){o&&(i.ambientOcclusionTexture=o,i.ambientOcclusionTextureStrength=l),s&&(i.emissionColorTexture=s)})},n.prototype.loadMaterialAlphaProperties=function(e,n,r){if(0===this._pbrMaterialImpls.size)throw new Error("".concat(e,": Material type not supported"));var o=this._getOrCreateMaterialAdapter(r),a=o.baseColorTexture;switch(n.alphaMode||"OPAQUE"){case"OPAQUE":r.transparencyMode=t.Material.MATERIAL_OPAQUE,r.alpha=1;break;case"MASK":r.transparencyMode=t.Material.MATERIAL_ALPHATEST,o.alphaCutOff=null==n.alphaCutoff?.5:n.alphaCutoff,a&&(a.hasAlpha=!0);break;case"BLEND":r.transparencyMode=t.Material.MATERIAL_ALPHABLEND,a&&(a.hasAlpha=!0,o.useAlphaFromBaseColorTexture=!0);break;default:throw new Error("".concat(e,"/alphaMode: Invalid value (").concat(n.alphaMode,")"))}},n.prototype.loadTextureInfoAsync=function(e,t,r){var o=this;void 0===r&&(r=function(){});var a=this._extensionsLoadTextureInfoAsync(e,t,r);if(a)return a;if(this.logOpen("".concat(e)),t.texCoord>=6)throw new Error("".concat(e,"/texCoord: Invalid value (").concat(t.texCoord,")"));var i=U.Get("".concat(e,"/index"),this._gltf.textures,t.index);i._textureInfo=t;var s=this._loadTextureAsync("/textures/".concat(t.index),i,function(a){a.coordinatesIndex=t.texCoord||0,n.AddPointerMetadata(a,e),o._parent.onTextureLoadedObservable.notifyObservers(a),r(a)});return this.logClose(),s},n.prototype._loadTextureAsync=function(e,t,r){void 0===r&&(r=function(){});var o=this._extensionsLoadTextureAsync(e,t,r);if(o)return o;this.logOpen("".concat(e," ").concat(t.name||""));var a=null==t.sampler?n.DefaultSampler:U.Get("".concat(e,"/sampler"),this._gltf.samplers,t.sampler),i=U.Get("".concat(e,"/source"),this._gltf.images,t.source),s=this._createTextureAsync(e,a,i,r,void 0,!t._textureInfo.nonColorData);return this.logClose(),s},n.prototype._createTextureAsync=function(e,n,r,o,a,i){var s,l,u=this;void 0===o&&(o=function(){});var c=this._loadSampler("/samplers/".concat(n.index),n),f=new Array,h=new t.Deferred;this._babylonScene._blockEntityCollection=!!this._assetContainer;var p={noMipmap:c.noMipMaps,invertY:!1,samplingMode:c.samplingMode,onLoad:function(){u._disposed||h.resolve()},onError:function(t,n){u._disposed||h.reject(new Error("".concat(e,": ").concat(n&&n.message?n.message:t||"Failed to load texture")))},mimeType:null!==(s=r.mimeType)&&void 0!==s?s:t.GetMimeType(null!==(l=r.uri)&&void 0!==l?l:""),loaderOptions:a,useSRGBBuffer:!!i&&this._parent.useSRGBBuffers},d=new t.Texture(null,this._babylonScene,p);d._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,f.push(h.promise);var m=r.uri&&!t.IsBase64DataUrl(r.uri)?r.uri:void 0,_=null!=m?m:"".concat(this._fileName,"#image").concat(r.index);if(f.push(this.loadImageAsync("/images/".concat(r.index),r).then(function(e){var t="data:".concat(u._uniqueRootUrl).concat(_);d.updateURL(t,e);var n=d.getInternalTexture();n&&(n.label=r.name)})),d.wrapU=c.wrapU,d.wrapV=c.wrapV,o(d),this._parent.useGltfTextureNames){var b=r.name||m||"image".concat(r.index);d.name=b}return Promise.all(f).then(function(){return d})},n.prototype._loadSampler=function(e,t){return t._data||(t._data={noMipMaps:9728===t.minFilter||9729===t.minFilter,samplingMode:n._GetTextureSamplingMode(e,t),wrapU:n._GetTextureWrapMode("".concat(e,"/wrapS"),t.wrapS),wrapV:n._GetTextureWrapMode("".concat(e,"/wrapT"),t.wrapT)}),t._data},n.prototype.loadImageAsync=function(e,t){if(!t._data){if(this.logOpen("".concat(e," ").concat(t.name||"")),t.uri)t._data=this.loadUriAsync("".concat(e,"/uri"),t,t.uri);else{var n=U.Get("".concat(e,"/bufferView"),this._gltf.bufferViews,t.bufferView);t._data=this.loadBufferViewAsync("/bufferViews/".concat(n.index),n)}this.logClose()}return t._data},n.prototype.loadUriAsync=function(e,r,o){var a=this,i=this._extensionsLoadUriAsync(e,r,o);if(i)return i;if(!n._ValidateUri(o))throw new Error("".concat(e,": '").concat(o,"' is invalid"));if(t.IsBase64DataUrl(o)){var s=new Uint8Array(t.DecodeBase64UrlToBinary(o));return this.log("".concat(e,": Decoded ").concat(o.substring(0,64),"... (").concat(s.length," bytes)")),Promise.resolve(s)}return this.log("".concat(e,": Loading ").concat(o)),this._parent.preprocessUrlAsync(this._rootUrl+o).then(function(n){return new Promise(function(r,i){a._parent._loadFile(a._babylonScene,n,function(t){a._disposed||(a.log("".concat(e,": Loaded ").concat(o," (").concat(t.byteLength," bytes)")),r(new Uint8Array(t)))},!0,function(n){i(new t.LoadFileError("".concat(e,": Failed to load '").concat(o,"'").concat(n?": "+n.status+" "+n.statusText:""),n))})})})},n.AddPointerMetadata=function(e,t){e.metadata=e.metadata||{};var n=e._internalMetadata=e._internalMetadata||{},r=n.gltf=n.gltf||{};(r.pointers=r.pointers||[]).push(t)},n._GetTextureWrapMode=function(e,n){switch(n=null==n?10497:n){case 33071:return t.Texture.CLAMP_ADDRESSMODE;case 33648:return t.Texture.MIRROR_ADDRESSMODE;case 10497:return t.Texture.WRAP_ADDRESSMODE;default:return t.Logger.Warn("".concat(e,": Invalid value (").concat(n,")")),t.Texture.WRAP_ADDRESSMODE}},n._GetTextureSamplingMode=function(e,n){var r=null==n.magFilter?9729:n.magFilter,o=null==n.minFilter?9987:n.minFilter;if(9729===r)switch(o){case 9728:return t.Texture.LINEAR_NEAREST;case 9729:return t.Texture.LINEAR_LINEAR;case 9984:return t.Texture.LINEAR_NEAREST_MIPNEAREST;case 9985:return t.Texture.LINEAR_LINEAR_MIPNEAREST;case 9986:return t.Texture.LINEAR_NEAREST_MIPLINEAR;case 9987:return t.Texture.LINEAR_LINEAR_MIPLINEAR;default:return t.Logger.Warn("".concat(e,"/minFilter: Invalid value (").concat(o,")")),t.Texture.LINEAR_LINEAR_MIPLINEAR}else switch(9728!==r&&t.Logger.Warn("".concat(e,"/magFilter: Invalid value (").concat(r,")")),o){case 9728:return t.Texture.NEAREST_NEAREST;case 9729:return t.Texture.NEAREST_LINEAR;case 9984:return t.Texture.NEAREST_NEAREST_MIPNEAREST;case 9985:return t.Texture.NEAREST_LINEAR_MIPNEAREST;case 9986:return t.Texture.NEAREST_NEAREST_MIPLINEAR;case 9987:return t.Texture.NEAREST_LINEAR_MIPLINEAR;default:return t.Logger.Warn("".concat(e,"/minFilter: Invalid value (").concat(o,")")),t.Texture.NEAREST_NEAREST_MIPNEAREST}},n._GetTypedArrayConstructor=function(e,n){try{return t.GetTypedArrayConstructor(n)}catch(t){throw new Error("".concat(e,": ").concat(t.message),{cause:t})}},n._GetTypedArray=function(e,r,o,a,i){var s=o.buffer;a=o.byteOffset+(a||0);var l=n._GetTypedArrayConstructor("".concat(e,"/componentType"),r),u=t.VertexBufferGetTypeByteLength(r);return a%u!==0?(t.Logger.Warn("".concat(e,": Copying buffer as byte offset (").concat(a,") is not a multiple of component type byte length (").concat(u,")")),new l(s.slice(a,a+i*u),0)):new l(s,a,i)},n._GetNumComponents=function(e,t){switch(t){case"SCALAR":return 1;case"VEC2":return 2;case"VEC3":return 3;case"VEC4":case"MAT2":return 4;case"MAT3":return 9;case"MAT4":return 16}throw new Error("".concat(e,": Invalid type (").concat(t,")"))},n._ValidateUri=function(e){return t.Tools.IsBase64(e)||-1===e.indexOf("..")},n._GetDrawMode=function(e,n){switch(null==n&&(n=4),n){case 0:return t.Material.PointListDrawMode;case 1:return t.Material.LineListDrawMode;case 2:return t.Material.LineLoopDrawMode;case 3:return t.Material.LineStripDrawMode;case 4:return t.Material.TriangleFillMode;case 5:return t.Material.TriangleStripDrawMode;case 6:return t.Material.TriangleFanDrawMode}throw new Error("".concat(e,": Invalid mesh primitive mode (").concat(n,")"))},n.prototype._compileMaterialsAsync=function(){var e=this;this._parent._startPerformanceCounter("Compile materials");var t=new Array;if(this._gltf.materials)for(var n=0,r=this._gltf.materials;n<r.length;n++){var o=r[n];if(o._data)for(var a in o._data)for(var i=o._data[a],s=0,l=i.babylonMeshes;s<l.length;s++){var u=l[s];u.computeWorldMatrix(!0);var c=i.babylonMaterial;t.push(c.forceCompilationAsync(u)),t.push(c.forceCompilationAsync(u,{useInstances:!0})),this._parent.useClipPlane&&(t.push(c.forceCompilationAsync(u,{clipPlane:!0})),t.push(c.forceCompilationAsync(u,{clipPlane:!0,useInstances:!0})))}}return Promise.all(t).then(function(){e._parent._endPerformanceCounter("Compile materials")})},n.prototype._compileShadowGeneratorsAsync=function(){var e=this;this._parent._startPerformanceCounter("Compile shadow generators");for(var t=new Array,n=0,r=this._babylonScene.lights;n<r.length;n++){var o=r[n].getShadowGenerator();o&&t.push(o.forceCompilationAsync())}return Promise.all(t).then(function(){e._parent._endPerformanceCounter("Compile shadow generators")})},n.prototype._forEachExtensions=function(e){for(var t=0,n=this._extensions;t<n.length;t++){var r=n[t];r.enabled&&e(r)}},n.prototype._applyExtensions=function(e,t,n){for(var r=0,o=this._extensions;r<o.length;r++){var a=o[r];if(a.enabled){var i="".concat(a.name,".").concat(t),s=e;s._activeLoaderExtensionFunctions=s._activeLoaderExtensionFunctions||{};var l=s._activeLoaderExtensionFunctions;if(!l[i]){l[i]=!0;try{var u=n(a);if(u)return u}finally{delete l[i]}}}}return null},n.prototype._extensionsOnLoading=function(){this._forEachExtensions(function(e){return e.onLoading&&e.onLoading()})},n.prototype._extensionsOnReady=function(){this._forEachExtensions(function(e){return e.onReady&&e.onReady()})},n.prototype._extensionsLoadSceneAsync=function(e,t){return this._applyExtensions(t,"loadScene",function(n){return n.loadSceneAsync&&n.loadSceneAsync(e,t)})},n.prototype._extensionsLoadNodeAsync=function(e,t,n){return this._applyExtensions(t,"loadNode",function(r){return r.loadNodeAsync&&r.loadNodeAsync(e,t,n)})},n.prototype._extensionsLoadCameraAsync=function(e,t,n){return this._applyExtensions(t,"loadCamera",function(r){return r.loadCameraAsync&&r.loadCameraAsync(e,t,n)})},n.prototype._extensionsLoadVertexDataAsync=function(e,t,n){return this._applyExtensions(t,"loadVertexData",function(r){return r._loadVertexDataAsync&&r._loadVertexDataAsync(e,t,n)})},n.prototype._extensionsLoadMeshPrimitiveAsync=function(e,t,n,r,o,a){return this._applyExtensions(o,"loadMeshPrimitive",function(i){return i._loadMeshPrimitiveAsync&&i._loadMeshPrimitiveAsync(e,t,n,r,o,a)})},n.prototype._extensionsLoadMaterialAsync=function(e,t,n,r,o){return this._applyExtensions(t,"loadMaterial",function(a){return a._loadMaterialAsync&&a._loadMaterialAsync(e,t,n,r,o)})},n.prototype._extensionsCreateMaterial=function(e,t,n){return this._applyExtensions(t,"createMaterial",function(r){return r.createMaterial&&r.createMaterial(e,t,n)})},n.prototype._extensionsLoadMaterialPropertiesAsync=function(e,t,n){return this._applyExtensions(t,"loadMaterialProperties",function(r){return r.loadMaterialPropertiesAsync&&r.loadMaterialPropertiesAsync(e,t,n)})},n.prototype._extensionsLoadTextureInfoAsync=function(e,t,n){return this._applyExtensions(t,"loadTextureInfo",function(r){return r.loadTextureInfoAsync&&r.loadTextureInfoAsync(e,t,n)})},n.prototype._extensionsLoadTextureAsync=function(e,t,n){return this._applyExtensions(t,"loadTexture",function(r){return r._loadTextureAsync&&r._loadTextureAsync(e,t,n)})},n.prototype._extensionsLoadAnimationAsync=function(e,t){return this._applyExtensions(t,"loadAnimation",function(n){return n.loadAnimationAsync&&n.loadAnimationAsync(e,t)})},n.prototype._extensionsLoadAnimationChannelAsync=function(e,t,n,r,o){return this._applyExtensions(n,"loadAnimationChannel",function(a){return a._loadAnimationChannelAsync&&a._loadAnimationChannelAsync(e,t,n,r,o)})},n.prototype._extensionsLoadSkinAsync=function(e,t,n){return this._applyExtensions(n,"loadSkin",function(r){return r._loadSkinAsync&&r._loadSkinAsync(e,t,n)})},n.prototype._extensionsLoadUriAsync=function(e,t,n){return this._applyExtensions(t,"loadUri",function(r){return r._loadUriAsync&&r._loadUriAsync(e,t,n)})},n.prototype._extensionsLoadBufferViewAsync=function(e,t){return this._applyExtensions(t,"loadBufferView",function(n){return n.loadBufferViewAsync&&n.loadBufferViewAsync(e,t)})},n.prototype._extensionsLoadBufferAsync=function(e,t,n,r){return this._applyExtensions(t,"loadBuffer",function(o){return o.loadBufferAsync&&o.loadBufferAsync(e,t,n,r)})},n.LoadExtensionAsync=function(e,t,n,r){if(!t.extensions)return null;var o=t.extensions[n];return o?r("".concat(e,"/extensions/").concat(n),o):null},n.LoadExtraAsync=function(e,t,n,r){if(!t.extras)return null;var o=t.extras[n];return o?r("".concat(e,"/extras/").concat(n),o):null},n.prototype.isExtensionUsed=function(e){return!!this._gltf.extensionsUsed&&-1!==this._gltf.extensionsUsed.indexOf(e)},n.prototype.logOpen=function(e){this._parent._logOpen(e)},n.prototype.logClose=function(){this._parent._logClose()},n.prototype.log=function(e){this._parent._log(e)},n.prototype.startPerformanceCounter=function(e){this._parent._startPerformanceCounter(e)},n.prototype.endPerformanceCounter=function(e){this._parent._endPerformanceCounter(e)},n.DefaultSampler={index:-1},n}();T._CreateGLTF2Loader=function(e){return new q(e)};var Y="EXT_lights_image_based",X=function(){function e(e){this.name=Y,this._loader=e,this.enabled=this._loader.isExtensionUsed(Y)}return e.prototype.dispose=function(){this._loader=null,delete this._lights},e.prototype.onLoading=function(){var e=this._loader.gltf.extensions;if(e&&e[this.name]){var t=e[this.name];this._lights=t.lights}},e.prototype.loadSceneAsync=function(e,t){var n=this;return q.LoadExtensionAsync(e,t,this.name,function(r,o){return a(n,void 0,void 0,function(){var n,a,s=this;return i(this,function(i){switch(i.label){case 0:return this._loader._allMaterialsDirtyRequired=!0,(n=new Array).push(this._loader.loadSceneAsync(e,t)),this._loader.logOpen("".concat(r)),a=U.Get("".concat(r,"/light"),this._lights,o.light),n.push(this._loadLightAsync("/extensions/".concat(this.name,"/lights/").concat(o.light),a).then(function(e){s._loader.babylonScene.environmentTexture=e})),this._loader.logClose(),[4,Promise.all(n).then(function(){})];case 1:return[2,i.sent()]}})})})},e.prototype._loadLightAsync=function(e,n){var r=this;if(!n._loaded){var o=new Array;this._loader.logOpen("".concat(e));for(var s=new Array(n.specularImages.length),l=function(t){var r=n.specularImages[t];s[t]=new Array(r.length);for(var a=function(n){var a="".concat(e,"/specularImages/").concat(t,"/").concat(n);u._loader.logOpen("".concat(a));var i=r[n],l=U.Get(a,u._loader.gltf.images,i);o.push(u._loader.loadImageAsync("/images/".concat(i),l).then(function(e){s[t][n]=e})),u._loader.logClose()},i=0;i<r.length;i++)a(i)},u=this,c=0;c<n.specularImages.length;c++)l(c);this._loader.logClose(),n._loaded=Promise.all(o).then(function(){return a(r,void 0,void 0,function(){var r,o,a,l,u;return i(this,function(i){switch(i.label){case 0:if((r=new t.RawCubeTexture(this._loader.babylonScene,null,n.specularImageSize)).name=n.name||"environment",n._babylonTexture=r,null!=n.intensity&&(r.level=n.intensity),n.rotation&&(o=t.Quaternion.FromArray(n.rotation),this._loader.babylonScene.useRightHandedSystem||(o=t.Quaternion.Inverse(o)),t.Matrix.FromQuaternionToRef(o,r.getReflectionTextureMatrix())),!n.irradianceCoefficients)throw new Error("".concat(e,": Irradiance coefficients are missing"));return(a=t.SphericalHarmonics.FromArray(n.irradianceCoefficients)).scaleInPlace(n.intensity),a.convertIrradianceToLambertianRadiance(),l=t.SphericalPolynomial.FromHarmonics(a),u=(s.length-1)/Math.log2(n.specularImageSize),[4,r.updateRGBDAsync(s,l,u)];case 1:return[2,i.sent()]}})})})}return n._loaded.then(function(){return n._babylonTexture})},e}();K(Y),H(Y,!0,function(e){return new X(e)});var Q="EXT_mesh_gpu_instancing",J=function(){function e(e){this.name=Q,this._loader=e,this.enabled=this._loader.isExtensionUsed(Q)}return e.prototype.dispose=function(){this._loader=null},e.prototype.loadNodeAsync=function(e,n,r){var o=this;return q.LoadExtensionAsync(e,n,this.name,function(e,s){return a(o,void 0,void 0,function(){var o,l,u,c,f=this;return i(this,function(h){switch(h.label){case 0:return this._loader._disableInstancedMesh++,o=this._loader.loadNodeAsync("/nodes/".concat(n.index),n,r),this._loader._disableInstancedMesh--,n._primitiveBabylonMeshes?[3,2]:[4,o];case 1:case 3:return[2,h.sent()];case 2:return l=new Array,u=0,(c=function(t){if(null!=s.attributes[t]){var n=U.Get("".concat(e,"/attributes/").concat(t),f._loader.gltf.accessors,s.attributes[t]);if(l.push(f._loader._loadFloatAccessorAsync("/accessors/".concat(n.bufferView),n)),0===u)u=n.count;else if(u!==n.count)throw new Error("".concat(e,"/attributes: Instance buffer accessors do not have the same count."))}else l.push(Promise.resolve(null))})("TRANSLATION"),c("ROTATION"),c("SCALE"),c("_COLOR_0"),[4,o.then(function(e){return a(f,void 0,void 0,function(){var r,o,a,s,c,f,h,p,d,m;return i(this,function(i){switch(i.label){case 0:return[4,Promise.all(l)];case 1:for(r=i.sent(),o=r[0],a=r[1],s=r[2],c=r[3],f=new Float32Array(16*u),t.TmpVectors.Vector3[0].copyFromFloats(0,0,0),t.TmpVectors.Quaternion[0].copyFromFloats(0,0,0,1),t.TmpVectors.Vector3[1].copyFromFloats(1,1,1),h=0;h<u;++h)o&&t.Vector3.FromArrayToRef(o,3*h,t.TmpVectors.Vector3[0]),a&&t.Quaternion.FromArrayToRef(a,4*h,t.TmpVectors.Quaternion[0]),s&&t.Vector3.FromArrayToRef(s,3*h,t.TmpVectors.Vector3[1]),t.Matrix.ComposeToRef(t.TmpVectors.Vector3[1],t.TmpVectors.Quaternion[0],t.TmpVectors.Vector3[0],t.TmpVectors.Matrix[0]),t.TmpVectors.Matrix[0].copyToArray(f,16*h);for(p=0,d=n._primitiveBabylonMeshes;p<d.length;p++)(m=d[p]).thinInstanceSetBuffer("matrix",f,16,!0),c&&(c.length===3*u?m.thinInstanceSetBuffer("color",c,3,!0):c.length===4*u?m.thinInstanceSetBuffer("color",c,4,!0):t.Logger.Warn("Unexpected size of _COLOR_0 attribute for mesh "+m.name));return[2,e]}})})})]}})})})},e}();K(Q),H(Q,!0,function(e){return new J(e)});var Z="EXT_meshopt_compression",$=function(){function e(e){this.name=Z,this.enabled=e.isExtensionUsed(Z),this._loader=e}return e.prototype.dispose=function(){this._loader=null},e.prototype.loadBufferViewAsync=function(e,n){var r=this;return q.LoadExtensionAsync(e,n,this.name,function(o,s){return a(r,void 0,void 0,function(){var r,o,l=this;return i(this,function(u){switch(u.label){case 0:return(r=n)._meshOptData?[4,r._meshOptData]:[3,2];case 1:case 3:return[2,u.sent()];case 2:return o=U.Get("".concat(e,"/buffer"),this._loader.gltf.buffers,s.buffer),r._meshOptData=this._loader.loadBufferAsync("/buffers/".concat(o.index),o,s.byteOffset||0,s.byteLength).then(function(e){return a(l,void 0,void 0,function(){return i(this,function(n){switch(n.label){case 0:return[4,t.MeshoptCompression.Default.decodeGltfBufferAsync(e,s.count,s.byteStride,s.mode,s.filter)];case 1:return[2,n.sent()]}})})}),[4,r._meshOptData]}})})})},e}();K(Z),H(Z,!0,function(e){return new $(e)});var ee="EXT_texture_webp",te=function(){function e(e){this.name=ee,this._loader=e,this.enabled=e.isExtensionUsed(ee)}return e.prototype.dispose=function(){this._loader=null},e.prototype._loadTextureAsync=function(e,t,n){var r=this;return q.LoadExtensionAsync(e,t,this.name,function(o,s){return a(r,void 0,void 0,function(){var r,a;return i(this,function(i){switch(i.label){case 0:return r=null==t.sampler?q.DefaultSampler:U.Get("".concat(e,"/sampler"),this._loader.gltf.samplers,t.sampler),a=U.Get("".concat(o,"/source"),this._loader.gltf.images,s.source),[4,this._loader._createTextureAsync(e,r,a,function(e){n(e)},void 0,!t._textureInfo.nonColorData)];case 1:return[2,i.sent()]}})})})},e}();K(ee),H(ee,!0,function(e){return new te(e)});var ne="EXT_texture_avif",re=function(){function e(e){this.name=ne,this._loader=e,this.enabled=e.isExtensionUsed(ne)}return e.prototype.dispose=function(){this._loader=null},e.prototype._loadTextureAsync=function(e,t,n){var r=this;return q.LoadExtensionAsync(e,t,this.name,function(o,s){return a(r,void 0,void 0,function(){var r,a;return i(this,function(i){switch(i.label){case 0:return r=null==t.sampler?q.DefaultSampler:U.Get("".concat(e,"/sampler"),this._loader.gltf.samplers,t.sampler),a=U.Get("".concat(o,"/source"),this._loader.gltf.images,s.source),[4,this._loader._createTextureAsync(e,r,a,function(e){n(e)},void 0,!t._textureInfo.nonColorData)];case 1:return[2,i.sent()]}})})})},e}();K(ne),H(ne,!0,function(e){return new re(e)});var oe="EXT_lights_ies",ae=function(){function e(e){this.name=oe,this._loader=e,this.enabled=this._loader.isExtensionUsed(oe)}return e.prototype.dispose=function(){this._loader=null,delete this._lights},e.prototype.onLoading=function(){var e=this._loader.gltf.extensions;if(e&&e[this.name]){var t=e[this.name];this._lights=t.lights,U.Assign(this._lights)}},e.prototype.loadNodeAsync=function(e,n,r){var o=this;return q.LoadExtensionAsync(e,n,this.name,function(s,l){return a(o,void 0,void 0,function(){var o,a,u,c,f,h=this;return i(this,function(i){switch(i.label){case 0:return this._loader._allMaterialsDirtyRequired=!0,[4,this._loader.loadNodeAsync(e,n,function(e){var n=(a=U.Get(s,h._lights,l.light)).name||e.name;h._loader.babylonScene._blockEntityCollection=!!h._loader._assetContainer,(o=new t.SpotLight(n,t.Vector3.Zero(),t.Vector3.Backward(),0,1,h._loader.babylonScene)).angle=Math.PI/2,o.innerAngle=0,o._parentContainer=h._loader._assetContainer,h._loader.babylonScene._blockEntityCollection=!1,a._babylonLight=o,o.falloffType=t.Light.FALLOFF_GLTF,o.diffuse=l.color?t.Color3.FromArray(l.color):t.Color3.White(),o.intensity=l.multiplier||1,o.range=Number.MAX_VALUE,o.parent=e,h._loader._babylonLights.push(o),q.AddPointerMetadata(o,s),r(e)})];case 1:return u=i.sent(),a.uri?[4,this._loader.loadUriAsync(e,a,a.uri)]:[3,3];case 2:return c=i.sent(),[3,5];case 3:return f=U.Get("".concat(e,"/bufferView"),this._loader.gltf.bufferViews,a.bufferView),[4,this._loader.loadBufferViewAsync("/bufferViews/".concat(f.index),f)];case 4:c=i.sent(),i.label=5;case 5:return o.iesProfileTexture=new t.Texture(name+"_iesProfile",this._loader.babylonScene,!0,!1,void 0,null,null,c,!0,void 0,void 0,void 0,void 0,".ies"),[2,u]}})})})},e}();K(oe),H(oe,!0,function(e){return new ae(e)});var ie="KHR_draco_mesh_compression",se=function(){function e(e){this.name=ie,this.useNormalizedFlagFromAccessor=!0,this._loader=e,this.enabled=t.DracoDecoder.DefaultAvailable&&this._loader.isExtensionUsed(ie)}return e.prototype.dispose=function(){delete this.dracoDecoder,this._loader=null},e.prototype._loadVertexDataAsync=function(e,n,r){var o=this;return q.LoadExtensionAsync(e,n,this.name,function(s,l){return a(o,void 0,void 0,function(){var o,u,c,f,h=this;return i(this,function(p){switch(p.label){case 0:if(null!=n.mode&&4!==n.mode&&5!==n.mode)throw new Error("".concat(e,": Unsupported mode ").concat(n.mode));return o={},u={},(c=function(e,t){var a=l.attributes[e];if(null!=a&&(r._delayInfo=r._delayInfo||[],-1===r._delayInfo.indexOf(t)&&r._delayInfo.push(t),o[t]=a,h.useNormalizedFlagFromAccessor)){var i=U.TryGet(h._loader.gltf.accessors,n.attributes[e]);i&&(u[t]=i.normalized||!1)}})("POSITION",t.VertexBuffer.PositionKind),c("NORMAL",t.VertexBuffer.NormalKind),c("TANGENT",t.VertexBuffer.TangentKind),c("TEXCOORD_0",t.VertexBuffer.UVKind),c("TEXCOORD_1",t.VertexBuffer.UV2Kind),c("TEXCOORD_2",t.VertexBuffer.UV3Kind),c("TEXCOORD_3",t.VertexBuffer.UV4Kind),c("TEXCOORD_4",t.VertexBuffer.UV5Kind),c("TEXCOORD_5",t.VertexBuffer.UV6Kind),c("JOINTS_0",t.VertexBuffer.MatricesIndicesKind),c("WEIGHTS_0",t.VertexBuffer.MatricesWeightsKind),c("COLOR_0",t.VertexBuffer.ColorKind),(f=U.Get(s,this._loader.gltf.bufferViews,l.bufferView))._dracoBabylonGeometry||(f._dracoBabylonGeometry=this._loader.loadBufferViewAsync("/bufferViews/".concat(f.index),f).then(function(s){return a(h,void 0,void 0,function(){var a,l,c;return i(this,function(i){switch(i.label){case 0:return a=this.dracoDecoder||t.DracoDecoder.Default,l=U.TryGet(this._loader.gltf.accessors,n.attributes.POSITION),c=this._loader.parent.alwaysComputeBoundingBox||r.skeleton||!l?null:z(l),[4,a._decodeMeshToGeometryForGltfAsync(r.name,this._loader.babylonScene,s,o,u,c).catch(function(t){throw new Error("".concat(e,": ").concat(t.message))})];case 1:return[2,i.sent()]}})})})),[4,f._dracoBabylonGeometry];case 1:return[2,p.sent()]}})})})},e}();K(ie),H(ie,!0,function(e){return new se(e)});var le="KHR_lights_punctual",ue=function(){function e(e){this.name=le,this._loader=e,this.enabled=this._loader.isExtensionUsed(le)}return e.prototype.dispose=function(){this._loader=null,delete this._lights},e.prototype.onLoading=function(){var e=this._loader.gltf.extensions;if(e&&e[this.name]){var t=e[this.name];this._lights=t.lights,U.Assign(this._lights)}},e.prototype.loadNodeAsync=function(e,n,r){var o=this;return q.LoadExtensionAsync(e,n,this.name,function(s,l){return a(o,void 0,void 0,function(){var o=this;return i(this,function(a){switch(a.label){case 0:return this._loader._allMaterialsDirtyRequired=!0,[4,this._loader.loadNodeAsync(e,n,function(e){var n,a=U.Get(s,o._lights,l.light),i=a.name||e.name;switch(o._loader.babylonScene._blockEntityCollection=!!o._loader._assetContainer,a.type){case"directional":var u=new t.DirectionalLight(i,t.Vector3.Backward(),o._loader.babylonScene);u.position.setAll(0),n=u;break;case"point":n=new t.PointLight(i,t.Vector3.Zero(),o._loader.babylonScene);break;case"spot":var c=new t.SpotLight(i,t.Vector3.Zero(),t.Vector3.Backward(),0,1,o._loader.babylonScene);c.angle=2*(a.spot&&a.spot.outerConeAngle||Math.PI/4),c.innerAngle=2*(a.spot&&a.spot.innerConeAngle||0),n=c;break;default:throw o._loader.babylonScene._blockEntityCollection=!1,new Error("".concat(s,": Invalid light type (").concat(a.type,")"))}n._parentContainer=o._loader._assetContainer,o._loader.babylonScene._blockEntityCollection=!1,a._babylonLight=n,n.falloffType=t.Light.FALLOFF_GLTF,n.diffuse=a.color?t.Color3.FromArray(a.color):t.Color3.White(),n.intensity=null==a.intensity?1:a.intensity,n.range=null==a.range?Number.MAX_VALUE:a.range,n.parent=e,o._loader._babylonLights.push(n),q.AddPointerMetadata(n,s),r(e)})];case 1:return[2,a.sent()]}})})})},e}();K(le),H(le,!0,function(e){return new ue(e)});var ce="EXT_lights_area",fe=function(){function e(e){this.name=ce,this._loader=e,this.enabled=this._loader.isExtensionUsed(ce)}return e.prototype.dispose=function(){this._loader=null,delete this._lights},e.prototype.onLoading=function(){var e=this._loader.gltf.extensions;if(e&&e[this.name]){var t=e[this.name];this._lights=t.lights,U.Assign(this._lights)}},e.prototype.loadNodeAsync=function(e,n,r){var o=this;return q.LoadExtensionAsync(e,n,this.name,function(s,l){return a(o,void 0,void 0,function(){var o=this;return i(this,function(a){switch(a.label){case 0:return this._loader._allMaterialsDirtyRequired=!0,[4,this._loader.loadNodeAsync(e,n,function(e){var n,a,i=U.Get(s,o._lights,l.light),u=i.name||e.name;o._loader.babylonScene._blockEntityCollection=!!o._loader._assetContainer;var c=void 0!==i.size?i.size:1;switch(i.type){case"rect":var f=void 0!==(null===(n=i.rect)||void 0===n?void 0:n.aspect)?i.rect.aspect*c:c,h=c;a=new t.RectAreaLight(u,t.Vector3.Zero(),f,h,o._loader.babylonScene);break;case"disk":var p=Math.sqrt(c*c*.25*Math.PI);a=new t.RectAreaLight(u,t.Vector3.Zero(),p,p,o._loader.babylonScene);break;default:throw o._loader.babylonScene._blockEntityCollection=!1,new Error("".concat(s,": Invalid area light type (").concat(i.type,")"))}a._parentContainer=o._loader._assetContainer,o._loader.babylonScene._blockEntityCollection=!1,i._babylonLight=a,a.falloffType=t.Light.FALLOFF_GLTF,a.diffuse=i.color?t.Color3.FromArray(i.color):t.Color3.White(),a.intensity=null==i.intensity?1:i.intensity;var d=new t.TransformNode("".concat(u,"_orientation"),o._loader.babylonScene);d.rotationQuaternion=t.Quaternion.RotationAxis(t.Vector3.Up(),Math.PI),d.parent=e,a.parent=d,o._loader._babylonLights.push(a),q.AddPointerMetadata(a,s),r(e)})];case 1:return[2,a.sent()]}})})})},e}();K(ce),H(ce,!0,function(e){return new fe(e)});var he="KHR_materials_pbrSpecularGlossiness",pe=function(){function e(e){this.name=he,this.order=200,this._loader=e,this.enabled=this._loader.isExtensionUsed(he)}return e.prototype.dispose=function(){this._loader=null},e.prototype.loadMaterialPropertiesAsync=function(e,t,n){var r=this;return q.LoadExtensionAsync(e,t,this.name,function(o,s){return a(r,void 0,void 0,function(){var r;return i(this,function(a){switch(a.label){case 0:return(r=new Array).push(this._loader.loadMaterialBasePropertiesAsync(e,t,n)),r.push(this._loadSpecularGlossinessPropertiesAsync(o,s,n)),this._loader.loadMaterialAlphaProperties(e,t,n),[4,Promise.all(r).then(function(){})];case 1:return[2,a.sent()]}})})})},e.prototype._loadSpecularGlossinessPropertiesAsync=function(e,n,r){var o=this._loader._getOrCreateMaterialAdapter(r),a=new Array;return o.configureSpecularGlossiness(),n.diffuseFactor?(o.baseColor=t.Color3.FromArray(n.diffuseFactor),r.alpha=n.diffuseFactor[3]):o.baseColor=t.Color3.White(),o.specularColor=n.specularFactor?t.Color3.FromArray(n.specularFactor):t.Color3.White(),o.glossiness=null==n.glossinessFactor?1:n.glossinessFactor,n.diffuseTexture&&a.push(this._loader.loadTextureInfoAsync("".concat(e,"/diffuseTexture"),n.diffuseTexture,function(e){e.name="".concat(r.name," (Diffuse)"),o.baseColorTexture=e})),n.specularGlossinessTexture&&a.push(this._loader.loadTextureInfoAsync("".concat(e,"/specularGlossinessTexture"),n.specularGlossinessTexture,function(e){e.name="".concat(r.name," (Specular Glossiness)"),o.specularColorTexture=e})),Promise.all(a).then(function(){})},e}();K(he),H(he,!0,function(e){return new pe(e)});var de="KHR_materials_unlit",me=function(){function e(e){this.name=de,this.order=210,this._loader=e,this.enabled=this._loader.isExtensionUsed(de)}return e.prototype.dispose=function(){this._loader=null},e.prototype.loadMaterialPropertiesAsync=function(e,t,n){var r=this;return q.LoadExtensionAsync(e,t,this.name,function(){return a(r,void 0,void 0,function(){return i(this,function(r){switch(r.label){case 0:return[4,this._loadUnlitPropertiesAsync(e,t,n)];case 1:return[2,r.sent()]}})})})},e.prototype._loadUnlitPropertiesAsync=function(e,n,r){var o=this._loader._getOrCreateMaterialAdapter(r),a=new Array,i=n.pbrMetallicRoughness;return i&&(i.baseColorFactor&&(o.baseColor=t.Color3.FromArray(i.baseColorFactor),o.geometryOpacity=i.baseColorFactor[3]),i.baseColorTexture&&a.push(this._loader.loadTextureInfoAsync("".concat(e,"/baseColorTexture"),i.baseColorTexture,function(e){e.name="".concat(r.name," (Base Color)"),o.baseColorTexture=e}))),o.isUnlit=!0,n.doubleSided&&(o.backFaceCulling=!1,o.twoSidedLighting=!0),this._loader.loadMaterialAlphaProperties(e,n,r),Promise.all(a).then(function(){})},e}();K(de),H(de,!0,function(e){return new me(e)});var _e="KHR_materials_clearcoat",be=function(){function e(e){this.name=_e,this.order=190,this._loader=e,this.enabled=this._loader.isExtensionUsed(_e)}return e.prototype.dispose=function(){this._loader=null},e.prototype.loadMaterialPropertiesAsync=function(e,t,n){var r=this;return q.LoadExtensionAsync(e,t,this.name,function(o,s){return a(r,void 0,void 0,function(){var r;return i(this,function(a){switch(a.label){case 0:return(r=new Array).push(this._loader.loadMaterialPropertiesAsync(e,t,n)),r.push(this._loadClearCoatPropertiesAsync(o,s,n)),[4,Promise.all(r)];case 1:return a.sent(),[2]}})})})},e.prototype._loadClearCoatPropertiesAsync=function(e,t,n){var r=this._loader._getOrCreateMaterialAdapter(n),o=new Array;return r.configureCoat(),r.coatWeight=void 0!==t.clearcoatFactor?t.clearcoatFactor:0,r.coatRoughness=void 0!==t.clearcoatRoughnessFactor?t.clearcoatRoughnessFactor:0,t.clearcoatTexture&&o.push(this._loader.loadTextureInfoAsync("".concat(e,"/clearcoatTexture"),t.clearcoatTexture,function(e){e.name="".concat(n.name," (ClearCoat)"),r.coatWeightTexture=e})),t.clearcoatRoughnessTexture&&(t.clearcoatRoughnessTexture.nonColorData=!0,o.push(this._loader.loadTextureInfoAsync("".concat(e,"/clearcoatRoughnessTexture"),t.clearcoatRoughnessTexture,function(e){e.name="".concat(n.name," (ClearCoat Roughness)"),r.coatRoughnessTexture=e}))),t.clearcoatNormalTexture&&(t.clearcoatNormalTexture.nonColorData=!0,o.push(this._loader.loadTextureInfoAsync("".concat(e,"/clearcoatNormalTexture"),t.clearcoatNormalTexture,function(e){var o;e.name="".concat(n.name," (ClearCoat Normal)"),r.geometryCoatNormalTexture=e,null!=(null===(o=t.clearcoatNormalTexture)||void 0===o?void 0:o.scale)&&(r.geometryCoatNormalTextureScale=t.clearcoatNormalTexture.scale)})),r.setNormalMapInversions(!n.getScene().useRightHandedSystem,n.getScene().useRightHandedSystem)),Promise.all(o).then(function(){})},e}();K(_e),H(_e,!0,function(e){return new be(e)});var ge="KHR_materials_coat",ye=function(){function e(e){this.name=ge,this.order=191,this.useOpenPBR=!1,this._loader=e,this.enabled=this._loader.isExtensionUsed(ge)}return e.prototype.dispose=function(){this._loader=null},e.prototype.loadMaterialPropertiesAsync=function(e,t,n){var r=this;return q.LoadExtensionAsync(e,t,this.name,function(o,s){return a(r,void 0,void 0,function(){var r;return i(this,function(a){switch(a.label){case 0:return(r=new Array).push(this._loader.loadMaterialPropertiesAsync(e,t,n)),t.extensions&&t.extensions.KHR_materials_openpbr&&(this.useOpenPBR=!0),r.push(this._loadCoatPropertiesAsync(o,s,n)),[4,Promise.all(r)];case 1:return a.sent(),[2]}})})})},e.prototype._loadCoatPropertiesAsync=function(e,n,r){var o,a,i=this._loader._getOrCreateMaterialAdapter(r),s=new Array;i.configureCoat(),i.coatWeight=void 0!==n.coatFactor?n.coatFactor:0,i.coatRoughness=void 0!==n.coatRoughnessFactor?n.coatRoughnessFactor:0,n.coatTexture&&s.push(this._loader.loadTextureInfoAsync("".concat(e,"/coatTexture"),n.coatTexture,function(e){e.name="".concat(r.name," (Coat)"),i.coatWeightTexture=e})),n.coatRoughnessTexture&&(n.coatRoughnessTexture.nonColorData=!0,s.push(this._loader.loadTextureInfoAsync("".concat(e,"/coatRoughnessTexture"),n.coatRoughnessTexture,function(e){e.name="".concat(r.name," (Coat Roughness)"),i.coatRoughnessTexture=e}))),n.coatNormalTexture&&(n.coatNormalTexture.nonColorData=!0,s.push(this._loader.loadTextureInfoAsync("".concat(e,"/coatNormalTexture"),n.coatNormalTexture,function(e){var t;e.name="".concat(r.name," (Coat Normal)"),i.geometryCoatNormalTexture=e,null!=(null===(t=n.coatNormalTexture)||void 0===t?void 0:t.scale)&&(i.geometryCoatNormalTextureScale=n.coatNormalTexture.scale)})),i.setNormalMapInversions(!r.getScene().useRightHandedSystem,r.getScene().useRightHandedSystem)),i.coatDarkening=void 0!==n.coatDarkeningFactor?n.coatDarkeningFactor:1,i.coatIor=void 0!==n.coatIor?n.coatIor:1.5;var l=t.Color3.White();void 0!==n.coatColorFactor&&l.fromArray(n.coatColorFactor),i.coatColor=l,n.coatColorTexture&&s.push(this._loader.loadTextureInfoAsync("".concat(e,"/coatColorTexture"),n.coatColorTexture,function(e){e.name="".concat(r.name," (Coat Color)"),i.coatColorTexture=e}));var u=null!==(o=n.coatAnisotropyStrength)&&void 0!==o?o:0,c=null!==(a=n.coatAnisotropyRotation)&&void 0!==a?a:0;return i.coatRoughnessAnisotropy=u,i.geometryCoatTangentAngle=c,this.useOpenPBR||i.configureGltfStyleAnisotropy(!0),n.coatAnisotropyTexture&&(n.coatAnisotropyTexture.nonColorData=!0,s.push(this._loader.loadTextureInfoAsync("".concat(e,"/coatAnisotropyTexture"),n.coatAnisotropyTexture,function(e){e.name="".concat(r.name," (Coat Anisotropy)"),i.geometryCoatTangentTexture=e}))),Promise.all(s).then(function(){})},e}();K(ge),H(ge,!0,function(e){return new ye(e)});var ve="KHR_materials_iridescence",Te=function(){function e(e){this.name=ve,this.order=195,this._loader=e,this.enabled=this._loader.isExtensionUsed(ve)}return e.prototype.dispose=function(){this._loader=null},e.prototype.loadMaterialPropertiesAsync=function(e,t,n){var r=this;return q.LoadExtensionAsync(e,t,this.name,function(o,s){return a(r,void 0,void 0,function(){var r;return i(this,function(a){switch(a.label){case 0:return(r=new Array).push(this._loader.loadMaterialPropertiesAsync(e,t,n)),r.push(this._loadIridescencePropertiesAsync(o,s,n)),[4,Promise.all(r).then(function(){})];case 1:return[2,a.sent()]}})})})},e.prototype._loadIridescencePropertiesAsync=function(e,t,n){var r,o,a,i,s,l=this._loader._getOrCreateMaterialAdapter(n),u=new Array;return l.thinFilmWeight=null!==(r=t.iridescenceFactor)&&void 0!==r?r:0,l.thinFilmIor=null!==(a=null!==(o=t.iridescenceIor)&&void 0!==o?o:t.iridescenceIOR)&&void 0!==a?a:1.3,l.thinFilmThicknessMinimum=null!==(i=t.iridescenceThicknessMinimum)&&void 0!==i?i:100,l.thinFilmThicknessMaximum=null!==(s=t.iridescenceThicknessMaximum)&&void 0!==s?s:400,t.iridescenceTexture&&u.push(this._loader.loadTextureInfoAsync("".concat(e,"/iridescenceTexture"),t.iridescenceTexture,function(e){e.name="".concat(n.name," (Iridescence)"),l.thinFilmWeightTexture=e})),t.iridescenceThicknessTexture&&u.push(this._loader.loadTextureInfoAsync("".concat(e,"/iridescenceThicknessTexture"),t.iridescenceThicknessTexture,function(e){e.name="".concat(n.name," (Iridescence Thickness)"),l.thinFilmThicknessTexture=e})),Promise.all(u).then(function(){})},e}();K(ve),H(ve,!0,function(e){return new Te(e)});var xe="KHR_materials_anisotropy",Ae=function(){function e(e){this.name=xe,this.order=195,this._loader=e,this.enabled=this._loader.isExtensionUsed(xe)}return e.prototype.dispose=function(){this._loader=null},e.prototype.loadMaterialPropertiesAsync=function(e,t,n){var r=this;return q.LoadExtensionAsync(e,t,this.name,function(o,s){return a(r,void 0,void 0,function(){var r;return i(this,function(a){switch(a.label){case 0:return(r=new Array).push(this._loader.loadMaterialPropertiesAsync(e,t,n)),r.push(this._loadAnisotropyPropertiesAsync(o,s,n)),[4,Promise.all(r)];case 1:return a.sent(),[2]}})})})},e.prototype._loadAnisotropyPropertiesAsync=function(e,t,n){return a(this,void 0,void 0,function(){var r,o,a,s,l,u,c,f;return i(this,function(i){switch(i.label){case 0:return r=this._loader._getOrCreateMaterialAdapter(n),o=new Array,a=null!==(u=t.anisotropyStrength)&&void 0!==u?u:0,s=null!==(c=t.anisotropyRotation)&&void 0!==c?c:0,r.specularRoughnessAnisotropy=a,r.geometryTangentAngle=s,(l=null!==(f=t.extensions)&&void 0!==f?f:{}).EXT_materials_anisotropy_openpbr&&l.EXT_materials_anisotropy_openpbr.openPbrAnisotropyEnabled||r.configureGltfStyleAnisotropy(!0),t.anisotropyTexture&&(t.anisotropyTexture.nonColorData=!0,o.push(this._loader.loadTextureInfoAsync("".concat(e,"/anisotropyTexture"),t.anisotropyTexture,function(e){e.name="".concat(n.name," (Anisotropy Intensity)"),r.geometryTangentTexture=e}))),[4,Promise.all(o)];case 1:return i.sent(),[2]}})})},e}();K(xe),H(xe,!0,function(e){return new Ae(e)});var Ce="KHR_materials_emissive_strength",we=function(){function e(e){this.name=Ce,this.order=170,this._loader=e,this.enabled=this._loader.isExtensionUsed(Ce)}return e.prototype.dispose=function(){this._loader=null},e.prototype.loadMaterialPropertiesAsync=function(e,t,n){var r=this;return q.LoadExtensionAsync(e,t,this.name,function(o,s){return a(r,void 0,void 0,function(){return i(this,function(r){switch(r.label){case 0:return[4,this._loader.loadMaterialPropertiesAsync(e,t,n)];case 1:return r.sent(),this._loadEmissiveProperties(o,s,n),[4,Promise.resolve()];case 2:return[2,r.sent()]}})})})},e.prototype._loadEmissiveProperties=function(e,t,n){void 0!==t.emissiveStrength&&(this._loader._getOrCreateMaterialAdapter(n).emissionLuminance=t.emissiveStrength)},e}();K(Ce),H(Ce,!0,function(e){return new we(e)});var Oe="KHR_materials_sheen",Me=function(){function e(e){this.name=Oe,this.order=190,this._loader=e,this.enabled=this._loader.isExtensionUsed(Oe)}return e.prototype.dispose=function(){this._loader=null},e.prototype.loadMaterialPropertiesAsync=function(e,t,n){var r=this;return q.LoadExtensionAsync(e,t,this.name,function(o,s){return a(r,void 0,void 0,function(){var r;return i(this,function(a){switch(a.label){case 0:return(r=new Array).push(this._loader.loadMaterialPropertiesAsync(e,t,n)),r.push(this._loadSheenPropertiesAsync(o,s,n)),[4,Promise.all(r).then(function(){})];case 1:return[2,a.sent()]}})})})},e.prototype._loadSheenPropertiesAsync=function(e,n,r){var o=this._loader._getOrCreateMaterialAdapter(r),a=new Array;o.configureFuzz();var i=void 0!==n.sheenColorFactor?t.Color3.FromArray(n.sheenColorFactor):t.Color3.Black(),s=void 0!==n.sheenRoughnessFactor?n.sheenRoughnessFactor:0;return o.fuzzWeight=1,o.fuzzColor=i,o.fuzzRoughness=s,n.sheenColorTexture&&a.push(this._loader.loadTextureInfoAsync("".concat(e,"/sheenColorTexture"),n.sheenColorTexture,function(e){e.name="".concat(r.name," (Sheen Color)"),o.fuzzColorTexture=e})),n.sheenRoughnessTexture&&(n.sheenRoughnessTexture.nonColorData=!0,a.push(this._loader.loadTextureInfoAsync("".concat(e,"/sheenRoughnessTexture"),n.sheenRoughnessTexture,function(e){e.name="".concat(r.name," (Sheen Roughness)"),o.fuzzRoughnessTexture=e}))),Promise.all(a).then(function(){})},e}();K(Oe),H(Oe,!0,function(e){return new Me(e)});var Re="KHR_materials_fuzz",Pe=function(){function e(e){this.name=Re,this.order=190,this._loader=e,this.enabled=this._loader.isExtensionUsed(Re)}return e.prototype.dispose=function(){this._loader=null},e.prototype.loadMaterialPropertiesAsync=function(e,t,n){var r=this;return q.LoadExtensionAsync(e,t,this.name,function(o,s){return a(r,void 0,void 0,function(){var r;return i(this,function(a){switch(a.label){case 0:return(r=new Array).push(this._loader.loadMaterialPropertiesAsync(e,t,n)),r.push(this._loadFuzzPropertiesAsync(o,s,n)),[4,Promise.all(r).then(function(){})];case 1:return[2,a.sent()]}})})})},e.prototype._loadFuzzPropertiesAsync=function(e,n,r){var o=this._loader._getOrCreateMaterialAdapter(r),a=new Array;return o.configureFuzz(),o.fuzzWeight=void 0!==n.fuzzFactor?n.fuzzFactor:0,o.fuzzColor=void 0!==n.fuzzColorFactor?t.Color3.FromArray(n.fuzzColorFactor):t.Color3.White(),o.fuzzRoughness=void 0!==n.fuzzRoughnessFactor?n.fuzzRoughnessFactor:.5,n.fuzzTexture&&a.push(this._loader.loadTextureInfoAsync("".concat(e,"/fuzzTexture"),n.fuzzTexture,function(e){e.name="".concat(r.name," (Fuzz)"),o.fuzzWeightTexture=e})),n.fuzzColorTexture&&a.push(this._loader.loadTextureInfoAsync("".concat(e,"/fuzzColorTexture"),n.fuzzColorTexture,function(e){e.name="".concat(r.name," (Fuzz Color)"),o.fuzzColorTexture=e})),n.fuzzRoughnessTexture&&(n.fuzzRoughnessTexture.nonColorData=!0,a.push(this._loader.loadTextureInfoAsync("".concat(e,"/fuzzRoughnessTexture"),n.fuzzRoughnessTexture,function(e){e.name="".concat(r.name," (Fuzz Roughness)"),o.fuzzRoughnessTexture=e}))),Promise.all(a).then(function(){})},e}();K(Re),H(Re,!0,function(e){return new Pe(e)});var Le="KHR_materials_specular",Fe=function(){function e(e){this.name=Le,this.order=190,this._loader=e,this.enabled=this._loader.isExtensionUsed(Le)}return e.prototype.dispose=function(){this._loader=null},e.prototype.loadMaterialPropertiesAsync=function(e,t,n){var r=this;return q.LoadExtensionAsync(e,t,this.name,function(o,s){return a(r,void 0,void 0,function(){var r,a;return i(this,function(i){switch(i.label){case 0:return(r=new Array).push(this._loader.loadMaterialPropertiesAsync(e,t,n)),r.push(this._loadSpecularPropertiesAsync(o,s,n)),a=this._loader._getOrCreateMaterialAdapter(n),s.extensions&&s.extensions.EXT_materials_specular_edge_color&&s.extensions.EXT_materials_specular_edge_color.specularEdgeColorEnabled&&a.enableSpecularEdgeColor(!0),[4,Promise.all(r).then(function(){})];case 1:return[2,i.sent()]}})})})},e.prototype._loadSpecularPropertiesAsync=function(e,n,r){var o,a=this._loader._getOrCreateMaterialAdapter(r),i=new Array;return a.specularWeight=null!==(o=n.specularFactor)&&void 0!==o?o:1,a.specularColor=void 0!==n.specularColorFactor?t.Color3.FromArray(n.specularColorFactor):new t.Color3(1,1,1),n.specularTexture&&(n.specularTexture.nonColorData=!0,i.push(this._loader.loadTextureInfoAsync("".concat(e,"/specularTexture"),n.specularTexture,function(e){e.name="".concat(r.name," (Specular)"),a.specularWeightTexture=e}))),n.specularColorTexture&&i.push(this._loader.loadTextureInfoAsync("".concat(e,"/specularColorTexture"),n.specularColorTexture,function(e){e.name="".concat(r.name," (Specular Color)"),a.specularColorTexture=e})),Promise.all(i).then(function(){})},e}();K(Le),H(Le,!0,function(e){return new Fe(e)});var Ee="KHR_materials_ior",Se=function(){function e(e){this.name=Ee,this.order=180,this._loader=e,this.enabled=this._loader.isExtensionUsed(Ee)}return e.prototype.dispose=function(){this._loader=null},e.prototype.loadMaterialPropertiesAsync=function(e,t,n){var r=this;return q.LoadExtensionAsync(e,t,this.name,function(o,s){return a(r,void 0,void 0,function(){var r;return i(this,function(a){switch(a.label){case 0:return(r=new Array).push(this._loader.loadMaterialPropertiesAsync(e,t,n)),r.push(this._loadIorPropertiesAsync(o,s,n)),[4,Promise.all(r).then(function(){})];case 1:return[2,a.sent()]}})})})},e.prototype._loadIorPropertiesAsync=function(t,n,r){var o=this._loader._getOrCreateMaterialAdapter(r),a=void 0!==n.ior?n.ior:e._DEFAULT_IOR;return o.specularIor=a,Promise.resolve()},e._DEFAULT_IOR=1.5,e}();K(Ee),H(Ee,!0,function(e){return new Se(e)});var ke="KHR_materials_variants",Ie=function(){function e(e){this.name=ke,this._loader=e,this.enabled=this._loader.isExtensionUsed(ke)&&!this._loader.parent.skipMaterials}return e.prototype.dispose=function(){this._loader=null},e.GetAvailableVariants=function(e){var t=this._GetExtensionMetadata(e);return t?Object.keys(t.variants):[]},e.prototype.getAvailableVariants=function(t){return e.GetAvailableVariants(t)},e.SelectVariant=function(e,t){var n=this._GetExtensionMetadata(e);if(!n)throw new Error("Cannot select variant on a glTF mesh that does not have the ".concat(ke," extension"));var r=function(e){var t=n.variants[e];if(t)for(var r=0,o=t;r<o.length;r++){var a=o[r];a.mesh.material=a.material}};if(t instanceof Array)for(var o=0,a=t;o<a.length;o++)r(a[o]);else r(t);n.lastSelected=t},e.prototype.selectVariant=function(t,n){e.SelectVariant(t,n)},e.Reset=function(e){var t=this._GetExtensionMetadata(e);if(!t)throw new Error("Cannot reset on a glTF mesh that does not have the ".concat(ke," extension"));for(var n=0,r=t.original;n<r.length;n++){var o=r[n];o.mesh.material=o.material}t.lastSelected=null},e.prototype.reset=function(t){e.Reset(t)},e.GetLastSelectedVariant=function(e){var t=this._GetExtensionMetadata(e);if(!t)throw new Error("Cannot get the last selected variant on a glTF mesh that does not have the ".concat(ke," extension"));return t.lastSelected},e.prototype.getLastSelectedVariant=function(t){return e.GetLastSelectedVariant(t)},e._GetExtensionMetadata=function(e){var t,n;return(null===(n=null===(t=null==e?void 0:e._internalMetadata)||void 0===t?void 0:t.gltf)||void 0===n?void 0:n[ke])||null},e.prototype.onLoading=function(){var e=this._loader.gltf.extensions;if(e&&e[this.name]){var t=e[this.name];this._variants=t.variants}},e.prototype.onReady=function(){var t,n=this._loader.rootBabylonMesh;if(n){var r=this._loader.parent.extensionOptions[ke];(null==r?void 0:r.defaultVariant)&&e.SelectVariant(n,r.defaultVariant),null===(t=null==r?void 0:r.onLoaded)||void 0===t||t.call(r,{get variants(){return e.GetAvailableVariants(n)},get selectedVariant(){var t=e.GetLastSelectedVariant(n);return t?Array.isArray(t)?t[0]:t:e.GetAvailableVariants(n)[0]},set selectedVariant(t){e.SelectVariant(n,t)}})}},e.prototype._loadMeshPrimitiveAsync=function(n,r,o,s,l,u){var c=this;return q.LoadExtensionAsync(n,l,this.name,function(f,h){return a(c,void 0,void 0,function(){var a,c=this;return i(this,function(i){switch(i.label){case 0:return(a=new Array).push(this._loader._loadMeshPrimitiveAsync(n,r,o,s,l,function(r){if(u(r),r instanceof t.Mesh){var o=q._GetDrawMode(n,l.mode),i=c._loader.rootBabylonMesh,s=i?i._internalMetadata=i._internalMetadata||{}:{},p=s.gltf=s.gltf||{},d=p[ke]=p[ke]||{lastSelected:null,original:[],variants:{}};d.original.push({mesh:r,material:r.material});for(var m=function(t){var n=h.mappings[t],s=U.Get("".concat(f,"/mappings/").concat(t,"/material"),c._loader.gltf.materials,n.material);a.push(c._loader._loadMaterialAsync("#/materials/".concat(n.material),s,r,o,function(t){for(var o=function(o){var a=n.variants[o],s=U.Get("/extensions/".concat(ke,"/variants/").concat(a),c._variants,a);d.variants[s.name]=d.variants[s.name]||[],d.variants[s.name].push({mesh:r,material:t}),r.onClonedObservable.add(function(t){var n,o=t,a=o;do{if(!(a=a.parent))return;n=e._GetExtensionMetadata(a)}while(null===n);if(i&&n===e._GetExtensionMetadata(i)){for(var l in a._internalMetadata={},i._internalMetadata)a._internalMetadata[l]=i._internalMetadata[l];for(var l in a._internalMetadata.gltf=[],i._internalMetadata.gltf)a._internalMetadata.gltf[l]=i._internalMetadata.gltf[l];a._internalMetadata.gltf[ke]={lastSelected:null,original:[],variants:{}};for(var u=0,c=n.original;u<c.length;u++){var f=c[u];a._internalMetadata.gltf[ke].original.push({mesh:f.mesh,material:f.material})}for(var l in n.variants)if(Object.prototype.hasOwnProperty.call(n.variants,l)){a._internalMetadata.gltf[ke].variants[l]=[];for(var h=0,p=n.variants[l];h<p.length;h++){var d=p[h];a._internalMetadata.gltf[ke].variants[l].push({mesh:d.mesh,material:d.material})}}n=a._internalMetadata.gltf[ke]}for(var m=0,_=n.original;m<_.length;m++)(y=_[m]).mesh===r&&(y.mesh=o);for(var b=0,g=n.variants[s.name];b<g.length;b++){var y;(y=g[b]).mesh===r&&(y.mesh=o)}})},a=0;a<n.variants.length;++a)o(a)}))},_=0;_<h.mappings.length;++_)m(_)}})),[4,Promise.all(a).then(function(e){return e[0]})];case 1:return[2,i.sent()]}})})})},e}();K(ke),H(ke,!0,function(e){return new Ie(e)});var Be=function(){function e(n,r){var a=this;this._opaqueRenderTarget=null,this._opaqueMeshesCache=[],this._transparentMeshesCache=[],this._materialObservers={},this._materialImpls=[],this._adapterCache=new WeakMap,this._translucentMaterialIndices=new Map,this._opaqueOnlySubMeshes=new Map,this._savedSubMeshes=new Map,this._options=o(o({},e._GetDefaultOptions()),n),this._scene=r,this._scene._transmissionHelper=this,this.onErrorObservable=new t.Observable,this._scene.onDisposeObservable.addOnce(function(){a.dispose()}),this._parseScene(),this._setupRenderTargets()}return e._GetDefaultOptions=function(){return{renderSize:1024,samples:4,lodGenerationScale:1,lodGenerationOffset:-4,renderTargetTextureType:t.Constants.TEXTURETYPE_HALF_FLOAT,generateMipmaps:!0}},e.prototype.addMaterialImpl=function(e){this._materialImpls.some(function(t){return t.materialClass===e.materialClass})||this._materialImpls.push(e)},e.prototype.updateOptions=function(e){var t=this,n=Object.keys(e).filter(function(n){return t._options[n]!==e[n]});if(n.length){var r=o(o({},this._options),e),a=this._options;this._options=r,r.renderSize===a.renderSize&&r.renderTargetTextureType===a.renderTargetTextureType&&r.generateMipmaps===a.generateMipmaps&&this._opaqueRenderTarget?(this._opaqueRenderTarget.samples=r.samples,this._opaqueRenderTarget.lodGenerationScale=r.lodGenerationScale,this._opaqueRenderTarget.lodGenerationOffset=r.lodGenerationOffset):this._setupRenderTargets()}},e.prototype.getOpaqueTarget=function(){return this._opaqueRenderTarget},e.prototype._getOrCreateAdapter=function(e){var t=this._adapterCache.get(e);if(!t)for(var n=0,r=this._materialImpls;n<r.length;n++){var o=r[n];if(e instanceof o.materialClass){t=new o.adapterClass(e),this._adapterCache.set(e,t);break}}return t},e.prototype._classifyMeshMaterials=function(e){var n=e.material;if(!n)return"opaque";if(!(n instanceof t.MultiMaterial))return(s=this._getOrCreateAdapter(n))&&s.isTranslucent()?(s.refractionBackgroundTexture=this._opaqueRenderTarget,"transparent"):"opaque";for(var r=!1,o=!1,a=new Set,i=0;i<n.subMaterials.length;i++){var s,l=n.subMaterials[i];l&&(s=this._getOrCreateAdapter(l))&&s.isTranslucent()?(s.refractionBackgroundTexture=this._opaqueRenderTarget,r=!0,a.add(i)):o=!0}return r&&o?(this._translucentMaterialIndices.set(e,a),this._rebuildOpaqueOnlySubMeshes(e,a),"mixed"):(this._translucentMaterialIndices.delete(e),this._opaqueOnlySubMeshes.delete(e),r?"transparent":"opaque")},e.prototype._rebuildOpaqueOnlySubMeshes=function(e,t){e.subMeshes&&this._opaqueOnlySubMeshes.set(e,e.subMeshes.filter(function(e){return!t.has(e.materialIndex)}))},e.prototype._addMesh=function(e){var n=this;this._materialObservers[e.uniqueId]=e.onMaterialChangedObservable.add(this._onMeshMaterialChanged.bind(this)),t.Tools.SetImmediate(function(){e.material&&("transparent"===n._classifyMeshMaterials(e)?-1===n._transparentMeshesCache.indexOf(e)&&n._transparentMeshesCache.push(e):-1===n._opaqueMeshesCache.indexOf(e)&&n._opaqueMeshesCache.push(e))})},e.prototype._removeMesh=function(e){e.onMaterialChangedObservable.remove(this._materialObservers[e.uniqueId]),delete this._materialObservers[e.uniqueId];var t=this._transparentMeshesCache.indexOf(e);-1!==t&&this._transparentMeshesCache.splice(t,1),-1!==(t=this._opaqueMeshesCache.indexOf(e))&&this._opaqueMeshesCache.splice(t,1),this._translucentMaterialIndices.delete(e),this._opaqueOnlySubMeshes.delete(e)},e.prototype._parseScene=function(){this._scene.meshes.forEach(this._addMesh.bind(this)),this._scene.onNewMeshAddedObservable.add(this._addMesh.bind(this)),this._scene.onMeshRemovedObservable.add(this._removeMesh.bind(this))},e.prototype._onMeshMaterialChanged=function(e){var t=this._transparentMeshesCache.indexOf(e),n=this._opaqueMeshesCache.indexOf(e);"transparent"===this._classifyMeshMaterials(e)?-1!==n?(this._opaqueMeshesCache.splice(n,1),this._transparentMeshesCache.push(e)):-1===t&&this._transparentMeshesCache.push(e):-1!==t?(this._transparentMeshesCache.splice(t,1),this._opaqueMeshesCache.push(e)):-1===n&&this._opaqueMeshesCache.push(e)},e.prototype._isRenderTargetValid=function(){var e;return null!==(null===(e=this._opaqueRenderTarget)||void 0===e?void 0:e.getInternalTexture())},e.prototype._setupRenderTargets=function(){var e,n,r,o=this;this._opaqueRenderTarget&&this._opaqueRenderTarget.dispose(),this._opaqueRenderTarget=new t.RenderTargetTexture("opaqueSceneTexture",this._options.renderSize,this._scene,this._options.generateMipmaps,void 0,this._options.renderTargetTextureType),this._opaqueRenderTarget.ignoreCameraViewport=!0,this._opaqueRenderTarget.renderList=this._opaqueMeshesCache,this._opaqueRenderTarget.clearColor=null!==(n=null===(e=this._options.clearColor)||void 0===e?void 0:e.clone())&&void 0!==n?n:this._scene.clearColor.clone(),this._opaqueRenderTarget.clearColor.a=0,this._opaqueRenderTarget.gammaSpace=!1,this._opaqueRenderTarget.lodGenerationScale=this._options.lodGenerationScale,this._opaqueRenderTarget.lodGenerationOffset=this._options.lodGenerationOffset,this._opaqueRenderTarget.samples=this._options.samples,this._opaqueRenderTarget.renderSprites=!0,this._opaqueRenderTarget.renderParticles=!0,this._opaqueRenderTarget.disableImageProcessing=!0,this._opaqueRenderTarget.onBeforeBindObservable.add(function(e){r=o._scene.environmentIntensity,o._scene.environmentIntensity=1,o._options.clearColor?e.clearColor.copyFrom(o._options.clearColor):o._scene.clearColor.toLinearSpaceToRef(e.clearColor,o._scene.getEngine().useExactSrgbConversions),e.clearColor.a=0;for(var t=o._opaqueOnlySubMeshes.entries(),n=t.next();!n.done;n=t.next()){var a=n.value[0],i=n.value[1];a.subMeshes&&(o._savedSubMeshes.set(a,a.subMeshes),a.subMeshes=i)}}),this._opaqueRenderTarget.onAfterUnbindObservable.add(function(){o._scene.environmentIntensity=r;for(var e=o._savedSubMeshes.entries(),t=e.next();!t.done;t=e.next())t.value[0].subMeshes=t.value[1];o._savedSubMeshes.clear()});for(var a=0,i=this._transparentMeshesCache;a<i.length;a++)(u=i[a]).material&&this._classifyMeshMaterials(u);for(var s=this._translucentMaterialIndices.entries(),l=s.next();!l.done;l=s.next()){var u;(u=l.value[0]).material&&this._classifyMeshMaterials(u)}},e.prototype.dispose=function(){this._scene._transmissionHelper=void 0,this._opaqueRenderTarget&&(this._opaqueRenderTarget.dispose(),this._opaqueRenderTarget=null),this._transparentMeshesCache=[],this._opaqueMeshesCache=[],this._translucentMaterialIndices.clear(),this._opaqueOnlySubMeshes.clear(),this._savedSubMeshes.clear()},e}();function Ne(e,t){if(!e.parent.dontUseTransmissionHelper){for(var n=t.getScene()._transmissionHelper,r=null!=n?n:new Be({},t.getScene()),o=0,a=Array.from(e._pbrMaterialImpls.values());o<a.length;o++){var i=a[o];r.addMaterialImpl(i)}n&&!n._isRenderTargetValid()&&n._setupRenderTargets()}}var Ge="KHR_materials_transmission",De=function(){function e(e){this.name=Ge,this.order=175,this._loader=e,this.enabled=this._loader.isExtensionUsed(Ge),this.enabled&&(e.parent.transparencyAsCoverage=!0)}return e.prototype.dispose=function(){this._loader=null},e.prototype.loadMaterialPropertiesAsync=function(e,t,n){var r=this;return q.LoadExtensionAsync(e,t,this.name,function(o,s){return a(r,void 0,void 0,function(){var r;return i(this,function(a){switch(a.label){case 0:return(r=new Array).push(this._loader.loadMaterialPropertiesAsync(e,t,n)),r.push(this._loadTransparentPropertiesAsync(o,t,n,s)),[4,Promise.all(r).then(function(){})];case 1:return[2,a.sent()]}})})})},e.prototype._loadTransparentPropertiesAsync=function(e,t,n,r){var o=this._loader._getOrCreateMaterialAdapter(n),a=void 0!==r.transmissionFactor?r.transmissionFactor:0;if(0===a||!o)return Promise.resolve();o.configureTransmission(),o.transmissionWeight=a,a>0&&Ne(this._loader,n);var i=Promise.resolve(null);return r.transmissionTexture&&(r.transmissionTexture.nonColorData=!0,i=this._loader.loadTextureInfoAsync("".concat(e,"/transmissionTexture"),r.transmissionTexture,function(e){e.name="".concat(n.name," (Transmission)"),o.transmissionWeightTexture=e})),i.then(function(){})},e}();K(Ge),H(Ge,!0,function(e){return new De(e)});var Ve="KHR_materials_diffuse_transmission",He=function(){function e(e){this.name=Ve,this.order=174,this._loader=e,this.enabled=this._loader.isExtensionUsed(Ve),this.enabled&&(e.parent.transparencyAsCoverage=!0)}return e.prototype.dispose=function(){this._loader=null},e.prototype.loadMaterialPropertiesAsync=function(e,t,n){var r=this;return q.LoadExtensionAsync(e,t,this.name,function(o,s){return a(r,void 0,void 0,function(){var r;return i(this,function(a){switch(a.label){case 0:return(r=new Array).push(this._loader.loadMaterialPropertiesAsync(e,t,n)),r.push(this._loadTranslucentPropertiesAsync(o,t,n,s)),[4,Promise.all(r).then(function(){})];case 1:return[2,a.sent()]}})})})},e.prototype._loadTranslucentPropertiesAsync=function(e,n,r,o){var a,i=this._loader._getOrCreateMaterialAdapter(r);i.configureSubsurface(),i.subsurfaceWeight=null!==(a=o.diffuseTransmissionFactor)&&void 0!==a?a:0,i.subsurfaceWeight>0&&Ne(this._loader,r),i.diffuseTransmissionTint=void 0!==o.diffuseTransmissionColorFactor?t.Color3.FromArray(o.diffuseTransmissionColorFactor):t.Color3.White();var s=new Array;return o.diffuseTransmissionTexture&&(o.diffuseTransmissionTexture.nonColorData=!0,s.push(this._loader.loadTextureInfoAsync("".concat(e,"/diffuseTransmissionTexture"),o.diffuseTransmissionTexture).then(function(e){e.name="".concat(r.name," (Diffuse Transmission)"),i.subsurfaceWeightTexture=e}))),o.diffuseTransmissionColorTexture&&s.push(this._loader.loadTextureInfoAsync("".concat(e,"/diffuseTransmissionColorTexture"),o.diffuseTransmissionColorTexture).then(function(e){e.name="".concat(r.name," (Diffuse Transmission Color)"),i.diffuseTransmissionTintTexture=e})),Promise.all(s).then(function(){})},e}();K(Ve),H(Ve,!0,function(e){return new He(e)});var Ke="KHR_materials_volume",je=function(){function e(e){this.name=Ke,this.order=173,this._loader=e,this.enabled=this._loader.isExtensionUsed(Ke),this.enabled&&this._loader._disableInstancedMesh++}return e.prototype.dispose=function(){this.enabled&&this._loader._disableInstancedMesh--,this._loader=null},e.prototype.loadMaterialPropertiesAsync=function(e,t,n){var r=this;return q.LoadExtensionAsync(e,t,this.name,function(o,s){return a(r,void 0,void 0,function(){var r;return i(this,function(a){switch(a.label){case 0:return(r=new Array).push(this._loader.loadMaterialPropertiesAsync(e,t,n)),r.push(this._loadVolumePropertiesAsync(o,t,n,s)),[4,Promise.all(r).then(function(){})];case 1:return[2,a.sent()]}})})})},e.prototype._loadVolumePropertiesAsync=function(e,n,r,o){var a,i=this._loader._getOrCreateMaterialAdapter(r);if(0===i.transmissionWeight&&0===i.subsurfaceWeight||!o.thicknessFactor)return Promise.resolve();i.geometryThinWalled=!1;var s=void 0!==o.attenuationDistance?o.attenuationDistance:Number.MAX_VALUE,l=void 0!==o.attenuationColor&&3==o.attenuationColor.length?t.Color3.FromArray(o.attenuationColor):t.Color3.White();i.configureVolume(),i.transmissionColor=l,i.transmissionDepth=s,i.volumeThickness=null!==(a=o.thicknessFactor)&&void 0!==a?a:0;var u=new Array;return o.thicknessTexture&&(o.thicknessTexture.nonColorData=!0,u.push(this._loader.loadTextureInfoAsync("".concat(e,"/thicknessTexture"),o.thicknessTexture,function(e){e.name="".concat(r.name," (Thickness)"),i.volumeThicknessTexture=e}))),Promise.all(u).then(function(){})},e}();K(Ke),H(Ke,!0,function(e){return new je(e)});var We="KHR_materials_volume_scatter",Ue=function(){function e(e){this.name=We,this.order=172,this._loader=e,this.enabled=this._loader.isExtensionUsed(We),this.enabled&&this._loader._disableInstancedMesh++}return e.prototype.dispose=function(){this.enabled&&this._loader._disableInstancedMesh--,this._loader=null},e.prototype.loadMaterialPropertiesAsync=function(e,t,n){var r=this;return q.LoadExtensionAsync(e,t,this.name,function(o,s){return a(r,void 0,void 0,function(){var r;return i(this,function(a){switch(a.label){case 0:return(r=new Array).push(this._loader.loadMaterialPropertiesAsync(e,t,n)),r.push(this._loadVolumePropertiesAsync(o,t,n,s)),[4,Promise.all(r).then(function(){})];case 1:return[2,a.sent()]}})})})},e.prototype._loadVolumePropertiesAsync=function(e,n,r,o){var a=this._loader._getOrCreateMaterialAdapter(r);if(0===a.transmissionWeight&&0===a.subsurfaceWeight||a.geometryThinWalled)return Promise.resolve();var i=void 0!==o.multiscatterColorFactor&&3==o.multiscatterColorFactor.length?t.Color3.FromArray(o.multiscatterColorFactor):t.Color3.Black(),s=void 0!==o.scatterAnisotropy?o.scatterAnisotropy:0,l=Promise.resolve(null);o.multiscatterColorTexture&&(o.multiscatterColorTexture.nonColorData=!0,l=this._loader.loadTextureInfoAsync("".concat(e,"/multiscatterColorTexture"),o.multiscatterColorTexture,function(e){e.name="".concat(r.name," (Scatter Color)"),a.transmissionWeight>0&&(a.transmissionScatterTexture=e),a.subsurfaceWeight>0&&(a.subsurfaceColorTexture=e)}));var u=new t.Vector3(-Math.log(a.transmissionColor.r),-Math.log(a.transmissionColor.g),-Math.log(a.transmissionColor.b));if(u.scaleInPlace(1/Math.max(a.transmissionDepth,1e-6)),a.transmissionWeight>0){var c=function(e){var n=new t.Vector3(e.r,e.g,e.b),r=new t.Vector3(4.09712,4.09712,4.09712);r.addInPlace(new t.Vector3(4.20863,4.20863,4.20863).multiplyInPlace(n));var o=new t.Vector3(9.59217,9.59217,9.59217);return o.addInPlace(new t.Vector3(41.6808,41.6808,41.6808).multiplyInPlace(n)),o.addInPlace(new t.Vector3(17.7126,17.7126,17.7126).multiplyInPlace(n.multiply(n))),r.subtractInPlace(new t.Vector3(Math.sqrt(o.x),Math.sqrt(o.y),Math.sqrt(o.z))),new t.Vector3(1,1,1).subtract(r.multiply(r))}(i),f=u.multiply(c);f.scaleInPlace(a.transmissionDepth),a.transmissionScatter.set(f.x,f.y,f.z),a.transmissionScatterAnisotropy=s}if(a.subsurfaceWeight>0){a.subsurfaceScatterAnisotropy=s,a.subsurfaceColor=i;var h=new t.Vector3(0!==u.x?1/u.x:1,0!==u.y?1/u.y:1,0!==u.z?1/u.z:1);a.subsurfaceRadius=Math.max(h.x,h.y,h.z),a.subsurfaceRadiusScale=new t.Color3(h.x/a.subsurfaceRadius,h.y/a.subsurfaceRadius,h.z/a.subsurfaceRadius)}return l.then(function(){})},e}();K(We),H(We,!0,function(e){return new Ue(e)});var ze="KHR_materials_dispersion",qe=function(){function e(e){this.name=ze,this.order=174,this._loader=e,this.enabled=this._loader.isExtensionUsed(ze)}return e.prototype.dispose=function(){this._loader=null},e.prototype.loadMaterialPropertiesAsync=function(e,t,n){var r=this;return q.LoadExtensionAsync(e,t,this.name,function(o,s){return a(r,void 0,void 0,function(){var r;return i(this,function(a){switch(a.label){case 0:return(r=new Array).push(this._loader.loadMaterialPropertiesAsync(e,t,n)),r.push(this._loadDispersionPropertiesAsync(o,t,n,s)),[4,Promise.all(r).then(function(){})];case 1:return[2,a.sent()]}})})})},e.prototype._loadDispersionPropertiesAsync=function(e,t,n,r){var o=this._loader._getOrCreateMaterialAdapter(n);return 0!=o.transmissionWeight&&r.dispersion?(o.transmissionDispersionAbbeNumber=20,o.transmissionDispersionScale=r.dispersion,Promise.resolve()):Promise.resolve()},e}();K(ze),H(ze,!0,function(e){return new qe(e)});var Ye="KHR_materials_diffuse_roughness",Xe=function(){function e(e){this.name=Ye,this.order=190,this._loader=e,this.enabled=this._loader.isExtensionUsed(Ye)}return e.prototype.dispose=function(){this._loader=null},e.prototype.loadMaterialPropertiesAsync=function(e,t,n){var r=this;return q.LoadExtensionAsync(e,t,this.name,function(o,s){return a(r,void 0,void 0,function(){var r;return i(this,function(a){switch(a.label){case 0:return(r=new Array).push(this._loader.loadMaterialPropertiesAsync(e,t,n)),r.push(this._loadDiffuseRoughnessPropertiesAsync(o,s,n)),[4,Promise.all(r).then(function(){})];case 1:return[2,a.sent()]}})})})},e.prototype._loadDiffuseRoughnessPropertiesAsync=function(e,t,n){var r,o=this._loader._getOrCreateMaterialAdapter(n),a=new Array;return o.baseDiffuseRoughness=null!==(r=t.diffuseRoughnessFactor)&&void 0!==r?r:0,t.diffuseRoughnessTexture&&a.push(this._loader.loadTextureInfoAsync("".concat(e,"/diffuseRoughnessTexture"),t.diffuseRoughnessTexture,function(e){e.name="".concat(n.name," (Diffuse Roughness)"),o.baseDiffuseRoughnessTexture=e})),Promise.all(a).then(function(){})},e}();K(Ye),H(Ye,!0,function(e){return new Xe(e)});var Qe="KHR_mesh_quantization",Je=function(){function e(e){this.name=Qe,this.enabled=e.isExtensionUsed(Qe)}return e.prototype.dispose=function(){},e}();K(Qe),H(Qe,!0,function(e){return new Je(e)});var Ze="KHR_texture_basisu",$e=function(){function e(e){this.name=Ze,this._loader=e,this.enabled=e.isExtensionUsed(Ze)}return e.prototype.dispose=function(){this._loader=null},e.prototype._loadTextureAsync=function(e,t,n){var r=this;return q.LoadExtensionAsync(e,t,this.name,function(o,s){return a(r,void 0,void 0,function(){var r,a;return i(this,function(i){switch(i.label){case 0:return r=null==t.sampler?q.DefaultSampler:U.Get("".concat(e,"/sampler"),this._loader.gltf.samplers,t.sampler),a=U.Get("".concat(o,"/source"),this._loader.gltf.images,s.source),[4,this._loader._createTextureAsync(e,r,a,function(e){n(e)},t._textureInfo.nonColorData?{useRGBAIfASTCBC7NotAvailableWhenUASTC:!0}:void 0,!t._textureInfo.nonColorData)];case 1:return[2,i.sent()]}})})})},e}();K(Ze),H(Ze,!0,function(e){return new $e(e)});var et="KHR_texture_transform",tt=function(){function e(e){this.name=et,this._loader=e,this.enabled=this._loader.isExtensionUsed(et)}return e.prototype.dispose=function(){this._loader=null},e.prototype.loadTextureInfoAsync=function(e,n,r){var o=this;return q.LoadExtensionAsync(e,n,this.name,function(s,l){return a(o,void 0,void 0,function(){return i(this,function(o){switch(o.label){case 0:return[4,this._loader.loadTextureInfoAsync(e,n,function(e){if(!(e instanceof t.Texture))throw new Error("".concat(s,": Texture type not supported"));l.offset&&(e.uOffset=l.offset[0],e.vOffset=l.offset[1]),e.uRotationCenter=0,e.vRotationCenter=0,l.rotation&&(e.wAng=-l.rotation),l.scale&&(e.uScale=l.scale[0],e.vScale=l.scale[1]),null!=l.texCoord&&(e.coordinatesIndex=l.texCoord),r(e)})];case 1:return[2,o.sent()]}})})})},e}();K(et),H(et,!0,function(e){return new tt(e)});var nt="KHR_xmp_json_ld",rt=function(){function e(e){this.name=nt,this.order=100,this._loader=e,this.enabled=this._loader.isExtensionUsed(nt)}return e.prototype.dispose=function(){this._loader=null},e.prototype.onLoading=function(){var e,t,n;if(null!==this._loader.rootBabylonMesh){var r=null===(e=this._loader.gltf.extensions)||void 0===e?void 0:e.KHR_xmp_json_ld,o=null===(n=null===(t=this._loader.gltf.asset)||void 0===t?void 0:t.extensions)||void 0===n?void 0:n.KHR_xmp_json_ld;if(r&&o){var a=+o.packet;r.packets&&a<r.packets.length&&(this._loader.rootBabylonMesh.metadata=this._loader.rootBabylonMesh.metadata||{},this._loader.rootBabylonMesh.metadata.xmp=r.packets[a])}}},e}();function ot(e,n,r,o){return t.Vector3.FromArray(n,r).scaleInPlace(o)}function at(e,n,r,o){return t.Quaternion.FromArray(n,r).scaleInPlace(o)}function it(e,t,n,r){for(var o=new Array(e._numMorphTargets),a=0;a<o.length;a++)o[a]=t[n++]*r;return o}K(nt),H(nt,!0,function(e){return new rt(e)});var st=function(){function e(e,t,n,r){this.type=e,this.name=t,this.getValue=n,this.getStride=r}return e.prototype._buildAnimation=function(e,n,r){var o=new t.Animation(e,this.name,n,this.type);return o.setKeys(r,!0),o},e}(),lt=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return r(t,e),t.prototype.buildAnimations=function(e,t,n,r){var o=[];return o.push({babylonAnimatable:e._babylonTransformNode,babylonAnimation:this._buildAnimation(t,n,r)}),o},t}(st),ut=function(e){function n(){return null!==e&&e.apply(this,arguments)||this}return r(n,e),n.prototype.buildAnimations=function(e,n,r,o){var a=[];if(e._numMorphTargets)for(var i=function(i){var l=new t.Animation("".concat(n,"_").concat(i),s.name,r,s.type);if(l.setKeys(o.map(function(e){return{frame:e.frame,inTangent:e.inTangent?e.inTangent[i]:void 0,value:e.value[i],outTangent:e.outTangent?e.outTangent[i]:void 0,interpolation:e.interpolation}}),!0),e._primitiveBabylonMeshes)for(var u=0,c=e._primitiveBabylonMeshes;u<c.length;u++){var f=c[u];if(f.morphTargetManager){var h=f.morphTargetManager.getTarget(i),p=l.clone();h.animations.push(p),a.push({babylonAnimatable:h,babylonAnimation:p})}}},s=this,l=0;l<e._numMorphTargets;l++)i(l);return a},n}(st);N("/nodes/{}/translation",[new lt(t.Animation.ANIMATIONTYPE_VECTOR3,"position",ot,function(){return 3})]),N("/nodes/{}/rotation",[new lt(t.Animation.ANIMATIONTYPE_QUATERNION,"rotationQuaternion",at,function(){return 4})]),N("/nodes/{}/scale",[new lt(t.Animation.ANIMATIONTYPE_VECTOR3,"scaling",ot,function(){return 3})]),N("/nodes/{}/weights",[new ut(t.Animation.ANIMATIONTYPE_FLOAT,"influence",it,function(e){return e._numMorphTargets})]);var ct={__proto__:null,AnimationPropertyInfo:st,TransformNodeAnimationPropertyInfo:lt,WeightAnimationPropertyInfo:ut,getQuaternion:at,getVector3:ot,getWeights:it};function ft(e,n,r,o){return t.Color3.FromArray(n,r).scale(o)}function ht(e,t,n,r){return t[n]*r}function pt(e,t,n,r){return-t[n]*r}function dt(e,t,n,r){return t[n+1]*r}function mt(e,t,n,r){return t[n]*r*2}function _t(e){return{scale:[new gt(t.Animation.ANIMATIONTYPE_FLOAT,"".concat(e,".uScale"),ht,function(){return 2}),new gt(t.Animation.ANIMATIONTYPE_FLOAT,"".concat(e,".vScale"),dt,function(){return 2})],offset:[new gt(t.Animation.ANIMATIONTYPE_FLOAT,"".concat(e,".uOffset"),ht,function(){return 2}),new gt(t.Animation.ANIMATIONTYPE_FLOAT,"".concat(e,".vOffset"),dt,function(){return 2})],rotation:[new gt(t.Animation.ANIMATIONTYPE_FLOAT,"".concat(e,".wAng"),pt,function(){return 1})]}}var bt=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return r(t,e),t.prototype.buildAnimations=function(e,t,n,r){return[{babylonAnimatable:e._babylonCamera,babylonAnimation:this._buildAnimation(t,n,r)}]},t}(st),gt=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return r(t,e),t.prototype.buildAnimations=function(e,t,n,r){var o=[];for(var a in e._data)o.push({babylonAnimatable:e._data[a].babylonMaterial,babylonAnimation:this._buildAnimation(t,n,r)});return o},t}(st),yt=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return r(t,e),t.prototype.buildAnimations=function(e,t,n,r){return[{babylonAnimatable:e._babylonLight,babylonAnimation:this._buildAnimation(t,n,r)}]},t}(st),vt=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return r(t,e),t.prototype.buildAnimations=function(e,t,n,r){var o=this;return e._primitiveBabylonMeshes?e._primitiveBabylonMeshes.map(function(e){return{babylonAnimatable:e,babylonAnimation:o._buildAnimation(t,n,r)}}):[]},t}(st);N("/cameras/{}/orthographic/xmag",[new bt(t.Animation.ANIMATIONTYPE_FLOAT,"orthoLeft",pt,function(){return 1}),new bt(t.Animation.ANIMATIONTYPE_FLOAT,"orthoRight",dt,function(){return 1})]),N("/cameras/{}/orthographic/ymag",[new bt(t.Animation.ANIMATIONTYPE_FLOAT,"orthoBottom",pt,function(){return 1}),new bt(t.Animation.ANIMATIONTYPE_FLOAT,"orthoTop",dt,function(){return 1})]),N("/cameras/{}/orthographic/zfar",[new bt(t.Animation.ANIMATIONTYPE_FLOAT,"maxZ",ht,function(){return 1})]),N("/cameras/{}/orthographic/znear",[new bt(t.Animation.ANIMATIONTYPE_FLOAT,"minZ",ht,function(){return 1})]),N("/cameras/{}/perspective/yfov",[new bt(t.Animation.ANIMATIONTYPE_FLOAT,"fov",ht,function(){return 1})]),N("/cameras/{}/perspective/zfar",[new bt(t.Animation.ANIMATIONTYPE_FLOAT,"maxZ",ht,function(){return 1})]),N("/cameras/{}/perspective/znear",[new bt(t.Animation.ANIMATIONTYPE_FLOAT,"minZ",ht,function(){return 1})]),N("/materials/{}/pbrMetallicRoughness/baseColorFactor",[new gt(t.Animation.ANIMATIONTYPE_COLOR3,"albedoColor",ft,function(){return 4}),new gt(t.Animation.ANIMATIONTYPE_FLOAT,"alpha",function(e,t,n,r){return t[n+3]*r},function(){return 4})]),N("/materials/{}/pbrMetallicRoughness/metallicFactor",[new gt(t.Animation.ANIMATIONTYPE_FLOAT,"metallic",ht,function(){return 1})]),N("/materials/{}/pbrMetallicRoughness/metallicFactor",[new gt(t.Animation.ANIMATIONTYPE_FLOAT,"roughness",ht,function(){return 1})]);var Tt=_t("albedoTexture");N("/materials/{}/pbrMetallicRoughness/baseColorTexture/extensions/KHR_texture_transform/scale",Tt.scale),N("/materials/{}/pbrMetallicRoughness/baseColorTexture/extensions/KHR_texture_transform/offset",Tt.offset),N("/materials/{}/pbrMetallicRoughness/baseColorTexture/extensions/KHR_texture_transform/rotation",Tt.rotation);var xt=_t("metallicTexture");N("//materials/{}/pbrMetallicRoughness/metallicRoughnessTexture/scale",xt.scale),N("//materials/{}/pbrMetallicRoughness/metallicRoughnessTexture/offset",xt.offset),N("//materials/{}/pbrMetallicRoughness/metallicRoughnessTexture/rotation",xt.rotation),N("/materials/{}/emissiveFactor",[new gt(t.Animation.ANIMATIONTYPE_COLOR3,"emissiveColor",ft,function(){return 3})]);var At=_t("bumpTexture");N("/materials/{}/normalTexture/scale",[new gt(t.Animation.ANIMATIONTYPE_FLOAT,"bumpTexture.level",ht,function(){return 1})]),N("/materials/{}/normalTexture/extensions/KHR_texture_transform/scale",At.scale),N("/materials/{}/normalTexture/extensions/KHR_texture_transform/offset",At.offset),N("/materials/{}/normalTexture/extensions/KHR_texture_transform/rotation",At.rotation),N("/materials/{}/occlusionTexture/strength",[new gt(t.Animation.ANIMATIONTYPE_FLOAT,"ambientTextureStrength",ht,function(){return 1})]);var Ct=_t("ambientTexture");N("/materials/{}/occlusionTexture/extensions/KHR_texture_transform/scale",Ct.scale),N("/materials/{}/occlusionTexture/extensions/KHR_texture_transform/offset",Ct.offset),N("/materials/{}/occlusionTexture/extensions/KHR_texture_transform/rotation",Ct.rotation);var wt=_t("emissiveTexture");N("/materials/{}/emissiveTexture/extensions/KHR_texture_transform/scale",wt.scale),N("/materials/{}/emissiveTexture/extensions/KHR_texture_transform/offset",wt.offset),N("/materials/{}/emissiveTexture/extensions/KHR_texture_transform/rotation",wt.rotation),N("/materials/{}/extensions/KHR_materials_anisotropy/anisotropyStrength",[new gt(t.Animation.ANIMATIONTYPE_FLOAT,"anisotropy.intensity",ht,function(){return 1})]),N("/materials/{}/extensions/KHR_materials_anisotropy/anisotropyRotation",[new gt(t.Animation.ANIMATIONTYPE_FLOAT,"anisotropy.angle",ht,function(){return 1})]);var Ot=_t("anisotropy.texture");N("/materials/{}/extensions/KHR_materials_anisotropy/anisotropyTexture/extensions/KHR_texture_transform/scale",Ot.scale),N("/materials/{}/extensions/KHR_materials_anisotropy/anisotropyTexture/extensions/KHR_texture_transform/offset",Ot.offset),N("/materials/{}/extensions/KHR_materials_anisotropy/anisotropyTexture/extensions/KHR_texture_transform/rotation",Ot.rotation),N("/materials/{}/extensions/KHR_materials_clearcoat/clearcoatFactor",[new gt(t.Animation.ANIMATIONTYPE_FLOAT,"clearCoat.intensity",ht,function(){return 1})]),N("/materials/{}/extensions/KHR_materials_clearcoat/clearcoatRoughnessFactor",[new gt(t.Animation.ANIMATIONTYPE_FLOAT,"clearCoat.roughness",ht,function(){return 1})]);var Mt=_t("clearCoat.texture");N("/materials/{}/extensions/KHR_materials_clearcoat/clearcoatTexture/extensions/KHR_texture_transform/scale",Mt.scale),N("/materials/{}/extensions/KHR_materials_clearcoat/clearcoatTexture/extensions/KHR_texture_transform/offset",Mt.offset),N("/materials/{}/extensions/KHR_materials_clearcoat/clearcoatTexture/extensions/KHR_texture_transform/rotation",Mt.rotation);var Rt=_t("clearCoat.bumpTexture");N("/materials/{}/extensions/KHR_materials_clearcoat/clearcoatNormalTexture/scale",[new gt(t.Animation.ANIMATIONTYPE_FLOAT,"clearCoat.bumpTexture.level",ht,function(){return 1})]),N("/materials/{}/extensions/KHR_materials_clearcoat/clearcoatNormalTexture/extensions/KHR_texture_transform/scale",Rt.scale),N("/materials/{}/extensions/KHR_materials_clearcoat/clearcoatNormalTexture/extensions/KHR_texture_transform/offset",Rt.offset),N("/materials/{}/extensions/KHR_materials_clearcoat/clearcoatNormalTexture/extensions/KHR_texture_transform/rotation",Rt.rotation);var Pt=_t("clearCoat.textureRoughness");N("/materials/{}/extensions/KHR_materials_clearcoat/clearcoatRoughnessTexture/extensions/KHR_texture_transform/scale",Pt.scale),N("/materials/{}/extensions/KHR_materials_clearcoat/clearcoatRoughnessTexture/extensions/KHR_texture_transform/offset",Pt.offset),N("/materials/{}/extensions/KHR_materials_clearcoat/clearcoatRoughnessTexture/extensions/KHR_texture_transform/rotation",Pt.rotation),N("/materials/{}/extensions/KHR_materials_dispersion/dispersionFactor",[new gt(t.Animation.ANIMATIONTYPE_FLOAT,"subSurface.dispersion",ht,function(){return 1})]),N("/materials/{}/extensions/KHR_materials_emissive_strength/emissiveStrength",[new gt(t.Animation.ANIMATIONTYPE_FLOAT,"emissiveIntensity",ht,function(){return 1})]),N("/materials/{}/extensions/KHR_materials_ior/ior",[new gt(t.Animation.ANIMATIONTYPE_FLOAT,"indexOfRefraction",ht,function(){return 1})]),N("/materials/{}/extensions/KHR_materials_iridescence/iridescenceFactor",[new gt(t.Animation.ANIMATIONTYPE_FLOAT,"iridescence.intensity",ht,function(){return 1})]),N("/materials/{}/extensions/KHR_materials_iridescence/iridescenceIor",[new gt(t.Animation.ANIMATIONTYPE_FLOAT,"iridescence.indexOfRefraction",ht,function(){return 1})]),N("/materials/{}/extensions/KHR_materials_iridescence/iridescenceThicknessMinimum",[new gt(t.Animation.ANIMATIONTYPE_FLOAT,"iridescence.minimumThickness",ht,function(){return 1})]),N("/materials/{}/extensions/KHR_materials_iridescence/iridescenceThicknessMaximum",[new gt(t.Animation.ANIMATIONTYPE_FLOAT,"iridescence.maximumThickness",ht,function(){return 1})]);var Lt=_t("iridescence.texture");N("/materials/{}/extensions/KHR_materials_iridescence/iridescenceTexture/extensions/KHR_texture_transform/scale",Lt.scale),N("/materials/{}/extensions/KHR_materials_iridescence/iridescenceTexture/extensions/KHR_texture_transform/offset",Lt.offset),N("/materials/{}/extensions/KHR_materials_iridescence/iridescenceTexture/extensions/KHR_texture_transform/rotation",Lt.rotation);var Ft=_t("iridescence.thicknessTexture");N("/materials/{}/extensions/KHR_materials_iridescence/iridescenceThicknessTexture/extensions/KHR_texture_transform/scale",Ft.scale),N("/materials/{}/extensions/KHR_materials_iridescence/iridescenceThicknessTexture/extensions/KHR_texture_transform/offset",Ft.offset),N("/materials/{}/extensions/KHR_materials_iridescence/iridescenceThicknessTexture/extensions/KHR_texture_transform/rotation",Ft.rotation),N("/materials/{}/extensions/KHR_materials_sheen/sheenColorFactor",[new gt(t.Animation.ANIMATIONTYPE_COLOR3,"sheen.color",ft,function(){return 3})]),N("/materials/{}/extensions/KHR_materials_sheen/sheenRoughnessFactor",[new gt(t.Animation.ANIMATIONTYPE_FLOAT,"sheen.roughness",ht,function(){return 1})]);var Et=_t("sheen.texture");N("/materials/{}/extensions/KHR_materials_sheen/sheenColorTexture/extensions/KHR_texture_transform/scale",Et.scale),N("/materials/{}/extensions/KHR_materials_sheen/sheenColorTexture/extensions/KHR_texture_transform/offset",Et.offset),N("/materials/{}/extensions/KHR_materials_sheen/sheenColorTexture/extensions/KHR_texture_transform/rotation",Et.rotation);var St=_t("sheen.textureRoughness");N("/materials/{}/extensions/KHR_materials_sheen/sheenRoughnessTexture/extensions/KHR_texture_transform/scale",St.scale),N("/materials/{}/extensions/KHR_materials_sheen/sheenRoughnessTexture/extensions/KHR_texture_transform/offset",St.offset),N("/materials/{}/extensions/KHR_materials_sheen/sheenRoughnessTexture/extensions/KHR_texture_transform/rotation",St.rotation),N("/materials/{}/extensions/KHR_materials_specular/specularFactor",[new gt(t.Animation.ANIMATIONTYPE_FLOAT,"metallicF0Factor",ht,function(){return 1})]),N("/materials/{}/extensions/KHR_materials_specular/specularColorFactor",[new gt(t.Animation.ANIMATIONTYPE_COLOR3,"metallicReflectanceColor",ft,function(){return 3})]);var kt=_t("metallicReflectanceTexture");N("/materials/{}/extensions/KHR_materials_specular/specularTexture/extensions/KHR_texture_transform/scale",kt.scale),N("/materials/{}/extensions/KHR_materials_specular/specularTexture/extensions/KHR_texture_transform/offset",kt.offset),N("/materials/{}/extensions/KHR_materials_specular/specularTexture/extensions/KHR_texture_transform/rotation",kt.rotation);var It=_t("reflectanceTexture");N("/materials/{}/extensions/KHR_materials_specular/specularColorTexture/extensions/KHR_texture_transform/scale",It.scale),N("/materials/{}/extensions/KHR_materials_specular/specularColorTexture/extensions/KHR_texture_transform/offset",It.offset),N("/materials/{}/extensions/KHR_materials_specular/specularColorTexture/extensions/KHR_texture_transform/rotation",It.rotation),N("/materials/{}/extensions/KHR_materials_transmission/transmissionFactor",[new gt(t.Animation.ANIMATIONTYPE_FLOAT,"subSurface.refractionIntensity",ht,function(){return 1})]);var Bt=_t("subSurface.refractionIntensityTexture");N("/materials/{}/extensions/KHR_materials_transmission/transmissionTexture/extensions/KHR_texture_transform/scale",Bt.scale),N("/materials/{}/extensions/KHR_materials_transmission/transmissionTexture/extensions/KHR_texture_transform/offset",Bt.offset),N("/materials/{}/extensions/KHR_materials_transmission/transmissionTexture/extensions/KHR_texture_transform/rotation",Bt.rotation),N("/materials/{}/extensions/KHR_materials_volume/attenuationColor",[new gt(t.Animation.ANIMATIONTYPE_COLOR3,"subSurface.tintColor",ft,function(){return 3})]),N("/materials/{}/extensions/KHR_materials_volume/attenuationDistance",[new gt(t.Animation.ANIMATIONTYPE_FLOAT,"subSurface.tintColorAtDistance",ht,function(){return 1})]),N("/materials/{}/extensions/KHR_materials_volume/thicknessFactor",[new gt(t.Animation.ANIMATIONTYPE_FLOAT,"subSurface.maximumThickness",ht,function(){return 1})]);var Nt=_t("subSurface.thicknessTexture");N("/materials/{}/extensions/KHR_materials_volume/thicknessTexture/extensions/KHR_texture_transform/scale",Nt.scale),N("/materials/{}/extensions/KHR_materials_volume/thicknessTexture/extensions/KHR_texture_transform/offset",Nt.offset),N("/materials/{}/extensions/KHR_materials_volume/thicknessTexture/extensions/KHR_texture_transform/rotation",Nt.rotation),N("/materials/{}/extensions/KHR_materials_diffuse_transmission/diffuseTransmissionFactor",[new gt(t.Animation.ANIMATIONTYPE_FLOAT,"subSurface.translucencyIntensity",ht,function(){return 1})]);var Gt=_t("subSurface.translucencyIntensityTexture");N("materials/{}/extensions/KHR_materials_diffuse_transmission/diffuseTransmissionTexture/extensions/KHR_texture_transform/scale",Gt.scale),N("materials/{}/extensions/KHR_materials_diffuse_transmission/diffuseTransmissionTexture/extensions/KHR_texture_transform/offset",Gt.offset),N("materials/{}/extensions/KHR_materials_diffuse_transmission/diffuseTransmissionTexture/extensions/KHR_texture_transform/rotation",Gt.rotation),N("/materials/{}/extensions/KHR_materials_diffuse_transmission/diffuseTransmissionColorFactor",[new gt(t.Animation.ANIMATIONTYPE_COLOR3,"subSurface.translucencyColor",ft,function(){return 3})]);var Dt=_t("subSurface.translucencyColorTexture");N("materials/{}/extensions/KHR_materials_diffuse_transmission/diffuseTransmissionColorTexture/extensions/KHR_texture_transform/scale",Dt.scale),N("materials/{}/extensions/KHR_materials_diffuse_transmission/diffuseTransmissionColorTexture/extensions/KHR_texture_transform/offset",Dt.offset),N("materials/{}/extensions/KHR_materials_diffuse_transmission/diffuseTransmissionColorTexture/extensions/KHR_texture_transform/rotation",Dt.rotation),N("/extensions/KHR_lights_punctual/lights/{}/color",[new yt(t.Animation.ANIMATIONTYPE_COLOR3,"diffuse",ft,function(){return 3})]),N("/extensions/KHR_lights_punctual/lights/{}/intensity",[new yt(t.Animation.ANIMATIONTYPE_FLOAT,"intensity",ht,function(){return 1})]),N("/extensions/KHR_lights_punctual/lights/{}/range",[new yt(t.Animation.ANIMATIONTYPE_FLOAT,"range",ht,function(){return 1})]),N("/extensions/KHR_lights_punctual/lights/{}/spot/innerConeAngle",[new yt(t.Animation.ANIMATIONTYPE_FLOAT,"innerAngle",mt,function(){return 1})]),N("/extensions/KHR_lights_punctual/lights/{}/spot/outerConeAngle",[new yt(t.Animation.ANIMATIONTYPE_FLOAT,"angle",mt,function(){return 1})]),N("/extensions/EXT_lights_area/lights/{}/color",[new yt(t.Animation.ANIMATIONTYPE_COLOR3,"diffuse",ft,function(){return 3})]),N("/extensions/EXT_lights_area/lights/{}/intensity",[new yt(t.Animation.ANIMATIONTYPE_FLOAT,"intensity",ht,function(){return 1})]),N("/extensions/EXT_lights_area/lights/{}/size",[new yt(t.Animation.ANIMATIONTYPE_FLOAT,"radius",ht,function(){return 1})]),N("/extensions/EXT_lights_area/lights/{}/rect/aspect",[new yt(t.Animation.ANIMATIONTYPE_FLOAT,"radius",ht,function(){return 1})]),N("/nodes/{}/extensions/EXT_lights_ies/color",[new yt(t.Animation.ANIMATIONTYPE_COLOR3,"diffuse",ft,function(){return 3})]),N("/nodes/{}/extensions/EXT_lights_ies/multiplier",[new yt(t.Animation.ANIMATIONTYPE_FLOAT,"intensity",ht,function(){return 1})]),N("/nodes/{}/extensions/KHR_node_visibility/visible",[new vt(t.Animation.ANIMATIONTYPE_FLOAT,"isVisible",ht,function(){return 1})]);var Vt="KHR_animation_pointer",Ht=function(){function e(e){this.name=Vt,this._loader=e,this._pathToObjectConverter=I(this._loader.gltf)}return Object.defineProperty(e.prototype,"enabled",{get:function(){return this._loader.isExtensionUsed(Vt)},enumerable:!1,configurable:!0}),e.prototype.dispose=function(){this._loader=null,delete this._pathToObjectConverter},e.prototype._loadAnimationChannelAsync=function(e,n,r,o,a){var i,s=null===(i=o.target.extensions)||void 0===i?void 0:i.KHR_animation_pointer;if(!s||!this._pathToObjectConverter)return null;"pointer"!==o.target.path&&t.Logger.Warn("".concat(e,"/target/path: Value (").concat(o.target.path,") must be (").concat("pointer",") when using the ").concat(this.name," extension")),null!=o.target.node&&t.Logger.Warn("".concat(e,"/target/node: Value (").concat(o.target.node,") must not be present when using the ").concat(this.name," extension"));var l="".concat(e,"/extensions/").concat(this.name),u=s.pointer;if(!u)throw new Error("".concat(l,": Pointer is missing"));try{var c=this._pathToObjectConverter.convert(u);if(!c.info.interpolation)throw new Error("".concat(l,"/pointer: Interpolation is missing"));return this._loader._loadAnimationChannelFromTargetInfoAsync(e,n,r,o,{object:c.object,info:c.info.interpolation},a)}catch(e){return t.Logger.Warn("".concat(l,"/pointer: Invalid pointer (").concat(u,") skipped")),null}},e}();K(Vt),H(Vt,!0,function(e){return new Ht(e)});var Kt="MSFT_audio_emitter",jt=function(){function e(e){this.name=Kt,this._loader=e,this.enabled=this._loader.isExtensionUsed(Kt)}return e.prototype.dispose=function(){this._loader=null,this._clips=null,this._emitters=null},e.prototype.onLoading=function(){var e=this._loader.gltf.extensions;if(e&&e[this.name]){var t=e[this.name];this._clips=t.clips,this._emitters=t.emitters,U.Assign(this._clips),U.Assign(this._emitters)}},e.prototype.loadSceneAsync=function(e,t){var n=this;return q.LoadExtensionAsync(e,t,this.name,function(r,o){return a(n,void 0,void 0,function(){var n,a,s,l,u;return i(this,function(i){switch(i.label){case 0:for((n=new Array).push(this._loader.loadSceneAsync(e,t)),a=0,s=o.emitters;a<s.length;a++){if(l=s[a],null!=(u=U.Get("".concat(r,"/emitters"),this._emitters,l)).refDistance||null!=u.maxDistance||null!=u.rolloffFactor||null!=u.distanceModel||null!=u.innerAngle||null!=u.outerAngle)throw new Error("".concat(r,": Direction or Distance properties are not allowed on emitters attached to a scene"));n.push(this._loadEmitterAsync("".concat(r,"/emitters/").concat(u.index),u))}return[4,Promise.all(n)];case 1:return i.sent(),[2]}})})})},e.prototype.loadNodeAsync=function(e,n,r){var o=this;return q.LoadExtensionAsync(e,n,this.name,function(e,s){return a(o,void 0,void 0,function(){var o,a,l=this;return i(this,function(i){switch(i.label){case 0:return o=new Array,[4,this._loader.loadNodeAsync(e,n,function(n){for(var a=function(r){var a=U.Get("".concat(e,"/emitters"),l._emitters,r);o.push(l._loadEmitterAsync("".concat(e,"/emitters/").concat(a.index),a).then(function(){for(var e=0,r=a._babylonSounds;e<r.length;e++){var o=r[e];o.attachToMesh(n),null==a.innerAngle&&null==a.outerAngle||(o.setLocalDirectionToMesh(t.Vector3.Forward()),o.setDirectionalCone(2*t.Tools.ToDegrees(null==a.innerAngle?Math.PI:a.innerAngle),2*t.Tools.ToDegrees(null==a.outerAngle?Math.PI:a.outerAngle),0))}}))},i=0,u=s.emitters;i<u.length;i++)a(u[i]);r(n)})];case 1:return a=i.sent(),[4,Promise.all(o)];case 2:return i.sent(),[2,a]}})})})},e.prototype.loadAnimationAsync=function(e,t){var n=this;return q.LoadExtensionAsync(e,t,this.name,function(r,o){return a(n,void 0,void 0,function(){var n,a,s,l,u;return i(this,function(i){switch(i.label){case 0:return[4,this._loader.loadAnimationAsync(e,t)];case 1:for(n=i.sent(),a=new Array,U.Assign(o.events),s=0,l=o.events;s<l.length;s++)u=l[s],a.push(this._loadAnimationEventAsync("".concat(r,"/events/").concat(u.index),e,t,u,n));return[4,Promise.all(a)];case 2:return i.sent(),[2,n]}})})})},e.prototype._loadClipAsync=function(e,n){if(n._objectURL)return n._objectURL;var r;if(n.uri)r=this._loader.loadUriAsync(e,n,n.uri);else{var o=U.Get("".concat(e,"/bufferView"),this._loader.gltf.bufferViews,n.bufferView);r=this._loader.loadBufferViewAsync("/bufferViews/".concat(o.index),o)}return n._objectURL=r.then(function(e){var r=t.GetBlobBufferSource(e);return URL.createObjectURL(new Blob([r],{type:n.mimeType}))}),n._objectURL},e.prototype._loadEmitterAsync=function(e,n){var r=this;if(n._babylonSounds=n._babylonSounds||[],!n._babylonData){for(var o=new Array,a=n.name||"emitter".concat(n.index),i={loop:!1,autoplay:!1,volume:null==n.volume?1:n.volume},s=function(e){var s="/extensions/".concat(l.name,"/clips"),u=U.Get(s,l._clips,n.clips[e].clip);o.push(l._loadClipAsync("".concat(s,"/").concat(n.clips[e].clip),u).then(function(o){var s=n._babylonSounds[e]=new t.Sound(a,o,r._loader.babylonScene,null,i);s.refDistance=n.refDistance||1,s.maxDistance=n.maxDistance||256,s.rolloffFactor=n.rolloffFactor||1,s.distanceModel=n.distanceModel||"exponential"}))},l=this,u=0;u<n.clips.length;u++)s(u);var c=Promise.all(o).then(function(){var e=n.clips.map(function(e){return e.weight||1}),r=new t.WeightedSound(n.loop||!1,n._babylonSounds,e);n.innerAngle&&(r.directionalConeInnerAngle=2*t.Tools.ToDegrees(n.innerAngle)),n.outerAngle&&(r.directionalConeOuterAngle=2*t.Tools.ToDegrees(n.outerAngle)),n.volume&&(r.volume=n.volume),n._babylonData.sound=r});n._babylonData={loaded:c}}return n._babylonData.loaded},e.prototype._getEventAction=function(e,t,n,r,o){switch(n){case"play":return function(e){var n=(o||0)+(e-r);t.play(n)};case"stop":return function(){t.stop()};case"pause":return function(){t.pause()};default:throw new Error("".concat(e,": Unsupported action ").concat(n))}},e.prototype._loadAnimationEventAsync=function(e,n,r,o,a){var i=this;if(0==a.targetedAnimations.length)return Promise.resolve();var s=a.targetedAnimations[0],l=o.emitter,u=U.Get("/extensions/".concat(this.name,"/emitters"),this._emitters,l);return this._loadEmitterAsync(e,u).then(function(){var n=u._babylonData.sound;if(n){var r=new t.AnimationEvent(o.time,i._getEventAction(e,n,o.action,o.time,o.startOffset));s.animation.addEvent(r),a.onAnimationGroupEndObservable.add(function(){n.stop()}),a.onAnimationGroupPauseObservable.add(function(){n.pause()})}})},e}();K(Kt),H(Kt,!0,function(e){return new jt(e)});var Wt="MSFT_lod",Ut=function(){function e(e){var n,r;this.name=Wt,this.order=100,this.maxLODsToLoad=10,this.onNodeLODsLoadedObservable=new t.Observable,this.onMaterialLODsLoadedObservable=new t.Observable,this._bufferLODs=new Array,this._nodeIndexLOD=null,this._nodeSignalLODs=new Array,this._nodePromiseLODs=new Array,this._nodeBufferLODs=new Array,this._materialIndexLOD=null,this._materialSignalLODs=new Array,this._materialPromiseLODs=new Array,this._materialBufferLODs=new Array,this._loader=e,this.maxLODsToLoad=null!==(r=null===(n=this._loader.parent.extensionOptions[Wt])||void 0===n?void 0:n.maxLODsToLoad)&&void 0!==r?r:this.maxLODsToLoad,this.enabled=this._loader.isExtensionUsed(Wt)}return e.prototype.dispose=function(){this._loader=null,this._nodeIndexLOD=null,this._nodeSignalLODs.length=0,this._nodePromiseLODs.length=0,this._nodeBufferLODs.length=0,this._materialIndexLOD=null,this._materialSignalLODs.length=0,this._materialPromiseLODs.length=0,this._materialBufferLODs.length=0,this.onMaterialLODsLoadedObservable.clear(),this.onNodeLODsLoadedObservable.clear()},e.prototype.onReady=function(){for(var e=this,t=function(t){var r=Promise.all(n._nodePromiseLODs[t]).then(function(){0!==t&&(e._loader.endPerformanceCounter("Node LOD ".concat(t)),e._loader.log("Loaded node LOD ".concat(t))),e.onNodeLODsLoadedObservable.notifyObservers(t),t!==e._nodePromiseLODs.length-1&&(e._loader.startPerformanceCounter("Node LOD ".concat(t+1)),e._loadBufferLOD(e._nodeBufferLODs,t+1),e._nodeSignalLODs[t]&&e._nodeSignalLODs[t].resolve())});n._loader._completePromises.push(r)},n=this,r=0;r<this._nodePromiseLODs.length;r++)t(r);var o=function(t){var n=Promise.all(a._materialPromiseLODs[t]).then(function(){0!==t&&(e._loader.endPerformanceCounter("Material LOD ".concat(t)),e._loader.log("Loaded material LOD ".concat(t))),e.onMaterialLODsLoadedObservable.notifyObservers(t),t!==e._materialPromiseLODs.length-1&&(e._loader.startPerformanceCounter("Material LOD ".concat(t+1)),e._loadBufferLOD(e._materialBufferLODs,t+1),e._materialSignalLODs[t]&&e._materialSignalLODs[t].resolve())});a._loader._completePromises.push(n)},a=this;for(r=0;r<this._materialPromiseLODs.length;r++)o(r)},e.prototype.loadSceneAsync=function(e,t){var n=this._loader.loadSceneAsync(e,t);return this._loadBufferLOD(this._bufferLODs,0),n},e.prototype.loadNodeAsync=function(e,n,r){var o=this;return q.LoadExtensionAsync(e,n,this.name,function(e,s){return a(o,void 0,void 0,function(){var o,a,l,u,c,f=this;return i(this,function(i){switch(i.label){case 0:for(a=this._getLODs(e,n,this._loader.gltf.nodes,s.ids),this._loader.logOpen("".concat(e)),l=function(e){var n=a[e];0!==e&&(u._nodeIndexLOD=e,u._nodeSignalLODs[e]=u._nodeSignalLODs[e]||new t.Deferred);var i=u._loader.loadNodeAsync("/nodes/".concat(n.index),n,function(e){r(e),e.setEnabled(!1)}).then(function(t){if(0!==e){var n=a[e-1];n._babylonTransformNode&&(f._disposeTransformNode(n._babylonTransformNode),delete n._babylonTransformNode)}return t.setEnabled(!0),t});u._nodePromiseLODs[e]=u._nodePromiseLODs[e]||[],0===e?o=i:(u._nodeIndexLOD=null,u._nodePromiseLODs[e].push(i))},u=this,c=0;c<a.length;c++)l(c);return this._loader.logClose(),[4,o];case 1:return[2,i.sent()]}})})})},e.prototype._loadMaterialAsync=function(e,t,n,r,o){var s=this;return this._nodeIndexLOD?null:q.LoadExtensionAsync(e,t,this.name,function(e,l){return a(s,void 0,void 0,function(){var a,s,u,c,f,h=this;return i(this,function(i){switch(i.label){case 0:for(s=this._getLODs(e,t,this._loader.gltf.materials,l.ids),this._loader.logOpen("".concat(e)),u=function(e){var t=s[e];0!==e&&(c._materialIndexLOD=e);var i=c._loader._loadMaterialAsync("/materials/".concat(t.index),t,n,r,function(t){0===e&&o(t)}).then(function(t){if(0!==e){o(t);var n=s[e-1]._data;n[r]&&(h._disposeMaterials([n[r].babylonMaterial]),delete n[r])}return t});c._materialPromiseLODs[e]=c._materialPromiseLODs[e]||[],0===e?a=i:(c._materialIndexLOD=null,c._materialPromiseLODs[e].push(i))},c=this,f=0;f<s.length;f++)u(f);return this._loader.logClose(),[4,a];case 1:return[2,i.sent()]}})})})},e.prototype._loadUriAsync=function(e,n,r){var o=this;if(null!==this._nodeIndexLOD){this._loader.log("deferred");var s=this._nodeIndexLOD-1;return this._nodeSignalLODs[s]=this._nodeSignalLODs[s]||new t.Deferred,this._nodeSignalLODs[this._nodeIndexLOD-1].promise.then(function(){return a(o,void 0,void 0,function(){return i(this,function(t){switch(t.label){case 0:return[4,this._loader.loadUriAsync(e,n,r)];case 1:return[2,t.sent()]}})})})}return null!==this._materialIndexLOD?(this._loader.log("deferred"),s=this._materialIndexLOD-1,this._materialSignalLODs[s]=this._materialSignalLODs[s]||new t.Deferred,this._materialSignalLODs[s].promise.then(function(){return a(o,void 0,void 0,function(){return i(this,function(t){switch(t.label){case 0:return[4,this._loader.loadUriAsync(e,n,r)];case 1:return[2,t.sent()]}})})})):null},e.prototype.loadBufferAsync=function(e,n,r,o){var s=this;if(this._loader.parent.useRangeRequests&&!n.uri){if(!this._loader.bin)throw new Error("".concat(e,": Uri is missing or the binary glTF is missing its binary chunk"));var l=function(e,n){return a(s,void 0,void 0,function(){var a,s,l;return i(this,function(i){switch(i.label){case 0:return s=(a=r)+o-1,(l=e[n])?(l.start=Math.min(l.start,a),l.end=Math.max(l.end,s)):(l={start:a,end:s,loaded:new t.Deferred},e[n]=l),[4,l.loaded.promise.then(function(e){return new Uint8Array(e.buffer,e.byteOffset+r-l.start,o)})];case 1:return[2,i.sent()]}})})};return this._loader.log("deferred"),null!==this._nodeIndexLOD?l(this._nodeBufferLODs,this._nodeIndexLOD):null!==this._materialIndexLOD?l(this._materialBufferLODs,this._materialIndexLOD):l(this._bufferLODs,0)}return null},e.prototype._loadBufferLOD=function(e,t){var n=e[t];n&&(this._loader.log("Loading buffer range [".concat(n.start,"-").concat(n.end,"]")),this._loader.bin.readAsync(n.start,n.end-n.start+1).then(function(e){n.loaded.resolve(e)},function(e){n.loaded.reject(e)}))},e.prototype._getLODs=function(e,t,n,r){if(this.maxLODsToLoad<=0)throw new Error("maxLODsToLoad must be greater than zero");for(var o=[],a=r.length-1;a>=0;a--)if(o.push(U.Get("".concat(e,"/ids/").concat(r[a]),n,r[a])),o.length===this.maxLODsToLoad)return o;return o.push(t),o},e.prototype._disposeTransformNode=function(e){var t=this,n=[],r=e.material;r&&n.push(r);for(var o=0,a=e.getChildMeshes();o<a.length;o++){var i=a[o];i.material&&n.push(i.material)}e.dispose();var s=n.filter(function(e){return t._loader.babylonScene.meshes.every(function(t){return t.material!=e})});this._disposeMaterials(s)},e.prototype._disposeMaterials=function(e){for(var t={},n=0,r=e;n<r.length;n++){for(var o=0,a=(c=r[n]).getActiveTextures();o<a.length;o++){var i=a[o];t[i.uniqueId]=i}c.dispose()}for(var s in t)for(var l=0,u=this._loader.babylonScene.materials;l<u.length;l++){var c;(c=u[l]).hasTexture(t[s])&&delete t[s]}for(var s in t)t[s].dispose()},e}();K(Wt),H(Wt,!0,function(e){return new Ut(e)});var zt="MSFT_minecraftMesh",qt=function(){function e(e){this.name=zt,this._loader=e,this.enabled=this._loader.isExtensionUsed(zt)}return e.prototype.dispose=function(){this._loader=null},e.prototype.loadMaterialPropertiesAsync=function(e,t,n){var r=this;return q.LoadExtraAsync(e,t,this.name,function(o,s){return a(r,void 0,void 0,function(){var r;return i(this,function(a){switch(a.label){case 0:if(!s)return[3,2];if(!this._loader._pbrMaterialImpls.get("pbr"))throw new Error("".concat(o,": Material type not supported"));return r=this._loader.loadMaterialPropertiesAsync(e,t,n),n.needAlphaBlending()&&(n.forceDepthWrite=!0,n.separateCullingPass=!0),n.backFaceCulling=n.forceDepthWrite,n.twoSidedLighting=!0,[4,r];case 1:return[2,a.sent()];case 2:return[2]}})})})},e}();K(zt),H(zt,!0,function(e){return new qt(e)});var Yt="MSFT_sRGBFactors",Xt=function(){function e(e){this.name=Yt,this._loader=e,this.enabled=this._loader.isExtensionUsed(Yt)}return e.prototype.dispose=function(){this._loader=null},e.prototype.loadMaterialPropertiesAsync=function(e,t,n){var r=this;return q.LoadExtraAsync(e,t,this.name,function(o,s){return a(r,void 0,void 0,function(){var r,o,a;return i(this,function(i){switch(i.label){case 0:return s?(r=this._loader._getOrCreateMaterialAdapter(n),o=this._loader.loadMaterialPropertiesAsync(e,t,n),a=n.getScene().getEngine().useExactSrgbConversions,r.baseColorTexture||r.baseColor.toLinearSpaceToRef(r.baseColor,a),r.specularColorTexture||r.specularColor.toLinearSpaceToRef(r.specularColor,a),[4,o]):[3,2];case 1:return[2,i.sent()];case 2:return[2]}})})})},e}();function Qt(e){var t=e.split(":");return Jt({op:t[0],extension:t[1]})}function Jt(e,n){var r;void 0===n&&(n=!0);var o=e.extension?null===(r=$t[e.extension])||void 0===r?void 0:r[e.op]:en[e.op];if(!o&&(t.Logger.Warn("No mapping found for operation ".concat(e.op," and extension ").concat(e.extension||"KHR_interactivity")),n)){var a={},i={flows:{}};if(e.inputValueSockets)for(var s in a.values={},e.inputValueSockets)a.values[s]={name:s};return e.outputValueSockets&&(i.values={},Object.keys(e.outputValueSockets).forEach(function(e){i.values[e]={name:e}})),{blocks:[],inputs:a,outputs:i}}return o}function Zt(e,t,n){$t[t]||($t[t]={}),$t[t][e]=n}K(Yt),H(Yt,!0,function(e){return new Xt(e)});var $t={BABYLON:{"flow/log":{blocks:["FlowGraphConsoleLogBlock"],inputs:{values:{message:{name:"message"}}}}}},en={"event/onStart":{blocks:["FlowGraphSceneReadyEventBlock"],outputs:{flows:{out:{name:"done"}}}},"event/onTick":{blocks:["FlowGraphSceneTickEventBlock"],inputs:{},outputs:{values:{timeSinceLastTick:{name:"deltaTime",gltfType:"number"}},flows:{out:{name:"done"}}}},"event/send":{blocks:["FlowGraphSendCustomEventBlock"],extraProcessor:function(e,t,n,r,o){var a;if("event/send"!==t.op||!e.configuration||1!==Object.keys(e.configuration).length)throw new Error("Receive event should have a single configuration object, the event itself");var i=null===(a=e.configuration.event.value)||void 0===a?void 0:a[0];if("number"!=typeof i)throw new Error("Event id should be a number");var s=r.arrays.events[i],l=o[0];return l.config||(l.config={}),l.config.eventId=s.eventId,l.config.eventData=s.eventData,o}},"event/receive":{blocks:["FlowGraphReceiveCustomEventBlock"],outputs:{flows:{out:{name:"done"}}},validation:function(e,n){var r,o;if(!e.configuration)return t.Logger.Error("Receive event should have a configuration object"),{valid:!1,error:"Receive event should have a configuration object"};var a=e.configuration.event;if(!a)return t.Logger.Error("Receive event should have a single configuration object, the event itself"),{valid:!1,error:"Receive event should have a single configuration object, the event itself"};var i=null===(r=a.value)||void 0===r?void 0:r[0];return"number"!=typeof i?(t.Logger.Error("Event id should be a number"),{valid:!1,error:"Event id should be a number"}):(null===(o=n.events)||void 0===o?void 0:o[i])?{valid:!0}:(t.Logger.Error("Event with id ".concat(i," not found")),{valid:!1,error:"Event with id ".concat(i," not found")})},extraProcessor:function(e,t,n,r,o){var a;if("event/receive"!==t.op||!e.configuration||1!==Object.keys(e.configuration).length)throw new Error("Receive event should have a single configuration object, the event itself");var i=null===(a=e.configuration.event.value)||void 0===a?void 0:a[0];if("number"!=typeof i)throw new Error("Event id should be a number");var s=r.arrays.events[i],l=o[0];return l.config||(l.config={}),l.config.eventId=s.eventId,l.config.eventData=s.eventData,o}},"math/E":tn("FlowGraphEBlock"),"math/Pi":tn("FlowGraphPIBlock"),"math/Inf":tn("FlowGraphInfBlock"),"math/NaN":tn("FlowGraphNaNBlock"),"math/abs":tn("FlowGraphAbsBlock"),"math/sign":tn("FlowGraphSignBlock"),"math/trunc":tn("FlowGraphTruncBlock"),"math/floor":tn("FlowGraphFloorBlock"),"math/ceil":tn("FlowGraphCeilBlock"),"math/round":{blocks:["FlowGraphRoundBlock"],configuration:{},inputs:{values:{a:{name:"a"}}},outputs:{values:{value:{name:"value"}}},extraProcessor:function(e,t,n,r,o){var a;return(a=o[0]).config||(a.config={}),o[0].config.roundHalfAwayFromZero=!0,o}},"math/fract":tn("FlowGraphFractBlock"),"math/neg":tn("FlowGraphNegationBlock"),"math/add":tn("FlowGraphAddBlock",["a","b"],!0),"math/sub":tn("FlowGraphSubtractBlock",["a","b"],!0),"math/mul":{blocks:["FlowGraphMultiplyBlock"],extraProcessor:function(e,t,n,r,o){var a;(a=o[0]).config||(a.config={}),o[0].config.useMatrixPerComponent=!0,o[0].config.preventIntegerFloatArithmetic=!0;var i=-1;return Object.keys(e.values||{}).find(function(t){var n;return void 0!==(null===(n=e.values)||void 0===n?void 0:n[t].type)&&(i=e.values[t].type,!0)}),-1!==i&&(o[0].config.type=r.arrays.types[i].flowGraphType),o},validation:function(e){return e.values?nn(e):{valid:!0}}},"math/div":tn("FlowGraphDivideBlock",["a","b"],!0),"math/rem":tn("FlowGraphModuloBlock",["a","b"]),"math/min":tn("FlowGraphMinBlock",["a","b"]),"math/max":tn("FlowGraphMaxBlock",["a","b"]),"math/clamp":tn("FlowGraphClampBlock",["a","b","c"]),"math/saturate":tn("FlowGraphSaturateBlock"),"math/mix":tn("FlowGraphMathInterpolationBlock",["a","b","c"]),"math/eq":tn("FlowGraphEqualityBlock",["a","b"]),"math/lt":tn("FlowGraphLessThanBlock",["a","b"]),"math/le":tn("FlowGraphLessThanOrEqualBlock",["a","b"]),"math/gt":tn("FlowGraphGreaterThanBlock",["a","b"]),"math/ge":tn("FlowGraphGreaterThanOrEqualBlock",["a","b"]),"math/isNaN":tn("FlowGraphIsNaNBlock"),"math/isInf":tn("FlowGraphIsInfBlock"),"math/select":{blocks:["FlowGraphConditionalBlock"],inputs:{values:{condition:{name:"condition"},a:{name:"onTrue"},b:{name:"onFalse"}}},outputs:{values:{value:{name:"output"}}}},"math/random":{blocks:["FlowGraphRandomBlock"],outputs:{values:{value:{name:"value"}}}},"math/sin":tn("FlowGraphSinBlock"),"math/cos":tn("FlowGraphCosBlock"),"math/tan":tn("FlowGraphTanBlock"),"math/asin":tn("FlowGraphASinBlock"),"math/acos":tn("FlowGraphACosBlock"),"math/atan":tn("FlowGraphATanBlock"),"math/atan2":tn("FlowGraphATan2Block",["a","b"]),"math/sinh":tn("FlowGraphSinhBlock"),"math/cosh":tn("FlowGraphCoshBlock"),"math/tanh":tn("FlowGraphTanhBlock"),"math/asinh":tn("FlowGraphASinhBlock"),"math/acosh":tn("FlowGraphACoshBlock"),"math/atanh":tn("FlowGraphATanhBlock"),"math/exp":tn("FlowGraphExponentialBlock"),"math/log":tn("FlowGraphLogBlock"),"math/log2":tn("FlowGraphLog2Block"),"math/log10":tn("FlowGraphLog10Block"),"math/sqrt":tn("FlowGraphSquareRootBlock"),"math/cbrt":tn("FlowGraphCubeRootBlock"),"math/pow":tn("FlowGraphPowerBlock",["a","b"]),"math/length":tn("FlowGraphLengthBlock"),"math/normalize":tn("FlowGraphNormalizeBlock"),"math/dot":tn("FlowGraphDotBlock",["a","b"]),"math/cross":tn("FlowGraphCrossBlock",["a","b"]),"math/rotate2D":{blocks:["FlowGraphRotate2DBlock"],inputs:{values:{a:{name:"a"},angle:{name:"b"}}},outputs:{values:{value:{name:"value"}}}},"math/rotate3D":{blocks:["FlowGraphRotate3DBlock"],inputs:{values:{a:{name:"a"},rotation:{name:"b"}}},outputs:{values:{value:{name:"value"}}}},"math/transform":{blocks:["FlowGraphTransformVectorBlock"],inputs:{values:{a:{name:"a"},b:{name:"b"}}},outputs:{values:{value:{name:"value"}}}},"math/combine2":{blocks:["FlowGraphCombineVector2Block"],inputs:{values:{a:{name:"input_0",gltfType:"number"},b:{name:"input_1",gltfType:"number"}}},outputs:{values:{value:{name:"value"}}}},"math/combine3":{blocks:["FlowGraphCombineVector3Block"],inputs:{values:{a:{name:"input_0",gltfType:"number"},b:{name:"input_1",gltfType:"number"},c:{name:"input_2",gltfType:"number"}}},outputs:{values:{value:{name:"value"}}}},"math/combine4":{blocks:["FlowGraphCombineVector4Block"],inputs:{values:{a:{name:"input_0",gltfType:"number"},b:{name:"input_1",gltfType:"number"},c:{name:"input_2",gltfType:"number"},d:{name:"input_3",gltfType:"number"}}},outputs:{values:{value:{name:"value"}}}},"math/extract2":{blocks:["FlowGraphExtractVector2Block"],inputs:{values:{a:{name:"input",gltfType:"number"}}},outputs:{values:{0:{name:"output_0"},1:{name:"output_1"}}}},"math/extract3":{blocks:["FlowGraphExtractVector3Block"],inputs:{values:{a:{name:"input",gltfType:"number"}}},outputs:{values:{0:{name:"output_0"},1:{name:"output_1"},2:{name:"output_2"}}}},"math/extract4":{blocks:["FlowGraphExtractVector4Block"],inputs:{values:{a:{name:"input",gltfType:"number"}}},outputs:{values:{0:{name:"output_0"},1:{name:"output_1"},2:{name:"output_2"},3:{name:"output_3"}}}},"math/transpose":tn("FlowGraphTransposeBlock"),"math/determinant":tn("FlowGraphDeterminantBlock"),"math/inverse":tn("FlowGraphInvertMatrixBlock"),"math/matMul":tn("FlowGraphMatrixMultiplicationBlock",["a","b"]),"math/matCompose":{blocks:["FlowGraphMatrixCompose"],inputs:{values:{translation:{name:"position",gltfType:"float3"},rotation:{name:"rotationQuaternion",gltfType:"float4"},scale:{name:"scaling",gltfType:"float3"}}},outputs:{values:{value:{name:"value"}}},extraProcessor:function(e,t,n,r,o,a){var i=o[0].dataInputs.find(function(e){return"rotationQuaternion"===e.name});if(!i)throw new Error("Rotation quaternion input not found");return a._connectionValues[i.uniqueId]&&(a._connectionValues[i.uniqueId].type="Quaternion"),o}},"math/matDecompose":{blocks:["FlowGraphMatrixDecompose"],inputs:{values:{a:{name:"input",gltfType:"number"}}},outputs:{values:{translation:{name:"position"},rotation:{name:"rotationQuaternion"},scale:{name:"scaling"}}}},"math/quatConjugate":tn("FlowGraphConjugateBlock",["a"]),"math/quatMul":{blocks:["FlowGraphMultiplyBlock"],inputs:{values:{a:{name:"a",gltfType:"vector4"},b:{name:"b",gltfType:"vector4"}}},outputs:{values:{value:{name:"value"}}},extraProcessor:function(e,t,n,r,o){var a;return(a=o[0]).config||(a.config={}),o[0].config.type="Quaternion",o}},"math/quatAngleBetween":tn("FlowGraphAngleBetweenBlock",["a","b"]),"math/quatFromAxisAngle":{blocks:["FlowGraphQuaternionFromAxisAngleBlock"],inputs:{values:{axis:{name:"a",gltfType:"float3"},angle:{name:"b",gltfType:"number"}}},outputs:{values:{value:{name:"value"}}}},"math/quatToAxisAngle":tn("FlowGraphAxisAngleFromQuaternionBlock",["a"]),"math/quatFromDirections":tn("FlowGraphQuaternionFromDirectionsBlock",["a","b"]),"math/combine2x2":{blocks:["FlowGraphCombineMatrix2DBlock"],inputs:{values:{a:{name:"input_0",gltfType:"number"},b:{name:"input_1",gltfType:"number"},c:{name:"input_2",gltfType:"number"},d:{name:"input_3",gltfType:"number"}}},outputs:{values:{value:{name:"value"}}},extraProcessor:function(e,t,n,r,o){var a;return(a=o[0]).config||(a.config={}),o[0].config.inputIsColumnMajor=!0,o}},"math/extract2x2":{blocks:["FlowGraphExtractMatrix2DBlock"],inputs:{values:{a:{name:"input",gltfType:"float2x2"}}},outputs:{values:{0:{name:"output_0"},1:{name:"output_1"},2:{name:"output_2"},3:{name:"output_3"}}}},"math/combine3x3":{blocks:["FlowGraphCombineMatrix3DBlock"],inputs:{values:{a:{name:"input_0",gltfType:"number"},b:{name:"input_1",gltfType:"number"},c:{name:"input_2",gltfType:"number"},d:{name:"input_3",gltfType:"number"},e:{name:"input_4",gltfType:"number"},f:{name:"input_5",gltfType:"number"},g:{name:"input_6",gltfType:"number"},h:{name:"input_7",gltfType:"number"},i:{name:"input_8",gltfType:"number"}}},outputs:{values:{value:{name:"value"}}},extraProcessor:function(e,t,n,r,o){var a;return(a=o[0]).config||(a.config={}),o[0].config.inputIsColumnMajor=!0,o}},"math/extract3x3":{blocks:["FlowGraphExtractMatrix3DBlock"],inputs:{values:{a:{name:"input",gltfType:"float3x3"}}},outputs:{values:{0:{name:"output_0"},1:{name:"output_1"},2:{name:"output_2"},3:{name:"output_3"},4:{name:"output_4"},5:{name:"output_5"},6:{name:"output_6"},7:{name:"output_7"},8:{name:"output_8"}}}},"math/combine4x4":{blocks:["FlowGraphCombineMatrixBlock"],inputs:{values:{a:{name:"input_0",gltfType:"number"},b:{name:"input_1",gltfType:"number"},c:{name:"input_2",gltfType:"number"},d:{name:"input_3",gltfType:"number"},e:{name:"input_4",gltfType:"number"},f:{name:"input_5",gltfType:"number"},g:{name:"input_6",gltfType:"number"},h:{name:"input_7",gltfType:"number"},i:{name:"input_8",gltfType:"number"},j:{name:"input_9",gltfType:"number"},k:{name:"input_10",gltfType:"number"},l:{name:"input_11",gltfType:"number"},m:{name:"input_12",gltfType:"number"},n:{name:"input_13",gltfType:"number"},o:{name:"input_14",gltfType:"number"},p:{name:"input_15",gltfType:"number"}}},outputs:{values:{value:{name:"value"}}},extraProcessor:function(e,t,n,r,o){var a;return(a=o[0]).config||(a.config={}),o[0].config.inputIsColumnMajor=!0,o}},"math/extract4x4":{blocks:["FlowGraphExtractMatrixBlock"],configuration:{},inputs:{values:{a:{name:"input",gltfType:"number"}}},outputs:{values:{0:{name:"output_0"},1:{name:"output_1"},2:{name:"output_2"},3:{name:"output_3"},4:{name:"output_4"},5:{name:"output_5"},6:{name:"output_6"},7:{name:"output_7"},8:{name:"output_8"},9:{name:"output_9"},10:{name:"output_10"},11:{name:"output_11"},12:{name:"output_12"},13:{name:"output_13"},14:{name:"output_14"},15:{name:"output_15"}}}},"math/not":{blocks:["FlowGraphBitwiseNotBlock"],inputs:{values:{a:{name:"a"}}},outputs:{values:{value:{name:"value"}}},extraProcessor:function(e,t,n,r,o,a){var i,s,l;(l=o[0]).config||(l.config={});var u=o[0].dataInputs[0];return o[0].config.valueType=null!==(s=null===(i=a._connectionValues[u.uniqueId])||void 0===i?void 0:i.type)&&void 0!==s?s:"FlowGraphInteger",o}},"math/and":{blocks:["FlowGraphBitwiseAndBlock"],inputs:{values:{a:{name:"a"},b:{name:"b"}}},outputs:{values:{value:{name:"value"}}},extraProcessor:function(e,t,n,r,o,a){var i,s,l,u,c;(c=o[0]).config||(c.config={});var f=o[0].dataInputs[0],h=o[0].dataInputs[1];return o[0].config.valueType=null!==(u=null!==(s=null===(i=a._connectionValues[f.uniqueId])||void 0===i?void 0:i.type)&&void 0!==s?s:null===(l=a._connectionValues[h.uniqueId])||void 0===l?void 0:l.type)&&void 0!==u?u:"FlowGraphInteger",o}},"math/or":{blocks:["FlowGraphBitwiseOrBlock"],inputs:{values:{a:{name:"a"},b:{name:"b"}}},outputs:{values:{value:{name:"value"}}},extraProcessor:function(e,t,n,r,o,a){var i,s,l,u,c;(c=o[0]).config||(c.config={});var f=o[0].dataInputs[0],h=o[0].dataInputs[1];return o[0].config.valueType=null!==(u=null!==(s=null===(i=a._connectionValues[f.uniqueId])||void 0===i?void 0:i.type)&&void 0!==s?s:null===(l=a._connectionValues[h.uniqueId])||void 0===l?void 0:l.type)&&void 0!==u?u:"FlowGraphInteger",o}},"math/xor":{blocks:["FlowGraphBitwiseXorBlock"],inputs:{values:{a:{name:"a"},b:{name:"b"}}},outputs:{values:{value:{name:"value"}}},extraProcessor:function(e,t,n,r,o,a){var i,s,l,u,c;(c=o[0]).config||(c.config={});var f=o[0].dataInputs[0],h=o[0].dataInputs[1];return o[0].config.valueType=null!==(u=null!==(s=null===(i=a._connectionValues[f.uniqueId])||void 0===i?void 0:i.type)&&void 0!==s?s:null===(l=a._connectionValues[h.uniqueId])||void 0===l?void 0:l.type)&&void 0!==u?u:"FlowGraphInteger",o}},"math/asr":tn("FlowGraphBitwiseRightShiftBlock",["a","b"]),"math/lsl":tn("FlowGraphBitwiseLeftShiftBlock",["a","b"]),"math/clz":tn("FlowGraphLeadingZerosBlock"),"math/ctz":tn("FlowGraphTrailingZerosBlock"),"math/popcnt":tn("FlowGraphOneBitsCounterBlock"),"math/rad":tn("FlowGraphDegToRadBlock"),"math/deg":tn("FlowGraphRadToDegBlock"),"type/boolToInt":tn("FlowGraphBooleanToInt"),"type/boolToFloat":tn("FlowGraphBooleanToFloat"),"type/intToBool":tn("FlowGraphIntToBoolean"),"type/intToFloat":tn("FlowGraphIntToFloat"),"type/floatToInt":tn("FlowGraphFloatToInt"),"type/floatToBool":tn("FlowGraphFloatToBoolean"),"flow/sequence":{blocks:["FlowGraphSequenceBlock"],extraProcessor:function(e,t,n,r,o){var a=o[0];return a.config||(a.config={}),a.config.outputSignalCount=Object.keys(e.flows||[]).length,a.signalOutputs.forEach(function(e,t){e.name="out_"+t}),o}},"flow/branch":{blocks:["FlowGraphBranchBlock"],outputs:{flows:{true:{name:"onTrue"},false:{name:"onFalse"}}}},"flow/switch":{blocks:["FlowGraphSwitchBlock"],configuration:{cases:{name:"cases",isArray:!0,inOptions:!0,defaultValue:[]}},inputs:{values:{selection:{name:"case"},default:{name:"default"}}},validation:function(e){var n,r=null===(n=e.configuration)||void 0===n?void 0:n.cases;if(r&&r.value){if(!r.value.every(function(e){return"number"==typeof e&&/^-?\d+$/.test(e.toString())}))return t.Logger.Warn("Switch cases should be integers. Using empty array instead."),r.value=[],{valid:!0};var o=new Set(r.value);r.value=Array.from(o)}return{valid:!0}},extraProcessor:function(e,t,n,r,o){if("flow/switch"!==t.op||!e.flows||0===Object.keys(e.flows).length)throw new Error("Switch should have a single configuration object, the cases array");return o[0].signalOutputs.forEach(function(e){"default"!==e.name&&(e.name="out_"+e.name)}),o}},"flow/while":{blocks:["FlowGraphWhileLoopBlock"],outputs:{flows:{loopBody:{name:"executionFlow"}}}},"flow/for":{blocks:["FlowGraphForLoopBlock"],configuration:{initialIndex:{name:"initialIndex",gltfType:"number",inOptions:!0,defaultValue:0}},inputs:{values:{startIndex:{name:"startIndex",gltfType:"number"},endIndex:{name:"endIndex",gltfType:"number"}}},outputs:{values:{index:{name:"index"}},flows:{loopBody:{name:"executionFlow"}}},extraProcessor:function(e,t,n,r,o){var a=o[0];return a.config||(a.config={}),a.config.incrementIndexWhenLoopDone=!0,o}},"flow/doN":{blocks:["FlowGraphDoNBlock"],configuration:{},inputs:{values:{n:{name:"maxExecutions",gltfType:"number"}}},outputs:{values:{currentCount:{name:"executionCount"}}}},"flow/multiGate":{blocks:["FlowGraphMultiGateBlock"],configuration:{isRandom:{name:"isRandom",gltfType:"boolean",inOptions:!0,defaultValue:!1},isLoop:{name:"isLoop",gltfType:"boolean",inOptions:!0,defaultValue:!1}},extraProcessor:function(e,t,n,r,o){if("flow/multiGate"!==t.op||!e.flows||0===Object.keys(e.flows).length)throw new Error("MultiGate should have a single configuration object, the number of output flows");var a=o[0];return a.config||(a.config={}),a.config.outputSignalCount=Object.keys(e.flows).length,a.signalOutputs.forEach(function(e,t){e.name="out_"+t}),o}},"flow/waitAll":{blocks:["FlowGraphWaitAllBlock"],configuration:{inputFlows:{name:"inputSignalCount",gltfType:"number",inOptions:!0,defaultValue:0}},inputs:{flows:{reset:{name:"reset"},"[segment]":{name:"in_$1"}}},validation:function(e){var t,n,r;return"number"!=typeof(null===(r=null===(n=null===(t=e.configuration)||void 0===t?void 0:t.inputFlows)||void 0===n?void 0:n.value)||void 0===r?void 0:r[0])&&(e.configuration=e.configuration||{inputFlows:{value:[0]}},e.configuration.inputFlows.value=[0]),{valid:!0}}},"flow/throttle":{blocks:["FlowGraphThrottleBlock"],outputs:{flows:{err:{name:"error"}}}},"flow/setDelay":{blocks:["FlowGraphSetDelayBlock"],outputs:{flows:{err:{name:"error"}}}},"flow/cancelDelay":{blocks:["FlowGraphCancelDelayBlock"]},"variable/get":{blocks:["FlowGraphGetVariableBlock"],validation:function(e){var n,r;return(null===(r=null===(n=e.configuration)||void 0===n?void 0:n.variable)||void 0===r?void 0:r.value)?{valid:!0}:(t.Logger.Error("Variable get block should have a variable configuration"),{valid:!1,error:"Variable get block should have a variable configuration"})},configuration:{variable:{name:"variable",gltfType:"number",flowGraphType:"string",inOptions:!0,isVariable:!0,dataTransformer:function(e,t){return t.getVariableName(e)}}}},"variable/set":{blocks:["FlowGraphSetVariableBlock"],configuration:{variables:{name:"variables",gltfType:"number",flowGraphType:"string",inOptions:!0,isArray:!0,dataTransformer:function(e,t){return e.map(function(e){return t.getVariableName(e)})}}},extraProcessor:function(e,t,n,r,o){return o[0].dataInputs.forEach(function(e){e.name=r.getVariableName(+e.name)}),o}},"variable/interpolate":{blocks:["FlowGraphInterpolationBlock","FlowGraphContextBlock","FlowGraphPlayAnimationBlock","FlowGraphBezierCurveEasing","FlowGraphGetVariableBlock"],configuration:{variable:{name:"propertyName",inOptions:!0,isVariable:!0,dataTransformer:function(e,t){return t.getVariableName(e)}},useSlerp:{name:"animationType",inOptions:!0,defaultValue:!1,dataTransformer:function(e){return!0===e?"Quaternion":void 0}}},inputs:{values:{value:{name:"value_1"},duration:{name:"duration_1",gltfType:"number"},p1:{name:"controlPoint1",toBlock:"FlowGraphBezierCurveEasing"},p2:{name:"controlPoint2",toBlock:"FlowGraphBezierCurveEasing"}},flows:{in:{name:"in",toBlock:"FlowGraphPlayAnimationBlock"}}},outputs:{flows:{err:{name:"error",toBlock:"FlowGraphPlayAnimationBlock"},out:{name:"out",toBlock:"FlowGraphPlayAnimationBlock"},done:{name:"done",toBlock:"FlowGraphPlayAnimationBlock"}}},interBlockConnectors:[{input:"object",output:"userVariables",inputBlockIndex:2,outputBlockIndex:1,isVariable:!0},{input:"animation",output:"animation",inputBlockIndex:2,outputBlockIndex:0,isVariable:!0},{input:"easingFunction",output:"easingFunction",inputBlockIndex:0,outputBlockIndex:3,isVariable:!0},{input:"value_0",output:"value",inputBlockIndex:0,outputBlockIndex:4,isVariable:!0}],extraProcessor:function(e,n,r,o,a){var i,s,l,u,c,f,h=a[0],p=null===(s=null===(i=e.configuration)||void 0===i?void 0:i.variable.value)||void 0===s?void 0:s[0];if("number"!=typeof p)throw t.Logger.Error("Variable index is not defined for variable interpolation block"),new Error("Variable index is not defined for variable interpolation block");var d=o.arrays.staticVariables[p];void 0===(null===(u=null===(l=h.config)||void 0===l?void 0:l.animationType)||void 0===u?void 0:u.value)&&(h.config||(h.config={}),(c=h.config).animationType||(c.animationType={}),h.config.animationType.value=t.getAnimationTypeByFlowGraphType(d.type));var m=a[4];return m.config||(m.config={}),(f=m.config).variable||(f.variable={}),m.config.variable.value=o.getVariableName(p),a}},"pointer/get":{blocks:["FlowGraphGetPropertyBlock","FlowGraphJsonPointerParserBlock"],configuration:{pointer:{name:"jsonPointer",toBlock:"FlowGraphJsonPointerParserBlock"}},inputs:{values:{"[segment]":{name:"$1",toBlock:"FlowGraphJsonPointerParserBlock"}}},interBlockConnectors:[{input:"object",output:"object",inputBlockIndex:0,outputBlockIndex:1,isVariable:!0},{input:"propertyName",output:"propertyName",inputBlockIndex:0,outputBlockIndex:1,isVariable:!0},{input:"customGetFunction",output:"getFunction",inputBlockIndex:0,outputBlockIndex:1,isVariable:!0}],extraProcessor:function(e,t,n,r,o){return o.forEach(function(e){"FlowGraphJsonPointerParserBlock"===e.className&&(e.config||(e.config={}),e.config.outputValue=!0)}),o}},"pointer/set":{blocks:["FlowGraphSetPropertyBlock","FlowGraphJsonPointerParserBlock"],configuration:{pointer:{name:"jsonPointer",toBlock:"FlowGraphJsonPointerParserBlock"}},inputs:{values:{value:{name:"value"},"[segment]":{name:"$1",toBlock:"FlowGraphJsonPointerParserBlock"}}},outputs:{flows:{err:{name:"error"}}},interBlockConnectors:[{input:"object",output:"object",inputBlockIndex:0,outputBlockIndex:1,isVariable:!0},{input:"propertyName",output:"propertyName",inputBlockIndex:0,outputBlockIndex:1,isVariable:!0},{input:"customSetFunction",output:"setFunction",inputBlockIndex:0,outputBlockIndex:1,isVariable:!0}],extraProcessor:function(e,t,n,r,o){return o.forEach(function(e){"FlowGraphJsonPointerParserBlock"===e.className&&(e.config||(e.config={}),e.config.outputValue=!0)}),o}},"pointer/interpolate":{blocks:["FlowGraphInterpolationBlock","FlowGraphJsonPointerParserBlock","FlowGraphPlayAnimationBlock","FlowGraphBezierCurveEasing"],configuration:{pointer:{name:"jsonPointer",toBlock:"FlowGraphJsonPointerParserBlock"}},inputs:{values:{value:{name:"value_1"},"[segment]":{name:"$1",toBlock:"FlowGraphJsonPointerParserBlock"},duration:{name:"duration_1",gltfType:"number"},p1:{name:"controlPoint1",toBlock:"FlowGraphBezierCurveEasing"},p2:{name:"controlPoint2",toBlock:"FlowGraphBezierCurveEasing"}},flows:{in:{name:"in",toBlock:"FlowGraphPlayAnimationBlock"}}},outputs:{flows:{err:{name:"error",toBlock:"FlowGraphPlayAnimationBlock"},out:{name:"out",toBlock:"FlowGraphPlayAnimationBlock"},done:{name:"done",toBlock:"FlowGraphPlayAnimationBlock"}}},interBlockConnectors:[{input:"object",output:"object",inputBlockIndex:2,outputBlockIndex:1,isVariable:!0},{input:"propertyName",output:"propertyName",inputBlockIndex:0,outputBlockIndex:1,isVariable:!0},{input:"customBuildAnimation",output:"generateAnimationsFunction",inputBlockIndex:0,outputBlockIndex:1,isVariable:!0},{input:"animation",output:"animation",inputBlockIndex:2,outputBlockIndex:0,isVariable:!0},{input:"easingFunction",output:"easingFunction",inputBlockIndex:0,outputBlockIndex:3,isVariable:!0},{input:"value_0",output:"value",inputBlockIndex:0,outputBlockIndex:1,isVariable:!0}],extraProcessor:function(e,t,n,r,o){return o.forEach(function(t){"FlowGraphJsonPointerParserBlock"===t.className?(t.config||(t.config={}),t.config.outputValue=!0):"FlowGraphInterpolationBlock"===t.className&&(t.config||(t.config={}),Object.keys(e.values||[]).forEach(function(n){var o,a=null===(o=e.values)||void 0===o?void 0:o[n];if("value"===n&&a){var i=a.type;void 0!==i&&(t.config.animationType=r.arrays.types[i].flowGraphType)}}))}),o}},"animation/start":{blocks:["FlowGraphPlayAnimationBlock","FlowGraphArrayIndexBlock","KHR_interactivity/FlowGraphGLTFDataProvider"],inputs:{values:{animation:{name:"index",gltfType:"number",toBlock:"FlowGraphArrayIndexBlock"},speed:{name:"speed",gltfType:"number"},startTime:{name:"from",gltfType:"number",dataTransformer:function(e,t){return[e[0]*t._animationTargetFps]}},endTime:{name:"to",gltfType:"number",dataTransformer:function(e,t){return[e[0]*t._animationTargetFps]}}}},outputs:{flows:{err:{name:"error"}}},interBlockConnectors:[{input:"animationGroup",output:"value",inputBlockIndex:0,outputBlockIndex:1,isVariable:!0},{input:"array",output:"animationGroups",inputBlockIndex:1,outputBlockIndex:2,isVariable:!0}],extraProcessor:function(e,t,n,r,o,a,i){var s=o[o.length-1];return s.config||(s.config={}),s.config.glTF=i,o}},"animation/stop":{blocks:["FlowGraphStopAnimationBlock","FlowGraphArrayIndexBlock","KHR_interactivity/FlowGraphGLTFDataProvider"],inputs:{values:{animation:{name:"index",gltfType:"number",toBlock:"FlowGraphArrayIndexBlock"}}},outputs:{flows:{err:{name:"error"}}},interBlockConnectors:[{input:"animationGroup",output:"value",inputBlockIndex:0,outputBlockIndex:1,isVariable:!0},{input:"array",output:"animationGroups",inputBlockIndex:1,outputBlockIndex:2,isVariable:!0}],extraProcessor:function(e,t,n,r,o,a,i){var s=o[o.length-1];return s.config||(s.config={}),s.config.glTF=i,o}},"animation/stopAt":{blocks:["FlowGraphStopAnimationBlock","FlowGraphArrayIndexBlock","KHR_interactivity/FlowGraphGLTFDataProvider"],configuration:{},inputs:{values:{animation:{name:"index",gltfType:"number",toBlock:"FlowGraphArrayIndexBlock"},stopTime:{name:"stopAtFrame",gltfType:"number",dataTransformer:function(e,t){return[e[0]*t._animationTargetFps]}}}},outputs:{flows:{err:{name:"error"}}},interBlockConnectors:[{input:"animationGroup",output:"value",inputBlockIndex:0,outputBlockIndex:1,isVariable:!0},{input:"array",output:"animationGroups",inputBlockIndex:1,outputBlockIndex:2,isVariable:!0}],extraProcessor:function(e,t,n,r,o,a,i){var s=o[o.length-1];return s.config||(s.config={}),s.config.glTF=i,o}},"math/switch":{blocks:["FlowGraphDataSwitchBlock"],configuration:{cases:{name:"cases",isArray:!0,inOptions:!0,defaultValue:[]}},inputs:{values:{selection:{name:"case"}}},validation:function(e){var n,r=null===(n=e.configuration)||void 0===n?void 0:n.cases;if(r&&r.value){if(!r.value.every(function(e){return"number"==typeof e&&/^-?\d+$/.test(e.toString())}))return t.Logger.Warn("Switch cases should be integers. Using empty array instead."),r.value=[],{valid:!0};var o=new Set(r.value);r.value=Array.from(o)}return{valid:!0}},extraProcessor:function(e,t,n,r,o){var a=o[0];return a.dataInputs.forEach(function(e){"default"!==e.name&&"case"!==e.name&&(e.name="in_"+e.name)}),a.config||(a.config={}),a.config.treatCasesAsIntegers=!0,o}},"debug/log":{blocks:["FlowGraphConsoleLogBlock"],configuration:{message:{name:"messageTemplate",inOptions:!0}}}};function tn(e,t,n){return void 0===t&&(t=["a"]),{blocks:[e],inputs:{values:t.reduce(function(e,t){return e[t]={name:t},e},{})},outputs:{values:{value:{name:"value"}}},extraProcessor:function(e,t,r,o,a){var i;if(n){(i=a[0]).config||(i.config={}),a[0].config.preventIntegerFloatArithmetic=!0;var s=-1;Object.keys(e.values||{}).find(function(t){var n;return void 0!==(null===(n=e.values)||void 0===n?void 0:n[t].type)&&(s=e.values[t].type,!0)}),-1!==s&&(a[0].config.type=o.arrays.types[s].flowGraphType)}return a},validation:function(e){return n?nn(e):{valid:!0}}}}function nn(e){if(e.values){var t=Object.keys(e.values).map(function(t){return e.values[t].type}).filter(function(e){return void 0!==e});if(!t.every(function(e){return e===t[0]}))return{valid:!1,error:"All inputs must be of the same type"}}return{valid:!0}}function rn(){return Object.keys(en)}var on={float:{length:1,flowGraphType:"number",elementType:"number"},bool:{length:1,flowGraphType:"boolean",elementType:"boolean"},float2:{length:2,flowGraphType:"Vector2",elementType:"number"},float3:{length:3,flowGraphType:"Vector3",elementType:"number"},float4:{length:4,flowGraphType:"Vector4",elementType:"number"},float4x4:{length:16,flowGraphType:"Matrix",elementType:"number"},float2x2:{length:4,flowGraphType:"Matrix2D",elementType:"number"},float3x3:{length:9,flowGraphType:"Matrix3D",elementType:"number"},int:{length:1,flowGraphType:"FlowGraphInteger",elementType:"number"}},an=function(){function e(e,t,n){void 0===n&&(n=60),this._interactivityGraph=e,this._gltf=t,this._animationTargetFps=n,this._types=[],this._mappings=[],this._staticVariables=[],this._events=[],this._internalEventsCounter=0,this._nodes=[],this._parseTypes(),this._parseDeclarations(),this._parseVariables(),this._parseEvents(),this._parseNodes()}return Object.defineProperty(e.prototype,"arrays",{get:function(){return{types:this._types,mappings:this._mappings,staticVariables:this._staticVariables,events:this._events,nodes:this._nodes}},enumerable:!1,configurable:!0}),e.prototype._parseTypes=function(){if(this._interactivityGraph.types)for(var e=0,t=this._interactivityGraph.types;e<t.length;e++){var n=t[e];this._types.push(on[n.signature])}},e.prototype._parseDeclarations=function(){if(this._interactivityGraph.declarations)for(var e=0,n=this._interactivityGraph.declarations;e<n.length;e++){var r=n[e],o=Jt(r);if(!o)throw t.Logger.Error(["No mapping found for declaration",r]),new Error("Error parsing declarations");this._mappings.push({flowGraphMapping:o,fullOperationName:r.extension?r.op+":"+r.extension:r.op})}},e.prototype._parseVariables=function(){if(this._interactivityGraph.variables)for(var e=0,t=this._interactivityGraph.variables;e<t.length;e++){var n=t[e],r=this._parseVariable(n);this._staticVariables.push(r)}},e.prototype._parseVariable=function(e,n){var r=this._types[e.type];if(!r)throw t.Logger.Error(["No type found for variable",e]),new Error("Error parsing variables");if(e.value&&e.value.length!==r.length)throw t.Logger.Error(["Invalid value length for variable",e,r]),new Error("Error parsing variables");var o=e.value||[];if(!o.length)switch(r.flowGraphType){case"boolean":o.push(!1);break;case"FlowGraphInteger":o.push(0);break;case"number":o.push(NaN);break;case"Vector2":o.push(NaN,NaN);break;case"Vector3":o.push(NaN,NaN,NaN);break;case"Vector4":case"Matrix2D":case"Quaternion":o.fill(NaN,0,4);break;case"Matrix":o.fill(NaN,0,16);break;case"Matrix3D":o.fill(NaN,0,9)}return"number"===r.elementType&&"string"==typeof o[0]&&(o[0]=parseFloat(o[0])),{type:r.flowGraphType,value:n?n(o,this):o}},e.prototype._parseEvents=function(){var e=this;if(this._interactivityGraph.events)for(var n=function(n){var o={eventId:n.id||"internalEvent_"+r._internalEventsCounter++};n.values&&(o.eventData=Object.keys(n.values).map(function(r){var o,a=null===(o=n.values)||void 0===o?void 0:o[r];if(!a)throw t.Logger.Error(["No value found for event key",r]),new Error("Error parsing events");var i=e._types[a.type];if(!i)throw t.Logger.Error(["No type found for event value",a]),new Error("Error parsing events");var s=void 0!==a.value?e._parseVariable(a):void 0;return{id:r,type:i.flowGraphType,eventData:!0,value:s}})),r._events.push(o)},r=this,o=0,a=this._interactivityGraph.events;o<a.length;o++)n(a[o])},e.prototype._parseNodes=function(){var e;if(this._interactivityGraph.nodes)for(var n=0,r=this._interactivityGraph.nodes;n<r.length;n++){var o=r[n];if("number"!=typeof o.declaration)throw t.Logger.Error(["No declaration found for node",o]),new Error("Error parsing nodes");var a=this._mappings[o.declaration];if(!a)throw t.Logger.Error(["No mapping found for node",o]),new Error("Error parsing nodes");if(a.flowGraphMapping.validation){var i=a.flowGraphMapping.validation(o,this._interactivityGraph,this._gltf);if(!i.valid)throw new Error("Error validating interactivity node ".concat(null===(e=this._interactivityGraph.declarations)||void 0===e?void 0:e[o.declaration].op," - ").concat(i.error))}for(var s=[],l=0,u=a.flowGraphMapping.blocks;l<u.length;l++){var c=u[l],f=this._getEmptyBlock(c,a.fullOperationName);this._parseNodeConfiguration(o,f,a.flowGraphMapping,c),s.push(f)}this._nodes.push({blocks:s,fullOperationName:a.fullOperationName})}},e.prototype._getEmptyBlock=function(e,n){return{uniqueId:t.RandomGUID(),className:e,dataInputs:[],dataOutputs:[],signalInputs:[],signalOutputs:[],config:{},type:n,metadata:{}}},e.prototype._parseNodeConfiguration=function(e,n,r,o){var a,i=e.configuration;if(i)for(var s in i){var l=i[s];if(!l)throw new Error("Error parsing node configuration");var u=null===(a=r.configuration)||void 0===a?void 0:a[s];if(u&&u.toBlock?u.toBlock===o:0===r.blocks.indexOf(o)){var c=null==u?void 0:u.defaultValue;(null==l?void 0:l.value)&&(c=l.value),(null==u?void 0:u.isArray)||(1!==c.length&&t.Logger.Warn("Invalid non-array value length: ".concat(c.length)),c=c[0]),(null==u?void 0:u.dataTransformer)&&(c=u.dataTransformer(c,this)),void 0!==c&&(n.config[(null==u?void 0:u.name)||s]={value:c})}}},e.prototype._parseNodeConnections=function(e){for(var n,r,o,a,i,s,l,u,c,f,h,p,d,m,_,b,g,y,v,T=0;T<this._nodes.length;T++){var x=null===(n=this._interactivityGraph.nodes)||void 0===n?void 0:n[T];if(!x)throw t.Logger.Error(["No node found for interactivity node",this._nodes[T]]),new Error("Error parsing node connections");var A=this._nodes[T],C=this._mappings[x.declaration];if(!C)throw t.Logger.Error(["No mapping found for node",x]),new Error("Error parsing node connections");for(var w=x.flows||{},O=Object.keys(w).sort(),M=function(e){var n=w[e],c=null===(o=null===(r=C.flowGraphMapping.outputs)||void 0===r?void 0:r.flows)||void 0===o?void 0:o[e],f=(null==c?void 0:c.name)||e,h=R._createNewSocketConnection(f,!0);(c&&c.toBlock&&A.blocks.find(function(e){return e.className===c.toBlock})||A.blocks[0]).signalOutputs.push(h);var p=n.node,d=R._nodes[p];if(!d)throw t.Logger.Error(["No node found for input node id",p]),new Error("Error parsing node connections");var m=Qt(d.fullOperationName);if(!m)throw t.Logger.Error(["No mapping found for input node",d]),new Error("Error parsing node connections");var _=null===(i=null===(a=m.inputs)||void 0===a?void 0:a.flows)||void 0===i?void 0:i[n.socket||"in"],b=!1;if(!_)for(var g in null===(s=m.inputs)||void 0===s?void 0:s.flows)g.startsWith("[")&&g.endsWith("]")&&(b=!0,_=null===(u=null===(l=m.inputs)||void 0===l?void 0:l.flows)||void 0===u?void 0:u[g]);var y=_?b?_.name.replace("$1",n.socket||""):_.name:n.socket||"in",v=_&&_.toBlock&&d.blocks.find(function(e){return e.className===_.toBlock})||d.blocks[0],T=v.signalInputs.find(function(e){return e.name===y});T||(T=R._createNewSocketConnection(y),v.signalInputs.push(T)),T.connectedPointIds.push(h.uniqueId),h.connectedPointIds.push(T.uniqueId)},R=this,P=0,L=O;P<L.length;P++)M(L[P]);for(var F=x.values||{},E=Object.keys(F),S=function(n){var r=F[n],o=null===(f=null===(c=C.flowGraphMapping.inputs)||void 0===c?void 0:c.values)||void 0===f?void 0:f[n],a=!1;if(!o)for(var i in null===(h=C.flowGraphMapping.inputs)||void 0===h?void 0:h.values)i.startsWith("[")&&i.endsWith("]")&&(a=!0,o=null===(d=null===(p=C.flowGraphMapping.inputs)||void 0===p?void 0:p.values)||void 0===d?void 0:d[i]);var s=o?a?o.name.replace("$1",n):o.name:n,l=k._createNewSocketConnection(s);if((o&&o.toBlock&&A.blocks.find(function(e){return e.className===o.toBlock})||A.blocks[0]).dataInputs.push(l),void 0!==r.value){var u=k._parseVariable(r,o&&o.dataTransformer);e._connectionValues[l.uniqueId]=u}else{if(void 0===r.node)throw t.Logger.Error(["Invalid value for value connection",r]),new Error("Error parsing node connections");var v=r.node,T=r.socket||"value",x=k._nodes[v];if(!x)throw t.Logger.Error(["No node found for output socket reference",r]),new Error("Error parsing node connections");var w=Qt(x.fullOperationName);if(!w)throw t.Logger.Error(["No mapping found for output socket reference",r]),new Error("Error parsing node connections");var O=null===(_=null===(m=w.outputs)||void 0===m?void 0:m.values)||void 0===_?void 0:_[T],M=!1;if(!O)for(var i in null===(b=w.outputs)||void 0===b?void 0:b.values)i.startsWith("[")&&i.endsWith("]")&&(M=!0,O=null===(y=null===(g=w.outputs)||void 0===g?void 0:g.values)||void 0===y?void 0:y[i]);var R=O?M?O.name.replace("$1",T):null==O?void 0:O.name:T,P=O&&O.toBlock&&x.blocks.find(function(e){return e.className===O.toBlock})||x.blocks[0],L=P.dataOutputs.find(function(e){return e.name===R});L||(L=k._createNewSocketConnection(R,!0),P.dataOutputs.push(L)),l.connectedPointIds.push(L.uniqueId),L.connectedPointIds.push(l.uniqueId)}},k=this,I=0,B=E;I<B.length;I++)S(B[I]);if(C.flowGraphMapping.interBlockConnectors)for(var N=0,G=C.flowGraphMapping.interBlockConnectors;N<G.length;N++){var D=G[N],V=D.input,H=D.output,K=D.isVariable;this._connectFlowGraphNodes(V,H,A.blocks[D.inputBlockIndex],A.blocks[D.outputBlockIndex],K)}if(C.flowGraphMapping.extraProcessor){var j=null===(v=this._interactivityGraph.declarations)||void 0===v?void 0:v[x.declaration];if(!j)throw t.Logger.Error(["No declaration found for extra processor",x]),new Error("Error parsing node connections");A.blocks=C.flowGraphMapping.extraProcessor(x,j,C.flowGraphMapping,this,A.blocks,e,this._gltf)}}},e.prototype._createNewSocketConnection=function(e,n){return{uniqueId:t.RandomGUID(),name:e,_connectionType:n?1:0,connectedPointIds:[]}},e.prototype._connectFlowGraphNodes=function(e,t,n,r,o){var a=o?n.dataInputs:n.signalInputs,i=o?r.dataOutputs:r.signalOutputs,s=a.find(function(t){return t.name===e})||this._createNewSocketConnection(e),l=i.find(function(e){return e.name===t})||this._createNewSocketConnection(t,!0);a.find(function(t){return t.name===e})||a.push(s),i.find(function(e){return e.name===t})||i.push(l),s.connectedPointIds.push(l.uniqueId),l.connectedPointIds.push(s.uniqueId)},e.prototype.getVariableName=function(e){return"staticVariable_"+e},e.prototype.serializeToFlowGraph=function(){var e={uniqueId:t.RandomGUID(),_userVariables:{},_connectionValues:{}};this._parseNodeConnections(e);for(var n=0;n<this._staticVariables.length;n++){var r=this._staticVariables[n];e._userVariables[this.getVariableName(n)]=r}return{rightHanded:!0,allBlocks:this._nodes.reduce(function(e,t){return e.concat(t.blocks)},[]),executionContexts:[e]}},e}(),sn="KHR_interactivity",ln=function(){function e(e){this._loader=e,this.name=sn,this.enabled=this._loader.isExtensionUsed(sn),this._pathConverter=I(this._loader.gltf),e._skipStartAnimationStep=!0;var t=e.babylonScene;t&&un(t)}return e.prototype.dispose=function(){this._loader=null,delete this._pathConverter},e.prototype.onReady=function(){return a(this,void 0,void 0,function(){var e,n,r,o,s,l=this;return i(this,function(u){switch(u.label){case 0:return this._loader.babylonScene&&this._pathConverter?(e=this._loader.babylonScene,(n=null===(s=this._loader.gltf.extensions)||void 0===s?void 0:s.KHR_interactivity)?((r=new t.FlowGraphCoordinator({scene:e})).dispatchEventsSynchronously=!1,o=n.graphs.map(function(e){return new an(e,l._loader.gltf,l._loader.parent.targetFps).serializeToFlowGraph()}),[4,Promise.all(o.map(function(e){return a(l,void 0,void 0,function(){return i(this,function(n){switch(n.label){case 0:return[4,t.ParseFlowGraphAsync(e,{coordinator:r,pathConverter:this._pathConverter})];case 1:return[2,n.sent()]}})})}))]):[2]):[2];case 1:return u.sent(),r.start(),[2]}})})},e}();function un(e){G("/extensions/KHR_interactivity/?/activeCamera/rotation",{get:function(){if(!e.activeCamera)return new t.Quaternion(NaN,NaN,NaN,NaN);var n=t.Quaternion.FromRotationMatrix(e.activeCamera.getWorldMatrix()).normalize();return e.useRightHandedSystem||(n.w*=-1,n.x*=-1),n},type:"Quaternion",getTarget:function(){return e.activeCamera}}),G("/extensions/KHR_interactivity/?/activeCamera/position",{get:function(){if(!e.activeCamera)return new t.Vector3(NaN,NaN,NaN);var n=e.activeCamera.getWorldMatrix().getTranslation();return e.useRightHandedSystem||(n.x*=-1),n},type:"Vector3",getTarget:function(){return e.activeCamera}}),G("/animations/{}/extensions/KHR_interactivity/isPlaying",{get:function(e){var t,n;return null!==(n=null===(t=e._babylonAnimationGroup)||void 0===t?void 0:t.isPlaying)&&void 0!==n&&n},type:"boolean",getTarget:function(e){return e._babylonAnimationGroup}}),G("/animations/{}/extensions/KHR_interactivity/minTime",{get:function(e){var t,n;return(null!==(n=null===(t=e._babylonAnimationGroup)||void 0===t?void 0:t.from)&&void 0!==n?n:0)/60},type:"number",getTarget:function(e){return e._babylonAnimationGroup}}),G("/animations/{}/extensions/KHR_interactivity/maxTime",{get:function(e){var t,n;return(null!==(n=null===(t=e._babylonAnimationGroup)||void 0===t?void 0:t.to)&&void 0!==n?n:0)/60},type:"number",getTarget:function(e){return e._babylonAnimationGroup}}),G("/animations/{}/extensions/KHR_interactivity/playhead",{get:function(e){var t,n;return(null!==(n=null===(t=e._babylonAnimationGroup)||void 0===t?void 0:t.getCurrentFrame())&&void 0!==n?n:0)/60},type:"number",getTarget:function(e){return e._babylonAnimationGroup}}),G("/animations/{}/extensions/KHR_interactivity/virtualPlayhead",{get:function(e){var t,n;return(null!==(n=null===(t=e._babylonAnimationGroup)||void 0===t?void 0:t.getCurrentFrame())&&void 0!==n?n:0)/60},type:"number",getTarget:function(e){return e._babylonAnimationGroup}})}t.addToBlockFactory(sn,"FlowGraphGLTFDataProvider",function(){return a(void 0,void 0,void 0,function(){return i(this,function(e){switch(e.label){case 0:return[4,Promise.resolve().then(function(){return An})];case 1:return[2,e.sent().FlowGraphGLTFDataProvider]}})})}),K(sn),H(sn,!0,function(e){return new ln(e)});var cn="KHR_node_visibility";G("/nodes/{}/extensions/KHR_node_visibility/visible",{get:function(e){var t=e._babylonTransformNode;return!t||void 0===t.isVisible||t.isVisible},set:function(e,t){var n,r;null===(n=t._primitiveBabylonMeshes)||void 0===n||n.forEach(function(e){e.inheritVisibility=!0}),t._babylonTransformNode&&(t._babylonTransformNode.isVisible=e),null===(r=t._primitiveBabylonMeshes)||void 0===r||r.forEach(function(t){t.isVisible=e})},getTarget:function(e){return e._babylonTransformNode},getPropertyName:[function(){return"isVisible"}],type:"boolean"});var fn=function(){function e(e){this.name=cn,this._loader=e,this.enabled=e.isExtensionUsed(cn)}return e.prototype.onReady=function(){if(this._loader){var e=this._loader.gltf.nodes;if(e)for(var t=0,n=e;t<n.length;t++){var r=n[t],o=r._babylonTransformNode;o&&(o.inheritVisibility=!0,r.extensions&&r.extensions.KHR_node_visibility&&!1===r.extensions.KHR_node_visibility.visible&&(o.isVisible=!1))}}},e.prototype.dispose=function(){delete this._loader},e}();K(cn),H(cn,!0,function(e){return new fn(e)});var hn="KHR_node_selectability";Zt("event/onSelect",hn,{blocks:["FlowGraphMeshPickEventBlock","FlowGraphGetVariableBlock","FlowGraphIndexOfBlock","KHR_interactivity/FlowGraphGLTFDataProvider"],configuration:{stopPropagation:{name:"stopPropagation"},nodeIndex:{name:"variable",toBlock:"FlowGraphGetVariableBlock",dataTransformer:function(e){return"pickedMesh_"+e}}},outputs:{values:{selectedNodeIndex:{name:"index",toBlock:"FlowGraphIndexOfBlock"},controllerIndex:{name:"pointerId"},selectionPoint:{name:"pickedPoint"},selectionRayOrigin:{name:"pickOrigin"}},flows:{out:{name:"done"}}},interBlockConnectors:[{input:"asset",output:"value",inputBlockIndex:0,outputBlockIndex:1,isVariable:!0},{input:"array",output:"nodes",inputBlockIndex:2,outputBlockIndex:3,isVariable:!0},{input:"object",output:"pickedMesh",inputBlockIndex:2,outputBlockIndex:0,isVariable:!0}],extraProcessor:function(e,t,n,r,o,a,i){var s,l,u,c,f,h,p,d=o[o.length-1];d.config=d.config||{},d.config.glTF=i;var m=null===(u=null===(l=null===(s=e.configuration)||void 0===s?void 0:s.nodeIndex)||void 0===l?void 0:l.value)||void 0===u?void 0:u[0];if(void 0===m||"number"!=typeof m)throw new Error("nodeIndex not found in configuration");var _="pickedMesh_"+m;return o[1].config.variable=_,a._userVariables[_]={className:"Mesh",id:null===(f=null===(c=null==i?void 0:i.nodes)||void 0===c?void 0:c[m]._babylonTransformNode)||void 0===f?void 0:f.id,uniqueId:null===(p=null===(h=null==i?void 0:i.nodes)||void 0===h?void 0:h[m]._babylonTransformNode)||void 0===p?void 0:p.uniqueId},o}}),G("/nodes/{}/extensions/KHR_node_selectability/selectable",{get:function(e){var t=e._babylonTransformNode;return!t||void 0===t.isPickable||t.isPickable},set:function(e,t){var n;null===(n=t._primitiveBabylonMeshes)||void 0===n||n.forEach(function(t){t.isPickable=e})},getTarget:function(e){return e._babylonTransformNode},getPropertyName:[function(){return"isPickable"}],type:"boolean"});var pn=function(){function e(e){this.name=hn,this._loader=e,this.enabled=e.isExtensionUsed(hn)}return e.prototype.onReady=function(){return a(this,void 0,void 0,function(){var e;return i(this,function(t){return null===(e=this._loader.gltf.nodes)||void 0===e||e.forEach(function(e){var t,n,r;(null===(t=e.extensions)||void 0===t?void 0:t.KHR_node_selectability)&&!1===(null===(n=e.extensions)||void 0===n?void 0:n.KHR_node_selectability.selectable)&&(null===(r=e._babylonTransformNode)||void 0===r||r.getChildMeshes().forEach(function(e){e.isPickable=!1}))}),[2]})})},e.prototype.dispose=function(){this._loader=null},e}();K(hn),H(hn,!0,function(e){return new pn(e)});var dn="KHR_node_hoverability",mn="targetMeshPointerOver_";Zt("event/onHoverIn",dn,{blocks:["FlowGraphPointerOverEventBlock","FlowGraphGetVariableBlock","FlowGraphIndexOfBlock","KHR_interactivity/FlowGraphGLTFDataProvider"],configuration:{stopPropagation:{name:"stopPropagation"},nodeIndex:{name:"variable",toBlock:"FlowGraphGetVariableBlock",dataTransformer:function(e){return mn+e}}},outputs:{values:{hoverNodeIndex:{name:"index",toBlock:"FlowGraphIndexOfBlock"},controllerIndex:{name:"pointerId"}},flows:{out:{name:"done"}}},interBlockConnectors:[{input:"targetMesh",output:"value",inputBlockIndex:0,outputBlockIndex:1,isVariable:!0},{input:"array",output:"nodes",inputBlockIndex:2,outputBlockIndex:3,isVariable:!0},{input:"object",output:"meshUnderPointer",inputBlockIndex:2,outputBlockIndex:0,isVariable:!0}],extraProcessor:function(e,t,n,r,o,a,i){var s,l,u,c,f,h,p,d=o[o.length-1];d.config=d.config||{},d.config.glTF=i;var m=null===(u=null===(l=null===(s=e.configuration)||void 0===s?void 0:s.nodeIndex)||void 0===l?void 0:l.value)||void 0===u?void 0:u[0];if(void 0===m||"number"!=typeof m)throw new Error("nodeIndex not found in configuration");var _=mn+m;return o[1].config.variable=_,a._userVariables[_]={className:"Mesh",id:null===(f=null===(c=null==i?void 0:i.nodes)||void 0===c?void 0:c[m]._babylonTransformNode)||void 0===f?void 0:f.id,uniqueId:null===(p=null===(h=null==i?void 0:i.nodes)||void 0===h?void 0:h[m]._babylonTransformNode)||void 0===p?void 0:p.uniqueId},o}});var _n="targetMeshPointerOut_";Zt("event/onHoverOut",dn,{blocks:["FlowGraphPointerOutEventBlock","FlowGraphGetVariableBlock","FlowGraphIndexOfBlock","KHR_interactivity/FlowGraphGLTFDataProvider"],configuration:{stopPropagation:{name:"stopPropagation"},nodeIndex:{name:"variable",toBlock:"FlowGraphGetVariableBlock",dataTransformer:function(e){return _n+e}}},outputs:{values:{hoverNodeIndex:{name:"index",toBlock:"FlowGraphIndexOfBlock"},controllerIndex:{name:"pointerId"}},flows:{out:{name:"done"}}},interBlockConnectors:[{input:"targetMesh",output:"value",inputBlockIndex:0,outputBlockIndex:1,isVariable:!0},{input:"array",output:"nodes",inputBlockIndex:2,outputBlockIndex:3,isVariable:!0},{input:"object",output:"meshOutOfPointer",inputBlockIndex:2,outputBlockIndex:0,isVariable:!0}],extraProcessor:function(e,t,n,r,o,a,i){var s,l,u,c,f,h,p,d=o[o.length-1];d.config=d.config||{},d.config.glTF=i;var m=null===(u=null===(l=null===(s=e.configuration)||void 0===s?void 0:s.nodeIndex)||void 0===l?void 0:l.value)||void 0===u?void 0:u[0];if(void 0===m||"number"!=typeof m)throw new Error("nodeIndex not found in configuration");var _=_n+m;return o[1].config.variable=_,a._userVariables[_]={className:"Mesh",id:null===(f=null===(c=null==i?void 0:i.nodes)||void 0===c?void 0:c[m]._babylonTransformNode)||void 0===f?void 0:f.id,uniqueId:null===(p=null===(h=null==i?void 0:i.nodes)||void 0===h?void 0:h[m]._babylonTransformNode)||void 0===p?void 0:p.uniqueId},o}}),G("/nodes/{}/extensions/KHR_node_hoverability/hoverable",{get:function(e){var t=e._babylonTransformNode;return!t||void 0===t.pointerOverDisableMeshTesting||t.pointerOverDisableMeshTesting},set:function(e,t){var n;null===(n=t._primitiveBabylonMeshes)||void 0===n||n.forEach(function(t){t.pointerOverDisableMeshTesting=!e})},getTarget:function(e){return e._babylonTransformNode},getPropertyName:[function(){return"pointerOverDisableMeshTesting"}],type:"boolean"});var bn=function(){function e(e){this.name=dn,this._loader=e,this.enabled=e.isExtensionUsed(dn)}return e.prototype.onReady=function(){return a(this,void 0,void 0,function(){var e;return i(this,function(t){return null===(e=this._loader.gltf.nodes)||void 0===e||e.forEach(function(e){var t,n,r;(null===(t=e.extensions)||void 0===t?void 0:t.KHR_node_hoverability)&&!1===(null===(n=e.extensions)||void 0===n?void 0:n.KHR_node_hoverability.hoverable)&&(null===(r=e._babylonTransformNode)||void 0===r||r.getChildMeshes().forEach(function(e){e.pointerOverDisableMeshTesting=!0}))}),[2]})})},e.prototype.dispose=function(){this._loader=null},e}();K(dn),H(dn,!0,function(e){return new bn(e)});var gn="ExtrasAsMetadata",yn=function(){function e(e){this.name=gn,this.enabled=!0,this._loader=e}return e.prototype._assignExtras=function(e,t){if(t.extras&&Object.keys(t.extras).length>0){var n=e.metadata=e.metadata||{};(n.gltf=n.gltf||{}).extras=t.extras}},e.prototype.dispose=function(){this._loader=null},e.prototype.loadNodeAsync=function(e,t,n){var r=this;return this._loader.loadNodeAsync(e,t,function(e){r._assignExtras(e,t),n(e)})},e.prototype.loadCameraAsync=function(e,t,n){var r=this;return this._loader.loadCameraAsync(e,t,function(e){r._assignExtras(e,t),n(e)})},e.prototype.createMaterial=function(e,t,n){var r=this._loader.createMaterial(e,t,n);return this._assignExtras(r,t),r},e.prototype.loadAnimationAsync=function(e,t){var n=this;return this._loader.loadAnimationAsync(e,t).then(function(e){return n._assignExtras(e,t),e})},e}();K(gn),H(gn,!1,function(e){return new yn(e)});var vn,Tn,xn=function(e){function n(n){var r,o,a=e.call(this,n)||this,i=n.glTF,s=(null===(r=null==i?void 0:i.animations)||void 0===r?void 0:r.map(function(e){return e._babylonAnimationGroup}))||[];a.animationGroups=a.registerDataOutput("animationGroups",t.RichTypeAny,s);var l=(null===(o=null==i?void 0:i.nodes)||void 0===o?void 0:o.map(function(e){return e._babylonTransformNode}))||[];return a.nodes=a.registerDataOutput("nodes",t.RichTypeAny,l),a}return r(n,e),n.prototype.getClassName=function(){return"FlowGraphGLTFDataProvider"},n}(t.FlowGraphBlock),An={__proto__:null,FlowGraphGLTFDataProvider:xn},Cn={__proto__:null,AddObjectAccessorToKey:G,EXT_lights_area:fe,EXT_lights_ies:ae,EXT_lights_image_based:X,EXT_mesh_gpu_instancing:J,EXT_meshopt_compression:$,EXT_texture_avif:re,EXT_texture_webp:te,ExtrasAsMetadata:yn,FlowGraphGLTFDataProvider:xn,GetMappingForKey:B,GetPathToObjectConverter:I,InteractivityGraphToFlowGraphParser:an,KHR_animation_pointer:Ht,KHR_draco_mesh_compression:se,KHR_interactivity:ln,KHR_lights:ue,KHR_materials_anisotropy:Ae,KHR_materials_clearcoat:be,KHR_materials_coat:ye,KHR_materials_diffuse_roughness:Xe,KHR_materials_diffuse_transmission:He,KHR_materials_dispersion:qe,KHR_materials_emissive_strength:we,KHR_materials_fuzz:Pe,KHR_materials_ior:Se,KHR_materials_iridescence:Te,KHR_materials_pbrSpecularGlossiness:pe,KHR_materials_sheen:Me,KHR_materials_specular:Fe,KHR_materials_transmission:De,KHR_materials_unlit:me,KHR_materials_variants:Ie,KHR_materials_volume:je,KHR_materials_volume_scatter:Ue,KHR_mesh_quantization:Je,KHR_node_hoverability:bn,KHR_node_selectability:pn,KHR_node_visibility:fn,KHR_texture_basisu:$e,KHR_texture_transform:tt,KHR_xmp_json_ld:rt,MSFT_audio_emitter:jt,MSFT_lod:Ut,MSFT_minecraftMesh:qt,MSFT_sRGBFactors:Xt,SetInterpolationForKey:N,TransmissionHelper:Be,_AddInteractivityObjectModel:un,addNewInteractivityFlowGraphMapping:Zt,ensureTransmissionHelper:Ne,getAllSupportedNativeNodeTypes:rn,getMappingForDeclaration:Jt,getMappingForFullOperationName:Qt,gltfTypeToBabylonType:on},wn=function(){function e(e){this._specWorkflow=!1,this._diffuseTransmissionTint=t.Color3.White(),this._diffuseTransmissionTintTexture=null,this._material=e}return Object.defineProperty(e.prototype,"material",{get:function(){return this._material},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isUnlit",{get:function(){return this._material.unlit},set:function(e){this._material.unlit=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"backFaceCulling",{get:function(){return this._material.backFaceCulling},set:function(e){this._material.backFaceCulling=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"twoSidedLighting",{get:function(){return this._material.twoSidedLighting},set:function(e){this._material.twoSidedLighting=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"alphaCutOff",{get:function(){return.5},set:function(e){},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"useAlphaFromBaseColorTexture",{get:function(){return!1},set:function(e){this._material._useAlphaFromBaseColorTexture=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"transparencyAsAlphaCoverage",{get:function(){return!1},set:function(e){},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"baseColor",{get:function(){return this._material.baseColor},set:function(e){this._material.baseColor=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"baseColorTexture",{get:function(){return this._material.baseColorTexture},set:function(e){this._material.baseColorTexture=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"baseDiffuseRoughness",{get:function(){return this._material.baseDiffuseRoughness},set:function(e){this._material.baseDiffuseRoughness=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"baseDiffuseRoughnessTexture",{get:function(){return this._material.baseDiffuseRoughnessTexture},set:function(e){this._material.baseDiffuseRoughnessTexture=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"baseMetalness",{get:function(){return this._material.baseMetalness},set:function(e){this._material.baseMetalness=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"baseMetalnessTexture",{get:function(){return this._material.baseMetalnessTexture},set:function(e){this._material.baseMetalnessTexture=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"useRoughnessFromMetallicTextureGreen",{set:function(e){this._material._useRoughnessFromMetallicTextureGreen=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"useMetallicFromMetallicTextureBlue",{set:function(e){this._material._useMetallicFromMetallicTextureBlue=e},enumerable:!1,configurable:!0}),e.prototype.enableSpecularEdgeColor=function(e){void 0===e&&(e=!1)},e.prototype.configureSpecularGlossiness=function(){this._specWorkflow=!0},Object.defineProperty(e.prototype,"specularWeight",{get:function(){return this._material.specularWeight},set:function(e){this._material.specularWeight=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"specularWeightTexture",{get:function(){return this._material.specularWeightTexture},set:function(e){this._material.specularColorTexture===e?(this._material.specularWeightTexture=null,this._material._useSpecularWeightFromSpecularColorTexture=!0,this._material._useSpecularWeightFromAlpha=!0):this._material.specularWeightTexture=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"specularColor",{get:function(){return this._material.specularColor},set:function(e){this._material.specularColor=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"specularColorTexture",{get:function(){return this._material.specularColorTexture},set:function(e){this._material.specularColorTexture=e,this._material.specularWeightTexture===this._material.specularColorTexture&&(this._material.specularWeightTexture=null,this._material._useSpecularWeightFromSpecularColorTexture=!0,this._material._useSpecularWeightFromAlpha=!0)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"specularRoughness",{get:function(){return this._material.specularRoughness},set:function(e){this._material.specularRoughness=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"specularRoughnessTexture",{get:function(){return this._material.specularRoughnessTexture},set:function(e){this._material.specularRoughnessTexture=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"specularIor",{get:function(){return this._material.specularIor},set:function(e){this._material.specularIor=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"glossiness",{get:function(){return 1-this._material.specularRoughness},set:function(e){this._material.specularRoughness=Math.max(1-e,0)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"emissionColor",{get:function(){return this._material.emissionColor},set:function(e){this._material.emissionColor=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"emissionLuminance",{get:function(){return this._material.emissionLuminance},set:function(e){this._material.emissionLuminance=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"emissionColorTexture",{get:function(){return this._material.emissionColorTexture},set:function(e){this._material.emissionColorTexture=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"ambientOcclusionTexture",{get:function(){return this._material.ambientOcclusionTexture},set:function(e){this._material.ambientOcclusionTexture=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"ambientOcclusionTextureStrength",{get:function(){var e,t=this._material.ambientOcclusionTexture;return null!==(e=null==t?void 0:t.level)&&void 0!==e?e:1},set:function(e){var t=this._material.ambientOcclusionTexture;t&&(t.level=e)},enumerable:!1,configurable:!0}),e.prototype.configureCoat=function(){},Object.defineProperty(e.prototype,"coatWeight",{get:function(){return this._material.coatWeight},set:function(e){this._material.coatWeight=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"coatWeightTexture",{get:function(){return this._material.coatWeightTexture},set:function(e){this._material.coatWeightTexture=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"coatColor",{get:function(){return this._material.coatColor},set:function(e){this._material.coatColor=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"coatColorTexture",{set:function(e){this._material.coatColorTexture=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"coatRoughness",{get:function(){return this._material.coatRoughness},set:function(e){this._material.coatRoughness=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"coatRoughnessTexture",{get:function(){return this._material.coatRoughnessTexture},set:function(e){this._material.coatRoughnessTexture=e,e&&(this._material._useCoatRoughnessFromGreenChannel=!0)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"coatIor",{get:function(){return this._material.coatIor},set:function(e){this._material.coatIor=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"coatDarkening",{get:function(){return this._material.coatDarkening},set:function(e){this._material.coatDarkening=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"coatDarkeningTexture",{set:function(e){this._material.coatDarkeningTexture=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"coatRoughnessAnisotropy",{get:function(){return this._material.coatRoughnessAnisotropy},set:function(e){this._material.coatRoughnessAnisotropy=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"geometryCoatTangentAngle",{set:function(e){this._material.geometryCoatTangentAngle=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"geometryCoatTangentTexture",{get:function(){return this._material.geometryCoatTangentTexture},set:function(e){this._material.geometryCoatTangentTexture=e,e&&(this._material._useCoatRoughnessAnisotropyFromTangentTexture=!0)},enumerable:!1,configurable:!0}),e.prototype.configureTransmission=function(){this._material.geometryThinWalled=1,this._material.transmissionDepth=0},Object.defineProperty(e.prototype,"transmissionWeight",{get:function(){return this._material.transmissionWeight},set:function(e){this._material.transmissionWeight=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"transmissionWeightTexture",{get:function(){return this._material.transmissionWeightTexture},set:function(e){this._material.transmissionWeightTexture=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"transmissionScatter",{get:function(){return this._material.transmissionScatter},set:function(e){this._material.transmissionScatter=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"transmissionScatterTexture",{get:function(){return this._material.transmissionScatterTexture},set:function(e){this._material.transmissionScatterTexture=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"transmissionScatterAnisotropy",{set:function(e){this._material.transmissionScatterAnisotropy=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"transmissionDispersionAbbeNumber",{set:function(e){this._material.transmissionDispersionAbbeNumber=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"transmissionDispersionScale",{set:function(e){this._material.transmissionDispersionScale=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"transmissionDepth",{get:function(){return this._material.transmissionDepth},set:function(e){e!==Number.MAX_VALUE||0!==this._material.transmissionDepth?this._material.transmissionDepth=e:this._material.transmissionDepth=0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"transmissionColor",{get:function(){return this._material.transmissionColor},set:function(e){e.equals(t.Color3.White())||(this._material.transmissionColor=e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"refractionBackgroundTexture",{get:function(){return this._material.backgroundRefractionTexture},set:function(e){this._material.backgroundRefractionTexture=e},enumerable:!1,configurable:!0}),e.prototype.configureVolume=function(){this._material.geometryThinWalled=0},Object.defineProperty(e.prototype,"geometryThinWalled",{get:function(){return!!this._material.geometryThinWalled},set:function(e){this._material.geometryThinWalled=e?1:0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"volumeThicknessTexture",{set:function(e){this._material.geometryThicknessTexture=e,this._material._useGeometryThicknessFromGreenChannel=!0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"volumeThickness",{set:function(e){this._material.geometryThickness=e},enumerable:!1,configurable:!0}),e.prototype.configureSubsurface=function(){this._material.geometryThinWalled=1,this._material.subsurfaceScatterAnisotropy=1},Object.defineProperty(e.prototype,"subsurfaceWeight",{get:function(){return this._material.subsurfaceWeight},set:function(e){this._material.subsurfaceWeight=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"subsurfaceWeightTexture",{get:function(){return this._material.subsurfaceWeightTexture},set:function(e){this._material.subsurfaceWeightTexture=e,this._material._useSubsurfaceWeightFromTextureAlpha=!0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"subsurfaceColor",{set:function(e){this._material.subsurfaceColor=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"subsurfaceColorTexture",{set:function(e){this._material.subsurfaceColorTexture=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"diffuseTransmissionTint",{get:function(){return this._diffuseTransmissionTint},set:function(e){this._diffuseTransmissionTint=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"diffuseTransmissionTintTexture",{set:function(e){this._diffuseTransmissionTintTexture=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"subsurfaceRadius",{get:function(){return this._material.subsurfaceRadius},set:function(e){this._material.subsurfaceRadius=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"subsurfaceRadiusScale",{get:function(){return this._material.subsurfaceRadiusScale},set:function(e){this._material.subsurfaceRadiusScale=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"subsurfaceScatterAnisotropy",{set:function(e){this._material.subsurfaceScatterAnisotropy=e},enumerable:!1,configurable:!0}),e.prototype.isTranslucent=function(){return this.transmissionWeight>0||this.subsurfaceWeight>0},e.prototype.configureFuzz=function(){},Object.defineProperty(e.prototype,"fuzzWeight",{set:function(e){this._material.fuzzWeight=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"fuzzWeightTexture",{set:function(e){this._material.fuzzWeightTexture=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"fuzzColor",{set:function(e){this._material.fuzzColor=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"fuzzColorTexture",{set:function(e){this._material.fuzzColorTexture=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"fuzzRoughness",{set:function(e){this._material.fuzzRoughness=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"fuzzRoughnessTexture",{set:function(e){this._material.fuzzRoughnessTexture=e,this._material._useFuzzRoughnessFromTextureAlpha=!0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"specularRoughnessAnisotropy",{get:function(){return this._material.specularRoughnessAnisotropy},set:function(e){this._material.specularRoughnessAnisotropy=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"geometryTangentAngle",{set:function(e){this._material.geometryTangentAngle=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"geometryTangentTexture",{get:function(){return this._material.geometryTangentTexture},set:function(e){this._material.geometryTangentTexture=e,this._material._useSpecularRoughnessAnisotropyFromTangentTexture=!0},enumerable:!1,configurable:!0}),e.prototype.configureGltfStyleAnisotropy=function(e){void 0===e&&(e=!0),this._material._useGltfStyleAnisotropy=e},Object.defineProperty(e.prototype,"thinFilmWeight",{set:function(e){this._material.thinFilmWeight=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"thinFilmIor",{set:function(e){this._material.thinFilmIor=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"thinFilmThicknessMinimum",{set:function(e){this._material.thinFilmThicknessMin=e/1e3},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"thinFilmThicknessMaximum",{set:function(e){this._material.thinFilmThickness=e/1e3},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"thinFilmWeightTexture",{set:function(e){this._material.thinFilmWeightTexture=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"thinFilmThicknessTexture",{set:function(e){this._material.thinFilmThicknessTexture=e,this._material._useThinFilmThicknessFromTextureGreen=!0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"unlit",{set:function(e){this._material.unlit=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"geometryOpacity",{get:function(){return this._material.geometryOpacity},set:function(e){this._material.geometryOpacity=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"geometryNormalTexture",{get:function(){return this._material.geometryNormalTexture},set:function(e){this._material.geometryNormalTexture=e},enumerable:!1,configurable:!0}),e.prototype.setNormalMapInversions=function(e,t){},Object.defineProperty(e.prototype,"geometryCoatNormalTexture",{get:function(){return this._material.geometryCoatNormalTexture},set:function(e){this._material.geometryCoatNormalTexture=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"geometryCoatNormalTextureScale",{set:function(e){this._material.geometryCoatNormalTexture&&(this._material.geometryCoatNormalTexture.level=e)},enumerable:!1,configurable:!0}),e.prototype.finalizeAsync=function(e){return a(this,void 0,void 0,function(){var n,r,a,s,l,u,c,f,h,p;return i(this,function(i){switch(i.label){case 0:return this._diffuseTransmissionTint&&!this._diffuseTransmissionTint.equals(t.Color3.White())||this._diffuseTransmissionTintTexture?this._material.geometryThinWalled?(this.subsurfaceColor=this._diffuseTransmissionTint,this.subsurfaceColorTexture=this._diffuseTransmissionTintTexture,[3,3]):[3,1]:[3,3];case 1:return[4,this.copySurfaceToCoatAsync(e,this.subsurfaceWeight,this.subsurfaceWeightTexture,t.TextureChannel.A,this._diffuseTransmissionTint,this._diffuseTransmissionTintTexture,!0)];case 2:if(i.sent(),e._disposed)return[2];i.label=3;case 3:return this.transmissionWeight>0?this._material.geometryThinWalled||0===this._material.transmissionDepth?(this._material.transmissionColor=this._material.baseColor,this._material.transmissionColorTexture=this._material.baseColorTexture,[3,6]):[3,4]:[3,6];case 4:return this.baseColor.equals(t.Color3.White())&&null===this.baseColorTexture?[3,6]:[4,this.copySurfaceToCoatAsync(e,this.transmissionWeight,this.transmissionWeightTexture,t.TextureChannel.R,this.baseColor,this.baseColorTexture,!1)];case 5:if(i.sent(),e._disposed)return[2];i.label=6;case 6:return this._specWorkflow?(r=t.InvertTextureAsync,a=["newRoughnessTexture ("+this._material.name+")"],[4,t.ExtractChannelAsync("glossiness ("+this._material.name+")",t.CreateTextureWithFactorOperand(this.specularColorTexture,new t.Color4(this.specularColor.r,this.specularColor.g,this.specularColor.b,this.glossiness),t.TextureChannel.A,t.TextureColorSpace.Linear),t.TextureChannel.A,this._material.getScene(),t.TextureColorSpace.Linear,t.ChannelMask.R)]):[3,11];case 7:return[4,r.apply(void 0,a.concat([i.sent(),this._material.getScene(),t.ChannelMask.R,t.TextureColorSpace.Linear,t.ChannelMask.R]))];case 8:return n=i.sent(),e._disposed?(null===(f=n.texture)||void 0===f||f.dispose(),[2]):(this.specularRoughnessTexture=n.texture,this.specularRoughness=n.factor?n.factor.r:1,[4,t.ExtractMaxChannelAsync("metallicTexture ("+this._material.name+")",t.CreateTextureWithFactorOperand(this.specularColorTexture,this.specularColor.toColor4(),t.TextureChannel.RGBA,t.TextureColorSpace.Linear),this._material.getScene(),!1,t.TextureColorSpace.SRGB,t.ChannelMask.RGB)]);case 9:return s=i.sent(),e._disposed?(null===(h=s.texture)||void 0===h||h.dispose(),[2]):(this.baseMetalnessTexture=s.texture,this.baseMetalness=s.factor?s.factor.r:1,[4,t.LerpTexturesAsync("newBaseColor ("+this._material.name+")",t.CreateTextureWithFactorOperand(this.baseColorTexture,this.baseColor.toColor4(),t.TextureChannel.RGBA,t.TextureColorSpace.Linear),t.CreateTextureWithFactorOperand(this.specularColorTexture,this.specularColor.toColor4(),t.TextureChannel.RGBA,t.TextureColorSpace.Linear),o(o({},s),{dispose:void 0,colorSpace:t.TextureColorSpace.Linear}),this._material.getScene(),t.TextureColorSpace.SRGB,t.ChannelMask.RGB)]);case 10:if(l=i.sent(),e._disposed)return null===(p=l.texture)||void 0===p||p.dispose(),[2];null==(u=this.baseColorTexture)||u.dispose(),this.baseColorTexture=l.texture,this.baseColor=l.factor?new t.Color3(l.factor.r,l.factor.g,l.factor.b):t.Color3.White(),null==(c=this.specularColorTexture)||c.dispose(),this.specularColorTexture=null,i.label=11;case 11:return[2]}})})},e.prototype.copySurfaceToCoatAsync=function(e,n,r,o,s,l){return a(this,arguments,void 0,function(e,n,r,o,a,s,l){var u,c,f,h,p,d,m,_,b,g,y,v,T,x,A,C,w,O,M,R,P,L,F,E,S,k,I,B,N,G;return void 0===l&&(l=!1),i(this,function(i){switch(i.label){case 0:return u=this._material.coatWeight,c=this._material.coatWeightTexture,f=this._material.coatColor.clone(),h=this._material.coatColorTexture,p=this._material.geometryCoatNormalTexture,d=new t.Color4(u,u,u,u),m=new t.Color4(n,n,n,n),this.coatWeightTexture=null,this.coatWeight=1,[4,Promise.allSettled([t.LerpTexturesAsync("lerpExistingCoat",t.CreateTextureWithFactorOperand(null,new t.Color4(1,1,1,1)),t.CreateTextureWithFactorOperand(h,f.toColor4(),t.TextureChannel.RGBA,t.TextureColorSpace.SRGB),t.CreateTextureWithFactorOperand(c,d,t.TextureChannel.R),this._material.getScene(),t.TextureColorSpace.SRGB),t.LerpTexturesAsync("lerpSurfaceColor",t.CreateTextureWithFactorOperand(null,new t.Color4(1,1,1,1)),t.CreateTextureWithFactorOperand(s,a.toColor4(),t.TextureChannel.RGBA,t.TextureColorSpace.SRGB),t.CreateTextureWithFactorOperand(r,m,o),this._material.getScene(),t.TextureColorSpace.SRGB)])];case 1:if(_=i.sent(),b=_.find(function(e){return"rejected"===e.status}),b){for(g=0,y=_;g<y.length;g++)"fulfilled"===(v=y[g]).status&&(null===(L=v.value.texture)||void 0===L||L.dispose());throw b.reason}return T=_.map(function(e){return e.value}),x=T[0],A=T[1],e._disposed?(null===(F=x.texture)||void 0===F||F.dispose(),null===(E=A.texture)||void 0===E||E.dispose(),[2]):[4,t.MultiplyTexturesAsync("newCoatColor ("+this._material.name+")",x,A,this._material.getScene(),t.TextureColorSpace.SRGB)];case 2:return C=i.sent(),e._disposed?(null===(S=C.texture)||void 0===S||S.dispose(),[2]):(C.texture?(this.coatColorTexture=C.texture,this.coatColor=t.Color3.White()):C.factor&&(this.coatColorTexture=null,this.coatColor.fromArray([C.factor.r,C.factor.g,C.factor.b])),[4,t.LerpTexturesAsync("newCoatIor ("+this._material.name+")",t.CreateTextureWithFactorOperand(null,new t.Color4(this._material.specularIor,this._material.specularIor,this._material.specularIor,1),t.TextureChannel.R),t.CreateTextureWithFactorOperand(null,new t.Color4(this.coatIor,this.coatIor,this.coatIor,1),t.TextureChannel.R),t.CreateTextureWithFactorOperand(c,d,t.TextureChannel.R),this._material.getScene())]);case 3:return w=i.sent(),e._disposed?(null===(k=w.texture)||void 0===k||k.dispose(),[2]):(this.coatIor=w.factor?w.factor.r:this.coatIor,[4,t.LerpTexturesAsync("newCoatRoughness ("+this._material.name+")",t.CreateTextureWithFactorOperand(this.specularRoughnessTexture,new t.Color4(this.specularRoughness,this.specularRoughness,this.specularRoughness,1),t.TextureChannel.G),t.CreateTextureWithFactorOperand(this.coatRoughnessTexture,new t.Color4(this.coatRoughness,this.coatRoughness,this.coatRoughness,1),t.TextureChannel.G),t.CreateTextureWithFactorOperand(c,d,t.TextureChannel.R),this._material.getScene())]);case 4:return O=i.sent(),e._disposed?(null===(I=O.texture)||void 0===I||I.dispose(),[2]):(this.coatRoughness=O.factor?O.factor.r:1,this.coatRoughnessTexture=O.texture,[4,t.LerpTexturesAsync("newCoatDarkening ("+this._material.name+")",t.CreateTextureWithFactorOperand(null,new t.Color4(0,0,0,1),t.TextureChannel.R),t.CreateTextureWithFactorOperand(null,new t.Color4(this.coatDarkening,this.coatDarkening,this.coatDarkening,1),t.TextureChannel.R),t.CreateTextureWithFactorOperand(c,d,t.TextureChannel.R),this._material.getScene())]);case 5:return M=i.sent(),e._disposed?(null===(B=M.texture)||void 0===B||B.dispose(),[2]):(this.coatDarkening=M.factor?M.factor.r:this.coatDarkening,l?[4,t.LerpTexturesAsync("newSpecularRoughness ("+this._material.name+")",t.CreateTextureWithFactorOperand(this.specularRoughnessTexture,new t.Color4(this._material.specularRoughness,this._material.specularRoughness,this._material.specularRoughness,1),t.TextureChannel.G),t.CreateTextureWithFactorOperand(null,new t.Color4(1,1,1,1),t.TextureChannel.R),t.CreateTextureWithFactorOperand(r,m,o),this._material.getScene())]:[3,7]);case 6:if(R=i.sent(),e._disposed)return null===(N=R.texture)||void 0===N||N.dispose(),[2];this.specularRoughness=R.factor?R.factor.r:1,this.specularRoughnessTexture=R.texture,i.label=7;case 7:return p||this.geometryNormalTexture?[4,t.LerpTexturesAsync("newCoatNormal ("+this._material.name+")",t.CreateTextureWithFactorOperand(this.geometryNormalTexture,this.geometryNormalTexture?new t.Color4(1,1,1,1):new t.Color4(.5,.5,1,1),t.TextureChannel.RGBA),t.CreateTextureWithFactorOperand(p,p?new t.Color4(1,1,1,1):new t.Color4(.5,.5,1,1),t.TextureChannel.RGBA),t.CreateTextureWithFactorOperand(c,d,t.TextureChannel.R),this._material.getScene())]:[3,9];case 8:if(P=i.sent(),e._disposed)return null===(G=P.texture)||void 0===G||G.dispose(),[2];P.texture&&(this.geometryCoatNormalTexture=P.texture),i.label=9;case 9:return[2]}})})},e}(),On={__proto__:null,OpenPBRMaterialLoadingAdapter:wn},Mn=function(){function e(e){this._specWorkflow=!1,this._material=e,this._material.enableSpecularAntiAliasing=!0}return Object.defineProperty(e.prototype,"material",{get:function(){return this._material},enumerable:!1,configurable:!0}),e.prototype.finalizeAsync=function(e){return a(this,void 0,void 0,function(){return i(this,function(e){return[2]})})},Object.defineProperty(e.prototype,"isUnlit",{get:function(){return this._material.unlit},set:function(e){this._material.unlit=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"backFaceCulling",{get:function(){return this._material.backFaceCulling},set:function(e){this._material.backFaceCulling=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"twoSidedLighting",{get:function(){return this._material.twoSidedLighting},set:function(e){this._material.twoSidedLighting=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"alphaCutOff",{get:function(){return this._material.alphaCutOff},set:function(e){this._material.alphaCutOff=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"useAlphaFromBaseColorTexture",{get:function(){return this._material.useAlphaFromAlbedoTexture},set:function(e){this._material.useAlphaFromAlbedoTexture=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"transparencyAsAlphaCoverage",{get:function(){return this._material.useRadianceOverAlpha||this._material.useSpecularOverAlpha},set:function(e){this._material.useRadianceOverAlpha=!e,this._material.useSpecularOverAlpha=!e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"baseColor",{get:function(){return this._material.albedoColor},set:function(e){this._material.albedoColor=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"baseColorTexture",{get:function(){return this._material.albedoTexture},set:function(e){this._material.albedoTexture=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"baseDiffuseRoughness",{get:function(){var e;return null!==(e=this._material.baseDiffuseRoughness)&&void 0!==e?e:0},set:function(e){this._material.baseDiffuseRoughness=e,e>0&&(this._material.brdf.baseDiffuseModel=t.Constants.MATERIAL_DIFFUSE_MODEL_E_OREN_NAYAR)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"baseDiffuseRoughnessTexture",{get:function(){return this._material.baseDiffuseRoughnessTexture},set:function(e){this._material.baseDiffuseRoughnessTexture=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"baseMetalness",{get:function(){var e;return null!==(e=this._material.metallic)&&void 0!==e?e:1},set:function(e){this._material.metallic=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"baseMetalnessTexture",{get:function(){return this._material.metallicTexture},set:function(e){this._material.metallicTexture=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"useRoughnessFromMetallicTextureGreen",{set:function(e){this._material.useRoughnessFromMetallicTextureGreen=e,this._material.useRoughnessFromMetallicTextureAlpha=!e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"useMetallicFromMetallicTextureBlue",{set:function(e){this._material.useMetallnessFromMetallicTextureBlue=e},enumerable:!1,configurable:!0}),e.prototype.enableSpecularEdgeColor=function(e){void 0===e&&(e=!1),e&&(this._material.brdf.dielectricSpecularModel=t.Constants.MATERIAL_DIELECTRIC_SPECULAR_MODEL_OPENPBR,this._material.brdf.conductorSpecularModel=t.Constants.MATERIAL_CONDUCTOR_SPECULAR_MODEL_OPENPBR)},e.prototype.configureSpecularGlossiness=function(){this._specWorkflow=!0,this._material.metallic=null,this._material.roughness=null,this._material.useMicroSurfaceFromReflectivityMapAlpha=!0},Object.defineProperty(e.prototype,"specularWeight",{get:function(){var e;return null!==(e=this._material.metallicF0Factor)&&void 0!==e?e:1},set:function(e){this._material.metallicF0Factor=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"specularWeightTexture",{get:function(){return this._material.metallicReflectanceTexture},set:function(e){e?(this._material.metallicReflectanceTexture=e,this._material.useOnlyMetallicFromMetallicReflectanceTexture=!0):(this._material.metallicReflectanceTexture=null,this._material.useOnlyMetallicFromMetallicReflectanceTexture=!1)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"specularColor",{get:function(){return this._specWorkflow?this._material.reflectivityColor:this._material.metallicReflectanceColor},set:function(e){this._specWorkflow?this._material.reflectivityColor=e:this._material.metallicReflectanceColor=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"specularColorTexture",{get:function(){return this._specWorkflow?this._material.reflectivityTexture:this._material.reflectanceTexture},set:function(e){this._specWorkflow?(this._material.reflectivityTexture=e,this._material.reflectivityTexture&&(this._material.reflectivityTexture.hasAlpha=!0)):this._material.reflectanceTexture=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"specularRoughness",{get:function(){var e;return null!==(e=this._material.roughness)&&void 0!==e?e:1},set:function(e){this._material.roughness=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"specularRoughnessTexture",{get:function(){return this._material.metallicTexture},set:function(e){this.baseMetalnessTexture||(this._material.metallicTexture=e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"specularIor",{get:function(){return this._material.indexOfRefraction},set:function(e){this._material.indexOfRefraction=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"glossiness",{get:function(){var e;return null!==(e=this._material.microSurface)&&void 0!==e?e:1},set:function(e){this._material.microSurface=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"emissionColor",{get:function(){return this._material.emissiveColor},set:function(e){this._material.emissiveColor=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"emissionLuminance",{get:function(){return this._material.emissiveIntensity},set:function(e){this._material.emissiveIntensity=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"emissionColorTexture",{get:function(){return this._material.emissiveTexture},set:function(e){this._material.emissiveTexture=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"ambientOcclusionTexture",{get:function(){return this._material.ambientTexture},set:function(e){this._material.ambientTexture=e,e&&(this._material.useAmbientInGrayScale=!0)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"ambientOcclusionTextureStrength",{get:function(){var e;return null!==(e=this._material.ambientTextureStrength)&&void 0!==e?e:1},set:function(e){this._material.ambientTextureStrength=e},enumerable:!1,configurable:!0}),e.prototype.configureCoat=function(){this._material.clearCoat.isEnabled=!0,this._material.clearCoat.useRoughnessFromMainTexture=!1,this._material.clearCoat.remapF0OnInterfaceChange=!1},Object.defineProperty(e.prototype,"coatWeight",{get:function(){return this._material.clearCoat.intensity},set:function(e){this._material.clearCoat.isEnabled=!0,this._material.clearCoat.intensity=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"coatWeightTexture",{get:function(){return this._material.clearCoat.texture},set:function(e){this._material.clearCoat.isEnabled=!0,this._material.clearCoat.texture=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"coatColor",{set:function(e){this._material.clearCoat.isTintEnabled=e!=t.Color3.White(),this._material.clearCoat.tintColor=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"coatColorTexture",{set:function(e){this._material.clearCoat.tintTexture=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"coatRoughness",{get:function(){var e;return null!==(e=this._material.clearCoat.roughness)&&void 0!==e?e:0},set:function(e){this._material.clearCoat.isEnabled=!0,this._material.clearCoat.roughness=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"coatRoughnessTexture",{get:function(){return this._material.clearCoat.textureRoughness},set:function(e){this._material.clearCoat.isEnabled=!0,this._material.clearCoat.useRoughnessFromMainTexture=!1,this._material.clearCoat.textureRoughness=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"coatIor",{set:function(e){this._material.clearCoat.indexOfRefraction=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"coatDarkening",{set:function(e){},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"coatDarkeningTexture",{set:function(e){},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"coatRoughnessAnisotropy",{get:function(){return 0},set:function(e){},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"geometryCoatTangentAngle",{set:function(e){},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"geometryCoatTangentTexture",{get:function(){return null},set:function(e){},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"transmissionWeight",{get:function(){return this._material.subSurface.isRefractionEnabled?this._material.subSurface.refractionIntensity:0},set:function(e){this._material.subSurface.isRefractionEnabled=e>0,this._material.subSurface.refractionIntensity=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"transmissionWeightTexture",{set:function(e){this._material.subSurface.isRefractionEnabled=!0,this._material.subSurface.refractionIntensityTexture=e,this._material.subSurface.useGltfStyleTextures=!0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"transmissionDepth",{get:function(){return this.transmissionWeight>0?this._material.subSurface.tintColorAtDistance:0},set:function(e){this.transmissionWeight>0?this._material.subSurface.tintColorAtDistance=e:this.subsurfaceWeight>0&&this._material.subSurface.diffusionDistance.multiplyInPlace(new t.Color3(e,e,e))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"transmissionColor",{get:function(){return this.transmissionWeight>0?this._material.subSurface.tintColor:this.subsurfaceWeight>0?this._material.subSurface.diffusionDistance:new t.Color3(0,0,0)},set:function(e){this.transmissionWeight>0?this._material.subSurface.tintColor=e:this.subsurfaceWeight>0&&this._material.subSurface.diffusionDistance.multiplyInPlace(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"transmissionScatter",{get:function(){return this._material.subSurface.diffusionDistance},set:function(e){this._material.subSurface.diffusionDistance=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"transmissionScatterTexture",{set:function(e){},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"transmissionScatterAnisotropy",{set:function(e){},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"transmissionDispersionAbbeNumber",{set:function(e){},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"transmissionDispersionScale",{set:function(e){e>0?(this._material.subSurface.isDispersionEnabled=!0,this._material.subSurface.dispersion=20/e):(this._material.subSurface.isDispersionEnabled=!1,this._material.subSurface.dispersion=0)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"refractionBackgroundTexture",{get:function(){return this._material.subSurface.refractionTexture},set:function(e){this._material.subSurface.refractionTexture=e},enumerable:!1,configurable:!0}),e.prototype.configureTransmission=function(){this._material.subSurface.volumeIndexOfRefraction=1,this._material.subSurface.useAlbedoToTintRefraction=!0,this._material.subSurface.minimumThickness=0,this._material.subSurface.maximumThickness=0},e.prototype.configureVolume=function(){},Object.defineProperty(e.prototype,"geometryThinWalled",{get:function(){return 0===this._material.subSurface.maximumThickness},set:function(e){},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"volumeThicknessTexture",{set:function(e){this._material.subSurface.thicknessTexture=e,this._material.subSurface.useGltfStyleTextures=!0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"volumeThickness",{set:function(e){this._material.subSurface.minimumThickness=0,this._material.subSurface.maximumThickness=e,this._material.subSurface.useThicknessAsDepth=!0,e>0&&(this._material.subSurface.volumeIndexOfRefraction=this._material.indexOfRefraction)},enumerable:!1,configurable:!0}),e.prototype.configureSubsurface=function(){this._material.subSurface.useGltfStyleTextures=!0,this._material.subSurface.volumeIndexOfRefraction=1,this._material.subSurface.minimumThickness=0,this._material.subSurface.maximumThickness=0,this._material.subSurface.useAlbedoToTintTranslucency=!1},Object.defineProperty(e.prototype,"subsurfaceWeight",{get:function(){return this._material.subSurface.isTranslucencyEnabled?this._material.subSurface.translucencyIntensity:0},set:function(e){this._material.subSurface.isTranslucencyEnabled=e>0,this._material.subSurface.translucencyIntensity=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"subsurfaceWeightTexture",{set:function(e){this._material.subSurface.translucencyIntensityTexture=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"subsurfaceColor",{set:function(e){var n=new t.Vector3(-Math.log(this.transmissionColor.r),-Math.log(this.transmissionColor.g),-Math.log(this.transmissionColor.b));n.scaleInPlace(1/Math.max(this.transmissionDepth,.001));var r=n,o=Math.max(r.x,Math.max(r.y,r.z)),a=o>0?1/o:1;this._material.subSurface.diffusionDistance=new t.Color3(Math.exp(-r.x*a),Math.exp(-r.y*a),Math.exp(-r.z*a))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"subsurfaceColorTexture",{set:function(e){},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"diffuseTransmissionTint",{get:function(){return this._material.subSurface.tintColor},set:function(e){this._material.subSurface.tintColor=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"diffuseTransmissionTintTexture",{set:function(e){this._material.subSurface.translucencyColorTexture=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"subsurfaceRadius",{get:function(){return 1},set:function(e){},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"subsurfaceRadiusScale",{get:function(){var e;return null!==(e=this._material.subSurface.scatteringDiffusionProfile)&&void 0!==e?e:t.Color3.White()},set:function(e){this._material.subSurface.scatteringDiffusionProfile=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"subsurfaceScatterAnisotropy",{set:function(e){},enumerable:!1,configurable:!0}),e.prototype.isTranslucent=function(){return this.transmissionWeight>0||this.subsurfaceWeight>0},e.prototype.configureFuzz=function(){this._material.sheen.isEnabled=!0,this._material.sheen.useRoughnessFromMainTexture=!1,this._material.sheen.albedoScaling=!0},Object.defineProperty(e.prototype,"fuzzWeight",{set:function(e){this._material.sheen.isEnabled=!0,this._material.sheen.intensity=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"fuzzWeightTexture",{set:function(e){this._material.sheen.texture||(this._material.sheen.texture=e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"fuzzColor",{set:function(e){this._material.sheen.isEnabled=!0,this._material.sheen.color=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"fuzzColorTexture",{set:function(e){this._material.sheen.texture=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"fuzzRoughness",{set:function(e){this._material.sheen.isEnabled=!0,this._material.sheen.roughness=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"fuzzRoughnessTexture",{set:function(e){this._material.sheen.isEnabled=!0,this._material.sheen.textureRoughness=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"specularRoughnessAnisotropy",{get:function(){return this._material.anisotropy.intensity},set:function(e){this._material.anisotropy.isEnabled=!0,this._material.anisotropy.intensity=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"geometryTangentAngle",{set:function(e){this._material.anisotropy.isEnabled=!0,this._material.anisotropy.angle=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"geometryTangentTexture",{get:function(){return this._material.anisotropy.texture},set:function(e){this._material.anisotropy.isEnabled=!0,this._material.anisotropy.texture=e},enumerable:!1,configurable:!0}),e.prototype.configureGltfStyleAnisotropy=function(e){void 0===e&&(e=!0)},Object.defineProperty(e.prototype,"thinFilmWeight",{set:function(e){this._material.iridescence.isEnabled=e>0,this._material.iridescence.intensity=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"thinFilmIor",{set:function(e){this._material.iridescence.indexOfRefraction=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"thinFilmThicknessMinimum",{set:function(e){this._material.iridescence.minimumThickness=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"thinFilmThicknessMaximum",{set:function(e){this._material.iridescence.maximumThickness=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"thinFilmWeightTexture",{set:function(e){this._material.iridescence.texture=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"thinFilmThicknessTexture",{set:function(e){this._material.iridescence.thicknessTexture=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"unlit",{set:function(e){this._material.unlit=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"geometryOpacity",{get:function(){return this._material.alpha},set:function(e){this._material.alpha=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"geometryNormalTexture",{get:function(){return this._material.bumpTexture},set:function(e){this._material.bumpTexture=e,this._material.forceIrradianceInFragment=!0},enumerable:!1,configurable:!0}),e.prototype.setNormalMapInversions=function(e,t){this._material.invertNormalMapX=e,this._material.invertNormalMapY=t},Object.defineProperty(e.prototype,"geometryCoatNormalTexture",{get:function(){return this._material.clearCoat.bumpTexture},set:function(e){this._material.clearCoat.isEnabled=!0,this._material.clearCoat.bumpTexture=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"geometryCoatNormalTextureScale",{set:function(e){this._material.clearCoat.bumpTexture&&(this._material.clearCoat.bumpTexture.level=e)},enumerable:!1,configurable:!0}),e}(),Rn={__proto__:null,PBRMaterialLoadingAdapter:Mn},Pn={__proto__:null,AddObjectAccessorToKey:G,AnimationPropertyInfo:st,ArrayItem:U,EXT_lights_area:fe,EXT_lights_ies:ae,EXT_lights_image_based:X,EXT_mesh_gpu_instancing:J,EXT_meshopt_compression:$,EXT_texture_avif:re,EXT_texture_webp:te,ExtrasAsMetadata:yn,FlowGraphGLTFDataProvider:xn,GLTFFileLoader:T,GLTFLoader:q,GetMappingForKey:B,GetPathToObjectConverter:I,InteractivityGraphToFlowGraphParser:an,KHR_animation_pointer:Ht,KHR_draco_mesh_compression:se,KHR_interactivity:ln,KHR_lights:ue,KHR_materials_anisotropy:Ae,KHR_materials_clearcoat:be,KHR_materials_coat:ye,KHR_materials_diffuse_roughness:Xe,KHR_materials_diffuse_transmission:He,KHR_materials_dispersion:qe,KHR_materials_emissive_strength:we,KHR_materials_fuzz:Pe,KHR_materials_ior:Se,KHR_materials_iridescence:Te,KHR_materials_pbrSpecularGlossiness:pe,KHR_materials_sheen:Me,KHR_materials_specular:Fe,KHR_materials_transmission:De,KHR_materials_unlit:me,KHR_materials_variants:Ie,KHR_materials_volume:je,KHR_materials_volume_scatter:Ue,KHR_mesh_quantization:Je,KHR_node_hoverability:bn,KHR_node_selectability:pn,KHR_node_visibility:fn,KHR_texture_basisu:$e,KHR_texture_transform:tt,KHR_xmp_json_ld:rt,LoadBoundingInfoFromPositionAccessor:z,MSFT_audio_emitter:jt,MSFT_lod:Ut,MSFT_minecraftMesh:qt,MSFT_sRGBFactors:Xt,OpenPBRMaterialLoadingAdapter:wn,PBRMaterialLoadingAdapter:Mn,SetInterpolationForKey:N,TransformNodeAnimationPropertyInfo:lt,TransmissionHelper:Be,WeightAnimationPropertyInfo:ut,_AddInteractivityObjectModel:un,addNewInteractivityFlowGraphMapping:Zt,ensureTransmissionHelper:Ne,getAllSupportedNativeNodeTypes:rn,getMappingForDeclaration:Jt,getMappingForFullOperationName:Qt,getQuaternion:at,getVector3:ot,getWeights:it,gltfTypeToBabylonType:on,registerGLTFExtension:H,registeredGLTFExtensions:V,unregisterGLTFExtension:K},Ln=o({},Cn),Fn=o(o({},{__proto__:null}),((vn={}).Extensions=Ln,vn)),En=o(o({},Pn),((Tn={}).Loader=Fn,Tn)),Sn="undefined"!=typeof global?global:"undefined"!=typeof window?window:void 0;if(void 0!==Sn){Sn.BABYLON=Sn.BABYLON||{};var kn=Sn.BABYLON;kn.GLTF2=kn.GLTF2||{},kn.GLTF2.Loader=kn.GLTF2.Loader||{},kn.GLTF2.Loader.Extensions=kn.GLTF2.Loader.Extensions||{};var In=["Loader"];for(var Bn in Ln)kn.GLTF2.Loader.Extensions[Bn]=Ln[Bn],In.push(Bn);for(var Bn in Fn)"Extensions"!==Bn&&(kn.GLTF2.Loader[Bn]=Fn[Bn],In.push(Bn));for(var Bn in En)In.indexOf(Bn)>-1||(kn.GLTF2[Bn]=En[Bn])}e.GLTF2=En,e.GLTFFileLoader=T,e.GLTFLoaderDefaultOptions=y,e.GLTFValidation=h});
2
2
  //# sourceMappingURL=babylon.glTF2FileLoader.min.js.map