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.
- package/babylon.glTF2FileLoader.js +1 -1
- package/babylon.glTF2FileLoader.js.map +1 -1
- package/babylon.glTF2FileLoader.min.js +1 -1
- package/babylon.glTF2FileLoader.min.js.map +1 -1
- package/babylon.glTFFileLoader.js +1 -1
- package/babylon.glTFFileLoader.js.map +1 -1
- package/babylon.glTFFileLoader.min.js +1 -1
- package/babylon.glTFFileLoader.min.js.map +1 -1
- package/babylonjs.loaders.d.ts +20 -2
- package/babylonjs.loaders.js +1 -1
- package/babylonjs.loaders.js.map +1 -1
- package/babylonjs.loaders.min.js +1 -1
- package/babylonjs.loaders.min.js.map +1 -1
- package/babylonjs.loaders.module.d.ts +40 -4
- package/package.json +3 -3
|
@@ -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 r(e,t,r,s){const a={externalResourceFunction:s};return r&&(a.uri="file:"===t?r:t+r),ArrayBuffer.isView(e)?GLTFValidator.validateBytes(e,a):GLTFValidator.validateString(e,a)}function s(){const e=[];onmessage=t=>{const s=t.data;switch(s.id){case"init":importScripts(s.url);break;case"validate":r(s.data,s.rootUrl,s.fileName,t=>new Promise((r,s)=>{const a=e.length;e.push({resolve:r,reject:s}),postMessage({id:"getExternalResource",index:a,uri:t})})).then(e=>{postMessage({id:"validate.resolve",value:e})},e=>{postMessage({id:"validate.reject",reason:e})});break;case"getExternalResource.resolve":e[s.index].resolve(s.value);break;case"getExternalResource.reject":e[s.index].reject(s.reason)}}}class a{static ValidateAsync(e,n,o,i){return"function"==typeof Worker?new Promise((l,u)=>{const c=`${r}(${s})()`,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",_),a._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:n,fileName:o},[t.buffer])}else d.postMessage({id:"validate",data:e,rootUrl:n,fileName:o})}):(this._LoadScriptPromise||(this._LoadScriptPromise=t.Tools.LoadBabylonScriptAsync(this.Configuration.url)),this._LoadScriptPromise.then(()=>r(e,n,o,i)))}}a.Configuration={url:`${t.Tools._DefaultCdnUrl}/gltf_validator.js`},a._LastResults=null;var n={__proto__:null,GLTFValidation:a};const o="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,"+o)||e.startsWith("data:;base64,"+o)||e.startsWith("data:application/octet-stream;base64,"+o)||e.startsWith("data:model/gltf-binary;base64,"+o);function c(e,t,r){try{return Promise.resolve(new Uint8Array(e,t,r))}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,r,s,a,n,o,i,l,u,c,h,d,m,_,p,f,g,b,y,T,v,x,A,C,R,w,M;e&&(this.alwaysComputeBoundingBox=null!==(t=e.alwaysComputeBoundingBox)&&void 0!==t?t:this.alwaysComputeBoundingBox,this.alwaysComputeSkeletonRootNode=null!==(r=e.alwaysComputeSkeletonRootNode)&&void 0!==r?r:this.alwaysComputeSkeletonRootNode,this.animationStartMode=null!==(s=e.animationStartMode)&&void 0!==s?s:this.animationStartMode,this.capturePerformanceCounters=null!==(a=e.capturePerformanceCounters)&&void 0!==a?a:this.capturePerformanceCounters,this.compileMaterials=null!==(n=e.compileMaterials)&&void 0!==n?n:this.compileMaterials,this.compileShadowGenerators=null!==(o=e.compileShadowGenerators)&&void 0!==o?o: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!==(v=e.useGltfTextureNames)&&void 0!==v?v:this.useGltfTextureNames,this.useMaxMorphTargetInfluencers=null!==(x=e.useMaxMorphTargetInfluencers)&&void 0!==x?x: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!==(w=e.validate)&&void 0!==w?w:this.validate,this.dontUseTransmissionHelper=null!==(M=e.dontUseTransmissionHelper)&&void 0!==M?M: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,r,s,a,n,o,i,l){if(ArrayBuffer.isView(r))return this._loadBinary(e,r,s,a,i,l),null;this._progressCallback=n;const u=r.name||t.Tools.GetFilename(r);if(o){if(this.useRangeRequests){this.validate&&t.Logger.Warn("glTF validation is not supported when range requests are enabled");const s={abort:()=>{},onCompleteObservable:new t.Observable},n={readAsync:(t,s)=>new Promise((a,n)=>{this._loadFile(e,r,e=>{a(new Uint8Array(e))},!0,e=>{n(e)},e=>{e.setRequestHeader("Range",`bytes=${t}-${t+s-1}`)})}),byteLength:0};return this._unpackBinaryAsync(new t.DataReader(n)).then(e=>{s.onCompleteObservable.notifyObservers(s),a(e)},i?e=>i(void 0,e):void 0),s}return this._loadFile(e,r,r=>{this._validate(e,new Uint8Array(r,0,r.byteLength),s,u),this._unpackBinaryAsync(new t.DataReader({readAsync:(e,t)=>c(r,e,t),byteLength:r.byteLength})).then(e=>{a(e)},i?e=>i(void 0,e):void 0)},!0,i)}return this._loadFile(e,r,t=>{try{this._validate(e,t,s,u),a({json:this._parseJson(t)})}catch(e){i&&i()}},!1,i)}_loadBinary(e,r,s,a,n,o){this._validate(e,new Uint8Array(r.buffer,r.byteOffset,r.byteLength),s,o),this._unpackBinaryAsync(new t.DataReader({readAsync:(e,t)=>function(e,t,r){try{if(t<0||t>=e.byteLength)throw new RangeError("Offset is out of range.");if(t+r>e.byteLength)throw new RangeError("Length is out of range.");return Promise.resolve(new Uint8Array(e.buffer,e.byteOffset+t,r))}catch(e){return Promise.reject(e)}}(r,e,t),byteLength:r.byteLength})).then(e=>{a(e)},n?e=>n(void 0,e):void 0)}importMeshAsync(e,t,r,s,a,n){return Promise.resolve().then(()=>(this.onParsedObservable.notifyObservers(r),this.onParsedObservable.clear(),this._log(`Loading ${n||""}`),this._loader=this._getLoader(r),this._loader.importMeshAsync(e,t,null,r,s,a,n)))}loadAsync(e,t,r,s,a){return Promise.resolve().then(()=>(this.onParsedObservable.notifyObservers(t),this.onParsedObservable.clear(),this._log(`Loading ${a||""}`),this._loader=this._getLoader(t),this._loader.loadAsync(e,t,r,s,a)))}loadAssetContainerAsync(e,r,s,a,n){return Promise.resolve().then(()=>{this.onParsedObservable.notifyObservers(r),this.onParsedObservable.clear(),this._log(`Loading ${n||""}`),this._loader=this._getLoader(r);const o=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,o,r,s,a,n).then(e=>(Array.prototype.push.apply(o.geometries,e.geometries),Array.prototype.push.apply(o.meshes,e.meshes),Array.prototype.push.apply(o.particleSystems,e.particleSystems),Array.prototype.push.apply(o.skeletons,e.skeletons),Array.prototype.push.apply(o.animationGroups,e.animationGroups),Array.prototype.push.apply(o.materials,i),Array.prototype.push.apply(o.textures,l),Array.prototype.push.apply(o.lights,e.lights),Array.prototype.push.apply(o.transformNodes,e.transformNodes),Array.prototype.push.apply(o.cameras,u),Array.prototype.push.apply(o.morphTargetManagers,c),o))})}canDirectLoad(e){return u(e)}directLoad(e,r){if(r.startsWith("base64,"+o)||r.startsWith(";base64,"+o)||r.startsWith("application/octet-stream;base64,"+o)||r.startsWith("model/gltf-binary;base64,"+o)){const s=t.DecodeBase64UrlToBinary(r);return this._validate(e,new Uint8Array(s,0,s.byteLength)),this._unpackBinaryAsync(new t.DataReader({readAsync:(e,t)=>c(s,e,t),byteLength:s.byteLength}))}return this._validate(e,r),Promise.resolve({json:this._parseJson(r)})}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,r,s,a,n){const o=e._loadFile(t,r,e=>{this._onProgress(e,o)},!0,s,a,n);return o.onCompleteObservable.add(()=>{o._lengthComputable=!0,o._total=o._loaded}),this._requests.push(o),o}_onProgress(e,t){if(!this._progressCallback)return;t._lengthComputable=e.lengthComputable,t._loaded=e.loaded,t._total=e.total;let r=!0,s=0,a=0;for(const e of this._requests){if(void 0===e._lengthComputable||void 0===e._loaded||void 0===e._total)return;r=r&&e._lengthComputable,s+=e._loaded,a+=e._total}this._progressCallback({lengthComputable:r,loaded:s,total:r?a:0})}_validate(e,r,s="",n=""){this.validate&&(this._startPerformanceCounter("Validate JSON"),a.ValidateAsync(r,s,n,t=>this.preprocessUrlAsync(s+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 r=g._parseVersion(t.version);if(!r)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 s={1:g._CreateGLTF1Loader,2:g._CreateGLTF2Loader}[r.major];if(!s)throw new Error("Unsupported version: "+t.version);return s(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 r=e.readUint32();if(1179937895!==r)throw new t.RuntimeError("Unexpected magic: "+r,t.ErrorCodes.GLTFLoaderUnexpectedMagicError);const s=e.readUint32();this.loggingEnabled&&this._log(`Binary version: ${s}`);const a=e.readUint32();let n;switch(this.useRangeRequests||a===e.buffer.byteLength||t.Logger.Warn(`Length in header does not match actual data length: ${a} != ${e.buffer.byteLength}`),s){case 1:n=this._unpackBinaryV1Async(e,a);break;case 2:n=this._unpackBinaryV2Async(e,a);break;default:throw new Error("Unsupported version: "+s)}return this._endPerformanceCounter("Unpack Binary"),n})}_unpackBinaryV1Async(e,t){const r=e.readUint32(),s=e.readUint32();if(0!==s)throw new Error(`Unexpected content format: ${s}`);const a=t-e.byteOffset,n={json:this._parseJson(e.readString(r)),bin:null};if(0!==a){const t=e.byteOffset;n.bin={readAsync:(r,s)=>e.buffer.readAsync(t+r,s),byteLength:a}}return Promise.resolve(n)}_unpackBinaryV2Async(e,t){const r=1313821514,s=e.readUint32();if(e.readUint32()!==r)throw new Error("First chunk format is not JSON");return e.byteOffset+s===t?e.loadAsync(s).then(()=>({json:this._parseJson(e.readString(s)),bin:null})):e.loadAsync(s+8).then(()=>{const a={json:this._parseJson(e.readString(s)),bin:null},n=()=>{const s=e.readUint32();switch(e.readUint32()){case r:throw new Error("Unexpected JSON chunk");case 5130562:{const t=e.byteOffset;a.bin={readAsync:(r,s)=>e.buffer.readAsync(t+r,s),byteLength:s},e.skipBytes(s);break}default:e.skipBytes(s)}return e.byteOffset!==t?e.loadAsync(8).then(n):Promise.resolve(a)};return n()})}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 r=g._logSpaces.substring(0,2*this._logIndentLevel);t.Logger.Log(`${r}${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 v="undefined"!=typeof global?global:"undefined"!=typeof window?window:void 0;if(void 0!==v){v.BABYLON=v.BABYLON||{};for(const e in T)v.BABYLON[e]=T[e];for(const e in n)v.BABYLON[e]=n[e]}const x=[{regex:new RegExp("^/nodes/\\d+/extensions/")}];class A{constructor(e,t){this._gltf=e,this._infoTree=t}convert(e){let t,r=this._gltf,s=this._infoTree;if(!e.startsWith("/"))throw new Error("Path must start with a /");const a=e.split("/");if(a.shift(),a[a.length-1].includes(".length")){const e=a[a.length-1].split(".");a.pop(),a.push(...e)}let n=!1;for(const o of a){const a="length"===o;if(a&&!s.__array__)throw new Error(`Path ${e} is invalid`);if(s.__ignoreObjectTree__&&(n=!0),s.__array__&&!a)s=s.__array__;else if(s=s[o],!s)throw new Error(`Path ${e} is invalid`);if(!n)if(void 0===r){if(!x.find(t=>t.regex.test(e)))throw new Error(`Path ${e} is invalid`)}else a||(r=null==r?void 0:r[o]);(s.__target__||a)&&(t=r)}return{object:t,info:s}}}function C(e,t,r,s){const a=R(e);return s?a[r][s]:a[r]}function R(e,r,s){var a,n,o;return null===(o=null===(a=e._data)||void 0===a?void 0:a[null!==(n=null==s?void 0:s.fillMode)&&void 0!==n?n:t.Constants.MATERIAL_TriangleFillMode])||void 0===o?void 0:o.babylonMaterial}function w(e,r){return{offset:{componentsCount:2,type:"Vector2",get:(s,a,n)=>{const o=C(s,0,e,r);return new t.Vector2(null==o?void 0:o.uOffset,null==o?void 0:o.vOffset)},getTarget:R,set:(t,s,a,n)=>{const o=C(s,0,e,r);o.uOffset=t.x,o.vOffset=t.y},getPropertyName:[()=>`${e}${r?"."+r:""}.uOffset`,()=>`${e}${r?"."+r:""}.vOffset`]},rotation:{type:"number",get:(t,s,a)=>{var n;return null===(n=C(t,0,e,r))||void 0===n?void 0:n.wAng},getTarget:R,set:(t,s,a,n)=>C(s,0,e,r).wAng=t,getPropertyName:[()=>`${e}${r?"."+r:""}.wAng`]},scale:{componentsCount:2,type:"Vector2",get:(s,a,n)=>{const o=C(s,0,e,r);return new t.Vector2(null==o?void 0:o.uScale,null==o?void 0:o.vScale)},getTarget:R,set:(t,s,a,n)=>{const o=C(s,0,e,r);o.uScale=t.x,o.vScale=t.y},getPropertyName:[()=>`${e}${r?"."+r:""}.uScale`,()=>`${e}${r?"."+r:""}.vScale`]}}}const M={cameras:{__array__:{__target__:!0,orthographic:{xmag:{componentsCount:2,type:"Vector2",get:e=>{var r,s,a,n;return new t.Vector2(null!==(s=null===(r=e._babylonCamera)||void 0===r?void 0:r.orthoLeft)&&void 0!==s?s:0,null!==(n=null===(a=e._babylonCamera)||void 0===a?void 0:a.orthoRight)&&void 0!==n?n: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 r,s,a,n;return new t.Vector2(null!==(s=null===(r=e._babylonCamera)||void 0===r?void 0:r.orthoBottom)&&void 0!==s?s:0,null!==(n=null===(a=e._babylonCamera)||void 0===a?void 0:a.orthoTop)&&void 0!==n?n: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 r;return null===(r=t._babylonTransformNode)||void 0===r?void 0:r.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 r,s;return null===(s=null===(r=t._babylonTransformNode)||void 0===r?void 0:r.rotationQuaternion)||void 0===s?void 0:s.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 r;return null===(r=t._babylonTransformNode)||void 0===r?void 0:r.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 r,s;return void 0!==t?null===(s=null===(r=e._primitiveBabylonMeshes)||void 0===r?void 0:r[0].morphTargetManager)||void 0===s?void 0:s.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 r,s,a;return t.Matrix.Compose(null===(r=e._babylonTransformNode)||void 0===r?void 0:r.scaling,null===(s=e._babylonTransformNode)||void 0===s?void 0:s.rotationQuaternion,null===(a=e._babylonTransformNode)||void 0===a?void 0:a.position)},getTarget:e=>e._babylonTransformNode,isReadOnly:!0},globalMatrix:{type:"Matrix",get:e=>{var r,s,a,n,o,i,l;const u=t.Matrix.Identity();let c=e.parent;for(;c&&c.parent;)c=c.parent;const h=(null===(r=e._babylonTransformNode)||void 0===r?void 0:r.position._isDirty)||(null===(a=null===(s=e._babylonTransformNode)||void 0===s?void 0:s.rotationQuaternion)||void 0===a?void 0:a._isDirty)||(null===(n=e._babylonTransformNode)||void 0===n?void 0:n.scaling._isDirty);if(c){const t=null===(o=c._babylonTransformNode)||void 0===o?void 0:o.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 r,s;return null===(s=null===(r=e._babylonTransformNode)||void 0===r?void 0:r.getChildren(e=>e instanceof t.SpotLight,!0)[0])||void 0===s?void 0:s.intensity},getTarget:e=>{var r;return null===(r=e._babylonTransformNode)||void 0===r?void 0:r.getChildren(e=>e instanceof t.SpotLight,!0)[0]},set:(e,r)=>{if(r._babylonTransformNode){const s=r._babylonTransformNode.getChildren(e=>e instanceof t.SpotLight,!0)[0];s&&(s.intensity=e)}}},color:{type:"Color3",get:e=>{var r,s;return null===(s=null===(r=e._babylonTransformNode)||void 0===r?void 0:r.getChildren(e=>e instanceof t.SpotLight,!0)[0])||void 0===s?void 0:s.diffuse},getTarget:e=>{var r;return null===(r=e._babylonTransformNode)||void 0===r?void 0:r.getChildren(e=>e instanceof t.SpotLight,!0)[0]},set:(e,r)=>{if(r._babylonTransformNode){const s=r._babylonTransformNode.getChildren(e=>e instanceof t.SpotLight,!0)[0];s&&(s.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,r)=>R(e,0,r).emissiveColor,set:(e,t,r,s)=>R(t,0,s).emissiveColor.copyFrom(e),getTarget:(e,t,r)=>R(e,0,r),getPropertyName:[()=>"emissiveColor"]},emissiveTexture:{extensions:{KHR_texture_transform:w("emissiveTexture")}},normalTexture:{scale:{type:"number",get:(e,t,r)=>{var s;return null===(s=C(e,0,"bumpTexture"))||void 0===s?void 0:s.level},set:(e,t,r,s)=>{const a=C(t,0,"bumpTexture");a&&(a.level=e)},getTarget:(e,t,r)=>R(e,0,r),getPropertyName:[()=>"level"]},extensions:{KHR_texture_transform:w("bumpTexture")}},occlusionTexture:{strength:{type:"number",get:(e,t,r)=>R(e,0,r).ambientTextureStrength,set:(e,t,r,s)=>{const a=R(t,0,s);a&&(a.ambientTextureStrength=e)},getTarget:(e,t,r)=>R(e,0,r),getPropertyName:[()=>"ambientTextureStrength"]},extensions:{KHR_texture_transform:w("ambientTexture")}},pbrMetallicRoughness:{baseColorFactor:{type:"Color4",get:(e,r,s)=>{const a=R(e,0,s);return t.Color4.FromColor3(a.albedoColor,a.alpha)},set:(e,t,r,s)=>{const a=R(t,0,s);a.albedoColor.set(e.r,e.g,e.b),a.alpha=e.a},getTarget:(e,t,r)=>R(e,0,r),getPropertyName:[()=>"albedoColor",()=>"alpha"]},baseColorTexture:{extensions:{KHR_texture_transform:w("albedoTexture")}},metallicFactor:{type:"number",get:(e,t,r)=>R(e,0,r).metallic,set:(e,t,r,s)=>{const a=R(t,0,s);a&&(a.metallic=e)},getTarget:(e,t,r)=>R(e,0,r),getPropertyName:[()=>"metallic"]},roughnessFactor:{type:"number",get:(e,t,r)=>R(e,0,r).roughness,set:(e,t,r,s)=>{const a=R(t,0,s);a&&(a.roughness=e)},getTarget:(e,t,r)=>R(e,0,r),getPropertyName:[()=>"roughness"]},metallicRoughnessTexture:{extensions:{KHR_texture_transform:w("metallicTexture")}}},extensions:{KHR_materials_anisotropy:{anisotropyStrength:{type:"number",get:(e,t,r)=>R(e,0,r).anisotropy.intensity,set:(e,t,r,s)=>{R(t,0,s).anisotropy.intensity=e},getTarget:(e,t,r)=>R(e,0,r),getPropertyName:[()=>"anisotropy.intensity"]},anisotropyRotation:{type:"number",get:(e,t,r)=>R(e,0,r).anisotropy.angle,set:(e,t,r,s)=>{R(t,0,s).anisotropy.angle=e},getTarget:(e,t,r)=>R(e,0,r),getPropertyName:[()=>"anisotropy.angle"]},anisotropyTexture:{extensions:{KHR_texture_transform:w("anisotropy","texture")}}},KHR_materials_clearcoat:{clearcoatFactor:{type:"number",get:(e,t,r)=>R(e,0,r).clearCoat.intensity,set:(e,t,r,s)=>{R(t,0,s).clearCoat.intensity=e},getTarget:(e,t,r)=>R(e,0,r),getPropertyName:[()=>"clearCoat.intensity"]},clearcoatRoughnessFactor:{type:"number",get:(e,t,r)=>R(e,0,r).clearCoat.roughness,set:(e,t,r,s)=>{R(t,0,s).clearCoat.roughness=e},getTarget:(e,t,r)=>R(e,0,r),getPropertyName:[()=>"clearCoat.roughness"]},clearcoatTexture:{extensions:{KHR_texture_transform:w("clearCoat","texture")}},clearcoatNormalTexture:{scale:{type:"number",get:(e,t,r)=>{var s;return null===(s=R(e,0,r).clearCoat.bumpTexture)||void 0===s?void 0:s.level},getTarget:R,set:(e,t,r,s)=>R(t,0,s).clearCoat.bumpTexture.level=e},extensions:{KHR_texture_transform:w("clearCoat","bumpTexture")}},clearcoatRoughnessTexture:{extensions:{KHR_texture_transform:w("clearCoat","textureRoughness")}}},KHR_materials_dispersion:{dispersion:{type:"number",get:(e,t,r)=>R(e,0,r).subSurface.dispersion,getTarget:R,set:(e,t,r,s)=>R(t,0,s).subSurface.dispersion=e}},KHR_materials_emissive_strength:{emissiveStrength:{type:"number",get:(e,t,r)=>R(e,0,r).emissiveIntensity,getTarget:R,set:(e,t,r,s)=>R(t,0,s).emissiveIntensity=e}},KHR_materials_ior:{ior:{type:"number",get:(e,t,r)=>R(e,0,r).indexOfRefraction,getTarget:R,set:(e,t,r,s)=>R(t,0,s).indexOfRefraction=e}},KHR_materials_iridescence:{iridescenceFactor:{type:"number",get:(e,t,r)=>R(e,0,r).iridescence.intensity,getTarget:R,set:(e,t,r,s)=>R(t,0,s).iridescence.intensity=e},iridescenceIor:{type:"number",get:(e,t,r)=>R(e,0,r).iridescence.indexOfRefraction,getTarget:R,set:(e,t,r,s)=>R(t,0,s).iridescence.indexOfRefraction=e},iridescenceTexture:{extensions:{KHR_texture_transform:w("iridescence","texture")}},iridescenceThicknessMaximum:{type:"number",get:(e,t,r)=>R(e,0,r).iridescence.maximumThickness,getTarget:R,set:(e,t,r,s)=>R(t,0,s).iridescence.maximumThickness=e},iridescenceThicknessMinimum:{type:"number",get:(e,t,r)=>R(e,0,r).iridescence.minimumThickness,getTarget:R,set:(e,t,r,s)=>R(t,0,s).iridescence.minimumThickness=e},iridescenceThicknessTexture:{extensions:{KHR_texture_transform:w("iridescence","thicknessTexture")}}},KHR_materials_sheen:{sheenColorFactor:{type:"Color3",get:(e,t,r)=>R(e,0,r).sheen.color,getTarget:R,set:(e,t,r,s)=>R(t,0,s).sheen.color.copyFrom(e)},sheenColorTexture:{extensions:{KHR_texture_transform:w("sheen","texture")}},sheenRoughnessFactor:{type:"number",get:(e,t,r)=>R(e,0,r).sheen.intensity,getTarget:R,set:(e,t,r,s)=>R(t,0,s).sheen.intensity=e},sheenRoughnessTexture:{extensions:{KHR_texture_transform:w("sheen","thicknessTexture")}}},KHR_materials_specular:{specularFactor:{type:"number",get:(e,t,r)=>R(e,0,r).metallicF0Factor,getTarget:R,set:(e,t,r,s)=>R(t,0,s).metallicF0Factor=e,getPropertyName:[()=>"metallicF0Factor"]},specularColorFactor:{type:"Color3",get:(e,t,r)=>R(e,0,r).metallicReflectanceColor,getTarget:R,set:(e,t,r,s)=>R(t,0,s).metallicReflectanceColor.copyFrom(e),getPropertyName:[()=>"metallicReflectanceColor"]},specularTexture:{extensions:{KHR_texture_transform:w("metallicReflectanceTexture")}},specularColorTexture:{extensions:{KHR_texture_transform:w("reflectanceTexture")}}},KHR_materials_transmission:{transmissionFactor:{type:"number",get:(e,t,r)=>R(e,0,r).subSurface.refractionIntensity,getTarget:R,set:(e,t,r,s)=>R(t,0,s).subSurface.refractionIntensity=e,getPropertyName:[()=>"subSurface.refractionIntensity"]},transmissionTexture:{extensions:{KHR_texture_transform:w("subSurface","refractionIntensityTexture")}}},KHR_materials_diffuse_transmission:{diffuseTransmissionFactor:{type:"number",get:(e,t,r)=>R(e,0,r).subSurface.translucencyIntensity,getTarget:R,set:(e,t,r,s)=>R(t,0,s).subSurface.translucencyIntensity=e},diffuseTransmissionTexture:{extensions:{KHR_texture_transform:w("subSurface","translucencyIntensityTexture")}},diffuseTransmissionColorFactor:{type:"Color3",get:(e,t,r)=>R(e,0,r).subSurface.translucencyColor,getTarget:R,set:(e,t,r,s)=>{var a;return e&&(null===(a=R(t,0,s).subSurface.translucencyColor)||void 0===a?void 0:a.copyFrom(e))}},diffuseTransmissionColorTexture:{extensions:{KHR_texture_transform:w("subSurface","translucencyColorTexture")}}},KHR_materials_volume:{attenuationColor:{type:"Color3",get:(e,t,r)=>R(e,0,r).subSurface.tintColor,getTarget:R,set:(e,t,r,s)=>R(t,0,s).subSurface.tintColor.copyFrom(e)},attenuationDistance:{type:"number",get:(e,t,r)=>R(e,0,r).subSurface.tintColorAtDistance,getTarget:R,set:(e,t,r,s)=>R(t,0,s).subSurface.tintColorAtDistance=e},thicknessFactor:{type:"number",get:(e,t,r)=>R(e,0,r).subSurface.maximumThickness,getTarget:R,set:(e,t,r,s)=>R(t,0,s).subSurface.maximumThickness=e},thicknessTexture:{extensions:{KHR_texture_transform:w("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 r;return null===(r=t._babylonLight)||void 0===r?void 0:r.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 r;return null===(r=t._babylonLight)||void 0===r?void 0:r.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,r;return(null===(t=e._babylonLight)||void 0===t?void 0:t.width)/(null===(r=e._babylonLight)||void 0===r?void 0:r.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 r;return e._babylonTexture&&t.Quaternion.FromRotationMatrix(null===(r=e._babylonTexture)||void 0===r?void 0:r.getReflectionTextureMatrix())},set:(e,r)=>{var s;r._babylonTexture&&((null===(s=r._babylonTexture.getScene())||void 0===s?void 0:s.useRightHandedSystem)||(e=t.Quaternion.Inverse(e)),t.Matrix.FromQuaternionToRef(e,r._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 O(e){return new A(e,M)}function L(e){const t=e.split("/").map(e=>e.replace(/{}/g,"__array__"));let r=M;for(const e of t)e&&(r=r[e]);if(r&&r.type&&r.get)return r}function F(e,t){const r=e.split("/").map(e=>e.replace(/{}/g,"__array__"));let s=M;for(const e of r)e&&(s=s[e]);s&&s.type&&s.get&&(s.interpolation=t)}function E(e,t){const r=e.split("/").map(e=>e.replace(/{}/g,"__array__"));let s=M;for(const e of r)if(e){if(!s[e]){if("?"===e){s.__ignoreObjectTree__=!0;continue}s[e]={},"__array__"===e&&(s[e].__target__=!0)}s=s[e]}Object.assign(s,t)}function S(e,t,r,s){return new(r||(r=Promise))(function(a,n){function o(e){try{l(s.next(e))}catch(e){n(e)}}function i(e){try{l(s.throw(e))}catch(e){n(e)}}function l(e){var t;e.done?a(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(o,i)}l((s=s.apply(e,t||[])).next())})}Object.create,Object.create,"function"==typeof SuppressedError&&SuppressedError;const k=new Map,I=k;function P(e,r,s){B(e)&&t.Logger.Warn(`Extension with the name '${e}' already exists`),k.set(e,{isGLTFExtension:r,factory:s})}function B(e){return k.delete(e)}const N=new t.Lazy(()=>Promise.resolve(BABYLON)),G=new t.Lazy(()=>Promise.resolve().then(function(){return Rr}));class D{static Get(e,t,r){if(!t||null==r||!t[r])throw new Error(`${e}: Failed to find index (${r})`);return t[r]}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 V(e){if(e.min&&e.max){const r=e.min,s=e.max,a=t.TmpVectors.Vector3[0].copyFromFloats(r[0],r[1],r[2]),n=t.TmpVectors.Vector3[1].copyFromFloats(s[0],s[1],s[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 r=1/t;a.scaleInPlace(r),n.scaleInPlace(r)}return new t.BoundingInfo(a,n)}return null}class ${isMatchingMaterialType(e){if(!e)return!1;const t=Array.from(this._pbrMaterialImpls.values());for(const r of t)if(e instanceof r.materialClass)return!0;return!1}static RegisterExtension(e,t){P(e,!1,t)}static UnregisterExtension(e){return B(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 r=Array.from(this._pbrMaterialImpls.values());for(const s of r)if(e instanceof s.materialClass){t=new s.adapterClass(e);break}if(!t)throw new Error("Appropriate material adapter class not found");const s=t;this._materialAdapterCache.set(e,s),this._materialAdapters.add(s)}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,r,s,a,n){return S(this,arguments,void 0,function*(e,t,r,s,a,n,o=""){return yield Promise.resolve().then(()=>S(this,void 0,void 0,function*(){this._babylonScene=t,this._assetContainer=r,this._loadData(s);let n=null;if(e){const t={};if(this._gltf.nodes)for(const e of this._gltf.nodes)e.name&&(t[e.name]=e.index);n=(e instanceof Array?e:[e]).map(e=>{const r=t[e];if(void 0===r)throw new Error(`Failed to find node '${e}'`);return r})}return yield this._loadAsync(a,o,n,()=>({meshes:this._getMeshes(),particleSystems:[],skeletons:this._getSkeletons(),animationGroups:this._getAnimationGroups(),lights:this._babylonLights,transformNodes:this._getTransformNodes(),geometries:this._getGeometries(),spriteManagers:[]}))}))})}loadAsync(e,t,r,s){return S(this,arguments,void 0,function*(e,t,r,s,a=""){return this._babylonScene=e,this._loadData(t),yield this._loadAsync(r,a,null,()=>{})})}_loadAsync(r,s,a,n){return S(this,void 0,void 0,function*(){return yield Promise.resolve().then(()=>S(this,void 0,void 0,function*(){var o;if(this._rootUrl=r,this._uniqueRootUrl=!r.startsWith("file:")&&s?r:`${r}${Date.now()}/`,this._fileName=s,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===(o=this._gltf.materials)||void 0===o?void 0:o.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 r=[];e&&!this._pbrMaterialImpls.has("openpbr")&&r.push(Promise.all([Promise.resolve(BABYLON),Promise.resolve().then(function(){return Zs})]).then(([{OpenPBRMaterial:e,RegisterOpenpbrMaterial:t},{OpenPBRMaterialLoadingAdapter:r}])=>{t(),this._pbrMaterialImpls.set("openpbr",{materialClass:e,adapterClass:r})})),t&&!this._pbrMaterialImpls.has("pbr")&&r.push(Promise.all([Promise.resolve(BABYLON),Promise.resolve().then(function(){return ta})]).then(([{PBRMaterial:e,RegisterPbrMaterial:t},{PBRMaterialLoadingAdapter:r}])=>{t(),this._pbrMaterialImpls.set("pbr",{materialClass:e,adapterClass:r})})),yield Promise.all(r)}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(a)u.push(this.loadSceneAsync("/nodes",{nodes:a,index:-1}));else if(null!=this._gltf.scene||this._gltf.scenes&&this._gltf.scenes[0]){const e=D.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 r=this._gltf.materials[e],s="/materials/"+e,a=t.Material.TriangleFillMode;u.push(this._loadMaterialAsync(s,r,null,a,()=>{}))}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(),n()});return yield h.then(r=>(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()})}),r))})).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 r=this._gltf.buffers;if(r&&r[0]&&!r[0].uri){const s=r[0];(s.byteLength<e.bin.byteLength-3||s.byteLength>e.bin.byteLength)&&t.Logger.Warn(`Binary buffer length (${s.byteLength}) from JSON does not match chunk length (${e.bin.byteLength})`),this._bin=e.bin}else t.Logger.Warn("Unexpected BIN chunk")}}_setupData(){if(D.Assign(this._gltf.accessors),D.Assign(this._gltf.animations),D.Assign(this._gltf.buffers),D.Assign(this._gltf.bufferViews),D.Assign(this._gltf.cameras),D.Assign(this._gltf.images),D.Assign(this._gltf.materials),D.Assign(this._gltf.meshes),D.Assign(this._gltf.nodes),D.Assign(this._gltf.samplers),D.Assign(this._gltf.scenes),D.Assign(this._gltf.skins),D.Assign(this._gltf.textures),this._gltf.nodes){const e={};for(const t of this._gltf.nodes)if(t.children)for(const r of t.children)e[r]=t.index;const t=this._createRootNode();for(const r of this._gltf.nodes){const s=e[r.index];r.parent=void 0===s?t:this._gltf.nodes[s]}}}_loadExtensionsAsync(){return S(this,void 0,void 0,function*(){var e;const r=[];if(I.forEach((e,s)=>{var a;!1===(null===(a=this.parent.extensionOptions[s])||void 0===a?void 0:a.enabled)?e.isGLTFExtension&&this.isExtensionUsed(s)&&t.Logger.Warn(`Extension ${s} is used but has been explicitly disabled.`):e.isGLTFExtension&&!this.isExtensionUsed(s)||r.push((()=>S(this,void 0,void 0,function*(){const r=yield e.factory(this);return r.name!==s&&t.Logger.Warn(`The name of the glTF loader extension instance does not match the registered name: ${r.name} !== ${s}`),this._parent.onExtensionLoadedObservable.notifyObservers(r),r}))())}),this._extensions.push(...yield Promise.all(r)),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 r=new t.Mesh("__root__",this._babylonScene);this._rootBabylonMesh=r,this._rootBabylonMesh._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,this._rootBabylonMesh.setEnabled(!1);const s={_babylonTransformNode:this._rootBabylonMesh,index:-1};switch(this._parent.coordinateSystemMode){case e.GLTFLoaderCoordinateSystemMode.AUTO:this._babylonScene.useRightHandedSystem||(s.rotation=[0,1,0,0],s.scale=[1,1,-1],$._LoadTransform(s,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(r),s}loadSceneAsync(e,t){const r=this._extensionsLoadSceneAsync(e,t);if(r)return r;const s=new Array;if(this.logOpen(`${e} ${t.name||""}`),t.nodes)for(const r of t.nodes){const t=D.Get(`${e}/nodes/${r}`,this._gltf.nodes,r);s.push(this.loadNodeAsync(`/nodes/${t.index}`,t,e=>{e.parent=this._rootBabylonMesh}))}for(const e of this._postSceneLoadActions)e();return s.push(this._loadAnimationsAsync()),this.logClose(),Promise.all(s).then(()=>{})}_forEachPrimitive(e,t){if(e._primitiveBabylonMeshes)for(const r of e._primitiveBabylonMeshes)t(r)}_getGeometries(){const e=[],t=this._gltf.nodes;if(t)for(const r of t)this._forEachPrimitive(r,t=>{const r=t.geometry;r&&-1===e.indexOf(r)&&e.push(r)});return e}_getMeshes(){const e=[];this._rootBabylonMesh instanceof t.AbstractMesh&&e.push(this._rootBabylonMesh);const r=this._gltf.nodes;if(r)for(const t of r)this._forEachPrimitive(t,t=>{e.push(t)});return e}_getTransformNodes(){const e=[],t=this._gltf.nodes;if(t)for(const r of t)r._babylonTransformNode&&"TransformNode"===r._babylonTransformNode.getClassName()&&e.push(r._babylonTransformNode),r._babylonTransformNodeForSkin&&e.push(r._babylonTransformNodeForSkin);return e}_getSkeletons(){const e=[],t=this._gltf.skins;if(t)for(const r of t)r._data&&e.push(r._data.babylonSkeleton);return e}_getAnimationGroups(){const e=[],t=this._gltf.animations;if(t)for(const r of t)r._babylonAnimationGroup&&e.push(r._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,r,s=()=>{}){const a=this._extensionsLoadNodeAsync(e,r,s);if(a)return a;if(r._babylonTransformNode)throw new Error(`${e}: Invalid recursive node hierarchy`);const n=new Array;this.logOpen(`${e} ${r.name||""}`);const o=t=>{if($.AddPointerMetadata(t,e),$._LoadTransform(r,t),null!=r.camera){const s=D.Get(`${e}/camera`,this._gltf.cameras,r.camera);n.push(this.loadCameraAsync(`/cameras/${s.index}`,s,e=>{e.parent=t,this._babylonScene.useRightHandedSystem||(t.scaling.x=-1)}))}if(r.children)for(const s of r.children){const r=D.Get(`${e}/children/${s}`,this._gltf.nodes,s);n.push(this.loadNodeAsync(`/nodes/${r.index}`,r,e=>{e.parent=t}))}s(t)},i=null!=r.mesh,l=this._parent.loadSkins&&null!=r.skin;if(!i||l){const e=r.name||`node${r.index}`;this._babylonScene._blockEntityCollection=!!this._assetContainer;const s=new t.TransformNode(e,this._babylonScene);s._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,null==r.mesh?r._babylonTransformNode=s:r._babylonTransformNodeForSkin=s,o(s)}if(i)if(l){const s=D.Get(`${e}/mesh`,this._gltf.meshes,r.mesh);n.push(this._loadMeshAsync(`/meshes/${s.index}`,r,s,s=>{const a=r._babylonTransformNodeForSkin;s.metadata=t.deepMerge(a.metadata,s.metadata||{});const o=D.Get(`${e}/skin`,this._gltf.skins,r.skin);n.push(this._loadSkinAsync(`/skins/${o.index}`,r,o,e=>{this._forEachPrimitive(r,t=>{t.skeleton=e}),this._postSceneLoadActions.push(()=>{if(null!=o.skeleton){const e=D.Get(`/skins/${o.index}/skeleton`,this._gltf.nodes,o.skeleton).parent;r.index===e.index?s.parent=a.parent:s.parent=e._babylonTransformNode}else s.parent=this._rootBabylonMesh;this._parent.onSkinLoadedObservable.notifyObservers({node:a,skinnedNode:s})})}))}))}else{const t=D.Get(`${e}/mesh`,this._gltf.meshes,r.mesh);n.push(this._loadMeshAsync(`/meshes/${t.index}`,r,t,o))}return this.logClose(),Promise.all(n).then(()=>(this._forEachPrimitive(r,e=>{const t=e;!t.isAnInstance&&t.geometry&&t.geometry.useBoundingInfoFromGeometry?e._updateBoundingInfo():e.refreshBoundingInfo(!0,!0)}),r._babylonTransformNode))}_loadMeshAsync(e,r,s,a){const n=s.primitives;if(!n||!n.length)throw new Error(`${e}: Primitives are missing`);null==n[0].index&&D.Assign(n);const o=new Array;this.logOpen(`${e} ${s.name||""}`);const i=r.name||`node${r.index}`;if(1===n.length){const t=s.primitives[0];o.push(this._loadMeshPrimitiveAsync(`${e}/primitives/${t.index}`,i,r,s,t,e=>{r._babylonTransformNode=e,r._primitiveBabylonMeshes=[e]}))}else{this._babylonScene._blockEntityCollection=!!this._assetContainer,r._babylonTransformNode=new t.TransformNode(i,this._babylonScene),r._babylonTransformNode._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,r._primitiveBabylonMeshes=[];for(const t of n)o.push(this._loadMeshPrimitiveAsync(`${e}/primitives/${t.index}`,`${i}_primitive${t.index}`,r,s,t,e=>{e.parent=r._babylonTransformNode,r._primitiveBabylonMeshes.push(e)}))}return a(r._babylonTransformNode),this.logClose(),Promise.all(o).then(()=>r._babylonTransformNode)}_loadMeshPrimitiveAsync(e,r,s,a,n,o){const i=this._extensionsLoadMeshPrimitiveAsync(e,r,s,a,n,o);if(i)return i;this.logOpen(`${e}`);const l=0===this._disableInstancedMesh&&this._parent.createInstances&&null==s.skin&&!a.primitives[0].targets;let u,c;if(l&&n._instanceData)this._babylonScene._blockEntityCollection=!!this._assetContainer,u=n._instanceData.babylonSourceMesh.createInstance(r),u._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,c=n._instanceData.promise;else{const o=new Array;this._babylonScene._blockEntityCollection=!!this._assetContainer;const i=new t.Mesh(r,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,s,a,n,i),o.push(this._loadVertexDataAsync(e,n,i).then(t=>S(this,void 0,void 0,function*(){return yield this._loadMorphTargetsAsync(e,n,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=$._GetDrawMode(e,n.mode);if(null==n.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 r=D.Get(`${e}/material`,this._gltf.materials,n.material);o.push(this._loadMaterialAsync(`/materials/${r.index}`,r,i,t,e=>{i.material=e}))}}c=Promise.all(o),l&&(n._instanceData={babylonSourceMesh:i,promise:c}),u=i}return $.AddPointerMetadata(u,e),this._parent.onMeshLoadedObservable.notifyObservers(u),o(u),this.logClose(),c.then(()=>u)}_loadVertexDataAsync(e,r,s){const a=this._extensionsLoadVertexDataAsync(e,r,s);if(a)return a;const n=r.attributes;if(!n)throw new Error(`${e}: Attributes are missing`);const o=new Array,i=new t.Geometry(s.name,this._babylonScene);if(null==r.indices)s.isUnIndexed=!0;else{const t=D.Get(`${e}/indices`,this._gltf.accessors,r.indices);o.push(this._loadIndicesAccessorAsync(`/accessors/${t.index}`,t).then(e=>{i.setIndices(e)}))}const l=(r,a,l)=>{if(null==n[r])return;s._delayInfo=s._delayInfo||[],-1===s._delayInfo.indexOf(a)&&s._delayInfo.push(a);const u=D.Get(`${e}/attributes/${r}`,this._gltf.accessors,n[r]);o.push(this._loadVertexAccessorAsync(`/accessors/${u.index}`,u,a).then(e=>{if(e.getKind()===t.VertexBuffer.PositionKind&&!this.parent.alwaysComputeBoundingBox&&!s.skeleton){const e=V(u);e&&(i._boundingInfo=e,i.useBoundingInfoFromGeometry=!0)}i.setVerticesBuffer(e,u.count)})),a==t.VertexBuffer.MatricesIndicesExtraKind&&(s.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&&(s.hasVertexAlpha=!0)}),Promise.all(o).then(()=>i)}_createMorphTargets(e,r,s,a,n){if(!a.targets||!this._parent.loadMorphTargets)return;if(null==r._numMorphTargets)r._numMorphTargets=a.targets.length;else if(a.targets.length!==r._numMorphTargets)throw new Error(`${e}: Primitives do not have the same number of targets`);const o=s.extras?s.extras.targetNames:null;this._babylonScene._blockEntityCollection=!!this._assetContainer,n.morphTargetManager=new t.MorphTargetManager(this._babylonScene),n.morphTargetManager._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,n.morphTargetManager.areUpdatesFrozen=!0;for(let e=0;e<a.targets.length;e++){const a=r.weights?r.weights[e]:s.weights?s.weights[e]:0,i=o?o[e]:`morphTarget${e}`;n.morphTargetManager.addTarget(new t.MorphTarget(i,a,n.getScene()))}}_loadMorphTargetsAsync(e,r,s,a){if(!r.targets||!this._parent.loadMorphTargets)return Promise.resolve();const n=new Array,o=s.morphTargetManager;for(let t=0;t<o.numTargets;t++){const s=o.getTarget(t);n.push(this._loadMorphTargetVertexDataAsync(`${e}/targets/${t}`,a,r.targets[t],s))}return Promise.all(n).then(()=>{o.areUpdatesFrozen=!1,this._parent.useMaxMorphTargetInfluencers&&(o.isUsingTextureForTargets||o.numTargets<=t.MorphTargetManager.MaxActiveMorphTargetsInVertexAttributeMode)&&(o.optimizeInfluencers=!1,o.numMaxInfluencers=o.numTargets)})}_loadMorphTargetVertexDataAsync(e,r,s,a){return S(this,void 0,void 0,function*(){const n=new Array,o=(t,a,o)=>{if(null==s[t])return;const i=r.getVertexBuffer(a);if(!i)return;const l=D.Get(`${e}/${t}`,this._gltf.accessors,s[t]);n.push(this._loadFloatAccessorAsync(`/accessors/${l.index}`,l).then(e=>{o(i,e)}))};return o("POSITION",t.VertexBuffer.PositionKind,(e,t)=>{const r=new Float32Array(t.length);e.forEach(t.length,(e,s)=>{r[s]=t[s]+e}),a.setPositions(r)}),o("NORMAL",t.VertexBuffer.NormalKind,(e,t)=>{const r=new Float32Array(t.length);e.forEach(r.length,(e,s)=>{r[s]=t[s]+e}),a.setNormals(r)}),o("TANGENT",t.VertexBuffer.TangentKind,(e,t)=>{const r=new Float32Array(t.length/3*4);let s=0;e.forEach(t.length/3*4,(e,a)=>{(a+1)%4!=0&&(r[s]=t[s]+e,s++)}),a.setTangents(r)}),o("TEXCOORD_0",t.VertexBuffer.UVKind,(e,t)=>{const r=new Float32Array(t.length);e.forEach(t.length,(e,s)=>{r[s]=t[s]+e}),a.setUVs(r)}),o("TEXCOORD_1",t.VertexBuffer.UV2Kind,(e,t)=>{const r=new Float32Array(t.length);e.forEach(t.length,(e,s)=>{r[s]=t[s]+e}),a.setUV2s(r)}),o("COLOR_0",t.VertexBuffer.ColorKind,(t,r)=>{let s=null;const n=t.getSize();if(3===n){s=new Float32Array(r.length/3*4),t.forEach(r.length,(e,t)=>{const a=Math.floor(t/3),n=t%3;s[4*a+n]=r[3*a+n]+e});for(let e=0;e<r.length/3;++e)s[4*e+3]=1}else{if(4!==n)throw new Error(`${e}: Invalid number of components (${n}) for COLOR_0 attribute`);s=new Float32Array(r.length),t.forEach(r.length,(e,t)=>{s[t]=r[t]+e})}a.setColors(s)}),yield Promise.all(n).then(()=>{})})}static _LoadTransform(e,r){if(null!=e.skin)return;let s=t.Vector3.Zero(),a=t.Quaternion.Identity(),n=t.Vector3.One();e.matrix?t.Matrix.FromArray(e.matrix).decompose(n,a,s):(e.translation&&(s=t.Vector3.FromArray(e.translation)),e.rotation&&(a=t.Quaternion.FromArray(e.rotation)),e.scale&&(n=t.Vector3.FromArray(e.scale))),r.position=s,r.rotationQuaternion=a,r.scaling=n}_loadSkinAsync(e,r,s,a){if(!this._parent.loadSkins)return Promise.resolve();const n=this._extensionsLoadSkinAsync(e,r,s);if(n)return n;if(s._data)return a(s._data.babylonSkeleton),s._data.promise;const o=`skeleton${s.index}`;this._babylonScene._blockEntityCollection=!!this._assetContainer;const i=new t.Skeleton(s.name||o,o,this._babylonScene);i._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,this._loadBones(e,s,i);const l=this._loadSkinInverseBindMatricesDataAsync(e,s).then(e=>{this._updateBoneMatrices(i,e)});return s._data={babylonSkeleton:i,promise:l},a(i),l}_loadBones(e,r,s){if(null==r.skeleton||this._parent.alwaysComputeSkeletonRootNode){const s=this._findSkeletonRootNode(`${e}/joints`,r.joints);if(s)if(void 0===r.skeleton)r.skeleton=s.index;else{const a=(e,t)=>{for(;t.parent;t=t.parent)if(t.parent===e)return!0;return!1},n=D.Get(`${e}/skeleton`,this._gltf.nodes,r.skeleton);n===s||a(n,s)||(t.Logger.Warn(`${e}/skeleton: Overriding with nearest common ancestor as skeleton node is not a common root`),r.skeleton=s.index)}else t.Logger.Warn(`${e}: Failed to find common root`)}const a={};for(const t of r.joints){const n=D.Get(`${e}/joints/${t}`,this._gltf.nodes,t);this._loadBone(n,r,s,a)}}_findSkeletonRootNode(e,t){if(0===t.length)return null;const r={};for(const s of t){const t=[];let a=D.Get(`${e}/${s}`,this._gltf.nodes,s);for(;-1!==a.index;)t.unshift(a),a=a.parent;r[s]=t}let s=null;for(let e=0;;++e){let a=r[t[0]];if(e>=a.length)return s;const n=a[e];for(let o=1;o<t.length;++o)if(a=r[t[o]],e>=a.length||n!==a[e])return s;s=n}}_loadBone(e,r,s,a){e._isJoint=!0;let n=a[e.index];if(n)return n;let o=null;e.index!==r.skeleton&&(e.parent&&-1!==e.parent.index?o=this._loadBone(e.parent,r,s,a):void 0!==r.skeleton&&t.Logger.Warn(`/skins/${r.index}/skeleton: Skeleton node is not a common root`));const i=r.joints.indexOf(e.index);return n=new t.Bone(e.name||`joint${e.index}`,s,o,this._getNodeMatrix(e),null,null,i),a[e.index]=n,this._postSceneLoadActions.push(()=>{n.linkTransformNode(e._babylonTransformNode)}),n}_loadSkinInverseBindMatricesDataAsync(e,t){if(null==t.inverseBindMatrices)return Promise.resolve(null);const r=D.Get(`${e}/inverseBindMatrices`,this._gltf.accessors,t.inverseBindMatrices);return this._loadFloatAccessorAsync(`/accessors/${r.index}`,r)}_updateBoneMatrices(e,r){for(const s of e.bones){const e=t.Matrix.Identity(),a=s._index;r&&-1!==a&&(t.Matrix.FromArrayToRef(r,16*a,e),e.invertToRef(e));const n=s.getParent();n&&e.multiplyToRef(n.getAbsoluteInverseBindMatrix(),e),s.updateMatrix(e,!1,!1),s._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,r,s=()=>{}){const a=this._extensionsLoadCameraAsync(e,r,s);if(a)return a;const n=new Array;this.logOpen(`${e} ${r.name||""}`),this._babylonScene._blockEntityCollection=!!this._assetContainer;const o=new t.FreeCamera(r.name||`camera${r.index}`,t.Vector3.Zero(),this._babylonScene,!1);switch(o._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,r._babylonCamera=o,o.setTarget(new t.Vector3(0,0,-1)),r.type){case"perspective":{const t=r.perspective;if(!t)throw new Error(`${e}: Camera perspective properties are missing`);o.fov=t.yfov,o.minZ=t.znear,o.maxZ=t.zfar||0;break}case"orthographic":if(!r.orthographic)throw new Error(`${e}: Camera orthographic properties are missing`);o.mode=t.Camera.ORTHOGRAPHIC_CAMERA,o.orthoLeft=-r.orthographic.xmag,o.orthoRight=r.orthographic.xmag,o.orthoBottom=-r.orthographic.ymag,o.orthoTop=r.orthographic.ymag,o.minZ=r.orthographic.znear,o.maxZ=r.orthographic.zfar;break;default:throw new Error(`${e}: Invalid camera type (${r.type})`)}return $.AddPointerMetadata(o,e),this._parent.onCameraLoadedObservable.notifyObservers(o),s(o),this.logClose(),Promise.all(n).then(()=>o)}_loadAnimationsAsync(){this._parent._startPerformanceCounter("Load animations");const e=this._gltf.animations;if(!e)return Promise.resolve();const t=new Array;for(let r=0;r<e.length;r++){const s=e[r];t.push(this.loadAnimationAsync(`/animations/${s.index}`,s).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)||N.value.then(({AnimationGroup:r})=>{this._babylonScene._blockEntityCollection=!!this._assetContainer;const s=new r(t.name||`animation${t.index}`,this._babylonScene);s._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,t._babylonAnimationGroup=s;const a=new Array;D.Assign(t.channels),D.Assign(t.samplers);for(const r of t.channels)a.push(this._loadAnimationChannelAsync(`${e}/channels/${r.index}`,e,t,r,(e,t)=>{e.animations=e.animations||[],e.animations.push(t),s.addTargetedAnimation(t,e)}));return this._parent._endPerformanceCounter("Load animation"),Promise.all(a).then(()=>(s.normalize(0),s))})}_loadAnimationChannelAsync(e,t,r,s,a){const n=this._extensionsLoadAnimationChannelAsync(e,t,r,s,a);if(n)return n;if(null==s.target.node)return Promise.resolve();const o=D.Get(`${e}/target/node`,this._gltf.nodes,s.target.node),i=s.target.path,l="weights"===i;return l&&!o._numMorphTargets||!l&&!o._babylonTransformNode?Promise.resolve():this._parent.loadNodeAnimations||l||o._isJoint?G.value.then(()=>{var n,l,u,c;let h;switch(i){case"translation":h=null===(n=L("/nodes/{}/translation"))||void 0===n?void 0:n.interpolation;break;case"rotation":h=null===(l=L("/nodes/{}/rotation"))||void 0===l?void 0:l.interpolation;break;case"scale":h=null===(u=L("/nodes/{}/scale"))||void 0===u?void 0:u.interpolation;break;case"weights":h=null===(c=L("/nodes/{}/weights"))||void 0===c?void 0:c.interpolation;break;default:throw new Error(`${e}/target/path: Invalid value (${s.target.path})`)}if(!h)throw new Error(`${e}/target/path: Could not find interpolation properties for target path (${s.target.path})`);const d={object:o,info:h};return this._loadAnimationChannelFromTargetInfoAsync(e,t,r,s,d,a)}):Promise.resolve()}_loadAnimationChannelFromTargetInfoAsync(e,t,r,s,a,n){const o=this.parent.targetFps,i=1/o,l=D.Get(`${e}/sampler`,r.samplers,s.sampler);return this._loadAnimationSamplerAsync(`${t}/samplers/${s.sampler}`,l).then(e=>{let t=0;const l=a.object,u=a.info;for(const a of u){const u=a.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=a.getValue(l,h,m,1);m+=u,d[e]={frame:c[e]*o,value:t,interpolation:1}}break;case"CUBICSPLINE":for(let e=0;e<c.length;e++){const t=a.getValue(l,h,m,i);m+=u;const r=a.getValue(l,h,m,1);m+=u;const s=a.getValue(l,h,m,i);m+=u,d[e]={frame:c[e]*o,inTangent:t,value:r,outTangent:s}}break;case"LINEAR":for(let e=0;e<c.length;e++){const t=a.getValue(l,h,m,1);m+=u,d[e]={frame:c[e]*o,value:t}}}if(m>0){const e=`${r.name||`animation${r.index}`}_channel${s.index}_${t}`,i=a.buildAnimations(l,e,o,d);for(const e of i)t++,n(e.babylonAnimatable,e.babylonAnimation)}}})}_loadAnimationSamplerAsync(e,t){if(t._data)return t._data;const r=t.interpolation||"LINEAR";switch(r){case"STEP":case"LINEAR":case"CUBICSPLINE":break;default:throw new Error(`${e}/interpolation: Invalid value (${t.interpolation})`)}const s=D.Get(`${e}/input`,this._gltf.accessors,t.input),a=D.Get(`${e}/output`,this._gltf.accessors,t.output);return t._data=Promise.all([this._loadFloatAccessorAsync(`/accessors/${s.index}`,s),this._loadFloatAccessorAsync(`/accessors/${a.index}`,a)]).then(([e,t])=>({input:e,interpolation:r,output:t})),t._data}loadBufferAsync(e,t,r,s){const a=this._extensionsLoadBufferAsync(e,t,r,s);if(a)return a;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+r,s)}catch(t){throw new Error(`${e}: ${t.message}`,{cause:t})}})}loadBufferViewAsync(e,t){const r=this._extensionsLoadBufferViewAsync(e,t);if(r)return r;if(t._data)return t._data;const s=D.Get(`${e}/buffer`,this._gltf.buffers,t.buffer);return t._data=this.loadBufferAsync(`/buffers/${s.index}`,s,t.byteOffset||0,t.byteLength),t._data}_loadAccessorAsync(e,r,s){if(r._data)return r._data;const a=$._GetNumComponents(e,r.type),n=a*t.VertexBufferGetTypeByteLength(r.componentType),o=a*r.count;if(null==r.bufferView)r._data=Promise.resolve(new s(o));else{const i=D.Get(`${e}/bufferView`,this._gltf.bufferViews,r.bufferView);r._data=this.loadBufferViewAsync(`/bufferViews/${i.index}`,i).then(l=>{if(5126!==r.componentType||r.normalized||i.byteStride&&i.byteStride!==n){const e=new s(o);return t.VertexBufferForEach(l,r.byteOffset||0,i.byteStride||n,a,r.componentType,e.length,r.normalized||!1,(t,r)=>{e[r]=t}),e}return $._GetTypedArray(e,r.componentType,l,r.byteOffset,o)})}if(r.sparse){const o=r.sparse;r._data=r._data.then(i=>{const l=i,u=D.Get(`${e}/sparse/indices/bufferView`,this._gltf.bufferViews,o.indices.bufferView),c=D.Get(`${e}/sparse/values/bufferView`,this._gltf.bufferViews,o.values.bufferView);return Promise.all([this.loadBufferViewAsync(`/bufferViews/${u.index}`,u),this.loadBufferViewAsync(`/bufferViews/${c.index}`,c)]).then(([i,u])=>{const c=$._GetTypedArray(`${e}/sparse/indices`,o.indices.componentType,i,o.indices.byteOffset,o.count),h=a*o.count;let d;if(5126!==r.componentType||r.normalized){const i=$._GetTypedArray(`${e}/sparse/values`,r.componentType,u,o.values.byteOffset,h);d=new s(h),t.VertexBufferForEach(i,0,n,a,r.componentType,d.length,r.normalized||!1,(e,t)=>{d[t]=e})}else d=$._GetTypedArray(`${e}/sparse/values`,r.componentType,u,o.values.byteOffset,h);let m=0;for(let e=0;e<c.length;e++){let t=c[e]*a;for(let e=0;e<a;e++)l[t++]=d[m++]}return l})})}return r._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 r=$._GetTypedArrayConstructor(`${e}/componentType`,t.componentType);t._data=this._loadAccessorAsync(e,t,r)}else{const r=D.Get(`${e}/bufferView`,this._gltf.bufferViews,t.bufferView);t._data=this.loadBufferViewAsync(`/bufferViews/${r.index}`,r).then(r=>$._GetTypedArray(e,t.componentType,r,t.byteOffset,t.count))}return t._data}_loadVertexBufferViewAsync(e){if(e._babylonBuffer)return e._babylonBuffer;const r=this._babylonScene.getEngine();return e._babylonBuffer=this.loadBufferViewAsync(`/bufferViews/${e.index}`,e).then(e=>new t.Buffer(r,e,!1)),e._babylonBuffer}_loadVertexAccessorAsync(e,r,s){var a;if(null===(a=r._babylonVertexBuffer)||void 0===a?void 0:a[s])return r._babylonVertexBuffer[s];r._babylonVertexBuffer||(r._babylonVertexBuffer={});const n=this._babylonScene.getEngine();if(r.sparse||null==r.bufferView)r._babylonVertexBuffer[s]=this._loadFloatAccessorAsync(e,r).then(e=>new t.VertexBuffer(n,e,s,!1));else{const a=D.Get(`${e}/bufferView`,this._gltf.bufferViews,r.bufferView);r._babylonVertexBuffer[s]=this._loadVertexBufferViewAsync(a).then(o=>{const i=$._GetNumComponents(e,r.type);return new t.VertexBuffer(n,o,s,!1,void 0,a.byteStride,void 0,r.byteOffset,i,r.componentType,r.normalized,!0,void 0,!0)})}return r._babylonVertexBuffer[s]}_loadMaterialMetallicRoughnessPropertiesAsync(e,r,s){const a=new Array,n=this._getOrCreateMaterialAdapter(s);return r&&(r.baseColorFactor?(n.baseColor=t.Color3.FromArray(r.baseColorFactor),n.geometryOpacity=r.baseColorFactor[3]):n.baseColor=t.Color3.White(),n.baseMetalness=null==r.metallicFactor?1:r.metallicFactor,n.specularRoughness=null==r.roughnessFactor?1:r.roughnessFactor,r.baseColorTexture&&a.push(this.loadTextureInfoAsync(`${e}/baseColorTexture`,r.baseColorTexture,e=>{e.name=`${s.name} (Base Color)`,n.baseColorTexture=e})),r.metallicRoughnessTexture&&(r.metallicRoughnessTexture.nonColorData=!0,a.push(this.loadTextureInfoAsync(`${e}/metallicRoughnessTexture`,r.metallicRoughnessTexture,e=>{e.name=`${s.name} (Metallic Roughness)`,n.baseMetalnessTexture=e,n.specularRoughnessTexture=e})),n.useRoughnessFromMetallicTextureGreen=!0,n.useMetallicFromMetallicTextureBlue=!0)),Promise.all(a).then(()=>{})}_loadMaterialAsync(e,t,r,s,a=()=>{}){const n=this._extensionsLoadMaterialAsync(e,t,r,s,a);if(n)return n;t._data=t._data||{};let o=t._data[s];if(!o){this.logOpen(`${e} ${t.name||""}`);const r=this.createMaterial(e,t,s);o={babylonMaterial:r,babylonMeshes:[],promise:this.loadMaterialPropertiesAsync(e,t,r)},t._data[s]=o,$.AddPointerMetadata(r,e),this._parent.onMaterialLoadedObservable.notifyObservers(r),this.logClose()}return r&&(o.babylonMeshes.push(r),r.onDisposeObservable.addOnce(()=>{const e=o.babylonMeshes.indexOf(r);-1!==e&&o.babylonMeshes.splice(e,1)})),a(o.babylonMaterial),o.promise.then(()=>o.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 r=this._pbrMaterialImpls.get("pbr");if(r)return r;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,r){this._babylonScene._blockEntityCollection=!!this._assetContainer;const s=new r.materialClass(e,this._babylonScene);s._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,s.fillMode=t,s.transparencyMode=r.materialClass.MATERIAL_OPAQUE;const a=this._getOrCreateMaterialAdapter(s);return a.transparencyAsAlphaCoverage=this._parent.transparencyAsCoverage,a.baseMetalness=1,a.specularRoughness=1,s}createMaterial(e,t,r){const s=this._extensionsCreateMaterial(e,t,r);if(s)return s;const a=t.name||`material${t.index}`;return this._createDefaultMaterial(a,r,this._selectImplForGltfMaterial(t))}loadMaterialPropertiesAsync(e,t,r){const s=this._extensionsLoadMaterialPropertiesAsync(e,t,r);if(s)return s;const a=new Array;return a.push(this.loadMaterialBasePropertiesAsync(e,t,r)),t.pbrMetallicRoughness&&a.push(this._loadMaterialMetallicRoughnessPropertiesAsync(`${e}/pbrMetallicRoughness`,t.pbrMetallicRoughness,r)),this.loadMaterialAlphaProperties(e,t,r),Promise.all(a).then(()=>{})}loadMaterialBasePropertiesAsync(e,r,s){const a=new Array,n=this._getOrCreateMaterialAdapter(s);let o;n.emissionColor=r.emissiveFactor?t.Color3.FromArray(r.emissiveFactor):new t.Color3(0,0,0),r.doubleSided&&(n.backFaceCulling=!1,n.twoSidedLighting=!0),r.normalTexture&&(r.normalTexture.nonColorData=!0,a.push(this.loadTextureInfoAsync(`${e}/normalTexture`,r.normalTexture,e=>{var t;e.name=`${s.name} (Normal)`,n.geometryNormalTexture=e,null!=(null===(t=r.normalTexture)||void 0===t?void 0:t.scale)&&(e.level=r.normalTexture.scale)})),n.setNormalMapInversions(!this._babylonScene.useRightHandedSystem,this._babylonScene.useRightHandedSystem));let i,l=1;return r.occlusionTexture&&(r.occlusionTexture.nonColorData=!0,a.push(this.loadTextureInfoAsync(`${e}/occlusionTexture`,r.occlusionTexture,e=>{e.name=`${s.name} (Occlusion)`,o=e})),null!=r.occlusionTexture.strength&&(l=r.occlusionTexture.strength)),r.emissiveTexture&&a.push(this.loadTextureInfoAsync(`${e}/emissiveTexture`,r.emissiveTexture,e=>{e.name=`${s.name} (Emissive)`,i=e})),Promise.all(a).then(()=>{o&&(n.ambientOcclusionTexture=o,n.ambientOcclusionTextureStrength=l),i&&(n.emissionColorTexture=i)})}loadMaterialAlphaProperties(e,r,s){if(0===this._pbrMaterialImpls.size)throw new Error(`${e}: Material type not supported`);const a=this._getOrCreateMaterialAdapter(s),n=a.baseColorTexture;switch(r.alphaMode||"OPAQUE"){case"OPAQUE":s.transparencyMode=t.Material.MATERIAL_OPAQUE,s.alpha=1;break;case"MASK":s.transparencyMode=t.Material.MATERIAL_ALPHATEST,a.alphaCutOff=null==r.alphaCutoff?.5:r.alphaCutoff,n&&(n.hasAlpha=!0,a.useAlphaFromBaseColorTexture=!0);break;case"BLEND":s.transparencyMode=t.Material.MATERIAL_ALPHABLEND,n&&(n.hasAlpha=!0,a.useAlphaFromBaseColorTexture=!0);break;default:throw new Error(`${e}/alphaMode: Invalid value (${r.alphaMode})`)}}loadTextureInfoAsync(e,t,r=()=>{}){const s=this._extensionsLoadTextureInfoAsync(e,t,r);if(s)return s;if(this.logOpen(`${e}`),t.texCoord>=6)throw new Error(`${e}/texCoord: Invalid value (${t.texCoord})`);const a=D.Get(`${e}/index`,this._gltf.textures,t.index);a._textureInfo=t;const n=this._loadTextureAsync(`/textures/${t.index}`,a,s=>{s.coordinatesIndex=t.texCoord||0,$.AddPointerMetadata(s,e),this._parent.onTextureLoadedObservable.notifyObservers(s),r(s)});return this.logClose(),n}_loadTextureAsync(e,t,r=()=>{}){const s=this._extensionsLoadTextureAsync(e,t,r);if(s)return s;this.logOpen(`${e} ${t.name||""}`);const a=null==t.sampler?$.DefaultSampler:D.Get(`${e}/sampler`,this._gltf.samplers,t.sampler),n=D.Get(`${e}/source`,this._gltf.images,t.source),o=this._createTextureAsync(e,a,n,r,void 0,!t._textureInfo.nonColorData);return this.logClose(),o}_createTextureAsync(e,r,s,a=()=>{},n,o){var i,l;const u=this._loadSampler(`/samplers/${r.index}`,r),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,r)=>{this._disposed||h.reject(new Error(`${e}: ${r&&r.message?r.message:t||"Failed to load texture"}`))},mimeType:null!==(i=s.mimeType)&&void 0!==i?i:t.GetMimeType(null!==(l=s.uri)&&void 0!==l?l:""),loaderOptions:n,useSRGBBuffer:!!o&&this._parent.useSRGBBuffers},m=new t.Texture(null,this._babylonScene,d);m._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,c.push(h.promise);const _=s.uri&&!t.IsBase64DataUrl(s.uri)?s.uri:void 0,p=null!=_?_:`${this._fileName}#image${s.index}`;if(c.push(this.loadImageAsync(`/images/${s.index}`,s).then(e=>{const t=`data:${this._uniqueRootUrl}${p}`;m.updateURL(t,e);const r=m.getInternalTexture();r&&(r.label=s.name)})),m.wrapU=u.wrapU,m.wrapV=u.wrapV,a(m),this._parent.useGltfTextureNames){const e=s.name||_||`image${s.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:$._GetTextureSamplingMode(e,t),wrapU:$._GetTextureWrapMode(`${e}/wrapS`,t.wrapS),wrapV:$._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 r=D.Get(`${e}/bufferView`,this._gltf.bufferViews,t.bufferView);t._data=this.loadBufferViewAsync(`/bufferViews/${r.index}`,r)}this.logClose()}return t._data}loadUriAsync(e,r,s){const a=this._extensionsLoadUriAsync(e,r,s);if(a)return a;if(!$._ValidateUri(s))throw new Error(`${e}: '${s}' is invalid`);if(t.IsBase64DataUrl(s)){const r=new Uint8Array(t.DecodeBase64UrlToBinary(s));return this.log(`${e}: Decoded ${s.substring(0,64)}... (${r.length} bytes)`),Promise.resolve(r)}return this.log(`${e}: Loading ${s}`),this._parent.preprocessUrlAsync(this._rootUrl+s).then(r=>new Promise((a,n)=>{this._parent._loadFile(this._babylonScene,r,t=>{this._disposed||(this.log(`${e}: Loaded ${s} (${t.byteLength} bytes)`),a(new Uint8Array(t)))},!0,r=>{n(new t.LoadFileError(`${e}: Failed to load '${s}'${r?": "+r.status+" "+r.statusText:""}`,r))})}))}static AddPointerMetadata(e,t){e.metadata=e.metadata||{};const r=e._internalMetadata=e._internalMetadata||{},s=r.gltf=r.gltf||{};(s.pointers=s.pointers||[]).push(t)}static _GetTextureWrapMode(e,r){switch(r=null==r?10497:r){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 (${r})`),t.Texture.WRAP_ADDRESSMODE}}static _GetTextureSamplingMode(e,r){const s=null==r.magFilter?9729:r.magFilter,a=null==r.minFilter?9987:r.minFilter;if(9729===s)switch(a){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 (${a})`),t.Texture.LINEAR_LINEAR_MIPLINEAR}else switch(9728!==s&&t.Logger.Warn(`${e}/magFilter: Invalid value (${s})`),a){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 (${a})`),t.Texture.NEAREST_NEAREST_MIPNEAREST}}static _GetTypedArrayConstructor(e,r){try{return t.GetTypedArrayConstructor(r)}catch(t){throw new Error(`${e}: ${t.message}`,{cause:t})}}static _GetTypedArray(e,r,s,a,n){const o=s.buffer;a=s.byteOffset+(a||0);const i=$._GetTypedArrayConstructor(`${e}/componentType`,r),l=t.VertexBufferGetTypeByteLength(r);return a%l!==0?(t.Logger.Warn(`${e}: Copying buffer as byte offset (${a}) is not a multiple of component type byte length (${l})`),new i(o.slice(a,a+n*l),0)):new i(o,a,n)}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,r){switch(null==r&&(r=4),r){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 (${r})`)}_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 r in t._data){const s=t._data[r];for(const t of s.babylonMeshes){t.computeWorldMatrix(!0);const r=s.babylonMaterial;e.push(r.forceCompilationAsync(t)),e.push(r.forceCompilationAsync(t,{useInstances:!0})),this._parent.useClipPlane&&(e.push(r.forceCompilationAsync(t,{clipPlane:!0})),e.push(r.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 r of t){const t=r.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,r){for(const s of this._extensions)if(s.enabled){const a=`${s.name}.${t}`,n=e;n._activeLoaderExtensionFunctions=n._activeLoaderExtensionFunctions||{};const o=n._activeLoaderExtensionFunctions;if(!o[a]){o[a]=!0;try{const e=r(s);if(e)return e}finally{delete o[a]}}}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",r=>r.loadSceneAsync&&r.loadSceneAsync(e,t))}_extensionsLoadNodeAsync(e,t,r){return this._applyExtensions(t,"loadNode",s=>s.loadNodeAsync&&s.loadNodeAsync(e,t,r))}_extensionsLoadCameraAsync(e,t,r){return this._applyExtensions(t,"loadCamera",s=>s.loadCameraAsync&&s.loadCameraAsync(e,t,r))}_extensionsLoadVertexDataAsync(e,t,r){return this._applyExtensions(t,"loadVertexData",s=>s._loadVertexDataAsync&&s._loadVertexDataAsync(e,t,r))}_extensionsLoadMeshPrimitiveAsync(e,t,r,s,a,n){return this._applyExtensions(a,"loadMeshPrimitive",o=>o._loadMeshPrimitiveAsync&&o._loadMeshPrimitiveAsync(e,t,r,s,a,n))}_extensionsLoadMaterialAsync(e,t,r,s,a){return this._applyExtensions(t,"loadMaterial",n=>n._loadMaterialAsync&&n._loadMaterialAsync(e,t,r,s,a))}_extensionsCreateMaterial(e,t,r){return this._applyExtensions(t,"createMaterial",s=>s.createMaterial&&s.createMaterial(e,t,r))}_extensionsLoadMaterialPropertiesAsync(e,t,r){return this._applyExtensions(t,"loadMaterialProperties",s=>s.loadMaterialPropertiesAsync&&s.loadMaterialPropertiesAsync(e,t,r))}_extensionsLoadTextureInfoAsync(e,t,r){return this._applyExtensions(t,"loadTextureInfo",s=>s.loadTextureInfoAsync&&s.loadTextureInfoAsync(e,t,r))}_extensionsLoadTextureAsync(e,t,r){return this._applyExtensions(t,"loadTexture",s=>s._loadTextureAsync&&s._loadTextureAsync(e,t,r))}_extensionsLoadAnimationAsync(e,t){return this._applyExtensions(t,"loadAnimation",r=>r.loadAnimationAsync&&r.loadAnimationAsync(e,t))}_extensionsLoadAnimationChannelAsync(e,t,r,s,a){return this._applyExtensions(r,"loadAnimationChannel",n=>n._loadAnimationChannelAsync&&n._loadAnimationChannelAsync(e,t,r,s,a))}_extensionsLoadSkinAsync(e,t,r){return this._applyExtensions(r,"loadSkin",s=>s._loadSkinAsync&&s._loadSkinAsync(e,t,r))}_extensionsLoadUriAsync(e,t,r){return this._applyExtensions(t,"loadUri",s=>s._loadUriAsync&&s._loadUriAsync(e,t,r))}_extensionsLoadBufferViewAsync(e,t){return this._applyExtensions(t,"loadBufferView",r=>r.loadBufferViewAsync&&r.loadBufferViewAsync(e,t))}_extensionsLoadBufferAsync(e,t,r,s){return this._applyExtensions(t,"loadBuffer",a=>a.loadBufferAsync&&a.loadBufferAsync(e,t,r,s))}static LoadExtensionAsync(e,t,r,s){if(!t.extensions)return null;const a=t.extensions[r];return a?s(`${e}/extensions/${r}`,a):null}static LoadExtraAsync(e,t,r,s){if(!t.extras)return null;const a=t.extras[r];return a?s(`${e}/extras/${r}`,a):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)}}$.DefaultSampler={index:-1};let H=!1;function K(){H||(H=!0,g._CreateGLTF2Loader=e=>new $(e))}const W="EXT_lights_image_based";class U{constructor(e){this.name=W,this._loader=e,this.enabled=this._loader.isExtensionUsed(W)}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 $.LoadExtensionAsync(e,t,this.name,(r,s)=>S(this,void 0,void 0,function*(){this._loader._allMaterialsDirtyRequired=!0;const a=new Array;a.push(this._loader.loadSceneAsync(e,t)),this._loader.logOpen(`${r}`);const n=D.Get(`${r}/light`,this._lights,s.light);return a.push(this._loadLightAsync(`/extensions/${this.name}/lights/${s.light}`,n).then(e=>{this._loader.babylonScene.environmentTexture=e})),this._loader.logClose(),yield Promise.all(a).then(()=>{})}))}_loadLightAsync(e,r){if(!r._loaded){const s=new Array;this._loader.logOpen(`${e}`);const a=new Array(r.specularImages.length);for(let t=0;t<r.specularImages.length;t++){const n=r.specularImages[t];a[t]=new Array(n.length);for(let r=0;r<n.length;r++){const o=`${e}/specularImages/${t}/${r}`;this._loader.logOpen(`${o}`);const i=n[r],l=D.Get(o,this._loader.gltf.images,i);s.push(this._loader.loadImageAsync(`/images/${i}`,l).then(e=>{a[t][r]=e})),this._loader.logClose()}}this._loader.logClose(),r._loaded=Promise.all(s).then(()=>S(this,void 0,void 0,function*(){const s=new t.RawCubeTexture(this._loader.babylonScene,null,r.specularImageSize);if(s.name=r.name||"environment",r._babylonTexture=s,null!=r.intensity&&(s.level=r.intensity),r.rotation){let e=t.Quaternion.FromArray(r.rotation);this._loader.babylonScene.useRightHandedSystem||(e=t.Quaternion.Inverse(e)),t.Matrix.FromQuaternionToRef(e,s.getReflectionTextureMatrix())}if(!r.irradianceCoefficients)throw new Error(`${e}: Irradiance coefficients are missing`);const n=t.SphericalHarmonics.FromArray(r.irradianceCoefficients);n.scaleInPlace(r.intensity),n.convertIrradianceToLambertianRadiance();const o=t.SphericalPolynomial.FromHarmonics(n),i=(a.length-1)/Math.log2(r.specularImageSize);return yield s.updateRGBDAsync(a,o,i)}))}return r._loaded.then(()=>r._babylonTexture)}}let z=!1;function q(){z||(z=!0,B(W),P(W,!0,e=>new U(e)))}q();const j="EXT_mesh_gpu_instancing";class Y{constructor(e){this.name=j,this._loader=e,this.enabled=this._loader.isExtensionUsed(j)}dispose(){this._loader=null}loadNodeAsync(e,r,s){return $.LoadExtensionAsync(e,r,this.name,(e,a)=>S(this,void 0,void 0,function*(){this._loader._disableInstancedMesh++;const n=this._loader.loadNodeAsync(`/nodes/${r.index}`,r,s);if(this._loader._disableInstancedMesh--,!r._primitiveBabylonMeshes)return yield n;const o=new Array;let i=0;const l=t=>{if(null==a.attributes[t])return void o.push(Promise.resolve(null));const r=D.Get(`${e}/attributes/${t}`,this._loader.gltf.accessors,a.attributes[t]);if(o.push(this._loader._loadFloatAccessorAsync(`/accessors/${r.bufferView}`,r)),0===i)i=r.count;else if(i!==r.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 n.then(e=>S(this,void 0,void 0,function*(){const[s,a,n,l]=yield Promise.all(o),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)s&&t.Vector3.FromArrayToRef(s,3*e,t.TmpVectors.Vector3[0]),a&&t.Quaternion.FromArrayToRef(a,4*e,t.TmpVectors.Quaternion[0]),n&&t.Vector3.FromArrayToRef(n,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 r._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 X=!1;function Q(){X||(X=!0,B(j),P(j,!0,e=>new Y(e)))}Q();const J="EXT_meshopt_compression";class Z{constructor(e){this.name=J,this.enabled=e.isExtensionUsed(J),this._loader=e}dispose(){this._loader=null}loadBufferViewAsync(e,r){return $.LoadExtensionAsync(e,r,this.name,(s,a)=>S(this,void 0,void 0,function*(){const s=r;if(s._meshOptData)return yield s._meshOptData;const n=D.Get(`${e}/buffer`,this._loader.gltf.buffers,a.buffer);return s._meshOptData=this._loader.loadBufferAsync(`/buffers/${n.index}`,n,a.byteOffset||0,a.byteLength).then(e=>S(this,void 0,void 0,function*(){return yield t.MeshoptCompression.Default.decodeGltfBufferAsync(e,a.count,a.byteStride,a.mode,a.filter)})),yield s._meshOptData}))}}let ee=!1;function te(){ee||(ee=!0,B(J),P(J,!0,e=>new Z(e)))}te();const re="EXT_texture_webp";class se{constructor(e){this.name=re,this._loader=e,this.enabled=e.isExtensionUsed(re)}dispose(){this._loader=null}_loadTextureAsync(e,t,r){return $.LoadExtensionAsync(e,t,this.name,(s,a)=>S(this,void 0,void 0,function*(){const n=null==t.sampler?$.DefaultSampler:D.Get(`${e}/sampler`,this._loader.gltf.samplers,t.sampler),o=D.Get(`${s}/source`,this._loader.gltf.images,a.source);return yield this._loader._createTextureAsync(e,n,o,e=>{r(e)},void 0,!t._textureInfo.nonColorData)}))}}let ae=!1;function ne(){ae||(ae=!0,B(re),P(re,!0,e=>new se(e)))}ne();const oe="EXT_texture_avif";class ie{constructor(e){this.name=oe,this._loader=e,this.enabled=e.isExtensionUsed(oe)}dispose(){this._loader=null}_loadTextureAsync(e,t,r){return $.LoadExtensionAsync(e,t,this.name,(s,a)=>S(this,void 0,void 0,function*(){const n=null==t.sampler?$.DefaultSampler:D.Get(`${e}/sampler`,this._loader.gltf.samplers,t.sampler),o=D.Get(`${s}/source`,this._loader.gltf.images,a.source);return yield this._loader._createTextureAsync(e,n,o,e=>{r(e)},void 0,!t._textureInfo.nonColorData)}))}}let le=!1;function ue(){le||(le=!0,B(oe),P(oe,!0,e=>new ie(e)))}ue();const ce="EXT_lights_ies";class he{constructor(e){this.name=ce,this._loader=e,this.enabled=this._loader.isExtensionUsed(ce)}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,D.Assign(this._lights)}}loadNodeAsync(e,r,s){return $.LoadExtensionAsync(e,r,this.name,(a,n)=>S(this,void 0,void 0,function*(){let o,i;this._loader._allMaterialsDirtyRequired=!0;const l=yield this._loader.loadNodeAsync(e,r,e=>{i=D.Get(a,this._lights,n.light);const r=i.name||e.name;this._loader.babylonScene._blockEntityCollection=!!this._loader._assetContainer,o=new t.SpotLight(r,t.Vector3.Zero(),t.Vector3.Backward(),0,1,this._loader.babylonScene),o.angle=Math.PI/2,o.innerAngle=0,o._parentContainer=this._loader._assetContainer,this._loader.babylonScene._blockEntityCollection=!1,i._babylonLight=o,o.falloffType=t.Light.FALLOFF_GLTF,o.diffuse=n.color?t.Color3.FromArray(n.color):t.Color3.White(),o.intensity=n.multiplier||1,o.range=Number.MAX_VALUE,o.parent=e,this._loader._babylonLights.push(o),$.AddPointerMetadata(o,a),s(e)});let u;if(i.uri)u=yield this._loader.loadUriAsync(e,i,i.uri);else{const t=D.Get(`${e}/bufferView`,this._loader.gltf.bufferViews,i.bufferView);u=yield this._loader.loadBufferViewAsync(`/bufferViews/${t.index}`,t)}return o.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 de=!1;function me(){de||(de=!0,B(ce),P(ce,!0,e=>new he(e)))}me();const _e="KHR_draco_mesh_compression";class pe{constructor(e){this.name=_e,this.useNormalizedFlagFromAccessor=!0,this._loader=e,this.enabled=t.DracoDecoder.DefaultAvailable&&this._loader.isExtensionUsed(_e)}dispose(){delete this.dracoDecoder,this._loader=null}_loadVertexDataAsync(e,r,s){return $.LoadExtensionAsync(e,r,this.name,(a,n)=>S(this,void 0,void 0,function*(){if(null!=r.mode&&4!==r.mode&&5!==r.mode)throw new Error(`${e}: Unsupported mode ${r.mode}`);const o={},i={},l=(e,t)=>{const a=n.attributes[e];if(null!=a&&(s._delayInfo=s._delayInfo||[],-1===s._delayInfo.indexOf(t)&&s._delayInfo.push(t),o[t]=a,this.useNormalizedFlagFromAccessor)){const s=D.TryGet(this._loader.gltf.accessors,r.attributes[e]);s&&(i[t]=s.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=D.Get(a,this._loader.gltf.bufferViews,n.bufferView);return u._dracoBabylonGeometry||(u._dracoBabylonGeometry=this._loader.loadBufferViewAsync(`/bufferViews/${u.index}`,u).then(a=>S(this,void 0,void 0,function*(){const n=this.dracoDecoder||t.DracoDecoder.Default,l=D.TryGet(this._loader.gltf.accessors,r.attributes.POSITION),u=this._loader.parent.alwaysComputeBoundingBox||s.skeleton||!l?null:V(l);return yield n._decodeMeshToGeometryForGltfAsync(s.name,this._loader.babylonScene,a,o,i,u).catch(t=>{throw new Error(`${e}: ${t.message}`)})}))),yield u._dracoBabylonGeometry}))}}let fe=!1;function ge(){fe||(fe=!0,B(_e),P(_e,!0,e=>new pe(e)))}ge();const be="KHR_gaussian_splatting",ye=.28209479177387814,Te=[0,3,5,7];function ve(e){return e<=0?0:e>=255?255:e+.5|0}class xe{constructor(e){this.name=be,this._loader=e,this.enabled=this._loader.isExtensionUsed(be)}dispose(){this._loader=null}_loadMeshPrimitiveAsync(e,r,s,a,n,o){return $.LoadExtensionAsync(e,n,this.name,s=>S(this,void 0,void 0,function*(){if(null!=n.mode&&0!==n.mode)throw new Error(`${s}: Gaussian splatting primitives must use POINTS mode`);const a=this._loader,i=t=>{const r=n.attributes[t];if(null==r)return null;const s=D.Get(`${e}/attributes/${t}`,a.gltf.accessors,r);return a._loadFloatAccessorAsync(`/accessors/${s.index}`,s)},l=i("POSITION");if(!l)throw new Error(`${s}: Gaussian splatting primitive is missing the POSITION attribute`);let u=0;const c=[];for(let e=1;e<=3&&null!=n.attributes[`KHR_gaussian_splatting:SH_DEGREE_${e}_COEF_0`];e++){u=e;for(let t=0;t<Te[e];t++)c.push(`KHR_gaussian_splatting:SH_DEGREE_${e}_COEF_${t}`)}const h=a.babylonScene;h._blockEntityCollection=!!a._assetContainer;const d=new t.GaussianSplattingMesh(r,null,h);d._parentContainer=a._assetContainer,h._blockEntityCollection=!1,$.AddPointerMetadata(d,e),a.parent.onMeshLoadedObservable.notifyObservers(d),o(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))]),v=_.length/3,x=y?y.length/v:0,A=new ArrayBuffer(32*v),C=new Float32Array(A),R=new Uint8Array(A);let w=null;if(u>0){const e=3*((u+1)*(u+1)-1),r=Math.ceil(e/16),s=m.maxTextureSize,a=Math.ceil(v/s);w=t.AllocateShBuffers(r,a*s*4*4)}for(let e=0;e<v;e++){const t=8*e,r=32*e,s=3*e;if(C[t+0]=_[s+0],C[t+1]=_[s+1],C[t+2]=_[s+2],C[t+3]=f?f[s+0]:1,C[t+4]=f?f[s+1]:1,C[t+5]=f?f[s+2]:1,b)R[r+24]=ve(255*(.5+ye*b[s+0])),R[r+25]=ve(255*(.5+ye*b[s+1])),R[r+26]=ve(255*(.5+ye*b[s+2]));else if(y){const t=e*x;R[r+24]=ve(255*y[t+0]),R[r+25]=ve(255*y[t+1]),R[r+26]=ve(255*y[t+2])}else R[r+24]=255,R[r+25]=255,R[r+26]=255;R[r+27]=g?ve(255*g[e]):y&&x>=4?ve(255*y[e*x+3]):255;const a=4*e,n=p?p[a+0]:0,o=p?p[a+1]:0,i=p?p[a+2]:0,l=p?p[a+3]:1;if(R[r+28]=ve(127.5*l+127.5),R[r+29]=ve(127.5*n+127.5),R[r+30]=ve(127.5*o+127.5),R[r+31]=ve(127.5*i+127.5),w){const t=16*e;for(let e=0;e<T.length;e++){const r=T[e];if(r)for(let a=0;a<3;a++){const n=3*e+a,o=15&n;w[n>>4][t+o]=ve(128*r[s+a]+128)}}}}return yield d.updateDataAsync(A,null!=w?w:void 0,void 0,u||void 0),d}))}}let Ae=!1;function Ce(){Ae||(Ae=!0,B(be),P(be,!0,e=>new xe(e)))}Ce();const Re="KHR_lights_punctual";class we{constructor(e){this.name=Re,this._loader=e,this.enabled=this._loader.isExtensionUsed(Re)}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,D.Assign(this._lights)}}loadNodeAsync(e,r,s){return $.LoadExtensionAsync(e,r,this.name,(a,n)=>S(this,void 0,void 0,function*(){return this._loader._allMaterialsDirtyRequired=!0,yield this._loader.loadNodeAsync(e,r,e=>{let r;const o=D.Get(a,this._lights,n.light),i=o.name||e.name;switch(this._loader.babylonScene._blockEntityCollection=!!this._loader._assetContainer,o.type){case"directional":{const e=new t.DirectionalLight(i,t.Vector3.Backward(),this._loader.babylonScene);e.position.setAll(0),r=e;break}case"point":r=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*(o.spot&&o.spot.outerConeAngle||Math.PI/4),e.innerAngle=2*(o.spot&&o.spot.innerConeAngle||0),r=e;break}default:throw this._loader.babylonScene._blockEntityCollection=!1,new Error(`${a}: Invalid light type (${o.type})`)}r._parentContainer=this._loader._assetContainer,this._loader.babylonScene._blockEntityCollection=!1,o._babylonLight=r,r.falloffType=t.Light.FALLOFF_GLTF,r.diffuse=o.color?t.Color3.FromArray(o.color):t.Color3.White(),r.intensity=null==o.intensity?1:o.intensity,r.range=null==o.range?Number.MAX_VALUE:o.range,r.parent=e,this._loader._babylonLights.push(r),$.AddPointerMetadata(r,a),s(e)})}))}}let Me=!1;function Oe(){Me||(Me=!0,B(Re),P(Re,!0,e=>new we(e)))}Oe();const Le="EXT_lights_area";class Fe{constructor(e){this.name=Le,this._loader=e,this.enabled=this._loader.isExtensionUsed(Le)}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,D.Assign(this._lights)}}loadNodeAsync(e,r,s){return $.LoadExtensionAsync(e,r,this.name,(a,n)=>S(this,void 0,void 0,function*(){return this._loader._allMaterialsDirtyRequired=!0,yield this._loader.loadNodeAsync(e,r,e=>{var r;let o;const i=D.Get(a,this._lights,n.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===(r=i.rect)||void 0===r?void 0:r.aspect)?i.rect.aspect*u:u,s=u;o=new t.RectAreaLight(l,t.Vector3.Zero(),e,s,this._loader.babylonScene);break}case"disk":{const e=Math.sqrt(u*u*.25*Math.PI);o=new t.RectAreaLight(l,t.Vector3.Zero(),e,e,this._loader.babylonScene);break}default:throw this._loader.babylonScene._blockEntityCollection=!1,new Error(`${a}: Invalid area light type (${i.type})`)}o._parentContainer=this._loader._assetContainer,this._loader.babylonScene._blockEntityCollection=!1,i._babylonLight=o,o.falloffType=t.Light.FALLOFF_GLTF,o.diffuse=i.color?t.Color3.FromArray(i.color):t.Color3.White(),o.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,o.parent=c,this._loader._babylonLights.push(o),$.AddPointerMetadata(o,a),s(e)})}))}}let Ee=!1;function Se(){Ee||(Ee=!0,B(Le),P(Le,!0,e=>new Fe(e)))}Se();const ke="KHR_materials_pbrSpecularGlossiness";class Ie{constructor(e){this.name=ke,this.order=200,this._loader=e,this.enabled=this._loader.isExtensionUsed(ke)}dispose(){this._loader=null}loadMaterialPropertiesAsync(e,t,r){return $.LoadExtensionAsync(e,t,this.name,(s,a)=>S(this,void 0,void 0,function*(){const n=new Array;return n.push(this._loader.loadMaterialBasePropertiesAsync(e,t,r)),n.push(this._loadSpecularGlossinessPropertiesAsync(s,a,r)),this._loader.loadMaterialAlphaProperties(e,t,r),yield Promise.all(n).then(()=>{})}))}_loadSpecularGlossinessPropertiesAsync(e,r,s){const a=this._loader._getOrCreateMaterialAdapter(s),n=new Array;return a.configureSpecularGlossiness(),r.diffuseFactor?(a.baseColor=t.Color3.FromArray(r.diffuseFactor),s.alpha=r.diffuseFactor[3]):a.baseColor=t.Color3.White(),a.specularColor=r.specularFactor?t.Color3.FromArray(r.specularFactor):t.Color3.White(),a.glossiness=null==r.glossinessFactor?1:r.glossinessFactor,r.diffuseTexture&&n.push(this._loader.loadTextureInfoAsync(`${e}/diffuseTexture`,r.diffuseTexture,e=>{e.name=`${s.name} (Diffuse)`,a.baseColorTexture=e})),r.specularGlossinessTexture&&n.push(this._loader.loadTextureInfoAsync(`${e}/specularGlossinessTexture`,r.specularGlossinessTexture,e=>{e.name=`${s.name} (Specular Glossiness)`,a.specularColorTexture=e})),Promise.all(n).then(()=>{})}}let Pe=!1;function Be(){Pe||(Pe=!0,B(ke),P(ke,!0,e=>new Ie(e)))}Be();const Ne="KHR_materials_unlit";class Ge{constructor(e){this.name=Ne,this.order=210,this._loader=e,this.enabled=this._loader.isExtensionUsed(Ne)}dispose(){this._loader=null}loadMaterialPropertiesAsync(e,t,r){return $.LoadExtensionAsync(e,t,this.name,()=>S(this,void 0,void 0,function*(){return yield this._loadUnlitPropertiesAsync(e,t,r)}))}_loadUnlitPropertiesAsync(e,r,s){const a=this._loader._getOrCreateMaterialAdapter(s),n=new Array,o=r.pbrMetallicRoughness;return o&&(o.baseColorFactor&&(a.baseColor=t.Color3.FromArray(o.baseColorFactor),a.geometryOpacity=o.baseColorFactor[3]),o.baseColorTexture&&n.push(this._loader.loadTextureInfoAsync(`${e}/baseColorTexture`,o.baseColorTexture,e=>{e.name=`${s.name} (Base Color)`,a.baseColorTexture=e}))),a.isUnlit=!0,r.doubleSided&&(a.backFaceCulling=!1,a.twoSidedLighting=!0),this._loader.loadMaterialAlphaProperties(e,r,s),Promise.all(n).then(()=>{})}}let De=!1;function Ve(){De||(De=!0,B(Ne),P(Ne,!0,e=>new Ge(e)))}Ve();const $e="KHR_materials_clearcoat";class He{constructor(e){this.name=$e,this.order=190,this._loader=e,this.enabled=this._loader.isExtensionUsed($e)}dispose(){this._loader=null}loadMaterialPropertiesAsync(e,t,r){return $.LoadExtensionAsync(e,t,this.name,(s,a)=>S(this,void 0,void 0,function*(){const n=new Array;n.push(this._loader.loadMaterialPropertiesAsync(e,t,r)),n.push(this._loadClearCoatPropertiesAsync(s,a,r)),yield Promise.all(n)}))}_loadClearCoatPropertiesAsync(e,t,r){const s=this._loader._getOrCreateMaterialAdapter(r),a=new Array;return s.configureCoat(),s.coatWeight=void 0!==t.clearcoatFactor?t.clearcoatFactor:0,s.coatRoughness=void 0!==t.clearcoatRoughnessFactor?t.clearcoatRoughnessFactor:0,t.clearcoatTexture&&a.push(this._loader.loadTextureInfoAsync(`${e}/clearcoatTexture`,t.clearcoatTexture,e=>{e.name=`${r.name} (ClearCoat)`,s.coatWeightTexture=e})),t.clearcoatRoughnessTexture&&(t.clearcoatRoughnessTexture.nonColorData=!0,a.push(this._loader.loadTextureInfoAsync(`${e}/clearcoatRoughnessTexture`,t.clearcoatRoughnessTexture,e=>{e.name=`${r.name} (ClearCoat Roughness)`,s.coatRoughnessTexture=e}))),t.clearcoatNormalTexture&&(t.clearcoatNormalTexture.nonColorData=!0,a.push(this._loader.loadTextureInfoAsync(`${e}/clearcoatNormalTexture`,t.clearcoatNormalTexture,e=>{var a;e.name=`${r.name} (ClearCoat Normal)`,s.geometryCoatNormalTexture=e,null!=(null===(a=t.clearcoatNormalTexture)||void 0===a?void 0:a.scale)&&(s.geometryCoatNormalTextureScale=t.clearcoatNormalTexture.scale)})),s.setNormalMapInversions(!r.getScene().useRightHandedSystem,r.getScene().useRightHandedSystem)),Promise.all(a).then(()=>{})}}let Ke=!1;function We(){Ke||(Ke=!0,B($e),P($e,!0,e=>new He(e)))}We();const Ue="KHR_materials_coat";class ze{constructor(e){this.name=Ue,this.order=191,this.useOpenPBR=!1,this._loader=e,this.enabled=this._loader.isExtensionUsed(Ue)}dispose(){this._loader=null}loadMaterialPropertiesAsync(e,t,r){return $.LoadExtensionAsync(e,t,this.name,(s,a)=>S(this,void 0,void 0,function*(){const n=new Array;n.push(this._loader.loadMaterialPropertiesAsync(e,t,r)),t.extensions&&t.extensions.KHR_materials_openpbr&&(this.useOpenPBR=!0),n.push(this._loadCoatPropertiesAsync(s,a,r)),yield Promise.all(n)}))}_loadCoatPropertiesAsync(e,r,s){var a,n;const o=this._loader._getOrCreateMaterialAdapter(s),i=new Array;o.configureCoat(),o.coatWeight=void 0!==r.coatFactor?r.coatFactor:0,o.coatRoughness=void 0!==r.coatRoughnessFactor?r.coatRoughnessFactor:0,r.coatTexture&&i.push(this._loader.loadTextureInfoAsync(`${e}/coatTexture`,r.coatTexture,e=>{e.name=`${s.name} (Coat)`,o.coatWeightTexture=e})),r.coatRoughnessTexture&&(r.coatRoughnessTexture.nonColorData=!0,i.push(this._loader.loadTextureInfoAsync(`${e}/coatRoughnessTexture`,r.coatRoughnessTexture,e=>{e.name=`${s.name} (Coat Roughness)`,o.coatRoughnessTexture=e}))),r.coatNormalTexture&&(r.coatNormalTexture.nonColorData=!0,i.push(this._loader.loadTextureInfoAsync(`${e}/coatNormalTexture`,r.coatNormalTexture,e=>{var t;e.name=`${s.name} (Coat Normal)`,o.geometryCoatNormalTexture=e,null!=(null===(t=r.coatNormalTexture)||void 0===t?void 0:t.scale)&&(o.geometryCoatNormalTextureScale=r.coatNormalTexture.scale)})),o.setNormalMapInversions(!s.getScene().useRightHandedSystem,s.getScene().useRightHandedSystem)),o.coatDarkening=void 0!==r.coatDarkeningFactor?r.coatDarkeningFactor:1,o.coatIor=void 0!==r.coatIor?r.coatIor:1.5;const l=t.Color3.White();void 0!==r.coatColorFactor&&l.fromArray(r.coatColorFactor),o.coatColor=l,r.coatColorTexture&&i.push(this._loader.loadTextureInfoAsync(`${e}/coatColorTexture`,r.coatColorTexture,e=>{e.name=`${s.name} (Coat Color)`,o.coatColorTexture=e}));const u=null!==(a=r.coatAnisotropyStrength)&&void 0!==a?a:0,c=null!==(n=r.coatAnisotropyRotation)&&void 0!==n?n:0;return o.coatRoughnessAnisotropy=u,o.geometryCoatTangentAngle=c,this.useOpenPBR||o.configureGltfStyleAnisotropy(!0),r.coatAnisotropyTexture&&(r.coatAnisotropyTexture.nonColorData=!0,i.push(this._loader.loadTextureInfoAsync(`${e}/coatAnisotropyTexture`,r.coatAnisotropyTexture,e=>{e.name=`${s.name} (Coat Anisotropy)`,o.geometryCoatTangentTexture=e}))),Promise.all(i).then(()=>{})}}let qe=!1;function je(){qe||(qe=!0,B(Ue),P(Ue,!0,e=>new ze(e)))}je();const Ye="KHR_materials_iridescence";class Xe{constructor(e){this.name=Ye,this.order=195,this._loader=e,this.enabled=this._loader.isExtensionUsed(Ye)}dispose(){this._loader=null}loadMaterialPropertiesAsync(e,t,r){return $.LoadExtensionAsync(e,t,this.name,(s,a)=>S(this,void 0,void 0,function*(){const n=new Array;return n.push(this._loader.loadMaterialPropertiesAsync(e,t,r)),n.push(this._loadIridescencePropertiesAsync(s,a,r)),yield Promise.all(n).then(()=>{})}))}_loadIridescencePropertiesAsync(e,t,r){var s,a,n,o,i;const l=this._loader._getOrCreateMaterialAdapter(r),u=new Array;return l.thinFilmWeight=null!==(s=t.iridescenceFactor)&&void 0!==s?s:0,l.thinFilmIor=null!==(n=null!==(a=t.iridescenceIor)&&void 0!==a?a:t.iridescenceIOR)&&void 0!==n?n:1.3,l.thinFilmThicknessMinimum=null!==(o=t.iridescenceThicknessMinimum)&&void 0!==o?o: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=`${r.name} (Iridescence)`,l.thinFilmWeightTexture=e})),t.iridescenceThicknessTexture&&u.push(this._loader.loadTextureInfoAsync(`${e}/iridescenceThicknessTexture`,t.iridescenceThicknessTexture,e=>{e.name=`${r.name} (Iridescence Thickness)`,l.thinFilmThicknessTexture=e})),Promise.all(u).then(()=>{})}}let Qe=!1;function Je(){Qe||(Qe=!0,B(Ye),P(Ye,!0,e=>new Xe(e)))}Je();const Ze="KHR_materials_anisotropy";class et{constructor(e){this.name=Ze,this.order=195,this._loader=e,this.enabled=this._loader.isExtensionUsed(Ze)}dispose(){this._loader=null}loadMaterialPropertiesAsync(e,t,r){return $.LoadExtensionAsync(e,t,this.name,(s,a)=>S(this,void 0,void 0,function*(){const n=new Array;n.push(this._loader.loadMaterialPropertiesAsync(e,t,r)),n.push(this._loadAnisotropyPropertiesAsync(s,a,r)),yield Promise.all(n)}))}_loadAnisotropyPropertiesAsync(e,t,r){return S(this,void 0,void 0,function*(){var s,a,n;const o=this._loader._getOrCreateMaterialAdapter(r),i=new Array,l=null!==(s=t.anisotropyStrength)&&void 0!==s?s:0,u=null!==(a=t.anisotropyRotation)&&void 0!==a?a:0;o.specularRoughnessAnisotropy=l,o.geometryTangentAngle=u;const c=null!==(n=t.extensions)&&void 0!==n?n:{};c.EXT_materials_anisotropy_openpbr&&c.EXT_materials_anisotropy_openpbr.openPbrAnisotropyEnabled||o.configureGltfStyleAnisotropy(!0),t.anisotropyTexture&&(t.anisotropyTexture.nonColorData=!0,i.push(this._loader.loadTextureInfoAsync(`${e}/anisotropyTexture`,t.anisotropyTexture,e=>{e.name=`${r.name} (Anisotropy Intensity)`,o.geometryTangentTexture=e}))),yield Promise.all(i)})}}let tt=!1;function rt(){tt||(tt=!0,B(Ze),P(Ze,!0,e=>new et(e)))}rt();const st="KHR_materials_emissive_strength";class at{constructor(e){this.name=st,this.order=170,this._loader=e,this.enabled=this._loader.isExtensionUsed(st)}dispose(){this._loader=null}loadMaterialPropertiesAsync(e,t,r){return $.LoadExtensionAsync(e,t,this.name,(s,a)=>S(this,void 0,void 0,function*(){return yield this._loader.loadMaterialPropertiesAsync(e,t,r),this._loadEmissiveProperties(s,a,r),yield Promise.resolve()}))}_loadEmissiveProperties(e,t,r){void 0!==t.emissiveStrength&&(this._loader._getOrCreateMaterialAdapter(r).emissionLuminance=t.emissiveStrength)}}let nt=!1;function ot(){nt||(nt=!0,B(st),P(st,!0,e=>new at(e)))}ot();const it="KHR_materials_sheen";class lt{constructor(e){this.name=it,this.order=190,this._loader=e,this.enabled=this._loader.isExtensionUsed(it)}dispose(){this._loader=null}loadMaterialPropertiesAsync(e,t,r){return $.LoadExtensionAsync(e,t,this.name,(s,a)=>S(this,void 0,void 0,function*(){const n=new Array;return n.push(this._loader.loadMaterialPropertiesAsync(e,t,r)),n.push(this._loadSheenPropertiesAsync(s,a,r)),yield Promise.all(n).then(()=>{})}))}_loadSheenPropertiesAsync(e,r,s){const a=this._loader._getOrCreateMaterialAdapter(s),n=new Array;a.configureFuzz();const o=void 0!==r.sheenColorFactor?t.Color3.FromArray(r.sheenColorFactor):t.Color3.Black(),i=void 0!==r.sheenRoughnessFactor?r.sheenRoughnessFactor:0;return a.fuzzWeight=1,a.fuzzColor=o,a.fuzzRoughness=i,r.sheenColorTexture&&n.push(this._loader.loadTextureInfoAsync(`${e}/sheenColorTexture`,r.sheenColorTexture,e=>{e.name=`${s.name} (Sheen Color)`,a.fuzzColorTexture=e})),r.sheenRoughnessTexture&&(r.sheenRoughnessTexture.nonColorData=!0,n.push(this._loader.loadTextureInfoAsync(`${e}/sheenRoughnessTexture`,r.sheenRoughnessTexture,e=>{e.name=`${s.name} (Sheen Roughness)`,a.fuzzRoughnessTexture=e}))),Promise.all(n).then(()=>{})}}let ut=!1;function ct(){ut||(ut=!0,B(it),P(it,!0,e=>new lt(e)))}ct();const ht="KHR_materials_fuzz";class dt{constructor(e){this.name=ht,this.order=190,this._loader=e,this.enabled=this._loader.isExtensionUsed(ht)}dispose(){this._loader=null}loadMaterialPropertiesAsync(e,t,r){return $.LoadExtensionAsync(e,t,this.name,(s,a)=>S(this,void 0,void 0,function*(){const n=new Array;return n.push(this._loader.loadMaterialPropertiesAsync(e,t,r)),n.push(this._loadFuzzPropertiesAsync(s,a,r)),yield Promise.all(n).then(()=>{})}))}_loadFuzzPropertiesAsync(e,r,s){const a=this._loader._getOrCreateMaterialAdapter(s),n=new Array;return a.configureFuzz(),a.fuzzWeight=void 0!==r.fuzzFactor?r.fuzzFactor:0,a.fuzzColor=void 0!==r.fuzzColorFactor?t.Color3.FromArray(r.fuzzColorFactor):t.Color3.White(),a.fuzzRoughness=void 0!==r.fuzzRoughnessFactor?r.fuzzRoughnessFactor:.5,r.fuzzTexture&&n.push(this._loader.loadTextureInfoAsync(`${e}/fuzzTexture`,r.fuzzTexture,e=>{e.name=`${s.name} (Fuzz)`,a.fuzzWeightTexture=e})),r.fuzzColorTexture&&n.push(this._loader.loadTextureInfoAsync(`${e}/fuzzColorTexture`,r.fuzzColorTexture,e=>{e.name=`${s.name} (Fuzz Color)`,a.fuzzColorTexture=e})),r.fuzzRoughnessTexture&&(r.fuzzRoughnessTexture.nonColorData=!0,n.push(this._loader.loadTextureInfoAsync(`${e}/fuzzRoughnessTexture`,r.fuzzRoughnessTexture,e=>{e.name=`${s.name} (Fuzz Roughness)`,a.fuzzRoughnessTexture=e}))),Promise.all(n).then(()=>{})}}let mt=!1;function _t(){mt||(mt=!0,B(ht),P(ht,!0,e=>new dt(e)))}_t();const pt="KHR_materials_specular";class ft{constructor(e){this.name=pt,this.order=190,this._loader=e,this.enabled=this._loader.isExtensionUsed(pt)}dispose(){this._loader=null}loadMaterialPropertiesAsync(e,t,r){return $.LoadExtensionAsync(e,t,this.name,(s,a)=>S(this,void 0,void 0,function*(){const n=new Array;n.push(this._loader.loadMaterialPropertiesAsync(e,t,r)),n.push(this._loadSpecularPropertiesAsync(s,a,r));const o=this._loader._getOrCreateMaterialAdapter(r);return a.extensions&&a.extensions.EXT_materials_specular_edge_color&&a.extensions.EXT_materials_specular_edge_color.specularEdgeColorEnabled&&o.enableSpecularEdgeColor(!0),yield Promise.all(n).then(()=>{})}))}_loadSpecularPropertiesAsync(e,r,s){var a;const n=this._loader._getOrCreateMaterialAdapter(s),o=new Array;return n.specularWeight=null!==(a=r.specularFactor)&&void 0!==a?a:1,n.specularColor=void 0!==r.specularColorFactor?t.Color3.FromArray(r.specularColorFactor):new t.Color3(1,1,1),r.specularTexture&&(r.specularTexture.nonColorData=!0,o.push(this._loader.loadTextureInfoAsync(`${e}/specularTexture`,r.specularTexture,e=>{e.name=`${s.name} (Specular)`,n.specularWeightTexture=e}))),r.specularColorTexture&&o.push(this._loader.loadTextureInfoAsync(`${e}/specularColorTexture`,r.specularColorTexture,e=>{e.name=`${s.name} (Specular Color)`,n.specularColorTexture=e})),Promise.all(o).then(()=>{})}}let gt=!1;function bt(){gt||(gt=!0,B(pt),P(pt,!0,e=>new ft(e)))}bt();const yt="KHR_materials_ior";class Tt{constructor(e){this.name=yt,this.order=180,this._loader=e,this.enabled=this._loader.isExtensionUsed(yt)}dispose(){this._loader=null}loadMaterialPropertiesAsync(e,t,r){return $.LoadExtensionAsync(e,t,this.name,(s,a)=>S(this,void 0,void 0,function*(){const n=new Array;return n.push(this._loader.loadMaterialPropertiesAsync(e,t,r)),n.push(this._loadIorPropertiesAsync(s,a,r)),yield Promise.all(n).then(()=>{})}))}_loadIorPropertiesAsync(e,t,r){const s=this._loader._getOrCreateMaterialAdapter(r),a=void 0!==t.ior?t.ior:Tt._DEFAULT_IOR;return s.specularIor=a,Promise.resolve()}}Tt._DEFAULT_IOR=1.5;let vt=!1;function xt(){vt||(vt=!0,B(yt),P(yt,!0,e=>new Tt(e)))}xt();const At="KHR_materials_variants";class Ct{constructor(e){this.name=At,this._loader=e,this.enabled=this._loader.isExtensionUsed(At)&&!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 Ct.GetAvailableVariants(e)}static SelectVariant(e,t){const r=this._GetExtensionMetadata(e);if(!r)throw new Error(`Cannot select variant on a glTF mesh that does not have the ${At} extension`);const s=e=>{const t=r.variants[e];if(t)for(const e of t)e.mesh.material=e.material};if(t instanceof Array)for(const e of t)s(e);else s(t);r.lastSelected=t}selectVariant(e,t){Ct.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 ${At} extension`);for(const e of t.original)e.mesh.material=e.material;t.lastSelected=null}reset(e){Ct.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 ${At} extension`);return t.lastSelected}getLastSelectedVariant(e){return Ct.GetLastSelectedVariant(e)}static _GetExtensionMetadata(e){var t,r;return(null===(r=null===(t=null==e?void 0:e._internalMetadata)||void 0===t?void 0:t.gltf)||void 0===r?void 0:r[At])||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 r=this._loader.parent.extensionOptions[At];(null==r?void 0:r.defaultVariant)&&Ct.SelectVariant(t,r.defaultVariant),null===(e=null==r?void 0:r.onLoaded)||void 0===e||e.call(r,{get variants(){return Ct.GetAvailableVariants(t)},get selectedVariant(){const e=Ct.GetLastSelectedVariant(t);return e?Array.isArray(e)?e[0]:e:Ct.GetAvailableVariants(t)[0]},set selectedVariant(e){Ct.SelectVariant(t,e)}})}}_loadMeshPrimitiveAsync(e,r,s,a,n,o){return $.LoadExtensionAsync(e,n,this.name,(i,l)=>S(this,void 0,void 0,function*(){const u=new Array;return u.push(this._loader._loadMeshPrimitiveAsync(e,r,s,a,n,r=>{if(o(r),r instanceof t.Mesh){const t=$._GetDrawMode(e,n.mode),s=this._loader.rootBabylonMesh,a=s?s._internalMetadata=s._internalMetadata||{}:{},o=a.gltf=a.gltf||{},c=o[At]=o[At]||{lastSelected:null,original:[],variants:{}};c.original.push({mesh:r,material:r.material});for(let e=0;e<l.mappings.length;++e){const a=l.mappings[e],n=D.Get(`${i}/mappings/${e}/material`,this._loader.gltf.materials,a.material);u.push(this._loader._loadMaterialAsync(`#/materials/${a.material}`,n,r,t,e=>{for(let t=0;t<a.variants.length;++t){const n=a.variants[t],o=D.Get(`/extensions/${At}/variants/${n}`,this._variants,n);c.variants[o.name]=c.variants[o.name]||[],c.variants[o.name].push({mesh:r,material:e}),r.onClonedObservable.add(e=>{const t=e;let a,n=t;do{if(n=n.parent,!n)return;a=Ct._GetExtensionMetadata(n)}while(null===a);if(s&&a===Ct._GetExtensionMetadata(s)){n._internalMetadata={};for(const e in s._internalMetadata)n._internalMetadata[e]=s._internalMetadata[e];n._internalMetadata.gltf=[];for(const e in s._internalMetadata.gltf)n._internalMetadata.gltf[e]=s._internalMetadata.gltf[e];n._internalMetadata.gltf[At]={lastSelected:null,original:[],variants:{}};for(const e of a.original)n._internalMetadata.gltf[At].original.push({mesh:e.mesh,material:e.material});for(const e in a.variants)if(Object.prototype.hasOwnProperty.call(a.variants,e)){n._internalMetadata.gltf[At].variants[e]=[];for(const t of a.variants[e])n._internalMetadata.gltf[At].variants[e].push({mesh:t.mesh,material:t.material})}a=n._internalMetadata.gltf[At]}for(const e of a.original)e.mesh===r&&(e.mesh=t);for(const e of a.variants[o.name])e.mesh===r&&(e.mesh=t)})}}))}}})),yield Promise.all(u).then(([e])=>e)}))}}let Rt=!1;function wt(){Rt||(Rt=!0,B(At),P(At,!0,e=>new Ct(e)))}wt();class Mt{static _GetDefaultOptions(){return{renderSize:1024,samples:4,lodGenerationScale:1,lodGenerationOffset:-4,renderTargetTextureType:t.Constants.TEXTURETYPE_HALF_FLOAT,generateMipmaps:!0}}constructor(e,r){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({},Mt._GetDefaultOptions()),e),this._scene=r,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),r=this._options;this._options=t,t.renderSize===r.renderSize&&t.renderTargetTextureType===r.renderTargetTextureType&&t.generateMipmaps===r.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 r of this._materialImpls)if(e instanceof r.materialClass){t=new r.adapterClass(e),this._adapterCache.set(e,t);break}return t}_classifyMeshMaterials(e){const r=e.material;if(!r)return"opaque";if(!(r instanceof t.MultiMaterial)){const e=this._getOrCreateAdapter(r);return e&&e.isTranslucent()?(e.refractionBackgroundTexture=this._opaqueRenderTarget,"transparent"):"opaque"}let s=!1,a=!1;const n=new Set;for(let e=0;e<r.subMaterials.length;e++){const t=r.subMaterials[e];if(!t){a=!0;continue}const o=this._getOrCreateAdapter(t);o&&o.isTranslucent()?(o.refractionBackgroundTexture=this._opaqueRenderTarget,s=!0,n.add(e)):a=!0}return s&&a?(this._translucentMaterialIndices.set(e,n),this._rebuildOpaqueOnlySubMeshes(e,n),"mixed"):(this._translucentMaterialIndices.delete(e),this._opaqueOnlySubMeshes.delete(e),s?"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),r=this._opaqueMeshesCache.indexOf(e);"transparent"===this._classifyMeshMaterials(e)?-1!==r?(this._opaqueMeshesCache.splice(r,1),this._transparentMeshesCache.push(e)):-1===t&&this._transparentMeshesCache.push(e):-1!==t?(this._transparentMeshesCache.splice(t,1),this._opaqueMeshesCache.push(e)):-1===r&&this._opaqueMeshesCache.push(e)}_isRenderTargetValid(){var e;return null!==(null===(e=this._opaqueRenderTarget)||void 0===e?void 0:e.getInternalTexture())}_setupRenderTargets(){var e,r;let s;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!==(r=null===(e=this._options.clearColor)||void 0===e?void 0:e.clone())&&void 0!==r?r: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=>{s=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],r=e.value[1];t.subMeshes&&(this._savedSubMeshes.set(t,t.subMeshes),t.subMeshes=r)}}),this._opaqueRenderTarget.onAfterUnbindObservable.add(()=>{this._scene.environmentIntensity=s;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 a=this._translucentMaterialIndices.entries();for(let e=a.next();!e.done;e=a.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 r=[...this._transparentMeshesCache,...this._opaqueMeshesCache];for(const e of r){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 Ot(e,t){if(e.parent.dontUseTransmissionHelper)return;const r=t.getScene()._transmissionHelper,s=null!=r?r:new Mt({},t.getScene());for(const t of Array.from(e._pbrMaterialImpls.values()))s.addMaterialImpl(t);r&&!r._isRenderTargetValid()&&r._setupRenderTargets()}const Lt="KHR_materials_transmission";class Ft{constructor(e){this.name=Lt,this.order=175,this._loader=e,this.enabled=this._loader.isExtensionUsed(Lt),this.enabled&&(e.parent.transparencyAsCoverage=!0)}dispose(){this._loader=null}loadMaterialPropertiesAsync(e,t,r){return $.LoadExtensionAsync(e,t,this.name,(s,a)=>S(this,void 0,void 0,function*(){const n=new Array;return n.push(this._loader.loadMaterialPropertiesAsync(e,t,r)),n.push(this._loadTransparentPropertiesAsync(s,t,r,a)),yield Promise.all(n).then(()=>{})}))}_loadTransparentPropertiesAsync(e,t,r,s){const a=this._loader._getOrCreateMaterialAdapter(r),n=void 0!==s.transmissionFactor?s.transmissionFactor:0;if(0===n||!a)return Promise.resolve();a.configureTransmission(),a.transmissionWeight=n,n>0&&Ot(this._loader,r);let o=Promise.resolve(null);return s.transmissionTexture&&(s.transmissionTexture.nonColorData=!0,o=this._loader.loadTextureInfoAsync(`${e}/transmissionTexture`,s.transmissionTexture,e=>{e.name=`${r.name} (Transmission)`,a.transmissionWeightTexture=e})),o.then(()=>{})}}let Et=!1;function St(){Et||(Et=!0,B(Lt),P(Lt,!0,e=>new Ft(e)))}St();const kt="KHR_materials_diffuse_transmission";class It{constructor(e){this.name=kt,this.order=174,this._loader=e,this.enabled=this._loader.isExtensionUsed(kt),this.enabled&&(e.parent.transparencyAsCoverage=!0)}dispose(){this._loader=null}loadMaterialPropertiesAsync(e,t,r){return $.LoadExtensionAsync(e,t,this.name,(s,a)=>S(this,void 0,void 0,function*(){const n=new Array;return n.push(this._loader.loadMaterialPropertiesAsync(e,t,r)),n.push(this._loadTranslucentPropertiesAsync(s,t,r,a)),yield Promise.all(n).then(()=>{})}))}_loadTranslucentPropertiesAsync(e,r,s,a){var n;const o=this._loader._getOrCreateMaterialAdapter(s);o.configureSubsurface(),o.subsurfaceWeight=null!==(n=a.diffuseTransmissionFactor)&&void 0!==n?n:0,o.subsurfaceWeight>0&&Ot(this._loader,s),o.diffuseTransmissionTint=void 0!==a.diffuseTransmissionColorFactor?t.Color3.FromArray(a.diffuseTransmissionColorFactor):t.Color3.White();const i=new Array;return a.diffuseTransmissionTexture&&(a.diffuseTransmissionTexture.nonColorData=!0,i.push(this._loader.loadTextureInfoAsync(`${e}/diffuseTransmissionTexture`,a.diffuseTransmissionTexture).then(e=>{e.name=`${s.name} (Diffuse Transmission)`,o.subsurfaceWeightTexture=e}))),a.diffuseTransmissionColorTexture&&i.push(this._loader.loadTextureInfoAsync(`${e}/diffuseTransmissionColorTexture`,a.diffuseTransmissionColorTexture).then(e=>{e.name=`${s.name} (Diffuse Transmission Color)`,o.diffuseTransmissionTintTexture=e})),Promise.all(i).then(()=>{})}}let Pt=!1;function Bt(){Pt||(Pt=!0,B(kt),P(kt,!0,e=>new It(e)))}Bt();const Nt="KHR_materials_volume";class Gt{constructor(e){this.name=Nt,this.order=173,this._loader=e,this.enabled=this._loader.isExtensionUsed(Nt),this.enabled&&this._loader._disableInstancedMesh++}dispose(){this.enabled&&this._loader._disableInstancedMesh--,this._loader=null}loadMaterialPropertiesAsync(e,t,r){return $.LoadExtensionAsync(e,t,this.name,(s,a)=>S(this,void 0,void 0,function*(){const n=new Array;return n.push(this._loader.loadMaterialPropertiesAsync(e,t,r)),n.push(this._loadVolumePropertiesAsync(s,t,r,a)),yield Promise.all(n).then(()=>{})}))}_loadVolumePropertiesAsync(e,r,s,a){var n;const o=this._loader._getOrCreateMaterialAdapter(s);if(0===o.transmissionWeight&&0===o.subsurfaceWeight||!a.thicknessFactor)return Promise.resolve();o.geometryThinWalled=!1;const i=void 0!==a.attenuationDistance?a.attenuationDistance:Number.MAX_VALUE,l=void 0!==a.attenuationColor&&3==a.attenuationColor.length?t.Color3.FromArray(a.attenuationColor):t.Color3.White();o.configureVolume(),o.transmissionColor=l,o.transmissionDepth=i,o.volumeThickness=null!==(n=a.thicknessFactor)&&void 0!==n?n:0;const u=new Array;return a.thicknessTexture&&(a.thicknessTexture.nonColorData=!0,u.push(this._loader.loadTextureInfoAsync(`${e}/thicknessTexture`,a.thicknessTexture,e=>{e.name=`${s.name} (Thickness)`,o.volumeThicknessTexture=e}))),Promise.all(u).then(()=>{})}}let Dt=!1;function Vt(){Dt||(Dt=!0,B(Nt),P(Nt,!0,e=>new Gt(e)))}Vt();const $t="KHR_materials_volume_scatter";class Ht{constructor(e){this.name=$t,this.order=172,this._loader=e,this.enabled=this._loader.isExtensionUsed($t),this.enabled&&this._loader._disableInstancedMesh++}dispose(){this.enabled&&this._loader._disableInstancedMesh--,this._loader=null}loadMaterialPropertiesAsync(e,t,r){return $.LoadExtensionAsync(e,t,this.name,(s,a)=>S(this,void 0,void 0,function*(){const n=new Array;return n.push(this._loader.loadMaterialPropertiesAsync(e,t,r)),n.push(this._loadVolumePropertiesAsync(s,t,r,a)),yield Promise.all(n).then(()=>{})}))}_loadVolumePropertiesAsync(e,r,s,a){const n=this._loader._getOrCreateMaterialAdapter(s);if(0===n.transmissionWeight&&0===n.subsurfaceWeight||n.geometryThinWalled)return Promise.resolve();const o=void 0!==a.multiscatterColorFactor&&3==a.multiscatterColorFactor.length?t.Color3.FromArray(a.multiscatterColorFactor):t.Color3.Black(),i=void 0!==a.scatterAnisotropy?a.scatterAnisotropy:0;let l=Promise.resolve(null);a.multiscatterColorTexture&&(a.multiscatterColorTexture.nonColorData=!0,l=this._loader.loadTextureInfoAsync(`${e}/multiscatterColorTexture`,a.multiscatterColorTexture,e=>{e.name=`${s.name} (Scatter Color)`,n.transmissionWeight>0&&(n.transmissionScatterTexture=e),n.subsurfaceWeight>0&&(n.subsurfaceColorTexture=e)}));const u=new t.Vector3(-Math.log(n.transmissionColor.r),-Math.log(n.transmissionColor.g),-Math.log(n.transmissionColor.b));if(u.scaleInPlace(1/Math.max(n.transmissionDepth,1e-6)),n.transmissionWeight>0){const e=function(e){const r=new t.Vector3(e.r,e.g,e.b),s=new t.Vector3(4.09712,4.09712,4.09712);s.addInPlace(new t.Vector3(4.20863,4.20863,4.20863).multiplyInPlace(r));const a=new t.Vector3(9.59217,9.59217,9.59217);return a.addInPlace(new t.Vector3(41.6808,41.6808,41.6808).multiplyInPlace(r)),a.addInPlace(new t.Vector3(17.7126,17.7126,17.7126).multiplyInPlace(r.multiply(r))),s.subtractInPlace(new t.Vector3(Math.sqrt(a.x),Math.sqrt(a.y),Math.sqrt(a.z))),new t.Vector3(1,1,1).subtract(s.multiply(s))}(o),r=u.multiply(e);r.scaleInPlace(n.transmissionDepth),n.transmissionScatter.set(r.x,r.y,r.z),n.transmissionScatterAnisotropy=i}if(n.subsurfaceWeight>0){n.subsurfaceScatterAnisotropy=i,n.subsurfaceColor=o;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);n.subsurfaceRadius=Math.max(e.x,e.y,e.z),n.subsurfaceRadiusScale=new t.Color3(e.x/n.subsurfaceRadius,e.y/n.subsurfaceRadius,e.z/n.subsurfaceRadius)}return l.then(()=>{})}}let Kt=!1;function Wt(){Kt||(Kt=!0,B($t),P($t,!0,e=>new Ht(e)))}Wt();const Ut="KHR_materials_dispersion";class zt{constructor(e){this.name=Ut,this.order=174,this._loader=e,this.enabled=this._loader.isExtensionUsed(Ut)}dispose(){this._loader=null}loadMaterialPropertiesAsync(e,t,r){return $.LoadExtensionAsync(e,t,this.name,(s,a)=>S(this,void 0,void 0,function*(){const n=new Array;return n.push(this._loader.loadMaterialPropertiesAsync(e,t,r)),n.push(this._loadDispersionPropertiesAsync(s,t,r,a)),yield Promise.all(n).then(()=>{})}))}_loadDispersionPropertiesAsync(e,t,r,s){const a=this._loader._getOrCreateMaterialAdapter(r);return 0!=a.transmissionWeight&&s.dispersion?(a.transmissionDispersionAbbeNumber=20,a.transmissionDispersionScale=s.dispersion,Promise.resolve()):Promise.resolve()}}let qt=!1;function jt(){qt||(qt=!0,B(Ut),P(Ut,!0,e=>new zt(e)))}jt();const Yt="KHR_materials_diffuse_roughness";class Xt{constructor(e){this.name=Yt,this.order=190,this._loader=e,this.enabled=this._loader.isExtensionUsed(Yt)}dispose(){this._loader=null}loadMaterialPropertiesAsync(e,t,r){return $.LoadExtensionAsync(e,t,this.name,(s,a)=>S(this,void 0,void 0,function*(){const n=new Array;return n.push(this._loader.loadMaterialPropertiesAsync(e,t,r)),n.push(this._loadDiffuseRoughnessPropertiesAsync(s,a,r)),yield Promise.all(n).then(()=>{})}))}_loadDiffuseRoughnessPropertiesAsync(e,t,r){var s;const a=this._loader._getOrCreateMaterialAdapter(r),n=new Array;return a.baseDiffuseRoughness=null!==(s=t.diffuseRoughnessFactor)&&void 0!==s?s:0,t.diffuseRoughnessTexture&&n.push(this._loader.loadTextureInfoAsync(`${e}/diffuseRoughnessTexture`,t.diffuseRoughnessTexture,e=>{e.name=`${r.name} (Diffuse Roughness)`,a.baseDiffuseRoughnessTexture=e})),Promise.all(n).then(()=>{})}}let Qt=!1;function Jt(){Qt||(Qt=!0,B(Yt),P(Yt,!0,e=>new Xt(e)))}Jt();const Zt="KHR_mesh_quantization";class er{constructor(e){this.name=Zt,this.enabled=e.isExtensionUsed(Zt)}dispose(){}}let tr=!1;function rr(){tr||(tr=!0,B(Zt),P(Zt,!0,e=>new er(e)))}rr();const sr="KHR_texture_basisu";class ar{constructor(e){this.name=sr,this._loader=e,this.enabled=e.isExtensionUsed(sr)}dispose(){this._loader=null}_loadTextureAsync(e,t,r){return $.LoadExtensionAsync(e,t,this.name,(s,a)=>S(this,void 0,void 0,function*(){const n=null==t.sampler?$.DefaultSampler:D.Get(`${e}/sampler`,this._loader.gltf.samplers,t.sampler),o=D.Get(`${s}/source`,this._loader.gltf.images,a.source);return yield this._loader._createTextureAsync(e,n,o,e=>{r(e)},t._textureInfo.nonColorData?{useRGBAIfASTCBC7NotAvailableWhenUASTC:!0}:void 0,!t._textureInfo.nonColorData)}))}}let nr=!1;function or(){nr||(nr=!0,B(sr),P(sr,!0,e=>new ar(e)))}or();const ir="KHR_texture_transform";class lr{constructor(e){this.name=ir,this._loader=e,this.enabled=this._loader.isExtensionUsed(ir)}dispose(){this._loader=null}loadTextureInfoAsync(e,r,s){return $.LoadExtensionAsync(e,r,this.name,(a,n)=>S(this,void 0,void 0,function*(){return yield this._loader.loadTextureInfoAsync(e,r,e=>{if(!(e instanceof t.Texture))throw new Error(`${a}: Texture type not supported`);n.offset&&(e.uOffset=n.offset[0],e.vOffset=n.offset[1]),e.uRotationCenter=0,e.vRotationCenter=0,n.rotation&&(e.wAng=-n.rotation),n.scale&&(e.uScale=n.scale[0],e.vScale=n.scale[1]),null!=n.texCoord&&(e.coordinatesIndex=n.texCoord),s(e)})}))}}let ur=!1;function cr(){ur||(ur=!0,B(ir),P(ir,!0,e=>new lr(e)))}cr();const hr="KHR_xmp_json_ld";class dr{constructor(e){this.name=hr,this.order=100,this._loader=e,this.enabled=this._loader.isExtensionUsed(hr)}dispose(){this._loader=null}onLoading(){var e,t,r;if(null===this._loader.rootBabylonMesh)return;const s=null===(e=this._loader.gltf.extensions)||void 0===e?void 0:e.KHR_xmp_json_ld,a=null===(r=null===(t=this._loader.gltf.asset)||void 0===t?void 0:t.extensions)||void 0===r?void 0:r.KHR_xmp_json_ld;if(s&&a){const e=+a.packet;s.packets&&e<s.packets.length&&(this._loader.rootBabylonMesh.metadata=this._loader.rootBabylonMesh.metadata||{},this._loader.rootBabylonMesh.metadata.xmp=s.packets[e])}}}let mr=!1;function _r(){mr||(mr=!0,B(hr),P(hr,!0,e=>new dr(e)))}_r();const pr="KHR_animation_pointer";class fr{constructor(e){this.name=pr,this._loader=e,this._pathToObjectConverter=O(this._loader.gltf)}get enabled(){return this._loader.isExtensionUsed(pr)}dispose(){this._loader=null,delete this._pathToObjectConverter}_loadAnimationChannelAsync(e,r,s,a,n){var o;const i=null===(o=a.target.extensions)||void 0===o?void 0:o.KHR_animation_pointer;if(!i||!this._pathToObjectConverter)return null;"pointer"!==a.target.path&&t.Logger.Warn(`${e}/target/path: Value (${a.target.path}) must be (pointer) when using the ${this.name} extension`),null!=a.target.node&&t.Logger.Warn(`${e}/target/node: Value (${a.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,r,s,a,{object:t.object,info:t.info.interpolation},n)}catch(e){return t.Logger.Warn(`${l}/pointer: Invalid pointer (${u}) skipped`),null}}}let gr=!1;function br(){gr||(gr=!0,B(pr),P(pr,!0,e=>new fr(e)))}function yr(e,r,s,a){return t.Vector3.FromArray(r,s).scaleInPlace(a)}function Tr(e,r,s,a){return t.Quaternion.FromArray(r,s).scaleInPlace(a)}function vr(e,t,r,s){const a=new Array(e._numMorphTargets);for(let e=0;e<a.length;e++)a[e]=t[r++]*s;return a}class xr{constructor(e,t,r,s){this.type=e,this.name=t,this.getValue=r,this.getStride=s}_buildAnimation(e,r,s){const a=new t.Animation(e,this.name,r,this.type);return a.setKeys(s,!0),a}}class Ar extends xr{buildAnimations(e,t,r,s){const a=[];return a.push({babylonAnimatable:e._babylonTransformNode,babylonAnimation:this._buildAnimation(t,r,s)}),a}}class Cr extends xr{buildAnimations(e,r,s,a){const n=[];if(e._numMorphTargets)for(let o=0;o<e._numMorphTargets;o++){const i=new t.Animation(`${r}_${o}`,this.name,s,this.type);if(i.setKeys(a.map(e=>({frame:e.frame,inTangent:e.inTangent?e.inTangent[o]:void 0,value:e.value[o],outTangent:e.outTangent?e.outTangent[o]:void 0,interpolation:e.interpolation})),!0),e._primitiveBabylonMeshes)for(const t of e._primitiveBabylonMeshes)if(t.morphTargetManager){const e=t.morphTargetManager.getTarget(o),r=i.clone();e.animations.push(r),n.push({babylonAnimatable:e,babylonAnimation:r})}}return n}}F("/nodes/{}/translation",[new Ar(t.Animation.ANIMATIONTYPE_VECTOR3,"position",yr,()=>3)]),F("/nodes/{}/rotation",[new Ar(t.Animation.ANIMATIONTYPE_QUATERNION,"rotationQuaternion",Tr,()=>4)]),F("/nodes/{}/scale",[new Ar(t.Animation.ANIMATIONTYPE_VECTOR3,"scaling",yr,()=>3)]),F("/nodes/{}/weights",[new Cr(t.Animation.ANIMATIONTYPE_FLOAT,"influence",vr,e=>e._numMorphTargets)]);var Rr={__proto__:null,AnimationPropertyInfo:xr,TransformNodeAnimationPropertyInfo:Ar,WeightAnimationPropertyInfo:Cr,getQuaternion:Tr,getVector3:yr,getWeights:vr};function wr(e,r,s,a){return t.Color3.FromArray(r,s).scale(a)}function Mr(e,t,r,s){return t[r]*s}function Or(e,t,r,s){return-t[r]*s}function Lr(e,t,r,s){return t[r+1]*s}function Fr(e,t,r,s){return t[r]*s*2}function Er(e){return{scale:[new kr(t.Animation.ANIMATIONTYPE_FLOAT,`${e}.uScale`,Mr,()=>2),new kr(t.Animation.ANIMATIONTYPE_FLOAT,`${e}.vScale`,Lr,()=>2)],offset:[new kr(t.Animation.ANIMATIONTYPE_FLOAT,`${e}.uOffset`,Mr,()=>2),new kr(t.Animation.ANIMATIONTYPE_FLOAT,`${e}.vOffset`,Lr,()=>2)],rotation:[new kr(t.Animation.ANIMATIONTYPE_FLOAT,`${e}.wAng`,Or,()=>1)]}}class Sr extends xr{buildAnimations(e,t,r,s){return[{babylonAnimatable:e._babylonCamera,babylonAnimation:this._buildAnimation(t,r,s)}]}}class kr extends xr{buildAnimations(e,t,r,s){const a=[];for(const n in e._data)a.push({babylonAnimatable:e._data[n].babylonMaterial,babylonAnimation:this._buildAnimation(t,r,s)});return a}}class Ir extends xr{buildAnimations(e,t,r,s){return[{babylonAnimatable:e._babylonLight,babylonAnimation:this._buildAnimation(t,r,s)}]}}F("/cameras/{}/orthographic/xmag",[new Sr(t.Animation.ANIMATIONTYPE_FLOAT,"orthoLeft",Or,()=>1),new Sr(t.Animation.ANIMATIONTYPE_FLOAT,"orthoRight",Lr,()=>1)]),F("/cameras/{}/orthographic/ymag",[new Sr(t.Animation.ANIMATIONTYPE_FLOAT,"orthoBottom",Or,()=>1),new Sr(t.Animation.ANIMATIONTYPE_FLOAT,"orthoTop",Lr,()=>1)]),F("/cameras/{}/orthographic/zfar",[new Sr(t.Animation.ANIMATIONTYPE_FLOAT,"maxZ",Mr,()=>1)]),F("/cameras/{}/orthographic/znear",[new Sr(t.Animation.ANIMATIONTYPE_FLOAT,"minZ",Mr,()=>1)]),F("/cameras/{}/perspective/yfov",[new Sr(t.Animation.ANIMATIONTYPE_FLOAT,"fov",Mr,()=>1)]),F("/cameras/{}/perspective/zfar",[new Sr(t.Animation.ANIMATIONTYPE_FLOAT,"maxZ",Mr,()=>1)]),F("/cameras/{}/perspective/znear",[new Sr(t.Animation.ANIMATIONTYPE_FLOAT,"minZ",Mr,()=>1)]),F("/materials/{}/pbrMetallicRoughness/baseColorFactor",[new kr(t.Animation.ANIMATIONTYPE_COLOR3,"albedoColor",wr,()=>4),new kr(t.Animation.ANIMATIONTYPE_FLOAT,"alpha",function(e,t,r,s){return t[r+3]*s},()=>4)]),F("/materials/{}/pbrMetallicRoughness/metallicFactor",[new kr(t.Animation.ANIMATIONTYPE_FLOAT,"metallic",Mr,()=>1)]),F("/materials/{}/pbrMetallicRoughness/metallicFactor",[new kr(t.Animation.ANIMATIONTYPE_FLOAT,"roughness",Mr,()=>1)]);const Pr=Er("albedoTexture");F("/materials/{}/pbrMetallicRoughness/baseColorTexture/extensions/KHR_texture_transform/scale",Pr.scale),F("/materials/{}/pbrMetallicRoughness/baseColorTexture/extensions/KHR_texture_transform/offset",Pr.offset),F("/materials/{}/pbrMetallicRoughness/baseColorTexture/extensions/KHR_texture_transform/rotation",Pr.rotation);const Br=Er("metallicTexture");F("//materials/{}/pbrMetallicRoughness/metallicRoughnessTexture/scale",Br.scale),F("//materials/{}/pbrMetallicRoughness/metallicRoughnessTexture/offset",Br.offset),F("//materials/{}/pbrMetallicRoughness/metallicRoughnessTexture/rotation",Br.rotation),F("/materials/{}/emissiveFactor",[new kr(t.Animation.ANIMATIONTYPE_COLOR3,"emissiveColor",wr,()=>3)]);const Nr=Er("bumpTexture");F("/materials/{}/normalTexture/scale",[new kr(t.Animation.ANIMATIONTYPE_FLOAT,"bumpTexture.level",Mr,()=>1)]),F("/materials/{}/normalTexture/extensions/KHR_texture_transform/scale",Nr.scale),F("/materials/{}/normalTexture/extensions/KHR_texture_transform/offset",Nr.offset),F("/materials/{}/normalTexture/extensions/KHR_texture_transform/rotation",Nr.rotation),F("/materials/{}/occlusionTexture/strength",[new kr(t.Animation.ANIMATIONTYPE_FLOAT,"ambientTextureStrength",Mr,()=>1)]);const Gr=Er("ambientTexture");F("/materials/{}/occlusionTexture/extensions/KHR_texture_transform/scale",Gr.scale),F("/materials/{}/occlusionTexture/extensions/KHR_texture_transform/offset",Gr.offset),F("/materials/{}/occlusionTexture/extensions/KHR_texture_transform/rotation",Gr.rotation);const Dr=Er("emissiveTexture");F("/materials/{}/emissiveTexture/extensions/KHR_texture_transform/scale",Dr.scale),F("/materials/{}/emissiveTexture/extensions/KHR_texture_transform/offset",Dr.offset),F("/materials/{}/emissiveTexture/extensions/KHR_texture_transform/rotation",Dr.rotation),F("/materials/{}/extensions/KHR_materials_anisotropy/anisotropyStrength",[new kr(t.Animation.ANIMATIONTYPE_FLOAT,"anisotropy.intensity",Mr,()=>1)]),F("/materials/{}/extensions/KHR_materials_anisotropy/anisotropyRotation",[new kr(t.Animation.ANIMATIONTYPE_FLOAT,"anisotropy.angle",Mr,()=>1)]);const Vr=Er("anisotropy.texture");F("/materials/{}/extensions/KHR_materials_anisotropy/anisotropyTexture/extensions/KHR_texture_transform/scale",Vr.scale),F("/materials/{}/extensions/KHR_materials_anisotropy/anisotropyTexture/extensions/KHR_texture_transform/offset",Vr.offset),F("/materials/{}/extensions/KHR_materials_anisotropy/anisotropyTexture/extensions/KHR_texture_transform/rotation",Vr.rotation),F("/materials/{}/extensions/KHR_materials_clearcoat/clearcoatFactor",[new kr(t.Animation.ANIMATIONTYPE_FLOAT,"clearCoat.intensity",Mr,()=>1)]),F("/materials/{}/extensions/KHR_materials_clearcoat/clearcoatRoughnessFactor",[new kr(t.Animation.ANIMATIONTYPE_FLOAT,"clearCoat.roughness",Mr,()=>1)]);const $r=Er("clearCoat.texture");F("/materials/{}/extensions/KHR_materials_clearcoat/clearcoatTexture/extensions/KHR_texture_transform/scale",$r.scale),F("/materials/{}/extensions/KHR_materials_clearcoat/clearcoatTexture/extensions/KHR_texture_transform/offset",$r.offset),F("/materials/{}/extensions/KHR_materials_clearcoat/clearcoatTexture/extensions/KHR_texture_transform/rotation",$r.rotation);const Hr=Er("clearCoat.bumpTexture");F("/materials/{}/extensions/KHR_materials_clearcoat/clearcoatNormalTexture/scale",[new kr(t.Animation.ANIMATIONTYPE_FLOAT,"clearCoat.bumpTexture.level",Mr,()=>1)]),F("/materials/{}/extensions/KHR_materials_clearcoat/clearcoatNormalTexture/extensions/KHR_texture_transform/scale",Hr.scale),F("/materials/{}/extensions/KHR_materials_clearcoat/clearcoatNormalTexture/extensions/KHR_texture_transform/offset",Hr.offset),F("/materials/{}/extensions/KHR_materials_clearcoat/clearcoatNormalTexture/extensions/KHR_texture_transform/rotation",Hr.rotation);const Kr=Er("clearCoat.textureRoughness");F("/materials/{}/extensions/KHR_materials_clearcoat/clearcoatRoughnessTexture/extensions/KHR_texture_transform/scale",Kr.scale),F("/materials/{}/extensions/KHR_materials_clearcoat/clearcoatRoughnessTexture/extensions/KHR_texture_transform/offset",Kr.offset),F("/materials/{}/extensions/KHR_materials_clearcoat/clearcoatRoughnessTexture/extensions/KHR_texture_transform/rotation",Kr.rotation),F("/materials/{}/extensions/KHR_materials_dispersion/dispersionFactor",[new kr(t.Animation.ANIMATIONTYPE_FLOAT,"subSurface.dispersion",Mr,()=>1)]),F("/materials/{}/extensions/KHR_materials_emissive_strength/emissiveStrength",[new kr(t.Animation.ANIMATIONTYPE_FLOAT,"emissiveIntensity",Mr,()=>1)]),F("/materials/{}/extensions/KHR_materials_ior/ior",[new kr(t.Animation.ANIMATIONTYPE_FLOAT,"indexOfRefraction",Mr,()=>1)]),F("/materials/{}/extensions/KHR_materials_iridescence/iridescenceFactor",[new kr(t.Animation.ANIMATIONTYPE_FLOAT,"iridescence.intensity",Mr,()=>1)]),F("/materials/{}/extensions/KHR_materials_iridescence/iridescenceIor",[new kr(t.Animation.ANIMATIONTYPE_FLOAT,"iridescence.indexOfRefraction",Mr,()=>1)]),F("/materials/{}/extensions/KHR_materials_iridescence/iridescenceThicknessMinimum",[new kr(t.Animation.ANIMATIONTYPE_FLOAT,"iridescence.minimumThickness",Mr,()=>1)]),F("/materials/{}/extensions/KHR_materials_iridescence/iridescenceThicknessMaximum",[new kr(t.Animation.ANIMATIONTYPE_FLOAT,"iridescence.maximumThickness",Mr,()=>1)]);const Wr=Er("iridescence.texture");F("/materials/{}/extensions/KHR_materials_iridescence/iridescenceTexture/extensions/KHR_texture_transform/scale",Wr.scale),F("/materials/{}/extensions/KHR_materials_iridescence/iridescenceTexture/extensions/KHR_texture_transform/offset",Wr.offset),F("/materials/{}/extensions/KHR_materials_iridescence/iridescenceTexture/extensions/KHR_texture_transform/rotation",Wr.rotation);const Ur=Er("iridescence.thicknessTexture");F("/materials/{}/extensions/KHR_materials_iridescence/iridescenceThicknessTexture/extensions/KHR_texture_transform/scale",Ur.scale),F("/materials/{}/extensions/KHR_materials_iridescence/iridescenceThicknessTexture/extensions/KHR_texture_transform/offset",Ur.offset),F("/materials/{}/extensions/KHR_materials_iridescence/iridescenceThicknessTexture/extensions/KHR_texture_transform/rotation",Ur.rotation),F("/materials/{}/extensions/KHR_materials_sheen/sheenColorFactor",[new kr(t.Animation.ANIMATIONTYPE_COLOR3,"sheen.color",wr,()=>3)]),F("/materials/{}/extensions/KHR_materials_sheen/sheenRoughnessFactor",[new kr(t.Animation.ANIMATIONTYPE_FLOAT,"sheen.roughness",Mr,()=>1)]);const zr=Er("sheen.texture");F("/materials/{}/extensions/KHR_materials_sheen/sheenColorTexture/extensions/KHR_texture_transform/scale",zr.scale),F("/materials/{}/extensions/KHR_materials_sheen/sheenColorTexture/extensions/KHR_texture_transform/offset",zr.offset),F("/materials/{}/extensions/KHR_materials_sheen/sheenColorTexture/extensions/KHR_texture_transform/rotation",zr.rotation);const qr=Er("sheen.textureRoughness");F("/materials/{}/extensions/KHR_materials_sheen/sheenRoughnessTexture/extensions/KHR_texture_transform/scale",qr.scale),F("/materials/{}/extensions/KHR_materials_sheen/sheenRoughnessTexture/extensions/KHR_texture_transform/offset",qr.offset),F("/materials/{}/extensions/KHR_materials_sheen/sheenRoughnessTexture/extensions/KHR_texture_transform/rotation",qr.rotation),F("/materials/{}/extensions/KHR_materials_specular/specularFactor",[new kr(t.Animation.ANIMATIONTYPE_FLOAT,"metallicF0Factor",Mr,()=>1)]),F("/materials/{}/extensions/KHR_materials_specular/specularColorFactor",[new kr(t.Animation.ANIMATIONTYPE_COLOR3,"metallicReflectanceColor",wr,()=>3)]);const jr=Er("metallicReflectanceTexture");F("/materials/{}/extensions/KHR_materials_specular/specularTexture/extensions/KHR_texture_transform/scale",jr.scale),F("/materials/{}/extensions/KHR_materials_specular/specularTexture/extensions/KHR_texture_transform/offset",jr.offset),F("/materials/{}/extensions/KHR_materials_specular/specularTexture/extensions/KHR_texture_transform/rotation",jr.rotation);const Yr=Er("reflectanceTexture");F("/materials/{}/extensions/KHR_materials_specular/specularColorTexture/extensions/KHR_texture_transform/scale",Yr.scale),F("/materials/{}/extensions/KHR_materials_specular/specularColorTexture/extensions/KHR_texture_transform/offset",Yr.offset),F("/materials/{}/extensions/KHR_materials_specular/specularColorTexture/extensions/KHR_texture_transform/rotation",Yr.rotation),F("/materials/{}/extensions/KHR_materials_transmission/transmissionFactor",[new kr(t.Animation.ANIMATIONTYPE_FLOAT,"subSurface.refractionIntensity",Mr,()=>1)]);const Xr=Er("subSurface.refractionIntensityTexture");F("/materials/{}/extensions/KHR_materials_transmission/transmissionTexture/extensions/KHR_texture_transform/scale",Xr.scale),F("/materials/{}/extensions/KHR_materials_transmission/transmissionTexture/extensions/KHR_texture_transform/offset",Xr.offset),F("/materials/{}/extensions/KHR_materials_transmission/transmissionTexture/extensions/KHR_texture_transform/rotation",Xr.rotation),F("/materials/{}/extensions/KHR_materials_volume/attenuationColor",[new kr(t.Animation.ANIMATIONTYPE_COLOR3,"subSurface.tintColor",wr,()=>3)]),F("/materials/{}/extensions/KHR_materials_volume/attenuationDistance",[new kr(t.Animation.ANIMATIONTYPE_FLOAT,"subSurface.tintColorAtDistance",Mr,()=>1)]),F("/materials/{}/extensions/KHR_materials_volume/thicknessFactor",[new kr(t.Animation.ANIMATIONTYPE_FLOAT,"subSurface.maximumThickness",Mr,()=>1)]);const Qr=Er("subSurface.thicknessTexture");F("/materials/{}/extensions/KHR_materials_volume/thicknessTexture/extensions/KHR_texture_transform/scale",Qr.scale),F("/materials/{}/extensions/KHR_materials_volume/thicknessTexture/extensions/KHR_texture_transform/offset",Qr.offset),F("/materials/{}/extensions/KHR_materials_volume/thicknessTexture/extensions/KHR_texture_transform/rotation",Qr.rotation),F("/materials/{}/extensions/KHR_materials_diffuse_transmission/diffuseTransmissionFactor",[new kr(t.Animation.ANIMATIONTYPE_FLOAT,"subSurface.translucencyIntensity",Mr,()=>1)]);const Jr=Er("subSurface.translucencyIntensityTexture");F("materials/{}/extensions/KHR_materials_diffuse_transmission/diffuseTransmissionTexture/extensions/KHR_texture_transform/scale",Jr.scale),F("materials/{}/extensions/KHR_materials_diffuse_transmission/diffuseTransmissionTexture/extensions/KHR_texture_transform/offset",Jr.offset),F("materials/{}/extensions/KHR_materials_diffuse_transmission/diffuseTransmissionTexture/extensions/KHR_texture_transform/rotation",Jr.rotation),F("/materials/{}/extensions/KHR_materials_diffuse_transmission/diffuseTransmissionColorFactor",[new kr(t.Animation.ANIMATIONTYPE_COLOR3,"subSurface.translucencyColor",wr,()=>3)]);const Zr=Er("subSurface.translucencyColorTexture");F("materials/{}/extensions/KHR_materials_diffuse_transmission/diffuseTransmissionColorTexture/extensions/KHR_texture_transform/scale",Zr.scale),F("materials/{}/extensions/KHR_materials_diffuse_transmission/diffuseTransmissionColorTexture/extensions/KHR_texture_transform/offset",Zr.offset),F("materials/{}/extensions/KHR_materials_diffuse_transmission/diffuseTransmissionColorTexture/extensions/KHR_texture_transform/rotation",Zr.rotation),F("/extensions/KHR_lights_punctual/lights/{}/color",[new Ir(t.Animation.ANIMATIONTYPE_COLOR3,"diffuse",wr,()=>3)]),F("/extensions/KHR_lights_punctual/lights/{}/intensity",[new Ir(t.Animation.ANIMATIONTYPE_FLOAT,"intensity",Mr,()=>1)]),F("/extensions/KHR_lights_punctual/lights/{}/range",[new Ir(t.Animation.ANIMATIONTYPE_FLOAT,"range",Mr,()=>1)]),F("/extensions/KHR_lights_punctual/lights/{}/spot/innerConeAngle",[new Ir(t.Animation.ANIMATIONTYPE_FLOAT,"innerAngle",Fr,()=>1)]),F("/extensions/KHR_lights_punctual/lights/{}/spot/outerConeAngle",[new Ir(t.Animation.ANIMATIONTYPE_FLOAT,"angle",Fr,()=>1)]),F("/extensions/EXT_lights_area/lights/{}/color",[new Ir(t.Animation.ANIMATIONTYPE_COLOR3,"diffuse",wr,()=>3)]),F("/extensions/EXT_lights_area/lights/{}/intensity",[new Ir(t.Animation.ANIMATIONTYPE_FLOAT,"intensity",Mr,()=>1)]),F("/extensions/EXT_lights_area/lights/{}/size",[new Ir(t.Animation.ANIMATIONTYPE_FLOAT,"radius",Mr,()=>1)]),F("/extensions/EXT_lights_area/lights/{}/rect/aspect",[new Ir(t.Animation.ANIMATIONTYPE_FLOAT,"radius",Mr,()=>1)]),F("/nodes/{}/extensions/EXT_lights_ies/color",[new Ir(t.Animation.ANIMATIONTYPE_COLOR3,"diffuse",wr,()=>3)]),F("/nodes/{}/extensions/EXT_lights_ies/multiplier",[new Ir(t.Animation.ANIMATIONTYPE_FLOAT,"intensity",Mr,()=>1)]),F("/nodes/{}/extensions/KHR_node_visibility/visible",[new class extends xr{buildAnimations(e,t,r,s){return e._primitiveBabylonMeshes?e._primitiveBabylonMeshes.map(e=>({babylonAnimatable:e,babylonAnimation:this._buildAnimation(t,r,s)})):[]}}(t.Animation.ANIMATIONTYPE_FLOAT,"isVisible",Mr,()=>1)]),br();const es="MSFT_audio_emitter";class ts{constructor(e){this.name=es,this._loader=e,this.enabled=this._loader.isExtensionUsed(es)}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,D.Assign(this._clips),D.Assign(this._emitters)}}loadSceneAsync(e,t){return $.LoadExtensionAsync(e,t,this.name,(r,s)=>S(this,void 0,void 0,function*(){const a=new Array;a.push(this._loader.loadSceneAsync(e,t));for(const e of s.emitters){const t=D.Get(`${r}/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(`${r}: Direction or Distance properties are not allowed on emitters attached to a scene`);a.push(this._loadEmitterAsync(`${r}/emitters/${t.index}`,t))}yield Promise.all(a)}))}loadNodeAsync(e,r,s){return $.LoadExtensionAsync(e,r,this.name,(e,a)=>S(this,void 0,void 0,function*(){const n=new Array,o=yield this._loader.loadNodeAsync(e,r,r=>{for(const s of a.emitters){const a=D.Get(`${e}/emitters`,this._emitters,s);n.push(this._loadEmitterAsync(`${e}/emitters/${a.index}`,a).then(()=>{for(const e of a._babylonSounds)e.attachToMesh(r),null==a.innerAngle&&null==a.outerAngle||(e.setLocalDirectionToMesh(t.Vector3.Forward()),e.setDirectionalCone(2*t.Tools.ToDegrees(null==a.innerAngle?Math.PI:a.innerAngle),2*t.Tools.ToDegrees(null==a.outerAngle?Math.PI:a.outerAngle),0))}))}s(r)});return yield Promise.all(n),o}))}loadAnimationAsync(e,t){return $.LoadExtensionAsync(e,t,this.name,(r,s)=>S(this,void 0,void 0,function*(){const a=yield this._loader.loadAnimationAsync(e,t),n=new Array;D.Assign(s.events);for(const o of s.events)n.push(this._loadAnimationEventAsync(`${r}/events/${o.index}`,e,t,o,a));return yield Promise.all(n),a}))}_loadClipAsync(e,r){if(r._objectURL)return r._objectURL;let s;if(r.uri)s=this._loader.loadUriAsync(e,r,r.uri);else{const t=D.Get(`${e}/bufferView`,this._loader.gltf.bufferViews,r.bufferView);s=this._loader.loadBufferViewAsync(`/bufferViews/${t.index}`,t)}return r._objectURL=s.then(e=>{const s=t.GetBlobBufferSource(e);return URL.createObjectURL(new Blob([s],{type:r.mimeType}))}),r._objectURL}_loadEmitterAsync(e,r){if(r._babylonSounds=r._babylonSounds||[],!r._babylonData){const e=new Array,s=r.name||`emitter${r.index}`,a={loop:!1,autoplay:!1,volume:null==r.volume?1:r.volume};for(let n=0;n<r.clips.length;n++){const o=`/extensions/${this.name}/clips`,i=D.Get(o,this._clips,r.clips[n].clip);e.push(this._loadClipAsync(`${o}/${r.clips[n].clip}`,i).then(e=>{const o=r._babylonSounds[n]=new t.Sound(s,e,this._loader.babylonScene,null,a);o.refDistance=r.refDistance||1,o.maxDistance=r.maxDistance||256,o.rolloffFactor=r.rolloffFactor||1,o.distanceModel=r.distanceModel||"exponential"}))}const n=Promise.all(e).then(()=>{const e=r.clips.map(e=>e.weight||1),s=new t.WeightedSound(r.loop||!1,r._babylonSounds,e);r.innerAngle&&(s.directionalConeInnerAngle=2*t.Tools.ToDegrees(r.innerAngle)),r.outerAngle&&(s.directionalConeOuterAngle=2*t.Tools.ToDegrees(r.outerAngle)),r.volume&&(s.volume=r.volume),r._babylonData.sound=s});r._babylonData={loaded:n}}return r._babylonData.loaded}_getEventAction(e,t,r,s,a){switch(r){case"play":return e=>{const r=(a||0)+(e-s);t.play(r)};case"stop":return()=>{t.stop()};case"pause":return()=>{t.pause()};default:throw new Error(`${e}: Unsupported action ${r}`)}}_loadAnimationEventAsync(e,r,s,a,n){if(0==n.targetedAnimations.length)return Promise.resolve();const o=n.targetedAnimations[0],i=a.emitter,l=D.Get(`/extensions/${this.name}/emitters`,this._emitters,i);return this._loadEmitterAsync(e,l).then(()=>{const r=l._babylonData.sound;if(r){const s=new t.AnimationEvent(a.time,this._getEventAction(e,r,a.action,a.time,a.startOffset));o.animation.addEvent(s),n.onAnimationGroupEndObservable.add(()=>{r.stop()}),n.onAnimationGroupPauseObservable.add(()=>{r.pause()})}})}}let rs=!1;function ss(){rs||(rs=!0,B(es),P(es,!0,e=>new ts(e)))}ss();const as="MSFT_lod";class ns{constructor(e){var r,s;this.name=as,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!==(s=null===(r=this._loader.parent.extensionOptions[as])||void 0===r?void 0:r.maxLODsToLoad)&&void 0!==s?s:this.maxLODsToLoad,this.enabled=this._loader.isExtensionUsed(as)}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 r=this._loader.loadSceneAsync(e,t);return this._loadBufferLOD(this._bufferLODs,0),r}loadNodeAsync(e,r,s){return $.LoadExtensionAsync(e,r,this.name,(e,a)=>S(this,void 0,void 0,function*(){let n;const o=this._getLODs(e,r,this._loader.gltf.nodes,a.ids);this._loader.logOpen(`${e}`);for(let e=0;e<o.length;e++){const r=o[e];0!==e&&(this._nodeIndexLOD=e,this._nodeSignalLODs[e]=this._nodeSignalLODs[e]||new t.Deferred);const a=e=>{s(e),e.setEnabled(!1)},i=this._loader.loadNodeAsync(`/nodes/${r.index}`,r,a).then(t=>{if(0!==e){const t=o[e-1];t._babylonTransformNode&&(this._disposeTransformNode(t._babylonTransformNode),delete t._babylonTransformNode)}return t.setEnabled(!0),t});this._nodePromiseLODs[e]=this._nodePromiseLODs[e]||[],0===e?n=i:(this._nodeIndexLOD=null,this._nodePromiseLODs[e].push(i))}return this._loader.logClose(),yield n}))}_loadMaterialAsync(e,t,r,s,a){return this._nodeIndexLOD?null:$.LoadExtensionAsync(e,t,this.name,(e,n)=>S(this,void 0,void 0,function*(){let o;const i=this._getLODs(e,t,this._loader.gltf.materials,n.ids);this._loader.logOpen(`${e}`);for(let e=0;e<i.length;e++){const t=i[e];0!==e&&(this._materialIndexLOD=e);const n=this._loader._loadMaterialAsync(`/materials/${t.index}`,t,r,s,t=>{0===e&&a(t)}).then(t=>{if(0!==e){a(t);const r=i[e-1]._data;r[s]&&(this._disposeMaterials([r[s].babylonMaterial]),delete r[s])}return t});this._materialPromiseLODs[e]=this._materialPromiseLODs[e]||[],0===e?o=n:(this._materialIndexLOD=null,this._materialPromiseLODs[e].push(n))}return this._loader.logClose(),yield o}))}_loadUriAsync(e,r,s){if(null!==this._nodeIndexLOD){this._loader.log("deferred");const a=this._nodeIndexLOD-1;return this._nodeSignalLODs[a]=this._nodeSignalLODs[a]||new t.Deferred,this._nodeSignalLODs[this._nodeIndexLOD-1].promise.then(()=>S(this,void 0,void 0,function*(){return yield this._loader.loadUriAsync(e,r,s)}))}if(null!==this._materialIndexLOD){this._loader.log("deferred");const a=this._materialIndexLOD-1;return this._materialSignalLODs[a]=this._materialSignalLODs[a]||new t.Deferred,this._materialSignalLODs[a].promise.then(()=>S(this,void 0,void 0,function*(){return yield this._loader.loadUriAsync(e,r,s)}))}return null}loadBufferAsync(e,r,s,a){if(this._loader.parent.useRangeRequests&&!r.uri){if(!this._loader.bin)throw new Error(`${e}: Uri is missing or the binary glTF is missing its binary chunk`);const r=(e,r)=>S(this,void 0,void 0,function*(){const n=s,o=n+a-1;let i=e[r];return i?(i.start=Math.min(i.start,n),i.end=Math.max(i.end,o)):(i={start:n,end:o,loaded:new t.Deferred},e[r]=i),yield i.loaded.promise.then(e=>new Uint8Array(e.buffer,e.byteOffset+s-i.start,a))});return this._loader.log("deferred"),null!==this._nodeIndexLOD?r(this._nodeBufferLODs,this._nodeIndexLOD):null!==this._materialIndexLOD?r(this._materialBufferLODs,this._materialIndexLOD):r(this._bufferLODs,0)}return null}_loadBufferLOD(e,t){const r=e[t];r&&(this._loader.log(`Loading buffer range [${r.start}-${r.end}]`),this._loader.bin.readAsync(r.start,r.end-r.start+1).then(e=>{r.loaded.resolve(e)},e=>{r.loaded.reject(e)}))}_getLODs(e,t,r,s){if(this.maxLODsToLoad<=0)throw new Error("maxLODsToLoad must be greater than zero");const a=[];for(let t=s.length-1;t>=0;t--)if(a.push(D.Get(`${e}/ids/${s[t]}`,r,s[t])),a.length===this.maxLODsToLoad)return a;return a.push(t),a}_disposeTransformNode(e){const t=[],r=e.material;r&&t.push(r);for(const r of e.getChildMeshes())r.material&&t.push(r.material);e.dispose();const s=t.filter(e=>this._loader.babylonScene.meshes.every(t=>t.material!=e));this._disposeMaterials(s)}_disposeMaterials(e){const t={};for(const r of e){for(const e of r.getActiveTextures())t[e.uniqueId]=e;r.dispose()}for(const e in t)for(const r of this._loader.babylonScene.materials)r.hasTexture(t[e])&&delete t[e];for(const e in t)t[e].dispose()}}let os=!1;function is(){os||(os=!0,B(as),P(as,!0,e=>new ns(e)))}is();const ls="MSFT_minecraftMesh";class us{constructor(e){this.name=ls,this._loader=e,this.enabled=this._loader.isExtensionUsed(ls)}dispose(){this._loader=null}loadMaterialPropertiesAsync(e,t,r){return $.LoadExtraAsync(e,t,this.name,(s,a)=>S(this,void 0,void 0,function*(){if(a){if(!this._loader._pbrMaterialImpls.get("pbr"))throw new Error(`${s}: Material type not supported`);const a=this._loader.loadMaterialPropertiesAsync(e,t,r);return r.needAlphaBlending()&&(r.forceDepthWrite=!0,r.separateCullingPass=!0),r.backFaceCulling=r.forceDepthWrite,r.twoSidedLighting=!0,yield a}}))}}let cs=!1;function hs(){cs||(cs=!0,B(ls),P(ls,!0,e=>new us(e)))}hs();const ds="MSFT_sRGBFactors";class ms{constructor(e){this.name=ds,this._loader=e,this.enabled=this._loader.isExtensionUsed(ds)}dispose(){this._loader=null}loadMaterialPropertiesAsync(e,t,r){return $.LoadExtraAsync(e,t,this.name,(s,a)=>S(this,void 0,void 0,function*(){if(a){const s=this._loader._getOrCreateMaterialAdapter(r),a=this._loader.loadMaterialPropertiesAsync(e,t,r),n=r.getScene().getEngine().useExactSrgbConversions;return s.baseColorTexture||s.baseColor.toLinearSpaceToRef(s.baseColor,n),s.specularColorTexture||s.specularColor.toLinearSpaceToRef(s.specularColor,n),yield a}}))}}let _s=!1;function ps(){_s||(_s=!0,B(ds),P(ds,!0,e=>new ms(e)))}function fs(e){const[t,r]=e.split(":");return gs({op:t,extension:r})}function gs(e,r=!0){var s;const a=e.extension?null===(s=ys[e.extension])||void 0===s?void 0:s[e.op]:Ts[e.op];if(!a&&(t.Logger.Warn(`No mapping found for operation ${e.op} and extension ${e.extension||"KHR_interactivity"}`),r)){const t={},r={flows:{}};if(e.inputValueSockets){t.values={};for(const r in e.inputValueSockets)t.values[r]={name:r}}return e.outputValueSockets&&(r.values={},Object.keys(e.outputValueSockets).forEach(e=>{r.values[e]={name:e}})),{blocks:[],inputs:t,outputs:r}}return a}function bs(e,t,r){ys[t]||(ys[t]={}),ys[t][e]=r}ps();const ys={BABYLON:{"flow/log":{blocks:["FlowGraphConsoleLogBlock"],inputs:{values:{message:{name:"message"}}}}}},Ts={"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,r,s,a){var n;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 o=null===(n=e.configuration.event.value)||void 0===n?void 0:n[0];if("number"!=typeof o)throw new Error("Event id should be a number");const i=s.arrays.events[o],l=a[0];return l.config||(l.config={}),l.config.eventId=i.eventId,l.config.eventData=i.eventData,a}},"event/receive":{blocks:["FlowGraphReceiveCustomEventBlock"],outputs:{flows:{out:{name:"done"}}},validation(e,r){var s,a;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 n=e.configuration.event;if(!n)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 o=null===(s=n.value)||void 0===s?void 0:s[0];return"number"!=typeof o?(t.Logger.Error("Event id should be a number"),{valid:!1,error:"Event id should be a number"}):(null===(a=r.events)||void 0===a?void 0:a[o])?{valid:!0}:(t.Logger.Error(`Event with id ${o} not found`),{valid:!1,error:`Event with id ${o} not found`})},extraProcessor(e,t,r,s,a){var n;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 o=null===(n=e.configuration.event.value)||void 0===n?void 0:n[0];if("number"!=typeof o)throw new Error("Event id should be a number");const i=s.arrays.events[o],l=a[0];return l.config||(l.config={}),l.config.eventId=i.eventId,l.config.eventData=i.eventData,a}},"math/E":vs("FlowGraphEBlock"),"math/Pi":vs("FlowGraphPIBlock"),"math/Inf":vs("FlowGraphInfBlock"),"math/NaN":vs("FlowGraphNaNBlock"),"math/abs":vs("FlowGraphAbsBlock"),"math/sign":vs("FlowGraphSignBlock"),"math/trunc":vs("FlowGraphTruncBlock"),"math/floor":vs("FlowGraphFloorBlock"),"math/ceil":vs("FlowGraphCeilBlock"),"math/round":{blocks:["FlowGraphRoundBlock"],configuration:{},inputs:{values:{a:{name:"a"}}},outputs:{values:{value:{name:"value"}}},extraProcessor(e,t,r,s,a){var n;return(n=a[0]).config||(n.config={}),a[0].config.roundHalfAwayFromZero=!0,a}},"math/fract":vs("FlowGraphFractBlock"),"math/neg":vs("FlowGraphNegationBlock"),"math/add":vs("FlowGraphAddBlock",["a","b"],!0),"math/sub":vs("FlowGraphSubtractBlock",["a","b"],!0),"math/mul":{blocks:["FlowGraphMultiplyBlock"],extraProcessor(e,t,r,s,a){var n;(n=a[0]).config||(n.config={}),a[0].config.useMatrixPerComponent=!0,a[0].config.preventIntegerFloatArithmetic=!0;let o=-1;return Object.keys(e.values||{}).find(t=>{var r;return void 0!==(null===(r=e.values)||void 0===r?void 0:r[t].type)&&(o=e.values[t].type,!0)}),-1!==o&&(a[0].config.type=s.arrays.types[o].flowGraphType),a},validation:e=>e.values?xs(e):{valid:!0}},"math/div":vs("FlowGraphDivideBlock",["a","b"],!0),"math/rem":vs("FlowGraphModuloBlock",["a","b"]),"math/min":vs("FlowGraphMinBlock",["a","b"]),"math/max":vs("FlowGraphMaxBlock",["a","b"]),"math/clamp":vs("FlowGraphClampBlock",["a","b","c"]),"math/saturate":vs("FlowGraphSaturateBlock"),"math/mix":vs("FlowGraphMathInterpolationBlock",["a","b","c"]),"math/eq":vs("FlowGraphEqualityBlock",["a","b"]),"math/lt":vs("FlowGraphLessThanBlock",["a","b"]),"math/le":vs("FlowGraphLessThanOrEqualBlock",["a","b"]),"math/gt":vs("FlowGraphGreaterThanBlock",["a","b"]),"math/ge":vs("FlowGraphGreaterThanOrEqualBlock",["a","b"]),"math/isNaN":vs("FlowGraphIsNaNBlock"),"math/isInf":vs("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":vs("FlowGraphSinBlock"),"math/cos":vs("FlowGraphCosBlock"),"math/tan":vs("FlowGraphTanBlock"),"math/asin":vs("FlowGraphASinBlock"),"math/acos":vs("FlowGraphACosBlock"),"math/atan":vs("FlowGraphATanBlock"),"math/atan2":vs("FlowGraphATan2Block",["a","b"]),"math/sinh":vs("FlowGraphSinhBlock"),"math/cosh":vs("FlowGraphCoshBlock"),"math/tanh":vs("FlowGraphTanhBlock"),"math/asinh":vs("FlowGraphASinhBlock"),"math/acosh":vs("FlowGraphACoshBlock"),"math/atanh":vs("FlowGraphATanhBlock"),"math/exp":vs("FlowGraphExponentialBlock"),"math/log":vs("FlowGraphLogBlock"),"math/log2":vs("FlowGraphLog2Block"),"math/log10":vs("FlowGraphLog10Block"),"math/sqrt":vs("FlowGraphSquareRootBlock"),"math/cbrt":vs("FlowGraphCubeRootBlock"),"math/pow":vs("FlowGraphPowerBlock",["a","b"]),"math/length":vs("FlowGraphLengthBlock"),"math/normalize":vs("FlowGraphNormalizeBlock"),"math/dot":vs("FlowGraphDotBlock",["a","b"]),"math/cross":vs("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":vs("FlowGraphTransposeBlock"),"math/determinant":vs("FlowGraphDeterminantBlock"),"math/inverse":vs("FlowGraphInvertMatrixBlock"),"math/matMul":vs("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,r,s,a,n){const o=a[0].dataInputs.find(e=>"rotationQuaternion"===e.name);if(!o)throw new Error("Rotation quaternion input not found");return n._connectionValues[o.uniqueId]&&(n._connectionValues[o.uniqueId].type="Quaternion"),a}},"math/matDecompose":{blocks:["FlowGraphMatrixDecompose"],inputs:{values:{a:{name:"input",gltfType:"number"}}},outputs:{values:{translation:{name:"position"},rotation:{name:"rotationQuaternion"},scale:{name:"scaling"}}}},"math/quatConjugate":vs("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,r,s,a){var n;return(n=a[0]).config||(n.config={}),a[0].config.type="Quaternion",a}},"math/quatAngleBetween":vs("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":vs("FlowGraphAxisAngleFromQuaternionBlock",["a"]),"math/quatFromDirections":vs("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,r,s,a){var n;return(n=a[0]).config||(n.config={}),a[0].config.inputIsColumnMajor=!0,a}},"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,r,s,a){var n;return(n=a[0]).config||(n.config={}),a[0].config.inputIsColumnMajor=!0,a}},"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,r,s,a){var n;return(n=a[0]).config||(n.config={}),a[0].config.inputIsColumnMajor=!0,a}},"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,r,s,a,n){var o,i,l;(l=a[0]).config||(l.config={});const u=a[0].dataInputs[0];return a[0].config.valueType=null!==(i=null===(o=n._connectionValues[u.uniqueId])||void 0===o?void 0:o.type)&&void 0!==i?i:"FlowGraphInteger",a}},"math/and":{blocks:["FlowGraphBitwiseAndBlock"],inputs:{values:{a:{name:"a"},b:{name:"b"}}},outputs:{values:{value:{name:"value"}}},extraProcessor(e,t,r,s,a,n){var o,i,l,u,c;(c=a[0]).config||(c.config={});const h=a[0].dataInputs[0],d=a[0].dataInputs[1];return a[0].config.valueType=null!==(u=null!==(i=null===(o=n._connectionValues[h.uniqueId])||void 0===o?void 0:o.type)&&void 0!==i?i:null===(l=n._connectionValues[d.uniqueId])||void 0===l?void 0:l.type)&&void 0!==u?u:"FlowGraphInteger",a}},"math/or":{blocks:["FlowGraphBitwiseOrBlock"],inputs:{values:{a:{name:"a"},b:{name:"b"}}},outputs:{values:{value:{name:"value"}}},extraProcessor(e,t,r,s,a,n){var o,i,l,u,c;(c=a[0]).config||(c.config={});const h=a[0].dataInputs[0],d=a[0].dataInputs[1];return a[0].config.valueType=null!==(u=null!==(i=null===(o=n._connectionValues[h.uniqueId])||void 0===o?void 0:o.type)&&void 0!==i?i:null===(l=n._connectionValues[d.uniqueId])||void 0===l?void 0:l.type)&&void 0!==u?u:"FlowGraphInteger",a}},"math/xor":{blocks:["FlowGraphBitwiseXorBlock"],inputs:{values:{a:{name:"a"},b:{name:"b"}}},outputs:{values:{value:{name:"value"}}},extraProcessor(e,t,r,s,a,n){var o,i,l,u,c;(c=a[0]).config||(c.config={});const h=a[0].dataInputs[0],d=a[0].dataInputs[1];return a[0].config.valueType=null!==(u=null!==(i=null===(o=n._connectionValues[h.uniqueId])||void 0===o?void 0:o.type)&&void 0!==i?i:null===(l=n._connectionValues[d.uniqueId])||void 0===l?void 0:l.type)&&void 0!==u?u:"FlowGraphInteger",a}},"math/asr":vs("FlowGraphBitwiseRightShiftBlock",["a","b"]),"math/lsl":vs("FlowGraphBitwiseLeftShiftBlock",["a","b"]),"math/clz":vs("FlowGraphLeadingZerosBlock"),"math/ctz":vs("FlowGraphTrailingZerosBlock"),"math/popcnt":vs("FlowGraphOneBitsCounterBlock"),"math/rad":vs("FlowGraphDegToRadBlock"),"math/deg":vs("FlowGraphRadToDegBlock"),"type/boolToInt":vs("FlowGraphBooleanToInt"),"type/boolToFloat":vs("FlowGraphBooleanToFloat"),"type/intToBool":vs("FlowGraphIntToBoolean"),"type/intToFloat":vs("FlowGraphIntToFloat"),"type/floatToInt":vs("FlowGraphFloatToInt"),"type/floatToBool":vs("FlowGraphFloatToBoolean"),"flow/sequence":{blocks:["FlowGraphSequenceBlock"],extraProcessor(e,t,r,s,a){const n=a[0];return n.config||(n.config={}),n.config.outputSignalCount=Object.keys(e.flows||[]).length,n.signalOutputs.forEach((e,t)=>{e.name="out_"+t}),a}},"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 r;const s=null===(r=e.configuration)||void 0===r?void 0:r.cases;if(s&&s.value){if(!s.value.every(e=>"number"==typeof e&&/^-?\d+$/.test(e.toString())))return t.Logger.Warn("Switch cases should be integers. Using empty array instead."),s.value=[],{valid:!0};const e=new Set(s.value);s.value=Array.from(e)}return{valid:!0}},extraProcessor(e,t,r,s,a){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 a[0].signalOutputs.forEach(e=>{"default"!==e.name&&(e.name="out_"+e.name)}),a}},"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,r,s,a){const n=a[0];return n.config||(n.config={}),n.config.incrementIndexWhenLoopDone=!0,a}},"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,r,s,a){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 n=a[0];return n.config||(n.config={}),n.config.outputSignalCount=Object.keys(e.flows).length,n.signalOutputs.forEach((e,t)=>{e.name="out_"+t}),a}},"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,r,s;return"number"!=typeof(null===(s=null===(r=null===(t=e.configuration)||void 0===t?void 0:t.inputFlows)||void 0===r?void 0:r.value)||void 0===s?void 0:s[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 r,s;return(null===(s=null===(r=e.configuration)||void 0===r?void 0:r.variable)||void 0===s?void 0:s.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,r,s,a)=>(a[0].dataInputs.forEach(e=>{e.name=s.getVariableName(+e.name)}),a)},"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,r,s,a,n){var o,i,l,u,c,h;const d=n[0],m=null===(i=null===(o=e.configuration)||void 0===o?void 0:o.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 _=a.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=n[4];return p.config||(p.config={}),(h=p.config).variable||(h.variable={}),p.config.variable.value=a.getVariableName(m),n}},"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,r,s,a)=>(a.forEach(e=>{"FlowGraphJsonPointerParserBlock"===e.className&&(e.config||(e.config={}),e.config.outputValue=!0)}),a)},"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,r,s,a)=>(a.forEach(e=>{"FlowGraphJsonPointerParserBlock"===e.className&&(e.config||(e.config={}),e.config.outputValue=!0)}),a)},"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,r,s,a)=>(a.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(r=>{var a;const n=null===(a=e.values)||void 0===a?void 0:a[r];if("value"===r&&n){const e=n.type;void 0!==e&&(t.config.animationType=s.arrays.types[e].flowGraphType)}}))}),a)},"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,r,s,a,n,o){const i=a[a.length-1];return i.config||(i.config={}),i.config.glTF=o,a}},"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,r,s,a,n,o){const i=a[a.length-1];return i.config||(i.config={}),i.config.glTF=o,a}},"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,r,s,a,n,o){const i=a[a.length-1];return i.config||(i.config={}),i.config.glTF=o,a}},"math/switch":{blocks:["FlowGraphDataSwitchBlock"],configuration:{cases:{name:"cases",isArray:!0,inOptions:!0,defaultValue:[]}},inputs:{values:{selection:{name:"case"}}},validation(e){var r;const s=null===(r=e.configuration)||void 0===r?void 0:r.cases;if(s&&s.value){if(!s.value.every(e=>"number"==typeof e&&/^-?\d+$/.test(e.toString())))return t.Logger.Warn("Switch cases should be integers. Using empty array instead."),s.value=[],{valid:!0};const e=new Set(s.value);s.value=Array.from(e)}return{valid:!0}},extraProcessor(e,t,r,s,a){const n=a[0];return n.dataInputs.forEach(e=>{"default"!==e.name&&"case"!==e.name&&(e.name="in_"+e.name)}),n.config||(n.config={}),n.config.treatCasesAsIntegers=!0,a}},"debug/log":{blocks:["FlowGraphConsoleLogBlock"],configuration:{message:{name:"messageTemplate",inOptions:!0}}}};function vs(e,t=["a"],r){return{blocks:[e],inputs:{values:t.reduce((e,t)=>(e[t]={name:t},e),{})},outputs:{values:{value:{name:"value"}}},extraProcessor(e,t,s,a,n){var o;if(r){(o=n[0]).config||(o.config={}),n[0].config.preventIntegerFloatArithmetic=!0;let t=-1;Object.keys(e.values||{}).find(r=>{var s;return void 0!==(null===(s=e.values)||void 0===s?void 0:s[r].type)&&(t=e.values[r].type,!0)}),-1!==t&&(n[0].config.type=a.arrays.types[t].flowGraphType)}return n},validation:e=>r?xs(e):{valid:!0}}}function xs(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 As(){return Object.keys(Ts)}const Cs={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 Rs{constructor(e,t,r=60){this._interactivityGraph=e,this._gltf=t,this._animationTargetFps=r,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(Cs[e.signature])}_parseDeclarations(){if(this._interactivityGraph.declarations)for(const e of this._interactivityGraph.declarations){const r=gs(e);if(!r)throw t.Logger.Error(["No mapping found for declaration",e]),new Error("Error parsing declarations");this._mappings.push({flowGraphMapping:r,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,r){const s=this._types[e.type];if(!s)throw t.Logger.Error(["No type found for variable",e]),new Error("Error parsing variables");if(e.value&&e.value.length!==s.length)throw t.Logger.Error(["Invalid value length for variable",e,s]),new Error("Error parsing variables");const a=e.value||[];if(!a.length)switch(s.flowGraphType){case"boolean":a.push(!1);break;case"FlowGraphInteger":a.push(0);break;case"number":a.push(NaN);break;case"Vector2":a.push(NaN,NaN);break;case"Vector3":a.push(NaN,NaN,NaN);break;case"Vector4":case"Matrix2D":case"Quaternion":a.fill(NaN,0,4);break;case"Matrix":a.fill(NaN,0,16);break;case"Matrix3D":a.fill(NaN,0,9)}return"number"===s.elementType&&"string"==typeof a[0]&&(a[0]=parseFloat(a[0])),{type:s.flowGraphType,value:r?r(a,this):a}}_parseEvents(){if(this._interactivityGraph.events)for(const e of this._interactivityGraph.events){const r={eventId:e.id||"internalEvent_"+this._internalEventsCounter++};e.values&&(r.eventData=Object.keys(e.values).map(r=>{var s;const a=null===(s=e.values)||void 0===s?void 0:s[r];if(!a)throw t.Logger.Error(["No value found for event key",r]),new Error("Error parsing events");const n=this._types[a.type];if(!n)throw t.Logger.Error(["No type found for event value",a]),new Error("Error parsing events");const o=void 0!==a.value?this._parseVariable(a):void 0;return{id:r,type:n.flowGraphType,eventData:!0,value:o}})),this._events.push(r)}}_parseNodes(){var e;if(this._interactivityGraph.nodes)for(const r of this._interactivityGraph.nodes){if("number"!=typeof r.declaration)throw t.Logger.Error(["No declaration found for node",r]),new Error("Error parsing nodes");const s=this._mappings[r.declaration];if(!s)throw t.Logger.Error(["No mapping found for node",r]),new Error("Error parsing nodes");if(s.flowGraphMapping.validation){const t=s.flowGraphMapping.validation(r,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[r.declaration].op} - ${t.error}`)}const a=[];for(const e of s.flowGraphMapping.blocks){const t=this._getEmptyBlock(e,s.fullOperationName);this._parseNodeConfiguration(r,t,s.flowGraphMapping,e),a.push(t)}this._nodes.push({blocks:a,fullOperationName:s.fullOperationName})}}_getEmptyBlock(e,r){return{uniqueId:t.RandomGUID(),className:e,dataInputs:[],dataOutputs:[],signalInputs:[],signalOutputs:[],config:{},type:r,metadata:{}}}_parseNodeConfiguration(e,r,s,a){var n;const o=e.configuration;if(o)for(const e in o){const i=o[e];if(!i)throw new Error("Error parsing node configuration");const l=null===(n=s.configuration)||void 0===n?void 0:n[e];if(l&&l.toBlock?l.toBlock===a:0===s.blocks.indexOf(a)){let s=null==l?void 0:l.defaultValue;(null==i?void 0:i.value)&&(s=i.value),(null==l?void 0:l.isArray)||(1!==s.length&&t.Logger.Warn(`Invalid non-array value length: ${s.length}`),s=s[0]),(null==l?void 0:l.dataTransformer)&&(s=l.dataTransformer(s,this)),void 0!==s&&(r.config[(null==l?void 0:l.name)||e]={value:s})}}}_parseNodeConnections(e){var r,s,a,n,o,i,l,u,c,h,d,m,_,p,f,g,b,y,T;for(let v=0;v<this._nodes.length;v++){const x=null===(r=this._interactivityGraph.nodes)||void 0===r?void 0:r[v];if(!x)throw t.Logger.Error(["No node found for interactivity node",this._nodes[v]]),new Error("Error parsing node connections");const A=this._nodes[v],C=this._mappings[x.declaration];if(!C)throw t.Logger.Error(["No mapping found for node",x]),new Error("Error parsing node connections");const R=x.flows||{},w=Object.keys(R).sort();for(const e of w){const r=R[e],c=null===(a=null===(s=C.flowGraphMapping.outputs)||void 0===s?void 0:s.flows)||void 0===a?void 0:a[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=r.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=fs(_.fullOperationName);if(!p)throw t.Logger.Error(["No mapping found for input node",_]),new Error("Error parsing node connections");let f=null===(o=null===(n=p.inputs)||void 0===n?void 0:n.flows)||void 0===o?void 0:o[r.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",r.socket||""):f.name:r.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 M=x.values||{},O=Object.keys(M);for(const r of O){const s=M[r];let a=null===(h=null===(c=C.flowGraphMapping.inputs)||void 0===c?void 0:c.values)||void 0===h?void 0:h[r],n=!1;if(!a)for(const e in null===(d=C.flowGraphMapping.inputs)||void 0===d?void 0:d.values)e.startsWith("[")&&e.endsWith("]")&&(n=!0,a=null===(_=null===(m=C.flowGraphMapping.inputs)||void 0===m?void 0:m.values)||void 0===_?void 0:_[e]);const o=a?n?a.name.replace("$1",r):a.name:r,i=this._createNewSocketConnection(o);if((a&&a.toBlock&&A.blocks.find(e=>e.className===a.toBlock)||A.blocks[0]).dataInputs.push(i),void 0!==s.value){const t=this._parseVariable(s,a&&a.dataTransformer);e._connectionValues[i.uniqueId]=t}else{if(void 0===s.node)throw t.Logger.Error(["Invalid value for value connection",s]),new Error("Error parsing node connections");{const e=s.node,r=s.socket||"value",a=this._nodes[e];if(!a)throw t.Logger.Error(["No node found for output socket reference",s]),new Error("Error parsing node connections");const n=fs(a.fullOperationName);if(!n)throw t.Logger.Error(["No mapping found for output socket reference",s]),new Error("Error parsing node connections");let o=null===(f=null===(p=n.outputs)||void 0===p?void 0:p.values)||void 0===f?void 0:f[r],l=!1;if(!o)for(const e in null===(g=n.outputs)||void 0===g?void 0:g.values)e.startsWith("[")&&e.endsWith("]")&&(l=!0,o=null===(y=null===(b=n.outputs)||void 0===b?void 0:b.values)||void 0===y?void 0:y[e]);const u=o?l?o.name.replace("$1",r):null==o?void 0:o.name:r,c=o&&o.toBlock&&a.blocks.find(e=>e.className===o.toBlock)||a.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,r=e.output,s=e.isVariable;this._connectFlowGraphNodes(t,r,A.blocks[e.inputBlockIndex],A.blocks[e.outputBlockIndex],s)}if(C.flowGraphMapping.extraProcessor){const r=null===(T=this._interactivityGraph.declarations)||void 0===T?void 0:T[x.declaration];if(!r)throw t.Logger.Error(["No declaration found for extra processor",x]),new Error("Error parsing node connections");A.blocks=C.flowGraphMapping.extraProcessor(x,r,C.flowGraphMapping,this,A.blocks,e,this._gltf)}}}_createNewSocketConnection(e,r){return{uniqueId:t.RandomGUID(),name:e,_connectionType:r?1:0,connectedPointIds:[]}}_connectFlowGraphNodes(e,t,r,s,a){const n=a?r.dataInputs:r.signalInputs,o=a?s.dataOutputs:s.signalOutputs,i=n.find(t=>t.name===e)||this._createNewSocketConnection(e),l=o.find(e=>e.name===t)||this._createNewSocketConnection(t,!0);n.find(t=>t.name===e)||n.push(i),o.find(e=>e.name===t)||o.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 r=this._staticVariables[t];e._userVariables[this.getVariableName(t)]=r}return{rightHanded:!0,allBlocks:this._nodes.reduce((e,t)=>e.concat(t.blocks),[]),executionContexts:[e]}}}const ws="KHR_interactivity";class Ms{constructor(e){this._loader=e,this.name=ws,this.enabled=this._loader.isExtensionUsed(ws),this._pathConverter=O(this._loader.gltf),e._skipStartAnimationStep=!0;const t=e.babylonScene;t&&Os(t)}dispose(){this._loader=null,delete this._pathConverter}onReady(){return S(this,void 0,void 0,function*(){var e;if(!this._loader.babylonScene||!this._pathConverter)return;const r=this._loader.babylonScene,s=null===(e=this._loader.gltf.extensions)||void 0===e?void 0:e.KHR_interactivity;if(!s)return;const a=new t.FlowGraphCoordinator({scene:r});a.dispatchEventsSynchronously=!1;const n=s.graphs.map(e=>new Rs(e,this._loader.gltf,this._loader.parent.targetFps).serializeToFlowGraph());yield Promise.all(n.map(e=>S(this,void 0,void 0,function*(){return yield t.ParseFlowGraphAsync(e,{coordinator:a,pathConverter:this._pathConverter})}))),a.start()})}}function Os(e){E("/extensions/KHR_interactivity/?/activeCamera/rotation",{get:()=>{if(!e.activeCamera)return new t.Quaternion(NaN,NaN,NaN,NaN);const r=t.Quaternion.FromRotationMatrix(e.activeCamera.getWorldMatrix()).normalize();return e.useRightHandedSystem||(r.w*=-1,r.x*=-1),r},type:"Quaternion",getTarget:()=>e.activeCamera}),E("/extensions/KHR_interactivity/?/activeCamera/position",{get:()=>{if(!e.activeCamera)return new t.Vector3(NaN,NaN,NaN);const r=e.activeCamera.getWorldMatrix().getTranslation();return e.useRightHandedSystem||(r.x*=-1),r},type:"Vector3",getTarget:()=>e.activeCamera}),E("/animations/{}/extensions/KHR_interactivity/isPlaying",{get:e=>{var t,r;return null!==(r=null===(t=e._babylonAnimationGroup)||void 0===t?void 0:t.isPlaying)&&void 0!==r&&r},type:"boolean",getTarget:e=>e._babylonAnimationGroup}),E("/animations/{}/extensions/KHR_interactivity/minTime",{get:e=>{var t,r;return(null!==(r=null===(t=e._babylonAnimationGroup)||void 0===t?void 0:t.from)&&void 0!==r?r:0)/60},type:"number",getTarget:e=>e._babylonAnimationGroup}),E("/animations/{}/extensions/KHR_interactivity/maxTime",{get:e=>{var t,r;return(null!==(r=null===(t=e._babylonAnimationGroup)||void 0===t?void 0:t.to)&&void 0!==r?r:0)/60},type:"number",getTarget:e=>e._babylonAnimationGroup}),E("/animations/{}/extensions/KHR_interactivity/playhead",{get:e=>{var t,r;return(null!==(r=null===(t=e._babylonAnimationGroup)||void 0===t?void 0:t.getCurrentFrame())&&void 0!==r?r:0)/60},type:"number",getTarget:e=>e._babylonAnimationGroup}),E("/animations/{}/extensions/KHR_interactivity/virtualPlayhead",{get:e=>{var t,r;return(null!==(r=null===(t=e._babylonAnimationGroup)||void 0===t?void 0:t.getCurrentFrame())&&void 0!==r?r:0)/60},type:"number",getTarget:e=>e._babylonAnimationGroup})}let Ls=!1;function Fs(){Ls||(Ls=!0,t.addToBlockFactory(ws,"FlowGraphGLTFDataProvider",()=>S(this,void 0,void 0,function*(){return(yield Promise.resolve().then(function(){return Xs})).FlowGraphGLTFDataProvider})),B(ws),P(ws,!0,e=>new Ms(e)))}Fs();const Es="KHR_node_visibility";class Ss{constructor(e){this.name=Es,this._loader=e,this.enabled=e.isExtensionUsed(Es)}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 ks=!1;function Is(){ks||(ks=!0,E("/nodes/{}/extensions/KHR_node_visibility/visible",{get:e=>{const t=e._babylonTransformNode;return!t||void 0===t.isVisible||t.isVisible},set:(e,t)=>{var r,s;null===(r=t._primitiveBabylonMeshes)||void 0===r||r.forEach(e=>{e.inheritVisibility=!0}),t._babylonTransformNode&&(t._babylonTransformNode.isVisible=e),null===(s=t._primitiveBabylonMeshes)||void 0===s||s.forEach(t=>{t.isVisible=e})},getTarget:e=>e._babylonTransformNode,getPropertyName:[()=>"isVisible"],type:"boolean"}),B(Es),P(Es,!0,e=>new Ss(e)))}Is();const Ps="KHR_node_selectability";class Bs{constructor(e){this.name=Ps,this._loader=e,this.enabled=e.isExtensionUsed(Ps)}onReady(){return S(this,void 0,void 0,function*(){var e;null===(e=this._loader.gltf.nodes)||void 0===e||e.forEach(e=>{var t,r,s;(null===(t=e.extensions)||void 0===t?void 0:t.KHR_node_selectability)&&!1===(null===(r=e.extensions)||void 0===r?void 0:r.KHR_node_selectability.selectable)&&(null===(s=e._babylonTransformNode)||void 0===s||s.getChildMeshes().forEach(e=>{e.isPickable=!1}))})})}dispose(){this._loader=null}}let Ns=!1;function Gs(){Ns||(Ns=!0,bs("event/onSelect",Ps,{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,r,s,a,n,o){var i,l,u,c,h,d,m;const _=a[a.length-1];_.config=_.config||{},_.config.glTF=o;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 a[1].config.variable=f,n._userVariables[f]={className:"Mesh",id:null===(h=null===(c=null==o?void 0:o.nodes)||void 0===c?void 0:c[p]._babylonTransformNode)||void 0===h?void 0:h.id,uniqueId:null===(m=null===(d=null==o?void 0:o.nodes)||void 0===d?void 0:d[p]._babylonTransformNode)||void 0===m?void 0:m.uniqueId},a}}),E("/nodes/{}/extensions/KHR_node_selectability/selectable",{get:e=>{const t=e._babylonTransformNode;return!t||void 0===t.isPickable||t.isPickable},set:(e,t)=>{var r;null===(r=t._primitiveBabylonMeshes)||void 0===r||r.forEach(t=>{t.isPickable=e})},getTarget:e=>e._babylonTransformNode,getPropertyName:[()=>"isPickable"],type:"boolean"}),B(Ps),P(Ps,!0,e=>new Bs(e)))}Gs();const Ds="KHR_node_hoverability",Vs="targetMeshPointerOver_",$s="targetMeshPointerOut_";class Hs{constructor(e){this.name=Ds,this._loader=e,this.enabled=e.isExtensionUsed(Ds)}onReady(){return S(this,void 0,void 0,function*(){var e;null===(e=this._loader.gltf.nodes)||void 0===e||e.forEach(e=>{var t,r,s;(null===(t=e.extensions)||void 0===t?void 0:t.KHR_node_hoverability)&&!1===(null===(r=e.extensions)||void 0===r?void 0:r.KHR_node_hoverability.hoverable)&&(null===(s=e._babylonTransformNode)||void 0===s||s.getChildMeshes().forEach(e=>{e.pointerOverDisableMeshTesting=!0}))})})}dispose(){this._loader=null}}let Ks=!1;function Ws(){Ks||(Ks=!0,bs("event/onHoverIn",Ds,{blocks:["FlowGraphPointerOverEventBlock","FlowGraphGetVariableBlock","FlowGraphIndexOfBlock","KHR_interactivity/FlowGraphGLTFDataProvider"],configuration:{stopPropagation:{name:"stopPropagation"},nodeIndex:{name:"variable",toBlock:"FlowGraphGetVariableBlock",dataTransformer:e=>Vs+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,r,s,a,n,o){var i,l,u,c,h,d,m;const _=a[a.length-1];_.config=_.config||{},_.config.glTF=o;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=Vs+p;return a[1].config.variable=f,n._userVariables[f]={className:"Mesh",id:null===(h=null===(c=null==o?void 0:o.nodes)||void 0===c?void 0:c[p]._babylonTransformNode)||void 0===h?void 0:h.id,uniqueId:null===(m=null===(d=null==o?void 0:o.nodes)||void 0===d?void 0:d[p]._babylonTransformNode)||void 0===m?void 0:m.uniqueId},a}}),bs("event/onHoverOut",Ds,{blocks:["FlowGraphPointerOutEventBlock","FlowGraphGetVariableBlock","FlowGraphIndexOfBlock","KHR_interactivity/FlowGraphGLTFDataProvider"],configuration:{stopPropagation:{name:"stopPropagation"},nodeIndex:{name:"variable",toBlock:"FlowGraphGetVariableBlock",dataTransformer:e=>$s+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,r,s,a,n,o){var i,l,u,c,h,d,m;const _=a[a.length-1];_.config=_.config||{},_.config.glTF=o;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=$s+p;return a[1].config.variable=f,n._userVariables[f]={className:"Mesh",id:null===(h=null===(c=null==o?void 0:o.nodes)||void 0===c?void 0:c[p]._babylonTransformNode)||void 0===h?void 0:h.id,uniqueId:null===(m=null===(d=null==o?void 0:o.nodes)||void 0===d?void 0:d[p]._babylonTransformNode)||void 0===m?void 0:m.uniqueId},a}}),E("/nodes/{}/extensions/KHR_node_hoverability/hoverable",{get:e=>{const t=e._babylonTransformNode;return!t||void 0===t.pointerOverDisableMeshTesting||t.pointerOverDisableMeshTesting},set:(e,t)=>{var r;null===(r=t._primitiveBabylonMeshes)||void 0===r||r.forEach(t=>{t.pointerOverDisableMeshTesting=!e})},getTarget:e=>e._babylonTransformNode,getPropertyName:[()=>"pointerOverDisableMeshTesting"],type:"boolean"}),B(Ds),P(Ds,!0,e=>new Hs(e)))}Ws();const Us="ExtrasAsMetadata";class zs{_assignExtras(e,t){if(t.extras&&Object.keys(t.extras).length>0){const r=e.metadata=e.metadata||{};(r.gltf=r.gltf||{}).extras=t.extras}}constructor(e){this.name=Us,this.enabled=!0,this._loader=e}dispose(){this._loader=null}loadNodeAsync(e,t,r){return this._loader.loadNodeAsync(e,t,e=>{this._assignExtras(e,t),r(e)})}loadCameraAsync(e,t,r){return this._loader.loadCameraAsync(e,t,e=>{this._assignExtras(e,t),r(e)})}createMaterial(e,t,r){const s=this._loader.createMaterial(e,t,r);return this._assignExtras(s,t),s}loadAnimationAsync(e,t){return this._loader.loadAnimationAsync(e,t).then(e=>(this._assignExtras(e,t),e))}}let qs=!1;function js(){qs||(qs=!0,B(Us),P(Us,!1,e=>new zs(e)))}js();class Ys extends t.FlowGraphBlock{constructor(e){var r,s;super(e);const a=e.glTF,n=(null===(r=null==a?void 0:a.animations)||void 0===r?void 0:r.map(e=>e._babylonAnimationGroup))||[];this.animationGroups=this.registerDataOutput("animationGroups",t.RichTypeAny,n);const o=(null===(s=null==a?void 0:a.nodes)||void 0===s?void 0:s.map(e=>e._babylonTransformNode))||[];this.nodes=this.registerDataOutput("nodes",t.RichTypeAny,o)}getClassName(){return"FlowGraphGLTFDataProvider"}}var Xs={__proto__:null,FlowGraphGLTFDataProvider:Ys},Qs={__proto__:null,AddObjectAccessorToKey:E,EXT_lights_area:Fe,EXT_lights_ies:he,EXT_lights_image_based:U,EXT_mesh_gpu_instancing:Y,EXT_meshopt_compression:Z,EXT_texture_avif:ie,EXT_texture_webp:se,ExtrasAsMetadata:zs,FlowGraphGLTFDataProvider:Ys,GetMappingForKey:L,GetPathToObjectConverter:O,InteractivityGraphToFlowGraphParser:Rs,KHR_animation_pointer:fr,KHR_draco_mesh_compression:pe,KHR_gaussian_splatting:xe,KHR_interactivity:Ms,KHR_lights:we,KHR_materials_anisotropy:et,KHR_materials_clearcoat:He,KHR_materials_coat:ze,KHR_materials_diffuse_roughness:Xt,KHR_materials_diffuse_transmission:It,KHR_materials_dispersion:zt,KHR_materials_emissive_strength:at,KHR_materials_fuzz:dt,KHR_materials_ior:Tt,KHR_materials_iridescence:Xe,KHR_materials_pbrSpecularGlossiness:Ie,KHR_materials_sheen:lt,KHR_materials_specular:ft,KHR_materials_transmission:Ft,KHR_materials_unlit:Ge,KHR_materials_variants:Ct,KHR_materials_volume:Gt,KHR_materials_volume_scatter:Ht,KHR_mesh_quantization:er,KHR_node_hoverability:Hs,KHR_node_selectability:Bs,KHR_node_visibility:Ss,KHR_texture_basisu:ar,KHR_texture_transform:lr,KHR_xmp_json_ld:dr,MSFT_audio_emitter:ts,MSFT_lod:ns,MSFT_minecraftMesh:us,MSFT_sRGBFactors:ms,RegisterEXT_lights_area:Se,RegisterEXT_lights_ies:me,RegisterEXT_lights_image_based:q,RegisterEXT_mesh_gpu_instancing:Q,RegisterEXT_meshopt_compression:te,RegisterEXT_texture_avif:ue,RegisterEXT_texture_webp:ne,RegisterExtrasAsMetadata:js,RegisterKHR_animation_pointer:br,RegisterKHR_draco_mesh_compression:ge,RegisterKHR_gaussian_splatting:Ce,RegisterKHR_interactivity:Fs,RegisterKHR_lights:Oe,RegisterKHR_materials_anisotropy:rt,RegisterKHR_materials_clearcoat:We,RegisterKHR_materials_coat:je,RegisterKHR_materials_diffuse_roughness:Jt,RegisterKHR_materials_diffuse_transmission:Bt,RegisterKHR_materials_dispersion:jt,RegisterKHR_materials_emissive_strength:ot,RegisterKHR_materials_fuzz:_t,RegisterKHR_materials_ior:xt,RegisterKHR_materials_iridescence:Je,RegisterKHR_materials_pbrSpecularGlossiness:Be,RegisterKHR_materials_sheen:ct,RegisterKHR_materials_specular:bt,RegisterKHR_materials_transmission:St,RegisterKHR_materials_unlit:Ve,RegisterKHR_materials_variants:wt,RegisterKHR_materials_volume:Vt,RegisterKHR_materials_volume_scatter:Wt,RegisterKHR_mesh_quantization:rr,RegisterKHR_node_hoverability:Ws,RegisterKHR_node_selectability:Gs,RegisterKHR_node_visibility:Is,RegisterKHR_texture_basisu:or,RegisterKHR_texture_transform:cr,RegisterKHR_xmp_json_ld:_r,RegisterMSFT_audio_emitter:ss,RegisterMSFT_lod:is,RegisterMSFT_minecraftMesh:hs,RegisterMSFT_sRGBFactors:ps,SetInterpolationForKey:F,TransmissionHelper:Mt,_AddInteractivityObjectModel:Os,addNewInteractivityFlowGraphMapping:bs,ensureTransmissionHelper:Ot,getAllSupportedNativeNodeTypes:As,getMappingForDeclaration:gs,getMappingForFullOperationName:fs,gltfTypeToBabylonType:Cs};K();class Js{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 S(this,void 0,void 0,function*(){var r,s,a;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 n=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===(r=n.texture)||void 0===r||r.dispose());this.specularRoughnessTexture=n.texture,this.specularRoughness=n.factor?n.factor.r:1;const o=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===(s=o.texture)||void 0===s||s.dispose());this.baseMetalnessTexture=o.texture,this.baseMetalness=o.factor?o.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({},o),{dispose:void 0,colorSpace:t.TextureColorSpace.Linear}),this._material.getScene(),t.TextureColorSpace.SRGB,t.ChannelMask.RGB);if(e._disposed)return void(null===(a=i.texture)||void 0===a||a.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,r,s,a,n,o){return S(this,arguments,void 0,function*(e,r,s,a,n,o,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,v=this._material.geometryCoatNormalTexture,x=new t.Color4(g,g,g,g),A=new t.Color4(r,r,r,r);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,x,t.TextureChannel.R),this._material.getScene(),t.TextureColorSpace.SRGB),t.LerpTexturesAsync("lerpSurfaceColor",t.CreateTextureWithFactorOperand(null,new t.Color4(1,1,1,1)),t.CreateTextureWithFactorOperand(o,n.toColor4(),t.TextureChannel.RGBA,t.TextureColorSpace.SRGB),t.CreateTextureWithFactorOperand(s,A,a),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[w,M]=C.map(e=>e.value);if(e._disposed)return null===(u=w.texture)||void 0===u||u.dispose(),void(null===(c=M.texture)||void 0===c||c.dispose());const O=yield t.MultiplyTexturesAsync("newCoatColor ("+this._material.name+")",w,M,this._material.getScene(),t.TextureColorSpace.SRGB);if(e._disposed)return void(null===(h=O.texture)||void 0===h||h.dispose());O.texture?(this.coatColorTexture=O.texture,this.coatColor=t.Color3.White()):O.factor&&(this.coatColorTexture=null,this.coatColor.fromArray([O.factor.r,O.factor.g,O.factor.b]));const L=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,x,t.TextureChannel.R),this._material.getScene());if(e._disposed)return void(null===(d=L.texture)||void 0===d||d.dispose());this.coatIor=L.factor?L.factor.r:this.coatIor;const F=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,x,t.TextureChannel.R),this._material.getScene());if(e._disposed)return void(null===(m=F.texture)||void 0===m||m.dispose());this.coatRoughness=F.factor?F.factor.r:1,this.coatRoughnessTexture=F.texture;const E=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,x,t.TextureChannel.R),this._material.getScene());if(e._disposed)null===(_=E.texture)||void 0===_||_.dispose();else{if(this.coatDarkening=E.factor?E.factor.r:this.coatDarkening,i){const r=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(s,A,a),this._material.getScene());if(e._disposed)return void(null===(p=r.texture)||void 0===p||p.dispose());this.specularRoughness=r.factor?r.factor.r:1,this.specularRoughnessTexture=r.texture}if(v||this.geometryNormalTexture){const r=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(v,v?new t.Color4(1,1,1,1):new t.Color4(.5,.5,1,1),t.TextureChannel.RGBA),t.CreateTextureWithFactorOperand(b,x,t.TextureChannel.R),this._material.getScene());if(e._disposed)return void(null===(f=r.texture)||void 0===f||f.dispose());r.texture&&(this.geometryCoatNormalTexture=r.texture)}}})}}var Zs={__proto__:null,OpenPBRMaterialLoadingAdapter:Js};class ea{constructor(e){this._specWorkflow=!1,this._material=e,this._material.enableSpecularAntiAliasing=!0}get material(){return this._material}finalizeAsync(e){return S(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 r=new t.Vector3(-Math.log(this.transmissionColor.r),-Math.log(this.transmissionColor.g),-Math.log(this.transmissionColor.b));r.scaleInPlace(1/Math.max(this.transmissionDepth,.001));const s=r,a=Math.max(s.x,Math.max(s.y,s.z)),n=a>0?1/a:1;this._material.subSurface.diffusionDistance=new t.Color3(Math.exp(-s.x*n),Math.exp(-s.y*n),Math.exp(-s.z*n))}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 ta={__proto__:null,PBRMaterialLoadingAdapter:ea},ra={__proto__:null,AddObjectAccessorToKey:E,AnimationPropertyInfo:xr,ArrayItem:D,EXT_lights_area:Fe,EXT_lights_ies:he,EXT_lights_image_based:U,EXT_mesh_gpu_instancing:Y,EXT_meshopt_compression:Z,EXT_texture_avif:ie,EXT_texture_webp:se,ExtrasAsMetadata:zs,FlowGraphGLTFDataProvider:Ys,GLTFFileLoader:g,GLTFLoader:$,GetMappingForKey:L,GetPathToObjectConverter:O,InteractivityGraphToFlowGraphParser:Rs,KHR_animation_pointer:fr,KHR_draco_mesh_compression:pe,KHR_gaussian_splatting:xe,KHR_interactivity:Ms,KHR_lights:we,KHR_materials_anisotropy:et,KHR_materials_clearcoat:He,KHR_materials_coat:ze,KHR_materials_diffuse_roughness:Xt,KHR_materials_diffuse_transmission:It,KHR_materials_dispersion:zt,KHR_materials_emissive_strength:at,KHR_materials_fuzz:dt,KHR_materials_ior:Tt,KHR_materials_iridescence:Xe,KHR_materials_pbrSpecularGlossiness:Ie,KHR_materials_sheen:lt,KHR_materials_specular:ft,KHR_materials_transmission:Ft,KHR_materials_unlit:Ge,KHR_materials_variants:Ct,KHR_materials_volume:Gt,KHR_materials_volume_scatter:Ht,KHR_mesh_quantization:er,KHR_node_hoverability:Hs,KHR_node_selectability:Bs,KHR_node_visibility:Ss,KHR_texture_basisu:ar,KHR_texture_transform:lr,KHR_xmp_json_ld:dr,LoadBoundingInfoFromPositionAccessor:V,MSFT_audio_emitter:ts,MSFT_lod:ns,MSFT_minecraftMesh:us,MSFT_sRGBFactors:ms,OpenPBRMaterialLoadingAdapter:Js,PBRMaterialLoadingAdapter:ea,RegisterEXT_lights_area:Se,RegisterEXT_lights_ies:me,RegisterEXT_lights_image_based:q,RegisterEXT_mesh_gpu_instancing:Q,RegisterEXT_meshopt_compression:te,RegisterEXT_texture_avif:ue,RegisterEXT_texture_webp:ne,RegisterExtrasAsMetadata:js,RegisterGLTF2Loader:K,RegisterKHR_animation_pointer:br,RegisterKHR_draco_mesh_compression:ge,RegisterKHR_gaussian_splatting:Ce,RegisterKHR_interactivity:Fs,RegisterKHR_lights:Oe,RegisterKHR_materials_anisotropy:rt,RegisterKHR_materials_clearcoat:We,RegisterKHR_materials_coat:je,RegisterKHR_materials_diffuse_roughness:Jt,RegisterKHR_materials_diffuse_transmission:Bt,RegisterKHR_materials_dispersion:jt,RegisterKHR_materials_emissive_strength:ot,RegisterKHR_materials_fuzz:_t,RegisterKHR_materials_ior:xt,RegisterKHR_materials_iridescence:Je,RegisterKHR_materials_pbrSpecularGlossiness:Be,RegisterKHR_materials_sheen:ct,RegisterKHR_materials_specular:bt,RegisterKHR_materials_transmission:St,RegisterKHR_materials_unlit:Ve,RegisterKHR_materials_variants:wt,RegisterKHR_materials_volume:Vt,RegisterKHR_materials_volume_scatter:Wt,RegisterKHR_mesh_quantization:rr,RegisterKHR_node_hoverability:Ws,RegisterKHR_node_selectability:Gs,RegisterKHR_node_visibility:Is,RegisterKHR_texture_basisu:or,RegisterKHR_texture_transform:cr,RegisterKHR_xmp_json_ld:_r,RegisterMSFT_audio_emitter:ss,RegisterMSFT_lod:is,RegisterMSFT_minecraftMesh:hs,RegisterMSFT_sRGBFactors:ps,SetInterpolationForKey:F,TransformNodeAnimationPropertyInfo:Ar,TransmissionHelper:Mt,WeightAnimationPropertyInfo:Cr,_AddInteractivityObjectModel:Os,addNewInteractivityFlowGraphMapping:bs,ensureTransmissionHelper:Ot,getAllSupportedNativeNodeTypes:As,getMappingForDeclaration:gs,getMappingForFullOperationName:fs,getQuaternion:Tr,getVector3:yr,getWeights:vr,gltfTypeToBabylonType:Cs,registerGLTFExtension:P,registeredGLTFExtensions:I,unregisterGLTFExtension:B};const sa=Object.assign({},Qs),aa=Object.assign(Object.assign({},{__proto__:null}),{Extensions:sa}),na=Object.assign(Object.assign({},ra),{Loader:aa}),oa="undefined"!=typeof global?global:"undefined"!=typeof window?window:void 0;if(void 0!==oa){oa.BABYLON=oa.BABYLON||{};const e=oa.BABYLON;e.GLTF2=e.GLTF2||{},e.GLTF2.Loader=e.GLTF2.Loader||{},e.GLTF2.Loader.Extensions=e.GLTF2.Loader.Extensions||{};const t=["Loader"];for(const r in sa)e.GLTF2.Loader.Extensions[r]=sa[r],t.push(r);for(const r in aa)"Extensions"!==r&&(e.GLTF2.Loader[r]=aa[r],t.push(r));for(const r in na)t.indexOf(r)>-1||(e.GLTF2[r]=na[r])}e.GLTF2=na,e.GLTFFileLoader=g,e.GLTFLoaderDefaultOptions=p,e.GLTFValidation=a,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 r(e,t,r,s){const a={externalResourceFunction:s};return r&&(a.uri="file:"===t?r:t+r),ArrayBuffer.isView(e)?GLTFValidator.validateBytes(e,a):GLTFValidator.validateString(e,a)}function s(){const e=[];onmessage=t=>{const s=t.data;switch(s.id){case"init":importScripts(s.url);break;case"validate":r(s.data,s.rootUrl,s.fileName,t=>new Promise((r,s)=>{const a=e.length;e.push({resolve:r,reject:s}),postMessage({id:"getExternalResource",index:a,uri:t})})).then(e=>{postMessage({id:"validate.resolve",value:e})},e=>{postMessage({id:"validate.reject",reason:e})});break;case"getExternalResource.resolve":e[s.index].resolve(s.value);break;case"getExternalResource.reject":e[s.index].reject(s.reason)}}}class a{static ValidateAsync(e,n,o,i){return"function"==typeof Worker?new Promise((l,u)=>{const c=`${r}(${s})()`,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",_),a._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:n,fileName:o},[t.buffer])}else d.postMessage({id:"validate",data:e,rootUrl:n,fileName:o})}):(this._LoadScriptPromise||(this._LoadScriptPromise=t.Tools.LoadBabylonScriptAsync(this.Configuration.url)),this._LoadScriptPromise.then(()=>r(e,n,o,i)))}}a.Configuration={url:`${t.Tools._DefaultCdnUrl}/gltf_validator.js`},a._LastResults=null;var n={__proto__:null,GLTFValidation:a};const o="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,"+o)||e.startsWith("data:;base64,"+o)||e.startsWith("data:application/octet-stream;base64,"+o)||e.startsWith("data:model/gltf-binary;base64,"+o);function c(e,t,r){try{return Promise.resolve(new Uint8Array(e,t,r))}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,r,s,a,n,o,i,l,u,c,h,d,m,_,p,f,g,b,y,T,v,x,A,C,R,w,M;e&&(this.alwaysComputeBoundingBox=null!==(t=e.alwaysComputeBoundingBox)&&void 0!==t?t:this.alwaysComputeBoundingBox,this.alwaysComputeSkeletonRootNode=null!==(r=e.alwaysComputeSkeletonRootNode)&&void 0!==r?r:this.alwaysComputeSkeletonRootNode,this.animationStartMode=null!==(s=e.animationStartMode)&&void 0!==s?s:this.animationStartMode,this.capturePerformanceCounters=null!==(a=e.capturePerformanceCounters)&&void 0!==a?a:this.capturePerformanceCounters,this.compileMaterials=null!==(n=e.compileMaterials)&&void 0!==n?n:this.compileMaterials,this.compileShadowGenerators=null!==(o=e.compileShadowGenerators)&&void 0!==o?o: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!==(v=e.useGltfTextureNames)&&void 0!==v?v:this.useGltfTextureNames,this.useMaxMorphTargetInfluencers=null!==(x=e.useMaxMorphTargetInfluencers)&&void 0!==x?x: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!==(w=e.validate)&&void 0!==w?w:this.validate,this.dontUseTransmissionHelper=null!==(M=e.dontUseTransmissionHelper)&&void 0!==M?M: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,r,s,a,n,o,i,l){if(ArrayBuffer.isView(r))return this._loadBinary(e,r,s,a,i,l),null;this._progressCallback=n;const u=r.name||t.Tools.GetFilename(r);if(o){if(this.useRangeRequests){this.validate&&t.Logger.Warn("glTF validation is not supported when range requests are enabled");const s={abort:()=>{},onCompleteObservable:new t.Observable},n={readAsync:(t,s)=>new Promise((a,n)=>{this._loadFile(e,r,e=>{a(new Uint8Array(e))},!0,e=>{n(e)},e=>{e.setRequestHeader("Range",`bytes=${t}-${t+s-1}`)})}),byteLength:0};return this._unpackBinaryAsync(new t.DataReader(n)).then(e=>{s.onCompleteObservable.notifyObservers(s),a(e)},i?e=>i(void 0,e):void 0),s}return this._loadFile(e,r,r=>{this._validate(e,new Uint8Array(r,0,r.byteLength),s,u),this._unpackBinaryAsync(new t.DataReader({readAsync:(e,t)=>c(r,e,t),byteLength:r.byteLength})).then(e=>{a(e)},i?e=>i(void 0,e):void 0)},!0,i)}return this._loadFile(e,r,t=>{try{this._validate(e,t,s,u),a({json:this._parseJson(t)})}catch(e){i&&i()}},!1,i)}_loadBinary(e,r,s,a,n,o){this._validate(e,new Uint8Array(r.buffer,r.byteOffset,r.byteLength),s,o),this._unpackBinaryAsync(new t.DataReader({readAsync:(e,t)=>function(e,t,r){try{if(t<0||t>=e.byteLength)throw new RangeError("Offset is out of range.");if(t+r>e.byteLength)throw new RangeError("Length is out of range.");return Promise.resolve(new Uint8Array(e.buffer,e.byteOffset+t,r))}catch(e){return Promise.reject(e)}}(r,e,t),byteLength:r.byteLength})).then(e=>{a(e)},n?e=>n(void 0,e):void 0)}importMeshAsync(e,t,r,s,a,n){return Promise.resolve().then(()=>(this.onParsedObservable.notifyObservers(r),this.onParsedObservable.clear(),this._log(`Loading ${n||""}`),this._loader=this._getLoader(r),this._loader.importMeshAsync(e,t,null,r,s,a,n)))}loadAsync(e,t,r,s,a){return Promise.resolve().then(()=>(this.onParsedObservable.notifyObservers(t),this.onParsedObservable.clear(),this._log(`Loading ${a||""}`),this._loader=this._getLoader(t),this._loader.loadAsync(e,t,r,s,a)))}loadAssetContainerAsync(e,r,s,a,n){return Promise.resolve().then(()=>{this.onParsedObservable.notifyObservers(r),this.onParsedObservable.clear(),this._log(`Loading ${n||""}`),this._loader=this._getLoader(r);const o=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,o,r,s,a,n).then(e=>(Array.prototype.push.apply(o.geometries,e.geometries),Array.prototype.push.apply(o.meshes,e.meshes),Array.prototype.push.apply(o.particleSystems,e.particleSystems),Array.prototype.push.apply(o.skeletons,e.skeletons),Array.prototype.push.apply(o.animationGroups,e.animationGroups),Array.prototype.push.apply(o.materials,i),Array.prototype.push.apply(o.textures,l),Array.prototype.push.apply(o.lights,e.lights),Array.prototype.push.apply(o.transformNodes,e.transformNodes),Array.prototype.push.apply(o.cameras,u),Array.prototype.push.apply(o.morphTargetManagers,c),o))})}canDirectLoad(e){return u(e)}directLoad(e,r){if(r.startsWith("base64,"+o)||r.startsWith(";base64,"+o)||r.startsWith("application/octet-stream;base64,"+o)||r.startsWith("model/gltf-binary;base64,"+o)){const s=t.DecodeBase64UrlToBinary(r);return this._validate(e,new Uint8Array(s,0,s.byteLength)),this._unpackBinaryAsync(new t.DataReader({readAsync:(e,t)=>c(s,e,t),byteLength:s.byteLength}))}return this._validate(e,r),Promise.resolve({json:this._parseJson(r)})}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,r,s,a,n){const o=e._loadFile(t,r,e=>{this._onProgress(e,o)},!0,s,a,n);return o.onCompleteObservable.add(()=>{o._lengthComputable=!0,o._total=o._loaded}),this._requests.push(o),o}_onProgress(e,t){if(!this._progressCallback)return;t._lengthComputable=e.lengthComputable,t._loaded=e.loaded,t._total=e.total;let r=!0,s=0,a=0;for(const e of this._requests){if(void 0===e._lengthComputable||void 0===e._loaded||void 0===e._total)return;r=r&&e._lengthComputable,s+=e._loaded,a+=e._total}this._progressCallback({lengthComputable:r,loaded:s,total:r?a:0})}_validate(e,r,s="",n=""){this.validate&&(this._startPerformanceCounter("Validate JSON"),a.ValidateAsync(r,s,n,t=>this.preprocessUrlAsync(s+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 r=g._parseVersion(t.version);if(!r)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 s={1:g._CreateGLTF1Loader,2:g._CreateGLTF2Loader}[r.major];if(!s)throw new Error("Unsupported version: "+t.version);return s(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 r=e.readUint32();if(1179937895!==r)throw new t.RuntimeError("Unexpected magic: "+r,t.ErrorCodes.GLTFLoaderUnexpectedMagicError);const s=e.readUint32();this.loggingEnabled&&this._log(`Binary version: ${s}`);const a=e.readUint32();let n;switch(this.useRangeRequests||a===e.buffer.byteLength||t.Logger.Warn(`Length in header does not match actual data length: ${a} != ${e.buffer.byteLength}`),s){case 1:n=this._unpackBinaryV1Async(e,a);break;case 2:n=this._unpackBinaryV2Async(e,a);break;default:throw new Error("Unsupported version: "+s)}return this._endPerformanceCounter("Unpack Binary"),n})}_unpackBinaryV1Async(e,t){const r=e.readUint32(),s=e.readUint32();if(0!==s)throw new Error(`Unexpected content format: ${s}`);const a=t-e.byteOffset,n={json:this._parseJson(e.readString(r)),bin:null};if(0!==a){const t=e.byteOffset;n.bin={readAsync:(r,s)=>e.buffer.readAsync(t+r,s),byteLength:a}}return Promise.resolve(n)}_unpackBinaryV2Async(e,t){const r=1313821514,s=e.readUint32();if(e.readUint32()!==r)throw new Error("First chunk format is not JSON");return e.byteOffset+s===t?e.loadAsync(s).then(()=>({json:this._parseJson(e.readString(s)),bin:null})):e.loadAsync(s+8).then(()=>{const a={json:this._parseJson(e.readString(s)),bin:null},n=()=>{const s=e.readUint32();switch(e.readUint32()){case r:throw new Error("Unexpected JSON chunk");case 5130562:{const t=e.byteOffset;a.bin={readAsync:(r,s)=>e.buffer.readAsync(t+r,s),byteLength:s},e.skipBytes(s);break}default:e.skipBytes(s)}return e.byteOffset!==t?e.loadAsync(8).then(n):Promise.resolve(a)};return n()})}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 r=g._logSpaces.substring(0,2*this._logIndentLevel);t.Logger.Log(`${r}${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 v="undefined"!=typeof global?global:"undefined"!=typeof window?window:void 0;if(void 0!==v){v.BABYLON=v.BABYLON||{};for(const e in T)v.BABYLON[e]=T[e];for(const e in n)v.BABYLON[e]=n[e]}const x=[{regex:new RegExp("^/nodes/\\d+/extensions/")}];class A{constructor(e,t){this._gltf=e,this._infoTree=t}convert(e){let t,r=this._gltf,s=this._infoTree;if(!e.startsWith("/"))throw new Error("Path must start with a /");const a=e.split("/");if(a.shift(),a[a.length-1].includes(".length")){const e=a[a.length-1].split(".");a.pop(),a.push(...e)}let n=!1;for(const o of a){const a="length"===o;if(a&&!s.__array__)throw new Error(`Path ${e} is invalid`);if(s.__ignoreObjectTree__&&(n=!0),s.__array__&&!a)s=s.__array__;else if(s=s[o],!s)throw new Error(`Path ${e} is invalid`);if(!n)if(void 0===r){if(!x.find(t=>t.regex.test(e)))throw new Error(`Path ${e} is invalid`)}else a||(r=null==r?void 0:r[o]);(s.__target__||a)&&(t=r)}return{object:t,info:s}}}function C(e,t,r,s){const a=R(e);return s?a[r][s]:a[r]}function R(e,r,s){var a,n,o;return null===(o=null===(a=e._data)||void 0===a?void 0:a[null!==(n=null==s?void 0:s.fillMode)&&void 0!==n?n:t.Constants.MATERIAL_TriangleFillMode])||void 0===o?void 0:o.babylonMaterial}function w(e,r){return{offset:{componentsCount:2,type:"Vector2",get:(s,a,n)=>{const o=C(s,0,e,r);return new t.Vector2(null==o?void 0:o.uOffset,null==o?void 0:o.vOffset)},getTarget:R,set:(t,s,a,n)=>{const o=C(s,0,e,r);o.uOffset=t.x,o.vOffset=t.y},getPropertyName:[()=>`${e}${r?"."+r:""}.uOffset`,()=>`${e}${r?"."+r:""}.vOffset`]},rotation:{type:"number",get:(t,s,a)=>{var n;return null===(n=C(t,0,e,r))||void 0===n?void 0:n.wAng},getTarget:R,set:(t,s,a,n)=>C(s,0,e,r).wAng=t,getPropertyName:[()=>`${e}${r?"."+r:""}.wAng`]},scale:{componentsCount:2,type:"Vector2",get:(s,a,n)=>{const o=C(s,0,e,r);return new t.Vector2(null==o?void 0:o.uScale,null==o?void 0:o.vScale)},getTarget:R,set:(t,s,a,n)=>{const o=C(s,0,e,r);o.uScale=t.x,o.vScale=t.y},getPropertyName:[()=>`${e}${r?"."+r:""}.uScale`,()=>`${e}${r?"."+r:""}.vScale`]}}}const M={cameras:{__array__:{__target__:!0,orthographic:{xmag:{componentsCount:2,type:"Vector2",get:e=>{var r,s,a,n;return new t.Vector2(null!==(s=null===(r=e._babylonCamera)||void 0===r?void 0:r.orthoLeft)&&void 0!==s?s:0,null!==(n=null===(a=e._babylonCamera)||void 0===a?void 0:a.orthoRight)&&void 0!==n?n: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 r,s,a,n;return new t.Vector2(null!==(s=null===(r=e._babylonCamera)||void 0===r?void 0:r.orthoBottom)&&void 0!==s?s:0,null!==(n=null===(a=e._babylonCamera)||void 0===a?void 0:a.orthoTop)&&void 0!==n?n: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 r;return null===(r=t._babylonTransformNode)||void 0===r?void 0:r.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 r,s;return null===(s=null===(r=t._babylonTransformNode)||void 0===r?void 0:r.rotationQuaternion)||void 0===s?void 0:s.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 r;return null===(r=t._babylonTransformNode)||void 0===r?void 0:r.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 r,s;return void 0!==t?null===(s=null===(r=e._primitiveBabylonMeshes)||void 0===r?void 0:r[0].morphTargetManager)||void 0===s?void 0:s.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 r,s,a;return t.Matrix.Compose(null===(r=e._babylonTransformNode)||void 0===r?void 0:r.scaling,null===(s=e._babylonTransformNode)||void 0===s?void 0:s.rotationQuaternion,null===(a=e._babylonTransformNode)||void 0===a?void 0:a.position)},getTarget:e=>e._babylonTransformNode,isReadOnly:!0},globalMatrix:{type:"Matrix",get:e=>{var r,s,a,n,o,i,l;const u=t.Matrix.Identity();let c=e.parent;for(;c&&c.parent;)c=c.parent;const h=(null===(r=e._babylonTransformNode)||void 0===r?void 0:r.position._isDirty)||(null===(a=null===(s=e._babylonTransformNode)||void 0===s?void 0:s.rotationQuaternion)||void 0===a?void 0:a._isDirty)||(null===(n=e._babylonTransformNode)||void 0===n?void 0:n.scaling._isDirty);if(c){const t=null===(o=c._babylonTransformNode)||void 0===o?void 0:o.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 r,s;return null===(s=null===(r=e._babylonTransformNode)||void 0===r?void 0:r.getChildren(e=>e instanceof t.SpotLight,!0)[0])||void 0===s?void 0:s.intensity},getTarget:e=>{var r;return null===(r=e._babylonTransformNode)||void 0===r?void 0:r.getChildren(e=>e instanceof t.SpotLight,!0)[0]},set:(e,r)=>{if(r._babylonTransformNode){const s=r._babylonTransformNode.getChildren(e=>e instanceof t.SpotLight,!0)[0];s&&(s.intensity=e)}}},color:{type:"Color3",get:e=>{var r,s;return null===(s=null===(r=e._babylonTransformNode)||void 0===r?void 0:r.getChildren(e=>e instanceof t.SpotLight,!0)[0])||void 0===s?void 0:s.diffuse},getTarget:e=>{var r;return null===(r=e._babylonTransformNode)||void 0===r?void 0:r.getChildren(e=>e instanceof t.SpotLight,!0)[0]},set:(e,r)=>{if(r._babylonTransformNode){const s=r._babylonTransformNode.getChildren(e=>e instanceof t.SpotLight,!0)[0];s&&(s.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,r)=>R(e,0,r).emissiveColor,set:(e,t,r,s)=>R(t,0,s).emissiveColor.copyFrom(e),getTarget:(e,t,r)=>R(e,0,r),getPropertyName:[()=>"emissiveColor"]},emissiveTexture:{extensions:{KHR_texture_transform:w("emissiveTexture")}},normalTexture:{scale:{type:"number",get:(e,t,r)=>{var s;return null===(s=C(e,0,"bumpTexture"))||void 0===s?void 0:s.level},set:(e,t,r,s)=>{const a=C(t,0,"bumpTexture");a&&(a.level=e)},getTarget:(e,t,r)=>R(e,0,r),getPropertyName:[()=>"level"]},extensions:{KHR_texture_transform:w("bumpTexture")}},occlusionTexture:{strength:{type:"number",get:(e,t,r)=>R(e,0,r).ambientTextureStrength,set:(e,t,r,s)=>{const a=R(t,0,s);a&&(a.ambientTextureStrength=e)},getTarget:(e,t,r)=>R(e,0,r),getPropertyName:[()=>"ambientTextureStrength"]},extensions:{KHR_texture_transform:w("ambientTexture")}},pbrMetallicRoughness:{baseColorFactor:{type:"Color4",get:(e,r,s)=>{const a=R(e,0,s);return t.Color4.FromColor3(a.albedoColor,a.alpha)},set:(e,t,r,s)=>{const a=R(t,0,s);a.albedoColor.set(e.r,e.g,e.b),a.alpha=e.a},getTarget:(e,t,r)=>R(e,0,r),getPropertyName:[()=>"albedoColor",()=>"alpha"]},baseColorTexture:{extensions:{KHR_texture_transform:w("albedoTexture")}},metallicFactor:{type:"number",get:(e,t,r)=>R(e,0,r).metallic,set:(e,t,r,s)=>{const a=R(t,0,s);a&&(a.metallic=e)},getTarget:(e,t,r)=>R(e,0,r),getPropertyName:[()=>"metallic"]},roughnessFactor:{type:"number",get:(e,t,r)=>R(e,0,r).roughness,set:(e,t,r,s)=>{const a=R(t,0,s);a&&(a.roughness=e)},getTarget:(e,t,r)=>R(e,0,r),getPropertyName:[()=>"roughness"]},metallicRoughnessTexture:{extensions:{KHR_texture_transform:w("metallicTexture")}}},extensions:{KHR_materials_anisotropy:{anisotropyStrength:{type:"number",get:(e,t,r)=>R(e,0,r).anisotropy.intensity,set:(e,t,r,s)=>{R(t,0,s).anisotropy.intensity=e},getTarget:(e,t,r)=>R(e,0,r),getPropertyName:[()=>"anisotropy.intensity"]},anisotropyRotation:{type:"number",get:(e,t,r)=>R(e,0,r).anisotropy.angle,set:(e,t,r,s)=>{R(t,0,s).anisotropy.angle=e},getTarget:(e,t,r)=>R(e,0,r),getPropertyName:[()=>"anisotropy.angle"]},anisotropyTexture:{extensions:{KHR_texture_transform:w("anisotropy","texture")}}},KHR_materials_clearcoat:{clearcoatFactor:{type:"number",get:(e,t,r)=>R(e,0,r).clearCoat.intensity,set:(e,t,r,s)=>{R(t,0,s).clearCoat.intensity=e},getTarget:(e,t,r)=>R(e,0,r),getPropertyName:[()=>"clearCoat.intensity"]},clearcoatRoughnessFactor:{type:"number",get:(e,t,r)=>R(e,0,r).clearCoat.roughness,set:(e,t,r,s)=>{R(t,0,s).clearCoat.roughness=e},getTarget:(e,t,r)=>R(e,0,r),getPropertyName:[()=>"clearCoat.roughness"]},clearcoatTexture:{extensions:{KHR_texture_transform:w("clearCoat","texture")}},clearcoatNormalTexture:{scale:{type:"number",get:(e,t,r)=>{var s;return null===(s=R(e,0,r).clearCoat.bumpTexture)||void 0===s?void 0:s.level},getTarget:R,set:(e,t,r,s)=>R(t,0,s).clearCoat.bumpTexture.level=e},extensions:{KHR_texture_transform:w("clearCoat","bumpTexture")}},clearcoatRoughnessTexture:{extensions:{KHR_texture_transform:w("clearCoat","textureRoughness")}}},KHR_materials_dispersion:{dispersion:{type:"number",get:(e,t,r)=>R(e,0,r).subSurface.dispersion,getTarget:R,set:(e,t,r,s)=>R(t,0,s).subSurface.dispersion=e}},KHR_materials_emissive_strength:{emissiveStrength:{type:"number",get:(e,t,r)=>R(e,0,r).emissiveIntensity,getTarget:R,set:(e,t,r,s)=>R(t,0,s).emissiveIntensity=e}},KHR_materials_ior:{ior:{type:"number",get:(e,t,r)=>R(e,0,r).indexOfRefraction,getTarget:R,set:(e,t,r,s)=>R(t,0,s).indexOfRefraction=e}},KHR_materials_iridescence:{iridescenceFactor:{type:"number",get:(e,t,r)=>R(e,0,r).iridescence.intensity,getTarget:R,set:(e,t,r,s)=>R(t,0,s).iridescence.intensity=e},iridescenceIor:{type:"number",get:(e,t,r)=>R(e,0,r).iridescence.indexOfRefraction,getTarget:R,set:(e,t,r,s)=>R(t,0,s).iridescence.indexOfRefraction=e},iridescenceTexture:{extensions:{KHR_texture_transform:w("iridescence","texture")}},iridescenceThicknessMaximum:{type:"number",get:(e,t,r)=>R(e,0,r).iridescence.maximumThickness,getTarget:R,set:(e,t,r,s)=>R(t,0,s).iridescence.maximumThickness=e},iridescenceThicknessMinimum:{type:"number",get:(e,t,r)=>R(e,0,r).iridescence.minimumThickness,getTarget:R,set:(e,t,r,s)=>R(t,0,s).iridescence.minimumThickness=e},iridescenceThicknessTexture:{extensions:{KHR_texture_transform:w("iridescence","thicknessTexture")}}},KHR_materials_sheen:{sheenColorFactor:{type:"Color3",get:(e,t,r)=>R(e,0,r).sheen.color,getTarget:R,set:(e,t,r,s)=>R(t,0,s).sheen.color.copyFrom(e)},sheenColorTexture:{extensions:{KHR_texture_transform:w("sheen","texture")}},sheenRoughnessFactor:{type:"number",get:(e,t,r)=>R(e,0,r).sheen.intensity,getTarget:R,set:(e,t,r,s)=>R(t,0,s).sheen.intensity=e},sheenRoughnessTexture:{extensions:{KHR_texture_transform:w("sheen","thicknessTexture")}}},KHR_materials_specular:{specularFactor:{type:"number",get:(e,t,r)=>R(e,0,r).metallicF0Factor,getTarget:R,set:(e,t,r,s)=>R(t,0,s).metallicF0Factor=e,getPropertyName:[()=>"metallicF0Factor"]},specularColorFactor:{type:"Color3",get:(e,t,r)=>R(e,0,r).metallicReflectanceColor,getTarget:R,set:(e,t,r,s)=>R(t,0,s).metallicReflectanceColor.copyFrom(e),getPropertyName:[()=>"metallicReflectanceColor"]},specularTexture:{extensions:{KHR_texture_transform:w("metallicReflectanceTexture")}},specularColorTexture:{extensions:{KHR_texture_transform:w("reflectanceTexture")}}},KHR_materials_transmission:{transmissionFactor:{type:"number",get:(e,t,r)=>R(e,0,r).subSurface.refractionIntensity,getTarget:R,set:(e,t,r,s)=>R(t,0,s).subSurface.refractionIntensity=e,getPropertyName:[()=>"subSurface.refractionIntensity"]},transmissionTexture:{extensions:{KHR_texture_transform:w("subSurface","refractionIntensityTexture")}}},KHR_materials_diffuse_transmission:{diffuseTransmissionFactor:{type:"number",get:(e,t,r)=>R(e,0,r).subSurface.translucencyIntensity,getTarget:R,set:(e,t,r,s)=>R(t,0,s).subSurface.translucencyIntensity=e},diffuseTransmissionTexture:{extensions:{KHR_texture_transform:w("subSurface","translucencyIntensityTexture")}},diffuseTransmissionColorFactor:{type:"Color3",get:(e,t,r)=>R(e,0,r).subSurface.translucencyColor,getTarget:R,set:(e,t,r,s)=>{var a;return e&&(null===(a=R(t,0,s).subSurface.translucencyColor)||void 0===a?void 0:a.copyFrom(e))}},diffuseTransmissionColorTexture:{extensions:{KHR_texture_transform:w("subSurface","translucencyColorTexture")}}},KHR_materials_volume:{attenuationColor:{type:"Color3",get:(e,t,r)=>R(e,0,r).subSurface.tintColor,getTarget:R,set:(e,t,r,s)=>R(t,0,s).subSurface.tintColor.copyFrom(e)},attenuationDistance:{type:"number",get:(e,t,r)=>R(e,0,r).subSurface.tintColorAtDistance,getTarget:R,set:(e,t,r,s)=>R(t,0,s).subSurface.tintColorAtDistance=e},thicknessFactor:{type:"number",get:(e,t,r)=>R(e,0,r).subSurface.maximumThickness,getTarget:R,set:(e,t,r,s)=>R(t,0,s).subSurface.maximumThickness=e},thicknessTexture:{extensions:{KHR_texture_transform:w("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 r;return null===(r=t._babylonLight)||void 0===r?void 0:r.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 r;return null===(r=t._babylonLight)||void 0===r?void 0:r.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,r;return(null===(t=e._babylonLight)||void 0===t?void 0:t.width)/(null===(r=e._babylonLight)||void 0===r?void 0:r.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 r;return e._babylonTexture&&t.Quaternion.FromRotationMatrix(null===(r=e._babylonTexture)||void 0===r?void 0:r.getReflectionTextureMatrix())},set:(e,r)=>{var s;r._babylonTexture&&((null===(s=r._babylonTexture.getScene())||void 0===s?void 0:s.useRightHandedSystem)||(e=t.Quaternion.Inverse(e)),t.Matrix.FromQuaternionToRef(e,r._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 O(e){return new A(e,M)}function L(e){const t=e.split("/").map(e=>e.replace(/{}/g,"__array__"));let r=M;for(const e of t)e&&(r=r[e]);if(r&&r.type&&r.get)return r}function F(e,t){const r=e.split("/").map(e=>e.replace(/{}/g,"__array__"));let s=M;for(const e of r)e&&(s=s[e]);s&&s.type&&s.get&&(s.interpolation=t)}function E(e,t){const r=e.split("/").map(e=>e.replace(/{}/g,"__array__"));let s=M;for(const e of r)if(e){if(!s[e]){if("?"===e){s.__ignoreObjectTree__=!0;continue}s[e]={},"__array__"===e&&(s[e].__target__=!0)}s=s[e]}Object.assign(s,t)}function S(e,t,r,s){return new(r||(r=Promise))(function(a,n){function o(e){try{l(s.next(e))}catch(e){n(e)}}function i(e){try{l(s.throw(e))}catch(e){n(e)}}function l(e){var t;e.done?a(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(o,i)}l((s=s.apply(e,t||[])).next())})}Object.create,Object.create,"function"==typeof SuppressedError&&SuppressedError;const k=new Map,I=k;function P(e,r,s){B(e)&&t.Logger.Warn(`Extension with the name '${e}' already exists`),k.set(e,{isGLTFExtension:r,factory:s})}function B(e){return k.delete(e)}const N=new t.Lazy(()=>Promise.resolve(BABYLON)),G=new t.Lazy(()=>Promise.resolve().then(function(){return Rr}));class D{static Get(e,t,r){if(!t||null==r||!t[r])throw new Error(`${e}: Failed to find index (${r})`);return t[r]}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 V(e){if(e.min&&e.max){const r=e.min,s=e.max,a=t.TmpVectors.Vector3[0].copyFromFloats(r[0],r[1],r[2]),n=t.TmpVectors.Vector3[1].copyFromFloats(s[0],s[1],s[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 r=1/t;a.scaleInPlace(r),n.scaleInPlace(r)}return new t.BoundingInfo(a,n)}return null}class ${isMatchingMaterialType(e){if(!e)return!1;const t=Array.from(this._pbrMaterialImpls.values());for(const r of t)if(e instanceof r.materialClass)return!0;return!1}static RegisterExtension(e,t){P(e,!1,t)}static UnregisterExtension(e){return B(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 r=Array.from(this._pbrMaterialImpls.values());for(const s of r)if(e instanceof s.materialClass){t=new s.adapterClass(e);break}if(!t)throw new Error("Appropriate material adapter class not found");const s=t;this._materialAdapterCache.set(e,s),this._materialAdapters.add(s)}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,r,s,a,n){return S(this,arguments,void 0,function*(e,t,r,s,a,n,o=""){return yield Promise.resolve().then(()=>S(this,void 0,void 0,function*(){this._babylonScene=t,this._assetContainer=r,this._loadData(s);let n=null;if(e){const t={};if(this._gltf.nodes)for(const e of this._gltf.nodes)e.name&&(t[e.name]=e.index);n=(e instanceof Array?e:[e]).map(e=>{const r=t[e];if(void 0===r)throw new Error(`Failed to find node '${e}'`);return r})}return yield this._loadAsync(a,o,n,()=>({meshes:this._getMeshes(),particleSystems:[],skeletons:this._getSkeletons(),animationGroups:this._getAnimationGroups(),lights:this._babylonLights,transformNodes:this._getTransformNodes(),geometries:this._getGeometries(),spriteManagers:[]}))}))})}loadAsync(e,t,r,s){return S(this,arguments,void 0,function*(e,t,r,s,a=""){return this._babylonScene=e,this._loadData(t),yield this._loadAsync(r,a,null,()=>{})})}_loadAsync(r,s,a,n){return S(this,void 0,void 0,function*(){return yield Promise.resolve().then(()=>S(this,void 0,void 0,function*(){var o;if(this._rootUrl=r,this._uniqueRootUrl=!r.startsWith("file:")&&s?r:`${r}${Date.now()}/`,this._fileName=s,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===(o=this._gltf.materials)||void 0===o?void 0:o.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 r=[];e&&!this._pbrMaterialImpls.has("openpbr")&&r.push(Promise.all([Promise.resolve(BABYLON),Promise.resolve().then(function(){return Zs})]).then(([{OpenPBRMaterial:e,RegisterOpenpbrMaterial:t},{OpenPBRMaterialLoadingAdapter:r}])=>{t(),this._pbrMaterialImpls.set("openpbr",{materialClass:e,adapterClass:r})})),t&&!this._pbrMaterialImpls.has("pbr")&&r.push(Promise.all([Promise.resolve(BABYLON),Promise.resolve().then(function(){return ta})]).then(([{PBRMaterial:e,RegisterPbrMaterial:t},{PBRMaterialLoadingAdapter:r}])=>{t(),this._pbrMaterialImpls.set("pbr",{materialClass:e,adapterClass:r})})),yield Promise.all(r)}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(a)u.push(this.loadSceneAsync("/nodes",{nodes:a,index:-1}));else if(null!=this._gltf.scene||this._gltf.scenes&&this._gltf.scenes[0]){const e=D.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 r=this._gltf.materials[e],s="/materials/"+e,a=t.Material.TriangleFillMode;u.push(this._loadMaterialAsync(s,r,null,a,()=>{}))}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(),n()});return yield h.then(r=>(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()})}),r))})).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 r=this._gltf.buffers;if(r&&r[0]&&!r[0].uri){const s=r[0];(s.byteLength<e.bin.byteLength-3||s.byteLength>e.bin.byteLength)&&t.Logger.Warn(`Binary buffer length (${s.byteLength}) from JSON does not match chunk length (${e.bin.byteLength})`),this._bin=e.bin}else t.Logger.Warn("Unexpected BIN chunk")}}_setupData(){if(D.Assign(this._gltf.accessors),D.Assign(this._gltf.animations),D.Assign(this._gltf.buffers),D.Assign(this._gltf.bufferViews),D.Assign(this._gltf.cameras),D.Assign(this._gltf.images),D.Assign(this._gltf.materials),D.Assign(this._gltf.meshes),D.Assign(this._gltf.nodes),D.Assign(this._gltf.samplers),D.Assign(this._gltf.scenes),D.Assign(this._gltf.skins),D.Assign(this._gltf.textures),this._gltf.nodes){const e={};for(const t of this._gltf.nodes)if(t.children)for(const r of t.children)e[r]=t.index;const t=this._createRootNode();for(const r of this._gltf.nodes){const s=e[r.index];r.parent=void 0===s?t:this._gltf.nodes[s]}}}_loadExtensionsAsync(){return S(this,void 0,void 0,function*(){var e;const r=[];if(I.forEach((e,s)=>{var a;!1===(null===(a=this.parent.extensionOptions[s])||void 0===a?void 0:a.enabled)?e.isGLTFExtension&&this.isExtensionUsed(s)&&t.Logger.Warn(`Extension ${s} is used but has been explicitly disabled.`):e.isGLTFExtension&&!this.isExtensionUsed(s)||r.push((()=>S(this,void 0,void 0,function*(){const r=yield e.factory(this);return r.name!==s&&t.Logger.Warn(`The name of the glTF loader extension instance does not match the registered name: ${r.name} !== ${s}`),this._parent.onExtensionLoadedObservable.notifyObservers(r),r}))())}),this._extensions.push(...yield Promise.all(r)),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 r=new t.Mesh("__root__",this._babylonScene);this._rootBabylonMesh=r,this._rootBabylonMesh._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,this._rootBabylonMesh.setEnabled(!1);const s={_babylonTransformNode:this._rootBabylonMesh,index:-1};switch(this._parent.coordinateSystemMode){case e.GLTFLoaderCoordinateSystemMode.AUTO:this._babylonScene.useRightHandedSystem||(s.rotation=[0,1,0,0],s.scale=[1,1,-1],$._LoadTransform(s,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(r),s}loadSceneAsync(e,t){const r=this._extensionsLoadSceneAsync(e,t);if(r)return r;const s=new Array;if(this.logOpen(`${e} ${t.name||""}`),t.nodes)for(const r of t.nodes){const t=D.Get(`${e}/nodes/${r}`,this._gltf.nodes,r);s.push(this.loadNodeAsync(`/nodes/${t.index}`,t,e=>{e.parent=this._rootBabylonMesh}))}for(const e of this._postSceneLoadActions)e();return s.push(this._loadAnimationsAsync()),this.logClose(),Promise.all(s).then(()=>{})}_forEachPrimitive(e,t){if(e._primitiveBabylonMeshes)for(const r of e._primitiveBabylonMeshes)t(r)}_getGeometries(){const e=[],t=this._gltf.nodes;if(t)for(const r of t)this._forEachPrimitive(r,t=>{const r=t.geometry;r&&-1===e.indexOf(r)&&e.push(r)});return e}_getMeshes(){const e=[];this._rootBabylonMesh instanceof t.AbstractMesh&&e.push(this._rootBabylonMesh);const r=this._gltf.nodes;if(r)for(const t of r)this._forEachPrimitive(t,t=>{e.push(t)});return e}_getTransformNodes(){const e=[],t=this._gltf.nodes;if(t)for(const r of t)r._babylonTransformNode&&"TransformNode"===r._babylonTransformNode.getClassName()&&e.push(r._babylonTransformNode),r._babylonTransformNodeForSkin&&e.push(r._babylonTransformNodeForSkin);return e}_getSkeletons(){const e=[],t=this._gltf.skins;if(t)for(const r of t)r._data&&e.push(r._data.babylonSkeleton);return e}_getAnimationGroups(){const e=[],t=this._gltf.animations;if(t)for(const r of t)r._babylonAnimationGroup&&e.push(r._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,r,s=()=>{}){const a=this._extensionsLoadNodeAsync(e,r,s);if(a)return a;if(r._babylonTransformNode)throw new Error(`${e}: Invalid recursive node hierarchy`);const n=new Array;this.logOpen(`${e} ${r.name||""}`);const o=t=>{if($.AddPointerMetadata(t,e),$._LoadTransform(r,t),null!=r.camera){const s=D.Get(`${e}/camera`,this._gltf.cameras,r.camera);n.push(this.loadCameraAsync(`/cameras/${s.index}`,s,e=>{e.parent=t,this._babylonScene.useRightHandedSystem||(t.scaling.x=-1)}))}if(r.children)for(const s of r.children){const r=D.Get(`${e}/children/${s}`,this._gltf.nodes,s);n.push(this.loadNodeAsync(`/nodes/${r.index}`,r,e=>{e.parent=t}))}s(t)},i=null!=r.mesh,l=this._parent.loadSkins&&null!=r.skin;if(!i||l){const e=r.name||`node${r.index}`;this._babylonScene._blockEntityCollection=!!this._assetContainer;const s=new t.TransformNode(e,this._babylonScene);s._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,null==r.mesh?r._babylonTransformNode=s:r._babylonTransformNodeForSkin=s,o(s)}if(i)if(l){const s=D.Get(`${e}/mesh`,this._gltf.meshes,r.mesh);n.push(this._loadMeshAsync(`/meshes/${s.index}`,r,s,s=>{const a=r._babylonTransformNodeForSkin;s.metadata=t.deepMerge(a.metadata,s.metadata||{});const o=D.Get(`${e}/skin`,this._gltf.skins,r.skin);n.push(this._loadSkinAsync(`/skins/${o.index}`,r,o,e=>{this._forEachPrimitive(r,t=>{t.skeleton=e}),this._postSceneLoadActions.push(()=>{if(null!=o.skeleton){const e=D.Get(`/skins/${o.index}/skeleton`,this._gltf.nodes,o.skeleton).parent;r.index===e.index?s.parent=a.parent:s.parent=e._babylonTransformNode}else s.parent=this._rootBabylonMesh;this._parent.onSkinLoadedObservable.notifyObservers({node:a,skinnedNode:s})})}))}))}else{const t=D.Get(`${e}/mesh`,this._gltf.meshes,r.mesh);n.push(this._loadMeshAsync(`/meshes/${t.index}`,r,t,o))}return this.logClose(),Promise.all(n).then(()=>(this._forEachPrimitive(r,e=>{const t=e;!t.isAnInstance&&t.geometry&&t.geometry.useBoundingInfoFromGeometry?e._updateBoundingInfo():e.refreshBoundingInfo(!0,!0)}),r._babylonTransformNode))}_loadMeshAsync(e,r,s,a){const n=s.primitives;if(!n||!n.length)throw new Error(`${e}: Primitives are missing`);null==n[0].index&&D.Assign(n);const o=new Array;this.logOpen(`${e} ${s.name||""}`);const i=r.name||`node${r.index}`;if(1===n.length){const t=s.primitives[0];o.push(this._loadMeshPrimitiveAsync(`${e}/primitives/${t.index}`,i,r,s,t,e=>{r._babylonTransformNode=e,r._primitiveBabylonMeshes=[e]}))}else{this._babylonScene._blockEntityCollection=!!this._assetContainer,r._babylonTransformNode=new t.TransformNode(i,this._babylonScene),r._babylonTransformNode._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,r._primitiveBabylonMeshes=[];for(const t of n)o.push(this._loadMeshPrimitiveAsync(`${e}/primitives/${t.index}`,`${i}_primitive${t.index}`,r,s,t,e=>{e.parent=r._babylonTransformNode,r._primitiveBabylonMeshes.push(e)}))}return a(r._babylonTransformNode),this.logClose(),Promise.all(o).then(()=>r._babylonTransformNode)}_loadMeshPrimitiveAsync(e,r,s,a,n,o){const i=this._extensionsLoadMeshPrimitiveAsync(e,r,s,a,n,o);if(i)return i;this.logOpen(`${e}`);const l=0===this._disableInstancedMesh&&this._parent.createInstances&&null==s.skin&&!a.primitives[0].targets;let u,c;if(l&&n._instanceData)this._babylonScene._blockEntityCollection=!!this._assetContainer,u=n._instanceData.babylonSourceMesh.createInstance(r),u._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,c=n._instanceData.promise;else{const o=new Array;this._babylonScene._blockEntityCollection=!!this._assetContainer;const i=new t.Mesh(r,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,s,a,n,i),o.push(this._loadVertexDataAsync(e,n,i).then(t=>S(this,void 0,void 0,function*(){return yield this._loadMorphTargetsAsync(e,n,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=$._GetDrawMode(e,n.mode);if(null==n.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 r=D.Get(`${e}/material`,this._gltf.materials,n.material);o.push(this._loadMaterialAsync(`/materials/${r.index}`,r,i,t,e=>{i.material=e}))}}c=Promise.all(o),l&&(n._instanceData={babylonSourceMesh:i,promise:c}),u=i}return $.AddPointerMetadata(u,e),this._parent.onMeshLoadedObservable.notifyObservers(u),o(u),this.logClose(),c.then(()=>u)}_loadVertexDataAsync(e,r,s){const a=this._extensionsLoadVertexDataAsync(e,r,s);if(a)return a;const n=r.attributes;if(!n)throw new Error(`${e}: Attributes are missing`);const o=new Array,i=new t.Geometry(s.name,this._babylonScene);if(null==r.indices)s.isUnIndexed=!0;else{const t=D.Get(`${e}/indices`,this._gltf.accessors,r.indices);o.push(this._loadIndicesAccessorAsync(`/accessors/${t.index}`,t).then(e=>{i.setIndices(e)}))}const l=(r,a,l)=>{if(null==n[r])return;s._delayInfo=s._delayInfo||[],-1===s._delayInfo.indexOf(a)&&s._delayInfo.push(a);const u=D.Get(`${e}/attributes/${r}`,this._gltf.accessors,n[r]);o.push(this._loadVertexAccessorAsync(`/accessors/${u.index}`,u,a).then(e=>{if(e.getKind()===t.VertexBuffer.PositionKind&&!this.parent.alwaysComputeBoundingBox&&!s.skeleton){const e=V(u);e&&(i._boundingInfo=e,i.useBoundingInfoFromGeometry=!0)}i.setVerticesBuffer(e,u.count)})),a==t.VertexBuffer.MatricesIndicesExtraKind&&(s.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&&(s.hasVertexAlpha=!0)}),Promise.all(o).then(()=>i)}_createMorphTargets(e,r,s,a,n){if(!a.targets||!this._parent.loadMorphTargets)return;if(null==r._numMorphTargets)r._numMorphTargets=a.targets.length;else if(a.targets.length!==r._numMorphTargets)throw new Error(`${e}: Primitives do not have the same number of targets`);const o=s.extras?s.extras.targetNames:null;this._babylonScene._blockEntityCollection=!!this._assetContainer,n.morphTargetManager=new t.MorphTargetManager(this._babylonScene),n.morphTargetManager._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,n.morphTargetManager.areUpdatesFrozen=!0;for(let e=0;e<a.targets.length;e++){const a=r.weights?r.weights[e]:s.weights?s.weights[e]:0,i=o?o[e]:`morphTarget${e}`;n.morphTargetManager.addTarget(new t.MorphTarget(i,a,n.getScene()))}}_loadMorphTargetsAsync(e,r,s,a){if(!r.targets||!this._parent.loadMorphTargets)return Promise.resolve();const n=new Array,o=s.morphTargetManager;for(let t=0;t<o.numTargets;t++){const s=o.getTarget(t);n.push(this._loadMorphTargetVertexDataAsync(`${e}/targets/${t}`,a,r.targets[t],s))}return Promise.all(n).then(()=>{o.areUpdatesFrozen=!1,this._parent.useMaxMorphTargetInfluencers&&(o.isUsingTextureForTargets||o.numTargets<=t.MorphTargetManager.MaxActiveMorphTargetsInVertexAttributeMode)&&(o.optimizeInfluencers=!1,o.numMaxInfluencers=o.numTargets)})}_loadMorphTargetVertexDataAsync(e,r,s,a){return S(this,void 0,void 0,function*(){const n=new Array,o=(t,a,o)=>{if(null==s[t])return;const i=r.getVertexBuffer(a);if(!i)return;const l=D.Get(`${e}/${t}`,this._gltf.accessors,s[t]);n.push(this._loadFloatAccessorAsync(`/accessors/${l.index}`,l).then(e=>{o(i,e)}))};return o("POSITION",t.VertexBuffer.PositionKind,(e,t)=>{const r=new Float32Array(t.length);e.forEach(t.length,(e,s)=>{r[s]=t[s]+e}),a.setPositions(r)}),o("NORMAL",t.VertexBuffer.NormalKind,(e,t)=>{const r=new Float32Array(t.length);e.forEach(r.length,(e,s)=>{r[s]=t[s]+e}),a.setNormals(r)}),o("TANGENT",t.VertexBuffer.TangentKind,(e,t)=>{const r=new Float32Array(t.length/3*4);let s=0;e.forEach(t.length/3*4,(e,a)=>{(a+1)%4!=0&&(r[s]=t[s]+e,s++)}),a.setTangents(r)}),o("TEXCOORD_0",t.VertexBuffer.UVKind,(e,t)=>{const r=new Float32Array(t.length);e.forEach(t.length,(e,s)=>{r[s]=t[s]+e}),a.setUVs(r)}),o("TEXCOORD_1",t.VertexBuffer.UV2Kind,(e,t)=>{const r=new Float32Array(t.length);e.forEach(t.length,(e,s)=>{r[s]=t[s]+e}),a.setUV2s(r)}),o("COLOR_0",t.VertexBuffer.ColorKind,(t,r)=>{let s=null;const n=t.getSize();if(3===n){s=new Float32Array(r.length/3*4),t.forEach(r.length,(e,t)=>{const a=Math.floor(t/3),n=t%3;s[4*a+n]=r[3*a+n]+e});for(let e=0;e<r.length/3;++e)s[4*e+3]=1}else{if(4!==n)throw new Error(`${e}: Invalid number of components (${n}) for COLOR_0 attribute`);s=new Float32Array(r.length),t.forEach(r.length,(e,t)=>{s[t]=r[t]+e})}a.setColors(s)}),yield Promise.all(n).then(()=>{})})}static _LoadTransform(e,r){if(null!=e.skin)return;let s=t.Vector3.Zero(),a=t.Quaternion.Identity(),n=t.Vector3.One();e.matrix?t.Matrix.FromArray(e.matrix).decompose(n,a,s):(e.translation&&(s=t.Vector3.FromArray(e.translation)),e.rotation&&(a=t.Quaternion.FromArray(e.rotation)),e.scale&&(n=t.Vector3.FromArray(e.scale))),r.position=s,r.rotationQuaternion=a,r.scaling=n}_loadSkinAsync(e,r,s,a){if(!this._parent.loadSkins)return Promise.resolve();const n=this._extensionsLoadSkinAsync(e,r,s);if(n)return n;if(s._data)return a(s._data.babylonSkeleton),s._data.promise;const o=`skeleton${s.index}`;this._babylonScene._blockEntityCollection=!!this._assetContainer;const i=new t.Skeleton(s.name||o,o,this._babylonScene);i._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,this._loadBones(e,s,i);const l=this._loadSkinInverseBindMatricesDataAsync(e,s).then(e=>{this._updateBoneMatrices(i,e)});return s._data={babylonSkeleton:i,promise:l},a(i),l}_loadBones(e,r,s){if(null==r.skeleton||this._parent.alwaysComputeSkeletonRootNode){const s=this._findSkeletonRootNode(`${e}/joints`,r.joints);if(s)if(void 0===r.skeleton)r.skeleton=s.index;else{const a=(e,t)=>{for(;t.parent;t=t.parent)if(t.parent===e)return!0;return!1},n=D.Get(`${e}/skeleton`,this._gltf.nodes,r.skeleton);n===s||a(n,s)||(t.Logger.Warn(`${e}/skeleton: Overriding with nearest common ancestor as skeleton node is not a common root`),r.skeleton=s.index)}else t.Logger.Warn(`${e}: Failed to find common root`)}const a={};for(const t of r.joints){const n=D.Get(`${e}/joints/${t}`,this._gltf.nodes,t);this._loadBone(n,r,s,a)}}_findSkeletonRootNode(e,t){if(0===t.length)return null;const r={};for(const s of t){const t=[];let a=D.Get(`${e}/${s}`,this._gltf.nodes,s);for(;-1!==a.index;)t.unshift(a),a=a.parent;r[s]=t}let s=null;for(let e=0;;++e){let a=r[t[0]];if(e>=a.length)return s;const n=a[e];for(let o=1;o<t.length;++o)if(a=r[t[o]],e>=a.length||n!==a[e])return s;s=n}}_loadBone(e,r,s,a){e._isJoint=!0;let n=a[e.index];if(n)return n;let o=null;e.index!==r.skeleton&&(e.parent&&-1!==e.parent.index?o=this._loadBone(e.parent,r,s,a):void 0!==r.skeleton&&t.Logger.Warn(`/skins/${r.index}/skeleton: Skeleton node is not a common root`));const i=r.joints.indexOf(e.index);return n=new t.Bone(e.name||`joint${e.index}`,s,o,this._getNodeMatrix(e),null,null,i),a[e.index]=n,this._postSceneLoadActions.push(()=>{n.linkTransformNode(e._babylonTransformNode)}),n}_loadSkinInverseBindMatricesDataAsync(e,t){if(null==t.inverseBindMatrices)return Promise.resolve(null);const r=D.Get(`${e}/inverseBindMatrices`,this._gltf.accessors,t.inverseBindMatrices);return this._loadFloatAccessorAsync(`/accessors/${r.index}`,r)}_updateBoneMatrices(e,r){for(const s of e.bones){const e=t.Matrix.Identity(),a=s._index;r&&-1!==a&&(t.Matrix.FromArrayToRef(r,16*a,e),e.invertToRef(e));const n=s.getParent();n&&e.multiplyToRef(n.getAbsoluteInverseBindMatrix(),e),s.updateMatrix(e,!1,!1),s._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,r,s=()=>{}){const a=this._extensionsLoadCameraAsync(e,r,s);if(a)return a;const n=new Array;this.logOpen(`${e} ${r.name||""}`),this._babylonScene._blockEntityCollection=!!this._assetContainer;const o=new t.FreeCamera(r.name||`camera${r.index}`,t.Vector3.Zero(),this._babylonScene,!1);switch(o._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,r._babylonCamera=o,o.setTarget(new t.Vector3(0,0,-1)),r.type){case"perspective":{const t=r.perspective;if(!t)throw new Error(`${e}: Camera perspective properties are missing`);o.fov=t.yfov,o.minZ=t.znear,o.maxZ=t.zfar||0;break}case"orthographic":if(!r.orthographic)throw new Error(`${e}: Camera orthographic properties are missing`);o.mode=t.Camera.ORTHOGRAPHIC_CAMERA,o.orthoLeft=-r.orthographic.xmag,o.orthoRight=r.orthographic.xmag,o.orthoBottom=-r.orthographic.ymag,o.orthoTop=r.orthographic.ymag,o.minZ=r.orthographic.znear,o.maxZ=r.orthographic.zfar;break;default:throw new Error(`${e}: Invalid camera type (${r.type})`)}return $.AddPointerMetadata(o,e),this._parent.onCameraLoadedObservable.notifyObservers(o),s(o),this.logClose(),Promise.all(n).then(()=>o)}_loadAnimationsAsync(){this._parent._startPerformanceCounter("Load animations");const e=this._gltf.animations;if(!e)return Promise.resolve();const t=new Array;for(let r=0;r<e.length;r++){const s=e[r];t.push(this.loadAnimationAsync(`/animations/${s.index}`,s).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)||N.value.then(({AnimationGroup:r})=>{this._babylonScene._blockEntityCollection=!!this._assetContainer;const s=new r(t.name||`animation${t.index}`,this._babylonScene);s._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,t._babylonAnimationGroup=s;const a=new Array;D.Assign(t.channels),D.Assign(t.samplers);for(const r of t.channels)a.push(this._loadAnimationChannelAsync(`${e}/channels/${r.index}`,e,t,r,(e,t)=>{e.animations=e.animations||[],e.animations.push(t),s.addTargetedAnimation(t,e)}));return this._parent._endPerformanceCounter("Load animation"),Promise.all(a).then(()=>(s.normalize(0),s))})}_loadAnimationChannelAsync(e,t,r,s,a){const n=this._extensionsLoadAnimationChannelAsync(e,t,r,s,a);if(n)return n;if(null==s.target.node)return Promise.resolve();const o=D.Get(`${e}/target/node`,this._gltf.nodes,s.target.node),i=s.target.path,l="weights"===i;return l&&!o._numMorphTargets||!l&&!o._babylonTransformNode?Promise.resolve():this._parent.loadNodeAnimations||l||o._isJoint?G.value.then(()=>{var n,l,u,c;let h;switch(i){case"translation":h=null===(n=L("/nodes/{}/translation"))||void 0===n?void 0:n.interpolation;break;case"rotation":h=null===(l=L("/nodes/{}/rotation"))||void 0===l?void 0:l.interpolation;break;case"scale":h=null===(u=L("/nodes/{}/scale"))||void 0===u?void 0:u.interpolation;break;case"weights":h=null===(c=L("/nodes/{}/weights"))||void 0===c?void 0:c.interpolation;break;default:throw new Error(`${e}/target/path: Invalid value (${s.target.path})`)}if(!h)throw new Error(`${e}/target/path: Could not find interpolation properties for target path (${s.target.path})`);const d={object:o,info:h};return this._loadAnimationChannelFromTargetInfoAsync(e,t,r,s,d,a)}):Promise.resolve()}_loadAnimationChannelFromTargetInfoAsync(e,t,r,s,a,n){const o=this.parent.targetFps,i=1/o,l=D.Get(`${e}/sampler`,r.samplers,s.sampler);return this._loadAnimationSamplerAsync(`${t}/samplers/${s.sampler}`,l).then(e=>{let t=0;const l=a.object,u=a.info;for(const a of u){const u=a.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=a.getValue(l,h,m,1);m+=u,d[e]={frame:c[e]*o,value:t,interpolation:1}}break;case"CUBICSPLINE":for(let e=0;e<c.length;e++){const t=a.getValue(l,h,m,i);m+=u;const r=a.getValue(l,h,m,1);m+=u;const s=a.getValue(l,h,m,i);m+=u,d[e]={frame:c[e]*o,inTangent:t,value:r,outTangent:s}}break;case"LINEAR":for(let e=0;e<c.length;e++){const t=a.getValue(l,h,m,1);m+=u,d[e]={frame:c[e]*o,value:t}}}if(m>0){const e=`${r.name||`animation${r.index}`}_channel${s.index}_${t}`,i=a.buildAnimations(l,e,o,d);for(const e of i)t++,n(e.babylonAnimatable,e.babylonAnimation)}}})}_loadAnimationSamplerAsync(e,t){if(t._data)return t._data;const r=t.interpolation||"LINEAR";switch(r){case"STEP":case"LINEAR":case"CUBICSPLINE":break;default:throw new Error(`${e}/interpolation: Invalid value (${t.interpolation})`)}const s=D.Get(`${e}/input`,this._gltf.accessors,t.input),a=D.Get(`${e}/output`,this._gltf.accessors,t.output);return t._data=Promise.all([this._loadFloatAccessorAsync(`/accessors/${s.index}`,s),this._loadFloatAccessorAsync(`/accessors/${a.index}`,a)]).then(([e,t])=>({input:e,interpolation:r,output:t})),t._data}loadBufferAsync(e,t,r,s){const a=this._extensionsLoadBufferAsync(e,t,r,s);if(a)return a;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+r,s)}catch(t){throw new Error(`${e}: ${t.message}`,{cause:t})}})}loadBufferViewAsync(e,t){const r=this._extensionsLoadBufferViewAsync(e,t);if(r)return r;if(t._data)return t._data;const s=D.Get(`${e}/buffer`,this._gltf.buffers,t.buffer);return t._data=this.loadBufferAsync(`/buffers/${s.index}`,s,t.byteOffset||0,t.byteLength),t._data}_loadAccessorAsync(e,r,s){if(r._data)return r._data;const a=$._GetNumComponents(e,r.type),n=a*t.VertexBufferGetTypeByteLength(r.componentType),o=a*r.count;if(null==r.bufferView)r._data=Promise.resolve(new s(o));else{const i=D.Get(`${e}/bufferView`,this._gltf.bufferViews,r.bufferView);r._data=this.loadBufferViewAsync(`/bufferViews/${i.index}`,i).then(l=>{if(5126!==r.componentType||r.normalized||i.byteStride&&i.byteStride!==n){const e=new s(o);return t.VertexBufferForEach(l,r.byteOffset||0,i.byteStride||n,a,r.componentType,e.length,r.normalized||!1,(t,r)=>{e[r]=t}),e}return $._GetTypedArray(e,r.componentType,l,r.byteOffset,o)})}if(r.sparse){const o=r.sparse;r._data=r._data.then(i=>{const l=i,u=D.Get(`${e}/sparse/indices/bufferView`,this._gltf.bufferViews,o.indices.bufferView),c=D.Get(`${e}/sparse/values/bufferView`,this._gltf.bufferViews,o.values.bufferView);return Promise.all([this.loadBufferViewAsync(`/bufferViews/${u.index}`,u),this.loadBufferViewAsync(`/bufferViews/${c.index}`,c)]).then(([i,u])=>{const c=$._GetTypedArray(`${e}/sparse/indices`,o.indices.componentType,i,o.indices.byteOffset,o.count),h=a*o.count;let d;if(5126!==r.componentType||r.normalized){const i=$._GetTypedArray(`${e}/sparse/values`,r.componentType,u,o.values.byteOffset,h);d=new s(h),t.VertexBufferForEach(i,0,n,a,r.componentType,d.length,r.normalized||!1,(e,t)=>{d[t]=e})}else d=$._GetTypedArray(`${e}/sparse/values`,r.componentType,u,o.values.byteOffset,h);let m=0;for(let e=0;e<c.length;e++){let t=c[e]*a;for(let e=0;e<a;e++)l[t++]=d[m++]}return l})})}return r._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 r=$._GetTypedArrayConstructor(`${e}/componentType`,t.componentType);t._data=this._loadAccessorAsync(e,t,r)}else{const r=D.Get(`${e}/bufferView`,this._gltf.bufferViews,t.bufferView);t._data=this.loadBufferViewAsync(`/bufferViews/${r.index}`,r).then(r=>$._GetTypedArray(e,t.componentType,r,t.byteOffset,t.count))}return t._data}_loadVertexBufferViewAsync(e){if(e._babylonBuffer)return e._babylonBuffer;const r=this._babylonScene.getEngine();return e._babylonBuffer=this.loadBufferViewAsync(`/bufferViews/${e.index}`,e).then(e=>new t.Buffer(r,e,!1)),e._babylonBuffer}_loadVertexAccessorAsync(e,r,s){var a;if(null===(a=r._babylonVertexBuffer)||void 0===a?void 0:a[s])return r._babylonVertexBuffer[s];r._babylonVertexBuffer||(r._babylonVertexBuffer={});const n=this._babylonScene.getEngine();if(r.sparse||null==r.bufferView)r._babylonVertexBuffer[s]=this._loadFloatAccessorAsync(e,r).then(e=>new t.VertexBuffer(n,e,s,!1));else{const a=D.Get(`${e}/bufferView`,this._gltf.bufferViews,r.bufferView);r._babylonVertexBuffer[s]=this._loadVertexBufferViewAsync(a).then(o=>{const i=$._GetNumComponents(e,r.type);return new t.VertexBuffer(n,o,s,!1,void 0,a.byteStride,void 0,r.byteOffset,i,r.componentType,r.normalized,!0,void 0,!0)})}return r._babylonVertexBuffer[s]}_loadMaterialMetallicRoughnessPropertiesAsync(e,r,s){const a=new Array,n=this._getOrCreateMaterialAdapter(s);return r&&(r.baseColorFactor?(n.baseColor=t.Color3.FromArray(r.baseColorFactor),n.geometryOpacity=r.baseColorFactor[3]):n.baseColor=t.Color3.White(),n.baseMetalness=null==r.metallicFactor?1:r.metallicFactor,n.specularRoughness=null==r.roughnessFactor?1:r.roughnessFactor,r.baseColorTexture&&a.push(this.loadTextureInfoAsync(`${e}/baseColorTexture`,r.baseColorTexture,e=>{e.name=`${s.name} (Base Color)`,n.baseColorTexture=e})),r.metallicRoughnessTexture&&(r.metallicRoughnessTexture.nonColorData=!0,a.push(this.loadTextureInfoAsync(`${e}/metallicRoughnessTexture`,r.metallicRoughnessTexture,e=>{e.name=`${s.name} (Metallic Roughness)`,n.baseMetalnessTexture=e,n.specularRoughnessTexture=e})),n.useRoughnessFromMetallicTextureGreen=!0,n.useMetallicFromMetallicTextureBlue=!0)),Promise.all(a).then(()=>{})}_loadMaterialAsync(e,t,r,s,a=()=>{}){const n=this._extensionsLoadMaterialAsync(e,t,r,s,a);if(n)return n;t._data=t._data||{};let o=t._data[s];if(!o){this.logOpen(`${e} ${t.name||""}`);const r=this.createMaterial(e,t,s);o={babylonMaterial:r,babylonMeshes:[],promise:this.loadMaterialPropertiesAsync(e,t,r)},t._data[s]=o,$.AddPointerMetadata(r,e),this._parent.onMaterialLoadedObservable.notifyObservers(r),this.logClose()}return r&&(o.babylonMeshes.push(r),r.onDisposeObservable.addOnce(()=>{const e=o.babylonMeshes.indexOf(r);-1!==e&&o.babylonMeshes.splice(e,1)})),a(o.babylonMaterial),o.promise.then(()=>o.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 r=this._pbrMaterialImpls.get("pbr");if(r)return r;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,r){this._babylonScene._blockEntityCollection=!!this._assetContainer;const s=new r.materialClass(e,this._babylonScene);s._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,s.fillMode=t,s.transparencyMode=r.materialClass.MATERIAL_OPAQUE;const a=this._getOrCreateMaterialAdapter(s);return a.transparencyAsAlphaCoverage=this._parent.transparencyAsCoverage,a.baseMetalness=1,a.specularRoughness=1,s}createMaterial(e,t,r){const s=this._extensionsCreateMaterial(e,t,r);if(s)return s;const a=t.name||`material${t.index}`;return this._createDefaultMaterial(a,r,this._selectImplForGltfMaterial(t))}loadMaterialPropertiesAsync(e,t,r){const s=this._extensionsLoadMaterialPropertiesAsync(e,t,r);if(s)return s;const a=new Array;return a.push(this.loadMaterialBasePropertiesAsync(e,t,r)),t.pbrMetallicRoughness&&a.push(this._loadMaterialMetallicRoughnessPropertiesAsync(`${e}/pbrMetallicRoughness`,t.pbrMetallicRoughness,r)),this.loadMaterialAlphaProperties(e,t,r),Promise.all(a).then(()=>{})}loadMaterialBasePropertiesAsync(e,r,s){const a=new Array,n=this._getOrCreateMaterialAdapter(s);let o;n.emissionColor=r.emissiveFactor?t.Color3.FromArray(r.emissiveFactor):new t.Color3(0,0,0),r.doubleSided&&(n.backFaceCulling=!1,n.twoSidedLighting=!0),r.normalTexture&&(r.normalTexture.nonColorData=!0,a.push(this.loadTextureInfoAsync(`${e}/normalTexture`,r.normalTexture,e=>{var t;e.name=`${s.name} (Normal)`,n.geometryNormalTexture=e,null!=(null===(t=r.normalTexture)||void 0===t?void 0:t.scale)&&(e.level=r.normalTexture.scale)})),n.setNormalMapInversions(!this._babylonScene.useRightHandedSystem,this._babylonScene.useRightHandedSystem));let i,l=1;return r.occlusionTexture&&(r.occlusionTexture.nonColorData=!0,a.push(this.loadTextureInfoAsync(`${e}/occlusionTexture`,r.occlusionTexture,e=>{e.name=`${s.name} (Occlusion)`,o=e})),null!=r.occlusionTexture.strength&&(l=r.occlusionTexture.strength)),r.emissiveTexture&&a.push(this.loadTextureInfoAsync(`${e}/emissiveTexture`,r.emissiveTexture,e=>{e.name=`${s.name} (Emissive)`,i=e})),Promise.all(a).then(()=>{o&&(n.ambientOcclusionTexture=o,n.ambientOcclusionTextureStrength=l),i&&(n.emissionColorTexture=i)})}loadMaterialAlphaProperties(e,r,s){if(0===this._pbrMaterialImpls.size)throw new Error(`${e}: Material type not supported`);const a=this._getOrCreateMaterialAdapter(s),n=a.baseColorTexture;switch(r.alphaMode||"OPAQUE"){case"OPAQUE":s.transparencyMode=t.Material.MATERIAL_OPAQUE,s.alpha=1;break;case"MASK":s.transparencyMode=t.Material.MATERIAL_ALPHATEST,a.alphaCutOff=null==r.alphaCutoff?.5:r.alphaCutoff,n&&(n.hasAlpha=!0,a.useAlphaFromBaseColorTexture=!0);break;case"BLEND":s.transparencyMode=t.Material.MATERIAL_ALPHABLEND,n&&(n.hasAlpha=!0,a.useAlphaFromBaseColorTexture=!0);break;default:throw new Error(`${e}/alphaMode: Invalid value (${r.alphaMode})`)}}loadTextureInfoAsync(e,t,r=()=>{}){const s=this._extensionsLoadTextureInfoAsync(e,t,r);if(s)return s;if(this.logOpen(`${e}`),t.texCoord>=6)throw new Error(`${e}/texCoord: Invalid value (${t.texCoord})`);const a=D.Get(`${e}/index`,this._gltf.textures,t.index);a._textureInfo=t;const n=this._loadTextureAsync(`/textures/${t.index}`,a,s=>{s.coordinatesIndex=t.texCoord||0,$.AddPointerMetadata(s,e),this._parent.onTextureLoadedObservable.notifyObservers(s),r(s)});return this.logClose(),n}_loadTextureAsync(e,t,r=()=>{}){const s=this._extensionsLoadTextureAsync(e,t,r);if(s)return s;this.logOpen(`${e} ${t.name||""}`);const a=null==t.sampler?$.DefaultSampler:D.Get(`${e}/sampler`,this._gltf.samplers,t.sampler),n=D.Get(`${e}/source`,this._gltf.images,t.source),o=this._createTextureAsync(e,a,n,r,void 0,!t._textureInfo.nonColorData);return this.logClose(),o}_createTextureAsync(e,r,s,a=()=>{},n,o){var i,l;const u=this._loadSampler(`/samplers/${r.index}`,r),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,r)=>{this._disposed||h.reject(new Error(`${e}: ${r&&r.message?r.message:t||"Failed to load texture"}`))},mimeType:null!==(i=s.mimeType)&&void 0!==i?i:t.GetMimeType(null!==(l=s.uri)&&void 0!==l?l:""),loaderOptions:n,useSRGBBuffer:!!o&&this._parent.useSRGBBuffers},m=new t.Texture(null,this._babylonScene,d);m._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,c.push(h.promise);const _=s.uri&&!t.IsBase64DataUrl(s.uri)?s.uri:void 0,p=null!=_?_:`${this._fileName}#image${s.index}`;if(c.push(this.loadImageAsync(`/images/${s.index}`,s).then(e=>{const t=`data:${this._uniqueRootUrl}${p}`;m.updateURL(t,e);const r=m.getInternalTexture();r&&(r.label=s.name)})),m.wrapU=u.wrapU,m.wrapV=u.wrapV,a(m),this._parent.useGltfTextureNames){const e=s.name||_||`image${s.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:$._GetTextureSamplingMode(e,t),wrapU:$._GetTextureWrapMode(`${e}/wrapS`,t.wrapS),wrapV:$._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 r=D.Get(`${e}/bufferView`,this._gltf.bufferViews,t.bufferView);t._data=this.loadBufferViewAsync(`/bufferViews/${r.index}`,r)}this.logClose()}return t._data}loadUriAsync(e,r,s){const a=this._extensionsLoadUriAsync(e,r,s);if(a)return a;if(!$._ValidateUri(s))throw new Error(`${e}: '${s}' is invalid`);if(t.IsBase64DataUrl(s)){const r=new Uint8Array(t.DecodeBase64UrlToBinary(s));return this.log(`${e}: Decoded ${s.substring(0,64)}... (${r.length} bytes)`),Promise.resolve(r)}return this.log(`${e}: Loading ${s}`),this._parent.preprocessUrlAsync(this._rootUrl+s).then(r=>new Promise((a,n)=>{this._parent._loadFile(this._babylonScene,r,t=>{this._disposed||(this.log(`${e}: Loaded ${s} (${t.byteLength} bytes)`),a(new Uint8Array(t)))},!0,r=>{n(new t.LoadFileError(`${e}: Failed to load '${s}'${r?": "+r.status+" "+r.statusText:""}`,r))})}))}static AddPointerMetadata(e,t){e.metadata=e.metadata||{};const r=e._internalMetadata=e._internalMetadata||{},s=r.gltf=r.gltf||{};(s.pointers=s.pointers||[]).push(t)}static _GetTextureWrapMode(e,r){switch(r=null==r?10497:r){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 (${r})`),t.Texture.WRAP_ADDRESSMODE}}static _GetTextureSamplingMode(e,r){const s=null==r.magFilter?9729:r.magFilter,a=null==r.minFilter?9987:r.minFilter;if(9729===s)switch(a){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 (${a})`),t.Texture.LINEAR_LINEAR_MIPLINEAR}else switch(9728!==s&&t.Logger.Warn(`${e}/magFilter: Invalid value (${s})`),a){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 (${a})`),t.Texture.NEAREST_NEAREST_MIPNEAREST}}static _GetTypedArrayConstructor(e,r){try{return t.GetTypedArrayConstructor(r)}catch(t){throw new Error(`${e}: ${t.message}`,{cause:t})}}static _GetTypedArray(e,r,s,a,n){const o=s.buffer;a=s.byteOffset+(a||0);const i=$._GetTypedArrayConstructor(`${e}/componentType`,r),l=t.VertexBufferGetTypeByteLength(r);return a%l!==0?(t.Logger.Warn(`${e}: Copying buffer as byte offset (${a}) is not a multiple of component type byte length (${l})`),new i(o.slice(a,a+n*l),0)):new i(o,a,n)}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,r){switch(null==r&&(r=4),r){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 (${r})`)}_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 r in t._data){const s=t._data[r];for(const t of s.babylonMeshes){t.computeWorldMatrix(!0);const r=s.babylonMaterial;e.push(r.forceCompilationAsync(t)),e.push(r.forceCompilationAsync(t,{useInstances:!0})),this._parent.useClipPlane&&(e.push(r.forceCompilationAsync(t,{clipPlane:!0})),e.push(r.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 r of t){const t=r.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,r){for(const s of this._extensions)if(s.enabled){const a=`${s.name}.${t}`,n=e;n._activeLoaderExtensionFunctions=n._activeLoaderExtensionFunctions||{};const o=n._activeLoaderExtensionFunctions;if(!o[a]){o[a]=!0;try{const e=r(s);if(e)return e}finally{delete o[a]}}}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",r=>r.loadSceneAsync&&r.loadSceneAsync(e,t))}_extensionsLoadNodeAsync(e,t,r){return this._applyExtensions(t,"loadNode",s=>s.loadNodeAsync&&s.loadNodeAsync(e,t,r))}_extensionsLoadCameraAsync(e,t,r){return this._applyExtensions(t,"loadCamera",s=>s.loadCameraAsync&&s.loadCameraAsync(e,t,r))}_extensionsLoadVertexDataAsync(e,t,r){return this._applyExtensions(t,"loadVertexData",s=>s._loadVertexDataAsync&&s._loadVertexDataAsync(e,t,r))}_extensionsLoadMeshPrimitiveAsync(e,t,r,s,a,n){return this._applyExtensions(a,"loadMeshPrimitive",o=>o._loadMeshPrimitiveAsync&&o._loadMeshPrimitiveAsync(e,t,r,s,a,n))}_extensionsLoadMaterialAsync(e,t,r,s,a){return this._applyExtensions(t,"loadMaterial",n=>n._loadMaterialAsync&&n._loadMaterialAsync(e,t,r,s,a))}_extensionsCreateMaterial(e,t,r){return this._applyExtensions(t,"createMaterial",s=>s.createMaterial&&s.createMaterial(e,t,r))}_extensionsLoadMaterialPropertiesAsync(e,t,r){return this._applyExtensions(t,"loadMaterialProperties",s=>s.loadMaterialPropertiesAsync&&s.loadMaterialPropertiesAsync(e,t,r))}_extensionsLoadTextureInfoAsync(e,t,r){return this._applyExtensions(t,"loadTextureInfo",s=>s.loadTextureInfoAsync&&s.loadTextureInfoAsync(e,t,r))}_extensionsLoadTextureAsync(e,t,r){return this._applyExtensions(t,"loadTexture",s=>s._loadTextureAsync&&s._loadTextureAsync(e,t,r))}_extensionsLoadAnimationAsync(e,t){return this._applyExtensions(t,"loadAnimation",r=>r.loadAnimationAsync&&r.loadAnimationAsync(e,t))}_extensionsLoadAnimationChannelAsync(e,t,r,s,a){return this._applyExtensions(r,"loadAnimationChannel",n=>n._loadAnimationChannelAsync&&n._loadAnimationChannelAsync(e,t,r,s,a))}_extensionsLoadSkinAsync(e,t,r){return this._applyExtensions(r,"loadSkin",s=>s._loadSkinAsync&&s._loadSkinAsync(e,t,r))}_extensionsLoadUriAsync(e,t,r){return this._applyExtensions(t,"loadUri",s=>s._loadUriAsync&&s._loadUriAsync(e,t,r))}_extensionsLoadBufferViewAsync(e,t){return this._applyExtensions(t,"loadBufferView",r=>r.loadBufferViewAsync&&r.loadBufferViewAsync(e,t))}_extensionsLoadBufferAsync(e,t,r,s){return this._applyExtensions(t,"loadBuffer",a=>a.loadBufferAsync&&a.loadBufferAsync(e,t,r,s))}static LoadExtensionAsync(e,t,r,s){if(!t.extensions)return null;const a=t.extensions[r];return a?s(`${e}/extensions/${r}`,a):null}static LoadExtraAsync(e,t,r,s){if(!t.extras)return null;const a=t.extras[r];return a?s(`${e}/extras/${r}`,a):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)}}$.DefaultSampler={index:-1};let H=!1;function K(){H||(H=!0,g._CreateGLTF2Loader=e=>new $(e))}const W="EXT_lights_image_based";class U{constructor(e){this.name=W,this._loader=e,this.enabled=this._loader.isExtensionUsed(W)}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 $.LoadExtensionAsync(e,t,this.name,(r,s)=>S(this,void 0,void 0,function*(){this._loader._allMaterialsDirtyRequired=!0;const a=new Array;a.push(this._loader.loadSceneAsync(e,t)),this._loader.logOpen(`${r}`);const n=D.Get(`${r}/light`,this._lights,s.light);return a.push(this._loadLightAsync(`/extensions/${this.name}/lights/${s.light}`,n).then(e=>{this._loader.babylonScene.environmentTexture=e})),this._loader.logClose(),yield Promise.all(a).then(()=>{})}))}_loadLightAsync(e,r){if(!r._loaded){const s=new Array;this._loader.logOpen(`${e}`);const a=new Array(r.specularImages.length);for(let t=0;t<r.specularImages.length;t++){const n=r.specularImages[t];a[t]=new Array(n.length);for(let r=0;r<n.length;r++){const o=`${e}/specularImages/${t}/${r}`;this._loader.logOpen(`${o}`);const i=n[r],l=D.Get(o,this._loader.gltf.images,i);s.push(this._loader.loadImageAsync(`/images/${i}`,l).then(e=>{a[t][r]=e})),this._loader.logClose()}}this._loader.logClose(),r._loaded=Promise.all(s).then(()=>S(this,void 0,void 0,function*(){const s=new t.RawCubeTexture(this._loader.babylonScene,null,r.specularImageSize);if(s.name=r.name||"environment",r._babylonTexture=s,null!=r.intensity&&(s.level=r.intensity),r.rotation){let e=t.Quaternion.FromArray(r.rotation);this._loader.babylonScene.useRightHandedSystem||(e=t.Quaternion.Inverse(e)),t.Matrix.FromQuaternionToRef(e,s.getReflectionTextureMatrix())}if(!r.irradianceCoefficients)throw new Error(`${e}: Irradiance coefficients are missing`);const n=t.SphericalHarmonics.FromArray(r.irradianceCoefficients);n.scaleInPlace(r.intensity),n.convertIrradianceToLambertianRadiance();const o=t.SphericalPolynomial.FromHarmonics(n),i=(a.length-1)/Math.log2(r.specularImageSize);return yield s.updateRGBDAsync(a,o,i)}))}return r._loaded.then(()=>r._babylonTexture)}}let z=!1;function q(){z||(z=!0,B(W),P(W,!0,e=>new U(e)))}q();const j="EXT_mesh_gpu_instancing";class Y{constructor(e){this.name=j,this._loader=e,this.enabled=this._loader.isExtensionUsed(j)}dispose(){this._loader=null}loadNodeAsync(e,r,s){return $.LoadExtensionAsync(e,r,this.name,(e,a)=>S(this,void 0,void 0,function*(){this._loader._disableInstancedMesh++;const n=this._loader.loadNodeAsync(`/nodes/${r.index}`,r,s);if(this._loader._disableInstancedMesh--,!r._primitiveBabylonMeshes)return yield n;const o=new Array;let i=0;const l=t=>{if(null==a.attributes[t])return void o.push(Promise.resolve(null));const r=D.Get(`${e}/attributes/${t}`,this._loader.gltf.accessors,a.attributes[t]);if(o.push(this._loader._loadFloatAccessorAsync(`/accessors/${r.bufferView}`,r)),0===i)i=r.count;else if(i!==r.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 n.then(e=>S(this,void 0,void 0,function*(){const[s,a,n,l]=yield Promise.all(o),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)s&&t.Vector3.FromArrayToRef(s,3*e,t.TmpVectors.Vector3[0]),a&&t.Quaternion.FromArrayToRef(a,4*e,t.TmpVectors.Quaternion[0]),n&&t.Vector3.FromArrayToRef(n,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 r._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 X=!1;function Q(){X||(X=!0,B(j),P(j,!0,e=>new Y(e)))}Q();const J="EXT_meshopt_compression";class Z{constructor(e){this.name=J,this.enabled=e.isExtensionUsed(J),this._loader=e}dispose(){this._loader=null}loadBufferViewAsync(e,r){return $.LoadExtensionAsync(e,r,this.name,(s,a)=>S(this,void 0,void 0,function*(){const s=r;if(s._meshOptData)return yield s._meshOptData;const n=D.Get(`${e}/buffer`,this._loader.gltf.buffers,a.buffer);return s._meshOptData=this._loader.loadBufferAsync(`/buffers/${n.index}`,n,a.byteOffset||0,a.byteLength).then(e=>S(this,void 0,void 0,function*(){return yield t.MeshoptCompression.Default.decodeGltfBufferAsync(e,a.count,a.byteStride,a.mode,a.filter)})),yield s._meshOptData}))}}let ee=!1;function te(){ee||(ee=!0,B(J),P(J,!0,e=>new Z(e)))}te();const re="EXT_texture_webp";class se{constructor(e){this.name=re,this._loader=e,this.enabled=e.isExtensionUsed(re)}dispose(){this._loader=null}_loadTextureAsync(e,t,r){return $.LoadExtensionAsync(e,t,this.name,(s,a)=>S(this,void 0,void 0,function*(){const n=null==t.sampler?$.DefaultSampler:D.Get(`${e}/sampler`,this._loader.gltf.samplers,t.sampler),o=D.Get(`${s}/source`,this._loader.gltf.images,a.source);return yield this._loader._createTextureAsync(e,n,o,e=>{r(e)},void 0,!t._textureInfo.nonColorData)}))}}let ae=!1;function ne(){ae||(ae=!0,B(re),P(re,!0,e=>new se(e)))}ne();const oe="EXT_texture_avif";class ie{constructor(e){this.name=oe,this._loader=e,this.enabled=e.isExtensionUsed(oe)}dispose(){this._loader=null}_loadTextureAsync(e,t,r){return $.LoadExtensionAsync(e,t,this.name,(s,a)=>S(this,void 0,void 0,function*(){const n=null==t.sampler?$.DefaultSampler:D.Get(`${e}/sampler`,this._loader.gltf.samplers,t.sampler),o=D.Get(`${s}/source`,this._loader.gltf.images,a.source);return yield this._loader._createTextureAsync(e,n,o,e=>{r(e)},void 0,!t._textureInfo.nonColorData)}))}}let le=!1;function ue(){le||(le=!0,B(oe),P(oe,!0,e=>new ie(e)))}ue();const ce="EXT_lights_ies";class he{constructor(e){this.name=ce,this._loader=e,this.enabled=this._loader.isExtensionUsed(ce)}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,D.Assign(this._lights)}}loadNodeAsync(e,r,s){return $.LoadExtensionAsync(e,r,this.name,(a,n)=>S(this,void 0,void 0,function*(){let o,i;this._loader._allMaterialsDirtyRequired=!0;const l=yield this._loader.loadNodeAsync(e,r,e=>{i=D.Get(a,this._lights,n.light);const r=i.name||e.name;this._loader.babylonScene._blockEntityCollection=!!this._loader._assetContainer,o=new t.SpotLight(r,t.Vector3.Zero(),t.Vector3.Backward(),0,1,this._loader.babylonScene),o.angle=Math.PI/2,o.innerAngle=0,o._parentContainer=this._loader._assetContainer,this._loader.babylonScene._blockEntityCollection=!1,i._babylonLight=o,o.falloffType=t.Light.FALLOFF_GLTF,o.diffuse=n.color?t.Color3.FromArray(n.color):t.Color3.White(),o.intensity=n.multiplier||1,o.range=Number.MAX_VALUE,o.parent=e,this._loader._babylonLights.push(o),$.AddPointerMetadata(o,a),s(e)});let u;if(i.uri)u=yield this._loader.loadUriAsync(e,i,i.uri);else{const t=D.Get(`${e}/bufferView`,this._loader.gltf.bufferViews,i.bufferView);u=yield this._loader.loadBufferViewAsync(`/bufferViews/${t.index}`,t)}return o.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 de=!1;function me(){de||(de=!0,B(ce),P(ce,!0,e=>new he(e)))}me();const _e="KHR_draco_mesh_compression";class pe{constructor(e){this.name=_e,this.useNormalizedFlagFromAccessor=!0,this._loader=e,this.enabled=t.DracoDecoder.DefaultAvailable&&this._loader.isExtensionUsed(_e)}dispose(){delete this.dracoDecoder,this._loader=null}_loadVertexDataAsync(e,r,s){return $.LoadExtensionAsync(e,r,this.name,(a,n)=>S(this,void 0,void 0,function*(){if(null!=r.mode&&4!==r.mode&&5!==r.mode)throw new Error(`${e}: Unsupported mode ${r.mode}`);const o={},i={},l=(e,t)=>{const a=n.attributes[e];if(null!=a&&(s._delayInfo=s._delayInfo||[],-1===s._delayInfo.indexOf(t)&&s._delayInfo.push(t),o[t]=a,this.useNormalizedFlagFromAccessor)){const s=D.TryGet(this._loader.gltf.accessors,r.attributes[e]);s&&(i[t]=s.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=D.Get(a,this._loader.gltf.bufferViews,n.bufferView);return u._dracoBabylonGeometry||(u._dracoBabylonGeometry=this._loader.loadBufferViewAsync(`/bufferViews/${u.index}`,u).then(a=>S(this,void 0,void 0,function*(){const n=this.dracoDecoder||t.DracoDecoder.Default,l=D.TryGet(this._loader.gltf.accessors,r.attributes.POSITION),u=this._loader.parent.alwaysComputeBoundingBox||s.skeleton||!l?null:V(l);return yield n._decodeMeshToGeometryForGltfAsync(s.name,this._loader.babylonScene,a,o,i,u).catch(t=>{throw new Error(`${e}: ${t.message}`)})}))),yield u._dracoBabylonGeometry}))}}let fe=!1;function ge(){fe||(fe=!0,B(_e),P(_e,!0,e=>new pe(e)))}ge();const be="KHR_gaussian_splatting",ye=.28209479177387814,Te=[0,3,5,7];function ve(e){return e<=0?0:e>=255?255:e+.5|0}class xe{constructor(e){this.name=be,this._loader=e,this.enabled=this._loader.isExtensionUsed(be)}dispose(){this._loader=null}_loadMeshPrimitiveAsync(e,r,s,a,n,o){return $.LoadExtensionAsync(e,n,this.name,s=>S(this,void 0,void 0,function*(){if(null!=n.mode&&0!==n.mode)throw new Error(`${s}: Gaussian splatting primitives must use POINTS mode`);const a=this._loader,i=t=>{const r=n.attributes[t];if(null==r)return null;const s=D.Get(`${e}/attributes/${t}`,a.gltf.accessors,r);return a._loadFloatAccessorAsync(`/accessors/${s.index}`,s)},l=i("POSITION");if(!l)throw new Error(`${s}: Gaussian splatting primitive is missing the POSITION attribute`);let u=0;const c=[];for(let e=1;e<=3&&null!=n.attributes[`KHR_gaussian_splatting:SH_DEGREE_${e}_COEF_0`];e++){u=e;for(let t=0;t<Te[e];t++)c.push(`KHR_gaussian_splatting:SH_DEGREE_${e}_COEF_${t}`)}const h=a.babylonScene;h._blockEntityCollection=!!a._assetContainer;const d=new t.GaussianSplattingMesh(r,null,h);d._parentContainer=a._assetContainer,h._blockEntityCollection=!1,$.AddPointerMetadata(d,e),a.parent.onMeshLoadedObservable.notifyObservers(d),o(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))]),v=_.length/3,x=y?y.length/v:0,A=new ArrayBuffer(32*v),C=new Float32Array(A),R=new Uint8Array(A);let w=null;if(u>0){const e=3*((u+1)*(u+1)-1),r=Math.ceil(e/16),s=m.maxTextureSize,a=Math.ceil(v/s);w=t.AllocateShBuffers(r,a*s*4*4)}for(let e=0;e<v;e++){const t=8*e,r=32*e,s=3*e;if(C[t+0]=_[s+0],C[t+1]=_[s+1],C[t+2]=_[s+2],C[t+3]=f?f[s+0]:1,C[t+4]=f?f[s+1]:1,C[t+5]=f?f[s+2]:1,b)R[r+24]=ve(255*(.5+ye*b[s+0])),R[r+25]=ve(255*(.5+ye*b[s+1])),R[r+26]=ve(255*(.5+ye*b[s+2]));else if(y){const t=e*x;R[r+24]=ve(255*y[t+0]),R[r+25]=ve(255*y[t+1]),R[r+26]=ve(255*y[t+2])}else R[r+24]=255,R[r+25]=255,R[r+26]=255;R[r+27]=g?ve(255*g[e]):y&&x>=4?ve(255*y[e*x+3]):255;const a=4*e,n=p?p[a+0]:0,o=p?p[a+1]:0,i=p?p[a+2]:0,l=p?p[a+3]:1;if(R[r+28]=ve(127.5*l+127.5),R[r+29]=ve(127.5*n+127.5),R[r+30]=ve(127.5*o+127.5),R[r+31]=ve(127.5*i+127.5),w){const t=16*e;for(let e=0;e<T.length;e++){const r=T[e];if(r)for(let a=0;a<3;a++){const n=3*e+a,o=15&n;w[n>>4][t+o]=ve(128*r[s+a]+128)}}}}return yield d.updateDataAsync(A,null!=w?w:void 0,void 0,u||void 0),d}))}}let Ae=!1;function Ce(){Ae||(Ae=!0,B(be),P(be,!0,e=>new xe(e)))}Ce();const Re="KHR_lights_punctual";class we{constructor(e){this.name=Re,this._loader=e,this.enabled=this._loader.isExtensionUsed(Re)}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,D.Assign(this._lights)}}loadNodeAsync(e,r,s){return $.LoadExtensionAsync(e,r,this.name,(a,n)=>S(this,void 0,void 0,function*(){return this._loader._allMaterialsDirtyRequired=!0,yield this._loader.loadNodeAsync(e,r,e=>{let r;const o=D.Get(a,this._lights,n.light),i=o.name||e.name;switch(this._loader.babylonScene._blockEntityCollection=!!this._loader._assetContainer,o.type){case"directional":{const e=new t.DirectionalLight(i,t.Vector3.Backward(),this._loader.babylonScene);e.position.setAll(0),r=e;break}case"point":r=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*(o.spot&&o.spot.outerConeAngle||Math.PI/4),e.innerAngle=2*(o.spot&&o.spot.innerConeAngle||0),r=e;break}default:throw this._loader.babylonScene._blockEntityCollection=!1,new Error(`${a}: Invalid light type (${o.type})`)}r._parentContainer=this._loader._assetContainer,this._loader.babylonScene._blockEntityCollection=!1,o._babylonLight=r,r.falloffType=t.Light.FALLOFF_GLTF,r.diffuse=o.color?t.Color3.FromArray(o.color):t.Color3.White(),r.intensity=null==o.intensity?1:o.intensity,r.range=null==o.range?Number.MAX_VALUE:o.range,r.parent=e,this._loader._babylonLights.push(r),$.AddPointerMetadata(r,a),s(e)})}))}}let Me=!1;function Oe(){Me||(Me=!0,B(Re),P(Re,!0,e=>new we(e)))}Oe();const Le="EXT_lights_area";class Fe{constructor(e){this.name=Le,this._loader=e,this.enabled=this._loader.isExtensionUsed(Le)}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,D.Assign(this._lights)}}loadNodeAsync(e,r,s){return $.LoadExtensionAsync(e,r,this.name,(a,n)=>S(this,void 0,void 0,function*(){return this._loader._allMaterialsDirtyRequired=!0,yield this._loader.loadNodeAsync(e,r,e=>{var r;let o;const i=D.Get(a,this._lights,n.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===(r=i.rect)||void 0===r?void 0:r.aspect)?i.rect.aspect*u:u,s=u;o=new t.RectAreaLight(l,t.Vector3.Zero(),e,s,this._loader.babylonScene);break}case"disk":{const e=Math.sqrt(u*u*.25*Math.PI);o=new t.RectAreaLight(l,t.Vector3.Zero(),e,e,this._loader.babylonScene);break}default:throw this._loader.babylonScene._blockEntityCollection=!1,new Error(`${a}: Invalid area light type (${i.type})`)}o._parentContainer=this._loader._assetContainer,this._loader.babylonScene._blockEntityCollection=!1,i._babylonLight=o,o.falloffType=t.Light.FALLOFF_GLTF,o.diffuse=i.color?t.Color3.FromArray(i.color):t.Color3.White(),o.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,o.parent=c,this._loader._babylonLights.push(o),$.AddPointerMetadata(o,a),s(e)})}))}}let Ee=!1;function Se(){Ee||(Ee=!0,B(Le),P(Le,!0,e=>new Fe(e)))}Se();const ke="KHR_materials_pbrSpecularGlossiness";class Ie{constructor(e){this.name=ke,this.order=200,this._loader=e,this.enabled=this._loader.isExtensionUsed(ke)}dispose(){this._loader=null}loadMaterialPropertiesAsync(e,t,r){return $.LoadExtensionAsync(e,t,this.name,(s,a)=>S(this,void 0,void 0,function*(){const n=new Array;return n.push(this._loader.loadMaterialBasePropertiesAsync(e,t,r)),n.push(this._loadSpecularGlossinessPropertiesAsync(s,a,r)),this._loader.loadMaterialAlphaProperties(e,t,r),yield Promise.all(n).then(()=>{})}))}_loadSpecularGlossinessPropertiesAsync(e,r,s){const a=this._loader._getOrCreateMaterialAdapter(s),n=new Array;return a.configureSpecularGlossiness(),r.diffuseFactor?(a.baseColor=t.Color3.FromArray(r.diffuseFactor),s.alpha=r.diffuseFactor[3]):a.baseColor=t.Color3.White(),a.specularColor=r.specularFactor?t.Color3.FromArray(r.specularFactor):t.Color3.White(),a.glossiness=null==r.glossinessFactor?1:r.glossinessFactor,r.diffuseTexture&&n.push(this._loader.loadTextureInfoAsync(`${e}/diffuseTexture`,r.diffuseTexture,e=>{e.name=`${s.name} (Diffuse)`,a.baseColorTexture=e})),r.specularGlossinessTexture&&n.push(this._loader.loadTextureInfoAsync(`${e}/specularGlossinessTexture`,r.specularGlossinessTexture,e=>{e.name=`${s.name} (Specular Glossiness)`,a.specularColorTexture=e})),Promise.all(n).then(()=>{})}}let Pe=!1;function Be(){Pe||(Pe=!0,B(ke),P(ke,!0,e=>new Ie(e)))}Be();const Ne="KHR_materials_unlit";class Ge{constructor(e){this.name=Ne,this.order=210,this._loader=e,this.enabled=this._loader.isExtensionUsed(Ne)}dispose(){this._loader=null}loadMaterialPropertiesAsync(e,t,r){return $.LoadExtensionAsync(e,t,this.name,()=>S(this,void 0,void 0,function*(){return yield this._loadUnlitPropertiesAsync(e,t,r)}))}_loadUnlitPropertiesAsync(e,r,s){const a=this._loader._getOrCreateMaterialAdapter(s),n=new Array,o=r.pbrMetallicRoughness;return o&&(o.baseColorFactor&&(a.baseColor=t.Color3.FromArray(o.baseColorFactor),a.geometryOpacity=o.baseColorFactor[3]),o.baseColorTexture&&n.push(this._loader.loadTextureInfoAsync(`${e}/baseColorTexture`,o.baseColorTexture,e=>{e.name=`${s.name} (Base Color)`,a.baseColorTexture=e}))),a.isUnlit=!0,r.doubleSided&&(a.backFaceCulling=!1,a.twoSidedLighting=!0),this._loader.loadMaterialAlphaProperties(e,r,s),Promise.all(n).then(()=>{})}}let De=!1;function Ve(){De||(De=!0,B(Ne),P(Ne,!0,e=>new Ge(e)))}Ve();const $e="KHR_materials_clearcoat";class He{constructor(e){this.name=$e,this.order=190,this._loader=e,this.enabled=this._loader.isExtensionUsed($e)}dispose(){this._loader=null}loadMaterialPropertiesAsync(e,t,r){return $.LoadExtensionAsync(e,t,this.name,(s,a)=>S(this,void 0,void 0,function*(){const n=new Array;n.push(this._loader.loadMaterialPropertiesAsync(e,t,r)),n.push(this._loadClearCoatPropertiesAsync(s,a,r)),yield Promise.all(n)}))}_loadClearCoatPropertiesAsync(e,t,r){const s=this._loader._getOrCreateMaterialAdapter(r),a=new Array;return s.configureCoat(),s.coatWeight=void 0!==t.clearcoatFactor?t.clearcoatFactor:0,s.coatRoughness=void 0!==t.clearcoatRoughnessFactor?t.clearcoatRoughnessFactor:0,t.clearcoatTexture&&a.push(this._loader.loadTextureInfoAsync(`${e}/clearcoatTexture`,t.clearcoatTexture,e=>{e.name=`${r.name} (ClearCoat)`,s.coatWeightTexture=e})),t.clearcoatRoughnessTexture&&(t.clearcoatRoughnessTexture.nonColorData=!0,a.push(this._loader.loadTextureInfoAsync(`${e}/clearcoatRoughnessTexture`,t.clearcoatRoughnessTexture,e=>{e.name=`${r.name} (ClearCoat Roughness)`,s.coatRoughnessTexture=e}))),t.clearcoatNormalTexture&&(t.clearcoatNormalTexture.nonColorData=!0,a.push(this._loader.loadTextureInfoAsync(`${e}/clearcoatNormalTexture`,t.clearcoatNormalTexture,e=>{var a;e.name=`${r.name} (ClearCoat Normal)`,s.geometryCoatNormalTexture=e,null!=(null===(a=t.clearcoatNormalTexture)||void 0===a?void 0:a.scale)&&(s.geometryCoatNormalTextureScale=t.clearcoatNormalTexture.scale)})),s.setNormalMapInversions(!r.getScene().useRightHandedSystem,r.getScene().useRightHandedSystem)),Promise.all(a).then(()=>{})}}let Ke=!1;function We(){Ke||(Ke=!0,B($e),P($e,!0,e=>new He(e)))}We();const Ue="KHR_materials_coat";class ze{constructor(e){this.name=Ue,this.order=191,this.useOpenPBR=!1,this._loader=e,this.enabled=this._loader.isExtensionUsed(Ue)}dispose(){this._loader=null}loadMaterialPropertiesAsync(e,t,r){return $.LoadExtensionAsync(e,t,this.name,(s,a)=>S(this,void 0,void 0,function*(){const n=new Array;n.push(this._loader.loadMaterialPropertiesAsync(e,t,r)),t.extensions&&t.extensions.KHR_materials_openpbr&&(this.useOpenPBR=!0),n.push(this._loadCoatPropertiesAsync(s,a,r)),yield Promise.all(n)}))}_loadCoatPropertiesAsync(e,r,s){var a,n;const o=this._loader._getOrCreateMaterialAdapter(s),i=new Array;o.configureCoat(),o.coatWeight=void 0!==r.coatFactor?r.coatFactor:0,o.coatRoughness=void 0!==r.coatRoughnessFactor?r.coatRoughnessFactor:0,r.coatTexture&&i.push(this._loader.loadTextureInfoAsync(`${e}/coatTexture`,r.coatTexture,e=>{e.name=`${s.name} (Coat)`,o.coatWeightTexture=e})),r.coatRoughnessTexture&&(r.coatRoughnessTexture.nonColorData=!0,i.push(this._loader.loadTextureInfoAsync(`${e}/coatRoughnessTexture`,r.coatRoughnessTexture,e=>{e.name=`${s.name} (Coat Roughness)`,o.coatRoughnessTexture=e}))),r.coatNormalTexture&&(r.coatNormalTexture.nonColorData=!0,i.push(this._loader.loadTextureInfoAsync(`${e}/coatNormalTexture`,r.coatNormalTexture,e=>{var t;e.name=`${s.name} (Coat Normal)`,o.geometryCoatNormalTexture=e,null!=(null===(t=r.coatNormalTexture)||void 0===t?void 0:t.scale)&&(o.geometryCoatNormalTextureScale=r.coatNormalTexture.scale)})),o.setNormalMapInversions(!s.getScene().useRightHandedSystem,s.getScene().useRightHandedSystem)),o.coatDarkening=void 0!==r.coatDarkeningFactor?r.coatDarkeningFactor:1,o.coatIor=void 0!==r.coatIor?r.coatIor:1.5;const l=t.Color3.White();void 0!==r.coatColorFactor&&l.fromArray(r.coatColorFactor),o.coatColor=l,r.coatColorTexture&&i.push(this._loader.loadTextureInfoAsync(`${e}/coatColorTexture`,r.coatColorTexture,e=>{e.name=`${s.name} (Coat Color)`,o.coatColorTexture=e}));const u=null!==(a=r.coatAnisotropyStrength)&&void 0!==a?a:0,c=null!==(n=r.coatAnisotropyRotation)&&void 0!==n?n:0;return o.coatRoughnessAnisotropy=u,o.geometryCoatTangentAngle=c,this.useOpenPBR||o.configureGltfStyleAnisotropy(!0),r.coatAnisotropyTexture&&(r.coatAnisotropyTexture.nonColorData=!0,i.push(this._loader.loadTextureInfoAsync(`${e}/coatAnisotropyTexture`,r.coatAnisotropyTexture,e=>{e.name=`${s.name} (Coat Anisotropy)`,o.geometryCoatTangentTexture=e}))),Promise.all(i).then(()=>{})}}let qe=!1;function je(){qe||(qe=!0,B(Ue),P(Ue,!0,e=>new ze(e)))}je();const Ye="KHR_materials_iridescence";class Xe{constructor(e){this.name=Ye,this.order=195,this._loader=e,this.enabled=this._loader.isExtensionUsed(Ye)}dispose(){this._loader=null}loadMaterialPropertiesAsync(e,t,r){return $.LoadExtensionAsync(e,t,this.name,(s,a)=>S(this,void 0,void 0,function*(){const n=new Array;return n.push(this._loader.loadMaterialPropertiesAsync(e,t,r)),n.push(this._loadIridescencePropertiesAsync(s,a,r)),yield Promise.all(n).then(()=>{})}))}_loadIridescencePropertiesAsync(e,t,r){var s,a,n,o,i;const l=this._loader._getOrCreateMaterialAdapter(r),u=new Array;return l.thinFilmWeight=null!==(s=t.iridescenceFactor)&&void 0!==s?s:0,l.thinFilmIor=null!==(n=null!==(a=t.iridescenceIor)&&void 0!==a?a:t.iridescenceIOR)&&void 0!==n?n:1.3,l.thinFilmThicknessMinimum=null!==(o=t.iridescenceThicknessMinimum)&&void 0!==o?o: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=`${r.name} (Iridescence)`,l.thinFilmWeightTexture=e})),t.iridescenceThicknessTexture&&u.push(this._loader.loadTextureInfoAsync(`${e}/iridescenceThicknessTexture`,t.iridescenceThicknessTexture,e=>{e.name=`${r.name} (Iridescence Thickness)`,l.thinFilmThicknessTexture=e})),Promise.all(u).then(()=>{})}}let Qe=!1;function Je(){Qe||(Qe=!0,B(Ye),P(Ye,!0,e=>new Xe(e)))}Je();const Ze="KHR_materials_anisotropy";class et{constructor(e){this.name=Ze,this.order=195,this._loader=e,this.enabled=this._loader.isExtensionUsed(Ze)}dispose(){this._loader=null}loadMaterialPropertiesAsync(e,t,r){return $.LoadExtensionAsync(e,t,this.name,(s,a)=>S(this,void 0,void 0,function*(){const n=new Array;n.push(this._loader.loadMaterialPropertiesAsync(e,t,r)),n.push(this._loadAnisotropyPropertiesAsync(s,a,r)),yield Promise.all(n)}))}_loadAnisotropyPropertiesAsync(e,t,r){return S(this,void 0,void 0,function*(){var s,a,n;const o=this._loader._getOrCreateMaterialAdapter(r),i=new Array,l=null!==(s=t.anisotropyStrength)&&void 0!==s?s:0,u=null!==(a=t.anisotropyRotation)&&void 0!==a?a:0;o.specularRoughnessAnisotropy=l,o.geometryTangentAngle=u;const c=null!==(n=t.extensions)&&void 0!==n?n:{};c.EXT_materials_anisotropy_openpbr&&c.EXT_materials_anisotropy_openpbr.openPbrAnisotropyEnabled||o.configureGltfStyleAnisotropy(!0),t.anisotropyTexture&&(t.anisotropyTexture.nonColorData=!0,i.push(this._loader.loadTextureInfoAsync(`${e}/anisotropyTexture`,t.anisotropyTexture,e=>{e.name=`${r.name} (Anisotropy Intensity)`,o.geometryTangentTexture=e}))),yield Promise.all(i)})}}let tt=!1;function rt(){tt||(tt=!0,B(Ze),P(Ze,!0,e=>new et(e)))}rt();const st="KHR_materials_emissive_strength";class at{constructor(e){this.name=st,this.order=170,this._loader=e,this.enabled=this._loader.isExtensionUsed(st)}dispose(){this._loader=null}loadMaterialPropertiesAsync(e,t,r){return $.LoadExtensionAsync(e,t,this.name,(s,a)=>S(this,void 0,void 0,function*(){return yield this._loader.loadMaterialPropertiesAsync(e,t,r),this._loadEmissiveProperties(s,a,r),yield Promise.resolve()}))}_loadEmissiveProperties(e,t,r){void 0!==t.emissiveStrength&&(this._loader._getOrCreateMaterialAdapter(r).emissionLuminance=t.emissiveStrength)}}let nt=!1;function ot(){nt||(nt=!0,B(st),P(st,!0,e=>new at(e)))}ot();const it="KHR_materials_sheen";class lt{constructor(e){this.name=it,this.order=190,this._loader=e,this.enabled=this._loader.isExtensionUsed(it)}dispose(){this._loader=null}loadMaterialPropertiesAsync(e,t,r){return $.LoadExtensionAsync(e,t,this.name,(s,a)=>S(this,void 0,void 0,function*(){const n=new Array;return n.push(this._loader.loadMaterialPropertiesAsync(e,t,r)),n.push(this._loadSheenPropertiesAsync(s,a,r)),yield Promise.all(n).then(()=>{})}))}_loadSheenPropertiesAsync(e,r,s){const a=this._loader._getOrCreateMaterialAdapter(s),n=new Array;a.configureFuzz();const o=void 0!==r.sheenColorFactor?t.Color3.FromArray(r.sheenColorFactor):t.Color3.Black(),i=void 0!==r.sheenRoughnessFactor?r.sheenRoughnessFactor:0;return a.fuzzWeight=1,a.fuzzColor=o,a.fuzzRoughness=i,r.sheenColorTexture&&n.push(this._loader.loadTextureInfoAsync(`${e}/sheenColorTexture`,r.sheenColorTexture,e=>{e.name=`${s.name} (Sheen Color)`,a.fuzzColorTexture=e})),r.sheenRoughnessTexture&&(r.sheenRoughnessTexture.nonColorData=!0,n.push(this._loader.loadTextureInfoAsync(`${e}/sheenRoughnessTexture`,r.sheenRoughnessTexture,e=>{e.name=`${s.name} (Sheen Roughness)`,a.fuzzRoughnessTexture=e}))),Promise.all(n).then(()=>{})}}let ut=!1;function ct(){ut||(ut=!0,B(it),P(it,!0,e=>new lt(e)))}ct();const ht="KHR_materials_fuzz";class dt{constructor(e){this.name=ht,this.order=190,this._loader=e,this.enabled=this._loader.isExtensionUsed(ht)}dispose(){this._loader=null}loadMaterialPropertiesAsync(e,t,r){return $.LoadExtensionAsync(e,t,this.name,(s,a)=>S(this,void 0,void 0,function*(){const n=new Array;return n.push(this._loader.loadMaterialPropertiesAsync(e,t,r)),n.push(this._loadFuzzPropertiesAsync(s,a,r)),yield Promise.all(n).then(()=>{})}))}_loadFuzzPropertiesAsync(e,r,s){const a=this._loader._getOrCreateMaterialAdapter(s),n=new Array;return a.configureFuzz(),a.fuzzWeight=void 0!==r.fuzzFactor?r.fuzzFactor:0,a.fuzzColor=void 0!==r.fuzzColorFactor?t.Color3.FromArray(r.fuzzColorFactor):t.Color3.White(),a.fuzzRoughness=void 0!==r.fuzzRoughnessFactor?r.fuzzRoughnessFactor:.5,r.fuzzTexture&&n.push(this._loader.loadTextureInfoAsync(`${e}/fuzzTexture`,r.fuzzTexture,e=>{e.name=`${s.name} (Fuzz)`,a.fuzzWeightTexture=e})),r.fuzzColorTexture&&n.push(this._loader.loadTextureInfoAsync(`${e}/fuzzColorTexture`,r.fuzzColorTexture,e=>{e.name=`${s.name} (Fuzz Color)`,a.fuzzColorTexture=e})),r.fuzzRoughnessTexture&&(r.fuzzRoughnessTexture.nonColorData=!0,n.push(this._loader.loadTextureInfoAsync(`${e}/fuzzRoughnessTexture`,r.fuzzRoughnessTexture,e=>{e.name=`${s.name} (Fuzz Roughness)`,a.fuzzRoughnessTexture=e}))),Promise.all(n).then(()=>{})}}let mt=!1;function _t(){mt||(mt=!0,B(ht),P(ht,!0,e=>new dt(e)))}_t();const pt="KHR_materials_specular";class ft{constructor(e){this.name=pt,this.order=190,this._loader=e,this.enabled=this._loader.isExtensionUsed(pt)}dispose(){this._loader=null}loadMaterialPropertiesAsync(e,t,r){return $.LoadExtensionAsync(e,t,this.name,(s,a)=>S(this,void 0,void 0,function*(){const n=new Array;n.push(this._loader.loadMaterialPropertiesAsync(e,t,r)),n.push(this._loadSpecularPropertiesAsync(s,a,r));const o=this._loader._getOrCreateMaterialAdapter(r);return a.extensions&&a.extensions.EXT_materials_specular_edge_color&&a.extensions.EXT_materials_specular_edge_color.specularEdgeColorEnabled&&o.enableSpecularEdgeColor(!0),yield Promise.all(n).then(()=>{})}))}_loadSpecularPropertiesAsync(e,r,s){var a;const n=this._loader._getOrCreateMaterialAdapter(s),o=new Array;return n.specularWeight=null!==(a=r.specularFactor)&&void 0!==a?a:1,n.specularColor=void 0!==r.specularColorFactor?t.Color3.FromArray(r.specularColorFactor):new t.Color3(1,1,1),r.specularTexture&&(r.specularTexture.nonColorData=!0,o.push(this._loader.loadTextureInfoAsync(`${e}/specularTexture`,r.specularTexture,e=>{e.name=`${s.name} (Specular)`,n.specularWeightTexture=e}))),r.specularColorTexture&&o.push(this._loader.loadTextureInfoAsync(`${e}/specularColorTexture`,r.specularColorTexture,e=>{e.name=`${s.name} (Specular Color)`,n.specularColorTexture=e})),Promise.all(o).then(()=>{})}}let gt=!1;function bt(){gt||(gt=!0,B(pt),P(pt,!0,e=>new ft(e)))}bt();const yt="KHR_materials_ior";class Tt{constructor(e){this.name=yt,this.order=180,this._loader=e,this.enabled=this._loader.isExtensionUsed(yt)}dispose(){this._loader=null}loadMaterialPropertiesAsync(e,t,r){return $.LoadExtensionAsync(e,t,this.name,(s,a)=>S(this,void 0,void 0,function*(){const n=new Array;return n.push(this._loader.loadMaterialPropertiesAsync(e,t,r)),n.push(this._loadIorPropertiesAsync(s,a,r)),yield Promise.all(n).then(()=>{})}))}_loadIorPropertiesAsync(e,t,r){const s=this._loader._getOrCreateMaterialAdapter(r),a=void 0!==t.ior?t.ior:Tt._DEFAULT_IOR;return s.specularIor=a,Promise.resolve()}}Tt._DEFAULT_IOR=1.5;let vt=!1;function xt(){vt||(vt=!0,B(yt),P(yt,!0,e=>new Tt(e)))}xt();const At="KHR_materials_variants";class Ct{constructor(e){this.name=At,this._loader=e,this.enabled=this._loader.isExtensionUsed(At)&&!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 Ct.GetAvailableVariants(e)}static SelectVariant(e,t){const r=this._GetExtensionMetadata(e);if(!r)throw new Error(`Cannot select variant on a glTF mesh that does not have the ${At} extension`);const s=e=>{const t=r.variants[e];if(t)for(const e of t)e.mesh.material=e.material};if(t instanceof Array)for(const e of t)s(e);else s(t);r.lastSelected=t}selectVariant(e,t){Ct.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 ${At} extension`);for(const e of t.original)e.mesh.material=e.material;t.lastSelected=null}reset(e){Ct.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 ${At} extension`);return t.lastSelected}getLastSelectedVariant(e){return Ct.GetLastSelectedVariant(e)}static _GetExtensionMetadata(e){var t,r;return(null===(r=null===(t=null==e?void 0:e._internalMetadata)||void 0===t?void 0:t.gltf)||void 0===r?void 0:r[At])||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 r=this._loader.parent.extensionOptions[At];(null==r?void 0:r.defaultVariant)&&Ct.SelectVariant(t,r.defaultVariant),null===(e=null==r?void 0:r.onLoaded)||void 0===e||e.call(r,{get variants(){return Ct.GetAvailableVariants(t)},get selectedVariant(){const e=Ct.GetLastSelectedVariant(t);return e?Array.isArray(e)?e[0]:e:Ct.GetAvailableVariants(t)[0]},set selectedVariant(e){Ct.SelectVariant(t,e)}})}}_loadMeshPrimitiveAsync(e,r,s,a,n,o){return $.LoadExtensionAsync(e,n,this.name,(i,l)=>S(this,void 0,void 0,function*(){const u=new Array;return u.push(this._loader._loadMeshPrimitiveAsync(e,r,s,a,n,r=>{if(o(r),r instanceof t.Mesh){const t=$._GetDrawMode(e,n.mode),s=this._loader.rootBabylonMesh,a=s?s._internalMetadata=s._internalMetadata||{}:{},o=a.gltf=a.gltf||{},c=o[At]=o[At]||{lastSelected:null,original:[],variants:{}};c.original.push({mesh:r,material:r.material});for(let e=0;e<l.mappings.length;++e){const a=l.mappings[e],n=D.Get(`${i}/mappings/${e}/material`,this._loader.gltf.materials,a.material);u.push(this._loader._loadMaterialAsync(`#/materials/${a.material}`,n,r,t,e=>{for(let t=0;t<a.variants.length;++t){const n=a.variants[t],o=D.Get(`/extensions/${At}/variants/${n}`,this._variants,n);c.variants[o.name]=c.variants[o.name]||[],c.variants[o.name].push({mesh:r,material:e}),r.onClonedObservable.add(e=>{const t=e;let a,n=t;do{if(n=n.parent,!n)return;a=Ct._GetExtensionMetadata(n)}while(null===a);if(s&&a===Ct._GetExtensionMetadata(s)){n._internalMetadata={};for(const e in s._internalMetadata)n._internalMetadata[e]=s._internalMetadata[e];n._internalMetadata.gltf=[];for(const e in s._internalMetadata.gltf)n._internalMetadata.gltf[e]=s._internalMetadata.gltf[e];n._internalMetadata.gltf[At]={lastSelected:null,original:[],variants:{}};for(const e of a.original)n._internalMetadata.gltf[At].original.push({mesh:e.mesh,material:e.material});for(const e in a.variants)if(Object.prototype.hasOwnProperty.call(a.variants,e)){n._internalMetadata.gltf[At].variants[e]=[];for(const t of a.variants[e])n._internalMetadata.gltf[At].variants[e].push({mesh:t.mesh,material:t.material})}a=n._internalMetadata.gltf[At]}for(const e of a.original)e.mesh===r&&(e.mesh=t);for(const e of a.variants[o.name])e.mesh===r&&(e.mesh=t)})}}))}}})),yield Promise.all(u).then(([e])=>e)}))}}let Rt=!1;function wt(){Rt||(Rt=!0,B(At),P(At,!0,e=>new Ct(e)))}wt();class Mt{static _GetDefaultOptions(){return{renderSize:1024,samples:4,lodGenerationScale:1,lodGenerationOffset:-4,renderTargetTextureType:t.Constants.TEXTURETYPE_HALF_FLOAT,generateMipmaps:!0}}constructor(e,r){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({},Mt._GetDefaultOptions()),e),this._scene=r,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),r=this._options;this._options=t,t.renderSize===r.renderSize&&t.renderTargetTextureType===r.renderTargetTextureType&&t.generateMipmaps===r.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 r of this._materialImpls)if(e instanceof r.materialClass){t=new r.adapterClass(e),this._adapterCache.set(e,t);break}return t}_classifyMeshMaterials(e){const r=e.material;if(!r)return"opaque";if(!(r instanceof t.MultiMaterial)){const e=this._getOrCreateAdapter(r);return e&&e.isTranslucent()?(e.refractionBackgroundTexture=this._opaqueRenderTarget,"transparent"):"opaque"}let s=!1,a=!1;const n=new Set;for(let e=0;e<r.subMaterials.length;e++){const t=r.subMaterials[e];if(!t){a=!0;continue}const o=this._getOrCreateAdapter(t);o&&o.isTranslucent()?(o.refractionBackgroundTexture=this._opaqueRenderTarget,s=!0,n.add(e)):a=!0}return s&&a?(this._translucentMaterialIndices.set(e,n),this._rebuildOpaqueOnlySubMeshes(e,n),"mixed"):(this._translucentMaterialIndices.delete(e),this._opaqueOnlySubMeshes.delete(e),s?"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),r=this._opaqueMeshesCache.indexOf(e);"transparent"===this._classifyMeshMaterials(e)?-1!==r?(this._opaqueMeshesCache.splice(r,1),this._transparentMeshesCache.push(e)):-1===t&&this._transparentMeshesCache.push(e):-1!==t?(this._transparentMeshesCache.splice(t,1),this._opaqueMeshesCache.push(e)):-1===r&&this._opaqueMeshesCache.push(e)}_isRenderTargetValid(){var e;return null!==(null===(e=this._opaqueRenderTarget)||void 0===e?void 0:e.getInternalTexture())}_setupRenderTargets(){var e,r;let s;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!==(r=null===(e=this._options.clearColor)||void 0===e?void 0:e.clone())&&void 0!==r?r: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=>{s=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],r=e.value[1];t.subMeshes&&(this._savedSubMeshes.set(t,t.subMeshes),t.subMeshes=r)}}),this._opaqueRenderTarget.onAfterUnbindObservable.add(()=>{this._scene.environmentIntensity=s;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 a=this._translucentMaterialIndices.entries();for(let e=a.next();!e.done;e=a.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 r=[...this._transparentMeshesCache,...this._opaqueMeshesCache];for(const e of r){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 Ot(e,t){if(e.parent.dontUseTransmissionHelper)return;const r=t.getScene()._transmissionHelper,s=null!=r?r:new Mt({},t.getScene());for(const t of Array.from(e._pbrMaterialImpls.values()))s.addMaterialImpl(t);r&&!r._isRenderTargetValid()&&r._setupRenderTargets()}const Lt="KHR_materials_transmission";class Ft{constructor(e){this.name=Lt,this.order=175,this._loader=e,this.enabled=this._loader.isExtensionUsed(Lt),this.enabled&&(e.parent.transparencyAsCoverage=!0)}dispose(){this._loader=null}loadMaterialPropertiesAsync(e,t,r){return $.LoadExtensionAsync(e,t,this.name,(s,a)=>S(this,void 0,void 0,function*(){const n=new Array;return n.push(this._loader.loadMaterialPropertiesAsync(e,t,r)),n.push(this._loadTransparentPropertiesAsync(s,t,r,a)),yield Promise.all(n).then(()=>{})}))}_loadTransparentPropertiesAsync(e,t,r,s){const a=this._loader._getOrCreateMaterialAdapter(r),n=void 0!==s.transmissionFactor?s.transmissionFactor:0;if(0===n||!a)return Promise.resolve();a.configureTransmission(),a.transmissionWeight=n,n>0&&Ot(this._loader,r);let o=Promise.resolve(null);return s.transmissionTexture&&(s.transmissionTexture.nonColorData=!0,o=this._loader.loadTextureInfoAsync(`${e}/transmissionTexture`,s.transmissionTexture,e=>{e.name=`${r.name} (Transmission)`,a.transmissionWeightTexture=e})),o.then(()=>{})}}let Et=!1;function St(){Et||(Et=!0,B(Lt),P(Lt,!0,e=>new Ft(e)))}St();const kt="KHR_materials_diffuse_transmission";class It{constructor(e){this.name=kt,this.order=174,this._loader=e,this.enabled=this._loader.isExtensionUsed(kt),this.enabled&&(e.parent.transparencyAsCoverage=!0)}dispose(){this._loader=null}loadMaterialPropertiesAsync(e,t,r){return $.LoadExtensionAsync(e,t,this.name,(s,a)=>S(this,void 0,void 0,function*(){const n=new Array;return n.push(this._loader.loadMaterialPropertiesAsync(e,t,r)),n.push(this._loadTranslucentPropertiesAsync(s,t,r,a)),yield Promise.all(n).then(()=>{})}))}_loadTranslucentPropertiesAsync(e,r,s,a){var n;const o=this._loader._getOrCreateMaterialAdapter(s);o.configureSubsurface(),o.subsurfaceWeight=null!==(n=a.diffuseTransmissionFactor)&&void 0!==n?n:0,o.subsurfaceWeight>0&&Ot(this._loader,s),o.diffuseTransmissionTint=void 0!==a.diffuseTransmissionColorFactor?t.Color3.FromArray(a.diffuseTransmissionColorFactor):t.Color3.White();const i=new Array;return a.diffuseTransmissionTexture&&(a.diffuseTransmissionTexture.nonColorData=!0,i.push(this._loader.loadTextureInfoAsync(`${e}/diffuseTransmissionTexture`,a.diffuseTransmissionTexture).then(e=>{e.name=`${s.name} (Diffuse Transmission)`,o.subsurfaceWeightTexture=e}))),a.diffuseTransmissionColorTexture&&i.push(this._loader.loadTextureInfoAsync(`${e}/diffuseTransmissionColorTexture`,a.diffuseTransmissionColorTexture).then(e=>{e.name=`${s.name} (Diffuse Transmission Color)`,o.diffuseTransmissionTintTexture=e})),Promise.all(i).then(()=>{})}}let Pt=!1;function Bt(){Pt||(Pt=!0,B(kt),P(kt,!0,e=>new It(e)))}Bt();const Nt="KHR_materials_volume";class Gt{constructor(e){this.name=Nt,this.order=173,this._loader=e,this.enabled=this._loader.isExtensionUsed(Nt),this.enabled&&this._loader._disableInstancedMesh++}dispose(){this.enabled&&this._loader._disableInstancedMesh--,this._loader=null}loadMaterialPropertiesAsync(e,t,r){return $.LoadExtensionAsync(e,t,this.name,(s,a)=>S(this,void 0,void 0,function*(){const n=new Array;return n.push(this._loader.loadMaterialPropertiesAsync(e,t,r)),n.push(this._loadVolumePropertiesAsync(s,t,r,a)),yield Promise.all(n).then(()=>{})}))}_loadVolumePropertiesAsync(e,r,s,a){var n;const o=this._loader._getOrCreateMaterialAdapter(s);if(0===o.transmissionWeight&&0===o.subsurfaceWeight||!a.thicknessFactor)return Promise.resolve();o.geometryThinWalled=!1;const i=void 0!==a.attenuationDistance?a.attenuationDistance:Number.MAX_VALUE,l=void 0!==a.attenuationColor&&3==a.attenuationColor.length?t.Color3.FromArray(a.attenuationColor):t.Color3.White();o.configureVolume(),o.transmissionColor=l,o.transmissionDepth=i,o.volumeThickness=null!==(n=a.thicknessFactor)&&void 0!==n?n:0;const u=new Array;return a.thicknessTexture&&(a.thicknessTexture.nonColorData=!0,u.push(this._loader.loadTextureInfoAsync(`${e}/thicknessTexture`,a.thicknessTexture,e=>{e.name=`${s.name} (Thickness)`,o.volumeThicknessTexture=e}))),Promise.all(u).then(()=>{})}}let Dt=!1;function Vt(){Dt||(Dt=!0,B(Nt),P(Nt,!0,e=>new Gt(e)))}Vt();const $t="KHR_materials_volume_scatter";class Ht{constructor(e){this.name=$t,this.order=172,this._loader=e,this.enabled=this._loader.isExtensionUsed($t),this.enabled&&this._loader._disableInstancedMesh++}dispose(){this.enabled&&this._loader._disableInstancedMesh--,this._loader=null}loadMaterialPropertiesAsync(e,t,r){return $.LoadExtensionAsync(e,t,this.name,(s,a)=>S(this,void 0,void 0,function*(){const n=new Array;return n.push(this._loader.loadMaterialPropertiesAsync(e,t,r)),n.push(this._loadVolumePropertiesAsync(s,t,r,a)),yield Promise.all(n).then(()=>{})}))}_loadVolumePropertiesAsync(e,r,s,a){const n=this._loader._getOrCreateMaterialAdapter(s);if(0===n.transmissionWeight&&0===n.subsurfaceWeight||n.geometryThinWalled)return Promise.resolve();const o=void 0!==a.multiscatterColorFactor&&3==a.multiscatterColorFactor.length?t.Color3.FromArray(a.multiscatterColorFactor):t.Color3.Black(),i=void 0!==a.scatterAnisotropy?a.scatterAnisotropy:0;let l=Promise.resolve(null);a.multiscatterColorTexture&&(a.multiscatterColorTexture.nonColorData=!0,l=this._loader.loadTextureInfoAsync(`${e}/multiscatterColorTexture`,a.multiscatterColorTexture,e=>{e.name=`${s.name} (Scatter Color)`,n.transmissionWeight>0&&(n.transmissionScatterTexture=e),n.subsurfaceWeight>0&&(n.subsurfaceColorTexture=e)}));const u=new t.Vector3(-Math.log(n.transmissionColor.r),-Math.log(n.transmissionColor.g),-Math.log(n.transmissionColor.b));if(u.scaleInPlace(1/Math.max(n.transmissionDepth,1e-6)),n.transmissionWeight>0){const e=function(e){const r=new t.Vector3(e.r,e.g,e.b),s=new t.Vector3(4.09712,4.09712,4.09712);s.addInPlace(new t.Vector3(4.20863,4.20863,4.20863).multiplyInPlace(r));const a=new t.Vector3(9.59217,9.59217,9.59217);return a.addInPlace(new t.Vector3(41.6808,41.6808,41.6808).multiplyInPlace(r)),a.addInPlace(new t.Vector3(17.7126,17.7126,17.7126).multiplyInPlace(r.multiply(r))),s.subtractInPlace(new t.Vector3(Math.sqrt(a.x),Math.sqrt(a.y),Math.sqrt(a.z))),new t.Vector3(1,1,1).subtract(s.multiply(s))}(o),r=u.multiply(e);r.scaleInPlace(n.transmissionDepth),n.transmissionScatter.set(r.x,r.y,r.z),n.transmissionScatterAnisotropy=i}if(n.subsurfaceWeight>0){n.subsurfaceScatterAnisotropy=i,n.subsurfaceColor=o;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);n.subsurfaceRadius=Math.max(e.x,e.y,e.z),n.subsurfaceRadiusScale=new t.Color3(e.x/n.subsurfaceRadius,e.y/n.subsurfaceRadius,e.z/n.subsurfaceRadius)}return l.then(()=>{})}}let Kt=!1;function Wt(){Kt||(Kt=!0,B($t),P($t,!0,e=>new Ht(e)))}Wt();const Ut="KHR_materials_dispersion";class zt{constructor(e){this.name=Ut,this.order=174,this._loader=e,this.enabled=this._loader.isExtensionUsed(Ut)}dispose(){this._loader=null}loadMaterialPropertiesAsync(e,t,r){return $.LoadExtensionAsync(e,t,this.name,(s,a)=>S(this,void 0,void 0,function*(){const n=new Array;return n.push(this._loader.loadMaterialPropertiesAsync(e,t,r)),n.push(this._loadDispersionPropertiesAsync(s,t,r,a)),yield Promise.all(n).then(()=>{})}))}_loadDispersionPropertiesAsync(e,t,r,s){const a=this._loader._getOrCreateMaterialAdapter(r);return 0!=a.transmissionWeight&&s.dispersion?(a.transmissionDispersionAbbeNumber=20,a.transmissionDispersionScale=s.dispersion,Promise.resolve()):Promise.resolve()}}let qt=!1;function jt(){qt||(qt=!0,B(Ut),P(Ut,!0,e=>new zt(e)))}jt();const Yt="KHR_materials_diffuse_roughness";class Xt{constructor(e){this.name=Yt,this.order=190,this._loader=e,this.enabled=this._loader.isExtensionUsed(Yt)}dispose(){this._loader=null}loadMaterialPropertiesAsync(e,t,r){return $.LoadExtensionAsync(e,t,this.name,(s,a)=>S(this,void 0,void 0,function*(){const n=new Array;return n.push(this._loader.loadMaterialPropertiesAsync(e,t,r)),n.push(this._loadDiffuseRoughnessPropertiesAsync(s,a,r)),yield Promise.all(n).then(()=>{})}))}_loadDiffuseRoughnessPropertiesAsync(e,t,r){var s;const a=this._loader._getOrCreateMaterialAdapter(r),n=new Array;return a.baseDiffuseRoughness=null!==(s=t.diffuseRoughnessFactor)&&void 0!==s?s:0,t.diffuseRoughnessTexture&&n.push(this._loader.loadTextureInfoAsync(`${e}/diffuseRoughnessTexture`,t.diffuseRoughnessTexture,e=>{e.name=`${r.name} (Diffuse Roughness)`,a.baseDiffuseRoughnessTexture=e})),Promise.all(n).then(()=>{})}}let Qt=!1;function Jt(){Qt||(Qt=!0,B(Yt),P(Yt,!0,e=>new Xt(e)))}Jt();const Zt="KHR_mesh_quantization";class er{constructor(e){this.name=Zt,this.enabled=e.isExtensionUsed(Zt)}dispose(){}}let tr=!1;function rr(){tr||(tr=!0,B(Zt),P(Zt,!0,e=>new er(e)))}rr();const sr="KHR_texture_basisu";class ar{constructor(e){this.name=sr,this._loader=e,this.enabled=e.isExtensionUsed(sr)}dispose(){this._loader=null}_loadTextureAsync(e,t,r){return $.LoadExtensionAsync(e,t,this.name,(s,a)=>S(this,void 0,void 0,function*(){const n=null==t.sampler?$.DefaultSampler:D.Get(`${e}/sampler`,this._loader.gltf.samplers,t.sampler),o=D.Get(`${s}/source`,this._loader.gltf.images,a.source);return yield this._loader._createTextureAsync(e,n,o,e=>{r(e)},t._textureInfo.nonColorData?{useRGBAIfASTCBC7NotAvailableWhenUASTC:!0}:void 0,!t._textureInfo.nonColorData)}))}}let nr=!1;function or(){nr||(nr=!0,B(sr),P(sr,!0,e=>new ar(e)))}or();const ir="KHR_texture_transform";class lr{constructor(e){this.name=ir,this._loader=e,this.enabled=this._loader.isExtensionUsed(ir)}dispose(){this._loader=null}loadTextureInfoAsync(e,r,s){return $.LoadExtensionAsync(e,r,this.name,(a,n)=>S(this,void 0,void 0,function*(){return yield this._loader.loadTextureInfoAsync(e,r,e=>{if(!(e instanceof t.Texture))throw new Error(`${a}: Texture type not supported`);n.offset&&(e.uOffset=n.offset[0],e.vOffset=n.offset[1]),e.uRotationCenter=0,e.vRotationCenter=0,n.rotation&&(e.wAng=-n.rotation),n.scale&&(e.uScale=n.scale[0],e.vScale=n.scale[1]),null!=n.texCoord&&(e.coordinatesIndex=n.texCoord),s(e)})}))}}let ur=!1;function cr(){ur||(ur=!0,B(ir),P(ir,!0,e=>new lr(e)))}cr();const hr="KHR_xmp_json_ld";class dr{constructor(e){this.name=hr,this.order=100,this._loader=e,this.enabled=this._loader.isExtensionUsed(hr)}dispose(){this._loader=null}onLoading(){var e,t,r;if(null===this._loader.rootBabylonMesh)return;const s=null===(e=this._loader.gltf.extensions)||void 0===e?void 0:e.KHR_xmp_json_ld,a=null===(r=null===(t=this._loader.gltf.asset)||void 0===t?void 0:t.extensions)||void 0===r?void 0:r.KHR_xmp_json_ld;if(s&&a){const e=+a.packet;s.packets&&e<s.packets.length&&(this._loader.rootBabylonMesh.metadata=this._loader.rootBabylonMesh.metadata||{},this._loader.rootBabylonMesh.metadata.xmp=s.packets[e])}}}let mr=!1;function _r(){mr||(mr=!0,B(hr),P(hr,!0,e=>new dr(e)))}_r();const pr="KHR_animation_pointer";class fr{constructor(e){this.name=pr,this._loader=e,this._pathToObjectConverter=O(this._loader.gltf)}get enabled(){return this._loader.isExtensionUsed(pr)}dispose(){this._loader=null,delete this._pathToObjectConverter}_loadAnimationChannelAsync(e,r,s,a,n){var o;const i=null===(o=a.target.extensions)||void 0===o?void 0:o.KHR_animation_pointer;if(!i||!this._pathToObjectConverter)return null;"pointer"!==a.target.path&&t.Logger.Warn(`${e}/target/path: Value (${a.target.path}) must be (pointer) when using the ${this.name} extension`),null!=a.target.node&&t.Logger.Warn(`${e}/target/node: Value (${a.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,r,s,a,{object:t.object,info:t.info.interpolation},n)}catch(e){return t.Logger.Warn(`${l}/pointer: Invalid pointer (${u}) skipped`),null}}}let gr=!1;function br(){gr||(gr=!0,B(pr),P(pr,!0,e=>new fr(e)))}function yr(e,r,s,a){return t.Vector3.FromArray(r,s).scaleInPlace(a)}function Tr(e,r,s,a){return t.Quaternion.FromArray(r,s).scaleInPlace(a)}function vr(e,t,r,s){const a=new Array(e._numMorphTargets);for(let e=0;e<a.length;e++)a[e]=t[r++]*s;return a}class xr{constructor(e,t,r,s){this.type=e,this.name=t,this.getValue=r,this.getStride=s}_buildAnimation(e,r,s){const a=new t.Animation(e,this.name,r,this.type);return a.setKeys(s,!0),a}}class Ar extends xr{buildAnimations(e,t,r,s){const a=[];return a.push({babylonAnimatable:e._babylonTransformNode,babylonAnimation:this._buildAnimation(t,r,s)}),a}}class Cr extends xr{buildAnimations(e,r,s,a){const n=[];if(e._numMorphTargets)for(let o=0;o<e._numMorphTargets;o++){const i=new t.Animation(`${r}_${o}`,this.name,s,this.type);if(i.setKeys(a.map(e=>({frame:e.frame,inTangent:e.inTangent?e.inTangent[o]:void 0,value:e.value[o],outTangent:e.outTangent?e.outTangent[o]:void 0,interpolation:e.interpolation})),!0),e._primitiveBabylonMeshes)for(const t of e._primitiveBabylonMeshes)if(t.morphTargetManager){const e=t.morphTargetManager.getTarget(o),r=i.clone();e.animations.push(r),n.push({babylonAnimatable:e,babylonAnimation:r})}}return n}}F("/nodes/{}/translation",[new Ar(t.Animation.ANIMATIONTYPE_VECTOR3,"position",yr,()=>3)]),F("/nodes/{}/rotation",[new Ar(t.Animation.ANIMATIONTYPE_QUATERNION,"rotationQuaternion",Tr,()=>4)]),F("/nodes/{}/scale",[new Ar(t.Animation.ANIMATIONTYPE_VECTOR3,"scaling",yr,()=>3)]),F("/nodes/{}/weights",[new Cr(t.Animation.ANIMATIONTYPE_FLOAT,"influence",vr,e=>e._numMorphTargets)]);var Rr={__proto__:null,AnimationPropertyInfo:xr,TransformNodeAnimationPropertyInfo:Ar,WeightAnimationPropertyInfo:Cr,getQuaternion:Tr,getVector3:yr,getWeights:vr};function wr(e,r,s,a){return t.Color3.FromArray(r,s).scale(a)}function Mr(e,t,r,s){return t[r]*s}function Or(e,t,r,s){return-t[r]*s}function Lr(e,t,r,s){return t[r+1]*s}function Fr(e,t,r,s){return t[r]*s*2}function Er(e){return{scale:[new kr(t.Animation.ANIMATIONTYPE_FLOAT,`${e}.uScale`,Mr,()=>2),new kr(t.Animation.ANIMATIONTYPE_FLOAT,`${e}.vScale`,Lr,()=>2)],offset:[new kr(t.Animation.ANIMATIONTYPE_FLOAT,`${e}.uOffset`,Mr,()=>2),new kr(t.Animation.ANIMATIONTYPE_FLOAT,`${e}.vOffset`,Lr,()=>2)],rotation:[new kr(t.Animation.ANIMATIONTYPE_FLOAT,`${e}.wAng`,Or,()=>1)]}}class Sr extends xr{buildAnimations(e,t,r,s){return[{babylonAnimatable:e._babylonCamera,babylonAnimation:this._buildAnimation(t,r,s)}]}}class kr extends xr{buildAnimations(e,t,r,s){const a=[];for(const n in e._data)a.push({babylonAnimatable:e._data[n].babylonMaterial,babylonAnimation:this._buildAnimation(t,r,s)});return a}}class Ir extends xr{buildAnimations(e,t,r,s){return[{babylonAnimatable:e._babylonLight,babylonAnimation:this._buildAnimation(t,r,s)}]}}F("/cameras/{}/orthographic/xmag",[new Sr(t.Animation.ANIMATIONTYPE_FLOAT,"orthoLeft",Or,()=>1),new Sr(t.Animation.ANIMATIONTYPE_FLOAT,"orthoRight",Lr,()=>1)]),F("/cameras/{}/orthographic/ymag",[new Sr(t.Animation.ANIMATIONTYPE_FLOAT,"orthoBottom",Or,()=>1),new Sr(t.Animation.ANIMATIONTYPE_FLOAT,"orthoTop",Lr,()=>1)]),F("/cameras/{}/orthographic/zfar",[new Sr(t.Animation.ANIMATIONTYPE_FLOAT,"maxZ",Mr,()=>1)]),F("/cameras/{}/orthographic/znear",[new Sr(t.Animation.ANIMATIONTYPE_FLOAT,"minZ",Mr,()=>1)]),F("/cameras/{}/perspective/yfov",[new Sr(t.Animation.ANIMATIONTYPE_FLOAT,"fov",Mr,()=>1)]),F("/cameras/{}/perspective/zfar",[new Sr(t.Animation.ANIMATIONTYPE_FLOAT,"maxZ",Mr,()=>1)]),F("/cameras/{}/perspective/znear",[new Sr(t.Animation.ANIMATIONTYPE_FLOAT,"minZ",Mr,()=>1)]),F("/materials/{}/pbrMetallicRoughness/baseColorFactor",[new kr(t.Animation.ANIMATIONTYPE_COLOR3,"albedoColor",wr,()=>4),new kr(t.Animation.ANIMATIONTYPE_FLOAT,"alpha",function(e,t,r,s){return t[r+3]*s},()=>4)]),F("/materials/{}/pbrMetallicRoughness/metallicFactor",[new kr(t.Animation.ANIMATIONTYPE_FLOAT,"metallic",Mr,()=>1)]),F("/materials/{}/pbrMetallicRoughness/metallicFactor",[new kr(t.Animation.ANIMATIONTYPE_FLOAT,"roughness",Mr,()=>1)]);const Pr=Er("albedoTexture");F("/materials/{}/pbrMetallicRoughness/baseColorTexture/extensions/KHR_texture_transform/scale",Pr.scale),F("/materials/{}/pbrMetallicRoughness/baseColorTexture/extensions/KHR_texture_transform/offset",Pr.offset),F("/materials/{}/pbrMetallicRoughness/baseColorTexture/extensions/KHR_texture_transform/rotation",Pr.rotation);const Br=Er("metallicTexture");F("//materials/{}/pbrMetallicRoughness/metallicRoughnessTexture/scale",Br.scale),F("//materials/{}/pbrMetallicRoughness/metallicRoughnessTexture/offset",Br.offset),F("//materials/{}/pbrMetallicRoughness/metallicRoughnessTexture/rotation",Br.rotation),F("/materials/{}/emissiveFactor",[new kr(t.Animation.ANIMATIONTYPE_COLOR3,"emissiveColor",wr,()=>3)]);const Nr=Er("bumpTexture");F("/materials/{}/normalTexture/scale",[new kr(t.Animation.ANIMATIONTYPE_FLOAT,"bumpTexture.level",Mr,()=>1)]),F("/materials/{}/normalTexture/extensions/KHR_texture_transform/scale",Nr.scale),F("/materials/{}/normalTexture/extensions/KHR_texture_transform/offset",Nr.offset),F("/materials/{}/normalTexture/extensions/KHR_texture_transform/rotation",Nr.rotation),F("/materials/{}/occlusionTexture/strength",[new kr(t.Animation.ANIMATIONTYPE_FLOAT,"ambientTextureStrength",Mr,()=>1)]);const Gr=Er("ambientTexture");F("/materials/{}/occlusionTexture/extensions/KHR_texture_transform/scale",Gr.scale),F("/materials/{}/occlusionTexture/extensions/KHR_texture_transform/offset",Gr.offset),F("/materials/{}/occlusionTexture/extensions/KHR_texture_transform/rotation",Gr.rotation);const Dr=Er("emissiveTexture");F("/materials/{}/emissiveTexture/extensions/KHR_texture_transform/scale",Dr.scale),F("/materials/{}/emissiveTexture/extensions/KHR_texture_transform/offset",Dr.offset),F("/materials/{}/emissiveTexture/extensions/KHR_texture_transform/rotation",Dr.rotation),F("/materials/{}/extensions/KHR_materials_anisotropy/anisotropyStrength",[new kr(t.Animation.ANIMATIONTYPE_FLOAT,"anisotropy.intensity",Mr,()=>1)]),F("/materials/{}/extensions/KHR_materials_anisotropy/anisotropyRotation",[new kr(t.Animation.ANIMATIONTYPE_FLOAT,"anisotropy.angle",Mr,()=>1)]);const Vr=Er("anisotropy.texture");F("/materials/{}/extensions/KHR_materials_anisotropy/anisotropyTexture/extensions/KHR_texture_transform/scale",Vr.scale),F("/materials/{}/extensions/KHR_materials_anisotropy/anisotropyTexture/extensions/KHR_texture_transform/offset",Vr.offset),F("/materials/{}/extensions/KHR_materials_anisotropy/anisotropyTexture/extensions/KHR_texture_transform/rotation",Vr.rotation),F("/materials/{}/extensions/KHR_materials_clearcoat/clearcoatFactor",[new kr(t.Animation.ANIMATIONTYPE_FLOAT,"clearCoat.intensity",Mr,()=>1)]),F("/materials/{}/extensions/KHR_materials_clearcoat/clearcoatRoughnessFactor",[new kr(t.Animation.ANIMATIONTYPE_FLOAT,"clearCoat.roughness",Mr,()=>1)]);const $r=Er("clearCoat.texture");F("/materials/{}/extensions/KHR_materials_clearcoat/clearcoatTexture/extensions/KHR_texture_transform/scale",$r.scale),F("/materials/{}/extensions/KHR_materials_clearcoat/clearcoatTexture/extensions/KHR_texture_transform/offset",$r.offset),F("/materials/{}/extensions/KHR_materials_clearcoat/clearcoatTexture/extensions/KHR_texture_transform/rotation",$r.rotation);const Hr=Er("clearCoat.bumpTexture");F("/materials/{}/extensions/KHR_materials_clearcoat/clearcoatNormalTexture/scale",[new kr(t.Animation.ANIMATIONTYPE_FLOAT,"clearCoat.bumpTexture.level",Mr,()=>1)]),F("/materials/{}/extensions/KHR_materials_clearcoat/clearcoatNormalTexture/extensions/KHR_texture_transform/scale",Hr.scale),F("/materials/{}/extensions/KHR_materials_clearcoat/clearcoatNormalTexture/extensions/KHR_texture_transform/offset",Hr.offset),F("/materials/{}/extensions/KHR_materials_clearcoat/clearcoatNormalTexture/extensions/KHR_texture_transform/rotation",Hr.rotation);const Kr=Er("clearCoat.textureRoughness");F("/materials/{}/extensions/KHR_materials_clearcoat/clearcoatRoughnessTexture/extensions/KHR_texture_transform/scale",Kr.scale),F("/materials/{}/extensions/KHR_materials_clearcoat/clearcoatRoughnessTexture/extensions/KHR_texture_transform/offset",Kr.offset),F("/materials/{}/extensions/KHR_materials_clearcoat/clearcoatRoughnessTexture/extensions/KHR_texture_transform/rotation",Kr.rotation),F("/materials/{}/extensions/KHR_materials_dispersion/dispersionFactor",[new kr(t.Animation.ANIMATIONTYPE_FLOAT,"subSurface.dispersion",Mr,()=>1)]),F("/materials/{}/extensions/KHR_materials_emissive_strength/emissiveStrength",[new kr(t.Animation.ANIMATIONTYPE_FLOAT,"emissiveIntensity",Mr,()=>1)]),F("/materials/{}/extensions/KHR_materials_ior/ior",[new kr(t.Animation.ANIMATIONTYPE_FLOAT,"indexOfRefraction",Mr,()=>1)]),F("/materials/{}/extensions/KHR_materials_iridescence/iridescenceFactor",[new kr(t.Animation.ANIMATIONTYPE_FLOAT,"iridescence.intensity",Mr,()=>1)]),F("/materials/{}/extensions/KHR_materials_iridescence/iridescenceIor",[new kr(t.Animation.ANIMATIONTYPE_FLOAT,"iridescence.indexOfRefraction",Mr,()=>1)]),F("/materials/{}/extensions/KHR_materials_iridescence/iridescenceThicknessMinimum",[new kr(t.Animation.ANIMATIONTYPE_FLOAT,"iridescence.minimumThickness",Mr,()=>1)]),F("/materials/{}/extensions/KHR_materials_iridescence/iridescenceThicknessMaximum",[new kr(t.Animation.ANIMATIONTYPE_FLOAT,"iridescence.maximumThickness",Mr,()=>1)]);const Wr=Er("iridescence.texture");F("/materials/{}/extensions/KHR_materials_iridescence/iridescenceTexture/extensions/KHR_texture_transform/scale",Wr.scale),F("/materials/{}/extensions/KHR_materials_iridescence/iridescenceTexture/extensions/KHR_texture_transform/offset",Wr.offset),F("/materials/{}/extensions/KHR_materials_iridescence/iridescenceTexture/extensions/KHR_texture_transform/rotation",Wr.rotation);const Ur=Er("iridescence.thicknessTexture");F("/materials/{}/extensions/KHR_materials_iridescence/iridescenceThicknessTexture/extensions/KHR_texture_transform/scale",Ur.scale),F("/materials/{}/extensions/KHR_materials_iridescence/iridescenceThicknessTexture/extensions/KHR_texture_transform/offset",Ur.offset),F("/materials/{}/extensions/KHR_materials_iridescence/iridescenceThicknessTexture/extensions/KHR_texture_transform/rotation",Ur.rotation),F("/materials/{}/extensions/KHR_materials_sheen/sheenColorFactor",[new kr(t.Animation.ANIMATIONTYPE_COLOR3,"sheen.color",wr,()=>3)]),F("/materials/{}/extensions/KHR_materials_sheen/sheenRoughnessFactor",[new kr(t.Animation.ANIMATIONTYPE_FLOAT,"sheen.roughness",Mr,()=>1)]);const zr=Er("sheen.texture");F("/materials/{}/extensions/KHR_materials_sheen/sheenColorTexture/extensions/KHR_texture_transform/scale",zr.scale),F("/materials/{}/extensions/KHR_materials_sheen/sheenColorTexture/extensions/KHR_texture_transform/offset",zr.offset),F("/materials/{}/extensions/KHR_materials_sheen/sheenColorTexture/extensions/KHR_texture_transform/rotation",zr.rotation);const qr=Er("sheen.textureRoughness");F("/materials/{}/extensions/KHR_materials_sheen/sheenRoughnessTexture/extensions/KHR_texture_transform/scale",qr.scale),F("/materials/{}/extensions/KHR_materials_sheen/sheenRoughnessTexture/extensions/KHR_texture_transform/offset",qr.offset),F("/materials/{}/extensions/KHR_materials_sheen/sheenRoughnessTexture/extensions/KHR_texture_transform/rotation",qr.rotation),F("/materials/{}/extensions/KHR_materials_specular/specularFactor",[new kr(t.Animation.ANIMATIONTYPE_FLOAT,"metallicF0Factor",Mr,()=>1)]),F("/materials/{}/extensions/KHR_materials_specular/specularColorFactor",[new kr(t.Animation.ANIMATIONTYPE_COLOR3,"metallicReflectanceColor",wr,()=>3)]);const jr=Er("metallicReflectanceTexture");F("/materials/{}/extensions/KHR_materials_specular/specularTexture/extensions/KHR_texture_transform/scale",jr.scale),F("/materials/{}/extensions/KHR_materials_specular/specularTexture/extensions/KHR_texture_transform/offset",jr.offset),F("/materials/{}/extensions/KHR_materials_specular/specularTexture/extensions/KHR_texture_transform/rotation",jr.rotation);const Yr=Er("reflectanceTexture");F("/materials/{}/extensions/KHR_materials_specular/specularColorTexture/extensions/KHR_texture_transform/scale",Yr.scale),F("/materials/{}/extensions/KHR_materials_specular/specularColorTexture/extensions/KHR_texture_transform/offset",Yr.offset),F("/materials/{}/extensions/KHR_materials_specular/specularColorTexture/extensions/KHR_texture_transform/rotation",Yr.rotation),F("/materials/{}/extensions/KHR_materials_transmission/transmissionFactor",[new kr(t.Animation.ANIMATIONTYPE_FLOAT,"subSurface.refractionIntensity",Mr,()=>1)]);const Xr=Er("subSurface.refractionIntensityTexture");F("/materials/{}/extensions/KHR_materials_transmission/transmissionTexture/extensions/KHR_texture_transform/scale",Xr.scale),F("/materials/{}/extensions/KHR_materials_transmission/transmissionTexture/extensions/KHR_texture_transform/offset",Xr.offset),F("/materials/{}/extensions/KHR_materials_transmission/transmissionTexture/extensions/KHR_texture_transform/rotation",Xr.rotation),F("/materials/{}/extensions/KHR_materials_volume/attenuationColor",[new kr(t.Animation.ANIMATIONTYPE_COLOR3,"subSurface.tintColor",wr,()=>3)]),F("/materials/{}/extensions/KHR_materials_volume/attenuationDistance",[new kr(t.Animation.ANIMATIONTYPE_FLOAT,"subSurface.tintColorAtDistance",Mr,()=>1)]),F("/materials/{}/extensions/KHR_materials_volume/thicknessFactor",[new kr(t.Animation.ANIMATIONTYPE_FLOAT,"subSurface.maximumThickness",Mr,()=>1)]);const Qr=Er("subSurface.thicknessTexture");F("/materials/{}/extensions/KHR_materials_volume/thicknessTexture/extensions/KHR_texture_transform/scale",Qr.scale),F("/materials/{}/extensions/KHR_materials_volume/thicknessTexture/extensions/KHR_texture_transform/offset",Qr.offset),F("/materials/{}/extensions/KHR_materials_volume/thicknessTexture/extensions/KHR_texture_transform/rotation",Qr.rotation),F("/materials/{}/extensions/KHR_materials_diffuse_transmission/diffuseTransmissionFactor",[new kr(t.Animation.ANIMATIONTYPE_FLOAT,"subSurface.translucencyIntensity",Mr,()=>1)]);const Jr=Er("subSurface.translucencyIntensityTexture");F("materials/{}/extensions/KHR_materials_diffuse_transmission/diffuseTransmissionTexture/extensions/KHR_texture_transform/scale",Jr.scale),F("materials/{}/extensions/KHR_materials_diffuse_transmission/diffuseTransmissionTexture/extensions/KHR_texture_transform/offset",Jr.offset),F("materials/{}/extensions/KHR_materials_diffuse_transmission/diffuseTransmissionTexture/extensions/KHR_texture_transform/rotation",Jr.rotation),F("/materials/{}/extensions/KHR_materials_diffuse_transmission/diffuseTransmissionColorFactor",[new kr(t.Animation.ANIMATIONTYPE_COLOR3,"subSurface.translucencyColor",wr,()=>3)]);const Zr=Er("subSurface.translucencyColorTexture");F("materials/{}/extensions/KHR_materials_diffuse_transmission/diffuseTransmissionColorTexture/extensions/KHR_texture_transform/scale",Zr.scale),F("materials/{}/extensions/KHR_materials_diffuse_transmission/diffuseTransmissionColorTexture/extensions/KHR_texture_transform/offset",Zr.offset),F("materials/{}/extensions/KHR_materials_diffuse_transmission/diffuseTransmissionColorTexture/extensions/KHR_texture_transform/rotation",Zr.rotation),F("/extensions/KHR_lights_punctual/lights/{}/color",[new Ir(t.Animation.ANIMATIONTYPE_COLOR3,"diffuse",wr,()=>3)]),F("/extensions/KHR_lights_punctual/lights/{}/intensity",[new Ir(t.Animation.ANIMATIONTYPE_FLOAT,"intensity",Mr,()=>1)]),F("/extensions/KHR_lights_punctual/lights/{}/range",[new Ir(t.Animation.ANIMATIONTYPE_FLOAT,"range",Mr,()=>1)]),F("/extensions/KHR_lights_punctual/lights/{}/spot/innerConeAngle",[new Ir(t.Animation.ANIMATIONTYPE_FLOAT,"innerAngle",Fr,()=>1)]),F("/extensions/KHR_lights_punctual/lights/{}/spot/outerConeAngle",[new Ir(t.Animation.ANIMATIONTYPE_FLOAT,"angle",Fr,()=>1)]),F("/extensions/EXT_lights_area/lights/{}/color",[new Ir(t.Animation.ANIMATIONTYPE_COLOR3,"diffuse",wr,()=>3)]),F("/extensions/EXT_lights_area/lights/{}/intensity",[new Ir(t.Animation.ANIMATIONTYPE_FLOAT,"intensity",Mr,()=>1)]),F("/extensions/EXT_lights_area/lights/{}/size",[new Ir(t.Animation.ANIMATIONTYPE_FLOAT,"radius",Mr,()=>1)]),F("/extensions/EXT_lights_area/lights/{}/rect/aspect",[new Ir(t.Animation.ANIMATIONTYPE_FLOAT,"radius",Mr,()=>1)]),F("/nodes/{}/extensions/EXT_lights_ies/color",[new Ir(t.Animation.ANIMATIONTYPE_COLOR3,"diffuse",wr,()=>3)]),F("/nodes/{}/extensions/EXT_lights_ies/multiplier",[new Ir(t.Animation.ANIMATIONTYPE_FLOAT,"intensity",Mr,()=>1)]),F("/nodes/{}/extensions/KHR_node_visibility/visible",[new class extends xr{buildAnimations(e,t,r,s){return e._primitiveBabylonMeshes?e._primitiveBabylonMeshes.map(e=>({babylonAnimatable:e,babylonAnimation:this._buildAnimation(t,r,s)})):[]}}(t.Animation.ANIMATIONTYPE_FLOAT,"isVisible",Mr,()=>1)]),br();const es="MSFT_audio_emitter";class ts{constructor(e){this.name=es,this._loader=e,this.enabled=this._loader.isExtensionUsed(es)}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,D.Assign(this._clips),D.Assign(this._emitters)}}loadSceneAsync(e,t){return $.LoadExtensionAsync(e,t,this.name,(r,s)=>S(this,void 0,void 0,function*(){const a=new Array;a.push(this._loader.loadSceneAsync(e,t));for(const e of s.emitters){const t=D.Get(`${r}/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(`${r}: Direction or Distance properties are not allowed on emitters attached to a scene`);a.push(this._loadEmitterAsync(`${r}/emitters/${t.index}`,t))}yield Promise.all(a)}))}loadNodeAsync(e,r,s){return $.LoadExtensionAsync(e,r,this.name,(e,a)=>S(this,void 0,void 0,function*(){const n=new Array,o=yield this._loader.loadNodeAsync(e,r,r=>{for(const s of a.emitters){const a=D.Get(`${e}/emitters`,this._emitters,s);n.push(this._loadEmitterAsync(`${e}/emitters/${a.index}`,a).then(()=>{for(const e of a._babylonSounds)e.attachToMesh(r),null==a.innerAngle&&null==a.outerAngle||(e.setLocalDirectionToMesh(t.Vector3.Forward()),e.setDirectionalCone(2*t.Tools.ToDegrees(null==a.innerAngle?Math.PI:a.innerAngle),2*t.Tools.ToDegrees(null==a.outerAngle?Math.PI:a.outerAngle),0))}))}s(r)});return yield Promise.all(n),o}))}loadAnimationAsync(e,t){return $.LoadExtensionAsync(e,t,this.name,(r,s)=>S(this,void 0,void 0,function*(){const a=yield this._loader.loadAnimationAsync(e,t),n=new Array;D.Assign(s.events);for(const o of s.events)n.push(this._loadAnimationEventAsync(`${r}/events/${o.index}`,e,t,o,a));return yield Promise.all(n),a}))}_loadClipAsync(e,r){if(r._objectURL)return r._objectURL;let s;if(r.uri)s=this._loader.loadUriAsync(e,r,r.uri);else{const t=D.Get(`${e}/bufferView`,this._loader.gltf.bufferViews,r.bufferView);s=this._loader.loadBufferViewAsync(`/bufferViews/${t.index}`,t)}return r._objectURL=s.then(e=>{const s=t.GetBlobBufferSource(e);return URL.createObjectURL(new Blob([s],{type:r.mimeType}))}),r._objectURL}_loadEmitterAsync(e,r){if(r._babylonSounds=r._babylonSounds||[],!r._babylonData){const e=new Array,s=r.name||`emitter${r.index}`,a={loop:!1,autoplay:!1,volume:null==r.volume?1:r.volume};for(let n=0;n<r.clips.length;n++){const o=`/extensions/${this.name}/clips`,i=D.Get(o,this._clips,r.clips[n].clip);e.push(this._loadClipAsync(`${o}/${r.clips[n].clip}`,i).then(e=>{const o=r._babylonSounds[n]=new t.Sound(s,e,this._loader.babylonScene,null,a);o.refDistance=r.refDistance||1,o.maxDistance=r.maxDistance||256,o.rolloffFactor=r.rolloffFactor||1,o.distanceModel=r.distanceModel||"exponential"}))}const n=Promise.all(e).then(()=>{const e=r.clips.map(e=>e.weight||1),s=new t.WeightedSound(r.loop||!1,r._babylonSounds,e);r.innerAngle&&(s.directionalConeInnerAngle=2*t.Tools.ToDegrees(r.innerAngle)),r.outerAngle&&(s.directionalConeOuterAngle=2*t.Tools.ToDegrees(r.outerAngle)),r.volume&&(s.volume=r.volume),r._babylonData.sound=s});r._babylonData={loaded:n}}return r._babylonData.loaded}_getEventAction(e,t,r,s,a){switch(r){case"play":return e=>{const r=(a||0)+(e-s);t.play(r)};case"stop":return()=>{t.stop()};case"pause":return()=>{t.pause()};default:throw new Error(`${e}: Unsupported action ${r}`)}}_loadAnimationEventAsync(e,r,s,a,n){if(0==n.targetedAnimations.length)return Promise.resolve();const o=n.targetedAnimations[0],i=a.emitter,l=D.Get(`/extensions/${this.name}/emitters`,this._emitters,i);return this._loadEmitterAsync(e,l).then(()=>{const r=l._babylonData.sound;if(r){const s=new t.AnimationEvent(a.time,this._getEventAction(e,r,a.action,a.time,a.startOffset));o.animation.addEvent(s),n.onAnimationGroupEndObservable.add(()=>{r.stop()}),n.onAnimationGroupPauseObservable.add(()=>{r.pause()})}})}}let rs=!1;function ss(){rs||(rs=!0,B(es),P(es,!0,e=>new ts(e)))}ss();const as="MSFT_lod";class ns{constructor(e){var r,s;this.name=as,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!==(s=null===(r=this._loader.parent.extensionOptions[as])||void 0===r?void 0:r.maxLODsToLoad)&&void 0!==s?s:this.maxLODsToLoad,this.enabled=this._loader.isExtensionUsed(as)}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 r=this._loader.loadSceneAsync(e,t);return this._loadBufferLOD(this._bufferLODs,0),r}loadNodeAsync(e,r,s){return $.LoadExtensionAsync(e,r,this.name,(e,a)=>S(this,void 0,void 0,function*(){let n;const o=this._getLODs(e,r,this._loader.gltf.nodes,a.ids);this._loader.logOpen(`${e}`);for(let e=0;e<o.length;e++){const r=o[e];0!==e&&(this._nodeIndexLOD=e,this._nodeSignalLODs[e]=this._nodeSignalLODs[e]||new t.Deferred);const a=e=>{s(e),e.setEnabled(!1)},i=this._loader.loadNodeAsync(`/nodes/${r.index}`,r,a).then(t=>{if(0!==e){const t=o[e-1];t._babylonTransformNode&&(this._disposeTransformNode(t._babylonTransformNode),delete t._babylonTransformNode)}return t.setEnabled(!0),t});this._nodePromiseLODs[e]=this._nodePromiseLODs[e]||[],0===e?n=i:(this._nodeIndexLOD=null,this._nodePromiseLODs[e].push(i))}return this._loader.logClose(),yield n}))}_loadMaterialAsync(e,t,r,s,a){return this._nodeIndexLOD?null:$.LoadExtensionAsync(e,t,this.name,(e,n)=>S(this,void 0,void 0,function*(){let o;const i=this._getLODs(e,t,this._loader.gltf.materials,n.ids);this._loader.logOpen(`${e}`);for(let e=0;e<i.length;e++){const t=i[e];0!==e&&(this._materialIndexLOD=e);const n=this._loader._loadMaterialAsync(`/materials/${t.index}`,t,r,s,t=>{0===e&&a(t)}).then(t=>{if(0!==e){a(t);const r=i[e-1]._data;r[s]&&(this._disposeMaterials([r[s].babylonMaterial]),delete r[s])}return t});this._materialPromiseLODs[e]=this._materialPromiseLODs[e]||[],0===e?o=n:(this._materialIndexLOD=null,this._materialPromiseLODs[e].push(n))}return this._loader.logClose(),yield o}))}_loadUriAsync(e,r,s){if(null!==this._nodeIndexLOD){this._loader.log("deferred");const a=this._nodeIndexLOD-1;return this._nodeSignalLODs[a]=this._nodeSignalLODs[a]||new t.Deferred,this._nodeSignalLODs[this._nodeIndexLOD-1].promise.then(()=>S(this,void 0,void 0,function*(){return yield this._loader.loadUriAsync(e,r,s)}))}if(null!==this._materialIndexLOD){this._loader.log("deferred");const a=this._materialIndexLOD-1;return this._materialSignalLODs[a]=this._materialSignalLODs[a]||new t.Deferred,this._materialSignalLODs[a].promise.then(()=>S(this,void 0,void 0,function*(){return yield this._loader.loadUriAsync(e,r,s)}))}return null}loadBufferAsync(e,r,s,a){if(this._loader.parent.useRangeRequests&&!r.uri){if(!this._loader.bin)throw new Error(`${e}: Uri is missing or the binary glTF is missing its binary chunk`);const r=(e,r)=>S(this,void 0,void 0,function*(){const n=s,o=n+a-1;let i=e[r];return i?(i.start=Math.min(i.start,n),i.end=Math.max(i.end,o)):(i={start:n,end:o,loaded:new t.Deferred},e[r]=i),yield i.loaded.promise.then(e=>new Uint8Array(e.buffer,e.byteOffset+s-i.start,a))});return this._loader.log("deferred"),null!==this._nodeIndexLOD?r(this._nodeBufferLODs,this._nodeIndexLOD):null!==this._materialIndexLOD?r(this._materialBufferLODs,this._materialIndexLOD):r(this._bufferLODs,0)}return null}_loadBufferLOD(e,t){const r=e[t];r&&(this._loader.log(`Loading buffer range [${r.start}-${r.end}]`),this._loader.bin.readAsync(r.start,r.end-r.start+1).then(e=>{r.loaded.resolve(e)},e=>{r.loaded.reject(e)}))}_getLODs(e,t,r,s){if(this.maxLODsToLoad<=0)throw new Error("maxLODsToLoad must be greater than zero");const a=[];for(let t=s.length-1;t>=0;t--)if(a.push(D.Get(`${e}/ids/${s[t]}`,r,s[t])),a.length===this.maxLODsToLoad)return a;return a.push(t),a}_disposeTransformNode(e){const t=[],r=e.material;r&&t.push(r);for(const r of e.getChildMeshes())r.material&&t.push(r.material);e.dispose();const s=t.filter(e=>this._loader.babylonScene.meshes.every(t=>t.material!=e));this._disposeMaterials(s)}_disposeMaterials(e){const t={};for(const r of e){for(const e of r.getActiveTextures())t[e.uniqueId]=e;r.dispose()}for(const e in t)for(const r of this._loader.babylonScene.materials)r.hasTexture(t[e])&&delete t[e];for(const e in t)t[e].dispose()}}let os=!1;function is(){os||(os=!0,B(as),P(as,!0,e=>new ns(e)))}is();const ls="MSFT_minecraftMesh";class us{constructor(e){this.name=ls,this._loader=e,this.enabled=this._loader.isExtensionUsed(ls)}dispose(){this._loader=null}loadMaterialPropertiesAsync(e,t,r){return $.LoadExtraAsync(e,t,this.name,(s,a)=>S(this,void 0,void 0,function*(){if(a){if(!this._loader._pbrMaterialImpls.get("pbr"))throw new Error(`${s}: Material type not supported`);const a=this._loader.loadMaterialPropertiesAsync(e,t,r);return r.needAlphaBlending()&&(r.forceDepthWrite=!0,r.separateCullingPass=!0),r.backFaceCulling=r.forceDepthWrite,r.twoSidedLighting=!0,yield a}}))}}let cs=!1;function hs(){cs||(cs=!0,B(ls),P(ls,!0,e=>new us(e)))}hs();const ds="MSFT_sRGBFactors";class ms{constructor(e){this.name=ds,this._loader=e,this.enabled=this._loader.isExtensionUsed(ds)}dispose(){this._loader=null}loadMaterialPropertiesAsync(e,t,r){return $.LoadExtraAsync(e,t,this.name,(s,a)=>S(this,void 0,void 0,function*(){if(a){const s=this._loader._getOrCreateMaterialAdapter(r),a=this._loader.loadMaterialPropertiesAsync(e,t,r),n=r.getScene().getEngine().useExactSrgbConversions;return s.baseColorTexture||s.baseColor.toLinearSpaceToRef(s.baseColor,n),s.specularColorTexture||s.specularColor.toLinearSpaceToRef(s.specularColor,n),yield a}}))}}let _s=!1;function ps(){_s||(_s=!0,B(ds),P(ds,!0,e=>new ms(e)))}function fs(e){const[t,r]=e.split(":");return gs({op:t,extension:r})}function gs(e,r=!0){var s;const a=e.extension?null===(s=ys[e.extension])||void 0===s?void 0:s[e.op]:Ts[e.op];if(!a&&(t.Logger.Warn(`No mapping found for operation ${e.op} and extension ${e.extension||"KHR_interactivity"}`),r)){const t={},r={flows:{}};if(e.inputValueSockets){t.values={};for(const r in e.inputValueSockets)t.values[r]={name:r}}return e.outputValueSockets&&(r.values={},Object.keys(e.outputValueSockets).forEach(e=>{r.values[e]={name:e}})),{blocks:[],inputs:t,outputs:r}}return a}function bs(e,t,r){ys[t]||(ys[t]={}),ys[t][e]=r}ps();const ys={BABYLON:{"flow/log":{blocks:["FlowGraphConsoleLogBlock"],inputs:{values:{message:{name:"message"}}}}}},Ts={"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,r,s,a){var n;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 o=null===(n=e.configuration.event.value)||void 0===n?void 0:n[0];if("number"!=typeof o)throw new Error("Event id should be a number");const i=s.arrays.events[o],l=a[0];return l.config||(l.config={}),l.config.eventId=i.eventId,l.config.eventData=i.eventData,a}},"event/receive":{blocks:["FlowGraphReceiveCustomEventBlock"],outputs:{flows:{out:{name:"done"}}},validation(e,r){var s,a;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 n=e.configuration.event;if(!n)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 o=null===(s=n.value)||void 0===s?void 0:s[0];return"number"!=typeof o?(t.Logger.Error("Event id should be a number"),{valid:!1,error:"Event id should be a number"}):(null===(a=r.events)||void 0===a?void 0:a[o])?{valid:!0}:(t.Logger.Error(`Event with id ${o} not found`),{valid:!1,error:`Event with id ${o} not found`})},extraProcessor(e,t,r,s,a){var n;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 o=null===(n=e.configuration.event.value)||void 0===n?void 0:n[0];if("number"!=typeof o)throw new Error("Event id should be a number");const i=s.arrays.events[o],l=a[0];return l.config||(l.config={}),l.config.eventId=i.eventId,l.config.eventData=i.eventData,a}},"math/E":vs("FlowGraphEBlock"),"math/Pi":vs("FlowGraphPIBlock"),"math/Inf":vs("FlowGraphInfBlock"),"math/NaN":vs("FlowGraphNaNBlock"),"math/abs":vs("FlowGraphAbsBlock"),"math/sign":vs("FlowGraphSignBlock"),"math/trunc":vs("FlowGraphTruncBlock"),"math/floor":vs("FlowGraphFloorBlock"),"math/ceil":vs("FlowGraphCeilBlock"),"math/round":{blocks:["FlowGraphRoundBlock"],configuration:{},inputs:{values:{a:{name:"a"}}},outputs:{values:{value:{name:"value"}}},extraProcessor(e,t,r,s,a){var n;return(n=a[0]).config||(n.config={}),a[0].config.roundHalfAwayFromZero=!0,a}},"math/fract":vs("FlowGraphFractBlock"),"math/neg":vs("FlowGraphNegationBlock"),"math/add":vs("FlowGraphAddBlock",["a","b"],!0),"math/sub":vs("FlowGraphSubtractBlock",["a","b"],!0),"math/mul":{blocks:["FlowGraphMultiplyBlock"],extraProcessor(e,t,r,s,a){var n;(n=a[0]).config||(n.config={}),a[0].config.useMatrixPerComponent=!0,a[0].config.preventIntegerFloatArithmetic=!0;let o=-1;return Object.keys(e.values||{}).find(t=>{var r;return void 0!==(null===(r=e.values)||void 0===r?void 0:r[t].type)&&(o=e.values[t].type,!0)}),-1!==o&&(a[0].config.type=s.arrays.types[o].flowGraphType),a},validation:e=>e.values?xs(e):{valid:!0}},"math/div":vs("FlowGraphDivideBlock",["a","b"],!0),"math/rem":vs("FlowGraphModuloBlock",["a","b"]),"math/min":vs("FlowGraphMinBlock",["a","b"]),"math/max":vs("FlowGraphMaxBlock",["a","b"]),"math/clamp":vs("FlowGraphClampBlock",["a","b","c"]),"math/saturate":vs("FlowGraphSaturateBlock"),"math/mix":vs("FlowGraphMathInterpolationBlock",["a","b","c"]),"math/eq":vs("FlowGraphEqualityBlock",["a","b"]),"math/lt":vs("FlowGraphLessThanBlock",["a","b"]),"math/le":vs("FlowGraphLessThanOrEqualBlock",["a","b"]),"math/gt":vs("FlowGraphGreaterThanBlock",["a","b"]),"math/ge":vs("FlowGraphGreaterThanOrEqualBlock",["a","b"]),"math/isNaN":vs("FlowGraphIsNaNBlock"),"math/isInf":vs("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":vs("FlowGraphSinBlock"),"math/cos":vs("FlowGraphCosBlock"),"math/tan":vs("FlowGraphTanBlock"),"math/asin":vs("FlowGraphASinBlock"),"math/acos":vs("FlowGraphACosBlock"),"math/atan":vs("FlowGraphATanBlock"),"math/atan2":vs("FlowGraphATan2Block",["a","b"]),"math/sinh":vs("FlowGraphSinhBlock"),"math/cosh":vs("FlowGraphCoshBlock"),"math/tanh":vs("FlowGraphTanhBlock"),"math/asinh":vs("FlowGraphASinhBlock"),"math/acosh":vs("FlowGraphACoshBlock"),"math/atanh":vs("FlowGraphATanhBlock"),"math/exp":vs("FlowGraphExponentialBlock"),"math/log":vs("FlowGraphLogBlock"),"math/log2":vs("FlowGraphLog2Block"),"math/log10":vs("FlowGraphLog10Block"),"math/sqrt":vs("FlowGraphSquareRootBlock"),"math/cbrt":vs("FlowGraphCubeRootBlock"),"math/pow":vs("FlowGraphPowerBlock",["a","b"]),"math/length":vs("FlowGraphLengthBlock"),"math/normalize":vs("FlowGraphNormalizeBlock"),"math/dot":vs("FlowGraphDotBlock",["a","b"]),"math/cross":vs("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":vs("FlowGraphTransposeBlock"),"math/determinant":vs("FlowGraphDeterminantBlock"),"math/inverse":vs("FlowGraphInvertMatrixBlock"),"math/matMul":vs("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,r,s,a,n){const o=a[0].dataInputs.find(e=>"rotationQuaternion"===e.name);if(!o)throw new Error("Rotation quaternion input not found");return n._connectionValues[o.uniqueId]&&(n._connectionValues[o.uniqueId].type="Quaternion"),a}},"math/matDecompose":{blocks:["FlowGraphMatrixDecompose"],inputs:{values:{a:{name:"input",gltfType:"number"}}},outputs:{values:{translation:{name:"position"},rotation:{name:"rotationQuaternion"},scale:{name:"scaling"}}}},"math/quatConjugate":vs("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,r,s,a){var n;return(n=a[0]).config||(n.config={}),a[0].config.type="Quaternion",a}},"math/quatAngleBetween":vs("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":vs("FlowGraphAxisAngleFromQuaternionBlock",["a"]),"math/quatFromDirections":vs("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,r,s,a){var n;return(n=a[0]).config||(n.config={}),a[0].config.inputIsColumnMajor=!0,a}},"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,r,s,a){var n;return(n=a[0]).config||(n.config={}),a[0].config.inputIsColumnMajor=!0,a}},"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,r,s,a){var n;return(n=a[0]).config||(n.config={}),a[0].config.inputIsColumnMajor=!0,a}},"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,r,s,a,n){var o,i,l;(l=a[0]).config||(l.config={});const u=a[0].dataInputs[0];return a[0].config.valueType=null!==(i=null===(o=n._connectionValues[u.uniqueId])||void 0===o?void 0:o.type)&&void 0!==i?i:"FlowGraphInteger",a}},"math/and":{blocks:["FlowGraphBitwiseAndBlock"],inputs:{values:{a:{name:"a"},b:{name:"b"}}},outputs:{values:{value:{name:"value"}}},extraProcessor(e,t,r,s,a,n){var o,i,l,u,c;(c=a[0]).config||(c.config={});const h=a[0].dataInputs[0],d=a[0].dataInputs[1];return a[0].config.valueType=null!==(u=null!==(i=null===(o=n._connectionValues[h.uniqueId])||void 0===o?void 0:o.type)&&void 0!==i?i:null===(l=n._connectionValues[d.uniqueId])||void 0===l?void 0:l.type)&&void 0!==u?u:"FlowGraphInteger",a}},"math/or":{blocks:["FlowGraphBitwiseOrBlock"],inputs:{values:{a:{name:"a"},b:{name:"b"}}},outputs:{values:{value:{name:"value"}}},extraProcessor(e,t,r,s,a,n){var o,i,l,u,c;(c=a[0]).config||(c.config={});const h=a[0].dataInputs[0],d=a[0].dataInputs[1];return a[0].config.valueType=null!==(u=null!==(i=null===(o=n._connectionValues[h.uniqueId])||void 0===o?void 0:o.type)&&void 0!==i?i:null===(l=n._connectionValues[d.uniqueId])||void 0===l?void 0:l.type)&&void 0!==u?u:"FlowGraphInteger",a}},"math/xor":{blocks:["FlowGraphBitwiseXorBlock"],inputs:{values:{a:{name:"a"},b:{name:"b"}}},outputs:{values:{value:{name:"value"}}},extraProcessor(e,t,r,s,a,n){var o,i,l,u,c;(c=a[0]).config||(c.config={});const h=a[0].dataInputs[0],d=a[0].dataInputs[1];return a[0].config.valueType=null!==(u=null!==(i=null===(o=n._connectionValues[h.uniqueId])||void 0===o?void 0:o.type)&&void 0!==i?i:null===(l=n._connectionValues[d.uniqueId])||void 0===l?void 0:l.type)&&void 0!==u?u:"FlowGraphInteger",a}},"math/asr":vs("FlowGraphBitwiseRightShiftBlock",["a","b"]),"math/lsl":vs("FlowGraphBitwiseLeftShiftBlock",["a","b"]),"math/clz":vs("FlowGraphLeadingZerosBlock"),"math/ctz":vs("FlowGraphTrailingZerosBlock"),"math/popcnt":vs("FlowGraphOneBitsCounterBlock"),"math/rad":vs("FlowGraphDegToRadBlock"),"math/deg":vs("FlowGraphRadToDegBlock"),"type/boolToInt":vs("FlowGraphBooleanToInt"),"type/boolToFloat":vs("FlowGraphBooleanToFloat"),"type/intToBool":vs("FlowGraphIntToBoolean"),"type/intToFloat":vs("FlowGraphIntToFloat"),"type/floatToInt":vs("FlowGraphFloatToInt"),"type/floatToBool":vs("FlowGraphFloatToBoolean"),"flow/sequence":{blocks:["FlowGraphSequenceBlock"],extraProcessor(e,t,r,s,a){const n=a[0];return n.config||(n.config={}),n.config.outputSignalCount=Object.keys(e.flows||[]).length,n.signalOutputs.forEach((e,t)=>{e.name="out_"+t}),a}},"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 r;const s=null===(r=e.configuration)||void 0===r?void 0:r.cases;if(s&&s.value){if(!s.value.every(e=>"number"==typeof e&&/^-?\d+$/.test(e.toString())))return t.Logger.Warn("Switch cases should be integers. Using empty array instead."),s.value=[],{valid:!0};const e=new Set(s.value);s.value=Array.from(e)}return{valid:!0}},extraProcessor(e,t,r,s,a){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 a[0].signalOutputs.forEach(e=>{"default"!==e.name&&(e.name="out_"+e.name)}),a}},"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,r,s,a){const n=a[0];return n.config||(n.config={}),n.config.incrementIndexWhenLoopDone=!0,a}},"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,r,s,a){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 n=a[0];return n.config||(n.config={}),n.config.outputSignalCount=Object.keys(e.flows).length,n.signalOutputs.forEach((e,t)=>{e.name="out_"+t}),a}},"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,r,s;return"number"!=typeof(null===(s=null===(r=null===(t=e.configuration)||void 0===t?void 0:t.inputFlows)||void 0===r?void 0:r.value)||void 0===s?void 0:s[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 r,s;return(null===(s=null===(r=e.configuration)||void 0===r?void 0:r.variable)||void 0===s?void 0:s.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,r,s,a)=>(a[0].dataInputs.forEach(e=>{e.name=s.getVariableName(+e.name)}),a)},"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,r,s,a,n){var o,i,l,u,c,h;const d=n[0],m=null===(i=null===(o=e.configuration)||void 0===o?void 0:o.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 _=a.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=n[4];return p.config||(p.config={}),(h=p.config).variable||(h.variable={}),p.config.variable.value=a.getVariableName(m),n}},"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,r,s,a)=>(a.forEach(e=>{"FlowGraphJsonPointerParserBlock"===e.className&&(e.config||(e.config={}),e.config.outputValue=!0)}),a)},"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,r,s,a)=>(a.forEach(e=>{"FlowGraphJsonPointerParserBlock"===e.className&&(e.config||(e.config={}),e.config.outputValue=!0)}),a)},"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,r,s,a)=>(a.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(r=>{var a;const n=null===(a=e.values)||void 0===a?void 0:a[r];if("value"===r&&n){const e=n.type;void 0!==e&&(t.config.animationType=s.arrays.types[e].flowGraphType)}}))}),a)},"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,r,s,a,n,o){const i=a[a.length-1];return i.config||(i.config={}),i.config.glTF=o,a}},"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,r,s,a,n,o){const i=a[a.length-1];return i.config||(i.config={}),i.config.glTF=o,a}},"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,r,s,a,n,o){const i=a[a.length-1];return i.config||(i.config={}),i.config.glTF=o,a}},"math/switch":{blocks:["FlowGraphDataSwitchBlock"],configuration:{cases:{name:"cases",isArray:!0,inOptions:!0,defaultValue:[]}},inputs:{values:{selection:{name:"case"}}},validation(e){var r;const s=null===(r=e.configuration)||void 0===r?void 0:r.cases;if(s&&s.value){if(!s.value.every(e=>"number"==typeof e&&/^-?\d+$/.test(e.toString())))return t.Logger.Warn("Switch cases should be integers. Using empty array instead."),s.value=[],{valid:!0};const e=new Set(s.value);s.value=Array.from(e)}return{valid:!0}},extraProcessor(e,t,r,s,a){const n=a[0];return n.dataInputs.forEach(e=>{"default"!==e.name&&"case"!==e.name&&(e.name="in_"+e.name)}),n.config||(n.config={}),n.config.treatCasesAsIntegers=!0,a}},"debug/log":{blocks:["FlowGraphConsoleLogBlock"],configuration:{message:{name:"messageTemplate",inOptions:!0}}}};function vs(e,t=["a"],r){return{blocks:[e],inputs:{values:t.reduce((e,t)=>(e[t]={name:t},e),{})},outputs:{values:{value:{name:"value"}}},extraProcessor(e,t,s,a,n){var o;if(r){(o=n[0]).config||(o.config={}),n[0].config.preventIntegerFloatArithmetic=!0;let t=-1;Object.keys(e.values||{}).find(r=>{var s;return void 0!==(null===(s=e.values)||void 0===s?void 0:s[r].type)&&(t=e.values[r].type,!0)}),-1!==t&&(n[0].config.type=a.arrays.types[t].flowGraphType)}return n},validation:e=>r?xs(e):{valid:!0}}}function xs(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 As(){return Object.keys(Ts)}const Cs={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 Rs{constructor(e,t,r=60){this._interactivityGraph=e,this._gltf=t,this._animationTargetFps=r,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(Cs[e.signature])}_parseDeclarations(){if(this._interactivityGraph.declarations)for(const e of this._interactivityGraph.declarations){const r=gs(e);if(!r)throw t.Logger.Error(["No mapping found for declaration",e]),new Error("Error parsing declarations");this._mappings.push({flowGraphMapping:r,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,r){const s=this._types[e.type];if(!s)throw t.Logger.Error(["No type found for variable",e]),new Error("Error parsing variables");if(e.value&&e.value.length!==s.length)throw t.Logger.Error(["Invalid value length for variable",e,s]),new Error("Error parsing variables");const a=e.value||[];if(!a.length)switch(s.flowGraphType){case"boolean":a.push(!1);break;case"FlowGraphInteger":a.push(0);break;case"number":a.push(NaN);break;case"Vector2":a.push(NaN,NaN);break;case"Vector3":a.push(NaN,NaN,NaN);break;case"Vector4":case"Matrix2D":case"Quaternion":a.fill(NaN,0,4);break;case"Matrix":a.fill(NaN,0,16);break;case"Matrix3D":a.fill(NaN,0,9)}return"number"===s.elementType&&"string"==typeof a[0]&&(a[0]=parseFloat(a[0])),{type:s.flowGraphType,value:r?r(a,this):a}}_parseEvents(){if(this._interactivityGraph.events)for(const e of this._interactivityGraph.events){const r={eventId:e.id||"internalEvent_"+this._internalEventsCounter++};e.values&&(r.eventData=Object.keys(e.values).map(r=>{var s;const a=null===(s=e.values)||void 0===s?void 0:s[r];if(!a)throw t.Logger.Error(["No value found for event key",r]),new Error("Error parsing events");const n=this._types[a.type];if(!n)throw t.Logger.Error(["No type found for event value",a]),new Error("Error parsing events");const o=void 0!==a.value?this._parseVariable(a):void 0;return{id:r,type:n.flowGraphType,eventData:!0,value:o}})),this._events.push(r)}}_parseNodes(){var e;if(this._interactivityGraph.nodes)for(const r of this._interactivityGraph.nodes){if("number"!=typeof r.declaration)throw t.Logger.Error(["No declaration found for node",r]),new Error("Error parsing nodes");const s=this._mappings[r.declaration];if(!s)throw t.Logger.Error(["No mapping found for node",r]),new Error("Error parsing nodes");if(s.flowGraphMapping.validation){const t=s.flowGraphMapping.validation(r,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[r.declaration].op} - ${t.error}`)}const a=[];for(const e of s.flowGraphMapping.blocks){const t=this._getEmptyBlock(e,s.fullOperationName);this._parseNodeConfiguration(r,t,s.flowGraphMapping,e),a.push(t)}this._nodes.push({blocks:a,fullOperationName:s.fullOperationName})}}_getEmptyBlock(e,r){return{uniqueId:t.RandomGUID(),className:e,dataInputs:[],dataOutputs:[],signalInputs:[],signalOutputs:[],config:{},type:r,metadata:{}}}_parseNodeConfiguration(e,r,s,a){var n;const o=e.configuration;if(o)for(const e in o){const i=o[e];if(!i)throw new Error("Error parsing node configuration");const l=null===(n=s.configuration)||void 0===n?void 0:n[e];if(l&&l.toBlock?l.toBlock===a:0===s.blocks.indexOf(a)){let s=null==l?void 0:l.defaultValue;(null==i?void 0:i.value)&&(s=i.value),(null==l?void 0:l.isArray)||(1!==s.length&&t.Logger.Warn(`Invalid non-array value length: ${s.length}`),s=s[0]),(null==l?void 0:l.dataTransformer)&&(s=l.dataTransformer(s,this)),void 0!==s&&(r.config[(null==l?void 0:l.name)||e]={value:s})}}}_parseNodeConnections(e){var r,s,a,n,o,i,l,u,c,h,d,m,_,p,f,g,b,y,T;for(let v=0;v<this._nodes.length;v++){const x=null===(r=this._interactivityGraph.nodes)||void 0===r?void 0:r[v];if(!x)throw t.Logger.Error(["No node found for interactivity node",this._nodes[v]]),new Error("Error parsing node connections");const A=this._nodes[v],C=this._mappings[x.declaration];if(!C)throw t.Logger.Error(["No mapping found for node",x]),new Error("Error parsing node connections");const R=x.flows||{},w=Object.keys(R).sort();for(const e of w){const r=R[e],c=null===(a=null===(s=C.flowGraphMapping.outputs)||void 0===s?void 0:s.flows)||void 0===a?void 0:a[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=r.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=fs(_.fullOperationName);if(!p)throw t.Logger.Error(["No mapping found for input node",_]),new Error("Error parsing node connections");let f=null===(o=null===(n=p.inputs)||void 0===n?void 0:n.flows)||void 0===o?void 0:o[r.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",r.socket||""):f.name:r.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 M=x.values||{},O=Object.keys(M);for(const r of O){const s=M[r];let a=null===(h=null===(c=C.flowGraphMapping.inputs)||void 0===c?void 0:c.values)||void 0===h?void 0:h[r],n=!1;if(!a)for(const e in null===(d=C.flowGraphMapping.inputs)||void 0===d?void 0:d.values)e.startsWith("[")&&e.endsWith("]")&&(n=!0,a=null===(_=null===(m=C.flowGraphMapping.inputs)||void 0===m?void 0:m.values)||void 0===_?void 0:_[e]);const o=a?n?a.name.replace("$1",r):a.name:r,i=this._createNewSocketConnection(o);if((a&&a.toBlock&&A.blocks.find(e=>e.className===a.toBlock)||A.blocks[0]).dataInputs.push(i),void 0!==s.value){const t=this._parseVariable(s,a&&a.dataTransformer);e._connectionValues[i.uniqueId]=t}else{if(void 0===s.node)throw t.Logger.Error(["Invalid value for value connection",s]),new Error("Error parsing node connections");{const e=s.node,r=s.socket||"value",a=this._nodes[e];if(!a)throw t.Logger.Error(["No node found for output socket reference",s]),new Error("Error parsing node connections");const n=fs(a.fullOperationName);if(!n)throw t.Logger.Error(["No mapping found for output socket reference",s]),new Error("Error parsing node connections");let o=null===(f=null===(p=n.outputs)||void 0===p?void 0:p.values)||void 0===f?void 0:f[r],l=!1;if(!o)for(const e in null===(g=n.outputs)||void 0===g?void 0:g.values)e.startsWith("[")&&e.endsWith("]")&&(l=!0,o=null===(y=null===(b=n.outputs)||void 0===b?void 0:b.values)||void 0===y?void 0:y[e]);const u=o?l?o.name.replace("$1",r):null==o?void 0:o.name:r,c=o&&o.toBlock&&a.blocks.find(e=>e.className===o.toBlock)||a.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,r=e.output,s=e.isVariable;this._connectFlowGraphNodes(t,r,A.blocks[e.inputBlockIndex],A.blocks[e.outputBlockIndex],s)}if(C.flowGraphMapping.extraProcessor){const r=null===(T=this._interactivityGraph.declarations)||void 0===T?void 0:T[x.declaration];if(!r)throw t.Logger.Error(["No declaration found for extra processor",x]),new Error("Error parsing node connections");A.blocks=C.flowGraphMapping.extraProcessor(x,r,C.flowGraphMapping,this,A.blocks,e,this._gltf)}}}_createNewSocketConnection(e,r){return{uniqueId:t.RandomGUID(),name:e,_connectionType:r?1:0,connectedPointIds:[]}}_connectFlowGraphNodes(e,t,r,s,a){const n=a?r.dataInputs:r.signalInputs,o=a?s.dataOutputs:s.signalOutputs,i=n.find(t=>t.name===e)||this._createNewSocketConnection(e),l=o.find(e=>e.name===t)||this._createNewSocketConnection(t,!0);n.find(t=>t.name===e)||n.push(i),o.find(e=>e.name===t)||o.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 r=this._staticVariables[t];e._userVariables[this.getVariableName(t)]=r}return{rightHanded:!0,allBlocks:this._nodes.reduce((e,t)=>e.concat(t.blocks),[]),executionContexts:[e]}}}const ws="KHR_interactivity";class Ms{constructor(e){this._loader=e,this.name=ws,this.enabled=this._loader.isExtensionUsed(ws),this._pathConverter=O(this._loader.gltf),e._skipStartAnimationStep=!0;const t=e.babylonScene;t&&Os(t)}dispose(){this._loader=null,delete this._pathConverter}onReady(){return S(this,void 0,void 0,function*(){var e;if(!this._loader.babylonScene||!this._pathConverter)return;const r=this._loader.babylonScene,s=null===(e=this._loader.gltf.extensions)||void 0===e?void 0:e.KHR_interactivity;if(!s)return;const a=new t.FlowGraphCoordinator({scene:r});a.dispatchEventsSynchronously=!1;const n=s.graphs.map(e=>new Rs(e,this._loader.gltf,this._loader.parent.targetFps).serializeToFlowGraph());yield Promise.all(n.map(e=>S(this,void 0,void 0,function*(){return yield t.ParseFlowGraphAsync(e,{coordinator:a,pathConverter:this._pathConverter})}))),a.start()})}}function Os(e){E("/extensions/KHR_interactivity/?/activeCamera/rotation",{get:()=>{if(!e.activeCamera)return new t.Quaternion(NaN,NaN,NaN,NaN);const r=t.Quaternion.FromRotationMatrix(e.activeCamera.getWorldMatrix()).normalize();return e.useRightHandedSystem||(r.w*=-1,r.x*=-1),r},type:"Quaternion",getTarget:()=>e.activeCamera}),E("/extensions/KHR_interactivity/?/activeCamera/position",{get:()=>{if(!e.activeCamera)return new t.Vector3(NaN,NaN,NaN);const r=e.activeCamera.getWorldMatrix().getTranslation();return e.useRightHandedSystem||(r.x*=-1),r},type:"Vector3",getTarget:()=>e.activeCamera}),E("/animations/{}/extensions/KHR_interactivity/isPlaying",{get:e=>{var t,r;return null!==(r=null===(t=e._babylonAnimationGroup)||void 0===t?void 0:t.isPlaying)&&void 0!==r&&r},type:"boolean",getTarget:e=>e._babylonAnimationGroup}),E("/animations/{}/extensions/KHR_interactivity/minTime",{get:e=>{var t,r;return(null!==(r=null===(t=e._babylonAnimationGroup)||void 0===t?void 0:t.from)&&void 0!==r?r:0)/60},type:"number",getTarget:e=>e._babylonAnimationGroup}),E("/animations/{}/extensions/KHR_interactivity/maxTime",{get:e=>{var t,r;return(null!==(r=null===(t=e._babylonAnimationGroup)||void 0===t?void 0:t.to)&&void 0!==r?r:0)/60},type:"number",getTarget:e=>e._babylonAnimationGroup}),E("/animations/{}/extensions/KHR_interactivity/playhead",{get:e=>{var t,r;return(null!==(r=null===(t=e._babylonAnimationGroup)||void 0===t?void 0:t.getCurrentFrame())&&void 0!==r?r:0)/60},type:"number",getTarget:e=>e._babylonAnimationGroup}),E("/animations/{}/extensions/KHR_interactivity/virtualPlayhead",{get:e=>{var t,r;return(null!==(r=null===(t=e._babylonAnimationGroup)||void 0===t?void 0:t.getCurrentFrame())&&void 0!==r?r:0)/60},type:"number",getTarget:e=>e._babylonAnimationGroup})}let Ls=!1;function Fs(){Ls||(Ls=!0,t.addToBlockFactory(ws,"FlowGraphGLTFDataProvider",()=>S(this,void 0,void 0,function*(){return(yield Promise.resolve().then(function(){return Xs})).FlowGraphGLTFDataProvider})),B(ws),P(ws,!0,e=>new Ms(e)))}Fs();const Es="KHR_node_visibility";class Ss{constructor(e){this.name=Es,this._loader=e,this.enabled=e.isExtensionUsed(Es)}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 ks=!1;function Is(){ks||(ks=!0,E("/nodes/{}/extensions/KHR_node_visibility/visible",{get:e=>{const t=e._babylonTransformNode;return!t||void 0===t.isVisible||t.isVisible},set:(e,t)=>{var r,s;null===(r=t._primitiveBabylonMeshes)||void 0===r||r.forEach(e=>{e.inheritVisibility=!0}),t._babylonTransformNode&&(t._babylonTransformNode.isVisible=e),null===(s=t._primitiveBabylonMeshes)||void 0===s||s.forEach(t=>{t.isVisible=e})},getTarget:e=>e._babylonTransformNode,getPropertyName:[()=>"isVisible"],type:"boolean"}),B(Es),P(Es,!0,e=>new Ss(e)))}Is();const Ps="KHR_node_selectability";class Bs{constructor(e){this.name=Ps,this._loader=e,this.enabled=e.isExtensionUsed(Ps)}onReady(){return S(this,void 0,void 0,function*(){var e;null===(e=this._loader.gltf.nodes)||void 0===e||e.forEach(e=>{var t,r,s;(null===(t=e.extensions)||void 0===t?void 0:t.KHR_node_selectability)&&!1===(null===(r=e.extensions)||void 0===r?void 0:r.KHR_node_selectability.selectable)&&(null===(s=e._babylonTransformNode)||void 0===s||s.getChildMeshes().forEach(e=>{e.isPickable=!1}))})})}dispose(){this._loader=null}}let Ns=!1;function Gs(){Ns||(Ns=!0,bs("event/onSelect",Ps,{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,r,s,a,n,o){var i,l,u,c,h,d,m;const _=a[a.length-1];_.config=_.config||{},_.config.glTF=o;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 a[1].config.variable=f,n._userVariables[f]={className:"Mesh",id:null===(h=null===(c=null==o?void 0:o.nodes)||void 0===c?void 0:c[p]._babylonTransformNode)||void 0===h?void 0:h.id,uniqueId:null===(m=null===(d=null==o?void 0:o.nodes)||void 0===d?void 0:d[p]._babylonTransformNode)||void 0===m?void 0:m.uniqueId},a}}),E("/nodes/{}/extensions/KHR_node_selectability/selectable",{get:e=>{const t=e._babylonTransformNode;return!t||void 0===t.isPickable||t.isPickable},set:(e,t)=>{var r;null===(r=t._primitiveBabylonMeshes)||void 0===r||r.forEach(t=>{t.isPickable=e})},getTarget:e=>e._babylonTransformNode,getPropertyName:[()=>"isPickable"],type:"boolean"}),B(Ps),P(Ps,!0,e=>new Bs(e)))}Gs();const Ds="KHR_node_hoverability",Vs="targetMeshPointerOver_",$s="targetMeshPointerOut_";class Hs{constructor(e){this.name=Ds,this._loader=e,this.enabled=e.isExtensionUsed(Ds)}onReady(){return S(this,void 0,void 0,function*(){var e;null===(e=this._loader.gltf.nodes)||void 0===e||e.forEach(e=>{var t,r,s;(null===(t=e.extensions)||void 0===t?void 0:t.KHR_node_hoverability)&&!1===(null===(r=e.extensions)||void 0===r?void 0:r.KHR_node_hoverability.hoverable)&&(null===(s=e._babylonTransformNode)||void 0===s||s.getChildMeshes().forEach(e=>{e.pointerOverDisableMeshTesting=!0}))})})}dispose(){this._loader=null}}let Ks=!1;function Ws(){Ks||(Ks=!0,bs("event/onHoverIn",Ds,{blocks:["FlowGraphPointerOverEventBlock","FlowGraphGetVariableBlock","FlowGraphIndexOfBlock","KHR_interactivity/FlowGraphGLTFDataProvider"],configuration:{stopPropagation:{name:"stopPropagation"},nodeIndex:{name:"variable",toBlock:"FlowGraphGetVariableBlock",dataTransformer:e=>Vs+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,r,s,a,n,o){var i,l,u,c,h,d,m;const _=a[a.length-1];_.config=_.config||{},_.config.glTF=o;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=Vs+p;return a[1].config.variable=f,n._userVariables[f]={className:"Mesh",id:null===(h=null===(c=null==o?void 0:o.nodes)||void 0===c?void 0:c[p]._babylonTransformNode)||void 0===h?void 0:h.id,uniqueId:null===(m=null===(d=null==o?void 0:o.nodes)||void 0===d?void 0:d[p]._babylonTransformNode)||void 0===m?void 0:m.uniqueId},a}}),bs("event/onHoverOut",Ds,{blocks:["FlowGraphPointerOutEventBlock","FlowGraphGetVariableBlock","FlowGraphIndexOfBlock","KHR_interactivity/FlowGraphGLTFDataProvider"],configuration:{stopPropagation:{name:"stopPropagation"},nodeIndex:{name:"variable",toBlock:"FlowGraphGetVariableBlock",dataTransformer:e=>$s+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,r,s,a,n,o){var i,l,u,c,h,d,m;const _=a[a.length-1];_.config=_.config||{},_.config.glTF=o;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=$s+p;return a[1].config.variable=f,n._userVariables[f]={className:"Mesh",id:null===(h=null===(c=null==o?void 0:o.nodes)||void 0===c?void 0:c[p]._babylonTransformNode)||void 0===h?void 0:h.id,uniqueId:null===(m=null===(d=null==o?void 0:o.nodes)||void 0===d?void 0:d[p]._babylonTransformNode)||void 0===m?void 0:m.uniqueId},a}}),E("/nodes/{}/extensions/KHR_node_hoverability/hoverable",{get:e=>{const t=e._babylonTransformNode;return!t||void 0===t.pointerOverDisableMeshTesting||t.pointerOverDisableMeshTesting},set:(e,t)=>{var r;null===(r=t._primitiveBabylonMeshes)||void 0===r||r.forEach(t=>{t.pointerOverDisableMeshTesting=!e})},getTarget:e=>e._babylonTransformNode,getPropertyName:[()=>"pointerOverDisableMeshTesting"],type:"boolean"}),B(Ds),P(Ds,!0,e=>new Hs(e)))}Ws();const Us="ExtrasAsMetadata";class zs{_assignExtras(e,t){if(t.extras&&Object.keys(t.extras).length>0){const r=e.metadata=e.metadata||{};(r.gltf=r.gltf||{}).extras=t.extras}}constructor(e){this.name=Us,this.enabled=!0,this._loader=e}dispose(){this._loader=null}loadNodeAsync(e,t,r){return this._loader.loadNodeAsync(e,t,e=>{this._assignExtras(e,t),r(e)})}loadCameraAsync(e,t,r){return this._loader.loadCameraAsync(e,t,e=>{this._assignExtras(e,t),r(e)})}createMaterial(e,t,r){const s=this._loader.createMaterial(e,t,r);return this._assignExtras(s,t),s}loadAnimationAsync(e,t){return this._loader.loadAnimationAsync(e,t).then(e=>(this._assignExtras(e,t),e))}}let qs=!1;function js(){qs||(qs=!0,B(Us),P(Us,!1,e=>new zs(e)))}js();class Ys extends t.FlowGraphBlock{constructor(e){var r,s;super(e);const a=e.glTF,n=(null===(r=null==a?void 0:a.animations)||void 0===r?void 0:r.map(e=>e._babylonAnimationGroup))||[];this.animationGroups=this.registerDataOutput("animationGroups",t.RichTypeAny,n);const o=(null===(s=null==a?void 0:a.nodes)||void 0===s?void 0:s.map(e=>e._babylonTransformNode))||[];this.nodes=this.registerDataOutput("nodes",t.RichTypeAny,o)}getClassName(){return"FlowGraphGLTFDataProvider"}}var Xs={__proto__:null,FlowGraphGLTFDataProvider:Ys},Qs={__proto__:null,AddObjectAccessorToKey:E,EXT_lights_area:Fe,EXT_lights_ies:he,EXT_lights_image_based:U,EXT_mesh_gpu_instancing:Y,EXT_meshopt_compression:Z,EXT_texture_avif:ie,EXT_texture_webp:se,ExtrasAsMetadata:zs,FlowGraphGLTFDataProvider:Ys,GetMappingForKey:L,GetPathToObjectConverter:O,InteractivityGraphToFlowGraphParser:Rs,KHR_animation_pointer:fr,KHR_draco_mesh_compression:pe,KHR_gaussian_splatting:xe,KHR_interactivity:Ms,KHR_lights:we,KHR_materials_anisotropy:et,KHR_materials_clearcoat:He,KHR_materials_coat:ze,KHR_materials_diffuse_roughness:Xt,KHR_materials_diffuse_transmission:It,KHR_materials_dispersion:zt,KHR_materials_emissive_strength:at,KHR_materials_fuzz:dt,KHR_materials_ior:Tt,KHR_materials_iridescence:Xe,KHR_materials_pbrSpecularGlossiness:Ie,KHR_materials_sheen:lt,KHR_materials_specular:ft,KHR_materials_transmission:Ft,KHR_materials_unlit:Ge,KHR_materials_variants:Ct,KHR_materials_volume:Gt,KHR_materials_volume_scatter:Ht,KHR_mesh_quantization:er,KHR_node_hoverability:Hs,KHR_node_selectability:Bs,KHR_node_visibility:Ss,KHR_texture_basisu:ar,KHR_texture_transform:lr,KHR_xmp_json_ld:dr,MSFT_audio_emitter:ts,MSFT_lod:ns,MSFT_minecraftMesh:us,MSFT_sRGBFactors:ms,RegisterEXT_lights_area:Se,RegisterEXT_lights_ies:me,RegisterEXT_lights_image_based:q,RegisterEXT_mesh_gpu_instancing:Q,RegisterEXT_meshopt_compression:te,RegisterEXT_texture_avif:ue,RegisterEXT_texture_webp:ne,RegisterExtrasAsMetadata:js,RegisterKHR_animation_pointer:br,RegisterKHR_draco_mesh_compression:ge,RegisterKHR_gaussian_splatting:Ce,RegisterKHR_interactivity:Fs,RegisterKHR_lights:Oe,RegisterKHR_materials_anisotropy:rt,RegisterKHR_materials_clearcoat:We,RegisterKHR_materials_coat:je,RegisterKHR_materials_diffuse_roughness:Jt,RegisterKHR_materials_diffuse_transmission:Bt,RegisterKHR_materials_dispersion:jt,RegisterKHR_materials_emissive_strength:ot,RegisterKHR_materials_fuzz:_t,RegisterKHR_materials_ior:xt,RegisterKHR_materials_iridescence:Je,RegisterKHR_materials_pbrSpecularGlossiness:Be,RegisterKHR_materials_sheen:ct,RegisterKHR_materials_specular:bt,RegisterKHR_materials_transmission:St,RegisterKHR_materials_unlit:Ve,RegisterKHR_materials_variants:wt,RegisterKHR_materials_volume:Vt,RegisterKHR_materials_volume_scatter:Wt,RegisterKHR_mesh_quantization:rr,RegisterKHR_node_hoverability:Ws,RegisterKHR_node_selectability:Gs,RegisterKHR_node_visibility:Is,RegisterKHR_texture_basisu:or,RegisterKHR_texture_transform:cr,RegisterKHR_xmp_json_ld:_r,RegisterMSFT_audio_emitter:ss,RegisterMSFT_lod:is,RegisterMSFT_minecraftMesh:hs,RegisterMSFT_sRGBFactors:ps,SetInterpolationForKey:F,TransmissionHelper:Mt,_AddInteractivityObjectModel:Os,addNewInteractivityFlowGraphMapping:bs,ensureTransmissionHelper:Ot,getAllSupportedNativeNodeTypes:As,getMappingForDeclaration:gs,getMappingForFullOperationName:fs,gltfTypeToBabylonType:Cs};K(),y();class Js{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 S(this,void 0,void 0,function*(){var r,s,a;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 n=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===(r=n.texture)||void 0===r||r.dispose());this.specularRoughnessTexture=n.texture,this.specularRoughness=n.factor?n.factor.r:1;const o=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===(s=o.texture)||void 0===s||s.dispose());this.baseMetalnessTexture=o.texture,this.baseMetalness=o.factor?o.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({},o),{dispose:void 0,colorSpace:t.TextureColorSpace.Linear}),this._material.getScene(),t.TextureColorSpace.SRGB,t.ChannelMask.RGB);if(e._disposed)return void(null===(a=i.texture)||void 0===a||a.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,r,s,a,n,o){return S(this,arguments,void 0,function*(e,r,s,a,n,o,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,v=this._material.geometryCoatNormalTexture,x=new t.Color4(g,g,g,g),A=new t.Color4(r,r,r,r);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,x,t.TextureChannel.R),this._material.getScene(),t.TextureColorSpace.SRGB),t.LerpTexturesAsync("lerpSurfaceColor",t.CreateTextureWithFactorOperand(null,new t.Color4(1,1,1,1)),t.CreateTextureWithFactorOperand(o,n.toColor4(),t.TextureChannel.RGBA,t.TextureColorSpace.SRGB),t.CreateTextureWithFactorOperand(s,A,a),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[w,M]=C.map(e=>e.value);if(e._disposed)return null===(u=w.texture)||void 0===u||u.dispose(),void(null===(c=M.texture)||void 0===c||c.dispose());const O=yield t.MultiplyTexturesAsync("newCoatColor ("+this._material.name+")",w,M,this._material.getScene(),t.TextureColorSpace.SRGB);if(e._disposed)return void(null===(h=O.texture)||void 0===h||h.dispose());O.texture?(this.coatColorTexture=O.texture,this.coatColor=t.Color3.White()):O.factor&&(this.coatColorTexture=null,this.coatColor.fromArray([O.factor.r,O.factor.g,O.factor.b]));const L=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,x,t.TextureChannel.R),this._material.getScene());if(e._disposed)return void(null===(d=L.texture)||void 0===d||d.dispose());this.coatIor=L.factor?L.factor.r:this.coatIor;const F=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,x,t.TextureChannel.R),this._material.getScene());if(e._disposed)return void(null===(m=F.texture)||void 0===m||m.dispose());this.coatRoughness=F.factor?F.factor.r:1,this.coatRoughnessTexture=F.texture;const E=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,x,t.TextureChannel.R),this._material.getScene());if(e._disposed)null===(_=E.texture)||void 0===_||_.dispose();else{if(this.coatDarkening=E.factor?E.factor.r:this.coatDarkening,i){const r=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(s,A,a),this._material.getScene());if(e._disposed)return void(null===(p=r.texture)||void 0===p||p.dispose());this.specularRoughness=r.factor?r.factor.r:1,this.specularRoughnessTexture=r.texture}if(v||this.geometryNormalTexture){const r=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(v,v?new t.Color4(1,1,1,1):new t.Color4(.5,.5,1,1),t.TextureChannel.RGBA),t.CreateTextureWithFactorOperand(b,x,t.TextureChannel.R),this._material.getScene());if(e._disposed)return void(null===(f=r.texture)||void 0===f||f.dispose());r.texture&&(this.geometryCoatNormalTexture=r.texture)}}})}}var Zs={__proto__:null,OpenPBRMaterialLoadingAdapter:Js};class ea{constructor(e){this._specWorkflow=!1,this._material=e,this._material.enableSpecularAntiAliasing=!0}get material(){return this._material}finalizeAsync(e){return S(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 r=new t.Vector3(-Math.log(this.transmissionColor.r),-Math.log(this.transmissionColor.g),-Math.log(this.transmissionColor.b));r.scaleInPlace(1/Math.max(this.transmissionDepth,.001));const s=r,a=Math.max(s.x,Math.max(s.y,s.z)),n=a>0?1/a:1;this._material.subSurface.diffusionDistance=new t.Color3(Math.exp(-s.x*n),Math.exp(-s.y*n),Math.exp(-s.z*n))}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 ta={__proto__:null,PBRMaterialLoadingAdapter:ea},ra={__proto__:null,AddObjectAccessorToKey:E,AnimationPropertyInfo:xr,ArrayItem:D,EXT_lights_area:Fe,EXT_lights_ies:he,EXT_lights_image_based:U,EXT_mesh_gpu_instancing:Y,EXT_meshopt_compression:Z,EXT_texture_avif:ie,EXT_texture_webp:se,ExtrasAsMetadata:zs,FlowGraphGLTFDataProvider:Ys,GLTFFileLoader:g,GLTFLoader:$,GetMappingForKey:L,GetPathToObjectConverter:O,InteractivityGraphToFlowGraphParser:Rs,KHR_animation_pointer:fr,KHR_draco_mesh_compression:pe,KHR_gaussian_splatting:xe,KHR_interactivity:Ms,KHR_lights:we,KHR_materials_anisotropy:et,KHR_materials_clearcoat:He,KHR_materials_coat:ze,KHR_materials_diffuse_roughness:Xt,KHR_materials_diffuse_transmission:It,KHR_materials_dispersion:zt,KHR_materials_emissive_strength:at,KHR_materials_fuzz:dt,KHR_materials_ior:Tt,KHR_materials_iridescence:Xe,KHR_materials_pbrSpecularGlossiness:Ie,KHR_materials_sheen:lt,KHR_materials_specular:ft,KHR_materials_transmission:Ft,KHR_materials_unlit:Ge,KHR_materials_variants:Ct,KHR_materials_volume:Gt,KHR_materials_volume_scatter:Ht,KHR_mesh_quantization:er,KHR_node_hoverability:Hs,KHR_node_selectability:Bs,KHR_node_visibility:Ss,KHR_texture_basisu:ar,KHR_texture_transform:lr,KHR_xmp_json_ld:dr,LoadBoundingInfoFromPositionAccessor:V,MSFT_audio_emitter:ts,MSFT_lod:ns,MSFT_minecraftMesh:us,MSFT_sRGBFactors:ms,OpenPBRMaterialLoadingAdapter:Js,PBRMaterialLoadingAdapter:ea,RegisterEXT_lights_area:Se,RegisterEXT_lights_ies:me,RegisterEXT_lights_image_based:q,RegisterEXT_mesh_gpu_instancing:Q,RegisterEXT_meshopt_compression:te,RegisterEXT_texture_avif:ue,RegisterEXT_texture_webp:ne,RegisterExtrasAsMetadata:js,RegisterGLTF2Loader:K,RegisterKHR_animation_pointer:br,RegisterKHR_draco_mesh_compression:ge,RegisterKHR_gaussian_splatting:Ce,RegisterKHR_interactivity:Fs,RegisterKHR_lights:Oe,RegisterKHR_materials_anisotropy:rt,RegisterKHR_materials_clearcoat:We,RegisterKHR_materials_coat:je,RegisterKHR_materials_diffuse_roughness:Jt,RegisterKHR_materials_diffuse_transmission:Bt,RegisterKHR_materials_dispersion:jt,RegisterKHR_materials_emissive_strength:ot,RegisterKHR_materials_fuzz:_t,RegisterKHR_materials_ior:xt,RegisterKHR_materials_iridescence:Je,RegisterKHR_materials_pbrSpecularGlossiness:Be,RegisterKHR_materials_sheen:ct,RegisterKHR_materials_specular:bt,RegisterKHR_materials_transmission:St,RegisterKHR_materials_unlit:Ve,RegisterKHR_materials_variants:wt,RegisterKHR_materials_volume:Vt,RegisterKHR_materials_volume_scatter:Wt,RegisterKHR_mesh_quantization:rr,RegisterKHR_node_hoverability:Ws,RegisterKHR_node_selectability:Gs,RegisterKHR_node_visibility:Is,RegisterKHR_texture_basisu:or,RegisterKHR_texture_transform:cr,RegisterKHR_xmp_json_ld:_r,RegisterMSFT_audio_emitter:ss,RegisterMSFT_lod:is,RegisterMSFT_minecraftMesh:hs,RegisterMSFT_sRGBFactors:ps,SetInterpolationForKey:F,TransformNodeAnimationPropertyInfo:Ar,TransmissionHelper:Mt,WeightAnimationPropertyInfo:Cr,_AddInteractivityObjectModel:Os,addNewInteractivityFlowGraphMapping:bs,ensureTransmissionHelper:Ot,getAllSupportedNativeNodeTypes:As,getMappingForDeclaration:gs,getMappingForFullOperationName:fs,getQuaternion:Tr,getVector3:yr,getWeights:vr,gltfTypeToBabylonType:Cs,registerGLTFExtension:P,registeredGLTFExtensions:I,unregisterGLTFExtension:B};const sa=Object.assign({},Qs),aa=Object.assign(Object.assign({},{__proto__:null}),{Extensions:sa}),na=Object.assign(Object.assign({},ra),{Loader:aa}),oa="undefined"!=typeof global?global:"undefined"!=typeof window?window:void 0;if(void 0!==oa){oa.BABYLON=oa.BABYLON||{};const e=oa.BABYLON;e.GLTF2=e.GLTF2||{},e.GLTF2.Loader=e.GLTF2.Loader||{},e.GLTF2.Loader.Extensions=e.GLTF2.Loader.Extensions||{};const t=["Loader"];for(const r in sa)e.GLTF2.Loader.Extensions[r]=sa[r],t.push(r);for(const r in aa)"Extensions"!==r&&(e.GLTF2.Loader[r]=aa[r],t.push(r));for(const r in na)t.indexOf(r)>-1||(e.GLTF2[r]=na[r])}e.GLTF2=na,e.GLTFFileLoader=g,e.GLTFLoaderDefaultOptions=p,e.GLTFValidation=a,e.RegisterGLTFFileLoader=y});
|
|
2
2
|
//# sourceMappingURL=babylon.glTF2FileLoader.min.js.map
|