babylonjs-loaders 9.16.1 → 9.17.0

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";function n(e,t,n,r){const s={externalResourceFunction:r};return n&&(s.uri="file:"===t?n:t+n),ArrayBuffer.isView(e)?GLTFValidator.validateBytes(e,s):GLTFValidator.validateString(e,s)}function r(){const e=[];onmessage=t=>{const r=t.data;switch(r.id){case"init":importScripts(r.url);break;case"validate":n(r.data,r.rootUrl,r.fileName,t=>new Promise((n,r)=>{const s=e.length;e.push({resolve:n,reject:r}),postMessage({id:"getExternalResource",index:s,uri:t})})).then(e=>{postMessage({id:"validate.resolve",value:e})},e=>{postMessage({id:"validate.reject",reason:e})});break;case"getExternalResource.resolve":e[r.index].resolve(r.value);break;case"getExternalResource.reject":e[r.index].reject(r.reason)}}}class s{static ValidateAsync(e,o,a,i){return"function"==typeof Worker?new Promise((l,u)=>{const c=`${n}(${r})()`,h=URL.createObjectURL(new Blob([c],{type:"application/javascript"})),d=new Worker(h),m=e=>{d.removeEventListener("error",m),d.removeEventListener("message",_),u(e)},_=e=>{const t=e.data;switch(t.id){case"getExternalResource":i(t.uri).then(e=>{d.postMessage({id:"getExternalResource.resolve",index:t.index,value:e},[e.buffer])},e=>{d.postMessage({id:"getExternalResource.reject",index:t.index,reason:e})});break;case"validate.resolve":d.removeEventListener("error",m),d.removeEventListener("message",_),s._LastResults=t.value,l(t.value),d.terminate();break;case"validate.reject":d.removeEventListener("error",m),d.removeEventListener("message",_),u(t.reason),d.terminate()}};if(d.addEventListener("error",m),d.addEventListener("message",_),d.postMessage({id:"init",url:t.Tools.GetBabylonScriptURL(this.Configuration.url)}),ArrayBuffer.isView(e)){const t=e.slice();d.postMessage({id:"validate",data:t,rootUrl:o,fileName:a},[t.buffer])}else d.postMessage({id:"validate",data:e,rootUrl:o,fileName:a})}):(this._LoadScriptPromise||(this._LoadScriptPromise=t.Tools.LoadBabylonScriptAsync(this.Configuration.url)),this._LoadScriptPromise.then(()=>n(e,o,a,i)))}}s.Configuration={url:`${t.Tools._DefaultCdnUrl}/gltf_validator.js`},s._LastResults=null;var o={__proto__:null,GLTFValidation:s};const a="Z2xURg",i="gltf",l={".gltf":{isBinary:!1,mimeType:"model/gltf+json"},".glb":{isBinary:!0,mimeType:"model/gltf-binary"}},u=e=>-1!==e.indexOf("asset")&&-1!==e.indexOf("version")||e.startsWith("data:base64,"+a)||e.startsWith("data:;base64,"+a)||e.startsWith("data:application/octet-stream;base64,"+a)||e.startsWith("data:model/gltf-binary;base64,"+a);function c(e,t,n){try{return Promise.resolve(new Uint8Array(e,t,n))}catch(e){return Promise.reject(e)}}var h,d,m;e.GLTFLoaderCoordinateSystemMode=void 0,(h=e.GLTFLoaderCoordinateSystemMode||(e.GLTFLoaderCoordinateSystemMode={}))[h.AUTO=0]="AUTO",h[h.FORCE_RIGHT_HANDED=1]="FORCE_RIGHT_HANDED",e.GLTFLoaderAnimationStartMode=void 0,(d=e.GLTFLoaderAnimationStartMode||(e.GLTFLoaderAnimationStartMode={}))[d.NONE=0]="NONE",d[d.FIRST=1]="FIRST",d[d.ALL=2]="ALL",e.GLTFLoaderState=void 0,(m=e.GLTFLoaderState||(e.GLTFLoaderState={}))[m.LOADING=0]="LOADING",m[m.READY=1]="READY",m[m.COMPLETE=2]="COMPLETE";class _{constructor(){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.useMaxMorphTargetInfluencers=!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}}const p=new _;class f extends _{constructor(){super(...arguments),this.extensionOptions={},this.preprocessUrlAsync=e=>Promise.resolve(e)}copyFrom(e){var t,n,r,s,o,a,i,l,u,c,h,d,m,_,p,f,g,b,y,T,x,v,A,C,R,M,w;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!==(s=e.capturePerformanceCounters)&&void 0!==s?s:this.capturePerformanceCounters,this.compileMaterials=null!==(o=e.compileMaterials)&&void 0!==o?o:this.compileMaterials,this.compileShadowGenerators=null!==(a=e.compileShadowGenerators)&&void 0!==a?a:this.compileShadowGenerators,this.coordinateSystemMode=null!==(i=e.coordinateSystemMode)&&void 0!==i?i: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!==(h=e.loadMorphTargets)&&void 0!==h?h:this.loadMorphTargets,this.loadNodeAnimations=null!==(d=e.loadNodeAnimations)&&void 0!==d?d:this.loadNodeAnimations,this.loadOnlyMaterials=null!==(m=e.loadOnlyMaterials)&&void 0!==m?m:this.loadOnlyMaterials,this.loadSkins=null!==(_=e.loadSkins)&&void 0!==_?_:this.loadSkins,this.loggingEnabled=null!==(p=e.loggingEnabled)&&void 0!==p?p: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!==(f=e.preprocessUrlAsync)&&void 0!==f?f:this.preprocessUrlAsync,this.skipMaterials=null!==(g=e.skipMaterials)&&void 0!==g?g:this.skipMaterials,this.targetFps=null!==(b=e.targetFps)&&void 0!==b?b:this.targetFps,this.transparencyAsCoverage=null!==(y=e.transparencyAsCoverage)&&void 0!==y?y:this.transparencyAsCoverage,this.useClipPlane=null!==(T=e.useClipPlane)&&void 0!==T?T:this.useClipPlane,this.useGltfTextureNames=null!==(x=e.useGltfTextureNames)&&void 0!==x?x:this.useGltfTextureNames,this.useMaxMorphTargetInfluencers=null!==(v=e.useMaxMorphTargetInfluencers)&&void 0!==v?v:this.useMaxMorphTargetInfluencers,this.useOpenPBR=null!==(A=e.useOpenPBR)&&void 0!==A?A:this.useOpenPBR,this.useRangeRequests=null!==(C=e.useRangeRequests)&&void 0!==C?C:this.useRangeRequests,this.useSRGBBuffers=null!==(R=e.useSRGBBuffers)&&void 0!==R?R:this.useSRGBBuffers,this.validate=null!==(M=e.validate)&&void 0!==M?M:this.validate,this.dontUseTransmissionHelper=null!==(w=e.dontUseTransmissionHelper)&&void 0!==w?w:this.dontUseTransmissionHelper)}}class g extends f{constructor(e){super(),this.onParsedObservable=new t.Observable,this.onMeshLoadedObservable=new t.Observable,this.onSkinLoadedObservable=new t.Observable,this.onTextureLoadedObservable=new t.Observable,this.onMaterialLoadedObservable=new t.Observable,this.onCameraLoadedObservable=new t.Observable,this.onCompleteObservable=new t.Observable,this.onErrorObservable=new t.Observable,this.onDisposeObservable=new t.Observable,this.onExtensionLoadedObservable=new t.Observable,this.onValidatedObservable=new t.Observable,this._loader=null,this._state=null,this._requests=new Array,this.name=i,this.extensions=l,this.onLoaderStateChangedObservable=new t.Observable,this._logIndentLevel=0,this._loggingEnabled=!1,this._log=this._logDisabled,this._capturePerformanceCounters=!1,this._startPerformanceCounter=this._startPerformanceCounterDisabled,this._endPerformanceCounter=this._endPerformanceCounterDisabled,this.copyFrom(Object.assign(Object.assign({},p),e))}set onParsed(e){this._onParsedObserver&&this.onParsedObservable.remove(this._onParsedObserver),e&&(this._onParsedObserver=this.onParsedObservable.add(e))}set onMeshLoaded(e){this._onMeshLoadedObserver&&this.onMeshLoadedObservable.remove(this._onMeshLoadedObserver),e&&(this._onMeshLoadedObserver=this.onMeshLoadedObservable.add(e))}set onSkinLoaded(e){this._onSkinLoadedObserver&&this.onSkinLoadedObservable.remove(this._onSkinLoadedObserver),e&&(this._onSkinLoadedObserver=this.onSkinLoadedObservable.add(t=>e(t.node,t.skinnedNode)))}set onTextureLoaded(e){this._onTextureLoadedObserver&&this.onTextureLoadedObservable.remove(this._onTextureLoadedObserver),e&&(this._onTextureLoadedObserver=this.onTextureLoadedObservable.add(e))}set onMaterialLoaded(e){this._onMaterialLoadedObserver&&this.onMaterialLoadedObservable.remove(this._onMaterialLoadedObserver),e&&(this._onMaterialLoadedObserver=this.onMaterialLoadedObservable.add(e))}set onCameraLoaded(e){this._onCameraLoadedObserver&&this.onCameraLoadedObservable.remove(this._onCameraLoadedObserver),e&&(this._onCameraLoadedObserver=this.onCameraLoadedObservable.add(e))}set onComplete(e){this._onCompleteObserver&&this.onCompleteObservable.remove(this._onCompleteObserver),this._onCompleteObserver=this.onCompleteObservable.add(e)}set onError(e){this._onErrorObserver&&this.onErrorObservable.remove(this._onErrorObserver),this._onErrorObserver=this.onErrorObservable.add(e)}set onDispose(e){this._onDisposeObserver&&this.onDisposeObservable.remove(this._onDisposeObserver),this._onDisposeObserver=this.onDisposeObservable.add(e)}set onExtensionLoaded(e){this._onExtensionLoadedObserver&&this.onExtensionLoadedObservable.remove(this._onExtensionLoadedObserver),this._onExtensionLoadedObserver=this.onExtensionLoadedObservable.add(e)}get loggingEnabled(){return this._loggingEnabled}set loggingEnabled(e){this._loggingEnabled!==e&&(this._loggingEnabled=e,this._loggingEnabled?this._log=this._logEnabled:this._log=this._logDisabled)}get capturePerformanceCounters(){return this._capturePerformanceCounters}set capturePerformanceCounters(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))}set onValidated(e){this._onValidatedObserver&&this.onValidatedObservable.remove(this._onValidatedObserver),this._onValidatedObserver=this.onValidatedObservable.add(e)}dispose(){this._loader&&(this._loader.dispose(),this._loader=null);for(const e of this._requests)e.abort();this._requests.length=0,delete this._progressCallback,this.preprocessUrlAsync=e=>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()}loadFile(e,n,r,s,o,a,i,l){if(ArrayBuffer.isView(n))return this._loadBinary(e,n,r,s,i,l),null;this._progressCallback=o;const u=n.name||t.Tools.GetFilename(n);if(a){if(this.useRangeRequests){this.validate&&t.Logger.Warn("glTF validation is not supported when range requests are enabled");const r={abort:()=>{},onCompleteObservable:new t.Observable},o={readAsync:(t,r)=>new Promise((s,o)=>{this._loadFile(e,n,e=>{s(new Uint8Array(e))},!0,e=>{o(e)},e=>{e.setRequestHeader("Range",`bytes=${t}-${t+r-1}`)})}),byteLength:0};return this._unpackBinaryAsync(new t.DataReader(o)).then(e=>{r.onCompleteObservable.notifyObservers(r),s(e)},i?e=>i(void 0,e):void 0),r}return this._loadFile(e,n,n=>{this._validate(e,new Uint8Array(n,0,n.byteLength),r,u),this._unpackBinaryAsync(new t.DataReader({readAsync:(e,t)=>c(n,e,t),byteLength:n.byteLength})).then(e=>{s(e)},i?e=>i(void 0,e):void 0)},!0,i)}return this._loadFile(e,n,t=>{try{this._validate(e,t,r,u),s({json:this._parseJson(t)})}catch(e){i&&i()}},!1,i)}_loadBinary(e,n,r,s,o,a){this._validate(e,new Uint8Array(n.buffer,n.byteOffset,n.byteLength),r,a),this._unpackBinaryAsync(new t.DataReader({readAsync:(e,t)=>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(e=>{s(e)},o?e=>o(void 0,e):void 0)}importMeshAsync(e,t,n,r,s,o){return Promise.resolve().then(()=>(this.onParsedObservable.notifyObservers(n),this.onParsedObservable.clear(),this._log(`Loading ${o||""}`),this._loader=this._getLoader(n),this._loader.importMeshAsync(e,t,null,n,r,s,o)))}loadAsync(e,t,n,r,s){return Promise.resolve().then(()=>(this.onParsedObservable.notifyObservers(t),this.onParsedObservable.clear(),this._log(`Loading ${s||""}`),this._loader=this._getLoader(t),this._loader.loadAsync(e,t,n,r,s)))}loadAssetContainerAsync(e,n,r,s,o){return Promise.resolve().then(()=>{this.onParsedObservable.notifyObservers(n),this.onParsedObservable.clear(),this._log(`Loading ${o||""}`),this._loader=this._getLoader(n);const a=new t.AssetContainer(e),i=[];this.onMaterialLoadedObservable.add(e=>{i.push(e)});const l=[];this.onTextureLoadedObservable.add(e=>{l.push(e)});const u=[];this.onCameraLoadedObservable.add(e=>{u.push(e)});const c=[];return this.onMeshLoadedObservable.add(e=>{e.morphTargetManager&&c.push(e.morphTargetManager)}),this._loader.importMeshAsync(null,e,a,n,r,s,o).then(e=>(Array.prototype.push.apply(a.geometries,e.geometries),Array.prototype.push.apply(a.meshes,e.meshes),Array.prototype.push.apply(a.particleSystems,e.particleSystems),Array.prototype.push.apply(a.skeletons,e.skeletons),Array.prototype.push.apply(a.animationGroups,e.animationGroups),Array.prototype.push.apply(a.materials,i),Array.prototype.push.apply(a.textures,l),Array.prototype.push.apply(a.lights,e.lights),Array.prototype.push.apply(a.transformNodes,e.transformNodes),Array.prototype.push.apply(a.cameras,u),Array.prototype.push.apply(a.morphTargetManagers,c),a))})}canDirectLoad(e){return u(e)}directLoad(e,n){if(n.startsWith("base64,"+a)||n.startsWith(";base64,"+a)||n.startsWith("application/octet-stream;base64,"+a)||n.startsWith("model/gltf-binary;base64,"+a)){const r=t.DecodeBase64UrlToBinary(n);return this._validate(e,new Uint8Array(r,0,r.byteLength)),this._unpackBinaryAsync(new t.DataReader({readAsync:(e,t)=>c(r,e,t),byteLength:r.byteLength}))}return this._validate(e,n),Promise.resolve({json:this._parseJson(n)})}createPlugin(e){return new g(e[i])}get loaderState(){return this._state}whenCompleteAsync(){return new Promise((e,t)=>{this.onCompleteObservable.addOnce(()=>{e()}),this.onErrorObservable.addOnce(e=>{t(e)})})}_setState(t){this._state!==t&&(this._state=t,this.onLoaderStateChangedObservable.notifyObservers(this._state),this._log(e.GLTFLoaderState[this._state]))}_loadFile(e,t,n,r,s,o){const a=e._loadFile(t,n,e=>{this._onProgress(e,a)},!0,r,s,o);return a.onCompleteObservable.add(()=>{a._lengthComputable=!0,a._total=a._loaded}),this._requests.push(a),a}_onProgress(e,t){if(!this._progressCallback)return;t._lengthComputable=e.lengthComputable,t._loaded=e.loaded,t._total=e.total;let n=!0,r=0,s=0;for(const e of this._requests){if(void 0===e._lengthComputable||void 0===e._loaded||void 0===e._total)return;n=n&&e._lengthComputable,r+=e._loaded,s+=e._total}this._progressCallback({lengthComputable:n,loaded:r,total:n?s:0})}_validate(e,n,r="",o=""){this.validate&&(this._startPerformanceCounter("Validate JSON"),s.ValidateAsync(n,r,o,t=>this.preprocessUrlAsync(r+t).then(t=>e._loadFileAsync(t,void 0,!0,!0).then(e=>new Uint8Array(e,0,e.byteLength)))).then(e=>{this._endPerformanceCounter("Validate JSON"),this.onValidatedObservable.notifyObservers(e),this.onValidatedObservable.clear()},e=>{this._endPerformanceCounter("Validate JSON"),t.Tools.Warn(`Failed to validate: ${e.message}`),this.onValidatedObservable.clear()}))}_getLoader(e){const t=e.json.asset||{};this._log(`Asset version: ${t.version}`),t.minVersion&&this._log(`Asset minimum version: ${t.minVersion}`),t.generator&&this._log(`Asset generator: ${t.generator}`);const n=g._parseVersion(t.version);if(!n)throw new Error("Invalid version: "+t.version);if(void 0!==t.minVersion){const e=g._parseVersion(t.minVersion);if(!e)throw new Error("Invalid minimum version: "+t.minVersion);if(g._compareVersion(e,{major:2,minor:0})>0)throw new Error("Incompatible minimum version: "+t.minVersion)}const r={1:g._CreateGLTF1Loader,2:g._CreateGLTF2Loader}[n.major];if(!r)throw new Error("Unsupported version: "+t.version);return r(this)}_parseJson(e){this._startPerformanceCounter("Parse JSON"),this._log(`JSON length: ${e.length}`);const t=JSON.parse(e);return this._endPerformanceCounter("Parse JSON"),t}_unpackBinaryAsync(e){return this._startPerformanceCounter("Unpack Binary"),e.loadAsync(20).then(()=>{const n=e.readUint32();if(1179937895!==n)throw new t.RuntimeError("Unexpected magic: "+n,t.ErrorCodes.GLTFLoaderUnexpectedMagicError);const r=e.readUint32();this.loggingEnabled&&this._log(`Binary version: ${r}`);const s=e.readUint32();let o;switch(this.useRangeRequests||s===e.buffer.byteLength||t.Logger.Warn(`Length in header does not match actual data length: ${s} != ${e.buffer.byteLength}`),r){case 1:o=this._unpackBinaryV1Async(e,s);break;case 2:o=this._unpackBinaryV2Async(e,s);break;default:throw new Error("Unsupported version: "+r)}return this._endPerformanceCounter("Unpack Binary"),o})}_unpackBinaryV1Async(e,t){const n=e.readUint32(),r=e.readUint32();if(0!==r)throw new Error(`Unexpected content format: ${r}`);const s=t-e.byteOffset,o={json:this._parseJson(e.readString(n)),bin:null};if(0!==s){const t=e.byteOffset;o.bin={readAsync:(n,r)=>e.buffer.readAsync(t+n,r),byteLength:s}}return Promise.resolve(o)}_unpackBinaryV2Async(e,t){const n=1313821514,r=e.readUint32();if(e.readUint32()!==n)throw new Error("First chunk format is not JSON");return e.byteOffset+r===t?e.loadAsync(r).then(()=>({json:this._parseJson(e.readString(r)),bin:null})):e.loadAsync(r+8).then(()=>{const s={json:this._parseJson(e.readString(r)),bin:null},o=()=>{const r=e.readUint32();switch(e.readUint32()){case n:throw new Error("Unexpected JSON chunk");case 5130562:{const t=e.byteOffset;s.bin={readAsync:(n,r)=>e.buffer.readAsync(t+n,r),byteLength:r},e.skipBytes(r);break}default:e.skipBytes(r)}return e.byteOffset!==t?e.loadAsync(8).then(o):Promise.resolve(s)};return o()})}static _parseVersion(e){if("1.0"===e||"1.0.1"===e)return{major:1,minor:0};const t=(e+"").match(/^(\d+)\.(\d+)/);return t?{major:parseInt(t[1]),minor:parseInt(t[2])}:null}static _compareVersion(e,t){return e.major>t.major?1:e.major<t.major?-1:e.minor>t.minor?1:e.minor<t.minor?-1:0}_logOpen(e){this._log(e),this._logIndentLevel++}_logClose(){--this._logIndentLevel}_logEnabled(e){const n=g._logSpaces.substring(0,2*this._logIndentLevel);t.Logger.Log(`${n}${e}`)}_logDisabled(e){}_startPerformanceCounterEnabled(e){t.Tools.StartPerformanceCounter(e)}_startPerformanceCounterDisabled(e){}_endPerformanceCounterEnabled(e){t.Tools.EndPerformanceCounter(e)}_endPerformanceCounterDisabled(e){}}g.IncrementalLoading=!0,g.HomogeneousCoordinates=!1,g._logSpaces=" ";let b=!1;function y(){b||(b=!0,t.RegisterSceneLoaderPlugin(new g))}y();var T={__proto__:null,GLTFFileLoader:g,get GLTFLoaderAnimationStartMode(){return e.GLTFLoaderAnimationStartMode},get GLTFLoaderCoordinateSystemMode(){return e.GLTFLoaderCoordinateSystemMode},GLTFLoaderDefaultOptions:p,get GLTFLoaderState(){return e.GLTFLoaderState},RegisterGLTFFileLoader:y};const x="undefined"!=typeof global?global:"undefined"!=typeof window?window:void 0;if(void 0!==x){x.BABYLON=x.BABYLON||{};for(const e in T)x.BABYLON[e]=T[e];for(const e in o)x.BABYLON[e]=o[e]}function v(e,t,n,r){return new(n||(n=Promise))(function(s,o){function a(e){try{l(r.next(e))}catch(e){o(e)}}function i(e){try{l(r.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?s(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,i)}l((r=r.apply(e,t||[])).next())})}var A,C,R,M,w,E,O,L,S;Object.create,Object.create,"function"==typeof SuppressedError&&SuppressedError,function(e){e[e.BYTE=5120]="BYTE",e[e.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",e[e.SHORT=5122]="SHORT",e[e.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",e[e.FLOAT=5126]="FLOAT"}(A||(A={})),function(e){e[e.FRAGMENT=35632]="FRAGMENT",e[e.VERTEX=35633]="VERTEX"}(C||(C={})),function(e){e[e.BYTE=5120]="BYTE",e[e.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",e[e.SHORT=5122]="SHORT",e[e.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",e[e.INT=5124]="INT",e[e.UNSIGNED_INT=5125]="UNSIGNED_INT",e[e.FLOAT=5126]="FLOAT",e[e.FLOAT_VEC2=35664]="FLOAT_VEC2",e[e.FLOAT_VEC3=35665]="FLOAT_VEC3",e[e.FLOAT_VEC4=35666]="FLOAT_VEC4",e[e.INT_VEC2=35667]="INT_VEC2",e[e.INT_VEC3=35668]="INT_VEC3",e[e.INT_VEC4=35669]="INT_VEC4",e[e.BOOL=35670]="BOOL",e[e.BOOL_VEC2=35671]="BOOL_VEC2",e[e.BOOL_VEC3=35672]="BOOL_VEC3",e[e.BOOL_VEC4=35673]="BOOL_VEC4",e[e.FLOAT_MAT2=35674]="FLOAT_MAT2",e[e.FLOAT_MAT3=35675]="FLOAT_MAT3",e[e.FLOAT_MAT4=35676]="FLOAT_MAT4",e[e.SAMPLER_2D=35678]="SAMPLER_2D"}(R||(R={})),function(e){e[e.CLAMP_TO_EDGE=33071]="CLAMP_TO_EDGE",e[e.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",e[e.REPEAT=10497]="REPEAT"}(M||(M={})),function(e){e[e.NEAREST=9728]="NEAREST",e[e.LINEAR=9728]="LINEAR",e[e.NEAREST_MIPMAP_NEAREST=9984]="NEAREST_MIPMAP_NEAREST",e[e.LINEAR_MIPMAP_NEAREST=9985]="LINEAR_MIPMAP_NEAREST",e[e.NEAREST_MIPMAP_LINEAR=9986]="NEAREST_MIPMAP_LINEAR",e[e.LINEAR_MIPMAP_LINEAR=9987]="LINEAR_MIPMAP_LINEAR"}(w||(w={})),function(e){e[e.ALPHA=6406]="ALPHA",e[e.RGB=6407]="RGB",e[e.RGBA=6408]="RGBA",e[e.LUMINANCE=6409]="LUMINANCE",e[e.LUMINANCE_ALPHA=6410]="LUMINANCE_ALPHA"}(E||(E={})),function(e){e[e.FRONT=1028]="FRONT",e[e.BACK=1029]="BACK",e[e.FRONT_AND_BACK=1032]="FRONT_AND_BACK"}(O||(O={})),function(e){e[e.ZERO=0]="ZERO",e[e.ONE=1]="ONE",e[e.SRC_COLOR=768]="SRC_COLOR",e[e.ONE_MINUS_SRC_COLOR=769]="ONE_MINUS_SRC_COLOR",e[e.DST_COLOR=774]="DST_COLOR",e[e.ONE_MINUS_DST_COLOR=775]="ONE_MINUS_DST_COLOR",e[e.SRC_ALPHA=770]="SRC_ALPHA",e[e.ONE_MINUS_SRC_ALPHA=771]="ONE_MINUS_SRC_ALPHA",e[e.DST_ALPHA=772]="DST_ALPHA",e[e.ONE_MINUS_DST_ALPHA=773]="ONE_MINUS_DST_ALPHA",e[e.CONSTANT_COLOR=32769]="CONSTANT_COLOR",e[e.ONE_MINUS_CONSTANT_COLOR=32770]="ONE_MINUS_CONSTANT_COLOR",e[e.CONSTANT_ALPHA=32771]="CONSTANT_ALPHA",e[e.ONE_MINUS_CONSTANT_ALPHA=32772]="ONE_MINUS_CONSTANT_ALPHA",e[e.SRC_ALPHA_SATURATE=776]="SRC_ALPHA_SATURATE"}(L||(L={}));class F{static SetMatrix(e,n,r,s,o){let a=null;if("MODEL"===r.semantic?a=n.getWorldMatrix():"PROJECTION"===r.semantic?a=e.getProjectionMatrix():"VIEW"===r.semantic?a=e.getViewMatrix():"MODELVIEWINVERSETRANSPOSE"===r.semantic?a=t.Matrix.Transpose(n.getWorldMatrix().multiply(e.getViewMatrix()).invert()):"MODELVIEW"===r.semantic?a=n.getWorldMatrix().multiply(e.getViewMatrix()):"MODELVIEWPROJECTION"===r.semantic?a=n.getWorldMatrix().multiply(e.getTransformMatrix()):"MODELINVERSE"===r.semantic?a=n.getWorldMatrix().invert():"VIEWINVERSE"===r.semantic?a=e.getViewMatrix().invert():"PROJECTIONINVERSE"===r.semantic?a=e.getProjectionMatrix().invert():"MODELVIEWINVERSE"===r.semantic?a=n.getWorldMatrix().multiply(e.getViewMatrix()).invert():"MODELVIEWPROJECTIONINVERSE"===r.semantic?a=n.getWorldMatrix().multiply(e.getTransformMatrix()).invert():"MODELINVERSETRANSPOSE"===r.semantic&&(a=t.Matrix.Transpose(n.getWorldMatrix().invert())),a)switch(r.type){case R.FLOAT_MAT2:o.setMatrix2x2(s,t.Matrix.GetAsMatrix2x2(a));break;case R.FLOAT_MAT3:o.setMatrix3x3(s,t.Matrix.GetAsMatrix3x3(a));break;case R.FLOAT_MAT4:o.setMatrix(s,a)}}static SetUniform(e,n,r,s){switch(s){case R.FLOAT:return e.setFloat(n,r),!0;case R.FLOAT_VEC2:return e.setVector2(n,t.Vector2.FromArray(r)),!0;case R.FLOAT_VEC3:return e.setVector3(n,t.Vector3.FromArray(r)),!0;case R.FLOAT_VEC4:return e.setVector4(n,t.Vector4.FromArray(r)),!0;default:return!1}}static GetWrapMode(e){switch(e){case M.CLAMP_TO_EDGE:return t.Texture.CLAMP_ADDRESSMODE;case M.MIRRORED_REPEAT:return t.Texture.MIRROR_ADDRESSMODE;case M.REPEAT:default:return t.Texture.WRAP_ADDRESSMODE}}static GetByteStrideFromType(e){switch(e.type){case"VEC2":return 2;case"VEC3":return 3;case"VEC4":case"MAT2":return 4;case"MAT3":return 9;case"MAT4":return 16;default:return 1}}static GetTextureFilterMode(e){switch(e){case w.LINEAR:case w.LINEAR_MIPMAP_NEAREST:case w.LINEAR_MIPMAP_LINEAR:return t.Texture.TRILINEAR_SAMPLINGMODE;case w.NEAREST:case w.NEAREST_MIPMAP_NEAREST:return t.Texture.NEAREST_SAMPLINGMODE;default:return t.Texture.BILINEAR_SAMPLINGMODE}}static GetBufferFromBufferView(e,t,n,r,s){n=t.byteOffset+n;const o=e.loadedBufferViews[t.buffer];if(n+r>o.byteLength)throw new Error("Buffer access is out of range");const a=o.buffer;switch(n+=o.byteOffset,s){case A.BYTE:return new Int8Array(a,n,r);case A.UNSIGNED_BYTE:return new Uint8Array(a,n,r);case A.SHORT:return new Int16Array(a,n,r);case A.UNSIGNED_SHORT:return new Uint16Array(a,n,r);default:return new Float32Array(a,n,r)}}static GetBufferFromAccessor(e,t){const n=e.bufferViews[t.bufferView],r=t.count*F.GetByteStrideFromType(t);return F.GetBufferFromBufferView(e,n,t.byteOffset,r,t.componentType)}static DecodeBufferToText(e){let t="";const n=e.byteLength;for(let r=0;r<n;++r)t+=String.fromCharCode(e[r]);return t}static GetDefaultMaterial(e){if(!F._DefaultMaterial){t.Effect.ShadersStore.GLTFDefaultMaterialVertexShader=["precision highp float;","","uniform mat4 worldView;","uniform mat4 projection;","","attribute vec3 position;","","void main(void)","{"," gl_Position = projection * worldView * vec4(position, 1.0);","}"].join("\n"),t.Effect.ShadersStore.GLTFDefaultMaterialPixelShader=["precision highp float;","","uniform vec4 u_emission;","","void main(void)","{"," gl_FragColor = u_emission;","}"].join("\n");const n={vertex:"GLTFDefaultMaterial",fragment:"GLTFDefaultMaterial"},r={attributes:["position"],uniforms:["worldView","projection","u_emission"],samplers:new Array,needAlphaBlending:!1};F._DefaultMaterial=new t.ShaderMaterial("GLTFDefaultMaterial",e,n,r),F._DefaultMaterial.setColor4("u_emission",new t.Color4(.5,.5,.5,1))}return F._DefaultMaterial}}F._DefaultMaterial=null,function(e){e[e.IDENTIFIER=1]="IDENTIFIER",e[e.UNKNOWN=2]="UNKNOWN",e[e.END_OF_INPUT=3]="END_OF_INPUT"}(S||(S={}));class I{constructor(e){this._pos=0,this.currentToken=S.UNKNOWN,this.currentIdentifier="",this.currentString="",this.isLetterOrDigitPattern=/^[a-zA-Z0-9]+$/,this._toParse=e,this._maxPos=e.length}getNextToken(){if(this.isEnd())return S.END_OF_INPUT;if(this.currentString=this.read(),this.currentToken=S.UNKNOWN,"_"===this.currentString||this.isLetterOrDigitPattern.test(this.currentString))for(this.currentToken=S.IDENTIFIER,this.currentIdentifier=this.currentString;!this.isEnd()&&(this.isLetterOrDigitPattern.test(this.currentString=this.peek())||"_"===this.currentString);)this.currentIdentifier+=this.currentString,this.forward();return this.currentToken}peek(){return this._toParse[this._pos]}read(){return this._toParse[this._pos++]}forward(){this._pos++}isEnd(){return this._pos>=this._maxPos}}const N=["MODEL","VIEW","PROJECTION","MODELVIEW","MODELVIEWPROJECTION","JOINTMATRIX"],k=["world","view","projection","worldView","worldViewProjection","mBones"],P=["translation","rotation","scale"],B=["position","rotationQuaternion","scaling"],G=(e,t,n)=>{for(const r in e){const s=e[r];n[t][r]=s}},D=e=>{if(e)for(let t=0;t<e.length/2;t++)e[2*t+1]=1-e[2*t+1]},V=e=>{if("NORMAL"===e.semantic)return"normal";if("POSITION"===e.semantic)return"position";if("JOINT"===e.semantic)return"matricesIndices";if("WEIGHT"===e.semantic)return"matricesWeights";if("COLOR"===e.semantic)return"color";if(e.semantic&&-1!==e.semantic.indexOf("TEXCOORD_")){const t=Number(e.semantic.split("_")[1]);return"uv"+(0===t?"":t+1)}return null},H=e=>{let n;if(e.translation||e.rotation||e.scale){const r=t.Vector3.FromArray(e.scale||[1,1,1]),s=t.Quaternion.FromArray(e.rotation||[0,0,0,1]),o=t.Vector3.FromArray(e.translation||[0,0,0]);n=t.Matrix.Compose(r,s,o)}else n=t.Matrix.FromArray(e.matrix);return n},$=(e,n,r,s)=>{for(let e=0;e<s.bones.length;e++)if(s.bones[e].name===r)return s.bones[e];const o=e.nodes;for(const a in o){const i=o[a];if(!i.jointName)continue;const l=i.children;for(let o=0;o<l.length;o++){const u=e.nodes[l[o]];if(u.jointName&&u.jointName===r){const r=H(i),o=new t.Bone(i.name||"",s,$(e,n,i.jointName,s),r);return o.id=a,o}}}return null},K=(e,t)=>{for(let n=0;n<e.length;n++){const r=e[n];for(let e=0;e<r.node.children.length;e++)if(r.node.children[e]===t)return r.bone}return null},W=(e,t)=>{const n=e.nodes;let r=n[t];if(r)return{node:r,id:t};for(const e in n)if(r=n[e],r.jointName===t)return{node:r,id:e};return null},U=(e,t)=>{for(let n=0;n<e.jointNames.length;n++)if(e.jointNames[n]===t)return!0;return!1},z=(e,n,r,s,o)=>{if(o||(e.scene._blockEntityCollection=!!e.assetContainer,(o=new t.Mesh(n.name||"",e.scene))._parentContainer=e.assetContainer,e.scene._blockEntityCollection=!1,o.id=s),!n.babylonNode)return o;const a=[];let i=null;const l=[],u=[],c=[],h=[];for(let n=0;n<r.length;n++){const s=r[n],o=e.meshes[s];if(o)for(let n=0;n<o.primitives.length;n++){const r=new t.VertexData,s=o.primitives[n];s.mode;const d=s.attributes;let m,_;for(const n in d)if(m=e.accessors[d[n]],_=F.GetBufferFromAccessor(e,m),"NORMAL"===n)r.normals=new Float32Array(_.length),r.normals.set(_);else if("POSITION"===n){if(g.HomogeneousCoordinates){r.positions=new Float32Array(_.length-_.length/4);for(let e=0;e<_.length;e+=4)r.positions[e]=_[e],r.positions[e+1]=_[e+1],r.positions[e+2]=_[e+2]}else r.positions=new Float32Array(_.length),r.positions.set(_);u.push(r.positions.length)}else if(-1!==n.indexOf("TEXCOORD_")){const e=Number(n.split("_")[1]),s=t.VertexBuffer.UVKind+(0===e?"":e+1),o=new Float32Array(_.length);o.set(_),D(o),r.set(o,s)}else"JOINT"===n?(r.matricesIndices=new Float32Array(_.length),r.matricesIndices.set(_)):"WEIGHT"===n?(r.matricesWeights=new Float32Array(_.length),r.matricesWeights.set(_)):"COLOR"===n&&(r.colors=new Float32Array(_.length),r.colors.set(_));if(m=e.accessors[s.indices],m)_=F.GetBufferFromAccessor(e,m),r.indices=new Int32Array(_.length),r.indices.set(_),h.push(r.indices.length);else{const e=[];for(let t=0;t<r.positions.length/3;t++)e.push(t);r.indices=new Int32Array(e),h.push(r.indices.length)}i?i.merge(r):i=r;const p=e.scene.getMaterialById(s.material);a.push(null===p?F.GetDefaultMaterial(e.scene):p),l.push(0===l.length?0:l[l.length-1]+u[u.length-2]),c.push(0===c.length?0:c[c.length-1]+h[h.length-2])}}let d;e.scene._blockEntityCollection=!!e.assetContainer,a.length>1?(d=new t.MultiMaterial("multimat"+s,e.scene),d.subMaterials=a):d=new t.StandardMaterial("multimat"+s,e.scene),1===a.length&&(d=a[0]),d._parentContainer=e.assetContainer,o.material||(o.material=d),new t.Geometry(s,e.scene,i,!1,o),o.computeWorldMatrix(!0),e.scene._blockEntityCollection=!1,o.subMeshes=[];let m=0;for(let n=0;n<r.length;n++){const s=r[n],a=e.meshes[s];if(a)for(let e=0;e<a.primitives.length;e++)a.primitives[e].mode,t.SubMesh.AddToMesh(m,l[m],u[m],c[m],h[m],o,o,!0),m++}return o},j=(e,t,n,r)=>{e.position&&(e.position=t),(e.rotationQuaternion||e.rotation)&&(e.rotationQuaternion=n),e.scaling&&(e.scaling=r)},q=(e,n,r)=>{let s=null;if(e.importOnlyMeshes&&(n.skin||n.meshes)&&e.importMeshesNames&&e.importMeshesNames.length>0&&-1===e.importMeshesNames.indexOf(n.name||""))return null;if(n.skin){if(n.meshes){const o=e.skins[n.skin],a=z(e,n,n.meshes,r,n.babylonNode);a.skeleton=e.scene.getLastSkeletonById(n.skin),null===a.skeleton&&(a.skeleton=((e,n,r,s)=>{if(s||(s=new t.Skeleton(n.name||"","",e.scene)),!n.babylonSkeleton)return s;const o=[],a=[];((e,n,r,s)=>{for(const o in e.nodes){const a=e.nodes[o],i=o;if(!a.jointName||U(r,a.jointName))continue;const l=H(a),u=new t.Bone(a.name||"",n,null,l);u.id=i,s.push({bone:u,node:a,id:i})}for(let e=0;e<s.length;e++){const t=s[e],n=t.node.children;for(let e=0;e<n.length;e++){let r=null;for(let t=0;t<s.length;t++)if(s[t].id===n[e]){r=s[t];break}r&&(r.bone._parent=t.bone,t.bone.children.push(r.bone))}}})(e,s,n,o),s.bones=[];for(let r=0;r<n.jointNames.length;r++){const i=W(e,n.jointNames[r]);if(!i)continue;const l=i.node;if(!l){t.Tools.Warn("Joint named "+n.jointNames[r]+" does not exist");continue}const u=i.id,c=e.scene.getBoneById(u);if(c){s.bones.push(c);continue}let h,d=null;for(let o=0;o<r;o++){const r=W(e,n.jointNames[o]);if(!r)continue;const a=r.node;if(!a){t.Tools.Warn("Joint named "+n.jointNames[o]+" does not exist when looking for parent");continue}const i=a.children;if(i){h=!1;for(let t=0;t<i.length;t++)if(i[t]===u){d=$(e,n,n.jointNames[o],s),h=!0;break}if(h)break}}const m=H(l);!d&&o.length>0&&(d=K(o,u),d&&-1===a.indexOf(d)&&a.push(d)),new t.Bone(l.jointName||"",s,d,m).id=u}const i=s.bones;s.bones=[];for(let t=0;t<n.jointNames.length;t++){const r=W(e,n.jointNames[t]);if(r)for(let e=0;e<i.length;e++)if(i[e].id===r.id){s.bones.push(i[e]);break}}s.prepare();for(let e=0;e<a.length;e++)s.bones.push(a[e]);return s})(e,o,0,o.babylonSkeleton),o.babylonSkeleton||(o.babylonSkeleton=a.skeleton)),s=a}}else if(n.meshes)s=z(e,n,n.mesh?[n.mesh]:n.meshes,r,n.babylonNode);else if(!n.light||n.babylonNode||e.importOnlyMeshes){if(n.camera&&!n.babylonNode&&!e.importOnlyMeshes){const r=e.cameras[n.camera];if(r){if(e.scene._blockEntityCollection=!!e.assetContainer,"orthographic"===r.type){const r=new t.FreeCamera(n.camera,t.Vector3.Zero(),e.scene,!1);r.name=n.name||"",r.mode=t.Camera.ORTHOGRAPHIC_CAMERA,r.attachControl(),s=r,r._parentContainer=e.assetContainer}else if("perspective"===r.type){const o=r[r.type],a=new t.FreeCamera(n.camera,t.Vector3.Zero(),e.scene,!1);a.name=n.name||"",a.attachControl(),o.aspectRatio||(o.aspectRatio=e.scene.getEngine().getRenderWidth()/e.scene.getEngine().getRenderHeight()),o.znear&&o.zfar&&(a.maxZ=o.zfar,a.minZ=o.znear),s=a,a._parentContainer=e.assetContainer}e.scene._blockEntityCollection=!1}}}else{const r=e.lights[n.light];if(r)if("ambient"===r.type){const o=r[r.type],a=new t.HemisphericLight(n.light,t.Vector3.Zero(),e.scene);a.name=n.name||"",o.color&&(a.diffuse=t.Color3.FromArray(o.color)),s=a}else if("directional"===r.type){const o=r[r.type],a=new t.DirectionalLight(n.light,t.Vector3.Zero(),e.scene);a.name=n.name||"",o.color&&(a.diffuse=t.Color3.FromArray(o.color)),s=a}else if("point"===r.type){const o=r[r.type],a=new t.PointLight(n.light,t.Vector3.Zero(),e.scene);a.name=n.name||"",o.color&&(a.diffuse=t.Color3.FromArray(o.color)),s=a}else if("spot"===r.type){const o=r[r.type],a=new t.SpotLight(n.light,t.Vector3.Zero(),t.Vector3.Zero(),0,0,e.scene);a.name=n.name||"",o.color&&(a.diffuse=t.Color3.FromArray(o.color)),o.fallOfAngle&&(a.angle=o.fallOfAngle),o.fallOffExponent&&(a.exponent=o.fallOffExponent),s=a}}if(!n.jointName){if(n.babylonNode)return n.babylonNode;if(null===s){e.scene._blockEntityCollection=!!e.assetContainer;const r=new t.Mesh(n.name||"",e.scene);r._parentContainer=e.assetContainer,e.scene._blockEntityCollection=!1,n.babylonNode=r,s=r}}if(null!==s){if(n.matrix&&s instanceof t.Mesh)((e,n)=>{if(n.matrix){const r=new t.Vector3(0,0,0),s=new t.Quaternion,o=new t.Vector3(0,0,0);t.Matrix.FromArray(n.matrix).decompose(o,s,r),j(e,r,s,o)}else n.translation&&n.rotation&&n.scale&&j(e,t.Vector3.FromArray(n.translation),t.Quaternion.FromArray(n.rotation),t.Vector3.FromArray(n.scale));e.computeWorldMatrix(!0)})(s,n);else{const e=n.translation||[0,0,0],r=n.rotation||[0,0,0,1],o=n.scale||[1,1,1];j(s,t.Vector3.FromArray(e),t.Quaternion.FromArray(r),t.Vector3.FromArray(o))}s.updateCache(!0),n.babylonNode=s}return s},Y=(e,t,n,r=!1)=>{const s=e.nodes[t];let o=null;if(r=!(e.importOnlyMeshes&&!r&&e.importMeshesNames)||-1!==e.importMeshesNames.indexOf(s.name||"")||0===e.importMeshesNames.length,!s.jointName&&r&&(o=q(e,s,t),null!==o&&(o.id=t,o.parent=n)),s.children)for(let t=0;t<s.children.length;t++)Y(e,s.children[t],o,r)},X=e=>{let n=e.currentScene;if(n)for(let t=0;t<n.nodes.length;t++)Y(e,n.nodes[t],null);else for(const t in e.scenes){n=e.scenes[t];for(let t=0;t<n.nodes.length;t++)Y(e,n.nodes[t],null)}(e=>{for(const n in e.animations){const r=e.animations[n];if(!r.channels||!r.samplers)continue;let s=null;for(let o=0;o<r.channels.length;o++){const a=r.channels[o],i=r.samplers[a.sampler];if(!i)continue;let l,u;r.parameters?(l=r.parameters[i.input],u=r.parameters[i.output]):(l=i.input,u=i.output);const c=F.GetBufferFromAccessor(e,e.accessors[l]),h=F.GetBufferFromAccessor(e,e.accessors[u]),d=a.target.id;let m=e.scene.getNodeById(d);if(null===m&&(m=e.scene.getNodeByName(d)),null===m){t.Tools.Warn("Creating animation named "+n+". But cannot find node named "+d+" to attach to");continue}const _=m instanceof t.Bone;let p=a.target.path;const f=P.indexOf(p);-1!==f&&(p=B[f]);let g=t.Animation.ANIMATIONTYPE_MATRIX;_||("rotationQuaternion"===p?(g=t.Animation.ANIMATIONTYPE_QUATERNION,m.rotationQuaternion=new t.Quaternion):g=t.Animation.ANIMATIONTYPE_VECTOR3);let b=null;const y=[];let T=0,x=!1;_&&s&&s.getKeys().length===c.length&&(b=s,x=!0),x||(e.scene._blockEntityCollection=!!e.assetContainer,b=new t.Animation(n,_?"_matrix":p,1,g,t.Animation.ANIMATIONLOOPMODE_CYCLE),e.scene._blockEntityCollection=!1);for(let e=0;e<c.length;e++){let n;if("rotationQuaternion"===p?(n=t.Quaternion.FromArray([h[T],h[T+1],h[T+2],h[T+3]]),T+=4):(n=t.Vector3.FromArray([h[T],h[T+1],h[T+2]]),T+=3),_){const r=m;let o=t.Vector3.Zero(),a=new t.Quaternion,i=t.Vector3.Zero(),l=r.getBaseMatrix();x&&s&&(l=s.getKeys()[e].value),l.decompose(i,a,o),"position"===p?o=n:"rotationQuaternion"===p?a=n:i=n,n=t.Matrix.Compose(i,a,o)}x?s&&(s.getKeys()[e].value=n):y.push({frame:c[e],value:n})}!x&&b&&(b.setKeys(y),m.animations.push(b)),s=b,e.scene.stopAnimation(m),e.scene.beginAnimation(m,0,c[c.length-1],!0,1)}}})(e);for(let t=0;t<e.scene.skeletons.length;t++){const n=e.scene.skeletons[t];e.scene.beginAnimation(n,0,Number.MAX_VALUE,!0,1)}},Q=(e,t,n)=>{for(const r in t.uniforms){const s=t.uniforms[r],o=t.parameters[s];if(e.currentIdentifier===r&&o.semantic&&!o.source&&!o.node){const e=N.indexOf(o.semantic);if(-1!==e)return delete n[r],k[e]}}return e.currentIdentifier},Z=e=>{for(const t in e.materials)te.LoadMaterialAsync(e,t,()=>{},()=>{})};class J{static CreateRuntime(e,t,n){const r={extensions:{},accessors:{},buffers:{},bufferViews:{},meshes:{},lights:{},cameras:{},nodes:{},images:{},textures:{},shaders:{},programs:{},samplers:{},techniques:{},materials:{},animations:{},skins:{},extensionsUsed:[],scenes:{},buffersCount:0,shaderscount:0,scene:t,rootUrl:n,loadedBufferCount:0,loadedBufferViews:{},loadedShaderCount:0,importOnlyMeshes:!1,dummyNodes:[],assetContainer:null};return e.extensions&&G(e.extensions,"extensions",r),e.extensionsUsed&&G(e.extensionsUsed,"extensionsUsed",r),e.buffers&&((e,t)=>{for(const n in e){const r=e[n];t.buffers[n]=r,t.buffersCount++}})(e.buffers,r),e.bufferViews&&G(e.bufferViews,"bufferViews",r),e.accessors&&G(e.accessors,"accessors",r),e.meshes&&G(e.meshes,"meshes",r),e.lights&&G(e.lights,"lights",r),e.cameras&&G(e.cameras,"cameras",r),e.nodes&&G(e.nodes,"nodes",r),e.images&&G(e.images,"images",r),e.textures&&G(e.textures,"textures",r),e.shaders&&((e,t)=>{for(const n in e){const r=e[n];t.shaders[n]=r,t.shaderscount++}})(e.shaders,r),e.programs&&G(e.programs,"programs",r),e.samplers&&G(e.samplers,"samplers",r),e.techniques&&G(e.techniques,"techniques",r),e.materials&&G(e.materials,"materials",r),e.animations&&G(e.animations,"animations",r),e.skins&&G(e.skins,"skins",r),e.scenes&&(r.scenes=e.scenes),e.scene&&e.scenes&&(r.currentScene=e.scenes[e.scene]),r}static LoadBufferAsync(e,n,r,s,o){const a=e.buffers[n];t.Tools.IsBase64(a.uri)?setTimeout(()=>r(new Uint8Array(t.Tools.DecodeBase64(a.uri)))):t.Tools.LoadFile(e.rootUrl+a.uri,e=>r(new Uint8Array(e)),o,void 0,!0,e=>{e&&s(e.status+" "+e.statusText)})}static LoadTextureBufferAsync(e,n,r,s){const o=e.textures[n];if(!o||!o.source)return void s("");if(o.babylonTexture)return void r(null);const a=e.images[o.source];t.Tools.IsBase64(a.uri)?setTimeout(()=>r(new Uint8Array(t.Tools.DecodeBase64(a.uri)))):t.Tools.LoadFile(e.rootUrl+a.uri,e=>r(new Uint8Array(e)),void 0,void 0,!0,e=>{e&&s(e.status+" "+e.statusText)})}static CreateTextureAsync(e,n,r,s){const o=e.textures[n];if(o.babylonTexture)return void s(o.babylonTexture);const a=e.samplers[o.sampler],i=a.minFilter===w.NEAREST_MIPMAP_NEAREST||a.minFilter===w.NEAREST_MIPMAP_LINEAR||a.minFilter===w.LINEAR_MIPMAP_NEAREST||a.minFilter===w.LINEAR_MIPMAP_LINEAR,l=t.Texture.BILINEAR_SAMPLINGMODE,u=null==r?new Blob:new Blob([t.GetBlobBufferSource(r)]),c=URL.createObjectURL(u),h=()=>URL.revokeObjectURL(c),d=new t.Texture(c,e.scene,!i,!0,l,h,h);void 0!==a.wrapS&&(d.wrapU=F.GetWrapMode(a.wrapS)),void 0!==a.wrapT&&(d.wrapV=F.GetWrapMode(a.wrapT)),d.name=n,o.babylonTexture=d,s(d)}static LoadShaderStringAsync(e,n,r,s){const o=e.shaders[n];if(t.Tools.IsBase64(o.uri)){const e=atob(o.uri.split(",")[1]);r&&r(e)}else t.Tools.LoadFile(e.rootUrl+o.uri,r,void 0,void 0,!1,e=>{e&&s&&s(e.status+" "+e.statusText)})}static LoadMaterialAsync(e,n,r,s){const o=e.materials[n];if(!o.technique)return void(s&&s("No technique found."));const a=e.techniques[o.technique];if(!a){e.scene._blockEntityCollection=!!e.assetContainer;const s=new t.StandardMaterial(n,e.scene);return s._parentContainer=e.assetContainer,e.scene._blockEntityCollection=!1,s.diffuseColor=new t.Color3(.5,.5,.5),s.sideOrientation=t.Material.CounterClockWiseSideOrientation,void r(s)}const i=e.programs[a.program],l=a.states,u=t.Effect.ShadersStore[i.vertexShader+"VertexShader"],c=t.Effect.ShadersStore[i.fragmentShader+"PixelShader"];let h="",d="";const m=new I(u),_=new I(c),p={},f=[],g=[],b=[];for(const e in a.uniforms){const t=a.uniforms[e],n=a.parameters[t];if(p[e]=n,!n.semantic||n.node||n.source)n.type===R.SAMPLER_2D?b.push(e):f.push(e);else{const t=N.indexOf(n.semantic);-1!==t?(f.push(k[t]),delete p[e]):f.push(e)}}for(const e in a.attributes){const t=a.attributes[e],n=a.parameters[t];if(n.semantic){const e=V(n);e&&g.push(e)}}for(;!m.isEnd()&&m.getNextToken();){if(m.currentToken!==S.IDENTIFIER){h+=m.currentString;continue}let e=!1;for(const t in a.attributes){const n=a.attributes[t],r=a.parameters[n];if(m.currentIdentifier===t&&r.semantic){h+=V(r),e=!0;break}}e||(h+=Q(m,a,p))}for(;!_.isEnd()&&_.getNextToken();)_.currentToken===S.IDENTIFIER?d+=Q(_,a,p):d+=_.currentString;const y={vertex:i.vertexShader+n,fragment:i.fragmentShader+n},T={attributes:g,uniforms:f,samplers:b,needAlphaBlending:l&&l.enable&&-1!==l.enable.indexOf(3042)};t.Effect.ShadersStore[i.vertexShader+n+"VertexShader"]=h,t.Effect.ShadersStore[i.fragmentShader+n+"PixelShader"]=d;const x=new t.ShaderMaterial(n,e.scene,y,T);if(x.onError=((e,t,n)=>(r,s)=>{t.dispose(!0),n("Cannot compile program named "+e.name+". Error: "+s+". Default material will be applied")})(i,x,s),x.onCompiled=((e,t,n,r,s,o)=>a=>{((e,t,n,r,s)=>{const o=r.values||n.parameters,a=n.uniforms;for(const n in s){const i=s[n],l=i.type;let u=o[a[n]];if(void 0===u&&(u=i.value),!u)continue;const c=e=>n=>{i.value&&e&&(t.setTexture(e,n),delete s[e])};l===R.SAMPLER_2D?te.LoadTextureAsync(e,r.values?u:i.value,c(n),()=>c(null)):i.value&&F.SetUniform(t,n,r.values?u:i.value,l)&&delete s[n]}})(e,t,n,r,s),t.onBind=a=>{((e,t,n,r,s,o,a)=>{const i=o.values||s.parameters;for(const a in n){const l=n[a],u=l.type;if(u===R.FLOAT_MAT2||u===R.FLOAT_MAT3||u===R.FLOAT_MAT4)if(!l.semantic||l.source||l.node){if(l.semantic&&(l.source||l.node)){let e=t.scene.getNodeByName(l.source||l.node||"");if(null===e&&(e=t.scene.getNodeById(l.source||l.node||"")),null===e)continue;F.SetMatrix(t.scene,e,l,a,r.getEffect())}}else F.SetMatrix(t.scene,e,l,a,r.getEffect());else{const e=i[s.uniforms[a]];if(!e)continue;if(u===R.SAMPLER_2D){const n=t.textures[o.values?e:l.value].babylonTexture;if(null==n)continue;r.getEffect().setTexture(a,n)}else F.SetUniform(r.getEffect(),a,e,u)}}a(r)})(a,e,s,t,n,r,o)}})(e,x,a,o,p,r),x.sideOrientation=t.Material.CounterClockWiseSideOrientation,l&&l.functions){const e=l.functions;e.cullFace&&e.cullFace[0]!==O.BACK&&(x.backFaceCulling=!1);const n=e.blendFuncSeparate;n&&(n[0]===L.SRC_ALPHA&&n[1]===L.ONE_MINUS_SRC_ALPHA&&n[2]===L.ONE&&n[3]===L.ONE?x.alphaMode=t.Constants.ALPHA_COMBINE:n[0]===L.ONE&&n[1]===L.ONE&&n[2]===L.ZERO&&n[3]===L.ONE?x.alphaMode=t.Constants.ALPHA_ONEONE:n[0]===L.SRC_ALPHA&&n[1]===L.ONE&&n[2]===L.ZERO&&n[3]===L.ONE?x.alphaMode=t.Constants.ALPHA_ADD:n[0]===L.ZERO&&n[1]===L.ONE_MINUS_SRC_COLOR&&n[2]===L.ONE&&n[3]===L.ONE?x.alphaMode=t.Constants.ALPHA_SUBTRACT:n[0]===L.DST_COLOR&&n[1]===L.ZERO&&n[2]===L.ONE&&n[3]===L.ONE?x.alphaMode=t.Constants.ALPHA_MULTIPLY:n[0]===L.SRC_ALPHA&&n[1]===L.ONE_MINUS_SRC_COLOR&&n[2]===L.ONE&&n[3]===L.ONE&&(x.alphaMode=t.Constants.ALPHA_MAXIMIZED))}}}let ee=class e{static RegisterExtension(n){e.Extensions[n.name]?t.Tools.Error('Tool with the same name "'+n.name+'" already exists'):e.Extensions[n.name]=n}dispose(){}_importMeshAsync(e,n,r,s,o,a,i,l){return n.useRightHandedSystem=!0,te.LoadRuntimeAsync(n,r,s,n=>{n.assetContainer=o,n.importOnlyMeshes=!0,""===e?n.importMeshesNames=[]:"string"==typeof e?n.importMeshesNames=[e]:!e||e instanceof Array?(n.importMeshesNames=[],t.Tools.Warn("Argument meshesNames must be of type string or string[]")):n.importMeshesNames=[e],this._createNodes(n);const r=[],s=[];for(const e in n.nodes){const s=n.nodes[e];s.babylonNode instanceof t.AbstractMesh&&r.push(s.babylonNode)}for(const e in n.skins){const r=n.skins[e];r.babylonSkeleton instanceof t.Skeleton&&s.push(r.babylonSkeleton)}this._loadBuffersAsync(n,()=>{this._loadShadersAsync(n,()=>{Z(n),X(n),!g.IncrementalLoading&&a&&a(r,s)})}),g.IncrementalLoading&&a&&a(r,s)},l),!0}importMeshAsync(e,t,n,r,s,o){return new Promise((a,i)=>{this._importMeshAsync(e,t,r,s,n,(e,t)=>{a({meshes:e,particleSystems:[],skeletons:t,animationGroups:[],lights:[],transformNodes:[],geometries:[],spriteManagers:[]})},o,e=>{i(new Error(e))})})}_loadAsync(e,t,n,r,s,o){e.useRightHandedSystem=!0,te.LoadRuntimeAsync(e,t,n,e=>{te.LoadRuntimeExtensionsAsync(e,()=>{this._createNodes(e),this._loadBuffersAsync(e,()=>{this._loadShadersAsync(e,()=>{Z(e),X(e),g.IncrementalLoading||r()})}),g.IncrementalLoading&&r()},o)},o)}loadAsync(e,t,n,r){return v(this,void 0,void 0,function*(){return yield new Promise((s,o)=>{this._loadAsync(e,t,n,()=>{s()},r,e=>{o(new Error(e))})})})}_loadShadersAsync(e,n){let r=!1;const s=(r,s)=>{te.LoadShaderStringAsync(e,r,o=>{o instanceof ArrayBuffer||(e.loadedShaderCount++,o&&(t.Effect.ShadersStore[r+(s.type===C.VERTEX?"VertexShader":"PixelShader")]=o),e.loadedShaderCount===e.shaderscount&&n())},()=>{t.Tools.Error("Error when loading shader program named "+r+" located at "+s.uri)})};for(const n in e.shaders){r=!0;const o=e.shaders[n];o?s.bind(this,n,o)():t.Tools.Error("No shader named: "+n)}r||n()}_loadBuffersAsync(e,n){let r=!1;const s=(r,s)=>{te.LoadBufferAsync(e,r,o=>{e.loadedBufferCount++,o&&(o.byteLength!=e.buffers[r].byteLength&&t.Tools.Error("Buffer named "+r+" is length "+o.byteLength+". Expected: "+s.byteLength),e.loadedBufferViews[r]=o),e.loadedBufferCount===e.buffersCount&&n()},()=>{t.Tools.Error("Error when loading buffer named "+r+" located at "+s.uri)})};for(const n in e.buffers){r=!0;const o=e.buffers[n];o?s.bind(this,n,o)():t.Tools.Error("No buffer named: "+n)}r||n()}_createNodes(e){let t=e.currentScene;if(t)for(let n=0;n<t.nodes.length;n++)Y(e,t.nodes[n],null);else for(const n in e.scenes){t=e.scenes[n];for(let n=0;n<t.nodes.length;n++)Y(e,t.nodes[n],null)}}};ee.Extensions={};class te{constructor(e){this._name=e}get name(){return this._name}loadRuntimeAsync(e,t,n,r,s){return!1}loadRuntimeExtensionsAsync(e,t,n){return!1}loadBufferAsync(e,t,n,r,s){return!1}loadTextureBufferAsync(e,t,n,r){return!1}createTextureAsync(e,t,n,r,s){return!1}loadShaderStringAsync(e,t,n,r){return!1}loadMaterialAsync(e,t,n,r){return!1}static LoadRuntimeAsync(e,t,n,r,s){te._ApplyExtensions(o=>o.loadRuntimeAsync(e,t,n,r,s),()=>{setTimeout(()=>{r&&r(J.CreateRuntime(t.json,e,n))})})}static LoadRuntimeExtensionsAsync(e,t,n){te._ApplyExtensions(r=>r.loadRuntimeExtensionsAsync(e,t,n),()=>{setTimeout(()=>{t()})})}static LoadBufferAsync(e,t,n,r,s){te._ApplyExtensions(o=>o.loadBufferAsync(e,t,n,r,s),()=>{J.LoadBufferAsync(e,t,n,r,s)})}static LoadTextureAsync(e,t,n,r){te._LoadTextureBufferAsync(e,t,s=>{s&&te._CreateTextureAsync(e,t,s,n,r)},r)}static LoadShaderStringAsync(e,t,n,r){te._ApplyExtensions(s=>s.loadShaderStringAsync(e,t,n,r),()=>{J.LoadShaderStringAsync(e,t,n,r)})}static LoadMaterialAsync(e,t,n,r){te._ApplyExtensions(s=>s.loadMaterialAsync(e,t,n,r),()=>{J.LoadMaterialAsync(e,t,n,r)})}static _LoadTextureBufferAsync(e,t,n,r){te._ApplyExtensions(s=>s.loadTextureBufferAsync(e,t,n,r),()=>{J.LoadTextureBufferAsync(e,t,n,r)})}static _CreateTextureAsync(e,t,n,r,s){te._ApplyExtensions(o=>o.createTextureAsync(e,t,n,r,s),()=>{J.CreateTextureAsync(e,t,n,r)})}static _ApplyExtensions(e,t){for(const t in ee.Extensions)if(e(ee.Extensions[t]))return;t()}}g._CreateGLTF1Loader=()=>new ee;class ne extends te{constructor(){super("KHR_binary_glTF")}loadRuntimeAsync(e,t,n,r){const s=t.json.extensionsUsed;return!(!s||-1===s.indexOf(this.name)||!t.bin||(this._bin=t.bin,r(J.CreateRuntime(t.json,e,n)),0))}loadBufferAsync(e,t,n,r){return-1!==e.extensionsUsed.indexOf(this.name)&&"binary_glTF"===t&&(this._bin.readAsync(0,this._bin.byteLength).then(n,e=>r(e.message)),!0)}loadTextureBufferAsync(e,t,n){const r=e.textures[t],s=e.images[r.source];if(!s.extensions||!(this.name in s.extensions))return!1;const o=s.extensions[this.name],a=e.bufferViews[o.bufferView];return n(F.GetBufferFromBufferView(e,a,0,a.byteLength,A.UNSIGNED_BYTE)),!0}loadShaderStringAsync(e,t,n){const r=e.shaders[t];if(!r.extensions||!(this.name in r.extensions))return!1;const s=r.extensions[this.name],o=e.bufferViews[s.bufferView],a=F.GetBufferFromBufferView(e,o,0,o.byteLength,A.UNSIGNED_BYTE);return setTimeout(()=>{const e=F.DecodeBufferToText(a);n(e)}),!0}}ee.RegisterExtension(new ne);class re extends te{constructor(){super("KHR_materials_common")}loadRuntimeExtensionsAsync(e){if(!e.extensions)return!1;const n=e.extensions[this.name];if(!n)return!1;const r=n.lights;if(r)for(const n in r){const s=r[n];switch(s.type){case"ambient":{const n=new t.HemisphericLight(s.name,new t.Vector3(0,1,0),e.scene),r=s.ambient;r&&(n.diffuse=t.Color3.FromArray(r.color||[1,1,1]));break}case"point":{const n=new t.PointLight(s.name,new t.Vector3(10,10,10),e.scene),r=s.point;r&&(n.diffuse=t.Color3.FromArray(r.color||[1,1,1]));break}case"directional":{const n=new t.DirectionalLight(s.name,new t.Vector3(0,-1,0),e.scene),r=s.directional;r&&(n.diffuse=t.Color3.FromArray(r.color||[1,1,1]));break}case"spot":{const n=s.spot;n&&(new t.SpotLight(s.name,new t.Vector3(0,10,0),new t.Vector3(0,-1,0),n.fallOffAngle||Math.PI,n.fallOffExponent||0,e.scene).diffuse=t.Color3.FromArray(n.color||[1,1,1]));break}default:t.Tools.Warn('GLTF Material Common extension: light type "'+s.type+"” not supported")}}return!1}loadMaterialAsync(e,n,r,s){const o=e.materials[n];if(!o||!o.extensions)return!1;const a=o.extensions[this.name];if(!a)return!1;const i=new t.StandardMaterial(n,e.scene);return i.sideOrientation=t.Material.CounterClockWiseSideOrientation,"CONSTANT"===a.technique&&(i.disableLighting=!0),i.backFaceCulling=void 0!==a.doubleSided&&!a.doubleSided,i.alpha=void 0===a.values.transparency?1:a.values.transparency,i.specularPower=void 0===a.values.shininess?0:a.values.shininess,"string"==typeof a.values.ambient?this._loadTexture(e,a.values.ambient,i,"ambientTexture",s):i.ambientColor=t.Color3.FromArray(a.values.ambient||[0,0,0]),"string"==typeof a.values.diffuse?this._loadTexture(e,a.values.diffuse,i,"diffuseTexture",s):i.diffuseColor=t.Color3.FromArray(a.values.diffuse||[0,0,0]),"string"==typeof a.values.emission?this._loadTexture(e,a.values.emission,i,"emissiveTexture",s):i.emissiveColor=t.Color3.FromArray(a.values.emission||[0,0,0]),"string"==typeof a.values.specular?this._loadTexture(e,a.values.specular,i,"specularTexture",s):i.specularColor=t.Color3.FromArray(a.values.specular||[0,0,0]),!0}_loadTexture(e,t,n,r,s){J.LoadTextureBufferAsync(e,t,s=>{J.CreateTextureAsync(e,t,s,e=>n[r]=e)},s)}}ee.RegisterExtension(new re);var se={__proto__:null,get EBlendingFunction(){return L},get EComponentType(){return A},get ECullingType(){return O},get EParameterType(){return R},get EShaderType(){return C},get ETextureFilterType(){return w},get ETextureFormat(){return E},get ETextureWrapMode(){return M},GLTFBinaryExtension:ne,GLTFLoader:ee,GLTFLoaderBase:J,GLTFLoaderExtension:te,GLTFMaterialsCommonExtension:re,GLTFUtils:F};const oe="undefined"!=typeof global?global:"undefined"!=typeof window?window:void 0;if(void 0!==oe){oe.BABYLON=oe.BABYLON||{},oe.BABYLON.GLTF1=oe.BABYLON.GLTF1||{};for(const e in se)oe.BABYLON.GLTF1[e]=se[e]}const ae=[{regex:new RegExp("^/nodes/\\d+/extensions/")}];class ie{constructor(e,t){this._gltf=e,this._infoTree=t}convert(e){let t,n=this._gltf,r=this._infoTree;if(!e.startsWith("/"))throw new Error("Path must start with a /");const s=e.split("/");if(s.shift(),s[s.length-1].includes(".length")){const e=s[s.length-1].split(".");s.pop(),s.push(...e)}let o=!1;for(const a of s){const s="length"===a;if(s&&!r.__array__)throw new Error(`Path ${e} is invalid`);if(r.__ignoreObjectTree__&&(o=!0),r.__array__&&!s)r=r.__array__;else if(r=r[a],!r)throw new Error(`Path ${e} is invalid`);if(!o)if(void 0===n){if(!ae.find(t=>t.regex.test(e)))throw new Error(`Path ${e} is invalid`)}else s||(n=null==n?void 0:n[a]);(r.__target__||s)&&(t=n)}return{object:t,info:r}}}function le(e,t,n,r){const s=ue(e);return r?s[n][r]:s[n]}function ue(e,n,r){var s,o,a;return null===(a=null===(s=e._data)||void 0===s?void 0:s[null!==(o=null==r?void 0:r.fillMode)&&void 0!==o?o:t.Constants.MATERIAL_TriangleFillMode])||void 0===a?void 0:a.babylonMaterial}function ce(e,n){return{offset:{componentsCount:2,type:"Vector2",get:(r,s,o)=>{const a=le(r,0,e,n);return new t.Vector2(null==a?void 0:a.uOffset,null==a?void 0:a.vOffset)},getTarget:ue,set:(t,r,s,o)=>{const a=le(r,0,e,n);a.uOffset=t.x,a.vOffset=t.y},getPropertyName:[()=>`${e}${n?"."+n:""}.uOffset`,()=>`${e}${n?"."+n:""}.vOffset`]},rotation:{type:"number",get:(t,r,s)=>{var o;return null===(o=le(t,0,e,n))||void 0===o?void 0:o.wAng},getTarget:ue,set:(t,r,s,o)=>le(r,0,e,n).wAng=t,getPropertyName:[()=>`${e}${n?"."+n:""}.wAng`]},scale:{componentsCount:2,type:"Vector2",get:(r,s,o)=>{const a=le(r,0,e,n);return new t.Vector2(null==a?void 0:a.uScale,null==a?void 0:a.vScale)},getTarget:ue,set:(t,r,s,o)=>{const a=le(r,0,e,n);a.uScale=t.x,a.vScale=t.y},getPropertyName:[()=>`${e}${n?"."+n:""}.uScale`,()=>`${e}${n?"."+n:""}.vScale`]}}}const he={cameras:{__array__:{__target__:!0,orthographic:{xmag:{componentsCount:2,type:"Vector2",get:e=>{var n,r,s,o;return new t.Vector2(null!==(r=null===(n=e._babylonCamera)||void 0===n?void 0:n.orthoLeft)&&void 0!==r?r:0,null!==(o=null===(s=e._babylonCamera)||void 0===s?void 0:s.orthoRight)&&void 0!==o?o:0)},set:(e,t)=>{t._babylonCamera&&(t._babylonCamera.orthoLeft=e.x,t._babylonCamera.orthoRight=e.y)},getTarget:e=>e,getPropertyName:[()=>"orthoLeft",()=>"orthoRight"]},ymag:{componentsCount:2,type:"Vector2",get:e=>{var n,r,s,o;return new t.Vector2(null!==(r=null===(n=e._babylonCamera)||void 0===n?void 0:n.orthoBottom)&&void 0!==r?r:0,null!==(o=null===(s=e._babylonCamera)||void 0===s?void 0:s.orthoTop)&&void 0!==o?o:0)},set:(e,t)=>{t._babylonCamera&&(t._babylonCamera.orthoBottom=e.x,t._babylonCamera.orthoTop=e.y)},getTarget:e=>e,getPropertyName:[()=>"orthoBottom",()=>"orthoTop"]},zfar:{type:"number",get:e=>{var t;return null===(t=e._babylonCamera)||void 0===t?void 0:t.maxZ},set:(e,t)=>{t._babylonCamera&&(t._babylonCamera.maxZ=e)},getTarget:e=>e,getPropertyName:[()=>"maxZ"]},znear:{type:"number",get:e=>{var t;return null===(t=e._babylonCamera)||void 0===t?void 0:t.minZ},set:(e,t)=>{t._babylonCamera&&(t._babylonCamera.minZ=e)},getTarget:e=>e,getPropertyName:[()=>"minZ"]}},perspective:{aspectRatio:{type:"number",get:e=>{var t;return null===(t=e._babylonCamera)||void 0===t?void 0:t.getEngine().getAspectRatio(e._babylonCamera)},getTarget:e=>e,getPropertyName:[()=>"aspectRatio"],isReadOnly:!0},yfov:{type:"number",get:e=>{var t;return null===(t=e._babylonCamera)||void 0===t?void 0:t.fov},set:(e,t)=>{t._babylonCamera&&(t._babylonCamera.fov=e)},getTarget:e=>e,getPropertyName:[()=>"fov"]},zfar:{type:"number",get:e=>{var t;return null===(t=e._babylonCamera)||void 0===t?void 0:t.maxZ},set:(e,t)=>{t._babylonCamera&&(t._babylonCamera.maxZ=e)},getTarget:e=>e,getPropertyName:[()=>"maxZ"]},znear:{type:"number",get:e=>{var t;return null===(t=e._babylonCamera)||void 0===t?void 0:t.minZ},set:(e,t)=>{t._babylonCamera&&(t._babylonCamera.minZ=e)},getTarget:e=>e,getPropertyName:[()=>"minZ"]}}}},nodes:{length:{type:"number",get:e=>e.length,getTarget:e=>e.map(e=>e._babylonTransformNode),getPropertyName:[()=>"length"]},__array__:{__target__:!0,translation:{type:"Vector3",get:e=>{var t;return null===(t=e._babylonTransformNode)||void 0===t?void 0:t.position},set:(e,t)=>{var n;return null===(n=t._babylonTransformNode)||void 0===n?void 0:n.position.copyFrom(e)},getTarget:e=>e._babylonTransformNode,getPropertyName:[()=>"position"]},rotation:{type:"Quaternion",get:e=>{var t;return null===(t=e._babylonTransformNode)||void 0===t?void 0:t.rotationQuaternion},set:(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:e=>e._babylonTransformNode,getPropertyName:[()=>"rotationQuaternion"]},scale:{type:"Vector3",get:e=>{var t;return null===(t=e._babylonTransformNode)||void 0===t?void 0:t.scaling},set:(e,t)=>{var n;return null===(n=t._babylonTransformNode)||void 0===n?void 0:n.scaling.copyFrom(e)},getTarget:e=>e._babylonTransformNode,getPropertyName:[()=>"scaling"]},weights:{length:{type:"number",get:e=>e._numMorphTargets,getTarget:e=>e._babylonTransformNode,getPropertyName:[()=>"influence"]},__array__:{__target__:!0,type:"number",get:(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:e=>e._babylonTransformNode,getPropertyName:[()=>"influence"]},type:"number[]",get:(e,t)=>[0],getTarget:e=>e._babylonTransformNode,getPropertyName:[()=>"influence"]},matrix:{type:"Matrix",get:e=>{var n,r,s;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===(s=e._babylonTransformNode)||void 0===s?void 0:s.position)},getTarget:e=>e._babylonTransformNode,isReadOnly:!0},globalMatrix:{type:"Matrix",get:e=>{var n,r,s,o,a,i,l;const u=t.Matrix.Identity();let c=e.parent;for(;c&&c.parent;)c=c.parent;const h=(null===(n=e._babylonTransformNode)||void 0===n?void 0:n.position._isDirty)||(null===(s=null===(r=e._babylonTransformNode)||void 0===r?void 0:r.rotationQuaternion)||void 0===s?void 0:s._isDirty)||(null===(o=e._babylonTransformNode)||void 0===o?void 0:o.scaling._isDirty);if(c){const t=null===(a=c._babylonTransformNode)||void 0===a?void 0:a.computeWorldMatrix(!0).invert();t&&(null===(l=null===(i=e._babylonTransformNode)||void 0===i?void 0:i.computeWorldMatrix(h))||void 0===l||l.multiplyToRef(t,u))}else e._babylonTransformNode&&u.copyFrom(e._babylonTransformNode.computeWorldMatrix(h));return u},getTarget:e=>e._babylonTransformNode,isReadOnly:!0},extensions:{EXT_lights_ies:{multiplier:{type:"number",get:e=>{var n,r;return null===(r=null===(n=e._babylonTransformNode)||void 0===n?void 0:n.getChildren(e=>e instanceof t.SpotLight,!0)[0])||void 0===r?void 0:r.intensity},getTarget:e=>{var n;return null===(n=e._babylonTransformNode)||void 0===n?void 0:n.getChildren(e=>e instanceof t.SpotLight,!0)[0]},set:(e,n)=>{if(n._babylonTransformNode){const r=n._babylonTransformNode.getChildren(e=>e instanceof t.SpotLight,!0)[0];r&&(r.intensity=e)}}},color:{type:"Color3",get:e=>{var n,r;return null===(r=null===(n=e._babylonTransformNode)||void 0===n?void 0:n.getChildren(e=>e instanceof t.SpotLight,!0)[0])||void 0===r?void 0:r.diffuse},getTarget:e=>{var n;return null===(n=e._babylonTransformNode)||void 0===n?void 0:n.getChildren(e=>e instanceof t.SpotLight,!0)[0]},set:(e,n)=>{if(n._babylonTransformNode){const r=n._babylonTransformNode.getChildren(e=>e instanceof t.SpotLight,!0)[0];r&&(r.diffuse=e)}}}},KHR_node_visibility:{visible:{type:"boolean",get:e=>!!e._primitiveBabylonMeshes&&e._primitiveBabylonMeshes[0].isVisible,getTarget:()=>{},set:(e,t)=>{t._primitiveBabylonMeshes&&t._primitiveBabylonMeshes.forEach(t=>t.isVisible=e)}}}}}},materials:{__array__:{__target__:!0,emissiveFactor:{type:"Color3",get:(e,t,n)=>ue(e,0,n).emissiveColor,set:(e,t,n,r)=>ue(t,0,r).emissiveColor.copyFrom(e),getTarget:(e,t,n)=>ue(e,0,n),getPropertyName:[()=>"emissiveColor"]},emissiveTexture:{extensions:{KHR_texture_transform:ce("emissiveTexture")}},normalTexture:{scale:{type:"number",get:(e,t,n)=>{var r;return null===(r=le(e,0,"bumpTexture"))||void 0===r?void 0:r.level},set:(e,t,n,r)=>{const s=le(t,0,"bumpTexture");s&&(s.level=e)},getTarget:(e,t,n)=>ue(e,0,n),getPropertyName:[()=>"level"]},extensions:{KHR_texture_transform:ce("bumpTexture")}},occlusionTexture:{strength:{type:"number",get:(e,t,n)=>ue(e,0,n).ambientTextureStrength,set:(e,t,n,r)=>{const s=ue(t,0,r);s&&(s.ambientTextureStrength=e)},getTarget:(e,t,n)=>ue(e,0,n),getPropertyName:[()=>"ambientTextureStrength"]},extensions:{KHR_texture_transform:ce("ambientTexture")}},pbrMetallicRoughness:{baseColorFactor:{type:"Color4",get:(e,n,r)=>{const s=ue(e,0,r);return t.Color4.FromColor3(s.albedoColor,s.alpha)},set:(e,t,n,r)=>{const s=ue(t,0,r);s.albedoColor.set(e.r,e.g,e.b),s.alpha=e.a},getTarget:(e,t,n)=>ue(e,0,n),getPropertyName:[()=>"albedoColor",()=>"alpha"]},baseColorTexture:{extensions:{KHR_texture_transform:ce("albedoTexture")}},metallicFactor:{type:"number",get:(e,t,n)=>ue(e,0,n).metallic,set:(e,t,n,r)=>{const s=ue(t,0,r);s&&(s.metallic=e)},getTarget:(e,t,n)=>ue(e,0,n),getPropertyName:[()=>"metallic"]},roughnessFactor:{type:"number",get:(e,t,n)=>ue(e,0,n).roughness,set:(e,t,n,r)=>{const s=ue(t,0,r);s&&(s.roughness=e)},getTarget:(e,t,n)=>ue(e,0,n),getPropertyName:[()=>"roughness"]},metallicRoughnessTexture:{extensions:{KHR_texture_transform:ce("metallicTexture")}}},extensions:{KHR_materials_anisotropy:{anisotropyStrength:{type:"number",get:(e,t,n)=>ue(e,0,n).anisotropy.intensity,set:(e,t,n,r)=>{ue(t,0,r).anisotropy.intensity=e},getTarget:(e,t,n)=>ue(e,0,n),getPropertyName:[()=>"anisotropy.intensity"]},anisotropyRotation:{type:"number",get:(e,t,n)=>ue(e,0,n).anisotropy.angle,set:(e,t,n,r)=>{ue(t,0,r).anisotropy.angle=e},getTarget:(e,t,n)=>ue(e,0,n),getPropertyName:[()=>"anisotropy.angle"]},anisotropyTexture:{extensions:{KHR_texture_transform:ce("anisotropy","texture")}}},KHR_materials_clearcoat:{clearcoatFactor:{type:"number",get:(e,t,n)=>ue(e,0,n).clearCoat.intensity,set:(e,t,n,r)=>{ue(t,0,r).clearCoat.intensity=e},getTarget:(e,t,n)=>ue(e,0,n),getPropertyName:[()=>"clearCoat.intensity"]},clearcoatRoughnessFactor:{type:"number",get:(e,t,n)=>ue(e,0,n).clearCoat.roughness,set:(e,t,n,r)=>{ue(t,0,r).clearCoat.roughness=e},getTarget:(e,t,n)=>ue(e,0,n),getPropertyName:[()=>"clearCoat.roughness"]},clearcoatTexture:{extensions:{KHR_texture_transform:ce("clearCoat","texture")}},clearcoatNormalTexture:{scale:{type:"number",get:(e,t,n)=>{var r;return null===(r=ue(e,0,n).clearCoat.bumpTexture)||void 0===r?void 0:r.level},getTarget:ue,set:(e,t,n,r)=>ue(t,0,r).clearCoat.bumpTexture.level=e},extensions:{KHR_texture_transform:ce("clearCoat","bumpTexture")}},clearcoatRoughnessTexture:{extensions:{KHR_texture_transform:ce("clearCoat","textureRoughness")}}},KHR_materials_dispersion:{dispersion:{type:"number",get:(e,t,n)=>ue(e,0,n).subSurface.dispersion,getTarget:ue,set:(e,t,n,r)=>ue(t,0,r).subSurface.dispersion=e}},KHR_materials_emissive_strength:{emissiveStrength:{type:"number",get:(e,t,n)=>ue(e,0,n).emissiveIntensity,getTarget:ue,set:(e,t,n,r)=>ue(t,0,r).emissiveIntensity=e}},KHR_materials_ior:{ior:{type:"number",get:(e,t,n)=>ue(e,0,n).indexOfRefraction,getTarget:ue,set:(e,t,n,r)=>ue(t,0,r).indexOfRefraction=e}},KHR_materials_iridescence:{iridescenceFactor:{type:"number",get:(e,t,n)=>ue(e,0,n).iridescence.intensity,getTarget:ue,set:(e,t,n,r)=>ue(t,0,r).iridescence.intensity=e},iridescenceIor:{type:"number",get:(e,t,n)=>ue(e,0,n).iridescence.indexOfRefraction,getTarget:ue,set:(e,t,n,r)=>ue(t,0,r).iridescence.indexOfRefraction=e},iridescenceTexture:{extensions:{KHR_texture_transform:ce("iridescence","texture")}},iridescenceThicknessMaximum:{type:"number",get:(e,t,n)=>ue(e,0,n).iridescence.maximumThickness,getTarget:ue,set:(e,t,n,r)=>ue(t,0,r).iridescence.maximumThickness=e},iridescenceThicknessMinimum:{type:"number",get:(e,t,n)=>ue(e,0,n).iridescence.minimumThickness,getTarget:ue,set:(e,t,n,r)=>ue(t,0,r).iridescence.minimumThickness=e},iridescenceThicknessTexture:{extensions:{KHR_texture_transform:ce("iridescence","thicknessTexture")}}},KHR_materials_sheen:{sheenColorFactor:{type:"Color3",get:(e,t,n)=>ue(e,0,n).sheen.color,getTarget:ue,set:(e,t,n,r)=>ue(t,0,r).sheen.color.copyFrom(e)},sheenColorTexture:{extensions:{KHR_texture_transform:ce("sheen","texture")}},sheenRoughnessFactor:{type:"number",get:(e,t,n)=>ue(e,0,n).sheen.intensity,getTarget:ue,set:(e,t,n,r)=>ue(t,0,r).sheen.intensity=e},sheenRoughnessTexture:{extensions:{KHR_texture_transform:ce("sheen","thicknessTexture")}}},KHR_materials_specular:{specularFactor:{type:"number",get:(e,t,n)=>ue(e,0,n).metallicF0Factor,getTarget:ue,set:(e,t,n,r)=>ue(t,0,r).metallicF0Factor=e,getPropertyName:[()=>"metallicF0Factor"]},specularColorFactor:{type:"Color3",get:(e,t,n)=>ue(e,0,n).metallicReflectanceColor,getTarget:ue,set:(e,t,n,r)=>ue(t,0,r).metallicReflectanceColor.copyFrom(e),getPropertyName:[()=>"metallicReflectanceColor"]},specularTexture:{extensions:{KHR_texture_transform:ce("metallicReflectanceTexture")}},specularColorTexture:{extensions:{KHR_texture_transform:ce("reflectanceTexture")}}},KHR_materials_transmission:{transmissionFactor:{type:"number",get:(e,t,n)=>ue(e,0,n).subSurface.refractionIntensity,getTarget:ue,set:(e,t,n,r)=>ue(t,0,r).subSurface.refractionIntensity=e,getPropertyName:[()=>"subSurface.refractionIntensity"]},transmissionTexture:{extensions:{KHR_texture_transform:ce("subSurface","refractionIntensityTexture")}}},KHR_materials_diffuse_transmission:{diffuseTransmissionFactor:{type:"number",get:(e,t,n)=>ue(e,0,n).subSurface.translucencyIntensity,getTarget:ue,set:(e,t,n,r)=>ue(t,0,r).subSurface.translucencyIntensity=e},diffuseTransmissionTexture:{extensions:{KHR_texture_transform:ce("subSurface","translucencyIntensityTexture")}},diffuseTransmissionColorFactor:{type:"Color3",get:(e,t,n)=>ue(e,0,n).subSurface.translucencyColor,getTarget:ue,set:(e,t,n,r)=>{var s;return e&&(null===(s=ue(t,0,r).subSurface.translucencyColor)||void 0===s?void 0:s.copyFrom(e))}},diffuseTransmissionColorTexture:{extensions:{KHR_texture_transform:ce("subSurface","translucencyColorTexture")}}},KHR_materials_volume:{attenuationColor:{type:"Color3",get:(e,t,n)=>ue(e,0,n).subSurface.tintColor,getTarget:ue,set:(e,t,n,r)=>ue(t,0,r).subSurface.tintColor.copyFrom(e)},attenuationDistance:{type:"number",get:(e,t,n)=>ue(e,0,n).subSurface.tintColorAtDistance,getTarget:ue,set:(e,t,n,r)=>ue(t,0,r).subSurface.tintColorAtDistance=e},thicknessFactor:{type:"number",get:(e,t,n)=>ue(e,0,n).subSurface.maximumThickness,getTarget:ue,set:(e,t,n,r)=>ue(t,0,r).subSurface.maximumThickness=e},thicknessTexture:{extensions:{KHR_texture_transform:ce("subSurface","thicknessTexture")}}}}}},extensions:{KHR_lights_punctual:{lights:{length:{type:"number",get:e=>e.length,getTarget:e=>e.map(e=>e._babylonLight),getPropertyName:[e=>"length"]},__array__:{__target__:!0,color:{type:"Color3",get:e=>{var t;return null===(t=e._babylonLight)||void 0===t?void 0:t.diffuse},set:(e,t)=>{var n;return null===(n=t._babylonLight)||void 0===n?void 0:n.diffuse.copyFrom(e)},getTarget:e=>e._babylonLight,getPropertyName:[e=>"diffuse"]},intensity:{type:"number",get:e=>{var t;return null===(t=e._babylonLight)||void 0===t?void 0:t.intensity},set:(e,t)=>t._babylonLight?t._babylonLight.intensity=e:void 0,getTarget:e=>e._babylonLight,getPropertyName:[e=>"intensity"]},range:{type:"number",get:e=>{var t;return null===(t=e._babylonLight)||void 0===t?void 0:t.range},set:(e,t)=>t._babylonLight?t._babylonLight.range=e:void 0,getTarget:e=>e._babylonLight,getPropertyName:[e=>"range"]},spot:{innerConeAngle:{type:"number",get:e=>{var t;return null===(t=e._babylonLight)||void 0===t?void 0:t.innerAngle},set:(e,t)=>t._babylonLight?t._babylonLight.innerAngle=e:void 0,getTarget:e=>e._babylonLight,getPropertyName:[e=>"innerConeAngle"]},outerConeAngle:{type:"number",get:e=>{var t;return null===(t=e._babylonLight)||void 0===t?void 0:t.angle},set:(e,t)=>t._babylonLight?t._babylonLight.angle=e:void 0,getTarget:e=>e._babylonLight,getPropertyName:[e=>"outerConeAngle"]}}}}},EXT_lights_area:{lights:{length:{type:"number",get:e=>e.length,getTarget:e=>e.map(e=>e._babylonLight),getPropertyName:[e=>"length"]},__array__:{__target__:!0,color:{type:"Color3",get:e=>{var t;return null===(t=e._babylonLight)||void 0===t?void 0:t.diffuse},set:(e,t)=>{var n;return null===(n=t._babylonLight)||void 0===n?void 0:n.diffuse.copyFrom(e)},getTarget:e=>e._babylonLight,getPropertyName:[e=>"diffuse"]},intensity:{type:"number",get:e=>{var t;return null===(t=e._babylonLight)||void 0===t?void 0:t.intensity},set:(e,t)=>t._babylonLight?t._babylonLight.intensity=e:void 0,getTarget:e=>e._babylonLight,getPropertyName:[e=>"intensity"]},size:{type:"number",get:e=>{var t;return null===(t=e._babylonLight)||void 0===t?void 0:t.height},set:(e,t)=>t._babylonLight?t._babylonLight.height=e:void 0,getTarget:e=>e._babylonLight,getPropertyName:[e=>"size"]},rect:{aspect:{type:"number",get: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:(e,t)=>t._babylonLight?t._babylonLight.width=e*t._babylonLight.height:void 0,getTarget:e=>e._babylonLight,getPropertyName:[e=>"aspect"]}}}}},EXT_lights_ies:{lights:{length:{type:"number",get:e=>e.length,getTarget:e=>e.map(e=>e._babylonLight),getPropertyName:[e=>"length"]}}},EXT_lights_image_based:{lights:{length:{type:"number",get:e=>e.length,getTarget:e=>e.map(e=>e._babylonTexture),getPropertyName:[e=>"length"]},__array__:{__target__:!0,intensity:{type:"number",get:e=>{var t;return null===(t=e._babylonTexture)||void 0===t?void 0:t.level},set:(e,t)=>{t._babylonTexture&&(t._babylonTexture.level=e)},getTarget:e=>e._babylonTexture},rotation:{type:"Quaternion",get:e=>{var n;return e._babylonTexture&&t.Quaternion.FromRotationMatrix(null===(n=e._babylonTexture)||void 0===n?void 0:n.getReflectionTextureMatrix())},set:(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:e=>e._babylonTexture}}}}},animations:{length:{type:"number",get:e=>e.length,getTarget:e=>e.map(e=>e._babylonAnimationGroup),getPropertyName:[()=>"length"]},__array__:{}},meshes:{length:{type:"number",get:e=>e.length,getTarget:e=>e.map(e=>{var t;return null===(t=e.primitives[0]._instanceData)||void 0===t?void 0:t.babylonSourceMesh}),getPropertyName:[()=>"length"]},__array__:{}}};function de(e){return new ie(e,he)}function me(e){const t=e.split("/").map(e=>e.replace(/{}/g,"__array__"));let n=he;for(const e of t)e&&(n=n[e]);if(n&&n.type&&n.get)return n}function _e(e,t){const n=e.split("/").map(e=>e.replace(/{}/g,"__array__"));let r=he;for(const e of n)e&&(r=r[e]);r&&r.type&&r.get&&(r.interpolation=t)}function pe(e,t){const n=e.split("/").map(e=>e.replace(/{}/g,"__array__"));let r=he;for(const e of n)if(e){if(!r[e]){if("?"===e){r.__ignoreObjectTree__=!0;continue}r[e]={},"__array__"===e&&(r[e].__target__=!0)}r=r[e]}Object.assign(r,t)}const fe=new Map,ge=fe;function be(e,n,r){ye(e)&&t.Logger.Warn(`Extension with the name '${e}' already exists`),fe.set(e,{isGLTFExtension:n,factory:r})}function ye(e){return fe.delete(e)}const Te=new t.Lazy(()=>Promise.resolve(BABYLON)),xe=new t.Lazy(()=>Promise.resolve().then(function(){return ur}));class ve{static Get(e,t,n){if(!t||null==n||!t[n])throw new Error(`${e}: Failed to find index (${n})`);return t[n]}static TryGet(e,t){return e&&null!=t&&e[t]?e[t]:null}static Assign(e){if(e)for(let t=0;t<e.length;t++)e[t].index=t}}function Ae(e){if(e.min&&e.max){const n=e.min,r=e.max,s=t.TmpVectors.Vector3[0].copyFromFloats(n[0],n[1],n[2]),o=t.TmpVectors.Vector3[1].copyFromFloats(r[0],r[1],r[2]);if(e.normalized&&5126!==e.componentType){let t=1;switch(e.componentType){case 5120:t=127;break;case 5121:t=255;break;case 5122:t=32767;break;case 5123:t=65535}const n=1/t;s.scaleInPlace(n),o.scaleInPlace(n)}return new t.BoundingInfo(s,o)}return null}class Ce{isMatchingMaterialType(e){if(!e)return!1;const t=Array.from(this._pbrMaterialImpls.values());for(const n of t)if(e instanceof n.materialClass)return!0;return!1}static RegisterExtension(e,t){be(e,!1,t)}static UnregisterExtension(e){return ye(e)}get gltf(){if(!this._gltf)throw new Error("glTF JSON is not available");return this._gltf}get bin(){return this._bin}get parent(){return this._parent}get babylonScene(){if(!this._babylonScene)throw new Error("Scene is not available");return this._babylonScene}get rootBabylonMesh(){return this._rootBabylonMesh}get rootUrl(){return this._rootUrl}constructor(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}_getOrCreateMaterialAdapter(e){let t=this._materialAdapterCache.get(e);if(!t){const n=Array.from(this._pbrMaterialImpls.values());for(const r of n)if(e instanceof r.materialClass){t=new r.adapterClass(e);break}if(!t)throw new Error("Appropriate material adapter class not found");const r=t;this._materialAdapterCache.set(e,r),this._materialAdapters.add(r)}return t}dispose(){this._disposed||(this._disposed=!0,this._completePromises.length=0,this._extensions.forEach(e=>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())}importMeshAsync(e,t,n,r,s,o){return v(this,arguments,void 0,function*(e,t,n,r,s,o,a=""){return yield Promise.resolve().then(()=>v(this,void 0,void 0,function*(){this._babylonScene=t,this._assetContainer=n,this._loadData(r);let o=null;if(e){const t={};if(this._gltf.nodes)for(const e of this._gltf.nodes)e.name&&(t[e.name]=e.index);o=(e instanceof Array?e:[e]).map(e=>{const n=t[e];if(void 0===n)throw new Error(`Failed to find node '${e}'`);return n})}return yield this._loadAsync(s,a,o,()=>({meshes:this._getMeshes(),particleSystems:[],skeletons:this._getSkeletons(),animationGroups:this._getAnimationGroups(),lights:this._babylonLights,transformNodes:this._getTransformNodes(),geometries:this._getGeometries(),spriteManagers:[]}))}))})}loadAsync(e,t,n,r){return v(this,arguments,void 0,function*(e,t,n,r,s=""){return this._babylonScene=e,this._loadData(t),yield this._loadAsync(n,s,null,()=>{})})}_loadAsync(n,r,s,o){return v(this,void 0,void 0,function*(){return yield Promise.resolve().then(()=>v(this,void 0,void 0,function*(){var a;if(this._rootUrl=n,this._uniqueRootUrl=!n.startsWith("file:")&&r?n:`${n}${Date.now()}/`,this._fileName=r,this._allMaterialsDirtyRequired=!1,yield this._loadExtensionsAsync(),!this.parent.skipMaterials){const e=this.parent.useOpenPBR||this.isExtensionUsed("KHR_materials_openpbr");let t=!1;this.parent.useOpenPBR?(null===(a=this._gltf.materials)||void 0===a?void 0:a.length)&&this._gltf.materials.some(e=>{var t;return!(null===(t=e.extensions)||void 0===t?void 0:t.KHR_materials_openpbr)})&&(t=!0):t=!0;const n=[];e&&!this._pbrMaterialImpls.has("openpbr")&&n.push(Promise.all([Promise.resolve(BABYLON),Promise.resolve().then(function(){return Bs})]).then(([{OpenPBRMaterial:e,RegisterOpenpbrMaterial:t},{OpenPBRMaterialLoadingAdapter:n}])=>{t(),this._pbrMaterialImpls.set("openpbr",{materialClass:e,adapterClass:n})})),t&&!this._pbrMaterialImpls.has("pbr")&&n.push(Promise.all([Promise.resolve(BABYLON),Promise.resolve().then(function(){return Ds})]).then(([{PBRMaterial:e,RegisterPbrMaterial:t},{PBRMaterialLoadingAdapter:n}])=>{t(),this._pbrMaterialImpls.set("pbr",{materialClass:e,adapterClass:n})})),yield Promise.all(n)}const i=`${e.GLTFLoaderState[e.GLTFLoaderState.LOADING]} => ${e.GLTFLoaderState[e.GLTFLoaderState.READY]}`,l=`${e.GLTFLoaderState[e.GLTFLoaderState.LOADING]} => ${e.GLTFLoaderState[e.GLTFLoaderState.COMPLETE]}`;this._parent._startPerformanceCounter(i),this._parent._startPerformanceCounter(l),this._parent._setState(e.GLTFLoaderState.LOADING),this._extensionsOnLoading();const u=new Array,c=this._babylonScene.blockMaterialDirtyMechanism;if(this._babylonScene.blockMaterialDirtyMechanism=!0,!this.parent.loadOnlyMaterials)if(s)u.push(this.loadSceneAsync("/nodes",{nodes:s,index:-1}));else if(null!=this._gltf.scene||this._gltf.scenes&&this._gltf.scenes[0]){const e=ve.Get("/scene",this._gltf.scenes,this._gltf.scene||0);u.push(this.loadSceneAsync(`/scenes/${e.index}`,e))}if(!this.parent.skipMaterials&&this.parent.loadAllMaterials&&this._gltf.materials)for(let e=0;e<this._gltf.materials.length;++e){const n=this._gltf.materials[e],r="/materials/"+e,s=t.Material.TriangleFillMode;u.push(this._loadMaterialAsync(r,n,null,s,()=>{}))}this._allMaterialsDirtyRequired?this._babylonScene.blockMaterialDirtyMechanism=c:this._babylonScene._forceBlockMaterialDirtyMechanism(c),this._parent.compileMaterials&&u.push(this._compileMaterialsAsync()),this._parent.compileShadowGenerators&&u.push(this._compileShadowGeneratorsAsync());const h=Promise.all(u).then(()=>{this._rootBabylonMesh&&this._rootBabylonMesh!==this._parent.customRootNode&&this._rootBabylonMesh.setEnabled(!0);for(const e of this._babylonScene.materials){const t=e;void 0!==t.maxSimultaneousLights&&(t.maxSimultaneousLights=Math.max(t.maxSimultaneousLights,this._babylonScene.lights.length))}for(const e of Array.from(this._materialAdapters))this._completePromises.push(e.finalizeAsync(this));return this._extensionsOnReady(),this._parent._setState(e.GLTFLoaderState.READY),this._skipStartAnimationStep||this._startAnimations(),o()});return yield h.then(n=>(this._parent._endPerformanceCounter(i),t.Tools.SetImmediate(()=>{this._disposed||Promise.all(this._completePromises).then(()=>{this._parent._endPerformanceCounter(l),this._parent._setState(e.GLTFLoaderState.COMPLETE),this._parent.onCompleteObservable.notifyObservers(void 0),this._parent.onCompleteObservable.clear(),this.dispose()},e=>{this._parent.onErrorObservable.notifyObservers(e),this._parent.onErrorObservable.clear(),this.dispose()})}),n))})).catch(e=>{throw this._disposed||(this._parent.onErrorObservable.notifyObservers(e),this._parent.onErrorObservable.clear(),this.dispose()),e})})}_loadData(e){if(this._gltf=e.json,this._setupData(),e.bin){const n=this._gltf.buffers;if(n&&n[0]&&!n[0].uri){const r=n[0];(r.byteLength<e.bin.byteLength-3||r.byteLength>e.bin.byteLength)&&t.Logger.Warn(`Binary buffer length (${r.byteLength}) from JSON does not match chunk length (${e.bin.byteLength})`),this._bin=e.bin}else t.Logger.Warn("Unexpected BIN chunk")}}_setupData(){if(ve.Assign(this._gltf.accessors),ve.Assign(this._gltf.animations),ve.Assign(this._gltf.buffers),ve.Assign(this._gltf.bufferViews),ve.Assign(this._gltf.cameras),ve.Assign(this._gltf.images),ve.Assign(this._gltf.materials),ve.Assign(this._gltf.meshes),ve.Assign(this._gltf.nodes),ve.Assign(this._gltf.samplers),ve.Assign(this._gltf.scenes),ve.Assign(this._gltf.skins),ve.Assign(this._gltf.textures),this._gltf.nodes){const e={};for(const t of this._gltf.nodes)if(t.children)for(const n of t.children)e[n]=t.index;const t=this._createRootNode();for(const n of this._gltf.nodes){const r=e[n.index];n.parent=void 0===r?t:this._gltf.nodes[r]}}}_loadExtensionsAsync(){return v(this,void 0,void 0,function*(){var e;const n=[];if(ge.forEach((e,r)=>{var s;!1===(null===(s=this.parent.extensionOptions[r])||void 0===s?void 0:s.enabled)?e.isGLTFExtension&&this.isExtensionUsed(r)&&t.Logger.Warn(`Extension ${r} is used but has been explicitly disabled.`):e.isGLTFExtension&&!this.isExtensionUsed(r)||n.push((()=>v(this,void 0,void 0,function*(){const n=yield e.factory(this);return n.name!==r&&t.Logger.Warn(`The name of the glTF loader extension instance does not match the registered name: ${n.name} !== ${r}`),this._parent.onExtensionLoadedObservable.notifyObservers(n),n}))())}),this._extensions.push(...yield Promise.all(n)),this._extensions.sort((e,t)=>(e.order||Number.MAX_VALUE)-(t.order||Number.MAX_VALUE)),this._parent.onExtensionLoadedObservable.clear(),this._gltf.extensionsRequired)for(const t of this._gltf.extensionsRequired)if(!this._extensions.some(e=>e.name===t&&e.enabled)){if(!1===(null===(e=this.parent.extensionOptions[t])||void 0===e?void 0:e.enabled))throw new Error(`Required extension ${t} is disabled`);throw new Error(`Required extension ${t} is not available`)}})}_createRootNode(){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;const n=new t.Mesh("__root__",this._babylonScene);this._rootBabylonMesh=n,this._rootBabylonMesh._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,this._rootBabylonMesh.setEnabled(!1);const r={_babylonTransformNode:this._rootBabylonMesh,index:-1};switch(this._parent.coordinateSystemMode){case e.GLTFLoaderCoordinateSystemMode.AUTO:this._babylonScene.useRightHandedSystem||(r.rotation=[0,1,0,0],r.scale=[1,1,-1],Ce._LoadTransform(r,this._rootBabylonMesh));break;case e.GLTFLoaderCoordinateSystemMode.FORCE_RIGHT_HANDED:this._babylonScene.useRightHandedSystem=!0;break;default:throw new Error(`Invalid coordinate system mode (${this._parent.coordinateSystemMode})`)}return this._parent.onMeshLoadedObservable.notifyObservers(n),r}loadSceneAsync(e,t){const n=this._extensionsLoadSceneAsync(e,t);if(n)return n;const r=new Array;if(this.logOpen(`${e} ${t.name||""}`),t.nodes)for(const n of t.nodes){const t=ve.Get(`${e}/nodes/${n}`,this._gltf.nodes,n);r.push(this.loadNodeAsync(`/nodes/${t.index}`,t,e=>{e.parent=this._rootBabylonMesh}))}for(const e of this._postSceneLoadActions)e();return r.push(this._loadAnimationsAsync()),this.logClose(),Promise.all(r).then(()=>{})}_forEachPrimitive(e,t){if(e._primitiveBabylonMeshes)for(const n of e._primitiveBabylonMeshes)t(n)}_getGeometries(){const e=[],t=this._gltf.nodes;if(t)for(const n of t)this._forEachPrimitive(n,t=>{const n=t.geometry;n&&-1===e.indexOf(n)&&e.push(n)});return e}_getMeshes(){const e=[];this._rootBabylonMesh instanceof t.AbstractMesh&&e.push(this._rootBabylonMesh);const n=this._gltf.nodes;if(n)for(const t of n)this._forEachPrimitive(t,t=>{e.push(t)});return e}_getTransformNodes(){const e=[],t=this._gltf.nodes;if(t)for(const n of t)n._babylonTransformNode&&"TransformNode"===n._babylonTransformNode.getClassName()&&e.push(n._babylonTransformNode),n._babylonTransformNodeForSkin&&e.push(n._babylonTransformNodeForSkin);return e}_getSkeletons(){const e=[],t=this._gltf.skins;if(t)for(const n of t)n._data&&e.push(n._data.babylonSkeleton);return e}_getAnimationGroups(){const e=[],t=this._gltf.animations;if(t)for(const n of t)n._babylonAnimationGroup&&e.push(n._babylonAnimationGroup);return e}_startAnimations(){switch(this._parent.animationStartMode){case e.GLTFLoaderAnimationStartMode.NONE:break;case e.GLTFLoaderAnimationStartMode.FIRST:{const e=this._getAnimationGroups();0!==e.length&&e[0].start(!0);break}case e.GLTFLoaderAnimationStartMode.ALL:{const e=this._getAnimationGroups();for(const t of e)t.start(!0);break}default:return void t.Logger.Error(`Invalid animation start mode (${this._parent.animationStartMode})`)}}loadNodeAsync(e,n,r=()=>{}){const s=this._extensionsLoadNodeAsync(e,n,r);if(s)return s;if(n._babylonTransformNode)throw new Error(`${e}: Invalid recursive node hierarchy`);const o=new Array;this.logOpen(`${e} ${n.name||""}`);const a=t=>{if(Ce.AddPointerMetadata(t,e),Ce._LoadTransform(n,t),null!=n.camera){const r=ve.Get(`${e}/camera`,this._gltf.cameras,n.camera);o.push(this.loadCameraAsync(`/cameras/${r.index}`,r,e=>{e.parent=t,this._babylonScene.useRightHandedSystem||(t.scaling.x=-1)}))}if(n.children)for(const r of n.children){const n=ve.Get(`${e}/children/${r}`,this._gltf.nodes,r);o.push(this.loadNodeAsync(`/nodes/${n.index}`,n,e=>{e.parent=t}))}r(t)},i=null!=n.mesh,l=this._parent.loadSkins&&null!=n.skin;if(!i||l){const e=n.name||`node${n.index}`;this._babylonScene._blockEntityCollection=!!this._assetContainer;const r=new t.TransformNode(e,this._babylonScene);r._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,null==n.mesh?n._babylonTransformNode=r:n._babylonTransformNodeForSkin=r,a(r)}if(i)if(l){const r=ve.Get(`${e}/mesh`,this._gltf.meshes,n.mesh);o.push(this._loadMeshAsync(`/meshes/${r.index}`,n,r,r=>{const s=n._babylonTransformNodeForSkin;r.metadata=t.deepMerge(s.metadata,r.metadata||{});const a=ve.Get(`${e}/skin`,this._gltf.skins,n.skin);o.push(this._loadSkinAsync(`/skins/${a.index}`,n,a,e=>{this._forEachPrimitive(n,t=>{t.skeleton=e}),this._postSceneLoadActions.push(()=>{if(null!=a.skeleton){const e=ve.Get(`/skins/${a.index}/skeleton`,this._gltf.nodes,a.skeleton).parent;n.index===e.index?r.parent=s.parent:r.parent=e._babylonTransformNode}else r.parent=this._rootBabylonMesh;this._parent.onSkinLoadedObservable.notifyObservers({node:s,skinnedNode:r})})}))}))}else{const t=ve.Get(`${e}/mesh`,this._gltf.meshes,n.mesh);o.push(this._loadMeshAsync(`/meshes/${t.index}`,n,t,a))}return this.logClose(),Promise.all(o).then(()=>(this._forEachPrimitive(n,e=>{const t=e;!t.isAnInstance&&t.geometry&&t.geometry.useBoundingInfoFromGeometry?e._updateBoundingInfo():e.refreshBoundingInfo(!0,!0)}),n._babylonTransformNode))}_loadMeshAsync(e,n,r,s){const o=r.primitives;if(!o||!o.length)throw new Error(`${e}: Primitives are missing`);null==o[0].index&&ve.Assign(o);const a=new Array;this.logOpen(`${e} ${r.name||""}`);const i=n.name||`node${n.index}`;if(1===o.length){const t=r.primitives[0];a.push(this._loadMeshPrimitiveAsync(`${e}/primitives/${t.index}`,i,n,r,t,e=>{n._babylonTransformNode=e,n._primitiveBabylonMeshes=[e]}))}else{this._babylonScene._blockEntityCollection=!!this._assetContainer,n._babylonTransformNode=new t.TransformNode(i,this._babylonScene),n._babylonTransformNode._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,n._primitiveBabylonMeshes=[];for(const t of o)a.push(this._loadMeshPrimitiveAsync(`${e}/primitives/${t.index}`,`${i}_primitive${t.index}`,n,r,t,e=>{e.parent=n._babylonTransformNode,n._primitiveBabylonMeshes.push(e)}))}return s(n._babylonTransformNode),this.logClose(),Promise.all(a).then(()=>n._babylonTransformNode)}_loadMeshPrimitiveAsync(e,n,r,s,o,a){const i=this._extensionsLoadMeshPrimitiveAsync(e,n,r,s,o,a);if(i)return i;this.logOpen(`${e}`);const l=0===this._disableInstancedMesh&&this._parent.createInstances&&null==r.skin&&!s.primitives[0].targets;let u,c;if(l&&o._instanceData)this._babylonScene._blockEntityCollection=!!this._assetContainer,u=o._instanceData.babylonSourceMesh.createInstance(n),u._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,c=o._instanceData.promise;else{const a=new Array;this._babylonScene._blockEntityCollection=!!this._assetContainer;const i=new t.Mesh(n,this._babylonScene);if(i._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,i.sideOrientation=this._babylonScene.useRightHandedSystem?t.Material.CounterClockWiseSideOrientation:t.Material.ClockWiseSideOrientation,this._createMorphTargets(e,r,s,o,i),a.push(this._loadVertexDataAsync(e,o,i).then(t=>v(this,void 0,void 0,function*(){return yield this._loadMorphTargetsAsync(e,o,i,t).then(()=>{this._disposed||(this._babylonScene._blockEntityCollection=!!this._assetContainer,t.applyToMesh(i),t._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1)})}))),!this.parent.skipMaterials){const t=Ce._GetDrawMode(e,o.mode);if(null==o.material){let e=this._defaultBabylonMaterialData[t];e||(e=this._createDefaultMaterial("__GLTFLoader._default",t,this._getDefaultImpl()),this._parent.onMaterialLoadedObservable.notifyObservers(e),this._defaultBabylonMaterialData[t]=e),i.material=e}else{const n=ve.Get(`${e}/material`,this._gltf.materials,o.material);a.push(this._loadMaterialAsync(`/materials/${n.index}`,n,i,t,e=>{i.material=e}))}}c=Promise.all(a),l&&(o._instanceData={babylonSourceMesh:i,promise:c}),u=i}return Ce.AddPointerMetadata(u,e),this._parent.onMeshLoadedObservable.notifyObservers(u),a(u),this.logClose(),c.then(()=>u)}_loadVertexDataAsync(e,n,r){const s=this._extensionsLoadVertexDataAsync(e,n,r);if(s)return s;const o=n.attributes;if(!o)throw new Error(`${e}: Attributes are missing`);const a=new Array,i=new t.Geometry(r.name,this._babylonScene);if(null==n.indices)r.isUnIndexed=!0;else{const t=ve.Get(`${e}/indices`,this._gltf.accessors,n.indices);a.push(this._loadIndicesAccessorAsync(`/accessors/${t.index}`,t).then(e=>{i.setIndices(e)}))}const l=(n,s,l)=>{if(null==o[n])return;r._delayInfo=r._delayInfo||[],-1===r._delayInfo.indexOf(s)&&r._delayInfo.push(s);const u=ve.Get(`${e}/attributes/${n}`,this._gltf.accessors,o[n]);a.push(this._loadVertexAccessorAsync(`/accessors/${u.index}`,u,s).then(e=>{if(e.getKind()===t.VertexBuffer.PositionKind&&!this.parent.alwaysComputeBoundingBox&&!r.skeleton){const e=Ae(u);e&&(i._boundingInfo=e,i.useBoundingInfoFromGeometry=!0)}i.setVerticesBuffer(e,u.count)})),s==t.VertexBuffer.MatricesIndicesExtraKind&&(r.numBoneInfluencers=8),l&&l(u)};return l("POSITION",t.VertexBuffer.PositionKind),l("NORMAL",t.VertexBuffer.NormalKind),l("TANGENT",t.VertexBuffer.TangentKind),l("TEXCOORD_0",t.VertexBuffer.UVKind),l("TEXCOORD_1",t.VertexBuffer.UV2Kind),l("TEXCOORD_2",t.VertexBuffer.UV3Kind),l("TEXCOORD_3",t.VertexBuffer.UV4Kind),l("TEXCOORD_4",t.VertexBuffer.UV5Kind),l("TEXCOORD_5",t.VertexBuffer.UV6Kind),l("JOINTS_0",t.VertexBuffer.MatricesIndicesKind),l("WEIGHTS_0",t.VertexBuffer.MatricesWeightsKind),l("JOINTS_1",t.VertexBuffer.MatricesIndicesExtraKind),l("WEIGHTS_1",t.VertexBuffer.MatricesWeightsExtraKind),l("COLOR_0",t.VertexBuffer.ColorKind,e=>{"VEC4"===e.type&&(r.hasVertexAlpha=!0)}),Promise.all(a).then(()=>i)}_createMorphTargets(e,n,r,s,o){if(!s.targets||!this._parent.loadMorphTargets)return;if(null==n._numMorphTargets)n._numMorphTargets=s.targets.length;else if(s.targets.length!==n._numMorphTargets)throw new Error(`${e}: Primitives do not have the same number of targets`);const a=r.extras?r.extras.targetNames:null;this._babylonScene._blockEntityCollection=!!this._assetContainer,o.morphTargetManager=new t.MorphTargetManager(this._babylonScene),o.morphTargetManager._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,o.morphTargetManager.areUpdatesFrozen=!0;for(let e=0;e<s.targets.length;e++){const s=n.weights?n.weights[e]:r.weights?r.weights[e]:0,i=a?a[e]:`morphTarget${e}`;o.morphTargetManager.addTarget(new t.MorphTarget(i,s,o.getScene()))}}_loadMorphTargetsAsync(e,n,r,s){if(!n.targets||!this._parent.loadMorphTargets)return Promise.resolve();const o=new Array,a=r.morphTargetManager;for(let t=0;t<a.numTargets;t++){const r=a.getTarget(t);o.push(this._loadMorphTargetVertexDataAsync(`${e}/targets/${t}`,s,n.targets[t],r))}return Promise.all(o).then(()=>{a.areUpdatesFrozen=!1,this._parent.useMaxMorphTargetInfluencers&&(a.isUsingTextureForTargets||a.numTargets<=t.MorphTargetManager.MaxActiveMorphTargetsInVertexAttributeMode)&&(a.optimizeInfluencers=!1,a.numMaxInfluencers=a.numTargets)})}_loadMorphTargetVertexDataAsync(e,n,r,s){return v(this,void 0,void 0,function*(){const o=new Array,a=(t,s,a)=>{if(null==r[t])return;const i=n.getVertexBuffer(s);if(!i)return;const l=ve.Get(`${e}/${t}`,this._gltf.accessors,r[t]);o.push(this._loadFloatAccessorAsync(`/accessors/${l.index}`,l).then(e=>{a(i,e)}))};return a("POSITION",t.VertexBuffer.PositionKind,(e,t)=>{const n=new Float32Array(t.length);e.forEach(t.length,(e,r)=>{n[r]=t[r]+e}),s.setPositions(n)}),a("NORMAL",t.VertexBuffer.NormalKind,(e,t)=>{const n=new Float32Array(t.length);e.forEach(n.length,(e,r)=>{n[r]=t[r]+e}),s.setNormals(n)}),a("TANGENT",t.VertexBuffer.TangentKind,(e,t)=>{const n=new Float32Array(t.length/3*4);let r=0;e.forEach(t.length/3*4,(e,s)=>{(s+1)%4!=0&&(n[r]=t[r]+e,r++)}),s.setTangents(n)}),a("TEXCOORD_0",t.VertexBuffer.UVKind,(e,t)=>{const n=new Float32Array(t.length);e.forEach(t.length,(e,r)=>{n[r]=t[r]+e}),s.setUVs(n)}),a("TEXCOORD_1",t.VertexBuffer.UV2Kind,(e,t)=>{const n=new Float32Array(t.length);e.forEach(t.length,(e,r)=>{n[r]=t[r]+e}),s.setUV2s(n)}),a("COLOR_0",t.VertexBuffer.ColorKind,(t,n)=>{let r=null;const o=t.getSize();if(3===o){r=new Float32Array(n.length/3*4),t.forEach(n.length,(e,t)=>{const s=Math.floor(t/3),o=t%3;r[4*s+o]=n[3*s+o]+e});for(let e=0;e<n.length/3;++e)r[4*e+3]=1}else{if(4!==o)throw new Error(`${e}: Invalid number of components (${o}) for COLOR_0 attribute`);r=new Float32Array(n.length),t.forEach(n.length,(e,t)=>{r[t]=n[t]+e})}s.setColors(r)}),yield Promise.all(o).then(()=>{})})}static _LoadTransform(e,n){if(null!=e.skin)return;let r=t.Vector3.Zero(),s=t.Quaternion.Identity(),o=t.Vector3.One();e.matrix?t.Matrix.FromArray(e.matrix).decompose(o,s,r):(e.translation&&(r=t.Vector3.FromArray(e.translation)),e.rotation&&(s=t.Quaternion.FromArray(e.rotation)),e.scale&&(o=t.Vector3.FromArray(e.scale))),n.position=r,n.rotationQuaternion=s,n.scaling=o}_loadSkinAsync(e,n,r,s){if(!this._parent.loadSkins)return Promise.resolve();const o=this._extensionsLoadSkinAsync(e,n,r);if(o)return o;if(r._data)return s(r._data.babylonSkeleton),r._data.promise;const a=`skeleton${r.index}`;this._babylonScene._blockEntityCollection=!!this._assetContainer;const i=new t.Skeleton(r.name||a,a,this._babylonScene);i._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,this._loadBones(e,r,i);const l=this._loadSkinInverseBindMatricesDataAsync(e,r).then(e=>{this._updateBoneMatrices(i,e)});return r._data={babylonSkeleton:i,promise:l},s(i),l}_loadBones(e,n,r){if(null==n.skeleton||this._parent.alwaysComputeSkeletonRootNode){const r=this._findSkeletonRootNode(`${e}/joints`,n.joints);if(r)if(void 0===n.skeleton)n.skeleton=r.index;else{const s=(e,t)=>{for(;t.parent;t=t.parent)if(t.parent===e)return!0;return!1},o=ve.Get(`${e}/skeleton`,this._gltf.nodes,n.skeleton);o===r||s(o,r)||(t.Logger.Warn(`${e}/skeleton: Overriding with nearest common ancestor as skeleton node is not a common root`),n.skeleton=r.index)}else t.Logger.Warn(`${e}: Failed to find common root`)}const s={};for(const t of n.joints){const o=ve.Get(`${e}/joints/${t}`,this._gltf.nodes,t);this._loadBone(o,n,r,s)}}_findSkeletonRootNode(e,t){if(0===t.length)return null;const n={};for(const r of t){const t=[];let s=ve.Get(`${e}/${r}`,this._gltf.nodes,r);for(;-1!==s.index;)t.unshift(s),s=s.parent;n[r]=t}let r=null;for(let e=0;;++e){let s=n[t[0]];if(e>=s.length)return r;const o=s[e];for(let a=1;a<t.length;++a)if(s=n[t[a]],e>=s.length||o!==s[e])return r;r=o}}_loadBone(e,n,r,s){e._isJoint=!0;let o=s[e.index];if(o)return o;let a=null;e.index!==n.skeleton&&(e.parent&&-1!==e.parent.index?a=this._loadBone(e.parent,n,r,s):void 0!==n.skeleton&&t.Logger.Warn(`/skins/${n.index}/skeleton: Skeleton node is not a common root`));const i=n.joints.indexOf(e.index);return o=new t.Bone(e.name||`joint${e.index}`,r,a,this._getNodeMatrix(e),null,null,i),s[e.index]=o,this._postSceneLoadActions.push(()=>{o.linkTransformNode(e._babylonTransformNode)}),o}_loadSkinInverseBindMatricesDataAsync(e,t){if(null==t.inverseBindMatrices)return Promise.resolve(null);const n=ve.Get(`${e}/inverseBindMatrices`,this._gltf.accessors,t.inverseBindMatrices);return this._loadFloatAccessorAsync(`/accessors/${n.index}`,n)}_updateBoneMatrices(e,n){for(const r of e.bones){const e=t.Matrix.Identity(),s=r._index;n&&-1!==s&&(t.Matrix.FromArrayToRef(n,16*s,e),e.invertToRef(e));const o=r.getParent();o&&e.multiplyToRef(o.getAbsoluteInverseBindMatrix(),e),r.updateMatrix(e,!1,!1),r._updateAbsoluteBindMatrices(void 0,!1)}}_getNodeMatrix(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())}loadCameraAsync(e,n,r=()=>{}){const s=this._extensionsLoadCameraAsync(e,n,r);if(s)return s;const o=new Array;this.logOpen(`${e} ${n.name||""}`),this._babylonScene._blockEntityCollection=!!this._assetContainer;const a=new t.FreeCamera(n.name||`camera${n.index}`,t.Vector3.Zero(),this._babylonScene,!1);switch(a._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,n._babylonCamera=a,a.setTarget(new t.Vector3(0,0,-1)),n.type){case"perspective":{const t=n.perspective;if(!t)throw new Error(`${e}: Camera perspective properties are missing`);a.fov=t.yfov,a.minZ=t.znear,a.maxZ=t.zfar||0;break}case"orthographic":if(!n.orthographic)throw new Error(`${e}: Camera orthographic properties are missing`);a.mode=t.Camera.ORTHOGRAPHIC_CAMERA,a.orthoLeft=-n.orthographic.xmag,a.orthoRight=n.orthographic.xmag,a.orthoBottom=-n.orthographic.ymag,a.orthoTop=n.orthographic.ymag,a.minZ=n.orthographic.znear,a.maxZ=n.orthographic.zfar;break;default:throw new Error(`${e}: Invalid camera type (${n.type})`)}return Ce.AddPointerMetadata(a,e),this._parent.onCameraLoadedObservable.notifyObservers(a),r(a),this.logClose(),Promise.all(o).then(()=>a)}_loadAnimationsAsync(){this._parent._startPerformanceCounter("Load animations");const e=this._gltf.animations;if(!e)return Promise.resolve();const t=new Array;for(let n=0;n<e.length;n++){const r=e[n];t.push(this.loadAnimationAsync(`/animations/${r.index}`,r).then(e=>{0===e.targetedAnimations.length&&e.dispose()}))}return Promise.all(t).then(()=>{this._parent._endPerformanceCounter("Load animations")})}loadAnimationAsync(e,t){this._parent._startPerformanceCounter("Load animation");return this._extensionsLoadAnimationAsync(e,t)||Te.value.then(({AnimationGroup:n})=>{this._babylonScene._blockEntityCollection=!!this._assetContainer;const r=new n(t.name||`animation${t.index}`,this._babylonScene);r._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,t._babylonAnimationGroup=r;const s=new Array;ve.Assign(t.channels),ve.Assign(t.samplers);for(const n of t.channels)s.push(this._loadAnimationChannelAsync(`${e}/channels/${n.index}`,e,t,n,(e,t)=>{e.animations=e.animations||[],e.animations.push(t),r.addTargetedAnimation(t,e)}));return this._parent._endPerformanceCounter("Load animation"),Promise.all(s).then(()=>(r.normalize(0),r))})}_loadAnimationChannelAsync(e,t,n,r,s){const o=this._extensionsLoadAnimationChannelAsync(e,t,n,r,s);if(o)return o;if(null==r.target.node)return Promise.resolve();const a=ve.Get(`${e}/target/node`,this._gltf.nodes,r.target.node),i=r.target.path,l="weights"===i;return l&&!a._numMorphTargets||!l&&!a._babylonTransformNode?Promise.resolve():this._parent.loadNodeAnimations||l||a._isJoint?xe.value.then(()=>{var o,l,u,c;let h;switch(i){case"translation":h=null===(o=me("/nodes/{}/translation"))||void 0===o?void 0:o.interpolation;break;case"rotation":h=null===(l=me("/nodes/{}/rotation"))||void 0===l?void 0:l.interpolation;break;case"scale":h=null===(u=me("/nodes/{}/scale"))||void 0===u?void 0:u.interpolation;break;case"weights":h=null===(c=me("/nodes/{}/weights"))||void 0===c?void 0:c.interpolation;break;default:throw new Error(`${e}/target/path: Invalid value (${r.target.path})`)}if(!h)throw new Error(`${e}/target/path: Could not find interpolation properties for target path (${r.target.path})`);const d={object:a,info:h};return this._loadAnimationChannelFromTargetInfoAsync(e,t,n,r,d,s)}):Promise.resolve()}_loadAnimationChannelFromTargetInfoAsync(e,t,n,r,s,o){const a=this.parent.targetFps,i=1/a,l=ve.Get(`${e}/sampler`,n.samplers,r.sampler);return this._loadAnimationSamplerAsync(`${t}/samplers/${r.sampler}`,l).then(e=>{let t=0;const l=s.object,u=s.info;for(const s of u){const u=s.getStride(l),c=e.input,h=e.output,d=new Array(c.length);let m=0;switch(e.interpolation){case"STEP":for(let e=0;e<c.length;e++){const t=s.getValue(l,h,m,1);m+=u,d[e]={frame:c[e]*a,value:t,interpolation:1}}break;case"CUBICSPLINE":for(let e=0;e<c.length;e++){const t=s.getValue(l,h,m,i);m+=u;const n=s.getValue(l,h,m,1);m+=u;const r=s.getValue(l,h,m,i);m+=u,d[e]={frame:c[e]*a,inTangent:t,value:n,outTangent:r}}break;case"LINEAR":for(let e=0;e<c.length;e++){const t=s.getValue(l,h,m,1);m+=u,d[e]={frame:c[e]*a,value:t}}}if(m>0){const e=`${n.name||`animation${n.index}`}_channel${r.index}_${t}`,i=s.buildAnimations(l,e,a,d);for(const e of i)t++,o(e.babylonAnimatable,e.babylonAnimation)}}})}_loadAnimationSamplerAsync(e,t){if(t._data)return t._data;const n=t.interpolation||"LINEAR";switch(n){case"STEP":case"LINEAR":case"CUBICSPLINE":break;default:throw new Error(`${e}/interpolation: Invalid value (${t.interpolation})`)}const r=ve.Get(`${e}/input`,this._gltf.accessors,t.input),s=ve.Get(`${e}/output`,this._gltf.accessors,t.output);return t._data=Promise.all([this._loadFloatAccessorAsync(`/accessors/${r.index}`,r),this._loadFloatAccessorAsync(`/accessors/${s.index}`,s)]).then(([e,t])=>({input:e,interpolation:n,output:t})),t._data}loadBufferAsync(e,t,n,r){const s=this._extensionsLoadBufferAsync(e,t,n,r);if(s)return s;if(!t._data)if(t.uri)t._data=this.loadUriAsync(`${e}/uri`,t,t.uri);else{if(!this._bin)throw new Error(`${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(t=>{try{return new Uint8Array(t.buffer,t.byteOffset+n,r)}catch(t){throw new Error(`${e}: ${t.message}`,{cause:t})}})}loadBufferViewAsync(e,t){const n=this._extensionsLoadBufferViewAsync(e,t);if(n)return n;if(t._data)return t._data;const r=ve.Get(`${e}/buffer`,this._gltf.buffers,t.buffer);return t._data=this.loadBufferAsync(`/buffers/${r.index}`,r,t.byteOffset||0,t.byteLength),t._data}_loadAccessorAsync(e,n,r){if(n._data)return n._data;const s=Ce._GetNumComponents(e,n.type),o=s*t.VertexBufferGetTypeByteLength(n.componentType),a=s*n.count;if(null==n.bufferView)n._data=Promise.resolve(new r(a));else{const i=ve.Get(`${e}/bufferView`,this._gltf.bufferViews,n.bufferView);n._data=this.loadBufferViewAsync(`/bufferViews/${i.index}`,i).then(l=>{if(5126!==n.componentType||n.normalized||i.byteStride&&i.byteStride!==o){const e=new r(a);return t.VertexBufferForEach(l,n.byteOffset||0,i.byteStride||o,s,n.componentType,e.length,n.normalized||!1,(t,n)=>{e[n]=t}),e}return Ce._GetTypedArray(e,n.componentType,l,n.byteOffset,a)})}if(n.sparse){const a=n.sparse;n._data=n._data.then(i=>{const l=i,u=ve.Get(`${e}/sparse/indices/bufferView`,this._gltf.bufferViews,a.indices.bufferView),c=ve.Get(`${e}/sparse/values/bufferView`,this._gltf.bufferViews,a.values.bufferView);return Promise.all([this.loadBufferViewAsync(`/bufferViews/${u.index}`,u),this.loadBufferViewAsync(`/bufferViews/${c.index}`,c)]).then(([i,u])=>{const c=Ce._GetTypedArray(`${e}/sparse/indices`,a.indices.componentType,i,a.indices.byteOffset,a.count),h=s*a.count;let d;if(5126!==n.componentType||n.normalized){const i=Ce._GetTypedArray(`${e}/sparse/values`,n.componentType,u,a.values.byteOffset,h);d=new r(h),t.VertexBufferForEach(i,0,o,s,n.componentType,d.length,n.normalized||!1,(e,t)=>{d[t]=e})}else d=Ce._GetTypedArray(`${e}/sparse/values`,n.componentType,u,a.values.byteOffset,h);let m=0;for(let e=0;e<c.length;e++){let t=c[e]*s;for(let e=0;e<s;e++)l[t++]=d[m++]}return l})})}return n._data}_loadFloatAccessorAsync(e,t){return this._loadAccessorAsync(e,t,Float32Array)}_loadIndicesAccessorAsync(e,t){if("SCALAR"!==t.type)throw new Error(`${e}/type: Invalid value ${t.type}`);if(5121!==t.componentType&&5123!==t.componentType&&5125!==t.componentType)throw new Error(`${e}/componentType: Invalid value ${t.componentType}`);if(t._data)return t._data;if(t.sparse){const n=Ce._GetTypedArrayConstructor(`${e}/componentType`,t.componentType);t._data=this._loadAccessorAsync(e,t,n)}else{const n=ve.Get(`${e}/bufferView`,this._gltf.bufferViews,t.bufferView);t._data=this.loadBufferViewAsync(`/bufferViews/${n.index}`,n).then(n=>Ce._GetTypedArray(e,t.componentType,n,t.byteOffset,t.count))}return t._data}_loadVertexBufferViewAsync(e){if(e._babylonBuffer)return e._babylonBuffer;const n=this._babylonScene.getEngine();return e._babylonBuffer=this.loadBufferViewAsync(`/bufferViews/${e.index}`,e).then(e=>new t.Buffer(n,e,!1)),e._babylonBuffer}_loadVertexAccessorAsync(e,n,r){var s;if(null===(s=n._babylonVertexBuffer)||void 0===s?void 0:s[r])return n._babylonVertexBuffer[r];n._babylonVertexBuffer||(n._babylonVertexBuffer={});const o=this._babylonScene.getEngine();if(n.sparse||null==n.bufferView)n._babylonVertexBuffer[r]=this._loadFloatAccessorAsync(e,n).then(e=>new t.VertexBuffer(o,e,r,!1));else{const s=ve.Get(`${e}/bufferView`,this._gltf.bufferViews,n.bufferView);n._babylonVertexBuffer[r]=this._loadVertexBufferViewAsync(s).then(a=>{const i=Ce._GetNumComponents(e,n.type);return new t.VertexBuffer(o,a,r,!1,void 0,s.byteStride,void 0,n.byteOffset,i,n.componentType,n.normalized,!0,void 0,!0)})}return n._babylonVertexBuffer[r]}_loadMaterialMetallicRoughnessPropertiesAsync(e,n,r){const s=new Array,o=this._getOrCreateMaterialAdapter(r);return n&&(n.baseColorFactor?(o.baseColor=t.Color3.FromArray(n.baseColorFactor),o.geometryOpacity=n.baseColorFactor[3]):o.baseColor=t.Color3.White(),o.baseMetalness=null==n.metallicFactor?1:n.metallicFactor,o.specularRoughness=null==n.roughnessFactor?1:n.roughnessFactor,n.baseColorTexture&&s.push(this.loadTextureInfoAsync(`${e}/baseColorTexture`,n.baseColorTexture,e=>{e.name=`${r.name} (Base Color)`,o.baseColorTexture=e})),n.metallicRoughnessTexture&&(n.metallicRoughnessTexture.nonColorData=!0,s.push(this.loadTextureInfoAsync(`${e}/metallicRoughnessTexture`,n.metallicRoughnessTexture,e=>{e.name=`${r.name} (Metallic Roughness)`,o.baseMetalnessTexture=e,o.specularRoughnessTexture=e})),o.useRoughnessFromMetallicTextureGreen=!0,o.useMetallicFromMetallicTextureBlue=!0)),Promise.all(s).then(()=>{})}_loadMaterialAsync(e,t,n,r,s=()=>{}){const o=this._extensionsLoadMaterialAsync(e,t,n,r,s);if(o)return o;t._data=t._data||{};let a=t._data[r];if(!a){this.logOpen(`${e} ${t.name||""}`);const n=this.createMaterial(e,t,r);a={babylonMaterial:n,babylonMeshes:[],promise:this.loadMaterialPropertiesAsync(e,t,n)},t._data[r]=a,Ce.AddPointerMetadata(n,e),this._parent.onMaterialLoadedObservable.notifyObservers(n),this.logClose()}return n&&(a.babylonMeshes.push(n),n.onDisposeObservable.addOnce(()=>{const e=a.babylonMeshes.indexOf(n);-1!==e&&a.babylonMeshes.splice(e,1)})),s(a.babylonMaterial),a.promise.then(()=>a.babylonMaterial)}_selectImplForGltfMaterial(e){var t;if(this.parent.useOpenPBR||(null===(t=e.extensions)||void 0===t?void 0:t.KHR_materials_openpbr)){const e=this._pbrMaterialImpls.get("openpbr");if(e)return e}const n=this._pbrMaterialImpls.get("pbr");if(n)return n;throw new Error("No PBR material implementation loaded")}_getDefaultImpl(){var e;if(this.parent.useOpenPBR){const e=this._pbrMaterialImpls.get("openpbr");if(e)return e}const t=null!==(e=this._pbrMaterialImpls.get("pbr"))&&void 0!==e?e:this._pbrMaterialImpls.values().next().value;if(t)return t;throw new Error("No PBR material implementation loaded")}_createDefaultMaterial(e,t,n){this._babylonScene._blockEntityCollection=!!this._assetContainer;const r=new n.materialClass(e,this._babylonScene);r._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,r.fillMode=t,r.transparencyMode=n.materialClass.MATERIAL_OPAQUE;const s=this._getOrCreateMaterialAdapter(r);return s.transparencyAsAlphaCoverage=this._parent.transparencyAsCoverage,s.baseMetalness=1,s.specularRoughness=1,r}createMaterial(e,t,n){const r=this._extensionsCreateMaterial(e,t,n);if(r)return r;const s=t.name||`material${t.index}`;return this._createDefaultMaterial(s,n,this._selectImplForGltfMaterial(t))}loadMaterialPropertiesAsync(e,t,n){const r=this._extensionsLoadMaterialPropertiesAsync(e,t,n);if(r)return r;const s=new Array;return s.push(this.loadMaterialBasePropertiesAsync(e,t,n)),t.pbrMetallicRoughness&&s.push(this._loadMaterialMetallicRoughnessPropertiesAsync(`${e}/pbrMetallicRoughness`,t.pbrMetallicRoughness,n)),this.loadMaterialAlphaProperties(e,t,n),Promise.all(s).then(()=>{})}loadMaterialBasePropertiesAsync(e,n,r){const s=new Array,o=this._getOrCreateMaterialAdapter(r);let a;o.emissionColor=n.emissiveFactor?t.Color3.FromArray(n.emissiveFactor):new t.Color3(0,0,0),n.doubleSided&&(o.backFaceCulling=!1,o.twoSidedLighting=!0),n.normalTexture&&(n.normalTexture.nonColorData=!0,s.push(this.loadTextureInfoAsync(`${e}/normalTexture`,n.normalTexture,e=>{var t;e.name=`${r.name} (Normal)`,o.geometryNormalTexture=e,null!=(null===(t=n.normalTexture)||void 0===t?void 0:t.scale)&&(e.level=n.normalTexture.scale)})),o.setNormalMapInversions(!this._babylonScene.useRightHandedSystem,this._babylonScene.useRightHandedSystem));let i,l=1;return n.occlusionTexture&&(n.occlusionTexture.nonColorData=!0,s.push(this.loadTextureInfoAsync(`${e}/occlusionTexture`,n.occlusionTexture,e=>{e.name=`${r.name} (Occlusion)`,a=e})),null!=n.occlusionTexture.strength&&(l=n.occlusionTexture.strength)),n.emissiveTexture&&s.push(this.loadTextureInfoAsync(`${e}/emissiveTexture`,n.emissiveTexture,e=>{e.name=`${r.name} (Emissive)`,i=e})),Promise.all(s).then(()=>{a&&(o.ambientOcclusionTexture=a,o.ambientOcclusionTextureStrength=l),i&&(o.emissionColorTexture=i)})}loadMaterialAlphaProperties(e,n,r){if(0===this._pbrMaterialImpls.size)throw new Error(`${e}: Material type not supported`);const s=this._getOrCreateMaterialAdapter(r),o=s.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,s.alphaCutOff=null==n.alphaCutoff?.5:n.alphaCutoff,o&&(o.hasAlpha=!0,s.useAlphaFromBaseColorTexture=!0);break;case"BLEND":r.transparencyMode=t.Material.MATERIAL_ALPHABLEND,o&&(o.hasAlpha=!0,s.useAlphaFromBaseColorTexture=!0);break;default:throw new Error(`${e}/alphaMode: Invalid value (${n.alphaMode})`)}}loadTextureInfoAsync(e,t,n=()=>{}){const r=this._extensionsLoadTextureInfoAsync(e,t,n);if(r)return r;if(this.logOpen(`${e}`),t.texCoord>=6)throw new Error(`${e}/texCoord: Invalid value (${t.texCoord})`);const s=ve.Get(`${e}/index`,this._gltf.textures,t.index);s._textureInfo=t;const o=this._loadTextureAsync(`/textures/${t.index}`,s,r=>{r.coordinatesIndex=t.texCoord||0,Ce.AddPointerMetadata(r,e),this._parent.onTextureLoadedObservable.notifyObservers(r),n(r)});return this.logClose(),o}_loadTextureAsync(e,t,n=()=>{}){const r=this._extensionsLoadTextureAsync(e,t,n);if(r)return r;this.logOpen(`${e} ${t.name||""}`);const s=null==t.sampler?Ce.DefaultSampler:ve.Get(`${e}/sampler`,this._gltf.samplers,t.sampler),o=ve.Get(`${e}/source`,this._gltf.images,t.source),a=this._createTextureAsync(e,s,o,n,void 0,!t._textureInfo.nonColorData);return this.logClose(),a}_createTextureAsync(e,n,r,s=()=>{},o,a){var i,l;const u=this._loadSampler(`/samplers/${n.index}`,n),c=new Array,h=new t.Deferred;this._babylonScene._blockEntityCollection=!!this._assetContainer;const d={noMipmap:u.noMipMaps,invertY:!1,samplingMode:u.samplingMode,onLoad:()=>{this._disposed||h.resolve()},onError:(t,n)=>{this._disposed||h.reject(new Error(`${e}: ${n&&n.message?n.message:t||"Failed to load texture"}`))},mimeType:null!==(i=r.mimeType)&&void 0!==i?i:t.GetMimeType(null!==(l=r.uri)&&void 0!==l?l:""),loaderOptions:o,useSRGBBuffer:!!a&&this._parent.useSRGBBuffers},m=new t.Texture(null,this._babylonScene,d);m._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,c.push(h.promise);const _=r.uri&&!t.IsBase64DataUrl(r.uri)?r.uri:void 0,p=null!=_?_:`${this._fileName}#image${r.index}`;if(c.push(this.loadImageAsync(`/images/${r.index}`,r).then(e=>{const t=`data:${this._uniqueRootUrl}${p}`;m.updateURL(t,e);const n=m.getInternalTexture();n&&(n.label=r.name)})),m.wrapU=u.wrapU,m.wrapV=u.wrapV,s(m),this._parent.useGltfTextureNames){const e=r.name||_||`image${r.index}`;m.name=e}return Promise.all(c).then(()=>m)}_loadSampler(e,t){return t._data||(t._data={noMipMaps:9728===t.minFilter||9729===t.minFilter,samplingMode:Ce._GetTextureSamplingMode(e,t),wrapU:Ce._GetTextureWrapMode(`${e}/wrapS`,t.wrapS),wrapV:Ce._GetTextureWrapMode(`${e}/wrapT`,t.wrapT)}),t._data}loadImageAsync(e,t){if(!t._data){if(this.logOpen(`${e} ${t.name||""}`),t.uri)t._data=this.loadUriAsync(`${e}/uri`,t,t.uri);else{const n=ve.Get(`${e}/bufferView`,this._gltf.bufferViews,t.bufferView);t._data=this.loadBufferViewAsync(`/bufferViews/${n.index}`,n)}this.logClose()}return t._data}loadUriAsync(e,n,r){const s=this._extensionsLoadUriAsync(e,n,r);if(s)return s;if(!Ce._ValidateUri(r))throw new Error(`${e}: '${r}' is invalid`);if(t.IsBase64DataUrl(r)){const n=new Uint8Array(t.DecodeBase64UrlToBinary(r));return this.log(`${e}: Decoded ${r.substring(0,64)}... (${n.length} bytes)`),Promise.resolve(n)}return this.log(`${e}: Loading ${r}`),this._parent.preprocessUrlAsync(this._rootUrl+r).then(n=>new Promise((s,o)=>{this._parent._loadFile(this._babylonScene,n,t=>{this._disposed||(this.log(`${e}: Loaded ${r} (${t.byteLength} bytes)`),s(new Uint8Array(t)))},!0,n=>{o(new t.LoadFileError(`${e}: Failed to load '${r}'${n?": "+n.status+" "+n.statusText:""}`,n))})}))}static AddPointerMetadata(e,t){e.metadata=e.metadata||{};const n=e._internalMetadata=e._internalMetadata||{},r=n.gltf=n.gltf||{};(r.pointers=r.pointers||[]).push(t)}static _GetTextureWrapMode(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(`${e}: Invalid value (${n})`),t.Texture.WRAP_ADDRESSMODE}}static _GetTextureSamplingMode(e,n){const r=null==n.magFilter?9729:n.magFilter,s=null==n.minFilter?9987:n.minFilter;if(9729===r)switch(s){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(`${e}/minFilter: Invalid value (${s})`),t.Texture.LINEAR_LINEAR_MIPLINEAR}else switch(9728!==r&&t.Logger.Warn(`${e}/magFilter: Invalid value (${r})`),s){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(`${e}/minFilter: Invalid value (${s})`),t.Texture.NEAREST_NEAREST_MIPNEAREST}}static _GetTypedArrayConstructor(e,n){try{return t.GetTypedArrayConstructor(n)}catch(t){throw new Error(`${e}: ${t.message}`,{cause:t})}}static _GetTypedArray(e,n,r,s,o){const a=r.buffer;s=r.byteOffset+(s||0);const i=Ce._GetTypedArrayConstructor(`${e}/componentType`,n),l=t.VertexBufferGetTypeByteLength(n);return s%l!==0?(t.Logger.Warn(`${e}: Copying buffer as byte offset (${s}) is not a multiple of component type byte length (${l})`),new i(a.slice(s,s+o*l),0)):new i(a,s,o)}static _GetNumComponents(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(`${e}: Invalid type (${t})`)}static _ValidateUri(e){return t.Tools.IsBase64(e)||-1===e.indexOf("..")}static _GetDrawMode(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(`${e}: Invalid mesh primitive mode (${n})`)}_compileMaterialsAsync(){this._parent._startPerformanceCounter("Compile materials");const e=new Array;if(this._gltf.materials)for(const t of this._gltf.materials)if(t._data)for(const n in t._data){const r=t._data[n];for(const t of r.babylonMeshes){t.computeWorldMatrix(!0);const n=r.babylonMaterial;e.push(n.forceCompilationAsync(t)),e.push(n.forceCompilationAsync(t,{useInstances:!0})),this._parent.useClipPlane&&(e.push(n.forceCompilationAsync(t,{clipPlane:!0})),e.push(n.forceCompilationAsync(t,{clipPlane:!0,useInstances:!0})))}}return Promise.all(e).then(()=>{this._parent._endPerformanceCounter("Compile materials")})}_compileShadowGeneratorsAsync(){this._parent._startPerformanceCounter("Compile shadow generators");const e=new Array,t=this._babylonScene.lights;for(const n of t){const t=n.getShadowGenerator();t&&e.push(t.forceCompilationAsync())}return Promise.all(e).then(()=>{this._parent._endPerformanceCounter("Compile shadow generators")})}_forEachExtensions(e){for(const t of this._extensions)t.enabled&&e(t)}_applyExtensions(e,t,n){for(const r of this._extensions)if(r.enabled){const s=`${r.name}.${t}`,o=e;o._activeLoaderExtensionFunctions=o._activeLoaderExtensionFunctions||{};const a=o._activeLoaderExtensionFunctions;if(!a[s]){a[s]=!0;try{const e=n(r);if(e)return e}finally{delete a[s]}}}return null}_extensionsOnLoading(){this._forEachExtensions(e=>e.onLoading&&e.onLoading())}_extensionsOnReady(){this._forEachExtensions(e=>e.onReady&&e.onReady())}_extensionsLoadSceneAsync(e,t){return this._applyExtensions(t,"loadScene",n=>n.loadSceneAsync&&n.loadSceneAsync(e,t))}_extensionsLoadNodeAsync(e,t,n){return this._applyExtensions(t,"loadNode",r=>r.loadNodeAsync&&r.loadNodeAsync(e,t,n))}_extensionsLoadCameraAsync(e,t,n){return this._applyExtensions(t,"loadCamera",r=>r.loadCameraAsync&&r.loadCameraAsync(e,t,n))}_extensionsLoadVertexDataAsync(e,t,n){return this._applyExtensions(t,"loadVertexData",r=>r._loadVertexDataAsync&&r._loadVertexDataAsync(e,t,n))}_extensionsLoadMeshPrimitiveAsync(e,t,n,r,s,o){return this._applyExtensions(s,"loadMeshPrimitive",a=>a._loadMeshPrimitiveAsync&&a._loadMeshPrimitiveAsync(e,t,n,r,s,o))}_extensionsLoadMaterialAsync(e,t,n,r,s){return this._applyExtensions(t,"loadMaterial",o=>o._loadMaterialAsync&&o._loadMaterialAsync(e,t,n,r,s))}_extensionsCreateMaterial(e,t,n){return this._applyExtensions(t,"createMaterial",r=>r.createMaterial&&r.createMaterial(e,t,n))}_extensionsLoadMaterialPropertiesAsync(e,t,n){return this._applyExtensions(t,"loadMaterialProperties",r=>r.loadMaterialPropertiesAsync&&r.loadMaterialPropertiesAsync(e,t,n))}_extensionsLoadTextureInfoAsync(e,t,n){return this._applyExtensions(t,"loadTextureInfo",r=>r.loadTextureInfoAsync&&r.loadTextureInfoAsync(e,t,n))}_extensionsLoadTextureAsync(e,t,n){return this._applyExtensions(t,"loadTexture",r=>r._loadTextureAsync&&r._loadTextureAsync(e,t,n))}_extensionsLoadAnimationAsync(e,t){return this._applyExtensions(t,"loadAnimation",n=>n.loadAnimationAsync&&n.loadAnimationAsync(e,t))}_extensionsLoadAnimationChannelAsync(e,t,n,r,s){return this._applyExtensions(n,"loadAnimationChannel",o=>o._loadAnimationChannelAsync&&o._loadAnimationChannelAsync(e,t,n,r,s))}_extensionsLoadSkinAsync(e,t,n){return this._applyExtensions(n,"loadSkin",r=>r._loadSkinAsync&&r._loadSkinAsync(e,t,n))}_extensionsLoadUriAsync(e,t,n){return this._applyExtensions(t,"loadUri",r=>r._loadUriAsync&&r._loadUriAsync(e,t,n))}_extensionsLoadBufferViewAsync(e,t){return this._applyExtensions(t,"loadBufferView",n=>n.loadBufferViewAsync&&n.loadBufferViewAsync(e,t))}_extensionsLoadBufferAsync(e,t,n,r){return this._applyExtensions(t,"loadBuffer",s=>s.loadBufferAsync&&s.loadBufferAsync(e,t,n,r))}static LoadExtensionAsync(e,t,n,r){if(!t.extensions)return null;const s=t.extensions[n];return s?r(`${e}/extensions/${n}`,s):null}static LoadExtraAsync(e,t,n,r){if(!t.extras)return null;const s=t.extras[n];return s?r(`${e}/extras/${n}`,s):null}isExtensionUsed(e){return!!this._gltf.extensionsUsed&&-1!==this._gltf.extensionsUsed.indexOf(e)}logOpen(e){this._parent._logOpen(e)}logClose(){this._parent._logClose()}log(e){this._parent._log(e)}startPerformanceCounter(e){this._parent._startPerformanceCounter(e)}endPerformanceCounter(e){this._parent._endPerformanceCounter(e)}}Ce.DefaultSampler={index:-1};let Re=!1;function Me(){Re||(Re=!0,g._CreateGLTF2Loader=e=>new Ce(e))}const we="EXT_lights_image_based";class Ee{constructor(e){this.name=we,this._loader=e,this.enabled=this._loader.isExtensionUsed(we)}dispose(){this._loader=null,delete this._lights}onLoading(){const e=this._loader.gltf.extensions;if(e&&e[this.name]){const t=e[this.name];this._lights=t.lights}}loadSceneAsync(e,t){return Ce.LoadExtensionAsync(e,t,this.name,(n,r)=>v(this,void 0,void 0,function*(){this._loader._allMaterialsDirtyRequired=!0;const s=new Array;s.push(this._loader.loadSceneAsync(e,t)),this._loader.logOpen(`${n}`);const o=ve.Get(`${n}/light`,this._lights,r.light);return s.push(this._loadLightAsync(`/extensions/${this.name}/lights/${r.light}`,o).then(e=>{this._loader.babylonScene.environmentTexture=e})),this._loader.logClose(),yield Promise.all(s).then(()=>{})}))}_loadLightAsync(e,n){if(!n._loaded){const r=new Array;this._loader.logOpen(`${e}`);const s=new Array(n.specularImages.length);for(let t=0;t<n.specularImages.length;t++){const o=n.specularImages[t];s[t]=new Array(o.length);for(let n=0;n<o.length;n++){const a=`${e}/specularImages/${t}/${n}`;this._loader.logOpen(`${a}`);const i=o[n],l=ve.Get(a,this._loader.gltf.images,i);r.push(this._loader.loadImageAsync(`/images/${i}`,l).then(e=>{s[t][n]=e})),this._loader.logClose()}}this._loader.logClose(),n._loaded=Promise.all(r).then(()=>v(this,void 0,void 0,function*(){const r=new t.RawCubeTexture(this._loader.babylonScene,null,n.specularImageSize);if(r.name=n.name||"environment",n._babylonTexture=r,null!=n.intensity&&(r.level=n.intensity),n.rotation){let e=t.Quaternion.FromArray(n.rotation);this._loader.babylonScene.useRightHandedSystem||(e=t.Quaternion.Inverse(e)),t.Matrix.FromQuaternionToRef(e,r.getReflectionTextureMatrix())}if(!n.irradianceCoefficients)throw new Error(`${e}: Irradiance coefficients are missing`);const o=t.SphericalHarmonics.FromArray(n.irradianceCoefficients);o.scaleInPlace(n.intensity),o.convertIrradianceToLambertianRadiance();const a=t.SphericalPolynomial.FromHarmonics(o),i=(s.length-1)/Math.log2(n.specularImageSize);return yield r.updateRGBDAsync(s,a,i)}))}return n._loaded.then(()=>n._babylonTexture)}}let Oe=!1;function Le(){Oe||(Oe=!0,ye(we),be(we,!0,e=>new Ee(e)))}Le();const Se="EXT_mesh_gpu_instancing";class Fe{constructor(e){this.name=Se,this._loader=e,this.enabled=this._loader.isExtensionUsed(Se)}dispose(){this._loader=null}loadNodeAsync(e,n,r){return Ce.LoadExtensionAsync(e,n,this.name,(e,s)=>v(this,void 0,void 0,function*(){this._loader._disableInstancedMesh++;const o=this._loader.loadNodeAsync(`/nodes/${n.index}`,n,r);if(this._loader._disableInstancedMesh--,!n._primitiveBabylonMeshes)return yield o;const a=new Array;let i=0;const l=t=>{if(null==s.attributes[t])return void a.push(Promise.resolve(null));const n=ve.Get(`${e}/attributes/${t}`,this._loader.gltf.accessors,s.attributes[t]);if(a.push(this._loader._loadFloatAccessorAsync(`/accessors/${n.bufferView}`,n)),0===i)i=n.count;else if(i!==n.count)throw new Error(`${e}/attributes: Instance buffer accessors do not have the same count.`)};return l("TRANSLATION"),l("ROTATION"),l("SCALE"),l("_COLOR_0"),yield o.then(e=>v(this,void 0,void 0,function*(){const[r,s,o,l]=yield Promise.all(a),u=new Float32Array(16*i);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);for(let e=0;e<i;++e)r&&t.Vector3.FromArrayToRef(r,3*e,t.TmpVectors.Vector3[0]),s&&t.Quaternion.FromArrayToRef(s,4*e,t.TmpVectors.Quaternion[0]),o&&t.Vector3.FromArrayToRef(o,3*e,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(u,16*e);for(const e of n._primitiveBabylonMeshes)e.thinInstanceSetBuffer("matrix",u,16,!0),l&&(l.length===3*i?e.thinInstanceSetBuffer("color",l,3,!0):l.length===4*i?e.thinInstanceSetBuffer("color",l,4,!0):t.Logger.Warn("Unexpected size of _COLOR_0 attribute for mesh "+e.name));return e}))}))}}let Ie=!1;function Ne(){Ie||(Ie=!0,ye(Se),be(Se,!0,e=>new Fe(e)))}Ne();const ke="EXT_meshopt_compression";class Pe{constructor(e){this.name=ke,this.enabled=e.isExtensionUsed(ke),this._loader=e}dispose(){this._loader=null}loadBufferViewAsync(e,n){return Ce.LoadExtensionAsync(e,n,this.name,(r,s)=>v(this,void 0,void 0,function*(){const r=n;if(r._meshOptData)return yield r._meshOptData;const o=ve.Get(`${e}/buffer`,this._loader.gltf.buffers,s.buffer);return r._meshOptData=this._loader.loadBufferAsync(`/buffers/${o.index}`,o,s.byteOffset||0,s.byteLength).then(e=>v(this,void 0,void 0,function*(){return yield t.MeshoptCompression.Default.decodeGltfBufferAsync(e,s.count,s.byteStride,s.mode,s.filter)})),yield r._meshOptData}))}}let Be=!1;function Ge(){Be||(Be=!0,ye(ke),be(ke,!0,e=>new Pe(e)))}Ge();const De="EXT_texture_webp";class Ve{constructor(e){this.name=De,this._loader=e,this.enabled=e.isExtensionUsed(De)}dispose(){this._loader=null}_loadTextureAsync(e,t,n){return Ce.LoadExtensionAsync(e,t,this.name,(r,s)=>v(this,void 0,void 0,function*(){const o=null==t.sampler?Ce.DefaultSampler:ve.Get(`${e}/sampler`,this._loader.gltf.samplers,t.sampler),a=ve.Get(`${r}/source`,this._loader.gltf.images,s.source);return yield this._loader._createTextureAsync(e,o,a,e=>{n(e)},void 0,!t._textureInfo.nonColorData)}))}}let He=!1;function $e(){He||(He=!0,ye(De),be(De,!0,e=>new Ve(e)))}$e();const Ke="EXT_texture_avif";class We{constructor(e){this.name=Ke,this._loader=e,this.enabled=e.isExtensionUsed(Ke)}dispose(){this._loader=null}_loadTextureAsync(e,t,n){return Ce.LoadExtensionAsync(e,t,this.name,(r,s)=>v(this,void 0,void 0,function*(){const o=null==t.sampler?Ce.DefaultSampler:ve.Get(`${e}/sampler`,this._loader.gltf.samplers,t.sampler),a=ve.Get(`${r}/source`,this._loader.gltf.images,s.source);return yield this._loader._createTextureAsync(e,o,a,e=>{n(e)},void 0,!t._textureInfo.nonColorData)}))}}let Ue=!1;function ze(){Ue||(Ue=!0,ye(Ke),be(Ke,!0,e=>new We(e)))}ze();const je="EXT_lights_ies";class qe{constructor(e){this.name=je,this._loader=e,this.enabled=this._loader.isExtensionUsed(je)}dispose(){this._loader=null,delete this._lights}onLoading(){const e=this._loader.gltf.extensions;if(e&&e[this.name]){const t=e[this.name];this._lights=t.lights,ve.Assign(this._lights)}}loadNodeAsync(e,n,r){return Ce.LoadExtensionAsync(e,n,this.name,(s,o)=>v(this,void 0,void 0,function*(){let a,i;this._loader._allMaterialsDirtyRequired=!0;const l=yield this._loader.loadNodeAsync(e,n,e=>{i=ve.Get(s,this._lights,o.light);const n=i.name||e.name;this._loader.babylonScene._blockEntityCollection=!!this._loader._assetContainer,a=new t.SpotLight(n,t.Vector3.Zero(),t.Vector3.Backward(),0,1,this._loader.babylonScene),a.angle=Math.PI/2,a.innerAngle=0,a._parentContainer=this._loader._assetContainer,this._loader.babylonScene._blockEntityCollection=!1,i._babylonLight=a,a.falloffType=t.Light.FALLOFF_GLTF,a.diffuse=o.color?t.Color3.FromArray(o.color):t.Color3.White(),a.intensity=o.multiplier||1,a.range=Number.MAX_VALUE,a.parent=e,this._loader._babylonLights.push(a),Ce.AddPointerMetadata(a,s),r(e)});let u;if(i.uri)u=yield this._loader.loadUriAsync(e,i,i.uri);else{const t=ve.Get(`${e}/bufferView`,this._loader.gltf.bufferViews,i.bufferView);u=yield this._loader.loadBufferViewAsync(`/bufferViews/${t.index}`,t)}return a.iesProfileTexture=new t.Texture(name+"_iesProfile",this._loader.babylonScene,!0,!1,void 0,null,null,u,!0,void 0,void 0,void 0,void 0,".ies"),l}))}}let Ye=!1;function Xe(){Ye||(Ye=!0,ye(je),be(je,!0,e=>new qe(e)))}Xe();const Qe="KHR_draco_mesh_compression";class Ze{constructor(e){this.name=Qe,this.useNormalizedFlagFromAccessor=!0,this._loader=e,this.enabled=t.DracoDecoder.DefaultAvailable&&this._loader.isExtensionUsed(Qe)}dispose(){delete this.dracoDecoder,this._loader=null}_loadVertexDataAsync(e,n,r){return Ce.LoadExtensionAsync(e,n,this.name,(s,o)=>v(this,void 0,void 0,function*(){if(null!=n.mode&&4!==n.mode&&5!==n.mode)throw new Error(`${e}: Unsupported mode ${n.mode}`);const a={},i={},l=(e,t)=>{const s=o.attributes[e];if(null!=s&&(r._delayInfo=r._delayInfo||[],-1===r._delayInfo.indexOf(t)&&r._delayInfo.push(t),a[t]=s,this.useNormalizedFlagFromAccessor)){const r=ve.TryGet(this._loader.gltf.accessors,n.attributes[e]);r&&(i[t]=r.normalized||!1)}};l("POSITION",t.VertexBuffer.PositionKind),l("NORMAL",t.VertexBuffer.NormalKind),l("TANGENT",t.VertexBuffer.TangentKind),l("TEXCOORD_0",t.VertexBuffer.UVKind),l("TEXCOORD_1",t.VertexBuffer.UV2Kind),l("TEXCOORD_2",t.VertexBuffer.UV3Kind),l("TEXCOORD_3",t.VertexBuffer.UV4Kind),l("TEXCOORD_4",t.VertexBuffer.UV5Kind),l("TEXCOORD_5",t.VertexBuffer.UV6Kind),l("JOINTS_0",t.VertexBuffer.MatricesIndicesKind),l("WEIGHTS_0",t.VertexBuffer.MatricesWeightsKind),l("COLOR_0",t.VertexBuffer.ColorKind);const u=ve.Get(s,this._loader.gltf.bufferViews,o.bufferView);return u._dracoBabylonGeometry||(u._dracoBabylonGeometry=this._loader.loadBufferViewAsync(`/bufferViews/${u.index}`,u).then(s=>v(this,void 0,void 0,function*(){const o=this.dracoDecoder||t.DracoDecoder.Default,l=ve.TryGet(this._loader.gltf.accessors,n.attributes.POSITION),u=this._loader.parent.alwaysComputeBoundingBox||r.skeleton||!l?null:Ae(l);return yield o._decodeMeshToGeometryForGltfAsync(r.name,this._loader.babylonScene,s,a,i,u).catch(t=>{throw new Error(`${e}: ${t.message}`)})}))),yield u._dracoBabylonGeometry}))}}let Je=!1;function et(){Je||(Je=!0,ye(Qe),be(Qe,!0,e=>new Ze(e)))}et();const tt="KHR_gaussian_splatting",nt=.28209479177387814,rt=[0,3,5,7];function st(e){return e<=0?0:e>=255?255:e+.5|0}class ot{constructor(e){this.name=tt,this._loader=e,this.enabled=this._loader.isExtensionUsed(tt)}dispose(){this._loader=null}_loadMeshPrimitiveAsync(e,n,r,s,o,a){return Ce.LoadExtensionAsync(e,o,this.name,r=>v(this,void 0,void 0,function*(){if(null!=o.mode&&0!==o.mode)throw new Error(`${r}: Gaussian splatting primitives must use POINTS mode`);const s=this._loader,i=t=>{const n=o.attributes[t];if(null==n)return null;const r=ve.Get(`${e}/attributes/${t}`,s.gltf.accessors,n);return s._loadFloatAccessorAsync(`/accessors/${r.index}`,r)},l=i("POSITION");if(!l)throw new Error(`${r}: Gaussian splatting primitive is missing the POSITION attribute`);let u=0;const c=[];for(let e=1;e<=3&&null!=o.attributes[`KHR_gaussian_splatting:SH_DEGREE_${e}_COEF_0`];e++){u=e;for(let t=0;t<rt[e];t++)c.push(`KHR_gaussian_splatting:SH_DEGREE_${e}_COEF_${t}`)}const h=s.babylonScene;h._blockEntityCollection=!!s._assetContainer;const d=new t.GaussianSplattingMesh(n,null,h);d._parentContainer=s._assetContainer,h._blockEntityCollection=!1,Ce.AddPointerMetadata(d,e),s.parent.onMeshLoadedObservable.notifyObservers(d),a(d);const m=h.getEngine().getCaps(),[_,p,f,g,b,y,...T]=yield Promise.all([l,i("KHR_gaussian_splatting:ROTATION"),i("KHR_gaussian_splatting:SCALE"),i("KHR_gaussian_splatting:OPACITY"),i("KHR_gaussian_splatting:SH_DEGREE_0_COEF_0"),i("COLOR_0"),...c.map(e=>i(e))]),x=_.length/3,v=y?y.length/x:0,A=new ArrayBuffer(32*x),C=new Float32Array(A),R=new Uint8Array(A);let M=null;if(u>0){const e=3*((u+1)*(u+1)-1),n=Math.ceil(e/16),r=m.maxTextureSize,s=Math.ceil(x/r);M=t.AllocateShBuffers(n,s*r*4*4)}for(let e=0;e<x;e++){const t=8*e,n=32*e,r=3*e;if(C[t+0]=_[r+0],C[t+1]=_[r+1],C[t+2]=_[r+2],C[t+3]=f?f[r+0]:1,C[t+4]=f?f[r+1]:1,C[t+5]=f?f[r+2]:1,b)R[n+24]=st(255*(.5+nt*b[r+0])),R[n+25]=st(255*(.5+nt*b[r+1])),R[n+26]=st(255*(.5+nt*b[r+2]));else if(y){const t=e*v;R[n+24]=st(255*y[t+0]),R[n+25]=st(255*y[t+1]),R[n+26]=st(255*y[t+2])}else R[n+24]=255,R[n+25]=255,R[n+26]=255;R[n+27]=g?st(255*g[e]):y&&v>=4?st(255*y[e*v+3]):255;const s=4*e,o=p?p[s+0]:0,a=p?p[s+1]:0,i=p?p[s+2]:0,l=p?p[s+3]:1;if(R[n+28]=st(127.5*l+127.5),R[n+29]=st(127.5*o+127.5),R[n+30]=st(127.5*a+127.5),R[n+31]=st(127.5*i+127.5),M){const t=16*e;for(let e=0;e<T.length;e++){const n=T[e];if(n)for(let s=0;s<3;s++){const o=3*e+s,a=15&o;M[o>>4][t+a]=st(128*n[r+s]+128)}}}}return yield d.updateDataAsync(A,null!=M?M:void 0,void 0,u||void 0),d}))}}let at=!1;function it(){at||(at=!0,ye(tt),be(tt,!0,e=>new ot(e)))}it();const lt="KHR_lights_punctual";class ut{constructor(e){this.name=lt,this._loader=e,this.enabled=this._loader.isExtensionUsed(lt)}dispose(){this._loader=null,delete this._lights}onLoading(){const e=this._loader.gltf.extensions;if(e&&e[this.name]){const t=e[this.name];this._lights=t.lights,ve.Assign(this._lights)}}loadNodeAsync(e,n,r){return Ce.LoadExtensionAsync(e,n,this.name,(s,o)=>v(this,void 0,void 0,function*(){return this._loader._allMaterialsDirtyRequired=!0,yield this._loader.loadNodeAsync(e,n,e=>{let n;const a=ve.Get(s,this._lights,o.light),i=a.name||e.name;switch(this._loader.babylonScene._blockEntityCollection=!!this._loader._assetContainer,a.type){case"directional":{const e=new t.DirectionalLight(i,t.Vector3.Backward(),this._loader.babylonScene);e.position.setAll(0),n=e;break}case"point":n=new t.PointLight(i,t.Vector3.Zero(),this._loader.babylonScene);break;case"spot":{const e=new t.SpotLight(i,t.Vector3.Zero(),t.Vector3.Backward(),0,1,this._loader.babylonScene);e.angle=2*(a.spot&&a.spot.outerConeAngle||Math.PI/4),e.innerAngle=2*(a.spot&&a.spot.innerConeAngle||0),n=e;break}default:throw this._loader.babylonScene._blockEntityCollection=!1,new Error(`${s}: Invalid light type (${a.type})`)}n._parentContainer=this._loader._assetContainer,this._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,this._loader._babylonLights.push(n),Ce.AddPointerMetadata(n,s),r(e)})}))}}let ct=!1;function ht(){ct||(ct=!0,ye(lt),be(lt,!0,e=>new ut(e)))}ht();const dt="EXT_lights_area";class mt{constructor(e){this.name=dt,this._loader=e,this.enabled=this._loader.isExtensionUsed(dt)}dispose(){this._loader=null,delete this._lights}onLoading(){const e=this._loader.gltf.extensions;if(e&&e[this.name]){const t=e[this.name];this._lights=t.lights,ve.Assign(this._lights)}}loadNodeAsync(e,n,r){return Ce.LoadExtensionAsync(e,n,this.name,(s,o)=>v(this,void 0,void 0,function*(){return this._loader._allMaterialsDirtyRequired=!0,yield this._loader.loadNodeAsync(e,n,e=>{var n;let a;const i=ve.Get(s,this._lights,o.light),l=i.name||e.name;this._loader.babylonScene._blockEntityCollection=!!this._loader._assetContainer;const u=void 0!==i.size?i.size:1;switch(i.type){case"rect":{const e=void 0!==(null===(n=i.rect)||void 0===n?void 0:n.aspect)?i.rect.aspect*u:u,r=u;a=new t.RectAreaLight(l,t.Vector3.Zero(),e,r,this._loader.babylonScene);break}case"disk":{const e=Math.sqrt(u*u*.25*Math.PI);a=new t.RectAreaLight(l,t.Vector3.Zero(),e,e,this._loader.babylonScene);break}default:throw this._loader.babylonScene._blockEntityCollection=!1,new Error(`${s}: Invalid area light type (${i.type})`)}a._parentContainer=this._loader._assetContainer,this._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;const c=new t.TransformNode(`${l}_orientation`,this._loader.babylonScene);c.rotationQuaternion=t.Quaternion.RotationAxis(t.Vector3.Up(),Math.PI),c.parent=e,a.parent=c,this._loader._babylonLights.push(a),Ce.AddPointerMetadata(a,s),r(e)})}))}}let _t=!1;function pt(){_t||(_t=!0,ye(dt),be(dt,!0,e=>new mt(e)))}pt();const ft="KHR_materials_pbrSpecularGlossiness";class gt{constructor(e){this.name=ft,this.order=200,this._loader=e,this.enabled=this._loader.isExtensionUsed(ft)}dispose(){this._loader=null}loadMaterialPropertiesAsync(e,t,n){return Ce.LoadExtensionAsync(e,t,this.name,(r,s)=>v(this,void 0,void 0,function*(){const o=new Array;return o.push(this._loader.loadMaterialBasePropertiesAsync(e,t,n)),o.push(this._loadSpecularGlossinessPropertiesAsync(r,s,n)),this._loader.loadMaterialAlphaProperties(e,t,n),yield Promise.all(o).then(()=>{})}))}_loadSpecularGlossinessPropertiesAsync(e,n,r){const s=this._loader._getOrCreateMaterialAdapter(r),o=new Array;return s.configureSpecularGlossiness(),n.diffuseFactor?(s.baseColor=t.Color3.FromArray(n.diffuseFactor),r.alpha=n.diffuseFactor[3]):s.baseColor=t.Color3.White(),s.specularColor=n.specularFactor?t.Color3.FromArray(n.specularFactor):t.Color3.White(),s.glossiness=null==n.glossinessFactor?1:n.glossinessFactor,n.diffuseTexture&&o.push(this._loader.loadTextureInfoAsync(`${e}/diffuseTexture`,n.diffuseTexture,e=>{e.name=`${r.name} (Diffuse)`,s.baseColorTexture=e})),n.specularGlossinessTexture&&o.push(this._loader.loadTextureInfoAsync(`${e}/specularGlossinessTexture`,n.specularGlossinessTexture,e=>{e.name=`${r.name} (Specular Glossiness)`,s.specularColorTexture=e})),Promise.all(o).then(()=>{})}}let bt=!1;function yt(){bt||(bt=!0,ye(ft),be(ft,!0,e=>new gt(e)))}yt();const Tt="KHR_materials_unlit";class xt{constructor(e){this.name=Tt,this.order=210,this._loader=e,this.enabled=this._loader.isExtensionUsed(Tt)}dispose(){this._loader=null}loadMaterialPropertiesAsync(e,t,n){return Ce.LoadExtensionAsync(e,t,this.name,()=>v(this,void 0,void 0,function*(){return yield this._loadUnlitPropertiesAsync(e,t,n)}))}_loadUnlitPropertiesAsync(e,n,r){const s=this._loader._getOrCreateMaterialAdapter(r),o=new Array,a=n.pbrMetallicRoughness;return a&&(a.baseColorFactor&&(s.baseColor=t.Color3.FromArray(a.baseColorFactor),s.geometryOpacity=a.baseColorFactor[3]),a.baseColorTexture&&o.push(this._loader.loadTextureInfoAsync(`${e}/baseColorTexture`,a.baseColorTexture,e=>{e.name=`${r.name} (Base Color)`,s.baseColorTexture=e}))),s.isUnlit=!0,n.doubleSided&&(s.backFaceCulling=!1,s.twoSidedLighting=!0),this._loader.loadMaterialAlphaProperties(e,n,r),Promise.all(o).then(()=>{})}}let vt=!1;function At(){vt||(vt=!0,ye(Tt),be(Tt,!0,e=>new xt(e)))}At();const Ct="KHR_materials_clearcoat";class Rt{constructor(e){this.name=Ct,this.order=190,this._loader=e,this.enabled=this._loader.isExtensionUsed(Ct)}dispose(){this._loader=null}loadMaterialPropertiesAsync(e,t,n){return Ce.LoadExtensionAsync(e,t,this.name,(r,s)=>v(this,void 0,void 0,function*(){const o=new Array;o.push(this._loader.loadMaterialPropertiesAsync(e,t,n)),o.push(this._loadClearCoatPropertiesAsync(r,s,n)),yield Promise.all(o)}))}_loadClearCoatPropertiesAsync(e,t,n){const r=this._loader._getOrCreateMaterialAdapter(n),s=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&&s.push(this._loader.loadTextureInfoAsync(`${e}/clearcoatTexture`,t.clearcoatTexture,e=>{e.name=`${n.name} (ClearCoat)`,r.coatWeightTexture=e})),t.clearcoatRoughnessTexture&&(t.clearcoatRoughnessTexture.nonColorData=!0,s.push(this._loader.loadTextureInfoAsync(`${e}/clearcoatRoughnessTexture`,t.clearcoatRoughnessTexture,e=>{e.name=`${n.name} (ClearCoat Roughness)`,r.coatRoughnessTexture=e}))),t.clearcoatNormalTexture&&(t.clearcoatNormalTexture.nonColorData=!0,s.push(this._loader.loadTextureInfoAsync(`${e}/clearcoatNormalTexture`,t.clearcoatNormalTexture,e=>{var s;e.name=`${n.name} (ClearCoat Normal)`,r.geometryCoatNormalTexture=e,null!=(null===(s=t.clearcoatNormalTexture)||void 0===s?void 0:s.scale)&&(r.geometryCoatNormalTextureScale=t.clearcoatNormalTexture.scale)})),r.setNormalMapInversions(!n.getScene().useRightHandedSystem,n.getScene().useRightHandedSystem)),Promise.all(s).then(()=>{})}}let Mt=!1;function wt(){Mt||(Mt=!0,ye(Ct),be(Ct,!0,e=>new Rt(e)))}wt();const Et="KHR_materials_coat";class Ot{constructor(e){this.name=Et,this.order=191,this.useOpenPBR=!1,this._loader=e,this.enabled=this._loader.isExtensionUsed(Et)}dispose(){this._loader=null}loadMaterialPropertiesAsync(e,t,n){return Ce.LoadExtensionAsync(e,t,this.name,(r,s)=>v(this,void 0,void 0,function*(){const o=new Array;o.push(this._loader.loadMaterialPropertiesAsync(e,t,n)),t.extensions&&t.extensions.KHR_materials_openpbr&&(this.useOpenPBR=!0),o.push(this._loadCoatPropertiesAsync(r,s,n)),yield Promise.all(o)}))}_loadCoatPropertiesAsync(e,n,r){var s,o;const a=this._loader._getOrCreateMaterialAdapter(r),i=new Array;a.configureCoat(),a.coatWeight=void 0!==n.coatFactor?n.coatFactor:0,a.coatRoughness=void 0!==n.coatRoughnessFactor?n.coatRoughnessFactor:0,n.coatTexture&&i.push(this._loader.loadTextureInfoAsync(`${e}/coatTexture`,n.coatTexture,e=>{e.name=`${r.name} (Coat)`,a.coatWeightTexture=e})),n.coatRoughnessTexture&&(n.coatRoughnessTexture.nonColorData=!0,i.push(this._loader.loadTextureInfoAsync(`${e}/coatRoughnessTexture`,n.coatRoughnessTexture,e=>{e.name=`${r.name} (Coat Roughness)`,a.coatRoughnessTexture=e}))),n.coatNormalTexture&&(n.coatNormalTexture.nonColorData=!0,i.push(this._loader.loadTextureInfoAsync(`${e}/coatNormalTexture`,n.coatNormalTexture,e=>{var t;e.name=`${r.name} (Coat Normal)`,a.geometryCoatNormalTexture=e,null!=(null===(t=n.coatNormalTexture)||void 0===t?void 0:t.scale)&&(a.geometryCoatNormalTextureScale=n.coatNormalTexture.scale)})),a.setNormalMapInversions(!r.getScene().useRightHandedSystem,r.getScene().useRightHandedSystem)),a.coatDarkening=void 0!==n.coatDarkeningFactor?n.coatDarkeningFactor:1,a.coatIor=void 0!==n.coatIor?n.coatIor:1.5;const l=t.Color3.White();void 0!==n.coatColorFactor&&l.fromArray(n.coatColorFactor),a.coatColor=l,n.coatColorTexture&&i.push(this._loader.loadTextureInfoAsync(`${e}/coatColorTexture`,n.coatColorTexture,e=>{e.name=`${r.name} (Coat Color)`,a.coatColorTexture=e}));const u=null!==(s=n.coatAnisotropyStrength)&&void 0!==s?s:0,c=null!==(o=n.coatAnisotropyRotation)&&void 0!==o?o:0;return a.coatRoughnessAnisotropy=u,a.geometryCoatTangentAngle=c,this.useOpenPBR||a.configureGltfStyleAnisotropy(!0),n.coatAnisotropyTexture&&(n.coatAnisotropyTexture.nonColorData=!0,i.push(this._loader.loadTextureInfoAsync(`${e}/coatAnisotropyTexture`,n.coatAnisotropyTexture,e=>{e.name=`${r.name} (Coat Anisotropy)`,a.geometryCoatTangentTexture=e}))),Promise.all(i).then(()=>{})}}let Lt=!1;function St(){Lt||(Lt=!0,ye(Et),be(Et,!0,e=>new Ot(e)))}St();const Ft="KHR_materials_iridescence";class It{constructor(e){this.name=Ft,this.order=195,this._loader=e,this.enabled=this._loader.isExtensionUsed(Ft)}dispose(){this._loader=null}loadMaterialPropertiesAsync(e,t,n){return Ce.LoadExtensionAsync(e,t,this.name,(r,s)=>v(this,void 0,void 0,function*(){const o=new Array;return o.push(this._loader.loadMaterialPropertiesAsync(e,t,n)),o.push(this._loadIridescencePropertiesAsync(r,s,n)),yield Promise.all(o).then(()=>{})}))}_loadIridescencePropertiesAsync(e,t,n){var r,s,o,a,i;const l=this._loader._getOrCreateMaterialAdapter(n),u=new Array;return l.thinFilmWeight=null!==(r=t.iridescenceFactor)&&void 0!==r?r:0,l.thinFilmIor=null!==(o=null!==(s=t.iridescenceIor)&&void 0!==s?s:t.iridescenceIOR)&&void 0!==o?o:1.3,l.thinFilmThicknessMinimum=null!==(a=t.iridescenceThicknessMinimum)&&void 0!==a?a:100,l.thinFilmThicknessMaximum=null!==(i=t.iridescenceThicknessMaximum)&&void 0!==i?i:400,t.iridescenceTexture&&u.push(this._loader.loadTextureInfoAsync(`${e}/iridescenceTexture`,t.iridescenceTexture,e=>{e.name=`${n.name} (Iridescence)`,l.thinFilmWeightTexture=e})),t.iridescenceThicknessTexture&&u.push(this._loader.loadTextureInfoAsync(`${e}/iridescenceThicknessTexture`,t.iridescenceThicknessTexture,e=>{e.name=`${n.name} (Iridescence Thickness)`,l.thinFilmThicknessTexture=e})),Promise.all(u).then(()=>{})}}let Nt=!1;function kt(){Nt||(Nt=!0,ye(Ft),be(Ft,!0,e=>new It(e)))}kt();const Pt="KHR_materials_anisotropy";class Bt{constructor(e){this.name=Pt,this.order=195,this._loader=e,this.enabled=this._loader.isExtensionUsed(Pt)}dispose(){this._loader=null}loadMaterialPropertiesAsync(e,t,n){return Ce.LoadExtensionAsync(e,t,this.name,(r,s)=>v(this,void 0,void 0,function*(){const o=new Array;o.push(this._loader.loadMaterialPropertiesAsync(e,t,n)),o.push(this._loadAnisotropyPropertiesAsync(r,s,n)),yield Promise.all(o)}))}_loadAnisotropyPropertiesAsync(e,t,n){return v(this,void 0,void 0,function*(){var r,s,o;const a=this._loader._getOrCreateMaterialAdapter(n),i=new Array,l=null!==(r=t.anisotropyStrength)&&void 0!==r?r:0,u=null!==(s=t.anisotropyRotation)&&void 0!==s?s:0;a.specularRoughnessAnisotropy=l,a.geometryTangentAngle=u;const c=null!==(o=t.extensions)&&void 0!==o?o:{};c.EXT_materials_anisotropy_openpbr&&c.EXT_materials_anisotropy_openpbr.openPbrAnisotropyEnabled||a.configureGltfStyleAnisotropy(!0),t.anisotropyTexture&&(t.anisotropyTexture.nonColorData=!0,i.push(this._loader.loadTextureInfoAsync(`${e}/anisotropyTexture`,t.anisotropyTexture,e=>{e.name=`${n.name} (Anisotropy Intensity)`,a.geometryTangentTexture=e}))),yield Promise.all(i)})}}let Gt=!1;function Dt(){Gt||(Gt=!0,ye(Pt),be(Pt,!0,e=>new Bt(e)))}Dt();const Vt="KHR_materials_emissive_strength";class Ht{constructor(e){this.name=Vt,this.order=170,this._loader=e,this.enabled=this._loader.isExtensionUsed(Vt)}dispose(){this._loader=null}loadMaterialPropertiesAsync(e,t,n){return Ce.LoadExtensionAsync(e,t,this.name,(r,s)=>v(this,void 0,void 0,function*(){return yield this._loader.loadMaterialPropertiesAsync(e,t,n),this._loadEmissiveProperties(r,s,n),yield Promise.resolve()}))}_loadEmissiveProperties(e,t,n){void 0!==t.emissiveStrength&&(this._loader._getOrCreateMaterialAdapter(n).emissionLuminance=t.emissiveStrength)}}let $t=!1;function Kt(){$t||($t=!0,ye(Vt),be(Vt,!0,e=>new Ht(e)))}Kt();const Wt="KHR_materials_sheen";class Ut{constructor(e){this.name=Wt,this.order=190,this._loader=e,this.enabled=this._loader.isExtensionUsed(Wt)}dispose(){this._loader=null}loadMaterialPropertiesAsync(e,t,n){return Ce.LoadExtensionAsync(e,t,this.name,(r,s)=>v(this,void 0,void 0,function*(){const o=new Array;return o.push(this._loader.loadMaterialPropertiesAsync(e,t,n)),o.push(this._loadSheenPropertiesAsync(r,s,n)),yield Promise.all(o).then(()=>{})}))}_loadSheenPropertiesAsync(e,n,r){const s=this._loader._getOrCreateMaterialAdapter(r),o=new Array;s.configureFuzz();const a=void 0!==n.sheenColorFactor?t.Color3.FromArray(n.sheenColorFactor):t.Color3.Black(),i=void 0!==n.sheenRoughnessFactor?n.sheenRoughnessFactor:0;return s.fuzzWeight=1,s.fuzzColor=a,s.fuzzRoughness=i,n.sheenColorTexture&&o.push(this._loader.loadTextureInfoAsync(`${e}/sheenColorTexture`,n.sheenColorTexture,e=>{e.name=`${r.name} (Sheen Color)`,s.fuzzColorTexture=e})),n.sheenRoughnessTexture&&(n.sheenRoughnessTexture.nonColorData=!0,o.push(this._loader.loadTextureInfoAsync(`${e}/sheenRoughnessTexture`,n.sheenRoughnessTexture,e=>{e.name=`${r.name} (Sheen Roughness)`,s.fuzzRoughnessTexture=e}))),Promise.all(o).then(()=>{})}}let zt=!1;function jt(){zt||(zt=!0,ye(Wt),be(Wt,!0,e=>new Ut(e)))}jt();const qt="KHR_materials_fuzz";class Yt{constructor(e){this.name=qt,this.order=190,this._loader=e,this.enabled=this._loader.isExtensionUsed(qt)}dispose(){this._loader=null}loadMaterialPropertiesAsync(e,t,n){return Ce.LoadExtensionAsync(e,t,this.name,(r,s)=>v(this,void 0,void 0,function*(){const o=new Array;return o.push(this._loader.loadMaterialPropertiesAsync(e,t,n)),o.push(this._loadFuzzPropertiesAsync(r,s,n)),yield Promise.all(o).then(()=>{})}))}_loadFuzzPropertiesAsync(e,n,r){const s=this._loader._getOrCreateMaterialAdapter(r),o=new Array;return s.configureFuzz(),s.fuzzWeight=void 0!==n.fuzzFactor?n.fuzzFactor:0,s.fuzzColor=void 0!==n.fuzzColorFactor?t.Color3.FromArray(n.fuzzColorFactor):t.Color3.White(),s.fuzzRoughness=void 0!==n.fuzzRoughnessFactor?n.fuzzRoughnessFactor:.5,n.fuzzTexture&&o.push(this._loader.loadTextureInfoAsync(`${e}/fuzzTexture`,n.fuzzTexture,e=>{e.name=`${r.name} (Fuzz)`,s.fuzzWeightTexture=e})),n.fuzzColorTexture&&o.push(this._loader.loadTextureInfoAsync(`${e}/fuzzColorTexture`,n.fuzzColorTexture,e=>{e.name=`${r.name} (Fuzz Color)`,s.fuzzColorTexture=e})),n.fuzzRoughnessTexture&&(n.fuzzRoughnessTexture.nonColorData=!0,o.push(this._loader.loadTextureInfoAsync(`${e}/fuzzRoughnessTexture`,n.fuzzRoughnessTexture,e=>{e.name=`${r.name} (Fuzz Roughness)`,s.fuzzRoughnessTexture=e}))),Promise.all(o).then(()=>{})}}let Xt=!1;function Qt(){Xt||(Xt=!0,ye(qt),be(qt,!0,e=>new Yt(e)))}Qt();const Zt="KHR_materials_specular";class Jt{constructor(e){this.name=Zt,this.order=190,this._loader=e,this.enabled=this._loader.isExtensionUsed(Zt)}dispose(){this._loader=null}loadMaterialPropertiesAsync(e,t,n){return Ce.LoadExtensionAsync(e,t,this.name,(r,s)=>v(this,void 0,void 0,function*(){const o=new Array;o.push(this._loader.loadMaterialPropertiesAsync(e,t,n)),o.push(this._loadSpecularPropertiesAsync(r,s,n));const a=this._loader._getOrCreateMaterialAdapter(n);return s.extensions&&s.extensions.EXT_materials_specular_edge_color&&s.extensions.EXT_materials_specular_edge_color.specularEdgeColorEnabled&&a.enableSpecularEdgeColor(!0),yield Promise.all(o).then(()=>{})}))}_loadSpecularPropertiesAsync(e,n,r){var s;const o=this._loader._getOrCreateMaterialAdapter(r),a=new Array;return o.specularWeight=null!==(s=n.specularFactor)&&void 0!==s?s:1,o.specularColor=void 0!==n.specularColorFactor?t.Color3.FromArray(n.specularColorFactor):new t.Color3(1,1,1),n.specularTexture&&(n.specularTexture.nonColorData=!0,a.push(this._loader.loadTextureInfoAsync(`${e}/specularTexture`,n.specularTexture,e=>{e.name=`${r.name} (Specular)`,o.specularWeightTexture=e}))),n.specularColorTexture&&a.push(this._loader.loadTextureInfoAsync(`${e}/specularColorTexture`,n.specularColorTexture,e=>{e.name=`${r.name} (Specular Color)`,o.specularColorTexture=e})),Promise.all(a).then(()=>{})}}let en=!1;function tn(){en||(en=!0,ye(Zt),be(Zt,!0,e=>new Jt(e)))}tn();const nn="KHR_materials_ior";class rn{constructor(e){this.name=nn,this.order=180,this._loader=e,this.enabled=this._loader.isExtensionUsed(nn)}dispose(){this._loader=null}loadMaterialPropertiesAsync(e,t,n){return Ce.LoadExtensionAsync(e,t,this.name,(r,s)=>v(this,void 0,void 0,function*(){const o=new Array;return o.push(this._loader.loadMaterialPropertiesAsync(e,t,n)),o.push(this._loadIorPropertiesAsync(r,s,n)),yield Promise.all(o).then(()=>{})}))}_loadIorPropertiesAsync(e,t,n){const r=this._loader._getOrCreateMaterialAdapter(n),s=void 0!==t.ior?t.ior:rn._DEFAULT_IOR;return r.specularIor=s,Promise.resolve()}}rn._DEFAULT_IOR=1.5;let sn=!1;function on(){sn||(sn=!0,ye(nn),be(nn,!0,e=>new rn(e)))}on();const an="KHR_materials_variants";class ln{constructor(e){this.name=an,this._loader=e,this.enabled=this._loader.isExtensionUsed(an)&&!this._loader.parent.skipMaterials}dispose(){this._loader=null}static GetAvailableVariants(e){const t=this._GetExtensionMetadata(e);return t?Object.keys(t.variants):[]}getAvailableVariants(e){return ln.GetAvailableVariants(e)}static SelectVariant(e,t){const n=this._GetExtensionMetadata(e);if(!n)throw new Error(`Cannot select variant on a glTF mesh that does not have the ${an} extension`);const r=e=>{const t=n.variants[e];if(t)for(const e of t)e.mesh.material=e.material};if(t instanceof Array)for(const e of t)r(e);else r(t);n.lastSelected=t}selectVariant(e,t){ln.SelectVariant(e,t)}static Reset(e){const t=this._GetExtensionMetadata(e);if(!t)throw new Error(`Cannot reset on a glTF mesh that does not have the ${an} extension`);for(const e of t.original)e.mesh.material=e.material;t.lastSelected=null}reset(e){ln.Reset(e)}static GetLastSelectedVariant(e){const t=this._GetExtensionMetadata(e);if(!t)throw new Error(`Cannot get the last selected variant on a glTF mesh that does not have the ${an} extension`);return t.lastSelected}getLastSelectedVariant(e){return ln.GetLastSelectedVariant(e)}static _GetExtensionMetadata(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[an])||null}onLoading(){const e=this._loader.gltf.extensions;if(e&&e[this.name]){const t=e[this.name];this._variants=t.variants}}onReady(){var e;const t=this._loader.rootBabylonMesh;if(t){const n=this._loader.parent.extensionOptions[an];(null==n?void 0:n.defaultVariant)&&ln.SelectVariant(t,n.defaultVariant),null===(e=null==n?void 0:n.onLoaded)||void 0===e||e.call(n,{get variants(){return ln.GetAvailableVariants(t)},get selectedVariant(){const e=ln.GetLastSelectedVariant(t);return e?Array.isArray(e)?e[0]:e:ln.GetAvailableVariants(t)[0]},set selectedVariant(e){ln.SelectVariant(t,e)}})}}_loadMeshPrimitiveAsync(e,n,r,s,o,a){return Ce.LoadExtensionAsync(e,o,this.name,(i,l)=>v(this,void 0,void 0,function*(){const u=new Array;return u.push(this._loader._loadMeshPrimitiveAsync(e,n,r,s,o,n=>{if(a(n),n instanceof t.Mesh){const t=Ce._GetDrawMode(e,o.mode),r=this._loader.rootBabylonMesh,s=r?r._internalMetadata=r._internalMetadata||{}:{},a=s.gltf=s.gltf||{},c=a[an]=a[an]||{lastSelected:null,original:[],variants:{}};c.original.push({mesh:n,material:n.material});for(let e=0;e<l.mappings.length;++e){const s=l.mappings[e],o=ve.Get(`${i}/mappings/${e}/material`,this._loader.gltf.materials,s.material);u.push(this._loader._loadMaterialAsync(`#/materials/${s.material}`,o,n,t,e=>{for(let t=0;t<s.variants.length;++t){const o=s.variants[t],a=ve.Get(`/extensions/${an}/variants/${o}`,this._variants,o);c.variants[a.name]=c.variants[a.name]||[],c.variants[a.name].push({mesh:n,material:e}),n.onClonedObservable.add(e=>{const t=e;let s,o=t;do{if(o=o.parent,!o)return;s=ln._GetExtensionMetadata(o)}while(null===s);if(r&&s===ln._GetExtensionMetadata(r)){o._internalMetadata={};for(const e in r._internalMetadata)o._internalMetadata[e]=r._internalMetadata[e];o._internalMetadata.gltf=[];for(const e in r._internalMetadata.gltf)o._internalMetadata.gltf[e]=r._internalMetadata.gltf[e];o._internalMetadata.gltf[an]={lastSelected:null,original:[],variants:{}};for(const e of s.original)o._internalMetadata.gltf[an].original.push({mesh:e.mesh,material:e.material});for(const e in s.variants)if(Object.prototype.hasOwnProperty.call(s.variants,e)){o._internalMetadata.gltf[an].variants[e]=[];for(const t of s.variants[e])o._internalMetadata.gltf[an].variants[e].push({mesh:t.mesh,material:t.material})}s=o._internalMetadata.gltf[an]}for(const e of s.original)e.mesh===n&&(e.mesh=t);for(const e of s.variants[a.name])e.mesh===n&&(e.mesh=t)})}}))}}})),yield Promise.all(u).then(([e])=>e)}))}}let un=!1;function cn(){un||(un=!0,ye(an),be(an,!0,e=>new ln(e)))}cn();class hn{static _GetDefaultOptions(){return{renderSize:1024,samples:4,lodGenerationScale:1,lodGenerationOffset:-4,renderTargetTextureType:t.Constants.TEXTURETYPE_HALF_FLOAT,generateMipmaps:!0}}constructor(e,n){this._opaqueRenderTarget=null,this._opaqueMeshesCache=[],this._transparentMeshesCache=[],this._materialObservers={},this._newMeshObserver=null,this._removedMeshObserver=null,this._disposed=!1,this._materialImpls=[],this._adapterCache=new WeakMap,this._translucentMaterialIndices=new Map,this._opaqueOnlySubMeshes=new Map,this._savedSubMeshes=new Map,this._options=Object.assign(Object.assign({},hn._GetDefaultOptions()),e),this._scene=n,this._scene._transmissionHelper=this,this.onErrorObservable=new t.Observable,this._scene.onDisposeObservable.addOnce(()=>{this.dispose()}),this._parseScene(),this._setupRenderTargets()}addMaterialImpl(e){this._materialImpls.some(t=>t.materialClass===e.materialClass)||this._materialImpls.push(e)}updateOptions(e){if(!Object.keys(e).filter(t=>this._options[t]!==e[t]).length)return;const t=Object.assign(Object.assign({},this._options),e),n=this._options;this._options=t,t.renderSize===n.renderSize&&t.renderTargetTextureType===n.renderTargetTextureType&&t.generateMipmaps===n.generateMipmaps&&this._opaqueRenderTarget?(this._opaqueRenderTarget.samples=t.samples,this._opaqueRenderTarget.lodGenerationScale=t.lodGenerationScale,this._opaqueRenderTarget.lodGenerationOffset=t.lodGenerationOffset):this._setupRenderTargets()}getOpaqueTarget(){return this._opaqueRenderTarget}_getOrCreateAdapter(e){let t=this._adapterCache.get(e);if(!t)for(const n of this._materialImpls)if(e instanceof n.materialClass){t=new n.adapterClass(e),this._adapterCache.set(e,t);break}return t}_classifyMeshMaterials(e){const n=e.material;if(!n)return"opaque";if(!(n instanceof t.MultiMaterial)){const e=this._getOrCreateAdapter(n);return e&&e.isTranslucent()?(e.refractionBackgroundTexture=this._opaqueRenderTarget,"transparent"):"opaque"}let r=!1,s=!1;const o=new Set;for(let e=0;e<n.subMaterials.length;e++){const t=n.subMaterials[e];if(!t){s=!0;continue}const a=this._getOrCreateAdapter(t);a&&a.isTranslucent()?(a.refractionBackgroundTexture=this._opaqueRenderTarget,r=!0,o.add(e)):s=!0}return r&&s?(this._translucentMaterialIndices.set(e,o),this._rebuildOpaqueOnlySubMeshes(e,o),"mixed"):(this._translucentMaterialIndices.delete(e),this._opaqueOnlySubMeshes.delete(e),r?"transparent":"opaque")}_rebuildOpaqueOnlySubMeshes(e,t){e.subMeshes&&this._opaqueOnlySubMeshes.set(e,e.subMeshes.filter(e=>!t.has(e.materialIndex)))}_addMesh(e){this._materialObservers[e.uniqueId]=e.onMaterialChangedObservable.add(this._onMeshMaterialChanged.bind(this)),t.Tools.SetImmediate(()=>{!this._disposed&&e.material&&("transparent"===this._classifyMeshMaterials(e)?-1===this._transparentMeshesCache.indexOf(e)&&this._transparentMeshesCache.push(e):-1===this._opaqueMeshesCache.indexOf(e)&&this._opaqueMeshesCache.push(e))})}_removeMesh(e){e.onMaterialChangedObservable.remove(this._materialObservers[e.uniqueId]),delete this._materialObservers[e.uniqueId];let t=this._transparentMeshesCache.indexOf(e);-1!==t&&this._transparentMeshesCache.splice(t,1),t=this._opaqueMeshesCache.indexOf(e),-1!==t&&this._opaqueMeshesCache.splice(t,1),this._translucentMaterialIndices.delete(e),this._opaqueOnlySubMeshes.delete(e)}_parseScene(){this._scene.meshes.forEach(this._addMesh.bind(this)),this._newMeshObserver=this._scene.onNewMeshAddedObservable.add(this._addMesh.bind(this)),this._removedMeshObserver=this._scene.onMeshRemovedObservable.add(this._removeMesh.bind(this))}_onMeshMaterialChanged(e){const 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)}_isRenderTargetValid(){var e;return null!==(null===(e=this._opaqueRenderTarget)||void 0===e?void 0:e.getInternalTexture())}_setupRenderTargets(){var e,n;let r;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(e=>{r=this._scene.environmentIntensity,this._scene.environmentIntensity=1,this._options.clearColor?e.clearColor.copyFrom(this._options.clearColor):this._scene.clearColor.toLinearSpaceToRef(e.clearColor,this._scene.getEngine().useExactSrgbConversions),e.clearColor.a=0;const t=this._opaqueOnlySubMeshes.entries();for(let e=t.next();!e.done;e=t.next()){const t=e.value[0],n=e.value[1];t.subMeshes&&(this._savedSubMeshes.set(t,t.subMeshes),t.subMeshes=n)}}),this._opaqueRenderTarget.onAfterUnbindObservable.add(()=>{this._scene.environmentIntensity=r;const e=this._savedSubMeshes.entries();for(let t=e.next();!t.done;t=e.next())t.value[0].subMeshes=t.value[1];this._savedSubMeshes.clear()});for(const e of this._transparentMeshesCache)e.material&&this._classifyMeshMaterials(e);const s=this._translucentMaterialIndices.entries();for(let e=s.next();!e.done;e=s.next()){const t=e.value[0];t.material&&this._classifyMeshMaterials(t)}}dispose(){var e,t;this._disposed=!0,null===(e=this._newMeshObserver)||void 0===e||e.remove(),null===(t=this._removedMeshObserver)||void 0===t||t.remove(),this._newMeshObserver=null,this._removedMeshObserver=null;const n=[...this._transparentMeshesCache,...this._opaqueMeshesCache];for(const e of n){const t=this._materialObservers[e.uniqueId];t&&(t.remove(),delete this._materialObservers[e.uniqueId])}for(const e of this._scene.meshes){const t=this._materialObservers[e.uniqueId];t&&(t.remove(),delete this._materialObservers[e.uniqueId])}this._materialObservers={},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()}}function dn(e,t){if(e.parent.dontUseTransmissionHelper)return;const n=t.getScene()._transmissionHelper,r=null!=n?n:new hn({},t.getScene());for(const t of Array.from(e._pbrMaterialImpls.values()))r.addMaterialImpl(t);n&&!n._isRenderTargetValid()&&n._setupRenderTargets()}const mn="KHR_materials_transmission";class _n{constructor(e){this.name=mn,this.order=175,this._loader=e,this.enabled=this._loader.isExtensionUsed(mn),this.enabled&&(e.parent.transparencyAsCoverage=!0)}dispose(){this._loader=null}loadMaterialPropertiesAsync(e,t,n){return Ce.LoadExtensionAsync(e,t,this.name,(r,s)=>v(this,void 0,void 0,function*(){const o=new Array;return o.push(this._loader.loadMaterialPropertiesAsync(e,t,n)),o.push(this._loadTransparentPropertiesAsync(r,t,n,s)),yield Promise.all(o).then(()=>{})}))}_loadTransparentPropertiesAsync(e,t,n,r){const s=this._loader._getOrCreateMaterialAdapter(n),o=void 0!==r.transmissionFactor?r.transmissionFactor:0;if(0===o||!s)return Promise.resolve();s.configureTransmission(),s.transmissionWeight=o,o>0&&dn(this._loader,n);let a=Promise.resolve(null);return r.transmissionTexture&&(r.transmissionTexture.nonColorData=!0,a=this._loader.loadTextureInfoAsync(`${e}/transmissionTexture`,r.transmissionTexture,e=>{e.name=`${n.name} (Transmission)`,s.transmissionWeightTexture=e})),a.then(()=>{})}}let pn=!1;function fn(){pn||(pn=!0,ye(mn),be(mn,!0,e=>new _n(e)))}fn();const gn="KHR_materials_diffuse_transmission";class bn{constructor(e){this.name=gn,this.order=174,this._loader=e,this.enabled=this._loader.isExtensionUsed(gn),this.enabled&&(e.parent.transparencyAsCoverage=!0)}dispose(){this._loader=null}loadMaterialPropertiesAsync(e,t,n){return Ce.LoadExtensionAsync(e,t,this.name,(r,s)=>v(this,void 0,void 0,function*(){const o=new Array;return o.push(this._loader.loadMaterialPropertiesAsync(e,t,n)),o.push(this._loadTranslucentPropertiesAsync(r,t,n,s)),yield Promise.all(o).then(()=>{})}))}_loadTranslucentPropertiesAsync(e,n,r,s){var o;const a=this._loader._getOrCreateMaterialAdapter(r);a.configureSubsurface(),a.subsurfaceWeight=null!==(o=s.diffuseTransmissionFactor)&&void 0!==o?o:0,a.subsurfaceWeight>0&&dn(this._loader,r),a.diffuseTransmissionTint=void 0!==s.diffuseTransmissionColorFactor?t.Color3.FromArray(s.diffuseTransmissionColorFactor):t.Color3.White();const i=new Array;return s.diffuseTransmissionTexture&&(s.diffuseTransmissionTexture.nonColorData=!0,i.push(this._loader.loadTextureInfoAsync(`${e}/diffuseTransmissionTexture`,s.diffuseTransmissionTexture).then(e=>{e.name=`${r.name} (Diffuse Transmission)`,a.subsurfaceWeightTexture=e}))),s.diffuseTransmissionColorTexture&&i.push(this._loader.loadTextureInfoAsync(`${e}/diffuseTransmissionColorTexture`,s.diffuseTransmissionColorTexture).then(e=>{e.name=`${r.name} (Diffuse Transmission Color)`,a.diffuseTransmissionTintTexture=e})),Promise.all(i).then(()=>{})}}let yn=!1;function Tn(){yn||(yn=!0,ye(gn),be(gn,!0,e=>new bn(e)))}Tn();const xn="KHR_materials_volume";class vn{constructor(e){this.name=xn,this.order=173,this._loader=e,this.enabled=this._loader.isExtensionUsed(xn),this.enabled&&this._loader._disableInstancedMesh++}dispose(){this.enabled&&this._loader._disableInstancedMesh--,this._loader=null}loadMaterialPropertiesAsync(e,t,n){return Ce.LoadExtensionAsync(e,t,this.name,(r,s)=>v(this,void 0,void 0,function*(){const o=new Array;return o.push(this._loader.loadMaterialPropertiesAsync(e,t,n)),o.push(this._loadVolumePropertiesAsync(r,t,n,s)),yield Promise.all(o).then(()=>{})}))}_loadVolumePropertiesAsync(e,n,r,s){var o;const a=this._loader._getOrCreateMaterialAdapter(r);if(0===a.transmissionWeight&&0===a.subsurfaceWeight||!s.thicknessFactor)return Promise.resolve();a.geometryThinWalled=!1;const i=void 0!==s.attenuationDistance?s.attenuationDistance:Number.MAX_VALUE,l=void 0!==s.attenuationColor&&3==s.attenuationColor.length?t.Color3.FromArray(s.attenuationColor):t.Color3.White();a.configureVolume(),a.transmissionColor=l,a.transmissionDepth=i,a.volumeThickness=null!==(o=s.thicknessFactor)&&void 0!==o?o:0;const u=new Array;return s.thicknessTexture&&(s.thicknessTexture.nonColorData=!0,u.push(this._loader.loadTextureInfoAsync(`${e}/thicknessTexture`,s.thicknessTexture,e=>{e.name=`${r.name} (Thickness)`,a.volumeThicknessTexture=e}))),Promise.all(u).then(()=>{})}}let An=!1;function Cn(){An||(An=!0,ye(xn),be(xn,!0,e=>new vn(e)))}Cn();const Rn="KHR_materials_volume_scatter";class Mn{constructor(e){this.name=Rn,this.order=172,this._loader=e,this.enabled=this._loader.isExtensionUsed(Rn),this.enabled&&this._loader._disableInstancedMesh++}dispose(){this.enabled&&this._loader._disableInstancedMesh--,this._loader=null}loadMaterialPropertiesAsync(e,t,n){return Ce.LoadExtensionAsync(e,t,this.name,(r,s)=>v(this,void 0,void 0,function*(){const o=new Array;return o.push(this._loader.loadMaterialPropertiesAsync(e,t,n)),o.push(this._loadVolumePropertiesAsync(r,t,n,s)),yield Promise.all(o).then(()=>{})}))}_loadVolumePropertiesAsync(e,n,r,s){const o=this._loader._getOrCreateMaterialAdapter(r);if(0===o.transmissionWeight&&0===o.subsurfaceWeight||o.geometryThinWalled)return Promise.resolve();const a=void 0!==s.multiscatterColorFactor&&3==s.multiscatterColorFactor.length?t.Color3.FromArray(s.multiscatterColorFactor):t.Color3.Black(),i=void 0!==s.scatterAnisotropy?s.scatterAnisotropy:0;let l=Promise.resolve(null);s.multiscatterColorTexture&&(s.multiscatterColorTexture.nonColorData=!0,l=this._loader.loadTextureInfoAsync(`${e}/multiscatterColorTexture`,s.multiscatterColorTexture,e=>{e.name=`${r.name} (Scatter Color)`,o.transmissionWeight>0&&(o.transmissionScatterTexture=e),o.subsurfaceWeight>0&&(o.subsurfaceColorTexture=e)}));const u=new t.Vector3(-Math.log(o.transmissionColor.r),-Math.log(o.transmissionColor.g),-Math.log(o.transmissionColor.b));if(u.scaleInPlace(1/Math.max(o.transmissionDepth,1e-6)),o.transmissionWeight>0){const e=function(e){const 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));const s=new t.Vector3(9.59217,9.59217,9.59217);return s.addInPlace(new t.Vector3(41.6808,41.6808,41.6808).multiplyInPlace(n)),s.addInPlace(new t.Vector3(17.7126,17.7126,17.7126).multiplyInPlace(n.multiply(n))),r.subtractInPlace(new t.Vector3(Math.sqrt(s.x),Math.sqrt(s.y),Math.sqrt(s.z))),new t.Vector3(1,1,1).subtract(r.multiply(r))}(a),n=u.multiply(e);n.scaleInPlace(o.transmissionDepth),o.transmissionScatter.set(n.x,n.y,n.z),o.transmissionScatterAnisotropy=i}if(o.subsurfaceWeight>0){o.subsurfaceScatterAnisotropy=i,o.subsurfaceColor=a;const e=new t.Vector3(0!==u.x?1/u.x:1,0!==u.y?1/u.y:1,0!==u.z?1/u.z:1);o.subsurfaceRadius=Math.max(e.x,e.y,e.z),o.subsurfaceRadiusScale=new t.Color3(e.x/o.subsurfaceRadius,e.y/o.subsurfaceRadius,e.z/o.subsurfaceRadius)}return l.then(()=>{})}}let wn=!1;function En(){wn||(wn=!0,ye(Rn),be(Rn,!0,e=>new Mn(e)))}En();const On="KHR_materials_dispersion";class Ln{constructor(e){this.name=On,this.order=174,this._loader=e,this.enabled=this._loader.isExtensionUsed(On)}dispose(){this._loader=null}loadMaterialPropertiesAsync(e,t,n){return Ce.LoadExtensionAsync(e,t,this.name,(r,s)=>v(this,void 0,void 0,function*(){const o=new Array;return o.push(this._loader.loadMaterialPropertiesAsync(e,t,n)),o.push(this._loadDispersionPropertiesAsync(r,t,n,s)),yield Promise.all(o).then(()=>{})}))}_loadDispersionPropertiesAsync(e,t,n,r){const s=this._loader._getOrCreateMaterialAdapter(n);return 0!=s.transmissionWeight&&r.dispersion?(s.transmissionDispersionAbbeNumber=20,s.transmissionDispersionScale=r.dispersion,Promise.resolve()):Promise.resolve()}}let Sn=!1;function Fn(){Sn||(Sn=!0,ye(On),be(On,!0,e=>new Ln(e)))}Fn();const In="KHR_materials_diffuse_roughness";class Nn{constructor(e){this.name=In,this.order=190,this._loader=e,this.enabled=this._loader.isExtensionUsed(In)}dispose(){this._loader=null}loadMaterialPropertiesAsync(e,t,n){return Ce.LoadExtensionAsync(e,t,this.name,(r,s)=>v(this,void 0,void 0,function*(){const o=new Array;return o.push(this._loader.loadMaterialPropertiesAsync(e,t,n)),o.push(this._loadDiffuseRoughnessPropertiesAsync(r,s,n)),yield Promise.all(o).then(()=>{})}))}_loadDiffuseRoughnessPropertiesAsync(e,t,n){var r;const s=this._loader._getOrCreateMaterialAdapter(n),o=new Array;return s.baseDiffuseRoughness=null!==(r=t.diffuseRoughnessFactor)&&void 0!==r?r:0,t.diffuseRoughnessTexture&&o.push(this._loader.loadTextureInfoAsync(`${e}/diffuseRoughnessTexture`,t.diffuseRoughnessTexture,e=>{e.name=`${n.name} (Diffuse Roughness)`,s.baseDiffuseRoughnessTexture=e})),Promise.all(o).then(()=>{})}}let kn=!1;function Pn(){kn||(kn=!0,ye(In),be(In,!0,e=>new Nn(e)))}Pn();const Bn="KHR_mesh_quantization";class Gn{constructor(e){this.name=Bn,this.enabled=e.isExtensionUsed(Bn)}dispose(){}}let Dn=!1;function Vn(){Dn||(Dn=!0,ye(Bn),be(Bn,!0,e=>new Gn(e)))}Vn();const Hn="KHR_texture_basisu";class $n{constructor(e){this.name=Hn,this._loader=e,this.enabled=e.isExtensionUsed(Hn)}dispose(){this._loader=null}_loadTextureAsync(e,t,n){return Ce.LoadExtensionAsync(e,t,this.name,(r,s)=>v(this,void 0,void 0,function*(){const o=null==t.sampler?Ce.DefaultSampler:ve.Get(`${e}/sampler`,this._loader.gltf.samplers,t.sampler),a=ve.Get(`${r}/source`,this._loader.gltf.images,s.source);return yield this._loader._createTextureAsync(e,o,a,e=>{n(e)},t._textureInfo.nonColorData?{useRGBAIfASTCBC7NotAvailableWhenUASTC:!0}:void 0,!t._textureInfo.nonColorData)}))}}let Kn=!1;function Wn(){Kn||(Kn=!0,ye(Hn),be(Hn,!0,e=>new $n(e)))}Wn();const Un="KHR_texture_transform";class zn{constructor(e){this.name=Un,this._loader=e,this.enabled=this._loader.isExtensionUsed(Un)}dispose(){this._loader=null}loadTextureInfoAsync(e,n,r){return Ce.LoadExtensionAsync(e,n,this.name,(s,o)=>v(this,void 0,void 0,function*(){return yield this._loader.loadTextureInfoAsync(e,n,e=>{if(!(e instanceof t.Texture))throw new Error(`${s}: Texture type not supported`);o.offset&&(e.uOffset=o.offset[0],e.vOffset=o.offset[1]),e.uRotationCenter=0,e.vRotationCenter=0,o.rotation&&(e.wAng=-o.rotation),o.scale&&(e.uScale=o.scale[0],e.vScale=o.scale[1]),null!=o.texCoord&&(e.coordinatesIndex=o.texCoord),r(e)})}))}}let jn=!1;function qn(){jn||(jn=!0,ye(Un),be(Un,!0,e=>new zn(e)))}qn();const Yn="KHR_xmp_json_ld";class Xn{constructor(e){this.name=Yn,this.order=100,this._loader=e,this.enabled=this._loader.isExtensionUsed(Yn)}dispose(){this._loader=null}onLoading(){var e,t,n;if(null===this._loader.rootBabylonMesh)return;const r=null===(e=this._loader.gltf.extensions)||void 0===e?void 0:e.KHR_xmp_json_ld,s=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&&s){const e=+s.packet;r.packets&&e<r.packets.length&&(this._loader.rootBabylonMesh.metadata=this._loader.rootBabylonMesh.metadata||{},this._loader.rootBabylonMesh.metadata.xmp=r.packets[e])}}}let Qn=!1;function Zn(){Qn||(Qn=!0,ye(Yn),be(Yn,!0,e=>new Xn(e)))}Zn();const Jn="KHR_animation_pointer";class er{constructor(e){this.name=Jn,this._loader=e,this._pathToObjectConverter=de(this._loader.gltf)}get enabled(){return this._loader.isExtensionUsed(Jn)}dispose(){this._loader=null,delete this._pathToObjectConverter}_loadAnimationChannelAsync(e,n,r,s,o){var a;const i=null===(a=s.target.extensions)||void 0===a?void 0:a.KHR_animation_pointer;if(!i||!this._pathToObjectConverter)return null;"pointer"!==s.target.path&&t.Logger.Warn(`${e}/target/path: Value (${s.target.path}) must be (pointer) when using the ${this.name} extension`),null!=s.target.node&&t.Logger.Warn(`${e}/target/node: Value (${s.target.node}) must not be present when using the ${this.name} extension`);const l=`${e}/extensions/${this.name}`,u=i.pointer;if(!u)throw new Error(`${l}: Pointer is missing`);try{const t=this._pathToObjectConverter.convert(u);if(!t.info.interpolation)throw new Error(`${l}/pointer: Interpolation is missing`);return this._loader._loadAnimationChannelFromTargetInfoAsync(e,n,r,s,{object:t.object,info:t.info.interpolation},o)}catch(e){return t.Logger.Warn(`${l}/pointer: Invalid pointer (${u}) skipped`),null}}}let tr=!1;function nr(){tr||(tr=!0,ye(Jn),be(Jn,!0,e=>new er(e)))}function rr(e,n,r,s){return t.Vector3.FromArray(n,r).scaleInPlace(s)}function sr(e,n,r,s){return t.Quaternion.FromArray(n,r).scaleInPlace(s)}function or(e,t,n,r){const s=new Array(e._numMorphTargets);for(let e=0;e<s.length;e++)s[e]=t[n++]*r;return s}class ar{constructor(e,t,n,r){this.type=e,this.name=t,this.getValue=n,this.getStride=r}_buildAnimation(e,n,r){const s=new t.Animation(e,this.name,n,this.type);return s.setKeys(r,!0),s}}class ir extends ar{buildAnimations(e,t,n,r){const s=[];return s.push({babylonAnimatable:e._babylonTransformNode,babylonAnimation:this._buildAnimation(t,n,r)}),s}}class lr extends ar{buildAnimations(e,n,r,s){const o=[];if(e._numMorphTargets)for(let a=0;a<e._numMorphTargets;a++){const i=new t.Animation(`${n}_${a}`,this.name,r,this.type);if(i.setKeys(s.map(e=>({frame:e.frame,inTangent:e.inTangent?e.inTangent[a]:void 0,value:e.value[a],outTangent:e.outTangent?e.outTangent[a]:void 0,interpolation:e.interpolation})),!0),e._primitiveBabylonMeshes)for(const t of e._primitiveBabylonMeshes)if(t.morphTargetManager){const e=t.morphTargetManager.getTarget(a),n=i.clone();e.animations.push(n),o.push({babylonAnimatable:e,babylonAnimation:n})}}return o}}_e("/nodes/{}/translation",[new ir(t.Animation.ANIMATIONTYPE_VECTOR3,"position",rr,()=>3)]),_e("/nodes/{}/rotation",[new ir(t.Animation.ANIMATIONTYPE_QUATERNION,"rotationQuaternion",sr,()=>4)]),_e("/nodes/{}/scale",[new ir(t.Animation.ANIMATIONTYPE_VECTOR3,"scaling",rr,()=>3)]),_e("/nodes/{}/weights",[new lr(t.Animation.ANIMATIONTYPE_FLOAT,"influence",or,e=>e._numMorphTargets)]);var ur={__proto__:null,AnimationPropertyInfo:ar,TransformNodeAnimationPropertyInfo:ir,WeightAnimationPropertyInfo:lr,getQuaternion:sr,getVector3:rr,getWeights:or};function cr(e,n,r,s){return t.Color3.FromArray(n,r).scale(s)}function hr(e,t,n,r){return t[n]*r}function dr(e,t,n,r){return-t[n]*r}function mr(e,t,n,r){return t[n+1]*r}function _r(e,t,n,r){return t[n]*r*2}function pr(e){return{scale:[new gr(t.Animation.ANIMATIONTYPE_FLOAT,`${e}.uScale`,hr,()=>2),new gr(t.Animation.ANIMATIONTYPE_FLOAT,`${e}.vScale`,mr,()=>2)],offset:[new gr(t.Animation.ANIMATIONTYPE_FLOAT,`${e}.uOffset`,hr,()=>2),new gr(t.Animation.ANIMATIONTYPE_FLOAT,`${e}.vOffset`,mr,()=>2)],rotation:[new gr(t.Animation.ANIMATIONTYPE_FLOAT,`${e}.wAng`,dr,()=>1)]}}class fr extends ar{buildAnimations(e,t,n,r){return[{babylonAnimatable:e._babylonCamera,babylonAnimation:this._buildAnimation(t,n,r)}]}}class gr extends ar{buildAnimations(e,t,n,r){const s=[];for(const o in e._data)s.push({babylonAnimatable:e._data[o].babylonMaterial,babylonAnimation:this._buildAnimation(t,n,r)});return s}}class br extends ar{buildAnimations(e,t,n,r){return[{babylonAnimatable:e._babylonLight,babylonAnimation:this._buildAnimation(t,n,r)}]}}_e("/cameras/{}/orthographic/xmag",[new fr(t.Animation.ANIMATIONTYPE_FLOAT,"orthoLeft",dr,()=>1),new fr(t.Animation.ANIMATIONTYPE_FLOAT,"orthoRight",mr,()=>1)]),_e("/cameras/{}/orthographic/ymag",[new fr(t.Animation.ANIMATIONTYPE_FLOAT,"orthoBottom",dr,()=>1),new fr(t.Animation.ANIMATIONTYPE_FLOAT,"orthoTop",mr,()=>1)]),_e("/cameras/{}/orthographic/zfar",[new fr(t.Animation.ANIMATIONTYPE_FLOAT,"maxZ",hr,()=>1)]),_e("/cameras/{}/orthographic/znear",[new fr(t.Animation.ANIMATIONTYPE_FLOAT,"minZ",hr,()=>1)]),_e("/cameras/{}/perspective/yfov",[new fr(t.Animation.ANIMATIONTYPE_FLOAT,"fov",hr,()=>1)]),_e("/cameras/{}/perspective/zfar",[new fr(t.Animation.ANIMATIONTYPE_FLOAT,"maxZ",hr,()=>1)]),_e("/cameras/{}/perspective/znear",[new fr(t.Animation.ANIMATIONTYPE_FLOAT,"minZ",hr,()=>1)]),_e("/materials/{}/pbrMetallicRoughness/baseColorFactor",[new gr(t.Animation.ANIMATIONTYPE_COLOR3,"albedoColor",cr,()=>4),new gr(t.Animation.ANIMATIONTYPE_FLOAT,"alpha",function(e,t,n,r){return t[n+3]*r},()=>4)]),_e("/materials/{}/pbrMetallicRoughness/metallicFactor",[new gr(t.Animation.ANIMATIONTYPE_FLOAT,"metallic",hr,()=>1)]),_e("/materials/{}/pbrMetallicRoughness/metallicFactor",[new gr(t.Animation.ANIMATIONTYPE_FLOAT,"roughness",hr,()=>1)]);const yr=pr("albedoTexture");_e("/materials/{}/pbrMetallicRoughness/baseColorTexture/extensions/KHR_texture_transform/scale",yr.scale),_e("/materials/{}/pbrMetallicRoughness/baseColorTexture/extensions/KHR_texture_transform/offset",yr.offset),_e("/materials/{}/pbrMetallicRoughness/baseColorTexture/extensions/KHR_texture_transform/rotation",yr.rotation);const Tr=pr("metallicTexture");_e("//materials/{}/pbrMetallicRoughness/metallicRoughnessTexture/scale",Tr.scale),_e("//materials/{}/pbrMetallicRoughness/metallicRoughnessTexture/offset",Tr.offset),_e("//materials/{}/pbrMetallicRoughness/metallicRoughnessTexture/rotation",Tr.rotation),_e("/materials/{}/emissiveFactor",[new gr(t.Animation.ANIMATIONTYPE_COLOR3,"emissiveColor",cr,()=>3)]);const xr=pr("bumpTexture");_e("/materials/{}/normalTexture/scale",[new gr(t.Animation.ANIMATIONTYPE_FLOAT,"bumpTexture.level",hr,()=>1)]),_e("/materials/{}/normalTexture/extensions/KHR_texture_transform/scale",xr.scale),_e("/materials/{}/normalTexture/extensions/KHR_texture_transform/offset",xr.offset),_e("/materials/{}/normalTexture/extensions/KHR_texture_transform/rotation",xr.rotation),_e("/materials/{}/occlusionTexture/strength",[new gr(t.Animation.ANIMATIONTYPE_FLOAT,"ambientTextureStrength",hr,()=>1)]);const vr=pr("ambientTexture");_e("/materials/{}/occlusionTexture/extensions/KHR_texture_transform/scale",vr.scale),_e("/materials/{}/occlusionTexture/extensions/KHR_texture_transform/offset",vr.offset),_e("/materials/{}/occlusionTexture/extensions/KHR_texture_transform/rotation",vr.rotation);const Ar=pr("emissiveTexture");_e("/materials/{}/emissiveTexture/extensions/KHR_texture_transform/scale",Ar.scale),_e("/materials/{}/emissiveTexture/extensions/KHR_texture_transform/offset",Ar.offset),_e("/materials/{}/emissiveTexture/extensions/KHR_texture_transform/rotation",Ar.rotation),_e("/materials/{}/extensions/KHR_materials_anisotropy/anisotropyStrength",[new gr(t.Animation.ANIMATIONTYPE_FLOAT,"anisotropy.intensity",hr,()=>1)]),_e("/materials/{}/extensions/KHR_materials_anisotropy/anisotropyRotation",[new gr(t.Animation.ANIMATIONTYPE_FLOAT,"anisotropy.angle",hr,()=>1)]);const Cr=pr("anisotropy.texture");_e("/materials/{}/extensions/KHR_materials_anisotropy/anisotropyTexture/extensions/KHR_texture_transform/scale",Cr.scale),_e("/materials/{}/extensions/KHR_materials_anisotropy/anisotropyTexture/extensions/KHR_texture_transform/offset",Cr.offset),_e("/materials/{}/extensions/KHR_materials_anisotropy/anisotropyTexture/extensions/KHR_texture_transform/rotation",Cr.rotation),_e("/materials/{}/extensions/KHR_materials_clearcoat/clearcoatFactor",[new gr(t.Animation.ANIMATIONTYPE_FLOAT,"clearCoat.intensity",hr,()=>1)]),_e("/materials/{}/extensions/KHR_materials_clearcoat/clearcoatRoughnessFactor",[new gr(t.Animation.ANIMATIONTYPE_FLOAT,"clearCoat.roughness",hr,()=>1)]);const Rr=pr("clearCoat.texture");_e("/materials/{}/extensions/KHR_materials_clearcoat/clearcoatTexture/extensions/KHR_texture_transform/scale",Rr.scale),_e("/materials/{}/extensions/KHR_materials_clearcoat/clearcoatTexture/extensions/KHR_texture_transform/offset",Rr.offset),_e("/materials/{}/extensions/KHR_materials_clearcoat/clearcoatTexture/extensions/KHR_texture_transform/rotation",Rr.rotation);const Mr=pr("clearCoat.bumpTexture");_e("/materials/{}/extensions/KHR_materials_clearcoat/clearcoatNormalTexture/scale",[new gr(t.Animation.ANIMATIONTYPE_FLOAT,"clearCoat.bumpTexture.level",hr,()=>1)]),_e("/materials/{}/extensions/KHR_materials_clearcoat/clearcoatNormalTexture/extensions/KHR_texture_transform/scale",Mr.scale),_e("/materials/{}/extensions/KHR_materials_clearcoat/clearcoatNormalTexture/extensions/KHR_texture_transform/offset",Mr.offset),_e("/materials/{}/extensions/KHR_materials_clearcoat/clearcoatNormalTexture/extensions/KHR_texture_transform/rotation",Mr.rotation);const wr=pr("clearCoat.textureRoughness");_e("/materials/{}/extensions/KHR_materials_clearcoat/clearcoatRoughnessTexture/extensions/KHR_texture_transform/scale",wr.scale),_e("/materials/{}/extensions/KHR_materials_clearcoat/clearcoatRoughnessTexture/extensions/KHR_texture_transform/offset",wr.offset),_e("/materials/{}/extensions/KHR_materials_clearcoat/clearcoatRoughnessTexture/extensions/KHR_texture_transform/rotation",wr.rotation),_e("/materials/{}/extensions/KHR_materials_dispersion/dispersionFactor",[new gr(t.Animation.ANIMATIONTYPE_FLOAT,"subSurface.dispersion",hr,()=>1)]),_e("/materials/{}/extensions/KHR_materials_emissive_strength/emissiveStrength",[new gr(t.Animation.ANIMATIONTYPE_FLOAT,"emissiveIntensity",hr,()=>1)]),_e("/materials/{}/extensions/KHR_materials_ior/ior",[new gr(t.Animation.ANIMATIONTYPE_FLOAT,"indexOfRefraction",hr,()=>1)]),_e("/materials/{}/extensions/KHR_materials_iridescence/iridescenceFactor",[new gr(t.Animation.ANIMATIONTYPE_FLOAT,"iridescence.intensity",hr,()=>1)]),_e("/materials/{}/extensions/KHR_materials_iridescence/iridescenceIor",[new gr(t.Animation.ANIMATIONTYPE_FLOAT,"iridescence.indexOfRefraction",hr,()=>1)]),_e("/materials/{}/extensions/KHR_materials_iridescence/iridescenceThicknessMinimum",[new gr(t.Animation.ANIMATIONTYPE_FLOAT,"iridescence.minimumThickness",hr,()=>1)]),_e("/materials/{}/extensions/KHR_materials_iridescence/iridescenceThicknessMaximum",[new gr(t.Animation.ANIMATIONTYPE_FLOAT,"iridescence.maximumThickness",hr,()=>1)]);const Er=pr("iridescence.texture");_e("/materials/{}/extensions/KHR_materials_iridescence/iridescenceTexture/extensions/KHR_texture_transform/scale",Er.scale),_e("/materials/{}/extensions/KHR_materials_iridescence/iridescenceTexture/extensions/KHR_texture_transform/offset",Er.offset),_e("/materials/{}/extensions/KHR_materials_iridescence/iridescenceTexture/extensions/KHR_texture_transform/rotation",Er.rotation);const Or=pr("iridescence.thicknessTexture");_e("/materials/{}/extensions/KHR_materials_iridescence/iridescenceThicknessTexture/extensions/KHR_texture_transform/scale",Or.scale),_e("/materials/{}/extensions/KHR_materials_iridescence/iridescenceThicknessTexture/extensions/KHR_texture_transform/offset",Or.offset),_e("/materials/{}/extensions/KHR_materials_iridescence/iridescenceThicknessTexture/extensions/KHR_texture_transform/rotation",Or.rotation),_e("/materials/{}/extensions/KHR_materials_sheen/sheenColorFactor",[new gr(t.Animation.ANIMATIONTYPE_COLOR3,"sheen.color",cr,()=>3)]),_e("/materials/{}/extensions/KHR_materials_sheen/sheenRoughnessFactor",[new gr(t.Animation.ANIMATIONTYPE_FLOAT,"sheen.roughness",hr,()=>1)]);const Lr=pr("sheen.texture");_e("/materials/{}/extensions/KHR_materials_sheen/sheenColorTexture/extensions/KHR_texture_transform/scale",Lr.scale),_e("/materials/{}/extensions/KHR_materials_sheen/sheenColorTexture/extensions/KHR_texture_transform/offset",Lr.offset),_e("/materials/{}/extensions/KHR_materials_sheen/sheenColorTexture/extensions/KHR_texture_transform/rotation",Lr.rotation);const Sr=pr("sheen.textureRoughness");_e("/materials/{}/extensions/KHR_materials_sheen/sheenRoughnessTexture/extensions/KHR_texture_transform/scale",Sr.scale),_e("/materials/{}/extensions/KHR_materials_sheen/sheenRoughnessTexture/extensions/KHR_texture_transform/offset",Sr.offset),_e("/materials/{}/extensions/KHR_materials_sheen/sheenRoughnessTexture/extensions/KHR_texture_transform/rotation",Sr.rotation),_e("/materials/{}/extensions/KHR_materials_specular/specularFactor",[new gr(t.Animation.ANIMATIONTYPE_FLOAT,"metallicF0Factor",hr,()=>1)]),_e("/materials/{}/extensions/KHR_materials_specular/specularColorFactor",[new gr(t.Animation.ANIMATIONTYPE_COLOR3,"metallicReflectanceColor",cr,()=>3)]);const Fr=pr("metallicReflectanceTexture");_e("/materials/{}/extensions/KHR_materials_specular/specularTexture/extensions/KHR_texture_transform/scale",Fr.scale),_e("/materials/{}/extensions/KHR_materials_specular/specularTexture/extensions/KHR_texture_transform/offset",Fr.offset),_e("/materials/{}/extensions/KHR_materials_specular/specularTexture/extensions/KHR_texture_transform/rotation",Fr.rotation);const Ir=pr("reflectanceTexture");_e("/materials/{}/extensions/KHR_materials_specular/specularColorTexture/extensions/KHR_texture_transform/scale",Ir.scale),_e("/materials/{}/extensions/KHR_materials_specular/specularColorTexture/extensions/KHR_texture_transform/offset",Ir.offset),_e("/materials/{}/extensions/KHR_materials_specular/specularColorTexture/extensions/KHR_texture_transform/rotation",Ir.rotation),_e("/materials/{}/extensions/KHR_materials_transmission/transmissionFactor",[new gr(t.Animation.ANIMATIONTYPE_FLOAT,"subSurface.refractionIntensity",hr,()=>1)]);const Nr=pr("subSurface.refractionIntensityTexture");_e("/materials/{}/extensions/KHR_materials_transmission/transmissionTexture/extensions/KHR_texture_transform/scale",Nr.scale),_e("/materials/{}/extensions/KHR_materials_transmission/transmissionTexture/extensions/KHR_texture_transform/offset",Nr.offset),_e("/materials/{}/extensions/KHR_materials_transmission/transmissionTexture/extensions/KHR_texture_transform/rotation",Nr.rotation),_e("/materials/{}/extensions/KHR_materials_volume/attenuationColor",[new gr(t.Animation.ANIMATIONTYPE_COLOR3,"subSurface.tintColor",cr,()=>3)]),_e("/materials/{}/extensions/KHR_materials_volume/attenuationDistance",[new gr(t.Animation.ANIMATIONTYPE_FLOAT,"subSurface.tintColorAtDistance",hr,()=>1)]),_e("/materials/{}/extensions/KHR_materials_volume/thicknessFactor",[new gr(t.Animation.ANIMATIONTYPE_FLOAT,"subSurface.maximumThickness",hr,()=>1)]);const kr=pr("subSurface.thicknessTexture");_e("/materials/{}/extensions/KHR_materials_volume/thicknessTexture/extensions/KHR_texture_transform/scale",kr.scale),_e("/materials/{}/extensions/KHR_materials_volume/thicknessTexture/extensions/KHR_texture_transform/offset",kr.offset),_e("/materials/{}/extensions/KHR_materials_volume/thicknessTexture/extensions/KHR_texture_transform/rotation",kr.rotation),_e("/materials/{}/extensions/KHR_materials_diffuse_transmission/diffuseTransmissionFactor",[new gr(t.Animation.ANIMATIONTYPE_FLOAT,"subSurface.translucencyIntensity",hr,()=>1)]);const Pr=pr("subSurface.translucencyIntensityTexture");_e("materials/{}/extensions/KHR_materials_diffuse_transmission/diffuseTransmissionTexture/extensions/KHR_texture_transform/scale",Pr.scale),_e("materials/{}/extensions/KHR_materials_diffuse_transmission/diffuseTransmissionTexture/extensions/KHR_texture_transform/offset",Pr.offset),_e("materials/{}/extensions/KHR_materials_diffuse_transmission/diffuseTransmissionTexture/extensions/KHR_texture_transform/rotation",Pr.rotation),_e("/materials/{}/extensions/KHR_materials_diffuse_transmission/diffuseTransmissionColorFactor",[new gr(t.Animation.ANIMATIONTYPE_COLOR3,"subSurface.translucencyColor",cr,()=>3)]);const Br=pr("subSurface.translucencyColorTexture");_e("materials/{}/extensions/KHR_materials_diffuse_transmission/diffuseTransmissionColorTexture/extensions/KHR_texture_transform/scale",Br.scale),_e("materials/{}/extensions/KHR_materials_diffuse_transmission/diffuseTransmissionColorTexture/extensions/KHR_texture_transform/offset",Br.offset),_e("materials/{}/extensions/KHR_materials_diffuse_transmission/diffuseTransmissionColorTexture/extensions/KHR_texture_transform/rotation",Br.rotation),_e("/extensions/KHR_lights_punctual/lights/{}/color",[new br(t.Animation.ANIMATIONTYPE_COLOR3,"diffuse",cr,()=>3)]),_e("/extensions/KHR_lights_punctual/lights/{}/intensity",[new br(t.Animation.ANIMATIONTYPE_FLOAT,"intensity",hr,()=>1)]),_e("/extensions/KHR_lights_punctual/lights/{}/range",[new br(t.Animation.ANIMATIONTYPE_FLOAT,"range",hr,()=>1)]),_e("/extensions/KHR_lights_punctual/lights/{}/spot/innerConeAngle",[new br(t.Animation.ANIMATIONTYPE_FLOAT,"innerAngle",_r,()=>1)]),_e("/extensions/KHR_lights_punctual/lights/{}/spot/outerConeAngle",[new br(t.Animation.ANIMATIONTYPE_FLOAT,"angle",_r,()=>1)]),_e("/extensions/EXT_lights_area/lights/{}/color",[new br(t.Animation.ANIMATIONTYPE_COLOR3,"diffuse",cr,()=>3)]),_e("/extensions/EXT_lights_area/lights/{}/intensity",[new br(t.Animation.ANIMATIONTYPE_FLOAT,"intensity",hr,()=>1)]),_e("/extensions/EXT_lights_area/lights/{}/size",[new br(t.Animation.ANIMATIONTYPE_FLOAT,"radius",hr,()=>1)]),_e("/extensions/EXT_lights_area/lights/{}/rect/aspect",[new br(t.Animation.ANIMATIONTYPE_FLOAT,"radius",hr,()=>1)]),_e("/nodes/{}/extensions/EXT_lights_ies/color",[new br(t.Animation.ANIMATIONTYPE_COLOR3,"diffuse",cr,()=>3)]),_e("/nodes/{}/extensions/EXT_lights_ies/multiplier",[new br(t.Animation.ANIMATIONTYPE_FLOAT,"intensity",hr,()=>1)]),_e("/nodes/{}/extensions/KHR_node_visibility/visible",[new class extends ar{buildAnimations(e,t,n,r){return e._primitiveBabylonMeshes?e._primitiveBabylonMeshes.map(e=>({babylonAnimatable:e,babylonAnimation:this._buildAnimation(t,n,r)})):[]}}(t.Animation.ANIMATIONTYPE_FLOAT,"isVisible",hr,()=>1)]),nr();const Gr="MSFT_audio_emitter";class Dr{constructor(e){this.name=Gr,this._loader=e,this.enabled=this._loader.isExtensionUsed(Gr)}dispose(){this._loader=null,this._clips=null,this._emitters=null}onLoading(){const e=this._loader.gltf.extensions;if(e&&e[this.name]){const t=e[this.name];this._clips=t.clips,this._emitters=t.emitters,ve.Assign(this._clips),ve.Assign(this._emitters)}}loadSceneAsync(e,t){return Ce.LoadExtensionAsync(e,t,this.name,(n,r)=>v(this,void 0,void 0,function*(){const s=new Array;s.push(this._loader.loadSceneAsync(e,t));for(const e of r.emitters){const t=ve.Get(`${n}/emitters`,this._emitters,e);if(null!=t.refDistance||null!=t.maxDistance||null!=t.rolloffFactor||null!=t.distanceModel||null!=t.innerAngle||null!=t.outerAngle)throw new Error(`${n}: Direction or Distance properties are not allowed on emitters attached to a scene`);s.push(this._loadEmitterAsync(`${n}/emitters/${t.index}`,t))}yield Promise.all(s)}))}loadNodeAsync(e,n,r){return Ce.LoadExtensionAsync(e,n,this.name,(e,s)=>v(this,void 0,void 0,function*(){const o=new Array,a=yield this._loader.loadNodeAsync(e,n,n=>{for(const r of s.emitters){const s=ve.Get(`${e}/emitters`,this._emitters,r);o.push(this._loadEmitterAsync(`${e}/emitters/${s.index}`,s).then(()=>{for(const e of s._babylonSounds)e.attachToMesh(n),null==s.innerAngle&&null==s.outerAngle||(e.setLocalDirectionToMesh(t.Vector3.Forward()),e.setDirectionalCone(2*t.Tools.ToDegrees(null==s.innerAngle?Math.PI:s.innerAngle),2*t.Tools.ToDegrees(null==s.outerAngle?Math.PI:s.outerAngle),0))}))}r(n)});return yield Promise.all(o),a}))}loadAnimationAsync(e,t){return Ce.LoadExtensionAsync(e,t,this.name,(n,r)=>v(this,void 0,void 0,function*(){const s=yield this._loader.loadAnimationAsync(e,t),o=new Array;ve.Assign(r.events);for(const a of r.events)o.push(this._loadAnimationEventAsync(`${n}/events/${a.index}`,e,t,a,s));return yield Promise.all(o),s}))}_loadClipAsync(e,n){if(n._objectURL)return n._objectURL;let r;if(n.uri)r=this._loader.loadUriAsync(e,n,n.uri);else{const t=ve.Get(`${e}/bufferView`,this._loader.gltf.bufferViews,n.bufferView);r=this._loader.loadBufferViewAsync(`/bufferViews/${t.index}`,t)}return n._objectURL=r.then(e=>{const r=t.GetBlobBufferSource(e);return URL.createObjectURL(new Blob([r],{type:n.mimeType}))}),n._objectURL}_loadEmitterAsync(e,n){if(n._babylonSounds=n._babylonSounds||[],!n._babylonData){const e=new Array,r=n.name||`emitter${n.index}`,s={loop:!1,autoplay:!1,volume:null==n.volume?1:n.volume};for(let o=0;o<n.clips.length;o++){const a=`/extensions/${this.name}/clips`,i=ve.Get(a,this._clips,n.clips[o].clip);e.push(this._loadClipAsync(`${a}/${n.clips[o].clip}`,i).then(e=>{const a=n._babylonSounds[o]=new t.Sound(r,e,this._loader.babylonScene,null,s);a.refDistance=n.refDistance||1,a.maxDistance=n.maxDistance||256,a.rolloffFactor=n.rolloffFactor||1,a.distanceModel=n.distanceModel||"exponential"}))}const o=Promise.all(e).then(()=>{const e=n.clips.map(e=>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:o}}return n._babylonData.loaded}_getEventAction(e,t,n,r,s){switch(n){case"play":return e=>{const n=(s||0)+(e-r);t.play(n)};case"stop":return()=>{t.stop()};case"pause":return()=>{t.pause()};default:throw new Error(`${e}: Unsupported action ${n}`)}}_loadAnimationEventAsync(e,n,r,s,o){if(0==o.targetedAnimations.length)return Promise.resolve();const a=o.targetedAnimations[0],i=s.emitter,l=ve.Get(`/extensions/${this.name}/emitters`,this._emitters,i);return this._loadEmitterAsync(e,l).then(()=>{const n=l._babylonData.sound;if(n){const r=new t.AnimationEvent(s.time,this._getEventAction(e,n,s.action,s.time,s.startOffset));a.animation.addEvent(r),o.onAnimationGroupEndObservable.add(()=>{n.stop()}),o.onAnimationGroupPauseObservable.add(()=>{n.pause()})}})}}let Vr=!1;function Hr(){Vr||(Vr=!0,ye(Gr),be(Gr,!0,e=>new Dr(e)))}Hr();const $r="MSFT_lod";class Kr{constructor(e){var n,r;this.name=$r,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[$r])||void 0===n?void 0:n.maxLODsToLoad)&&void 0!==r?r:this.maxLODsToLoad,this.enabled=this._loader.isExtensionUsed($r)}dispose(){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()}onReady(){for(let e=0;e<this._nodePromiseLODs.length;e++){const t=Promise.all(this._nodePromiseLODs[e]).then(()=>{0!==e&&(this._loader.endPerformanceCounter(`Node LOD ${e}`),this._loader.log(`Loaded node LOD ${e}`)),this.onNodeLODsLoadedObservable.notifyObservers(e),e!==this._nodePromiseLODs.length-1&&(this._loader.startPerformanceCounter(`Node LOD ${e+1}`),this._loadBufferLOD(this._nodeBufferLODs,e+1),this._nodeSignalLODs[e]&&this._nodeSignalLODs[e].resolve())});this._loader._completePromises.push(t)}for(let e=0;e<this._materialPromiseLODs.length;e++){const t=Promise.all(this._materialPromiseLODs[e]).then(()=>{0!==e&&(this._loader.endPerformanceCounter(`Material LOD ${e}`),this._loader.log(`Loaded material LOD ${e}`)),this.onMaterialLODsLoadedObservable.notifyObservers(e),e!==this._materialPromiseLODs.length-1&&(this._loader.startPerformanceCounter(`Material LOD ${e+1}`),this._loadBufferLOD(this._materialBufferLODs,e+1),this._materialSignalLODs[e]&&this._materialSignalLODs[e].resolve())});this._loader._completePromises.push(t)}}loadSceneAsync(e,t){const n=this._loader.loadSceneAsync(e,t);return this._loadBufferLOD(this._bufferLODs,0),n}loadNodeAsync(e,n,r){return Ce.LoadExtensionAsync(e,n,this.name,(e,s)=>v(this,void 0,void 0,function*(){let o;const a=this._getLODs(e,n,this._loader.gltf.nodes,s.ids);this._loader.logOpen(`${e}`);for(let e=0;e<a.length;e++){const n=a[e];0!==e&&(this._nodeIndexLOD=e,this._nodeSignalLODs[e]=this._nodeSignalLODs[e]||new t.Deferred);const s=e=>{r(e),e.setEnabled(!1)},i=this._loader.loadNodeAsync(`/nodes/${n.index}`,n,s).then(t=>{if(0!==e){const t=a[e-1];t._babylonTransformNode&&(this._disposeTransformNode(t._babylonTransformNode),delete t._babylonTransformNode)}return t.setEnabled(!0),t});this._nodePromiseLODs[e]=this._nodePromiseLODs[e]||[],0===e?o=i:(this._nodeIndexLOD=null,this._nodePromiseLODs[e].push(i))}return this._loader.logClose(),yield o}))}_loadMaterialAsync(e,t,n,r,s){return this._nodeIndexLOD?null:Ce.LoadExtensionAsync(e,t,this.name,(e,o)=>v(this,void 0,void 0,function*(){let a;const i=this._getLODs(e,t,this._loader.gltf.materials,o.ids);this._loader.logOpen(`${e}`);for(let e=0;e<i.length;e++){const t=i[e];0!==e&&(this._materialIndexLOD=e);const o=this._loader._loadMaterialAsync(`/materials/${t.index}`,t,n,r,t=>{0===e&&s(t)}).then(t=>{if(0!==e){s(t);const n=i[e-1]._data;n[r]&&(this._disposeMaterials([n[r].babylonMaterial]),delete n[r])}return t});this._materialPromiseLODs[e]=this._materialPromiseLODs[e]||[],0===e?a=o:(this._materialIndexLOD=null,this._materialPromiseLODs[e].push(o))}return this._loader.logClose(),yield a}))}_loadUriAsync(e,n,r){if(null!==this._nodeIndexLOD){this._loader.log("deferred");const s=this._nodeIndexLOD-1;return this._nodeSignalLODs[s]=this._nodeSignalLODs[s]||new t.Deferred,this._nodeSignalLODs[this._nodeIndexLOD-1].promise.then(()=>v(this,void 0,void 0,function*(){return yield this._loader.loadUriAsync(e,n,r)}))}if(null!==this._materialIndexLOD){this._loader.log("deferred");const s=this._materialIndexLOD-1;return this._materialSignalLODs[s]=this._materialSignalLODs[s]||new t.Deferred,this._materialSignalLODs[s].promise.then(()=>v(this,void 0,void 0,function*(){return yield this._loader.loadUriAsync(e,n,r)}))}return null}loadBufferAsync(e,n,r,s){if(this._loader.parent.useRangeRequests&&!n.uri){if(!this._loader.bin)throw new Error(`${e}: Uri is missing or the binary glTF is missing its binary chunk`);const n=(e,n)=>v(this,void 0,void 0,function*(){const o=r,a=o+s-1;let i=e[n];return i?(i.start=Math.min(i.start,o),i.end=Math.max(i.end,a)):(i={start:o,end:a,loaded:new t.Deferred},e[n]=i),yield i.loaded.promise.then(e=>new Uint8Array(e.buffer,e.byteOffset+r-i.start,s))});return this._loader.log("deferred"),null!==this._nodeIndexLOD?n(this._nodeBufferLODs,this._nodeIndexLOD):null!==this._materialIndexLOD?n(this._materialBufferLODs,this._materialIndexLOD):n(this._bufferLODs,0)}return null}_loadBufferLOD(e,t){const n=e[t];n&&(this._loader.log(`Loading buffer range [${n.start}-${n.end}]`),this._loader.bin.readAsync(n.start,n.end-n.start+1).then(e=>{n.loaded.resolve(e)},e=>{n.loaded.reject(e)}))}_getLODs(e,t,n,r){if(this.maxLODsToLoad<=0)throw new Error("maxLODsToLoad must be greater than zero");const s=[];for(let t=r.length-1;t>=0;t--)if(s.push(ve.Get(`${e}/ids/${r[t]}`,n,r[t])),s.length===this.maxLODsToLoad)return s;return s.push(t),s}_disposeTransformNode(e){const t=[],n=e.material;n&&t.push(n);for(const n of e.getChildMeshes())n.material&&t.push(n.material);e.dispose();const r=t.filter(e=>this._loader.babylonScene.meshes.every(t=>t.material!=e));this._disposeMaterials(r)}_disposeMaterials(e){const t={};for(const n of e){for(const e of n.getActiveTextures())t[e.uniqueId]=e;n.dispose()}for(const e in t)for(const n of this._loader.babylonScene.materials)n.hasTexture(t[e])&&delete t[e];for(const e in t)t[e].dispose()}}let Wr=!1;function Ur(){Wr||(Wr=!0,ye($r),be($r,!0,e=>new Kr(e)))}Ur();const zr="MSFT_minecraftMesh";class jr{constructor(e){this.name=zr,this._loader=e,this.enabled=this._loader.isExtensionUsed(zr)}dispose(){this._loader=null}loadMaterialPropertiesAsync(e,t,n){return Ce.LoadExtraAsync(e,t,this.name,(r,s)=>v(this,void 0,void 0,function*(){if(s){if(!this._loader._pbrMaterialImpls.get("pbr"))throw new Error(`${r}: Material type not supported`);const s=this._loader.loadMaterialPropertiesAsync(e,t,n);return n.needAlphaBlending()&&(n.forceDepthWrite=!0,n.separateCullingPass=!0),n.backFaceCulling=n.forceDepthWrite,n.twoSidedLighting=!0,yield s}}))}}let qr=!1;function Yr(){qr||(qr=!0,ye(zr),be(zr,!0,e=>new jr(e)))}Yr();const Xr="MSFT_sRGBFactors";class Qr{constructor(e){this.name=Xr,this._loader=e,this.enabled=this._loader.isExtensionUsed(Xr)}dispose(){this._loader=null}loadMaterialPropertiesAsync(e,t,n){return Ce.LoadExtraAsync(e,t,this.name,(r,s)=>v(this,void 0,void 0,function*(){if(s){const r=this._loader._getOrCreateMaterialAdapter(n),s=this._loader.loadMaterialPropertiesAsync(e,t,n),o=n.getScene().getEngine().useExactSrgbConversions;return r.baseColorTexture||r.baseColor.toLinearSpaceToRef(r.baseColor,o),r.specularColorTexture||r.specularColor.toLinearSpaceToRef(r.specularColor,o),yield s}}))}}let Zr=!1;function Jr(){Zr||(Zr=!0,ye(Xr),be(Xr,!0,e=>new Qr(e)))}function es(e){const[t,n]=e.split(":");return ts({op:t,extension:n})}function ts(e,n=!0){var r;const s=e.extension?null===(r=rs[e.extension])||void 0===r?void 0:r[e.op]:ss[e.op];if(!s&&(t.Logger.Warn(`No mapping found for operation ${e.op} and extension ${e.extension||"KHR_interactivity"}`),n)){const t={},n={flows:{}};if(e.inputValueSockets){t.values={};for(const n in e.inputValueSockets)t.values[n]={name:n}}return e.outputValueSockets&&(n.values={},Object.keys(e.outputValueSockets).forEach(e=>{n.values[e]={name:e}})),{blocks:[],inputs:t,outputs:n}}return s}function ns(e,t,n){rs[t]||(rs[t]={}),rs[t][e]=n}Jr();const rs={BABYLON:{"flow/log":{blocks:["FlowGraphConsoleLogBlock"],inputs:{values:{message:{name:"message"}}}}}},ss={"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(e,t,n,r,s){var o;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");const a=null===(o=e.configuration.event.value)||void 0===o?void 0:o[0];if("number"!=typeof a)throw new Error("Event id should be a number");const i=r.arrays.events[a],l=s[0];return l.config||(l.config={}),l.config.eventId=i.eventId,l.config.eventData=i.eventData,s}},"event/receive":{blocks:["FlowGraphReceiveCustomEventBlock"],outputs:{flows:{out:{name:"done"}}},validation(e,n){var r,s;if(!e.configuration)return t.Logger.Error("Receive event should have a configuration object"),{valid:!1,error:"Receive event should have a configuration object"};const o=e.configuration.event;if(!o)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"};const a=null===(r=o.value)||void 0===r?void 0:r[0];return"number"!=typeof a?(t.Logger.Error("Event id should be a number"),{valid:!1,error:"Event id should be a number"}):(null===(s=n.events)||void 0===s?void 0:s[a])?{valid:!0}:(t.Logger.Error(`Event with id ${a} not found`),{valid:!1,error:`Event with id ${a} not found`})},extraProcessor(e,t,n,r,s){var o;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");const a=null===(o=e.configuration.event.value)||void 0===o?void 0:o[0];if("number"!=typeof a)throw new Error("Event id should be a number");const i=r.arrays.events[a],l=s[0];return l.config||(l.config={}),l.config.eventId=i.eventId,l.config.eventData=i.eventData,s}},"math/E":os("FlowGraphEBlock"),"math/Pi":os("FlowGraphPIBlock"),"math/Inf":os("FlowGraphInfBlock"),"math/NaN":os("FlowGraphNaNBlock"),"math/abs":os("FlowGraphAbsBlock"),"math/sign":os("FlowGraphSignBlock"),"math/trunc":os("FlowGraphTruncBlock"),"math/floor":os("FlowGraphFloorBlock"),"math/ceil":os("FlowGraphCeilBlock"),"math/round":{blocks:["FlowGraphRoundBlock"],configuration:{},inputs:{values:{a:{name:"a"}}},outputs:{values:{value:{name:"value"}}},extraProcessor(e,t,n,r,s){var o;return(o=s[0]).config||(o.config={}),s[0].config.roundHalfAwayFromZero=!0,s}},"math/fract":os("FlowGraphFractBlock"),"math/neg":os("FlowGraphNegationBlock"),"math/add":os("FlowGraphAddBlock",["a","b"],!0),"math/sub":os("FlowGraphSubtractBlock",["a","b"],!0),"math/mul":{blocks:["FlowGraphMultiplyBlock"],extraProcessor(e,t,n,r,s){var o;(o=s[0]).config||(o.config={}),s[0].config.useMatrixPerComponent=!0,s[0].config.preventIntegerFloatArithmetic=!0;let a=-1;return Object.keys(e.values||{}).find(t=>{var n;return void 0!==(null===(n=e.values)||void 0===n?void 0:n[t].type)&&(a=e.values[t].type,!0)}),-1!==a&&(s[0].config.type=r.arrays.types[a].flowGraphType),s},validation:e=>e.values?as(e):{valid:!0}},"math/div":os("FlowGraphDivideBlock",["a","b"],!0),"math/rem":os("FlowGraphModuloBlock",["a","b"]),"math/min":os("FlowGraphMinBlock",["a","b"]),"math/max":os("FlowGraphMaxBlock",["a","b"]),"math/clamp":os("FlowGraphClampBlock",["a","b","c"]),"math/saturate":os("FlowGraphSaturateBlock"),"math/mix":os("FlowGraphMathInterpolationBlock",["a","b","c"]),"math/eq":os("FlowGraphEqualityBlock",["a","b"]),"math/lt":os("FlowGraphLessThanBlock",["a","b"]),"math/le":os("FlowGraphLessThanOrEqualBlock",["a","b"]),"math/gt":os("FlowGraphGreaterThanBlock",["a","b"]),"math/ge":os("FlowGraphGreaterThanOrEqualBlock",["a","b"]),"math/isNaN":os("FlowGraphIsNaNBlock"),"math/isInf":os("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":os("FlowGraphSinBlock"),"math/cos":os("FlowGraphCosBlock"),"math/tan":os("FlowGraphTanBlock"),"math/asin":os("FlowGraphASinBlock"),"math/acos":os("FlowGraphACosBlock"),"math/atan":os("FlowGraphATanBlock"),"math/atan2":os("FlowGraphATan2Block",["a","b"]),"math/sinh":os("FlowGraphSinhBlock"),"math/cosh":os("FlowGraphCoshBlock"),"math/tanh":os("FlowGraphTanhBlock"),"math/asinh":os("FlowGraphASinhBlock"),"math/acosh":os("FlowGraphACoshBlock"),"math/atanh":os("FlowGraphATanhBlock"),"math/exp":os("FlowGraphExponentialBlock"),"math/log":os("FlowGraphLogBlock"),"math/log2":os("FlowGraphLog2Block"),"math/log10":os("FlowGraphLog10Block"),"math/sqrt":os("FlowGraphSquareRootBlock"),"math/cbrt":os("FlowGraphCubeRootBlock"),"math/pow":os("FlowGraphPowerBlock",["a","b"]),"math/length":os("FlowGraphLengthBlock"),"math/normalize":os("FlowGraphNormalizeBlock"),"math/dot":os("FlowGraphDotBlock",["a","b"]),"math/cross":os("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":os("FlowGraphTransposeBlock"),"math/determinant":os("FlowGraphDeterminantBlock"),"math/inverse":os("FlowGraphInvertMatrixBlock"),"math/matMul":os("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(e,t,n,r,s,o){const a=s[0].dataInputs.find(e=>"rotationQuaternion"===e.name);if(!a)throw new Error("Rotation quaternion input not found");return o._connectionValues[a.uniqueId]&&(o._connectionValues[a.uniqueId].type="Quaternion"),s}},"math/matDecompose":{blocks:["FlowGraphMatrixDecompose"],inputs:{values:{a:{name:"input",gltfType:"number"}}},outputs:{values:{translation:{name:"position"},rotation:{name:"rotationQuaternion"},scale:{name:"scaling"}}}},"math/quatConjugate":os("FlowGraphConjugateBlock",["a"]),"math/quatMul":{blocks:["FlowGraphMultiplyBlock"],inputs:{values:{a:{name:"a",gltfType:"vector4"},b:{name:"b",gltfType:"vector4"}}},outputs:{values:{value:{name:"value"}}},extraProcessor(e,t,n,r,s){var o;return(o=s[0]).config||(o.config={}),s[0].config.type="Quaternion",s}},"math/quatAngleBetween":os("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":os("FlowGraphAxisAngleFromQuaternionBlock",["a"]),"math/quatFromDirections":os("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(e,t,n,r,s){var o;return(o=s[0]).config||(o.config={}),s[0].config.inputIsColumnMajor=!0,s}},"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(e,t,n,r,s){var o;return(o=s[0]).config||(o.config={}),s[0].config.inputIsColumnMajor=!0,s}},"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(e,t,n,r,s){var o;return(o=s[0]).config||(o.config={}),s[0].config.inputIsColumnMajor=!0,s}},"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(e,t,n,r,s,o){var a,i,l;(l=s[0]).config||(l.config={});const u=s[0].dataInputs[0];return s[0].config.valueType=null!==(i=null===(a=o._connectionValues[u.uniqueId])||void 0===a?void 0:a.type)&&void 0!==i?i:"FlowGraphInteger",s}},"math/and":{blocks:["FlowGraphBitwiseAndBlock"],inputs:{values:{a:{name:"a"},b:{name:"b"}}},outputs:{values:{value:{name:"value"}}},extraProcessor(e,t,n,r,s,o){var a,i,l,u,c;(c=s[0]).config||(c.config={});const h=s[0].dataInputs[0],d=s[0].dataInputs[1];return s[0].config.valueType=null!==(u=null!==(i=null===(a=o._connectionValues[h.uniqueId])||void 0===a?void 0:a.type)&&void 0!==i?i:null===(l=o._connectionValues[d.uniqueId])||void 0===l?void 0:l.type)&&void 0!==u?u:"FlowGraphInteger",s}},"math/or":{blocks:["FlowGraphBitwiseOrBlock"],inputs:{values:{a:{name:"a"},b:{name:"b"}}},outputs:{values:{value:{name:"value"}}},extraProcessor(e,t,n,r,s,o){var a,i,l,u,c;(c=s[0]).config||(c.config={});const h=s[0].dataInputs[0],d=s[0].dataInputs[1];return s[0].config.valueType=null!==(u=null!==(i=null===(a=o._connectionValues[h.uniqueId])||void 0===a?void 0:a.type)&&void 0!==i?i:null===(l=o._connectionValues[d.uniqueId])||void 0===l?void 0:l.type)&&void 0!==u?u:"FlowGraphInteger",s}},"math/xor":{blocks:["FlowGraphBitwiseXorBlock"],inputs:{values:{a:{name:"a"},b:{name:"b"}}},outputs:{values:{value:{name:"value"}}},extraProcessor(e,t,n,r,s,o){var a,i,l,u,c;(c=s[0]).config||(c.config={});const h=s[0].dataInputs[0],d=s[0].dataInputs[1];return s[0].config.valueType=null!==(u=null!==(i=null===(a=o._connectionValues[h.uniqueId])||void 0===a?void 0:a.type)&&void 0!==i?i:null===(l=o._connectionValues[d.uniqueId])||void 0===l?void 0:l.type)&&void 0!==u?u:"FlowGraphInteger",s}},"math/asr":os("FlowGraphBitwiseRightShiftBlock",["a","b"]),"math/lsl":os("FlowGraphBitwiseLeftShiftBlock",["a","b"]),"math/clz":os("FlowGraphLeadingZerosBlock"),"math/ctz":os("FlowGraphTrailingZerosBlock"),"math/popcnt":os("FlowGraphOneBitsCounterBlock"),"math/rad":os("FlowGraphDegToRadBlock"),"math/deg":os("FlowGraphRadToDegBlock"),"type/boolToInt":os("FlowGraphBooleanToInt"),"type/boolToFloat":os("FlowGraphBooleanToFloat"),"type/intToBool":os("FlowGraphIntToBoolean"),"type/intToFloat":os("FlowGraphIntToFloat"),"type/floatToInt":os("FlowGraphFloatToInt"),"type/floatToBool":os("FlowGraphFloatToBoolean"),"flow/sequence":{blocks:["FlowGraphSequenceBlock"],extraProcessor(e,t,n,r,s){const o=s[0];return o.config||(o.config={}),o.config.outputSignalCount=Object.keys(e.flows||[]).length,o.signalOutputs.forEach((e,t)=>{e.name="out_"+t}),s}},"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(e){var n;const r=null===(n=e.configuration)||void 0===n?void 0:n.cases;if(r&&r.value){if(!r.value.every(e=>"number"==typeof e&&/^-?\d+$/.test(e.toString())))return t.Logger.Warn("Switch cases should be integers. Using empty array instead."),r.value=[],{valid:!0};const e=new Set(r.value);r.value=Array.from(e)}return{valid:!0}},extraProcessor(e,t,n,r,s){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 s[0].signalOutputs.forEach(e=>{"default"!==e.name&&(e.name="out_"+e.name)}),s}},"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(e,t,n,r,s){const o=s[0];return o.config||(o.config={}),o.config.incrementIndexWhenLoopDone=!0,s}},"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(e,t,n,r,s){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");const o=s[0];return o.config||(o.config={}),o.config.outputSignalCount=Object.keys(e.flows).length,o.signalOutputs.forEach((e,t)=>{e.name="out_"+t}),s}},"flow/waitAll":{blocks:["FlowGraphWaitAllBlock"],configuration:{inputFlows:{name:"inputSignalCount",gltfType:"number",inOptions:!0,defaultValue:0}},inputs:{flows:{reset:{name:"reset"},"[segment]":{name:"in_$1"}}},validation(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(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:(e,t)=>t.getVariableName(e)}}},"variable/set":{blocks:["FlowGraphSetVariableBlock"],configuration:{variables:{name:"variables",gltfType:"number",flowGraphType:"string",inOptions:!0,isArray:!0,dataTransformer:(e,t)=>e.map(e=>t.getVariableName(e))}},extraProcessor:(e,t,n,r,s)=>(s[0].dataInputs.forEach(e=>{e.name=r.getVariableName(+e.name)}),s)},"variable/interpolate":{blocks:["FlowGraphInterpolationBlock","FlowGraphContextBlock","FlowGraphPlayAnimationBlock","FlowGraphBezierCurveEasing","FlowGraphGetVariableBlock"],configuration:{variable:{name:"propertyName",inOptions:!0,isVariable:!0,dataTransformer:(e,t)=>t.getVariableName(e)},useSlerp:{name:"animationType",inOptions:!0,defaultValue:!1,dataTransformer:e=>!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(e,n,r,s,o){var a,i,l,u,c,h;const d=o[0],m=null===(i=null===(a=e.configuration)||void 0===a?void 0:a.variable.value)||void 0===i?void 0:i[0];if("number"!=typeof m)throw t.Logger.Error("Variable index is not defined for variable interpolation block"),new Error("Variable index is not defined for variable interpolation block");const _=s.arrays.staticVariables[m];void 0===(null===(u=null===(l=d.config)||void 0===l?void 0:l.animationType)||void 0===u?void 0:u.value)&&(d.config||(d.config={}),(c=d.config).animationType||(c.animationType={}),d.config.animationType.value=t.getAnimationTypeByFlowGraphType(_.type));const p=o[4];return p.config||(p.config={}),(h=p.config).variable||(h.variable={}),p.config.variable.value=s.getVariableName(m),o}},"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:(e,t,n,r,s)=>(s.forEach(e=>{"FlowGraphJsonPointerParserBlock"===e.className&&(e.config||(e.config={}),e.config.outputValue=!0)}),s)},"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:(e,t,n,r,s)=>(s.forEach(e=>{"FlowGraphJsonPointerParserBlock"===e.className&&(e.config||(e.config={}),e.config.outputValue=!0)}),s)},"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:(e,t,n,r,s)=>(s.forEach(t=>{"FlowGraphJsonPointerParserBlock"===t.className?(t.config||(t.config={}),t.config.outputValue=!0):"FlowGraphInterpolationBlock"===t.className&&(t.config||(t.config={}),Object.keys(e.values||[]).forEach(n=>{var s;const o=null===(s=e.values)||void 0===s?void 0:s[n];if("value"===n&&o){const e=o.type;void 0!==e&&(t.config.animationType=r.arrays.types[e].flowGraphType)}}))}),s)},"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:(e,t)=>[e[0]*t._animationTargetFps]},endTime:{name:"to",gltfType:"number",dataTransformer:(e,t)=>[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(e,t,n,r,s,o,a){const i=s[s.length-1];return i.config||(i.config={}),i.config.glTF=a,s}},"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(e,t,n,r,s,o,a){const i=s[s.length-1];return i.config||(i.config={}),i.config.glTF=a,s}},"animation/stopAt":{blocks:["FlowGraphStopAnimationBlock","FlowGraphArrayIndexBlock","KHR_interactivity/FlowGraphGLTFDataProvider"],configuration:{},inputs:{values:{animation:{name:"index",gltfType:"number",toBlock:"FlowGraphArrayIndexBlock"},stopTime:{name:"stopAtFrame",gltfType:"number",dataTransformer:(e,t)=>[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(e,t,n,r,s,o,a){const i=s[s.length-1];return i.config||(i.config={}),i.config.glTF=a,s}},"math/switch":{blocks:["FlowGraphDataSwitchBlock"],configuration:{cases:{name:"cases",isArray:!0,inOptions:!0,defaultValue:[]}},inputs:{values:{selection:{name:"case"}}},validation(e){var n;const r=null===(n=e.configuration)||void 0===n?void 0:n.cases;if(r&&r.value){if(!r.value.every(e=>"number"==typeof e&&/^-?\d+$/.test(e.toString())))return t.Logger.Warn("Switch cases should be integers. Using empty array instead."),r.value=[],{valid:!0};const e=new Set(r.value);r.value=Array.from(e)}return{valid:!0}},extraProcessor(e,t,n,r,s){const o=s[0];return o.dataInputs.forEach(e=>{"default"!==e.name&&"case"!==e.name&&(e.name="in_"+e.name)}),o.config||(o.config={}),o.config.treatCasesAsIntegers=!0,s}},"debug/log":{blocks:["FlowGraphConsoleLogBlock"],configuration:{message:{name:"messageTemplate",inOptions:!0}}}};function os(e,t=["a"],n){return{blocks:[e],inputs:{values:t.reduce((e,t)=>(e[t]={name:t},e),{})},outputs:{values:{value:{name:"value"}}},extraProcessor(e,t,r,s,o){var a;if(n){(a=o[0]).config||(a.config={}),o[0].config.preventIntegerFloatArithmetic=!0;let t=-1;Object.keys(e.values||{}).find(n=>{var r;return void 0!==(null===(r=e.values)||void 0===r?void 0:r[n].type)&&(t=e.values[n].type,!0)}),-1!==t&&(o[0].config.type=s.arrays.types[t].flowGraphType)}return o},validation:e=>n?as(e):{valid:!0}}}function as(e){if(e.values){const t=Object.keys(e.values).map(t=>e.values[t].type).filter(e=>void 0!==e);if(!t.every(e=>e===t[0]))return{valid:!1,error:"All inputs must be of the same type"}}return{valid:!0}}function is(){return Object.keys(ss)}const ls={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"}};class us{constructor(e,t,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()}get arrays(){return{types:this._types,mappings:this._mappings,staticVariables:this._staticVariables,events:this._events,nodes:this._nodes}}_parseTypes(){if(this._interactivityGraph.types)for(const e of this._interactivityGraph.types)this._types.push(ls[e.signature])}_parseDeclarations(){if(this._interactivityGraph.declarations)for(const e of this._interactivityGraph.declarations){const n=ts(e);if(!n)throw t.Logger.Error(["No mapping found for declaration",e]),new Error("Error parsing declarations");this._mappings.push({flowGraphMapping:n,fullOperationName:e.extension?e.op+":"+e.extension:e.op})}}_parseVariables(){if(this._interactivityGraph.variables)for(const e of this._interactivityGraph.variables){const t=this._parseVariable(e);this._staticVariables.push(t)}}_parseVariable(e,n){const 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");const s=e.value||[];if(!s.length)switch(r.flowGraphType){case"boolean":s.push(!1);break;case"FlowGraphInteger":s.push(0);break;case"number":s.push(NaN);break;case"Vector2":s.push(NaN,NaN);break;case"Vector3":s.push(NaN,NaN,NaN);break;case"Vector4":case"Matrix2D":case"Quaternion":s.fill(NaN,0,4);break;case"Matrix":s.fill(NaN,0,16);break;case"Matrix3D":s.fill(NaN,0,9)}return"number"===r.elementType&&"string"==typeof s[0]&&(s[0]=parseFloat(s[0])),{type:r.flowGraphType,value:n?n(s,this):s}}_parseEvents(){if(this._interactivityGraph.events)for(const e of this._interactivityGraph.events){const n={eventId:e.id||"internalEvent_"+this._internalEventsCounter++};e.values&&(n.eventData=Object.keys(e.values).map(n=>{var r;const s=null===(r=e.values)||void 0===r?void 0:r[n];if(!s)throw t.Logger.Error(["No value found for event key",n]),new Error("Error parsing events");const o=this._types[s.type];if(!o)throw t.Logger.Error(["No type found for event value",s]),new Error("Error parsing events");const a=void 0!==s.value?this._parseVariable(s):void 0;return{id:n,type:o.flowGraphType,eventData:!0,value:a}})),this._events.push(n)}}_parseNodes(){var e;if(this._interactivityGraph.nodes)for(const n of this._interactivityGraph.nodes){if("number"!=typeof n.declaration)throw t.Logger.Error(["No declaration found for node",n]),new Error("Error parsing nodes");const r=this._mappings[n.declaration];if(!r)throw t.Logger.Error(["No mapping found for node",n]),new Error("Error parsing nodes");if(r.flowGraphMapping.validation){const t=r.flowGraphMapping.validation(n,this._interactivityGraph,this._gltf);if(!t.valid)throw new Error(`Error validating interactivity node ${null===(e=this._interactivityGraph.declarations)||void 0===e?void 0:e[n.declaration].op} - ${t.error}`)}const s=[];for(const e of r.flowGraphMapping.blocks){const t=this._getEmptyBlock(e,r.fullOperationName);this._parseNodeConfiguration(n,t,r.flowGraphMapping,e),s.push(t)}this._nodes.push({blocks:s,fullOperationName:r.fullOperationName})}}_getEmptyBlock(e,n){return{uniqueId:t.RandomGUID(),className:e,dataInputs:[],dataOutputs:[],signalInputs:[],signalOutputs:[],config:{},type:n,metadata:{}}}_parseNodeConfiguration(e,n,r,s){var o;const a=e.configuration;if(a)for(const e in a){const i=a[e];if(!i)throw new Error("Error parsing node configuration");const l=null===(o=r.configuration)||void 0===o?void 0:o[e];if(l&&l.toBlock?l.toBlock===s:0===r.blocks.indexOf(s)){let r=null==l?void 0:l.defaultValue;(null==i?void 0:i.value)&&(r=i.value),(null==l?void 0:l.isArray)||(1!==r.length&&t.Logger.Warn(`Invalid non-array value length: ${r.length}`),r=r[0]),(null==l?void 0:l.dataTransformer)&&(r=l.dataTransformer(r,this)),void 0!==r&&(n.config[(null==l?void 0:l.name)||e]={value:r})}}}_parseNodeConnections(e){var n,r,s,o,a,i,l,u,c,h,d,m,_,p,f,g,b,y,T;for(let x=0;x<this._nodes.length;x++){const v=null===(n=this._interactivityGraph.nodes)||void 0===n?void 0:n[x];if(!v)throw t.Logger.Error(["No node found for interactivity node",this._nodes[x]]),new Error("Error parsing node connections");const A=this._nodes[x],C=this._mappings[v.declaration];if(!C)throw t.Logger.Error(["No mapping found for node",v]),new Error("Error parsing node connections");const R=v.flows||{},M=Object.keys(R).sort();for(const e of M){const n=R[e],c=null===(s=null===(r=C.flowGraphMapping.outputs)||void 0===r?void 0:r.flows)||void 0===s?void 0:s[e],h=(null==c?void 0:c.name)||e,d=this._createNewSocketConnection(h,!0);(c&&c.toBlock&&A.blocks.find(e=>e.className===c.toBlock)||A.blocks[0]).signalOutputs.push(d);const m=n.node,_=this._nodes[m];if(!_)throw t.Logger.Error(["No node found for input node id",m]),new Error("Error parsing node connections");const p=es(_.fullOperationName);if(!p)throw t.Logger.Error(["No mapping found for input node",_]),new Error("Error parsing node connections");let f=null===(a=null===(o=p.inputs)||void 0===o?void 0:o.flows)||void 0===a?void 0:a[n.socket||"in"],g=!1;if(!f)for(const e in null===(i=p.inputs)||void 0===i?void 0:i.flows)e.startsWith("[")&&e.endsWith("]")&&(g=!0,f=null===(u=null===(l=p.inputs)||void 0===l?void 0:l.flows)||void 0===u?void 0:u[e]);const b=f?g?f.name.replace("$1",n.socket||""):f.name:n.socket||"in",y=f&&f.toBlock&&_.blocks.find(e=>e.className===f.toBlock)||_.blocks[0];let T=y.signalInputs.find(e=>e.name===b);T||(T=this._createNewSocketConnection(b),y.signalInputs.push(T)),T.connectedPointIds.push(d.uniqueId),d.connectedPointIds.push(T.uniqueId)}const w=v.values||{},E=Object.keys(w);for(const n of E){const r=w[n];let s=null===(h=null===(c=C.flowGraphMapping.inputs)||void 0===c?void 0:c.values)||void 0===h?void 0:h[n],o=!1;if(!s)for(const e in null===(d=C.flowGraphMapping.inputs)||void 0===d?void 0:d.values)e.startsWith("[")&&e.endsWith("]")&&(o=!0,s=null===(_=null===(m=C.flowGraphMapping.inputs)||void 0===m?void 0:m.values)||void 0===_?void 0:_[e]);const a=s?o?s.name.replace("$1",n):s.name:n,i=this._createNewSocketConnection(a);if((s&&s.toBlock&&A.blocks.find(e=>e.className===s.toBlock)||A.blocks[0]).dataInputs.push(i),void 0!==r.value){const t=this._parseVariable(r,s&&s.dataTransformer);e._connectionValues[i.uniqueId]=t}else{if(void 0===r.node)throw t.Logger.Error(["Invalid value for value connection",r]),new Error("Error parsing node connections");{const e=r.node,n=r.socket||"value",s=this._nodes[e];if(!s)throw t.Logger.Error(["No node found for output socket reference",r]),new Error("Error parsing node connections");const o=es(s.fullOperationName);if(!o)throw t.Logger.Error(["No mapping found for output socket reference",r]),new Error("Error parsing node connections");let a=null===(f=null===(p=o.outputs)||void 0===p?void 0:p.values)||void 0===f?void 0:f[n],l=!1;if(!a)for(const e in null===(g=o.outputs)||void 0===g?void 0:g.values)e.startsWith("[")&&e.endsWith("]")&&(l=!0,a=null===(y=null===(b=o.outputs)||void 0===b?void 0:b.values)||void 0===y?void 0:y[e]);const u=a?l?a.name.replace("$1",n):null==a?void 0:a.name:n,c=a&&a.toBlock&&s.blocks.find(e=>e.className===a.toBlock)||s.blocks[0];let h=c.dataOutputs.find(e=>e.name===u);h||(h=this._createNewSocketConnection(u,!0),c.dataOutputs.push(h)),i.connectedPointIds.push(h.uniqueId),h.connectedPointIds.push(i.uniqueId)}}}if(C.flowGraphMapping.interBlockConnectors)for(const e of C.flowGraphMapping.interBlockConnectors){const t=e.input,n=e.output,r=e.isVariable;this._connectFlowGraphNodes(t,n,A.blocks[e.inputBlockIndex],A.blocks[e.outputBlockIndex],r)}if(C.flowGraphMapping.extraProcessor){const n=null===(T=this._interactivityGraph.declarations)||void 0===T?void 0:T[v.declaration];if(!n)throw t.Logger.Error(["No declaration found for extra processor",v]),new Error("Error parsing node connections");A.blocks=C.flowGraphMapping.extraProcessor(v,n,C.flowGraphMapping,this,A.blocks,e,this._gltf)}}}_createNewSocketConnection(e,n){return{uniqueId:t.RandomGUID(),name:e,_connectionType:n?1:0,connectedPointIds:[]}}_connectFlowGraphNodes(e,t,n,r,s){const o=s?n.dataInputs:n.signalInputs,a=s?r.dataOutputs:r.signalOutputs,i=o.find(t=>t.name===e)||this._createNewSocketConnection(e),l=a.find(e=>e.name===t)||this._createNewSocketConnection(t,!0);o.find(t=>t.name===e)||o.push(i),a.find(e=>e.name===t)||a.push(l),i.connectedPointIds.push(l.uniqueId),l.connectedPointIds.push(i.uniqueId)}getVariableName(e){return"staticVariable_"+e}serializeToFlowGraph(){const e={uniqueId:t.RandomGUID(),_userVariables:{},_connectionValues:{}};this._parseNodeConnections(e);for(let t=0;t<this._staticVariables.length;t++){const n=this._staticVariables[t];e._userVariables[this.getVariableName(t)]=n}return{rightHanded:!0,allBlocks:this._nodes.reduce((e,t)=>e.concat(t.blocks),[]),executionContexts:[e]}}}const cs="KHR_interactivity";class hs{constructor(e){this._loader=e,this.name=cs,this.enabled=this._loader.isExtensionUsed(cs),this._pathConverter=de(this._loader.gltf),e._skipStartAnimationStep=!0;const t=e.babylonScene;t&&ds(t)}dispose(){this._loader=null,delete this._pathConverter}onReady(){return v(this,void 0,void 0,function*(){var e;if(!this._loader.babylonScene||!this._pathConverter)return;const n=this._loader.babylonScene,r=null===(e=this._loader.gltf.extensions)||void 0===e?void 0:e.KHR_interactivity;if(!r)return;const s=new t.FlowGraphCoordinator({scene:n});s.dispatchEventsSynchronously=!1;const o=r.graphs.map(e=>new us(e,this._loader.gltf,this._loader.parent.targetFps).serializeToFlowGraph());yield Promise.all(o.map(e=>v(this,void 0,void 0,function*(){return yield t.ParseFlowGraphAsync(e,{coordinator:s,pathConverter:this._pathConverter})}))),s.start()})}}function ds(e){pe("/extensions/KHR_interactivity/?/activeCamera/rotation",{get:()=>{if(!e.activeCamera)return new t.Quaternion(NaN,NaN,NaN,NaN);const n=t.Quaternion.FromRotationMatrix(e.activeCamera.getWorldMatrix()).normalize();return e.useRightHandedSystem||(n.w*=-1,n.x*=-1),n},type:"Quaternion",getTarget:()=>e.activeCamera}),pe("/extensions/KHR_interactivity/?/activeCamera/position",{get:()=>{if(!e.activeCamera)return new t.Vector3(NaN,NaN,NaN);const n=e.activeCamera.getWorldMatrix().getTranslation();return e.useRightHandedSystem||(n.x*=-1),n},type:"Vector3",getTarget:()=>e.activeCamera}),pe("/animations/{}/extensions/KHR_interactivity/isPlaying",{get: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:e=>e._babylonAnimationGroup}),pe("/animations/{}/extensions/KHR_interactivity/minTime",{get: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:e=>e._babylonAnimationGroup}),pe("/animations/{}/extensions/KHR_interactivity/maxTime",{get: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:e=>e._babylonAnimationGroup}),pe("/animations/{}/extensions/KHR_interactivity/playhead",{get: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:e=>e._babylonAnimationGroup}),pe("/animations/{}/extensions/KHR_interactivity/virtualPlayhead",{get: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:e=>e._babylonAnimationGroup})}let ms=!1;function _s(){ms||(ms=!0,t.addToBlockFactory(cs,"FlowGraphGLTFDataProvider",()=>v(this,void 0,void 0,function*(){return(yield Promise.resolve().then(function(){return Ns})).FlowGraphGLTFDataProvider})),ye(cs),be(cs,!0,e=>new hs(e)))}_s();const ps="KHR_node_visibility";class fs{constructor(e){this.name=ps,this._loader=e,this.enabled=e.isExtensionUsed(ps)}onReady(){if(!this._loader)return;const e=this._loader.gltf.nodes;if(e)for(const t of e){const e=t._babylonTransformNode;e&&(e.inheritVisibility=!0,t.extensions&&t.extensions.KHR_node_visibility&&!1===t.extensions.KHR_node_visibility.visible&&(e.isVisible=!1))}}dispose(){delete this._loader}}let gs=!1;function bs(){gs||(gs=!0,pe("/nodes/{}/extensions/KHR_node_visibility/visible",{get:e=>{const t=e._babylonTransformNode;return!t||void 0===t.isVisible||t.isVisible},set:(e,t)=>{var n,r;null===(n=t._primitiveBabylonMeshes)||void 0===n||n.forEach(e=>{e.inheritVisibility=!0}),t._babylonTransformNode&&(t._babylonTransformNode.isVisible=e),null===(r=t._primitiveBabylonMeshes)||void 0===r||r.forEach(t=>{t.isVisible=e})},getTarget:e=>e._babylonTransformNode,getPropertyName:[()=>"isVisible"],type:"boolean"}),ye(ps),be(ps,!0,e=>new fs(e)))}bs();const ys="KHR_node_selectability";class Ts{constructor(e){this.name=ys,this._loader=e,this.enabled=e.isExtensionUsed(ys)}onReady(){return v(this,void 0,void 0,function*(){var e;null===(e=this._loader.gltf.nodes)||void 0===e||e.forEach(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(e=>{e.isPickable=!1}))})})}dispose(){this._loader=null}}let xs=!1;function vs(){xs||(xs=!0,ns("event/onSelect",ys,{blocks:["FlowGraphMeshPickEventBlock","FlowGraphGetVariableBlock","FlowGraphIndexOfBlock","KHR_interactivity/FlowGraphGLTFDataProvider"],configuration:{stopPropagation:{name:"stopPropagation"},nodeIndex:{name:"variable",toBlock:"FlowGraphGetVariableBlock",dataTransformer:e=>"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(e,t,n,r,s,o,a){var i,l,u,c,h,d,m;const _=s[s.length-1];_.config=_.config||{},_.config.glTF=a;const p=null===(u=null===(l=null===(i=e.configuration)||void 0===i?void 0:i.nodeIndex)||void 0===l?void 0:l.value)||void 0===u?void 0:u[0];if(void 0===p||"number"!=typeof p)throw new Error("nodeIndex not found in configuration");const f="pickedMesh_"+p;return s[1].config.variable=f,o._userVariables[f]={className:"Mesh",id:null===(h=null===(c=null==a?void 0:a.nodes)||void 0===c?void 0:c[p]._babylonTransformNode)||void 0===h?void 0:h.id,uniqueId:null===(m=null===(d=null==a?void 0:a.nodes)||void 0===d?void 0:d[p]._babylonTransformNode)||void 0===m?void 0:m.uniqueId},s}}),pe("/nodes/{}/extensions/KHR_node_selectability/selectable",{get:e=>{const t=e._babylonTransformNode;return!t||void 0===t.isPickable||t.isPickable},set:(e,t)=>{var n;null===(n=t._primitiveBabylonMeshes)||void 0===n||n.forEach(t=>{t.isPickable=e})},getTarget:e=>e._babylonTransformNode,getPropertyName:[()=>"isPickable"],type:"boolean"}),ye(ys),be(ys,!0,e=>new Ts(e)))}vs();const As="KHR_node_hoverability",Cs="targetMeshPointerOver_",Rs="targetMeshPointerOut_";class Ms{constructor(e){this.name=As,this._loader=e,this.enabled=e.isExtensionUsed(As)}onReady(){return v(this,void 0,void 0,function*(){var e;null===(e=this._loader.gltf.nodes)||void 0===e||e.forEach(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(e=>{e.pointerOverDisableMeshTesting=!0}))})})}dispose(){this._loader=null}}let ws=!1;function Es(){ws||(ws=!0,ns("event/onHoverIn",As,{blocks:["FlowGraphPointerOverEventBlock","FlowGraphGetVariableBlock","FlowGraphIndexOfBlock","KHR_interactivity/FlowGraphGLTFDataProvider"],configuration:{stopPropagation:{name:"stopPropagation"},nodeIndex:{name:"variable",toBlock:"FlowGraphGetVariableBlock",dataTransformer:e=>Cs+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(e,t,n,r,s,o,a){var i,l,u,c,h,d,m;const _=s[s.length-1];_.config=_.config||{},_.config.glTF=a;const p=null===(u=null===(l=null===(i=e.configuration)||void 0===i?void 0:i.nodeIndex)||void 0===l?void 0:l.value)||void 0===u?void 0:u[0];if(void 0===p||"number"!=typeof p)throw new Error("nodeIndex not found in configuration");const f=Cs+p;return s[1].config.variable=f,o._userVariables[f]={className:"Mesh",id:null===(h=null===(c=null==a?void 0:a.nodes)||void 0===c?void 0:c[p]._babylonTransformNode)||void 0===h?void 0:h.id,uniqueId:null===(m=null===(d=null==a?void 0:a.nodes)||void 0===d?void 0:d[p]._babylonTransformNode)||void 0===m?void 0:m.uniqueId},s}}),ns("event/onHoverOut",As,{blocks:["FlowGraphPointerOutEventBlock","FlowGraphGetVariableBlock","FlowGraphIndexOfBlock","KHR_interactivity/FlowGraphGLTFDataProvider"],configuration:{stopPropagation:{name:"stopPropagation"},nodeIndex:{name:"variable",toBlock:"FlowGraphGetVariableBlock",dataTransformer:e=>Rs+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(e,t,n,r,s,o,a){var i,l,u,c,h,d,m;const _=s[s.length-1];_.config=_.config||{},_.config.glTF=a;const p=null===(u=null===(l=null===(i=e.configuration)||void 0===i?void 0:i.nodeIndex)||void 0===l?void 0:l.value)||void 0===u?void 0:u[0];if(void 0===p||"number"!=typeof p)throw new Error("nodeIndex not found in configuration");const f=Rs+p;return s[1].config.variable=f,o._userVariables[f]={className:"Mesh",id:null===(h=null===(c=null==a?void 0:a.nodes)||void 0===c?void 0:c[p]._babylonTransformNode)||void 0===h?void 0:h.id,uniqueId:null===(m=null===(d=null==a?void 0:a.nodes)||void 0===d?void 0:d[p]._babylonTransformNode)||void 0===m?void 0:m.uniqueId},s}}),pe("/nodes/{}/extensions/KHR_node_hoverability/hoverable",{get:e=>{const t=e._babylonTransformNode;return!t||void 0===t.pointerOverDisableMeshTesting||t.pointerOverDisableMeshTesting},set:(e,t)=>{var n;null===(n=t._primitiveBabylonMeshes)||void 0===n||n.forEach(t=>{t.pointerOverDisableMeshTesting=!e})},getTarget:e=>e._babylonTransformNode,getPropertyName:[()=>"pointerOverDisableMeshTesting"],type:"boolean"}),ye(As),be(As,!0,e=>new Ms(e)))}Es();const Os="ExtrasAsMetadata";class Ls{_assignExtras(e,t){if(t.extras&&Object.keys(t.extras).length>0){const n=e.metadata=e.metadata||{};(n.gltf=n.gltf||{}).extras=t.extras}}constructor(e){this.name=Os,this.enabled=!0,this._loader=e}dispose(){this._loader=null}loadNodeAsync(e,t,n){return this._loader.loadNodeAsync(e,t,e=>{this._assignExtras(e,t),n(e)})}loadCameraAsync(e,t,n){return this._loader.loadCameraAsync(e,t,e=>{this._assignExtras(e,t),n(e)})}createMaterial(e,t,n){const r=this._loader.createMaterial(e,t,n);return this._assignExtras(r,t),r}loadAnimationAsync(e,t){return this._loader.loadAnimationAsync(e,t).then(e=>(this._assignExtras(e,t),e))}}let Ss=!1;function Fs(){Ss||(Ss=!0,ye(Os),be(Os,!1,e=>new Ls(e)))}Fs();class Is extends t.FlowGraphBlock{constructor(e){var n,r;super(e);const s=e.glTF,o=(null===(n=null==s?void 0:s.animations)||void 0===n?void 0:n.map(e=>e._babylonAnimationGroup))||[];this.animationGroups=this.registerDataOutput("animationGroups",t.RichTypeAny,o);const a=(null===(r=null==s?void 0:s.nodes)||void 0===r?void 0:r.map(e=>e._babylonTransformNode))||[];this.nodes=this.registerDataOutput("nodes",t.RichTypeAny,a)}getClassName(){return"FlowGraphGLTFDataProvider"}}var Ns={__proto__:null,FlowGraphGLTFDataProvider:Is},ks={__proto__:null,AddObjectAccessorToKey:pe,EXT_lights_area:mt,EXT_lights_ies:qe,EXT_lights_image_based:Ee,EXT_mesh_gpu_instancing:Fe,EXT_meshopt_compression:Pe,EXT_texture_avif:We,EXT_texture_webp:Ve,ExtrasAsMetadata:Ls,FlowGraphGLTFDataProvider:Is,GetMappingForKey:me,GetPathToObjectConverter:de,InteractivityGraphToFlowGraphParser:us,KHR_animation_pointer:er,KHR_draco_mesh_compression:Ze,KHR_gaussian_splatting:ot,KHR_interactivity:hs,KHR_lights:ut,KHR_materials_anisotropy:Bt,KHR_materials_clearcoat:Rt,KHR_materials_coat:Ot,KHR_materials_diffuse_roughness:Nn,KHR_materials_diffuse_transmission:bn,KHR_materials_dispersion:Ln,KHR_materials_emissive_strength:Ht,KHR_materials_fuzz:Yt,KHR_materials_ior:rn,KHR_materials_iridescence:It,KHR_materials_pbrSpecularGlossiness:gt,KHR_materials_sheen:Ut,KHR_materials_specular:Jt,KHR_materials_transmission:_n,KHR_materials_unlit:xt,KHR_materials_variants:ln,KHR_materials_volume:vn,KHR_materials_volume_scatter:Mn,KHR_mesh_quantization:Gn,KHR_node_hoverability:Ms,KHR_node_selectability:Ts,KHR_node_visibility:fs,KHR_texture_basisu:$n,KHR_texture_transform:zn,KHR_xmp_json_ld:Xn,MSFT_audio_emitter:Dr,MSFT_lod:Kr,MSFT_minecraftMesh:jr,MSFT_sRGBFactors:Qr,RegisterEXT_lights_area:pt,RegisterEXT_lights_ies:Xe,RegisterEXT_lights_image_based:Le,RegisterEXT_mesh_gpu_instancing:Ne,RegisterEXT_meshopt_compression:Ge,RegisterEXT_texture_avif:ze,RegisterEXT_texture_webp:$e,RegisterExtrasAsMetadata:Fs,RegisterKHR_animation_pointer:nr,RegisterKHR_draco_mesh_compression:et,RegisterKHR_gaussian_splatting:it,RegisterKHR_interactivity:_s,RegisterKHR_lights:ht,RegisterKHR_materials_anisotropy:Dt,RegisterKHR_materials_clearcoat:wt,RegisterKHR_materials_coat:St,RegisterKHR_materials_diffuse_roughness:Pn,RegisterKHR_materials_diffuse_transmission:Tn,RegisterKHR_materials_dispersion:Fn,RegisterKHR_materials_emissive_strength:Kt,RegisterKHR_materials_fuzz:Qt,RegisterKHR_materials_ior:on,RegisterKHR_materials_iridescence:kt,RegisterKHR_materials_pbrSpecularGlossiness:yt,RegisterKHR_materials_sheen:jt,RegisterKHR_materials_specular:tn,RegisterKHR_materials_transmission:fn,RegisterKHR_materials_unlit:At,RegisterKHR_materials_variants:cn,RegisterKHR_materials_volume:Cn,RegisterKHR_materials_volume_scatter:En,RegisterKHR_mesh_quantization:Vn,RegisterKHR_node_hoverability:Es,RegisterKHR_node_selectability:vs,RegisterKHR_node_visibility:bs,RegisterKHR_texture_basisu:Wn,RegisterKHR_texture_transform:qn,RegisterKHR_xmp_json_ld:Zn,RegisterMSFT_audio_emitter:Hr,RegisterMSFT_lod:Ur,RegisterMSFT_minecraftMesh:Yr,RegisterMSFT_sRGBFactors:Jr,SetInterpolationForKey:_e,TransmissionHelper:hn,_AddInteractivityObjectModel:ds,addNewInteractivityFlowGraphMapping:ns,ensureTransmissionHelper:dn,getAllSupportedNativeNodeTypes:is,getMappingForDeclaration:ts,getMappingForFullOperationName:es,gltfTypeToBabylonType:ls};Me();class Ps{constructor(e){this._specWorkflow=!1,this._diffuseTransmissionTint=t.Color3.White(),this._diffuseTransmissionTintTexture=null,this._material=e}get material(){return this._material}get isUnlit(){return this._material.unlit}set isUnlit(e){this._material.unlit=e}set backFaceCulling(e){this._material.backFaceCulling=e}get backFaceCulling(){return this._material.backFaceCulling}set twoSidedLighting(e){this._material.twoSidedLighting=e}get twoSidedLighting(){return this._material.twoSidedLighting}set alphaCutOff(e){this._material.alphaCutOff=e}get alphaCutOff(){return this._material.alphaCutOff}set useAlphaFromBaseColorTexture(e){this._material._useAlphaFromBaseColorTexture=e}get useAlphaFromBaseColorTexture(){return this._material._useAlphaFromBaseColorTexture}get transparencyAsAlphaCoverage(){return!1}set transparencyAsAlphaCoverage(e){}set baseColor(e){this._material.baseColor=e}get baseColor(){return this._material.baseColor}set baseColorTexture(e){this._material.baseColorTexture=e}get baseColorTexture(){return this._material.baseColorTexture}set baseDiffuseRoughness(e){this._material.baseDiffuseRoughness=e}get baseDiffuseRoughness(){return this._material.baseDiffuseRoughness}set baseDiffuseRoughnessTexture(e){this._material.baseDiffuseRoughnessTexture=e}get baseDiffuseRoughnessTexture(){return this._material.baseDiffuseRoughnessTexture}set baseMetalness(e){this._material.baseMetalness=e}get baseMetalness(){return this._material.baseMetalness}set baseMetalnessTexture(e){this._material.baseMetalnessTexture=e}get baseMetalnessTexture(){return this._material.baseMetalnessTexture}set useRoughnessFromMetallicTextureGreen(e){this._material._useRoughnessFromMetallicTextureGreen=e}set useMetallicFromMetallicTextureBlue(e){this._material._useMetallicFromMetallicTextureBlue=e}enableSpecularEdgeColor(e=!1){}configureSpecularGlossiness(){this._specWorkflow=!0}set specularWeight(e){this._material.specularWeight=e}get specularWeight(){return this._material.specularWeight}set specularWeightTexture(e){this._material.specularColorTexture===e?(this._material.specularWeightTexture=null,this._material._useSpecularWeightFromSpecularColorTexture=!0,this._material._useSpecularWeightFromAlpha=!0):this._material.specularWeightTexture=e}get specularWeightTexture(){return this._material.specularWeightTexture}set specularColor(e){this._material.specularColor=e}get specularColor(){return this._material.specularColor}set specularColorTexture(e){this._material.specularColorTexture=e,this._material.specularWeightTexture===this._material.specularColorTexture&&(this._material.specularWeightTexture=null,this._material._useSpecularWeightFromSpecularColorTexture=!0,this._material._useSpecularWeightFromAlpha=!0)}get specularColorTexture(){return this._material.specularColorTexture}set specularRoughness(e){this._material.specularRoughness=e}get specularRoughness(){return this._material.specularRoughness}set specularRoughnessTexture(e){this._material.specularRoughnessTexture=e}get specularRoughnessTexture(){return this._material.specularRoughnessTexture}set specularIor(e){this._material.specularIor=e}get specularIor(){return this._material.specularIor}set glossiness(e){this._material.specularRoughness=Math.max(1-e,0)}get glossiness(){return 1-this._material.specularRoughness}set emissionColor(e){this._material.emissionColor=e}get emissionColor(){return this._material.emissionColor}set emissionLuminance(e){this._material.emissionLuminance=e}get emissionLuminance(){return this._material.emissionLuminance}set emissionColorTexture(e){this._material.emissionColorTexture=e}get emissionColorTexture(){return this._material.emissionColorTexture}set ambientOcclusionTexture(e){this._material.ambientOcclusionTexture=e}get ambientOcclusionTexture(){return this._material.ambientOcclusionTexture}set ambientOcclusionTextureStrength(e){const t=this._material.ambientOcclusionTexture;t&&(t.level=e)}get ambientOcclusionTextureStrength(){var e;const t=this._material.ambientOcclusionTexture;return null!==(e=null==t?void 0:t.level)&&void 0!==e?e:1}configureCoat(){}set coatWeight(e){this._material.coatWeight=e}get coatWeight(){return this._material.coatWeight}set coatWeightTexture(e){this._material.coatWeightTexture=e}get coatWeightTexture(){return this._material.coatWeightTexture}set coatColor(e){this._material.coatColor=e}get coatColor(){return this._material.coatColor}set coatColorTexture(e){this._material.coatColorTexture=e}set coatRoughness(e){this._material.coatRoughness=e}get coatRoughness(){return this._material.coatRoughness}set coatRoughnessTexture(e){this._material.coatRoughnessTexture=e,e&&(this._material._useCoatRoughnessFromGreenChannel=!0)}get coatRoughnessTexture(){return this._material.coatRoughnessTexture}set coatIor(e){this._material.coatIor=e}get coatIor(){return this._material.coatIor}set coatDarkening(e){this._material.coatDarkening=e}get coatDarkening(){return this._material.coatDarkening}set coatDarkeningTexture(e){this._material.coatDarkeningTexture=e}set coatRoughnessAnisotropy(e){this._material.coatRoughnessAnisotropy=e}get coatRoughnessAnisotropy(){return this._material.coatRoughnessAnisotropy}set geometryCoatTangentAngle(e){this._material.geometryCoatTangentAngle=e}set geometryCoatTangentTexture(e){this._material.geometryCoatTangentTexture=e,e&&(this._material._useCoatRoughnessAnisotropyFromTangentTexture=!0)}get geometryCoatTangentTexture(){return this._material.geometryCoatTangentTexture}configureTransmission(){this._material.geometryThinWalled=1,this._material.transmissionDepth=0}set transmissionWeight(e){this._material.transmissionWeight=e}set transmissionWeightTexture(e){this._material.transmissionWeightTexture=e}get transmissionWeightTexture(){return this._material.transmissionWeightTexture}get transmissionWeight(){return this._material.transmissionWeight}set transmissionScatter(e){this._material.transmissionScatter=e}get transmissionScatter(){return this._material.transmissionScatter}set transmissionScatterTexture(e){this._material.transmissionScatterTexture=e}get transmissionScatterTexture(){return this._material.transmissionScatterTexture}set transmissionScatterAnisotropy(e){this._material.transmissionScatterAnisotropy=e}set transmissionDispersionAbbeNumber(e){this._material.transmissionDispersionAbbeNumber=e}set transmissionDispersionScale(e){this._material.transmissionDispersionScale=e}set transmissionDepth(e){e!==Number.MAX_VALUE||0!==this._material.transmissionDepth?this._material.transmissionDepth=e:this._material.transmissionDepth=0}get transmissionDepth(){return this._material.transmissionDepth}set transmissionColor(e){e.equals(t.Color3.White())||(this._material.transmissionColor=e)}get transmissionColor(){return this._material.transmissionColor}get refractionBackgroundTexture(){return this._material.backgroundRefractionTexture}set refractionBackgroundTexture(e){this._material.backgroundRefractionTexture=e}configureVolume(){this._material.geometryThinWalled=0}set geometryThinWalled(e){this._material.geometryThinWalled=e?1:0}get geometryThinWalled(){return!!this._material.geometryThinWalled}set volumeThicknessTexture(e){this._material.geometryThicknessTexture=e,this._material._useGeometryThicknessFromGreenChannel=!0}set volumeThickness(e){this._material.geometryThickness=e}configureSubsurface(){this._material.geometryThinWalled=1,this._material.subsurfaceScatterAnisotropy=1}set subsurfaceWeight(e){this._material.subsurfaceWeight=e}get subsurfaceWeight(){return this._material.subsurfaceWeight}set subsurfaceWeightTexture(e){this._material.subsurfaceWeightTexture=e,this._material._useSubsurfaceWeightFromTextureAlpha=!0}get subsurfaceWeightTexture(){return this._material.subsurfaceWeightTexture}set subsurfaceColor(e){this._material.subsurfaceColor=e}set subsurfaceColorTexture(e){this._material.subsurfaceColorTexture=e}set diffuseTransmissionTint(e){this._diffuseTransmissionTint=e}get diffuseTransmissionTint(){return this._diffuseTransmissionTint}set diffuseTransmissionTintTexture(e){this._diffuseTransmissionTintTexture=e}get subsurfaceRadius(){return this._material.subsurfaceRadius}set subsurfaceRadius(e){this._material.subsurfaceRadius=e}get subsurfaceRadiusScale(){return this._material.subsurfaceRadiusScale}set subsurfaceRadiusScale(e){this._material.subsurfaceRadiusScale=e}set subsurfaceScatterAnisotropy(e){this._material.subsurfaceScatterAnisotropy=e}isTranslucent(){return this.transmissionWeight>0||this.subsurfaceWeight>0}configureFuzz(){}set fuzzWeight(e){this._material.fuzzWeight=e}set fuzzWeightTexture(e){this._material.fuzzWeightTexture=e}set fuzzColor(e){this._material.fuzzColor=e}set fuzzColorTexture(e){this._material.fuzzColorTexture=e}set fuzzRoughness(e){this._material.fuzzRoughness=e}set fuzzRoughnessTexture(e){this._material.fuzzRoughnessTexture=e,this._material._useFuzzRoughnessFromTextureAlpha=!0}set specularRoughnessAnisotropy(e){this._material.specularRoughnessAnisotropy=e}get specularRoughnessAnisotropy(){return this._material.specularRoughnessAnisotropy}set geometryTangentAngle(e){this._material.geometryTangentAngle=e}set geometryTangentTexture(e){this._material.geometryTangentTexture=e,this._material._useSpecularRoughnessAnisotropyFromTangentTexture=!0}get geometryTangentTexture(){return this._material.geometryTangentTexture}configureGltfStyleAnisotropy(e=!0){this._material._useGltfStyleAnisotropy=e}set thinFilmWeight(e){this._material.thinFilmWeight=e}set thinFilmIor(e){this._material.thinFilmIor=e}set thinFilmThicknessMinimum(e){this._material.thinFilmThicknessMin=e/1e3}set thinFilmThicknessMaximum(e){this._material.thinFilmThickness=e/1e3}set thinFilmWeightTexture(e){this._material.thinFilmWeightTexture=e}set thinFilmThicknessTexture(e){this._material.thinFilmThicknessTexture=e,this._material._useThinFilmThicknessFromTextureGreen=!0}set unlit(e){this._material.unlit=e}set geometryOpacity(e){this._material.geometryOpacity=e}get geometryOpacity(){return this._material.geometryOpacity}set geometryNormalTexture(e){this._material.geometryNormalTexture=e}get geometryNormalTexture(){return this._material.geometryNormalTexture}setNormalMapInversions(e,t){}set geometryCoatNormalTexture(e){this._material.geometryCoatNormalTexture=e}get geometryCoatNormalTexture(){return this._material.geometryCoatNormalTexture}set geometryCoatNormalTextureScale(e){this._material.geometryCoatNormalTexture&&(this._material.geometryCoatNormalTexture.level=e)}finalizeAsync(e){return v(this,void 0,void 0,function*(){var n,r,s;if(this._diffuseTransmissionTint&&!this._diffuseTransmissionTint.equals(t.Color3.White())||this._diffuseTransmissionTintTexture)if(this._material.geometryThinWalled)this.subsurfaceColor=this._diffuseTransmissionTint,this.subsurfaceColorTexture=this._diffuseTransmissionTintTexture;else if(yield this.copySurfaceToCoatAsync(e,this.subsurfaceWeight,this.subsurfaceWeightTexture,t.TextureChannel.A,this._diffuseTransmissionTint,this._diffuseTransmissionTintTexture,!0),e._disposed)return;if(this.transmissionWeight>0)if(this._material.geometryThinWalled||0===this._material.transmissionDepth)this._material.transmissionColor=this._material.baseColor,this._material.transmissionColorTexture=this._material.baseColorTexture;else if((!this.baseColor.equals(t.Color3.White())||null!==this.baseColorTexture)&&(yield this.copySurfaceToCoatAsync(e,this.transmissionWeight,this.transmissionWeightTexture,t.TextureChannel.R,this.baseColor,this.baseColorTexture,!1),e._disposed))return;if(this._specWorkflow){const o=yield t.InvertTextureAsync("newRoughnessTexture ("+this._material.name+")",yield 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),this._material.getScene(),t.ChannelMask.R,t.TextureColorSpace.Linear,t.ChannelMask.R);if(e._disposed)return void(null===(n=o.texture)||void 0===n||n.dispose());this.specularRoughnessTexture=o.texture,this.specularRoughness=o.factor?o.factor.r:1;const a=yield 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);if(e._disposed)return void(null===(r=a.texture)||void 0===r||r.dispose());this.baseMetalnessTexture=a.texture,this.baseMetalness=a.factor?a.factor.r:1;const i=yield 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),Object.assign(Object.assign({},a),{dispose:void 0,colorSpace:t.TextureColorSpace.Linear}),this._material.getScene(),t.TextureColorSpace.SRGB,t.ChannelMask.RGB);if(e._disposed)return void(null===(s=i.texture)||void 0===s||s.dispose());const l=this.baseColorTexture;null==l||l.dispose(),this.baseColorTexture=i.texture,this.baseColor=i.factor?new t.Color3(i.factor.r,i.factor.g,i.factor.b):t.Color3.White();const u=this.specularColorTexture;null==u||u.dispose(),this.specularColorTexture=null}})}copySurfaceToCoatAsync(e,n,r,s,o,a){return v(this,arguments,void 0,function*(e,n,r,s,o,a,i=!1){var l,u,c,h,d,m,_,p,f;const g=this._material.coatWeight,b=this._material.coatWeightTexture,y=this._material.coatColor.clone(),T=this._material.coatColorTexture,x=this._material.geometryCoatNormalTexture,v=new t.Color4(g,g,g,g),A=new t.Color4(n,n,n,n);this.coatWeightTexture=null,this.coatWeight=1;const C=yield Promise.allSettled([t.LerpTexturesAsync("lerpExistingCoat",t.CreateTextureWithFactorOperand(null,new t.Color4(1,1,1,1)),t.CreateTextureWithFactorOperand(T,y.toColor4(),t.TextureChannel.RGBA,t.TextureColorSpace.SRGB),t.CreateTextureWithFactorOperand(b,v,t.TextureChannel.R),this._material.getScene(),t.TextureColorSpace.SRGB),t.LerpTexturesAsync("lerpSurfaceColor",t.CreateTextureWithFactorOperand(null,new t.Color4(1,1,1,1)),t.CreateTextureWithFactorOperand(a,o.toColor4(),t.TextureChannel.RGBA,t.TextureColorSpace.SRGB),t.CreateTextureWithFactorOperand(r,A,s),this._material.getScene(),t.TextureColorSpace.SRGB)]),R=C.find(e=>"rejected"===e.status);if(R){for(const e of C)"fulfilled"===e.status&&(null===(l=e.value.texture)||void 0===l||l.dispose());throw R.reason}const[M,w]=C.map(e=>e.value);if(e._disposed)return null===(u=M.texture)||void 0===u||u.dispose(),void(null===(c=w.texture)||void 0===c||c.dispose());const E=yield t.MultiplyTexturesAsync("newCoatColor ("+this._material.name+")",M,w,this._material.getScene(),t.TextureColorSpace.SRGB);if(e._disposed)return void(null===(h=E.texture)||void 0===h||h.dispose());E.texture?(this.coatColorTexture=E.texture,this.coatColor=t.Color3.White()):E.factor&&(this.coatColorTexture=null,this.coatColor.fromArray([E.factor.r,E.factor.g,E.factor.b]));const O=yield 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(b,v,t.TextureChannel.R),this._material.getScene());if(e._disposed)return void(null===(d=O.texture)||void 0===d||d.dispose());this.coatIor=O.factor?O.factor.r:this.coatIor;const L=yield 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(b,v,t.TextureChannel.R),this._material.getScene());if(e._disposed)return void(null===(m=L.texture)||void 0===m||m.dispose());this.coatRoughness=L.factor?L.factor.r:1,this.coatRoughnessTexture=L.texture;const S=yield 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(b,v,t.TextureChannel.R),this._material.getScene());if(e._disposed)null===(_=S.texture)||void 0===_||_.dispose();else{if(this.coatDarkening=S.factor?S.factor.r:this.coatDarkening,i){const n=yield 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,A,s),this._material.getScene());if(e._disposed)return void(null===(p=n.texture)||void 0===p||p.dispose());this.specularRoughness=n.factor?n.factor.r:1,this.specularRoughnessTexture=n.texture}if(x||this.geometryNormalTexture){const n=yield 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(x,x?new t.Color4(1,1,1,1):new t.Color4(.5,.5,1,1),t.TextureChannel.RGBA),t.CreateTextureWithFactorOperand(b,v,t.TextureChannel.R),this._material.getScene());if(e._disposed)return void(null===(f=n.texture)||void 0===f||f.dispose());n.texture&&(this.geometryCoatNormalTexture=n.texture)}}})}}var Bs={__proto__:null,OpenPBRMaterialLoadingAdapter:Ps};class Gs{constructor(e){this._specWorkflow=!1,this._material=e,this._material.enableSpecularAntiAliasing=!0}get material(){return this._material}finalizeAsync(e){return v(this,void 0,void 0,function*(){})}get isUnlit(){return this._material.unlit}set isUnlit(e){this._material.unlit=e}set backFaceCulling(e){this._material.backFaceCulling=e}get backFaceCulling(){return this._material.backFaceCulling}set twoSidedLighting(e){this._material.twoSidedLighting=e}get twoSidedLighting(){return this._material.twoSidedLighting}set alphaCutOff(e){this._material.alphaCutOff=e}get alphaCutOff(){return this._material.alphaCutOff}set useAlphaFromBaseColorTexture(e){this._material.useAlphaFromAlbedoTexture=e}get useAlphaFromBaseColorTexture(){return this._material.useAlphaFromAlbedoTexture}get transparencyAsAlphaCoverage(){return this._material.useRadianceOverAlpha||this._material.useSpecularOverAlpha}set transparencyAsAlphaCoverage(e){this._material.useRadianceOverAlpha=!e,this._material.useSpecularOverAlpha=!e}set baseColor(e){this._material.albedoColor=e}get baseColor(){return this._material.albedoColor}set baseColorTexture(e){this._material.albedoTexture=e}get baseColorTexture(){return this._material.albedoTexture}set baseDiffuseRoughness(e){this._material.baseDiffuseRoughness=e,e>0&&(this._material.brdf.baseDiffuseModel=t.Constants.MATERIAL_DIFFUSE_MODEL_E_OREN_NAYAR)}get baseDiffuseRoughness(){var e;return null!==(e=this._material.baseDiffuseRoughness)&&void 0!==e?e:0}set baseDiffuseRoughnessTexture(e){this._material.baseDiffuseRoughnessTexture=e}get baseDiffuseRoughnessTexture(){return this._material.baseDiffuseRoughnessTexture}set baseMetalness(e){this._material.metallic=e}get baseMetalness(){var e;return null!==(e=this._material.metallic)&&void 0!==e?e:1}set baseMetalnessTexture(e){this._material.metallicTexture=e}get baseMetalnessTexture(){return this._material.metallicTexture}set useRoughnessFromMetallicTextureGreen(e){this._material.useRoughnessFromMetallicTextureGreen=e,this._material.useRoughnessFromMetallicTextureAlpha=!e}set useMetallicFromMetallicTextureBlue(e){this._material.useMetallnessFromMetallicTextureBlue=e}enableSpecularEdgeColor(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)}configureSpecularGlossiness(){this._specWorkflow=!0,this._material.metallic=null,this._material.roughness=null,this._material.useMicroSurfaceFromReflectivityMapAlpha=!0}set specularWeight(e){this._material.metallicF0Factor=e}get specularWeight(){var e;return null!==(e=this._material.metallicF0Factor)&&void 0!==e?e:1}set specularWeightTexture(e){e?(this._material.metallicReflectanceTexture=e,this._material.useOnlyMetallicFromMetallicReflectanceTexture=!0):(this._material.metallicReflectanceTexture=null,this._material.useOnlyMetallicFromMetallicReflectanceTexture=!1)}get specularWeightTexture(){return this._material.metallicReflectanceTexture}set specularColor(e){this._specWorkflow?this._material.reflectivityColor=e:this._material.metallicReflectanceColor=e}get specularColor(){return this._specWorkflow?this._material.reflectivityColor:this._material.metallicReflectanceColor}set specularColorTexture(e){this._specWorkflow?(this._material.reflectivityTexture=e,this._material.reflectivityTexture&&(this._material.reflectivityTexture.hasAlpha=!0)):this._material.reflectanceTexture=e}get specularColorTexture(){return this._specWorkflow?this._material.reflectivityTexture:this._material.reflectanceTexture}set specularRoughness(e){this._material.roughness=e}get specularRoughness(){var e;return null!==(e=this._material.roughness)&&void 0!==e?e:1}set specularRoughnessTexture(e){this.baseMetalnessTexture||(this._material.metallicTexture=e)}get specularRoughnessTexture(){return this._material.metallicTexture}set specularIor(e){this._material.indexOfRefraction=e}get specularIor(){return this._material.indexOfRefraction}get glossiness(){var e;return null!==(e=this._material.microSurface)&&void 0!==e?e:1}set glossiness(e){this._material.microSurface=e}set emissionColor(e){this._material.emissiveColor=e}get emissionColor(){return this._material.emissiveColor}set emissionLuminance(e){this._material.emissiveIntensity=e}get emissionLuminance(){return this._material.emissiveIntensity}set emissionColorTexture(e){this._material.emissiveTexture=e}get emissionColorTexture(){return this._material.emissiveTexture}set ambientOcclusionTexture(e){this._material.ambientTexture=e,e&&(this._material.useAmbientInGrayScale=!0)}get ambientOcclusionTexture(){return this._material.ambientTexture}set ambientOcclusionTextureStrength(e){this._material.ambientTextureStrength=e}get ambientOcclusionTextureStrength(){var e;return null!==(e=this._material.ambientTextureStrength)&&void 0!==e?e:1}configureCoat(){this._material.clearCoat.isEnabled=!0,this._material.clearCoat.useRoughnessFromMainTexture=!1,this._material.clearCoat.remapF0OnInterfaceChange=!1}set coatWeight(e){this._material.clearCoat.isEnabled=!0,this._material.clearCoat.intensity=e}get coatWeight(){return this._material.clearCoat.intensity}set coatWeightTexture(e){this._material.clearCoat.isEnabled=!0,this._material.clearCoat.texture=e}get coatWeightTexture(){return this._material.clearCoat.texture}set coatColor(e){this._material.clearCoat.isTintEnabled=e!=t.Color3.White(),this._material.clearCoat.tintColor=e}set coatColorTexture(e){this._material.clearCoat.tintTexture=e}set coatRoughness(e){this._material.clearCoat.isEnabled=!0,this._material.clearCoat.roughness=e}get coatRoughness(){var e;return null!==(e=this._material.clearCoat.roughness)&&void 0!==e?e:0}set coatRoughnessTexture(e){this._material.clearCoat.isEnabled=!0,this._material.clearCoat.useRoughnessFromMainTexture=!1,this._material.clearCoat.textureRoughness=e}get coatRoughnessTexture(){return this._material.clearCoat.textureRoughness}set coatIor(e){this._material.clearCoat.indexOfRefraction=e}set coatDarkening(e){}set coatDarkeningTexture(e){}set coatRoughnessAnisotropy(e){}get coatRoughnessAnisotropy(){return 0}set geometryCoatTangentAngle(e){}set geometryCoatTangentTexture(e){}get geometryCoatTangentTexture(){return null}set transmissionWeight(e){this._material.subSurface.isRefractionEnabled=e>0,this._material.subSurface.refractionIntensity=e}get transmissionWeight(){return this._material.subSurface.isRefractionEnabled?this._material.subSurface.refractionIntensity:0}set transmissionWeightTexture(e){this._material.subSurface.isRefractionEnabled=!0,this._material.subSurface.refractionIntensityTexture=e,this._material.subSurface.useGltfStyleTextures=!0}set transmissionDepth(e){this.transmissionWeight>0?this._material.subSurface.tintColorAtDistance=e:this.subsurfaceWeight>0&&this._material.subSurface.diffusionDistance.multiplyInPlace(new t.Color3(e,e,e))}get transmissionDepth(){return this.transmissionWeight>0?this._material.subSurface.tintColorAtDistance:0}set transmissionColor(e){this.transmissionWeight>0?this._material.subSurface.tintColor=e:this.subsurfaceWeight>0&&this._material.subSurface.diffusionDistance.multiplyInPlace(e)}get transmissionColor(){return this.transmissionWeight>0?this._material.subSurface.tintColor:this.subsurfaceWeight>0?this._material.subSurface.diffusionDistance:new t.Color3(0,0,0)}set transmissionScatter(e){this._material.subSurface.diffusionDistance=e}get transmissionScatter(){return this._material.subSurface.diffusionDistance}set transmissionScatterTexture(e){}set transmissionScatterAnisotropy(e){}set transmissionDispersionAbbeNumber(e){}set transmissionDispersionScale(e){e>0?(this._material.subSurface.isDispersionEnabled=!0,this._material.subSurface.dispersion=20/e):(this._material.subSurface.isDispersionEnabled=!1,this._material.subSurface.dispersion=0)}get refractionBackgroundTexture(){return this._material.subSurface.refractionTexture}set refractionBackgroundTexture(e){this._material.subSurface.refractionTexture=e}configureTransmission(){this._material.subSurface.volumeIndexOfRefraction=1,this._material.subSurface.useAlbedoToTintRefraction=!0,this._material.subSurface.minimumThickness=0,this._material.subSurface.maximumThickness=0}configureVolume(){}set geometryThinWalled(e){}get geometryThinWalled(){return 0===this._material.subSurface.maximumThickness}set volumeThicknessTexture(e){this._material.subSurface.thicknessTexture=e,this._material.subSurface.useGltfStyleTextures=!0}set volumeThickness(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)}configureSubsurface(){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}set subsurfaceWeight(e){this._material.subSurface.isTranslucencyEnabled=e>0,this._material.subSurface.translucencyIntensity=e}get subsurfaceWeight(){return this._material.subSurface.isTranslucencyEnabled?this._material.subSurface.translucencyIntensity:0}set subsurfaceWeightTexture(e){this._material.subSurface.translucencyIntensityTexture=e}set subsurfaceColor(e){const 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));const r=n,s=Math.max(r.x,Math.max(r.y,r.z)),o=s>0?1/s:1;this._material.subSurface.diffusionDistance=new t.Color3(Math.exp(-r.x*o),Math.exp(-r.y*o),Math.exp(-r.z*o))}set subsurfaceColorTexture(e){}set diffuseTransmissionTint(e){this._material.subSurface.tintColor=e}get diffuseTransmissionTint(){return this._material.subSurface.tintColor}set diffuseTransmissionTintTexture(e){this._material.subSurface.translucencyColorTexture=e}get subsurfaceRadius(){return 1}set subsurfaceRadius(e){}get subsurfaceRadiusScale(){var e;return null!==(e=this._material.subSurface.scatteringDiffusionProfile)&&void 0!==e?e:t.Color3.White()}set subsurfaceRadiusScale(e){this._material.subSurface.scatteringDiffusionProfile=e}set subsurfaceScatterAnisotropy(e){}isTranslucent(){return this.transmissionWeight>0||this.subsurfaceWeight>0}configureFuzz(){this._material.sheen.isEnabled=!0,this._material.sheen.useRoughnessFromMainTexture=!1,this._material.sheen.albedoScaling=!0}set fuzzWeight(e){this._material.sheen.isEnabled=!0,this._material.sheen.intensity=e}set fuzzWeightTexture(e){this._material.sheen.texture||(this._material.sheen.texture=e)}set fuzzColor(e){this._material.sheen.isEnabled=!0,this._material.sheen.color=e}set fuzzColorTexture(e){this._material.sheen.texture=e}set fuzzRoughness(e){this._material.sheen.isEnabled=!0,this._material.sheen.roughness=e}set fuzzRoughnessTexture(e){this._material.sheen.isEnabled=!0,this._material.sheen.textureRoughness=e}set specularRoughnessAnisotropy(e){this._material.anisotropy.isEnabled=!0,this._material.anisotropy.intensity=e}get specularRoughnessAnisotropy(){return this._material.anisotropy.intensity}set geometryTangentAngle(e){this._material.anisotropy.isEnabled=!0,this._material.anisotropy.angle=e}set geometryTangentTexture(e){this._material.anisotropy.isEnabled=!0,this._material.anisotropy.texture=e}get geometryTangentTexture(){return this._material.anisotropy.texture}configureGltfStyleAnisotropy(e=!0){}set thinFilmWeight(e){this._material.iridescence.isEnabled=e>0,this._material.iridescence.intensity=e}set thinFilmIor(e){this._material.iridescence.indexOfRefraction=e}set thinFilmThicknessMinimum(e){this._material.iridescence.minimumThickness=e}set thinFilmThicknessMaximum(e){this._material.iridescence.maximumThickness=e}set thinFilmWeightTexture(e){this._material.iridescence.texture=e}set thinFilmThicknessTexture(e){this._material.iridescence.thicknessTexture=e}set unlit(e){this._material.unlit=e}set geometryOpacity(e){this._material.alpha=e}get geometryOpacity(){return this._material.alpha}set geometryNormalTexture(e){this._material.bumpTexture=e,this._material.forceIrradianceInFragment=!0}get geometryNormalTexture(){return this._material.bumpTexture}setNormalMapInversions(e,t){this._material.invertNormalMapX=e,this._material.invertNormalMapY=t}set geometryCoatNormalTexture(e){this._material.clearCoat.isEnabled=!0,this._material.clearCoat.bumpTexture=e}get geometryCoatNormalTexture(){return this._material.clearCoat.bumpTexture}set geometryCoatNormalTextureScale(e){this._material.clearCoat.bumpTexture&&(this._material.clearCoat.bumpTexture.level=e)}}var Ds={__proto__:null,PBRMaterialLoadingAdapter:Gs},Vs={__proto__:null,AddObjectAccessorToKey:pe,AnimationPropertyInfo:ar,ArrayItem:ve,EXT_lights_area:mt,EXT_lights_ies:qe,EXT_lights_image_based:Ee,EXT_mesh_gpu_instancing:Fe,EXT_meshopt_compression:Pe,EXT_texture_avif:We,EXT_texture_webp:Ve,ExtrasAsMetadata:Ls,FlowGraphGLTFDataProvider:Is,GLTFFileLoader:g,GLTFLoader:Ce,GetMappingForKey:me,GetPathToObjectConverter:de,InteractivityGraphToFlowGraphParser:us,KHR_animation_pointer:er,KHR_draco_mesh_compression:Ze,KHR_gaussian_splatting:ot,KHR_interactivity:hs,KHR_lights:ut,KHR_materials_anisotropy:Bt,KHR_materials_clearcoat:Rt,KHR_materials_coat:Ot,KHR_materials_diffuse_roughness:Nn,KHR_materials_diffuse_transmission:bn,KHR_materials_dispersion:Ln,KHR_materials_emissive_strength:Ht,KHR_materials_fuzz:Yt,KHR_materials_ior:rn,KHR_materials_iridescence:It,KHR_materials_pbrSpecularGlossiness:gt,KHR_materials_sheen:Ut,KHR_materials_specular:Jt,KHR_materials_transmission:_n,KHR_materials_unlit:xt,KHR_materials_variants:ln,KHR_materials_volume:vn,KHR_materials_volume_scatter:Mn,KHR_mesh_quantization:Gn,KHR_node_hoverability:Ms,KHR_node_selectability:Ts,KHR_node_visibility:fs,KHR_texture_basisu:$n,KHR_texture_transform:zn,KHR_xmp_json_ld:Xn,LoadBoundingInfoFromPositionAccessor:Ae,MSFT_audio_emitter:Dr,MSFT_lod:Kr,MSFT_minecraftMesh:jr,MSFT_sRGBFactors:Qr,OpenPBRMaterialLoadingAdapter:Ps,PBRMaterialLoadingAdapter:Gs,RegisterEXT_lights_area:pt,RegisterEXT_lights_ies:Xe,RegisterEXT_lights_image_based:Le,RegisterEXT_mesh_gpu_instancing:Ne,RegisterEXT_meshopt_compression:Ge,RegisterEXT_texture_avif:ze,RegisterEXT_texture_webp:$e,RegisterExtrasAsMetadata:Fs,RegisterGLTF2Loader:Me,RegisterKHR_animation_pointer:nr,RegisterKHR_draco_mesh_compression:et,RegisterKHR_gaussian_splatting:it,RegisterKHR_interactivity:_s,RegisterKHR_lights:ht,RegisterKHR_materials_anisotropy:Dt,RegisterKHR_materials_clearcoat:wt,RegisterKHR_materials_coat:St,RegisterKHR_materials_diffuse_roughness:Pn,RegisterKHR_materials_diffuse_transmission:Tn,RegisterKHR_materials_dispersion:Fn,RegisterKHR_materials_emissive_strength:Kt,RegisterKHR_materials_fuzz:Qt,RegisterKHR_materials_ior:on,RegisterKHR_materials_iridescence:kt,RegisterKHR_materials_pbrSpecularGlossiness:yt,RegisterKHR_materials_sheen:jt,RegisterKHR_materials_specular:tn,RegisterKHR_materials_transmission:fn,RegisterKHR_materials_unlit:At,RegisterKHR_materials_variants:cn,RegisterKHR_materials_volume:Cn,RegisterKHR_materials_volume_scatter:En,RegisterKHR_mesh_quantization:Vn,RegisterKHR_node_hoverability:Es,RegisterKHR_node_selectability:vs,RegisterKHR_node_visibility:bs,RegisterKHR_texture_basisu:Wn,RegisterKHR_texture_transform:qn,RegisterKHR_xmp_json_ld:Zn,RegisterMSFT_audio_emitter:Hr,RegisterMSFT_lod:Ur,RegisterMSFT_minecraftMesh:Yr,RegisterMSFT_sRGBFactors:Jr,SetInterpolationForKey:_e,TransformNodeAnimationPropertyInfo:ir,TransmissionHelper:hn,WeightAnimationPropertyInfo:lr,_AddInteractivityObjectModel:ds,addNewInteractivityFlowGraphMapping:ns,ensureTransmissionHelper:dn,getAllSupportedNativeNodeTypes:is,getMappingForDeclaration:ts,getMappingForFullOperationName:es,getQuaternion:sr,getVector3:rr,getWeights:or,gltfTypeToBabylonType:ls,registerGLTFExtension:be,registeredGLTFExtensions:ge,unregisterGLTFExtension:ye};const Hs=Object.assign({},ks),$s=Object.assign(Object.assign({},{__proto__:null}),{Extensions:Hs}),Ks=Object.assign(Object.assign({},Vs),{Loader:$s}),Ws="undefined"!=typeof global?global:"undefined"!=typeof window?window:void 0;if(void 0!==Ws){Ws.BABYLON=Ws.BABYLON||{};const e=Ws.BABYLON;e.GLTF2=e.GLTF2||{},e.GLTF2.Loader=e.GLTF2.Loader||{},e.GLTF2.Loader.Extensions=e.GLTF2.Loader.Extensions||{};const t=["Loader"];for(const n in Hs)e.GLTF2.Loader.Extensions[n]=Hs[n],t.push(n);for(const n in $s)"Extensions"!==n&&(e.GLTF2.Loader[n]=$s[n],t.push(n));for(const n in Ks)t.indexOf(n)>-1||(e.GLTF2[n]=Ks[n])}e.GLTF1=se,e.GLTF2=Ks,e.GLTFFileLoader=g,e.GLTFLoaderDefaultOptions=p,e.GLTFValidation=s,e.RegisterGLTFFileLoader=y});
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";function n(e,t,n,r){const s={externalResourceFunction:r};return n&&(s.uri="file:"===t?n:t+n),ArrayBuffer.isView(e)?GLTFValidator.validateBytes(e,s):GLTFValidator.validateString(e,s)}function r(){const e=[];onmessage=t=>{const r=t.data;switch(r.id){case"init":importScripts(r.url);break;case"validate":n(r.data,r.rootUrl,r.fileName,t=>new Promise((n,r)=>{const s=e.length;e.push({resolve:n,reject:r}),postMessage({id:"getExternalResource",index:s,uri:t})})).then(e=>{postMessage({id:"validate.resolve",value:e})},e=>{postMessage({id:"validate.reject",reason:e})});break;case"getExternalResource.resolve":e[r.index].resolve(r.value);break;case"getExternalResource.reject":e[r.index].reject(r.reason)}}}class s{static ValidateAsync(e,o,a,i){return"function"==typeof Worker?new Promise((l,u)=>{const c=`${n}(${r})()`,h=URL.createObjectURL(new Blob([c],{type:"application/javascript"})),d=new Worker(h),m=e=>{d.removeEventListener("error",m),d.removeEventListener("message",_),u(e)},_=e=>{const t=e.data;switch(t.id){case"getExternalResource":i(t.uri).then(e=>{d.postMessage({id:"getExternalResource.resolve",index:t.index,value:e},[e.buffer])},e=>{d.postMessage({id:"getExternalResource.reject",index:t.index,reason:e})});break;case"validate.resolve":d.removeEventListener("error",m),d.removeEventListener("message",_),s._LastResults=t.value,l(t.value),d.terminate();break;case"validate.reject":d.removeEventListener("error",m),d.removeEventListener("message",_),u(t.reason),d.terminate()}};if(d.addEventListener("error",m),d.addEventListener("message",_),d.postMessage({id:"init",url:t.Tools.GetBabylonScriptURL(this.Configuration.url)}),ArrayBuffer.isView(e)){const t=e.slice();d.postMessage({id:"validate",data:t,rootUrl:o,fileName:a},[t.buffer])}else d.postMessage({id:"validate",data:e,rootUrl:o,fileName:a})}):(this._LoadScriptPromise||(this._LoadScriptPromise=t.Tools.LoadBabylonScriptAsync(this.Configuration.url)),this._LoadScriptPromise.then(()=>n(e,o,a,i)))}}s.Configuration={url:`${t.Tools._DefaultCdnUrl}/gltf_validator.js`},s._LastResults=null;var o={__proto__:null,GLTFValidation:s};const a="Z2xURg",i="gltf",l={".gltf":{isBinary:!1,mimeType:"model/gltf+json"},".glb":{isBinary:!0,mimeType:"model/gltf-binary"}},u=e=>-1!==e.indexOf("asset")&&-1!==e.indexOf("version")||e.startsWith("data:base64,"+a)||e.startsWith("data:;base64,"+a)||e.startsWith("data:application/octet-stream;base64,"+a)||e.startsWith("data:model/gltf-binary;base64,"+a);function c(e,t,n){try{return Promise.resolve(new Uint8Array(e,t,n))}catch(e){return Promise.reject(e)}}var h,d,m;e.GLTFLoaderCoordinateSystemMode=void 0,(h=e.GLTFLoaderCoordinateSystemMode||(e.GLTFLoaderCoordinateSystemMode={}))[h.AUTO=0]="AUTO",h[h.FORCE_RIGHT_HANDED=1]="FORCE_RIGHT_HANDED",e.GLTFLoaderAnimationStartMode=void 0,(d=e.GLTFLoaderAnimationStartMode||(e.GLTFLoaderAnimationStartMode={}))[d.NONE=0]="NONE",d[d.FIRST=1]="FIRST",d[d.ALL=2]="ALL",e.GLTFLoaderState=void 0,(m=e.GLTFLoaderState||(e.GLTFLoaderState={}))[m.LOADING=0]="LOADING",m[m.READY=1]="READY",m[m.COMPLETE=2]="COMPLETE";class _{constructor(){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.useMaxMorphTargetInfluencers=!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}}const p=new _;class f extends _{constructor(){super(...arguments),this.extensionOptions={},this.preprocessUrlAsync=e=>Promise.resolve(e)}copyFrom(e){var t,n,r,s,o,a,i,l,u,c,h,d,m,_,p,f,g,b,y,T,x,v,A,C,R,M,w;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!==(s=e.capturePerformanceCounters)&&void 0!==s?s:this.capturePerformanceCounters,this.compileMaterials=null!==(o=e.compileMaterials)&&void 0!==o?o:this.compileMaterials,this.compileShadowGenerators=null!==(a=e.compileShadowGenerators)&&void 0!==a?a:this.compileShadowGenerators,this.coordinateSystemMode=null!==(i=e.coordinateSystemMode)&&void 0!==i?i: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!==(h=e.loadMorphTargets)&&void 0!==h?h:this.loadMorphTargets,this.loadNodeAnimations=null!==(d=e.loadNodeAnimations)&&void 0!==d?d:this.loadNodeAnimations,this.loadOnlyMaterials=null!==(m=e.loadOnlyMaterials)&&void 0!==m?m:this.loadOnlyMaterials,this.loadSkins=null!==(_=e.loadSkins)&&void 0!==_?_:this.loadSkins,this.loggingEnabled=null!==(p=e.loggingEnabled)&&void 0!==p?p: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!==(f=e.preprocessUrlAsync)&&void 0!==f?f:this.preprocessUrlAsync,this.skipMaterials=null!==(g=e.skipMaterials)&&void 0!==g?g:this.skipMaterials,this.targetFps=null!==(b=e.targetFps)&&void 0!==b?b:this.targetFps,this.transparencyAsCoverage=null!==(y=e.transparencyAsCoverage)&&void 0!==y?y:this.transparencyAsCoverage,this.useClipPlane=null!==(T=e.useClipPlane)&&void 0!==T?T:this.useClipPlane,this.useGltfTextureNames=null!==(x=e.useGltfTextureNames)&&void 0!==x?x:this.useGltfTextureNames,this.useMaxMorphTargetInfluencers=null!==(v=e.useMaxMorphTargetInfluencers)&&void 0!==v?v:this.useMaxMorphTargetInfluencers,this.useOpenPBR=null!==(A=e.useOpenPBR)&&void 0!==A?A:this.useOpenPBR,this.useRangeRequests=null!==(C=e.useRangeRequests)&&void 0!==C?C:this.useRangeRequests,this.useSRGBBuffers=null!==(R=e.useSRGBBuffers)&&void 0!==R?R:this.useSRGBBuffers,this.validate=null!==(M=e.validate)&&void 0!==M?M:this.validate,this.dontUseTransmissionHelper=null!==(w=e.dontUseTransmissionHelper)&&void 0!==w?w:this.dontUseTransmissionHelper)}}class g extends f{constructor(e){super(),this.onParsedObservable=new t.Observable,this.onMeshLoadedObservable=new t.Observable,this.onSkinLoadedObservable=new t.Observable,this.onTextureLoadedObservable=new t.Observable,this.onMaterialLoadedObservable=new t.Observable,this.onCameraLoadedObservable=new t.Observable,this.onCompleteObservable=new t.Observable,this.onErrorObservable=new t.Observable,this.onDisposeObservable=new t.Observable,this.onExtensionLoadedObservable=new t.Observable,this.onValidatedObservable=new t.Observable,this._loader=null,this._state=null,this._requests=new Array,this.name=i,this.extensions=l,this.onLoaderStateChangedObservable=new t.Observable,this._logIndentLevel=0,this._loggingEnabled=!1,this._log=this._logDisabled,this._capturePerformanceCounters=!1,this._startPerformanceCounter=this._startPerformanceCounterDisabled,this._endPerformanceCounter=this._endPerformanceCounterDisabled,this.copyFrom(Object.assign(Object.assign({},p),e))}set onParsed(e){this._onParsedObserver&&this.onParsedObservable.remove(this._onParsedObserver),e&&(this._onParsedObserver=this.onParsedObservable.add(e))}set onMeshLoaded(e){this._onMeshLoadedObserver&&this.onMeshLoadedObservable.remove(this._onMeshLoadedObserver),e&&(this._onMeshLoadedObserver=this.onMeshLoadedObservable.add(e))}set onSkinLoaded(e){this._onSkinLoadedObserver&&this.onSkinLoadedObservable.remove(this._onSkinLoadedObserver),e&&(this._onSkinLoadedObserver=this.onSkinLoadedObservable.add(t=>e(t.node,t.skinnedNode)))}set onTextureLoaded(e){this._onTextureLoadedObserver&&this.onTextureLoadedObservable.remove(this._onTextureLoadedObserver),e&&(this._onTextureLoadedObserver=this.onTextureLoadedObservable.add(e))}set onMaterialLoaded(e){this._onMaterialLoadedObserver&&this.onMaterialLoadedObservable.remove(this._onMaterialLoadedObserver),e&&(this._onMaterialLoadedObserver=this.onMaterialLoadedObservable.add(e))}set onCameraLoaded(e){this._onCameraLoadedObserver&&this.onCameraLoadedObservable.remove(this._onCameraLoadedObserver),e&&(this._onCameraLoadedObserver=this.onCameraLoadedObservable.add(e))}set onComplete(e){this._onCompleteObserver&&this.onCompleteObservable.remove(this._onCompleteObserver),this._onCompleteObserver=this.onCompleteObservable.add(e)}set onError(e){this._onErrorObserver&&this.onErrorObservable.remove(this._onErrorObserver),this._onErrorObserver=this.onErrorObservable.add(e)}set onDispose(e){this._onDisposeObserver&&this.onDisposeObservable.remove(this._onDisposeObserver),this._onDisposeObserver=this.onDisposeObservable.add(e)}set onExtensionLoaded(e){this._onExtensionLoadedObserver&&this.onExtensionLoadedObservable.remove(this._onExtensionLoadedObserver),this._onExtensionLoadedObserver=this.onExtensionLoadedObservable.add(e)}get loggingEnabled(){return this._loggingEnabled}set loggingEnabled(e){this._loggingEnabled!==e&&(this._loggingEnabled=e,this._loggingEnabled?this._log=this._logEnabled:this._log=this._logDisabled)}get capturePerformanceCounters(){return this._capturePerformanceCounters}set capturePerformanceCounters(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))}set onValidated(e){this._onValidatedObserver&&this.onValidatedObservable.remove(this._onValidatedObserver),this._onValidatedObserver=this.onValidatedObservable.add(e)}dispose(){this._loader&&(this._loader.dispose(),this._loader=null);for(const e of this._requests)e.abort();this._requests.length=0,delete this._progressCallback,this.preprocessUrlAsync=e=>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()}loadFile(e,n,r,s,o,a,i,l){if(ArrayBuffer.isView(n))return this._loadBinary(e,n,r,s,i,l),null;this._progressCallback=o;const u=n.name||t.Tools.GetFilename(n);if(a){if(this.useRangeRequests){this.validate&&t.Logger.Warn("glTF validation is not supported when range requests are enabled");const r={abort:()=>{},onCompleteObservable:new t.Observable},o={readAsync:(t,r)=>new Promise((s,o)=>{this._loadFile(e,n,e=>{s(new Uint8Array(e))},!0,e=>{o(e)},e=>{e.setRequestHeader("Range",`bytes=${t}-${t+r-1}`)})}),byteLength:0};return this._unpackBinaryAsync(new t.DataReader(o)).then(e=>{r.onCompleteObservable.notifyObservers(r),s(e)},i?e=>i(void 0,e):void 0),r}return this._loadFile(e,n,n=>{this._validate(e,new Uint8Array(n,0,n.byteLength),r,u),this._unpackBinaryAsync(new t.DataReader({readAsync:(e,t)=>c(n,e,t),byteLength:n.byteLength})).then(e=>{s(e)},i?e=>i(void 0,e):void 0)},!0,i)}return this._loadFile(e,n,t=>{try{this._validate(e,t,r,u),s({json:this._parseJson(t)})}catch(e){i&&i()}},!1,i)}_loadBinary(e,n,r,s,o,a){this._validate(e,new Uint8Array(n.buffer,n.byteOffset,n.byteLength),r,a),this._unpackBinaryAsync(new t.DataReader({readAsync:(e,t)=>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(e=>{s(e)},o?e=>o(void 0,e):void 0)}importMeshAsync(e,t,n,r,s,o){return Promise.resolve().then(()=>(this.onParsedObservable.notifyObservers(n),this.onParsedObservable.clear(),this._log(`Loading ${o||""}`),this._loader=this._getLoader(n),this._loader.importMeshAsync(e,t,null,n,r,s,o)))}loadAsync(e,t,n,r,s){return Promise.resolve().then(()=>(this.onParsedObservable.notifyObservers(t),this.onParsedObservable.clear(),this._log(`Loading ${s||""}`),this._loader=this._getLoader(t),this._loader.loadAsync(e,t,n,r,s)))}loadAssetContainerAsync(e,n,r,s,o){return Promise.resolve().then(()=>{this.onParsedObservable.notifyObservers(n),this.onParsedObservable.clear(),this._log(`Loading ${o||""}`),this._loader=this._getLoader(n);const a=new t.AssetContainer(e),i=[];this.onMaterialLoadedObservable.add(e=>{i.push(e)});const l=[];this.onTextureLoadedObservable.add(e=>{l.push(e)});const u=[];this.onCameraLoadedObservable.add(e=>{u.push(e)});const c=[];return this.onMeshLoadedObservable.add(e=>{e.morphTargetManager&&c.push(e.morphTargetManager)}),this._loader.importMeshAsync(null,e,a,n,r,s,o).then(e=>(Array.prototype.push.apply(a.geometries,e.geometries),Array.prototype.push.apply(a.meshes,e.meshes),Array.prototype.push.apply(a.particleSystems,e.particleSystems),Array.prototype.push.apply(a.skeletons,e.skeletons),Array.prototype.push.apply(a.animationGroups,e.animationGroups),Array.prototype.push.apply(a.materials,i),Array.prototype.push.apply(a.textures,l),Array.prototype.push.apply(a.lights,e.lights),Array.prototype.push.apply(a.transformNodes,e.transformNodes),Array.prototype.push.apply(a.cameras,u),Array.prototype.push.apply(a.morphTargetManagers,c),a))})}canDirectLoad(e){return u(e)}directLoad(e,n){if(n.startsWith("base64,"+a)||n.startsWith(";base64,"+a)||n.startsWith("application/octet-stream;base64,"+a)||n.startsWith("model/gltf-binary;base64,"+a)){const r=t.DecodeBase64UrlToBinary(n);return this._validate(e,new Uint8Array(r,0,r.byteLength)),this._unpackBinaryAsync(new t.DataReader({readAsync:(e,t)=>c(r,e,t),byteLength:r.byteLength}))}return this._validate(e,n),Promise.resolve({json:this._parseJson(n)})}createPlugin(e){return new g(e[i])}get loaderState(){return this._state}whenCompleteAsync(){return new Promise((e,t)=>{this.onCompleteObservable.addOnce(()=>{e()}),this.onErrorObservable.addOnce(e=>{t(e)})})}_setState(t){this._state!==t&&(this._state=t,this.onLoaderStateChangedObservable.notifyObservers(this._state),this._log(e.GLTFLoaderState[this._state]))}_loadFile(e,t,n,r,s,o){const a=e._loadFile(t,n,e=>{this._onProgress(e,a)},!0,r,s,o);return a.onCompleteObservable.add(()=>{a._lengthComputable=!0,a._total=a._loaded}),this._requests.push(a),a}_onProgress(e,t){if(!this._progressCallback)return;t._lengthComputable=e.lengthComputable,t._loaded=e.loaded,t._total=e.total;let n=!0,r=0,s=0;for(const e of this._requests){if(void 0===e._lengthComputable||void 0===e._loaded||void 0===e._total)return;n=n&&e._lengthComputable,r+=e._loaded,s+=e._total}this._progressCallback({lengthComputable:n,loaded:r,total:n?s:0})}_validate(e,n,r="",o=""){this.validate&&(this._startPerformanceCounter("Validate JSON"),s.ValidateAsync(n,r,o,t=>this.preprocessUrlAsync(r+t).then(t=>e._loadFileAsync(t,void 0,!0,!0).then(e=>new Uint8Array(e,0,e.byteLength)))).then(e=>{this._endPerformanceCounter("Validate JSON"),this.onValidatedObservable.notifyObservers(e),this.onValidatedObservable.clear()},e=>{this._endPerformanceCounter("Validate JSON"),t.Tools.Warn(`Failed to validate: ${e.message}`),this.onValidatedObservable.clear()}))}_getLoader(e){const t=e.json.asset||{};this._log(`Asset version: ${t.version}`),t.minVersion&&this._log(`Asset minimum version: ${t.minVersion}`),t.generator&&this._log(`Asset generator: ${t.generator}`);const n=g._parseVersion(t.version);if(!n)throw new Error("Invalid version: "+t.version);if(void 0!==t.minVersion){const e=g._parseVersion(t.minVersion);if(!e)throw new Error("Invalid minimum version: "+t.minVersion);if(g._compareVersion(e,{major:2,minor:0})>0)throw new Error("Incompatible minimum version: "+t.minVersion)}const r={1:g._CreateGLTF1Loader,2:g._CreateGLTF2Loader}[n.major];if(!r)throw new Error("Unsupported version: "+t.version);return r(this)}_parseJson(e){this._startPerformanceCounter("Parse JSON"),this._log(`JSON length: ${e.length}`);const t=JSON.parse(e);return this._endPerformanceCounter("Parse JSON"),t}_unpackBinaryAsync(e){return this._startPerformanceCounter("Unpack Binary"),e.loadAsync(20).then(()=>{const n=e.readUint32();if(1179937895!==n)throw new t.RuntimeError("Unexpected magic: "+n,t.ErrorCodes.GLTFLoaderUnexpectedMagicError);const r=e.readUint32();this.loggingEnabled&&this._log(`Binary version: ${r}`);const s=e.readUint32();let o;switch(this.useRangeRequests||s===e.buffer.byteLength||t.Logger.Warn(`Length in header does not match actual data length: ${s} != ${e.buffer.byteLength}`),r){case 1:o=this._unpackBinaryV1Async(e,s);break;case 2:o=this._unpackBinaryV2Async(e,s);break;default:throw new Error("Unsupported version: "+r)}return this._endPerformanceCounter("Unpack Binary"),o})}_unpackBinaryV1Async(e,t){const n=e.readUint32(),r=e.readUint32();if(0!==r)throw new Error(`Unexpected content format: ${r}`);const s=t-e.byteOffset,o={json:this._parseJson(e.readString(n)),bin:null};if(0!==s){const t=e.byteOffset;o.bin={readAsync:(n,r)=>e.buffer.readAsync(t+n,r),byteLength:s}}return Promise.resolve(o)}_unpackBinaryV2Async(e,t){const n=1313821514,r=e.readUint32();if(e.readUint32()!==n)throw new Error("First chunk format is not JSON");return e.byteOffset+r===t?e.loadAsync(r).then(()=>({json:this._parseJson(e.readString(r)),bin:null})):e.loadAsync(r+8).then(()=>{const s={json:this._parseJson(e.readString(r)),bin:null},o=()=>{const r=e.readUint32();switch(e.readUint32()){case n:throw new Error("Unexpected JSON chunk");case 5130562:{const t=e.byteOffset;s.bin={readAsync:(n,r)=>e.buffer.readAsync(t+n,r),byteLength:r},e.skipBytes(r);break}default:e.skipBytes(r)}return e.byteOffset!==t?e.loadAsync(8).then(o):Promise.resolve(s)};return o()})}static _parseVersion(e){if("1.0"===e||"1.0.1"===e)return{major:1,minor:0};const t=(e+"").match(/^(\d+)\.(\d+)/);return t?{major:parseInt(t[1]),minor:parseInt(t[2])}:null}static _compareVersion(e,t){return e.major>t.major?1:e.major<t.major?-1:e.minor>t.minor?1:e.minor<t.minor?-1:0}_logOpen(e){this._log(e),this._logIndentLevel++}_logClose(){--this._logIndentLevel}_logEnabled(e){const n=g._logSpaces.substring(0,2*this._logIndentLevel);t.Logger.Log(`${n}${e}`)}_logDisabled(e){}_startPerformanceCounterEnabled(e){t.Tools.StartPerformanceCounter(e)}_startPerformanceCounterDisabled(e){}_endPerformanceCounterEnabled(e){t.Tools.EndPerformanceCounter(e)}_endPerformanceCounterDisabled(e){}}g.IncrementalLoading=!0,g.HomogeneousCoordinates=!1,g._logSpaces=" ";let b=!1;function y(){b||(b=!0,t.RegisterSceneLoaderPlugin(new g))}y();var T={__proto__:null,GLTFFileLoader:g,get GLTFLoaderAnimationStartMode(){return e.GLTFLoaderAnimationStartMode},get GLTFLoaderCoordinateSystemMode(){return e.GLTFLoaderCoordinateSystemMode},GLTFLoaderDefaultOptions:p,get GLTFLoaderState(){return e.GLTFLoaderState},RegisterGLTFFileLoader:y};const x="undefined"!=typeof global?global:"undefined"!=typeof window?window:void 0;if(void 0!==x){x.BABYLON=x.BABYLON||{};for(const e in T)x.BABYLON[e]=T[e];for(const e in o)x.BABYLON[e]=o[e]}function v(e,t,n,r){return new(n||(n=Promise))(function(s,o){function a(e){try{l(r.next(e))}catch(e){o(e)}}function i(e){try{l(r.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?s(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,i)}l((r=r.apply(e,t||[])).next())})}var A,C,R,M,w,E,O,L,S;Object.create,Object.create,"function"==typeof SuppressedError&&SuppressedError,function(e){e[e.BYTE=5120]="BYTE",e[e.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",e[e.SHORT=5122]="SHORT",e[e.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",e[e.FLOAT=5126]="FLOAT"}(A||(A={})),function(e){e[e.FRAGMENT=35632]="FRAGMENT",e[e.VERTEX=35633]="VERTEX"}(C||(C={})),function(e){e[e.BYTE=5120]="BYTE",e[e.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",e[e.SHORT=5122]="SHORT",e[e.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",e[e.INT=5124]="INT",e[e.UNSIGNED_INT=5125]="UNSIGNED_INT",e[e.FLOAT=5126]="FLOAT",e[e.FLOAT_VEC2=35664]="FLOAT_VEC2",e[e.FLOAT_VEC3=35665]="FLOAT_VEC3",e[e.FLOAT_VEC4=35666]="FLOAT_VEC4",e[e.INT_VEC2=35667]="INT_VEC2",e[e.INT_VEC3=35668]="INT_VEC3",e[e.INT_VEC4=35669]="INT_VEC4",e[e.BOOL=35670]="BOOL",e[e.BOOL_VEC2=35671]="BOOL_VEC2",e[e.BOOL_VEC3=35672]="BOOL_VEC3",e[e.BOOL_VEC4=35673]="BOOL_VEC4",e[e.FLOAT_MAT2=35674]="FLOAT_MAT2",e[e.FLOAT_MAT3=35675]="FLOAT_MAT3",e[e.FLOAT_MAT4=35676]="FLOAT_MAT4",e[e.SAMPLER_2D=35678]="SAMPLER_2D"}(R||(R={})),function(e){e[e.CLAMP_TO_EDGE=33071]="CLAMP_TO_EDGE",e[e.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",e[e.REPEAT=10497]="REPEAT"}(M||(M={})),function(e){e[e.NEAREST=9728]="NEAREST",e[e.LINEAR=9728]="LINEAR",e[e.NEAREST_MIPMAP_NEAREST=9984]="NEAREST_MIPMAP_NEAREST",e[e.LINEAR_MIPMAP_NEAREST=9985]="LINEAR_MIPMAP_NEAREST",e[e.NEAREST_MIPMAP_LINEAR=9986]="NEAREST_MIPMAP_LINEAR",e[e.LINEAR_MIPMAP_LINEAR=9987]="LINEAR_MIPMAP_LINEAR"}(w||(w={})),function(e){e[e.ALPHA=6406]="ALPHA",e[e.RGB=6407]="RGB",e[e.RGBA=6408]="RGBA",e[e.LUMINANCE=6409]="LUMINANCE",e[e.LUMINANCE_ALPHA=6410]="LUMINANCE_ALPHA"}(E||(E={})),function(e){e[e.FRONT=1028]="FRONT",e[e.BACK=1029]="BACK",e[e.FRONT_AND_BACK=1032]="FRONT_AND_BACK"}(O||(O={})),function(e){e[e.ZERO=0]="ZERO",e[e.ONE=1]="ONE",e[e.SRC_COLOR=768]="SRC_COLOR",e[e.ONE_MINUS_SRC_COLOR=769]="ONE_MINUS_SRC_COLOR",e[e.DST_COLOR=774]="DST_COLOR",e[e.ONE_MINUS_DST_COLOR=775]="ONE_MINUS_DST_COLOR",e[e.SRC_ALPHA=770]="SRC_ALPHA",e[e.ONE_MINUS_SRC_ALPHA=771]="ONE_MINUS_SRC_ALPHA",e[e.DST_ALPHA=772]="DST_ALPHA",e[e.ONE_MINUS_DST_ALPHA=773]="ONE_MINUS_DST_ALPHA",e[e.CONSTANT_COLOR=32769]="CONSTANT_COLOR",e[e.ONE_MINUS_CONSTANT_COLOR=32770]="ONE_MINUS_CONSTANT_COLOR",e[e.CONSTANT_ALPHA=32771]="CONSTANT_ALPHA",e[e.ONE_MINUS_CONSTANT_ALPHA=32772]="ONE_MINUS_CONSTANT_ALPHA",e[e.SRC_ALPHA_SATURATE=776]="SRC_ALPHA_SATURATE"}(L||(L={}));class F{static SetMatrix(e,n,r,s,o){let a=null;if("MODEL"===r.semantic?a=n.getWorldMatrix():"PROJECTION"===r.semantic?a=e.getProjectionMatrix():"VIEW"===r.semantic?a=e.getViewMatrix():"MODELVIEWINVERSETRANSPOSE"===r.semantic?a=t.Matrix.Transpose(n.getWorldMatrix().multiply(e.getViewMatrix()).invert()):"MODELVIEW"===r.semantic?a=n.getWorldMatrix().multiply(e.getViewMatrix()):"MODELVIEWPROJECTION"===r.semantic?a=n.getWorldMatrix().multiply(e.getTransformMatrix()):"MODELINVERSE"===r.semantic?a=n.getWorldMatrix().invert():"VIEWINVERSE"===r.semantic?a=e.getViewMatrix().invert():"PROJECTIONINVERSE"===r.semantic?a=e.getProjectionMatrix().invert():"MODELVIEWINVERSE"===r.semantic?a=n.getWorldMatrix().multiply(e.getViewMatrix()).invert():"MODELVIEWPROJECTIONINVERSE"===r.semantic?a=n.getWorldMatrix().multiply(e.getTransformMatrix()).invert():"MODELINVERSETRANSPOSE"===r.semantic&&(a=t.Matrix.Transpose(n.getWorldMatrix().invert())),a)switch(r.type){case R.FLOAT_MAT2:o.setMatrix2x2(s,t.Matrix.GetAsMatrix2x2(a));break;case R.FLOAT_MAT3:o.setMatrix3x3(s,t.Matrix.GetAsMatrix3x3(a));break;case R.FLOAT_MAT4:o.setMatrix(s,a)}}static SetUniform(e,n,r,s){switch(s){case R.FLOAT:return e.setFloat(n,r),!0;case R.FLOAT_VEC2:return e.setVector2(n,t.Vector2.FromArray(r)),!0;case R.FLOAT_VEC3:return e.setVector3(n,t.Vector3.FromArray(r)),!0;case R.FLOAT_VEC4:return e.setVector4(n,t.Vector4.FromArray(r)),!0;default:return!1}}static GetWrapMode(e){switch(e){case M.CLAMP_TO_EDGE:return t.Texture.CLAMP_ADDRESSMODE;case M.MIRRORED_REPEAT:return t.Texture.MIRROR_ADDRESSMODE;case M.REPEAT:default:return t.Texture.WRAP_ADDRESSMODE}}static GetByteStrideFromType(e){switch(e.type){case"VEC2":return 2;case"VEC3":return 3;case"VEC4":case"MAT2":return 4;case"MAT3":return 9;case"MAT4":return 16;default:return 1}}static GetTextureFilterMode(e){switch(e){case w.LINEAR:case w.LINEAR_MIPMAP_NEAREST:case w.LINEAR_MIPMAP_LINEAR:return t.Texture.TRILINEAR_SAMPLINGMODE;case w.NEAREST:case w.NEAREST_MIPMAP_NEAREST:return t.Texture.NEAREST_SAMPLINGMODE;default:return t.Texture.BILINEAR_SAMPLINGMODE}}static GetBufferFromBufferView(e,t,n,r,s){n=t.byteOffset+n;const o=e.loadedBufferViews[t.buffer];if(n+r>o.byteLength)throw new Error("Buffer access is out of range");const a=o.buffer;switch(n+=o.byteOffset,s){case A.BYTE:return new Int8Array(a,n,r);case A.UNSIGNED_BYTE:return new Uint8Array(a,n,r);case A.SHORT:return new Int16Array(a,n,r);case A.UNSIGNED_SHORT:return new Uint16Array(a,n,r);default:return new Float32Array(a,n,r)}}static GetBufferFromAccessor(e,t){const n=e.bufferViews[t.bufferView],r=t.count*F.GetByteStrideFromType(t);return F.GetBufferFromBufferView(e,n,t.byteOffset,r,t.componentType)}static DecodeBufferToText(e){let t="";const n=e.byteLength;for(let r=0;r<n;++r)t+=String.fromCharCode(e[r]);return t}static GetDefaultMaterial(e){if(!F._DefaultMaterial){t.Effect.ShadersStore.GLTFDefaultMaterialVertexShader=["precision highp float;","","uniform mat4 worldView;","uniform mat4 projection;","","attribute vec3 position;","","void main(void)","{"," gl_Position = projection * worldView * vec4(position, 1.0);","}"].join("\n"),t.Effect.ShadersStore.GLTFDefaultMaterialPixelShader=["precision highp float;","","uniform vec4 u_emission;","","void main(void)","{"," gl_FragColor = u_emission;","}"].join("\n");const n={vertex:"GLTFDefaultMaterial",fragment:"GLTFDefaultMaterial"},r={attributes:["position"],uniforms:["worldView","projection","u_emission"],samplers:new Array,needAlphaBlending:!1};F._DefaultMaterial=new t.ShaderMaterial("GLTFDefaultMaterial",e,n,r),F._DefaultMaterial.setColor4("u_emission",new t.Color4(.5,.5,.5,1))}return F._DefaultMaterial}}F._DefaultMaterial=null,function(e){e[e.IDENTIFIER=1]="IDENTIFIER",e[e.UNKNOWN=2]="UNKNOWN",e[e.END_OF_INPUT=3]="END_OF_INPUT"}(S||(S={}));class I{constructor(e){this._pos=0,this.currentToken=S.UNKNOWN,this.currentIdentifier="",this.currentString="",this.isLetterOrDigitPattern=/^[a-zA-Z0-9]+$/,this._toParse=e,this._maxPos=e.length}getNextToken(){if(this.isEnd())return S.END_OF_INPUT;if(this.currentString=this.read(),this.currentToken=S.UNKNOWN,"_"===this.currentString||this.isLetterOrDigitPattern.test(this.currentString))for(this.currentToken=S.IDENTIFIER,this.currentIdentifier=this.currentString;!this.isEnd()&&(this.isLetterOrDigitPattern.test(this.currentString=this.peek())||"_"===this.currentString);)this.currentIdentifier+=this.currentString,this.forward();return this.currentToken}peek(){return this._toParse[this._pos]}read(){return this._toParse[this._pos++]}forward(){this._pos++}isEnd(){return this._pos>=this._maxPos}}const N=["MODEL","VIEW","PROJECTION","MODELVIEW","MODELVIEWPROJECTION","JOINTMATRIX"],k=["world","view","projection","worldView","worldViewProjection","mBones"],P=["translation","rotation","scale"],B=["position","rotationQuaternion","scaling"],G=(e,t,n)=>{for(const r in e){const s=e[r];n[t][r]=s}},D=e=>{if(e)for(let t=0;t<e.length/2;t++)e[2*t+1]=1-e[2*t+1]},V=e=>{if("NORMAL"===e.semantic)return"normal";if("POSITION"===e.semantic)return"position";if("JOINT"===e.semantic)return"matricesIndices";if("WEIGHT"===e.semantic)return"matricesWeights";if("COLOR"===e.semantic)return"color";if(e.semantic&&-1!==e.semantic.indexOf("TEXCOORD_")){const t=Number(e.semantic.split("_")[1]);return"uv"+(0===t?"":t+1)}return null},H=e=>{let n;if(e.translation||e.rotation||e.scale){const r=t.Vector3.FromArray(e.scale||[1,1,1]),s=t.Quaternion.FromArray(e.rotation||[0,0,0,1]),o=t.Vector3.FromArray(e.translation||[0,0,0]);n=t.Matrix.Compose(r,s,o)}else n=t.Matrix.FromArray(e.matrix);return n},$=(e,n,r,s)=>{for(let e=0;e<s.bones.length;e++)if(s.bones[e].name===r)return s.bones[e];const o=e.nodes;for(const a in o){const i=o[a];if(!i.jointName)continue;const l=i.children;for(let o=0;o<l.length;o++){const u=e.nodes[l[o]];if(u.jointName&&u.jointName===r){const r=H(i),o=new t.Bone(i.name||"",s,$(e,n,i.jointName,s),r);return o.id=a,o}}}return null},K=(e,t)=>{for(let n=0;n<e.length;n++){const r=e[n];for(let e=0;e<r.node.children.length;e++)if(r.node.children[e]===t)return r.bone}return null},W=(e,t)=>{const n=e.nodes;let r=n[t];if(r)return{node:r,id:t};for(const e in n)if(r=n[e],r.jointName===t)return{node:r,id:e};return null},U=(e,t)=>{for(let n=0;n<e.jointNames.length;n++)if(e.jointNames[n]===t)return!0;return!1},z=(e,n,r,s,o)=>{if(o||(e.scene._blockEntityCollection=!!e.assetContainer,(o=new t.Mesh(n.name||"",e.scene))._parentContainer=e.assetContainer,e.scene._blockEntityCollection=!1,o.id=s),!n.babylonNode)return o;const a=[];let i=null;const l=[],u=[],c=[],h=[];for(let n=0;n<r.length;n++){const s=r[n],o=e.meshes[s];if(o)for(let n=0;n<o.primitives.length;n++){const r=new t.VertexData,s=o.primitives[n];s.mode;const d=s.attributes;let m,_;for(const n in d)if(m=e.accessors[d[n]],_=F.GetBufferFromAccessor(e,m),"NORMAL"===n)r.normals=new Float32Array(_.length),r.normals.set(_);else if("POSITION"===n){if(g.HomogeneousCoordinates){r.positions=new Float32Array(_.length-_.length/4);for(let e=0;e<_.length;e+=4)r.positions[e]=_[e],r.positions[e+1]=_[e+1],r.positions[e+2]=_[e+2]}else r.positions=new Float32Array(_.length),r.positions.set(_);u.push(r.positions.length)}else if(-1!==n.indexOf("TEXCOORD_")){const e=Number(n.split("_")[1]),s=t.VertexBuffer.UVKind+(0===e?"":e+1),o=new Float32Array(_.length);o.set(_),D(o),r.set(o,s)}else"JOINT"===n?(r.matricesIndices=new Float32Array(_.length),r.matricesIndices.set(_)):"WEIGHT"===n?(r.matricesWeights=new Float32Array(_.length),r.matricesWeights.set(_)):"COLOR"===n&&(r.colors=new Float32Array(_.length),r.colors.set(_));if(m=e.accessors[s.indices],m)_=F.GetBufferFromAccessor(e,m),r.indices=new Int32Array(_.length),r.indices.set(_),h.push(r.indices.length);else{const e=[];for(let t=0;t<r.positions.length/3;t++)e.push(t);r.indices=new Int32Array(e),h.push(r.indices.length)}i?i.merge(r):i=r;const p=e.scene.getMaterialById(s.material);a.push(null===p?F.GetDefaultMaterial(e.scene):p),l.push(0===l.length?0:l[l.length-1]+u[u.length-2]),c.push(0===c.length?0:c[c.length-1]+h[h.length-2])}}let d;e.scene._blockEntityCollection=!!e.assetContainer,a.length>1?(d=new t.MultiMaterial("multimat"+s,e.scene),d.subMaterials=a):d=new t.StandardMaterial("multimat"+s,e.scene),1===a.length&&(d=a[0]),d._parentContainer=e.assetContainer,o.material||(o.material=d),new t.Geometry(s,e.scene,i,!1,o),o.computeWorldMatrix(!0),e.scene._blockEntityCollection=!1,o.subMeshes=[];let m=0;for(let n=0;n<r.length;n++){const s=r[n],a=e.meshes[s];if(a)for(let e=0;e<a.primitives.length;e++)a.primitives[e].mode,t.SubMesh.AddToMesh(m,l[m],u[m],c[m],h[m],o,o,!0),m++}return o},j=(e,t,n,r)=>{e.position&&(e.position=t),(e.rotationQuaternion||e.rotation)&&(e.rotationQuaternion=n),e.scaling&&(e.scaling=r)},q=(e,n,r)=>{let s=null;if(e.importOnlyMeshes&&(n.skin||n.meshes)&&e.importMeshesNames&&e.importMeshesNames.length>0&&-1===e.importMeshesNames.indexOf(n.name||""))return null;if(n.skin){if(n.meshes){const o=e.skins[n.skin],a=z(e,n,n.meshes,r,n.babylonNode);a.skeleton=e.scene.getLastSkeletonById(n.skin),null===a.skeleton&&(a.skeleton=((e,n,r,s)=>{if(s||(s=new t.Skeleton(n.name||"","",e.scene)),!n.babylonSkeleton)return s;const o=[],a=[];((e,n,r,s)=>{for(const o in e.nodes){const a=e.nodes[o],i=o;if(!a.jointName||U(r,a.jointName))continue;const l=H(a),u=new t.Bone(a.name||"",n,null,l);u.id=i,s.push({bone:u,node:a,id:i})}for(let e=0;e<s.length;e++){const t=s[e],n=t.node.children;for(let e=0;e<n.length;e++){let r=null;for(let t=0;t<s.length;t++)if(s[t].id===n[e]){r=s[t];break}r&&(r.bone._parent=t.bone,t.bone.children.push(r.bone))}}})(e,s,n,o),s.bones=[];for(let r=0;r<n.jointNames.length;r++){const i=W(e,n.jointNames[r]);if(!i)continue;const l=i.node;if(!l){t.Tools.Warn("Joint named "+n.jointNames[r]+" does not exist");continue}const u=i.id,c=e.scene.getBoneById(u);if(c){s.bones.push(c);continue}let h,d=null;for(let o=0;o<r;o++){const r=W(e,n.jointNames[o]);if(!r)continue;const a=r.node;if(!a){t.Tools.Warn("Joint named "+n.jointNames[o]+" does not exist when looking for parent");continue}const i=a.children;if(i){h=!1;for(let t=0;t<i.length;t++)if(i[t]===u){d=$(e,n,n.jointNames[o],s),h=!0;break}if(h)break}}const m=H(l);!d&&o.length>0&&(d=K(o,u),d&&-1===a.indexOf(d)&&a.push(d)),new t.Bone(l.jointName||"",s,d,m).id=u}const i=s.bones;s.bones=[];for(let t=0;t<n.jointNames.length;t++){const r=W(e,n.jointNames[t]);if(r)for(let e=0;e<i.length;e++)if(i[e].id===r.id){s.bones.push(i[e]);break}}s.prepare();for(let e=0;e<a.length;e++)s.bones.push(a[e]);return s})(e,o,0,o.babylonSkeleton),o.babylonSkeleton||(o.babylonSkeleton=a.skeleton)),s=a}}else if(n.meshes)s=z(e,n,n.mesh?[n.mesh]:n.meshes,r,n.babylonNode);else if(!n.light||n.babylonNode||e.importOnlyMeshes){if(n.camera&&!n.babylonNode&&!e.importOnlyMeshes){const r=e.cameras[n.camera];if(r){if(e.scene._blockEntityCollection=!!e.assetContainer,"orthographic"===r.type){const r=new t.FreeCamera(n.camera,t.Vector3.Zero(),e.scene,!1);r.name=n.name||"",r.mode=t.Camera.ORTHOGRAPHIC_CAMERA,r.attachControl(),s=r,r._parentContainer=e.assetContainer}else if("perspective"===r.type){const o=r[r.type],a=new t.FreeCamera(n.camera,t.Vector3.Zero(),e.scene,!1);a.name=n.name||"",a.attachControl(),o.aspectRatio||(o.aspectRatio=e.scene.getEngine().getRenderWidth()/e.scene.getEngine().getRenderHeight()),o.znear&&o.zfar&&(a.maxZ=o.zfar,a.minZ=o.znear),s=a,a._parentContainer=e.assetContainer}e.scene._blockEntityCollection=!1}}}else{const r=e.lights[n.light];if(r)if("ambient"===r.type){const o=r[r.type],a=new t.HemisphericLight(n.light,t.Vector3.Zero(),e.scene);a.name=n.name||"",o.color&&(a.diffuse=t.Color3.FromArray(o.color)),s=a}else if("directional"===r.type){const o=r[r.type],a=new t.DirectionalLight(n.light,t.Vector3.Zero(),e.scene);a.name=n.name||"",o.color&&(a.diffuse=t.Color3.FromArray(o.color)),s=a}else if("point"===r.type){const o=r[r.type],a=new t.PointLight(n.light,t.Vector3.Zero(),e.scene);a.name=n.name||"",o.color&&(a.diffuse=t.Color3.FromArray(o.color)),s=a}else if("spot"===r.type){const o=r[r.type],a=new t.SpotLight(n.light,t.Vector3.Zero(),t.Vector3.Zero(),0,0,e.scene);a.name=n.name||"",o.color&&(a.diffuse=t.Color3.FromArray(o.color)),o.fallOfAngle&&(a.angle=o.fallOfAngle),o.fallOffExponent&&(a.exponent=o.fallOffExponent),s=a}}if(!n.jointName){if(n.babylonNode)return n.babylonNode;if(null===s){e.scene._blockEntityCollection=!!e.assetContainer;const r=new t.Mesh(n.name||"",e.scene);r._parentContainer=e.assetContainer,e.scene._blockEntityCollection=!1,n.babylonNode=r,s=r}}if(null!==s){if(n.matrix&&s instanceof t.Mesh)((e,n)=>{if(n.matrix){const r=new t.Vector3(0,0,0),s=new t.Quaternion,o=new t.Vector3(0,0,0);t.Matrix.FromArray(n.matrix).decompose(o,s,r),j(e,r,s,o)}else n.translation&&n.rotation&&n.scale&&j(e,t.Vector3.FromArray(n.translation),t.Quaternion.FromArray(n.rotation),t.Vector3.FromArray(n.scale));e.computeWorldMatrix(!0)})(s,n);else{const e=n.translation||[0,0,0],r=n.rotation||[0,0,0,1],o=n.scale||[1,1,1];j(s,t.Vector3.FromArray(e),t.Quaternion.FromArray(r),t.Vector3.FromArray(o))}s.updateCache(!0),n.babylonNode=s}return s},Y=(e,t,n,r=!1)=>{const s=e.nodes[t];let o=null;if(r=!(e.importOnlyMeshes&&!r&&e.importMeshesNames)||-1!==e.importMeshesNames.indexOf(s.name||"")||0===e.importMeshesNames.length,!s.jointName&&r&&(o=q(e,s,t),null!==o&&(o.id=t,o.parent=n)),s.children)for(let t=0;t<s.children.length;t++)Y(e,s.children[t],o,r)},X=e=>{let n=e.currentScene;if(n)for(let t=0;t<n.nodes.length;t++)Y(e,n.nodes[t],null);else for(const t in e.scenes){n=e.scenes[t];for(let t=0;t<n.nodes.length;t++)Y(e,n.nodes[t],null)}(e=>{for(const n in e.animations){const r=e.animations[n];if(!r.channels||!r.samplers)continue;let s=null;for(let o=0;o<r.channels.length;o++){const a=r.channels[o],i=r.samplers[a.sampler];if(!i)continue;let l,u;r.parameters?(l=r.parameters[i.input],u=r.parameters[i.output]):(l=i.input,u=i.output);const c=F.GetBufferFromAccessor(e,e.accessors[l]),h=F.GetBufferFromAccessor(e,e.accessors[u]),d=a.target.id;let m=e.scene.getNodeById(d);if(null===m&&(m=e.scene.getNodeByName(d)),null===m){t.Tools.Warn("Creating animation named "+n+". But cannot find node named "+d+" to attach to");continue}const _=m instanceof t.Bone;let p=a.target.path;const f=P.indexOf(p);-1!==f&&(p=B[f]);let g=t.Animation.ANIMATIONTYPE_MATRIX;_||("rotationQuaternion"===p?(g=t.Animation.ANIMATIONTYPE_QUATERNION,m.rotationQuaternion=new t.Quaternion):g=t.Animation.ANIMATIONTYPE_VECTOR3);let b=null;const y=[];let T=0,x=!1;_&&s&&s.getKeys().length===c.length&&(b=s,x=!0),x||(e.scene._blockEntityCollection=!!e.assetContainer,b=new t.Animation(n,_?"_matrix":p,1,g,t.Animation.ANIMATIONLOOPMODE_CYCLE),e.scene._blockEntityCollection=!1);for(let e=0;e<c.length;e++){let n;if("rotationQuaternion"===p?(n=t.Quaternion.FromArray([h[T],h[T+1],h[T+2],h[T+3]]),T+=4):(n=t.Vector3.FromArray([h[T],h[T+1],h[T+2]]),T+=3),_){const r=m;let o=t.Vector3.Zero(),a=new t.Quaternion,i=t.Vector3.Zero(),l=r.getBaseMatrix();x&&s&&(l=s.getKeys()[e].value),l.decompose(i,a,o),"position"===p?o=n:"rotationQuaternion"===p?a=n:i=n,n=t.Matrix.Compose(i,a,o)}x?s&&(s.getKeys()[e].value=n):y.push({frame:c[e],value:n})}!x&&b&&(b.setKeys(y),m.animations.push(b)),s=b,e.scene.stopAnimation(m),e.scene.beginAnimation(m,0,c[c.length-1],!0,1)}}})(e);for(let t=0;t<e.scene.skeletons.length;t++){const n=e.scene.skeletons[t];e.scene.beginAnimation(n,0,Number.MAX_VALUE,!0,1)}},Q=(e,t,n)=>{for(const r in t.uniforms){const s=t.uniforms[r],o=t.parameters[s];if(e.currentIdentifier===r&&o.semantic&&!o.source&&!o.node){const e=N.indexOf(o.semantic);if(-1!==e)return delete n[r],k[e]}}return e.currentIdentifier},Z=e=>{for(const t in e.materials)te.LoadMaterialAsync(e,t,()=>{},()=>{})};class J{static CreateRuntime(e,t,n){const r={extensions:{},accessors:{},buffers:{},bufferViews:{},meshes:{},lights:{},cameras:{},nodes:{},images:{},textures:{},shaders:{},programs:{},samplers:{},techniques:{},materials:{},animations:{},skins:{},extensionsUsed:[],scenes:{},buffersCount:0,shaderscount:0,scene:t,rootUrl:n,loadedBufferCount:0,loadedBufferViews:{},loadedShaderCount:0,importOnlyMeshes:!1,dummyNodes:[],assetContainer:null};return e.extensions&&G(e.extensions,"extensions",r),e.extensionsUsed&&G(e.extensionsUsed,"extensionsUsed",r),e.buffers&&((e,t)=>{for(const n in e){const r=e[n];t.buffers[n]=r,t.buffersCount++}})(e.buffers,r),e.bufferViews&&G(e.bufferViews,"bufferViews",r),e.accessors&&G(e.accessors,"accessors",r),e.meshes&&G(e.meshes,"meshes",r),e.lights&&G(e.lights,"lights",r),e.cameras&&G(e.cameras,"cameras",r),e.nodes&&G(e.nodes,"nodes",r),e.images&&G(e.images,"images",r),e.textures&&G(e.textures,"textures",r),e.shaders&&((e,t)=>{for(const n in e){const r=e[n];t.shaders[n]=r,t.shaderscount++}})(e.shaders,r),e.programs&&G(e.programs,"programs",r),e.samplers&&G(e.samplers,"samplers",r),e.techniques&&G(e.techniques,"techniques",r),e.materials&&G(e.materials,"materials",r),e.animations&&G(e.animations,"animations",r),e.skins&&G(e.skins,"skins",r),e.scenes&&(r.scenes=e.scenes),e.scene&&e.scenes&&(r.currentScene=e.scenes[e.scene]),r}static LoadBufferAsync(e,n,r,s,o){const a=e.buffers[n];t.Tools.IsBase64(a.uri)?setTimeout(()=>r(new Uint8Array(t.Tools.DecodeBase64(a.uri)))):t.Tools.LoadFile(e.rootUrl+a.uri,e=>r(new Uint8Array(e)),o,void 0,!0,e=>{e&&s(e.status+" "+e.statusText)})}static LoadTextureBufferAsync(e,n,r,s){const o=e.textures[n];if(!o||!o.source)return void s("");if(o.babylonTexture)return void r(null);const a=e.images[o.source];t.Tools.IsBase64(a.uri)?setTimeout(()=>r(new Uint8Array(t.Tools.DecodeBase64(a.uri)))):t.Tools.LoadFile(e.rootUrl+a.uri,e=>r(new Uint8Array(e)),void 0,void 0,!0,e=>{e&&s(e.status+" "+e.statusText)})}static CreateTextureAsync(e,n,r,s){const o=e.textures[n];if(o.babylonTexture)return void s(o.babylonTexture);const a=e.samplers[o.sampler],i=a.minFilter===w.NEAREST_MIPMAP_NEAREST||a.minFilter===w.NEAREST_MIPMAP_LINEAR||a.minFilter===w.LINEAR_MIPMAP_NEAREST||a.minFilter===w.LINEAR_MIPMAP_LINEAR,l=t.Texture.BILINEAR_SAMPLINGMODE,u=null==r?new Blob:new Blob([t.GetBlobBufferSource(r)]),c=URL.createObjectURL(u),h=()=>URL.revokeObjectURL(c),d=new t.Texture(c,e.scene,!i,!0,l,h,h);void 0!==a.wrapS&&(d.wrapU=F.GetWrapMode(a.wrapS)),void 0!==a.wrapT&&(d.wrapV=F.GetWrapMode(a.wrapT)),d.name=n,o.babylonTexture=d,s(d)}static LoadShaderStringAsync(e,n,r,s){const o=e.shaders[n];if(t.Tools.IsBase64(o.uri)){const e=atob(o.uri.split(",")[1]);r&&r(e)}else t.Tools.LoadFile(e.rootUrl+o.uri,r,void 0,void 0,!1,e=>{e&&s&&s(e.status+" "+e.statusText)})}static LoadMaterialAsync(e,n,r,s){const o=e.materials[n];if(!o.technique)return void(s&&s("No technique found."));const a=e.techniques[o.technique];if(!a){e.scene._blockEntityCollection=!!e.assetContainer;const s=new t.StandardMaterial(n,e.scene);return s._parentContainer=e.assetContainer,e.scene._blockEntityCollection=!1,s.diffuseColor=new t.Color3(.5,.5,.5),s.sideOrientation=t.Material.CounterClockWiseSideOrientation,void r(s)}const i=e.programs[a.program],l=a.states,u=t.Effect.ShadersStore[i.vertexShader+"VertexShader"],c=t.Effect.ShadersStore[i.fragmentShader+"PixelShader"];let h="",d="";const m=new I(u),_=new I(c),p={},f=[],g=[],b=[];for(const e in a.uniforms){const t=a.uniforms[e],n=a.parameters[t];if(p[e]=n,!n.semantic||n.node||n.source)n.type===R.SAMPLER_2D?b.push(e):f.push(e);else{const t=N.indexOf(n.semantic);-1!==t?(f.push(k[t]),delete p[e]):f.push(e)}}for(const e in a.attributes){const t=a.attributes[e],n=a.parameters[t];if(n.semantic){const e=V(n);e&&g.push(e)}}for(;!m.isEnd()&&m.getNextToken();){if(m.currentToken!==S.IDENTIFIER){h+=m.currentString;continue}let e=!1;for(const t in a.attributes){const n=a.attributes[t],r=a.parameters[n];if(m.currentIdentifier===t&&r.semantic){h+=V(r),e=!0;break}}e||(h+=Q(m,a,p))}for(;!_.isEnd()&&_.getNextToken();)_.currentToken===S.IDENTIFIER?d+=Q(_,a,p):d+=_.currentString;const y={vertex:i.vertexShader+n,fragment:i.fragmentShader+n},T={attributes:g,uniforms:f,samplers:b,needAlphaBlending:l&&l.enable&&-1!==l.enable.indexOf(3042)};t.Effect.ShadersStore[i.vertexShader+n+"VertexShader"]=h,t.Effect.ShadersStore[i.fragmentShader+n+"PixelShader"]=d;const x=new t.ShaderMaterial(n,e.scene,y,T);if(x.onError=((e,t,n)=>(r,s)=>{t.dispose(!0),n("Cannot compile program named "+e.name+". Error: "+s+". Default material will be applied")})(i,x,s),x.onCompiled=((e,t,n,r,s,o)=>a=>{((e,t,n,r,s)=>{const o=r.values||n.parameters,a=n.uniforms;for(const n in s){const i=s[n],l=i.type;let u=o[a[n]];if(void 0===u&&(u=i.value),!u)continue;const c=e=>n=>{i.value&&e&&(t.setTexture(e,n),delete s[e])};l===R.SAMPLER_2D?te.LoadTextureAsync(e,r.values?u:i.value,c(n),()=>c(null)):i.value&&F.SetUniform(t,n,r.values?u:i.value,l)&&delete s[n]}})(e,t,n,r,s),t.onBind=a=>{((e,t,n,r,s,o,a)=>{const i=o.values||s.parameters;for(const a in n){const l=n[a],u=l.type;if(u===R.FLOAT_MAT2||u===R.FLOAT_MAT3||u===R.FLOAT_MAT4)if(!l.semantic||l.source||l.node){if(l.semantic&&(l.source||l.node)){let e=t.scene.getNodeByName(l.source||l.node||"");if(null===e&&(e=t.scene.getNodeById(l.source||l.node||"")),null===e)continue;F.SetMatrix(t.scene,e,l,a,r.getEffect())}}else F.SetMatrix(t.scene,e,l,a,r.getEffect());else{const e=i[s.uniforms[a]];if(!e)continue;if(u===R.SAMPLER_2D){const n=t.textures[o.values?e:l.value].babylonTexture;if(null==n)continue;r.getEffect().setTexture(a,n)}else F.SetUniform(r.getEffect(),a,e,u)}}a(r)})(a,e,s,t,n,r,o)}})(e,x,a,o,p,r),x.sideOrientation=t.Material.CounterClockWiseSideOrientation,l&&l.functions){const e=l.functions;e.cullFace&&e.cullFace[0]!==O.BACK&&(x.backFaceCulling=!1);const n=e.blendFuncSeparate;n&&(n[0]===L.SRC_ALPHA&&n[1]===L.ONE_MINUS_SRC_ALPHA&&n[2]===L.ONE&&n[3]===L.ONE?x.alphaMode=t.Constants.ALPHA_COMBINE:n[0]===L.ONE&&n[1]===L.ONE&&n[2]===L.ZERO&&n[3]===L.ONE?x.alphaMode=t.Constants.ALPHA_ONEONE:n[0]===L.SRC_ALPHA&&n[1]===L.ONE&&n[2]===L.ZERO&&n[3]===L.ONE?x.alphaMode=t.Constants.ALPHA_ADD:n[0]===L.ZERO&&n[1]===L.ONE_MINUS_SRC_COLOR&&n[2]===L.ONE&&n[3]===L.ONE?x.alphaMode=t.Constants.ALPHA_SUBTRACT:n[0]===L.DST_COLOR&&n[1]===L.ZERO&&n[2]===L.ONE&&n[3]===L.ONE?x.alphaMode=t.Constants.ALPHA_MULTIPLY:n[0]===L.SRC_ALPHA&&n[1]===L.ONE_MINUS_SRC_COLOR&&n[2]===L.ONE&&n[3]===L.ONE&&(x.alphaMode=t.Constants.ALPHA_MAXIMIZED))}}}let ee=class e{static RegisterExtension(n){e.Extensions[n.name]?t.Tools.Error('Tool with the same name "'+n.name+'" already exists'):e.Extensions[n.name]=n}dispose(){}_importMeshAsync(e,n,r,s,o,a,i,l){return n.useRightHandedSystem=!0,te.LoadRuntimeAsync(n,r,s,n=>{n.assetContainer=o,n.importOnlyMeshes=!0,""===e?n.importMeshesNames=[]:"string"==typeof e?n.importMeshesNames=[e]:!e||e instanceof Array?(n.importMeshesNames=[],t.Tools.Warn("Argument meshesNames must be of type string or string[]")):n.importMeshesNames=[e],this._createNodes(n);const r=[],s=[];for(const e in n.nodes){const s=n.nodes[e];s.babylonNode instanceof t.AbstractMesh&&r.push(s.babylonNode)}for(const e in n.skins){const r=n.skins[e];r.babylonSkeleton instanceof t.Skeleton&&s.push(r.babylonSkeleton)}this._loadBuffersAsync(n,()=>{this._loadShadersAsync(n,()=>{Z(n),X(n),!g.IncrementalLoading&&a&&a(r,s)})}),g.IncrementalLoading&&a&&a(r,s)},l),!0}importMeshAsync(e,t,n,r,s,o){return new Promise((a,i)=>{this._importMeshAsync(e,t,r,s,n,(e,t)=>{a({meshes:e,particleSystems:[],skeletons:t,animationGroups:[],lights:[],transformNodes:[],geometries:[],spriteManagers:[]})},o,e=>{i(new Error(e))})})}_loadAsync(e,t,n,r,s,o){e.useRightHandedSystem=!0,te.LoadRuntimeAsync(e,t,n,e=>{te.LoadRuntimeExtensionsAsync(e,()=>{this._createNodes(e),this._loadBuffersAsync(e,()=>{this._loadShadersAsync(e,()=>{Z(e),X(e),g.IncrementalLoading||r()})}),g.IncrementalLoading&&r()},o)},o)}loadAsync(e,t,n,r){return v(this,void 0,void 0,function*(){return yield new Promise((s,o)=>{this._loadAsync(e,t,n,()=>{s()},r,e=>{o(new Error(e))})})})}_loadShadersAsync(e,n){let r=!1;const s=(r,s)=>{te.LoadShaderStringAsync(e,r,o=>{o instanceof ArrayBuffer||(e.loadedShaderCount++,o&&(t.Effect.ShadersStore[r+(s.type===C.VERTEX?"VertexShader":"PixelShader")]=o),e.loadedShaderCount===e.shaderscount&&n())},()=>{t.Tools.Error("Error when loading shader program named "+r+" located at "+s.uri)})};for(const n in e.shaders){r=!0;const o=e.shaders[n];o?s.bind(this,n,o)():t.Tools.Error("No shader named: "+n)}r||n()}_loadBuffersAsync(e,n){let r=!1;const s=(r,s)=>{te.LoadBufferAsync(e,r,o=>{e.loadedBufferCount++,o&&(o.byteLength!=e.buffers[r].byteLength&&t.Tools.Error("Buffer named "+r+" is length "+o.byteLength+". Expected: "+s.byteLength),e.loadedBufferViews[r]=o),e.loadedBufferCount===e.buffersCount&&n()},()=>{t.Tools.Error("Error when loading buffer named "+r+" located at "+s.uri)})};for(const n in e.buffers){r=!0;const o=e.buffers[n];o?s.bind(this,n,o)():t.Tools.Error("No buffer named: "+n)}r||n()}_createNodes(e){let t=e.currentScene;if(t)for(let n=0;n<t.nodes.length;n++)Y(e,t.nodes[n],null);else for(const n in e.scenes){t=e.scenes[n];for(let n=0;n<t.nodes.length;n++)Y(e,t.nodes[n],null)}}};ee.Extensions={};class te{constructor(e){this._name=e}get name(){return this._name}loadRuntimeAsync(e,t,n,r,s){return!1}loadRuntimeExtensionsAsync(e,t,n){return!1}loadBufferAsync(e,t,n,r,s){return!1}loadTextureBufferAsync(e,t,n,r){return!1}createTextureAsync(e,t,n,r,s){return!1}loadShaderStringAsync(e,t,n,r){return!1}loadMaterialAsync(e,t,n,r){return!1}static LoadRuntimeAsync(e,t,n,r,s){te._ApplyExtensions(o=>o.loadRuntimeAsync(e,t,n,r,s),()=>{setTimeout(()=>{r&&r(J.CreateRuntime(t.json,e,n))})})}static LoadRuntimeExtensionsAsync(e,t,n){te._ApplyExtensions(r=>r.loadRuntimeExtensionsAsync(e,t,n),()=>{setTimeout(()=>{t()})})}static LoadBufferAsync(e,t,n,r,s){te._ApplyExtensions(o=>o.loadBufferAsync(e,t,n,r,s),()=>{J.LoadBufferAsync(e,t,n,r,s)})}static LoadTextureAsync(e,t,n,r){te._LoadTextureBufferAsync(e,t,s=>{s&&te._CreateTextureAsync(e,t,s,n,r)},r)}static LoadShaderStringAsync(e,t,n,r){te._ApplyExtensions(s=>s.loadShaderStringAsync(e,t,n,r),()=>{J.LoadShaderStringAsync(e,t,n,r)})}static LoadMaterialAsync(e,t,n,r){te._ApplyExtensions(s=>s.loadMaterialAsync(e,t,n,r),()=>{J.LoadMaterialAsync(e,t,n,r)})}static _LoadTextureBufferAsync(e,t,n,r){te._ApplyExtensions(s=>s.loadTextureBufferAsync(e,t,n,r),()=>{J.LoadTextureBufferAsync(e,t,n,r)})}static _CreateTextureAsync(e,t,n,r,s){te._ApplyExtensions(o=>o.createTextureAsync(e,t,n,r,s),()=>{J.CreateTextureAsync(e,t,n,r)})}static _ApplyExtensions(e,t){for(const t in ee.Extensions)if(e(ee.Extensions[t]))return;t()}}g._CreateGLTF1Loader=()=>new ee;class ne extends te{constructor(){super("KHR_binary_glTF")}loadRuntimeAsync(e,t,n,r){const s=t.json.extensionsUsed;return!(!s||-1===s.indexOf(this.name)||!t.bin||(this._bin=t.bin,r(J.CreateRuntime(t.json,e,n)),0))}loadBufferAsync(e,t,n,r){return-1!==e.extensionsUsed.indexOf(this.name)&&"binary_glTF"===t&&(this._bin.readAsync(0,this._bin.byteLength).then(n,e=>r(e.message)),!0)}loadTextureBufferAsync(e,t,n){const r=e.textures[t],s=e.images[r.source];if(!s.extensions||!(this.name in s.extensions))return!1;const o=s.extensions[this.name],a=e.bufferViews[o.bufferView];return n(F.GetBufferFromBufferView(e,a,0,a.byteLength,A.UNSIGNED_BYTE)),!0}loadShaderStringAsync(e,t,n){const r=e.shaders[t];if(!r.extensions||!(this.name in r.extensions))return!1;const s=r.extensions[this.name],o=e.bufferViews[s.bufferView],a=F.GetBufferFromBufferView(e,o,0,o.byteLength,A.UNSIGNED_BYTE);return setTimeout(()=>{const e=F.DecodeBufferToText(a);n(e)}),!0}}ee.RegisterExtension(new ne);class re extends te{constructor(){super("KHR_materials_common")}loadRuntimeExtensionsAsync(e){if(!e.extensions)return!1;const n=e.extensions[this.name];if(!n)return!1;const r=n.lights;if(r)for(const n in r){const s=r[n];switch(s.type){case"ambient":{const n=new t.HemisphericLight(s.name,new t.Vector3(0,1,0),e.scene),r=s.ambient;r&&(n.diffuse=t.Color3.FromArray(r.color||[1,1,1]));break}case"point":{const n=new t.PointLight(s.name,new t.Vector3(10,10,10),e.scene),r=s.point;r&&(n.diffuse=t.Color3.FromArray(r.color||[1,1,1]));break}case"directional":{const n=new t.DirectionalLight(s.name,new t.Vector3(0,-1,0),e.scene),r=s.directional;r&&(n.diffuse=t.Color3.FromArray(r.color||[1,1,1]));break}case"spot":{const n=s.spot;n&&(new t.SpotLight(s.name,new t.Vector3(0,10,0),new t.Vector3(0,-1,0),n.fallOffAngle||Math.PI,n.fallOffExponent||0,e.scene).diffuse=t.Color3.FromArray(n.color||[1,1,1]));break}default:t.Tools.Warn('GLTF Material Common extension: light type "'+s.type+"” not supported")}}return!1}loadMaterialAsync(e,n,r,s){const o=e.materials[n];if(!o||!o.extensions)return!1;const a=o.extensions[this.name];if(!a)return!1;const i=new t.StandardMaterial(n,e.scene);return i.sideOrientation=t.Material.CounterClockWiseSideOrientation,"CONSTANT"===a.technique&&(i.disableLighting=!0),i.backFaceCulling=void 0!==a.doubleSided&&!a.doubleSided,i.alpha=void 0===a.values.transparency?1:a.values.transparency,i.specularPower=void 0===a.values.shininess?0:a.values.shininess,"string"==typeof a.values.ambient?this._loadTexture(e,a.values.ambient,i,"ambientTexture",s):i.ambientColor=t.Color3.FromArray(a.values.ambient||[0,0,0]),"string"==typeof a.values.diffuse?this._loadTexture(e,a.values.diffuse,i,"diffuseTexture",s):i.diffuseColor=t.Color3.FromArray(a.values.diffuse||[0,0,0]),"string"==typeof a.values.emission?this._loadTexture(e,a.values.emission,i,"emissiveTexture",s):i.emissiveColor=t.Color3.FromArray(a.values.emission||[0,0,0]),"string"==typeof a.values.specular?this._loadTexture(e,a.values.specular,i,"specularTexture",s):i.specularColor=t.Color3.FromArray(a.values.specular||[0,0,0]),!0}_loadTexture(e,t,n,r,s){J.LoadTextureBufferAsync(e,t,s=>{J.CreateTextureAsync(e,t,s,e=>n[r]=e)},s)}}ee.RegisterExtension(new re);var se={__proto__:null,get EBlendingFunction(){return L},get EComponentType(){return A},get ECullingType(){return O},get EParameterType(){return R},get EShaderType(){return C},get ETextureFilterType(){return w},get ETextureFormat(){return E},get ETextureWrapMode(){return M},GLTFBinaryExtension:ne,GLTFLoader:ee,GLTFLoaderBase:J,GLTFLoaderExtension:te,GLTFMaterialsCommonExtension:re,GLTFUtils:F};const oe="undefined"!=typeof global?global:"undefined"!=typeof window?window:void 0;if(void 0!==oe){oe.BABYLON=oe.BABYLON||{},oe.BABYLON.GLTF1=oe.BABYLON.GLTF1||{};for(const e in se)oe.BABYLON.GLTF1[e]=se[e]}const ae=[{regex:new RegExp("^/nodes/\\d+/extensions/")}];class ie{constructor(e,t){this._gltf=e,this._infoTree=t}convert(e){let t,n=this._gltf,r=this._infoTree;if(!e.startsWith("/"))throw new Error("Path must start with a /");const s=e.split("/");if(s.shift(),s[s.length-1].includes(".length")){const e=s[s.length-1].split(".");s.pop(),s.push(...e)}let o=!1;for(const a of s){const s="length"===a;if(s&&!r.__array__)throw new Error(`Path ${e} is invalid`);if(r.__ignoreObjectTree__&&(o=!0),r.__array__&&!s)r=r.__array__;else if(r=r[a],!r)throw new Error(`Path ${e} is invalid`);if(!o)if(void 0===n){if(!ae.find(t=>t.regex.test(e)))throw new Error(`Path ${e} is invalid`)}else s||(n=null==n?void 0:n[a]);(r.__target__||s)&&(t=n)}return{object:t,info:r}}}function le(e,t,n,r){const s=ue(e);return r?s[n][r]:s[n]}function ue(e,n,r){var s,o,a;return null===(a=null===(s=e._data)||void 0===s?void 0:s[null!==(o=null==r?void 0:r.fillMode)&&void 0!==o?o:t.Constants.MATERIAL_TriangleFillMode])||void 0===a?void 0:a.babylonMaterial}function ce(e,n){return{offset:{componentsCount:2,type:"Vector2",get:(r,s,o)=>{const a=le(r,0,e,n);return new t.Vector2(null==a?void 0:a.uOffset,null==a?void 0:a.vOffset)},getTarget:ue,set:(t,r,s,o)=>{const a=le(r,0,e,n);a.uOffset=t.x,a.vOffset=t.y},getPropertyName:[()=>`${e}${n?"."+n:""}.uOffset`,()=>`${e}${n?"."+n:""}.vOffset`]},rotation:{type:"number",get:(t,r,s)=>{var o;return null===(o=le(t,0,e,n))||void 0===o?void 0:o.wAng},getTarget:ue,set:(t,r,s,o)=>le(r,0,e,n).wAng=t,getPropertyName:[()=>`${e}${n?"."+n:""}.wAng`]},scale:{componentsCount:2,type:"Vector2",get:(r,s,o)=>{const a=le(r,0,e,n);return new t.Vector2(null==a?void 0:a.uScale,null==a?void 0:a.vScale)},getTarget:ue,set:(t,r,s,o)=>{const a=le(r,0,e,n);a.uScale=t.x,a.vScale=t.y},getPropertyName:[()=>`${e}${n?"."+n:""}.uScale`,()=>`${e}${n?"."+n:""}.vScale`]}}}const he={cameras:{__array__:{__target__:!0,orthographic:{xmag:{componentsCount:2,type:"Vector2",get:e=>{var n,r,s,o;return new t.Vector2(null!==(r=null===(n=e._babylonCamera)||void 0===n?void 0:n.orthoLeft)&&void 0!==r?r:0,null!==(o=null===(s=e._babylonCamera)||void 0===s?void 0:s.orthoRight)&&void 0!==o?o:0)},set:(e,t)=>{t._babylonCamera&&(t._babylonCamera.orthoLeft=e.x,t._babylonCamera.orthoRight=e.y)},getTarget:e=>e,getPropertyName:[()=>"orthoLeft",()=>"orthoRight"]},ymag:{componentsCount:2,type:"Vector2",get:e=>{var n,r,s,o;return new t.Vector2(null!==(r=null===(n=e._babylonCamera)||void 0===n?void 0:n.orthoBottom)&&void 0!==r?r:0,null!==(o=null===(s=e._babylonCamera)||void 0===s?void 0:s.orthoTop)&&void 0!==o?o:0)},set:(e,t)=>{t._babylonCamera&&(t._babylonCamera.orthoBottom=e.x,t._babylonCamera.orthoTop=e.y)},getTarget:e=>e,getPropertyName:[()=>"orthoBottom",()=>"orthoTop"]},zfar:{type:"number",get:e=>{var t;return null===(t=e._babylonCamera)||void 0===t?void 0:t.maxZ},set:(e,t)=>{t._babylonCamera&&(t._babylonCamera.maxZ=e)},getTarget:e=>e,getPropertyName:[()=>"maxZ"]},znear:{type:"number",get:e=>{var t;return null===(t=e._babylonCamera)||void 0===t?void 0:t.minZ},set:(e,t)=>{t._babylonCamera&&(t._babylonCamera.minZ=e)},getTarget:e=>e,getPropertyName:[()=>"minZ"]}},perspective:{aspectRatio:{type:"number",get:e=>{var t;return null===(t=e._babylonCamera)||void 0===t?void 0:t.getEngine().getAspectRatio(e._babylonCamera)},getTarget:e=>e,getPropertyName:[()=>"aspectRatio"],isReadOnly:!0},yfov:{type:"number",get:e=>{var t;return null===(t=e._babylonCamera)||void 0===t?void 0:t.fov},set:(e,t)=>{t._babylonCamera&&(t._babylonCamera.fov=e)},getTarget:e=>e,getPropertyName:[()=>"fov"]},zfar:{type:"number",get:e=>{var t;return null===(t=e._babylonCamera)||void 0===t?void 0:t.maxZ},set:(e,t)=>{t._babylonCamera&&(t._babylonCamera.maxZ=e)},getTarget:e=>e,getPropertyName:[()=>"maxZ"]},znear:{type:"number",get:e=>{var t;return null===(t=e._babylonCamera)||void 0===t?void 0:t.minZ},set:(e,t)=>{t._babylonCamera&&(t._babylonCamera.minZ=e)},getTarget:e=>e,getPropertyName:[()=>"minZ"]}}}},nodes:{length:{type:"number",get:e=>e.length,getTarget:e=>e.map(e=>e._babylonTransformNode),getPropertyName:[()=>"length"]},__array__:{__target__:!0,translation:{type:"Vector3",get:e=>{var t;return null===(t=e._babylonTransformNode)||void 0===t?void 0:t.position},set:(e,t)=>{var n;return null===(n=t._babylonTransformNode)||void 0===n?void 0:n.position.copyFrom(e)},getTarget:e=>e._babylonTransformNode,getPropertyName:[()=>"position"]},rotation:{type:"Quaternion",get:e=>{var t;return null===(t=e._babylonTransformNode)||void 0===t?void 0:t.rotationQuaternion},set:(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:e=>e._babylonTransformNode,getPropertyName:[()=>"rotationQuaternion"]},scale:{type:"Vector3",get:e=>{var t;return null===(t=e._babylonTransformNode)||void 0===t?void 0:t.scaling},set:(e,t)=>{var n;return null===(n=t._babylonTransformNode)||void 0===n?void 0:n.scaling.copyFrom(e)},getTarget:e=>e._babylonTransformNode,getPropertyName:[()=>"scaling"]},weights:{length:{type:"number",get:e=>e._numMorphTargets,getTarget:e=>e._babylonTransformNode,getPropertyName:[()=>"influence"]},__array__:{__target__:!0,type:"number",get:(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:e=>e._babylonTransformNode,getPropertyName:[()=>"influence"]},type:"number[]",get:(e,t)=>[0],getTarget:e=>e._babylonTransformNode,getPropertyName:[()=>"influence"]},matrix:{type:"Matrix",get:e=>{var n,r,s;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===(s=e._babylonTransformNode)||void 0===s?void 0:s.position)},getTarget:e=>e._babylonTransformNode,isReadOnly:!0},globalMatrix:{type:"Matrix",get:e=>{var n,r,s,o,a,i,l;const u=t.Matrix.Identity();let c=e.parent;for(;c&&c.parent;)c=c.parent;const h=(null===(n=e._babylonTransformNode)||void 0===n?void 0:n.position._isDirty)||(null===(s=null===(r=e._babylonTransformNode)||void 0===r?void 0:r.rotationQuaternion)||void 0===s?void 0:s._isDirty)||(null===(o=e._babylonTransformNode)||void 0===o?void 0:o.scaling._isDirty);if(c){const t=null===(a=c._babylonTransformNode)||void 0===a?void 0:a.computeWorldMatrix(!0).invert();t&&(null===(l=null===(i=e._babylonTransformNode)||void 0===i?void 0:i.computeWorldMatrix(h))||void 0===l||l.multiplyToRef(t,u))}else e._babylonTransformNode&&u.copyFrom(e._babylonTransformNode.computeWorldMatrix(h));return u},getTarget:e=>e._babylonTransformNode,isReadOnly:!0},extensions:{EXT_lights_ies:{multiplier:{type:"number",get:e=>{var n,r;return null===(r=null===(n=e._babylonTransformNode)||void 0===n?void 0:n.getChildren(e=>e instanceof t.SpotLight,!0)[0])||void 0===r?void 0:r.intensity},getTarget:e=>{var n;return null===(n=e._babylonTransformNode)||void 0===n?void 0:n.getChildren(e=>e instanceof t.SpotLight,!0)[0]},set:(e,n)=>{if(n._babylonTransformNode){const r=n._babylonTransformNode.getChildren(e=>e instanceof t.SpotLight,!0)[0];r&&(r.intensity=e)}}},color:{type:"Color3",get:e=>{var n,r;return null===(r=null===(n=e._babylonTransformNode)||void 0===n?void 0:n.getChildren(e=>e instanceof t.SpotLight,!0)[0])||void 0===r?void 0:r.diffuse},getTarget:e=>{var n;return null===(n=e._babylonTransformNode)||void 0===n?void 0:n.getChildren(e=>e instanceof t.SpotLight,!0)[0]},set:(e,n)=>{if(n._babylonTransformNode){const r=n._babylonTransformNode.getChildren(e=>e instanceof t.SpotLight,!0)[0];r&&(r.diffuse=e)}}}},KHR_node_visibility:{visible:{type:"boolean",get:e=>!!e._primitiveBabylonMeshes&&e._primitiveBabylonMeshes[0].isVisible,getTarget:()=>{},set:(e,t)=>{t._primitiveBabylonMeshes&&t._primitiveBabylonMeshes.forEach(t=>t.isVisible=e)}}}}}},materials:{__array__:{__target__:!0,emissiveFactor:{type:"Color3",get:(e,t,n)=>ue(e,0,n).emissiveColor,set:(e,t,n,r)=>ue(t,0,r).emissiveColor.copyFrom(e),getTarget:(e,t,n)=>ue(e,0,n),getPropertyName:[()=>"emissiveColor"]},emissiveTexture:{extensions:{KHR_texture_transform:ce("emissiveTexture")}},normalTexture:{scale:{type:"number",get:(e,t,n)=>{var r;return null===(r=le(e,0,"bumpTexture"))||void 0===r?void 0:r.level},set:(e,t,n,r)=>{const s=le(t,0,"bumpTexture");s&&(s.level=e)},getTarget:(e,t,n)=>ue(e,0,n),getPropertyName:[()=>"level"]},extensions:{KHR_texture_transform:ce("bumpTexture")}},occlusionTexture:{strength:{type:"number",get:(e,t,n)=>ue(e,0,n).ambientTextureStrength,set:(e,t,n,r)=>{const s=ue(t,0,r);s&&(s.ambientTextureStrength=e)},getTarget:(e,t,n)=>ue(e,0,n),getPropertyName:[()=>"ambientTextureStrength"]},extensions:{KHR_texture_transform:ce("ambientTexture")}},pbrMetallicRoughness:{baseColorFactor:{type:"Color4",get:(e,n,r)=>{const s=ue(e,0,r);return t.Color4.FromColor3(s.albedoColor,s.alpha)},set:(e,t,n,r)=>{const s=ue(t,0,r);s.albedoColor.set(e.r,e.g,e.b),s.alpha=e.a},getTarget:(e,t,n)=>ue(e,0,n),getPropertyName:[()=>"albedoColor",()=>"alpha"]},baseColorTexture:{extensions:{KHR_texture_transform:ce("albedoTexture")}},metallicFactor:{type:"number",get:(e,t,n)=>ue(e,0,n).metallic,set:(e,t,n,r)=>{const s=ue(t,0,r);s&&(s.metallic=e)},getTarget:(e,t,n)=>ue(e,0,n),getPropertyName:[()=>"metallic"]},roughnessFactor:{type:"number",get:(e,t,n)=>ue(e,0,n).roughness,set:(e,t,n,r)=>{const s=ue(t,0,r);s&&(s.roughness=e)},getTarget:(e,t,n)=>ue(e,0,n),getPropertyName:[()=>"roughness"]},metallicRoughnessTexture:{extensions:{KHR_texture_transform:ce("metallicTexture")}}},extensions:{KHR_materials_anisotropy:{anisotropyStrength:{type:"number",get:(e,t,n)=>ue(e,0,n).anisotropy.intensity,set:(e,t,n,r)=>{ue(t,0,r).anisotropy.intensity=e},getTarget:(e,t,n)=>ue(e,0,n),getPropertyName:[()=>"anisotropy.intensity"]},anisotropyRotation:{type:"number",get:(e,t,n)=>ue(e,0,n).anisotropy.angle,set:(e,t,n,r)=>{ue(t,0,r).anisotropy.angle=e},getTarget:(e,t,n)=>ue(e,0,n),getPropertyName:[()=>"anisotropy.angle"]},anisotropyTexture:{extensions:{KHR_texture_transform:ce("anisotropy","texture")}}},KHR_materials_clearcoat:{clearcoatFactor:{type:"number",get:(e,t,n)=>ue(e,0,n).clearCoat.intensity,set:(e,t,n,r)=>{ue(t,0,r).clearCoat.intensity=e},getTarget:(e,t,n)=>ue(e,0,n),getPropertyName:[()=>"clearCoat.intensity"]},clearcoatRoughnessFactor:{type:"number",get:(e,t,n)=>ue(e,0,n).clearCoat.roughness,set:(e,t,n,r)=>{ue(t,0,r).clearCoat.roughness=e},getTarget:(e,t,n)=>ue(e,0,n),getPropertyName:[()=>"clearCoat.roughness"]},clearcoatTexture:{extensions:{KHR_texture_transform:ce("clearCoat","texture")}},clearcoatNormalTexture:{scale:{type:"number",get:(e,t,n)=>{var r;return null===(r=ue(e,0,n).clearCoat.bumpTexture)||void 0===r?void 0:r.level},getTarget:ue,set:(e,t,n,r)=>ue(t,0,r).clearCoat.bumpTexture.level=e},extensions:{KHR_texture_transform:ce("clearCoat","bumpTexture")}},clearcoatRoughnessTexture:{extensions:{KHR_texture_transform:ce("clearCoat","textureRoughness")}}},KHR_materials_dispersion:{dispersion:{type:"number",get:(e,t,n)=>ue(e,0,n).subSurface.dispersion,getTarget:ue,set:(e,t,n,r)=>ue(t,0,r).subSurface.dispersion=e}},KHR_materials_emissive_strength:{emissiveStrength:{type:"number",get:(e,t,n)=>ue(e,0,n).emissiveIntensity,getTarget:ue,set:(e,t,n,r)=>ue(t,0,r).emissiveIntensity=e}},KHR_materials_ior:{ior:{type:"number",get:(e,t,n)=>ue(e,0,n).indexOfRefraction,getTarget:ue,set:(e,t,n,r)=>ue(t,0,r).indexOfRefraction=e}},KHR_materials_iridescence:{iridescenceFactor:{type:"number",get:(e,t,n)=>ue(e,0,n).iridescence.intensity,getTarget:ue,set:(e,t,n,r)=>ue(t,0,r).iridescence.intensity=e},iridescenceIor:{type:"number",get:(e,t,n)=>ue(e,0,n).iridescence.indexOfRefraction,getTarget:ue,set:(e,t,n,r)=>ue(t,0,r).iridescence.indexOfRefraction=e},iridescenceTexture:{extensions:{KHR_texture_transform:ce("iridescence","texture")}},iridescenceThicknessMaximum:{type:"number",get:(e,t,n)=>ue(e,0,n).iridescence.maximumThickness,getTarget:ue,set:(e,t,n,r)=>ue(t,0,r).iridescence.maximumThickness=e},iridescenceThicknessMinimum:{type:"number",get:(e,t,n)=>ue(e,0,n).iridescence.minimumThickness,getTarget:ue,set:(e,t,n,r)=>ue(t,0,r).iridescence.minimumThickness=e},iridescenceThicknessTexture:{extensions:{KHR_texture_transform:ce("iridescence","thicknessTexture")}}},KHR_materials_sheen:{sheenColorFactor:{type:"Color3",get:(e,t,n)=>ue(e,0,n).sheen.color,getTarget:ue,set:(e,t,n,r)=>ue(t,0,r).sheen.color.copyFrom(e)},sheenColorTexture:{extensions:{KHR_texture_transform:ce("sheen","texture")}},sheenRoughnessFactor:{type:"number",get:(e,t,n)=>ue(e,0,n).sheen.intensity,getTarget:ue,set:(e,t,n,r)=>ue(t,0,r).sheen.intensity=e},sheenRoughnessTexture:{extensions:{KHR_texture_transform:ce("sheen","thicknessTexture")}}},KHR_materials_specular:{specularFactor:{type:"number",get:(e,t,n)=>ue(e,0,n).metallicF0Factor,getTarget:ue,set:(e,t,n,r)=>ue(t,0,r).metallicF0Factor=e,getPropertyName:[()=>"metallicF0Factor"]},specularColorFactor:{type:"Color3",get:(e,t,n)=>ue(e,0,n).metallicReflectanceColor,getTarget:ue,set:(e,t,n,r)=>ue(t,0,r).metallicReflectanceColor.copyFrom(e),getPropertyName:[()=>"metallicReflectanceColor"]},specularTexture:{extensions:{KHR_texture_transform:ce("metallicReflectanceTexture")}},specularColorTexture:{extensions:{KHR_texture_transform:ce("reflectanceTexture")}}},KHR_materials_transmission:{transmissionFactor:{type:"number",get:(e,t,n)=>ue(e,0,n).subSurface.refractionIntensity,getTarget:ue,set:(e,t,n,r)=>ue(t,0,r).subSurface.refractionIntensity=e,getPropertyName:[()=>"subSurface.refractionIntensity"]},transmissionTexture:{extensions:{KHR_texture_transform:ce("subSurface","refractionIntensityTexture")}}},KHR_materials_diffuse_transmission:{diffuseTransmissionFactor:{type:"number",get:(e,t,n)=>ue(e,0,n).subSurface.translucencyIntensity,getTarget:ue,set:(e,t,n,r)=>ue(t,0,r).subSurface.translucencyIntensity=e},diffuseTransmissionTexture:{extensions:{KHR_texture_transform:ce("subSurface","translucencyIntensityTexture")}},diffuseTransmissionColorFactor:{type:"Color3",get:(e,t,n)=>ue(e,0,n).subSurface.translucencyColor,getTarget:ue,set:(e,t,n,r)=>{var s;return e&&(null===(s=ue(t,0,r).subSurface.translucencyColor)||void 0===s?void 0:s.copyFrom(e))}},diffuseTransmissionColorTexture:{extensions:{KHR_texture_transform:ce("subSurface","translucencyColorTexture")}}},KHR_materials_volume:{attenuationColor:{type:"Color3",get:(e,t,n)=>ue(e,0,n).subSurface.tintColor,getTarget:ue,set:(e,t,n,r)=>ue(t,0,r).subSurface.tintColor.copyFrom(e)},attenuationDistance:{type:"number",get:(e,t,n)=>ue(e,0,n).subSurface.tintColorAtDistance,getTarget:ue,set:(e,t,n,r)=>ue(t,0,r).subSurface.tintColorAtDistance=e},thicknessFactor:{type:"number",get:(e,t,n)=>ue(e,0,n).subSurface.maximumThickness,getTarget:ue,set:(e,t,n,r)=>ue(t,0,r).subSurface.maximumThickness=e},thicknessTexture:{extensions:{KHR_texture_transform:ce("subSurface","thicknessTexture")}}}}}},extensions:{KHR_lights_punctual:{lights:{length:{type:"number",get:e=>e.length,getTarget:e=>e.map(e=>e._babylonLight),getPropertyName:[e=>"length"]},__array__:{__target__:!0,color:{type:"Color3",get:e=>{var t;return null===(t=e._babylonLight)||void 0===t?void 0:t.diffuse},set:(e,t)=>{var n;return null===(n=t._babylonLight)||void 0===n?void 0:n.diffuse.copyFrom(e)},getTarget:e=>e._babylonLight,getPropertyName:[e=>"diffuse"]},intensity:{type:"number",get:e=>{var t;return null===(t=e._babylonLight)||void 0===t?void 0:t.intensity},set:(e,t)=>t._babylonLight?t._babylonLight.intensity=e:void 0,getTarget:e=>e._babylonLight,getPropertyName:[e=>"intensity"]},range:{type:"number",get:e=>{var t;return null===(t=e._babylonLight)||void 0===t?void 0:t.range},set:(e,t)=>t._babylonLight?t._babylonLight.range=e:void 0,getTarget:e=>e._babylonLight,getPropertyName:[e=>"range"]},spot:{innerConeAngle:{type:"number",get:e=>{var t;return null===(t=e._babylonLight)||void 0===t?void 0:t.innerAngle},set:(e,t)=>t._babylonLight?t._babylonLight.innerAngle=e:void 0,getTarget:e=>e._babylonLight,getPropertyName:[e=>"innerConeAngle"]},outerConeAngle:{type:"number",get:e=>{var t;return null===(t=e._babylonLight)||void 0===t?void 0:t.angle},set:(e,t)=>t._babylonLight?t._babylonLight.angle=e:void 0,getTarget:e=>e._babylonLight,getPropertyName:[e=>"outerConeAngle"]}}}}},EXT_lights_area:{lights:{length:{type:"number",get:e=>e.length,getTarget:e=>e.map(e=>e._babylonLight),getPropertyName:[e=>"length"]},__array__:{__target__:!0,color:{type:"Color3",get:e=>{var t;return null===(t=e._babylonLight)||void 0===t?void 0:t.diffuse},set:(e,t)=>{var n;return null===(n=t._babylonLight)||void 0===n?void 0:n.diffuse.copyFrom(e)},getTarget:e=>e._babylonLight,getPropertyName:[e=>"diffuse"]},intensity:{type:"number",get:e=>{var t;return null===(t=e._babylonLight)||void 0===t?void 0:t.intensity},set:(e,t)=>t._babylonLight?t._babylonLight.intensity=e:void 0,getTarget:e=>e._babylonLight,getPropertyName:[e=>"intensity"]},size:{type:"number",get:e=>{var t;return null===(t=e._babylonLight)||void 0===t?void 0:t.height},set:(e,t)=>t._babylonLight?t._babylonLight.height=e:void 0,getTarget:e=>e._babylonLight,getPropertyName:[e=>"size"]},rect:{aspect:{type:"number",get: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:(e,t)=>t._babylonLight?t._babylonLight.width=e*t._babylonLight.height:void 0,getTarget:e=>e._babylonLight,getPropertyName:[e=>"aspect"]}}}}},EXT_lights_ies:{lights:{length:{type:"number",get:e=>e.length,getTarget:e=>e.map(e=>e._babylonLight),getPropertyName:[e=>"length"]}}},EXT_lights_image_based:{lights:{length:{type:"number",get:e=>e.length,getTarget:e=>e.map(e=>e._babylonTexture),getPropertyName:[e=>"length"]},__array__:{__target__:!0,intensity:{type:"number",get:e=>{var t;return null===(t=e._babylonTexture)||void 0===t?void 0:t.level},set:(e,t)=>{t._babylonTexture&&(t._babylonTexture.level=e)},getTarget:e=>e._babylonTexture},rotation:{type:"Quaternion",get:e=>{var n;return e._babylonTexture&&t.Quaternion.FromRotationMatrix(null===(n=e._babylonTexture)||void 0===n?void 0:n.getReflectionTextureMatrix())},set:(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:e=>e._babylonTexture}}}}},animations:{length:{type:"number",get:e=>e.length,getTarget:e=>e.map(e=>e._babylonAnimationGroup),getPropertyName:[()=>"length"]},__array__:{}},meshes:{length:{type:"number",get:e=>e.length,getTarget:e=>e.map(e=>{var t;return null===(t=e.primitives[0]._instanceData)||void 0===t?void 0:t.babylonSourceMesh}),getPropertyName:[()=>"length"]},__array__:{}}};function de(e){return new ie(e,he)}function me(e){const t=e.split("/").map(e=>e.replace(/{}/g,"__array__"));let n=he;for(const e of t)e&&(n=n[e]);if(n&&n.type&&n.get)return n}function _e(e,t){const n=e.split("/").map(e=>e.replace(/{}/g,"__array__"));let r=he;for(const e of n)e&&(r=r[e]);r&&r.type&&r.get&&(r.interpolation=t)}function pe(e,t){const n=e.split("/").map(e=>e.replace(/{}/g,"__array__"));let r=he;for(const e of n)if(e){if(!r[e]){if("?"===e){r.__ignoreObjectTree__=!0;continue}r[e]={},"__array__"===e&&(r[e].__target__=!0)}r=r[e]}Object.assign(r,t)}const fe=new Map,ge=fe;function be(e,n,r){ye(e)&&t.Logger.Warn(`Extension with the name '${e}' already exists`),fe.set(e,{isGLTFExtension:n,factory:r})}function ye(e){return fe.delete(e)}const Te=new t.Lazy(()=>Promise.resolve(BABYLON)),xe=new t.Lazy(()=>Promise.resolve().then(function(){return ur}));class ve{static Get(e,t,n){if(!t||null==n||!t[n])throw new Error(`${e}: Failed to find index (${n})`);return t[n]}static TryGet(e,t){return e&&null!=t&&e[t]?e[t]:null}static Assign(e){if(e)for(let t=0;t<e.length;t++)e[t].index=t}}function Ae(e){if(e.min&&e.max){const n=e.min,r=e.max,s=t.TmpVectors.Vector3[0].copyFromFloats(n[0],n[1],n[2]),o=t.TmpVectors.Vector3[1].copyFromFloats(r[0],r[1],r[2]);if(e.normalized&&5126!==e.componentType){let t=1;switch(e.componentType){case 5120:t=127;break;case 5121:t=255;break;case 5122:t=32767;break;case 5123:t=65535}const n=1/t;s.scaleInPlace(n),o.scaleInPlace(n)}return new t.BoundingInfo(s,o)}return null}class Ce{isMatchingMaterialType(e){if(!e)return!1;const t=Array.from(this._pbrMaterialImpls.values());for(const n of t)if(e instanceof n.materialClass)return!0;return!1}static RegisterExtension(e,t){be(e,!1,t)}static UnregisterExtension(e){return ye(e)}get gltf(){if(!this._gltf)throw new Error("glTF JSON is not available");return this._gltf}get bin(){return this._bin}get parent(){return this._parent}get babylonScene(){if(!this._babylonScene)throw new Error("Scene is not available");return this._babylonScene}get rootBabylonMesh(){return this._rootBabylonMesh}get rootUrl(){return this._rootUrl}constructor(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}_getOrCreateMaterialAdapter(e){let t=this._materialAdapterCache.get(e);if(!t){const n=Array.from(this._pbrMaterialImpls.values());for(const r of n)if(e instanceof r.materialClass){t=new r.adapterClass(e);break}if(!t)throw new Error("Appropriate material adapter class not found");const r=t;this._materialAdapterCache.set(e,r),this._materialAdapters.add(r)}return t}dispose(){this._disposed||(this._disposed=!0,this._completePromises.length=0,this._extensions.forEach(e=>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())}importMeshAsync(e,t,n,r,s,o){return v(this,arguments,void 0,function*(e,t,n,r,s,o,a=""){return yield Promise.resolve().then(()=>v(this,void 0,void 0,function*(){this._babylonScene=t,this._assetContainer=n,this._loadData(r);let o=null;if(e){const t={};if(this._gltf.nodes)for(const e of this._gltf.nodes)e.name&&(t[e.name]=e.index);o=(e instanceof Array?e:[e]).map(e=>{const n=t[e];if(void 0===n)throw new Error(`Failed to find node '${e}'`);return n})}return yield this._loadAsync(s,a,o,()=>({meshes:this._getMeshes(),particleSystems:[],skeletons:this._getSkeletons(),animationGroups:this._getAnimationGroups(),lights:this._babylonLights,transformNodes:this._getTransformNodes(),geometries:this._getGeometries(),spriteManagers:[]}))}))})}loadAsync(e,t,n,r){return v(this,arguments,void 0,function*(e,t,n,r,s=""){return this._babylonScene=e,this._loadData(t),yield this._loadAsync(n,s,null,()=>{})})}_loadAsync(n,r,s,o){return v(this,void 0,void 0,function*(){return yield Promise.resolve().then(()=>v(this,void 0,void 0,function*(){var a;if(this._rootUrl=n,this._uniqueRootUrl=!n.startsWith("file:")&&r?n:`${n}${Date.now()}/`,this._fileName=r,this._allMaterialsDirtyRequired=!1,yield this._loadExtensionsAsync(),!this.parent.skipMaterials){const e=this.parent.useOpenPBR||this.isExtensionUsed("KHR_materials_openpbr");let t=!1;this.parent.useOpenPBR?(null===(a=this._gltf.materials)||void 0===a?void 0:a.length)&&this._gltf.materials.some(e=>{var t;return!(null===(t=e.extensions)||void 0===t?void 0:t.KHR_materials_openpbr)})&&(t=!0):t=!0;const n=[];e&&!this._pbrMaterialImpls.has("openpbr")&&n.push(Promise.all([Promise.resolve(BABYLON),Promise.resolve().then(function(){return Bs})]).then(([{OpenPBRMaterial:e,RegisterOpenpbrMaterial:t},{OpenPBRMaterialLoadingAdapter:n}])=>{t(),this._pbrMaterialImpls.set("openpbr",{materialClass:e,adapterClass:n})})),t&&!this._pbrMaterialImpls.has("pbr")&&n.push(Promise.all([Promise.resolve(BABYLON),Promise.resolve().then(function(){return Ds})]).then(([{PBRMaterial:e,RegisterPbrMaterial:t},{PBRMaterialLoadingAdapter:n}])=>{t(),this._pbrMaterialImpls.set("pbr",{materialClass:e,adapterClass:n})})),yield Promise.all(n)}const i=`${e.GLTFLoaderState[e.GLTFLoaderState.LOADING]} => ${e.GLTFLoaderState[e.GLTFLoaderState.READY]}`,l=`${e.GLTFLoaderState[e.GLTFLoaderState.LOADING]} => ${e.GLTFLoaderState[e.GLTFLoaderState.COMPLETE]}`;this._parent._startPerformanceCounter(i),this._parent._startPerformanceCounter(l),this._parent._setState(e.GLTFLoaderState.LOADING),this._extensionsOnLoading();const u=new Array,c=this._babylonScene.blockMaterialDirtyMechanism;if(this._babylonScene.blockMaterialDirtyMechanism=!0,!this.parent.loadOnlyMaterials)if(s)u.push(this.loadSceneAsync("/nodes",{nodes:s,index:-1}));else if(null!=this._gltf.scene||this._gltf.scenes&&this._gltf.scenes[0]){const e=ve.Get("/scene",this._gltf.scenes,this._gltf.scene||0);u.push(this.loadSceneAsync(`/scenes/${e.index}`,e))}if(!this.parent.skipMaterials&&this.parent.loadAllMaterials&&this._gltf.materials)for(let e=0;e<this._gltf.materials.length;++e){const n=this._gltf.materials[e],r="/materials/"+e,s=t.Material.TriangleFillMode;u.push(this._loadMaterialAsync(r,n,null,s,()=>{}))}this._allMaterialsDirtyRequired?this._babylonScene.blockMaterialDirtyMechanism=c:this._babylonScene._forceBlockMaterialDirtyMechanism(c),this._parent.compileMaterials&&u.push(this._compileMaterialsAsync()),this._parent.compileShadowGenerators&&u.push(this._compileShadowGeneratorsAsync());const h=Promise.all(u).then(()=>{this._rootBabylonMesh&&this._rootBabylonMesh!==this._parent.customRootNode&&this._rootBabylonMesh.setEnabled(!0);for(const e of this._babylonScene.materials){const t=e;void 0!==t.maxSimultaneousLights&&(t.maxSimultaneousLights=Math.max(t.maxSimultaneousLights,this._babylonScene.lights.length))}for(const e of Array.from(this._materialAdapters))this._completePromises.push(e.finalizeAsync(this));return this._extensionsOnReady(),this._parent._setState(e.GLTFLoaderState.READY),this._skipStartAnimationStep||this._startAnimations(),o()});return yield h.then(n=>(this._parent._endPerformanceCounter(i),t.Tools.SetImmediate(()=>{this._disposed||Promise.all(this._completePromises).then(()=>{this._parent._endPerformanceCounter(l),this._parent._setState(e.GLTFLoaderState.COMPLETE),this._parent.onCompleteObservable.notifyObservers(void 0),this._parent.onCompleteObservable.clear(),this.dispose()},e=>{this._parent.onErrorObservable.notifyObservers(e),this._parent.onErrorObservable.clear(),this.dispose()})}),n))})).catch(e=>{throw this._disposed||(this._parent.onErrorObservable.notifyObservers(e),this._parent.onErrorObservable.clear(),this.dispose()),e})})}_loadData(e){if(this._gltf=e.json,this._setupData(),e.bin){const n=this._gltf.buffers;if(n&&n[0]&&!n[0].uri){const r=n[0];(r.byteLength<e.bin.byteLength-3||r.byteLength>e.bin.byteLength)&&t.Logger.Warn(`Binary buffer length (${r.byteLength}) from JSON does not match chunk length (${e.bin.byteLength})`),this._bin=e.bin}else t.Logger.Warn("Unexpected BIN chunk")}}_setupData(){if(ve.Assign(this._gltf.accessors),ve.Assign(this._gltf.animations),ve.Assign(this._gltf.buffers),ve.Assign(this._gltf.bufferViews),ve.Assign(this._gltf.cameras),ve.Assign(this._gltf.images),ve.Assign(this._gltf.materials),ve.Assign(this._gltf.meshes),ve.Assign(this._gltf.nodes),ve.Assign(this._gltf.samplers),ve.Assign(this._gltf.scenes),ve.Assign(this._gltf.skins),ve.Assign(this._gltf.textures),this._gltf.nodes){const e={};for(const t of this._gltf.nodes)if(t.children)for(const n of t.children)e[n]=t.index;const t=this._createRootNode();for(const n of this._gltf.nodes){const r=e[n.index];n.parent=void 0===r?t:this._gltf.nodes[r]}}}_loadExtensionsAsync(){return v(this,void 0,void 0,function*(){var e;const n=[];if(ge.forEach((e,r)=>{var s;!1===(null===(s=this.parent.extensionOptions[r])||void 0===s?void 0:s.enabled)?e.isGLTFExtension&&this.isExtensionUsed(r)&&t.Logger.Warn(`Extension ${r} is used but has been explicitly disabled.`):e.isGLTFExtension&&!this.isExtensionUsed(r)||n.push((()=>v(this,void 0,void 0,function*(){const n=yield e.factory(this);return n.name!==r&&t.Logger.Warn(`The name of the glTF loader extension instance does not match the registered name: ${n.name} !== ${r}`),this._parent.onExtensionLoadedObservable.notifyObservers(n),n}))())}),this._extensions.push(...yield Promise.all(n)),this._extensions.sort((e,t)=>(e.order||Number.MAX_VALUE)-(t.order||Number.MAX_VALUE)),this._parent.onExtensionLoadedObservable.clear(),this._gltf.extensionsRequired)for(const t of this._gltf.extensionsRequired)if(!this._extensions.some(e=>e.name===t&&e.enabled)){if(!1===(null===(e=this.parent.extensionOptions[t])||void 0===e?void 0:e.enabled))throw new Error(`Required extension ${t} is disabled`);throw new Error(`Required extension ${t} is not available`)}})}_createRootNode(){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;const n=new t.Mesh("__root__",this._babylonScene);this._rootBabylonMesh=n,this._rootBabylonMesh._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,this._rootBabylonMesh.setEnabled(!1);const r={_babylonTransformNode:this._rootBabylonMesh,index:-1};switch(this._parent.coordinateSystemMode){case e.GLTFLoaderCoordinateSystemMode.AUTO:this._babylonScene.useRightHandedSystem||(r.rotation=[0,1,0,0],r.scale=[1,1,-1],Ce._LoadTransform(r,this._rootBabylonMesh));break;case e.GLTFLoaderCoordinateSystemMode.FORCE_RIGHT_HANDED:this._babylonScene.useRightHandedSystem=!0;break;default:throw new Error(`Invalid coordinate system mode (${this._parent.coordinateSystemMode})`)}return this._parent.onMeshLoadedObservable.notifyObservers(n),r}loadSceneAsync(e,t){const n=this._extensionsLoadSceneAsync(e,t);if(n)return n;const r=new Array;if(this.logOpen(`${e} ${t.name||""}`),t.nodes)for(const n of t.nodes){const t=ve.Get(`${e}/nodes/${n}`,this._gltf.nodes,n);r.push(this.loadNodeAsync(`/nodes/${t.index}`,t,e=>{e.parent=this._rootBabylonMesh}))}for(const e of this._postSceneLoadActions)e();return r.push(this._loadAnimationsAsync()),this.logClose(),Promise.all(r).then(()=>{})}_forEachPrimitive(e,t){if(e._primitiveBabylonMeshes)for(const n of e._primitiveBabylonMeshes)t(n)}_getGeometries(){const e=[],t=this._gltf.nodes;if(t)for(const n of t)this._forEachPrimitive(n,t=>{const n=t.geometry;n&&-1===e.indexOf(n)&&e.push(n)});return e}_getMeshes(){const e=[];this._rootBabylonMesh instanceof t.AbstractMesh&&e.push(this._rootBabylonMesh);const n=this._gltf.nodes;if(n)for(const t of n)this._forEachPrimitive(t,t=>{e.push(t)});return e}_getTransformNodes(){const e=[],t=this._gltf.nodes;if(t)for(const n of t)n._babylonTransformNode&&"TransformNode"===n._babylonTransformNode.getClassName()&&e.push(n._babylonTransformNode),n._babylonTransformNodeForSkin&&e.push(n._babylonTransformNodeForSkin);return e}_getSkeletons(){const e=[],t=this._gltf.skins;if(t)for(const n of t)n._data&&e.push(n._data.babylonSkeleton);return e}_getAnimationGroups(){const e=[],t=this._gltf.animations;if(t)for(const n of t)n._babylonAnimationGroup&&e.push(n._babylonAnimationGroup);return e}_startAnimations(){switch(this._parent.animationStartMode){case e.GLTFLoaderAnimationStartMode.NONE:break;case e.GLTFLoaderAnimationStartMode.FIRST:{const e=this._getAnimationGroups();0!==e.length&&e[0].start(!0);break}case e.GLTFLoaderAnimationStartMode.ALL:{const e=this._getAnimationGroups();for(const t of e)t.start(!0);break}default:return void t.Logger.Error(`Invalid animation start mode (${this._parent.animationStartMode})`)}}loadNodeAsync(e,n,r=()=>{}){const s=this._extensionsLoadNodeAsync(e,n,r);if(s)return s;if(n._babylonTransformNode)throw new Error(`${e}: Invalid recursive node hierarchy`);const o=new Array;this.logOpen(`${e} ${n.name||""}`);const a=t=>{if(Ce.AddPointerMetadata(t,e),Ce._LoadTransform(n,t),null!=n.camera){const r=ve.Get(`${e}/camera`,this._gltf.cameras,n.camera);o.push(this.loadCameraAsync(`/cameras/${r.index}`,r,e=>{e.parent=t,this._babylonScene.useRightHandedSystem||(t.scaling.x=-1)}))}if(n.children)for(const r of n.children){const n=ve.Get(`${e}/children/${r}`,this._gltf.nodes,r);o.push(this.loadNodeAsync(`/nodes/${n.index}`,n,e=>{e.parent=t}))}r(t)},i=null!=n.mesh,l=this._parent.loadSkins&&null!=n.skin;if(!i||l){const e=n.name||`node${n.index}`;this._babylonScene._blockEntityCollection=!!this._assetContainer;const r=new t.TransformNode(e,this._babylonScene);r._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,null==n.mesh?n._babylonTransformNode=r:n._babylonTransformNodeForSkin=r,a(r)}if(i)if(l){const r=ve.Get(`${e}/mesh`,this._gltf.meshes,n.mesh);o.push(this._loadMeshAsync(`/meshes/${r.index}`,n,r,r=>{const s=n._babylonTransformNodeForSkin;r.metadata=t.deepMerge(s.metadata,r.metadata||{});const a=ve.Get(`${e}/skin`,this._gltf.skins,n.skin);o.push(this._loadSkinAsync(`/skins/${a.index}`,n,a,e=>{this._forEachPrimitive(n,t=>{t.skeleton=e}),this._postSceneLoadActions.push(()=>{if(null!=a.skeleton){const e=ve.Get(`/skins/${a.index}/skeleton`,this._gltf.nodes,a.skeleton).parent;n.index===e.index?r.parent=s.parent:r.parent=e._babylonTransformNode}else r.parent=this._rootBabylonMesh;this._parent.onSkinLoadedObservable.notifyObservers({node:s,skinnedNode:r})})}))}))}else{const t=ve.Get(`${e}/mesh`,this._gltf.meshes,n.mesh);o.push(this._loadMeshAsync(`/meshes/${t.index}`,n,t,a))}return this.logClose(),Promise.all(o).then(()=>(this._forEachPrimitive(n,e=>{const t=e;!t.isAnInstance&&t.geometry&&t.geometry.useBoundingInfoFromGeometry?e._updateBoundingInfo():e.refreshBoundingInfo(!0,!0)}),n._babylonTransformNode))}_loadMeshAsync(e,n,r,s){const o=r.primitives;if(!o||!o.length)throw new Error(`${e}: Primitives are missing`);null==o[0].index&&ve.Assign(o);const a=new Array;this.logOpen(`${e} ${r.name||""}`);const i=n.name||`node${n.index}`;if(1===o.length){const t=r.primitives[0];a.push(this._loadMeshPrimitiveAsync(`${e}/primitives/${t.index}`,i,n,r,t,e=>{n._babylonTransformNode=e,n._primitiveBabylonMeshes=[e]}))}else{this._babylonScene._blockEntityCollection=!!this._assetContainer,n._babylonTransformNode=new t.TransformNode(i,this._babylonScene),n._babylonTransformNode._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,n._primitiveBabylonMeshes=[];for(const t of o)a.push(this._loadMeshPrimitiveAsync(`${e}/primitives/${t.index}`,`${i}_primitive${t.index}`,n,r,t,e=>{e.parent=n._babylonTransformNode,n._primitiveBabylonMeshes.push(e)}))}return s(n._babylonTransformNode),this.logClose(),Promise.all(a).then(()=>n._babylonTransformNode)}_loadMeshPrimitiveAsync(e,n,r,s,o,a){const i=this._extensionsLoadMeshPrimitiveAsync(e,n,r,s,o,a);if(i)return i;this.logOpen(`${e}`);const l=0===this._disableInstancedMesh&&this._parent.createInstances&&null==r.skin&&!s.primitives[0].targets;let u,c;if(l&&o._instanceData)this._babylonScene._blockEntityCollection=!!this._assetContainer,u=o._instanceData.babylonSourceMesh.createInstance(n),u._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,c=o._instanceData.promise;else{const a=new Array;this._babylonScene._blockEntityCollection=!!this._assetContainer;const i=new t.Mesh(n,this._babylonScene);if(i._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,i.sideOrientation=this._babylonScene.useRightHandedSystem?t.Material.CounterClockWiseSideOrientation:t.Material.ClockWiseSideOrientation,this._createMorphTargets(e,r,s,o,i),a.push(this._loadVertexDataAsync(e,o,i).then(t=>v(this,void 0,void 0,function*(){return yield this._loadMorphTargetsAsync(e,o,i,t).then(()=>{this._disposed||(this._babylonScene._blockEntityCollection=!!this._assetContainer,t.applyToMesh(i),t._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1)})}))),!this.parent.skipMaterials){const t=Ce._GetDrawMode(e,o.mode);if(null==o.material){let e=this._defaultBabylonMaterialData[t];e||(e=this._createDefaultMaterial("__GLTFLoader._default",t,this._getDefaultImpl()),this._parent.onMaterialLoadedObservable.notifyObservers(e),this._defaultBabylonMaterialData[t]=e),i.material=e}else{const n=ve.Get(`${e}/material`,this._gltf.materials,o.material);a.push(this._loadMaterialAsync(`/materials/${n.index}`,n,i,t,e=>{i.material=e}))}}c=Promise.all(a),l&&(o._instanceData={babylonSourceMesh:i,promise:c}),u=i}return Ce.AddPointerMetadata(u,e),this._parent.onMeshLoadedObservable.notifyObservers(u),a(u),this.logClose(),c.then(()=>u)}_loadVertexDataAsync(e,n,r){const s=this._extensionsLoadVertexDataAsync(e,n,r);if(s)return s;const o=n.attributes;if(!o)throw new Error(`${e}: Attributes are missing`);const a=new Array,i=new t.Geometry(r.name,this._babylonScene);if(null==n.indices)r.isUnIndexed=!0;else{const t=ve.Get(`${e}/indices`,this._gltf.accessors,n.indices);a.push(this._loadIndicesAccessorAsync(`/accessors/${t.index}`,t).then(e=>{i.setIndices(e)}))}const l=(n,s,l)=>{if(null==o[n])return;r._delayInfo=r._delayInfo||[],-1===r._delayInfo.indexOf(s)&&r._delayInfo.push(s);const u=ve.Get(`${e}/attributes/${n}`,this._gltf.accessors,o[n]);a.push(this._loadVertexAccessorAsync(`/accessors/${u.index}`,u,s).then(e=>{if(e.getKind()===t.VertexBuffer.PositionKind&&!this.parent.alwaysComputeBoundingBox&&!r.skeleton){const e=Ae(u);e&&(i._boundingInfo=e,i.useBoundingInfoFromGeometry=!0)}i.setVerticesBuffer(e,u.count)})),s==t.VertexBuffer.MatricesIndicesExtraKind&&(r.numBoneInfluencers=8),l&&l(u)};return l("POSITION",t.VertexBuffer.PositionKind),l("NORMAL",t.VertexBuffer.NormalKind),l("TANGENT",t.VertexBuffer.TangentKind),l("TEXCOORD_0",t.VertexBuffer.UVKind),l("TEXCOORD_1",t.VertexBuffer.UV2Kind),l("TEXCOORD_2",t.VertexBuffer.UV3Kind),l("TEXCOORD_3",t.VertexBuffer.UV4Kind),l("TEXCOORD_4",t.VertexBuffer.UV5Kind),l("TEXCOORD_5",t.VertexBuffer.UV6Kind),l("JOINTS_0",t.VertexBuffer.MatricesIndicesKind),l("WEIGHTS_0",t.VertexBuffer.MatricesWeightsKind),l("JOINTS_1",t.VertexBuffer.MatricesIndicesExtraKind),l("WEIGHTS_1",t.VertexBuffer.MatricesWeightsExtraKind),l("COLOR_0",t.VertexBuffer.ColorKind,e=>{"VEC4"===e.type&&(r.hasVertexAlpha=!0)}),Promise.all(a).then(()=>i)}_createMorphTargets(e,n,r,s,o){if(!s.targets||!this._parent.loadMorphTargets)return;if(null==n._numMorphTargets)n._numMorphTargets=s.targets.length;else if(s.targets.length!==n._numMorphTargets)throw new Error(`${e}: Primitives do not have the same number of targets`);const a=r.extras?r.extras.targetNames:null;this._babylonScene._blockEntityCollection=!!this._assetContainer,o.morphTargetManager=new t.MorphTargetManager(this._babylonScene),o.morphTargetManager._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,o.morphTargetManager.areUpdatesFrozen=!0;for(let e=0;e<s.targets.length;e++){const s=n.weights?n.weights[e]:r.weights?r.weights[e]:0,i=a?a[e]:`morphTarget${e}`;o.morphTargetManager.addTarget(new t.MorphTarget(i,s,o.getScene()))}}_loadMorphTargetsAsync(e,n,r,s){if(!n.targets||!this._parent.loadMorphTargets)return Promise.resolve();const o=new Array,a=r.morphTargetManager;for(let t=0;t<a.numTargets;t++){const r=a.getTarget(t);o.push(this._loadMorphTargetVertexDataAsync(`${e}/targets/${t}`,s,n.targets[t],r))}return Promise.all(o).then(()=>{a.areUpdatesFrozen=!1,this._parent.useMaxMorphTargetInfluencers&&(a.isUsingTextureForTargets||a.numTargets<=t.MorphTargetManager.MaxActiveMorphTargetsInVertexAttributeMode)&&(a.optimizeInfluencers=!1,a.numMaxInfluencers=a.numTargets)})}_loadMorphTargetVertexDataAsync(e,n,r,s){return v(this,void 0,void 0,function*(){const o=new Array,a=(t,s,a)=>{if(null==r[t])return;const i=n.getVertexBuffer(s);if(!i)return;const l=ve.Get(`${e}/${t}`,this._gltf.accessors,r[t]);o.push(this._loadFloatAccessorAsync(`/accessors/${l.index}`,l).then(e=>{a(i,e)}))};return a("POSITION",t.VertexBuffer.PositionKind,(e,t)=>{const n=new Float32Array(t.length);e.forEach(t.length,(e,r)=>{n[r]=t[r]+e}),s.setPositions(n)}),a("NORMAL",t.VertexBuffer.NormalKind,(e,t)=>{const n=new Float32Array(t.length);e.forEach(n.length,(e,r)=>{n[r]=t[r]+e}),s.setNormals(n)}),a("TANGENT",t.VertexBuffer.TangentKind,(e,t)=>{const n=new Float32Array(t.length/3*4);let r=0;e.forEach(t.length/3*4,(e,s)=>{(s+1)%4!=0&&(n[r]=t[r]+e,r++)}),s.setTangents(n)}),a("TEXCOORD_0",t.VertexBuffer.UVKind,(e,t)=>{const n=new Float32Array(t.length);e.forEach(t.length,(e,r)=>{n[r]=t[r]+e}),s.setUVs(n)}),a("TEXCOORD_1",t.VertexBuffer.UV2Kind,(e,t)=>{const n=new Float32Array(t.length);e.forEach(t.length,(e,r)=>{n[r]=t[r]+e}),s.setUV2s(n)}),a("COLOR_0",t.VertexBuffer.ColorKind,(t,n)=>{let r=null;const o=t.getSize();if(3===o){r=new Float32Array(n.length/3*4),t.forEach(n.length,(e,t)=>{const s=Math.floor(t/3),o=t%3;r[4*s+o]=n[3*s+o]+e});for(let e=0;e<n.length/3;++e)r[4*e+3]=1}else{if(4!==o)throw new Error(`${e}: Invalid number of components (${o}) for COLOR_0 attribute`);r=new Float32Array(n.length),t.forEach(n.length,(e,t)=>{r[t]=n[t]+e})}s.setColors(r)}),yield Promise.all(o).then(()=>{})})}static _LoadTransform(e,n){if(null!=e.skin)return;let r=t.Vector3.Zero(),s=t.Quaternion.Identity(),o=t.Vector3.One();e.matrix?t.Matrix.FromArray(e.matrix).decompose(o,s,r):(e.translation&&(r=t.Vector3.FromArray(e.translation)),e.rotation&&(s=t.Quaternion.FromArray(e.rotation)),e.scale&&(o=t.Vector3.FromArray(e.scale))),n.position=r,n.rotationQuaternion=s,n.scaling=o}_loadSkinAsync(e,n,r,s){if(!this._parent.loadSkins)return Promise.resolve();const o=this._extensionsLoadSkinAsync(e,n,r);if(o)return o;if(r._data)return s(r._data.babylonSkeleton),r._data.promise;const a=`skeleton${r.index}`;this._babylonScene._blockEntityCollection=!!this._assetContainer;const i=new t.Skeleton(r.name||a,a,this._babylonScene);i._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,this._loadBones(e,r,i);const l=this._loadSkinInverseBindMatricesDataAsync(e,r).then(e=>{this._updateBoneMatrices(i,e)});return r._data={babylonSkeleton:i,promise:l},s(i),l}_loadBones(e,n,r){if(null==n.skeleton||this._parent.alwaysComputeSkeletonRootNode){const r=this._findSkeletonRootNode(`${e}/joints`,n.joints);if(r)if(void 0===n.skeleton)n.skeleton=r.index;else{const s=(e,t)=>{for(;t.parent;t=t.parent)if(t.parent===e)return!0;return!1},o=ve.Get(`${e}/skeleton`,this._gltf.nodes,n.skeleton);o===r||s(o,r)||(t.Logger.Warn(`${e}/skeleton: Overriding with nearest common ancestor as skeleton node is not a common root`),n.skeleton=r.index)}else t.Logger.Warn(`${e}: Failed to find common root`)}const s={};for(const t of n.joints){const o=ve.Get(`${e}/joints/${t}`,this._gltf.nodes,t);this._loadBone(o,n,r,s)}}_findSkeletonRootNode(e,t){if(0===t.length)return null;const n={};for(const r of t){const t=[];let s=ve.Get(`${e}/${r}`,this._gltf.nodes,r);for(;-1!==s.index;)t.unshift(s),s=s.parent;n[r]=t}let r=null;for(let e=0;;++e){let s=n[t[0]];if(e>=s.length)return r;const o=s[e];for(let a=1;a<t.length;++a)if(s=n[t[a]],e>=s.length||o!==s[e])return r;r=o}}_loadBone(e,n,r,s){e._isJoint=!0;let o=s[e.index];if(o)return o;let a=null;e.index!==n.skeleton&&(e.parent&&-1!==e.parent.index?a=this._loadBone(e.parent,n,r,s):void 0!==n.skeleton&&t.Logger.Warn(`/skins/${n.index}/skeleton: Skeleton node is not a common root`));const i=n.joints.indexOf(e.index);return o=new t.Bone(e.name||`joint${e.index}`,r,a,this._getNodeMatrix(e),null,null,i),s[e.index]=o,this._postSceneLoadActions.push(()=>{o.linkTransformNode(e._babylonTransformNode)}),o}_loadSkinInverseBindMatricesDataAsync(e,t){if(null==t.inverseBindMatrices)return Promise.resolve(null);const n=ve.Get(`${e}/inverseBindMatrices`,this._gltf.accessors,t.inverseBindMatrices);return this._loadFloatAccessorAsync(`/accessors/${n.index}`,n)}_updateBoneMatrices(e,n){for(const r of e.bones){const e=t.Matrix.Identity(),s=r._index;n&&-1!==s&&(t.Matrix.FromArrayToRef(n,16*s,e),e.invertToRef(e));const o=r.getParent();o&&e.multiplyToRef(o.getAbsoluteInverseBindMatrix(),e),r.updateMatrix(e,!1,!1),r._updateAbsoluteBindMatrices(void 0,!1)}}_getNodeMatrix(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())}loadCameraAsync(e,n,r=()=>{}){const s=this._extensionsLoadCameraAsync(e,n,r);if(s)return s;const o=new Array;this.logOpen(`${e} ${n.name||""}`),this._babylonScene._blockEntityCollection=!!this._assetContainer;const a=new t.FreeCamera(n.name||`camera${n.index}`,t.Vector3.Zero(),this._babylonScene,!1);switch(a._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,n._babylonCamera=a,a.setTarget(new t.Vector3(0,0,-1)),n.type){case"perspective":{const t=n.perspective;if(!t)throw new Error(`${e}: Camera perspective properties are missing`);a.fov=t.yfov,a.minZ=t.znear,a.maxZ=t.zfar||0;break}case"orthographic":if(!n.orthographic)throw new Error(`${e}: Camera orthographic properties are missing`);a.mode=t.Camera.ORTHOGRAPHIC_CAMERA,a.orthoLeft=-n.orthographic.xmag,a.orthoRight=n.orthographic.xmag,a.orthoBottom=-n.orthographic.ymag,a.orthoTop=n.orthographic.ymag,a.minZ=n.orthographic.znear,a.maxZ=n.orthographic.zfar;break;default:throw new Error(`${e}: Invalid camera type (${n.type})`)}return Ce.AddPointerMetadata(a,e),this._parent.onCameraLoadedObservable.notifyObservers(a),r(a),this.logClose(),Promise.all(o).then(()=>a)}_loadAnimationsAsync(){this._parent._startPerformanceCounter("Load animations");const e=this._gltf.animations;if(!e)return Promise.resolve();const t=new Array;for(let n=0;n<e.length;n++){const r=e[n];t.push(this.loadAnimationAsync(`/animations/${r.index}`,r).then(e=>{0===e.targetedAnimations.length&&e.dispose()}))}return Promise.all(t).then(()=>{this._parent._endPerformanceCounter("Load animations")})}loadAnimationAsync(e,t){this._parent._startPerformanceCounter("Load animation");return this._extensionsLoadAnimationAsync(e,t)||Te.value.then(({AnimationGroup:n})=>{this._babylonScene._blockEntityCollection=!!this._assetContainer;const r=new n(t.name||`animation${t.index}`,this._babylonScene);r._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,t._babylonAnimationGroup=r;const s=new Array;ve.Assign(t.channels),ve.Assign(t.samplers);for(const n of t.channels)s.push(this._loadAnimationChannelAsync(`${e}/channels/${n.index}`,e,t,n,(e,t)=>{e.animations=e.animations||[],e.animations.push(t),r.addTargetedAnimation(t,e)}));return this._parent._endPerformanceCounter("Load animation"),Promise.all(s).then(()=>(r.normalize(0),r))})}_loadAnimationChannelAsync(e,t,n,r,s){const o=this._extensionsLoadAnimationChannelAsync(e,t,n,r,s);if(o)return o;if(null==r.target.node)return Promise.resolve();const a=ve.Get(`${e}/target/node`,this._gltf.nodes,r.target.node),i=r.target.path,l="weights"===i;return l&&!a._numMorphTargets||!l&&!a._babylonTransformNode?Promise.resolve():this._parent.loadNodeAnimations||l||a._isJoint?xe.value.then(()=>{var o,l,u,c;let h;switch(i){case"translation":h=null===(o=me("/nodes/{}/translation"))||void 0===o?void 0:o.interpolation;break;case"rotation":h=null===(l=me("/nodes/{}/rotation"))||void 0===l?void 0:l.interpolation;break;case"scale":h=null===(u=me("/nodes/{}/scale"))||void 0===u?void 0:u.interpolation;break;case"weights":h=null===(c=me("/nodes/{}/weights"))||void 0===c?void 0:c.interpolation;break;default:throw new Error(`${e}/target/path: Invalid value (${r.target.path})`)}if(!h)throw new Error(`${e}/target/path: Could not find interpolation properties for target path (${r.target.path})`);const d={object:a,info:h};return this._loadAnimationChannelFromTargetInfoAsync(e,t,n,r,d,s)}):Promise.resolve()}_loadAnimationChannelFromTargetInfoAsync(e,t,n,r,s,o){const a=this.parent.targetFps,i=1/a,l=ve.Get(`${e}/sampler`,n.samplers,r.sampler);return this._loadAnimationSamplerAsync(`${t}/samplers/${r.sampler}`,l).then(e=>{let t=0;const l=s.object,u=s.info;for(const s of u){const u=s.getStride(l),c=e.input,h=e.output,d=new Array(c.length);let m=0;switch(e.interpolation){case"STEP":for(let e=0;e<c.length;e++){const t=s.getValue(l,h,m,1);m+=u,d[e]={frame:c[e]*a,value:t,interpolation:1}}break;case"CUBICSPLINE":for(let e=0;e<c.length;e++){const t=s.getValue(l,h,m,i);m+=u;const n=s.getValue(l,h,m,1);m+=u;const r=s.getValue(l,h,m,i);m+=u,d[e]={frame:c[e]*a,inTangent:t,value:n,outTangent:r}}break;case"LINEAR":for(let e=0;e<c.length;e++){const t=s.getValue(l,h,m,1);m+=u,d[e]={frame:c[e]*a,value:t}}}if(m>0){const e=`${n.name||`animation${n.index}`}_channel${r.index}_${t}`,i=s.buildAnimations(l,e,a,d);for(const e of i)t++,o(e.babylonAnimatable,e.babylonAnimation)}}})}_loadAnimationSamplerAsync(e,t){if(t._data)return t._data;const n=t.interpolation||"LINEAR";switch(n){case"STEP":case"LINEAR":case"CUBICSPLINE":break;default:throw new Error(`${e}/interpolation: Invalid value (${t.interpolation})`)}const r=ve.Get(`${e}/input`,this._gltf.accessors,t.input),s=ve.Get(`${e}/output`,this._gltf.accessors,t.output);return t._data=Promise.all([this._loadFloatAccessorAsync(`/accessors/${r.index}`,r),this._loadFloatAccessorAsync(`/accessors/${s.index}`,s)]).then(([e,t])=>({input:e,interpolation:n,output:t})),t._data}loadBufferAsync(e,t,n,r){const s=this._extensionsLoadBufferAsync(e,t,n,r);if(s)return s;if(!t._data)if(t.uri)t._data=this.loadUriAsync(`${e}/uri`,t,t.uri);else{if(!this._bin)throw new Error(`${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(t=>{try{return new Uint8Array(t.buffer,t.byteOffset+n,r)}catch(t){throw new Error(`${e}: ${t.message}`,{cause:t})}})}loadBufferViewAsync(e,t){const n=this._extensionsLoadBufferViewAsync(e,t);if(n)return n;if(t._data)return t._data;const r=ve.Get(`${e}/buffer`,this._gltf.buffers,t.buffer);return t._data=this.loadBufferAsync(`/buffers/${r.index}`,r,t.byteOffset||0,t.byteLength),t._data}_loadAccessorAsync(e,n,r){if(n._data)return n._data;const s=Ce._GetNumComponents(e,n.type),o=s*t.VertexBufferGetTypeByteLength(n.componentType),a=s*n.count;if(null==n.bufferView)n._data=Promise.resolve(new r(a));else{const i=ve.Get(`${e}/bufferView`,this._gltf.bufferViews,n.bufferView);n._data=this.loadBufferViewAsync(`/bufferViews/${i.index}`,i).then(l=>{if(5126!==n.componentType||n.normalized||i.byteStride&&i.byteStride!==o){const e=new r(a);return t.VertexBufferForEach(l,n.byteOffset||0,i.byteStride||o,s,n.componentType,e.length,n.normalized||!1,(t,n)=>{e[n]=t}),e}return Ce._GetTypedArray(e,n.componentType,l,n.byteOffset,a)})}if(n.sparse){const a=n.sparse;n._data=n._data.then(i=>{const l=i,u=ve.Get(`${e}/sparse/indices/bufferView`,this._gltf.bufferViews,a.indices.bufferView),c=ve.Get(`${e}/sparse/values/bufferView`,this._gltf.bufferViews,a.values.bufferView);return Promise.all([this.loadBufferViewAsync(`/bufferViews/${u.index}`,u),this.loadBufferViewAsync(`/bufferViews/${c.index}`,c)]).then(([i,u])=>{const c=Ce._GetTypedArray(`${e}/sparse/indices`,a.indices.componentType,i,a.indices.byteOffset,a.count),h=s*a.count;let d;if(5126!==n.componentType||n.normalized){const i=Ce._GetTypedArray(`${e}/sparse/values`,n.componentType,u,a.values.byteOffset,h);d=new r(h),t.VertexBufferForEach(i,0,o,s,n.componentType,d.length,n.normalized||!1,(e,t)=>{d[t]=e})}else d=Ce._GetTypedArray(`${e}/sparse/values`,n.componentType,u,a.values.byteOffset,h);let m=0;for(let e=0;e<c.length;e++){let t=c[e]*s;for(let e=0;e<s;e++)l[t++]=d[m++]}return l})})}return n._data}_loadFloatAccessorAsync(e,t){return this._loadAccessorAsync(e,t,Float32Array)}_loadIndicesAccessorAsync(e,t){if("SCALAR"!==t.type)throw new Error(`${e}/type: Invalid value ${t.type}`);if(5121!==t.componentType&&5123!==t.componentType&&5125!==t.componentType)throw new Error(`${e}/componentType: Invalid value ${t.componentType}`);if(t._data)return t._data;if(t.sparse){const n=Ce._GetTypedArrayConstructor(`${e}/componentType`,t.componentType);t._data=this._loadAccessorAsync(e,t,n)}else{const n=ve.Get(`${e}/bufferView`,this._gltf.bufferViews,t.bufferView);t._data=this.loadBufferViewAsync(`/bufferViews/${n.index}`,n).then(n=>Ce._GetTypedArray(e,t.componentType,n,t.byteOffset,t.count))}return t._data}_loadVertexBufferViewAsync(e){if(e._babylonBuffer)return e._babylonBuffer;const n=this._babylonScene.getEngine();return e._babylonBuffer=this.loadBufferViewAsync(`/bufferViews/${e.index}`,e).then(e=>new t.Buffer(n,e,!1)),e._babylonBuffer}_loadVertexAccessorAsync(e,n,r){var s;if(null===(s=n._babylonVertexBuffer)||void 0===s?void 0:s[r])return n._babylonVertexBuffer[r];n._babylonVertexBuffer||(n._babylonVertexBuffer={});const o=this._babylonScene.getEngine();if(n.sparse||null==n.bufferView)n._babylonVertexBuffer[r]=this._loadFloatAccessorAsync(e,n).then(e=>new t.VertexBuffer(o,e,r,!1));else{const s=ve.Get(`${e}/bufferView`,this._gltf.bufferViews,n.bufferView);n._babylonVertexBuffer[r]=this._loadVertexBufferViewAsync(s).then(a=>{const i=Ce._GetNumComponents(e,n.type);return new t.VertexBuffer(o,a,r,!1,void 0,s.byteStride,void 0,n.byteOffset,i,n.componentType,n.normalized,!0,void 0,!0)})}return n._babylonVertexBuffer[r]}_loadMaterialMetallicRoughnessPropertiesAsync(e,n,r){const s=new Array,o=this._getOrCreateMaterialAdapter(r);return n&&(n.baseColorFactor?(o.baseColor=t.Color3.FromArray(n.baseColorFactor),o.geometryOpacity=n.baseColorFactor[3]):o.baseColor=t.Color3.White(),o.baseMetalness=null==n.metallicFactor?1:n.metallicFactor,o.specularRoughness=null==n.roughnessFactor?1:n.roughnessFactor,n.baseColorTexture&&s.push(this.loadTextureInfoAsync(`${e}/baseColorTexture`,n.baseColorTexture,e=>{e.name=`${r.name} (Base Color)`,o.baseColorTexture=e})),n.metallicRoughnessTexture&&(n.metallicRoughnessTexture.nonColorData=!0,s.push(this.loadTextureInfoAsync(`${e}/metallicRoughnessTexture`,n.metallicRoughnessTexture,e=>{e.name=`${r.name} (Metallic Roughness)`,o.baseMetalnessTexture=e,o.specularRoughnessTexture=e})),o.useRoughnessFromMetallicTextureGreen=!0,o.useMetallicFromMetallicTextureBlue=!0)),Promise.all(s).then(()=>{})}_loadMaterialAsync(e,t,n,r,s=()=>{}){const o=this._extensionsLoadMaterialAsync(e,t,n,r,s);if(o)return o;t._data=t._data||{};let a=t._data[r];if(!a){this.logOpen(`${e} ${t.name||""}`);const n=this.createMaterial(e,t,r);a={babylonMaterial:n,babylonMeshes:[],promise:this.loadMaterialPropertiesAsync(e,t,n)},t._data[r]=a,Ce.AddPointerMetadata(n,e),this._parent.onMaterialLoadedObservable.notifyObservers(n),this.logClose()}return n&&(a.babylonMeshes.push(n),n.onDisposeObservable.addOnce(()=>{const e=a.babylonMeshes.indexOf(n);-1!==e&&a.babylonMeshes.splice(e,1)})),s(a.babylonMaterial),a.promise.then(()=>a.babylonMaterial)}_selectImplForGltfMaterial(e){var t;if(this.parent.useOpenPBR||(null===(t=e.extensions)||void 0===t?void 0:t.KHR_materials_openpbr)){const e=this._pbrMaterialImpls.get("openpbr");if(e)return e}const n=this._pbrMaterialImpls.get("pbr");if(n)return n;throw new Error("No PBR material implementation loaded")}_getDefaultImpl(){var e;if(this.parent.useOpenPBR){const e=this._pbrMaterialImpls.get("openpbr");if(e)return e}const t=null!==(e=this._pbrMaterialImpls.get("pbr"))&&void 0!==e?e:this._pbrMaterialImpls.values().next().value;if(t)return t;throw new Error("No PBR material implementation loaded")}_createDefaultMaterial(e,t,n){this._babylonScene._blockEntityCollection=!!this._assetContainer;const r=new n.materialClass(e,this._babylonScene);r._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,r.fillMode=t,r.transparencyMode=n.materialClass.MATERIAL_OPAQUE;const s=this._getOrCreateMaterialAdapter(r);return s.transparencyAsAlphaCoverage=this._parent.transparencyAsCoverage,s.baseMetalness=1,s.specularRoughness=1,r}createMaterial(e,t,n){const r=this._extensionsCreateMaterial(e,t,n);if(r)return r;const s=t.name||`material${t.index}`;return this._createDefaultMaterial(s,n,this._selectImplForGltfMaterial(t))}loadMaterialPropertiesAsync(e,t,n){const r=this._extensionsLoadMaterialPropertiesAsync(e,t,n);if(r)return r;const s=new Array;return s.push(this.loadMaterialBasePropertiesAsync(e,t,n)),t.pbrMetallicRoughness&&s.push(this._loadMaterialMetallicRoughnessPropertiesAsync(`${e}/pbrMetallicRoughness`,t.pbrMetallicRoughness,n)),this.loadMaterialAlphaProperties(e,t,n),Promise.all(s).then(()=>{})}loadMaterialBasePropertiesAsync(e,n,r){const s=new Array,o=this._getOrCreateMaterialAdapter(r);let a;o.emissionColor=n.emissiveFactor?t.Color3.FromArray(n.emissiveFactor):new t.Color3(0,0,0),n.doubleSided&&(o.backFaceCulling=!1,o.twoSidedLighting=!0),n.normalTexture&&(n.normalTexture.nonColorData=!0,s.push(this.loadTextureInfoAsync(`${e}/normalTexture`,n.normalTexture,e=>{var t;e.name=`${r.name} (Normal)`,o.geometryNormalTexture=e,null!=(null===(t=n.normalTexture)||void 0===t?void 0:t.scale)&&(e.level=n.normalTexture.scale)})),o.setNormalMapInversions(!this._babylonScene.useRightHandedSystem,this._babylonScene.useRightHandedSystem));let i,l=1;return n.occlusionTexture&&(n.occlusionTexture.nonColorData=!0,s.push(this.loadTextureInfoAsync(`${e}/occlusionTexture`,n.occlusionTexture,e=>{e.name=`${r.name} (Occlusion)`,a=e})),null!=n.occlusionTexture.strength&&(l=n.occlusionTexture.strength)),n.emissiveTexture&&s.push(this.loadTextureInfoAsync(`${e}/emissiveTexture`,n.emissiveTexture,e=>{e.name=`${r.name} (Emissive)`,i=e})),Promise.all(s).then(()=>{a&&(o.ambientOcclusionTexture=a,o.ambientOcclusionTextureStrength=l),i&&(o.emissionColorTexture=i)})}loadMaterialAlphaProperties(e,n,r){if(0===this._pbrMaterialImpls.size)throw new Error(`${e}: Material type not supported`);const s=this._getOrCreateMaterialAdapter(r),o=s.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,s.alphaCutOff=null==n.alphaCutoff?.5:n.alphaCutoff,o&&(o.hasAlpha=!0,s.useAlphaFromBaseColorTexture=!0);break;case"BLEND":r.transparencyMode=t.Material.MATERIAL_ALPHABLEND,o&&(o.hasAlpha=!0,s.useAlphaFromBaseColorTexture=!0);break;default:throw new Error(`${e}/alphaMode: Invalid value (${n.alphaMode})`)}}loadTextureInfoAsync(e,t,n=()=>{}){const r=this._extensionsLoadTextureInfoAsync(e,t,n);if(r)return r;if(this.logOpen(`${e}`),t.texCoord>=6)throw new Error(`${e}/texCoord: Invalid value (${t.texCoord})`);const s=ve.Get(`${e}/index`,this._gltf.textures,t.index);s._textureInfo=t;const o=this._loadTextureAsync(`/textures/${t.index}`,s,r=>{r.coordinatesIndex=t.texCoord||0,Ce.AddPointerMetadata(r,e),this._parent.onTextureLoadedObservable.notifyObservers(r),n(r)});return this.logClose(),o}_loadTextureAsync(e,t,n=()=>{}){const r=this._extensionsLoadTextureAsync(e,t,n);if(r)return r;this.logOpen(`${e} ${t.name||""}`);const s=null==t.sampler?Ce.DefaultSampler:ve.Get(`${e}/sampler`,this._gltf.samplers,t.sampler),o=ve.Get(`${e}/source`,this._gltf.images,t.source),a=this._createTextureAsync(e,s,o,n,void 0,!t._textureInfo.nonColorData);return this.logClose(),a}_createTextureAsync(e,n,r,s=()=>{},o,a){var i,l;const u=this._loadSampler(`/samplers/${n.index}`,n),c=new Array,h=new t.Deferred;this._babylonScene._blockEntityCollection=!!this._assetContainer;const d={noMipmap:u.noMipMaps,invertY:!1,samplingMode:u.samplingMode,onLoad:()=>{this._disposed||h.resolve()},onError:(t,n)=>{this._disposed||h.reject(new Error(`${e}: ${n&&n.message?n.message:t||"Failed to load texture"}`))},mimeType:null!==(i=r.mimeType)&&void 0!==i?i:t.GetMimeType(null!==(l=r.uri)&&void 0!==l?l:""),loaderOptions:o,useSRGBBuffer:!!a&&this._parent.useSRGBBuffers},m=new t.Texture(null,this._babylonScene,d);m._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,c.push(h.promise);const _=r.uri&&!t.IsBase64DataUrl(r.uri)?r.uri:void 0,p=null!=_?_:`${this._fileName}#image${r.index}`;if(c.push(this.loadImageAsync(`/images/${r.index}`,r).then(e=>{const t=`data:${this._uniqueRootUrl}${p}`;m.updateURL(t,e);const n=m.getInternalTexture();n&&(n.label=r.name)})),m.wrapU=u.wrapU,m.wrapV=u.wrapV,s(m),this._parent.useGltfTextureNames){const e=r.name||_||`image${r.index}`;m.name=e}return Promise.all(c).then(()=>m)}_loadSampler(e,t){return t._data||(t._data={noMipMaps:9728===t.minFilter||9729===t.minFilter,samplingMode:Ce._GetTextureSamplingMode(e,t),wrapU:Ce._GetTextureWrapMode(`${e}/wrapS`,t.wrapS),wrapV:Ce._GetTextureWrapMode(`${e}/wrapT`,t.wrapT)}),t._data}loadImageAsync(e,t){if(!t._data){if(this.logOpen(`${e} ${t.name||""}`),t.uri)t._data=this.loadUriAsync(`${e}/uri`,t,t.uri);else{const n=ve.Get(`${e}/bufferView`,this._gltf.bufferViews,t.bufferView);t._data=this.loadBufferViewAsync(`/bufferViews/${n.index}`,n)}this.logClose()}return t._data}loadUriAsync(e,n,r){const s=this._extensionsLoadUriAsync(e,n,r);if(s)return s;if(!Ce._ValidateUri(r))throw new Error(`${e}: '${r}' is invalid`);if(t.IsBase64DataUrl(r)){const n=new Uint8Array(t.DecodeBase64UrlToBinary(r));return this.log(`${e}: Decoded ${r.substring(0,64)}... (${n.length} bytes)`),Promise.resolve(n)}return this.log(`${e}: Loading ${r}`),this._parent.preprocessUrlAsync(this._rootUrl+r).then(n=>new Promise((s,o)=>{this._parent._loadFile(this._babylonScene,n,t=>{this._disposed||(this.log(`${e}: Loaded ${r} (${t.byteLength} bytes)`),s(new Uint8Array(t)))},!0,n=>{o(new t.LoadFileError(`${e}: Failed to load '${r}'${n?": "+n.status+" "+n.statusText:""}`,n))})}))}static AddPointerMetadata(e,t){e.metadata=e.metadata||{};const n=e._internalMetadata=e._internalMetadata||{},r=n.gltf=n.gltf||{};(r.pointers=r.pointers||[]).push(t)}static _GetTextureWrapMode(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(`${e}: Invalid value (${n})`),t.Texture.WRAP_ADDRESSMODE}}static _GetTextureSamplingMode(e,n){const r=null==n.magFilter?9729:n.magFilter,s=null==n.minFilter?9987:n.minFilter;if(9729===r)switch(s){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(`${e}/minFilter: Invalid value (${s})`),t.Texture.LINEAR_LINEAR_MIPLINEAR}else switch(9728!==r&&t.Logger.Warn(`${e}/magFilter: Invalid value (${r})`),s){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(`${e}/minFilter: Invalid value (${s})`),t.Texture.NEAREST_NEAREST_MIPNEAREST}}static _GetTypedArrayConstructor(e,n){try{return t.GetTypedArrayConstructor(n)}catch(t){throw new Error(`${e}: ${t.message}`,{cause:t})}}static _GetTypedArray(e,n,r,s,o){const a=r.buffer;s=r.byteOffset+(s||0);const i=Ce._GetTypedArrayConstructor(`${e}/componentType`,n),l=t.VertexBufferGetTypeByteLength(n);return s%l!==0?(t.Logger.Warn(`${e}: Copying buffer as byte offset (${s}) is not a multiple of component type byte length (${l})`),new i(a.slice(s,s+o*l),0)):new i(a,s,o)}static _GetNumComponents(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(`${e}: Invalid type (${t})`)}static _ValidateUri(e){return t.Tools.IsBase64(e)||-1===e.indexOf("..")}static _GetDrawMode(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(`${e}: Invalid mesh primitive mode (${n})`)}_compileMaterialsAsync(){this._parent._startPerformanceCounter("Compile materials");const e=new Array;if(this._gltf.materials)for(const t of this._gltf.materials)if(t._data)for(const n in t._data){const r=t._data[n];for(const t of r.babylonMeshes){t.computeWorldMatrix(!0);const n=r.babylonMaterial;e.push(n.forceCompilationAsync(t)),e.push(n.forceCompilationAsync(t,{useInstances:!0})),this._parent.useClipPlane&&(e.push(n.forceCompilationAsync(t,{clipPlane:!0})),e.push(n.forceCompilationAsync(t,{clipPlane:!0,useInstances:!0})))}}return Promise.all(e).then(()=>{this._parent._endPerformanceCounter("Compile materials")})}_compileShadowGeneratorsAsync(){this._parent._startPerformanceCounter("Compile shadow generators");const e=new Array,t=this._babylonScene.lights;for(const n of t){const t=n.getShadowGenerator();t&&e.push(t.forceCompilationAsync())}return Promise.all(e).then(()=>{this._parent._endPerformanceCounter("Compile shadow generators")})}_forEachExtensions(e){for(const t of this._extensions)t.enabled&&e(t)}_applyExtensions(e,t,n){for(const r of this._extensions)if(r.enabled){const s=`${r.name}.${t}`,o=e;o._activeLoaderExtensionFunctions=o._activeLoaderExtensionFunctions||{};const a=o._activeLoaderExtensionFunctions;if(!a[s]){a[s]=!0;try{const e=n(r);if(e)return e}finally{delete a[s]}}}return null}_extensionsOnLoading(){this._forEachExtensions(e=>e.onLoading&&e.onLoading())}_extensionsOnReady(){this._forEachExtensions(e=>e.onReady&&e.onReady())}_extensionsLoadSceneAsync(e,t){return this._applyExtensions(t,"loadScene",n=>n.loadSceneAsync&&n.loadSceneAsync(e,t))}_extensionsLoadNodeAsync(e,t,n){return this._applyExtensions(t,"loadNode",r=>r.loadNodeAsync&&r.loadNodeAsync(e,t,n))}_extensionsLoadCameraAsync(e,t,n){return this._applyExtensions(t,"loadCamera",r=>r.loadCameraAsync&&r.loadCameraAsync(e,t,n))}_extensionsLoadVertexDataAsync(e,t,n){return this._applyExtensions(t,"loadVertexData",r=>r._loadVertexDataAsync&&r._loadVertexDataAsync(e,t,n))}_extensionsLoadMeshPrimitiveAsync(e,t,n,r,s,o){return this._applyExtensions(s,"loadMeshPrimitive",a=>a._loadMeshPrimitiveAsync&&a._loadMeshPrimitiveAsync(e,t,n,r,s,o))}_extensionsLoadMaterialAsync(e,t,n,r,s){return this._applyExtensions(t,"loadMaterial",o=>o._loadMaterialAsync&&o._loadMaterialAsync(e,t,n,r,s))}_extensionsCreateMaterial(e,t,n){return this._applyExtensions(t,"createMaterial",r=>r.createMaterial&&r.createMaterial(e,t,n))}_extensionsLoadMaterialPropertiesAsync(e,t,n){return this._applyExtensions(t,"loadMaterialProperties",r=>r.loadMaterialPropertiesAsync&&r.loadMaterialPropertiesAsync(e,t,n))}_extensionsLoadTextureInfoAsync(e,t,n){return this._applyExtensions(t,"loadTextureInfo",r=>r.loadTextureInfoAsync&&r.loadTextureInfoAsync(e,t,n))}_extensionsLoadTextureAsync(e,t,n){return this._applyExtensions(t,"loadTexture",r=>r._loadTextureAsync&&r._loadTextureAsync(e,t,n))}_extensionsLoadAnimationAsync(e,t){return this._applyExtensions(t,"loadAnimation",n=>n.loadAnimationAsync&&n.loadAnimationAsync(e,t))}_extensionsLoadAnimationChannelAsync(e,t,n,r,s){return this._applyExtensions(n,"loadAnimationChannel",o=>o._loadAnimationChannelAsync&&o._loadAnimationChannelAsync(e,t,n,r,s))}_extensionsLoadSkinAsync(e,t,n){return this._applyExtensions(n,"loadSkin",r=>r._loadSkinAsync&&r._loadSkinAsync(e,t,n))}_extensionsLoadUriAsync(e,t,n){return this._applyExtensions(t,"loadUri",r=>r._loadUriAsync&&r._loadUriAsync(e,t,n))}_extensionsLoadBufferViewAsync(e,t){return this._applyExtensions(t,"loadBufferView",n=>n.loadBufferViewAsync&&n.loadBufferViewAsync(e,t))}_extensionsLoadBufferAsync(e,t,n,r){return this._applyExtensions(t,"loadBuffer",s=>s.loadBufferAsync&&s.loadBufferAsync(e,t,n,r))}static LoadExtensionAsync(e,t,n,r){if(!t.extensions)return null;const s=t.extensions[n];return s?r(`${e}/extensions/${n}`,s):null}static LoadExtraAsync(e,t,n,r){if(!t.extras)return null;const s=t.extras[n];return s?r(`${e}/extras/${n}`,s):null}isExtensionUsed(e){return!!this._gltf.extensionsUsed&&-1!==this._gltf.extensionsUsed.indexOf(e)}logOpen(e){this._parent._logOpen(e)}logClose(){this._parent._logClose()}log(e){this._parent._log(e)}startPerformanceCounter(e){this._parent._startPerformanceCounter(e)}endPerformanceCounter(e){this._parent._endPerformanceCounter(e)}}Ce.DefaultSampler={index:-1};let Re=!1;function Me(){Re||(Re=!0,g._CreateGLTF2Loader=e=>new Ce(e))}const we="EXT_lights_image_based";class Ee{constructor(e){this.name=we,this._loader=e,this.enabled=this._loader.isExtensionUsed(we)}dispose(){this._loader=null,delete this._lights}onLoading(){const e=this._loader.gltf.extensions;if(e&&e[this.name]){const t=e[this.name];this._lights=t.lights}}loadSceneAsync(e,t){return Ce.LoadExtensionAsync(e,t,this.name,(n,r)=>v(this,void 0,void 0,function*(){this._loader._allMaterialsDirtyRequired=!0;const s=new Array;s.push(this._loader.loadSceneAsync(e,t)),this._loader.logOpen(`${n}`);const o=ve.Get(`${n}/light`,this._lights,r.light);return s.push(this._loadLightAsync(`/extensions/${this.name}/lights/${r.light}`,o).then(e=>{this._loader.babylonScene.environmentTexture=e})),this._loader.logClose(),yield Promise.all(s).then(()=>{})}))}_loadLightAsync(e,n){if(!n._loaded){const r=new Array;this._loader.logOpen(`${e}`);const s=new Array(n.specularImages.length);for(let t=0;t<n.specularImages.length;t++){const o=n.specularImages[t];s[t]=new Array(o.length);for(let n=0;n<o.length;n++){const a=`${e}/specularImages/${t}/${n}`;this._loader.logOpen(`${a}`);const i=o[n],l=ve.Get(a,this._loader.gltf.images,i);r.push(this._loader.loadImageAsync(`/images/${i}`,l).then(e=>{s[t][n]=e})),this._loader.logClose()}}this._loader.logClose(),n._loaded=Promise.all(r).then(()=>v(this,void 0,void 0,function*(){const r=new t.RawCubeTexture(this._loader.babylonScene,null,n.specularImageSize);if(r.name=n.name||"environment",n._babylonTexture=r,null!=n.intensity&&(r.level=n.intensity),n.rotation){let e=t.Quaternion.FromArray(n.rotation);this._loader.babylonScene.useRightHandedSystem||(e=t.Quaternion.Inverse(e)),t.Matrix.FromQuaternionToRef(e,r.getReflectionTextureMatrix())}if(!n.irradianceCoefficients)throw new Error(`${e}: Irradiance coefficients are missing`);const o=t.SphericalHarmonics.FromArray(n.irradianceCoefficients);o.scaleInPlace(n.intensity),o.convertIrradianceToLambertianRadiance();const a=t.SphericalPolynomial.FromHarmonics(o),i=(s.length-1)/Math.log2(n.specularImageSize);return yield r.updateRGBDAsync(s,a,i)}))}return n._loaded.then(()=>n._babylonTexture)}}let Oe=!1;function Le(){Oe||(Oe=!0,ye(we),be(we,!0,e=>new Ee(e)))}Le();const Se="EXT_mesh_gpu_instancing";class Fe{constructor(e){this.name=Se,this._loader=e,this.enabled=this._loader.isExtensionUsed(Se)}dispose(){this._loader=null}loadNodeAsync(e,n,r){return Ce.LoadExtensionAsync(e,n,this.name,(e,s)=>v(this,void 0,void 0,function*(){this._loader._disableInstancedMesh++;const o=this._loader.loadNodeAsync(`/nodes/${n.index}`,n,r);if(this._loader._disableInstancedMesh--,!n._primitiveBabylonMeshes)return yield o;const a=new Array;let i=0;const l=t=>{if(null==s.attributes[t])return void a.push(Promise.resolve(null));const n=ve.Get(`${e}/attributes/${t}`,this._loader.gltf.accessors,s.attributes[t]);if(a.push(this._loader._loadFloatAccessorAsync(`/accessors/${n.bufferView}`,n)),0===i)i=n.count;else if(i!==n.count)throw new Error(`${e}/attributes: Instance buffer accessors do not have the same count.`)};return l("TRANSLATION"),l("ROTATION"),l("SCALE"),l("_COLOR_0"),yield o.then(e=>v(this,void 0,void 0,function*(){const[r,s,o,l]=yield Promise.all(a),u=new Float32Array(16*i);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);for(let e=0;e<i;++e)r&&t.Vector3.FromArrayToRef(r,3*e,t.TmpVectors.Vector3[0]),s&&t.Quaternion.FromArrayToRef(s,4*e,t.TmpVectors.Quaternion[0]),o&&t.Vector3.FromArrayToRef(o,3*e,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(u,16*e);for(const e of n._primitiveBabylonMeshes)e.thinInstanceSetBuffer("matrix",u,16,!0),l&&(l.length===3*i?e.thinInstanceSetBuffer("color",l,3,!0):l.length===4*i?e.thinInstanceSetBuffer("color",l,4,!0):t.Logger.Warn("Unexpected size of _COLOR_0 attribute for mesh "+e.name));return e}))}))}}let Ie=!1;function Ne(){Ie||(Ie=!0,ye(Se),be(Se,!0,e=>new Fe(e)))}Ne();const ke="EXT_meshopt_compression";class Pe{constructor(e){this.name=ke,this.enabled=e.isExtensionUsed(ke),this._loader=e}dispose(){this._loader=null}loadBufferViewAsync(e,n){return Ce.LoadExtensionAsync(e,n,this.name,(r,s)=>v(this,void 0,void 0,function*(){const r=n;if(r._meshOptData)return yield r._meshOptData;const o=ve.Get(`${e}/buffer`,this._loader.gltf.buffers,s.buffer);return r._meshOptData=this._loader.loadBufferAsync(`/buffers/${o.index}`,o,s.byteOffset||0,s.byteLength).then(e=>v(this,void 0,void 0,function*(){return yield t.MeshoptCompression.Default.decodeGltfBufferAsync(e,s.count,s.byteStride,s.mode,s.filter)})),yield r._meshOptData}))}}let Be=!1;function Ge(){Be||(Be=!0,ye(ke),be(ke,!0,e=>new Pe(e)))}Ge();const De="EXT_texture_webp";class Ve{constructor(e){this.name=De,this._loader=e,this.enabled=e.isExtensionUsed(De)}dispose(){this._loader=null}_loadTextureAsync(e,t,n){return Ce.LoadExtensionAsync(e,t,this.name,(r,s)=>v(this,void 0,void 0,function*(){const o=null==t.sampler?Ce.DefaultSampler:ve.Get(`${e}/sampler`,this._loader.gltf.samplers,t.sampler),a=ve.Get(`${r}/source`,this._loader.gltf.images,s.source);return yield this._loader._createTextureAsync(e,o,a,e=>{n(e)},void 0,!t._textureInfo.nonColorData)}))}}let He=!1;function $e(){He||(He=!0,ye(De),be(De,!0,e=>new Ve(e)))}$e();const Ke="EXT_texture_avif";class We{constructor(e){this.name=Ke,this._loader=e,this.enabled=e.isExtensionUsed(Ke)}dispose(){this._loader=null}_loadTextureAsync(e,t,n){return Ce.LoadExtensionAsync(e,t,this.name,(r,s)=>v(this,void 0,void 0,function*(){const o=null==t.sampler?Ce.DefaultSampler:ve.Get(`${e}/sampler`,this._loader.gltf.samplers,t.sampler),a=ve.Get(`${r}/source`,this._loader.gltf.images,s.source);return yield this._loader._createTextureAsync(e,o,a,e=>{n(e)},void 0,!t._textureInfo.nonColorData)}))}}let Ue=!1;function ze(){Ue||(Ue=!0,ye(Ke),be(Ke,!0,e=>new We(e)))}ze();const je="EXT_lights_ies";class qe{constructor(e){this.name=je,this._loader=e,this.enabled=this._loader.isExtensionUsed(je)}dispose(){this._loader=null,delete this._lights}onLoading(){const e=this._loader.gltf.extensions;if(e&&e[this.name]){const t=e[this.name];this._lights=t.lights,ve.Assign(this._lights)}}loadNodeAsync(e,n,r){return Ce.LoadExtensionAsync(e,n,this.name,(s,o)=>v(this,void 0,void 0,function*(){let a,i;this._loader._allMaterialsDirtyRequired=!0;const l=yield this._loader.loadNodeAsync(e,n,e=>{i=ve.Get(s,this._lights,o.light);const n=i.name||e.name;this._loader.babylonScene._blockEntityCollection=!!this._loader._assetContainer,a=new t.SpotLight(n,t.Vector3.Zero(),t.Vector3.Backward(),0,1,this._loader.babylonScene),a.angle=Math.PI/2,a.innerAngle=0,a._parentContainer=this._loader._assetContainer,this._loader.babylonScene._blockEntityCollection=!1,i._babylonLight=a,a.falloffType=t.Light.FALLOFF_GLTF,a.diffuse=o.color?t.Color3.FromArray(o.color):t.Color3.White(),a.intensity=o.multiplier||1,a.range=Number.MAX_VALUE,a.parent=e,this._loader._babylonLights.push(a),Ce.AddPointerMetadata(a,s),r(e)});let u;if(i.uri)u=yield this._loader.loadUriAsync(e,i,i.uri);else{const t=ve.Get(`${e}/bufferView`,this._loader.gltf.bufferViews,i.bufferView);u=yield this._loader.loadBufferViewAsync(`/bufferViews/${t.index}`,t)}return a.iesProfileTexture=new t.Texture(name+"_iesProfile",this._loader.babylonScene,!0,!1,void 0,null,null,u,!0,void 0,void 0,void 0,void 0,".ies"),l}))}}let Ye=!1;function Xe(){Ye||(Ye=!0,ye(je),be(je,!0,e=>new qe(e)))}Xe();const Qe="KHR_draco_mesh_compression";class Ze{constructor(e){this.name=Qe,this.useNormalizedFlagFromAccessor=!0,this._loader=e,this.enabled=t.DracoDecoder.DefaultAvailable&&this._loader.isExtensionUsed(Qe)}dispose(){delete this.dracoDecoder,this._loader=null}_loadVertexDataAsync(e,n,r){return Ce.LoadExtensionAsync(e,n,this.name,(s,o)=>v(this,void 0,void 0,function*(){if(null!=n.mode&&4!==n.mode&&5!==n.mode)throw new Error(`${e}: Unsupported mode ${n.mode}`);const a={},i={},l=(e,t)=>{const s=o.attributes[e];if(null!=s&&(r._delayInfo=r._delayInfo||[],-1===r._delayInfo.indexOf(t)&&r._delayInfo.push(t),a[t]=s,this.useNormalizedFlagFromAccessor)){const r=ve.TryGet(this._loader.gltf.accessors,n.attributes[e]);r&&(i[t]=r.normalized||!1)}};l("POSITION",t.VertexBuffer.PositionKind),l("NORMAL",t.VertexBuffer.NormalKind),l("TANGENT",t.VertexBuffer.TangentKind),l("TEXCOORD_0",t.VertexBuffer.UVKind),l("TEXCOORD_1",t.VertexBuffer.UV2Kind),l("TEXCOORD_2",t.VertexBuffer.UV3Kind),l("TEXCOORD_3",t.VertexBuffer.UV4Kind),l("TEXCOORD_4",t.VertexBuffer.UV5Kind),l("TEXCOORD_5",t.VertexBuffer.UV6Kind),l("JOINTS_0",t.VertexBuffer.MatricesIndicesKind),l("WEIGHTS_0",t.VertexBuffer.MatricesWeightsKind),l("COLOR_0",t.VertexBuffer.ColorKind);const u=ve.Get(s,this._loader.gltf.bufferViews,o.bufferView);return u._dracoBabylonGeometry||(u._dracoBabylonGeometry=this._loader.loadBufferViewAsync(`/bufferViews/${u.index}`,u).then(s=>v(this,void 0,void 0,function*(){const o=this.dracoDecoder||t.DracoDecoder.Default,l=ve.TryGet(this._loader.gltf.accessors,n.attributes.POSITION),u=this._loader.parent.alwaysComputeBoundingBox||r.skeleton||!l?null:Ae(l);return yield o._decodeMeshToGeometryForGltfAsync(r.name,this._loader.babylonScene,s,a,i,u).catch(t=>{throw new Error(`${e}: ${t.message}`)})}))),yield u._dracoBabylonGeometry}))}}let Je=!1;function et(){Je||(Je=!0,ye(Qe),be(Qe,!0,e=>new Ze(e)))}et();const tt="KHR_gaussian_splatting",nt=.28209479177387814,rt=[0,3,5,7];function st(e){return e<=0?0:e>=255?255:e+.5|0}class ot{constructor(e){this.name=tt,this._loader=e,this.enabled=this._loader.isExtensionUsed(tt)}dispose(){this._loader=null}_loadMeshPrimitiveAsync(e,n,r,s,o,a){return Ce.LoadExtensionAsync(e,o,this.name,r=>v(this,void 0,void 0,function*(){if(null!=o.mode&&0!==o.mode)throw new Error(`${r}: Gaussian splatting primitives must use POINTS mode`);const s=this._loader,i=t=>{const n=o.attributes[t];if(null==n)return null;const r=ve.Get(`${e}/attributes/${t}`,s.gltf.accessors,n);return s._loadFloatAccessorAsync(`/accessors/${r.index}`,r)},l=i("POSITION");if(!l)throw new Error(`${r}: Gaussian splatting primitive is missing the POSITION attribute`);let u=0;const c=[];for(let e=1;e<=3&&null!=o.attributes[`KHR_gaussian_splatting:SH_DEGREE_${e}_COEF_0`];e++){u=e;for(let t=0;t<rt[e];t++)c.push(`KHR_gaussian_splatting:SH_DEGREE_${e}_COEF_${t}`)}const h=s.babylonScene;h._blockEntityCollection=!!s._assetContainer;const d=new t.GaussianSplattingMesh(n,null,h);d._parentContainer=s._assetContainer,h._blockEntityCollection=!1,Ce.AddPointerMetadata(d,e),s.parent.onMeshLoadedObservable.notifyObservers(d),a(d);const m=h.getEngine().getCaps(),[_,p,f,g,b,y,...T]=yield Promise.all([l,i("KHR_gaussian_splatting:ROTATION"),i("KHR_gaussian_splatting:SCALE"),i("KHR_gaussian_splatting:OPACITY"),i("KHR_gaussian_splatting:SH_DEGREE_0_COEF_0"),i("COLOR_0"),...c.map(e=>i(e))]),x=_.length/3,v=y?y.length/x:0,A=new ArrayBuffer(32*x),C=new Float32Array(A),R=new Uint8Array(A);let M=null;if(u>0){const e=3*((u+1)*(u+1)-1),n=Math.ceil(e/16),r=m.maxTextureSize,s=Math.ceil(x/r);M=t.AllocateShBuffers(n,s*r*4*4)}for(let e=0;e<x;e++){const t=8*e,n=32*e,r=3*e;if(C[t+0]=_[r+0],C[t+1]=_[r+1],C[t+2]=_[r+2],C[t+3]=f?f[r+0]:1,C[t+4]=f?f[r+1]:1,C[t+5]=f?f[r+2]:1,b)R[n+24]=st(255*(.5+nt*b[r+0])),R[n+25]=st(255*(.5+nt*b[r+1])),R[n+26]=st(255*(.5+nt*b[r+2]));else if(y){const t=e*v;R[n+24]=st(255*y[t+0]),R[n+25]=st(255*y[t+1]),R[n+26]=st(255*y[t+2])}else R[n+24]=255,R[n+25]=255,R[n+26]=255;R[n+27]=g?st(255*g[e]):y&&v>=4?st(255*y[e*v+3]):255;const s=4*e,o=p?p[s+0]:0,a=p?p[s+1]:0,i=p?p[s+2]:0,l=p?p[s+3]:1;if(R[n+28]=st(127.5*l+127.5),R[n+29]=st(127.5*o+127.5),R[n+30]=st(127.5*a+127.5),R[n+31]=st(127.5*i+127.5),M){const t=16*e;for(let e=0;e<T.length;e++){const n=T[e];if(n)for(let s=0;s<3;s++){const o=3*e+s,a=15&o;M[o>>4][t+a]=st(128*n[r+s]+128)}}}}return yield d.updateDataAsync(A,null!=M?M:void 0,void 0,u||void 0),d}))}}let at=!1;function it(){at||(at=!0,ye(tt),be(tt,!0,e=>new ot(e)))}it();const lt="KHR_lights_punctual";class ut{constructor(e){this.name=lt,this._loader=e,this.enabled=this._loader.isExtensionUsed(lt)}dispose(){this._loader=null,delete this._lights}onLoading(){const e=this._loader.gltf.extensions;if(e&&e[this.name]){const t=e[this.name];this._lights=t.lights,ve.Assign(this._lights)}}loadNodeAsync(e,n,r){return Ce.LoadExtensionAsync(e,n,this.name,(s,o)=>v(this,void 0,void 0,function*(){return this._loader._allMaterialsDirtyRequired=!0,yield this._loader.loadNodeAsync(e,n,e=>{let n;const a=ve.Get(s,this._lights,o.light),i=a.name||e.name;switch(this._loader.babylonScene._blockEntityCollection=!!this._loader._assetContainer,a.type){case"directional":{const e=new t.DirectionalLight(i,t.Vector3.Backward(),this._loader.babylonScene);e.position.setAll(0),n=e;break}case"point":n=new t.PointLight(i,t.Vector3.Zero(),this._loader.babylonScene);break;case"spot":{const e=new t.SpotLight(i,t.Vector3.Zero(),t.Vector3.Backward(),0,1,this._loader.babylonScene);e.angle=2*(a.spot&&a.spot.outerConeAngle||Math.PI/4),e.innerAngle=2*(a.spot&&a.spot.innerConeAngle||0),n=e;break}default:throw this._loader.babylonScene._blockEntityCollection=!1,new Error(`${s}: Invalid light type (${a.type})`)}n._parentContainer=this._loader._assetContainer,this._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,this._loader._babylonLights.push(n),Ce.AddPointerMetadata(n,s),r(e)})}))}}let ct=!1;function ht(){ct||(ct=!0,ye(lt),be(lt,!0,e=>new ut(e)))}ht();const dt="EXT_lights_area";class mt{constructor(e){this.name=dt,this._loader=e,this.enabled=this._loader.isExtensionUsed(dt)}dispose(){this._loader=null,delete this._lights}onLoading(){const e=this._loader.gltf.extensions;if(e&&e[this.name]){const t=e[this.name];this._lights=t.lights,ve.Assign(this._lights)}}loadNodeAsync(e,n,r){return Ce.LoadExtensionAsync(e,n,this.name,(s,o)=>v(this,void 0,void 0,function*(){return this._loader._allMaterialsDirtyRequired=!0,yield this._loader.loadNodeAsync(e,n,e=>{var n;let a;const i=ve.Get(s,this._lights,o.light),l=i.name||e.name;this._loader.babylonScene._blockEntityCollection=!!this._loader._assetContainer;const u=void 0!==i.size?i.size:1;switch(i.type){case"rect":{const e=void 0!==(null===(n=i.rect)||void 0===n?void 0:n.aspect)?i.rect.aspect*u:u,r=u;a=new t.RectAreaLight(l,t.Vector3.Zero(),e,r,this._loader.babylonScene);break}case"disk":{const e=Math.sqrt(u*u*.25*Math.PI);a=new t.RectAreaLight(l,t.Vector3.Zero(),e,e,this._loader.babylonScene);break}default:throw this._loader.babylonScene._blockEntityCollection=!1,new Error(`${s}: Invalid area light type (${i.type})`)}a._parentContainer=this._loader._assetContainer,this._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;const c=new t.TransformNode(`${l}_orientation`,this._loader.babylonScene);c.rotationQuaternion=t.Quaternion.RotationAxis(t.Vector3.Up(),Math.PI),c.parent=e,a.parent=c,this._loader._babylonLights.push(a),Ce.AddPointerMetadata(a,s),r(e)})}))}}let _t=!1;function pt(){_t||(_t=!0,ye(dt),be(dt,!0,e=>new mt(e)))}pt();const ft="KHR_materials_pbrSpecularGlossiness";class gt{constructor(e){this.name=ft,this.order=200,this._loader=e,this.enabled=this._loader.isExtensionUsed(ft)}dispose(){this._loader=null}loadMaterialPropertiesAsync(e,t,n){return Ce.LoadExtensionAsync(e,t,this.name,(r,s)=>v(this,void 0,void 0,function*(){const o=new Array;return o.push(this._loader.loadMaterialBasePropertiesAsync(e,t,n)),o.push(this._loadSpecularGlossinessPropertiesAsync(r,s,n)),this._loader.loadMaterialAlphaProperties(e,t,n),yield Promise.all(o).then(()=>{})}))}_loadSpecularGlossinessPropertiesAsync(e,n,r){const s=this._loader._getOrCreateMaterialAdapter(r),o=new Array;return s.configureSpecularGlossiness(),n.diffuseFactor?(s.baseColor=t.Color3.FromArray(n.diffuseFactor),r.alpha=n.diffuseFactor[3]):s.baseColor=t.Color3.White(),s.specularColor=n.specularFactor?t.Color3.FromArray(n.specularFactor):t.Color3.White(),s.glossiness=null==n.glossinessFactor?1:n.glossinessFactor,n.diffuseTexture&&o.push(this._loader.loadTextureInfoAsync(`${e}/diffuseTexture`,n.diffuseTexture,e=>{e.name=`${r.name} (Diffuse)`,s.baseColorTexture=e})),n.specularGlossinessTexture&&o.push(this._loader.loadTextureInfoAsync(`${e}/specularGlossinessTexture`,n.specularGlossinessTexture,e=>{e.name=`${r.name} (Specular Glossiness)`,s.specularColorTexture=e})),Promise.all(o).then(()=>{})}}let bt=!1;function yt(){bt||(bt=!0,ye(ft),be(ft,!0,e=>new gt(e)))}yt();const Tt="KHR_materials_unlit";class xt{constructor(e){this.name=Tt,this.order=210,this._loader=e,this.enabled=this._loader.isExtensionUsed(Tt)}dispose(){this._loader=null}loadMaterialPropertiesAsync(e,t,n){return Ce.LoadExtensionAsync(e,t,this.name,()=>v(this,void 0,void 0,function*(){return yield this._loadUnlitPropertiesAsync(e,t,n)}))}_loadUnlitPropertiesAsync(e,n,r){const s=this._loader._getOrCreateMaterialAdapter(r),o=new Array,a=n.pbrMetallicRoughness;return a&&(a.baseColorFactor&&(s.baseColor=t.Color3.FromArray(a.baseColorFactor),s.geometryOpacity=a.baseColorFactor[3]),a.baseColorTexture&&o.push(this._loader.loadTextureInfoAsync(`${e}/baseColorTexture`,a.baseColorTexture,e=>{e.name=`${r.name} (Base Color)`,s.baseColorTexture=e}))),s.isUnlit=!0,n.doubleSided&&(s.backFaceCulling=!1,s.twoSidedLighting=!0),this._loader.loadMaterialAlphaProperties(e,n,r),Promise.all(o).then(()=>{})}}let vt=!1;function At(){vt||(vt=!0,ye(Tt),be(Tt,!0,e=>new xt(e)))}At();const Ct="KHR_materials_clearcoat";class Rt{constructor(e){this.name=Ct,this.order=190,this._loader=e,this.enabled=this._loader.isExtensionUsed(Ct)}dispose(){this._loader=null}loadMaterialPropertiesAsync(e,t,n){return Ce.LoadExtensionAsync(e,t,this.name,(r,s)=>v(this,void 0,void 0,function*(){const o=new Array;o.push(this._loader.loadMaterialPropertiesAsync(e,t,n)),o.push(this._loadClearCoatPropertiesAsync(r,s,n)),yield Promise.all(o)}))}_loadClearCoatPropertiesAsync(e,t,n){const r=this._loader._getOrCreateMaterialAdapter(n),s=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&&s.push(this._loader.loadTextureInfoAsync(`${e}/clearcoatTexture`,t.clearcoatTexture,e=>{e.name=`${n.name} (ClearCoat)`,r.coatWeightTexture=e})),t.clearcoatRoughnessTexture&&(t.clearcoatRoughnessTexture.nonColorData=!0,s.push(this._loader.loadTextureInfoAsync(`${e}/clearcoatRoughnessTexture`,t.clearcoatRoughnessTexture,e=>{e.name=`${n.name} (ClearCoat Roughness)`,r.coatRoughnessTexture=e}))),t.clearcoatNormalTexture&&(t.clearcoatNormalTexture.nonColorData=!0,s.push(this._loader.loadTextureInfoAsync(`${e}/clearcoatNormalTexture`,t.clearcoatNormalTexture,e=>{var s;e.name=`${n.name} (ClearCoat Normal)`,r.geometryCoatNormalTexture=e,null!=(null===(s=t.clearcoatNormalTexture)||void 0===s?void 0:s.scale)&&(r.geometryCoatNormalTextureScale=t.clearcoatNormalTexture.scale)})),r.setNormalMapInversions(!n.getScene().useRightHandedSystem,n.getScene().useRightHandedSystem)),Promise.all(s).then(()=>{})}}let Mt=!1;function wt(){Mt||(Mt=!0,ye(Ct),be(Ct,!0,e=>new Rt(e)))}wt();const Et="KHR_materials_coat";class Ot{constructor(e){this.name=Et,this.order=191,this.useOpenPBR=!1,this._loader=e,this.enabled=this._loader.isExtensionUsed(Et)}dispose(){this._loader=null}loadMaterialPropertiesAsync(e,t,n){return Ce.LoadExtensionAsync(e,t,this.name,(r,s)=>v(this,void 0,void 0,function*(){const o=new Array;o.push(this._loader.loadMaterialPropertiesAsync(e,t,n)),t.extensions&&t.extensions.KHR_materials_openpbr&&(this.useOpenPBR=!0),o.push(this._loadCoatPropertiesAsync(r,s,n)),yield Promise.all(o)}))}_loadCoatPropertiesAsync(e,n,r){var s,o;const a=this._loader._getOrCreateMaterialAdapter(r),i=new Array;a.configureCoat(),a.coatWeight=void 0!==n.coatFactor?n.coatFactor:0,a.coatRoughness=void 0!==n.coatRoughnessFactor?n.coatRoughnessFactor:0,n.coatTexture&&i.push(this._loader.loadTextureInfoAsync(`${e}/coatTexture`,n.coatTexture,e=>{e.name=`${r.name} (Coat)`,a.coatWeightTexture=e})),n.coatRoughnessTexture&&(n.coatRoughnessTexture.nonColorData=!0,i.push(this._loader.loadTextureInfoAsync(`${e}/coatRoughnessTexture`,n.coatRoughnessTexture,e=>{e.name=`${r.name} (Coat Roughness)`,a.coatRoughnessTexture=e}))),n.coatNormalTexture&&(n.coatNormalTexture.nonColorData=!0,i.push(this._loader.loadTextureInfoAsync(`${e}/coatNormalTexture`,n.coatNormalTexture,e=>{var t;e.name=`${r.name} (Coat Normal)`,a.geometryCoatNormalTexture=e,null!=(null===(t=n.coatNormalTexture)||void 0===t?void 0:t.scale)&&(a.geometryCoatNormalTextureScale=n.coatNormalTexture.scale)})),a.setNormalMapInversions(!r.getScene().useRightHandedSystem,r.getScene().useRightHandedSystem)),a.coatDarkening=void 0!==n.coatDarkeningFactor?n.coatDarkeningFactor:1,a.coatIor=void 0!==n.coatIor?n.coatIor:1.5;const l=t.Color3.White();void 0!==n.coatColorFactor&&l.fromArray(n.coatColorFactor),a.coatColor=l,n.coatColorTexture&&i.push(this._loader.loadTextureInfoAsync(`${e}/coatColorTexture`,n.coatColorTexture,e=>{e.name=`${r.name} (Coat Color)`,a.coatColorTexture=e}));const u=null!==(s=n.coatAnisotropyStrength)&&void 0!==s?s:0,c=null!==(o=n.coatAnisotropyRotation)&&void 0!==o?o:0;return a.coatRoughnessAnisotropy=u,a.geometryCoatTangentAngle=c,this.useOpenPBR||a.configureGltfStyleAnisotropy(!0),n.coatAnisotropyTexture&&(n.coatAnisotropyTexture.nonColorData=!0,i.push(this._loader.loadTextureInfoAsync(`${e}/coatAnisotropyTexture`,n.coatAnisotropyTexture,e=>{e.name=`${r.name} (Coat Anisotropy)`,a.geometryCoatTangentTexture=e}))),Promise.all(i).then(()=>{})}}let Lt=!1;function St(){Lt||(Lt=!0,ye(Et),be(Et,!0,e=>new Ot(e)))}St();const Ft="KHR_materials_iridescence";class It{constructor(e){this.name=Ft,this.order=195,this._loader=e,this.enabled=this._loader.isExtensionUsed(Ft)}dispose(){this._loader=null}loadMaterialPropertiesAsync(e,t,n){return Ce.LoadExtensionAsync(e,t,this.name,(r,s)=>v(this,void 0,void 0,function*(){const o=new Array;return o.push(this._loader.loadMaterialPropertiesAsync(e,t,n)),o.push(this._loadIridescencePropertiesAsync(r,s,n)),yield Promise.all(o).then(()=>{})}))}_loadIridescencePropertiesAsync(e,t,n){var r,s,o,a,i;const l=this._loader._getOrCreateMaterialAdapter(n),u=new Array;return l.thinFilmWeight=null!==(r=t.iridescenceFactor)&&void 0!==r?r:0,l.thinFilmIor=null!==(o=null!==(s=t.iridescenceIor)&&void 0!==s?s:t.iridescenceIOR)&&void 0!==o?o:1.3,l.thinFilmThicknessMinimum=null!==(a=t.iridescenceThicknessMinimum)&&void 0!==a?a:100,l.thinFilmThicknessMaximum=null!==(i=t.iridescenceThicknessMaximum)&&void 0!==i?i:400,t.iridescenceTexture&&u.push(this._loader.loadTextureInfoAsync(`${e}/iridescenceTexture`,t.iridescenceTexture,e=>{e.name=`${n.name} (Iridescence)`,l.thinFilmWeightTexture=e})),t.iridescenceThicknessTexture&&u.push(this._loader.loadTextureInfoAsync(`${e}/iridescenceThicknessTexture`,t.iridescenceThicknessTexture,e=>{e.name=`${n.name} (Iridescence Thickness)`,l.thinFilmThicknessTexture=e})),Promise.all(u).then(()=>{})}}let Nt=!1;function kt(){Nt||(Nt=!0,ye(Ft),be(Ft,!0,e=>new It(e)))}kt();const Pt="KHR_materials_anisotropy";class Bt{constructor(e){this.name=Pt,this.order=195,this._loader=e,this.enabled=this._loader.isExtensionUsed(Pt)}dispose(){this._loader=null}loadMaterialPropertiesAsync(e,t,n){return Ce.LoadExtensionAsync(e,t,this.name,(r,s)=>v(this,void 0,void 0,function*(){const o=new Array;o.push(this._loader.loadMaterialPropertiesAsync(e,t,n)),o.push(this._loadAnisotropyPropertiesAsync(r,s,n)),yield Promise.all(o)}))}_loadAnisotropyPropertiesAsync(e,t,n){return v(this,void 0,void 0,function*(){var r,s,o;const a=this._loader._getOrCreateMaterialAdapter(n),i=new Array,l=null!==(r=t.anisotropyStrength)&&void 0!==r?r:0,u=null!==(s=t.anisotropyRotation)&&void 0!==s?s:0;a.specularRoughnessAnisotropy=l,a.geometryTangentAngle=u;const c=null!==(o=t.extensions)&&void 0!==o?o:{};c.EXT_materials_anisotropy_openpbr&&c.EXT_materials_anisotropy_openpbr.openPbrAnisotropyEnabled||a.configureGltfStyleAnisotropy(!0),t.anisotropyTexture&&(t.anisotropyTexture.nonColorData=!0,i.push(this._loader.loadTextureInfoAsync(`${e}/anisotropyTexture`,t.anisotropyTexture,e=>{e.name=`${n.name} (Anisotropy Intensity)`,a.geometryTangentTexture=e}))),yield Promise.all(i)})}}let Gt=!1;function Dt(){Gt||(Gt=!0,ye(Pt),be(Pt,!0,e=>new Bt(e)))}Dt();const Vt="KHR_materials_emissive_strength";class Ht{constructor(e){this.name=Vt,this.order=170,this._loader=e,this.enabled=this._loader.isExtensionUsed(Vt)}dispose(){this._loader=null}loadMaterialPropertiesAsync(e,t,n){return Ce.LoadExtensionAsync(e,t,this.name,(r,s)=>v(this,void 0,void 0,function*(){return yield this._loader.loadMaterialPropertiesAsync(e,t,n),this._loadEmissiveProperties(r,s,n),yield Promise.resolve()}))}_loadEmissiveProperties(e,t,n){void 0!==t.emissiveStrength&&(this._loader._getOrCreateMaterialAdapter(n).emissionLuminance=t.emissiveStrength)}}let $t=!1;function Kt(){$t||($t=!0,ye(Vt),be(Vt,!0,e=>new Ht(e)))}Kt();const Wt="KHR_materials_sheen";class Ut{constructor(e){this.name=Wt,this.order=190,this._loader=e,this.enabled=this._loader.isExtensionUsed(Wt)}dispose(){this._loader=null}loadMaterialPropertiesAsync(e,t,n){return Ce.LoadExtensionAsync(e,t,this.name,(r,s)=>v(this,void 0,void 0,function*(){const o=new Array;return o.push(this._loader.loadMaterialPropertiesAsync(e,t,n)),o.push(this._loadSheenPropertiesAsync(r,s,n)),yield Promise.all(o).then(()=>{})}))}_loadSheenPropertiesAsync(e,n,r){const s=this._loader._getOrCreateMaterialAdapter(r),o=new Array;s.configureFuzz();const a=void 0!==n.sheenColorFactor?t.Color3.FromArray(n.sheenColorFactor):t.Color3.Black(),i=void 0!==n.sheenRoughnessFactor?n.sheenRoughnessFactor:0;return s.fuzzWeight=1,s.fuzzColor=a,s.fuzzRoughness=i,n.sheenColorTexture&&o.push(this._loader.loadTextureInfoAsync(`${e}/sheenColorTexture`,n.sheenColorTexture,e=>{e.name=`${r.name} (Sheen Color)`,s.fuzzColorTexture=e})),n.sheenRoughnessTexture&&(n.sheenRoughnessTexture.nonColorData=!0,o.push(this._loader.loadTextureInfoAsync(`${e}/sheenRoughnessTexture`,n.sheenRoughnessTexture,e=>{e.name=`${r.name} (Sheen Roughness)`,s.fuzzRoughnessTexture=e}))),Promise.all(o).then(()=>{})}}let zt=!1;function jt(){zt||(zt=!0,ye(Wt),be(Wt,!0,e=>new Ut(e)))}jt();const qt="KHR_materials_fuzz";class Yt{constructor(e){this.name=qt,this.order=190,this._loader=e,this.enabled=this._loader.isExtensionUsed(qt)}dispose(){this._loader=null}loadMaterialPropertiesAsync(e,t,n){return Ce.LoadExtensionAsync(e,t,this.name,(r,s)=>v(this,void 0,void 0,function*(){const o=new Array;return o.push(this._loader.loadMaterialPropertiesAsync(e,t,n)),o.push(this._loadFuzzPropertiesAsync(r,s,n)),yield Promise.all(o).then(()=>{})}))}_loadFuzzPropertiesAsync(e,n,r){const s=this._loader._getOrCreateMaterialAdapter(r),o=new Array;return s.configureFuzz(),s.fuzzWeight=void 0!==n.fuzzFactor?n.fuzzFactor:0,s.fuzzColor=void 0!==n.fuzzColorFactor?t.Color3.FromArray(n.fuzzColorFactor):t.Color3.White(),s.fuzzRoughness=void 0!==n.fuzzRoughnessFactor?n.fuzzRoughnessFactor:.5,n.fuzzTexture&&o.push(this._loader.loadTextureInfoAsync(`${e}/fuzzTexture`,n.fuzzTexture,e=>{e.name=`${r.name} (Fuzz)`,s.fuzzWeightTexture=e})),n.fuzzColorTexture&&o.push(this._loader.loadTextureInfoAsync(`${e}/fuzzColorTexture`,n.fuzzColorTexture,e=>{e.name=`${r.name} (Fuzz Color)`,s.fuzzColorTexture=e})),n.fuzzRoughnessTexture&&(n.fuzzRoughnessTexture.nonColorData=!0,o.push(this._loader.loadTextureInfoAsync(`${e}/fuzzRoughnessTexture`,n.fuzzRoughnessTexture,e=>{e.name=`${r.name} (Fuzz Roughness)`,s.fuzzRoughnessTexture=e}))),Promise.all(o).then(()=>{})}}let Xt=!1;function Qt(){Xt||(Xt=!0,ye(qt),be(qt,!0,e=>new Yt(e)))}Qt();const Zt="KHR_materials_specular";class Jt{constructor(e){this.name=Zt,this.order=190,this._loader=e,this.enabled=this._loader.isExtensionUsed(Zt)}dispose(){this._loader=null}loadMaterialPropertiesAsync(e,t,n){return Ce.LoadExtensionAsync(e,t,this.name,(r,s)=>v(this,void 0,void 0,function*(){const o=new Array;o.push(this._loader.loadMaterialPropertiesAsync(e,t,n)),o.push(this._loadSpecularPropertiesAsync(r,s,n));const a=this._loader._getOrCreateMaterialAdapter(n);return s.extensions&&s.extensions.EXT_materials_specular_edge_color&&s.extensions.EXT_materials_specular_edge_color.specularEdgeColorEnabled&&a.enableSpecularEdgeColor(!0),yield Promise.all(o).then(()=>{})}))}_loadSpecularPropertiesAsync(e,n,r){var s;const o=this._loader._getOrCreateMaterialAdapter(r),a=new Array;return o.specularWeight=null!==(s=n.specularFactor)&&void 0!==s?s:1,o.specularColor=void 0!==n.specularColorFactor?t.Color3.FromArray(n.specularColorFactor):new t.Color3(1,1,1),n.specularTexture&&(n.specularTexture.nonColorData=!0,a.push(this._loader.loadTextureInfoAsync(`${e}/specularTexture`,n.specularTexture,e=>{e.name=`${r.name} (Specular)`,o.specularWeightTexture=e}))),n.specularColorTexture&&a.push(this._loader.loadTextureInfoAsync(`${e}/specularColorTexture`,n.specularColorTexture,e=>{e.name=`${r.name} (Specular Color)`,o.specularColorTexture=e})),Promise.all(a).then(()=>{})}}let en=!1;function tn(){en||(en=!0,ye(Zt),be(Zt,!0,e=>new Jt(e)))}tn();const nn="KHR_materials_ior";class rn{constructor(e){this.name=nn,this.order=180,this._loader=e,this.enabled=this._loader.isExtensionUsed(nn)}dispose(){this._loader=null}loadMaterialPropertiesAsync(e,t,n){return Ce.LoadExtensionAsync(e,t,this.name,(r,s)=>v(this,void 0,void 0,function*(){const o=new Array;return o.push(this._loader.loadMaterialPropertiesAsync(e,t,n)),o.push(this._loadIorPropertiesAsync(r,s,n)),yield Promise.all(o).then(()=>{})}))}_loadIorPropertiesAsync(e,t,n){const r=this._loader._getOrCreateMaterialAdapter(n),s=void 0!==t.ior?t.ior:rn._DEFAULT_IOR;return r.specularIor=s,Promise.resolve()}}rn._DEFAULT_IOR=1.5;let sn=!1;function on(){sn||(sn=!0,ye(nn),be(nn,!0,e=>new rn(e)))}on();const an="KHR_materials_variants";class ln{constructor(e){this.name=an,this._loader=e,this.enabled=this._loader.isExtensionUsed(an)&&!this._loader.parent.skipMaterials}dispose(){this._loader=null}static GetAvailableVariants(e){const t=this._GetExtensionMetadata(e);return t?Object.keys(t.variants):[]}getAvailableVariants(e){return ln.GetAvailableVariants(e)}static SelectVariant(e,t){const n=this._GetExtensionMetadata(e);if(!n)throw new Error(`Cannot select variant on a glTF mesh that does not have the ${an} extension`);const r=e=>{const t=n.variants[e];if(t)for(const e of t)e.mesh.material=e.material};if(t instanceof Array)for(const e of t)r(e);else r(t);n.lastSelected=t}selectVariant(e,t){ln.SelectVariant(e,t)}static Reset(e){const t=this._GetExtensionMetadata(e);if(!t)throw new Error(`Cannot reset on a glTF mesh that does not have the ${an} extension`);for(const e of t.original)e.mesh.material=e.material;t.lastSelected=null}reset(e){ln.Reset(e)}static GetLastSelectedVariant(e){const t=this._GetExtensionMetadata(e);if(!t)throw new Error(`Cannot get the last selected variant on a glTF mesh that does not have the ${an} extension`);return t.lastSelected}getLastSelectedVariant(e){return ln.GetLastSelectedVariant(e)}static _GetExtensionMetadata(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[an])||null}onLoading(){const e=this._loader.gltf.extensions;if(e&&e[this.name]){const t=e[this.name];this._variants=t.variants}}onReady(){var e;const t=this._loader.rootBabylonMesh;if(t){const n=this._loader.parent.extensionOptions[an];(null==n?void 0:n.defaultVariant)&&ln.SelectVariant(t,n.defaultVariant),null===(e=null==n?void 0:n.onLoaded)||void 0===e||e.call(n,{get variants(){return ln.GetAvailableVariants(t)},get selectedVariant(){const e=ln.GetLastSelectedVariant(t);return e?Array.isArray(e)?e[0]:e:ln.GetAvailableVariants(t)[0]},set selectedVariant(e){ln.SelectVariant(t,e)}})}}_loadMeshPrimitiveAsync(e,n,r,s,o,a){return Ce.LoadExtensionAsync(e,o,this.name,(i,l)=>v(this,void 0,void 0,function*(){const u=new Array;return u.push(this._loader._loadMeshPrimitiveAsync(e,n,r,s,o,n=>{if(a(n),n instanceof t.Mesh){const t=Ce._GetDrawMode(e,o.mode),r=this._loader.rootBabylonMesh,s=r?r._internalMetadata=r._internalMetadata||{}:{},a=s.gltf=s.gltf||{},c=a[an]=a[an]||{lastSelected:null,original:[],variants:{}};c.original.push({mesh:n,material:n.material});for(let e=0;e<l.mappings.length;++e){const s=l.mappings[e],o=ve.Get(`${i}/mappings/${e}/material`,this._loader.gltf.materials,s.material);u.push(this._loader._loadMaterialAsync(`#/materials/${s.material}`,o,n,t,e=>{for(let t=0;t<s.variants.length;++t){const o=s.variants[t],a=ve.Get(`/extensions/${an}/variants/${o}`,this._variants,o);c.variants[a.name]=c.variants[a.name]||[],c.variants[a.name].push({mesh:n,material:e}),n.onClonedObservable.add(e=>{const t=e;let s,o=t;do{if(o=o.parent,!o)return;s=ln._GetExtensionMetadata(o)}while(null===s);if(r&&s===ln._GetExtensionMetadata(r)){o._internalMetadata={};for(const e in r._internalMetadata)o._internalMetadata[e]=r._internalMetadata[e];o._internalMetadata.gltf=[];for(const e in r._internalMetadata.gltf)o._internalMetadata.gltf[e]=r._internalMetadata.gltf[e];o._internalMetadata.gltf[an]={lastSelected:null,original:[],variants:{}};for(const e of s.original)o._internalMetadata.gltf[an].original.push({mesh:e.mesh,material:e.material});for(const e in s.variants)if(Object.prototype.hasOwnProperty.call(s.variants,e)){o._internalMetadata.gltf[an].variants[e]=[];for(const t of s.variants[e])o._internalMetadata.gltf[an].variants[e].push({mesh:t.mesh,material:t.material})}s=o._internalMetadata.gltf[an]}for(const e of s.original)e.mesh===n&&(e.mesh=t);for(const e of s.variants[a.name])e.mesh===n&&(e.mesh=t)})}}))}}})),yield Promise.all(u).then(([e])=>e)}))}}let un=!1;function cn(){un||(un=!0,ye(an),be(an,!0,e=>new ln(e)))}cn();class hn{static _GetDefaultOptions(){return{renderSize:1024,samples:4,lodGenerationScale:1,lodGenerationOffset:-4,renderTargetTextureType:t.Constants.TEXTURETYPE_HALF_FLOAT,generateMipmaps:!0}}constructor(e,n){this._opaqueRenderTarget=null,this._opaqueMeshesCache=[],this._transparentMeshesCache=[],this._materialObservers={},this._newMeshObserver=null,this._removedMeshObserver=null,this._disposed=!1,this._materialImpls=[],this._adapterCache=new WeakMap,this._translucentMaterialIndices=new Map,this._opaqueOnlySubMeshes=new Map,this._savedSubMeshes=new Map,this._options=Object.assign(Object.assign({},hn._GetDefaultOptions()),e),this._scene=n,this._scene._transmissionHelper=this,this.onErrorObservable=new t.Observable,this._scene.onDisposeObservable.addOnce(()=>{this.dispose()}),this._parseScene(),this._setupRenderTargets()}addMaterialImpl(e){this._materialImpls.some(t=>t.materialClass===e.materialClass)||this._materialImpls.push(e)}updateOptions(e){if(!Object.keys(e).filter(t=>this._options[t]!==e[t]).length)return;const t=Object.assign(Object.assign({},this._options),e),n=this._options;this._options=t,t.renderSize===n.renderSize&&t.renderTargetTextureType===n.renderTargetTextureType&&t.generateMipmaps===n.generateMipmaps&&this._opaqueRenderTarget?(this._opaqueRenderTarget.samples=t.samples,this._opaqueRenderTarget.lodGenerationScale=t.lodGenerationScale,this._opaqueRenderTarget.lodGenerationOffset=t.lodGenerationOffset):this._setupRenderTargets()}getOpaqueTarget(){return this._opaqueRenderTarget}_getOrCreateAdapter(e){let t=this._adapterCache.get(e);if(!t)for(const n of this._materialImpls)if(e instanceof n.materialClass){t=new n.adapterClass(e),this._adapterCache.set(e,t);break}return t}_classifyMeshMaterials(e){const n=e.material;if(!n)return"opaque";if(!(n instanceof t.MultiMaterial)){const e=this._getOrCreateAdapter(n);return e&&e.isTranslucent()?(e.refractionBackgroundTexture=this._opaqueRenderTarget,"transparent"):"opaque"}let r=!1,s=!1;const o=new Set;for(let e=0;e<n.subMaterials.length;e++){const t=n.subMaterials[e];if(!t){s=!0;continue}const a=this._getOrCreateAdapter(t);a&&a.isTranslucent()?(a.refractionBackgroundTexture=this._opaqueRenderTarget,r=!0,o.add(e)):s=!0}return r&&s?(this._translucentMaterialIndices.set(e,o),this._rebuildOpaqueOnlySubMeshes(e,o),"mixed"):(this._translucentMaterialIndices.delete(e),this._opaqueOnlySubMeshes.delete(e),r?"transparent":"opaque")}_rebuildOpaqueOnlySubMeshes(e,t){e.subMeshes&&this._opaqueOnlySubMeshes.set(e,e.subMeshes.filter(e=>!t.has(e.materialIndex)))}_addMesh(e){this._materialObservers[e.uniqueId]=e.onMaterialChangedObservable.add(this._onMeshMaterialChanged.bind(this)),t.Tools.SetImmediate(()=>{!this._disposed&&e.material&&("transparent"===this._classifyMeshMaterials(e)?-1===this._transparentMeshesCache.indexOf(e)&&this._transparentMeshesCache.push(e):-1===this._opaqueMeshesCache.indexOf(e)&&this._opaqueMeshesCache.push(e))})}_removeMesh(e){e.onMaterialChangedObservable.remove(this._materialObservers[e.uniqueId]),delete this._materialObservers[e.uniqueId];let t=this._transparentMeshesCache.indexOf(e);-1!==t&&this._transparentMeshesCache.splice(t,1),t=this._opaqueMeshesCache.indexOf(e),-1!==t&&this._opaqueMeshesCache.splice(t,1),this._translucentMaterialIndices.delete(e),this._opaqueOnlySubMeshes.delete(e)}_parseScene(){this._scene.meshes.forEach(this._addMesh.bind(this)),this._newMeshObserver=this._scene.onNewMeshAddedObservable.add(this._addMesh.bind(this)),this._removedMeshObserver=this._scene.onMeshRemovedObservable.add(this._removeMesh.bind(this))}_onMeshMaterialChanged(e){const 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)}_isRenderTargetValid(){var e;return null!==(null===(e=this._opaqueRenderTarget)||void 0===e?void 0:e.getInternalTexture())}_setupRenderTargets(){var e,n;let r;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(e=>{r=this._scene.environmentIntensity,this._scene.environmentIntensity=1,this._options.clearColor?e.clearColor.copyFrom(this._options.clearColor):this._scene.clearColor.toLinearSpaceToRef(e.clearColor,this._scene.getEngine().useExactSrgbConversions),e.clearColor.a=0;const t=this._opaqueOnlySubMeshes.entries();for(let e=t.next();!e.done;e=t.next()){const t=e.value[0],n=e.value[1];t.subMeshes&&(this._savedSubMeshes.set(t,t.subMeshes),t.subMeshes=n)}}),this._opaqueRenderTarget.onAfterUnbindObservable.add(()=>{this._scene.environmentIntensity=r;const e=this._savedSubMeshes.entries();for(let t=e.next();!t.done;t=e.next())t.value[0].subMeshes=t.value[1];this._savedSubMeshes.clear()});for(const e of this._transparentMeshesCache)e.material&&this._classifyMeshMaterials(e);const s=this._translucentMaterialIndices.entries();for(let e=s.next();!e.done;e=s.next()){const t=e.value[0];t.material&&this._classifyMeshMaterials(t)}}dispose(){var e,t;this._disposed=!0,null===(e=this._newMeshObserver)||void 0===e||e.remove(),null===(t=this._removedMeshObserver)||void 0===t||t.remove(),this._newMeshObserver=null,this._removedMeshObserver=null;const n=[...this._transparentMeshesCache,...this._opaqueMeshesCache];for(const e of n){const t=this._materialObservers[e.uniqueId];t&&(t.remove(),delete this._materialObservers[e.uniqueId])}for(const e of this._scene.meshes){const t=this._materialObservers[e.uniqueId];t&&(t.remove(),delete this._materialObservers[e.uniqueId])}this._materialObservers={},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()}}function dn(e,t){if(e.parent.dontUseTransmissionHelper)return;const n=t.getScene()._transmissionHelper,r=null!=n?n:new hn({},t.getScene());for(const t of Array.from(e._pbrMaterialImpls.values()))r.addMaterialImpl(t);n&&!n._isRenderTargetValid()&&n._setupRenderTargets()}const mn="KHR_materials_transmission";class _n{constructor(e){this.name=mn,this.order=175,this._loader=e,this.enabled=this._loader.isExtensionUsed(mn),this.enabled&&(e.parent.transparencyAsCoverage=!0)}dispose(){this._loader=null}loadMaterialPropertiesAsync(e,t,n){return Ce.LoadExtensionAsync(e,t,this.name,(r,s)=>v(this,void 0,void 0,function*(){const o=new Array;return o.push(this._loader.loadMaterialPropertiesAsync(e,t,n)),o.push(this._loadTransparentPropertiesAsync(r,t,n,s)),yield Promise.all(o).then(()=>{})}))}_loadTransparentPropertiesAsync(e,t,n,r){const s=this._loader._getOrCreateMaterialAdapter(n),o=void 0!==r.transmissionFactor?r.transmissionFactor:0;if(0===o||!s)return Promise.resolve();s.configureTransmission(),s.transmissionWeight=o,o>0&&dn(this._loader,n);let a=Promise.resolve(null);return r.transmissionTexture&&(r.transmissionTexture.nonColorData=!0,a=this._loader.loadTextureInfoAsync(`${e}/transmissionTexture`,r.transmissionTexture,e=>{e.name=`${n.name} (Transmission)`,s.transmissionWeightTexture=e})),a.then(()=>{})}}let pn=!1;function fn(){pn||(pn=!0,ye(mn),be(mn,!0,e=>new _n(e)))}fn();const gn="KHR_materials_diffuse_transmission";class bn{constructor(e){this.name=gn,this.order=174,this._loader=e,this.enabled=this._loader.isExtensionUsed(gn),this.enabled&&(e.parent.transparencyAsCoverage=!0)}dispose(){this._loader=null}loadMaterialPropertiesAsync(e,t,n){return Ce.LoadExtensionAsync(e,t,this.name,(r,s)=>v(this,void 0,void 0,function*(){const o=new Array;return o.push(this._loader.loadMaterialPropertiesAsync(e,t,n)),o.push(this._loadTranslucentPropertiesAsync(r,t,n,s)),yield Promise.all(o).then(()=>{})}))}_loadTranslucentPropertiesAsync(e,n,r,s){var o;const a=this._loader._getOrCreateMaterialAdapter(r);a.configureSubsurface(),a.subsurfaceWeight=null!==(o=s.diffuseTransmissionFactor)&&void 0!==o?o:0,a.subsurfaceWeight>0&&dn(this._loader,r),a.diffuseTransmissionTint=void 0!==s.diffuseTransmissionColorFactor?t.Color3.FromArray(s.diffuseTransmissionColorFactor):t.Color3.White();const i=new Array;return s.diffuseTransmissionTexture&&(s.diffuseTransmissionTexture.nonColorData=!0,i.push(this._loader.loadTextureInfoAsync(`${e}/diffuseTransmissionTexture`,s.diffuseTransmissionTexture).then(e=>{e.name=`${r.name} (Diffuse Transmission)`,a.subsurfaceWeightTexture=e}))),s.diffuseTransmissionColorTexture&&i.push(this._loader.loadTextureInfoAsync(`${e}/diffuseTransmissionColorTexture`,s.diffuseTransmissionColorTexture).then(e=>{e.name=`${r.name} (Diffuse Transmission Color)`,a.diffuseTransmissionTintTexture=e})),Promise.all(i).then(()=>{})}}let yn=!1;function Tn(){yn||(yn=!0,ye(gn),be(gn,!0,e=>new bn(e)))}Tn();const xn="KHR_materials_volume";class vn{constructor(e){this.name=xn,this.order=173,this._loader=e,this.enabled=this._loader.isExtensionUsed(xn),this.enabled&&this._loader._disableInstancedMesh++}dispose(){this.enabled&&this._loader._disableInstancedMesh--,this._loader=null}loadMaterialPropertiesAsync(e,t,n){return Ce.LoadExtensionAsync(e,t,this.name,(r,s)=>v(this,void 0,void 0,function*(){const o=new Array;return o.push(this._loader.loadMaterialPropertiesAsync(e,t,n)),o.push(this._loadVolumePropertiesAsync(r,t,n,s)),yield Promise.all(o).then(()=>{})}))}_loadVolumePropertiesAsync(e,n,r,s){var o;const a=this._loader._getOrCreateMaterialAdapter(r);if(0===a.transmissionWeight&&0===a.subsurfaceWeight||!s.thicknessFactor)return Promise.resolve();a.geometryThinWalled=!1;const i=void 0!==s.attenuationDistance?s.attenuationDistance:Number.MAX_VALUE,l=void 0!==s.attenuationColor&&3==s.attenuationColor.length?t.Color3.FromArray(s.attenuationColor):t.Color3.White();a.configureVolume(),a.transmissionColor=l,a.transmissionDepth=i,a.volumeThickness=null!==(o=s.thicknessFactor)&&void 0!==o?o:0;const u=new Array;return s.thicknessTexture&&(s.thicknessTexture.nonColorData=!0,u.push(this._loader.loadTextureInfoAsync(`${e}/thicknessTexture`,s.thicknessTexture,e=>{e.name=`${r.name} (Thickness)`,a.volumeThicknessTexture=e}))),Promise.all(u).then(()=>{})}}let An=!1;function Cn(){An||(An=!0,ye(xn),be(xn,!0,e=>new vn(e)))}Cn();const Rn="KHR_materials_volume_scatter";class Mn{constructor(e){this.name=Rn,this.order=172,this._loader=e,this.enabled=this._loader.isExtensionUsed(Rn),this.enabled&&this._loader._disableInstancedMesh++}dispose(){this.enabled&&this._loader._disableInstancedMesh--,this._loader=null}loadMaterialPropertiesAsync(e,t,n){return Ce.LoadExtensionAsync(e,t,this.name,(r,s)=>v(this,void 0,void 0,function*(){const o=new Array;return o.push(this._loader.loadMaterialPropertiesAsync(e,t,n)),o.push(this._loadVolumePropertiesAsync(r,t,n,s)),yield Promise.all(o).then(()=>{})}))}_loadVolumePropertiesAsync(e,n,r,s){const o=this._loader._getOrCreateMaterialAdapter(r);if(0===o.transmissionWeight&&0===o.subsurfaceWeight||o.geometryThinWalled)return Promise.resolve();const a=void 0!==s.multiscatterColorFactor&&3==s.multiscatterColorFactor.length?t.Color3.FromArray(s.multiscatterColorFactor):t.Color3.Black(),i=void 0!==s.scatterAnisotropy?s.scatterAnisotropy:0;let l=Promise.resolve(null);s.multiscatterColorTexture&&(s.multiscatterColorTexture.nonColorData=!0,l=this._loader.loadTextureInfoAsync(`${e}/multiscatterColorTexture`,s.multiscatterColorTexture,e=>{e.name=`${r.name} (Scatter Color)`,o.transmissionWeight>0&&(o.transmissionScatterTexture=e),o.subsurfaceWeight>0&&(o.subsurfaceColorTexture=e)}));const u=new t.Vector3(-Math.log(o.transmissionColor.r),-Math.log(o.transmissionColor.g),-Math.log(o.transmissionColor.b));if(u.scaleInPlace(1/Math.max(o.transmissionDepth,1e-6)),o.transmissionWeight>0){const e=function(e){const 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));const s=new t.Vector3(9.59217,9.59217,9.59217);return s.addInPlace(new t.Vector3(41.6808,41.6808,41.6808).multiplyInPlace(n)),s.addInPlace(new t.Vector3(17.7126,17.7126,17.7126).multiplyInPlace(n.multiply(n))),r.subtractInPlace(new t.Vector3(Math.sqrt(s.x),Math.sqrt(s.y),Math.sqrt(s.z))),new t.Vector3(1,1,1).subtract(r.multiply(r))}(a),n=u.multiply(e);n.scaleInPlace(o.transmissionDepth),o.transmissionScatter.set(n.x,n.y,n.z),o.transmissionScatterAnisotropy=i}if(o.subsurfaceWeight>0){o.subsurfaceScatterAnisotropy=i,o.subsurfaceColor=a;const e=new t.Vector3(0!==u.x?1/u.x:1,0!==u.y?1/u.y:1,0!==u.z?1/u.z:1);o.subsurfaceRadius=Math.max(e.x,e.y,e.z),o.subsurfaceRadiusScale=new t.Color3(e.x/o.subsurfaceRadius,e.y/o.subsurfaceRadius,e.z/o.subsurfaceRadius)}return l.then(()=>{})}}let wn=!1;function En(){wn||(wn=!0,ye(Rn),be(Rn,!0,e=>new Mn(e)))}En();const On="KHR_materials_dispersion";class Ln{constructor(e){this.name=On,this.order=174,this._loader=e,this.enabled=this._loader.isExtensionUsed(On)}dispose(){this._loader=null}loadMaterialPropertiesAsync(e,t,n){return Ce.LoadExtensionAsync(e,t,this.name,(r,s)=>v(this,void 0,void 0,function*(){const o=new Array;return o.push(this._loader.loadMaterialPropertiesAsync(e,t,n)),o.push(this._loadDispersionPropertiesAsync(r,t,n,s)),yield Promise.all(o).then(()=>{})}))}_loadDispersionPropertiesAsync(e,t,n,r){const s=this._loader._getOrCreateMaterialAdapter(n);return 0!=s.transmissionWeight&&r.dispersion?(s.transmissionDispersionAbbeNumber=20,s.transmissionDispersionScale=r.dispersion,Promise.resolve()):Promise.resolve()}}let Sn=!1;function Fn(){Sn||(Sn=!0,ye(On),be(On,!0,e=>new Ln(e)))}Fn();const In="KHR_materials_diffuse_roughness";class Nn{constructor(e){this.name=In,this.order=190,this._loader=e,this.enabled=this._loader.isExtensionUsed(In)}dispose(){this._loader=null}loadMaterialPropertiesAsync(e,t,n){return Ce.LoadExtensionAsync(e,t,this.name,(r,s)=>v(this,void 0,void 0,function*(){const o=new Array;return o.push(this._loader.loadMaterialPropertiesAsync(e,t,n)),o.push(this._loadDiffuseRoughnessPropertiesAsync(r,s,n)),yield Promise.all(o).then(()=>{})}))}_loadDiffuseRoughnessPropertiesAsync(e,t,n){var r;const s=this._loader._getOrCreateMaterialAdapter(n),o=new Array;return s.baseDiffuseRoughness=null!==(r=t.diffuseRoughnessFactor)&&void 0!==r?r:0,t.diffuseRoughnessTexture&&o.push(this._loader.loadTextureInfoAsync(`${e}/diffuseRoughnessTexture`,t.diffuseRoughnessTexture,e=>{e.name=`${n.name} (Diffuse Roughness)`,s.baseDiffuseRoughnessTexture=e})),Promise.all(o).then(()=>{})}}let kn=!1;function Pn(){kn||(kn=!0,ye(In),be(In,!0,e=>new Nn(e)))}Pn();const Bn="KHR_mesh_quantization";class Gn{constructor(e){this.name=Bn,this.enabled=e.isExtensionUsed(Bn)}dispose(){}}let Dn=!1;function Vn(){Dn||(Dn=!0,ye(Bn),be(Bn,!0,e=>new Gn(e)))}Vn();const Hn="KHR_texture_basisu";class $n{constructor(e){this.name=Hn,this._loader=e,this.enabled=e.isExtensionUsed(Hn)}dispose(){this._loader=null}_loadTextureAsync(e,t,n){return Ce.LoadExtensionAsync(e,t,this.name,(r,s)=>v(this,void 0,void 0,function*(){const o=null==t.sampler?Ce.DefaultSampler:ve.Get(`${e}/sampler`,this._loader.gltf.samplers,t.sampler),a=ve.Get(`${r}/source`,this._loader.gltf.images,s.source);return yield this._loader._createTextureAsync(e,o,a,e=>{n(e)},t._textureInfo.nonColorData?{useRGBAIfASTCBC7NotAvailableWhenUASTC:!0}:void 0,!t._textureInfo.nonColorData)}))}}let Kn=!1;function Wn(){Kn||(Kn=!0,ye(Hn),be(Hn,!0,e=>new $n(e)))}Wn();const Un="KHR_texture_transform";class zn{constructor(e){this.name=Un,this._loader=e,this.enabled=this._loader.isExtensionUsed(Un)}dispose(){this._loader=null}loadTextureInfoAsync(e,n,r){return Ce.LoadExtensionAsync(e,n,this.name,(s,o)=>v(this,void 0,void 0,function*(){return yield this._loader.loadTextureInfoAsync(e,n,e=>{if(!(e instanceof t.Texture))throw new Error(`${s}: Texture type not supported`);o.offset&&(e.uOffset=o.offset[0],e.vOffset=o.offset[1]),e.uRotationCenter=0,e.vRotationCenter=0,o.rotation&&(e.wAng=-o.rotation),o.scale&&(e.uScale=o.scale[0],e.vScale=o.scale[1]),null!=o.texCoord&&(e.coordinatesIndex=o.texCoord),r(e)})}))}}let jn=!1;function qn(){jn||(jn=!0,ye(Un),be(Un,!0,e=>new zn(e)))}qn();const Yn="KHR_xmp_json_ld";class Xn{constructor(e){this.name=Yn,this.order=100,this._loader=e,this.enabled=this._loader.isExtensionUsed(Yn)}dispose(){this._loader=null}onLoading(){var e,t,n;if(null===this._loader.rootBabylonMesh)return;const r=null===(e=this._loader.gltf.extensions)||void 0===e?void 0:e.KHR_xmp_json_ld,s=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&&s){const e=+s.packet;r.packets&&e<r.packets.length&&(this._loader.rootBabylonMesh.metadata=this._loader.rootBabylonMesh.metadata||{},this._loader.rootBabylonMesh.metadata.xmp=r.packets[e])}}}let Qn=!1;function Zn(){Qn||(Qn=!0,ye(Yn),be(Yn,!0,e=>new Xn(e)))}Zn();const Jn="KHR_animation_pointer";class er{constructor(e){this.name=Jn,this._loader=e,this._pathToObjectConverter=de(this._loader.gltf)}get enabled(){return this._loader.isExtensionUsed(Jn)}dispose(){this._loader=null,delete this._pathToObjectConverter}_loadAnimationChannelAsync(e,n,r,s,o){var a;const i=null===(a=s.target.extensions)||void 0===a?void 0:a.KHR_animation_pointer;if(!i||!this._pathToObjectConverter)return null;"pointer"!==s.target.path&&t.Logger.Warn(`${e}/target/path: Value (${s.target.path}) must be (pointer) when using the ${this.name} extension`),null!=s.target.node&&t.Logger.Warn(`${e}/target/node: Value (${s.target.node}) must not be present when using the ${this.name} extension`);const l=`${e}/extensions/${this.name}`,u=i.pointer;if(!u)throw new Error(`${l}: Pointer is missing`);try{const t=this._pathToObjectConverter.convert(u);if(!t.info.interpolation)throw new Error(`${l}/pointer: Interpolation is missing`);return this._loader._loadAnimationChannelFromTargetInfoAsync(e,n,r,s,{object:t.object,info:t.info.interpolation},o)}catch(e){return t.Logger.Warn(`${l}/pointer: Invalid pointer (${u}) skipped`),null}}}let tr=!1;function nr(){tr||(tr=!0,ye(Jn),be(Jn,!0,e=>new er(e)))}function rr(e,n,r,s){return t.Vector3.FromArray(n,r).scaleInPlace(s)}function sr(e,n,r,s){return t.Quaternion.FromArray(n,r).scaleInPlace(s)}function or(e,t,n,r){const s=new Array(e._numMorphTargets);for(let e=0;e<s.length;e++)s[e]=t[n++]*r;return s}class ar{constructor(e,t,n,r){this.type=e,this.name=t,this.getValue=n,this.getStride=r}_buildAnimation(e,n,r){const s=new t.Animation(e,this.name,n,this.type);return s.setKeys(r,!0),s}}class ir extends ar{buildAnimations(e,t,n,r){const s=[];return s.push({babylonAnimatable:e._babylonTransformNode,babylonAnimation:this._buildAnimation(t,n,r)}),s}}class lr extends ar{buildAnimations(e,n,r,s){const o=[];if(e._numMorphTargets)for(let a=0;a<e._numMorphTargets;a++){const i=new t.Animation(`${n}_${a}`,this.name,r,this.type);if(i.setKeys(s.map(e=>({frame:e.frame,inTangent:e.inTangent?e.inTangent[a]:void 0,value:e.value[a],outTangent:e.outTangent?e.outTangent[a]:void 0,interpolation:e.interpolation})),!0),e._primitiveBabylonMeshes)for(const t of e._primitiveBabylonMeshes)if(t.morphTargetManager){const e=t.morphTargetManager.getTarget(a),n=i.clone();e.animations.push(n),o.push({babylonAnimatable:e,babylonAnimation:n})}}return o}}_e("/nodes/{}/translation",[new ir(t.Animation.ANIMATIONTYPE_VECTOR3,"position",rr,()=>3)]),_e("/nodes/{}/rotation",[new ir(t.Animation.ANIMATIONTYPE_QUATERNION,"rotationQuaternion",sr,()=>4)]),_e("/nodes/{}/scale",[new ir(t.Animation.ANIMATIONTYPE_VECTOR3,"scaling",rr,()=>3)]),_e("/nodes/{}/weights",[new lr(t.Animation.ANIMATIONTYPE_FLOAT,"influence",or,e=>e._numMorphTargets)]);var ur={__proto__:null,AnimationPropertyInfo:ar,TransformNodeAnimationPropertyInfo:ir,WeightAnimationPropertyInfo:lr,getQuaternion:sr,getVector3:rr,getWeights:or};function cr(e,n,r,s){return t.Color3.FromArray(n,r).scale(s)}function hr(e,t,n,r){return t[n]*r}function dr(e,t,n,r){return-t[n]*r}function mr(e,t,n,r){return t[n+1]*r}function _r(e,t,n,r){return t[n]*r*2}function pr(e){return{scale:[new gr(t.Animation.ANIMATIONTYPE_FLOAT,`${e}.uScale`,hr,()=>2),new gr(t.Animation.ANIMATIONTYPE_FLOAT,`${e}.vScale`,mr,()=>2)],offset:[new gr(t.Animation.ANIMATIONTYPE_FLOAT,`${e}.uOffset`,hr,()=>2),new gr(t.Animation.ANIMATIONTYPE_FLOAT,`${e}.vOffset`,mr,()=>2)],rotation:[new gr(t.Animation.ANIMATIONTYPE_FLOAT,`${e}.wAng`,dr,()=>1)]}}class fr extends ar{buildAnimations(e,t,n,r){return[{babylonAnimatable:e._babylonCamera,babylonAnimation:this._buildAnimation(t,n,r)}]}}class gr extends ar{buildAnimations(e,t,n,r){const s=[];for(const o in e._data)s.push({babylonAnimatable:e._data[o].babylonMaterial,babylonAnimation:this._buildAnimation(t,n,r)});return s}}class br extends ar{buildAnimations(e,t,n,r){return[{babylonAnimatable:e._babylonLight,babylonAnimation:this._buildAnimation(t,n,r)}]}}_e("/cameras/{}/orthographic/xmag",[new fr(t.Animation.ANIMATIONTYPE_FLOAT,"orthoLeft",dr,()=>1),new fr(t.Animation.ANIMATIONTYPE_FLOAT,"orthoRight",mr,()=>1)]),_e("/cameras/{}/orthographic/ymag",[new fr(t.Animation.ANIMATIONTYPE_FLOAT,"orthoBottom",dr,()=>1),new fr(t.Animation.ANIMATIONTYPE_FLOAT,"orthoTop",mr,()=>1)]),_e("/cameras/{}/orthographic/zfar",[new fr(t.Animation.ANIMATIONTYPE_FLOAT,"maxZ",hr,()=>1)]),_e("/cameras/{}/orthographic/znear",[new fr(t.Animation.ANIMATIONTYPE_FLOAT,"minZ",hr,()=>1)]),_e("/cameras/{}/perspective/yfov",[new fr(t.Animation.ANIMATIONTYPE_FLOAT,"fov",hr,()=>1)]),_e("/cameras/{}/perspective/zfar",[new fr(t.Animation.ANIMATIONTYPE_FLOAT,"maxZ",hr,()=>1)]),_e("/cameras/{}/perspective/znear",[new fr(t.Animation.ANIMATIONTYPE_FLOAT,"minZ",hr,()=>1)]),_e("/materials/{}/pbrMetallicRoughness/baseColorFactor",[new gr(t.Animation.ANIMATIONTYPE_COLOR3,"albedoColor",cr,()=>4),new gr(t.Animation.ANIMATIONTYPE_FLOAT,"alpha",function(e,t,n,r){return t[n+3]*r},()=>4)]),_e("/materials/{}/pbrMetallicRoughness/metallicFactor",[new gr(t.Animation.ANIMATIONTYPE_FLOAT,"metallic",hr,()=>1)]),_e("/materials/{}/pbrMetallicRoughness/metallicFactor",[new gr(t.Animation.ANIMATIONTYPE_FLOAT,"roughness",hr,()=>1)]);const yr=pr("albedoTexture");_e("/materials/{}/pbrMetallicRoughness/baseColorTexture/extensions/KHR_texture_transform/scale",yr.scale),_e("/materials/{}/pbrMetallicRoughness/baseColorTexture/extensions/KHR_texture_transform/offset",yr.offset),_e("/materials/{}/pbrMetallicRoughness/baseColorTexture/extensions/KHR_texture_transform/rotation",yr.rotation);const Tr=pr("metallicTexture");_e("//materials/{}/pbrMetallicRoughness/metallicRoughnessTexture/scale",Tr.scale),_e("//materials/{}/pbrMetallicRoughness/metallicRoughnessTexture/offset",Tr.offset),_e("//materials/{}/pbrMetallicRoughness/metallicRoughnessTexture/rotation",Tr.rotation),_e("/materials/{}/emissiveFactor",[new gr(t.Animation.ANIMATIONTYPE_COLOR3,"emissiveColor",cr,()=>3)]);const xr=pr("bumpTexture");_e("/materials/{}/normalTexture/scale",[new gr(t.Animation.ANIMATIONTYPE_FLOAT,"bumpTexture.level",hr,()=>1)]),_e("/materials/{}/normalTexture/extensions/KHR_texture_transform/scale",xr.scale),_e("/materials/{}/normalTexture/extensions/KHR_texture_transform/offset",xr.offset),_e("/materials/{}/normalTexture/extensions/KHR_texture_transform/rotation",xr.rotation),_e("/materials/{}/occlusionTexture/strength",[new gr(t.Animation.ANIMATIONTYPE_FLOAT,"ambientTextureStrength",hr,()=>1)]);const vr=pr("ambientTexture");_e("/materials/{}/occlusionTexture/extensions/KHR_texture_transform/scale",vr.scale),_e("/materials/{}/occlusionTexture/extensions/KHR_texture_transform/offset",vr.offset),_e("/materials/{}/occlusionTexture/extensions/KHR_texture_transform/rotation",vr.rotation);const Ar=pr("emissiveTexture");_e("/materials/{}/emissiveTexture/extensions/KHR_texture_transform/scale",Ar.scale),_e("/materials/{}/emissiveTexture/extensions/KHR_texture_transform/offset",Ar.offset),_e("/materials/{}/emissiveTexture/extensions/KHR_texture_transform/rotation",Ar.rotation),_e("/materials/{}/extensions/KHR_materials_anisotropy/anisotropyStrength",[new gr(t.Animation.ANIMATIONTYPE_FLOAT,"anisotropy.intensity",hr,()=>1)]),_e("/materials/{}/extensions/KHR_materials_anisotropy/anisotropyRotation",[new gr(t.Animation.ANIMATIONTYPE_FLOAT,"anisotropy.angle",hr,()=>1)]);const Cr=pr("anisotropy.texture");_e("/materials/{}/extensions/KHR_materials_anisotropy/anisotropyTexture/extensions/KHR_texture_transform/scale",Cr.scale),_e("/materials/{}/extensions/KHR_materials_anisotropy/anisotropyTexture/extensions/KHR_texture_transform/offset",Cr.offset),_e("/materials/{}/extensions/KHR_materials_anisotropy/anisotropyTexture/extensions/KHR_texture_transform/rotation",Cr.rotation),_e("/materials/{}/extensions/KHR_materials_clearcoat/clearcoatFactor",[new gr(t.Animation.ANIMATIONTYPE_FLOAT,"clearCoat.intensity",hr,()=>1)]),_e("/materials/{}/extensions/KHR_materials_clearcoat/clearcoatRoughnessFactor",[new gr(t.Animation.ANIMATIONTYPE_FLOAT,"clearCoat.roughness",hr,()=>1)]);const Rr=pr("clearCoat.texture");_e("/materials/{}/extensions/KHR_materials_clearcoat/clearcoatTexture/extensions/KHR_texture_transform/scale",Rr.scale),_e("/materials/{}/extensions/KHR_materials_clearcoat/clearcoatTexture/extensions/KHR_texture_transform/offset",Rr.offset),_e("/materials/{}/extensions/KHR_materials_clearcoat/clearcoatTexture/extensions/KHR_texture_transform/rotation",Rr.rotation);const Mr=pr("clearCoat.bumpTexture");_e("/materials/{}/extensions/KHR_materials_clearcoat/clearcoatNormalTexture/scale",[new gr(t.Animation.ANIMATIONTYPE_FLOAT,"clearCoat.bumpTexture.level",hr,()=>1)]),_e("/materials/{}/extensions/KHR_materials_clearcoat/clearcoatNormalTexture/extensions/KHR_texture_transform/scale",Mr.scale),_e("/materials/{}/extensions/KHR_materials_clearcoat/clearcoatNormalTexture/extensions/KHR_texture_transform/offset",Mr.offset),_e("/materials/{}/extensions/KHR_materials_clearcoat/clearcoatNormalTexture/extensions/KHR_texture_transform/rotation",Mr.rotation);const wr=pr("clearCoat.textureRoughness");_e("/materials/{}/extensions/KHR_materials_clearcoat/clearcoatRoughnessTexture/extensions/KHR_texture_transform/scale",wr.scale),_e("/materials/{}/extensions/KHR_materials_clearcoat/clearcoatRoughnessTexture/extensions/KHR_texture_transform/offset",wr.offset),_e("/materials/{}/extensions/KHR_materials_clearcoat/clearcoatRoughnessTexture/extensions/KHR_texture_transform/rotation",wr.rotation),_e("/materials/{}/extensions/KHR_materials_dispersion/dispersionFactor",[new gr(t.Animation.ANIMATIONTYPE_FLOAT,"subSurface.dispersion",hr,()=>1)]),_e("/materials/{}/extensions/KHR_materials_emissive_strength/emissiveStrength",[new gr(t.Animation.ANIMATIONTYPE_FLOAT,"emissiveIntensity",hr,()=>1)]),_e("/materials/{}/extensions/KHR_materials_ior/ior",[new gr(t.Animation.ANIMATIONTYPE_FLOAT,"indexOfRefraction",hr,()=>1)]),_e("/materials/{}/extensions/KHR_materials_iridescence/iridescenceFactor",[new gr(t.Animation.ANIMATIONTYPE_FLOAT,"iridescence.intensity",hr,()=>1)]),_e("/materials/{}/extensions/KHR_materials_iridescence/iridescenceIor",[new gr(t.Animation.ANIMATIONTYPE_FLOAT,"iridescence.indexOfRefraction",hr,()=>1)]),_e("/materials/{}/extensions/KHR_materials_iridescence/iridescenceThicknessMinimum",[new gr(t.Animation.ANIMATIONTYPE_FLOAT,"iridescence.minimumThickness",hr,()=>1)]),_e("/materials/{}/extensions/KHR_materials_iridescence/iridescenceThicknessMaximum",[new gr(t.Animation.ANIMATIONTYPE_FLOAT,"iridescence.maximumThickness",hr,()=>1)]);const Er=pr("iridescence.texture");_e("/materials/{}/extensions/KHR_materials_iridescence/iridescenceTexture/extensions/KHR_texture_transform/scale",Er.scale),_e("/materials/{}/extensions/KHR_materials_iridescence/iridescenceTexture/extensions/KHR_texture_transform/offset",Er.offset),_e("/materials/{}/extensions/KHR_materials_iridescence/iridescenceTexture/extensions/KHR_texture_transform/rotation",Er.rotation);const Or=pr("iridescence.thicknessTexture");_e("/materials/{}/extensions/KHR_materials_iridescence/iridescenceThicknessTexture/extensions/KHR_texture_transform/scale",Or.scale),_e("/materials/{}/extensions/KHR_materials_iridescence/iridescenceThicknessTexture/extensions/KHR_texture_transform/offset",Or.offset),_e("/materials/{}/extensions/KHR_materials_iridescence/iridescenceThicknessTexture/extensions/KHR_texture_transform/rotation",Or.rotation),_e("/materials/{}/extensions/KHR_materials_sheen/sheenColorFactor",[new gr(t.Animation.ANIMATIONTYPE_COLOR3,"sheen.color",cr,()=>3)]),_e("/materials/{}/extensions/KHR_materials_sheen/sheenRoughnessFactor",[new gr(t.Animation.ANIMATIONTYPE_FLOAT,"sheen.roughness",hr,()=>1)]);const Lr=pr("sheen.texture");_e("/materials/{}/extensions/KHR_materials_sheen/sheenColorTexture/extensions/KHR_texture_transform/scale",Lr.scale),_e("/materials/{}/extensions/KHR_materials_sheen/sheenColorTexture/extensions/KHR_texture_transform/offset",Lr.offset),_e("/materials/{}/extensions/KHR_materials_sheen/sheenColorTexture/extensions/KHR_texture_transform/rotation",Lr.rotation);const Sr=pr("sheen.textureRoughness");_e("/materials/{}/extensions/KHR_materials_sheen/sheenRoughnessTexture/extensions/KHR_texture_transform/scale",Sr.scale),_e("/materials/{}/extensions/KHR_materials_sheen/sheenRoughnessTexture/extensions/KHR_texture_transform/offset",Sr.offset),_e("/materials/{}/extensions/KHR_materials_sheen/sheenRoughnessTexture/extensions/KHR_texture_transform/rotation",Sr.rotation),_e("/materials/{}/extensions/KHR_materials_specular/specularFactor",[new gr(t.Animation.ANIMATIONTYPE_FLOAT,"metallicF0Factor",hr,()=>1)]),_e("/materials/{}/extensions/KHR_materials_specular/specularColorFactor",[new gr(t.Animation.ANIMATIONTYPE_COLOR3,"metallicReflectanceColor",cr,()=>3)]);const Fr=pr("metallicReflectanceTexture");_e("/materials/{}/extensions/KHR_materials_specular/specularTexture/extensions/KHR_texture_transform/scale",Fr.scale),_e("/materials/{}/extensions/KHR_materials_specular/specularTexture/extensions/KHR_texture_transform/offset",Fr.offset),_e("/materials/{}/extensions/KHR_materials_specular/specularTexture/extensions/KHR_texture_transform/rotation",Fr.rotation);const Ir=pr("reflectanceTexture");_e("/materials/{}/extensions/KHR_materials_specular/specularColorTexture/extensions/KHR_texture_transform/scale",Ir.scale),_e("/materials/{}/extensions/KHR_materials_specular/specularColorTexture/extensions/KHR_texture_transform/offset",Ir.offset),_e("/materials/{}/extensions/KHR_materials_specular/specularColorTexture/extensions/KHR_texture_transform/rotation",Ir.rotation),_e("/materials/{}/extensions/KHR_materials_transmission/transmissionFactor",[new gr(t.Animation.ANIMATIONTYPE_FLOAT,"subSurface.refractionIntensity",hr,()=>1)]);const Nr=pr("subSurface.refractionIntensityTexture");_e("/materials/{}/extensions/KHR_materials_transmission/transmissionTexture/extensions/KHR_texture_transform/scale",Nr.scale),_e("/materials/{}/extensions/KHR_materials_transmission/transmissionTexture/extensions/KHR_texture_transform/offset",Nr.offset),_e("/materials/{}/extensions/KHR_materials_transmission/transmissionTexture/extensions/KHR_texture_transform/rotation",Nr.rotation),_e("/materials/{}/extensions/KHR_materials_volume/attenuationColor",[new gr(t.Animation.ANIMATIONTYPE_COLOR3,"subSurface.tintColor",cr,()=>3)]),_e("/materials/{}/extensions/KHR_materials_volume/attenuationDistance",[new gr(t.Animation.ANIMATIONTYPE_FLOAT,"subSurface.tintColorAtDistance",hr,()=>1)]),_e("/materials/{}/extensions/KHR_materials_volume/thicknessFactor",[new gr(t.Animation.ANIMATIONTYPE_FLOAT,"subSurface.maximumThickness",hr,()=>1)]);const kr=pr("subSurface.thicknessTexture");_e("/materials/{}/extensions/KHR_materials_volume/thicknessTexture/extensions/KHR_texture_transform/scale",kr.scale),_e("/materials/{}/extensions/KHR_materials_volume/thicknessTexture/extensions/KHR_texture_transform/offset",kr.offset),_e("/materials/{}/extensions/KHR_materials_volume/thicknessTexture/extensions/KHR_texture_transform/rotation",kr.rotation),_e("/materials/{}/extensions/KHR_materials_diffuse_transmission/diffuseTransmissionFactor",[new gr(t.Animation.ANIMATIONTYPE_FLOAT,"subSurface.translucencyIntensity",hr,()=>1)]);const Pr=pr("subSurface.translucencyIntensityTexture");_e("materials/{}/extensions/KHR_materials_diffuse_transmission/diffuseTransmissionTexture/extensions/KHR_texture_transform/scale",Pr.scale),_e("materials/{}/extensions/KHR_materials_diffuse_transmission/diffuseTransmissionTexture/extensions/KHR_texture_transform/offset",Pr.offset),_e("materials/{}/extensions/KHR_materials_diffuse_transmission/diffuseTransmissionTexture/extensions/KHR_texture_transform/rotation",Pr.rotation),_e("/materials/{}/extensions/KHR_materials_diffuse_transmission/diffuseTransmissionColorFactor",[new gr(t.Animation.ANIMATIONTYPE_COLOR3,"subSurface.translucencyColor",cr,()=>3)]);const Br=pr("subSurface.translucencyColorTexture");_e("materials/{}/extensions/KHR_materials_diffuse_transmission/diffuseTransmissionColorTexture/extensions/KHR_texture_transform/scale",Br.scale),_e("materials/{}/extensions/KHR_materials_diffuse_transmission/diffuseTransmissionColorTexture/extensions/KHR_texture_transform/offset",Br.offset),_e("materials/{}/extensions/KHR_materials_diffuse_transmission/diffuseTransmissionColorTexture/extensions/KHR_texture_transform/rotation",Br.rotation),_e("/extensions/KHR_lights_punctual/lights/{}/color",[new br(t.Animation.ANIMATIONTYPE_COLOR3,"diffuse",cr,()=>3)]),_e("/extensions/KHR_lights_punctual/lights/{}/intensity",[new br(t.Animation.ANIMATIONTYPE_FLOAT,"intensity",hr,()=>1)]),_e("/extensions/KHR_lights_punctual/lights/{}/range",[new br(t.Animation.ANIMATIONTYPE_FLOAT,"range",hr,()=>1)]),_e("/extensions/KHR_lights_punctual/lights/{}/spot/innerConeAngle",[new br(t.Animation.ANIMATIONTYPE_FLOAT,"innerAngle",_r,()=>1)]),_e("/extensions/KHR_lights_punctual/lights/{}/spot/outerConeAngle",[new br(t.Animation.ANIMATIONTYPE_FLOAT,"angle",_r,()=>1)]),_e("/extensions/EXT_lights_area/lights/{}/color",[new br(t.Animation.ANIMATIONTYPE_COLOR3,"diffuse",cr,()=>3)]),_e("/extensions/EXT_lights_area/lights/{}/intensity",[new br(t.Animation.ANIMATIONTYPE_FLOAT,"intensity",hr,()=>1)]),_e("/extensions/EXT_lights_area/lights/{}/size",[new br(t.Animation.ANIMATIONTYPE_FLOAT,"radius",hr,()=>1)]),_e("/extensions/EXT_lights_area/lights/{}/rect/aspect",[new br(t.Animation.ANIMATIONTYPE_FLOAT,"radius",hr,()=>1)]),_e("/nodes/{}/extensions/EXT_lights_ies/color",[new br(t.Animation.ANIMATIONTYPE_COLOR3,"diffuse",cr,()=>3)]),_e("/nodes/{}/extensions/EXT_lights_ies/multiplier",[new br(t.Animation.ANIMATIONTYPE_FLOAT,"intensity",hr,()=>1)]),_e("/nodes/{}/extensions/KHR_node_visibility/visible",[new class extends ar{buildAnimations(e,t,n,r){return e._primitiveBabylonMeshes?e._primitiveBabylonMeshes.map(e=>({babylonAnimatable:e,babylonAnimation:this._buildAnimation(t,n,r)})):[]}}(t.Animation.ANIMATIONTYPE_FLOAT,"isVisible",hr,()=>1)]),nr();const Gr="MSFT_audio_emitter";class Dr{constructor(e){this.name=Gr,this._loader=e,this.enabled=this._loader.isExtensionUsed(Gr)}dispose(){this._loader=null,this._clips=null,this._emitters=null}onLoading(){const e=this._loader.gltf.extensions;if(e&&e[this.name]){const t=e[this.name];this._clips=t.clips,this._emitters=t.emitters,ve.Assign(this._clips),ve.Assign(this._emitters)}}loadSceneAsync(e,t){return Ce.LoadExtensionAsync(e,t,this.name,(n,r)=>v(this,void 0,void 0,function*(){const s=new Array;s.push(this._loader.loadSceneAsync(e,t));for(const e of r.emitters){const t=ve.Get(`${n}/emitters`,this._emitters,e);if(null!=t.refDistance||null!=t.maxDistance||null!=t.rolloffFactor||null!=t.distanceModel||null!=t.innerAngle||null!=t.outerAngle)throw new Error(`${n}: Direction or Distance properties are not allowed on emitters attached to a scene`);s.push(this._loadEmitterAsync(`${n}/emitters/${t.index}`,t))}yield Promise.all(s)}))}loadNodeAsync(e,n,r){return Ce.LoadExtensionAsync(e,n,this.name,(e,s)=>v(this,void 0,void 0,function*(){const o=new Array,a=yield this._loader.loadNodeAsync(e,n,n=>{for(const r of s.emitters){const s=ve.Get(`${e}/emitters`,this._emitters,r);o.push(this._loadEmitterAsync(`${e}/emitters/${s.index}`,s).then(()=>{for(const e of s._babylonSounds)e.attachToMesh(n),null==s.innerAngle&&null==s.outerAngle||(e.setLocalDirectionToMesh(t.Vector3.Forward()),e.setDirectionalCone(2*t.Tools.ToDegrees(null==s.innerAngle?Math.PI:s.innerAngle),2*t.Tools.ToDegrees(null==s.outerAngle?Math.PI:s.outerAngle),0))}))}r(n)});return yield Promise.all(o),a}))}loadAnimationAsync(e,t){return Ce.LoadExtensionAsync(e,t,this.name,(n,r)=>v(this,void 0,void 0,function*(){const s=yield this._loader.loadAnimationAsync(e,t),o=new Array;ve.Assign(r.events);for(const a of r.events)o.push(this._loadAnimationEventAsync(`${n}/events/${a.index}`,e,t,a,s));return yield Promise.all(o),s}))}_loadClipAsync(e,n){if(n._objectURL)return n._objectURL;let r;if(n.uri)r=this._loader.loadUriAsync(e,n,n.uri);else{const t=ve.Get(`${e}/bufferView`,this._loader.gltf.bufferViews,n.bufferView);r=this._loader.loadBufferViewAsync(`/bufferViews/${t.index}`,t)}return n._objectURL=r.then(e=>{const r=t.GetBlobBufferSource(e);return URL.createObjectURL(new Blob([r],{type:n.mimeType}))}),n._objectURL}_loadEmitterAsync(e,n){if(n._babylonSounds=n._babylonSounds||[],!n._babylonData){const e=new Array,r=n.name||`emitter${n.index}`,s={loop:!1,autoplay:!1,volume:null==n.volume?1:n.volume};for(let o=0;o<n.clips.length;o++){const a=`/extensions/${this.name}/clips`,i=ve.Get(a,this._clips,n.clips[o].clip);e.push(this._loadClipAsync(`${a}/${n.clips[o].clip}`,i).then(e=>{const a=n._babylonSounds[o]=new t.Sound(r,e,this._loader.babylonScene,null,s);a.refDistance=n.refDistance||1,a.maxDistance=n.maxDistance||256,a.rolloffFactor=n.rolloffFactor||1,a.distanceModel=n.distanceModel||"exponential"}))}const o=Promise.all(e).then(()=>{const e=n.clips.map(e=>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:o}}return n._babylonData.loaded}_getEventAction(e,t,n,r,s){switch(n){case"play":return e=>{const n=(s||0)+(e-r);t.play(n)};case"stop":return()=>{t.stop()};case"pause":return()=>{t.pause()};default:throw new Error(`${e}: Unsupported action ${n}`)}}_loadAnimationEventAsync(e,n,r,s,o){if(0==o.targetedAnimations.length)return Promise.resolve();const a=o.targetedAnimations[0],i=s.emitter,l=ve.Get(`/extensions/${this.name}/emitters`,this._emitters,i);return this._loadEmitterAsync(e,l).then(()=>{const n=l._babylonData.sound;if(n){const r=new t.AnimationEvent(s.time,this._getEventAction(e,n,s.action,s.time,s.startOffset));a.animation.addEvent(r),o.onAnimationGroupEndObservable.add(()=>{n.stop()}),o.onAnimationGroupPauseObservable.add(()=>{n.pause()})}})}}let Vr=!1;function Hr(){Vr||(Vr=!0,ye(Gr),be(Gr,!0,e=>new Dr(e)))}Hr();const $r="MSFT_lod";class Kr{constructor(e){var n,r;this.name=$r,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[$r])||void 0===n?void 0:n.maxLODsToLoad)&&void 0!==r?r:this.maxLODsToLoad,this.enabled=this._loader.isExtensionUsed($r)}dispose(){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()}onReady(){for(let e=0;e<this._nodePromiseLODs.length;e++){const t=Promise.all(this._nodePromiseLODs[e]).then(()=>{0!==e&&(this._loader.endPerformanceCounter(`Node LOD ${e}`),this._loader.log(`Loaded node LOD ${e}`)),this.onNodeLODsLoadedObservable.notifyObservers(e),e!==this._nodePromiseLODs.length-1&&(this._loader.startPerformanceCounter(`Node LOD ${e+1}`),this._loadBufferLOD(this._nodeBufferLODs,e+1),this._nodeSignalLODs[e]&&this._nodeSignalLODs[e].resolve())});this._loader._completePromises.push(t)}for(let e=0;e<this._materialPromiseLODs.length;e++){const t=Promise.all(this._materialPromiseLODs[e]).then(()=>{0!==e&&(this._loader.endPerformanceCounter(`Material LOD ${e}`),this._loader.log(`Loaded material LOD ${e}`)),this.onMaterialLODsLoadedObservable.notifyObservers(e),e!==this._materialPromiseLODs.length-1&&(this._loader.startPerformanceCounter(`Material LOD ${e+1}`),this._loadBufferLOD(this._materialBufferLODs,e+1),this._materialSignalLODs[e]&&this._materialSignalLODs[e].resolve())});this._loader._completePromises.push(t)}}loadSceneAsync(e,t){const n=this._loader.loadSceneAsync(e,t);return this._loadBufferLOD(this._bufferLODs,0),n}loadNodeAsync(e,n,r){return Ce.LoadExtensionAsync(e,n,this.name,(e,s)=>v(this,void 0,void 0,function*(){let o;const a=this._getLODs(e,n,this._loader.gltf.nodes,s.ids);this._loader.logOpen(`${e}`);for(let e=0;e<a.length;e++){const n=a[e];0!==e&&(this._nodeIndexLOD=e,this._nodeSignalLODs[e]=this._nodeSignalLODs[e]||new t.Deferred);const s=e=>{r(e),e.setEnabled(!1)},i=this._loader.loadNodeAsync(`/nodes/${n.index}`,n,s).then(t=>{if(0!==e){const t=a[e-1];t._babylonTransformNode&&(this._disposeTransformNode(t._babylonTransformNode),delete t._babylonTransformNode)}return t.setEnabled(!0),t});this._nodePromiseLODs[e]=this._nodePromiseLODs[e]||[],0===e?o=i:(this._nodeIndexLOD=null,this._nodePromiseLODs[e].push(i))}return this._loader.logClose(),yield o}))}_loadMaterialAsync(e,t,n,r,s){return this._nodeIndexLOD?null:Ce.LoadExtensionAsync(e,t,this.name,(e,o)=>v(this,void 0,void 0,function*(){let a;const i=this._getLODs(e,t,this._loader.gltf.materials,o.ids);this._loader.logOpen(`${e}`);for(let e=0;e<i.length;e++){const t=i[e];0!==e&&(this._materialIndexLOD=e);const o=this._loader._loadMaterialAsync(`/materials/${t.index}`,t,n,r,t=>{0===e&&s(t)}).then(t=>{if(0!==e){s(t);const n=i[e-1]._data;n[r]&&(this._disposeMaterials([n[r].babylonMaterial]),delete n[r])}return t});this._materialPromiseLODs[e]=this._materialPromiseLODs[e]||[],0===e?a=o:(this._materialIndexLOD=null,this._materialPromiseLODs[e].push(o))}return this._loader.logClose(),yield a}))}_loadUriAsync(e,n,r){if(null!==this._nodeIndexLOD){this._loader.log("deferred");const s=this._nodeIndexLOD-1;return this._nodeSignalLODs[s]=this._nodeSignalLODs[s]||new t.Deferred,this._nodeSignalLODs[this._nodeIndexLOD-1].promise.then(()=>v(this,void 0,void 0,function*(){return yield this._loader.loadUriAsync(e,n,r)}))}if(null!==this._materialIndexLOD){this._loader.log("deferred");const s=this._materialIndexLOD-1;return this._materialSignalLODs[s]=this._materialSignalLODs[s]||new t.Deferred,this._materialSignalLODs[s].promise.then(()=>v(this,void 0,void 0,function*(){return yield this._loader.loadUriAsync(e,n,r)}))}return null}loadBufferAsync(e,n,r,s){if(this._loader.parent.useRangeRequests&&!n.uri){if(!this._loader.bin)throw new Error(`${e}: Uri is missing or the binary glTF is missing its binary chunk`);const n=(e,n)=>v(this,void 0,void 0,function*(){const o=r,a=o+s-1;let i=e[n];return i?(i.start=Math.min(i.start,o),i.end=Math.max(i.end,a)):(i={start:o,end:a,loaded:new t.Deferred},e[n]=i),yield i.loaded.promise.then(e=>new Uint8Array(e.buffer,e.byteOffset+r-i.start,s))});return this._loader.log("deferred"),null!==this._nodeIndexLOD?n(this._nodeBufferLODs,this._nodeIndexLOD):null!==this._materialIndexLOD?n(this._materialBufferLODs,this._materialIndexLOD):n(this._bufferLODs,0)}return null}_loadBufferLOD(e,t){const n=e[t];n&&(this._loader.log(`Loading buffer range [${n.start}-${n.end}]`),this._loader.bin.readAsync(n.start,n.end-n.start+1).then(e=>{n.loaded.resolve(e)},e=>{n.loaded.reject(e)}))}_getLODs(e,t,n,r){if(this.maxLODsToLoad<=0)throw new Error("maxLODsToLoad must be greater than zero");const s=[];for(let t=r.length-1;t>=0;t--)if(s.push(ve.Get(`${e}/ids/${r[t]}`,n,r[t])),s.length===this.maxLODsToLoad)return s;return s.push(t),s}_disposeTransformNode(e){const t=[],n=e.material;n&&t.push(n);for(const n of e.getChildMeshes())n.material&&t.push(n.material);e.dispose();const r=t.filter(e=>this._loader.babylonScene.meshes.every(t=>t.material!=e));this._disposeMaterials(r)}_disposeMaterials(e){const t={};for(const n of e){for(const e of n.getActiveTextures())t[e.uniqueId]=e;n.dispose()}for(const e in t)for(const n of this._loader.babylonScene.materials)n.hasTexture(t[e])&&delete t[e];for(const e in t)t[e].dispose()}}let Wr=!1;function Ur(){Wr||(Wr=!0,ye($r),be($r,!0,e=>new Kr(e)))}Ur();const zr="MSFT_minecraftMesh";class jr{constructor(e){this.name=zr,this._loader=e,this.enabled=this._loader.isExtensionUsed(zr)}dispose(){this._loader=null}loadMaterialPropertiesAsync(e,t,n){return Ce.LoadExtraAsync(e,t,this.name,(r,s)=>v(this,void 0,void 0,function*(){if(s){if(!this._loader._pbrMaterialImpls.get("pbr"))throw new Error(`${r}: Material type not supported`);const s=this._loader.loadMaterialPropertiesAsync(e,t,n);return n.needAlphaBlending()&&(n.forceDepthWrite=!0,n.separateCullingPass=!0),n.backFaceCulling=n.forceDepthWrite,n.twoSidedLighting=!0,yield s}}))}}let qr=!1;function Yr(){qr||(qr=!0,ye(zr),be(zr,!0,e=>new jr(e)))}Yr();const Xr="MSFT_sRGBFactors";class Qr{constructor(e){this.name=Xr,this._loader=e,this.enabled=this._loader.isExtensionUsed(Xr)}dispose(){this._loader=null}loadMaterialPropertiesAsync(e,t,n){return Ce.LoadExtraAsync(e,t,this.name,(r,s)=>v(this,void 0,void 0,function*(){if(s){const r=this._loader._getOrCreateMaterialAdapter(n),s=this._loader.loadMaterialPropertiesAsync(e,t,n),o=n.getScene().getEngine().useExactSrgbConversions;return r.baseColorTexture||r.baseColor.toLinearSpaceToRef(r.baseColor,o),r.specularColorTexture||r.specularColor.toLinearSpaceToRef(r.specularColor,o),yield s}}))}}let Zr=!1;function Jr(){Zr||(Zr=!0,ye(Xr),be(Xr,!0,e=>new Qr(e)))}function es(e){const[t,n]=e.split(":");return ts({op:t,extension:n})}function ts(e,n=!0){var r;const s=e.extension?null===(r=rs[e.extension])||void 0===r?void 0:r[e.op]:ss[e.op];if(!s&&(t.Logger.Warn(`No mapping found for operation ${e.op} and extension ${e.extension||"KHR_interactivity"}`),n)){const t={},n={flows:{}};if(e.inputValueSockets){t.values={};for(const n in e.inputValueSockets)t.values[n]={name:n}}return e.outputValueSockets&&(n.values={},Object.keys(e.outputValueSockets).forEach(e=>{n.values[e]={name:e}})),{blocks:[],inputs:t,outputs:n}}return s}function ns(e,t,n){rs[t]||(rs[t]={}),rs[t][e]=n}Jr();const rs={BABYLON:{"flow/log":{blocks:["FlowGraphConsoleLogBlock"],inputs:{values:{message:{name:"message"}}}}}},ss={"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(e,t,n,r,s){var o;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");const a=null===(o=e.configuration.event.value)||void 0===o?void 0:o[0];if("number"!=typeof a)throw new Error("Event id should be a number");const i=r.arrays.events[a],l=s[0];return l.config||(l.config={}),l.config.eventId=i.eventId,l.config.eventData=i.eventData,s}},"event/receive":{blocks:["FlowGraphReceiveCustomEventBlock"],outputs:{flows:{out:{name:"done"}}},validation(e,n){var r,s;if(!e.configuration)return t.Logger.Error("Receive event should have a configuration object"),{valid:!1,error:"Receive event should have a configuration object"};const o=e.configuration.event;if(!o)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"};const a=null===(r=o.value)||void 0===r?void 0:r[0];return"number"!=typeof a?(t.Logger.Error("Event id should be a number"),{valid:!1,error:"Event id should be a number"}):(null===(s=n.events)||void 0===s?void 0:s[a])?{valid:!0}:(t.Logger.Error(`Event with id ${a} not found`),{valid:!1,error:`Event with id ${a} not found`})},extraProcessor(e,t,n,r,s){var o;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");const a=null===(o=e.configuration.event.value)||void 0===o?void 0:o[0];if("number"!=typeof a)throw new Error("Event id should be a number");const i=r.arrays.events[a],l=s[0];return l.config||(l.config={}),l.config.eventId=i.eventId,l.config.eventData=i.eventData,s}},"math/E":os("FlowGraphEBlock"),"math/Pi":os("FlowGraphPIBlock"),"math/Inf":os("FlowGraphInfBlock"),"math/NaN":os("FlowGraphNaNBlock"),"math/abs":os("FlowGraphAbsBlock"),"math/sign":os("FlowGraphSignBlock"),"math/trunc":os("FlowGraphTruncBlock"),"math/floor":os("FlowGraphFloorBlock"),"math/ceil":os("FlowGraphCeilBlock"),"math/round":{blocks:["FlowGraphRoundBlock"],configuration:{},inputs:{values:{a:{name:"a"}}},outputs:{values:{value:{name:"value"}}},extraProcessor(e,t,n,r,s){var o;return(o=s[0]).config||(o.config={}),s[0].config.roundHalfAwayFromZero=!0,s}},"math/fract":os("FlowGraphFractBlock"),"math/neg":os("FlowGraphNegationBlock"),"math/add":os("FlowGraphAddBlock",["a","b"],!0),"math/sub":os("FlowGraphSubtractBlock",["a","b"],!0),"math/mul":{blocks:["FlowGraphMultiplyBlock"],extraProcessor(e,t,n,r,s){var o;(o=s[0]).config||(o.config={}),s[0].config.useMatrixPerComponent=!0,s[0].config.preventIntegerFloatArithmetic=!0;let a=-1;return Object.keys(e.values||{}).find(t=>{var n;return void 0!==(null===(n=e.values)||void 0===n?void 0:n[t].type)&&(a=e.values[t].type,!0)}),-1!==a&&(s[0].config.type=r.arrays.types[a].flowGraphType),s},validation:e=>e.values?as(e):{valid:!0}},"math/div":os("FlowGraphDivideBlock",["a","b"],!0),"math/rem":os("FlowGraphModuloBlock",["a","b"]),"math/min":os("FlowGraphMinBlock",["a","b"]),"math/max":os("FlowGraphMaxBlock",["a","b"]),"math/clamp":os("FlowGraphClampBlock",["a","b","c"]),"math/saturate":os("FlowGraphSaturateBlock"),"math/mix":os("FlowGraphMathInterpolationBlock",["a","b","c"]),"math/eq":os("FlowGraphEqualityBlock",["a","b"]),"math/lt":os("FlowGraphLessThanBlock",["a","b"]),"math/le":os("FlowGraphLessThanOrEqualBlock",["a","b"]),"math/gt":os("FlowGraphGreaterThanBlock",["a","b"]),"math/ge":os("FlowGraphGreaterThanOrEqualBlock",["a","b"]),"math/isNaN":os("FlowGraphIsNaNBlock"),"math/isInf":os("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":os("FlowGraphSinBlock"),"math/cos":os("FlowGraphCosBlock"),"math/tan":os("FlowGraphTanBlock"),"math/asin":os("FlowGraphASinBlock"),"math/acos":os("FlowGraphACosBlock"),"math/atan":os("FlowGraphATanBlock"),"math/atan2":os("FlowGraphATan2Block",["a","b"]),"math/sinh":os("FlowGraphSinhBlock"),"math/cosh":os("FlowGraphCoshBlock"),"math/tanh":os("FlowGraphTanhBlock"),"math/asinh":os("FlowGraphASinhBlock"),"math/acosh":os("FlowGraphACoshBlock"),"math/atanh":os("FlowGraphATanhBlock"),"math/exp":os("FlowGraphExponentialBlock"),"math/log":os("FlowGraphLogBlock"),"math/log2":os("FlowGraphLog2Block"),"math/log10":os("FlowGraphLog10Block"),"math/sqrt":os("FlowGraphSquareRootBlock"),"math/cbrt":os("FlowGraphCubeRootBlock"),"math/pow":os("FlowGraphPowerBlock",["a","b"]),"math/length":os("FlowGraphLengthBlock"),"math/normalize":os("FlowGraphNormalizeBlock"),"math/dot":os("FlowGraphDotBlock",["a","b"]),"math/cross":os("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":os("FlowGraphTransposeBlock"),"math/determinant":os("FlowGraphDeterminantBlock"),"math/inverse":os("FlowGraphInvertMatrixBlock"),"math/matMul":os("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(e,t,n,r,s,o){const a=s[0].dataInputs.find(e=>"rotationQuaternion"===e.name);if(!a)throw new Error("Rotation quaternion input not found");return o._connectionValues[a.uniqueId]&&(o._connectionValues[a.uniqueId].type="Quaternion"),s}},"math/matDecompose":{blocks:["FlowGraphMatrixDecompose"],inputs:{values:{a:{name:"input",gltfType:"number"}}},outputs:{values:{translation:{name:"position"},rotation:{name:"rotationQuaternion"},scale:{name:"scaling"}}}},"math/quatConjugate":os("FlowGraphConjugateBlock",["a"]),"math/quatMul":{blocks:["FlowGraphMultiplyBlock"],inputs:{values:{a:{name:"a",gltfType:"vector4"},b:{name:"b",gltfType:"vector4"}}},outputs:{values:{value:{name:"value"}}},extraProcessor(e,t,n,r,s){var o;return(o=s[0]).config||(o.config={}),s[0].config.type="Quaternion",s}},"math/quatAngleBetween":os("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":os("FlowGraphAxisAngleFromQuaternionBlock",["a"]),"math/quatFromDirections":os("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(e,t,n,r,s){var o;return(o=s[0]).config||(o.config={}),s[0].config.inputIsColumnMajor=!0,s}},"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(e,t,n,r,s){var o;return(o=s[0]).config||(o.config={}),s[0].config.inputIsColumnMajor=!0,s}},"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(e,t,n,r,s){var o;return(o=s[0]).config||(o.config={}),s[0].config.inputIsColumnMajor=!0,s}},"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(e,t,n,r,s,o){var a,i,l;(l=s[0]).config||(l.config={});const u=s[0].dataInputs[0];return s[0].config.valueType=null!==(i=null===(a=o._connectionValues[u.uniqueId])||void 0===a?void 0:a.type)&&void 0!==i?i:"FlowGraphInteger",s}},"math/and":{blocks:["FlowGraphBitwiseAndBlock"],inputs:{values:{a:{name:"a"},b:{name:"b"}}},outputs:{values:{value:{name:"value"}}},extraProcessor(e,t,n,r,s,o){var a,i,l,u,c;(c=s[0]).config||(c.config={});const h=s[0].dataInputs[0],d=s[0].dataInputs[1];return s[0].config.valueType=null!==(u=null!==(i=null===(a=o._connectionValues[h.uniqueId])||void 0===a?void 0:a.type)&&void 0!==i?i:null===(l=o._connectionValues[d.uniqueId])||void 0===l?void 0:l.type)&&void 0!==u?u:"FlowGraphInteger",s}},"math/or":{blocks:["FlowGraphBitwiseOrBlock"],inputs:{values:{a:{name:"a"},b:{name:"b"}}},outputs:{values:{value:{name:"value"}}},extraProcessor(e,t,n,r,s,o){var a,i,l,u,c;(c=s[0]).config||(c.config={});const h=s[0].dataInputs[0],d=s[0].dataInputs[1];return s[0].config.valueType=null!==(u=null!==(i=null===(a=o._connectionValues[h.uniqueId])||void 0===a?void 0:a.type)&&void 0!==i?i:null===(l=o._connectionValues[d.uniqueId])||void 0===l?void 0:l.type)&&void 0!==u?u:"FlowGraphInteger",s}},"math/xor":{blocks:["FlowGraphBitwiseXorBlock"],inputs:{values:{a:{name:"a"},b:{name:"b"}}},outputs:{values:{value:{name:"value"}}},extraProcessor(e,t,n,r,s,o){var a,i,l,u,c;(c=s[0]).config||(c.config={});const h=s[0].dataInputs[0],d=s[0].dataInputs[1];return s[0].config.valueType=null!==(u=null!==(i=null===(a=o._connectionValues[h.uniqueId])||void 0===a?void 0:a.type)&&void 0!==i?i:null===(l=o._connectionValues[d.uniqueId])||void 0===l?void 0:l.type)&&void 0!==u?u:"FlowGraphInteger",s}},"math/asr":os("FlowGraphBitwiseRightShiftBlock",["a","b"]),"math/lsl":os("FlowGraphBitwiseLeftShiftBlock",["a","b"]),"math/clz":os("FlowGraphLeadingZerosBlock"),"math/ctz":os("FlowGraphTrailingZerosBlock"),"math/popcnt":os("FlowGraphOneBitsCounterBlock"),"math/rad":os("FlowGraphDegToRadBlock"),"math/deg":os("FlowGraphRadToDegBlock"),"type/boolToInt":os("FlowGraphBooleanToInt"),"type/boolToFloat":os("FlowGraphBooleanToFloat"),"type/intToBool":os("FlowGraphIntToBoolean"),"type/intToFloat":os("FlowGraphIntToFloat"),"type/floatToInt":os("FlowGraphFloatToInt"),"type/floatToBool":os("FlowGraphFloatToBoolean"),"flow/sequence":{blocks:["FlowGraphSequenceBlock"],extraProcessor(e,t,n,r,s){const o=s[0];return o.config||(o.config={}),o.config.outputSignalCount=Object.keys(e.flows||[]).length,o.signalOutputs.forEach((e,t)=>{e.name="out_"+t}),s}},"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(e){var n;const r=null===(n=e.configuration)||void 0===n?void 0:n.cases;if(r&&r.value){if(!r.value.every(e=>"number"==typeof e&&/^-?\d+$/.test(e.toString())))return t.Logger.Warn("Switch cases should be integers. Using empty array instead."),r.value=[],{valid:!0};const e=new Set(r.value);r.value=Array.from(e)}return{valid:!0}},extraProcessor(e,t,n,r,s){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 s[0].signalOutputs.forEach(e=>{"default"!==e.name&&(e.name="out_"+e.name)}),s}},"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(e,t,n,r,s){const o=s[0];return o.config||(o.config={}),o.config.incrementIndexWhenLoopDone=!0,s}},"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(e,t,n,r,s){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");const o=s[0];return o.config||(o.config={}),o.config.outputSignalCount=Object.keys(e.flows).length,o.signalOutputs.forEach((e,t)=>{e.name="out_"+t}),s}},"flow/waitAll":{blocks:["FlowGraphWaitAllBlock"],configuration:{inputFlows:{name:"inputSignalCount",gltfType:"number",inOptions:!0,defaultValue:0}},inputs:{flows:{reset:{name:"reset"},"[segment]":{name:"in_$1"}}},validation(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(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:(e,t)=>t.getVariableName(e)}}},"variable/set":{blocks:["FlowGraphSetVariableBlock"],configuration:{variables:{name:"variables",gltfType:"number",flowGraphType:"string",inOptions:!0,isArray:!0,dataTransformer:(e,t)=>e.map(e=>t.getVariableName(e))}},extraProcessor:(e,t,n,r,s)=>(s[0].dataInputs.forEach(e=>{e.name=r.getVariableName(+e.name)}),s)},"variable/interpolate":{blocks:["FlowGraphInterpolationBlock","FlowGraphContextBlock","FlowGraphPlayAnimationBlock","FlowGraphBezierCurveEasing","FlowGraphGetVariableBlock"],configuration:{variable:{name:"propertyName",inOptions:!0,isVariable:!0,dataTransformer:(e,t)=>t.getVariableName(e)},useSlerp:{name:"animationType",inOptions:!0,defaultValue:!1,dataTransformer:e=>!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(e,n,r,s,o){var a,i,l,u,c,h;const d=o[0],m=null===(i=null===(a=e.configuration)||void 0===a?void 0:a.variable.value)||void 0===i?void 0:i[0];if("number"!=typeof m)throw t.Logger.Error("Variable index is not defined for variable interpolation block"),new Error("Variable index is not defined for variable interpolation block");const _=s.arrays.staticVariables[m];void 0===(null===(u=null===(l=d.config)||void 0===l?void 0:l.animationType)||void 0===u?void 0:u.value)&&(d.config||(d.config={}),(c=d.config).animationType||(c.animationType={}),d.config.animationType.value=t.getAnimationTypeByFlowGraphType(_.type));const p=o[4];return p.config||(p.config={}),(h=p.config).variable||(h.variable={}),p.config.variable.value=s.getVariableName(m),o}},"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:(e,t,n,r,s)=>(s.forEach(e=>{"FlowGraphJsonPointerParserBlock"===e.className&&(e.config||(e.config={}),e.config.outputValue=!0)}),s)},"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:(e,t,n,r,s)=>(s.forEach(e=>{"FlowGraphJsonPointerParserBlock"===e.className&&(e.config||(e.config={}),e.config.outputValue=!0)}),s)},"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:(e,t,n,r,s)=>(s.forEach(t=>{"FlowGraphJsonPointerParserBlock"===t.className?(t.config||(t.config={}),t.config.outputValue=!0):"FlowGraphInterpolationBlock"===t.className&&(t.config||(t.config={}),Object.keys(e.values||[]).forEach(n=>{var s;const o=null===(s=e.values)||void 0===s?void 0:s[n];if("value"===n&&o){const e=o.type;void 0!==e&&(t.config.animationType=r.arrays.types[e].flowGraphType)}}))}),s)},"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:(e,t)=>[e[0]*t._animationTargetFps]},endTime:{name:"to",gltfType:"number",dataTransformer:(e,t)=>[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(e,t,n,r,s,o,a){const i=s[s.length-1];return i.config||(i.config={}),i.config.glTF=a,s}},"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(e,t,n,r,s,o,a){const i=s[s.length-1];return i.config||(i.config={}),i.config.glTF=a,s}},"animation/stopAt":{blocks:["FlowGraphStopAnimationBlock","FlowGraphArrayIndexBlock","KHR_interactivity/FlowGraphGLTFDataProvider"],configuration:{},inputs:{values:{animation:{name:"index",gltfType:"number",toBlock:"FlowGraphArrayIndexBlock"},stopTime:{name:"stopAtFrame",gltfType:"number",dataTransformer:(e,t)=>[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(e,t,n,r,s,o,a){const i=s[s.length-1];return i.config||(i.config={}),i.config.glTF=a,s}},"math/switch":{blocks:["FlowGraphDataSwitchBlock"],configuration:{cases:{name:"cases",isArray:!0,inOptions:!0,defaultValue:[]}},inputs:{values:{selection:{name:"case"}}},validation(e){var n;const r=null===(n=e.configuration)||void 0===n?void 0:n.cases;if(r&&r.value){if(!r.value.every(e=>"number"==typeof e&&/^-?\d+$/.test(e.toString())))return t.Logger.Warn("Switch cases should be integers. Using empty array instead."),r.value=[],{valid:!0};const e=new Set(r.value);r.value=Array.from(e)}return{valid:!0}},extraProcessor(e,t,n,r,s){const o=s[0];return o.dataInputs.forEach(e=>{"default"!==e.name&&"case"!==e.name&&(e.name="in_"+e.name)}),o.config||(o.config={}),o.config.treatCasesAsIntegers=!0,s}},"debug/log":{blocks:["FlowGraphConsoleLogBlock"],configuration:{message:{name:"messageTemplate",inOptions:!0}}}};function os(e,t=["a"],n){return{blocks:[e],inputs:{values:t.reduce((e,t)=>(e[t]={name:t},e),{})},outputs:{values:{value:{name:"value"}}},extraProcessor(e,t,r,s,o){var a;if(n){(a=o[0]).config||(a.config={}),o[0].config.preventIntegerFloatArithmetic=!0;let t=-1;Object.keys(e.values||{}).find(n=>{var r;return void 0!==(null===(r=e.values)||void 0===r?void 0:r[n].type)&&(t=e.values[n].type,!0)}),-1!==t&&(o[0].config.type=s.arrays.types[t].flowGraphType)}return o},validation:e=>n?as(e):{valid:!0}}}function as(e){if(e.values){const t=Object.keys(e.values).map(t=>e.values[t].type).filter(e=>void 0!==e);if(!t.every(e=>e===t[0]))return{valid:!1,error:"All inputs must be of the same type"}}return{valid:!0}}function is(){return Object.keys(ss)}const ls={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"}};class us{constructor(e,t,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()}get arrays(){return{types:this._types,mappings:this._mappings,staticVariables:this._staticVariables,events:this._events,nodes:this._nodes}}_parseTypes(){if(this._interactivityGraph.types)for(const e of this._interactivityGraph.types)this._types.push(ls[e.signature])}_parseDeclarations(){if(this._interactivityGraph.declarations)for(const e of this._interactivityGraph.declarations){const n=ts(e);if(!n)throw t.Logger.Error(["No mapping found for declaration",e]),new Error("Error parsing declarations");this._mappings.push({flowGraphMapping:n,fullOperationName:e.extension?e.op+":"+e.extension:e.op})}}_parseVariables(){if(this._interactivityGraph.variables)for(const e of this._interactivityGraph.variables){const t=this._parseVariable(e);this._staticVariables.push(t)}}_parseVariable(e,n){const 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");const s=e.value||[];if(!s.length)switch(r.flowGraphType){case"boolean":s.push(!1);break;case"FlowGraphInteger":s.push(0);break;case"number":s.push(NaN);break;case"Vector2":s.push(NaN,NaN);break;case"Vector3":s.push(NaN,NaN,NaN);break;case"Vector4":case"Matrix2D":case"Quaternion":s.fill(NaN,0,4);break;case"Matrix":s.fill(NaN,0,16);break;case"Matrix3D":s.fill(NaN,0,9)}return"number"===r.elementType&&"string"==typeof s[0]&&(s[0]=parseFloat(s[0])),{type:r.flowGraphType,value:n?n(s,this):s}}_parseEvents(){if(this._interactivityGraph.events)for(const e of this._interactivityGraph.events){const n={eventId:e.id||"internalEvent_"+this._internalEventsCounter++};e.values&&(n.eventData=Object.keys(e.values).map(n=>{var r;const s=null===(r=e.values)||void 0===r?void 0:r[n];if(!s)throw t.Logger.Error(["No value found for event key",n]),new Error("Error parsing events");const o=this._types[s.type];if(!o)throw t.Logger.Error(["No type found for event value",s]),new Error("Error parsing events");const a=void 0!==s.value?this._parseVariable(s):void 0;return{id:n,type:o.flowGraphType,eventData:!0,value:a}})),this._events.push(n)}}_parseNodes(){var e;if(this._interactivityGraph.nodes)for(const n of this._interactivityGraph.nodes){if("number"!=typeof n.declaration)throw t.Logger.Error(["No declaration found for node",n]),new Error("Error parsing nodes");const r=this._mappings[n.declaration];if(!r)throw t.Logger.Error(["No mapping found for node",n]),new Error("Error parsing nodes");if(r.flowGraphMapping.validation){const t=r.flowGraphMapping.validation(n,this._interactivityGraph,this._gltf);if(!t.valid)throw new Error(`Error validating interactivity node ${null===(e=this._interactivityGraph.declarations)||void 0===e?void 0:e[n.declaration].op} - ${t.error}`)}const s=[];for(const e of r.flowGraphMapping.blocks){const t=this._getEmptyBlock(e,r.fullOperationName);this._parseNodeConfiguration(n,t,r.flowGraphMapping,e),s.push(t)}this._nodes.push({blocks:s,fullOperationName:r.fullOperationName})}}_getEmptyBlock(e,n){return{uniqueId:t.RandomGUID(),className:e,dataInputs:[],dataOutputs:[],signalInputs:[],signalOutputs:[],config:{},type:n,metadata:{}}}_parseNodeConfiguration(e,n,r,s){var o;const a=e.configuration;if(a)for(const e in a){const i=a[e];if(!i)throw new Error("Error parsing node configuration");const l=null===(o=r.configuration)||void 0===o?void 0:o[e];if(l&&l.toBlock?l.toBlock===s:0===r.blocks.indexOf(s)){let r=null==l?void 0:l.defaultValue;(null==i?void 0:i.value)&&(r=i.value),(null==l?void 0:l.isArray)||(1!==r.length&&t.Logger.Warn(`Invalid non-array value length: ${r.length}`),r=r[0]),(null==l?void 0:l.dataTransformer)&&(r=l.dataTransformer(r,this)),void 0!==r&&(n.config[(null==l?void 0:l.name)||e]={value:r})}}}_parseNodeConnections(e){var n,r,s,o,a,i,l,u,c,h,d,m,_,p,f,g,b,y,T;for(let x=0;x<this._nodes.length;x++){const v=null===(n=this._interactivityGraph.nodes)||void 0===n?void 0:n[x];if(!v)throw t.Logger.Error(["No node found for interactivity node",this._nodes[x]]),new Error("Error parsing node connections");const A=this._nodes[x],C=this._mappings[v.declaration];if(!C)throw t.Logger.Error(["No mapping found for node",v]),new Error("Error parsing node connections");const R=v.flows||{},M=Object.keys(R).sort();for(const e of M){const n=R[e],c=null===(s=null===(r=C.flowGraphMapping.outputs)||void 0===r?void 0:r.flows)||void 0===s?void 0:s[e],h=(null==c?void 0:c.name)||e,d=this._createNewSocketConnection(h,!0);(c&&c.toBlock&&A.blocks.find(e=>e.className===c.toBlock)||A.blocks[0]).signalOutputs.push(d);const m=n.node,_=this._nodes[m];if(!_)throw t.Logger.Error(["No node found for input node id",m]),new Error("Error parsing node connections");const p=es(_.fullOperationName);if(!p)throw t.Logger.Error(["No mapping found for input node",_]),new Error("Error parsing node connections");let f=null===(a=null===(o=p.inputs)||void 0===o?void 0:o.flows)||void 0===a?void 0:a[n.socket||"in"],g=!1;if(!f)for(const e in null===(i=p.inputs)||void 0===i?void 0:i.flows)e.startsWith("[")&&e.endsWith("]")&&(g=!0,f=null===(u=null===(l=p.inputs)||void 0===l?void 0:l.flows)||void 0===u?void 0:u[e]);const b=f?g?f.name.replace("$1",n.socket||""):f.name:n.socket||"in",y=f&&f.toBlock&&_.blocks.find(e=>e.className===f.toBlock)||_.blocks[0];let T=y.signalInputs.find(e=>e.name===b);T||(T=this._createNewSocketConnection(b),y.signalInputs.push(T)),T.connectedPointIds.push(d.uniqueId),d.connectedPointIds.push(T.uniqueId)}const w=v.values||{},E=Object.keys(w);for(const n of E){const r=w[n];let s=null===(h=null===(c=C.flowGraphMapping.inputs)||void 0===c?void 0:c.values)||void 0===h?void 0:h[n],o=!1;if(!s)for(const e in null===(d=C.flowGraphMapping.inputs)||void 0===d?void 0:d.values)e.startsWith("[")&&e.endsWith("]")&&(o=!0,s=null===(_=null===(m=C.flowGraphMapping.inputs)||void 0===m?void 0:m.values)||void 0===_?void 0:_[e]);const a=s?o?s.name.replace("$1",n):s.name:n,i=this._createNewSocketConnection(a);if((s&&s.toBlock&&A.blocks.find(e=>e.className===s.toBlock)||A.blocks[0]).dataInputs.push(i),void 0!==r.value){const t=this._parseVariable(r,s&&s.dataTransformer);e._connectionValues[i.uniqueId]=t}else{if(void 0===r.node)throw t.Logger.Error(["Invalid value for value connection",r]),new Error("Error parsing node connections");{const e=r.node,n=r.socket||"value",s=this._nodes[e];if(!s)throw t.Logger.Error(["No node found for output socket reference",r]),new Error("Error parsing node connections");const o=es(s.fullOperationName);if(!o)throw t.Logger.Error(["No mapping found for output socket reference",r]),new Error("Error parsing node connections");let a=null===(f=null===(p=o.outputs)||void 0===p?void 0:p.values)||void 0===f?void 0:f[n],l=!1;if(!a)for(const e in null===(g=o.outputs)||void 0===g?void 0:g.values)e.startsWith("[")&&e.endsWith("]")&&(l=!0,a=null===(y=null===(b=o.outputs)||void 0===b?void 0:b.values)||void 0===y?void 0:y[e]);const u=a?l?a.name.replace("$1",n):null==a?void 0:a.name:n,c=a&&a.toBlock&&s.blocks.find(e=>e.className===a.toBlock)||s.blocks[0];let h=c.dataOutputs.find(e=>e.name===u);h||(h=this._createNewSocketConnection(u,!0),c.dataOutputs.push(h)),i.connectedPointIds.push(h.uniqueId),h.connectedPointIds.push(i.uniqueId)}}}if(C.flowGraphMapping.interBlockConnectors)for(const e of C.flowGraphMapping.interBlockConnectors){const t=e.input,n=e.output,r=e.isVariable;this._connectFlowGraphNodes(t,n,A.blocks[e.inputBlockIndex],A.blocks[e.outputBlockIndex],r)}if(C.flowGraphMapping.extraProcessor){const n=null===(T=this._interactivityGraph.declarations)||void 0===T?void 0:T[v.declaration];if(!n)throw t.Logger.Error(["No declaration found for extra processor",v]),new Error("Error parsing node connections");A.blocks=C.flowGraphMapping.extraProcessor(v,n,C.flowGraphMapping,this,A.blocks,e,this._gltf)}}}_createNewSocketConnection(e,n){return{uniqueId:t.RandomGUID(),name:e,_connectionType:n?1:0,connectedPointIds:[]}}_connectFlowGraphNodes(e,t,n,r,s){const o=s?n.dataInputs:n.signalInputs,a=s?r.dataOutputs:r.signalOutputs,i=o.find(t=>t.name===e)||this._createNewSocketConnection(e),l=a.find(e=>e.name===t)||this._createNewSocketConnection(t,!0);o.find(t=>t.name===e)||o.push(i),a.find(e=>e.name===t)||a.push(l),i.connectedPointIds.push(l.uniqueId),l.connectedPointIds.push(i.uniqueId)}getVariableName(e){return"staticVariable_"+e}serializeToFlowGraph(){const e={uniqueId:t.RandomGUID(),_userVariables:{},_connectionValues:{}};this._parseNodeConnections(e);for(let t=0;t<this._staticVariables.length;t++){const n=this._staticVariables[t];e._userVariables[this.getVariableName(t)]=n}return{rightHanded:!0,allBlocks:this._nodes.reduce((e,t)=>e.concat(t.blocks),[]),executionContexts:[e]}}}const cs="KHR_interactivity";class hs{constructor(e){this._loader=e,this.name=cs,this.enabled=this._loader.isExtensionUsed(cs),this._pathConverter=de(this._loader.gltf),e._skipStartAnimationStep=!0;const t=e.babylonScene;t&&ds(t)}dispose(){this._loader=null,delete this._pathConverter}onReady(){return v(this,void 0,void 0,function*(){var e;if(!this._loader.babylonScene||!this._pathConverter)return;const n=this._loader.babylonScene,r=null===(e=this._loader.gltf.extensions)||void 0===e?void 0:e.KHR_interactivity;if(!r)return;const s=new t.FlowGraphCoordinator({scene:n});s.dispatchEventsSynchronously=!1;const o=r.graphs.map(e=>new us(e,this._loader.gltf,this._loader.parent.targetFps).serializeToFlowGraph());yield Promise.all(o.map(e=>v(this,void 0,void 0,function*(){return yield t.ParseFlowGraphAsync(e,{coordinator:s,pathConverter:this._pathConverter})}))),s.start()})}}function ds(e){pe("/extensions/KHR_interactivity/?/activeCamera/rotation",{get:()=>{if(!e.activeCamera)return new t.Quaternion(NaN,NaN,NaN,NaN);const n=t.Quaternion.FromRotationMatrix(e.activeCamera.getWorldMatrix()).normalize();return e.useRightHandedSystem||(n.w*=-1,n.x*=-1),n},type:"Quaternion",getTarget:()=>e.activeCamera}),pe("/extensions/KHR_interactivity/?/activeCamera/position",{get:()=>{if(!e.activeCamera)return new t.Vector3(NaN,NaN,NaN);const n=e.activeCamera.getWorldMatrix().getTranslation();return e.useRightHandedSystem||(n.x*=-1),n},type:"Vector3",getTarget:()=>e.activeCamera}),pe("/animations/{}/extensions/KHR_interactivity/isPlaying",{get: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:e=>e._babylonAnimationGroup}),pe("/animations/{}/extensions/KHR_interactivity/minTime",{get: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:e=>e._babylonAnimationGroup}),pe("/animations/{}/extensions/KHR_interactivity/maxTime",{get: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:e=>e._babylonAnimationGroup}),pe("/animations/{}/extensions/KHR_interactivity/playhead",{get: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:e=>e._babylonAnimationGroup}),pe("/animations/{}/extensions/KHR_interactivity/virtualPlayhead",{get: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:e=>e._babylonAnimationGroup})}let ms=!1;function _s(){ms||(ms=!0,t.addToBlockFactory(cs,"FlowGraphGLTFDataProvider",()=>v(this,void 0,void 0,function*(){return(yield Promise.resolve().then(function(){return Ns})).FlowGraphGLTFDataProvider})),ye(cs),be(cs,!0,e=>new hs(e)))}_s();const ps="KHR_node_visibility";class fs{constructor(e){this.name=ps,this._loader=e,this.enabled=e.isExtensionUsed(ps)}onReady(){if(!this._loader)return;const e=this._loader.gltf.nodes;if(e)for(const t of e){const e=t._babylonTransformNode;e&&(e.inheritVisibility=!0,t.extensions&&t.extensions.KHR_node_visibility&&!1===t.extensions.KHR_node_visibility.visible&&(e.isVisible=!1))}}dispose(){delete this._loader}}let gs=!1;function bs(){gs||(gs=!0,pe("/nodes/{}/extensions/KHR_node_visibility/visible",{get:e=>{const t=e._babylonTransformNode;return!t||void 0===t.isVisible||t.isVisible},set:(e,t)=>{var n,r;null===(n=t._primitiveBabylonMeshes)||void 0===n||n.forEach(e=>{e.inheritVisibility=!0}),t._babylonTransformNode&&(t._babylonTransformNode.isVisible=e),null===(r=t._primitiveBabylonMeshes)||void 0===r||r.forEach(t=>{t.isVisible=e})},getTarget:e=>e._babylonTransformNode,getPropertyName:[()=>"isVisible"],type:"boolean"}),ye(ps),be(ps,!0,e=>new fs(e)))}bs();const ys="KHR_node_selectability";class Ts{constructor(e){this.name=ys,this._loader=e,this.enabled=e.isExtensionUsed(ys)}onReady(){return v(this,void 0,void 0,function*(){var e;null===(e=this._loader.gltf.nodes)||void 0===e||e.forEach(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(e=>{e.isPickable=!1}))})})}dispose(){this._loader=null}}let xs=!1;function vs(){xs||(xs=!0,ns("event/onSelect",ys,{blocks:["FlowGraphMeshPickEventBlock","FlowGraphGetVariableBlock","FlowGraphIndexOfBlock","KHR_interactivity/FlowGraphGLTFDataProvider"],configuration:{stopPropagation:{name:"stopPropagation"},nodeIndex:{name:"variable",toBlock:"FlowGraphGetVariableBlock",dataTransformer:e=>"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(e,t,n,r,s,o,a){var i,l,u,c,h,d,m;const _=s[s.length-1];_.config=_.config||{},_.config.glTF=a;const p=null===(u=null===(l=null===(i=e.configuration)||void 0===i?void 0:i.nodeIndex)||void 0===l?void 0:l.value)||void 0===u?void 0:u[0];if(void 0===p||"number"!=typeof p)throw new Error("nodeIndex not found in configuration");const f="pickedMesh_"+p;return s[1].config.variable=f,o._userVariables[f]={className:"Mesh",id:null===(h=null===(c=null==a?void 0:a.nodes)||void 0===c?void 0:c[p]._babylonTransformNode)||void 0===h?void 0:h.id,uniqueId:null===(m=null===(d=null==a?void 0:a.nodes)||void 0===d?void 0:d[p]._babylonTransformNode)||void 0===m?void 0:m.uniqueId},s}}),pe("/nodes/{}/extensions/KHR_node_selectability/selectable",{get:e=>{const t=e._babylonTransformNode;return!t||void 0===t.isPickable||t.isPickable},set:(e,t)=>{var n;null===(n=t._primitiveBabylonMeshes)||void 0===n||n.forEach(t=>{t.isPickable=e})},getTarget:e=>e._babylonTransformNode,getPropertyName:[()=>"isPickable"],type:"boolean"}),ye(ys),be(ys,!0,e=>new Ts(e)))}vs();const As="KHR_node_hoverability",Cs="targetMeshPointerOver_",Rs="targetMeshPointerOut_";class Ms{constructor(e){this.name=As,this._loader=e,this.enabled=e.isExtensionUsed(As)}onReady(){return v(this,void 0,void 0,function*(){var e;null===(e=this._loader.gltf.nodes)||void 0===e||e.forEach(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(e=>{e.pointerOverDisableMeshTesting=!0}))})})}dispose(){this._loader=null}}let ws=!1;function Es(){ws||(ws=!0,ns("event/onHoverIn",As,{blocks:["FlowGraphPointerOverEventBlock","FlowGraphGetVariableBlock","FlowGraphIndexOfBlock","KHR_interactivity/FlowGraphGLTFDataProvider"],configuration:{stopPropagation:{name:"stopPropagation"},nodeIndex:{name:"variable",toBlock:"FlowGraphGetVariableBlock",dataTransformer:e=>Cs+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(e,t,n,r,s,o,a){var i,l,u,c,h,d,m;const _=s[s.length-1];_.config=_.config||{},_.config.glTF=a;const p=null===(u=null===(l=null===(i=e.configuration)||void 0===i?void 0:i.nodeIndex)||void 0===l?void 0:l.value)||void 0===u?void 0:u[0];if(void 0===p||"number"!=typeof p)throw new Error("nodeIndex not found in configuration");const f=Cs+p;return s[1].config.variable=f,o._userVariables[f]={className:"Mesh",id:null===(h=null===(c=null==a?void 0:a.nodes)||void 0===c?void 0:c[p]._babylonTransformNode)||void 0===h?void 0:h.id,uniqueId:null===(m=null===(d=null==a?void 0:a.nodes)||void 0===d?void 0:d[p]._babylonTransformNode)||void 0===m?void 0:m.uniqueId},s}}),ns("event/onHoverOut",As,{blocks:["FlowGraphPointerOutEventBlock","FlowGraphGetVariableBlock","FlowGraphIndexOfBlock","KHR_interactivity/FlowGraphGLTFDataProvider"],configuration:{stopPropagation:{name:"stopPropagation"},nodeIndex:{name:"variable",toBlock:"FlowGraphGetVariableBlock",dataTransformer:e=>Rs+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(e,t,n,r,s,o,a){var i,l,u,c,h,d,m;const _=s[s.length-1];_.config=_.config||{},_.config.glTF=a;const p=null===(u=null===(l=null===(i=e.configuration)||void 0===i?void 0:i.nodeIndex)||void 0===l?void 0:l.value)||void 0===u?void 0:u[0];if(void 0===p||"number"!=typeof p)throw new Error("nodeIndex not found in configuration");const f=Rs+p;return s[1].config.variable=f,o._userVariables[f]={className:"Mesh",id:null===(h=null===(c=null==a?void 0:a.nodes)||void 0===c?void 0:c[p]._babylonTransformNode)||void 0===h?void 0:h.id,uniqueId:null===(m=null===(d=null==a?void 0:a.nodes)||void 0===d?void 0:d[p]._babylonTransformNode)||void 0===m?void 0:m.uniqueId},s}}),pe("/nodes/{}/extensions/KHR_node_hoverability/hoverable",{get:e=>{const t=e._babylonTransformNode;return!t||void 0===t.pointerOverDisableMeshTesting||t.pointerOverDisableMeshTesting},set:(e,t)=>{var n;null===(n=t._primitiveBabylonMeshes)||void 0===n||n.forEach(t=>{t.pointerOverDisableMeshTesting=!e})},getTarget:e=>e._babylonTransformNode,getPropertyName:[()=>"pointerOverDisableMeshTesting"],type:"boolean"}),ye(As),be(As,!0,e=>new Ms(e)))}Es();const Os="ExtrasAsMetadata";class Ls{_assignExtras(e,t){if(t.extras&&Object.keys(t.extras).length>0){const n=e.metadata=e.metadata||{};(n.gltf=n.gltf||{}).extras=t.extras}}constructor(e){this.name=Os,this.enabled=!0,this._loader=e}dispose(){this._loader=null}loadNodeAsync(e,t,n){return this._loader.loadNodeAsync(e,t,e=>{this._assignExtras(e,t),n(e)})}loadCameraAsync(e,t,n){return this._loader.loadCameraAsync(e,t,e=>{this._assignExtras(e,t),n(e)})}createMaterial(e,t,n){const r=this._loader.createMaterial(e,t,n);return this._assignExtras(r,t),r}loadAnimationAsync(e,t){return this._loader.loadAnimationAsync(e,t).then(e=>(this._assignExtras(e,t),e))}}let Ss=!1;function Fs(){Ss||(Ss=!0,ye(Os),be(Os,!1,e=>new Ls(e)))}Fs();class Is extends t.FlowGraphBlock{constructor(e){var n,r;super(e);const s=e.glTF,o=(null===(n=null==s?void 0:s.animations)||void 0===n?void 0:n.map(e=>e._babylonAnimationGroup))||[];this.animationGroups=this.registerDataOutput("animationGroups",t.RichTypeAny,o);const a=(null===(r=null==s?void 0:s.nodes)||void 0===r?void 0:r.map(e=>e._babylonTransformNode))||[];this.nodes=this.registerDataOutput("nodes",t.RichTypeAny,a)}getClassName(){return"FlowGraphGLTFDataProvider"}}var Ns={__proto__:null,FlowGraphGLTFDataProvider:Is},ks={__proto__:null,AddObjectAccessorToKey:pe,EXT_lights_area:mt,EXT_lights_ies:qe,EXT_lights_image_based:Ee,EXT_mesh_gpu_instancing:Fe,EXT_meshopt_compression:Pe,EXT_texture_avif:We,EXT_texture_webp:Ve,ExtrasAsMetadata:Ls,FlowGraphGLTFDataProvider:Is,GetMappingForKey:me,GetPathToObjectConverter:de,InteractivityGraphToFlowGraphParser:us,KHR_animation_pointer:er,KHR_draco_mesh_compression:Ze,KHR_gaussian_splatting:ot,KHR_interactivity:hs,KHR_lights:ut,KHR_materials_anisotropy:Bt,KHR_materials_clearcoat:Rt,KHR_materials_coat:Ot,KHR_materials_diffuse_roughness:Nn,KHR_materials_diffuse_transmission:bn,KHR_materials_dispersion:Ln,KHR_materials_emissive_strength:Ht,KHR_materials_fuzz:Yt,KHR_materials_ior:rn,KHR_materials_iridescence:It,KHR_materials_pbrSpecularGlossiness:gt,KHR_materials_sheen:Ut,KHR_materials_specular:Jt,KHR_materials_transmission:_n,KHR_materials_unlit:xt,KHR_materials_variants:ln,KHR_materials_volume:vn,KHR_materials_volume_scatter:Mn,KHR_mesh_quantization:Gn,KHR_node_hoverability:Ms,KHR_node_selectability:Ts,KHR_node_visibility:fs,KHR_texture_basisu:$n,KHR_texture_transform:zn,KHR_xmp_json_ld:Xn,MSFT_audio_emitter:Dr,MSFT_lod:Kr,MSFT_minecraftMesh:jr,MSFT_sRGBFactors:Qr,RegisterEXT_lights_area:pt,RegisterEXT_lights_ies:Xe,RegisterEXT_lights_image_based:Le,RegisterEXT_mesh_gpu_instancing:Ne,RegisterEXT_meshopt_compression:Ge,RegisterEXT_texture_avif:ze,RegisterEXT_texture_webp:$e,RegisterExtrasAsMetadata:Fs,RegisterKHR_animation_pointer:nr,RegisterKHR_draco_mesh_compression:et,RegisterKHR_gaussian_splatting:it,RegisterKHR_interactivity:_s,RegisterKHR_lights:ht,RegisterKHR_materials_anisotropy:Dt,RegisterKHR_materials_clearcoat:wt,RegisterKHR_materials_coat:St,RegisterKHR_materials_diffuse_roughness:Pn,RegisterKHR_materials_diffuse_transmission:Tn,RegisterKHR_materials_dispersion:Fn,RegisterKHR_materials_emissive_strength:Kt,RegisterKHR_materials_fuzz:Qt,RegisterKHR_materials_ior:on,RegisterKHR_materials_iridescence:kt,RegisterKHR_materials_pbrSpecularGlossiness:yt,RegisterKHR_materials_sheen:jt,RegisterKHR_materials_specular:tn,RegisterKHR_materials_transmission:fn,RegisterKHR_materials_unlit:At,RegisterKHR_materials_variants:cn,RegisterKHR_materials_volume:Cn,RegisterKHR_materials_volume_scatter:En,RegisterKHR_mesh_quantization:Vn,RegisterKHR_node_hoverability:Es,RegisterKHR_node_selectability:vs,RegisterKHR_node_visibility:bs,RegisterKHR_texture_basisu:Wn,RegisterKHR_texture_transform:qn,RegisterKHR_xmp_json_ld:Zn,RegisterMSFT_audio_emitter:Hr,RegisterMSFT_lod:Ur,RegisterMSFT_minecraftMesh:Yr,RegisterMSFT_sRGBFactors:Jr,SetInterpolationForKey:_e,TransmissionHelper:hn,_AddInteractivityObjectModel:ds,addNewInteractivityFlowGraphMapping:ns,ensureTransmissionHelper:dn,getAllSupportedNativeNodeTypes:is,getMappingForDeclaration:ts,getMappingForFullOperationName:es,gltfTypeToBabylonType:ls};Me(),y();class Ps{constructor(e){this._specWorkflow=!1,this._diffuseTransmissionTint=t.Color3.White(),this._diffuseTransmissionTintTexture=null,this._material=e}get material(){return this._material}get isUnlit(){return this._material.unlit}set isUnlit(e){this._material.unlit=e}set backFaceCulling(e){this._material.backFaceCulling=e}get backFaceCulling(){return this._material.backFaceCulling}set twoSidedLighting(e){this._material.twoSidedLighting=e}get twoSidedLighting(){return this._material.twoSidedLighting}set alphaCutOff(e){this._material.alphaCutOff=e}get alphaCutOff(){return this._material.alphaCutOff}set useAlphaFromBaseColorTexture(e){this._material._useAlphaFromBaseColorTexture=e}get useAlphaFromBaseColorTexture(){return this._material._useAlphaFromBaseColorTexture}get transparencyAsAlphaCoverage(){return!1}set transparencyAsAlphaCoverage(e){}set baseColor(e){this._material.baseColor=e}get baseColor(){return this._material.baseColor}set baseColorTexture(e){this._material.baseColorTexture=e}get baseColorTexture(){return this._material.baseColorTexture}set baseDiffuseRoughness(e){this._material.baseDiffuseRoughness=e}get baseDiffuseRoughness(){return this._material.baseDiffuseRoughness}set baseDiffuseRoughnessTexture(e){this._material.baseDiffuseRoughnessTexture=e}get baseDiffuseRoughnessTexture(){return this._material.baseDiffuseRoughnessTexture}set baseMetalness(e){this._material.baseMetalness=e}get baseMetalness(){return this._material.baseMetalness}set baseMetalnessTexture(e){this._material.baseMetalnessTexture=e}get baseMetalnessTexture(){return this._material.baseMetalnessTexture}set useRoughnessFromMetallicTextureGreen(e){this._material._useRoughnessFromMetallicTextureGreen=e}set useMetallicFromMetallicTextureBlue(e){this._material._useMetallicFromMetallicTextureBlue=e}enableSpecularEdgeColor(e=!1){}configureSpecularGlossiness(){this._specWorkflow=!0}set specularWeight(e){this._material.specularWeight=e}get specularWeight(){return this._material.specularWeight}set specularWeightTexture(e){this._material.specularColorTexture===e?(this._material.specularWeightTexture=null,this._material._useSpecularWeightFromSpecularColorTexture=!0,this._material._useSpecularWeightFromAlpha=!0):this._material.specularWeightTexture=e}get specularWeightTexture(){return this._material.specularWeightTexture}set specularColor(e){this._material.specularColor=e}get specularColor(){return this._material.specularColor}set specularColorTexture(e){this._material.specularColorTexture=e,this._material.specularWeightTexture===this._material.specularColorTexture&&(this._material.specularWeightTexture=null,this._material._useSpecularWeightFromSpecularColorTexture=!0,this._material._useSpecularWeightFromAlpha=!0)}get specularColorTexture(){return this._material.specularColorTexture}set specularRoughness(e){this._material.specularRoughness=e}get specularRoughness(){return this._material.specularRoughness}set specularRoughnessTexture(e){this._material.specularRoughnessTexture=e}get specularRoughnessTexture(){return this._material.specularRoughnessTexture}set specularIor(e){this._material.specularIor=e}get specularIor(){return this._material.specularIor}set glossiness(e){this._material.specularRoughness=Math.max(1-e,0)}get glossiness(){return 1-this._material.specularRoughness}set emissionColor(e){this._material.emissionColor=e}get emissionColor(){return this._material.emissionColor}set emissionLuminance(e){this._material.emissionLuminance=e}get emissionLuminance(){return this._material.emissionLuminance}set emissionColorTexture(e){this._material.emissionColorTexture=e}get emissionColorTexture(){return this._material.emissionColorTexture}set ambientOcclusionTexture(e){this._material.ambientOcclusionTexture=e}get ambientOcclusionTexture(){return this._material.ambientOcclusionTexture}set ambientOcclusionTextureStrength(e){const t=this._material.ambientOcclusionTexture;t&&(t.level=e)}get ambientOcclusionTextureStrength(){var e;const t=this._material.ambientOcclusionTexture;return null!==(e=null==t?void 0:t.level)&&void 0!==e?e:1}configureCoat(){}set coatWeight(e){this._material.coatWeight=e}get coatWeight(){return this._material.coatWeight}set coatWeightTexture(e){this._material.coatWeightTexture=e}get coatWeightTexture(){return this._material.coatWeightTexture}set coatColor(e){this._material.coatColor=e}get coatColor(){return this._material.coatColor}set coatColorTexture(e){this._material.coatColorTexture=e}set coatRoughness(e){this._material.coatRoughness=e}get coatRoughness(){return this._material.coatRoughness}set coatRoughnessTexture(e){this._material.coatRoughnessTexture=e,e&&(this._material._useCoatRoughnessFromGreenChannel=!0)}get coatRoughnessTexture(){return this._material.coatRoughnessTexture}set coatIor(e){this._material.coatIor=e}get coatIor(){return this._material.coatIor}set coatDarkening(e){this._material.coatDarkening=e}get coatDarkening(){return this._material.coatDarkening}set coatDarkeningTexture(e){this._material.coatDarkeningTexture=e}set coatRoughnessAnisotropy(e){this._material.coatRoughnessAnisotropy=e}get coatRoughnessAnisotropy(){return this._material.coatRoughnessAnisotropy}set geometryCoatTangentAngle(e){this._material.geometryCoatTangentAngle=e}set geometryCoatTangentTexture(e){this._material.geometryCoatTangentTexture=e,e&&(this._material._useCoatRoughnessAnisotropyFromTangentTexture=!0)}get geometryCoatTangentTexture(){return this._material.geometryCoatTangentTexture}configureTransmission(){this._material.geometryThinWalled=1,this._material.transmissionDepth=0}set transmissionWeight(e){this._material.transmissionWeight=e}set transmissionWeightTexture(e){this._material.transmissionWeightTexture=e}get transmissionWeightTexture(){return this._material.transmissionWeightTexture}get transmissionWeight(){return this._material.transmissionWeight}set transmissionScatter(e){this._material.transmissionScatter=e}get transmissionScatter(){return this._material.transmissionScatter}set transmissionScatterTexture(e){this._material.transmissionScatterTexture=e}get transmissionScatterTexture(){return this._material.transmissionScatterTexture}set transmissionScatterAnisotropy(e){this._material.transmissionScatterAnisotropy=e}set transmissionDispersionAbbeNumber(e){this._material.transmissionDispersionAbbeNumber=e}set transmissionDispersionScale(e){this._material.transmissionDispersionScale=e}set transmissionDepth(e){e!==Number.MAX_VALUE||0!==this._material.transmissionDepth?this._material.transmissionDepth=e:this._material.transmissionDepth=0}get transmissionDepth(){return this._material.transmissionDepth}set transmissionColor(e){e.equals(t.Color3.White())||(this._material.transmissionColor=e)}get transmissionColor(){return this._material.transmissionColor}get refractionBackgroundTexture(){return this._material.backgroundRefractionTexture}set refractionBackgroundTexture(e){this._material.backgroundRefractionTexture=e}configureVolume(){this._material.geometryThinWalled=0}set geometryThinWalled(e){this._material.geometryThinWalled=e?1:0}get geometryThinWalled(){return!!this._material.geometryThinWalled}set volumeThicknessTexture(e){this._material.geometryThicknessTexture=e,this._material._useGeometryThicknessFromGreenChannel=!0}set volumeThickness(e){this._material.geometryThickness=e}configureSubsurface(){this._material.geometryThinWalled=1,this._material.subsurfaceScatterAnisotropy=1}set subsurfaceWeight(e){this._material.subsurfaceWeight=e}get subsurfaceWeight(){return this._material.subsurfaceWeight}set subsurfaceWeightTexture(e){this._material.subsurfaceWeightTexture=e,this._material._useSubsurfaceWeightFromTextureAlpha=!0}get subsurfaceWeightTexture(){return this._material.subsurfaceWeightTexture}set subsurfaceColor(e){this._material.subsurfaceColor=e}set subsurfaceColorTexture(e){this._material.subsurfaceColorTexture=e}set diffuseTransmissionTint(e){this._diffuseTransmissionTint=e}get diffuseTransmissionTint(){return this._diffuseTransmissionTint}set diffuseTransmissionTintTexture(e){this._diffuseTransmissionTintTexture=e}get subsurfaceRadius(){return this._material.subsurfaceRadius}set subsurfaceRadius(e){this._material.subsurfaceRadius=e}get subsurfaceRadiusScale(){return this._material.subsurfaceRadiusScale}set subsurfaceRadiusScale(e){this._material.subsurfaceRadiusScale=e}set subsurfaceScatterAnisotropy(e){this._material.subsurfaceScatterAnisotropy=e}isTranslucent(){return this.transmissionWeight>0||this.subsurfaceWeight>0}configureFuzz(){}set fuzzWeight(e){this._material.fuzzWeight=e}set fuzzWeightTexture(e){this._material.fuzzWeightTexture=e}set fuzzColor(e){this._material.fuzzColor=e}set fuzzColorTexture(e){this._material.fuzzColorTexture=e}set fuzzRoughness(e){this._material.fuzzRoughness=e}set fuzzRoughnessTexture(e){this._material.fuzzRoughnessTexture=e,this._material._useFuzzRoughnessFromTextureAlpha=!0}set specularRoughnessAnisotropy(e){this._material.specularRoughnessAnisotropy=e}get specularRoughnessAnisotropy(){return this._material.specularRoughnessAnisotropy}set geometryTangentAngle(e){this._material.geometryTangentAngle=e}set geometryTangentTexture(e){this._material.geometryTangentTexture=e,this._material._useSpecularRoughnessAnisotropyFromTangentTexture=!0}get geometryTangentTexture(){return this._material.geometryTangentTexture}configureGltfStyleAnisotropy(e=!0){this._material._useGltfStyleAnisotropy=e}set thinFilmWeight(e){this._material.thinFilmWeight=e}set thinFilmIor(e){this._material.thinFilmIor=e}set thinFilmThicknessMinimum(e){this._material.thinFilmThicknessMin=e/1e3}set thinFilmThicknessMaximum(e){this._material.thinFilmThickness=e/1e3}set thinFilmWeightTexture(e){this._material.thinFilmWeightTexture=e}set thinFilmThicknessTexture(e){this._material.thinFilmThicknessTexture=e,this._material._useThinFilmThicknessFromTextureGreen=!0}set unlit(e){this._material.unlit=e}set geometryOpacity(e){this._material.geometryOpacity=e}get geometryOpacity(){return this._material.geometryOpacity}set geometryNormalTexture(e){this._material.geometryNormalTexture=e}get geometryNormalTexture(){return this._material.geometryNormalTexture}setNormalMapInversions(e,t){}set geometryCoatNormalTexture(e){this._material.geometryCoatNormalTexture=e}get geometryCoatNormalTexture(){return this._material.geometryCoatNormalTexture}set geometryCoatNormalTextureScale(e){this._material.geometryCoatNormalTexture&&(this._material.geometryCoatNormalTexture.level=e)}finalizeAsync(e){return v(this,void 0,void 0,function*(){var n,r,s;if(this._diffuseTransmissionTint&&!this._diffuseTransmissionTint.equals(t.Color3.White())||this._diffuseTransmissionTintTexture)if(this._material.geometryThinWalled)this.subsurfaceColor=this._diffuseTransmissionTint,this.subsurfaceColorTexture=this._diffuseTransmissionTintTexture;else if(yield this.copySurfaceToCoatAsync(e,this.subsurfaceWeight,this.subsurfaceWeightTexture,t.TextureChannel.A,this._diffuseTransmissionTint,this._diffuseTransmissionTintTexture,!0),e._disposed)return;if(this.transmissionWeight>0)if(this._material.geometryThinWalled||0===this._material.transmissionDepth)this._material.transmissionColor=this._material.baseColor,this._material.transmissionColorTexture=this._material.baseColorTexture;else if((!this.baseColor.equals(t.Color3.White())||null!==this.baseColorTexture)&&(yield this.copySurfaceToCoatAsync(e,this.transmissionWeight,this.transmissionWeightTexture,t.TextureChannel.R,this.baseColor,this.baseColorTexture,!1),e._disposed))return;if(this._specWorkflow){const o=yield t.InvertTextureAsync("newRoughnessTexture ("+this._material.name+")",yield 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),this._material.getScene(),t.ChannelMask.R,t.TextureColorSpace.Linear,t.ChannelMask.R);if(e._disposed)return void(null===(n=o.texture)||void 0===n||n.dispose());this.specularRoughnessTexture=o.texture,this.specularRoughness=o.factor?o.factor.r:1;const a=yield 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);if(e._disposed)return void(null===(r=a.texture)||void 0===r||r.dispose());this.baseMetalnessTexture=a.texture,this.baseMetalness=a.factor?a.factor.r:1;const i=yield 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),Object.assign(Object.assign({},a),{dispose:void 0,colorSpace:t.TextureColorSpace.Linear}),this._material.getScene(),t.TextureColorSpace.SRGB,t.ChannelMask.RGB);if(e._disposed)return void(null===(s=i.texture)||void 0===s||s.dispose());const l=this.baseColorTexture;null==l||l.dispose(),this.baseColorTexture=i.texture,this.baseColor=i.factor?new t.Color3(i.factor.r,i.factor.g,i.factor.b):t.Color3.White();const u=this.specularColorTexture;null==u||u.dispose(),this.specularColorTexture=null}})}copySurfaceToCoatAsync(e,n,r,s,o,a){return v(this,arguments,void 0,function*(e,n,r,s,o,a,i=!1){var l,u,c,h,d,m,_,p,f;const g=this._material.coatWeight,b=this._material.coatWeightTexture,y=this._material.coatColor.clone(),T=this._material.coatColorTexture,x=this._material.geometryCoatNormalTexture,v=new t.Color4(g,g,g,g),A=new t.Color4(n,n,n,n);this.coatWeightTexture=null,this.coatWeight=1;const C=yield Promise.allSettled([t.LerpTexturesAsync("lerpExistingCoat",t.CreateTextureWithFactorOperand(null,new t.Color4(1,1,1,1)),t.CreateTextureWithFactorOperand(T,y.toColor4(),t.TextureChannel.RGBA,t.TextureColorSpace.SRGB),t.CreateTextureWithFactorOperand(b,v,t.TextureChannel.R),this._material.getScene(),t.TextureColorSpace.SRGB),t.LerpTexturesAsync("lerpSurfaceColor",t.CreateTextureWithFactorOperand(null,new t.Color4(1,1,1,1)),t.CreateTextureWithFactorOperand(a,o.toColor4(),t.TextureChannel.RGBA,t.TextureColorSpace.SRGB),t.CreateTextureWithFactorOperand(r,A,s),this._material.getScene(),t.TextureColorSpace.SRGB)]),R=C.find(e=>"rejected"===e.status);if(R){for(const e of C)"fulfilled"===e.status&&(null===(l=e.value.texture)||void 0===l||l.dispose());throw R.reason}const[M,w]=C.map(e=>e.value);if(e._disposed)return null===(u=M.texture)||void 0===u||u.dispose(),void(null===(c=w.texture)||void 0===c||c.dispose());const E=yield t.MultiplyTexturesAsync("newCoatColor ("+this._material.name+")",M,w,this._material.getScene(),t.TextureColorSpace.SRGB);if(e._disposed)return void(null===(h=E.texture)||void 0===h||h.dispose());E.texture?(this.coatColorTexture=E.texture,this.coatColor=t.Color3.White()):E.factor&&(this.coatColorTexture=null,this.coatColor.fromArray([E.factor.r,E.factor.g,E.factor.b]));const O=yield 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(b,v,t.TextureChannel.R),this._material.getScene());if(e._disposed)return void(null===(d=O.texture)||void 0===d||d.dispose());this.coatIor=O.factor?O.factor.r:this.coatIor;const L=yield 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(b,v,t.TextureChannel.R),this._material.getScene());if(e._disposed)return void(null===(m=L.texture)||void 0===m||m.dispose());this.coatRoughness=L.factor?L.factor.r:1,this.coatRoughnessTexture=L.texture;const S=yield 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(b,v,t.TextureChannel.R),this._material.getScene());if(e._disposed)null===(_=S.texture)||void 0===_||_.dispose();else{if(this.coatDarkening=S.factor?S.factor.r:this.coatDarkening,i){const n=yield 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,A,s),this._material.getScene());if(e._disposed)return void(null===(p=n.texture)||void 0===p||p.dispose());this.specularRoughness=n.factor?n.factor.r:1,this.specularRoughnessTexture=n.texture}if(x||this.geometryNormalTexture){const n=yield 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(x,x?new t.Color4(1,1,1,1):new t.Color4(.5,.5,1,1),t.TextureChannel.RGBA),t.CreateTextureWithFactorOperand(b,v,t.TextureChannel.R),this._material.getScene());if(e._disposed)return void(null===(f=n.texture)||void 0===f||f.dispose());n.texture&&(this.geometryCoatNormalTexture=n.texture)}}})}}var Bs={__proto__:null,OpenPBRMaterialLoadingAdapter:Ps};class Gs{constructor(e){this._specWorkflow=!1,this._material=e,this._material.enableSpecularAntiAliasing=!0}get material(){return this._material}finalizeAsync(e){return v(this,void 0,void 0,function*(){})}get isUnlit(){return this._material.unlit}set isUnlit(e){this._material.unlit=e}set backFaceCulling(e){this._material.backFaceCulling=e}get backFaceCulling(){return this._material.backFaceCulling}set twoSidedLighting(e){this._material.twoSidedLighting=e}get twoSidedLighting(){return this._material.twoSidedLighting}set alphaCutOff(e){this._material.alphaCutOff=e}get alphaCutOff(){return this._material.alphaCutOff}set useAlphaFromBaseColorTexture(e){this._material.useAlphaFromAlbedoTexture=e}get useAlphaFromBaseColorTexture(){return this._material.useAlphaFromAlbedoTexture}get transparencyAsAlphaCoverage(){return this._material.useRadianceOverAlpha||this._material.useSpecularOverAlpha}set transparencyAsAlphaCoverage(e){this._material.useRadianceOverAlpha=!e,this._material.useSpecularOverAlpha=!e}set baseColor(e){this._material.albedoColor=e}get baseColor(){return this._material.albedoColor}set baseColorTexture(e){this._material.albedoTexture=e}get baseColorTexture(){return this._material.albedoTexture}set baseDiffuseRoughness(e){this._material.baseDiffuseRoughness=e,e>0&&(this._material.brdf.baseDiffuseModel=t.Constants.MATERIAL_DIFFUSE_MODEL_E_OREN_NAYAR)}get baseDiffuseRoughness(){var e;return null!==(e=this._material.baseDiffuseRoughness)&&void 0!==e?e:0}set baseDiffuseRoughnessTexture(e){this._material.baseDiffuseRoughnessTexture=e}get baseDiffuseRoughnessTexture(){return this._material.baseDiffuseRoughnessTexture}set baseMetalness(e){this._material.metallic=e}get baseMetalness(){var e;return null!==(e=this._material.metallic)&&void 0!==e?e:1}set baseMetalnessTexture(e){this._material.metallicTexture=e}get baseMetalnessTexture(){return this._material.metallicTexture}set useRoughnessFromMetallicTextureGreen(e){this._material.useRoughnessFromMetallicTextureGreen=e,this._material.useRoughnessFromMetallicTextureAlpha=!e}set useMetallicFromMetallicTextureBlue(e){this._material.useMetallnessFromMetallicTextureBlue=e}enableSpecularEdgeColor(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)}configureSpecularGlossiness(){this._specWorkflow=!0,this._material.metallic=null,this._material.roughness=null,this._material.useMicroSurfaceFromReflectivityMapAlpha=!0}set specularWeight(e){this._material.metallicF0Factor=e}get specularWeight(){var e;return null!==(e=this._material.metallicF0Factor)&&void 0!==e?e:1}set specularWeightTexture(e){e?(this._material.metallicReflectanceTexture=e,this._material.useOnlyMetallicFromMetallicReflectanceTexture=!0):(this._material.metallicReflectanceTexture=null,this._material.useOnlyMetallicFromMetallicReflectanceTexture=!1)}get specularWeightTexture(){return this._material.metallicReflectanceTexture}set specularColor(e){this._specWorkflow?this._material.reflectivityColor=e:this._material.metallicReflectanceColor=e}get specularColor(){return this._specWorkflow?this._material.reflectivityColor:this._material.metallicReflectanceColor}set specularColorTexture(e){this._specWorkflow?(this._material.reflectivityTexture=e,this._material.reflectivityTexture&&(this._material.reflectivityTexture.hasAlpha=!0)):this._material.reflectanceTexture=e}get specularColorTexture(){return this._specWorkflow?this._material.reflectivityTexture:this._material.reflectanceTexture}set specularRoughness(e){this._material.roughness=e}get specularRoughness(){var e;return null!==(e=this._material.roughness)&&void 0!==e?e:1}set specularRoughnessTexture(e){this.baseMetalnessTexture||(this._material.metallicTexture=e)}get specularRoughnessTexture(){return this._material.metallicTexture}set specularIor(e){this._material.indexOfRefraction=e}get specularIor(){return this._material.indexOfRefraction}get glossiness(){var e;return null!==(e=this._material.microSurface)&&void 0!==e?e:1}set glossiness(e){this._material.microSurface=e}set emissionColor(e){this._material.emissiveColor=e}get emissionColor(){return this._material.emissiveColor}set emissionLuminance(e){this._material.emissiveIntensity=e}get emissionLuminance(){return this._material.emissiveIntensity}set emissionColorTexture(e){this._material.emissiveTexture=e}get emissionColorTexture(){return this._material.emissiveTexture}set ambientOcclusionTexture(e){this._material.ambientTexture=e,e&&(this._material.useAmbientInGrayScale=!0)}get ambientOcclusionTexture(){return this._material.ambientTexture}set ambientOcclusionTextureStrength(e){this._material.ambientTextureStrength=e}get ambientOcclusionTextureStrength(){var e;return null!==(e=this._material.ambientTextureStrength)&&void 0!==e?e:1}configureCoat(){this._material.clearCoat.isEnabled=!0,this._material.clearCoat.useRoughnessFromMainTexture=!1,this._material.clearCoat.remapF0OnInterfaceChange=!1}set coatWeight(e){this._material.clearCoat.isEnabled=!0,this._material.clearCoat.intensity=e}get coatWeight(){return this._material.clearCoat.intensity}set coatWeightTexture(e){this._material.clearCoat.isEnabled=!0,this._material.clearCoat.texture=e}get coatWeightTexture(){return this._material.clearCoat.texture}set coatColor(e){this._material.clearCoat.isTintEnabled=e!=t.Color3.White(),this._material.clearCoat.tintColor=e}set coatColorTexture(e){this._material.clearCoat.tintTexture=e}set coatRoughness(e){this._material.clearCoat.isEnabled=!0,this._material.clearCoat.roughness=e}get coatRoughness(){var e;return null!==(e=this._material.clearCoat.roughness)&&void 0!==e?e:0}set coatRoughnessTexture(e){this._material.clearCoat.isEnabled=!0,this._material.clearCoat.useRoughnessFromMainTexture=!1,this._material.clearCoat.textureRoughness=e}get coatRoughnessTexture(){return this._material.clearCoat.textureRoughness}set coatIor(e){this._material.clearCoat.indexOfRefraction=e}set coatDarkening(e){}set coatDarkeningTexture(e){}set coatRoughnessAnisotropy(e){}get coatRoughnessAnisotropy(){return 0}set geometryCoatTangentAngle(e){}set geometryCoatTangentTexture(e){}get geometryCoatTangentTexture(){return null}set transmissionWeight(e){this._material.subSurface.isRefractionEnabled=e>0,this._material.subSurface.refractionIntensity=e}get transmissionWeight(){return this._material.subSurface.isRefractionEnabled?this._material.subSurface.refractionIntensity:0}set transmissionWeightTexture(e){this._material.subSurface.isRefractionEnabled=!0,this._material.subSurface.refractionIntensityTexture=e,this._material.subSurface.useGltfStyleTextures=!0}set transmissionDepth(e){this.transmissionWeight>0?this._material.subSurface.tintColorAtDistance=e:this.subsurfaceWeight>0&&this._material.subSurface.diffusionDistance.multiplyInPlace(new t.Color3(e,e,e))}get transmissionDepth(){return this.transmissionWeight>0?this._material.subSurface.tintColorAtDistance:0}set transmissionColor(e){this.transmissionWeight>0?this._material.subSurface.tintColor=e:this.subsurfaceWeight>0&&this._material.subSurface.diffusionDistance.multiplyInPlace(e)}get transmissionColor(){return this.transmissionWeight>0?this._material.subSurface.tintColor:this.subsurfaceWeight>0?this._material.subSurface.diffusionDistance:new t.Color3(0,0,0)}set transmissionScatter(e){this._material.subSurface.diffusionDistance=e}get transmissionScatter(){return this._material.subSurface.diffusionDistance}set transmissionScatterTexture(e){}set transmissionScatterAnisotropy(e){}set transmissionDispersionAbbeNumber(e){}set transmissionDispersionScale(e){e>0?(this._material.subSurface.isDispersionEnabled=!0,this._material.subSurface.dispersion=20/e):(this._material.subSurface.isDispersionEnabled=!1,this._material.subSurface.dispersion=0)}get refractionBackgroundTexture(){return this._material.subSurface.refractionTexture}set refractionBackgroundTexture(e){this._material.subSurface.refractionTexture=e}configureTransmission(){this._material.subSurface.volumeIndexOfRefraction=1,this._material.subSurface.useAlbedoToTintRefraction=!0,this._material.subSurface.minimumThickness=0,this._material.subSurface.maximumThickness=0}configureVolume(){}set geometryThinWalled(e){}get geometryThinWalled(){return 0===this._material.subSurface.maximumThickness}set volumeThicknessTexture(e){this._material.subSurface.thicknessTexture=e,this._material.subSurface.useGltfStyleTextures=!0}set volumeThickness(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)}configureSubsurface(){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}set subsurfaceWeight(e){this._material.subSurface.isTranslucencyEnabled=e>0,this._material.subSurface.translucencyIntensity=e}get subsurfaceWeight(){return this._material.subSurface.isTranslucencyEnabled?this._material.subSurface.translucencyIntensity:0}set subsurfaceWeightTexture(e){this._material.subSurface.translucencyIntensityTexture=e}set subsurfaceColor(e){const 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));const r=n,s=Math.max(r.x,Math.max(r.y,r.z)),o=s>0?1/s:1;this._material.subSurface.diffusionDistance=new t.Color3(Math.exp(-r.x*o),Math.exp(-r.y*o),Math.exp(-r.z*o))}set subsurfaceColorTexture(e){}set diffuseTransmissionTint(e){this._material.subSurface.tintColor=e}get diffuseTransmissionTint(){return this._material.subSurface.tintColor}set diffuseTransmissionTintTexture(e){this._material.subSurface.translucencyColorTexture=e}get subsurfaceRadius(){return 1}set subsurfaceRadius(e){}get subsurfaceRadiusScale(){var e;return null!==(e=this._material.subSurface.scatteringDiffusionProfile)&&void 0!==e?e:t.Color3.White()}set subsurfaceRadiusScale(e){this._material.subSurface.scatteringDiffusionProfile=e}set subsurfaceScatterAnisotropy(e){}isTranslucent(){return this.transmissionWeight>0||this.subsurfaceWeight>0}configureFuzz(){this._material.sheen.isEnabled=!0,this._material.sheen.useRoughnessFromMainTexture=!1,this._material.sheen.albedoScaling=!0}set fuzzWeight(e){this._material.sheen.isEnabled=!0,this._material.sheen.intensity=e}set fuzzWeightTexture(e){this._material.sheen.texture||(this._material.sheen.texture=e)}set fuzzColor(e){this._material.sheen.isEnabled=!0,this._material.sheen.color=e}set fuzzColorTexture(e){this._material.sheen.texture=e}set fuzzRoughness(e){this._material.sheen.isEnabled=!0,this._material.sheen.roughness=e}set fuzzRoughnessTexture(e){this._material.sheen.isEnabled=!0,this._material.sheen.textureRoughness=e}set specularRoughnessAnisotropy(e){this._material.anisotropy.isEnabled=!0,this._material.anisotropy.intensity=e}get specularRoughnessAnisotropy(){return this._material.anisotropy.intensity}set geometryTangentAngle(e){this._material.anisotropy.isEnabled=!0,this._material.anisotropy.angle=e}set geometryTangentTexture(e){this._material.anisotropy.isEnabled=!0,this._material.anisotropy.texture=e}get geometryTangentTexture(){return this._material.anisotropy.texture}configureGltfStyleAnisotropy(e=!0){}set thinFilmWeight(e){this._material.iridescence.isEnabled=e>0,this._material.iridescence.intensity=e}set thinFilmIor(e){this._material.iridescence.indexOfRefraction=e}set thinFilmThicknessMinimum(e){this._material.iridescence.minimumThickness=e}set thinFilmThicknessMaximum(e){this._material.iridescence.maximumThickness=e}set thinFilmWeightTexture(e){this._material.iridescence.texture=e}set thinFilmThicknessTexture(e){this._material.iridescence.thicknessTexture=e}set unlit(e){this._material.unlit=e}set geometryOpacity(e){this._material.alpha=e}get geometryOpacity(){return this._material.alpha}set geometryNormalTexture(e){this._material.bumpTexture=e,this._material.forceIrradianceInFragment=!0}get geometryNormalTexture(){return this._material.bumpTexture}setNormalMapInversions(e,t){this._material.invertNormalMapX=e,this._material.invertNormalMapY=t}set geometryCoatNormalTexture(e){this._material.clearCoat.isEnabled=!0,this._material.clearCoat.bumpTexture=e}get geometryCoatNormalTexture(){return this._material.clearCoat.bumpTexture}set geometryCoatNormalTextureScale(e){this._material.clearCoat.bumpTexture&&(this._material.clearCoat.bumpTexture.level=e)}}var Ds={__proto__:null,PBRMaterialLoadingAdapter:Gs},Vs={__proto__:null,AddObjectAccessorToKey:pe,AnimationPropertyInfo:ar,ArrayItem:ve,EXT_lights_area:mt,EXT_lights_ies:qe,EXT_lights_image_based:Ee,EXT_mesh_gpu_instancing:Fe,EXT_meshopt_compression:Pe,EXT_texture_avif:We,EXT_texture_webp:Ve,ExtrasAsMetadata:Ls,FlowGraphGLTFDataProvider:Is,GLTFFileLoader:g,GLTFLoader:Ce,GetMappingForKey:me,GetPathToObjectConverter:de,InteractivityGraphToFlowGraphParser:us,KHR_animation_pointer:er,KHR_draco_mesh_compression:Ze,KHR_gaussian_splatting:ot,KHR_interactivity:hs,KHR_lights:ut,KHR_materials_anisotropy:Bt,KHR_materials_clearcoat:Rt,KHR_materials_coat:Ot,KHR_materials_diffuse_roughness:Nn,KHR_materials_diffuse_transmission:bn,KHR_materials_dispersion:Ln,KHR_materials_emissive_strength:Ht,KHR_materials_fuzz:Yt,KHR_materials_ior:rn,KHR_materials_iridescence:It,KHR_materials_pbrSpecularGlossiness:gt,KHR_materials_sheen:Ut,KHR_materials_specular:Jt,KHR_materials_transmission:_n,KHR_materials_unlit:xt,KHR_materials_variants:ln,KHR_materials_volume:vn,KHR_materials_volume_scatter:Mn,KHR_mesh_quantization:Gn,KHR_node_hoverability:Ms,KHR_node_selectability:Ts,KHR_node_visibility:fs,KHR_texture_basisu:$n,KHR_texture_transform:zn,KHR_xmp_json_ld:Xn,LoadBoundingInfoFromPositionAccessor:Ae,MSFT_audio_emitter:Dr,MSFT_lod:Kr,MSFT_minecraftMesh:jr,MSFT_sRGBFactors:Qr,OpenPBRMaterialLoadingAdapter:Ps,PBRMaterialLoadingAdapter:Gs,RegisterEXT_lights_area:pt,RegisterEXT_lights_ies:Xe,RegisterEXT_lights_image_based:Le,RegisterEXT_mesh_gpu_instancing:Ne,RegisterEXT_meshopt_compression:Ge,RegisterEXT_texture_avif:ze,RegisterEXT_texture_webp:$e,RegisterExtrasAsMetadata:Fs,RegisterGLTF2Loader:Me,RegisterKHR_animation_pointer:nr,RegisterKHR_draco_mesh_compression:et,RegisterKHR_gaussian_splatting:it,RegisterKHR_interactivity:_s,RegisterKHR_lights:ht,RegisterKHR_materials_anisotropy:Dt,RegisterKHR_materials_clearcoat:wt,RegisterKHR_materials_coat:St,RegisterKHR_materials_diffuse_roughness:Pn,RegisterKHR_materials_diffuse_transmission:Tn,RegisterKHR_materials_dispersion:Fn,RegisterKHR_materials_emissive_strength:Kt,RegisterKHR_materials_fuzz:Qt,RegisterKHR_materials_ior:on,RegisterKHR_materials_iridescence:kt,RegisterKHR_materials_pbrSpecularGlossiness:yt,RegisterKHR_materials_sheen:jt,RegisterKHR_materials_specular:tn,RegisterKHR_materials_transmission:fn,RegisterKHR_materials_unlit:At,RegisterKHR_materials_variants:cn,RegisterKHR_materials_volume:Cn,RegisterKHR_materials_volume_scatter:En,RegisterKHR_mesh_quantization:Vn,RegisterKHR_node_hoverability:Es,RegisterKHR_node_selectability:vs,RegisterKHR_node_visibility:bs,RegisterKHR_texture_basisu:Wn,RegisterKHR_texture_transform:qn,RegisterKHR_xmp_json_ld:Zn,RegisterMSFT_audio_emitter:Hr,RegisterMSFT_lod:Ur,RegisterMSFT_minecraftMesh:Yr,RegisterMSFT_sRGBFactors:Jr,SetInterpolationForKey:_e,TransformNodeAnimationPropertyInfo:ir,TransmissionHelper:hn,WeightAnimationPropertyInfo:lr,_AddInteractivityObjectModel:ds,addNewInteractivityFlowGraphMapping:ns,ensureTransmissionHelper:dn,getAllSupportedNativeNodeTypes:is,getMappingForDeclaration:ts,getMappingForFullOperationName:es,getQuaternion:sr,getVector3:rr,getWeights:or,gltfTypeToBabylonType:ls,registerGLTFExtension:be,registeredGLTFExtensions:ge,unregisterGLTFExtension:ye};const Hs=Object.assign({},ks),$s=Object.assign(Object.assign({},{__proto__:null}),{Extensions:Hs}),Ks=Object.assign(Object.assign({},Vs),{Loader:$s}),Ws="undefined"!=typeof global?global:"undefined"!=typeof window?window:void 0;if(void 0!==Ws){Ws.BABYLON=Ws.BABYLON||{};const e=Ws.BABYLON;e.GLTF2=e.GLTF2||{},e.GLTF2.Loader=e.GLTF2.Loader||{},e.GLTF2.Loader.Extensions=e.GLTF2.Loader.Extensions||{};const t=["Loader"];for(const n in Hs)e.GLTF2.Loader.Extensions[n]=Hs[n],t.push(n);for(const n in $s)"Extensions"!==n&&(e.GLTF2.Loader[n]=$s[n],t.push(n));for(const n in Ks)t.indexOf(n)>-1||(e.GLTF2[n]=Ks[n])}e.GLTF1=se,e.GLTF2=Ks,e.GLTFFileLoader=g,e.GLTFLoaderDefaultOptions=p,e.GLTFValidation=s,e.RegisterGLTFFileLoader=y});
2
2
  //# sourceMappingURL=babylon.glTFFileLoader.min.js.map