babylonjs-loaders 9.12.0 → 9.13.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/babylonjs.loaders.d.ts +1477 -1
- 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 +3021 -2
- package/package.json +3 -3
package/babylonjs.loaders.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("babylonjs")):"function"==typeof define&&define.amd?define(["exports","babylonjs"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).BABYLON=e.BABYLON||{},e.BABYLON)}(this,function(e,t){"use strict";var n="Xposition",r="Yposition",o="Zposition",a="Xrotation",i="Yrotation",s="Zrotation",l=function(e){this.loopMode=t.Animation.ANIMATIONLOOPMODE_CYCLE,this.list=[],this.root=u(),this.numFrames=0,this.frameRate=0,this.skeleton=e};function u(){return{name:"",type:"",offset:new t.Vector3,channels:[],children:[],frames:[],parent:null}}function c(e,l,u){for(var f=function(e){var n=e.offset.x,r=e.offset.y,o=e.offset.z;return t.Matrix.Translation(n,r,o)}(e),h=new t.Bone(e.name,u.skeleton,l,f),d=function(e,l){if(0===e.frames.length)return[];for(var u=[],c=e.channels.some(function(e){return e===n||e===r||e===o}),f=e.channels.some(function(e){return e===a||e===i||e===s}),h=new t.Animation("".concat(e.name,"_pos"),"position",l.frameRate,t.Animation.ANIMATIONTYPE_VECTOR3,l.loopMode),d=new t.Animation("".concat(e.name,"_rot"),"rotationQuaternion",l.frameRate,t.Animation.ANIMATIONTYPE_QUATERNION,l.loopMode),p=[],m=[],_=0;_<e.frames.length;_++){var g=e.frames[_];c&&g.position&&p.push({frame:g.frame,value:g.position.clone()}),f&&m.push({frame:g.frame,value:g.rotation.clone()})}return p.length>0&&(h.setKeys(p),u.push(h)),m.length>0&&(d.setKeys(m),u.push(d)),u}(e,u),p=0,m=d;p<m.length;p++){var _=m[p];_.getKeys()&&_.getKeys().length>0&&h.animations.push(_)}for(var g=0,b=e.children;g<b.length;g++)c(b[g],h,u)}function f(e,l,u,c){if("ENDSITE"!==u.type){var h={frame:0,position:new t.Vector3,rotation:new t.Quaternion};h.frame=l,h.position=new t.Vector3,h.rotation=new t.Quaternion,u.frames.push(h);for(var d=t.Matrix.Identity(),p=0;p<u.channels.length;++p){var m=u.channels[p],_=e[c.i++];if(_){var g=parseFloat(_.trim());if(m.endsWith("position"))switch(m){case n:h.position.x=g;break;case r:h.position.y=g;break;case o:h.position.z=g}else if(m.endsWith("rotation")){var b=t.Tools.ToRadians(g),y=void 0;switch(m){case a:y=t.Matrix.RotationX(b);break;case i:y=t.Matrix.RotationY(b);break;case s:y=t.Matrix.RotationZ(b)}d=y.multiply(d)}}}t.Quaternion.FromRotationMatrixToRef(d,h.rotation);for(var v=0,T=u.children;v<T.length;v++)f(e,l,T[v],c)}}function h(e,n,r,o){var a,i,s,l,c=u();c.parent=r,o.list.push(c);var f=n.trim().split(/\s+/);if("END"===f[0].toUpperCase()&&"SITE"===f[1].toUpperCase()?(c.type="ENDSITE",c.name="ENDSITE"):(c.name=f[1],c.type=f[0].toUpperCase()),"{"!=(null===(a=e.shift())||void 0===a?void 0:a.trim()))throw new Error("Expected opening { after type & name");var d=null===(i=e.shift())||void 0===i?void 0:i.trim().split(/\s+/);if(!d)throw new Error("Unexpected end of file: missing OFFSET");if("OFFSET"!=(f=d)[0].toUpperCase())throw new Error("Expected OFFSET, but got: "+f[0]);if(4!=f.length)throw new Error("OFFSET: Invalid number of values");var p=new t.Vector3(parseFloat(f[1]),parseFloat(f[2]),parseFloat(f[3]));if(isNaN(p.x)||isNaN(p.y)||isNaN(p.z))throw new Error("OFFSET: Invalid values");if(c.offset=p,"ENDSITE"!=c.type){if(!(f=null===(s=e.shift())||void 0===s?void 0:s.trim().split(/\s+/)))throw new Error("Unexpected end of file: missing CHANNELS");if("CHANNELS"!=f[0].toUpperCase())throw new Error("Expected CHANNELS definition");var m=parseInt(f[1]);c.channels=f.splice(2,m),c.children=[]}for(;e.length>0;){var _=null===(l=e.shift())||void 0===l?void 0:l.trim();if("}"===_)return c;_&&c.children.push(h(e,_,c,o))}throw new Error("Unexpected end of file: missing closing brace")}function d(e,n,r,o){var a=e.split("\n"),i=o.loopMode;n._blockEntityCollection=!!r;var s=new t.Skeleton("","",n);s._parentContainer=r,n._blockEntityCollection=!1;var u=new l(s);u.loopMode=i;var d=a.shift();if(!d||"HIERARCHY"!==d.trim().toUpperCase())throw new Error("HIERARCHY expected");var p=a.shift();if(!p)throw new Error("Unexpected end of file after HIERARCHY");var m=h(a,p.trim(),null,u),_=a.shift();if(!_||"MOTION"!==_.trim().toUpperCase())throw new Error("MOTION expected");var g=a.shift();if(!g)throw new Error("Unexpected end of file before frame count");var b=g.trim().split(/[\s]+/);if(b.length<2)throw new Error("Invalid frame count line");var y=parseInt(b[1]);if(isNaN(y))throw new Error("Failed to read number of frames.");u.numFrames=y;var v=a.shift();if(!v)throw new Error("Unexpected end of file before frame time");var T=v.trim().split(/[\s]+/);if(T.length<3)throw new Error("Invalid frame time line");var x=parseFloat(T[2]);if(isNaN(x))throw new Error("Failed to read frame time.");if(x<=0)throw new Error("Failed to read frame time. Invalid value "+x);u.frameRate=1/x;for(var A=0;A<y;++A){var w=a.shift();w&&f(w.trim().split(/[\s]+/)||[],A,m,{i:0})}return u.root=m,c(u.root,null,u),u.skeleton.returnToRest(),u.skeleton}var p=function(e,t){return p=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},p(e,t)};function m(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}p(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}var _=function(){return _=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},_.apply(this,arguments)};function g(e,t,n,r){return new(n||(n=Promise))(function(o,a){function i(e){try{l(r.next(e))}catch(e){a(e)}}function s(e){try{l(r.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(i,s)}l((r=r.apply(e,t||[])).next())})}function b(e,t){var n,r,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=s(0),i.throw=s(1),i.return=s(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(l){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(n=1,r&&(o=2&s[0]?r.return:s[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,s[1])).done)return o;switch(r=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,r=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){a.label=s[1];break}if(6===s[0]&&a.label<o[1]){a.label=o[1],o=s;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(s);break}o[2]&&a.ops.pop(),a.trys.pop();continue}s=t.call(e,a)}catch(e){s=[6,e],r=0}finally{n=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,l])}}}function y(e,t,n){if(n||2===arguments.length)for(var r,o=0,a=t.length;o<a;o++)!r&&o in t||(r||(r=Array.prototype.slice.call(t,0,o)),r[o]=t[o]);return e.concat(r||Array.prototype.slice.call(t))}Object.create,Object.create,"function"==typeof SuppressedError&&SuppressedError;var v={name:"bvh",extensions:{".bvh":{isBinary:!1}}},T=function(){function e(t){this.name=v.name,this.extensions=v.extensions,this._loadingOptions=_(_({},e._DefaultLoadingOptions),null!=t?t:{})}return Object.defineProperty(e,"_DefaultLoadingOptions",{get:function(){return{loopMode:t.Animation.ANIMATIONLOOPMODE_CYCLE}},enumerable:!1,configurable:!0}),e.prototype.createPlugin=function(t){return new e(t[v.name])},e.prototype.canDirectLoad=function(e){return this.isBvhHeader(e)},e.prototype.isBvhHeader=function(e){return"HIERARCHY"==e.split("\n")[0]},e.prototype.isNotBvhHeader=function(e){return!this.isBvhHeader(e)},e.prototype.importMeshAsync=function(e,t,n){if("string"!=typeof n)return Promise.reject("BVH loader expects string data.");if(this.isNotBvhHeader(n))return Promise.reject("BVH loader expects HIERARCHY header.");try{var r=d(n,t,null,this._loadingOptions);return Promise.resolve({meshes:[],particleSystems:[],skeletons:[r],animationGroups:[],transformNodes:[],geometries:[],lights:[],spriteManagers:[]})}catch(e){return Promise.reject(e)}},e.prototype.loadAsync=function(e,t){return"string"!=typeof t?Promise.reject("BVH loader expects string data."):this.isNotBvhHeader(t)?Promise.reject("BVH loader expects HIERARCHY header."):this.importMeshAsync(null,e,t).then(function(){})},e.prototype.loadAssetContainerAsync=function(e,n){if("string"!=typeof n)return Promise.reject("BVH loader expects string data.");if(this.isNotBvhHeader(n))return Promise.reject("BVH loader expects HIERARCHY header.");var r=new t.AssetContainer(e);try{var o=d(n,e,r,this._loadingOptions);return r.skeletons.push(o),Promise.resolve(r)}catch(e){return Promise.reject(e)}},e}();t.RegisterSceneLoaderPlugin(new T);var x={__proto__:null,BVHFileLoader:T},A={__proto__:null,BVHFileLoader:T,ReadBvh:d};function w(e,t,n,r){var o={externalResourceFunction:r};return n&&(o.uri="file:"===t?n:t+n),ArrayBuffer.isView(e)?GLTFValidator.validateBytes(e,o):GLTFValidator.validateString(e,o)}function O(){var e=[];onmessage=function(t){var n=t.data;switch(n.id){case"init":importScripts(n.url);break;case"validate":w(n.data,n.rootUrl,n.fileName,function(t){return new Promise(function(n,r){var o=e.length;e.push({resolve:n,reject:r}),postMessage({id:"getExternalResource",index:o,uri:t})})}).then(function(e){postMessage({id:"validate.resolve",value:e})},function(e){postMessage({id:"validate.reject",reason:e})});break;case"getExternalResource.resolve":e[n.index].resolve(n.value);break;case"getExternalResource.reject":e[n.index].reject(n.reason)}}}var C,M,E,R=function(){function e(){}return e.ValidateAsync=function(n,r,o,a){var i=this;return"function"==typeof Worker?new Promise(function(s,l){var u="".concat(w,"(").concat(O,")()"),c=URL.createObjectURL(new Blob([u],{type:"application/javascript"})),f=new Worker(c),h=function(e){f.removeEventListener("error",h),f.removeEventListener("message",d),l(e)},d=function(t){var n=t.data;switch(n.id){case"getExternalResource":a(n.uri).then(function(e){f.postMessage({id:"getExternalResource.resolve",index:n.index,value:e},[e.buffer])},function(e){f.postMessage({id:"getExternalResource.reject",index:n.index,reason:e})});break;case"validate.resolve":f.removeEventListener("error",h),f.removeEventListener("message",d),e._LastResults=n.value,s(n.value),f.terminate();break;case"validate.reject":f.removeEventListener("error",h),f.removeEventListener("message",d),l(n.reason),f.terminate()}};if(f.addEventListener("error",h),f.addEventListener("message",d),f.postMessage({id:"init",url:t.Tools.GetBabylonScriptURL(i.Configuration.url)}),ArrayBuffer.isView(n)){var p=n.slice();f.postMessage({id:"validate",data:p,rootUrl:r,fileName:o},[p.buffer])}else f.postMessage({id:"validate",data:n,rootUrl:r,fileName:o})}):(this._LoadScriptPromise||(this._LoadScriptPromise=t.Tools.LoadBabylonScriptAsync(this.Configuration.url)),this._LoadScriptPromise.then(function(){return w(n,r,o,a)}))},e.Configuration={url:"".concat(t.Tools._DefaultCdnUrl,"/gltf_validator.js")},e._LastResults=null,e}(),F={__proto__:null,GLTFValidation:R},L="Z2xURg",P={name:"gltf",extensions:{".gltf":{isBinary:!1,mimeType:"model/gltf+json"},".glb":{isBinary:!0,mimeType:"model/gltf-binary"}},canDirectLoad:function(e){return-1!==e.indexOf("asset")&&-1!==e.indexOf("version")||e.startsWith("data:base64,"+L)||e.startsWith("data:;base64,"+L)||e.startsWith("data:application/octet-stream;base64,"+L)||e.startsWith("data:model/gltf-binary;base64,"+L)}};function S(e,t,n){try{return Promise.resolve(new Uint8Array(e,t,n))}catch(e){return Promise.reject(e)}}e.GLTFLoaderCoordinateSystemMode=void 0,(C=e.GLTFLoaderCoordinateSystemMode||(e.GLTFLoaderCoordinateSystemMode={}))[C.AUTO=0]="AUTO",C[C.FORCE_RIGHT_HANDED=1]="FORCE_RIGHT_HANDED",e.GLTFLoaderAnimationStartMode=void 0,(M=e.GLTFLoaderAnimationStartMode||(e.GLTFLoaderAnimationStartMode={}))[M.NONE=0]="NONE",M[M.FIRST=1]="FIRST",M[M.ALL=2]="ALL",e.GLTFLoaderState=void 0,(E=e.GLTFLoaderState||(e.GLTFLoaderState={}))[E.LOADING=0]="LOADING",E[E.READY=1]="READY",E[E.COMPLETE=2]="COMPLETE";var N=function(){this.alwaysComputeBoundingBox=!1,this.alwaysComputeSkeletonRootNode=!1,this.animationStartMode=e.GLTFLoaderAnimationStartMode.FIRST,this.compileMaterials=!1,this.compileShadowGenerators=!1,this.coordinateSystemMode=e.GLTFLoaderCoordinateSystemMode.AUTO,this.createInstances=!0,this.loadAllMaterials=!1,this.loadMorphTargets=!0,this.loadNodeAnimations=!0,this.loadOnlyMaterials=!1,this.loadSkins=!0,this.skipMaterials=!1,this.targetFps=60,this.transparencyAsCoverage=!1,this.useClipPlane=!1,this.useGltfTextureNames=!1,this.useRangeRequests=!1,this.useSRGBBuffers=!0,this.validate=!1,this.useOpenPBR=!1,this.dontUseTransmissionHelper=!1},I=new N,B=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.extensionOptions={},t.preprocessUrlAsync=function(e){return Promise.resolve(e)},t}return m(t,e),t.prototype.copyFrom=function(e){var t,n,r,o,a,i,s,l,u,c,f,h,d,p,m,_,g,b,y,v,T,x,A,w,O,C;e&&(this.alwaysComputeBoundingBox=null!==(t=e.alwaysComputeBoundingBox)&&void 0!==t?t:this.alwaysComputeBoundingBox,this.alwaysComputeSkeletonRootNode=null!==(n=e.alwaysComputeSkeletonRootNode)&&void 0!==n?n:this.alwaysComputeSkeletonRootNode,this.animationStartMode=null!==(r=e.animationStartMode)&&void 0!==r?r:this.animationStartMode,this.capturePerformanceCounters=null!==(o=e.capturePerformanceCounters)&&void 0!==o?o:this.capturePerformanceCounters,this.compileMaterials=null!==(a=e.compileMaterials)&&void 0!==a?a:this.compileMaterials,this.compileShadowGenerators=null!==(i=e.compileShadowGenerators)&&void 0!==i?i:this.compileShadowGenerators,this.coordinateSystemMode=null!==(s=e.coordinateSystemMode)&&void 0!==s?s:this.coordinateSystemMode,this.createInstances=null!==(l=e.createInstances)&&void 0!==l?l:this.createInstances,this.customRootNode=e.customRootNode,this.extensionOptions=null!==(u=e.extensionOptions)&&void 0!==u?u:this.extensionOptions,this.loadAllMaterials=null!==(c=e.loadAllMaterials)&&void 0!==c?c:this.loadAllMaterials,this.loadMorphTargets=null!==(f=e.loadMorphTargets)&&void 0!==f?f:this.loadMorphTargets,this.loadNodeAnimations=null!==(h=e.loadNodeAnimations)&&void 0!==h?h:this.loadNodeAnimations,this.loadOnlyMaterials=null!==(d=e.loadOnlyMaterials)&&void 0!==d?d:this.loadOnlyMaterials,this.loadSkins=null!==(p=e.loadSkins)&&void 0!==p?p:this.loadSkins,this.loggingEnabled=null!==(m=e.loggingEnabled)&&void 0!==m?m:this.loggingEnabled,this.onCameraLoaded=e.onCameraLoaded,this.onMaterialLoaded=e.onMaterialLoaded,this.onMeshLoaded=e.onMeshLoaded,this.onParsed=e.onParsed,this.onSkinLoaded=e.onSkinLoaded,this.onTextureLoaded=e.onTextureLoaded,this.onValidated=e.onValidated,this.preprocessUrlAsync=null!==(_=e.preprocessUrlAsync)&&void 0!==_?_:this.preprocessUrlAsync,this.skipMaterials=null!==(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!==(v=e.useClipPlane)&&void 0!==v?v:this.useClipPlane,this.useGltfTextureNames=null!==(T=e.useGltfTextureNames)&&void 0!==T?T:this.useGltfTextureNames,this.useOpenPBR=null!==(x=e.useOpenPBR)&&void 0!==x?x:this.useOpenPBR,this.useRangeRequests=null!==(A=e.useRangeRequests)&&void 0!==A?A:this.useRangeRequests,this.useSRGBBuffers=null!==(w=e.useSRGBBuffers)&&void 0!==w?w:this.useSRGBBuffers,this.validate=null!==(O=e.validate)&&void 0!==O?O:this.validate,this.dontUseTransmissionHelper=null!==(C=e.dontUseTransmissionHelper)&&void 0!==C?C:this.dontUseTransmissionHelper)},t}(N),k=function(n){function r(e){var r=n.call(this)||this;return r.onParsedObservable=new t.Observable,r.onMeshLoadedObservable=new t.Observable,r.onSkinLoadedObservable=new t.Observable,r.onTextureLoadedObservable=new t.Observable,r.onMaterialLoadedObservable=new t.Observable,r.onCameraLoadedObservable=new t.Observable,r.onCompleteObservable=new t.Observable,r.onErrorObservable=new t.Observable,r.onDisposeObservable=new t.Observable,r.onExtensionLoadedObservable=new t.Observable,r.onValidatedObservable=new t.Observable,r._loader=null,r._state=null,r._requests=new Array,r.name=P.name,r.extensions=P.extensions,r.onLoaderStateChangedObservable=new t.Observable,r._logIndentLevel=0,r._loggingEnabled=!1,r._log=r._logDisabled,r._capturePerformanceCounters=!1,r._startPerformanceCounter=r._startPerformanceCounterDisabled,r._endPerformanceCounter=r._endPerformanceCounterDisabled,r.copyFrom(Object.assign(_({},I),e)),r}return m(r,n),Object.defineProperty(r.prototype,"onParsed",{set:function(e){this._onParsedObserver&&this.onParsedObservable.remove(this._onParsedObserver),e&&(this._onParsedObserver=this.onParsedObservable.add(e))},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"onMeshLoaded",{set:function(e){this._onMeshLoadedObserver&&this.onMeshLoadedObservable.remove(this._onMeshLoadedObserver),e&&(this._onMeshLoadedObserver=this.onMeshLoadedObservable.add(e))},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"onSkinLoaded",{set:function(e){this._onSkinLoadedObserver&&this.onSkinLoadedObservable.remove(this._onSkinLoadedObserver),e&&(this._onSkinLoadedObserver=this.onSkinLoadedObservable.add(function(t){return e(t.node,t.skinnedNode)}))},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"onTextureLoaded",{set:function(e){this._onTextureLoadedObserver&&this.onTextureLoadedObservable.remove(this._onTextureLoadedObserver),e&&(this._onTextureLoadedObserver=this.onTextureLoadedObservable.add(e))},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"onMaterialLoaded",{set:function(e){this._onMaterialLoadedObserver&&this.onMaterialLoadedObservable.remove(this._onMaterialLoadedObserver),e&&(this._onMaterialLoadedObserver=this.onMaterialLoadedObservable.add(e))},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"onCameraLoaded",{set:function(e){this._onCameraLoadedObserver&&this.onCameraLoadedObservable.remove(this._onCameraLoadedObserver),e&&(this._onCameraLoadedObserver=this.onCameraLoadedObservable.add(e))},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"onComplete",{set:function(e){this._onCompleteObserver&&this.onCompleteObservable.remove(this._onCompleteObserver),this._onCompleteObserver=this.onCompleteObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"onError",{set:function(e){this._onErrorObserver&&this.onErrorObservable.remove(this._onErrorObserver),this._onErrorObserver=this.onErrorObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"onDispose",{set:function(e){this._onDisposeObserver&&this.onDisposeObservable.remove(this._onDisposeObserver),this._onDisposeObserver=this.onDisposeObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"onExtensionLoaded",{set:function(e){this._onExtensionLoadedObserver&&this.onExtensionLoadedObservable.remove(this._onExtensionLoadedObserver),this._onExtensionLoadedObserver=this.onExtensionLoadedObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"loggingEnabled",{get:function(){return this._loggingEnabled},set:function(e){this._loggingEnabled!==e&&(this._loggingEnabled=e,this._loggingEnabled?this._log=this._logEnabled:this._log=this._logDisabled)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"capturePerformanceCounters",{get:function(){return this._capturePerformanceCounters},set:function(e){this._capturePerformanceCounters!==e&&(this._capturePerformanceCounters=e,this._capturePerformanceCounters?(this._startPerformanceCounter=this._startPerformanceCounterEnabled,this._endPerformanceCounter=this._endPerformanceCounterEnabled):(this._startPerformanceCounter=this._startPerformanceCounterDisabled,this._endPerformanceCounter=this._endPerformanceCounterDisabled))},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"onValidated",{set:function(e){this._onValidatedObserver&&this.onValidatedObservable.remove(this._onValidatedObserver),this._onValidatedObserver=this.onValidatedObservable.add(e)},enumerable:!1,configurable:!0}),r.prototype.dispose=function(){this._loader&&(this._loader.dispose(),this._loader=null);for(var e=0,t=this._requests;e<t.length;e++)t[e].abort();this._requests.length=0,delete this._progressCallback,this.preprocessUrlAsync=function(e){return Promise.resolve(e)},this.onMeshLoadedObservable.clear(),this.onSkinLoadedObservable.clear(),this.onTextureLoadedObservable.clear(),this.onMaterialLoadedObservable.clear(),this.onCameraLoadedObservable.clear(),this.onCompleteObservable.clear(),this.onExtensionLoadedObservable.clear(),this.onDisposeObservable.notifyObservers(void 0),this.onDisposeObservable.clear()},r.prototype.loadFile=function(e,n,r,o,a,i,s,l){var u=this;if(ArrayBuffer.isView(n))return this._loadBinary(e,n,r,o,s,l),null;this._progressCallback=a;var c=n.name||t.Tools.GetFilename(n);if(i){if(this.useRangeRequests){this.validate&&t.Logger.Warn("glTF validation is not supported when range requests are enabled");var f={abort:function(){},onCompleteObservable:new t.Observable},h={readAsync:function(t,r){return new Promise(function(o,a){u._loadFile(e,n,function(e){o(new Uint8Array(e))},!0,function(e){a(e)},function(e){e.setRequestHeader("Range","bytes=".concat(t,"-").concat(t+r-1))})})},byteLength:0};return this._unpackBinaryAsync(new t.DataReader(h)).then(function(e){f.onCompleteObservable.notifyObservers(f),o(e)},s?function(e){return s(void 0,e)}:void 0),f}return this._loadFile(e,n,function(n){u._validate(e,new Uint8Array(n,0,n.byteLength),r,c),u._unpackBinaryAsync(new t.DataReader({readAsync:function(e,t){return S(n,e,t)},byteLength:n.byteLength})).then(function(e){o(e)},s?function(e){return s(void 0,e)}:void 0)},!0,s)}return this._loadFile(e,n,function(t){try{u._validate(e,t,r,c),o({json:u._parseJson(t)})}catch(e){s&&s()}},!1,s)},r.prototype._loadBinary=function(e,n,r,o,a,i){this._validate(e,new Uint8Array(n.buffer,n.byteOffset,n.byteLength),r,i),this._unpackBinaryAsync(new t.DataReader({readAsync:function(e,t){return function(e,t,n){try{if(t<0||t>=e.byteLength)throw new RangeError("Offset is out of range.");if(t+n>e.byteLength)throw new RangeError("Length is out of range.");return Promise.resolve(new Uint8Array(e.buffer,e.byteOffset+t,n))}catch(e){return Promise.reject(e)}}(n,e,t)},byteLength:n.byteLength})).then(function(e){o(e)},a?function(e){return a(void 0,e)}:void 0)},r.prototype.importMeshAsync=function(e,t,n,r,o,a){var i=this;return Promise.resolve().then(function(){return i.onParsedObservable.notifyObservers(n),i.onParsedObservable.clear(),i._log("Loading ".concat(a||"")),i._loader=i._getLoader(n),i._loader.importMeshAsync(e,t,null,n,r,o,a)})},r.prototype.loadAsync=function(e,t,n,r,o){var a=this;return Promise.resolve().then(function(){return a.onParsedObservable.notifyObservers(t),a.onParsedObservable.clear(),a._log("Loading ".concat(o||"")),a._loader=a._getLoader(t),a._loader.loadAsync(e,t,n,r,o)})},r.prototype.loadAssetContainerAsync=function(e,n,r,o,a){var i=this;return Promise.resolve().then(function(){i.onParsedObservable.notifyObservers(n),i.onParsedObservable.clear(),i._log("Loading ".concat(a||"")),i._loader=i._getLoader(n);var s=new t.AssetContainer(e),l=[];i.onMaterialLoadedObservable.add(function(e){l.push(e)});var u=[];i.onTextureLoadedObservable.add(function(e){u.push(e)});var c=[];i.onCameraLoadedObservable.add(function(e){c.push(e)});var f=[];return i.onMeshLoadedObservable.add(function(e){e.morphTargetManager&&f.push(e.morphTargetManager)}),i._loader.importMeshAsync(null,e,s,n,r,o,a).then(function(e){return Array.prototype.push.apply(s.geometries,e.geometries),Array.prototype.push.apply(s.meshes,e.meshes),Array.prototype.push.apply(s.particleSystems,e.particleSystems),Array.prototype.push.apply(s.skeletons,e.skeletons),Array.prototype.push.apply(s.animationGroups,e.animationGroups),Array.prototype.push.apply(s.materials,l),Array.prototype.push.apply(s.textures,u),Array.prototype.push.apply(s.lights,e.lights),Array.prototype.push.apply(s.transformNodes,e.transformNodes),Array.prototype.push.apply(s.cameras,c),Array.prototype.push.apply(s.morphTargetManagers,f),s})})},r.prototype.canDirectLoad=function(e){return P.canDirectLoad(e)},r.prototype.directLoad=function(e,n){if(n.startsWith("base64,"+L)||n.startsWith(";base64,"+L)||n.startsWith("application/octet-stream;base64,"+L)||n.startsWith("model/gltf-binary;base64,"+L)){var r=t.DecodeBase64UrlToBinary(n);return this._validate(e,new Uint8Array(r,0,r.byteLength)),this._unpackBinaryAsync(new t.DataReader({readAsync:function(e,t){return S(r,e,t)},byteLength:r.byteLength}))}return this._validate(e,n),Promise.resolve({json:this._parseJson(n)})},r.prototype.createPlugin=function(e){return new r(e[P.name])},Object.defineProperty(r.prototype,"loaderState",{get:function(){return this._state},enumerable:!1,configurable:!0}),r.prototype.whenCompleteAsync=function(){var e=this;return new Promise(function(t,n){e.onCompleteObservable.addOnce(function(){t()}),e.onErrorObservable.addOnce(function(e){n(e)})})},r.prototype._setState=function(t){this._state!==t&&(this._state=t,this.onLoaderStateChangedObservable.notifyObservers(this._state),this._log(e.GLTFLoaderState[this._state]))},r.prototype._loadFile=function(e,t,n,r,o,a){var i=this,s=e._loadFile(t,n,function(e){i._onProgress(e,s)},!0,r,o,a);return s.onCompleteObservable.add(function(){s._lengthComputable=!0,s._total=s._loaded}),this._requests.push(s),s},r.prototype._onProgress=function(e,t){if(this._progressCallback){t._lengthComputable=e.lengthComputable,t._loaded=e.loaded,t._total=e.total;for(var n=!0,r=0,o=0,a=0,i=this._requests;a<i.length;a++){var s=i[a];if(void 0===s._lengthComputable||void 0===s._loaded||void 0===s._total)return;n=n&&s._lengthComputable,r+=s._loaded,o+=s._total}this._progressCallback({lengthComputable:n,loaded:r,total:n?o:0})}},r.prototype._validate=function(e,n,r,o){var a=this;void 0===r&&(r=""),void 0===o&&(o=""),this.validate&&(this._startPerformanceCounter("Validate JSON"),R.ValidateAsync(n,r,o,function(t){return a.preprocessUrlAsync(r+t).then(function(t){return e._loadFileAsync(t,void 0,!0,!0).then(function(e){return new Uint8Array(e,0,e.byteLength)})})}).then(function(e){a._endPerformanceCounter("Validate JSON"),a.onValidatedObservable.notifyObservers(e),a.onValidatedObservable.clear()},function(e){a._endPerformanceCounter("Validate JSON"),t.Tools.Warn("Failed to validate: ".concat(e.message)),a.onValidatedObservable.clear()}))},r.prototype._getLoader=function(e){var t=e.json.asset||{};this._log("Asset version: ".concat(t.version)),t.minVersion&&this._log("Asset minimum version: ".concat(t.minVersion)),t.generator&&this._log("Asset generator: ".concat(t.generator));var n=r._parseVersion(t.version);if(!n)throw new Error("Invalid version: "+t.version);if(void 0!==t.minVersion){var o=r._parseVersion(t.minVersion);if(!o)throw new Error("Invalid minimum version: "+t.minVersion);if(r._compareVersion(o,{major:2,minor:0})>0)throw new Error("Incompatible minimum version: "+t.minVersion)}var a={1:r._CreateGLTF1Loader,2:r._CreateGLTF2Loader}[n.major];if(!a)throw new Error("Unsupported version: "+t.version);return a(this)},r.prototype._parseJson=function(e){this._startPerformanceCounter("Parse JSON"),this._log("JSON length: ".concat(e.length));var t=JSON.parse(e);return this._endPerformanceCounter("Parse JSON"),t},r.prototype._unpackBinaryAsync=function(e){var n=this;return this._startPerformanceCounter("Unpack Binary"),e.loadAsync(20).then(function(){var r=e.readUint32();if(1179937895!==r)throw new t.RuntimeError("Unexpected magic: "+r,t.ErrorCodes.GLTFLoaderUnexpectedMagicError);var o=e.readUint32();n.loggingEnabled&&n._log("Binary version: ".concat(o));var a,i=e.readUint32();switch(n.useRangeRequests||i===e.buffer.byteLength||t.Logger.Warn("Length in header does not match actual data length: ".concat(i," != ").concat(e.buffer.byteLength)),o){case 1:a=n._unpackBinaryV1Async(e,i);break;case 2:a=n._unpackBinaryV2Async(e,i);break;default:throw new Error("Unsupported version: "+o)}return n._endPerformanceCounter("Unpack Binary"),a})},r.prototype._unpackBinaryV1Async=function(e,t){var n=e.readUint32(),r=e.readUint32();if(0!==r)throw new Error("Unexpected content format: ".concat(r));var o=t-e.byteOffset,a={json:this._parseJson(e.readString(n)),bin:null};if(0!==o){var i=e.byteOffset;a.bin={readAsync:function(t,n){return e.buffer.readAsync(i+t,n)},byteLength:o}}return Promise.resolve(a)},r.prototype._unpackBinaryV2Async=function(e,t){var n=this,r=1313821514,o=e.readUint32();if(e.readUint32()!==r)throw new Error("First chunk format is not JSON");return e.byteOffset+o===t?e.loadAsync(o).then(function(){return{json:n._parseJson(e.readString(o)),bin:null}}):e.loadAsync(o+8).then(function(){var a={json:n._parseJson(e.readString(o)),bin:null},i=function(){var n=e.readUint32();switch(e.readUint32()){case r:throw new Error("Unexpected JSON chunk");case 5130562:var o=e.byteOffset;a.bin={readAsync:function(t,n){return e.buffer.readAsync(o+t,n)},byteLength:n},e.skipBytes(n);break;default:e.skipBytes(n)}return e.byteOffset!==t?e.loadAsync(8).then(i):Promise.resolve(a)};return i()})},r._parseVersion=function(e){if("1.0"===e||"1.0.1"===e)return{major:1,minor:0};var t=(e+"").match(/^(\d+)\.(\d+)/);return t?{major:parseInt(t[1]),minor:parseInt(t[2])}:null},r._compareVersion=function(e,t){return e.major>t.major?1:e.major<t.major?-1:e.minor>t.minor?1:e.minor<t.minor?-1:0},r.prototype._logOpen=function(e){this._log(e),this._logIndentLevel++},r.prototype._logClose=function(){--this._logIndentLevel},r.prototype._logEnabled=function(e){var n=r._logSpaces.substring(0,2*this._logIndentLevel);t.Logger.Log("".concat(n).concat(e))},r.prototype._logDisabled=function(e){},r.prototype._startPerformanceCounterEnabled=function(e){t.Tools.StartPerformanceCounter(e)},r.prototype._startPerformanceCounterDisabled=function(e){},r.prototype._endPerformanceCounterEnabled=function(e){t.Tools.EndPerformanceCounter(e)},r.prototype._endPerformanceCounterDisabled=function(e){},r.IncrementalLoading=!0,r.HomogeneousCoordinates=!1,r._logSpaces=" ",r}(B);t.RegisterSceneLoaderPlugin(new k);var G,D,V,H,K,j,U,W,z={__proto__:null,GLTFFileLoader:k,get GLTFLoaderAnimationStartMode(){return e.GLTFLoaderAnimationStartMode},get GLTFLoaderCoordinateSystemMode(){return e.GLTFLoaderCoordinateSystemMode},GLTFLoaderDefaultOptions:I,get GLTFLoaderState(){return e.GLTFLoaderState}};!function(e){e[e.BYTE=5120]="BYTE",e[e.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",e[e.SHORT=5122]="SHORT",e[e.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",e[e.FLOAT=5126]="FLOAT"}(G||(G={})),function(e){e[e.FRAGMENT=35632]="FRAGMENT",e[e.VERTEX=35633]="VERTEX"}(D||(D={})),function(e){e[e.BYTE=5120]="BYTE",e[e.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",e[e.SHORT=5122]="SHORT",e[e.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",e[e.INT=5124]="INT",e[e.UNSIGNED_INT=5125]="UNSIGNED_INT",e[e.FLOAT=5126]="FLOAT",e[e.FLOAT_VEC2=35664]="FLOAT_VEC2",e[e.FLOAT_VEC3=35665]="FLOAT_VEC3",e[e.FLOAT_VEC4=35666]="FLOAT_VEC4",e[e.INT_VEC2=35667]="INT_VEC2",e[e.INT_VEC3=35668]="INT_VEC3",e[e.INT_VEC4=35669]="INT_VEC4",e[e.BOOL=35670]="BOOL",e[e.BOOL_VEC2=35671]="BOOL_VEC2",e[e.BOOL_VEC3=35672]="BOOL_VEC3",e[e.BOOL_VEC4=35673]="BOOL_VEC4",e[e.FLOAT_MAT2=35674]="FLOAT_MAT2",e[e.FLOAT_MAT3=35675]="FLOAT_MAT3",e[e.FLOAT_MAT4=35676]="FLOAT_MAT4",e[e.SAMPLER_2D=35678]="SAMPLER_2D"}(V||(V={})),function(e){e[e.CLAMP_TO_EDGE=33071]="CLAMP_TO_EDGE",e[e.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",e[e.REPEAT=10497]="REPEAT"}(H||(H={})),function(e){e[e.NEAREST=9728]="NEAREST",e[e.LINEAR=9728]="LINEAR",e[e.NEAREST_MIPMAP_NEAREST=9984]="NEAREST_MIPMAP_NEAREST",e[e.LINEAR_MIPMAP_NEAREST=9985]="LINEAR_MIPMAP_NEAREST",e[e.NEAREST_MIPMAP_LINEAR=9986]="NEAREST_MIPMAP_LINEAR",e[e.LINEAR_MIPMAP_LINEAR=9987]="LINEAR_MIPMAP_LINEAR"}(K||(K={})),function(e){e[e.ALPHA=6406]="ALPHA",e[e.RGB=6407]="RGB",e[e.RGBA=6408]="RGBA",e[e.LUMINANCE=6409]="LUMINANCE",e[e.LUMINANCE_ALPHA=6410]="LUMINANCE_ALPHA"}(j||(j={})),function(e){e[e.FRONT=1028]="FRONT",e[e.BACK=1029]="BACK",e[e.FRONT_AND_BACK=1032]="FRONT_AND_BACK"}(U||(U={})),function(e){e[e.ZERO=0]="ZERO",e[e.ONE=1]="ONE",e[e.SRC_COLOR=768]="SRC_COLOR",e[e.ONE_MINUS_SRC_COLOR=769]="ONE_MINUS_SRC_COLOR",e[e.DST_COLOR=774]="DST_COLOR",e[e.ONE_MINUS_DST_COLOR=775]="ONE_MINUS_DST_COLOR",e[e.SRC_ALPHA=770]="SRC_ALPHA",e[e.ONE_MINUS_SRC_ALPHA=771]="ONE_MINUS_SRC_ALPHA",e[e.DST_ALPHA=772]="DST_ALPHA",e[e.ONE_MINUS_DST_ALPHA=773]="ONE_MINUS_DST_ALPHA",e[e.CONSTANT_COLOR=32769]="CONSTANT_COLOR",e[e.ONE_MINUS_CONSTANT_COLOR=32770]="ONE_MINUS_CONSTANT_COLOR",e[e.CONSTANT_ALPHA=32771]="CONSTANT_ALPHA",e[e.ONE_MINUS_CONSTANT_ALPHA=32772]="ONE_MINUS_CONSTANT_ALPHA",e[e.SRC_ALPHA_SATURATE=776]="SRC_ALPHA_SATURATE"}(W||(W={}));var q,Y=function(){function e(){}return e.SetMatrix=function(e,n,r,o,a){var i=null;if("MODEL"===r.semantic?i=n.getWorldMatrix():"PROJECTION"===r.semantic?i=e.getProjectionMatrix():"VIEW"===r.semantic?i=e.getViewMatrix():"MODELVIEWINVERSETRANSPOSE"===r.semantic?i=t.Matrix.Transpose(n.getWorldMatrix().multiply(e.getViewMatrix()).invert()):"MODELVIEW"===r.semantic?i=n.getWorldMatrix().multiply(e.getViewMatrix()):"MODELVIEWPROJECTION"===r.semantic?i=n.getWorldMatrix().multiply(e.getTransformMatrix()):"MODELINVERSE"===r.semantic?i=n.getWorldMatrix().invert():"VIEWINVERSE"===r.semantic?i=e.getViewMatrix().invert():"PROJECTIONINVERSE"===r.semantic?i=e.getProjectionMatrix().invert():"MODELVIEWINVERSE"===r.semantic?i=n.getWorldMatrix().multiply(e.getViewMatrix()).invert():"MODELVIEWPROJECTIONINVERSE"===r.semantic?i=n.getWorldMatrix().multiply(e.getTransformMatrix()).invert():"MODELINVERSETRANSPOSE"===r.semantic&&(i=t.Matrix.Transpose(n.getWorldMatrix().invert())),i)switch(r.type){case V.FLOAT_MAT2:a.setMatrix2x2(o,t.Matrix.GetAsMatrix2x2(i));break;case V.FLOAT_MAT3:a.setMatrix3x3(o,t.Matrix.GetAsMatrix3x3(i));break;case V.FLOAT_MAT4:a.setMatrix(o,i)}},e.SetUniform=function(e,n,r,o){switch(o){case V.FLOAT:return e.setFloat(n,r),!0;case V.FLOAT_VEC2:return e.setVector2(n,t.Vector2.FromArray(r)),!0;case V.FLOAT_VEC3:return e.setVector3(n,t.Vector3.FromArray(r)),!0;case V.FLOAT_VEC4:return e.setVector4(n,t.Vector4.FromArray(r)),!0;default:return!1}},e.GetWrapMode=function(e){switch(e){case H.CLAMP_TO_EDGE:return t.Texture.CLAMP_ADDRESSMODE;case H.MIRRORED_REPEAT:return t.Texture.MIRROR_ADDRESSMODE;case H.REPEAT:default:return t.Texture.WRAP_ADDRESSMODE}},e.GetByteStrideFromType=function(e){switch(e.type){case"VEC2":return 2;case"VEC3":return 3;case"VEC4":case"MAT2":return 4;case"MAT3":return 9;case"MAT4":return 16;default:return 1}},e.GetTextureFilterMode=function(e){switch(e){case K.LINEAR:case K.LINEAR_MIPMAP_NEAREST:case K.LINEAR_MIPMAP_LINEAR:return t.Texture.TRILINEAR_SAMPLINGMODE;case K.NEAREST:case K.NEAREST_MIPMAP_NEAREST:return t.Texture.NEAREST_SAMPLINGMODE;default:return t.Texture.BILINEAR_SAMPLINGMODE}},e.GetBufferFromBufferView=function(e,t,n,r,o){n=t.byteOffset+n;var a=e.loadedBufferViews[t.buffer];if(n+r>a.byteLength)throw new Error("Buffer access is out of range");var i=a.buffer;switch(n+=a.byteOffset,o){case G.BYTE:return new Int8Array(i,n,r);case G.UNSIGNED_BYTE:return new Uint8Array(i,n,r);case G.SHORT:return new Int16Array(i,n,r);case G.UNSIGNED_SHORT:return new Uint16Array(i,n,r);default:return new Float32Array(i,n,r)}},e.GetBufferFromAccessor=function(t,n){var r=t.bufferViews[n.bufferView],o=n.count*e.GetByteStrideFromType(n);return e.GetBufferFromBufferView(t,r,n.byteOffset,o,n.componentType)},e.DecodeBufferToText=function(e){for(var t="",n=e.byteLength,r=0;r<n;++r)t+=String.fromCharCode(e[r]);return t},e.GetDefaultMaterial=function(n){if(!e._DefaultMaterial){t.Effect.ShadersStore.GLTFDefaultMaterialVertexShader=["precision highp float;","","uniform mat4 worldView;","uniform mat4 projection;","","attribute vec3 position;","","void main(void)","{"," gl_Position = projection * worldView * vec4(position, 1.0);","}"].join("\n"),t.Effect.ShadersStore.GLTFDefaultMaterialPixelShader=["precision highp float;","","uniform vec4 u_emission;","","void main(void)","{"," gl_FragColor = u_emission;","}"].join("\n");var r={attributes:["position"],uniforms:["worldView","projection","u_emission"],samplers:new Array,needAlphaBlending:!1};e._DefaultMaterial=new t.ShaderMaterial("GLTFDefaultMaterial",n,{vertex:"GLTFDefaultMaterial",fragment:"GLTFDefaultMaterial"},r),e._DefaultMaterial.setColor4("u_emission",new t.Color4(.5,.5,.5,1))}return e._DefaultMaterial},e._DefaultMaterial=null,e}();!function(e){e[e.IDENTIFIER=1]="IDENTIFIER",e[e.UNKNOWN=2]="UNKNOWN",e[e.END_OF_INPUT=3]="END_OF_INPUT"}(q||(q={}));var X=function(){function e(e){this._pos=0,this.currentToken=q.UNKNOWN,this.currentIdentifier="",this.currentString="",this.isLetterOrDigitPattern=/^[a-zA-Z0-9]+$/,this._toParse=e,this._maxPos=e.length}return e.prototype.getNextToken=function(){if(this.isEnd())return q.END_OF_INPUT;if(this.currentString=this.read(),this.currentToken=q.UNKNOWN,"_"===this.currentString||this.isLetterOrDigitPattern.test(this.currentString))for(this.currentToken=q.IDENTIFIER,this.currentIdentifier=this.currentString;!this.isEnd()&&(this.isLetterOrDigitPattern.test(this.currentString=this.peek())||"_"===this.currentString);)this.currentIdentifier+=this.currentString,this.forward();return this.currentToken},e.prototype.peek=function(){return this._toParse[this._pos]},e.prototype.read=function(){return this._toParse[this._pos++]},e.prototype.forward=function(){this._pos++},e.prototype.isEnd=function(){return this._pos>=this._maxPos},e}(),J=["MODEL","VIEW","PROJECTION","MODELVIEW","MODELVIEWPROJECTION","JOINTMATRIX"],Q=["world","view","projection","worldView","worldViewProjection","mBones"],Z=["translation","rotation","scale"],$=["position","rotationQuaternion","scaling"],ee=function(e,t,n){for(var r in e){var o=e[r];n[t][r]=o}},te=function(e){if(e)for(var t=0;t<e.length/2;t++)e[2*t+1]=1-e[2*t+1]},ne=function(e){if("NORMAL"===e.semantic)return"normal";if("POSITION"===e.semantic)return"position";if("JOINT"===e.semantic)return"matricesIndices";if("WEIGHT"===e.semantic)return"matricesWeights";if("COLOR"===e.semantic)return"color";if(e.semantic&&-1!==e.semantic.indexOf("TEXCOORD_")){var t=Number(e.semantic.split("_")[1]);return"uv"+(0===t?"":t+1)}return null},re=function(e){var n;if(e.translation||e.rotation||e.scale){var r=t.Vector3.FromArray(e.scale||[1,1,1]),o=t.Quaternion.FromArray(e.rotation||[0,0,0,1]),a=t.Vector3.FromArray(e.translation||[0,0,0]);n=t.Matrix.Compose(r,o,a)}else n=t.Matrix.FromArray(e.matrix);return n},oe=function(e,n,r,o){for(var a=0;a<o.bones.length;a++)if(o.bones[a].name===r)return o.bones[a];var i=e.nodes;for(var s in i){var l=i[s];if(l.jointName){var u=l.children;for(a=0;a<u.length;a++){var c=e.nodes[u[a]];if(c.jointName&&c.jointName===r){var f=re(l),h=new t.Bone(l.name||"",o,oe(e,n,l.jointName,o),f);return h.id=s,h}}}}return null},ae=function(e,t){for(var n=0;n<e.length;n++)for(var r=e[n],o=0;o<r.node.children.length;o++)if(r.node.children[o]===t)return r.bone;return null},ie=function(e,t){var n=e.nodes,r=n[t];if(r)return{node:r,id:t};for(var o in n)if((r=n[o]).jointName===t)return{node:r,id:o};return null},se=function(e,t){for(var n=0;n<e.jointNames.length;n++)if(e.jointNames[n]===t)return!0;return!1},le=function(e,n,r,o,a){if(a||(e.scene._blockEntityCollection=!!e.assetContainer,(a=new t.Mesh(n.name||"",e.scene))._parentContainer=e.assetContainer,e.scene._blockEntityCollection=!1,a.id=o),!n.babylonNode)return a;for(var i,s=[],l=null,u=[],c=[],f=[],h=[],d=0;d<r.length;d++){var p=r[d];if(R=e.meshes[p])for(var m=0;m<R.primitives.length;m++){var _=new t.VertexData,g=R.primitives[m];g.mode;var b=g.attributes,y=void 0,v=void 0;for(var T in b)if(y=e.accessors[b[T]],v=Y.GetBufferFromAccessor(e,y),"NORMAL"===T)_.normals=new Float32Array(v.length),_.normals.set(v);else if("POSITION"===T){if(k.HomogeneousCoordinates){_.positions=new Float32Array(v.length-v.length/4);for(var x=0;x<v.length;x+=4)_.positions[x]=v[x],_.positions[x+1]=v[x+1],_.positions[x+2]=v[x+2]}else _.positions=new Float32Array(v.length),_.positions.set(v);c.push(_.positions.length)}else if(-1!==T.indexOf("TEXCOORD_")){var A=Number(T.split("_")[1]),w=t.VertexBuffer.UVKind+(0===A?"":A+1),O=new Float32Array(v.length);O.set(v),te(O),_.set(O,w)}else"JOINT"===T?(_.matricesIndices=new Float32Array(v.length),_.matricesIndices.set(v)):"WEIGHT"===T?(_.matricesWeights=new Float32Array(v.length),_.matricesWeights.set(v)):"COLOR"===T&&(_.colors=new Float32Array(v.length),_.colors.set(v));if(y=e.accessors[g.indices])v=Y.GetBufferFromAccessor(e,y),_.indices=new Int32Array(v.length),_.indices.set(v),h.push(_.indices.length);else{var C=[];for(x=0;x<_.positions.length/3;x++)C.push(x);_.indices=new Int32Array(C),h.push(_.indices.length)}l?l.merge(_):l=_;var M=e.scene.getMaterialById(g.material);s.push(null===M?Y.GetDefaultMaterial(e.scene):M),u.push(0===u.length?0:u[u.length-1]+c[c.length-2]),f.push(0===f.length?0:f[f.length-1]+h[h.length-2])}}e.scene._blockEntityCollection=!!e.assetContainer,s.length>1?(i=new t.MultiMaterial("multimat"+o,e.scene)).subMaterials=s:i=new t.StandardMaterial("multimat"+o,e.scene),1===s.length&&(i=s[0]),i._parentContainer=e.assetContainer,a.material||(a.material=i),new t.Geometry(o,e.scene,l,!1,a),a.computeWorldMatrix(!0),e.scene._blockEntityCollection=!1,a.subMeshes=[];var E=0;for(d=0;d<r.length;d++){var R;if(p=r[d],R=e.meshes[p])for(m=0;m<R.primitives.length;m++)R.primitives[m].mode,t.SubMesh.AddToMesh(E,u[E],c[E],f[E],h[E],a,a,!0),E++}return a},ue=function(e,t,n,r){e.position&&(e.position=t),(e.rotationQuaternion||e.rotation)&&(e.rotationQuaternion=n),e.scaling&&(e.scaling=r)},ce=function(e,n,r){var o=null;if(e.importOnlyMeshes&&(n.skin||n.meshes)&&e.importMeshesNames&&e.importMeshesNames.length>0&&-1===e.importMeshesNames.indexOf(n.name||""))return null;if(n.skin){if(n.meshes){var a=e.skins[n.skin];(i=le(e,n,n.meshes,r,n.babylonNode)).skeleton=e.scene.getLastSkeletonById(n.skin),null===i.skeleton&&(i.skeleton=function(e,n,r,o){if(o||(o=new t.Skeleton(n.name||"","",e.scene)),!n.babylonSkeleton)return o;var a=[],i=[];!function(e,n,r,o){for(var a in e.nodes){var i=e.nodes[a],s=a;if(i.jointName&&!se(r,i.jointName)){var l=re(i),u=new t.Bone(i.name||"",n,null,l);u.id=s,o.push({bone:u,node:i,id:s})}}for(var c=0;c<o.length;c++)for(var f=o[c],h=f.node.children,d=0;d<h.length;d++){for(var p=null,m=0;m<o.length;m++)if(o[m].id===h[d]){p=o[m];break}p&&(p.bone._parent=f.bone,f.bone.children.push(p.bone))}}(e,o,n,a),o.bones=[];for(var s=0;s<n.jointNames.length;s++)if(v=ie(e,n.jointNames[s])){var l=v.node;if(l){var u=v.id,c=e.scene.getBoneById(u);if(c)o.bones.push(c);else{for(var f=void 0,h=null,d=0;d<s;d++){var p=ie(e,n.jointNames[d]);if(p){var m=p.node;if(m){var _=m.children;if(_){f=!1;for(var g=0;g<_.length;g++)if(_[g]===u){h=oe(e,n,n.jointNames[d],o),f=!0;break}if(f)break}}else t.Tools.Warn("Joint named "+n.jointNames[d]+" does not exist when looking for parent")}}var b=re(l);!h&&a.length>0&&(h=ae(a,u))&&-1===i.indexOf(h)&&i.push(h),new t.Bone(l.jointName||"",o,h,b).id=u}}else t.Tools.Warn("Joint named "+n.jointNames[s]+" does not exist")}var y=o.bones;for(o.bones=[],s=0;s<n.jointNames.length;s++){var v;if(v=ie(e,n.jointNames[s]))for(d=0;d<y.length;d++)if(y[d].id===v.id){o.bones.push(y[d]);break}}for(o.prepare(),s=0;s<i.length;s++)o.bones.push(i[s]);return o}(e,a,0,a.babylonSkeleton),a.babylonSkeleton||(a.babylonSkeleton=i.skeleton)),o=i}}else if(n.meshes){var i;o=i=le(e,n,n.mesh?[n.mesh]:n.meshes,r,n.babylonNode)}else if(!n.light||n.babylonNode||e.importOnlyMeshes){if(n.camera&&!n.babylonNode&&!e.importOnlyMeshes){var s=e.cameras[n.camera];if(s){if(e.scene._blockEntityCollection=!!e.assetContainer,"orthographic"===s.type){var l=new t.FreeCamera(n.camera,t.Vector3.Zero(),e.scene,!1);l.name=n.name||"",l.mode=t.Camera.ORTHOGRAPHIC_CAMERA,l.attachControl(),o=l,l._parentContainer=e.assetContainer}else if("perspective"===s.type){var u=s[s.type],c=new t.FreeCamera(n.camera,t.Vector3.Zero(),e.scene,!1);c.name=n.name||"",c.attachControl(),u.aspectRatio||(u.aspectRatio=e.scene.getEngine().getRenderWidth()/e.scene.getEngine().getRenderHeight()),u.znear&&u.zfar&&(c.maxZ=u.zfar,c.minZ=u.znear),o=c,c._parentContainer=e.assetContainer}e.scene._blockEntityCollection=!1}}}else{var f=e.lights[n.light];if(f)if("ambient"===f.type){var h=f[f.type],d=new t.HemisphericLight(n.light,t.Vector3.Zero(),e.scene);d.name=n.name||"",h.color&&(d.diffuse=t.Color3.FromArray(h.color)),o=d}else if("directional"===f.type){var p=f[f.type],m=new t.DirectionalLight(n.light,t.Vector3.Zero(),e.scene);m.name=n.name||"",p.color&&(m.diffuse=t.Color3.FromArray(p.color)),o=m}else if("point"===f.type){var _=f[f.type],g=new t.PointLight(n.light,t.Vector3.Zero(),e.scene);g.name=n.name||"",_.color&&(g.diffuse=t.Color3.FromArray(_.color)),o=g}else if("spot"===f.type){var b=f[f.type],y=new t.SpotLight(n.light,t.Vector3.Zero(),t.Vector3.Zero(),0,0,e.scene);y.name=n.name||"",b.color&&(y.diffuse=t.Color3.FromArray(b.color)),b.fallOfAngle&&(y.angle=b.fallOfAngle),b.fallOffExponent&&(y.exponent=b.fallOffExponent),o=y}}if(!n.jointName){if(n.babylonNode)return n.babylonNode;if(null===o){e.scene._blockEntityCollection=!!e.assetContainer;var v=new t.Mesh(n.name||"",e.scene);v._parentContainer=e.assetContainer,e.scene._blockEntityCollection=!1,n.babylonNode=v,o=v}}if(null!==o){if(n.matrix&&o instanceof t.Mesh)!function(e,n){if(n.matrix){var r=new t.Vector3(0,0,0),o=new t.Quaternion,a=new t.Vector3(0,0,0);t.Matrix.FromArray(n.matrix).decompose(a,o,r),ue(e,r,o,a)}else n.translation&&n.rotation&&n.scale&&ue(e,t.Vector3.FromArray(n.translation),t.Quaternion.FromArray(n.rotation),t.Vector3.FromArray(n.scale));e.computeWorldMatrix(!0)}(o,n);else{var T=n.translation||[0,0,0],x=n.rotation||[0,0,0,1],A=n.scale||[1,1,1];ue(o,t.Vector3.FromArray(T),t.Quaternion.FromArray(x),t.Vector3.FromArray(A))}o.updateCache(!0),n.babylonNode=o}return o},fe=function(e,t,n,r){void 0===r&&(r=!1);var o=e.nodes[t],a=null;if(r=!(e.importOnlyMeshes&&!r&&e.importMeshesNames)||-1!==e.importMeshesNames.indexOf(o.name||"")||0===e.importMeshesNames.length,!o.jointName&&r&&null!==(a=ce(e,o,t))&&(a.id=t,a.parent=n),o.children)for(var i=0;i<o.children.length;i++)fe(e,o.children[i],a,r)},he=function(e){var n=e.currentScene;if(n)for(var r=0;r<n.nodes.length;r++)fe(e,n.nodes[r],null);else for(var o in e.scenes)for(n=e.scenes[o],r=0;r<n.nodes.length;r++)fe(e,n.nodes[r],null);for(function(e){for(var n in e.animations){var r=e.animations[n];if(r.channels&&r.samplers)for(var o=null,a=0;a<r.channels.length;a++){var i=r.channels[a],s=r.samplers[i.sampler];if(s){var l=void 0,u=void 0;r.parameters?(l=r.parameters[s.input],u=r.parameters[s.output]):(l=s.input,u=s.output);var c=Y.GetBufferFromAccessor(e,e.accessors[l]),f=Y.GetBufferFromAccessor(e,e.accessors[u]),h=i.target.id,d=e.scene.getNodeById(h);if(null===d&&(d=e.scene.getNodeByName(h)),null!==d){var p=d instanceof t.Bone,m=i.target.path,_=Z.indexOf(m);-1!==_&&(m=$[_]);var g=t.Animation.ANIMATIONTYPE_MATRIX;p||("rotationQuaternion"===m?(g=t.Animation.ANIMATIONTYPE_QUATERNION,d.rotationQuaternion=new t.Quaternion):g=t.Animation.ANIMATIONTYPE_VECTOR3);var b=null,y=[],v=0,T=!1;p&&o&&o.getKeys().length===c.length&&(b=o,T=!0),T||(e.scene._blockEntityCollection=!!e.assetContainer,b=new t.Animation(n,p?"_matrix":m,1,g,t.Animation.ANIMATIONLOOPMODE_CYCLE),e.scene._blockEntityCollection=!1);for(var x=0;x<c.length;x++){var A=void 0;if("rotationQuaternion"===m?(A=t.Quaternion.FromArray([f[v],f[v+1],f[v+2],f[v+3]]),v+=4):(A=t.Vector3.FromArray([f[v],f[v+1],f[v+2]]),v+=3),p){var w=d,O=t.Vector3.Zero(),C=new t.Quaternion,M=t.Vector3.Zero(),E=w.getBaseMatrix();T&&o&&(E=o.getKeys()[x].value),E.decompose(M,C,O),"position"===m?O=A:"rotationQuaternion"===m?C=A:M=A,A=t.Matrix.Compose(M,C,O)}T?o&&(o.getKeys()[x].value=A):y.push({frame:c[x],value:A})}!T&&b&&(b.setKeys(y),d.animations.push(b)),o=b,e.scene.stopAnimation(d),e.scene.beginAnimation(d,0,c[c.length-1],!0,1)}else t.Tools.Warn("Creating animation named "+n+". But cannot find node named "+h+" to attach to")}}}}(e),r=0;r<e.scene.skeletons.length;r++){var a=e.scene.skeletons[r];e.scene.beginAnimation(a,0,Number.MAX_VALUE,!0,1)}},de=function(e,t,n){for(var r in t.uniforms){var o=t.uniforms[r],a=t.parameters[o];if(e.currentIdentifier===r&&a.semantic&&!a.source&&!a.node){var i=J.indexOf(a.semantic);if(-1!==i)return delete n[r],Q[i]}}return e.currentIdentifier},pe=function(e){for(var t in e.materials)ge.LoadMaterialAsync(e,t,function(){},function(){})},me=function(){function e(){}return e.CreateRuntime=function(e,t,n){var r={extensions:{},accessors:{},buffers:{},bufferViews:{},meshes:{},lights:{},cameras:{},nodes:{},images:{},textures:{},shaders:{},programs:{},samplers:{},techniques:{},materials:{},animations:{},skins:{},extensionsUsed:[],scenes:{},buffersCount:0,shaderscount:0,scene:t,rootUrl:n,loadedBufferCount:0,loadedBufferViews:{},loadedShaderCount:0,importOnlyMeshes:!1,dummyNodes:[],assetContainer:null};return e.extensions&&ee(e.extensions,"extensions",r),e.extensionsUsed&&ee(e.extensionsUsed,"extensionsUsed",r),e.buffers&&function(e,t){for(var n in e){var r=e[n];t.buffers[n]=r,t.buffersCount++}}(e.buffers,r),e.bufferViews&&ee(e.bufferViews,"bufferViews",r),e.accessors&&ee(e.accessors,"accessors",r),e.meshes&&ee(e.meshes,"meshes",r),e.lights&&ee(e.lights,"lights",r),e.cameras&&ee(e.cameras,"cameras",r),e.nodes&&ee(e.nodes,"nodes",r),e.images&&ee(e.images,"images",r),e.textures&&ee(e.textures,"textures",r),e.shaders&&function(e,t){for(var n in e){var r=e[n];t.shaders[n]=r,t.shaderscount++}}(e.shaders,r),e.programs&&ee(e.programs,"programs",r),e.samplers&&ee(e.samplers,"samplers",r),e.techniques&&ee(e.techniques,"techniques",r),e.materials&&ee(e.materials,"materials",r),e.animations&&ee(e.animations,"animations",r),e.skins&&ee(e.skins,"skins",r),e.scenes&&(r.scenes=e.scenes),e.scene&&e.scenes&&(r.currentScene=e.scenes[e.scene]),r},e.LoadBufferAsync=function(e,n,r,o,a){var i=e.buffers[n];t.Tools.IsBase64(i.uri)?setTimeout(function(){return r(new Uint8Array(t.Tools.DecodeBase64(i.uri)))}):t.Tools.LoadFile(e.rootUrl+i.uri,function(e){return r(new Uint8Array(e))},a,void 0,!0,function(e){e&&o(e.status+" "+e.statusText)})},e.LoadTextureBufferAsync=function(e,n,r,o){var a=e.textures[n];if(a&&a.source)if(a.babylonTexture)r(null);else{var i=e.images[a.source];t.Tools.IsBase64(i.uri)?setTimeout(function(){return r(new Uint8Array(t.Tools.DecodeBase64(i.uri)))}):t.Tools.LoadFile(e.rootUrl+i.uri,function(e){return r(new Uint8Array(e))},void 0,void 0,!0,function(e){e&&o(e.status+" "+e.statusText)})}else o("")},e.CreateTextureAsync=function(e,n,r,o){var a=e.textures[n];if(a.babylonTexture)o(a.babylonTexture);else{var i=e.samplers[a.sampler],s=i.minFilter===K.NEAREST_MIPMAP_NEAREST||i.minFilter===K.NEAREST_MIPMAP_LINEAR||i.minFilter===K.LINEAR_MIPMAP_NEAREST||i.minFilter===K.LINEAR_MIPMAP_LINEAR,l=t.Texture.BILINEAR_SAMPLINGMODE,u=null==r?new Blob:new Blob([t.GetBlobBufferSource(r)]),c=URL.createObjectURL(u),f=function(){return URL.revokeObjectURL(c)},h=new t.Texture(c,e.scene,!s,!0,l,f,f);void 0!==i.wrapS&&(h.wrapU=Y.GetWrapMode(i.wrapS)),void 0!==i.wrapT&&(h.wrapV=Y.GetWrapMode(i.wrapT)),h.name=n,a.babylonTexture=h,o(h)}},e.LoadShaderStringAsync=function(e,n,r,o){var a=e.shaders[n];if(t.Tools.IsBase64(a.uri)){var i=atob(a.uri.split(",")[1]);r&&r(i)}else t.Tools.LoadFile(e.rootUrl+a.uri,r,void 0,void 0,!1,function(e){e&&o&&o(e.status+" "+e.statusText)})},e.LoadMaterialAsync=function(e,n,r,o){var a=e.materials[n];if(a.technique){var i=e.techniques[a.technique];if(!i){e.scene._blockEntityCollection=!!e.assetContainer;var s=new t.StandardMaterial(n,e.scene);return s._parentContainer=e.assetContainer,e.scene._blockEntityCollection=!1,s.diffuseColor=new t.Color3(.5,.5,.5),s.sideOrientation=t.Material.CounterClockWiseSideOrientation,void r(s)}var l=e.programs[i.program],u=i.states,c=t.Effect.ShadersStore[l.vertexShader+"VertexShader"],f=t.Effect.ShadersStore[l.fragmentShader+"PixelShader"],h="",d="",p=new X(c),m=new X(f),_={},g=[],b=[],y=[];for(var v in i.uniforms){var T=i.uniforms[v],x=i.parameters[T];if(_[v]=x,!x.semantic||x.node||x.source)x.type===V.SAMPLER_2D?y.push(v):g.push(v);else{var A=J.indexOf(x.semantic);-1!==A?(g.push(Q[A]),delete _[v]):g.push(v)}}for(var w in i.attributes){var O=i.attributes[w];if((E=i.parameters[O]).semantic){var C=ne(E);C&&b.push(C)}}for(;!p.isEnd()&&p.getNextToken();)if(p.currentToken===q.IDENTIFIER){var M=!1;for(var w in i.attributes){O=i.attributes[w];var E=i.parameters[O];if(p.currentIdentifier===w&&E.semantic){h+=ne(E),M=!0;break}}M||(h+=de(p,i,_))}else h+=p.currentString;for(;!m.isEnd()&&m.getNextToken();)m.currentToken===q.IDENTIFIER?d+=de(m,i,_):d+=m.currentString;var R={vertex:l.vertexShader+n,fragment:l.fragmentShader+n},F={attributes:b,uniforms:g,samplers:y,needAlphaBlending:u&&u.enable&&-1!==u.enable.indexOf(3042)};t.Effect.ShadersStore[l.vertexShader+n+"VertexShader"]=h,t.Effect.ShadersStore[l.fragmentShader+n+"PixelShader"]=d;var L=new t.ShaderMaterial(n,e.scene,R,F);if(L.onError=function(e,t,n){return function(r,o){t.dispose(!0),n("Cannot compile program named "+e.name+". Error: "+o+". Default material will be applied")}}(l,L,o),L.onCompiled=function(e,t,n,r,o,a){return function(i){!function(e,t,n,r,o){var a=r.values||n.parameters,i=n.uniforms,s=function(n){var s=o[n],l=s.type,u=a[i[n]];if(void 0===u&&(u=s.value),!u)return"continue";var c=function(e){return function(n){s.value&&e&&(t.setTexture(e,n),delete o[e])}};l===V.SAMPLER_2D?ge.LoadTextureAsync(e,r.values?u:s.value,c(n),function(){return c(null)}):s.value&&Y.SetUniform(t,n,r.values?u:s.value,l)&&delete o[n]};for(var l in o)s(l)}(e,t,n,r,o),t.onBind=function(i){!function(e,t,n,r,o,a,i){var s=a.values||o.parameters;for(var l in n){var u=n[l],c=u.type;if(c===V.FLOAT_MAT2||c===V.FLOAT_MAT3||c===V.FLOAT_MAT4)if(!u.semantic||u.source||u.node){if(u.semantic&&(u.source||u.node)){var f=t.scene.getNodeByName(u.source||u.node||"");if(null===f&&(f=t.scene.getNodeById(u.source||u.node||"")),null===f)continue;Y.SetMatrix(t.scene,f,u,l,r.getEffect())}}else Y.SetMatrix(t.scene,e,u,l,r.getEffect());else{var h=s[o.uniforms[l]];if(!h)continue;if(c===V.SAMPLER_2D){var d=t.textures[a.values?h:u.value].babylonTexture;if(null==d)continue;r.getEffect().setTexture(l,d)}else Y.SetUniform(r.getEffect(),l,h,c)}}i(r)}(i,e,o,t,n,r,a)}}}(e,L,i,a,_,r),L.sideOrientation=t.Material.CounterClockWiseSideOrientation,u&&u.functions){var P=u.functions;P.cullFace&&P.cullFace[0]!==U.BACK&&(L.backFaceCulling=!1);var S=P.blendFuncSeparate;S&&(S[0]===W.SRC_ALPHA&&S[1]===W.ONE_MINUS_SRC_ALPHA&&S[2]===W.ONE&&S[3]===W.ONE?L.alphaMode=t.Constants.ALPHA_COMBINE:S[0]===W.ONE&&S[1]===W.ONE&&S[2]===W.ZERO&&S[3]===W.ONE?L.alphaMode=t.Constants.ALPHA_ONEONE:S[0]===W.SRC_ALPHA&&S[1]===W.ONE&&S[2]===W.ZERO&&S[3]===W.ONE?L.alphaMode=t.Constants.ALPHA_ADD:S[0]===W.ZERO&&S[1]===W.ONE_MINUS_SRC_COLOR&&S[2]===W.ONE&&S[3]===W.ONE?L.alphaMode=t.Constants.ALPHA_SUBTRACT:S[0]===W.DST_COLOR&&S[1]===W.ZERO&&S[2]===W.ONE&&S[3]===W.ONE?L.alphaMode=t.Constants.ALPHA_MULTIPLY:S[0]===W.SRC_ALPHA&&S[1]===W.ONE_MINUS_SRC_COLOR&&S[2]===W.ONE&&S[3]===W.ONE&&(L.alphaMode=t.Constants.ALPHA_MAXIMIZED))}}else o&&o("No technique found.")},e}(),_e=function(){function e(){}return e.RegisterExtension=function(n){e.Extensions[n.name]?t.Tools.Error('Tool with the same name "'+n.name+'" already exists'):e.Extensions[n.name]=n},e.prototype.dispose=function(){},e.prototype._importMeshAsync=function(e,n,r,o,a,i,s,l){var u=this;return n.useRightHandedSystem=!0,ge.LoadRuntimeAsync(n,r,o,function(n){n.assetContainer=a,n.importOnlyMeshes=!0,""===e?n.importMeshesNames=[]:"string"==typeof e?n.importMeshesNames=[e]:!e||e instanceof Array?(n.importMeshesNames=[],t.Tools.Warn("Argument meshesNames must be of type string or string[]")):n.importMeshesNames=[e],u._createNodes(n);var r=[],o=[];for(var s in n.nodes){var l=n.nodes[s];l.babylonNode instanceof t.AbstractMesh&&r.push(l.babylonNode)}for(var c in n.skins){var f=n.skins[c];f.babylonSkeleton instanceof t.Skeleton&&o.push(f.babylonSkeleton)}u._loadBuffersAsync(n,function(){u._loadShadersAsync(n,function(){pe(n),he(n),!k.IncrementalLoading&&i&&i(r,o)})}),k.IncrementalLoading&&i&&i(r,o)},l),!0},e.prototype.importMeshAsync=function(e,t,n,r,o,a){var i=this;return new Promise(function(s,l){i._importMeshAsync(e,t,r,o,n,function(e,t){s({meshes:e,particleSystems:[],skeletons:t,animationGroups:[],lights:[],transformNodes:[],geometries:[],spriteManagers:[]})},a,function(e){l(new Error(e))})})},e.prototype._loadAsync=function(e,t,n,r,o,a){var i=this;e.useRightHandedSystem=!0,ge.LoadRuntimeAsync(e,t,n,function(e){ge.LoadRuntimeExtensionsAsync(e,function(){i._createNodes(e),i._loadBuffersAsync(e,function(){i._loadShadersAsync(e,function(){pe(e),he(e),k.IncrementalLoading||r()})}),k.IncrementalLoading&&r()},a)},a)},e.prototype.loadAsync=function(e,t,n,r){return g(this,void 0,void 0,function(){var o=this;return b(this,function(a){switch(a.label){case 0:return[4,new Promise(function(a,i){o._loadAsync(e,t,n,function(){a()},r,function(e){i(new Error(e))})})];case 1:return[2,a.sent()]}})})},e.prototype._loadShadersAsync=function(e,n){var r=!1,o=function(r,o){ge.LoadShaderStringAsync(e,r,function(a){a instanceof ArrayBuffer||(e.loadedShaderCount++,a&&(t.Effect.ShadersStore[r+(o.type===D.VERTEX?"VertexShader":"PixelShader")]=a),e.loadedShaderCount===e.shaderscount&&n())},function(){t.Tools.Error("Error when loading shader program named "+r+" located at "+o.uri)})};for(var a in e.shaders){r=!0;var i=e.shaders[a];i?o.bind(this,a,i)():t.Tools.Error("No shader named: "+a)}r||n()},e.prototype._loadBuffersAsync=function(e,n){var r=!1,o=function(r,o){ge.LoadBufferAsync(e,r,function(a){e.loadedBufferCount++,a&&(a.byteLength!=e.buffers[r].byteLength&&t.Tools.Error("Buffer named "+r+" is length "+a.byteLength+". Expected: "+o.byteLength),e.loadedBufferViews[r]=a),e.loadedBufferCount===e.buffersCount&&n()},function(){t.Tools.Error("Error when loading buffer named "+r+" located at "+o.uri)})};for(var a in e.buffers){r=!0;var i=e.buffers[a];i?o.bind(this,a,i)():t.Tools.Error("No buffer named: "+a)}r||n()},e.prototype._createNodes=function(e){var t=e.currentScene;if(t)for(var n=0;n<t.nodes.length;n++)fe(e,t.nodes[n],null);else for(var r in e.scenes)for(t=e.scenes[r],n=0;n<t.nodes.length;n++)fe(e,t.nodes[n],null)},e.Extensions={},e}(),ge=function(){function e(e){this._name=e}return Object.defineProperty(e.prototype,"name",{get:function(){return this._name},enumerable:!1,configurable:!0}),e.prototype.loadRuntimeAsync=function(e,t,n,r,o){return!1},e.prototype.loadRuntimeExtensionsAsync=function(e,t,n){return!1},e.prototype.loadBufferAsync=function(e,t,n,r,o){return!1},e.prototype.loadTextureBufferAsync=function(e,t,n,r){return!1},e.prototype.createTextureAsync=function(e,t,n,r,o){return!1},e.prototype.loadShaderStringAsync=function(e,t,n,r){return!1},e.prototype.loadMaterialAsync=function(e,t,n,r){return!1},e.LoadRuntimeAsync=function(t,n,r,o,a){e._ApplyExtensions(function(e){return e.loadRuntimeAsync(t,n,r,o,a)},function(){setTimeout(function(){o&&o(me.CreateRuntime(n.json,t,r))})})},e.LoadRuntimeExtensionsAsync=function(t,n,r){e._ApplyExtensions(function(e){return e.loadRuntimeExtensionsAsync(t,n,r)},function(){setTimeout(function(){n()})})},e.LoadBufferAsync=function(t,n,r,o,a){e._ApplyExtensions(function(e){return e.loadBufferAsync(t,n,r,o,a)},function(){me.LoadBufferAsync(t,n,r,o,a)})},e.LoadTextureAsync=function(t,n,r,o){e._LoadTextureBufferAsync(t,n,function(a){a&&e._CreateTextureAsync(t,n,a,r,o)},o)},e.LoadShaderStringAsync=function(t,n,r,o){e._ApplyExtensions(function(e){return e.loadShaderStringAsync(t,n,r,o)},function(){me.LoadShaderStringAsync(t,n,r,o)})},e.LoadMaterialAsync=function(t,n,r,o){e._ApplyExtensions(function(e){return e.loadMaterialAsync(t,n,r,o)},function(){me.LoadMaterialAsync(t,n,r,o)})},e._LoadTextureBufferAsync=function(t,n,r,o){e._ApplyExtensions(function(e){return e.loadTextureBufferAsync(t,n,r,o)},function(){me.LoadTextureBufferAsync(t,n,r,o)})},e._CreateTextureAsync=function(t,n,r,o,a){e._ApplyExtensions(function(e){return e.createTextureAsync(t,n,r,o,a)},function(){me.CreateTextureAsync(t,n,r,o)})},e._ApplyExtensions=function(e,t){for(var n in _e.Extensions)if(e(_e.Extensions[n]))return;t()},e}();k._CreateGLTF1Loader=function(){return new _e};var be=function(e){function t(){return e.call(this,"KHR_binary_glTF")||this}return m(t,e),t.prototype.loadRuntimeAsync=function(e,t,n,r){var o=t.json.extensionsUsed;return!(!o||-1===o.indexOf(this.name)||!t.bin||(this._bin=t.bin,r(me.CreateRuntime(t.json,e,n)),0))},t.prototype.loadBufferAsync=function(e,t,n,r){return-1!==e.extensionsUsed.indexOf(this.name)&&"binary_glTF"===t&&(this._bin.readAsync(0,this._bin.byteLength).then(n,function(e){return r(e.message)}),!0)},t.prototype.loadTextureBufferAsync=function(e,t,n){var r=e.textures[t],o=e.images[r.source];if(!o.extensions||!(this.name in o.extensions))return!1;var a=o.extensions[this.name],i=e.bufferViews[a.bufferView];return n(Y.GetBufferFromBufferView(e,i,0,i.byteLength,G.UNSIGNED_BYTE)),!0},t.prototype.loadShaderStringAsync=function(e,t,n){var r=e.shaders[t];if(!r.extensions||!(this.name in r.extensions))return!1;var o=r.extensions[this.name],a=e.bufferViews[o.bufferView],i=Y.GetBufferFromBufferView(e,a,0,a.byteLength,G.UNSIGNED_BYTE);return setTimeout(function(){var e=Y.DecodeBufferToText(i);n(e)}),!0},t}(ge);_e.RegisterExtension(new be);var ye=function(e){function n(){return e.call(this,"KHR_materials_common")||this}return m(n,e),n.prototype.loadRuntimeExtensionsAsync=function(e){if(!e.extensions)return!1;var n=e.extensions[this.name];if(!n)return!1;var r=n.lights;if(r)for(var o in r){var a=r[o];switch(a.type){case"ambient":var i=new t.HemisphericLight(a.name,new t.Vector3(0,1,0),e.scene),s=a.ambient;s&&(i.diffuse=t.Color3.FromArray(s.color||[1,1,1]));break;case"point":var l=new t.PointLight(a.name,new t.Vector3(10,10,10),e.scene),u=a.point;u&&(l.diffuse=t.Color3.FromArray(u.color||[1,1,1]));break;case"directional":var c=new t.DirectionalLight(a.name,new t.Vector3(0,-1,0),e.scene),f=a.directional;f&&(c.diffuse=t.Color3.FromArray(f.color||[1,1,1]));break;case"spot":var h=a.spot;h&&(new t.SpotLight(a.name,new t.Vector3(0,10,0),new t.Vector3(0,-1,0),h.fallOffAngle||Math.PI,h.fallOffExponent||0,e.scene).diffuse=t.Color3.FromArray(h.color||[1,1,1]));break;default:t.Tools.Warn('GLTF Material Common extension: light type "'+a.type+"” not supported")}}return!1},n.prototype.loadMaterialAsync=function(e,n,r,o){var a=e.materials[n];if(!a||!a.extensions)return!1;var i=a.extensions[this.name];if(!i)return!1;var s=new t.StandardMaterial(n,e.scene);return s.sideOrientation=t.Material.CounterClockWiseSideOrientation,"CONSTANT"===i.technique&&(s.disableLighting=!0),s.backFaceCulling=void 0!==i.doubleSided&&!i.doubleSided,s.alpha=void 0===i.values.transparency?1:i.values.transparency,s.specularPower=void 0===i.values.shininess?0:i.values.shininess,"string"==typeof i.values.ambient?this._loadTexture(e,i.values.ambient,s,"ambientTexture",o):s.ambientColor=t.Color3.FromArray(i.values.ambient||[0,0,0]),"string"==typeof i.values.diffuse?this._loadTexture(e,i.values.diffuse,s,"diffuseTexture",o):s.diffuseColor=t.Color3.FromArray(i.values.diffuse||[0,0,0]),"string"==typeof i.values.emission?this._loadTexture(e,i.values.emission,s,"emissiveTexture",o):s.emissiveColor=t.Color3.FromArray(i.values.emission||[0,0,0]),"string"==typeof i.values.specular?this._loadTexture(e,i.values.specular,s,"specularTexture",o):s.specularColor=t.Color3.FromArray(i.values.specular||[0,0,0]),!0},n.prototype._loadTexture=function(e,t,n,r,o){me.LoadTextureBufferAsync(e,t,function(o){me.CreateTextureAsync(e,t,o,function(e){return n[r]=e})},o)},n}(ge);_e.RegisterExtension(new ye);var ve={__proto__:null,get EBlendingFunction(){return W},get EComponentType(){return G},get ECullingType(){return U},get EParameterType(){return V},get EShaderType(){return D},get ETextureFilterType(){return K},get ETextureFormat(){return j},get ETextureWrapMode(){return H},GLTFBinaryExtension:be,GLTFLoader:_e,GLTFLoaderBase:me,GLTFLoaderExtension:ge,GLTFMaterialsCommonExtension:ye,GLTFUtils:Y},Te=new Map,xe=Te;function Ae(e,n,r){we(e)&&t.Logger.Warn("Extension with the name '".concat(e,"' already exists")),Te.set(e,{isGLTFExtension:n,factory:r})}function we(e){return Te.delete(e)}var Oe=[{regex:new RegExp("^/nodes/\\d+/extensions/")}],Ce=function(){function e(e,t){this._gltf=e,this._infoTree=t}return e.prototype.convert=function(e){var t=this._gltf,n=this._infoTree,r=void 0;if(!e.startsWith("/"))throw new Error("Path must start with a /");var o=e.split("/");if(o.shift(),o[o.length-1].includes(".length")){var a=o[o.length-1].split(".");o.pop(),o.push.apply(o,a)}for(var i=!1,s=0,l=o;s<l.length;s++){var u=l[s],c="length"===u;if(c&&!n.__array__)throw new Error("Path ".concat(e," is invalid"));if(n.__ignoreObjectTree__&&(i=!0),n.__array__&&!c)n=n.__array__;else if(!(n=n[u]))throw new Error("Path ".concat(e," is invalid"));if(!i)if(void 0===t){if(!Oe.find(function(t){return t.regex.test(e)}))throw new Error("Path ".concat(e," is invalid"))}else c||(t=null==t?void 0:t[u]);(n.__target__||c)&&(r=t)}return{object:r,info:n}},e}(),Me={length:{type:"number",get:function(e){return e.length},getTarget:function(e){return e.map(function(e){return e._babylonTransformNode})},getPropertyName:[function(){return"length"}]},__array__:{__target__:!0,translation:{type:"Vector3",get:function(e){var t;return null===(t=e._babylonTransformNode)||void 0===t?void 0:t.position},set:function(e,t){var n;return null===(n=t._babylonTransformNode)||void 0===n?void 0:n.position.copyFrom(e)},getTarget:function(e){return e._babylonTransformNode},getPropertyName:[function(){return"position"}]},rotation:{type:"Quaternion",get:function(e){var t;return null===(t=e._babylonTransformNode)||void 0===t?void 0:t.rotationQuaternion},set:function(e,t){var n,r;return null===(r=null===(n=t._babylonTransformNode)||void 0===n?void 0:n.rotationQuaternion)||void 0===r?void 0:r.copyFrom(e)},getTarget:function(e){return e._babylonTransformNode},getPropertyName:[function(){return"rotationQuaternion"}]},scale:{type:"Vector3",get:function(e){var t;return null===(t=e._babylonTransformNode)||void 0===t?void 0:t.scaling},set:function(e,t){var n;return null===(n=t._babylonTransformNode)||void 0===n?void 0:n.scaling.copyFrom(e)},getTarget:function(e){return e._babylonTransformNode},getPropertyName:[function(){return"scaling"}]},weights:{length:{type:"number",get:function(e){return e._numMorphTargets},getTarget:function(e){return e._babylonTransformNode},getPropertyName:[function(){return"influence"}]},__array__:{__target__:!0,type:"number",get:function(e,t){var n,r;return void 0!==t?null===(r=null===(n=e._primitiveBabylonMeshes)||void 0===n?void 0:n[0].morphTargetManager)||void 0===r?void 0:r.getTarget(t).influence:void 0},getTarget:function(e){return e._babylonTransformNode},getPropertyName:[function(){return"influence"}]},type:"number[]",get:function(e,t){return[0]},getTarget:function(e){return e._babylonTransformNode},getPropertyName:[function(){return"influence"}]},matrix:{type:"Matrix",get:function(e){var n,r,o;return t.Matrix.Compose(null===(n=e._babylonTransformNode)||void 0===n?void 0:n.scaling,null===(r=e._babylonTransformNode)||void 0===r?void 0:r.rotationQuaternion,null===(o=e._babylonTransformNode)||void 0===o?void 0:o.position)},getTarget:function(e){return e._babylonTransformNode},isReadOnly:!0},globalMatrix:{type:"Matrix",get:function(e){for(var n,r,o,a,i,s,l,u=t.Matrix.Identity(),c=e.parent;c&&c.parent;)c=c.parent;var f=(null===(n=e._babylonTransformNode)||void 0===n?void 0:n.position._isDirty)||(null===(o=null===(r=e._babylonTransformNode)||void 0===r?void 0:r.rotationQuaternion)||void 0===o?void 0:o._isDirty)||(null===(a=e._babylonTransformNode)||void 0===a?void 0:a.scaling._isDirty);if(c){var h=null===(i=c._babylonTransformNode)||void 0===i?void 0:i.computeWorldMatrix(!0).invert();h&&(null===(l=null===(s=e._babylonTransformNode)||void 0===s?void 0:s.computeWorldMatrix(f))||void 0===l||l.multiplyToRef(h,u))}else e._babylonTransformNode&&u.copyFrom(e._babylonTransformNode.computeWorldMatrix(f));return u},getTarget:function(e){return e._babylonTransformNode},isReadOnly:!0},extensions:{EXT_lights_ies:{multiplier:{type:"number",get:function(e){var n,r;return null===(r=null===(n=e._babylonTransformNode)||void 0===n?void 0:n.getChildren(function(e){return e instanceof t.SpotLight},!0)[0])||void 0===r?void 0:r.intensity},getTarget:function(e){var n;return null===(n=e._babylonTransformNode)||void 0===n?void 0:n.getChildren(function(e){return e instanceof t.SpotLight},!0)[0]},set:function(e,n){if(n._babylonTransformNode){var r=n._babylonTransformNode.getChildren(function(e){return e instanceof t.SpotLight},!0)[0];r&&(r.intensity=e)}}},color:{type:"Color3",get:function(e){var n,r;return null===(r=null===(n=e._babylonTransformNode)||void 0===n?void 0:n.getChildren(function(e){return e instanceof t.SpotLight},!0)[0])||void 0===r?void 0:r.diffuse},getTarget:function(e){var n;return null===(n=e._babylonTransformNode)||void 0===n?void 0:n.getChildren(function(e){return e instanceof t.SpotLight},!0)[0]},set:function(e,n){if(n._babylonTransformNode){var r=n._babylonTransformNode.getChildren(function(e){return e instanceof t.SpotLight},!0)[0];r&&(r.diffuse=e)}}}},KHR_node_visibility:{visible:{type:"boolean",get:function(e){return!!e._primitiveBabylonMeshes&&e._primitiveBabylonMeshes[0].isVisible},getTarget:function(){},set:function(e,t){t._primitiveBabylonMeshes&&t._primitiveBabylonMeshes.forEach(function(t){return t.isVisible=e})}}}}}},Ee={__array__:{__target__:!0,orthographic:{xmag:{componentsCount:2,type:"Vector2",get:function(e){var n,r,o,a;return new t.Vector2(null!==(r=null===(n=e._babylonCamera)||void 0===n?void 0:n.orthoLeft)&&void 0!==r?r:0,null!==(a=null===(o=e._babylonCamera)||void 0===o?void 0:o.orthoRight)&&void 0!==a?a:0)},set:function(e,t){t._babylonCamera&&(t._babylonCamera.orthoLeft=e.x,t._babylonCamera.orthoRight=e.y)},getTarget:function(e){return e},getPropertyName:[function(){return"orthoLeft"},function(){return"orthoRight"}]},ymag:{componentsCount:2,type:"Vector2",get:function(e){var n,r,o,a;return new t.Vector2(null!==(r=null===(n=e._babylonCamera)||void 0===n?void 0:n.orthoBottom)&&void 0!==r?r:0,null!==(a=null===(o=e._babylonCamera)||void 0===o?void 0:o.orthoTop)&&void 0!==a?a:0)},set:function(e,t){t._babylonCamera&&(t._babylonCamera.orthoBottom=e.x,t._babylonCamera.orthoTop=e.y)},getTarget:function(e){return e},getPropertyName:[function(){return"orthoBottom"},function(){return"orthoTop"}]},zfar:{type:"number",get:function(e){var t;return null===(t=e._babylonCamera)||void 0===t?void 0:t.maxZ},set:function(e,t){t._babylonCamera&&(t._babylonCamera.maxZ=e)},getTarget:function(e){return e},getPropertyName:[function(){return"maxZ"}]},znear:{type:"number",get:function(e){var t;return null===(t=e._babylonCamera)||void 0===t?void 0:t.minZ},set:function(e,t){t._babylonCamera&&(t._babylonCamera.minZ=e)},getTarget:function(e){return e},getPropertyName:[function(){return"minZ"}]}},perspective:{aspectRatio:{type:"number",get:function(e){var t;return null===(t=e._babylonCamera)||void 0===t?void 0:t.getEngine().getAspectRatio(e._babylonCamera)},getTarget:function(e){return e},getPropertyName:[function(){return"aspectRatio"}],isReadOnly:!0},yfov:{type:"number",get:function(e){var t;return null===(t=e._babylonCamera)||void 0===t?void 0:t.fov},set:function(e,t){t._babylonCamera&&(t._babylonCamera.fov=e)},getTarget:function(e){return e},getPropertyName:[function(){return"fov"}]},zfar:{type:"number",get:function(e){var t;return null===(t=e._babylonCamera)||void 0===t?void 0:t.maxZ},set:function(e,t){t._babylonCamera&&(t._babylonCamera.maxZ=e)},getTarget:function(e){return e},getPropertyName:[function(){return"maxZ"}]},znear:{type:"number",get:function(e){var t;return null===(t=e._babylonCamera)||void 0===t?void 0:t.minZ},set:function(e,t){t._babylonCamera&&(t._babylonCamera.minZ=e)},getTarget:function(e){return e},getPropertyName:[function(){return"minZ"}]}}}},Re={__array__:{__target__:!0,emissiveFactor:{type:"Color3",get:function(e,t,n){return Pe(e,0,n).emissiveColor},set:function(e,t,n,r){return Pe(t,0,r).emissiveColor.copyFrom(e)},getTarget:function(e,t,n){return Pe(e,0,n)},getPropertyName:[function(){return"emissiveColor"}]},emissiveTexture:{extensions:{KHR_texture_transform:Se("emissiveTexture")}},normalTexture:{scale:{type:"number",get:function(e,t,n){var r;return null===(r=Le(e,n,"bumpTexture"))||void 0===r?void 0:r.level},set:function(e,t,n,r){var o=Le(t,r,"bumpTexture");o&&(o.level=e)},getTarget:function(e,t,n){return Pe(e,0,n)},getPropertyName:[function(){return"level"}]},extensions:{KHR_texture_transform:Se("bumpTexture")}},occlusionTexture:{strength:{type:"number",get:function(e,t,n){return Pe(e,0,n).ambientTextureStrength},set:function(e,t,n,r){var o=Pe(t,0,r);o&&(o.ambientTextureStrength=e)},getTarget:function(e,t,n){return Pe(e,0,n)},getPropertyName:[function(){return"ambientTextureStrength"}]},extensions:{KHR_texture_transform:Se("ambientTexture")}},pbrMetallicRoughness:{baseColorFactor:{type:"Color4",get:function(e,n,r){var o=Pe(e,0,r);return t.Color4.FromColor3(o.albedoColor,o.alpha)},set:function(e,t,n,r){var o=Pe(t,0,r);o.albedoColor.set(e.r,e.g,e.b),o.alpha=e.a},getTarget:function(e,t,n){return Pe(e,0,n)},getPropertyName:[function(){return"albedoColor"},function(){return"alpha"}]},baseColorTexture:{extensions:{KHR_texture_transform:Se("albedoTexture")}},metallicFactor:{type:"number",get:function(e,t,n){return Pe(e,0,n).metallic},set:function(e,t,n,r){var o=Pe(t,0,r);o&&(o.metallic=e)},getTarget:function(e,t,n){return Pe(e,0,n)},getPropertyName:[function(){return"metallic"}]},roughnessFactor:{type:"number",get:function(e,t,n){return Pe(e,0,n).roughness},set:function(e,t,n,r){var o=Pe(t,0,r);o&&(o.roughness=e)},getTarget:function(e,t,n){return Pe(e,0,n)},getPropertyName:[function(){return"roughness"}]},metallicRoughnessTexture:{extensions:{KHR_texture_transform:Se("metallicTexture")}}},extensions:{KHR_materials_anisotropy:{anisotropyStrength:{type:"number",get:function(e,t,n){return Pe(e,0,n).anisotropy.intensity},set:function(e,t,n,r){Pe(t,0,r).anisotropy.intensity=e},getTarget:function(e,t,n){return Pe(e,0,n)},getPropertyName:[function(){return"anisotropy.intensity"}]},anisotropyRotation:{type:"number",get:function(e,t,n){return Pe(e,0,n).anisotropy.angle},set:function(e,t,n,r){Pe(t,0,r).anisotropy.angle=e},getTarget:function(e,t,n){return Pe(e,0,n)},getPropertyName:[function(){return"anisotropy.angle"}]},anisotropyTexture:{extensions:{KHR_texture_transform:Se("anisotropy","texture")}}},KHR_materials_clearcoat:{clearcoatFactor:{type:"number",get:function(e,t,n){return Pe(e,0,n).clearCoat.intensity},set:function(e,t,n,r){Pe(t,0,r).clearCoat.intensity=e},getTarget:function(e,t,n){return Pe(e,0,n)},getPropertyName:[function(){return"clearCoat.intensity"}]},clearcoatRoughnessFactor:{type:"number",get:function(e,t,n){return Pe(e,0,n).clearCoat.roughness},set:function(e,t,n,r){Pe(t,0,r).clearCoat.roughness=e},getTarget:function(e,t,n){return Pe(e,0,n)},getPropertyName:[function(){return"clearCoat.roughness"}]},clearcoatTexture:{extensions:{KHR_texture_transform:Se("clearCoat","texture")}},clearcoatNormalTexture:{scale:{type:"number",get:function(e,t,n){var r;return null===(r=Pe(e,0,n).clearCoat.bumpTexture)||void 0===r?void 0:r.level},getTarget:Pe,set:function(e,t,n,r){return Pe(t,0,r).clearCoat.bumpTexture.level=e}},extensions:{KHR_texture_transform:Se("clearCoat","bumpTexture")}},clearcoatRoughnessTexture:{extensions:{KHR_texture_transform:Se("clearCoat","textureRoughness")}}},KHR_materials_dispersion:{dispersion:{type:"number",get:function(e,t,n){return Pe(e,0,n).subSurface.dispersion},getTarget:Pe,set:function(e,t,n,r){return Pe(t,0,r).subSurface.dispersion=e}}},KHR_materials_emissive_strength:{emissiveStrength:{type:"number",get:function(e,t,n){return Pe(e,0,n).emissiveIntensity},getTarget:Pe,set:function(e,t,n,r){return Pe(t,0,r).emissiveIntensity=e}}},KHR_materials_ior:{ior:{type:"number",get:function(e,t,n){return Pe(e,0,n).indexOfRefraction},getTarget:Pe,set:function(e,t,n,r){return Pe(t,0,r).indexOfRefraction=e}}},KHR_materials_iridescence:{iridescenceFactor:{type:"number",get:function(e,t,n){return Pe(e,0,n).iridescence.intensity},getTarget:Pe,set:function(e,t,n,r){return Pe(t,0,r).iridescence.intensity=e}},iridescenceIor:{type:"number",get:function(e,t,n){return Pe(e,0,n).iridescence.indexOfRefraction},getTarget:Pe,set:function(e,t,n,r){return Pe(t,0,r).iridescence.indexOfRefraction=e}},iridescenceTexture:{extensions:{KHR_texture_transform:Se("iridescence","texture")}},iridescenceThicknessMaximum:{type:"number",get:function(e,t,n){return Pe(e,0,n).iridescence.maximumThickness},getTarget:Pe,set:function(e,t,n,r){return Pe(t,0,r).iridescence.maximumThickness=e}},iridescenceThicknessMinimum:{type:"number",get:function(e,t,n){return Pe(e,0,n).iridescence.minimumThickness},getTarget:Pe,set:function(e,t,n,r){return Pe(t,0,r).iridescence.minimumThickness=e}},iridescenceThicknessTexture:{extensions:{KHR_texture_transform:Se("iridescence","thicknessTexture")}}},KHR_materials_sheen:{sheenColorFactor:{type:"Color3",get:function(e,t,n){return Pe(e,0,n).sheen.color},getTarget:Pe,set:function(e,t,n,r){return Pe(t,0,r).sheen.color.copyFrom(e)}},sheenColorTexture:{extensions:{KHR_texture_transform:Se("sheen","texture")}},sheenRoughnessFactor:{type:"number",get:function(e,t,n){return Pe(e,0,n).sheen.intensity},getTarget:Pe,set:function(e,t,n,r){return Pe(t,0,r).sheen.intensity=e}},sheenRoughnessTexture:{extensions:{KHR_texture_transform:Se("sheen","thicknessTexture")}}},KHR_materials_specular:{specularFactor:{type:"number",get:function(e,t,n){return Pe(e,0,n).metallicF0Factor},getTarget:Pe,set:function(e,t,n,r){return Pe(t,0,r).metallicF0Factor=e},getPropertyName:[function(){return"metallicF0Factor"}]},specularColorFactor:{type:"Color3",get:function(e,t,n){return Pe(e,0,n).metallicReflectanceColor},getTarget:Pe,set:function(e,t,n,r){return Pe(t,0,r).metallicReflectanceColor.copyFrom(e)},getPropertyName:[function(){return"metallicReflectanceColor"}]},specularTexture:{extensions:{KHR_texture_transform:Se("metallicReflectanceTexture")}},specularColorTexture:{extensions:{KHR_texture_transform:Se("reflectanceTexture")}}},KHR_materials_transmission:{transmissionFactor:{type:"number",get:function(e,t,n){return Pe(e,0,n).subSurface.refractionIntensity},getTarget:Pe,set:function(e,t,n,r){return Pe(t,0,r).subSurface.refractionIntensity=e},getPropertyName:[function(){return"subSurface.refractionIntensity"}]},transmissionTexture:{extensions:{KHR_texture_transform:Se("subSurface","refractionIntensityTexture")}}},KHR_materials_diffuse_transmission:{diffuseTransmissionFactor:{type:"number",get:function(e,t,n){return Pe(e,0,n).subSurface.translucencyIntensity},getTarget:Pe,set:function(e,t,n,r){return Pe(t,0,r).subSurface.translucencyIntensity=e}},diffuseTransmissionTexture:{extensions:{KHR_texture_transform:Se("subSurface","translucencyIntensityTexture")}},diffuseTransmissionColorFactor:{type:"Color3",get:function(e,t,n){return Pe(e,0,n).subSurface.translucencyColor},getTarget:Pe,set:function(e,t,n,r){var o;return e&&(null===(o=Pe(t,0,r).subSurface.translucencyColor)||void 0===o?void 0:o.copyFrom(e))}},diffuseTransmissionColorTexture:{extensions:{KHR_texture_transform:Se("subSurface","translucencyColorTexture")}}},KHR_materials_volume:{attenuationColor:{type:"Color3",get:function(e,t,n){return Pe(e,0,n).subSurface.tintColor},getTarget:Pe,set:function(e,t,n,r){return Pe(t,0,r).subSurface.tintColor.copyFrom(e)}},attenuationDistance:{type:"number",get:function(e,t,n){return Pe(e,0,n).subSurface.tintColorAtDistance},getTarget:Pe,set:function(e,t,n,r){return Pe(t,0,r).subSurface.tintColorAtDistance=e}},thicknessFactor:{type:"number",get:function(e,t,n){return Pe(e,0,n).subSurface.maximumThickness},getTarget:Pe,set:function(e,t,n,r){return Pe(t,0,r).subSurface.maximumThickness=e}},thicknessTexture:{extensions:{KHR_texture_transform:Se("subSurface","thicknessTexture")}}}}}},Fe={KHR_lights_punctual:{lights:{length:{type:"number",get:function(e){return e.length},getTarget:function(e){return e.map(function(e){return e._babylonLight})},getPropertyName:[function(e){return"length"}]},__array__:{__target__:!0,color:{type:"Color3",get:function(e){var t;return null===(t=e._babylonLight)||void 0===t?void 0:t.diffuse},set:function(e,t){var n;return null===(n=t._babylonLight)||void 0===n?void 0:n.diffuse.copyFrom(e)},getTarget:function(e){return e._babylonLight},getPropertyName:[function(e){return"diffuse"}]},intensity:{type:"number",get:function(e){var t;return null===(t=e._babylonLight)||void 0===t?void 0:t.intensity},set:function(e,t){return t._babylonLight?t._babylonLight.intensity=e:void 0},getTarget:function(e){return e._babylonLight},getPropertyName:[function(e){return"intensity"}]},range:{type:"number",get:function(e){var t;return null===(t=e._babylonLight)||void 0===t?void 0:t.range},set:function(e,t){return t._babylonLight?t._babylonLight.range=e:void 0},getTarget:function(e){return e._babylonLight},getPropertyName:[function(e){return"range"}]},spot:{innerConeAngle:{type:"number",get:function(e){var t;return null===(t=e._babylonLight)||void 0===t?void 0:t.innerAngle},set:function(e,t){return t._babylonLight?t._babylonLight.innerAngle=e:void 0},getTarget:function(e){return e._babylonLight},getPropertyName:[function(e){return"innerConeAngle"}]},outerConeAngle:{type:"number",get:function(e){var t;return null===(t=e._babylonLight)||void 0===t?void 0:t.angle},set:function(e,t){return t._babylonLight?t._babylonLight.angle=e:void 0},getTarget:function(e){return e._babylonLight},getPropertyName:[function(e){return"outerConeAngle"}]}}}}},EXT_lights_area:{lights:{length:{type:"number",get:function(e){return e.length},getTarget:function(e){return e.map(function(e){return e._babylonLight})},getPropertyName:[function(e){return"length"}]},__array__:{__target__:!0,color:{type:"Color3",get:function(e){var t;return null===(t=e._babylonLight)||void 0===t?void 0:t.diffuse},set:function(e,t){var n;return null===(n=t._babylonLight)||void 0===n?void 0:n.diffuse.copyFrom(e)},getTarget:function(e){return e._babylonLight},getPropertyName:[function(e){return"diffuse"}]},intensity:{type:"number",get:function(e){var t;return null===(t=e._babylonLight)||void 0===t?void 0:t.intensity},set:function(e,t){return t._babylonLight?t._babylonLight.intensity=e:void 0},getTarget:function(e){return e._babylonLight},getPropertyName:[function(e){return"intensity"}]},size:{type:"number",get:function(e){var t;return null===(t=e._babylonLight)||void 0===t?void 0:t.height},set:function(e,t){return t._babylonLight?t._babylonLight.height=e:void 0},getTarget:function(e){return e._babylonLight},getPropertyName:[function(e){return"size"}]},rect:{aspect:{type:"number",get:function(e){var t,n;return(null===(t=e._babylonLight)||void 0===t?void 0:t.width)/(null===(n=e._babylonLight)||void 0===n?void 0:n.height)},set:function(e,t){return t._babylonLight?t._babylonLight.width=e*t._babylonLight.height:void 0},getTarget:function(e){return e._babylonLight},getPropertyName:[function(e){return"aspect"}]}}}}},EXT_lights_ies:{lights:{length:{type:"number",get:function(e){return e.length},getTarget:function(e){return e.map(function(e){return e._babylonLight})},getPropertyName:[function(e){return"length"}]}}},EXT_lights_image_based:{lights:{length:{type:"number",get:function(e){return e.length},getTarget:function(e){return e.map(function(e){return e._babylonTexture})},getPropertyName:[function(e){return"length"}]},__array__:{__target__:!0,intensity:{type:"number",get:function(e){var t;return null===(t=e._babylonTexture)||void 0===t?void 0:t.level},set:function(e,t){t._babylonTexture&&(t._babylonTexture.level=e)},getTarget:function(e){return e._babylonTexture}},rotation:{type:"Quaternion",get:function(e){var n;return e._babylonTexture&&t.Quaternion.FromRotationMatrix(null===(n=e._babylonTexture)||void 0===n?void 0:n.getReflectionTextureMatrix())},set:function(e,n){var r;n._babylonTexture&&((null===(r=n._babylonTexture.getScene())||void 0===r?void 0:r.useRightHandedSystem)||(e=t.Quaternion.Inverse(e)),t.Matrix.FromQuaternionToRef(e,n._babylonTexture.getReflectionTextureMatrix()))},getTarget:function(e){return e._babylonTexture}}}}}};function Le(e,t,n,r){var o=Pe(e);return r?o[n][r]:o[n]}function Pe(e,n,r){var o,a,i;return null===(i=null===(o=e._data)||void 0===o?void 0:o[null!==(a=null==r?void 0:r.fillMode)&&void 0!==a?a:t.Constants.MATERIAL_TriangleFillMode])||void 0===i?void 0:i.babylonMaterial}function Se(e,n){return{offset:{componentsCount:2,type:"Vector2",get:function(r,o,a){var i=Le(r,0,e,n);return new t.Vector2(null==i?void 0:i.uOffset,null==i?void 0:i.vOffset)},getTarget:Pe,set:function(t,r,o,a){var i=Le(r,0,e,n);i.uOffset=t.x,i.vOffset=t.y},getPropertyName:[function(){return"".concat(e).concat(n?"."+n:"",".uOffset")},function(){return"".concat(e).concat(n?"."+n:"",".vOffset")}]},rotation:{type:"number",get:function(t,r,o){var a;return null===(a=Le(t,0,e,n))||void 0===a?void 0:a.wAng},getTarget:Pe,set:function(t,r,o,a){return Le(r,0,e,n).wAng=t},getPropertyName:[function(){return"".concat(e).concat(n?"."+n:"",".wAng")}]},scale:{componentsCount:2,type:"Vector2",get:function(r,o,a){var i=Le(r,0,e,n);return new t.Vector2(null==i?void 0:i.uScale,null==i?void 0:i.vScale)},getTarget:Pe,set:function(t,r,o,a){var i=Le(r,0,e,n);i.uScale=t.x,i.vScale=t.y},getPropertyName:[function(){return"".concat(e).concat(n?"."+n:"",".uScale")},function(){return"".concat(e).concat(n?"."+n:"",".vScale")}]}}}var Ne={cameras:Ee,nodes:Me,materials:Re,extensions:Fe,animations:{length:{type:"number",get:function(e){return e.length},getTarget:function(e){return e.map(function(e){return e._babylonAnimationGroup})},getPropertyName:[function(){return"length"}]},__array__:{}},meshes:{length:{type:"number",get:function(e){return e.length},getTarget:function(e){return e.map(function(e){var t;return null===(t=e.primitives[0]._instanceData)||void 0===t?void 0:t.babylonSourceMesh})},getPropertyName:[function(){return"length"}]},__array__:{}}};function Ie(e){return new Ce(e,Ne)}function Be(e){for(var t=e.split("/").map(function(e){return e.replace(/{}/g,"__array__")}),n=Ne,r=0,o=t;r<o.length;r++){var a=o[r];a&&(n=n[a])}if(n&&n.type&&n.get)return n}function ke(e,t){for(var n=e.split("/").map(function(e){return e.replace(/{}/g,"__array__")}),r=Ne,o=0,a=n;o<a.length;o++){var i=a[o];i&&(r=r[i])}r&&r.type&&r.get&&(r.interpolation=t)}function Ge(e,t){for(var n=e.split("/").map(function(e){return e.replace(/{}/g,"__array__")}),r=Ne,o=0,a=n;o<a.length;o++){var i=a[o];if(i){if(!r[i]){if("?"===i){r.__ignoreObjectTree__=!0;continue}r[i]={},"__array__"===i&&(r[i].__target__=!0)}r=r[i]}}Object.assign(r,t)}var De=new t.Lazy(function(){return Promise.resolve(BABYLON)}),Ve=new t.Lazy(function(){return Promise.resolve().then(function(){return Qe})}),He=function(){function e(){}return e.Get=function(e,t,n){if(!t||null==n||!t[n])throw new Error("".concat(e,": Failed to find index (").concat(n,")"));return t[n]},e.TryGet=function(e,t){return e&&null!=t&&e[t]?e[t]:null},e.Assign=function(e){if(e)for(var t=0;t<e.length;t++)e[t].index=t},e}();function Ke(e){if(e.min&&e.max){var n=e.min,r=e.max,o=t.TmpVectors.Vector3[0].copyFromFloats(n[0],n[1],n[2]),a=t.TmpVectors.Vector3[1].copyFromFloats(r[0],r[1],r[2]);if(e.normalized&&5126!==e.componentType){var i=1;switch(e.componentType){case 5120:i=127;break;case 5121:i=255;break;case 5122:i=32767;break;case 5123:i=65535}var s=1/i;o.scaleInPlace(s),a.scaleInPlace(s)}return new t.BoundingInfo(o,a)}return null}var je=function(){function n(e){this._completePromises=new Array,this._assetContainer=null,this._babylonLights=[],this._disableInstancedMesh=0,this._allMaterialsDirtyRequired=!1,this._skipStartAnimationStep=!1,this._extensions=new Array,this._disposed=!1,this._rootUrl=null,this._fileName=null,this._uniqueRootUrl=null,this._bin=null,this._rootBabylonMesh=null,this._defaultBabylonMaterialData={},this._postSceneLoadActions=new Array,this._materialAdapterCache=new WeakMap,this._materialAdapters=new Set,this._pbrMaterialImpls=new Map,this._parent=e}return n.prototype.isMatchingMaterialType=function(e){if(!e)return!1;for(var t=0,n=Array.from(this._pbrMaterialImpls.values());t<n.length;t++)if(e instanceof n[t].materialClass)return!0;return!1},n.RegisterExtension=function(e,t){Ae(e,!1,t)},n.UnregisterExtension=function(e){return we(e)},Object.defineProperty(n.prototype,"gltf",{get:function(){if(!this._gltf)throw new Error("glTF JSON is not available");return this._gltf},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"bin",{get:function(){return this._bin},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"parent",{get:function(){return this._parent},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"babylonScene",{get:function(){if(!this._babylonScene)throw new Error("Scene is not available");return this._babylonScene},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"rootBabylonMesh",{get:function(){return this._rootBabylonMesh},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"rootUrl",{get:function(){return this._rootUrl},enumerable:!1,configurable:!0}),n.prototype._getOrCreateMaterialAdapter=function(e){var t=this._materialAdapterCache.get(e);if(!t){for(var n=0,r=Array.from(this._pbrMaterialImpls.values());n<r.length;n++){var o=r[n];if(e instanceof o.materialClass){t=new o.adapterClass(e);break}}if(!t)throw new Error("Appropriate material adapter class not found");var a=t;this._materialAdapterCache.set(e,a),this._materialAdapters.add(a)}return t},n.prototype.dispose=function(){this._disposed||(this._disposed=!0,this._completePromises.length=0,this._extensions.forEach(function(e){return e.dispose&&e.dispose()}),this._extensions.length=0,this._materialAdapters.clear(),this._gltf=null,this._bin=null,this._babylonScene=null,this._rootBabylonMesh=null,this._defaultBabylonMaterialData={},this._postSceneLoadActions.length=0,this._parent.dispose())},n.prototype.importMeshAsync=function(e,t,n,r,o,a){return g(this,arguments,void 0,function(e,t,n,r,o,a,i){var s=this;return void 0===i&&(i=""),b(this,function(a){switch(a.label){case 0:return[4,Promise.resolve().then(function(){return g(s,void 0,void 0,function(){var a,s,l,u,c,f=this;return b(this,function(h){switch(h.label){case 0:if(this._babylonScene=t,this._assetContainer=n,this._loadData(r),a=null,e){if(s={},this._gltf.nodes)for(l=0,u=this._gltf.nodes;l<u.length;l++)(c=u[l]).name&&(s[c.name]=c.index);a=(e instanceof Array?e:[e]).map(function(e){var t=s[e];if(void 0===t)throw new Error("Failed to find node '".concat(e,"'"));return t})}return[4,this._loadAsync(o,i,a,function(){return{meshes:f._getMeshes(),particleSystems:[],skeletons:f._getSkeletons(),animationGroups:f._getAnimationGroups(),lights:f._babylonLights,transformNodes:f._getTransformNodes(),geometries:f._getGeometries(),spriteManagers:[]}})];case 1:return[2,h.sent()]}})})})];case 1:return[2,a.sent()]}})})},n.prototype.loadAsync=function(e,t,n,r){return g(this,arguments,void 0,function(e,t,n,r,o){return void 0===o&&(o=""),b(this,function(r){switch(r.label){case 0:return this._babylonScene=e,this._loadData(t),[4,this._loadAsync(n,o,null,function(){})];case 1:return[2,r.sent()]}})})},n.prototype._loadAsync=function(n,r,o,a){return g(this,void 0,void 0,function(){var i=this;return b(this,function(s){switch(s.label){case 0:return[4,Promise.resolve().then(function(){return g(i,void 0,void 0,function(){var i,s,l,u,c,f,h,d,p,m,_,g,y,v,T=this;return b(this,function(b){switch(b.label){case 0:return this._rootUrl=n,this._uniqueRootUrl=!n.startsWith("file:")&&r?n:"".concat(n).concat(Date.now(),"/"),this._fileName=r,this._allMaterialsDirtyRequired=!1,[4,this._loadExtensionsAsync()];case 1:return b.sent(),this.parent.skipMaterials?[3,3]:(i=this.parent.useOpenPBR||this.isExtensionUsed("KHR_materials_openpbr"),s=!1,this.parent.useOpenPBR?(null===(v=this._gltf.materials)||void 0===v?void 0:v.length)&&this._gltf.materials.some(function(e){var t;return!(null===(t=e.extensions)||void 0===t?void 0:t.KHR_materials_openpbr)})&&(s=!0):s=!0,l=[],i&&!this._pbrMaterialImpls.has("openpbr")&&l.push(Promise.all([Promise.resolve(BABYLON),Promise.resolve().then(function(){return $e})]).then(function(e){var t=e[0].OpenPBRMaterial,n=e[1].OpenPBRMaterialLoadingAdapter;T._pbrMaterialImpls.set("openpbr",{materialClass:t,adapterClass:n})})),s&&!this._pbrMaterialImpls.has("pbr")&&l.push(Promise.all([Promise.resolve(BABYLON),Promise.resolve().then(function(){return tt})]).then(function(e){var t=e[0].PBRMaterial,n=e[1].PBRMaterialLoadingAdapter;T._pbrMaterialImpls.set("pbr",{materialClass:t,adapterClass:n})})),[4,Promise.all(l)]);case 2:b.sent(),b.label=3;case 3:if(u="".concat(e.GLTFLoaderState[e.GLTFLoaderState.LOADING]," => ").concat(e.GLTFLoaderState[e.GLTFLoaderState.READY]),c="".concat(e.GLTFLoaderState[e.GLTFLoaderState.LOADING]," => ").concat(e.GLTFLoaderState[e.GLTFLoaderState.COMPLETE]),this._parent._startPerformanceCounter(u),this._parent._startPerformanceCounter(c),this._parent._setState(e.GLTFLoaderState.LOADING),this._extensionsOnLoading(),f=new Array,h=this._babylonScene.blockMaterialDirtyMechanism,this._babylonScene.blockMaterialDirtyMechanism=!0,this.parent.loadOnlyMaterials||(o?f.push(this.loadSceneAsync("/nodes",{nodes:o,index:-1})):(null!=this._gltf.scene||this._gltf.scenes&&this._gltf.scenes[0])&&(d=He.Get("/scene",this._gltf.scenes,this._gltf.scene||0),f.push(this.loadSceneAsync("/scenes/".concat(d.index),d)))),!this.parent.skipMaterials&&this.parent.loadAllMaterials&&this._gltf.materials)for(p=0;p<this._gltf.materials.length;++p)m=this._gltf.materials[p],_="/materials/"+p,g=t.Material.TriangleFillMode,f.push(this._loadMaterialAsync(_,m,null,g,function(){}));return this._allMaterialsDirtyRequired?this._babylonScene.blockMaterialDirtyMechanism=h:this._babylonScene._forceBlockMaterialDirtyMechanism(h),this._parent.compileMaterials&&f.push(this._compileMaterialsAsync()),this._parent.compileShadowGenerators&&f.push(this._compileShadowGeneratorsAsync()),y=Promise.all(f).then(function(){T._rootBabylonMesh&&T._rootBabylonMesh!==T._parent.customRootNode&&T._rootBabylonMesh.setEnabled(!0);for(var t=0,n=T._babylonScene.materials;t<n.length;t++){var r=n[t];void 0!==r.maxSimultaneousLights&&(r.maxSimultaneousLights=Math.max(r.maxSimultaneousLights,T._babylonScene.lights.length))}for(var o=0,i=Array.from(T._materialAdapters);o<i.length;o++){var s=i[o];T._completePromises.push(s.finalizeAsync(T))}return T._extensionsOnReady(),T._parent._setState(e.GLTFLoaderState.READY),T._skipStartAnimationStep||T._startAnimations(),a()}),[4,y.then(function(n){return T._parent._endPerformanceCounter(u),t.Tools.SetImmediate(function(){T._disposed||Promise.all(T._completePromises).then(function(){T._parent._endPerformanceCounter(c),T._parent._setState(e.GLTFLoaderState.COMPLETE),T._parent.onCompleteObservable.notifyObservers(void 0),T._parent.onCompleteObservable.clear(),T.dispose()},function(e){T._parent.onErrorObservable.notifyObservers(e),T._parent.onErrorObservable.clear(),T.dispose()})}),n})];case 4:return[2,b.sent()]}})})}).catch(function(e){throw i._disposed||(i._parent.onErrorObservable.notifyObservers(e),i._parent.onErrorObservable.clear(),i.dispose()),e})];case 1:return[2,s.sent()]}})})},n.prototype._loadData=function(e){if(this._gltf=e.json,this._setupData(),e.bin){var n=this._gltf.buffers;if(n&&n[0]&&!n[0].uri){var r=n[0];(r.byteLength<e.bin.byteLength-3||r.byteLength>e.bin.byteLength)&&t.Logger.Warn("Binary buffer length (".concat(r.byteLength,") from JSON does not match chunk length (").concat(e.bin.byteLength,")")),this._bin=e.bin}else t.Logger.Warn("Unexpected BIN chunk")}},n.prototype._setupData=function(){if(He.Assign(this._gltf.accessors),He.Assign(this._gltf.animations),He.Assign(this._gltf.buffers),He.Assign(this._gltf.bufferViews),He.Assign(this._gltf.cameras),He.Assign(this._gltf.images),He.Assign(this._gltf.materials),He.Assign(this._gltf.meshes),He.Assign(this._gltf.nodes),He.Assign(this._gltf.samplers),He.Assign(this._gltf.scenes),He.Assign(this._gltf.skins),He.Assign(this._gltf.textures),this._gltf.nodes){for(var e={},t=0,n=this._gltf.nodes;t<n.length;t++)if((l=n[t]).children)for(var r=0,o=l.children;r<o.length;r++)e[o[r]]=l.index;for(var a=this._createRootNode(),i=0,s=this._gltf.nodes;i<s.length;i++){var l,u=e[(l=s[i]).index];l.parent=void 0===u?a:this._gltf.nodes[u]}}},n.prototype._loadExtensionsAsync=function(){return g(this,void 0,void 0,function(){var e,n,r,o,a,i,s,l,u,c,f,h=this;return b(this,function(d){switch(d.label){case 0:return e=[],xe.forEach(function(n,r){var o;!1===(null===(o=h.parent.extensionOptions[r])||void 0===o?void 0:o.enabled)?n.isGLTFExtension&&h.isExtensionUsed(r)&&t.Logger.Warn("Extension ".concat(r," is used but has been explicitly disabled.")):n.isGLTFExtension&&!h.isExtensionUsed(r)||e.push(g(h,void 0,void 0,function(){var e;return b(this,function(o){switch(o.label){case 0:return[4,n.factory(this)];case 1:return(e=o.sent()).name!==r&&t.Logger.Warn("The name of the glTF loader extension instance does not match the registered name: ".concat(e.name," !== ").concat(r)),this._parent.onExtensionLoadedObservable.notifyObservers(e),[2,e]}})}))}),r=(n=(c=this._extensions).push).apply,o=[c],[4,Promise.all(e)];case 1:if(r.apply(n,o.concat([d.sent()])),this._extensions.sort(function(e,t){return(e.order||Number.MAX_VALUE)-(t.order||Number.MAX_VALUE)}),this._parent.onExtensionLoadedObservable.clear(),this._gltf.extensionsRequired)for(a=function(e){if(!i._extensions.some(function(t){return t.name===e&&t.enabled})){if(!1===(null===(f=i.parent.extensionOptions[e])||void 0===f?void 0:f.enabled))throw new Error("Required extension ".concat(e," is disabled"));throw new Error("Required extension ".concat(e," is not available"))}},i=this,s=0,l=this._gltf.extensionsRequired;s<l.length;s++)u=l[s],a(u);return[2]}})})},n.prototype._createRootNode=function(){if(void 0!==this._parent.customRootNode)return this._rootBabylonMesh=this._parent.customRootNode,{_babylonTransformNode:null===this._rootBabylonMesh?void 0:this._rootBabylonMesh,index:-1};this._babylonScene._blockEntityCollection=!!this._assetContainer;var r=new t.Mesh("__root__",this._babylonScene);this._rootBabylonMesh=r,this._rootBabylonMesh._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,this._rootBabylonMesh.setEnabled(!1);var o={_babylonTransformNode:this._rootBabylonMesh,index:-1};switch(this._parent.coordinateSystemMode){case e.GLTFLoaderCoordinateSystemMode.AUTO:this._babylonScene.useRightHandedSystem||(o.rotation=[0,1,0,0],o.scale=[1,1,-1],n._LoadTransform(o,this._rootBabylonMesh));break;case e.GLTFLoaderCoordinateSystemMode.FORCE_RIGHT_HANDED:this._babylonScene.useRightHandedSystem=!0;break;default:throw new Error("Invalid coordinate system mode (".concat(this._parent.coordinateSystemMode,")"))}return this._parent.onMeshLoadedObservable.notifyObservers(r),o},n.prototype.loadSceneAsync=function(e,t){var n=this,r=this._extensionsLoadSceneAsync(e,t);if(r)return r;var o=new Array;if(this.logOpen("".concat(e," ").concat(t.name||"")),t.nodes)for(var a=0,i=t.nodes;a<i.length;a++){var s=i[a],l=He.Get("".concat(e,"/nodes/").concat(s),this._gltf.nodes,s);o.push(this.loadNodeAsync("/nodes/".concat(l.index),l,function(e){e.parent=n._rootBabylonMesh}))}for(var u=0,c=this._postSceneLoadActions;u<c.length;u++)(0,c[u])();return o.push(this._loadAnimationsAsync()),this.logClose(),Promise.all(o).then(function(){})},n.prototype._forEachPrimitive=function(e,t){if(e._primitiveBabylonMeshes)for(var n=0,r=e._primitiveBabylonMeshes;n<r.length;n++)t(r[n])},n.prototype._getGeometries=function(){var e=[],t=this._gltf.nodes;if(t)for(var n=0,r=t;n<r.length;n++){var o=r[n];this._forEachPrimitive(o,function(t){var n=t.geometry;n&&-1===e.indexOf(n)&&e.push(n)})}return e},n.prototype._getMeshes=function(){var e=[];this._rootBabylonMesh instanceof t.AbstractMesh&&e.push(this._rootBabylonMesh);var n=this._gltf.nodes;if(n)for(var r=0,o=n;r<o.length;r++){var a=o[r];this._forEachPrimitive(a,function(t){e.push(t)})}return e},n.prototype._getTransformNodes=function(){var e=[],t=this._gltf.nodes;if(t)for(var n=0,r=t;n<r.length;n++){var o=r[n];o._babylonTransformNode&&"TransformNode"===o._babylonTransformNode.getClassName()&&e.push(o._babylonTransformNode),o._babylonTransformNodeForSkin&&e.push(o._babylonTransformNodeForSkin)}return e},n.prototype._getSkeletons=function(){var e=[],t=this._gltf.skins;if(t)for(var n=0,r=t;n<r.length;n++){var o=r[n];o._data&&e.push(o._data.babylonSkeleton)}return e},n.prototype._getAnimationGroups=function(){var e=[],t=this._gltf.animations;if(t)for(var n=0,r=t;n<r.length;n++){var o=r[n];o._babylonAnimationGroup&&e.push(o._babylonAnimationGroup)}return e},n.prototype._startAnimations=function(){switch(this._parent.animationStartMode){case e.GLTFLoaderAnimationStartMode.NONE:break;case e.GLTFLoaderAnimationStartMode.FIRST:0!==(n=this._getAnimationGroups()).length&&n[0].start(!0);break;case e.GLTFLoaderAnimationStartMode.ALL:for(var n,r=0,o=n=this._getAnimationGroups();r<o.length;r++)o[r].start(!0);break;default:return void t.Logger.Error("Invalid animation start mode (".concat(this._parent.animationStartMode,")"))}},n.prototype.loadNodeAsync=function(e,r,o){var a=this;void 0===o&&(o=function(){});var i=this._extensionsLoadNodeAsync(e,r,o);if(i)return i;if(r._babylonTransformNode)throw new Error("".concat(e,": Invalid recursive node hierarchy"));var s=new Array;this.logOpen("".concat(e," ").concat(r.name||""));var l=function(t){if(n.AddPointerMetadata(t,e),n._LoadTransform(r,t),null!=r.camera){var i=He.Get("".concat(e,"/camera"),a._gltf.cameras,r.camera);s.push(a.loadCameraAsync("/cameras/".concat(i.index),i,function(e){e.parent=t,a._babylonScene.useRightHandedSystem||(t.scaling.x=-1)}))}if(r.children)for(var l=0,u=r.children;l<u.length;l++){var c=u[l],f=He.Get("".concat(e,"/children/").concat(c),a._gltf.nodes,c);s.push(a.loadNodeAsync("/nodes/".concat(f.index),f,function(e){e.parent=t}))}o(t)},u=null!=r.mesh,c=this._parent.loadSkins&&null!=r.skin;if(!u||c){var f=r.name||"node".concat(r.index);this._babylonScene._blockEntityCollection=!!this._assetContainer;var h=new t.TransformNode(f,this._babylonScene);h._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,null==r.mesh?r._babylonTransformNode=h:r._babylonTransformNodeForSkin=h,l(h)}if(u)if(c){var d=He.Get("".concat(e,"/mesh"),this._gltf.meshes,r.mesh);s.push(this._loadMeshAsync("/meshes/".concat(d.index),r,d,function(n){var o=r._babylonTransformNodeForSkin;n.metadata=t.deepMerge(o.metadata,n.metadata||{});var i=He.Get("".concat(e,"/skin"),a._gltf.skins,r.skin);s.push(a._loadSkinAsync("/skins/".concat(i.index),r,i,function(e){a._forEachPrimitive(r,function(t){t.skeleton=e}),a._postSceneLoadActions.push(function(){if(null!=i.skeleton){var e=He.Get("/skins/".concat(i.index,"/skeleton"),a._gltf.nodes,i.skeleton).parent;r.index===e.index?n.parent=o.parent:n.parent=e._babylonTransformNode}else n.parent=a._rootBabylonMesh;a._parent.onSkinLoadedObservable.notifyObservers({node:o,skinnedNode:n})})}))}))}else d=He.Get("".concat(e,"/mesh"),this._gltf.meshes,r.mesh),s.push(this._loadMeshAsync("/meshes/".concat(d.index),r,d,l));return this.logClose(),Promise.all(s).then(function(){return a._forEachPrimitive(r,function(e){var t=e;!t.isAnInstance&&t.geometry&&t.geometry.useBoundingInfoFromGeometry?e._updateBoundingInfo():e.refreshBoundingInfo(!0,!0)}),r._babylonTransformNode})},n.prototype._loadMeshAsync=function(e,n,r,o){var a=r.primitives;if(!a||!a.length)throw new Error("".concat(e,": Primitives are missing"));null==a[0].index&&He.Assign(a);var i=new Array;this.logOpen("".concat(e," ").concat(r.name||""));var s=n.name||"node".concat(n.index);if(1===a.length){var l=r.primitives[0];i.push(this._loadMeshPrimitiveAsync("".concat(e,"/primitives/").concat(l.index),s,n,r,l,function(e){n._babylonTransformNode=e,n._primitiveBabylonMeshes=[e]}))}else{this._babylonScene._blockEntityCollection=!!this._assetContainer,n._babylonTransformNode=new t.TransformNode(s,this._babylonScene),n._babylonTransformNode._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,n._primitiveBabylonMeshes=[];for(var u=0,c=a;u<c.length;u++)l=c[u],i.push(this._loadMeshPrimitiveAsync("".concat(e,"/primitives/").concat(l.index),"".concat(s,"_primitive").concat(l.index),n,r,l,function(e){e.parent=n._babylonTransformNode,n._primitiveBabylonMeshes.push(e)}))}return o(n._babylonTransformNode),this.logClose(),Promise.all(i).then(function(){return n._babylonTransformNode})},n.prototype._loadMeshPrimitiveAsync=function(e,r,o,a,i,s){var l=this,u=this._extensionsLoadMeshPrimitiveAsync(e,r,o,a,i,s);if(u)return u;this.logOpen("".concat(e));var c,f,h=0===this._disableInstancedMesh&&this._parent.createInstances&&null==o.skin&&!a.primitives[0].targets;if(h&&i._instanceData)this._babylonScene._blockEntityCollection=!!this._assetContainer,(c=i._instanceData.babylonSourceMesh.createInstance(r))._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,f=i._instanceData.promise;else{var d=new Array;this._babylonScene._blockEntityCollection=!!this._assetContainer;var p=new t.Mesh(r,this._babylonScene);if(p._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,p.sideOrientation=this._babylonScene.useRightHandedSystem?t.Material.CounterClockWiseSideOrientation:t.Material.ClockWiseSideOrientation,this._createMorphTargets(e,o,a,i,p),d.push(this._loadVertexDataAsync(e,i,p).then(function(t){return g(l,void 0,void 0,function(){var n=this;return b(this,function(r){switch(r.label){case 0:return[4,this._loadMorphTargetsAsync(e,i,p,t).then(function(){n._disposed||(n._babylonScene._blockEntityCollection=!!n._assetContainer,t.applyToMesh(p),t._parentContainer=n._assetContainer,n._babylonScene._blockEntityCollection=!1)})];case 1:return[2,r.sent()]}})})})),!this.parent.skipMaterials){var m=n._GetDrawMode(e,i.mode);if(null==i.material){var _=this._defaultBabylonMaterialData[m];_||(_=this._createDefaultMaterial("__GLTFLoader._default",m,this._getDefaultImpl()),this._parent.onMaterialLoadedObservable.notifyObservers(_),this._defaultBabylonMaterialData[m]=_),p.material=_}else{var y=He.Get("".concat(e,"/material"),this._gltf.materials,i.material);d.push(this._loadMaterialAsync("/materials/".concat(y.index),y,p,m,function(e){p.material=e}))}}f=Promise.all(d),h&&(i._instanceData={babylonSourceMesh:p,promise:f}),c=p}return n.AddPointerMetadata(c,e),this._parent.onMeshLoadedObservable.notifyObservers(c),s(c),this.logClose(),f.then(function(){return c})},n.prototype._loadVertexDataAsync=function(e,n,r){var o=this,a=this._extensionsLoadVertexDataAsync(e,n,r);if(a)return a;var i=n.attributes;if(!i)throw new Error("".concat(e,": Attributes are missing"));var s=new Array,l=new t.Geometry(r.name,this._babylonScene);if(null==n.indices)r.isUnIndexed=!0;else{var u=He.Get("".concat(e,"/indices"),this._gltf.accessors,n.indices);s.push(this._loadIndicesAccessorAsync("/accessors/".concat(u.index),u).then(function(e){l.setIndices(e)}))}var c=function(n,a,u){if(null!=i[n]){r._delayInfo=r._delayInfo||[],-1===r._delayInfo.indexOf(a)&&r._delayInfo.push(a);var c=He.Get("".concat(e,"/attributes/").concat(n),o._gltf.accessors,i[n]);s.push(o._loadVertexAccessorAsync("/accessors/".concat(c.index),c,a).then(function(e){if(e.getKind()===t.VertexBuffer.PositionKind&&!o.parent.alwaysComputeBoundingBox&&!r.skeleton){var n=Ke(c);n&&(l._boundingInfo=n,l.useBoundingInfoFromGeometry=!0)}l.setVerticesBuffer(e,c.count)})),a==t.VertexBuffer.MatricesIndicesExtraKind&&(r.numBoneInfluencers=8),u&&u(c)}};return c("POSITION",t.VertexBuffer.PositionKind),c("NORMAL",t.VertexBuffer.NormalKind),c("TANGENT",t.VertexBuffer.TangentKind),c("TEXCOORD_0",t.VertexBuffer.UVKind),c("TEXCOORD_1",t.VertexBuffer.UV2Kind),c("TEXCOORD_2",t.VertexBuffer.UV3Kind),c("TEXCOORD_3",t.VertexBuffer.UV4Kind),c("TEXCOORD_4",t.VertexBuffer.UV5Kind),c("TEXCOORD_5",t.VertexBuffer.UV6Kind),c("JOINTS_0",t.VertexBuffer.MatricesIndicesKind),c("WEIGHTS_0",t.VertexBuffer.MatricesWeightsKind),c("JOINTS_1",t.VertexBuffer.MatricesIndicesExtraKind),c("WEIGHTS_1",t.VertexBuffer.MatricesWeightsExtraKind),c("COLOR_0",t.VertexBuffer.ColorKind,function(e){"VEC4"===e.type&&(r.hasVertexAlpha=!0)}),Promise.all(s).then(function(){return l})},n.prototype._createMorphTargets=function(e,n,r,o,a){if(o.targets&&this._parent.loadMorphTargets){if(null==n._numMorphTargets)n._numMorphTargets=o.targets.length;else if(o.targets.length!==n._numMorphTargets)throw new Error("".concat(e,": Primitives do not have the same number of targets"));var i=r.extras?r.extras.targetNames:null;this._babylonScene._blockEntityCollection=!!this._assetContainer,a.morphTargetManager=new t.MorphTargetManager(this._babylonScene),a.morphTargetManager._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,a.morphTargetManager.areUpdatesFrozen=!0;for(var s=0;s<o.targets.length;s++){var l=n.weights?n.weights[s]:r.weights?r.weights[s]:0,u=i?i[s]:"morphTarget".concat(s);a.morphTargetManager.addTarget(new t.MorphTarget(u,l,a.getScene()))}}},n.prototype._loadMorphTargetsAsync=function(e,t,n,r){if(!t.targets||!this._parent.loadMorphTargets)return Promise.resolve();for(var o=new Array,a=n.morphTargetManager,i=0;i<a.numTargets;i++){var s=a.getTarget(i);o.push(this._loadMorphTargetVertexDataAsync("".concat(e,"/targets/").concat(i),r,t.targets[i],s))}return Promise.all(o).then(function(){a.areUpdatesFrozen=!1})},n.prototype._loadMorphTargetVertexDataAsync=function(e,n,r,o){return g(this,void 0,void 0,function(){var a,i,s=this;return b(this,function(l){switch(l.label){case 0:return a=new Array,(i=function(t,o,i){if(null!=r[t]){var l=n.getVertexBuffer(o);if(l){var u=He.Get("".concat(e,"/").concat(t),s._gltf.accessors,r[t]);a.push(s._loadFloatAccessorAsync("/accessors/".concat(u.index),u).then(function(e){i(l,e)}))}}})("POSITION",t.VertexBuffer.PositionKind,function(e,t){var n=new Float32Array(t.length);e.forEach(t.length,function(e,r){n[r]=t[r]+e}),o.setPositions(n)}),i("NORMAL",t.VertexBuffer.NormalKind,function(e,t){var n=new Float32Array(t.length);e.forEach(n.length,function(e,r){n[r]=t[r]+e}),o.setNormals(n)}),i("TANGENT",t.VertexBuffer.TangentKind,function(e,t){var n=new Float32Array(t.length/3*4),r=0;e.forEach(t.length/3*4,function(e,o){(o+1)%4!=0&&(n[r]=t[r]+e,r++)}),o.setTangents(n)}),i("TEXCOORD_0",t.VertexBuffer.UVKind,function(e,t){var n=new Float32Array(t.length);e.forEach(t.length,function(e,r){n[r]=t[r]+e}),o.setUVs(n)}),i("TEXCOORD_1",t.VertexBuffer.UV2Kind,function(e,t){var n=new Float32Array(t.length);e.forEach(t.length,function(e,r){n[r]=t[r]+e}),o.setUV2s(n)}),i("COLOR_0",t.VertexBuffer.ColorKind,function(t,n){var r=null,a=t.getSize();if(3===a){r=new Float32Array(n.length/3*4),t.forEach(n.length,function(e,t){var o=Math.floor(t/3),a=t%3;r[4*o+a]=n[3*o+a]+e});for(var i=0;i<n.length/3;++i)r[4*i+3]=1}else{if(4!==a)throw new Error("".concat(e,": Invalid number of components (").concat(a,") for COLOR_0 attribute"));r=new Float32Array(n.length),t.forEach(n.length,function(e,t){r[t]=n[t]+e})}o.setColors(r)}),[4,Promise.all(a).then(function(){})];case 1:return[2,l.sent()]}})})},n._LoadTransform=function(e,n){if(null==e.skin){var r=t.Vector3.Zero(),o=t.Quaternion.Identity(),a=t.Vector3.One();e.matrix?t.Matrix.FromArray(e.matrix).decompose(a,o,r):(e.translation&&(r=t.Vector3.FromArray(e.translation)),e.rotation&&(o=t.Quaternion.FromArray(e.rotation)),e.scale&&(a=t.Vector3.FromArray(e.scale))),n.position=r,n.rotationQuaternion=o,n.scaling=a}},n.prototype._loadSkinAsync=function(e,n,r,o){var a=this;if(!this._parent.loadSkins)return Promise.resolve();var i=this._extensionsLoadSkinAsync(e,n,r);if(i)return i;if(r._data)return o(r._data.babylonSkeleton),r._data.promise;var s="skeleton".concat(r.index);this._babylonScene._blockEntityCollection=!!this._assetContainer;var l=new t.Skeleton(r.name||s,s,this._babylonScene);l._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,this._loadBones(e,r,l);var u=this._loadSkinInverseBindMatricesDataAsync(e,r).then(function(e){a._updateBoneMatrices(l,e)});return r._data={babylonSkeleton:l,promise:u},o(l),u},n.prototype._loadBones=function(e,n,r){if(null==n.skeleton||this._parent.alwaysComputeSkeletonRootNode){var o=this._findSkeletonRootNode("".concat(e,"/joints"),n.joints);if(o)if(void 0===n.skeleton)n.skeleton=o.index;else{var a=He.Get("".concat(e,"/skeleton"),this._gltf.nodes,n.skeleton);a===o||function(e,t){for(;t.parent;t=t.parent)if(t.parent===e)return!0;return!1}(a,o)||(t.Logger.Warn("".concat(e,"/skeleton: Overriding with nearest common ancestor as skeleton node is not a common root")),n.skeleton=o.index)}else t.Logger.Warn("".concat(e,": Failed to find common root"))}for(var i={},s=0,l=n.joints;s<l.length;s++){var u=l[s],c=He.Get("".concat(e,"/joints/").concat(u),this._gltf.nodes,u);this._loadBone(c,n,r,i)}},n.prototype._findSkeletonRootNode=function(e,t){if(0===t.length)return null;for(var n={},r=0,o=t;r<o.length;r++){for(var a=o[r],i=[],s=He.Get("".concat(e,"/").concat(a),this._gltf.nodes,a);-1!==s.index;)i.unshift(s),s=s.parent;n[a]=i}for(var l=null,u=0;;++u){if(u>=(i=n[t[0]]).length)return l;s=i[u];for(var c=1;c<t.length;++c)if(u>=(i=n[t[c]]).length||s!==i[u])return l;l=s}},n.prototype._loadBone=function(e,n,r,o){e._isJoint=!0;var a=o[e.index];if(a)return a;var i=null;e.index!==n.skeleton&&(e.parent&&-1!==e.parent.index?i=this._loadBone(e.parent,n,r,o):void 0!==n.skeleton&&t.Logger.Warn("/skins/".concat(n.index,"/skeleton: Skeleton node is not a common root")));var s=n.joints.indexOf(e.index);return a=new t.Bone(e.name||"joint".concat(e.index),r,i,this._getNodeMatrix(e),null,null,s),o[e.index]=a,this._postSceneLoadActions.push(function(){a.linkTransformNode(e._babylonTransformNode)}),a},n.prototype._loadSkinInverseBindMatricesDataAsync=function(e,t){if(null==t.inverseBindMatrices)return Promise.resolve(null);var n=He.Get("".concat(e,"/inverseBindMatrices"),this._gltf.accessors,t.inverseBindMatrices);return this._loadFloatAccessorAsync("/accessors/".concat(n.index),n)},n.prototype._updateBoneMatrices=function(e,n){for(var r=0,o=e.bones;r<o.length;r++){var a=o[r],i=t.Matrix.Identity(),s=a._index;n&&-1!==s&&(t.Matrix.FromArrayToRef(n,16*s,i),i.invertToRef(i));var l=a.getParent();l&&i.multiplyToRef(l.getAbsoluteInverseBindMatrix(),i),a.updateMatrix(i,!1,!1),a._updateAbsoluteBindMatrices(void 0,!1)}},n.prototype._getNodeMatrix=function(e){return e.matrix?t.Matrix.FromArray(e.matrix):t.Matrix.Compose(e.scale?t.Vector3.FromArray(e.scale):t.Vector3.One(),e.rotation?t.Quaternion.FromArray(e.rotation):t.Quaternion.Identity(),e.translation?t.Vector3.FromArray(e.translation):t.Vector3.Zero())},n.prototype.loadCameraAsync=function(e,r,o){void 0===o&&(o=function(){});var a=this._extensionsLoadCameraAsync(e,r,o);if(a)return a;var i=new Array;this.logOpen("".concat(e," ").concat(r.name||"")),this._babylonScene._blockEntityCollection=!!this._assetContainer;var s=new t.FreeCamera(r.name||"camera".concat(r.index),t.Vector3.Zero(),this._babylonScene,!1);switch(s._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,r._babylonCamera=s,s.setTarget(new t.Vector3(0,0,-1)),r.type){case"perspective":var l=r.perspective;if(!l)throw new Error("".concat(e,": Camera perspective properties are missing"));s.fov=l.yfov,s.minZ=l.znear,s.maxZ=l.zfar||0;break;case"orthographic":if(!r.orthographic)throw new Error("".concat(e,": Camera orthographic properties are missing"));s.mode=t.Camera.ORTHOGRAPHIC_CAMERA,s.orthoLeft=-r.orthographic.xmag,s.orthoRight=r.orthographic.xmag,s.orthoBottom=-r.orthographic.ymag,s.orthoTop=r.orthographic.ymag,s.minZ=r.orthographic.znear,s.maxZ=r.orthographic.zfar;break;default:throw new Error("".concat(e,": Invalid camera type (").concat(r.type,")"))}return n.AddPointerMetadata(s,e),this._parent.onCameraLoadedObservable.notifyObservers(s),o(s),this.logClose(),Promise.all(i).then(function(){return s})},n.prototype._loadAnimationsAsync=function(){var e=this;this._parent._startPerformanceCounter("Load animations");var t=this._gltf.animations;if(!t)return Promise.resolve();for(var n=new Array,r=0;r<t.length;r++){var o=t[r];n.push(this.loadAnimationAsync("/animations/".concat(o.index),o).then(function(e){0===e.targetedAnimations.length&&e.dispose()}))}return Promise.all(n).then(function(){e._parent._endPerformanceCounter("Load animations")})},n.prototype.loadAnimationAsync=function(e,t){var n=this;return this._parent._startPerformanceCounter("Load animation"),this._extensionsLoadAnimationAsync(e,t)||De.value.then(function(r){var o=r.AnimationGroup;n._babylonScene._blockEntityCollection=!!n._assetContainer;var a=new o(t.name||"animation".concat(t.index),n._babylonScene);a._parentContainer=n._assetContainer,n._babylonScene._blockEntityCollection=!1,t._babylonAnimationGroup=a;var i=new Array;He.Assign(t.channels),He.Assign(t.samplers);for(var s=0,l=t.channels;s<l.length;s++){var u=l[s];i.push(n._loadAnimationChannelAsync("".concat(e,"/channels/").concat(u.index),e,t,u,function(e,t){e.animations=e.animations||[],e.animations.push(t),a.addTargetedAnimation(t,e)}))}return n._parent._endPerformanceCounter("Load animation"),Promise.all(i).then(function(){return a.normalize(0),a})})},n.prototype._loadAnimationChannelAsync=function(e,t,n,r,o){var a=this,i=this._extensionsLoadAnimationChannelAsync(e,t,n,r,o);if(i)return i;if(null==r.target.node)return Promise.resolve();var s=He.Get("".concat(e,"/target/node"),this._gltf.nodes,r.target.node),l=r.target.path,u="weights"===l;return u&&!s._numMorphTargets||!u&&!s._babylonTransformNode?Promise.resolve():this._parent.loadNodeAnimations||u||s._isJoint?Ve.value.then(function(){var i,u,c,f,h;switch(l){case"translation":h=null===(i=Be("/nodes/{}/translation"))||void 0===i?void 0:i.interpolation;break;case"rotation":h=null===(u=Be("/nodes/{}/rotation"))||void 0===u?void 0:u.interpolation;break;case"scale":h=null===(c=Be("/nodes/{}/scale"))||void 0===c?void 0:c.interpolation;break;case"weights":h=null===(f=Be("/nodes/{}/weights"))||void 0===f?void 0:f.interpolation;break;default:throw new Error("".concat(e,"/target/path: Invalid value (").concat(r.target.path,")"))}if(!h)throw new Error("".concat(e,"/target/path: Could not find interpolation properties for target path (").concat(r.target.path,")"));var d={object:s,info:h};return a._loadAnimationChannelFromTargetInfoAsync(e,t,n,r,d,o)}):Promise.resolve()},n.prototype._loadAnimationChannelFromTargetInfoAsync=function(e,t,n,r,o,a){var i=this.parent.targetFps,s=1/i,l=He.Get("".concat(e,"/sampler"),n.samplers,r.sampler);return this._loadAnimationSamplerAsync("".concat(t,"/samplers/").concat(r.sampler),l).then(function(e){for(var t=0,l=o.object,u=0,c=o.info;u<c.length;u++){var f=c[u],h=f.getStride(l),d=e.input,p=e.output,m=new Array(d.length),_=0;switch(e.interpolation){case"STEP":for(var g=0;g<d.length;g++){var b=f.getValue(l,p,_,1);_+=h,m[g]={frame:d[g]*i,value:b,interpolation:1}}break;case"CUBICSPLINE":for(g=0;g<d.length;g++){var y=f.getValue(l,p,_,s);_+=h,b=f.getValue(l,p,_,1),_+=h;var v=f.getValue(l,p,_,s);_+=h,m[g]={frame:d[g]*i,inTangent:y,value:b,outTangent:v}}break;case"LINEAR":for(g=0;g<d.length;g++)b=f.getValue(l,p,_,1),_+=h,m[g]={frame:d[g]*i,value:b}}if(_>0)for(var T="".concat(n.name||"animation".concat(n.index),"_channel").concat(r.index,"_").concat(t),x=0,A=f.buildAnimations(l,T,i,m);x<A.length;x++){var w=A[x];t++,a(w.babylonAnimatable,w.babylonAnimation)}}})},n.prototype._loadAnimationSamplerAsync=function(e,t){if(t._data)return t._data;var n=t.interpolation||"LINEAR";switch(n){case"STEP":case"LINEAR":case"CUBICSPLINE":break;default:throw new Error("".concat(e,"/interpolation: Invalid value (").concat(t.interpolation,")"))}var r=He.Get("".concat(e,"/input"),this._gltf.accessors,t.input),o=He.Get("".concat(e,"/output"),this._gltf.accessors,t.output);return t._data=Promise.all([this._loadFloatAccessorAsync("/accessors/".concat(r.index),r),this._loadFloatAccessorAsync("/accessors/".concat(o.index),o)]).then(function(e){var t=e[0],r=e[1];return{input:t,interpolation:n,output:r}}),t._data},n.prototype.loadBufferAsync=function(e,t,n,r){var o=this._extensionsLoadBufferAsync(e,t,n,r);if(o)return o;if(!t._data)if(t.uri)t._data=this.loadUriAsync("".concat(e,"/uri"),t,t.uri);else{if(!this._bin)throw new Error("".concat(e,": Uri is missing or the binary glTF is missing its binary chunk"));t._data=this._bin.readAsync(0,t.byteLength)}return t._data.then(function(t){try{return new Uint8Array(t.buffer,t.byteOffset+n,r)}catch(t){throw new Error("".concat(e,": ").concat(t.message),{cause:t})}})},n.prototype.loadBufferViewAsync=function(e,t){var n=this._extensionsLoadBufferViewAsync(e,t);if(n)return n;if(t._data)return t._data;var r=He.Get("".concat(e,"/buffer"),this._gltf.buffers,t.buffer);return t._data=this.loadBufferAsync("/buffers/".concat(r.index),r,t.byteOffset||0,t.byteLength),t._data},n.prototype._loadAccessorAsync=function(e,r,o){var a=this;if(r._data)return r._data;var i=n._GetNumComponents(e,r.type),s=i*t.VertexBufferGetTypeByteLength(r.componentType),l=i*r.count;if(null==r.bufferView)r._data=Promise.resolve(new o(l));else{var u=He.Get("".concat(e,"/bufferView"),this._gltf.bufferViews,r.bufferView);r._data=this.loadBufferViewAsync("/bufferViews/".concat(u.index),u).then(function(a){if(5126!==r.componentType||r.normalized||u.byteStride&&u.byteStride!==s){var c=new o(l);return t.VertexBufferForEach(a,r.byteOffset||0,u.byteStride||s,i,r.componentType,c.length,r.normalized||!1,function(e,t){c[t]=e}),c}return n._GetTypedArray(e,r.componentType,a,r.byteOffset,l)})}if(r.sparse){var c=r.sparse;r._data=r._data.then(function(l){var u=l,f=He.Get("".concat(e,"/sparse/indices/bufferView"),a._gltf.bufferViews,c.indices.bufferView),h=He.Get("".concat(e,"/sparse/values/bufferView"),a._gltf.bufferViews,c.values.bufferView);return Promise.all([a.loadBufferViewAsync("/bufferViews/".concat(f.index),f),a.loadBufferViewAsync("/bufferViews/".concat(h.index),h)]).then(function(a){var l,f=a[0],h=a[1],d=n._GetTypedArray("".concat(e,"/sparse/indices"),c.indices.componentType,f,c.indices.byteOffset,c.count),p=i*c.count;if(5126!==r.componentType||r.normalized){var m=n._GetTypedArray("".concat(e,"/sparse/values"),r.componentType,h,c.values.byteOffset,p);l=new o(p),t.VertexBufferForEach(m,0,s,i,r.componentType,l.length,r.normalized||!1,function(e,t){l[t]=e})}else l=n._GetTypedArray("".concat(e,"/sparse/values"),r.componentType,h,c.values.byteOffset,p);for(var _=0,g=0;g<d.length;g++)for(var b=d[g]*i,y=0;y<i;y++)u[b++]=l[_++];return u})})}return r._data},n.prototype._loadFloatAccessorAsync=function(e,t){return this._loadAccessorAsync(e,t,Float32Array)},n.prototype._loadIndicesAccessorAsync=function(e,t){if("SCALAR"!==t.type)throw new Error("".concat(e,"/type: Invalid value ").concat(t.type));if(5121!==t.componentType&&5123!==t.componentType&&5125!==t.componentType)throw new Error("".concat(e,"/componentType: Invalid value ").concat(t.componentType));if(t._data)return t._data;if(t.sparse){var r=n._GetTypedArrayConstructor("".concat(e,"/componentType"),t.componentType);t._data=this._loadAccessorAsync(e,t,r)}else{var o=He.Get("".concat(e,"/bufferView"),this._gltf.bufferViews,t.bufferView);t._data=this.loadBufferViewAsync("/bufferViews/".concat(o.index),o).then(function(r){return n._GetTypedArray(e,t.componentType,r,t.byteOffset,t.count)})}return t._data},n.prototype._loadVertexBufferViewAsync=function(e){if(e._babylonBuffer)return e._babylonBuffer;var n=this._babylonScene.getEngine();return e._babylonBuffer=this.loadBufferViewAsync("/bufferViews/".concat(e.index),e).then(function(e){return new t.Buffer(n,e,!1)}),e._babylonBuffer},n.prototype._loadVertexAccessorAsync=function(e,r,o){var a;if(null===(a=r._babylonVertexBuffer)||void 0===a?void 0:a[o])return r._babylonVertexBuffer[o];r._babylonVertexBuffer||(r._babylonVertexBuffer={});var i=this._babylonScene.getEngine();if(r.sparse||null==r.bufferView)r._babylonVertexBuffer[o]=this._loadFloatAccessorAsync(e,r).then(function(e){return new t.VertexBuffer(i,e,o,!1)});else{var s=He.Get("".concat(e,"/bufferView"),this._gltf.bufferViews,r.bufferView);r._babylonVertexBuffer[o]=this._loadVertexBufferViewAsync(s).then(function(a){var l=n._GetNumComponents(e,r.type);return new t.VertexBuffer(i,a,o,!1,void 0,s.byteStride,void 0,r.byteOffset,l,r.componentType,r.normalized,!0,void 0,!0)})}return r._babylonVertexBuffer[o]},n.prototype._loadMaterialMetallicRoughnessPropertiesAsync=function(e,n,r){var o=new Array,a=this._getOrCreateMaterialAdapter(r);return n&&(n.baseColorFactor?(a.baseColor=t.Color3.FromArray(n.baseColorFactor),a.geometryOpacity=n.baseColorFactor[3]):a.baseColor=t.Color3.White(),a.baseMetalness=null==n.metallicFactor?1:n.metallicFactor,a.specularRoughness=null==n.roughnessFactor?1:n.roughnessFactor,n.baseColorTexture&&o.push(this.loadTextureInfoAsync("".concat(e,"/baseColorTexture"),n.baseColorTexture,function(e){e.name="".concat(r.name," (Base Color)"),a.baseColorTexture=e})),n.metallicRoughnessTexture&&(n.metallicRoughnessTexture.nonColorData=!0,o.push(this.loadTextureInfoAsync("".concat(e,"/metallicRoughnessTexture"),n.metallicRoughnessTexture,function(e){e.name="".concat(r.name," (Metallic Roughness)"),a.baseMetalnessTexture=e,a.specularRoughnessTexture=e})),a.useRoughnessFromMetallicTextureGreen=!0,a.useMetallicFromMetallicTextureBlue=!0)),Promise.all(o).then(function(){})},n.prototype._loadMaterialAsync=function(e,t,r,o,a){void 0===a&&(a=function(){});var i=this._extensionsLoadMaterialAsync(e,t,r,o,a);if(i)return i;t._data=t._data||{};var s=t._data[o];if(!s){this.logOpen("".concat(e," ").concat(t.name||""));var l=this.createMaterial(e,t,o);s={babylonMaterial:l,babylonMeshes:[],promise:this.loadMaterialPropertiesAsync(e,t,l)},t._data[o]=s,n.AddPointerMetadata(l,e),this._parent.onMaterialLoadedObservable.notifyObservers(l),this.logClose()}return r&&(s.babylonMeshes.push(r),r.onDisposeObservable.addOnce(function(){var e=s.babylonMeshes.indexOf(r);-1!==e&&s.babylonMeshes.splice(e,1)})),a(s.babylonMaterial),s.promise.then(function(){return s.babylonMaterial})},n.prototype._selectImplForGltfMaterial=function(e){var t;if(this.parent.useOpenPBR||(null===(t=e.extensions)||void 0===t?void 0:t.KHR_materials_openpbr)){var n=this._pbrMaterialImpls.get("openpbr");if(n)return n}var r=this._pbrMaterialImpls.get("pbr");if(r)return r;throw new Error("No PBR material implementation loaded")},n.prototype._getDefaultImpl=function(){var e;if(this.parent.useOpenPBR){var t=this._pbrMaterialImpls.get("openpbr");if(t)return t}var n=null!==(e=this._pbrMaterialImpls.get("pbr"))&&void 0!==e?e:this._pbrMaterialImpls.values().next().value;if(n)return n;throw new Error("No PBR material implementation loaded")},n.prototype._createDefaultMaterial=function(e,t,n){this._babylonScene._blockEntityCollection=!!this._assetContainer;var r=new n.materialClass(e,this._babylonScene);r._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,r.fillMode=t,r.transparencyMode=n.materialClass.MATERIAL_OPAQUE;var o=this._getOrCreateMaterialAdapter(r);return o.transparencyAsAlphaCoverage=this._parent.transparencyAsCoverage,o.baseMetalness=1,o.specularRoughness=1,r},n.prototype.createMaterial=function(e,t,n){var r=this._extensionsCreateMaterial(e,t,n);if(r)return r;var o=t.name||"material".concat(t.index);return this._createDefaultMaterial(o,n,this._selectImplForGltfMaterial(t))},n.prototype.loadMaterialPropertiesAsync=function(e,t,n){var r=this._extensionsLoadMaterialPropertiesAsync(e,t,n);if(r)return r;var o=new Array;return o.push(this.loadMaterialBasePropertiesAsync(e,t,n)),t.pbrMetallicRoughness&&o.push(this._loadMaterialMetallicRoughnessPropertiesAsync("".concat(e,"/pbrMetallicRoughness"),t.pbrMetallicRoughness,n)),this.loadMaterialAlphaProperties(e,t,n),Promise.all(o).then(function(){})},n.prototype.loadMaterialBasePropertiesAsync=function(e,n,r){var o,a=new Array,i=this._getOrCreateMaterialAdapter(r);i.emissionColor=n.emissiveFactor?t.Color3.FromArray(n.emissiveFactor):new t.Color3(0,0,0),n.doubleSided&&(i.backFaceCulling=!1,i.twoSidedLighting=!0),n.normalTexture&&(n.normalTexture.nonColorData=!0,a.push(this.loadTextureInfoAsync("".concat(e,"/normalTexture"),n.normalTexture,function(e){var t;e.name="".concat(r.name," (Normal)"),i.geometryNormalTexture=e,null!=(null===(t=n.normalTexture)||void 0===t?void 0:t.scale)&&(e.level=n.normalTexture.scale)})),i.setNormalMapInversions(!this._babylonScene.useRightHandedSystem,this._babylonScene.useRightHandedSystem));var s,l=1;return n.occlusionTexture&&(n.occlusionTexture.nonColorData=!0,a.push(this.loadTextureInfoAsync("".concat(e,"/occlusionTexture"),n.occlusionTexture,function(e){e.name="".concat(r.name," (Occlusion)"),o=e})),null!=n.occlusionTexture.strength&&(l=n.occlusionTexture.strength)),n.emissiveTexture&&a.push(this.loadTextureInfoAsync("".concat(e,"/emissiveTexture"),n.emissiveTexture,function(e){e.name="".concat(r.name," (Emissive)"),s=e})),Promise.all(a).then(function(){o&&(i.ambientOcclusionTexture=o,i.ambientOcclusionTextureStrength=l),s&&(i.emissionColorTexture=s)})},n.prototype.loadMaterialAlphaProperties=function(e,n,r){if(0===this._pbrMaterialImpls.size)throw new Error("".concat(e,": Material type not supported"));var o=this._getOrCreateMaterialAdapter(r),a=o.baseColorTexture;switch(n.alphaMode||"OPAQUE"){case"OPAQUE":r.transparencyMode=t.Material.MATERIAL_OPAQUE,r.alpha=1;break;case"MASK":r.transparencyMode=t.Material.MATERIAL_ALPHATEST,o.alphaCutOff=null==n.alphaCutoff?.5:n.alphaCutoff,a&&(a.hasAlpha=!0,o.useAlphaFromBaseColorTexture=!0);break;case"BLEND":r.transparencyMode=t.Material.MATERIAL_ALPHABLEND,a&&(a.hasAlpha=!0,o.useAlphaFromBaseColorTexture=!0);break;default:throw new Error("".concat(e,"/alphaMode: Invalid value (").concat(n.alphaMode,")"))}},n.prototype.loadTextureInfoAsync=function(e,t,r){var o=this;void 0===r&&(r=function(){});var a=this._extensionsLoadTextureInfoAsync(e,t,r);if(a)return a;if(this.logOpen("".concat(e)),t.texCoord>=6)throw new Error("".concat(e,"/texCoord: Invalid value (").concat(t.texCoord,")"));var i=He.Get("".concat(e,"/index"),this._gltf.textures,t.index);i._textureInfo=t;var s=this._loadTextureAsync("/textures/".concat(t.index),i,function(a){a.coordinatesIndex=t.texCoord||0,n.AddPointerMetadata(a,e),o._parent.onTextureLoadedObservable.notifyObservers(a),r(a)});return this.logClose(),s},n.prototype._loadTextureAsync=function(e,t,r){void 0===r&&(r=function(){});var o=this._extensionsLoadTextureAsync(e,t,r);if(o)return o;this.logOpen("".concat(e," ").concat(t.name||""));var a=null==t.sampler?n.DefaultSampler:He.Get("".concat(e,"/sampler"),this._gltf.samplers,t.sampler),i=He.Get("".concat(e,"/source"),this._gltf.images,t.source),s=this._createTextureAsync(e,a,i,r,void 0,!t._textureInfo.nonColorData);return this.logClose(),s},n.prototype._createTextureAsync=function(e,n,r,o,a,i){var s,l,u=this;void 0===o&&(o=function(){});var c=this._loadSampler("/samplers/".concat(n.index),n),f=new Array,h=new t.Deferred;this._babylonScene._blockEntityCollection=!!this._assetContainer;var d={noMipmap:c.noMipMaps,invertY:!1,samplingMode:c.samplingMode,onLoad:function(){u._disposed||h.resolve()},onError:function(t,n){u._disposed||h.reject(new Error("".concat(e,": ").concat(n&&n.message?n.message:t||"Failed to load texture")))},mimeType:null!==(s=r.mimeType)&&void 0!==s?s:t.GetMimeType(null!==(l=r.uri)&&void 0!==l?l:""),loaderOptions:a,useSRGBBuffer:!!i&&this._parent.useSRGBBuffers},p=new t.Texture(null,this._babylonScene,d);p._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,f.push(h.promise);var m=r.uri&&!t.IsBase64DataUrl(r.uri)?r.uri:void 0,_=null!=m?m:"".concat(this._fileName,"#image").concat(r.index);if(f.push(this.loadImageAsync("/images/".concat(r.index),r).then(function(e){var t="data:".concat(u._uniqueRootUrl).concat(_);p.updateURL(t,e);var n=p.getInternalTexture();n&&(n.label=r.name)})),p.wrapU=c.wrapU,p.wrapV=c.wrapV,o(p),this._parent.useGltfTextureNames){var g=r.name||m||"image".concat(r.index);p.name=g}return Promise.all(f).then(function(){return p})},n.prototype._loadSampler=function(e,t){return t._data||(t._data={noMipMaps:9728===t.minFilter||9729===t.minFilter,samplingMode:n._GetTextureSamplingMode(e,t),wrapU:n._GetTextureWrapMode("".concat(e,"/wrapS"),t.wrapS),wrapV:n._GetTextureWrapMode("".concat(e,"/wrapT"),t.wrapT)}),t._data},n.prototype.loadImageAsync=function(e,t){if(!t._data){if(this.logOpen("".concat(e," ").concat(t.name||"")),t.uri)t._data=this.loadUriAsync("".concat(e,"/uri"),t,t.uri);else{var n=He.Get("".concat(e,"/bufferView"),this._gltf.bufferViews,t.bufferView);t._data=this.loadBufferViewAsync("/bufferViews/".concat(n.index),n)}this.logClose()}return t._data},n.prototype.loadUriAsync=function(e,r,o){var a=this,i=this._extensionsLoadUriAsync(e,r,o);if(i)return i;if(!n._ValidateUri(o))throw new Error("".concat(e,": '").concat(o,"' is invalid"));if(t.IsBase64DataUrl(o)){var s=new Uint8Array(t.DecodeBase64UrlToBinary(o));return this.log("".concat(e,": Decoded ").concat(o.substring(0,64),"... (").concat(s.length," bytes)")),Promise.resolve(s)}return this.log("".concat(e,": Loading ").concat(o)),this._parent.preprocessUrlAsync(this._rootUrl+o).then(function(n){return new Promise(function(r,i){a._parent._loadFile(a._babylonScene,n,function(t){a._disposed||(a.log("".concat(e,": Loaded ").concat(o," (").concat(t.byteLength," bytes)")),r(new Uint8Array(t)))},!0,function(n){i(new t.LoadFileError("".concat(e,": Failed to load '").concat(o,"'").concat(n?": "+n.status+" "+n.statusText:""),n))})})})},n.AddPointerMetadata=function(e,t){e.metadata=e.metadata||{};var n=e._internalMetadata=e._internalMetadata||{},r=n.gltf=n.gltf||{};(r.pointers=r.pointers||[]).push(t)},n._GetTextureWrapMode=function(e,n){switch(n=null==n?10497:n){case 33071:return t.Texture.CLAMP_ADDRESSMODE;case 33648:return t.Texture.MIRROR_ADDRESSMODE;case 10497:return t.Texture.WRAP_ADDRESSMODE;default:return t.Logger.Warn("".concat(e,": Invalid value (").concat(n,")")),t.Texture.WRAP_ADDRESSMODE}},n._GetTextureSamplingMode=function(e,n){var r=null==n.magFilter?9729:n.magFilter,o=null==n.minFilter?9987:n.minFilter;if(9729===r)switch(o){case 9728:return t.Texture.LINEAR_NEAREST;case 9729:return t.Texture.LINEAR_LINEAR;case 9984:return t.Texture.LINEAR_NEAREST_MIPNEAREST;case 9985:return t.Texture.LINEAR_LINEAR_MIPNEAREST;case 9986:return t.Texture.LINEAR_NEAREST_MIPLINEAR;case 9987:return t.Texture.LINEAR_LINEAR_MIPLINEAR;default:return t.Logger.Warn("".concat(e,"/minFilter: Invalid value (").concat(o,")")),t.Texture.LINEAR_LINEAR_MIPLINEAR}else switch(9728!==r&&t.Logger.Warn("".concat(e,"/magFilter: Invalid value (").concat(r,")")),o){case 9728:return t.Texture.NEAREST_NEAREST;case 9729:return t.Texture.NEAREST_LINEAR;case 9984:return t.Texture.NEAREST_NEAREST_MIPNEAREST;case 9985:return t.Texture.NEAREST_LINEAR_MIPNEAREST;case 9986:return t.Texture.NEAREST_NEAREST_MIPLINEAR;case 9987:return t.Texture.NEAREST_LINEAR_MIPLINEAR;default:return t.Logger.Warn("".concat(e,"/minFilter: Invalid value (").concat(o,")")),t.Texture.NEAREST_NEAREST_MIPNEAREST}},n._GetTypedArrayConstructor=function(e,n){try{return t.GetTypedArrayConstructor(n)}catch(t){throw new Error("".concat(e,": ").concat(t.message),{cause:t})}},n._GetTypedArray=function(e,r,o,a,i){var s=o.buffer;a=o.byteOffset+(a||0);var l=n._GetTypedArrayConstructor("".concat(e,"/componentType"),r),u=t.VertexBufferGetTypeByteLength(r);return a%u!==0?(t.Logger.Warn("".concat(e,": Copying buffer as byte offset (").concat(a,") is not a multiple of component type byte length (").concat(u,")")),new l(s.slice(a,a+i*u),0)):new l(s,a,i)},n._GetNumComponents=function(e,t){switch(t){case"SCALAR":return 1;case"VEC2":return 2;case"VEC3":return 3;case"VEC4":case"MAT2":return 4;case"MAT3":return 9;case"MAT4":return 16}throw new Error("".concat(e,": Invalid type (").concat(t,")"))},n._ValidateUri=function(e){return t.Tools.IsBase64(e)||-1===e.indexOf("..")},n._GetDrawMode=function(e,n){switch(null==n&&(n=4),n){case 0:return t.Material.PointListDrawMode;case 1:return t.Material.LineListDrawMode;case 2:return t.Material.LineLoopDrawMode;case 3:return t.Material.LineStripDrawMode;case 4:return t.Material.TriangleFillMode;case 5:return t.Material.TriangleStripDrawMode;case 6:return t.Material.TriangleFanDrawMode}throw new Error("".concat(e,": Invalid mesh primitive mode (").concat(n,")"))},n.prototype._compileMaterialsAsync=function(){var e=this;this._parent._startPerformanceCounter("Compile materials");var t=new Array;if(this._gltf.materials)for(var n=0,r=this._gltf.materials;n<r.length;n++){var o=r[n];if(o._data)for(var a in o._data)for(var i=o._data[a],s=0,l=i.babylonMeshes;s<l.length;s++){var u=l[s];u.computeWorldMatrix(!0);var c=i.babylonMaterial;t.push(c.forceCompilationAsync(u)),t.push(c.forceCompilationAsync(u,{useInstances:!0})),this._parent.useClipPlane&&(t.push(c.forceCompilationAsync(u,{clipPlane:!0})),t.push(c.forceCompilationAsync(u,{clipPlane:!0,useInstances:!0})))}}return Promise.all(t).then(function(){e._parent._endPerformanceCounter("Compile materials")})},n.prototype._compileShadowGeneratorsAsync=function(){var e=this;this._parent._startPerformanceCounter("Compile shadow generators");for(var t=new Array,n=0,r=this._babylonScene.lights;n<r.length;n++){var o=r[n].getShadowGenerator();o&&t.push(o.forceCompilationAsync())}return Promise.all(t).then(function(){e._parent._endPerformanceCounter("Compile shadow generators")})},n.prototype._forEachExtensions=function(e){for(var t=0,n=this._extensions;t<n.length;t++){var r=n[t];r.enabled&&e(r)}},n.prototype._applyExtensions=function(e,t,n){for(var r=0,o=this._extensions;r<o.length;r++){var a=o[r];if(a.enabled){var i="".concat(a.name,".").concat(t),s=e;s._activeLoaderExtensionFunctions=s._activeLoaderExtensionFunctions||{};var l=s._activeLoaderExtensionFunctions;if(!l[i]){l[i]=!0;try{var u=n(a);if(u)return u}finally{delete l[i]}}}}return null},n.prototype._extensionsOnLoading=function(){this._forEachExtensions(function(e){return e.onLoading&&e.onLoading()})},n.prototype._extensionsOnReady=function(){this._forEachExtensions(function(e){return e.onReady&&e.onReady()})},n.prototype._extensionsLoadSceneAsync=function(e,t){return this._applyExtensions(t,"loadScene",function(n){return n.loadSceneAsync&&n.loadSceneAsync(e,t)})},n.prototype._extensionsLoadNodeAsync=function(e,t,n){return this._applyExtensions(t,"loadNode",function(r){return r.loadNodeAsync&&r.loadNodeAsync(e,t,n)})},n.prototype._extensionsLoadCameraAsync=function(e,t,n){return this._applyExtensions(t,"loadCamera",function(r){return r.loadCameraAsync&&r.loadCameraAsync(e,t,n)})},n.prototype._extensionsLoadVertexDataAsync=function(e,t,n){return this._applyExtensions(t,"loadVertexData",function(r){return r._loadVertexDataAsync&&r._loadVertexDataAsync(e,t,n)})},n.prototype._extensionsLoadMeshPrimitiveAsync=function(e,t,n,r,o,a){return this._applyExtensions(o,"loadMeshPrimitive",function(i){return i._loadMeshPrimitiveAsync&&i._loadMeshPrimitiveAsync(e,t,n,r,o,a)})},n.prototype._extensionsLoadMaterialAsync=function(e,t,n,r,o){return this._applyExtensions(t,"loadMaterial",function(a){return a._loadMaterialAsync&&a._loadMaterialAsync(e,t,n,r,o)})},n.prototype._extensionsCreateMaterial=function(e,t,n){return this._applyExtensions(t,"createMaterial",function(r){return r.createMaterial&&r.createMaterial(e,t,n)})},n.prototype._extensionsLoadMaterialPropertiesAsync=function(e,t,n){return this._applyExtensions(t,"loadMaterialProperties",function(r){return r.loadMaterialPropertiesAsync&&r.loadMaterialPropertiesAsync(e,t,n)})},n.prototype._extensionsLoadTextureInfoAsync=function(e,t,n){return this._applyExtensions(t,"loadTextureInfo",function(r){return r.loadTextureInfoAsync&&r.loadTextureInfoAsync(e,t,n)})},n.prototype._extensionsLoadTextureAsync=function(e,t,n){return this._applyExtensions(t,"loadTexture",function(r){return r._loadTextureAsync&&r._loadTextureAsync(e,t,n)})},n.prototype._extensionsLoadAnimationAsync=function(e,t){return this._applyExtensions(t,"loadAnimation",function(n){return n.loadAnimationAsync&&n.loadAnimationAsync(e,t)})},n.prototype._extensionsLoadAnimationChannelAsync=function(e,t,n,r,o){return this._applyExtensions(n,"loadAnimationChannel",function(a){return a._loadAnimationChannelAsync&&a._loadAnimationChannelAsync(e,t,n,r,o)})},n.prototype._extensionsLoadSkinAsync=function(e,t,n){return this._applyExtensions(n,"loadSkin",function(r){return r._loadSkinAsync&&r._loadSkinAsync(e,t,n)})},n.prototype._extensionsLoadUriAsync=function(e,t,n){return this._applyExtensions(t,"loadUri",function(r){return r._loadUriAsync&&r._loadUriAsync(e,t,n)})},n.prototype._extensionsLoadBufferViewAsync=function(e,t){return this._applyExtensions(t,"loadBufferView",function(n){return n.loadBufferViewAsync&&n.loadBufferViewAsync(e,t)})},n.prototype._extensionsLoadBufferAsync=function(e,t,n,r){return this._applyExtensions(t,"loadBuffer",function(o){return o.loadBufferAsync&&o.loadBufferAsync(e,t,n,r)})},n.LoadExtensionAsync=function(e,t,n,r){if(!t.extensions)return null;var o=t.extensions[n];return o?r("".concat(e,"/extensions/").concat(n),o):null},n.LoadExtraAsync=function(e,t,n,r){if(!t.extras)return null;var o=t.extras[n];return o?r("".concat(e,"/extras/").concat(n),o):null},n.prototype.isExtensionUsed=function(e){return!!this._gltf.extensionsUsed&&-1!==this._gltf.extensionsUsed.indexOf(e)},n.prototype.logOpen=function(e){this._parent._logOpen(e)},n.prototype.logClose=function(){this._parent._logClose()},n.prototype.log=function(e){this._parent._log(e)},n.prototype.startPerformanceCounter=function(e){this._parent._startPerformanceCounter(e)},n.prototype.endPerformanceCounter=function(e){this._parent._endPerformanceCounter(e)},n.DefaultSampler={index:-1},n}();k._CreateGLTF2Loader=function(e){return new je(e)};var Ue={__proto__:null,ArrayItem:He,GLTFFileLoader:k,GLTFLoader:je,LoadBoundingInfoFromPositionAccessor:Ke};function We(e,n,r,o){return t.Vector3.FromArray(n,r).scaleInPlace(o)}function ze(e,n,r,o){return t.Quaternion.FromArray(n,r).scaleInPlace(o)}function qe(e,t,n,r){for(var o=new Array(e._numMorphTargets),a=0;a<o.length;a++)o[a]=t[n++]*r;return o}var Ye=function(){function e(e,t,n,r){this.type=e,this.name=t,this.getValue=n,this.getStride=r}return e.prototype._buildAnimation=function(e,n,r){var o=new t.Animation(e,this.name,n,this.type);return o.setKeys(r,!0),o},e}(),Xe=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return m(t,e),t.prototype.buildAnimations=function(e,t,n,r){var o=[];return o.push({babylonAnimatable:e._babylonTransformNode,babylonAnimation:this._buildAnimation(t,n,r)}),o},t}(Ye),Je=function(e){function n(){return null!==e&&e.apply(this,arguments)||this}return m(n,e),n.prototype.buildAnimations=function(e,n,r,o){var a=[];if(e._numMorphTargets)for(var i=function(i){var l=new t.Animation("".concat(n,"_").concat(i),s.name,r,s.type);if(l.setKeys(o.map(function(e){return{frame:e.frame,inTangent:e.inTangent?e.inTangent[i]:void 0,value:e.value[i],outTangent:e.outTangent?e.outTangent[i]:void 0,interpolation:e.interpolation}}),!0),e._primitiveBabylonMeshes)for(var u=0,c=e._primitiveBabylonMeshes;u<c.length;u++){var f=c[u];if(f.morphTargetManager){var h=f.morphTargetManager.getTarget(i),d=l.clone();h.animations.push(d),a.push({babylonAnimatable:h,babylonAnimation:d})}}},s=this,l=0;l<e._numMorphTargets;l++)i(l);return a},n}(Ye);ke("/nodes/{}/translation",[new Xe(t.Animation.ANIMATIONTYPE_VECTOR3,"position",We,function(){return 3})]),ke("/nodes/{}/rotation",[new Xe(t.Animation.ANIMATIONTYPE_QUATERNION,"rotationQuaternion",ze,function(){return 4})]),ke("/nodes/{}/scale",[new Xe(t.Animation.ANIMATIONTYPE_VECTOR3,"scaling",We,function(){return 3})]),ke("/nodes/{}/weights",[new Je(t.Animation.ANIMATIONTYPE_FLOAT,"influence",qe,function(e){return e._numMorphTargets})]);var Qe={__proto__:null,AnimationPropertyInfo:Ye,TransformNodeAnimationPropertyInfo:Xe,WeightAnimationPropertyInfo:Je,getQuaternion:ze,getVector3:We,getWeights:qe},Ze=function(){function e(e){this._specWorkflow=!1,this._diffuseTransmissionTint=t.Color3.White(),this._diffuseTransmissionTintTexture=null,this._material=e}return Object.defineProperty(e.prototype,"material",{get:function(){return this._material},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isUnlit",{get:function(){return this._material.unlit},set:function(e){this._material.unlit=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"backFaceCulling",{get:function(){return this._material.backFaceCulling},set:function(e){this._material.backFaceCulling=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"twoSidedLighting",{get:function(){return this._material.twoSidedLighting},set:function(e){this._material.twoSidedLighting=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"alphaCutOff",{get:function(){return this._material.alphaCutOff},set:function(e){this._material.alphaCutOff=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"useAlphaFromBaseColorTexture",{get:function(){return this._material._useAlphaFromBaseColorTexture},set:function(e){this._material._useAlphaFromBaseColorTexture=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"transparencyAsAlphaCoverage",{get:function(){return!1},set:function(e){},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"baseColor",{get:function(){return this._material.baseColor},set:function(e){this._material.baseColor=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"baseColorTexture",{get:function(){return this._material.baseColorTexture},set:function(e){this._material.baseColorTexture=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"baseDiffuseRoughness",{get:function(){return this._material.baseDiffuseRoughness},set:function(e){this._material.baseDiffuseRoughness=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"baseDiffuseRoughnessTexture",{get:function(){return this._material.baseDiffuseRoughnessTexture},set:function(e){this._material.baseDiffuseRoughnessTexture=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"baseMetalness",{get:function(){return this._material.baseMetalness},set:function(e){this._material.baseMetalness=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"baseMetalnessTexture",{get:function(){return this._material.baseMetalnessTexture},set:function(e){this._material.baseMetalnessTexture=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"useRoughnessFromMetallicTextureGreen",{set:function(e){this._material._useRoughnessFromMetallicTextureGreen=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"useMetallicFromMetallicTextureBlue",{set:function(e){this._material._useMetallicFromMetallicTextureBlue=e},enumerable:!1,configurable:!0}),e.prototype.enableSpecularEdgeColor=function(e){void 0===e&&(e=!1)},e.prototype.configureSpecularGlossiness=function(){this._specWorkflow=!0},Object.defineProperty(e.prototype,"specularWeight",{get:function(){return this._material.specularWeight},set:function(e){this._material.specularWeight=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"specularWeightTexture",{get:function(){return this._material.specularWeightTexture},set:function(e){this._material.specularColorTexture===e?(this._material.specularWeightTexture=null,this._material._useSpecularWeightFromSpecularColorTexture=!0,this._material._useSpecularWeightFromAlpha=!0):this._material.specularWeightTexture=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"specularColor",{get:function(){return this._material.specularColor},set:function(e){this._material.specularColor=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"specularColorTexture",{get:function(){return this._material.specularColorTexture},set:function(e){this._material.specularColorTexture=e,this._material.specularWeightTexture===this._material.specularColorTexture&&(this._material.specularWeightTexture=null,this._material._useSpecularWeightFromSpecularColorTexture=!0,this._material._useSpecularWeightFromAlpha=!0)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"specularRoughness",{get:function(){return this._material.specularRoughness},set:function(e){this._material.specularRoughness=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"specularRoughnessTexture",{get:function(){return this._material.specularRoughnessTexture},set:function(e){this._material.specularRoughnessTexture=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"specularIor",{get:function(){return this._material.specularIor},set:function(e){this._material.specularIor=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"glossiness",{get:function(){return 1-this._material.specularRoughness},set:function(e){this._material.specularRoughness=Math.max(1-e,0)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"emissionColor",{get:function(){return this._material.emissionColor},set:function(e){this._material.emissionColor=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"emissionLuminance",{get:function(){return this._material.emissionLuminance},set:function(e){this._material.emissionLuminance=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"emissionColorTexture",{get:function(){return this._material.emissionColorTexture},set:function(e){this._material.emissionColorTexture=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"ambientOcclusionTexture",{get:function(){return this._material.ambientOcclusionTexture},set:function(e){this._material.ambientOcclusionTexture=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"ambientOcclusionTextureStrength",{get:function(){var e,t=this._material.ambientOcclusionTexture;return null!==(e=null==t?void 0:t.level)&&void 0!==e?e:1},set:function(e){var t=this._material.ambientOcclusionTexture;t&&(t.level=e)},enumerable:!1,configurable:!0}),e.prototype.configureCoat=function(){},Object.defineProperty(e.prototype,"coatWeight",{get:function(){return this._material.coatWeight},set:function(e){this._material.coatWeight=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"coatWeightTexture",{get:function(){return this._material.coatWeightTexture},set:function(e){this._material.coatWeightTexture=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"coatColor",{get:function(){return this._material.coatColor},set:function(e){this._material.coatColor=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"coatColorTexture",{set:function(e){this._material.coatColorTexture=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"coatRoughness",{get:function(){return this._material.coatRoughness},set:function(e){this._material.coatRoughness=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"coatRoughnessTexture",{get:function(){return this._material.coatRoughnessTexture},set:function(e){this._material.coatRoughnessTexture=e,e&&(this._material._useCoatRoughnessFromGreenChannel=!0)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"coatIor",{get:function(){return this._material.coatIor},set:function(e){this._material.coatIor=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"coatDarkening",{get:function(){return this._material.coatDarkening},set:function(e){this._material.coatDarkening=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"coatDarkeningTexture",{set:function(e){this._material.coatDarkeningTexture=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"coatRoughnessAnisotropy",{get:function(){return this._material.coatRoughnessAnisotropy},set:function(e){this._material.coatRoughnessAnisotropy=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"geometryCoatTangentAngle",{set:function(e){this._material.geometryCoatTangentAngle=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"geometryCoatTangentTexture",{get:function(){return this._material.geometryCoatTangentTexture},set:function(e){this._material.geometryCoatTangentTexture=e,e&&(this._material._useCoatRoughnessAnisotropyFromTangentTexture=!0)},enumerable:!1,configurable:!0}),e.prototype.configureTransmission=function(){this._material.geometryThinWalled=1,this._material.transmissionDepth=0},Object.defineProperty(e.prototype,"transmissionWeight",{get:function(){return this._material.transmissionWeight},set:function(e){this._material.transmissionWeight=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"transmissionWeightTexture",{get:function(){return this._material.transmissionWeightTexture},set:function(e){this._material.transmissionWeightTexture=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"transmissionScatter",{get:function(){return this._material.transmissionScatter},set:function(e){this._material.transmissionScatter=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"transmissionScatterTexture",{get:function(){return this._material.transmissionScatterTexture},set:function(e){this._material.transmissionScatterTexture=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"transmissionScatterAnisotropy",{set:function(e){this._material.transmissionScatterAnisotropy=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"transmissionDispersionAbbeNumber",{set:function(e){this._material.transmissionDispersionAbbeNumber=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"transmissionDispersionScale",{set:function(e){this._material.transmissionDispersionScale=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"transmissionDepth",{get:function(){return this._material.transmissionDepth},set:function(e){e!==Number.MAX_VALUE||0!==this._material.transmissionDepth?this._material.transmissionDepth=e:this._material.transmissionDepth=0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"transmissionColor",{get:function(){return this._material.transmissionColor},set:function(e){e.equals(t.Color3.White())||(this._material.transmissionColor=e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"refractionBackgroundTexture",{get:function(){return this._material.backgroundRefractionTexture},set:function(e){this._material.backgroundRefractionTexture=e},enumerable:!1,configurable:!0}),e.prototype.configureVolume=function(){this._material.geometryThinWalled=0},Object.defineProperty(e.prototype,"geometryThinWalled",{get:function(){return!!this._material.geometryThinWalled},set:function(e){this._material.geometryThinWalled=e?1:0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"volumeThicknessTexture",{set:function(e){this._material.geometryThicknessTexture=e,this._material._useGeometryThicknessFromGreenChannel=!0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"volumeThickness",{set:function(e){this._material.geometryThickness=e},enumerable:!1,configurable:!0}),e.prototype.configureSubsurface=function(){this._material.geometryThinWalled=1,this._material.subsurfaceScatterAnisotropy=1},Object.defineProperty(e.prototype,"subsurfaceWeight",{get:function(){return this._material.subsurfaceWeight},set:function(e){this._material.subsurfaceWeight=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"subsurfaceWeightTexture",{get:function(){return this._material.subsurfaceWeightTexture},set:function(e){this._material.subsurfaceWeightTexture=e,this._material._useSubsurfaceWeightFromTextureAlpha=!0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"subsurfaceColor",{set:function(e){this._material.subsurfaceColor=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"subsurfaceColorTexture",{set:function(e){this._material.subsurfaceColorTexture=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"diffuseTransmissionTint",{get:function(){return this._diffuseTransmissionTint},set:function(e){this._diffuseTransmissionTint=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"diffuseTransmissionTintTexture",{set:function(e){this._diffuseTransmissionTintTexture=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"subsurfaceRadius",{get:function(){return this._material.subsurfaceRadius},set:function(e){this._material.subsurfaceRadius=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"subsurfaceRadiusScale",{get:function(){return this._material.subsurfaceRadiusScale},set:function(e){this._material.subsurfaceRadiusScale=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"subsurfaceScatterAnisotropy",{set:function(e){this._material.subsurfaceScatterAnisotropy=e},enumerable:!1,configurable:!0}),e.prototype.isTranslucent=function(){return this.transmissionWeight>0||this.subsurfaceWeight>0},e.prototype.configureFuzz=function(){},Object.defineProperty(e.prototype,"fuzzWeight",{set:function(e){this._material.fuzzWeight=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"fuzzWeightTexture",{set:function(e){this._material.fuzzWeightTexture=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"fuzzColor",{set:function(e){this._material.fuzzColor=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"fuzzColorTexture",{set:function(e){this._material.fuzzColorTexture=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"fuzzRoughness",{set:function(e){this._material.fuzzRoughness=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"fuzzRoughnessTexture",{set:function(e){this._material.fuzzRoughnessTexture=e,this._material._useFuzzRoughnessFromTextureAlpha=!0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"specularRoughnessAnisotropy",{get:function(){return this._material.specularRoughnessAnisotropy},set:function(e){this._material.specularRoughnessAnisotropy=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"geometryTangentAngle",{set:function(e){this._material.geometryTangentAngle=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"geometryTangentTexture",{get:function(){return this._material.geometryTangentTexture},set:function(e){this._material.geometryTangentTexture=e,this._material._useSpecularRoughnessAnisotropyFromTangentTexture=!0},enumerable:!1,configurable:!0}),e.prototype.configureGltfStyleAnisotropy=function(e){void 0===e&&(e=!0),this._material._useGltfStyleAnisotropy=e},Object.defineProperty(e.prototype,"thinFilmWeight",{set:function(e){this._material.thinFilmWeight=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"thinFilmIor",{set:function(e){this._material.thinFilmIor=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"thinFilmThicknessMinimum",{set:function(e){this._material.thinFilmThicknessMin=e/1e3},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"thinFilmThicknessMaximum",{set:function(e){this._material.thinFilmThickness=e/1e3},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"thinFilmWeightTexture",{set:function(e){this._material.thinFilmWeightTexture=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"thinFilmThicknessTexture",{set:function(e){this._material.thinFilmThicknessTexture=e,this._material._useThinFilmThicknessFromTextureGreen=!0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"unlit",{set:function(e){this._material.unlit=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"geometryOpacity",{get:function(){return this._material.geometryOpacity},set:function(e){this._material.geometryOpacity=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"geometryNormalTexture",{get:function(){return this._material.geometryNormalTexture},set:function(e){this._material.geometryNormalTexture=e},enumerable:!1,configurable:!0}),e.prototype.setNormalMapInversions=function(e,t){},Object.defineProperty(e.prototype,"geometryCoatNormalTexture",{get:function(){return this._material.geometryCoatNormalTexture},set:function(e){this._material.geometryCoatNormalTexture=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"geometryCoatNormalTextureScale",{set:function(e){this._material.geometryCoatNormalTexture&&(this._material.geometryCoatNormalTexture.level=e)},enumerable:!1,configurable:!0}),e.prototype.finalizeAsync=function(e){return g(this,void 0,void 0,function(){var n,r,o,a,i,s,l,u,c,f;return b(this,function(h){switch(h.label){case 0:return this._diffuseTransmissionTint&&!this._diffuseTransmissionTint.equals(t.Color3.White())||this._diffuseTransmissionTintTexture?this._material.geometryThinWalled?(this.subsurfaceColor=this._diffuseTransmissionTint,this.subsurfaceColorTexture=this._diffuseTransmissionTintTexture,[3,3]):[3,1]:[3,3];case 1:return[4,this.copySurfaceToCoatAsync(e,this.subsurfaceWeight,this.subsurfaceWeightTexture,t.TextureChannel.A,this._diffuseTransmissionTint,this._diffuseTransmissionTintTexture,!0)];case 2:if(h.sent(),e._disposed)return[2];h.label=3;case 3:return this.transmissionWeight>0?this._material.geometryThinWalled||0===this._material.transmissionDepth?(this._material.transmissionColor=this._material.baseColor,this._material.transmissionColorTexture=this._material.baseColorTexture,[3,6]):[3,4]:[3,6];case 4:return this.baseColor.equals(t.Color3.White())&&null===this.baseColorTexture?[3,6]:[4,this.copySurfaceToCoatAsync(e,this.transmissionWeight,this.transmissionWeightTexture,t.TextureChannel.R,this.baseColor,this.baseColorTexture,!1)];case 5:if(h.sent(),e._disposed)return[2];h.label=6;case 6:return this._specWorkflow?(r=t.InvertTextureAsync,o=["newRoughnessTexture ("+this._material.name+")"],[4,t.ExtractChannelAsync("glossiness ("+this._material.name+")",t.CreateTextureWithFactorOperand(this.specularColorTexture,new t.Color4(this.specularColor.r,this.specularColor.g,this.specularColor.b,this.glossiness),t.TextureChannel.A,t.TextureColorSpace.Linear),t.TextureChannel.A,this._material.getScene(),t.TextureColorSpace.Linear,t.ChannelMask.R)]):[3,11];case 7:return[4,r.apply(void 0,o.concat([h.sent(),this._material.getScene(),t.ChannelMask.R,t.TextureColorSpace.Linear,t.ChannelMask.R]))];case 8:return n=h.sent(),e._disposed?(null===(u=n.texture)||void 0===u||u.dispose(),[2]):(this.specularRoughnessTexture=n.texture,this.specularRoughness=n.factor?n.factor.r:1,[4,t.ExtractMaxChannelAsync("metallicTexture ("+this._material.name+")",t.CreateTextureWithFactorOperand(this.specularColorTexture,this.specularColor.toColor4(),t.TextureChannel.RGBA,t.TextureColorSpace.Linear),this._material.getScene(),!1,t.TextureColorSpace.SRGB,t.ChannelMask.RGB)]);case 9:return a=h.sent(),e._disposed?(null===(c=a.texture)||void 0===c||c.dispose(),[2]):(this.baseMetalnessTexture=a.texture,this.baseMetalness=a.factor?a.factor.r:1,[4,t.LerpTexturesAsync("newBaseColor ("+this._material.name+")",t.CreateTextureWithFactorOperand(this.baseColorTexture,this.baseColor.toColor4(),t.TextureChannel.RGBA,t.TextureColorSpace.Linear),t.CreateTextureWithFactorOperand(this.specularColorTexture,this.specularColor.toColor4(),t.TextureChannel.RGBA,t.TextureColorSpace.Linear),_(_({},a),{dispose:void 0,colorSpace:t.TextureColorSpace.Linear}),this._material.getScene(),t.TextureColorSpace.SRGB,t.ChannelMask.RGB)]);case 10:if(i=h.sent(),e._disposed)return null===(f=i.texture)||void 0===f||f.dispose(),[2];null==(s=this.baseColorTexture)||s.dispose(),this.baseColorTexture=i.texture,this.baseColor=i.factor?new t.Color3(i.factor.r,i.factor.g,i.factor.b):t.Color3.White(),null==(l=this.specularColorTexture)||l.dispose(),this.specularColorTexture=null,h.label=11;case 11:return[2]}})})},e.prototype.copySurfaceToCoatAsync=function(e,n,r,o,a,i){return g(this,arguments,void 0,function(e,n,r,o,a,i,s){var l,u,c,f,h,d,p,m,_,g,y,v,T,x,A,w,O,C,M,E,R,F,L,P,S,N,I,B,k,G;return void 0===s&&(s=!1),b(this,function(b){switch(b.label){case 0:return l=this._material.coatWeight,u=this._material.coatWeightTexture,c=this._material.coatColor.clone(),f=this._material.coatColorTexture,h=this._material.geometryCoatNormalTexture,d=new t.Color4(l,l,l,l),p=new t.Color4(n,n,n,n),this.coatWeightTexture=null,this.coatWeight=1,[4,Promise.allSettled([t.LerpTexturesAsync("lerpExistingCoat",t.CreateTextureWithFactorOperand(null,new t.Color4(1,1,1,1)),t.CreateTextureWithFactorOperand(f,c.toColor4(),t.TextureChannel.RGBA,t.TextureColorSpace.SRGB),t.CreateTextureWithFactorOperand(u,d,t.TextureChannel.R),this._material.getScene(),t.TextureColorSpace.SRGB),t.LerpTexturesAsync("lerpSurfaceColor",t.CreateTextureWithFactorOperand(null,new t.Color4(1,1,1,1)),t.CreateTextureWithFactorOperand(i,a.toColor4(),t.TextureChannel.RGBA,t.TextureColorSpace.SRGB),t.CreateTextureWithFactorOperand(r,p,o),this._material.getScene(),t.TextureColorSpace.SRGB)])];case 1:if(m=b.sent(),_=m.find(function(e){return"rejected"===e.status}),_){for(g=0,y=m;g<y.length;g++)"fulfilled"===(v=y[g]).status&&(null===(F=v.value.texture)||void 0===F||F.dispose());throw _.reason}return T=m.map(function(e){return e.value}),x=T[0],A=T[1],e._disposed?(null===(L=x.texture)||void 0===L||L.dispose(),null===(P=A.texture)||void 0===P||P.dispose(),[2]):[4,t.MultiplyTexturesAsync("newCoatColor ("+this._material.name+")",x,A,this._material.getScene(),t.TextureColorSpace.SRGB)];case 2:return w=b.sent(),e._disposed?(null===(S=w.texture)||void 0===S||S.dispose(),[2]):(w.texture?(this.coatColorTexture=w.texture,this.coatColor=t.Color3.White()):w.factor&&(this.coatColorTexture=null,this.coatColor.fromArray([w.factor.r,w.factor.g,w.factor.b])),[4,t.LerpTexturesAsync("newCoatIor ("+this._material.name+")",t.CreateTextureWithFactorOperand(null,new t.Color4(this._material.specularIor,this._material.specularIor,this._material.specularIor,1),t.TextureChannel.R),t.CreateTextureWithFactorOperand(null,new t.Color4(this.coatIor,this.coatIor,this.coatIor,1),t.TextureChannel.R),t.CreateTextureWithFactorOperand(u,d,t.TextureChannel.R),this._material.getScene())]);case 3:return O=b.sent(),e._disposed?(null===(N=O.texture)||void 0===N||N.dispose(),[2]):(this.coatIor=O.factor?O.factor.r:this.coatIor,[4,t.LerpTexturesAsync("newCoatRoughness ("+this._material.name+")",t.CreateTextureWithFactorOperand(this.specularRoughnessTexture,new t.Color4(this.specularRoughness,this.specularRoughness,this.specularRoughness,1),t.TextureChannel.G),t.CreateTextureWithFactorOperand(this.coatRoughnessTexture,new t.Color4(this.coatRoughness,this.coatRoughness,this.coatRoughness,1),t.TextureChannel.G),t.CreateTextureWithFactorOperand(u,d,t.TextureChannel.R),this._material.getScene())]);case 4:return C=b.sent(),e._disposed?(null===(I=C.texture)||void 0===I||I.dispose(),[2]):(this.coatRoughness=C.factor?C.factor.r:1,this.coatRoughnessTexture=C.texture,[4,t.LerpTexturesAsync("newCoatDarkening ("+this._material.name+")",t.CreateTextureWithFactorOperand(null,new t.Color4(0,0,0,1),t.TextureChannel.R),t.CreateTextureWithFactorOperand(null,new t.Color4(this.coatDarkening,this.coatDarkening,this.coatDarkening,1),t.TextureChannel.R),t.CreateTextureWithFactorOperand(u,d,t.TextureChannel.R),this._material.getScene())]);case 5:return M=b.sent(),e._disposed?(null===(B=M.texture)||void 0===B||B.dispose(),[2]):(this.coatDarkening=M.factor?M.factor.r:this.coatDarkening,s?[4,t.LerpTexturesAsync("newSpecularRoughness ("+this._material.name+")",t.CreateTextureWithFactorOperand(this.specularRoughnessTexture,new t.Color4(this._material.specularRoughness,this._material.specularRoughness,this._material.specularRoughness,1),t.TextureChannel.G),t.CreateTextureWithFactorOperand(null,new t.Color4(1,1,1,1),t.TextureChannel.R),t.CreateTextureWithFactorOperand(r,p,o),this._material.getScene())]:[3,7]);case 6:if(E=b.sent(),e._disposed)return null===(k=E.texture)||void 0===k||k.dispose(),[2];this.specularRoughness=E.factor?E.factor.r:1,this.specularRoughnessTexture=E.texture,b.label=7;case 7:return h||this.geometryNormalTexture?[4,t.LerpTexturesAsync("newCoatNormal ("+this._material.name+")",t.CreateTextureWithFactorOperand(this.geometryNormalTexture,this.geometryNormalTexture?new t.Color4(1,1,1,1):new t.Color4(.5,.5,1,1),t.TextureChannel.RGBA),t.CreateTextureWithFactorOperand(h,h?new t.Color4(1,1,1,1):new t.Color4(.5,.5,1,1),t.TextureChannel.RGBA),t.CreateTextureWithFactorOperand(u,d,t.TextureChannel.R),this._material.getScene())]:[3,9];case 8:if(R=b.sent(),e._disposed)return null===(G=R.texture)||void 0===G||G.dispose(),[2];R.texture&&(this.geometryCoatNormalTexture=R.texture),b.label=9;case 9:return[2]}})})},e}(),$e={__proto__:null,OpenPBRMaterialLoadingAdapter:Ze},et=function(){function e(e){this._specWorkflow=!1,this._material=e,this._material.enableSpecularAntiAliasing=!0}return Object.defineProperty(e.prototype,"material",{get:function(){return this._material},enumerable:!1,configurable:!0}),e.prototype.finalizeAsync=function(e){return g(this,void 0,void 0,function(){return b(this,function(e){return[2]})})},Object.defineProperty(e.prototype,"isUnlit",{get:function(){return this._material.unlit},set:function(e){this._material.unlit=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"backFaceCulling",{get:function(){return this._material.backFaceCulling},set:function(e){this._material.backFaceCulling=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"twoSidedLighting",{get:function(){return this._material.twoSidedLighting},set:function(e){this._material.twoSidedLighting=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"alphaCutOff",{get:function(){return this._material.alphaCutOff},set:function(e){this._material.alphaCutOff=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"useAlphaFromBaseColorTexture",{get:function(){return this._material.useAlphaFromAlbedoTexture},set:function(e){this._material.useAlphaFromAlbedoTexture=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"transparencyAsAlphaCoverage",{get:function(){return this._material.useRadianceOverAlpha||this._material.useSpecularOverAlpha},set:function(e){this._material.useRadianceOverAlpha=!e,this._material.useSpecularOverAlpha=!e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"baseColor",{get:function(){return this._material.albedoColor},set:function(e){this._material.albedoColor=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"baseColorTexture",{get:function(){return this._material.albedoTexture},set:function(e){this._material.albedoTexture=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"baseDiffuseRoughness",{get:function(){var e;return null!==(e=this._material.baseDiffuseRoughness)&&void 0!==e?e:0},set:function(e){this._material.baseDiffuseRoughness=e,e>0&&(this._material.brdf.baseDiffuseModel=t.Constants.MATERIAL_DIFFUSE_MODEL_E_OREN_NAYAR)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"baseDiffuseRoughnessTexture",{get:function(){return this._material.baseDiffuseRoughnessTexture},set:function(e){this._material.baseDiffuseRoughnessTexture=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"baseMetalness",{get:function(){var e;return null!==(e=this._material.metallic)&&void 0!==e?e:1},set:function(e){this._material.metallic=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"baseMetalnessTexture",{get:function(){return this._material.metallicTexture},set:function(e){this._material.metallicTexture=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"useRoughnessFromMetallicTextureGreen",{set:function(e){this._material.useRoughnessFromMetallicTextureGreen=e,this._material.useRoughnessFromMetallicTextureAlpha=!e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"useMetallicFromMetallicTextureBlue",{set:function(e){this._material.useMetallnessFromMetallicTextureBlue=e},enumerable:!1,configurable:!0}),e.prototype.enableSpecularEdgeColor=function(e){void 0===e&&(e=!1),e&&(this._material.brdf.dielectricSpecularModel=t.Constants.MATERIAL_DIELECTRIC_SPECULAR_MODEL_OPENPBR,this._material.brdf.conductorSpecularModel=t.Constants.MATERIAL_CONDUCTOR_SPECULAR_MODEL_OPENPBR)},e.prototype.configureSpecularGlossiness=function(){this._specWorkflow=!0,this._material.metallic=null,this._material.roughness=null,this._material.useMicroSurfaceFromReflectivityMapAlpha=!0},Object.defineProperty(e.prototype,"specularWeight",{get:function(){var e;return null!==(e=this._material.metallicF0Factor)&&void 0!==e?e:1},set:function(e){this._material.metallicF0Factor=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"specularWeightTexture",{get:function(){return this._material.metallicReflectanceTexture},set:function(e){e?(this._material.metallicReflectanceTexture=e,this._material.useOnlyMetallicFromMetallicReflectanceTexture=!0):(this._material.metallicReflectanceTexture=null,this._material.useOnlyMetallicFromMetallicReflectanceTexture=!1)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"specularColor",{get:function(){return this._specWorkflow?this._material.reflectivityColor:this._material.metallicReflectanceColor},set:function(e){this._specWorkflow?this._material.reflectivityColor=e:this._material.metallicReflectanceColor=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"specularColorTexture",{get:function(){return this._specWorkflow?this._material.reflectivityTexture:this._material.reflectanceTexture},set:function(e){this._specWorkflow?(this._material.reflectivityTexture=e,this._material.reflectivityTexture&&(this._material.reflectivityTexture.hasAlpha=!0)):this._material.reflectanceTexture=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"specularRoughness",{get:function(){var e;return null!==(e=this._material.roughness)&&void 0!==e?e:1},set:function(e){this._material.roughness=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"specularRoughnessTexture",{get:function(){return this._material.metallicTexture},set:function(e){this.baseMetalnessTexture||(this._material.metallicTexture=e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"specularIor",{get:function(){return this._material.indexOfRefraction},set:function(e){this._material.indexOfRefraction=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"glossiness",{get:function(){var e;return null!==(e=this._material.microSurface)&&void 0!==e?e:1},set:function(e){this._material.microSurface=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"emissionColor",{get:function(){return this._material.emissiveColor},set:function(e){this._material.emissiveColor=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"emissionLuminance",{get:function(){return this._material.emissiveIntensity},set:function(e){this._material.emissiveIntensity=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"emissionColorTexture",{get:function(){return this._material.emissiveTexture},set:function(e){this._material.emissiveTexture=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"ambientOcclusionTexture",{get:function(){return this._material.ambientTexture},set:function(e){this._material.ambientTexture=e,e&&(this._material.useAmbientInGrayScale=!0)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"ambientOcclusionTextureStrength",{get:function(){var e;return null!==(e=this._material.ambientTextureStrength)&&void 0!==e?e:1},set:function(e){this._material.ambientTextureStrength=e},enumerable:!1,configurable:!0}),e.prototype.configureCoat=function(){this._material.clearCoat.isEnabled=!0,this._material.clearCoat.useRoughnessFromMainTexture=!1,this._material.clearCoat.remapF0OnInterfaceChange=!1},Object.defineProperty(e.prototype,"coatWeight",{get:function(){return this._material.clearCoat.intensity},set:function(e){this._material.clearCoat.isEnabled=!0,this._material.clearCoat.intensity=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"coatWeightTexture",{get:function(){return this._material.clearCoat.texture},set:function(e){this._material.clearCoat.isEnabled=!0,this._material.clearCoat.texture=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"coatColor",{set:function(e){this._material.clearCoat.isTintEnabled=e!=t.Color3.White(),this._material.clearCoat.tintColor=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"coatColorTexture",{set:function(e){this._material.clearCoat.tintTexture=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"coatRoughness",{get:function(){var e;return null!==(e=this._material.clearCoat.roughness)&&void 0!==e?e:0},set:function(e){this._material.clearCoat.isEnabled=!0,this._material.clearCoat.roughness=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"coatRoughnessTexture",{get:function(){return this._material.clearCoat.textureRoughness},set:function(e){this._material.clearCoat.isEnabled=!0,this._material.clearCoat.useRoughnessFromMainTexture=!1,this._material.clearCoat.textureRoughness=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"coatIor",{set:function(e){this._material.clearCoat.indexOfRefraction=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"coatDarkening",{set:function(e){},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"coatDarkeningTexture",{set:function(e){},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"coatRoughnessAnisotropy",{get:function(){return 0},set:function(e){},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"geometryCoatTangentAngle",{set:function(e){},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"geometryCoatTangentTexture",{get:function(){return null},set:function(e){},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"transmissionWeight",{get:function(){return this._material.subSurface.isRefractionEnabled?this._material.subSurface.refractionIntensity:0},set:function(e){this._material.subSurface.isRefractionEnabled=e>0,this._material.subSurface.refractionIntensity=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"transmissionWeightTexture",{set:function(e){this._material.subSurface.isRefractionEnabled=!0,this._material.subSurface.refractionIntensityTexture=e,this._material.subSurface.useGltfStyleTextures=!0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"transmissionDepth",{get:function(){return this.transmissionWeight>0?this._material.subSurface.tintColorAtDistance:0},set:function(e){this.transmissionWeight>0?this._material.subSurface.tintColorAtDistance=e:this.subsurfaceWeight>0&&this._material.subSurface.diffusionDistance.multiplyInPlace(new t.Color3(e,e,e))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"transmissionColor",{get:function(){return this.transmissionWeight>0?this._material.subSurface.tintColor:this.subsurfaceWeight>0?this._material.subSurface.diffusionDistance:new t.Color3(0,0,0)},set:function(e){this.transmissionWeight>0?this._material.subSurface.tintColor=e:this.subsurfaceWeight>0&&this._material.subSurface.diffusionDistance.multiplyInPlace(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"transmissionScatter",{get:function(){return this._material.subSurface.diffusionDistance},set:function(e){this._material.subSurface.diffusionDistance=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"transmissionScatterTexture",{set:function(e){},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"transmissionScatterAnisotropy",{set:function(e){},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"transmissionDispersionAbbeNumber",{set:function(e){},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"transmissionDispersionScale",{set:function(e){e>0?(this._material.subSurface.isDispersionEnabled=!0,this._material.subSurface.dispersion=20/e):(this._material.subSurface.isDispersionEnabled=!1,this._material.subSurface.dispersion=0)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"refractionBackgroundTexture",{get:function(){return this._material.subSurface.refractionTexture},set:function(e){this._material.subSurface.refractionTexture=e},enumerable:!1,configurable:!0}),e.prototype.configureTransmission=function(){this._material.subSurface.volumeIndexOfRefraction=1,this._material.subSurface.useAlbedoToTintRefraction=!0,this._material.subSurface.minimumThickness=0,this._material.subSurface.maximumThickness=0},e.prototype.configureVolume=function(){},Object.defineProperty(e.prototype,"geometryThinWalled",{get:function(){return 0===this._material.subSurface.maximumThickness},set:function(e){},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"volumeThicknessTexture",{set:function(e){this._material.subSurface.thicknessTexture=e,this._material.subSurface.useGltfStyleTextures=!0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"volumeThickness",{set:function(e){this._material.subSurface.minimumThickness=0,this._material.subSurface.maximumThickness=e,this._material.subSurface.useThicknessAsDepth=!0,e>0&&(this._material.subSurface.volumeIndexOfRefraction=this._material.indexOfRefraction)},enumerable:!1,configurable:!0}),e.prototype.configureSubsurface=function(){this._material.subSurface.useGltfStyleTextures=!0,this._material.subSurface.volumeIndexOfRefraction=1,this._material.subSurface.minimumThickness=0,this._material.subSurface.maximumThickness=0,this._material.subSurface.useAlbedoToTintTranslucency=!1},Object.defineProperty(e.prototype,"subsurfaceWeight",{get:function(){return this._material.subSurface.isTranslucencyEnabled?this._material.subSurface.translucencyIntensity:0},set:function(e){this._material.subSurface.isTranslucencyEnabled=e>0,this._material.subSurface.translucencyIntensity=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"subsurfaceWeightTexture",{set:function(e){this._material.subSurface.translucencyIntensityTexture=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"subsurfaceColor",{set:function(e){var n=new t.Vector3(-Math.log(this.transmissionColor.r),-Math.log(this.transmissionColor.g),-Math.log(this.transmissionColor.b));n.scaleInPlace(1/Math.max(this.transmissionDepth,.001));var r=n,o=Math.max(r.x,Math.max(r.y,r.z)),a=o>0?1/o:1;this._material.subSurface.diffusionDistance=new t.Color3(Math.exp(-r.x*a),Math.exp(-r.y*a),Math.exp(-r.z*a))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"subsurfaceColorTexture",{set:function(e){},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"diffuseTransmissionTint",{get:function(){return this._material.subSurface.tintColor},set:function(e){this._material.subSurface.tintColor=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"diffuseTransmissionTintTexture",{set:function(e){this._material.subSurface.translucencyColorTexture=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"subsurfaceRadius",{get:function(){return 1},set:function(e){},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"subsurfaceRadiusScale",{get:function(){var e;return null!==(e=this._material.subSurface.scatteringDiffusionProfile)&&void 0!==e?e:t.Color3.White()},set:function(e){this._material.subSurface.scatteringDiffusionProfile=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"subsurfaceScatterAnisotropy",{set:function(e){},enumerable:!1,configurable:!0}),e.prototype.isTranslucent=function(){return this.transmissionWeight>0||this.subsurfaceWeight>0},e.prototype.configureFuzz=function(){this._material.sheen.isEnabled=!0,this._material.sheen.useRoughnessFromMainTexture=!1,this._material.sheen.albedoScaling=!0},Object.defineProperty(e.prototype,"fuzzWeight",{set:function(e){this._material.sheen.isEnabled=!0,this._material.sheen.intensity=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"fuzzWeightTexture",{set:function(e){this._material.sheen.texture||(this._material.sheen.texture=e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"fuzzColor",{set:function(e){this._material.sheen.isEnabled=!0,this._material.sheen.color=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"fuzzColorTexture",{set:function(e){this._material.sheen.texture=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"fuzzRoughness",{set:function(e){this._material.sheen.isEnabled=!0,this._material.sheen.roughness=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"fuzzRoughnessTexture",{set:function(e){this._material.sheen.isEnabled=!0,this._material.sheen.textureRoughness=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"specularRoughnessAnisotropy",{get:function(){return this._material.anisotropy.intensity},set:function(e){this._material.anisotropy.isEnabled=!0,this._material.anisotropy.intensity=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"geometryTangentAngle",{set:function(e){this._material.anisotropy.isEnabled=!0,this._material.anisotropy.angle=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"geometryTangentTexture",{get:function(){return this._material.anisotropy.texture},set:function(e){this._material.anisotropy.isEnabled=!0,this._material.anisotropy.texture=e},enumerable:!1,configurable:!0}),e.prototype.configureGltfStyleAnisotropy=function(e){void 0===e&&(e=!0)},Object.defineProperty(e.prototype,"thinFilmWeight",{set:function(e){this._material.iridescence.isEnabled=e>0,this._material.iridescence.intensity=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"thinFilmIor",{set:function(e){this._material.iridescence.indexOfRefraction=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"thinFilmThicknessMinimum",{set:function(e){this._material.iridescence.minimumThickness=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"thinFilmThicknessMaximum",{set:function(e){this._material.iridescence.maximumThickness=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"thinFilmWeightTexture",{set:function(e){this._material.iridescence.texture=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"thinFilmThicknessTexture",{set:function(e){this._material.iridescence.thicknessTexture=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"unlit",{set:function(e){this._material.unlit=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"geometryOpacity",{get:function(){return this._material.alpha},set:function(e){this._material.alpha=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"geometryNormalTexture",{get:function(){return this._material.bumpTexture},set:function(e){this._material.bumpTexture=e,this._material.forceIrradianceInFragment=!0},enumerable:!1,configurable:!0}),e.prototype.setNormalMapInversions=function(e,t){this._material.invertNormalMapX=e,this._material.invertNormalMapY=t},Object.defineProperty(e.prototype,"geometryCoatNormalTexture",{get:function(){return this._material.clearCoat.bumpTexture},set:function(e){this._material.clearCoat.isEnabled=!0,this._material.clearCoat.bumpTexture=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"geometryCoatNormalTextureScale",{set:function(e){this._material.clearCoat.bumpTexture&&(this._material.clearCoat.bumpTexture.level=e)},enumerable:!1,configurable:!0}),e}(),tt={__proto__:null,PBRMaterialLoadingAdapter:et},nt="EXT_lights_image_based",rt=function(){function e(e){this.name=nt,this._loader=e,this.enabled=this._loader.isExtensionUsed(nt)}return e.prototype.dispose=function(){this._loader=null,delete this._lights},e.prototype.onLoading=function(){var e=this._loader.gltf.extensions;if(e&&e[this.name]){var t=e[this.name];this._lights=t.lights}},e.prototype.loadSceneAsync=function(e,t){var n=this;return je.LoadExtensionAsync(e,t,this.name,function(r,o){return g(n,void 0,void 0,function(){var n,a,i=this;return b(this,function(s){switch(s.label){case 0:return this._loader._allMaterialsDirtyRequired=!0,(n=new Array).push(this._loader.loadSceneAsync(e,t)),this._loader.logOpen("".concat(r)),a=He.Get("".concat(r,"/light"),this._lights,o.light),n.push(this._loadLightAsync("/extensions/".concat(this.name,"/lights/").concat(o.light),a).then(function(e){i._loader.babylonScene.environmentTexture=e})),this._loader.logClose(),[4,Promise.all(n).then(function(){})];case 1:return[2,s.sent()]}})})})},e.prototype._loadLightAsync=function(e,n){var r=this;if(!n._loaded){var o=new Array;this._loader.logOpen("".concat(e));for(var a=new Array(n.specularImages.length),i=function(t){var r=n.specularImages[t];a[t]=new Array(r.length);for(var i=function(n){var i="".concat(e,"/specularImages/").concat(t,"/").concat(n);s._loader.logOpen("".concat(i));var l=r[n],u=He.Get(i,s._loader.gltf.images,l);o.push(s._loader.loadImageAsync("/images/".concat(l),u).then(function(e){a[t][n]=e})),s._loader.logClose()},l=0;l<r.length;l++)i(l)},s=this,l=0;l<n.specularImages.length;l++)i(l);this._loader.logClose(),n._loaded=Promise.all(o).then(function(){return g(r,void 0,void 0,function(){var r,o,i,s,l;return b(this,function(u){switch(u.label){case 0:if((r=new t.RawCubeTexture(this._loader.babylonScene,null,n.specularImageSize)).name=n.name||"environment",n._babylonTexture=r,null!=n.intensity&&(r.level=n.intensity),n.rotation&&(o=t.Quaternion.FromArray(n.rotation),this._loader.babylonScene.useRightHandedSystem||(o=t.Quaternion.Inverse(o)),t.Matrix.FromQuaternionToRef(o,r.getReflectionTextureMatrix())),!n.irradianceCoefficients)throw new Error("".concat(e,": Irradiance coefficients are missing"));return(i=t.SphericalHarmonics.FromArray(n.irradianceCoefficients)).scaleInPlace(n.intensity),i.convertIrradianceToLambertianRadiance(),s=t.SphericalPolynomial.FromHarmonics(i),l=(a.length-1)/Math.log2(n.specularImageSize),[4,r.updateRGBDAsync(a,s,l)];case 1:return[2,u.sent()]}})})})}return n._loaded.then(function(){return n._babylonTexture})},e}();we(nt),Ae(nt,!0,function(e){return new rt(e)});var ot={__proto__:null,EXT_lights_image_based:rt},at="EXT_mesh_gpu_instancing",it=function(){function e(e){this.name=at,this._loader=e,this.enabled=this._loader.isExtensionUsed(at)}return e.prototype.dispose=function(){this._loader=null},e.prototype.loadNodeAsync=function(e,n,r){var o=this;return je.LoadExtensionAsync(e,n,this.name,function(e,a){return g(o,void 0,void 0,function(){var o,i,s,l,u=this;return b(this,function(c){switch(c.label){case 0:return this._loader._disableInstancedMesh++,o=this._loader.loadNodeAsync("/nodes/".concat(n.index),n,r),this._loader._disableInstancedMesh--,n._primitiveBabylonMeshes?[3,2]:[4,o];case 1:case 3:return[2,c.sent()];case 2:return i=new Array,s=0,(l=function(t){if(null!=a.attributes[t]){var n=He.Get("".concat(e,"/attributes/").concat(t),u._loader.gltf.accessors,a.attributes[t]);if(i.push(u._loader._loadFloatAccessorAsync("/accessors/".concat(n.bufferView),n)),0===s)s=n.count;else if(s!==n.count)throw new Error("".concat(e,"/attributes: Instance buffer accessors do not have the same count."))}else i.push(Promise.resolve(null))})("TRANSLATION"),l("ROTATION"),l("SCALE"),l("_COLOR_0"),[4,o.then(function(e){return g(u,void 0,void 0,function(){var r,o,a,l,u,c,f,h,d,p;return b(this,function(m){switch(m.label){case 0:return[4,Promise.all(i)];case 1:for(r=m.sent(),o=r[0],a=r[1],l=r[2],u=r[3],c=new Float32Array(16*s),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),f=0;f<s;++f)o&&t.Vector3.FromArrayToRef(o,3*f,t.TmpVectors.Vector3[0]),a&&t.Quaternion.FromArrayToRef(a,4*f,t.TmpVectors.Quaternion[0]),l&&t.Vector3.FromArrayToRef(l,3*f,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(c,16*f);for(h=0,d=n._primitiveBabylonMeshes;h<d.length;h++)(p=d[h]).thinInstanceSetBuffer("matrix",c,16,!0),u&&(u.length===3*s?p.thinInstanceSetBuffer("color",u,3,!0):u.length===4*s?p.thinInstanceSetBuffer("color",u,4,!0):t.Logger.Warn("Unexpected size of _COLOR_0 attribute for mesh "+p.name));return[2,e]}})})})]}})})})},e}();we(at),Ae(at,!0,function(e){return new it(e)});var st={__proto__:null,EXT_mesh_gpu_instancing:it},lt="EXT_meshopt_compression",ut=function(){function e(e){this.name=lt,this.enabled=e.isExtensionUsed(lt),this._loader=e}return e.prototype.dispose=function(){this._loader=null},e.prototype.loadBufferViewAsync=function(e,n){var r=this;return je.LoadExtensionAsync(e,n,this.name,function(o,a){return g(r,void 0,void 0,function(){var r,o,i=this;return b(this,function(s){switch(s.label){case 0:return(r=n)._meshOptData?[4,r._meshOptData]:[3,2];case 1:case 3:return[2,s.sent()];case 2:return o=He.Get("".concat(e,"/buffer"),this._loader.gltf.buffers,a.buffer),r._meshOptData=this._loader.loadBufferAsync("/buffers/".concat(o.index),o,a.byteOffset||0,a.byteLength).then(function(e){return g(i,void 0,void 0,function(){return b(this,function(n){switch(n.label){case 0:return[4,t.MeshoptCompression.Default.decodeGltfBufferAsync(e,a.count,a.byteStride,a.mode,a.filter)];case 1:return[2,n.sent()]}})})}),[4,r._meshOptData]}})})})},e}();we(lt),Ae(lt,!0,function(e){return new ut(e)});var ct={__proto__:null,EXT_meshopt_compression:ut},ft="EXT_texture_webp",ht=function(){function e(e){this.name=ft,this._loader=e,this.enabled=e.isExtensionUsed(ft)}return e.prototype.dispose=function(){this._loader=null},e.prototype._loadTextureAsync=function(e,t,n){var r=this;return je.LoadExtensionAsync(e,t,this.name,function(o,a){return g(r,void 0,void 0,function(){var r,i;return b(this,function(s){switch(s.label){case 0:return r=null==t.sampler?je.DefaultSampler:He.Get("".concat(e,"/sampler"),this._loader.gltf.samplers,t.sampler),i=He.Get("".concat(o,"/source"),this._loader.gltf.images,a.source),[4,this._loader._createTextureAsync(e,r,i,function(e){n(e)},void 0,!t._textureInfo.nonColorData)];case 1:return[2,s.sent()]}})})})},e}();we(ft),Ae(ft,!0,function(e){return new ht(e)});var dt={__proto__:null,EXT_texture_webp:ht},pt="EXT_texture_avif",mt=function(){function e(e){this.name=pt,this._loader=e,this.enabled=e.isExtensionUsed(pt)}return e.prototype.dispose=function(){this._loader=null},e.prototype._loadTextureAsync=function(e,t,n){var r=this;return je.LoadExtensionAsync(e,t,this.name,function(o,a){return g(r,void 0,void 0,function(){var r,i;return b(this,function(s){switch(s.label){case 0:return r=null==t.sampler?je.DefaultSampler:He.Get("".concat(e,"/sampler"),this._loader.gltf.samplers,t.sampler),i=He.Get("".concat(o,"/source"),this._loader.gltf.images,a.source),[4,this._loader._createTextureAsync(e,r,i,function(e){n(e)},void 0,!t._textureInfo.nonColorData)];case 1:return[2,s.sent()]}})})})},e}();we(pt),Ae(pt,!0,function(e){return new mt(e)});var _t={__proto__:null,EXT_texture_avif:mt},gt="EXT_lights_ies",bt=function(){function e(e){this.name=gt,this._loader=e,this.enabled=this._loader.isExtensionUsed(gt)}return e.prototype.dispose=function(){this._loader=null,delete this._lights},e.prototype.onLoading=function(){var e=this._loader.gltf.extensions;if(e&&e[this.name]){var t=e[this.name];this._lights=t.lights,He.Assign(this._lights)}},e.prototype.loadNodeAsync=function(e,n,r){var o=this;return je.LoadExtensionAsync(e,n,this.name,function(a,i){return g(o,void 0,void 0,function(){var o,s,l,u,c,f=this;return b(this,function(h){switch(h.label){case 0:return this._loader._allMaterialsDirtyRequired=!0,[4,this._loader.loadNodeAsync(e,n,function(e){var n=(s=He.Get(a,f._lights,i.light)).name||e.name;f._loader.babylonScene._blockEntityCollection=!!f._loader._assetContainer,(o=new t.SpotLight(n,t.Vector3.Zero(),t.Vector3.Backward(),0,1,f._loader.babylonScene)).angle=Math.PI/2,o.innerAngle=0,o._parentContainer=f._loader._assetContainer,f._loader.babylonScene._blockEntityCollection=!1,s._babylonLight=o,o.falloffType=t.Light.FALLOFF_GLTF,o.diffuse=i.color?t.Color3.FromArray(i.color):t.Color3.White(),o.intensity=i.multiplier||1,o.range=Number.MAX_VALUE,o.parent=e,f._loader._babylonLights.push(o),je.AddPointerMetadata(o,a),r(e)})];case 1:return l=h.sent(),s.uri?[4,this._loader.loadUriAsync(e,s,s.uri)]:[3,3];case 2:return u=h.sent(),[3,5];case 3:return c=He.Get("".concat(e,"/bufferView"),this._loader.gltf.bufferViews,s.bufferView),[4,this._loader.loadBufferViewAsync("/bufferViews/".concat(c.index),c)];case 4:u=h.sent(),h.label=5;case 5: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"),[2,l]}})})})},e}();we(gt),Ae(gt,!0,function(e){return new bt(e)});var yt={__proto__:null,EXT_lights_ies:bt},vt="KHR_draco_mesh_compression",Tt=function(){function e(e){this.name=vt,this.useNormalizedFlagFromAccessor=!0,this._loader=e,this.enabled=t.DracoDecoder.DefaultAvailable&&this._loader.isExtensionUsed(vt)}return e.prototype.dispose=function(){delete this.dracoDecoder,this._loader=null},e.prototype._loadVertexDataAsync=function(e,n,r){var o=this;return je.LoadExtensionAsync(e,n,this.name,function(a,i){return g(o,void 0,void 0,function(){var o,s,l,u,c=this;return b(this,function(f){switch(f.label){case 0:if(null!=n.mode&&4!==n.mode&&5!==n.mode)throw new Error("".concat(e,": Unsupported mode ").concat(n.mode));return o={},s={},(l=function(e,t){var a=i.attributes[e];if(null!=a&&(r._delayInfo=r._delayInfo||[],-1===r._delayInfo.indexOf(t)&&r._delayInfo.push(t),o[t]=a,c.useNormalizedFlagFromAccessor)){var l=He.TryGet(c._loader.gltf.accessors,n.attributes[e]);l&&(s[t]=l.normalized||!1)}})("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),(u=He.Get(a,this._loader.gltf.bufferViews,i.bufferView))._dracoBabylonGeometry||(u._dracoBabylonGeometry=this._loader.loadBufferViewAsync("/bufferViews/".concat(u.index),u).then(function(a){return g(c,void 0,void 0,function(){var i,l,u;return b(this,function(c){switch(c.label){case 0:return i=this.dracoDecoder||t.DracoDecoder.Default,l=He.TryGet(this._loader.gltf.accessors,n.attributes.POSITION),u=this._loader.parent.alwaysComputeBoundingBox||r.skeleton||!l?null:Ke(l),[4,i._decodeMeshToGeometryForGltfAsync(r.name,this._loader.babylonScene,a,o,s,u).catch(function(t){throw new Error("".concat(e,": ").concat(t.message))})];case 1:return[2,c.sent()]}})})})),[4,u._dracoBabylonGeometry];case 1:return[2,f.sent()]}})})})},e}();we(vt),Ae(vt,!0,function(e){return new Tt(e)});var xt={__proto__:null,KHR_draco_mesh_compression:Tt},At="KHR_lights_punctual",wt=function(){function e(e){this.name=At,this._loader=e,this.enabled=this._loader.isExtensionUsed(At)}return e.prototype.dispose=function(){this._loader=null,delete this._lights},e.prototype.onLoading=function(){var e=this._loader.gltf.extensions;if(e&&e[this.name]){var t=e[this.name];this._lights=t.lights,He.Assign(this._lights)}},e.prototype.loadNodeAsync=function(e,n,r){var o=this;return je.LoadExtensionAsync(e,n,this.name,function(a,i){return g(o,void 0,void 0,function(){var o=this;return b(this,function(s){switch(s.label){case 0:return this._loader._allMaterialsDirtyRequired=!0,[4,this._loader.loadNodeAsync(e,n,function(e){var n,s=He.Get(a,o._lights,i.light),l=s.name||e.name;switch(o._loader.babylonScene._blockEntityCollection=!!o._loader._assetContainer,s.type){case"directional":var u=new t.DirectionalLight(l,t.Vector3.Backward(),o._loader.babylonScene);u.position.setAll(0),n=u;break;case"point":n=new t.PointLight(l,t.Vector3.Zero(),o._loader.babylonScene);break;case"spot":var c=new t.SpotLight(l,t.Vector3.Zero(),t.Vector3.Backward(),0,1,o._loader.babylonScene);c.angle=2*(s.spot&&s.spot.outerConeAngle||Math.PI/4),c.innerAngle=2*(s.spot&&s.spot.innerConeAngle||0),n=c;break;default:throw o._loader.babylonScene._blockEntityCollection=!1,new Error("".concat(a,": Invalid light type (").concat(s.type,")"))}n._parentContainer=o._loader._assetContainer,o._loader.babylonScene._blockEntityCollection=!1,s._babylonLight=n,n.falloffType=t.Light.FALLOFF_GLTF,n.diffuse=s.color?t.Color3.FromArray(s.color):t.Color3.White(),n.intensity=null==s.intensity?1:s.intensity,n.range=null==s.range?Number.MAX_VALUE:s.range,n.parent=e,o._loader._babylonLights.push(n),je.AddPointerMetadata(n,a),r(e)})];case 1:return[2,s.sent()]}})})})},e}();we(At),Ae(At,!0,function(e){return new wt(e)});var Ot={__proto__:null,KHR_lights:wt},Ct="EXT_lights_area",Mt=function(){function e(e){this.name=Ct,this._loader=e,this.enabled=this._loader.isExtensionUsed(Ct)}return e.prototype.dispose=function(){this._loader=null,delete this._lights},e.prototype.onLoading=function(){var e=this._loader.gltf.extensions;if(e&&e[this.name]){var t=e[this.name];this._lights=t.lights,He.Assign(this._lights)}},e.prototype.loadNodeAsync=function(e,n,r){var o=this;return je.LoadExtensionAsync(e,n,this.name,function(a,i){return g(o,void 0,void 0,function(){var o=this;return b(this,function(s){switch(s.label){case 0:return this._loader._allMaterialsDirtyRequired=!0,[4,this._loader.loadNodeAsync(e,n,function(e){var n,s,l=He.Get(a,o._lights,i.light),u=l.name||e.name;o._loader.babylonScene._blockEntityCollection=!!o._loader._assetContainer;var c=void 0!==l.size?l.size:1;switch(l.type){case"rect":var f=void 0!==(null===(n=l.rect)||void 0===n?void 0:n.aspect)?l.rect.aspect*c:c,h=c;s=new t.RectAreaLight(u,t.Vector3.Zero(),f,h,o._loader.babylonScene);break;case"disk":var d=Math.sqrt(c*c*.25*Math.PI);s=new t.RectAreaLight(u,t.Vector3.Zero(),d,d,o._loader.babylonScene);break;default:throw o._loader.babylonScene._blockEntityCollection=!1,new Error("".concat(a,": Invalid area light type (").concat(l.type,")"))}s._parentContainer=o._loader._assetContainer,o._loader.babylonScene._blockEntityCollection=!1,l._babylonLight=s,s.falloffType=t.Light.FALLOFF_GLTF,s.diffuse=l.color?t.Color3.FromArray(l.color):t.Color3.White(),s.intensity=null==l.intensity?1:l.intensity;var p=new t.TransformNode("".concat(u,"_orientation"),o._loader.babylonScene);p.rotationQuaternion=t.Quaternion.RotationAxis(t.Vector3.Up(),Math.PI),p.parent=e,s.parent=p,o._loader._babylonLights.push(s),je.AddPointerMetadata(s,a),r(e)})];case 1:return[2,s.sent()]}})})})},e}();we(Ct),Ae(Ct,!0,function(e){return new Mt(e)});var Et={__proto__:null,EXT_lights_area:Mt},Rt="KHR_materials_pbrSpecularGlossiness",Ft=function(){function e(e){this.name=Rt,this.order=200,this._loader=e,this.enabled=this._loader.isExtensionUsed(Rt)}return e.prototype.dispose=function(){this._loader=null},e.prototype.loadMaterialPropertiesAsync=function(e,t,n){var r=this;return je.LoadExtensionAsync(e,t,this.name,function(o,a){return g(r,void 0,void 0,function(){var r;return b(this,function(i){switch(i.label){case 0:return(r=new Array).push(this._loader.loadMaterialBasePropertiesAsync(e,t,n)),r.push(this._loadSpecularGlossinessPropertiesAsync(o,a,n)),this._loader.loadMaterialAlphaProperties(e,t,n),[4,Promise.all(r).then(function(){})];case 1:return[2,i.sent()]}})})})},e.prototype._loadSpecularGlossinessPropertiesAsync=function(e,n,r){var o=this._loader._getOrCreateMaterialAdapter(r),a=new Array;return o.configureSpecularGlossiness(),n.diffuseFactor?(o.baseColor=t.Color3.FromArray(n.diffuseFactor),r.alpha=n.diffuseFactor[3]):o.baseColor=t.Color3.White(),o.specularColor=n.specularFactor?t.Color3.FromArray(n.specularFactor):t.Color3.White(),o.glossiness=null==n.glossinessFactor?1:n.glossinessFactor,n.diffuseTexture&&a.push(this._loader.loadTextureInfoAsync("".concat(e,"/diffuseTexture"),n.diffuseTexture,function(e){e.name="".concat(r.name," (Diffuse)"),o.baseColorTexture=e})),n.specularGlossinessTexture&&a.push(this._loader.loadTextureInfoAsync("".concat(e,"/specularGlossinessTexture"),n.specularGlossinessTexture,function(e){e.name="".concat(r.name," (Specular Glossiness)"),o.specularColorTexture=e})),Promise.all(a).then(function(){})},e}();we(Rt),Ae(Rt,!0,function(e){return new Ft(e)});var Lt={__proto__:null,KHR_materials_pbrSpecularGlossiness:Ft},Pt="KHR_materials_unlit",St=function(){function e(e){this.name=Pt,this.order=210,this._loader=e,this.enabled=this._loader.isExtensionUsed(Pt)}return e.prototype.dispose=function(){this._loader=null},e.prototype.loadMaterialPropertiesAsync=function(e,t,n){var r=this;return je.LoadExtensionAsync(e,t,this.name,function(){return g(r,void 0,void 0,function(){return b(this,function(r){switch(r.label){case 0:return[4,this._loadUnlitPropertiesAsync(e,t,n)];case 1:return[2,r.sent()]}})})})},e.prototype._loadUnlitPropertiesAsync=function(e,n,r){var o=this._loader._getOrCreateMaterialAdapter(r),a=new Array,i=n.pbrMetallicRoughness;return i&&(i.baseColorFactor&&(o.baseColor=t.Color3.FromArray(i.baseColorFactor),o.geometryOpacity=i.baseColorFactor[3]),i.baseColorTexture&&a.push(this._loader.loadTextureInfoAsync("".concat(e,"/baseColorTexture"),i.baseColorTexture,function(e){e.name="".concat(r.name," (Base Color)"),o.baseColorTexture=e}))),o.isUnlit=!0,n.doubleSided&&(o.backFaceCulling=!1,o.twoSidedLighting=!0),this._loader.loadMaterialAlphaProperties(e,n,r),Promise.all(a).then(function(){})},e}();we(Pt),Ae(Pt,!0,function(e){return new St(e)});var Nt={__proto__:null,KHR_materials_unlit:St},It="KHR_materials_clearcoat",Bt=function(){function e(e){this.name=It,this.order=190,this._loader=e,this.enabled=this._loader.isExtensionUsed(It)}return e.prototype.dispose=function(){this._loader=null},e.prototype.loadMaterialPropertiesAsync=function(e,t,n){var r=this;return je.LoadExtensionAsync(e,t,this.name,function(o,a){return g(r,void 0,void 0,function(){var r;return b(this,function(i){switch(i.label){case 0:return(r=new Array).push(this._loader.loadMaterialPropertiesAsync(e,t,n)),r.push(this._loadClearCoatPropertiesAsync(o,a,n)),[4,Promise.all(r)];case 1:return i.sent(),[2]}})})})},e.prototype._loadClearCoatPropertiesAsync=function(e,t,n){var r=this._loader._getOrCreateMaterialAdapter(n),o=new Array;return r.configureCoat(),r.coatWeight=void 0!==t.clearcoatFactor?t.clearcoatFactor:0,r.coatRoughness=void 0!==t.clearcoatRoughnessFactor?t.clearcoatRoughnessFactor:0,t.clearcoatTexture&&o.push(this._loader.loadTextureInfoAsync("".concat(e,"/clearcoatTexture"),t.clearcoatTexture,function(e){e.name="".concat(n.name," (ClearCoat)"),r.coatWeightTexture=e})),t.clearcoatRoughnessTexture&&(t.clearcoatRoughnessTexture.nonColorData=!0,o.push(this._loader.loadTextureInfoAsync("".concat(e,"/clearcoatRoughnessTexture"),t.clearcoatRoughnessTexture,function(e){e.name="".concat(n.name," (ClearCoat Roughness)"),r.coatRoughnessTexture=e}))),t.clearcoatNormalTexture&&(t.clearcoatNormalTexture.nonColorData=!0,o.push(this._loader.loadTextureInfoAsync("".concat(e,"/clearcoatNormalTexture"),t.clearcoatNormalTexture,function(e){var o;e.name="".concat(n.name," (ClearCoat Normal)"),r.geometryCoatNormalTexture=e,null!=(null===(o=t.clearcoatNormalTexture)||void 0===o?void 0:o.scale)&&(r.geometryCoatNormalTextureScale=t.clearcoatNormalTexture.scale)})),r.setNormalMapInversions(!n.getScene().useRightHandedSystem,n.getScene().useRightHandedSystem)),Promise.all(o).then(function(){})},e}();we(It),Ae(It,!0,function(e){return new Bt(e)});var kt={__proto__:null,KHR_materials_clearcoat:Bt},Gt="KHR_materials_coat",Dt=function(){function e(e){this.name=Gt,this.order=191,this.useOpenPBR=!1,this._loader=e,this.enabled=this._loader.isExtensionUsed(Gt)}return e.prototype.dispose=function(){this._loader=null},e.prototype.loadMaterialPropertiesAsync=function(e,t,n){var r=this;return je.LoadExtensionAsync(e,t,this.name,function(o,a){return g(r,void 0,void 0,function(){var r;return b(this,function(i){switch(i.label){case 0:return(r=new Array).push(this._loader.loadMaterialPropertiesAsync(e,t,n)),t.extensions&&t.extensions.KHR_materials_openpbr&&(this.useOpenPBR=!0),r.push(this._loadCoatPropertiesAsync(o,a,n)),[4,Promise.all(r)];case 1:return i.sent(),[2]}})})})},e.prototype._loadCoatPropertiesAsync=function(e,n,r){var o,a,i=this._loader._getOrCreateMaterialAdapter(r),s=new Array;i.configureCoat(),i.coatWeight=void 0!==n.coatFactor?n.coatFactor:0,i.coatRoughness=void 0!==n.coatRoughnessFactor?n.coatRoughnessFactor:0,n.coatTexture&&s.push(this._loader.loadTextureInfoAsync("".concat(e,"/coatTexture"),n.coatTexture,function(e){e.name="".concat(r.name," (Coat)"),i.coatWeightTexture=e})),n.coatRoughnessTexture&&(n.coatRoughnessTexture.nonColorData=!0,s.push(this._loader.loadTextureInfoAsync("".concat(e,"/coatRoughnessTexture"),n.coatRoughnessTexture,function(e){e.name="".concat(r.name," (Coat Roughness)"),i.coatRoughnessTexture=e}))),n.coatNormalTexture&&(n.coatNormalTexture.nonColorData=!0,s.push(this._loader.loadTextureInfoAsync("".concat(e,"/coatNormalTexture"),n.coatNormalTexture,function(e){var t;e.name="".concat(r.name," (Coat Normal)"),i.geometryCoatNormalTexture=e,null!=(null===(t=n.coatNormalTexture)||void 0===t?void 0:t.scale)&&(i.geometryCoatNormalTextureScale=n.coatNormalTexture.scale)})),i.setNormalMapInversions(!r.getScene().useRightHandedSystem,r.getScene().useRightHandedSystem)),i.coatDarkening=void 0!==n.coatDarkeningFactor?n.coatDarkeningFactor:1,i.coatIor=void 0!==n.coatIor?n.coatIor:1.5;var l=t.Color3.White();void 0!==n.coatColorFactor&&l.fromArray(n.coatColorFactor),i.coatColor=l,n.coatColorTexture&&s.push(this._loader.loadTextureInfoAsync("".concat(e,"/coatColorTexture"),n.coatColorTexture,function(e){e.name="".concat(r.name," (Coat Color)"),i.coatColorTexture=e}));var u=null!==(o=n.coatAnisotropyStrength)&&void 0!==o?o:0,c=null!==(a=n.coatAnisotropyRotation)&&void 0!==a?a:0;return i.coatRoughnessAnisotropy=u,i.geometryCoatTangentAngle=c,this.useOpenPBR||i.configureGltfStyleAnisotropy(!0),n.coatAnisotropyTexture&&(n.coatAnisotropyTexture.nonColorData=!0,s.push(this._loader.loadTextureInfoAsync("".concat(e,"/coatAnisotropyTexture"),n.coatAnisotropyTexture,function(e){e.name="".concat(r.name," (Coat Anisotropy)"),i.geometryCoatTangentTexture=e}))),Promise.all(s).then(function(){})},e}();we(Gt),Ae(Gt,!0,function(e){return new Dt(e)});var Vt={__proto__:null,KHR_materials_coat:Dt},Ht="KHR_materials_iridescence",Kt=function(){function e(e){this.name=Ht,this.order=195,this._loader=e,this.enabled=this._loader.isExtensionUsed(Ht)}return e.prototype.dispose=function(){this._loader=null},e.prototype.loadMaterialPropertiesAsync=function(e,t,n){var r=this;return je.LoadExtensionAsync(e,t,this.name,function(o,a){return g(r,void 0,void 0,function(){var r;return b(this,function(i){switch(i.label){case 0:return(r=new Array).push(this._loader.loadMaterialPropertiesAsync(e,t,n)),r.push(this._loadIridescencePropertiesAsync(o,a,n)),[4,Promise.all(r).then(function(){})];case 1:return[2,i.sent()]}})})})},e.prototype._loadIridescencePropertiesAsync=function(e,t,n){var r,o,a,i,s,l=this._loader._getOrCreateMaterialAdapter(n),u=new Array;return l.thinFilmWeight=null!==(r=t.iridescenceFactor)&&void 0!==r?r:0,l.thinFilmIor=null!==(a=null!==(o=t.iridescenceIor)&&void 0!==o?o:t.iridescenceIOR)&&void 0!==a?a:1.3,l.thinFilmThicknessMinimum=null!==(i=t.iridescenceThicknessMinimum)&&void 0!==i?i:100,l.thinFilmThicknessMaximum=null!==(s=t.iridescenceThicknessMaximum)&&void 0!==s?s:400,t.iridescenceTexture&&u.push(this._loader.loadTextureInfoAsync("".concat(e,"/iridescenceTexture"),t.iridescenceTexture,function(e){e.name="".concat(n.name," (Iridescence)"),l.thinFilmWeightTexture=e})),t.iridescenceThicknessTexture&&u.push(this._loader.loadTextureInfoAsync("".concat(e,"/iridescenceThicknessTexture"),t.iridescenceThicknessTexture,function(e){e.name="".concat(n.name," (Iridescence Thickness)"),l.thinFilmThicknessTexture=e})),Promise.all(u).then(function(){})},e}();we(Ht),Ae(Ht,!0,function(e){return new Kt(e)});var jt={__proto__:null,KHR_materials_iridescence:Kt},Ut="KHR_materials_anisotropy",Wt=function(){function e(e){this.name=Ut,this.order=195,this._loader=e,this.enabled=this._loader.isExtensionUsed(Ut)}return e.prototype.dispose=function(){this._loader=null},e.prototype.loadMaterialPropertiesAsync=function(e,t,n){var r=this;return je.LoadExtensionAsync(e,t,this.name,function(o,a){return g(r,void 0,void 0,function(){var r;return b(this,function(i){switch(i.label){case 0:return(r=new Array).push(this._loader.loadMaterialPropertiesAsync(e,t,n)),r.push(this._loadAnisotropyPropertiesAsync(o,a,n)),[4,Promise.all(r)];case 1:return i.sent(),[2]}})})})},e.prototype._loadAnisotropyPropertiesAsync=function(e,t,n){return g(this,void 0,void 0,function(){var r,o,a,i,s,l,u,c;return b(this,function(f){switch(f.label){case 0:return r=this._loader._getOrCreateMaterialAdapter(n),o=new Array,a=null!==(l=t.anisotropyStrength)&&void 0!==l?l:0,i=null!==(u=t.anisotropyRotation)&&void 0!==u?u:0,r.specularRoughnessAnisotropy=a,r.geometryTangentAngle=i,(s=null!==(c=t.extensions)&&void 0!==c?c:{}).EXT_materials_anisotropy_openpbr&&s.EXT_materials_anisotropy_openpbr.openPbrAnisotropyEnabled||r.configureGltfStyleAnisotropy(!0),t.anisotropyTexture&&(t.anisotropyTexture.nonColorData=!0,o.push(this._loader.loadTextureInfoAsync("".concat(e,"/anisotropyTexture"),t.anisotropyTexture,function(e){e.name="".concat(n.name," (Anisotropy Intensity)"),r.geometryTangentTexture=e}))),[4,Promise.all(o)];case 1:return f.sent(),[2]}})})},e}();we(Ut),Ae(Ut,!0,function(e){return new Wt(e)});var zt={__proto__:null,KHR_materials_anisotropy:Wt},qt="KHR_materials_emissive_strength",Yt=function(){function e(e){this.name=qt,this.order=170,this._loader=e,this.enabled=this._loader.isExtensionUsed(qt)}return e.prototype.dispose=function(){this._loader=null},e.prototype.loadMaterialPropertiesAsync=function(e,t,n){var r=this;return je.LoadExtensionAsync(e,t,this.name,function(o,a){return g(r,void 0,void 0,function(){return b(this,function(r){switch(r.label){case 0:return[4,this._loader.loadMaterialPropertiesAsync(e,t,n)];case 1:return r.sent(),this._loadEmissiveProperties(o,a,n),[4,Promise.resolve()];case 2:return[2,r.sent()]}})})})},e.prototype._loadEmissiveProperties=function(e,t,n){void 0!==t.emissiveStrength&&(this._loader._getOrCreateMaterialAdapter(n).emissionLuminance=t.emissiveStrength)},e}();we(qt),Ae(qt,!0,function(e){return new Yt(e)});var Xt={__proto__:null,KHR_materials_emissive_strength:Yt},Jt="KHR_materials_sheen",Qt=function(){function e(e){this.name=Jt,this.order=190,this._loader=e,this.enabled=this._loader.isExtensionUsed(Jt)}return e.prototype.dispose=function(){this._loader=null},e.prototype.loadMaterialPropertiesAsync=function(e,t,n){var r=this;return je.LoadExtensionAsync(e,t,this.name,function(o,a){return g(r,void 0,void 0,function(){var r;return b(this,function(i){switch(i.label){case 0:return(r=new Array).push(this._loader.loadMaterialPropertiesAsync(e,t,n)),r.push(this._loadSheenPropertiesAsync(o,a,n)),[4,Promise.all(r).then(function(){})];case 1:return[2,i.sent()]}})})})},e.prototype._loadSheenPropertiesAsync=function(e,n,r){var o=this._loader._getOrCreateMaterialAdapter(r),a=new Array;o.configureFuzz();var i=void 0!==n.sheenColorFactor?t.Color3.FromArray(n.sheenColorFactor):t.Color3.Black(),s=void 0!==n.sheenRoughnessFactor?n.sheenRoughnessFactor:0;return o.fuzzWeight=1,o.fuzzColor=i,o.fuzzRoughness=s,n.sheenColorTexture&&a.push(this._loader.loadTextureInfoAsync("".concat(e,"/sheenColorTexture"),n.sheenColorTexture,function(e){e.name="".concat(r.name," (Sheen Color)"),o.fuzzColorTexture=e})),n.sheenRoughnessTexture&&(n.sheenRoughnessTexture.nonColorData=!0,a.push(this._loader.loadTextureInfoAsync("".concat(e,"/sheenRoughnessTexture"),n.sheenRoughnessTexture,function(e){e.name="".concat(r.name," (Sheen Roughness)"),o.fuzzRoughnessTexture=e}))),Promise.all(a).then(function(){})},e}();we(Jt),Ae(Jt,!0,function(e){return new Qt(e)});var Zt={__proto__:null,KHR_materials_sheen:Qt},$t="KHR_materials_fuzz",en=function(){function e(e){this.name=$t,this.order=190,this._loader=e,this.enabled=this._loader.isExtensionUsed($t)}return e.prototype.dispose=function(){this._loader=null},e.prototype.loadMaterialPropertiesAsync=function(e,t,n){var r=this;return je.LoadExtensionAsync(e,t,this.name,function(o,a){return g(r,void 0,void 0,function(){var r;return b(this,function(i){switch(i.label){case 0:return(r=new Array).push(this._loader.loadMaterialPropertiesAsync(e,t,n)),r.push(this._loadFuzzPropertiesAsync(o,a,n)),[4,Promise.all(r).then(function(){})];case 1:return[2,i.sent()]}})})})},e.prototype._loadFuzzPropertiesAsync=function(e,n,r){var o=this._loader._getOrCreateMaterialAdapter(r),a=new Array;return o.configureFuzz(),o.fuzzWeight=void 0!==n.fuzzFactor?n.fuzzFactor:0,o.fuzzColor=void 0!==n.fuzzColorFactor?t.Color3.FromArray(n.fuzzColorFactor):t.Color3.White(),o.fuzzRoughness=void 0!==n.fuzzRoughnessFactor?n.fuzzRoughnessFactor:.5,n.fuzzTexture&&a.push(this._loader.loadTextureInfoAsync("".concat(e,"/fuzzTexture"),n.fuzzTexture,function(e){e.name="".concat(r.name," (Fuzz)"),o.fuzzWeightTexture=e})),n.fuzzColorTexture&&a.push(this._loader.loadTextureInfoAsync("".concat(e,"/fuzzColorTexture"),n.fuzzColorTexture,function(e){e.name="".concat(r.name," (Fuzz Color)"),o.fuzzColorTexture=e})),n.fuzzRoughnessTexture&&(n.fuzzRoughnessTexture.nonColorData=!0,a.push(this._loader.loadTextureInfoAsync("".concat(e,"/fuzzRoughnessTexture"),n.fuzzRoughnessTexture,function(e){e.name="".concat(r.name," (Fuzz Roughness)"),o.fuzzRoughnessTexture=e}))),Promise.all(a).then(function(){})},e}();we($t),Ae($t,!0,function(e){return new en(e)});var tn={__proto__:null,KHR_materials_fuzz:en},nn="KHR_materials_specular",rn=function(){function e(e){this.name=nn,this.order=190,this._loader=e,this.enabled=this._loader.isExtensionUsed(nn)}return e.prototype.dispose=function(){this._loader=null},e.prototype.loadMaterialPropertiesAsync=function(e,t,n){var r=this;return je.LoadExtensionAsync(e,t,this.name,function(o,a){return g(r,void 0,void 0,function(){var r,i;return b(this,function(s){switch(s.label){case 0:return(r=new Array).push(this._loader.loadMaterialPropertiesAsync(e,t,n)),r.push(this._loadSpecularPropertiesAsync(o,a,n)),i=this._loader._getOrCreateMaterialAdapter(n),a.extensions&&a.extensions.EXT_materials_specular_edge_color&&a.extensions.EXT_materials_specular_edge_color.specularEdgeColorEnabled&&i.enableSpecularEdgeColor(!0),[4,Promise.all(r).then(function(){})];case 1:return[2,s.sent()]}})})})},e.prototype._loadSpecularPropertiesAsync=function(e,n,r){var o,a=this._loader._getOrCreateMaterialAdapter(r),i=new Array;return a.specularWeight=null!==(o=n.specularFactor)&&void 0!==o?o:1,a.specularColor=void 0!==n.specularColorFactor?t.Color3.FromArray(n.specularColorFactor):new t.Color3(1,1,1),n.specularTexture&&(n.specularTexture.nonColorData=!0,i.push(this._loader.loadTextureInfoAsync("".concat(e,"/specularTexture"),n.specularTexture,function(e){e.name="".concat(r.name," (Specular)"),a.specularWeightTexture=e}))),n.specularColorTexture&&i.push(this._loader.loadTextureInfoAsync("".concat(e,"/specularColorTexture"),n.specularColorTexture,function(e){e.name="".concat(r.name," (Specular Color)"),a.specularColorTexture=e})),Promise.all(i).then(function(){})},e}();we(nn),Ae(nn,!0,function(e){return new rn(e)});var on={__proto__:null,KHR_materials_specular:rn},an="KHR_materials_ior",sn=function(){function e(e){this.name=an,this.order=180,this._loader=e,this.enabled=this._loader.isExtensionUsed(an)}return e.prototype.dispose=function(){this._loader=null},e.prototype.loadMaterialPropertiesAsync=function(e,t,n){var r=this;return je.LoadExtensionAsync(e,t,this.name,function(o,a){return g(r,void 0,void 0,function(){var r;return b(this,function(i){switch(i.label){case 0:return(r=new Array).push(this._loader.loadMaterialPropertiesAsync(e,t,n)),r.push(this._loadIorPropertiesAsync(o,a,n)),[4,Promise.all(r).then(function(){})];case 1:return[2,i.sent()]}})})})},e.prototype._loadIorPropertiesAsync=function(t,n,r){var o=this._loader._getOrCreateMaterialAdapter(r),a=void 0!==n.ior?n.ior:e._DEFAULT_IOR;return o.specularIor=a,Promise.resolve()},e._DEFAULT_IOR=1.5,e}();we(an),Ae(an,!0,function(e){return new sn(e)});var ln={__proto__:null,KHR_materials_ior:sn},un="KHR_materials_variants",cn=function(){function e(e){this.name=un,this._loader=e,this.enabled=this._loader.isExtensionUsed(un)&&!this._loader.parent.skipMaterials}return e.prototype.dispose=function(){this._loader=null},e.GetAvailableVariants=function(e){var t=this._GetExtensionMetadata(e);return t?Object.keys(t.variants):[]},e.prototype.getAvailableVariants=function(t){return e.GetAvailableVariants(t)},e.SelectVariant=function(e,t){var n=this._GetExtensionMetadata(e);if(!n)throw new Error("Cannot select variant on a glTF mesh that does not have the ".concat(un," extension"));var r=function(e){var t=n.variants[e];if(t)for(var r=0,o=t;r<o.length;r++){var a=o[r];a.mesh.material=a.material}};if(t instanceof Array)for(var o=0,a=t;o<a.length;o++)r(a[o]);else r(t);n.lastSelected=t},e.prototype.selectVariant=function(t,n){e.SelectVariant(t,n)},e.Reset=function(e){var t=this._GetExtensionMetadata(e);if(!t)throw new Error("Cannot reset on a glTF mesh that does not have the ".concat(un," extension"));for(var n=0,r=t.original;n<r.length;n++){var o=r[n];o.mesh.material=o.material}t.lastSelected=null},e.prototype.reset=function(t){e.Reset(t)},e.GetLastSelectedVariant=function(e){var t=this._GetExtensionMetadata(e);if(!t)throw new Error("Cannot get the last selected variant on a glTF mesh that does not have the ".concat(un," extension"));return t.lastSelected},e.prototype.getLastSelectedVariant=function(t){return e.GetLastSelectedVariant(t)},e._GetExtensionMetadata=function(e){var t,n;return(null===(n=null===(t=null==e?void 0:e._internalMetadata)||void 0===t?void 0:t.gltf)||void 0===n?void 0:n[un])||null},e.prototype.onLoading=function(){var e=this._loader.gltf.extensions;if(e&&e[this.name]){var t=e[this.name];this._variants=t.variants}},e.prototype.onReady=function(){var t,n=this._loader.rootBabylonMesh;if(n){var r=this._loader.parent.extensionOptions[un];(null==r?void 0:r.defaultVariant)&&e.SelectVariant(n,r.defaultVariant),null===(t=null==r?void 0:r.onLoaded)||void 0===t||t.call(r,{get variants(){return e.GetAvailableVariants(n)},get selectedVariant(){var t=e.GetLastSelectedVariant(n);return t?Array.isArray(t)?t[0]:t:e.GetAvailableVariants(n)[0]},set selectedVariant(t){e.SelectVariant(n,t)}})}},e.prototype._loadMeshPrimitiveAsync=function(n,r,o,a,i,s){var l=this;return je.LoadExtensionAsync(n,i,this.name,function(u,c){return g(l,void 0,void 0,function(){var l,f=this;return b(this,function(h){switch(h.label){case 0:return(l=new Array).push(this._loader._loadMeshPrimitiveAsync(n,r,o,a,i,function(r){if(s(r),r instanceof t.Mesh){var o=je._GetDrawMode(n,i.mode),a=f._loader.rootBabylonMesh,h=a?a._internalMetadata=a._internalMetadata||{}:{},d=h.gltf=h.gltf||{},p=d[un]=d[un]||{lastSelected:null,original:[],variants:{}};p.original.push({mesh:r,material:r.material});for(var m=function(t){var n=c.mappings[t],i=He.Get("".concat(u,"/mappings/").concat(t,"/material"),f._loader.gltf.materials,n.material);l.push(f._loader._loadMaterialAsync("#/materials/".concat(n.material),i,r,o,function(t){for(var o=function(o){var i=n.variants[o],s=He.Get("/extensions/".concat(un,"/variants/").concat(i),f._variants,i);p.variants[s.name]=p.variants[s.name]||[],p.variants[s.name].push({mesh:r,material:t}),r.onClonedObservable.add(function(t){var n,o=t,i=o;do{if(!(i=i.parent))return;n=e._GetExtensionMetadata(i)}while(null===n);if(a&&n===e._GetExtensionMetadata(a)){for(var l in i._internalMetadata={},a._internalMetadata)i._internalMetadata[l]=a._internalMetadata[l];for(var l in i._internalMetadata.gltf=[],a._internalMetadata.gltf)i._internalMetadata.gltf[l]=a._internalMetadata.gltf[l];i._internalMetadata.gltf[un]={lastSelected:null,original:[],variants:{}};for(var u=0,c=n.original;u<c.length;u++){var f=c[u];i._internalMetadata.gltf[un].original.push({mesh:f.mesh,material:f.material})}for(var l in n.variants)if(Object.prototype.hasOwnProperty.call(n.variants,l)){i._internalMetadata.gltf[un].variants[l]=[];for(var h=0,d=n.variants[l];h<d.length;h++){var p=d[h];i._internalMetadata.gltf[un].variants[l].push({mesh:p.mesh,material:p.material})}}n=i._internalMetadata.gltf[un]}for(var m=0,_=n.original;m<_.length;m++)(y=_[m]).mesh===r&&(y.mesh=o);for(var g=0,b=n.variants[s.name];g<b.length;g++){var y;(y=b[g]).mesh===r&&(y.mesh=o)}})},i=0;i<n.variants.length;++i)o(i)}))},_=0;_<c.mappings.length;++_)m(_)}})),[4,Promise.all(l).then(function(e){return e[0]})];case 1:return[2,h.sent()]}})})})},e}();we(un),Ae(un,!0,function(e){return new cn(e)});var fn={__proto__:null,KHR_materials_variants:cn},hn=function(){function e(n,r){var o=this;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=_(_({},e._GetDefaultOptions()),n),this._scene=r,this._scene._transmissionHelper=this,this.onErrorObservable=new t.Observable,this._scene.onDisposeObservable.addOnce(function(){o.dispose()}),this._parseScene(),this._setupRenderTargets()}return e._GetDefaultOptions=function(){return{renderSize:1024,samples:4,lodGenerationScale:1,lodGenerationOffset:-4,renderTargetTextureType:t.Constants.TEXTURETYPE_HALF_FLOAT,generateMipmaps:!0}},e.prototype.addMaterialImpl=function(e){this._materialImpls.some(function(t){return t.materialClass===e.materialClass})||this._materialImpls.push(e)},e.prototype.updateOptions=function(e){var t=this,n=Object.keys(e).filter(function(n){return t._options[n]!==e[n]});if(n.length){var r=_(_({},this._options),e),o=this._options;this._options=r,r.renderSize===o.renderSize&&r.renderTargetTextureType===o.renderTargetTextureType&&r.generateMipmaps===o.generateMipmaps&&this._opaqueRenderTarget?(this._opaqueRenderTarget.samples=r.samples,this._opaqueRenderTarget.lodGenerationScale=r.lodGenerationScale,this._opaqueRenderTarget.lodGenerationOffset=r.lodGenerationOffset):this._setupRenderTargets()}},e.prototype.getOpaqueTarget=function(){return this._opaqueRenderTarget},e.prototype._getOrCreateAdapter=function(e){var t=this._adapterCache.get(e);if(!t)for(var n=0,r=this._materialImpls;n<r.length;n++){var o=r[n];if(e instanceof o.materialClass){t=new o.adapterClass(e),this._adapterCache.set(e,t);break}}return t},e.prototype._classifyMeshMaterials=function(e){var n=e.material;if(!n)return"opaque";if(!(n instanceof t.MultiMaterial))return(s=this._getOrCreateAdapter(n))&&s.isTranslucent()?(s.refractionBackgroundTexture=this._opaqueRenderTarget,"transparent"):"opaque";for(var r=!1,o=!1,a=new Set,i=0;i<n.subMaterials.length;i++){var s,l=n.subMaterials[i];l&&(s=this._getOrCreateAdapter(l))&&s.isTranslucent()?(s.refractionBackgroundTexture=this._opaqueRenderTarget,r=!0,a.add(i)):o=!0}return r&&o?(this._translucentMaterialIndices.set(e,a),this._rebuildOpaqueOnlySubMeshes(e,a),"mixed"):(this._translucentMaterialIndices.delete(e),this._opaqueOnlySubMeshes.delete(e),r?"transparent":"opaque")},e.prototype._rebuildOpaqueOnlySubMeshes=function(e,t){e.subMeshes&&this._opaqueOnlySubMeshes.set(e,e.subMeshes.filter(function(e){return!t.has(e.materialIndex)}))},e.prototype._addMesh=function(e){var n=this;this._materialObservers[e.uniqueId]=e.onMaterialChangedObservable.add(this._onMeshMaterialChanged.bind(this)),t.Tools.SetImmediate(function(){n._disposed||e.material&&("transparent"===n._classifyMeshMaterials(e)?-1===n._transparentMeshesCache.indexOf(e)&&n._transparentMeshesCache.push(e):-1===n._opaqueMeshesCache.indexOf(e)&&n._opaqueMeshesCache.push(e))})},e.prototype._removeMesh=function(e){e.onMaterialChangedObservable.remove(this._materialObservers[e.uniqueId]),delete this._materialObservers[e.uniqueId];var t=this._transparentMeshesCache.indexOf(e);-1!==t&&this._transparentMeshesCache.splice(t,1),-1!==(t=this._opaqueMeshesCache.indexOf(e))&&this._opaqueMeshesCache.splice(t,1),this._translucentMaterialIndices.delete(e),this._opaqueOnlySubMeshes.delete(e)},e.prototype._parseScene=function(){this._scene.meshes.forEach(this._addMesh.bind(this)),this._newMeshObserver=this._scene.onNewMeshAddedObservable.add(this._addMesh.bind(this)),this._removedMeshObserver=this._scene.onMeshRemovedObservable.add(this._removeMesh.bind(this))},e.prototype._onMeshMaterialChanged=function(e){var t=this._transparentMeshesCache.indexOf(e),n=this._opaqueMeshesCache.indexOf(e);"transparent"===this._classifyMeshMaterials(e)?-1!==n?(this._opaqueMeshesCache.splice(n,1),this._transparentMeshesCache.push(e)):-1===t&&this._transparentMeshesCache.push(e):-1!==t?(this._transparentMeshesCache.splice(t,1),this._opaqueMeshesCache.push(e)):-1===n&&this._opaqueMeshesCache.push(e)},e.prototype._isRenderTargetValid=function(){var e;return null!==(null===(e=this._opaqueRenderTarget)||void 0===e?void 0:e.getInternalTexture())},e.prototype._setupRenderTargets=function(){var e,n,r,o=this;this._opaqueRenderTarget&&this._opaqueRenderTarget.dispose(),this._opaqueRenderTarget=new t.RenderTargetTexture("opaqueSceneTexture",this._options.renderSize,this._scene,this._options.generateMipmaps,void 0,this._options.renderTargetTextureType),this._opaqueRenderTarget.ignoreCameraViewport=!0,this._opaqueRenderTarget.renderList=this._opaqueMeshesCache,this._opaqueRenderTarget.clearColor=null!==(n=null===(e=this._options.clearColor)||void 0===e?void 0:e.clone())&&void 0!==n?n:this._scene.clearColor.clone(),this._opaqueRenderTarget.clearColor.a=0,this._opaqueRenderTarget.gammaSpace=!1,this._opaqueRenderTarget.lodGenerationScale=this._options.lodGenerationScale,this._opaqueRenderTarget.lodGenerationOffset=this._options.lodGenerationOffset,this._opaqueRenderTarget.samples=this._options.samples,this._opaqueRenderTarget.renderSprites=!0,this._opaqueRenderTarget.renderParticles=!0,this._opaqueRenderTarget.disableImageProcessing=!0,this._opaqueRenderTarget.onBeforeBindObservable.add(function(e){r=o._scene.environmentIntensity,o._scene.environmentIntensity=1,o._options.clearColor?e.clearColor.copyFrom(o._options.clearColor):o._scene.clearColor.toLinearSpaceToRef(e.clearColor,o._scene.getEngine().useExactSrgbConversions),e.clearColor.a=0;for(var t=o._opaqueOnlySubMeshes.entries(),n=t.next();!n.done;n=t.next()){var a=n.value[0],i=n.value[1];a.subMeshes&&(o._savedSubMeshes.set(a,a.subMeshes),a.subMeshes=i)}}),this._opaqueRenderTarget.onAfterUnbindObservable.add(function(){o._scene.environmentIntensity=r;for(var e=o._savedSubMeshes.entries(),t=e.next();!t.done;t=e.next())t.value[0].subMeshes=t.value[1];o._savedSubMeshes.clear()});for(var a=0,i=this._transparentMeshesCache;a<i.length;a++)(u=i[a]).material&&this._classifyMeshMaterials(u);for(var s=this._translucentMaterialIndices.entries(),l=s.next();!l.done;l=s.next()){var u;(u=l.value[0]).material&&this._classifyMeshMaterials(u)}},e.prototype.dispose=function(){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;for(var n=0,r=y(y([],this._transparentMeshesCache,!0),this._opaqueMeshesCache,!0);n<r.length;n++){var o=r[n];(s=this._materialObservers[o.uniqueId])&&(s.remove(),delete this._materialObservers[o.uniqueId])}for(var a=0,i=this._scene.meshes;a<i.length;a++){var s;o=i[a],(s=this._materialObservers[o.uniqueId])&&(s.remove(),delete this._materialObservers[o.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()},e}();function dn(e,t){if(!e.parent.dontUseTransmissionHelper){for(var n=t.getScene()._transmissionHelper,r=null!=n?n:new hn({},t.getScene()),o=0,a=Array.from(e._pbrMaterialImpls.values());o<a.length;o++){var i=a[o];r.addMaterialImpl(i)}n&&!n._isRenderTargetValid()&&n._setupRenderTargets()}}var pn="KHR_materials_transmission",mn=function(){function e(e){this.name=pn,this.order=175,this._loader=e,this.enabled=this._loader.isExtensionUsed(pn),this.enabled&&(e.parent.transparencyAsCoverage=!0)}return e.prototype.dispose=function(){this._loader=null},e.prototype.loadMaterialPropertiesAsync=function(e,t,n){var r=this;return je.LoadExtensionAsync(e,t,this.name,function(o,a){return g(r,void 0,void 0,function(){var r;return b(this,function(i){switch(i.label){case 0:return(r=new Array).push(this._loader.loadMaterialPropertiesAsync(e,t,n)),r.push(this._loadTransparentPropertiesAsync(o,t,n,a)),[4,Promise.all(r).then(function(){})];case 1:return[2,i.sent()]}})})})},e.prototype._loadTransparentPropertiesAsync=function(e,t,n,r){var o=this._loader._getOrCreateMaterialAdapter(n),a=void 0!==r.transmissionFactor?r.transmissionFactor:0;if(0===a||!o)return Promise.resolve();o.configureTransmission(),o.transmissionWeight=a,a>0&&dn(this._loader,n);var i=Promise.resolve(null);return r.transmissionTexture&&(r.transmissionTexture.nonColorData=!0,i=this._loader.loadTextureInfoAsync("".concat(e,"/transmissionTexture"),r.transmissionTexture,function(e){e.name="".concat(n.name," (Transmission)"),o.transmissionWeightTexture=e})),i.then(function(){})},e}();we(pn),Ae(pn,!0,function(e){return new mn(e)});var _n={__proto__:null,KHR_materials_transmission:mn},gn="KHR_materials_diffuse_transmission",bn=function(){function e(e){this.name=gn,this.order=174,this._loader=e,this.enabled=this._loader.isExtensionUsed(gn),this.enabled&&(e.parent.transparencyAsCoverage=!0)}return e.prototype.dispose=function(){this._loader=null},e.prototype.loadMaterialPropertiesAsync=function(e,t,n){var r=this;return je.LoadExtensionAsync(e,t,this.name,function(o,a){return g(r,void 0,void 0,function(){var r;return b(this,function(i){switch(i.label){case 0:return(r=new Array).push(this._loader.loadMaterialPropertiesAsync(e,t,n)),r.push(this._loadTranslucentPropertiesAsync(o,t,n,a)),[4,Promise.all(r).then(function(){})];case 1:return[2,i.sent()]}})})})},e.prototype._loadTranslucentPropertiesAsync=function(e,n,r,o){var a,i=this._loader._getOrCreateMaterialAdapter(r);i.configureSubsurface(),i.subsurfaceWeight=null!==(a=o.diffuseTransmissionFactor)&&void 0!==a?a:0,i.subsurfaceWeight>0&&dn(this._loader,r),i.diffuseTransmissionTint=void 0!==o.diffuseTransmissionColorFactor?t.Color3.FromArray(o.diffuseTransmissionColorFactor):t.Color3.White();var s=new Array;return o.diffuseTransmissionTexture&&(o.diffuseTransmissionTexture.nonColorData=!0,s.push(this._loader.loadTextureInfoAsync("".concat(e,"/diffuseTransmissionTexture"),o.diffuseTransmissionTexture).then(function(e){e.name="".concat(r.name," (Diffuse Transmission)"),i.subsurfaceWeightTexture=e}))),o.diffuseTransmissionColorTexture&&s.push(this._loader.loadTextureInfoAsync("".concat(e,"/diffuseTransmissionColorTexture"),o.diffuseTransmissionColorTexture).then(function(e){e.name="".concat(r.name," (Diffuse Transmission Color)"),i.diffuseTransmissionTintTexture=e})),Promise.all(s).then(function(){})},e}();we(gn),Ae(gn,!0,function(e){return new bn(e)});var yn={__proto__:null,KHR_materials_diffuse_transmission:bn},vn="KHR_materials_volume",Tn=function(){function e(e){this.name=vn,this.order=173,this._loader=e,this.enabled=this._loader.isExtensionUsed(vn),this.enabled&&this._loader._disableInstancedMesh++}return e.prototype.dispose=function(){this.enabled&&this._loader._disableInstancedMesh--,this._loader=null},e.prototype.loadMaterialPropertiesAsync=function(e,t,n){var r=this;return je.LoadExtensionAsync(e,t,this.name,function(o,a){return g(r,void 0,void 0,function(){var r;return b(this,function(i){switch(i.label){case 0:return(r=new Array).push(this._loader.loadMaterialPropertiesAsync(e,t,n)),r.push(this._loadVolumePropertiesAsync(o,t,n,a)),[4,Promise.all(r).then(function(){})];case 1:return[2,i.sent()]}})})})},e.prototype._loadVolumePropertiesAsync=function(e,n,r,o){var a,i=this._loader._getOrCreateMaterialAdapter(r);if(0===i.transmissionWeight&&0===i.subsurfaceWeight||!o.thicknessFactor)return Promise.resolve();i.geometryThinWalled=!1;var s=void 0!==o.attenuationDistance?o.attenuationDistance:Number.MAX_VALUE,l=void 0!==o.attenuationColor&&3==o.attenuationColor.length?t.Color3.FromArray(o.attenuationColor):t.Color3.White();i.configureVolume(),i.transmissionColor=l,i.transmissionDepth=s,i.volumeThickness=null!==(a=o.thicknessFactor)&&void 0!==a?a:0;var u=new Array;return o.thicknessTexture&&(o.thicknessTexture.nonColorData=!0,u.push(this._loader.loadTextureInfoAsync("".concat(e,"/thicknessTexture"),o.thicknessTexture,function(e){e.name="".concat(r.name," (Thickness)"),i.volumeThicknessTexture=e}))),Promise.all(u).then(function(){})},e}();we(vn),Ae(vn,!0,function(e){return new Tn(e)});var xn={__proto__:null,KHR_materials_volume:Tn},An="KHR_materials_volume_scatter",wn=function(){function e(e){this.name=An,this.order=172,this._loader=e,this.enabled=this._loader.isExtensionUsed(An),this.enabled&&this._loader._disableInstancedMesh++}return e.prototype.dispose=function(){this.enabled&&this._loader._disableInstancedMesh--,this._loader=null},e.prototype.loadMaterialPropertiesAsync=function(e,t,n){var r=this;return je.LoadExtensionAsync(e,t,this.name,function(o,a){return g(r,void 0,void 0,function(){var r;return b(this,function(i){switch(i.label){case 0:return(r=new Array).push(this._loader.loadMaterialPropertiesAsync(e,t,n)),r.push(this._loadVolumePropertiesAsync(o,t,n,a)),[4,Promise.all(r).then(function(){})];case 1:return[2,i.sent()]}})})})},e.prototype._loadVolumePropertiesAsync=function(e,n,r,o){var a=this._loader._getOrCreateMaterialAdapter(r);if(0===a.transmissionWeight&&0===a.subsurfaceWeight||a.geometryThinWalled)return Promise.resolve();var i=void 0!==o.multiscatterColorFactor&&3==o.multiscatterColorFactor.length?t.Color3.FromArray(o.multiscatterColorFactor):t.Color3.Black(),s=void 0!==o.scatterAnisotropy?o.scatterAnisotropy:0,l=Promise.resolve(null);o.multiscatterColorTexture&&(o.multiscatterColorTexture.nonColorData=!0,l=this._loader.loadTextureInfoAsync("".concat(e,"/multiscatterColorTexture"),o.multiscatterColorTexture,function(e){e.name="".concat(r.name," (Scatter Color)"),a.transmissionWeight>0&&(a.transmissionScatterTexture=e),a.subsurfaceWeight>0&&(a.subsurfaceColorTexture=e)}));var u=new t.Vector3(-Math.log(a.transmissionColor.r),-Math.log(a.transmissionColor.g),-Math.log(a.transmissionColor.b));if(u.scaleInPlace(1/Math.max(a.transmissionDepth,1e-6)),a.transmissionWeight>0){var c=function(e){var n=new t.Vector3(e.r,e.g,e.b),r=new t.Vector3(4.09712,4.09712,4.09712);r.addInPlace(new t.Vector3(4.20863,4.20863,4.20863).multiplyInPlace(n));var o=new t.Vector3(9.59217,9.59217,9.59217);return o.addInPlace(new t.Vector3(41.6808,41.6808,41.6808).multiplyInPlace(n)),o.addInPlace(new t.Vector3(17.7126,17.7126,17.7126).multiplyInPlace(n.multiply(n))),r.subtractInPlace(new t.Vector3(Math.sqrt(o.x),Math.sqrt(o.y),Math.sqrt(o.z))),new t.Vector3(1,1,1).subtract(r.multiply(r))}(i),f=u.multiply(c);f.scaleInPlace(a.transmissionDepth),a.transmissionScatter.set(f.x,f.y,f.z),a.transmissionScatterAnisotropy=s}if(a.subsurfaceWeight>0){a.subsurfaceScatterAnisotropy=s,a.subsurfaceColor=i;var h=new t.Vector3(0!==u.x?1/u.x:1,0!==u.y?1/u.y:1,0!==u.z?1/u.z:1);a.subsurfaceRadius=Math.max(h.x,h.y,h.z),a.subsurfaceRadiusScale=new t.Color3(h.x/a.subsurfaceRadius,h.y/a.subsurfaceRadius,h.z/a.subsurfaceRadius)}return l.then(function(){})},e}();we(An),Ae(An,!0,function(e){return new wn(e)});var On={__proto__:null,KHR_materials_volume_scatter:wn},Cn="KHR_materials_dispersion",Mn=function(){function e(e){this.name=Cn,this.order=174,this._loader=e,this.enabled=this._loader.isExtensionUsed(Cn)}return e.prototype.dispose=function(){this._loader=null},e.prototype.loadMaterialPropertiesAsync=function(e,t,n){var r=this;return je.LoadExtensionAsync(e,t,this.name,function(o,a){return g(r,void 0,void 0,function(){var r;return b(this,function(i){switch(i.label){case 0:return(r=new Array).push(this._loader.loadMaterialPropertiesAsync(e,t,n)),r.push(this._loadDispersionPropertiesAsync(o,t,n,a)),[4,Promise.all(r).then(function(){})];case 1:return[2,i.sent()]}})})})},e.prototype._loadDispersionPropertiesAsync=function(e,t,n,r){var o=this._loader._getOrCreateMaterialAdapter(n);return 0!=o.transmissionWeight&&r.dispersion?(o.transmissionDispersionAbbeNumber=20,o.transmissionDispersionScale=r.dispersion,Promise.resolve()):Promise.resolve()},e}();we(Cn),Ae(Cn,!0,function(e){return new Mn(e)});var En={__proto__:null,KHR_materials_dispersion:Mn},Rn="KHR_materials_diffuse_roughness",Fn=function(){function e(e){this.name=Rn,this.order=190,this._loader=e,this.enabled=this._loader.isExtensionUsed(Rn)}return e.prototype.dispose=function(){this._loader=null},e.prototype.loadMaterialPropertiesAsync=function(e,t,n){var r=this;return je.LoadExtensionAsync(e,t,this.name,function(o,a){return g(r,void 0,void 0,function(){var r;return b(this,function(i){switch(i.label){case 0:return(r=new Array).push(this._loader.loadMaterialPropertiesAsync(e,t,n)),r.push(this._loadDiffuseRoughnessPropertiesAsync(o,a,n)),[4,Promise.all(r).then(function(){})];case 1:return[2,i.sent()]}})})})},e.prototype._loadDiffuseRoughnessPropertiesAsync=function(e,t,n){var r,o=this._loader._getOrCreateMaterialAdapter(n),a=new Array;return o.baseDiffuseRoughness=null!==(r=t.diffuseRoughnessFactor)&&void 0!==r?r:0,t.diffuseRoughnessTexture&&a.push(this._loader.loadTextureInfoAsync("".concat(e,"/diffuseRoughnessTexture"),t.diffuseRoughnessTexture,function(e){e.name="".concat(n.name," (Diffuse Roughness)"),o.baseDiffuseRoughnessTexture=e})),Promise.all(a).then(function(){})},e}();we(Rn),Ae(Rn,!0,function(e){return new Fn(e)});var Ln={__proto__:null,KHR_materials_diffuse_roughness:Fn},Pn="KHR_mesh_quantization",Sn=function(){function e(e){this.name=Pn,this.enabled=e.isExtensionUsed(Pn)}return e.prototype.dispose=function(){},e}();we(Pn),Ae(Pn,!0,function(e){return new Sn(e)});var Nn={__proto__:null,KHR_mesh_quantization:Sn},In="KHR_texture_basisu",Bn=function(){function e(e){this.name=In,this._loader=e,this.enabled=e.isExtensionUsed(In)}return e.prototype.dispose=function(){this._loader=null},e.prototype._loadTextureAsync=function(e,t,n){var r=this;return je.LoadExtensionAsync(e,t,this.name,function(o,a){return g(r,void 0,void 0,function(){var r,i;return b(this,function(s){switch(s.label){case 0:return r=null==t.sampler?je.DefaultSampler:He.Get("".concat(e,"/sampler"),this._loader.gltf.samplers,t.sampler),i=He.Get("".concat(o,"/source"),this._loader.gltf.images,a.source),[4,this._loader._createTextureAsync(e,r,i,function(e){n(e)},t._textureInfo.nonColorData?{useRGBAIfASTCBC7NotAvailableWhenUASTC:!0}:void 0,!t._textureInfo.nonColorData)];case 1:return[2,s.sent()]}})})})},e}();we(In),Ae(In,!0,function(e){return new Bn(e)});var kn={__proto__:null,KHR_texture_basisu:Bn},Gn="KHR_texture_transform",Dn=function(){function e(e){this.name=Gn,this._loader=e,this.enabled=this._loader.isExtensionUsed(Gn)}return e.prototype.dispose=function(){this._loader=null},e.prototype.loadTextureInfoAsync=function(e,n,r){var o=this;return je.LoadExtensionAsync(e,n,this.name,function(a,i){return g(o,void 0,void 0,function(){return b(this,function(o){switch(o.label){case 0:return[4,this._loader.loadTextureInfoAsync(e,n,function(e){if(!(e instanceof t.Texture))throw new Error("".concat(a,": Texture type not supported"));i.offset&&(e.uOffset=i.offset[0],e.vOffset=i.offset[1]),e.uRotationCenter=0,e.vRotationCenter=0,i.rotation&&(e.wAng=-i.rotation),i.scale&&(e.uScale=i.scale[0],e.vScale=i.scale[1]),null!=i.texCoord&&(e.coordinatesIndex=i.texCoord),r(e)})];case 1:return[2,o.sent()]}})})})},e}();we(Gn),Ae(Gn,!0,function(e){return new Dn(e)});var Vn={__proto__:null,KHR_texture_transform:Dn},Hn="KHR_xmp_json_ld",Kn=function(){function e(e){this.name=Hn,this.order=100,this._loader=e,this.enabled=this._loader.isExtensionUsed(Hn)}return e.prototype.dispose=function(){this._loader=null},e.prototype.onLoading=function(){var e,t,n;if(null!==this._loader.rootBabylonMesh){var r=null===(e=this._loader.gltf.extensions)||void 0===e?void 0:e.KHR_xmp_json_ld,o=null===(n=null===(t=this._loader.gltf.asset)||void 0===t?void 0:t.extensions)||void 0===n?void 0:n.KHR_xmp_json_ld;if(r&&o){var a=+o.packet;r.packets&&a<r.packets.length&&(this._loader.rootBabylonMesh.metadata=this._loader.rootBabylonMesh.metadata||{},this._loader.rootBabylonMesh.metadata.xmp=r.packets[a])}}},e}();we(Hn),Ae(Hn,!0,function(e){return new Kn(e)});var jn={__proto__:null,KHR_xmp_json_ld:Kn};function Un(e,n,r,o){return t.Color3.FromArray(n,r).scale(o)}function Wn(e,t,n,r){return t[n]*r}function zn(e,t,n,r){return-t[n]*r}function qn(e,t,n,r){return t[n+1]*r}function Yn(e,t,n,r){return t[n]*r*2}function Xn(e){return{scale:[new Qn(t.Animation.ANIMATIONTYPE_FLOAT,"".concat(e,".uScale"),Wn,function(){return 2}),new Qn(t.Animation.ANIMATIONTYPE_FLOAT,"".concat(e,".vScale"),qn,function(){return 2})],offset:[new Qn(t.Animation.ANIMATIONTYPE_FLOAT,"".concat(e,".uOffset"),Wn,function(){return 2}),new Qn(t.Animation.ANIMATIONTYPE_FLOAT,"".concat(e,".vOffset"),qn,function(){return 2})],rotation:[new Qn(t.Animation.ANIMATIONTYPE_FLOAT,"".concat(e,".wAng"),zn,function(){return 1})]}}var Jn=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return m(t,e),t.prototype.buildAnimations=function(e,t,n,r){return[{babylonAnimatable:e._babylonCamera,babylonAnimation:this._buildAnimation(t,n,r)}]},t}(Ye),Qn=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return m(t,e),t.prototype.buildAnimations=function(e,t,n,r){var o=[];for(var a in e._data)o.push({babylonAnimatable:e._data[a].babylonMaterial,babylonAnimation:this._buildAnimation(t,n,r)});return o},t}(Ye),Zn=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return m(t,e),t.prototype.buildAnimations=function(e,t,n,r){return[{babylonAnimatable:e._babylonLight,babylonAnimation:this._buildAnimation(t,n,r)}]},t}(Ye),$n=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return m(t,e),t.prototype.buildAnimations=function(e,t,n,r){var o=this;return e._primitiveBabylonMeshes?e._primitiveBabylonMeshes.map(function(e){return{babylonAnimatable:e,babylonAnimation:o._buildAnimation(t,n,r)}}):[]},t}(Ye);ke("/cameras/{}/orthographic/xmag",[new Jn(t.Animation.ANIMATIONTYPE_FLOAT,"orthoLeft",zn,function(){return 1}),new Jn(t.Animation.ANIMATIONTYPE_FLOAT,"orthoRight",qn,function(){return 1})]),ke("/cameras/{}/orthographic/ymag",[new Jn(t.Animation.ANIMATIONTYPE_FLOAT,"orthoBottom",zn,function(){return 1}),new Jn(t.Animation.ANIMATIONTYPE_FLOAT,"orthoTop",qn,function(){return 1})]),ke("/cameras/{}/orthographic/zfar",[new Jn(t.Animation.ANIMATIONTYPE_FLOAT,"maxZ",Wn,function(){return 1})]),ke("/cameras/{}/orthographic/znear",[new Jn(t.Animation.ANIMATIONTYPE_FLOAT,"minZ",Wn,function(){return 1})]),ke("/cameras/{}/perspective/yfov",[new Jn(t.Animation.ANIMATIONTYPE_FLOAT,"fov",Wn,function(){return 1})]),ke("/cameras/{}/perspective/zfar",[new Jn(t.Animation.ANIMATIONTYPE_FLOAT,"maxZ",Wn,function(){return 1})]),ke("/cameras/{}/perspective/znear",[new Jn(t.Animation.ANIMATIONTYPE_FLOAT,"minZ",Wn,function(){return 1})]),ke("/materials/{}/pbrMetallicRoughness/baseColorFactor",[new Qn(t.Animation.ANIMATIONTYPE_COLOR3,"albedoColor",Un,function(){return 4}),new Qn(t.Animation.ANIMATIONTYPE_FLOAT,"alpha",function(e,t,n,r){return t[n+3]*r},function(){return 4})]),ke("/materials/{}/pbrMetallicRoughness/metallicFactor",[new Qn(t.Animation.ANIMATIONTYPE_FLOAT,"metallic",Wn,function(){return 1})]),ke("/materials/{}/pbrMetallicRoughness/metallicFactor",[new Qn(t.Animation.ANIMATIONTYPE_FLOAT,"roughness",Wn,function(){return 1})]);var er=Xn("albedoTexture");ke("/materials/{}/pbrMetallicRoughness/baseColorTexture/extensions/KHR_texture_transform/scale",er.scale),ke("/materials/{}/pbrMetallicRoughness/baseColorTexture/extensions/KHR_texture_transform/offset",er.offset),ke("/materials/{}/pbrMetallicRoughness/baseColorTexture/extensions/KHR_texture_transform/rotation",er.rotation);var tr=Xn("metallicTexture");ke("//materials/{}/pbrMetallicRoughness/metallicRoughnessTexture/scale",tr.scale),ke("//materials/{}/pbrMetallicRoughness/metallicRoughnessTexture/offset",tr.offset),ke("//materials/{}/pbrMetallicRoughness/metallicRoughnessTexture/rotation",tr.rotation),ke("/materials/{}/emissiveFactor",[new Qn(t.Animation.ANIMATIONTYPE_COLOR3,"emissiveColor",Un,function(){return 3})]);var nr=Xn("bumpTexture");ke("/materials/{}/normalTexture/scale",[new Qn(t.Animation.ANIMATIONTYPE_FLOAT,"bumpTexture.level",Wn,function(){return 1})]),ke("/materials/{}/normalTexture/extensions/KHR_texture_transform/scale",nr.scale),ke("/materials/{}/normalTexture/extensions/KHR_texture_transform/offset",nr.offset),ke("/materials/{}/normalTexture/extensions/KHR_texture_transform/rotation",nr.rotation),ke("/materials/{}/occlusionTexture/strength",[new Qn(t.Animation.ANIMATIONTYPE_FLOAT,"ambientTextureStrength",Wn,function(){return 1})]);var rr=Xn("ambientTexture");ke("/materials/{}/occlusionTexture/extensions/KHR_texture_transform/scale",rr.scale),ke("/materials/{}/occlusionTexture/extensions/KHR_texture_transform/offset",rr.offset),ke("/materials/{}/occlusionTexture/extensions/KHR_texture_transform/rotation",rr.rotation);var or=Xn("emissiveTexture");ke("/materials/{}/emissiveTexture/extensions/KHR_texture_transform/scale",or.scale),ke("/materials/{}/emissiveTexture/extensions/KHR_texture_transform/offset",or.offset),ke("/materials/{}/emissiveTexture/extensions/KHR_texture_transform/rotation",or.rotation),ke("/materials/{}/extensions/KHR_materials_anisotropy/anisotropyStrength",[new Qn(t.Animation.ANIMATIONTYPE_FLOAT,"anisotropy.intensity",Wn,function(){return 1})]),ke("/materials/{}/extensions/KHR_materials_anisotropy/anisotropyRotation",[new Qn(t.Animation.ANIMATIONTYPE_FLOAT,"anisotropy.angle",Wn,function(){return 1})]);var ar=Xn("anisotropy.texture");ke("/materials/{}/extensions/KHR_materials_anisotropy/anisotropyTexture/extensions/KHR_texture_transform/scale",ar.scale),ke("/materials/{}/extensions/KHR_materials_anisotropy/anisotropyTexture/extensions/KHR_texture_transform/offset",ar.offset),ke("/materials/{}/extensions/KHR_materials_anisotropy/anisotropyTexture/extensions/KHR_texture_transform/rotation",ar.rotation),ke("/materials/{}/extensions/KHR_materials_clearcoat/clearcoatFactor",[new Qn(t.Animation.ANIMATIONTYPE_FLOAT,"clearCoat.intensity",Wn,function(){return 1})]),ke("/materials/{}/extensions/KHR_materials_clearcoat/clearcoatRoughnessFactor",[new Qn(t.Animation.ANIMATIONTYPE_FLOAT,"clearCoat.roughness",Wn,function(){return 1})]);var ir=Xn("clearCoat.texture");ke("/materials/{}/extensions/KHR_materials_clearcoat/clearcoatTexture/extensions/KHR_texture_transform/scale",ir.scale),ke("/materials/{}/extensions/KHR_materials_clearcoat/clearcoatTexture/extensions/KHR_texture_transform/offset",ir.offset),ke("/materials/{}/extensions/KHR_materials_clearcoat/clearcoatTexture/extensions/KHR_texture_transform/rotation",ir.rotation);var sr=Xn("clearCoat.bumpTexture");ke("/materials/{}/extensions/KHR_materials_clearcoat/clearcoatNormalTexture/scale",[new Qn(t.Animation.ANIMATIONTYPE_FLOAT,"clearCoat.bumpTexture.level",Wn,function(){return 1})]),ke("/materials/{}/extensions/KHR_materials_clearcoat/clearcoatNormalTexture/extensions/KHR_texture_transform/scale",sr.scale),ke("/materials/{}/extensions/KHR_materials_clearcoat/clearcoatNormalTexture/extensions/KHR_texture_transform/offset",sr.offset),ke("/materials/{}/extensions/KHR_materials_clearcoat/clearcoatNormalTexture/extensions/KHR_texture_transform/rotation",sr.rotation);var lr=Xn("clearCoat.textureRoughness");ke("/materials/{}/extensions/KHR_materials_clearcoat/clearcoatRoughnessTexture/extensions/KHR_texture_transform/scale",lr.scale),ke("/materials/{}/extensions/KHR_materials_clearcoat/clearcoatRoughnessTexture/extensions/KHR_texture_transform/offset",lr.offset),ke("/materials/{}/extensions/KHR_materials_clearcoat/clearcoatRoughnessTexture/extensions/KHR_texture_transform/rotation",lr.rotation),ke("/materials/{}/extensions/KHR_materials_dispersion/dispersionFactor",[new Qn(t.Animation.ANIMATIONTYPE_FLOAT,"subSurface.dispersion",Wn,function(){return 1})]),ke("/materials/{}/extensions/KHR_materials_emissive_strength/emissiveStrength",[new Qn(t.Animation.ANIMATIONTYPE_FLOAT,"emissiveIntensity",Wn,function(){return 1})]),ke("/materials/{}/extensions/KHR_materials_ior/ior",[new Qn(t.Animation.ANIMATIONTYPE_FLOAT,"indexOfRefraction",Wn,function(){return 1})]),ke("/materials/{}/extensions/KHR_materials_iridescence/iridescenceFactor",[new Qn(t.Animation.ANIMATIONTYPE_FLOAT,"iridescence.intensity",Wn,function(){return 1})]),ke("/materials/{}/extensions/KHR_materials_iridescence/iridescenceIor",[new Qn(t.Animation.ANIMATIONTYPE_FLOAT,"iridescence.indexOfRefraction",Wn,function(){return 1})]),ke("/materials/{}/extensions/KHR_materials_iridescence/iridescenceThicknessMinimum",[new Qn(t.Animation.ANIMATIONTYPE_FLOAT,"iridescence.minimumThickness",Wn,function(){return 1})]),ke("/materials/{}/extensions/KHR_materials_iridescence/iridescenceThicknessMaximum",[new Qn(t.Animation.ANIMATIONTYPE_FLOAT,"iridescence.maximumThickness",Wn,function(){return 1})]);var ur=Xn("iridescence.texture");ke("/materials/{}/extensions/KHR_materials_iridescence/iridescenceTexture/extensions/KHR_texture_transform/scale",ur.scale),ke("/materials/{}/extensions/KHR_materials_iridescence/iridescenceTexture/extensions/KHR_texture_transform/offset",ur.offset),ke("/materials/{}/extensions/KHR_materials_iridescence/iridescenceTexture/extensions/KHR_texture_transform/rotation",ur.rotation);var cr=Xn("iridescence.thicknessTexture");ke("/materials/{}/extensions/KHR_materials_iridescence/iridescenceThicknessTexture/extensions/KHR_texture_transform/scale",cr.scale),ke("/materials/{}/extensions/KHR_materials_iridescence/iridescenceThicknessTexture/extensions/KHR_texture_transform/offset",cr.offset),ke("/materials/{}/extensions/KHR_materials_iridescence/iridescenceThicknessTexture/extensions/KHR_texture_transform/rotation",cr.rotation),ke("/materials/{}/extensions/KHR_materials_sheen/sheenColorFactor",[new Qn(t.Animation.ANIMATIONTYPE_COLOR3,"sheen.color",Un,function(){return 3})]),ke("/materials/{}/extensions/KHR_materials_sheen/sheenRoughnessFactor",[new Qn(t.Animation.ANIMATIONTYPE_FLOAT,"sheen.roughness",Wn,function(){return 1})]);var fr=Xn("sheen.texture");ke("/materials/{}/extensions/KHR_materials_sheen/sheenColorTexture/extensions/KHR_texture_transform/scale",fr.scale),ke("/materials/{}/extensions/KHR_materials_sheen/sheenColorTexture/extensions/KHR_texture_transform/offset",fr.offset),ke("/materials/{}/extensions/KHR_materials_sheen/sheenColorTexture/extensions/KHR_texture_transform/rotation",fr.rotation);var hr=Xn("sheen.textureRoughness");ke("/materials/{}/extensions/KHR_materials_sheen/sheenRoughnessTexture/extensions/KHR_texture_transform/scale",hr.scale),ke("/materials/{}/extensions/KHR_materials_sheen/sheenRoughnessTexture/extensions/KHR_texture_transform/offset",hr.offset),ke("/materials/{}/extensions/KHR_materials_sheen/sheenRoughnessTexture/extensions/KHR_texture_transform/rotation",hr.rotation),ke("/materials/{}/extensions/KHR_materials_specular/specularFactor",[new Qn(t.Animation.ANIMATIONTYPE_FLOAT,"metallicF0Factor",Wn,function(){return 1})]),ke("/materials/{}/extensions/KHR_materials_specular/specularColorFactor",[new Qn(t.Animation.ANIMATIONTYPE_COLOR3,"metallicReflectanceColor",Un,function(){return 3})]);var dr=Xn("metallicReflectanceTexture");ke("/materials/{}/extensions/KHR_materials_specular/specularTexture/extensions/KHR_texture_transform/scale",dr.scale),ke("/materials/{}/extensions/KHR_materials_specular/specularTexture/extensions/KHR_texture_transform/offset",dr.offset),ke("/materials/{}/extensions/KHR_materials_specular/specularTexture/extensions/KHR_texture_transform/rotation",dr.rotation);var pr=Xn("reflectanceTexture");ke("/materials/{}/extensions/KHR_materials_specular/specularColorTexture/extensions/KHR_texture_transform/scale",pr.scale),ke("/materials/{}/extensions/KHR_materials_specular/specularColorTexture/extensions/KHR_texture_transform/offset",pr.offset),ke("/materials/{}/extensions/KHR_materials_specular/specularColorTexture/extensions/KHR_texture_transform/rotation",pr.rotation),ke("/materials/{}/extensions/KHR_materials_transmission/transmissionFactor",[new Qn(t.Animation.ANIMATIONTYPE_FLOAT,"subSurface.refractionIntensity",Wn,function(){return 1})]);var mr=Xn("subSurface.refractionIntensityTexture");ke("/materials/{}/extensions/KHR_materials_transmission/transmissionTexture/extensions/KHR_texture_transform/scale",mr.scale),ke("/materials/{}/extensions/KHR_materials_transmission/transmissionTexture/extensions/KHR_texture_transform/offset",mr.offset),ke("/materials/{}/extensions/KHR_materials_transmission/transmissionTexture/extensions/KHR_texture_transform/rotation",mr.rotation),ke("/materials/{}/extensions/KHR_materials_volume/attenuationColor",[new Qn(t.Animation.ANIMATIONTYPE_COLOR3,"subSurface.tintColor",Un,function(){return 3})]),ke("/materials/{}/extensions/KHR_materials_volume/attenuationDistance",[new Qn(t.Animation.ANIMATIONTYPE_FLOAT,"subSurface.tintColorAtDistance",Wn,function(){return 1})]),ke("/materials/{}/extensions/KHR_materials_volume/thicknessFactor",[new Qn(t.Animation.ANIMATIONTYPE_FLOAT,"subSurface.maximumThickness",Wn,function(){return 1})]);var _r=Xn("subSurface.thicknessTexture");ke("/materials/{}/extensions/KHR_materials_volume/thicknessTexture/extensions/KHR_texture_transform/scale",_r.scale),ke("/materials/{}/extensions/KHR_materials_volume/thicknessTexture/extensions/KHR_texture_transform/offset",_r.offset),ke("/materials/{}/extensions/KHR_materials_volume/thicknessTexture/extensions/KHR_texture_transform/rotation",_r.rotation),ke("/materials/{}/extensions/KHR_materials_diffuse_transmission/diffuseTransmissionFactor",[new Qn(t.Animation.ANIMATIONTYPE_FLOAT,"subSurface.translucencyIntensity",Wn,function(){return 1})]);var gr=Xn("subSurface.translucencyIntensityTexture");ke("materials/{}/extensions/KHR_materials_diffuse_transmission/diffuseTransmissionTexture/extensions/KHR_texture_transform/scale",gr.scale),ke("materials/{}/extensions/KHR_materials_diffuse_transmission/diffuseTransmissionTexture/extensions/KHR_texture_transform/offset",gr.offset),ke("materials/{}/extensions/KHR_materials_diffuse_transmission/diffuseTransmissionTexture/extensions/KHR_texture_transform/rotation",gr.rotation),ke("/materials/{}/extensions/KHR_materials_diffuse_transmission/diffuseTransmissionColorFactor",[new Qn(t.Animation.ANIMATIONTYPE_COLOR3,"subSurface.translucencyColor",Un,function(){return 3})]);var br=Xn("subSurface.translucencyColorTexture");ke("materials/{}/extensions/KHR_materials_diffuse_transmission/diffuseTransmissionColorTexture/extensions/KHR_texture_transform/scale",br.scale),ke("materials/{}/extensions/KHR_materials_diffuse_transmission/diffuseTransmissionColorTexture/extensions/KHR_texture_transform/offset",br.offset),ke("materials/{}/extensions/KHR_materials_diffuse_transmission/diffuseTransmissionColorTexture/extensions/KHR_texture_transform/rotation",br.rotation),ke("/extensions/KHR_lights_punctual/lights/{}/color",[new Zn(t.Animation.ANIMATIONTYPE_COLOR3,"diffuse",Un,function(){return 3})]),ke("/extensions/KHR_lights_punctual/lights/{}/intensity",[new Zn(t.Animation.ANIMATIONTYPE_FLOAT,"intensity",Wn,function(){return 1})]),ke("/extensions/KHR_lights_punctual/lights/{}/range",[new Zn(t.Animation.ANIMATIONTYPE_FLOAT,"range",Wn,function(){return 1})]),ke("/extensions/KHR_lights_punctual/lights/{}/spot/innerConeAngle",[new Zn(t.Animation.ANIMATIONTYPE_FLOAT,"innerAngle",Yn,function(){return 1})]),ke("/extensions/KHR_lights_punctual/lights/{}/spot/outerConeAngle",[new Zn(t.Animation.ANIMATIONTYPE_FLOAT,"angle",Yn,function(){return 1})]),ke("/extensions/EXT_lights_area/lights/{}/color",[new Zn(t.Animation.ANIMATIONTYPE_COLOR3,"diffuse",Un,function(){return 3})]),ke("/extensions/EXT_lights_area/lights/{}/intensity",[new Zn(t.Animation.ANIMATIONTYPE_FLOAT,"intensity",Wn,function(){return 1})]),ke("/extensions/EXT_lights_area/lights/{}/size",[new Zn(t.Animation.ANIMATIONTYPE_FLOAT,"radius",Wn,function(){return 1})]),ke("/extensions/EXT_lights_area/lights/{}/rect/aspect",[new Zn(t.Animation.ANIMATIONTYPE_FLOAT,"radius",Wn,function(){return 1})]),ke("/nodes/{}/extensions/EXT_lights_ies/color",[new Zn(t.Animation.ANIMATIONTYPE_COLOR3,"diffuse",Un,function(){return 3})]),ke("/nodes/{}/extensions/EXT_lights_ies/multiplier",[new Zn(t.Animation.ANIMATIONTYPE_FLOAT,"intensity",Wn,function(){return 1})]),ke("/nodes/{}/extensions/KHR_node_visibility/visible",[new $n(t.Animation.ANIMATIONTYPE_FLOAT,"isVisible",Wn,function(){return 1})]);var yr="KHR_animation_pointer",vr=function(){function e(e){this.name=yr,this._loader=e,this._pathToObjectConverter=Ie(this._loader.gltf)}return Object.defineProperty(e.prototype,"enabled",{get:function(){return this._loader.isExtensionUsed(yr)},enumerable:!1,configurable:!0}),e.prototype.dispose=function(){this._loader=null,delete this._pathToObjectConverter},e.prototype._loadAnimationChannelAsync=function(e,n,r,o,a){var i,s=null===(i=o.target.extensions)||void 0===i?void 0:i.KHR_animation_pointer;if(!s||!this._pathToObjectConverter)return null;"pointer"!==o.target.path&&t.Logger.Warn("".concat(e,"/target/path: Value (").concat(o.target.path,") must be (").concat("pointer",") when using the ").concat(this.name," extension")),null!=o.target.node&&t.Logger.Warn("".concat(e,"/target/node: Value (").concat(o.target.node,") must not be present when using the ").concat(this.name," extension"));var l="".concat(e,"/extensions/").concat(this.name),u=s.pointer;if(!u)throw new Error("".concat(l,": Pointer is missing"));try{var c=this._pathToObjectConverter.convert(u);if(!c.info.interpolation)throw new Error("".concat(l,"/pointer: Interpolation is missing"));return this._loader._loadAnimationChannelFromTargetInfoAsync(e,n,r,o,{object:c.object,info:c.info.interpolation},a)}catch(e){return t.Logger.Warn("".concat(l,"/pointer: Invalid pointer (").concat(u,") skipped")),null}},e}();we(yr),Ae(yr,!0,function(e){return new vr(e)});var Tr={__proto__:null,KHR_animation_pointer:vr},xr="MSFT_audio_emitter",Ar=function(){function e(e){this.name=xr,this._loader=e,this.enabled=this._loader.isExtensionUsed(xr)}return e.prototype.dispose=function(){this._loader=null,this._clips=null,this._emitters=null},e.prototype.onLoading=function(){var e=this._loader.gltf.extensions;if(e&&e[this.name]){var t=e[this.name];this._clips=t.clips,this._emitters=t.emitters,He.Assign(this._clips),He.Assign(this._emitters)}},e.prototype.loadSceneAsync=function(e,t){var n=this;return je.LoadExtensionAsync(e,t,this.name,function(r,o){return g(n,void 0,void 0,function(){var n,a,i,s,l;return b(this,function(u){switch(u.label){case 0:for((n=new Array).push(this._loader.loadSceneAsync(e,t)),a=0,i=o.emitters;a<i.length;a++){if(s=i[a],null!=(l=He.Get("".concat(r,"/emitters"),this._emitters,s)).refDistance||null!=l.maxDistance||null!=l.rolloffFactor||null!=l.distanceModel||null!=l.innerAngle||null!=l.outerAngle)throw new Error("".concat(r,": Direction or Distance properties are not allowed on emitters attached to a scene"));n.push(this._loadEmitterAsync("".concat(r,"/emitters/").concat(l.index),l))}return[4,Promise.all(n)];case 1:return u.sent(),[2]}})})})},e.prototype.loadNodeAsync=function(e,n,r){var o=this;return je.LoadExtensionAsync(e,n,this.name,function(e,a){return g(o,void 0,void 0,function(){var o,i,s=this;return b(this,function(l){switch(l.label){case 0:return o=new Array,[4,this._loader.loadNodeAsync(e,n,function(n){for(var i=function(r){var a=He.Get("".concat(e,"/emitters"),s._emitters,r);o.push(s._loadEmitterAsync("".concat(e,"/emitters/").concat(a.index),a).then(function(){for(var e=0,r=a._babylonSounds;e<r.length;e++){var o=r[e];o.attachToMesh(n),null==a.innerAngle&&null==a.outerAngle||(o.setLocalDirectionToMesh(t.Vector3.Forward()),o.setDirectionalCone(2*t.Tools.ToDegrees(null==a.innerAngle?Math.PI:a.innerAngle),2*t.Tools.ToDegrees(null==a.outerAngle?Math.PI:a.outerAngle),0))}}))},l=0,u=a.emitters;l<u.length;l++)i(u[l]);r(n)})];case 1:return i=l.sent(),[4,Promise.all(o)];case 2:return l.sent(),[2,i]}})})})},e.prototype.loadAnimationAsync=function(e,t){var n=this;return je.LoadExtensionAsync(e,t,this.name,function(r,o){return g(n,void 0,void 0,function(){var n,a,i,s,l;return b(this,function(u){switch(u.label){case 0:return[4,this._loader.loadAnimationAsync(e,t)];case 1:for(n=u.sent(),a=new Array,He.Assign(o.events),i=0,s=o.events;i<s.length;i++)l=s[i],a.push(this._loadAnimationEventAsync("".concat(r,"/events/").concat(l.index),e,t,l,n));return[4,Promise.all(a)];case 2:return u.sent(),[2,n]}})})})},e.prototype._loadClipAsync=function(e,n){if(n._objectURL)return n._objectURL;var r;if(n.uri)r=this._loader.loadUriAsync(e,n,n.uri);else{var o=He.Get("".concat(e,"/bufferView"),this._loader.gltf.bufferViews,n.bufferView);r=this._loader.loadBufferViewAsync("/bufferViews/".concat(o.index),o)}return n._objectURL=r.then(function(e){var r=t.GetBlobBufferSource(e);return URL.createObjectURL(new Blob([r],{type:n.mimeType}))}),n._objectURL},e.prototype._loadEmitterAsync=function(e,n){var r=this;if(n._babylonSounds=n._babylonSounds||[],!n._babylonData){for(var o=new Array,a=n.name||"emitter".concat(n.index),i={loop:!1,autoplay:!1,volume:null==n.volume?1:n.volume},s=function(e){var s="/extensions/".concat(l.name,"/clips"),u=He.Get(s,l._clips,n.clips[e].clip);o.push(l._loadClipAsync("".concat(s,"/").concat(n.clips[e].clip),u).then(function(o){var s=n._babylonSounds[e]=new t.Sound(a,o,r._loader.babylonScene,null,i);s.refDistance=n.refDistance||1,s.maxDistance=n.maxDistance||256,s.rolloffFactor=n.rolloffFactor||1,s.distanceModel=n.distanceModel||"exponential"}))},l=this,u=0;u<n.clips.length;u++)s(u);var c=Promise.all(o).then(function(){var e=n.clips.map(function(e){return e.weight||1}),r=new t.WeightedSound(n.loop||!1,n._babylonSounds,e);n.innerAngle&&(r.directionalConeInnerAngle=2*t.Tools.ToDegrees(n.innerAngle)),n.outerAngle&&(r.directionalConeOuterAngle=2*t.Tools.ToDegrees(n.outerAngle)),n.volume&&(r.volume=n.volume),n._babylonData.sound=r});n._babylonData={loaded:c}}return n._babylonData.loaded},e.prototype._getEventAction=function(e,t,n,r,o){switch(n){case"play":return function(e){var n=(o||0)+(e-r);t.play(n)};case"stop":return function(){t.stop()};case"pause":return function(){t.pause()};default:throw new Error("".concat(e,": Unsupported action ").concat(n))}},e.prototype._loadAnimationEventAsync=function(e,n,r,o,a){var i=this;if(0==a.targetedAnimations.length)return Promise.resolve();var s=a.targetedAnimations[0],l=o.emitter,u=He.Get("/extensions/".concat(this.name,"/emitters"),this._emitters,l);return this._loadEmitterAsync(e,u).then(function(){var n=u._babylonData.sound;if(n){var r=new t.AnimationEvent(o.time,i._getEventAction(e,n,o.action,o.time,o.startOffset));s.animation.addEvent(r),a.onAnimationGroupEndObservable.add(function(){n.stop()}),a.onAnimationGroupPauseObservable.add(function(){n.pause()})}})},e}();we(xr),Ae(xr,!0,function(e){return new Ar(e)});var wr={__proto__:null,MSFT_audio_emitter:Ar},Or="MSFT_lod",Cr=function(){function e(e){var n,r;this.name=Or,this.order=100,this.maxLODsToLoad=10,this.onNodeLODsLoadedObservable=new t.Observable,this.onMaterialLODsLoadedObservable=new t.Observable,this._bufferLODs=new Array,this._nodeIndexLOD=null,this._nodeSignalLODs=new Array,this._nodePromiseLODs=new Array,this._nodeBufferLODs=new Array,this._materialIndexLOD=null,this._materialSignalLODs=new Array,this._materialPromiseLODs=new Array,this._materialBufferLODs=new Array,this._loader=e,this.maxLODsToLoad=null!==(r=null===(n=this._loader.parent.extensionOptions[Or])||void 0===n?void 0:n.maxLODsToLoad)&&void 0!==r?r:this.maxLODsToLoad,this.enabled=this._loader.isExtensionUsed(Or)}return e.prototype.dispose=function(){this._loader=null,this._nodeIndexLOD=null,this._nodeSignalLODs.length=0,this._nodePromiseLODs.length=0,this._nodeBufferLODs.length=0,this._materialIndexLOD=null,this._materialSignalLODs.length=0,this._materialPromiseLODs.length=0,this._materialBufferLODs.length=0,this.onMaterialLODsLoadedObservable.clear(),this.onNodeLODsLoadedObservable.clear()},e.prototype.onReady=function(){for(var e=this,t=function(t){var r=Promise.all(n._nodePromiseLODs[t]).then(function(){0!==t&&(e._loader.endPerformanceCounter("Node LOD ".concat(t)),e._loader.log("Loaded node LOD ".concat(t))),e.onNodeLODsLoadedObservable.notifyObservers(t),t!==e._nodePromiseLODs.length-1&&(e._loader.startPerformanceCounter("Node LOD ".concat(t+1)),e._loadBufferLOD(e._nodeBufferLODs,t+1),e._nodeSignalLODs[t]&&e._nodeSignalLODs[t].resolve())});n._loader._completePromises.push(r)},n=this,r=0;r<this._nodePromiseLODs.length;r++)t(r);var o=function(t){var n=Promise.all(a._materialPromiseLODs[t]).then(function(){0!==t&&(e._loader.endPerformanceCounter("Material LOD ".concat(t)),e._loader.log("Loaded material LOD ".concat(t))),e.onMaterialLODsLoadedObservable.notifyObservers(t),t!==e._materialPromiseLODs.length-1&&(e._loader.startPerformanceCounter("Material LOD ".concat(t+1)),e._loadBufferLOD(e._materialBufferLODs,t+1),e._materialSignalLODs[t]&&e._materialSignalLODs[t].resolve())});a._loader._completePromises.push(n)},a=this;for(r=0;r<this._materialPromiseLODs.length;r++)o(r)},e.prototype.loadSceneAsync=function(e,t){var n=this._loader.loadSceneAsync(e,t);return this._loadBufferLOD(this._bufferLODs,0),n},e.prototype.loadNodeAsync=function(e,n,r){var o=this;return je.LoadExtensionAsync(e,n,this.name,function(e,a){return g(o,void 0,void 0,function(){var o,i,s,l,u,c=this;return b(this,function(f){switch(f.label){case 0:for(i=this._getLODs(e,n,this._loader.gltf.nodes,a.ids),this._loader.logOpen("".concat(e)),s=function(e){var n=i[e];0!==e&&(l._nodeIndexLOD=e,l._nodeSignalLODs[e]=l._nodeSignalLODs[e]||new t.Deferred);var a=l._loader.loadNodeAsync("/nodes/".concat(n.index),n,function(e){r(e),e.setEnabled(!1)}).then(function(t){if(0!==e){var n=i[e-1];n._babylonTransformNode&&(c._disposeTransformNode(n._babylonTransformNode),delete n._babylonTransformNode)}return t.setEnabled(!0),t});l._nodePromiseLODs[e]=l._nodePromiseLODs[e]||[],0===e?o=a:(l._nodeIndexLOD=null,l._nodePromiseLODs[e].push(a))},l=this,u=0;u<i.length;u++)s(u);return this._loader.logClose(),[4,o];case 1:return[2,f.sent()]}})})})},e.prototype._loadMaterialAsync=function(e,t,n,r,o){var a=this;return this._nodeIndexLOD?null:je.LoadExtensionAsync(e,t,this.name,function(e,i){return g(a,void 0,void 0,function(){var a,s,l,u,c,f=this;return b(this,function(h){switch(h.label){case 0:for(s=this._getLODs(e,t,this._loader.gltf.materials,i.ids),this._loader.logOpen("".concat(e)),l=function(e){var t=s[e];0!==e&&(u._materialIndexLOD=e);var i=u._loader._loadMaterialAsync("/materials/".concat(t.index),t,n,r,function(t){0===e&&o(t)}).then(function(t){if(0!==e){o(t);var n=s[e-1]._data;n[r]&&(f._disposeMaterials([n[r].babylonMaterial]),delete n[r])}return t});u._materialPromiseLODs[e]=u._materialPromiseLODs[e]||[],0===e?a=i:(u._materialIndexLOD=null,u._materialPromiseLODs[e].push(i))},u=this,c=0;c<s.length;c++)l(c);return this._loader.logClose(),[4,a];case 1:return[2,h.sent()]}})})})},e.prototype._loadUriAsync=function(e,n,r){var o=this;if(null!==this._nodeIndexLOD){this._loader.log("deferred");var a=this._nodeIndexLOD-1;return this._nodeSignalLODs[a]=this._nodeSignalLODs[a]||new t.Deferred,this._nodeSignalLODs[this._nodeIndexLOD-1].promise.then(function(){return g(o,void 0,void 0,function(){return b(this,function(t){switch(t.label){case 0:return[4,this._loader.loadUriAsync(e,n,r)];case 1:return[2,t.sent()]}})})})}return null!==this._materialIndexLOD?(this._loader.log("deferred"),a=this._materialIndexLOD-1,this._materialSignalLODs[a]=this._materialSignalLODs[a]||new t.Deferred,this._materialSignalLODs[a].promise.then(function(){return g(o,void 0,void 0,function(){return b(this,function(t){switch(t.label){case 0:return[4,this._loader.loadUriAsync(e,n,r)];case 1:return[2,t.sent()]}})})})):null},e.prototype.loadBufferAsync=function(e,n,r,o){var a=this;if(this._loader.parent.useRangeRequests&&!n.uri){if(!this._loader.bin)throw new Error("".concat(e,": Uri is missing or the binary glTF is missing its binary chunk"));var i=function(e,n){return g(a,void 0,void 0,function(){var a,i,s;return b(this,function(l){switch(l.label){case 0:return i=(a=r)+o-1,(s=e[n])?(s.start=Math.min(s.start,a),s.end=Math.max(s.end,i)):(s={start:a,end:i,loaded:new t.Deferred},e[n]=s),[4,s.loaded.promise.then(function(e){return new Uint8Array(e.buffer,e.byteOffset+r-s.start,o)})];case 1:return[2,l.sent()]}})})};return this._loader.log("deferred"),null!==this._nodeIndexLOD?i(this._nodeBufferLODs,this._nodeIndexLOD):null!==this._materialIndexLOD?i(this._materialBufferLODs,this._materialIndexLOD):i(this._bufferLODs,0)}return null},e.prototype._loadBufferLOD=function(e,t){var n=e[t];n&&(this._loader.log("Loading buffer range [".concat(n.start,"-").concat(n.end,"]")),this._loader.bin.readAsync(n.start,n.end-n.start+1).then(function(e){n.loaded.resolve(e)},function(e){n.loaded.reject(e)}))},e.prototype._getLODs=function(e,t,n,r){if(this.maxLODsToLoad<=0)throw new Error("maxLODsToLoad must be greater than zero");for(var o=[],a=r.length-1;a>=0;a--)if(o.push(He.Get("".concat(e,"/ids/").concat(r[a]),n,r[a])),o.length===this.maxLODsToLoad)return o;return o.push(t),o},e.prototype._disposeTransformNode=function(e){var t=this,n=[],r=e.material;r&&n.push(r);for(var o=0,a=e.getChildMeshes();o<a.length;o++){var i=a[o];i.material&&n.push(i.material)}e.dispose();var s=n.filter(function(e){return t._loader.babylonScene.meshes.every(function(t){return t.material!=e})});this._disposeMaterials(s)},e.prototype._disposeMaterials=function(e){for(var t={},n=0,r=e;n<r.length;n++){for(var o=0,a=(c=r[n]).getActiveTextures();o<a.length;o++){var i=a[o];t[i.uniqueId]=i}c.dispose()}for(var s in t)for(var l=0,u=this._loader.babylonScene.materials;l<u.length;l++){var c;(c=u[l]).hasTexture(t[s])&&delete t[s]}for(var s in t)t[s].dispose()},e}();we(Or),Ae(Or,!0,function(e){return new Cr(e)});var Mr={__proto__:null,MSFT_lod:Cr},Er="MSFT_minecraftMesh",Rr=function(){function e(e){this.name=Er,this._loader=e,this.enabled=this._loader.isExtensionUsed(Er)}return e.prototype.dispose=function(){this._loader=null},e.prototype.loadMaterialPropertiesAsync=function(e,t,n){var r=this;return je.LoadExtraAsync(e,t,this.name,function(o,a){return g(r,void 0,void 0,function(){var r;return b(this,function(i){switch(i.label){case 0:if(!a)return[3,2];if(!this._loader._pbrMaterialImpls.get("pbr"))throw new Error("".concat(o,": Material type not supported"));return r=this._loader.loadMaterialPropertiesAsync(e,t,n),n.needAlphaBlending()&&(n.forceDepthWrite=!0,n.separateCullingPass=!0),n.backFaceCulling=n.forceDepthWrite,n.twoSidedLighting=!0,[4,r];case 1:return[2,i.sent()];case 2:return[2]}})})})},e}();we(Er),Ae(Er,!0,function(e){return new Rr(e)});var Fr={__proto__:null,MSFT_minecraftMesh:Rr},Lr="MSFT_sRGBFactors",Pr=function(){function e(e){this.name=Lr,this._loader=e,this.enabled=this._loader.isExtensionUsed(Lr)}return e.prototype.dispose=function(){this._loader=null},e.prototype.loadMaterialPropertiesAsync=function(e,t,n){var r=this;return je.LoadExtraAsync(e,t,this.name,function(o,a){return g(r,void 0,void 0,function(){var r,o,i;return b(this,function(s){switch(s.label){case 0:return a?(r=this._loader._getOrCreateMaterialAdapter(n),o=this._loader.loadMaterialPropertiesAsync(e,t,n),i=n.getScene().getEngine().useExactSrgbConversions,r.baseColorTexture||r.baseColor.toLinearSpaceToRef(r.baseColor,i),r.specularColorTexture||r.specularColor.toLinearSpaceToRef(r.specularColor,i),[4,o]):[3,2];case 1:return[2,s.sent()];case 2:return[2]}})})})},e}();we(Lr),Ae(Lr,!0,function(e){return new Pr(e)});var Sr={__proto__:null,MSFT_sRGBFactors:Pr};function Nr(e){var t=e.split(":");return Ir({op:t[0],extension:t[1]})}function Ir(e,n){var r;void 0===n&&(n=!0);var o=e.extension?null===(r=kr[e.extension])||void 0===r?void 0:r[e.op]:Gr[e.op];if(!o&&(t.Logger.Warn("No mapping found for operation ".concat(e.op," and extension ").concat(e.extension||"KHR_interactivity")),n)){var a={},i={flows:{}};if(e.inputValueSockets)for(var s in a.values={},e.inputValueSockets)a.values[s]={name:s};return e.outputValueSockets&&(i.values={},Object.keys(e.outputValueSockets).forEach(function(e){i.values[e]={name:e}})),{blocks:[],inputs:a,outputs:i}}return o}function Br(e,t,n){kr[t]||(kr[t]={}),kr[t][e]=n}var kr={BABYLON:{"flow/log":{blocks:["FlowGraphConsoleLogBlock"],inputs:{values:{message:{name:"message"}}}}}},Gr={"event/onStart":{blocks:["FlowGraphSceneReadyEventBlock"],outputs:{flows:{out:{name:"done"}}}},"event/onTick":{blocks:["FlowGraphSceneTickEventBlock"],inputs:{},outputs:{values:{timeSinceLastTick:{name:"deltaTime",gltfType:"number"}},flows:{out:{name:"done"}}}},"event/send":{blocks:["FlowGraphSendCustomEventBlock"],extraProcessor:function(e,t,n,r,o){var a;if("event/send"!==t.op||!e.configuration||1!==Object.keys(e.configuration).length)throw new Error("Receive event should have a single configuration object, the event itself");var i=null===(a=e.configuration.event.value)||void 0===a?void 0:a[0];if("number"!=typeof i)throw new Error("Event id should be a number");var s=r.arrays.events[i],l=o[0];return l.config||(l.config={}),l.config.eventId=s.eventId,l.config.eventData=s.eventData,o}},"event/receive":{blocks:["FlowGraphReceiveCustomEventBlock"],outputs:{flows:{out:{name:"done"}}},validation:function(e,n){var r,o;if(!e.configuration)return t.Logger.Error("Receive event should have a configuration object"),{valid:!1,error:"Receive event should have a configuration object"};var a=e.configuration.event;if(!a)return t.Logger.Error("Receive event should have a single configuration object, the event itself"),{valid:!1,error:"Receive event should have a single configuration object, the event itself"};var i=null===(r=a.value)||void 0===r?void 0:r[0];return"number"!=typeof i?(t.Logger.Error("Event id should be a number"),{valid:!1,error:"Event id should be a number"}):(null===(o=n.events)||void 0===o?void 0:o[i])?{valid:!0}:(t.Logger.Error("Event with id ".concat(i," not found")),{valid:!1,error:"Event with id ".concat(i," not found")})},extraProcessor:function(e,t,n,r,o){var a;if("event/receive"!==t.op||!e.configuration||1!==Object.keys(e.configuration).length)throw new Error("Receive event should have a single configuration object, the event itself");var i=null===(a=e.configuration.event.value)||void 0===a?void 0:a[0];if("number"!=typeof i)throw new Error("Event id should be a number");var s=r.arrays.events[i],l=o[0];return l.config||(l.config={}),l.config.eventId=s.eventId,l.config.eventData=s.eventData,o}},"math/E":Dr("FlowGraphEBlock"),"math/Pi":Dr("FlowGraphPIBlock"),"math/Inf":Dr("FlowGraphInfBlock"),"math/NaN":Dr("FlowGraphNaNBlock"),"math/abs":Dr("FlowGraphAbsBlock"),"math/sign":Dr("FlowGraphSignBlock"),"math/trunc":Dr("FlowGraphTruncBlock"),"math/floor":Dr("FlowGraphFloorBlock"),"math/ceil":Dr("FlowGraphCeilBlock"),"math/round":{blocks:["FlowGraphRoundBlock"],configuration:{},inputs:{values:{a:{name:"a"}}},outputs:{values:{value:{name:"value"}}},extraProcessor:function(e,t,n,r,o){var a;return(a=o[0]).config||(a.config={}),o[0].config.roundHalfAwayFromZero=!0,o}},"math/fract":Dr("FlowGraphFractBlock"),"math/neg":Dr("FlowGraphNegationBlock"),"math/add":Dr("FlowGraphAddBlock",["a","b"],!0),"math/sub":Dr("FlowGraphSubtractBlock",["a","b"],!0),"math/mul":{blocks:["FlowGraphMultiplyBlock"],extraProcessor:function(e,t,n,r,o){var a;(a=o[0]).config||(a.config={}),o[0].config.useMatrixPerComponent=!0,o[0].config.preventIntegerFloatArithmetic=!0;var i=-1;return Object.keys(e.values||{}).find(function(t){var n;return void 0!==(null===(n=e.values)||void 0===n?void 0:n[t].type)&&(i=e.values[t].type,!0)}),-1!==i&&(o[0].config.type=r.arrays.types[i].flowGraphType),o},validation:function(e){return e.values?Vr(e):{valid:!0}}},"math/div":Dr("FlowGraphDivideBlock",["a","b"],!0),"math/rem":Dr("FlowGraphModuloBlock",["a","b"]),"math/min":Dr("FlowGraphMinBlock",["a","b"]),"math/max":Dr("FlowGraphMaxBlock",["a","b"]),"math/clamp":Dr("FlowGraphClampBlock",["a","b","c"]),"math/saturate":Dr("FlowGraphSaturateBlock"),"math/mix":Dr("FlowGraphMathInterpolationBlock",["a","b","c"]),"math/eq":Dr("FlowGraphEqualityBlock",["a","b"]),"math/lt":Dr("FlowGraphLessThanBlock",["a","b"]),"math/le":Dr("FlowGraphLessThanOrEqualBlock",["a","b"]),"math/gt":Dr("FlowGraphGreaterThanBlock",["a","b"]),"math/ge":Dr("FlowGraphGreaterThanOrEqualBlock",["a","b"]),"math/isNaN":Dr("FlowGraphIsNaNBlock"),"math/isInf":Dr("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":Dr("FlowGraphSinBlock"),"math/cos":Dr("FlowGraphCosBlock"),"math/tan":Dr("FlowGraphTanBlock"),"math/asin":Dr("FlowGraphASinBlock"),"math/acos":Dr("FlowGraphACosBlock"),"math/atan":Dr("FlowGraphATanBlock"),"math/atan2":Dr("FlowGraphATan2Block",["a","b"]),"math/sinh":Dr("FlowGraphSinhBlock"),"math/cosh":Dr("FlowGraphCoshBlock"),"math/tanh":Dr("FlowGraphTanhBlock"),"math/asinh":Dr("FlowGraphASinhBlock"),"math/acosh":Dr("FlowGraphACoshBlock"),"math/atanh":Dr("FlowGraphATanhBlock"),"math/exp":Dr("FlowGraphExponentialBlock"),"math/log":Dr("FlowGraphLogBlock"),"math/log2":Dr("FlowGraphLog2Block"),"math/log10":Dr("FlowGraphLog10Block"),"math/sqrt":Dr("FlowGraphSquareRootBlock"),"math/cbrt":Dr("FlowGraphCubeRootBlock"),"math/pow":Dr("FlowGraphPowerBlock",["a","b"]),"math/length":Dr("FlowGraphLengthBlock"),"math/normalize":Dr("FlowGraphNormalizeBlock"),"math/dot":Dr("FlowGraphDotBlock",["a","b"]),"math/cross":Dr("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":Dr("FlowGraphTransposeBlock"),"math/determinant":Dr("FlowGraphDeterminantBlock"),"math/inverse":Dr("FlowGraphInvertMatrixBlock"),"math/matMul":Dr("FlowGraphMatrixMultiplicationBlock",["a","b"]),"math/matCompose":{blocks:["FlowGraphMatrixCompose"],inputs:{values:{translation:{name:"position",gltfType:"float3"},rotation:{name:"rotationQuaternion",gltfType:"float4"},scale:{name:"scaling",gltfType:"float3"}}},outputs:{values:{value:{name:"value"}}},extraProcessor:function(e,t,n,r,o,a){var i=o[0].dataInputs.find(function(e){return"rotationQuaternion"===e.name});if(!i)throw new Error("Rotation quaternion input not found");return a._connectionValues[i.uniqueId]&&(a._connectionValues[i.uniqueId].type="Quaternion"),o}},"math/matDecompose":{blocks:["FlowGraphMatrixDecompose"],inputs:{values:{a:{name:"input",gltfType:"number"}}},outputs:{values:{translation:{name:"position"},rotation:{name:"rotationQuaternion"},scale:{name:"scaling"}}}},"math/quatConjugate":Dr("FlowGraphConjugateBlock",["a"]),"math/quatMul":{blocks:["FlowGraphMultiplyBlock"],inputs:{values:{a:{name:"a",gltfType:"vector4"},b:{name:"b",gltfType:"vector4"}}},outputs:{values:{value:{name:"value"}}},extraProcessor:function(e,t,n,r,o){var a;return(a=o[0]).config||(a.config={}),o[0].config.type="Quaternion",o}},"math/quatAngleBetween":Dr("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":Dr("FlowGraphAxisAngleFromQuaternionBlock",["a"]),"math/quatFromDirections":Dr("FlowGraphQuaternionFromDirectionsBlock",["a","b"]),"math/combine2x2":{blocks:["FlowGraphCombineMatrix2DBlock"],inputs:{values:{a:{name:"input_0",gltfType:"number"},b:{name:"input_1",gltfType:"number"},c:{name:"input_2",gltfType:"number"},d:{name:"input_3",gltfType:"number"}}},outputs:{values:{value:{name:"value"}}},extraProcessor:function(e,t,n,r,o){var a;return(a=o[0]).config||(a.config={}),o[0].config.inputIsColumnMajor=!0,o}},"math/extract2x2":{blocks:["FlowGraphExtractMatrix2DBlock"],inputs:{values:{a:{name:"input",gltfType:"float2x2"}}},outputs:{values:{0:{name:"output_0"},1:{name:"output_1"},2:{name:"output_2"},3:{name:"output_3"}}}},"math/combine3x3":{blocks:["FlowGraphCombineMatrix3DBlock"],inputs:{values:{a:{name:"input_0",gltfType:"number"},b:{name:"input_1",gltfType:"number"},c:{name:"input_2",gltfType:"number"},d:{name:"input_3",gltfType:"number"},e:{name:"input_4",gltfType:"number"},f:{name:"input_5",gltfType:"number"},g:{name:"input_6",gltfType:"number"},h:{name:"input_7",gltfType:"number"},i:{name:"input_8",gltfType:"number"}}},outputs:{values:{value:{name:"value"}}},extraProcessor:function(e,t,n,r,o){var a;return(a=o[0]).config||(a.config={}),o[0].config.inputIsColumnMajor=!0,o}},"math/extract3x3":{blocks:["FlowGraphExtractMatrix3DBlock"],inputs:{values:{a:{name:"input",gltfType:"float3x3"}}},outputs:{values:{0:{name:"output_0"},1:{name:"output_1"},2:{name:"output_2"},3:{name:"output_3"},4:{name:"output_4"},5:{name:"output_5"},6:{name:"output_6"},7:{name:"output_7"},8:{name:"output_8"}}}},"math/combine4x4":{blocks:["FlowGraphCombineMatrixBlock"],inputs:{values:{a:{name:"input_0",gltfType:"number"},b:{name:"input_1",gltfType:"number"},c:{name:"input_2",gltfType:"number"},d:{name:"input_3",gltfType:"number"},e:{name:"input_4",gltfType:"number"},f:{name:"input_5",gltfType:"number"},g:{name:"input_6",gltfType:"number"},h:{name:"input_7",gltfType:"number"},i:{name:"input_8",gltfType:"number"},j:{name:"input_9",gltfType:"number"},k:{name:"input_10",gltfType:"number"},l:{name:"input_11",gltfType:"number"},m:{name:"input_12",gltfType:"number"},n:{name:"input_13",gltfType:"number"},o:{name:"input_14",gltfType:"number"},p:{name:"input_15",gltfType:"number"}}},outputs:{values:{value:{name:"value"}}},extraProcessor:function(e,t,n,r,o){var a;return(a=o[0]).config||(a.config={}),o[0].config.inputIsColumnMajor=!0,o}},"math/extract4x4":{blocks:["FlowGraphExtractMatrixBlock"],configuration:{},inputs:{values:{a:{name:"input",gltfType:"number"}}},outputs:{values:{0:{name:"output_0"},1:{name:"output_1"},2:{name:"output_2"},3:{name:"output_3"},4:{name:"output_4"},5:{name:"output_5"},6:{name:"output_6"},7:{name:"output_7"},8:{name:"output_8"},9:{name:"output_9"},10:{name:"output_10"},11:{name:"output_11"},12:{name:"output_12"},13:{name:"output_13"},14:{name:"output_14"},15:{name:"output_15"}}}},"math/not":{blocks:["FlowGraphBitwiseNotBlock"],inputs:{values:{a:{name:"a"}}},outputs:{values:{value:{name:"value"}}},extraProcessor:function(e,t,n,r,o,a){var i,s,l;(l=o[0]).config||(l.config={});var u=o[0].dataInputs[0];return o[0].config.valueType=null!==(s=null===(i=a._connectionValues[u.uniqueId])||void 0===i?void 0:i.type)&&void 0!==s?s:"FlowGraphInteger",o}},"math/and":{blocks:["FlowGraphBitwiseAndBlock"],inputs:{values:{a:{name:"a"},b:{name:"b"}}},outputs:{values:{value:{name:"value"}}},extraProcessor:function(e,t,n,r,o,a){var i,s,l,u,c;(c=o[0]).config||(c.config={});var f=o[0].dataInputs[0],h=o[0].dataInputs[1];return o[0].config.valueType=null!==(u=null!==(s=null===(i=a._connectionValues[f.uniqueId])||void 0===i?void 0:i.type)&&void 0!==s?s:null===(l=a._connectionValues[h.uniqueId])||void 0===l?void 0:l.type)&&void 0!==u?u:"FlowGraphInteger",o}},"math/or":{blocks:["FlowGraphBitwiseOrBlock"],inputs:{values:{a:{name:"a"},b:{name:"b"}}},outputs:{values:{value:{name:"value"}}},extraProcessor:function(e,t,n,r,o,a){var i,s,l,u,c;(c=o[0]).config||(c.config={});var f=o[0].dataInputs[0],h=o[0].dataInputs[1];return o[0].config.valueType=null!==(u=null!==(s=null===(i=a._connectionValues[f.uniqueId])||void 0===i?void 0:i.type)&&void 0!==s?s:null===(l=a._connectionValues[h.uniqueId])||void 0===l?void 0:l.type)&&void 0!==u?u:"FlowGraphInteger",o}},"math/xor":{blocks:["FlowGraphBitwiseXorBlock"],inputs:{values:{a:{name:"a"},b:{name:"b"}}},outputs:{values:{value:{name:"value"}}},extraProcessor:function(e,t,n,r,o,a){var i,s,l,u,c;(c=o[0]).config||(c.config={});var f=o[0].dataInputs[0],h=o[0].dataInputs[1];return o[0].config.valueType=null!==(u=null!==(s=null===(i=a._connectionValues[f.uniqueId])||void 0===i?void 0:i.type)&&void 0!==s?s:null===(l=a._connectionValues[h.uniqueId])||void 0===l?void 0:l.type)&&void 0!==u?u:"FlowGraphInteger",o}},"math/asr":Dr("FlowGraphBitwiseRightShiftBlock",["a","b"]),"math/lsl":Dr("FlowGraphBitwiseLeftShiftBlock",["a","b"]),"math/clz":Dr("FlowGraphLeadingZerosBlock"),"math/ctz":Dr("FlowGraphTrailingZerosBlock"),"math/popcnt":Dr("FlowGraphOneBitsCounterBlock"),"math/rad":Dr("FlowGraphDegToRadBlock"),"math/deg":Dr("FlowGraphRadToDegBlock"),"type/boolToInt":Dr("FlowGraphBooleanToInt"),"type/boolToFloat":Dr("FlowGraphBooleanToFloat"),"type/intToBool":Dr("FlowGraphIntToBoolean"),"type/intToFloat":Dr("FlowGraphIntToFloat"),"type/floatToInt":Dr("FlowGraphFloatToInt"),"type/floatToBool":Dr("FlowGraphFloatToBoolean"),"flow/sequence":{blocks:["FlowGraphSequenceBlock"],extraProcessor:function(e,t,n,r,o){var a=o[0];return a.config||(a.config={}),a.config.outputSignalCount=Object.keys(e.flows||[]).length,a.signalOutputs.forEach(function(e,t){e.name="out_"+t}),o}},"flow/branch":{blocks:["FlowGraphBranchBlock"],outputs:{flows:{true:{name:"onTrue"},false:{name:"onFalse"}}}},"flow/switch":{blocks:["FlowGraphSwitchBlock"],configuration:{cases:{name:"cases",isArray:!0,inOptions:!0,defaultValue:[]}},inputs:{values:{selection:{name:"case"},default:{name:"default"}}},validation:function(e){var n,r=null===(n=e.configuration)||void 0===n?void 0:n.cases;if(r&&r.value){if(!r.value.every(function(e){return"number"==typeof e&&/^-?\d+$/.test(e.toString())}))return t.Logger.Warn("Switch cases should be integers. Using empty array instead."),r.value=[],{valid:!0};var o=new Set(r.value);r.value=Array.from(o)}return{valid:!0}},extraProcessor:function(e,t,n,r,o){if("flow/switch"!==t.op||!e.flows||0===Object.keys(e.flows).length)throw new Error("Switch should have a single configuration object, the cases array");return o[0].signalOutputs.forEach(function(e){"default"!==e.name&&(e.name="out_"+e.name)}),o}},"flow/while":{blocks:["FlowGraphWhileLoopBlock"],outputs:{flows:{loopBody:{name:"executionFlow"}}}},"flow/for":{blocks:["FlowGraphForLoopBlock"],configuration:{initialIndex:{name:"initialIndex",gltfType:"number",inOptions:!0,defaultValue:0}},inputs:{values:{startIndex:{name:"startIndex",gltfType:"number"},endIndex:{name:"endIndex",gltfType:"number"}}},outputs:{values:{index:{name:"index"}},flows:{loopBody:{name:"executionFlow"}}},extraProcessor:function(e,t,n,r,o){var a=o[0];return a.config||(a.config={}),a.config.incrementIndexWhenLoopDone=!0,o}},"flow/doN":{blocks:["FlowGraphDoNBlock"],configuration:{},inputs:{values:{n:{name:"maxExecutions",gltfType:"number"}}},outputs:{values:{currentCount:{name:"executionCount"}}}},"flow/multiGate":{blocks:["FlowGraphMultiGateBlock"],configuration:{isRandom:{name:"isRandom",gltfType:"boolean",inOptions:!0,defaultValue:!1},isLoop:{name:"isLoop",gltfType:"boolean",inOptions:!0,defaultValue:!1}},extraProcessor:function(e,t,n,r,o){if("flow/multiGate"!==t.op||!e.flows||0===Object.keys(e.flows).length)throw new Error("MultiGate should have a single configuration object, the number of output flows");var a=o[0];return a.config||(a.config={}),a.config.outputSignalCount=Object.keys(e.flows).length,a.signalOutputs.forEach(function(e,t){e.name="out_"+t}),o}},"flow/waitAll":{blocks:["FlowGraphWaitAllBlock"],configuration:{inputFlows:{name:"inputSignalCount",gltfType:"number",inOptions:!0,defaultValue:0}},inputs:{flows:{reset:{name:"reset"},"[segment]":{name:"in_$1"}}},validation:function(e){var t,n,r;return"number"!=typeof(null===(r=null===(n=null===(t=e.configuration)||void 0===t?void 0:t.inputFlows)||void 0===n?void 0:n.value)||void 0===r?void 0:r[0])&&(e.configuration=e.configuration||{inputFlows:{value:[0]}},e.configuration.inputFlows.value=[0]),{valid:!0}}},"flow/throttle":{blocks:["FlowGraphThrottleBlock"],outputs:{flows:{err:{name:"error"}}}},"flow/setDelay":{blocks:["FlowGraphSetDelayBlock"],outputs:{flows:{err:{name:"error"}}}},"flow/cancelDelay":{blocks:["FlowGraphCancelDelayBlock"]},"variable/get":{blocks:["FlowGraphGetVariableBlock"],validation:function(e){var n,r;return(null===(r=null===(n=e.configuration)||void 0===n?void 0:n.variable)||void 0===r?void 0:r.value)?{valid:!0}:(t.Logger.Error("Variable get block should have a variable configuration"),{valid:!1,error:"Variable get block should have a variable configuration"})},configuration:{variable:{name:"variable",gltfType:"number",flowGraphType:"string",inOptions:!0,isVariable:!0,dataTransformer:function(e,t){return t.getVariableName(e)}}}},"variable/set":{blocks:["FlowGraphSetVariableBlock"],configuration:{variables:{name:"variables",gltfType:"number",flowGraphType:"string",inOptions:!0,isArray:!0,dataTransformer:function(e,t){return e.map(function(e){return t.getVariableName(e)})}}},extraProcessor:function(e,t,n,r,o){return o[0].dataInputs.forEach(function(e){e.name=r.getVariableName(+e.name)}),o}},"variable/interpolate":{blocks:["FlowGraphInterpolationBlock","FlowGraphContextBlock","FlowGraphPlayAnimationBlock","FlowGraphBezierCurveEasing","FlowGraphGetVariableBlock"],configuration:{variable:{name:"propertyName",inOptions:!0,isVariable:!0,dataTransformer:function(e,t){return t.getVariableName(e)}},useSlerp:{name:"animationType",inOptions:!0,defaultValue:!1,dataTransformer:function(e){return!0===e?"Quaternion":void 0}}},inputs:{values:{value:{name:"value_1"},duration:{name:"duration_1",gltfType:"number"},p1:{name:"controlPoint1",toBlock:"FlowGraphBezierCurveEasing"},p2:{name:"controlPoint2",toBlock:"FlowGraphBezierCurveEasing"}},flows:{in:{name:"in",toBlock:"FlowGraphPlayAnimationBlock"}}},outputs:{flows:{err:{name:"error",toBlock:"FlowGraphPlayAnimationBlock"},out:{name:"out",toBlock:"FlowGraphPlayAnimationBlock"},done:{name:"done",toBlock:"FlowGraphPlayAnimationBlock"}}},interBlockConnectors:[{input:"object",output:"userVariables",inputBlockIndex:2,outputBlockIndex:1,isVariable:!0},{input:"animation",output:"animation",inputBlockIndex:2,outputBlockIndex:0,isVariable:!0},{input:"easingFunction",output:"easingFunction",inputBlockIndex:0,outputBlockIndex:3,isVariable:!0},{input:"value_0",output:"value",inputBlockIndex:0,outputBlockIndex:4,isVariable:!0}],extraProcessor:function(e,n,r,o,a){var i,s,l,u,c,f,h=a[0],d=null===(s=null===(i=e.configuration)||void 0===i?void 0:i.variable.value)||void 0===s?void 0:s[0];if("number"!=typeof d)throw t.Logger.Error("Variable index is not defined for variable interpolation block"),new Error("Variable index is not defined for variable interpolation block");var p=o.arrays.staticVariables[d];void 0===(null===(u=null===(l=h.config)||void 0===l?void 0:l.animationType)||void 0===u?void 0:u.value)&&(h.config||(h.config={}),(c=h.config).animationType||(c.animationType={}),h.config.animationType.value=t.getAnimationTypeByFlowGraphType(p.type));var m=a[4];return m.config||(m.config={}),(f=m.config).variable||(f.variable={}),m.config.variable.value=o.getVariableName(d),a}},"pointer/get":{blocks:["FlowGraphGetPropertyBlock","FlowGraphJsonPointerParserBlock"],configuration:{pointer:{name:"jsonPointer",toBlock:"FlowGraphJsonPointerParserBlock"}},inputs:{values:{"[segment]":{name:"$1",toBlock:"FlowGraphJsonPointerParserBlock"}}},interBlockConnectors:[{input:"object",output:"object",inputBlockIndex:0,outputBlockIndex:1,isVariable:!0},{input:"propertyName",output:"propertyName",inputBlockIndex:0,outputBlockIndex:1,isVariable:!0},{input:"customGetFunction",output:"getFunction",inputBlockIndex:0,outputBlockIndex:1,isVariable:!0}],extraProcessor:function(e,t,n,r,o){return o.forEach(function(e){"FlowGraphJsonPointerParserBlock"===e.className&&(e.config||(e.config={}),e.config.outputValue=!0)}),o}},"pointer/set":{blocks:["FlowGraphSetPropertyBlock","FlowGraphJsonPointerParserBlock"],configuration:{pointer:{name:"jsonPointer",toBlock:"FlowGraphJsonPointerParserBlock"}},inputs:{values:{value:{name:"value"},"[segment]":{name:"$1",toBlock:"FlowGraphJsonPointerParserBlock"}}},outputs:{flows:{err:{name:"error"}}},interBlockConnectors:[{input:"object",output:"object",inputBlockIndex:0,outputBlockIndex:1,isVariable:!0},{input:"propertyName",output:"propertyName",inputBlockIndex:0,outputBlockIndex:1,isVariable:!0},{input:"customSetFunction",output:"setFunction",inputBlockIndex:0,outputBlockIndex:1,isVariable:!0}],extraProcessor:function(e,t,n,r,o){return o.forEach(function(e){"FlowGraphJsonPointerParserBlock"===e.className&&(e.config||(e.config={}),e.config.outputValue=!0)}),o}},"pointer/interpolate":{blocks:["FlowGraphInterpolationBlock","FlowGraphJsonPointerParserBlock","FlowGraphPlayAnimationBlock","FlowGraphBezierCurveEasing"],configuration:{pointer:{name:"jsonPointer",toBlock:"FlowGraphJsonPointerParserBlock"}},inputs:{values:{value:{name:"value_1"},"[segment]":{name:"$1",toBlock:"FlowGraphJsonPointerParserBlock"},duration:{name:"duration_1",gltfType:"number"},p1:{name:"controlPoint1",toBlock:"FlowGraphBezierCurveEasing"},p2:{name:"controlPoint2",toBlock:"FlowGraphBezierCurveEasing"}},flows:{in:{name:"in",toBlock:"FlowGraphPlayAnimationBlock"}}},outputs:{flows:{err:{name:"error",toBlock:"FlowGraphPlayAnimationBlock"},out:{name:"out",toBlock:"FlowGraphPlayAnimationBlock"},done:{name:"done",toBlock:"FlowGraphPlayAnimationBlock"}}},interBlockConnectors:[{input:"object",output:"object",inputBlockIndex:2,outputBlockIndex:1,isVariable:!0},{input:"propertyName",output:"propertyName",inputBlockIndex:0,outputBlockIndex:1,isVariable:!0},{input:"customBuildAnimation",output:"generateAnimationsFunction",inputBlockIndex:0,outputBlockIndex:1,isVariable:!0},{input:"animation",output:"animation",inputBlockIndex:2,outputBlockIndex:0,isVariable:!0},{input:"easingFunction",output:"easingFunction",inputBlockIndex:0,outputBlockIndex:3,isVariable:!0},{input:"value_0",output:"value",inputBlockIndex:0,outputBlockIndex:1,isVariable:!0}],extraProcessor:function(e,t,n,r,o){return o.forEach(function(t){"FlowGraphJsonPointerParserBlock"===t.className?(t.config||(t.config={}),t.config.outputValue=!0):"FlowGraphInterpolationBlock"===t.className&&(t.config||(t.config={}),Object.keys(e.values||[]).forEach(function(n){var o,a=null===(o=e.values)||void 0===o?void 0:o[n];if("value"===n&&a){var i=a.type;void 0!==i&&(t.config.animationType=r.arrays.types[i].flowGraphType)}}))}),o}},"animation/start":{blocks:["FlowGraphPlayAnimationBlock","FlowGraphArrayIndexBlock","KHR_interactivity/FlowGraphGLTFDataProvider"],inputs:{values:{animation:{name:"index",gltfType:"number",toBlock:"FlowGraphArrayIndexBlock"},speed:{name:"speed",gltfType:"number"},startTime:{name:"from",gltfType:"number",dataTransformer:function(e,t){return[e[0]*t._animationTargetFps]}},endTime:{name:"to",gltfType:"number",dataTransformer:function(e,t){return[e[0]*t._animationTargetFps]}}}},outputs:{flows:{err:{name:"error"}}},interBlockConnectors:[{input:"animationGroup",output:"value",inputBlockIndex:0,outputBlockIndex:1,isVariable:!0},{input:"array",output:"animationGroups",inputBlockIndex:1,outputBlockIndex:2,isVariable:!0}],extraProcessor:function(e,t,n,r,o,a,i){var s=o[o.length-1];return s.config||(s.config={}),s.config.glTF=i,o}},"animation/stop":{blocks:["FlowGraphStopAnimationBlock","FlowGraphArrayIndexBlock","KHR_interactivity/FlowGraphGLTFDataProvider"],inputs:{values:{animation:{name:"index",gltfType:"number",toBlock:"FlowGraphArrayIndexBlock"}}},outputs:{flows:{err:{name:"error"}}},interBlockConnectors:[{input:"animationGroup",output:"value",inputBlockIndex:0,outputBlockIndex:1,isVariable:!0},{input:"array",output:"animationGroups",inputBlockIndex:1,outputBlockIndex:2,isVariable:!0}],extraProcessor:function(e,t,n,r,o,a,i){var s=o[o.length-1];return s.config||(s.config={}),s.config.glTF=i,o}},"animation/stopAt":{blocks:["FlowGraphStopAnimationBlock","FlowGraphArrayIndexBlock","KHR_interactivity/FlowGraphGLTFDataProvider"],configuration:{},inputs:{values:{animation:{name:"index",gltfType:"number",toBlock:"FlowGraphArrayIndexBlock"},stopTime:{name:"stopAtFrame",gltfType:"number",dataTransformer:function(e,t){return[e[0]*t._animationTargetFps]}}}},outputs:{flows:{err:{name:"error"}}},interBlockConnectors:[{input:"animationGroup",output:"value",inputBlockIndex:0,outputBlockIndex:1,isVariable:!0},{input:"array",output:"animationGroups",inputBlockIndex:1,outputBlockIndex:2,isVariable:!0}],extraProcessor:function(e,t,n,r,o,a,i){var s=o[o.length-1];return s.config||(s.config={}),s.config.glTF=i,o}},"math/switch":{blocks:["FlowGraphDataSwitchBlock"],configuration:{cases:{name:"cases",isArray:!0,inOptions:!0,defaultValue:[]}},inputs:{values:{selection:{name:"case"}}},validation:function(e){var n,r=null===(n=e.configuration)||void 0===n?void 0:n.cases;if(r&&r.value){if(!r.value.every(function(e){return"number"==typeof e&&/^-?\d+$/.test(e.toString())}))return t.Logger.Warn("Switch cases should be integers. Using empty array instead."),r.value=[],{valid:!0};var o=new Set(r.value);r.value=Array.from(o)}return{valid:!0}},extraProcessor:function(e,t,n,r,o){var a=o[0];return a.dataInputs.forEach(function(e){"default"!==e.name&&"case"!==e.name&&(e.name="in_"+e.name)}),a.config||(a.config={}),a.config.treatCasesAsIntegers=!0,o}},"debug/log":{blocks:["FlowGraphConsoleLogBlock"],configuration:{message:{name:"messageTemplate",inOptions:!0}}}};function Dr(e,t,n){return void 0===t&&(t=["a"]),{blocks:[e],inputs:{values:t.reduce(function(e,t){return e[t]={name:t},e},{})},outputs:{values:{value:{name:"value"}}},extraProcessor:function(e,t,r,o,a){var i;if(n){(i=a[0]).config||(i.config={}),a[0].config.preventIntegerFloatArithmetic=!0;var s=-1;Object.keys(e.values||{}).find(function(t){var n;return void 0!==(null===(n=e.values)||void 0===n?void 0:n[t].type)&&(s=e.values[t].type,!0)}),-1!==s&&(a[0].config.type=o.arrays.types[s].flowGraphType)}return a},validation:function(e){return n?Vr(e):{valid:!0}}}}function Vr(e){if(e.values){var t=Object.keys(e.values).map(function(t){return e.values[t].type}).filter(function(e){return void 0!==e});if(!t.every(function(e){return e===t[0]}))return{valid:!1,error:"All inputs must be of the same type"}}return{valid:!0}}function Hr(){return Object.keys(Gr)}var Kr={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"}},jr=function(){function e(e,t,n){void 0===n&&(n=60),this._interactivityGraph=e,this._gltf=t,this._animationTargetFps=n,this._types=[],this._mappings=[],this._staticVariables=[],this._events=[],this._internalEventsCounter=0,this._nodes=[],this._parseTypes(),this._parseDeclarations(),this._parseVariables(),this._parseEvents(),this._parseNodes()}return Object.defineProperty(e.prototype,"arrays",{get:function(){return{types:this._types,mappings:this._mappings,staticVariables:this._staticVariables,events:this._events,nodes:this._nodes}},enumerable:!1,configurable:!0}),e.prototype._parseTypes=function(){if(this._interactivityGraph.types)for(var e=0,t=this._interactivityGraph.types;e<t.length;e++){var n=t[e];this._types.push(Kr[n.signature])}},e.prototype._parseDeclarations=function(){if(this._interactivityGraph.declarations)for(var e=0,n=this._interactivityGraph.declarations;e<n.length;e++){var r=n[e],o=Ir(r);if(!o)throw t.Logger.Error(["No mapping found for declaration",r]),new Error("Error parsing declarations");this._mappings.push({flowGraphMapping:o,fullOperationName:r.extension?r.op+":"+r.extension:r.op})}},e.prototype._parseVariables=function(){if(this._interactivityGraph.variables)for(var e=0,t=this._interactivityGraph.variables;e<t.length;e++){var n=t[e],r=this._parseVariable(n);this._staticVariables.push(r)}},e.prototype._parseVariable=function(e,n){var r=this._types[e.type];if(!r)throw t.Logger.Error(["No type found for variable",e]),new Error("Error parsing variables");if(e.value&&e.value.length!==r.length)throw t.Logger.Error(["Invalid value length for variable",e,r]),new Error("Error parsing variables");var o=e.value||[];if(!o.length)switch(r.flowGraphType){case"boolean":o.push(!1);break;case"FlowGraphInteger":o.push(0);break;case"number":o.push(NaN);break;case"Vector2":o.push(NaN,NaN);break;case"Vector3":o.push(NaN,NaN,NaN);break;case"Vector4":case"Matrix2D":case"Quaternion":o.fill(NaN,0,4);break;case"Matrix":o.fill(NaN,0,16);break;case"Matrix3D":o.fill(NaN,0,9)}return"number"===r.elementType&&"string"==typeof o[0]&&(o[0]=parseFloat(o[0])),{type:r.flowGraphType,value:n?n(o,this):o}},e.prototype._parseEvents=function(){var e=this;if(this._interactivityGraph.events)for(var n=function(n){var o={eventId:n.id||"internalEvent_"+r._internalEventsCounter++};n.values&&(o.eventData=Object.keys(n.values).map(function(r){var o,a=null===(o=n.values)||void 0===o?void 0:o[r];if(!a)throw t.Logger.Error(["No value found for event key",r]),new Error("Error parsing events");var i=e._types[a.type];if(!i)throw t.Logger.Error(["No type found for event value",a]),new Error("Error parsing events");var s=void 0!==a.value?e._parseVariable(a):void 0;return{id:r,type:i.flowGraphType,eventData:!0,value:s}})),r._events.push(o)},r=this,o=0,a=this._interactivityGraph.events;o<a.length;o++)n(a[o])},e.prototype._parseNodes=function(){var e;if(this._interactivityGraph.nodes)for(var n=0,r=this._interactivityGraph.nodes;n<r.length;n++){var o=r[n];if("number"!=typeof o.declaration)throw t.Logger.Error(["No declaration found for node",o]),new Error("Error parsing nodes");var a=this._mappings[o.declaration];if(!a)throw t.Logger.Error(["No mapping found for node",o]),new Error("Error parsing nodes");if(a.flowGraphMapping.validation){var i=a.flowGraphMapping.validation(o,this._interactivityGraph,this._gltf);if(!i.valid)throw new Error("Error validating interactivity node ".concat(null===(e=this._interactivityGraph.declarations)||void 0===e?void 0:e[o.declaration].op," - ").concat(i.error))}for(var s=[],l=0,u=a.flowGraphMapping.blocks;l<u.length;l++){var c=u[l],f=this._getEmptyBlock(c,a.fullOperationName);this._parseNodeConfiguration(o,f,a.flowGraphMapping,c),s.push(f)}this._nodes.push({blocks:s,fullOperationName:a.fullOperationName})}},e.prototype._getEmptyBlock=function(e,n){return{uniqueId:t.RandomGUID(),className:e,dataInputs:[],dataOutputs:[],signalInputs:[],signalOutputs:[],config:{},type:n,metadata:{}}},e.prototype._parseNodeConfiguration=function(e,n,r,o){var a,i=e.configuration;if(i)for(var s in i){var l=i[s];if(!l)throw new Error("Error parsing node configuration");var u=null===(a=r.configuration)||void 0===a?void 0:a[s];if(u&&u.toBlock?u.toBlock===o:0===r.blocks.indexOf(o)){var c=null==u?void 0:u.defaultValue;(null==l?void 0:l.value)&&(c=l.value),(null==u?void 0:u.isArray)||(1!==c.length&&t.Logger.Warn("Invalid non-array value length: ".concat(c.length)),c=c[0]),(null==u?void 0:u.dataTransformer)&&(c=u.dataTransformer(c,this)),void 0!==c&&(n.config[(null==u?void 0:u.name)||s]={value:c})}}},e.prototype._parseNodeConnections=function(e){for(var n,r,o,a,i,s,l,u,c,f,h,d,p,m,_,g,b,y,v,T=0;T<this._nodes.length;T++){var x=null===(n=this._interactivityGraph.nodes)||void 0===n?void 0:n[T];if(!x)throw t.Logger.Error(["No node found for interactivity node",this._nodes[T]]),new Error("Error parsing node connections");var A=this._nodes[T],w=this._mappings[x.declaration];if(!w)throw t.Logger.Error(["No mapping found for node",x]),new Error("Error parsing node connections");for(var O=x.flows||{},C=Object.keys(O).sort(),M=function(e){var n=O[e],c=null===(o=null===(r=w.flowGraphMapping.outputs)||void 0===r?void 0:r.flows)||void 0===o?void 0:o[e],f=(null==c?void 0:c.name)||e,h=E._createNewSocketConnection(f,!0);(c&&c.toBlock&&A.blocks.find(function(e){return e.className===c.toBlock})||A.blocks[0]).signalOutputs.push(h);var d=n.node,p=E._nodes[d];if(!p)throw t.Logger.Error(["No node found for input node id",d]),new Error("Error parsing node connections");var m=Nr(p.fullOperationName);if(!m)throw t.Logger.Error(["No mapping found for input node",p]),new Error("Error parsing node connections");var _=null===(i=null===(a=m.inputs)||void 0===a?void 0:a.flows)||void 0===i?void 0:i[n.socket||"in"],g=!1;if(!_)for(var b in null===(s=m.inputs)||void 0===s?void 0:s.flows)b.startsWith("[")&&b.endsWith("]")&&(g=!0,_=null===(u=null===(l=m.inputs)||void 0===l?void 0:l.flows)||void 0===u?void 0:u[b]);var y=_?g?_.name.replace("$1",n.socket||""):_.name:n.socket||"in",v=_&&_.toBlock&&p.blocks.find(function(e){return e.className===_.toBlock})||p.blocks[0],T=v.signalInputs.find(function(e){return e.name===y});T||(T=E._createNewSocketConnection(y),v.signalInputs.push(T)),T.connectedPointIds.push(h.uniqueId),h.connectedPointIds.push(T.uniqueId)},E=this,R=0,F=C;R<F.length;R++)M(F[R]);for(var L=x.values||{},P=Object.keys(L),S=function(n){var r=L[n],o=null===(f=null===(c=w.flowGraphMapping.inputs)||void 0===c?void 0:c.values)||void 0===f?void 0:f[n],a=!1;if(!o)for(var i in null===(h=w.flowGraphMapping.inputs)||void 0===h?void 0:h.values)i.startsWith("[")&&i.endsWith("]")&&(a=!0,o=null===(p=null===(d=w.flowGraphMapping.inputs)||void 0===d?void 0:d.values)||void 0===p?void 0:p[i]);var s=o?a?o.name.replace("$1",n):o.name:n,l=N._createNewSocketConnection(s);if((o&&o.toBlock&&A.blocks.find(function(e){return e.className===o.toBlock})||A.blocks[0]).dataInputs.push(l),void 0!==r.value){var u=N._parseVariable(r,o&&o.dataTransformer);e._connectionValues[l.uniqueId]=u}else{if(void 0===r.node)throw t.Logger.Error(["Invalid value for value connection",r]),new Error("Error parsing node connections");var v=r.node,T=r.socket||"value",x=N._nodes[v];if(!x)throw t.Logger.Error(["No node found for output socket reference",r]),new Error("Error parsing node connections");var O=Nr(x.fullOperationName);if(!O)throw t.Logger.Error(["No mapping found for output socket reference",r]),new Error("Error parsing node connections");var C=null===(_=null===(m=O.outputs)||void 0===m?void 0:m.values)||void 0===_?void 0:_[T],M=!1;if(!C)for(var i in null===(g=O.outputs)||void 0===g?void 0:g.values)i.startsWith("[")&&i.endsWith("]")&&(M=!0,C=null===(y=null===(b=O.outputs)||void 0===b?void 0:b.values)||void 0===y?void 0:y[i]);var E=C?M?C.name.replace("$1",T):null==C?void 0:C.name:T,R=C&&C.toBlock&&x.blocks.find(function(e){return e.className===C.toBlock})||x.blocks[0],F=R.dataOutputs.find(function(e){return e.name===E});F||(F=N._createNewSocketConnection(E,!0),R.dataOutputs.push(F)),l.connectedPointIds.push(F.uniqueId),F.connectedPointIds.push(l.uniqueId)}},N=this,I=0,B=P;I<B.length;I++)S(B[I]);if(w.flowGraphMapping.interBlockConnectors)for(var k=0,G=w.flowGraphMapping.interBlockConnectors;k<G.length;k++){var D=G[k],V=D.input,H=D.output,K=D.isVariable;this._connectFlowGraphNodes(V,H,A.blocks[D.inputBlockIndex],A.blocks[D.outputBlockIndex],K)}if(w.flowGraphMapping.extraProcessor){var j=null===(v=this._interactivityGraph.declarations)||void 0===v?void 0:v[x.declaration];if(!j)throw t.Logger.Error(["No declaration found for extra processor",x]),new Error("Error parsing node connections");A.blocks=w.flowGraphMapping.extraProcessor(x,j,w.flowGraphMapping,this,A.blocks,e,this._gltf)}}},e.prototype._createNewSocketConnection=function(e,n){return{uniqueId:t.RandomGUID(),name:e,_connectionType:n?1:0,connectedPointIds:[]}},e.prototype._connectFlowGraphNodes=function(e,t,n,r,o){var a=o?n.dataInputs:n.signalInputs,i=o?r.dataOutputs:r.signalOutputs,s=a.find(function(t){return t.name===e})||this._createNewSocketConnection(e),l=i.find(function(e){return e.name===t})||this._createNewSocketConnection(t,!0);a.find(function(t){return t.name===e})||a.push(s),i.find(function(e){return e.name===t})||i.push(l),s.connectedPointIds.push(l.uniqueId),l.connectedPointIds.push(s.uniqueId)},e.prototype.getVariableName=function(e){return"staticVariable_"+e},e.prototype.serializeToFlowGraph=function(){var e={uniqueId:t.RandomGUID(),_userVariables:{},_connectionValues:{}};this._parseNodeConnections(e);for(var n=0;n<this._staticVariables.length;n++){var r=this._staticVariables[n];e._userVariables[this.getVariableName(n)]=r}return{rightHanded:!0,allBlocks:this._nodes.reduce(function(e,t){return e.concat(t.blocks)},[]),executionContexts:[e]}},e}(),Ur="KHR_interactivity",Wr=function(){function e(e){this._loader=e,this.name=Ur,this.enabled=this._loader.isExtensionUsed(Ur),this._pathConverter=Ie(this._loader.gltf),e._skipStartAnimationStep=!0;var t=e.babylonScene;t&&zr(t)}return e.prototype.dispose=function(){this._loader=null,delete this._pathConverter},e.prototype.onReady=function(){return g(this,void 0,void 0,function(){var e,n,r,o,a,i=this;return b(this,function(s){switch(s.label){case 0:return this._loader.babylonScene&&this._pathConverter?(e=this._loader.babylonScene,(n=null===(a=this._loader.gltf.extensions)||void 0===a?void 0:a.KHR_interactivity)?((r=new t.FlowGraphCoordinator({scene:e})).dispatchEventsSynchronously=!1,o=n.graphs.map(function(e){return new jr(e,i._loader.gltf,i._loader.parent.targetFps).serializeToFlowGraph()}),[4,Promise.all(o.map(function(e){return g(i,void 0,void 0,function(){return b(this,function(n){switch(n.label){case 0:return[4,t.ParseFlowGraphAsync(e,{coordinator:r,pathConverter:this._pathConverter})];case 1:return[2,n.sent()]}})})}))]):[2]):[2];case 1:return s.sent(),r.start(),[2]}})})},e}();function zr(e){Ge("/extensions/KHR_interactivity/?/activeCamera/rotation",{get:function(){if(!e.activeCamera)return new t.Quaternion(NaN,NaN,NaN,NaN);var n=t.Quaternion.FromRotationMatrix(e.activeCamera.getWorldMatrix()).normalize();return e.useRightHandedSystem||(n.w*=-1,n.x*=-1),n},type:"Quaternion",getTarget:function(){return e.activeCamera}}),Ge("/extensions/KHR_interactivity/?/activeCamera/position",{get:function(){if(!e.activeCamera)return new t.Vector3(NaN,NaN,NaN);var n=e.activeCamera.getWorldMatrix().getTranslation();return e.useRightHandedSystem||(n.x*=-1),n},type:"Vector3",getTarget:function(){return e.activeCamera}}),Ge("/animations/{}/extensions/KHR_interactivity/isPlaying",{get:function(e){var t,n;return null!==(n=null===(t=e._babylonAnimationGroup)||void 0===t?void 0:t.isPlaying)&&void 0!==n&&n},type:"boolean",getTarget:function(e){return e._babylonAnimationGroup}}),Ge("/animations/{}/extensions/KHR_interactivity/minTime",{get:function(e){var t,n;return(null!==(n=null===(t=e._babylonAnimationGroup)||void 0===t?void 0:t.from)&&void 0!==n?n:0)/60},type:"number",getTarget:function(e){return e._babylonAnimationGroup}}),Ge("/animations/{}/extensions/KHR_interactivity/maxTime",{get:function(e){var t,n;return(null!==(n=null===(t=e._babylonAnimationGroup)||void 0===t?void 0:t.to)&&void 0!==n?n:0)/60},type:"number",getTarget:function(e){return e._babylonAnimationGroup}}),Ge("/animations/{}/extensions/KHR_interactivity/playhead",{get:function(e){var t,n;return(null!==(n=null===(t=e._babylonAnimationGroup)||void 0===t?void 0:t.getCurrentFrame())&&void 0!==n?n:0)/60},type:"number",getTarget:function(e){return e._babylonAnimationGroup}}),Ge("/animations/{}/extensions/KHR_interactivity/virtualPlayhead",{get:function(e){var t,n;return(null!==(n=null===(t=e._babylonAnimationGroup)||void 0===t?void 0:t.getCurrentFrame())&&void 0!==n?n:0)/60},type:"number",getTarget:function(e){return e._babylonAnimationGroup}})}t.addToBlockFactory(Ur,"FlowGraphGLTFDataProvider",function(){return g(void 0,void 0,void 0,function(){return b(this,function(e){switch(e.label){case 0:return[4,Promise.resolve().then(function(){return uo})];case 1:return[2,e.sent().FlowGraphGLTFDataProvider]}})})}),we(Ur),Ae(Ur,!0,function(e){return new Wr(e)});var qr={__proto__:null,KHR_interactivity:Wr,_AddInteractivityObjectModel:zr},Yr="KHR_node_visibility";Ge("/nodes/{}/extensions/KHR_node_visibility/visible",{get:function(e){var t=e._babylonTransformNode;return!t||void 0===t.isVisible||t.isVisible},set:function(e,t){var n,r;null===(n=t._primitiveBabylonMeshes)||void 0===n||n.forEach(function(e){e.inheritVisibility=!0}),t._babylonTransformNode&&(t._babylonTransformNode.isVisible=e),null===(r=t._primitiveBabylonMeshes)||void 0===r||r.forEach(function(t){t.isVisible=e})},getTarget:function(e){return e._babylonTransformNode},getPropertyName:[function(){return"isVisible"}],type:"boolean"});var Xr=function(){function e(e){this.name=Yr,this._loader=e,this.enabled=e.isExtensionUsed(Yr)}return e.prototype.onReady=function(){if(this._loader){var e=this._loader.gltf.nodes;if(e)for(var t=0,n=e;t<n.length;t++){var r=n[t],o=r._babylonTransformNode;o&&(o.inheritVisibility=!0,r.extensions&&r.extensions.KHR_node_visibility&&!1===r.extensions.KHR_node_visibility.visible&&(o.isVisible=!1))}}},e.prototype.dispose=function(){delete this._loader},e}();we(Yr),Ae(Yr,!0,function(e){return new Xr(e)});var Jr={__proto__:null,KHR_node_visibility:Xr},Qr="KHR_node_selectability";Br("event/onSelect",Qr,{blocks:["FlowGraphMeshPickEventBlock","FlowGraphGetVariableBlock","FlowGraphIndexOfBlock","KHR_interactivity/FlowGraphGLTFDataProvider"],configuration:{stopPropagation:{name:"stopPropagation"},nodeIndex:{name:"variable",toBlock:"FlowGraphGetVariableBlock",dataTransformer:function(e){return"pickedMesh_"+e}}},outputs:{values:{selectedNodeIndex:{name:"index",toBlock:"FlowGraphIndexOfBlock"},controllerIndex:{name:"pointerId"},selectionPoint:{name:"pickedPoint"},selectionRayOrigin:{name:"pickOrigin"}},flows:{out:{name:"done"}}},interBlockConnectors:[{input:"asset",output:"value",inputBlockIndex:0,outputBlockIndex:1,isVariable:!0},{input:"array",output:"nodes",inputBlockIndex:2,outputBlockIndex:3,isVariable:!0},{input:"object",output:"pickedMesh",inputBlockIndex:2,outputBlockIndex:0,isVariable:!0}],extraProcessor:function(e,t,n,r,o,a,i){var s,l,u,c,f,h,d,p=o[o.length-1];p.config=p.config||{},p.config.glTF=i;var m=null===(u=null===(l=null===(s=e.configuration)||void 0===s?void 0:s.nodeIndex)||void 0===l?void 0:l.value)||void 0===u?void 0:u[0];if(void 0===m||"number"!=typeof m)throw new Error("nodeIndex not found in configuration");var _="pickedMesh_"+m;return o[1].config.variable=_,a._userVariables[_]={className:"Mesh",id:null===(f=null===(c=null==i?void 0:i.nodes)||void 0===c?void 0:c[m]._babylonTransformNode)||void 0===f?void 0:f.id,uniqueId:null===(d=null===(h=null==i?void 0:i.nodes)||void 0===h?void 0:h[m]._babylonTransformNode)||void 0===d?void 0:d.uniqueId},o}}),Ge("/nodes/{}/extensions/KHR_node_selectability/selectable",{get:function(e){var t=e._babylonTransformNode;return!t||void 0===t.isPickable||t.isPickable},set:function(e,t){var n;null===(n=t._primitiveBabylonMeshes)||void 0===n||n.forEach(function(t){t.isPickable=e})},getTarget:function(e){return e._babylonTransformNode},getPropertyName:[function(){return"isPickable"}],type:"boolean"});var Zr=function(){function e(e){this.name=Qr,this._loader=e,this.enabled=e.isExtensionUsed(Qr)}return e.prototype.onReady=function(){return g(this,void 0,void 0,function(){var e;return b(this,function(t){return null===(e=this._loader.gltf.nodes)||void 0===e||e.forEach(function(e){var t,n,r;(null===(t=e.extensions)||void 0===t?void 0:t.KHR_node_selectability)&&!1===(null===(n=e.extensions)||void 0===n?void 0:n.KHR_node_selectability.selectable)&&(null===(r=e._babylonTransformNode)||void 0===r||r.getChildMeshes().forEach(function(e){e.isPickable=!1}))}),[2]})})},e.prototype.dispose=function(){this._loader=null},e}();we(Qr),Ae(Qr,!0,function(e){return new Zr(e)});var $r={__proto__:null,KHR_node_selectability:Zr},eo="KHR_node_hoverability",to="targetMeshPointerOver_";Br("event/onHoverIn",eo,{blocks:["FlowGraphPointerOverEventBlock","FlowGraphGetVariableBlock","FlowGraphIndexOfBlock","KHR_interactivity/FlowGraphGLTFDataProvider"],configuration:{stopPropagation:{name:"stopPropagation"},nodeIndex:{name:"variable",toBlock:"FlowGraphGetVariableBlock",dataTransformer:function(e){return to+e}}},outputs:{values:{hoverNodeIndex:{name:"index",toBlock:"FlowGraphIndexOfBlock"},controllerIndex:{name:"pointerId"}},flows:{out:{name:"done"}}},interBlockConnectors:[{input:"targetMesh",output:"value",inputBlockIndex:0,outputBlockIndex:1,isVariable:!0},{input:"array",output:"nodes",inputBlockIndex:2,outputBlockIndex:3,isVariable:!0},{input:"object",output:"meshUnderPointer",inputBlockIndex:2,outputBlockIndex:0,isVariable:!0}],extraProcessor:function(e,t,n,r,o,a,i){var s,l,u,c,f,h,d,p=o[o.length-1];p.config=p.config||{},p.config.glTF=i;var m=null===(u=null===(l=null===(s=e.configuration)||void 0===s?void 0:s.nodeIndex)||void 0===l?void 0:l.value)||void 0===u?void 0:u[0];if(void 0===m||"number"!=typeof m)throw new Error("nodeIndex not found in configuration");var _=to+m;return o[1].config.variable=_,a._userVariables[_]={className:"Mesh",id:null===(f=null===(c=null==i?void 0:i.nodes)||void 0===c?void 0:c[m]._babylonTransformNode)||void 0===f?void 0:f.id,uniqueId:null===(d=null===(h=null==i?void 0:i.nodes)||void 0===h?void 0:h[m]._babylonTransformNode)||void 0===d?void 0:d.uniqueId},o}});var no="targetMeshPointerOut_";Br("event/onHoverOut",eo,{blocks:["FlowGraphPointerOutEventBlock","FlowGraphGetVariableBlock","FlowGraphIndexOfBlock","KHR_interactivity/FlowGraphGLTFDataProvider"],configuration:{stopPropagation:{name:"stopPropagation"},nodeIndex:{name:"variable",toBlock:"FlowGraphGetVariableBlock",dataTransformer:function(e){return no+e}}},outputs:{values:{hoverNodeIndex:{name:"index",toBlock:"FlowGraphIndexOfBlock"},controllerIndex:{name:"pointerId"}},flows:{out:{name:"done"}}},interBlockConnectors:[{input:"targetMesh",output:"value",inputBlockIndex:0,outputBlockIndex:1,isVariable:!0},{input:"array",output:"nodes",inputBlockIndex:2,outputBlockIndex:3,isVariable:!0},{input:"object",output:"meshOutOfPointer",inputBlockIndex:2,outputBlockIndex:0,isVariable:!0}],extraProcessor:function(e,t,n,r,o,a,i){var s,l,u,c,f,h,d,p=o[o.length-1];p.config=p.config||{},p.config.glTF=i;var m=null===(u=null===(l=null===(s=e.configuration)||void 0===s?void 0:s.nodeIndex)||void 0===l?void 0:l.value)||void 0===u?void 0:u[0];if(void 0===m||"number"!=typeof m)throw new Error("nodeIndex not found in configuration");var _=no+m;return o[1].config.variable=_,a._userVariables[_]={className:"Mesh",id:null===(f=null===(c=null==i?void 0:i.nodes)||void 0===c?void 0:c[m]._babylonTransformNode)||void 0===f?void 0:f.id,uniqueId:null===(d=null===(h=null==i?void 0:i.nodes)||void 0===h?void 0:h[m]._babylonTransformNode)||void 0===d?void 0:d.uniqueId},o}}),Ge("/nodes/{}/extensions/KHR_node_hoverability/hoverable",{get:function(e){var t=e._babylonTransformNode;return!t||void 0===t.pointerOverDisableMeshTesting||t.pointerOverDisableMeshTesting},set:function(e,t){var n;null===(n=t._primitiveBabylonMeshes)||void 0===n||n.forEach(function(t){t.pointerOverDisableMeshTesting=!e})},getTarget:function(e){return e._babylonTransformNode},getPropertyName:[function(){return"pointerOverDisableMeshTesting"}],type:"boolean"});var ro=function(){function e(e){this.name=eo,this._loader=e,this.enabled=e.isExtensionUsed(eo)}return e.prototype.onReady=function(){return g(this,void 0,void 0,function(){var e;return b(this,function(t){return null===(e=this._loader.gltf.nodes)||void 0===e||e.forEach(function(e){var t,n,r;(null===(t=e.extensions)||void 0===t?void 0:t.KHR_node_hoverability)&&!1===(null===(n=e.extensions)||void 0===n?void 0:n.KHR_node_hoverability.hoverable)&&(null===(r=e._babylonTransformNode)||void 0===r||r.getChildMeshes().forEach(function(e){e.pointerOverDisableMeshTesting=!0}))}),[2]})})},e.prototype.dispose=function(){this._loader=null},e}();we(eo),Ae(eo,!0,function(e){return new ro(e)});var oo={__proto__:null,KHR_node_hoverability:ro},ao="ExtrasAsMetadata",io=function(){function e(e){this.name=ao,this.enabled=!0,this._loader=e}return e.prototype._assignExtras=function(e,t){if(t.extras&&Object.keys(t.extras).length>0){var n=e.metadata=e.metadata||{};(n.gltf=n.gltf||{}).extras=t.extras}},e.prototype.dispose=function(){this._loader=null},e.prototype.loadNodeAsync=function(e,t,n){var r=this;return this._loader.loadNodeAsync(e,t,function(e){r._assignExtras(e,t),n(e)})},e.prototype.loadCameraAsync=function(e,t,n){var r=this;return this._loader.loadCameraAsync(e,t,function(e){r._assignExtras(e,t),n(e)})},e.prototype.createMaterial=function(e,t,n){var r=this._loader.createMaterial(e,t,n);return this._assignExtras(r,t),r},e.prototype.loadAnimationAsync=function(e,t){var n=this;return this._loader.loadAnimationAsync(e,t).then(function(e){return n._assignExtras(e,t),e})},e}();we(ao),Ae(ao,!1,function(e){return new io(e)});var so={__proto__:null,ExtrasAsMetadata:io},lo=function(e){function n(n){var r,o,a=e.call(this,n)||this,i=n.glTF,s=(null===(r=null==i?void 0:i.animations)||void 0===r?void 0:r.map(function(e){return e._babylonAnimationGroup}))||[];a.animationGroups=a.registerDataOutput("animationGroups",t.RichTypeAny,s);var l=(null===(o=null==i?void 0:i.nodes)||void 0===o?void 0:o.map(function(e){return e._babylonTransformNode}))||[];return a.nodes=a.registerDataOutput("nodes",t.RichTypeAny,l),a}return m(n,e),n.prototype.getClassName=function(){return"FlowGraphGLTFDataProvider"},n}(t.FlowGraphBlock),uo={__proto__:null,FlowGraphGLTFDataProvider:lo},co={__proto__:null,AddObjectAccessorToKey:Ge,EXT_lights_area:Mt,EXT_lights_ies:bt,EXT_lights_image_based:rt,EXT_mesh_gpu_instancing:it,EXT_meshopt_compression:ut,EXT_texture_avif:mt,EXT_texture_webp:ht,ExtrasAsMetadata:io,FlowGraphGLTFDataProvider:lo,GetMappingForKey:Be,GetPathToObjectConverter:Ie,InteractivityGraphToFlowGraphParser:jr,KHR_animation_pointer:vr,KHR_draco_mesh_compression:Tt,KHR_interactivity:Wr,KHR_lights:wt,KHR_materials_anisotropy:Wt,KHR_materials_clearcoat:Bt,KHR_materials_coat:Dt,KHR_materials_diffuse_roughness:Fn,KHR_materials_diffuse_transmission:bn,KHR_materials_dispersion:Mn,KHR_materials_emissive_strength:Yt,KHR_materials_fuzz:en,KHR_materials_ior:sn,KHR_materials_iridescence:Kt,KHR_materials_pbrSpecularGlossiness:Ft,KHR_materials_sheen:Qt,KHR_materials_specular:rn,KHR_materials_transmission:mn,KHR_materials_unlit:St,KHR_materials_variants:cn,KHR_materials_volume:Tn,KHR_materials_volume_scatter:wn,KHR_mesh_quantization:Sn,KHR_node_hoverability:ro,KHR_node_selectability:Zr,KHR_node_visibility:Xr,KHR_texture_basisu:Bn,KHR_texture_transform:Dn,KHR_xmp_json_ld:Kn,MSFT_audio_emitter:Ar,MSFT_lod:Cr,MSFT_minecraftMesh:Rr,MSFT_sRGBFactors:Pr,SetInterpolationForKey:ke,TransmissionHelper:hn,_AddInteractivityObjectModel:zr,addNewInteractivityFlowGraphMapping:Br,ensureTransmissionHelper:dn,getAllSupportedNativeNodeTypes:Hr,getMappingForDeclaration:Ir,getMappingForFullOperationName:Nr,gltfTypeToBabylonType:Kr},fo={__proto__:null,AddObjectAccessorToKey:Ge,AnimationPropertyInfo:Ye,ArrayItem:He,EXT_lights_area:Mt,EXT_lights_ies:bt,EXT_lights_image_based:rt,EXT_mesh_gpu_instancing:it,EXT_meshopt_compression:ut,EXT_texture_avif:mt,EXT_texture_webp:ht,ExtrasAsMetadata:io,FlowGraphGLTFDataProvider:lo,GLTFFileLoader:k,GLTFLoader:je,GetMappingForKey:Be,GetPathToObjectConverter:Ie,InteractivityGraphToFlowGraphParser:jr,KHR_animation_pointer:vr,KHR_draco_mesh_compression:Tt,KHR_interactivity:Wr,KHR_lights:wt,KHR_materials_anisotropy:Wt,KHR_materials_clearcoat:Bt,KHR_materials_coat:Dt,KHR_materials_diffuse_roughness:Fn,KHR_materials_diffuse_transmission:bn,KHR_materials_dispersion:Mn,KHR_materials_emissive_strength:Yt,KHR_materials_fuzz:en,KHR_materials_ior:sn,KHR_materials_iridescence:Kt,KHR_materials_pbrSpecularGlossiness:Ft,KHR_materials_sheen:Qt,KHR_materials_specular:rn,KHR_materials_transmission:mn,KHR_materials_unlit:St,KHR_materials_variants:cn,KHR_materials_volume:Tn,KHR_materials_volume_scatter:wn,KHR_mesh_quantization:Sn,KHR_node_hoverability:ro,KHR_node_selectability:Zr,KHR_node_visibility:Xr,KHR_texture_basisu:Bn,KHR_texture_transform:Dn,KHR_xmp_json_ld:Kn,LoadBoundingInfoFromPositionAccessor:Ke,MSFT_audio_emitter:Ar,MSFT_lod:Cr,MSFT_minecraftMesh:Rr,MSFT_sRGBFactors:Pr,OpenPBRMaterialLoadingAdapter:Ze,PBRMaterialLoadingAdapter:et,SetInterpolationForKey:ke,TransformNodeAnimationPropertyInfo:Xe,TransmissionHelper:hn,WeightAnimationPropertyInfo:Je,_AddInteractivityObjectModel:zr,addNewInteractivityFlowGraphMapping:Br,ensureTransmissionHelper:dn,getAllSupportedNativeNodeTypes:Hr,getMappingForDeclaration:Ir,getMappingForFullOperationName:Nr,getQuaternion:ze,getVector3:We,getWeights:qe,gltfTypeToBabylonType:Kr,registerGLTFExtension:Ae,registeredGLTFExtensions:xe,unregisterGLTFExtension:we},ho=function(){function e(){this.materials=[]}return e.prototype.parseMTL=function(n,r,o,a){if(!(r instanceof ArrayBuffer)){for(var i,s=r.split("\n"),l=/\s+/,u=null,c=0;c<s.length;c++){var f=s[c].trim();if(0!==f.length&&"#"!==f.charAt(0)){var h=f.indexOf(" "),d=h>=0?f.substring(0,h):f;d=d.toLowerCase();var p=h>=0?f.substring(h+1).trim():"";if("newmtl"===d)u&&this.materials.push(u),n._blockEntityCollection=!!a,(u=new t.StandardMaterial(p,n))._parentContainer=a,n._blockEntityCollection=!1;else if("kd"===d&&u)i=p.split(l,3).map(parseFloat),u.diffuseColor=t.Color3.FromArray(i);else if("ka"===d&&u)i=p.split(l,3).map(parseFloat),u.ambientColor=t.Color3.FromArray(i);else if("ks"===d&&u)i=p.split(l,3).map(parseFloat),u.specularColor=t.Color3.FromArray(i);else if("ke"===d&&u)i=p.split(l,3).map(parseFloat),u.emissiveColor=t.Color3.FromArray(i);else if("ns"===d&&u)u.specularPower=parseFloat(p);else if("d"===d&&u)u.alpha=parseFloat(p);else if("map_ka"===d&&u)u.ambientTexture=e._GetTexture(o,p,n);else if("map_kd"===d&&u)u.diffuseTexture=e._GetTexture(o,p,n);else if("map_ks"===d&&u)u.specularTexture=e._GetTexture(o,p,n);else if("map_ns"===d);else if("map_bump"===d&&u){var m=p.split(l),_=m.indexOf("-bm"),g=null;_>=0&&(g=m[_+1],m.splice(_,2)),u.bumpTexture=e._GetTexture(o,m.join(" "),n),u.bumpTexture&&null!==g&&(u.bumpTexture.level=parseFloat(g))}else"map_d"===d&&u&&(u.opacityTexture=e._GetTexture(o,p,n))}}u&&this.materials.push(u)}},e._GetTexture=function(n,r,o){if(!r)return null;var a=n;if("file:"===n){var i=r.lastIndexOf("\\");-1===i&&(i=r.lastIndexOf("/")),a+=i>-1?r.substring(i+1):r}else a+=r;return new t.Texture(a,o,!1,e.INVERT_TEXTURE_Y)},e.INVERT_TEXTURE_Y=!0,e}(),po=function(){function e(e,n,r){this._positions=[],this._normals=[],this._uvs=[],this._colors=[],this._extColors=[],this._meshesFromObj=[],this._indicesForBabylon=[],this._wrappedPositionForBabylon=[],this._wrappedUvsForBabylon=[],this._wrappedColorsForBabylon=[],this._wrappedNormalsForBabylon=[],this._tuplePosNorm=[],this._curPositionInIndices=0,this._hasMeshes=!1,this._unwrappedPositionsForBabylon=[],this._unwrappedColorsForBabylon=[],this._unwrappedNormalsForBabylon=[],this._unwrappedUVForBabylon=[],this._triangles=[],this._materialNameFromObj="",this._objMeshName="",this._increment=1,this._isFirstMaterial=!0,this._grayColor=new t.Color4(.5,.5,.5,1),this._hasLineData=!1,this._materialToUse=e,this._babylonMeshesArray=n,this._loadingOptions=r}return e.prototype._isInArray=function(e,t){e[t[0]]||(e[t[0]]={normals:[],idx:[]});var n=e[t[0]].normals.indexOf(t[1]);return-1===n?-1:e[t[0]].idx[n]},e.prototype._isInArrayUV=function(e,t){e[t[0]]||(e[t[0]]={normals:[],idx:[],uv:[]});var n=e[t[0]].normals.indexOf(t[1]);return 1!=n&&t[2]===e[t[0]].uv[n]?e[t[0]].idx[n]:-1},e.prototype._setData=function(e){var t,n,r;null!==(t=e.indiceUvsFromObj)&&void 0!==t||(e.indiceUvsFromObj=-1),null!==(n=e.indiceNormalFromObj)&&void 0!==n||(e.indiceNormalFromObj=-1),-1===(r=this._loadingOptions.optimizeWithUV?this._isInArrayUV(this._tuplePosNorm,[e.indicePositionFromObj,e.indiceNormalFromObj,e.indiceUvsFromObj]):this._isInArray(this._tuplePosNorm,[e.indicePositionFromObj,e.indiceNormalFromObj]))?(this._indicesForBabylon.push(this._wrappedPositionForBabylon.length),this._wrappedPositionForBabylon.push(e.positionVectorFromOBJ),void 0!==e.textureVectorFromOBJ&&this._wrappedUvsForBabylon.push(e.textureVectorFromOBJ),void 0!==e.normalsVectorFromOBJ&&this._wrappedNormalsForBabylon.push(e.normalsVectorFromOBJ),void 0!==e.positionColorsFromOBJ&&this._wrappedColorsForBabylon.push(e.positionColorsFromOBJ),this._tuplePosNorm[e.indicePositionFromObj].normals.push(e.indiceNormalFromObj),this._tuplePosNorm[e.indicePositionFromObj].idx.push(this._curPositionInIndices++),this._loadingOptions.optimizeWithUV&&this._tuplePosNorm[e.indicePositionFromObj].uv.push(e.indiceUvsFromObj)):this._indicesForBabylon.push(r)},e.prototype._unwrapData=function(){try{for(var e=0;e<this._wrappedPositionForBabylon.length;e++)this._unwrappedPositionsForBabylon.push(this._wrappedPositionForBabylon[e].x*this._handednessSign,this._wrappedPositionForBabylon[e].y,this._wrappedPositionForBabylon[e].z),this._wrappedNormalsForBabylon.length&&this._unwrappedNormalsForBabylon.push(this._wrappedNormalsForBabylon[e].x*this._handednessSign,this._wrappedNormalsForBabylon[e].y,this._wrappedNormalsForBabylon[e].z),this._wrappedUvsForBabylon.length&&this._unwrappedUVForBabylon.push(this._wrappedUvsForBabylon[e].x,this._wrappedUvsForBabylon[e].y),this._wrappedColorsForBabylon.length&&this._unwrappedColorsForBabylon.push(this._wrappedColorsForBabylon[e].r,this._wrappedColorsForBabylon[e].g,this._wrappedColorsForBabylon[e].b,this._wrappedColorsForBabylon[e].a);this._wrappedPositionForBabylon.length=0,this._wrappedNormalsForBabylon.length=0,this._wrappedUvsForBabylon.length=0,this._wrappedColorsForBabylon.length=0,this._tuplePosNorm.length=0,this._curPositionInIndices=0}catch(e){throw new Error("Unable to unwrap data while parsing OBJ data.",{cause:e})}},e.prototype._getTriangles=function(e,t){for(var n=t;n<e.length-1;n++)this._pushTriangle(e,n)},e.prototype._getColor=function(e){var t;return this._loadingOptions.importVertexColors?null!==(t=this._extColors[e])&&void 0!==t?t:this._colors[e]:void 0},e.prototype._setDataForCurrentFaceWithPattern1=function(e,t){this._getTriangles(e,t);for(var n=0;n<this._triangles.length;n++){var r=parseInt(this._triangles[n])-1;this._setData({indicePositionFromObj:r,positionVectorFromOBJ:this._positions[r],positionColorsFromOBJ:this._getColor(r)})}this._triangles.length=0},e.prototype._setDataForCurrentFaceWithPattern2=function(e,t){this._getTriangles(e,t);for(var n=0;n<this._triangles.length;n++){var r=this._triangles[n].split("/"),o=parseInt(r[0])-1,a=parseInt(r[1])-1;this._setData({indicePositionFromObj:o,indiceUvsFromObj:a,positionVectorFromOBJ:this._positions[o],textureVectorFromOBJ:this._uvs[a],positionColorsFromOBJ:this._getColor(o)})}this._triangles.length=0},e.prototype._setDataForCurrentFaceWithPattern3=function(e,t){this._getTriangles(e,t);for(var n=0;n<this._triangles.length;n++){var r=this._triangles[n].split("/"),o=parseInt(r[0])-1,a=parseInt(r[1])-1,i=parseInt(r[2])-1;this._setData({indicePositionFromObj:o,indiceUvsFromObj:a,indiceNormalFromObj:i,positionVectorFromOBJ:this._positions[o],textureVectorFromOBJ:this._uvs[a],normalsVectorFromOBJ:this._normals[i]})}this._triangles.length=0},e.prototype._setDataForCurrentFaceWithPattern4=function(e,t){this._getTriangles(e,t);for(var n=0;n<this._triangles.length;n++){var r=this._triangles[n].split("//"),o=parseInt(r[0])-1,a=parseInt(r[1])-1;this._setData({indicePositionFromObj:o,indiceNormalFromObj:a,positionVectorFromOBJ:this._positions[o],normalsVectorFromOBJ:this._normals[a],positionColorsFromOBJ:this._getColor(o)})}this._triangles.length=0},e.prototype._setDataForCurrentFaceWithPattern5=function(e,t){this._getTriangles(e,t);for(var n=0;n<this._triangles.length;n++){var r=this._triangles[n].split("/"),o=this._positions.length+parseInt(r[0]),a=this._uvs.length+parseInt(r[1]),i=this._normals.length+parseInt(r[2]);this._setData({indicePositionFromObj:o,indiceUvsFromObj:a,indiceNormalFromObj:i,positionVectorFromOBJ:this._positions[o],textureVectorFromOBJ:this._uvs[a],normalsVectorFromOBJ:this._normals[i],positionColorsFromOBJ:this._getColor(o)})}this._triangles.length=0},e.prototype._addPreviousObjMesh=function(){this._meshesFromObj.length>0&&(this._handledMesh=this._meshesFromObj[this._meshesFromObj.length-1],this._unwrapData(),this._loadingOptions.useLegacyBehavior&&this._indicesForBabylon.reverse(),this._handledMesh.indices=this._indicesForBabylon.slice(),this._handledMesh.positions=this._unwrappedPositionsForBabylon.slice(),this._unwrappedNormalsForBabylon.length&&(this._handledMesh.normals=this._unwrappedNormalsForBabylon.slice()),this._unwrappedUVForBabylon.length&&(this._handledMesh.uvs=this._unwrappedUVForBabylon.slice()),this._unwrappedColorsForBabylon.length&&(this._handledMesh.colors=this._unwrappedColorsForBabylon.slice()),this._handledMesh.hasLines=this._hasLineData,this._indicesForBabylon.length=0,this._unwrappedPositionsForBabylon.length=0,this._unwrappedColorsForBabylon.length=0,this._unwrappedNormalsForBabylon.length=0,this._unwrappedUVForBabylon.length=0,this._hasLineData=!1)},e.prototype._optimizeNormals=function(e){var n=e.getVerticesData(t.VertexBuffer.PositionKind),r=e.getVerticesData(t.VertexBuffer.NormalKind),o={};if(n&&r){for(var a=0;a<n.length/3;a++)(l=o[s=n[3*a+0]+"_"+n[3*a+1]+"_"+n[3*a+2]])||(l=[],o[s]=l),l.push(a);var i=new t.Vector3;for(var s in o){var l;if(!((l=o[s]).length<2)){var u=l[0];for(a=1;a<l.length;++a){var c=l[a];r[3*u+0]+=r[3*c+0],r[3*u+1]+=r[3*c+1],r[3*u+2]+=r[3*c+2]}for(i.copyFromFloats(r[3*u+0],r[3*u+1],r[3*u+2]),i.normalize(),a=0;a<l.length;++a)r[3*(c=l[a])+0]=i.x,r[3*c+1]=i.y,r[3*c+2]=i.z}}e.setVerticesData(t.VertexBuffer.NormalKind,r)}},e._IsLineElement=function(e){return e.startsWith("l")},e._IsObjectElement=function(e){return e.startsWith("o")},e._IsGroupElement=function(e){return e.startsWith("g")},e._GetZbrushMRGB=function(e,n){if(!e.startsWith("mrgb"))return null;if(e=e.replace("mrgb","").trim(),n)return[];var r=e.match(/[a-z0-9]/g);if(!r||r.length%8!=0)return[];for(var o=[],a=0;a<r.length/8;a++){var i=r[8*a+2]+r[8*a+3],s=r[8*a+4]+r[8*a+5],l=r[8*a+6]+r[8*a+7];o.push(new t.Color4(parseInt(i,16)/255,parseInt(s,16)/255,parseInt(l,16)/255,1))}return o},e.prototype.parse=function(n,r,o,a,i){var s,l,u=this;r=(r=r.replace(/#MRGB/g,"mrgb")).replace(/#.*$/gm,"").trim(),this._loadingOptions.useLegacyBehavior?(this._pushTriangle=function(e,t){return u._triangles.push(e[0],e[t],e[t+1])},this._handednessSign=1):o.useRightHandedSystem?(this._pushTriangle=function(e,t){return u._triangles.push(e[0],e[t+1],e[t])},this._handednessSign=1):(this._pushTriangle=function(e,t){return u._triangles.push(e[0],e[t],e[t+1])},this._handednessSign=-1);var c=r.split("\n"),f=[],h=[];f.push(h);for(var d=0;d<c.length;d++)if(0!==(g=c[d].trim().replace(/\s\s/g," ")).length&&"#"!==g.charAt(0))if((e._IsGroupElement(g)||e._IsObjectElement(g))&&(h=[],f.push(h)),e._IsLineElement(g))for(var p=g.split(" "),m=1;m<p.length-1;m++)h.push("l ".concat(p[m]," ").concat(p[m+1]));else h.push(g);var _=f.flat();for(d=0;d<_.length;d++){var g,b=void 0;if(0!==(g=_[d].trim().replace(/\s\s/g," ")).length&&"#"!==g.charAt(0))if(e.VertexPattern.test(g)){if(b=g.match(/[^ ]+/g),this._positions.push(new t.Vector3(parseFloat(b[1]),parseFloat(b[2]),parseFloat(b[3]))),this._loadingOptions.importVertexColors)if(b.length>=7){var y=parseFloat(b[4]),v=parseFloat(b[5]),T=parseFloat(b[6]);this._colors.push(new t.Color4(y>1?y/255:y,v>1?v/255:v,T>1?T/255:T,7===b.length||void 0===b[7]?1:parseFloat(b[7])))}else this._colors.push(this._grayColor)}else if(null!==(b=e.NormalPattern.exec(g)))this._normals.push(new t.Vector3(parseFloat(b[1]),parseFloat(b[2]),parseFloat(b[3])));else if(null!==(b=e.UVPattern.exec(g)))this._uvs.push(new t.Vector2(parseFloat(b[1])*this._loadingOptions.UVScaling.x,parseFloat(b[2])*this._loadingOptions.UVScaling.y));else if(null!==(b=e.FacePattern3.exec(g)))this._setDataForCurrentFaceWithPattern3(b[1].trim().split(" "),1);else if(null!==(b=e.FacePattern4.exec(g)))this._setDataForCurrentFaceWithPattern4(b[1].trim().split(" "),1);else if(null!==(b=e.FacePattern5.exec(g)))this._setDataForCurrentFaceWithPattern5(b[1].trim().split(" "),1);else if(null!==(b=e.FacePattern2.exec(g)))this._setDataForCurrentFaceWithPattern2(b[1].trim().split(" "),1);else if(null!==(b=e.FacePattern1.exec(g)))this._setDataForCurrentFaceWithPattern1(b[1].trim().split(" "),1);else if(null!==(b=e.LinePattern1.exec(g)))this._setDataForCurrentFaceWithPattern1(b[1].trim().split(" "),0),this._hasLineData=!0;else if(null!==(b=e.LinePattern2.exec(g)))this._setDataForCurrentFaceWithPattern2(b[1].trim().split(" "),0),this._hasLineData=!0;else if(b=e._GetZbrushMRGB(g,!this._loadingOptions.importVertexColors))for(var x=0,A=b;x<A.length;x++){var w=A[x];this._extColors.push(w)}else if(null!==(b=e.LinePattern3.exec(g)))this._setDataForCurrentFaceWithPattern3(b[1].trim().split(" "),0),this._hasLineData=!0;else if(e.GroupDescriptor.test(g)||e.ObjectDescriptor.test(g)){var O={name:g.substring(2).trim(),indices:null,positions:null,normals:null,uvs:null,colors:null,materialName:this._materialNameFromObj,isObject:e.ObjectDescriptor.test(g)};this._addPreviousObjMesh(),this._meshesFromObj.push(O),this._hasMeshes=!0,this._isFirstMaterial=!0,this._increment=1}else e.UseMtlDescriptor.test(g)?(this._materialNameFromObj=g.substring(7).trim(),this._isFirstMaterial&&this._hasMeshes||(this._addPreviousObjMesh(),O={name:(this._objMeshName||"mesh")+"_mm"+this._increment.toString(),indices:null,positions:null,normals:null,uvs:null,colors:null,materialName:this._materialNameFromObj,isObject:!1},this._increment++,this._meshesFromObj.push(O),this._hasMeshes=!0),this._hasMeshes&&this._isFirstMaterial&&(this._meshesFromObj[this._meshesFromObj.length-1].materialName=this._materialNameFromObj,this._isFirstMaterial=!1)):e.MtlLibGroupDescriptor.test(g)?i(g.substring(7).trim()):e.SmoothDescriptor.test(g)||t.Logger.Log("Unhandled expression at line : "+g)}if(this._hasMeshes&&(this._handledMesh=this._meshesFromObj[this._meshesFromObj.length-1],this._loadingOptions.useLegacyBehavior&&this._indicesForBabylon.reverse(),this._unwrapData(),this._handledMesh.indices=this._indicesForBabylon,this._handledMesh.positions=this._unwrappedPositionsForBabylon,this._unwrappedNormalsForBabylon.length&&(this._handledMesh.normals=this._unwrappedNormalsForBabylon),this._unwrappedUVForBabylon.length&&(this._handledMesh.uvs=this._unwrappedUVForBabylon),this._unwrappedColorsForBabylon.length&&(this._handledMesh.colors=this._unwrappedColorsForBabylon),this._handledMesh.hasLines=this._hasLineData),!this._hasMeshes){var C=null;if(this._indicesForBabylon.length)this._loadingOptions.useLegacyBehavior&&this._indicesForBabylon.reverse(),this._unwrapData();else{for(var M=0,E=this._positions;M<E.length;M++){var R=E[M];this._unwrappedPositionsForBabylon.push(R.x,R.y,R.z)}if(this._normals.length)for(var F=0,L=this._normals;F<L.length;F++){var P=L[F];this._unwrappedNormalsForBabylon.push(P.x,P.y,P.z)}if(this._uvs.length)for(var S=0,N=this._uvs;S<N.length;S++){var I=N[S];this._unwrappedUVForBabylon.push(I.x,I.y)}if(this._extColors.length)for(var B=0,k=this._extColors;B<k.length;B++){var G=k[B];this._unwrappedColorsForBabylon.push(G.r,G.g,G.b,G.a)}else if(this._colors.length)for(var D=0,V=this._colors;D<V.length;D++)G=V[D],this._unwrappedColorsForBabylon.push(G.r,G.g,G.b,G.a);this._materialNameFromObj||((C=new t.StandardMaterial(t.Geometry.RandomId(),o)).pointsCloud=!0,this._materialNameFromObj=C.name,this._normals.length||(C.disableLighting=!0,C.emissiveColor=t.Color3.White()))}this._meshesFromObj.push({name:t.Geometry.RandomId(),indices:this._indicesForBabylon,positions:this._unwrappedPositionsForBabylon,colors:this._unwrappedColorsForBabylon,normals:this._unwrappedNormalsForBabylon,uvs:this._unwrappedUVForBabylon,materialName:this._materialNameFromObj,directMaterial:C,isObject:!0,hasLines:this._hasLineData})}for(var H=0;H<this._meshesFromObj.length;H++){if(n&&this._meshesFromObj[H].name)if(n instanceof Array){if(-1===n.indexOf(this._meshesFromObj[H].name))continue}else if(this._meshesFromObj[H].name!==n)continue;this._handledMesh=this._meshesFromObj[H],o._blockEntityCollection=!!a;var K=new t.Mesh(this._meshesFromObj[H].name,o);if(K._parentContainer=a,o._blockEntityCollection=!1,this._handledMesh._babylonMesh=K,!this._handledMesh.isObject)for(var j=H-1;j>=0;--j)if(this._meshesFromObj[j].isObject&&this._meshesFromObj[j]._babylonMesh){K.parent=this._meshesFromObj[j]._babylonMesh;break}if(this._materialToUse.push(this._meshesFromObj[H].materialName),this._handledMesh.hasLines&&(null!==(s=K._internalMetadata)&&void 0!==s||(K._internalMetadata={}),K._internalMetadata._isLine=!0),0!==(null===(l=this._handledMesh.positions)||void 0===l?void 0:l.length)){var U=new t.VertexData;if(U.indices=this._handledMesh.indices,U.positions=this._handledMesh.positions,this._loadingOptions.computeNormals||!this._handledMesh.normals){var W=new Array;t.VertexData.ComputeNormals(this._handledMesh.positions,this._handledMesh.indices,W),U.normals=W}else U.normals=this._handledMesh.normals;this._handledMesh.uvs&&(U.uvs=this._handledMesh.uvs),this._handledMesh.colors&&(U.colors=this._handledMesh.colors),U.applyToMesh(K),this._loadingOptions.invertY&&(K.scaling.y*=-1),this._loadingOptions.optimizeNormals&&this._optimizeNormals(K),this._babylonMeshesArray.push(K),this._handledMesh.directMaterial&&(K.material=this._handledMesh.directMaterial)}else this._babylonMeshesArray.push(K)}},e.ObjectDescriptor=/^o/,e.GroupDescriptor=/^g/,e.MtlLibGroupDescriptor=/^mtllib /,e.UseMtlDescriptor=/^usemtl /,e.SmoothDescriptor=/^s /,e.VertexPattern=/^v(\s+[\d|.|+|\-|e|E]+){3,7}/,e.NormalPattern=/^vn(\s+[\d|.|+|\-|e|E]+)( +[\d|.|+|\-|e|E]+)( +[\d|.|+|\-|e|E]+)/,e.UVPattern=/^vt(\s+[\d|.|+|\-|e|E]+)( +[\d|.|+|\-|e|E]+)/,e.FacePattern1=/^f\s+(([\d]{1,}[\s]?){3,})+/,e.FacePattern2=/^f\s+((([\d]{1,}\/[\d]{1,}[\s]?){3,})+)/,e.FacePattern3=/^f\s+((([\d]{1,}\/[\d]{1,}\/[\d]{1,}[\s]?){3,})+)/,e.FacePattern4=/^f\s+((([\d]{1,}\/\/[\d]{1,}[\s]?){3,})+)/,e.FacePattern5=/^f\s+(((-[\d]{1,}\/-[\d]{1,}\/-[\d]{1,}[\s]?){3,})+)/,e.LinePattern1=/^l\s+(([\d]{1,}[\s]?){2,})+/,e.LinePattern2=/^l\s+((([\d]{1,}\/[\d]{1,}[\s]?){2,})+)/,e.LinePattern3=/^l\s+((([\d]{1,}\/[\d]{1,}\/[\d]{1,}[\s]?){2,})+)/,e}(),mo={name:"obj",extensions:".obj"},_o=function(){function e(t){this.name=mo.name,this.extensions=mo.extensions,this._assetContainer=null,this._loadingOptions=_(_({},e._DefaultLoadingOptions),null!=t?t:{})}return Object.defineProperty(e,"INVERT_TEXTURE_Y",{get:function(){return ho.INVERT_TEXTURE_Y},set:function(e){ho.INVERT_TEXTURE_Y=e},enumerable:!1,configurable:!0}),Object.defineProperty(e,"_DefaultLoadingOptions",{get:function(){return{computeNormals:e.COMPUTE_NORMALS,optimizeNormals:e.OPTIMIZE_NORMALS,importVertexColors:e.IMPORT_VERTEX_COLORS,invertY:e.INVERT_Y,invertTextureY:e.INVERT_TEXTURE_Y,UVScaling:e.UV_SCALING,materialLoadingFailsSilently:e.MATERIAL_LOADING_FAILS_SILENTLY,optimizeWithUV:e.OPTIMIZE_WITH_UV,skipMaterials:e.SKIP_MATERIALS,useLegacyBehavior:e.USE_LEGACY_BEHAVIOR}},enumerable:!1,configurable:!0}),e.prototype._loadMTL=function(e,n,r,o){var a=n+e;t.Tools.LoadFile(a,r,void 0,void 0,!1,function(e,t){o(a,t)})},e.prototype.createPlugin=function(t){return new e(t[mo.name])},e.prototype.canDirectLoad=function(){return!1},e.prototype.importMeshAsync=function(e,t,n,r){return this._parseSolidAsync(e,t,n,r).then(function(e){return{meshes:e,particleSystems:[],skeletons:[],animationGroups:[],transformNodes:[],geometries:[],lights:[],spriteManagers:[]}})},e.prototype.loadAsync=function(e,t,n){return this.importMeshAsync(null,e,t,n).then(function(){})},e.prototype.loadAssetContainerAsync=function(e,n,r){var o=this,a=new t.AssetContainer(e);return this._assetContainer=a,this.importMeshAsync(null,e,n,r).then(function(e){return e.meshes.forEach(function(e){return a.meshes.push(e)}),e.meshes.forEach(function(e){var t=e.material;t&&-1==a.materials.indexOf(t)&&(a.materials.push(t),t.getActiveTextures().forEach(function(e){-1==a.textures.indexOf(e)&&a.textures.push(e)}))}),o._assetContainer=null,a}).catch(function(e){throw o._assetContainer=null,e})},e.prototype._parseSolidAsync=function(e,n,r,o){var a=this,i="",s=new ho,l=[],u=[];r=r.replace(/#.*$/gm,"").trim(),new po(l,u,this._loadingOptions).parse(e,r,n,this._assetContainer,function(e){i=e});var c=[];return""===i||this._loadingOptions.skipMaterials||c.push(new Promise(function(e,r){a._loadMTL(i,o,function(c){try{s.parseMTL(n,c,o,a._assetContainer);for(var f=0;f<s.materials.length;f++){for(var h=0,d=[],p=void 0;(p=l.indexOf(s.materials[f].name,h))>-1;)d.push(p),h=p+1;if(-1===p&&0===d.length)s.materials[f].dispose();else for(var m=0;m<d.length;m++){var _=u[d[m]],g=s.materials[f];_.material=g,_.getTotalIndices()||(g.pointsCloud=!0)}}e()}catch(n){t.Tools.Warn("Error processing MTL file: '".concat(i,"'")),a._loadingOptions.materialLoadingFailsSilently?e():r(n)}},function(n,o){t.Tools.Warn("Error downloading MTL file: '".concat(i,"'")),a._loadingOptions.materialLoadingFailsSilently?e():r(o)})})),Promise.all(c).then(function(){var e=function(e){var t,n;return Boolean(null!==(n=null===(t=e._internalMetadata)||void 0===t?void 0:t._isLine)&&void 0!==n&&n)};return u.forEach(function(r){var o,a;if(e(r)){var i=null!==(o=r.material)&&void 0!==o?o:new t.StandardMaterial(r.name+"_line",n);i.getBindedMeshes().filter(function(t){return!e(t)}).length>0&&(i=null!==(a=i.clone(i.name+"_line"))&&void 0!==a?a:i),i.wireframe=!0,r.material=i,r._internalMetadata&&(r._internalMetadata._isLine=void 0)}}),u})},e.OPTIMIZE_WITH_UV=!0,e.INVERT_Y=!1,e.IMPORT_VERTEX_COLORS=!1,e.COMPUTE_NORMALS=!1,e.OPTIMIZE_NORMALS=!1,e.UV_SCALING=new t.Vector2(1,1),e.SKIP_MATERIALS=!1,e.MATERIAL_LOADING_FAILS_SILENTLY=!0,e.USE_LEGACY_BEHAVIOR=!1,e}();t.RegisterSceneLoaderPlugin(new _o);var go={__proto__:null,OBJFileLoader:_o},bo={__proto__:null,MTLFileLoader:ho,OBJFileLoader:_o,SolidParser:po},yo={name:"stl",extensions:{".stl":{isBinary:!0}}},vo=function(){function e(){this.solidPattern=/solid (\S*)([\S\s]*?)endsolid[ ]*(\S*)/g,this.facetsPattern=/facet([\s\S]*?)endfacet/g,this.normalPattern=/normal[\s]+([-+]?[0-9]+\.?[0-9]*([eE][-+]?[0-9]+)?)+[\s]+([-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?)+[\s]+([-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?)+/g,this.vertexPattern=/vertex[\s]+([-+]?[0-9]+\.?[0-9]*([eE][-+]?[0-9]+)?)+[\s]+([-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?)+[\s]+([-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?)+/g,this.name=yo.name,this.extensions=yo.extensions}return e.prototype.importMesh=function(e,n,r,o,a){var i;if("string"!=typeof r){if(this._isBinary(r)){var s=new t.Mesh("stlmesh",n);return this._parseBinary(s,r),a&&a.push(s),!0}r=(new TextDecoder).decode(new Uint8Array(r))}for(;i=this.solidPattern.exec(r);){var l=i[1],u=i[3];if(u&&l!=u)return t.Tools.Error("Error in STL, solid name != endsolid name"),!1;if(e&&l)if(e instanceof Array){if(!e.indexOf(l))continue}else if(l!==e)continue;l=l||"stlmesh",s=new t.Mesh(l,n),this._parseASCII(s,i[2]),a&&a.push(s)}return!0},e.prototype.load=function(e,t,n){return this.importMesh(null,e,t,n,null)},e.prototype.loadAssetContainer=function(e,n,r){var o=new t.AssetContainer(e);return e._blockEntityCollection=!0,this.importMesh(null,e,n,r,o.meshes),e._blockEntityCollection=!1,o},e.prototype._isBinary=function(e){var t=new DataView(e);if(t.byteLength<=80)return!1;if(84+50*t.getUint32(80,!0)===t.byteLength)return!0;for(var n=[115,111,108,105,100],r=0;r<5;r++)if(t.getUint8(r)!==n[r])return!0;return!1},e.prototype._parseBinary=function(n,r){for(var o=new DataView(r),a=o.getUint32(80,!0),i=0,s=new Float32Array(3*a*3),l=new Float32Array(3*a*3),u=new Uint32Array(3*a),c=0,f=0;f<a;f++){for(var h=84+50*f,d=o.getFloat32(h,!0),p=o.getFloat32(h+4,!0),m=o.getFloat32(h+8,!0),_=1;_<=3;_++){var g=h+12*_;s[i]=o.getFloat32(g,!0),l[i]=d,e.DO_NOT_ALTER_FILE_COORDINATES?(s[i+1]=o.getFloat32(g+4,!0),s[i+2]=o.getFloat32(g+8,!0),l[i+1]=p,l[i+2]=m):(s[i+2]=o.getFloat32(g+4,!0),s[i+1]=o.getFloat32(g+8,!0),l[i+2]=p,l[i+1]=m),i+=3}e.DO_NOT_ALTER_FILE_COORDINATES?(u[c]=c,u[c+1]=c+2,u[c+2]=c+1,c+=3):(u[c]=c++,u[c]=c++,u[c]=c++)}n.setVerticesData(t.VertexBuffer.PositionKind,s),n.setVerticesData(t.VertexBuffer.NormalKind,l),n.setIndices(u),n.computeWorldMatrix(!0)},e.prototype._parseASCII=function(n,r){for(var o,a=[],i=[],s=[],l=0;o=this.facetsPattern.exec(r);){var u=o[1],c=this.normalPattern.exec(u);if(this.normalPattern.lastIndex=0,c){for(var f=[Number(c[1]),Number(c[5]),Number(c[3])],h=void 0;h=this.vertexPattern.exec(u);)e.DO_NOT_ALTER_FILE_COORDINATES?(a.push(Number(h[1]),Number(h[3]),Number(h[5])),i.push(f[0],f[2],f[1])):(a.push(Number(h[1]),Number(h[5]),Number(h[3])),i.push(f[0],f[1],f[2]));e.DO_NOT_ALTER_FILE_COORDINATES?(s.push(l,l+2,l+1),l+=3):s.push(l++,l++,l++),this.vertexPattern.lastIndex=0}}this.facetsPattern.lastIndex=0,n.setVerticesData(t.VertexBuffer.PositionKind,a),n.setVerticesData(t.VertexBuffer.NormalKind,i),n.setIndices(s),n.computeWorldMatrix(!0)},e.DO_NOT_ALTER_FILE_COORDINATES=!1,e}();t.RegisterSceneLoaderPlugin(new vo);var To={__proto__:null,STLFileLoader:vo},xo={__proto__:null,STLFileLoader:vo},Ao={name:"splat",extensions:{".splat":{isBinary:!0},".ply":{isBinary:!0},".spz":{isBinary:!0},".json":{isBinary:!1},".sog":{isBinary:!0}}},wo=.28209479177387814,Oo=null,Co=null;function Mo(e,n,r){var o,a,i,s,l,u,c,f,h,d,p,m,_,g,y,v,T,x,A,w,O,C,M,E,R,F,L,P,S,N,I,B,k,G,D,V,H,K,j,U,W,z,q,Y,X,J;return void 0===r&&(r=!1),b(this,function(b){switch(b.label){case 0:if(o=e.numPoints,a=new ArrayBuffer(32*o),i=new Float32Array(a),s=new Uint8Array(a),l=e.positions,u=e.scales,c=e.colors,f=e.alphas,h=e.rotations,d=null,p=e.shDegree,m=null,_=0,g=null,y=null,v=null,p>0&&e.sh.length>0){for(_=3*((p+1)*(p+1)-1),T=Math.ceil(_/16),x=n.getEngine(),A=x.getCaps().maxTextureSize,w=Math.ceil(o/A),d=t.AllocateShBuffers(T,w*A*4*4),g=new Int32Array(T),y=new Int32Array(T),D=0;D<T;D++)g[D]=16*D,y[D]=Math.min(16*(D+1),_);v=d,m=e.sh}O=0,b.label=1;case 1:if(!(O<o))return[3,4];if(M=32*O,E=3*O,R=4*O,i[0+(C=8*O)]=l[E+0],i[C+1]=l[E+1],i[C+2]=l[E+2],i[C+3]=Math.exp(u[E+0]),i[C+4]=Math.exp(u[E+1]),i[C+5]=Math.exp(u[E+2]),F=255*(.5+wo*c[E+0]),L=255*(.5+wo*c[E+1]),P=255*(.5+wo*c[E+2]),s[M+24]=F<=0?0:F>=255?255:F+.5|0,s[M+25]=L<=0?0:L>=255?255:L+.5|0,s[M+26]=P<=0?0:P>=255?255:P+.5|0,s[M+27]=1/(1+Math.exp(-f[O]))*255+.5|0,S=127.5*h[R+3]+127.5,N=127.5*h[R+0]+127.5,I=127.5*h[R+1]+127.5,B=127.5*h[R+2]+127.5,s[M+28]=S<=0?0:S>=255?255:S+.5|0,s[M+29]=N<=0?0:N>=255?255:N+.5|0,s[M+30]=I<=0?0:I>=255?255:I+.5|0,s[M+31]=B<=0?0:B>=255?255:B+.5|0,m&&v&&g&&y)for(k=O*_,G=16*O,D=0;D<v.length;D++)for(V=v[D],H=g[D],K=y[D],j=H;j<K;j++)U=128*m[k+j]+128,V[G+j-H]=U<=0?0:U>=255?255:U+.5|0;return O%32768==0&&r?[4]:[3,3];case 2:b.sent(),b.label=3;case 3:return O++,[3,1];case 4:if(e.extensions)for(q=0,Y=e.extensions;q<Y.length;q++)if(X=Y[q],void 0!==(J=X).safeOrbitRadiusMin){W=J.safeOrbitRadiusMin,z=[J.safeOrbitElevationMin,J.safeOrbitElevationMax];break}return[2,{mode:0,data:a,hasVertexColors:!1,sh:null!==d?d:void 0,shDegree:p>0?p:void 0,trainedWithAntialiasing:!!e.antialiased,safeOrbitCameraRadiusMin:W,safeOrbitCameraElevationMinMax:z}]}})}var Eo=.28209479177387814;function Ro(e,t,n){return g(this,void 0,void 0,function(){return b(this,function(r){switch(r.label){case 0:return[4,new Promise(function(r,o){var a,i=n.createCanvasImage();if(!i)throw new Error("Failed to create ImageBitmap");if(i.onload=function(){try{var e=n.createCanvas(i.width,i.height);if(!e)throw new Error("Failed to create canvas");var t=e.getContext("2d");if(!t)throw new Error("Failed to get 2D context");t.drawImage(i,0,0);var a=t.getImageData(0,0,e.width,e.height);r({bits:new Uint8Array(a.data.buffer),width:a.width})}catch(e){o("Error loading image ".concat(i.src," with exception: ").concat(e))}},i.onerror=function(e){o("Error loading image ".concat(i.src," with exception: ").concat(e))},i.crossOrigin="anonymous","string"==typeof e){if(!t)throw new Error("filename is required when using a URL");i.src=e+t}else{var s=new Blob([e],{type:"image/webp"});a=URL.createObjectURL(s),i.src=a}})];case 1:return[2,r.sent()]}})})}function Fo(e,n,r){return g(this,void 0,void 0,function(){var o,a,i,s,l,u,c,f,h,d,p,m,_,g,y,v,T,x,A,w,O,C,M,E,R,F,L,P,S,N,I,B,k,G,D,V,H,K,j,U,W,z,q,Y,X,J,Q,Z,$,ee,te,ne,re,oe,ae,ie,se,le,ue,ce,fe,he,de;return b(this,function(b){switch(b.label){case 0:if(o=e.count?e.count:e.means.shape[0],a=new ArrayBuffer(32*o),i=new Float32Array(a),s=new Float32Array(a),l=new Uint8ClampedArray(a),u=new Uint8ClampedArray(a),c=function(e){return Math.sign(e)*(Math.exp(Math.abs(e))-1)},f=n[0].bits,h=n[1].bits,!Array.isArray(e.means.mins)||!Array.isArray(e.means.maxs))throw new Error("Missing arrays in SOG data.");for(ee=0;ee<o;ee++)for(O=4*ee,ie=0;ie<3;ie++)d=e.means.mins[ie],p=e.means.maxs[ie],m=h[O+ie],_=f[O+ie],K=m<<8|_,te=t.Scalar.Lerp(d,p,K/65535),i[8*ee+ie]=c(te);if(g=n[2].bits,2===e.version){if(!e.scales.codebook)throw new Error("Missing codebook in SOG version 2 scales data.");for(ee=0;ee<o;ee++)for(O=4*ee,ie=0;ie<3;ie++)v=e.scales.codebook[g[O+ie]],y=Math.exp(v),s[8*ee+3+ie]=y}else{if(!Array.isArray(e.scales.mins)||!Array.isArray(e.scales.maxs))throw new Error("Missing arrays in SOG scales data.");for(ee=0;ee<o;ee++)for(O=4*ee,ie=0;ie<3;ie++)v=g[O+ie],T=t.Scalar.Lerp(e.scales.mins[ie],e.scales.maxs[ie],v/255),x=Math.exp(T),s[8*ee+3+ie]=x}if(A=n[4].bits,2===e.version){if(!e.sh0.codebook)throw new Error("Missing codebook in SOG version 2 sh0 data.");for(ee=0;ee<o;ee++){for(O=4*ee,ie=0;ie<3;ie++)w=.5+e.sh0.codebook[A[O+ie]]*Eo,l[32*ee+24+ie]=Math.max(0,Math.min(255,Math.round(255*w)));l[32*ee+24+3]=A[O+3]}}else{if(!Array.isArray(e.sh0.mins)||!Array.isArray(e.sh0.maxs))throw new Error("Missing arrays in SOG sh0 data.");for(ee=0;ee<o;ee++)for(O=4*ee,ie=0;ie<4;ie++)C=e.sh0.mins[ie],M=e.sh0.maxs[ie],E=A[O+ie],G=t.Scalar.Lerp(C,M,E/255),void 0,R=ie<3?.5+G*Eo:1/(1+Math.exp(-G)),l[32*ee+24+ie]=Math.max(0,Math.min(255,Math.round(255*R)))}for(F=function(e){return 2*(e/255-.5)/Math.SQRT2},L=n[3].bits,ee=0;ee<o;ee++){switch(P=L[4*ee+0],S=L[4*ee+1],N=L[4*ee+2],I=L[4*ee+3],B=F(P),k=F(S),G=F(N),D=I-252,V=B*B+k*k+G*G,H=Math.sqrt(Math.max(0,1-V)),K=void 0,D){case 0:K=[H,B,k,G];break;case 1:K=[B,H,k,G];break;case 2:K=[B,k,H,G];break;case 3:K=[B,k,G,H];break;default:throw new Error("Invalid quaternion mode")}u[32*ee+28+0]=127.5*K[0]+127.5,u[32*ee+28+1]=127.5*K[1]+127.5,u[32*ee+28+2]=127.5*K[2]+127.5,u[32*ee+28+3]=127.5*K[3]+127.5}if(!e.shN)return[3,2];if(j=e.shN.bands?Math.pow(e.shN.bands+1,2)-1:e.shN.shape[1]/3,U=void 0!==e.shN.bands&&null!==e.shN.bands?e.shN.bands:Math.round(Math.sqrt(j+1)-1),W=n[5].bits,z=n[6].bits,q=n[5].width,Y=3*j,X=Math.ceil(Y/16),J=r.getEngine(),Q=J.getCaps().maxTextureSize,Z=Math.ceil(o/Q),$=t.AllocateShBuffers(X,Z*Q*4*4),2===e.version){if(!e.shN.codebook)throw new Error("Missing codebook in SOG version 2 shN data.");for(ee=0;ee<o;ee++)for(te=z[4*ee+0]+(z[4*ee+1]<<8),ne=te%64*j,re=Math.floor(te/64),se=0;se<j;se++)for(ie=0;ie<3;ie++)le=3*se+ie,ue=Math.floor(le/16),ce=$[ue],fe=le%16,he=16*ee,de=127.5*e.shN.codebook[W[4*(ne+se)+ie+re*q*4]]+127.5,ce[fe+he]=Math.max(0,Math.min(255,de))}else for(ee=0;ee<o;ee++)for(te=z[4*ee+0]+(z[4*ee+1]<<8),ne=te%64*j,re=Math.floor(te/64),oe=e.shN.mins,ae=e.shN.maxs,ie=0;ie<3;ie++)for(se=0;se<j/3;se++)le=3*se+ie,ue=Math.floor(le/16),ce=$[ue],fe=le%16,he=16*ee,de=127.5*t.Scalar.Lerp(oe,ae,W[4*(ne+se)+ie+re*q*4]/255)+127.5,ce[fe+he]=Math.max(0,Math.min(255,de));return[4,new Promise(function(e){e({mode:0,data:a,hasVertexColors:!1,sh:$,shDegree:U})})];case 1:case 3:return[2,b.sent()];case 2:return[4,new Promise(function(e){e({mode:0,data:a,hasVertexColors:!1})})]}})})}function Lo(e,t,n){return g(this,void 0,void 0,function(){var r,o,a,i,s,l=this;return b(this,function(u){switch(u.label){case 0:if(e instanceof Map){if(!(a=(o=e).get("meta.json")))throw new Error("meta.json not found in files Map");r=JSON.parse((new TextDecoder).decode(a))}else r=e;return i=y(y(y(y([],r.means.files,!0),r.scales.files,!0),r.quats.files,!0),r.sh0.files,!0),r.shN&&i.push.apply(i,r.shN.files),[4,Promise.all(i.map(function(e){return g(l,void 0,void 0,function(){return b(this,function(r){switch(r.label){case 0:return o&&o.has(e)?[4,Ro(o.get(e),e,n.getEngine())]:[3,2];case 1:case 3:return[2,r.sent()];case 2:return[4,Ro(t,e,n.getEngine())]}})})}))];case 1:return s=u.sent(),[4,Fo(r,s,n)];case 2:return[2,u.sent()]}})})}function Po(e,n,r,o){var a=new t.RawTexture(n,r,o,t.Constants.TEXTUREFORMAT_RGBA,e,!1,!1,t.Constants.TEXTURE_NEAREST_SAMPLINGMODE,t.Constants.TEXTURETYPE_UNSIGNED_BYTE);return a.wrapU=t.Constants.TEXTURE_CLAMP_ADDRESSMODE,a.wrapV=t.Constants.TEXTURE_CLAMP_ADDRESSMODE,a}function So(e,n,r,o){var a=function(e){return Math.sign(e)*(Math.exp(Math.abs(e))-1)};if(!Array.isArray(e.means.mins)||!Array.isArray(e.means.maxs))throw new Error("Missing arrays in SOG data.");for(var i=new Float32Array(4*o),s=0;s<o;s++){for(var l=4*s,u=0;u<3;u++){var c=r[l+u]<<8|n[l+u],f=t.Scalar.Lerp(e.means.mins[u],e.means.maxs[u],c/65535);i[4*s+u]=a(f)}i[4*s+3]=1}return i}function No(e,n,r){return g(this,void 0,void 0,function(){var o,a,i,s,l,u,c,f,h,d,p,m,_,v,T,x,A,w,O,C,M,E,R,F,L,P,S,N,I,B,k,G,D,V=this;return b(this,function(H){switch(H.label){case 0:if(e instanceof Map){if(!(i=(a=e).get("meta.json")))throw new Error("meta.json not found in files Map");o=JSON.parse((new TextDecoder).decode(i))}else o=e;return s=y(y(y(y([],o.means.files,!0),o.scales.files,!0),o.quats.files,!0),o.sh0.files,!0),o.shN&&s.push.apply(s,o.shN.files),[4,Promise.all(s.map(function(e){return g(V,void 0,void 0,function(){return b(this,function(t){switch(t.label){case 0:return a&&a.has(e)?[4,Ro(a.get(e),e,r.getEngine())]:[3,2];case 1:case 3:return[2,t.sent()];case 2:return[4,Ro(n,e,r.getEngine())]}})})}))];case 1:return l=H.sent(),u=null!==(I=o.count)&&void 0!==I?I:o.means.shape[0],c=r.getEngine(),f=Math.min(u,c.getCaps().maxTextureSize),h=Math.ceil(u/f),d=Po(r,l[0].bits,f,h),p=Po(r,l[1].bits,f,h),m=Po(r,l[2].bits,f,h),_=Po(r,l[3].bits,f,h),v=Po(r,l[4].bits,f,h),A=0,w=0,o.shN&&l.length>=7&&(O=l[5],C=l[6],M=O.bits.length/4/O.width,T=Po(r,O.bits,O.width,M),E=C.bits.length/4/C.width,x=Po(r,C.bits,C.width,E),A=o.shN.bands?Math.pow(o.shN.bands+1,2)-1:o.shN.shape[1]/3,w=null!==(B=o.shN.bands)&&void 0!==B?B:Math.round(Math.sqrt(A+1)-1)),2===o.version&&(F=256,L=new Float32Array(768),o.scales.codebook&&L.set(o.scales.codebook.slice(0,F),0),o.sh0.codebook&&L.set(o.sh0.codebook.slice(0,F),F),(null===(k=o.shN)||void 0===k?void 0:k.codebook)&&L.set(o.shN.codebook.slice(0,F),512),(R=new t.RawTexture(L,768,1,t.Constants.TEXTUREFORMAT_R,r,!1,!1,t.Constants.TEXTURE_NEAREST_SAMPLINGMODE,t.Constants.TEXTURETYPE_FLOAT)).wrapU=t.Constants.TEXTURE_CLAMP_ADDRESSMODE,R.wrapV=t.Constants.TEXTURE_CLAMP_ADDRESSMODE),P=o.means.mins,S=o.means.maxs,N={version:2===o.version?2:1,splatCount:u,shDegree:w,meansTextureL:d,meansTextureU:p,scalesTexture:m,quatsTexture:_,sh0Texture:v,shCentroidsTexture:T,shLabelsTexture:x,codebookTexture:R,meansMin:[P[0],P[1],P[2]],meansMax:[S[0],S[1],S[2]],scalesMin:Array.isArray(o.scales.mins)?[o.scales.mins[0],o.scales.mins[1],o.scales.mins[2]]:void 0,scalesMax:Array.isArray(o.scales.maxs)?[o.scales.maxs[0],o.scales.maxs[1],o.scales.maxs[2]]:void 0,sh0Min:Array.isArray(o.sh0.mins)?[o.sh0.mins[0],o.sh0.mins[1],o.sh0.mins[2],o.sh0.mins[3]]:void 0,sh0Max:Array.isArray(o.sh0.maxs)?[o.sh0.maxs[0],o.sh0.maxs[1],o.sh0.maxs[2],o.sh0.maxs[3]]:void 0,shnMin:"number"==typeof(null===(G=o.shN)||void 0===G?void 0:G.mins)?o.shN.mins:void 0,shnMax:"number"==typeof(null===(D=o.shN)||void 0===D?void 0:D.maxs)?o.shN.maxs:void 0,shCoeffCount:A,positions:So(o,l[0].bits,l[1].bits,u)},[2,{mode:0,data:new ArrayBuffer(0),hasVertexColors:!1,shDegree:w,sogTextures:N}]}})})}var Io=function(){function e(t){void 0===t&&(t={}),this.name=Ao.name,this._assetContainer=null,this.extensions=Ao.extensions,this._loadingOptions=_(_({},e._DefaultLoadingOptions),t)}return e.prototype.createPlugin=function(t){return new e(t[Ao.name])},e.prototype.importMeshAsync=function(e,t,n,r,o,a){return g(this,void 0,void 0,function(){return b(this,function(o){switch(o.label){case 0:return[4,this._parseAsync(e,t,n,r).then(function(e){return{meshes:e,particleSystems:[],skeletons:[],animationGroups:[],transformNodes:[],geometries:[],lights:[],spriteManagers:[]}})];case 1:return[2,o.sent()]}})})},e._BuildPointCloud=function(e,n){if(!n.byteLength)return!1;var r=new Uint8Array(n),o=new Float32Array(n),a=r.length/32;return e.addPoints(a,function(e,n){var a=o[8*n+0],i=o[8*n+1],s=o[8*n+2];e.position=new t.Vector3(a,i,s);var l=r[32*n+24+0]/255,u=r[32*n+24+1]/255,c=r[32*n+24+2]/255;e.color=new t.Color4(l,u,c,1)}),!0},e._BuildMesh=function(e,n){for(var r=new t.Mesh("PLYMesh",e),o=new Uint8Array(n.data),a=new Float32Array(n.data),i=o.length/32,s=[],l=new t.VertexData,u=0;u<i;u++){var c=a[8*u+0],f=a[8*u+1],h=a[8*u+2];s.push(c,f,h)}if(n.hasVertexColors){var d=new Float32Array(4*i);for(u=0;u<i;u++){var p=o[32*u+24+0]/255,m=o[32*u+24+1]/255,_=o[32*u+24+2]/255;d[4*u+0]=p,d[4*u+1]=m,d[4*u+2]=_,d[4*u+3]=1}l.colors=d}return l.positions=s,l.indices=n.faces,l.applyToMesh(r),r},e.prototype._unzipWithFFlateAsync=function(e){return g(this,void 0,void 0,function(){var n,r,o,a,i,s,l,u,c,f;return b(this,function(h){switch(h.label){case 0:return(n=this._loadingOptions.fflate)?[3,3]:void 0!==window.fflate?[3,2]:[4,t.Tools.LoadScriptAsync(null!==(f=this._loadingOptions.deflateURL)&&void 0!==f?f:"https://unpkg.com/fflate/umd/index.js")];case 1:h.sent(),h.label=2;case 2:n=window.fflate,h.label=3;case 3:for(r=n.unzipSync,o=r(e),a=new Map,i=0,s=Object.entries(o);i<s.length;i++)l=s[i],u=l[0],c=l[1],a.set(u,c);return[2,a]}})})},e.prototype._parseAsync=function(n,r,o,a){var i=this,s=[],l=function(e){var n;r._blockEntityCollection=!!i._assetContainer;var o=null!==(n=i._loadingOptions.gaussianSplattingMesh)&&void 0!==n?n:new t.GaussianSplattingMesh("GaussianSplatting",null,r,i._loadingOptions.keepInRam,i._loadingOptions.needsRotationScaleTextures);o._parentContainer=i._assetContainer,s.push(o),e.sogTextures?o.setSogTextureData(e.sogTextures):o.updateData(e.data,e.sh,{flipY:!1},void 0,e.shDegree),o.scaling.y*=-1,o.computeWorldMatrix(!0),r._blockEntityCollection=!1},u=r.getEngine(),c=this._loadingOptions.useSogTextures;c&&!u.isWebGPU&&u.version<2&&(t.Logger.Warn("SPLATFileLoader: useSogTextures requires WebGL2 or WebGPU. Falling back to CPU path."),c=!1);var f=c?No:Lo;if("string"==typeof o){var h=JSON.parse(o);if(h&&h.means&&h.scales&&h.quats&&h.sh0)return new Promise(function(e,t){f(h,a,r).then(function(t){l(t),e(s)}).catch(function(e){t(new Error("Failed to parse SOG data.",{cause:e}))})})}var d=o instanceof ArrayBuffer?new Uint8Array(o):o;if(80===d[0]&&75===d[1])return new Promise(function(e,t){i._unzipWithFFlateAsync(d).then(function(n){f(n,a,r).then(function(t){l(t),e(s)}).catch(function(e){t(new Error("Failed to parse SOG zip data.",{cause:e}))})})});var p=function(n){e._ConvertPLYToSplat(o).then(function(o){return g(i,void 0,void 0,function(){var a,i,l;return b(this,function(u){switch(u.label){case 0:switch(r._blockEntityCollection=!!this._assetContainer,o.mode){case 0:return[3,1];case 1:return[3,2];case 2:return[3,6]}return[3,7];case 1:switch((a=null!==(l=this._loadingOptions.gaussianSplattingMesh)&&void 0!==l?l:new t.GaussianSplattingMesh("GaussianSplatting",null,r,this._loadingOptions.keepInRam,this._loadingOptions.needsRotationScaleTextures))._parentContainer=this._assetContainer,s.push(a),a.updateData(o.data,o.sh,{flipY:!1},void 0,o.shDegree),a.scaling.y*=-1,"RightHanded"===o.chirality&&(a.scaling.y*=-1),o.upAxis){case"X":a.rotation=new t.Vector3(0,0,Math.PI/2);break;case"Y":a.rotation=new t.Vector3(0,0,Math.PI);break;case"Z":a.rotation=new t.Vector3(-Math.PI/2,Math.PI,0)}return a.computeWorldMatrix(!0),[3,8];case 2:return i=new t.PointsCloudSystem("PointCloud",1,r),e._BuildPointCloud(i,o.data)?[4,i.buildMeshAsync().then(function(e){s.push(e)})]:[3,4];case 3:return u.sent(),[3,5];case 4:i.dispose(),u.label=5;case 5:return[3,8];case 6:if(!o.faces)throw new Error("PLY mesh doesn't contain face informations.");return s.push(e._BuildMesh(r,o)),[3,8];case 7:throw new Error("Unsupported Splat mode");case 8:return r._blockEntityCollection=!1,this.applyAutoCameraLimits(o,r),n(s),[2]}})})})},m=31===d[0]&&139===d[1],_=78===d[0]&&71===d[1]&&83===d[2]&&80===d[3];if(!m&&!_)return new Promise(function(e){p(e)});var y=function(e,n){var o;r._blockEntityCollection=!!i._assetContainer;var a=null!==(o=i._loadingOptions.gaussianSplattingMesh)&&void 0!==o?o:new t.GaussianSplattingMesh("GaussianSplatting",null,r,i._loadingOptions.keepInRam,i._loadingOptions.needsRotationScaleTextures);if(e.trainedWithAntialiasing){var l=a.material;l.kernelSize=.1,l.compensation=!0}a._parentContainer=i._assetContainer,s.push(a),a.updateData(e.data,e.sh,{flipY:!1},void 0,e.shDegree),i._loadingOptions.flipY||(a.scaling.y*=-1,a.computeWorldMatrix(!0)),r._blockEntityCollection=!1,i.applyAutoCameraLimits(e,r),n(s)};if(this._loadingOptions.spzLibraryUrl)return function(e){return g(this,void 0,void 0,function(){var n;return b(this,function(r){switch(r.label){case 0:return Oo&&Co===e?[4,Oo]:[3,2];case 1:case 3:return[2,r.sent()];case 2:return n=t._LoadScriptModuleAsync("import createSpzModule from '".concat(e,"';\n const module = await createSpzModule();\n const returnedValue = module;")),Co=e,Oo=n,[4,n]}})})}(this._loadingOptions.spzLibraryUrl).then(function(e){return function(e,n){return g(this,void 0,void 0,function(){return b(this,function(r){switch(r.label){case 0:return[4,t.runCoroutineAsync(Mo(e,n,!0),t.createYieldingScheduler())];case 1:return[2,r.sent()]}})})}(e.loadSpzFromBuffer(new Uint8Array(o),{to:e.CoordinateSystem.RUB}),r).then(function(e){return new Promise(function(t){y(e,t)})})});if(_)return Promise.reject(new Error("SPZ V4+ files (NGSP format) are not supported by the native fallback loader. Please provide a valid 'spzLibraryUrl' in the loading options to use the WASM-based SPZ library, or ensure WebAssembly is available in your environment."));var v=new ReadableStream({start:function(e){e.enqueue(new Uint8Array(o)),e.close()}}),T=new DecompressionStream("gzip"),x=v.pipeThrough(T);return new Promise(function(e){new Response(x).arrayBuffer().then(function(n){(function(e,n){var r=new Uint8Array(e),o=new Uint32Array(e.slice(0,12)),a=o[2],i=r[12],s=r[13],l=r[14],u=r[15],c=o[1];if(u||1347635022!=o[0]||c<2||c>4)return new Promise(function(e){e({mode:3,data:new ArrayBuffer(0),hasVertexColors:!1})});for(var f=new ArrayBuffer(32*a),h=1/(1<<s),d=new Int32Array(1),p=new Uint8Array(d.buffer),m=function(e,t){return p[0]=e[t+0],p[1]=e[t+1],p[2]=e[t+2],p[3]=128&e[t+2]?255:0,d[0]*h},_=16,g=new Float32Array(f),b=new Float32Array(f),y=new Uint8ClampedArray(f),v=new Uint8ClampedArray(f),T=0;T<a;T++)g[8*T+0]=m(r,_+0),g[8*T+1]=m(r,_+3),g[8*T+2]=m(r,_+6),_+=9;for(T=0;T<a;T++){for(var x=0;x<3;x++){var A=(r[_+a+3*T+x]-127.5)/38.25;y[32*T+24+x]=t.Scalar.Clamp(255*(.5+wo*A),0,255)}y[32*T+24+3]=r[_+T]}for(_+=4*a,T=0;T<a;T++)b[8*T+3+0]=Math.exp(r[_+0]/16-10),b[8*T+3+1]=Math.exp(r[_+1]/16-10),b[8*T+3+2]=Math.exp(r[_+2]/16-10),_+=3;if(c>=3){var w=Math.SQRT1_2;for(T=0;T<a;T++){for(var O=[r[_+0],r[_+1],r[_+2],r[_+3]],C=O[0]+(O[1]<<8)+(O[2]<<16)+(O[3]<<24),M=[],E=C>>>30,R=C,F=0,L=3;L>=0;--L)if(L!==E){var P=511&R,S=R>>>9&1;R>>>=10,M[L]=w*(P/511),1===S&&(M[L]=-M[L]),F+=M[L]*M[L]}var N=1-F;M[E]=Math.sqrt(Math.max(N,0));for(var I=[3,0,1,2],B=0;B<4;B++)v[32*T+28+B]=Math.round(127.5+127.5*M[I[B]]);_+=4}}else for(T=0;T<a;T++){var k=r[_+0],G=r[_+1],D=r[_+2],V=k/127.5-1,H=G/127.5-1,K=D/127.5-1;v[32*T+28+1]=k,v[32*T+28+2]=G,v[32*T+28+3]=D;var j=1-(V*V+H*H+K*K);v[32*T+28+0]=127.5+127.5*Math.sqrt(j<0?0:j),_+=3}if(i){var U=3*((i+1)*(i+1)-1),W=Math.ceil(U/16),z=_,q=n.getEngine().getCaps().maxTextureSize,Y=Math.ceil(a/q),X=t.AllocateShBuffers(W,Y*q*4*4);for(T=0;T<a;T++)for(var J=0;J<U;J++){var Q=r[z++],Z=Math.floor(J/16);X[Z][J%16+16*T]=Q}return new Promise(function(e){e({mode:0,data:f,hasVertexColors:!1,sh:X,shDegree:i,trainedWithAntialiasing:!!l})})}return new Promise(function(e){e({mode:0,data:f,hasVertexColors:!1,trainedWithAntialiasing:!!l})})})(n,r,i._loadingOptions).then(function(t){y(t,e)})}).catch(function(){p(e)})})},e.prototype.applyAutoCameraLimits=function(e,t){var n;if(!this._loadingOptions.disableAutoCameraLimits&&(void 0!==e.safeOrbitCameraRadiusMin||void 0!==e.safeOrbitCameraElevationMinMax)&&"ArcRotateCamera"===(null===(n=t.activeCamera)||void 0===n?void 0:n.getClassName())){var r=t.activeCamera;e.safeOrbitCameraElevationMinMax&&(r.lowerBetaLimit=.5*Math.PI-e.safeOrbitCameraElevationMinMax[1],r.upperBetaLimit=.5*Math.PI-e.safeOrbitCameraElevationMinMax[0]),e.safeOrbitCameraRadiusMin&&(r.lowerRadiusLimit=e.safeOrbitCameraRadiusMin)}},e.prototype.loadAssetContainerAsync=function(e,n,r){var o=this,a=new t.AssetContainer(e);return this._assetContainer=a,this.importMeshAsync(null,e,n,r).then(function(e){for(var t=0,n=e.meshes;t<n.length;t++){var r=n[t];a.meshes.push(r)}return o._assetContainer=null,a}).catch(function(e){throw o._assetContainer=null,e})},e.prototype.loadAsync=function(e,t,n){return this.importMeshAsync(null,e,t,n).then(function(){})},e._ConvertPLYToSplat=function(e){var n=this,r=new Uint8Array(e),o=(new TextDecoder).decode(r.slice(0,10240)),a=o.indexOf("end_header\n");if(a<0||!o)return new Promise(function(t){t({mode:0,data:e,rawSplat:!0})});var i=parseInt(/element vertex (\d+)\n/.exec(o)[1]),s=/element face (\d+)\n/.exec(o),l=0;s&&(l=parseInt(s[1]));var u=/element chunk (\d+)\n/.exec(o),c=0;u&&(c=parseInt(u[1]));for(var f=0,h=0,d={double:8,int:4,uint:4,float:4,short:2,ushort:2,uchar:1,list:0},p=1,m=[],y=[],v=o.slice(0,a).split("\n"),T={},x=0,A=v;x<A.length;x++){var w=A[x];if(w.startsWith("property ")){var O=w.split(" "),C=O[1],M=O[2];if(1==p)y.push({name:M,type:C,offset:h}),h+=d[C];else if(0==p)m.push({name:M,type:C,offset:f}),f+=d[C];else if(2==p)m.push({name:M,type:C,offset:f});else if(3==p){var E=new DataView(e,h,2*d.float);T.safeOrbitCameraElevationMinMax=[E.getFloat32(0,!0),E.getFloat32(4,!0)]}else 4==p?(E=new DataView(e,h,d.float),T.safeOrbitCameraRadiusMin=E.getFloat32(0,!0)):5==p&&(E=new DataView(e,h,d.uchar),"up_axis"==M?T.upAxis=0==E.getUint8(0)?"X":1==E.getUint8(0)?"Y":"Z":"chirality"==M&&(T.chirality=0==E.getUint8(0)?"LeftHanded":"RightHanded"));d[C]||t.Logger.Warn("Unsupported property type: ".concat(C,"."))}else w.startsWith("element ")&&("chunk"==(C=w.split(" ")[1])?p=1:"vertex"==C?p=0:"sh"==C?p=2:"safe_orbit_camera_elevation_min_max_radians"==C?p=3:"safe_orbit_camera_radius_min"==C?p=4:"up_axis"!=C&&"chirality"!=C||(p=5))}var R=f,F=h;return t.GaussianSplattingMesh.ConvertPLYWithSHToSplatAsync(e).then(function(t){return g(n,void 0,void 0,function(){var n,r,o,s,u,f,h,d,p,g,y,v,x,A,w;return b(this,function(b){switch(b.label){case 0:if(n=new DataView(e,a+11),r=F*c+R*i,o=[],l)for(s=0;s<l;s++)if(3==(u=n.getUint8(r))){for(r+=1,f=0;f<u;f++)h=n.getUint32(r+4*(2-f),!0),o.push(h);r+=12}return c?[4,new Promise(function(e){e({mode:0,data:t.buffer,sh:t.sh,shDegree:t.shDegree,faces:o,hasVertexColors:!1,compressed:!0,rawSplat:!1})})]:[3,2];case 1:case 3:return[2,b.sent()];case 2:for(d=0,p=0,g=["x","y","z","scale_0","scale_1","scale_2","opacity","rot_0","rot_1","rot_2","rot_3"],y=["red","green","blue","f_dc_0","f_dc_1","f_dc_2"],v=0;v<m.length;v++)x=m[v],g.includes(x.name)&&d++,y.includes(x.name)&&p++;return A=d==g.length&&3==p,w=l?2:A?0:1,[4,new Promise(function(e){e(_(_({},T),{mode:w,data:t.buffer,sh:t.sh,shDegree:t.shDegree,faces:o,hasVertexColors:!!p,compressed:!1,rawSplat:!1}))})]}})})})},e._DefaultLoadingOptions={keepInRam:!1,flipY:!1,needsRotationScaleTextures:!1,spzLibraryUrl:"object"==typeof WebAssembly?"https://unpkg.com/@adobe/spz@0.2.2/dist/spz.js":void 0},e}();t.RegisterSceneLoaderPlugin(new Io);var Bo={__proto__:null,SPLATFileLoader:Io};function ko(){var e=this;t.RegisterSceneLoaderPlugin(_(_({},v),{createPlugin:function(t){return g(e,void 0,void 0,function(){return b(this,function(e){switch(e.label){case 0:return[4,Promise.resolve().then(function(){return x})];case 1:return[2,new(0,e.sent().BVHFileLoader)(t[v.name])]}})})}})),t.RegisterSceneLoaderPlugin(_(_({},P),{createPlugin:function(t){return g(e,void 0,void 0,function(){return b(this,function(e){switch(e.label){case 0:return[4,Promise.resolve().then(function(){return Ue})];case 1:return[2,new(0,e.sent().GLTFFileLoader)(t[P.name])]}})})}})),function(){var e=this;we("EXT_lights_image_based"),Ae("EXT_lights_image_based",!0,function(t){return g(e,void 0,void 0,function(){return b(this,function(e){switch(e.label){case 0:return[4,Promise.resolve().then(function(){return ot})];case 1:return[2,new(0,e.sent().EXT_lights_image_based)(t)]}})})}),we("EXT_mesh_gpu_instancing"),Ae("EXT_mesh_gpu_instancing",!0,function(t){return g(e,void 0,void 0,function(){return b(this,function(e){switch(e.label){case 0:return[4,Promise.resolve().then(function(){return st})];case 1:return[2,new(0,e.sent().EXT_mesh_gpu_instancing)(t)]}})})}),we("EXT_meshopt_compression"),Ae("EXT_meshopt_compression",!0,function(t){return g(e,void 0,void 0,function(){return b(this,function(e){switch(e.label){case 0:return[4,Promise.resolve().then(function(){return ct})];case 1:return[2,new(0,e.sent().EXT_meshopt_compression)(t)]}})})}),we("EXT_texture_avif"),Ae("EXT_texture_avif",!0,function(t){return g(e,void 0,void 0,function(){return b(this,function(e){switch(e.label){case 0:return[4,Promise.resolve().then(function(){return _t})];case 1:return[2,new(0,e.sent().EXT_texture_avif)(t)]}})})}),we("EXT_texture_webp"),Ae("EXT_texture_webp",!0,function(t){return g(e,void 0,void 0,function(){return b(this,function(e){switch(e.label){case 0:return[4,Promise.resolve().then(function(){return dt})];case 1:return[2,new(0,e.sent().EXT_texture_webp)(t)]}})})}),we("ExtrasAsMetadata"),Ae("ExtrasAsMetadata",!1,function(t){return g(e,void 0,void 0,function(){return b(this,function(e){switch(e.label){case 0:return[4,Promise.resolve().then(function(){return so})];case 1:return[2,new(0,e.sent().ExtrasAsMetadata)(t)]}})})}),we("KHR_animation_pointer"),Ae("KHR_animation_pointer",!0,function(t){return g(e,void 0,void 0,function(){return b(this,function(e){switch(e.label){case 0:return[4,Promise.resolve().then(function(){return Tr})];case 1:return[2,new(0,e.sent().KHR_animation_pointer)(t)]}})})}),we("KHR_draco_mesh_compression"),Ae("KHR_draco_mesh_compression",!0,function(t){return g(e,void 0,void 0,function(){return b(this,function(e){switch(e.label){case 0:return[4,Promise.resolve().then(function(){return xt})];case 1:return[2,new(0,e.sent().KHR_draco_mesh_compression)(t)]}})})}),we("KHR_interactivity"),Ae("KHR_interactivity",!0,function(t){return g(e,void 0,void 0,function(){return b(this,function(e){switch(e.label){case 0:return[4,Promise.resolve().then(function(){return qr})];case 1:return[2,new(0,e.sent().KHR_interactivity)(t)]}})})}),we("KHR_lights_punctual"),Ae("KHR_lights_punctual",!0,function(t){return g(e,void 0,void 0,function(){return b(this,function(e){switch(e.label){case 0:return[4,Promise.resolve().then(function(){return Ot})];case 1:return[2,new(0,e.sent().KHR_lights)(t)]}})})}),we("EXT_lights_area"),Ae("EXT_lights_area",!0,function(t){return g(e,void 0,void 0,function(){return b(this,function(e){switch(e.label){case 0:return[4,Promise.resolve().then(function(){return Et})];case 1:return[2,new(0,e.sent().EXT_lights_area)(t)]}})})}),we("EXT_lights_ies"),Ae("EXT_lights_ies",!0,function(t){return g(e,void 0,void 0,function(){return b(this,function(e){switch(e.label){case 0:return[4,Promise.resolve().then(function(){return yt})];case 1:return[2,new(0,e.sent().EXT_lights_ies)(t)]}})})}),we("KHR_materials_anisotropy"),Ae("KHR_materials_anisotropy",!0,function(t){return g(e,void 0,void 0,function(){return b(this,function(e){switch(e.label){case 0:return[4,Promise.resolve().then(function(){return zt})];case 1:return[2,new(0,e.sent().KHR_materials_anisotropy)(t)]}})})}),we("KHR_materials_clearcoat"),Ae("KHR_materials_clearcoat",!0,function(t){return g(e,void 0,void 0,function(){return b(this,function(e){switch(e.label){case 0:return[4,Promise.resolve().then(function(){return kt})];case 1:return[2,new(0,e.sent().KHR_materials_clearcoat)(t)]}})})}),we("KHR_materials_diffuse_roughness"),Ae("KHR_materials_diffuse_roughness",!0,function(t){return g(e,void 0,void 0,function(){return b(this,function(e){switch(e.label){case 0:return[4,Promise.resolve().then(function(){return Ln})];case 1:return[2,new(0,e.sent().KHR_materials_diffuse_roughness)(t)]}})})}),we("KHR_materials_diffuse_transmission"),Ae("KHR_materials_diffuse_transmission",!0,function(t){return g(e,void 0,void 0,function(){return b(this,function(e){switch(e.label){case 0:return[4,Promise.resolve().then(function(){return yn})];case 1:return[2,new(0,e.sent().KHR_materials_diffuse_transmission)(t)]}})})}),we("KHR_materials_dispersion"),Ae("KHR_materials_dispersion",!0,function(t){return g(e,void 0,void 0,function(){return b(this,function(e){switch(e.label){case 0:return[4,Promise.resolve().then(function(){return En})];case 1:return[2,new(0,e.sent().KHR_materials_dispersion)(t)]}})})}),we("KHR_materials_emissive_strength"),Ae("KHR_materials_emissive_strength",!0,function(t){return g(e,void 0,void 0,function(){return b(this,function(e){switch(e.label){case 0:return[4,Promise.resolve().then(function(){return Xt})];case 1:return[2,new(0,e.sent().KHR_materials_emissive_strength)(t)]}})})}),we("KHR_materials_ior"),Ae("KHR_materials_ior",!0,function(t){return g(e,void 0,void 0,function(){return b(this,function(e){switch(e.label){case 0:return[4,Promise.resolve().then(function(){return ln})];case 1:return[2,new(0,e.sent().KHR_materials_ior)(t)]}})})}),we("KHR_materials_iridescence"),Ae("KHR_materials_iridescence",!0,function(t){return g(e,void 0,void 0,function(){return b(this,function(e){switch(e.label){case 0:return[4,Promise.resolve().then(function(){return jt})];case 1:return[2,new(0,e.sent().KHR_materials_iridescence)(t)]}})})}),we("KHR_materials_pbrSpecularGlossiness"),Ae("KHR_materials_pbrSpecularGlossiness",!0,function(t){return g(e,void 0,void 0,function(){return b(this,function(e){switch(e.label){case 0:return[4,Promise.resolve().then(function(){return Lt})];case 1:return[2,new(0,e.sent().KHR_materials_pbrSpecularGlossiness)(t)]}})})}),we("KHR_materials_sheen"),Ae("KHR_materials_sheen",!0,function(t){return g(e,void 0,void 0,function(){return b(this,function(e){switch(e.label){case 0:return[4,Promise.resolve().then(function(){return Zt})];case 1:return[2,new(0,e.sent().KHR_materials_sheen)(t)]}})})}),we("KHR_materials_specular"),Ae("KHR_materials_specular",!0,function(t){return g(e,void 0,void 0,function(){return b(this,function(e){switch(e.label){case 0:return[4,Promise.resolve().then(function(){return on})];case 1:return[2,new(0,e.sent().KHR_materials_specular)(t)]}})})}),we("KHR_materials_transmission"),Ae("KHR_materials_transmission",!0,function(t){return g(e,void 0,void 0,function(){return b(this,function(e){switch(e.label){case 0:return[4,Promise.resolve().then(function(){return _n})];case 1:return[2,new(0,e.sent().KHR_materials_transmission)(t)]}})})}),we("KHR_materials_unlit"),Ae("KHR_materials_unlit",!0,function(t){return g(e,void 0,void 0,function(){return b(this,function(e){switch(e.label){case 0:return[4,Promise.resolve().then(function(){return Nt})];case 1:return[2,new(0,e.sent().KHR_materials_unlit)(t)]}})})}),we("KHR_materials_variants"),Ae("KHR_materials_variants",!0,function(t){return g(e,void 0,void 0,function(){return b(this,function(e){switch(e.label){case 0:return[4,Promise.resolve().then(function(){return fn})];case 1:return[2,new(0,e.sent().KHR_materials_variants)(t)]}})})}),we("KHR_materials_volume"),Ae("KHR_materials_volume",!0,function(t){return g(e,void 0,void 0,function(){return b(this,function(e){switch(e.label){case 0:return[4,Promise.resolve().then(function(){return xn})];case 1:return[2,new(0,e.sent().KHR_materials_volume)(t)]}})})}),we("KHR_mesh_quantization"),Ae("KHR_mesh_quantization",!0,function(t){return g(e,void 0,void 0,function(){return b(this,function(e){switch(e.label){case 0:return[4,Promise.resolve().then(function(){return Nn})];case 1:return[2,new(0,e.sent().KHR_mesh_quantization)(t)]}})})}),we("KHR_texture_basisu"),Ae("KHR_texture_basisu",!0,function(t){return g(e,void 0,void 0,function(){return b(this,function(e){switch(e.label){case 0:return[4,Promise.resolve().then(function(){return kn})];case 1:return[2,new(0,e.sent().KHR_texture_basisu)(t)]}})})}),we("KHR_texture_transform"),Ae("KHR_texture_transform",!0,function(t){return g(e,void 0,void 0,function(){return b(this,function(e){switch(e.label){case 0:return[4,Promise.resolve().then(function(){return Vn})];case 1:return[2,new(0,e.sent().KHR_texture_transform)(t)]}})})}),we("KHR_xmp_json_ld"),Ae("KHR_xmp_json_ld",!0,function(t){return g(e,void 0,void 0,function(){return b(this,function(e){switch(e.label){case 0:return[4,Promise.resolve().then(function(){return jn})];case 1:return[2,new(0,e.sent().KHR_xmp_json_ld)(t)]}})})}),we("MSFT_audio_emitter"),Ae("MSFT_audio_emitter",!0,function(t){return g(e,void 0,void 0,function(){return b(this,function(e){switch(e.label){case 0:return[4,Promise.resolve().then(function(){return wr})];case 1:return[2,new(0,e.sent().MSFT_audio_emitter)(t)]}})})}),we("MSFT_lod"),Ae("MSFT_lod",!0,function(t){return g(e,void 0,void 0,function(){return b(this,function(e){switch(e.label){case 0:return[4,Promise.resolve().then(function(){return Mr})];case 1:return[2,new(0,e.sent().MSFT_lod)(t)]}})})}),we("MSFT_minecraftMesh"),Ae("MSFT_minecraftMesh",!0,function(t){return g(e,void 0,void 0,function(){return b(this,function(e){switch(e.label){case 0:return[4,Promise.resolve().then(function(){return Fr})];case 1:return[2,new(0,e.sent().MSFT_minecraftMesh)(t)]}})})}),we("MSFT_sRGBFactors"),Ae("MSFT_sRGBFactors",!0,function(t){return g(e,void 0,void 0,function(){return b(this,function(e){switch(e.label){case 0:return[4,Promise.resolve().then(function(){return Sr})];case 1:return[2,new(0,e.sent().MSFT_sRGBFactors)(t)]}})})}),we("KHR_node_visibility"),Ae("KHR_node_visibility",!0,function(t){return g(e,void 0,void 0,function(){return b(this,function(e){switch(e.label){case 0:return[4,Promise.resolve().then(function(){return Jr})];case 1:return[2,new(0,e.sent().KHR_node_visibility)(t)]}})})}),we("KHR_node_hoverability"),Ae("KHR_node_hoverability",!0,function(t){return g(e,void 0,void 0,function(){return b(this,function(e){switch(e.label){case 0:return[4,Promise.resolve().then(function(){return oo})];case 1:return[2,new(0,e.sent().KHR_node_hoverability)(t)]}})})}),we("KHR_node_selectability"),Ae("KHR_node_selectability",!0,function(t){return g(e,void 0,void 0,function(){return b(this,function(e){switch(e.label){case 0:return[4,Promise.resolve().then(function(){return $r})];case 1:return[2,new(0,e.sent().KHR_node_selectability)(t)]}})})}),we("KHR_materials_coat"),Ae("KHR_materials_coat",!0,function(t){return g(e,void 0,void 0,function(){return b(this,function(e){switch(e.label){case 0:return[4,Promise.resolve().then(function(){return Vt})];case 1:return[2,new(0,e.sent().KHR_materials_coat)(t)]}})})}),we("KHR_materials_fuzz"),Ae("KHR_materials_fuzz",!0,function(t){return g(e,void 0,void 0,function(){return b(this,function(e){switch(e.label){case 0:return[4,Promise.resolve().then(function(){return tn})];case 1:return[2,new(0,e.sent().KHR_materials_fuzz)(t)]}})})}),we("KHR_materials_volume_scatter"),Ae("KHR_materials_volume_scatter",!0,function(t){return g(e,void 0,void 0,function(){return b(this,function(e){switch(e.label){case 0:return[4,Promise.resolve().then(function(){return On})];case 1:return[2,new(0,e.sent().KHR_materials_volume_scatter)(t)]}})})})}(),t.RegisterSceneLoaderPlugin(_(_({},mo),{createPlugin:function(t){return g(e,void 0,void 0,function(){return b(this,function(e){switch(e.label){case 0:return[4,Promise.resolve().then(function(){return go})];case 1:return[2,new(0,e.sent().OBJFileLoader)(t[mo.name])]}})})}})),t.RegisterSceneLoaderPlugin(_(_({},Ao),{createPlugin:function(t){return g(e,void 0,void 0,function(){return b(this,function(e){switch(e.label){case 0:return[4,Promise.resolve().then(function(){return Bo})];case 1:return[2,new(0,e.sent().SPLATFileLoader)(t[Ao.name])]}})})}})),t.RegisterSceneLoaderPlugin(_(_({},yo),{createPlugin:function(){return g(e,void 0,void 0,function(){return b(this,function(e){switch(e.label){case 0:return[4,Promise.resolve().then(function(){return To})];case 1:return[2,new(0,e.sent().STLFileLoader)]}})})}}))}var Go={__proto__:null,registerBuiltInLoaders:ko},Do="undefined"!=typeof global?global:"undefined"!=typeof window?window:void 0;if(void 0!==Do)for(var Vo in A)Do.BABYLON[Vo]||(Do.BABYLON[Vo]=A[Vo]);var Ho="undefined"!=typeof global?global:"undefined"!=typeof window?window:void 0;if(void 0!==Ho)for(var Ko in Ho.BABYLON=Ho.BABYLON||{},Go)Ho.BABYLON[Ko]=Go[Ko];var jo="undefined"!=typeof global?global:"undefined"!=typeof window?window:void 0;if(void 0!==jo){for(var Uo in jo.BABYLON=jo.BABYLON||{},z)jo.BABYLON[Uo]=z[Uo];for(var Uo in F)jo.BABYLON[Uo]=F[Uo]}var Wo,zo,qo="undefined"!=typeof global?global:"undefined"!=typeof window?window:void 0;if(void 0!==qo)for(var Yo in qo.BABYLON=qo.BABYLON||{},qo.BABYLON.GLTF1=qo.BABYLON.GLTF1||{},ve)qo.BABYLON.GLTF1[Yo]=ve[Yo];var Xo=_({},co),Jo=_(_({},{__proto__:null}),((Wo={}).Extensions=Xo,Wo)),Qo=_(_({},fo),((zo={}).Loader=Jo,zo)),Zo="undefined"!=typeof global?global:"undefined"!=typeof window?window:void 0;if(void 0!==Zo){Zo.BABYLON=Zo.BABYLON||{};var $o=Zo.BABYLON;$o.GLTF2=$o.GLTF2||{},$o.GLTF2.Loader=$o.GLTF2.Loader||{},$o.GLTF2.Loader.Extensions=$o.GLTF2.Loader.Extensions||{};var ea=["Loader"];for(var ta in Xo)$o.GLTF2.Loader.Extensions[ta]=Xo[ta],ea.push(ta);for(var ta in Jo)"Extensions"!==ta&&($o.GLTF2.Loader[ta]=Jo[ta],ea.push(ta));for(var ta in Qo)ea.indexOf(ta)>-1||($o.GLTF2[ta]=Qo[ta])}var na="undefined"!=typeof global?global:"undefined"!=typeof window?window:void 0;if(void 0!==na)for(var ra in bo)na.BABYLON[ra]||(na.BABYLON[ra]=bo[ra]);var oa="undefined"!=typeof global?global:"undefined"!=typeof window?window:void 0;if(void 0!==oa)for(var aa in xo)oa.BABYLON[aa]||(oa.BABYLON[aa]=xo[aa]);e.BVHFileLoader=T,e.GLTF1=ve,e.GLTF2=Qo,e.GLTFFileLoader=k,e.GLTFLoaderDefaultOptions=I,e.GLTFValidation=R,e.MTLFileLoader=ho,e.OBJFileLoader=_o,e.ReadBvh=d,e.SPLATFileLoader=Io,e.STLFileLoader=vo,e.SolidParser=po,e.registerBuiltInLoaders=ko});
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("babylonjs")):"function"==typeof define&&define.amd?define(["exports","babylonjs"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).BABYLON=e.BABYLON||{},e.BABYLON)}(this,function(e,t){"use strict";var n="Xposition",r="Yposition",o="Zposition",a="Xrotation",i="Yrotation",s="Zrotation",l=function(e){this.loopMode=t.Animation.ANIMATIONLOOPMODE_CYCLE,this.list=[],this.root=u(),this.numFrames=0,this.frameRate=0,this.skeleton=e};function u(){return{name:"",type:"",offset:new t.Vector3,channels:[],children:[],frames:[],parent:null}}function c(e,l,u){for(var f=function(e){var n=e.offset.x,r=e.offset.y,o=e.offset.z;return t.Matrix.Translation(n,r,o)}(e),d=new t.Bone(e.name,u.skeleton,l,f),h=function(e,l){if(0===e.frames.length)return[];for(var u=[],c=e.channels.some(function(e){return e===n||e===r||e===o}),f=e.channels.some(function(e){return e===a||e===i||e===s}),d=new t.Animation("".concat(e.name,"_pos"),"position",l.frameRate,t.Animation.ANIMATIONTYPE_VECTOR3,l.loopMode),h=new t.Animation("".concat(e.name,"_rot"),"rotationQuaternion",l.frameRate,t.Animation.ANIMATIONTYPE_QUATERNION,l.loopMode),p=[],m=[],v=0;v<e.frames.length;v++){var _=e.frames[v];c&&_.position&&p.push({frame:_.frame,value:_.position.clone()}),f&&m.push({frame:_.frame,value:_.rotation.clone()})}return p.length>0&&(d.setKeys(p),u.push(d)),m.length>0&&(h.setKeys(m),u.push(h)),u}(e,u),p=0,m=h;p<m.length;p++){var v=m[p];v.getKeys()&&v.getKeys().length>0&&d.animations.push(v)}for(var _=0,g=e.children;_<g.length;_++)c(g[_],d,u)}function f(e,l,u,c){if("ENDSITE"!==u.type){var d={frame:0,position:new t.Vector3,rotation:new t.Quaternion};d.frame=l,d.position=new t.Vector3,d.rotation=new t.Quaternion,u.frames.push(d);for(var h=t.Matrix.Identity(),p=0;p<u.channels.length;++p){var m=u.channels[p],v=e[c.i++];if(v){var _=parseFloat(v.trim());if(m.endsWith("position"))switch(m){case n:d.position.x=_;break;case r:d.position.y=_;break;case o:d.position.z=_}else if(m.endsWith("rotation")){var g=t.Tools.ToRadians(_),y=void 0;switch(m){case a:y=t.Matrix.RotationX(g);break;case i:y=t.Matrix.RotationY(g);break;case s:y=t.Matrix.RotationZ(g)}h=y.multiply(h)}}}t.Quaternion.FromRotationMatrixToRef(h,d.rotation);for(var b=0,x=u.children;b<x.length;b++)f(e,l,x[b],c)}}function d(e,n,r,o){var a,i,s,l,c=u();c.parent=r,o.list.push(c);var f=n.trim().split(/\s+/);if("END"===f[0].toUpperCase()&&"SITE"===f[1].toUpperCase()?(c.type="ENDSITE",c.name="ENDSITE"):(c.name=f[1],c.type=f[0].toUpperCase()),"{"!=(null===(a=e.shift())||void 0===a?void 0:a.trim()))throw new Error("Expected opening { after type & name");var h=null===(i=e.shift())||void 0===i?void 0:i.trim().split(/\s+/);if(!h)throw new Error("Unexpected end of file: missing OFFSET");if("OFFSET"!=(f=h)[0].toUpperCase())throw new Error("Expected OFFSET, but got: "+f[0]);if(4!=f.length)throw new Error("OFFSET: Invalid number of values");var p=new t.Vector3(parseFloat(f[1]),parseFloat(f[2]),parseFloat(f[3]));if(isNaN(p.x)||isNaN(p.y)||isNaN(p.z))throw new Error("OFFSET: Invalid values");if(c.offset=p,"ENDSITE"!=c.type){if(!(f=null===(s=e.shift())||void 0===s?void 0:s.trim().split(/\s+/)))throw new Error("Unexpected end of file: missing CHANNELS");if("CHANNELS"!=f[0].toUpperCase())throw new Error("Expected CHANNELS definition");var m=parseInt(f[1]);c.channels=f.splice(2,m),c.children=[]}for(;e.length>0;){var v=null===(l=e.shift())||void 0===l?void 0:l.trim();if("}"===v)return c;v&&c.children.push(d(e,v,c,o))}throw new Error("Unexpected end of file: missing closing brace")}function h(e,n,r,o){var a=e.split("\n"),i=o.loopMode;n._blockEntityCollection=!!r;var s=new t.Skeleton("","",n);s._parentContainer=r,n._blockEntityCollection=!1;var u=new l(s);u.loopMode=i;var h=a.shift();if(!h||"HIERARCHY"!==h.trim().toUpperCase())throw new Error("HIERARCHY expected");var p=a.shift();if(!p)throw new Error("Unexpected end of file after HIERARCHY");var m=d(a,p.trim(),null,u),v=a.shift();if(!v||"MOTION"!==v.trim().toUpperCase())throw new Error("MOTION expected");var _=a.shift();if(!_)throw new Error("Unexpected end of file before frame count");var g=_.trim().split(/[\s]+/);if(g.length<2)throw new Error("Invalid frame count line");var y=parseInt(g[1]);if(isNaN(y))throw new Error("Failed to read number of frames.");u.numFrames=y;var b=a.shift();if(!b)throw new Error("Unexpected end of file before frame time");var x=b.trim().split(/[\s]+/);if(x.length<3)throw new Error("Invalid frame time line");var T=parseFloat(x[2]);if(isNaN(T))throw new Error("Failed to read frame time.");if(T<=0)throw new Error("Failed to read frame time. Invalid value "+T);u.frameRate=1/T;for(var A=0;A<y;++A){var w=a.shift();w&&f(w.trim().split(/[\s]+/)||[],A,m,{i:0})}return u.root=m,c(u.root,null,u),u.skeleton.returnToRest(),u.skeleton}var p=function(e,t){return p=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},p(e,t)};function m(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}p(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}var v=function(){return v=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},v.apply(this,arguments)};function _(e,t,n,r){return new(n||(n=Promise))(function(o,a){function i(e){try{l(r.next(e))}catch(e){a(e)}}function s(e){try{l(r.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(i,s)}l((r=r.apply(e,t||[])).next())})}function g(e,t){var n,r,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=s(0),i.throw=s(1),i.return=s(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(l){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(n=1,r&&(o=2&s[0]?r.return:s[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,s[1])).done)return o;switch(r=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,r=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){a.label=s[1];break}if(6===s[0]&&a.label<o[1]){a.label=o[1],o=s;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(s);break}o[2]&&a.ops.pop(),a.trys.pop();continue}s=t.call(e,a)}catch(e){s=[6,e],r=0}finally{n=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,l])}}}function y(e,t,n){if(n||2===arguments.length)for(var r,o=0,a=t.length;o<a;o++)!r&&o in t||(r||(r=Array.prototype.slice.call(t,0,o)),r[o]=t[o]);return e.concat(r||Array.prototype.slice.call(t))}Object.create,Object.create,"function"==typeof SuppressedError&&SuppressedError;var b={name:"bvh",extensions:{".bvh":{isBinary:!1}}},x=function(){function e(t){this.name=b.name,this.extensions=b.extensions,this._loadingOptions=v(v({},e._DefaultLoadingOptions),null!=t?t:{})}return Object.defineProperty(e,"_DefaultLoadingOptions",{get:function(){return{loopMode:t.Animation.ANIMATIONLOOPMODE_CYCLE}},enumerable:!1,configurable:!0}),e.prototype.createPlugin=function(t){return new e(t[b.name])},e.prototype.canDirectLoad=function(e){return this.isBvhHeader(e)},e.prototype.isBvhHeader=function(e){return"HIERARCHY"==e.split("\n")[0]},e.prototype.isNotBvhHeader=function(e){return!this.isBvhHeader(e)},e.prototype.importMeshAsync=function(e,t,n){if("string"!=typeof n)return Promise.reject("BVH loader expects string data.");if(this.isNotBvhHeader(n))return Promise.reject("BVH loader expects HIERARCHY header.");try{var r=h(n,t,null,this._loadingOptions);return Promise.resolve({meshes:[],particleSystems:[],skeletons:[r],animationGroups:[],transformNodes:[],geometries:[],lights:[],spriteManagers:[]})}catch(e){return Promise.reject(e)}},e.prototype.loadAsync=function(e,t){return"string"!=typeof t?Promise.reject("BVH loader expects string data."):this.isNotBvhHeader(t)?Promise.reject("BVH loader expects HIERARCHY header."):this.importMeshAsync(null,e,t).then(function(){})},e.prototype.loadAssetContainerAsync=function(e,n){if("string"!=typeof n)return Promise.reject("BVH loader expects string data.");if(this.isNotBvhHeader(n))return Promise.reject("BVH loader expects HIERARCHY header.");var r=new t.AssetContainer(e);try{var o=h(n,e,r,this._loadingOptions);return r.skeletons.push(o),Promise.resolve(r)}catch(e){return Promise.reject(e)}},e}();t.RegisterSceneLoaderPlugin(new x);var T,A,w,M={__proto__:null,BVHFileLoader:x},C={__proto__:null,BVHFileLoader:x,ReadBvh:h},O=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258],S=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],E=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577],F=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],R=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],L=function(){function e(e,t,n){this.input=e,this.byteOffset=t,this.endOffset=n,this.bitBuffer=0,this.bitCount=0}return e.prototype.readBits=function(e){this.ensureBits(e);var t=this.bitBuffer&(1<<e)-1;return this.bitBuffer>>>=e,this.bitCount-=e,t},e.prototype.readBit=function(){if(0===this.bitCount){if(this.byteOffset>=this.endOffset)throw new Error("zlib: unexpected end of input");this.bitBuffer=this.input[this.byteOffset++],this.bitCount=8}var e=1&this.bitBuffer;return this.bitBuffer>>>=1,this.bitCount--,e},e.prototype.alignToByte=function(){this.bitBuffer=0,this.bitCount=0},e.prototype.readUint16LE=function(){if(this.ensureByteAligned(),this.byteOffset+2>this.endOffset)throw new Error("zlib: unexpected end of input");var e=this.input[this.byteOffset]|this.input[this.byteOffset+1]<<8;return this.byteOffset+=2,e},e.prototype.readByte=function(){if(this.ensureByteAligned(),this.byteOffset>=this.endOffset)throw new Error("zlib: unexpected end of input");return this.input[this.byteOffset++]},e.prototype.ensureByteAligned=function(){if(0!==this.bitCount)throw new Error("deflate: expected byte alignment")},e.prototype.ensureBits=function(e){for(;this.bitCount<e;){if(this.byteOffset>=this.endOffset)throw new Error("zlib: unexpected end of input");this.bitBuffer|=this.input[this.byteOffset++]<<this.bitCount,this.bitCount+=8}},e}(),I=function(){function e(e){this.offset=0,this.adlerA=1,this.adlerB=0,this.bytes=new Uint8Array(e)}return e.prototype.writeByte=function(e){if(this.offset>=this.bytes.byteLength)throw new Error("zlib: output length mismatch");var t=255&e;this.bytes[this.offset++]=t,this.adlerA+=t,this.adlerB+=this.adlerA,this.adlerA%=65521,this.adlerB%=65521},e.prototype.copy=function(e,t){if(e<=0||e>this.offset)throw new Error("deflate: distance out of range");for(var n=0;n<t;n++)this.writeByte(this.bytes[this.offset-e])},e.prototype.finish=function(){if(this.offset!==this.bytes.byteLength)throw new Error("zlib: output length mismatch")},e.prototype.adler32=function(){return(this.adlerB<<16|this.adlerA)>>>0},e}(),P=function(){function e(e,t){void 0===t&&(t={});for(var n=new Array(16).fill(0),r=0,o=0,a=0,i=e;a<i.length;a++){var s=i[a];if(!Number.isInteger(s)||s<0||s>15)throw new Error("deflate: invalid huffman code lengths");s>0&&(n[s]++,r++,o=Math.max(o,s))}if(0===r){if(t.allowEmpty)return this.symbolsByLength=[],void(this.maxCodeLength=0);throw new Error("deflate: invalid huffman code lengths")}for(var l=1,u=1;u<=15;u++)if((l=(l<<1)-n[u])<0)throw new Error("deflate: invalid huffman code lengths");if(0!==l&&1!==r)throw new Error("deflate: invalid huffman code lengths");var c=new Array(16).fill(0),f=0;for(u=1;u<=15;u++)f=f+n[u-1]<<1,c[u]=f;this.symbolsByLength=Array.from({length:16},function(e,t){if(0!==n[t]){var r=new Int16Array(1<<t);return r.fill(-1),r}});for(var d=0;d<e.length;d++){var h=e[d];0!==h&&(this.symbolsByLength[h][c[h]++]=d)}this.maxCodeLength=o}return e.prototype.decode=function(e){var t,n;if(0===this.maxCodeLength)throw new Error("deflate: invalid huffman code");for(var r=0,o=1;o<=this.maxCodeLength;o++){r=r<<1|e.readBit();var a=null!==(n=null===(t=this.symbolsByLength[o])||void 0===t?void 0:t[r])&&void 0!==n?n:-1;if(a>=0)return a}throw new Error("deflate: invalid huffman code")},e}();function N(){if(!T){for(var e=new Array(288),t=0;t<=143;t++)e[t]=8;for(t=144;t<=255;t++)e[t]=9;for(t=256;t<=279;t++)e[t]=7;for(t=280;t<=287;t++)e[t]=8;T=new P(e)}return T}function B(){return A||(A=new P(new Array(32).fill(5))),A}function k(e,t){e.alignToByte();var n=e.readUint16LE();if(65535&(n^~e.readUint16LE()))throw new Error("deflate: invalid stored block length");for(var r=0;r<n;r++)t.writeByte(e.readByte())}function D(e,t,n,r){for(;;){var o=n.decode(e);if(o<256)t.writeByte(o);else{if(256===o)return;if(o>285)throw new Error("deflate: invalid literal/length symbol");var a=o-257,i=O[a]+e.readBits(S[a]),s=r.decode(e);if(s>29)throw new Error("deflate: invalid distance symbol");var l=E[s]+e.readBits(F[s]);t.copy(l,i)}}}function G(e){for(var t=e.readBits(5)+257,n=e.readBits(5)+1,r=e.readBits(4)+4,o=new Array(19).fill(0),a=0;a<r;a++)o[R[a]]=e.readBits(3);var i=function(e,t,n){for(var r=[];r.length<n;){var o=t.decode(e);if(o<=15)r.push(o);else{var a=void 0,i=void 0;switch(o){case 16:if(0===r.length)throw new Error("deflate: invalid code length repeat");i=r[r.length-1],a=e.readBits(2)+3;break;case 17:i=0,a=e.readBits(3)+3;break;case 18:i=0,a=e.readBits(7)+11;break;default:throw new Error("deflate: invalid code length symbol")}if(r.length+a>n)throw new Error("deflate: invalid code length repeat");for(var s=0;s<a;s++)r.push(i)}}return r}(e,new P(o),t+n),s=i.slice(0,t),l=i.slice(t);if(0===s[256])throw new Error("deflate: missing end-of-block code");return{literalLengthTree:new P(s),distanceTree:new P(l,{allowEmpty:!0})}}function V(e,t,n,r,o){var a,i,s,l;if(r?(j(t,n,25,o,"FBX node header"),a=K(e,n),i=K(e,n+8),s=K(e,n+16),l=25):(j(t,n,13,o,"FBX node header"),a=e.getUint32(n,!0),i=e.getUint32(n+4,!0),s=e.getUint32(n+8,!0),l=13),0===a)return null;if(a<=n||a>o)throw new Error("Invalid FBX node end offset ".concat(a," at offset ").concat(n));var u=t[n+l-1];j(t,n+l,u,a,"FBX node name");var c=z(t,n+l,u),f=n+l+u,d=f+s;if(d>a)throw new Error("Invalid FBX property list length for node '".concat(c,"' at offset ").concat(n));for(var h=[],p=0;p<i;p++){var m=H(e,t,f,d);h.push(m.property),f=m.nextOffset}if(f!==d)throw new Error("Invalid FBX property list length for node '".concat(c,"' at offset ").concat(n));var v=[];if(f<a)for(;f<a;){var _=V(e,t,f,r,a);if(null===_)break;if(_.endOffset<=f||_.endOffset>a)throw new Error("Invalid FBX child node end offset ".concat(_.endOffset," at offset ").concat(f));v.push(_.node),f=_.endOffset}return{node:{name:c,properties:h,children:v},endOffset:a}}function H(e,t,n,r){j(t,n,1,r,"FBX property type");var o=String.fromCharCode(t[n]);switch(n+=1,o){case"C":return j(t,n,1,r,"FBX boolean property"),{property:{type:"boolean",value:a=0!==t[n]},nextOffset:n+1};case"Y":return j(t,n,2,r,"FBX int16 property"),{property:{type:"int16",value:a=e.getInt16(n,!0)},nextOffset:n+2};case"I":return j(t,n,4,r,"FBX int32 property"),{property:{type:"int32",value:a=e.getInt32(n,!0)},nextOffset:n+4};case"F":return j(t,n,4,r,"FBX float32 property"),{property:{type:"float32",value:a=e.getFloat32(n,!0)},nextOffset:n+4};case"D":return j(t,n,8,r,"FBX float64 property"),{property:{type:"float64",value:a=e.getFloat64(n,!0)},nextOffset:n+8};case"L":return j(t,n,8,r,"FBX int64 property"),{property:{type:"int64",value:a=W(e,n)},nextOffset:n+8};case"S":j(t,n,4,r,"FBX string property length"),j(t,n+4,i=e.getUint32(n,!0),r,"FBX string property data");var a=function(e,t,n){return new TextDecoder("utf-8").decode(e.subarray(t,t+n))}(t,n+4,i);return{property:{type:"string",value:a},nextOffset:n+4+i};case"R":var i;return j(t,n,4,r,"FBX raw property length"),j(t,n+4,i=e.getUint32(n,!0),r,"FBX raw property data"),{property:{type:"raw",value:a=t.slice(n+4,n+4+i)},nextOffset:n+4+i};case"f":return U(e,t,n,"float32[]",4,r);case"d":return U(e,t,n,"float64[]",8,r);case"i":return U(e,t,n,"int32[]",4,r);case"l":return U(e,t,n,"int64[]",8,r);case"b":return U(e,t,n,"boolean[]",1,r);default:throw new Error("Unknown FBX property type: '".concat(o,"' at offset ").concat(n-1))}}function U(e,t,n,r,o,a){j(t,n,12,a,"FBX array property header for ".concat(r));var i,s=e.getUint32(n,!0),l=e.getUint32(n+4,!0),u=e.getUint32(n+8,!0),c=s*o;if(j(t,n+=12,u,a,"FBX array property data for ".concat(r)),1===l)i=function(e,t){if(!Number.isInteger(t)||t<0)throw new Error("zlib: invalid expected length");if(e.byteLength<6)throw new Error("zlib: unexpected end of input");var n=e[0],r=e[1];if(8!=(15&n)||n>>4>7||((n<<8)+r)%31!=0)throw new Error("zlib: invalid header");if(32&r)throw new Error("zlib: preset dictionary not supported");for(var o=new L(e,2,e.byteLength-4),a=new I(t),i=!1;!i;)switch(i=1===o.readBits(1),o.readBits(2)){case 0:k(o,a);break;case 1:D(o,a,N(),B());break;case 2:var s=G(o);D(o,a,s.literalLengthTree,s.distanceTree);break;default:throw new Error("deflate: invalid block type")}if(o.byteOffset<e.byteLength-4)throw new Error("zlib: trailing deflate data");a.finish();var l=(e[e.byteLength-4]<<24|e[e.byteLength-3]<<16|e[e.byteLength-2]<<8|e[e.byteLength-1])>>>0;if(a.adler32()!==l)throw new Error("zlib: adler32 mismatch");return a.bytes}(t.subarray(n,n+u),c);else{if(0!==l)throw new Error("Unsupported FBX array encoding: ".concat(l));if(u!==c)throw new Error("Invalid FBX array byte length for ".concat(r));i=t.slice(n,n+u)}var f,d=i.buffer.slice(i.byteOffset,i.byteOffset+i.byteLength);switch(r){case"float32[]":f=new Float32Array(d);break;case"float64[]":f=new Float64Array(d);break;case"int32[]":f=new Int32Array(d);break;case"boolean[]":f=i;break;case"int64[]":f=function(e){for(var t=new DataView(e.buffer,e.byteOffset,e.byteLength),n=new Float64Array(e.byteLength/8),r=0;r<n.length;r++)n[r]=W(t,8*r);return n}(i);break;default:throw new Error("Unexpected array type: ".concat(r))}return{property:{type:r,value:f},nextOffset:n+u}}function j(e,t,n,r,o){if(t<0||n<0||t+n>r||t+n>e.byteLength)throw new Error("".concat(o,": unexpected end of input"))}function K(e,t){var n=e.getUint32(t,!0);return 4294967296*e.getUint32(t+4,!0)+n}function W(e,t){var n=e.getUint32(t,!0);return 4294967296*e.getInt32(t+4,!0)+n}function z(e,t,n){for(var r="",o=0;o<n;o++)r+=String.fromCharCode(e[t+o]);return r}function q(e){for(var t=new X(e),n=function(e){var t=e.match(/;\s*FBX\s+(\d+)\.(\d+)\.(\d+)/);if(!t)throw new Error("Cannot determine FBX version from ASCII header");return 1e3*parseInt(t[1])+100*parseInt(t[2])+parseInt(t[3])}(e),r=[];!t.isEOF()&&(t.skipWhitespaceAndComments(),!t.isEOF());){var o=Y(t);o&&r.push(o)}return{version:n,nodes:r}}!function(e){e[e.Identifier=0]="Identifier",e[e.Number=1]="Number",e[e.String=2]="String",e[e.OpenBrace=3]="OpenBrace",e[e.CloseBrace=4]="CloseBrace",e[e.Colon=5]="Colon",e[e.Comma=6]="Comma",e[e.Star=7]="Star",e[e.EOF=8]="EOF"}(w||(w={}));var X=function(){function e(e){this.text=e,this.pos=0,this.len=e.length}return e.prototype.isEOF=function(){return this.skipWhitespaceAndComments(),this.pos>=this.len},e.prototype.peek=function(){var e=this.pos,t=this.next();return this.pos=e,t},e.prototype.next=function(){if(this.skipWhitespaceAndComments(),this.pos>=this.len)return{type:8,value:"",pos:this.pos};var e=this.text[this.pos],t=this.pos;switch(e){case"{":return this.pos++,{type:3,value:"{",pos:t};case"}":return this.pos++,{type:4,value:"}",pos:t};case":":return this.pos++,{type:5,value:":",pos:t};case",":return this.pos++,{type:6,value:",",pos:t};case"*":return this.pos++,{type:7,value:"*",pos:t};case'"':return this.readString();default:if(this.isNumberStart(e))return this.readNumber();if(this.isIdentStart(e))return this.readIdentifier();throw new Error("Unexpected character '".concat(e,"' at position ").concat(this.pos))}},e.prototype.expect=function(e){var t=this.next();if(t.type!==e)throw new Error("Expected token type ".concat(e," but got ").concat(t.type," ('").concat(t.value,"') at pos ").concat(t.pos));return t},e.prototype.isNextNodeStart=function(){var e=this.pos;if(this.skipWhitespaceAndComments(),this.pos<this.len&&this.isIdentStart(this.text[this.pos])){for(;this.pos<this.len&&this.isIdentChar(this.text[this.pos]);)this.pos++;for(;this.pos<this.len&&(" "===this.text[this.pos]||"\t"===this.text[this.pos]);)this.pos++;var t=this.pos<this.len&&":"===this.text[this.pos];return this.pos=e,t}return this.pos=e,!1},e.prototype.skipWhitespaceAndComments=function(){for(;this.pos<this.len;){var e=this.text[this.pos];if(" "===e||"\t"===e||"\r"===e||"\n"===e)this.pos++;else{if(";"!==e)break;for(;this.pos<this.len&&"\n"!==this.text[this.pos];)this.pos++}}},e.prototype.readString=function(){var e=this.pos;this.pos++;for(var t="";this.pos<this.len&&'"'!==this.text[this.pos];)"\\"===this.text[this.pos]&&this.pos+1<this.len?(this.pos++,t+=this.text[this.pos]):t+=this.text[this.pos],this.pos++;return this.pos<this.len&&this.pos++,{type:2,value:t,pos:e}},e.prototype.readNumber=function(){var e=this.pos;for("-"!==this.text[this.pos]&&"+"!==this.text[this.pos]||this.pos++;this.pos<this.len&&this.isDigit(this.text[this.pos]);)this.pos++;if(this.pos<this.len&&"."===this.text[this.pos])for(this.pos++;this.pos<this.len&&this.isDigit(this.text[this.pos]);)this.pos++;if(this.pos<this.len&&("e"===this.text[this.pos]||"E"===this.text[this.pos]))for(this.pos++,this.pos<this.len&&("+"===this.text[this.pos]||"-"===this.text[this.pos])&&this.pos++;this.pos<this.len&&this.isDigit(this.text[this.pos]);)this.pos++;return{type:1,value:this.text.substring(e,this.pos),pos:e}},e.prototype.readIdentifier=function(){for(var e=this.pos;this.pos<this.len&&this.isIdentChar(this.text[this.pos]);)this.pos++;return{type:0,value:this.text.substring(e,this.pos),pos:e}},e.prototype.isDigit=function(e){return e>="0"&&e<="9"},e.prototype.isNumberStart=function(e){return!!this.isDigit(e)||("-"===e||"+"===e)&&this.pos+1<this.len&&(this.isDigit(this.text[this.pos+1])||"."===this.text[this.pos+1])},e.prototype.isIdentStart=function(e){return e>="a"&&e<="z"||e>="A"&&e<="Z"||"_"===e},e.prototype.isIdentChar=function(e){return this.isIdentStart(e)||this.isDigit(e)||"|"===e},e}();function Y(e){var t=e.peek();if(4===t.type||8===t.type)return null;var n=e.next();if(0!==n.type)throw new Error("Expected identifier for node name, got '".concat(n.value,"' at pos ").concat(n.pos));var r=n.value;e.expect(5);var o=[],a=[],i=e.peek();if(7===i.type){e.next();var s=e.expect(1),l=parseInt(s.value);e.expect(3);var u=e.next();if(0===u.type&&"a"===u.value){e.expect(5);var c=function(e,t){for(var n=[];;){var r=e.peek();if(4===r.type||8===r.type)break;if(6!==r.type){if(1!==r.type)break;var o=e.next();n.push(Number(o.value))}else e.next()}if(n.length!==t)throw new Error("ASCII FBX array declared ".concat(t," values but parsed ").concat(n.length));return n}(e,l);o.push({type:"float64[]",value:new Float64Array(c)})}return e.expect(4),{name:r,properties:o,children:a}}for(i=e.peek();3!==i.type&&4!==i.type&&8!==i.type;){if(1===i.type){var f=Q((d=e.next()).value);!Number.isInteger(f)||d.value.includes(".")||d.value.includes("e")||d.value.includes("E")?o.push({type:"float64",value:f}):o.push({type:Z(f)?"int32":"int64",value:f})}else if(2===i.type){var d=e.next();o.push({type:"string",value:d.value})}else if(0===i.type){if(e.isNextNodeStart())break;d=e.next(),o.push({type:"string",value:d.value})}else{if(6!==i.type)break;e.next()}i=e.peek()}if(3===(i=e.peek()).type){for(e.next();4!==(i=e.peek()).type&&8!==i.type;){var h=Y(e);if(!h)break;a.push(h)}e.expect(4)}return{name:r,properties:o,children:a}}function Q(e){return Number(e)}function Z(e){return e>=-2147483648&&e<=2147483647}function J(e,t){return e.children.find(function(e){return e.name===t})}function $(e,t){return e.nodes.find(function(e){return e.name===t})}function ee(e,t){if(t<e.properties.length)return e.properties[t].value}function te(e){var t=e.indexOf("\0");t>=0&&(e=e.substring(0,t));var n=e.indexOf("::");return n>=0&&(e=e.substring(n+2)),e}function ne(e,t,n){for(var r,o=[],a=0,i=null!==(r=e.childrenOf.get(t))&&void 0!==r?r:[];a<i.length;a++){var s=i[a],l=e.objects.get(s.id);!l||n&&l.name!==n||o.push({id:s.id,node:l,propertyName:s.propertyName})}return o}function re(e){return function(e){if("number"==typeof e){if(!Number.isSafeInteger(e))throw new Error("Unsafe FBX object ID ".concat(e.toString(),": object IDs must be safe integers."));return e}}(e)}function oe(e,t){var n=re(e);if(void 0!==n)return n;if("string"==typeof e){var r=te(e);return"Scene"===r?0:t.get(r)}}function ae(e,t,n,r,o,a,i,s,l){e.push({type:o,childId:a,parentId:i,propertyName:s}),t.has(i)||t.set(i,[]),t.get(i).push({id:a,propertyName:s}),n.get(a)&&r.push({reason:"duplicate-parent",message:"FBX object has multiple parents; preserving the existing last-parent behavior.",connectionIndex:l,type:o,childId:a,parentId:i,propertyName:s}),n.set(a,{id:i,propertyName:s})}function ie(e,t){var n,r,o=te(null!==(n=ee(e,0))&&void 0!==n?n:e.name),a=null!==(r=ee(e,1))&&void 0!==r?r:"";return v(v({},e),{properties:[{type:"int64",value:t},{type:"string",value:o},{type:"string",value:a}]})}function se(e,t){var n;return{name:"Geometry",properties:[{type:"int64",value:t},{type:"string",value:te(null!==(n=ee(e,0))&&void 0!==n?n:"Geometry")},{type:"string",value:"Mesh"}],children:e.children}}function le(e,t){var n,r,o,a=te(null!==(n=ee(e,1))&&void 0!==n?n:"Geometry"),i=J(e,"Vertices");if(!i)throw new Error("Geometry '".concat(a,"' has no Vertices node"));var s=_e(ye(i)),l=J(e,"PolygonVertexIndex");if(!l)throw new Error("Geometry '".concat(a,"' has no PolygonVertexIndex node"));var u=[],c=function(e){for(var t=[],n=[],r=0,o=0;o<e.length;o++){var a=e[o];a<0?(n.push(-(a+1)),t.push({indices:n,startIndex:r}),n=[],r=o+1):n.push(a)}return t}(ge(ye(l))),f=function(e,t,n){for(var r=[],o=0;o<e.length;o++){var a=e[o];r.push.apply(r,ue(a,o,t,n))}return r}(c,s,u),d=function(e){for(var t=[],n=0;n<e.length;n++)for(var r=e[n],o=0;o<r.indices.length;o++)t.push({polyIndex:n,vertexInPoly:o,controlPointIndex:r.indices[o],globalIndex:r.startIndex+o});return t}(c),h=J(e,"LayerElementNormal"),p=null;h&&(p=me(h,"Normals","NormalsIndex",d,s.length,3,u));for(var m=[],v=0,_=e.children.filter(function(e){return"LayerElementUV"===e.name});v<_.length;v++){var g=_[v],b=J(g,"Name"),x=b&&null!==(r=ee(b,0))&&void 0!==r?r:"UVSet".concat(m.length),T=me(g,"UV","UVIndex",d,s.length,2,u);T&&m.push({name:x,data:T})}var A=m.length>0?m[0].data:null,w=J(e,"LayerElementColor"),M=null;if(w){var C=me(w,"Colors","ColorIndex",d,s.length,4,u);if(C){M=new Float32Array(C.length);for(var O=0;O<C.length;O++)M[O]=C[O]}}var S=J(e,"LayerElementTangent"),E=J(e,"LayerElementBinormal"),F=E?me(E,"Binormals","BinormalsIndex",d,s.length,3,u):null,R=S?function(e,t,n,r,o,a){var i=function(e,t,n,r,o,a){var i,s,l,u,c=J(e,"Tangents");if(!c)return 3;var f=_e(ye(c)),d=null!==(s=ee(null!==(i=J(e,"MappingInformationType"))&&void 0!==i?i:{name:"",properties:[],children:[]},0))&&void 0!==s?s:"",h=null!==(u=ee(null!==(l=J(e,"ReferenceInformationType"))&&void 0!==l?l:{name:"",properties:[],children:[]},0))&&void 0!==u?u:"",p=J(e,"TangentsIndex"),m=p?ge(ye(p)):null,v="IndexToDirect"===h&&m?Math.max.apply(Math,y(y([],Array.from(m),!1),[0],!1))+1:"ByControlPoint"===d||"ByVertice"===d?o:"AllSame"===d?1:r.length;if(v>0&&f.length%v===0){var _=f.length/v;if(3===_||4===_)return _}return a.push({type:"layer-data-too-short",message:"Could not infer stride for layer '".concat(e.name,"', defaulting to 3."),layerName:e.name}),3}(e,0,0,t,n,a),s=me(e,"Tangents","TangentsIndex",t,0,i,a);if(!s)return null;for(var l=new Float64Array(4*t.length),u=0;u<t.length;u++){var c=u*i,f=4*u;l[f]=s[c],l[f+1]=s[c+1],l[f+2]=s[c+2],l[f+3]=i>=4?s[c+3]:ve(u,l,r,o)}return l}(S,d,s.length/3,p,F,u):null,L=J(e,"LayerElementMaterial"),I=null;L&&(I=function(e,t){var n,r,o=J(e,"MappingInformationType"),a=J(e,"ReferenceInformationType");if(!o||!a)return null;var i=null!==(n=ee(o,0))&&void 0!==n?n:"",s=null!==(r=ee(a,0))&&void 0!==r?r:"";if("AllSame"===i){var l=(f=(c=J(e,"Materials"))?ge(ye(c)):null)&&f.length>0?f[0]:0,u=new Int32Array(t);return 0!==l&&u.fill(l),u}if("ByPolygon"===i){var c;if(!(c=J(e,"Materials")))return null;var f=ge(ye(c));if("Direct"===s||"IndexToDirect"===s)return f}return null}(L,c.length));var P=function(e,t,n,r,o,a,i,s,l){for(var u=n.length,c=new Float64Array(3*u),f=new Uint32Array(u),d=0;d<n.length;d++){var h=n[d].controlPointIndex;c[3*d]=e[3*h],c[3*d+1]=e[3*h+1],c[3*d+2]=e[3*h+2],f[d]=h}var p=3*t.length,m=new Uint32Array(p);for(d=0;d<t.length;d++)m[3*d]=t[d].vertices[0],m[3*d+1]=t[d].vertices[1],m[3*d+2]=t[d].vertices[2];return{positions:c,indices:m,normals:r,uvs:o,uvSets:a,colors:i,tangents:s,binormals:l,controlPointIndices:f}}(s,f,d,p,A,m,M,R,F),N=null;if(I){var B=!0,k=I[0];for(O=1;O<I.length;O++)if(I[O]!==k){B=!1;break}if(!B||0!==k){var D=P.indices.length/3;N=new Int32Array(D);for(var G=0;G<f.length;G++)N[G]=null!==(o=I[f[G].polyIndex])&&void 0!==o?o:0}}return{id:t,name:a,positions:P.positions,indices:P.indices,normals:P.normals,uvs:P.uvs,uvSets:P.uvSets,colors:P.colors,tangents:P.tangents,binormals:P.binormals,controlPointIndices:P.controlPointIndices,materialIndices:N,diagnostics:u}}function ue(e,t,n,r){if(e.indices.length<3)return r.push({type:"degenerate-polygon",message:"Polygon ".concat(t," has fewer than three vertices."),polygonIndex:t}),[];if(3===e.indices.length)return[{vertices:[e.startIndex,e.startIndex+1,e.startIndex+2],polyIndex:t}];var o=function(e,t){var n=function(e,t){for(var n=0,r=0,o=0,a=0;a<e.indices.length;a++){var i=3*e.indices[a],s=3*e.indices[(a+1)%e.indices.length],l=t[i],u=t[i+1],c=t[i+2],f=t[s],d=t[s+1],h=t[s+2];n+=(u-d)*(c+h),r+=(c-h)*(l+f),o+=(l-f)*(u+d)}return[n,r,o]}(e,t),r=Math.abs(n[0]),o=Math.abs(n[1]),a=Math.abs(n[2]);if(r+o+a<1e-12)return null;var i=r>o&&r>a?0:o>a?1:2;return e.indices.map(function(e){var r=t[3*e],o=t[3*e+1],a=t[3*e+2];return 0===i?n[0]>=0?[o,a]:[a,o]:1===i?n[1]>=0?[a,r]:[r,a]:n[2]>=0?[r,o]:[o,r]})}(e,n);if(!o)return r.push({type:"degenerate-polygon",message:"Polygon ".concat(t," has a near-zero normal; using fan triangulation."),polygonIndex:t}),ce(e,t);var a=function(e){for(var t=0,n=0;n<e.length;n++){var r=e[n],o=e[(n+1)%e.length];t+=r[0]*o[1]-o[0]*r[1]}return t/2}(o);if(Math.abs(a)<1e-12)return r.push({type:"degenerate-polygon",message:"Polygon ".concat(t," projects to near-zero area; using fan triangulation."),polygonIndex:t}),ce(e,t);for(var i=a>0,s=e.indices.map(function(e,t){return t}),l=[],u=0;s.length>3&&u++<e.indices.length*e.indices.length;){for(var c=!1,f=0;f<s.length;f++){var d=s[(f+s.length-1)%s.length],h=s[f],p=s[(f+1)%s.length];if(fe(o[d],o[h],o[p],i)&&!de(o,s,d,h,p)){l.push({vertices:[e.startIndex+d,e.startIndex+h,e.startIndex+p],polyIndex:t}),s.splice(f,1),c=!0;break}}if(!c)return r.push({type:"triangulation-fallback",message:"Polygon ".concat(t," could not be fully ear-clipped; using fan triangulation."),polygonIndex:t}),ce(e,t)}return l.push({vertices:[e.startIndex+s[0],e.startIndex+s[1],e.startIndex+s[2]],polyIndex:t}),l}function ce(e,t){for(var n=[],r=1;r<e.indices.length-1;r++)n.push({vertices:[e.startIndex,e.startIndex+r,e.startIndex+r+1],polyIndex:t});return n}function fe(e,t,n,r){var o=(t[0]-e[0])*(n[1]-e[1])-(t[1]-e[1])*(n[0]-e[0]);return r?o>1e-12:o<-1e-12}function de(e,t,n,r,o){for(var a=0,i=t;a<i.length;a++){var s=i[a];if(s!==n&&s!==r&&s!==o&&he(e[s],e[n],e[r],e[o]))return!0}return!1}function he(e,t,n,r){var o=Math.abs(pe(t,n,r)),a=Math.abs(pe(e,t,n)),i=Math.abs(pe(e,n,r)),s=Math.abs(pe(e,r,t));return Math.abs(o-(a+i+s))<1e-10}function pe(e,t,n){return(t[0]-e[0])*(n[1]-e[1])-(t[1]-e[1])*(n[0]-e[0])}function me(e,t,n,r,o,a,i){var s,l,u=J(e,"MappingInformationType"),c=J(e,"ReferenceInformationType");if(!u||!c)return null;var f=null!==(s=ee(u,0))&&void 0!==s?s:"",d=null!==(l=ee(c,0))&&void 0!==l?l:"",h=J(e,t);if(!h)return null;var p=_e(ye(h)),m=null;if("IndexToDirect"===d){var v=J(e,n);v&&(m=ge(ye(v)))}for(var _=new Float64Array(r.length*a),g=0;g<r.length;g++){var y,b=r[g];y="ByPolygonVertex"===f?"IndexToDirect"===d&&m?m[b.globalIndex]:b.globalIndex:"ByControlPoint"===f||"ByVertice"===f?"IndexToDirect"===d&&m?m[b.controlPointIndex]:b.controlPointIndex:"ByPolygon"===f?"IndexToDirect"===d&&m?m[b.polyIndex]:b.polyIndex:"AllSame"===f?0:b.globalIndex;for(var x=0;x<a;x++){var T=y*a+x;y<0||T>=p.length?(i.push({type:T>=p.length?"layer-data-too-short":"layer-index-out-of-bounds",message:"Layer '".concat(e.name,"' references unavailable element ").concat(y,"."),layerName:e.name,index:y}),_[g*a+x]=0):_[g*a+x]=p[T]}}return _}function ve(e,t,n,r){if(!n||!r)return 1;var o=4*e,a=3*e,i=n[a],s=n[a+1],l=n[a+2],u=t[o],c=t[o+1],f=t[o+2];return(s*f-l*c)*r[a]+(l*u-i*f)*r[a+1]+(i*c-s*u)*r[a+2]<0?-1:1}function _e(e){if(e instanceof Float64Array)return e;if(e instanceof Float32Array)return new Float64Array(e);if(e instanceof Int32Array)return new Float64Array(e);if(Array.isArray(e)){for(var t=new Float64Array(e.length),n=0;n<e.length;n++)t[n]=Number(e[n]);return t}throw new Error("Cannot convert ".concat(typeof e," to Float64Array"))}function ge(e){if(e instanceof Int32Array)return e;if(e instanceof Float64Array){for(var t=new Int32Array(e.length),n=0;n<e.length;n++)t[n]=Math.round(e[n]);return t}if(e instanceof Float32Array){for(t=new Int32Array(e.length),n=0;n<e.length;n++)t[n]=Math.round(e[n]);return t}if(Array.isArray(e)){for(t=new Int32Array(e.length),n=0;n<e.length;n++)t[n]=Math.round(Number(e[n]));return t}throw new Error("Cannot convert ".concat(typeof e," to Int32Array"))}function ye(e){return 1===e.properties.length?e.properties[0].value:e.properties.map(function(e){return e.value})}function be(e,t,n){var r=e.get(t);if(r)return n?r.get(n):r.values().next().value}function xe(e,t,n,r){var o;return void 0===r&&(r=0),null===(o=we(e,t,n))||void 0===o?void 0:o[r]}function Te(e,t,n,r){var o;return null!==(o=Me(xe(e,t,n)))&&void 0!==o?o:r}function Ae(e,t,n,r){var o=we(e,t,n);if(!o)return r;var a=Me(o[0]),i=Me(o[1]),s=Me(o[2]);return void 0!==a&&void 0!==i&&void 0!==s?[a,i,s]:r}function we(e,t,n){var r,o;return null!==(r=function(e,t){for(var n=0,r=[J(e,"Properties70"),J(e,"Properties60")].filter(function(e){return void 0!==e});n<r.length;n++)for(var o=0,a=r[n].children;o<a.length;o++){var i=a[o];if(("P"===i.name||"Property"===i.name)&&ee(i,0)===t)return i.properties.slice("Property"===i.name?3:4).map(function(e){return e.value})}}(e,n))&&void 0!==r?r:null===(o=null==t?void 0:t.properties.get(n))||void 0===o?void 0:o.values}function Me(e){if("number"==typeof e)return e}function Ce(e,t,n){for(var r,o=new Map,a=J(n,"Properties70"),i=0,s=null!==(r=null==a?void 0:a.children)&&void 0!==r?r:[];i<s.length;i++){var l=s[i];if("P"===l.name){var u=Oe(l);u&&o.set(u.name,u)}}return{objectType:e,templateName:t,properties:o}}function Oe(e){var t,n,r,o=ee(e,0);return o?{name:o,propertyType:null!==(t=ee(e,1))&&void 0!==t?t:"",label:null!==(n=ee(e,2))&&void 0!==n?n:"",flags:null!==(r=ee(e,3))&&void 0!==r?r:"",values:e.properties.slice(4).map(function(e){return e.value})}:null}function Se(e,t,n,r){var o,a,i,s,l=te(null!==(o=ee(e,1))&&void 0!==o?o:"Material"),u=function(e,t){var n,r;if(t){var o=J(e,"ShadingModel"),a=o?ee(o,0):void 0;return"phong"===(null==a?void 0:a.toLowerCase())?null!==(n=be(t,"Material","FbxSurfacePhong"))&&void 0!==n?n:be(t,"Material"):"lambert"===(null==a?void 0:a.toLowerCase())&&null!==(r=be(t,"Material","FbxSurfaceLambert"))&&void 0!==r?r:be(t,"Material")}}(e,r),c=J(e,"ShadingModel"),f="phong"===(c?null!==(a=ee(c,0))&&void 0!==a?a:"Lambert":null!==(i=xe(e,u,"ShadingModel"))&&void 0!==i?i:"Lambert").toLowerCase()?"Phong":"Lambert",d=function(e,t){var n,r,o,a,i,s={};return s.diffuseColor=null!==(n=Ee(e,t,"DiffuseColor"))&&void 0!==n?n:Ee(e,t,"Diffuse"),s.diffuseFactor=Fe(e,t,"DiffuseFactor"),s.ambientColor=null!==(r=Ee(e,t,"AmbientColor"))&&void 0!==r?r:Ee(e,t,"Ambient"),s.ambientFactor=Fe(e,t,"AmbientFactor"),s.specularColor=null!==(o=Ee(e,t,"SpecularColor"))&&void 0!==o?o:Ee(e,t,"Specular"),s.specularFactor=Fe(e,t,"SpecularFactor"),s.shininess=null!==(a=Fe(e,t,"Shininess"))&&void 0!==a?a:Fe(e,t,"ShininessExponent"),s.emissiveColor=null!==(i=Ee(e,t,"EmissiveColor"))&&void 0!==i?i:Ee(e,t,"Emissive"),s.emissiveFactor=Fe(e,t,"EmissiveFactor"),s.opacity=Fe(e,t,"Opacity"),s.transparencyFactor=Fe(e,t,"TransparencyFactor"),s}(e,u),h=function(e,t,n){for(var r,o,a,i,s,l=[],u=0,c=ne(t,e,"Texture");u<c.length;u++){var f=c[u],d=f.id,h=f.node,p=f.propertyName,m=J(h,"FileName"),v=J(h,"RelativeFilename"),_=m&&null!==(r=ee(m,0))&&void 0!==r?r:"",g=v&&null!==(o=ee(v,0))&&void 0!==o?o:"",y=void 0,b=void 0,x=null!==(a=Fe(h,n,"UVRotation"))&&void 0!==a?a:Fe(h,n,"Rotation"),T=void 0;y=null!==(i=Re(h,n,"UVTranslation"))&&void 0!==i?i:Re(h,n,"Translation"),b=null!==(s=Re(h,n,"UVScaling"))&&void 0!==s?s:Re(h,n,"Scaling");var A=xe(h,n,"UVSet");A&&A.length>0&&(T=A),null!=y||(y=Ie(h,"ModelUVTranslation")),null!=b||(b=Ie(h,"ModelUVScaling"));for(var w=null,M=0,C=ne(t,d,"Video");M<C.length;M++){var O=J(C[M].node,"Content");if(O&&O.properties.length>0){var S=O.properties[0].value;S instanceof Uint8Array&&S.length>0?w=S:S instanceof ArrayBuffer&&S.byteLength>0&&(w=new Uint8Array(S))}}l.push({propertyName:null!=p?p:"DiffuseColor",fileName:_,relativeFileName:g,id:d,embeddedData:w,uvTranslation:y,uvScaling:b,uvRotation:x,uvSetName:T})}return l}(t,n,r?null!==(s=be(r,"Texture","FbxFileTexture"))&&void 0!==s?s:be(r,"Texture"):void 0);return{id:t,name:l,type:f,properties:d,textures:h}}function Ee(e,t,n){var r=we(e,t,n);if(r&&!(r.length<3)){var o=Le(r[0]),a=Le(r[1]),i=Le(r[2]);if(void 0!==o&&void 0!==a&&void 0!==i)return[o,a,i]}}function Fe(e,t,n){return Le(xe(e,t,n))}function Re(e,t,n){var r=we(e,t,n);if(r){var o=Le(r[0]),a=Le(r[1]);return void 0!==o&&void 0!==a?[o,a]:void 0}}function Le(e){if("number"==typeof e)return e}function Ie(e,t){var n,r,o=J(e,t);if(o){var a=Le(null===(n=o.properties[0])||void 0===n?void 0:n.value),i=Le(null===(r=o.properties[1])||void 0===r?void 0:r.value);return void 0!==a&&void 0!==i?[a,i]:void 0}}function Pe(e,t,n){var r,o=n.parentOf.get(e);if(!o)return null;var a=o.id,i=n.objects.get(a);if(!i||"Geometry"!==i.name)return null;var s=n.parentOf.get(a),l=s?n.objects.get(s.id):void 0,u="Model"===(null==l?void 0:l.name)?s.id:void 0,c=ne(n,e,"Deformer");if(0===c.length)return null;for(var f=new Map,d=0,h=c;d<h.length;d++){var p=h[d],m=p.id,v=p.node;if("Cluster"===ee(v,2)){var _=ne(n,m,"Model");_.length>0&&f.set(_[0].id,{clusterId:m,clusterNode:v})}}var g=function(e,t){var n,r,o=t.parentOf.get(e),a=o?t.objects.get(o.id):void 0,i="Model"===(null==a?void 0:a.name)?o.id:void 0;if(void 0===i)return new Map;for(var s=0,l=Array.from(t.objects);s<l.length;s++){var u=l[s][1];if("Pose"===u.name&&"BindPose"===ee(u,2)){for(var c=new Map,f=0,d=u.children;f<d.length;f++){var h=d[f];if("PoseNode"===h.name){var p=J(h,"Node"),m=J(h,"Matrix"),v=null===(n=null==p?void 0:p.properties[0])||void 0===n?void 0:n.value,_=null===(r=null==m?void 0:m.properties[0])||void 0===r?void 0:r.value;if("number"==typeof v){var g=Ue(_);16===(null==g?void 0:g.length)&&c.set(v,g)}}}if(c.has(i))return c}}return new Map}(a,n),y=[],b=function(e,t,n,r){for(var o,a,i,s,l,u=[],c=new Set,f=function(e,t){for(var n=new Set(Array.from(e.keys())),r=0,o=Array.from(e.keys());r<o.length;r++)for(var a=Ne(o[r],t);void 0!==a;){var i=t.objects.get(a);if(!i||"Model"!==i.name)break;n.add(a),a=Ne(a,t)}return n}(e,n),d=function(e,t){for(var n=new Map,r=0,o=Array.from(e);r<o.length;r++)for(var a=o[r],i=Ne(a,t);void 0!==i;){if(e.has(i)){n.set(a,i);break}i=Ne(i,t)}return n}(f,n),h=function(e,t){for(var n=new Map,r=0,o=Array.from(e);r<o.length;r++){var a=o[r],i=t.get(a);void 0!==i&&(n.has(i)||n.set(i,[]),n.get(i).push(a))}return n}(f,d),p=Array.from(f).filter(function(e){return!d.has(e)}).map(function(e){return{modelId:e,parentIndex:-1}});p.length>0;){var m=p.shift(),v=m.modelId,_=m.parentIndex;if(!c.has(v)){c.add(v);var g=n.objects.get(v);if(g){var y=u.length,b=e.get(v),x=ke(g),T=b?De(b.clusterNode):{bindPoseMatrix:null,transformLinkMatrix:null,transformAssociateModelMatrix:null,clusterMode:"Unknown"},A=T.bindPoseMatrix,w=T.transformLinkMatrix,M=T.transformAssociateModelMatrix,C=T.clusterMode,O=Ge(v,te(null!==(o=ee(g,1))&&void 0!==o?o:"Bone".concat(y)),void 0!==b,C,A,w,M,null!==(a=t.get(v))&&void 0!==a?a:null);r.push.apply(r,O),u.push({modelId:v,name:te(null!==(i=ee(g,1))&&void 0!==i?i:"Bone".concat(y)),index:y,parentIndex:_,isCluster:void 0!==b,translation:x.translation,rotation:x.rotation,preRotation:x.preRotation,postRotation:x.postRotation,rotationPivot:x.rotationPivot,scalingPivot:x.scalingPivot,rotationOffset:x.rotationOffset,scalingOffset:x.scalingOffset,scale:x.scale,rotationOrder:x.rotationOrder,inheritType:x.inheritType,clusterMode:C,bindPoseMatrix:A,transformLinkMatrix:w,transformAssociateModelMatrix:M,modelBindPoseMatrix:null!==(s=t.get(v))&&void 0!==s?s:null,diagnostics:O});for(var S=0,E=null!==(l=h.get(v))&&void 0!==l?l:[];S<E.length;S++){var F=E[S];c.has(F)||p.push({modelId:F,parentIndex:y})}}}}return u}(f,g,n,y);if(0===b.length)return null;var x=function(e,t){for(var n,r,o,a=0,i=0,s=e;i<s.length;i++){var l=s[i];if((m=t.get(l.modelId))&&(v=J(m.clusterNode,"Indexes"))&&(g=He(null===(n=v.properties[0])||void 0===n?void 0:n.value)))for(var u=0;u<g.length;u++)g[u]>a&&(a=g[u])}var c=a+1,f=new Array(c),d=new Array(c);for(u=0;u<c;u++)f[u]=[],d[u]=[];for(var h=0,p=e;h<p.length;h++){var m;if(l=p[h],m=t.get(l.modelId)){var v=J(m.clusterNode,"Indexes"),_=J(m.clusterNode,"Weights");if(v&&_){var g=He(null===(r=v.properties[0])||void 0===r?void 0:r.value),y=Ue(null===(o=_.properties[0])||void 0===o?void 0:o.value);if(g&&y)for(u=0;u<g.length;u++){var b=g[u];f[b].push(l.index),d[b].push(y[u])}}}}var x=function(e){if(0===f[e].length)return"continue";var t=f[e].map(function(t,n){return{index:t,weight:d[e][n]}});t.sort(function(e,t){return t.weight-e.weight});var n=t.slice(0,8);f[e]=n.map(function(e){return e.index}),d[e]=n.map(function(e){return e.weight})};for(u=0;u<c;u++)x(u);for(u=0;u<c;u++){var T=d[u].reduce(function(e,t){return e+t},0);if(T>0)for(var A=0;A<d[u].length;A++)d[u][A]/=T}return{boneIndices:f,boneWeights:d}}(b,f),T=x.boneIndices,A=x.boneWeights;return{id:e,geometryId:a,meshBindPoseMatrix:void 0!==u&&null!==(r=g.get(u))&&void 0!==r?r:null,bones:b,boneIndices:T,boneWeights:A,diagnostics:y}}function Ne(e,t){var n=t.connections.find(function(n){var r;return"OO"===n.type&&n.childId===e&&"Model"===(null===(r=t.objects.get(n.parentId))||void 0===r?void 0:r.name)});return null==n?void 0:n.parentId}function Be(e){var t=ee(e,2);return"Root"===t||"LimbNode"===t}function ke(e){var t,n,r,o,a,i,s,l,u,c,f,d,h,p,m,v,_,g,y,b,x,T,A,w,M,C,O,S,E,F,R,L,I,P,N,B,k,D,G,V,H,U,j,K,W,z,q,X,Y,Q,Z,$,te,ne,re,oe,ae,ie,se=[0,0,0],le=[0,0,0],ue=[0,0,0],ce=[0,0,0],fe=[0,0,0],de=[0,0,0],he=[0,0,0],pe=[0,0,0],me=[1,1,1],ve=0,_e=1,ge=J(e,"Properties70");if(!ge)return{translation:se,rotation:le,preRotation:ue,postRotation:ce,rotationPivot:fe,scalingPivot:de,rotationOffset:he,scalingOffset:pe,scale:me,rotationOrder:ve,inheritType:_e};for(var ye=0,be=ge.children;ye<be.length;ye++){var xe=be[ye];if("P"===xe.name){var Te=ee(xe,0);if(Te)switch(Te){case"Lcl Translation":se[0]=null!==(n=Ve(null===(t=xe.properties[4])||void 0===t?void 0:t.value))&&void 0!==n?n:0,se[1]=null!==(o=Ve(null===(r=xe.properties[5])||void 0===r?void 0:r.value))&&void 0!==o?o:0,se[2]=null!==(i=Ve(null===(a=xe.properties[6])||void 0===a?void 0:a.value))&&void 0!==i?i:0;break;case"Lcl Rotation":le[0]=null!==(l=Ve(null===(s=xe.properties[4])||void 0===s?void 0:s.value))&&void 0!==l?l:0,le[1]=null!==(c=Ve(null===(u=xe.properties[5])||void 0===u?void 0:u.value))&&void 0!==c?c:0,le[2]=null!==(d=Ve(null===(f=xe.properties[6])||void 0===f?void 0:f.value))&&void 0!==d?d:0;break;case"PreRotation":ue[0]=null!==(p=Ve(null===(h=xe.properties[4])||void 0===h?void 0:h.value))&&void 0!==p?p:0,ue[1]=null!==(v=Ve(null===(m=xe.properties[5])||void 0===m?void 0:m.value))&&void 0!==v?v:0,ue[2]=null!==(g=Ve(null===(_=xe.properties[6])||void 0===_?void 0:_.value))&&void 0!==g?g:0;break;case"PostRotation":ce[0]=null!==(b=Ve(null===(y=xe.properties[4])||void 0===y?void 0:y.value))&&void 0!==b?b:0,ce[1]=null!==(T=Ve(null===(x=xe.properties[5])||void 0===x?void 0:x.value))&&void 0!==T?T:0,ce[2]=null!==(w=Ve(null===(A=xe.properties[6])||void 0===A?void 0:A.value))&&void 0!==w?w:0;break;case"RotationPivot":fe[0]=null!==(C=Ve(null===(M=xe.properties[4])||void 0===M?void 0:M.value))&&void 0!==C?C:0,fe[1]=null!==(S=Ve(null===(O=xe.properties[5])||void 0===O?void 0:O.value))&&void 0!==S?S:0,fe[2]=null!==(F=Ve(null===(E=xe.properties[6])||void 0===E?void 0:E.value))&&void 0!==F?F:0;break;case"ScalingPivot":de[0]=null!==(L=Ve(null===(R=xe.properties[4])||void 0===R?void 0:R.value))&&void 0!==L?L:0,de[1]=null!==(P=Ve(null===(I=xe.properties[5])||void 0===I?void 0:I.value))&&void 0!==P?P:0,de[2]=null!==(B=Ve(null===(N=xe.properties[6])||void 0===N?void 0:N.value))&&void 0!==B?B:0;break;case"RotationOffset":he[0]=null!==(D=Ve(null===(k=xe.properties[4])||void 0===k?void 0:k.value))&&void 0!==D?D:0,he[1]=null!==(V=Ve(null===(G=xe.properties[5])||void 0===G?void 0:G.value))&&void 0!==V?V:0,he[2]=null!==(U=Ve(null===(H=xe.properties[6])||void 0===H?void 0:H.value))&&void 0!==U?U:0;break;case"ScalingOffset":pe[0]=null!==(K=Ve(null===(j=xe.properties[4])||void 0===j?void 0:j.value))&&void 0!==K?K:0,pe[1]=null!==(z=Ve(null===(W=xe.properties[5])||void 0===W?void 0:W.value))&&void 0!==z?z:0,pe[2]=null!==(X=Ve(null===(q=xe.properties[6])||void 0===q?void 0:q.value))&&void 0!==X?X:0;break;case"Lcl Scaling":me[0]=null!==(Q=Ve(null===(Y=xe.properties[4])||void 0===Y?void 0:Y.value))&&void 0!==Q?Q:1,me[1]=null!==($=Ve(null===(Z=xe.properties[5])||void 0===Z?void 0:Z.value))&&void 0!==$?$:1,me[2]=null!==(ne=Ve(null===(te=xe.properties[6])||void 0===te?void 0:te.value))&&void 0!==ne?ne:1;break;case"RotationOrder":ve=null!==(oe=Ve(null===(re=xe.properties[4])||void 0===re?void 0:re.value))&&void 0!==oe?oe:0;break;case"InheritType":_e=null!==(ie=Ve(null===(ae=xe.properties[4])||void 0===ae?void 0:ae.value))&&void 0!==ie?ie:1}}}return{translation:se,rotation:le,preRotation:ue,postRotation:ce,rotationPivot:fe,scalingPivot:de,rotationOffset:he,scalingOffset:pe,scale:me,rotationOrder:ve,inheritType:_e}}function De(e){var t=null,n=null,r=null,o="Normalize",a=J(e,"Transform");a&&a.properties[0]&&((s=a.properties[0].value)instanceof Float64Array&&16===s.length?t=s:s instanceof Float32Array&&16===s.length&&(t=new Float64Array(s)));var i=J(e,"TransformLink");i&&i.properties[0]&&((s=i.properties[0].value)instanceof Float64Array&&16===s.length?n=s:s instanceof Float32Array&&16===s.length&&(n=new Float64Array(s)));var s,l=J(e,"TransformAssociateModel");l&&l.properties[0]&&((s=l.properties[0].value)instanceof Float64Array&&16===s.length?r=s:s instanceof Float32Array&&16===s.length&&(r=new Float64Array(s)));var u=J(e,"Mode"),c=u?ee(u,0):void 0;return"Normalize"===c||"Additive"===c||"TotalOne"===c?o=c:c&&(o="Unknown"),{bindPoseMatrix:t,transformLinkMatrix:n,transformAssociateModelMatrix:r,clusterMode:o}}function Ge(e,t,n,r,o,a,i,s){if(!n)return[];var l=[];return"Additive"!==r&&"TotalOne"!==r||l.push({type:"cluster-mode-runtime-unsupported",message:"Cluster mode '".concat(r,"' is preserved but not applied by Babylon linear blend skinning."),boneModelId:e,boneName:t,clusterMode:r}),o||l.push({type:"missing-cluster-transform",message:"Cluster is missing Transform matrix; falling back to rest/bind-pose data.",boneModelId:e,boneName:t,clusterMode:r}),a||l.push({type:"missing-cluster-transform-link",message:"Cluster is missing TransformLink matrix; falling back to model bind pose or rest transform.",boneModelId:e,boneName:t,clusterMode:r}),s||l.push({type:"missing-bind-pose-matrix",message:"No BindPose matrix was found for this bone model.",boneModelId:e,boneName:t,clusterMode:r}),i&&l.push({type:"associate-model-present",message:"TransformAssociateModel is preserved for future associate-model skinning semantics.",boneModelId:e,boneName:t,clusterMode:r}),l}function Ve(e){if("number"==typeof e)return e}function He(e){if(e instanceof Int32Array)return e;if(e instanceof Float64Array){for(var t=new Int32Array(e.length),n=0;n<e.length;n++)t[n]=Math.round(e[n]);return t}return null}function Ue(e){return e instanceof Float64Array?e:e instanceof Float32Array?new Float64Array(e):null}function je(e,t){for(var n,r=null!==(n=function(e,t){if(0!==e.length){for(var n=e.map(function(e){return Ke(e,t)}),r=new Set(n[0]),o=0,a=n.slice(1);o<a.length;o++)for(var i=a[o],s=0,l=Array.from(r);s<l.length;s++){var u=l[s];i.includes(u)||r.delete(u)}return n[0].find(function(e){return r.has(e)})}}(e,t))&&void 0!==n?n:e[0],o=r,a=We(o,t);void 0!==a;){var i=t.objects.get(a);if(!i||"Model"!==i.name||!Be(i))break;o=a,a=We(a,t)}return o}function Ke(e,t){for(var n=[],r=e;void 0!==r;){var o=t.objects.get(r);if(!o||"Model"!==o.name)break;n.push(r),r=We(r,t)}return n}function We(e,t){var n=t.connections.find(function(n){var r;return"OO"===n.type&&n.childId===e&&"Model"===(null===(r=t.objects.get(n.parentId))||void 0===r?void 0:r.name)});return null==n?void 0:n.parentId}function ze(e){var t,n,r;return null!==(r=null!==(n=null!==(t=e.find(function(e){return e.isCluster&&e.transformLinkMatrix}))&&void 0!==t?t:e.find(function(e){return e.isCluster}))&&void 0!==n?n:e.find(function(e){return e.modelBindPoseMatrix}))&&void 0!==r?r:e[0]}function qe(e,t){var n,r=t.objects.get(e);if(!r||"Model"!==r.name)return null;var o=ke(r);return{modelId:e,name:te(null!==(n=ee(r,1))&&void 0!==n?n:"Bone".concat(e.toString())),index:-1,parentIndex:-1,isCluster:!1,translation:o.translation,rotation:o.rotation,preRotation:o.preRotation,postRotation:o.postRotation,rotationPivot:o.rotationPivot,scalingPivot:o.scalingPivot,rotationOffset:o.rotationOffset,scalingOffset:o.scalingOffset,scale:o.scale,rotationOrder:o.rotationOrder,inheritType:o.inheritType,clusterMode:"Unknown",bindPoseMatrix:null,transformLinkMatrix:null,transformAssociateModelMatrix:null,modelBindPoseMatrix:null,diagnostics:[]}}function Xe(e,t){return e<t?-1:e>t?1:0}function Ye(e,t,n){var r,o;return(null!==(r=n.get(e))&&void 0!==r?r:Number.MAX_SAFE_INTEGER)-(null!==(o=n.get(t))&&void 0!==o?o:Number.MAX_SAFE_INTEGER)||Xe(e,t)}var Qe=46186158e3,Ze=1/23,Je=1e-5,$e=[24,25,30,48,50,60,100,120];function et(e,t,n){var r,o,a,i,s=te(null!==(r=ee(t,1))&&void 0!==r?r:"Animation"),l=function(e){var t,n,r,o,a=J(e,"Properties70");if(!a)return null;for(var i=0,s=null,l=0,u=a.children;l<u.length;l++){var c=u[l];if("P"===c.name){var f=ee(c,0);"LocalStart"===f||"ReferenceStart"===f?i=null!==(n=ct(null===(t=c.properties[4])||void 0===t?void 0:t.value))&&void 0!==n?n:i:"LocalStop"!==f&&"ReferenceStop"!==f||(s=null!==(o=ct(null===(r=c.properties[4])||void 0===r?void 0:r.value))&&void 0!==o?o:s)}}return null!==s?{start:i,stop:s}:null}(t),u=ne(n,e,"AnimationLayer");if(0===u.length)return null;for(var c=[],f=[],d=[],h=[],p=1/0,m=0,v=0,_=u;v<_.length;v++){var g=_[v],y=g.id,b=g.node,x=te(null!==(o=ee(b,1))&&void 0!==o?o:"Layer"),T=100,A=0,w=J(b,"Properties70");if(w)for(var M=0,C=w.children;M<C.length;M++){var O=C[M];if("P"===O.name){var S=ee(O,0);if("Weight"===S)"number"==typeof(E=null===(a=O.properties[4])||void 0===a?void 0:a.value)&&(T=E);else if("BlendMode"===S){var E;"number"==typeof(E=null===(i=O.properties[4])||void 0===i?void 0:i.value)&&(A=E)}}}for(var F=[],R=[],L=[],I=0,P=ne(n,y,"AnimationCurveNode");I<P.length;I++){var N=P[I],B=N.id,k=N.node,D=tt(B,k,n);if(D){for(var G=0,V=D.curves;G<V.length;G++)for(var H=0,U=V[G].keys;H<U.length;H++)(fe=U[H]).time<p&&(p=fe.time),fe.time>m&&(m=fe.time);F.push(D),c.push(D)}else{var j=nt(B,k,n);if(j){rt(j.curves,function(e){e<p&&(p=e),e>m&&(m=e)}),R.push(j),f.push(j);var K={type:"unsupported-curve-node",message:"AnimationCurveNode '".concat(j.type,"' is preserved as diagnostic data but not evaluated at runtime."),layerName:x,curveNodeId:B,curveNodeType:j.type,targetId:j.targetId,propertyName:j.propertyName};L.push(K),h.push(K)}}}d.push({name:x,weight:T,normalizedWeight:T/100,blendMode:A,curveNodes:F,unsupportedCurveNodes:R,diagnostics:L})}if(0===c.length&&0===f.length)return null;d.length>1&&h.push({type:"multiple-animation-layers",message:"Multiple animation layers are preserved, but runtime blending is not yet evaluated."});for(var W=0,z=d;W<z.length;W++){var q=z[W];0!==q.blendMode&&(K={type:"unsupported-layer-blend-mode",message:"Animation layer blend mode ".concat(q.blendMode," is preserved but not yet blended at runtime."),layerName:q.name},q.diagnostics.push(K),h.push(K)),100!==q.weight&&(K={type:"partial-layer-weight",message:"Animation layer weight ".concat(q.weight," is preserved but not yet applied at runtime."),layerName:q.name},q.diagnostics.push(K),h.push(K))}var X=p>0&&isFinite(p)?p:0;if(X>0){for(var Y=0,Q=c;Y<Q.length;Y++)for(var Z=0,$=Q[Y].curves;Z<$.length;Z++)for(var re=0,oe=$[Z].keys;re<oe.length;re++)(fe=oe[re]).time-=X;for(var ae=0,ie=f;ae<ie.length;ae++)for(var se=0,le=ie[ae].curves;se<le.length;se++)for(var ue=0,ce=le[se].keys;ue<ce.length;ue++){var fe;(fe=ce[ue]).time-=X}m-=X}var de=l?Math.max(l.start-X,0):0,he=l?Math.max(l.stop-X,de):0,pe=he>de,me=pe?de:0,ve=pe?he:m;return{name:s,startTime:me,stopTime:ve,duration:Math.max(ve-me,0),curveNodes:c,layers:d,unsupportedCurveNodes:f,diagnostics:h}}function tt(e,t,n){var r,o=te(null!==(r=ee(t,1))&&void 0!==r?r:"");if("T"===o||"R"===o||"S"===o){var a=function(e,t){for(var n=0,r=t.connections;n<r.length;n++){var o=r[n];if(o.childId===e&&"OP"===o.type){var a=t.objects.get(o.parentId);if(a&&"Model"===a.name)return o.parentId}}return null}(e,n);return null===a||0===(i=ot(e,n)).length?null:{type:o,targetModelId:a,curves:i}}if("DeformPercent"===o){var i,s=function(e,t){for(var n=0,r=t.connections;n<r.length;n++)if((i=r[n]).childId===e&&"OP"===i.type&&(s=t.objects.get(i.parentId))&&"Deformer"===s.name&&"BlendShapeChannel"===ee(s,2))return i.parentId;for(var o=0,a=t.connections;o<a.length;o++){var i,s;if((i=a[o]).childId===e&&"OO"===i.type&&(s=t.objects.get(i.parentId))&&"Deformer"===s.name&&"BlendShapeChannel"===ee(s,2))return i.parentId}return null}(e,n);return null===s||0===(i=ot(e,n)).length?null:{type:"DeformPercent",targetModelId:s,curves:i}}return null}function nt(e,t,n){var r,o=te(null!==(r=ee(t,1))&&void 0!==r?r:""),a=ot(e,n),i=function(e){for(var t,n,r={},o=J(e,"Properties70"),a=0,i=null!==(t=null==o?void 0:o.children)&&void 0!==t?t:[];a<i.length;a++){var s=i[a];if("P"===s.name){var l=ee(s,0);if(null==l?void 0:l.startsWith("d|")){var u=ft(null===(n=s.properties[4])||void 0===n?void 0:n.value);null!==u&&(r[l]=u)}}}return r}(t);if(0===a.length&&0===Object.keys(i).length)return null;for(var s,l=null,u=0,c=n.connections;u<c.length;u++){var f=c[u];if(f.childId===e&&"OP"===f.type){l=f.parentId,s=f.propertyName;break}}return{type:o,id:e,targetId:l,propertyName:s,curveCount:a.length,curves:a,defaultValues:i}}function rt(e,t){for(var n=0,r=e;n<r.length;n++)for(var o=0,a=r[n].keys;o<a.length;o++)t(a[o].time)}function ot(e,t){for(var n,r=[],o=0,a=t.connections;o<a.length;o++){var i=a[o];if(i.parentId===e&&"OP"===i.type){var s=t.objects.get(i.childId);if(!s||"AnimationCurve"!==s.name)continue;var l=null!==(n=i.propertyName)&&void 0!==n?n:"d|X";if((h=at(s)).length>0){var u=it(s,h);r.push({channel:l,keys:u?st(h):h,isSampled:u})}}}if(0===r.length)for(var c=ne(t,e,"AnimationCurve"),f=["d|X","d|Y","d|Z"],d=0;d<c.length&&d<3;d++){var h;(h=at(c[d].node)).length>0&&(u=it(c[d].node,h),r.push({channel:f[d],keys:u?st(h):h,isSampled:u}))}return r}function at(e){var t,n,r,o,a,i,s,l,u,c=J(e,"KeyTime"),f=J(e,"KeyValueFloat");if(!c||!f)return[];var d,h=(d=null===(t=c.properties[0])||void 0===t?void 0:t.value)instanceof Float64Array?d:null,p=dt(null===(n=f.properties[0])||void 0===n?void 0:n.value),m=ut(null===(o=null===(r=J(e,"KeyAttrFlags"))||void 0===r?void 0:r.properties[0])||void 0===o?void 0:o.value),v=dt(null===(i=null===(a=J(e,"KeyAttrDataFloat"))||void 0===a?void 0:a.properties[0])||void 0===i?void 0:i.value),_=ut(null===(l=null===(s=J(e,"KeyAttrRefCount"))||void 0===s?void 0:s.properties[0])||void 0===l?void 0:l.value);if(!h||!p)return[];if(h.length!==p.length)return[];for(var g=function(e,t,n){if(!t||0===t.length)return new Array(e).fill(-1);if(n&&n.length>0){for(var r=0,o=0,a=n;o<a.length;o++)r+=l=a[o];if(r===e){for(var i=[],s=0;s<n.length;s++)for(var l=n[s],u=0;u<l;u++)i.push(s);return i}}return t.length===e?Array.from({length:e},function(e,t){return t}):1===t.length?new Array(e).fill(0):Array.from({length:e},function(e,n){return Math.min(n,t.length-1)})}(h.length,m,_),y=[],b=0;b<h.length;b++){var x=g[b],T=x>=0&&null!==(u=null==m?void 0:m[x])&&void 0!==u?u:0,A=4*x;y.push({time:Number(h[b])/Qe,value:p[b],interpolation:ht(T),constantMode:256&T?"next":"standard",rightSlope:pt(v,A),nextLeftSlope:pt(v,A+1)})}return y}function it(e,t){var n;return"FbxMayaSample Curve"===te(null!==(n=ee(e,1))&&void 0!==n?n:"")||function(e){if(e.length<8)return!1;for(var t=[],n=1;n<e.length;n++){var r=e[n].time-e[n-1].time;if(!(r>0))return!1;t.push(r)}var o=t.reduce(function(e,t){return e+t},0)/t.length;if(o>Ze)return!1;var a=Math.max(1e-6,.05*o);if(t.some(function(e){return Math.abs(e-o)>a}))return!1;var i=1/o;return!!$e.some(function(e){return Math.abs(i-e)<=Math.max(.25,.02*e)})&&!function(e){for(var t=!1,n=!0,r=!0,o=Number.POSITIVE_INFINITY,a=Number.NEGATIVE_INFINITY,i=0,s=0,l=e;s<l.length;s++){var u=l[s];o=Math.min(o,u.value),a=Math.max(a,u.value)}for(var c=0;c<e.length-1;c++){u=e[c];var f=e[c+1];if("cubic"===u.interpolation){t=!0;var d=f.time-u.time;if(d>0){var h=(f.value-u.value)/d,p=u.rightSlope,m=u.nextLeftSlope;if(void 0!==p&&void 0!==m){(Math.abs(p)>Je||Math.abs(m)>Je)&&(r=!1);for(var v=0,_=[.25,.5,.75];v<_.length;v++){var g=_[v],y=mt(u.value,f.value,p,m,d,g),b=u.value+g*d*h;i=Math.max(i,Math.abs(y-b))}}else n=!1}}}if(!t||!n||r)return!1;var x=a-o;return i>Math.max(1e-4,.01*x)}(e)}(t)}function st(e){return e.map(function(e){return{time:e.time,value:e.value,interpolation:"linear"}})}function lt(e,t){var n,r;if(!e||0===e.keys.length)return null;var o=e.keys;if(t<=o[0].time)return o[0].value;if(t>=o[o.length-1].time)return o[o.length-1].value;for(var a=0;a<o.length-1;a++){var i=o[a],s=o[a+1];if(!(t<i.time||t>s.time)){if(s.time===i.time)return i.value;if("constant"===i.interpolation)return"next"===i.constantMode?s.value:i.value;var l=s.time-i.time,u=(t-i.time)/l;if("cubic"===i.interpolation&&!e.isSampled){var c=(s.value-i.value)/l,f=null!==(n=i.rightSlope)&&void 0!==n?n:c,d=null!==(r=i.nextLeftSlope)&&void 0!==r?r:c;return mt(i.value,s.value,f,d,l,u)}return i.value+u*(s.value-i.value)}}return o[o.length-1].value}function ut(e){if(e instanceof Int32Array)return e;if(e instanceof Float32Array||e instanceof Float64Array){for(var t=new Int32Array(e.length),n=0;n<e.length;n++)t[n]=e[n];return t}return null}function ct(e){return"number"==typeof e?e/Qe:null}function ft(e){return"number"==typeof e?e:null}function dt(e){if(e instanceof Float32Array)return e;if(e instanceof Float64Array){for(var t=new Float32Array(e.length),n=0;n<e.length;n++)t[n]=e[n];return t}return null}function ht(e){return 8&e?"cubic":4&e?"linear":2&e?"constant":"linear"}function pt(e,t){if(!(!e||t<0||t>=e.length)){var n=e[t];return Number.isFinite(n)?n:void 0}}function mt(e,t,n,r,o,a){var i=a*a,s=i*a;return(2*s-3*i+1)*e+(s-2*i+a)*o*n+(-2*s+3*i)*t+(s-i)*o*r}function vt(e,t,n){var r,o,a=n.parentOf.get(e);if(!a)return null;var i=n.objects.get(a.id);if(!i||"Geometry"!==i.name)return null;for(var s=a.id,l=[],u=0,c=ne(n,e,"Deformer");u<c.length;u++){var f=c[u],d=f.id,h=f.node;if("BlendShapeChannel"===ee(h,2)){var p=te(null!==(r=ee(h,1))&&void 0!==r?r:"MorphTarget"),m=0,v=J(h,"Properties70");if(v)for(var _=0,g=v.children;_<g.length;_++){var b=g[_];if("P"===b.name&&"DeformPercent"===ee(b,0)){var x=null===(o=b.properties[4])||void 0===o?void 0:o.value;"number"==typeof x&&(m=x)}}for(var T=_t(h),A=[],w=0,M=ne(n,d,"Geometry");w<M.length;w++){var C=M[w].node;if("Shape"===ee(C,2)){var O=bt(C);O&&A.push(O)}}if(A.length>0){var S=[],E=gt(T,A,d,p,S);l.push({name:p,id:d,deformPercent:m,shapes:yt(A,E),fullWeights:E?y([],E,!0).sort(function(e,t){return e-t}):null,diagnostics:S})}}}return 0===l.length?null:{id:e,geometryId:s,channels:l}}function _t(e){var t,n=J(e,"FullWeights"),r=null===(t=null==n?void 0:n.properties[0])||void 0===t?void 0:t.value;return r&&(r instanceof Float64Array||r instanceof Float32Array||r instanceof Int32Array)?Array.from(r,function(e){return Number(e)}):null}function gt(e,t,n,r,o){return e?e.length!==t.length?(1===t.length||o.push({type:"full-weights-mismatch",message:"FullWeights length ".concat(e.length," does not match shape count ").concat(t.length,"; using the first shape for compatibility."),channelId:n,channelName:r}),null):e:(t.length>1&&o.push({type:"missing-full-weights",message:"Blend shape channel has multiple shapes but no FullWeights; using the first shape for compatibility.",channelId:n,channelName:r}),null)}function yt(e,t){return t&&t.length===e.length?e.map(function(e,n){return{shape:e,weight:t[n]}}).sort(function(e,t){return e.weight-t.weight}).map(function(e){return e.shape}):e.length>1?[e[0]]:e}function bt(e){var t,n,r,o=J(e,"Indexes"),a=J(e,"Vertices");if(!o||!a)return null;var i=null===(t=o.properties[0])||void 0===t?void 0:t.value,s=null===(n=a.properties[0])||void 0===n?void 0:n.value;if(!i||!s)return null;var l,u=function(e){if(e instanceof Uint32Array)return e;if(e instanceof Int32Array||e instanceof Float32Array||e instanceof Float64Array){for(var t=new Uint32Array(e.length),n=0;n<e.length;n++)t[n]=e[n];return t}return null}(i);if(!u)return null;if(s instanceof Float64Array)l=s;else{if(!(s instanceof Float32Array))return null;l=new Float64Array(s)}var c=null,f=J(e,"Normals");if(f){var d=null===(r=f.properties[0])||void 0===r?void 0:r.value;d instanceof Float64Array?c=d:d instanceof Float32Array&&(c=new Float64Array(d))}return{indices:u,vertices:l,normals:c}}var xt=new Set(["Character","CharacterPose","ControlSet","ControlSetPlug","SelectionSet","CollectionExclusive"]);function Tt(e){return"Skin"===e||"Cluster"===e||"BlendShape"===e||"BlendShapeChannel"===e}function At(e,t,n,r,o){var a,i,s,l;return{type:r,message:o,objectId:t,objectName:te(null!==(a=ee(n,1))&&void 0!==a?a:n.name),nodeName:n.name,subType:null!==(i=ee(n,2))&&void 0!==i?i:"",parentCount:e.connections.filter(function(e){return e.childId===t}).length,childCount:null!==(l=null===(s=e.childrenOf.get(t))||void 0===s?void 0:s.length)&&void 0!==l?l:0}}function wt(e){for(var t=function(e){var t,n,r=new Map,o=[],a=new Map,i=new Map,s=[],l=[],u=[],c=new Map,f=new Map,d=-1,h=function(e){var t=c.get(e);return void 0===t&&(t=d--,c.set(e,t)),t},p=function(e,t){var n=f.get(e);n||(n=new Map,f.set(e,n));var r=n.get(t);return void 0===r&&(r=d--,n.set(t,r)),r},m=$(e,"Objects");if(m)for(var v=0,_=m.children;v<_.length;v++){var g=_[v],y=g.properties[0];if(y){var b=re(y.value);if(void 0!==b)r.set(b,g),o.push({id:b,node:g,source:"Objects",synthetic:!1});else if("string"==typeof y.value){var x=te(y.value),T=h(x),A=ie(g,T);if(r.set(T,A),o.push({id:T,node:A,source:"Objects",legacyName:x,synthetic:!1}),"Model"===g.name&&"Mesh"===ee(g,1)){var w=p("Geometry",x),M=se(g,w);r.set(w,M),o.push({id:w,node:M,source:"legacySyntheticGeometry",legacyName:x,synthetic:!0}),ae(s,a,i,u,"OO",w,T)}}}}var C=$(e,"Connections");if(C)for(var O=0,S=C.children;O<S.length;O++){var E=S[O];if("C"===E.name||"Connect"===E.name){var F=l.length,R=ee(E,0),L=null===(t=E.properties[1])||void 0===t?void 0:t.value,I=null===(n=E.properties[2])||void 0===n?void 0:n.value,P={source:E.name,rawType:R,accepted:!1};if(l.push(P),"OO"===R||"OP"===R)if(void 0!==L&&void 0!==I){var N=oe(L,c),B=oe(I,c);if(void 0!==N&&void 0!==B){var k="OP"===R&&E.properties.length>3?ee(E,3):void 0;P.childId=N,P.parentId=B,P.propertyName=k,N===B&&u.push({reason:"self-loop",message:"FBX connection references the same object as child and parent.",connectionIndex:F,type:R,childId:N,parentId:B,propertyName:k}),r.has(N)||u.push({reason:"unresolved-object-reference",message:"FBX connection child ID is not present in the object table.",connectionIndex:F,type:R,childId:N,parentId:B,propertyName:k}),0===B||r.has(B)||u.push({reason:"unresolved-object-reference",message:"FBX connection parent ID is not present in the object table.",connectionIndex:F,type:R,childId:N,parentId:B,propertyName:k}),ae(s,a,i,u,R,N,B,k,F),P.accepted=!0}else u.push({reason:"unresolved-legacy-endpoint",message:"FBX connection references a legacy string endpoint that is not present in the object table.",connectionIndex:F,type:R})}else u.push({reason:"missing-connection-endpoint",message:"FBX connection is missing a child or parent endpoint.",connectionIndex:F,type:R});else{var D=void 0===L?void 0:oe(L,c),G=void 0===I?void 0:oe(I,c);u.push({reason:"unsupported-connection-type",message:"Unsupported FBX connection type '".concat(null!=R?R:"","' was not added to the graph."),connectionIndex:F,type:R,childId:D,parentId:G})}}}return{objects:r,objectEntries:o,childrenOf:a,parentOf:i,connections:s,connectionEntries:l,diagnostics:u}}(e),n=function(e){var t=new Map,n=$(e,"Definitions");if(!n)return t;for(var r=0,o=n.children;r<o.length;r++){var a=o[r];if("ObjectType"===a.name){var i=ee(a,0);if(i)for(var s=0,l=a.children;s<l.length;s++){var u=l[s];if("PropertyTemplate"===u.name){var c=ee(u,0);if(c){var f=Ce(i,c,u),d=t.get(i);d||(d=new Map,t.set(i,d)),d.set(c,f)}}}}}return t}(e),r=function(e){var t,n={upAxis:1,upAxisSign:1,frontAxis:2,frontAxisSign:1,coordAxis:0,coordAxisSign:1,unitScaleFactor:1},r=$(e,"GlobalSettings");if(!r)return n;var o=r.children.find(function(e){return"Properties70"===e.name});if(!o)return n;for(var a=0,i=o.children;a<i.length;a++){var s=i[a];if("P"===s.name){var l=ee(s,0),u=Et(null===(t=s.properties[4])||void 0===t?void 0:t.value);if(l&&void 0!==u)switch(l){case"UpAxis":n.upAxis=u;break;case"UpAxisSign":n.upAxisSign=u;break;case"FrontAxis":n.frontAxis=u;break;case"FrontAxisSign":n.frontAxisSign=u;break;case"CoordAxis":n.coordAxis=u;break;case"CoordAxisSign":n.coordAxisSign=u;break;case"UnitScaleFactor":n.unitScaleFactor=u}}}return n}(e),o=[],a=0,i=Array.from(t.objects);a<i.length;a++){var s=i[a],l=s[0];"Material"===(d=s[1]).name&&o.push(Se(d,l,t,n))}for(var u=[],c=0,f=Array.from(t.objects);c<f.length;c++){var d,h=f[c];l=h[0],"Geometry"===(d=h[1]).name&&"Mesh"===ee(d,2)&&u.push(le(d,l))}var p=function(e){for(var t=[],n=0,r=Array.from(e.objects);n<r.length;n++){var o=r[n],a=o[0],i=o[1];if("Deformer"===i.name&&"Skin"===ee(i,2)){var s=Pe(a,0,e);s&&t.push(s)}}return t}(t),m=function(e,t){if(0===t.length)return[];for(var n=new Map,r=0,o=t;r<o.length;r++){var a=o[r],i=a.bones.filter(function(e){return e.isCluster}).map(function(e){return e.modelId});if(0!==i.length){var s=je(i,e),l=n.get(s);l?l.push(a):n.set(s,[a])}}return Array.from(n.entries()).sort(function(e,t){return Xe(e[0],t[0])}).map(function(t){return function(e,t,n){for(var r,o,a=new Set,i=new Set,s=new Map,l=new Map,u=0,c=t;u<c.length;u++)for(var f=0,d=c[u].bones;f<d.length;f++){var h=d[f];if(l.has(h.modelId)||l.set(h.modelId,l.size),(M=s.get(h.modelId))||(M=[],s.set(h.modelId,M)),M.push(h),h.isCluster){a.add(h.modelId);for(var p=0,m=Ke(h.modelId,n);p<m.length;p++){var _=m[p];i.add(_)}}}for(var g=function(e){for(var t=[],n=function(e,n){var r=n.filter(function(e){return e.isCluster&&e.transformLinkMatrix}).map(function(e){return e.transformLinkMatrix});if(r.length<2)return"continue";var o=r[0];r.some(function(e){return!function(e,t){if(e.length!==t.length)return!1;for(var n=0;n<e.length;n++)if(Math.abs(e[n]-t[n])>1e-5)return!1;return!0}(o,e)})&&t.push("Model ".concat(e.toString()," has differing Cluster.TransformLink matrices across skins"))},r=0,o=Array.from(e);r<o.length;r++){var a=o[r];n(a[0],a[1])}return t}(s),b=new Map,x=0,T=Array.from(s);x<T.length;x++){var A=T[x],w=A[0],M=A[1];b.set(w,ze(M))}for(var C=function(e,t){for(var n=new Map,r=0,o=Array.from(e);r<o.length;r++){var a=o[r],i=We(a,t);void 0!==i&&e.has(i)&&n.set(a,i)}return n}(i,n),O=function(e,t,n){for(var r,o=new Map,a=0,i=Array.from(e);a<i.length;a++){var s=i[a],l=t.get(s);void 0!==l&&((f=o.get(l))||(f=[],o.set(l,f)),f.push(s))}for(var u=0,c=Array.from(o.values());u<c.length;u++){var f;(f=c[u]).sort(function(e,t){return Ye(e,t,n)})}for(var d=Array.from(e).filter(function(e){return!t.has(e)}).sort(function(e,t){return Ye(e,t,n)}),h=[],p=y([],d,!0);p.length>0;)s=p.shift(),h.push(s),p.push.apply(p,null!==(r=o.get(s))&&void 0!==r?r:[]);return h}(i,C,l),S=[],E=new Map,F=0,R=O;F<R.length;F++){w=R[F];var L=null!==(r=b.get(w))&&void 0!==r?r:qe(w,n);if(L){var I=C.get(w),P=void 0===I?-1:null!==(o=E.get(I))&&void 0!==o?o:-1,N=S.length;h=v(v({},L),{index:N,parentIndex:P,isCluster:a.has(w)}),S.push(h),E.set(w,N)}}var B=t.map(function(t){return function(e,t,n){var r=e.bones.map(function(e){var r=n.get(e.modelId);if(void 0===r&&e.isCluster)throw new Error("FBX rig resolver: cluster bone ".concat(e.name," is missing from resolved rig ").concat(t));return null!=r?r:-1});return{skinId:e.id,geometryId:e.geometryId,rigId:t,skinBoneIndexToRigBoneIndex:r,clusterModelIds:new Set(e.bones.filter(function(e){return e.isCluster}).map(function(e){return e.modelId}))}}(t,"rig_".concat(e.toString()),E)});return{id:"rig_".concat(e.toString()),rootModelIds:S.filter(function(e){return e.parentIndex<0}).map(function(e){return e.modelId}),bones:S,modelIdToBoneIndex:E,clusterModelIds:a,skinBindings:B,warnings:g}}(t[0],t[1],e)})}(t,p),_=function(e){for(var t=[],n=0,r=Array.from(e.objects);n<r.length;n++){var o=r[n],a=o[0],i=o[1];if("Deformer"===i.name&&"BlendShape"===ee(i,2)){var s=vt(a,0,e);s&&t.push(s)}}return t}(t),g=function(e){for(var t=[],n=0,r=Array.from(e.objects);n<r.length;n++){var o=r[n],a=o[0],i=o[1];if("AnimationStack"===i.name){var s=et(a,i,e);s&&t.push(s)}}return t}(t),b=function(e,t){for(var n,r,o,a,i=[],s=null!==(n=be(t,"NodeAttribute","FbxCamera"))&&void 0!==n?n:be(t,"NodeAttribute"),l=0,u=Array.from(e.objects);l<u.length;l++){var c=u[l],f=c[0],d=c[1];if("NodeAttribute"===d.name&&"Camera"===ee(d,2)){var h=e.parentOf.get(f);if(h){var p=e.objects.get(h.id);if(p&&"Model"===p.name){var m=te(null!==(r=ee(p,1))&&void 0!==r?r:"Camera"),v=Te(d,s,"NearPlane",.1),_=Te(d,s,"FarPlane",1e4),g=Rt(d,s),y=1===Te(d,s,"CameraProjectionType",0)||1===Te(d,s,"ProjectionType",0)?"orthographic":"perspective",b=Et(xe(d,s,"FocalLength")),x=null!==(o=Et(xe(d,s,"FilmWidth")))&&void 0!==o?o:Et(xe(d,s,"ApertureWidth")),T=null!==(a=Et(xe(d,s,"FilmHeight")))&&void 0!==a?a:Et(xe(d,s,"ApertureHeight")),A=Et(xe(d,s,"OrthoZoom")),w=Et(xe(d,s,"Roll")),M=Lt(d,s,g,b,T),C=[];"orthographic"===y&&void 0===A&&C.push("Orthographic camera has no OrthoZoom; runtime orthographic bounds use a fallback."),void 0!==b&&void 0===T&&void 0===xe(d,s,"FieldOfView")&&C.push("FocalLength is present without FilmHeight; default field of view fallback may be used."),i.push({modelId:h.id,name:m,fieldOfView:M,nearPlane:v,farPlane:_,aspectRatio:g,projectionType:y,focalLength:b,filmWidth:x,filmHeight:T,orthoZoom:A,roll:w,unknownProperties:It(d,Ot),diagnostics:C})}}}}return i}(t,n),x=function(e,t){for(var n,r,o,a,i,s=[],l=null!==(n=be(t,"NodeAttribute","FbxLight"))&&void 0!==n?n:be(t,"NodeAttribute"),u=0,c=Array.from(e.objects);u<c.length;u++){var f=c[u],d=f[0],h=f[1];if("NodeAttribute"===h.name&&"Light"===ee(h,2)){var p=e.parentOf.get(d);if(p){var m=e.objects.get(p.id);if(m&&"Model"===m.name){var v=te(null!==(r=ee(m,1))&&void 0!==r?r:"Light"),_=Te(h,l,"LightType",0),g=Ae(h,l,"Color",[1,1,1]),y=Te(h,l,"Intensity",100)/100,b=null!==(o=Et(xe(h,l,"OuterAngle")))&&void 0!==o?o:Et(xe(h,l,"ConeAngle")),x=Et(xe(h,l,"InnerAngle")),T=null!=b?b:45,A=Te(h,l,"DecayType",2),w=Et(xe(h,l,"DecayStart")),M=Ft(xe(h,l,"EnableNearAttenuation")),C=Ft(xe(h,l,"EnableFarAttenuation")),O=null!==(i=null!==(a=Ft(xe(h,l,"CastShadow")))&&void 0!==a?a:Ft(xe(m,void 0,"CastShadow")))&&void 0!==i?i:Ft(xe(m,void 0,"Shadow")),S=[];2!==A&&S.push("DecayType ".concat(A," is preserved as metadata; Babylon falloff is not remapped in this pass.")),void 0!==w&&S.push("DecayStart is preserved as metadata and is not mapped to Babylon light range."),s.push({modelId:p.id,name:v,lightType:_,color:g,intensity:y,coneAngle:T,decayType:A,innerAngle:x,outerAngle:b,decayStart:w,enableNearAttenuation:M,enableFarAttenuation:C,castShadows:O,unknownProperties:It(h,St),diagnostics:S})}}}}return s}(t,n),T=function(e){for(var t,n,r=e.diagnostics.map(function(t){return{type:"connection-graph",message:t.message,objectId:t.childId,subType:t.reason,parentCount:void 0===t.childId?void 0:e.connections.filter(function(e){return e.childId===t.childId}).length}}),o=0,a=Array.from(e.objects);o<a.length;o++){var i=a[o],s=i[0],l=i[1],u=null!==(t=ee(l,2))&&void 0!==t?t:"";"Constraint"!==l.name?xt.has(l.name)?r.push(At(e,s,l,"unsupported-helper","".concat(l.name," helper data is preserved as diagnostic data but not evaluated at runtime."))):"LayeredTexture"!==l.name?"Pose"!==l.name||"BindPose"===u?"Deformer"!==l.name||Tt(u)?"NodeAttribute"===l.name&&u&&"Camera"!==u&&"Light"!==u&&r.push(At(e,s,l,"unsupported-node-attribute","NodeAttribute subtype '".concat(u,"' is preserved as diagnostic data but not converted to a Babylon object."))):r.push(At(e,s,l,"unsupported-deformer","Deformer subtype '".concat(u,"' is preserved as diagnostic data but not evaluated at runtime."))):r.push(At(e,s,l,"unsupported-pose","Pose subtype '".concat(u,"' is preserved as diagnostic data but not evaluated at runtime."))):r.push(At(e,s,l,"unsupported-layered-texture","LayeredTexture is preserved as diagnostic data; runtime texture layer blending is not implemented.")):r.push(At(e,s,l,"unsupported-constraint","Constraint '".concat(u||te(null!==(n=ee(l,1))&&void 0!==n?n:""),"' is preserved as diagnostic data but not evaluated at runtime.")))}return r}(t),A=function(e,t,n,r){for(var o,a=new Map,i=0,s=t;i<s.length;i++){var l=s[i];a.set(l.id,l)}for(var u=new Map,c=0,f=n;c<f.length;c++){var d=f[c];u.set(d.id,d)}for(var h=[],p=0,m=null!==(o=e.childrenOf.get(0))&&void 0!==o?o:[];p<m.length;p++){var v=m[p].id,_=e.objects.get(v);_&&"Model"===_.name&&h.push(Mt(v,_,e,a,u,r))}return h}(t,u,o,n);return v({rootModels:A,geometries:u,materials:o,skins:p,rigs:m,blendShapes:_,animations:g,cameras:b,lights:x,diagnostics:T},r)}function Mt(e,t,n,r,o,a){for(var i,s,l,u=te(null!==(i=ee(t,1))&&void 0!==i?i:"Model"),c=null!==(s=ee(t,2))&&void 0!==s?s:"Null",f=ne(n,e,"Geometry"),d=f.length>0?r.get(f[0].id):void 0,h=[],p=0,m=ne(n,e,"Material");p<m.length;p++){var _=m[p].id,g=o.get(_);g&&h.push(g)}for(var y=function(e,t){var n=Ae(e,t,"Lcl Translation",[0,0,0]),r=Ae(e,t,"Lcl Rotation",[0,0,0]),o=Ae(e,t,"Lcl Scaling",[1,1,1]),a=Ae(e,t,"PreRotation",[0,0,0]),i=Ae(e,t,"PostRotation",[0,0,0]),s=Ae(e,t,"RotationPivot",[0,0,0]),l=Ae(e,t,"ScalingPivot",[0,0,0]),u=Ae(e,t,"RotationOffset",[0,0,0]),c=Ae(e,t,"ScalingOffset",[0,0,0]),f=Ae(e,t,"GeometricTranslation",[0,0,0]),d=Ae(e,t,"GeometricRotation",[0,0,0]),h=Ae(e,t,"GeometricScaling",[1,1,1]),p=Te(e,t,"RotationOrder",0),m=Te(e,t,"InheritType",1);return{translation:n,rotation:r,scale:o,preRotation:a,postRotation:i,rotationPivot:s,scalingPivot:l,rotationOffset:u,scalingOffset:c,geometricTranslation:f,geometricRotation:d,geometricScaling:h,rotationOrder:p,inheritType:m,diagnostics:1!==m&&2!==m?["InheritType ".concat(m," is parsed and preserved; runtime parent-scale inheritance remains gated to avoid changing existing visual behavior without a fixture-specific baseline.")]:[]}}(t,null!==(l=be(a,"Model","FbxNode"))&&void 0!==l?l:be(a,"Model")),b=[],x=0,T=ne(n,e,"Model");x<T.length;x++){var A=T[x],w=(_=A.id,A.node);b.push(Mt(_,w,n,r,o,a))}var M=t.children.find(function(e){return"Culling"===e.name}),C=!!M&&"CullingOff"===ee(M,0),O=function(e){var t,n=J(e,"Properties70");if(n){for(var r={},o=!1,a=0,i=n.children;a<i.length;a++){var s=i[a];if("P"===s.name){var l=ee(s,0);if(l&&!Ct.has(l)){var u=null===(t=s.properties[4])||void 0===t?void 0:t.value;void 0!==u&&("string"==typeof u||"number"==typeof u||"boolean"==typeof u)&&(r[l]=u,o=!0)}}}return o?r:void 0}}(t);return v({id:e,name:u,subType:c,geometry:d,materials:h,children:b,cullingOff:C,customProperties:O},y)}var Ct=new Set(["Lcl Translation","Lcl Rotation","Lcl Scaling","PreRotation","PostRotation","RotationPivot","ScalingPivot","RotationOffset","ScalingOffset","RotationOrder","GeometricTranslation","GeometricRotation","GeometricScaling","Visibility","InheritType","ScalingMax","DefaultAttributeIndex","currentUVSet","lockInfluenceWeights"]),Ot=new Set(["FieldOfView","FieldOfViewX","FieldOfViewY","NearPlane","FarPlane","AspectWidth","AspectHeight","FilmAspectRatio","FocalLength","FilmWidth","FilmHeight","ApertureWidth","ApertureHeight","CameraProjectionType","ProjectionType","OrthoZoom","Roll","ApertureMode"]),St=new Set(["LightType","Color","Intensity","InnerAngle","OuterAngle","ConeAngle","DecayType","DecayStart","EnableNearAttenuation","EnableFarAttenuation","CastShadow","Shadow"]);function Et(e){if("number"==typeof e)return e}function Ft(e){return"boolean"==typeof e?e:"number"==typeof e?0!==e:void 0}function Rt(e,t){var n=Et(xe(e,t,"FilmAspectRatio"));if(void 0!==n&&n>0)return n;var r=Et(xe(e,t,"AspectWidth")),o=Et(xe(e,t,"AspectHeight"));return void 0!==r&&void 0!==o&&r>0&&o>0?r/o:0}function Lt(e,t,n,r,o){var a,i=null!==(a=Et(xe(e,t,"FieldOfViewY")))&&void 0!==a?a:Et(xe(e,t,"FieldOfView"));if(void 0!==i)return i;var s=Et(xe(e,t,"FieldOfViewX"));return void 0!==s?n>0?Pt(2*Math.atan(Math.tan(s*Math.PI/180/2)/n)):s:void 0!==r&&r>0&&void 0!==o&&o>0?Pt(2*Math.atan(25.4*o/(2*r))):45}function It(e,t){for(var n,r=new Set,o=0,a=["Properties70","Properties60"];o<a.length;o++)for(var i=J(e,a[o]),s=0,l=null!==(n=null==i?void 0:i.children)&&void 0!==n?n:[];s<l.length;s++){var u=l[s];if("P"===u.name||"Property"===u.name){var c=ee(u,0);c&&!t.has(c)&&r.add(c)}}return Array.from(r).sort()}function Pt(e){return 180*e/Math.PI}function Nt(e,n,r){var o=t.Matrix.RotationX(e),a=t.Matrix.RotationY(n),i=t.Matrix.RotationZ(r);return o.multiply(a).multiply(i)}function Bt(e,n,r,o){var a=t.Matrix.RotationX(e),i=t.Matrix.RotationY(n),s=t.Matrix.RotationZ(r);switch(o){case 0:default:return a.multiply(i).multiply(s);case 1:return a.multiply(s).multiply(i);case 2:return i.multiply(s).multiply(a);case 3:return i.multiply(a).multiply(s);case 4:return s.multiply(a).multiply(i);case 5:return s.multiply(i).multiply(a)}}function kt(e,n){var r=Math.PI/180,o=t.Matrix.Scaling(n[0],n[1],n[2]),a=Nt(e[0]*r,e[1]*r,e[2]*r);return o.multiply(a)}var Dt={name:"fbx",extensions:{".fbx":{isBinary:!0}}},Gt=function(){function e(e){var t;void 0===e&&(e={}),this.name=Dt.name,this.extensions=Dt.extensions,this._bindRestBones=new WeakSet,this._sourceBonesBySkeleton=new WeakMap,this._scaleCompensationHelpersBySkeleton=new WeakMap,this._options={normalMapCoordinateSystem:null!==(t=e.normalMapCoordinateSystem)&&void 0!==t?t:"y-up"}}return e.prototype.createPlugin=function(t){return new e(t[Dt.name])},e.prototype.importMeshAsync=function(e,t,n,r,o,a){return _(this,void 0,void 0,function(){var o,a;return g(this,function(i){return o=this._parse(n),a=wt(o),[2,this._buildScene(a,t,r,e)]})})},e.prototype.loadAsync=function(e,t,n,r,o){return _(this,void 0,void 0,function(){var r,o;return g(this,function(a){return r=this._parse(t),o=wt(r),this._buildScene(o,e,n,null),[2]})})},e.prototype.loadAssetContainerAsync=function(e,n,r,o,a){return _(this,void 0,void 0,function(){var o,a,i,s,l,u,c,f,d,h,p,m,v,_,y,b,x,T,A,w,M,C,O,S,E,F,R,L,I,P;return g(this,function(g){for(o=this._parse(n),a=wt(o),i=new t.AssetContainer(e),s=this._buildScene(a,e,r,null),l=0,u=s.meshes;l<u.length;l++)P=u[l],i.meshes.push(P);for(c=0,f=s.skeletons;c<f.length;c++)d=f[c],i.skeletons.push(d);for(h=0,p=s.animationGroups;h<p.length;h++)m=p[h],i.animationGroups.push(m);for(v=0,_=s.transformNodes;v<_.length;v++)y=_[v],i.transformNodes.push(y);for(b=0,x=s.lights;b<x.length;b++)T=x[b],i.lights.push(T);for(A=0,w=s.cameras;A<w.length;A++)M=w[A],i.cameras.push(M);for(C=0,O=s.materials;C<O.length;C++)S=O[C],this._addMaterialToContainer(S,i);for(E=0,F=s.textures;E<F.length;E++)R=F[E],this._addTextureToContainer(R,i);for(L=0,I=s.meshes;L<I.length;L++)P=I[L],this._addMaterialToContainer(P.material,i);return this._setAssetContainer(i),i.removeAllFromScene(),[2,i]})})},e.prototype._parse=function(e){if(e instanceof ArrayBuffer)return this._parseFromArrayBuffer(e);if(ArrayBuffer.isView(e)){var t=e,n=t.buffer.slice(t.byteOffset,t.byteOffset+t.byteLength);return this._parseFromArrayBuffer(n)}if("string"==typeof e)return q(e);throw new Error("FBXFileLoader: unsupported data type")},e.prototype._parseFromArrayBuffer=function(e){var t=new Uint8Array(e,0,Math.min(21,e.byteLength));if(String.fromCharCode.apply(String,t).startsWith("Kaydara FBX Binary"))return function(e){var t=new DataView(e),n=new Uint8Array(e);if("Kaydara FBX Binary \0"!==z(n,0,21))throw new Error("Not a valid binary FBX file");if(e.byteLength<27)throw new Error("Truncated binary FBX header");for(var r=t.getUint32(23,!0),o=r>=7500,a=[],i=27;i<e.byteLength;){var s=V(t,n,i,o,e.byteLength);if(null===s)break;a.push(s.node),i=s.endOffset}return{version:r,nodes:a}}(e);var n=new TextDecoder("utf-8").decode(e);if(n.trimStart().startsWith("; FBX"))return q(n);throw new Error("FBXFileLoader: unrecognized FBX format")},e.prototype._buildScene=function(n,r,o,a){for(var i,s=this._buildNameFilter(a),l=new Map,u=0,c=n.materials;u<c.length;u++){var f=c[u],d=this._createMaterial(f,r,o);l.set(f.id,d)}for(var h=[],p=new Map,m=new Map,v=new Map,_=new Map,g=new Map,b=0,x=n.skins;b<x.length;b++){var T=x[b];g.set(T.id,T)}for(var A=0,w=n.rigs;A<w.length;A++){var M=w[A],C=this._createSkeleton(M.id,M.bones,r);h.push(C),p.set(M.id,C);for(var O=0,S=M.skinBindings;O<S.length;O++){var E=S[O];(T=g.get(E.skinId))&&(m.set(E.geometryId,C),v.set(E.geometryId,T),_.set(E.geometryId,E))}}var F=new Map,R=function(e){for(var t=0,n=e;t<n.length;t++){var r=n[t];F.set(r.id,r),R(r.children)}};R(n.rootModels);var L=e._collectCullingConflictMaterialIds(n.rootModels),I=new Map,P=new t.TransformNode("__fbx_root__",r);r.useRightHandedSystem||(P.rotation.y=Math.PI,P.scaling.z=-1);var N=[],B=[P],k=P,D=e._computeFBXAxisConversionMatrix(n);D.equals(t.Matrix.Identity())||((k=new t.TransformNode("__fbx_axis_conversion__",r)).parent=P,e._applyMatrixToTransform(k,D),B.push(k));for(var G=new Map,V=t.Matrix.Identity(),H=0,U=n.rootModels;H<U.length;H++){var j=U[H];this._buildModel(j,r,k,k,V,l,s,N,B,m,v,_,G,L,I)}for(var K=function(n){var r=p.get(n.id);if(!r)return"continue";for(var o=new Set(n.bones.map(function(e){return e.modelId})),a=null!==(i=N.find(function(e){return e.skeleton===r}))&&void 0!==i?i:null,s=null!=a?a:P,l=0,u=n.bones;l<u.length;l++){var c=u[l];if(c.isCluster){var f=G.get(c.modelId),d=W._getSourceBone(r,c.index);if(f&&d)for(var h=0,m=y([],f.getChildren(),!0);h<m.length;h++){for(var v=m[h],_=!1,g=0,b=Array.from(G);g<b.length;g++){var x=b[g],T=x[0];if(x[1]===v&&o.has(T)){_=!0;break}}if(!_){var A=v.computeWorldMatrix(!0).clone(),w=e._getBoneReferenceWorldMatrix(r,d,s,a),M=new t.Matrix;w.invertToRef(M);var C=A.multiply(M);v.parent=null,v.attachToBone(d,s),e._applyMatrixToTransform(v,C)}}}}},W=this,z=0,q=n.rigs;z<q.length;z++)K(M=q[z]);n.blendShapes.length>0&&this._applyBlendShapes(n.blendShapes,N,r);for(var X=[],Y=0,Q=n.animations;Y<Q.length;Y++){var Z=Q[Y],J=this._createAnimationGroup(Z,n.rigs,p,r,G,F,N);J&&X.push(J)}for(var $=[],ee=0,te=n.cameras;ee<te.length;ee++){var ne=te[ee],re=this._createCamera(ne,G,r);re&&$.push(re)}for(var oe=[],ae=0,ie=n.lights;ae<ie.length;ae++){var se=ie[ae],le=this._createLight(se,G,r);le&&oe.push(le)}return{meshes:N,particleSystems:[],skeletons:h,animationGroups:X,transformNodes:B,geometries:[],lights:oe,spriteManagers:[],materials:Array.from(l.values()),textures:Array.from(new Set(Array.from(l.values()).flatMap(function(e){return e.getActiveTextures()}))),cameras:$}},e.prototype._addMaterialToContainer=function(e,n){if(e){if(e instanceof t.MultiMaterial){n.multiMaterials.includes(e)||n.multiMaterials.push(e);for(var r=0,o=e.subMaterials;r<o.length;r++){var a=o[r];this._addMaterialToContainer(a,n)}}else n.materials.includes(e)||n.materials.push(e);for(var i=0,s=e.getActiveTextures();i<s.length;i++){var l=s[i];this._addTextureToContainer(l,n)}}},e.prototype._addTextureToContainer=function(e,t){t.textures.includes(e)||t.textures.push(e)},e.prototype._setAssetContainer=function(e){for(var t=0,n=e.meshes;t<n.length;t++)n[t]._parentContainer=e;for(var r=0,o=e.transformNodes;r<o.length;r++)o[r]._parentContainer=e;for(var a=0,i=e.skeletons;a<i.length;a++)i[a]._parentContainer=e;for(var s=0,l=e.animationGroups;s<l.length;s++)l[s]._parentContainer=e;for(var u=0,c=e.lights;u<c.length;u++)c[u]._parentContainer=e;for(var f=0,d=e.cameras;f<d.length;f++)d[f]._parentContainer=e;for(var h=0,p=e.materials;h<p.length;h++)p[h]._parentContainer=e;for(var m=0,v=e.multiMaterials;m<v.length;m++)v[m]._parentContainer=e;for(var _=0,g=e.textures;_<g.length;_++)g[_]._parentContainer=e},e._computeFBXAxisConversionMatrix=function(e){var n=[[0,0,0],[0,0,0],[0,0,0]],r=function(e,t,r){if(!(e<0||e>2)){var o=[0,0,0];o[r]=t>=0?1:-1,n[e]=o}};return r(e.coordAxis,e.coordAxisSign,0),r(e.upAxis,e.upAxisSign,1),r(e.frontAxis,e.frontAxisSign,2),n.some(function(e){return e.every(function(e){return 0===e})})?t.Matrix.Identity():t.Matrix.FromValues(n[0][0],n[0][1],n[0][2],0,n[1][0],n[1][1],n[1][2],0,n[2][0],n[2][1],n[2][2],0,0,0,0,1)},e.prototype._buildModel=function(n,r,o,a,i,s,l,u,c,f,d,h,p,m,v){var _,g,y=e._computeFBXModelLocalMatrix(n).multiply(i);if(!n.geometry||"Mesh"!==n.subType||l&&!l(n.name)){if(n.geometry&&"Mesh"===n.subType&&l&&!e._modelSubtreeMatchesNameFilter(n,l))return;var b=new t.TransformNode(n.name,r);o&&(b.parent=o),e._applyFBXTransform(b,n),c.push(b),p.set(n.id,b),e._applyModelMetadata(b,n);for(var x=0,T=n.children;x<T.length;x++)R=T[x],this._buildModel(R,r,b,a,y,s,l,u,c,f,d,h,p,m,v)}else{var A=f.get(n.geometry.id),w=d.get(n.geometry.id),M=h.get(n.geometry.id);A&&w&&(A.needInitialSkinMatrix=!0);var C=this._createMesh(n,n.geometry,r,A,w,M);if(A&&w){var O=w.meshBindPoseMatrix?t.Matrix.FromArray(w.meshBindPoseMatrix):y;C.parent=a,e._applyMatrixToTransform(C,O),C.computeWorldMatrix(!0),C.updatePoseMatrix(t.Matrix.Invert(O)),C.alwaysSelectAsActiveMesh=!0}else o&&(C.parent=o),e._applyFBXTransform(C,n);if(n.materials.length>1&&(null===(_=n.geometry)||void 0===_?void 0:_.materialIndices))this._applyMultiMaterial(C,n,s,r,m,v);else if(n.materials.length>0){var S=s.get(n.materials[0].id);S&&(C.material=e._getModelMaterial(S,n,v,m.has(n.materials[0].id)))}(null===(g=n.geometry)||void 0===g?void 0:g.colors)&&this._useUnmodulatedVertexColorMaterials(C,r),this._applyMaterialUVSetCoordinates(C.material,n.geometry),u.push(C),p.set(n.id,C),e._applyModelMetadata(C,n);for(var E=0,F=n.children;E<F.length;E++){var R=F[E];this._buildModel(R,r,C,a,y,s,l,u,c,f,d,h,p,m,v)}}},e._modelSubtreeMatchesNameFilter=function(t,n){for(var r=0,o=t.children;r<o.length;r++){var a=o[r];if(a.geometry&&"Mesh"===a.subType&&n(a.name))return!0;if(e._modelSubtreeMatchesNameFilter(a,n))return!0}return!1},e._applyModelMetadata=function(e,t){var n;(t.customProperties||0!==t.diagnostics.length)&&(e.metadata=v(v(v({},null!==(n=e.metadata)&&void 0!==n?n:{}),t.customProperties?{fbxCustomProperties:t.customProperties}:{}),t.diagnostics.length>0?{fbxDiagnostics:t.diagnostics}:{}))},e.prototype._createMesh=function(n,r,o,a,i,s){var l,u=new t.Mesh(n.name,o);u.sideOrientation=o.useRightHandedSystem?t.Material.CounterClockWiseSideOrientation:t.Material.ClockWiseSideOrientation;var c,f=new t.VertexData,d=Vt(r.positions),h=n.geometricTranslation,p=n.geometricRotation,m=n.geometricScaling,_=e._computeFBXGeometricMatrix(h,p,m),g=e._computeFBXGeometricDeltaMatrix(p,m),y=e._computeFBXGeometricNormalMatrix(p,m),b=!_.equals(t.Matrix.Identity()),x=!g.equals(t.Matrix.Identity()),T=!y.equals(t.Matrix.Identity());if(b)for(var A=0;A<d.length;A+=3){var w=t.Vector3.TransformCoordinates(new t.Vector3(d[A],d[A+1],d[A+2]),_);d[A]=w.x,d[A+1]=w.y,d[A+2]=w.z}if(f.positions=d,f.indices=Array.from(r.indices),r.normals){if(c=Vt(r.normals),T)for(A=0;A<c.length;A+=3){var M=t.Vector3.TransformNormal(new t.Vector3(c[A],c[A+1],c[A+2]),y);M.lengthSquared()>0&&M.normalize(),c[A]=M.x,c[A+1]=M.y,c[A+2]=M.z}f.normals=c}if(r.uvs&&(f.uvs=Vt(r.uvs)),r.uvSets.length>1&&(f.uvs2=Vt(r.uvSets[1].data)),r.uvSets.length>2&&(f.uvs3=Vt(r.uvSets[2].data)),r.uvSets.length>3&&(f.uvs4=Vt(r.uvSets[3].data)),r.uvSets.length>4&&(f.uvs5=Vt(r.uvSets[4].data)),r.uvSets.length>5&&(f.uvs6=Vt(r.uvSets[5].data)),r.tangents){var C=Vt(r.tangents);if(T)for(A=0;A<C.length;A+=4){var O=t.Vector3.TransformNormal(new t.Vector3(C[A],C[A+1],C[A+2]),y);O.lengthSquared()>0&&O.normalize(),C[A]=O.x,C[A+1]=O.y,C[A+2]=O.z}!function(e,t){if(1!==t)for(var n=3;n<e.length;n+=4)e[n]*=t}(C,this._getNormalMapTangentHandednessScale()),f.tangents=C}else c&&f.uvs&&(f.tangents=function(e,t,n,r,o,a,i){var s,l,u,c,f,d,h;void 0===o&&(o=1),void 0===a&&(a=null),void 0===i&&(i=null);for(var p=e.length/3,m=new Map,v=new Array(p).fill(null),_=0;_+2<r.length;_+=3){var g=i?i[_/3]:0,y=r[_],b=r[_+1],x=r[_+2],T=3*y,A=3*b,w=3*x,M=2*y,C=2*b,O=2*x,S=e[A]-e[T],E=e[w]-e[T],F=e[A+1]-e[T+1],R=e[w+1]-e[T+1],L=e[A+2]-e[T+2],I=e[w+2]-e[T+2],P=n[C]-n[M],N=n[O]-n[M],B=n[C+1]-n[M+1],k=n[O+1]-n[M+1],D=P*k-N*B;if(!(Math.abs(D)<1e-8)){var G=1/D,V=(k*S-B*E)*G,H=(k*F-B*R)*G,U=(k*L-B*I)*G;Ht(y,b,x,V,H,U,ae=(P*E-N*S)*G,ie=(P*R-N*F)*G,se=(P*I-N*L)*G,e,t,n,a,g,m,v),Ht(b,x,y,V,H,U,ae,ie,se,e,t,n,a,g,m,v),Ht(x,y,b,V,H,U,ae,ie,se,e,t,n,a,g,m,v)}}var j=new Float32Array(4*p);for(_=0;_<p;_++){var K=3*_,W=4*_,z=Ut(t[K],t[K+1],t[K+2]),q=z[0],X=z[1],Y=z[2],Q=v[_]?m.get(v[_]):void 0,Z=null!==(l=null==Q?void 0:Q.tx)&&void 0!==l?l:0,J=null!==(u=null==Q?void 0:Q.ty)&&void 0!==u?u:0,$=null!==(c=null==Q?void 0:Q.tz)&&void 0!==c?c:0,ee=q*Z+X*J+Y*$,te=Z-q*ee,ne=J-X*ee,re=$-Y*ee,oe=Math.hypot(te,ne,re);oe>1e-8?(te/=oe,ne/=oe,re/=oe):(te=(s=Kt(q,X,Y))[0],ne=s[1],re=s[2]);var ae=null!==(f=null==Q?void 0:Q.bx)&&void 0!==f?f:0,ie=null!==(d=null==Q?void 0:Q.by)&&void 0!==d?d:0,se=null!==(h=null==Q?void 0:Q.bz)&&void 0!==h?h:0,le=X*re-Y*ne,ue=Y*te-q*re,ce=q*ne-X*te,fe=Math.hypot(ae,ie,se)>1e-8&&le*ae+ue*ie+ce*se<0?-1:1;j[W]=te,j[W+1]=ne,j[W+2]=re,j[W+3]=fe*o}return j}(d,c,f.uvs,r.indices,this._getNormalMapTangentHandednessScale(),r.controlPointIndices,r.materialIndices));if(r.colors){var S=new Float32Array(r.colors.length);for(A=0;A<S.length;A+=4)S[A]=r.colors[A],S[A+1]=r.colors[A+1],S[A+2]=r.colors[A+2],S[A+3]=1;f.colors=S,u.hasVertexAlpha=!1}if(a&&i){var E=this._buildSkinningData(r,i,s),F=E.matricesIndices,R=E.matricesWeights,L=E.matricesIndicesExtra,I=E.matricesWeightsExtra,P=E.numBoneInfluencers;f.matricesIndices=F,f.matricesWeights=R,L&&I&&(f.matricesIndicesExtra=L,f.matricesWeightsExtra=I),u.numBoneInfluencers=P}return f.applyToMesh(u),u.metadata=v(v({},null!==(l=u.metadata)&&void 0!==l?l:{}),{fbxGeometryId:r.id,fbxControlPointIndices:r.controlPointIndices,fbxGeometryDeltaMatrix:x?g:null,fbxGeometryNormalMatrix:T?y:null,fbxPreRotMatrix:x?g:null}),a&&(u.skeleton=a),u},e.prototype._applyMultiMaterial=function(n,r,o,a,i,s){var l=r.geometry.materialIndices,u=n.getIndices();if(u){for(var c=u.length/3,f=new Map,d=0;d<c;d++){var h=d<l.length?l[d]:0,p=f.get(h);p||(p=[],f.set(h,p)),p.push(d)}for(var m=[],v=[],_=0,g=Array.from(f.keys()).sort(function(e,t){return e-t});_<g.length;_++){h=g[_];for(var y=f.get(h),b=m.length,x=0,T=y;x<T.length;x++)d=T[x],m.push(u[3*d],u[3*d+1],u[3*d+2]);v.push({start:b,count:3*y.length,matIdx:h})}n.setIndices(m);for(var A=new t.MultiMaterial(r.name+"_multi",a),w=0,M=v;w<M.length;w++){var C=M[w],O=r.materials[C.matIdx];if(O){var S=o.get(O.id);S?A.subMaterials.push(e._getModelMaterial(S,r,s,i.has(O.id))):A.subMaterials.push(null)}else A.subMaterials.push(null)}n.material=A,n.subMeshes=[];for(var E=n.getTotalVertices(),F=0;F<v.length;F++)C=v[F],new t.SubMesh(F,0,E,C.start,C.count,n)}},e._collectCullingConflictMaterialIds=function(e){for(var t=new Map,n=function(e){for(var r,o=0,a=e.materials;o<a.length;o++){var i=a[o],s=null!==(r=t.get(i.id))&&void 0!==r?r:{cullingOff:!1,cullingOn:!1};e.cullingOff?s.cullingOff=!0:s.cullingOn=!0,t.set(i.id,s)}for(var l=0,u=e.children;l<u.length;l++){var c=u[l];n(c)}},r=0,o=e;r<o.length;r++){var a=o[r];n(a)}for(var i=new Set,s=0,l=Array.from(t);s<l.length;s++){var u=l[s],c=u[0],f=u[1];f.cullingOff&&f.cullingOn&&i.add(c)}return i},e._getModelMaterial=function(e,t,n,r){if(void 0===r&&(r=!0),!t.cullingOff||!e.backFaceCulling)return e;if(!r)return e.backFaceCulling=!1,e;var o=null==n?void 0:n.get(e);if(o)return o;var a=e.clone("".concat(e.name,"_CullingOff"));return a.backFaceCulling=!1,null==n||n.set(e,a),a},e.prototype._applyMaterialUVSetCoordinates=function(e,n){if(e)if(e instanceof t.MultiMaterial)for(var r=0,o=e.subMaterials;r<o.length;r++){var a=o[r];a instanceof t.StandardMaterial&&this._applyStandardMaterialUVSetCoordinates(a,n)}else e instanceof t.StandardMaterial&&this._applyStandardMaterialUVSetCoordinates(e,n)},e.prototype._applyStandardMaterialUVSetCoordinates=function(e,t){for(var n,r=function(e){if(!e)return"continue";var r=null===(n=e.metadata)||void 0===n?void 0:n.fbxUVSetName;if(!r)return"continue";var o=t.uvSets.findIndex(function(e){return e.name===r});o>=0&&(e.coordinatesIndex=o)},o=0,a=[e.diffuseTexture,e.bumpTexture,e.emissiveTexture,e.ambientTexture,e.specularTexture,e.opacityTexture,e.reflectionTexture];o<a.length;o++)r(a[o])},e.prototype._useUnmodulatedVertexColorMaterials=function(e,n){var r=e.material;if(r)if(r instanceof t.StandardMaterial){if(!r.diffuseTexture){var o=r.clone("".concat(r.name,"_VertexColor"));o.diffuseColor=new t.Color3(1,1,1),e.material=o}}else if(r instanceof t.MultiMaterial){var a=new t.MultiMaterial("".concat(r.name,"_VertexColor"),n);a.subMaterials=r.subMaterials.map(function(e){if(e instanceof t.StandardMaterial&&!e.diffuseTexture){var n=e.clone("".concat(e.name,"_VertexColor"));return n.diffuseColor=new t.Color3(1,1,1),n}return e}),e.material=a}},e.prototype._buildSkinningData=function(e,t,n){var r,o,a,i=e.positions.length/3,s=new Float32Array(4*i),l=new Float32Array(4*i),u=null,c=null,f=0;if(e.controlPointIndices){for(var d=0;d<i;d++){var h=e.controlPointIndices[d],p=null!==(r=t.boneIndices[h])&&void 0!==r?r:[];f=Math.max(f,Math.min(p.length,8))}for(f>4&&(u=new Float32Array(4*i),c=new Float32Array(4*i)),d=0;d<i;d++){h=e.controlPointIndices[d],p=null!==(o=t.boneIndices[h])&&void 0!==o?o:[];for(var m=null!==(a=t.boneWeights[h])&&void 0!==a?a:[],v=0;v<8;v++){var _=v<4?s:u,g=v<4?l:c;if(_&&g){var y=4*d+v%4;if(v<p.length){var b=p[v],x=n?n.skinBoneIndexToRigBoneIndex[b]:b;if(void 0===x||x<0)throw new Error("FBXFileLoader: missing rig bone mapping for skin bone index ".concat(b));_[y]=x}else _[y]=0;g[y]=v<m.length?m[v]:0}}}}return{matricesIndices:s,matricesWeights:l,matricesIndicesExtra:u,matricesWeightsExtra:c,numBoneInfluencers:Math.max(f,1)}},e.prototype._createMaterial=function(n,r,o){var a,i,s,l,u,c=new t.StandardMaterial(n.name,r),f=n.properties,d=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return n.textures.some(function(t){return e.includes(t.propertyName)})};if("Lambert"===n.type&&(c.specularColor=t.Color3.Black()),f.diffuseColor){var h=d("DiffuseColor","Diffuse")?1:null!==(a=f.diffuseFactor)&&void 0!==a?a:1;c.diffuseColor=new t.Color3(f.diffuseColor[0]*h,f.diffuseColor[1]*h,f.diffuseColor[2]*h)}if(f.ambientColor){var p=d("AmbientColor","Ambient")?1:null!==(i=f.ambientFactor)&&void 0!==i?i:1;c.ambientColor=new t.Color3(f.ambientColor[0]*p,f.ambientColor[1]*p,f.ambientColor[2]*p)}if("Phong"===n.type&&f.specularColor){var m=d("SpecularColor","Specular","Shininess","ShininessExponent")?1:null!==(s=f.specularFactor)&&void 0!==s?s:1;c.specularColor=new t.Color3(f.specularColor[0]*m,f.specularColor[1]*m,f.specularColor[2]*m)}if(f.emissiveColor){var _=d("EmissiveColor","Emissive")?1:null!==(l=f.emissiveFactor)&&void 0!==l?l:1;c.emissiveColor=new t.Color3(f.emissiveColor[0]*_,f.emissiveColor[1]*_,f.emissiveColor[2]*_)}void 0!==f.opacity?c.alpha=f.opacity:void 0!==f.transparencyFactor&&(c.alpha=1-f.transparencyFactor),c.alpha<1&&(c.transparencyMode=t.Material.MATERIAL_ALPHABLEND),void 0!==f.shininess&&(c.specularPower=f.shininess);for(var g=0,y=n.textures;g<y.length;g++){var b=y[g];if(e._isSupportedMaterialTextureSlot(b.propertyName)){var x=e._createTexture(b,r,o,e._isNormalMapTextureSlot(b.propertyName));if(x){switch(b.propertyName){case"DiffuseColor":c.diffuseTexture=x,c.diffuseColor=new t.Color3(1,1,1);break;case"NormalMap":case"NormalMapTexture":case"normalCamera":case"Bump":case"BumpFactor":c.bumpTexture=x,this._configureNormalTexture(x,c);break;case"EmissiveColor":c.emissiveTexture=x;break;case"AmbientColor":c.ambientTexture=x;break;case"SpecularColor":c.specularTexture=x;break;case"TransparencyFactor":case"TransparentColor":c.opacityTexture=x,c.transparencyMode=t.Material.MATERIAL_ALPHATESTANDBLEND;break;case"ReflectionColor":case"ReflectionFactor":c.reflectionTexture=x}b.uvTranslation&&(x.uOffset=b.uvTranslation[0],x.vOffset=b.uvTranslation[1]),b.uvScaling&&(x.uScale=b.uvScaling[0],x.vScale=b.uvScaling[1]),void 0!==b.uvRotation&&(x.wAng=b.uvRotation*(Math.PI/180)),void 0!==b.uvSetIndex&&(x.coordinatesIndex=b.uvSetIndex),b.uvSetName&&(x.metadata=v(v({},null!==(u=x.metadata)&&void 0!==u?u:{}),{fbxUVSetName:b.uvSetName}))}}}return c},e.prototype._configureNormalTexture=function(e,t){e.gammaSpace=!1,t.invertNormalMapX=!1,t.invertNormalMapY="y-down"===this._options.normalMapCoordinateSystem},e.prototype._getNormalMapTangentHandednessScale=function(){return"y-down"===this._options.normalMapCoordinateSystem?-1:1},e._isSupportedMaterialTextureSlot=function(e){switch(e){case"DiffuseColor":case"NormalMap":case"NormalMapTexture":case"normalCamera":case"Bump":case"BumpFactor":case"EmissiveColor":case"AmbientColor":case"SpecularColor":case"TransparencyFactor":case"TransparentColor":case"ReflectionColor":case"ReflectionFactor":case"DisplacementColor":case"Displacement":case"DisplacementFactor":case"ShininessExponent":case"Shininess":return!0;default:return!1}},e._isNormalMapTextureSlot=function(e){switch(e){case"NormalMap":case"NormalMapTexture":case"normalCamera":case"Bump":case"BumpFactor":return!0;default:return!1}},e._createTexture=function(n,r,o,a){var i=e._getTextureSourceName(n),s=e._getTextureCreationOptions(i,a,n.embeddedData);if(n.embeddedData){var l=new t.Texture(null,r,s),u=null!=i?i:"embeddedTexture_".concat(n.id.toString());return l.updateURL("data:fbx-embedded-texture/".concat(encodeURIComponent(u)),new Uint8Array(n.embeddedData),void 0,s.forcedExtension),l.name=u,l}var c=e._getExternalTextureUrls(n,o),f=c.shift();return f?e._createExternalTexture(f,c,r,s):null},e._createExternalTexture=function(n,r,o,a){r.push.apply(r,e._buildTextureFallbackUrls(n));var i=0,s=new t.Texture(n,o,v(v({},a),{onError:function(){var t=r[i++];t&&s.getScene()&&s.updateURL(t,null,void 0,e._getForcedExtension(t))}}));return s},e._buildTextureFallbackUrls=function(e){var t=Math.max(e.lastIndexOf("/"),e.lastIndexOf("\\")),n=e.lastIndexOf(".");if(n<=t)return[];var r=e.slice(0,n),o=e.slice(n+1).toLowerCase();return["png","jpg","jpeg","webp","bmp","tga"].filter(function(e){return e!==o}).map(function(e){return"".concat(r,".").concat(e)})},e._getTextureCreationOptions=function(t,n,r){var o=r?t?e._getMimeType(t):"image/png":void 0;return{buffer:r?new Uint8Array(r):void 0,forcedExtension:t?e._getForcedExtension(t,o):r?".png":void 0,gammaSpace:!n,mimeType:o}},e._getExternalTextureUrls=function(t,n){for(var r=[],o=0,a=[t.relativeFileName,t.fileName].filter(function(e){return!!e});o<a.length;o++){var i=a[o].replace(/\\/g,"/");e._isSafeRelativeTexturePath(i)&&r.push(n+i);var s=e._getTextureSourceNameFromPath(i);s&&r.push(n+s)}return Array.from(new Set(r))},e._getTextureSourceName=function(t){var n=t.relativeFileName||t.fileName;if(!n)return null;var r=n.replace(/\\/g,"/");return e._getTextureSourceNameFromPath(r)},e._getTextureSourceNameFromPath=function(e){var t;return null!==(t=e.split("/").pop())&&void 0!==t?t:e},e._isSafeRelativeTexturePath=function(e){return!(/^[a-zA-Z][a-zA-Z0-9+.-]*:/.test(e)||e.startsWith("/")||e.startsWith("//")||e.split("/").some(function(e){return".."===e}))},e._getForcedExtension=function(e,t){var n=Math.max(e.lastIndexOf("/"),e.lastIndexOf("\\")),r=e.lastIndexOf(".");if(r>n)return e.slice(r).toLowerCase();switch(t){case"image/png":return".png";case"image/jpeg":return".jpg";case"image/webp":return".webp";case"image/bmp":return".bmp";case"image/gif":return".gif";case"image/x-tga":return".tga";default:return}},e._getMimeType=function(n){var r=t.GetMimeType(n);if(r)return r;switch(e._getForcedExtension(n)){case".tga":return"image/x-tga";case".bmp":return"image/bmp";case".gif":return"image/gif";default:return"image/png"}},e.prototype._applyBlendShapes=function(e,n,r){for(var o,a,i,s,l,u,c,f,d=function(e){var d=n.find(function(t){var n;return(null===(n=t.metadata)||void 0===n?void 0:n.fbxGeometryId)===e.geometryId});if(!d)return"continue";var h=new t.MorphTargetManager(r);h.optimizeInfluencers=!1;for(var p=null!==(s=null!==(a=null===(o=d.metadata)||void 0===o?void 0:o.fbxGeometryDeltaMatrix)&&void 0!==a?a:null===(i=d.metadata)||void 0===i?void 0:i.fbxPreRotMatrix)&&void 0!==s?s:null,m=null!==(u=null===(l=d.metadata)||void 0===l?void 0:l.fbxGeometryNormalMatrix)&&void 0!==u?u:p,v=0,_=e.channels;v<_.length;v++){var g=_[v],y=null===(c=d.metadata)||void 0===c?void 0:c.fbxControlPointIndices;if(y){var b=d.getVerticesData("position"),x=d.getVerticesData("normal");if(b){for(var T=zt(g.deformPercent,g.fullWeights,g.shapes.length),A=[],w=0;w<g.shapes.length;w++){var M=g.shapes[w];if(M){var C=Wt(M,y,b,x,p,m);if(C){var O=g.fullWeights&&g.shapes.length>1?"".concat(g.name,"_").concat(g.fullWeights[w]):g.name,S=new t.MorphTarget(O,null!==(f=T[w])&&void 0!==f?f:0,r);S.setPositions(C.positions),C.normals&&S.setNormals(C.normals),A.push(h.numTargets),h.addTarget(S)}}}0!==A.length&&(d.metadata||(d.metadata={}),d.metadata.fbxBlendShapeChannelIds||(d.metadata.fbxBlendShapeChannelIds=new Map),d.metadata.fbxBlendShapeChannelIds.set(g.id,A[0]),d.metadata.fbxBlendShapeChannelTargets||(d.metadata.fbxBlendShapeChannelTargets=new Map),d.metadata.fbxBlendShapeChannelTargets.set(g.id,{targetIndices:A,fullWeights:g.fullWeights}))}}}h.numTargets>0&&(h.numMaxInfluencers=h.numTargets,d.morphTargetManager=h)},h=0,p=e;h<p.length;h++)d(p[h])},e.prototype._createCamera=function(e,n,r){var o,a=n.get(e.modelId),i=a?a.computeWorldMatrix(!0):t.Matrix.Identity(),s=t.Vector3.TransformCoordinates(t.Vector3.Zero(),i),l=new t.FreeCamera(e.name,s,r);if(l.fov=e.fieldOfView*(Math.PI/180),l.minZ=e.nearPlane,l.maxZ=e.farPlane,l.metadata=v(v({},null!==(o=l.metadata)&&void 0!==o?o:{}),{fbxCamera:{projectionType:e.projectionType,focalLength:e.focalLength,filmWidth:e.filmWidth,filmHeight:e.filmHeight,orthoZoom:e.orthoZoom,roll:e.roll,aspectRatio:e.aspectRatio,unknownProperties:e.unknownProperties,diagnostics:e.diagnostics}}),"orthographic"===e.projectionType){var u=e.orthoZoom&&e.orthoZoom>0?e.orthoZoom:1,c=e.aspectRatio>0?e.aspectRatio:1;l.mode=t.Camera.ORTHOGRAPHIC_CAMERA,l.orthoTop=u/2,l.orthoBottom=-u/2,l.orthoRight=u*c/2,l.orthoLeft=-u*c/2}var f=t.Vector3.TransformCoordinates(new t.Vector3(1,0,0),i);return l.setTarget(f),l},e.prototype._createLight=function(e,n,r){var o,a,i=n.get(e.modelId),s=i?i.computeWorldMatrix(!0):t.Matrix.Identity(),l=t.Vector3.TransformCoordinates(t.Vector3.Zero(),s),u=new t.Color3(e.color[0],e.color[1],e.color[2]),c=t.Vector3.TransformCoordinates(new t.Vector3(0,0,-1),s).subtract(l).normalize();switch(e.lightType){case 1:(a=new t.DirectionalLight(e.name,c,r)).diffuse=u,a.intensity=e.intensity;break;case 2:var f=e.coneAngle*(Math.PI/180);(a=new t.SpotLight(e.name,l,c,f,2,r)).diffuse=u,a.intensity=e.intensity;break;default:(a=new t.PointLight(e.name,l,r)).diffuse=u,a.intensity=e.intensity}return a.metadata=v(v({},null!==(o=a.metadata)&&void 0!==o?o:{}),{fbxLight:{lightType:e.lightType,decayType:e.decayType,decayStart:e.decayStart,innerAngle:e.innerAngle,outerAngle:e.outerAngle,enableNearAttenuation:e.enableNearAttenuation,enableFarAttenuation:e.enableFarAttenuation,castShadows:e.castShadows,unknownProperties:e.unknownProperties,diagnostics:e.diagnostics}}),a},e.prototype._createSkeleton=function(n,r,o){for(var a,i=new t.Skeleton("Skeleton","skeleton_".concat(n),o),s=[],l=new Map,u=[],c=[],f=[],d=0;d<r.length;d++){var h=r[d],p=e._computeFBXLocalMatrix(h.translation,h.rotation,h.scale,h.preRotation,h.postRotation,h.rotationPivot,h.scalingPivot,h.rotationOffset,h.scalingOffset,h.rotationOrder);u[d]=p,f[d]=e._computeFBXRuntimeLocalMatrix(r,p,d)}c.push.apply(c,e._computeFBXAbsoluteMatrices(r,f));var m=r.map(function(e,n){return e.transformLinkMatrix?t.Matrix.FromArray(e.transformLinkMatrix):e.modelBindPoseMatrix?t.Matrix.FromArray(e.modelBindPoseMatrix):c[n]}),_=m.map(function(e,n){var o=r[n].parentIndex;if(o<0)return e;var a=new t.Matrix;return m[o].invertToRef(a),e.multiply(a)}),g=e._shouldUseBindMatricesAsRest(r,u,_);for(d=0;d<r.length;d++){var y=g?_[d]:f[d],b=r[d].parentIndex>=0?s[r[d].parentIndex]:null;if(!g&&2===r[d].inheritType&&r[d].parentIndex>=0&&b){var x=e._splitParentScaleCompensatedLocalMatrix(u[d],r[r[d].parentIndex].scale);(M=new t.Bone("".concat(r[d].name,"__fbx_scaleCompensation"),i,b,x.helperLocalMatrix,x.helperLocalMatrix.clone(),t.Matrix.Identity(),-1)).metadata=v(v({},null!==(a=M.metadata)&&void 0!==a?a:{}),{fbxScaleCompensationForBoneIndex:d,fbxScaleCompensationForBoneName:r[d].name}),l.set(d,M),b=M,y=x.boneLocalMatrix}var T=new t.Bone(r[d].name,i,b,y,g?y.clone():null,g?y.clone():null,d);g&&r[d].isCluster&&e._getMaxScaleRatio(u[d],_[d])>=10&&this._bindRestBones.add(T),s.push(T)}if(this._sourceBonesBySkeleton.set(i,s),this._scaleCompensationHelpersBySkeleton.set(i,l),!g){for(d=0;d<r.length;d++)(T=s[d]).updateMatrix(_[d],!1,!1);for(var A=0,w=Array.from(l.values());A<w.length;A++){var M;(M=w[A]).updateMatrix(t.Matrix.Identity(),!1,!1)}for(var C=0,O=i.bones;C<O.length;C++)(T=O[C]).getParent()||T._updateAbsoluteBindMatrices(void 0,!0)}return i},e.prototype._getSourceBone=function(e,t){var n,r;return null!==(r=null===(n=this._sourceBonesBySkeleton.get(e))||void 0===n?void 0:n[t])&&void 0!==r?r:e.bones[t]},e.prototype._getScaleCompensationHelper=function(e,t){var n;return null===(n=this._scaleCompensationHelpersBySkeleton.get(e))||void 0===n?void 0:n.get(t)},e._computeFBXAbsoluteMatrices=function(e,t){for(var n=[],r=0;r<e.length;r++){var o=e[r].parentIndex;n[r]=o<0?t[r].clone():t[r].multiply(n[o])}return n},e._computeFBXRuntimeLocalMatrix=function(t,n,r,o){var a=t[r].parentIndex;if(2!==t[r].inheritType||a<0)return n;var i=null!=o?o:t[a].scale;return e._applyParentScaleCompensation(n,i)},e._applyParentScaleCompensation=function(t,n){var r=e._splitParentScaleCompensatedLocalMatrix(t,n);return r.boneLocalMatrix.multiply(r.helperLocalMatrix)},e._splitParentScaleCompensatedLocalMatrix=function(n,r){var o=n.getTranslation(),a=n.clone();return a.setTranslation(t.Vector3.Zero()),{boneLocalMatrix:a,helperLocalMatrix:t.Matrix.Compose(e._getInverseScaleVector(r),t.Quaternion.Identity(),o)}},e._safeInverseScale=function(e){return Math.abs(e)>1e-8?1/e:1},e._getInverseScaleVector=function(n){return new t.Vector3(e._safeInverseScale(n[0]),e._safeInverseScale(n[1]),e._safeInverseScale(n[2]))},e._shouldUseBindMatricesAsRest=function(t,n,r){return t.some(function(t,o){return!!t.isCluster&&e._getMaxScaleRatio(n[o],r[o])>=10})},e._getMaxScaleRatio=function(n,r){var o=new t.Vector3,a=new t.Quaternion,i=new t.Vector3,s=new t.Vector3,l=new t.Quaternion,u=new t.Vector3;return n.decompose(o,a,i),r.decompose(s,l,u),Math.max(e._getScaleRatio(o.x,s.x),e._getScaleRatio(o.y,s.y),e._getScaleRatio(o.z,s.z))},e._getScaleRatio=function(e,t){var n=Math.abs(e),r=Math.abs(t);return n<1e-6||r<1e-6?n<1e-6&&r<1e-6?1:Number.POSITIVE_INFINITY:Math.max(n/r,r/n)},e._computeFBXGeometricMatrix=function(e,n,r){return function(e,n,r){var o=t.Matrix.Translation(e[0],e[1],e[2]);return kt(n,r).multiply(o)}(e,n,r)},e._computeFBXGeometricDeltaMatrix=function(e,t){return kt(e,t)},e._computeFBXGeometricNormalMatrix=function(e,n){return function(e,n){var r=Math.PI/180,o=t.Matrix.Scaling(0===n[0]?0:1/n[0],0===n[1]?0:1/n[1],0===n[2]?0:1/n[2]),a=Nt(e[0]*r,e[1]*r,e[2]*r);return o.multiply(a)}(e,n)},e._computeFBXLocalMatrix=function(e,n,r,o,a,i,s,l,u,c){return void 0===c&&(c=0),function(e){var n=e.translation,r=e.rotation,o=e.scale,a=e.preRotation,i=e.postRotation,s=e.rotationPivot,l=e.scalingPivot,u=e.rotationOffset,c=e.scalingOffset,f=e.rotationOrder,d=Math.PI/180,h=0!==s[0]||0!==s[1]||0!==s[2]||0!==l[0]||0!==l[1]||0!==l[2],p=0!==u[0]||0!==u[1]||0!==u[2]||0!==c[0]||0!==c[1]||0!==c[2],m=0!==i[0]||0!==i[1]||0!==i[2];if(!h&&!p&&!m){var v=Nt(a[0]*d,a[1]*d,a[2]*d),_=Bt(r[0]*d,r[1]*d,r[2]*d,f),g=t.Matrix.Translation(n[0],n[1],n[2]),y=_.multiply(v);return t.Matrix.Scaling(o[0],o[1],o[2]).multiply(y).multiply(g)}var b,x=t.Matrix.Translation(n[0],n[1],n[2]),T=t.Matrix.Translation(u[0],u[1],u[2]),A=t.Matrix.Translation(s[0],s[1],s[2]),w=t.Matrix.Translation(-s[0],-s[1],-s[2]),M=t.Matrix.Translation(c[0],c[1],c[2]),C=t.Matrix.Translation(l[0],l[1],l[2]),O=t.Matrix.Translation(-l[0],-l[1],-l[2]),S=Nt(a[0]*d,a[1]*d,a[2]*d),E=Bt(r[0]*d,r[1]*d,r[2]*d,f),F=t.Matrix.Scaling(o[0],o[1],o[2]);if(m){var R=Nt(i[0]*d,i[1]*d,i[2]*d);b=new t.Matrix,R.invertToRef(b)}else b=t.Matrix.Identity();return O.multiply(F).multiply(C).multiply(M).multiply(w).multiply(b).multiply(E).multiply(S).multiply(A).multiply(T).multiply(x)}({translation:e,rotation:n,scale:r,preRotation:o,postRotation:a,rotationPivot:i,scalingPivot:s,rotationOffset:l,scalingOffset:u,rotationOrder:c})},e._applyFBXTransform=function(n,r){var o=e._computeFBXModelLocalMatrix(r),a=new t.Vector3,i=new t.Quaternion,s=new t.Vector3;o.decompose(a,i,s),n.position=s,n.rotationQuaternion=i,n.scaling=a},e._computeFBXModelLocalMatrix=function(t){return e._computeFBXLocalMatrix(t.translation,t.rotation,t.scale,t.preRotation,t.postRotation,t.rotationPivot,t.scalingPivot,t.rotationOffset,t.scalingOffset,t.rotationOrder)},e._getBoneReferenceWorldMatrix=function(e,t,n,r){return r?e.getTransformMatrices(r):e.prepare(!0),n.computeWorldMatrix(!0),t.getFinalMatrix().multiply(n.getWorldMatrix())},e._applyMatrixToTransform=function(e,n){var r=new t.Vector3,o=new t.Quaternion,a=new t.Vector3;n.decompose(r,o,a),e.position=a,e.rotationQuaternion=o,e.scaling=r},e.prototype._createAnimationGroup=function(e,n,r,o,a,i,s){var l=this;if(0===e.curveNodes.length)return null;for(var u=new t.AnimationGroup(e.name,o),c=new Map,f=0,d=n;f<d.length;f++){var h=d[f];if(M=r.get(h.id))for(var p=0,m=h.bones;p<m.length;p++){var v=m[p];(I=this._getSourceBone(M,v.index))&&((U=c.get(v.modelId))?U.push(I):c.set(v.modelId,[I]))}}for(var _=new Map,g=new Map,y=[],b=0,x=e.curveNodes;b<x.length;b++)"DeformPercent"!==(ne=x[b]).type?c.has(ne.targetModelId)?(_.has(ne.targetModelId)||_.set(ne.targetModelId,[]),_.get(ne.targetModelId).push(ne)):(g.has(ne.targetModelId)||g.set(ne.targetModelId,[]),g.get(ne.targetModelId).push(ne)):y.push(ne);for(var T=new Set,A=0,w=n;A<w.length;A++){h=w[A];var M,C=new Set(h.bones.filter(function(e){return 2===e.inheritType}).map(function(e){return e.modelId}));if(0!==C.size&&(M=r.get(h.id))&&!M.bones.some(function(e){return l._bindRestBones.has(e)})){for(var O=0,S=Array.from(C);O<S.length;O++){var E=S[O];T.add(E)}for(var F=0,R=this._buildInheritedRigBoneAnimations(h,M,_,i,C,e.startTime,e.stopTime);F<R.length;F++)for(var L=R[F],I=L.bone,P=0,N=L.animations;P<N.length;P++){var B=N[P];u.addTargetedAnimation(B,I)}}}for(var k=0,D=Array.from(_);k<D.length;k++){var G=D[k],V=G[0],H=G[1];if(!T.has(V)){var U=c.get(V),j=i.get(V);if(U&&0!==U.length&&j)for(var K=0,W=U;K<W.length;K++){I=W[K];for(var z=0,q=this._buildBoneAnimations(H,I.name,j,e.startTime,e.stopTime,this._bindRestBones.has(I)?I.getBindMatrix():void 0);z<q.length;z++)B=q[z],u.addTargetedAnimation(B,I)}}}for(var X=0,Y=Array.from(g);X<Y.length;X++){var Q=Y[X],Z=(V=Q[0],H=Q[1],a.get(V));if(Z&&(j=i.get(V)))for(var J=0,$=this._buildNodeAnimations(H,Z.name,j,e.startTime,e.stopTime);J<$.length;J++)B=$[J],u.addTargetedAnimation(B,Z)}for(var ee=0,te=y;ee<te.length;ee++)for(var ne,re=(ne=te[ee]).targetModelId,oe=!1,ae=function(n){if(!n.morphTargetManager||oe)return"continue";var r=n.metadata,o=null==r?void 0:r.fbxBlendShapeChannelTargets,a=null==o?void 0:o.get(re);if(a&&ne.curves.length>0){for(var i=30,s=function(r){var o=n.morphTargetManager.getTarget(a.targetIndices[r]);if(!o)return"continue";var s=new t.Animation("".concat(o.name,"_influence"),"influence",i,t.Animation.ANIMATIONTYPE_FLOAT,t.Animation.ANIMATIONLOOPMODE_CYCLE),l=Qt(ne.curves[0],i,e.startTime,e.stopTime,function(e){var t;return null!==(t=zt(e,a.fullWeights,a.targetIndices.length)[r])&&void 0!==t?t:0});s.setKeys(l),u.addTargetedAnimation(s,o)},l=0;l<a.targetIndices.length;l++)s(l);return oe=!0,"continue"}var c=null==r?void 0:r.fbxBlendShapeChannelIds;if(!c)return"continue";var f=c.get(re);if(void 0===f)return"continue";var d=n.morphTargetManager.getTarget(f);if(d&&ne.curves.length>0){i=30;var h=new t.Animation("".concat(d.name,"_influence"),"influence",i,t.Animation.ANIMATIONTYPE_FLOAT,t.Animation.ANIMATIONLOOPMODE_CYCLE),p=Qt(ne.curves[0],i,e.startTime,e.stopTime,function(e){return e/100});h.setKeys(p),u.addTargetedAnimation(h,d),oe=!0}},ie=0,se=s;ie<se.length;ie++)ae(se[ie]);return u.targetedAnimations.length>0?(u.normalize(30*e.startTime,30*e.stopTime),u):(u.dispose(),null)},e.prototype._buildInheritedRigBoneAnimations=function(n,r,o,a,i,s,l){for(var u=this,c=30,f=new Set,d=0;d<n.bones.length;d++)if(i.has(n.bones[d].modelId))for(var h=d;h>=0;h=n.bones[h].parentIndex)f.add(n.bones[h].modelId);var p=n.bones.filter(function(e){return f.has(e.modelId)}).flatMap(function(e){var t;return null!==(t=o.get(e.modelId))&&void 0!==t?t:[]}),m=Xt(p,c,s,l);if(0===m.length)return[];for(var v=n.bones.map(function(){return{posKeys:[],rotKeys:[],sclKeys:[],prevQuat:null}}),_=n.bones.map(function(){return{posKeys:[],rotKeys:[],sclKeys:[],prevQuat:null}}),g=n.bones.map(function(n,o){var i=u._getSourceBone(r,o),s=a.get(n.modelId);if(!i||!s||!u._bindRestBones.has(i))return null;var l=e._computeFBXModelLocalMatrix(s),c=new t.Matrix;return l.invertToRef(c),c}),y=function(s){for(var l=n.bones.map(function(e,n){var i,l,c=a.get(e.modelId),f=null!==(i=o.get(e.modelId))&&void 0!==i?i:[],d=c?u._sampleModelLocalMatrix(c,f,s):t.Matrix.Identity(),h=g[n];if(h){var p=u._getSourceBone(r,n);d=(null!==(l=null==p?void 0:p.getBindMatrix())&&void 0!==l?l:t.Matrix.Identity()).multiply(h).multiply(d)}return d}),f=n.bones.map(function(e){var t,n=a.get(e.modelId),r=null!==(t=o.get(e.modelId))&&void 0!==t?t:[];return n?u._sampleModelScale(n,r,s):e.scale}),d=s*c,h=0;h<l.length;h++)if(i.has(n.bones[h].modelId)){var p=n.bones[h].parentIndex,m=p>=0?f[p]:n.bones[h].scale,y=e._splitParentScaleCompensatedLocalMatrix(l[h],m);e._pushMatrixKeys(v[h],d,y.boneLocalMatrix),e._pushMatrixKeys(_[h],d,y.helperLocalMatrix)}},b=0,x=m;b<x.length;b++)y(x[b]);var T=[];for(d=0;d<n.bones.length;d++)if(i.has(n.bones[d].modelId)){var A=this._getSourceBone(r,d);if(A){var w=v[d],M=w.posKeys,C=w.rotKeys,O=w.sclKeys,S=[];this._isVector3KeysConstant(M)||((F=new t.Animation("".concat(A.name,"_position"),"position",c,t.Animation.ANIMATIONTYPE_VECTOR3,t.Animation.ANIMATIONLOOPMODE_CYCLE)).setKeys(M),S.push(F)),Yt(C)||((R=new t.Animation("".concat(A.name,"_rotation"),"rotationQuaternion",c,t.Animation.ANIMATIONTYPE_QUATERNION,t.Animation.ANIMATIONLOOPMODE_CYCLE)).setKeys(C),S.push(R)),this._isVector3KeysConstant(O)||((L=new t.Animation("".concat(A.name,"_scaling"),"scaling",c,t.Animation.ANIMATIONTYPE_VECTOR3,t.Animation.ANIMATIONLOOPMODE_CYCLE)).setKeys(O),S.push(L)),S.length>0&&T.push({bone:A,animations:S});var E=this._getScaleCompensationHelper(r,d);if(E){var F,R,L,I=[],P=_[d],N=P.posKeys,B=P.rotKeys,k=P.sclKeys;this._isVector3KeysConstant(N)||((F=new t.Animation("".concat(E.name,"_position"),"position",c,t.Animation.ANIMATIONTYPE_VECTOR3,t.Animation.ANIMATIONLOOPMODE_CYCLE)).setKeys(N),I.push(F)),Yt(B)||((R=new t.Animation("".concat(E.name,"_rotation"),"rotationQuaternion",c,t.Animation.ANIMATIONTYPE_QUATERNION,t.Animation.ANIMATIONLOOPMODE_CYCLE)).setKeys(B),I.push(R)),this._isVector3KeysConstant(k)||((L=new t.Animation("".concat(E.name,"_scaling"),"scaling",c,t.Animation.ANIMATIONTYPE_VECTOR3,t.Animation.ANIMATIONLOOPMODE_CYCLE)).setKeys(k),I.push(L)),I.length>0&&T.push({bone:E,animations:I})}}}return T},e._pushMatrixKeys=function(e,n,r){var o=new t.Vector3,a=new t.Quaternion,i=new t.Vector3;r.decompose(o,a,i),e.prevQuat&&t.Quaternion.Dot(e.prevQuat,a)<0&&a.scaleInPlace(-1),e.prevQuat=a,e.posKeys.push({frame:n,value:i}),e.rotKeys.push({frame:n,value:a}),e.sclKeys.push({frame:n,value:o})},e.prototype._buildNodeAnimations=function(n,r,o,a,i){var s,l,u,c,f,d,h,p,m,v=n.find(function(e){return"T"===e.type}),_=n.find(function(e){return"R"===e.type}),g=n.find(function(e){return"S"===e.type}),y=Xt(n,30,a,i);if(0===y.length)return[];for(var b=null==v?void 0:v.curves.find(function(e){return"d|X"===e.channel}),x=null==v?void 0:v.curves.find(function(e){return"d|Y"===e.channel}),T=null==v?void 0:v.curves.find(function(e){return"d|Z"===e.channel}),A=null==_?void 0:_.curves.find(function(e){return"d|X"===e.channel}),w=null==_?void 0:_.curves.find(function(e){return"d|Y"===e.channel}),M=null==_?void 0:_.curves.find(function(e){return"d|Z"===e.channel}),C=null==g?void 0:g.curves.find(function(e){return"d|X"===e.channel}),O=null==g?void 0:g.curves.find(function(e){return"d|Y"===e.channel}),S=null==g?void 0:g.curves.find(function(e){return"d|Z"===e.channel}),E=[],F=[],R=[],L=null,I=0,P=y;I<P.length;I++){var N=P[I],B=30*N,k=null!==(s=lt(b,N))&&void 0!==s?s:o.translation[0],D=null!==(l=lt(x,N))&&void 0!==l?l:o.translation[1],G=null!==(u=lt(T,N))&&void 0!==u?u:o.translation[2],V=null!==(c=lt(A,N))&&void 0!==c?c:o.rotation[0],H=null!==(f=lt(w,N))&&void 0!==f?f:o.rotation[1],U=null!==(d=lt(M,N))&&void 0!==d?d:o.rotation[2],j=null!==(h=lt(C,N))&&void 0!==h?h:o.scale[0],K=null!==(p=lt(O,N))&&void 0!==p?p:o.scale[1],W=null!==(m=lt(S,N))&&void 0!==m?m:o.scale[2],z=e._computeFBXLocalMatrix([k,D,G],[V,H,U],[j,K,W],o.preRotation,o.postRotation,o.rotationPivot,o.scalingPivot,o.rotationOffset,o.scalingOffset,o.rotationOrder),q=new t.Vector3,X=new t.Quaternion,Y=new t.Vector3;z.decompose(q,X,Y),L&&t.Quaternion.Dot(L,X)<0&&X.scaleInPlace(-1),L=X,E.push({frame:B,value:Y}),F.push({frame:B,value:X}),R.push({frame:B,value:q})}var Q=[];if(!this._isVector3KeysConstant(E)){var Z=new t.Animation("".concat(r,"_position"),"position",30,t.Animation.ANIMATIONTYPE_VECTOR3,t.Animation.ANIMATIONLOOPMODE_CYCLE);Z.setKeys(E),Q.push(Z)}if(_){var J=new t.Animation("".concat(r,"_rotation"),"rotationQuaternion",30,t.Animation.ANIMATIONTYPE_QUATERNION,t.Animation.ANIMATIONLOOPMODE_CYCLE);J.setKeys(F),Q.push(J)}if(!this._isVector3KeysConstant(R)){var $=new t.Animation("".concat(r,"_scaling"),"scaling",30,t.Animation.ANIMATIONTYPE_VECTOR3,t.Animation.ANIMATIONLOOPMODE_CYCLE);$.setKeys(R),Q.push($)}return Q},e.prototype._isVector3KeysConstant=function(e){if(e.length<2)return!0;for(var t=e[0].value,n=1;n<e.length;n++){var r=e[n].value;if(Math.abs(r.x-t.x)>1e-4||Math.abs(r.y-t.y)>1e-4||Math.abs(r.z-t.z)>1e-4)return!1}return!0},e.prototype._sampleModelLocalMatrix=function(t,n,r,o){var a,i,s,l,u,c,f,d,h,p=n.find(function(e){return"T"===e.type}),m=n.find(function(e){return"R"===e.type}),v=n.find(function(e){return"S"===e.type}),_=null==p?void 0:p.curves.find(function(e){return"d|X"===e.channel}),g=null==p?void 0:p.curves.find(function(e){return"d|Y"===e.channel}),y=null==p?void 0:p.curves.find(function(e){return"d|Z"===e.channel}),b=null==m?void 0:m.curves.find(function(e){return"d|X"===e.channel}),x=null==m?void 0:m.curves.find(function(e){return"d|Y"===e.channel}),T=null==m?void 0:m.curves.find(function(e){return"d|Z"===e.channel}),A=null==v?void 0:v.curves.find(function(e){return"d|X"===e.channel}),w=null==v?void 0:v.curves.find(function(e){return"d|Y"===e.channel}),M=null==v?void 0:v.curves.find(function(e){return"d|Z"===e.channel});return e._computeFBXLocalMatrix([null!==(a=lt(_,r))&&void 0!==a?a:t.translation[0],null!==(i=lt(g,r))&&void 0!==i?i:t.translation[1],null!==(s=lt(y,r))&&void 0!==s?s:t.translation[2]],[null!==(l=lt(b,r))&&void 0!==l?l:t.rotation[0],null!==(u=lt(x,r))&&void 0!==u?u:t.rotation[1],null!==(c=lt(T,r))&&void 0!==c?c:t.rotation[2]],null!=o?o:[null!==(f=lt(A,r))&&void 0!==f?f:t.scale[0],null!==(d=lt(w,r))&&void 0!==d?d:t.scale[1],null!==(h=lt(M,r))&&void 0!==h?h:t.scale[2]],t.preRotation,t.postRotation,t.rotationPivot,t.scalingPivot,t.rotationOffset,t.scalingOffset,t.rotationOrder)},e.prototype._sampleModelScale=function(e,t,n){var r,o,a,i=t.find(function(e){return"S"===e.type}),s=null==i?void 0:i.curves.find(function(e){return"d|X"===e.channel}),l=null==i?void 0:i.curves.find(function(e){return"d|Y"===e.channel}),u=null==i?void 0:i.curves.find(function(e){return"d|Z"===e.channel});return[null!==(r=lt(s,n))&&void 0!==r?r:e.scale[0],null!==(o=lt(l,n))&&void 0!==o?o:e.scale[1],null!==(a=lt(u,n))&&void 0!==a?a:e.scale[2]]},e.prototype._buildBoneAnimations=function(n,r,o,a,i,s){var l,u,c,f,d,h,p,m,v,_=n.find(function(e){return"T"===e.type}),g=n.find(function(e){return"R"===e.type}),y=n.find(function(e){return"S"===e.type}),b=Xt(n,30,a,i);if(0===b.length)return[];var x=null==_?void 0:_.curves.find(function(e){return"d|X"===e.channel}),T=null==_?void 0:_.curves.find(function(e){return"d|Y"===e.channel}),A=null==_?void 0:_.curves.find(function(e){return"d|Z"===e.channel}),w=null==g?void 0:g.curves.find(function(e){return"d|X"===e.channel}),M=null==g?void 0:g.curves.find(function(e){return"d|Y"===e.channel}),C=null==g?void 0:g.curves.find(function(e){return"d|Z"===e.channel}),O=null==y?void 0:y.curves.find(function(e){return"d|X"===e.channel}),S=null==y?void 0:y.curves.find(function(e){return"d|Y"===e.channel}),E=null==y?void 0:y.curves.find(function(e){return"d|Z"===e.channel}),F=[],R=[],L=[],I=null,P=null;if(s){var N=e._computeFBXLocalMatrix(o.translation,o.rotation,o.scale,o.preRotation,o.postRotation,o.rotationPivot,o.scalingPivot,o.rotationOffset,o.scalingOffset,o.rotationOrder);P=new t.Matrix,N.invertToRef(P)}for(var B=0,k=b;B<k.length;B++){var D=k[B],G=30*D,V=null!==(l=lt(x,D))&&void 0!==l?l:o.translation[0],H=null!==(u=lt(T,D))&&void 0!==u?u:o.translation[1],U=null!==(c=lt(A,D))&&void 0!==c?c:o.translation[2],j=null!==(f=lt(w,D))&&void 0!==f?f:o.rotation[0],K=null!==(d=lt(M,D))&&void 0!==d?d:o.rotation[1],W=null!==(h=lt(C,D))&&void 0!==h?h:o.rotation[2],z=null!==(p=lt(O,D))&&void 0!==p?p:o.scale[0],q=null!==(m=lt(S,D))&&void 0!==m?m:o.scale[1],X=null!==(v=lt(E,D))&&void 0!==v?v:o.scale[2],Y=e._computeFBXLocalMatrix([V,H,U],[j,K,W],[z,q,X],o.preRotation,o.postRotation,o.rotationPivot,o.scalingPivot,o.rotationOffset,o.scalingOffset,o.rotationOrder),Q=P&&s?s.multiply(P).multiply(Y):Y,Z=new t.Vector3,J=new t.Quaternion,$=new t.Vector3;Q.decompose(Z,J,$),I&&t.Quaternion.Dot(I,J)<0&&J.scaleInPlace(-1),I=J,F.push({frame:G,value:$}),R.push({frame:G,value:J}),L.push({frame:G,value:Z})}var ee=[];if(!this._isVector3KeysConstant(F)){var te=new t.Animation("".concat(r,"_position"),"position",30,t.Animation.ANIMATIONTYPE_VECTOR3,t.Animation.ANIMATIONLOOPMODE_CYCLE);te.setKeys(F),ee.push(te)}if(g){var ne=new t.Animation("".concat(r,"_rotation"),"rotationQuaternion",30,t.Animation.ANIMATIONTYPE_QUATERNION,t.Animation.ANIMATIONLOOPMODE_CYCLE);ne.setKeys(R),ee.push(ne)}if(!this._isVector3KeysConstant(L)){var re=new t.Animation("".concat(r,"_scaling"),"scaling",30,t.Animation.ANIMATIONTYPE_VECTOR3,t.Animation.ANIMATIONLOOPMODE_CYCLE);re.setKeys(L),ee.push(re)}return ee},e.prototype._buildNameFilter=function(e){if(!e)return null;if("string"==typeof e)return""===e?null:function(t){return t===e};if(0===e.length)return null;var t=new Set(e);return function(e){return t.has(e)}},e}();function Vt(e){for(var t=new Float32Array(e.length),n=0;n<e.length;n++)t[n]=e[n];return t}function Ht(e,t,n,r,o,a,i,s,l,u,c,f,d,h,p,m){var v,_=function(e,t,n,r){var o=3*t,a=3*n,i=3*r,s=e[a]-e[o],l=e[a+1]-e[o+1],u=e[a+2]-e[o+2],c=e[i]-e[o],f=e[i+1]-e[o+1],d=e[i+2]-e[o+2],h=Math.hypot(s,l,u),p=Math.hypot(c,f,d);if(h<=1e-8||p<=1e-8)return 0;var m=(s*c+l*f+u*d)/(h*p);return Math.acos(Math.max(-1,Math.min(1,m)))}(u,e,t,n);if(!(_<=1e-8)){var g=function(e,t,n,r,o,a,i,s,l,u,c,f){var d=3*e,h=3*e,p=2*e,m=Ut(l[h],l[h+1],l[h+2]),v=m[0],_=m[1],g=m[2],y=function(e,t,n,r,o,a,i,s,l){return(t*a-n*o)*i+(n*r-e*a)*s+(e*o-t*r)*l<0?-1:1}(v,_,g,t,n,r,o,a,i);return[c?"cp:".concat(c[e]):"p:".concat(jt(s[d]),",").concat(jt(s[d+1]),",").concat(jt(s[d+2])),jt(v),jt(_),jt(g),jt(u[p]),jt(u[p+1]),y,f].join("|")}(e,r,o,a,i,s,l,u,c,f,d,h),y=p.get(g);y||(y={tx:0,ty:0,tz:0,bx:0,by:0,bz:0},p.set(g,y)),y.tx+=r*_,y.ty+=o*_,y.tz+=a*_,y.bx+=i*_,y.by+=s*_,y.bz+=l*_,null!==(v=m[e])&&void 0!==v||(m[e]=g)}}function Ut(e,t,n){var r=Math.hypot(e,t,n);return r>1e-8?[e/r,t/r,n/r]:[0,0,1]}function jt(e){var t=Math.round(1e6*e);return Object.is(t,-0)?0:t}function Kt(e,t,n){var r=Math.abs(e)<.9?1:0,o=1===r?0:1,a=e*r+t*o,i=r-e*a,s=o-t*a,l=-n*a,u=Math.hypot(i,s,l);return u<=1e-8?[1,0,0]:[i/=u,s/=u,l/=u]}function Wt(e,n,r,o,a,i){for(var s=r.length/3,l=new Float32Array(3*s),u=null!==e.normals&&null!==o?new Float32Array(3*s):null,c=0;c<l.length;c++)l[c]=r[c];if(u&&o)for(c=0;c<u.length;c++)u[c]=o[c];var f=new Map;for(c=0;c<e.indices.length;c++)f.set(e.indices[c],c);for(var d=0;d<s;d++){var h=n[d],p=f.get(h);if(void 0!==p){var m=e.vertices[3*p],v=e.vertices[3*p+1],_=e.vertices[3*p+2];if(a){var g=t.Vector3.TransformNormal(new t.Vector3(m,v,_),a);m=g.x,v=g.y,_=g.z}if(l[3*d]+=m,l[3*d+1]+=v,l[3*d+2]+=_,u&&e.normals){var y=e.normals[3*p],b=e.normals[3*p+1],x=e.normals[3*p+2];if(i){var T=t.Vector3.TransformNormal(new t.Vector3(y,b,x),i);T.lengthSquared()>0&&T.normalize(),y=T.x,b=T.y,x=T.z}u[3*d]+=y,u[3*d+1]+=b,u[3*d+2]+=x}}}return{positions:l,normals:u}}function zt(e,t,n){if(n<=0)return[];if(!t||t.length!==n||1===n)return[qt(e/((null==t?void 0:t[0])&&0!==t[0]?t[0]:100))];var r=new Array(n).fill(0);if(e<=t[0])return r[0]=0===t[0]?e<=0?1:0:qt(e/t[0]),r;for(var o=1;o<t.length;o++){var a=t[o-1],i=t[o];if(!(e>i)){var s=i-a;if(Math.abs(s)<1e-6)return r[o]=1,r;var l=qt((e-a)/s);return r[o-1]=1-l,r[o]=l,r}}return r[n-1]=1,r}function qt(e){return Math.max(0,Math.min(1,e))}function Xt(e,t,n,r){for(var o=Number.POSITIVE_INFINITY,a=Number.NEGATIVE_INFINITY,i=new Set,s=0,l=e;s<l.length;s++)for(var u=0,c=l[s].curves;u<c.length;u++)for(var f=0,d=c[u].keys;f<d.length;f++){var h=d[f];o=Math.min(o,h.time),a=Math.max(a,h.time),h.time>=n&&h.time<=r&&i.add(h.time)}if(!Number.isFinite(o)||!Number.isFinite(a))return[];for(var p=r>n?n:o,m=r>n?r:a,v=new Set(y([p,m],Array.from(i),!0)),_=Math.ceil(p*t),g=Math.floor(m*t),b=_;b<=g;b++)v.add(b/t);return Array.from(v).sort(function(e,t){return e-t})}function Yt(e){if(e.length<2)return!0;for(var t=e[0].value,n=1;n<e.length;n++){var r=e[n].value;if(Math.abs(r.x-t.x)>1e-4||Math.abs(r.y-t.y)>1e-4||Math.abs(r.z-t.z)>1e-4||Math.abs(r.w-t.w)>1e-4)return!1}return!0}function Qt(e,t,n,r,o){var a,i,s,l,u,c,f=function(e,t,n){var r,o,a,i;return n>t?{start:t,stop:n}:{start:null!==(o=null===(r=e.keys[0])||void 0===r?void 0:r.time)&&void 0!==o?o:0,stop:null!==(i=null===(a=e.keys[e.keys.length-1])||void 0===a?void 0:a.time)&&void 0!==i?i:0}}(e,n,r),d=e.keys.filter(function(e){return e.time>=f.start&&e.time<=f.stop}).map(function(e){return{source:e,frame:e.time*t,value:o(e.value)}});d.some(function(e){return Math.abs(e.source.time-f.start)<1e-6})||d.unshift({source:{time:f.start,value:null!==(a=lt(e,f.start))&&void 0!==a?a:0,interpolation:"linear"},frame:f.start*t,value:o(null!==(i=lt(e,f.start))&&void 0!==i?i:0)}),d.some(function(e){return Math.abs(e.source.time-f.stop)<1e-6})||d.push({source:{time:f.stop,value:null!==(s=lt(e,f.stop))&&void 0!==s?s:0,interpolation:"linear"},frame:f.stop*t,value:o(null!==(l=lt(e,f.stop))&&void 0!==l?l:0)});for(var h=d.map(function(e){return{frame:e.frame,value:e.value}}),p=0;p<d.length-1;p++){var m=d[p].source,v=h[p+1];if("constant"!==m.interpolation){if("cubic"===m.interpolation){var _=d[p+1].source,g=Math.max(_.time-m.time,1e-6),y=(_.value-m.value)/g;h[p].outTangent=Zt(null!==(u=m.rightSlope)&&void 0!==u?u:y,o)/t,v.inTangent=Zt(null!==(c=m.nextLeftSlope)&&void 0!==c?c:y,o)/t}}else h[p].interpolation=1}return h}function Zt(e,t){return t(e)-t(0)}t.RegisterSceneLoaderPlugin(new Gt);var Jt={__proto__:null,FBXFileLoader:Gt};function $t(e,t,n,r){var o={externalResourceFunction:r};return n&&(o.uri="file:"===t?n:t+n),ArrayBuffer.isView(e)?GLTFValidator.validateBytes(e,o):GLTFValidator.validateString(e,o)}function en(){var e=[];onmessage=function(t){var n=t.data;switch(n.id){case"init":importScripts(n.url);break;case"validate":$t(n.data,n.rootUrl,n.fileName,function(t){return new Promise(function(n,r){var o=e.length;e.push({resolve:n,reject:r}),postMessage({id:"getExternalResource",index:o,uri:t})})}).then(function(e){postMessage({id:"validate.resolve",value:e})},function(e){postMessage({id:"validate.reject",reason:e})});break;case"getExternalResource.resolve":e[n.index].resolve(n.value);break;case"getExternalResource.reject":e[n.index].reject(n.reason)}}}var tn,nn,rn,on=function(){function e(){}return e.ValidateAsync=function(n,r,o,a){var i=this;return"function"==typeof Worker?new Promise(function(s,l){var u="".concat($t,"(").concat(en,")()"),c=URL.createObjectURL(new Blob([u],{type:"application/javascript"})),f=new Worker(c),d=function(e){f.removeEventListener("error",d),f.removeEventListener("message",h),l(e)},h=function(t){var n=t.data;switch(n.id){case"getExternalResource":a(n.uri).then(function(e){f.postMessage({id:"getExternalResource.resolve",index:n.index,value:e},[e.buffer])},function(e){f.postMessage({id:"getExternalResource.reject",index:n.index,reason:e})});break;case"validate.resolve":f.removeEventListener("error",d),f.removeEventListener("message",h),e._LastResults=n.value,s(n.value),f.terminate();break;case"validate.reject":f.removeEventListener("error",d),f.removeEventListener("message",h),l(n.reason),f.terminate()}};if(f.addEventListener("error",d),f.addEventListener("message",h),f.postMessage({id:"init",url:t.Tools.GetBabylonScriptURL(i.Configuration.url)}),ArrayBuffer.isView(n)){var p=n.slice();f.postMessage({id:"validate",data:p,rootUrl:r,fileName:o},[p.buffer])}else f.postMessage({id:"validate",data:n,rootUrl:r,fileName:o})}):(this._LoadScriptPromise||(this._LoadScriptPromise=t.Tools.LoadBabylonScriptAsync(this.Configuration.url)),this._LoadScriptPromise.then(function(){return $t(n,r,o,a)}))},e.Configuration={url:"".concat(t.Tools._DefaultCdnUrl,"/gltf_validator.js")},e._LastResults=null,e}(),an={__proto__:null,GLTFValidation:on},sn="Z2xURg",ln={name:"gltf",extensions:{".gltf":{isBinary:!1,mimeType:"model/gltf+json"},".glb":{isBinary:!0,mimeType:"model/gltf-binary"}},canDirectLoad:function(e){return-1!==e.indexOf("asset")&&-1!==e.indexOf("version")||e.startsWith("data:base64,"+sn)||e.startsWith("data:;base64,"+sn)||e.startsWith("data:application/octet-stream;base64,"+sn)||e.startsWith("data:model/gltf-binary;base64,"+sn)}};function un(e,t,n){try{return Promise.resolve(new Uint8Array(e,t,n))}catch(e){return Promise.reject(e)}}e.GLTFLoaderCoordinateSystemMode=void 0,(tn=e.GLTFLoaderCoordinateSystemMode||(e.GLTFLoaderCoordinateSystemMode={}))[tn.AUTO=0]="AUTO",tn[tn.FORCE_RIGHT_HANDED=1]="FORCE_RIGHT_HANDED",e.GLTFLoaderAnimationStartMode=void 0,(nn=e.GLTFLoaderAnimationStartMode||(e.GLTFLoaderAnimationStartMode={}))[nn.NONE=0]="NONE",nn[nn.FIRST=1]="FIRST",nn[nn.ALL=2]="ALL",e.GLTFLoaderState=void 0,(rn=e.GLTFLoaderState||(e.GLTFLoaderState={}))[rn.LOADING=0]="LOADING",rn[rn.READY=1]="READY",rn[rn.COMPLETE=2]="COMPLETE";var cn=function(){this.alwaysComputeBoundingBox=!1,this.alwaysComputeSkeletonRootNode=!1,this.animationStartMode=e.GLTFLoaderAnimationStartMode.FIRST,this.compileMaterials=!1,this.compileShadowGenerators=!1,this.coordinateSystemMode=e.GLTFLoaderCoordinateSystemMode.AUTO,this.createInstances=!0,this.loadAllMaterials=!1,this.loadMorphTargets=!0,this.loadNodeAnimations=!0,this.loadOnlyMaterials=!1,this.loadSkins=!0,this.skipMaterials=!1,this.targetFps=60,this.transparencyAsCoverage=!1,this.useClipPlane=!1,this.useGltfTextureNames=!1,this.useRangeRequests=!1,this.useSRGBBuffers=!0,this.validate=!1,this.useOpenPBR=!1,this.dontUseTransmissionHelper=!1},fn=new cn,dn=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.extensionOptions={},t.preprocessUrlAsync=function(e){return Promise.resolve(e)},t}return m(t,e),t.prototype.copyFrom=function(e){var t,n,r,o,a,i,s,l,u,c,f,d,h,p,m,v,_,g,y,b,x,T,A,w,M,C;e&&(this.alwaysComputeBoundingBox=null!==(t=e.alwaysComputeBoundingBox)&&void 0!==t?t:this.alwaysComputeBoundingBox,this.alwaysComputeSkeletonRootNode=null!==(n=e.alwaysComputeSkeletonRootNode)&&void 0!==n?n:this.alwaysComputeSkeletonRootNode,this.animationStartMode=null!==(r=e.animationStartMode)&&void 0!==r?r:this.animationStartMode,this.capturePerformanceCounters=null!==(o=e.capturePerformanceCounters)&&void 0!==o?o:this.capturePerformanceCounters,this.compileMaterials=null!==(a=e.compileMaterials)&&void 0!==a?a:this.compileMaterials,this.compileShadowGenerators=null!==(i=e.compileShadowGenerators)&&void 0!==i?i:this.compileShadowGenerators,this.coordinateSystemMode=null!==(s=e.coordinateSystemMode)&&void 0!==s?s:this.coordinateSystemMode,this.createInstances=null!==(l=e.createInstances)&&void 0!==l?l:this.createInstances,this.customRootNode=e.customRootNode,this.extensionOptions=null!==(u=e.extensionOptions)&&void 0!==u?u:this.extensionOptions,this.loadAllMaterials=null!==(c=e.loadAllMaterials)&&void 0!==c?c:this.loadAllMaterials,this.loadMorphTargets=null!==(f=e.loadMorphTargets)&&void 0!==f?f:this.loadMorphTargets,this.loadNodeAnimations=null!==(d=e.loadNodeAnimations)&&void 0!==d?d:this.loadNodeAnimations,this.loadOnlyMaterials=null!==(h=e.loadOnlyMaterials)&&void 0!==h?h:this.loadOnlyMaterials,this.loadSkins=null!==(p=e.loadSkins)&&void 0!==p?p:this.loadSkins,this.loggingEnabled=null!==(m=e.loggingEnabled)&&void 0!==m?m:this.loggingEnabled,this.onCameraLoaded=e.onCameraLoaded,this.onMaterialLoaded=e.onMaterialLoaded,this.onMeshLoaded=e.onMeshLoaded,this.onParsed=e.onParsed,this.onSkinLoaded=e.onSkinLoaded,this.onTextureLoaded=e.onTextureLoaded,this.onValidated=e.onValidated,this.preprocessUrlAsync=null!==(v=e.preprocessUrlAsync)&&void 0!==v?v:this.preprocessUrlAsync,this.skipMaterials=null!==(_=e.skipMaterials)&&void 0!==_?_:this.skipMaterials,this.targetFps=null!==(g=e.targetFps)&&void 0!==g?g:this.targetFps,this.transparencyAsCoverage=null!==(y=e.transparencyAsCoverage)&&void 0!==y?y:this.transparencyAsCoverage,this.useClipPlane=null!==(b=e.useClipPlane)&&void 0!==b?b:this.useClipPlane,this.useGltfTextureNames=null!==(x=e.useGltfTextureNames)&&void 0!==x?x:this.useGltfTextureNames,this.useOpenPBR=null!==(T=e.useOpenPBR)&&void 0!==T?T:this.useOpenPBR,this.useRangeRequests=null!==(A=e.useRangeRequests)&&void 0!==A?A:this.useRangeRequests,this.useSRGBBuffers=null!==(w=e.useSRGBBuffers)&&void 0!==w?w:this.useSRGBBuffers,this.validate=null!==(M=e.validate)&&void 0!==M?M:this.validate,this.dontUseTransmissionHelper=null!==(C=e.dontUseTransmissionHelper)&&void 0!==C?C:this.dontUseTransmissionHelper)},t}(cn),hn=function(n){function r(e){var r=n.call(this)||this;return r.onParsedObservable=new t.Observable,r.onMeshLoadedObservable=new t.Observable,r.onSkinLoadedObservable=new t.Observable,r.onTextureLoadedObservable=new t.Observable,r.onMaterialLoadedObservable=new t.Observable,r.onCameraLoadedObservable=new t.Observable,r.onCompleteObservable=new t.Observable,r.onErrorObservable=new t.Observable,r.onDisposeObservable=new t.Observable,r.onExtensionLoadedObservable=new t.Observable,r.onValidatedObservable=new t.Observable,r._loader=null,r._state=null,r._requests=new Array,r.name=ln.name,r.extensions=ln.extensions,r.onLoaderStateChangedObservable=new t.Observable,r._logIndentLevel=0,r._loggingEnabled=!1,r._log=r._logDisabled,r._capturePerformanceCounters=!1,r._startPerformanceCounter=r._startPerformanceCounterDisabled,r._endPerformanceCounter=r._endPerformanceCounterDisabled,r.copyFrom(Object.assign(v({},fn),e)),r}return m(r,n),Object.defineProperty(r.prototype,"onParsed",{set:function(e){this._onParsedObserver&&this.onParsedObservable.remove(this._onParsedObserver),e&&(this._onParsedObserver=this.onParsedObservable.add(e))},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"onMeshLoaded",{set:function(e){this._onMeshLoadedObserver&&this.onMeshLoadedObservable.remove(this._onMeshLoadedObserver),e&&(this._onMeshLoadedObserver=this.onMeshLoadedObservable.add(e))},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"onSkinLoaded",{set:function(e){this._onSkinLoadedObserver&&this.onSkinLoadedObservable.remove(this._onSkinLoadedObserver),e&&(this._onSkinLoadedObserver=this.onSkinLoadedObservable.add(function(t){return e(t.node,t.skinnedNode)}))},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"onTextureLoaded",{set:function(e){this._onTextureLoadedObserver&&this.onTextureLoadedObservable.remove(this._onTextureLoadedObserver),e&&(this._onTextureLoadedObserver=this.onTextureLoadedObservable.add(e))},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"onMaterialLoaded",{set:function(e){this._onMaterialLoadedObserver&&this.onMaterialLoadedObservable.remove(this._onMaterialLoadedObserver),e&&(this._onMaterialLoadedObserver=this.onMaterialLoadedObservable.add(e))},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"onCameraLoaded",{set:function(e){this._onCameraLoadedObserver&&this.onCameraLoadedObservable.remove(this._onCameraLoadedObserver),e&&(this._onCameraLoadedObserver=this.onCameraLoadedObservable.add(e))},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"onComplete",{set:function(e){this._onCompleteObserver&&this.onCompleteObservable.remove(this._onCompleteObserver),this._onCompleteObserver=this.onCompleteObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"onError",{set:function(e){this._onErrorObserver&&this.onErrorObservable.remove(this._onErrorObserver),this._onErrorObserver=this.onErrorObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"onDispose",{set:function(e){this._onDisposeObserver&&this.onDisposeObservable.remove(this._onDisposeObserver),this._onDisposeObserver=this.onDisposeObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"onExtensionLoaded",{set:function(e){this._onExtensionLoadedObserver&&this.onExtensionLoadedObservable.remove(this._onExtensionLoadedObserver),this._onExtensionLoadedObserver=this.onExtensionLoadedObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"loggingEnabled",{get:function(){return this._loggingEnabled},set:function(e){this._loggingEnabled!==e&&(this._loggingEnabled=e,this._loggingEnabled?this._log=this._logEnabled:this._log=this._logDisabled)},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"capturePerformanceCounters",{get:function(){return this._capturePerformanceCounters},set:function(e){this._capturePerformanceCounters!==e&&(this._capturePerformanceCounters=e,this._capturePerformanceCounters?(this._startPerformanceCounter=this._startPerformanceCounterEnabled,this._endPerformanceCounter=this._endPerformanceCounterEnabled):(this._startPerformanceCounter=this._startPerformanceCounterDisabled,this._endPerformanceCounter=this._endPerformanceCounterDisabled))},enumerable:!1,configurable:!0}),Object.defineProperty(r.prototype,"onValidated",{set:function(e){this._onValidatedObserver&&this.onValidatedObservable.remove(this._onValidatedObserver),this._onValidatedObserver=this.onValidatedObservable.add(e)},enumerable:!1,configurable:!0}),r.prototype.dispose=function(){this._loader&&(this._loader.dispose(),this._loader=null);for(var e=0,t=this._requests;e<t.length;e++)t[e].abort();this._requests.length=0,delete this._progressCallback,this.preprocessUrlAsync=function(e){return Promise.resolve(e)},this.onMeshLoadedObservable.clear(),this.onSkinLoadedObservable.clear(),this.onTextureLoadedObservable.clear(),this.onMaterialLoadedObservable.clear(),this.onCameraLoadedObservable.clear(),this.onCompleteObservable.clear(),this.onExtensionLoadedObservable.clear(),this.onDisposeObservable.notifyObservers(void 0),this.onDisposeObservable.clear()},r.prototype.loadFile=function(e,n,r,o,a,i,s,l){var u=this;if(ArrayBuffer.isView(n))return this._loadBinary(e,n,r,o,s,l),null;this._progressCallback=a;var c=n.name||t.Tools.GetFilename(n);if(i){if(this.useRangeRequests){this.validate&&t.Logger.Warn("glTF validation is not supported when range requests are enabled");var f={abort:function(){},onCompleteObservable:new t.Observable},d={readAsync:function(t,r){return new Promise(function(o,a){u._loadFile(e,n,function(e){o(new Uint8Array(e))},!0,function(e){a(e)},function(e){e.setRequestHeader("Range","bytes=".concat(t,"-").concat(t+r-1))})})},byteLength:0};return this._unpackBinaryAsync(new t.DataReader(d)).then(function(e){f.onCompleteObservable.notifyObservers(f),o(e)},s?function(e){return s(void 0,e)}:void 0),f}return this._loadFile(e,n,function(n){u._validate(e,new Uint8Array(n,0,n.byteLength),r,c),u._unpackBinaryAsync(new t.DataReader({readAsync:function(e,t){return un(n,e,t)},byteLength:n.byteLength})).then(function(e){o(e)},s?function(e){return s(void 0,e)}:void 0)},!0,s)}return this._loadFile(e,n,function(t){try{u._validate(e,t,r,c),o({json:u._parseJson(t)})}catch(e){s&&s()}},!1,s)},r.prototype._loadBinary=function(e,n,r,o,a,i){this._validate(e,new Uint8Array(n.buffer,n.byteOffset,n.byteLength),r,i),this._unpackBinaryAsync(new t.DataReader({readAsync:function(e,t){return function(e,t,n){try{if(t<0||t>=e.byteLength)throw new RangeError("Offset is out of range.");if(t+n>e.byteLength)throw new RangeError("Length is out of range.");return Promise.resolve(new Uint8Array(e.buffer,e.byteOffset+t,n))}catch(e){return Promise.reject(e)}}(n,e,t)},byteLength:n.byteLength})).then(function(e){o(e)},a?function(e){return a(void 0,e)}:void 0)},r.prototype.importMeshAsync=function(e,t,n,r,o,a){var i=this;return Promise.resolve().then(function(){return i.onParsedObservable.notifyObservers(n),i.onParsedObservable.clear(),i._log("Loading ".concat(a||"")),i._loader=i._getLoader(n),i._loader.importMeshAsync(e,t,null,n,r,o,a)})},r.prototype.loadAsync=function(e,t,n,r,o){var a=this;return Promise.resolve().then(function(){return a.onParsedObservable.notifyObservers(t),a.onParsedObservable.clear(),a._log("Loading ".concat(o||"")),a._loader=a._getLoader(t),a._loader.loadAsync(e,t,n,r,o)})},r.prototype.loadAssetContainerAsync=function(e,n,r,o,a){var i=this;return Promise.resolve().then(function(){i.onParsedObservable.notifyObservers(n),i.onParsedObservable.clear(),i._log("Loading ".concat(a||"")),i._loader=i._getLoader(n);var s=new t.AssetContainer(e),l=[];i.onMaterialLoadedObservable.add(function(e){l.push(e)});var u=[];i.onTextureLoadedObservable.add(function(e){u.push(e)});var c=[];i.onCameraLoadedObservable.add(function(e){c.push(e)});var f=[];return i.onMeshLoadedObservable.add(function(e){e.morphTargetManager&&f.push(e.morphTargetManager)}),i._loader.importMeshAsync(null,e,s,n,r,o,a).then(function(e){return Array.prototype.push.apply(s.geometries,e.geometries),Array.prototype.push.apply(s.meshes,e.meshes),Array.prototype.push.apply(s.particleSystems,e.particleSystems),Array.prototype.push.apply(s.skeletons,e.skeletons),Array.prototype.push.apply(s.animationGroups,e.animationGroups),Array.prototype.push.apply(s.materials,l),Array.prototype.push.apply(s.textures,u),Array.prototype.push.apply(s.lights,e.lights),Array.prototype.push.apply(s.transformNodes,e.transformNodes),Array.prototype.push.apply(s.cameras,c),Array.prototype.push.apply(s.morphTargetManagers,f),s})})},r.prototype.canDirectLoad=function(e){return ln.canDirectLoad(e)},r.prototype.directLoad=function(e,n){if(n.startsWith("base64,"+sn)||n.startsWith(";base64,"+sn)||n.startsWith("application/octet-stream;base64,"+sn)||n.startsWith("model/gltf-binary;base64,"+sn)){var r=t.DecodeBase64UrlToBinary(n);return this._validate(e,new Uint8Array(r,0,r.byteLength)),this._unpackBinaryAsync(new t.DataReader({readAsync:function(e,t){return un(r,e,t)},byteLength:r.byteLength}))}return this._validate(e,n),Promise.resolve({json:this._parseJson(n)})},r.prototype.createPlugin=function(e){return new r(e[ln.name])},Object.defineProperty(r.prototype,"loaderState",{get:function(){return this._state},enumerable:!1,configurable:!0}),r.prototype.whenCompleteAsync=function(){var e=this;return new Promise(function(t,n){e.onCompleteObservable.addOnce(function(){t()}),e.onErrorObservable.addOnce(function(e){n(e)})})},r.prototype._setState=function(t){this._state!==t&&(this._state=t,this.onLoaderStateChangedObservable.notifyObservers(this._state),this._log(e.GLTFLoaderState[this._state]))},r.prototype._loadFile=function(e,t,n,r,o,a){var i=this,s=e._loadFile(t,n,function(e){i._onProgress(e,s)},!0,r,o,a);return s.onCompleteObservable.add(function(){s._lengthComputable=!0,s._total=s._loaded}),this._requests.push(s),s},r.prototype._onProgress=function(e,t){if(this._progressCallback){t._lengthComputable=e.lengthComputable,t._loaded=e.loaded,t._total=e.total;for(var n=!0,r=0,o=0,a=0,i=this._requests;a<i.length;a++){var s=i[a];if(void 0===s._lengthComputable||void 0===s._loaded||void 0===s._total)return;n=n&&s._lengthComputable,r+=s._loaded,o+=s._total}this._progressCallback({lengthComputable:n,loaded:r,total:n?o:0})}},r.prototype._validate=function(e,n,r,o){var a=this;void 0===r&&(r=""),void 0===o&&(o=""),this.validate&&(this._startPerformanceCounter("Validate JSON"),on.ValidateAsync(n,r,o,function(t){return a.preprocessUrlAsync(r+t).then(function(t){return e._loadFileAsync(t,void 0,!0,!0).then(function(e){return new Uint8Array(e,0,e.byteLength)})})}).then(function(e){a._endPerformanceCounter("Validate JSON"),a.onValidatedObservable.notifyObservers(e),a.onValidatedObservable.clear()},function(e){a._endPerformanceCounter("Validate JSON"),t.Tools.Warn("Failed to validate: ".concat(e.message)),a.onValidatedObservable.clear()}))},r.prototype._getLoader=function(e){var t=e.json.asset||{};this._log("Asset version: ".concat(t.version)),t.minVersion&&this._log("Asset minimum version: ".concat(t.minVersion)),t.generator&&this._log("Asset generator: ".concat(t.generator));var n=r._parseVersion(t.version);if(!n)throw new Error("Invalid version: "+t.version);if(void 0!==t.minVersion){var o=r._parseVersion(t.minVersion);if(!o)throw new Error("Invalid minimum version: "+t.minVersion);if(r._compareVersion(o,{major:2,minor:0})>0)throw new Error("Incompatible minimum version: "+t.minVersion)}var a={1:r._CreateGLTF1Loader,2:r._CreateGLTF2Loader}[n.major];if(!a)throw new Error("Unsupported version: "+t.version);return a(this)},r.prototype._parseJson=function(e){this._startPerformanceCounter("Parse JSON"),this._log("JSON length: ".concat(e.length));var t=JSON.parse(e);return this._endPerformanceCounter("Parse JSON"),t},r.prototype._unpackBinaryAsync=function(e){var n=this;return this._startPerformanceCounter("Unpack Binary"),e.loadAsync(20).then(function(){var r=e.readUint32();if(1179937895!==r)throw new t.RuntimeError("Unexpected magic: "+r,t.ErrorCodes.GLTFLoaderUnexpectedMagicError);var o=e.readUint32();n.loggingEnabled&&n._log("Binary version: ".concat(o));var a,i=e.readUint32();switch(n.useRangeRequests||i===e.buffer.byteLength||t.Logger.Warn("Length in header does not match actual data length: ".concat(i," != ").concat(e.buffer.byteLength)),o){case 1:a=n._unpackBinaryV1Async(e,i);break;case 2:a=n._unpackBinaryV2Async(e,i);break;default:throw new Error("Unsupported version: "+o)}return n._endPerformanceCounter("Unpack Binary"),a})},r.prototype._unpackBinaryV1Async=function(e,t){var n=e.readUint32(),r=e.readUint32();if(0!==r)throw new Error("Unexpected content format: ".concat(r));var o=t-e.byteOffset,a={json:this._parseJson(e.readString(n)),bin:null};if(0!==o){var i=e.byteOffset;a.bin={readAsync:function(t,n){return e.buffer.readAsync(i+t,n)},byteLength:o}}return Promise.resolve(a)},r.prototype._unpackBinaryV2Async=function(e,t){var n=this,r=1313821514,o=e.readUint32();if(e.readUint32()!==r)throw new Error("First chunk format is not JSON");return e.byteOffset+o===t?e.loadAsync(o).then(function(){return{json:n._parseJson(e.readString(o)),bin:null}}):e.loadAsync(o+8).then(function(){var a={json:n._parseJson(e.readString(o)),bin:null},i=function(){var n=e.readUint32();switch(e.readUint32()){case r:throw new Error("Unexpected JSON chunk");case 5130562:var o=e.byteOffset;a.bin={readAsync:function(t,n){return e.buffer.readAsync(o+t,n)},byteLength:n},e.skipBytes(n);break;default:e.skipBytes(n)}return e.byteOffset!==t?e.loadAsync(8).then(i):Promise.resolve(a)};return i()})},r._parseVersion=function(e){if("1.0"===e||"1.0.1"===e)return{major:1,minor:0};var t=(e+"").match(/^(\d+)\.(\d+)/);return t?{major:parseInt(t[1]),minor:parseInt(t[2])}:null},r._compareVersion=function(e,t){return e.major>t.major?1:e.major<t.major?-1:e.minor>t.minor?1:e.minor<t.minor?-1:0},r.prototype._logOpen=function(e){this._log(e),this._logIndentLevel++},r.prototype._logClose=function(){--this._logIndentLevel},r.prototype._logEnabled=function(e){var n=r._logSpaces.substring(0,2*this._logIndentLevel);t.Logger.Log("".concat(n).concat(e))},r.prototype._logDisabled=function(e){},r.prototype._startPerformanceCounterEnabled=function(e){t.Tools.StartPerformanceCounter(e)},r.prototype._startPerformanceCounterDisabled=function(e){},r.prototype._endPerformanceCounterEnabled=function(e){t.Tools.EndPerformanceCounter(e)},r.prototype._endPerformanceCounterDisabled=function(e){},r.IncrementalLoading=!0,r.HomogeneousCoordinates=!1,r._logSpaces=" ",r}(dn);t.RegisterSceneLoaderPlugin(new hn);var pn,mn,vn,_n,gn,yn,bn,xn,Tn={__proto__:null,GLTFFileLoader:hn,get GLTFLoaderAnimationStartMode(){return e.GLTFLoaderAnimationStartMode},get GLTFLoaderCoordinateSystemMode(){return e.GLTFLoaderCoordinateSystemMode},GLTFLoaderDefaultOptions:fn,get GLTFLoaderState(){return e.GLTFLoaderState}};!function(e){e[e.BYTE=5120]="BYTE",e[e.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",e[e.SHORT=5122]="SHORT",e[e.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",e[e.FLOAT=5126]="FLOAT"}(pn||(pn={})),function(e){e[e.FRAGMENT=35632]="FRAGMENT",e[e.VERTEX=35633]="VERTEX"}(mn||(mn={})),function(e){e[e.BYTE=5120]="BYTE",e[e.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",e[e.SHORT=5122]="SHORT",e[e.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",e[e.INT=5124]="INT",e[e.UNSIGNED_INT=5125]="UNSIGNED_INT",e[e.FLOAT=5126]="FLOAT",e[e.FLOAT_VEC2=35664]="FLOAT_VEC2",e[e.FLOAT_VEC3=35665]="FLOAT_VEC3",e[e.FLOAT_VEC4=35666]="FLOAT_VEC4",e[e.INT_VEC2=35667]="INT_VEC2",e[e.INT_VEC3=35668]="INT_VEC3",e[e.INT_VEC4=35669]="INT_VEC4",e[e.BOOL=35670]="BOOL",e[e.BOOL_VEC2=35671]="BOOL_VEC2",e[e.BOOL_VEC3=35672]="BOOL_VEC3",e[e.BOOL_VEC4=35673]="BOOL_VEC4",e[e.FLOAT_MAT2=35674]="FLOAT_MAT2",e[e.FLOAT_MAT3=35675]="FLOAT_MAT3",e[e.FLOAT_MAT4=35676]="FLOAT_MAT4",e[e.SAMPLER_2D=35678]="SAMPLER_2D"}(vn||(vn={})),function(e){e[e.CLAMP_TO_EDGE=33071]="CLAMP_TO_EDGE",e[e.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",e[e.REPEAT=10497]="REPEAT"}(_n||(_n={})),function(e){e[e.NEAREST=9728]="NEAREST",e[e.LINEAR=9728]="LINEAR",e[e.NEAREST_MIPMAP_NEAREST=9984]="NEAREST_MIPMAP_NEAREST",e[e.LINEAR_MIPMAP_NEAREST=9985]="LINEAR_MIPMAP_NEAREST",e[e.NEAREST_MIPMAP_LINEAR=9986]="NEAREST_MIPMAP_LINEAR",e[e.LINEAR_MIPMAP_LINEAR=9987]="LINEAR_MIPMAP_LINEAR"}(gn||(gn={})),function(e){e[e.ALPHA=6406]="ALPHA",e[e.RGB=6407]="RGB",e[e.RGBA=6408]="RGBA",e[e.LUMINANCE=6409]="LUMINANCE",e[e.LUMINANCE_ALPHA=6410]="LUMINANCE_ALPHA"}(yn||(yn={})),function(e){e[e.FRONT=1028]="FRONT",e[e.BACK=1029]="BACK",e[e.FRONT_AND_BACK=1032]="FRONT_AND_BACK"}(bn||(bn={})),function(e){e[e.ZERO=0]="ZERO",e[e.ONE=1]="ONE",e[e.SRC_COLOR=768]="SRC_COLOR",e[e.ONE_MINUS_SRC_COLOR=769]="ONE_MINUS_SRC_COLOR",e[e.DST_COLOR=774]="DST_COLOR",e[e.ONE_MINUS_DST_COLOR=775]="ONE_MINUS_DST_COLOR",e[e.SRC_ALPHA=770]="SRC_ALPHA",e[e.ONE_MINUS_SRC_ALPHA=771]="ONE_MINUS_SRC_ALPHA",e[e.DST_ALPHA=772]="DST_ALPHA",e[e.ONE_MINUS_DST_ALPHA=773]="ONE_MINUS_DST_ALPHA",e[e.CONSTANT_COLOR=32769]="CONSTANT_COLOR",e[e.ONE_MINUS_CONSTANT_COLOR=32770]="ONE_MINUS_CONSTANT_COLOR",e[e.CONSTANT_ALPHA=32771]="CONSTANT_ALPHA",e[e.ONE_MINUS_CONSTANT_ALPHA=32772]="ONE_MINUS_CONSTANT_ALPHA",e[e.SRC_ALPHA_SATURATE=776]="SRC_ALPHA_SATURATE"}(xn||(xn={}));var An,wn=function(){function e(){}return e.SetMatrix=function(e,n,r,o,a){var i=null;if("MODEL"===r.semantic?i=n.getWorldMatrix():"PROJECTION"===r.semantic?i=e.getProjectionMatrix():"VIEW"===r.semantic?i=e.getViewMatrix():"MODELVIEWINVERSETRANSPOSE"===r.semantic?i=t.Matrix.Transpose(n.getWorldMatrix().multiply(e.getViewMatrix()).invert()):"MODELVIEW"===r.semantic?i=n.getWorldMatrix().multiply(e.getViewMatrix()):"MODELVIEWPROJECTION"===r.semantic?i=n.getWorldMatrix().multiply(e.getTransformMatrix()):"MODELINVERSE"===r.semantic?i=n.getWorldMatrix().invert():"VIEWINVERSE"===r.semantic?i=e.getViewMatrix().invert():"PROJECTIONINVERSE"===r.semantic?i=e.getProjectionMatrix().invert():"MODELVIEWINVERSE"===r.semantic?i=n.getWorldMatrix().multiply(e.getViewMatrix()).invert():"MODELVIEWPROJECTIONINVERSE"===r.semantic?i=n.getWorldMatrix().multiply(e.getTransformMatrix()).invert():"MODELINVERSETRANSPOSE"===r.semantic&&(i=t.Matrix.Transpose(n.getWorldMatrix().invert())),i)switch(r.type){case vn.FLOAT_MAT2:a.setMatrix2x2(o,t.Matrix.GetAsMatrix2x2(i));break;case vn.FLOAT_MAT3:a.setMatrix3x3(o,t.Matrix.GetAsMatrix3x3(i));break;case vn.FLOAT_MAT4:a.setMatrix(o,i)}},e.SetUniform=function(e,n,r,o){switch(o){case vn.FLOAT:return e.setFloat(n,r),!0;case vn.FLOAT_VEC2:return e.setVector2(n,t.Vector2.FromArray(r)),!0;case vn.FLOAT_VEC3:return e.setVector3(n,t.Vector3.FromArray(r)),!0;case vn.FLOAT_VEC4:return e.setVector4(n,t.Vector4.FromArray(r)),!0;default:return!1}},e.GetWrapMode=function(e){switch(e){case _n.CLAMP_TO_EDGE:return t.Texture.CLAMP_ADDRESSMODE;case _n.MIRRORED_REPEAT:return t.Texture.MIRROR_ADDRESSMODE;case _n.REPEAT:default:return t.Texture.WRAP_ADDRESSMODE}},e.GetByteStrideFromType=function(e){switch(e.type){case"VEC2":return 2;case"VEC3":return 3;case"VEC4":case"MAT2":return 4;case"MAT3":return 9;case"MAT4":return 16;default:return 1}},e.GetTextureFilterMode=function(e){switch(e){case gn.LINEAR:case gn.LINEAR_MIPMAP_NEAREST:case gn.LINEAR_MIPMAP_LINEAR:return t.Texture.TRILINEAR_SAMPLINGMODE;case gn.NEAREST:case gn.NEAREST_MIPMAP_NEAREST:return t.Texture.NEAREST_SAMPLINGMODE;default:return t.Texture.BILINEAR_SAMPLINGMODE}},e.GetBufferFromBufferView=function(e,t,n,r,o){n=t.byteOffset+n;var a=e.loadedBufferViews[t.buffer];if(n+r>a.byteLength)throw new Error("Buffer access is out of range");var i=a.buffer;switch(n+=a.byteOffset,o){case pn.BYTE:return new Int8Array(i,n,r);case pn.UNSIGNED_BYTE:return new Uint8Array(i,n,r);case pn.SHORT:return new Int16Array(i,n,r);case pn.UNSIGNED_SHORT:return new Uint16Array(i,n,r);default:return new Float32Array(i,n,r)}},e.GetBufferFromAccessor=function(t,n){var r=t.bufferViews[n.bufferView],o=n.count*e.GetByteStrideFromType(n);return e.GetBufferFromBufferView(t,r,n.byteOffset,o,n.componentType)},e.DecodeBufferToText=function(e){for(var t="",n=e.byteLength,r=0;r<n;++r)t+=String.fromCharCode(e[r]);return t},e.GetDefaultMaterial=function(n){if(!e._DefaultMaterial){t.Effect.ShadersStore.GLTFDefaultMaterialVertexShader=["precision highp float;","","uniform mat4 worldView;","uniform mat4 projection;","","attribute vec3 position;","","void main(void)","{"," gl_Position = projection * worldView * vec4(position, 1.0);","}"].join("\n"),t.Effect.ShadersStore.GLTFDefaultMaterialPixelShader=["precision highp float;","","uniform vec4 u_emission;","","void main(void)","{"," gl_FragColor = u_emission;","}"].join("\n");var r={attributes:["position"],uniforms:["worldView","projection","u_emission"],samplers:new Array,needAlphaBlending:!1};e._DefaultMaterial=new t.ShaderMaterial("GLTFDefaultMaterial",n,{vertex:"GLTFDefaultMaterial",fragment:"GLTFDefaultMaterial"},r),e._DefaultMaterial.setColor4("u_emission",new t.Color4(.5,.5,.5,1))}return e._DefaultMaterial},e._DefaultMaterial=null,e}();!function(e){e[e.IDENTIFIER=1]="IDENTIFIER",e[e.UNKNOWN=2]="UNKNOWN",e[e.END_OF_INPUT=3]="END_OF_INPUT"}(An||(An={}));var Mn=function(){function e(e){this._pos=0,this.currentToken=An.UNKNOWN,this.currentIdentifier="",this.currentString="",this.isLetterOrDigitPattern=/^[a-zA-Z0-9]+$/,this._toParse=e,this._maxPos=e.length}return e.prototype.getNextToken=function(){if(this.isEnd())return An.END_OF_INPUT;if(this.currentString=this.read(),this.currentToken=An.UNKNOWN,"_"===this.currentString||this.isLetterOrDigitPattern.test(this.currentString))for(this.currentToken=An.IDENTIFIER,this.currentIdentifier=this.currentString;!this.isEnd()&&(this.isLetterOrDigitPattern.test(this.currentString=this.peek())||"_"===this.currentString);)this.currentIdentifier+=this.currentString,this.forward();return this.currentToken},e.prototype.peek=function(){return this._toParse[this._pos]},e.prototype.read=function(){return this._toParse[this._pos++]},e.prototype.forward=function(){this._pos++},e.prototype.isEnd=function(){return this._pos>=this._maxPos},e}(),Cn=["MODEL","VIEW","PROJECTION","MODELVIEW","MODELVIEWPROJECTION","JOINTMATRIX"],On=["world","view","projection","worldView","worldViewProjection","mBones"],Sn=["translation","rotation","scale"],En=["position","rotationQuaternion","scaling"],Fn=function(e,t,n){for(var r in e){var o=e[r];n[t][r]=o}},Rn=function(e){if(e)for(var t=0;t<e.length/2;t++)e[2*t+1]=1-e[2*t+1]},Ln=function(e){if("NORMAL"===e.semantic)return"normal";if("POSITION"===e.semantic)return"position";if("JOINT"===e.semantic)return"matricesIndices";if("WEIGHT"===e.semantic)return"matricesWeights";if("COLOR"===e.semantic)return"color";if(e.semantic&&-1!==e.semantic.indexOf("TEXCOORD_")){var t=Number(e.semantic.split("_")[1]);return"uv"+(0===t?"":t+1)}return null},In=function(e){var n;if(e.translation||e.rotation||e.scale){var r=t.Vector3.FromArray(e.scale||[1,1,1]),o=t.Quaternion.FromArray(e.rotation||[0,0,0,1]),a=t.Vector3.FromArray(e.translation||[0,0,0]);n=t.Matrix.Compose(r,o,a)}else n=t.Matrix.FromArray(e.matrix);return n},Pn=function(e,n,r,o){for(var a=0;a<o.bones.length;a++)if(o.bones[a].name===r)return o.bones[a];var i=e.nodes;for(var s in i){var l=i[s];if(l.jointName){var u=l.children;for(a=0;a<u.length;a++){var c=e.nodes[u[a]];if(c.jointName&&c.jointName===r){var f=In(l),d=new t.Bone(l.name||"",o,Pn(e,n,l.jointName,o),f);return d.id=s,d}}}}return null},Nn=function(e,t){for(var n=0;n<e.length;n++)for(var r=e[n],o=0;o<r.node.children.length;o++)if(r.node.children[o]===t)return r.bone;return null},Bn=function(e,t){var n=e.nodes,r=n[t];if(r)return{node:r,id:t};for(var o in n)if((r=n[o]).jointName===t)return{node:r,id:o};return null},kn=function(e,t){for(var n=0;n<e.jointNames.length;n++)if(e.jointNames[n]===t)return!0;return!1},Dn=function(e,n,r,o,a){if(a||(e.scene._blockEntityCollection=!!e.assetContainer,(a=new t.Mesh(n.name||"",e.scene))._parentContainer=e.assetContainer,e.scene._blockEntityCollection=!1,a.id=o),!n.babylonNode)return a;for(var i,s=[],l=null,u=[],c=[],f=[],d=[],h=0;h<r.length;h++){var p=r[h];if(E=e.meshes[p])for(var m=0;m<E.primitives.length;m++){var v=new t.VertexData,_=E.primitives[m];_.mode;var g=_.attributes,y=void 0,b=void 0;for(var x in g)if(y=e.accessors[g[x]],b=wn.GetBufferFromAccessor(e,y),"NORMAL"===x)v.normals=new Float32Array(b.length),v.normals.set(b);else if("POSITION"===x){if(hn.HomogeneousCoordinates){v.positions=new Float32Array(b.length-b.length/4);for(var T=0;T<b.length;T+=4)v.positions[T]=b[T],v.positions[T+1]=b[T+1],v.positions[T+2]=b[T+2]}else v.positions=new Float32Array(b.length),v.positions.set(b);c.push(v.positions.length)}else if(-1!==x.indexOf("TEXCOORD_")){var A=Number(x.split("_")[1]),w=t.VertexBuffer.UVKind+(0===A?"":A+1),M=new Float32Array(b.length);M.set(b),Rn(M),v.set(M,w)}else"JOINT"===x?(v.matricesIndices=new Float32Array(b.length),v.matricesIndices.set(b)):"WEIGHT"===x?(v.matricesWeights=new Float32Array(b.length),v.matricesWeights.set(b)):"COLOR"===x&&(v.colors=new Float32Array(b.length),v.colors.set(b));if(y=e.accessors[_.indices])b=wn.GetBufferFromAccessor(e,y),v.indices=new Int32Array(b.length),v.indices.set(b),d.push(v.indices.length);else{var C=[];for(T=0;T<v.positions.length/3;T++)C.push(T);v.indices=new Int32Array(C),d.push(v.indices.length)}l?l.merge(v):l=v;var O=e.scene.getMaterialById(_.material);s.push(null===O?wn.GetDefaultMaterial(e.scene):O),u.push(0===u.length?0:u[u.length-1]+c[c.length-2]),f.push(0===f.length?0:f[f.length-1]+d[d.length-2])}}e.scene._blockEntityCollection=!!e.assetContainer,s.length>1?(i=new t.MultiMaterial("multimat"+o,e.scene)).subMaterials=s:i=new t.StandardMaterial("multimat"+o,e.scene),1===s.length&&(i=s[0]),i._parentContainer=e.assetContainer,a.material||(a.material=i),new t.Geometry(o,e.scene,l,!1,a),a.computeWorldMatrix(!0),e.scene._blockEntityCollection=!1,a.subMeshes=[];var S=0;for(h=0;h<r.length;h++){var E;if(p=r[h],E=e.meshes[p])for(m=0;m<E.primitives.length;m++)E.primitives[m].mode,t.SubMesh.AddToMesh(S,u[S],c[S],f[S],d[S],a,a,!0),S++}return a},Gn=function(e,t,n,r){e.position&&(e.position=t),(e.rotationQuaternion||e.rotation)&&(e.rotationQuaternion=n),e.scaling&&(e.scaling=r)},Vn=function(e,n,r){var o=null;if(e.importOnlyMeshes&&(n.skin||n.meshes)&&e.importMeshesNames&&e.importMeshesNames.length>0&&-1===e.importMeshesNames.indexOf(n.name||""))return null;if(n.skin){if(n.meshes){var a=e.skins[n.skin];(i=Dn(e,n,n.meshes,r,n.babylonNode)).skeleton=e.scene.getLastSkeletonById(n.skin),null===i.skeleton&&(i.skeleton=function(e,n,r,o){if(o||(o=new t.Skeleton(n.name||"","",e.scene)),!n.babylonSkeleton)return o;var a=[],i=[];!function(e,n,r,o){for(var a in e.nodes){var i=e.nodes[a],s=a;if(i.jointName&&!kn(r,i.jointName)){var l=In(i),u=new t.Bone(i.name||"",n,null,l);u.id=s,o.push({bone:u,node:i,id:s})}}for(var c=0;c<o.length;c++)for(var f=o[c],d=f.node.children,h=0;h<d.length;h++){for(var p=null,m=0;m<o.length;m++)if(o[m].id===d[h]){p=o[m];break}p&&(p.bone._parent=f.bone,f.bone.children.push(p.bone))}}(e,o,n,a),o.bones=[];for(var s=0;s<n.jointNames.length;s++)if(b=Bn(e,n.jointNames[s])){var l=b.node;if(l){var u=b.id,c=e.scene.getBoneById(u);if(c)o.bones.push(c);else{for(var f=void 0,d=null,h=0;h<s;h++){var p=Bn(e,n.jointNames[h]);if(p){var m=p.node;if(m){var v=m.children;if(v){f=!1;for(var _=0;_<v.length;_++)if(v[_]===u){d=Pn(e,n,n.jointNames[h],o),f=!0;break}if(f)break}}else t.Tools.Warn("Joint named "+n.jointNames[h]+" does not exist when looking for parent")}}var g=In(l);!d&&a.length>0&&(d=Nn(a,u))&&-1===i.indexOf(d)&&i.push(d),new t.Bone(l.jointName||"",o,d,g).id=u}}else t.Tools.Warn("Joint named "+n.jointNames[s]+" does not exist")}var y=o.bones;for(o.bones=[],s=0;s<n.jointNames.length;s++){var b;if(b=Bn(e,n.jointNames[s]))for(h=0;h<y.length;h++)if(y[h].id===b.id){o.bones.push(y[h]);break}}for(o.prepare(),s=0;s<i.length;s++)o.bones.push(i[s]);return o}(e,a,0,a.babylonSkeleton),a.babylonSkeleton||(a.babylonSkeleton=i.skeleton)),o=i}}else if(n.meshes){var i;o=i=Dn(e,n,n.mesh?[n.mesh]:n.meshes,r,n.babylonNode)}else if(!n.light||n.babylonNode||e.importOnlyMeshes){if(n.camera&&!n.babylonNode&&!e.importOnlyMeshes){var s=e.cameras[n.camera];if(s){if(e.scene._blockEntityCollection=!!e.assetContainer,"orthographic"===s.type){var l=new t.FreeCamera(n.camera,t.Vector3.Zero(),e.scene,!1);l.name=n.name||"",l.mode=t.Camera.ORTHOGRAPHIC_CAMERA,l.attachControl(),o=l,l._parentContainer=e.assetContainer}else if("perspective"===s.type){var u=s[s.type],c=new t.FreeCamera(n.camera,t.Vector3.Zero(),e.scene,!1);c.name=n.name||"",c.attachControl(),u.aspectRatio||(u.aspectRatio=e.scene.getEngine().getRenderWidth()/e.scene.getEngine().getRenderHeight()),u.znear&&u.zfar&&(c.maxZ=u.zfar,c.minZ=u.znear),o=c,c._parentContainer=e.assetContainer}e.scene._blockEntityCollection=!1}}}else{var f=e.lights[n.light];if(f)if("ambient"===f.type){var d=f[f.type],h=new t.HemisphericLight(n.light,t.Vector3.Zero(),e.scene);h.name=n.name||"",d.color&&(h.diffuse=t.Color3.FromArray(d.color)),o=h}else if("directional"===f.type){var p=f[f.type],m=new t.DirectionalLight(n.light,t.Vector3.Zero(),e.scene);m.name=n.name||"",p.color&&(m.diffuse=t.Color3.FromArray(p.color)),o=m}else if("point"===f.type){var v=f[f.type],_=new t.PointLight(n.light,t.Vector3.Zero(),e.scene);_.name=n.name||"",v.color&&(_.diffuse=t.Color3.FromArray(v.color)),o=_}else if("spot"===f.type){var g=f[f.type],y=new t.SpotLight(n.light,t.Vector3.Zero(),t.Vector3.Zero(),0,0,e.scene);y.name=n.name||"",g.color&&(y.diffuse=t.Color3.FromArray(g.color)),g.fallOfAngle&&(y.angle=g.fallOfAngle),g.fallOffExponent&&(y.exponent=g.fallOffExponent),o=y}}if(!n.jointName){if(n.babylonNode)return n.babylonNode;if(null===o){e.scene._blockEntityCollection=!!e.assetContainer;var b=new t.Mesh(n.name||"",e.scene);b._parentContainer=e.assetContainer,e.scene._blockEntityCollection=!1,n.babylonNode=b,o=b}}if(null!==o){if(n.matrix&&o instanceof t.Mesh)!function(e,n){if(n.matrix){var r=new t.Vector3(0,0,0),o=new t.Quaternion,a=new t.Vector3(0,0,0);t.Matrix.FromArray(n.matrix).decompose(a,o,r),Gn(e,r,o,a)}else n.translation&&n.rotation&&n.scale&&Gn(e,t.Vector3.FromArray(n.translation),t.Quaternion.FromArray(n.rotation),t.Vector3.FromArray(n.scale));e.computeWorldMatrix(!0)}(o,n);else{var x=n.translation||[0,0,0],T=n.rotation||[0,0,0,1],A=n.scale||[1,1,1];Gn(o,t.Vector3.FromArray(x),t.Quaternion.FromArray(T),t.Vector3.FromArray(A))}o.updateCache(!0),n.babylonNode=o}return o},Hn=function(e,t,n,r){void 0===r&&(r=!1);var o=e.nodes[t],a=null;if(r=!(e.importOnlyMeshes&&!r&&e.importMeshesNames)||-1!==e.importMeshesNames.indexOf(o.name||"")||0===e.importMeshesNames.length,!o.jointName&&r&&null!==(a=Vn(e,o,t))&&(a.id=t,a.parent=n),o.children)for(var i=0;i<o.children.length;i++)Hn(e,o.children[i],a,r)},Un=function(e){var n=e.currentScene;if(n)for(var r=0;r<n.nodes.length;r++)Hn(e,n.nodes[r],null);else for(var o in e.scenes)for(n=e.scenes[o],r=0;r<n.nodes.length;r++)Hn(e,n.nodes[r],null);for(function(e){for(var n in e.animations){var r=e.animations[n];if(r.channels&&r.samplers)for(var o=null,a=0;a<r.channels.length;a++){var i=r.channels[a],s=r.samplers[i.sampler];if(s){var l=void 0,u=void 0;r.parameters?(l=r.parameters[s.input],u=r.parameters[s.output]):(l=s.input,u=s.output);var c=wn.GetBufferFromAccessor(e,e.accessors[l]),f=wn.GetBufferFromAccessor(e,e.accessors[u]),d=i.target.id,h=e.scene.getNodeById(d);if(null===h&&(h=e.scene.getNodeByName(d)),null!==h){var p=h instanceof t.Bone,m=i.target.path,v=Sn.indexOf(m);-1!==v&&(m=En[v]);var _=t.Animation.ANIMATIONTYPE_MATRIX;p||("rotationQuaternion"===m?(_=t.Animation.ANIMATIONTYPE_QUATERNION,h.rotationQuaternion=new t.Quaternion):_=t.Animation.ANIMATIONTYPE_VECTOR3);var g=null,y=[],b=0,x=!1;p&&o&&o.getKeys().length===c.length&&(g=o,x=!0),x||(e.scene._blockEntityCollection=!!e.assetContainer,g=new t.Animation(n,p?"_matrix":m,1,_,t.Animation.ANIMATIONLOOPMODE_CYCLE),e.scene._blockEntityCollection=!1);for(var T=0;T<c.length;T++){var A=void 0;if("rotationQuaternion"===m?(A=t.Quaternion.FromArray([f[b],f[b+1],f[b+2],f[b+3]]),b+=4):(A=t.Vector3.FromArray([f[b],f[b+1],f[b+2]]),b+=3),p){var w=h,M=t.Vector3.Zero(),C=new t.Quaternion,O=t.Vector3.Zero(),S=w.getBaseMatrix();x&&o&&(S=o.getKeys()[T].value),S.decompose(O,C,M),"position"===m?M=A:"rotationQuaternion"===m?C=A:O=A,A=t.Matrix.Compose(O,C,M)}x?o&&(o.getKeys()[T].value=A):y.push({frame:c[T],value:A})}!x&&g&&(g.setKeys(y),h.animations.push(g)),o=g,e.scene.stopAnimation(h),e.scene.beginAnimation(h,0,c[c.length-1],!0,1)}else t.Tools.Warn("Creating animation named "+n+". But cannot find node named "+d+" to attach to")}}}}(e),r=0;r<e.scene.skeletons.length;r++){var a=e.scene.skeletons[r];e.scene.beginAnimation(a,0,Number.MAX_VALUE,!0,1)}},jn=function(e,t,n){for(var r in t.uniforms){var o=t.uniforms[r],a=t.parameters[o];if(e.currentIdentifier===r&&a.semantic&&!a.source&&!a.node){var i=Cn.indexOf(a.semantic);if(-1!==i)return delete n[r],On[i]}}return e.currentIdentifier},Kn=function(e){for(var t in e.materials)qn.LoadMaterialAsync(e,t,function(){},function(){})},Wn=function(){function e(){}return e.CreateRuntime=function(e,t,n){var r={extensions:{},accessors:{},buffers:{},bufferViews:{},meshes:{},lights:{},cameras:{},nodes:{},images:{},textures:{},shaders:{},programs:{},samplers:{},techniques:{},materials:{},animations:{},skins:{},extensionsUsed:[],scenes:{},buffersCount:0,shaderscount:0,scene:t,rootUrl:n,loadedBufferCount:0,loadedBufferViews:{},loadedShaderCount:0,importOnlyMeshes:!1,dummyNodes:[],assetContainer:null};return e.extensions&&Fn(e.extensions,"extensions",r),e.extensionsUsed&&Fn(e.extensionsUsed,"extensionsUsed",r),e.buffers&&function(e,t){for(var n in e){var r=e[n];t.buffers[n]=r,t.buffersCount++}}(e.buffers,r),e.bufferViews&&Fn(e.bufferViews,"bufferViews",r),e.accessors&&Fn(e.accessors,"accessors",r),e.meshes&&Fn(e.meshes,"meshes",r),e.lights&&Fn(e.lights,"lights",r),e.cameras&&Fn(e.cameras,"cameras",r),e.nodes&&Fn(e.nodes,"nodes",r),e.images&&Fn(e.images,"images",r),e.textures&&Fn(e.textures,"textures",r),e.shaders&&function(e,t){for(var n in e){var r=e[n];t.shaders[n]=r,t.shaderscount++}}(e.shaders,r),e.programs&&Fn(e.programs,"programs",r),e.samplers&&Fn(e.samplers,"samplers",r),e.techniques&&Fn(e.techniques,"techniques",r),e.materials&&Fn(e.materials,"materials",r),e.animations&&Fn(e.animations,"animations",r),e.skins&&Fn(e.skins,"skins",r),e.scenes&&(r.scenes=e.scenes),e.scene&&e.scenes&&(r.currentScene=e.scenes[e.scene]),r},e.LoadBufferAsync=function(e,n,r,o,a){var i=e.buffers[n];t.Tools.IsBase64(i.uri)?setTimeout(function(){return r(new Uint8Array(t.Tools.DecodeBase64(i.uri)))}):t.Tools.LoadFile(e.rootUrl+i.uri,function(e){return r(new Uint8Array(e))},a,void 0,!0,function(e){e&&o(e.status+" "+e.statusText)})},e.LoadTextureBufferAsync=function(e,n,r,o){var a=e.textures[n];if(a&&a.source)if(a.babylonTexture)r(null);else{var i=e.images[a.source];t.Tools.IsBase64(i.uri)?setTimeout(function(){return r(new Uint8Array(t.Tools.DecodeBase64(i.uri)))}):t.Tools.LoadFile(e.rootUrl+i.uri,function(e){return r(new Uint8Array(e))},void 0,void 0,!0,function(e){e&&o(e.status+" "+e.statusText)})}else o("")},e.CreateTextureAsync=function(e,n,r,o){var a=e.textures[n];if(a.babylonTexture)o(a.babylonTexture);else{var i=e.samplers[a.sampler],s=i.minFilter===gn.NEAREST_MIPMAP_NEAREST||i.minFilter===gn.NEAREST_MIPMAP_LINEAR||i.minFilter===gn.LINEAR_MIPMAP_NEAREST||i.minFilter===gn.LINEAR_MIPMAP_LINEAR,l=t.Texture.BILINEAR_SAMPLINGMODE,u=null==r?new Blob:new Blob([t.GetBlobBufferSource(r)]),c=URL.createObjectURL(u),f=function(){return URL.revokeObjectURL(c)},d=new t.Texture(c,e.scene,!s,!0,l,f,f);void 0!==i.wrapS&&(d.wrapU=wn.GetWrapMode(i.wrapS)),void 0!==i.wrapT&&(d.wrapV=wn.GetWrapMode(i.wrapT)),d.name=n,a.babylonTexture=d,o(d)}},e.LoadShaderStringAsync=function(e,n,r,o){var a=e.shaders[n];if(t.Tools.IsBase64(a.uri)){var i=atob(a.uri.split(",")[1]);r&&r(i)}else t.Tools.LoadFile(e.rootUrl+a.uri,r,void 0,void 0,!1,function(e){e&&o&&o(e.status+" "+e.statusText)})},e.LoadMaterialAsync=function(e,n,r,o){var a=e.materials[n];if(a.technique){var i=e.techniques[a.technique];if(!i){e.scene._blockEntityCollection=!!e.assetContainer;var s=new t.StandardMaterial(n,e.scene);return s._parentContainer=e.assetContainer,e.scene._blockEntityCollection=!1,s.diffuseColor=new t.Color3(.5,.5,.5),s.sideOrientation=t.Material.CounterClockWiseSideOrientation,void r(s)}var l=e.programs[i.program],u=i.states,c=t.Effect.ShadersStore[l.vertexShader+"VertexShader"],f=t.Effect.ShadersStore[l.fragmentShader+"PixelShader"],d="",h="",p=new Mn(c),m=new Mn(f),v={},_=[],g=[],y=[];for(var b in i.uniforms){var x=i.uniforms[b],T=i.parameters[x];if(v[b]=T,!T.semantic||T.node||T.source)T.type===vn.SAMPLER_2D?y.push(b):_.push(b);else{var A=Cn.indexOf(T.semantic);-1!==A?(_.push(On[A]),delete v[b]):_.push(b)}}for(var w in i.attributes){var M=i.attributes[w];if((S=i.parameters[M]).semantic){var C=Ln(S);C&&g.push(C)}}for(;!p.isEnd()&&p.getNextToken();)if(p.currentToken===An.IDENTIFIER){var O=!1;for(var w in i.attributes){M=i.attributes[w];var S=i.parameters[M];if(p.currentIdentifier===w&&S.semantic){d+=Ln(S),O=!0;break}}O||(d+=jn(p,i,v))}else d+=p.currentString;for(;!m.isEnd()&&m.getNextToken();)m.currentToken===An.IDENTIFIER?h+=jn(m,i,v):h+=m.currentString;var E={vertex:l.vertexShader+n,fragment:l.fragmentShader+n},F={attributes:g,uniforms:_,samplers:y,needAlphaBlending:u&&u.enable&&-1!==u.enable.indexOf(3042)};t.Effect.ShadersStore[l.vertexShader+n+"VertexShader"]=d,t.Effect.ShadersStore[l.fragmentShader+n+"PixelShader"]=h;var R=new t.ShaderMaterial(n,e.scene,E,F);if(R.onError=function(e,t,n){return function(r,o){t.dispose(!0),n("Cannot compile program named "+e.name+". Error: "+o+". Default material will be applied")}}(l,R,o),R.onCompiled=function(e,t,n,r,o,a){return function(i){!function(e,t,n,r,o){var a=r.values||n.parameters,i=n.uniforms,s=function(n){var s=o[n],l=s.type,u=a[i[n]];if(void 0===u&&(u=s.value),!u)return"continue";var c=function(e){return function(n){s.value&&e&&(t.setTexture(e,n),delete o[e])}};l===vn.SAMPLER_2D?qn.LoadTextureAsync(e,r.values?u:s.value,c(n),function(){return c(null)}):s.value&&wn.SetUniform(t,n,r.values?u:s.value,l)&&delete o[n]};for(var l in o)s(l)}(e,t,n,r,o),t.onBind=function(i){!function(e,t,n,r,o,a,i){var s=a.values||o.parameters;for(var l in n){var u=n[l],c=u.type;if(c===vn.FLOAT_MAT2||c===vn.FLOAT_MAT3||c===vn.FLOAT_MAT4)if(!u.semantic||u.source||u.node){if(u.semantic&&(u.source||u.node)){var f=t.scene.getNodeByName(u.source||u.node||"");if(null===f&&(f=t.scene.getNodeById(u.source||u.node||"")),null===f)continue;wn.SetMatrix(t.scene,f,u,l,r.getEffect())}}else wn.SetMatrix(t.scene,e,u,l,r.getEffect());else{var d=s[o.uniforms[l]];if(!d)continue;if(c===vn.SAMPLER_2D){var h=t.textures[a.values?d:u.value].babylonTexture;if(null==h)continue;r.getEffect().setTexture(l,h)}else wn.SetUniform(r.getEffect(),l,d,c)}}i(r)}(i,e,o,t,n,r,a)}}}(e,R,i,a,v,r),R.sideOrientation=t.Material.CounterClockWiseSideOrientation,u&&u.functions){var L=u.functions;L.cullFace&&L.cullFace[0]!==bn.BACK&&(R.backFaceCulling=!1);var I=L.blendFuncSeparate;I&&(I[0]===xn.SRC_ALPHA&&I[1]===xn.ONE_MINUS_SRC_ALPHA&&I[2]===xn.ONE&&I[3]===xn.ONE?R.alphaMode=t.Constants.ALPHA_COMBINE:I[0]===xn.ONE&&I[1]===xn.ONE&&I[2]===xn.ZERO&&I[3]===xn.ONE?R.alphaMode=t.Constants.ALPHA_ONEONE:I[0]===xn.SRC_ALPHA&&I[1]===xn.ONE&&I[2]===xn.ZERO&&I[3]===xn.ONE?R.alphaMode=t.Constants.ALPHA_ADD:I[0]===xn.ZERO&&I[1]===xn.ONE_MINUS_SRC_COLOR&&I[2]===xn.ONE&&I[3]===xn.ONE?R.alphaMode=t.Constants.ALPHA_SUBTRACT:I[0]===xn.DST_COLOR&&I[1]===xn.ZERO&&I[2]===xn.ONE&&I[3]===xn.ONE?R.alphaMode=t.Constants.ALPHA_MULTIPLY:I[0]===xn.SRC_ALPHA&&I[1]===xn.ONE_MINUS_SRC_COLOR&&I[2]===xn.ONE&&I[3]===xn.ONE&&(R.alphaMode=t.Constants.ALPHA_MAXIMIZED))}}else o&&o("No technique found.")},e}(),zn=function(){function e(){}return e.RegisterExtension=function(n){e.Extensions[n.name]?t.Tools.Error('Tool with the same name "'+n.name+'" already exists'):e.Extensions[n.name]=n},e.prototype.dispose=function(){},e.prototype._importMeshAsync=function(e,n,r,o,a,i,s,l){var u=this;return n.useRightHandedSystem=!0,qn.LoadRuntimeAsync(n,r,o,function(n){n.assetContainer=a,n.importOnlyMeshes=!0,""===e?n.importMeshesNames=[]:"string"==typeof e?n.importMeshesNames=[e]:!e||e instanceof Array?(n.importMeshesNames=[],t.Tools.Warn("Argument meshesNames must be of type string or string[]")):n.importMeshesNames=[e],u._createNodes(n);var r=[],o=[];for(var s in n.nodes){var l=n.nodes[s];l.babylonNode instanceof t.AbstractMesh&&r.push(l.babylonNode)}for(var c in n.skins){var f=n.skins[c];f.babylonSkeleton instanceof t.Skeleton&&o.push(f.babylonSkeleton)}u._loadBuffersAsync(n,function(){u._loadShadersAsync(n,function(){Kn(n),Un(n),!hn.IncrementalLoading&&i&&i(r,o)})}),hn.IncrementalLoading&&i&&i(r,o)},l),!0},e.prototype.importMeshAsync=function(e,t,n,r,o,a){var i=this;return new Promise(function(s,l){i._importMeshAsync(e,t,r,o,n,function(e,t){s({meshes:e,particleSystems:[],skeletons:t,animationGroups:[],lights:[],transformNodes:[],geometries:[],spriteManagers:[]})},a,function(e){l(new Error(e))})})},e.prototype._loadAsync=function(e,t,n,r,o,a){var i=this;e.useRightHandedSystem=!0,qn.LoadRuntimeAsync(e,t,n,function(e){qn.LoadRuntimeExtensionsAsync(e,function(){i._createNodes(e),i._loadBuffersAsync(e,function(){i._loadShadersAsync(e,function(){Kn(e),Un(e),hn.IncrementalLoading||r()})}),hn.IncrementalLoading&&r()},a)},a)},e.prototype.loadAsync=function(e,t,n,r){return _(this,void 0,void 0,function(){var o=this;return g(this,function(a){switch(a.label){case 0:return[4,new Promise(function(a,i){o._loadAsync(e,t,n,function(){a()},r,function(e){i(new Error(e))})})];case 1:return[2,a.sent()]}})})},e.prototype._loadShadersAsync=function(e,n){var r=!1,o=function(r,o){qn.LoadShaderStringAsync(e,r,function(a){a instanceof ArrayBuffer||(e.loadedShaderCount++,a&&(t.Effect.ShadersStore[r+(o.type===mn.VERTEX?"VertexShader":"PixelShader")]=a),e.loadedShaderCount===e.shaderscount&&n())},function(){t.Tools.Error("Error when loading shader program named "+r+" located at "+o.uri)})};for(var a in e.shaders){r=!0;var i=e.shaders[a];i?o.bind(this,a,i)():t.Tools.Error("No shader named: "+a)}r||n()},e.prototype._loadBuffersAsync=function(e,n){var r=!1,o=function(r,o){qn.LoadBufferAsync(e,r,function(a){e.loadedBufferCount++,a&&(a.byteLength!=e.buffers[r].byteLength&&t.Tools.Error("Buffer named "+r+" is length "+a.byteLength+". Expected: "+o.byteLength),e.loadedBufferViews[r]=a),e.loadedBufferCount===e.buffersCount&&n()},function(){t.Tools.Error("Error when loading buffer named "+r+" located at "+o.uri)})};for(var a in e.buffers){r=!0;var i=e.buffers[a];i?o.bind(this,a,i)():t.Tools.Error("No buffer named: "+a)}r||n()},e.prototype._createNodes=function(e){var t=e.currentScene;if(t)for(var n=0;n<t.nodes.length;n++)Hn(e,t.nodes[n],null);else for(var r in e.scenes)for(t=e.scenes[r],n=0;n<t.nodes.length;n++)Hn(e,t.nodes[n],null)},e.Extensions={},e}(),qn=function(){function e(e){this._name=e}return Object.defineProperty(e.prototype,"name",{get:function(){return this._name},enumerable:!1,configurable:!0}),e.prototype.loadRuntimeAsync=function(e,t,n,r,o){return!1},e.prototype.loadRuntimeExtensionsAsync=function(e,t,n){return!1},e.prototype.loadBufferAsync=function(e,t,n,r,o){return!1},e.prototype.loadTextureBufferAsync=function(e,t,n,r){return!1},e.prototype.createTextureAsync=function(e,t,n,r,o){return!1},e.prototype.loadShaderStringAsync=function(e,t,n,r){return!1},e.prototype.loadMaterialAsync=function(e,t,n,r){return!1},e.LoadRuntimeAsync=function(t,n,r,o,a){e._ApplyExtensions(function(e){return e.loadRuntimeAsync(t,n,r,o,a)},function(){setTimeout(function(){o&&o(Wn.CreateRuntime(n.json,t,r))})})},e.LoadRuntimeExtensionsAsync=function(t,n,r){e._ApplyExtensions(function(e){return e.loadRuntimeExtensionsAsync(t,n,r)},function(){setTimeout(function(){n()})})},e.LoadBufferAsync=function(t,n,r,o,a){e._ApplyExtensions(function(e){return e.loadBufferAsync(t,n,r,o,a)},function(){Wn.LoadBufferAsync(t,n,r,o,a)})},e.LoadTextureAsync=function(t,n,r,o){e._LoadTextureBufferAsync(t,n,function(a){a&&e._CreateTextureAsync(t,n,a,r,o)},o)},e.LoadShaderStringAsync=function(t,n,r,o){e._ApplyExtensions(function(e){return e.loadShaderStringAsync(t,n,r,o)},function(){Wn.LoadShaderStringAsync(t,n,r,o)})},e.LoadMaterialAsync=function(t,n,r,o){e._ApplyExtensions(function(e){return e.loadMaterialAsync(t,n,r,o)},function(){Wn.LoadMaterialAsync(t,n,r,o)})},e._LoadTextureBufferAsync=function(t,n,r,o){e._ApplyExtensions(function(e){return e.loadTextureBufferAsync(t,n,r,o)},function(){Wn.LoadTextureBufferAsync(t,n,r,o)})},e._CreateTextureAsync=function(t,n,r,o,a){e._ApplyExtensions(function(e){return e.createTextureAsync(t,n,r,o,a)},function(){Wn.CreateTextureAsync(t,n,r,o)})},e._ApplyExtensions=function(e,t){for(var n in zn.Extensions)if(e(zn.Extensions[n]))return;t()},e}();hn._CreateGLTF1Loader=function(){return new zn};var Xn=function(e){function t(){return e.call(this,"KHR_binary_glTF")||this}return m(t,e),t.prototype.loadRuntimeAsync=function(e,t,n,r){var o=t.json.extensionsUsed;return!(!o||-1===o.indexOf(this.name)||!t.bin||(this._bin=t.bin,r(Wn.CreateRuntime(t.json,e,n)),0))},t.prototype.loadBufferAsync=function(e,t,n,r){return-1!==e.extensionsUsed.indexOf(this.name)&&"binary_glTF"===t&&(this._bin.readAsync(0,this._bin.byteLength).then(n,function(e){return r(e.message)}),!0)},t.prototype.loadTextureBufferAsync=function(e,t,n){var r=e.textures[t],o=e.images[r.source];if(!o.extensions||!(this.name in o.extensions))return!1;var a=o.extensions[this.name],i=e.bufferViews[a.bufferView];return n(wn.GetBufferFromBufferView(e,i,0,i.byteLength,pn.UNSIGNED_BYTE)),!0},t.prototype.loadShaderStringAsync=function(e,t,n){var r=e.shaders[t];if(!r.extensions||!(this.name in r.extensions))return!1;var o=r.extensions[this.name],a=e.bufferViews[o.bufferView],i=wn.GetBufferFromBufferView(e,a,0,a.byteLength,pn.UNSIGNED_BYTE);return setTimeout(function(){var e=wn.DecodeBufferToText(i);n(e)}),!0},t}(qn);zn.RegisterExtension(new Xn);var Yn=function(e){function n(){return e.call(this,"KHR_materials_common")||this}return m(n,e),n.prototype.loadRuntimeExtensionsAsync=function(e){if(!e.extensions)return!1;var n=e.extensions[this.name];if(!n)return!1;var r=n.lights;if(r)for(var o in r){var a=r[o];switch(a.type){case"ambient":var i=new t.HemisphericLight(a.name,new t.Vector3(0,1,0),e.scene),s=a.ambient;s&&(i.diffuse=t.Color3.FromArray(s.color||[1,1,1]));break;case"point":var l=new t.PointLight(a.name,new t.Vector3(10,10,10),e.scene),u=a.point;u&&(l.diffuse=t.Color3.FromArray(u.color||[1,1,1]));break;case"directional":var c=new t.DirectionalLight(a.name,new t.Vector3(0,-1,0),e.scene),f=a.directional;f&&(c.diffuse=t.Color3.FromArray(f.color||[1,1,1]));break;case"spot":var d=a.spot;d&&(new t.SpotLight(a.name,new t.Vector3(0,10,0),new t.Vector3(0,-1,0),d.fallOffAngle||Math.PI,d.fallOffExponent||0,e.scene).diffuse=t.Color3.FromArray(d.color||[1,1,1]));break;default:t.Tools.Warn('GLTF Material Common extension: light type "'+a.type+"” not supported")}}return!1},n.prototype.loadMaterialAsync=function(e,n,r,o){var a=e.materials[n];if(!a||!a.extensions)return!1;var i=a.extensions[this.name];if(!i)return!1;var s=new t.StandardMaterial(n,e.scene);return s.sideOrientation=t.Material.CounterClockWiseSideOrientation,"CONSTANT"===i.technique&&(s.disableLighting=!0),s.backFaceCulling=void 0!==i.doubleSided&&!i.doubleSided,s.alpha=void 0===i.values.transparency?1:i.values.transparency,s.specularPower=void 0===i.values.shininess?0:i.values.shininess,"string"==typeof i.values.ambient?this._loadTexture(e,i.values.ambient,s,"ambientTexture",o):s.ambientColor=t.Color3.FromArray(i.values.ambient||[0,0,0]),"string"==typeof i.values.diffuse?this._loadTexture(e,i.values.diffuse,s,"diffuseTexture",o):s.diffuseColor=t.Color3.FromArray(i.values.diffuse||[0,0,0]),"string"==typeof i.values.emission?this._loadTexture(e,i.values.emission,s,"emissiveTexture",o):s.emissiveColor=t.Color3.FromArray(i.values.emission||[0,0,0]),"string"==typeof i.values.specular?this._loadTexture(e,i.values.specular,s,"specularTexture",o):s.specularColor=t.Color3.FromArray(i.values.specular||[0,0,0]),!0},n.prototype._loadTexture=function(e,t,n,r,o){Wn.LoadTextureBufferAsync(e,t,function(o){Wn.CreateTextureAsync(e,t,o,function(e){return n[r]=e})},o)},n}(qn);zn.RegisterExtension(new Yn);var Qn={__proto__:null,get EBlendingFunction(){return xn},get EComponentType(){return pn},get ECullingType(){return bn},get EParameterType(){return vn},get EShaderType(){return mn},get ETextureFilterType(){return gn},get ETextureFormat(){return yn},get ETextureWrapMode(){return _n},GLTFBinaryExtension:Xn,GLTFLoader:zn,GLTFLoaderBase:Wn,GLTFLoaderExtension:qn,GLTFMaterialsCommonExtension:Yn,GLTFUtils:wn},Zn=new Map,Jn=Zn;function $n(e,n,r){er(e)&&t.Logger.Warn("Extension with the name '".concat(e,"' already exists")),Zn.set(e,{isGLTFExtension:n,factory:r})}function er(e){return Zn.delete(e)}var tr=[{regex:new RegExp("^/nodes/\\d+/extensions/")}],nr=function(){function e(e,t){this._gltf=e,this._infoTree=t}return e.prototype.convert=function(e){var t=this._gltf,n=this._infoTree,r=void 0;if(!e.startsWith("/"))throw new Error("Path must start with a /");var o=e.split("/");if(o.shift(),o[o.length-1].includes(".length")){var a=o[o.length-1].split(".");o.pop(),o.push.apply(o,a)}for(var i=!1,s=0,l=o;s<l.length;s++){var u=l[s],c="length"===u;if(c&&!n.__array__)throw new Error("Path ".concat(e," is invalid"));if(n.__ignoreObjectTree__&&(i=!0),n.__array__&&!c)n=n.__array__;else if(!(n=n[u]))throw new Error("Path ".concat(e," is invalid"));if(!i)if(void 0===t){if(!tr.find(function(t){return t.regex.test(e)}))throw new Error("Path ".concat(e," is invalid"))}else c||(t=null==t?void 0:t[u]);(n.__target__||c)&&(r=t)}return{object:r,info:n}},e}(),rr={length:{type:"number",get:function(e){return e.length},getTarget:function(e){return e.map(function(e){return e._babylonTransformNode})},getPropertyName:[function(){return"length"}]},__array__:{__target__:!0,translation:{type:"Vector3",get:function(e){var t;return null===(t=e._babylonTransformNode)||void 0===t?void 0:t.position},set:function(e,t){var n;return null===(n=t._babylonTransformNode)||void 0===n?void 0:n.position.copyFrom(e)},getTarget:function(e){return e._babylonTransformNode},getPropertyName:[function(){return"position"}]},rotation:{type:"Quaternion",get:function(e){var t;return null===(t=e._babylonTransformNode)||void 0===t?void 0:t.rotationQuaternion},set:function(e,t){var n,r;return null===(r=null===(n=t._babylonTransformNode)||void 0===n?void 0:n.rotationQuaternion)||void 0===r?void 0:r.copyFrom(e)},getTarget:function(e){return e._babylonTransformNode},getPropertyName:[function(){return"rotationQuaternion"}]},scale:{type:"Vector3",get:function(e){var t;return null===(t=e._babylonTransformNode)||void 0===t?void 0:t.scaling},set:function(e,t){var n;return null===(n=t._babylonTransformNode)||void 0===n?void 0:n.scaling.copyFrom(e)},getTarget:function(e){return e._babylonTransformNode},getPropertyName:[function(){return"scaling"}]},weights:{length:{type:"number",get:function(e){return e._numMorphTargets},getTarget:function(e){return e._babylonTransformNode},getPropertyName:[function(){return"influence"}]},__array__:{__target__:!0,type:"number",get:function(e,t){var n,r;return void 0!==t?null===(r=null===(n=e._primitiveBabylonMeshes)||void 0===n?void 0:n[0].morphTargetManager)||void 0===r?void 0:r.getTarget(t).influence:void 0},getTarget:function(e){return e._babylonTransformNode},getPropertyName:[function(){return"influence"}]},type:"number[]",get:function(e,t){return[0]},getTarget:function(e){return e._babylonTransformNode},getPropertyName:[function(){return"influence"}]},matrix:{type:"Matrix",get:function(e){var n,r,o;return t.Matrix.Compose(null===(n=e._babylonTransformNode)||void 0===n?void 0:n.scaling,null===(r=e._babylonTransformNode)||void 0===r?void 0:r.rotationQuaternion,null===(o=e._babylonTransformNode)||void 0===o?void 0:o.position)},getTarget:function(e){return e._babylonTransformNode},isReadOnly:!0},globalMatrix:{type:"Matrix",get:function(e){for(var n,r,o,a,i,s,l,u=t.Matrix.Identity(),c=e.parent;c&&c.parent;)c=c.parent;var f=(null===(n=e._babylonTransformNode)||void 0===n?void 0:n.position._isDirty)||(null===(o=null===(r=e._babylonTransformNode)||void 0===r?void 0:r.rotationQuaternion)||void 0===o?void 0:o._isDirty)||(null===(a=e._babylonTransformNode)||void 0===a?void 0:a.scaling._isDirty);if(c){var d=null===(i=c._babylonTransformNode)||void 0===i?void 0:i.computeWorldMatrix(!0).invert();d&&(null===(l=null===(s=e._babylonTransformNode)||void 0===s?void 0:s.computeWorldMatrix(f))||void 0===l||l.multiplyToRef(d,u))}else e._babylonTransformNode&&u.copyFrom(e._babylonTransformNode.computeWorldMatrix(f));return u},getTarget:function(e){return e._babylonTransformNode},isReadOnly:!0},extensions:{EXT_lights_ies:{multiplier:{type:"number",get:function(e){var n,r;return null===(r=null===(n=e._babylonTransformNode)||void 0===n?void 0:n.getChildren(function(e){return e instanceof t.SpotLight},!0)[0])||void 0===r?void 0:r.intensity},getTarget:function(e){var n;return null===(n=e._babylonTransformNode)||void 0===n?void 0:n.getChildren(function(e){return e instanceof t.SpotLight},!0)[0]},set:function(e,n){if(n._babylonTransformNode){var r=n._babylonTransformNode.getChildren(function(e){return e instanceof t.SpotLight},!0)[0];r&&(r.intensity=e)}}},color:{type:"Color3",get:function(e){var n,r;return null===(r=null===(n=e._babylonTransformNode)||void 0===n?void 0:n.getChildren(function(e){return e instanceof t.SpotLight},!0)[0])||void 0===r?void 0:r.diffuse},getTarget:function(e){var n;return null===(n=e._babylonTransformNode)||void 0===n?void 0:n.getChildren(function(e){return e instanceof t.SpotLight},!0)[0]},set:function(e,n){if(n._babylonTransformNode){var r=n._babylonTransformNode.getChildren(function(e){return e instanceof t.SpotLight},!0)[0];r&&(r.diffuse=e)}}}},KHR_node_visibility:{visible:{type:"boolean",get:function(e){return!!e._primitiveBabylonMeshes&&e._primitiveBabylonMeshes[0].isVisible},getTarget:function(){},set:function(e,t){t._primitiveBabylonMeshes&&t._primitiveBabylonMeshes.forEach(function(t){return t.isVisible=e})}}}}}},or={__array__:{__target__:!0,orthographic:{xmag:{componentsCount:2,type:"Vector2",get:function(e){var n,r,o,a;return new t.Vector2(null!==(r=null===(n=e._babylonCamera)||void 0===n?void 0:n.orthoLeft)&&void 0!==r?r:0,null!==(a=null===(o=e._babylonCamera)||void 0===o?void 0:o.orthoRight)&&void 0!==a?a:0)},set:function(e,t){t._babylonCamera&&(t._babylonCamera.orthoLeft=e.x,t._babylonCamera.orthoRight=e.y)},getTarget:function(e){return e},getPropertyName:[function(){return"orthoLeft"},function(){return"orthoRight"}]},ymag:{componentsCount:2,type:"Vector2",get:function(e){var n,r,o,a;return new t.Vector2(null!==(r=null===(n=e._babylonCamera)||void 0===n?void 0:n.orthoBottom)&&void 0!==r?r:0,null!==(a=null===(o=e._babylonCamera)||void 0===o?void 0:o.orthoTop)&&void 0!==a?a:0)},set:function(e,t){t._babylonCamera&&(t._babylonCamera.orthoBottom=e.x,t._babylonCamera.orthoTop=e.y)},getTarget:function(e){return e},getPropertyName:[function(){return"orthoBottom"},function(){return"orthoTop"}]},zfar:{type:"number",get:function(e){var t;return null===(t=e._babylonCamera)||void 0===t?void 0:t.maxZ},set:function(e,t){t._babylonCamera&&(t._babylonCamera.maxZ=e)},getTarget:function(e){return e},getPropertyName:[function(){return"maxZ"}]},znear:{type:"number",get:function(e){var t;return null===(t=e._babylonCamera)||void 0===t?void 0:t.minZ},set:function(e,t){t._babylonCamera&&(t._babylonCamera.minZ=e)},getTarget:function(e){return e},getPropertyName:[function(){return"minZ"}]}},perspective:{aspectRatio:{type:"number",get:function(e){var t;return null===(t=e._babylonCamera)||void 0===t?void 0:t.getEngine().getAspectRatio(e._babylonCamera)},getTarget:function(e){return e},getPropertyName:[function(){return"aspectRatio"}],isReadOnly:!0},yfov:{type:"number",get:function(e){var t;return null===(t=e._babylonCamera)||void 0===t?void 0:t.fov},set:function(e,t){t._babylonCamera&&(t._babylonCamera.fov=e)},getTarget:function(e){return e},getPropertyName:[function(){return"fov"}]},zfar:{type:"number",get:function(e){var t;return null===(t=e._babylonCamera)||void 0===t?void 0:t.maxZ},set:function(e,t){t._babylonCamera&&(t._babylonCamera.maxZ=e)},getTarget:function(e){return e},getPropertyName:[function(){return"maxZ"}]},znear:{type:"number",get:function(e){var t;return null===(t=e._babylonCamera)||void 0===t?void 0:t.minZ},set:function(e,t){t._babylonCamera&&(t._babylonCamera.minZ=e)},getTarget:function(e){return e},getPropertyName:[function(){return"minZ"}]}}}},ar={__array__:{__target__:!0,emissiveFactor:{type:"Color3",get:function(e,t,n){return lr(e,0,n).emissiveColor},set:function(e,t,n,r){return lr(t,0,r).emissiveColor.copyFrom(e)},getTarget:function(e,t,n){return lr(e,0,n)},getPropertyName:[function(){return"emissiveColor"}]},emissiveTexture:{extensions:{KHR_texture_transform:ur("emissiveTexture")}},normalTexture:{scale:{type:"number",get:function(e,t,n){var r;return null===(r=sr(e,n,"bumpTexture"))||void 0===r?void 0:r.level},set:function(e,t,n,r){var o=sr(t,r,"bumpTexture");o&&(o.level=e)},getTarget:function(e,t,n){return lr(e,0,n)},getPropertyName:[function(){return"level"}]},extensions:{KHR_texture_transform:ur("bumpTexture")}},occlusionTexture:{strength:{type:"number",get:function(e,t,n){return lr(e,0,n).ambientTextureStrength},set:function(e,t,n,r){var o=lr(t,0,r);o&&(o.ambientTextureStrength=e)},getTarget:function(e,t,n){return lr(e,0,n)},getPropertyName:[function(){return"ambientTextureStrength"}]},extensions:{KHR_texture_transform:ur("ambientTexture")}},pbrMetallicRoughness:{baseColorFactor:{type:"Color4",get:function(e,n,r){var o=lr(e,0,r);return t.Color4.FromColor3(o.albedoColor,o.alpha)},set:function(e,t,n,r){var o=lr(t,0,r);o.albedoColor.set(e.r,e.g,e.b),o.alpha=e.a},getTarget:function(e,t,n){return lr(e,0,n)},getPropertyName:[function(){return"albedoColor"},function(){return"alpha"}]},baseColorTexture:{extensions:{KHR_texture_transform:ur("albedoTexture")}},metallicFactor:{type:"number",get:function(e,t,n){return lr(e,0,n).metallic},set:function(e,t,n,r){var o=lr(t,0,r);o&&(o.metallic=e)},getTarget:function(e,t,n){return lr(e,0,n)},getPropertyName:[function(){return"metallic"}]},roughnessFactor:{type:"number",get:function(e,t,n){return lr(e,0,n).roughness},set:function(e,t,n,r){var o=lr(t,0,r);o&&(o.roughness=e)},getTarget:function(e,t,n){return lr(e,0,n)},getPropertyName:[function(){return"roughness"}]},metallicRoughnessTexture:{extensions:{KHR_texture_transform:ur("metallicTexture")}}},extensions:{KHR_materials_anisotropy:{anisotropyStrength:{type:"number",get:function(e,t,n){return lr(e,0,n).anisotropy.intensity},set:function(e,t,n,r){lr(t,0,r).anisotropy.intensity=e},getTarget:function(e,t,n){return lr(e,0,n)},getPropertyName:[function(){return"anisotropy.intensity"}]},anisotropyRotation:{type:"number",get:function(e,t,n){return lr(e,0,n).anisotropy.angle},set:function(e,t,n,r){lr(t,0,r).anisotropy.angle=e},getTarget:function(e,t,n){return lr(e,0,n)},getPropertyName:[function(){return"anisotropy.angle"}]},anisotropyTexture:{extensions:{KHR_texture_transform:ur("anisotropy","texture")}}},KHR_materials_clearcoat:{clearcoatFactor:{type:"number",get:function(e,t,n){return lr(e,0,n).clearCoat.intensity},set:function(e,t,n,r){lr(t,0,r).clearCoat.intensity=e},getTarget:function(e,t,n){return lr(e,0,n)},getPropertyName:[function(){return"clearCoat.intensity"}]},clearcoatRoughnessFactor:{type:"number",get:function(e,t,n){return lr(e,0,n).clearCoat.roughness},set:function(e,t,n,r){lr(t,0,r).clearCoat.roughness=e},getTarget:function(e,t,n){return lr(e,0,n)},getPropertyName:[function(){return"clearCoat.roughness"}]},clearcoatTexture:{extensions:{KHR_texture_transform:ur("clearCoat","texture")}},clearcoatNormalTexture:{scale:{type:"number",get:function(e,t,n){var r;return null===(r=lr(e,0,n).clearCoat.bumpTexture)||void 0===r?void 0:r.level},getTarget:lr,set:function(e,t,n,r){return lr(t,0,r).clearCoat.bumpTexture.level=e}},extensions:{KHR_texture_transform:ur("clearCoat","bumpTexture")}},clearcoatRoughnessTexture:{extensions:{KHR_texture_transform:ur("clearCoat","textureRoughness")}}},KHR_materials_dispersion:{dispersion:{type:"number",get:function(e,t,n){return lr(e,0,n).subSurface.dispersion},getTarget:lr,set:function(e,t,n,r){return lr(t,0,r).subSurface.dispersion=e}}},KHR_materials_emissive_strength:{emissiveStrength:{type:"number",get:function(e,t,n){return lr(e,0,n).emissiveIntensity},getTarget:lr,set:function(e,t,n,r){return lr(t,0,r).emissiveIntensity=e}}},KHR_materials_ior:{ior:{type:"number",get:function(e,t,n){return lr(e,0,n).indexOfRefraction},getTarget:lr,set:function(e,t,n,r){return lr(t,0,r).indexOfRefraction=e}}},KHR_materials_iridescence:{iridescenceFactor:{type:"number",get:function(e,t,n){return lr(e,0,n).iridescence.intensity},getTarget:lr,set:function(e,t,n,r){return lr(t,0,r).iridescence.intensity=e}},iridescenceIor:{type:"number",get:function(e,t,n){return lr(e,0,n).iridescence.indexOfRefraction},getTarget:lr,set:function(e,t,n,r){return lr(t,0,r).iridescence.indexOfRefraction=e}},iridescenceTexture:{extensions:{KHR_texture_transform:ur("iridescence","texture")}},iridescenceThicknessMaximum:{type:"number",get:function(e,t,n){return lr(e,0,n).iridescence.maximumThickness},getTarget:lr,set:function(e,t,n,r){return lr(t,0,r).iridescence.maximumThickness=e}},iridescenceThicknessMinimum:{type:"number",get:function(e,t,n){return lr(e,0,n).iridescence.minimumThickness},getTarget:lr,set:function(e,t,n,r){return lr(t,0,r).iridescence.minimumThickness=e}},iridescenceThicknessTexture:{extensions:{KHR_texture_transform:ur("iridescence","thicknessTexture")}}},KHR_materials_sheen:{sheenColorFactor:{type:"Color3",get:function(e,t,n){return lr(e,0,n).sheen.color},getTarget:lr,set:function(e,t,n,r){return lr(t,0,r).sheen.color.copyFrom(e)}},sheenColorTexture:{extensions:{KHR_texture_transform:ur("sheen","texture")}},sheenRoughnessFactor:{type:"number",get:function(e,t,n){return lr(e,0,n).sheen.intensity},getTarget:lr,set:function(e,t,n,r){return lr(t,0,r).sheen.intensity=e}},sheenRoughnessTexture:{extensions:{KHR_texture_transform:ur("sheen","thicknessTexture")}}},KHR_materials_specular:{specularFactor:{type:"number",get:function(e,t,n){return lr(e,0,n).metallicF0Factor},getTarget:lr,set:function(e,t,n,r){return lr(t,0,r).metallicF0Factor=e},getPropertyName:[function(){return"metallicF0Factor"}]},specularColorFactor:{type:"Color3",get:function(e,t,n){return lr(e,0,n).metallicReflectanceColor},getTarget:lr,set:function(e,t,n,r){return lr(t,0,r).metallicReflectanceColor.copyFrom(e)},getPropertyName:[function(){return"metallicReflectanceColor"}]},specularTexture:{extensions:{KHR_texture_transform:ur("metallicReflectanceTexture")}},specularColorTexture:{extensions:{KHR_texture_transform:ur("reflectanceTexture")}}},KHR_materials_transmission:{transmissionFactor:{type:"number",get:function(e,t,n){return lr(e,0,n).subSurface.refractionIntensity},getTarget:lr,set:function(e,t,n,r){return lr(t,0,r).subSurface.refractionIntensity=e},getPropertyName:[function(){return"subSurface.refractionIntensity"}]},transmissionTexture:{extensions:{KHR_texture_transform:ur("subSurface","refractionIntensityTexture")}}},KHR_materials_diffuse_transmission:{diffuseTransmissionFactor:{type:"number",get:function(e,t,n){return lr(e,0,n).subSurface.translucencyIntensity},getTarget:lr,set:function(e,t,n,r){return lr(t,0,r).subSurface.translucencyIntensity=e}},diffuseTransmissionTexture:{extensions:{KHR_texture_transform:ur("subSurface","translucencyIntensityTexture")}},diffuseTransmissionColorFactor:{type:"Color3",get:function(e,t,n){return lr(e,0,n).subSurface.translucencyColor},getTarget:lr,set:function(e,t,n,r){var o;return e&&(null===(o=lr(t,0,r).subSurface.translucencyColor)||void 0===o?void 0:o.copyFrom(e))}},diffuseTransmissionColorTexture:{extensions:{KHR_texture_transform:ur("subSurface","translucencyColorTexture")}}},KHR_materials_volume:{attenuationColor:{type:"Color3",get:function(e,t,n){return lr(e,0,n).subSurface.tintColor},getTarget:lr,set:function(e,t,n,r){return lr(t,0,r).subSurface.tintColor.copyFrom(e)}},attenuationDistance:{type:"number",get:function(e,t,n){return lr(e,0,n).subSurface.tintColorAtDistance},getTarget:lr,set:function(e,t,n,r){return lr(t,0,r).subSurface.tintColorAtDistance=e}},thicknessFactor:{type:"number",get:function(e,t,n){return lr(e,0,n).subSurface.maximumThickness},getTarget:lr,set:function(e,t,n,r){return lr(t,0,r).subSurface.maximumThickness=e}},thicknessTexture:{extensions:{KHR_texture_transform:ur("subSurface","thicknessTexture")}}}}}},ir={KHR_lights_punctual:{lights:{length:{type:"number",get:function(e){return e.length},getTarget:function(e){return e.map(function(e){return e._babylonLight})},getPropertyName:[function(e){return"length"}]},__array__:{__target__:!0,color:{type:"Color3",get:function(e){var t;return null===(t=e._babylonLight)||void 0===t?void 0:t.diffuse},set:function(e,t){var n;return null===(n=t._babylonLight)||void 0===n?void 0:n.diffuse.copyFrom(e)},getTarget:function(e){return e._babylonLight},getPropertyName:[function(e){return"diffuse"}]},intensity:{type:"number",get:function(e){var t;return null===(t=e._babylonLight)||void 0===t?void 0:t.intensity},set:function(e,t){return t._babylonLight?t._babylonLight.intensity=e:void 0},getTarget:function(e){return e._babylonLight},getPropertyName:[function(e){return"intensity"}]},range:{type:"number",get:function(e){var t;return null===(t=e._babylonLight)||void 0===t?void 0:t.range},set:function(e,t){return t._babylonLight?t._babylonLight.range=e:void 0},getTarget:function(e){return e._babylonLight},getPropertyName:[function(e){return"range"}]},spot:{innerConeAngle:{type:"number",get:function(e){var t;return null===(t=e._babylonLight)||void 0===t?void 0:t.innerAngle},set:function(e,t){return t._babylonLight?t._babylonLight.innerAngle=e:void 0},getTarget:function(e){return e._babylonLight},getPropertyName:[function(e){return"innerConeAngle"}]},outerConeAngle:{type:"number",get:function(e){var t;return null===(t=e._babylonLight)||void 0===t?void 0:t.angle},set:function(e,t){return t._babylonLight?t._babylonLight.angle=e:void 0},getTarget:function(e){return e._babylonLight},getPropertyName:[function(e){return"outerConeAngle"}]}}}}},EXT_lights_area:{lights:{length:{type:"number",get:function(e){return e.length},getTarget:function(e){return e.map(function(e){return e._babylonLight})},getPropertyName:[function(e){return"length"}]},__array__:{__target__:!0,color:{type:"Color3",get:function(e){var t;return null===(t=e._babylonLight)||void 0===t?void 0:t.diffuse},set:function(e,t){var n;return null===(n=t._babylonLight)||void 0===n?void 0:n.diffuse.copyFrom(e)},getTarget:function(e){return e._babylonLight},getPropertyName:[function(e){return"diffuse"}]},intensity:{type:"number",get:function(e){var t;return null===(t=e._babylonLight)||void 0===t?void 0:t.intensity},set:function(e,t){return t._babylonLight?t._babylonLight.intensity=e:void 0},getTarget:function(e){return e._babylonLight},getPropertyName:[function(e){return"intensity"}]},size:{type:"number",get:function(e){var t;return null===(t=e._babylonLight)||void 0===t?void 0:t.height},set:function(e,t){return t._babylonLight?t._babylonLight.height=e:void 0},getTarget:function(e){return e._babylonLight},getPropertyName:[function(e){return"size"}]},rect:{aspect:{type:"number",get:function(e){var t,n;return(null===(t=e._babylonLight)||void 0===t?void 0:t.width)/(null===(n=e._babylonLight)||void 0===n?void 0:n.height)},set:function(e,t){return t._babylonLight?t._babylonLight.width=e*t._babylonLight.height:void 0},getTarget:function(e){return e._babylonLight},getPropertyName:[function(e){return"aspect"}]}}}}},EXT_lights_ies:{lights:{length:{type:"number",get:function(e){return e.length},getTarget:function(e){return e.map(function(e){return e._babylonLight})},getPropertyName:[function(e){return"length"}]}}},EXT_lights_image_based:{lights:{length:{type:"number",get:function(e){return e.length},getTarget:function(e){return e.map(function(e){return e._babylonTexture})},getPropertyName:[function(e){return"length"}]},__array__:{__target__:!0,intensity:{type:"number",get:function(e){var t;return null===(t=e._babylonTexture)||void 0===t?void 0:t.level},set:function(e,t){t._babylonTexture&&(t._babylonTexture.level=e)},getTarget:function(e){return e._babylonTexture}},rotation:{type:"Quaternion",get:function(e){var n;return e._babylonTexture&&t.Quaternion.FromRotationMatrix(null===(n=e._babylonTexture)||void 0===n?void 0:n.getReflectionTextureMatrix())},set:function(e,n){var r;n._babylonTexture&&((null===(r=n._babylonTexture.getScene())||void 0===r?void 0:r.useRightHandedSystem)||(e=t.Quaternion.Inverse(e)),t.Matrix.FromQuaternionToRef(e,n._babylonTexture.getReflectionTextureMatrix()))},getTarget:function(e){return e._babylonTexture}}}}}};function sr(e,t,n,r){var o=lr(e);return r?o[n][r]:o[n]}function lr(e,n,r){var o,a,i;return null===(i=null===(o=e._data)||void 0===o?void 0:o[null!==(a=null==r?void 0:r.fillMode)&&void 0!==a?a:t.Constants.MATERIAL_TriangleFillMode])||void 0===i?void 0:i.babylonMaterial}function ur(e,n){return{offset:{componentsCount:2,type:"Vector2",get:function(r,o,a){var i=sr(r,0,e,n);return new t.Vector2(null==i?void 0:i.uOffset,null==i?void 0:i.vOffset)},getTarget:lr,set:function(t,r,o,a){var i=sr(r,0,e,n);i.uOffset=t.x,i.vOffset=t.y},getPropertyName:[function(){return"".concat(e).concat(n?"."+n:"",".uOffset")},function(){return"".concat(e).concat(n?"."+n:"",".vOffset")}]},rotation:{type:"number",get:function(t,r,o){var a;return null===(a=sr(t,0,e,n))||void 0===a?void 0:a.wAng},getTarget:lr,set:function(t,r,o,a){return sr(r,0,e,n).wAng=t},getPropertyName:[function(){return"".concat(e).concat(n?"."+n:"",".wAng")}]},scale:{componentsCount:2,type:"Vector2",get:function(r,o,a){var i=sr(r,0,e,n);return new t.Vector2(null==i?void 0:i.uScale,null==i?void 0:i.vScale)},getTarget:lr,set:function(t,r,o,a){var i=sr(r,0,e,n);i.uScale=t.x,i.vScale=t.y},getPropertyName:[function(){return"".concat(e).concat(n?"."+n:"",".uScale")},function(){return"".concat(e).concat(n?"."+n:"",".vScale")}]}}}var cr={cameras:or,nodes:rr,materials:ar,extensions:ir,animations:{length:{type:"number",get:function(e){return e.length},getTarget:function(e){return e.map(function(e){return e._babylonAnimationGroup})},getPropertyName:[function(){return"length"}]},__array__:{}},meshes:{length:{type:"number",get:function(e){return e.length},getTarget:function(e){return e.map(function(e){var t;return null===(t=e.primitives[0]._instanceData)||void 0===t?void 0:t.babylonSourceMesh})},getPropertyName:[function(){return"length"}]},__array__:{}}};function fr(e){return new nr(e,cr)}function dr(e){for(var t=e.split("/").map(function(e){return e.replace(/{}/g,"__array__")}),n=cr,r=0,o=t;r<o.length;r++){var a=o[r];a&&(n=n[a])}if(n&&n.type&&n.get)return n}function hr(e,t){for(var n=e.split("/").map(function(e){return e.replace(/{}/g,"__array__")}),r=cr,o=0,a=n;o<a.length;o++){var i=a[o];i&&(r=r[i])}r&&r.type&&r.get&&(r.interpolation=t)}function pr(e,t){for(var n=e.split("/").map(function(e){return e.replace(/{}/g,"__array__")}),r=cr,o=0,a=n;o<a.length;o++){var i=a[o];if(i){if(!r[i]){if("?"===i){r.__ignoreObjectTree__=!0;continue}r[i]={},"__array__"===i&&(r[i].__target__=!0)}r=r[i]}}Object.assign(r,t)}var mr=new t.Lazy(function(){return Promise.resolve(BABYLON)}),vr=new t.Lazy(function(){return Promise.resolve().then(function(){return Or})}),_r=function(){function e(){}return e.Get=function(e,t,n){if(!t||null==n||!t[n])throw new Error("".concat(e,": Failed to find index (").concat(n,")"));return t[n]},e.TryGet=function(e,t){return e&&null!=t&&e[t]?e[t]:null},e.Assign=function(e){if(e)for(var t=0;t<e.length;t++)e[t].index=t},e}();function gr(e){if(e.min&&e.max){var n=e.min,r=e.max,o=t.TmpVectors.Vector3[0].copyFromFloats(n[0],n[1],n[2]),a=t.TmpVectors.Vector3[1].copyFromFloats(r[0],r[1],r[2]);if(e.normalized&&5126!==e.componentType){var i=1;switch(e.componentType){case 5120:i=127;break;case 5121:i=255;break;case 5122:i=32767;break;case 5123:i=65535}var s=1/i;o.scaleInPlace(s),a.scaleInPlace(s)}return new t.BoundingInfo(o,a)}return null}var yr=function(){function n(e){this._completePromises=new Array,this._assetContainer=null,this._babylonLights=[],this._disableInstancedMesh=0,this._allMaterialsDirtyRequired=!1,this._skipStartAnimationStep=!1,this._extensions=new Array,this._disposed=!1,this._rootUrl=null,this._fileName=null,this._uniqueRootUrl=null,this._bin=null,this._rootBabylonMesh=null,this._defaultBabylonMaterialData={},this._postSceneLoadActions=new Array,this._materialAdapterCache=new WeakMap,this._materialAdapters=new Set,this._pbrMaterialImpls=new Map,this._parent=e}return n.prototype.isMatchingMaterialType=function(e){if(!e)return!1;for(var t=0,n=Array.from(this._pbrMaterialImpls.values());t<n.length;t++)if(e instanceof n[t].materialClass)return!0;return!1},n.RegisterExtension=function(e,t){$n(e,!1,t)},n.UnregisterExtension=function(e){return er(e)},Object.defineProperty(n.prototype,"gltf",{get:function(){if(!this._gltf)throw new Error("glTF JSON is not available");return this._gltf},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"bin",{get:function(){return this._bin},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"parent",{get:function(){return this._parent},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"babylonScene",{get:function(){if(!this._babylonScene)throw new Error("Scene is not available");return this._babylonScene},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"rootBabylonMesh",{get:function(){return this._rootBabylonMesh},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"rootUrl",{get:function(){return this._rootUrl},enumerable:!1,configurable:!0}),n.prototype._getOrCreateMaterialAdapter=function(e){var t=this._materialAdapterCache.get(e);if(!t){for(var n=0,r=Array.from(this._pbrMaterialImpls.values());n<r.length;n++){var o=r[n];if(e instanceof o.materialClass){t=new o.adapterClass(e);break}}if(!t)throw new Error("Appropriate material adapter class not found");var a=t;this._materialAdapterCache.set(e,a),this._materialAdapters.add(a)}return t},n.prototype.dispose=function(){this._disposed||(this._disposed=!0,this._completePromises.length=0,this._extensions.forEach(function(e){return e.dispose&&e.dispose()}),this._extensions.length=0,this._materialAdapters.clear(),this._gltf=null,this._bin=null,this._babylonScene=null,this._rootBabylonMesh=null,this._defaultBabylonMaterialData={},this._postSceneLoadActions.length=0,this._parent.dispose())},n.prototype.importMeshAsync=function(e,t,n,r,o,a){return _(this,arguments,void 0,function(e,t,n,r,o,a,i){var s=this;return void 0===i&&(i=""),g(this,function(a){switch(a.label){case 0:return[4,Promise.resolve().then(function(){return _(s,void 0,void 0,function(){var a,s,l,u,c,f=this;return g(this,function(d){switch(d.label){case 0:if(this._babylonScene=t,this._assetContainer=n,this._loadData(r),a=null,e){if(s={},this._gltf.nodes)for(l=0,u=this._gltf.nodes;l<u.length;l++)(c=u[l]).name&&(s[c.name]=c.index);a=(e instanceof Array?e:[e]).map(function(e){var t=s[e];if(void 0===t)throw new Error("Failed to find node '".concat(e,"'"));return t})}return[4,this._loadAsync(o,i,a,function(){return{meshes:f._getMeshes(),particleSystems:[],skeletons:f._getSkeletons(),animationGroups:f._getAnimationGroups(),lights:f._babylonLights,transformNodes:f._getTransformNodes(),geometries:f._getGeometries(),spriteManagers:[]}})];case 1:return[2,d.sent()]}})})})];case 1:return[2,a.sent()]}})})},n.prototype.loadAsync=function(e,t,n,r){return _(this,arguments,void 0,function(e,t,n,r,o){return void 0===o&&(o=""),g(this,function(r){switch(r.label){case 0:return this._babylonScene=e,this._loadData(t),[4,this._loadAsync(n,o,null,function(){})];case 1:return[2,r.sent()]}})})},n.prototype._loadAsync=function(n,r,o,a){return _(this,void 0,void 0,function(){var i=this;return g(this,function(s){switch(s.label){case 0:return[4,Promise.resolve().then(function(){return _(i,void 0,void 0,function(){var i,s,l,u,c,f,d,h,p,m,v,_,y,b,x=this;return g(this,function(g){switch(g.label){case 0:return this._rootUrl=n,this._uniqueRootUrl=!n.startsWith("file:")&&r?n:"".concat(n).concat(Date.now(),"/"),this._fileName=r,this._allMaterialsDirtyRequired=!1,[4,this._loadExtensionsAsync()];case 1:return g.sent(),this.parent.skipMaterials?[3,3]:(i=this.parent.useOpenPBR||this.isExtensionUsed("KHR_materials_openpbr"),s=!1,this.parent.useOpenPBR?(null===(b=this._gltf.materials)||void 0===b?void 0:b.length)&&this._gltf.materials.some(function(e){var t;return!(null===(t=e.extensions)||void 0===t?void 0:t.KHR_materials_openpbr)})&&(s=!0):s=!0,l=[],i&&!this._pbrMaterialImpls.has("openpbr")&&l.push(Promise.all([Promise.resolve(BABYLON),Promise.resolve().then(function(){return Er})]).then(function(e){var t=e[0].OpenPBRMaterial,n=e[1].OpenPBRMaterialLoadingAdapter;x._pbrMaterialImpls.set("openpbr",{materialClass:t,adapterClass:n})})),s&&!this._pbrMaterialImpls.has("pbr")&&l.push(Promise.all([Promise.resolve(BABYLON),Promise.resolve().then(function(){return Rr})]).then(function(e){var t=e[0].PBRMaterial,n=e[1].PBRMaterialLoadingAdapter;x._pbrMaterialImpls.set("pbr",{materialClass:t,adapterClass:n})})),[4,Promise.all(l)]);case 2:g.sent(),g.label=3;case 3:if(u="".concat(e.GLTFLoaderState[e.GLTFLoaderState.LOADING]," => ").concat(e.GLTFLoaderState[e.GLTFLoaderState.READY]),c="".concat(e.GLTFLoaderState[e.GLTFLoaderState.LOADING]," => ").concat(e.GLTFLoaderState[e.GLTFLoaderState.COMPLETE]),this._parent._startPerformanceCounter(u),this._parent._startPerformanceCounter(c),this._parent._setState(e.GLTFLoaderState.LOADING),this._extensionsOnLoading(),f=new Array,d=this._babylonScene.blockMaterialDirtyMechanism,this._babylonScene.blockMaterialDirtyMechanism=!0,this.parent.loadOnlyMaterials||(o?f.push(this.loadSceneAsync("/nodes",{nodes:o,index:-1})):(null!=this._gltf.scene||this._gltf.scenes&&this._gltf.scenes[0])&&(h=_r.Get("/scene",this._gltf.scenes,this._gltf.scene||0),f.push(this.loadSceneAsync("/scenes/".concat(h.index),h)))),!this.parent.skipMaterials&&this.parent.loadAllMaterials&&this._gltf.materials)for(p=0;p<this._gltf.materials.length;++p)m=this._gltf.materials[p],v="/materials/"+p,_=t.Material.TriangleFillMode,f.push(this._loadMaterialAsync(v,m,null,_,function(){}));return this._allMaterialsDirtyRequired?this._babylonScene.blockMaterialDirtyMechanism=d:this._babylonScene._forceBlockMaterialDirtyMechanism(d),this._parent.compileMaterials&&f.push(this._compileMaterialsAsync()),this._parent.compileShadowGenerators&&f.push(this._compileShadowGeneratorsAsync()),y=Promise.all(f).then(function(){x._rootBabylonMesh&&x._rootBabylonMesh!==x._parent.customRootNode&&x._rootBabylonMesh.setEnabled(!0);for(var t=0,n=x._babylonScene.materials;t<n.length;t++){var r=n[t];void 0!==r.maxSimultaneousLights&&(r.maxSimultaneousLights=Math.max(r.maxSimultaneousLights,x._babylonScene.lights.length))}for(var o=0,i=Array.from(x._materialAdapters);o<i.length;o++){var s=i[o];x._completePromises.push(s.finalizeAsync(x))}return x._extensionsOnReady(),x._parent._setState(e.GLTFLoaderState.READY),x._skipStartAnimationStep||x._startAnimations(),a()}),[4,y.then(function(n){return x._parent._endPerformanceCounter(u),t.Tools.SetImmediate(function(){x._disposed||Promise.all(x._completePromises).then(function(){x._parent._endPerformanceCounter(c),x._parent._setState(e.GLTFLoaderState.COMPLETE),x._parent.onCompleteObservable.notifyObservers(void 0),x._parent.onCompleteObservable.clear(),x.dispose()},function(e){x._parent.onErrorObservable.notifyObservers(e),x._parent.onErrorObservable.clear(),x.dispose()})}),n})];case 4:return[2,g.sent()]}})})}).catch(function(e){throw i._disposed||(i._parent.onErrorObservable.notifyObservers(e),i._parent.onErrorObservable.clear(),i.dispose()),e})];case 1:return[2,s.sent()]}})})},n.prototype._loadData=function(e){if(this._gltf=e.json,this._setupData(),e.bin){var n=this._gltf.buffers;if(n&&n[0]&&!n[0].uri){var r=n[0];(r.byteLength<e.bin.byteLength-3||r.byteLength>e.bin.byteLength)&&t.Logger.Warn("Binary buffer length (".concat(r.byteLength,") from JSON does not match chunk length (").concat(e.bin.byteLength,")")),this._bin=e.bin}else t.Logger.Warn("Unexpected BIN chunk")}},n.prototype._setupData=function(){if(_r.Assign(this._gltf.accessors),_r.Assign(this._gltf.animations),_r.Assign(this._gltf.buffers),_r.Assign(this._gltf.bufferViews),_r.Assign(this._gltf.cameras),_r.Assign(this._gltf.images),_r.Assign(this._gltf.materials),_r.Assign(this._gltf.meshes),_r.Assign(this._gltf.nodes),_r.Assign(this._gltf.samplers),_r.Assign(this._gltf.scenes),_r.Assign(this._gltf.skins),_r.Assign(this._gltf.textures),this._gltf.nodes){for(var e={},t=0,n=this._gltf.nodes;t<n.length;t++)if((l=n[t]).children)for(var r=0,o=l.children;r<o.length;r++)e[o[r]]=l.index;for(var a=this._createRootNode(),i=0,s=this._gltf.nodes;i<s.length;i++){var l,u=e[(l=s[i]).index];l.parent=void 0===u?a:this._gltf.nodes[u]}}},n.prototype._loadExtensionsAsync=function(){return _(this,void 0,void 0,function(){var e,n,r,o,a,i,s,l,u,c,f,d=this;return g(this,function(h){switch(h.label){case 0:return e=[],Jn.forEach(function(n,r){var o;!1===(null===(o=d.parent.extensionOptions[r])||void 0===o?void 0:o.enabled)?n.isGLTFExtension&&d.isExtensionUsed(r)&&t.Logger.Warn("Extension ".concat(r," is used but has been explicitly disabled.")):n.isGLTFExtension&&!d.isExtensionUsed(r)||e.push(_(d,void 0,void 0,function(){var e;return g(this,function(o){switch(o.label){case 0:return[4,n.factory(this)];case 1:return(e=o.sent()).name!==r&&t.Logger.Warn("The name of the glTF loader extension instance does not match the registered name: ".concat(e.name," !== ").concat(r)),this._parent.onExtensionLoadedObservable.notifyObservers(e),[2,e]}})}))}),r=(n=(c=this._extensions).push).apply,o=[c],[4,Promise.all(e)];case 1:if(r.apply(n,o.concat([h.sent()])),this._extensions.sort(function(e,t){return(e.order||Number.MAX_VALUE)-(t.order||Number.MAX_VALUE)}),this._parent.onExtensionLoadedObservable.clear(),this._gltf.extensionsRequired)for(a=function(e){if(!i._extensions.some(function(t){return t.name===e&&t.enabled})){if(!1===(null===(f=i.parent.extensionOptions[e])||void 0===f?void 0:f.enabled))throw new Error("Required extension ".concat(e," is disabled"));throw new Error("Required extension ".concat(e," is not available"))}},i=this,s=0,l=this._gltf.extensionsRequired;s<l.length;s++)u=l[s],a(u);return[2]}})})},n.prototype._createRootNode=function(){if(void 0!==this._parent.customRootNode)return this._rootBabylonMesh=this._parent.customRootNode,{_babylonTransformNode:null===this._rootBabylonMesh?void 0:this._rootBabylonMesh,index:-1};this._babylonScene._blockEntityCollection=!!this._assetContainer;var r=new t.Mesh("__root__",this._babylonScene);this._rootBabylonMesh=r,this._rootBabylonMesh._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,this._rootBabylonMesh.setEnabled(!1);var o={_babylonTransformNode:this._rootBabylonMesh,index:-1};switch(this._parent.coordinateSystemMode){case e.GLTFLoaderCoordinateSystemMode.AUTO:this._babylonScene.useRightHandedSystem||(o.rotation=[0,1,0,0],o.scale=[1,1,-1],n._LoadTransform(o,this._rootBabylonMesh));break;case e.GLTFLoaderCoordinateSystemMode.FORCE_RIGHT_HANDED:this._babylonScene.useRightHandedSystem=!0;break;default:throw new Error("Invalid coordinate system mode (".concat(this._parent.coordinateSystemMode,")"))}return this._parent.onMeshLoadedObservable.notifyObservers(r),o},n.prototype.loadSceneAsync=function(e,t){var n=this,r=this._extensionsLoadSceneAsync(e,t);if(r)return r;var o=new Array;if(this.logOpen("".concat(e," ").concat(t.name||"")),t.nodes)for(var a=0,i=t.nodes;a<i.length;a++){var s=i[a],l=_r.Get("".concat(e,"/nodes/").concat(s),this._gltf.nodes,s);o.push(this.loadNodeAsync("/nodes/".concat(l.index),l,function(e){e.parent=n._rootBabylonMesh}))}for(var u=0,c=this._postSceneLoadActions;u<c.length;u++)(0,c[u])();return o.push(this._loadAnimationsAsync()),this.logClose(),Promise.all(o).then(function(){})},n.prototype._forEachPrimitive=function(e,t){if(e._primitiveBabylonMeshes)for(var n=0,r=e._primitiveBabylonMeshes;n<r.length;n++)t(r[n])},n.prototype._getGeometries=function(){var e=[],t=this._gltf.nodes;if(t)for(var n=0,r=t;n<r.length;n++){var o=r[n];this._forEachPrimitive(o,function(t){var n=t.geometry;n&&-1===e.indexOf(n)&&e.push(n)})}return e},n.prototype._getMeshes=function(){var e=[];this._rootBabylonMesh instanceof t.AbstractMesh&&e.push(this._rootBabylonMesh);var n=this._gltf.nodes;if(n)for(var r=0,o=n;r<o.length;r++){var a=o[r];this._forEachPrimitive(a,function(t){e.push(t)})}return e},n.prototype._getTransformNodes=function(){var e=[],t=this._gltf.nodes;if(t)for(var n=0,r=t;n<r.length;n++){var o=r[n];o._babylonTransformNode&&"TransformNode"===o._babylonTransformNode.getClassName()&&e.push(o._babylonTransformNode),o._babylonTransformNodeForSkin&&e.push(o._babylonTransformNodeForSkin)}return e},n.prototype._getSkeletons=function(){var e=[],t=this._gltf.skins;if(t)for(var n=0,r=t;n<r.length;n++){var o=r[n];o._data&&e.push(o._data.babylonSkeleton)}return e},n.prototype._getAnimationGroups=function(){var e=[],t=this._gltf.animations;if(t)for(var n=0,r=t;n<r.length;n++){var o=r[n];o._babylonAnimationGroup&&e.push(o._babylonAnimationGroup)}return e},n.prototype._startAnimations=function(){switch(this._parent.animationStartMode){case e.GLTFLoaderAnimationStartMode.NONE:break;case e.GLTFLoaderAnimationStartMode.FIRST:0!==(n=this._getAnimationGroups()).length&&n[0].start(!0);break;case e.GLTFLoaderAnimationStartMode.ALL:for(var n,r=0,o=n=this._getAnimationGroups();r<o.length;r++)o[r].start(!0);break;default:return void t.Logger.Error("Invalid animation start mode (".concat(this._parent.animationStartMode,")"))}},n.prototype.loadNodeAsync=function(e,r,o){var a=this;void 0===o&&(o=function(){});var i=this._extensionsLoadNodeAsync(e,r,o);if(i)return i;if(r._babylonTransformNode)throw new Error("".concat(e,": Invalid recursive node hierarchy"));var s=new Array;this.logOpen("".concat(e," ").concat(r.name||""));var l=function(t){if(n.AddPointerMetadata(t,e),n._LoadTransform(r,t),null!=r.camera){var i=_r.Get("".concat(e,"/camera"),a._gltf.cameras,r.camera);s.push(a.loadCameraAsync("/cameras/".concat(i.index),i,function(e){e.parent=t,a._babylonScene.useRightHandedSystem||(t.scaling.x=-1)}))}if(r.children)for(var l=0,u=r.children;l<u.length;l++){var c=u[l],f=_r.Get("".concat(e,"/children/").concat(c),a._gltf.nodes,c);s.push(a.loadNodeAsync("/nodes/".concat(f.index),f,function(e){e.parent=t}))}o(t)},u=null!=r.mesh,c=this._parent.loadSkins&&null!=r.skin;if(!u||c){var f=r.name||"node".concat(r.index);this._babylonScene._blockEntityCollection=!!this._assetContainer;var d=new t.TransformNode(f,this._babylonScene);d._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,null==r.mesh?r._babylonTransformNode=d:r._babylonTransformNodeForSkin=d,l(d)}if(u)if(c){var h=_r.Get("".concat(e,"/mesh"),this._gltf.meshes,r.mesh);s.push(this._loadMeshAsync("/meshes/".concat(h.index),r,h,function(n){var o=r._babylonTransformNodeForSkin;n.metadata=t.deepMerge(o.metadata,n.metadata||{});var i=_r.Get("".concat(e,"/skin"),a._gltf.skins,r.skin);s.push(a._loadSkinAsync("/skins/".concat(i.index),r,i,function(e){a._forEachPrimitive(r,function(t){t.skeleton=e}),a._postSceneLoadActions.push(function(){if(null!=i.skeleton){var e=_r.Get("/skins/".concat(i.index,"/skeleton"),a._gltf.nodes,i.skeleton).parent;r.index===e.index?n.parent=o.parent:n.parent=e._babylonTransformNode}else n.parent=a._rootBabylonMesh;a._parent.onSkinLoadedObservable.notifyObservers({node:o,skinnedNode:n})})}))}))}else h=_r.Get("".concat(e,"/mesh"),this._gltf.meshes,r.mesh),s.push(this._loadMeshAsync("/meshes/".concat(h.index),r,h,l));return this.logClose(),Promise.all(s).then(function(){return a._forEachPrimitive(r,function(e){var t=e;!t.isAnInstance&&t.geometry&&t.geometry.useBoundingInfoFromGeometry?e._updateBoundingInfo():e.refreshBoundingInfo(!0,!0)}),r._babylonTransformNode})},n.prototype._loadMeshAsync=function(e,n,r,o){var a=r.primitives;if(!a||!a.length)throw new Error("".concat(e,": Primitives are missing"));null==a[0].index&&_r.Assign(a);var i=new Array;this.logOpen("".concat(e," ").concat(r.name||""));var s=n.name||"node".concat(n.index);if(1===a.length){var l=r.primitives[0];i.push(this._loadMeshPrimitiveAsync("".concat(e,"/primitives/").concat(l.index),s,n,r,l,function(e){n._babylonTransformNode=e,n._primitiveBabylonMeshes=[e]}))}else{this._babylonScene._blockEntityCollection=!!this._assetContainer,n._babylonTransformNode=new t.TransformNode(s,this._babylonScene),n._babylonTransformNode._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,n._primitiveBabylonMeshes=[];for(var u=0,c=a;u<c.length;u++)l=c[u],i.push(this._loadMeshPrimitiveAsync("".concat(e,"/primitives/").concat(l.index),"".concat(s,"_primitive").concat(l.index),n,r,l,function(e){e.parent=n._babylonTransformNode,n._primitiveBabylonMeshes.push(e)}))}return o(n._babylonTransformNode),this.logClose(),Promise.all(i).then(function(){return n._babylonTransformNode})},n.prototype._loadMeshPrimitiveAsync=function(e,r,o,a,i,s){var l=this,u=this._extensionsLoadMeshPrimitiveAsync(e,r,o,a,i,s);if(u)return u;this.logOpen("".concat(e));var c,f,d=0===this._disableInstancedMesh&&this._parent.createInstances&&null==o.skin&&!a.primitives[0].targets;if(d&&i._instanceData)this._babylonScene._blockEntityCollection=!!this._assetContainer,(c=i._instanceData.babylonSourceMesh.createInstance(r))._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,f=i._instanceData.promise;else{var h=new Array;this._babylonScene._blockEntityCollection=!!this._assetContainer;var p=new t.Mesh(r,this._babylonScene);if(p._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,p.sideOrientation=this._babylonScene.useRightHandedSystem?t.Material.CounterClockWiseSideOrientation:t.Material.ClockWiseSideOrientation,this._createMorphTargets(e,o,a,i,p),h.push(this._loadVertexDataAsync(e,i,p).then(function(t){return _(l,void 0,void 0,function(){var n=this;return g(this,function(r){switch(r.label){case 0:return[4,this._loadMorphTargetsAsync(e,i,p,t).then(function(){n._disposed||(n._babylonScene._blockEntityCollection=!!n._assetContainer,t.applyToMesh(p),t._parentContainer=n._assetContainer,n._babylonScene._blockEntityCollection=!1)})];case 1:return[2,r.sent()]}})})})),!this.parent.skipMaterials){var m=n._GetDrawMode(e,i.mode);if(null==i.material){var v=this._defaultBabylonMaterialData[m];v||(v=this._createDefaultMaterial("__GLTFLoader._default",m,this._getDefaultImpl()),this._parent.onMaterialLoadedObservable.notifyObservers(v),this._defaultBabylonMaterialData[m]=v),p.material=v}else{var y=_r.Get("".concat(e,"/material"),this._gltf.materials,i.material);h.push(this._loadMaterialAsync("/materials/".concat(y.index),y,p,m,function(e){p.material=e}))}}f=Promise.all(h),d&&(i._instanceData={babylonSourceMesh:p,promise:f}),c=p}return n.AddPointerMetadata(c,e),this._parent.onMeshLoadedObservable.notifyObservers(c),s(c),this.logClose(),f.then(function(){return c})},n.prototype._loadVertexDataAsync=function(e,n,r){var o=this,a=this._extensionsLoadVertexDataAsync(e,n,r);if(a)return a;var i=n.attributes;if(!i)throw new Error("".concat(e,": Attributes are missing"));var s=new Array,l=new t.Geometry(r.name,this._babylonScene);if(null==n.indices)r.isUnIndexed=!0;else{var u=_r.Get("".concat(e,"/indices"),this._gltf.accessors,n.indices);s.push(this._loadIndicesAccessorAsync("/accessors/".concat(u.index),u).then(function(e){l.setIndices(e)}))}var c=function(n,a,u){if(null!=i[n]){r._delayInfo=r._delayInfo||[],-1===r._delayInfo.indexOf(a)&&r._delayInfo.push(a);var c=_r.Get("".concat(e,"/attributes/").concat(n),o._gltf.accessors,i[n]);s.push(o._loadVertexAccessorAsync("/accessors/".concat(c.index),c,a).then(function(e){if(e.getKind()===t.VertexBuffer.PositionKind&&!o.parent.alwaysComputeBoundingBox&&!r.skeleton){var n=gr(c);n&&(l._boundingInfo=n,l.useBoundingInfoFromGeometry=!0)}l.setVerticesBuffer(e,c.count)})),a==t.VertexBuffer.MatricesIndicesExtraKind&&(r.numBoneInfluencers=8),u&&u(c)}};return c("POSITION",t.VertexBuffer.PositionKind),c("NORMAL",t.VertexBuffer.NormalKind),c("TANGENT",t.VertexBuffer.TangentKind),c("TEXCOORD_0",t.VertexBuffer.UVKind),c("TEXCOORD_1",t.VertexBuffer.UV2Kind),c("TEXCOORD_2",t.VertexBuffer.UV3Kind),c("TEXCOORD_3",t.VertexBuffer.UV4Kind),c("TEXCOORD_4",t.VertexBuffer.UV5Kind),c("TEXCOORD_5",t.VertexBuffer.UV6Kind),c("JOINTS_0",t.VertexBuffer.MatricesIndicesKind),c("WEIGHTS_0",t.VertexBuffer.MatricesWeightsKind),c("JOINTS_1",t.VertexBuffer.MatricesIndicesExtraKind),c("WEIGHTS_1",t.VertexBuffer.MatricesWeightsExtraKind),c("COLOR_0",t.VertexBuffer.ColorKind,function(e){"VEC4"===e.type&&(r.hasVertexAlpha=!0)}),Promise.all(s).then(function(){return l})},n.prototype._createMorphTargets=function(e,n,r,o,a){if(o.targets&&this._parent.loadMorphTargets){if(null==n._numMorphTargets)n._numMorphTargets=o.targets.length;else if(o.targets.length!==n._numMorphTargets)throw new Error("".concat(e,": Primitives do not have the same number of targets"));var i=r.extras?r.extras.targetNames:null;this._babylonScene._blockEntityCollection=!!this._assetContainer,a.morphTargetManager=new t.MorphTargetManager(this._babylonScene),a.morphTargetManager._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,a.morphTargetManager.areUpdatesFrozen=!0;for(var s=0;s<o.targets.length;s++){var l=n.weights?n.weights[s]:r.weights?r.weights[s]:0,u=i?i[s]:"morphTarget".concat(s);a.morphTargetManager.addTarget(new t.MorphTarget(u,l,a.getScene()))}}},n.prototype._loadMorphTargetsAsync=function(e,t,n,r){if(!t.targets||!this._parent.loadMorphTargets)return Promise.resolve();for(var o=new Array,a=n.morphTargetManager,i=0;i<a.numTargets;i++){var s=a.getTarget(i);o.push(this._loadMorphTargetVertexDataAsync("".concat(e,"/targets/").concat(i),r,t.targets[i],s))}return Promise.all(o).then(function(){a.areUpdatesFrozen=!1})},n.prototype._loadMorphTargetVertexDataAsync=function(e,n,r,o){return _(this,void 0,void 0,function(){var a,i,s=this;return g(this,function(l){switch(l.label){case 0:return a=new Array,(i=function(t,o,i){if(null!=r[t]){var l=n.getVertexBuffer(o);if(l){var u=_r.Get("".concat(e,"/").concat(t),s._gltf.accessors,r[t]);a.push(s._loadFloatAccessorAsync("/accessors/".concat(u.index),u).then(function(e){i(l,e)}))}}})("POSITION",t.VertexBuffer.PositionKind,function(e,t){var n=new Float32Array(t.length);e.forEach(t.length,function(e,r){n[r]=t[r]+e}),o.setPositions(n)}),i("NORMAL",t.VertexBuffer.NormalKind,function(e,t){var n=new Float32Array(t.length);e.forEach(n.length,function(e,r){n[r]=t[r]+e}),o.setNormals(n)}),i("TANGENT",t.VertexBuffer.TangentKind,function(e,t){var n=new Float32Array(t.length/3*4),r=0;e.forEach(t.length/3*4,function(e,o){(o+1)%4!=0&&(n[r]=t[r]+e,r++)}),o.setTangents(n)}),i("TEXCOORD_0",t.VertexBuffer.UVKind,function(e,t){var n=new Float32Array(t.length);e.forEach(t.length,function(e,r){n[r]=t[r]+e}),o.setUVs(n)}),i("TEXCOORD_1",t.VertexBuffer.UV2Kind,function(e,t){var n=new Float32Array(t.length);e.forEach(t.length,function(e,r){n[r]=t[r]+e}),o.setUV2s(n)}),i("COLOR_0",t.VertexBuffer.ColorKind,function(t,n){var r=null,a=t.getSize();if(3===a){r=new Float32Array(n.length/3*4),t.forEach(n.length,function(e,t){var o=Math.floor(t/3),a=t%3;r[4*o+a]=n[3*o+a]+e});for(var i=0;i<n.length/3;++i)r[4*i+3]=1}else{if(4!==a)throw new Error("".concat(e,": Invalid number of components (").concat(a,") for COLOR_0 attribute"));r=new Float32Array(n.length),t.forEach(n.length,function(e,t){r[t]=n[t]+e})}o.setColors(r)}),[4,Promise.all(a).then(function(){})];case 1:return[2,l.sent()]}})})},n._LoadTransform=function(e,n){if(null==e.skin){var r=t.Vector3.Zero(),o=t.Quaternion.Identity(),a=t.Vector3.One();e.matrix?t.Matrix.FromArray(e.matrix).decompose(a,o,r):(e.translation&&(r=t.Vector3.FromArray(e.translation)),e.rotation&&(o=t.Quaternion.FromArray(e.rotation)),e.scale&&(a=t.Vector3.FromArray(e.scale))),n.position=r,n.rotationQuaternion=o,n.scaling=a}},n.prototype._loadSkinAsync=function(e,n,r,o){var a=this;if(!this._parent.loadSkins)return Promise.resolve();var i=this._extensionsLoadSkinAsync(e,n,r);if(i)return i;if(r._data)return o(r._data.babylonSkeleton),r._data.promise;var s="skeleton".concat(r.index);this._babylonScene._blockEntityCollection=!!this._assetContainer;var l=new t.Skeleton(r.name||s,s,this._babylonScene);l._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,this._loadBones(e,r,l);var u=this._loadSkinInverseBindMatricesDataAsync(e,r).then(function(e){a._updateBoneMatrices(l,e)});return r._data={babylonSkeleton:l,promise:u},o(l),u},n.prototype._loadBones=function(e,n,r){if(null==n.skeleton||this._parent.alwaysComputeSkeletonRootNode){var o=this._findSkeletonRootNode("".concat(e,"/joints"),n.joints);if(o)if(void 0===n.skeleton)n.skeleton=o.index;else{var a=_r.Get("".concat(e,"/skeleton"),this._gltf.nodes,n.skeleton);a===o||function(e,t){for(;t.parent;t=t.parent)if(t.parent===e)return!0;return!1}(a,o)||(t.Logger.Warn("".concat(e,"/skeleton: Overriding with nearest common ancestor as skeleton node is not a common root")),n.skeleton=o.index)}else t.Logger.Warn("".concat(e,": Failed to find common root"))}for(var i={},s=0,l=n.joints;s<l.length;s++){var u=l[s],c=_r.Get("".concat(e,"/joints/").concat(u),this._gltf.nodes,u);this._loadBone(c,n,r,i)}},n.prototype._findSkeletonRootNode=function(e,t){if(0===t.length)return null;for(var n={},r=0,o=t;r<o.length;r++){for(var a=o[r],i=[],s=_r.Get("".concat(e,"/").concat(a),this._gltf.nodes,a);-1!==s.index;)i.unshift(s),s=s.parent;n[a]=i}for(var l=null,u=0;;++u){if(u>=(i=n[t[0]]).length)return l;s=i[u];for(var c=1;c<t.length;++c)if(u>=(i=n[t[c]]).length||s!==i[u])return l;l=s}},n.prototype._loadBone=function(e,n,r,o){e._isJoint=!0;var a=o[e.index];if(a)return a;var i=null;e.index!==n.skeleton&&(e.parent&&-1!==e.parent.index?i=this._loadBone(e.parent,n,r,o):void 0!==n.skeleton&&t.Logger.Warn("/skins/".concat(n.index,"/skeleton: Skeleton node is not a common root")));var s=n.joints.indexOf(e.index);return a=new t.Bone(e.name||"joint".concat(e.index),r,i,this._getNodeMatrix(e),null,null,s),o[e.index]=a,this._postSceneLoadActions.push(function(){a.linkTransformNode(e._babylonTransformNode)}),a},n.prototype._loadSkinInverseBindMatricesDataAsync=function(e,t){if(null==t.inverseBindMatrices)return Promise.resolve(null);var n=_r.Get("".concat(e,"/inverseBindMatrices"),this._gltf.accessors,t.inverseBindMatrices);return this._loadFloatAccessorAsync("/accessors/".concat(n.index),n)},n.prototype._updateBoneMatrices=function(e,n){for(var r=0,o=e.bones;r<o.length;r++){var a=o[r],i=t.Matrix.Identity(),s=a._index;n&&-1!==s&&(t.Matrix.FromArrayToRef(n,16*s,i),i.invertToRef(i));var l=a.getParent();l&&i.multiplyToRef(l.getAbsoluteInverseBindMatrix(),i),a.updateMatrix(i,!1,!1),a._updateAbsoluteBindMatrices(void 0,!1)}},n.prototype._getNodeMatrix=function(e){return e.matrix?t.Matrix.FromArray(e.matrix):t.Matrix.Compose(e.scale?t.Vector3.FromArray(e.scale):t.Vector3.One(),e.rotation?t.Quaternion.FromArray(e.rotation):t.Quaternion.Identity(),e.translation?t.Vector3.FromArray(e.translation):t.Vector3.Zero())},n.prototype.loadCameraAsync=function(e,r,o){void 0===o&&(o=function(){});var a=this._extensionsLoadCameraAsync(e,r,o);if(a)return a;var i=new Array;this.logOpen("".concat(e," ").concat(r.name||"")),this._babylonScene._blockEntityCollection=!!this._assetContainer;var s=new t.FreeCamera(r.name||"camera".concat(r.index),t.Vector3.Zero(),this._babylonScene,!1);switch(s._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,r._babylonCamera=s,s.setTarget(new t.Vector3(0,0,-1)),r.type){case"perspective":var l=r.perspective;if(!l)throw new Error("".concat(e,": Camera perspective properties are missing"));s.fov=l.yfov,s.minZ=l.znear,s.maxZ=l.zfar||0;break;case"orthographic":if(!r.orthographic)throw new Error("".concat(e,": Camera orthographic properties are missing"));s.mode=t.Camera.ORTHOGRAPHIC_CAMERA,s.orthoLeft=-r.orthographic.xmag,s.orthoRight=r.orthographic.xmag,s.orthoBottom=-r.orthographic.ymag,s.orthoTop=r.orthographic.ymag,s.minZ=r.orthographic.znear,s.maxZ=r.orthographic.zfar;break;default:throw new Error("".concat(e,": Invalid camera type (").concat(r.type,")"))}return n.AddPointerMetadata(s,e),this._parent.onCameraLoadedObservable.notifyObservers(s),o(s),this.logClose(),Promise.all(i).then(function(){return s})},n.prototype._loadAnimationsAsync=function(){var e=this;this._parent._startPerformanceCounter("Load animations");var t=this._gltf.animations;if(!t)return Promise.resolve();for(var n=new Array,r=0;r<t.length;r++){var o=t[r];n.push(this.loadAnimationAsync("/animations/".concat(o.index),o).then(function(e){0===e.targetedAnimations.length&&e.dispose()}))}return Promise.all(n).then(function(){e._parent._endPerformanceCounter("Load animations")})},n.prototype.loadAnimationAsync=function(e,t){var n=this;return this._parent._startPerformanceCounter("Load animation"),this._extensionsLoadAnimationAsync(e,t)||mr.value.then(function(r){var o=r.AnimationGroup;n._babylonScene._blockEntityCollection=!!n._assetContainer;var a=new o(t.name||"animation".concat(t.index),n._babylonScene);a._parentContainer=n._assetContainer,n._babylonScene._blockEntityCollection=!1,t._babylonAnimationGroup=a;var i=new Array;_r.Assign(t.channels),_r.Assign(t.samplers);for(var s=0,l=t.channels;s<l.length;s++){var u=l[s];i.push(n._loadAnimationChannelAsync("".concat(e,"/channels/").concat(u.index),e,t,u,function(e,t){e.animations=e.animations||[],e.animations.push(t),a.addTargetedAnimation(t,e)}))}return n._parent._endPerformanceCounter("Load animation"),Promise.all(i).then(function(){return a.normalize(0),a})})},n.prototype._loadAnimationChannelAsync=function(e,t,n,r,o){var a=this,i=this._extensionsLoadAnimationChannelAsync(e,t,n,r,o);if(i)return i;if(null==r.target.node)return Promise.resolve();var s=_r.Get("".concat(e,"/target/node"),this._gltf.nodes,r.target.node),l=r.target.path,u="weights"===l;return u&&!s._numMorphTargets||!u&&!s._babylonTransformNode?Promise.resolve():this._parent.loadNodeAnimations||u||s._isJoint?vr.value.then(function(){var i,u,c,f,d;switch(l){case"translation":d=null===(i=dr("/nodes/{}/translation"))||void 0===i?void 0:i.interpolation;break;case"rotation":d=null===(u=dr("/nodes/{}/rotation"))||void 0===u?void 0:u.interpolation;break;case"scale":d=null===(c=dr("/nodes/{}/scale"))||void 0===c?void 0:c.interpolation;break;case"weights":d=null===(f=dr("/nodes/{}/weights"))||void 0===f?void 0:f.interpolation;break;default:throw new Error("".concat(e,"/target/path: Invalid value (").concat(r.target.path,")"))}if(!d)throw new Error("".concat(e,"/target/path: Could not find interpolation properties for target path (").concat(r.target.path,")"));var h={object:s,info:d};return a._loadAnimationChannelFromTargetInfoAsync(e,t,n,r,h,o)}):Promise.resolve()},n.prototype._loadAnimationChannelFromTargetInfoAsync=function(e,t,n,r,o,a){var i=this.parent.targetFps,s=1/i,l=_r.Get("".concat(e,"/sampler"),n.samplers,r.sampler);return this._loadAnimationSamplerAsync("".concat(t,"/samplers/").concat(r.sampler),l).then(function(e){for(var t=0,l=o.object,u=0,c=o.info;u<c.length;u++){var f=c[u],d=f.getStride(l),h=e.input,p=e.output,m=new Array(h.length),v=0;switch(e.interpolation){case"STEP":for(var _=0;_<h.length;_++){var g=f.getValue(l,p,v,1);v+=d,m[_]={frame:h[_]*i,value:g,interpolation:1}}break;case"CUBICSPLINE":for(_=0;_<h.length;_++){var y=f.getValue(l,p,v,s);v+=d,g=f.getValue(l,p,v,1),v+=d;var b=f.getValue(l,p,v,s);v+=d,m[_]={frame:h[_]*i,inTangent:y,value:g,outTangent:b}}break;case"LINEAR":for(_=0;_<h.length;_++)g=f.getValue(l,p,v,1),v+=d,m[_]={frame:h[_]*i,value:g}}if(v>0)for(var x="".concat(n.name||"animation".concat(n.index),"_channel").concat(r.index,"_").concat(t),T=0,A=f.buildAnimations(l,x,i,m);T<A.length;T++){var w=A[T];t++,a(w.babylonAnimatable,w.babylonAnimation)}}})},n.prototype._loadAnimationSamplerAsync=function(e,t){if(t._data)return t._data;var n=t.interpolation||"LINEAR";switch(n){case"STEP":case"LINEAR":case"CUBICSPLINE":break;default:throw new Error("".concat(e,"/interpolation: Invalid value (").concat(t.interpolation,")"))}var r=_r.Get("".concat(e,"/input"),this._gltf.accessors,t.input),o=_r.Get("".concat(e,"/output"),this._gltf.accessors,t.output);return t._data=Promise.all([this._loadFloatAccessorAsync("/accessors/".concat(r.index),r),this._loadFloatAccessorAsync("/accessors/".concat(o.index),o)]).then(function(e){var t=e[0],r=e[1];return{input:t,interpolation:n,output:r}}),t._data},n.prototype.loadBufferAsync=function(e,t,n,r){var o=this._extensionsLoadBufferAsync(e,t,n,r);if(o)return o;if(!t._data)if(t.uri)t._data=this.loadUriAsync("".concat(e,"/uri"),t,t.uri);else{if(!this._bin)throw new Error("".concat(e,": Uri is missing or the binary glTF is missing its binary chunk"));t._data=this._bin.readAsync(0,t.byteLength)}return t._data.then(function(t){try{return new Uint8Array(t.buffer,t.byteOffset+n,r)}catch(t){throw new Error("".concat(e,": ").concat(t.message),{cause:t})}})},n.prototype.loadBufferViewAsync=function(e,t){var n=this._extensionsLoadBufferViewAsync(e,t);if(n)return n;if(t._data)return t._data;var r=_r.Get("".concat(e,"/buffer"),this._gltf.buffers,t.buffer);return t._data=this.loadBufferAsync("/buffers/".concat(r.index),r,t.byteOffset||0,t.byteLength),t._data},n.prototype._loadAccessorAsync=function(e,r,o){var a=this;if(r._data)return r._data;var i=n._GetNumComponents(e,r.type),s=i*t.VertexBufferGetTypeByteLength(r.componentType),l=i*r.count;if(null==r.bufferView)r._data=Promise.resolve(new o(l));else{var u=_r.Get("".concat(e,"/bufferView"),this._gltf.bufferViews,r.bufferView);r._data=this.loadBufferViewAsync("/bufferViews/".concat(u.index),u).then(function(a){if(5126!==r.componentType||r.normalized||u.byteStride&&u.byteStride!==s){var c=new o(l);return t.VertexBufferForEach(a,r.byteOffset||0,u.byteStride||s,i,r.componentType,c.length,r.normalized||!1,function(e,t){c[t]=e}),c}return n._GetTypedArray(e,r.componentType,a,r.byteOffset,l)})}if(r.sparse){var c=r.sparse;r._data=r._data.then(function(l){var u=l,f=_r.Get("".concat(e,"/sparse/indices/bufferView"),a._gltf.bufferViews,c.indices.bufferView),d=_r.Get("".concat(e,"/sparse/values/bufferView"),a._gltf.bufferViews,c.values.bufferView);return Promise.all([a.loadBufferViewAsync("/bufferViews/".concat(f.index),f),a.loadBufferViewAsync("/bufferViews/".concat(d.index),d)]).then(function(a){var l,f=a[0],d=a[1],h=n._GetTypedArray("".concat(e,"/sparse/indices"),c.indices.componentType,f,c.indices.byteOffset,c.count),p=i*c.count;if(5126!==r.componentType||r.normalized){var m=n._GetTypedArray("".concat(e,"/sparse/values"),r.componentType,d,c.values.byteOffset,p);l=new o(p),t.VertexBufferForEach(m,0,s,i,r.componentType,l.length,r.normalized||!1,function(e,t){l[t]=e})}else l=n._GetTypedArray("".concat(e,"/sparse/values"),r.componentType,d,c.values.byteOffset,p);for(var v=0,_=0;_<h.length;_++)for(var g=h[_]*i,y=0;y<i;y++)u[g++]=l[v++];return u})})}return r._data},n.prototype._loadFloatAccessorAsync=function(e,t){return this._loadAccessorAsync(e,t,Float32Array)},n.prototype._loadIndicesAccessorAsync=function(e,t){if("SCALAR"!==t.type)throw new Error("".concat(e,"/type: Invalid value ").concat(t.type));if(5121!==t.componentType&&5123!==t.componentType&&5125!==t.componentType)throw new Error("".concat(e,"/componentType: Invalid value ").concat(t.componentType));if(t._data)return t._data;if(t.sparse){var r=n._GetTypedArrayConstructor("".concat(e,"/componentType"),t.componentType);t._data=this._loadAccessorAsync(e,t,r)}else{var o=_r.Get("".concat(e,"/bufferView"),this._gltf.bufferViews,t.bufferView);t._data=this.loadBufferViewAsync("/bufferViews/".concat(o.index),o).then(function(r){return n._GetTypedArray(e,t.componentType,r,t.byteOffset,t.count)})}return t._data},n.prototype._loadVertexBufferViewAsync=function(e){if(e._babylonBuffer)return e._babylonBuffer;var n=this._babylonScene.getEngine();return e._babylonBuffer=this.loadBufferViewAsync("/bufferViews/".concat(e.index),e).then(function(e){return new t.Buffer(n,e,!1)}),e._babylonBuffer},n.prototype._loadVertexAccessorAsync=function(e,r,o){var a;if(null===(a=r._babylonVertexBuffer)||void 0===a?void 0:a[o])return r._babylonVertexBuffer[o];r._babylonVertexBuffer||(r._babylonVertexBuffer={});var i=this._babylonScene.getEngine();if(r.sparse||null==r.bufferView)r._babylonVertexBuffer[o]=this._loadFloatAccessorAsync(e,r).then(function(e){return new t.VertexBuffer(i,e,o,!1)});else{var s=_r.Get("".concat(e,"/bufferView"),this._gltf.bufferViews,r.bufferView);r._babylonVertexBuffer[o]=this._loadVertexBufferViewAsync(s).then(function(a){var l=n._GetNumComponents(e,r.type);return new t.VertexBuffer(i,a,o,!1,void 0,s.byteStride,void 0,r.byteOffset,l,r.componentType,r.normalized,!0,void 0,!0)})}return r._babylonVertexBuffer[o]},n.prototype._loadMaterialMetallicRoughnessPropertiesAsync=function(e,n,r){var o=new Array,a=this._getOrCreateMaterialAdapter(r);return n&&(n.baseColorFactor?(a.baseColor=t.Color3.FromArray(n.baseColorFactor),a.geometryOpacity=n.baseColorFactor[3]):a.baseColor=t.Color3.White(),a.baseMetalness=null==n.metallicFactor?1:n.metallicFactor,a.specularRoughness=null==n.roughnessFactor?1:n.roughnessFactor,n.baseColorTexture&&o.push(this.loadTextureInfoAsync("".concat(e,"/baseColorTexture"),n.baseColorTexture,function(e){e.name="".concat(r.name," (Base Color)"),a.baseColorTexture=e})),n.metallicRoughnessTexture&&(n.metallicRoughnessTexture.nonColorData=!0,o.push(this.loadTextureInfoAsync("".concat(e,"/metallicRoughnessTexture"),n.metallicRoughnessTexture,function(e){e.name="".concat(r.name," (Metallic Roughness)"),a.baseMetalnessTexture=e,a.specularRoughnessTexture=e})),a.useRoughnessFromMetallicTextureGreen=!0,a.useMetallicFromMetallicTextureBlue=!0)),Promise.all(o).then(function(){})},n.prototype._loadMaterialAsync=function(e,t,r,o,a){void 0===a&&(a=function(){});var i=this._extensionsLoadMaterialAsync(e,t,r,o,a);if(i)return i;t._data=t._data||{};var s=t._data[o];if(!s){this.logOpen("".concat(e," ").concat(t.name||""));var l=this.createMaterial(e,t,o);s={babylonMaterial:l,babylonMeshes:[],promise:this.loadMaterialPropertiesAsync(e,t,l)},t._data[o]=s,n.AddPointerMetadata(l,e),this._parent.onMaterialLoadedObservable.notifyObservers(l),this.logClose()}return r&&(s.babylonMeshes.push(r),r.onDisposeObservable.addOnce(function(){var e=s.babylonMeshes.indexOf(r);-1!==e&&s.babylonMeshes.splice(e,1)})),a(s.babylonMaterial),s.promise.then(function(){return s.babylonMaterial})},n.prototype._selectImplForGltfMaterial=function(e){var t;if(this.parent.useOpenPBR||(null===(t=e.extensions)||void 0===t?void 0:t.KHR_materials_openpbr)){var n=this._pbrMaterialImpls.get("openpbr");if(n)return n}var r=this._pbrMaterialImpls.get("pbr");if(r)return r;throw new Error("No PBR material implementation loaded")},n.prototype._getDefaultImpl=function(){var e;if(this.parent.useOpenPBR){var t=this._pbrMaterialImpls.get("openpbr");if(t)return t}var n=null!==(e=this._pbrMaterialImpls.get("pbr"))&&void 0!==e?e:this._pbrMaterialImpls.values().next().value;if(n)return n;throw new Error("No PBR material implementation loaded")},n.prototype._createDefaultMaterial=function(e,t,n){this._babylonScene._blockEntityCollection=!!this._assetContainer;var r=new n.materialClass(e,this._babylonScene);r._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,r.fillMode=t,r.transparencyMode=n.materialClass.MATERIAL_OPAQUE;var o=this._getOrCreateMaterialAdapter(r);return o.transparencyAsAlphaCoverage=this._parent.transparencyAsCoverage,o.baseMetalness=1,o.specularRoughness=1,r},n.prototype.createMaterial=function(e,t,n){var r=this._extensionsCreateMaterial(e,t,n);if(r)return r;var o=t.name||"material".concat(t.index);return this._createDefaultMaterial(o,n,this._selectImplForGltfMaterial(t))},n.prototype.loadMaterialPropertiesAsync=function(e,t,n){var r=this._extensionsLoadMaterialPropertiesAsync(e,t,n);if(r)return r;var o=new Array;return o.push(this.loadMaterialBasePropertiesAsync(e,t,n)),t.pbrMetallicRoughness&&o.push(this._loadMaterialMetallicRoughnessPropertiesAsync("".concat(e,"/pbrMetallicRoughness"),t.pbrMetallicRoughness,n)),this.loadMaterialAlphaProperties(e,t,n),Promise.all(o).then(function(){})},n.prototype.loadMaterialBasePropertiesAsync=function(e,n,r){var o,a=new Array,i=this._getOrCreateMaterialAdapter(r);i.emissionColor=n.emissiveFactor?t.Color3.FromArray(n.emissiveFactor):new t.Color3(0,0,0),n.doubleSided&&(i.backFaceCulling=!1,i.twoSidedLighting=!0),n.normalTexture&&(n.normalTexture.nonColorData=!0,a.push(this.loadTextureInfoAsync("".concat(e,"/normalTexture"),n.normalTexture,function(e){var t;e.name="".concat(r.name," (Normal)"),i.geometryNormalTexture=e,null!=(null===(t=n.normalTexture)||void 0===t?void 0:t.scale)&&(e.level=n.normalTexture.scale)})),i.setNormalMapInversions(!this._babylonScene.useRightHandedSystem,this._babylonScene.useRightHandedSystem));var s,l=1;return n.occlusionTexture&&(n.occlusionTexture.nonColorData=!0,a.push(this.loadTextureInfoAsync("".concat(e,"/occlusionTexture"),n.occlusionTexture,function(e){e.name="".concat(r.name," (Occlusion)"),o=e})),null!=n.occlusionTexture.strength&&(l=n.occlusionTexture.strength)),n.emissiveTexture&&a.push(this.loadTextureInfoAsync("".concat(e,"/emissiveTexture"),n.emissiveTexture,function(e){e.name="".concat(r.name," (Emissive)"),s=e})),Promise.all(a).then(function(){o&&(i.ambientOcclusionTexture=o,i.ambientOcclusionTextureStrength=l),s&&(i.emissionColorTexture=s)})},n.prototype.loadMaterialAlphaProperties=function(e,n,r){if(0===this._pbrMaterialImpls.size)throw new Error("".concat(e,": Material type not supported"));var o=this._getOrCreateMaterialAdapter(r),a=o.baseColorTexture;switch(n.alphaMode||"OPAQUE"){case"OPAQUE":r.transparencyMode=t.Material.MATERIAL_OPAQUE,r.alpha=1;break;case"MASK":r.transparencyMode=t.Material.MATERIAL_ALPHATEST,o.alphaCutOff=null==n.alphaCutoff?.5:n.alphaCutoff,a&&(a.hasAlpha=!0,o.useAlphaFromBaseColorTexture=!0);break;case"BLEND":r.transparencyMode=t.Material.MATERIAL_ALPHABLEND,a&&(a.hasAlpha=!0,o.useAlphaFromBaseColorTexture=!0);break;default:throw new Error("".concat(e,"/alphaMode: Invalid value (").concat(n.alphaMode,")"))}},n.prototype.loadTextureInfoAsync=function(e,t,r){var o=this;void 0===r&&(r=function(){});var a=this._extensionsLoadTextureInfoAsync(e,t,r);if(a)return a;if(this.logOpen("".concat(e)),t.texCoord>=6)throw new Error("".concat(e,"/texCoord: Invalid value (").concat(t.texCoord,")"));var i=_r.Get("".concat(e,"/index"),this._gltf.textures,t.index);i._textureInfo=t;var s=this._loadTextureAsync("/textures/".concat(t.index),i,function(a){a.coordinatesIndex=t.texCoord||0,n.AddPointerMetadata(a,e),o._parent.onTextureLoadedObservable.notifyObservers(a),r(a)});return this.logClose(),s},n.prototype._loadTextureAsync=function(e,t,r){void 0===r&&(r=function(){});var o=this._extensionsLoadTextureAsync(e,t,r);if(o)return o;this.logOpen("".concat(e," ").concat(t.name||""));var a=null==t.sampler?n.DefaultSampler:_r.Get("".concat(e,"/sampler"),this._gltf.samplers,t.sampler),i=_r.Get("".concat(e,"/source"),this._gltf.images,t.source),s=this._createTextureAsync(e,a,i,r,void 0,!t._textureInfo.nonColorData);return this.logClose(),s},n.prototype._createTextureAsync=function(e,n,r,o,a,i){var s,l,u=this;void 0===o&&(o=function(){});var c=this._loadSampler("/samplers/".concat(n.index),n),f=new Array,d=new t.Deferred;this._babylonScene._blockEntityCollection=!!this._assetContainer;var h={noMipmap:c.noMipMaps,invertY:!1,samplingMode:c.samplingMode,onLoad:function(){u._disposed||d.resolve()},onError:function(t,n){u._disposed||d.reject(new Error("".concat(e,": ").concat(n&&n.message?n.message:t||"Failed to load texture")))},mimeType:null!==(s=r.mimeType)&&void 0!==s?s:t.GetMimeType(null!==(l=r.uri)&&void 0!==l?l:""),loaderOptions:a,useSRGBBuffer:!!i&&this._parent.useSRGBBuffers},p=new t.Texture(null,this._babylonScene,h);p._parentContainer=this._assetContainer,this._babylonScene._blockEntityCollection=!1,f.push(d.promise);var m=r.uri&&!t.IsBase64DataUrl(r.uri)?r.uri:void 0,v=null!=m?m:"".concat(this._fileName,"#image").concat(r.index);if(f.push(this.loadImageAsync("/images/".concat(r.index),r).then(function(e){var t="data:".concat(u._uniqueRootUrl).concat(v);p.updateURL(t,e);var n=p.getInternalTexture();n&&(n.label=r.name)})),p.wrapU=c.wrapU,p.wrapV=c.wrapV,o(p),this._parent.useGltfTextureNames){var _=r.name||m||"image".concat(r.index);p.name=_}return Promise.all(f).then(function(){return p})},n.prototype._loadSampler=function(e,t){return t._data||(t._data={noMipMaps:9728===t.minFilter||9729===t.minFilter,samplingMode:n._GetTextureSamplingMode(e,t),wrapU:n._GetTextureWrapMode("".concat(e,"/wrapS"),t.wrapS),wrapV:n._GetTextureWrapMode("".concat(e,"/wrapT"),t.wrapT)}),t._data},n.prototype.loadImageAsync=function(e,t){if(!t._data){if(this.logOpen("".concat(e," ").concat(t.name||"")),t.uri)t._data=this.loadUriAsync("".concat(e,"/uri"),t,t.uri);else{var n=_r.Get("".concat(e,"/bufferView"),this._gltf.bufferViews,t.bufferView);t._data=this.loadBufferViewAsync("/bufferViews/".concat(n.index),n)}this.logClose()}return t._data},n.prototype.loadUriAsync=function(e,r,o){var a=this,i=this._extensionsLoadUriAsync(e,r,o);if(i)return i;if(!n._ValidateUri(o))throw new Error("".concat(e,": '").concat(o,"' is invalid"));if(t.IsBase64DataUrl(o)){var s=new Uint8Array(t.DecodeBase64UrlToBinary(o));return this.log("".concat(e,": Decoded ").concat(o.substring(0,64),"... (").concat(s.length," bytes)")),Promise.resolve(s)}return this.log("".concat(e,": Loading ").concat(o)),this._parent.preprocessUrlAsync(this._rootUrl+o).then(function(n){return new Promise(function(r,i){a._parent._loadFile(a._babylonScene,n,function(t){a._disposed||(a.log("".concat(e,": Loaded ").concat(o," (").concat(t.byteLength," bytes)")),r(new Uint8Array(t)))},!0,function(n){i(new t.LoadFileError("".concat(e,": Failed to load '").concat(o,"'").concat(n?": "+n.status+" "+n.statusText:""),n))})})})},n.AddPointerMetadata=function(e,t){e.metadata=e.metadata||{};var n=e._internalMetadata=e._internalMetadata||{},r=n.gltf=n.gltf||{};(r.pointers=r.pointers||[]).push(t)},n._GetTextureWrapMode=function(e,n){switch(n=null==n?10497:n){case 33071:return t.Texture.CLAMP_ADDRESSMODE;case 33648:return t.Texture.MIRROR_ADDRESSMODE;case 10497:return t.Texture.WRAP_ADDRESSMODE;default:return t.Logger.Warn("".concat(e,": Invalid value (").concat(n,")")),t.Texture.WRAP_ADDRESSMODE}},n._GetTextureSamplingMode=function(e,n){var r=null==n.magFilter?9729:n.magFilter,o=null==n.minFilter?9987:n.minFilter;if(9729===r)switch(o){case 9728:return t.Texture.LINEAR_NEAREST;case 9729:return t.Texture.LINEAR_LINEAR;case 9984:return t.Texture.LINEAR_NEAREST_MIPNEAREST;case 9985:return t.Texture.LINEAR_LINEAR_MIPNEAREST;case 9986:return t.Texture.LINEAR_NEAREST_MIPLINEAR;case 9987:return t.Texture.LINEAR_LINEAR_MIPLINEAR;default:return t.Logger.Warn("".concat(e,"/minFilter: Invalid value (").concat(o,")")),t.Texture.LINEAR_LINEAR_MIPLINEAR}else switch(9728!==r&&t.Logger.Warn("".concat(e,"/magFilter: Invalid value (").concat(r,")")),o){case 9728:return t.Texture.NEAREST_NEAREST;case 9729:return t.Texture.NEAREST_LINEAR;case 9984:return t.Texture.NEAREST_NEAREST_MIPNEAREST;case 9985:return t.Texture.NEAREST_LINEAR_MIPNEAREST;case 9986:return t.Texture.NEAREST_NEAREST_MIPLINEAR;case 9987:return t.Texture.NEAREST_LINEAR_MIPLINEAR;default:return t.Logger.Warn("".concat(e,"/minFilter: Invalid value (").concat(o,")")),t.Texture.NEAREST_NEAREST_MIPNEAREST}},n._GetTypedArrayConstructor=function(e,n){try{return t.GetTypedArrayConstructor(n)}catch(t){throw new Error("".concat(e,": ").concat(t.message),{cause:t})}},n._GetTypedArray=function(e,r,o,a,i){var s=o.buffer;a=o.byteOffset+(a||0);var l=n._GetTypedArrayConstructor("".concat(e,"/componentType"),r),u=t.VertexBufferGetTypeByteLength(r);return a%u!==0?(t.Logger.Warn("".concat(e,": Copying buffer as byte offset (").concat(a,") is not a multiple of component type byte length (").concat(u,")")),new l(s.slice(a,a+i*u),0)):new l(s,a,i)},n._GetNumComponents=function(e,t){switch(t){case"SCALAR":return 1;case"VEC2":return 2;case"VEC3":return 3;case"VEC4":case"MAT2":return 4;case"MAT3":return 9;case"MAT4":return 16}throw new Error("".concat(e,": Invalid type (").concat(t,")"))},n._ValidateUri=function(e){return t.Tools.IsBase64(e)||-1===e.indexOf("..")},n._GetDrawMode=function(e,n){switch(null==n&&(n=4),n){case 0:return t.Material.PointListDrawMode;case 1:return t.Material.LineListDrawMode;case 2:return t.Material.LineLoopDrawMode;case 3:return t.Material.LineStripDrawMode;case 4:return t.Material.TriangleFillMode;case 5:return t.Material.TriangleStripDrawMode;case 6:return t.Material.TriangleFanDrawMode}throw new Error("".concat(e,": Invalid mesh primitive mode (").concat(n,")"))},n.prototype._compileMaterialsAsync=function(){var e=this;this._parent._startPerformanceCounter("Compile materials");var t=new Array;if(this._gltf.materials)for(var n=0,r=this._gltf.materials;n<r.length;n++){var o=r[n];if(o._data)for(var a in o._data)for(var i=o._data[a],s=0,l=i.babylonMeshes;s<l.length;s++){var u=l[s];u.computeWorldMatrix(!0);var c=i.babylonMaterial;t.push(c.forceCompilationAsync(u)),t.push(c.forceCompilationAsync(u,{useInstances:!0})),this._parent.useClipPlane&&(t.push(c.forceCompilationAsync(u,{clipPlane:!0})),t.push(c.forceCompilationAsync(u,{clipPlane:!0,useInstances:!0})))}}return Promise.all(t).then(function(){e._parent._endPerformanceCounter("Compile materials")})},n.prototype._compileShadowGeneratorsAsync=function(){var e=this;this._parent._startPerformanceCounter("Compile shadow generators");for(var t=new Array,n=0,r=this._babylonScene.lights;n<r.length;n++){var o=r[n].getShadowGenerator();o&&t.push(o.forceCompilationAsync())}return Promise.all(t).then(function(){e._parent._endPerformanceCounter("Compile shadow generators")})},n.prototype._forEachExtensions=function(e){for(var t=0,n=this._extensions;t<n.length;t++){var r=n[t];r.enabled&&e(r)}},n.prototype._applyExtensions=function(e,t,n){for(var r=0,o=this._extensions;r<o.length;r++){var a=o[r];if(a.enabled){var i="".concat(a.name,".").concat(t),s=e;s._activeLoaderExtensionFunctions=s._activeLoaderExtensionFunctions||{};var l=s._activeLoaderExtensionFunctions;if(!l[i]){l[i]=!0;try{var u=n(a);if(u)return u}finally{delete l[i]}}}}return null},n.prototype._extensionsOnLoading=function(){this._forEachExtensions(function(e){return e.onLoading&&e.onLoading()})},n.prototype._extensionsOnReady=function(){this._forEachExtensions(function(e){return e.onReady&&e.onReady()})},n.prototype._extensionsLoadSceneAsync=function(e,t){return this._applyExtensions(t,"loadScene",function(n){return n.loadSceneAsync&&n.loadSceneAsync(e,t)})},n.prototype._extensionsLoadNodeAsync=function(e,t,n){return this._applyExtensions(t,"loadNode",function(r){return r.loadNodeAsync&&r.loadNodeAsync(e,t,n)})},n.prototype._extensionsLoadCameraAsync=function(e,t,n){return this._applyExtensions(t,"loadCamera",function(r){return r.loadCameraAsync&&r.loadCameraAsync(e,t,n)})},n.prototype._extensionsLoadVertexDataAsync=function(e,t,n){return this._applyExtensions(t,"loadVertexData",function(r){return r._loadVertexDataAsync&&r._loadVertexDataAsync(e,t,n)})},n.prototype._extensionsLoadMeshPrimitiveAsync=function(e,t,n,r,o,a){return this._applyExtensions(o,"loadMeshPrimitive",function(i){return i._loadMeshPrimitiveAsync&&i._loadMeshPrimitiveAsync(e,t,n,r,o,a)})},n.prototype._extensionsLoadMaterialAsync=function(e,t,n,r,o){return this._applyExtensions(t,"loadMaterial",function(a){return a._loadMaterialAsync&&a._loadMaterialAsync(e,t,n,r,o)})},n.prototype._extensionsCreateMaterial=function(e,t,n){return this._applyExtensions(t,"createMaterial",function(r){return r.createMaterial&&r.createMaterial(e,t,n)})},n.prototype._extensionsLoadMaterialPropertiesAsync=function(e,t,n){return this._applyExtensions(t,"loadMaterialProperties",function(r){return r.loadMaterialPropertiesAsync&&r.loadMaterialPropertiesAsync(e,t,n)})},n.prototype._extensionsLoadTextureInfoAsync=function(e,t,n){return this._applyExtensions(t,"loadTextureInfo",function(r){return r.loadTextureInfoAsync&&r.loadTextureInfoAsync(e,t,n)})},n.prototype._extensionsLoadTextureAsync=function(e,t,n){return this._applyExtensions(t,"loadTexture",function(r){return r._loadTextureAsync&&r._loadTextureAsync(e,t,n)})},n.prototype._extensionsLoadAnimationAsync=function(e,t){return this._applyExtensions(t,"loadAnimation",function(n){return n.loadAnimationAsync&&n.loadAnimationAsync(e,t)})},n.prototype._extensionsLoadAnimationChannelAsync=function(e,t,n,r,o){return this._applyExtensions(n,"loadAnimationChannel",function(a){return a._loadAnimationChannelAsync&&a._loadAnimationChannelAsync(e,t,n,r,o)})},n.prototype._extensionsLoadSkinAsync=function(e,t,n){return this._applyExtensions(n,"loadSkin",function(r){return r._loadSkinAsync&&r._loadSkinAsync(e,t,n)})},n.prototype._extensionsLoadUriAsync=function(e,t,n){return this._applyExtensions(t,"loadUri",function(r){return r._loadUriAsync&&r._loadUriAsync(e,t,n)})},n.prototype._extensionsLoadBufferViewAsync=function(e,t){return this._applyExtensions(t,"loadBufferView",function(n){return n.loadBufferViewAsync&&n.loadBufferViewAsync(e,t)})},n.prototype._extensionsLoadBufferAsync=function(e,t,n,r){return this._applyExtensions(t,"loadBuffer",function(o){return o.loadBufferAsync&&o.loadBufferAsync(e,t,n,r)})},n.LoadExtensionAsync=function(e,t,n,r){if(!t.extensions)return null;var o=t.extensions[n];return o?r("".concat(e,"/extensions/").concat(n),o):null},n.LoadExtraAsync=function(e,t,n,r){if(!t.extras)return null;var o=t.extras[n];return o?r("".concat(e,"/extras/").concat(n),o):null},n.prototype.isExtensionUsed=function(e){return!!this._gltf.extensionsUsed&&-1!==this._gltf.extensionsUsed.indexOf(e)},n.prototype.logOpen=function(e){this._parent._logOpen(e)},n.prototype.logClose=function(){this._parent._logClose()},n.prototype.log=function(e){this._parent._log(e)},n.prototype.startPerformanceCounter=function(e){this._parent._startPerformanceCounter(e)},n.prototype.endPerformanceCounter=function(e){this._parent._endPerformanceCounter(e)},n.DefaultSampler={index:-1},n}();hn._CreateGLTF2Loader=function(e){return new yr(e)};var br={__proto__:null,ArrayItem:_r,GLTFFileLoader:hn,GLTFLoader:yr,LoadBoundingInfoFromPositionAccessor:gr};function xr(e,n,r,o){return t.Vector3.FromArray(n,r).scaleInPlace(o)}function Tr(e,n,r,o){return t.Quaternion.FromArray(n,r).scaleInPlace(o)}function Ar(e,t,n,r){for(var o=new Array(e._numMorphTargets),a=0;a<o.length;a++)o[a]=t[n++]*r;return o}var wr=function(){function e(e,t,n,r){this.type=e,this.name=t,this.getValue=n,this.getStride=r}return e.prototype._buildAnimation=function(e,n,r){var o=new t.Animation(e,this.name,n,this.type);return o.setKeys(r,!0),o},e}(),Mr=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return m(t,e),t.prototype.buildAnimations=function(e,t,n,r){var o=[];return o.push({babylonAnimatable:e._babylonTransformNode,babylonAnimation:this._buildAnimation(t,n,r)}),o},t}(wr),Cr=function(e){function n(){return null!==e&&e.apply(this,arguments)||this}return m(n,e),n.prototype.buildAnimations=function(e,n,r,o){var a=[];if(e._numMorphTargets)for(var i=function(i){var l=new t.Animation("".concat(n,"_").concat(i),s.name,r,s.type);if(l.setKeys(o.map(function(e){return{frame:e.frame,inTangent:e.inTangent?e.inTangent[i]:void 0,value:e.value[i],outTangent:e.outTangent?e.outTangent[i]:void 0,interpolation:e.interpolation}}),!0),e._primitiveBabylonMeshes)for(var u=0,c=e._primitiveBabylonMeshes;u<c.length;u++){var f=c[u];if(f.morphTargetManager){var d=f.morphTargetManager.getTarget(i),h=l.clone();d.animations.push(h),a.push({babylonAnimatable:d,babylonAnimation:h})}}},s=this,l=0;l<e._numMorphTargets;l++)i(l);return a},n}(wr);hr("/nodes/{}/translation",[new Mr(t.Animation.ANIMATIONTYPE_VECTOR3,"position",xr,function(){return 3})]),hr("/nodes/{}/rotation",[new Mr(t.Animation.ANIMATIONTYPE_QUATERNION,"rotationQuaternion",Tr,function(){return 4})]),hr("/nodes/{}/scale",[new Mr(t.Animation.ANIMATIONTYPE_VECTOR3,"scaling",xr,function(){return 3})]),hr("/nodes/{}/weights",[new Cr(t.Animation.ANIMATIONTYPE_FLOAT,"influence",Ar,function(e){return e._numMorphTargets})]);var Or={__proto__:null,AnimationPropertyInfo:wr,TransformNodeAnimationPropertyInfo:Mr,WeightAnimationPropertyInfo:Cr,getQuaternion:Tr,getVector3:xr,getWeights:Ar},Sr=function(){function e(e){this._specWorkflow=!1,this._diffuseTransmissionTint=t.Color3.White(),this._diffuseTransmissionTintTexture=null,this._material=e}return Object.defineProperty(e.prototype,"material",{get:function(){return this._material},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isUnlit",{get:function(){return this._material.unlit},set:function(e){this._material.unlit=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"backFaceCulling",{get:function(){return this._material.backFaceCulling},set:function(e){this._material.backFaceCulling=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"twoSidedLighting",{get:function(){return this._material.twoSidedLighting},set:function(e){this._material.twoSidedLighting=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"alphaCutOff",{get:function(){return this._material.alphaCutOff},set:function(e){this._material.alphaCutOff=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"useAlphaFromBaseColorTexture",{get:function(){return this._material._useAlphaFromBaseColorTexture},set:function(e){this._material._useAlphaFromBaseColorTexture=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"transparencyAsAlphaCoverage",{get:function(){return!1},set:function(e){},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"baseColor",{get:function(){return this._material.baseColor},set:function(e){this._material.baseColor=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"baseColorTexture",{get:function(){return this._material.baseColorTexture},set:function(e){this._material.baseColorTexture=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"baseDiffuseRoughness",{get:function(){return this._material.baseDiffuseRoughness},set:function(e){this._material.baseDiffuseRoughness=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"baseDiffuseRoughnessTexture",{get:function(){return this._material.baseDiffuseRoughnessTexture},set:function(e){this._material.baseDiffuseRoughnessTexture=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"baseMetalness",{get:function(){return this._material.baseMetalness},set:function(e){this._material.baseMetalness=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"baseMetalnessTexture",{get:function(){return this._material.baseMetalnessTexture},set:function(e){this._material.baseMetalnessTexture=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"useRoughnessFromMetallicTextureGreen",{set:function(e){this._material._useRoughnessFromMetallicTextureGreen=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"useMetallicFromMetallicTextureBlue",{set:function(e){this._material._useMetallicFromMetallicTextureBlue=e},enumerable:!1,configurable:!0}),e.prototype.enableSpecularEdgeColor=function(e){void 0===e&&(e=!1)},e.prototype.configureSpecularGlossiness=function(){this._specWorkflow=!0},Object.defineProperty(e.prototype,"specularWeight",{get:function(){return this._material.specularWeight},set:function(e){this._material.specularWeight=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"specularWeightTexture",{get:function(){return this._material.specularWeightTexture},set:function(e){this._material.specularColorTexture===e?(this._material.specularWeightTexture=null,this._material._useSpecularWeightFromSpecularColorTexture=!0,this._material._useSpecularWeightFromAlpha=!0):this._material.specularWeightTexture=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"specularColor",{get:function(){return this._material.specularColor},set:function(e){this._material.specularColor=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"specularColorTexture",{get:function(){return this._material.specularColorTexture},set:function(e){this._material.specularColorTexture=e,this._material.specularWeightTexture===this._material.specularColorTexture&&(this._material.specularWeightTexture=null,this._material._useSpecularWeightFromSpecularColorTexture=!0,this._material._useSpecularWeightFromAlpha=!0)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"specularRoughness",{get:function(){return this._material.specularRoughness},set:function(e){this._material.specularRoughness=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"specularRoughnessTexture",{get:function(){return this._material.specularRoughnessTexture},set:function(e){this._material.specularRoughnessTexture=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"specularIor",{get:function(){return this._material.specularIor},set:function(e){this._material.specularIor=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"glossiness",{get:function(){return 1-this._material.specularRoughness},set:function(e){this._material.specularRoughness=Math.max(1-e,0)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"emissionColor",{get:function(){return this._material.emissionColor},set:function(e){this._material.emissionColor=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"emissionLuminance",{get:function(){return this._material.emissionLuminance},set:function(e){this._material.emissionLuminance=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"emissionColorTexture",{get:function(){return this._material.emissionColorTexture},set:function(e){this._material.emissionColorTexture=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"ambientOcclusionTexture",{get:function(){return this._material.ambientOcclusionTexture},set:function(e){this._material.ambientOcclusionTexture=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"ambientOcclusionTextureStrength",{get:function(){var e,t=this._material.ambientOcclusionTexture;return null!==(e=null==t?void 0:t.level)&&void 0!==e?e:1},set:function(e){var t=this._material.ambientOcclusionTexture;t&&(t.level=e)},enumerable:!1,configurable:!0}),e.prototype.configureCoat=function(){},Object.defineProperty(e.prototype,"coatWeight",{get:function(){return this._material.coatWeight},set:function(e){this._material.coatWeight=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"coatWeightTexture",{get:function(){return this._material.coatWeightTexture},set:function(e){this._material.coatWeightTexture=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"coatColor",{get:function(){return this._material.coatColor},set:function(e){this._material.coatColor=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"coatColorTexture",{set:function(e){this._material.coatColorTexture=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"coatRoughness",{get:function(){return this._material.coatRoughness},set:function(e){this._material.coatRoughness=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"coatRoughnessTexture",{get:function(){return this._material.coatRoughnessTexture},set:function(e){this._material.coatRoughnessTexture=e,e&&(this._material._useCoatRoughnessFromGreenChannel=!0)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"coatIor",{get:function(){return this._material.coatIor},set:function(e){this._material.coatIor=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"coatDarkening",{get:function(){return this._material.coatDarkening},set:function(e){this._material.coatDarkening=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"coatDarkeningTexture",{set:function(e){this._material.coatDarkeningTexture=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"coatRoughnessAnisotropy",{get:function(){return this._material.coatRoughnessAnisotropy},set:function(e){this._material.coatRoughnessAnisotropy=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"geometryCoatTangentAngle",{set:function(e){this._material.geometryCoatTangentAngle=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"geometryCoatTangentTexture",{get:function(){return this._material.geometryCoatTangentTexture},set:function(e){this._material.geometryCoatTangentTexture=e,e&&(this._material._useCoatRoughnessAnisotropyFromTangentTexture=!0)},enumerable:!1,configurable:!0}),e.prototype.configureTransmission=function(){this._material.geometryThinWalled=1,this._material.transmissionDepth=0},Object.defineProperty(e.prototype,"transmissionWeight",{get:function(){return this._material.transmissionWeight},set:function(e){this._material.transmissionWeight=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"transmissionWeightTexture",{get:function(){return this._material.transmissionWeightTexture},set:function(e){this._material.transmissionWeightTexture=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"transmissionScatter",{get:function(){return this._material.transmissionScatter},set:function(e){this._material.transmissionScatter=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"transmissionScatterTexture",{get:function(){return this._material.transmissionScatterTexture},set:function(e){this._material.transmissionScatterTexture=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"transmissionScatterAnisotropy",{set:function(e){this._material.transmissionScatterAnisotropy=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"transmissionDispersionAbbeNumber",{set:function(e){this._material.transmissionDispersionAbbeNumber=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"transmissionDispersionScale",{set:function(e){this._material.transmissionDispersionScale=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"transmissionDepth",{get:function(){return this._material.transmissionDepth},set:function(e){e!==Number.MAX_VALUE||0!==this._material.transmissionDepth?this._material.transmissionDepth=e:this._material.transmissionDepth=0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"transmissionColor",{get:function(){return this._material.transmissionColor},set:function(e){e.equals(t.Color3.White())||(this._material.transmissionColor=e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"refractionBackgroundTexture",{get:function(){return this._material.backgroundRefractionTexture},set:function(e){this._material.backgroundRefractionTexture=e},enumerable:!1,configurable:!0}),e.prototype.configureVolume=function(){this._material.geometryThinWalled=0},Object.defineProperty(e.prototype,"geometryThinWalled",{get:function(){return!!this._material.geometryThinWalled},set:function(e){this._material.geometryThinWalled=e?1:0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"volumeThicknessTexture",{set:function(e){this._material.geometryThicknessTexture=e,this._material._useGeometryThicknessFromGreenChannel=!0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"volumeThickness",{set:function(e){this._material.geometryThickness=e},enumerable:!1,configurable:!0}),e.prototype.configureSubsurface=function(){this._material.geometryThinWalled=1,this._material.subsurfaceScatterAnisotropy=1},Object.defineProperty(e.prototype,"subsurfaceWeight",{get:function(){return this._material.subsurfaceWeight},set:function(e){this._material.subsurfaceWeight=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"subsurfaceWeightTexture",{get:function(){return this._material.subsurfaceWeightTexture},set:function(e){this._material.subsurfaceWeightTexture=e,this._material._useSubsurfaceWeightFromTextureAlpha=!0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"subsurfaceColor",{set:function(e){this._material.subsurfaceColor=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"subsurfaceColorTexture",{set:function(e){this._material.subsurfaceColorTexture=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"diffuseTransmissionTint",{get:function(){return this._diffuseTransmissionTint},set:function(e){this._diffuseTransmissionTint=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"diffuseTransmissionTintTexture",{set:function(e){this._diffuseTransmissionTintTexture=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"subsurfaceRadius",{get:function(){return this._material.subsurfaceRadius},set:function(e){this._material.subsurfaceRadius=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"subsurfaceRadiusScale",{get:function(){return this._material.subsurfaceRadiusScale},set:function(e){this._material.subsurfaceRadiusScale=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"subsurfaceScatterAnisotropy",{set:function(e){this._material.subsurfaceScatterAnisotropy=e},enumerable:!1,configurable:!0}),e.prototype.isTranslucent=function(){return this.transmissionWeight>0||this.subsurfaceWeight>0},e.prototype.configureFuzz=function(){},Object.defineProperty(e.prototype,"fuzzWeight",{set:function(e){this._material.fuzzWeight=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"fuzzWeightTexture",{set:function(e){this._material.fuzzWeightTexture=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"fuzzColor",{set:function(e){this._material.fuzzColor=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"fuzzColorTexture",{set:function(e){this._material.fuzzColorTexture=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"fuzzRoughness",{set:function(e){this._material.fuzzRoughness=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"fuzzRoughnessTexture",{set:function(e){this._material.fuzzRoughnessTexture=e,this._material._useFuzzRoughnessFromTextureAlpha=!0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"specularRoughnessAnisotropy",{get:function(){return this._material.specularRoughnessAnisotropy},set:function(e){this._material.specularRoughnessAnisotropy=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"geometryTangentAngle",{set:function(e){this._material.geometryTangentAngle=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"geometryTangentTexture",{get:function(){return this._material.geometryTangentTexture},set:function(e){this._material.geometryTangentTexture=e,this._material._useSpecularRoughnessAnisotropyFromTangentTexture=!0},enumerable:!1,configurable:!0}),e.prototype.configureGltfStyleAnisotropy=function(e){void 0===e&&(e=!0),this._material._useGltfStyleAnisotropy=e},Object.defineProperty(e.prototype,"thinFilmWeight",{set:function(e){this._material.thinFilmWeight=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"thinFilmIor",{set:function(e){this._material.thinFilmIor=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"thinFilmThicknessMinimum",{set:function(e){this._material.thinFilmThicknessMin=e/1e3},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"thinFilmThicknessMaximum",{set:function(e){this._material.thinFilmThickness=e/1e3},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"thinFilmWeightTexture",{set:function(e){this._material.thinFilmWeightTexture=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"thinFilmThicknessTexture",{set:function(e){this._material.thinFilmThicknessTexture=e,this._material._useThinFilmThicknessFromTextureGreen=!0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"unlit",{set:function(e){this._material.unlit=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"geometryOpacity",{get:function(){return this._material.geometryOpacity},set:function(e){this._material.geometryOpacity=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"geometryNormalTexture",{get:function(){return this._material.geometryNormalTexture},set:function(e){this._material.geometryNormalTexture=e},enumerable:!1,configurable:!0}),e.prototype.setNormalMapInversions=function(e,t){},Object.defineProperty(e.prototype,"geometryCoatNormalTexture",{get:function(){return this._material.geometryCoatNormalTexture},set:function(e){this._material.geometryCoatNormalTexture=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"geometryCoatNormalTextureScale",{set:function(e){this._material.geometryCoatNormalTexture&&(this._material.geometryCoatNormalTexture.level=e)},enumerable:!1,configurable:!0}),e.prototype.finalizeAsync=function(e){return _(this,void 0,void 0,function(){var n,r,o,a,i,s,l,u,c,f;return g(this,function(d){switch(d.label){case 0:return this._diffuseTransmissionTint&&!this._diffuseTransmissionTint.equals(t.Color3.White())||this._diffuseTransmissionTintTexture?this._material.geometryThinWalled?(this.subsurfaceColor=this._diffuseTransmissionTint,this.subsurfaceColorTexture=this._diffuseTransmissionTintTexture,[3,3]):[3,1]:[3,3];case 1:return[4,this.copySurfaceToCoatAsync(e,this.subsurfaceWeight,this.subsurfaceWeightTexture,t.TextureChannel.A,this._diffuseTransmissionTint,this._diffuseTransmissionTintTexture,!0)];case 2:if(d.sent(),e._disposed)return[2];d.label=3;case 3:return this.transmissionWeight>0?this._material.geometryThinWalled||0===this._material.transmissionDepth?(this._material.transmissionColor=this._material.baseColor,this._material.transmissionColorTexture=this._material.baseColorTexture,[3,6]):[3,4]:[3,6];case 4:return this.baseColor.equals(t.Color3.White())&&null===this.baseColorTexture?[3,6]:[4,this.copySurfaceToCoatAsync(e,this.transmissionWeight,this.transmissionWeightTexture,t.TextureChannel.R,this.baseColor,this.baseColorTexture,!1)];case 5:if(d.sent(),e._disposed)return[2];d.label=6;case 6:return this._specWorkflow?(r=t.InvertTextureAsync,o=["newRoughnessTexture ("+this._material.name+")"],[4,t.ExtractChannelAsync("glossiness ("+this._material.name+")",t.CreateTextureWithFactorOperand(this.specularColorTexture,new t.Color4(this.specularColor.r,this.specularColor.g,this.specularColor.b,this.glossiness),t.TextureChannel.A,t.TextureColorSpace.Linear),t.TextureChannel.A,this._material.getScene(),t.TextureColorSpace.Linear,t.ChannelMask.R)]):[3,11];case 7:return[4,r.apply(void 0,o.concat([d.sent(),this._material.getScene(),t.ChannelMask.R,t.TextureColorSpace.Linear,t.ChannelMask.R]))];case 8:return n=d.sent(),e._disposed?(null===(u=n.texture)||void 0===u||u.dispose(),[2]):(this.specularRoughnessTexture=n.texture,this.specularRoughness=n.factor?n.factor.r:1,[4,t.ExtractMaxChannelAsync("metallicTexture ("+this._material.name+")",t.CreateTextureWithFactorOperand(this.specularColorTexture,this.specularColor.toColor4(),t.TextureChannel.RGBA,t.TextureColorSpace.Linear),this._material.getScene(),!1,t.TextureColorSpace.SRGB,t.ChannelMask.RGB)]);case 9:return a=d.sent(),e._disposed?(null===(c=a.texture)||void 0===c||c.dispose(),[2]):(this.baseMetalnessTexture=a.texture,this.baseMetalness=a.factor?a.factor.r:1,[4,t.LerpTexturesAsync("newBaseColor ("+this._material.name+")",t.CreateTextureWithFactorOperand(this.baseColorTexture,this.baseColor.toColor4(),t.TextureChannel.RGBA,t.TextureColorSpace.Linear),t.CreateTextureWithFactorOperand(this.specularColorTexture,this.specularColor.toColor4(),t.TextureChannel.RGBA,t.TextureColorSpace.Linear),v(v({},a),{dispose:void 0,colorSpace:t.TextureColorSpace.Linear}),this._material.getScene(),t.TextureColorSpace.SRGB,t.ChannelMask.RGB)]);case 10:if(i=d.sent(),e._disposed)return null===(f=i.texture)||void 0===f||f.dispose(),[2];null==(s=this.baseColorTexture)||s.dispose(),this.baseColorTexture=i.texture,this.baseColor=i.factor?new t.Color3(i.factor.r,i.factor.g,i.factor.b):t.Color3.White(),null==(l=this.specularColorTexture)||l.dispose(),this.specularColorTexture=null,d.label=11;case 11:return[2]}})})},e.prototype.copySurfaceToCoatAsync=function(e,n,r,o,a,i){return _(this,arguments,void 0,function(e,n,r,o,a,i,s){var l,u,c,f,d,h,p,m,v,_,y,b,x,T,A,w,M,C,O,S,E,F,R,L,I,P,N,B,k,D;return void 0===s&&(s=!1),g(this,function(g){switch(g.label){case 0:return l=this._material.coatWeight,u=this._material.coatWeightTexture,c=this._material.coatColor.clone(),f=this._material.coatColorTexture,d=this._material.geometryCoatNormalTexture,h=new t.Color4(l,l,l,l),p=new t.Color4(n,n,n,n),this.coatWeightTexture=null,this.coatWeight=1,[4,Promise.allSettled([t.LerpTexturesAsync("lerpExistingCoat",t.CreateTextureWithFactorOperand(null,new t.Color4(1,1,1,1)),t.CreateTextureWithFactorOperand(f,c.toColor4(),t.TextureChannel.RGBA,t.TextureColorSpace.SRGB),t.CreateTextureWithFactorOperand(u,h,t.TextureChannel.R),this._material.getScene(),t.TextureColorSpace.SRGB),t.LerpTexturesAsync("lerpSurfaceColor",t.CreateTextureWithFactorOperand(null,new t.Color4(1,1,1,1)),t.CreateTextureWithFactorOperand(i,a.toColor4(),t.TextureChannel.RGBA,t.TextureColorSpace.SRGB),t.CreateTextureWithFactorOperand(r,p,o),this._material.getScene(),t.TextureColorSpace.SRGB)])];case 1:if(m=g.sent(),v=m.find(function(e){return"rejected"===e.status}),v){for(_=0,y=m;_<y.length;_++)"fulfilled"===(b=y[_]).status&&(null===(F=b.value.texture)||void 0===F||F.dispose());throw v.reason}return x=m.map(function(e){return e.value}),T=x[0],A=x[1],e._disposed?(null===(R=T.texture)||void 0===R||R.dispose(),null===(L=A.texture)||void 0===L||L.dispose(),[2]):[4,t.MultiplyTexturesAsync("newCoatColor ("+this._material.name+")",T,A,this._material.getScene(),t.TextureColorSpace.SRGB)];case 2:return w=g.sent(),e._disposed?(null===(I=w.texture)||void 0===I||I.dispose(),[2]):(w.texture?(this.coatColorTexture=w.texture,this.coatColor=t.Color3.White()):w.factor&&(this.coatColorTexture=null,this.coatColor.fromArray([w.factor.r,w.factor.g,w.factor.b])),[4,t.LerpTexturesAsync("newCoatIor ("+this._material.name+")",t.CreateTextureWithFactorOperand(null,new t.Color4(this._material.specularIor,this._material.specularIor,this._material.specularIor,1),t.TextureChannel.R),t.CreateTextureWithFactorOperand(null,new t.Color4(this.coatIor,this.coatIor,this.coatIor,1),t.TextureChannel.R),t.CreateTextureWithFactorOperand(u,h,t.TextureChannel.R),this._material.getScene())]);case 3:return M=g.sent(),e._disposed?(null===(P=M.texture)||void 0===P||P.dispose(),[2]):(this.coatIor=M.factor?M.factor.r:this.coatIor,[4,t.LerpTexturesAsync("newCoatRoughness ("+this._material.name+")",t.CreateTextureWithFactorOperand(this.specularRoughnessTexture,new t.Color4(this.specularRoughness,this.specularRoughness,this.specularRoughness,1),t.TextureChannel.G),t.CreateTextureWithFactorOperand(this.coatRoughnessTexture,new t.Color4(this.coatRoughness,this.coatRoughness,this.coatRoughness,1),t.TextureChannel.G),t.CreateTextureWithFactorOperand(u,h,t.TextureChannel.R),this._material.getScene())]);case 4:return C=g.sent(),e._disposed?(null===(N=C.texture)||void 0===N||N.dispose(),[2]):(this.coatRoughness=C.factor?C.factor.r:1,this.coatRoughnessTexture=C.texture,[4,t.LerpTexturesAsync("newCoatDarkening ("+this._material.name+")",t.CreateTextureWithFactorOperand(null,new t.Color4(0,0,0,1),t.TextureChannel.R),t.CreateTextureWithFactorOperand(null,new t.Color4(this.coatDarkening,this.coatDarkening,this.coatDarkening,1),t.TextureChannel.R),t.CreateTextureWithFactorOperand(u,h,t.TextureChannel.R),this._material.getScene())]);case 5:return O=g.sent(),e._disposed?(null===(B=O.texture)||void 0===B||B.dispose(),[2]):(this.coatDarkening=O.factor?O.factor.r:this.coatDarkening,s?[4,t.LerpTexturesAsync("newSpecularRoughness ("+this._material.name+")",t.CreateTextureWithFactorOperand(this.specularRoughnessTexture,new t.Color4(this._material.specularRoughness,this._material.specularRoughness,this._material.specularRoughness,1),t.TextureChannel.G),t.CreateTextureWithFactorOperand(null,new t.Color4(1,1,1,1),t.TextureChannel.R),t.CreateTextureWithFactorOperand(r,p,o),this._material.getScene())]:[3,7]);case 6:if(S=g.sent(),e._disposed)return null===(k=S.texture)||void 0===k||k.dispose(),[2];this.specularRoughness=S.factor?S.factor.r:1,this.specularRoughnessTexture=S.texture,g.label=7;case 7:return d||this.geometryNormalTexture?[4,t.LerpTexturesAsync("newCoatNormal ("+this._material.name+")",t.CreateTextureWithFactorOperand(this.geometryNormalTexture,this.geometryNormalTexture?new t.Color4(1,1,1,1):new t.Color4(.5,.5,1,1),t.TextureChannel.RGBA),t.CreateTextureWithFactorOperand(d,d?new t.Color4(1,1,1,1):new t.Color4(.5,.5,1,1),t.TextureChannel.RGBA),t.CreateTextureWithFactorOperand(u,h,t.TextureChannel.R),this._material.getScene())]:[3,9];case 8:if(E=g.sent(),e._disposed)return null===(D=E.texture)||void 0===D||D.dispose(),[2];E.texture&&(this.geometryCoatNormalTexture=E.texture),g.label=9;case 9:return[2]}})})},e}(),Er={__proto__:null,OpenPBRMaterialLoadingAdapter:Sr},Fr=function(){function e(e){this._specWorkflow=!1,this._material=e,this._material.enableSpecularAntiAliasing=!0}return Object.defineProperty(e.prototype,"material",{get:function(){return this._material},enumerable:!1,configurable:!0}),e.prototype.finalizeAsync=function(e){return _(this,void 0,void 0,function(){return g(this,function(e){return[2]})})},Object.defineProperty(e.prototype,"isUnlit",{get:function(){return this._material.unlit},set:function(e){this._material.unlit=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"backFaceCulling",{get:function(){return this._material.backFaceCulling},set:function(e){this._material.backFaceCulling=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"twoSidedLighting",{get:function(){return this._material.twoSidedLighting},set:function(e){this._material.twoSidedLighting=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"alphaCutOff",{get:function(){return this._material.alphaCutOff},set:function(e){this._material.alphaCutOff=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"useAlphaFromBaseColorTexture",{get:function(){return this._material.useAlphaFromAlbedoTexture},set:function(e){this._material.useAlphaFromAlbedoTexture=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"transparencyAsAlphaCoverage",{get:function(){return this._material.useRadianceOverAlpha||this._material.useSpecularOverAlpha},set:function(e){this._material.useRadianceOverAlpha=!e,this._material.useSpecularOverAlpha=!e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"baseColor",{get:function(){return this._material.albedoColor},set:function(e){this._material.albedoColor=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"baseColorTexture",{get:function(){return this._material.albedoTexture},set:function(e){this._material.albedoTexture=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"baseDiffuseRoughness",{get:function(){var e;return null!==(e=this._material.baseDiffuseRoughness)&&void 0!==e?e:0},set:function(e){this._material.baseDiffuseRoughness=e,e>0&&(this._material.brdf.baseDiffuseModel=t.Constants.MATERIAL_DIFFUSE_MODEL_E_OREN_NAYAR)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"baseDiffuseRoughnessTexture",{get:function(){return this._material.baseDiffuseRoughnessTexture},set:function(e){this._material.baseDiffuseRoughnessTexture=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"baseMetalness",{get:function(){var e;return null!==(e=this._material.metallic)&&void 0!==e?e:1},set:function(e){this._material.metallic=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"baseMetalnessTexture",{get:function(){return this._material.metallicTexture},set:function(e){this._material.metallicTexture=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"useRoughnessFromMetallicTextureGreen",{set:function(e){this._material.useRoughnessFromMetallicTextureGreen=e,this._material.useRoughnessFromMetallicTextureAlpha=!e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"useMetallicFromMetallicTextureBlue",{set:function(e){this._material.useMetallnessFromMetallicTextureBlue=e},enumerable:!1,configurable:!0}),e.prototype.enableSpecularEdgeColor=function(e){void 0===e&&(e=!1),e&&(this._material.brdf.dielectricSpecularModel=t.Constants.MATERIAL_DIELECTRIC_SPECULAR_MODEL_OPENPBR,this._material.brdf.conductorSpecularModel=t.Constants.MATERIAL_CONDUCTOR_SPECULAR_MODEL_OPENPBR)},e.prototype.configureSpecularGlossiness=function(){this._specWorkflow=!0,this._material.metallic=null,this._material.roughness=null,this._material.useMicroSurfaceFromReflectivityMapAlpha=!0},Object.defineProperty(e.prototype,"specularWeight",{get:function(){var e;return null!==(e=this._material.metallicF0Factor)&&void 0!==e?e:1},set:function(e){this._material.metallicF0Factor=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"specularWeightTexture",{get:function(){return this._material.metallicReflectanceTexture},set:function(e){e?(this._material.metallicReflectanceTexture=e,this._material.useOnlyMetallicFromMetallicReflectanceTexture=!0):(this._material.metallicReflectanceTexture=null,this._material.useOnlyMetallicFromMetallicReflectanceTexture=!1)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"specularColor",{get:function(){return this._specWorkflow?this._material.reflectivityColor:this._material.metallicReflectanceColor},set:function(e){this._specWorkflow?this._material.reflectivityColor=e:this._material.metallicReflectanceColor=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"specularColorTexture",{get:function(){return this._specWorkflow?this._material.reflectivityTexture:this._material.reflectanceTexture},set:function(e){this._specWorkflow?(this._material.reflectivityTexture=e,this._material.reflectivityTexture&&(this._material.reflectivityTexture.hasAlpha=!0)):this._material.reflectanceTexture=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"specularRoughness",{get:function(){var e;return null!==(e=this._material.roughness)&&void 0!==e?e:1},set:function(e){this._material.roughness=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"specularRoughnessTexture",{get:function(){return this._material.metallicTexture},set:function(e){this.baseMetalnessTexture||(this._material.metallicTexture=e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"specularIor",{get:function(){return this._material.indexOfRefraction},set:function(e){this._material.indexOfRefraction=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"glossiness",{get:function(){var e;return null!==(e=this._material.microSurface)&&void 0!==e?e:1},set:function(e){this._material.microSurface=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"emissionColor",{get:function(){return this._material.emissiveColor},set:function(e){this._material.emissiveColor=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"emissionLuminance",{get:function(){return this._material.emissiveIntensity},set:function(e){this._material.emissiveIntensity=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"emissionColorTexture",{get:function(){return this._material.emissiveTexture},set:function(e){this._material.emissiveTexture=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"ambientOcclusionTexture",{get:function(){return this._material.ambientTexture},set:function(e){this._material.ambientTexture=e,e&&(this._material.useAmbientInGrayScale=!0)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"ambientOcclusionTextureStrength",{get:function(){var e;return null!==(e=this._material.ambientTextureStrength)&&void 0!==e?e:1},set:function(e){this._material.ambientTextureStrength=e},enumerable:!1,configurable:!0}),e.prototype.configureCoat=function(){this._material.clearCoat.isEnabled=!0,this._material.clearCoat.useRoughnessFromMainTexture=!1,this._material.clearCoat.remapF0OnInterfaceChange=!1},Object.defineProperty(e.prototype,"coatWeight",{get:function(){return this._material.clearCoat.intensity},set:function(e){this._material.clearCoat.isEnabled=!0,this._material.clearCoat.intensity=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"coatWeightTexture",{get:function(){return this._material.clearCoat.texture},set:function(e){this._material.clearCoat.isEnabled=!0,this._material.clearCoat.texture=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"coatColor",{set:function(e){this._material.clearCoat.isTintEnabled=e!=t.Color3.White(),this._material.clearCoat.tintColor=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"coatColorTexture",{set:function(e){this._material.clearCoat.tintTexture=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"coatRoughness",{get:function(){var e;return null!==(e=this._material.clearCoat.roughness)&&void 0!==e?e:0},set:function(e){this._material.clearCoat.isEnabled=!0,this._material.clearCoat.roughness=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"coatRoughnessTexture",{get:function(){return this._material.clearCoat.textureRoughness},set:function(e){this._material.clearCoat.isEnabled=!0,this._material.clearCoat.useRoughnessFromMainTexture=!1,this._material.clearCoat.textureRoughness=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"coatIor",{set:function(e){this._material.clearCoat.indexOfRefraction=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"coatDarkening",{set:function(e){},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"coatDarkeningTexture",{set:function(e){},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"coatRoughnessAnisotropy",{get:function(){return 0},set:function(e){},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"geometryCoatTangentAngle",{set:function(e){},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"geometryCoatTangentTexture",{get:function(){return null},set:function(e){},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"transmissionWeight",{get:function(){return this._material.subSurface.isRefractionEnabled?this._material.subSurface.refractionIntensity:0},set:function(e){this._material.subSurface.isRefractionEnabled=e>0,this._material.subSurface.refractionIntensity=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"transmissionWeightTexture",{set:function(e){this._material.subSurface.isRefractionEnabled=!0,this._material.subSurface.refractionIntensityTexture=e,this._material.subSurface.useGltfStyleTextures=!0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"transmissionDepth",{get:function(){return this.transmissionWeight>0?this._material.subSurface.tintColorAtDistance:0},set:function(e){this.transmissionWeight>0?this._material.subSurface.tintColorAtDistance=e:this.subsurfaceWeight>0&&this._material.subSurface.diffusionDistance.multiplyInPlace(new t.Color3(e,e,e))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"transmissionColor",{get:function(){return this.transmissionWeight>0?this._material.subSurface.tintColor:this.subsurfaceWeight>0?this._material.subSurface.diffusionDistance:new t.Color3(0,0,0)},set:function(e){this.transmissionWeight>0?this._material.subSurface.tintColor=e:this.subsurfaceWeight>0&&this._material.subSurface.diffusionDistance.multiplyInPlace(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"transmissionScatter",{get:function(){return this._material.subSurface.diffusionDistance},set:function(e){this._material.subSurface.diffusionDistance=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"transmissionScatterTexture",{set:function(e){},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"transmissionScatterAnisotropy",{set:function(e){},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"transmissionDispersionAbbeNumber",{set:function(e){},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"transmissionDispersionScale",{set:function(e){e>0?(this._material.subSurface.isDispersionEnabled=!0,this._material.subSurface.dispersion=20/e):(this._material.subSurface.isDispersionEnabled=!1,this._material.subSurface.dispersion=0)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"refractionBackgroundTexture",{get:function(){return this._material.subSurface.refractionTexture},set:function(e){this._material.subSurface.refractionTexture=e},enumerable:!1,configurable:!0}),e.prototype.configureTransmission=function(){this._material.subSurface.volumeIndexOfRefraction=1,this._material.subSurface.useAlbedoToTintRefraction=!0,this._material.subSurface.minimumThickness=0,this._material.subSurface.maximumThickness=0},e.prototype.configureVolume=function(){},Object.defineProperty(e.prototype,"geometryThinWalled",{get:function(){return 0===this._material.subSurface.maximumThickness},set:function(e){},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"volumeThicknessTexture",{set:function(e){this._material.subSurface.thicknessTexture=e,this._material.subSurface.useGltfStyleTextures=!0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"volumeThickness",{set:function(e){this._material.subSurface.minimumThickness=0,this._material.subSurface.maximumThickness=e,this._material.subSurface.useThicknessAsDepth=!0,e>0&&(this._material.subSurface.volumeIndexOfRefraction=this._material.indexOfRefraction)},enumerable:!1,configurable:!0}),e.prototype.configureSubsurface=function(){this._material.subSurface.useGltfStyleTextures=!0,this._material.subSurface.volumeIndexOfRefraction=1,this._material.subSurface.minimumThickness=0,this._material.subSurface.maximumThickness=0,this._material.subSurface.useAlbedoToTintTranslucency=!1},Object.defineProperty(e.prototype,"subsurfaceWeight",{get:function(){return this._material.subSurface.isTranslucencyEnabled?this._material.subSurface.translucencyIntensity:0},set:function(e){this._material.subSurface.isTranslucencyEnabled=e>0,this._material.subSurface.translucencyIntensity=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"subsurfaceWeightTexture",{set:function(e){this._material.subSurface.translucencyIntensityTexture=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"subsurfaceColor",{set:function(e){var n=new t.Vector3(-Math.log(this.transmissionColor.r),-Math.log(this.transmissionColor.g),-Math.log(this.transmissionColor.b));n.scaleInPlace(1/Math.max(this.transmissionDepth,.001));var r=n,o=Math.max(r.x,Math.max(r.y,r.z)),a=o>0?1/o:1;this._material.subSurface.diffusionDistance=new t.Color3(Math.exp(-r.x*a),Math.exp(-r.y*a),Math.exp(-r.z*a))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"subsurfaceColorTexture",{set:function(e){},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"diffuseTransmissionTint",{get:function(){return this._material.subSurface.tintColor},set:function(e){this._material.subSurface.tintColor=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"diffuseTransmissionTintTexture",{set:function(e){this._material.subSurface.translucencyColorTexture=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"subsurfaceRadius",{get:function(){return 1},set:function(e){},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"subsurfaceRadiusScale",{get:function(){var e;return null!==(e=this._material.subSurface.scatteringDiffusionProfile)&&void 0!==e?e:t.Color3.White()},set:function(e){this._material.subSurface.scatteringDiffusionProfile=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"subsurfaceScatterAnisotropy",{set:function(e){},enumerable:!1,configurable:!0}),e.prototype.isTranslucent=function(){return this.transmissionWeight>0||this.subsurfaceWeight>0},e.prototype.configureFuzz=function(){this._material.sheen.isEnabled=!0,this._material.sheen.useRoughnessFromMainTexture=!1,this._material.sheen.albedoScaling=!0},Object.defineProperty(e.prototype,"fuzzWeight",{set:function(e){this._material.sheen.isEnabled=!0,this._material.sheen.intensity=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"fuzzWeightTexture",{set:function(e){this._material.sheen.texture||(this._material.sheen.texture=e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"fuzzColor",{set:function(e){this._material.sheen.isEnabled=!0,this._material.sheen.color=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"fuzzColorTexture",{set:function(e){this._material.sheen.texture=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"fuzzRoughness",{set:function(e){this._material.sheen.isEnabled=!0,this._material.sheen.roughness=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"fuzzRoughnessTexture",{set:function(e){this._material.sheen.isEnabled=!0,this._material.sheen.textureRoughness=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"specularRoughnessAnisotropy",{get:function(){return this._material.anisotropy.intensity},set:function(e){this._material.anisotropy.isEnabled=!0,this._material.anisotropy.intensity=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"geometryTangentAngle",{set:function(e){this._material.anisotropy.isEnabled=!0,this._material.anisotropy.angle=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"geometryTangentTexture",{get:function(){return this._material.anisotropy.texture},set:function(e){this._material.anisotropy.isEnabled=!0,this._material.anisotropy.texture=e},enumerable:!1,configurable:!0}),e.prototype.configureGltfStyleAnisotropy=function(e){void 0===e&&(e=!0)},Object.defineProperty(e.prototype,"thinFilmWeight",{set:function(e){this._material.iridescence.isEnabled=e>0,this._material.iridescence.intensity=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"thinFilmIor",{set:function(e){this._material.iridescence.indexOfRefraction=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"thinFilmThicknessMinimum",{set:function(e){this._material.iridescence.minimumThickness=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"thinFilmThicknessMaximum",{set:function(e){this._material.iridescence.maximumThickness=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"thinFilmWeightTexture",{set:function(e){this._material.iridescence.texture=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"thinFilmThicknessTexture",{set:function(e){this._material.iridescence.thicknessTexture=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"unlit",{set:function(e){this._material.unlit=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"geometryOpacity",{get:function(){return this._material.alpha},set:function(e){this._material.alpha=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"geometryNormalTexture",{get:function(){return this._material.bumpTexture},set:function(e){this._material.bumpTexture=e,this._material.forceIrradianceInFragment=!0},enumerable:!1,configurable:!0}),e.prototype.setNormalMapInversions=function(e,t){this._material.invertNormalMapX=e,this._material.invertNormalMapY=t},Object.defineProperty(e.prototype,"geometryCoatNormalTexture",{get:function(){return this._material.clearCoat.bumpTexture},set:function(e){this._material.clearCoat.isEnabled=!0,this._material.clearCoat.bumpTexture=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"geometryCoatNormalTextureScale",{set:function(e){this._material.clearCoat.bumpTexture&&(this._material.clearCoat.bumpTexture.level=e)},enumerable:!1,configurable:!0}),e}(),Rr={__proto__:null,PBRMaterialLoadingAdapter:Fr},Lr="EXT_lights_image_based",Ir=function(){function e(e){this.name=Lr,this._loader=e,this.enabled=this._loader.isExtensionUsed(Lr)}return e.prototype.dispose=function(){this._loader=null,delete this._lights},e.prototype.onLoading=function(){var e=this._loader.gltf.extensions;if(e&&e[this.name]){var t=e[this.name];this._lights=t.lights}},e.prototype.loadSceneAsync=function(e,t){var n=this;return yr.LoadExtensionAsync(e,t,this.name,function(r,o){return _(n,void 0,void 0,function(){var n,a,i=this;return g(this,function(s){switch(s.label){case 0:return this._loader._allMaterialsDirtyRequired=!0,(n=new Array).push(this._loader.loadSceneAsync(e,t)),this._loader.logOpen("".concat(r)),a=_r.Get("".concat(r,"/light"),this._lights,o.light),n.push(this._loadLightAsync("/extensions/".concat(this.name,"/lights/").concat(o.light),a).then(function(e){i._loader.babylonScene.environmentTexture=e})),this._loader.logClose(),[4,Promise.all(n).then(function(){})];case 1:return[2,s.sent()]}})})})},e.prototype._loadLightAsync=function(e,n){var r=this;if(!n._loaded){var o=new Array;this._loader.logOpen("".concat(e));for(var a=new Array(n.specularImages.length),i=function(t){var r=n.specularImages[t];a[t]=new Array(r.length);for(var i=function(n){var i="".concat(e,"/specularImages/").concat(t,"/").concat(n);s._loader.logOpen("".concat(i));var l=r[n],u=_r.Get(i,s._loader.gltf.images,l);o.push(s._loader.loadImageAsync("/images/".concat(l),u).then(function(e){a[t][n]=e})),s._loader.logClose()},l=0;l<r.length;l++)i(l)},s=this,l=0;l<n.specularImages.length;l++)i(l);this._loader.logClose(),n._loaded=Promise.all(o).then(function(){return _(r,void 0,void 0,function(){var r,o,i,s,l;return g(this,function(u){switch(u.label){case 0:if((r=new t.RawCubeTexture(this._loader.babylonScene,null,n.specularImageSize)).name=n.name||"environment",n._babylonTexture=r,null!=n.intensity&&(r.level=n.intensity),n.rotation&&(o=t.Quaternion.FromArray(n.rotation),this._loader.babylonScene.useRightHandedSystem||(o=t.Quaternion.Inverse(o)),t.Matrix.FromQuaternionToRef(o,r.getReflectionTextureMatrix())),!n.irradianceCoefficients)throw new Error("".concat(e,": Irradiance coefficients are missing"));return(i=t.SphericalHarmonics.FromArray(n.irradianceCoefficients)).scaleInPlace(n.intensity),i.convertIrradianceToLambertianRadiance(),s=t.SphericalPolynomial.FromHarmonics(i),l=(a.length-1)/Math.log2(n.specularImageSize),[4,r.updateRGBDAsync(a,s,l)];case 1:return[2,u.sent()]}})})})}return n._loaded.then(function(){return n._babylonTexture})},e}();er(Lr),$n(Lr,!0,function(e){return new Ir(e)});var Pr={__proto__:null,EXT_lights_image_based:Ir},Nr="EXT_mesh_gpu_instancing",Br=function(){function e(e){this.name=Nr,this._loader=e,this.enabled=this._loader.isExtensionUsed(Nr)}return e.prototype.dispose=function(){this._loader=null},e.prototype.loadNodeAsync=function(e,n,r){var o=this;return yr.LoadExtensionAsync(e,n,this.name,function(e,a){return _(o,void 0,void 0,function(){var o,i,s,l,u=this;return g(this,function(c){switch(c.label){case 0:return this._loader._disableInstancedMesh++,o=this._loader.loadNodeAsync("/nodes/".concat(n.index),n,r),this._loader._disableInstancedMesh--,n._primitiveBabylonMeshes?[3,2]:[4,o];case 1:case 3:return[2,c.sent()];case 2:return i=new Array,s=0,(l=function(t){if(null!=a.attributes[t]){var n=_r.Get("".concat(e,"/attributes/").concat(t),u._loader.gltf.accessors,a.attributes[t]);if(i.push(u._loader._loadFloatAccessorAsync("/accessors/".concat(n.bufferView),n)),0===s)s=n.count;else if(s!==n.count)throw new Error("".concat(e,"/attributes: Instance buffer accessors do not have the same count."))}else i.push(Promise.resolve(null))})("TRANSLATION"),l("ROTATION"),l("SCALE"),l("_COLOR_0"),[4,o.then(function(e){return _(u,void 0,void 0,function(){var r,o,a,l,u,c,f,d,h,p;return g(this,function(m){switch(m.label){case 0:return[4,Promise.all(i)];case 1:for(r=m.sent(),o=r[0],a=r[1],l=r[2],u=r[3],c=new Float32Array(16*s),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),f=0;f<s;++f)o&&t.Vector3.FromArrayToRef(o,3*f,t.TmpVectors.Vector3[0]),a&&t.Quaternion.FromArrayToRef(a,4*f,t.TmpVectors.Quaternion[0]),l&&t.Vector3.FromArrayToRef(l,3*f,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(c,16*f);for(d=0,h=n._primitiveBabylonMeshes;d<h.length;d++)(p=h[d]).thinInstanceSetBuffer("matrix",c,16,!0),u&&(u.length===3*s?p.thinInstanceSetBuffer("color",u,3,!0):u.length===4*s?p.thinInstanceSetBuffer("color",u,4,!0):t.Logger.Warn("Unexpected size of _COLOR_0 attribute for mesh "+p.name));return[2,e]}})})})]}})})})},e}();er(Nr),$n(Nr,!0,function(e){return new Br(e)});var kr={__proto__:null,EXT_mesh_gpu_instancing:Br},Dr="EXT_meshopt_compression",Gr=function(){function e(e){this.name=Dr,this.enabled=e.isExtensionUsed(Dr),this._loader=e}return e.prototype.dispose=function(){this._loader=null},e.prototype.loadBufferViewAsync=function(e,n){var r=this;return yr.LoadExtensionAsync(e,n,this.name,function(o,a){return _(r,void 0,void 0,function(){var r,o,i=this;return g(this,function(s){switch(s.label){case 0:return(r=n)._meshOptData?[4,r._meshOptData]:[3,2];case 1:case 3:return[2,s.sent()];case 2:return o=_r.Get("".concat(e,"/buffer"),this._loader.gltf.buffers,a.buffer),r._meshOptData=this._loader.loadBufferAsync("/buffers/".concat(o.index),o,a.byteOffset||0,a.byteLength).then(function(e){return _(i,void 0,void 0,function(){return g(this,function(n){switch(n.label){case 0:return[4,t.MeshoptCompression.Default.decodeGltfBufferAsync(e,a.count,a.byteStride,a.mode,a.filter)];case 1:return[2,n.sent()]}})})}),[4,r._meshOptData]}})})})},e}();er(Dr),$n(Dr,!0,function(e){return new Gr(e)});var Vr={__proto__:null,EXT_meshopt_compression:Gr},Hr="EXT_texture_webp",Ur=function(){function e(e){this.name=Hr,this._loader=e,this.enabled=e.isExtensionUsed(Hr)}return e.prototype.dispose=function(){this._loader=null},e.prototype._loadTextureAsync=function(e,t,n){var r=this;return yr.LoadExtensionAsync(e,t,this.name,function(o,a){return _(r,void 0,void 0,function(){var r,i;return g(this,function(s){switch(s.label){case 0:return r=null==t.sampler?yr.DefaultSampler:_r.Get("".concat(e,"/sampler"),this._loader.gltf.samplers,t.sampler),i=_r.Get("".concat(o,"/source"),this._loader.gltf.images,a.source),[4,this._loader._createTextureAsync(e,r,i,function(e){n(e)},void 0,!t._textureInfo.nonColorData)];case 1:return[2,s.sent()]}})})})},e}();er(Hr),$n(Hr,!0,function(e){return new Ur(e)});var jr={__proto__:null,EXT_texture_webp:Ur},Kr="EXT_texture_avif",Wr=function(){function e(e){this.name=Kr,this._loader=e,this.enabled=e.isExtensionUsed(Kr)}return e.prototype.dispose=function(){this._loader=null},e.prototype._loadTextureAsync=function(e,t,n){var r=this;return yr.LoadExtensionAsync(e,t,this.name,function(o,a){return _(r,void 0,void 0,function(){var r,i;return g(this,function(s){switch(s.label){case 0:return r=null==t.sampler?yr.DefaultSampler:_r.Get("".concat(e,"/sampler"),this._loader.gltf.samplers,t.sampler),i=_r.Get("".concat(o,"/source"),this._loader.gltf.images,a.source),[4,this._loader._createTextureAsync(e,r,i,function(e){n(e)},void 0,!t._textureInfo.nonColorData)];case 1:return[2,s.sent()]}})})})},e}();er(Kr),$n(Kr,!0,function(e){return new Wr(e)});var zr={__proto__:null,EXT_texture_avif:Wr},qr="EXT_lights_ies",Xr=function(){function e(e){this.name=qr,this._loader=e,this.enabled=this._loader.isExtensionUsed(qr)}return e.prototype.dispose=function(){this._loader=null,delete this._lights},e.prototype.onLoading=function(){var e=this._loader.gltf.extensions;if(e&&e[this.name]){var t=e[this.name];this._lights=t.lights,_r.Assign(this._lights)}},e.prototype.loadNodeAsync=function(e,n,r){var o=this;return yr.LoadExtensionAsync(e,n,this.name,function(a,i){return _(o,void 0,void 0,function(){var o,s,l,u,c,f=this;return g(this,function(d){switch(d.label){case 0:return this._loader._allMaterialsDirtyRequired=!0,[4,this._loader.loadNodeAsync(e,n,function(e){var n=(s=_r.Get(a,f._lights,i.light)).name||e.name;f._loader.babylonScene._blockEntityCollection=!!f._loader._assetContainer,(o=new t.SpotLight(n,t.Vector3.Zero(),t.Vector3.Backward(),0,1,f._loader.babylonScene)).angle=Math.PI/2,o.innerAngle=0,o._parentContainer=f._loader._assetContainer,f._loader.babylonScene._blockEntityCollection=!1,s._babylonLight=o,o.falloffType=t.Light.FALLOFF_GLTF,o.diffuse=i.color?t.Color3.FromArray(i.color):t.Color3.White(),o.intensity=i.multiplier||1,o.range=Number.MAX_VALUE,o.parent=e,f._loader._babylonLights.push(o),yr.AddPointerMetadata(o,a),r(e)})];case 1:return l=d.sent(),s.uri?[4,this._loader.loadUriAsync(e,s,s.uri)]:[3,3];case 2:return u=d.sent(),[3,5];case 3:return c=_r.Get("".concat(e,"/bufferView"),this._loader.gltf.bufferViews,s.bufferView),[4,this._loader.loadBufferViewAsync("/bufferViews/".concat(c.index),c)];case 4:u=d.sent(),d.label=5;case 5: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"),[2,l]}})})})},e}();er(qr),$n(qr,!0,function(e){return new Xr(e)});var Yr={__proto__:null,EXT_lights_ies:Xr},Qr="KHR_draco_mesh_compression",Zr=function(){function e(e){this.name=Qr,this.useNormalizedFlagFromAccessor=!0,this._loader=e,this.enabled=t.DracoDecoder.DefaultAvailable&&this._loader.isExtensionUsed(Qr)}return e.prototype.dispose=function(){delete this.dracoDecoder,this._loader=null},e.prototype._loadVertexDataAsync=function(e,n,r){var o=this;return yr.LoadExtensionAsync(e,n,this.name,function(a,i){return _(o,void 0,void 0,function(){var o,s,l,u,c=this;return g(this,function(f){switch(f.label){case 0:if(null!=n.mode&&4!==n.mode&&5!==n.mode)throw new Error("".concat(e,": Unsupported mode ").concat(n.mode));return o={},s={},(l=function(e,t){var a=i.attributes[e];if(null!=a&&(r._delayInfo=r._delayInfo||[],-1===r._delayInfo.indexOf(t)&&r._delayInfo.push(t),o[t]=a,c.useNormalizedFlagFromAccessor)){var l=_r.TryGet(c._loader.gltf.accessors,n.attributes[e]);l&&(s[t]=l.normalized||!1)}})("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),(u=_r.Get(a,this._loader.gltf.bufferViews,i.bufferView))._dracoBabylonGeometry||(u._dracoBabylonGeometry=this._loader.loadBufferViewAsync("/bufferViews/".concat(u.index),u).then(function(a){return _(c,void 0,void 0,function(){var i,l,u;return g(this,function(c){switch(c.label){case 0:return i=this.dracoDecoder||t.DracoDecoder.Default,l=_r.TryGet(this._loader.gltf.accessors,n.attributes.POSITION),u=this._loader.parent.alwaysComputeBoundingBox||r.skeleton||!l?null:gr(l),[4,i._decodeMeshToGeometryForGltfAsync(r.name,this._loader.babylonScene,a,o,s,u).catch(function(t){throw new Error("".concat(e,": ").concat(t.message))})];case 1:return[2,c.sent()]}})})})),[4,u._dracoBabylonGeometry];case 1:return[2,f.sent()]}})})})},e}();er(Qr),$n(Qr,!0,function(e){return new Zr(e)});var Jr={__proto__:null,KHR_draco_mesh_compression:Zr},$r="KHR_lights_punctual",eo=function(){function e(e){this.name=$r,this._loader=e,this.enabled=this._loader.isExtensionUsed($r)}return e.prototype.dispose=function(){this._loader=null,delete this._lights},e.prototype.onLoading=function(){var e=this._loader.gltf.extensions;if(e&&e[this.name]){var t=e[this.name];this._lights=t.lights,_r.Assign(this._lights)}},e.prototype.loadNodeAsync=function(e,n,r){var o=this;return yr.LoadExtensionAsync(e,n,this.name,function(a,i){return _(o,void 0,void 0,function(){var o=this;return g(this,function(s){switch(s.label){case 0:return this._loader._allMaterialsDirtyRequired=!0,[4,this._loader.loadNodeAsync(e,n,function(e){var n,s=_r.Get(a,o._lights,i.light),l=s.name||e.name;switch(o._loader.babylonScene._blockEntityCollection=!!o._loader._assetContainer,s.type){case"directional":var u=new t.DirectionalLight(l,t.Vector3.Backward(),o._loader.babylonScene);u.position.setAll(0),n=u;break;case"point":n=new t.PointLight(l,t.Vector3.Zero(),o._loader.babylonScene);break;case"spot":var c=new t.SpotLight(l,t.Vector3.Zero(),t.Vector3.Backward(),0,1,o._loader.babylonScene);c.angle=2*(s.spot&&s.spot.outerConeAngle||Math.PI/4),c.innerAngle=2*(s.spot&&s.spot.innerConeAngle||0),n=c;break;default:throw o._loader.babylonScene._blockEntityCollection=!1,new Error("".concat(a,": Invalid light type (").concat(s.type,")"))}n._parentContainer=o._loader._assetContainer,o._loader.babylonScene._blockEntityCollection=!1,s._babylonLight=n,n.falloffType=t.Light.FALLOFF_GLTF,n.diffuse=s.color?t.Color3.FromArray(s.color):t.Color3.White(),n.intensity=null==s.intensity?1:s.intensity,n.range=null==s.range?Number.MAX_VALUE:s.range,n.parent=e,o._loader._babylonLights.push(n),yr.AddPointerMetadata(n,a),r(e)})];case 1:return[2,s.sent()]}})})})},e}();er($r),$n($r,!0,function(e){return new eo(e)});var to={__proto__:null,KHR_lights:eo},no="EXT_lights_area",ro=function(){function e(e){this.name=no,this._loader=e,this.enabled=this._loader.isExtensionUsed(no)}return e.prototype.dispose=function(){this._loader=null,delete this._lights},e.prototype.onLoading=function(){var e=this._loader.gltf.extensions;if(e&&e[this.name]){var t=e[this.name];this._lights=t.lights,_r.Assign(this._lights)}},e.prototype.loadNodeAsync=function(e,n,r){var o=this;return yr.LoadExtensionAsync(e,n,this.name,function(a,i){return _(o,void 0,void 0,function(){var o=this;return g(this,function(s){switch(s.label){case 0:return this._loader._allMaterialsDirtyRequired=!0,[4,this._loader.loadNodeAsync(e,n,function(e){var n,s,l=_r.Get(a,o._lights,i.light),u=l.name||e.name;o._loader.babylonScene._blockEntityCollection=!!o._loader._assetContainer;var c=void 0!==l.size?l.size:1;switch(l.type){case"rect":var f=void 0!==(null===(n=l.rect)||void 0===n?void 0:n.aspect)?l.rect.aspect*c:c,d=c;s=new t.RectAreaLight(u,t.Vector3.Zero(),f,d,o._loader.babylonScene);break;case"disk":var h=Math.sqrt(c*c*.25*Math.PI);s=new t.RectAreaLight(u,t.Vector3.Zero(),h,h,o._loader.babylonScene);break;default:throw o._loader.babylonScene._blockEntityCollection=!1,new Error("".concat(a,": Invalid area light type (").concat(l.type,")"))}s._parentContainer=o._loader._assetContainer,o._loader.babylonScene._blockEntityCollection=!1,l._babylonLight=s,s.falloffType=t.Light.FALLOFF_GLTF,s.diffuse=l.color?t.Color3.FromArray(l.color):t.Color3.White(),s.intensity=null==l.intensity?1:l.intensity;var p=new t.TransformNode("".concat(u,"_orientation"),o._loader.babylonScene);p.rotationQuaternion=t.Quaternion.RotationAxis(t.Vector3.Up(),Math.PI),p.parent=e,s.parent=p,o._loader._babylonLights.push(s),yr.AddPointerMetadata(s,a),r(e)})];case 1:return[2,s.sent()]}})})})},e}();er(no),$n(no,!0,function(e){return new ro(e)});var oo={__proto__:null,EXT_lights_area:ro},ao="KHR_materials_pbrSpecularGlossiness",io=function(){function e(e){this.name=ao,this.order=200,this._loader=e,this.enabled=this._loader.isExtensionUsed(ao)}return e.prototype.dispose=function(){this._loader=null},e.prototype.loadMaterialPropertiesAsync=function(e,t,n){var r=this;return yr.LoadExtensionAsync(e,t,this.name,function(o,a){return _(r,void 0,void 0,function(){var r;return g(this,function(i){switch(i.label){case 0:return(r=new Array).push(this._loader.loadMaterialBasePropertiesAsync(e,t,n)),r.push(this._loadSpecularGlossinessPropertiesAsync(o,a,n)),this._loader.loadMaterialAlphaProperties(e,t,n),[4,Promise.all(r).then(function(){})];case 1:return[2,i.sent()]}})})})},e.prototype._loadSpecularGlossinessPropertiesAsync=function(e,n,r){var o=this._loader._getOrCreateMaterialAdapter(r),a=new Array;return o.configureSpecularGlossiness(),n.diffuseFactor?(o.baseColor=t.Color3.FromArray(n.diffuseFactor),r.alpha=n.diffuseFactor[3]):o.baseColor=t.Color3.White(),o.specularColor=n.specularFactor?t.Color3.FromArray(n.specularFactor):t.Color3.White(),o.glossiness=null==n.glossinessFactor?1:n.glossinessFactor,n.diffuseTexture&&a.push(this._loader.loadTextureInfoAsync("".concat(e,"/diffuseTexture"),n.diffuseTexture,function(e){e.name="".concat(r.name," (Diffuse)"),o.baseColorTexture=e})),n.specularGlossinessTexture&&a.push(this._loader.loadTextureInfoAsync("".concat(e,"/specularGlossinessTexture"),n.specularGlossinessTexture,function(e){e.name="".concat(r.name," (Specular Glossiness)"),o.specularColorTexture=e})),Promise.all(a).then(function(){})},e}();er(ao),$n(ao,!0,function(e){return new io(e)});var so={__proto__:null,KHR_materials_pbrSpecularGlossiness:io},lo="KHR_materials_unlit",uo=function(){function e(e){this.name=lo,this.order=210,this._loader=e,this.enabled=this._loader.isExtensionUsed(lo)}return e.prototype.dispose=function(){this._loader=null},e.prototype.loadMaterialPropertiesAsync=function(e,t,n){var r=this;return yr.LoadExtensionAsync(e,t,this.name,function(){return _(r,void 0,void 0,function(){return g(this,function(r){switch(r.label){case 0:return[4,this._loadUnlitPropertiesAsync(e,t,n)];case 1:return[2,r.sent()]}})})})},e.prototype._loadUnlitPropertiesAsync=function(e,n,r){var o=this._loader._getOrCreateMaterialAdapter(r),a=new Array,i=n.pbrMetallicRoughness;return i&&(i.baseColorFactor&&(o.baseColor=t.Color3.FromArray(i.baseColorFactor),o.geometryOpacity=i.baseColorFactor[3]),i.baseColorTexture&&a.push(this._loader.loadTextureInfoAsync("".concat(e,"/baseColorTexture"),i.baseColorTexture,function(e){e.name="".concat(r.name," (Base Color)"),o.baseColorTexture=e}))),o.isUnlit=!0,n.doubleSided&&(o.backFaceCulling=!1,o.twoSidedLighting=!0),this._loader.loadMaterialAlphaProperties(e,n,r),Promise.all(a).then(function(){})},e}();er(lo),$n(lo,!0,function(e){return new uo(e)});var co={__proto__:null,KHR_materials_unlit:uo},fo="KHR_materials_clearcoat",ho=function(){function e(e){this.name=fo,this.order=190,this._loader=e,this.enabled=this._loader.isExtensionUsed(fo)}return e.prototype.dispose=function(){this._loader=null},e.prototype.loadMaterialPropertiesAsync=function(e,t,n){var r=this;return yr.LoadExtensionAsync(e,t,this.name,function(o,a){return _(r,void 0,void 0,function(){var r;return g(this,function(i){switch(i.label){case 0:return(r=new Array).push(this._loader.loadMaterialPropertiesAsync(e,t,n)),r.push(this._loadClearCoatPropertiesAsync(o,a,n)),[4,Promise.all(r)];case 1:return i.sent(),[2]}})})})},e.prototype._loadClearCoatPropertiesAsync=function(e,t,n){var r=this._loader._getOrCreateMaterialAdapter(n),o=new Array;return r.configureCoat(),r.coatWeight=void 0!==t.clearcoatFactor?t.clearcoatFactor:0,r.coatRoughness=void 0!==t.clearcoatRoughnessFactor?t.clearcoatRoughnessFactor:0,t.clearcoatTexture&&o.push(this._loader.loadTextureInfoAsync("".concat(e,"/clearcoatTexture"),t.clearcoatTexture,function(e){e.name="".concat(n.name," (ClearCoat)"),r.coatWeightTexture=e})),t.clearcoatRoughnessTexture&&(t.clearcoatRoughnessTexture.nonColorData=!0,o.push(this._loader.loadTextureInfoAsync("".concat(e,"/clearcoatRoughnessTexture"),t.clearcoatRoughnessTexture,function(e){e.name="".concat(n.name," (ClearCoat Roughness)"),r.coatRoughnessTexture=e}))),t.clearcoatNormalTexture&&(t.clearcoatNormalTexture.nonColorData=!0,o.push(this._loader.loadTextureInfoAsync("".concat(e,"/clearcoatNormalTexture"),t.clearcoatNormalTexture,function(e){var o;e.name="".concat(n.name," (ClearCoat Normal)"),r.geometryCoatNormalTexture=e,null!=(null===(o=t.clearcoatNormalTexture)||void 0===o?void 0:o.scale)&&(r.geometryCoatNormalTextureScale=t.clearcoatNormalTexture.scale)})),r.setNormalMapInversions(!n.getScene().useRightHandedSystem,n.getScene().useRightHandedSystem)),Promise.all(o).then(function(){})},e}();er(fo),$n(fo,!0,function(e){return new ho(e)});var po={__proto__:null,KHR_materials_clearcoat:ho},mo="KHR_materials_coat",vo=function(){function e(e){this.name=mo,this.order=191,this.useOpenPBR=!1,this._loader=e,this.enabled=this._loader.isExtensionUsed(mo)}return e.prototype.dispose=function(){this._loader=null},e.prototype.loadMaterialPropertiesAsync=function(e,t,n){var r=this;return yr.LoadExtensionAsync(e,t,this.name,function(o,a){return _(r,void 0,void 0,function(){var r;return g(this,function(i){switch(i.label){case 0:return(r=new Array).push(this._loader.loadMaterialPropertiesAsync(e,t,n)),t.extensions&&t.extensions.KHR_materials_openpbr&&(this.useOpenPBR=!0),r.push(this._loadCoatPropertiesAsync(o,a,n)),[4,Promise.all(r)];case 1:return i.sent(),[2]}})})})},e.prototype._loadCoatPropertiesAsync=function(e,n,r){var o,a,i=this._loader._getOrCreateMaterialAdapter(r),s=new Array;i.configureCoat(),i.coatWeight=void 0!==n.coatFactor?n.coatFactor:0,i.coatRoughness=void 0!==n.coatRoughnessFactor?n.coatRoughnessFactor:0,n.coatTexture&&s.push(this._loader.loadTextureInfoAsync("".concat(e,"/coatTexture"),n.coatTexture,function(e){e.name="".concat(r.name," (Coat)"),i.coatWeightTexture=e})),n.coatRoughnessTexture&&(n.coatRoughnessTexture.nonColorData=!0,s.push(this._loader.loadTextureInfoAsync("".concat(e,"/coatRoughnessTexture"),n.coatRoughnessTexture,function(e){e.name="".concat(r.name," (Coat Roughness)"),i.coatRoughnessTexture=e}))),n.coatNormalTexture&&(n.coatNormalTexture.nonColorData=!0,s.push(this._loader.loadTextureInfoAsync("".concat(e,"/coatNormalTexture"),n.coatNormalTexture,function(e){var t;e.name="".concat(r.name," (Coat Normal)"),i.geometryCoatNormalTexture=e,null!=(null===(t=n.coatNormalTexture)||void 0===t?void 0:t.scale)&&(i.geometryCoatNormalTextureScale=n.coatNormalTexture.scale)})),i.setNormalMapInversions(!r.getScene().useRightHandedSystem,r.getScene().useRightHandedSystem)),i.coatDarkening=void 0!==n.coatDarkeningFactor?n.coatDarkeningFactor:1,i.coatIor=void 0!==n.coatIor?n.coatIor:1.5;var l=t.Color3.White();void 0!==n.coatColorFactor&&l.fromArray(n.coatColorFactor),i.coatColor=l,n.coatColorTexture&&s.push(this._loader.loadTextureInfoAsync("".concat(e,"/coatColorTexture"),n.coatColorTexture,function(e){e.name="".concat(r.name," (Coat Color)"),i.coatColorTexture=e}));var u=null!==(o=n.coatAnisotropyStrength)&&void 0!==o?o:0,c=null!==(a=n.coatAnisotropyRotation)&&void 0!==a?a:0;return i.coatRoughnessAnisotropy=u,i.geometryCoatTangentAngle=c,this.useOpenPBR||i.configureGltfStyleAnisotropy(!0),n.coatAnisotropyTexture&&(n.coatAnisotropyTexture.nonColorData=!0,s.push(this._loader.loadTextureInfoAsync("".concat(e,"/coatAnisotropyTexture"),n.coatAnisotropyTexture,function(e){e.name="".concat(r.name," (Coat Anisotropy)"),i.geometryCoatTangentTexture=e}))),Promise.all(s).then(function(){})},e}();er(mo),$n(mo,!0,function(e){return new vo(e)});var _o={__proto__:null,KHR_materials_coat:vo},go="KHR_materials_iridescence",yo=function(){function e(e){this.name=go,this.order=195,this._loader=e,this.enabled=this._loader.isExtensionUsed(go)}return e.prototype.dispose=function(){this._loader=null},e.prototype.loadMaterialPropertiesAsync=function(e,t,n){var r=this;return yr.LoadExtensionAsync(e,t,this.name,function(o,a){return _(r,void 0,void 0,function(){var r;return g(this,function(i){switch(i.label){case 0:return(r=new Array).push(this._loader.loadMaterialPropertiesAsync(e,t,n)),r.push(this._loadIridescencePropertiesAsync(o,a,n)),[4,Promise.all(r).then(function(){})];case 1:return[2,i.sent()]}})})})},e.prototype._loadIridescencePropertiesAsync=function(e,t,n){var r,o,a,i,s,l=this._loader._getOrCreateMaterialAdapter(n),u=new Array;return l.thinFilmWeight=null!==(r=t.iridescenceFactor)&&void 0!==r?r:0,l.thinFilmIor=null!==(a=null!==(o=t.iridescenceIor)&&void 0!==o?o:t.iridescenceIOR)&&void 0!==a?a:1.3,l.thinFilmThicknessMinimum=null!==(i=t.iridescenceThicknessMinimum)&&void 0!==i?i:100,l.thinFilmThicknessMaximum=null!==(s=t.iridescenceThicknessMaximum)&&void 0!==s?s:400,t.iridescenceTexture&&u.push(this._loader.loadTextureInfoAsync("".concat(e,"/iridescenceTexture"),t.iridescenceTexture,function(e){e.name="".concat(n.name," (Iridescence)"),l.thinFilmWeightTexture=e})),t.iridescenceThicknessTexture&&u.push(this._loader.loadTextureInfoAsync("".concat(e,"/iridescenceThicknessTexture"),t.iridescenceThicknessTexture,function(e){e.name="".concat(n.name," (Iridescence Thickness)"),l.thinFilmThicknessTexture=e})),Promise.all(u).then(function(){})},e}();er(go),$n(go,!0,function(e){return new yo(e)});var bo={__proto__:null,KHR_materials_iridescence:yo},xo="KHR_materials_anisotropy",To=function(){function e(e){this.name=xo,this.order=195,this._loader=e,this.enabled=this._loader.isExtensionUsed(xo)}return e.prototype.dispose=function(){this._loader=null},e.prototype.loadMaterialPropertiesAsync=function(e,t,n){var r=this;return yr.LoadExtensionAsync(e,t,this.name,function(o,a){return _(r,void 0,void 0,function(){var r;return g(this,function(i){switch(i.label){case 0:return(r=new Array).push(this._loader.loadMaterialPropertiesAsync(e,t,n)),r.push(this._loadAnisotropyPropertiesAsync(o,a,n)),[4,Promise.all(r)];case 1:return i.sent(),[2]}})})})},e.prototype._loadAnisotropyPropertiesAsync=function(e,t,n){return _(this,void 0,void 0,function(){var r,o,a,i,s,l,u,c;return g(this,function(f){switch(f.label){case 0:return r=this._loader._getOrCreateMaterialAdapter(n),o=new Array,a=null!==(l=t.anisotropyStrength)&&void 0!==l?l:0,i=null!==(u=t.anisotropyRotation)&&void 0!==u?u:0,r.specularRoughnessAnisotropy=a,r.geometryTangentAngle=i,(s=null!==(c=t.extensions)&&void 0!==c?c:{}).EXT_materials_anisotropy_openpbr&&s.EXT_materials_anisotropy_openpbr.openPbrAnisotropyEnabled||r.configureGltfStyleAnisotropy(!0),t.anisotropyTexture&&(t.anisotropyTexture.nonColorData=!0,o.push(this._loader.loadTextureInfoAsync("".concat(e,"/anisotropyTexture"),t.anisotropyTexture,function(e){e.name="".concat(n.name," (Anisotropy Intensity)"),r.geometryTangentTexture=e}))),[4,Promise.all(o)];case 1:return f.sent(),[2]}})})},e}();er(xo),$n(xo,!0,function(e){return new To(e)});var Ao={__proto__:null,KHR_materials_anisotropy:To},wo="KHR_materials_emissive_strength",Mo=function(){function e(e){this.name=wo,this.order=170,this._loader=e,this.enabled=this._loader.isExtensionUsed(wo)}return e.prototype.dispose=function(){this._loader=null},e.prototype.loadMaterialPropertiesAsync=function(e,t,n){var r=this;return yr.LoadExtensionAsync(e,t,this.name,function(o,a){return _(r,void 0,void 0,function(){return g(this,function(r){switch(r.label){case 0:return[4,this._loader.loadMaterialPropertiesAsync(e,t,n)];case 1:return r.sent(),this._loadEmissiveProperties(o,a,n),[4,Promise.resolve()];case 2:return[2,r.sent()]}})})})},e.prototype._loadEmissiveProperties=function(e,t,n){void 0!==t.emissiveStrength&&(this._loader._getOrCreateMaterialAdapter(n).emissionLuminance=t.emissiveStrength)},e}();er(wo),$n(wo,!0,function(e){return new Mo(e)});var Co={__proto__:null,KHR_materials_emissive_strength:Mo},Oo="KHR_materials_sheen",So=function(){function e(e){this.name=Oo,this.order=190,this._loader=e,this.enabled=this._loader.isExtensionUsed(Oo)}return e.prototype.dispose=function(){this._loader=null},e.prototype.loadMaterialPropertiesAsync=function(e,t,n){var r=this;return yr.LoadExtensionAsync(e,t,this.name,function(o,a){return _(r,void 0,void 0,function(){var r;return g(this,function(i){switch(i.label){case 0:return(r=new Array).push(this._loader.loadMaterialPropertiesAsync(e,t,n)),r.push(this._loadSheenPropertiesAsync(o,a,n)),[4,Promise.all(r).then(function(){})];case 1:return[2,i.sent()]}})})})},e.prototype._loadSheenPropertiesAsync=function(e,n,r){var o=this._loader._getOrCreateMaterialAdapter(r),a=new Array;o.configureFuzz();var i=void 0!==n.sheenColorFactor?t.Color3.FromArray(n.sheenColorFactor):t.Color3.Black(),s=void 0!==n.sheenRoughnessFactor?n.sheenRoughnessFactor:0;return o.fuzzWeight=1,o.fuzzColor=i,o.fuzzRoughness=s,n.sheenColorTexture&&a.push(this._loader.loadTextureInfoAsync("".concat(e,"/sheenColorTexture"),n.sheenColorTexture,function(e){e.name="".concat(r.name," (Sheen Color)"),o.fuzzColorTexture=e})),n.sheenRoughnessTexture&&(n.sheenRoughnessTexture.nonColorData=!0,a.push(this._loader.loadTextureInfoAsync("".concat(e,"/sheenRoughnessTexture"),n.sheenRoughnessTexture,function(e){e.name="".concat(r.name," (Sheen Roughness)"),o.fuzzRoughnessTexture=e}))),Promise.all(a).then(function(){})},e}();er(Oo),$n(Oo,!0,function(e){return new So(e)});var Eo={__proto__:null,KHR_materials_sheen:So},Fo="KHR_materials_fuzz",Ro=function(){function e(e){this.name=Fo,this.order=190,this._loader=e,this.enabled=this._loader.isExtensionUsed(Fo)}return e.prototype.dispose=function(){this._loader=null},e.prototype.loadMaterialPropertiesAsync=function(e,t,n){var r=this;return yr.LoadExtensionAsync(e,t,this.name,function(o,a){return _(r,void 0,void 0,function(){var r;return g(this,function(i){switch(i.label){case 0:return(r=new Array).push(this._loader.loadMaterialPropertiesAsync(e,t,n)),r.push(this._loadFuzzPropertiesAsync(o,a,n)),[4,Promise.all(r).then(function(){})];case 1:return[2,i.sent()]}})})})},e.prototype._loadFuzzPropertiesAsync=function(e,n,r){var o=this._loader._getOrCreateMaterialAdapter(r),a=new Array;return o.configureFuzz(),o.fuzzWeight=void 0!==n.fuzzFactor?n.fuzzFactor:0,o.fuzzColor=void 0!==n.fuzzColorFactor?t.Color3.FromArray(n.fuzzColorFactor):t.Color3.White(),o.fuzzRoughness=void 0!==n.fuzzRoughnessFactor?n.fuzzRoughnessFactor:.5,n.fuzzTexture&&a.push(this._loader.loadTextureInfoAsync("".concat(e,"/fuzzTexture"),n.fuzzTexture,function(e){e.name="".concat(r.name," (Fuzz)"),o.fuzzWeightTexture=e})),n.fuzzColorTexture&&a.push(this._loader.loadTextureInfoAsync("".concat(e,"/fuzzColorTexture"),n.fuzzColorTexture,function(e){e.name="".concat(r.name," (Fuzz Color)"),o.fuzzColorTexture=e})),n.fuzzRoughnessTexture&&(n.fuzzRoughnessTexture.nonColorData=!0,a.push(this._loader.loadTextureInfoAsync("".concat(e,"/fuzzRoughnessTexture"),n.fuzzRoughnessTexture,function(e){e.name="".concat(r.name," (Fuzz Roughness)"),o.fuzzRoughnessTexture=e}))),Promise.all(a).then(function(){})},e}();er(Fo),$n(Fo,!0,function(e){return new Ro(e)});var Lo={__proto__:null,KHR_materials_fuzz:Ro},Io="KHR_materials_specular",Po=function(){function e(e){this.name=Io,this.order=190,this._loader=e,this.enabled=this._loader.isExtensionUsed(Io)}return e.prototype.dispose=function(){this._loader=null},e.prototype.loadMaterialPropertiesAsync=function(e,t,n){var r=this;return yr.LoadExtensionAsync(e,t,this.name,function(o,a){return _(r,void 0,void 0,function(){var r,i;return g(this,function(s){switch(s.label){case 0:return(r=new Array).push(this._loader.loadMaterialPropertiesAsync(e,t,n)),r.push(this._loadSpecularPropertiesAsync(o,a,n)),i=this._loader._getOrCreateMaterialAdapter(n),a.extensions&&a.extensions.EXT_materials_specular_edge_color&&a.extensions.EXT_materials_specular_edge_color.specularEdgeColorEnabled&&i.enableSpecularEdgeColor(!0),[4,Promise.all(r).then(function(){})];case 1:return[2,s.sent()]}})})})},e.prototype._loadSpecularPropertiesAsync=function(e,n,r){var o,a=this._loader._getOrCreateMaterialAdapter(r),i=new Array;return a.specularWeight=null!==(o=n.specularFactor)&&void 0!==o?o:1,a.specularColor=void 0!==n.specularColorFactor?t.Color3.FromArray(n.specularColorFactor):new t.Color3(1,1,1),n.specularTexture&&(n.specularTexture.nonColorData=!0,i.push(this._loader.loadTextureInfoAsync("".concat(e,"/specularTexture"),n.specularTexture,function(e){e.name="".concat(r.name," (Specular)"),a.specularWeightTexture=e}))),n.specularColorTexture&&i.push(this._loader.loadTextureInfoAsync("".concat(e,"/specularColorTexture"),n.specularColorTexture,function(e){e.name="".concat(r.name," (Specular Color)"),a.specularColorTexture=e})),Promise.all(i).then(function(){})},e}();er(Io),$n(Io,!0,function(e){return new Po(e)});var No={__proto__:null,KHR_materials_specular:Po},Bo="KHR_materials_ior",ko=function(){function e(e){this.name=Bo,this.order=180,this._loader=e,this.enabled=this._loader.isExtensionUsed(Bo)}return e.prototype.dispose=function(){this._loader=null},e.prototype.loadMaterialPropertiesAsync=function(e,t,n){var r=this;return yr.LoadExtensionAsync(e,t,this.name,function(o,a){return _(r,void 0,void 0,function(){var r;return g(this,function(i){switch(i.label){case 0:return(r=new Array).push(this._loader.loadMaterialPropertiesAsync(e,t,n)),r.push(this._loadIorPropertiesAsync(o,a,n)),[4,Promise.all(r).then(function(){})];case 1:return[2,i.sent()]}})})})},e.prototype._loadIorPropertiesAsync=function(t,n,r){var o=this._loader._getOrCreateMaterialAdapter(r),a=void 0!==n.ior?n.ior:e._DEFAULT_IOR;return o.specularIor=a,Promise.resolve()},e._DEFAULT_IOR=1.5,e}();er(Bo),$n(Bo,!0,function(e){return new ko(e)});var Do={__proto__:null,KHR_materials_ior:ko},Go="KHR_materials_variants",Vo=function(){function e(e){this.name=Go,this._loader=e,this.enabled=this._loader.isExtensionUsed(Go)&&!this._loader.parent.skipMaterials}return e.prototype.dispose=function(){this._loader=null},e.GetAvailableVariants=function(e){var t=this._GetExtensionMetadata(e);return t?Object.keys(t.variants):[]},e.prototype.getAvailableVariants=function(t){return e.GetAvailableVariants(t)},e.SelectVariant=function(e,t){var n=this._GetExtensionMetadata(e);if(!n)throw new Error("Cannot select variant on a glTF mesh that does not have the ".concat(Go," extension"));var r=function(e){var t=n.variants[e];if(t)for(var r=0,o=t;r<o.length;r++){var a=o[r];a.mesh.material=a.material}};if(t instanceof Array)for(var o=0,a=t;o<a.length;o++)r(a[o]);else r(t);n.lastSelected=t},e.prototype.selectVariant=function(t,n){e.SelectVariant(t,n)},e.Reset=function(e){var t=this._GetExtensionMetadata(e);if(!t)throw new Error("Cannot reset on a glTF mesh that does not have the ".concat(Go," extension"));for(var n=0,r=t.original;n<r.length;n++){var o=r[n];o.mesh.material=o.material}t.lastSelected=null},e.prototype.reset=function(t){e.Reset(t)},e.GetLastSelectedVariant=function(e){var t=this._GetExtensionMetadata(e);if(!t)throw new Error("Cannot get the last selected variant on a glTF mesh that does not have the ".concat(Go," extension"));return t.lastSelected},e.prototype.getLastSelectedVariant=function(t){return e.GetLastSelectedVariant(t)},e._GetExtensionMetadata=function(e){var t,n;return(null===(n=null===(t=null==e?void 0:e._internalMetadata)||void 0===t?void 0:t.gltf)||void 0===n?void 0:n[Go])||null},e.prototype.onLoading=function(){var e=this._loader.gltf.extensions;if(e&&e[this.name]){var t=e[this.name];this._variants=t.variants}},e.prototype.onReady=function(){var t,n=this._loader.rootBabylonMesh;if(n){var r=this._loader.parent.extensionOptions[Go];(null==r?void 0:r.defaultVariant)&&e.SelectVariant(n,r.defaultVariant),null===(t=null==r?void 0:r.onLoaded)||void 0===t||t.call(r,{get variants(){return e.GetAvailableVariants(n)},get selectedVariant(){var t=e.GetLastSelectedVariant(n);return t?Array.isArray(t)?t[0]:t:e.GetAvailableVariants(n)[0]},set selectedVariant(t){e.SelectVariant(n,t)}})}},e.prototype._loadMeshPrimitiveAsync=function(n,r,o,a,i,s){var l=this;return yr.LoadExtensionAsync(n,i,this.name,function(u,c){return _(l,void 0,void 0,function(){var l,f=this;return g(this,function(d){switch(d.label){case 0:return(l=new Array).push(this._loader._loadMeshPrimitiveAsync(n,r,o,a,i,function(r){if(s(r),r instanceof t.Mesh){var o=yr._GetDrawMode(n,i.mode),a=f._loader.rootBabylonMesh,d=a?a._internalMetadata=a._internalMetadata||{}:{},h=d.gltf=d.gltf||{},p=h[Go]=h[Go]||{lastSelected:null,original:[],variants:{}};p.original.push({mesh:r,material:r.material});for(var m=function(t){var n=c.mappings[t],i=_r.Get("".concat(u,"/mappings/").concat(t,"/material"),f._loader.gltf.materials,n.material);l.push(f._loader._loadMaterialAsync("#/materials/".concat(n.material),i,r,o,function(t){for(var o=function(o){var i=n.variants[o],s=_r.Get("/extensions/".concat(Go,"/variants/").concat(i),f._variants,i);p.variants[s.name]=p.variants[s.name]||[],p.variants[s.name].push({mesh:r,material:t}),r.onClonedObservable.add(function(t){var n,o=t,i=o;do{if(!(i=i.parent))return;n=e._GetExtensionMetadata(i)}while(null===n);if(a&&n===e._GetExtensionMetadata(a)){for(var l in i._internalMetadata={},a._internalMetadata)i._internalMetadata[l]=a._internalMetadata[l];for(var l in i._internalMetadata.gltf=[],a._internalMetadata.gltf)i._internalMetadata.gltf[l]=a._internalMetadata.gltf[l];i._internalMetadata.gltf[Go]={lastSelected:null,original:[],variants:{}};for(var u=0,c=n.original;u<c.length;u++){var f=c[u];i._internalMetadata.gltf[Go].original.push({mesh:f.mesh,material:f.material})}for(var l in n.variants)if(Object.prototype.hasOwnProperty.call(n.variants,l)){i._internalMetadata.gltf[Go].variants[l]=[];for(var d=0,h=n.variants[l];d<h.length;d++){var p=h[d];i._internalMetadata.gltf[Go].variants[l].push({mesh:p.mesh,material:p.material})}}n=i._internalMetadata.gltf[Go]}for(var m=0,v=n.original;m<v.length;m++)(y=v[m]).mesh===r&&(y.mesh=o);for(var _=0,g=n.variants[s.name];_<g.length;_++){var y;(y=g[_]).mesh===r&&(y.mesh=o)}})},i=0;i<n.variants.length;++i)o(i)}))},v=0;v<c.mappings.length;++v)m(v)}})),[4,Promise.all(l).then(function(e){return e[0]})];case 1:return[2,d.sent()]}})})})},e}();er(Go),$n(Go,!0,function(e){return new Vo(e)});var Ho={__proto__:null,KHR_materials_variants:Vo},Uo=function(){function e(n,r){var o=this;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=v(v({},e._GetDefaultOptions()),n),this._scene=r,this._scene._transmissionHelper=this,this.onErrorObservable=new t.Observable,this._scene.onDisposeObservable.addOnce(function(){o.dispose()}),this._parseScene(),this._setupRenderTargets()}return e._GetDefaultOptions=function(){return{renderSize:1024,samples:4,lodGenerationScale:1,lodGenerationOffset:-4,renderTargetTextureType:t.Constants.TEXTURETYPE_HALF_FLOAT,generateMipmaps:!0}},e.prototype.addMaterialImpl=function(e){this._materialImpls.some(function(t){return t.materialClass===e.materialClass})||this._materialImpls.push(e)},e.prototype.updateOptions=function(e){var t=this,n=Object.keys(e).filter(function(n){return t._options[n]!==e[n]});if(n.length){var r=v(v({},this._options),e),o=this._options;this._options=r,r.renderSize===o.renderSize&&r.renderTargetTextureType===o.renderTargetTextureType&&r.generateMipmaps===o.generateMipmaps&&this._opaqueRenderTarget?(this._opaqueRenderTarget.samples=r.samples,this._opaqueRenderTarget.lodGenerationScale=r.lodGenerationScale,this._opaqueRenderTarget.lodGenerationOffset=r.lodGenerationOffset):this._setupRenderTargets()}},e.prototype.getOpaqueTarget=function(){return this._opaqueRenderTarget},e.prototype._getOrCreateAdapter=function(e){var t=this._adapterCache.get(e);if(!t)for(var n=0,r=this._materialImpls;n<r.length;n++){var o=r[n];if(e instanceof o.materialClass){t=new o.adapterClass(e),this._adapterCache.set(e,t);break}}return t},e.prototype._classifyMeshMaterials=function(e){var n=e.material;if(!n)return"opaque";if(!(n instanceof t.MultiMaterial))return(s=this._getOrCreateAdapter(n))&&s.isTranslucent()?(s.refractionBackgroundTexture=this._opaqueRenderTarget,"transparent"):"opaque";for(var r=!1,o=!1,a=new Set,i=0;i<n.subMaterials.length;i++){var s,l=n.subMaterials[i];l&&(s=this._getOrCreateAdapter(l))&&s.isTranslucent()?(s.refractionBackgroundTexture=this._opaqueRenderTarget,r=!0,a.add(i)):o=!0}return r&&o?(this._translucentMaterialIndices.set(e,a),this._rebuildOpaqueOnlySubMeshes(e,a),"mixed"):(this._translucentMaterialIndices.delete(e),this._opaqueOnlySubMeshes.delete(e),r?"transparent":"opaque")},e.prototype._rebuildOpaqueOnlySubMeshes=function(e,t){e.subMeshes&&this._opaqueOnlySubMeshes.set(e,e.subMeshes.filter(function(e){return!t.has(e.materialIndex)}))},e.prototype._addMesh=function(e){var n=this;this._materialObservers[e.uniqueId]=e.onMaterialChangedObservable.add(this._onMeshMaterialChanged.bind(this)),t.Tools.SetImmediate(function(){n._disposed||e.material&&("transparent"===n._classifyMeshMaterials(e)?-1===n._transparentMeshesCache.indexOf(e)&&n._transparentMeshesCache.push(e):-1===n._opaqueMeshesCache.indexOf(e)&&n._opaqueMeshesCache.push(e))})},e.prototype._removeMesh=function(e){e.onMaterialChangedObservable.remove(this._materialObservers[e.uniqueId]),delete this._materialObservers[e.uniqueId];var t=this._transparentMeshesCache.indexOf(e);-1!==t&&this._transparentMeshesCache.splice(t,1),-1!==(t=this._opaqueMeshesCache.indexOf(e))&&this._opaqueMeshesCache.splice(t,1),this._translucentMaterialIndices.delete(e),this._opaqueOnlySubMeshes.delete(e)},e.prototype._parseScene=function(){this._scene.meshes.forEach(this._addMesh.bind(this)),this._newMeshObserver=this._scene.onNewMeshAddedObservable.add(this._addMesh.bind(this)),this._removedMeshObserver=this._scene.onMeshRemovedObservable.add(this._removeMesh.bind(this))},e.prototype._onMeshMaterialChanged=function(e){var t=this._transparentMeshesCache.indexOf(e),n=this._opaqueMeshesCache.indexOf(e);"transparent"===this._classifyMeshMaterials(e)?-1!==n?(this._opaqueMeshesCache.splice(n,1),this._transparentMeshesCache.push(e)):-1===t&&this._transparentMeshesCache.push(e):-1!==t?(this._transparentMeshesCache.splice(t,1),this._opaqueMeshesCache.push(e)):-1===n&&this._opaqueMeshesCache.push(e)},e.prototype._isRenderTargetValid=function(){var e;return null!==(null===(e=this._opaqueRenderTarget)||void 0===e?void 0:e.getInternalTexture())},e.prototype._setupRenderTargets=function(){var e,n,r,o=this;this._opaqueRenderTarget&&this._opaqueRenderTarget.dispose(),this._opaqueRenderTarget=new t.RenderTargetTexture("opaqueSceneTexture",this._options.renderSize,this._scene,this._options.generateMipmaps,void 0,this._options.renderTargetTextureType),this._opaqueRenderTarget.ignoreCameraViewport=!0,this._opaqueRenderTarget.renderList=this._opaqueMeshesCache,this._opaqueRenderTarget.clearColor=null!==(n=null===(e=this._options.clearColor)||void 0===e?void 0:e.clone())&&void 0!==n?n:this._scene.clearColor.clone(),this._opaqueRenderTarget.clearColor.a=0,this._opaqueRenderTarget.gammaSpace=!1,this._opaqueRenderTarget.lodGenerationScale=this._options.lodGenerationScale,this._opaqueRenderTarget.lodGenerationOffset=this._options.lodGenerationOffset,this._opaqueRenderTarget.samples=this._options.samples,this._opaqueRenderTarget.renderSprites=!0,this._opaqueRenderTarget.renderParticles=!0,this._opaqueRenderTarget.disableImageProcessing=!0,this._opaqueRenderTarget.onBeforeBindObservable.add(function(e){r=o._scene.environmentIntensity,o._scene.environmentIntensity=1,o._options.clearColor?e.clearColor.copyFrom(o._options.clearColor):o._scene.clearColor.toLinearSpaceToRef(e.clearColor,o._scene.getEngine().useExactSrgbConversions),e.clearColor.a=0;for(var t=o._opaqueOnlySubMeshes.entries(),n=t.next();!n.done;n=t.next()){var a=n.value[0],i=n.value[1];a.subMeshes&&(o._savedSubMeshes.set(a,a.subMeshes),a.subMeshes=i)}}),this._opaqueRenderTarget.onAfterUnbindObservable.add(function(){o._scene.environmentIntensity=r;for(var e=o._savedSubMeshes.entries(),t=e.next();!t.done;t=e.next())t.value[0].subMeshes=t.value[1];o._savedSubMeshes.clear()});for(var a=0,i=this._transparentMeshesCache;a<i.length;a++)(u=i[a]).material&&this._classifyMeshMaterials(u);for(var s=this._translucentMaterialIndices.entries(),l=s.next();!l.done;l=s.next()){var u;(u=l.value[0]).material&&this._classifyMeshMaterials(u)}},e.prototype.dispose=function(){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;for(var n=0,r=y(y([],this._transparentMeshesCache,!0),this._opaqueMeshesCache,!0);n<r.length;n++){var o=r[n];(s=this._materialObservers[o.uniqueId])&&(s.remove(),delete this._materialObservers[o.uniqueId])}for(var a=0,i=this._scene.meshes;a<i.length;a++){var s;o=i[a],(s=this._materialObservers[o.uniqueId])&&(s.remove(),delete this._materialObservers[o.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()},e}();function jo(e,t){if(!e.parent.dontUseTransmissionHelper){for(var n=t.getScene()._transmissionHelper,r=null!=n?n:new Uo({},t.getScene()),o=0,a=Array.from(e._pbrMaterialImpls.values());o<a.length;o++){var i=a[o];r.addMaterialImpl(i)}n&&!n._isRenderTargetValid()&&n._setupRenderTargets()}}var Ko="KHR_materials_transmission",Wo=function(){function e(e){this.name=Ko,this.order=175,this._loader=e,this.enabled=this._loader.isExtensionUsed(Ko),this.enabled&&(e.parent.transparencyAsCoverage=!0)}return e.prototype.dispose=function(){this._loader=null},e.prototype.loadMaterialPropertiesAsync=function(e,t,n){var r=this;return yr.LoadExtensionAsync(e,t,this.name,function(o,a){return _(r,void 0,void 0,function(){var r;return g(this,function(i){switch(i.label){case 0:return(r=new Array).push(this._loader.loadMaterialPropertiesAsync(e,t,n)),r.push(this._loadTransparentPropertiesAsync(o,t,n,a)),[4,Promise.all(r).then(function(){})];case 1:return[2,i.sent()]}})})})},e.prototype._loadTransparentPropertiesAsync=function(e,t,n,r){var o=this._loader._getOrCreateMaterialAdapter(n),a=void 0!==r.transmissionFactor?r.transmissionFactor:0;if(0===a||!o)return Promise.resolve();o.configureTransmission(),o.transmissionWeight=a,a>0&&jo(this._loader,n);var i=Promise.resolve(null);return r.transmissionTexture&&(r.transmissionTexture.nonColorData=!0,i=this._loader.loadTextureInfoAsync("".concat(e,"/transmissionTexture"),r.transmissionTexture,function(e){e.name="".concat(n.name," (Transmission)"),o.transmissionWeightTexture=e})),i.then(function(){})},e}();er(Ko),$n(Ko,!0,function(e){return new Wo(e)});var zo={__proto__:null,KHR_materials_transmission:Wo},qo="KHR_materials_diffuse_transmission",Xo=function(){function e(e){this.name=qo,this.order=174,this._loader=e,this.enabled=this._loader.isExtensionUsed(qo),this.enabled&&(e.parent.transparencyAsCoverage=!0)}return e.prototype.dispose=function(){this._loader=null},e.prototype.loadMaterialPropertiesAsync=function(e,t,n){var r=this;return yr.LoadExtensionAsync(e,t,this.name,function(o,a){return _(r,void 0,void 0,function(){var r;return g(this,function(i){switch(i.label){case 0:return(r=new Array).push(this._loader.loadMaterialPropertiesAsync(e,t,n)),r.push(this._loadTranslucentPropertiesAsync(o,t,n,a)),[4,Promise.all(r).then(function(){})];case 1:return[2,i.sent()]}})})})},e.prototype._loadTranslucentPropertiesAsync=function(e,n,r,o){var a,i=this._loader._getOrCreateMaterialAdapter(r);i.configureSubsurface(),i.subsurfaceWeight=null!==(a=o.diffuseTransmissionFactor)&&void 0!==a?a:0,i.subsurfaceWeight>0&&jo(this._loader,r),i.diffuseTransmissionTint=void 0!==o.diffuseTransmissionColorFactor?t.Color3.FromArray(o.diffuseTransmissionColorFactor):t.Color3.White();var s=new Array;return o.diffuseTransmissionTexture&&(o.diffuseTransmissionTexture.nonColorData=!0,s.push(this._loader.loadTextureInfoAsync("".concat(e,"/diffuseTransmissionTexture"),o.diffuseTransmissionTexture).then(function(e){e.name="".concat(r.name," (Diffuse Transmission)"),i.subsurfaceWeightTexture=e}))),o.diffuseTransmissionColorTexture&&s.push(this._loader.loadTextureInfoAsync("".concat(e,"/diffuseTransmissionColorTexture"),o.diffuseTransmissionColorTexture).then(function(e){e.name="".concat(r.name," (Diffuse Transmission Color)"),i.diffuseTransmissionTintTexture=e})),Promise.all(s).then(function(){})},e}();er(qo),$n(qo,!0,function(e){return new Xo(e)});var Yo={__proto__:null,KHR_materials_diffuse_transmission:Xo},Qo="KHR_materials_volume",Zo=function(){function e(e){this.name=Qo,this.order=173,this._loader=e,this.enabled=this._loader.isExtensionUsed(Qo),this.enabled&&this._loader._disableInstancedMesh++}return e.prototype.dispose=function(){this.enabled&&this._loader._disableInstancedMesh--,this._loader=null},e.prototype.loadMaterialPropertiesAsync=function(e,t,n){var r=this;return yr.LoadExtensionAsync(e,t,this.name,function(o,a){return _(r,void 0,void 0,function(){var r;return g(this,function(i){switch(i.label){case 0:return(r=new Array).push(this._loader.loadMaterialPropertiesAsync(e,t,n)),r.push(this._loadVolumePropertiesAsync(o,t,n,a)),[4,Promise.all(r).then(function(){})];case 1:return[2,i.sent()]}})})})},e.prototype._loadVolumePropertiesAsync=function(e,n,r,o){var a,i=this._loader._getOrCreateMaterialAdapter(r);if(0===i.transmissionWeight&&0===i.subsurfaceWeight||!o.thicknessFactor)return Promise.resolve();i.geometryThinWalled=!1;var s=void 0!==o.attenuationDistance?o.attenuationDistance:Number.MAX_VALUE,l=void 0!==o.attenuationColor&&3==o.attenuationColor.length?t.Color3.FromArray(o.attenuationColor):t.Color3.White();i.configureVolume(),i.transmissionColor=l,i.transmissionDepth=s,i.volumeThickness=null!==(a=o.thicknessFactor)&&void 0!==a?a:0;var u=new Array;return o.thicknessTexture&&(o.thicknessTexture.nonColorData=!0,u.push(this._loader.loadTextureInfoAsync("".concat(e,"/thicknessTexture"),o.thicknessTexture,function(e){e.name="".concat(r.name," (Thickness)"),i.volumeThicknessTexture=e}))),Promise.all(u).then(function(){})},e}();er(Qo),$n(Qo,!0,function(e){return new Zo(e)});var Jo={__proto__:null,KHR_materials_volume:Zo},$o="KHR_materials_volume_scatter",ea=function(){function e(e){this.name=$o,this.order=172,this._loader=e,this.enabled=this._loader.isExtensionUsed($o),this.enabled&&this._loader._disableInstancedMesh++}return e.prototype.dispose=function(){this.enabled&&this._loader._disableInstancedMesh--,this._loader=null},e.prototype.loadMaterialPropertiesAsync=function(e,t,n){var r=this;return yr.LoadExtensionAsync(e,t,this.name,function(o,a){return _(r,void 0,void 0,function(){var r;return g(this,function(i){switch(i.label){case 0:return(r=new Array).push(this._loader.loadMaterialPropertiesAsync(e,t,n)),r.push(this._loadVolumePropertiesAsync(o,t,n,a)),[4,Promise.all(r).then(function(){})];case 1:return[2,i.sent()]}})})})},e.prototype._loadVolumePropertiesAsync=function(e,n,r,o){var a=this._loader._getOrCreateMaterialAdapter(r);if(0===a.transmissionWeight&&0===a.subsurfaceWeight||a.geometryThinWalled)return Promise.resolve();var i=void 0!==o.multiscatterColorFactor&&3==o.multiscatterColorFactor.length?t.Color3.FromArray(o.multiscatterColorFactor):t.Color3.Black(),s=void 0!==o.scatterAnisotropy?o.scatterAnisotropy:0,l=Promise.resolve(null);o.multiscatterColorTexture&&(o.multiscatterColorTexture.nonColorData=!0,l=this._loader.loadTextureInfoAsync("".concat(e,"/multiscatterColorTexture"),o.multiscatterColorTexture,function(e){e.name="".concat(r.name," (Scatter Color)"),a.transmissionWeight>0&&(a.transmissionScatterTexture=e),a.subsurfaceWeight>0&&(a.subsurfaceColorTexture=e)}));var u=new t.Vector3(-Math.log(a.transmissionColor.r),-Math.log(a.transmissionColor.g),-Math.log(a.transmissionColor.b));if(u.scaleInPlace(1/Math.max(a.transmissionDepth,1e-6)),a.transmissionWeight>0){var c=function(e){var n=new t.Vector3(e.r,e.g,e.b),r=new t.Vector3(4.09712,4.09712,4.09712);r.addInPlace(new t.Vector3(4.20863,4.20863,4.20863).multiplyInPlace(n));var o=new t.Vector3(9.59217,9.59217,9.59217);return o.addInPlace(new t.Vector3(41.6808,41.6808,41.6808).multiplyInPlace(n)),o.addInPlace(new t.Vector3(17.7126,17.7126,17.7126).multiplyInPlace(n.multiply(n))),r.subtractInPlace(new t.Vector3(Math.sqrt(o.x),Math.sqrt(o.y),Math.sqrt(o.z))),new t.Vector3(1,1,1).subtract(r.multiply(r))}(i),f=u.multiply(c);f.scaleInPlace(a.transmissionDepth),a.transmissionScatter.set(f.x,f.y,f.z),a.transmissionScatterAnisotropy=s}if(a.subsurfaceWeight>0){a.subsurfaceScatterAnisotropy=s,a.subsurfaceColor=i;var d=new t.Vector3(0!==u.x?1/u.x:1,0!==u.y?1/u.y:1,0!==u.z?1/u.z:1);a.subsurfaceRadius=Math.max(d.x,d.y,d.z),a.subsurfaceRadiusScale=new t.Color3(d.x/a.subsurfaceRadius,d.y/a.subsurfaceRadius,d.z/a.subsurfaceRadius)}return l.then(function(){})},e}();er($o),$n($o,!0,function(e){return new ea(e)});var ta={__proto__:null,KHR_materials_volume_scatter:ea},na="KHR_materials_dispersion",ra=function(){function e(e){this.name=na,this.order=174,this._loader=e,this.enabled=this._loader.isExtensionUsed(na)}return e.prototype.dispose=function(){this._loader=null},e.prototype.loadMaterialPropertiesAsync=function(e,t,n){var r=this;return yr.LoadExtensionAsync(e,t,this.name,function(o,a){return _(r,void 0,void 0,function(){var r;return g(this,function(i){switch(i.label){case 0:return(r=new Array).push(this._loader.loadMaterialPropertiesAsync(e,t,n)),r.push(this._loadDispersionPropertiesAsync(o,t,n,a)),[4,Promise.all(r).then(function(){})];case 1:return[2,i.sent()]}})})})},e.prototype._loadDispersionPropertiesAsync=function(e,t,n,r){var o=this._loader._getOrCreateMaterialAdapter(n);return 0!=o.transmissionWeight&&r.dispersion?(o.transmissionDispersionAbbeNumber=20,o.transmissionDispersionScale=r.dispersion,Promise.resolve()):Promise.resolve()},e}();er(na),$n(na,!0,function(e){return new ra(e)});var oa={__proto__:null,KHR_materials_dispersion:ra},aa="KHR_materials_diffuse_roughness",ia=function(){function e(e){this.name=aa,this.order=190,this._loader=e,this.enabled=this._loader.isExtensionUsed(aa)}return e.prototype.dispose=function(){this._loader=null},e.prototype.loadMaterialPropertiesAsync=function(e,t,n){var r=this;return yr.LoadExtensionAsync(e,t,this.name,function(o,a){return _(r,void 0,void 0,function(){var r;return g(this,function(i){switch(i.label){case 0:return(r=new Array).push(this._loader.loadMaterialPropertiesAsync(e,t,n)),r.push(this._loadDiffuseRoughnessPropertiesAsync(o,a,n)),[4,Promise.all(r).then(function(){})];case 1:return[2,i.sent()]}})})})},e.prototype._loadDiffuseRoughnessPropertiesAsync=function(e,t,n){var r,o=this._loader._getOrCreateMaterialAdapter(n),a=new Array;return o.baseDiffuseRoughness=null!==(r=t.diffuseRoughnessFactor)&&void 0!==r?r:0,t.diffuseRoughnessTexture&&a.push(this._loader.loadTextureInfoAsync("".concat(e,"/diffuseRoughnessTexture"),t.diffuseRoughnessTexture,function(e){e.name="".concat(n.name," (Diffuse Roughness)"),o.baseDiffuseRoughnessTexture=e})),Promise.all(a).then(function(){})},e}();er(aa),$n(aa,!0,function(e){return new ia(e)});var sa={__proto__:null,KHR_materials_diffuse_roughness:ia},la="KHR_mesh_quantization",ua=function(){function e(e){this.name=la,this.enabled=e.isExtensionUsed(la)}return e.prototype.dispose=function(){},e}();er(la),$n(la,!0,function(e){return new ua(e)});var ca={__proto__:null,KHR_mesh_quantization:ua},fa="KHR_texture_basisu",da=function(){function e(e){this.name=fa,this._loader=e,this.enabled=e.isExtensionUsed(fa)}return e.prototype.dispose=function(){this._loader=null},e.prototype._loadTextureAsync=function(e,t,n){var r=this;return yr.LoadExtensionAsync(e,t,this.name,function(o,a){return _(r,void 0,void 0,function(){var r,i;return g(this,function(s){switch(s.label){case 0:return r=null==t.sampler?yr.DefaultSampler:_r.Get("".concat(e,"/sampler"),this._loader.gltf.samplers,t.sampler),i=_r.Get("".concat(o,"/source"),this._loader.gltf.images,a.source),[4,this._loader._createTextureAsync(e,r,i,function(e){n(e)},t._textureInfo.nonColorData?{useRGBAIfASTCBC7NotAvailableWhenUASTC:!0}:void 0,!t._textureInfo.nonColorData)];case 1:return[2,s.sent()]}})})})},e}();er(fa),$n(fa,!0,function(e){return new da(e)});var ha={__proto__:null,KHR_texture_basisu:da},pa="KHR_texture_transform",ma=function(){function e(e){this.name=pa,this._loader=e,this.enabled=this._loader.isExtensionUsed(pa)}return e.prototype.dispose=function(){this._loader=null},e.prototype.loadTextureInfoAsync=function(e,n,r){var o=this;return yr.LoadExtensionAsync(e,n,this.name,function(a,i){return _(o,void 0,void 0,function(){return g(this,function(o){switch(o.label){case 0:return[4,this._loader.loadTextureInfoAsync(e,n,function(e){if(!(e instanceof t.Texture))throw new Error("".concat(a,": Texture type not supported"));i.offset&&(e.uOffset=i.offset[0],e.vOffset=i.offset[1]),e.uRotationCenter=0,e.vRotationCenter=0,i.rotation&&(e.wAng=-i.rotation),i.scale&&(e.uScale=i.scale[0],e.vScale=i.scale[1]),null!=i.texCoord&&(e.coordinatesIndex=i.texCoord),r(e)})];case 1:return[2,o.sent()]}})})})},e}();er(pa),$n(pa,!0,function(e){return new ma(e)});var va={__proto__:null,KHR_texture_transform:ma},_a="KHR_xmp_json_ld",ga=function(){function e(e){this.name=_a,this.order=100,this._loader=e,this.enabled=this._loader.isExtensionUsed(_a)}return e.prototype.dispose=function(){this._loader=null},e.prototype.onLoading=function(){var e,t,n;if(null!==this._loader.rootBabylonMesh){var r=null===(e=this._loader.gltf.extensions)||void 0===e?void 0:e.KHR_xmp_json_ld,o=null===(n=null===(t=this._loader.gltf.asset)||void 0===t?void 0:t.extensions)||void 0===n?void 0:n.KHR_xmp_json_ld;if(r&&o){var a=+o.packet;r.packets&&a<r.packets.length&&(this._loader.rootBabylonMesh.metadata=this._loader.rootBabylonMesh.metadata||{},this._loader.rootBabylonMesh.metadata.xmp=r.packets[a])}}},e}();er(_a),$n(_a,!0,function(e){return new ga(e)});var ya={__proto__:null,KHR_xmp_json_ld:ga};function ba(e,n,r,o){return t.Color3.FromArray(n,r).scale(o)}function xa(e,t,n,r){return t[n]*r}function Ta(e,t,n,r){return-t[n]*r}function Aa(e,t,n,r){return t[n+1]*r}function wa(e,t,n,r){return t[n]*r*2}function Ma(e){return{scale:[new Oa(t.Animation.ANIMATIONTYPE_FLOAT,"".concat(e,".uScale"),xa,function(){return 2}),new Oa(t.Animation.ANIMATIONTYPE_FLOAT,"".concat(e,".vScale"),Aa,function(){return 2})],offset:[new Oa(t.Animation.ANIMATIONTYPE_FLOAT,"".concat(e,".uOffset"),xa,function(){return 2}),new Oa(t.Animation.ANIMATIONTYPE_FLOAT,"".concat(e,".vOffset"),Aa,function(){return 2})],rotation:[new Oa(t.Animation.ANIMATIONTYPE_FLOAT,"".concat(e,".wAng"),Ta,function(){return 1})]}}var Ca=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return m(t,e),t.prototype.buildAnimations=function(e,t,n,r){return[{babylonAnimatable:e._babylonCamera,babylonAnimation:this._buildAnimation(t,n,r)}]},t}(wr),Oa=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return m(t,e),t.prototype.buildAnimations=function(e,t,n,r){var o=[];for(var a in e._data)o.push({babylonAnimatable:e._data[a].babylonMaterial,babylonAnimation:this._buildAnimation(t,n,r)});return o},t}(wr),Sa=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return m(t,e),t.prototype.buildAnimations=function(e,t,n,r){return[{babylonAnimatable:e._babylonLight,babylonAnimation:this._buildAnimation(t,n,r)}]},t}(wr),Ea=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return m(t,e),t.prototype.buildAnimations=function(e,t,n,r){var o=this;return e._primitiveBabylonMeshes?e._primitiveBabylonMeshes.map(function(e){return{babylonAnimatable:e,babylonAnimation:o._buildAnimation(t,n,r)}}):[]},t}(wr);hr("/cameras/{}/orthographic/xmag",[new Ca(t.Animation.ANIMATIONTYPE_FLOAT,"orthoLeft",Ta,function(){return 1}),new Ca(t.Animation.ANIMATIONTYPE_FLOAT,"orthoRight",Aa,function(){return 1})]),hr("/cameras/{}/orthographic/ymag",[new Ca(t.Animation.ANIMATIONTYPE_FLOAT,"orthoBottom",Ta,function(){return 1}),new Ca(t.Animation.ANIMATIONTYPE_FLOAT,"orthoTop",Aa,function(){return 1})]),hr("/cameras/{}/orthographic/zfar",[new Ca(t.Animation.ANIMATIONTYPE_FLOAT,"maxZ",xa,function(){return 1})]),hr("/cameras/{}/orthographic/znear",[new Ca(t.Animation.ANIMATIONTYPE_FLOAT,"minZ",xa,function(){return 1})]),hr("/cameras/{}/perspective/yfov",[new Ca(t.Animation.ANIMATIONTYPE_FLOAT,"fov",xa,function(){return 1})]),hr("/cameras/{}/perspective/zfar",[new Ca(t.Animation.ANIMATIONTYPE_FLOAT,"maxZ",xa,function(){return 1})]),hr("/cameras/{}/perspective/znear",[new Ca(t.Animation.ANIMATIONTYPE_FLOAT,"minZ",xa,function(){return 1})]),hr("/materials/{}/pbrMetallicRoughness/baseColorFactor",[new Oa(t.Animation.ANIMATIONTYPE_COLOR3,"albedoColor",ba,function(){return 4}),new Oa(t.Animation.ANIMATIONTYPE_FLOAT,"alpha",function(e,t,n,r){return t[n+3]*r},function(){return 4})]),hr("/materials/{}/pbrMetallicRoughness/metallicFactor",[new Oa(t.Animation.ANIMATIONTYPE_FLOAT,"metallic",xa,function(){return 1})]),hr("/materials/{}/pbrMetallicRoughness/metallicFactor",[new Oa(t.Animation.ANIMATIONTYPE_FLOAT,"roughness",xa,function(){return 1})]);var Fa=Ma("albedoTexture");hr("/materials/{}/pbrMetallicRoughness/baseColorTexture/extensions/KHR_texture_transform/scale",Fa.scale),hr("/materials/{}/pbrMetallicRoughness/baseColorTexture/extensions/KHR_texture_transform/offset",Fa.offset),hr("/materials/{}/pbrMetallicRoughness/baseColorTexture/extensions/KHR_texture_transform/rotation",Fa.rotation);var Ra=Ma("metallicTexture");hr("//materials/{}/pbrMetallicRoughness/metallicRoughnessTexture/scale",Ra.scale),hr("//materials/{}/pbrMetallicRoughness/metallicRoughnessTexture/offset",Ra.offset),hr("//materials/{}/pbrMetallicRoughness/metallicRoughnessTexture/rotation",Ra.rotation),hr("/materials/{}/emissiveFactor",[new Oa(t.Animation.ANIMATIONTYPE_COLOR3,"emissiveColor",ba,function(){return 3})]);var La=Ma("bumpTexture");hr("/materials/{}/normalTexture/scale",[new Oa(t.Animation.ANIMATIONTYPE_FLOAT,"bumpTexture.level",xa,function(){return 1})]),hr("/materials/{}/normalTexture/extensions/KHR_texture_transform/scale",La.scale),hr("/materials/{}/normalTexture/extensions/KHR_texture_transform/offset",La.offset),hr("/materials/{}/normalTexture/extensions/KHR_texture_transform/rotation",La.rotation),hr("/materials/{}/occlusionTexture/strength",[new Oa(t.Animation.ANIMATIONTYPE_FLOAT,"ambientTextureStrength",xa,function(){return 1})]);var Ia=Ma("ambientTexture");hr("/materials/{}/occlusionTexture/extensions/KHR_texture_transform/scale",Ia.scale),hr("/materials/{}/occlusionTexture/extensions/KHR_texture_transform/offset",Ia.offset),hr("/materials/{}/occlusionTexture/extensions/KHR_texture_transform/rotation",Ia.rotation);var Pa=Ma("emissiveTexture");hr("/materials/{}/emissiveTexture/extensions/KHR_texture_transform/scale",Pa.scale),hr("/materials/{}/emissiveTexture/extensions/KHR_texture_transform/offset",Pa.offset),hr("/materials/{}/emissiveTexture/extensions/KHR_texture_transform/rotation",Pa.rotation),hr("/materials/{}/extensions/KHR_materials_anisotropy/anisotropyStrength",[new Oa(t.Animation.ANIMATIONTYPE_FLOAT,"anisotropy.intensity",xa,function(){return 1})]),hr("/materials/{}/extensions/KHR_materials_anisotropy/anisotropyRotation",[new Oa(t.Animation.ANIMATIONTYPE_FLOAT,"anisotropy.angle",xa,function(){return 1})]);var Na=Ma("anisotropy.texture");hr("/materials/{}/extensions/KHR_materials_anisotropy/anisotropyTexture/extensions/KHR_texture_transform/scale",Na.scale),hr("/materials/{}/extensions/KHR_materials_anisotropy/anisotropyTexture/extensions/KHR_texture_transform/offset",Na.offset),hr("/materials/{}/extensions/KHR_materials_anisotropy/anisotropyTexture/extensions/KHR_texture_transform/rotation",Na.rotation),hr("/materials/{}/extensions/KHR_materials_clearcoat/clearcoatFactor",[new Oa(t.Animation.ANIMATIONTYPE_FLOAT,"clearCoat.intensity",xa,function(){return 1})]),hr("/materials/{}/extensions/KHR_materials_clearcoat/clearcoatRoughnessFactor",[new Oa(t.Animation.ANIMATIONTYPE_FLOAT,"clearCoat.roughness",xa,function(){return 1})]);var Ba=Ma("clearCoat.texture");hr("/materials/{}/extensions/KHR_materials_clearcoat/clearcoatTexture/extensions/KHR_texture_transform/scale",Ba.scale),hr("/materials/{}/extensions/KHR_materials_clearcoat/clearcoatTexture/extensions/KHR_texture_transform/offset",Ba.offset),hr("/materials/{}/extensions/KHR_materials_clearcoat/clearcoatTexture/extensions/KHR_texture_transform/rotation",Ba.rotation);var ka=Ma("clearCoat.bumpTexture");hr("/materials/{}/extensions/KHR_materials_clearcoat/clearcoatNormalTexture/scale",[new Oa(t.Animation.ANIMATIONTYPE_FLOAT,"clearCoat.bumpTexture.level",xa,function(){return 1})]),hr("/materials/{}/extensions/KHR_materials_clearcoat/clearcoatNormalTexture/extensions/KHR_texture_transform/scale",ka.scale),hr("/materials/{}/extensions/KHR_materials_clearcoat/clearcoatNormalTexture/extensions/KHR_texture_transform/offset",ka.offset),hr("/materials/{}/extensions/KHR_materials_clearcoat/clearcoatNormalTexture/extensions/KHR_texture_transform/rotation",ka.rotation);var Da=Ma("clearCoat.textureRoughness");hr("/materials/{}/extensions/KHR_materials_clearcoat/clearcoatRoughnessTexture/extensions/KHR_texture_transform/scale",Da.scale),hr("/materials/{}/extensions/KHR_materials_clearcoat/clearcoatRoughnessTexture/extensions/KHR_texture_transform/offset",Da.offset),hr("/materials/{}/extensions/KHR_materials_clearcoat/clearcoatRoughnessTexture/extensions/KHR_texture_transform/rotation",Da.rotation),hr("/materials/{}/extensions/KHR_materials_dispersion/dispersionFactor",[new Oa(t.Animation.ANIMATIONTYPE_FLOAT,"subSurface.dispersion",xa,function(){return 1})]),hr("/materials/{}/extensions/KHR_materials_emissive_strength/emissiveStrength",[new Oa(t.Animation.ANIMATIONTYPE_FLOAT,"emissiveIntensity",xa,function(){return 1})]),hr("/materials/{}/extensions/KHR_materials_ior/ior",[new Oa(t.Animation.ANIMATIONTYPE_FLOAT,"indexOfRefraction",xa,function(){return 1})]),hr("/materials/{}/extensions/KHR_materials_iridescence/iridescenceFactor",[new Oa(t.Animation.ANIMATIONTYPE_FLOAT,"iridescence.intensity",xa,function(){return 1})]),hr("/materials/{}/extensions/KHR_materials_iridescence/iridescenceIor",[new Oa(t.Animation.ANIMATIONTYPE_FLOAT,"iridescence.indexOfRefraction",xa,function(){return 1})]),hr("/materials/{}/extensions/KHR_materials_iridescence/iridescenceThicknessMinimum",[new Oa(t.Animation.ANIMATIONTYPE_FLOAT,"iridescence.minimumThickness",xa,function(){return 1})]),hr("/materials/{}/extensions/KHR_materials_iridescence/iridescenceThicknessMaximum",[new Oa(t.Animation.ANIMATIONTYPE_FLOAT,"iridescence.maximumThickness",xa,function(){return 1})]);var Ga=Ma("iridescence.texture");hr("/materials/{}/extensions/KHR_materials_iridescence/iridescenceTexture/extensions/KHR_texture_transform/scale",Ga.scale),hr("/materials/{}/extensions/KHR_materials_iridescence/iridescenceTexture/extensions/KHR_texture_transform/offset",Ga.offset),hr("/materials/{}/extensions/KHR_materials_iridescence/iridescenceTexture/extensions/KHR_texture_transform/rotation",Ga.rotation);var Va=Ma("iridescence.thicknessTexture");hr("/materials/{}/extensions/KHR_materials_iridescence/iridescenceThicknessTexture/extensions/KHR_texture_transform/scale",Va.scale),hr("/materials/{}/extensions/KHR_materials_iridescence/iridescenceThicknessTexture/extensions/KHR_texture_transform/offset",Va.offset),hr("/materials/{}/extensions/KHR_materials_iridescence/iridescenceThicknessTexture/extensions/KHR_texture_transform/rotation",Va.rotation),hr("/materials/{}/extensions/KHR_materials_sheen/sheenColorFactor",[new Oa(t.Animation.ANIMATIONTYPE_COLOR3,"sheen.color",ba,function(){return 3})]),hr("/materials/{}/extensions/KHR_materials_sheen/sheenRoughnessFactor",[new Oa(t.Animation.ANIMATIONTYPE_FLOAT,"sheen.roughness",xa,function(){return 1})]);var Ha=Ma("sheen.texture");hr("/materials/{}/extensions/KHR_materials_sheen/sheenColorTexture/extensions/KHR_texture_transform/scale",Ha.scale),hr("/materials/{}/extensions/KHR_materials_sheen/sheenColorTexture/extensions/KHR_texture_transform/offset",Ha.offset),hr("/materials/{}/extensions/KHR_materials_sheen/sheenColorTexture/extensions/KHR_texture_transform/rotation",Ha.rotation);var Ua=Ma("sheen.textureRoughness");hr("/materials/{}/extensions/KHR_materials_sheen/sheenRoughnessTexture/extensions/KHR_texture_transform/scale",Ua.scale),hr("/materials/{}/extensions/KHR_materials_sheen/sheenRoughnessTexture/extensions/KHR_texture_transform/offset",Ua.offset),hr("/materials/{}/extensions/KHR_materials_sheen/sheenRoughnessTexture/extensions/KHR_texture_transform/rotation",Ua.rotation),hr("/materials/{}/extensions/KHR_materials_specular/specularFactor",[new Oa(t.Animation.ANIMATIONTYPE_FLOAT,"metallicF0Factor",xa,function(){return 1})]),hr("/materials/{}/extensions/KHR_materials_specular/specularColorFactor",[new Oa(t.Animation.ANIMATIONTYPE_COLOR3,"metallicReflectanceColor",ba,function(){return 3})]);var ja=Ma("metallicReflectanceTexture");hr("/materials/{}/extensions/KHR_materials_specular/specularTexture/extensions/KHR_texture_transform/scale",ja.scale),hr("/materials/{}/extensions/KHR_materials_specular/specularTexture/extensions/KHR_texture_transform/offset",ja.offset),hr("/materials/{}/extensions/KHR_materials_specular/specularTexture/extensions/KHR_texture_transform/rotation",ja.rotation);var Ka=Ma("reflectanceTexture");hr("/materials/{}/extensions/KHR_materials_specular/specularColorTexture/extensions/KHR_texture_transform/scale",Ka.scale),hr("/materials/{}/extensions/KHR_materials_specular/specularColorTexture/extensions/KHR_texture_transform/offset",Ka.offset),hr("/materials/{}/extensions/KHR_materials_specular/specularColorTexture/extensions/KHR_texture_transform/rotation",Ka.rotation),hr("/materials/{}/extensions/KHR_materials_transmission/transmissionFactor",[new Oa(t.Animation.ANIMATIONTYPE_FLOAT,"subSurface.refractionIntensity",xa,function(){return 1})]);var Wa=Ma("subSurface.refractionIntensityTexture");hr("/materials/{}/extensions/KHR_materials_transmission/transmissionTexture/extensions/KHR_texture_transform/scale",Wa.scale),hr("/materials/{}/extensions/KHR_materials_transmission/transmissionTexture/extensions/KHR_texture_transform/offset",Wa.offset),hr("/materials/{}/extensions/KHR_materials_transmission/transmissionTexture/extensions/KHR_texture_transform/rotation",Wa.rotation),hr("/materials/{}/extensions/KHR_materials_volume/attenuationColor",[new Oa(t.Animation.ANIMATIONTYPE_COLOR3,"subSurface.tintColor",ba,function(){return 3})]),hr("/materials/{}/extensions/KHR_materials_volume/attenuationDistance",[new Oa(t.Animation.ANIMATIONTYPE_FLOAT,"subSurface.tintColorAtDistance",xa,function(){return 1})]),hr("/materials/{}/extensions/KHR_materials_volume/thicknessFactor",[new Oa(t.Animation.ANIMATIONTYPE_FLOAT,"subSurface.maximumThickness",xa,function(){return 1})]);var za=Ma("subSurface.thicknessTexture");hr("/materials/{}/extensions/KHR_materials_volume/thicknessTexture/extensions/KHR_texture_transform/scale",za.scale),hr("/materials/{}/extensions/KHR_materials_volume/thicknessTexture/extensions/KHR_texture_transform/offset",za.offset),hr("/materials/{}/extensions/KHR_materials_volume/thicknessTexture/extensions/KHR_texture_transform/rotation",za.rotation),hr("/materials/{}/extensions/KHR_materials_diffuse_transmission/diffuseTransmissionFactor",[new Oa(t.Animation.ANIMATIONTYPE_FLOAT,"subSurface.translucencyIntensity",xa,function(){return 1})]);var qa=Ma("subSurface.translucencyIntensityTexture");hr("materials/{}/extensions/KHR_materials_diffuse_transmission/diffuseTransmissionTexture/extensions/KHR_texture_transform/scale",qa.scale),hr("materials/{}/extensions/KHR_materials_diffuse_transmission/diffuseTransmissionTexture/extensions/KHR_texture_transform/offset",qa.offset),hr("materials/{}/extensions/KHR_materials_diffuse_transmission/diffuseTransmissionTexture/extensions/KHR_texture_transform/rotation",qa.rotation),hr("/materials/{}/extensions/KHR_materials_diffuse_transmission/diffuseTransmissionColorFactor",[new Oa(t.Animation.ANIMATIONTYPE_COLOR3,"subSurface.translucencyColor",ba,function(){return 3})]);var Xa=Ma("subSurface.translucencyColorTexture");hr("materials/{}/extensions/KHR_materials_diffuse_transmission/diffuseTransmissionColorTexture/extensions/KHR_texture_transform/scale",Xa.scale),hr("materials/{}/extensions/KHR_materials_diffuse_transmission/diffuseTransmissionColorTexture/extensions/KHR_texture_transform/offset",Xa.offset),hr("materials/{}/extensions/KHR_materials_diffuse_transmission/diffuseTransmissionColorTexture/extensions/KHR_texture_transform/rotation",Xa.rotation),hr("/extensions/KHR_lights_punctual/lights/{}/color",[new Sa(t.Animation.ANIMATIONTYPE_COLOR3,"diffuse",ba,function(){return 3})]),hr("/extensions/KHR_lights_punctual/lights/{}/intensity",[new Sa(t.Animation.ANIMATIONTYPE_FLOAT,"intensity",xa,function(){return 1})]),hr("/extensions/KHR_lights_punctual/lights/{}/range",[new Sa(t.Animation.ANIMATIONTYPE_FLOAT,"range",xa,function(){return 1})]),hr("/extensions/KHR_lights_punctual/lights/{}/spot/innerConeAngle",[new Sa(t.Animation.ANIMATIONTYPE_FLOAT,"innerAngle",wa,function(){return 1})]),hr("/extensions/KHR_lights_punctual/lights/{}/spot/outerConeAngle",[new Sa(t.Animation.ANIMATIONTYPE_FLOAT,"angle",wa,function(){return 1})]),hr("/extensions/EXT_lights_area/lights/{}/color",[new Sa(t.Animation.ANIMATIONTYPE_COLOR3,"diffuse",ba,function(){return 3})]),hr("/extensions/EXT_lights_area/lights/{}/intensity",[new Sa(t.Animation.ANIMATIONTYPE_FLOAT,"intensity",xa,function(){return 1})]),hr("/extensions/EXT_lights_area/lights/{}/size",[new Sa(t.Animation.ANIMATIONTYPE_FLOAT,"radius",xa,function(){return 1})]),hr("/extensions/EXT_lights_area/lights/{}/rect/aspect",[new Sa(t.Animation.ANIMATIONTYPE_FLOAT,"radius",xa,function(){return 1})]),hr("/nodes/{}/extensions/EXT_lights_ies/color",[new Sa(t.Animation.ANIMATIONTYPE_COLOR3,"diffuse",ba,function(){return 3})]),hr("/nodes/{}/extensions/EXT_lights_ies/multiplier",[new Sa(t.Animation.ANIMATIONTYPE_FLOAT,"intensity",xa,function(){return 1})]),hr("/nodes/{}/extensions/KHR_node_visibility/visible",[new Ea(t.Animation.ANIMATIONTYPE_FLOAT,"isVisible",xa,function(){return 1})]);var Ya="KHR_animation_pointer",Qa=function(){function e(e){this.name=Ya,this._loader=e,this._pathToObjectConverter=fr(this._loader.gltf)}return Object.defineProperty(e.prototype,"enabled",{get:function(){return this._loader.isExtensionUsed(Ya)},enumerable:!1,configurable:!0}),e.prototype.dispose=function(){this._loader=null,delete this._pathToObjectConverter},e.prototype._loadAnimationChannelAsync=function(e,n,r,o,a){var i,s=null===(i=o.target.extensions)||void 0===i?void 0:i.KHR_animation_pointer;if(!s||!this._pathToObjectConverter)return null;"pointer"!==o.target.path&&t.Logger.Warn("".concat(e,"/target/path: Value (").concat(o.target.path,") must be (").concat("pointer",") when using the ").concat(this.name," extension")),null!=o.target.node&&t.Logger.Warn("".concat(e,"/target/node: Value (").concat(o.target.node,") must not be present when using the ").concat(this.name," extension"));var l="".concat(e,"/extensions/").concat(this.name),u=s.pointer;if(!u)throw new Error("".concat(l,": Pointer is missing"));try{var c=this._pathToObjectConverter.convert(u);if(!c.info.interpolation)throw new Error("".concat(l,"/pointer: Interpolation is missing"));return this._loader._loadAnimationChannelFromTargetInfoAsync(e,n,r,o,{object:c.object,info:c.info.interpolation},a)}catch(e){return t.Logger.Warn("".concat(l,"/pointer: Invalid pointer (").concat(u,") skipped")),null}},e}();er(Ya),$n(Ya,!0,function(e){return new Qa(e)});var Za={__proto__:null,KHR_animation_pointer:Qa},Ja="MSFT_audio_emitter",$a=function(){function e(e){this.name=Ja,this._loader=e,this.enabled=this._loader.isExtensionUsed(Ja)}return e.prototype.dispose=function(){this._loader=null,this._clips=null,this._emitters=null},e.prototype.onLoading=function(){var e=this._loader.gltf.extensions;if(e&&e[this.name]){var t=e[this.name];this._clips=t.clips,this._emitters=t.emitters,_r.Assign(this._clips),_r.Assign(this._emitters)}},e.prototype.loadSceneAsync=function(e,t){var n=this;return yr.LoadExtensionAsync(e,t,this.name,function(r,o){return _(n,void 0,void 0,function(){var n,a,i,s,l;return g(this,function(u){switch(u.label){case 0:for((n=new Array).push(this._loader.loadSceneAsync(e,t)),a=0,i=o.emitters;a<i.length;a++){if(s=i[a],null!=(l=_r.Get("".concat(r,"/emitters"),this._emitters,s)).refDistance||null!=l.maxDistance||null!=l.rolloffFactor||null!=l.distanceModel||null!=l.innerAngle||null!=l.outerAngle)throw new Error("".concat(r,": Direction or Distance properties are not allowed on emitters attached to a scene"));n.push(this._loadEmitterAsync("".concat(r,"/emitters/").concat(l.index),l))}return[4,Promise.all(n)];case 1:return u.sent(),[2]}})})})},e.prototype.loadNodeAsync=function(e,n,r){var o=this;return yr.LoadExtensionAsync(e,n,this.name,function(e,a){return _(o,void 0,void 0,function(){var o,i,s=this;return g(this,function(l){switch(l.label){case 0:return o=new Array,[4,this._loader.loadNodeAsync(e,n,function(n){for(var i=function(r){var a=_r.Get("".concat(e,"/emitters"),s._emitters,r);o.push(s._loadEmitterAsync("".concat(e,"/emitters/").concat(a.index),a).then(function(){for(var e=0,r=a._babylonSounds;e<r.length;e++){var o=r[e];o.attachToMesh(n),null==a.innerAngle&&null==a.outerAngle||(o.setLocalDirectionToMesh(t.Vector3.Forward()),o.setDirectionalCone(2*t.Tools.ToDegrees(null==a.innerAngle?Math.PI:a.innerAngle),2*t.Tools.ToDegrees(null==a.outerAngle?Math.PI:a.outerAngle),0))}}))},l=0,u=a.emitters;l<u.length;l++)i(u[l]);r(n)})];case 1:return i=l.sent(),[4,Promise.all(o)];case 2:return l.sent(),[2,i]}})})})},e.prototype.loadAnimationAsync=function(e,t){var n=this;return yr.LoadExtensionAsync(e,t,this.name,function(r,o){return _(n,void 0,void 0,function(){var n,a,i,s,l;return g(this,function(u){switch(u.label){case 0:return[4,this._loader.loadAnimationAsync(e,t)];case 1:for(n=u.sent(),a=new Array,_r.Assign(o.events),i=0,s=o.events;i<s.length;i++)l=s[i],a.push(this._loadAnimationEventAsync("".concat(r,"/events/").concat(l.index),e,t,l,n));return[4,Promise.all(a)];case 2:return u.sent(),[2,n]}})})})},e.prototype._loadClipAsync=function(e,n){if(n._objectURL)return n._objectURL;var r;if(n.uri)r=this._loader.loadUriAsync(e,n,n.uri);else{var o=_r.Get("".concat(e,"/bufferView"),this._loader.gltf.bufferViews,n.bufferView);r=this._loader.loadBufferViewAsync("/bufferViews/".concat(o.index),o)}return n._objectURL=r.then(function(e){var r=t.GetBlobBufferSource(e);return URL.createObjectURL(new Blob([r],{type:n.mimeType}))}),n._objectURL},e.prototype._loadEmitterAsync=function(e,n){var r=this;if(n._babylonSounds=n._babylonSounds||[],!n._babylonData){for(var o=new Array,a=n.name||"emitter".concat(n.index),i={loop:!1,autoplay:!1,volume:null==n.volume?1:n.volume},s=function(e){var s="/extensions/".concat(l.name,"/clips"),u=_r.Get(s,l._clips,n.clips[e].clip);o.push(l._loadClipAsync("".concat(s,"/").concat(n.clips[e].clip),u).then(function(o){var s=n._babylonSounds[e]=new t.Sound(a,o,r._loader.babylonScene,null,i);s.refDistance=n.refDistance||1,s.maxDistance=n.maxDistance||256,s.rolloffFactor=n.rolloffFactor||1,s.distanceModel=n.distanceModel||"exponential"}))},l=this,u=0;u<n.clips.length;u++)s(u);var c=Promise.all(o).then(function(){var e=n.clips.map(function(e){return e.weight||1}),r=new t.WeightedSound(n.loop||!1,n._babylonSounds,e);n.innerAngle&&(r.directionalConeInnerAngle=2*t.Tools.ToDegrees(n.innerAngle)),n.outerAngle&&(r.directionalConeOuterAngle=2*t.Tools.ToDegrees(n.outerAngle)),n.volume&&(r.volume=n.volume),n._babylonData.sound=r});n._babylonData={loaded:c}}return n._babylonData.loaded},e.prototype._getEventAction=function(e,t,n,r,o){switch(n){case"play":return function(e){var n=(o||0)+(e-r);t.play(n)};case"stop":return function(){t.stop()};case"pause":return function(){t.pause()};default:throw new Error("".concat(e,": Unsupported action ").concat(n))}},e.prototype._loadAnimationEventAsync=function(e,n,r,o,a){var i=this;if(0==a.targetedAnimations.length)return Promise.resolve();var s=a.targetedAnimations[0],l=o.emitter,u=_r.Get("/extensions/".concat(this.name,"/emitters"),this._emitters,l);return this._loadEmitterAsync(e,u).then(function(){var n=u._babylonData.sound;if(n){var r=new t.AnimationEvent(o.time,i._getEventAction(e,n,o.action,o.time,o.startOffset));s.animation.addEvent(r),a.onAnimationGroupEndObservable.add(function(){n.stop()}),a.onAnimationGroupPauseObservable.add(function(){n.pause()})}})},e}();er(Ja),$n(Ja,!0,function(e){return new $a(e)});var ei={__proto__:null,MSFT_audio_emitter:$a},ti="MSFT_lod",ni=function(){function e(e){var n,r;this.name=ti,this.order=100,this.maxLODsToLoad=10,this.onNodeLODsLoadedObservable=new t.Observable,this.onMaterialLODsLoadedObservable=new t.Observable,this._bufferLODs=new Array,this._nodeIndexLOD=null,this._nodeSignalLODs=new Array,this._nodePromiseLODs=new Array,this._nodeBufferLODs=new Array,this._materialIndexLOD=null,this._materialSignalLODs=new Array,this._materialPromiseLODs=new Array,this._materialBufferLODs=new Array,this._loader=e,this.maxLODsToLoad=null!==(r=null===(n=this._loader.parent.extensionOptions[ti])||void 0===n?void 0:n.maxLODsToLoad)&&void 0!==r?r:this.maxLODsToLoad,this.enabled=this._loader.isExtensionUsed(ti)}return e.prototype.dispose=function(){this._loader=null,this._nodeIndexLOD=null,this._nodeSignalLODs.length=0,this._nodePromiseLODs.length=0,this._nodeBufferLODs.length=0,this._materialIndexLOD=null,this._materialSignalLODs.length=0,this._materialPromiseLODs.length=0,this._materialBufferLODs.length=0,this.onMaterialLODsLoadedObservable.clear(),this.onNodeLODsLoadedObservable.clear()},e.prototype.onReady=function(){for(var e=this,t=function(t){var r=Promise.all(n._nodePromiseLODs[t]).then(function(){0!==t&&(e._loader.endPerformanceCounter("Node LOD ".concat(t)),e._loader.log("Loaded node LOD ".concat(t))),e.onNodeLODsLoadedObservable.notifyObservers(t),t!==e._nodePromiseLODs.length-1&&(e._loader.startPerformanceCounter("Node LOD ".concat(t+1)),e._loadBufferLOD(e._nodeBufferLODs,t+1),e._nodeSignalLODs[t]&&e._nodeSignalLODs[t].resolve())});n._loader._completePromises.push(r)},n=this,r=0;r<this._nodePromiseLODs.length;r++)t(r);var o=function(t){var n=Promise.all(a._materialPromiseLODs[t]).then(function(){0!==t&&(e._loader.endPerformanceCounter("Material LOD ".concat(t)),e._loader.log("Loaded material LOD ".concat(t))),e.onMaterialLODsLoadedObservable.notifyObservers(t),t!==e._materialPromiseLODs.length-1&&(e._loader.startPerformanceCounter("Material LOD ".concat(t+1)),e._loadBufferLOD(e._materialBufferLODs,t+1),e._materialSignalLODs[t]&&e._materialSignalLODs[t].resolve())});a._loader._completePromises.push(n)},a=this;for(r=0;r<this._materialPromiseLODs.length;r++)o(r)},e.prototype.loadSceneAsync=function(e,t){var n=this._loader.loadSceneAsync(e,t);return this._loadBufferLOD(this._bufferLODs,0),n},e.prototype.loadNodeAsync=function(e,n,r){var o=this;return yr.LoadExtensionAsync(e,n,this.name,function(e,a){return _(o,void 0,void 0,function(){var o,i,s,l,u,c=this;return g(this,function(f){switch(f.label){case 0:for(i=this._getLODs(e,n,this._loader.gltf.nodes,a.ids),this._loader.logOpen("".concat(e)),s=function(e){var n=i[e];0!==e&&(l._nodeIndexLOD=e,l._nodeSignalLODs[e]=l._nodeSignalLODs[e]||new t.Deferred);var a=l._loader.loadNodeAsync("/nodes/".concat(n.index),n,function(e){r(e),e.setEnabled(!1)}).then(function(t){if(0!==e){var n=i[e-1];n._babylonTransformNode&&(c._disposeTransformNode(n._babylonTransformNode),delete n._babylonTransformNode)}return t.setEnabled(!0),t});l._nodePromiseLODs[e]=l._nodePromiseLODs[e]||[],0===e?o=a:(l._nodeIndexLOD=null,l._nodePromiseLODs[e].push(a))},l=this,u=0;u<i.length;u++)s(u);return this._loader.logClose(),[4,o];case 1:return[2,f.sent()]}})})})},e.prototype._loadMaterialAsync=function(e,t,n,r,o){var a=this;return this._nodeIndexLOD?null:yr.LoadExtensionAsync(e,t,this.name,function(e,i){return _(a,void 0,void 0,function(){var a,s,l,u,c,f=this;return g(this,function(d){switch(d.label){case 0:for(s=this._getLODs(e,t,this._loader.gltf.materials,i.ids),this._loader.logOpen("".concat(e)),l=function(e){var t=s[e];0!==e&&(u._materialIndexLOD=e);var i=u._loader._loadMaterialAsync("/materials/".concat(t.index),t,n,r,function(t){0===e&&o(t)}).then(function(t){if(0!==e){o(t);var n=s[e-1]._data;n[r]&&(f._disposeMaterials([n[r].babylonMaterial]),delete n[r])}return t});u._materialPromiseLODs[e]=u._materialPromiseLODs[e]||[],0===e?a=i:(u._materialIndexLOD=null,u._materialPromiseLODs[e].push(i))},u=this,c=0;c<s.length;c++)l(c);return this._loader.logClose(),[4,a];case 1:return[2,d.sent()]}})})})},e.prototype._loadUriAsync=function(e,n,r){var o=this;if(null!==this._nodeIndexLOD){this._loader.log("deferred");var a=this._nodeIndexLOD-1;return this._nodeSignalLODs[a]=this._nodeSignalLODs[a]||new t.Deferred,this._nodeSignalLODs[this._nodeIndexLOD-1].promise.then(function(){return _(o,void 0,void 0,function(){return g(this,function(t){switch(t.label){case 0:return[4,this._loader.loadUriAsync(e,n,r)];case 1:return[2,t.sent()]}})})})}return null!==this._materialIndexLOD?(this._loader.log("deferred"),a=this._materialIndexLOD-1,this._materialSignalLODs[a]=this._materialSignalLODs[a]||new t.Deferred,this._materialSignalLODs[a].promise.then(function(){return _(o,void 0,void 0,function(){return g(this,function(t){switch(t.label){case 0:return[4,this._loader.loadUriAsync(e,n,r)];case 1:return[2,t.sent()]}})})})):null},e.prototype.loadBufferAsync=function(e,n,r,o){var a=this;if(this._loader.parent.useRangeRequests&&!n.uri){if(!this._loader.bin)throw new Error("".concat(e,": Uri is missing or the binary glTF is missing its binary chunk"));var i=function(e,n){return _(a,void 0,void 0,function(){var a,i,s;return g(this,function(l){switch(l.label){case 0:return i=(a=r)+o-1,(s=e[n])?(s.start=Math.min(s.start,a),s.end=Math.max(s.end,i)):(s={start:a,end:i,loaded:new t.Deferred},e[n]=s),[4,s.loaded.promise.then(function(e){return new Uint8Array(e.buffer,e.byteOffset+r-s.start,o)})];case 1:return[2,l.sent()]}})})};return this._loader.log("deferred"),null!==this._nodeIndexLOD?i(this._nodeBufferLODs,this._nodeIndexLOD):null!==this._materialIndexLOD?i(this._materialBufferLODs,this._materialIndexLOD):i(this._bufferLODs,0)}return null},e.prototype._loadBufferLOD=function(e,t){var n=e[t];n&&(this._loader.log("Loading buffer range [".concat(n.start,"-").concat(n.end,"]")),this._loader.bin.readAsync(n.start,n.end-n.start+1).then(function(e){n.loaded.resolve(e)},function(e){n.loaded.reject(e)}))},e.prototype._getLODs=function(e,t,n,r){if(this.maxLODsToLoad<=0)throw new Error("maxLODsToLoad must be greater than zero");for(var o=[],a=r.length-1;a>=0;a--)if(o.push(_r.Get("".concat(e,"/ids/").concat(r[a]),n,r[a])),o.length===this.maxLODsToLoad)return o;return o.push(t),o},e.prototype._disposeTransformNode=function(e){var t=this,n=[],r=e.material;r&&n.push(r);for(var o=0,a=e.getChildMeshes();o<a.length;o++){var i=a[o];i.material&&n.push(i.material)}e.dispose();var s=n.filter(function(e){return t._loader.babylonScene.meshes.every(function(t){return t.material!=e})});this._disposeMaterials(s)},e.prototype._disposeMaterials=function(e){for(var t={},n=0,r=e;n<r.length;n++){for(var o=0,a=(c=r[n]).getActiveTextures();o<a.length;o++){var i=a[o];t[i.uniqueId]=i}c.dispose()}for(var s in t)for(var l=0,u=this._loader.babylonScene.materials;l<u.length;l++){var c;(c=u[l]).hasTexture(t[s])&&delete t[s]}for(var s in t)t[s].dispose()},e}();er(ti),$n(ti,!0,function(e){return new ni(e)});var ri={__proto__:null,MSFT_lod:ni},oi="MSFT_minecraftMesh",ai=function(){function e(e){this.name=oi,this._loader=e,this.enabled=this._loader.isExtensionUsed(oi)}return e.prototype.dispose=function(){this._loader=null},e.prototype.loadMaterialPropertiesAsync=function(e,t,n){var r=this;return yr.LoadExtraAsync(e,t,this.name,function(o,a){return _(r,void 0,void 0,function(){var r;return g(this,function(i){switch(i.label){case 0:if(!a)return[3,2];if(!this._loader._pbrMaterialImpls.get("pbr"))throw new Error("".concat(o,": Material type not supported"));return r=this._loader.loadMaterialPropertiesAsync(e,t,n),n.needAlphaBlending()&&(n.forceDepthWrite=!0,n.separateCullingPass=!0),n.backFaceCulling=n.forceDepthWrite,n.twoSidedLighting=!0,[4,r];case 1:return[2,i.sent()];case 2:return[2]}})})})},e}();er(oi),$n(oi,!0,function(e){return new ai(e)});var ii={__proto__:null,MSFT_minecraftMesh:ai},si="MSFT_sRGBFactors",li=function(){function e(e){this.name=si,this._loader=e,this.enabled=this._loader.isExtensionUsed(si)}return e.prototype.dispose=function(){this._loader=null},e.prototype.loadMaterialPropertiesAsync=function(e,t,n){var r=this;return yr.LoadExtraAsync(e,t,this.name,function(o,a){return _(r,void 0,void 0,function(){var r,o,i;return g(this,function(s){switch(s.label){case 0:return a?(r=this._loader._getOrCreateMaterialAdapter(n),o=this._loader.loadMaterialPropertiesAsync(e,t,n),i=n.getScene().getEngine().useExactSrgbConversions,r.baseColorTexture||r.baseColor.toLinearSpaceToRef(r.baseColor,i),r.specularColorTexture||r.specularColor.toLinearSpaceToRef(r.specularColor,i),[4,o]):[3,2];case 1:return[2,s.sent()];case 2:return[2]}})})})},e}();er(si),$n(si,!0,function(e){return new li(e)});var ui={__proto__:null,MSFT_sRGBFactors:li};function ci(e){var t=e.split(":");return fi({op:t[0],extension:t[1]})}function fi(e,n){var r;void 0===n&&(n=!0);var o=e.extension?null===(r=hi[e.extension])||void 0===r?void 0:r[e.op]:pi[e.op];if(!o&&(t.Logger.Warn("No mapping found for operation ".concat(e.op," and extension ").concat(e.extension||"KHR_interactivity")),n)){var a={},i={flows:{}};if(e.inputValueSockets)for(var s in a.values={},e.inputValueSockets)a.values[s]={name:s};return e.outputValueSockets&&(i.values={},Object.keys(e.outputValueSockets).forEach(function(e){i.values[e]={name:e}})),{blocks:[],inputs:a,outputs:i}}return o}function di(e,t,n){hi[t]||(hi[t]={}),hi[t][e]=n}var hi={BABYLON:{"flow/log":{blocks:["FlowGraphConsoleLogBlock"],inputs:{values:{message:{name:"message"}}}}}},pi={"event/onStart":{blocks:["FlowGraphSceneReadyEventBlock"],outputs:{flows:{out:{name:"done"}}}},"event/onTick":{blocks:["FlowGraphSceneTickEventBlock"],inputs:{},outputs:{values:{timeSinceLastTick:{name:"deltaTime",gltfType:"number"}},flows:{out:{name:"done"}}}},"event/send":{blocks:["FlowGraphSendCustomEventBlock"],extraProcessor:function(e,t,n,r,o){var a;if("event/send"!==t.op||!e.configuration||1!==Object.keys(e.configuration).length)throw new Error("Receive event should have a single configuration object, the event itself");var i=null===(a=e.configuration.event.value)||void 0===a?void 0:a[0];if("number"!=typeof i)throw new Error("Event id should be a number");var s=r.arrays.events[i],l=o[0];return l.config||(l.config={}),l.config.eventId=s.eventId,l.config.eventData=s.eventData,o}},"event/receive":{blocks:["FlowGraphReceiveCustomEventBlock"],outputs:{flows:{out:{name:"done"}}},validation:function(e,n){var r,o;if(!e.configuration)return t.Logger.Error("Receive event should have a configuration object"),{valid:!1,error:"Receive event should have a configuration object"};var a=e.configuration.event;if(!a)return t.Logger.Error("Receive event should have a single configuration object, the event itself"),{valid:!1,error:"Receive event should have a single configuration object, the event itself"};var i=null===(r=a.value)||void 0===r?void 0:r[0];return"number"!=typeof i?(t.Logger.Error("Event id should be a number"),{valid:!1,error:"Event id should be a number"}):(null===(o=n.events)||void 0===o?void 0:o[i])?{valid:!0}:(t.Logger.Error("Event with id ".concat(i," not found")),{valid:!1,error:"Event with id ".concat(i," not found")})},extraProcessor:function(e,t,n,r,o){var a;if("event/receive"!==t.op||!e.configuration||1!==Object.keys(e.configuration).length)throw new Error("Receive event should have a single configuration object, the event itself");var i=null===(a=e.configuration.event.value)||void 0===a?void 0:a[0];if("number"!=typeof i)throw new Error("Event id should be a number");var s=r.arrays.events[i],l=o[0];return l.config||(l.config={}),l.config.eventId=s.eventId,l.config.eventData=s.eventData,o}},"math/E":mi("FlowGraphEBlock"),"math/Pi":mi("FlowGraphPIBlock"),"math/Inf":mi("FlowGraphInfBlock"),"math/NaN":mi("FlowGraphNaNBlock"),"math/abs":mi("FlowGraphAbsBlock"),"math/sign":mi("FlowGraphSignBlock"),"math/trunc":mi("FlowGraphTruncBlock"),"math/floor":mi("FlowGraphFloorBlock"),"math/ceil":mi("FlowGraphCeilBlock"),"math/round":{blocks:["FlowGraphRoundBlock"],configuration:{},inputs:{values:{a:{name:"a"}}},outputs:{values:{value:{name:"value"}}},extraProcessor:function(e,t,n,r,o){var a;return(a=o[0]).config||(a.config={}),o[0].config.roundHalfAwayFromZero=!0,o}},"math/fract":mi("FlowGraphFractBlock"),"math/neg":mi("FlowGraphNegationBlock"),"math/add":mi("FlowGraphAddBlock",["a","b"],!0),"math/sub":mi("FlowGraphSubtractBlock",["a","b"],!0),"math/mul":{blocks:["FlowGraphMultiplyBlock"],extraProcessor:function(e,t,n,r,o){var a;(a=o[0]).config||(a.config={}),o[0].config.useMatrixPerComponent=!0,o[0].config.preventIntegerFloatArithmetic=!0;var i=-1;return Object.keys(e.values||{}).find(function(t){var n;return void 0!==(null===(n=e.values)||void 0===n?void 0:n[t].type)&&(i=e.values[t].type,!0)}),-1!==i&&(o[0].config.type=r.arrays.types[i].flowGraphType),o},validation:function(e){return e.values?vi(e):{valid:!0}}},"math/div":mi("FlowGraphDivideBlock",["a","b"],!0),"math/rem":mi("FlowGraphModuloBlock",["a","b"]),"math/min":mi("FlowGraphMinBlock",["a","b"]),"math/max":mi("FlowGraphMaxBlock",["a","b"]),"math/clamp":mi("FlowGraphClampBlock",["a","b","c"]),"math/saturate":mi("FlowGraphSaturateBlock"),"math/mix":mi("FlowGraphMathInterpolationBlock",["a","b","c"]),"math/eq":mi("FlowGraphEqualityBlock",["a","b"]),"math/lt":mi("FlowGraphLessThanBlock",["a","b"]),"math/le":mi("FlowGraphLessThanOrEqualBlock",["a","b"]),"math/gt":mi("FlowGraphGreaterThanBlock",["a","b"]),"math/ge":mi("FlowGraphGreaterThanOrEqualBlock",["a","b"]),"math/isNaN":mi("FlowGraphIsNaNBlock"),"math/isInf":mi("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":mi("FlowGraphSinBlock"),"math/cos":mi("FlowGraphCosBlock"),"math/tan":mi("FlowGraphTanBlock"),"math/asin":mi("FlowGraphASinBlock"),"math/acos":mi("FlowGraphACosBlock"),"math/atan":mi("FlowGraphATanBlock"),"math/atan2":mi("FlowGraphATan2Block",["a","b"]),"math/sinh":mi("FlowGraphSinhBlock"),"math/cosh":mi("FlowGraphCoshBlock"),"math/tanh":mi("FlowGraphTanhBlock"),"math/asinh":mi("FlowGraphASinhBlock"),"math/acosh":mi("FlowGraphACoshBlock"),"math/atanh":mi("FlowGraphATanhBlock"),"math/exp":mi("FlowGraphExponentialBlock"),"math/log":mi("FlowGraphLogBlock"),"math/log2":mi("FlowGraphLog2Block"),"math/log10":mi("FlowGraphLog10Block"),"math/sqrt":mi("FlowGraphSquareRootBlock"),"math/cbrt":mi("FlowGraphCubeRootBlock"),"math/pow":mi("FlowGraphPowerBlock",["a","b"]),"math/length":mi("FlowGraphLengthBlock"),"math/normalize":mi("FlowGraphNormalizeBlock"),"math/dot":mi("FlowGraphDotBlock",["a","b"]),"math/cross":mi("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":mi("FlowGraphTransposeBlock"),"math/determinant":mi("FlowGraphDeterminantBlock"),"math/inverse":mi("FlowGraphInvertMatrixBlock"),"math/matMul":mi("FlowGraphMatrixMultiplicationBlock",["a","b"]),"math/matCompose":{blocks:["FlowGraphMatrixCompose"],inputs:{values:{translation:{name:"position",gltfType:"float3"},rotation:{name:"rotationQuaternion",gltfType:"float4"},scale:{name:"scaling",gltfType:"float3"}}},outputs:{values:{value:{name:"value"}}},extraProcessor:function(e,t,n,r,o,a){var i=o[0].dataInputs.find(function(e){return"rotationQuaternion"===e.name});if(!i)throw new Error("Rotation quaternion input not found");return a._connectionValues[i.uniqueId]&&(a._connectionValues[i.uniqueId].type="Quaternion"),o}},"math/matDecompose":{blocks:["FlowGraphMatrixDecompose"],inputs:{values:{a:{name:"input",gltfType:"number"}}},outputs:{values:{translation:{name:"position"},rotation:{name:"rotationQuaternion"},scale:{name:"scaling"}}}},"math/quatConjugate":mi("FlowGraphConjugateBlock",["a"]),"math/quatMul":{blocks:["FlowGraphMultiplyBlock"],inputs:{values:{a:{name:"a",gltfType:"vector4"},b:{name:"b",gltfType:"vector4"}}},outputs:{values:{value:{name:"value"}}},extraProcessor:function(e,t,n,r,o){var a;return(a=o[0]).config||(a.config={}),o[0].config.type="Quaternion",o}},"math/quatAngleBetween":mi("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":mi("FlowGraphAxisAngleFromQuaternionBlock",["a"]),"math/quatFromDirections":mi("FlowGraphQuaternionFromDirectionsBlock",["a","b"]),"math/combine2x2":{blocks:["FlowGraphCombineMatrix2DBlock"],inputs:{values:{a:{name:"input_0",gltfType:"number"},b:{name:"input_1",gltfType:"number"},c:{name:"input_2",gltfType:"number"},d:{name:"input_3",gltfType:"number"}}},outputs:{values:{value:{name:"value"}}},extraProcessor:function(e,t,n,r,o){var a;return(a=o[0]).config||(a.config={}),o[0].config.inputIsColumnMajor=!0,o}},"math/extract2x2":{blocks:["FlowGraphExtractMatrix2DBlock"],inputs:{values:{a:{name:"input",gltfType:"float2x2"}}},outputs:{values:{0:{name:"output_0"},1:{name:"output_1"},2:{name:"output_2"},3:{name:"output_3"}}}},"math/combine3x3":{blocks:["FlowGraphCombineMatrix3DBlock"],inputs:{values:{a:{name:"input_0",gltfType:"number"},b:{name:"input_1",gltfType:"number"},c:{name:"input_2",gltfType:"number"},d:{name:"input_3",gltfType:"number"},e:{name:"input_4",gltfType:"number"},f:{name:"input_5",gltfType:"number"},g:{name:"input_6",gltfType:"number"},h:{name:"input_7",gltfType:"number"},i:{name:"input_8",gltfType:"number"}}},outputs:{values:{value:{name:"value"}}},extraProcessor:function(e,t,n,r,o){var a;return(a=o[0]).config||(a.config={}),o[0].config.inputIsColumnMajor=!0,o}},"math/extract3x3":{blocks:["FlowGraphExtractMatrix3DBlock"],inputs:{values:{a:{name:"input",gltfType:"float3x3"}}},outputs:{values:{0:{name:"output_0"},1:{name:"output_1"},2:{name:"output_2"},3:{name:"output_3"},4:{name:"output_4"},5:{name:"output_5"},6:{name:"output_6"},7:{name:"output_7"},8:{name:"output_8"}}}},"math/combine4x4":{blocks:["FlowGraphCombineMatrixBlock"],inputs:{values:{a:{name:"input_0",gltfType:"number"},b:{name:"input_1",gltfType:"number"},c:{name:"input_2",gltfType:"number"},d:{name:"input_3",gltfType:"number"},e:{name:"input_4",gltfType:"number"},f:{name:"input_5",gltfType:"number"},g:{name:"input_6",gltfType:"number"},h:{name:"input_7",gltfType:"number"},i:{name:"input_8",gltfType:"number"},j:{name:"input_9",gltfType:"number"},k:{name:"input_10",gltfType:"number"},l:{name:"input_11",gltfType:"number"},m:{name:"input_12",gltfType:"number"},n:{name:"input_13",gltfType:"number"},o:{name:"input_14",gltfType:"number"},p:{name:"input_15",gltfType:"number"}}},outputs:{values:{value:{name:"value"}}},extraProcessor:function(e,t,n,r,o){var a;return(a=o[0]).config||(a.config={}),o[0].config.inputIsColumnMajor=!0,o}},"math/extract4x4":{blocks:["FlowGraphExtractMatrixBlock"],configuration:{},inputs:{values:{a:{name:"input",gltfType:"number"}}},outputs:{values:{0:{name:"output_0"},1:{name:"output_1"},2:{name:"output_2"},3:{name:"output_3"},4:{name:"output_4"},5:{name:"output_5"},6:{name:"output_6"},7:{name:"output_7"},8:{name:"output_8"},9:{name:"output_9"},10:{name:"output_10"},11:{name:"output_11"},12:{name:"output_12"},13:{name:"output_13"},14:{name:"output_14"},15:{name:"output_15"}}}},"math/not":{blocks:["FlowGraphBitwiseNotBlock"],inputs:{values:{a:{name:"a"}}},outputs:{values:{value:{name:"value"}}},extraProcessor:function(e,t,n,r,o,a){var i,s,l;(l=o[0]).config||(l.config={});var u=o[0].dataInputs[0];return o[0].config.valueType=null!==(s=null===(i=a._connectionValues[u.uniqueId])||void 0===i?void 0:i.type)&&void 0!==s?s:"FlowGraphInteger",o}},"math/and":{blocks:["FlowGraphBitwiseAndBlock"],inputs:{values:{a:{name:"a"},b:{name:"b"}}},outputs:{values:{value:{name:"value"}}},extraProcessor:function(e,t,n,r,o,a){var i,s,l,u,c;(c=o[0]).config||(c.config={});var f=o[0].dataInputs[0],d=o[0].dataInputs[1];return o[0].config.valueType=null!==(u=null!==(s=null===(i=a._connectionValues[f.uniqueId])||void 0===i?void 0:i.type)&&void 0!==s?s:null===(l=a._connectionValues[d.uniqueId])||void 0===l?void 0:l.type)&&void 0!==u?u:"FlowGraphInteger",o}},"math/or":{blocks:["FlowGraphBitwiseOrBlock"],inputs:{values:{a:{name:"a"},b:{name:"b"}}},outputs:{values:{value:{name:"value"}}},extraProcessor:function(e,t,n,r,o,a){var i,s,l,u,c;(c=o[0]).config||(c.config={});var f=o[0].dataInputs[0],d=o[0].dataInputs[1];return o[0].config.valueType=null!==(u=null!==(s=null===(i=a._connectionValues[f.uniqueId])||void 0===i?void 0:i.type)&&void 0!==s?s:null===(l=a._connectionValues[d.uniqueId])||void 0===l?void 0:l.type)&&void 0!==u?u:"FlowGraphInteger",o}},"math/xor":{blocks:["FlowGraphBitwiseXorBlock"],inputs:{values:{a:{name:"a"},b:{name:"b"}}},outputs:{values:{value:{name:"value"}}},extraProcessor:function(e,t,n,r,o,a){var i,s,l,u,c;(c=o[0]).config||(c.config={});var f=o[0].dataInputs[0],d=o[0].dataInputs[1];return o[0].config.valueType=null!==(u=null!==(s=null===(i=a._connectionValues[f.uniqueId])||void 0===i?void 0:i.type)&&void 0!==s?s:null===(l=a._connectionValues[d.uniqueId])||void 0===l?void 0:l.type)&&void 0!==u?u:"FlowGraphInteger",o}},"math/asr":mi("FlowGraphBitwiseRightShiftBlock",["a","b"]),"math/lsl":mi("FlowGraphBitwiseLeftShiftBlock",["a","b"]),"math/clz":mi("FlowGraphLeadingZerosBlock"),"math/ctz":mi("FlowGraphTrailingZerosBlock"),"math/popcnt":mi("FlowGraphOneBitsCounterBlock"),"math/rad":mi("FlowGraphDegToRadBlock"),"math/deg":mi("FlowGraphRadToDegBlock"),"type/boolToInt":mi("FlowGraphBooleanToInt"),"type/boolToFloat":mi("FlowGraphBooleanToFloat"),"type/intToBool":mi("FlowGraphIntToBoolean"),"type/intToFloat":mi("FlowGraphIntToFloat"),"type/floatToInt":mi("FlowGraphFloatToInt"),"type/floatToBool":mi("FlowGraphFloatToBoolean"),"flow/sequence":{blocks:["FlowGraphSequenceBlock"],extraProcessor:function(e,t,n,r,o){var a=o[0];return a.config||(a.config={}),a.config.outputSignalCount=Object.keys(e.flows||[]).length,a.signalOutputs.forEach(function(e,t){e.name="out_"+t}),o}},"flow/branch":{blocks:["FlowGraphBranchBlock"],outputs:{flows:{true:{name:"onTrue"},false:{name:"onFalse"}}}},"flow/switch":{blocks:["FlowGraphSwitchBlock"],configuration:{cases:{name:"cases",isArray:!0,inOptions:!0,defaultValue:[]}},inputs:{values:{selection:{name:"case"},default:{name:"default"}}},validation:function(e){var n,r=null===(n=e.configuration)||void 0===n?void 0:n.cases;if(r&&r.value){if(!r.value.every(function(e){return"number"==typeof e&&/^-?\d+$/.test(e.toString())}))return t.Logger.Warn("Switch cases should be integers. Using empty array instead."),r.value=[],{valid:!0};var o=new Set(r.value);r.value=Array.from(o)}return{valid:!0}},extraProcessor:function(e,t,n,r,o){if("flow/switch"!==t.op||!e.flows||0===Object.keys(e.flows).length)throw new Error("Switch should have a single configuration object, the cases array");return o[0].signalOutputs.forEach(function(e){"default"!==e.name&&(e.name="out_"+e.name)}),o}},"flow/while":{blocks:["FlowGraphWhileLoopBlock"],outputs:{flows:{loopBody:{name:"executionFlow"}}}},"flow/for":{blocks:["FlowGraphForLoopBlock"],configuration:{initialIndex:{name:"initialIndex",gltfType:"number",inOptions:!0,defaultValue:0}},inputs:{values:{startIndex:{name:"startIndex",gltfType:"number"},endIndex:{name:"endIndex",gltfType:"number"}}},outputs:{values:{index:{name:"index"}},flows:{loopBody:{name:"executionFlow"}}},extraProcessor:function(e,t,n,r,o){var a=o[0];return a.config||(a.config={}),a.config.incrementIndexWhenLoopDone=!0,o}},"flow/doN":{blocks:["FlowGraphDoNBlock"],configuration:{},inputs:{values:{n:{name:"maxExecutions",gltfType:"number"}}},outputs:{values:{currentCount:{name:"executionCount"}}}},"flow/multiGate":{blocks:["FlowGraphMultiGateBlock"],configuration:{isRandom:{name:"isRandom",gltfType:"boolean",inOptions:!0,defaultValue:!1},isLoop:{name:"isLoop",gltfType:"boolean",inOptions:!0,defaultValue:!1}},extraProcessor:function(e,t,n,r,o){if("flow/multiGate"!==t.op||!e.flows||0===Object.keys(e.flows).length)throw new Error("MultiGate should have a single configuration object, the number of output flows");var a=o[0];return a.config||(a.config={}),a.config.outputSignalCount=Object.keys(e.flows).length,a.signalOutputs.forEach(function(e,t){e.name="out_"+t}),o}},"flow/waitAll":{blocks:["FlowGraphWaitAllBlock"],configuration:{inputFlows:{name:"inputSignalCount",gltfType:"number",inOptions:!0,defaultValue:0}},inputs:{flows:{reset:{name:"reset"},"[segment]":{name:"in_$1"}}},validation:function(e){var t,n,r;return"number"!=typeof(null===(r=null===(n=null===(t=e.configuration)||void 0===t?void 0:t.inputFlows)||void 0===n?void 0:n.value)||void 0===r?void 0:r[0])&&(e.configuration=e.configuration||{inputFlows:{value:[0]}},e.configuration.inputFlows.value=[0]),{valid:!0}}},"flow/throttle":{blocks:["FlowGraphThrottleBlock"],outputs:{flows:{err:{name:"error"}}}},"flow/setDelay":{blocks:["FlowGraphSetDelayBlock"],outputs:{flows:{err:{name:"error"}}}},"flow/cancelDelay":{blocks:["FlowGraphCancelDelayBlock"]},"variable/get":{blocks:["FlowGraphGetVariableBlock"],validation:function(e){var n,r;return(null===(r=null===(n=e.configuration)||void 0===n?void 0:n.variable)||void 0===r?void 0:r.value)?{valid:!0}:(t.Logger.Error("Variable get block should have a variable configuration"),{valid:!1,error:"Variable get block should have a variable configuration"})},configuration:{variable:{name:"variable",gltfType:"number",flowGraphType:"string",inOptions:!0,isVariable:!0,dataTransformer:function(e,t){return t.getVariableName(e)}}}},"variable/set":{blocks:["FlowGraphSetVariableBlock"],configuration:{variables:{name:"variables",gltfType:"number",flowGraphType:"string",inOptions:!0,isArray:!0,dataTransformer:function(e,t){return e.map(function(e){return t.getVariableName(e)})}}},extraProcessor:function(e,t,n,r,o){return o[0].dataInputs.forEach(function(e){e.name=r.getVariableName(+e.name)}),o}},"variable/interpolate":{blocks:["FlowGraphInterpolationBlock","FlowGraphContextBlock","FlowGraphPlayAnimationBlock","FlowGraphBezierCurveEasing","FlowGraphGetVariableBlock"],configuration:{variable:{name:"propertyName",inOptions:!0,isVariable:!0,dataTransformer:function(e,t){return t.getVariableName(e)}},useSlerp:{name:"animationType",inOptions:!0,defaultValue:!1,dataTransformer:function(e){return!0===e?"Quaternion":void 0}}},inputs:{values:{value:{name:"value_1"},duration:{name:"duration_1",gltfType:"number"},p1:{name:"controlPoint1",toBlock:"FlowGraphBezierCurveEasing"},p2:{name:"controlPoint2",toBlock:"FlowGraphBezierCurveEasing"}},flows:{in:{name:"in",toBlock:"FlowGraphPlayAnimationBlock"}}},outputs:{flows:{err:{name:"error",toBlock:"FlowGraphPlayAnimationBlock"},out:{name:"out",toBlock:"FlowGraphPlayAnimationBlock"},done:{name:"done",toBlock:"FlowGraphPlayAnimationBlock"}}},interBlockConnectors:[{input:"object",output:"userVariables",inputBlockIndex:2,outputBlockIndex:1,isVariable:!0},{input:"animation",output:"animation",inputBlockIndex:2,outputBlockIndex:0,isVariable:!0},{input:"easingFunction",output:"easingFunction",inputBlockIndex:0,outputBlockIndex:3,isVariable:!0},{input:"value_0",output:"value",inputBlockIndex:0,outputBlockIndex:4,isVariable:!0}],extraProcessor:function(e,n,r,o,a){var i,s,l,u,c,f,d=a[0],h=null===(s=null===(i=e.configuration)||void 0===i?void 0:i.variable.value)||void 0===s?void 0:s[0];if("number"!=typeof h)throw t.Logger.Error("Variable index is not defined for variable interpolation block"),new Error("Variable index is not defined for variable interpolation block");var p=o.arrays.staticVariables[h];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(p.type));var m=a[4];return m.config||(m.config={}),(f=m.config).variable||(f.variable={}),m.config.variable.value=o.getVariableName(h),a}},"pointer/get":{blocks:["FlowGraphGetPropertyBlock","FlowGraphJsonPointerParserBlock"],configuration:{pointer:{name:"jsonPointer",toBlock:"FlowGraphJsonPointerParserBlock"}},inputs:{values:{"[segment]":{name:"$1",toBlock:"FlowGraphJsonPointerParserBlock"}}},interBlockConnectors:[{input:"object",output:"object",inputBlockIndex:0,outputBlockIndex:1,isVariable:!0},{input:"propertyName",output:"propertyName",inputBlockIndex:0,outputBlockIndex:1,isVariable:!0},{input:"customGetFunction",output:"getFunction",inputBlockIndex:0,outputBlockIndex:1,isVariable:!0}],extraProcessor:function(e,t,n,r,o){return o.forEach(function(e){"FlowGraphJsonPointerParserBlock"===e.className&&(e.config||(e.config={}),e.config.outputValue=!0)}),o}},"pointer/set":{blocks:["FlowGraphSetPropertyBlock","FlowGraphJsonPointerParserBlock"],configuration:{pointer:{name:"jsonPointer",toBlock:"FlowGraphJsonPointerParserBlock"}},inputs:{values:{value:{name:"value"},"[segment]":{name:"$1",toBlock:"FlowGraphJsonPointerParserBlock"}}},outputs:{flows:{err:{name:"error"}}},interBlockConnectors:[{input:"object",output:"object",inputBlockIndex:0,outputBlockIndex:1,isVariable:!0},{input:"propertyName",output:"propertyName",inputBlockIndex:0,outputBlockIndex:1,isVariable:!0},{input:"customSetFunction",output:"setFunction",inputBlockIndex:0,outputBlockIndex:1,isVariable:!0}],extraProcessor:function(e,t,n,r,o){return o.forEach(function(e){"FlowGraphJsonPointerParserBlock"===e.className&&(e.config||(e.config={}),e.config.outputValue=!0)}),o}},"pointer/interpolate":{blocks:["FlowGraphInterpolationBlock","FlowGraphJsonPointerParserBlock","FlowGraphPlayAnimationBlock","FlowGraphBezierCurveEasing"],configuration:{pointer:{name:"jsonPointer",toBlock:"FlowGraphJsonPointerParserBlock"}},inputs:{values:{value:{name:"value_1"},"[segment]":{name:"$1",toBlock:"FlowGraphJsonPointerParserBlock"},duration:{name:"duration_1",gltfType:"number"},p1:{name:"controlPoint1",toBlock:"FlowGraphBezierCurveEasing"},p2:{name:"controlPoint2",toBlock:"FlowGraphBezierCurveEasing"}},flows:{in:{name:"in",toBlock:"FlowGraphPlayAnimationBlock"}}},outputs:{flows:{err:{name:"error",toBlock:"FlowGraphPlayAnimationBlock"},out:{name:"out",toBlock:"FlowGraphPlayAnimationBlock"},done:{name:"done",toBlock:"FlowGraphPlayAnimationBlock"}}},interBlockConnectors:[{input:"object",output:"object",inputBlockIndex:2,outputBlockIndex:1,isVariable:!0},{input:"propertyName",output:"propertyName",inputBlockIndex:0,outputBlockIndex:1,isVariable:!0},{input:"customBuildAnimation",output:"generateAnimationsFunction",inputBlockIndex:0,outputBlockIndex:1,isVariable:!0},{input:"animation",output:"animation",inputBlockIndex:2,outputBlockIndex:0,isVariable:!0},{input:"easingFunction",output:"easingFunction",inputBlockIndex:0,outputBlockIndex:3,isVariable:!0},{input:"value_0",output:"value",inputBlockIndex:0,outputBlockIndex:1,isVariable:!0}],extraProcessor:function(e,t,n,r,o){return o.forEach(function(t){"FlowGraphJsonPointerParserBlock"===t.className?(t.config||(t.config={}),t.config.outputValue=!0):"FlowGraphInterpolationBlock"===t.className&&(t.config||(t.config={}),Object.keys(e.values||[]).forEach(function(n){var o,a=null===(o=e.values)||void 0===o?void 0:o[n];if("value"===n&&a){var i=a.type;void 0!==i&&(t.config.animationType=r.arrays.types[i].flowGraphType)}}))}),o}},"animation/start":{blocks:["FlowGraphPlayAnimationBlock","FlowGraphArrayIndexBlock","KHR_interactivity/FlowGraphGLTFDataProvider"],inputs:{values:{animation:{name:"index",gltfType:"number",toBlock:"FlowGraphArrayIndexBlock"},speed:{name:"speed",gltfType:"number"},startTime:{name:"from",gltfType:"number",dataTransformer:function(e,t){return[e[0]*t._animationTargetFps]}},endTime:{name:"to",gltfType:"number",dataTransformer:function(e,t){return[e[0]*t._animationTargetFps]}}}},outputs:{flows:{err:{name:"error"}}},interBlockConnectors:[{input:"animationGroup",output:"value",inputBlockIndex:0,outputBlockIndex:1,isVariable:!0},{input:"array",output:"animationGroups",inputBlockIndex:1,outputBlockIndex:2,isVariable:!0}],extraProcessor:function(e,t,n,r,o,a,i){var s=o[o.length-1];return s.config||(s.config={}),s.config.glTF=i,o}},"animation/stop":{blocks:["FlowGraphStopAnimationBlock","FlowGraphArrayIndexBlock","KHR_interactivity/FlowGraphGLTFDataProvider"],inputs:{values:{animation:{name:"index",gltfType:"number",toBlock:"FlowGraphArrayIndexBlock"}}},outputs:{flows:{err:{name:"error"}}},interBlockConnectors:[{input:"animationGroup",output:"value",inputBlockIndex:0,outputBlockIndex:1,isVariable:!0},{input:"array",output:"animationGroups",inputBlockIndex:1,outputBlockIndex:2,isVariable:!0}],extraProcessor:function(e,t,n,r,o,a,i){var s=o[o.length-1];return s.config||(s.config={}),s.config.glTF=i,o}},"animation/stopAt":{blocks:["FlowGraphStopAnimationBlock","FlowGraphArrayIndexBlock","KHR_interactivity/FlowGraphGLTFDataProvider"],configuration:{},inputs:{values:{animation:{name:"index",gltfType:"number",toBlock:"FlowGraphArrayIndexBlock"},stopTime:{name:"stopAtFrame",gltfType:"number",dataTransformer:function(e,t){return[e[0]*t._animationTargetFps]}}}},outputs:{flows:{err:{name:"error"}}},interBlockConnectors:[{input:"animationGroup",output:"value",inputBlockIndex:0,outputBlockIndex:1,isVariable:!0},{input:"array",output:"animationGroups",inputBlockIndex:1,outputBlockIndex:2,isVariable:!0}],extraProcessor:function(e,t,n,r,o,a,i){var s=o[o.length-1];return s.config||(s.config={}),s.config.glTF=i,o}},"math/switch":{blocks:["FlowGraphDataSwitchBlock"],configuration:{cases:{name:"cases",isArray:!0,inOptions:!0,defaultValue:[]}},inputs:{values:{selection:{name:"case"}}},validation:function(e){var n,r=null===(n=e.configuration)||void 0===n?void 0:n.cases;if(r&&r.value){if(!r.value.every(function(e){return"number"==typeof e&&/^-?\d+$/.test(e.toString())}))return t.Logger.Warn("Switch cases should be integers. Using empty array instead."),r.value=[],{valid:!0};var o=new Set(r.value);r.value=Array.from(o)}return{valid:!0}},extraProcessor:function(e,t,n,r,o){var a=o[0];return a.dataInputs.forEach(function(e){"default"!==e.name&&"case"!==e.name&&(e.name="in_"+e.name)}),a.config||(a.config={}),a.config.treatCasesAsIntegers=!0,o}},"debug/log":{blocks:["FlowGraphConsoleLogBlock"],configuration:{message:{name:"messageTemplate",inOptions:!0}}}};function mi(e,t,n){return void 0===t&&(t=["a"]),{blocks:[e],inputs:{values:t.reduce(function(e,t){return e[t]={name:t},e},{})},outputs:{values:{value:{name:"value"}}},extraProcessor:function(e,t,r,o,a){var i;if(n){(i=a[0]).config||(i.config={}),a[0].config.preventIntegerFloatArithmetic=!0;var s=-1;Object.keys(e.values||{}).find(function(t){var n;return void 0!==(null===(n=e.values)||void 0===n?void 0:n[t].type)&&(s=e.values[t].type,!0)}),-1!==s&&(a[0].config.type=o.arrays.types[s].flowGraphType)}return a},validation:function(e){return n?vi(e):{valid:!0}}}}function vi(e){if(e.values){var t=Object.keys(e.values).map(function(t){return e.values[t].type}).filter(function(e){return void 0!==e});if(!t.every(function(e){return e===t[0]}))return{valid:!1,error:"All inputs must be of the same type"}}return{valid:!0}}function _i(){return Object.keys(pi)}var gi={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"}},yi=function(){function e(e,t,n){void 0===n&&(n=60),this._interactivityGraph=e,this._gltf=t,this._animationTargetFps=n,this._types=[],this._mappings=[],this._staticVariables=[],this._events=[],this._internalEventsCounter=0,this._nodes=[],this._parseTypes(),this._parseDeclarations(),this._parseVariables(),this._parseEvents(),this._parseNodes()}return Object.defineProperty(e.prototype,"arrays",{get:function(){return{types:this._types,mappings:this._mappings,staticVariables:this._staticVariables,events:this._events,nodes:this._nodes}},enumerable:!1,configurable:!0}),e.prototype._parseTypes=function(){if(this._interactivityGraph.types)for(var e=0,t=this._interactivityGraph.types;e<t.length;e++){var n=t[e];this._types.push(gi[n.signature])}},e.prototype._parseDeclarations=function(){if(this._interactivityGraph.declarations)for(var e=0,n=this._interactivityGraph.declarations;e<n.length;e++){var r=n[e],o=fi(r);if(!o)throw t.Logger.Error(["No mapping found for declaration",r]),new Error("Error parsing declarations");this._mappings.push({flowGraphMapping:o,fullOperationName:r.extension?r.op+":"+r.extension:r.op})}},e.prototype._parseVariables=function(){if(this._interactivityGraph.variables)for(var e=0,t=this._interactivityGraph.variables;e<t.length;e++){var n=t[e],r=this._parseVariable(n);this._staticVariables.push(r)}},e.prototype._parseVariable=function(e,n){var r=this._types[e.type];if(!r)throw t.Logger.Error(["No type found for variable",e]),new Error("Error parsing variables");if(e.value&&e.value.length!==r.length)throw t.Logger.Error(["Invalid value length for variable",e,r]),new Error("Error parsing variables");var o=e.value||[];if(!o.length)switch(r.flowGraphType){case"boolean":o.push(!1);break;case"FlowGraphInteger":o.push(0);break;case"number":o.push(NaN);break;case"Vector2":o.push(NaN,NaN);break;case"Vector3":o.push(NaN,NaN,NaN);break;case"Vector4":case"Matrix2D":case"Quaternion":o.fill(NaN,0,4);break;case"Matrix":o.fill(NaN,0,16);break;case"Matrix3D":o.fill(NaN,0,9)}return"number"===r.elementType&&"string"==typeof o[0]&&(o[0]=parseFloat(o[0])),{type:r.flowGraphType,value:n?n(o,this):o}},e.prototype._parseEvents=function(){var e=this;if(this._interactivityGraph.events)for(var n=function(n){var o={eventId:n.id||"internalEvent_"+r._internalEventsCounter++};n.values&&(o.eventData=Object.keys(n.values).map(function(r){var o,a=null===(o=n.values)||void 0===o?void 0:o[r];if(!a)throw t.Logger.Error(["No value found for event key",r]),new Error("Error parsing events");var i=e._types[a.type];if(!i)throw t.Logger.Error(["No type found for event value",a]),new Error("Error parsing events");var s=void 0!==a.value?e._parseVariable(a):void 0;return{id:r,type:i.flowGraphType,eventData:!0,value:s}})),r._events.push(o)},r=this,o=0,a=this._interactivityGraph.events;o<a.length;o++)n(a[o])},e.prototype._parseNodes=function(){var e;if(this._interactivityGraph.nodes)for(var n=0,r=this._interactivityGraph.nodes;n<r.length;n++){var o=r[n];if("number"!=typeof o.declaration)throw t.Logger.Error(["No declaration found for node",o]),new Error("Error parsing nodes");var a=this._mappings[o.declaration];if(!a)throw t.Logger.Error(["No mapping found for node",o]),new Error("Error parsing nodes");if(a.flowGraphMapping.validation){var i=a.flowGraphMapping.validation(o,this._interactivityGraph,this._gltf);if(!i.valid)throw new Error("Error validating interactivity node ".concat(null===(e=this._interactivityGraph.declarations)||void 0===e?void 0:e[o.declaration].op," - ").concat(i.error))}for(var s=[],l=0,u=a.flowGraphMapping.blocks;l<u.length;l++){var c=u[l],f=this._getEmptyBlock(c,a.fullOperationName);this._parseNodeConfiguration(o,f,a.flowGraphMapping,c),s.push(f)}this._nodes.push({blocks:s,fullOperationName:a.fullOperationName})}},e.prototype._getEmptyBlock=function(e,n){return{uniqueId:t.RandomGUID(),className:e,dataInputs:[],dataOutputs:[],signalInputs:[],signalOutputs:[],config:{},type:n,metadata:{}}},e.prototype._parseNodeConfiguration=function(e,n,r,o){var a,i=e.configuration;if(i)for(var s in i){var l=i[s];if(!l)throw new Error("Error parsing node configuration");var u=null===(a=r.configuration)||void 0===a?void 0:a[s];if(u&&u.toBlock?u.toBlock===o:0===r.blocks.indexOf(o)){var c=null==u?void 0:u.defaultValue;(null==l?void 0:l.value)&&(c=l.value),(null==u?void 0:u.isArray)||(1!==c.length&&t.Logger.Warn("Invalid non-array value length: ".concat(c.length)),c=c[0]),(null==u?void 0:u.dataTransformer)&&(c=u.dataTransformer(c,this)),void 0!==c&&(n.config[(null==u?void 0:u.name)||s]={value:c})}}},e.prototype._parseNodeConnections=function(e){for(var n,r,o,a,i,s,l,u,c,f,d,h,p,m,v,_,g,y,b,x=0;x<this._nodes.length;x++){var T=null===(n=this._interactivityGraph.nodes)||void 0===n?void 0:n[x];if(!T)throw t.Logger.Error(["No node found for interactivity node",this._nodes[x]]),new Error("Error parsing node connections");var A=this._nodes[x],w=this._mappings[T.declaration];if(!w)throw t.Logger.Error(["No mapping found for node",T]),new Error("Error parsing node connections");for(var M=T.flows||{},C=Object.keys(M).sort(),O=function(e){var n=M[e],c=null===(o=null===(r=w.flowGraphMapping.outputs)||void 0===r?void 0:r.flows)||void 0===o?void 0:o[e],f=(null==c?void 0:c.name)||e,d=S._createNewSocketConnection(f,!0);(c&&c.toBlock&&A.blocks.find(function(e){return e.className===c.toBlock})||A.blocks[0]).signalOutputs.push(d);var h=n.node,p=S._nodes[h];if(!p)throw t.Logger.Error(["No node found for input node id",h]),new Error("Error parsing node connections");var m=ci(p.fullOperationName);if(!m)throw t.Logger.Error(["No mapping found for input node",p]),new Error("Error parsing node connections");var v=null===(i=null===(a=m.inputs)||void 0===a?void 0:a.flows)||void 0===i?void 0:i[n.socket||"in"],_=!1;if(!v)for(var g in null===(s=m.inputs)||void 0===s?void 0:s.flows)g.startsWith("[")&&g.endsWith("]")&&(_=!0,v=null===(u=null===(l=m.inputs)||void 0===l?void 0:l.flows)||void 0===u?void 0:u[g]);var y=v?_?v.name.replace("$1",n.socket||""):v.name:n.socket||"in",b=v&&v.toBlock&&p.blocks.find(function(e){return e.className===v.toBlock})||p.blocks[0],x=b.signalInputs.find(function(e){return e.name===y});x||(x=S._createNewSocketConnection(y),b.signalInputs.push(x)),x.connectedPointIds.push(d.uniqueId),d.connectedPointIds.push(x.uniqueId)},S=this,E=0,F=C;E<F.length;E++)O(F[E]);for(var R=T.values||{},L=Object.keys(R),I=function(n){var r=R[n],o=null===(f=null===(c=w.flowGraphMapping.inputs)||void 0===c?void 0:c.values)||void 0===f?void 0:f[n],a=!1;if(!o)for(var i in null===(d=w.flowGraphMapping.inputs)||void 0===d?void 0:d.values)i.startsWith("[")&&i.endsWith("]")&&(a=!0,o=null===(p=null===(h=w.flowGraphMapping.inputs)||void 0===h?void 0:h.values)||void 0===p?void 0:p[i]);var s=o?a?o.name.replace("$1",n):o.name:n,l=P._createNewSocketConnection(s);if((o&&o.toBlock&&A.blocks.find(function(e){return e.className===o.toBlock})||A.blocks[0]).dataInputs.push(l),void 0!==r.value){var u=P._parseVariable(r,o&&o.dataTransformer);e._connectionValues[l.uniqueId]=u}else{if(void 0===r.node)throw t.Logger.Error(["Invalid value for value connection",r]),new Error("Error parsing node connections");var b=r.node,x=r.socket||"value",T=P._nodes[b];if(!T)throw t.Logger.Error(["No node found for output socket reference",r]),new Error("Error parsing node connections");var M=ci(T.fullOperationName);if(!M)throw t.Logger.Error(["No mapping found for output socket reference",r]),new Error("Error parsing node connections");var C=null===(v=null===(m=M.outputs)||void 0===m?void 0:m.values)||void 0===v?void 0:v[x],O=!1;if(!C)for(var i in null===(_=M.outputs)||void 0===_?void 0:_.values)i.startsWith("[")&&i.endsWith("]")&&(O=!0,C=null===(y=null===(g=M.outputs)||void 0===g?void 0:g.values)||void 0===y?void 0:y[i]);var S=C?O?C.name.replace("$1",x):null==C?void 0:C.name:x,E=C&&C.toBlock&&T.blocks.find(function(e){return e.className===C.toBlock})||T.blocks[0],F=E.dataOutputs.find(function(e){return e.name===S});F||(F=P._createNewSocketConnection(S,!0),E.dataOutputs.push(F)),l.connectedPointIds.push(F.uniqueId),F.connectedPointIds.push(l.uniqueId)}},P=this,N=0,B=L;N<B.length;N++)I(B[N]);if(w.flowGraphMapping.interBlockConnectors)for(var k=0,D=w.flowGraphMapping.interBlockConnectors;k<D.length;k++){var G=D[k],V=G.input,H=G.output,U=G.isVariable;this._connectFlowGraphNodes(V,H,A.blocks[G.inputBlockIndex],A.blocks[G.outputBlockIndex],U)}if(w.flowGraphMapping.extraProcessor){var j=null===(b=this._interactivityGraph.declarations)||void 0===b?void 0:b[T.declaration];if(!j)throw t.Logger.Error(["No declaration found for extra processor",T]),new Error("Error parsing node connections");A.blocks=w.flowGraphMapping.extraProcessor(T,j,w.flowGraphMapping,this,A.blocks,e,this._gltf)}}},e.prototype._createNewSocketConnection=function(e,n){return{uniqueId:t.RandomGUID(),name:e,_connectionType:n?1:0,connectedPointIds:[]}},e.prototype._connectFlowGraphNodes=function(e,t,n,r,o){var a=o?n.dataInputs:n.signalInputs,i=o?r.dataOutputs:r.signalOutputs,s=a.find(function(t){return t.name===e})||this._createNewSocketConnection(e),l=i.find(function(e){return e.name===t})||this._createNewSocketConnection(t,!0);a.find(function(t){return t.name===e})||a.push(s),i.find(function(e){return e.name===t})||i.push(l),s.connectedPointIds.push(l.uniqueId),l.connectedPointIds.push(s.uniqueId)},e.prototype.getVariableName=function(e){return"staticVariable_"+e},e.prototype.serializeToFlowGraph=function(){var e={uniqueId:t.RandomGUID(),_userVariables:{},_connectionValues:{}};this._parseNodeConnections(e);for(var n=0;n<this._staticVariables.length;n++){var r=this._staticVariables[n];e._userVariables[this.getVariableName(n)]=r}return{rightHanded:!0,allBlocks:this._nodes.reduce(function(e,t){return e.concat(t.blocks)},[]),executionContexts:[e]}},e}(),bi="KHR_interactivity",xi=function(){function e(e){this._loader=e,this.name=bi,this.enabled=this._loader.isExtensionUsed(bi),this._pathConverter=fr(this._loader.gltf),e._skipStartAnimationStep=!0;var t=e.babylonScene;t&&Ti(t)}return e.prototype.dispose=function(){this._loader=null,delete this._pathConverter},e.prototype.onReady=function(){return _(this,void 0,void 0,function(){var e,n,r,o,a,i=this;return g(this,function(s){switch(s.label){case 0:return this._loader.babylonScene&&this._pathConverter?(e=this._loader.babylonScene,(n=null===(a=this._loader.gltf.extensions)||void 0===a?void 0:a.KHR_interactivity)?((r=new t.FlowGraphCoordinator({scene:e})).dispatchEventsSynchronously=!1,o=n.graphs.map(function(e){return new yi(e,i._loader.gltf,i._loader.parent.targetFps).serializeToFlowGraph()}),[4,Promise.all(o.map(function(e){return _(i,void 0,void 0,function(){return g(this,function(n){switch(n.label){case 0:return[4,t.ParseFlowGraphAsync(e,{coordinator:r,pathConverter:this._pathConverter})];case 1:return[2,n.sent()]}})})}))]):[2]):[2];case 1:return s.sent(),r.start(),[2]}})})},e}();function Ti(e){pr("/extensions/KHR_interactivity/?/activeCamera/rotation",{get:function(){if(!e.activeCamera)return new t.Quaternion(NaN,NaN,NaN,NaN);var n=t.Quaternion.FromRotationMatrix(e.activeCamera.getWorldMatrix()).normalize();return e.useRightHandedSystem||(n.w*=-1,n.x*=-1),n},type:"Quaternion",getTarget:function(){return e.activeCamera}}),pr("/extensions/KHR_interactivity/?/activeCamera/position",{get:function(){if(!e.activeCamera)return new t.Vector3(NaN,NaN,NaN);var n=e.activeCamera.getWorldMatrix().getTranslation();return e.useRightHandedSystem||(n.x*=-1),n},type:"Vector3",getTarget:function(){return e.activeCamera}}),pr("/animations/{}/extensions/KHR_interactivity/isPlaying",{get:function(e){var t,n;return null!==(n=null===(t=e._babylonAnimationGroup)||void 0===t?void 0:t.isPlaying)&&void 0!==n&&n},type:"boolean",getTarget:function(e){return e._babylonAnimationGroup}}),pr("/animations/{}/extensions/KHR_interactivity/minTime",{get:function(e){var t,n;return(null!==(n=null===(t=e._babylonAnimationGroup)||void 0===t?void 0:t.from)&&void 0!==n?n:0)/60},type:"number",getTarget:function(e){return e._babylonAnimationGroup}}),pr("/animations/{}/extensions/KHR_interactivity/maxTime",{get:function(e){var t,n;return(null!==(n=null===(t=e._babylonAnimationGroup)||void 0===t?void 0:t.to)&&void 0!==n?n:0)/60},type:"number",getTarget:function(e){return e._babylonAnimationGroup}}),pr("/animations/{}/extensions/KHR_interactivity/playhead",{get:function(e){var t,n;return(null!==(n=null===(t=e._babylonAnimationGroup)||void 0===t?void 0:t.getCurrentFrame())&&void 0!==n?n:0)/60},type:"number",getTarget:function(e){return e._babylonAnimationGroup}}),pr("/animations/{}/extensions/KHR_interactivity/virtualPlayhead",{get:function(e){var t,n;return(null!==(n=null===(t=e._babylonAnimationGroup)||void 0===t?void 0:t.getCurrentFrame())&&void 0!==n?n:0)/60},type:"number",getTarget:function(e){return e._babylonAnimationGroup}})}t.addToBlockFactory(bi,"FlowGraphGLTFDataProvider",function(){return _(void 0,void 0,void 0,function(){return g(this,function(e){switch(e.label){case 0:return[4,Promise.resolve().then(function(){return Gi})];case 1:return[2,e.sent().FlowGraphGLTFDataProvider]}})})}),er(bi),$n(bi,!0,function(e){return new xi(e)});var Ai={__proto__:null,KHR_interactivity:xi,_AddInteractivityObjectModel:Ti},wi="KHR_node_visibility";pr("/nodes/{}/extensions/KHR_node_visibility/visible",{get:function(e){var t=e._babylonTransformNode;return!t||void 0===t.isVisible||t.isVisible},set:function(e,t){var n,r;null===(n=t._primitiveBabylonMeshes)||void 0===n||n.forEach(function(e){e.inheritVisibility=!0}),t._babylonTransformNode&&(t._babylonTransformNode.isVisible=e),null===(r=t._primitiveBabylonMeshes)||void 0===r||r.forEach(function(t){t.isVisible=e})},getTarget:function(e){return e._babylonTransformNode},getPropertyName:[function(){return"isVisible"}],type:"boolean"});var Mi=function(){function e(e){this.name=wi,this._loader=e,this.enabled=e.isExtensionUsed(wi)}return e.prototype.onReady=function(){if(this._loader){var e=this._loader.gltf.nodes;if(e)for(var t=0,n=e;t<n.length;t++){var r=n[t],o=r._babylonTransformNode;o&&(o.inheritVisibility=!0,r.extensions&&r.extensions.KHR_node_visibility&&!1===r.extensions.KHR_node_visibility.visible&&(o.isVisible=!1))}}},e.prototype.dispose=function(){delete this._loader},e}();er(wi),$n(wi,!0,function(e){return new Mi(e)});var Ci={__proto__:null,KHR_node_visibility:Mi},Oi="KHR_node_selectability";di("event/onSelect",Oi,{blocks:["FlowGraphMeshPickEventBlock","FlowGraphGetVariableBlock","FlowGraphIndexOfBlock","KHR_interactivity/FlowGraphGLTFDataProvider"],configuration:{stopPropagation:{name:"stopPropagation"},nodeIndex:{name:"variable",toBlock:"FlowGraphGetVariableBlock",dataTransformer:function(e){return"pickedMesh_"+e}}},outputs:{values:{selectedNodeIndex:{name:"index",toBlock:"FlowGraphIndexOfBlock"},controllerIndex:{name:"pointerId"},selectionPoint:{name:"pickedPoint"},selectionRayOrigin:{name:"pickOrigin"}},flows:{out:{name:"done"}}},interBlockConnectors:[{input:"asset",output:"value",inputBlockIndex:0,outputBlockIndex:1,isVariable:!0},{input:"array",output:"nodes",inputBlockIndex:2,outputBlockIndex:3,isVariable:!0},{input:"object",output:"pickedMesh",inputBlockIndex:2,outputBlockIndex:0,isVariable:!0}],extraProcessor:function(e,t,n,r,o,a,i){var s,l,u,c,f,d,h,p=o[o.length-1];p.config=p.config||{},p.config.glTF=i;var m=null===(u=null===(l=null===(s=e.configuration)||void 0===s?void 0:s.nodeIndex)||void 0===l?void 0:l.value)||void 0===u?void 0:u[0];if(void 0===m||"number"!=typeof m)throw new Error("nodeIndex not found in configuration");var v="pickedMesh_"+m;return o[1].config.variable=v,a._userVariables[v]={className:"Mesh",id:null===(f=null===(c=null==i?void 0:i.nodes)||void 0===c?void 0:c[m]._babylonTransformNode)||void 0===f?void 0:f.id,uniqueId:null===(h=null===(d=null==i?void 0:i.nodes)||void 0===d?void 0:d[m]._babylonTransformNode)||void 0===h?void 0:h.uniqueId},o}}),pr("/nodes/{}/extensions/KHR_node_selectability/selectable",{get:function(e){var t=e._babylonTransformNode;return!t||void 0===t.isPickable||t.isPickable},set:function(e,t){var n;null===(n=t._primitiveBabylonMeshes)||void 0===n||n.forEach(function(t){t.isPickable=e})},getTarget:function(e){return e._babylonTransformNode},getPropertyName:[function(){return"isPickable"}],type:"boolean"});var Si=function(){function e(e){this.name=Oi,this._loader=e,this.enabled=e.isExtensionUsed(Oi)}return e.prototype.onReady=function(){return _(this,void 0,void 0,function(){var e;return g(this,function(t){return null===(e=this._loader.gltf.nodes)||void 0===e||e.forEach(function(e){var t,n,r;(null===(t=e.extensions)||void 0===t?void 0:t.KHR_node_selectability)&&!1===(null===(n=e.extensions)||void 0===n?void 0:n.KHR_node_selectability.selectable)&&(null===(r=e._babylonTransformNode)||void 0===r||r.getChildMeshes().forEach(function(e){e.isPickable=!1}))}),[2]})})},e.prototype.dispose=function(){this._loader=null},e}();er(Oi),$n(Oi,!0,function(e){return new Si(e)});var Ei={__proto__:null,KHR_node_selectability:Si},Fi="KHR_node_hoverability",Ri="targetMeshPointerOver_";di("event/onHoverIn",Fi,{blocks:["FlowGraphPointerOverEventBlock","FlowGraphGetVariableBlock","FlowGraphIndexOfBlock","KHR_interactivity/FlowGraphGLTFDataProvider"],configuration:{stopPropagation:{name:"stopPropagation"},nodeIndex:{name:"variable",toBlock:"FlowGraphGetVariableBlock",dataTransformer:function(e){return Ri+e}}},outputs:{values:{hoverNodeIndex:{name:"index",toBlock:"FlowGraphIndexOfBlock"},controllerIndex:{name:"pointerId"}},flows:{out:{name:"done"}}},interBlockConnectors:[{input:"targetMesh",output:"value",inputBlockIndex:0,outputBlockIndex:1,isVariable:!0},{input:"array",output:"nodes",inputBlockIndex:2,outputBlockIndex:3,isVariable:!0},{input:"object",output:"meshUnderPointer",inputBlockIndex:2,outputBlockIndex:0,isVariable:!0}],extraProcessor:function(e,t,n,r,o,a,i){var s,l,u,c,f,d,h,p=o[o.length-1];p.config=p.config||{},p.config.glTF=i;var m=null===(u=null===(l=null===(s=e.configuration)||void 0===s?void 0:s.nodeIndex)||void 0===l?void 0:l.value)||void 0===u?void 0:u[0];if(void 0===m||"number"!=typeof m)throw new Error("nodeIndex not found in configuration");var v=Ri+m;return o[1].config.variable=v,a._userVariables[v]={className:"Mesh",id:null===(f=null===(c=null==i?void 0:i.nodes)||void 0===c?void 0:c[m]._babylonTransformNode)||void 0===f?void 0:f.id,uniqueId:null===(h=null===(d=null==i?void 0:i.nodes)||void 0===d?void 0:d[m]._babylonTransformNode)||void 0===h?void 0:h.uniqueId},o}});var Li="targetMeshPointerOut_";di("event/onHoverOut",Fi,{blocks:["FlowGraphPointerOutEventBlock","FlowGraphGetVariableBlock","FlowGraphIndexOfBlock","KHR_interactivity/FlowGraphGLTFDataProvider"],configuration:{stopPropagation:{name:"stopPropagation"},nodeIndex:{name:"variable",toBlock:"FlowGraphGetVariableBlock",dataTransformer:function(e){return Li+e}}},outputs:{values:{hoverNodeIndex:{name:"index",toBlock:"FlowGraphIndexOfBlock"},controllerIndex:{name:"pointerId"}},flows:{out:{name:"done"}}},interBlockConnectors:[{input:"targetMesh",output:"value",inputBlockIndex:0,outputBlockIndex:1,isVariable:!0},{input:"array",output:"nodes",inputBlockIndex:2,outputBlockIndex:3,isVariable:!0},{input:"object",output:"meshOutOfPointer",inputBlockIndex:2,outputBlockIndex:0,isVariable:!0}],extraProcessor:function(e,t,n,r,o,a,i){var s,l,u,c,f,d,h,p=o[o.length-1];p.config=p.config||{},p.config.glTF=i;var m=null===(u=null===(l=null===(s=e.configuration)||void 0===s?void 0:s.nodeIndex)||void 0===l?void 0:l.value)||void 0===u?void 0:u[0];if(void 0===m||"number"!=typeof m)throw new Error("nodeIndex not found in configuration");var v=Li+m;return o[1].config.variable=v,a._userVariables[v]={className:"Mesh",id:null===(f=null===(c=null==i?void 0:i.nodes)||void 0===c?void 0:c[m]._babylonTransformNode)||void 0===f?void 0:f.id,uniqueId:null===(h=null===(d=null==i?void 0:i.nodes)||void 0===d?void 0:d[m]._babylonTransformNode)||void 0===h?void 0:h.uniqueId},o}}),pr("/nodes/{}/extensions/KHR_node_hoverability/hoverable",{get:function(e){var t=e._babylonTransformNode;return!t||void 0===t.pointerOverDisableMeshTesting||t.pointerOverDisableMeshTesting},set:function(e,t){var n;null===(n=t._primitiveBabylonMeshes)||void 0===n||n.forEach(function(t){t.pointerOverDisableMeshTesting=!e})},getTarget:function(e){return e._babylonTransformNode},getPropertyName:[function(){return"pointerOverDisableMeshTesting"}],type:"boolean"});var Ii=function(){function e(e){this.name=Fi,this._loader=e,this.enabled=e.isExtensionUsed(Fi)}return e.prototype.onReady=function(){return _(this,void 0,void 0,function(){var e;return g(this,function(t){return null===(e=this._loader.gltf.nodes)||void 0===e||e.forEach(function(e){var t,n,r;(null===(t=e.extensions)||void 0===t?void 0:t.KHR_node_hoverability)&&!1===(null===(n=e.extensions)||void 0===n?void 0:n.KHR_node_hoverability.hoverable)&&(null===(r=e._babylonTransformNode)||void 0===r||r.getChildMeshes().forEach(function(e){e.pointerOverDisableMeshTesting=!0}))}),[2]})})},e.prototype.dispose=function(){this._loader=null},e}();er(Fi),$n(Fi,!0,function(e){return new Ii(e)});var Pi={__proto__:null,KHR_node_hoverability:Ii},Ni="ExtrasAsMetadata",Bi=function(){function e(e){this.name=Ni,this.enabled=!0,this._loader=e}return e.prototype._assignExtras=function(e,t){if(t.extras&&Object.keys(t.extras).length>0){var n=e.metadata=e.metadata||{};(n.gltf=n.gltf||{}).extras=t.extras}},e.prototype.dispose=function(){this._loader=null},e.prototype.loadNodeAsync=function(e,t,n){var r=this;return this._loader.loadNodeAsync(e,t,function(e){r._assignExtras(e,t),n(e)})},e.prototype.loadCameraAsync=function(e,t,n){var r=this;return this._loader.loadCameraAsync(e,t,function(e){r._assignExtras(e,t),n(e)})},e.prototype.createMaterial=function(e,t,n){var r=this._loader.createMaterial(e,t,n);return this._assignExtras(r,t),r},e.prototype.loadAnimationAsync=function(e,t){var n=this;return this._loader.loadAnimationAsync(e,t).then(function(e){return n._assignExtras(e,t),e})},e}();er(Ni),$n(Ni,!1,function(e){return new Bi(e)});var ki={__proto__:null,ExtrasAsMetadata:Bi},Di=function(e){function n(n){var r,o,a=e.call(this,n)||this,i=n.glTF,s=(null===(r=null==i?void 0:i.animations)||void 0===r?void 0:r.map(function(e){return e._babylonAnimationGroup}))||[];a.animationGroups=a.registerDataOutput("animationGroups",t.RichTypeAny,s);var l=(null===(o=null==i?void 0:i.nodes)||void 0===o?void 0:o.map(function(e){return e._babylonTransformNode}))||[];return a.nodes=a.registerDataOutput("nodes",t.RichTypeAny,l),a}return m(n,e),n.prototype.getClassName=function(){return"FlowGraphGLTFDataProvider"},n}(t.FlowGraphBlock),Gi={__proto__:null,FlowGraphGLTFDataProvider:Di},Vi={__proto__:null,AddObjectAccessorToKey:pr,EXT_lights_area:ro,EXT_lights_ies:Xr,EXT_lights_image_based:Ir,EXT_mesh_gpu_instancing:Br,EXT_meshopt_compression:Gr,EXT_texture_avif:Wr,EXT_texture_webp:Ur,ExtrasAsMetadata:Bi,FlowGraphGLTFDataProvider:Di,GetMappingForKey:dr,GetPathToObjectConverter:fr,InteractivityGraphToFlowGraphParser:yi,KHR_animation_pointer:Qa,KHR_draco_mesh_compression:Zr,KHR_interactivity:xi,KHR_lights:eo,KHR_materials_anisotropy:To,KHR_materials_clearcoat:ho,KHR_materials_coat:vo,KHR_materials_diffuse_roughness:ia,KHR_materials_diffuse_transmission:Xo,KHR_materials_dispersion:ra,KHR_materials_emissive_strength:Mo,KHR_materials_fuzz:Ro,KHR_materials_ior:ko,KHR_materials_iridescence:yo,KHR_materials_pbrSpecularGlossiness:io,KHR_materials_sheen:So,KHR_materials_specular:Po,KHR_materials_transmission:Wo,KHR_materials_unlit:uo,KHR_materials_variants:Vo,KHR_materials_volume:Zo,KHR_materials_volume_scatter:ea,KHR_mesh_quantization:ua,KHR_node_hoverability:Ii,KHR_node_selectability:Si,KHR_node_visibility:Mi,KHR_texture_basisu:da,KHR_texture_transform:ma,KHR_xmp_json_ld:ga,MSFT_audio_emitter:$a,MSFT_lod:ni,MSFT_minecraftMesh:ai,MSFT_sRGBFactors:li,SetInterpolationForKey:hr,TransmissionHelper:Uo,_AddInteractivityObjectModel:Ti,addNewInteractivityFlowGraphMapping:di,ensureTransmissionHelper:jo,getAllSupportedNativeNodeTypes:_i,getMappingForDeclaration:fi,getMappingForFullOperationName:ci,gltfTypeToBabylonType:gi},Hi={__proto__:null,AddObjectAccessorToKey:pr,AnimationPropertyInfo:wr,ArrayItem:_r,EXT_lights_area:ro,EXT_lights_ies:Xr,EXT_lights_image_based:Ir,EXT_mesh_gpu_instancing:Br,EXT_meshopt_compression:Gr,EXT_texture_avif:Wr,EXT_texture_webp:Ur,ExtrasAsMetadata:Bi,FlowGraphGLTFDataProvider:Di,GLTFFileLoader:hn,GLTFLoader:yr,GetMappingForKey:dr,GetPathToObjectConverter:fr,InteractivityGraphToFlowGraphParser:yi,KHR_animation_pointer:Qa,KHR_draco_mesh_compression:Zr,KHR_interactivity:xi,KHR_lights:eo,KHR_materials_anisotropy:To,KHR_materials_clearcoat:ho,KHR_materials_coat:vo,KHR_materials_diffuse_roughness:ia,KHR_materials_diffuse_transmission:Xo,KHR_materials_dispersion:ra,KHR_materials_emissive_strength:Mo,KHR_materials_fuzz:Ro,KHR_materials_ior:ko,KHR_materials_iridescence:yo,KHR_materials_pbrSpecularGlossiness:io,KHR_materials_sheen:So,KHR_materials_specular:Po,KHR_materials_transmission:Wo,KHR_materials_unlit:uo,KHR_materials_variants:Vo,KHR_materials_volume:Zo,KHR_materials_volume_scatter:ea,KHR_mesh_quantization:ua,KHR_node_hoverability:Ii,KHR_node_selectability:Si,KHR_node_visibility:Mi,KHR_texture_basisu:da,KHR_texture_transform:ma,KHR_xmp_json_ld:ga,LoadBoundingInfoFromPositionAccessor:gr,MSFT_audio_emitter:$a,MSFT_lod:ni,MSFT_minecraftMesh:ai,MSFT_sRGBFactors:li,OpenPBRMaterialLoadingAdapter:Sr,PBRMaterialLoadingAdapter:Fr,SetInterpolationForKey:hr,TransformNodeAnimationPropertyInfo:Mr,TransmissionHelper:Uo,WeightAnimationPropertyInfo:Cr,_AddInteractivityObjectModel:Ti,addNewInteractivityFlowGraphMapping:di,ensureTransmissionHelper:jo,getAllSupportedNativeNodeTypes:_i,getMappingForDeclaration:fi,getMappingForFullOperationName:ci,getQuaternion:Tr,getVector3:xr,getWeights:Ar,gltfTypeToBabylonType:gi,registerGLTFExtension:$n,registeredGLTFExtensions:Jn,unregisterGLTFExtension:er},Ui=function(){function e(){this.materials=[]}return e.prototype.parseMTL=function(n,r,o,a){if(!(r instanceof ArrayBuffer)){for(var i,s=r.split("\n"),l=/\s+/,u=null,c=0;c<s.length;c++){var f=s[c].trim();if(0!==f.length&&"#"!==f.charAt(0)){var d=f.indexOf(" "),h=d>=0?f.substring(0,d):f;h=h.toLowerCase();var p=d>=0?f.substring(d+1).trim():"";if("newmtl"===h)u&&this.materials.push(u),n._blockEntityCollection=!!a,(u=new t.StandardMaterial(p,n))._parentContainer=a,n._blockEntityCollection=!1;else if("kd"===h&&u)i=p.split(l,3).map(parseFloat),u.diffuseColor=t.Color3.FromArray(i);else if("ka"===h&&u)i=p.split(l,3).map(parseFloat),u.ambientColor=t.Color3.FromArray(i);else if("ks"===h&&u)i=p.split(l,3).map(parseFloat),u.specularColor=t.Color3.FromArray(i);else if("ke"===h&&u)i=p.split(l,3).map(parseFloat),u.emissiveColor=t.Color3.FromArray(i);else if("ns"===h&&u)u.specularPower=parseFloat(p);else if("d"===h&&u)u.alpha=parseFloat(p);else if("map_ka"===h&&u)u.ambientTexture=e._GetTexture(o,p,n);else if("map_kd"===h&&u)u.diffuseTexture=e._GetTexture(o,p,n);else if("map_ks"===h&&u)u.specularTexture=e._GetTexture(o,p,n);else if("map_ns"===h);else if("map_bump"===h&&u){var m=p.split(l),v=m.indexOf("-bm"),_=null;v>=0&&(_=m[v+1],m.splice(v,2)),u.bumpTexture=e._GetTexture(o,m.join(" "),n),u.bumpTexture&&null!==_&&(u.bumpTexture.level=parseFloat(_))}else"map_d"===h&&u&&(u.opacityTexture=e._GetTexture(o,p,n))}}u&&this.materials.push(u)}},e._GetTexture=function(n,r,o){if(!r)return null;var a=n;if("file:"===n){var i=r.lastIndexOf("\\");-1===i&&(i=r.lastIndexOf("/")),a+=i>-1?r.substring(i+1):r}else a+=r;return new t.Texture(a,o,!1,e.INVERT_TEXTURE_Y)},e.INVERT_TEXTURE_Y=!0,e}(),ji=function(){function e(e,n,r){this._positions=[],this._normals=[],this._uvs=[],this._colors=[],this._extColors=[],this._meshesFromObj=[],this._indicesForBabylon=[],this._wrappedPositionForBabylon=[],this._wrappedUvsForBabylon=[],this._wrappedColorsForBabylon=[],this._wrappedNormalsForBabylon=[],this._tuplePosNorm=[],this._curPositionInIndices=0,this._hasMeshes=!1,this._unwrappedPositionsForBabylon=[],this._unwrappedColorsForBabylon=[],this._unwrappedNormalsForBabylon=[],this._unwrappedUVForBabylon=[],this._triangles=[],this._materialNameFromObj="",this._objMeshName="",this._increment=1,this._isFirstMaterial=!0,this._grayColor=new t.Color4(.5,.5,.5,1),this._hasLineData=!1,this._materialToUse=e,this._babylonMeshesArray=n,this._loadingOptions=r}return e.prototype._isInArray=function(e,t){e[t[0]]||(e[t[0]]={normals:[],idx:[]});var n=e[t[0]].normals.indexOf(t[1]);return-1===n?-1:e[t[0]].idx[n]},e.prototype._isInArrayUV=function(e,t){e[t[0]]||(e[t[0]]={normals:[],idx:[],uv:[]});var n=e[t[0]].normals.indexOf(t[1]);return 1!=n&&t[2]===e[t[0]].uv[n]?e[t[0]].idx[n]:-1},e.prototype._setData=function(e){var t,n,r;null!==(t=e.indiceUvsFromObj)&&void 0!==t||(e.indiceUvsFromObj=-1),null!==(n=e.indiceNormalFromObj)&&void 0!==n||(e.indiceNormalFromObj=-1),-1===(r=this._loadingOptions.optimizeWithUV?this._isInArrayUV(this._tuplePosNorm,[e.indicePositionFromObj,e.indiceNormalFromObj,e.indiceUvsFromObj]):this._isInArray(this._tuplePosNorm,[e.indicePositionFromObj,e.indiceNormalFromObj]))?(this._indicesForBabylon.push(this._wrappedPositionForBabylon.length),this._wrappedPositionForBabylon.push(e.positionVectorFromOBJ),void 0!==e.textureVectorFromOBJ&&this._wrappedUvsForBabylon.push(e.textureVectorFromOBJ),void 0!==e.normalsVectorFromOBJ&&this._wrappedNormalsForBabylon.push(e.normalsVectorFromOBJ),void 0!==e.positionColorsFromOBJ&&this._wrappedColorsForBabylon.push(e.positionColorsFromOBJ),this._tuplePosNorm[e.indicePositionFromObj].normals.push(e.indiceNormalFromObj),this._tuplePosNorm[e.indicePositionFromObj].idx.push(this._curPositionInIndices++),this._loadingOptions.optimizeWithUV&&this._tuplePosNorm[e.indicePositionFromObj].uv.push(e.indiceUvsFromObj)):this._indicesForBabylon.push(r)},e.prototype._unwrapData=function(){try{for(var e=0;e<this._wrappedPositionForBabylon.length;e++)this._unwrappedPositionsForBabylon.push(this._wrappedPositionForBabylon[e].x*this._handednessSign,this._wrappedPositionForBabylon[e].y,this._wrappedPositionForBabylon[e].z),this._wrappedNormalsForBabylon.length&&this._unwrappedNormalsForBabylon.push(this._wrappedNormalsForBabylon[e].x*this._handednessSign,this._wrappedNormalsForBabylon[e].y,this._wrappedNormalsForBabylon[e].z),this._wrappedUvsForBabylon.length&&this._unwrappedUVForBabylon.push(this._wrappedUvsForBabylon[e].x,this._wrappedUvsForBabylon[e].y),this._wrappedColorsForBabylon.length&&this._unwrappedColorsForBabylon.push(this._wrappedColorsForBabylon[e].r,this._wrappedColorsForBabylon[e].g,this._wrappedColorsForBabylon[e].b,this._wrappedColorsForBabylon[e].a);this._wrappedPositionForBabylon.length=0,this._wrappedNormalsForBabylon.length=0,this._wrappedUvsForBabylon.length=0,this._wrappedColorsForBabylon.length=0,this._tuplePosNorm.length=0,this._curPositionInIndices=0}catch(e){throw new Error("Unable to unwrap data while parsing OBJ data.",{cause:e})}},e.prototype._getTriangles=function(e,t){for(var n=t;n<e.length-1;n++)this._pushTriangle(e,n)},e.prototype._getColor=function(e){var t;return this._loadingOptions.importVertexColors?null!==(t=this._extColors[e])&&void 0!==t?t:this._colors[e]:void 0},e.prototype._setDataForCurrentFaceWithPattern1=function(e,t){this._getTriangles(e,t);for(var n=0;n<this._triangles.length;n++){var r=parseInt(this._triangles[n])-1;this._setData({indicePositionFromObj:r,positionVectorFromOBJ:this._positions[r],positionColorsFromOBJ:this._getColor(r)})}this._triangles.length=0},e.prototype._setDataForCurrentFaceWithPattern2=function(e,t){this._getTriangles(e,t);for(var n=0;n<this._triangles.length;n++){var r=this._triangles[n].split("/"),o=parseInt(r[0])-1,a=parseInt(r[1])-1;this._setData({indicePositionFromObj:o,indiceUvsFromObj:a,positionVectorFromOBJ:this._positions[o],textureVectorFromOBJ:this._uvs[a],positionColorsFromOBJ:this._getColor(o)})}this._triangles.length=0},e.prototype._setDataForCurrentFaceWithPattern3=function(e,t){this._getTriangles(e,t);for(var n=0;n<this._triangles.length;n++){var r=this._triangles[n].split("/"),o=parseInt(r[0])-1,a=parseInt(r[1])-1,i=parseInt(r[2])-1;this._setData({indicePositionFromObj:o,indiceUvsFromObj:a,indiceNormalFromObj:i,positionVectorFromOBJ:this._positions[o],textureVectorFromOBJ:this._uvs[a],normalsVectorFromOBJ:this._normals[i]})}this._triangles.length=0},e.prototype._setDataForCurrentFaceWithPattern4=function(e,t){this._getTriangles(e,t);for(var n=0;n<this._triangles.length;n++){var r=this._triangles[n].split("//"),o=parseInt(r[0])-1,a=parseInt(r[1])-1;this._setData({indicePositionFromObj:o,indiceNormalFromObj:a,positionVectorFromOBJ:this._positions[o],normalsVectorFromOBJ:this._normals[a],positionColorsFromOBJ:this._getColor(o)})}this._triangles.length=0},e.prototype._setDataForCurrentFaceWithPattern5=function(e,t){this._getTriangles(e,t);for(var n=0;n<this._triangles.length;n++){var r=this._triangles[n].split("/"),o=this._positions.length+parseInt(r[0]),a=this._uvs.length+parseInt(r[1]),i=this._normals.length+parseInt(r[2]);this._setData({indicePositionFromObj:o,indiceUvsFromObj:a,indiceNormalFromObj:i,positionVectorFromOBJ:this._positions[o],textureVectorFromOBJ:this._uvs[a],normalsVectorFromOBJ:this._normals[i],positionColorsFromOBJ:this._getColor(o)})}this._triangles.length=0},e.prototype._addPreviousObjMesh=function(){this._meshesFromObj.length>0&&(this._handledMesh=this._meshesFromObj[this._meshesFromObj.length-1],this._unwrapData(),this._loadingOptions.useLegacyBehavior&&this._indicesForBabylon.reverse(),this._handledMesh.indices=this._indicesForBabylon.slice(),this._handledMesh.positions=this._unwrappedPositionsForBabylon.slice(),this._unwrappedNormalsForBabylon.length&&(this._handledMesh.normals=this._unwrappedNormalsForBabylon.slice()),this._unwrappedUVForBabylon.length&&(this._handledMesh.uvs=this._unwrappedUVForBabylon.slice()),this._unwrappedColorsForBabylon.length&&(this._handledMesh.colors=this._unwrappedColorsForBabylon.slice()),this._handledMesh.hasLines=this._hasLineData,this._indicesForBabylon.length=0,this._unwrappedPositionsForBabylon.length=0,this._unwrappedColorsForBabylon.length=0,this._unwrappedNormalsForBabylon.length=0,this._unwrappedUVForBabylon.length=0,this._hasLineData=!1)},e.prototype._optimizeNormals=function(e){var n=e.getVerticesData(t.VertexBuffer.PositionKind),r=e.getVerticesData(t.VertexBuffer.NormalKind),o={};if(n&&r){for(var a=0;a<n.length/3;a++)(l=o[s=n[3*a+0]+"_"+n[3*a+1]+"_"+n[3*a+2]])||(l=[],o[s]=l),l.push(a);var i=new t.Vector3;for(var s in o){var l;if(!((l=o[s]).length<2)){var u=l[0];for(a=1;a<l.length;++a){var c=l[a];r[3*u+0]+=r[3*c+0],r[3*u+1]+=r[3*c+1],r[3*u+2]+=r[3*c+2]}for(i.copyFromFloats(r[3*u+0],r[3*u+1],r[3*u+2]),i.normalize(),a=0;a<l.length;++a)r[3*(c=l[a])+0]=i.x,r[3*c+1]=i.y,r[3*c+2]=i.z}}e.setVerticesData(t.VertexBuffer.NormalKind,r)}},e._IsLineElement=function(e){return e.startsWith("l")},e._IsObjectElement=function(e){return e.startsWith("o")},e._IsGroupElement=function(e){return e.startsWith("g")},e._GetZbrushMRGB=function(e,n){if(!e.startsWith("mrgb"))return null;if(e=e.replace("mrgb","").trim(),n)return[];var r=e.match(/[a-z0-9]/g);if(!r||r.length%8!=0)return[];for(var o=[],a=0;a<r.length/8;a++){var i=r[8*a+2]+r[8*a+3],s=r[8*a+4]+r[8*a+5],l=r[8*a+6]+r[8*a+7];o.push(new t.Color4(parseInt(i,16)/255,parseInt(s,16)/255,parseInt(l,16)/255,1))}return o},e.prototype.parse=function(n,r,o,a,i){var s,l,u=this;r=(r=r.replace(/#MRGB/g,"mrgb")).replace(/#.*$/gm,"").trim(),this._loadingOptions.useLegacyBehavior?(this._pushTriangle=function(e,t){return u._triangles.push(e[0],e[t],e[t+1])},this._handednessSign=1):o.useRightHandedSystem?(this._pushTriangle=function(e,t){return u._triangles.push(e[0],e[t+1],e[t])},this._handednessSign=1):(this._pushTriangle=function(e,t){return u._triangles.push(e[0],e[t],e[t+1])},this._handednessSign=-1);var c=r.split("\n"),f=[],d=[];f.push(d);for(var h=0;h<c.length;h++)if(0!==(_=c[h].trim().replace(/\s\s/g," ")).length&&"#"!==_.charAt(0))if((e._IsGroupElement(_)||e._IsObjectElement(_))&&(d=[],f.push(d)),e._IsLineElement(_))for(var p=_.split(" "),m=1;m<p.length-1;m++)d.push("l ".concat(p[m]," ").concat(p[m+1]));else d.push(_);var v=f.flat();for(h=0;h<v.length;h++){var _,g=void 0;if(0!==(_=v[h].trim().replace(/\s\s/g," ")).length&&"#"!==_.charAt(0))if(e.VertexPattern.test(_)){if(g=_.match(/[^ ]+/g),this._positions.push(new t.Vector3(parseFloat(g[1]),parseFloat(g[2]),parseFloat(g[3]))),this._loadingOptions.importVertexColors)if(g.length>=7){var y=parseFloat(g[4]),b=parseFloat(g[5]),x=parseFloat(g[6]);this._colors.push(new t.Color4(y>1?y/255:y,b>1?b/255:b,x>1?x/255:x,7===g.length||void 0===g[7]?1:parseFloat(g[7])))}else this._colors.push(this._grayColor)}else if(null!==(g=e.NormalPattern.exec(_)))this._normals.push(new t.Vector3(parseFloat(g[1]),parseFloat(g[2]),parseFloat(g[3])));else if(null!==(g=e.UVPattern.exec(_)))this._uvs.push(new t.Vector2(parseFloat(g[1])*this._loadingOptions.UVScaling.x,parseFloat(g[2])*this._loadingOptions.UVScaling.y));else if(null!==(g=e.FacePattern3.exec(_)))this._setDataForCurrentFaceWithPattern3(g[1].trim().split(" "),1);else if(null!==(g=e.FacePattern4.exec(_)))this._setDataForCurrentFaceWithPattern4(g[1].trim().split(" "),1);else if(null!==(g=e.FacePattern5.exec(_)))this._setDataForCurrentFaceWithPattern5(g[1].trim().split(" "),1);else if(null!==(g=e.FacePattern2.exec(_)))this._setDataForCurrentFaceWithPattern2(g[1].trim().split(" "),1);else if(null!==(g=e.FacePattern1.exec(_)))this._setDataForCurrentFaceWithPattern1(g[1].trim().split(" "),1);else if(null!==(g=e.LinePattern1.exec(_)))this._setDataForCurrentFaceWithPattern1(g[1].trim().split(" "),0),this._hasLineData=!0;else if(null!==(g=e.LinePattern2.exec(_)))this._setDataForCurrentFaceWithPattern2(g[1].trim().split(" "),0),this._hasLineData=!0;else if(g=e._GetZbrushMRGB(_,!this._loadingOptions.importVertexColors))for(var T=0,A=g;T<A.length;T++){var w=A[T];this._extColors.push(w)}else if(null!==(g=e.LinePattern3.exec(_)))this._setDataForCurrentFaceWithPattern3(g[1].trim().split(" "),0),this._hasLineData=!0;else if(e.GroupDescriptor.test(_)||e.ObjectDescriptor.test(_)){var M={name:_.substring(2).trim(),indices:null,positions:null,normals:null,uvs:null,colors:null,materialName:this._materialNameFromObj,isObject:e.ObjectDescriptor.test(_)};this._addPreviousObjMesh(),this._meshesFromObj.push(M),this._hasMeshes=!0,this._isFirstMaterial=!0,this._increment=1}else e.UseMtlDescriptor.test(_)?(this._materialNameFromObj=_.substring(7).trim(),this._isFirstMaterial&&this._hasMeshes||(this._addPreviousObjMesh(),M={name:(this._objMeshName||"mesh")+"_mm"+this._increment.toString(),indices:null,positions:null,normals:null,uvs:null,colors:null,materialName:this._materialNameFromObj,isObject:!1},this._increment++,this._meshesFromObj.push(M),this._hasMeshes=!0),this._hasMeshes&&this._isFirstMaterial&&(this._meshesFromObj[this._meshesFromObj.length-1].materialName=this._materialNameFromObj,this._isFirstMaterial=!1)):e.MtlLibGroupDescriptor.test(_)?i(_.substring(7).trim()):e.SmoothDescriptor.test(_)||t.Logger.Log("Unhandled expression at line : "+_)}if(this._hasMeshes&&(this._handledMesh=this._meshesFromObj[this._meshesFromObj.length-1],this._loadingOptions.useLegacyBehavior&&this._indicesForBabylon.reverse(),this._unwrapData(),this._handledMesh.indices=this._indicesForBabylon,this._handledMesh.positions=this._unwrappedPositionsForBabylon,this._unwrappedNormalsForBabylon.length&&(this._handledMesh.normals=this._unwrappedNormalsForBabylon),this._unwrappedUVForBabylon.length&&(this._handledMesh.uvs=this._unwrappedUVForBabylon),this._unwrappedColorsForBabylon.length&&(this._handledMesh.colors=this._unwrappedColorsForBabylon),this._handledMesh.hasLines=this._hasLineData),!this._hasMeshes){var C=null;if(this._indicesForBabylon.length)this._loadingOptions.useLegacyBehavior&&this._indicesForBabylon.reverse(),this._unwrapData();else{for(var O=0,S=this._positions;O<S.length;O++){var E=S[O];this._unwrappedPositionsForBabylon.push(E.x,E.y,E.z)}if(this._normals.length)for(var F=0,R=this._normals;F<R.length;F++){var L=R[F];this._unwrappedNormalsForBabylon.push(L.x,L.y,L.z)}if(this._uvs.length)for(var I=0,P=this._uvs;I<P.length;I++){var N=P[I];this._unwrappedUVForBabylon.push(N.x,N.y)}if(this._extColors.length)for(var B=0,k=this._extColors;B<k.length;B++){var D=k[B];this._unwrappedColorsForBabylon.push(D.r,D.g,D.b,D.a)}else if(this._colors.length)for(var G=0,V=this._colors;G<V.length;G++)D=V[G],this._unwrappedColorsForBabylon.push(D.r,D.g,D.b,D.a);this._materialNameFromObj||((C=new t.StandardMaterial(t.Geometry.RandomId(),o)).pointsCloud=!0,this._materialNameFromObj=C.name,this._normals.length||(C.disableLighting=!0,C.emissiveColor=t.Color3.White()))}this._meshesFromObj.push({name:t.Geometry.RandomId(),indices:this._indicesForBabylon,positions:this._unwrappedPositionsForBabylon,colors:this._unwrappedColorsForBabylon,normals:this._unwrappedNormalsForBabylon,uvs:this._unwrappedUVForBabylon,materialName:this._materialNameFromObj,directMaterial:C,isObject:!0,hasLines:this._hasLineData})}for(var H=0;H<this._meshesFromObj.length;H++){if(n&&this._meshesFromObj[H].name)if(n instanceof Array){if(-1===n.indexOf(this._meshesFromObj[H].name))continue}else if(this._meshesFromObj[H].name!==n)continue;this._handledMesh=this._meshesFromObj[H],o._blockEntityCollection=!!a;var U=new t.Mesh(this._meshesFromObj[H].name,o);if(U._parentContainer=a,o._blockEntityCollection=!1,this._handledMesh._babylonMesh=U,!this._handledMesh.isObject)for(var j=H-1;j>=0;--j)if(this._meshesFromObj[j].isObject&&this._meshesFromObj[j]._babylonMesh){U.parent=this._meshesFromObj[j]._babylonMesh;break}if(this._materialToUse.push(this._meshesFromObj[H].materialName),this._handledMesh.hasLines&&(null!==(s=U._internalMetadata)&&void 0!==s||(U._internalMetadata={}),U._internalMetadata._isLine=!0),0!==(null===(l=this._handledMesh.positions)||void 0===l?void 0:l.length)){var K=new t.VertexData;if(K.indices=this._handledMesh.indices,K.positions=this._handledMesh.positions,this._loadingOptions.computeNormals||!this._handledMesh.normals){var W=new Array;t.VertexData.ComputeNormals(this._handledMesh.positions,this._handledMesh.indices,W),K.normals=W}else K.normals=this._handledMesh.normals;this._handledMesh.uvs&&(K.uvs=this._handledMesh.uvs),this._handledMesh.colors&&(K.colors=this._handledMesh.colors),K.applyToMesh(U),this._loadingOptions.invertY&&(U.scaling.y*=-1),this._loadingOptions.optimizeNormals&&this._optimizeNormals(U),this._babylonMeshesArray.push(U),this._handledMesh.directMaterial&&(U.material=this._handledMesh.directMaterial)}else this._babylonMeshesArray.push(U)}},e.ObjectDescriptor=/^o/,e.GroupDescriptor=/^g/,e.MtlLibGroupDescriptor=/^mtllib /,e.UseMtlDescriptor=/^usemtl /,e.SmoothDescriptor=/^s /,e.VertexPattern=/^v(\s+[\d|.|+|\-|e|E]+){3,7}/,e.NormalPattern=/^vn(\s+[\d|.|+|\-|e|E]+)( +[\d|.|+|\-|e|E]+)( +[\d|.|+|\-|e|E]+)/,e.UVPattern=/^vt(\s+[\d|.|+|\-|e|E]+)( +[\d|.|+|\-|e|E]+)/,e.FacePattern1=/^f\s+(([\d]{1,}[\s]?){3,})+/,e.FacePattern2=/^f\s+((([\d]{1,}\/[\d]{1,}[\s]?){3,})+)/,e.FacePattern3=/^f\s+((([\d]{1,}\/[\d]{1,}\/[\d]{1,}[\s]?){3,})+)/,e.FacePattern4=/^f\s+((([\d]{1,}\/\/[\d]{1,}[\s]?){3,})+)/,e.FacePattern5=/^f\s+(((-[\d]{1,}\/-[\d]{1,}\/-[\d]{1,}[\s]?){3,})+)/,e.LinePattern1=/^l\s+(([\d]{1,}[\s]?){2,})+/,e.LinePattern2=/^l\s+((([\d]{1,}\/[\d]{1,}[\s]?){2,})+)/,e.LinePattern3=/^l\s+((([\d]{1,}\/[\d]{1,}\/[\d]{1,}[\s]?){2,})+)/,e}(),Ki={name:"obj",extensions:".obj"},Wi=function(){function e(t){this.name=Ki.name,this.extensions=Ki.extensions,this._assetContainer=null,this._loadingOptions=v(v({},e._DefaultLoadingOptions),null!=t?t:{})}return Object.defineProperty(e,"INVERT_TEXTURE_Y",{get:function(){return Ui.INVERT_TEXTURE_Y},set:function(e){Ui.INVERT_TEXTURE_Y=e},enumerable:!1,configurable:!0}),Object.defineProperty(e,"_DefaultLoadingOptions",{get:function(){return{computeNormals:e.COMPUTE_NORMALS,optimizeNormals:e.OPTIMIZE_NORMALS,importVertexColors:e.IMPORT_VERTEX_COLORS,invertY:e.INVERT_Y,invertTextureY:e.INVERT_TEXTURE_Y,UVScaling:e.UV_SCALING,materialLoadingFailsSilently:e.MATERIAL_LOADING_FAILS_SILENTLY,optimizeWithUV:e.OPTIMIZE_WITH_UV,skipMaterials:e.SKIP_MATERIALS,useLegacyBehavior:e.USE_LEGACY_BEHAVIOR}},enumerable:!1,configurable:!0}),e.prototype._loadMTL=function(e,n,r,o){var a=n+e;t.Tools.LoadFile(a,r,void 0,void 0,!1,function(e,t){o(a,t)})},e.prototype.createPlugin=function(t){return new e(t[Ki.name])},e.prototype.canDirectLoad=function(){return!1},e.prototype.importMeshAsync=function(e,t,n,r){return this._parseSolidAsync(e,t,n,r).then(function(e){return{meshes:e,particleSystems:[],skeletons:[],animationGroups:[],transformNodes:[],geometries:[],lights:[],spriteManagers:[]}})},e.prototype.loadAsync=function(e,t,n){return this.importMeshAsync(null,e,t,n).then(function(){})},e.prototype.loadAssetContainerAsync=function(e,n,r){var o=this,a=new t.AssetContainer(e);return this._assetContainer=a,this.importMeshAsync(null,e,n,r).then(function(e){return e.meshes.forEach(function(e){return a.meshes.push(e)}),e.meshes.forEach(function(e){var t=e.material;t&&-1==a.materials.indexOf(t)&&(a.materials.push(t),t.getActiveTextures().forEach(function(e){-1==a.textures.indexOf(e)&&a.textures.push(e)}))}),o._assetContainer=null,a}).catch(function(e){throw o._assetContainer=null,e})},e.prototype._parseSolidAsync=function(e,n,r,o){var a=this,i="",s=new Ui,l=[],u=[];r=r.replace(/#.*$/gm,"").trim(),new ji(l,u,this._loadingOptions).parse(e,r,n,this._assetContainer,function(e){i=e});var c=[];return""===i||this._loadingOptions.skipMaterials||c.push(new Promise(function(e,r){a._loadMTL(i,o,function(c){try{s.parseMTL(n,c,o,a._assetContainer);for(var f=0;f<s.materials.length;f++){for(var d=0,h=[],p=void 0;(p=l.indexOf(s.materials[f].name,d))>-1;)h.push(p),d=p+1;if(-1===p&&0===h.length)s.materials[f].dispose();else for(var m=0;m<h.length;m++){var v=u[h[m]],_=s.materials[f];v.material=_,v.getTotalIndices()||(_.pointsCloud=!0)}}e()}catch(n){t.Tools.Warn("Error processing MTL file: '".concat(i,"'")),a._loadingOptions.materialLoadingFailsSilently?e():r(n)}},function(n,o){t.Tools.Warn("Error downloading MTL file: '".concat(i,"'")),a._loadingOptions.materialLoadingFailsSilently?e():r(o)})})),Promise.all(c).then(function(){var e=function(e){var t,n;return Boolean(null!==(n=null===(t=e._internalMetadata)||void 0===t?void 0:t._isLine)&&void 0!==n&&n)};return u.forEach(function(r){var o,a;if(e(r)){var i=null!==(o=r.material)&&void 0!==o?o:new t.StandardMaterial(r.name+"_line",n);i.getBindedMeshes().filter(function(t){return!e(t)}).length>0&&(i=null!==(a=i.clone(i.name+"_line"))&&void 0!==a?a:i),i.wireframe=!0,r.material=i,r._internalMetadata&&(r._internalMetadata._isLine=void 0)}}),u})},e.OPTIMIZE_WITH_UV=!0,e.INVERT_Y=!1,e.IMPORT_VERTEX_COLORS=!1,e.COMPUTE_NORMALS=!1,e.OPTIMIZE_NORMALS=!1,e.UV_SCALING=new t.Vector2(1,1),e.SKIP_MATERIALS=!1,e.MATERIAL_LOADING_FAILS_SILENTLY=!0,e.USE_LEGACY_BEHAVIOR=!1,e}();t.RegisterSceneLoaderPlugin(new Wi);var zi={__proto__:null,OBJFileLoader:Wi},qi={__proto__:null,MTLFileLoader:Ui,OBJFileLoader:Wi,SolidParser:ji},Xi={name:"stl",extensions:{".stl":{isBinary:!0}}},Yi=function(){function e(){this.solidPattern=/solid (\S*)([\S\s]*?)endsolid[ ]*(\S*)/g,this.facetsPattern=/facet([\s\S]*?)endfacet/g,this.normalPattern=/normal[\s]+([-+]?[0-9]+\.?[0-9]*([eE][-+]?[0-9]+)?)+[\s]+([-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?)+[\s]+([-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?)+/g,this.vertexPattern=/vertex[\s]+([-+]?[0-9]+\.?[0-9]*([eE][-+]?[0-9]+)?)+[\s]+([-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?)+[\s]+([-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?)+/g,this.name=Xi.name,this.extensions=Xi.extensions}return e.prototype.importMesh=function(e,n,r,o,a){var i;if("string"!=typeof r){if(this._isBinary(r)){var s=new t.Mesh("stlmesh",n);return this._parseBinary(s,r),a&&a.push(s),!0}r=(new TextDecoder).decode(new Uint8Array(r))}for(;i=this.solidPattern.exec(r);){var l=i[1],u=i[3];if(u&&l!=u)return t.Tools.Error("Error in STL, solid name != endsolid name"),!1;if(e&&l)if(e instanceof Array){if(!e.indexOf(l))continue}else if(l!==e)continue;l=l||"stlmesh",s=new t.Mesh(l,n),this._parseASCII(s,i[2]),a&&a.push(s)}return!0},e.prototype.load=function(e,t,n){return this.importMesh(null,e,t,n,null)},e.prototype.loadAssetContainer=function(e,n,r){var o=new t.AssetContainer(e);return e._blockEntityCollection=!0,this.importMesh(null,e,n,r,o.meshes),e._blockEntityCollection=!1,o},e.prototype._isBinary=function(e){var t=new DataView(e);if(t.byteLength<=80)return!1;if(84+50*t.getUint32(80,!0)===t.byteLength)return!0;for(var n=[115,111,108,105,100],r=0;r<5;r++)if(t.getUint8(r)!==n[r])return!0;return!1},e.prototype._parseBinary=function(n,r){for(var o=new DataView(r),a=o.getUint32(80,!0),i=0,s=new Float32Array(3*a*3),l=new Float32Array(3*a*3),u=new Uint32Array(3*a),c=0,f=0;f<a;f++){for(var d=84+50*f,h=o.getFloat32(d,!0),p=o.getFloat32(d+4,!0),m=o.getFloat32(d+8,!0),v=1;v<=3;v++){var _=d+12*v;s[i]=o.getFloat32(_,!0),l[i]=h,e.DO_NOT_ALTER_FILE_COORDINATES?(s[i+1]=o.getFloat32(_+4,!0),s[i+2]=o.getFloat32(_+8,!0),l[i+1]=p,l[i+2]=m):(s[i+2]=o.getFloat32(_+4,!0),s[i+1]=o.getFloat32(_+8,!0),l[i+2]=p,l[i+1]=m),i+=3}e.DO_NOT_ALTER_FILE_COORDINATES?(u[c]=c,u[c+1]=c+2,u[c+2]=c+1,c+=3):(u[c]=c++,u[c]=c++,u[c]=c++)}n.setVerticesData(t.VertexBuffer.PositionKind,s),n.setVerticesData(t.VertexBuffer.NormalKind,l),n.setIndices(u),n.computeWorldMatrix(!0)},e.prototype._parseASCII=function(n,r){for(var o,a=[],i=[],s=[],l=0;o=this.facetsPattern.exec(r);){var u=o[1],c=this.normalPattern.exec(u);if(this.normalPattern.lastIndex=0,c){for(var f=[Number(c[1]),Number(c[5]),Number(c[3])],d=void 0;d=this.vertexPattern.exec(u);)e.DO_NOT_ALTER_FILE_COORDINATES?(a.push(Number(d[1]),Number(d[3]),Number(d[5])),i.push(f[0],f[2],f[1])):(a.push(Number(d[1]),Number(d[5]),Number(d[3])),i.push(f[0],f[1],f[2]));e.DO_NOT_ALTER_FILE_COORDINATES?(s.push(l,l+2,l+1),l+=3):s.push(l++,l++,l++),this.vertexPattern.lastIndex=0}}this.facetsPattern.lastIndex=0,n.setVerticesData(t.VertexBuffer.PositionKind,a),n.setVerticesData(t.VertexBuffer.NormalKind,i),n.setIndices(s),n.computeWorldMatrix(!0)},e.DO_NOT_ALTER_FILE_COORDINATES=!1,e}();t.RegisterSceneLoaderPlugin(new Yi);var Qi={__proto__:null,STLFileLoader:Yi},Zi={__proto__:null,STLFileLoader:Yi},Ji={name:"splat",extensions:{".splat":{isBinary:!0},".ply":{isBinary:!0},".spz":{isBinary:!0},".json":{isBinary:!1},".sog":{isBinary:!0}}},$i=.28209479177387814;function es(e,t,n){return _(this,void 0,void 0,function(){return g(this,function(r){switch(r.label){case 0:return[4,new Promise(function(r,o){var a,i=n.createCanvasImage();if(!i)throw new Error("Failed to create ImageBitmap");if(i.onload=function(){try{var e=n.createCanvas(i.width,i.height);if(!e)throw new Error("Failed to create canvas");var t=e.getContext("2d");if(!t)throw new Error("Failed to get 2D context");t.drawImage(i,0,0);var a=t.getImageData(0,0,e.width,e.height);r({bits:new Uint8Array(a.data.buffer),width:a.width,height:a.height})}catch(e){o("Error loading image ".concat(i.src," with exception: ").concat(e))}},i.onerror=function(e){o("Error loading image ".concat(i.src," with exception: ").concat(e))},i.crossOrigin="anonymous","string"==typeof e){if(!t)throw new Error("filename is required when using a URL");i.src=e+t}else{var s=new Blob([e],{type:"image/webp"});a=URL.createObjectURL(s),i.src=a}})];case 1:return[2,r.sent()]}})})}function ts(e,n,r){return _(this,void 0,void 0,function(){var o,a,i,s,l,u,c,f,d,h,p,m,v,_,y,b,x,T,A,w,M,C,O,S,E,F,R,L,I,P,N,B,k,D,G,V,H,U,j,K,W,z,q,X,Y,Q,Z,J,$,ee,te,ne,re,oe,ae,ie,se,le,ue,ce,fe,de,he;return g(this,function(g){switch(g.label){case 0:if(o=e.count?e.count:e.means.shape[0],a=new ArrayBuffer(32*o),i=new Float32Array(a),s=new Float32Array(a),l=new Uint8ClampedArray(a),u=new Uint8ClampedArray(a),c=function(e){return Math.sign(e)*(Math.exp(Math.abs(e))-1)},f=n[0].bits,d=n[1].bits,!Array.isArray(e.means.mins)||!Array.isArray(e.means.maxs))throw new Error("Missing arrays in SOG data.");for(ee=0;ee<o;ee++)for(M=4*ee,ie=0;ie<3;ie++)h=e.means.mins[ie],p=e.means.maxs[ie],m=d[M+ie],v=f[M+ie],U=m<<8|v,te=t.Scalar.Lerp(h,p,U/65535),i[8*ee+ie]=c(te);if(_=n[2].bits,2===e.version){if(!e.scales.codebook)throw new Error("Missing codebook in SOG version 2 scales data.");for(ee=0;ee<o;ee++)for(M=4*ee,ie=0;ie<3;ie++)b=e.scales.codebook[_[M+ie]],y=Math.exp(b),s[8*ee+3+ie]=y}else{if(!Array.isArray(e.scales.mins)||!Array.isArray(e.scales.maxs))throw new Error("Missing arrays in SOG scales data.");for(ee=0;ee<o;ee++)for(M=4*ee,ie=0;ie<3;ie++)b=_[M+ie],x=t.Scalar.Lerp(e.scales.mins[ie],e.scales.maxs[ie],b/255),T=Math.exp(x),s[8*ee+3+ie]=T}if(A=n[4].bits,2===e.version){if(!e.sh0.codebook)throw new Error("Missing codebook in SOG version 2 sh0 data.");for(ee=0;ee<o;ee++){for(M=4*ee,ie=0;ie<3;ie++)w=.5+e.sh0.codebook[A[M+ie]]*$i,l[32*ee+24+ie]=Math.max(0,Math.min(255,Math.round(255*w)));l[32*ee+24+3]=A[M+3]}}else{if(!Array.isArray(e.sh0.mins)||!Array.isArray(e.sh0.maxs))throw new Error("Missing arrays in SOG sh0 data.");for(ee=0;ee<o;ee++)for(M=4*ee,ie=0;ie<4;ie++)C=e.sh0.mins[ie],O=e.sh0.maxs[ie],S=A[M+ie],D=t.Scalar.Lerp(C,O,S/255),void 0,E=ie<3?.5+D*$i:1/(1+Math.exp(-D)),l[32*ee+24+ie]=Math.max(0,Math.min(255,Math.round(255*E)))}for(F=function(e){return 2*(e/255-.5)/Math.SQRT2},R=n[3].bits,ee=0;ee<o;ee++){switch(L=R[4*ee+0],I=R[4*ee+1],P=R[4*ee+2],N=R[4*ee+3],B=F(L),k=F(I),D=F(P),G=N-252,V=B*B+k*k+D*D,H=Math.sqrt(Math.max(0,1-V)),U=void 0,G){case 0:U=[H,B,k,D];break;case 1:U=[B,H,k,D];break;case 2:U=[B,k,H,D];break;case 3:U=[B,k,D,H];break;default:throw new Error("Invalid quaternion mode")}u[32*ee+28+0]=127.5*U[0]+127.5,u[32*ee+28+1]=127.5*U[1]+127.5,u[32*ee+28+2]=127.5*U[2]+127.5,u[32*ee+28+3]=127.5*U[3]+127.5}if(!e.shN)return[3,2];if(j=e.shN.bands?Math.pow(e.shN.bands+1,2)-1:e.shN.shape[1]/3,K=void 0!==e.shN.bands&&null!==e.shN.bands?e.shN.bands:Math.round(Math.sqrt(j+1)-1),W=n[5].bits,z=n[6].bits,q=n[5].width,X=3*j,Y=Math.ceil(X/16),Q=r.getEngine(),Z=Q.getCaps().maxTextureSize,J=Math.ceil(o/Z),$=t.AllocateShBuffers(Y,J*Z*4*4),2===e.version){if(!e.shN.codebook)throw new Error("Missing codebook in SOG version 2 shN data.");for(ee=0;ee<o;ee++)for(te=z[4*ee+0]+(z[4*ee+1]<<8),ne=te%64*j,re=Math.floor(te/64),se=0;se<j;se++)for(ie=0;ie<3;ie++)le=3*se+ie,ue=Math.floor(le/16),ce=$[ue],fe=le%16,de=16*ee,he=127.5*e.shN.codebook[W[4*(ne+se)+ie+re*q*4]]+127.5,ce[fe+de]=Math.max(0,Math.min(255,he))}else for(ee=0;ee<o;ee++)for(te=z[4*ee+0]+(z[4*ee+1]<<8),ne=te%64*j,re=Math.floor(te/64),oe=e.shN.mins,ae=e.shN.maxs,ie=0;ie<3;ie++)for(se=0;se<j/3;se++)le=3*se+ie,ue=Math.floor(le/16),ce=$[ue],fe=le%16,de=16*ee,he=127.5*t.Scalar.Lerp(oe,ae,W[4*(ne+se)+ie+re*q*4]/255)+127.5,ce[fe+de]=Math.max(0,Math.min(255,he));return[4,new Promise(function(e){e({mode:0,data:a,hasVertexColors:!1,sh:$,shDegree:K})})];case 1:case 3:return[2,g.sent()];case 2:return[4,new Promise(function(e){e({mode:0,data:a,hasVertexColors:!1})})]}})})}function ns(e,t,n){return _(this,void 0,void 0,function(){var r,o,a,i,s,l=this;return g(this,function(u){switch(u.label){case 0:if(e instanceof Map){if(!(a=(o=e).get("meta.json")))throw new Error("meta.json not found in files Map");r=JSON.parse((new TextDecoder).decode(a))}else r=e;return i=y(y(y(y([],r.means.files,!0),r.scales.files,!0),r.quats.files,!0),r.sh0.files,!0),r.shN&&i.push.apply(i,r.shN.files),[4,Promise.all(i.map(function(e){return _(l,void 0,void 0,function(){return g(this,function(r){switch(r.label){case 0:return o&&o.has(e)?[4,es(o.get(e),e,n.getEngine())]:[3,2];case 1:case 3:return[2,r.sent()];case 2:return[4,es(t,e,n.getEngine())]}})})}))];case 1:return s=u.sent(),[4,ts(r,s,n)];case 2:return[2,u.sent()]}})})}function rs(e,n){return function(e,n,r,o){var a=new t.RawTexture(n,r,o,t.Constants.TEXTUREFORMAT_RGBA,e,!1,!1,t.Constants.TEXTURE_NEAREST_SAMPLINGMODE,t.Constants.TEXTURETYPE_UNSIGNED_BYTE);return a.wrapU=t.Constants.TEXTURE_CLAMP_ADDRESSMODE,a.wrapV=t.Constants.TEXTURE_CLAMP_ADDRESSMODE,a}(e,n.bits,n.width,n.height)}function os(e,n,r){return _(this,void 0,void 0,function(){var o,a,i,s,l,u,c,f;return g(this,function(d){switch(d.label){case 0:if(o=r.getEngine(),"function"!=typeof createImageBitmap)return[3,7];d.label=1;case 1:return d.trys.push([1,6,,7]),a=n.toLowerCase().endsWith(".png")?"image/png":"image/webp",i=void 0,"string"!=typeof e?[3,3]:[4,t.Tools.LoadFileAsync(e+n,!0)];case 2:return s=d.sent(),i=new Blob([s],{type:a}),[3,4];case 3:i=new Blob([e],{type:a}),d.label=4;case 4:return[4,createImageBitmap(i,{premultiplyAlpha:"none",colorSpaceConversion:"none"})];case 5:l=d.sent();try{return(u=new t.RawTexture(null,l.width,l.height,t.Constants.TEXTUREFORMAT_RGBA,r,!1,!1,t.Constants.TEXTURE_NEAREST_SAMPLINGMODE,t.Constants.TEXTURETYPE_UNSIGNED_BYTE)).wrapU=t.Constants.TEXTURE_CLAMP_ADDRESSMODE,u.wrapV=t.Constants.TEXTURE_CLAMP_ADDRESSMODE,(c=u.getInternalTexture())&&o.updateDynamicTexture(c,l,!1,!1),[2,u]}finally{l.close()}return[3,7];case 6:return d.sent(),[3,7];case 7:return[4,es(e,n,o)];case 8:return f=d.sent(),[2,rs(r,f)]}})})}function as(e,n,r,o){var a=function(e){return Math.sign(e)*(Math.exp(Math.abs(e))-1)};if(!Array.isArray(e.means.mins)||!Array.isArray(e.means.maxs))throw new Error("Missing arrays in SOG data.");for(var i=new Float32Array(4*o),s=0;s<o;s++){for(var l=4*s,u=0;u<3;u++){var c=r[l+u]<<8|n[l+u],f=t.Scalar.Lerp(e.means.mins[u],e.means.maxs[u],c/65535);i[4*s+u]=a(f)}i[4*s+3]=1}return i}function is(e,n,r){return _(this,arguments,void 0,function(e,n,r,o){var a,i,s,l,u,c,f,d,h,p,m,v,b,x,T,A,w,M,C,O,S,E,F,R,L,I,P,N,B,k,D,G,V,H,U,j,K,W,z,q,X=this;return void 0===o&&(o=!0),g(this,function(Y){switch(Y.label){case 0:if(e instanceof Map){if(!(s=(i=e).get("meta.json")))throw new Error("meta.json not found in files Map");a=JSON.parse((new TextDecoder).decode(s))}else a=e;return l=function(e){return _(X,void 0,void 0,function(){return g(this,function(t){switch(t.label){case 0:return i&&i.has(e)?[4,es(i.get(e),e,r.getEngine())]:[3,2];case 1:case 3:return[2,t.sent()];case 2:return[4,es(n,e,r.getEngine())]}})})},u=function(e){return _(X,void 0,void 0,function(){return g(this,function(t){switch(t.label){case 0:return i&&i.has(e)?[4,os(i.get(e),e,r)]:[3,2];case 1:case 3:return[2,t.sent()];case 2:return[4,os(n,e,r)]}})})},c=y(y(y(y([],a.scales.files,!0),a.quats.files,!0),a.sh0.files,!0),null!==(U=null===(H=a.shN)||void 0===H?void 0:H.files)&&void 0!==U?U:[],!0),m=null,o?[4,Promise.all([Promise.all(a.means.files.map(l)),Promise.all(c.map(u))])]:[3,2];case 1:return b=Y.sent(),x=b[0],w=b[1],m=[x[0],x[1]],v=w,f=rs(r,x[0]),d=rs(r,x[1]),h=x[0].width,p=x[0].height,[3,4];case 2:return[4,Promise.all([Promise.all(a.means.files.map(u)),Promise.all(c.map(u))])];case 3:T=Y.sent(),A=T[0],w=T[1],v=w,f=A[0],d=A[1],M=f.getSize(),h=M.width,p=M.height,Y.label=4;case 4:if(C=null!==(j=a.count)&&void 0!==j?j:a.means.shape[0],(O=h*p)<C)throw new Error("SOG texture contains ".concat(O," texels, but metadata references ").concat(C," splats."));return S=v[0],E=v[1],F=v[2],I=0,P=0,a.shN&&v.length>=5&&(R=v[3],L=v[4],I=a.shN.bands?Math.pow(a.shN.bands+1,2)-1:a.shN.shape[1]/3,P=null!==(K=a.shN.bands)&&void 0!==K?K:Math.round(Math.sqrt(I+1)-1)),2===a.version&&(B=256,k=new Float32Array(768),a.scales.codebook&&k.set(a.scales.codebook.slice(0,B),0),a.sh0.codebook&&k.set(a.sh0.codebook.slice(0,B),B),(null===(W=a.shN)||void 0===W?void 0:W.codebook)&&k.set(a.shN.codebook.slice(0,B),512),(N=new t.RawTexture(k,768,1,t.Constants.TEXTUREFORMAT_R,r,!1,!1,t.Constants.TEXTURE_NEAREST_SAMPLINGMODE,t.Constants.TEXTURETYPE_FLOAT)).wrapU=t.Constants.TEXTURE_CLAMP_ADDRESSMODE,N.wrapV=t.Constants.TEXTURE_CLAMP_ADDRESSMODE),D=a.means.mins,G=a.means.maxs,V={version:2===a.version?2:1,splatCount:C,shDegree:P,meansTextureL:f,meansTextureU:d,scalesTexture:S,quatsTexture:E,sh0Texture:F,shCentroidsTexture:R,shLabelsTexture:L,codebookTexture:N,meansMin:[D[0],D[1],D[2]],meansMax:[G[0],G[1],G[2]],scalesMin:Array.isArray(a.scales.mins)?[a.scales.mins[0],a.scales.mins[1],a.scales.mins[2]]:void 0,scalesMax:Array.isArray(a.scales.maxs)?[a.scales.maxs[0],a.scales.maxs[1],a.scales.maxs[2]]:void 0,sh0Min:Array.isArray(a.sh0.mins)?[a.sh0.mins[0],a.sh0.mins[1],a.sh0.mins[2],a.sh0.mins[3]]:void 0,sh0Max:Array.isArray(a.sh0.maxs)?[a.sh0.maxs[0],a.sh0.maxs[1],a.sh0.maxs[2],a.sh0.maxs[3]]:void 0,shnMin:"number"==typeof(null===(z=a.shN)||void 0===z?void 0:z.mins)?a.shN.mins:void 0,shnMax:"number"==typeof(null===(q=a.shN)||void 0===q?void 0:q.maxs)?a.shN.maxs:void 0,shCoeffCount:I,positions:m?as(a,m[0].bits,m[1].bits,C):new Float32Array(0)},[2,{mode:0,data:new ArrayBuffer(0),hasVertexColors:!1,shDegree:P,sogTextures:V}]}})})}var ss=function(){function e(e,n){this._disposed=!1,this._readFbo=null,this._scene=e,this._shaderLanguage=e.getEngine().isWebGPU?1:0,this._textureSize=Math.max(1,Math.ceil(Math.sqrt(Math.max(1,n)))),this._mrt=new t.MultiRenderTarget("gsWorkBuffer",{width:this._textureSize,height:this._textureSize},4,e,{types:[t.Constants.TEXTURETYPE_FLOAT,t.Constants.TEXTURETYPE_FLOAT,t.Constants.TEXTURETYPE_FLOAT,t.Constants.TEXTURETYPE_UNSIGNED_BYTE],samplingModes:[t.Constants.TEXTURE_NEAREST_SAMPLINGMODE,t.Constants.TEXTURE_NEAREST_SAMPLINGMODE,t.Constants.TEXTURE_NEAREST_SAMPLINGMODE,t.Constants.TEXTURE_NEAREST_SAMPLINGMODE],formats:[t.Constants.TEXTUREFORMAT_RGBA,t.Constants.TEXTUREFORMAT_RGBA,t.Constants.TEXTUREFORMAT_RGBA,t.Constants.TEXTUREFORMAT_RGBA],generateDepthBuffer:!1,generateDepthTexture:!1,generateMipMaps:!1},["gsWorkCenters","gsWorkCovA","gsWorkCovB","gsWorkColors"]),this._mrt.clearColor=new t.Color4(0,0,0,0),this._mrt.renderList=[],this._mrt.onClearObservable.add(function(){}),this._material=this._createMaterial(),this._quad=this._createQuad(),this._quad.material=this._material}return Object.defineProperty(e.prototype,"supportsAsyncCentersReadback",{get:function(){var e,t=this._scene.getEngine();if(t.isWebGPU)return!0;var n=t;return!!n._gl&&"function"==typeof n._readPixelsAsync&&(null!==(e=n.webGLVersion)&&void 0!==e?e:0)>=2},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"textureSize",{get:function(){return this._textureSize},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"textures",{get:function(){return this._mrt.textures},enumerable:!1,configurable:!0}),e.prototype.decodeAsync=function(e,t){return _(this,void 0,void 0,function(){var n=this;return g(this,function(r){switch(r.label){case 0:return this._disposed?[2]:(this._applyPack(e,t),[4,new Promise(function(e){var t=function(){n._disposed?e():n._material.isReady(n._quad)?(n._mrt.renderList=[n._quad],n._mrt.render(),e()):n._scene.onBeforeRenderObservable.addOnce(t)};n._scene.onBeforeRenderObservable.addOnce(t)})]);case 1:return r.sent(),[2]}})})},e.prototype.readCentersRangeAsync=function(e,t){return _(this,void 0,void 0,function(){var n,r,o,a,i,s,l,u,c,f,d,h,p,m,v,_,y,b;return g(this,function(g){switch(g.label){case 0:return this._disposed||t<=0||!this.supportsAsyncCentersReadback?[2,null]:(n=this._textureSize,r=Math.floor(e/n),o=Math.ceil((e+t)/n),a=o-r,s=(i=4*(e-r*n))+4*t,l=this._mrt.textures[0],(u=this._scene.getEngine()).isWebGPU?[4,l.readPixels(0,0,null,!0,!0,0,r,n,a)]:[3,2]);case 1:return c=g.sent(),this._disposed||!c?[2,null]:[2,(f=c instanceof Float32Array?c:new Float32Array(c.buffer,c.byteOffset,c.byteLength/4)).length>=s?f.subarray(i,s):null];case 2:return h=(d=u)._gl,(p=null===(b=null===(y=l.getInternalTexture())||void 0===y?void 0:y._hardwareTexture)||void 0===b?void 0:b.underlyingResource)?(m=new Float32Array(n*a*4),this._readFbo||(this._readFbo=h.createFramebuffer()),v=d._currentFramebuffer,h.bindFramebuffer(h.FRAMEBUFFER,this._readFbo),h.framebufferTexture2D(h.FRAMEBUFFER,h.COLOR_ATTACHMENT0,h.TEXTURE_2D,p,0),h.readBuffer(h.COLOR_ATTACHMENT0),_=d._readPixelsAsync(0,r,n,a,h.RGBA,h.FLOAT,m),h.bindFramebuffer(h.FRAMEBUFFER,v),v||h.readBuffer(h.BACK),_?[4,_]:[2,null]):[2,null];case 3:return g.sent(),this._disposed||m.length<s?[2,null]:[2,m.subarray(i,s)]}})})},e.prototype.dispose=function(){var e;this._disposed=!0,this._readFbo&&(null===(e=this._scene.getEngine()._gl)||void 0===e||e.deleteFramebuffer(this._readFbo),this._readFbo=null),this._quad.dispose(),this._material.dispose(!0,!1),this._mrt.dispose()},e.prototype._createQuad=function(){var e=new t.Mesh("gsWorkBufferQuad",this._scene),n=new t.VertexData;return n.positions=[-1,-1,0,3,-1,0,-1,3,0],n.indices=[0,1,2],n.applyToMesh(e),this._scene.removeMesh(e),e},e.prototype._createMaterial=function(){var e=1===this._shaderLanguage,n=new t.ShaderMaterial("gsSogDecode",this._scene,{vertexSource:e?"\nattribute position : vec3<f32>;\n@vertex\nfn main(input : VertexInputs) -> FragmentInputs {\n vertexOutputs.position = vec4<f32>(input.position.xy, 0.0, 1.0);\n}\n":"precision highp float;\nattribute vec3 position;\nvoid main() {\n gl_Position = vec4(position.xy, 0.0, 1.0);\n}\n",fragmentSource:e?"\nvar sogMeansLTexSampler : sampler;\nvar sogMeansLTex : texture_2d<f32>;\nvar sogMeansUTexSampler : sampler;\nvar sogMeansUTex : texture_2d<f32>;\nvar sogScalesTexSampler : sampler;\nvar sogScalesTex : texture_2d<f32>;\nvar sogQuatsTexSampler : sampler;\nvar sogQuatsTex : texture_2d<f32>;\nvar sogSh0TexSampler : sampler;\nvar sogSh0Tex : texture_2d<f32>;\nvar sogCodebookTexSampler : sampler;\nvar sogCodebookTex : texture_2d<f32>;\n\nuniform sogMeansMin : vec3<f32>;\nuniform sogMeansMax : vec3<f32>;\nuniform sogScalesMin : vec3<f32>;\nuniform sogScalesMax : vec3<f32>;\nuniform sogSh0Min : vec4<f32>;\nuniform sogSh0Max : vec4<f32>;\nuniform uVersion : i32;\nuniform uOffset : i32;\nuniform uCount : i32;\nuniform uDestWidth : i32;\nuniform uSrcWidth : i32;\n\n@fragment\nfn main(input : FragmentInputs) -> FragmentOutputs {\n let p : vec2<i32> = vec2<i32>(i32(fragmentInputs.position.x), i32(fragmentInputs.position.y));\n let global : i32 = p.y * uniforms.uDestWidth + p.x;\n if (global < uniforms.uOffset || global >= uniforms.uOffset + uniforms.uCount) {\n discard;\n }\n let k : i32 = global - uniforms.uOffset;\n let src : vec2<i32> = vec2<i32>(k - (k / uniforms.uSrcWidth) * uniforms.uSrcWidth, k / uniforms.uSrcWidth);\n\n let mL : vec3<f32> = textureLoad(sogMeansLTex, src, 0).xyz;\n let mU : vec3<f32> = textureLoad(sogMeansUTex, src, 0).xyz;\n let sRaw : vec3<f32> = textureLoad(sogScalesTex, src, 0).xyz;\n let qRaw : vec4<f32> = textureLoad(sogQuatsTex, src, 0);\n let c0 : vec4<f32> = textureLoad(sogSh0Tex, src, 0);\n\n let q16 : vec3<f32> = (mU * 256.0 + mL) * (255.0 / 65535.0);\n let nPos : vec3<f32> = mix(uniforms.sogMeansMin, uniforms.sogMeansMax, q16);\n let center : vec3<f32> = sign(nPos) * (exp(abs(nPos)) - vec3<f32>(1.0));\n\n var splatScale : vec3<f32>;\n if (uniforms.uVersion == 2) {\n let sIdx : vec3<f32> = floor(sRaw * 255.0 + 0.5);\n splatScale.x = exp(textureLoad(sogCodebookTex, vec2<i32>(i32(sIdx.x), 0), 0).r);\n splatScale.y = exp(textureLoad(sogCodebookTex, vec2<i32>(i32(sIdx.y), 0), 0).r);\n splatScale.z = exp(textureLoad(sogCodebookTex, vec2<i32>(i32(sIdx.z), 0), 0).r);\n } else {\n splatScale = exp(mix(uniforms.sogScalesMin, uniforms.sogScalesMax, sRaw));\n }\n\n let invSqrt2 : f32 = 0.70710678118;\n let qabc : vec3<f32> = (qRaw.xyz - vec3<f32>(0.5)) * 2.0 * invSqrt2;\n let qMode : i32 = i32(qRaw.w * 255.0 + 0.5) - 252;\n let qd : f32 = sqrt(max(0.0, 1.0 - dot(qabc, qabc)));\n var quat : vec4<f32>;\n if (qMode == 0) {\n quat = vec4<f32>(qd, qabc.x, qabc.y, qabc.z);\n } else if (qMode == 1) {\n quat = vec4<f32>(qabc.x, qd, qabc.y, qabc.z);\n } else if (qMode == 2) {\n quat = vec4<f32>(qabc.x, qabc.y, qd, qabc.z);\n } else {\n quat = vec4<f32>(qabc.x, qabc.y, qabc.z, qd);\n }\n\n let qw : f32 = quat.x;\n let qx : f32 = quat.y;\n let qy : f32 = quat.z;\n let qz : f32 = quat.w;\n let R : mat3x3<f32> = mat3x3<f32>(\n 1.0 - 2.0 * (qy * qy + qz * qz), 2.0 * (qx * qy + qw * qz), 2.0 * (qx * qz - qw * qy),\n 2.0 * (qx * qy - qw * qz), 1.0 - 2.0 * (qx * qx + qz * qz), 2.0 * (qy * qz + qw * qx),\n 2.0 * (qx * qz + qw * qy), 2.0 * (qy * qz - qw * qx), 1.0 - 2.0 * (qx * qx + qy * qy)\n );\n let S2 : mat3x3<f32> = mat3x3<f32>(\n 4.0 * splatScale.x * splatScale.x, 0.0, 0.0,\n 0.0, 4.0 * splatScale.y * splatScale.y, 0.0,\n 0.0, 0.0, 4.0 * splatScale.z * splatScale.z\n );\n let Sigma : mat3x3<f32> = R * S2 * transpose(R);\n\n let SH_C0 : f32 = 0.28209479177387814;\n var colRgb : vec3<f32>;\n var colA : f32;\n if (uniforms.uVersion == 2) {\n var c3 : vec3<f32>;\n c3.x = textureLoad(sogCodebookTex, vec2<i32>(256 + i32(c0.x * 255.0 + 0.5), 0), 0).r;\n c3.y = textureLoad(sogCodebookTex, vec2<i32>(256 + i32(c0.y * 255.0 + 0.5), 0), 0).r;\n c3.z = textureLoad(sogCodebookTex, vec2<i32>(256 + i32(c0.z * 255.0 + 0.5), 0), 0).r;\n colRgb = vec3<f32>(0.5) + c3 * SH_C0;\n colA = c0.w;\n } else {\n let cLerp : vec4<f32> = mix(uniforms.sogSh0Min, uniforms.sogSh0Max, c0);\n colRgb = vec3<f32>(0.5) + cLerp.xyz * SH_C0;\n colA = 1.0 / (1.0 + exp(-cLerp.w));\n }\n\n fragmentOutputs.fragData0 = vec4<f32>(center, 1.0);\n fragmentOutputs.fragData1 = vec4<f32>(Sigma[0][0], Sigma[0][1], Sigma[0][2], Sigma[1][1]);\n fragmentOutputs.fragData2 = vec4<f32>(Sigma[1][2], Sigma[2][2], 0.0, 0.0);\n fragmentOutputs.fragData3 = vec4<f32>(colRgb, colA);\n}\n":"precision highp float;\nprecision highp int;\n\nuniform sampler2D sogMeansLTex;\nuniform sampler2D sogMeansUTex;\nuniform sampler2D sogScalesTex;\nuniform sampler2D sogQuatsTex;\nuniform sampler2D sogSh0Tex;\nuniform sampler2D sogCodebookTex;\n\nuniform vec3 sogMeansMin;\nuniform vec3 sogMeansMax;\nuniform vec3 sogScalesMin;\nuniform vec3 sogScalesMax;\nuniform vec4 sogSh0Min;\nuniform vec4 sogSh0Max;\nuniform int uVersion;\nuniform int uOffset;\nuniform int uCount;\nuniform int uDestWidth;\nuniform int uSrcWidth;\n\nlayout(location = 0) out vec4 glFragData[4];\n\nmat3 transposeM(mat3 m) {\n return mat3(m[0][0], m[1][0], m[2][0], m[0][1], m[1][1], m[2][1], m[0][2], m[1][2], m[2][2]);\n}\n\nvoid main() {\n ivec2 p = ivec2(gl_FragCoord.xy);\n int global = p.y * uDestWidth + p.x;\n if (global < uOffset || global >= uOffset + uCount) {\n discard;\n }\n int k = global - uOffset;\n ivec2 src = ivec2(k - (k / uSrcWidth) * uSrcWidth, k / uSrcWidth);\n\n vec3 mL = texelFetch(sogMeansLTex, src, 0).xyz;\n vec3 mU = texelFetch(sogMeansUTex, src, 0).xyz;\n vec3 sRaw = texelFetch(sogScalesTex, src, 0).xyz;\n vec4 qRaw = texelFetch(sogQuatsTex, src, 0);\n vec4 c0 = texelFetch(sogSh0Tex, src, 0);\n\n // Position: q16 = (u<<8)|l normalized; n = lerp(min,max,q16); pos = sign(n)*(exp(|n|)-1)\n vec3 q16 = (mU * 256.0 + mL) * (255.0 / 65535.0);\n vec3 nPos = mix(sogMeansMin, sogMeansMax, q16);\n vec3 center = sign(nPos) * (exp(abs(nPos)) - vec3(1.0));\n\n // Scale (v1: lerp+exp ; v2: codebook lookup)\n vec3 splatScale;\n if (uVersion == 2) {\n vec3 sIdx = floor(sRaw * 255.0 + 0.5);\n splatScale.x = exp(texelFetch(sogCodebookTex, ivec2(int(sIdx.x), 0), 0).r);\n splatScale.y = exp(texelFetch(sogCodebookTex, ivec2(int(sIdx.y), 0), 0).r);\n splatScale.z = exp(texelFetch(sogCodebookTex, ivec2(int(sIdx.z), 0), 0).r);\n } else {\n splatScale = exp(mix(sogScalesMin, sogScalesMax, sRaw));\n }\n\n // Quaternion (largest-omitted, mode in alpha as 252 + omitted-index)\n const float invSqrt2 = 0.70710678118;\n vec3 qabc = (qRaw.xyz - vec3(0.5)) * 2.0 * invSqrt2;\n int qMode = int(qRaw.w * 255.0 + 0.5) - 252;\n float qd = sqrt(max(0.0, 1.0 - dot(qabc, qabc)));\n vec4 quat;\n if (qMode == 0) {\n quat = vec4(qd, qabc.x, qabc.y, qabc.z);\n } else if (qMode == 1) {\n quat = vec4(qabc.x, qd, qabc.y, qabc.z);\n } else if (qMode == 2) {\n quat = vec4(qabc.x, qabc.y, qd, qabc.z);\n } else {\n quat = vec4(qabc.x, qabc.y, qabc.z, qd);\n }\n\n float qw = quat.x, qx = quat.y, qy = quat.z, qz = quat.w;\n mat3 R = mat3(\n 1.0 - 2.0 * (qy * qy + qz * qz), 2.0 * (qx * qy + qw * qz), 2.0 * (qx * qz - qw * qy),\n 2.0 * (qx * qy - qw * qz), 1.0 - 2.0 * (qx * qx + qz * qz), 2.0 * (qy * qz + qw * qx),\n 2.0 * (qx * qz + qw * qy), 2.0 * (qy * qz - qw * qx), 1.0 - 2.0 * (qx * qx + qy * qy)\n );\n mat3 S2 = mat3(\n 4.0 * splatScale.x * splatScale.x, 0.0, 0.0,\n 0.0, 4.0 * splatScale.y * splatScale.y, 0.0,\n 0.0, 0.0, 4.0 * splatScale.z * splatScale.z\n );\n mat3 Sigma = R * S2 * transposeM(R);\n\n // Color (sh0)\n const float SH_C0 = 0.28209479177387814;\n vec3 colRgb;\n float colA;\n if (uVersion == 2) {\n vec3 c3;\n c3.x = texelFetch(sogCodebookTex, ivec2(256 + int(c0.x * 255.0 + 0.5), 0), 0).r;\n c3.y = texelFetch(sogCodebookTex, ivec2(256 + int(c0.y * 255.0 + 0.5), 0), 0).r;\n c3.z = texelFetch(sogCodebookTex, ivec2(256 + int(c0.z * 255.0 + 0.5), 0), 0).r;\n colRgb = vec3(0.5) + c3 * SH_C0;\n colA = c0.w;\n } else {\n vec4 cLerp = mix(sogSh0Min, sogSh0Max, c0);\n colRgb = vec3(0.5) + cLerp.xyz * SH_C0;\n colA = 1.0 / (1.0 + exp(-cLerp.w));\n }\n\n glFragData[0] = vec4(center, 1.0);\n glFragData[1] = vec4(Sigma[0][0], Sigma[0][1], Sigma[0][2], Sigma[1][1]);\n glFragData[2] = vec4(Sigma[1][2], Sigma[2][2], 0.0, 0.0);\n glFragData[3] = vec4(colRgb, colA);\n}\n"},{attributes:["position"],uniforms:["sogMeansMin","sogMeansMax","sogScalesMin","sogScalesMax","sogSh0Min","sogSh0Max","uVersion","uOffset","uCount","uDestWidth","uSrcWidth"],samplers:["sogMeansLTex","sogMeansUTex","sogScalesTex","sogQuatsTex","sogSh0Tex","sogCodebookTex"],shaderLanguage:this._shaderLanguage});return n.backFaceCulling=!1,n.disableDepthWrite=!0,n},e.prototype._applyPack=function(e,n){var r,o,a,i,s,l=this._material,u=e.meansTextureL.getSize().width;l.setTexture("sogMeansLTex",e.meansTextureL),l.setTexture("sogMeansUTex",e.meansTextureU),l.setTexture("sogScalesTex",e.scalesTexture),l.setTexture("sogQuatsTex",e.quatsTexture),l.setTexture("sogSh0Tex",e.sh0Texture),l.setTexture("sogCodebookTex",null!==(r=e.codebookTexture)&&void 0!==r?r:e.sh0Texture),l.setVector3("sogMeansMin",new t.Vector3(e.meansMin[0],e.meansMin[1],e.meansMin[2])),l.setVector3("sogMeansMax",new t.Vector3(e.meansMax[0],e.meansMax[1],e.meansMax[2]));var c=null!==(o=e.scalesMin)&&void 0!==o?o:[0,0,0],f=null!==(a=e.scalesMax)&&void 0!==a?a:[0,0,0];l.setVector3("sogScalesMin",new t.Vector3(c[0],c[1],c[2])),l.setVector3("sogScalesMax",new t.Vector3(f[0],f[1],f[2]));var d=null!==(i=e.sh0Min)&&void 0!==i?i:[0,0,0,0],h=null!==(s=e.sh0Max)&&void 0!==s?s:[0,0,0,0];l.setVector4("sogSh0Min",new t.Vector4(d[0],d[1],d[2],d[3])),l.setVector4("sogSh0Max",new t.Vector4(h[0],h[1],h[2],h[3])),l.setInt("uVersion",e.version),l.setInt("uOffset",n),l.setInt("uCount",e.splatCount),l.setInt("uDestWidth",this._textureSize),l.setInt("uSrcWidth",u)},e}(),ls=Math.tan(22.5*Math.PI/180),us=new t.Matrix,cs=new t.Vector3,fs=new t.Vector3,ds=new t.Vector3,hs=new t.Vector3(0,0,1),ps=[[0,1],[1,2],[2,3],[3,0],[4,5],[5,6],[6,7],[7,4],[0,4],[1,5],[2,6],[3,7]],ms=2*ps.length,vs=[new t.Color4(1,.2,.2,1),new t.Color4(1,.6,.1,1),new t.Color4(1,1,.2,1),new t.Color4(.3,1,.3,1),new t.Color4(.2,1,1,1),new t.Color4(.4,.5,1,1),new t.Color4(.9,.4,1,1),new t.Color4(1,1,1,1)],_s=function(e){function n(n,r,o,a,i){void 0===i&&(i={});var s=e.call(this,n,null,a,!1)||this;s._leafNodes=[],s._lodBaseDistance=5,s._lodMultiplier=3,s._lodBehindPenalty=1,s._lodRangeMin=0,s._maxDecodesPerFrame=1,s._lodCooldownFrames=10,s._lodUpdateInterval=4,s._lodUpdateDistance=.5,s._maxDetailLod=0,s._frustumCulling=!0,s._frustumPlanes=[new t.Plane(0,0,0,0),new t.Plane(0,0,0,0),new t.Plane(0,0,0,0),new t.Plane(0,0,0,0),new t.Plane(0,0,0,0),new t.Plane(0,0,0,0)],s._cullViewProj=new t.Matrix,s._workBuffer=null,s._useGpuPositionReadback=!1,s._readbackCandidate=!1,s._readbackProbed=!1,s._fileBaseSplat=new Map,s._fileCounts=new Map,s._fileMeta=new Map,s._decodedFiles=new Set,s._loadingFiles=new Set,s._decodeQueue=[],s._environmentRange=null,s._environmentFiles=null,s._lodObserver=null,s._baseLayerReady=!1,s._framesSinceLodUpdate=0,s._lastLodCamPos=new t.Vector3(1/0,1/0,1/0),s._forceLodUpdate=!1,s._boundsMin=new t.Vector3(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),s._boundsMax=new t.Vector3(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE),s._debugDisplay=!1,s._debugLodSource="optimal",s._debugMesh=null,s._debugObserver=null,s._debugColorData=null,s._debugSignature=0,s._disposed=!1,s._metadata=r,s._rootUrl=o,s._streamOptions=i;var l=Math.max(0,r.lodLevels-1);return s._lodRangeMax=l,void 0!==i.lodBaseDistance&&(s._lodBaseDistance=Math.max(.1,i.lodBaseDistance)),void 0!==i.lodMultiplier&&(s._lodMultiplier=Math.max(1.2,i.lodMultiplier)),void 0!==i.lodBehindPenalty&&(s._lodBehindPenalty=Math.max(1,i.lodBehindPenalty)),void 0!==i.lodRangeMin&&(s._lodRangeMin=Math.max(0,Math.min(i.lodRangeMin,l))),void 0!==i.lodRangeMax&&(s._lodRangeMax=Math.max(s._lodRangeMin,Math.min(i.lodRangeMax,l))),void 0!==i.maxDecodesPerFrame&&(s._maxDecodesPerFrame=Math.max(1,i.maxDecodesPerFrame)),void 0!==i.lodCooldownFrames&&(s._lodCooldownFrames=Math.max(0,i.lodCooldownFrames)),void 0!==i.lodUpdateInterval&&(s._lodUpdateInterval=Math.max(1,i.lodUpdateInterval)),void 0!==i.lodUpdateDistance&&(s._lodUpdateDistance=Math.max(0,i.lodUpdateDistance)),void 0!==i.maxDetailLod&&(s._maxDetailLod=Math.max(0,Math.floor(i.maxDetailLod))),void 0!==i.frustumCulling&&(s._frustumCulling=i.frustumCulling),i.debugLodSource&&(s._debugLodSource=i.debugLodSource),s.scaling.y*=-1,s.rotation.x=-Math.PI/2,s._collectLodEntries(r.tree),i.debugDisplay&&(s.debugDisplay=!0),s._streamAllAsync().catch(function(e){var n;t.Logger.Error("GaussianSplattingStream: streaming failed: "+(null!==(n=null==e?void 0:e.message)&&void 0!==n?n:e))}),s}return m(n,e),n.IsLODMetadata=function(e){if("object"!=typeof e||null===e)return!1;var t=e;return"number"==typeof t.lodLevels&&Array.isArray(t.filenames)&&"object"==typeof t.tree&&null!==t.tree},n.prototype.getClassName=function(){return"GaussianSplattingStream"},Object.defineProperty(n.prototype,"maxDetailLod",{get:function(){return this._maxDetailLod},set:function(e){var t=Math.max(0,Math.floor(e));this._maxDetailLod!==t&&(this._maxDetailLod=t,this._forceLodUpdate=!0)},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"maxLodLevel",{get:function(){return Math.max(0,this._metadata.lodLevels-1)},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"frustumCulling",{get:function(){return this._frustumCulling},set:function(e){this._frustumCulling!==e&&(this._frustumCulling=e,this._forceLodUpdate=!0)},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"debugDisplay",{get:function(){return this._debugDisplay},set:function(e){this._debugDisplay!==e&&(this._debugDisplay=e,e?this._refreshDebugDisplay():this._clearDebugDisplay())},enumerable:!1,configurable:!0}),Object.defineProperty(n.prototype,"debugLodSource",{get:function(){return this._debugLodSource},set:function(e){this._debugLodSource!==e&&(this._debugLodSource=e,this._debugDisplay&&this._refreshDebugDisplay())},enumerable:!1,configurable:!0}),n.prototype.dispose=function(t){var n;this._disposed=!0,this._lodObserver&&(this._scene.onBeforeRenderObservable.remove(this._lodObserver),this._lodObserver=null),this._clearDebugDisplay(),null===(n=this._workBuffer)||void 0===n||n.dispose(),this._workBuffer=null,e.prototype.dispose.call(this,t)},n.prototype.evaluateOptimalLods=function(e){if(void 0===e&&(e=this._scene.activeCamera),e&&0!==this._leafNodes.length){var n=Math.max(0,this._metadata.lodLevels-1),r=this._lodBaseDistance,o=this._lodMultiplier,a=this._lodBehindPenalty,i=this._lodRangeMin,s=this._lodRangeMax,l=this._scene.getEngine().getAspectRatio(e)||1,u=Math.tan(.5*e.fov);e.fovMode===t.Camera.FOVMODE_HORIZONTAL_FIXED&&(u/=l);var c=u*l,f=Math.min(u,c)/ls;this.computeWorldMatrix(!1).invertToRef(us);var d=t.Vector3.TransformCoordinatesToRef(e.globalPosition,us,cs),h=d.x,p=d.y,m=d.z,v=0,_=0,g=0;if(a>1){e.getDirectionToRef(hs,ds);var y=t.Vector3.TransformNormalToRef(ds,us,fs);y.normalize(),v=y.x,_=y.y,g=y.z}for(var b=0,x=this._leafNodes;b<x.length;b++){var T=x[b],A=T.bound.min,w=T.bound.max,M=(h<A[0]?A[0]:h>w[0]?w[0]:h)-h,C=(p<A[1]?A[1]:p>w[1]?w[1]:p)-p,O=(m<A[2]?A[2]:m>w[2]?w[2]:m)-m,S=Math.sqrt(M*M+C*C+O*O),E=S;if(a>1&&S>.01){var F=(v*M+_*C+g*O)/S;F<0&&(E=S*(1+-F*(a-1)))}var R=E*f,L=void 0;if(0===n||R<r)L=0;else for(L=n;L>1&&R<r*Math.pow(o,L-1);)L--;L<i?L=i:L>s&&(L=s),this._frustumCulling&&!1===T.inFrustum&&(L=s),T.optimalLod=L}}},n.prototype._displayedLodLevel=function(e){var t,n,r;return"optimal"===this._debugLodSource?null!==(n=null!==(t=e.optimalLod)&&void 0!==t?t:e.activeLod)&&void 0!==n?n:0:null!==(r=e.activeLod)&&void 0!==r?r:0},n.prototype._refreshDebugDisplay=function(){var e=this;"optimal"===this._debugLodSource&&this.evaluateOptimalLods(),this._buildDebugMesh();var t=this._debugDisplay;t&&!this._debugObserver?this._debugObserver=this._scene.onBeforeRenderObservable.add(function(){return e._onDebugFrame()}):!t&&this._debugObserver&&(this._scene.onBeforeRenderObservable.remove(this._debugObserver),this._debugObserver=null)},n.prototype._onDebugFrame=function(){"optimal"===this._debugLodSource&&this.evaluateOptimalLods(),this._computeDebugSignature()!==this._debugSignature&&this._updateDebugColors()},n.prototype._buildDebugMesh=function(){this._debugMesh&&(this._debugMesh.dispose(),this._debugMesh=null),this._debugColorData=null;for(var e=[],n=[],r=0,o=this._leafNodes;r<o.length;r++)for(var a=o[r],i=vs[this._displayedLodLevel(a)%vs.length],s=a.bound.min,l=a.bound.max,u=[new t.Vector3(s[0],s[1],s[2]),new t.Vector3(l[0],s[1],s[2]),new t.Vector3(l[0],l[1],s[2]),new t.Vector3(s[0],l[1],s[2]),new t.Vector3(s[0],s[1],l[2]),new t.Vector3(l[0],s[1],l[2]),new t.Vector3(l[0],l[1],l[2]),new t.Vector3(s[0],l[1],l[2])],c=0,f=ps;c<f.length;c++){var d=f[c];e.push([u[d[0]],u[d[1]]]),n.push([i,i])}if(this._debugSignature=this._computeDebugSignature(),0!==e.length){var h=t.CreateLineSystem(this.name+"_lodDebug",{lines:e,colors:n,updatable:!0,useVertexAlpha:!1},this._scene);h.parent=this,h.isPickable=!1,h.doNotSerialize=!0,h.reservedDataStore={hidden:!0},this._debugMesh=h,this._debugColorData=new Float32Array(this._leafNodes.length*ms*4)}},n.prototype._updateDebugColors=function(){if(this._debugMesh&&this._debugColorData){for(var e=this._debugColorData,n=0,r=0,o=this._leafNodes;r<o.length;r++)for(var a=o[r],i=vs[this._displayedLodLevel(a)%vs.length],s=0;s<ms;s++)e[n++]=i.r,e[n++]=i.g,e[n++]=i.b,e[n++]=i.a;this._debugMesh.updateVerticesData(t.VertexBuffer.ColorKind,e),this._debugSignature=this._computeDebugSignature()}},n.prototype._computeDebugSignature=function(){for(var e=0,t=0,n=this._leafNodes;t<n.length;t++){var r=n[t];e=31*e+this._displayedLodLevel(r)|0}return e},n.prototype._clearDebugDisplay=function(){this._debugObserver&&(this._scene.onBeforeRenderObservable.remove(this._debugObserver),this._debugObserver=null),this._debugMesh&&(this._debugMesh.dispose(),this._debugMesh=null),this._debugColorData=null,this._debugSignature=0},n.prototype._collectLodEntries=function(e){if(e.children)for(var n=0,r=e.children;n<r.length;n++){var o=r[n];this._collectLodEntries(o)}else if(e.lods){for(var a=[],i=0,s=Object.keys(e.lods);i<s.length;i++){var l=s[i],u=Number(l),c=e.lods[l];Number.isFinite(u)&&c&&c.count>0&&a.push(u)}0!==a.length&&(a.sort(function(e,t){return e-t}),e.availableLevels=a,e.baseLod=a[a.length-1],e.activeLod=void 0,e.lodCooldown=0,e.inFrustum=!0,e.cullBounds=new t.BoundingInfo(t.Vector3.FromArray(e.bound.min),t.Vector3.FromArray(e.bound.max)),this._leafNodes.push(e))}},n.prototype._streamAllAsync=function(){return _(this,void 0,void 0,function(){var e,t,n,r,o,a,i,s,l,u,c,f,d,h,p,m,v=this;return g(this,function(_){switch(_.label){case 0:return e=this._collectAllFileIds(),[4,this._gatherCountsAsync(e)];case 1:if(t=_.sent(),this._disposed)return[2];for(n=1,t>0&&(this._environmentRange={offset:n,count:t},n+=t),r=0,o=e;r<o.length;r++)m=o[r],void 0===(a=this._fileCounts.get(m))||a<=0||(this._fileBaseSplat.set(m,n),n+=a);return n<=1?[2]:(this._workBuffer=new ss(this._scene,n),this._readbackCandidate=this._workBuffer.supportsAsyncCentersReadback,i=new Float32Array(4*n),s=this._workBuffer.textures,this._setExternalWorkBuffer(s[0],s[1],s[2],s[3],i,n),this.setSplatIndexRanges([]),this.setEnabled(!0),this._environmentRange&&this._environmentFiles?[4,this._decodeEnvironmentAsync()]:[3,3]);case 2:_.sent(),_.label=3;case 3:for(this._environmentFiles=null,l=new Set,u=0,c=this._leafNodes;u<c.length;u++)f=c[u],(d=f.lods[String(f.baseLod)])&&this._fileBaseSplat.has(d.file)&&l.add(d.file);h=0,p=Array.from(l),_.label=4;case 4:return h<p.length?(m=p[h],this._disposed?[2]:[4,this._decodeFileAsync(m)]):[3,7];case 5:_.sent(),_.label=6;case 6:return h++,[3,4];case 7:return this._disposed||(this._baseLayerReady=!0,this._lodObserver||(this._lodObserver=this._scene.onBeforeRenderObservable.add(function(){return v._onLodFrame()}))),[2]}})})},n.prototype._collectAllFileIds=function(){for(var e=new Set,t=0,n=this._leafNodes;t<n.length;t++)for(var r=n[t],o=0,a=r.availableLevels;o<a.length;o++){var i=a[o],s=r.lods[String(i)];s&&e.add(s.file)}return Array.from(e).sort(function(e,t){return e-t})},n.prototype._gatherCountsAsync=function(e){return _(this,void 0,void 0,function(){var r,o,a,i,s,l,u,c,f=this;return g(this,function(d){switch(d.label){case 0:if(r=0,!this._metadata.environment)return[3,5];d.label=1;case 1:return d.trys.push([1,4,,5]),o=this._rootUrl+this._metadata.environment,[4,t.Tools.LoadFileAsync(o,!0)];case 2:return a=d.sent(),[4,this._unzipAsync(new Uint8Array(a))];case 3:return i=d.sent(),(s=i.get("meta.json"))&&(l=JSON.parse((new TextDecoder).decode(s)),r=n._GetSplatCount(l),this._environmentFiles=i),[3,5];case 4:return u=d.sent(),t.Logger.Warn("GaussianSplattingStream: failed to load environment: "+(null!==(c=null==u?void 0:u.message)&&void 0!==c?c:u)),[3,5];case 5:return[4,Promise.all(e.map(function(e){return _(f,void 0,void 0,function(){var r,o,a,i,s,l,u;return g(this,function(c){switch(c.label){case 0:if(!(r=this._metadata.filenames[e]))return t.Logger.Warn("GaussianSplattingStream: missing filename for file index ".concat(e,".")),[2];c.label=1;case 1:return c.trys.push([1,3,,4]),o=this._rootUrl+r,a=o.substring(0,o.lastIndexOf("/")+1),[4,t.Tools.LoadFileAsync(o,!1)];case 2:return i=c.sent(),s=JSON.parse(i),this._fileCounts.set(e,n._GetSplatCount(s)),this._fileMeta.set(e,{sogData:s,subRootUrl:a}),[3,4];case 3:return l=c.sent(),t.Logger.Warn("GaussianSplattingStream: failed to load metadata for ".concat(r,": ").concat(null!==(u=null==l?void 0:l.message)&&void 0!==u?u:l)),[3,4];case 4:return[2]}})})}))];case 6:return d.sent(),[2,r]}})})},n.prototype._enqueueDecode=function(e){this._decodedFiles.has(e)||this._loadingFiles.has(e)||!this._fileMeta.has(e)||-1===this._decodeQueue.indexOf(e)&&this._decodeQueue.push(e)},n.prototype._pumpDecodeQueue=function(){for(var e=0;this._decodeQueue.length>0&&e<this._maxDecodesPerFrame;){var n=this._decodeQueue.shift();this._decodedFiles.has(n)||this._loadingFiles.has(n)||(e++,this._decodeFileAsync(n).catch(function(e){var n;t.Logger.Warn("GaussianSplattingStream: decode failed: "+(null!==(n=null==e?void 0:e.message)&&void 0!==n?n:e))}))}},n.prototype._applyPositions=function(e,t,n){this._splatPositions.set(e,4*t),this._updateBounds(e,n),this._postWorkerPositionsRange(t,n)},n.prototype._probeReadbackAsync=function(e,n,r){return _(this,void 0,void 0,function(){var o,a,i,s,l,u,c;return g(this,function(f){switch(f.label){case 0:if(this._readbackProbed=!0,!this._workBuffer)return[2];o=Math.min(n,1024),a=!1,f.label=1;case 1:return f.trys.push([1,3,,4]),[4,this._workBuffer.readCentersRangeAsync(e,o)];case 2:if(i=f.sent(),this._disposed)return[2];if(i&&i.length>=4*o)for(a=!0,s=0;s<o&&a;s++)for(l=0;l<3;l++)if(u=i[4*s+l],c=r[4*s+l],Math.abs(u-c)>.01*(1+Math.abs(c))){a=!1;break}return[3,4];case 3:return f.sent(),a=!1,[3,4];case 4:return this._useGpuPositionReadback=a,t.Logger.Log(a?"GaussianSplattingStream: GPU position readback validated; streamed LOD positions are read back from the GPU.":"GaussianSplattingStream: GPU position readback unavailable; decoding LOD positions on the CPU."),[2]}})})},n.prototype._applyDecodedPositionsAsync=function(e,t,n){return _(this,void 0,void 0,function(){var r,o;return g(this,function(a){switch(a.label){case 0:return this._useGpuPositionReadback&&this._workBuffer?[4,this._workBuffer.readCentersRangeAsync(t,n)]:[3,2];case 1:if(r=a.sent(),this._disposed)return[2,!1];if(r&&this._splatPositions)return this._applyPositions(r,t,n),[2,!0];a.label=2;case 2:return(o=e.positions.length>=4*n?e.positions.subarray(0,4*n):null)&&this._splatPositions?(this._applyPositions(o,t,n),this._readbackProbed||!this._readbackCandidate?[3,4]:[4,this._probeReadbackAsync(t,n,o)]):[2,!1];case 3:a.sent(),a.label=4;case 4:return[2,!0]}})})},n.prototype._decodeEnvironmentAsync=function(){return _(this,void 0,void 0,function(){var e,r,o,a,i;return g(this,function(s){switch(s.label){case 0:if(!this._environmentRange||!this._environmentFiles||!this._workBuffer)return[2];e=this._environmentRange,s.label=1;case 1:return s.trys.push([1,8,,9]),[4,is(this._environmentFiles,"",this._scene,!this._useGpuPositionReadback)];case 2:if(r=s.sent(),!(o=r.sogTextures))return[2];s.label=3;case 3:return s.trys.push([3,,6,7]),this._disposed||!this._workBuffer?[2]:[4,this._workBuffer.decodeAsync(o,e.offset)];case 4:return s.sent(),this._disposed?[2]:[4,this._applyDecodedPositionsAsync(o,e.offset,e.count)];case 5:return s.sent(),this._disposed?[2]:(this._refreshActiveRanges(),[3,7]);case 6:return n._DisposePack(o),[7];case 7:return[3,9];case 8:return a=s.sent(),t.Logger.Warn("GaussianSplattingStream: failed to decode environment: "+(null!==(i=null==a?void 0:a.message)&&void 0!==i?i:a)),[3,9];case 9:return[2]}})})},n.prototype._decodeFileAsync=function(e){return _(this,void 0,void 0,function(){var t,r,o,a,i;return g(this,function(s){switch(s.label){case 0:if(this._decodedFiles.has(e)||this._loadingFiles.has(e))return[2];if(t=this._fileMeta.get(e),r=this._fileBaseSplat.get(e),o=this._fileCounts.get(e),!t||void 0===r||void 0===o)return[2];this._loadingFiles.add(e),s.label=1;case 1:return s.trys.push([1,,8,9]),[4,is(t.sogData,t.subRootUrl,this._scene,!this._useGpuPositionReadback)];case 2:if(a=s.sent(),!(i=a.sogTextures))return[2];s.label=3;case 3:return s.trys.push([3,,6,7]),this._disposed||!this._workBuffer?[2]:[4,this._workBuffer.decodeAsync(i,r)];case 4:return s.sent(),this._disposed?[2]:[4,this._applyDecodedPositionsAsync(i,r,o)];case 5:return s.sent(),this._disposed?[2]:(this._decodedFiles.add(e),this._applyDesiredLods()&&this._refreshActiveRanges(),[3,7]);case 6:return n._DisposePack(i),[7];case 7:return[3,9];case 8:return this._loadingFiles.delete(e),[7];case 9:return[2]}})})},n.prototype._cappedLevelForNode=function(e,t){for(var n=e.availableLevels,r=this._maxDetailLod,o=-1,a=Number.POSITIVE_INFINITY,i=0,s=n;i<s.length;i++){var l=s[i];if(!(l<r)){var u=Math.abs(l-t);u<a&&(o=l,a=u)}}return o<0?e.baseLod:o},n.prototype._computeTargetLevels=function(){for(var e,t=0,n=this._leafNodes;t<n.length;t++){var r=n[t],o=null!==(e=r.optimalLod)&&void 0!==e?e:r.baseLod;r.targetLevel=this._cappedLevelForNode(r,o)}},n.prototype._applyDesiredLods=function(){for(var e,t=!1,n=0,r=this._leafNodes;n<r.length;n++){var o=r[n];if(!(o.lodCooldown&&o.lodCooldown>0)){var a=null!==(e=o.targetLevel)&&void 0!==e?e:o.baseLod;if(a!==o.activeLod){var i=o.lods[String(a)];i&&(this._decodedFiles.has(i.file)?(o.activeLod=a,o.lodCooldown=this._lodCooldownFrames,t=!0):this._enqueueDecode(i.file))}}}return t},n.prototype._onLodFrame=function(){if(!this._disposed&&this._baseLayerReady){for(var e=0,n=this._leafNodes;e<n.length;e++){var r=n[e];r.lodCooldown&&r.lodCooldown>0&&r.lodCooldown--}this._pumpDecodeQueue();var o=this._updateNodeFrustum(),a=this._forceLodUpdate||o;if(!a&&++this._framesSinceLodUpdate>=this._lodUpdateInterval){var i=this._scene.activeCamera,s=this._lodUpdateDistance;(!i||t.Vector3.DistanceSquared(i.globalPosition,this._lastLodCamPos)>=s*s)&&(i&&this._lastLodCamPos.copyFrom(i.globalPosition),a=!0)}a&&(this._forceLodUpdate=!1,this._framesSinceLodUpdate=0,this.evaluateOptimalLods(this._scene.activeCamera),this._computeTargetLevels(),this._applyDesiredLods()&&this._refreshActiveRanges())}},n.prototype._updateNodeFrustum=function(){var e=this._scene.activeCamera,n=!1;if(!this._frustumCulling||!e){for(var r=0,o=this._leafNodes;r<o.length;r++)!1===(l=o[r]).inFrustum&&(l.inFrustum=!0,n=!0);return n}var a=this.computeWorldMatrix(!1);e.getViewMatrix().multiplyToRef(e.getProjectionMatrix(),this._cullViewProj),t.Frustum.GetPlanesToRef(this._cullViewProj,this._frustumPlanes);for(var i=0,s=this._leafNodes;i<s.length;i++){var l;(l=s[i]).cullBounds.update(a);var u=l.cullBounds.isInFrustum(this._frustumPlanes);u!==l.inFrustum&&(l.inFrustum=u,n=!0)}return n},n._GetSplatCount=function(e){var t;return null!==(t=e.count)&&void 0!==t?t:Array.isArray(e.means.shape)?e.means.shape[0]:0},n._DisposePack=function(e){var t,n,r;e.meansTextureL.dispose(),e.meansTextureU.dispose(),e.scalesTexture.dispose(),e.quatsTexture.dispose(),e.sh0Texture.dispose(),null===(t=e.shCentroidsTexture)||void 0===t||t.dispose(),null===(n=e.shLabelsTexture)||void 0===n||n.dispose(),null===(r=e.codebookTexture)||void 0===r||r.dispose()},n.prototype._updateBounds=function(e,n){for(var r=this._boundsMin,o=this._boundsMax,a=0;a<n;a++){var i=e[4*a+0],s=e[4*a+1],l=e[4*a+2];r.minimizeInPlaceFromFloats(i,s,l),o.maximizeInPlaceFromFloats(i,s,l)}this.setBoundingInfo(new t.BoundingInfo(r,o))},n.prototype._refreshActiveRanges=function(){var e=[];this._environmentRange&&e.push({offset:this._environmentRange.offset,count:this._environmentRange.count});for(var t=0,r=this._leafNodes;t<r.length;t++){var o=r[t];if(void 0!==o.activeLod){var a=o.lods[String(o.activeLod)];if(a){var i=this._fileBaseSplat.get(a.file);void 0!==i&&e.push({offset:i+a.offset,count:a.count})}}}this.setSplatIndexRanges(n._CoalesceRanges(e))},n._CoalesceRanges=function(e){if(e.length<=1)return e;for(var t=e.slice().sort(function(e,t){return e.offset-t.offset}),n=[{offset:t[0].offset,count:t[0].count}],r=1;r<t.length;r++){var o=n[n.length-1],a=t[r],i=o.offset+o.count;if(a.offset<=i){var s=Math.max(i,a.offset+a.count);o.count=s-o.offset}else n.push({offset:a.offset,count:a.count})}return n},n.prototype._unzipAsync=function(e){return _(this,void 0,void 0,function(){var n,r,o,a,i,s,l,u,c;return g(this,function(f){switch(f.label){case 0:return(n=this._streamOptions.fflate)?[3,3]:void 0!==window.fflate?[3,2]:[4,t.Tools.LoadScriptAsync(null!==(c=this._streamOptions.deflateURL)&&void 0!==c?c:"https://unpkg.com/fflate/umd/index.js")];case 1:f.sent(),f.label=2;case 2:n=window.fflate,f.label=3;case 3:for(r=n.unzipSync(e),o=new Map,a=0,i=Object.entries(r);a<i.length;a++)s=i[a],l=s[0],u=s[1],o.set(l,u);return[2,o]}})})},n}(t.GaussianSplattingMesh),gs=.28209479177387814,ys=null,bs=null;function xs(e,n,r){var o,a,i,s,l,u,c,f,d,h,p,m,v,_,y,b,x,T,A,w,M,C,O,S,E,F,R,L,I,P,N,B,k,D,G,V,H,U,j,K,W,z,q,X,Y,Q;return void 0===r&&(r=!1),g(this,function(g){switch(g.label){case 0:if(o=e.numPoints,a=new ArrayBuffer(32*o),i=new Float32Array(a),s=new Uint8Array(a),l=e.positions,u=e.scales,c=e.colors,f=e.alphas,d=e.rotations,h=null,p=e.shDegree,m=null,v=0,_=null,y=null,b=null,p>0&&e.sh.length>0){for(v=3*((p+1)*(p+1)-1),x=Math.ceil(v/16),T=n.getEngine(),A=T.getCaps().maxTextureSize,w=Math.ceil(o/A),h=t.AllocateShBuffers(x,w*A*4*4),_=new Int32Array(x),y=new Int32Array(x),G=0;G<x;G++)_[G]=16*G,y[G]=Math.min(16*(G+1),v);b=h,m=e.sh}M=0,g.label=1;case 1:if(!(M<o))return[3,4];if(O=32*M,S=3*M,E=4*M,i[0+(C=8*M)]=l[S+0],i[C+1]=l[S+1],i[C+2]=l[S+2],i[C+3]=Math.exp(u[S+0]),i[C+4]=Math.exp(u[S+1]),i[C+5]=Math.exp(u[S+2]),F=255*(.5+gs*c[S+0]),R=255*(.5+gs*c[S+1]),L=255*(.5+gs*c[S+2]),s[O+24]=F<=0?0:F>=255?255:F+.5|0,s[O+25]=R<=0?0:R>=255?255:R+.5|0,s[O+26]=L<=0?0:L>=255?255:L+.5|0,s[O+27]=1/(1+Math.exp(-f[M]))*255+.5|0,I=127.5*d[E+3]+127.5,P=127.5*d[E+0]+127.5,N=127.5*d[E+1]+127.5,B=127.5*d[E+2]+127.5,s[O+28]=I<=0?0:I>=255?255:I+.5|0,s[O+29]=P<=0?0:P>=255?255:P+.5|0,s[O+30]=N<=0?0:N>=255?255:N+.5|0,s[O+31]=B<=0?0:B>=255?255:B+.5|0,m&&b&&_&&y)for(k=M*v,D=16*M,G=0;G<b.length;G++)for(V=b[G],H=_[G],U=y[G],j=H;j<U;j++)K=128*m[k+j]+128,V[D+j-H]=K<=0?0:K>=255?255:K+.5|0;return M%32768==0&&r?[4]:[3,3];case 2:g.sent(),g.label=3;case 3:return M++,[3,1];case 4:if(e.extensions)for(q=0,X=e.extensions;q<X.length;q++)if(Y=X[q],void 0!==(Q=Y).safeOrbitRadiusMin){W=Q.safeOrbitRadiusMin,z=[Q.safeOrbitElevationMin,Q.safeOrbitElevationMax];break}return[2,{mode:0,data:a,hasVertexColors:!1,sh:null!==h?h:void 0,shDegree:p>0?p:void 0,trainedWithAntialiasing:!!e.antialiased,safeOrbitCameraRadiusMin:W,safeOrbitCameraElevationMinMax:z}]}})}var Ts=function(){function e(t){void 0===t&&(t={}),this.name=Ji.name,this._assetContainer=null,this.extensions=Ji.extensions,this._loadingOptions=v(v({},e._DefaultLoadingOptions),t)}return e.prototype.createPlugin=function(t){return new e(t[Ji.name])},e.prototype.importMeshAsync=function(e,t,n,r,o,a){return _(this,void 0,void 0,function(){var o;return g(this,function(a){switch(a.label){case 0:return(o=this._tryCreateLODStream(t,n,r))?[2,{meshes:[o],particleSystems:[],skeletons:[],animationGroups:[],transformNodes:[],geometries:[],lights:[],spriteManagers:[]}]:[4,this._parseAsync(e,t,n,r).then(function(e){return{meshes:e,particleSystems:[],skeletons:[],animationGroups:[],transformNodes:[],geometries:[],lights:[],spriteManagers:[]}})];case 1:return[2,a.sent()]}})})},e.prototype._tryCreateLODStream=function(e,t,n){if("string"!=typeof t)return null;var r;try{r=JSON.parse(t)}catch(e){return null}if(!_s.IsLODMetadata(r))return null;var o=e._blockEntityCollection;e._blockEntityCollection=!!this._assetContainer;try{var a=new _s("GaussianSplattingStream",r,n,e,{deflateURL:this._loadingOptions.deflateURL,fflate:this._loadingOptions.fflate});return a._parentContainer=this._assetContainer,a}finally{e._blockEntityCollection=o}},e._BuildPointCloud=function(e,n){if(!n.byteLength)return!1;var r=new Uint8Array(n),o=new Float32Array(n),a=r.length/32;return e.addPoints(a,function(e,n){var a=o[8*n+0],i=o[8*n+1],s=o[8*n+2];e.position=new t.Vector3(a,i,s);var l=r[32*n+24+0]/255,u=r[32*n+24+1]/255,c=r[32*n+24+2]/255;e.color=new t.Color4(l,u,c,1)}),!0},e._BuildMesh=function(e,n){for(var r=new t.Mesh("PLYMesh",e),o=new Uint8Array(n.data),a=new Float32Array(n.data),i=o.length/32,s=[],l=new t.VertexData,u=0;u<i;u++){var c=a[8*u+0],f=a[8*u+1],d=a[8*u+2];s.push(c,f,d)}if(n.hasVertexColors){var h=new Float32Array(4*i);for(u=0;u<i;u++){var p=o[32*u+24+0]/255,m=o[32*u+24+1]/255,v=o[32*u+24+2]/255;h[4*u+0]=p,h[4*u+1]=m,h[4*u+2]=v,h[4*u+3]=1}l.colors=h}return l.positions=s,l.indices=n.faces,l.applyToMesh(r),r},e.prototype._unzipWithFFlateAsync=function(e){return _(this,void 0,void 0,function(){var n,r,o,a,i,s,l,u,c,f;return g(this,function(d){switch(d.label){case 0:return(n=this._loadingOptions.fflate)?[3,3]:void 0!==window.fflate?[3,2]:[4,t.Tools.LoadScriptAsync(null!==(f=this._loadingOptions.deflateURL)&&void 0!==f?f:"https://unpkg.com/fflate/umd/index.js")];case 1:d.sent(),d.label=2;case 2:n=window.fflate,d.label=3;case 3:for(r=n.unzipSync,o=r(e),a=new Map,i=0,s=Object.entries(o);i<s.length;i++)l=s[i],u=l[0],c=l[1],a.set(u,c);return[2,a]}})})},e.prototype._parseAsync=function(n,r,o,a){var i=this,s=[],l=function(e){var n;r._blockEntityCollection=!!i._assetContainer;var o=null!==(n=i._loadingOptions.gaussianSplattingMesh)&&void 0!==n?n:new t.GaussianSplattingMesh("GaussianSplatting",null,r,i._loadingOptions.keepInRam,i._loadingOptions.needsRotationScaleTextures);o._parentContainer=i._assetContainer,s.push(o),e.sogTextures?o.setSogTextureData(e.sogTextures):o.updateData(e.data,e.sh,{flipY:!1},void 0,e.shDegree),o.scaling.y*=-1,o.computeWorldMatrix(!0),r._blockEntityCollection=!1},u=r.getEngine(),c=this._loadingOptions.useSogTextures;c&&!u.isWebGPU&&u.version<2&&(t.Logger.Warn("SPLATFileLoader: useSogTextures requires WebGL2 or WebGPU. Falling back to CPU path."),c=!1);var f=c?is:ns;if("string"==typeof o){var d=JSON.parse(o);if(d&&d.means&&d.scales&&d.quats&&d.sh0)return new Promise(function(e,t){f(d,a,r).then(function(t){l(t),e(s)}).catch(function(e){t(new Error("Failed to parse SOG data.",{cause:e}))})})}var h=o instanceof ArrayBuffer?new Uint8Array(o):o;if(80===h[0]&&75===h[1])return new Promise(function(e,t){i._unzipWithFFlateAsync(h).then(function(n){f(n,a,r).then(function(t){l(t),e(s)}).catch(function(e){t(new Error("Failed to parse SOG zip data.",{cause:e}))})})});var p=function(n){e._ConvertPLYToSplat(o).then(function(o){return _(i,void 0,void 0,function(){var a,i,l;return g(this,function(u){switch(u.label){case 0:switch(r._blockEntityCollection=!!this._assetContainer,o.mode){case 0:return[3,1];case 1:return[3,2];case 2:return[3,6]}return[3,7];case 1:switch((a=null!==(l=this._loadingOptions.gaussianSplattingMesh)&&void 0!==l?l:new t.GaussianSplattingMesh("GaussianSplatting",null,r,this._loadingOptions.keepInRam,this._loadingOptions.needsRotationScaleTextures))._parentContainer=this._assetContainer,s.push(a),a.updateData(o.data,o.sh,{flipY:!1},void 0,o.shDegree),a.scaling.y*=-1,"RightHanded"===o.chirality&&(a.scaling.y*=-1),o.upAxis){case"X":a.rotation=new t.Vector3(0,0,Math.PI/2);break;case"Y":a.rotation=new t.Vector3(0,0,Math.PI);break;case"Z":a.rotation=new t.Vector3(-Math.PI/2,Math.PI,0)}return a.computeWorldMatrix(!0),[3,8];case 2:return i=new t.PointsCloudSystem("PointCloud",1,r),e._BuildPointCloud(i,o.data)?[4,i.buildMeshAsync().then(function(e){s.push(e)})]:[3,4];case 3:return u.sent(),[3,5];case 4:i.dispose(),u.label=5;case 5:return[3,8];case 6:if(!o.faces)throw new Error("PLY mesh doesn't contain face informations.");return s.push(e._BuildMesh(r,o)),[3,8];case 7:throw new Error("Unsupported Splat mode");case 8:return r._blockEntityCollection=!1,this.applyAutoCameraLimits(o,r),n(s),[2]}})})})},m=31===h[0]&&139===h[1],v=78===h[0]&&71===h[1]&&83===h[2]&&80===h[3];if(!m&&!v)return new Promise(function(e){p(e)});var y=function(e,n){var o;r._blockEntityCollection=!!i._assetContainer;var a=null!==(o=i._loadingOptions.gaussianSplattingMesh)&&void 0!==o?o:new t.GaussianSplattingMesh("GaussianSplatting",null,r,i._loadingOptions.keepInRam,i._loadingOptions.needsRotationScaleTextures);if(e.trainedWithAntialiasing){var l=a.material;l.kernelSize=.1,l.compensation=!0}a._parentContainer=i._assetContainer,s.push(a),a.updateData(e.data,e.sh,{flipY:!1},void 0,e.shDegree),i._loadingOptions.flipY||(a.scaling.y*=-1,a.computeWorldMatrix(!0)),r._blockEntityCollection=!1,i.applyAutoCameraLimits(e,r),n(s)};if(this._loadingOptions.spzLibraryUrl)return function(e){return _(this,void 0,void 0,function(){var n;return g(this,function(r){switch(r.label){case 0:return ys&&bs===e?[4,ys]:[3,2];case 1:case 3:return[2,r.sent()];case 2:return n=t._LoadScriptModuleAsync("import createSpzModule from '".concat(e,"';\n const module = await createSpzModule();\n const returnedValue = module;")),bs=e,ys=n,[4,n]}})})}(this._loadingOptions.spzLibraryUrl).then(function(e){return function(e,n){return _(this,void 0,void 0,function(){return g(this,function(r){switch(r.label){case 0:return[4,t.runCoroutineAsync(xs(e,n,!0),t.createYieldingScheduler())];case 1:return[2,r.sent()]}})})}(e.loadSpzFromBuffer(new Uint8Array(o),{to:e.CoordinateSystem.RUB}),r).then(function(e){return new Promise(function(t){y(e,t)})})});if(v)return Promise.reject(new Error("SPZ V4+ files (NGSP format) are not supported by the native fallback loader. Please provide a valid 'spzLibraryUrl' in the loading options to use the WASM-based SPZ library, or ensure WebAssembly is available in your environment."));var b=new ReadableStream({start:function(e){e.enqueue(new Uint8Array(o)),e.close()}}),x=new DecompressionStream("gzip"),T=b.pipeThrough(x);return new Promise(function(e){new Response(T).arrayBuffer().then(function(n){(function(e,n){var r=new Uint8Array(e),o=new Uint32Array(e.slice(0,12)),a=o[2],i=r[12],s=r[13],l=r[14],u=r[15],c=o[1];if(u||1347635022!=o[0]||c<2||c>4)return new Promise(function(e){e({mode:3,data:new ArrayBuffer(0),hasVertexColors:!1})});for(var f=new ArrayBuffer(32*a),d=1/(1<<s),h=new Int32Array(1),p=new Uint8Array(h.buffer),m=function(e,t){return p[0]=e[t+0],p[1]=e[t+1],p[2]=e[t+2],p[3]=128&e[t+2]?255:0,h[0]*d},v=16,_=new Float32Array(f),g=new Float32Array(f),y=new Uint8ClampedArray(f),b=new Uint8ClampedArray(f),x=0;x<a;x++)_[8*x+0]=m(r,v+0),_[8*x+1]=m(r,v+3),_[8*x+2]=m(r,v+6),v+=9;for(x=0;x<a;x++){for(var T=0;T<3;T++){var A=(r[v+a+3*x+T]-127.5)/38.25;y[32*x+24+T]=t.Scalar.Clamp(255*(.5+gs*A),0,255)}y[32*x+24+3]=r[v+x]}for(v+=4*a,x=0;x<a;x++)g[8*x+3+0]=Math.exp(r[v+0]/16-10),g[8*x+3+1]=Math.exp(r[v+1]/16-10),g[8*x+3+2]=Math.exp(r[v+2]/16-10),v+=3;if(c>=3){var w=Math.SQRT1_2;for(x=0;x<a;x++){for(var M=[r[v+0],r[v+1],r[v+2],r[v+3]],C=M[0]+(M[1]<<8)+(M[2]<<16)+(M[3]<<24),O=[],S=C>>>30,E=C,F=0,R=3;R>=0;--R)if(R!==S){var L=511&E,I=E>>>9&1;E>>>=10,O[R]=w*(L/511),1===I&&(O[R]=-O[R]),F+=O[R]*O[R]}var P=1-F;O[S]=Math.sqrt(Math.max(P,0));for(var N=[3,0,1,2],B=0;B<4;B++)b[32*x+28+B]=Math.round(127.5+127.5*O[N[B]]);v+=4}}else for(x=0;x<a;x++){var k=r[v+0],D=r[v+1],G=r[v+2],V=k/127.5-1,H=D/127.5-1,U=G/127.5-1;b[32*x+28+1]=k,b[32*x+28+2]=D,b[32*x+28+3]=G;var j=1-(V*V+H*H+U*U);b[32*x+28+0]=127.5+127.5*Math.sqrt(j<0?0:j),v+=3}if(i){var K=3*((i+1)*(i+1)-1),W=Math.ceil(K/16),z=v,q=n.getEngine().getCaps().maxTextureSize,X=Math.ceil(a/q),Y=t.AllocateShBuffers(W,X*q*4*4);for(x=0;x<a;x++)for(var Q=0;Q<K;Q++){var Z=r[z++],J=Math.floor(Q/16);Y[J][Q%16+16*x]=Z}return new Promise(function(e){e({mode:0,data:f,hasVertexColors:!1,sh:Y,shDegree:i,trainedWithAntialiasing:!!l})})}return new Promise(function(e){e({mode:0,data:f,hasVertexColors:!1,trainedWithAntialiasing:!!l})})})(n,r,i._loadingOptions).then(function(t){y(t,e)})}).catch(function(){p(e)})})},e.prototype.applyAutoCameraLimits=function(e,t){var n;if(!this._loadingOptions.disableAutoCameraLimits&&(void 0!==e.safeOrbitCameraRadiusMin||void 0!==e.safeOrbitCameraElevationMinMax)&&"ArcRotateCamera"===(null===(n=t.activeCamera)||void 0===n?void 0:n.getClassName())){var r=t.activeCamera;e.safeOrbitCameraElevationMinMax&&(r.lowerBetaLimit=.5*Math.PI-e.safeOrbitCameraElevationMinMax[1],r.upperBetaLimit=.5*Math.PI-e.safeOrbitCameraElevationMinMax[0]),e.safeOrbitCameraRadiusMin&&(r.lowerRadiusLimit=e.safeOrbitCameraRadiusMin)}},e.prototype.loadAssetContainerAsync=function(e,n,r){var o=this,a=new t.AssetContainer(e);return this._assetContainer=a,this.importMeshAsync(null,e,n,r).then(function(e){for(var t=0,n=e.meshes;t<n.length;t++){var r=n[t];a.meshes.push(r)}return o._assetContainer=null,a}).catch(function(e){throw o._assetContainer=null,e})},e.prototype.loadAsync=function(e,t,n){return this.importMeshAsync(null,e,t,n).then(function(){})},e._ConvertPLYToSplat=function(e){var n=this,r=new Uint8Array(e),o=(new TextDecoder).decode(r.slice(0,10240)),a=o.indexOf("end_header\n");if(a<0||!o)return new Promise(function(t){t({mode:0,data:e,rawSplat:!0})});var i=parseInt(/element vertex (\d+)\n/.exec(o)[1]),s=/element face (\d+)\n/.exec(o),l=0;s&&(l=parseInt(s[1]));var u=/element chunk (\d+)\n/.exec(o),c=0;u&&(c=parseInt(u[1]));for(var f=0,d=0,h={double:8,int:4,uint:4,float:4,short:2,ushort:2,uchar:1,list:0},p=1,m=[],y=[],b=o.slice(0,a).split("\n"),x={},T=0,A=b;T<A.length;T++){var w=A[T];if(w.startsWith("property ")){var M=w.split(" "),C=M[1],O=M[2];if(1==p)y.push({name:O,type:C,offset:d}),d+=h[C];else if(0==p)m.push({name:O,type:C,offset:f}),f+=h[C];else if(2==p)m.push({name:O,type:C,offset:f});else if(3==p){var S=new DataView(e,d,2*h.float);x.safeOrbitCameraElevationMinMax=[S.getFloat32(0,!0),S.getFloat32(4,!0)]}else 4==p?(S=new DataView(e,d,h.float),x.safeOrbitCameraRadiusMin=S.getFloat32(0,!0)):5==p&&(S=new DataView(e,d,h.uchar),"up_axis"==O?x.upAxis=0==S.getUint8(0)?"X":1==S.getUint8(0)?"Y":"Z":"chirality"==O&&(x.chirality=0==S.getUint8(0)?"LeftHanded":"RightHanded"));h[C]||t.Logger.Warn("Unsupported property type: ".concat(C,"."))}else w.startsWith("element ")&&("chunk"==(C=w.split(" ")[1])?p=1:"vertex"==C?p=0:"sh"==C?p=2:"safe_orbit_camera_elevation_min_max_radians"==C?p=3:"safe_orbit_camera_radius_min"==C?p=4:"up_axis"!=C&&"chirality"!=C||(p=5))}var E=f,F=d;return t.GaussianSplattingMesh.ConvertPLYWithSHToSplatAsync(e).then(function(t){return _(n,void 0,void 0,function(){var n,r,o,s,u,f,d,h,p,_,y,b,T,A,w;return g(this,function(g){switch(g.label){case 0:if(n=new DataView(e,a+11),r=F*c+E*i,o=[],l)for(s=0;s<l;s++)if(3==(u=n.getUint8(r))){for(r+=1,f=0;f<u;f++)d=n.getUint32(r+4*(2-f),!0),o.push(d);r+=12}return c?[4,new Promise(function(e){e({mode:0,data:t.buffer,sh:t.sh,shDegree:t.shDegree,faces:o,hasVertexColors:!1,compressed:!0,rawSplat:!1})})]:[3,2];case 1:case 3:return[2,g.sent()];case 2:for(h=0,p=0,_=["x","y","z","scale_0","scale_1","scale_2","opacity","rot_0","rot_1","rot_2","rot_3"],y=["red","green","blue","f_dc_0","f_dc_1","f_dc_2"],b=0;b<m.length;b++)T=m[b],_.includes(T.name)&&h++,y.includes(T.name)&&p++;return A=h==_.length&&3==p,w=l?2:A?0:1,[4,new Promise(function(e){e(v(v({},x),{mode:w,data:t.buffer,sh:t.sh,shDegree:t.shDegree,faces:o,hasVertexColors:!!p,compressed:!1,rawSplat:!1}))})]}})})})},e._DefaultLoadingOptions={keepInRam:!1,flipY:!1,needsRotationScaleTextures:!1,spzLibraryUrl:"object"==typeof WebAssembly?"https://unpkg.com/@adobe/spz@0.2.2/dist/spz.js":void 0},e}();t.RegisterSceneLoaderPlugin(new Ts);var As={__proto__:null,SPLATFileLoader:Ts};function ws(){var e=this;t.RegisterSceneLoaderPlugin(v(v({},b),{createPlugin:function(t){return _(e,void 0,void 0,function(){return g(this,function(e){switch(e.label){case 0:return[4,Promise.resolve().then(function(){return M})];case 1:return[2,new(0,e.sent().BVHFileLoader)(t[b.name])]}})})}})),t.RegisterSceneLoaderPlugin(v(v({},Dt),{createPlugin:function(t){return _(e,void 0,void 0,function(){return g(this,function(e){switch(e.label){case 0:return[4,Promise.resolve().then(function(){return Jt})];case 1:return[2,new(0,e.sent().FBXFileLoader)(t[Dt.name])]}})})}})),t.RegisterSceneLoaderPlugin(v(v({},ln),{createPlugin:function(t){return _(e,void 0,void 0,function(){return g(this,function(e){switch(e.label){case 0:return[4,Promise.resolve().then(function(){return br})];case 1:return[2,new(0,e.sent().GLTFFileLoader)(t[ln.name])]}})})}})),function(){var e=this;er("EXT_lights_image_based"),$n("EXT_lights_image_based",!0,function(t){return _(e,void 0,void 0,function(){return g(this,function(e){switch(e.label){case 0:return[4,Promise.resolve().then(function(){return Pr})];case 1:return[2,new(0,e.sent().EXT_lights_image_based)(t)]}})})}),er("EXT_mesh_gpu_instancing"),$n("EXT_mesh_gpu_instancing",!0,function(t){return _(e,void 0,void 0,function(){return g(this,function(e){switch(e.label){case 0:return[4,Promise.resolve().then(function(){return kr})];case 1:return[2,new(0,e.sent().EXT_mesh_gpu_instancing)(t)]}})})}),er("EXT_meshopt_compression"),$n("EXT_meshopt_compression",!0,function(t){return _(e,void 0,void 0,function(){return g(this,function(e){switch(e.label){case 0:return[4,Promise.resolve().then(function(){return Vr})];case 1:return[2,new(0,e.sent().EXT_meshopt_compression)(t)]}})})}),er("EXT_texture_avif"),$n("EXT_texture_avif",!0,function(t){return _(e,void 0,void 0,function(){return g(this,function(e){switch(e.label){case 0:return[4,Promise.resolve().then(function(){return zr})];case 1:return[2,new(0,e.sent().EXT_texture_avif)(t)]}})})}),er("EXT_texture_webp"),$n("EXT_texture_webp",!0,function(t){return _(e,void 0,void 0,function(){return g(this,function(e){switch(e.label){case 0:return[4,Promise.resolve().then(function(){return jr})];case 1:return[2,new(0,e.sent().EXT_texture_webp)(t)]}})})}),er("ExtrasAsMetadata"),$n("ExtrasAsMetadata",!1,function(t){return _(e,void 0,void 0,function(){return g(this,function(e){switch(e.label){case 0:return[4,Promise.resolve().then(function(){return ki})];case 1:return[2,new(0,e.sent().ExtrasAsMetadata)(t)]}})})}),er("KHR_animation_pointer"),$n("KHR_animation_pointer",!0,function(t){return _(e,void 0,void 0,function(){return g(this,function(e){switch(e.label){case 0:return[4,Promise.resolve().then(function(){return Za})];case 1:return[2,new(0,e.sent().KHR_animation_pointer)(t)]}})})}),er("KHR_draco_mesh_compression"),$n("KHR_draco_mesh_compression",!0,function(t){return _(e,void 0,void 0,function(){return g(this,function(e){switch(e.label){case 0:return[4,Promise.resolve().then(function(){return Jr})];case 1:return[2,new(0,e.sent().KHR_draco_mesh_compression)(t)]}})})}),er("KHR_interactivity"),$n("KHR_interactivity",!0,function(t){return _(e,void 0,void 0,function(){return g(this,function(e){switch(e.label){case 0:return[4,Promise.resolve().then(function(){return Ai})];case 1:return[2,new(0,e.sent().KHR_interactivity)(t)]}})})}),er("KHR_lights_punctual"),$n("KHR_lights_punctual",!0,function(t){return _(e,void 0,void 0,function(){return g(this,function(e){switch(e.label){case 0:return[4,Promise.resolve().then(function(){return to})];case 1:return[2,new(0,e.sent().KHR_lights)(t)]}})})}),er("EXT_lights_area"),$n("EXT_lights_area",!0,function(t){return _(e,void 0,void 0,function(){return g(this,function(e){switch(e.label){case 0:return[4,Promise.resolve().then(function(){return oo})];case 1:return[2,new(0,e.sent().EXT_lights_area)(t)]}})})}),er("EXT_lights_ies"),$n("EXT_lights_ies",!0,function(t){return _(e,void 0,void 0,function(){return g(this,function(e){switch(e.label){case 0:return[4,Promise.resolve().then(function(){return Yr})];case 1:return[2,new(0,e.sent().EXT_lights_ies)(t)]}})})}),er("KHR_materials_anisotropy"),$n("KHR_materials_anisotropy",!0,function(t){return _(e,void 0,void 0,function(){return g(this,function(e){switch(e.label){case 0:return[4,Promise.resolve().then(function(){return Ao})];case 1:return[2,new(0,e.sent().KHR_materials_anisotropy)(t)]}})})}),er("KHR_materials_clearcoat"),$n("KHR_materials_clearcoat",!0,function(t){return _(e,void 0,void 0,function(){return g(this,function(e){switch(e.label){case 0:return[4,Promise.resolve().then(function(){return po})];case 1:return[2,new(0,e.sent().KHR_materials_clearcoat)(t)]}})})}),er("KHR_materials_diffuse_roughness"),$n("KHR_materials_diffuse_roughness",!0,function(t){return _(e,void 0,void 0,function(){return g(this,function(e){switch(e.label){case 0:return[4,Promise.resolve().then(function(){return sa})];case 1:return[2,new(0,e.sent().KHR_materials_diffuse_roughness)(t)]}})})}),er("KHR_materials_diffuse_transmission"),$n("KHR_materials_diffuse_transmission",!0,function(t){return _(e,void 0,void 0,function(){return g(this,function(e){switch(e.label){case 0:return[4,Promise.resolve().then(function(){return Yo})];case 1:return[2,new(0,e.sent().KHR_materials_diffuse_transmission)(t)]}})})}),er("KHR_materials_dispersion"),$n("KHR_materials_dispersion",!0,function(t){return _(e,void 0,void 0,function(){return g(this,function(e){switch(e.label){case 0:return[4,Promise.resolve().then(function(){return oa})];case 1:return[2,new(0,e.sent().KHR_materials_dispersion)(t)]}})})}),er("KHR_materials_emissive_strength"),$n("KHR_materials_emissive_strength",!0,function(t){return _(e,void 0,void 0,function(){return g(this,function(e){switch(e.label){case 0:return[4,Promise.resolve().then(function(){return Co})];case 1:return[2,new(0,e.sent().KHR_materials_emissive_strength)(t)]}})})}),er("KHR_materials_ior"),$n("KHR_materials_ior",!0,function(t){return _(e,void 0,void 0,function(){return g(this,function(e){switch(e.label){case 0:return[4,Promise.resolve().then(function(){return Do})];case 1:return[2,new(0,e.sent().KHR_materials_ior)(t)]}})})}),er("KHR_materials_iridescence"),$n("KHR_materials_iridescence",!0,function(t){return _(e,void 0,void 0,function(){return g(this,function(e){switch(e.label){case 0:return[4,Promise.resolve().then(function(){return bo})];case 1:return[2,new(0,e.sent().KHR_materials_iridescence)(t)]}})})}),er("KHR_materials_pbrSpecularGlossiness"),$n("KHR_materials_pbrSpecularGlossiness",!0,function(t){return _(e,void 0,void 0,function(){return g(this,function(e){switch(e.label){case 0:return[4,Promise.resolve().then(function(){return so})];case 1:return[2,new(0,e.sent().KHR_materials_pbrSpecularGlossiness)(t)]}})})}),er("KHR_materials_sheen"),$n("KHR_materials_sheen",!0,function(t){return _(e,void 0,void 0,function(){return g(this,function(e){switch(e.label){case 0:return[4,Promise.resolve().then(function(){return Eo})];case 1:return[2,new(0,e.sent().KHR_materials_sheen)(t)]}})})}),er("KHR_materials_specular"),$n("KHR_materials_specular",!0,function(t){return _(e,void 0,void 0,function(){return g(this,function(e){switch(e.label){case 0:return[4,Promise.resolve().then(function(){return No})];case 1:return[2,new(0,e.sent().KHR_materials_specular)(t)]}})})}),er("KHR_materials_transmission"),$n("KHR_materials_transmission",!0,function(t){return _(e,void 0,void 0,function(){return g(this,function(e){switch(e.label){case 0:return[4,Promise.resolve().then(function(){return zo})];case 1:return[2,new(0,e.sent().KHR_materials_transmission)(t)]}})})}),er("KHR_materials_unlit"),$n("KHR_materials_unlit",!0,function(t){return _(e,void 0,void 0,function(){return g(this,function(e){switch(e.label){case 0:return[4,Promise.resolve().then(function(){return co})];case 1:return[2,new(0,e.sent().KHR_materials_unlit)(t)]}})})}),er("KHR_materials_variants"),$n("KHR_materials_variants",!0,function(t){return _(e,void 0,void 0,function(){return g(this,function(e){switch(e.label){case 0:return[4,Promise.resolve().then(function(){return Ho})];case 1:return[2,new(0,e.sent().KHR_materials_variants)(t)]}})})}),er("KHR_materials_volume"),$n("KHR_materials_volume",!0,function(t){return _(e,void 0,void 0,function(){return g(this,function(e){switch(e.label){case 0:return[4,Promise.resolve().then(function(){return Jo})];case 1:return[2,new(0,e.sent().KHR_materials_volume)(t)]}})})}),er("KHR_mesh_quantization"),$n("KHR_mesh_quantization",!0,function(t){return _(e,void 0,void 0,function(){return g(this,function(e){switch(e.label){case 0:return[4,Promise.resolve().then(function(){return ca})];case 1:return[2,new(0,e.sent().KHR_mesh_quantization)(t)]}})})}),er("KHR_texture_basisu"),$n("KHR_texture_basisu",!0,function(t){return _(e,void 0,void 0,function(){return g(this,function(e){switch(e.label){case 0:return[4,Promise.resolve().then(function(){return ha})];case 1:return[2,new(0,e.sent().KHR_texture_basisu)(t)]}})})}),er("KHR_texture_transform"),$n("KHR_texture_transform",!0,function(t){return _(e,void 0,void 0,function(){return g(this,function(e){switch(e.label){case 0:return[4,Promise.resolve().then(function(){return va})];case 1:return[2,new(0,e.sent().KHR_texture_transform)(t)]}})})}),er("KHR_xmp_json_ld"),$n("KHR_xmp_json_ld",!0,function(t){return _(e,void 0,void 0,function(){return g(this,function(e){switch(e.label){case 0:return[4,Promise.resolve().then(function(){return ya})];case 1:return[2,new(0,e.sent().KHR_xmp_json_ld)(t)]}})})}),er("MSFT_audio_emitter"),$n("MSFT_audio_emitter",!0,function(t){return _(e,void 0,void 0,function(){return g(this,function(e){switch(e.label){case 0:return[4,Promise.resolve().then(function(){return ei})];case 1:return[2,new(0,e.sent().MSFT_audio_emitter)(t)]}})})}),er("MSFT_lod"),$n("MSFT_lod",!0,function(t){return _(e,void 0,void 0,function(){return g(this,function(e){switch(e.label){case 0:return[4,Promise.resolve().then(function(){return ri})];case 1:return[2,new(0,e.sent().MSFT_lod)(t)]}})})}),er("MSFT_minecraftMesh"),$n("MSFT_minecraftMesh",!0,function(t){return _(e,void 0,void 0,function(){return g(this,function(e){switch(e.label){case 0:return[4,Promise.resolve().then(function(){return ii})];case 1:return[2,new(0,e.sent().MSFT_minecraftMesh)(t)]}})})}),er("MSFT_sRGBFactors"),$n("MSFT_sRGBFactors",!0,function(t){return _(e,void 0,void 0,function(){return g(this,function(e){switch(e.label){case 0:return[4,Promise.resolve().then(function(){return ui})];case 1:return[2,new(0,e.sent().MSFT_sRGBFactors)(t)]}})})}),er("KHR_node_visibility"),$n("KHR_node_visibility",!0,function(t){return _(e,void 0,void 0,function(){return g(this,function(e){switch(e.label){case 0:return[4,Promise.resolve().then(function(){return Ci})];case 1:return[2,new(0,e.sent().KHR_node_visibility)(t)]}})})}),er("KHR_node_hoverability"),$n("KHR_node_hoverability",!0,function(t){return _(e,void 0,void 0,function(){return g(this,function(e){switch(e.label){case 0:return[4,Promise.resolve().then(function(){return Pi})];case 1:return[2,new(0,e.sent().KHR_node_hoverability)(t)]}})})}),er("KHR_node_selectability"),$n("KHR_node_selectability",!0,function(t){return _(e,void 0,void 0,function(){return g(this,function(e){switch(e.label){case 0:return[4,Promise.resolve().then(function(){return Ei})];case 1:return[2,new(0,e.sent().KHR_node_selectability)(t)]}})})}),er("KHR_materials_coat"),$n("KHR_materials_coat",!0,function(t){return _(e,void 0,void 0,function(){return g(this,function(e){switch(e.label){case 0:return[4,Promise.resolve().then(function(){return _o})];case 1:return[2,new(0,e.sent().KHR_materials_coat)(t)]}})})}),er("KHR_materials_fuzz"),$n("KHR_materials_fuzz",!0,function(t){return _(e,void 0,void 0,function(){return g(this,function(e){switch(e.label){case 0:return[4,Promise.resolve().then(function(){return Lo})];case 1:return[2,new(0,e.sent().KHR_materials_fuzz)(t)]}})})}),er("KHR_materials_volume_scatter"),$n("KHR_materials_volume_scatter",!0,function(t){return _(e,void 0,void 0,function(){return g(this,function(e){switch(e.label){case 0:return[4,Promise.resolve().then(function(){return ta})];case 1:return[2,new(0,e.sent().KHR_materials_volume_scatter)(t)]}})})})}(),t.RegisterSceneLoaderPlugin(v(v({},Ki),{createPlugin:function(t){return _(e,void 0,void 0,function(){return g(this,function(e){switch(e.label){case 0:return[4,Promise.resolve().then(function(){return zi})];case 1:return[2,new(0,e.sent().OBJFileLoader)(t[Ki.name])]}})})}})),t.RegisterSceneLoaderPlugin(v(v({},Ji),{createPlugin:function(t){return _(e,void 0,void 0,function(){return g(this,function(e){switch(e.label){case 0:return[4,Promise.resolve().then(function(){return As})];case 1:return[2,new(0,e.sent().SPLATFileLoader)(t[Ji.name])]}})})}})),t.RegisterSceneLoaderPlugin(v(v({},Xi),{createPlugin:function(){return _(e,void 0,void 0,function(){return g(this,function(e){switch(e.label){case 0:return[4,Promise.resolve().then(function(){return Qi})];case 1:return[2,new(0,e.sent().STLFileLoader)]}})})}}))}var Ms={__proto__:null,registerBuiltInLoaders:ws},Cs="undefined"!=typeof global?global:"undefined"!=typeof window?window:void 0;if(void 0!==Cs)for(var Os in C)Cs.BABYLON[Os]||(Cs.BABYLON[Os]=C[Os]);var Ss="undefined"!=typeof global?global:"undefined"!=typeof window?window:void 0;if(void 0!==Ss)for(var Es in Ss.BABYLON=Ss.BABYLON||{},Ms)Ss.BABYLON[Es]=Ms[Es];var Fs="undefined"!=typeof global?global:"undefined"!=typeof window?window:void 0;if(void 0!==Fs){for(var Rs in Fs.BABYLON=Fs.BABYLON||{},Tn)Fs.BABYLON[Rs]=Tn[Rs];for(var Rs in an)Fs.BABYLON[Rs]=an[Rs]}var Ls,Is,Ps="undefined"!=typeof global?global:"undefined"!=typeof window?window:void 0;if(void 0!==Ps)for(var Ns in Ps.BABYLON=Ps.BABYLON||{},Ps.BABYLON.GLTF1=Ps.BABYLON.GLTF1||{},Qn)Ps.BABYLON.GLTF1[Ns]=Qn[Ns];var Bs=v({},Vi),ks=v(v({},{__proto__:null}),((Ls={}).Extensions=Bs,Ls)),Ds=v(v({},Hi),((Is={}).Loader=ks,Is)),Gs="undefined"!=typeof global?global:"undefined"!=typeof window?window:void 0;if(void 0!==Gs){Gs.BABYLON=Gs.BABYLON||{};var Vs=Gs.BABYLON;Vs.GLTF2=Vs.GLTF2||{},Vs.GLTF2.Loader=Vs.GLTF2.Loader||{},Vs.GLTF2.Loader.Extensions=Vs.GLTF2.Loader.Extensions||{};var Hs=["Loader"];for(var Us in Bs)Vs.GLTF2.Loader.Extensions[Us]=Bs[Us],Hs.push(Us);for(var Us in ks)"Extensions"!==Us&&(Vs.GLTF2.Loader[Us]=ks[Us],Hs.push(Us));for(var Us in Ds)Hs.indexOf(Us)>-1||(Vs.GLTF2[Us]=Ds[Us])}var js="undefined"!=typeof global?global:"undefined"!=typeof window?window:void 0;if(void 0!==js)for(var Ks in qi)js.BABYLON[Ks]||(js.BABYLON[Ks]=qi[Ks]);var Ws="undefined"!=typeof global?global:"undefined"!=typeof window?window:void 0;if(void 0!==Ws)for(var zs in Zi)Ws.BABYLON[zs]||(Ws.BABYLON[zs]=Zi[zs]);e.BVHFileLoader=x,e.FBXFileLoader=Gt,e.FBXFileLoaderMetadata=Dt,e.GLTF1=Qn,e.GLTF2=Ds,e.GLTFFileLoader=hn,e.GLTFLoaderDefaultOptions=fn,e.GLTFValidation=on,e.GaussianSplattingStream=_s,e.MTLFileLoader=Ui,e.OBJFileLoader=Wi,e.ReadBvh=h,e.SPLATFileLoader=Ts,e.STLFileLoader=Yi,e.SolidParser=ji,e.registerBuiltInLoaders=ws});
|
|
2
2
|
//# sourceMappingURL=babylonjs.loaders.min.js.map
|