babylonjs-serializers 9.4.1 → 9.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/babylon.glTF2Serializer.min.js +2 -2
- package/babylon.glTF2Serializer.min.js.map +1 -1
- package/babylon.objSerializer.min.js +2 -2
- package/babylon.objSerializer.min.js.map +1 -1
- package/babylon.stlSerializer.min.js +2 -2
- package/babylon.stlSerializer.min.js.map +1 -1
- package/babylon.threemfSerializer.min.js +2 -2
- package/babylon.threemfSerializer.min.js.map +1 -1
- package/babylon.usdzSerializer.min.js +2 -2
- package/babylon.usdzSerializer.min.js.map +1 -1
- package/babylonjs.serializers.js +2 -2
- package/babylonjs.serializers.js.map +1 -0
- package/babylonjs.serializers.min.js +2 -2
- package/babylonjs.serializers.min.js.map +1 -1
- package/package.json +6 -11
- package/rollup.config.umd.mjs +25 -0
- package/babylon.glTF2Serializer.js +0 -2
- package/babylon.objSerializer.js +0 -2
- package/babylon.stlSerializer.js +0 -2
- package/babylon.threemfSerializer.js +0 -2
- package/babylon.usdzSerializer.js +0 -2
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("babylonjs")):"function"==typeof define&&define.amd?define("babylonjs-serializers",["babylonjs"],t):"object"==typeof exports?exports["babylonjs-serializers"]=t(require("babylonjs")):e.SERIALIZERS=t(e.BABYLON)}("undefined"!=typeof self?self:"undefined"!=typeof global?global:this,e=>(()=>{"use strict";var t={597(t){t.exports=e}},r={};function n(e){var s=r[e];if(void 0!==s)return s.exports;var o=r[e]={exports:{}};return t[e](o,o.exports,n),o.exports}n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var s={};n.d(s,{default:()=>Mt});var o={};n.r(o),n.d(o,{__IGLTFExporterExtension:()=>h});var i={};n.r(i),n.d(i,{GLTFData:()=>p});var a={};n.r(a),n.d(a,{GLTF2Export:()=>oe});var u={};n.r(u),n.d(u,{EXT_lights_area:()=>ve,EXT_mesh_gpu_instancing:()=>ue,EXT_texture_avif:()=>Tt,EXT_texture_webp:()=>_t,KHR_draco_mesh_compression:()=>he,KHR_lights_punctual:()=>ge,KHR_materials_anisotropy:()=>Me,KHR_materials_clearcoat:()=>Ce,KHR_materials_coat:()=>Oe,KHR_materials_diffuse_roughness:()=>ct,KHR_materials_diffuse_transmission:()=>Pe,KHR_materials_dispersion:()=>Le,KHR_materials_emissive_strength:()=>Ke,KHR_materials_fuzz:()=>Ze,KHR_materials_ior:()=>Ge,KHR_materials_iridescence:()=>He,KHR_materials_openpbr:()=>ht,KHR_materials_sheen:()=>je,KHR_materials_specular:()=>$e,KHR_materials_transmission:()=>tt,KHR_materials_unlit:()=>nt,KHR_materials_volume:()=>ot,KHR_materials_volume_scatter:()=>at,KHR_texture_basisu:()=>xt,KHR_texture_transform:()=>pt});var c={};n.r(c),n.d(c,{EXT_lights_area:()=>ve,EXT_mesh_gpu_instancing:()=>ue,EXT_texture_avif:()=>Tt,EXT_texture_webp:()=>_t,GLTF2Export:()=>oe,GLTFData:()=>p,KHR_draco_mesh_compression:()=>he,KHR_lights_punctual:()=>ge,KHR_materials_anisotropy:()=>Me,KHR_materials_clearcoat:()=>Ce,KHR_materials_coat:()=>Oe,KHR_materials_diffuse_roughness:()=>ct,KHR_materials_diffuse_transmission:()=>Pe,KHR_materials_dispersion:()=>Le,KHR_materials_emissive_strength:()=>Ke,KHR_materials_fuzz:()=>Ze,KHR_materials_ior:()=>Ge,KHR_materials_iridescence:()=>He,KHR_materials_openpbr:()=>ht,KHR_materials_sheen:()=>je,KHR_materials_specular:()=>$e,KHR_materials_transmission:()=>tt,KHR_materials_unlit:()=>nt,KHR_materials_volume:()=>ot,KHR_materials_volume_scatter:()=>at,KHR_texture_basisu:()=>xt,KHR_texture_transform:()=>pt,_ConvertToGLTFPBRMetallicRoughness:()=>R,_SolveMetallic:()=>A});var l={};n.r(l),n.d(l,{EXT_lights_area:()=>ve,EXT_mesh_gpu_instancing:()=>ue,EXT_texture_avif:()=>Tt,EXT_texture_webp:()=>_t,GLTF2Export:()=>oe,GLTFData:()=>p,KHR_draco_mesh_compression:()=>he,KHR_lights_punctual:()=>ge,KHR_materials_anisotropy:()=>Me,KHR_materials_clearcoat:()=>Ce,KHR_materials_coat:()=>Oe,KHR_materials_diffuse_roughness:()=>ct,KHR_materials_diffuse_transmission:()=>Pe,KHR_materials_dispersion:()=>Le,KHR_materials_emissive_strength:()=>Ke,KHR_materials_fuzz:()=>Ze,KHR_materials_ior:()=>Ge,KHR_materials_iridescence:()=>He,KHR_materials_openpbr:()=>ht,KHR_materials_sheen:()=>je,KHR_materials_specular:()=>$e,KHR_materials_transmission:()=>tt,KHR_materials_unlit:()=>nt,KHR_materials_volume:()=>ot,KHR_materials_volume_scatter:()=>at,KHR_texture_basisu:()=>xt,KHR_texture_transform:()=>pt,_ConvertToGLTFPBRMetallicRoughness:()=>R,_SolveMetallic:()=>A,__IGLTFExporterExtension:()=>h});var h=0,f=n(597),p=function(){function e(){this.files={}}return Object.defineProperty(e.prototype,"glTFFiles",{get:function(){return this.files},enumerable:!1,configurable:!0}),e.prototype.downloadFiles=function(){for(var e in this.files){var t=this.files[e],r=new Blob([t],{type:(0,f.GetMimeType)(e)});f.Tools.Download(r,e)}},e}(),d=function(){return d=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var s in t=arguments[r])Object.prototype.hasOwnProperty.call(t,s)&&(e[s]=t[s]);return e},d.apply(this,arguments)};function x(e,t,r,n){return new(r||(r=Promise))(function(s,o){function i(e){try{u(n.next(e))}catch(e){o(e)}}function a(e){try{u(n.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?s(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(i,a)}u((n=n.apply(e,t||[])).next())})}function g(e,t){var r,n,s,o={label:0,sent:function(){if(1&s[0])throw s[1];return s[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=a(0),i.throw=a(1),i.return=a(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(o=0)),o;)try{if(r=1,n&&(s=2&a[0]?n.return:a[0]?n.throw||((s=n.return)&&s.call(n),0):n.next)&&!(s=s.call(n,a[1])).done)return s;switch(n=0,s&&(a=[2&a[0],s.value]),a[0]){case 0:case 1:s=a;break;case 4:return o.label++,{value:a[1],done:!1};case 5:o.label++,n=a[1],a=[0];continue;case 7:a=o.ops.pop(),o.trys.pop();continue;default:if(!((s=(s=o.trys).length>0&&s[s.length-1])||6!==a[0]&&2!==a[0])){o=0;continue}if(3===a[0]&&(!s||a[1]>s[0]&&a[1]<s[3])){o.label=a[1];break}if(6===a[0]&&o.label<s[1]){o.label=s[1],s=a;break}if(s&&o.label<s[2]){o.label=s[2],o.ops.push(a);break}s[2]&&o.ops.pop(),o.trys.pop();continue}a=t.call(e,o)}catch(e){a=[6,e],n=0}finally{r=s=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}}function _(e,t,r){if(r||2===arguments.length)for(var n,s=0,o=t.length;s<o;s++)!n&&s in t||(n||(n=Array.prototype.slice.call(t,0,s)),n[s]=t[s]);return e.concat(n||Array.prototype.slice.call(t))}Object.create,Object.create,"function"==typeof SuppressedError&&SuppressedError;var m=1e-6,T=new f.Color3(.04,.04,.04),y=1024,v=f.Color3.White(),b=f.Color3.BlackReadOnly;function w(e){switch(e){case"image/jpeg":case"image/png":case"image/webp":case"image/avif":case"image/ktx2":return!0;default:return!1}}function M(e){return x(this,void 0,void 0,function(){var t,r,n,s;return g(this,function(o){switch(o.label){case 0:if(!(t=e.getInternalTexture())||1!==t.source)return[2,null];if(t.invertY)return[2,null];r=t._buffer,s=e.mimeType,o.label=1;case 1:return o.trys.push([1,12,,13]),r?[3,3]:[4,f.Tools.LoadFileAsync(t.url)];case 2:return n=o.sent(),s=(0,f.GetMimeType)(t.url)||s,[3,11];case 3:return ArrayBuffer.isView(r)?(n=r.buffer.slice(r.byteOffset,r.byteOffset+r.byteLength),[3,11]):[3,4];case 4:return r instanceof ArrayBuffer?(n=r,[3,11]):[3,5];case 5:return r instanceof Blob?[4,r.arrayBuffer()]:[3,7];case 6:return n=o.sent(),s=r.type||s,[3,11];case 7:return"string"!=typeof r?[3,9]:[4,f.Tools.LoadFileAsync(r)];case 8:return n=o.sent(),s=(0,f.GetMimeType)(r)||s,[3,11];case 9:return"undefined"!=typeof HTMLImageElement&&r instanceof HTMLImageElement?[4,f.Tools.LoadFileAsync(r.src)]:[3,11];case 10:n=o.sent(),s=(0,f.GetMimeType)(r.src)||s,o.label=11;case 11:return[3,13];case 12:return o.sent(),[2,null];case 13:return n&&w(s)?[2,new Blob([n],{type:s})]:[2,null]}})})}function A(e,t,r){if(t<T.r)return 0;var n=T.r,s=e*r/(1-T.r)+t-2*T.r,o=s*s-4*n*(T.r-t);return f.Scalar.Clamp((-s+Math.sqrt(o))/(2*n),0,1)}function R(e){var t=e.diffuseColor.toLinearSpace(e.getScene().getEngine().useExactSrgbConversions).scale(.5),r=e.alpha,n=f.Scalar.Clamp(e.specularPower,0,y),s=(0,f.SpecularPowerToRoughness)(n);return{baseColorFactor:[t.r,t.g,t.b,r],metallicFactor:0,roughnessFactor:s}}function E(e,t){t.needAlphaBlending()?e.alphaMode="BLEND":t.needAlphaTesting()&&(e.alphaMode="MASK",e.alphaCutoff=t.alphaCutOff)}function C(e,t,r){for(var n=new Uint8Array(e*t*4),s=0;s<n.length;s+=4)n[s]=n[s+1]=n[s+2]=n[s+3]=255;return f.RawTexture.CreateRGBATexture(n,e,t,r)}function I(e){if(e instanceof Uint8Array){for(var t=e.length,r=new Float32Array(e.length),n=0;n<t;++n)r[n]=e[n]/255;return r}if(e instanceof Float32Array)return e;throw new Error("Unsupported pixel format!")}var V=function(){function e(e){this._exporter=e,this._textureMap=new Map,this._internalTextureToImage={}}return e.prototype.getTextureInfo=function(e){var t;return e&&null!==(t=this._textureMap.get(e.uniqueId))&&void 0!==t?t:null},e.prototype.exportStandardMaterialAsync=function(e,t){return x(this,void 0,void 0,function(){var r,n,s,o,i,a,u,c;return g(this,function(l){switch(l.label){case 0:return r=R(e),n={name:e.name},null==e.backFaceCulling||e.backFaceCulling||(e.twoSidedLighting||f.Tools.Warn(e.name+": Back-face culling disabled and two-sided lighting disabled is not supported in glTF."),n.doubleSided=!0),t?(s=[],(o=e.diffuseTexture)&&s.push(this.exportTextureAsync(o).then(function(e){e&&(r.baseColorTexture=e)})),(i=e.bumpTexture)&&s.push(this.exportTextureAsync(i).then(function(e){e&&(n.normalTexture=e,1!==i.level&&(n.normalTexture.scale=i.level))})),(a=e.emissiveTexture)&&(n.emissiveFactor=[1,1,1],s.push(this.exportTextureAsync(a).then(function(e){e&&(n.emissiveTexture=e)}))),(u=e.ambientTexture)&&s.push(this.exportTextureAsync(u).then(function(e){if(e){var t={index:e.index};n.occlusionTexture=t}})),s.length>0?(this._exporter._materialNeedsUVsSet.add(e),[4,Promise.all(s)]):[3,2]):[3,2];case 1:l.sent(),l.label=2;case 2:return(e.alpha<1||e.opacityTexture)&&(e.alphaMode===f.Constants.ALPHA_COMBINE?n.alphaMode="BLEND":f.Tools.Warn(e.name+": glTF 2.0 does not support alpha mode: "+e.alphaMode.toString())),e.emissiveColor&&!e.emissiveColor.equalsWithEpsilon(b,m)&&(n.emissiveFactor=e.emissiveColor.asArray()),n.pbrMetallicRoughness=r,E(n,e),[4,this._finishMaterialAsync(n,e)];case 3:return l.sent(),(c=this._exporter._materials).push(n),[2,c.length-1]}})})},e.prototype._finishMaterialAsync=function(e,t){return x(this,void 0,void 0,function(){var r,n,s,o,i;return g(this,function(a){switch(a.label){case 0:return[4,this._exporter._extensionsPostExportMaterialAdditionalTexturesAsync("exportMaterial",e,t)];case 1:for(r=a.sent(),n=[],s=0,o=r;s<o.length;s++)i=o[s],n.push(this.exportTextureAsync(i));return[4,Promise.all(n)];case 2:return a.sent(),[4,this._exporter._extensionsPostExportMaterialAsync("exportMaterial",e,t)];case 3:return a.sent(),[2]}})})},e.prototype._resizeTexturesToSameDimensions=function(e,t,r){var n,s,o=e?e.getSize():{width:0,height:0},i=t?t.getSize():{width:0,height:0};return o.width<i.width?(n=e&&e instanceof f.Texture?f.TextureTools.CreateResizedCopy(e,i.width,i.height,!0):C(i.width,i.height,r),s=t):o.width>i.width?(s=t&&t instanceof f.Texture?f.TextureTools.CreateResizedCopy(t,o.width,o.height,!0):C(o.width,o.height,r),n=e):(n=e,s=t),{texture1:n,texture2:s}},e.prototype._convertSpecularGlossinessTexturesToMetallicRoughnessAsync=function(e,t,r){return x(this,void 0,void 0,function(){var n,s,o,i,a,u,c,l,h,p,d,x,_,T,y,b,w,M,A,R,E,C,V,S,F,B,O,N,U,P,W;return g(this,function(g){switch(g.label){case 0:return n=new Array,e||t?[3,2]:[4,Promise.reject("diffuse and specular glossiness textures are not defined!")];case 1:case 6:case 9:case 11:case 13:return[2,g.sent()];case 2:return(s=e?e.getScene():t?t.getScene():null)?(o=this._resizeTexturesToSameDimensions(e,t,s),i=null===(W=o.texture1)||void 0===W?void 0:W.getSize(),a=void 0,u=void 0,c=i.width,l=i.height,[4,o.texture1.readPixels()]):[3,12];case 3:return h=g.sent(),[4,o.texture2.readPixels()];case 4:return p=g.sent(),h?(a=I(h),[3,7]):[3,5];case 5:return[4,Promise.reject("Failed to retrieve pixels from diffuse texture!")];case 7:return p?(u=I(p),[3,10]):[3,8];case 8:return[4,Promise.reject("Failed to retrieve pixels from specular glossiness texture!")];case 10:for(d=u.byteLength,x=new Uint8Array(d),_=new Uint8Array(d),T=new f.Color3(0,0,0),y=0,b=0,B=0;B<l;++B)for(O=0;O<c;++O)w=4*(c*B+O),M=new f.Color3(a[w],a[w+1],a[w+2]).toLinearSpace(s.getEngine().useExactSrgbConversions).multiply(r.diffuseColor),A=new f.Color3(u[w],u[w+1],u[w+2]).toLinearSpace(s.getEngine().useExactSrgbConversions).multiply(r.specularColor),R=u[w+3]*r.glossiness,E={diffuseColor:M,specularColor:A,glossiness:R},C=this._convertSpecularGlossinessToMetallicRoughness(E),T.r=Math.max(T.r,C.baseColor.r),T.g=Math.max(T.g,C.baseColor.g),T.b=Math.max(T.b,C.baseColor.b),y=Math.max(y,C.metallic),b=Math.max(b,C.roughness),_[w]=255*C.baseColor.r,_[w+1]=255*C.baseColor.g,_[w+2]=255*C.baseColor.b,_[w+3]=o.texture1.hasAlpha?255*a[w+3]:255,x[w]=0,x[w+1]=255*C.roughness,x[w+2]=255*C.metallic,x[w+3]=255;for(V={baseColor:T,metallic:y,roughness:b},S=!1,F=!1,B=0;B<l;++B)for(O=0;O<c;++O)_[N=4*(c*B+O)]/=V.baseColor.r>m?V.baseColor.r:1,_[N+1]/=V.baseColor.g>m?V.baseColor.g:1,_[N+2]/=V.baseColor.b>m?V.baseColor.b:1,U=f.Color3.FromInts(_[N],_[N+1],_[N+2]),P=U.toGammaSpace(s.getEngine().useExactSrgbConversions),_[N]=255*P.r,_[N+1]=255*P.g,_[N+2]=255*P.b,P.equalsWithEpsilon(v,m)||(F=!0),x[N+1]/=V.roughness>m?V.roughness:1,x[N+2]/=V.metallic>m?V.metallic:1,f.Color3.FromInts(255,x[N+1],x[N+2]).equalsWithEpsilon(v,m)||(S=!0);return S&&n.push((0,f.EncodeImageAsync)(x,c,l).then(function(e){V.metallicRoughnessTextureData=e})),F&&n.push((0,f.EncodeImageAsync)(_,c,l).then(function(e){V.baseColorTextureData=e})),[4,Promise.all(n).then(function(){return V})];case 12:return[4,Promise.reject("_ConvertSpecularGlossinessTexturesToMetallicRoughness: Scene from textures is missing!")]}})})},e.prototype._convertSpecularGlossinessToMetallicRoughness=function(e){var t=this._getPerceivedBrightness(e.diffuseColor),r=this._getPerceivedBrightness(e.specularColor),n=1-this._getMaxComponent(e.specularColor),s=A(t,r,n),o=e.diffuseColor.scale(n/(1-T.r)/Math.max(1-s,m)),i=e.specularColor.subtract(T.scale(1-s)).scale(1/Math.max(s,m)),a=f.Color3.Lerp(o,i,s*s);return{baseColor:a=a.clampToRef(0,1,a),metallic:s,roughness:1-e.glossiness}},e.prototype._getPerceivedBrightness=function(e){return Math.sqrt(.299*e.r*e.r+.587*e.g*e.g+.114*e.b*e.b)},e.prototype._getMaxComponent=function(e){return Math.max(e.r,Math.max(e.g,e.b))},e.prototype._convertMetalRoughFactorsToMetallicRoughnessAsync=function(e,t,r,n,s,o,i,a,u){return x(this,void 0,void 0,function(){var c,l,h,p,d,_,m,T,y,v=this;return g(this,function(b){switch(b.label){case 0:return c=[],l={baseColor:e,metallic:t,roughness:r},u&&(i instanceof f.OpenPBRMaterial?(i.geometryOpacityTexture?(h=n&&n.getInternalTexture()?n.getInternalTexture().uniqueId:0,p=i.geometryOpacityTexture&&i.geometryOpacityTexture.getInternalTexture()?i.geometryOpacityTexture.getInternalTexture().uniqueId:0,d=Number("".concat(h).concat(p)),(y=this._textureMap.get(d))?a.baseColorTexture=y:c.push((0,f.MergeTexturesAsync)("baseColorOpacityTexture",(0,f.CreateRGBAConfiguration)(n?(0,f.CreateTextureInput)(n,0):(0,f.CreateConstantInput)(1),n?(0,f.CreateTextureInput)(n,1):(0,f.CreateConstantInput)(1),n?(0,f.CreateTextureInput)(n,2):(0,f.CreateConstantInput)(1),(0,f.CreateTextureInput)(i.geometryOpacityTexture,0)),i.getScene()).then(function(e){return x(v,void 0,void 0,function(){var t;return g(this,function(r){switch(r.label){case 0:return[4,this.exportTextureAsync(e,d)];case 1:return(t=r.sent())&&(a.baseColorTexture=t),[2]}})})}))):n&&c.push(this.exportTextureAsync(n).then(function(e){e&&(a.baseColorTexture=e)})),i._useMetallicFromMetallicTextureBlue&&s?c.push(this.exportTextureAsync(s).then(function(e){e&&(a.metallicRoughnessTexture=e)})):(o||s)&&(_=s&&s.getInternalTexture()?s.getInternalTexture().uniqueId:0,m=o&&o.getInternalTexture()?o.getInternalTexture().uniqueId:0,T=Number("".concat(_).concat(m)),(y=this._textureMap.get(T))?a.metallicRoughnessTexture=y:c.push((0,f.MergeTexturesAsync)("MetalRoughTexture",(0,f.CreateRGBAConfiguration)(i.ambientOcclusionTexture?(0,f.CreateTextureInput)(i.ambientOcclusionTexture,0):(0,f.CreateConstantInput)(1),o?(0,f.CreateTextureInput)(o,0):(0,f.CreateConstantInput)(1),s?(0,f.CreateTextureInput)(s,0):(0,f.CreateConstantInput)(1)),i.getScene()).then(function(e){return x(v,void 0,void 0,function(){var t;return g(this,function(r){switch(r.label){case 0:return[4,this.exportTextureAsync(e,T)];case 1:return(t=r.sent())&&(a.metallicRoughnessTexture=t),[2]}})})})))):(n&&c.push(this.exportTextureAsync(n).then(function(e){e&&(a.baseColorTexture=e)})),s&&c.push(this.exportTextureAsync(s).then(function(e){e&&(a.metallicRoughnessTexture=e)})))),c.length>0?(this._exporter._materialNeedsUVsSet.add(i),[4,Promise.all(c)]):[3,2];case 1:b.sent(),b.label=2;case 2:return[2,l]}})})},e.prototype._getTextureSampler=function(e){var t={};if(!(e&&e instanceof f.Texture))return t;var r=this._getGLTFTextureWrapMode(e.wrapU);10497!==r&&(t.wrapS=r);var n=this._getGLTFTextureWrapMode(e.wrapV);switch(10497!==n&&(t.wrapT=n),e.samplingMode){case f.Texture.LINEAR_LINEAR:t.magFilter=9729,t.minFilter=9729;break;case f.Texture.LINEAR_NEAREST:t.magFilter=9729,t.minFilter=9728;break;case f.Texture.NEAREST_LINEAR:t.magFilter=9728,t.minFilter=9729;break;case f.Texture.NEAREST_LINEAR_MIPLINEAR:t.magFilter=9728,t.minFilter=9987;break;case f.Texture.NEAREST_NEAREST:t.magFilter=9728,t.minFilter=9728;break;case f.Texture.NEAREST_LINEAR_MIPNEAREST:t.magFilter=9728,t.minFilter=9985;break;case f.Texture.LINEAR_NEAREST_MIPNEAREST:t.magFilter=9729,t.minFilter=9984;break;case f.Texture.LINEAR_NEAREST_MIPLINEAR:t.magFilter=9729,t.minFilter=9986;break;case f.Texture.NEAREST_NEAREST_MIPLINEAR:t.magFilter=9728,t.minFilter=9986;break;case f.Texture.LINEAR_LINEAR_MIPLINEAR:t.magFilter=9729,t.minFilter=9987;break;case f.Texture.LINEAR_LINEAR_MIPNEAREST:t.magFilter=9729,t.minFilter=9985;break;case f.Texture.NEAREST_NEAREST_MIPNEAREST:t.magFilter=9728,t.minFilter=9984}return t},e.prototype._getGLTFTextureWrapMode=function(e){switch(e){case f.Texture.WRAP_ADDRESSMODE:return 10497;case f.Texture.CLAMP_ADDRESSMODE:return 33071;case f.Texture.MIRROR_ADDRESSMODE:return 33648;default:return f.Tools.Error("Unsupported Texture Wrap Mode ".concat(e,"!")),10497}},e.prototype._convertSpecGlossFactorsToMetallicRoughnessAsync=function(e,t,r){return x(this,void 0,void 0,function(){var n,s,o,i,a,u,c,l;return g(this,function(h){switch(h.label){case 0:return n={diffuseColor:e._albedoColor,specularColor:e._reflectivityColor,glossiness:e._microSurface},s=e._albedoTexture,o=e._reflectivityTexture,i=e._useMicroSurfaceFromReflectivityMapAlpha,!o||i?[3,2]:[4,Promise.reject("_ConvertPBRMaterial: Glossiness values not included in the reflectivity texture are currently not supported")];case 1:return[2,h.sent()];case 2:return(s||o)&&r?(this._exporter._materialNeedsUVsSet.add(e),a=this._exportTextureSampler(s||o),[4,this._convertSpecularGlossinessTexturesToMetallicRoughnessAsync(s,o,n)]):[3,8];case 3:return u=h.sent(),c=this._exporter._textures,u.baseColorTextureData?[4,this._exportImageAsync("baseColor".concat(c.length),u.baseColorTextureData)]:[3,5];case 4:l=h.sent(),t.baseColorTexture=this._exportTextureInfo(l,a,null==s?void 0:s.coordinatesIndex),h.label=5;case 5:return u.metallicRoughnessTextureData?[4,this._exportImageAsync("metallicRoughness".concat(c.length),u.metallicRoughnessTextureData)]:[3,7];case 6:l=h.sent(),t.metallicRoughnessTexture=this._exportTextureInfo(l,a,null==o?void 0:o.coordinatesIndex),h.label=7;case 7:return[2,u];case 8:return[2,this._convertSpecularGlossinessToMetallicRoughness(n)]}})})},e.prototype.exportPBRMaterialAsync=function(e,t){return x(this,void 0,void 0,function(){var r,n,s,o,i,a,u,c;return g(this,function(l){switch(l.label){case 0:return r={},n={name:e.name},(s=e.isMetallicWorkflow())&&(o=e._albedoColor,i=e.alpha,o&&(r.baseColorFactor=[o.r,o.g,o.b,i])),s?[4,this._convertMetalRoughFactorsToMetallicRoughnessAsync(e._albedoColor,e._metallic,e._roughness,e._albedoTexture,e._metallicTexture,e._metallicTexture,e,r,t)]:[3,2];case 1:return u=l.sent(),[3,4];case 2:return[4,this._convertSpecGlossFactorsToMetallicRoughnessAsync(e,r,t)];case 3:u=l.sent(),l.label=4;case 4:return a=u,[4,this._setMetallicRoughnessPbrMaterialAsync(a,e,n,r,t)];case 5:return l.sent(),[4,this._finishMaterialAsync(n,e)];case 6:return l.sent(),(c=this._exporter._materials).push(n),[2,c.length-1]}})})},e.prototype._setMetallicRoughnessPbrMaterialAsync=function(e,t,r,n,s){return x(this,void 0,void 0,function(){var o,i,a,u,c,l=this;return g(this,function(h){switch(h.label){case 0:return E(r,t),e.baseColor.equalsWithEpsilon(v,m)&&f.Scalar.WithinEpsilon(t.alpha,1,m)||(n.baseColorFactor=[e.baseColor.r,e.baseColor.g,e.baseColor.b,t.alpha]),null!=e.metallic&&1!==e.metallic&&(n.metallicFactor=e.metallic),null!=e.roughness&&1!==e.roughness&&(n.roughnessFactor=e.roughness),null==t.backFaceCulling||t.backFaceCulling||(t._twoSidedLighting||f.Tools.Warn(t.name+": Back-face culling disabled and two-sided lighting disabled is not supported in glTF."),r.doubleSided=!0),s?(o=[],(i=t instanceof f.PBRBaseMaterial?t._bumpTexture:t.geometryNormalTexture)&&o.push(this.exportTextureAsync(i).then(function(e){e&&(r.normalTexture=e,1!==i.level&&(r.normalTexture.scale=i.level))})),(a=t instanceof f.PBRBaseMaterial?t._ambientTexture:t.ambientOcclusionTexture)&&o.push(new Promise(function(e){return x(l,void 0,void 0,function(){var r,s,o,i;return g(this,function(u){switch(u.label){case 0:return t instanceof f.OpenPBRMaterial&&n.metallicRoughnessTexture?(r=this._exportTextureSampler(a),s=this._exporter._textures[n.metallicRoughnessTexture.index].source,o=this._exportTextureInfo(s,r,a.coordinatesIndex),this._textureMap.set(a.uniqueId,o),this._exporter._extensionsPostExportTextures("exporter",o,a),[2,e(o)]):[3,1];case 1:return i=e,[4,this.exportTextureAsync(a)];case 2:return[2,i.apply(void 0,[u.sent()])]}})})}).then(function(e){return x(l,void 0,void 0,function(){var n;return g(this,function(s){return e&&(n={index:e.index,texCoord:e.texCoord,extensions:e.extensions},r.occlusionTexture=n,t instanceof f.PBRBaseMaterial?n.strength=t._ambientTextureStrength:n.strength=t.ambientOcclusionTexture.level),[2]})})})),(u=t instanceof f.PBRBaseMaterial?t._emissiveTexture:t.emissionColorTexture)&&o.push(this.exportTextureAsync(u).then(function(e){e&&(r.emissiveTexture=e)})),o.length>0?(this._exporter._materialNeedsUVsSet.add(t),[4,Promise.all(o)]):[3,2]):[3,2];case 1:h.sent(),h.label=2;case 2:return(c=t instanceof f.PBRBaseMaterial?t._emissiveColor:t.emissionColor).equalsWithEpsilon(b,m)||(r.emissiveFactor=c.asArray()),r.pbrMetallicRoughness=n,[2]}})})},e.prototype.exportOpenPBRMaterialAsync=function(e,t){return x(this,void 0,void 0,function(){var r,n,s,o,i,a;return g(this,function(u){switch(u.label){case 0:return r={},n={name:e.name},s=e.baseColor,o=e.geometryOpacity,s&&(r.baseColorFactor=[s.r,s.g,s.b,o]),[4,this._convertMetalRoughFactorsToMetallicRoughnessAsync(e.baseColor,e.baseMetalness,e.specularRoughness,e.baseColorTexture,e.baseMetalnessTexture,e.specularRoughnessTexture,e,r,t)];case 1:return i=u.sent(),[4,this._setMetallicRoughnessPbrMaterialAsync(i,e,n,r,t)];case 2:return u.sent(),[4,this._finishMaterialAsync(n,e)];case 3:return u.sent(),(a=this._exporter._materials).push(n),[2,a.length-1]}})})},e.prototype.exportTextureAsync=function(e){return x(this,arguments,void 0,function(e,t){var r,n,s;return void 0===t&&(t=null),g(this,function(o){switch(o.label){case 0:return(r=this._textureMap.get(null!=t?t:e.uniqueId))?[2,r]:(n=this._exportTextureSampler(e),[4,this._exportTextureImageAsync(e)]);case 1:return s=o.sent(),r=this._exportTextureInfo(s,n,e.coordinatesIndex),this._textureMap.set(null!=t?t:e.uniqueId,r),this._exporter._extensionsPostExportTextures("exporter",r,e),[2,r]}})})},e.prototype._exportTextureImageAsync=function(e){return x(this,void 0,void 0,function(){var t,r,n,s,o,i=this;return g(this,function(a){switch(a.label){case 0:return t=null!==(o=e.mimeType)&&void 0!==o?o:"none",r=this._internalTextureToImage,n=e.getInternalTexture().uniqueId,r[n]=r[n]||{},void 0===(s=r[n][t])&&(s=x(i,void 0,void 0,function(){var r,n,s,o,i;return g(this,function(a){switch(a.label){case 0:return[4,M(e)];case 1:return!(r=a.sent())||"none"!==t&&r.type!==t?[3,3]:[4,this._exportImageAsync(e.name,r)];case 2:case 6:return[2,a.sent()];case 3:return n="image/png","none"!==t&&(w(t)?n=t:(n="image/png",f.Tools.Warn("Unsupported media type: ".concat(t,". Exporting texture as PNG.")))),s=e.getSize(),[4,(0,f.GetTextureDataAsync)(e)];case 4:return o=a.sent(),[4,(0,f.EncodeImageAsync)(o,s.width,s.height,n)];case 5:return i=a.sent(),[4,this._exportImageAsync(e.name,i)]}})}),r[n][t]=s),[4,s];case 1:return[2,a.sent()]}})})},e.prototype._exportImageAsync=function(e,t){return x(this,void 0,void 0,function(){var r,n,s,o,i,a,u;return g(this,function(c){switch(c.label){case 0:return r=this._exporter._images,this._exporter._shouldUseGlb?(n={name:e,mimeType:t.type,bufferView:void 0},[4,t.arrayBuffer()]):[3,2];case 1:return s=c.sent(),o=this._exporter._bufferManager.createBufferView(new Uint8Array(s)),this._exporter._bufferManager.setBufferView(n,o),[3,3];case 2:i=e.replace(/\.\/|\/|\.\\|\\/g,"_"),a=function(e){switch(e){case"image/jpeg":return".jpg";case"image/png":return".png";case"image/webp":return".webp";case"image/avif":return".avif";case"image/ktx2":return".ktx2"}}(t.type),u=i+a,r.some(function(e){return e.uri===u})&&(u="".concat(i,"_").concat(f.Tools.RandomId()).concat(a)),n={name:e,uri:u},this._exporter._imageData[u]=t,c.label=3;case 3:return r.push(n),[2,r.length-1]}})})},e.prototype._exportTextureInfo=function(e,t,r){var n=this._exporter._textures,s=n.findIndex(function(r){return r.sampler==t&&r.source===e});-1===s&&(s=n.length,n.push({source:e,sampler:t}));var o={index:s};return r&&(o.texCoord=r),o},e.prototype._exportTextureSampler=function(e){var t=this._getTextureSampler(e),r=this._exporter._samplers,n=r.findIndex(function(e){return e.minFilter===t.minFilter&&e.magFilter===t.magFilter&&e.wrapS===t.wrapS&&e.wrapT===t.wrapT});return-1!==n?n:(r.push(t),r.length-1)},e}(),S=f.Matrix.Compose(new f.Vector3(-1,1,1),f.Quaternion.Identity(),f.Vector3.Zero());function F(e,t){if(!(e instanceof f.TransformNode))return!1;if(t){if(!e.getWorldMatrix().equalsWithEpsilon(f.Matrix.IdentityReadOnly,f.Epsilon))return!1}else if(!e.getWorldMatrix().multiplyToRef(S,f.TmpVectors.Matrix[0]).equalsWithEpsilon(f.Matrix.IdentityReadOnly,f.Epsilon))return!1;return!(e instanceof f.AbstractMesh&&e.geometry)}var B=f.Vector3.ZeroReadOnly,O=f.Quaternion.Identity(),N=f.Vector3.OneReadOnly,U=new f.Vector3(-1,1,1);function P(e,t){var r=e.byteOffset,n=e.byteStride,s=e.type,o=e.normalized,i=e.getSize(),a=t.reduce(function(e,t){return t.getTotalVertices()>e?t.getTotalVertices():e},-Number.MAX_VALUE);return{byteOffset:r,byteStride:n,componentCount:i,type:s,count:a*i,normalized:o,totalVertices:a,kind:e.getKind()}}function W(e){switch(e){case"MAT2":case"VEC4":return 4;case"MAT3":return 9;case"MAT4":return 16;case"SCALAR":return 1;case"VEC2":return 2;case"VEC3":return 3}}function L(e){return e.some(function(e){return e>=256})}function z(e){switch(e){case f.VertexBuffer.PositionKind:case f.VertexBuffer.NormalKind:case f.VertexBuffer.TangentKind:case f.VertexBuffer.ColorKind:case f.VertexBuffer.MatricesIndicesKind:case f.VertexBuffer.MatricesIndicesExtraKind:case f.VertexBuffer.MatricesWeightsKind:case f.VertexBuffer.MatricesWeightsExtraKind:case f.VertexBuffer.UVKind:case f.VertexBuffer.UV2Kind:case f.VertexBuffer.UV3Kind:case f.VertexBuffer.UV4Kind:case f.VertexBuffer.UV5Kind:case f.VertexBuffer.UV6Kind:return!0}return!1}function K(e){var t=Math.sqrt(e.x*e.x+e.y*e.y+e.z*e.z);t>0&&(e.x/=t,e.y/=t,e.z/=t)}function k(e){return e.x*=-1,e}function G(e){return S.invertToRef(f.TmpVectors.Matrix[0]).multiplyToRef(e,e).multiplyToRef(S,e),e}function D(e){if(e.x*e.x+e.y*e.y>.5){var t=Math.abs(e.x),r=Math.abs(e.y);if(t>r){var n=Math.sign(e.x);e.x=t,e.y*=-n,e.z*=-n,e.w*=n}else n=Math.sign(e.y),e.x*=-n,e.y=r,e.z*=n,e.w*=-n}else{var s=Math.abs(e.z),o=Math.abs(e.w);s>o?(n=Math.sign(e.z),e.x*=-n,e.y*=n,e.z=s,e.w*=-n):(n=Math.sign(e.w),e.x*=n,e.y*=-n,e.z*=-n,e.w=o)}return e}function H(e){e.copyFromFloats(-e.z,e.w,e.x,-e.y)}function q(e,t){var r=f.Vector3.FromArrayToRef(t.translation||[0,0,0],0,f.TmpVectors.Vector3[0]),n=f.Quaternion.FromArrayToRef(t.rotation||[0,0,0,1],0,f.TmpVectors.Quaternion[0]),s=f.Matrix.ComposeToRef(N,n,r,f.TmpVectors.Matrix[0]),o=f.Vector3.FromArrayToRef(e.translation||[0,0,0],0,f.TmpVectors.Vector3[2]),i=f.Quaternion.FromArrayToRef(e.rotation||[0,0,0,1],0,f.TmpVectors.Quaternion[1]),a=f.Matrix.ComposeToRef(N,i,o,f.TmpVectors.Matrix[1]);s.multiplyToRef(a,a),a.decompose(void 0,n,r),r.equalsWithEpsilon(B,f.Epsilon)?delete t.translation:t.translation=r.asArray(),n.equalsWithEpsilon(O,f.Epsilon)?delete t.rotation:t.rotation=n.asArray(),t.scale&&delete t.scale}function j(e,t){if(!(t instanceof f.TransformNode))return!1;if(1!==t.getChildren().length||0!==e.getChildren().length||e.parent!==t)return!1;var r=e.getScene(),n=e instanceof f.TargetCamera&&!r.useRightHandedSystem?U:N;return!!t.scaling.equalsWithEpsilon(n,f.Epsilon)||(f.Logger.Warn("Cannot collapse node ".concat(e.name," into parent node ").concat(t.name," with modified scaling.")),!1)}function Q(e,t){for(var r=0,n=Object.entries(e);r<n.length;r++){var s=n[r],o=s[0],i=s[1],a=t[o];(Array.isArray(i)&&Array.isArray(a)&&X(i,a)||i===a)&&delete e[o]}return e}function X(e,t){return e.length===t.length&&e.every(function(e,r){return e===t[r]})}var Y=new Map([[Int8Array,function(e,t,r){return e.setInt8(t,r)}],[Uint8Array,function(e,t,r){return e.setUint8(t,r)}],[Uint8ClampedArray,function(e,t,r){return e.setUint8(t,r)}],[Int16Array,function(e,t,r){return e.setInt16(t,r,!0)}],[Uint16Array,function(e,t,r){return e.setUint16(t,r,!0)}],[Int32Array,function(e,t,r){return e.setInt32(t,r,!0)}],[Uint32Array,function(e,t,r){return e.setUint32(t,r,!0)}],[Float32Array,function(e,t,r){return e.setFloat32(t,r,!0)}],[Float64Array,function(e,t,r){return e.setFloat64(t,r,!0)}]]),Z=function(){function e(e){this._data=new Uint8Array(e),this._dataView=new DataView(this._data.buffer),this._byteOffset=0}return e.prototype.writeTypedArray=function(e){this._checkGrowBuffer(e.byteLength);for(var t=Y.get(e.constructor),r=0;r<e.length;r++)t(this._dataView,this._byteOffset,e[r]),this._byteOffset+=e.BYTES_PER_ELEMENT},Object.defineProperty(e.prototype,"byteOffset",{get:function(){return this._byteOffset},enumerable:!1,configurable:!0}),e.prototype.getOutputData=function(){return new Uint8Array(this._data.buffer,0,this._byteOffset)},e.prototype.writeUInt8=function(e){this._checkGrowBuffer(1),this._dataView.setUint8(this._byteOffset,e),this._byteOffset++},e.prototype.writeInt8=function(e){this._checkGrowBuffer(1),this._dataView.setInt8(this._byteOffset,e),this._byteOffset++},e.prototype.writeInt16=function(e){this._checkGrowBuffer(2),this._dataView.setInt16(this._byteOffset,e,!0),this._byteOffset+=2},e.prototype.writeUInt16=function(e){this._checkGrowBuffer(2),this._dataView.setUint16(this._byteOffset,e,!0),this._byteOffset+=2},e.prototype.writeInt32=function(e){this._checkGrowBuffer(4),this._dataView.setInt32(this._byteOffset,e,!0),this._byteOffset+=4},e.prototype.writeUInt32=function(e){this._checkGrowBuffer(4),this._dataView.setUint32(this._byteOffset,e,!0),this._byteOffset+=4},e.prototype.writeFloat32=function(e){this._checkGrowBuffer(4),this._dataView.setFloat32(this._byteOffset,e,!0),this._byteOffset+=4},e.prototype.writeFloat64=function(e){this._checkGrowBuffer(8),this._dataView.setFloat64(this._byteOffset,e,!0),this._byteOffset+=8},e.prototype._checkGrowBuffer=function(e){var t=this.byteOffset+e;if(t>this._data.byteLength){var r=new Uint8Array(2*t);r.set(this._data),this._data=r,this._dataView=new DataView(this._data.buffer)}},e}();function J(e){return e%4==0?4:e%2==0?2:1}var $,ee=function(){function e(){this._bufferViewToData=new Map,this._bufferViewToProperties=new Map,this._accessorToBufferView=new Map}return e.prototype.generateBinary=function(e){var t=0;this._bufferViewToData.forEach(function(e){t+=e.byteLength});for(var r=new Z(t),n=0,s=Array.from(this._bufferViewToData.keys()).sort(function(e,t){return J(t.byteLength)-J(e.byteLength)});n<s.length;n++){var o=s[n];o.byteOffset=r.byteOffset,e.push(o);for(var i=e.length-1,a=0,u=this.getPropertiesWithBufferView(o);a<u.length;a++)u[a].bufferView=i;r.writeTypedArray(this._bufferViewToData.get(o)),this._bufferViewToData.delete(o)}return r.getOutputData()},e.prototype.createBufferView=function(e,t){var r={buffer:0,byteOffset:void 0,byteLength:e.byteLength,byteStride:t};return this._bufferViewToData.set(r,e),r},e.prototype.createAccessor=function(e,t,r,n,s,o,i){this._verifyBufferView(e);var a={bufferView:void 0,componentType:r,count:n,type:t,min:null==o?void 0:o.min,max:null==o?void 0:o.max,normalized:i,byteOffset:s};return this.setBufferView(a,e),this._accessorToBufferView.set(a,e),a},e.prototype.setBufferView=function(e,t){this._verifyBufferView(t),this.getPropertiesWithBufferView(t).push(e)},e.prototype.removeBufferView=function(e){for(var t=this,r=0,n=this.getPropertiesWithBufferView(e);r<n.length;r++){var s=n[r];void 0!==s.bufferView&&delete s.bufferView}this._bufferViewToData.delete(e),this._bufferViewToProperties.delete(e),this._accessorToBufferView.forEach(function(r,n){r===e&&(void 0!==n.byteOffset&&delete n.byteOffset,t._accessorToBufferView.delete(n))})},e.prototype.getBufferView=function(e){var t=this._accessorToBufferView.get(e);return this._verifyBufferView(t),t},e.prototype.getPropertiesWithBufferView=function(e){var t;return this._verifyBufferView(e),this._bufferViewToProperties.set(e,null!==(t=this._bufferViewToProperties.get(e))&&void 0!==t?t:[]),this._bufferViewToProperties.get(e)},e.prototype.getData=function(e){return this._verifyBufferView(e),this._bufferViewToData.get(e)},e.prototype._verifyBufferView=function(e){if(void 0===e||!this._bufferViewToData.has(e))throw new Error("BufferView ".concat(e," not found in BufferManager."))},e}();!function(e){e[e.INTANGENT=0]="INTANGENT",e[e.OUTTANGENT=1]="OUTTANGENT"}($||($={}));var te=function(){function e(){}return e._IsTransformable=function(e){return e&&(e instanceof f.TransformNode||e instanceof f.Camera||e instanceof f.Light)},e._CreateNodeAnimation=function(t,r,n,s,o){if(this._IsTransformable(t)){var i=[],a=[],u=r.getKeys(),c=e._CalculateMinMaxKeyFrames(u),l=e._DeduceInterpolation(u,n,s),h=l.interpolationType,p=l.shouldBakeAnimation;if(p?e._CreateBakedAnimation(t,r,n,c.min,c.max,r.framePerSecond,o,i,a,c,s):"LINEAR"===h||"STEP"===h?e._CreateLinearOrStepAnimation(t,r,n,i,a,s):"CUBICSPLINE"===h?e._CreateCubicSplineAnimation(t,r,n,i,a,s):e._CreateBakedAnimation(t,r,n,c.min,c.max,r.framePerSecond,o,i,a,c,s),i.length&&a.length)return{inputs:i,outputs:a,samplerInterpolation:h,inputsMin:p?c.min:f.Tools.FloatRound(c.min/r.framePerSecond),inputsMax:p?c.max:f.Tools.FloatRound(c.max/r.framePerSecond)}}return null},e._DeduceAnimationInfo=function(e){var t=null,r="VEC3",n=!1,s=e.targetProperty.split(".");switch(s[0]){case"scaling":t="scale";break;case"position":t="translation";break;case"rotation":r="VEC4",t="rotation";break;case"rotationQuaternion":r="VEC4",n=!0,t="rotation";break;case"influence":r="SCALAR",t="weights";break;default:f.Tools.Error("Unsupported animatable property ".concat(s[0]))}return t?{animationChannelTargetPath:t,dataAccessorType:r,useQuaternion:n}:(f.Tools.Error("animation channel target path and data accessor type could be deduced"),null)},e._CreateNodeAnimationFromNodeAnimations=function(t,r,n,s,o,i,a,u,c,l,h){var f;if(e._IsTransformable(t)&&t.animations)for(var p=0,d=t.animations;p<d.length;p++){var x=d[p];if(!h||h(x)){var g=e._DeduceAnimationInfo(x);g&&(f={name:x.name,samplers:[],channels:[]},e._AddAnimation("".concat(x.name),x.hasRunningRuntimeAnimations?r:f,t,x,g.dataAccessorType,g.animationChannelTargetPath,s,i,a,u,g.useQuaternion,c,l),f.samplers.length&&f.channels.length&&n.push(f))}}},e._CreateMorphTargetAnimationFromMorphTargetAnimations=function(t,r,n,s,o,i,a,u,c,l,h){var p;if(t instanceof f.Mesh){var d=t.morphTargetManager;if(d)for(var x=0;x<d.numTargets;++x)for(var g=0,_=d.getTarget(x).animations;g<_.length;g++){var m=_[g];if(!h||h(m)){for(var T=new f.Animation("".concat(m.name),"influence",m.framePerSecond,m.dataType,m.loopMode,m.enableBlending),y=[],v=m.getKeys(),b=0;b<v.length;++b)for(var w=v[b],M=0;M<d.numTargets;++M)M==x?y.push(w):y.push({frame:w.frame,value:0});T.setKeys(y,!0);var A=e._DeduceAnimationInfo(T);A&&(p={name:T.name,samplers:[],channels:[]},e._AddAnimation(m.name,m.hasRunningRuntimeAnimations?r:p,t,T,A.dataAccessorType,A.animationChannelTargetPath,s,i,a,u,A.useQuaternion,c,l,d.numTargets),p.samplers.length&&p.channels.length&&n.push(p))}}}},e._CreateNodeAndMorphAnimationFromAnimationGroups=function(t,r,n,s,o,i,a,u,c){var l,h;if(t.animationGroups)for(var p=t.animationGroups,d=function(p){var d=new Map,g=new Map,_=new Set,m=p.to-p.from;h={name:p.name,channels:[],samplers:[]};for(var T=function(r){var m=p.targetedAnimations[r],T=m.target,y=m.animation;if(c&&!c(y))return"continue";var v=u.has(T);if(x._IsTransformable(T)||1===T.length&&x._IsTransformable(T[0])){if(w=e._DeduceAnimationInfo(m.animation)){var b=x._IsTransformable(T)?T:x._IsTransformable(T[0])?T[0]:null;b&&e._AddAnimation("".concat(y.name),h,b,y,w.dataAccessorType,w.animationChannelTargetPath,n,s,o,i,w.useQuaternion,a,v)}}else if(T instanceof f.MorphTarget||1===T.length&&T[0]instanceof f.MorphTarget){var w;if(w=e._DeduceAnimationInfo(m.animation)){var M=T instanceof f.MorphTarget?T:T[0];if(M){var A=t.morphTargetManagers.find(function(e){for(var t=0;t<e.numTargets;++t)if(e.getTarget(t)===M)return!0;return!1});if(A){var R=t.meshes.find(function(e){return e.morphTargetManager===A});R&&(d.has(R)||d.set(R,new Map),null===(l=d.get(R))||void 0===l||l.set(M,y),_.add(R),g.set(R,y))}}}}},y=0;y<p.targetedAnimations.length;++y)T(y);_.forEach(function(t){for(var r=t.morphTargetManager,u=null,c=[],l=g.get(t).getKeys(),x=l.length,_=0;_<x;++_)for(var T=0;T<r.numTargets;++T){var y=r.getTarget(T),v=d.get(t);if(v){var b=v.get(y);b?(u||(u=new f.Animation("".concat(p.name,"_").concat(t.name,"_MorphWeightAnimation"),"influence",b.framePerSecond,f.Animation.ANIMATIONTYPE_FLOAT,b.loopMode,b.enableBlending)),c.push(b.getKeys()[_])):c.push({frame:p.from+m/x*_,value:y.influence,inTangent:l[0].inTangent?0:void 0,outTangent:l[0].outTangent?0:void 0})}}u.setKeys(c,!0);var w=e._DeduceAnimationInfo(u);w&&e._AddAnimation("".concat(p.name,"_").concat(t.name,"_MorphWeightAnimation"),h,t,u,w.dataAccessorType,w.animationChannelTargetPath,n,s,o,i,w.useQuaternion,a,!1,null==r?void 0:r.numTargets)}),h.channels.length&&h.samplers.length&&r.push(h)},x=this,g=0,_=p;g<_.length;g++)d(_[g])},e._AddAnimation=function(t,r,n,s,o,i,a,u,c,l,h,p,d,x){var g,_,m,T,y,v,b=e._CreateNodeAnimation(n,s,i,h,p);if(b){if(x){for(var w=0,M=void 0,A=[];b.inputs.length>0;)M=b.inputs.shift(),w%x==0&&A.push(M),w++;b.inputs=A}var R=a.get(n),E=new Float32Array(b.inputs);g=u.createBufferView(E),_=u.createAccessor(g,"SCALAR",5126,b.inputs.length,void 0,{min:[b.inputsMin],max:[b.inputsMax]}),l.push(_),m=l.length-1;var C=new f.Quaternion,I=new f.Vector3,V=new f.Vector3,S=n instanceof f.Camera,F=W(o),B=new Float32Array(b.outputs.length*F);b.outputs.forEach(function(e,t){var r=e;switch(i){case"translation":d&&(f.Vector3.FromArrayToRef(e,0,V),k(V),V.toArray(r));break;case"rotation":4===e.length?f.Quaternion.FromArrayToRef(e,0,C):(r=new Array(4),f.Vector3.FromArrayToRef(e,0,I),f.Quaternion.FromEulerVectorToRef(I,C)),d&&(D(C),S&&H(C)),C.toArray(r)}B.set(r,t*F)}),g=u.createBufferView(B),_=u.createAccessor(g,o,5126,b.outputs.length),l.push(_),T=l.length-1,y={interpolation:b.samplerInterpolation,input:m,output:T},r.samplers.push(y),v={sampler:r.samplers.length-1,target:{node:R,path:i}},r.channels.push(v)}},e._CreateBakedAnimation=function(t,r,n,s,o,i,a,u,c,l,h){var p,d,x,g,_,m,T=f.Quaternion.Identity(),y=null,v=null;l.min=f.Tools.FloatRound(s/i);for(var b=r.getKeys(),w=0,M=b.length;w<M;++w){if(x=b[w],w+1<M)if(g=b[w+1],x.value.equals&&x.value.equals(g.value)||x.value===g.value){if(0!==w)continue;m=x.frame}else m=g.frame;else{if(_=b[w-1],x.value.equals&&x.value.equals(_.value)||x.value===_.value)continue;m=o}if(m)for(var A=x.frame;A<=m;A+=a)if((d=f.Tools.FloatRound(A/i))!==y){y=d,v=d;var R={key:0,repeatCount:0,loopMode:r.loopMode};p=r._interpolate(A,R),e._SetInterpolatedValue(t,p,d,r,n,T,u,c,h)}}v&&(l.max=v)},e._ConvertFactorToVector3OrQuaternion=function(t,r,n,s,o){var i=e._GetBasePositionRotationOrScale(r,s,o),a=n.targetProperty.split("."),u=a?a[1]:"",c=o?f.Quaternion.FromArray(i).normalize():f.Vector3.FromArray(i);switch(u){case"x":case"y":case"z":c[u]=t;break;case"w":c.w=t;break;default:f.Tools.Error('glTFAnimation: Unsupported component name "'.concat(u,'"!'))}return c},e._SetInterpolatedValue=function(e,t,r,n,s,o,i,a,u){var c;i.push(r),"weights"!==s?(n.dataType===f.Animation.ANIMATIONTYPE_FLOAT&&(t=this._ConvertFactorToVector3OrQuaternion(t,e,n,s,u)),"rotation"===s?(u?o=t:(c=t,f.Quaternion.RotationYawPitchRollToRef(c.y,c.x,c.z,o)),a.push(o.asArray())):(c=t,a.push(c.asArray()))):a.push([t])},e._CreateLinearOrStepAnimation=function(t,r,n,s,o,i){for(var a=0,u=r.getKeys();a<u.length;a++){var c=u[a];s.push(c.frame/r.framePerSecond),e._AddKeyframeValue(c,r,o,n,t,i)}},e._CreateCubicSplineAnimation=function(t,r,n,s,o,i){r.getKeys().forEach(function(a){s.push(a.frame/r.framePerSecond),e._AddSplineTangent($.INTANGENT,o,n,"CUBICSPLINE",a,i),e._AddKeyframeValue(a,r,o,n,t,i),e._AddSplineTangent($.OUTTANGENT,o,n,"CUBICSPLINE",a,i)})},e._GetBasePositionRotationOrScale=function(e,t,r){var n;if("rotation"===t)if(r){var s=e.rotationQuaternion;n=(null!=s?s:f.Quaternion.Identity()).asArray()}else{var o=e.rotation;n=(null!=o?o:f.Vector3.Zero()).asArray()}else if("translation"===t){var i=e.position;n=(null!=i?i:f.Vector3.Zero()).asArray()}else{var a=e.scaling;n=(null!=a?a:f.Vector3.One()).asArray()}return n},e._AddKeyframeValue=function(e,t,r,n,s,o){var i,a=t.dataType;if(a===f.Animation.ANIMATIONTYPE_VECTOR3){var u=e.value.asArray();if("rotation"===n){var c=f.Vector3.FromArray(u);u=f.Quaternion.RotationYawPitchRoll(c.y,c.x,c.z).asArray()}r.push(u)}else if(a===f.Animation.ANIMATIONTYPE_FLOAT){if("weights"===n)r.push([e.value]);else if(i=this._ConvertFactorToVector3OrQuaternion(e.value,s,t,n,o)){if("rotation"===n){var l=o?i:f.Quaternion.RotationYawPitchRoll(i.y,i.x,i.z).normalize();r.push(l.asArray())}r.push(i.asArray())}}else a===f.Animation.ANIMATIONTYPE_QUATERNION?r.push(e.value.normalize().asArray()):f.Tools.Error("glTFAnimation: Unsupported key frame values for animation!")},e._DeduceInterpolation=function(e,t,r){var n,s,o=!1;if("rotation"===t&&!r)return{interpolationType:"LINEAR",shouldBakeAnimation:!0};for(var i=0,a=e.length;i<a;++i)if((s=e[i]).inTangent||s.outTangent)if(n){if("CUBICSPLINE"!==n){n="LINEAR",o=!0;break}}else n="CUBICSPLINE";else if(n){if("CUBICSPLINE"===n||s.interpolation&&1===s.interpolation&&"STEP"!==n){n="LINEAR",o=!0;break}}else n=s.interpolation&&1===s.interpolation?"STEP":"LINEAR";return n||(n="LINEAR"),{interpolationType:n,shouldBakeAnimation:o}},e._AddSplineTangent=function(e,t,r,n,s,o){var i,a=e===$.INTANGENT?s.inTangent:s.outTangent;if("CUBICSPLINE"===n){if("rotation"===r)if(a)if(o)i=a.asArray();else{var u=a;i=f.Quaternion.RotationYawPitchRoll(u.y,u.x,u.z).asArray()}else i=[0,0,0,0];else i="weights"===r?a?[a]:[0]:a?a.asArray():[0,0,0];t.push(i)}},e._CalculateMinMaxKeyFrames=function(e){var t=1/0,r=-1/0;return e.forEach(function(e){t=Math.min(t,e.frame),r=Math.max(r,e.frame)}),{min:t,max:r}},e}();function re(e,t,r,n,s,o){var i={attributes:{},influence:e.influence,name:e.name},a=t.geometry;if(!a)return f.Tools.Warn("Attempted to export morph target data from a mesh without geometry. This should not happen."),i;var u,c=o?-1:1,l=f.Vector3.Zero();if(e.hasPositions){var h=e.getPositions(),p=a.getVerticesData(f.VertexBuffer.PositionKind);if(p){var d=new Float32Array(p.length),x=[1/0,1/0,1/0],g=[-1/0,-1/0,-1/0];u=p.length/3;for(var _=0;_<u;++_){var m=f.Vector3.FromArray(p,3*_);f.Vector3.FromArray(h,3*_).subtractToRef(m,l),l.x*=c,x[0]=Math.min(x[0],l.x),g[0]=Math.max(g[0],l.x),x[1]=Math.min(x[1],l.y),g[1]=Math.max(g[1],l.y),x[2]=Math.min(x[2],l.z),g[2]=Math.max(g[2],l.z),d[3*_]=l.x,d[3*_+1]=l.y,d[3*_+2]=l.z}var T=r.createBufferView(d,12),y=r.createAccessor(T,"VEC3",5126,h.length/3,0,{min:x,max:g});s.push(y),i.attributes.POSITION=s.length-1}else f.Tools.Warn("Morph target positions for mesh ".concat(t.name," were not exported. Mesh does not have position vertex data"))}if(e.hasNormals){var v=e.getNormals(),b=a.getVerticesData(f.VertexBuffer.NormalKind);if(b){var w=new Float32Array(b.length);for(u=b.length/3,_=0;_<u;++_){var M=f.Vector3.FromArray(b,3*_).normalize();f.Vector3.FromArray(v,3*_).normalize().subtractToRef(M,l),w[3*_]=l.x*c,w[3*_+1]=l.y,w[3*_+2]=l.z}T=r.createBufferView(w,12),y=r.createAccessor(T,"VEC3",5126,v.length/3,0),s.push(y),i.attributes.NORMAL=s.length-1}else f.Tools.Warn("Morph target normals for mesh ".concat(t.name," were not exported. Mesh does not have normals vertex data"))}if(e.hasTangents){var A=e.getTangents(),R=a.getVerticesData(f.VertexBuffer.TangentKind);if(R){u=R.length/4;var E=new Float32Array(3*u);for(_=0;_<u;++_){var C=f.Vector3.FromArray(R,4*_);K(C);var I=f.Vector3.FromArray(A,3*_);K(I),I.subtractToRef(C,l),E[3*_]=l.x*c,E[3*_+1]=l.y,E[3*_+2]=l.z}T=r.createBufferView(E,12),y=r.createAccessor(T,"VEC3",5126,u,0),s.push(y),i.attributes.TANGENT=s.length-1}else f.Tools.Warn("Morph target tangents for mesh ".concat(t.name," were not exported. Mesh does not have tangents vertex data"))}if(e.hasColors){var V=e.getColors(),S=a.getVerticesData(f.VertexBuffer.ColorKind),F=a.getVertexBuffer(f.VertexBuffer.ColorKind);if(S&&F){var B=F.getSize();u=S.length/B;var O=new Float32Array(u*B);for(_=0;_<u;++_)if(3===B){var N=f.Vector3.FromArray(S,_*B);f.Vector3.FromArray(V,_*B).subtractToRef(N,l),O[3*_]=l.x,O[3*_+1]=l.y,O[3*_+2]=l.z}else if(4===B){var U=new f.Vector4;N=f.Vector4.FromArray(S,_*B),f.Vector4.FromArray(V,_*B).subtractToRef(N,U),O[4*_]=U.x,O[4*_+1]=U.y,O[4*_+2]=U.z,O[4*_+3]=U.w}else f.Tools.Warn("Unsupported number of components for color attribute: ".concat(B));T=r.createBufferView(O,4*B),y=r.createAccessor(T,3===B?"VEC3":"VEC4",5126,u,0),s.push(y),i.attributes.COLOR_0=s.length-1}else f.Tools.Warn("Morph target colors for mesh ".concat(t.name," were not exported. Mesh does not have colors vertex data"))}return i}var ne=function(){function e(e,t){this._indicesAccessorMap=new Map,this._vertexBufferViewMap=new Map,this._vertexAccessorMap=new Map,this._remappedBufferView=new Map,this._meshMorphTargetMap=new Map,this._vertexMapColorAlpha=new Map,this._exportedNodes=new Set,this._meshMap=new Map,this.convertedToRightHandedBuffers=new Map,this.convertToRightHanded=e,this.wasAddedByNoopNode=t}return e.prototype.getIndicesAccessor=function(e,t,r,n,s){var o,i,a,u;return null===(u=null===(a=null===(i=null===(o=this._indicesAccessorMap.get(e))||void 0===o?void 0:o.get(t))||void 0===i?void 0:i.get(r))||void 0===a?void 0:a.get(n))||void 0===u?void 0:u.get(s)},e.prototype.setIndicesAccessor=function(e,t,r,n,s,o){var i=this._indicesAccessorMap.get(e);i||(i=new Map,this._indicesAccessorMap.set(e,i));var a=i.get(t);a||(a=new Map,i.set(t,a));var u=a.get(r);u||(u=new Map,a.set(r,u));var c=u.get(n);c||(c=new Map,u.set(n,c)),c.set(s,o)},e.prototype.pushExportedNode=function(e){this._exportedNodes.has(e)||this._exportedNodes.add(e)},e.prototype.getNodesSet=function(){return this._exportedNodes},e.prototype.getVertexBufferView=function(e){return this._vertexBufferViewMap.get(e)},e.prototype.setVertexBufferView=function(e,t){this._vertexBufferViewMap.set(e,t)},e.prototype.setRemappedBufferView=function(e,t,r){this._remappedBufferView.set(e,new Map),this._remappedBufferView.get(e).set(t,r)},e.prototype.getRemappedBufferView=function(e,t){var r;return null===(r=this._remappedBufferView.get(e))||void 0===r?void 0:r.get(t)},e.prototype.getVertexAccessor=function(e,t,r){var n,s;return null===(s=null===(n=this._vertexAccessorMap.get(e))||void 0===n?void 0:n.get(t))||void 0===s?void 0:s.get(r)},e.prototype.setVertexAccessor=function(e,t,r,n){var s=this._vertexAccessorMap.get(e);s||(s=new Map,this._vertexAccessorMap.set(e,s));var o=s.get(t);o||(o=new Map,s.set(t,o)),o.set(r,n)},e.prototype.hasVertexColorAlpha=function(e){return this._vertexMapColorAlpha.get(e)||!1},e.prototype.setHasVertexColorAlpha=function(e,t){return this._vertexMapColorAlpha.set(e,t)},e.prototype.getMesh=function(e){return this._meshMap.get(e)},e.prototype.setMesh=function(e,t){this._meshMap.set(e,t)},e.prototype.bindMorphDataToMesh=function(e,t){var r=this._meshMorphTargetMap.get(e)||[];this._meshMorphTargetMap.set(e,r),-1===r.indexOf(t)&&r.push(t)},e.prototype.getMorphTargetsFromMesh=function(e){return this._meshMorphTargetMap.get(e)},e}(),se=function(){function e(e,t){if(void 0===e&&(e=f.EngineStore.LastCreatedScene),this._glTF={asset:{generator:"Babylon.js v".concat(f.Engine.Version),version:"2.0"}},this._animations=[],this._accessors=[],this._bufferViews=[],this._cameras=[],this._images=[],this._materials=[],this._meshes=[],this._nodes=[],this._samplers=[],this._scenes=[],this._skins=[],this._textures=[],this._imageData={},this._shouldUseGlb=!1,this._materialExporter=new V(this),this._extensions={},this._bufferManager=new ee,this._shouldExportNodeMap=new Map,this._nodeMap=new Map,this._materialMap=new Map,this._camerasMap=new Map,this._nodesCameraMap=new Map,this._skinMap=new Map,this._nodesSkinMap=new Map,this._materialNeedsUVsSet=new Set,!e)throw new Error("No scene available to export");this._babylonScene=e,this._options=d({shouldExportNode:function(){return!0},shouldExportAnimation:function(){return!0},metadataSelector:function(e){var t;return null===(t=null==e?void 0:e.gltf)||void 0===t?void 0:t.extras},animationSampleRate:1/60,exportWithoutWaitingForScene:!1,exportUnusedUVs:!1,removeNoopRootNodes:!0,includeCoordinateSystemConversionNodes:!1,meshCompressionMethod:"None"},t),this._loadExtensions()}return e.prototype._ApplyExtension=function(e,t,r,n){var s=this;if(r>=t.length)return Promise.resolve(e);var o=n(t[r],e);return o?o.then(function(e){return x(s,void 0,void 0,function(){var s;return g(this,function(o){switch(o.label){case 0:return e?[4,this._ApplyExtension(e,t,r+1,n)]:[3,2];case 1:return s=o.sent(),[3,3];case 2:s=null,o.label=3;case 3:return[2,s]}})})}):this._ApplyExtension(e,t,r+1,n)},e.prototype._ApplyExtensions=function(t,r){for(var n=[],s=0,o=e._ExtensionNames;s<o.length;s++){var i=o[s];n.push(this._extensions[i])}return this._ApplyExtension(t,n,0,r)},e.prototype._extensionsPostExportNodeAsync=function(e,t,r,n,s){var o=this;return this._ApplyExtensions(t,function(t,i){return t.postExportNodeAsync&&t.postExportNodeAsync(e,i,r,n,s,o._bufferManager)})},e.prototype._extensionsPostExportMaterialAsync=function(e,t,r){return this._ApplyExtensions(t,function(t,n){return t.postExportMaterialAsync&&t.postExportMaterialAsync(e,n,r)})},e.prototype._extensionsPostExportMaterialAdditionalTexturesAsync=function(t,r,n){return x(this,void 0,void 0,function(){var s,o=this;return g(this,function(i){switch(i.label){case 0:return s=[],[4,Promise.all(e._ExtensionNames.map(function(e){return x(o,void 0,void 0,function(){var o,i;return g(this,function(a){switch(a.label){case 0:return(o=this._extensions[e]).postExportMaterialAdditionalTexturesAsync?[4,o.postExportMaterialAdditionalTexturesAsync(t,r,n)]:[3,2];case 1:i=a.sent(),s.push.apply(s,i),a.label=2;case 2:return[2]}})})}))];case 1:return i.sent(),[2,s]}})})},e.prototype._extensionsPostExportTextures=function(t,r,n){for(var s=0,o=e._ExtensionNames;s<o.length;s++){var i=o[s],a=this._extensions[i];a.postExportTexture&&a.postExportTexture(t,r,n)}},e.prototype._extensionsPostExportMeshPrimitive=function(t){for(var r=0,n=e._ExtensionNames;r<n.length;r++){var s=n[r],o=this._extensions[s];o.postExportMeshPrimitive&&o.postExportMeshPrimitive(t,this._bufferManager,this._accessors)}},e.prototype._extensionsPreGenerateBinaryAsync=function(){return x(this,void 0,void 0,function(){var t,r,n,s;return g(this,function(o){switch(o.label){case 0:t=0,r=e._ExtensionNames,o.label=1;case 1:return t<r.length?(n=r[t],(s=this._extensions[n]).preGenerateBinaryAsync?[4,s.preGenerateBinaryAsync(this._bufferManager)]:[3,3]):[3,4];case 2:o.sent(),o.label=3;case 3:return t++,[3,1];case 4:return[2]}})})},e.prototype._forEachExtensions=function(t){for(var r=0,n=e._ExtensionNames;r<n.length;r++){var s=n[r],o=this._extensions[s];o.enabled&&t(o)}},e.prototype._extensionsOnExporting=function(){var e=this;this._forEachExtensions(function(t){var r,n,s;t.wasUsed&&((r=e._glTF).extensionsUsed||(r.extensionsUsed=[]),-1===e._glTF.extensionsUsed.indexOf(t.name)&&e._glTF.extensionsUsed.push(t.name),t.required&&((n=e._glTF).extensionsRequired||(n.extensionsRequired=[]),-1===e._glTF.extensionsRequired.indexOf(t.name)&&e._glTF.extensionsRequired.push(t.name)),(s=e._glTF).extensions||(s.extensions={}),t.onExporting&&t.onExporting())})},e.prototype._loadExtensions=function(){for(var t=0,r=e._ExtensionNames;t<r.length;t++){var n=r[t],s=e._ExtensionFactories[n](this);this._extensions[n]=s}},e.prototype.dispose=function(){for(var e in this._extensions)this._extensions[e].dispose()},Object.defineProperty(e.prototype,"options",{get:function(){return this._options},enumerable:!1,configurable:!0}),e.RegisterExtension=function(t,r,n){void 0===n&&(n=100),e.UnregisterExtension(t)&&f.Tools.Warn("Extension with the name ".concat(t," already exists")),e._ExtensionFactories[t]=r;var s=null!=n?n:0;e._ExtensionOrders[t]=s;for(var o=e._ExtensionNames.length,i=0;i<e._ExtensionNames.length;i++){var a=e._ExtensionNames[i];if(s<e._ExtensionOrders[a]){o=i;break}}e._ExtensionNames.splice(o,0,t)},e.UnregisterExtension=function(t){if(!e._ExtensionFactories[t])return!1;delete e._ExtensionFactories[t],delete e._ExtensionOrders[t];var r=e._ExtensionNames.indexOf(t);return-1!==r&&e._ExtensionNames.splice(r,1),!0},e.prototype._generateJSON=function(e,t,r){var n={byteLength:e};return n.byteLength&&(this._glTF.buffers=[n]),this._nodes&&this._nodes.length&&(this._glTF.nodes=this._nodes),this._meshes&&this._meshes.length&&(this._glTF.meshes=this._meshes),this._scenes&&this._scenes.length&&(this._glTF.scenes=this._scenes,this._glTF.scene=0),this._cameras&&this._cameras.length&&(this._glTF.cameras=this._cameras),this._bufferViews&&this._bufferViews.length&&(this._glTF.bufferViews=this._bufferViews),this._accessors&&this._accessors.length&&(this._glTF.accessors=this._accessors),this._animations&&this._animations.length&&(this._glTF.animations=this._animations),this._materials&&this._materials.length&&(this._glTF.materials=this._materials),this._textures&&this._textures.length&&(this._glTF.textures=this._textures),this._samplers&&this._samplers.length&&(this._glTF.samplers=this._samplers),this._skins&&this._skins.length&&(this._glTF.skins=this._skins),this._images&&this._images.length&&(this._glTF.images=this._images),this._shouldUseGlb||(n.uri=t+".bin"),r?JSON.stringify(this._glTF,null,2):JSON.stringify(this._glTF)},e.prototype.generateGLTFAsync=function(e){return x(this,void 0,void 0,function(){var t,r,n,s,o,i,a;return g(this,function(u){switch(u.label){case 0:return[4,this._generateBinaryAsync()];case 1:if(t=u.sent(),this._extensionsOnExporting(),r=this._generateJSON(t.byteLength,e,!0),n=new Blob([t],{type:"application/octet-stream"}),s=e+".gltf",o=e+".bin",(i=new p).files[s]=r,i.files[o]=n,this._imageData)for(a in this._imageData)i.files[a]=this._imageData[a];return[2,i]}})})},e.prototype._generateBinaryAsync=function(){return x(this,void 0,void 0,function(){return g(this,function(e){switch(e.label){case 0:return[4,this._exportSceneAsync()];case 1:return e.sent(),[4,this._extensionsPreGenerateBinaryAsync()];case 2:return e.sent(),[2,this._bufferManager.generateBinary(this._bufferViews)]}})})},e.prototype._getPadding=function(e){var t=e%4;return 0===t?t:4-t},e.prototype.generateGLBAsync=function(e){return x(this,void 0,void 0,function(){var t,r,n,s,o,i,a,u,c,l,h,f,d,x;return g(this,function(g){switch(g.label){case 0:return this._shouldUseGlb=!0,[4,this._generateBinaryAsync()];case 1:if(t=g.sent(),this._extensionsOnExporting(),r=this._generateJSON(t.byteLength),n=e+".glb",s=r.length,"undefined"!=typeof TextEncoder&&(i=new TextEncoder,o=i.encode(r),s=o.length),a=this._getPadding(s),u=this._getPadding(t.byteLength),c=28+s+a+t.byteLength+u,(l=new Z(c)).writeUInt32(1179937895),l.writeUInt32(2),l.writeUInt32(c),l.writeUInt32(s+a),l.writeUInt32(1313821514),o)l.writeTypedArray(o);else for(h="_".charCodeAt(0),d=0;d<s;++d)(f=r.charCodeAt(d))!=r.codePointAt(d)?l.writeUInt8(h):l.writeUInt8(f);for(d=0;d<a;++d)l.writeUInt8(32);for(l.writeUInt32(t.byteLength+u),l.writeUInt32(5130562),l.writeTypedArray(t),d=0;d<u;++d)l.writeUInt8(0);return(x=new p).files[n]=new Blob([l.getOutputData()],{type:"application/octet-stream"}),[2,x]}})})},e.prototype._setNodeTransformation=function(e,t,r){var n;if(t.getPivotPoint().equalsWithEpsilon(B,f.Epsilon)||f.Tools.Warn("Pivot points are not supported in the glTF serializer"),!t.position.equalsWithEpsilon(B,f.Epsilon)){var s=f.TmpVectors.Vector3[0].copyFrom(t.position);r&&k(s),e.translation=s.asArray()}t.scaling.equalsWithEpsilon(N,f.Epsilon)||(e.scale=t.scaling.asArray());var o=(null===(n=t.rotationQuaternion)||void 0===n?void 0:n.clone())||f.Quaternion.FromEulerAngles(t.rotation.x,t.rotation.y,t.rotation.z);o.equalsWithEpsilon(O,f.Epsilon)||(r&&D(o),e.rotation=o.normalize().asArray())},e.prototype._setCameraTransformation=function(e,t,r){var n=f.TmpVectors.Vector3[0],s=f.TmpVectors.Quaternion[0],o=t.getWorldMatrix();if(t.parent){var i=t.parent.getWorldMatrix().invertToRef(f.TmpVectors.Matrix[0]);o.multiplyToRef(i,f.TmpVectors.Matrix[1]).decompose(void 0,s,n)}else o.decompose(void 0,s,n);n.equalsWithEpsilon(B,f.Epsilon)||(r&&k(n),e.translation=n.asArray()),r&&D(s),this._babylonScene.useRightHandedSystem||H(s),s.equalsWithEpsilon(O,f.Epsilon)||(e.rotation=s.asArray())},e.prototype._listAvailableCameras=function(){for(var e=0,t=this._babylonScene.cameras;e<t.length;e++){var r=t[e],n={type:r.mode===f.Camera.PERSPECTIVE_CAMERA?"perspective":"orthographic"};if(r.name&&(n.name=r.name),"perspective"===n.type)n.perspective={aspectRatio:r.getEngine().getAspectRatio(r),yfov:r.fovMode===f.Camera.FOVMODE_VERTICAL_FIXED?r.fov:r.fov*r.getEngine().getAspectRatio(r),znear:r.minZ,zfar:r.maxZ};else if("orthographic"===n.type){var s=r.orthoLeft&&r.orthoRight?.5*(r.orthoRight-r.orthoLeft):.5*r.getEngine().getRenderWidth(),o=r.orthoBottom&&r.orthoTop?.5*(r.orthoTop-r.orthoBottom):.5*r.getEngine().getRenderHeight();n.orthographic={xmag:s,ymag:o,znear:r.minZ,zfar:r.maxZ}}this._camerasMap.set(r,n)}},e.prototype._exportAndAssignCameras=function(){for(var e=0,t=Array.from(this._camerasMap.values());e<t.length;e++){var r=t[e],n=this._nodesCameraMap.get(r);if(void 0!==n){this._cameras.push(r);for(var s=0,o=n;s<o.length;s++)o[s].camera=this._cameras.length-1}}},e.prototype._listAvailableSkeletons=function(){for(var e=0,t=this._babylonScene.skeletons;e<t.length;e++){var r=t[e];r.bones.length<=0||this._skinMap.set(r,{joints:[]})}},e.prototype._exportAndAssignSkeletons=function(e){for(var t,r=function(r){if(r.bones.length<=0)return"continue";var s=n._skinMap.get(r);if(null==s)return"continue";for(var o={},i=-1,a=0;a<r.bones.length;++a){var u=r.bones[a];-1!==(l=null!==(t=u.getIndex())&&void 0!==t?t:a)&&(o[l]=u,l>i&&(i=l))}for(var c=[],l=0;l<=i;++l){var h=(u=o[l]).getTransformNode(),p=h?n._nodeMap.get(h):void 0;if(void 0!==p){s.joints.push(p);var d=u.getAbsoluteInverseBindMatrix().clone();e.has(h)&&G(d),c.push(d)}else f.Tools.Warn("Exporting a bone without a linked transform node is currently unsupported.")}var x=n._nodesSkinMap.get(s);if(s.joints.length>0&&void 0!==x){var g=new Float32Array(16*c.length);c.forEach(function(e,t){g.set(e.m,16*t)});var _=n._bufferManager.createBufferView(g);n._accessors.push(n._bufferManager.createAccessor(_,"MAT4",5126,c.length)),s.inverseBindMatrices=n._accessors.length-1,n._skins.push(s);for(var m=n._skins.length-1,T=0,y=x;T<y.length;T++)y[T].skin=m}},n=this,s=0,o=this._babylonScene.skeletons;s<o.length;s++)r(o[s])},e.prototype._exportSceneAsync=function(){return x(this,void 0,void 0,function(){var e,t,r,n,s,o,i,a,u,c,l,h,p,d,x,_,m,T,y,v,b,w,M,A,R,E,C,I,V,S,B,O,N;return g(this,function(g){switch(g.label){case 0:if(e={nodes:[]},this._babylonScene.metadata&&(t=this._options.metadataSelector(this._babylonScene.metadata))&&(e.extras=t),r=new Array,n=new Array,s=new Array,this._options.removeNoopRootNodes&&!this._options.includeCoordinateSystemConversionNodes)for(i=0,a=this._babylonScene.animationGroups;i<a.length;i++)for(u=a[i],c=0,l=u.targetedAnimations;c<l.length;c++)h=l[c],(p=h.target)instanceof f.TransformNode&&!p.parent&&(null!=o?o:o=new Set).add(p);for(d=0,x=this._babylonScene.rootNodes;d<x.length;d++)_=x[d],m=_.animations,T=!!m&&m.length>0||(null==o?void 0:o.has(_)),this._options.removeNoopRootNodes&&!this._options.includeCoordinateSystemConversionNodes&&F(_,this._babylonScene.useRightHandedSystem)&&!T?s.push.apply(s,_.getChildren()):this._babylonScene.useRightHandedSystem?r.push(_):n.push(_);return this._listAvailableCameras(),this._listAvailableSkeletons(),y=new ne(!0,!1),b=(v=(B=e.nodes).push).apply,w=[B],[4,this._exportNodesAsync(n,y)];case 1:return b.apply(v,w.concat([g.sent()])),M=new ne(!1,!1),R=(A=(O=e.nodes).push).apply,E=[O],[4,this._exportNodesAsync(r,M)];case 2:return R.apply(A,E.concat([g.sent()])),C=new ne(!1,!0),V=(I=(N=e.nodes).push).apply,S=[N],[4,this._exportNodesAsync(s,C)];case 3:return V.apply(I,S.concat([g.sent()])),e.nodes.length&&this._scenes.push(e),this._exportAndAssignCameras(),this._exportAndAssignSkeletons(y.getNodesSet()),this._babylonScene.animationGroups.length&&te._CreateNodeAndMorphAnimationFromAnimationGroups(this._babylonScene,this._animations,this._nodeMap,this._bufferManager,this._bufferViews,this._accessors,this._animationSampleRate,y.getNodesSet(),this._options.shouldExportAnimation),[2]}})})},e.prototype._shouldExportNode=function(e){var t=this._shouldExportNodeMap.get(e);return void 0===t&&(t=this._options.shouldExportNode(e),this._shouldExportNodeMap.set(e,t)),t},e.prototype._exportNodesAsync=function(e,t){return x(this,void 0,void 0,function(){var r,n,s,o;return g(this,function(i){switch(i.label){case 0:r=new Array,this._exportBuffers(e,t),n=0,s=e,i.label=1;case 1:return n<s.length?(o=s[n],[4,this._exportNodeAsync(o,r,t)]):[3,4];case 2:i.sent(),i.label=3;case 3:return n++,[3,1];case 4:return[2,r]}})})},e.prototype._collectBuffers=function(e,t,r,n,s){if(this._shouldExportNode(e)&&e instanceof f.AbstractMesh&&e.geometry){var o=e.geometry.getVertexBuffers();if(o)for(var i in o)if(z(i)){var a=o[i];s.setHasVertexColorAlpha(a,e.hasVertexAlpha);var u=a._buffer,c=t.get(u)||[];t.set(u,c),-1===c.indexOf(a)&&c.push(a);var l=r.get(a)||[];r.set(a,l),-1===l.indexOf(e)&&l.push(e)}var h=e.morphTargetManager;if(h)for(var p=0;p<h.numTargets;p++){var d=h.getTarget(p);l=n.get(d)||[],n.set(d,l),-1===l.indexOf(e)&&l.push(e)}}for(var x=0,g=e.getChildren();x<g.length;x++){var _=g[x];this._collectBuffers(_,t,r,n,s)}},e.prototype._exportBuffers=function(e,t){for(var r=new Map,n=new Map,s=new Map,o=0,i=e;o<i.length;o++){var a=i[o];this._collectBuffers(a,r,n,s,t)}for(var u=Array.from(r.keys()),c=function(e){var s=e.getData();if(!s)throw new Error("Buffer data is not available");var o=r.get(e);if(!o)return"continue";var i=o[0].byteStride;if(o.some(function(e){return e.byteStride!==i}))throw new Error("Vertex buffers pointing to the same buffer must have the same byte stride");for(var a=function(e){if(e instanceof Array){var t=new Float32Array(e);return new Uint8Array(t.buffer,t.byteOffset,t.byteLength)}return ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):new Uint8Array(e)}(s).slice(),u=function(e){var t=n.get(e),r=P(e,t),s=r.byteOffset,o=r.byteStride,i=r.componentCount,u=r.type,c=r.count,h=r.normalized;switch(r.kind){case f.VertexBuffer.NormalKind:case f.VertexBuffer.TangentKind:(0,f.EnumerateFloatValues)(a,s,o,i,u,c,h,function(e){var t=Math.sqrt(e[0]*e[0]+e[1]*e[1]+e[2]*e[2]);if(t>0){var r=1/t;e[0]*=r,e[1]*=r,e[2]*=r}});break;case f.VertexBuffer.ColorKind:var p=t.filter(function(e){return e.material instanceof f.StandardMaterial||null==e.material}).length;if(0==p)break;if(p!=t.length){f.Logger.Warn("Not converting vertex color space, as buffer is shared by StandardMaterials and other material types. Results may look incorrect.");break}u==f.VertexBuffer.UNSIGNED_BYTE&&f.Logger.Warn("Converting uint8 vertex colors to linear space. Results may look incorrect.");var d=new f.Color3,x=new f.Color4,g=l._babylonScene.getEngine().useExactSrgbConversions;(0,f.EnumerateFloatValues)(a,s,o,i,u,c,h,function(e){3===e.length?(d.fromArray(e,0),d.toLinearSpaceToRef(d,g),d.toArray(e,0)):(x.fromArray(e,0),x.toLinearSpaceToRef(x,g),x.toArray(e,0))})}},c=0,h=o;c<h.length;c++)u(F=h[c]);if(t.convertToRightHanded){for(var p=0,d=o;p<d.length;p++){var x=P(F=d[p],n.get(F)),g=x.byteOffset,_=x.byteStride,m=x.componentCount,T=x.type,y=x.count,v=x.normalized;switch(E=x.kind){case f.VertexBuffer.PositionKind:case f.VertexBuffer.NormalKind:case f.VertexBuffer.TangentKind:(0,f.EnumerateFloatValues)(a,g,_,m,T,y,v,function(e){e[0]=-e[0]})}}t.convertedToRightHandedBuffers.set(e,a)}var b=l._bufferManager.createBufferView(a,i);t.setVertexBufferView(e,b);for(var w=new Map,M=0,A=o;M<A.length;M++){var R=P(F=A[M],n.get(F)),E=R.kind,C=R.totalVertices;switch(E){case f.VertexBuffer.MatricesIndicesKind:case f.VertexBuffer.MatricesIndicesExtraKind:if(F.type==f.VertexBuffer.FLOAT){var I=F.getFloatData(C);null!==I&&w.set(F,I)}}}0!==w.size&&f.Logger.Warn("Joint indices conversion needed: some joint indices are stored as floats in Babylon but GLTF requires UNSIGNED BYTES. We will perform the conversion but this might lead to unused data in the buffer.");for(var V=0,S=Array.from(w.keys());V<S.length;V++){var F=S[V],B=w.get(F);if(B){for(var O=L(B),N=new(O?Uint16Array:Uint8Array)(B.length),U=0;U<B.length;U++)N[U]=B[U];var W=l._bufferManager.createBufferView(N,4*(O?2:1));t.setRemappedBufferView(e,F,W)}}},l=this,h=0,p=u;h<p.length;h++)c(p[h]);for(var d=0,x=Array.from(s.keys());d<x.length;d++){var g=x[d],_=s.get(g);if(_)for(var m=re(g,_[0],this._bufferManager,this._bufferViews,this._accessors,t.convertToRightHanded),T=0,y=_;T<y.length;T++){var v=y[T];t.bindMorphDataToMesh(v,m)}}},e.prototype._exportNodeAsync=function(e,t,r){return x(this,void 0,void 0,function(){var n,s,o,i,a,u,c,l,h=this;return g(this,function(f){switch(f.label){case 0:return void 0!==(n=this._nodeMap.get(e))?(t.includes(n)||t.push(n),[2]):[4,this._createNodeAsync(e,r)];case 1:(s=f.sent())&&(n=this._nodes.length,this._nodes.push(s),this._nodeMap.set(e,n),r.pushExportedNode(e),t.push(n),o={name:"runtime animations",channels:[],samplers:[]},i=[],this._babylonScene.animationGroups.length||(te._CreateMorphTargetAnimationFromMorphTargetAnimations(e,o,i,this._nodeMap,this._nodes,this._bufferManager,this._bufferViews,this._accessors,this._animationSampleRate,r.convertToRightHanded,this._options.shouldExportAnimation),e.animations.length&&te._CreateNodeAnimationFromNodeAnimations(e,o,i,this._nodeMap,this._nodes,this._bufferManager,this._bufferViews,this._accessors,this._animationSampleRate,r.convertToRightHanded,this._options.shouldExportAnimation)),o.channels.length&&o.samplers.length&&this._animations.push(o),i.forEach(function(e){e.channels.length&&e.samplers.length&&h._animations.push(e)})),a=s?[]:t,u=0,c=e.getChildren(),f.label=2;case 2:return u<c.length?(l=c[u],[4,this._exportNodeAsync(l,a,r)]):[3,5];case 3:f.sent(),f.label=4;case 4:return u++,[3,2];case 5:return s&&a.length&&(s.children=a),[2]}})})},e.prototype._createNodeAsync=function(e,t){return x(this,void 0,void 0,function(){var r,n,s,o,i,a,u,c,l,h,p,d;return g(this,function(x){switch(x.label){case 0:return this._shouldExportNode(e)?(r={},e.name&&(r.name=e.name),e.metadata&&(n=this._options.metadataSelector(e.metadata))&&(r.extras=n),e instanceof f.TransformNode?(this._setNodeTransformation(r,e,t.convertToRightHanded),e instanceof f.AbstractMesh?(s=e instanceof f.InstancedMesh?e.sourceMesh:e).subMeshes&&s.subMeshes.length>0?(o=r,[4,this._exportMeshAsync(s,t)]):[3,2]:[3,3]):[3,3]):[2,null];case 1:o.mesh=x.sent(),x.label=2;case 2:e.skeleton&&void 0!==(i=this._skinMap.get(e.skeleton))&&(void 0===this._nodesSkinMap.get(i)&&this._nodesSkinMap.set(i,[]),null===(h=this._nodesSkinMap.get(i))||void 0===h||h.push(r)),x.label=3;case 3:if(e instanceof f.TargetCamera&&(a=this._camerasMap.get(e))){if(void 0===this._nodesCameraMap.get(a)&&this._nodesCameraMap.set(a,[]),this._setCameraTransformation(r,e,t.convertToRightHanded),null!==(u=e.parent)&&j(e,u)&&void 0!==(c=this._nodeMap.get(u)))return l=this._nodes[c],q(r,l),null===(p=this._nodesCameraMap.get(a))||void 0===p||p.push(l),[2,null];null===(d=this._nodesCameraMap.get(a))||void 0===d||d.push(r)}return[4,this._extensionsPostExportNodeAsync("exportNodeAsync",r,e,this._nodeMap,t.convertToRightHanded)];case 4:return x.sent()?[2,r]:(f.Logger.Warn("Not exporting node ".concat(e.name)),[2,null])}})})},e.prototype._exportIndices=function(e,t,r,n,s,o,i,a,u){var c=null;u.mode=function(e){switch(e){case f.Material.TriangleFillMode:return 4;case f.Material.TriangleStripDrawMode:return 5;case f.Material.TriangleFanDrawMode:return 6;case f.Material.PointListDrawMode:case f.Material.PointFillMode:return 0;case f.Material.LineLoopDrawMode:return 2;case f.Material.LineListDrawMode:return 1;case f.Material.LineStripDrawMode:return 3}throw new Error("Unknown fill mode: ".concat(e))}(o);var l=i!==f.Material.CounterClockWiseSideOrientation&&function(e){switch(e){case f.Material.TriangleFillMode:case f.Material.TriangleStripDrawMode:case f.Material.TriangleFanDrawMode:return!0}return!1}(o);if(l){if(o===f.Material.TriangleStripDrawMode||o===f.Material.TriangleFanDrawMode)throw new Error("Triangle strip/fan fill mode is not implemented");var h=t?new Uint32Array(n):new Uint16Array(n);if(e)for(var p=0;p+2<n;p+=3)h[p]=e[r+p]+s,h[p+1]=e[r+p+2]+s,h[p+2]=e[r+p+1]+s;else for(p=0;p+2<n;p+=3)h[p]=p,h[p+1]=p+2,h[p+2]=p+1;c=h}else if(e&&0!==s){for(h=t?new Uint32Array(n):new Uint16Array(n),p=0;p<n;p++)h[p]=e[r+p]+s;c=h}else e&&(c=function(e,t,r,n){var s=e;return 0===t&&r===e.length||(s=Array.isArray(e)?e.slice(t,t+r):e.subarray(t,t+r)),s instanceof Int32Array?new Uint32Array(s.buffer,s.byteOffset,s.length):Array.isArray(s)?n?new Uint32Array(s):new Uint16Array(s):s}(e,r,n,t));if(c){var d=a.getIndicesAccessor(e,r,n,s,l);if(void 0===d){var x=this._bufferManager.createBufferView(c),g=t?5125:5123;this._accessors.push(this._bufferManager.createAccessor(x,"SCALAR",g,n,0)),d=this._accessors.length-1,a.setIndicesAccessor(e,r,n,s,l,d)}u.indices=d}},e.prototype._exportVertexBuffer=function(e,t,r,n,s,o){var i=e.getKind();if(z(i)&&(!i.startsWith("uv")||this._options.exportUnusedUVs||t&&this._materialNeedsUVsSet.has(t))){var a=s.getVertexAccessor(e,r,n);if(void 0===a){var u=s.convertedToRightHandedBuffers.get(e._buffer)||e._buffer.getData(),c=i===f.VertexBuffer.PositionKind?function(e,t,r,n){var s=t.byteOffset,o=t.byteStride,i=t.type,a=t.normalized,u=t.getSize(),c=new Array(u).fill(1/0),l=new Array(u).fill(-1/0);return(0,f.EnumerateFloatValues)(e,s+r*o,o,u,i,n*u,a,function(e){for(var t=0;t<u;t++)c[t]=Math.min(c[t],e[t]),l[t]=Math.max(l[t],e[t])}),{min:c,max:l}}(u,e,r,n):void 0,l=(i===f.VertexBuffer.MatricesIndicesKind||i===f.VertexBuffer.MatricesIndicesExtraKind)&&e.type===f.VertexBuffer.FLOAT,h=l?f.VertexBuffer.UNSIGNED_BYTE:e.type,p=l?void 0:e.normalized,d=l?s.getRemappedBufferView(e._buffer,e):s.getVertexBufferView(e._buffer),x=e.byteOffset+r*e.byteStride;this._accessors.push(this._bufferManager.createAccessor(d,function(e,t){if(e==f.VertexBuffer.ColorKind)return t?"VEC4":"VEC3";switch(e){case f.VertexBuffer.PositionKind:case f.VertexBuffer.NormalKind:return"VEC3";case f.VertexBuffer.TangentKind:case f.VertexBuffer.MatricesIndicesKind:case f.VertexBuffer.MatricesIndicesExtraKind:case f.VertexBuffer.MatricesWeightsKind:case f.VertexBuffer.MatricesWeightsExtraKind:return"VEC4";case f.VertexBuffer.UVKind:case f.VertexBuffer.UV2Kind:case f.VertexBuffer.UV3Kind:case f.VertexBuffer.UV4Kind:case f.VertexBuffer.UV5Kind:case f.VertexBuffer.UV6Kind:return"VEC2"}throw new Error("Unknown kind ".concat(e))}(i,s.hasVertexColorAlpha(e)),h,n,x,c,p)),a=this._accessors.length-1,s.setVertexAccessor(e,r,n,a)}o.attributes[function(e){switch(e){case f.VertexBuffer.PositionKind:return"POSITION";case f.VertexBuffer.NormalKind:return"NORMAL";case f.VertexBuffer.TangentKind:return"TANGENT";case f.VertexBuffer.ColorKind:return"COLOR_0";case f.VertexBuffer.UVKind:return"TEXCOORD_0";case f.VertexBuffer.UV2Kind:return"TEXCOORD_1";case f.VertexBuffer.UV3Kind:return"TEXCOORD_2";case f.VertexBuffer.UV4Kind:return"TEXCOORD_3";case f.VertexBuffer.UV5Kind:return"TEXCOORD_4";case f.VertexBuffer.UV6Kind:return"TEXCOORD_5";case f.VertexBuffer.MatricesIndicesKind:return"JOINTS_0";case f.VertexBuffer.MatricesIndicesExtraKind:return"JOINTS_1";case f.VertexBuffer.MatricesWeightsKind:return"WEIGHTS_0";case f.VertexBuffer.MatricesWeightsExtraKind:return"WEIGHTS_1"}throw new Error("Unknown kind: ".concat(e))}(i)]=a}},e.prototype._exportMaterialAsync=function(e,t,r,n){return x(this,void 0,void 0,function(){var s,o;return g(this,function(i){switch(i.label){case 0:return void 0!==(s=this._materialMap.get(e))?[3,8]:(o=t&&Object.keys(t).some(function(e){return e.startsWith("uv")}),(e=e instanceof f.MultiMaterial?e.subMaterials[r.materialIndex]:e)instanceof f.PBRBaseMaterial?[4,this._materialExporter.exportPBRMaterialAsync(e,o)]:[3,2]);case 1:return s=i.sent(),[3,7];case 2:return e instanceof f.StandardMaterial?[4,this._materialExporter.exportStandardMaterialAsync(e,o)]:[3,4];case 3:return s=i.sent(),[3,7];case 4:return e instanceof f.OpenPBRMaterial?[4,this._materialExporter.exportOpenPBRMaterialAsync(e,o)]:[3,6];case 5:return s=i.sent(),[3,7];case 6:return f.Logger.Warn("Unsupported material '".concat(e.name,"' with type ").concat(e.getClassName())),[2];case 7:this._materialMap.set(e,s),i.label=8;case 8:return n.material=s,[2]}})})},e.prototype._exportMeshAsync=function(e,t){return x(this,void 0,void 0,function(){var r,n,s,o,i,a,u,c,l,h,p,d,x,m,T,y,v,b,w,M,A,R,E,C,I,V,S,F,B,O,N,U,P,W;return g(this,function(g){switch(g.label){case 0:if(void 0!==(r=t.getMesh(e)))return[2,r];if(n={primitives:[]},r=this._meshes.length,this._meshes.push(n),t.setMesh(e,r),s=e.isUnIndexed?null:e.getIndices(),o=null===(B=e.geometry)||void 0===B?void 0:B.getVertexBuffers(),i=t.getMorphTargetsFromMesh(e),a=e instanceof f.LinesMesh,u=e instanceof f.GreasedLineBaseMesh,c=e.subMeshes,!(o&&c&&c.length>0))return[3,7];l=0,h=c,g.label=1;case 1:return l<h.length?(p=h[l],d={attributes:{}},x=p.getMaterial()||this._babylonScene.defaultMaterial,u?(v={name:x.name},b=e,m=f.Color3.White(),T=null!==(N=null===(O=b.material)||void 0===O?void 0:O.alpha)&&void 0!==N?N:1,(!(y=null!==(P=null===(U=b.greasedLineMaterial)||void 0===U?void 0:U.color)&&void 0!==P?P:m).equalsWithEpsilon(m,f.Epsilon)||T<1)&&(v.pbrMetallicRoughness={baseColorFactor:_(_([],y.asArray(),!0),[T],!1)}),this._materials.push(v),d.material=this._materials.length-1,[3,5]):[3,2]):[3,7];case 2:return a?(v={name:x.name},(!(b=e).color.equalsWithEpsilon(f.Color3.White(),f.Epsilon)||b.alpha<1)&&(v.pbrMetallicRoughness={baseColorFactor:_(_([],b.color.asArray(),!0),[b.alpha],!1)}),this._materials.push(v),d.material=this._materials.length-1,[3,5]):[3,3];case 3:return[4,this._exportMaterialAsync(x,o,p,d)];case 4:g.sent(),g.label=5;case 5:for(w=a||u?f.Material.LineListDrawMode:null!==(W=e.overrideRenderingFillMode)&&void 0!==W?W:x.fillMode,M=x._getEffectiveOrientation(e),t.wasAddedByNoopNode&&!e.getScene().useRightHandedSystem&&(M=M===f.Material.ClockWiseSideOrientation?f.Material.CounterClockWiseSideOrientation:f.Material.ClockWiseSideOrientation),this._exportIndices(s,s?(0,f.AreIndices32Bits)(s,p.indexCount,p.indexStart,p.verticesStart):p.verticesCount>65535,s?p.indexStart:p.verticesStart,s?p.indexCount:p.verticesCount,-p.verticesStart,w,M,t,d),A=0,R=Object.values(o);A<R.length;A++)E=R[A],this._exportVertexBuffer(E,x,p.verticesStart,p.verticesCount,t,d);if(i)for(d.targets=[],C=0,I=i;C<I.length;C++)F=I[C],d.targets.push(F.attributes);n.primitives.push(d),this._extensionsPostExportMeshPrimitive(d),g.label=6;case 6:return l++,[3,1];case 7:if(i)for(n.weights=[],n.extras||(n.extras={}),n.extras.targetNames=[],V=0,S=i;V<S.length;V++)F=S[V],n.weights.push(F.influence),n.extras.targetNames.push(F.name);return[2,r]}})})},e._ExtensionNames=new Array,e._ExtensionFactories={},e._ExtensionOrders={},e}(),oe=function(){function e(){}return e.GLTFAsync=function(e,t,r){return x(this,void 0,void 0,function(){var n,s;return g(this,function(o){switch(o.label){case 0:return r&&r.exportWithoutWaitingForScene?[3,2]:[4,e.whenReadyAsync()];case 1:o.sent(),o.label=2;case 2:return[4,(n=new se(e,r)).generateGLTFAsync(t.replace(/\.[^/.]+$/,""))];case 3:return s=o.sent(),n.dispose(),[2,s]}})})},e.GLBAsync=function(e,t,r){return x(this,void 0,void 0,function(){var n,s;return g(this,function(o){switch(o.label){case 0:return r&&r.exportWithoutWaitingForScene?[3,2]:[4,e.whenReadyAsync()];case 1:o.sent(),o.label=2;case 2:return[4,(n=new se(e,r)).generateGLBAsync(t.replace(/\.[^/.]+$/,""))];case 3:return s=o.sent(),n.dispose(),[2,s]}})})},e}(),ie="EXT_mesh_gpu_instancing";function ae(e,t){for(var r=new Float32Array(3*t),n=0;n<t;n++)r[3*n+0]=e[4*n+0],r[3*n+1]=e[4*n+1],r[3*n+2]=e[4*n+2];return r}var ue=function(){function e(e){this.name=ie,this.enabled=!0,this.required=!1,this._instanceColorWarned=!1,this._wasUsed=!1,this._exporter=e}return e.prototype.dispose=function(){},Object.defineProperty(e.prototype,"wasUsed",{get:function(){return this._wasUsed},enumerable:!1,configurable:!0}),e.prototype.postExportNodeAsync=function(e,t,r,n,s,o){return x(this,void 0,void 0,function(){var e=this;return g(this,function(n){switch(n.label){case 0:return[4,new Promise(function(n){var i,a;if(t&&r instanceof f.Mesh&&r.hasThinInstances&&e._exporter){e._wasUsed=!0;for(var u=f.Vector3.Zero(),c=f.Quaternion.Identity(),l=f.Vector3.One(),h=r.thinInstanceGetWorldMatrices(),p=f.TmpVectors.Vector3[2],d=f.TmpVectors.Quaternion[1],x=f.TmpVectors.Vector3[3],g=!1,_=!1,m=!1,T=new Float32Array(3*r.thinInstanceCount),y=new Float32Array(4*r.thinInstanceCount),v=new Float32Array(3*r.thinInstanceCount),b=0,w=0,M=h;w<M.length;w++)M[w].decompose(x,d,p),s&&(k(p),D(d)),T.set(p.asArray(),3*b),y.set(d.normalize().asArray(),4*b),v.set(x.asArray(),3*b),g=g||!p.equalsWithEpsilon(u),_=_||!d.equalsWithEpsilon(c),m=m||!x.equalsWithEpsilon(l),b++;var A={attributes:{}};g&&(A.attributes.TRANSLATION=e._buildAccessor(T,"VEC3",r.thinInstanceCount,o)),_&&(A.attributes.ROTATION=e._buildAccessor(y,"VEC4",r.thinInstanceCount,o)),m&&(A.attributes.SCALE=e._buildAccessor(v,"VEC3",r.thinInstanceCount,o));var R=null===(a=null===(i=r._userThinInstanceBuffersStorage)||void 0===i?void 0:i.data)||void 0===a?void 0:a.instanceColor;if(R){var E=r.thinInstanceCount;r.hasVertexAlpha&&R.length===4*E?(e._instanceColorWarned||(f.Logger.Warn("EXT_mesh_gpu_instancing: Exporting instance colors as RGB, alpha channel of instance color is not exported"),e._instanceColorWarned=!0),R=ae(R,E)):R.length===4*E&&(R=ae(R,E)),R.length===3*E&&(A.attributes._COLOR_0=e._buildAccessor(R,"VEC3",E,o))}t.extensions=t.extensions||{},t.extensions[ie]=A}n(t)})];case 1:return[2,n.sent()]}})})},e.prototype._buildAccessor=function(e,t,r,n){var s=n.createBufferView(e),o=n.createAccessor(s,t,5126,r);return this._exporter._accessors.push(o),this._exporter._accessors.length-1},e}();se.RegisterExtension(ie,function(e){return new ue(e)});var ce="KHR_draco_mesh_compression";function le(e){return"POSITION"===e?"POSITION":"NORMAL"===e?"NORMAL":e.startsWith("COLOR")?"COLOR":e.startsWith("TEXCOORD")?"TEX_COORD":"GENERIC"}var he=function(){function e(e){this.name=ce,this.required=!0,this._bufferViewsUsed=new Set,this._accessorsUsed=new Set,this._encodePromises=[],this._wasUsed=!1,this.enabled="Draco"===e.options.meshCompressionMethod&&f.DracoEncoder.DefaultAvailable}return Object.defineProperty(e.prototype,"wasUsed",{get:function(){return this._wasUsed},enumerable:!1,configurable:!0}),e.prototype.dispose=function(){},e.prototype.postExportMeshPrimitive=function(e,t,r){var n=this;if(this.enabled)if(4===e.mode||5===e.mode){var s=[],o=[],i=null;if(void 0!==e.indices){var a=r[e.indices],u=t.getBufferView(a);i=t.getData(u).slice(),s.push(u),o.push(a)}for(var c=[],l=0,h=Object.entries(e.attributes);l<h.length;l++){var p=h[l],d=p[0],x=(a=r[p[1]],u=t.getBufferView(a),W(a.type)),g=(0,f.GetTypedArrayData)(t.getData(u),x,a.componentType,a.byteOffset||0,u.byteStride||(0,f.GetTypeByteLength)(a.componentType)*x,a.count,!0);c.push({kind:d,dracoName:le(d),size:W(a.type),data:g}),s.push(u),o.push(a)}var _={method:e.targets?"MESH_SEQUENTIAL_ENCODING":"MESH_EDGEBREAKER_ENCODING"},m=f.DracoEncoder.Default._encodeAsync(c,i,_).then(function(r){var i={bufferView:-1,attributes:r.attributeIds},a=t.createBufferView(r.data);t.setBufferView(i,a);for(var u=0,c=s;u<c.length;u++){var l=c[u];n._bufferViewsUsed.add(l)}for(var h=0,f=o;h<f.length;h++){var p=f[h];n._accessorsUsed.add(p)}e.extensions||(e.extensions={}),e.extensions[ce]=i}).catch(function(e){f.Logger.Error("KHR_draco_mesh_compression: Failed to export Draco-encoded primitive. Resulting glTF may be invalid. "+e.message)});this._encodePromises.push(m),this._wasUsed=!0}else f.Logger.Warn("Cannot compress primitive with mode "+e.mode+".")},e.prototype.preGenerateBinaryAsync=function(e){return x(this,void 0,void 0,function(){var t=this;return g(this,function(r){switch(r.label){case 0:return this.enabled?[4,Promise.all(this._encodePromises)]:[2];case 1:return r.sent(),this._bufferViewsUsed.forEach(function(r){e.getPropertiesWithBufferView(r).every(function(e){return t._accessorsUsed.has(e)})&&e.removeBufferView(r)}),this._bufferViewsUsed.clear(),this._accessorsUsed.clear(),[2]}})})},e}();se.RegisterExtension(ce,function(e){return new he(e)});var fe="KHR_lights_punctual",pe={name:"",color:[1,1,1],intensity:1,range:Number.MAX_VALUE},de={innerConeAngle:0,outerConeAngle:Math.PI/4},xe=f.Vector3.Backward(),ge=function(){function e(e){this.name=fe,this.enabled=!0,this.required=!1,this._exporter=e}return e.prototype.dispose=function(){this._lights=null},Object.defineProperty(e.prototype,"wasUsed",{get:function(){return!!this._lights},enumerable:!1,configurable:!0}),e.prototype.onExporting=function(){this._exporter._glTF.extensions[fe]=this._lights},e.prototype.postExportNodeAsync=function(e,t,r,n,s){return x(this,void 0,void 0,function(){var o=this;return g(this,function(i){switch(i.label){case 0:return[4,new Promise(function(i){if(r instanceof f.Light){var a=r.getTypeID()==f.Light.LIGHTTYPEID_POINTLIGHT?"point":r.getTypeID()==f.Light.LIGHTTYPEID_DIRECTIONALLIGHT?"directional":r.getTypeID()==f.Light.LIGHTTYPEID_SPOTLIGHT?"spot":null;if(!(a&&r instanceof f.ShadowLight))return f.Logger.Warn("".concat(e,": Light ").concat(r.name," is not supported in ").concat(fe)),void i(t);if(r.falloffType!==f.Light.FALLOFF_GLTF&&f.Logger.Warn("".concat(e,": Light falloff for ").concat(r.name," does not match the ").concat(fe," specification!")),!r.position.equalsToFloats(0,0,0)){var u=f.TmpVectors.Vector3[0].copyFrom(r.position);s&&k(u),t.translation=u.asArray()}if("point"!==a){var c=r.direction.normalizeToRef(f.TmpVectors.Vector3[0]);s&&k(c);var l=f.Quaternion.FromUnitVectorsToRef(xe,c,f.TmpVectors.Quaternion[0]);f.Quaternion.IsIdentity(l)||(t.rotation=l.asArray())}var h={type:a,name:r.name,color:r.diffuse.asArray(),intensity:r.intensity,range:r.range};if(Q(h,pe),"spot"===a){var p=r;h.spot={innerConeAngle:p.innerAngle/2,outerConeAngle:p.angle/2},Q(h.spot,de)}o._lights||(o._lights={lights:[]}),o._lights.lights.push(h);var d={light:o._lights.lights.length-1},x=r.parent;if(x&&j(r,x)){var g=n.get(x);if(g){var _=o._exporter._nodes[g];return q(t,_),_.extensions||(_.extensions={}),_.extensions[fe]=d,void i(null)}}t.extensions||(t.extensions={}),t.extensions[fe]=d,i(t)}else i(t)})];case 1:return[2,i.sent()]}})})},e}();se.RegisterExtension(fe,function(e){return new ge(e)});var _e="EXT_lights_area",me={name:"",color:[1,1,1],intensity:1,size:1},Te={aspect:1},ye=f.Vector3.Backward(),ve=function(){function e(e){this.name=_e,this.enabled=!0,this.required=!1,this._exporter=e}return e.prototype.dispose=function(){this._lights=null},Object.defineProperty(e.prototype,"wasUsed",{get:function(){return!!this._lights},enumerable:!1,configurable:!0}),e.prototype.onExporting=function(){this._exporter._glTF.extensions[_e]=this._lights},e.prototype.postExportNodeAsync=function(e,t,r,n,s){return x(this,void 0,void 0,function(){var o=this;return g(this,function(i){switch(i.label){case 0:return[4,new Promise(function(i){if(r instanceof f.Light){var a=r.getTypeID()==f.Light.LIGHTTYPEID_RECT_AREALIGHT?"rect":null;if(!a)return f.Logger.Warn("".concat(e,": Light ").concat(r.name," is not supported in ").concat(_e)),void i(t);var u=r;if(u.falloffType!==f.Light.FALLOFF_GLTF&&f.Logger.Warn("".concat(e,": Light falloff for ").concat(r.name," does not match the ").concat(_e," specification!")),!u.position.equalsToFloats(0,0,0)){var c=f.TmpVectors.Vector3[0].copyFrom(u.position);s&&k(c),t.translation=c.asArray()}var l=f.Vector3.Forward();s&&k(l);var h=f.Quaternion.FromUnitVectorsToRef(ye,l,f.TmpVectors.Quaternion[0]);f.Quaternion.IsIdentity(h)||(t.rotation=h.asArray());var p={type:a,name:u.name,color:u.diffuse.asArray(),intensity:u.intensity,size:u.height,rect:{aspect:u.width/u.height}};Q(p,me),p.rect&&Q(p.rect,Te),o._lights||(o._lights={lights:[]}),o._lights.lights.push(p);var d={light:o._lights.lights.length-1},x=r.parent;if(x&&j(u,x)){var g=n.get(x);if(g){var _=o._exporter._nodes[g];return q(t,_),_.extensions||(_.extensions={}),_.extensions[_e]=d,void i(null)}}t.extensions||(t.extensions={}),t.extensions[_e]=d,i(t)}else i(t)})];case 1:return[2,i.sent()]}})})},e}();se.RegisterExtension(_e,function(e){return new ve(e)});var be="KHR_materials_anisotropy";function we(e){return x(this,void 0,void 0,function(){var t,r,n;return g(this,function(s){switch(s.label){case 0:return t=e.getScene(),r=e.specularRoughnessAnisotropyTexture,n=e.geometryTangentTexture,r||n?[4,(0,f.MergeTexturesAsync)("AnisotropyTexture",(0,f.CreateRGBAConfiguration)(n?(0,f.CreateTextureInput)(n,0):(0,f.CreateConstantInput)(1),n?(0,f.CreateTextureInput)(n,1):(0,f.CreateConstantInput)(0),r?(0,f.CreateTextureInput)(r,0):(0,f.CreateConstantInput)(1)),t)]:[2,null];case 1:return[2,s.sent()]}})})}var Me=function(){function e(e){this.name=be,this.enabled=!0,this.required=!1,this._wasUsed=!1,this._anisoTexturesMap={},this._exporter=e}return e.prototype.dispose=function(){},Object.defineProperty(e.prototype,"wasUsed",{get:function(){return this._wasUsed},enumerable:!1,configurable:!0}),e.prototype.postExportMaterialAdditionalTexturesAsync=function(e,t,r){return x(this,void 0,void 0,function(){var e,t,n;return g(this,function(s){switch(s.label){case 0:return e=[],r instanceof f.PBRBaseMaterial?r.anisotropy.isEnabled&&!r.anisotropy.legacy?(r.anisotropy.texture&&e.push(r.anisotropy.texture),[2,e]):[3,5]:[3,1];case 1:return r instanceof f.OpenPBRMaterial&&r.specularRoughnessAnisotropy>0?(t=function(e){var t=e.specularRoughnessAnisotropyTexture,r=e.geometryTangentTexture,n=t&&t.getInternalTexture()?t.getInternalTexture().uniqueId:"NoStrength",s=r&&r.getInternalTexture()?r.getInternalTexture().uniqueId:"NoTangent";return"".concat(n,"_").concat(s)}(r),this._anisoTexturesMap[t]?(e.push(this._anisoTexturesMap[t]),[3,4]):[3,2]):[3,5];case 2:return[4,we(r)];case 3:(n=s.sent())&&(e.push(n),this._anisoTexturesMap[t]=n),s.label=4;case 4:return[2,e];case 5:return[2,[]]}})})},e.prototype.postExportMaterialAsync=function(e,t,r){var n=this;return new Promise(function(e){var s,o,i,a,u,c;if(r instanceof f.PBRBaseMaterial){if(!r.anisotropy.isEnabled||r.anisotropy.legacy)return void e(t);n._wasUsed=!0,t.extensions=t.extensions||{};var l=n._exporter._materialExporter.getTextureInfo(r.anisotropy.texture);null!==(T={anisotropyStrength:r.anisotropy.intensity,anisotropyRotation:r.anisotropy.angle,anisotropyTexture:null!=l?l:void 0}).anisotropyTexture&&n._exporter._materialNeedsUVsSet.add(r),t.extensions[be]=T}else if(r instanceof f.OpenPBRMaterial&&r.specularRoughnessAnisotropy>0){n._wasUsed=!0,t.extensions=t.extensions||{};var h=r.specularRoughnessTexture;r._useRoughnessFromMetallicTextureGreen&&(h=r.baseMetalnessTexture);var p=n._anisoTexturesMap[r.id];if(!h&&!p){var d=r.specularRoughness,x=r.specularRoughnessAnisotropy;if(!r._useGltfStyleAnisotropy){var g=(o=r.specularRoughness,c=(1-(i=r.specularRoughnessAnisotropy))*(u=(a=o*o)*Math.sqrt(2/(1+(1-i)*(1-i)))),{newBaseRoughness:Math.sqrt(c),newAnisotropyStrength:Math.min(Math.sqrt((u-a)/Math.max(1-a,1e-4)),1)});d=g.newBaseRoughness,x=g.newAnisotropyStrength}t.pbrMetallicRoughness&&(t.pbrMetallicRoughness.roughnessFactor=d);var _={anisotropyStrength:x,anisotropyRotation:r.geometryTangentAngle+.5*Math.PI,anisotropyTexture:void 0};return t.extensions[be]=_,e(t)}var m=p?n._exporter._materialExporter.getTextureInfo(p):null,T={anisotropyStrength:r.specularRoughnessAnisotropy,anisotropyRotation:r.geometryTangentAngle,anisotropyTexture:m||void 0,extensions:{}};r._useGltfStyleAnisotropy||(t.extensions.KHR_materials_openpbr={},(s=n._exporter._glTF).extensionsUsed||(s.extensionsUsed=[]),-1===n._exporter._glTF.extensionsUsed.indexOf("KHR_materials_openpbr")&&n._exporter._glTF.extensionsUsed.push("KHR_materials_openpbr")),n._exporter._materialNeedsUVsSet.add(r),t.extensions[be]=T}e(t)})},e}();se.RegisterExtension(be,function(e){return new Me(e)});var Ae="KHR_materials_clearcoat";function Re(e){return x(this,void 0,void 0,function(){var t,r,n;return g(this,function(s){switch(s.label){case 0:return t=e.getScene(),r=e.coatWeightTexture,n=e.coatRoughnessTexture,r||n?[4,(0,f.MergeTexturesAsync)("CoatTexture",(0,f.CreateRGBAConfiguration)(r?(0,f.CreateTextureInput)(r,0):(0,f.CreateConstantInput)(1),n?(0,f.CreateTextureInput)(n,e._useCoatRoughnessFromGreenChannel?1:0):(0,f.CreateConstantInput)(1)),t)]:[2,null];case 1:return[2,s.sent().getInternalTexture()]}})})}function Ee(e,t){var r=new f.Texture(t.name,t.getScene());return r._texture=e,r.coordinatesIndex=t.coordinatesIndex,t instanceof f.Texture&&(r.uOffset=t.uOffset,r.vOffset=t.vOffset,r.uScale=t.uScale,r.vScale=t.vScale,r.wAng=t.wAng),r.wrapU=t.wrapU,r.wrapV=t.wrapV,r}var Ce=function(){function e(e){this.name=Ae,this.enabled=!0,this.required=!1,this._wasUsed=!1,this._mergedTexturesMap={},this._cachedInternalTexturesMap={},this._exporter=e}return e.prototype.dispose=function(){for(var e=0,t=Object.keys(this._mergedTexturesMap);e<t.length;e++){var r=t[e];this._mergedTexturesMap[r].dispose()}this._mergedTexturesMap={};for(var n=0,s=Object.keys(this._cachedInternalTexturesMap);n<s.length;n++)r=s[n],this._cachedInternalTexturesMap[r].dispose();this._cachedInternalTexturesMap={}},Object.defineProperty(e.prototype,"wasUsed",{get:function(){return this._wasUsed},enumerable:!1,configurable:!0}),e.prototype.postExportMaterialAdditionalTexturesAsync=function(e,t,r){return x(this,void 0,void 0,function(){var e,t,n,s;return g(this,function(o){switch(o.label){case 0:return e=[],r instanceof f.PBRBaseMaterial?r.clearCoat.isEnabled?(r.clearCoat.texture&&e.push(r.clearCoat.texture),!r.clearCoat.useRoughnessFromMainTexture&&r.clearCoat.textureRoughness&&e.push(r.clearCoat.textureRoughness),r.clearCoat.bumpTexture&&e.push(r.clearCoat.bumpTexture),[2,e]):[3,5]:[3,1];case 1:return r instanceof f.OpenPBRMaterial&&r.coatWeight>0?(t=!1,r.coatWeightTexture?r.coatRoughnessTexture?r._useCoatRoughnessFromGreenChannel&&r.coatWeightTexture.getInternalTexture()===r.coatRoughnessTexture.getInternalTexture()?(e.push(r.coatWeightTexture),e.push(r.coatRoughnessTexture)):t=!0:e.push(r.coatWeightTexture):r.coatRoughnessTexture&&(r._useCoatRoughnessFromGreenChannel?e.push(r.coatRoughnessTexture):t=!0),t?(n=function(e){var t=e.coatWeightTexture,r=t&&t.getInternalTexture()?t.getInternalTexture().uniqueId:"NoCoat",n=e.coatRoughnessTexture,s=n&&n.getInternalTexture()?n.getInternalTexture().uniqueId:"NoRoughness";return"".concat(r,"_").concat(s)}(r),this._cachedInternalTexturesMap[n]?[3,3]:[4,Re(r)]):[3,4]):[3,5];case 2:(s=o.sent())&&(this._cachedInternalTexturesMap[n]=s),o.label=3;case 3:this._cachedInternalTexturesMap[n]&&(r.coatWeightTexture&&(this._mergedTexturesMap[r.coatWeightTexture.uniqueId]=Ee(this._cachedInternalTexturesMap[n],r.coatWeightTexture),e.push(this._mergedTexturesMap[r.coatWeightTexture.uniqueId])),r.coatRoughnessTexture&&(this._mergedTexturesMap[r.coatRoughnessTexture.uniqueId]=Ee(this._cachedInternalTexturesMap[n],r.coatRoughnessTexture),e.push(this._mergedTexturesMap[r.coatRoughnessTexture.uniqueId]))),o.label=4;case 4:return r.geometryCoatNormalTexture&&e.push(r.geometryCoatNormalTexture),[2,e];case 5:return[2,[]]}})})},e.prototype.postExportMaterialAsync=function(e,t,r){var n=this;return new Promise(function(e){if(r instanceof f.PBRBaseMaterial){if(!r.clearCoat.isEnabled)return void e(t);n._wasUsed=!0,t.extensions=t.extensions||{};var s,o=n._exporter._materialExporter.getTextureInfo(r.clearCoat.texture);s=r.clearCoat.useRoughnessFromMainTexture?n._exporter._materialExporter.getTextureInfo(r.clearCoat.texture):n._exporter._materialExporter.getTextureInfo(r.clearCoat.textureRoughness),r.clearCoat.isTintEnabled&&f.Tools.Warn("Clear Color tint is not supported for glTF export. Ignoring for: ".concat(r.name)),r.clearCoat.remapF0OnInterfaceChange&&f.Tools.Warn("Clear Color F0 remapping is not supported for glTF export. Ignoring for: ".concat(r.name));var i=n._exporter._materialExporter.getTextureInfo(r.clearCoat.bumpTexture);null===(c={clearcoatFactor:r.clearCoat.intensity,clearcoatTexture:null!=o?o:void 0,clearcoatRoughnessFactor:r.clearCoat.roughness,clearcoatRoughnessTexture:null!=s?s:void 0,clearcoatNormalTexture:null!=i?i:void 0}).clearcoatTexture&&null===c.clearcoatRoughnessTexture&&null===c.clearcoatRoughnessTexture||n._exporter._materialNeedsUVsSet.add(r),t.extensions[Ae]=c}else if(r instanceof f.OpenPBRMaterial){if(0==r.coatWeight)return void e(t);n._wasUsed=!0,t.extensions=t.extensions||{};var a=void 0,u=void 0;r.coatWeightTexture&&(a=n._mergedTexturesMap[r.coatWeightTexture.uniqueId],u=n._exporter._materialExporter.getTextureInfo(a));var c,l=void 0,h=void 0;r.coatRoughnessTexture&&(l=n._mergedTexturesMap[r.coatRoughnessTexture.uniqueId],h=n._exporter._materialExporter.getTextureInfo(l)),r.coatColorTexture&&f.Tools.Warn("Clear Color tint is not supported for glTF export. Ignoring for: ".concat(r.name)),i=n._exporter._materialExporter.getTextureInfo(r.geometryCoatNormalTexture),null===(c={clearcoatFactor:r.coatWeight,clearcoatTexture:null!=u?u:void 0,clearcoatRoughnessFactor:r.coatRoughness,clearcoatRoughnessTexture:null!=h?h:void 0,clearcoatNormalTexture:null!=i?i:void 0}).clearcoatTexture&&null===c.clearcoatRoughnessTexture&&null===c.clearcoatRoughnessTexture||n._exporter._materialNeedsUVsSet.add(r),t.extensions[Ae]=c}e(t)})},e}();se.RegisterExtension(Ae,function(e){return new Ce(e)});var Ie="KHR_materials_coat";function Ve(e){var t=e.coatRoughnessAnisotropyTexture,r=e.geometryCoatTangentTexture,n=t&&t.getInternalTexture()?t.getInternalTexture().uniqueId:"NoStrength",s=r&&r.getInternalTexture()?r.getInternalTexture().uniqueId:"NoTangent";return"".concat(n,"_").concat(s)}function Se(e){return x(this,void 0,void 0,function(){var t,r,n;return g(this,function(s){switch(s.label){case 0:return t=e.getScene(),r=e.coatRoughnessAnisotropyTexture,n=e.geometryCoatTangentTexture,r||n?[4,(0,f.MergeTexturesAsync)("AnisotropyTexture",(0,f.CreateRGBAConfiguration)(n?(0,f.CreateTextureInput)(n,0):(0,f.CreateConstantInput)(1),n?(0,f.CreateTextureInput)(n,1):(0,f.CreateConstantInput)(0),r?(0,f.CreateTextureInput)(r,0):(0,f.CreateConstantInput)(1)),t)]:[2,null];case 1:return[2,s.sent()]}})})}function Fe(e){return x(this,void 0,void 0,function(){var t,r,n;return g(this,function(s){switch(s.label){case 0:return t=e.getScene(),r=e.coatWeightTexture,n=e.coatRoughnessTexture,r||n?[4,(0,f.MergeTexturesAsync)("CoatTexture",(0,f.CreateRGBAConfiguration)(r?(0,f.CreateTextureInput)(r,0):(0,f.CreateConstantInput)(1),n?(0,f.CreateTextureInput)(n,e._useCoatRoughnessFromGreenChannel?1:0):(0,f.CreateConstantInput)(1)),t)]:[2,null];case 1:return[2,s.sent().getInternalTexture()]}})})}function Be(e,t){var r=new f.Texture(t.name,t.getScene());return r._texture=e,r.coordinatesIndex=t.coordinatesIndex,t instanceof f.Texture&&(r.uOffset=t.uOffset,r.vOffset=t.vOffset,r.uScale=t.uScale,r.vScale=t.vScale,r.wAng=t.wAng),r.wrapU=t.wrapU,r.wrapV=t.wrapV,r}var Oe=function(){function e(e){this.name=Ie,this.enabled=!0,this.required=!1,this._wasUsed=!1,this._mergedTexturesMap={},this._cachedInternalTexturesMap={},this._exporter=e}return e.prototype.dispose=function(){for(var e=0,t=Object.keys(this._mergedTexturesMap);e<t.length;e++){var r=t[e];this._mergedTexturesMap[r].dispose()}this._mergedTexturesMap={};for(var n=0,s=Object.keys(this._cachedInternalTexturesMap);n<s.length;n++)r=s[n],this._cachedInternalTexturesMap[r].dispose();this._cachedInternalTexturesMap={}},Object.defineProperty(e.prototype,"wasUsed",{get:function(){return this._wasUsed},enumerable:!1,configurable:!0}),e.prototype.postExportMaterialAdditionalTexturesAsync=function(e,t,r){return x(this,void 0,void 0,function(){var e,t,n,s,o;return g(this,function(i){switch(i.label){case 0:return e=[],r instanceof f.PBRBaseMaterial?r.clearCoat.isEnabled?(r.clearCoat.texture&&e.push(r.clearCoat.texture),!r.clearCoat.useRoughnessFromMainTexture&&r.clearCoat.textureRoughness&&e.push(r.clearCoat.textureRoughness),r.clearCoat.bumpTexture&&e.push(r.clearCoat.bumpTexture),r.clearCoat.tintTexture&&e.push(r.clearCoat.tintTexture),[2,e]):[3,9]:[3,1];case 1:return r instanceof f.OpenPBRMaterial&&r.coatWeight>0?(t=!1,r.coatWeightTexture?r.coatRoughnessTexture?r._useCoatRoughnessFromGreenChannel&&r.coatWeightTexture.getInternalTexture()===r.coatRoughnessTexture.getInternalTexture()?(e.push(r.coatWeightTexture),e.push(r.coatRoughnessTexture)):t=!0:e.push(r.coatWeightTexture):r.coatRoughnessTexture&&(r._useCoatRoughnessFromGreenChannel?e.push(r.coatRoughnessTexture):t=!0),t?(s=function(e){var t=e.coatWeightTexture,r=t&&t.getInternalTexture()?t.getInternalTexture().uniqueId:"NoCoat",n=e.coatRoughnessTexture,s=n&&n.getInternalTexture()?n.getInternalTexture().uniqueId:"NoRoughness";return"".concat(r,"_").concat(s)}(r),this._cachedInternalTexturesMap[s]?[3,3]:[4,Fe(r)]):[3,4]):[3,9];case 2:(n=i.sent())&&(this._cachedInternalTexturesMap[s]=n),i.label=3;case 3:this._cachedInternalTexturesMap[s]&&(r.coatWeightTexture&&(this._mergedTexturesMap[r.coatWeightTexture.uniqueId]=Be(this._cachedInternalTexturesMap[s],r.coatWeightTexture),e.push(this._mergedTexturesMap[r.coatWeightTexture.uniqueId])),r.coatRoughnessTexture&&(this._mergedTexturesMap[r.coatRoughnessTexture.uniqueId]=Be(this._cachedInternalTexturesMap[s],r.coatRoughnessTexture),e.push(this._mergedTexturesMap[r.coatRoughnessTexture.uniqueId]))),i.label=4;case 4:return r.geometryCoatNormalTexture&&e.push(r.geometryCoatNormalTexture),r.coatColorTexture&&e.push(r.coatColorTexture),r.coatRoughnessAnisotropy>0?(s=Ve(r),this._mergedTexturesMap[s]?(e.push(this._mergedTexturesMap[s]),[3,7]):[3,5]):[3,8];case 5:return[4,Se(r)];case 6:(o=i.sent())&&(e.push(o),this._mergedTexturesMap[s]=o),i.label=7;case 7:case 8:return[2,e];case 9:return[2,[]]}})})},e.prototype.postExportMaterialAsync=function(e,t,r){var n=this;return new Promise(function(e){var s,o,i,a,u,c;if(r instanceof f.PBRBaseMaterial){if(!r.clearCoat.isEnabled)return void e(t);n._wasUsed=!0,t.extensions=t.extensions||{};var l,h=n._exporter._materialExporter.getTextureInfo(r.clearCoat.texture);l=r.clearCoat.useRoughnessFromMainTexture?n._exporter._materialExporter.getTextureInfo(r.clearCoat.texture):n._exporter._materialExporter.getTextureInfo(r.clearCoat.textureRoughness);var p=void 0;r.clearCoat.isTintEnabled&&(p=n._exporter._materialExporter.getTextureInfo(r.clearCoat.tintTexture));var d=n._exporter._materialExporter.getTextureInfo(r.clearCoat.bumpTexture),x=r.clearCoat.indexOfRefraction;null===(T={coatFactor:r.clearCoat.intensity,coatTexture:null!=h?h:void 0,coatRoughnessFactor:r.clearCoat.roughness,coatRoughnessTexture:null!=l?l:void 0,coatNormalTexture:null!=d?d:void 0,coatColorFactor:r.clearCoat.tintColor.asArray(),coatColorTexture:null!=p?p:void 0,coatIor:1.5!==x?x:void 0}).coatTexture&&null===T.coatRoughnessTexture&&null===T.coatRoughnessTexture&&null===T.coatColorTexture||n._exporter._materialNeedsUVsSet.add(r),t.extensions[Ie]=T}else if(r instanceof f.OpenPBRMaterial){if(0==r.coatWeight)return void e(t);n._wasUsed=!0,t.extensions=t.extensions||{};var g=void 0;h=void 0,r.coatWeightTexture&&(g=n._mergedTexturesMap[r.coatWeightTexture.uniqueId]?n._mergedTexturesMap[r.coatWeightTexture.uniqueId]:r.coatWeightTexture,h=n._exporter._materialExporter.getTextureInfo(g));var _=void 0,m=void 0;r.coatRoughnessTexture&&(_=n._mergedTexturesMap[r.coatRoughnessTexture.uniqueId]?n._mergedTexturesMap[r.coatRoughnessTexture.uniqueId]:r.coatRoughnessTexture,m=n._exporter._materialExporter.getTextureInfo(_)),d=n._exporter._materialExporter.getTextureInfo(r.geometryCoatNormalTexture),p=n._exporter._materialExporter.getTextureInfo(r.coatColorTexture),x=r.coatIor;var T,y=r.coatDarkening,v=r.coatRoughnessTexture,b=Ve(r),w=n._mergedTexturesMap[b],M=0,A=0,R=void 0;if(r.coatRoughnessAnisotropy>0){if(v||w){var E=w?n._exporter._materialExporter.getTextureInfo(w):null;M=r.coatRoughnessAnisotropy,A=r.geometryCoatTangentAngle,R=E||void 0}else{var C=r.coatRoughness,I=r.coatRoughnessAnisotropy;if(!r._useGltfStyleAnisotropy){var V=(o=r.coatRoughness,c=(1-(i=r.coatRoughnessAnisotropy))*(u=(a=o*o)*Math.sqrt(2/(1+(1-i)*(1-i)))),{newBaseRoughness:Math.sqrt(c),newAnisotropyStrength:Math.min(Math.sqrt((u-a)/Math.max(1-a,1e-4)),1)});C=V.newBaseRoughness,I=V.newAnisotropyStrength}t.pbrMetallicRoughness&&(t.pbrMetallicRoughness.roughnessFactor=C),M=I,A=r.geometryCoatTangentAngle+.5*Math.PI,R=void 0}r._useGltfStyleAnisotropy||(t.extensions.KHR_materials_openpbr={},(s=n._exporter._glTF).extensionsUsed||(s.extensionsUsed=[]),-1===n._exporter._glTF.extensionsUsed.indexOf("KHR_materials_openpbr")&&n._exporter._glTF.extensionsUsed.push("KHR_materials_openpbr"))}null===(T={coatFactor:r.coatWeight,coatTexture:null!=h?h:void 0,coatRoughnessFactor:r.coatRoughness,coatRoughnessTexture:null!=m?m:void 0,coatNormalTexture:null!=d?d:void 0,coatColorFactor:r.coatColor.asArray(),coatColorTexture:null!=p?p:void 0,coatIor:1.5!==x?x:void 0,coatDarkeningFactor:1!==y?y:void 0,coatAnisotropyRotation:A,coatAnisotropyStrength:M,coatAnisotropyTexture:R}).coatTexture&&null===T.coatRoughnessTexture&&null===T.coatRoughnessTexture&&null===T.coatAnisotropyTexture&&null===T.coatColorTexture||n._exporter._materialNeedsUVsSet.add(r),t.extensions[Ie]=T}e(t)})},e}();se.RegisterExtension(Ie,function(e){return new Oe(e)});var Ne="KHR_materials_diffuse_transmission";function Ue(e,t){var r=t.subSurface,n=null;return r.translucencyIntensityTexture?n=r.translucencyIntensityTexture:r.thicknessTexture&&r.useMaskFromThicknessTexture&&(n=r.thicknessTexture),n&&!r.useGltfStyleTextures?(f.Logger.Warn("".concat(e,": Translucency intensity texture is not supported when useGltfStyleTextures = false. Ignoring for: ").concat(t.name),1),null):n}var Pe=function(){function e(e){this.name=Ne,this.enabled=!0,this.required=!1,this._wasUsed=!1,this._exporter=e}return e.prototype.dispose=function(){},Object.defineProperty(e.prototype,"wasUsed",{get:function(){return this._wasUsed},enumerable:!1,configurable:!0}),e.prototype.postExportMaterialAdditionalTexturesAsync=function(e,t,r){return x(this,void 0,void 0,function(){var t,n;return g(this,function(s){return t=[],r instanceof f.PBRMaterial&&this._isExtensionEnabled(r)?((n=Ue(e,r))&&t.push(n),r.subSurface.translucencyColorTexture&&t.push(r.subSurface.translucencyColorTexture),[2,t]):[2,t]})})},e.prototype._isExtensionEnabled=function(e){if(e.unlit)return!1;var t=e.subSurface;return!!t.isTranslucencyEnabled&&!e.unlit&&!t.useAlbedoToTintTranslucency&&t.useGltfStyleTextures&&1===t.volumeIndexOfRefraction&&0===t.minimumThickness&&0===t.maximumThickness},e.prototype.postExportMaterialAsync=function(e,t,r){var n=this;return new Promise(function(s){var o,i;if(r instanceof f.PBRMaterial&&n._isExtensionEnabled(r)){n._wasUsed=!0;var a=r.subSurface,u=Ue(e,r),c=0==a.translucencyIntensity?void 0:a.translucencyIntensity,l=null!==(o=n._exporter._materialExporter.getTextureInfo(u))&&void 0!==o?o:void 0,h=!a.translucencyColor||a.translucencyColor.equalsFloats(1,1,1)?void 0:a.translucencyColor.asArray(),p=null!==(i=n._exporter._materialExporter.getTextureInfo(a.translucencyColorTexture))&&void 0!==i?i:void 0,d={diffuseTransmissionFactor:c,diffuseTransmissionTexture:l,diffuseTransmissionColorFactor:h,diffuseTransmissionColorTexture:p};(l||p)&&n._exporter._materialNeedsUVsSet.add(r),t.extensions=t.extensions||{},t.extensions[Ne]=d}s(t)})},e}();se.RegisterExtension(Ne,function(e){return new Pe(e)});var We="KHR_materials_dispersion",Le=function(){function e(){this.name=We,this.enabled=!0,this.required=!1,this._wasUsed=!1}return e.prototype.dispose=function(){},Object.defineProperty(e.prototype,"wasUsed",{get:function(){return this._wasUsed},enumerable:!1,configurable:!0}),e.prototype._isExtensionEnabled=function(e){if(e.unlit)return!1;var t=e.subSurface;return!(!t.isRefractionEnabled&&!t.isDispersionEnabled)},e.prototype.postExportMaterialAsync=function(e,t,r){var n=this;return new Promise(function(e){if(r instanceof f.PBRMaterial&&n._isExtensionEnabled(r)){n._wasUsed=!0;var s={dispersion:r.subSurface.dispersion};t.extensions=t.extensions||{},t.extensions[We]=s}e(t)})},e}();se.RegisterExtension(We,function(){return new Le});var ze="KHR_materials_emissive_strength",Ke=function(){function e(){this.name=ze,this.enabled=!0,this.required=!1,this._wasUsed=!1}return e.prototype.dispose=function(){},Object.defineProperty(e.prototype,"wasUsed",{get:function(){return this._wasUsed},enumerable:!1,configurable:!0}),e.prototype.postExportMaterialAsync=function(e,t,r){return x(this,void 0,void 0,function(){var e=this;return g(this,function(n){switch(n.label){case 0:return[4,new Promise(function(n){if(!(r instanceof f.PBRMaterial))return n(t);var s=r.emissiveColor.scale(r.emissiveIntensity),o=Math.max.apply(Math,s.asArray());if(o>1){t.emissiveFactor=s.scale(1/o).asArray(),e._wasUsed=!0;var i={emissiveStrength:o};t.extensions||(t.extensions={}),t.extensions[ze]=i}else t.emissiveFactor=s.asArray();return n(t)})];case 1:return[2,n.sent()]}})})},e}();se.RegisterExtension(ze,function(){return new Ke});var ke="KHR_materials_ior",Ge=function(){function e(){this.name=ke,this.enabled=!0,this.required=!1,this._wasUsed=!1}return e.prototype.dispose=function(){},Object.defineProperty(e.prototype,"wasUsed",{get:function(){return this._wasUsed},enumerable:!1,configurable:!0}),e.prototype._isExtensionEnabled=function(e){return!e.unlit&&null!=e.indexOfRefraction&&1.5!=e.indexOfRefraction},e.prototype.postExportMaterialAsync=function(e,t,r){var n=this;return new Promise(function(e){if(r instanceof f.PBRMaterial&&n._isExtensionEnabled(r)){n._wasUsed=!0;var s={ior:r.indexOfRefraction};t.extensions=t.extensions||{},t.extensions[ke]=s}e(t)})},e}();se.RegisterExtension(ke,function(e){return new Ge});var De="KHR_materials_iridescence",He=function(){function e(e){this.name=De,this.enabled=!0,this.required=!1,this._wasUsed=!1,this._exporter=e}return e.prototype.dispose=function(){},Object.defineProperty(e.prototype,"wasUsed",{get:function(){return this._wasUsed},enumerable:!1,configurable:!0}),e.prototype.postExportMaterialAdditionalTexturesAsync=function(e,t,r){return x(this,void 0,void 0,function(){var e;return g(this,function(t){if(e=[],r instanceof f.PBRBaseMaterial){if(r.iridescence.isEnabled)return r.iridescence.texture&&e.push(r.iridescence.texture),r.iridescence.thicknessTexture&&r.iridescence.thicknessTexture!==r.iridescence.texture&&e.push(r.iridescence.thicknessTexture),[2,e]}else if(r instanceof f.OpenPBRMaterial&&r.thinFilmWeight>0)return r.thinFilmWeightTexture&&e.push(r.thinFilmWeightTexture),r.thinFilmThicknessTexture&&r.thinFilmThicknessTexture!==r.thinFilmWeightTexture&&e.push(r.thinFilmThicknessTexture),[2,e];return[2,[]]})})},e.prototype.postExportMaterialAsync=function(e,t,r){var n=this;return new Promise(function(e){if(r instanceof f.PBRBaseMaterial){if(!r.iridescence.isEnabled)return void e(t);n._wasUsed=!0,t.extensions=t.extensions||{};var s=n._exporter._materialExporter.getTextureInfo(r.iridescence.texture),o=n._exporter._materialExporter.getTextureInfo(r.iridescence.thicknessTexture);null===(i={iridescenceFactor:r.iridescence.intensity,iridescenceIor:r.iridescence.indexOfRefraction,iridescenceThicknessMinimum:r.iridescence.minimumThickness,iridescenceThicknessMaximum:r.iridescence.maximumThickness,iridescenceTexture:null!=s?s:void 0,iridescenceThicknessTexture:null!=o?o:void 0}).iridescenceTexture&&null===i.iridescenceThicknessTexture||n._exporter._materialNeedsUVsSet.add(r),t.extensions[De]=i}else if(r instanceof f.OpenPBRMaterial){if(r.thinFilmWeight<=0)return void e(t);n._wasUsed=!0,t.extensions=t.extensions||{};var i,a=n._exporter._materialExporter.getTextureInfo(r.thinFilmWeightTexture),u=n._exporter._materialExporter.getTextureInfo(r.thinFilmThicknessTexture);null===(i={iridescenceFactor:r.thinFilmWeight,iridescenceIor:r.thinFilmIor,iridescenceThicknessMinimum:1e3*r.thinFilmThicknessMin,iridescenceThicknessMaximum:1e3*r.thinFilmThickness,iridescenceTexture:null!=a?a:void 0,iridescenceThicknessTexture:null!=u?u:void 0}).iridescenceTexture&&null===i.iridescenceThicknessTexture||n._exporter._materialNeedsUVsSet.add(r),t.extensions[De]=i}e(t)})},e}();se.RegisterExtension(De,function(e){return new He(e)});var qe="KHR_materials_sheen",je=function(){function e(e){this.name=qe,this.enabled=!0,this.required=!1,this._wasUsed=!1,this._exporter=e}return e.prototype.dispose=function(){},Object.defineProperty(e.prototype,"wasUsed",{get:function(){return this._wasUsed},enumerable:!1,configurable:!0}),e.prototype.postExportMaterialAdditionalTexturesAsync=function(e,t,r){return x(this,void 0,void 0,function(){return g(this,function(e){return r instanceof f.PBRMaterial&&r.sheen.isEnabled&&r.sheen.texture?[2,[r.sheen.texture]]:[2,[]]})})},e.prototype.postExportMaterialAsync=function(e,t,r){return x(this,void 0,void 0,function(){var e=this;return g(this,function(n){switch(n.label){case 0:return[4,new Promise(function(n){var s,o,i,a;if(r instanceof f.PBRMaterial){if(!r.sheen.isEnabled)return void n(t);e._wasUsed=!0,null==t.extensions&&(t.extensions={});var u={sheenColorFactor:r.sheen.color.asArray(),sheenRoughnessFactor:null!==(s=r.sheen.roughness)&&void 0!==s?s:0};null===u.sheenColorTexture&&null===u.sheenRoughnessTexture||e._exporter._materialNeedsUVsSet.add(r),r.sheen.texture&&(u.sheenColorTexture=null!==(o=e._exporter._materialExporter.getTextureInfo(r.sheen.texture))&&void 0!==o?o:void 0),r.sheen.textureRoughness&&!r.sheen.useRoughnessFromMainTexture?u.sheenRoughnessTexture=null!==(i=e._exporter._materialExporter.getTextureInfo(r.sheen.textureRoughness))&&void 0!==i?i:void 0:r.sheen.texture&&r.sheen.useRoughnessFromMainTexture&&(u.sheenRoughnessTexture=null!==(a=e._exporter._materialExporter.getTextureInfo(r.sheen.texture))&&void 0!==a?a:void 0),t.extensions[qe]=u}n(t)})];case 1:return[2,n.sent()]}})})},e}();se.RegisterExtension(qe,function(e){return new je(e)});var Qe="KHR_materials_fuzz";function Xe(e){return x(this,void 0,void 0,function(){var t,r,n;return g(this,function(s){switch(s.label){case 0:return t=e.getScene(),r=e.fuzzColorTexture,n=e.fuzzRoughnessTexture,r||n?[4,(0,f.MergeTexturesAsync)("FuzzTexture",(0,f.CreateRGBAConfiguration)(r?(0,f.CreateTextureInput)(r,0):(0,f.CreateConstantInput)(1),r?(0,f.CreateTextureInput)(r,1):(0,f.CreateConstantInput)(1),r?(0,f.CreateTextureInput)(r,2):(0,f.CreateConstantInput)(1),n?(0,f.CreateTextureInput)(n,e._useFuzzRoughnessFromTextureAlpha?3:0):(0,f.CreateConstantInput)(1)),t)]:[2,null];case 1:return[2,s.sent().getInternalTexture()]}})})}function Ye(e,t){var r=new f.Texture(t.name,t.getScene());return r._texture=e,r.coordinatesIndex=t.coordinatesIndex,t instanceof f.Texture&&(r.uOffset=t.uOffset,r.vOffset=t.vOffset,r.uScale=t.uScale,r.vScale=t.vScale,r.wAng=t.wAng),r.wrapU=t.wrapU,r.wrapV=t.wrapV,r}var Ze=function(){function e(e){this.name=Qe,this.enabled=!0,this.required=!1,this._wasUsed=!1,this._mergedTexturesMap={},this._cachedInternalTexturesMap={},this._exporter=e}return e.prototype.dispose=function(){for(var e=0,t=Object.keys(this._mergedTexturesMap);e<t.length;e++){var r=t[e];this._mergedTexturesMap[r].dispose()}this._mergedTexturesMap={};for(var n=0,s=Object.keys(this._cachedInternalTexturesMap);n<s.length;n++)r=s[n],this._cachedInternalTexturesMap[r].dispose();this._cachedInternalTexturesMap={}},Object.defineProperty(e.prototype,"wasUsed",{get:function(){return this._wasUsed},enumerable:!1,configurable:!0}),e.prototype.postExportMaterialAdditionalTexturesAsync=function(e,t,r){return x(this,void 0,void 0,function(){var e,t,n,s;return g(this,function(o){switch(o.label){case 0:return r instanceof f.OpenPBRMaterial?(e=[],r.fuzzWeight>0?(r.fuzzWeightTexture&&e.push(r.fuzzWeightTexture),t=!1,r.fuzzRoughnessTexture&&(r._useFuzzRoughnessFromTextureAlpha?e.push(r.fuzzRoughnessTexture):t=!0),r.fuzzColorTexture&&!t&&e.push(r.fuzzColorTexture),t?(n=function(e){var t=e.fuzzColorTexture,r=t&&t.getInternalTexture()?t.getInternalTexture().uniqueId:"NoFuzzColor",n=e.fuzzRoughnessTexture,s=n&&n.getInternalTexture()?n.getInternalTexture().uniqueId:"NoFuzzRoughness";return"FuzzColor_".concat(r,"_FuzzRoughness_").concat(s)}(r),this._cachedInternalTexturesMap[n]?[3,2]:[4,Xe(r)]):[3,3]):[3,3]):[3,4];case 1:(s=o.sent())&&(this._cachedInternalTexturesMap[n]=s),o.label=2;case 2:this._cachedInternalTexturesMap[n]&&(r.fuzzColorTexture&&(this._mergedTexturesMap[r.fuzzColorTexture.uniqueId]=Ye(this._cachedInternalTexturesMap[n],r.fuzzColorTexture),e.push(this._mergedTexturesMap[r.fuzzColorTexture.uniqueId])),r.fuzzRoughnessTexture&&(this._mergedTexturesMap[r.fuzzRoughnessTexture.uniqueId]=Ye(this._cachedInternalTexturesMap[n],r.fuzzRoughnessTexture),e.push(this._mergedTexturesMap[r.fuzzRoughnessTexture.uniqueId]))),o.label=3;case 3:return[2,e];case 4:return[2,[]]}})})},e.prototype.postExportMaterialAsync=function(e,t,r){return x(this,void 0,void 0,function(){var e=this;return g(this,function(n){switch(n.label){case 0:return[4,new Promise(function(n){var s,o,i;if(r instanceof f.OpenPBRMaterial){if(0==r.fuzzWeight)return void n(t);e._wasUsed=!0,null==t.extensions&&(t.extensions={});var a={fuzzFactor:r.fuzzWeight,fuzzColorFactor:r.fuzzColor.asArray(),fuzzRoughnessFactor:r.fuzzRoughness};r.fuzzWeightTexture&&(a.fuzzTexture=null!==(s=e._exporter._materialExporter.getTextureInfo(r.fuzzWeightTexture))&&void 0!==s?s:void 0);var u=void 0;r.fuzzColorTexture&&(u=e._mergedTexturesMap[r.fuzzColorTexture.uniqueId]?e._mergedTexturesMap[r.fuzzColorTexture.uniqueId]:r.fuzzColorTexture,a.fuzzColorTexture=null!==(o=e._exporter._materialExporter.getTextureInfo(u))&&void 0!==o?o:void 0);var c=void 0;r.fuzzRoughnessTexture&&(c=e._mergedTexturesMap[r.fuzzRoughnessTexture.uniqueId]?e._mergedTexturesMap[r.fuzzRoughnessTexture.uniqueId]:r.fuzzRoughnessTexture,a.fuzzRoughnessTexture=null!==(i=e._exporter._materialExporter.getTextureInfo(c))&&void 0!==i?i:void 0),null===a.fuzzColorTexture&&null===a.fuzzRoughnessTexture||e._exporter._materialNeedsUVsSet.add(r),t.extensions[Qe]=a}n(t)})];case 1:return[2,n.sent()]}})})},e}();se.RegisterExtension(Qe,function(e){return new Ze(e)});var Je="KHR_materials_specular",$e=function(){function e(e){this.name=Je,this.enabled=!0,this.required=!1,this._wasUsed=!1,this._exporter=e}return e.prototype.dispose=function(){},Object.defineProperty(e.prototype,"wasUsed",{get:function(){return this._wasUsed},enumerable:!1,configurable:!0}),e.prototype.postExportMaterialAdditionalTexturesAsync=function(e,t,r){return x(this,void 0,void 0,function(){var e;return g(this,function(t){return e=[],r instanceof f.PBRMaterial&&this._isExtensionEnabled(r)?(r.metallicReflectanceTexture&&e.push(r.metallicReflectanceTexture),r.reflectanceTexture&&e.push(r.reflectanceTexture),[2,e]):[2,e]})})},e.prototype._isExtensionEnabled=function(e){return!e.unlit&&(null!=e.metallicF0Factor&&1!=e.metallicF0Factor||null!=e.metallicReflectanceColor&&!e.metallicReflectanceColor.equalsFloats(1,1,1)||this._hasTexturesExtension(e))},e.prototype._hasTexturesExtension=function(e){return null!=e.metallicReflectanceTexture||null!=e.reflectanceTexture},e.prototype.postExportMaterialAsync=function(e,t,r){var n=this;return new Promise(function(e){var s,o,i,a,u;if(r instanceof f.PBRMaterial&&n._isExtensionEnabled(r)){n._wasUsed=!0,t.extensions=t.extensions||{};var c=null!==(s=n._exporter._materialExporter.getTextureInfo(r.metallicReflectanceTexture))&&void 0!==s?s:void 0,l=null!==(o=n._exporter._materialExporter.getTextureInfo(r.reflectanceTexture))&&void 0!==o?o:void 0,h={specularFactor:1==r.metallicF0Factor?void 0:r.metallicF0Factor,specularTexture:c,specularColorFactor:r.metallicReflectanceColor.equalsFloats(1,1,1)?void 0:r.metallicReflectanceColor.asArray(),specularColorTexture:l};n._hasTexturesExtension(r)&&n._exporter._materialNeedsUVsSet.add(r),t.extensions[Je]=h}else if(r instanceof f.OpenPBRMaterial){t.extensions=t.extensions||{};var p=null!==(i=n._exporter._materialExporter.getTextureInfo(r.specularWeightTexture))&&void 0!==i?i:void 0,d=null!==(a=n._exporter._materialExporter.getTextureInfo(r.specularColorTexture))&&void 0!==a?a:void 0,x=1==r.specularWeight?void 0:r.specularWeight,g=r.specularColor.equalsFloats(1,1,1)?void 0:r.specularColor.asArray();if(!d&&!p&&void 0===x&&void 0===g)return e(t);n._wasUsed=!0,(h={specularFactor:x,specularTexture:p,specularColorFactor:g,specularColorTexture:d,extensions:{}}).extensions.EXT_materials_specular_edge_color={specularEdgeColorEnabled:!0},(u=n._exporter._glTF).extensionsUsed||(u.extensionsUsed=[]),-1===n._exporter._glTF.extensionsUsed.indexOf("EXT_materials_specular_edge_color")&&n._exporter._glTF.extensionsUsed.push("EXT_materials_specular_edge_color"),(p||d)&&n._exporter._materialNeedsUVsSet.add(r),t.extensions[Je]=h}e(t)})},e}();se.RegisterExtension(Je,function(e){return new $e(e)});var et="KHR_materials_transmission",tt=function(){function e(e){this.name=et,this.enabled=!0,this.required=!1,this._wasUsed=!1,this._exporter=e}return e.prototype.dispose=function(){},Object.defineProperty(e.prototype,"wasUsed",{get:function(){return this._wasUsed},enumerable:!1,configurable:!0}),e.prototype.postExportMaterialAdditionalTexturesAsync=function(e,t,r){return x(this,void 0,void 0,function(){var e;return g(this,function(t){if(e=[],r instanceof f.PBRMaterial){if(this._isExtensionEnabled(r))return r.subSurface.refractionIntensityTexture&&r.subSurface.useGltfStyleTextures&&e.push(r.subSurface.refractionIntensityTexture),[2,e]}else r instanceof f.OpenPBRMaterial&&(r.transmissionWeight>0&&r.transmissionWeightTexture&&e.push(r.transmissionWeightTexture),r.subsurfaceWeight>0&&r.subsurfaceWeightTexture&&e.push(r.subsurfaceWeightTexture));return[2,e]})})},e.prototype._isExtensionEnabled=function(e){if(e instanceof f.OpenPBRMaterial&&!e.unlit)return e.transmissionWeight>0||e.subsurfaceWeight>0;if(e instanceof f.PBRMaterial&&!e.unlit){var t=e.subSurface;return t.isRefractionEnabled&&null!=t.refractionIntensity&&0!=t.refractionIntensity||null!=t.refractionIntensityTexture&&t.useGltfStyleTextures}return!1},e.prototype.postExportMaterialAsync=function(e,t,r){return x(this,void 0,void 0,function(){var n,s,o,i,a,u;return g(this,function(c){return this._isExtensionEnabled(r)?(r instanceof f.PBRMaterial?(this._wasUsed=!0,n=r.subSurface,o=0===n.refractionIntensity?void 0:n.refractionIntensity,i={transmissionFactor:o},n.refractionIntensityTexture&&(n.useGltfStyleTextures?(this._exporter._materialNeedsUVsSet.add(r),(a=this._exporter._materialExporter.getTextureInfo(n.refractionIntensityTexture))&&(i.transmissionTexture=a)):f.Logger.Warn("".concat(e,": Exporting a subsurface refraction intensity texture without `useGltfStyleTextures` is not supported"))),t.extensions||(t.extensions={}),t.extensions[et]=i):r instanceof f.OpenPBRMaterial&&(this._wasUsed=!0,s=(1-r.transmissionWeight)*r.subsurfaceWeight,o=s+r.transmissionWeight,i={transmissionFactor:o},r.transmissionWeightTexture?(this._exporter._materialNeedsUVsSet.add(r),(a=this._exporter._materialExporter.getTextureInfo(r.transmissionWeightTexture))&&(i.transmissionTexture=a)):r.subsurfaceWeightTexture&&(this._exporter._materialNeedsUVsSet.add(r),(u=this._exporter._materialExporter.getTextureInfo(r.subsurfaceWeightTexture))&&(i.transmissionTexture=u)),1===o&&t.pbrMetallicRoughness&&(t.pbrMetallicRoughness.baseColorFactor=void 0),t.extensions||(t.extensions={}),t.extensions[et]=i),[2,t]):[2,t]})})},e}();se.RegisterExtension(et,function(e){return new tt(e)});var rt="KHR_materials_unlit",nt=function(){function e(){this.name=rt,this.enabled=!0,this.required=!1,this._wasUsed=!1}return Object.defineProperty(e.prototype,"wasUsed",{get:function(){return this._wasUsed},enumerable:!1,configurable:!0}),e.prototype.dispose=function(){},e.prototype.postExportMaterialAsync=function(e,t,r){var n=this;return new Promise(function(e){var s=!1;r instanceof f.PBRMaterial?s=r.unlit:r instanceof f.StandardMaterial&&(s=r.disableLighting),s&&(n._wasUsed=!0,null==t.extensions&&(t.extensions={}),t.extensions[rt]={}),e(t)})},e}();se.RegisterExtension(rt,function(){return new nt});var st="KHR_materials_volume",ot=function(){function e(e){this.name=st,this.enabled=!0,this.required=!1,this._wasUsed=!1,this._exporter=e}return e.prototype.dispose=function(){},Object.defineProperty(e.prototype,"wasUsed",{get:function(){return this._wasUsed},enumerable:!1,configurable:!0}),e.prototype.postExportMaterialAdditionalTexturesAsync=function(e,t,r){return x(this,void 0,void 0,function(){var e;return g(this,function(t){if(e=[],r instanceof f.PBRMaterial){if(this._isExtensionEnabled(r))return r.subSurface.thicknessTexture&&e.push(r.subSurface.thicknessTexture),[2,e]}else r instanceof f.OpenPBRMaterial&&(r.transmissionWeight>0||r.subsurfaceWeight>0)&&r.geometryThicknessTexture&&e.push(r.geometryThicknessTexture);return[2,e]})})},e.prototype._isExtensionEnabled=function(e){if(e.unlit)return!1;var t=e.subSurface;return!(!t.isRefractionEnabled&&!t.isTranslucencyEnabled)&&(null!=t.maximumThickness&&0!=t.maximumThickness||null!=t.tintColorAtDistance&&t.tintColorAtDistance!=Number.POSITIVE_INFINITY||null!=t.tintColor&&t.tintColor!=f.Color3.White()||this._hasTexturesExtension(e))},e.prototype._hasTexturesExtension=function(e){return null!=e.subSurface.thicknessTexture},e.prototype.postExportMaterialAsync=function(e,t,r){var n=this;return new Promise(function(e){var s,o;if(r instanceof f.PBRMaterial&&n._isExtensionEnabled(r)){n._wasUsed=!0;var i=r.subSurface,a={thicknessFactor:h=0==i.maximumThickness?void 0:i.maximumThickness,thicknessTexture:l=null!==(s=n._exporter._materialExporter.getTextureInfo(i.thicknessTexture))&&void 0!==s?s:void 0,attenuationDistance:i.tintColorAtDistance==Number.POSITIVE_INFINITY?void 0:i.tintColorAtDistance,attenuationColor:S=i.tintColor.equalsFloats(1,1,1)?void 0:i.tintColor.asArray()};n._hasTexturesExtension(r)&&n._exporter._materialNeedsUVsSet.add(r),t.extensions=t.extensions||{},t.extensions[st]=a}else if(r instanceof f.OpenPBRMaterial){var u=r.transmissionWeight>0&&!r.geometryThinWalled&&r.transmissionDepth>0,c=r.subsurfaceWeight>0&&!r.geometryThinWalled;if(u||c){n._wasUsed=!0;var l,h=r.geometryThickness;(l=null!==(o=n._exporter._materialExporter.getTextureInfo(r.geometryThicknessTexture))&&void 0!==o?o:void 0)&&n._exporter._materialNeedsUVsSet.add(r);var p=1,d=f.Color3.White().asArray();if(u){var x=1/r.transmissionDepth,g=new f.Vector3(-Math.log(r.transmissionColor.r)*x,-Math.log(r.transmissionColor.g)*x,-Math.log(r.transmissionColor.b)*x),_=new f.Vector3(r.transmissionScatter.r*x,r.transmissionScatter.g*x,r.transmissionScatter.b*x),m=g.subtract(_),T=Math.min(m.x,m.y,m.z);T<0&&(m.x=m.x-T,m.y=m.y-T,m.z=m.z-T),g=m.add(_),p=1/Math.max(g.x,g.y,g.z),d[0]=Math.exp(-g.x*p),d[1]=Math.exp(-g.y*p),d[2]=Math.exp(-g.z*p)}var y=1,v=f.Color3.White().asArray();if(c){var b=r.subsurfaceRadius,w=r.subsurfaceRadiusScale,M=new f.Vector3(w.r,w.g,w.b).multiplyByFloats(b,b,b),A=new f.Vector3(1/Math.max(M.x,1e-6),1/Math.max(M.y,1e-6),1/Math.max(M.z,1e-6));y=1/Math.max(A.x,A.y,A.z),v[0]=Math.exp(-A.x*y),v[1]=Math.exp(-A.y*y),v[2]=Math.exp(-A.z*y)}var R=(1-r.transmissionWeight)*r.subsurfaceWeight,E=R+r.transmissionWeight,C=1/Math.max(E,1e-6),I=r.transmissionWeight*C,V=R*C,S=d.map(function(e,t){return e*I+v[t]*V});a={thicknessFactor:h,thicknessTexture:l,attenuationDistance:p*I+y*V,attenuationColor:S},t.extensions=t.extensions||{},t.extensions[st]=a}}e(t)})},e}();se.RegisterExtension(st,function(e){return new ot(e)});var it="KHR_materials_volume_scatter",at=function(){function e(e){this.name=it,this.enabled=!0,this.required=!1,this._wasUsed=!1,this._exporter=e}return e.prototype.dispose=function(){},Object.defineProperty(e.prototype,"wasUsed",{get:function(){return this._wasUsed},enumerable:!1,configurable:!0}),e.prototype.postExportMaterialAdditionalTexturesAsync=function(e,t,r){return x(this,void 0,void 0,function(){var e;return g(this,function(t){return e=[],r instanceof f.OpenPBRMaterial&&(r.transmissionWeight>0&&r.transmissionScatterTexture&&e.push(r.transmissionScatterTexture),r.subsurfaceWeight>0&&r.subsurfaceColorTexture&&e.push(r.subsurfaceColorTexture)),[2,e]})})},e.prototype._isExtensionEnabled=function(e){if(e.unlit)return!1;var t=e.transmissionWeight>0&&!e.geometryThinWalled&&e.transmissionDepth>0&&!e.transmissionScatter.equals(f.Color3.Black()),r=e.subsurfaceWeight>0&&!e.geometryThinWalled;return!(!t&&!r)},e.prototype.postExportMaterialAsync=function(e,t,r){var n=this;return new Promise(function(e){if(r instanceof f.OpenPBRMaterial&&n._isExtensionEnabled(r)){n._wasUsed=!0;var s=f.Vector3.Zero(),o=0;if(r.transmissionWeight>0){var i=1/r.transmissionDepth,a=new f.Vector3(-Math.log(r.transmissionColor.r)*i,-Math.log(r.transmissionColor.g)*i,-Math.log(r.transmissionColor.b)*i),u=new f.Vector3(r.transmissionScatter.r*i,r.transmissionScatter.g*i,r.transmissionScatter.b*i),c=a.subtract(u),l=Math.min(c.x,c.y,c.z);l<0&&(c.x=c.x-l,c.y=c.y-l,c.z=c.z-l),a=c.add(u),b=new f.Vector3(u.x/Math.max(a.x,1e-6),u.y/Math.max(a.y,1e-6),u.z/Math.max(a.z,1e-6)),w=new f.Vector3(Math.sqrt(1-b.x),Math.sqrt(1-b.y),Math.sqrt(1-b.z)),A=(M=new f.Vector3(1,1,1)).subtract(w),R=M.subtract(new f.Vector3(.139,.139,.139).multiplyInPlace(w)),E=M.add(new f.Vector3(1.17,1.17,1.17).multiplyInPlace(w)),s=A.multiplyInPlace(R).divideInPlace(E),o=r.transmissionScatterAnisotropy}var h=f.Vector3.Zero(),p=0;r.subsurfaceWeight>0&&(h.set(r.subsurfaceColor.r,r.subsurfaceColor.g,r.subsurfaceColor.b),p=r.subsurfaceScatterAnisotropy);var d=(1-r.transmissionWeight)*r.subsurfaceWeight,x=d+r.transmissionWeight,g=1/Math.max(x,1e-6),_=r.transmissionWeight*g,m=d*g,T={multiscatterColorFactor:s.multiplyByFloats(_,_,_).addInPlace(h.multiplyByFloats(m,m,m)).asArray(),scatterAnisotropy:o*_+p*m};if(r.subsurfaceWeight>0&&r.subsurfaceColorTexture){n._exporter._materialNeedsUVsSet.add(r);var y=n._exporter._materialExporter.getTextureInfo(r.subsurfaceColorTexture);y&&(T.multiscatterColorTexture=y)}else if(r.transmissionWeight>0&&r.transmissionScatterTexture){n._exporter._materialNeedsUVsSet.add(r);var v=n._exporter._materialExporter.getTextureInfo(r.transmissionScatterTexture);v&&(T.multiscatterColorTexture=v)}t.extensions=t.extensions||{},t.extensions[it]=T}var b,w,M,A,R,E;e(t)})},e}();se.RegisterExtension(it,function(e){return new at(e)},101);var ut="KHR_materials_diffuse_roughness",ct=function(){function e(e){this.name=ut,this.enabled=!0,this.required=!1,this._wasUsed=!1,this._exporter=e}return e.prototype.dispose=function(){},Object.defineProperty(e.prototype,"wasUsed",{get:function(){return this._wasUsed},enumerable:!1,configurable:!0}),e.prototype.postExportMaterialAdditionalTexturesAsync=function(e,t,r){return x(this,void 0,void 0,function(){var e;return g(this,function(t){if(e=[],r instanceof f.PBRBaseMaterial){if(r._baseDiffuseRoughness)return r._baseDiffuseRoughnessTexture&&e.push(r._baseDiffuseRoughnessTexture),[2,e]}else if(r instanceof f.OpenPBRMaterial&&r.baseDiffuseRoughness)return r.baseDiffuseRoughnessTexture&&e.push(r.baseDiffuseRoughnessTexture),[2,e];return[2,[]]})})},e.prototype.postExportMaterialAsync=function(e,t,r){var n=this;return new Promise(function(e){var s=null,o=null;if(r instanceof f.PBRBaseMaterial?(s=r._baseDiffuseRoughness,o=r._baseDiffuseRoughnessTexture):r instanceof f.OpenPBRMaterial&&(s=r.baseDiffuseRoughness,o=r.baseDiffuseRoughnessTexture),s){n._wasUsed=!0,t.extensions=t.extensions||{};var i=n._exporter._materialExporter.getTextureInfo(o),a={diffuseRoughnessFactor:s,diffuseRoughnessTexture:null!=i?i:void 0};null!==a.diffuseRoughnessTexture&&n._exporter._materialNeedsUVsSet.add(r),t.extensions[ut]=a,e(t)}else e(t)})},e}();se.RegisterExtension(ut,function(e){return new ct(e)});var lt="KHR_materials_openpbr",ht=function(){function e(){this.name=lt,this.enabled=!0,this.required=!1,this._wasUsed=!1}return e.prototype.dispose=function(){},Object.defineProperty(e.prototype,"wasUsed",{get:function(){return this._wasUsed},enumerable:!1,configurable:!0}),e.prototype.postExportMaterialAsync=function(e,t,r){var n=this;return new Promise(function(e){r instanceof f.OpenPBRMaterial&&(n._wasUsed=!0,t.extensions=t.extensions||{},t.extensions[lt]={}),e(t)})},e}();se.RegisterExtension(lt,function(e){return new ht});var ft="KHR_texture_transform",pt=function(){function e(){this.name=ft,this.enabled=!0,this.required=!1,this._wasUsed=!1}return e.prototype.dispose=function(){},Object.defineProperty(e.prototype,"wasUsed",{get:function(){return this._wasUsed},enumerable:!1,configurable:!0}),e.prototype.postExportTexture=function(e,t,r){if(r.getScene()||f.Tools.Warn("".concat(e,': "scene" is not defined for Babylon texture ').concat(r.name,"!")),0===r.uAng&&0===r.vAng||(f.Tools.Warn("".concat(e,": Texture ").concat(r.name," with rotation in the u or v axis is not supported in glTF.")),0===r.uRotationCenter&&0===r.vRotationCenter)){var n={},s=!1;if(0===r.uOffset&&0===r.vOffset||(n.offset=[r.uOffset,r.vOffset],s=!0),1===r.uScale&&1===r.vScale||(n.scale=[r.uScale,r.vScale],s=!0),0!==r.wAng){if(0!==r.uRotationCenter||0!==r.vRotationCenter){if(r.homogeneousRotationInUVTransform&&r.uScale!==r.vScale)return void f.Tools.Warn("".concat(e,": Texture ").concat(r.name," with homogenousRotationInUVTransform, non-uniform scaling, and non-zero rotation cannot be exported with ").concat(ft,"."));f.Tools.Warn("".concat(e,": Texture ").concat(r.name," with non-origin rotation center will be exported using an adjusted offset with ").concat(ft,".")),n.offset=function(e){var t=e.uOffset,r=e.vOffset,n=e.uRotationCenter,s=e.vRotationCenter,o=e.uScale,i=e.vScale,a=e.wAng,u=Math.cos(a),c=Math.sin(a),l=n*o,h=s*i;return[t+(l*(1-u)+h*c),r+(h*(1-u)-l*c)]}(r)}n.rotation=-r.wAng,s=!0}0!==r.coordinatesIndex&&(n.texCoord=r.coordinatesIndex,s=!0),s&&(this._wasUsed=!0,t.extensions||(t.extensions={}),t.extensions[ft]=n)}},e}();se.RegisterExtension(ft,function(){return new pt});var dt="KHR_texture_basisu",xt=function(){function e(e){this.name=dt,this.enabled=!0,this.required=!0,this._wasUsed=!1,this._exporter=e}return Object.defineProperty(e.prototype,"wasUsed",{get:function(){return this._wasUsed},enumerable:!1,configurable:!0}),e.prototype.dispose=function(){},e.prototype.postExportTexture=function(e,t){var r=this._exporter._textures[t.index],n=r.source;if(void 0!==n){var s=this._exporter._images[n];"image/ktx2"===(s.mimeType||(0,f.GetMimeType)(s.uri))&&(r.source=void 0,r.extensions||(r.extensions={}),r.extensions[dt]={source:n},this._wasUsed=!0)}},e}();se.RegisterExtension(dt,function(e){return new xt(e)});var gt="EXT_texture_webp",_t=function(){function e(e){this.name=gt,this.enabled=!0,this.required=!0,this._wasUsed=!1,this._exporter=e}return Object.defineProperty(e.prototype,"wasUsed",{get:function(){return this._wasUsed},enumerable:!1,configurable:!0}),e.prototype.dispose=function(){},e.prototype.postExportTexture=function(e,t){var r=this._exporter._textures[t.index],n=r.source;if(void 0!==n){var s=this._exporter._images[n];"image/webp"===(s.mimeType||(0,f.GetMimeType)(s.uri))&&(r.source=void 0,r.extensions||(r.extensions={}),r.extensions[gt]={source:n},this._wasUsed=!0)}},e}();se.RegisterExtension(gt,function(e){return new _t(e)});var mt="EXT_texture_avif",Tt=function(){function e(e){this.name=mt,this.enabled=!0,this.required=!0,this._wasUsed=!1,this._exporter=e}return Object.defineProperty(e.prototype,"wasUsed",{get:function(){return this._wasUsed},enumerable:!1,configurable:!0}),e.prototype.dispose=function(){},e.prototype.postExportTexture=function(e,t){var r=this._exporter._textures[t.index],n=r.source;if(void 0!==n){var s=this._exporter._images[n];"image/avif"===(s.mimeType||(0,f.GetMimeType)(s.uri))&&(r.source=void 0,r.extensions||(r.extensions={}),r.extensions[mt]={source:n},this._wasUsed=!0)}},e}();se.RegisterExtension(mt,function(e){return new Tt(e)});var yt=void 0!==n.g?n.g:"undefined"!=typeof window?window:void 0;if(void 0!==yt){yt.BABYLON=yt.BABYLON||{};var vt=yt.BABYLON;vt.GLTF2=vt.GLTF2||{},vt.GLTF2.Exporter=vt.GLTF2.Exporter||{},vt.GLTF2.Exporter.Extensions=vt.GLTF2.Exporter.Extensions||{};var bt=[];for(var wt in o)vt[wt]=o[wt],bt.push(wt);for(var wt in i)vt[wt]=i[wt],bt.push(wt);for(var wt in a)vt[wt]=a[wt],bt.push(wt);for(var wt in u)vt.GLTF2.Exporter.Extensions[wt]=u[wt],bt.push(wt);for(var wt in c)bt.indexOf(wt)>-1||(vt.GLTF2.Exporter[wt]=c[wt])}const Mt=l;return s.default})());
|
|
2
|
-
//# sourceMappingURL=babylon.glTF2Serializer.min.js.map
|
|
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 r={__proto__:null,__IGLTFExporterExtension:0},n=function(){function e(){this.files={}}return Object.defineProperty(e.prototype,"glTFFiles",{get:function(){return this.files},enumerable:!1,configurable:!0}),e.prototype.downloadFiles=function(){for(var e in this.files){var r=this.files[e],n=new Blob([r],{type:t.GetMimeType(e)});t.Tools.Download(n,e)}},e}(),s={__proto__:null,GLTFData:n},o=function(){return o=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var s in t=arguments[r])Object.prototype.hasOwnProperty.call(t,s)&&(e[s]=t[s]);return e},o.apply(this,arguments)};function i(e,t,r,n){return new(r||(r=Promise))(function(s,o){function i(e){try{u(n.next(e))}catch(e){o(e)}}function a(e){try{u(n.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?s(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(i,a)}u((n=n.apply(e,t||[])).next())})}function a(e,t){var r,n,s,o={label:0,sent:function(){if(1&s[0])throw s[1];return s[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=a(0),i.throw=a(1),i.return=a(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(o=0)),o;)try{if(r=1,n&&(s=2&a[0]?n.return:a[0]?n.throw||((s=n.return)&&s.call(n),0):n.next)&&!(s=s.call(n,a[1])).done)return s;switch(n=0,s&&(a=[2&a[0],s.value]),a[0]){case 0:case 1:s=a;break;case 4:return o.label++,{value:a[1],done:!1};case 5:o.label++,n=a[1],a=[0];continue;case 7:a=o.ops.pop(),o.trys.pop();continue;default:if(!((s=(s=o.trys).length>0&&s[s.length-1])||6!==a[0]&&2!==a[0])){o=0;continue}if(3===a[0]&&(!s||a[1]>s[0]&&a[1]<s[3])){o.label=a[1];break}if(6===a[0]&&o.label<s[1]){o.label=s[1],s=a;break}if(s&&o.label<s[2]){o.label=s[2],o.ops.push(a);break}s[2]&&o.ops.pop(),o.trys.pop();continue}a=t.call(e,o)}catch(e){a=[6,e],n=0}finally{r=s=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}}function u(e,t,r){if(r||2===arguments.length)for(var n,s=0,o=t.length;s<o;s++)!n&&s in t||(n||(n=Array.prototype.slice.call(t,0,s)),n[s]=t[s]);return e.concat(n||Array.prototype.slice.call(t))}"function"==typeof SuppressedError&&SuppressedError;var c=1e-6,l=new t.Color3(.04,.04,.04),h=t.Color3.White(),f=t.Color3.BlackReadOnly;function p(e){switch(e){case"image/jpeg":case"image/png":case"image/webp":case"image/avif":case"image/ktx2":return!0;default:return!1}}function d(e){return i(this,void 0,void 0,function(){var r,n,s,o;return a(this,function(i){switch(i.label){case 0:if(!(r=e.getInternalTexture())||1!==r.source)return[2,null];if(r.invertY)return[2,null];n=r._buffer,o=e.mimeType,i.label=1;case 1:return i.trys.push([1,12,,13]),n?[3,3]:[4,t.Tools.LoadFileAsync(r.url)];case 2:return s=i.sent(),o=t.GetMimeType(r.url)||o,[3,11];case 3:return ArrayBuffer.isView(n)?(s=n.buffer.slice(n.byteOffset,n.byteOffset+n.byteLength),[3,11]):[3,4];case 4:return n instanceof ArrayBuffer?(s=n,[3,11]):[3,5];case 5:return n instanceof Blob?[4,n.arrayBuffer()]:[3,7];case 6:return s=i.sent(),o=n.type||o,[3,11];case 7:return"string"!=typeof n?[3,9]:[4,t.Tools.LoadFileAsync(n)];case 8:return s=i.sent(),o=t.GetMimeType(n)||o,[3,11];case 9:return"undefined"!=typeof HTMLImageElement&&n instanceof HTMLImageElement?[4,t.Tools.LoadFileAsync(n.src)]:[3,11];case 10:s=i.sent(),o=t.GetMimeType(n.src)||o,i.label=11;case 11:return[3,13];case 12:return i.sent(),[2,null];case 13:return s&&p(o)?[2,new Blob([s],{type:o})]:[2,null]}})})}function x(e,r,n){if(r<l.r)return 0;var s=l.r,o=e*n/(1-l.r)+r-2*l.r,i=o*o-4*s*(l.r-r);return t.Scalar.Clamp((-o+Math.sqrt(i))/(2*s),0,1)}function g(e){var r=e.diffuseColor.toLinearSpace(e.getScene().getEngine().useExactSrgbConversions).scale(.5),n=e.alpha,s=t.Scalar.Clamp(e.specularPower,0,1024),o=t.SpecularPowerToRoughness(s);return{baseColorFactor:[r.r,r.g,r.b,n],metallicFactor:0,roughnessFactor:o}}function _(e,t){t.needAlphaBlending()?e.alphaMode="BLEND":t.needAlphaTesting()&&(e.alphaMode="MASK",e.alphaCutoff=t.alphaCutOff)}function m(e,r,n){for(var s=new Uint8Array(e*r*4),o=0;o<s.length;o+=4)s[o]=s[o+1]=s[o+2]=s[o+3]=255;return t.RawTexture.CreateRGBATexture(s,e,r,n)}function T(e){if(e instanceof Uint8Array){for(var t=e.length,r=new Float32Array(e.length),n=0;n<t;++n)r[n]=e[n]/255;return r}if(e instanceof Float32Array)return e;throw new Error("Unsupported pixel format!")}var y=function(){function e(e){this._exporter=e,this._textureMap=new Map,this._internalTextureToImage={}}return e.prototype.getTextureInfo=function(e){var t;return e&&null!==(t=this._textureMap.get(e.uniqueId))&&void 0!==t?t:null},e.prototype.exportStandardMaterialAsync=function(e,r){return i(this,void 0,void 0,function(){var n,s,o,i,u,l,h,p;return a(this,function(a){switch(a.label){case 0:return n=g(e),s={name:e.name},null==e.backFaceCulling||e.backFaceCulling||(e.twoSidedLighting||t.Tools.Warn(e.name+": Back-face culling disabled and two-sided lighting disabled is not supported in glTF."),s.doubleSided=!0),r?(o=[],(i=e.diffuseTexture)&&o.push(this.exportTextureAsync(i).then(function(e){e&&(n.baseColorTexture=e)})),(u=e.bumpTexture)&&o.push(this.exportTextureAsync(u).then(function(e){e&&(s.normalTexture=e,1!==u.level&&(s.normalTexture.scale=u.level))})),(l=e.emissiveTexture)&&(s.emissiveFactor=[1,1,1],o.push(this.exportTextureAsync(l).then(function(e){e&&(s.emissiveTexture=e)}))),(h=e.ambientTexture)&&o.push(this.exportTextureAsync(h).then(function(e){if(e){var t={index:e.index};s.occlusionTexture=t}})),o.length>0?(this._exporter._materialNeedsUVsSet.add(e),[4,Promise.all(o)]):[3,2]):[3,2];case 1:a.sent(),a.label=2;case 2:return(e.alpha<1||e.opacityTexture)&&(e.alphaMode===t.Constants.ALPHA_COMBINE?s.alphaMode="BLEND":t.Tools.Warn(e.name+": glTF 2.0 does not support alpha mode: "+e.alphaMode.toString())),e.emissiveColor&&!e.emissiveColor.equalsWithEpsilon(f,c)&&(s.emissiveFactor=e.emissiveColor.asArray()),s.pbrMetallicRoughness=n,_(s,e),[4,this._finishMaterialAsync(s,e)];case 3:return a.sent(),(p=this._exporter._materials).push(s),[2,p.length-1]}})})},e.prototype._finishMaterialAsync=function(e,t){return i(this,void 0,void 0,function(){var r,n,s,o,i;return a(this,function(a){switch(a.label){case 0:return[4,this._exporter._extensionsPostExportMaterialAdditionalTexturesAsync("exportMaterial",e,t)];case 1:for(r=a.sent(),n=[],s=0,o=r;s<o.length;s++)i=o[s],n.push(this.exportTextureAsync(i));return[4,Promise.all(n)];case 2:return a.sent(),[4,this._exporter._extensionsPostExportMaterialAsync("exportMaterial",e,t)];case 3:return a.sent(),[2]}})})},e.prototype._resizeTexturesToSameDimensions=function(e,r,n){var s,o,i=e?e.getSize():{width:0,height:0},a=r?r.getSize():{width:0,height:0};return i.width<a.width?(s=e&&e instanceof t.Texture?t.TextureTools.CreateResizedCopy(e,a.width,a.height,!0):m(a.width,a.height,n),o=r):i.width>a.width?(o=r&&r instanceof t.Texture?t.TextureTools.CreateResizedCopy(r,i.width,i.height,!0):m(i.width,i.height,n),s=e):(s=e,o=r),{texture1:s,texture2:o}},e.prototype._convertSpecularGlossinessTexturesToMetallicRoughnessAsync=function(e,r,n){return i(this,void 0,void 0,function(){var s,o,i,u,l,f,p,d,x,g,_,m,y,v,b,M,w,A,R,E,C,I,V,S,F,B,N,O,U,P,W;return a(this,function(a){switch(a.label){case 0:return s=new Array,e||r?[3,2]:[4,Promise.reject("diffuse and specular glossiness textures are not defined!")];case 1:case 6:case 9:case 11:case 13:return[2,a.sent()];case 2:return(o=e?e.getScene():r?r.getScene():null)?(i=this._resizeTexturesToSameDimensions(e,r,o),u=null===(W=i.texture1)||void 0===W?void 0:W.getSize(),l=void 0,f=void 0,p=u.width,d=u.height,[4,i.texture1.readPixels()]):[3,12];case 3:return x=a.sent(),[4,i.texture2.readPixels()];case 4:return g=a.sent(),x?(l=T(x),[3,7]):[3,5];case 5:return[4,Promise.reject("Failed to retrieve pixels from diffuse texture!")];case 7:return g?(f=T(g),[3,10]):[3,8];case 8:return[4,Promise.reject("Failed to retrieve pixels from specular glossiness texture!")];case 10:for(_=f.byteLength,m=new Uint8Array(_),y=new Uint8Array(_),v=new t.Color3(0,0,0),b=0,M=0,B=0;B<d;++B)for(N=0;N<p;++N)w=4*(p*B+N),A=new t.Color3(l[w],l[w+1],l[w+2]).toLinearSpace(o.getEngine().useExactSrgbConversions).multiply(n.diffuseColor),R=new t.Color3(f[w],f[w+1],f[w+2]).toLinearSpace(o.getEngine().useExactSrgbConversions).multiply(n.specularColor),E=f[w+3]*n.glossiness,C={diffuseColor:A,specularColor:R,glossiness:E},I=this._convertSpecularGlossinessToMetallicRoughness(C),v.r=Math.max(v.r,I.baseColor.r),v.g=Math.max(v.g,I.baseColor.g),v.b=Math.max(v.b,I.baseColor.b),b=Math.max(b,I.metallic),M=Math.max(M,I.roughness),y[w]=255*I.baseColor.r,y[w+1]=255*I.baseColor.g,y[w+2]=255*I.baseColor.b,y[w+3]=i.texture1.hasAlpha?255*l[w+3]:255,m[w]=0,m[w+1]=255*I.roughness,m[w+2]=255*I.metallic,m[w+3]=255;for(V={baseColor:v,metallic:b,roughness:M},S=!1,F=!1,B=0;B<d;++B)for(N=0;N<p;++N)y[O=4*(p*B+N)]/=V.baseColor.r>c?V.baseColor.r:1,y[O+1]/=V.baseColor.g>c?V.baseColor.g:1,y[O+2]/=V.baseColor.b>c?V.baseColor.b:1,U=t.Color3.FromInts(y[O],y[O+1],y[O+2]),P=U.toGammaSpace(o.getEngine().useExactSrgbConversions),y[O]=255*P.r,y[O+1]=255*P.g,y[O+2]=255*P.b,P.equalsWithEpsilon(h,c)||(F=!0),m[O+1]/=V.roughness>c?V.roughness:1,m[O+2]/=V.metallic>c?V.metallic:1,t.Color3.FromInts(255,m[O+1],m[O+2]).equalsWithEpsilon(h,c)||(S=!0);return S&&s.push(t.EncodeImageAsync(m,p,d).then(function(e){V.metallicRoughnessTextureData=e})),F&&s.push(t.EncodeImageAsync(y,p,d).then(function(e){V.baseColorTextureData=e})),[4,Promise.all(s).then(function(){return V})];case 12:return[4,Promise.reject("_ConvertSpecularGlossinessTexturesToMetallicRoughness: Scene from textures is missing!")]}})})},e.prototype._convertSpecularGlossinessToMetallicRoughness=function(e){var r=this._getPerceivedBrightness(e.diffuseColor),n=this._getPerceivedBrightness(e.specularColor),s=1-this._getMaxComponent(e.specularColor),o=x(r,n,s),i=e.diffuseColor.scale(s/(1-l.r)/Math.max(1-o,c)),a=e.specularColor.subtract(l.scale(1-o)).scale(1/Math.max(o,c)),u=t.Color3.Lerp(i,a,o*o);return{baseColor:u=u.clampToRef(0,1,u),metallic:o,roughness:1-e.glossiness}},e.prototype._getPerceivedBrightness=function(e){return Math.sqrt(.299*e.r*e.r+.587*e.g*e.g+.114*e.b*e.b)},e.prototype._getMaxComponent=function(e){return Math.max(e.r,Math.max(e.g,e.b))},e.prototype._convertMetalRoughFactorsToMetallicRoughnessAsync=function(e,r,n,s,o,u,c,l,h){return i(this,void 0,void 0,function(){var f,p,d,x,g,_,m,T,y,v=this;return a(this,function(b){switch(b.label){case 0:return f=[],p={baseColor:e,metallic:r,roughness:n},h&&(c instanceof t.OpenPBRMaterial?(c.geometryOpacityTexture?(d=s&&s.getInternalTexture()?s.getInternalTexture().uniqueId:0,x=c.geometryOpacityTexture&&c.geometryOpacityTexture.getInternalTexture()?c.geometryOpacityTexture.getInternalTexture().uniqueId:0,g=Number("".concat(d).concat(x)),(y=this._textureMap.get(g))?l.baseColorTexture=y:f.push(t.MergeTexturesAsync("baseColorOpacityTexture",t.CreateRGBAConfiguration(s?t.CreateTextureInput(s,0):t.CreateConstantInput(1),s?t.CreateTextureInput(s,1):t.CreateConstantInput(1),s?t.CreateTextureInput(s,2):t.CreateConstantInput(1),t.CreateTextureInput(c.geometryOpacityTexture,0)),c.getScene()).then(function(e){return i(v,void 0,void 0,function(){var t;return a(this,function(r){switch(r.label){case 0:return[4,this.exportTextureAsync(e,g)];case 1:return(t=r.sent())&&(l.baseColorTexture=t),[2]}})})}))):s&&f.push(this.exportTextureAsync(s).then(function(e){e&&(l.baseColorTexture=e)})),c._useMetallicFromMetallicTextureBlue&&o?f.push(this.exportTextureAsync(o).then(function(e){e&&(l.metallicRoughnessTexture=e)})):(u||o)&&(_=o&&o.getInternalTexture()?o.getInternalTexture().uniqueId:0,m=u&&u.getInternalTexture()?u.getInternalTexture().uniqueId:0,T=Number("".concat(_).concat(m)),(y=this._textureMap.get(T))?l.metallicRoughnessTexture=y:f.push(t.MergeTexturesAsync("MetalRoughTexture",t.CreateRGBAConfiguration(c.ambientOcclusionTexture?t.CreateTextureInput(c.ambientOcclusionTexture,0):t.CreateConstantInput(1),u?t.CreateTextureInput(u,0):t.CreateConstantInput(1),o?t.CreateTextureInput(o,0):t.CreateConstantInput(1)),c.getScene()).then(function(e){return i(v,void 0,void 0,function(){var t;return a(this,function(r){switch(r.label){case 0:return[4,this.exportTextureAsync(e,T)];case 1:return(t=r.sent())&&(l.metallicRoughnessTexture=t),[2]}})})})))):(s&&f.push(this.exportTextureAsync(s).then(function(e){e&&(l.baseColorTexture=e)})),o&&f.push(this.exportTextureAsync(o).then(function(e){e&&(l.metallicRoughnessTexture=e)})))),f.length>0?(this._exporter._materialNeedsUVsSet.add(c),[4,Promise.all(f)]):[3,2];case 1:b.sent(),b.label=2;case 2:return[2,p]}})})},e.prototype._getTextureSampler=function(e){var r={};if(!(e&&e instanceof t.Texture))return r;var n=this._getGLTFTextureWrapMode(e.wrapU);10497!==n&&(r.wrapS=n);var s=this._getGLTFTextureWrapMode(e.wrapV);switch(10497!==s&&(r.wrapT=s),e.samplingMode){case t.Texture.LINEAR_LINEAR:r.magFilter=9729,r.minFilter=9729;break;case t.Texture.LINEAR_NEAREST:r.magFilter=9729,r.minFilter=9728;break;case t.Texture.NEAREST_LINEAR:r.magFilter=9728,r.minFilter=9729;break;case t.Texture.NEAREST_LINEAR_MIPLINEAR:r.magFilter=9728,r.minFilter=9987;break;case t.Texture.NEAREST_NEAREST:r.magFilter=9728,r.minFilter=9728;break;case t.Texture.NEAREST_LINEAR_MIPNEAREST:r.magFilter=9728,r.minFilter=9985;break;case t.Texture.LINEAR_NEAREST_MIPNEAREST:r.magFilter=9729,r.minFilter=9984;break;case t.Texture.LINEAR_NEAREST_MIPLINEAR:r.magFilter=9729,r.minFilter=9986;break;case t.Texture.NEAREST_NEAREST_MIPLINEAR:r.magFilter=9728,r.minFilter=9986;break;case t.Texture.LINEAR_LINEAR_MIPLINEAR:r.magFilter=9729,r.minFilter=9987;break;case t.Texture.LINEAR_LINEAR_MIPNEAREST:r.magFilter=9729,r.minFilter=9985;break;case t.Texture.NEAREST_NEAREST_MIPNEAREST:r.magFilter=9728,r.minFilter=9984}return r},e.prototype._getGLTFTextureWrapMode=function(e){switch(e){case t.Texture.WRAP_ADDRESSMODE:return 10497;case t.Texture.CLAMP_ADDRESSMODE:return 33071;case t.Texture.MIRROR_ADDRESSMODE:return 33648;default:return t.Tools.Error("Unsupported Texture Wrap Mode ".concat(e,"!")),10497}},e.prototype._convertSpecGlossFactorsToMetallicRoughnessAsync=function(e,t,r){return i(this,void 0,void 0,function(){var n,s,o,i,u,c,l,h;return a(this,function(a){switch(a.label){case 0:return n={diffuseColor:e._albedoColor,specularColor:e._reflectivityColor,glossiness:e._microSurface},s=e._albedoTexture,o=e._reflectivityTexture,i=e._useMicroSurfaceFromReflectivityMapAlpha,!o||i?[3,2]:[4,Promise.reject("_ConvertPBRMaterial: Glossiness values not included in the reflectivity texture are currently not supported")];case 1:return[2,a.sent()];case 2:return(s||o)&&r?(this._exporter._materialNeedsUVsSet.add(e),u=this._exportTextureSampler(s||o),[4,this._convertSpecularGlossinessTexturesToMetallicRoughnessAsync(s,o,n)]):[3,8];case 3:return c=a.sent(),l=this._exporter._textures,c.baseColorTextureData?[4,this._exportImageAsync("baseColor".concat(l.length),c.baseColorTextureData)]:[3,5];case 4:h=a.sent(),t.baseColorTexture=this._exportTextureInfo(h,u,null==s?void 0:s.coordinatesIndex),a.label=5;case 5:return c.metallicRoughnessTextureData?[4,this._exportImageAsync("metallicRoughness".concat(l.length),c.metallicRoughnessTextureData)]:[3,7];case 6:h=a.sent(),t.metallicRoughnessTexture=this._exportTextureInfo(h,u,null==o?void 0:o.coordinatesIndex),a.label=7;case 7:return[2,c];case 8:return[2,this._convertSpecularGlossinessToMetallicRoughness(n)]}})})},e.prototype.exportPBRMaterialAsync=function(e,t){return i(this,void 0,void 0,function(){var r,n,s,o,i,u,c,l;return a(this,function(a){switch(a.label){case 0:return r={},n={name:e.name},(s=e.isMetallicWorkflow())&&(o=e._albedoColor,i=e.alpha,o&&(r.baseColorFactor=[o.r,o.g,o.b,i])),s?[4,this._convertMetalRoughFactorsToMetallicRoughnessAsync(e._albedoColor,e._metallic,e._roughness,e._albedoTexture,e._metallicTexture,e._metallicTexture,e,r,t)]:[3,2];case 1:return c=a.sent(),[3,4];case 2:return[4,this._convertSpecGlossFactorsToMetallicRoughnessAsync(e,r,t)];case 3:c=a.sent(),a.label=4;case 4:return u=c,[4,this._setMetallicRoughnessPbrMaterialAsync(u,e,n,r,t)];case 5:return a.sent(),[4,this._finishMaterialAsync(n,e)];case 6:return a.sent(),(l=this._exporter._materials).push(n),[2,l.length-1]}})})},e.prototype._setMetallicRoughnessPbrMaterialAsync=function(e,r,n,s,o){return i(this,void 0,void 0,function(){var u,l,p,d,x,g=this;return a(this,function(m){switch(m.label){case 0:return _(n,r),e.baseColor.equalsWithEpsilon(h,c)&&t.Scalar.WithinEpsilon(r.alpha,1,c)||(s.baseColorFactor=[e.baseColor.r,e.baseColor.g,e.baseColor.b,r.alpha]),null!=e.metallic&&1!==e.metallic&&(s.metallicFactor=e.metallic),null!=e.roughness&&1!==e.roughness&&(s.roughnessFactor=e.roughness),null==r.backFaceCulling||r.backFaceCulling||(r._twoSidedLighting||t.Tools.Warn(r.name+": Back-face culling disabled and two-sided lighting disabled is not supported in glTF."),n.doubleSided=!0),o?(u=[],(l=r instanceof t.PBRBaseMaterial?r._bumpTexture:r.geometryNormalTexture)&&u.push(this.exportTextureAsync(l).then(function(e){e&&(n.normalTexture=e,1!==l.level&&(n.normalTexture.scale=l.level))})),(p=r instanceof t.PBRBaseMaterial?r._ambientTexture:r.ambientOcclusionTexture)&&u.push(new Promise(function(e){return i(g,void 0,void 0,function(){var n,o,i,u;return a(this,function(a){switch(a.label){case 0:return r instanceof t.OpenPBRMaterial&&s.metallicRoughnessTexture?(n=this._exportTextureSampler(p),o=this._exporter._textures[s.metallicRoughnessTexture.index].source,i=this._exportTextureInfo(o,n,p.coordinatesIndex),this._textureMap.set(p.uniqueId,i),this._exporter._extensionsPostExportTextures("exporter",i,p),[2,e(i)]):[3,1];case 1:return u=e,[4,this.exportTextureAsync(p)];case 2:return[2,u.apply(void 0,[a.sent()])]}})})}).then(function(e){return i(g,void 0,void 0,function(){var s;return a(this,function(o){return e&&(s={index:e.index,texCoord:e.texCoord,extensions:e.extensions},n.occlusionTexture=s,r instanceof t.PBRBaseMaterial?s.strength=r._ambientTextureStrength:s.strength=r.ambientOcclusionTexture.level),[2]})})})),(d=r instanceof t.PBRBaseMaterial?r._emissiveTexture:r.emissionColorTexture)&&u.push(this.exportTextureAsync(d).then(function(e){e&&(n.emissiveTexture=e)})),u.length>0?(this._exporter._materialNeedsUVsSet.add(r),[4,Promise.all(u)]):[3,2]):[3,2];case 1:m.sent(),m.label=2;case 2:return(x=r instanceof t.PBRBaseMaterial?r._emissiveColor:r.emissionColor).equalsWithEpsilon(f,c)||(n.emissiveFactor=x.asArray()),n.pbrMetallicRoughness=s,[2]}})})},e.prototype.exportOpenPBRMaterialAsync=function(e,t){return i(this,void 0,void 0,function(){var r,n,s,o,i,u;return a(this,function(a){switch(a.label){case 0:return r={},n={name:e.name},s=e.baseColor,o=e.geometryOpacity,s&&(r.baseColorFactor=[s.r,s.g,s.b,o]),[4,this._convertMetalRoughFactorsToMetallicRoughnessAsync(e.baseColor,e.baseMetalness,e.specularRoughness,e.baseColorTexture,e.baseMetalnessTexture,e.specularRoughnessTexture,e,r,t)];case 1:return i=a.sent(),[4,this._setMetallicRoughnessPbrMaterialAsync(i,e,n,r,t)];case 2:return a.sent(),[4,this._finishMaterialAsync(n,e)];case 3:return a.sent(),(u=this._exporter._materials).push(n),[2,u.length-1]}})})},e.prototype.exportTextureAsync=function(e){return i(this,arguments,void 0,function(e,t){var r,n,s;return void 0===t&&(t=null),a(this,function(o){switch(o.label){case 0:return(r=this._textureMap.get(null!=t?t:e.uniqueId))?[2,r]:(n=this._exportTextureSampler(e),[4,this._exportTextureImageAsync(e)]);case 1:return s=o.sent(),r=this._exportTextureInfo(s,n,e.coordinatesIndex),this._textureMap.set(null!=t?t:e.uniqueId,r),this._exporter._extensionsPostExportTextures("exporter",r,e),[2,r]}})})},e.prototype._exportTextureImageAsync=function(e){return i(this,void 0,void 0,function(){var r,n,s,o,u,c=this;return a(this,function(l){switch(l.label){case 0:return r=null!==(u=e.mimeType)&&void 0!==u?u:"none",n=this._internalTextureToImage,s=e.getInternalTexture().uniqueId,n[s]=n[s]||{},void 0===(o=n[s][r])&&(o=i(c,void 0,void 0,function(){var n,s,o,i,u;return a(this,function(a){switch(a.label){case 0:return[4,d(e)];case 1:return!(n=a.sent())||"none"!==r&&n.type!==r?[3,3]:[4,this._exportImageAsync(e.name,n)];case 2:case 6:return[2,a.sent()];case 3:return s="image/png","none"!==r&&(p(r)?s=r:(s="image/png",t.Tools.Warn("Unsupported media type: ".concat(r,". Exporting texture as PNG.")))),o=e.getSize(),[4,t.GetTextureDataAsync(e)];case 4:return i=a.sent(),[4,t.EncodeImageAsync(i,o.width,o.height,s)];case 5:return u=a.sent(),[4,this._exportImageAsync(e.name,u)]}})}),n[s][r]=o),[4,o];case 1:return[2,l.sent()]}})})},e.prototype._exportImageAsync=function(e,r){return i(this,void 0,void 0,function(){var n,s,o,i,u,c,l;return a(this,function(a){switch(a.label){case 0:return n=this._exporter._images,this._exporter._shouldUseGlb?(s={name:e,mimeType:r.type,bufferView:void 0},[4,r.arrayBuffer()]):[3,2];case 1:return o=a.sent(),i=this._exporter._bufferManager.createBufferView(new Uint8Array(o)),this._exporter._bufferManager.setBufferView(s,i),[3,3];case 2:u=e.replace(/\.\/|\/|\.\\|\\/g,"_"),c=function(e){switch(e){case"image/jpeg":return".jpg";case"image/png":return".png";case"image/webp":return".webp";case"image/avif":return".avif";case"image/ktx2":return".ktx2"}}(r.type),l=u+c,n.some(function(e){return e.uri===l})&&(l="".concat(u,"_").concat(t.Tools.RandomId()).concat(c)),s={name:e,uri:l},this._exporter._imageData[l]=r,a.label=3;case 3:return n.push(s),[2,n.length-1]}})})},e.prototype._exportTextureInfo=function(e,t,r){var n=this._exporter._textures,s=n.findIndex(function(r){return r.sampler==t&&r.source===e});-1===s&&(s=n.length,n.push({source:e,sampler:t}));var o={index:s};return r&&(o.texCoord=r),o},e.prototype._exportTextureSampler=function(e){var t=this._getTextureSampler(e),r=this._exporter._samplers,n=r.findIndex(function(e){return e.minFilter===t.minFilter&&e.magFilter===t.magFilter&&e.wrapS===t.wrapS&&e.wrapT===t.wrapT});return-1!==n?n:(r.push(t),r.length-1)},e}(),v=t.Matrix.Compose(new t.Vector3(-1,1,1),t.Quaternion.Identity(),t.Vector3.Zero());function b(e,r){if(!(e instanceof t.TransformNode))return!1;if(r){if(!e.getWorldMatrix().equalsWithEpsilon(t.Matrix.IdentityReadOnly,t.Epsilon))return!1}else if(!e.getWorldMatrix().multiplyToRef(v,t.TmpVectors.Matrix[0]).equalsWithEpsilon(t.Matrix.IdentityReadOnly,t.Epsilon))return!1;return!(e instanceof t.AbstractMesh&&e.geometry)}var M=t.Vector3.ZeroReadOnly,w=t.Quaternion.Identity(),A=t.Vector3.OneReadOnly,R=new t.Vector3(-1,1,1);function E(e,t){var r=e.byteOffset,n=e.byteStride,s=e.type,o=e.normalized,i=e.getSize(),a=t.reduce(function(e,t){return t.getTotalVertices()>e?t.getTotalVertices():e},-Number.MAX_VALUE);return{byteOffset:r,byteStride:n,componentCount:i,type:s,count:a*i,normalized:o,totalVertices:a,kind:e.getKind()}}function C(e){switch(e){case"MAT2":case"VEC4":return 4;case"MAT3":return 9;case"MAT4":return 16;case"SCALAR":return 1;case"VEC2":return 2;case"VEC3":return 3}}function I(e){return e.some(function(e){return e>=256})}function V(e){switch(e){case t.VertexBuffer.PositionKind:case t.VertexBuffer.NormalKind:case t.VertexBuffer.TangentKind:case t.VertexBuffer.ColorKind:case t.VertexBuffer.MatricesIndicesKind:case t.VertexBuffer.MatricesIndicesExtraKind:case t.VertexBuffer.MatricesWeightsKind:case t.VertexBuffer.MatricesWeightsExtraKind:case t.VertexBuffer.UVKind:case t.VertexBuffer.UV2Kind:case t.VertexBuffer.UV3Kind:case t.VertexBuffer.UV4Kind:case t.VertexBuffer.UV5Kind:case t.VertexBuffer.UV6Kind:return!0}return!1}function S(e){var t=Math.sqrt(e.x*e.x+e.y*e.y+e.z*e.z);t>0&&(e.x/=t,e.y/=t,e.z/=t)}function F(e){return e.x*=-1,e}function B(e){return v.invertToRef(t.TmpVectors.Matrix[0]).multiplyToRef(e,e).multiplyToRef(v,e),e}function N(e){if(e.x*e.x+e.y*e.y>.5){var t=Math.abs(e.x),r=Math.abs(e.y);if(t>r){var n=Math.sign(e.x);e.x=t,e.y*=-n,e.z*=-n,e.w*=n}else n=Math.sign(e.y),e.x*=-n,e.y=r,e.z*=n,e.w*=-n}else{var s=Math.abs(e.z),o=Math.abs(e.w);s>o?(n=Math.sign(e.z),e.x*=-n,e.y*=n,e.z=s,e.w*=-n):(n=Math.sign(e.w),e.x*=n,e.y*=-n,e.z*=-n,e.w=o)}return e}function O(e){e.copyFromFloats(-e.z,e.w,e.x,-e.y)}function U(e,r){var n=t.Vector3.FromArrayToRef(r.translation||[0,0,0],0,t.TmpVectors.Vector3[0]),s=t.Quaternion.FromArrayToRef(r.rotation||[0,0,0,1],0,t.TmpVectors.Quaternion[0]),o=t.Matrix.ComposeToRef(A,s,n,t.TmpVectors.Matrix[0]),i=t.Vector3.FromArrayToRef(e.translation||[0,0,0],0,t.TmpVectors.Vector3[2]),a=t.Quaternion.FromArrayToRef(e.rotation||[0,0,0,1],0,t.TmpVectors.Quaternion[1]),u=t.Matrix.ComposeToRef(A,a,i,t.TmpVectors.Matrix[1]);o.multiplyToRef(u,u),u.decompose(void 0,s,n),n.equalsWithEpsilon(M,t.Epsilon)?delete r.translation:r.translation=n.asArray(),s.equalsWithEpsilon(w,t.Epsilon)?delete r.rotation:r.rotation=s.asArray(),r.scale&&delete r.scale}function P(e,r){if(!(r instanceof t.TransformNode))return!1;if(1!==r.getChildren().length||0!==e.getChildren().length||e.parent!==r)return!1;var n=e.getScene(),s=e instanceof t.TargetCamera&&!n.useRightHandedSystem?R:A;return!!r.scaling.equalsWithEpsilon(s,t.Epsilon)||(t.Logger.Warn("Cannot collapse node ".concat(e.name," into parent node ").concat(r.name," with modified scaling.")),!1)}function W(e,t){for(var r=0,n=Object.entries(e);r<n.length;r++){var s=n[r],o=s[0],i=s[1],a=t[o];(Array.isArray(i)&&Array.isArray(a)&&L(i,a)||i===a)&&delete e[o]}return e}function L(e,t){return e.length===t.length&&e.every(function(e,r){return e===t[r]})}var z=new Map([[Int8Array,function(e,t,r){return e.setInt8(t,r)}],[Uint8Array,function(e,t,r){return e.setUint8(t,r)}],[Uint8ClampedArray,function(e,t,r){return e.setUint8(t,r)}],[Int16Array,function(e,t,r){return e.setInt16(t,r,!0)}],[Uint16Array,function(e,t,r){return e.setUint16(t,r,!0)}],[Int32Array,function(e,t,r){return e.setInt32(t,r,!0)}],[Uint32Array,function(e,t,r){return e.setUint32(t,r,!0)}],[Float32Array,function(e,t,r){return e.setFloat32(t,r,!0)}],[Float64Array,function(e,t,r){return e.setFloat64(t,r,!0)}]]),K=function(){function e(e){this._data=new Uint8Array(e),this._dataView=new DataView(this._data.buffer),this._byteOffset=0}return e.prototype.writeTypedArray=function(e){this._checkGrowBuffer(e.byteLength);for(var t=z.get(e.constructor),r=0;r<e.length;r++)t(this._dataView,this._byteOffset,e[r]),this._byteOffset+=e.BYTES_PER_ELEMENT},Object.defineProperty(e.prototype,"byteOffset",{get:function(){return this._byteOffset},enumerable:!1,configurable:!0}),e.prototype.getOutputData=function(){return new Uint8Array(this._data.buffer,0,this._byteOffset)},e.prototype.writeUInt8=function(e){this._checkGrowBuffer(1),this._dataView.setUint8(this._byteOffset,e),this._byteOffset++},e.prototype.writeInt8=function(e){this._checkGrowBuffer(1),this._dataView.setInt8(this._byteOffset,e),this._byteOffset++},e.prototype.writeInt16=function(e){this._checkGrowBuffer(2),this._dataView.setInt16(this._byteOffset,e,!0),this._byteOffset+=2},e.prototype.writeUInt16=function(e){this._checkGrowBuffer(2),this._dataView.setUint16(this._byteOffset,e,!0),this._byteOffset+=2},e.prototype.writeInt32=function(e){this._checkGrowBuffer(4),this._dataView.setInt32(this._byteOffset,e,!0),this._byteOffset+=4},e.prototype.writeUInt32=function(e){this._checkGrowBuffer(4),this._dataView.setUint32(this._byteOffset,e,!0),this._byteOffset+=4},e.prototype.writeFloat32=function(e){this._checkGrowBuffer(4),this._dataView.setFloat32(this._byteOffset,e,!0),this._byteOffset+=4},e.prototype.writeFloat64=function(e){this._checkGrowBuffer(8),this._dataView.setFloat64(this._byteOffset,e,!0),this._byteOffset+=8},e.prototype._checkGrowBuffer=function(e){var t=this.byteOffset+e;if(t>this._data.byteLength){var r=new Uint8Array(2*t);r.set(this._data),this._data=r,this._dataView=new DataView(this._data.buffer)}},e}();function k(e){return e%4==0?4:e%2==0?2:1}var G,D=function(){function e(){this._bufferViewToData=new Map,this._bufferViewToProperties=new Map,this._accessorToBufferView=new Map}return e.prototype.generateBinary=function(e){var t=0;this._bufferViewToData.forEach(function(e){t+=e.byteLength});for(var r=new K(t),n=0,s=Array.from(this._bufferViewToData.keys()).sort(function(e,t){return k(t.byteLength)-k(e.byteLength)});n<s.length;n++){var o=s[n];o.byteOffset=r.byteOffset,e.push(o);for(var i=e.length-1,a=0,u=this.getPropertiesWithBufferView(o);a<u.length;a++)u[a].bufferView=i;r.writeTypedArray(this._bufferViewToData.get(o)),this._bufferViewToData.delete(o)}return r.getOutputData()},e.prototype.createBufferView=function(e,t){var r={buffer:0,byteOffset:void 0,byteLength:e.byteLength,byteStride:t};return this._bufferViewToData.set(r,e),r},e.prototype.createAccessor=function(e,t,r,n,s,o,i){this._verifyBufferView(e);var a={bufferView:void 0,componentType:r,count:n,type:t,min:null==o?void 0:o.min,max:null==o?void 0:o.max,normalized:i,byteOffset:s};return this.setBufferView(a,e),this._accessorToBufferView.set(a,e),a},e.prototype.setBufferView=function(e,t){this._verifyBufferView(t),this.getPropertiesWithBufferView(t).push(e)},e.prototype.removeBufferView=function(e){for(var t=this,r=0,n=this.getPropertiesWithBufferView(e);r<n.length;r++){var s=n[r];void 0!==s.bufferView&&delete s.bufferView}this._bufferViewToData.delete(e),this._bufferViewToProperties.delete(e),this._accessorToBufferView.forEach(function(r,n){r===e&&(void 0!==n.byteOffset&&delete n.byteOffset,t._accessorToBufferView.delete(n))})},e.prototype.getBufferView=function(e){var t=this._accessorToBufferView.get(e);return this._verifyBufferView(t),t},e.prototype.getPropertiesWithBufferView=function(e){var t;return this._verifyBufferView(e),this._bufferViewToProperties.set(e,null!==(t=this._bufferViewToProperties.get(e))&&void 0!==t?t:[]),this._bufferViewToProperties.get(e)},e.prototype.getData=function(e){return this._verifyBufferView(e),this._bufferViewToData.get(e)},e.prototype._verifyBufferView=function(e){if(void 0===e||!this._bufferViewToData.has(e))throw new Error("BufferView ".concat(e," not found in BufferManager."))},e}();!function(e){e[e.INTANGENT=0]="INTANGENT",e[e.OUTTANGENT=1]="OUTTANGENT"}(G||(G={}));var H=function(){function e(){}return e._IsTransformable=function(e){return e&&(e instanceof t.TransformNode||e instanceof t.Camera||e instanceof t.Light)},e._CreateNodeAnimation=function(r,n,s,o,i){if(this._IsTransformable(r)){var a=[],u=[],c=n.getKeys(),l=e._CalculateMinMaxKeyFrames(c),h=e._DeduceInterpolation(c,s,o),f=h.interpolationType,p=h.shouldBakeAnimation;if(p?e._CreateBakedAnimation(r,n,s,l.min,l.max,n.framePerSecond,i,a,u,l,o):"LINEAR"===f||"STEP"===f?e._CreateLinearOrStepAnimation(r,n,s,a,u,o):"CUBICSPLINE"===f?e._CreateCubicSplineAnimation(r,n,s,a,u,o):e._CreateBakedAnimation(r,n,s,l.min,l.max,n.framePerSecond,i,a,u,l,o),a.length&&u.length)return{inputs:a,outputs:u,samplerInterpolation:f,inputsMin:p?l.min:t.Tools.FloatRound(l.min/n.framePerSecond),inputsMax:p?l.max:t.Tools.FloatRound(l.max/n.framePerSecond)}}return null},e._DeduceAnimationInfo=function(e){var r=null,n="VEC3",s=!1,o=e.targetProperty.split(".");switch(o[0]){case"scaling":r="scale";break;case"position":r="translation";break;case"rotation":n="VEC4",r="rotation";break;case"rotationQuaternion":n="VEC4",s=!0,r="rotation";break;case"influence":n="SCALAR",r="weights";break;default:t.Tools.Error("Unsupported animatable property ".concat(o[0]))}return r?{animationChannelTargetPath:r,dataAccessorType:n,useQuaternion:s}:(t.Tools.Error("animation channel target path and data accessor type could be deduced"),null)},e._CreateNodeAnimationFromNodeAnimations=function(t,r,n,s,o,i,a,u,c,l,h){var f;if(e._IsTransformable(t)&&t.animations)for(var p=0,d=t.animations;p<d.length;p++){var x=d[p];if(!h||h(x)){var g=e._DeduceAnimationInfo(x);g&&(f={name:x.name,samplers:[],channels:[]},e._AddAnimation("".concat(x.name),x.hasRunningRuntimeAnimations?r:f,t,x,g.dataAccessorType,g.animationChannelTargetPath,s,i,a,u,g.useQuaternion,c,l),f.samplers.length&&f.channels.length&&n.push(f))}}},e._CreateMorphTargetAnimationFromMorphTargetAnimations=function(r,n,s,o,i,a,u,c,l,h,f){var p;if(r instanceof t.Mesh){var d=r.morphTargetManager;if(d)for(var x=0;x<d.numTargets;++x)for(var g=0,_=d.getTarget(x).animations;g<_.length;g++){var m=_[g];if(!f||f(m)){for(var T=new t.Animation("".concat(m.name),"influence",m.framePerSecond,m.dataType,m.loopMode,m.enableBlending),y=[],v=m.getKeys(),b=0;b<v.length;++b)for(var M=v[b],w=0;w<d.numTargets;++w)w==x?y.push(M):y.push({frame:M.frame,value:0});T.setKeys(y,!0);var A=e._DeduceAnimationInfo(T);A&&(p={name:T.name,samplers:[],channels:[]},e._AddAnimation(m.name,m.hasRunningRuntimeAnimations?n:p,r,T,A.dataAccessorType,A.animationChannelTargetPath,o,a,u,c,A.useQuaternion,l,h,d.numTargets),p.samplers.length&&p.channels.length&&s.push(p))}}}},e._CreateNodeAndMorphAnimationFromAnimationGroups=function(r,n,s,o,i,a,u,c,l){var h,f;if(r.animationGroups)for(var p=r.animationGroups,d=function(p){var d=new Map,g=new Map,_=new Set,m=p.to-p.from;f={name:p.name,channels:[],samplers:[]};for(var T=function(n){var m=p.targetedAnimations[n],T=m.target,y=m.animation;if(l&&!l(y))return"continue";var v=c.has(T);if(x._IsTransformable(T)||1===T.length&&x._IsTransformable(T[0])){if(M=e._DeduceAnimationInfo(m.animation)){var b=x._IsTransformable(T)?T:x._IsTransformable(T[0])?T[0]:null;b&&e._AddAnimation("".concat(y.name),f,b,y,M.dataAccessorType,M.animationChannelTargetPath,s,o,i,a,M.useQuaternion,u,v)}}else if(T instanceof t.MorphTarget||1===T.length&&T[0]instanceof t.MorphTarget){var M;if(M=e._DeduceAnimationInfo(m.animation)){var w=T instanceof t.MorphTarget?T:T[0];if(w){var A=r.morphTargetManagers.find(function(e){for(var t=0;t<e.numTargets;++t)if(e.getTarget(t)===w)return!0;return!1});if(A){var R=r.meshes.find(function(e){return e.morphTargetManager===A});R&&(d.has(R)||d.set(R,new Map),null===(h=d.get(R))||void 0===h||h.set(w,y),_.add(R),g.set(R,y))}}}}},y=0;y<p.targetedAnimations.length;++y)T(y);_.forEach(function(r){for(var n=r.morphTargetManager,c=null,l=[],h=g.get(r).getKeys(),x=h.length,_=0;_<x;++_)for(var T=0;T<n.numTargets;++T){var y=n.getTarget(T),v=d.get(r);if(v){var b=v.get(y);b?(c||(c=new t.Animation("".concat(p.name,"_").concat(r.name,"_MorphWeightAnimation"),"influence",b.framePerSecond,t.Animation.ANIMATIONTYPE_FLOAT,b.loopMode,b.enableBlending)),l.push(b.getKeys()[_])):l.push({frame:p.from+m/x*_,value:y.influence,inTangent:h[0].inTangent?0:void 0,outTangent:h[0].outTangent?0:void 0})}}c.setKeys(l,!0);var M=e._DeduceAnimationInfo(c);M&&e._AddAnimation("".concat(p.name,"_").concat(r.name,"_MorphWeightAnimation"),f,r,c,M.dataAccessorType,M.animationChannelTargetPath,s,o,i,a,M.useQuaternion,u,!1,null==n?void 0:n.numTargets)}),f.channels.length&&f.samplers.length&&n.push(f)},x=this,g=0,_=p;g<_.length;g++)d(_[g])},e._AddAnimation=function(r,n,s,o,i,a,u,c,l,h,f,p,d,x){var g,_,m,T,y,v,b=e._CreateNodeAnimation(s,o,a,f,p);if(b){if(x){for(var M=0,w=void 0,A=[];b.inputs.length>0;)w=b.inputs.shift(),M%x==0&&A.push(w),M++;b.inputs=A}var R=u.get(s),E=new Float32Array(b.inputs);g=c.createBufferView(E),_=c.createAccessor(g,"SCALAR",5126,b.inputs.length,void 0,{min:[b.inputsMin],max:[b.inputsMax]}),h.push(_),m=h.length-1;var I=new t.Quaternion,V=new t.Vector3,S=new t.Vector3,B=s instanceof t.Camera,U=C(i),P=new Float32Array(b.outputs.length*U);b.outputs.forEach(function(e,r){var n=e;switch(a){case"translation":d&&(t.Vector3.FromArrayToRef(e,0,S),F(S),S.toArray(n));break;case"rotation":4===e.length?t.Quaternion.FromArrayToRef(e,0,I):(n=new Array(4),t.Vector3.FromArrayToRef(e,0,V),t.Quaternion.FromEulerVectorToRef(V,I)),d&&(N(I),B&&O(I)),I.toArray(n)}P.set(n,r*U)}),g=c.createBufferView(P),_=c.createAccessor(g,i,5126,b.outputs.length),h.push(_),T=h.length-1,y={interpolation:b.samplerInterpolation,input:m,output:T},n.samplers.push(y),v={sampler:n.samplers.length-1,target:{node:R,path:a}},n.channels.push(v)}},e._CreateBakedAnimation=function(r,n,s,o,i,a,u,c,l,h,f){var p,d,x,g,_,m,T=t.Quaternion.Identity(),y=null,v=null;h.min=t.Tools.FloatRound(o/a);for(var b=n.getKeys(),M=0,w=b.length;M<w;++M){if(x=b[M],M+1<w)if(g=b[M+1],x.value.equals&&x.value.equals(g.value)||x.value===g.value){if(0!==M)continue;m=x.frame}else m=g.frame;else{if(_=b[M-1],x.value.equals&&x.value.equals(_.value)||x.value===_.value)continue;m=i}if(m)for(var A=x.frame;A<=m;A+=u)if((d=t.Tools.FloatRound(A/a))!==y){y=d,v=d;var R={key:0,repeatCount:0,loopMode:n.loopMode};p=n._interpolate(A,R),e._SetInterpolatedValue(r,p,d,n,s,T,c,l,f)}}v&&(h.max=v)},e._ConvertFactorToVector3OrQuaternion=function(r,n,s,o,i){var a=e._GetBasePositionRotationOrScale(n,o,i),u=s.targetProperty.split("."),c=u?u[1]:"",l=i?t.Quaternion.FromArray(a).normalize():t.Vector3.FromArray(a);switch(c){case"x":case"y":case"z":l[c]=r;break;case"w":l.w=r;break;default:t.Tools.Error('glTFAnimation: Unsupported component name "'.concat(c,'"!'))}return l},e._SetInterpolatedValue=function(e,r,n,s,o,i,a,u,c){var l;a.push(n),"weights"!==o?(s.dataType===t.Animation.ANIMATIONTYPE_FLOAT&&(r=this._ConvertFactorToVector3OrQuaternion(r,e,s,o,c)),"rotation"===o?(c?i=r:(l=r,t.Quaternion.RotationYawPitchRollToRef(l.y,l.x,l.z,i)),u.push(i.asArray())):(l=r,u.push(l.asArray()))):u.push([r])},e._CreateLinearOrStepAnimation=function(t,r,n,s,o,i){for(var a=0,u=r.getKeys();a<u.length;a++){var c=u[a];s.push(c.frame/r.framePerSecond),e._AddKeyframeValue(c,r,o,n,t,i)}},e._CreateCubicSplineAnimation=function(t,r,n,s,o,i){r.getKeys().forEach(function(a){s.push(a.frame/r.framePerSecond),e._AddSplineTangent(G.INTANGENT,o,n,"CUBICSPLINE",a,i),e._AddKeyframeValue(a,r,o,n,t,i),e._AddSplineTangent(G.OUTTANGENT,o,n,"CUBICSPLINE",a,i)})},e._GetBasePositionRotationOrScale=function(e,r,n){var s;if("rotation"===r)if(n){var o=e.rotationQuaternion;s=(null!=o?o:t.Quaternion.Identity()).asArray()}else{var i=e.rotation;s=(null!=i?i:t.Vector3.Zero()).asArray()}else if("translation"===r){var a=e.position;s=(null!=a?a:t.Vector3.Zero()).asArray()}else{var u=e.scaling;s=(null!=u?u:t.Vector3.One()).asArray()}return s},e._AddKeyframeValue=function(e,r,n,s,o,i){var a,u=r.dataType;if(u===t.Animation.ANIMATIONTYPE_VECTOR3){var c=e.value.asArray();if("rotation"===s){var l=t.Vector3.FromArray(c);c=t.Quaternion.RotationYawPitchRoll(l.y,l.x,l.z).asArray()}n.push(c)}else if(u===t.Animation.ANIMATIONTYPE_FLOAT){if("weights"===s)n.push([e.value]);else if(a=this._ConvertFactorToVector3OrQuaternion(e.value,o,r,s,i)){if("rotation"===s){var h=i?a:t.Quaternion.RotationYawPitchRoll(a.y,a.x,a.z).normalize();n.push(h.asArray())}n.push(a.asArray())}}else u===t.Animation.ANIMATIONTYPE_QUATERNION?n.push(e.value.normalize().asArray()):t.Tools.Error("glTFAnimation: Unsupported key frame values for animation!")},e._DeduceInterpolation=function(e,t,r){var n,s,o=!1;if("rotation"===t&&!r)return{interpolationType:"LINEAR",shouldBakeAnimation:!0};for(var i=0,a=e.length;i<a;++i)if((s=e[i]).inTangent||s.outTangent)if(n){if("CUBICSPLINE"!==n){n="LINEAR",o=!0;break}}else n="CUBICSPLINE";else if(n){if("CUBICSPLINE"===n||s.interpolation&&1===s.interpolation&&"STEP"!==n){n="LINEAR",o=!0;break}}else n=s.interpolation&&1===s.interpolation?"STEP":"LINEAR";return n||(n="LINEAR"),{interpolationType:n,shouldBakeAnimation:o}},e._AddSplineTangent=function(e,r,n,s,o,i){var a,u=e===G.INTANGENT?o.inTangent:o.outTangent;if("CUBICSPLINE"===s){if("rotation"===n)if(u)if(i)a=u.asArray();else{var c=u;a=t.Quaternion.RotationYawPitchRoll(c.y,c.x,c.z).asArray()}else a=[0,0,0,0];else a="weights"===n?u?[u]:[0]:u?u.asArray():[0,0,0];r.push(a)}},e._CalculateMinMaxKeyFrames=function(e){var t=1/0,r=-1/0;return e.forEach(function(e){t=Math.min(t,e.frame),r=Math.max(r,e.frame)}),{min:t,max:r}},e}();function q(e,r,n,s,o,i){var a={attributes:{},influence:e.influence,name:e.name},u=r.geometry;if(!u)return t.Tools.Warn("Attempted to export morph target data from a mesh without geometry. This should not happen."),a;var c,l=i?-1:1,h=t.Vector3.Zero();if(e.hasPositions){var f=e.getPositions(),p=u.getVerticesData(t.VertexBuffer.PositionKind);if(p){var d=new Float32Array(p.length),x=[1/0,1/0,1/0],g=[-1/0,-1/0,-1/0];c=p.length/3;for(var _=0;_<c;++_){var m=t.Vector3.FromArray(p,3*_);t.Vector3.FromArray(f,3*_).subtractToRef(m,h),h.x*=l,x[0]=Math.min(x[0],h.x),g[0]=Math.max(g[0],h.x),x[1]=Math.min(x[1],h.y),g[1]=Math.max(g[1],h.y),x[2]=Math.min(x[2],h.z),g[2]=Math.max(g[2],h.z),d[3*_]=h.x,d[3*_+1]=h.y,d[3*_+2]=h.z}var T=n.createBufferView(d,12),y=n.createAccessor(T,"VEC3",5126,f.length/3,0,{min:x,max:g});o.push(y),a.attributes.POSITION=o.length-1}else t.Tools.Warn("Morph target positions for mesh ".concat(r.name," were not exported. Mesh does not have position vertex data"))}if(e.hasNormals){var v=e.getNormals(),b=u.getVerticesData(t.VertexBuffer.NormalKind);if(b){var M=new Float32Array(b.length);for(c=b.length/3,_=0;_<c;++_){var w=t.Vector3.FromArray(b,3*_).normalize();t.Vector3.FromArray(v,3*_).normalize().subtractToRef(w,h),M[3*_]=h.x*l,M[3*_+1]=h.y,M[3*_+2]=h.z}T=n.createBufferView(M,12),y=n.createAccessor(T,"VEC3",5126,v.length/3,0),o.push(y),a.attributes.NORMAL=o.length-1}else t.Tools.Warn("Morph target normals for mesh ".concat(r.name," were not exported. Mesh does not have normals vertex data"))}if(e.hasTangents){var A=e.getTangents(),R=u.getVerticesData(t.VertexBuffer.TangentKind);if(R){c=R.length/4;var E=new Float32Array(3*c);for(_=0;_<c;++_){var C=t.Vector3.FromArray(R,4*_);S(C);var I=t.Vector3.FromArray(A,3*_);S(I),I.subtractToRef(C,h),E[3*_]=h.x*l,E[3*_+1]=h.y,E[3*_+2]=h.z}T=n.createBufferView(E,12),y=n.createAccessor(T,"VEC3",5126,c,0),o.push(y),a.attributes.TANGENT=o.length-1}else t.Tools.Warn("Morph target tangents for mesh ".concat(r.name," were not exported. Mesh does not have tangents vertex data"))}if(e.hasColors){var V=e.getColors(),F=u.getVerticesData(t.VertexBuffer.ColorKind),B=u.getVertexBuffer(t.VertexBuffer.ColorKind);if(F&&B){var N=B.getSize();c=F.length/N;var O=new Float32Array(c*N);for(_=0;_<c;++_)if(3===N){var U=t.Vector3.FromArray(F,_*N);t.Vector3.FromArray(V,_*N).subtractToRef(U,h),O[3*_]=h.x,O[3*_+1]=h.y,O[3*_+2]=h.z}else if(4===N){var P=new t.Vector4;U=t.Vector4.FromArray(F,_*N),t.Vector4.FromArray(V,_*N).subtractToRef(U,P),O[4*_]=P.x,O[4*_+1]=P.y,O[4*_+2]=P.z,O[4*_+3]=P.w}else t.Tools.Warn("Unsupported number of components for color attribute: ".concat(N));T=n.createBufferView(O,4*N),y=n.createAccessor(T,3===N?"VEC3":"VEC4",5126,c,0),o.push(y),a.attributes.COLOR_0=o.length-1}else t.Tools.Warn("Morph target colors for mesh ".concat(r.name," were not exported. Mesh does not have colors vertex data"))}return a}var j=function(){function e(e,t){this._indicesAccessorMap=new Map,this._vertexBufferViewMap=new Map,this._vertexAccessorMap=new Map,this._remappedBufferView=new Map,this._meshMorphTargetMap=new Map,this._vertexMapColorAlpha=new Map,this._exportedNodes=new Set,this._meshMap=new Map,this.convertedToRightHandedBuffers=new Map,this.convertToRightHanded=e,this.wasAddedByNoopNode=t}return e.prototype.getIndicesAccessor=function(e,t,r,n,s){var o,i,a,u;return null===(u=null===(a=null===(i=null===(o=this._indicesAccessorMap.get(e))||void 0===o?void 0:o.get(t))||void 0===i?void 0:i.get(r))||void 0===a?void 0:a.get(n))||void 0===u?void 0:u.get(s)},e.prototype.setIndicesAccessor=function(e,t,r,n,s,o){var i=this._indicesAccessorMap.get(e);i||(i=new Map,this._indicesAccessorMap.set(e,i));var a=i.get(t);a||(a=new Map,i.set(t,a));var u=a.get(r);u||(u=new Map,a.set(r,u));var c=u.get(n);c||(c=new Map,u.set(n,c)),c.set(s,o)},e.prototype.pushExportedNode=function(e){this._exportedNodes.has(e)||this._exportedNodes.add(e)},e.prototype.getNodesSet=function(){return this._exportedNodes},e.prototype.getVertexBufferView=function(e){return this._vertexBufferViewMap.get(e)},e.prototype.setVertexBufferView=function(e,t){this._vertexBufferViewMap.set(e,t)},e.prototype.setRemappedBufferView=function(e,t,r){this._remappedBufferView.set(e,new Map),this._remappedBufferView.get(e).set(t,r)},e.prototype.getRemappedBufferView=function(e,t){var r;return null===(r=this._remappedBufferView.get(e))||void 0===r?void 0:r.get(t)},e.prototype.getVertexAccessor=function(e,t,r){var n,s;return null===(s=null===(n=this._vertexAccessorMap.get(e))||void 0===n?void 0:n.get(t))||void 0===s?void 0:s.get(r)},e.prototype.setVertexAccessor=function(e,t,r,n){var s=this._vertexAccessorMap.get(e);s||(s=new Map,this._vertexAccessorMap.set(e,s));var o=s.get(t);o||(o=new Map,s.set(t,o)),o.set(r,n)},e.prototype.hasVertexColorAlpha=function(e){return this._vertexMapColorAlpha.get(e)||!1},e.prototype.setHasVertexColorAlpha=function(e,t){return this._vertexMapColorAlpha.set(e,t)},e.prototype.getMesh=function(e){return this._meshMap.get(e)},e.prototype.setMesh=function(e,t){this._meshMap.set(e,t)},e.prototype.bindMorphDataToMesh=function(e,t){var r=this._meshMorphTargetMap.get(e)||[];this._meshMorphTargetMap.set(e,r),-1===r.indexOf(t)&&r.push(t)},e.prototype.getMorphTargetsFromMesh=function(e){return this._meshMorphTargetMap.get(e)},e}(),Q=function(){function e(e,r){if(void 0===e&&(e=t.EngineStore.LastCreatedScene),this._glTF={asset:{generator:"Babylon.js v".concat(t.Engine.Version),version:"2.0"}},this._animations=[],this._accessors=[],this._bufferViews=[],this._cameras=[],this._images=[],this._materials=[],this._meshes=[],this._nodes=[],this._samplers=[],this._scenes=[],this._skins=[],this._textures=[],this._imageData={},this._shouldUseGlb=!1,this._materialExporter=new y(this),this._extensions={},this._bufferManager=new D,this._shouldExportNodeMap=new Map,this._nodeMap=new Map,this._materialMap=new Map,this._camerasMap=new Map,this._nodesCameraMap=new Map,this._skinMap=new Map,this._nodesSkinMap=new Map,this._materialNeedsUVsSet=new Set,!e)throw new Error("No scene available to export");this._babylonScene=e,this._options=o({shouldExportNode:function(){return!0},shouldExportAnimation:function(){return!0},metadataSelector:function(e){var t;return null===(t=null==e?void 0:e.gltf)||void 0===t?void 0:t.extras},animationSampleRate:1/60,exportWithoutWaitingForScene:!1,exportUnusedUVs:!1,removeNoopRootNodes:!0,includeCoordinateSystemConversionNodes:!1,meshCompressionMethod:"None"},r),this._loadExtensions()}return e.prototype._ApplyExtension=function(e,t,r,n){var s=this;if(r>=t.length)return Promise.resolve(e);var o=n(t[r],e);return o?o.then(function(e){return i(s,void 0,void 0,function(){var s;return a(this,function(o){switch(o.label){case 0:return e?[4,this._ApplyExtension(e,t,r+1,n)]:[3,2];case 1:return s=o.sent(),[3,3];case 2:s=null,o.label=3;case 3:return[2,s]}})})}):this._ApplyExtension(e,t,r+1,n)},e.prototype._ApplyExtensions=function(t,r){for(var n=[],s=0,o=e._ExtensionNames;s<o.length;s++){var i=o[s];n.push(this._extensions[i])}return this._ApplyExtension(t,n,0,r)},e.prototype._extensionsPostExportNodeAsync=function(e,t,r,n,s){var o=this;return this._ApplyExtensions(t,function(t,i){return t.postExportNodeAsync&&t.postExportNodeAsync(e,i,r,n,s,o._bufferManager)})},e.prototype._extensionsPostExportMaterialAsync=function(e,t,r){return this._ApplyExtensions(t,function(t,n){return t.postExportMaterialAsync&&t.postExportMaterialAsync(e,n,r)})},e.prototype._extensionsPostExportMaterialAdditionalTexturesAsync=function(t,r,n){return i(this,void 0,void 0,function(){var s,o=this;return a(this,function(u){switch(u.label){case 0:return s=[],[4,Promise.all(e._ExtensionNames.map(function(e){return i(o,void 0,void 0,function(){var o,i;return a(this,function(a){switch(a.label){case 0:return(o=this._extensions[e]).postExportMaterialAdditionalTexturesAsync?[4,o.postExportMaterialAdditionalTexturesAsync(t,r,n)]:[3,2];case 1:i=a.sent(),s.push.apply(s,i),a.label=2;case 2:return[2]}})})}))];case 1:return u.sent(),[2,s]}})})},e.prototype._extensionsPostExportTextures=function(t,r,n){for(var s=0,o=e._ExtensionNames;s<o.length;s++){var i=o[s],a=this._extensions[i];a.postExportTexture&&a.postExportTexture(t,r,n)}},e.prototype._extensionsPostExportMeshPrimitive=function(t){for(var r=0,n=e._ExtensionNames;r<n.length;r++){var s=n[r],o=this._extensions[s];o.postExportMeshPrimitive&&o.postExportMeshPrimitive(t,this._bufferManager,this._accessors)}},e.prototype._extensionsPreGenerateBinaryAsync=function(){return i(this,void 0,void 0,function(){var t,r,n,s;return a(this,function(o){switch(o.label){case 0:t=0,r=e._ExtensionNames,o.label=1;case 1:return t<r.length?(n=r[t],(s=this._extensions[n]).preGenerateBinaryAsync?[4,s.preGenerateBinaryAsync(this._bufferManager)]:[3,3]):[3,4];case 2:o.sent(),o.label=3;case 3:return t++,[3,1];case 4:return[2]}})})},e.prototype._forEachExtensions=function(t){for(var r=0,n=e._ExtensionNames;r<n.length;r++){var s=n[r],o=this._extensions[s];o.enabled&&t(o)}},e.prototype._extensionsOnExporting=function(){var e=this;this._forEachExtensions(function(t){var r,n,s;t.wasUsed&&((r=e._glTF).extensionsUsed||(r.extensionsUsed=[]),-1===e._glTF.extensionsUsed.indexOf(t.name)&&e._glTF.extensionsUsed.push(t.name),t.required&&((n=e._glTF).extensionsRequired||(n.extensionsRequired=[]),-1===e._glTF.extensionsRequired.indexOf(t.name)&&e._glTF.extensionsRequired.push(t.name)),(s=e._glTF).extensions||(s.extensions={}),t.onExporting&&t.onExporting())})},e.prototype._loadExtensions=function(){for(var t=0,r=e._ExtensionNames;t<r.length;t++){var n=r[t],s=e._ExtensionFactories[n](this);this._extensions[n]=s}},e.prototype.dispose=function(){for(var e in this._extensions)this._extensions[e].dispose()},Object.defineProperty(e.prototype,"options",{get:function(){return this._options},enumerable:!1,configurable:!0}),e.RegisterExtension=function(r,n,s){void 0===s&&(s=100),e.UnregisterExtension(r)&&t.Tools.Warn("Extension with the name ".concat(r," already exists")),e._ExtensionFactories[r]=n;var o=null!=s?s:0;e._ExtensionOrders[r]=o;for(var i=e._ExtensionNames.length,a=0;a<e._ExtensionNames.length;a++){var u=e._ExtensionNames[a];if(o<e._ExtensionOrders[u]){i=a;break}}e._ExtensionNames.splice(i,0,r)},e.UnregisterExtension=function(t){if(!e._ExtensionFactories[t])return!1;delete e._ExtensionFactories[t],delete e._ExtensionOrders[t];var r=e._ExtensionNames.indexOf(t);return-1!==r&&e._ExtensionNames.splice(r,1),!0},e.prototype._generateJSON=function(e,t,r){var n={byteLength:e};return n.byteLength&&(this._glTF.buffers=[n]),this._nodes&&this._nodes.length&&(this._glTF.nodes=this._nodes),this._meshes&&this._meshes.length&&(this._glTF.meshes=this._meshes),this._scenes&&this._scenes.length&&(this._glTF.scenes=this._scenes,this._glTF.scene=0),this._cameras&&this._cameras.length&&(this._glTF.cameras=this._cameras),this._bufferViews&&this._bufferViews.length&&(this._glTF.bufferViews=this._bufferViews),this._accessors&&this._accessors.length&&(this._glTF.accessors=this._accessors),this._animations&&this._animations.length&&(this._glTF.animations=this._animations),this._materials&&this._materials.length&&(this._glTF.materials=this._materials),this._textures&&this._textures.length&&(this._glTF.textures=this._textures),this._samplers&&this._samplers.length&&(this._glTF.samplers=this._samplers),this._skins&&this._skins.length&&(this._glTF.skins=this._skins),this._images&&this._images.length&&(this._glTF.images=this._images),this._shouldUseGlb||(n.uri=t+".bin"),r?JSON.stringify(this._glTF,null,2):JSON.stringify(this._glTF)},e.prototype.generateGLTFAsync=function(e){return i(this,void 0,void 0,function(){var t,r,s,o,i,u,c;return a(this,function(a){switch(a.label){case 0:return[4,this._generateBinaryAsync()];case 1:if(t=a.sent(),this._extensionsOnExporting(),r=this._generateJSON(t.byteLength,e,!0),s=new Blob([t],{type:"application/octet-stream"}),o=e+".gltf",i=e+".bin",(u=new n).files[o]=r,u.files[i]=s,this._imageData)for(c in this._imageData)u.files[c]=this._imageData[c];return[2,u]}})})},e.prototype._generateBinaryAsync=function(){return i(this,void 0,void 0,function(){return a(this,function(e){switch(e.label){case 0:return[4,this._exportSceneAsync()];case 1:return e.sent(),[4,this._extensionsPreGenerateBinaryAsync()];case 2:return e.sent(),[2,this._bufferManager.generateBinary(this._bufferViews)]}})})},e.prototype._getPadding=function(e){var t=e%4;return 0===t?t:4-t},e.prototype.generateGLBAsync=function(e){return i(this,void 0,void 0,function(){var t,r,s,o,i,u,c,l,h,f,p,d,x,g;return a(this,function(a){switch(a.label){case 0:return this._shouldUseGlb=!0,[4,this._generateBinaryAsync()];case 1:if(t=a.sent(),this._extensionsOnExporting(),r=this._generateJSON(t.byteLength),s=e+".glb",o=r.length,"undefined"!=typeof TextEncoder&&(u=new TextEncoder,i=u.encode(r),o=i.length),c=this._getPadding(o),l=this._getPadding(t.byteLength),h=28+o+c+t.byteLength+l,(f=new K(h)).writeUInt32(1179937895),f.writeUInt32(2),f.writeUInt32(h),f.writeUInt32(o+c),f.writeUInt32(1313821514),i)f.writeTypedArray(i);else for(p="_".charCodeAt(0),x=0;x<o;++x)(d=r.charCodeAt(x))!=r.codePointAt(x)?f.writeUInt8(p):f.writeUInt8(d);for(x=0;x<c;++x)f.writeUInt8(32);for(f.writeUInt32(t.byteLength+l),f.writeUInt32(5130562),f.writeTypedArray(t),x=0;x<l;++x)f.writeUInt8(0);return(g=new n).files[s]=new Blob([f.getOutputData()],{type:"application/octet-stream"}),[2,g]}})})},e.prototype._setNodeTransformation=function(e,r,n){var s;if(r.getPivotPoint().equalsWithEpsilon(M,t.Epsilon)||t.Tools.Warn("Pivot points are not supported in the glTF serializer"),!r.position.equalsWithEpsilon(M,t.Epsilon)){var o=t.TmpVectors.Vector3[0].copyFrom(r.position);n&&F(o),e.translation=o.asArray()}r.scaling.equalsWithEpsilon(A,t.Epsilon)||(e.scale=r.scaling.asArray());var i=(null===(s=r.rotationQuaternion)||void 0===s?void 0:s.clone())||t.Quaternion.FromEulerAngles(r.rotation.x,r.rotation.y,r.rotation.z);i.equalsWithEpsilon(w,t.Epsilon)||(n&&N(i),e.rotation=i.normalize().asArray())},e.prototype._setCameraTransformation=function(e,r,n){var s=t.TmpVectors.Vector3[0],o=t.TmpVectors.Quaternion[0],i=r.getWorldMatrix();if(r.parent){var a=r.parent.getWorldMatrix().invertToRef(t.TmpVectors.Matrix[0]);i.multiplyToRef(a,t.TmpVectors.Matrix[1]).decompose(void 0,o,s)}else i.decompose(void 0,o,s);s.equalsWithEpsilon(M,t.Epsilon)||(n&&F(s),e.translation=s.asArray()),n&&N(o),this._babylonScene.useRightHandedSystem||O(o),o.equalsWithEpsilon(w,t.Epsilon)||(e.rotation=o.asArray())},e.prototype._listAvailableCameras=function(){for(var e=0,r=this._babylonScene.cameras;e<r.length;e++){var n=r[e],s={type:n.mode===t.Camera.PERSPECTIVE_CAMERA?"perspective":"orthographic"};if(n.name&&(s.name=n.name),"perspective"===s.type)s.perspective={aspectRatio:n.getEngine().getAspectRatio(n),yfov:n.fovMode===t.Camera.FOVMODE_VERTICAL_FIXED?n.fov:n.fov*n.getEngine().getAspectRatio(n),znear:n.minZ,zfar:n.maxZ};else if("orthographic"===s.type){var o=n.orthoLeft&&n.orthoRight?.5*(n.orthoRight-n.orthoLeft):.5*n.getEngine().getRenderWidth(),i=n.orthoBottom&&n.orthoTop?.5*(n.orthoTop-n.orthoBottom):.5*n.getEngine().getRenderHeight();s.orthographic={xmag:o,ymag:i,znear:n.minZ,zfar:n.maxZ}}this._camerasMap.set(n,s)}},e.prototype._exportAndAssignCameras=function(){for(var e=0,t=Array.from(this._camerasMap.values());e<t.length;e++){var r=t[e],n=this._nodesCameraMap.get(r);if(void 0!==n){this._cameras.push(r);for(var s=0,o=n;s<o.length;s++)o[s].camera=this._cameras.length-1}}},e.prototype._listAvailableSkeletons=function(){for(var e=0,t=this._babylonScene.skeletons;e<t.length;e++){var r=t[e];r.bones.length<=0||this._skinMap.set(r,{joints:[]})}},e.prototype._exportAndAssignSkeletons=function(e){for(var r,n=function(n){if(n.bones.length<=0)return"continue";var o=s._skinMap.get(n);if(null==o)return"continue";for(var i={},a=-1,u=0;u<n.bones.length;++u){var c=n.bones[u];-1!==(h=null!==(r=c.getIndex())&&void 0!==r?r:u)&&(i[h]=c,h>a&&(a=h))}for(var l=[],h=0;h<=a;++h){var f=(c=i[h]).getTransformNode(),p=f?s._nodeMap.get(f):void 0;if(void 0!==p){o.joints.push(p);var d=c.getAbsoluteInverseBindMatrix().clone();e.has(f)&&B(d),l.push(d)}else t.Tools.Warn("Exporting a bone without a linked transform node is currently unsupported.")}var x=s._nodesSkinMap.get(o);if(o.joints.length>0&&void 0!==x){var g=new Float32Array(16*l.length);l.forEach(function(e,t){g.set(e.m,16*t)});var _=s._bufferManager.createBufferView(g);s._accessors.push(s._bufferManager.createAccessor(_,"MAT4",5126,l.length)),o.inverseBindMatrices=s._accessors.length-1,s._skins.push(o);for(var m=s._skins.length-1,T=0,y=x;T<y.length;T++)y[T].skin=m}},s=this,o=0,i=this._babylonScene.skeletons;o<i.length;o++)n(i[o])},e.prototype._exportSceneAsync=function(){return i(this,void 0,void 0,function(){var e,r,n,s,o,i,u,c,l,h,f,p,d,x,g,_,m,T,y,v,M,w,A,R,E,C,I,V,S,F,B,N,O;return a(this,function(a){switch(a.label){case 0:if(e={nodes:[]},this._babylonScene.metadata&&(r=this._options.metadataSelector(this._babylonScene.metadata))&&(e.extras=r),n=new Array,s=new Array,o=new Array,this._options.removeNoopRootNodes&&!this._options.includeCoordinateSystemConversionNodes)for(u=0,c=this._babylonScene.animationGroups;u<c.length;u++)for(l=c[u],h=0,f=l.targetedAnimations;h<f.length;h++)p=f[h],(d=p.target)instanceof t.TransformNode&&!d.parent&&(null!=i?i:i=new Set).add(d);for(x=0,g=this._babylonScene.rootNodes;x<g.length;x++)_=g[x],m=_.animations,T=!!m&&m.length>0||(null==i?void 0:i.has(_)),this._options.removeNoopRootNodes&&!this._options.includeCoordinateSystemConversionNodes&&b(_,this._babylonScene.useRightHandedSystem)&&!T?o.push.apply(o,_.getChildren()):this._babylonScene.useRightHandedSystem?n.push(_):s.push(_);return this._listAvailableCameras(),this._listAvailableSkeletons(),y=new j(!0,!1),M=(v=(B=e.nodes).push).apply,w=[B],[4,this._exportNodesAsync(s,y)];case 1:return M.apply(v,w.concat([a.sent()])),A=new j(!1,!1),E=(R=(N=e.nodes).push).apply,C=[N],[4,this._exportNodesAsync(n,A)];case 2:return E.apply(R,C.concat([a.sent()])),I=new j(!1,!0),S=(V=(O=e.nodes).push).apply,F=[O],[4,this._exportNodesAsync(o,I)];case 3:return S.apply(V,F.concat([a.sent()])),e.nodes.length&&this._scenes.push(e),this._exportAndAssignCameras(),this._exportAndAssignSkeletons(y.getNodesSet()),this._babylonScene.animationGroups.length&&H._CreateNodeAndMorphAnimationFromAnimationGroups(this._babylonScene,this._animations,this._nodeMap,this._bufferManager,this._bufferViews,this._accessors,this._animationSampleRate,y.getNodesSet(),this._options.shouldExportAnimation),[2]}})})},e.prototype._shouldExportNode=function(e){var t=this._shouldExportNodeMap.get(e);return void 0===t&&(t=this._options.shouldExportNode(e),this._shouldExportNodeMap.set(e,t)),t},e.prototype._exportNodesAsync=function(e,t){return i(this,void 0,void 0,function(){var r,n,s,o;return a(this,function(i){switch(i.label){case 0:r=new Array,this._exportBuffers(e,t),n=0,s=e,i.label=1;case 1:return n<s.length?(o=s[n],[4,this._exportNodeAsync(o,r,t)]):[3,4];case 2:i.sent(),i.label=3;case 3:return n++,[3,1];case 4:return[2,r]}})})},e.prototype._collectBuffers=function(e,r,n,s,o){if(this._shouldExportNode(e)&&e instanceof t.AbstractMesh&&e.geometry){var i=e.geometry.getVertexBuffers();if(i)for(var a in i)if(V(a)){var u=i[a];o.setHasVertexColorAlpha(u,e.hasVertexAlpha);var c=u._buffer,l=r.get(c)||[];r.set(c,l),-1===l.indexOf(u)&&l.push(u);var h=n.get(u)||[];n.set(u,h),-1===h.indexOf(e)&&h.push(e)}var f=e.morphTargetManager;if(f)for(var p=0;p<f.numTargets;p++){var d=f.getTarget(p);h=s.get(d)||[],s.set(d,h),-1===h.indexOf(e)&&h.push(e)}}for(var x=0,g=e.getChildren();x<g.length;x++){var _=g[x];this._collectBuffers(_,r,n,s,o)}},e.prototype._exportBuffers=function(e,r){for(var n=new Map,s=new Map,o=new Map,i=0,a=e;i<a.length;i++){var u=a[i];this._collectBuffers(u,n,s,o,r)}for(var c=Array.from(n.keys()),l=function(e){var o=e.getData();if(!o)throw new Error("Buffer data is not available");var i=n.get(e);if(!i)return"continue";var a=i[0].byteStride;if(i.some(function(e){return e.byteStride!==a}))throw new Error("Vertex buffers pointing to the same buffer must have the same byte stride");for(var u=function(e){if(e instanceof Array){var t=new Float32Array(e);return new Uint8Array(t.buffer,t.byteOffset,t.byteLength)}return ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):new Uint8Array(e)}(o).slice(),c=function(e){var r=s.get(e),n=E(e,r),o=n.byteOffset,i=n.byteStride,a=n.componentCount,c=n.type,l=n.count,f=n.normalized;switch(n.kind){case t.VertexBuffer.NormalKind:case t.VertexBuffer.TangentKind:t.EnumerateFloatValues(u,o,i,a,c,l,f,function(e){var t=Math.sqrt(e[0]*e[0]+e[1]*e[1]+e[2]*e[2]);if(t>0){var r=1/t;e[0]*=r,e[1]*=r,e[2]*=r}});break;case t.VertexBuffer.ColorKind:var p=r.filter(function(e){return e.material instanceof t.StandardMaterial||null==e.material}).length;if(0==p)break;if(p!=r.length){t.Logger.Warn("Not converting vertex color space, as buffer is shared by StandardMaterials and other material types. Results may look incorrect.");break}c==t.VertexBuffer.UNSIGNED_BYTE&&t.Logger.Warn("Converting uint8 vertex colors to linear space. Results may look incorrect.");var d=new t.Color3,x=new t.Color4,g=h._babylonScene.getEngine().useExactSrgbConversions;t.EnumerateFloatValues(u,o,i,a,c,l,f,function(e){3===e.length?(d.fromArray(e,0),d.toLinearSpaceToRef(d,g),d.toArray(e,0)):(x.fromArray(e,0),x.toLinearSpaceToRef(x,g),x.toArray(e,0))})}},l=0,f=i;l<f.length;l++)c(N=f[l]);if(r.convertToRightHanded){for(var p=0,d=i;p<d.length;p++){var x=E(N=d[p],s.get(N)),g=x.byteOffset,_=x.byteStride,m=x.componentCount,T=x.type,y=x.count,v=x.normalized;switch(C=x.kind){case t.VertexBuffer.PositionKind:case t.VertexBuffer.NormalKind:case t.VertexBuffer.TangentKind:t.EnumerateFloatValues(u,g,_,m,T,y,v,function(e){e[0]=-e[0]})}}r.convertedToRightHandedBuffers.set(e,u)}var b=h._bufferManager.createBufferView(u,a);r.setVertexBufferView(e,b);for(var M=new Map,w=0,A=i;w<A.length;w++){var R=E(N=A[w],s.get(N)),C=R.kind,V=R.totalVertices;switch(C){case t.VertexBuffer.MatricesIndicesKind:case t.VertexBuffer.MatricesIndicesExtraKind:if(N.type==t.VertexBuffer.FLOAT){var S=N.getFloatData(V);null!==S&&M.set(N,S)}}}0!==M.size&&t.Logger.Warn("Joint indices conversion needed: some joint indices are stored as floats in Babylon but GLTF requires UNSIGNED BYTES. We will perform the conversion but this might lead to unused data in the buffer.");for(var F=0,B=Array.from(M.keys());F<B.length;F++){var N=B[F],O=M.get(N);if(O){for(var U=I(O),P=new(U?Uint16Array:Uint8Array)(O.length),W=0;W<O.length;W++)P[W]=O[W];var L=h._bufferManager.createBufferView(P,4*(U?2:1));r.setRemappedBufferView(e,N,L)}}},h=this,f=0,p=c;f<p.length;f++)l(p[f]);for(var d=0,x=Array.from(o.keys());d<x.length;d++){var g=x[d],_=o.get(g);if(_)for(var m=q(g,_[0],this._bufferManager,this._bufferViews,this._accessors,r.convertToRightHanded),T=0,y=_;T<y.length;T++){var v=y[T];r.bindMorphDataToMesh(v,m)}}},e.prototype._exportNodeAsync=function(e,t,r){return i(this,void 0,void 0,function(){var n,s,o,i,u,c,l,h,f=this;return a(this,function(a){switch(a.label){case 0:return void 0!==(n=this._nodeMap.get(e))?(t.includes(n)||t.push(n),[2]):[4,this._createNodeAsync(e,r)];case 1:(s=a.sent())&&(n=this._nodes.length,this._nodes.push(s),this._nodeMap.set(e,n),r.pushExportedNode(e),t.push(n),o={name:"runtime animations",channels:[],samplers:[]},i=[],this._babylonScene.animationGroups.length||(H._CreateMorphTargetAnimationFromMorphTargetAnimations(e,o,i,this._nodeMap,this._nodes,this._bufferManager,this._bufferViews,this._accessors,this._animationSampleRate,r.convertToRightHanded,this._options.shouldExportAnimation),e.animations.length&&H._CreateNodeAnimationFromNodeAnimations(e,o,i,this._nodeMap,this._nodes,this._bufferManager,this._bufferViews,this._accessors,this._animationSampleRate,r.convertToRightHanded,this._options.shouldExportAnimation)),o.channels.length&&o.samplers.length&&this._animations.push(o),i.forEach(function(e){e.channels.length&&e.samplers.length&&f._animations.push(e)})),u=s?[]:t,c=0,l=e.getChildren(),a.label=2;case 2:return c<l.length?(h=l[c],[4,this._exportNodeAsync(h,u,r)]):[3,5];case 3:a.sent(),a.label=4;case 4:return c++,[3,2];case 5:return s&&u.length&&(s.children=u),[2]}})})},e.prototype._createNodeAsync=function(e,r){return i(this,void 0,void 0,function(){var n,s,o,i,u,c,l,h,f,p,d,x;return a(this,function(a){switch(a.label){case 0:return this._shouldExportNode(e)?(n={},e.name&&(n.name=e.name),e.metadata&&(s=this._options.metadataSelector(e.metadata))&&(n.extras=s),e instanceof t.TransformNode?(this._setNodeTransformation(n,e,r.convertToRightHanded),e instanceof t.AbstractMesh?(o=e instanceof t.InstancedMesh?e.sourceMesh:e).subMeshes&&o.subMeshes.length>0?(i=n,[4,this._exportMeshAsync(o,r)]):[3,2]:[3,3]):[3,3]):[2,null];case 1:i.mesh=a.sent(),a.label=2;case 2:e.skeleton&&void 0!==(u=this._skinMap.get(e.skeleton))&&(void 0===this._nodesSkinMap.get(u)&&this._nodesSkinMap.set(u,[]),null===(p=this._nodesSkinMap.get(u))||void 0===p||p.push(n)),a.label=3;case 3:if(e instanceof t.TargetCamera&&(c=this._camerasMap.get(e))){if(void 0===this._nodesCameraMap.get(c)&&this._nodesCameraMap.set(c,[]),this._setCameraTransformation(n,e,r.convertToRightHanded),null!==(l=e.parent)&&P(e,l)&&void 0!==(h=this._nodeMap.get(l)))return f=this._nodes[h],U(n,f),null===(d=this._nodesCameraMap.get(c))||void 0===d||d.push(f),[2,null];null===(x=this._nodesCameraMap.get(c))||void 0===x||x.push(n)}return[4,this._extensionsPostExportNodeAsync("exportNodeAsync",n,e,this._nodeMap,r.convertToRightHanded)];case 4:return a.sent()?[2,n]:(t.Logger.Warn("Not exporting node ".concat(e.name)),[2,null])}})})},e.prototype._exportIndices=function(e,r,n,s,o,i,a,u,c){var l=null;c.mode=function(e){switch(e){case t.Material.TriangleFillMode:return 4;case t.Material.TriangleStripDrawMode:return 5;case t.Material.TriangleFanDrawMode:return 6;case t.Material.PointListDrawMode:case t.Material.PointFillMode:return 0;case t.Material.LineLoopDrawMode:return 2;case t.Material.LineListDrawMode:return 1;case t.Material.LineStripDrawMode:return 3}throw new Error("Unknown fill mode: ".concat(e))}(i);var h=a!==t.Material.CounterClockWiseSideOrientation&&function(e){switch(e){case t.Material.TriangleFillMode:case t.Material.TriangleStripDrawMode:case t.Material.TriangleFanDrawMode:return!0}return!1}(i);if(h){if(i===t.Material.TriangleStripDrawMode||i===t.Material.TriangleFanDrawMode)throw new Error("Triangle strip/fan fill mode is not implemented");var f=r?new Uint32Array(s):new Uint16Array(s);if(e)for(var p=0;p+2<s;p+=3)f[p]=e[n+p]+o,f[p+1]=e[n+p+2]+o,f[p+2]=e[n+p+1]+o;else for(p=0;p+2<s;p+=3)f[p]=p,f[p+1]=p+2,f[p+2]=p+1;l=f}else if(e&&0!==o){for(f=r?new Uint32Array(s):new Uint16Array(s),p=0;p<s;p++)f[p]=e[n+p]+o;l=f}else e&&(l=function(e,t,r,n){var s=e;return 0===t&&r===e.length||(s=Array.isArray(e)?e.slice(t,t+r):e.subarray(t,t+r)),s instanceof Int32Array?new Uint32Array(s.buffer,s.byteOffset,s.length):Array.isArray(s)?n?new Uint32Array(s):new Uint16Array(s):s}(e,n,s,r));if(l){var d=u.getIndicesAccessor(e,n,s,o,h);if(void 0===d){var x=this._bufferManager.createBufferView(l),g=r?5125:5123;this._accessors.push(this._bufferManager.createAccessor(x,"SCALAR",g,s,0)),d=this._accessors.length-1,u.setIndicesAccessor(e,n,s,o,h,d)}c.indices=d}},e.prototype._exportVertexBuffer=function(e,r,n,s,o,i){var a=e.getKind();if(V(a)&&(!a.startsWith("uv")||this._options.exportUnusedUVs||r&&this._materialNeedsUVsSet.has(r))){var u=o.getVertexAccessor(e,n,s);if(void 0===u){var c=o.convertedToRightHandedBuffers.get(e._buffer)||e._buffer.getData(),l=a===t.VertexBuffer.PositionKind?function(e,r,n,s){var o=r.byteOffset,i=r.byteStride,a=r.type,u=r.normalized,c=r.getSize(),l=new Array(c).fill(1/0),h=new Array(c).fill(-1/0);return t.EnumerateFloatValues(e,o+n*i,i,c,a,s*c,u,function(e){for(var t=0;t<c;t++)l[t]=Math.min(l[t],e[t]),h[t]=Math.max(h[t],e[t])}),{min:l,max:h}}(c,e,n,s):void 0,h=(a===t.VertexBuffer.MatricesIndicesKind||a===t.VertexBuffer.MatricesIndicesExtraKind)&&e.type===t.VertexBuffer.FLOAT,f=h?t.VertexBuffer.UNSIGNED_BYTE:e.type,p=h?void 0:e.normalized,d=h?o.getRemappedBufferView(e._buffer,e):o.getVertexBufferView(e._buffer),x=e.byteOffset+n*e.byteStride;this._accessors.push(this._bufferManager.createAccessor(d,function(e,r){if(e==t.VertexBuffer.ColorKind)return r?"VEC4":"VEC3";switch(e){case t.VertexBuffer.PositionKind:case t.VertexBuffer.NormalKind:return"VEC3";case t.VertexBuffer.TangentKind:case t.VertexBuffer.MatricesIndicesKind:case t.VertexBuffer.MatricesIndicesExtraKind:case t.VertexBuffer.MatricesWeightsKind:case t.VertexBuffer.MatricesWeightsExtraKind:return"VEC4";case t.VertexBuffer.UVKind:case t.VertexBuffer.UV2Kind:case t.VertexBuffer.UV3Kind:case t.VertexBuffer.UV4Kind:case t.VertexBuffer.UV5Kind:case t.VertexBuffer.UV6Kind:return"VEC2"}throw new Error("Unknown kind ".concat(e))}(a,o.hasVertexColorAlpha(e)),f,s,x,l,p)),u=this._accessors.length-1,o.setVertexAccessor(e,n,s,u)}i.attributes[function(e){switch(e){case t.VertexBuffer.PositionKind:return"POSITION";case t.VertexBuffer.NormalKind:return"NORMAL";case t.VertexBuffer.TangentKind:return"TANGENT";case t.VertexBuffer.ColorKind:return"COLOR_0";case t.VertexBuffer.UVKind:return"TEXCOORD_0";case t.VertexBuffer.UV2Kind:return"TEXCOORD_1";case t.VertexBuffer.UV3Kind:return"TEXCOORD_2";case t.VertexBuffer.UV4Kind:return"TEXCOORD_3";case t.VertexBuffer.UV5Kind:return"TEXCOORD_4";case t.VertexBuffer.UV6Kind:return"TEXCOORD_5";case t.VertexBuffer.MatricesIndicesKind:return"JOINTS_0";case t.VertexBuffer.MatricesIndicesExtraKind:return"JOINTS_1";case t.VertexBuffer.MatricesWeightsKind:return"WEIGHTS_0";case t.VertexBuffer.MatricesWeightsExtraKind:return"WEIGHTS_1"}throw new Error("Unknown kind: ".concat(e))}(a)]=u}},e.prototype._exportMaterialAsync=function(e,r,n,s){return i(this,void 0,void 0,function(){var o,i;return a(this,function(a){switch(a.label){case 0:return void 0!==(o=this._materialMap.get(e))?[3,8]:(i=r&&Object.keys(r).some(function(e){return e.startsWith("uv")}),(e=e instanceof t.MultiMaterial?e.subMaterials[n.materialIndex]:e)instanceof t.PBRBaseMaterial?[4,this._materialExporter.exportPBRMaterialAsync(e,i)]:[3,2]);case 1:return o=a.sent(),[3,7];case 2:return e instanceof t.StandardMaterial?[4,this._materialExporter.exportStandardMaterialAsync(e,i)]:[3,4];case 3:return o=a.sent(),[3,7];case 4:return e instanceof t.OpenPBRMaterial?[4,this._materialExporter.exportOpenPBRMaterialAsync(e,i)]:[3,6];case 5:return o=a.sent(),[3,7];case 6:return t.Logger.Warn("Unsupported material '".concat(e.name,"' with type ").concat(e.getClassName())),[2];case 7:this._materialMap.set(e,o),a.label=8;case 8:return s.material=o,[2]}})})},e.prototype._exportMeshAsync=function(e,r){return i(this,void 0,void 0,function(){var n,s,o,i,c,l,h,f,p,d,x,g,_,m,T,y,v,b,M,w,A,R,E,C,I,V,S,F,B,N,O,U,P,W;return a(this,function(a){switch(a.label){case 0:if(void 0!==(n=r.getMesh(e)))return[2,n];if(s={primitives:[]},n=this._meshes.length,this._meshes.push(s),r.setMesh(e,n),o=e.isUnIndexed?null:e.getIndices(),i=null===(B=e.geometry)||void 0===B?void 0:B.getVertexBuffers(),c=r.getMorphTargetsFromMesh(e),l=e instanceof t.LinesMesh,h=e instanceof t.GreasedLineBaseMesh,f=e.subMeshes,!(i&&f&&f.length>0))return[3,7];p=0,d=f,a.label=1;case 1:return p<d.length?(x=d[p],g={attributes:{}},_=x.getMaterial()||this._babylonScene.defaultMaterial,h?(v={name:_.name},b=e,m=t.Color3.White(),T=null!==(O=null===(N=b.material)||void 0===N?void 0:N.alpha)&&void 0!==O?O:1,(!(y=null!==(P=null===(U=b.greasedLineMaterial)||void 0===U?void 0:U.color)&&void 0!==P?P:m).equalsWithEpsilon(m,t.Epsilon)||T<1)&&(v.pbrMetallicRoughness={baseColorFactor:u(u([],y.asArray(),!0),[T],!1)}),this._materials.push(v),g.material=this._materials.length-1,[3,5]):[3,2]):[3,7];case 2:return l?(v={name:_.name},(!(b=e).color.equalsWithEpsilon(t.Color3.White(),t.Epsilon)||b.alpha<1)&&(v.pbrMetallicRoughness={baseColorFactor:u(u([],b.color.asArray(),!0),[b.alpha],!1)}),this._materials.push(v),g.material=this._materials.length-1,[3,5]):[3,3];case 3:return[4,this._exportMaterialAsync(_,i,x,g)];case 4:a.sent(),a.label=5;case 5:for(M=l||h?t.Material.LineListDrawMode:null!==(W=e.overrideRenderingFillMode)&&void 0!==W?W:_.fillMode,w=_._getEffectiveOrientation(e),r.wasAddedByNoopNode&&!e.getScene().useRightHandedSystem&&(w=w===t.Material.ClockWiseSideOrientation?t.Material.CounterClockWiseSideOrientation:t.Material.ClockWiseSideOrientation),this._exportIndices(o,o?t.AreIndices32Bits(o,x.indexCount,x.indexStart,x.verticesStart):x.verticesCount>65535,o?x.indexStart:x.verticesStart,o?x.indexCount:x.verticesCount,-x.verticesStart,M,w,r,g),A=0,R=Object.values(i);A<R.length;A++)E=R[A],this._exportVertexBuffer(E,_,x.verticesStart,x.verticesCount,r,g);if(c)for(g.targets=[],C=0,I=c;C<I.length;C++)F=I[C],g.targets.push(F.attributes);s.primitives.push(g),this._extensionsPostExportMeshPrimitive(g),a.label=6;case 6:return p++,[3,1];case 7:if(c)for(s.weights=[],s.extras||(s.extras={}),s.extras.targetNames=[],V=0,S=c;V<S.length;V++)F=S[V],s.weights.push(F.influence),s.extras.targetNames.push(F.name);return[2,n]}})})},e._ExtensionNames=new Array,e._ExtensionFactories={},e._ExtensionOrders={},e}(),X=function(){function e(){}return e.GLTFAsync=function(e,t,r){return i(this,void 0,void 0,function(){var n,s;return a(this,function(o){switch(o.label){case 0:return r&&r.exportWithoutWaitingForScene?[3,2]:[4,e.whenReadyAsync()];case 1:o.sent(),o.label=2;case 2:return[4,(n=new Q(e,r)).generateGLTFAsync(t.replace(/\.[^/.]+$/,""))];case 3:return s=o.sent(),n.dispose(),[2,s]}})})},e.GLBAsync=function(e,t,r){return i(this,void 0,void 0,function(){var n,s;return a(this,function(o){switch(o.label){case 0:return r&&r.exportWithoutWaitingForScene?[3,2]:[4,e.whenReadyAsync()];case 1:o.sent(),o.label=2;case 2:return[4,(n=new Q(e,r)).generateGLBAsync(t.replace(/\.[^/.]+$/,""))];case 3:return s=o.sent(),n.dispose(),[2,s]}})})},e}(),Y={__proto__:null,GLTF2Export:X},Z="EXT_mesh_gpu_instancing";function J(e,t){for(var r=new Float32Array(3*t),n=0;n<t;n++)r[3*n+0]=e[4*n+0],r[3*n+1]=e[4*n+1],r[3*n+2]=e[4*n+2];return r}var $=function(){function e(e){this.name=Z,this.enabled=!0,this.required=!1,this._instanceColorWarned=!1,this._wasUsed=!1,this._exporter=e}return e.prototype.dispose=function(){},Object.defineProperty(e.prototype,"wasUsed",{get:function(){return this._wasUsed},enumerable:!1,configurable:!0}),e.prototype.postExportNodeAsync=function(e,r,n,s,o,u){return i(this,void 0,void 0,function(){var e=this;return a(this,function(s){switch(s.label){case 0:return[4,new Promise(function(s){var i,a;if(r&&n instanceof t.Mesh&&n.hasThinInstances&&e._exporter){e._wasUsed=!0;for(var c=t.Vector3.Zero(),l=t.Quaternion.Identity(),h=t.Vector3.One(),f=n.thinInstanceGetWorldMatrices(),p=t.TmpVectors.Vector3[2],d=t.TmpVectors.Quaternion[1],x=t.TmpVectors.Vector3[3],g=!1,_=!1,m=!1,T=new Float32Array(3*n.thinInstanceCount),y=new Float32Array(4*n.thinInstanceCount),v=new Float32Array(3*n.thinInstanceCount),b=0,M=0,w=f;M<w.length;M++)w[M].decompose(x,d,p),o&&(F(p),N(d)),T.set(p.asArray(),3*b),y.set(d.normalize().asArray(),4*b),v.set(x.asArray(),3*b),g=g||!p.equalsWithEpsilon(c),_=_||!d.equalsWithEpsilon(l),m=m||!x.equalsWithEpsilon(h),b++;var A={attributes:{}};g&&(A.attributes.TRANSLATION=e._buildAccessor(T,"VEC3",n.thinInstanceCount,u)),_&&(A.attributes.ROTATION=e._buildAccessor(y,"VEC4",n.thinInstanceCount,u)),m&&(A.attributes.SCALE=e._buildAccessor(v,"VEC3",n.thinInstanceCount,u));var R=null===(a=null===(i=n._userThinInstanceBuffersStorage)||void 0===i?void 0:i.data)||void 0===a?void 0:a.instanceColor;if(R){var E=n.thinInstanceCount;n.hasVertexAlpha&&R.length===4*E?(e._instanceColorWarned||(t.Logger.Warn("EXT_mesh_gpu_instancing: Exporting instance colors as RGB, alpha channel of instance color is not exported"),e._instanceColorWarned=!0),R=J(R,E)):R.length===4*E&&(R=J(R,E)),R.length===3*E&&(A.attributes._COLOR_0=e._buildAccessor(R,"VEC3",E,u))}r.extensions=r.extensions||{},r.extensions[Z]=A}s(r)})];case 1:return[2,s.sent()]}})})},e.prototype._buildAccessor=function(e,t,r,n){var s=n.createBufferView(e),o=n.createAccessor(s,t,5126,r);return this._exporter._accessors.push(o),this._exporter._accessors.length-1},e}();Q.RegisterExtension(Z,function(e){return new $(e)});var ee="KHR_draco_mesh_compression";function te(e){return"POSITION"===e?"POSITION":"NORMAL"===e?"NORMAL":e.startsWith("COLOR")?"COLOR":e.startsWith("TEXCOORD")?"TEX_COORD":"GENERIC"}var re=function(){function e(e){this.name=ee,this.required=!0,this._bufferViewsUsed=new Set,this._accessorsUsed=new Set,this._encodePromises=[],this._wasUsed=!1,this.enabled="Draco"===e.options.meshCompressionMethod&&t.DracoEncoder.DefaultAvailable}return Object.defineProperty(e.prototype,"wasUsed",{get:function(){return this._wasUsed},enumerable:!1,configurable:!0}),e.prototype.dispose=function(){},e.prototype.postExportMeshPrimitive=function(e,r,n){var s=this;if(this.enabled)if(4===e.mode||5===e.mode){var o=[],i=[],a=null;if(void 0!==e.indices){var u=n[e.indices],c=r.getBufferView(u);a=r.getData(c).slice(),o.push(c),i.push(u)}for(var l=[],h=0,f=Object.entries(e.attributes);h<f.length;h++){var p=f[h],d=p[0],x=(u=n[p[1]],c=r.getBufferView(u),C(u.type)),g=t.GetTypedArrayData(r.getData(c),x,u.componentType,u.byteOffset||0,c.byteStride||t.GetTypeByteLength(u.componentType)*x,u.count,!0);l.push({kind:d,dracoName:te(d),size:C(u.type),data:g}),o.push(c),i.push(u)}var _={method:e.targets?"MESH_SEQUENTIAL_ENCODING":"MESH_EDGEBREAKER_ENCODING"},m=t.DracoEncoder.Default._encodeAsync(l,a,_).then(function(t){var n={bufferView:-1,attributes:t.attributeIds},a=r.createBufferView(t.data);r.setBufferView(n,a);for(var u=0,c=o;u<c.length;u++){var l=c[u];s._bufferViewsUsed.add(l)}for(var h=0,f=i;h<f.length;h++){var p=f[h];s._accessorsUsed.add(p)}e.extensions||(e.extensions={}),e.extensions[ee]=n}).catch(function(e){t.Logger.Error("KHR_draco_mesh_compression: Failed to export Draco-encoded primitive. Resulting glTF may be invalid. "+e.message)});this._encodePromises.push(m),this._wasUsed=!0}else t.Logger.Warn("Cannot compress primitive with mode "+e.mode+".")},e.prototype.preGenerateBinaryAsync=function(e){return i(this,void 0,void 0,function(){var t=this;return a(this,function(r){switch(r.label){case 0:return this.enabled?[4,Promise.all(this._encodePromises)]:[2];case 1:return r.sent(),this._bufferViewsUsed.forEach(function(r){e.getPropertiesWithBufferView(r).every(function(e){return t._accessorsUsed.has(e)})&&e.removeBufferView(r)}),this._bufferViewsUsed.clear(),this._accessorsUsed.clear(),[2]}})})},e}();Q.RegisterExtension(ee,function(e){return new re(e)});var ne="KHR_lights_punctual",se={name:"",color:[1,1,1],intensity:1,range:Number.MAX_VALUE},oe={innerConeAngle:0,outerConeAngle:Math.PI/4},ie=t.Vector3.Backward(),ae=function(){function e(e){this.name=ne,this.enabled=!0,this.required=!1,this._exporter=e}return e.prototype.dispose=function(){this._lights=null},Object.defineProperty(e.prototype,"wasUsed",{get:function(){return!!this._lights},enumerable:!1,configurable:!0}),e.prototype.onExporting=function(){this._exporter._glTF.extensions[ne]=this._lights},e.prototype.postExportNodeAsync=function(e,r,n,s,o){return i(this,void 0,void 0,function(){var i=this;return a(this,function(a){switch(a.label){case 0:return[4,new Promise(function(a){if(n instanceof t.Light){var u=n.getTypeID()==t.Light.LIGHTTYPEID_POINTLIGHT?"point":n.getTypeID()==t.Light.LIGHTTYPEID_DIRECTIONALLIGHT?"directional":n.getTypeID()==t.Light.LIGHTTYPEID_SPOTLIGHT?"spot":null;if(!(u&&n instanceof t.ShadowLight))return t.Logger.Warn("".concat(e,": Light ").concat(n.name," is not supported in ").concat(ne)),void a(r);if(n.falloffType!==t.Light.FALLOFF_GLTF&&t.Logger.Warn("".concat(e,": Light falloff for ").concat(n.name," does not match the ").concat(ne," specification!")),!n.position.equalsToFloats(0,0,0)){var c=t.TmpVectors.Vector3[0].copyFrom(n.position);o&&F(c),r.translation=c.asArray()}if("point"!==u){var l=n.direction.normalizeToRef(t.TmpVectors.Vector3[0]);o&&F(l);var h=t.Quaternion.FromUnitVectorsToRef(ie,l,t.TmpVectors.Quaternion[0]);t.Quaternion.IsIdentity(h)||(r.rotation=h.asArray())}var f={type:u,name:n.name,color:n.diffuse.asArray(),intensity:n.intensity,range:n.range};if(W(f,se),"spot"===u){var p=n;f.spot={innerConeAngle:p.innerAngle/2,outerConeAngle:p.angle/2},W(f.spot,oe)}i._lights||(i._lights={lights:[]}),i._lights.lights.push(f);var d={light:i._lights.lights.length-1},x=n.parent;if(x&&P(n,x)){var g=s.get(x);if(g){var _=i._exporter._nodes[g];return U(r,_),_.extensions||(_.extensions={}),_.extensions[ne]=d,void a(null)}}r.extensions||(r.extensions={}),r.extensions[ne]=d,a(r)}else a(r)})];case 1:return[2,a.sent()]}})})},e}();Q.RegisterExtension(ne,function(e){return new ae(e)});var ue="EXT_lights_area",ce={name:"",color:[1,1,1],intensity:1,size:1},le={aspect:1},he=t.Vector3.Backward(),fe=function(){function e(e){this.name=ue,this.enabled=!0,this.required=!1,this._exporter=e}return e.prototype.dispose=function(){this._lights=null},Object.defineProperty(e.prototype,"wasUsed",{get:function(){return!!this._lights},enumerable:!1,configurable:!0}),e.prototype.onExporting=function(){this._exporter._glTF.extensions[ue]=this._lights},e.prototype.postExportNodeAsync=function(e,r,n,s,o){return i(this,void 0,void 0,function(){var i=this;return a(this,function(a){switch(a.label){case 0:return[4,new Promise(function(a){if(n instanceof t.Light){var u=n.getTypeID()==t.Light.LIGHTTYPEID_RECT_AREALIGHT?"rect":null;if(!u)return t.Logger.Warn("".concat(e,": Light ").concat(n.name," is not supported in ").concat(ue)),void a(r);var c=n;if(c.falloffType!==t.Light.FALLOFF_GLTF&&t.Logger.Warn("".concat(e,": Light falloff for ").concat(n.name," does not match the ").concat(ue," specification!")),!c.position.equalsToFloats(0,0,0)){var l=t.TmpVectors.Vector3[0].copyFrom(c.position);o&&F(l),r.translation=l.asArray()}var h=t.Vector3.Forward();o&&F(h);var f=t.Quaternion.FromUnitVectorsToRef(he,h,t.TmpVectors.Quaternion[0]);t.Quaternion.IsIdentity(f)||(r.rotation=f.asArray());var p={type:u,name:c.name,color:c.diffuse.asArray(),intensity:c.intensity,size:c.height,rect:{aspect:c.width/c.height}};W(p,ce),p.rect&&W(p.rect,le),i._lights||(i._lights={lights:[]}),i._lights.lights.push(p);var d={light:i._lights.lights.length-1},x=n.parent;if(x&&P(c,x)){var g=s.get(x);if(g){var _=i._exporter._nodes[g];return U(r,_),_.extensions||(_.extensions={}),_.extensions[ue]=d,void a(null)}}r.extensions||(r.extensions={}),r.extensions[ue]=d,a(r)}else a(r)})];case 1:return[2,a.sent()]}})})},e}();Q.RegisterExtension(ue,function(e){return new fe(e)});var pe="KHR_materials_anisotropy";function de(e){return i(this,void 0,void 0,function(){var r,n,s;return a(this,function(o){switch(o.label){case 0:return r=e.getScene(),n=e.specularRoughnessAnisotropyTexture,s=e.geometryTangentTexture,n||s?[4,t.MergeTexturesAsync("AnisotropyTexture",t.CreateRGBAConfiguration(s?t.CreateTextureInput(s,0):t.CreateConstantInput(1),s?t.CreateTextureInput(s,1):t.CreateConstantInput(0),n?t.CreateTextureInput(n,0):t.CreateConstantInput(1)),r)]:[2,null];case 1:return[2,o.sent()]}})})}var xe=function(){function e(e){this.name=pe,this.enabled=!0,this.required=!1,this._wasUsed=!1,this._anisoTexturesMap={},this._exporter=e}return e.prototype.dispose=function(){},Object.defineProperty(e.prototype,"wasUsed",{get:function(){return this._wasUsed},enumerable:!1,configurable:!0}),e.prototype.postExportMaterialAdditionalTexturesAsync=function(e,r,n){return i(this,void 0,void 0,function(){var e,r,s;return a(this,function(o){switch(o.label){case 0:return e=[],n instanceof t.PBRBaseMaterial?n.anisotropy.isEnabled&&!n.anisotropy.legacy?(n.anisotropy.texture&&e.push(n.anisotropy.texture),[2,e]):[3,5]:[3,1];case 1:return n instanceof t.OpenPBRMaterial&&n.specularRoughnessAnisotropy>0?(r=function(e){var t=e.specularRoughnessAnisotropyTexture,r=e.geometryTangentTexture,n=t&&t.getInternalTexture()?t.getInternalTexture().uniqueId:"NoStrength",s=r&&r.getInternalTexture()?r.getInternalTexture().uniqueId:"NoTangent";return"".concat(n,"_").concat(s)}(n),this._anisoTexturesMap[r]?(e.push(this._anisoTexturesMap[r]),[3,4]):[3,2]):[3,5];case 2:return[4,de(n)];case 3:(s=o.sent())&&(e.push(s),this._anisoTexturesMap[r]=s),o.label=4;case 4:return[2,e];case 5:return[2,[]]}})})},e.prototype.postExportMaterialAsync=function(e,r,n){var s=this;return new Promise(function(e){var o,i,a,u,c,l;if(n instanceof t.PBRBaseMaterial){if(!n.anisotropy.isEnabled||n.anisotropy.legacy)return void e(r);s._wasUsed=!0,r.extensions=r.extensions||{};var h=s._exporter._materialExporter.getTextureInfo(n.anisotropy.texture);null!==(T={anisotropyStrength:n.anisotropy.intensity,anisotropyRotation:n.anisotropy.angle,anisotropyTexture:null!=h?h:void 0}).anisotropyTexture&&s._exporter._materialNeedsUVsSet.add(n),r.extensions[pe]=T}else if(n instanceof t.OpenPBRMaterial&&n.specularRoughnessAnisotropy>0){s._wasUsed=!0,r.extensions=r.extensions||{};var f=n.specularRoughnessTexture;n._useRoughnessFromMetallicTextureGreen&&(f=n.baseMetalnessTexture);var p=s._anisoTexturesMap[n.id];if(!f&&!p){var d=n.specularRoughness,x=n.specularRoughnessAnisotropy;if(!n._useGltfStyleAnisotropy){var g=(i=n.specularRoughness,l=(1-(a=n.specularRoughnessAnisotropy))*(c=(u=i*i)*Math.sqrt(2/(1+(1-a)*(1-a)))),{newBaseRoughness:Math.sqrt(l),newAnisotropyStrength:Math.min(Math.sqrt((c-u)/Math.max(1-u,1e-4)),1)});d=g.newBaseRoughness,x=g.newAnisotropyStrength}r.pbrMetallicRoughness&&(r.pbrMetallicRoughness.roughnessFactor=d);var _={anisotropyStrength:x,anisotropyRotation:n.geometryTangentAngle+.5*Math.PI,anisotropyTexture:void 0};return r.extensions[pe]=_,e(r)}var m=p?s._exporter._materialExporter.getTextureInfo(p):null,T={anisotropyStrength:n.specularRoughnessAnisotropy,anisotropyRotation:n.geometryTangentAngle,anisotropyTexture:m||void 0,extensions:{}};n._useGltfStyleAnisotropy||(r.extensions.KHR_materials_openpbr={},(o=s._exporter._glTF).extensionsUsed||(o.extensionsUsed=[]),-1===s._exporter._glTF.extensionsUsed.indexOf("KHR_materials_openpbr")&&s._exporter._glTF.extensionsUsed.push("KHR_materials_openpbr")),s._exporter._materialNeedsUVsSet.add(n),r.extensions[pe]=T}e(r)})},e}();Q.RegisterExtension(pe,function(e){return new xe(e)});var ge="KHR_materials_clearcoat";function _e(e){return i(this,void 0,void 0,function(){var r,n,s;return a(this,function(o){switch(o.label){case 0:return r=e.getScene(),n=e.coatWeightTexture,s=e.coatRoughnessTexture,n||s?[4,t.MergeTexturesAsync("CoatTexture",t.CreateRGBAConfiguration(n?t.CreateTextureInput(n,0):t.CreateConstantInput(1),s?t.CreateTextureInput(s,e._useCoatRoughnessFromGreenChannel?1:0):t.CreateConstantInput(1)),r)]:[2,null];case 1:return[2,o.sent().getInternalTexture()]}})})}function me(e,r){var n=new t.Texture(r.name,r.getScene());return n._texture=e,n.coordinatesIndex=r.coordinatesIndex,r instanceof t.Texture&&(n.uOffset=r.uOffset,n.vOffset=r.vOffset,n.uScale=r.uScale,n.vScale=r.vScale,n.wAng=r.wAng),n.wrapU=r.wrapU,n.wrapV=r.wrapV,n}var Te=function(){function e(e){this.name=ge,this.enabled=!0,this.required=!1,this._wasUsed=!1,this._mergedTexturesMap={},this._cachedInternalTexturesMap={},this._exporter=e}return e.prototype.dispose=function(){for(var e=0,t=Object.keys(this._mergedTexturesMap);e<t.length;e++){var r=t[e];this._mergedTexturesMap[r].dispose()}this._mergedTexturesMap={};for(var n=0,s=Object.keys(this._cachedInternalTexturesMap);n<s.length;n++)r=s[n],this._cachedInternalTexturesMap[r].dispose();this._cachedInternalTexturesMap={}},Object.defineProperty(e.prototype,"wasUsed",{get:function(){return this._wasUsed},enumerable:!1,configurable:!0}),e.prototype.postExportMaterialAdditionalTexturesAsync=function(e,r,n){return i(this,void 0,void 0,function(){var e,r,s,o;return a(this,function(i){switch(i.label){case 0:return e=[],n instanceof t.PBRBaseMaterial?n.clearCoat.isEnabled?(n.clearCoat.texture&&e.push(n.clearCoat.texture),!n.clearCoat.useRoughnessFromMainTexture&&n.clearCoat.textureRoughness&&e.push(n.clearCoat.textureRoughness),n.clearCoat.bumpTexture&&e.push(n.clearCoat.bumpTexture),[2,e]):[3,5]:[3,1];case 1:return n instanceof t.OpenPBRMaterial&&n.coatWeight>0?(r=!1,n.coatWeightTexture?n.coatRoughnessTexture?n._useCoatRoughnessFromGreenChannel&&n.coatWeightTexture.getInternalTexture()===n.coatRoughnessTexture.getInternalTexture()?(e.push(n.coatWeightTexture),e.push(n.coatRoughnessTexture)):r=!0:e.push(n.coatWeightTexture):n.coatRoughnessTexture&&(n._useCoatRoughnessFromGreenChannel?e.push(n.coatRoughnessTexture):r=!0),r?(s=function(e){var t=e.coatWeightTexture,r=t&&t.getInternalTexture()?t.getInternalTexture().uniqueId:"NoCoat",n=e.coatRoughnessTexture,s=n&&n.getInternalTexture()?n.getInternalTexture().uniqueId:"NoRoughness";return"".concat(r,"_").concat(s)}(n),this._cachedInternalTexturesMap[s]?[3,3]:[4,_e(n)]):[3,4]):[3,5];case 2:(o=i.sent())&&(this._cachedInternalTexturesMap[s]=o),i.label=3;case 3:this._cachedInternalTexturesMap[s]&&(n.coatWeightTexture&&(this._mergedTexturesMap[n.coatWeightTexture.uniqueId]=me(this._cachedInternalTexturesMap[s],n.coatWeightTexture),e.push(this._mergedTexturesMap[n.coatWeightTexture.uniqueId])),n.coatRoughnessTexture&&(this._mergedTexturesMap[n.coatRoughnessTexture.uniqueId]=me(this._cachedInternalTexturesMap[s],n.coatRoughnessTexture),e.push(this._mergedTexturesMap[n.coatRoughnessTexture.uniqueId]))),i.label=4;case 4:return n.geometryCoatNormalTexture&&e.push(n.geometryCoatNormalTexture),[2,e];case 5:return[2,[]]}})})},e.prototype.postExportMaterialAsync=function(e,r,n){var s=this;return new Promise(function(e){if(n instanceof t.PBRBaseMaterial){if(!n.clearCoat.isEnabled)return void e(r);s._wasUsed=!0,r.extensions=r.extensions||{};var o,i=s._exporter._materialExporter.getTextureInfo(n.clearCoat.texture);o=n.clearCoat.useRoughnessFromMainTexture?s._exporter._materialExporter.getTextureInfo(n.clearCoat.texture):s._exporter._materialExporter.getTextureInfo(n.clearCoat.textureRoughness),n.clearCoat.isTintEnabled&&t.Tools.Warn("Clear Color tint is not supported for glTF export. Ignoring for: ".concat(n.name)),n.clearCoat.remapF0OnInterfaceChange&&t.Tools.Warn("Clear Color F0 remapping is not supported for glTF export. Ignoring for: ".concat(n.name));var a=s._exporter._materialExporter.getTextureInfo(n.clearCoat.bumpTexture);null===(l={clearcoatFactor:n.clearCoat.intensity,clearcoatTexture:null!=i?i:void 0,clearcoatRoughnessFactor:n.clearCoat.roughness,clearcoatRoughnessTexture:null!=o?o:void 0,clearcoatNormalTexture:null!=a?a:void 0}).clearcoatTexture&&null===l.clearcoatRoughnessTexture&&null===l.clearcoatRoughnessTexture||s._exporter._materialNeedsUVsSet.add(n),r.extensions[ge]=l}else if(n instanceof t.OpenPBRMaterial){if(0==n.coatWeight)return void e(r);s._wasUsed=!0,r.extensions=r.extensions||{};var u=void 0,c=void 0;n.coatWeightTexture&&(u=s._mergedTexturesMap[n.coatWeightTexture.uniqueId],c=s._exporter._materialExporter.getTextureInfo(u));var l,h=void 0,f=void 0;n.coatRoughnessTexture&&(h=s._mergedTexturesMap[n.coatRoughnessTexture.uniqueId],f=s._exporter._materialExporter.getTextureInfo(h)),n.coatColorTexture&&t.Tools.Warn("Clear Color tint is not supported for glTF export. Ignoring for: ".concat(n.name)),a=s._exporter._materialExporter.getTextureInfo(n.geometryCoatNormalTexture),null===(l={clearcoatFactor:n.coatWeight,clearcoatTexture:null!=c?c:void 0,clearcoatRoughnessFactor:n.coatRoughness,clearcoatRoughnessTexture:null!=f?f:void 0,clearcoatNormalTexture:null!=a?a:void 0}).clearcoatTexture&&null===l.clearcoatRoughnessTexture&&null===l.clearcoatRoughnessTexture||s._exporter._materialNeedsUVsSet.add(n),r.extensions[ge]=l}e(r)})},e}();Q.RegisterExtension(ge,function(e){return new Te(e)});var ye="KHR_materials_coat";function ve(e){var t=e.coatRoughnessAnisotropyTexture,r=e.geometryCoatTangentTexture,n=t&&t.getInternalTexture()?t.getInternalTexture().uniqueId:"NoStrength",s=r&&r.getInternalTexture()?r.getInternalTexture().uniqueId:"NoTangent";return"".concat(n,"_").concat(s)}function be(e){return i(this,void 0,void 0,function(){var r,n,s;return a(this,function(o){switch(o.label){case 0:return r=e.getScene(),n=e.coatRoughnessAnisotropyTexture,s=e.geometryCoatTangentTexture,n||s?[4,t.MergeTexturesAsync("AnisotropyTexture",t.CreateRGBAConfiguration(s?t.CreateTextureInput(s,0):t.CreateConstantInput(1),s?t.CreateTextureInput(s,1):t.CreateConstantInput(0),n?t.CreateTextureInput(n,0):t.CreateConstantInput(1)),r)]:[2,null];case 1:return[2,o.sent()]}})})}function Me(e){return i(this,void 0,void 0,function(){var r,n,s;return a(this,function(o){switch(o.label){case 0:return r=e.getScene(),n=e.coatWeightTexture,s=e.coatRoughnessTexture,n||s?[4,t.MergeTexturesAsync("CoatTexture",t.CreateRGBAConfiguration(n?t.CreateTextureInput(n,0):t.CreateConstantInput(1),s?t.CreateTextureInput(s,e._useCoatRoughnessFromGreenChannel?1:0):t.CreateConstantInput(1)),r)]:[2,null];case 1:return[2,o.sent().getInternalTexture()]}})})}function we(e,r){var n=new t.Texture(r.name,r.getScene());return n._texture=e,n.coordinatesIndex=r.coordinatesIndex,r instanceof t.Texture&&(n.uOffset=r.uOffset,n.vOffset=r.vOffset,n.uScale=r.uScale,n.vScale=r.vScale,n.wAng=r.wAng),n.wrapU=r.wrapU,n.wrapV=r.wrapV,n}var Ae=function(){function e(e){this.name=ye,this.enabled=!0,this.required=!1,this._wasUsed=!1,this._mergedTexturesMap={},this._cachedInternalTexturesMap={},this._exporter=e}return e.prototype.dispose=function(){for(var e=0,t=Object.keys(this._mergedTexturesMap);e<t.length;e++){var r=t[e];this._mergedTexturesMap[r].dispose()}this._mergedTexturesMap={};for(var n=0,s=Object.keys(this._cachedInternalTexturesMap);n<s.length;n++)r=s[n],this._cachedInternalTexturesMap[r].dispose();this._cachedInternalTexturesMap={}},Object.defineProperty(e.prototype,"wasUsed",{get:function(){return this._wasUsed},enumerable:!1,configurable:!0}),e.prototype.postExportMaterialAdditionalTexturesAsync=function(e,r,n){return i(this,void 0,void 0,function(){var e,r,s,o,i;return a(this,function(a){switch(a.label){case 0:return e=[],n instanceof t.PBRBaseMaterial?n.clearCoat.isEnabled?(n.clearCoat.texture&&e.push(n.clearCoat.texture),!n.clearCoat.useRoughnessFromMainTexture&&n.clearCoat.textureRoughness&&e.push(n.clearCoat.textureRoughness),n.clearCoat.bumpTexture&&e.push(n.clearCoat.bumpTexture),n.clearCoat.tintTexture&&e.push(n.clearCoat.tintTexture),[2,e]):[3,9]:[3,1];case 1:return n instanceof t.OpenPBRMaterial&&n.coatWeight>0?(r=!1,n.coatWeightTexture?n.coatRoughnessTexture?n._useCoatRoughnessFromGreenChannel&&n.coatWeightTexture.getInternalTexture()===n.coatRoughnessTexture.getInternalTexture()?(e.push(n.coatWeightTexture),e.push(n.coatRoughnessTexture)):r=!0:e.push(n.coatWeightTexture):n.coatRoughnessTexture&&(n._useCoatRoughnessFromGreenChannel?e.push(n.coatRoughnessTexture):r=!0),r?(o=function(e){var t=e.coatWeightTexture,r=t&&t.getInternalTexture()?t.getInternalTexture().uniqueId:"NoCoat",n=e.coatRoughnessTexture,s=n&&n.getInternalTexture()?n.getInternalTexture().uniqueId:"NoRoughness";return"".concat(r,"_").concat(s)}(n),this._cachedInternalTexturesMap[o]?[3,3]:[4,Me(n)]):[3,4]):[3,9];case 2:(s=a.sent())&&(this._cachedInternalTexturesMap[o]=s),a.label=3;case 3:this._cachedInternalTexturesMap[o]&&(n.coatWeightTexture&&(this._mergedTexturesMap[n.coatWeightTexture.uniqueId]=we(this._cachedInternalTexturesMap[o],n.coatWeightTexture),e.push(this._mergedTexturesMap[n.coatWeightTexture.uniqueId])),n.coatRoughnessTexture&&(this._mergedTexturesMap[n.coatRoughnessTexture.uniqueId]=we(this._cachedInternalTexturesMap[o],n.coatRoughnessTexture),e.push(this._mergedTexturesMap[n.coatRoughnessTexture.uniqueId]))),a.label=4;case 4:return n.geometryCoatNormalTexture&&e.push(n.geometryCoatNormalTexture),n.coatColorTexture&&e.push(n.coatColorTexture),n.coatRoughnessAnisotropy>0?(o=ve(n),this._mergedTexturesMap[o]?(e.push(this._mergedTexturesMap[o]),[3,7]):[3,5]):[3,8];case 5:return[4,be(n)];case 6:(i=a.sent())&&(e.push(i),this._mergedTexturesMap[o]=i),a.label=7;case 7:case 8:return[2,e];case 9:return[2,[]]}})})},e.prototype.postExportMaterialAsync=function(e,r,n){var s=this;return new Promise(function(e){var o,i,a,u,c,l;if(n instanceof t.PBRBaseMaterial){if(!n.clearCoat.isEnabled)return void e(r);s._wasUsed=!0,r.extensions=r.extensions||{};var h,f=s._exporter._materialExporter.getTextureInfo(n.clearCoat.texture);h=n.clearCoat.useRoughnessFromMainTexture?s._exporter._materialExporter.getTextureInfo(n.clearCoat.texture):s._exporter._materialExporter.getTextureInfo(n.clearCoat.textureRoughness);var p=void 0;n.clearCoat.isTintEnabled&&(p=s._exporter._materialExporter.getTextureInfo(n.clearCoat.tintTexture));var d=s._exporter._materialExporter.getTextureInfo(n.clearCoat.bumpTexture),x=n.clearCoat.indexOfRefraction;null===(T={coatFactor:n.clearCoat.intensity,coatTexture:null!=f?f:void 0,coatRoughnessFactor:n.clearCoat.roughness,coatRoughnessTexture:null!=h?h:void 0,coatNormalTexture:null!=d?d:void 0,coatColorFactor:n.clearCoat.tintColor.asArray(),coatColorTexture:null!=p?p:void 0,coatIor:1.5!==x?x:void 0}).coatTexture&&null===T.coatRoughnessTexture&&null===T.coatRoughnessTexture&&null===T.coatColorTexture||s._exporter._materialNeedsUVsSet.add(n),r.extensions[ye]=T}else if(n instanceof t.OpenPBRMaterial){if(0==n.coatWeight)return void e(r);s._wasUsed=!0,r.extensions=r.extensions||{};var g=void 0;f=void 0,n.coatWeightTexture&&(g=s._mergedTexturesMap[n.coatWeightTexture.uniqueId]?s._mergedTexturesMap[n.coatWeightTexture.uniqueId]:n.coatWeightTexture,f=s._exporter._materialExporter.getTextureInfo(g));var _=void 0,m=void 0;n.coatRoughnessTexture&&(_=s._mergedTexturesMap[n.coatRoughnessTexture.uniqueId]?s._mergedTexturesMap[n.coatRoughnessTexture.uniqueId]:n.coatRoughnessTexture,m=s._exporter._materialExporter.getTextureInfo(_)),d=s._exporter._materialExporter.getTextureInfo(n.geometryCoatNormalTexture),p=s._exporter._materialExporter.getTextureInfo(n.coatColorTexture),x=n.coatIor;var T,y=n.coatDarkening,v=n.coatRoughnessTexture,b=ve(n),M=s._mergedTexturesMap[b],w=0,A=0,R=void 0;if(n.coatRoughnessAnisotropy>0){if(v||M){var E=M?s._exporter._materialExporter.getTextureInfo(M):null;w=n.coatRoughnessAnisotropy,A=n.geometryCoatTangentAngle,R=E||void 0}else{var C=n.coatRoughness,I=n.coatRoughnessAnisotropy;if(!n._useGltfStyleAnisotropy){var V=(i=n.coatRoughness,l=(1-(a=n.coatRoughnessAnisotropy))*(c=(u=i*i)*Math.sqrt(2/(1+(1-a)*(1-a)))),{newBaseRoughness:Math.sqrt(l),newAnisotropyStrength:Math.min(Math.sqrt((c-u)/Math.max(1-u,1e-4)),1)});C=V.newBaseRoughness,I=V.newAnisotropyStrength}r.pbrMetallicRoughness&&(r.pbrMetallicRoughness.roughnessFactor=C),w=I,A=n.geometryCoatTangentAngle+.5*Math.PI,R=void 0}n._useGltfStyleAnisotropy||(r.extensions.KHR_materials_openpbr={},(o=s._exporter._glTF).extensionsUsed||(o.extensionsUsed=[]),-1===s._exporter._glTF.extensionsUsed.indexOf("KHR_materials_openpbr")&&s._exporter._glTF.extensionsUsed.push("KHR_materials_openpbr"))}null===(T={coatFactor:n.coatWeight,coatTexture:null!=f?f:void 0,coatRoughnessFactor:n.coatRoughness,coatRoughnessTexture:null!=m?m:void 0,coatNormalTexture:null!=d?d:void 0,coatColorFactor:n.coatColor.asArray(),coatColorTexture:null!=p?p:void 0,coatIor:1.5!==x?x:void 0,coatDarkeningFactor:1!==y?y:void 0,coatAnisotropyRotation:A,coatAnisotropyStrength:w,coatAnisotropyTexture:R}).coatTexture&&null===T.coatRoughnessTexture&&null===T.coatRoughnessTexture&&null===T.coatAnisotropyTexture&&null===T.coatColorTexture||s._exporter._materialNeedsUVsSet.add(n),r.extensions[ye]=T}e(r)})},e}();Q.RegisterExtension(ye,function(e){return new Ae(e)});var Re="KHR_materials_diffuse_transmission";function Ee(e,r){var n=r.subSurface,s=null;return n.translucencyIntensityTexture?s=n.translucencyIntensityTexture:n.thicknessTexture&&n.useMaskFromThicknessTexture&&(s=n.thicknessTexture),s&&!n.useGltfStyleTextures?(t.Logger.Warn("".concat(e,": Translucency intensity texture is not supported when useGltfStyleTextures = false. Ignoring for: ").concat(r.name),1),null):s}var Ce=function(){function e(e){this.name=Re,this.enabled=!0,this.required=!1,this._wasUsed=!1,this._exporter=e}return e.prototype.dispose=function(){},Object.defineProperty(e.prototype,"wasUsed",{get:function(){return this._wasUsed},enumerable:!1,configurable:!0}),e.prototype.postExportMaterialAdditionalTexturesAsync=function(e,r,n){return i(this,void 0,void 0,function(){var r,s;return a(this,function(o){return r=[],n instanceof t.PBRMaterial&&this._isExtensionEnabled(n)?((s=Ee(e,n))&&r.push(s),n.subSurface.translucencyColorTexture&&r.push(n.subSurface.translucencyColorTexture),[2,r]):[2,r]})})},e.prototype._isExtensionEnabled=function(e){if(e.unlit)return!1;var t=e.subSurface;return!!t.isTranslucencyEnabled&&!e.unlit&&!t.useAlbedoToTintTranslucency&&t.useGltfStyleTextures&&1===t.volumeIndexOfRefraction&&0===t.minimumThickness&&0===t.maximumThickness},e.prototype.postExportMaterialAsync=function(e,r,n){var s=this;return new Promise(function(o){var i,a;if(n instanceof t.PBRMaterial&&s._isExtensionEnabled(n)){s._wasUsed=!0;var u=n.subSurface,c=Ee(e,n),l=0==u.translucencyIntensity?void 0:u.translucencyIntensity,h=null!==(i=s._exporter._materialExporter.getTextureInfo(c))&&void 0!==i?i:void 0,f=!u.translucencyColor||u.translucencyColor.equalsFloats(1,1,1)?void 0:u.translucencyColor.asArray(),p=null!==(a=s._exporter._materialExporter.getTextureInfo(u.translucencyColorTexture))&&void 0!==a?a:void 0,d={diffuseTransmissionFactor:l,diffuseTransmissionTexture:h,diffuseTransmissionColorFactor:f,diffuseTransmissionColorTexture:p};(h||p)&&s._exporter._materialNeedsUVsSet.add(n),r.extensions=r.extensions||{},r.extensions[Re]=d}o(r)})},e}();Q.RegisterExtension(Re,function(e){return new Ce(e)});var Ie="KHR_materials_dispersion",Ve=function(){function e(){this.name=Ie,this.enabled=!0,this.required=!1,this._wasUsed=!1}return e.prototype.dispose=function(){},Object.defineProperty(e.prototype,"wasUsed",{get:function(){return this._wasUsed},enumerable:!1,configurable:!0}),e.prototype._isExtensionEnabled=function(e){if(e.unlit)return!1;var t=e.subSurface;return!(!t.isRefractionEnabled&&!t.isDispersionEnabled)},e.prototype.postExportMaterialAsync=function(e,r,n){var s=this;return new Promise(function(e){if(n instanceof t.PBRMaterial&&s._isExtensionEnabled(n)){s._wasUsed=!0;var o={dispersion:n.subSurface.dispersion};r.extensions=r.extensions||{},r.extensions[Ie]=o}e(r)})},e}();Q.RegisterExtension(Ie,function(){return new Ve});var Se="KHR_materials_emissive_strength",Fe=function(){function e(){this.name=Se,this.enabled=!0,this.required=!1,this._wasUsed=!1}return e.prototype.dispose=function(){},Object.defineProperty(e.prototype,"wasUsed",{get:function(){return this._wasUsed},enumerable:!1,configurable:!0}),e.prototype.postExportMaterialAsync=function(e,r,n){return i(this,void 0,void 0,function(){var e=this;return a(this,function(s){switch(s.label){case 0:return[4,new Promise(function(s){if(!(n instanceof t.PBRMaterial))return s(r);var o=n.emissiveColor.scale(n.emissiveIntensity),i=Math.max.apply(Math,o.asArray());if(i>1){r.emissiveFactor=o.scale(1/i).asArray(),e._wasUsed=!0;var a={emissiveStrength:i};r.extensions||(r.extensions={}),r.extensions[Se]=a}else r.emissiveFactor=o.asArray();return s(r)})];case 1:return[2,s.sent()]}})})},e}();Q.RegisterExtension(Se,function(){return new Fe});var Be="KHR_materials_ior",Ne=function(){function e(){this.name=Be,this.enabled=!0,this.required=!1,this._wasUsed=!1}return e.prototype.dispose=function(){},Object.defineProperty(e.prototype,"wasUsed",{get:function(){return this._wasUsed},enumerable:!1,configurable:!0}),e.prototype._isExtensionEnabled=function(e){return!e.unlit&&(e instanceof t.OpenPBRMaterial?1.5!=e.specularIor:e instanceof t.PBRMaterial&&null!=e.indexOfRefraction&&1.5!=e.indexOfRefraction)},e.prototype.postExportMaterialAsync=function(e,r,n){var s=this;return new Promise(function(e){if(n instanceof t.PBRMaterial&&s._isExtensionEnabled(n)){s._wasUsed=!0;var o={ior:n.indexOfRefraction};r.extensions=r.extensions||{},r.extensions[Be]=o}else n instanceof t.OpenPBRMaterial&&s._isExtensionEnabled(n)&&(s._wasUsed=!0,o={ior:n.specularIor},r.extensions=r.extensions||{},r.extensions[Be]=o);e(r)})},e}();Q.RegisterExtension(Be,function(e){return new Ne});var Oe="KHR_materials_iridescence",Ue=function(){function e(e){this.name=Oe,this.enabled=!0,this.required=!1,this._wasUsed=!1,this._exporter=e}return e.prototype.dispose=function(){},Object.defineProperty(e.prototype,"wasUsed",{get:function(){return this._wasUsed},enumerable:!1,configurable:!0}),e.prototype.postExportMaterialAdditionalTexturesAsync=function(e,r,n){return i(this,void 0,void 0,function(){var e;return a(this,function(r){if(e=[],n instanceof t.PBRBaseMaterial){if(n.iridescence.isEnabled)return n.iridescence.texture&&e.push(n.iridescence.texture),n.iridescence.thicknessTexture&&n.iridescence.thicknessTexture!==n.iridescence.texture&&e.push(n.iridescence.thicknessTexture),[2,e]}else if(n instanceof t.OpenPBRMaterial&&n.thinFilmWeight>0)return n.thinFilmWeightTexture&&e.push(n.thinFilmWeightTexture),n.thinFilmThicknessTexture&&n.thinFilmThicknessTexture!==n.thinFilmWeightTexture&&e.push(n.thinFilmThicknessTexture),[2,e];return[2,[]]})})},e.prototype.postExportMaterialAsync=function(e,r,n){var s=this;return new Promise(function(e){if(n instanceof t.PBRBaseMaterial){if(!n.iridescence.isEnabled)return void e(r);s._wasUsed=!0,r.extensions=r.extensions||{};var o=s._exporter._materialExporter.getTextureInfo(n.iridescence.texture),i=s._exporter._materialExporter.getTextureInfo(n.iridescence.thicknessTexture);null===(a={iridescenceFactor:n.iridescence.intensity,iridescenceIor:n.iridescence.indexOfRefraction,iridescenceThicknessMinimum:n.iridescence.minimumThickness,iridescenceThicknessMaximum:n.iridescence.maximumThickness,iridescenceTexture:null!=o?o:void 0,iridescenceThicknessTexture:null!=i?i:void 0}).iridescenceTexture&&null===a.iridescenceThicknessTexture||s._exporter._materialNeedsUVsSet.add(n),r.extensions[Oe]=a}else if(n instanceof t.OpenPBRMaterial){if(n.thinFilmWeight<=0)return void e(r);s._wasUsed=!0,r.extensions=r.extensions||{};var a,u=s._exporter._materialExporter.getTextureInfo(n.thinFilmWeightTexture),c=s._exporter._materialExporter.getTextureInfo(n.thinFilmThicknessTexture);null===(a={iridescenceFactor:n.thinFilmWeight,iridescenceIor:n.thinFilmIor,iridescenceThicknessMinimum:1e3*n.thinFilmThicknessMin,iridescenceThicknessMaximum:1e3*n.thinFilmThickness,iridescenceTexture:null!=u?u:void 0,iridescenceThicknessTexture:null!=c?c:void 0}).iridescenceTexture&&null===a.iridescenceThicknessTexture||s._exporter._materialNeedsUVsSet.add(n),r.extensions[Oe]=a}e(r)})},e}();Q.RegisterExtension(Oe,function(e){return new Ue(e)});var Pe="KHR_materials_sheen",We=function(){function e(e){this.name=Pe,this.enabled=!0,this.required=!1,this._wasUsed=!1,this._exporter=e}return e.prototype.dispose=function(){},Object.defineProperty(e.prototype,"wasUsed",{get:function(){return this._wasUsed},enumerable:!1,configurable:!0}),e.prototype.postExportMaterialAdditionalTexturesAsync=function(e,r,n){return i(this,void 0,void 0,function(){return a(this,function(e){return n instanceof t.PBRMaterial&&n.sheen.isEnabled&&n.sheen.texture?[2,[n.sheen.texture]]:[2,[]]})})},e.prototype.postExportMaterialAsync=function(e,r,n){return i(this,void 0,void 0,function(){var e=this;return a(this,function(s){switch(s.label){case 0:return[4,new Promise(function(s){var o,i,a,u;if(n instanceof t.PBRMaterial){if(!n.sheen.isEnabled)return void s(r);e._wasUsed=!0,null==r.extensions&&(r.extensions={});var c={sheenColorFactor:n.sheen.color.asArray(),sheenRoughnessFactor:null!==(o=n.sheen.roughness)&&void 0!==o?o:0};null===c.sheenColorTexture&&null===c.sheenRoughnessTexture||e._exporter._materialNeedsUVsSet.add(n),n.sheen.texture&&(c.sheenColorTexture=null!==(i=e._exporter._materialExporter.getTextureInfo(n.sheen.texture))&&void 0!==i?i:void 0),n.sheen.textureRoughness&&!n.sheen.useRoughnessFromMainTexture?c.sheenRoughnessTexture=null!==(a=e._exporter._materialExporter.getTextureInfo(n.sheen.textureRoughness))&&void 0!==a?a:void 0:n.sheen.texture&&n.sheen.useRoughnessFromMainTexture&&(c.sheenRoughnessTexture=null!==(u=e._exporter._materialExporter.getTextureInfo(n.sheen.texture))&&void 0!==u?u:void 0),r.extensions[Pe]=c}s(r)})];case 1:return[2,s.sent()]}})})},e}();Q.RegisterExtension(Pe,function(e){return new We(e)});var Le="KHR_materials_fuzz";function ze(e){return i(this,void 0,void 0,function(){var r,n,s;return a(this,function(o){switch(o.label){case 0:return r=e.getScene(),n=e.fuzzColorTexture,s=e.fuzzRoughnessTexture,n||s?[4,t.MergeTexturesAsync("FuzzTexture",t.CreateRGBAConfiguration(n?t.CreateTextureInput(n,0):t.CreateConstantInput(1),n?t.CreateTextureInput(n,1):t.CreateConstantInput(1),n?t.CreateTextureInput(n,2):t.CreateConstantInput(1),s?t.CreateTextureInput(s,e._useFuzzRoughnessFromTextureAlpha?3:0):t.CreateConstantInput(1)),r)]:[2,null];case 1:return[2,o.sent().getInternalTexture()]}})})}function Ke(e,r){var n=new t.Texture(r.name,r.getScene());return n._texture=e,n.coordinatesIndex=r.coordinatesIndex,r instanceof t.Texture&&(n.uOffset=r.uOffset,n.vOffset=r.vOffset,n.uScale=r.uScale,n.vScale=r.vScale,n.wAng=r.wAng),n.wrapU=r.wrapU,n.wrapV=r.wrapV,n}var ke=function(){function e(e){this.name=Le,this.enabled=!0,this.required=!1,this._wasUsed=!1,this._mergedTexturesMap={},this._cachedInternalTexturesMap={},this._exporter=e}return e.prototype.dispose=function(){for(var e=0,t=Object.keys(this._mergedTexturesMap);e<t.length;e++){var r=t[e];this._mergedTexturesMap[r].dispose()}this._mergedTexturesMap={};for(var n=0,s=Object.keys(this._cachedInternalTexturesMap);n<s.length;n++)r=s[n],this._cachedInternalTexturesMap[r].dispose();this._cachedInternalTexturesMap={}},Object.defineProperty(e.prototype,"wasUsed",{get:function(){return this._wasUsed},enumerable:!1,configurable:!0}),e.prototype.postExportMaterialAdditionalTexturesAsync=function(e,r,n){return i(this,void 0,void 0,function(){var e,r,s,o;return a(this,function(i){switch(i.label){case 0:return n instanceof t.OpenPBRMaterial?(e=[],n.fuzzWeight>0?(n.fuzzWeightTexture&&e.push(n.fuzzWeightTexture),r=!1,n.fuzzRoughnessTexture&&(n._useFuzzRoughnessFromTextureAlpha?e.push(n.fuzzRoughnessTexture):r=!0),n.fuzzColorTexture&&!r&&e.push(n.fuzzColorTexture),r?(s=function(e){var t=e.fuzzColorTexture,r=t&&t.getInternalTexture()?t.getInternalTexture().uniqueId:"NoFuzzColor",n=e.fuzzRoughnessTexture,s=n&&n.getInternalTexture()?n.getInternalTexture().uniqueId:"NoFuzzRoughness";return"FuzzColor_".concat(r,"_FuzzRoughness_").concat(s)}(n),this._cachedInternalTexturesMap[s]?[3,2]:[4,ze(n)]):[3,3]):[3,3]):[3,4];case 1:(o=i.sent())&&(this._cachedInternalTexturesMap[s]=o),i.label=2;case 2:this._cachedInternalTexturesMap[s]&&(n.fuzzColorTexture&&(this._mergedTexturesMap[n.fuzzColorTexture.uniqueId]=Ke(this._cachedInternalTexturesMap[s],n.fuzzColorTexture),e.push(this._mergedTexturesMap[n.fuzzColorTexture.uniqueId])),n.fuzzRoughnessTexture&&(this._mergedTexturesMap[n.fuzzRoughnessTexture.uniqueId]=Ke(this._cachedInternalTexturesMap[s],n.fuzzRoughnessTexture),e.push(this._mergedTexturesMap[n.fuzzRoughnessTexture.uniqueId]))),i.label=3;case 3:return[2,e];case 4:return[2,[]]}})})},e.prototype.postExportMaterialAsync=function(e,r,n){return i(this,void 0,void 0,function(){var e=this;return a(this,function(s){switch(s.label){case 0:return[4,new Promise(function(s){var o,i,a;if(n instanceof t.OpenPBRMaterial){if(0==n.fuzzWeight)return void s(r);e._wasUsed=!0,null==r.extensions&&(r.extensions={});var u={fuzzFactor:n.fuzzWeight,fuzzColorFactor:n.fuzzColor.asArray(),fuzzRoughnessFactor:n.fuzzRoughness};n.fuzzWeightTexture&&(u.fuzzTexture=null!==(o=e._exporter._materialExporter.getTextureInfo(n.fuzzWeightTexture))&&void 0!==o?o:void 0);var c=void 0;n.fuzzColorTexture&&(c=e._mergedTexturesMap[n.fuzzColorTexture.uniqueId]?e._mergedTexturesMap[n.fuzzColorTexture.uniqueId]:n.fuzzColorTexture,u.fuzzColorTexture=null!==(i=e._exporter._materialExporter.getTextureInfo(c))&&void 0!==i?i:void 0);var l=void 0;n.fuzzRoughnessTexture&&(l=e._mergedTexturesMap[n.fuzzRoughnessTexture.uniqueId]?e._mergedTexturesMap[n.fuzzRoughnessTexture.uniqueId]:n.fuzzRoughnessTexture,u.fuzzRoughnessTexture=null!==(a=e._exporter._materialExporter.getTextureInfo(l))&&void 0!==a?a:void 0),null===u.fuzzColorTexture&&null===u.fuzzRoughnessTexture||e._exporter._materialNeedsUVsSet.add(n),r.extensions[Le]=u}s(r)})];case 1:return[2,s.sent()]}})})},e}();Q.RegisterExtension(Le,function(e){return new ke(e)});var Ge="KHR_materials_specular",De=function(){function e(e){this.name=Ge,this.enabled=!0,this.required=!1,this._wasUsed=!1,this._exporter=e}return e.prototype.dispose=function(){},Object.defineProperty(e.prototype,"wasUsed",{get:function(){return this._wasUsed},enumerable:!1,configurable:!0}),e.prototype.postExportMaterialAdditionalTexturesAsync=function(e,r,n){return i(this,void 0,void 0,function(){var e;return a(this,function(r){return e=[],n instanceof t.PBRMaterial&&this._isExtensionEnabled(n)?(n.metallicReflectanceTexture&&e.push(n.metallicReflectanceTexture),n.reflectanceTexture&&e.push(n.reflectanceTexture),[2,e]):[2,e]})})},e.prototype._isExtensionEnabled=function(e){return!e.unlit&&(null!=e.metallicF0Factor&&1!=e.metallicF0Factor||null!=e.metallicReflectanceColor&&!e.metallicReflectanceColor.equalsFloats(1,1,1)||this._hasTexturesExtension(e))},e.prototype._hasTexturesExtension=function(e){return null!=e.metallicReflectanceTexture||null!=e.reflectanceTexture},e.prototype.postExportMaterialAsync=function(e,r,n){var s=this;return new Promise(function(e){var o,i,a,u,c;if(n instanceof t.PBRMaterial&&s._isExtensionEnabled(n)){s._wasUsed=!0,r.extensions=r.extensions||{};var l=null!==(o=s._exporter._materialExporter.getTextureInfo(n.metallicReflectanceTexture))&&void 0!==o?o:void 0,h=null!==(i=s._exporter._materialExporter.getTextureInfo(n.reflectanceTexture))&&void 0!==i?i:void 0,f={specularFactor:1==n.metallicF0Factor?void 0:n.metallicF0Factor,specularTexture:l,specularColorFactor:n.metallicReflectanceColor.equalsFloats(1,1,1)?void 0:n.metallicReflectanceColor.asArray(),specularColorTexture:h};s._hasTexturesExtension(n)&&s._exporter._materialNeedsUVsSet.add(n),r.extensions[Ge]=f}else if(n instanceof t.OpenPBRMaterial){r.extensions=r.extensions||{};var p=null!==(a=s._exporter._materialExporter.getTextureInfo(n.specularWeightTexture))&&void 0!==a?a:void 0,d=null!==(u=s._exporter._materialExporter.getTextureInfo(n.specularColorTexture))&&void 0!==u?u:void 0,x=1==n.specularWeight?void 0:n.specularWeight,g=n.specularColor.equalsFloats(1,1,1)?void 0:n.specularColor.asArray();if(!d&&!p&&void 0===x&&void 0===g)return e(r);s._wasUsed=!0,(f={specularFactor:x,specularTexture:p,specularColorFactor:g,specularColorTexture:d,extensions:{}}).extensions.EXT_materials_specular_edge_color={specularEdgeColorEnabled:!0},(c=s._exporter._glTF).extensionsUsed||(c.extensionsUsed=[]),-1===s._exporter._glTF.extensionsUsed.indexOf("EXT_materials_specular_edge_color")&&s._exporter._glTF.extensionsUsed.push("EXT_materials_specular_edge_color"),(p||d)&&s._exporter._materialNeedsUVsSet.add(n),r.extensions[Ge]=f}e(r)})},e}();Q.RegisterExtension(Ge,function(e){return new De(e)});var He="KHR_materials_transmission",qe=function(){function e(e){this.name=He,this.enabled=!0,this.required=!1,this._wasUsed=!1,this._exporter=e}return e.prototype.dispose=function(){},Object.defineProperty(e.prototype,"wasUsed",{get:function(){return this._wasUsed},enumerable:!1,configurable:!0}),e.prototype.postExportMaterialAdditionalTexturesAsync=function(e,r,n){return i(this,void 0,void 0,function(){var e;return a(this,function(r){if(e=[],n instanceof t.PBRMaterial){if(this._isExtensionEnabled(n))return n.subSurface.refractionIntensityTexture&&n.subSurface.useGltfStyleTextures&&e.push(n.subSurface.refractionIntensityTexture),[2,e]}else n instanceof t.OpenPBRMaterial&&(n.transmissionWeight>0&&n.transmissionWeightTexture&&(e.push(n.transmissionWeightTexture),n.transmissionColorTexture&&e.push(n.transmissionColorTexture)),n.subsurfaceWeight>0&&n.subsurfaceWeightTexture&&e.push(n.subsurfaceWeightTexture));return[2,e]})})},e.prototype._isExtensionEnabled=function(e){if(e instanceof t.OpenPBRMaterial&&!e.unlit)return e.transmissionWeight>0||e.subsurfaceWeight>0;if(e instanceof t.PBRMaterial&&!e.unlit){var r=e.subSurface;return r.isRefractionEnabled&&null!=r.refractionIntensity&&0!=r.refractionIntensity||null!=r.refractionIntensityTexture&&r.useGltfStyleTextures}return!1},e.prototype.postExportMaterialAsync=function(e,r,n){return i(this,void 0,void 0,function(){var s,o,i,u,c,l,h;return a(this,function(a){return this._isExtensionEnabled(n)?(n instanceof t.PBRMaterial?(this._wasUsed=!0,s=n.subSurface,i=0===s.refractionIntensity?void 0:s.refractionIntensity,u={transmissionFactor:i},s.refractionIntensityTexture&&(s.useGltfStyleTextures?(this._exporter._materialNeedsUVsSet.add(n),(c=this._exporter._materialExporter.getTextureInfo(s.refractionIntensityTexture))&&(u.transmissionTexture=c)):t.Logger.Warn("".concat(e,": Exporting a subsurface refraction intensity texture without `useGltfStyleTextures` is not supported"))),r.extensions||(r.extensions={}),r.extensions[He]=u):n instanceof t.OpenPBRMaterial&&(this._wasUsed=!0,o=(1-n.transmissionWeight)*n.subsurfaceWeight,i=o+n.transmissionWeight,u={transmissionFactor:i},n.transmissionWeightTexture?(this._exporter._materialNeedsUVsSet.add(n),(c=this._exporter._materialExporter.getTextureInfo(n.transmissionWeightTexture))&&(u.transmissionTexture=c)):n.subsurfaceWeightTexture&&(this._exporter._materialNeedsUVsSet.add(n),(l=this._exporter._materialExporter.getTextureInfo(n.subsurfaceWeightTexture))&&(u.transmissionTexture=l)),0!=n.transmissionDepth||n.transmissionColor.equals(t.Color3.White())&&!n.transmissionColorTexture||r.pbrMetallicRoughness&&(r.pbrMetallicRoughness.baseColorFactor||(r.pbrMetallicRoughness.baseColorFactor=[1,1,1,1]),r.pbrMetallicRoughness.baseColorFactor[0]*=n.transmissionColor.r,r.pbrMetallicRoughness.baseColorFactor[1]*=n.transmissionColor.g,r.pbrMetallicRoughness.baseColorFactor[2]*=n.transmissionColor.b,n.transmissionColorTexture&&!r.pbrMetallicRoughness.baseColorTexture&&(h=this._exporter._materialExporter.getTextureInfo(n.transmissionColorTexture))&&(r.pbrMetallicRoughness.baseColorTexture=h,this._exporter._materialNeedsUVsSet.add(n))),r.extensions||(r.extensions={}),r.extensions[He]=u),[2,r]):[2,r]})})},e}();Q.RegisterExtension(He,function(e){return new qe(e)});var je="KHR_materials_unlit",Qe=function(){function e(){this.name=je,this.enabled=!0,this.required=!1,this._wasUsed=!1}return Object.defineProperty(e.prototype,"wasUsed",{get:function(){return this._wasUsed},enumerable:!1,configurable:!0}),e.prototype.dispose=function(){},e.prototype.postExportMaterialAsync=function(e,r,n){var s=this;return new Promise(function(e){var o=!1;n instanceof t.PBRMaterial?o=n.unlit:n instanceof t.StandardMaterial&&(o=n.disableLighting),o&&(s._wasUsed=!0,null==r.extensions&&(r.extensions={}),r.extensions[je]={}),e(r)})},e}();Q.RegisterExtension(je,function(){return new Qe});var Xe="KHR_materials_volume",Ye=function(){function e(e){this.name=Xe,this.enabled=!0,this.required=!1,this._wasUsed=!1,this._exporter=e}return e.prototype.dispose=function(){},Object.defineProperty(e.prototype,"wasUsed",{get:function(){return this._wasUsed},enumerable:!1,configurable:!0}),e.prototype.postExportMaterialAdditionalTexturesAsync=function(e,r,n){return i(this,void 0,void 0,function(){var e;return a(this,function(r){if(e=[],n instanceof t.PBRMaterial){if(this._isExtensionEnabled(n))return n.subSurface.thicknessTexture&&e.push(n.subSurface.thicknessTexture),[2,e]}else n instanceof t.OpenPBRMaterial&&(n.transmissionWeight>0||n.subsurfaceWeight>0)&&n.geometryThicknessTexture&&e.push(n.geometryThicknessTexture);return[2,e]})})},e.prototype._isExtensionEnabled=function(e){if(e.unlit)return!1;var r=e.subSurface;return!(!r.isRefractionEnabled&&!r.isTranslucencyEnabled)&&(null!=r.maximumThickness&&0!=r.maximumThickness||null!=r.tintColorAtDistance&&r.tintColorAtDistance!=Number.POSITIVE_INFINITY||null!=r.tintColor&&r.tintColor!=t.Color3.White()||this._hasTexturesExtension(e))},e.prototype._hasTexturesExtension=function(e){return null!=e.subSurface.thicknessTexture},e.prototype.postExportMaterialAsync=function(e,r,n){var s=this;return new Promise(function(e){var o,i;if(n instanceof t.PBRMaterial&&s._isExtensionEnabled(n)){s._wasUsed=!0;var a=n.subSurface,u={thicknessFactor:f=0==a.maximumThickness?void 0:a.maximumThickness,thicknessTexture:h=null!==(o=s._exporter._materialExporter.getTextureInfo(a.thicknessTexture))&&void 0!==o?o:void 0,attenuationDistance:a.tintColorAtDistance==Number.POSITIVE_INFINITY?void 0:a.tintColorAtDistance,attenuationColor:S=a.tintColor.equalsFloats(1,1,1)?void 0:a.tintColor.asArray()};s._hasTexturesExtension(n)&&s._exporter._materialNeedsUVsSet.add(n),r.extensions=r.extensions||{},r.extensions[Xe]=u}else if(n instanceof t.OpenPBRMaterial){var c=n.transmissionWeight>0&&!n.geometryThinWalled,l=n.subsurfaceWeight>0&&!n.geometryThinWalled;if(c||l){s._wasUsed=!0;var h,f=n.geometryThickness;(h=null!==(i=s._exporter._materialExporter.getTextureInfo(n.geometryThicknessTexture))&&void 0!==i?i:void 0)&&s._exporter._materialNeedsUVsSet.add(n);var p=void 0,d=t.Color3.White().asArray();if(c&&n.transmissionDepth>0){var x=1/n.transmissionDepth,g=new t.Vector3(-Math.log(n.transmissionColor.r)*x,-Math.log(n.transmissionColor.g)*x,-Math.log(n.transmissionColor.b)*x),_=new t.Vector3(n.transmissionScatter.r*x,n.transmissionScatter.g*x,n.transmissionScatter.b*x),m=g.subtract(_),T=Math.min(m.x,m.y,m.z);T<0&&(m.x=m.x-T,m.y=m.y-T,m.z=m.z-T),g=m.add(_),p=1/Math.max(g.x,g.y,g.z),d[0]=Math.exp(-g.x*p),d[1]=Math.exp(-g.y*p),d[2]=Math.exp(-g.z*p)}else p=Number.MAX_VALUE,d[0]=1,d[1]=1,d[2]=1;var y=1,v=t.Color3.White().asArray();if(l){var b=n.subsurfaceRadius,M=n.subsurfaceRadiusScale,w=new t.Vector3(M.r,M.g,M.b).multiplyByFloats(b,b,b),A=new t.Vector3(1/Math.max(w.x,1e-6),1/Math.max(w.y,1e-6),1/Math.max(w.z,1e-6));y=1/Math.max(A.x,A.y,A.z),v[0]=Math.exp(-A.x*y),v[1]=Math.exp(-A.y*y),v[2]=Math.exp(-A.z*y)}var R=(1-n.transmissionWeight)*n.subsurfaceWeight,E=R+n.transmissionWeight,C=1/Math.max(E,1e-6),I=n.transmissionWeight*C,V=R*C,S=d.map(function(e,t){return e*I+v[t]*V});u={thicknessFactor:f,thicknessTexture:h,attenuationDistance:p*I+y*V,attenuationColor:S},r.extensions=r.extensions||{},r.extensions[Xe]=u}}e(r)})},e}();Q.RegisterExtension(Xe,function(e){return new Ye(e)});var Ze="KHR_materials_volume_scatter",Je=function(){function e(e){this.name=Ze,this.enabled=!0,this.required=!1,this._wasUsed=!1,this._exporter=e}return e.prototype.dispose=function(){},Object.defineProperty(e.prototype,"wasUsed",{get:function(){return this._wasUsed},enumerable:!1,configurable:!0}),e.prototype.postExportMaterialAdditionalTexturesAsync=function(e,r,n){return i(this,void 0,void 0,function(){var e;return a(this,function(r){return e=[],n instanceof t.OpenPBRMaterial&&(n.transmissionWeight>0&&n.transmissionScatterTexture&&e.push(n.transmissionScatterTexture),n.subsurfaceWeight>0&&n.subsurfaceColorTexture&&e.push(n.subsurfaceColorTexture)),[2,e]})})},e.prototype._isExtensionEnabled=function(e){if(e.unlit)return!1;var r=e.transmissionWeight>0&&!e.geometryThinWalled&&e.transmissionDepth>0&&!e.transmissionScatter.equals(t.Color3.Black()),n=e.subsurfaceWeight>0&&!e.geometryThinWalled;return!(!r&&!n)},e.prototype.postExportMaterialAsync=function(e,r,n){var s=this;return new Promise(function(e){if(n instanceof t.OpenPBRMaterial&&s._isExtensionEnabled(n)){s._wasUsed=!0;var o=t.Vector3.Zero(),i=0;if(n.transmissionWeight>0)_=new t.Vector3(n.transmissionScatter.r,n.transmissionScatter.g,n.transmissionScatter.b),m=new t.Vector3(Math.sqrt(1-_.x),Math.sqrt(1-_.y),Math.sqrt(1-_.z)),y=(T=new t.Vector3(1,1,1)).subtract(m),v=T.subtract(new t.Vector3(.139,.139,.139).multiplyInPlace(m)),b=T.add(new t.Vector3(1.17,1.17,1.17).multiplyInPlace(m)),o=y.multiplyInPlace(v).divideInPlace(b),i=n.transmissionScatterAnisotropy;var a=t.Vector3.Zero(),u=0;n.subsurfaceWeight>0&&(a.set(n.subsurfaceColor.r,n.subsurfaceColor.g,n.subsurfaceColor.b),u=n.subsurfaceScatterAnisotropy);var c=(1-n.transmissionWeight)*n.subsurfaceWeight,l=c+n.transmissionWeight,h=1/Math.max(l,1e-6),f=n.transmissionWeight*h,p=c*h,d={multiscatterColorFactor:o.multiplyByFloats(f,f,f).addInPlace(a.multiplyByFloats(p,p,p)).asArray(),scatterAnisotropy:i*f+u*p};if(n.subsurfaceWeight>0&&n.subsurfaceColorTexture){s._exporter._materialNeedsUVsSet.add(n);var x=s._exporter._materialExporter.getTextureInfo(n.subsurfaceColorTexture);x&&(d.multiscatterColorTexture=x)}else if(n.transmissionWeight>0&&n.transmissionScatterTexture){s._exporter._materialNeedsUVsSet.add(n);var g=s._exporter._materialExporter.getTextureInfo(n.transmissionScatterTexture);g&&(d.multiscatterColorTexture=g)}r.extensions=r.extensions||{},r.extensions[Ze]=d}var _,m,T,y,v,b;e(r)})},e}();Q.RegisterExtension(Ze,function(e){return new Je(e)},101);var $e="KHR_materials_diffuse_roughness",et=function(){function e(e){this.name=$e,this.enabled=!0,this.required=!1,this._wasUsed=!1,this._exporter=e}return e.prototype.dispose=function(){},Object.defineProperty(e.prototype,"wasUsed",{get:function(){return this._wasUsed},enumerable:!1,configurable:!0}),e.prototype.postExportMaterialAdditionalTexturesAsync=function(e,r,n){return i(this,void 0,void 0,function(){var e;return a(this,function(r){if(e=[],n instanceof t.PBRBaseMaterial){if(n._baseDiffuseRoughness)return n._baseDiffuseRoughnessTexture&&e.push(n._baseDiffuseRoughnessTexture),[2,e]}else if(n instanceof t.OpenPBRMaterial&&n.baseDiffuseRoughness)return n.baseDiffuseRoughnessTexture&&e.push(n.baseDiffuseRoughnessTexture),[2,e];return[2,[]]})})},e.prototype.postExportMaterialAsync=function(e,r,n){var s=this;return new Promise(function(e){var o=null,i=null;if(n instanceof t.PBRBaseMaterial?(o=n._baseDiffuseRoughness,i=n._baseDiffuseRoughnessTexture):n instanceof t.OpenPBRMaterial&&(o=n.baseDiffuseRoughness,i=n.baseDiffuseRoughnessTexture),o){s._wasUsed=!0,r.extensions=r.extensions||{};var a=s._exporter._materialExporter.getTextureInfo(i),u={diffuseRoughnessFactor:o,diffuseRoughnessTexture:null!=a?a:void 0};null!==u.diffuseRoughnessTexture&&s._exporter._materialNeedsUVsSet.add(n),r.extensions[$e]=u,e(r)}else e(r)})},e}();Q.RegisterExtension($e,function(e){return new et(e)});var tt="KHR_materials_openpbr",rt=function(){function e(){this.name=tt,this.enabled=!0,this.required=!1,this._wasUsed=!1}return e.prototype.dispose=function(){},Object.defineProperty(e.prototype,"wasUsed",{get:function(){return this._wasUsed},enumerable:!1,configurable:!0}),e.prototype.postExportMaterialAsync=function(e,r,n){var s=this;return new Promise(function(e){n instanceof t.OpenPBRMaterial&&(s._wasUsed=!0,r.extensions=r.extensions||{},r.extensions[tt]={}),e(r)})},e}();Q.RegisterExtension(tt,function(e){return new rt});var nt="KHR_texture_transform",st=function(){function e(){this.name=nt,this.enabled=!0,this.required=!1,this._wasUsed=!1}return e.prototype.dispose=function(){},Object.defineProperty(e.prototype,"wasUsed",{get:function(){return this._wasUsed},enumerable:!1,configurable:!0}),e.prototype.postExportTexture=function(e,r,n){if(n.getScene()||t.Tools.Warn("".concat(e,': "scene" is not defined for Babylon texture ').concat(n.name,"!")),0===n.uAng&&0===n.vAng||(t.Tools.Warn("".concat(e,": Texture ").concat(n.name," with rotation in the u or v axis is not supported in glTF.")),0===n.uRotationCenter&&0===n.vRotationCenter)){var s={},o=!1;if(0===n.uOffset&&0===n.vOffset||(s.offset=[n.uOffset,n.vOffset],o=!0),1===n.uScale&&1===n.vScale||(s.scale=[n.uScale,n.vScale],o=!0),0!==n.wAng){if(0!==n.uRotationCenter||0!==n.vRotationCenter){if(n.homogeneousRotationInUVTransform&&n.uScale!==n.vScale)return void t.Tools.Warn("".concat(e,": Texture ").concat(n.name," with homogenousRotationInUVTransform, non-uniform scaling, and non-zero rotation cannot be exported with ").concat(nt,"."));t.Tools.Warn("".concat(e,": Texture ").concat(n.name," with non-origin rotation center will be exported using an adjusted offset with ").concat(nt,".")),s.offset=function(e){var t=e.uOffset,r=e.vOffset,n=e.uRotationCenter,s=e.vRotationCenter,o=e.uScale,i=e.vScale,a=e.wAng,u=Math.cos(a),c=Math.sin(a),l=n*o,h=s*i;return[t+(l*(1-u)+h*c),r+(h*(1-u)-l*c)]}(n)}s.rotation=-n.wAng,o=!0}0!==n.coordinatesIndex&&(s.texCoord=n.coordinatesIndex,o=!0),o&&(this._wasUsed=!0,r.extensions||(r.extensions={}),r.extensions[nt]=s)}},e}();Q.RegisterExtension(nt,function(){return new st});var ot="KHR_texture_basisu",it=function(){function e(e){this.name=ot,this.enabled=!0,this.required=!0,this._wasUsed=!1,this._exporter=e}return Object.defineProperty(e.prototype,"wasUsed",{get:function(){return this._wasUsed},enumerable:!1,configurable:!0}),e.prototype.dispose=function(){},e.prototype.postExportTexture=function(e,r){var n=this._exporter._textures[r.index],s=n.source;if(void 0!==s){var o=this._exporter._images[s];"image/ktx2"===(o.mimeType||t.GetMimeType(o.uri))&&(n.source=void 0,n.extensions||(n.extensions={}),n.extensions[ot]={source:s},this._wasUsed=!0)}},e}();Q.RegisterExtension(ot,function(e){return new it(e)});var at="EXT_texture_webp",ut=function(){function e(e){this.name=at,this.enabled=!0,this.required=!0,this._wasUsed=!1,this._exporter=e}return Object.defineProperty(e.prototype,"wasUsed",{get:function(){return this._wasUsed},enumerable:!1,configurable:!0}),e.prototype.dispose=function(){},e.prototype.postExportTexture=function(e,r){var n=this._exporter._textures[r.index],s=n.source;if(void 0!==s){var o=this._exporter._images[s];"image/webp"===(o.mimeType||t.GetMimeType(o.uri))&&(n.source=void 0,n.extensions||(n.extensions={}),n.extensions[at]={source:s},this._wasUsed=!0)}},e}();Q.RegisterExtension(at,function(e){return new ut(e)});var ct="EXT_texture_avif",lt=function(){function e(e){this.name=ct,this.enabled=!0,this.required=!0,this._wasUsed=!1,this._exporter=e}return Object.defineProperty(e.prototype,"wasUsed",{get:function(){return this._wasUsed},enumerable:!1,configurable:!0}),e.prototype.dispose=function(){},e.prototype.postExportTexture=function(e,r){var n=this._exporter._textures[r.index],s=n.source;if(void 0!==s){var o=this._exporter._images[s];"image/avif"===(o.mimeType||t.GetMimeType(o.uri))&&(n.source=void 0,n.extensions||(n.extensions={}),n.extensions[ct]={source:s},this._wasUsed=!0)}},e}();Q.RegisterExtension(ct,function(e){return new lt(e)});var ht={__proto__:null,EXT_lights_area:fe,EXT_mesh_gpu_instancing:$,EXT_texture_avif:lt,EXT_texture_webp:ut,KHR_draco_mesh_compression:re,KHR_lights_punctual:ae,KHR_materials_anisotropy:xe,KHR_materials_clearcoat:Te,KHR_materials_coat:Ae,KHR_materials_diffuse_roughness:et,KHR_materials_diffuse_transmission:Ce,KHR_materials_dispersion:Ve,KHR_materials_emissive_strength:Fe,KHR_materials_fuzz:ke,KHR_materials_ior:Ne,KHR_materials_iridescence:Ue,KHR_materials_openpbr:rt,KHR_materials_sheen:We,KHR_materials_specular:De,KHR_materials_transmission:qe,KHR_materials_unlit:Qe,KHR_materials_volume:Ye,KHR_materials_volume_scatter:Je,KHR_texture_basisu:it,KHR_texture_transform:st},ft={__proto__:null,EXT_lights_area:fe,EXT_mesh_gpu_instancing:$,EXT_texture_avif:lt,EXT_texture_webp:ut,GLTF2Export:X,GLTFData:n,KHR_draco_mesh_compression:re,KHR_lights_punctual:ae,KHR_materials_anisotropy:xe,KHR_materials_clearcoat:Te,KHR_materials_coat:Ae,KHR_materials_diffuse_roughness:et,KHR_materials_diffuse_transmission:Ce,KHR_materials_dispersion:Ve,KHR_materials_emissive_strength:Fe,KHR_materials_fuzz:ke,KHR_materials_ior:Ne,KHR_materials_iridescence:Ue,KHR_materials_openpbr:rt,KHR_materials_sheen:We,KHR_materials_specular:De,KHR_materials_transmission:qe,KHR_materials_unlit:Qe,KHR_materials_volume:Ye,KHR_materials_volume_scatter:Je,KHR_texture_basisu:it,KHR_texture_transform:st,_ConvertToGLTFPBRMetallicRoughness:g,_SolveMetallic:x},pt="undefined"!=typeof global?global:"undefined"!=typeof window?window:void 0;if(void 0!==pt){pt.BABYLON=pt.BABYLON||{};var dt=pt.BABYLON;dt.GLTF2=dt.GLTF2||{},dt.GLTF2.Exporter=dt.GLTF2.Exporter||{},dt.GLTF2.Exporter.Extensions=dt.GLTF2.Exporter.Extensions||{};var xt=[];for(var gt in r)dt[gt]=r[gt],xt.push(gt);for(var gt in s)dt[gt]=s[gt],xt.push(gt);for(var gt in Y)dt[gt]=Y[gt],xt.push(gt);for(var gt in ht)dt.GLTF2.Exporter.Extensions[gt]=ht[gt],xt.push(gt);for(var gt in ft)xt.indexOf(gt)>-1||(dt.GLTF2.Exporter[gt]=ft[gt])}var _t={__proto__:null,EXT_lights_area:fe,EXT_mesh_gpu_instancing:$,EXT_texture_avif:lt,EXT_texture_webp:ut,GLTF2Export:X,GLTFData:n,KHR_draco_mesh_compression:re,KHR_lights_punctual:ae,KHR_materials_anisotropy:xe,KHR_materials_clearcoat:Te,KHR_materials_coat:Ae,KHR_materials_diffuse_roughness:et,KHR_materials_diffuse_transmission:Ce,KHR_materials_dispersion:Ve,KHR_materials_emissive_strength:Fe,KHR_materials_fuzz:ke,KHR_materials_ior:Ne,KHR_materials_iridescence:Ue,KHR_materials_openpbr:rt,KHR_materials_sheen:We,KHR_materials_specular:De,KHR_materials_transmission:qe,KHR_materials_unlit:Qe,KHR_materials_volume:Ye,KHR_materials_volume_scatter:Je,KHR_texture_basisu:it,KHR_texture_transform:st,_ConvertToGLTFPBRMetallicRoughness:g,_SolveMetallic:x,__IGLTFExporterExtension:0};e.default=_t,e.serializers=_t,Object.defineProperty(e,"__esModule",{value:!0})});
|
|
2
|
+
//# sourceMappingURL=babylon.glTF2Serializer.min.js.map
|