babylonjs-serializers 5.3.0 → 5.4.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.js +288 -2
- package/babylon.glTF2Serializer.js.map +1 -1
- package/babylon.glTF2Serializer.min.js +1 -1
- package/babylon.glTF2Serializer.min.js.map +1 -1
- package/babylonjs.serializers.d.ts +66 -0
- package/babylonjs.serializers.js +297 -2
- package/babylonjs.serializers.js.map +1 -1
- package/babylonjs.serializers.min.js +1 -1
- package/babylonjs.serializers.min.js.map +1 -1
- package/babylonjs.serializers.module.d.ts +151 -0
- package/package.json +3 -3
|
@@ -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,(function(e){return(()=>{"use strict";var t={520:t=>{t.exports=e}},r={};function n(e){var a=r[e];if(void 0!==a)return a.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 a={};return(()=>{n.d(a,{default:()=>U});var e={};n.r(e),n.d(e,{__IGLTFExporterExtension:()=>u});var t={};n.r(t),n.d(t,{GLTFData:()=>l});var r={};n.r(r),n.d(r,{GLTF2Export:()=>T});var o={};n.r(o),n.d(o,{KHR_lights_punctual:()=>F,KHR_materials_clearcoat:()=>M,KHR_materials_iridescence:()=>C,KHR_materials_sheen:()=>w,KHR_materials_specular:()=>P,KHR_materials_unlit:()=>B,KHR_texture_transform:()=>A});var i={};n.r(i),n.d(i,{GLTF2Export:()=>T,GLTFData:()=>l,KHR_lights_punctual:()=>F,KHR_materials_clearcoat:()=>M,KHR_materials_iridescence:()=>C,KHR_materials_sheen:()=>w,KHR_materials_specular:()=>P,KHR_materials_unlit:()=>B,KHR_texture_transform:()=>A,_BinaryWriter:()=>y,_Exporter:()=>x,_GLTFAnimation:()=>_,_GLTFMaterialExporter:()=>g,_GLTFUtilities:()=>m,__IGLTFExporterExtensionV2:()=>N});var s={};n.r(s),n.d(s,{GLTF2Export:()=>T,GLTFData:()=>l,KHR_lights_punctual:()=>F,KHR_materials_clearcoat:()=>M,KHR_materials_iridescence:()=>C,KHR_materials_sheen:()=>w,KHR_materials_specular:()=>P,KHR_materials_unlit:()=>B,KHR_texture_transform:()=>A,_BinaryWriter:()=>y,_Exporter:()=>x,_GLTFAnimation:()=>_,_GLTFMaterialExporter:()=>g,_GLTFUtilities:()=>m,__IGLTFExporterExtension:()=>u,__IGLTFExporterExtensionV2:()=>N});var u=0,l=function(){function e(){this.glTFFiles={}}return e.prototype.downloadFiles=function(){function e(e,t){return-1!==e.indexOf(t,e.length-t.length)}for(var t in this.glTFFiles){var r=document.createElement("a");document.body.appendChild(r),r.setAttribute("type","hidden"),r.download=t;var n=this.glTFFiles[t],a=void 0;e(t,".glb")?a={type:"model/gltf-binary"}:e(t,".bin")?a={type:"application/octet-stream"}:e(t,".gltf")?a={type:"model/gltf+json"}:e(t,".jpeg")||e(t,".jpg")?a={type:"image/jpeg"}:e(t,".png")&&(a={type:"image/png"}),r.href=window.URL.createObjectURL(new Blob([n],a)),r.click()}},e}();function c(e,t,r,n){return new(r||(r=Promise))((function(a,o){function i(e){try{u(n.next(e))}catch(e){o(e)}}function s(e){try{u(n.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?a(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(i,s)}u((n=n.apply(e,t||[])).next())}))}function f(e,t){var r,n,a,o,i={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(r)throw new TypeError("Generator is already executing.");for(;i;)try{if(r=1,n&&(a=2&o[0]?n.return:o[0]?n.throw||((a=n.return)&&a.call(n),0):n.next)&&!(a=a.call(n,o[1])).done)return a;switch(n=0,a&&(o=[2&o[0],a.value]),o[0]){case 0:case 1:a=o;break;case 4:return i.label++,{value:o[1],done:!1};case 5:i.label++,n=o[1],o=[0];continue;case 7:o=i.ops.pop(),i.trys.pop();continue;default:if(!((a=(a=i.trys).length>0&&a[a.length-1])||6!==o[0]&&2!==o[0])){i=0;continue}if(3===o[0]&&(!a||o[1]>a[0]&&o[1]<a[3])){i.label=o[1];break}if(6===o[0]&&i.label<a[1]){i.label=a[1],a=o;break}if(a&&i.label<a[2]){i.label=a[2],i.ops.push(o);break}a[2]&&i.ops.pop(),i.trys.pop();continue}o=t.call(e,i)}catch(e){o=[6,e],n=0}finally{r=a=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,s])}}}function h(e,t,r){if(r||2===arguments.length)for(var n,a=0,o=t.length;a<o;a++)!n&&a in t||(n||(n=Array.prototype.slice.call(t,0,a)),n[a]=t[a]);return e.concat(n||Array.prototype.slice.call(t))}Object.create,Object.create;var p,d=n(520),g=function(){function e(e){this._textureMap={},this._textureMap={},this._exporter=e}return e._FuzzyEquals=function(e,t,r){return d.Scalar.WithinEpsilon(e.r,t.r,r)&&d.Scalar.WithinEpsilon(e.g,t.g,r)&&d.Scalar.WithinEpsilon(e.b,t.b,r)},e.prototype._convertMaterialsToGLTFAsync=function(e,t,r){var n=this,a=[];return e.forEach((function(e){"StandardMaterial"===e.getClassName()?a.push(n._convertStandardMaterialAsync(e,t,r)):-1!==e.getClassName().indexOf("PBR")?a.push(n._convertPBRMaterialAsync(e,t,r)):d.Tools.Warn("Unsupported material type: ".concat(e.name))})),Promise.all(a).then((function(){}))},e.prototype._stripTexturesFromMaterial=function(e){var t={};if(e){t.name=e.name,t.doubleSided=e.doubleSided,t.alphaMode=e.alphaMode,t.alphaCutoff=e.alphaCutoff,t.emissiveFactor=e.emissiveFactor;var r=e.pbrMetallicRoughness;r&&(t.pbrMetallicRoughness={},t.pbrMetallicRoughness.baseColorFactor=r.baseColorFactor,t.pbrMetallicRoughness.metallicFactor=r.metallicFactor,t.pbrMetallicRoughness.roughnessFactor=r.roughnessFactor)}return t},e.prototype._hasTexturesPresent=function(e){var t;if(e.emissiveTexture||e.normalTexture||e.occlusionTexture)return!0;var r=e.pbrMetallicRoughness;if(r&&(r.baseColorTexture||r.metallicRoughnessTexture))return!0;if(e.extensions)for(var n in e.extensions){var a=e.extensions[n];if(a)return null===(t=a.hasTextures)||void 0===t?void 0:t.call(a)}return!1},e.prototype._getTextureInfo=function(e){if(e){var t=e.uid;if(t in this._textureMap)return this._textureMap[t]}return null},e.prototype._convertToGLTFPBRMetallicRoughness=function(t){var r,n,a,o,i,s,u=new d.Vector2(0,1),l=new d.Vector2(0,.1),c=new d.Vector2(0,.1),f=new d.Vector2(1300,.1),h=t.diffuseColor.toLinearSpace().scale(.5),p=t.alpha,g=(r=d.Scalar.Clamp(t.specularPower,0,e._MaxSpecularPower),n=Math.pow(r/f.x,.333333),a=u.y,o=l.y,i=c.y,s=f.y,(1-n)*(1-n)*(1-n)*a+3*(1-n)*(1-n)*n*o+3*(1-n)*n*n*i+n*n*n*s);return{baseColorFactor:[h.r,h.g,h.b,p],metallicFactor:0,roughnessFactor:g}},e._SolveMetallic=function(e,t,r){if(t<this._DielectricSpecular.r)return this._DielectricSpecular,0;var n=this._DielectricSpecular.r,a=e*r/(1-this._DielectricSpecular.r)+t-2*this._DielectricSpecular.r,o=a*a-4*n*(this._DielectricSpecular.r-t);return d.Scalar.Clamp((-a+Math.sqrt(o))/(2*n),0,1)},e._SetAlphaMode=function(e,t){t.needAlphaBlending()?e.alphaMode="BLEND":t.needAlphaTesting()&&(e.alphaMode="MASK",e.alphaCutoff=t.alphaCutOff)},e.prototype._convertStandardMaterialAsync=function(t,r,n){var a=this._exporter._materialMap,o=this._exporter._materials,i=[],s=this._convertToGLTFPBRMetallicRoughness(t),u={name:t.name};return null==t.backFaceCulling||t.backFaceCulling||(t.twoSidedLighting||d.Tools.Warn(t.name+": Back-face culling disabled and two-sided lighting disabled is not supported in glTF."),u.doubleSided=!0),n&&(t.diffuseTexture&&i.push(this._exportTextureAsync(t.diffuseTexture,r).then((function(e){e&&(s.baseColorTexture=e)}))),t.bumpTexture&&i.push(this._exportTextureAsync(t.bumpTexture,r).then((function(e){e&&(u.normalTexture=e,null!=t.bumpTexture&&1!==t.bumpTexture.level&&(u.normalTexture.scale=t.bumpTexture.level))}))),t.emissiveTexture&&(u.emissiveFactor=[1,1,1],i.push(this._exportTextureAsync(t.emissiveTexture,r).then((function(e){e&&(u.emissiveTexture=e)})))),t.ambientTexture&&i.push(this._exportTextureAsync(t.ambientTexture,r).then((function(e){if(e){var t={index:e.index};u.occlusionTexture=t,t.strength=1}})))),(t.alpha<1||t.opacityTexture)&&(t.alphaMode===d.Constants.ALPHA_COMBINE?u.alphaMode="BLEND":d.Tools.Warn(t.name+": glTF 2.0 does not support alpha mode: "+t.alphaMode.toString())),t.emissiveColor&&!e._FuzzyEquals(t.emissiveColor,d.Color3.Black(),e._Epsilon)&&(u.emissiveFactor=t.emissiveColor.asArray()),u.pbrMetallicRoughness=s,e._SetAlphaMode(u,t),o.push(u),a[t.uniqueId]=o.length-1,this._finishMaterial(i,u,t,r)},e.prototype._finishMaterial=function(e,t,r,n){var a=this;return Promise.all(e).then((function(){for(var e=null,o=0,i=a._exporter._extensionsPostExportMaterialAdditionalTextures("exportMaterial",t,r);o<i.length;o++){var s=i[o];e||(e=[]),e.push(a._exportTextureAsync(s,n))}return e||(e=[Promise.resolve(null)]),Promise.all(e).then((function(){var e=a._exporter._extensionsPostExportMaterialAsync("exportMaterial",t,r);return e?e.then((function(){return t})):t}))}))},e.prototype._createBase64FromCanvasAsync=function(e,t,r,n){var a=this;return new Promise((function(o){return c(a,void 0,void 0,(function(){var a,i,s,u,l,c;return f(this,(function(f){switch(f.label){case 0:return a=d.Constants.TEXTURETYPE_UNSIGNED_INT,i=this._exporter._babylonScene,s=i.getEngine(),u=s.createRawTexture(e,t,r,d.Constants.TEXTUREFORMAT_RGBA,!1,!0,d.Texture.NEAREST_SAMPLINGMODE,null,a),[4,d.TextureTools.ApplyPostProcess("pass",u,i,a,d.Constants.TEXTURE_NEAREST_SAMPLINGMODE,d.Constants.TEXTUREFORMAT_RGBA)];case 1:return f.sent(),[4,s._readTexturePixels(u,t,r)];case 2:return l=f.sent(),[4,d.Tools.DumpDataAsync(t,r,l,n,void 0,!0,!1)];case 3:return c=f.sent(),o(c),[2]}}))}))}))},e.prototype._createWhiteTexture=function(e,t,r){for(var n=new Uint8Array(e*t*4),a=0;a<n.length;a+=4)n[a]=n[a+1]=n[a+2]=n[a+3]=255;return d.RawTexture.CreateRGBATexture(n,e,t,r)},e.prototype._resizeTexturesToSameDimensions=function(e,t,r){var n,a,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 d.Texture?d.TextureTools.CreateResizedCopy(e,i.width,i.height,!0):this._createWhiteTexture(i.width,i.height,r),a=t):o.width>i.width?(a=t&&t instanceof d.Texture?d.TextureTools.CreateResizedCopy(t,o.width,o.height,!0):this._createWhiteTexture(o.width,o.height,r),n=e):(n=e,a=t),{texture1:n,texture2:a}},e.prototype._convertPixelArrayToFloat32=function(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!")},e.prototype._convertSpecularGlossinessTexturesToMetallicRoughnessAsync=function(t,r,n,a){var o;return c(this,void 0,void 0,(function(){var i,s,u,l,c,h,p,g,m,_,x,y,T,v,A,b,F,E,M,R,C,V,w,S,B,I,P,N,L,O,k,G;return f(this,(function(f){switch(f.label){case 0:return i=[],t||r?(s=t?t.getScene():r?r.getScene():null)?(u=this._resizeTexturesToSameDimensions(t,r,s),l=null===(o=u.texture1)||void 0===o?void 0:o.getSize(),c=void 0,h=void 0,p=l.width,g=l.height,[4,u.texture1.readPixels()]):[3,3]:[2,Promise.reject("_ConvertSpecularGlosinessTexturesToMetallicRoughness: diffuse and specular glossiness textures are not defined!")];case 1:return m=f.sent(),[4,u.texture2.readPixels()];case 2:if(_=f.sent(),!m)return[2,Promise.reject("Failed to retrieve pixels from diffuse texture!")];if(c=this._convertPixelArrayToFloat32(m),!_)return[2,Promise.reject("Failed to retrieve pixels from specular glossiness texture!")];for(h=this._convertPixelArrayToFloat32(_),x=h.byteLength,y=new Uint8Array(x),T=new Uint8Array(x),v=d.Color3.Black(),A=0,b=0,I=0;I<g;++I)for(P=0;P<p;++P)F=4*(p*I+P),E=new d.Color3(c[F],c[F+1],c[F+2]).toLinearSpace().multiply(n.diffuseColor),M=new d.Color3(h[F],h[F+1],h[F+2]).toLinearSpace().multiply(n.specularColor),R=h[F+3]*n.glossiness,C={diffuseColor:E,specularColor:M,glossiness:R},V=this._convertSpecularGlossinessToMetallicRoughness(C),v.r=Math.max(v.r,V.baseColor.r),v.g=Math.max(v.g,V.baseColor.g),v.b=Math.max(v.b,V.baseColor.b),A=Math.max(A,V.metallic),b=Math.max(b,V.roughness),T[F]=255*V.baseColor.r,T[F+1]=255*V.baseColor.g,T[F+2]=255*V.baseColor.b,T[F+3]=u.texture1.hasAlpha?255*c[F+3]:255,y[F]=0,y[F+1]=255*V.roughness,y[F+2]=255*V.metallic,y[F+3]=255;for(w={baseColor:v,metallic:A,roughness:b},S=!1,B=!1,I=0;I<g;++I)for(P=0;P<p;++P)T[N=4*(p*I+P)]/=w.baseColor.r>e._Epsilon?w.baseColor.r:1,T[N+1]/=w.baseColor.g>e._Epsilon?w.baseColor.g:1,T[N+2]/=w.baseColor.b>e._Epsilon?w.baseColor.b:1,L=d.Color3.FromInts(T[N],T[N+1],T[N+2]),O=L.toGammaSpace(),T[N]=255*O.r,T[N+1]=255*O.g,T[N+2]=255*O.b,e._FuzzyEquals(O,d.Color3.White(),e._Epsilon)||(B=!0),y[N+1]/=w.roughness>e._Epsilon?w.roughness:1,y[N+2]/=w.metallic>e._Epsilon?w.metallic:1,k=d.Color3.FromInts(255,y[N+1],y[N+2]),e._FuzzyEquals(k,d.Color3.White(),e._Epsilon)||(S=!0);return S&&(G=this._createBase64FromCanvasAsync(y,p,g,a).then((function(e){w.metallicRoughnessTextureBase64=e})),i.push(G)),B&&(G=this._createBase64FromCanvasAsync(T,p,g,a).then((function(e){w.baseColorTextureBase64=e})),i.push(G)),[2,Promise.all(i).then((function(){return w}))];case 3:return[2,Promise.reject("_ConvertSpecularGlossinessTexturesToMetallicRoughness: Scene from textures is missing!")]}}))}))},e.prototype._convertSpecularGlossinessToMetallicRoughness=function(t){var r=this._getPerceivedBrightness(t.diffuseColor),n=this._getPerceivedBrightness(t.specularColor),a=1-this._getMaxComponent(t.specularColor),o=e._SolveMetallic(r,n,a),i=t.diffuseColor.scale(a/(1-e._DielectricSpecular.r)/Math.max(1-o,e._Epsilon)),s=t.specularColor.subtract(e._DielectricSpecular.scale(1-o)).scale(1/Math.max(o,e._Epsilon)),u=d.Color3.Lerp(i,s,o*o);return{baseColor:u=u.clampToRef(0,1,u),metallic:o,roughness:1-t.glossiness}},e.prototype._getPerceivedBrightness=function(e){return e?Math.sqrt(.299*e.r*e.r+.587*e.g*e.g+.114*e.b*e.b):0},e.prototype._getMaxComponent=function(e){return e?Math.max(e.r,Math.max(e.g,e.b)):0},e.prototype._convertMetalRoughFactorsToMetallicRoughnessAsync=function(e,t,r,n){var a=[],o={baseColor:e._albedoColor,metallic:e._metallic,roughness:e._roughness};if(n){e._albedoTexture&&a.push(this._exportTextureAsync(e._albedoTexture,t).then((function(e){e&&(r.baseColorTexture=e)})));var i=e._metallicTexture;i&&a.push(this._exportTextureAsync(i,t).then((function(e){e&&(r.metallicRoughnessTexture=e)})))}return Promise.all(a).then((function(){return o}))},e.prototype._getGLTFTextureSampler=function(e){var t=this._getGLTFTextureWrapModesSampler(e),r=e instanceof d.Texture?e.samplingMode:null;if(null!=r)switch(r){case d.Texture.LINEAR_LINEAR:t.magFilter=9729,t.minFilter=9729;break;case d.Texture.LINEAR_NEAREST:t.magFilter=9729,t.minFilter=9728;break;case d.Texture.NEAREST_LINEAR:t.magFilter=9728,t.minFilter=9729;break;case d.Texture.NEAREST_LINEAR_MIPLINEAR:t.magFilter=9728,t.minFilter=9987;break;case d.Texture.NEAREST_NEAREST:t.magFilter=9728,t.minFilter=9728;break;case d.Texture.NEAREST_LINEAR_MIPNEAREST:t.magFilter=9728,t.minFilter=9985;break;case d.Texture.LINEAR_NEAREST_MIPNEAREST:t.magFilter=9729,t.minFilter=9984;break;case d.Texture.LINEAR_NEAREST_MIPLINEAR:t.magFilter=9729,t.minFilter=9986;break;case d.Texture.NEAREST_NEAREST_MIPLINEAR:t.magFilter=9728,t.minFilter=9986;break;case d.Texture.LINEAR_LINEAR_MIPLINEAR:t.magFilter=9729,t.minFilter=9987;break;case d.Texture.LINEAR_LINEAR_MIPNEAREST:t.magFilter=9729,t.minFilter=9985;break;case d.Texture.NEAREST_NEAREST_MIPNEAREST:t.magFilter=9728,t.minFilter=9984}return t},e.prototype._getGLTFTextureWrapMode=function(e){switch(e){case d.Texture.WRAP_ADDRESSMODE:return 10497;case d.Texture.CLAMP_ADDRESSMODE:return 33071;case d.Texture.MIRROR_ADDRESSMODE:return 33648;default:return d.Tools.Error("Unsupported Texture Wrap Mode ".concat(e,"!")),10497}},e.prototype._getGLTFTextureWrapModesSampler=function(e){var t=this._getGLTFTextureWrapMode(e instanceof d.Texture?e.wrapU:d.Texture.WRAP_ADDRESSMODE),r=this._getGLTFTextureWrapMode(e instanceof d.Texture?e.wrapV:d.Texture.WRAP_ADDRESSMODE);return 10497===t&&10497===r?{}:{wrapS:t,wrapT:r}},e.prototype._convertSpecGlossFactorsToMetallicRoughnessAsync=function(e,t,r,n){var a=this;return Promise.resolve().then((function(){var o=a._exporter._samplers,i=a._exporter._textures,s={diffuseColor:e._albedoColor,specularColor:e._reflectivityColor,glossiness:e._microSurface},u=null,l=e._albedoTexture,c=e._reflectivityTexture;if(l){var f=a._getGLTFTextureSampler(l);null!=f.magFilter&&null!=f.minFilter&&null!=f.wrapS&&null!=f.wrapT&&(o.push(f),u=o.length-1)}var h=e._useMicroSurfaceFromReflectivityMapAlpha;return c&&!h?Promise.reject("_ConvertPBRMaterial: Glossiness values not included in the reflectivity texture are currently not supported"):(l||c)&&n?a._convertSpecularGlossinessTexturesToMetallicRoughnessAsync(l,c,s,t).then((function(e){if(e.baseColorTextureBase64){var n=a._getTextureInfoFromBase64(e.baseColorTextureBase64,"bjsBaseColorTexture_"+i.length+".png",t,l?l.coordinatesIndex:null,u);n&&(r.baseColorTexture=n)}if(e.metallicRoughnessTextureBase64){var o=a._getTextureInfoFromBase64(e.metallicRoughnessTextureBase64,"bjsMetallicRoughnessTexture_"+i.length+".png",t,c?c.coordinatesIndex:null,u);o&&(r.metallicRoughnessTexture=o)}return e})):a._convertSpecularGlossinessToMetallicRoughness(s)}))},e.prototype._convertPBRMaterialAsync=function(e,t,r){var n=this,a={},o={name:e.name};if(e.isMetallicWorkflow()){var i=e._albedoColor,s=e.alpha;return i&&(a.baseColorFactor=[i.r,i.g,i.b,s]),this._convertMetalRoughFactorsToMetallicRoughnessAsync(e,t,a,r).then((function(i){return n._setMetallicRoughnessPbrMaterial(i,e,o,a,t,r)}))}return this._convertSpecGlossFactorsToMetallicRoughnessAsync(e,t,a,r).then((function(i){return n._setMetallicRoughnessPbrMaterial(i,e,o,a,t,r)}))},e.prototype._setMetallicRoughnessPbrMaterial=function(t,r,n,a,o,i){var s=this._exporter._materialMap,u=this._exporter._materials,l=[];if(t){if(e._SetAlphaMode(n,r),e._FuzzyEquals(t.baseColor,d.Color3.White(),e._Epsilon)&&r.alpha>=e._Epsilon||(a.baseColorFactor=[t.baseColor.r,t.baseColor.g,t.baseColor.b,r.alpha]),null!=t.metallic&&1!==t.metallic&&(a.metallicFactor=t.metallic),null!=t.roughness&&1!==t.roughness&&(a.roughnessFactor=t.roughness),null==r.backFaceCulling||r.backFaceCulling||(r._twoSidedLighting||d.Tools.Warn(r.name+": Back-face culling disabled and two-sided lighting disabled is not supported in glTF."),n.doubleSided=!0),i){var c=r._bumpTexture;if(c){var f=this._exportTextureAsync(c,o).then((function(e){e&&(n.normalTexture=e,1!==c.level&&(n.normalTexture.scale=c.level))}));l.push(f)}var h=r._ambientTexture;h&&(f=this._exportTextureAsync(h,o).then((function(e){if(e){var t={index:e.index,texCoord:e.texCoord};n.occlusionTexture=t;var a=r._ambientTextureStrength;a&&(t.strength=a)}})),l.push(f));var p=r._emissiveTexture;p&&(f=this._exportTextureAsync(p,o).then((function(e){e&&(n.emissiveTexture=e)})),l.push(f))}var g=r._emissiveColor;e._FuzzyEquals(g,d.Color3.Black(),e._Epsilon)||(n.emissiveFactor=g.asArray()),n.pbrMetallicRoughness=a,u.push(n),s[r.uniqueId]=u.length-1}return this._finishMaterial(l,n,r,o)},e.prototype._getPixelsFromTexture=function(e){return e.textureType,d.Constants.TEXTURETYPE_UNSIGNED_INT,e.readPixels()},e.prototype._exportTextureAsync=function(e,t){var r=this,n=this._exporter._extensionsPreExportTextureAsync("exporter",e,t);return n?n.then((function(n){return n?r._exportTextureInfoAsync(n,t):r._exportTextureInfoAsync(e,t)})):this._exportTextureInfoAsync(e,t)},e.prototype._exportTextureInfoAsync=function(e,t){var r=this;return Promise.resolve().then((function(){return c(r,void 0,void 0,(function(){var r,n,a,o,i,s,u,l,c,h=this;return f(this,(function(f){switch(f.label){case 0:return(r=e.uid)in this._textureMap?[2,this._textureMap[r]]:[3,1];case 1:return[4,this._getPixelsFromTexture(e)];case 2:if(!(n=f.sent()))return[2,null];for(a=this._exporter._samplers,o=this._getGLTFTextureSampler(e),i=null,s=null,u=0;u<a.length;++u)if((l=a[u]).minFilter===o.minFilter&&l.magFilter===o.magFilter&&l.wrapS===o.wrapS&&l.wrapT===o.wrapT){s=u;break}if(null==s?(a.push(o),i=a.length-1):i=s,c=e.getSize(),e.mimeType)switch(e.mimeType){case"image/jpeg":t="image/jpeg";break;case"image/png":t="image/png"}return[2,this._createBase64FromCanvasAsync(n,c.width,c.height,t).then((function(n){var a=h._getTextureInfoFromBase64(n,e.name.replace(/\.\/|\/|\.\\|\\/g,"_"),t,e.coordinatesIndex,i);return a&&(h._textureMap[r]=a,h._exporter._extensionsPostExportTextures("linkTextureInfo",a,e)),a}))]}}))}))}))},e.prototype._getTextureInfoFromBase64=function(e,t,r,n,a){var o=this._exporter._textures,i=this._exporter._images,s=this._exporter._imageData,u=null,l={source:i.length,name:t};null!=a&&(l.sampler=a);for(var c=atob(e.split(",")[1]),f=new ArrayBuffer(c.length),h=new Uint8Array(f),p=0,g=c.length;p<g;++p)h[p]=c.charCodeAt(p);var m={data:h,mimeType:r},_="image/jpeg"===r?".jpeg":".png",x=t+_,y=x;if(x in s&&(x="".concat(t,"_").concat(d.Tools.RandomId()).concat(_)),s[x]=m,"image/jpeg"===r||"image/png"===r){var T={name:t,uri:x},v=null;for(p=0;p<i.length;++p)if(i[p].uri===y){v=p;break}null==v?(i.push(T),l.source=i.length-1):l.source=v,o.push(l),u={index:o.length-1},null!=n&&(u.texCoord=n)}else d.Tools.Error("Unsupported texture mime type ".concat(r));return u},e._DielectricSpecular=new d.Color3(.04,.04,.04),e._MaxSpecularPower=1024,e._Epsilon=1e-6,e}(),m=function(){function e(){}return e._CreateBufferView=function(e,t,r,n,a){var o={buffer:e,byteLength:r};return t&&(o.byteOffset=t),a&&(o.name=a),n&&(o.byteStride=n),o},e._CreateAccessor=function(e,t,r,n,a,o,i,s){var u={name:t,bufferView:e,componentType:n,count:a,type:r};return null!=i&&(u.min=i),null!=s&&(u.max=s),null!=o&&(u.byteOffset=o),u},e._CalculateMinMaxPositions=function(t,r,n,a){var o,i,s,u=[1/0,1/0,1/0],l=[-1/0,-1/0,-1/0];if(n)for(var c=r,f=r+n;c<f;++c){o=3*c,i=d.Vector3.FromArray(t,o),a&&e._GetRightHandedPositionVector3FromRef(i),s=i.asArray();for(var h=0;h<3;++h){var p=s[h];p<u[h]&&(u[h]=p),p>l[h]&&(l[h]=p),++o}}return{min:u,max:l}},e._GetRightHandedPositionVector3=function(e){return new d.Vector3(e.x,e.y,-e.z)},e._GetRightHandedPositionVector3FromRef=function(e){e.z*=-1},e._GetRightHandedPositionArray3FromRef=function(e){e[2]*=-1},e._GetRightHandedNormalVector3=function(e){return new d.Vector3(e.x,e.y,-e.z)},e._GetRightHandedNormalVector3FromRef=function(e){e.z*=-1},e._GetRightHandedNormalArray3FromRef=function(e){e[2]*=-1},e._GetRightHandedVector4FromRef=function(e){e.z*=-1,e.w*=-1},e._GetRightHandedArray4FromRef=function(e){e[2]*=-1,e[3]*=-1},e._GetRightHandedQuaternionFromRef=function(e){e.x*=-1,e.y*=-1},e._GetRightHandedQuaternionArrayFromRef=function(e){e[0]*=-1,e[1]*=-1},e._NormalizeTangentFromRef=function(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)},e._GetDataAccessorElementCount=function(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}},e}();!function(e){e[e.INTANGENT=0]="INTANGENT",e[e.OUTTANGENT=1]="OUTTANGENT"}(p||(p={}));var _=function(){function e(){}return e._CreateNodeAnimation=function(t,r,n,a,o,i){var s=[],u=[],l=r.getKeys(),c=e._CalculateMinMaxKeyFrames(l),f=e._DeduceInterpolation(l,n,o),h=c.max-c.min,p=f.interpolationType,g=f.shouldBakeAnimation;return g?e._CreateBakedAnimation(t,r,n,c.min,c.max,r.framePerSecond,i,s,u,c,a,o):"LINEAR"===p||"STEP"===p?e._CreateLinearOrStepAnimation(t,r,n,h,s,u,a,o):"CUBICSPLINE"===p?e._CreateCubicSplineAnimation(t,r,n,h,s,u,a,o):e._CreateBakedAnimation(t,r,n,c.min,c.max,r.framePerSecond,i,s,u,c,a,o),s.length&&u.length?{inputs:s,outputs:u,samplerInterpolation:p,inputsMin:g?c.min:d.Tools.FloatRound(c.min/r.framePerSecond),inputsMax:g?c.max:d.Tools.FloatRound(c.max/r.framePerSecond)}:null},e._DeduceAnimationInfo=function(e){var t=null,r="VEC3",n=!1,a=e.targetProperty.split(".");switch(a[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:d.Tools.Error("Unsupported animatable property ".concat(a[0]))}return t?{animationChannelTargetPath:t,dataAccessorType:r,useQuaternion:n}:(d.Tools.Error("animation channel target path and data accessor type could be deduced"),null)},e._CreateNodeAnimationFromNodeAnimations=function(t,r,n,a,o,i,s,u,l,c){var f;if(t instanceof d.TransformNode&&t.animations)for(var h=0,p=t.animations;h<p.length;h++){var g=p[h],m=e._DeduceAnimationInfo(g);m&&(f={name:g.name,samplers:[],channels:[]},e._AddAnimation("".concat(g.name),g.hasRunningRuntimeAnimations?r:f,t,g,m.dataAccessorType,m.animationChannelTargetPath,a,i,s,u,l,m.useQuaternion,c),f.samplers.length&&f.channels.length&&n.push(f))}},e._CreateMorphTargetAnimationFromMorphTargetAnimations=function(t,r,n,a,o,i,s,u,l,c){var f;if(t instanceof d.Mesh){var h=t.morphTargetManager;if(h)for(var p=0;p<h.numTargets;++p)for(var g=0,m=h.getTarget(p).animations;g<m.length;g++){for(var _=m[g],x=new d.Animation("".concat(_.name),"influence",_.framePerSecond,_.dataType,_.loopMode,_.enableBlending),y=[],T=_.getKeys(),v=0;v<T.length;++v)for(var A=T[v],b=0;b<h.numTargets;++b)b==p?y.push(A):y.push({frame:A.frame,value:0});x.setKeys(y);var F=e._DeduceAnimationInfo(x);F&&(f={name:x.name,samplers:[],channels:[]},e._AddAnimation(_.name,_.hasRunningRuntimeAnimations?r:f,t,x,F.dataAccessorType,F.animationChannelTargetPath,a,i,s,u,l,F.useQuaternion,c,h.numTargets),f.samplers.length&&f.channels.length&&n.push(f))}}},e._CreateNodeAndMorphAnimationFromAnimationGroups=function(t,r,n,a,o,i,s,u,l){var c,f;if(t.animationGroups)for(var h=function(a){var h=new Map,p=new Map,g=new Set,m=a.to-a.from;f={name:a.name,channels:[],samplers:[]};for(var _=function(r){var m=a.targetedAnimations[r],_=m.target,x=m.animation;if(_ instanceof d.TransformNode||1===_.length&&_[0]instanceof d.TransformNode){if(v=e._DeduceAnimationInfo(m.animation)){var y=_ instanceof d.TransformNode?_:_[0],T=u[y.uniqueId];e._AddAnimation("".concat(x.name),f,y,x,v.dataAccessorType,v.animationChannelTargetPath,n,o,i,s,T,v.useQuaternion,l)}}else if(_ instanceof d.MorphTarget||1===_.length&&_[0]instanceof d.MorphTarget){var v;if(v=e._DeduceAnimationInfo(m.animation)){var A=_ instanceof d.MorphTarget?_:_[0];if(A){var b=t.morphTargetManagers.find((function(e){for(var t=0;t<e.numTargets;++t)if(e.getTarget(t)===A)return!0;return!1}));if(b){var F=t.meshes.find((function(e){return e.morphTargetManager===b}));F&&(h.has(F)||h.set(F,new Map),null===(c=h.get(F))||void 0===c||c.set(A,x),g.add(F),p.set(F,x))}}}}},x=0;x<a.targetedAnimations.length;++x)_(x);g.forEach((function(t){for(var r=t.morphTargetManager,u=null,c=[],g=p.get(t).getKeys(),_=g.length,x=0;x<_;++x)for(var y=0;y<r.numTargets;++y){var T=r.getTarget(y),v=h.get(t);if(v){var A=v.get(T);A?(u||(u=new d.Animation("".concat(a.name,"_").concat(t.name,"_MorphWeightAnimation"),"influence",A.framePerSecond,d.Animation.ANIMATIONTYPE_FLOAT,A.loopMode,A.enableBlending)),c.push(A.getKeys()[x])):c.push({frame:a.from+m/_*x,value:T.influence,inTangent:g[0].inTangent?0:void 0,outTangent:g[0].outTangent?0:void 0})}}u.setKeys(c);var b=e._DeduceAnimationInfo(u);b&&e._AddAnimation("".concat(a.name,"_").concat(t.name,"_MorphWeightAnimation"),f,t,u,b.dataAccessorType,b.animationChannelTargetPath,n,o,i,s,!1,b.useQuaternion,l,null==r?void 0:r.numTargets)})),f.channels.length&&f.samplers.length&&r.push(f)},p=0,g=t.animationGroups;p<g.length;p++)h(g[p])},e._AddAnimation=function(t,r,n,a,o,i,s,u,l,c,f,h,p,d){var g,_,x,y,T,v,A,b=e._CreateNodeAnimation(n,a,i,f,h,p);if(b){if(d){for(var F=0,E=0,M=[];b.inputs.length>0;)E=b.inputs.shift(),F%d==0&&M.push(E),F++;b.inputs=M}var R=s[n.uniqueId],C=4*b.inputs.length;g=m._CreateBufferView(0,u.getByteOffset(),C,void 0,"".concat(t," keyframe data view")),l.push(g),b.inputs.forEach((function(e){u.setFloat32(e)})),_=m._CreateAccessor(l.length-1,"".concat(t," keyframes"),"SCALAR",5126,b.inputs.length,null,[b.inputsMin],[b.inputsMax]),c.push(_),x=c.length-1,T=b.outputs.length,C=4*m._GetDataAccessorElementCount(o)*b.outputs.length,g=m._CreateBufferView(0,u.getByteOffset(),C,void 0,"".concat(t," data view")),l.push(g),b.outputs.forEach((function(e){e.forEach((function(e){u.setFloat32(e)}))})),_=m._CreateAccessor(l.length-1,"".concat(t," data"),o,5126,T,null,null,null),c.push(_),y=c.length-1,v={interpolation:b.samplerInterpolation,input:x,output:y},r.samplers.push(v),A={sampler:r.samplers.length-1,target:{node:R,path:i}},r.channels.push(A)}},e._CreateBakedAnimation=function(t,r,n,a,o,i,s,u,l,c,f,h){var p,g,m=d.Quaternion.Identity(),_=null,x=null,y=null,T=null,v=null,A=null;c.min=d.Tools.FloatRound(a/i);for(var b=r.getKeys(),F=0,E=b.length;F<E;++F){if(A=null,y=b[F],F+1<E)if(T=b[F+1],y.value.equals&&y.value.equals(T.value)||y.value===T.value){if(0!==F)continue;A=y.frame}else A=T.frame;else{if(v=b[F-1],y.value.equals&&y.value.equals(v.value)||y.value===v.value)continue;A=o}if(A)for(var M=y.frame;M<=A;M+=s)if((g=d.Tools.FloatRound(M/i))!==_){_=g,x=g;var R={key:0,repeatCount:0,loopMode:r.loopMode};p=r._interpolate(M,R),e._SetInterpolatedValue(t,p,g,r,n,m,u,l,f,h)}}x&&(c.max=x)},e._ConvertFactorToVector3OrQuaternion=function(t,r,n,a,o,i,s){var u,l,c=null,f=e._GetBasePositionRotationOrScale(r,o,i,s);if(a===d.Animation.ANIMATIONTYPE_FLOAT)switch(l=(u=n.targetProperty.split("."))?u[1]:"",c=s?d.Quaternion.FromArray(f).normalize():d.Vector3.FromArray(f),l){case"x":case"y":c[l]=i&&s&&"scale"!==o?-t:t;break;case"z":c[l]=i&&!s&&"scale"!==o?-t:t;break;case"w":c.w=t;break;default:d.Tools.Error('glTFAnimation: Unsupported component type "'.concat(l,'" for scale animation!'))}return c},e._SetInterpolatedValue=function(e,t,r,n,a,o,i,s,u,l){var c,f=n.dataType;i.push(r),"number"==typeof t&&e instanceof d.TransformNode&&(t=this._ConvertFactorToVector3OrQuaternion(t,e,n,f,a,u,l)),t&&("rotation"===a?(l?o=t:(c=t,d.Quaternion.RotationYawPitchRollToRef(c.y,c.x,c.z,o)),u&&(m._GetRightHandedQuaternionFromRef(o),e.parent||(o=d.Quaternion.FromArray([0,1,0,0]).multiply(o))),s.push(o.asArray())):"weights"===a?s.push([t]):(c=t,u&&"scale"!==a&&(m._GetRightHandedPositionVector3FromRef(c),e.parent||(c.x*=-1,c.z*=-1)),s.push(c.asArray())))},e._CreateLinearOrStepAnimation=function(t,r,n,a,o,i,s,u){for(var l=0,c=r.getKeys();l<c.length;l++){var f=c[l];o.push(f.frame/r.framePerSecond),e._AddKeyframeValue(f,r,i,n,t,s,u)}},e._CreateCubicSplineAnimation=function(t,r,n,a,o,i,s,u){r.getKeys().forEach((function(l){o.push(l.frame/r.framePerSecond),e._AddSplineTangent(t,p.INTANGENT,i,n,"CUBICSPLINE",l,a,u,s),e._AddKeyframeValue(l,r,i,n,t,s,u),e._AddSplineTangent(t,p.OUTTANGENT,i,n,"CUBICSPLINE",l,a,u,s)}))},e._GetBasePositionRotationOrScale=function(e,t,r,n){var a;return"rotation"===t?n?e.rotationQuaternion?(a=e.rotationQuaternion.asArray(),r&&(m._GetRightHandedQuaternionArrayFromRef(a),e.parent||(a=d.Quaternion.FromArray([0,1,0,0]).multiply(d.Quaternion.FromArray(a)).asArray()))):a=d.Quaternion.Identity().asArray():(a=e.rotation.asArray(),m._GetRightHandedNormalArray3FromRef(a)):"translation"===t?(a=e.position.asArray(),r&&m._GetRightHandedPositionArray3FromRef(a)):a=e.scaling.asArray(),a},e._AddKeyframeValue=function(e,t,r,n,a,o,i){var s,u,l=t.dataType;if(l===d.Animation.ANIMATIONTYPE_VECTOR3){if(s=e.value.asArray(),"rotation"===n){var c=d.Vector3.FromArray(s),f=d.Quaternion.RotationYawPitchRoll(c.y,c.x,c.z);o&&(m._GetRightHandedQuaternionFromRef(f),a.parent||(f=d.Quaternion.FromArray([0,1,0,0]).multiply(f))),s=f.asArray()}else"translation"===n&&o&&(m._GetRightHandedNormalArray3FromRef(s),a.parent||(s[0]*=-1,s[2]*=-1));r.push(s)}else if(l===d.Animation.ANIMATIONTYPE_FLOAT){if("weights"===n)r.push([e.value]);else if(u=this._ConvertFactorToVector3OrQuaternion(e.value,a,t,l,n,o,i)){if("rotation"===n){var h=i?u:d.Quaternion.RotationYawPitchRoll(u.y,u.x,u.z).normalize();o&&(m._GetRightHandedQuaternionFromRef(h),a.parent||(h=d.Quaternion.FromArray([0,1,0,0]).multiply(h))),r.push(h.asArray())}else"translation"===n&&o&&(m._GetRightHandedNormalVector3FromRef(u),a.parent||(u.x*=-1,u.z*=-1));r.push(u.asArray())}}else l===d.Animation.ANIMATIONTYPE_QUATERNION?(s=e.value.normalize().asArray(),o&&(m._GetRightHandedQuaternionArrayFromRef(s),a.parent||(s=d.Quaternion.FromArray([0,1,0,0]).multiply(d.Quaternion.FromArray(s)).asArray())),r.push(s)):d.Tools.Error("glTFAnimation: Unsupported key frame values for animation!")},e._DeduceInterpolation=function(e,t,r){var n,a,o=!1;if("rotation"===t&&!r)return{interpolationType:"LINEAR",shouldBakeAnimation:!0};for(var i=0,s=e.length;i<s;++i)if((a=e[i]).inTangent||a.outTangent)if(n){if("CUBICSPLINE"!==n){n="LINEAR",o=!0;break}}else n="CUBICSPLINE";else if(n){if("CUBICSPLINE"===n||a.interpolation&&a.interpolation===d.AnimationKeyInterpolation.STEP&&"STEP"!==n){n="LINEAR",o=!0;break}}else n=a.interpolation&&a.interpolation===d.AnimationKeyInterpolation.STEP?"STEP":"LINEAR";return n||(n="LINEAR"),{interpolationType:n,shouldBakeAnimation:o}},e._AddSplineTangent=function(e,t,r,n,a,o,i,s,u){var l,c=t===p.INTANGENT?o.inTangent:o.outTangent;if("CUBICSPLINE"===a){if("rotation"===n)if(c){if(s)l=c.asArray();else{var f=c;l=d.Quaternion.RotationYawPitchRoll(f.y,f.x,f.z).asArray()}u&&(m._GetRightHandedQuaternionArrayFromRef(l),e.parent||(l=d.Quaternion.FromArray([0,1,0,0]).multiply(d.Quaternion.FromArray(l)).asArray()))}else l=[0,0,0,0];else"weights"===n?l=c?[c]:[0]:c?(l=c.asArray(),u&&"translation"===n&&(m._GetRightHandedPositionArray3FromRef(l),e.parent||(l[0]*=-1,l[2]*=-1))):l=[0,0,0];r.push(l)}},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}(),x=function(){function e(e,t){this._includeCoordinateSystemConversionNodes=!1,this._extensions={},this._glTF={asset:{generator:"Babylon.js v".concat(d.Engine.Version),version:"2.0"}},(e=e||d.EngineStore.LastCreatedScene)&&(this._babylonScene=e,this._bufferViews=[],this._accessors=[],this._meshes=[],this._scenes=[],this._cameras=[],this._nodes=[],this._images=[],this._materials=[],this._materialMap=[],this._textures=[],this._samplers=[],this._skins=[],this._animations=[],this._imageData={},this._orderedImageData=[],this._options=t||{},this._animationSampleRate=t&&t.animationSampleRate?t.animationSampleRate:1/60,this._includeCoordinateSystemConversionNodes=!(!t||!t.includeCoordinateSystemConversionNodes),this._glTFMaterialExporter=new g(this),this._loadExtensions())}return e.prototype._applyExtension=function(e,t,r,n){var a=this;if(r>=t.length)return Promise.resolve(e);var o=n(t[r],e);return o?o.then((function(e){return a._applyExtension(e,t,r+1,n)})):this._applyExtension(e,t,r+1,n)},e.prototype._applyExtensions=function(t,r){for(var n=[],a=0,o=e._ExtensionNames;a<o.length;a++){var i=o[a];n.push(this._extensions[i])}return this._applyExtension(t,n,0,r)},e.prototype._extensionsPreExportTextureAsync=function(e,t,r){return this._applyExtensions(t,(function(t,n){return t.preExportTextureAsync&&t.preExportTextureAsync(e,n,r)}))},e.prototype._extensionsPostExportMeshPrimitiveAsync=function(e,t,r,n){return this._applyExtensions(t,(function(t,a){return t.postExportMeshPrimitiveAsync&&t.postExportMeshPrimitiveAsync(e,a,r,n)}))},e.prototype._extensionsPostExportNodeAsync=function(e,t,r,n){return this._applyExtensions(t,(function(t,a){return t.postExportNodeAsync&&t.postExportNodeAsync(e,a,r,n)}))},e.prototype._extensionsPostExportMaterialAsync=function(e,t,r){return this._applyExtensions(t,(function(t,n){return t.postExportMaterialAsync&&t.postExportMaterialAsync(e,n,r)}))},e.prototype._extensionsPostExportMaterialAdditionalTextures=function(t,r,n){for(var a=[],o=0,i=e._ExtensionNames;o<i.length;o++){var s=i[o],u=this._extensions[s];u.postExportMaterialAdditionalTextures&&a.push.apply(a,u.postExportMaterialAdditionalTextures(t,r,n))}return a},e.prototype._extensionsPostExportTextures=function(t,r,n){for(var a=0,o=e._ExtensionNames;a<o.length;a++){var i=o[a],s=this._extensions[i];s.postExportTexture&&s.postExportTexture(t,r,n)}},e.prototype._forEachExtensions=function(t){for(var r=0,n=e._ExtensionNames;r<n.length;r++){var a=n[r],o=this._extensions[a];o.enabled&&t(o)}},e.prototype._extensionsOnExporting=function(){var e=this;this._forEachExtensions((function(t){t.wasUsed&&(null==e._glTF.extensionsUsed&&(e._glTF.extensionsUsed=[]),-1===e._glTF.extensionsUsed.indexOf(t.name)&&e._glTF.extensionsUsed.push(t.name),t.required&&(null==e._glTF.extensionsRequired&&(e._glTF.extensionsRequired=[]),-1===e._glTF.extensionsRequired.indexOf(t.name)&&e._glTF.extensionsRequired.push(t.name)),null==e._glTF.extensions&&(e._glTF.extensions={}),t.onExporting&&t.onExporting())}))},e.prototype._loadExtensions=function(){for(var t=0,r=e._ExtensionNames;t<r.length;t++){var n=r[t],a=e._ExtensionFactories[n](this);this._extensions[n]=a}},e.prototype.dispose=function(){for(var e in this._extensions)this._extensions[e].dispose()},e.RegisterExtension=function(t,r){e.UnregisterExtension(t)&&d.Tools.Warn("Extension with the name ".concat(t," already exists")),e._ExtensionFactories[t]=r,e._ExtensionNames.push(t)},e.UnregisterExtension=function(t){if(!e._ExtensionFactories[t])return!1;delete e._ExtensionFactories[t];var r=e._ExtensionNames.indexOf(t);return-1!==r&&e._ExtensionNames.splice(r,1),!0},e.prototype._reorderIndicesBasedOnPrimitiveMode=function(e,t,r,n,a){switch(t){case d.Material.TriangleFillMode:n||(n=0);for(var o=e.indexStart,i=e.indexStart+e.indexCount;o<i;o+=3){var s=n+4*o,u=a.getUInt32(s+4),l=a.getUInt32(s+8);a.setUInt32(l,s+4),a.setUInt32(u,s+8)}break;case d.Material.TriangleFanDrawMode:o=e.indexStart+e.indexCount-1;for(var c=e.indexStart;o>=c;--o)a.setUInt32(r[o],n),n+=4;break;case d.Material.TriangleStripDrawMode:e.indexCount>=3&&(a.setUInt32(r[e.indexStart+2],n+4),a.setUInt32(r[e.indexStart+1],n+8))}},e.prototype._reorderVertexAttributeDataBasedOnPrimitiveMode=function(e,t,r,n,a,o,i,s){if(s&&r===d.Material.ClockWiseSideOrientation)switch(t){case d.Material.TriangleFillMode:this._reorderTriangleFillMode(e,t,r,n,a,o,i,s);break;case d.Material.TriangleStripDrawMode:this._reorderTriangleStripDrawMode(e,t,r,n,a,o,i,s);break;case d.Material.TriangleFanDrawMode:this._reorderTriangleFanMode(e,t,r,n,a,o,i,s)}},e.prototype._reorderTriangleFillMode=function(e,t,r,n,a,o,i,s){var u=this._getVertexBufferFromMesh(n,e.getMesh());if(u){var l=u.byteStride/d.VertexBuffer.GetTypeByteLength(u.type);if(e.verticesCount%3!=0)d.Tools.Error("The submesh vertices for the triangle fill mode is not divisible by 3!");else{var c=[],f=0;switch(n){case d.VertexBuffer.PositionKind:case d.VertexBuffer.NormalKind:for(var h=e.verticesStart;h<e.verticesStart+e.verticesCount;h+=3)f=h*l,c.push(d.Vector3.FromArray(a,f)),c.push(d.Vector3.FromArray(a,f+2*l)),c.push(d.Vector3.FromArray(a,f+l));break;case d.VertexBuffer.TangentKind:for(h=e.verticesStart;h<e.verticesStart+e.verticesCount;h+=3)f=h*l,c.push(d.Vector4.FromArray(a,f)),c.push(d.Vector4.FromArray(a,f+2*l)),c.push(d.Vector4.FromArray(a,f+l));break;case d.VertexBuffer.ColorKind:var p=u.getSize();for(h=e.verticesStart;h<e.verticesStart+e.verticesCount;h+=p)f=h*l,4===p?(c.push(d.Vector4.FromArray(a,f)),c.push(d.Vector4.FromArray(a,f+2*l)),c.push(d.Vector4.FromArray(a,f+l))):(c.push(d.Vector3.FromArray(a,f)),c.push(d.Vector3.FromArray(a,f+2*l)),c.push(d.Vector3.FromArray(a,f+l)));break;case d.VertexBuffer.UVKind:case d.VertexBuffer.UV2Kind:for(h=e.verticesStart;h<e.verticesStart+e.verticesCount;h+=3)f=h*l,c.push(d.Vector2.FromArray(a,f)),c.push(d.Vector2.FromArray(a,f+2*l)),c.push(d.Vector2.FromArray(a,f+l));break;default:d.Tools.Error("Unsupported Vertex Buffer type: ".concat(n))}this._writeVertexAttributeData(c,o,n,a,i,s)}}else d.Tools.Warn("reorderTriangleFillMode: Vertex Buffer Kind ".concat(n," not present!"))},e.prototype._reorderTriangleStripDrawMode=function(e,t,r,n,a,o,i,s){var u=this._getVertexBufferFromMesh(n,e.getMesh());if(u){var l=u.byteStride/d.VertexBuffer.GetTypeByteLength(u.type),c=[],f=0;switch(n){case d.VertexBuffer.PositionKind:case d.VertexBuffer.NormalKind:f=e.verticesStart,c.push(d.Vector3.FromArray(a,f+2*l)),c.push(d.Vector3.FromArray(a,f+l));break;case d.VertexBuffer.TangentKind:for(var h=e.verticesStart+e.verticesCount-1;h>=e.verticesStart;--h)f=h*l,c.push(d.Vector4.FromArray(a,f));break;case d.VertexBuffer.ColorKind:for(h=e.verticesStart+e.verticesCount-1;h>=e.verticesStart;--h)f=h*l,4===u.getSize()?c.push(d.Vector4.FromArray(a,f)):c.push(d.Vector3.FromArray(a,f));break;case d.VertexBuffer.UVKind:case d.VertexBuffer.UV2Kind:for(h=e.verticesStart+e.verticesCount-1;h>=e.verticesStart;--h)f=h*l,c.push(d.Vector2.FromArray(a,f));break;default:d.Tools.Error("Unsupported Vertex Buffer type: ".concat(n))}this._writeVertexAttributeData(c,o+12,n,a,i,s)}else d.Tools.Warn("reorderTriangleStripDrawMode: Vertex buffer kind ".concat(n," not present!"))},e.prototype._reorderTriangleFanMode=function(e,t,r,n,a,o,i,s){var u=this._getVertexBufferFromMesh(n,e.getMesh());if(u){var l=u.byteStride/d.VertexBuffer.GetTypeByteLength(u.type),c=[],f=0;switch(n){case d.VertexBuffer.PositionKind:case d.VertexBuffer.NormalKind:for(var h=e.verticesStart+e.verticesCount-1;h>=e.verticesStart;--h)f=h*l,c.push(d.Vector3.FromArray(a,f));break;case d.VertexBuffer.TangentKind:for(h=e.verticesStart+e.verticesCount-1;h>=e.verticesStart;--h)f=h*l,c.push(d.Vector4.FromArray(a,f));break;case d.VertexBuffer.ColorKind:for(h=e.verticesStart+e.verticesCount-1;h>=e.verticesStart;--h)f=h*l,c.push(d.Vector4.FromArray(a,f)),4===u.getSize()?c.push(d.Vector4.FromArray(a,f)):c.push(d.Vector3.FromArray(a,f));break;case d.VertexBuffer.UVKind:case d.VertexBuffer.UV2Kind:for(h=e.verticesStart+e.verticesCount-1;h>=e.verticesStart;--h)f=h*l,c.push(d.Vector2.FromArray(a,f));break;default:d.Tools.Error("Unsupported Vertex Buffer type: ".concat(n))}this._writeVertexAttributeData(c,o,n,a,i,s)}else d.Tools.Warn("reorderTriangleFanMode: Vertex buffer kind ".concat(n," not present!"))},e.prototype._writeVertexAttributeData=function(e,t,r,n,a,o){for(var i=0,s=e;i<s.length;i++){var u=s[i];!o||r===d.VertexBuffer.ColorKind||u instanceof d.Vector2||(u instanceof d.Vector3?r===d.VertexBuffer.NormalKind?m._GetRightHandedNormalVector3FromRef(u):r===d.VertexBuffer.PositionKind?m._GetRightHandedPositionVector3FromRef(u):d.Tools.Error("Unsupported vertex attribute kind!"):m._GetRightHandedVector4FromRef(u)),r===d.VertexBuffer.NormalKind?u.normalize():r===d.VertexBuffer.TangentKind&&u instanceof d.Vector4&&m._NormalizeTangentFromRef(u);for(var l=0,c=u.asArray();l<c.length;l++){var f=c[l];a.setFloat32(f,t),t+=4}}},e.prototype._writeAttributeData=function(e,t,r,n,a,o,i){var s,u,l=[];switch(e){case d.VertexBuffer.PositionKind:for(var c=0,f=r.length/n;c<f;++c){s=c*n;var h=d.Vector3.FromArray(r,s);o&&m._GetRightHandedPositionVector3FromRef(h),l.push(h.asArray())}break;case d.VertexBuffer.NormalKind:c=0;for(var p=r.length/n;c<p;++c)s=c*n,h=d.Vector3.FromArray(r,s),o&&m._GetRightHandedNormalVector3FromRef(h),h.normalize(),l.push(h.asArray());break;case d.VertexBuffer.TangentKind:c=0;for(var g=r.length/n;c<g;++c)s=c*n,h=d.Vector4.FromArray(r,s),o&&m._GetRightHandedVector4FromRef(h),m._NormalizeTangentFromRef(h),l.push(h.asArray());break;case d.VertexBuffer.ColorKind:for(var _=i.material,x=!_||"StandardMaterial"===_.getClassName(),y=(h=3===n?new d.Color3:new d.Color4,c=0,r.length/n);c<y;++c)s=c*n,3===n?(d.Color3.FromArrayToRef(r,s,h),x&&h.toLinearSpaceToRef(h)):(d.Color4.FromArrayToRef(r,s,h),x&&h.toLinearSpaceToRef(h)),l.push(h.asArray());break;case d.VertexBuffer.UVKind:case d.VertexBuffer.UV2Kind:c=0;for(var T=r.length/n;c<T;++c)s=c*n,l.push([r[s],r[s+1]]);break;case d.VertexBuffer.MatricesIndicesKind:case d.VertexBuffer.MatricesIndicesExtraKind:c=0;for(var v=r.length/n;c<v;++c)s=c*n,h=d.Vector4.FromArray(r,s),l.push(h.asArray());break;case d.VertexBuffer.MatricesWeightsKind:case d.VertexBuffer.MatricesWeightsExtraKind:c=0;for(var A=r.length/n;c<A;++c)s=c*n,h=d.Vector4.FromArray(r,s),l.push(h.asArray());break;default:d.Tools.Warn("Unsupported Vertex Buffer Type: "+e),l=[]}switch(t){case 5121:u=a.setUInt8.bind(a);break;case 5123:u=a.setUInt16.bind(a);break;case 5125:u=a.setUInt32.bind(a);break;case 5126:u=a.setFloat32.bind(a);break;default:return void d.Tools.Warn("Unsupported Attribute Component kind: "+t)}for(var b=0,F=l;b<F.length;b++)for(var E=0,M=F[b];E<M.length;E++)u(M[E])},e.prototype.writeMorphTargetAttributeData=function(e,t,r,n,a,o,i,s,u,l){var c,f,h=[],p=new d.Vector3,g=new d.Vector4(0,0,0,0);switch(e){case d.VertexBuffer.PositionKind:for(var _=r.verticesStart;_<r.verticesCount;++_){c=r.indexStart+_*i;var x=d.Vector3.FromArray(a,c);p=(y=d.Vector3.FromArray(o,c)).subtractToRef(x,p),u&&m._GetRightHandedPositionVector3FromRef(p),l&&(l.min.copyFromFloats(Math.min(p.x,l.min.x),Math.min(p.y,l.min.y),Math.min(p.z,l.min.z)),l.max.copyFromFloats(Math.max(p.x,l.max.x),Math.max(p.y,l.max.y),Math.max(p.z,l.max.z))),h.push(p.asArray())}break;case d.VertexBuffer.NormalKind:for(_=r.verticesStart;_<r.verticesCount;++_)c=r.indexStart+_*i,(x=d.Vector3.FromArray(a,c)).normalize(),(y=d.Vector3.FromArray(o,c)).normalize(),p=y.subtractToRef(x,p),u&&m._GetRightHandedNormalVector3FromRef(p),h.push(p.asArray());break;case d.VertexBuffer.TangentKind:for(_=r.verticesStart;_<r.verticesCount;++_){c=r.indexStart+_*(i+1),x=d.Vector4.FromArray(a,c),m._NormalizeTangentFromRef(x);var y=d.Vector4.FromArray(o,c);m._NormalizeTangentFromRef(y),g=y.subtractToRef(x,g),u&&m._GetRightHandedVector4FromRef(g),h.push([g.x,g.y,g.z])}break;default:d.Tools.Warn("Unsupported Vertex Buffer Type: "+e),h=[]}switch(t){case 5121:f=s.setUInt8.bind(s);break;case 5123:f=s.setUInt16.bind(s);break;case 5125:f=s.setUInt32.bind(s);break;case 5126:f=s.setFloat32.bind(s);break;default:return void d.Tools.Warn("Unsupported Attribute Component kind: "+t)}for(var T=0,v=h;T<v.length;T++)for(var A=0,b=v[T];A<b.length;A++)f(b[A])},e.prototype._generateJSON=function(e,t,r){var n,a,o,i=this,s={byteLength:this._totalByteLength},u=this._totalByteLength;return s.byteLength&&(this._glTF.buffers=[s]),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&&(e?(this._glTF.images=[],this._images.forEach((function(e){e.uri&&(a=i._imageData[e.uri],i._orderedImageData.push(a),n=e.uri.split(".")[0]+" image",o=m._CreateBufferView(0,u,a.data.length,void 0,n),u+=a.data.buffer.byteLength,i._bufferViews.push(o),e.bufferView=i._bufferViews.length-1,e.name=n,e.mimeType=a.mimeType,e.uri=void 0,i._glTF.images||(i._glTF.images=[]),i._glTF.images.push(e))})),s.byteLength=u):this._glTF.images=this._images),e||(s.uri=t+".bin"),r?JSON.stringify(this._glTF,null,2):JSON.stringify(this._glTF)},e.prototype._generateGLTFAsync=function(e,t){var r=this;return void 0===t&&(t=!0),this._generateBinaryAsync().then((function(n){r._extensionsOnExporting();var a=r._generateJSON(!1,e,!0),o=new Blob([n],{type:"application/octet-stream"}),i=e+".gltf",s=e+".bin",u=new l;if(u.glTFFiles[i]=a,u.glTFFiles[s]=o,r._imageData)for(var c in r._imageData)u.glTFFiles[c]=new Blob([r._imageData[c].data],{type:r._imageData[c].mimeType});return t&&r.dispose(),u}))},e.prototype._generateBinaryAsync=function(){var e=this,t=new y(4);return this._createSceneAsync(this._babylonScene,t).then((function(){return e._localEngine&&e._localEngine.dispose(),t.getArrayBuffer()}))},e.prototype._getPadding=function(e){var t=e%4;return 0===t?t:4-t},e.prototype._generateGLBAsync=function(e,t){var r=this;return void 0===t&&(t=!0),this._generateBinaryAsync().then((function(n){r._extensionsOnExporting();var a,o=r._generateJSON(!0),i=e+".glb",s=o.length,u=0;"undefined"!=typeof TextEncoder&&(s=(a=(new TextEncoder).encode(o)).length);for(var c=0;c<r._orderedImageData.length;++c)u+=r._orderedImageData[c].data.byteLength;var f=r._getPadding(s),h=r._getPadding(n.byteLength),p=r._getPadding(u),d=28+s+f+n.byteLength+h+u+p,g=new ArrayBuffer(12),m=new DataView(g);m.setUint32(0,1179937895,!0),m.setUint32(4,2,!0),m.setUint32(8,d,!0);var _=new ArrayBuffer(8+s+f),x=new DataView(_);x.setUint32(0,s+f,!0),x.setUint32(4,1313821514,!0);var y=new Uint8Array(_,8);if(a)y.set(a);else{var T="_".charCodeAt(0);for(c=0;c<s;++c){var v=o.charCodeAt(c);v!=o.codePointAt(c)?y[c]=T:y[c]=v}}var A=new Uint8Array(_,8+s);for(c=0;c<f;++c)A[c]=32;var b=new ArrayBuffer(8),F=new DataView(b);F.setUint32(0,n.byteLength+u+p,!0),F.setUint32(4,5130562,!0);var E=new ArrayBuffer(h),M=new Uint8Array(E);for(c=0;c<h;++c)M[c]=0;var R=new ArrayBuffer(p),C=new Uint8Array(R);for(c=0;c<p;++c)C[c]=0;var V=[g,_,b,n];for(c=0;c<r._orderedImageData.length;++c)V.push(r._orderedImageData[c].data.buffer);V.push(E),V.push(R);var w=new Blob(V,{type:"application/octet-stream"}),S=new l;return S.glTFFiles[i]=w,null!=r._localEngine&&r._localEngine.dispose(),t&&r.dispose(),S}))},e.prototype._setNodeTransformation=function(e,t,r){t.getPivotPoint().equalsToFloats(0,0,0)||d.Tools.Warn("Pivot points are not supported in the glTF serializer"),t.position.equalsToFloats(0,0,0)||(e.translation=r?m._GetRightHandedPositionVector3(t.position).asArray():t.position.asArray()),t.scaling.equalsToFloats(1,1,1)||(e.scale=t.scaling.asArray());var n=d.Quaternion.RotationYawPitchRoll(t.rotation.y,t.rotation.x,t.rotation.z);t.rotationQuaternion&&n.multiplyInPlace(t.rotationQuaternion),d.Quaternion.IsIdentity(n)||(r&&m._GetRightHandedQuaternionFromRef(n),e.rotation=n.normalize().asArray())},e.prototype._setCameraTransformation=function(e,t,r){t.position.equalsToFloats(0,0,0)||(e.translation=r?m._GetRightHandedPositionVector3(t.position).asArray():t.position.asArray());var n=t.absoluteRotation;d.Quaternion.IsIdentity(n)||(r&&m._GetRightHandedQuaternionFromRef(n),e.rotation=n.normalize().asArray())},e.prototype._getVertexBufferFromMesh=function(e,t){if(t.isVerticesDataPresent(e)){var r=t.getVertexBuffer(e);if(r)return r}return null},e.prototype._createBufferViewKind=function(e,t,r,n,a,o){var i=r instanceof d.Mesh?r:r instanceof d.InstancedMesh?r.sourceMesh:null;if(i){var s=i.getVertexBuffer(e),u=i.getVerticesData(e);if(s&&u){var l=d.VertexBuffer.GetTypeByteLength(t),c=u.length*l,f=m._CreateBufferView(0,n.getByteOffset(),c,a,e+" - "+i.name);this._bufferViews.push(f),this._writeAttributeData(e,t,u,a/l,n,o,r)}}},e.prototype._setMorphTargetAttributes=function(e,t,r,n,a){if(r){t.targets||(t.targets=[]);var o={};if(r.hasNormals){var i=e.getMesh().getVerticesData(d.VertexBuffer.NormalKind),s=r.getNormals(),u=(_=e.verticesCount)*(x=12),l=m._CreateBufferView(0,n.getByteOffset(),u,x,r.name+"_NORMAL");this._bufferViews.push(l);var c=this._bufferViews.length-1,f=m._CreateAccessor(c,r.name+" - NORMAL","VEC3",5126,_,0,null,null);this._accessors.push(f),o.NORMAL=this._accessors.length-1,this.writeMorphTargetAttributeData(d.VertexBuffer.NormalKind,5126,e,r,i,s,x/4,n,a)}if(r.hasPositions){var h=e.getMesh().getVerticesData(d.VertexBuffer.PositionKind),p=r.getPositions();u=(_=e.verticesCount)*(x=12),l=m._CreateBufferView(0,n.getByteOffset(),u,x,r.name+"_POSITION"),this._bufferViews.push(l),c=this._bufferViews.length-1;var g={min:new d.Vector3(1/0,1/0,1/0),max:new d.Vector3(-1/0,-1/0,-1/0)};f=m._CreateAccessor(c,r.name+" - POSITION","VEC3",5126,_,0,null,null),this._accessors.push(f),o.POSITION=this._accessors.length-1,this.writeMorphTargetAttributeData(d.VertexBuffer.PositionKind,5126,e,r,h,p,x/4,n,a,g),f.min=g.min.asArray(),f.max=g.max.asArray()}if(r.hasTangents){var _,x,y=e.getMesh().getVerticesData(d.VertexBuffer.TangentKind),T=r.getTangents();u=(_=e.verticesCount)*(x=12),l=m._CreateBufferView(0,n.getByteOffset(),u,x,r.name+"_NORMAL"),this._bufferViews.push(l),c=this._bufferViews.length-1,f=m._CreateAccessor(c,r.name+" - TANGENT","VEC3",5126,_,0,null,null),this._accessors.push(f),o.TANGENT=this._accessors.length-1,this.writeMorphTargetAttributeData(d.VertexBuffer.TangentKind,5126,e,r,y,T,x/4,n,a)}t.targets.push(o)}},e.prototype._getMeshPrimitiveMode=function(e){return e instanceof d.LinesMesh?d.Material.LineListDrawMode:e.material?e.material.fillMode:d.Material.TriangleFillMode},e.prototype._setPrimitiveMode=function(e,t){switch(t){case d.Material.TriangleFillMode:break;case d.Material.TriangleStripDrawMode:e.mode=5;break;case d.Material.TriangleFanDrawMode:e.mode=6;break;case d.Material.PointListDrawMode:case d.Material.PointFillMode:e.mode=0;break;case d.Material.LineLoopDrawMode:e.mode=2;break;case d.Material.LineListDrawMode:e.mode=1;break;case d.Material.LineStripDrawMode:e.mode=3}},e.prototype._setAttributeKind=function(e,t){switch(t){case d.VertexBuffer.PositionKind:e.attributes.POSITION=this._accessors.length-1;break;case d.VertexBuffer.NormalKind:e.attributes.NORMAL=this._accessors.length-1;break;case d.VertexBuffer.ColorKind:e.attributes.COLOR_0=this._accessors.length-1;break;case d.VertexBuffer.TangentKind:e.attributes.TANGENT=this._accessors.length-1;break;case d.VertexBuffer.UVKind:e.attributes.TEXCOORD_0=this._accessors.length-1;break;case d.VertexBuffer.UV2Kind:e.attributes.TEXCOORD_1=this._accessors.length-1;break;case d.VertexBuffer.MatricesIndicesKind:e.attributes.JOINTS_0=this._accessors.length-1;break;case d.VertexBuffer.MatricesIndicesExtraKind:e.attributes.JOINTS_1=this._accessors.length-1;break;case d.VertexBuffer.MatricesWeightsKind:e.attributes.WEIGHTS_0=this._accessors.length-1;break;case d.VertexBuffer.MatricesWeightsExtraKind:e.attributes.WEIGHTS_1=this._accessors.length-1;break;default:d.Tools.Warn("Unsupported Vertex Buffer Type: "+t)}},e.prototype._setPrimitiveAttributesAsync=function(e,t,r,n){var a,o,i,s=[],u=null;t instanceof d.Mesh?u=t:t instanceof d.InstancedMesh&&(u=t.sourceMesh);var l=[{kind:d.VertexBuffer.PositionKind,accessorType:"VEC3",accessorComponentType:5126,byteStride:12},{kind:d.VertexBuffer.NormalKind,accessorType:"VEC3",accessorComponentType:5126,byteStride:12},{kind:d.VertexBuffer.ColorKind,accessorType:"VEC4",accessorComponentType:5126,byteStride:16},{kind:d.VertexBuffer.TangentKind,accessorType:"VEC4",accessorComponentType:5126,byteStride:16},{kind:d.VertexBuffer.UVKind,accessorType:"VEC2",accessorComponentType:5126,byteStride:8},{kind:d.VertexBuffer.UV2Kind,accessorType:"VEC2",accessorComponentType:5126,byteStride:8},{kind:d.VertexBuffer.MatricesIndicesKind,accessorType:"VEC4",accessorComponentType:5123,byteStride:8},{kind:d.VertexBuffer.MatricesIndicesExtraKind,accessorType:"VEC4",accessorComponentType:5123,byteStride:8},{kind:d.VertexBuffer.MatricesWeightsKind,accessorType:"VEC4",accessorComponentType:5126,byteStride:16},{kind:d.VertexBuffer.MatricesWeightsExtraKind,accessorType:"VEC4",accessorComponentType:5126,byteStride:16}];if(u){for(var c=null,f=this._getMeshPrimitiveMode(u),h={},p=u.morphTargetManager,g=0,_=l;g<_.length;g++){var x=(W=_[g]).kind,y=W.accessorComponentType;if(u.isVerticesDataPresent(x)){var T=this._getVertexBufferFromMesh(x,u);W.byteStride=T?T.getSize()*d.VertexBuffer.GetTypeByteLength(W.accessorComponentType):4*d.VertexBuffer.DeduceStride(x),12===W.byteStride&&(W.accessorType="VEC3"),this._createBufferViewKind(x,y,t,r,W.byteStride,n),W.bufferViewIndex=this._bufferViews.length-1,h[x]=W.bufferViewIndex}}if(u.getTotalIndices()){var v=u.getIndices();if(v){var A=4*v.length;o=m._CreateBufferView(0,r.getByteOffset(),A,void 0,"Indices - "+u.name),this._bufferViews.push(o),c=this._bufferViews.length-1;for(var b=0,F=v.length;b<F;++b)r.setUInt32(v[b])}}if(u.subMeshes)for(var E=0,M=u.subMeshes;E<M.length;E++){var R=M[E],C=R.getMaterial()||u.getScene().defaultMaterial,V=null;if(C)if(u instanceof d.LinesMesh){var w={name:u.name+" material"};(!u.color.equals(d.Color3.White())||u.alpha<1)&&(w.pbrMetallicRoughness={baseColorFactor:u.color.asArray().concat([u.alpha])}),this._materials.push(w),V=this._materials.length-1}else if(C instanceof d.MultiMaterial){var S=C.subMaterials[R.materialIndex];S&&(C=S,V=this._materialMap[C.uniqueId])}else V=this._materialMap[C.uniqueId];var B=null!=V?this._materials[V]:null,I={attributes:{}};this._setPrimitiveMode(I,f);for(var P=0,N=l;P<N.length;P++)if(((x=(W=N[P]).kind)!==d.VertexBuffer.UVKind&&x!==d.VertexBuffer.UV2Kind||this._options.exportUnusedUVs||B&&this._glTFMaterialExporter._hasTexturesPresent(B))&&(z=u.getVerticesData(x))&&(T=this._getVertexBufferFromMesh(x,u))){var L=T.getSize(),O=W.bufferViewIndex;if(null!=O){i={min:null,max:null},x==d.VertexBuffer.PositionKind&&(i=m._CalculateMinMaxPositions(z,0,z.length/L,n));var k=m._CreateAccessor(O,x+" - "+t.name,W.accessorType,W.accessorComponentType,z.length/L,0,i.min,i.max);this._accessors.push(k),this._setAttributeKind(I,x)}}if(c&&(k=m._CreateAccessor(c,"indices - "+t.name,"SCALAR",5125,R.indexCount,4*R.indexStart,null,null),this._accessors.push(k),I.indices=this._accessors.length-1),null!=V&&Object.keys(I.attributes).length>0){var G=null!==u.overrideMaterialSideOrientation?u.overrideMaterialSideOrientation:C.sideOrientation;if(G==d.Material.ClockWiseSideOrientation&&this._babylonScene.useRightHandedSystem||G==d.Material.ClockWiseSideOrientation&&n&&u.overrideMaterialSideOrientation!==(null===(a=u.material)||void 0===a?void 0:a.sideOrientation)){var U=null!=c?this._bufferViews[c].byteOffset:null;null==U&&(U=0);var K=null;if(null!=c&&(K=u.getIndices()),K)this._reorderIndicesBasedOnPrimitiveMode(R,f,K,U,r);else for(var D=0,H=l;D<H.length;D++){var z,W=H[D];if(z=u.getVerticesData(W.kind)){var q=this._bufferViews[h[W.kind]].byteOffset;q||(q=0),this._reorderVertexAttributeDataBasedOnPrimitiveMode(R,f,G,W.kind,z,q,r,n)}}}I.material=V}if(p)for(var Q=void 0,j=0;j<p.numTargets;++j)Q=p.getTarget(j),this._setMorphTargetAttributes(R,I,Q,r,n);e.primitives.push(I),this._extensionsPostExportMeshPrimitiveAsync("postExport",I,R,r),s.push()}}return Promise.all(s).then((function(){}))},e.prototype._isBabylonCoordinateSystemConvertingNode=function(e){return e instanceof d.TransformNode&&"__root__"===e.name&&1!==e.getWorldMatrix().determinant()&&!(e instanceof d.Mesh&&null!==e.geometry||e instanceof d.InstancedMesh&&null!==e.sourceMesh.geometry)&&!this._includeCoordinateSystemConversionNodes},e.prototype._createSceneAsync=function(e,t){var r,n,a,o=this,i={nodes:[]},s=h(h(h(h([],e.transformNodes,!0),e.meshes,!0),e.lights,!0),e.cameras,!0),u=[];this._convertToRightHandedSystem=!e.useRightHandedSystem,this._convertToRightHandedSystemMap={},e.rootNodes.forEach((function(e){o._convertToRightHandedSystemMap[e.uniqueId]=o._convertToRightHandedSystem,e.getDescendants(!1).forEach((function(e){o._convertToRightHandedSystemMap[e.uniqueId]=o._convertToRightHandedSystem}))})),e.rootNodes.forEach((function(e){if(o._isBabylonCoordinateSystemConvertingNode(e)){u.push(e);var t=s.indexOf(e);-1!==t&&s.splice(t,1),e.getDescendants(!1).forEach((function(e){o._convertToRightHandedSystemMap[e.uniqueId]=!1}))}}));var l=new Map;e.cameras.forEach((function(e){if(!o._options.shouldExportNode||o._options.shouldExportNode(e)){var t={type:e.mode===d.Camera.PERSPECTIVE_CAMERA?"perspective":"orthographic"};if(e.name&&(t.name=e.name),"perspective"===t.type)t.perspective={aspectRatio:e.getEngine().getAspectRatio(e),yfov:e.fovMode===d.Camera.FOVMODE_VERTICAL_FIXED?e.fov:e.fov*e.getEngine().getAspectRatio(e),znear:e.minZ,zfar:e.maxZ};else if("orthographic"===t.type){var r=e.orthoLeft&&e.orthoRight?.5*(e.orthoRight-e.orthoLeft):.5*e.getEngine().getRenderWidth(),n=e.orthoBottom&&e.orthoTop?.5*(e.orthoTop-e.orthoBottom):.5*e.getEngine().getRenderHeight();t.orthographic={xmag:r,ymag:n,znear:e.minZ,zfar:e.maxZ}}l.set(e,o._cameras.length),o._cameras.push(t)}}));var c=this._getExportNodes(s),f=c[0],p=c[1];return this._glTFMaterialExporter._convertMaterialsToGLTFAsync(p,"image/png",!0).then((function(){return o._createNodeMapAndAnimationsAsync(e,f,t).then((function(c){return o._createSkinsAsync(e,c,t).then((function(e){if(o._nodeMap=c,o._totalByteLength=t.getByteOffset(),null==o._totalByteLength)throw new Error("undefined byte length!");for(var f=0,h=s;f<h.length;f++){var p=h[f];if(void 0!==(r=o._nodeMap[p.uniqueId])){if(n=o._nodes[r],p.metadata&&(o._options.metadataSelector?n.extras=o._options.metadataSelector(p.metadata):p.metadata.gltf&&(n.extras=p.metadata.gltf.extras)),p instanceof d.Camera&&(n.camera=l.get(p)),p.parent&&-1===u.indexOf(p.parent)||(o._options.shouldExportNode&&!o._options.shouldExportNode(p)?d.Tools.Log("Omitting "+p.name+" from scene."):(o._convertToRightHandedSystemMap[p.uniqueId]&&(n.translation&&(n.translation[2]*=-1,n.translation[0]*=-1),n.rotation=n.rotation?d.Quaternion.FromArray([0,1,0,0]).multiply(d.Quaternion.FromArray(n.rotation)).asArray():d.Quaternion.FromArray([0,1,0,0]).asArray()),i.nodes.push(r))),p instanceof d.Mesh){var g=p;g.skeleton&&(n.skin=e[g.skeleton.uniqueId])}if(a=p.getDescendants(!0),!n.children&&a&&a.length){for(var m=[],_=0,x=a;_<x.length;_++){var y=x[_];null!=o._nodeMap[y.uniqueId]&&m.push(o._nodeMap[y.uniqueId])}m.length&&(n.children=m)}}}i.nodes.length&&o._scenes.push(i)}))}))}))},e.prototype._getExportNodes=function(e){for(var t=[],r=new Set,n=0,a=e;n<a.length;n++){var o=a[n];if(!this._options.shouldExportNode||this._options.shouldExportNode(o)){if(t.push(o),o instanceof d.AbstractMesh){var i=o.material||o.getScene().defaultMaterial;if(i instanceof d.MultiMaterial)for(var s=0,u=i.subMaterials;s<u.length;s++){var l=u[s];l&&r.add(l)}else r.add(i)}}else"Excluding node ".concat(o.name)}return[t,r]},e.prototype._createNodeMapAndAnimationsAsync=function(e,t,r){for(var n,a=this,o=Promise.resolve(),i={},s={name:"runtime animations",channels:[],samplers:[]},u=[],l=function(t){o=o.then((function(){var o=a._convertToRightHandedSystemMap[t.uniqueId];return a._createNodeAsync(t,r,o).then((function(l){var c=a._extensionsPostExportNodeAsync("createNodeAsync",l,t,i);return null==c?(d.Tools.Warn("Not exporting node ".concat(t.name)),Promise.resolve()):c.then((function(l){l&&(a._nodes.push(l),n=a._nodes.length-1,i[t.uniqueId]=n,e.animationGroups.length||(_._CreateMorphTargetAnimationFromMorphTargetAnimations(t,s,u,i,a._nodes,r,a._bufferViews,a._accessors,o,a._animationSampleRate),t.animations.length&&_._CreateNodeAnimationFromNodeAnimations(t,s,u,i,a._nodes,r,a._bufferViews,a._accessors,o,a._animationSampleRate)))}))}))}))},c=0,f=t;c<f.length;c++)l(f[c]);return o.then((function(){return s.channels.length&&s.samplers.length&&a._animations.push(s),u.forEach((function(e){e.channels.length&&e.samplers.length&&a._animations.push(e)})),e.animationGroups.length&&_._CreateNodeAndMorphAnimationFromAnimationGroups(e,a._animations,i,a._nodes,r,a._bufferViews,a._accessors,a._convertToRightHandedSystemMap,a._animationSampleRate),i}))},e.prototype._createNodeAsync=function(e,t,r){var n=this;return Promise.resolve().then((function(){var a={},o={primitives:[]};if(e.name&&(a.name=e.name),e instanceof d.TransformNode){if(n._setNodeTransformation(a,e,r),e instanceof d.Mesh){var i=e.morphTargetManager;if(i&&i.numTargets>0){o.weights=[];for(var s=0;s<i.numTargets;++s)o.weights.push(i.getTarget(s).influence)}}return n._setPrimitiveAttributesAsync(o,e,t,r).then((function(){return o.primitives.length&&(n._meshes.push(o),a.mesh=n._meshes.length-1),a}))}return e instanceof d.Camera?(n._setCameraTransformation(a,e,r),a):a}))},e.prototype._createSkinsAsync=function(e,t,r){for(var n,a=Promise.resolve(),o={},i=0,s=e.skeletons;i<s.length;i++){for(var u=s[i],l={joints:[]},c=[],f={},h=-1,p=0;p<u.bones.length;++p)-1!==(g=null!==(n=(_=u.bones[p]).getIndex())&&void 0!==n?n:p)&&(f[g]=_,g>h&&(h=g));for(var g=0;g<=h;++g){var _=f[g];c.push(_.getInvertedAbsoluteTransform());var x=_.getTransformNode();x?l.joints.push(t[x.uniqueId]):d.Tools.Warn("Exporting a bone without a linked transform node is currently unsupported")}var y=64*c.length,T=r.getByteOffset(),v=m._CreateBufferView(0,T,y,void 0,"InverseBindMatrices - "+u.name);this._bufferViews.push(v);var A=this._bufferViews.length-1,b=m._CreateAccessor(A,"InverseBindMatrices - "+u.name,"MAT4",5126,c.length,null,null,null),F=this._accessors.push(b)-1;l.inverseBindMatrices=F,this._skins.push(l),o[u.uniqueId]=this._skins.length-1,c.forEach((function(e){e.m.forEach((function(e){r.setFloat32(e)}))}))}return a.then((function(){return o}))},e._ExtensionNames=new Array,e._ExtensionFactories={},e}(),y=function(){function e(e){this._arrayBuffer=new ArrayBuffer(e),this._dataView=new DataView(this._arrayBuffer),this._byteOffset=0}return e.prototype._resizeBuffer=function(e){for(var t=new ArrayBuffer(e),r=new Uint8Array(this._arrayBuffer),n=new Uint8Array(t),a=0,o=n.byteLength;a<o;++a)n[a]=r[a];return this._arrayBuffer=t,this._dataView=new DataView(this._arrayBuffer),t},e.prototype.getArrayBuffer=function(){return this._resizeBuffer(this.getByteOffset())},e.prototype.getByteOffset=function(){if(null==this._byteOffset)throw new Error("Byte offset is undefined!");return this._byteOffset},e.prototype.setUInt8=function(e,t){null!=t?t<this._byteOffset?this._dataView.setUint8(t,e):d.Tools.Error("BinaryWriter: byteoffset is greater than the current binary buffer length!"):(this._byteOffset+1>this._arrayBuffer.byteLength&&this._resizeBuffer(2*this._arrayBuffer.byteLength),this._dataView.setUint8(this._byteOffset,e),this._byteOffset+=1)},e.prototype.setUInt16=function(e,t){null!=t?t<this._byteOffset?this._dataView.setUint16(t,e,!0):d.Tools.Error("BinaryWriter: byteoffset is greater than the current binary buffer length!"):(this._byteOffset+2>this._arrayBuffer.byteLength&&this._resizeBuffer(2*this._arrayBuffer.byteLength),this._dataView.setUint16(this._byteOffset,e,!0),this._byteOffset+=2)},e.prototype.getUInt32=function(e){if(e<this._byteOffset)return this._dataView.getUint32(e,!0);throw d.Tools.Error("BinaryWriter: byteoffset is greater than the current binary buffer length!"),new Error("BinaryWriter: byteoffset is greater than the current binary buffer length!")},e.prototype.getVector3Float32FromRef=function(e,t){t+8>this._byteOffset?d.Tools.Error("BinaryWriter: byteoffset is greater than the current binary buffer length!"):(e.x=this._dataView.getFloat32(t,!0),e.y=this._dataView.getFloat32(t+4,!0),e.z=this._dataView.getFloat32(t+8,!0))},e.prototype.setVector3Float32FromRef=function(e,t){t+8>this._byteOffset?d.Tools.Error("BinaryWriter: byteoffset is greater than the current binary buffer length!"):(this._dataView.setFloat32(t,e.x,!0),this._dataView.setFloat32(t+4,e.y,!0),this._dataView.setFloat32(t+8,e.z,!0))},e.prototype.getVector4Float32FromRef=function(e,t){t+12>this._byteOffset?d.Tools.Error("BinaryWriter: byteoffset is greater than the current binary buffer length!"):(e.x=this._dataView.getFloat32(t,!0),e.y=this._dataView.getFloat32(t+4,!0),e.z=this._dataView.getFloat32(t+8,!0),e.w=this._dataView.getFloat32(t+12,!0))},e.prototype.setVector4Float32FromRef=function(e,t){t+12>this._byteOffset?d.Tools.Error("BinaryWriter: byteoffset is greater than the current binary buffer length!"):(this._dataView.setFloat32(t,e.x,!0),this._dataView.setFloat32(t+4,e.y,!0),this._dataView.setFloat32(t+8,e.z,!0),this._dataView.setFloat32(t+12,e.w,!0))},e.prototype.setFloat32=function(e,t){isNaN(e)&&d.Tools.Error("Invalid data being written!"),null!=t&&(t<this._byteOffset?this._dataView.setFloat32(t,e,!0):d.Tools.Error("BinaryWriter: byteoffset is greater than the current binary length!")),this._byteOffset+4>this._arrayBuffer.byteLength&&this._resizeBuffer(2*this._arrayBuffer.byteLength),this._dataView.setFloat32(this._byteOffset,e,!0),this._byteOffset+=4},e.prototype.setUInt32=function(e,t){null!=t?t<this._byteOffset?this._dataView.setUint32(t,e,!0):d.Tools.Error("BinaryWriter: byteoffset is greater than the current binary buffer length!"):(this._byteOffset+4>this._arrayBuffer.byteLength&&this._resizeBuffer(2*this._arrayBuffer.byteLength),this._dataView.setUint32(this._byteOffset,e,!0),this._byteOffset+=4)},e}(),T=function(){function e(){}return e.GLTFAsync=function(e,t,r){return e.whenReadyAsync().then((function(){var n=t.replace(/\.[^/.]+$/,"");return new x(e,r)._generateGLTFAsync(n)}))},e._PreExportAsync=function(e,t){return Promise.resolve().then((function(){return t&&t.exportWithoutWaitingForScene?Promise.resolve():e.whenReadyAsync()}))},e._PostExportAsync=function(e,t,r){return Promise.resolve().then((function(){return r&&r.exportWithoutWaitingForScene,t}))},e.GLBAsync=function(e,t,r){var n=this;return this._PreExportAsync(e,r).then((function(){var a=t.replace(/\.[^/.]+$/,"");return new x(e,r)._generateGLBAsync(a).then((function(t){return n._PostExportAsync(e,t,r)}))}))},e}();d.ShaderStore.ShadersStore.textureTransformPixelShader="precision highp float;varying vec2 vUV;uniform sampler2D textureSampler;uniform mat4 textureTransformMat;void main(void) {\n#define CUSTOM_FRAGMENT_MAIN_BEGIN\nvec2 uvTransformed=(textureTransformMat*vec4(vUV.xy,1,1)).xy;gl_FragColor=texture2D(textureSampler,uvTransformed);\n#define CUSTOM_FRAGMENT_MAIN_END\n}";var v="KHR_texture_transform",A=function(){function e(){this._recordedTextures=[],this.name=v,this.enabled=!0,this.required=!1,this._wasUsed=!1}return e.prototype.dispose=function(){for(var e=0,t=this._recordedTextures;e<t.length;e++)t[e].dispose()},Object.defineProperty(e.prototype,"wasUsed",{get:function(){return this._wasUsed},enumerable:!1,configurable:!0}),e.prototype.postExportTexture=function(e,t,r){if(r&&(0===r.uAng&&0===r.wAng&&0===r.vAng||0===r.uRotationCenter&&0===r.vRotationCenter)){var n={},a=!1;if(0===r.uOffset&&0===r.vOffset||(n.offset=[r.uOffset,r.vOffset],a=!0),1===r.uScale&&1===r.vScale||(n.scale=[r.uScale,r.vScale],a=!0),0!==r.wAng&&(n.rotation=r.wAng,a=!0),0!==r.coordinatesIndex&&(n.texCoord=r.coordinatesIndex,a=!0),!a)return;this._wasUsed=!0,t.extensions||(t.extensions={}),t.extensions[v]=n}},e.prototype.preExportTextureAsync=function(e,t){var r=this;return new Promise((function(n,a){var o=t.getScene();if(o){var i=!1;if(0===t.uAng&&0===t.wAng&&0===t.vAng||0===t.uRotationCenter&&0===t.vRotationCenter||(i=!0),i)return r._textureTransformTextureAsync(t,o).then((function(e){n(e)})).catch((function(e){a(e)}));n(t)}else a("".concat(e,': "scene" is not defined for Babylon texture ').concat(t.name,"!"))}))},e.prototype._textureTransformTextureAsync=function(e,t){var r=this;return new Promise((function(n){var a=new d.ProceduralTexture("".concat(e.name),e.getSize(),"textureTransform",t);a||(d.Tools.Log("Cannot create procedural texture for ".concat(e.name,"!")),n(e)),a.reservedDataStore={hidden:!0,source:e},r._recordedTextures.push(a),a.coordinatesIndex=e.coordinatesIndex,a.setTexture("textureSampler",e),a.setMatrix("textureTransformMat",e.getTextureMatrix()),a.isReady()?(a.render(),n(a)):a.getEffect().executeWhenCompiled((function(){a.render(),n(a)}))}))},e}();x.RegisterExtension(v,(function(){return new A}));var b="KHR_lights_punctual",F=function(){function e(e){this.name=b,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.KHR_lights_punctual=this._lights},e.prototype.postExportNodeAsync=function(e,t,r,n){var a=this;return new Promise((function(o){if(t&&r instanceof d.ShadowLight){var i=r,s=void 0,u=i.getTypeID()==d.Light.LIGHTTYPEID_POINTLIGHT?"point":i.getTypeID()==d.Light.LIGHTTYPEID_DIRECTIONALLIGHT?"directional":i.getTypeID()==d.Light.LIGHTTYPEID_SPOTLIGHT?"spot":null;if(null==u)d.Logger.Warn("".concat(e,": Light ").concat(i.name," is not supported in ").concat(b));else{var l=i.position.clone(),c=a._exporter._convertToRightHandedSystemMap[r.uniqueId];if(l.equals(d.Vector3.Zero())||(c&&m._GetRightHandedPositionVector3FromRef(l),t.translation=l.asArray()),"point"!==u){var f=i.direction,h=-Math.atan2(f.z*(a._exporter._babylonScene.useRightHandedSystem?-1:1),f.x)+Math.PI/2,p=Math.sqrt(f.x*f.x+f.z*f.z),g=-Math.atan2(f.y,p),_=d.Quaternion.RotationYawPitchRoll(h,g,0);c&&m._GetRightHandedQuaternionFromRef(_),_.equals(d.Quaternion.Identity())||(t.rotation=_.asArray())}if(i.falloffType!==d.Light.FALLOFF_GLTF&&d.Logger.Warn("".concat(e,": Light falloff for ").concat(i.name," does not match the ").concat(b," specification!")),s={type:u},i.diffuse.equals(d.Color3.White())||(s.color=i.diffuse.asArray()),1!==i.intensity&&(s.intensity=i.intensity),i.range!==Number.MAX_VALUE&&(s.range=i.range),"spot"===u){var x=i;x.angle!==Math.PI/2&&(null==s.spot&&(s.spot={}),s.spot.outerConeAngle=x.angle/2),0!==x.innerAngle&&(null==s.spot&&(s.spot={}),s.spot.innerConeAngle=x.innerAngle/2)}null==a._lights&&(a._lights={lights:[]}),a._lights.lights.push(s);var y={light:a._lights.lights.length-1},T=r.parent;if(T&&1==T.getChildren().length){var v=a._exporter._nodes[n[T.uniqueId]];if(v){var A=d.TmpVectors.Matrix[0],F=d.TmpVectors.Matrix[1],E=v.translation?new d.Vector3(v.translation[0],v.translation[1],v.translation[2]):d.Vector3.Zero(),M=v.rotation?new d.Quaternion(v.rotation[0],v.rotation[1],v.rotation[2],v.rotation[3]):d.Quaternion.Identity(),R=v.scale?new d.Vector3(v.scale[0],v.scale[1],v.scale[2]):d.Vector3.One();d.Matrix.ComposeToRef(R,M,E,A),A.invertToRef(F);var C=d.TmpVectors.Matrix[2],V=t.translation?new d.Vector3(t.translation[0],t.translation[1],t.translation[2]):d.Vector3.Zero();i instanceof d.DirectionalLight&&V.subtractInPlace(a._exporter._babylonScene.useRightHandedSystem?i.direction:m._GetRightHandedPositionVector3(i.direction));var w=a._exporter._babylonScene.useRightHandedSystem?d.Quaternion.Identity():new d.Quaternion(0,1,0,0);t.rotation&&w.multiplyInPlace(new d.Quaternion(t.rotation[0],t.rotation[1],t.rotation[2],t.rotation[3]));var S=t.scale?new d.Vector3(t.scale[0],t.scale[1],t.scale[2]):d.Vector3.One();d.Matrix.ComposeToRef(S,w,V,C),C.multiplyToRef(F,C);var B=d.TmpVectors.Vector3[0],I=d.TmpVectors.Quaternion[0],P=d.TmpVectors.Vector3[1];return C.decompose(B,I,P),v.scale=B.asArray(),v.rotation=I.asArray(),v.translation=P.asArray(),null==v.extensions&&(v.extensions={}),v.extensions.KHR_lights_punctual=y,void o(null)}}null==t.extensions&&(t.extensions={}),t.extensions.KHR_lights_punctual=y}}o(t)}))},e}();x.RegisterExtension(b,(function(e){return new F(e)}));var E="KHR_materials_clearcoat",M=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.postExportMaterialAdditionalTextures=function(e,t,r){var n=[];return r instanceof d.PBRBaseMaterial&&r.clearCoat.isEnabled?(r.clearCoat.texture&&n.push(r.clearCoat.texture),!r.clearCoat.useRoughnessFromMainTexture&&r.clearCoat.textureRoughness&&n.push(r.clearCoat.textureRoughness),r.clearCoat.bumpTexture&&n.push(r.clearCoat.bumpTexture),n):[]},e.prototype.postExportMaterialAsync=function(e,t,r){var n=this;return new Promise((function(e){if(r instanceof d.PBRBaseMaterial){if(!r.clearCoat.isEnabled)return void e(t);n._wasUsed=!0,t.extensions=t.extensions||{};var a,o=n._exporter._glTFMaterialExporter._getTextureInfo(r.clearCoat.texture);a=r.clearCoat.useRoughnessFromMainTexture?n._exporter._glTFMaterialExporter._getTextureInfo(r.clearCoat.texture):n._exporter._glTFMaterialExporter._getTextureInfo(r.clearCoat.textureRoughness),r.clearCoat.isTintEnabled&&d.Tools.Warn("Clear Color tint is not supported for glTF export. Ignoring for: ".concat(r.name)),r.clearCoat.remapF0OnInterfaceChange&&d.Tools.Warn("Clear Color F0 remapping is not supported for glTF export. Ignoring for: ".concat(r.name));var i=n._exporter._glTFMaterialExporter._getTextureInfo(r.clearCoat.bumpTexture),s={clearcoatFactor:r.clearCoat.intensity,clearcoatTexture:null!=o?o:void 0,clearcoatRoughnessFactor:r.clearCoat.roughness,clearcoatRoughnessTexture:null!=a?a:void 0,clearcoatNormalTexture:null!=i?i:void 0,hasTextures:function(){return null!==s.clearcoatTexture||null!==s.clearcoatRoughnessTexture||null!==s.clearcoatRoughnessTexture}};t.extensions.KHR_materials_clearcoat=s}e(t)}))},e}();x.RegisterExtension(E,(function(e){return new M(e)}));var R="KHR_materials_iridescence",C=function(){function e(e){this.name=R,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.postExportMaterialAdditionalTextures=function(e,t,r){var n=[];return r instanceof d.PBRBaseMaterial&&r.iridescence.isEnabled?(r.iridescence.texture&&n.push(r.iridescence.texture),r.iridescence.thicknessTexture&&r.iridescence.thicknessTexture!==r.iridescence.texture&&n.push(r.iridescence.thicknessTexture),n):[]},e.prototype.postExportMaterialAsync=function(e,t,r){var n=this;return new Promise((function(e){if(r instanceof d.PBRBaseMaterial){if(!r.iridescence.isEnabled)return void e(t);n._wasUsed=!0,t.extensions=t.extensions||{};var a=n._exporter._glTFMaterialExporter._getTextureInfo(r.iridescence.texture),o=n._exporter._glTFMaterialExporter._getTextureInfo(r.iridescence.thicknessTexture),i={iridescenceFactor:r.iridescence.intensity,iridescenceIor:r.iridescence.indexOfRefraction,iridescenceThicknessMinimum:r.iridescence.minimumThickness,iridescenceThicknessMaximum:r.iridescence.maximumThickness,iridescenceTexture:null!=a?a:void 0,iridescenceThicknessTexture:null!=o?o:void 0,hasTextures:function(){return null!==i.iridescenceTexture||null!==i.iridescenceThicknessTexture}};t.extensions.KHR_materials_iridescence=i}e(t)}))},e}();x.RegisterExtension(R,(function(e){return new C(e)}));var V="KHR_materials_sheen",w=function(){function e(e){this.name=V,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.postExportMaterialAdditionalTextures=function(e,t,r){return r instanceof d.PBRMaterial&&r.sheen.isEnabled&&r.sheen.texture?[r.sheen.texture]:[]},e.prototype.postExportMaterialAsync=function(e,t,r){var n=this;return new Promise((function(e){var a,o,i,s;if(r instanceof d.PBRMaterial){if(!r.sheen.isEnabled)return void e(t);n._wasUsed=!0,null==t.extensions&&(t.extensions={});var u={sheenColorFactor:r.sheen.color.asArray(),sheenRoughnessFactor:null!==(a=r.sheen.roughness)&&void 0!==a?a:0,hasTextures:function(){return null!==u.sheenColorTexture||null!==u.sheenRoughnessTexture}};r.sheen.texture&&(u.sheenColorTexture=null!==(o=n._exporter._glTFMaterialExporter._getTextureInfo(r.sheen.texture))&&void 0!==o?o:void 0),r.sheen.textureRoughness&&!r.sheen.useRoughnessFromMainTexture?u.sheenRoughnessTexture=null!==(i=n._exporter._glTFMaterialExporter._getTextureInfo(r.sheen.textureRoughness))&&void 0!==i?i:void 0:r.sheen.texture&&r.sheen.useRoughnessFromMainTexture&&(u.sheenRoughnessTexture=null!==(s=n._exporter._glTFMaterialExporter._getTextureInfo(r.sheen.texture))&&void 0!==s?s:void 0),t.extensions.KHR_materials_sheen=u}e(t)}))},e}();x.RegisterExtension(V,(function(e){return new w(e)}));var S="KHR_materials_unlit",B=function(){function e(){this.name=S,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 a=!1;r instanceof d.PBRMaterial?a=r.unlit:r instanceof d.StandardMaterial&&(a=r.disableLighting),a&&(n._wasUsed=!0,null==t.extensions&&(t.extensions={}),t.extensions.KHR_materials_unlit={}),e(t)}))},e}();x.RegisterExtension(S,(function(){return new B}));var I="KHR_materials_specular",P=function(){function e(e){this.name=I,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.postExportMaterialAdditionalTextures=function(e,t,r){var n=[];return r instanceof d.PBRMaterial&&this._isExtensionEnabled(r)?(r.metallicReflectanceTexture&&n.push(r.metallicReflectanceTexture),r.reflectanceTexture&&n.push(r.reflectanceTexture),n):n},e.prototype._isExtensionEnabled=function(e){return 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 a,o;if(r instanceof d.PBRMaterial&&n._isExtensionEnabled(r)){n._wasUsed=!0,t.extensions=t.extensions||{};var i=null!==(a=n._exporter._glTFMaterialExporter._getTextureInfo(r.metallicReflectanceTexture))&&void 0!==a?a:void 0,s=null!==(o=n._exporter._glTFMaterialExporter._getTextureInfo(r.reflectanceTexture))&&void 0!==o?o:void 0,u={specularFactor:1==r.metallicF0Factor?void 0:r.metallicF0Factor,specularTexture:i,specularColorFactor:r.metallicReflectanceColor.equalsFloats(1,1,1)?void 0:r.metallicReflectanceColor.asArray(),specularColorTexture:s,hasTextures:function(){return n._hasTexturesExtension(r)}};t.extensions.KHR_materials_specular=u}e(t)}))},e}();x.RegisterExtension(I,(function(e){return new P(e)}));var N=0,L=void 0!==n.g?n.g:"undefined"!=typeof window?window:void 0;if(void 0!==L){L.BABYLON=L.BABYLON||{};var O=L.BABYLON;O.GLTF2=O.GLTF2||{},O.GLTF2.Exporter=O.GLTF2.Exporter||{},O.GLTF2.Exporter.Extensions=O.GLTF2.Exporter.Extensions||{};var k=[];for(var G in e)O[G]=e[G],k.push(G);for(var G in t)O[G]=t[G],k.push(G);for(var G in r)O[G]=r[G],k.push(G);for(var G in o)O.GLTF2.Exporter.Extensions[G]=o[G],k.push(G);for(var G in i)k.indexOf(G)>-1||(O.GLTF2.Exporter[G]=i[G])}const U=s})(),a.default})()}));
|
|
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,(function(e){return(()=>{"use strict";var t={520:t=>{t.exports=e}},r={};function n(e){var a=r[e];if(void 0!==a)return a.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 a={};return(()=>{n.d(a,{default:()=>q});var e={};n.r(e),n.d(e,{__IGLTFExporterExtension:()=>u});var t={};n.r(t),n.d(t,{GLTFData:()=>l});var r={};n.r(r),n.d(r,{GLTF2Export:()=>T});var o={};n.r(o),n.d(o,{KHR_lights_punctual:()=>E,KHR_materials_clearcoat:()=>M,KHR_materials_ior:()=>P,KHR_materials_iridescence:()=>w,KHR_materials_sheen:()=>V,KHR_materials_specular:()=>L,KHR_materials_transmission:()=>K,KHR_materials_unlit:()=>B,KHR_materials_volume:()=>k,KHR_texture_transform:()=>b});var i={};n.r(i),n.d(i,{GLTF2Export:()=>T,GLTFData:()=>l,KHR_lights_punctual:()=>E,KHR_materials_clearcoat:()=>M,KHR_materials_ior:()=>P,KHR_materials_iridescence:()=>w,KHR_materials_sheen:()=>V,KHR_materials_specular:()=>L,KHR_materials_transmission:()=>K,KHR_materials_unlit:()=>B,KHR_materials_volume:()=>k,KHR_texture_transform:()=>b,_BinaryWriter:()=>y,_Exporter:()=>x,_GLTFAnimation:()=>g,_GLTFMaterialExporter:()=>m,_GLTFUtilities:()=>_,__IGLTFExporterExtensionV2:()=>G});var s={};n.r(s),n.d(s,{GLTF2Export:()=>T,GLTFData:()=>l,KHR_lights_punctual:()=>E,KHR_materials_clearcoat:()=>M,KHR_materials_ior:()=>P,KHR_materials_iridescence:()=>w,KHR_materials_sheen:()=>V,KHR_materials_specular:()=>L,KHR_materials_transmission:()=>K,KHR_materials_unlit:()=>B,KHR_materials_volume:()=>k,KHR_texture_transform:()=>b,_BinaryWriter:()=>y,_Exporter:()=>x,_GLTFAnimation:()=>g,_GLTFMaterialExporter:()=>m,_GLTFUtilities:()=>_,__IGLTFExporterExtension:()=>u,__IGLTFExporterExtensionV2:()=>G});var u=0,l=function(){function e(){this.glTFFiles={}}return e.prototype.downloadFiles=function(){function e(e,t){return-1!==e.indexOf(t,e.length-t.length)}for(var t in this.glTFFiles){var r=document.createElement("a");document.body.appendChild(r),r.setAttribute("type","hidden"),r.download=t;var n=this.glTFFiles[t],a=void 0;e(t,".glb")?a={type:"model/gltf-binary"}:e(t,".bin")?a={type:"application/octet-stream"}:e(t,".gltf")?a={type:"model/gltf+json"}:e(t,".jpeg")||e(t,".jpg")?a={type:"image/jpeg"}:e(t,".png")&&(a={type:"image/png"}),r.href=window.URL.createObjectURL(new Blob([n],a)),r.click()}},e}();function c(e,t,r,n){return new(r||(r=Promise))((function(a,o){function i(e){try{u(n.next(e))}catch(e){o(e)}}function s(e){try{u(n.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?a(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(i,s)}u((n=n.apply(e,t||[])).next())}))}function f(e,t){var r,n,a,o,i={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(r)throw new TypeError("Generator is already executing.");for(;i;)try{if(r=1,n&&(a=2&o[0]?n.return:o[0]?n.throw||((a=n.return)&&a.call(n),0):n.next)&&!(a=a.call(n,o[1])).done)return a;switch(n=0,a&&(o=[2&o[0],a.value]),o[0]){case 0:case 1:a=o;break;case 4:return i.label++,{value:o[1],done:!1};case 5:i.label++,n=o[1],o=[0];continue;case 7:o=i.ops.pop(),i.trys.pop();continue;default:if(!((a=(a=i.trys).length>0&&a[a.length-1])||6!==o[0]&&2!==o[0])){i=0;continue}if(3===o[0]&&(!a||o[1]>a[0]&&o[1]<a[3])){i.label=o[1];break}if(6===o[0]&&i.label<a[1]){i.label=a[1],a=o;break}if(a&&i.label<a[2]){i.label=a[2],i.ops.push(o);break}a[2]&&i.ops.pop(),i.trys.pop();continue}o=t.call(e,i)}catch(e){o=[6,e],n=0}finally{r=a=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,s])}}}function h(e,t,r){if(r||2===arguments.length)for(var n,a=0,o=t.length;a<o;a++)!n&&a in t||(n||(n=Array.prototype.slice.call(t,0,a)),n[a]=t[a]);return e.concat(n||Array.prototype.slice.call(t))}Object.create,Object.create;var p,d=n(520),m=function(){function e(e){this._textureMap={},this._textureMap={},this._exporter=e}return e._FuzzyEquals=function(e,t,r){return d.Scalar.WithinEpsilon(e.r,t.r,r)&&d.Scalar.WithinEpsilon(e.g,t.g,r)&&d.Scalar.WithinEpsilon(e.b,t.b,r)},e.prototype._convertMaterialsToGLTFAsync=function(e,t,r){var n=this,a=[];return e.forEach((function(e){"StandardMaterial"===e.getClassName()?a.push(n._convertStandardMaterialAsync(e,t,r)):-1!==e.getClassName().indexOf("PBR")?a.push(n._convertPBRMaterialAsync(e,t,r)):d.Tools.Warn("Unsupported material type: ".concat(e.name))})),Promise.all(a).then((function(){}))},e.prototype._stripTexturesFromMaterial=function(e){var t={};if(e){t.name=e.name,t.doubleSided=e.doubleSided,t.alphaMode=e.alphaMode,t.alphaCutoff=e.alphaCutoff,t.emissiveFactor=e.emissiveFactor;var r=e.pbrMetallicRoughness;r&&(t.pbrMetallicRoughness={},t.pbrMetallicRoughness.baseColorFactor=r.baseColorFactor,t.pbrMetallicRoughness.metallicFactor=r.metallicFactor,t.pbrMetallicRoughness.roughnessFactor=r.roughnessFactor)}return t},e.prototype._hasTexturesPresent=function(e){var t;if(e.emissiveTexture||e.normalTexture||e.occlusionTexture)return!0;var r=e.pbrMetallicRoughness;if(r&&(r.baseColorTexture||r.metallicRoughnessTexture))return!0;if(e.extensions)for(var n in e.extensions){var a=e.extensions[n];if(a)return null===(t=a.hasTextures)||void 0===t?void 0:t.call(a)}return!1},e.prototype._getTextureInfo=function(e){if(e){var t=e.uid;if(t in this._textureMap)return this._textureMap[t]}return null},e.prototype._convertToGLTFPBRMetallicRoughness=function(t){var r,n,a,o,i,s,u=new d.Vector2(0,1),l=new d.Vector2(0,.1),c=new d.Vector2(0,.1),f=new d.Vector2(1300,.1),h=t.diffuseColor.toLinearSpace().scale(.5),p=t.alpha,m=(r=d.Scalar.Clamp(t.specularPower,0,e._MaxSpecularPower),n=Math.pow(r/f.x,.333333),a=u.y,o=l.y,i=c.y,s=f.y,(1-n)*(1-n)*(1-n)*a+3*(1-n)*(1-n)*n*o+3*(1-n)*n*n*i+n*n*n*s);return{baseColorFactor:[h.r,h.g,h.b,p],metallicFactor:0,roughnessFactor:m}},e._SolveMetallic=function(e,t,r){if(t<this._DielectricSpecular.r)return this._DielectricSpecular,0;var n=this._DielectricSpecular.r,a=e*r/(1-this._DielectricSpecular.r)+t-2*this._DielectricSpecular.r,o=a*a-4*n*(this._DielectricSpecular.r-t);return d.Scalar.Clamp((-a+Math.sqrt(o))/(2*n),0,1)},e._SetAlphaMode=function(e,t){t.needAlphaBlending()?e.alphaMode="BLEND":t.needAlphaTesting()&&(e.alphaMode="MASK",e.alphaCutoff=t.alphaCutOff)},e.prototype._convertStandardMaterialAsync=function(t,r,n){var a=this._exporter._materialMap,o=this._exporter._materials,i=[],s=this._convertToGLTFPBRMetallicRoughness(t),u={name:t.name};return null==t.backFaceCulling||t.backFaceCulling||(t.twoSidedLighting||d.Tools.Warn(t.name+": Back-face culling disabled and two-sided lighting disabled is not supported in glTF."),u.doubleSided=!0),n&&(t.diffuseTexture&&i.push(this._exportTextureAsync(t.diffuseTexture,r).then((function(e){e&&(s.baseColorTexture=e)}))),t.bumpTexture&&i.push(this._exportTextureAsync(t.bumpTexture,r).then((function(e){e&&(u.normalTexture=e,null!=t.bumpTexture&&1!==t.bumpTexture.level&&(u.normalTexture.scale=t.bumpTexture.level))}))),t.emissiveTexture&&(u.emissiveFactor=[1,1,1],i.push(this._exportTextureAsync(t.emissiveTexture,r).then((function(e){e&&(u.emissiveTexture=e)})))),t.ambientTexture&&i.push(this._exportTextureAsync(t.ambientTexture,r).then((function(e){if(e){var t={index:e.index};u.occlusionTexture=t,t.strength=1}})))),(t.alpha<1||t.opacityTexture)&&(t.alphaMode===d.Constants.ALPHA_COMBINE?u.alphaMode="BLEND":d.Tools.Warn(t.name+": glTF 2.0 does not support alpha mode: "+t.alphaMode.toString())),t.emissiveColor&&!e._FuzzyEquals(t.emissiveColor,d.Color3.Black(),e._Epsilon)&&(u.emissiveFactor=t.emissiveColor.asArray()),u.pbrMetallicRoughness=s,e._SetAlphaMode(u,t),o.push(u),a[t.uniqueId]=o.length-1,this._finishMaterial(i,u,t,r)},e.prototype._finishMaterial=function(e,t,r,n){var a=this;return Promise.all(e).then((function(){for(var e=null,o=0,i=a._exporter._extensionsPostExportMaterialAdditionalTextures("exportMaterial",t,r);o<i.length;o++){var s=i[o];e||(e=[]),e.push(a._exportTextureAsync(s,n))}return e||(e=[Promise.resolve(null)]),Promise.all(e).then((function(){var e=a._exporter._extensionsPostExportMaterialAsync("exportMaterial",t,r);return e?e.then((function(){return t})):t}))}))},e.prototype._createBase64FromCanvasAsync=function(e,t,r,n){var a=this;return new Promise((function(o){return c(a,void 0,void 0,(function(){var a,i,s,u,l,c;return f(this,(function(f){switch(f.label){case 0:return a=d.Constants.TEXTURETYPE_UNSIGNED_INT,i=this._exporter._babylonScene,s=i.getEngine(),u=s.createRawTexture(e,t,r,d.Constants.TEXTUREFORMAT_RGBA,!1,!0,d.Texture.NEAREST_SAMPLINGMODE,null,a),[4,d.TextureTools.ApplyPostProcess("pass",u,i,a,d.Constants.TEXTURE_NEAREST_SAMPLINGMODE,d.Constants.TEXTUREFORMAT_RGBA)];case 1:return f.sent(),[4,s._readTexturePixels(u,t,r)];case 2:return l=f.sent(),[4,d.Tools.DumpDataAsync(t,r,l,n,void 0,!0,!1)];case 3:return c=f.sent(),o(c),[2]}}))}))}))},e.prototype._createWhiteTexture=function(e,t,r){for(var n=new Uint8Array(e*t*4),a=0;a<n.length;a+=4)n[a]=n[a+1]=n[a+2]=n[a+3]=255;return d.RawTexture.CreateRGBATexture(n,e,t,r)},e.prototype._resizeTexturesToSameDimensions=function(e,t,r){var n,a,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 d.Texture?d.TextureTools.CreateResizedCopy(e,i.width,i.height,!0):this._createWhiteTexture(i.width,i.height,r),a=t):o.width>i.width?(a=t&&t instanceof d.Texture?d.TextureTools.CreateResizedCopy(t,o.width,o.height,!0):this._createWhiteTexture(o.width,o.height,r),n=e):(n=e,a=t),{texture1:n,texture2:a}},e.prototype._convertPixelArrayToFloat32=function(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!")},e.prototype._convertSpecularGlossinessTexturesToMetallicRoughnessAsync=function(t,r,n,a){var o;return c(this,void 0,void 0,(function(){var i,s,u,l,c,h,p,m,_,g,x,y,T,v,b,A,E,F,M,R,w,C,V,S,B,I,P,N,L,O,k,U;return f(this,(function(f){switch(f.label){case 0:return i=[],t||r?(s=t?t.getScene():r?r.getScene():null)?(u=this._resizeTexturesToSameDimensions(t,r,s),l=null===(o=u.texture1)||void 0===o?void 0:o.getSize(),c=void 0,h=void 0,p=l.width,m=l.height,[4,u.texture1.readPixels()]):[3,3]:[2,Promise.reject("_ConvertSpecularGlosinessTexturesToMetallicRoughness: diffuse and specular glossiness textures are not defined!")];case 1:return _=f.sent(),[4,u.texture2.readPixels()];case 2:if(g=f.sent(),!_)return[2,Promise.reject("Failed to retrieve pixels from diffuse texture!")];if(c=this._convertPixelArrayToFloat32(_),!g)return[2,Promise.reject("Failed to retrieve pixels from specular glossiness texture!")];for(h=this._convertPixelArrayToFloat32(g),x=h.byteLength,y=new Uint8Array(x),T=new Uint8Array(x),v=d.Color3.Black(),b=0,A=0,I=0;I<m;++I)for(P=0;P<p;++P)E=4*(p*I+P),F=new d.Color3(c[E],c[E+1],c[E+2]).toLinearSpace().multiply(n.diffuseColor),M=new d.Color3(h[E],h[E+1],h[E+2]).toLinearSpace().multiply(n.specularColor),R=h[E+3]*n.glossiness,w={diffuseColor:F,specularColor:M,glossiness:R},C=this._convertSpecularGlossinessToMetallicRoughness(w),v.r=Math.max(v.r,C.baseColor.r),v.g=Math.max(v.g,C.baseColor.g),v.b=Math.max(v.b,C.baseColor.b),b=Math.max(b,C.metallic),A=Math.max(A,C.roughness),T[E]=255*C.baseColor.r,T[E+1]=255*C.baseColor.g,T[E+2]=255*C.baseColor.b,T[E+3]=u.texture1.hasAlpha?255*c[E+3]:255,y[E]=0,y[E+1]=255*C.roughness,y[E+2]=255*C.metallic,y[E+3]=255;for(V={baseColor:v,metallic:b,roughness:A},S=!1,B=!1,I=0;I<m;++I)for(P=0;P<p;++P)T[N=4*(p*I+P)]/=V.baseColor.r>e._Epsilon?V.baseColor.r:1,T[N+1]/=V.baseColor.g>e._Epsilon?V.baseColor.g:1,T[N+2]/=V.baseColor.b>e._Epsilon?V.baseColor.b:1,L=d.Color3.FromInts(T[N],T[N+1],T[N+2]),O=L.toGammaSpace(),T[N]=255*O.r,T[N+1]=255*O.g,T[N+2]=255*O.b,e._FuzzyEquals(O,d.Color3.White(),e._Epsilon)||(B=!0),y[N+1]/=V.roughness>e._Epsilon?V.roughness:1,y[N+2]/=V.metallic>e._Epsilon?V.metallic:1,k=d.Color3.FromInts(255,y[N+1],y[N+2]),e._FuzzyEquals(k,d.Color3.White(),e._Epsilon)||(S=!0);return S&&(U=this._createBase64FromCanvasAsync(y,p,m,a).then((function(e){V.metallicRoughnessTextureBase64=e})),i.push(U)),B&&(U=this._createBase64FromCanvasAsync(T,p,m,a).then((function(e){V.baseColorTextureBase64=e})),i.push(U)),[2,Promise.all(i).then((function(){return V}))];case 3:return[2,Promise.reject("_ConvertSpecularGlossinessTexturesToMetallicRoughness: Scene from textures is missing!")]}}))}))},e.prototype._convertSpecularGlossinessToMetallicRoughness=function(t){var r=this._getPerceivedBrightness(t.diffuseColor),n=this._getPerceivedBrightness(t.specularColor),a=1-this._getMaxComponent(t.specularColor),o=e._SolveMetallic(r,n,a),i=t.diffuseColor.scale(a/(1-e._DielectricSpecular.r)/Math.max(1-o,e._Epsilon)),s=t.specularColor.subtract(e._DielectricSpecular.scale(1-o)).scale(1/Math.max(o,e._Epsilon)),u=d.Color3.Lerp(i,s,o*o);return{baseColor:u=u.clampToRef(0,1,u),metallic:o,roughness:1-t.glossiness}},e.prototype._getPerceivedBrightness=function(e){return e?Math.sqrt(.299*e.r*e.r+.587*e.g*e.g+.114*e.b*e.b):0},e.prototype._getMaxComponent=function(e){return e?Math.max(e.r,Math.max(e.g,e.b)):0},e.prototype._convertMetalRoughFactorsToMetallicRoughnessAsync=function(e,t,r,n){var a=[],o={baseColor:e._albedoColor,metallic:e._metallic,roughness:e._roughness};if(n){e._albedoTexture&&a.push(this._exportTextureAsync(e._albedoTexture,t).then((function(e){e&&(r.baseColorTexture=e)})));var i=e._metallicTexture;i&&a.push(this._exportTextureAsync(i,t).then((function(e){e&&(r.metallicRoughnessTexture=e)})))}return Promise.all(a).then((function(){return o}))},e.prototype._getGLTFTextureSampler=function(e){var t=this._getGLTFTextureWrapModesSampler(e),r=e instanceof d.Texture?e.samplingMode:null;if(null!=r)switch(r){case d.Texture.LINEAR_LINEAR:t.magFilter=9729,t.minFilter=9729;break;case d.Texture.LINEAR_NEAREST:t.magFilter=9729,t.minFilter=9728;break;case d.Texture.NEAREST_LINEAR:t.magFilter=9728,t.minFilter=9729;break;case d.Texture.NEAREST_LINEAR_MIPLINEAR:t.magFilter=9728,t.minFilter=9987;break;case d.Texture.NEAREST_NEAREST:t.magFilter=9728,t.minFilter=9728;break;case d.Texture.NEAREST_LINEAR_MIPNEAREST:t.magFilter=9728,t.minFilter=9985;break;case d.Texture.LINEAR_NEAREST_MIPNEAREST:t.magFilter=9729,t.minFilter=9984;break;case d.Texture.LINEAR_NEAREST_MIPLINEAR:t.magFilter=9729,t.minFilter=9986;break;case d.Texture.NEAREST_NEAREST_MIPLINEAR:t.magFilter=9728,t.minFilter=9986;break;case d.Texture.LINEAR_LINEAR_MIPLINEAR:t.magFilter=9729,t.minFilter=9987;break;case d.Texture.LINEAR_LINEAR_MIPNEAREST:t.magFilter=9729,t.minFilter=9985;break;case d.Texture.NEAREST_NEAREST_MIPNEAREST:t.magFilter=9728,t.minFilter=9984}return t},e.prototype._getGLTFTextureWrapMode=function(e){switch(e){case d.Texture.WRAP_ADDRESSMODE:return 10497;case d.Texture.CLAMP_ADDRESSMODE:return 33071;case d.Texture.MIRROR_ADDRESSMODE:return 33648;default:return d.Tools.Error("Unsupported Texture Wrap Mode ".concat(e,"!")),10497}},e.prototype._getGLTFTextureWrapModesSampler=function(e){var t=this._getGLTFTextureWrapMode(e instanceof d.Texture?e.wrapU:d.Texture.WRAP_ADDRESSMODE),r=this._getGLTFTextureWrapMode(e instanceof d.Texture?e.wrapV:d.Texture.WRAP_ADDRESSMODE);return 10497===t&&10497===r?{}:{wrapS:t,wrapT:r}},e.prototype._convertSpecGlossFactorsToMetallicRoughnessAsync=function(e,t,r,n){var a=this;return Promise.resolve().then((function(){var o=a._exporter._samplers,i=a._exporter._textures,s={diffuseColor:e._albedoColor,specularColor:e._reflectivityColor,glossiness:e._microSurface},u=null,l=e._albedoTexture,c=e._reflectivityTexture;if(l){var f=a._getGLTFTextureSampler(l);null!=f.magFilter&&null!=f.minFilter&&null!=f.wrapS&&null!=f.wrapT&&(o.push(f),u=o.length-1)}var h=e._useMicroSurfaceFromReflectivityMapAlpha;return c&&!h?Promise.reject("_ConvertPBRMaterial: Glossiness values not included in the reflectivity texture are currently not supported"):(l||c)&&n?a._convertSpecularGlossinessTexturesToMetallicRoughnessAsync(l,c,s,t).then((function(e){if(e.baseColorTextureBase64){var n=a._getTextureInfoFromBase64(e.baseColorTextureBase64,"bjsBaseColorTexture_"+i.length+".png",t,l?l.coordinatesIndex:null,u);n&&(r.baseColorTexture=n)}if(e.metallicRoughnessTextureBase64){var o=a._getTextureInfoFromBase64(e.metallicRoughnessTextureBase64,"bjsMetallicRoughnessTexture_"+i.length+".png",t,c?c.coordinatesIndex:null,u);o&&(r.metallicRoughnessTexture=o)}return e})):a._convertSpecularGlossinessToMetallicRoughness(s)}))},e.prototype._convertPBRMaterialAsync=function(e,t,r){var n=this,a={},o={name:e.name};if(e.isMetallicWorkflow()){var i=e._albedoColor,s=e.alpha;return i&&(a.baseColorFactor=[i.r,i.g,i.b,s]),this._convertMetalRoughFactorsToMetallicRoughnessAsync(e,t,a,r).then((function(i){return n._setMetallicRoughnessPbrMaterial(i,e,o,a,t,r)}))}return this._convertSpecGlossFactorsToMetallicRoughnessAsync(e,t,a,r).then((function(i){return n._setMetallicRoughnessPbrMaterial(i,e,o,a,t,r)}))},e.prototype._setMetallicRoughnessPbrMaterial=function(t,r,n,a,o,i){var s=this._exporter._materialMap,u=this._exporter._materials,l=[];if(t){if(e._SetAlphaMode(n,r),e._FuzzyEquals(t.baseColor,d.Color3.White(),e._Epsilon)&&r.alpha>=e._Epsilon||(a.baseColorFactor=[t.baseColor.r,t.baseColor.g,t.baseColor.b,r.alpha]),null!=t.metallic&&1!==t.metallic&&(a.metallicFactor=t.metallic),null!=t.roughness&&1!==t.roughness&&(a.roughnessFactor=t.roughness),null==r.backFaceCulling||r.backFaceCulling||(r._twoSidedLighting||d.Tools.Warn(r.name+": Back-face culling disabled and two-sided lighting disabled is not supported in glTF."),n.doubleSided=!0),i){var c=r._bumpTexture;if(c){var f=this._exportTextureAsync(c,o).then((function(e){e&&(n.normalTexture=e,1!==c.level&&(n.normalTexture.scale=c.level))}));l.push(f)}var h=r._ambientTexture;h&&(f=this._exportTextureAsync(h,o).then((function(e){if(e){var t={index:e.index,texCoord:e.texCoord};n.occlusionTexture=t;var a=r._ambientTextureStrength;a&&(t.strength=a)}})),l.push(f));var p=r._emissiveTexture;p&&(f=this._exportTextureAsync(p,o).then((function(e){e&&(n.emissiveTexture=e)})),l.push(f))}var m=r._emissiveColor;e._FuzzyEquals(m,d.Color3.Black(),e._Epsilon)||(n.emissiveFactor=m.asArray()),n.pbrMetallicRoughness=a,u.push(n),s[r.uniqueId]=u.length-1}return this._finishMaterial(l,n,r,o)},e.prototype._getPixelsFromTexture=function(e){return e.textureType,d.Constants.TEXTURETYPE_UNSIGNED_INT,e.readPixels()},e.prototype._exportTextureAsync=function(e,t){var r=this,n=this._exporter._extensionsPreExportTextureAsync("exporter",e,t);return n?n.then((function(n){return n?r._exportTextureInfoAsync(n,t):r._exportTextureInfoAsync(e,t)})):this._exportTextureInfoAsync(e,t)},e.prototype._exportTextureInfoAsync=function(e,t){var r=this;return Promise.resolve().then((function(){return c(r,void 0,void 0,(function(){var r,n,a,o,i,s,u,l,c,h=this;return f(this,(function(f){switch(f.label){case 0:return(r=e.uid)in this._textureMap?[2,this._textureMap[r]]:[3,1];case 1:return[4,this._getPixelsFromTexture(e)];case 2:if(!(n=f.sent()))return[2,null];for(a=this._exporter._samplers,o=this._getGLTFTextureSampler(e),i=null,s=null,u=0;u<a.length;++u)if((l=a[u]).minFilter===o.minFilter&&l.magFilter===o.magFilter&&l.wrapS===o.wrapS&&l.wrapT===o.wrapT){s=u;break}if(null==s?(a.push(o),i=a.length-1):i=s,c=e.getSize(),e.mimeType)switch(e.mimeType){case"image/jpeg":t="image/jpeg";break;case"image/png":t="image/png"}return[2,this._createBase64FromCanvasAsync(n,c.width,c.height,t).then((function(n){var a=h._getTextureInfoFromBase64(n,e.name.replace(/\.\/|\/|\.\\|\\/g,"_"),t,e.coordinatesIndex,i);return a&&(h._textureMap[r]=a,h._exporter._extensionsPostExportTextures("linkTextureInfo",a,e)),a}))]}}))}))}))},e.prototype._getTextureInfoFromBase64=function(e,t,r,n,a){var o=this._exporter._textures,i=this._exporter._images,s=this._exporter._imageData,u=null,l={source:i.length,name:t};null!=a&&(l.sampler=a);for(var c=atob(e.split(",")[1]),f=new ArrayBuffer(c.length),h=new Uint8Array(f),p=0,m=c.length;p<m;++p)h[p]=c.charCodeAt(p);var _={data:h,mimeType:r},g="image/jpeg"===r?".jpeg":".png",x=t+g,y=x;if(x in s&&(x="".concat(t,"_").concat(d.Tools.RandomId()).concat(g)),s[x]=_,"image/jpeg"===r||"image/png"===r){var T={name:t,uri:x},v=null;for(p=0;p<i.length;++p)if(i[p].uri===y){v=p;break}null==v?(i.push(T),l.source=i.length-1):l.source=v,o.push(l),u={index:o.length-1},null!=n&&(u.texCoord=n)}else d.Tools.Error("Unsupported texture mime type ".concat(r));return u},e._DielectricSpecular=new d.Color3(.04,.04,.04),e._MaxSpecularPower=1024,e._Epsilon=1e-6,e}(),_=function(){function e(){}return e._CreateBufferView=function(e,t,r,n,a){var o={buffer:e,byteLength:r};return t&&(o.byteOffset=t),a&&(o.name=a),n&&(o.byteStride=n),o},e._CreateAccessor=function(e,t,r,n,a,o,i,s){var u={name:t,bufferView:e,componentType:n,count:a,type:r};return null!=i&&(u.min=i),null!=s&&(u.max=s),null!=o&&(u.byteOffset=o),u},e._CalculateMinMaxPositions=function(t,r,n,a){var o,i,s,u=[1/0,1/0,1/0],l=[-1/0,-1/0,-1/0];if(n)for(var c=r,f=r+n;c<f;++c){o=3*c,i=d.Vector3.FromArray(t,o),a&&e._GetRightHandedPositionVector3FromRef(i),s=i.asArray();for(var h=0;h<3;++h){var p=s[h];p<u[h]&&(u[h]=p),p>l[h]&&(l[h]=p),++o}}return{min:u,max:l}},e._GetRightHandedPositionVector3=function(e){return new d.Vector3(e.x,e.y,-e.z)},e._GetRightHandedPositionVector3FromRef=function(e){e.z*=-1},e._GetRightHandedPositionArray3FromRef=function(e){e[2]*=-1},e._GetRightHandedNormalVector3=function(e){return new d.Vector3(e.x,e.y,-e.z)},e._GetRightHandedNormalVector3FromRef=function(e){e.z*=-1},e._GetRightHandedNormalArray3FromRef=function(e){e[2]*=-1},e._GetRightHandedVector4FromRef=function(e){e.z*=-1,e.w*=-1},e._GetRightHandedArray4FromRef=function(e){e[2]*=-1,e[3]*=-1},e._GetRightHandedQuaternionFromRef=function(e){e.x*=-1,e.y*=-1},e._GetRightHandedQuaternionArrayFromRef=function(e){e[0]*=-1,e[1]*=-1},e._NormalizeTangentFromRef=function(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)},e._GetDataAccessorElementCount=function(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}},e}();!function(e){e[e.INTANGENT=0]="INTANGENT",e[e.OUTTANGENT=1]="OUTTANGENT"}(p||(p={}));var g=function(){function e(){}return e._CreateNodeAnimation=function(t,r,n,a,o,i){var s=[],u=[],l=r.getKeys(),c=e._CalculateMinMaxKeyFrames(l),f=e._DeduceInterpolation(l,n,o),h=c.max-c.min,p=f.interpolationType,m=f.shouldBakeAnimation;return m?e._CreateBakedAnimation(t,r,n,c.min,c.max,r.framePerSecond,i,s,u,c,a,o):"LINEAR"===p||"STEP"===p?e._CreateLinearOrStepAnimation(t,r,n,h,s,u,a,o):"CUBICSPLINE"===p?e._CreateCubicSplineAnimation(t,r,n,h,s,u,a,o):e._CreateBakedAnimation(t,r,n,c.min,c.max,r.framePerSecond,i,s,u,c,a,o),s.length&&u.length?{inputs:s,outputs:u,samplerInterpolation:p,inputsMin:m?c.min:d.Tools.FloatRound(c.min/r.framePerSecond),inputsMax:m?c.max:d.Tools.FloatRound(c.max/r.framePerSecond)}:null},e._DeduceAnimationInfo=function(e){var t=null,r="VEC3",n=!1,a=e.targetProperty.split(".");switch(a[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:d.Tools.Error("Unsupported animatable property ".concat(a[0]))}return t?{animationChannelTargetPath:t,dataAccessorType:r,useQuaternion:n}:(d.Tools.Error("animation channel target path and data accessor type could be deduced"),null)},e._CreateNodeAnimationFromNodeAnimations=function(t,r,n,a,o,i,s,u,l,c){var f;if(t instanceof d.TransformNode&&t.animations)for(var h=0,p=t.animations;h<p.length;h++){var m=p[h],_=e._DeduceAnimationInfo(m);_&&(f={name:m.name,samplers:[],channels:[]},e._AddAnimation("".concat(m.name),m.hasRunningRuntimeAnimations?r:f,t,m,_.dataAccessorType,_.animationChannelTargetPath,a,i,s,u,l,_.useQuaternion,c),f.samplers.length&&f.channels.length&&n.push(f))}},e._CreateMorphTargetAnimationFromMorphTargetAnimations=function(t,r,n,a,o,i,s,u,l,c){var f;if(t instanceof d.Mesh){var h=t.morphTargetManager;if(h)for(var p=0;p<h.numTargets;++p)for(var m=0,_=h.getTarget(p).animations;m<_.length;m++){for(var g=_[m],x=new d.Animation("".concat(g.name),"influence",g.framePerSecond,g.dataType,g.loopMode,g.enableBlending),y=[],T=g.getKeys(),v=0;v<T.length;++v)for(var b=T[v],A=0;A<h.numTargets;++A)A==p?y.push(b):y.push({frame:b.frame,value:0});x.setKeys(y);var E=e._DeduceAnimationInfo(x);E&&(f={name:x.name,samplers:[],channels:[]},e._AddAnimation(g.name,g.hasRunningRuntimeAnimations?r:f,t,x,E.dataAccessorType,E.animationChannelTargetPath,a,i,s,u,l,E.useQuaternion,c,h.numTargets),f.samplers.length&&f.channels.length&&n.push(f))}}},e._CreateNodeAndMorphAnimationFromAnimationGroups=function(t,r,n,a,o,i,s,u,l){var c,f;if(t.animationGroups)for(var h=function(a){var h=new Map,p=new Map,m=new Set,_=a.to-a.from;f={name:a.name,channels:[],samplers:[]};for(var g=function(r){var _=a.targetedAnimations[r],g=_.target,x=_.animation;if(g instanceof d.TransformNode||1===g.length&&g[0]instanceof d.TransformNode){if(v=e._DeduceAnimationInfo(_.animation)){var y=g instanceof d.TransformNode?g:g[0],T=u[y.uniqueId];e._AddAnimation("".concat(x.name),f,y,x,v.dataAccessorType,v.animationChannelTargetPath,n,o,i,s,T,v.useQuaternion,l)}}else if(g instanceof d.MorphTarget||1===g.length&&g[0]instanceof d.MorphTarget){var v;if(v=e._DeduceAnimationInfo(_.animation)){var b=g instanceof d.MorphTarget?g:g[0];if(b){var A=t.morphTargetManagers.find((function(e){for(var t=0;t<e.numTargets;++t)if(e.getTarget(t)===b)return!0;return!1}));if(A){var E=t.meshes.find((function(e){return e.morphTargetManager===A}));E&&(h.has(E)||h.set(E,new Map),null===(c=h.get(E))||void 0===c||c.set(b,x),m.add(E),p.set(E,x))}}}}},x=0;x<a.targetedAnimations.length;++x)g(x);m.forEach((function(t){for(var r=t.morphTargetManager,u=null,c=[],m=p.get(t).getKeys(),g=m.length,x=0;x<g;++x)for(var y=0;y<r.numTargets;++y){var T=r.getTarget(y),v=h.get(t);if(v){var b=v.get(T);b?(u||(u=new d.Animation("".concat(a.name,"_").concat(t.name,"_MorphWeightAnimation"),"influence",b.framePerSecond,d.Animation.ANIMATIONTYPE_FLOAT,b.loopMode,b.enableBlending)),c.push(b.getKeys()[x])):c.push({frame:a.from+_/g*x,value:T.influence,inTangent:m[0].inTangent?0:void 0,outTangent:m[0].outTangent?0:void 0})}}u.setKeys(c);var A=e._DeduceAnimationInfo(u);A&&e._AddAnimation("".concat(a.name,"_").concat(t.name,"_MorphWeightAnimation"),f,t,u,A.dataAccessorType,A.animationChannelTargetPath,n,o,i,s,!1,A.useQuaternion,l,null==r?void 0:r.numTargets)})),f.channels.length&&f.samplers.length&&r.push(f)},p=0,m=t.animationGroups;p<m.length;p++)h(m[p])},e._AddAnimation=function(t,r,n,a,o,i,s,u,l,c,f,h,p,d){var m,g,x,y,T,v,b,A=e._CreateNodeAnimation(n,a,i,f,h,p);if(A){if(d){for(var E=0,F=0,M=[];A.inputs.length>0;)F=A.inputs.shift(),E%d==0&&M.push(F),E++;A.inputs=M}var R=s[n.uniqueId],w=4*A.inputs.length;m=_._CreateBufferView(0,u.getByteOffset(),w,void 0,"".concat(t," keyframe data view")),l.push(m),A.inputs.forEach((function(e){u.setFloat32(e)})),g=_._CreateAccessor(l.length-1,"".concat(t," keyframes"),"SCALAR",5126,A.inputs.length,null,[A.inputsMin],[A.inputsMax]),c.push(g),x=c.length-1,T=A.outputs.length,w=4*_._GetDataAccessorElementCount(o)*A.outputs.length,m=_._CreateBufferView(0,u.getByteOffset(),w,void 0,"".concat(t," data view")),l.push(m),A.outputs.forEach((function(e){e.forEach((function(e){u.setFloat32(e)}))})),g=_._CreateAccessor(l.length-1,"".concat(t," data"),o,5126,T,null,null,null),c.push(g),y=c.length-1,v={interpolation:A.samplerInterpolation,input:x,output:y},r.samplers.push(v),b={sampler:r.samplers.length-1,target:{node:R,path:i}},r.channels.push(b)}},e._CreateBakedAnimation=function(t,r,n,a,o,i,s,u,l,c,f,h){var p,m,_=d.Quaternion.Identity(),g=null,x=null,y=null,T=null,v=null,b=null;c.min=d.Tools.FloatRound(a/i);for(var A=r.getKeys(),E=0,F=A.length;E<F;++E){if(b=null,y=A[E],E+1<F)if(T=A[E+1],y.value.equals&&y.value.equals(T.value)||y.value===T.value){if(0!==E)continue;b=y.frame}else b=T.frame;else{if(v=A[E-1],y.value.equals&&y.value.equals(v.value)||y.value===v.value)continue;b=o}if(b)for(var M=y.frame;M<=b;M+=s)if((m=d.Tools.FloatRound(M/i))!==g){g=m,x=m;var R={key:0,repeatCount:0,loopMode:r.loopMode};p=r._interpolate(M,R),e._SetInterpolatedValue(t,p,m,r,n,_,u,l,f,h)}}x&&(c.max=x)},e._ConvertFactorToVector3OrQuaternion=function(t,r,n,a,o,i,s){var u,l,c=null,f=e._GetBasePositionRotationOrScale(r,o,i,s);if(a===d.Animation.ANIMATIONTYPE_FLOAT)switch(l=(u=n.targetProperty.split("."))?u[1]:"",c=s?d.Quaternion.FromArray(f).normalize():d.Vector3.FromArray(f),l){case"x":case"y":c[l]=i&&s&&"scale"!==o?-t:t;break;case"z":c[l]=i&&!s&&"scale"!==o?-t:t;break;case"w":c.w=t;break;default:d.Tools.Error('glTFAnimation: Unsupported component type "'.concat(l,'" for scale animation!'))}return c},e._SetInterpolatedValue=function(e,t,r,n,a,o,i,s,u,l){var c,f=n.dataType;i.push(r),"number"==typeof t&&e instanceof d.TransformNode&&(t=this._ConvertFactorToVector3OrQuaternion(t,e,n,f,a,u,l)),t&&("rotation"===a?(l?o=t:(c=t,d.Quaternion.RotationYawPitchRollToRef(c.y,c.x,c.z,o)),u&&(_._GetRightHandedQuaternionFromRef(o),e.parent||(o=d.Quaternion.FromArray([0,1,0,0]).multiply(o))),s.push(o.asArray())):"weights"===a?s.push([t]):(c=t,u&&"scale"!==a&&(_._GetRightHandedPositionVector3FromRef(c),e.parent||(c.x*=-1,c.z*=-1)),s.push(c.asArray())))},e._CreateLinearOrStepAnimation=function(t,r,n,a,o,i,s,u){for(var l=0,c=r.getKeys();l<c.length;l++){var f=c[l];o.push(f.frame/r.framePerSecond),e._AddKeyframeValue(f,r,i,n,t,s,u)}},e._CreateCubicSplineAnimation=function(t,r,n,a,o,i,s,u){r.getKeys().forEach((function(l){o.push(l.frame/r.framePerSecond),e._AddSplineTangent(t,p.INTANGENT,i,n,"CUBICSPLINE",l,a,u,s),e._AddKeyframeValue(l,r,i,n,t,s,u),e._AddSplineTangent(t,p.OUTTANGENT,i,n,"CUBICSPLINE",l,a,u,s)}))},e._GetBasePositionRotationOrScale=function(e,t,r,n){var a;return"rotation"===t?n?e.rotationQuaternion?(a=e.rotationQuaternion.asArray(),r&&(_._GetRightHandedQuaternionArrayFromRef(a),e.parent||(a=d.Quaternion.FromArray([0,1,0,0]).multiply(d.Quaternion.FromArray(a)).asArray()))):a=d.Quaternion.Identity().asArray():(a=e.rotation.asArray(),_._GetRightHandedNormalArray3FromRef(a)):"translation"===t?(a=e.position.asArray(),r&&_._GetRightHandedPositionArray3FromRef(a)):a=e.scaling.asArray(),a},e._AddKeyframeValue=function(e,t,r,n,a,o,i){var s,u,l=t.dataType;if(l===d.Animation.ANIMATIONTYPE_VECTOR3){if(s=e.value.asArray(),"rotation"===n){var c=d.Vector3.FromArray(s),f=d.Quaternion.RotationYawPitchRoll(c.y,c.x,c.z);o&&(_._GetRightHandedQuaternionFromRef(f),a.parent||(f=d.Quaternion.FromArray([0,1,0,0]).multiply(f))),s=f.asArray()}else"translation"===n&&o&&(_._GetRightHandedNormalArray3FromRef(s),a.parent||(s[0]*=-1,s[2]*=-1));r.push(s)}else if(l===d.Animation.ANIMATIONTYPE_FLOAT){if("weights"===n)r.push([e.value]);else if(u=this._ConvertFactorToVector3OrQuaternion(e.value,a,t,l,n,o,i)){if("rotation"===n){var h=i?u:d.Quaternion.RotationYawPitchRoll(u.y,u.x,u.z).normalize();o&&(_._GetRightHandedQuaternionFromRef(h),a.parent||(h=d.Quaternion.FromArray([0,1,0,0]).multiply(h))),r.push(h.asArray())}else"translation"===n&&o&&(_._GetRightHandedNormalVector3FromRef(u),a.parent||(u.x*=-1,u.z*=-1));r.push(u.asArray())}}else l===d.Animation.ANIMATIONTYPE_QUATERNION?(s=e.value.normalize().asArray(),o&&(_._GetRightHandedQuaternionArrayFromRef(s),a.parent||(s=d.Quaternion.FromArray([0,1,0,0]).multiply(d.Quaternion.FromArray(s)).asArray())),r.push(s)):d.Tools.Error("glTFAnimation: Unsupported key frame values for animation!")},e._DeduceInterpolation=function(e,t,r){var n,a,o=!1;if("rotation"===t&&!r)return{interpolationType:"LINEAR",shouldBakeAnimation:!0};for(var i=0,s=e.length;i<s;++i)if((a=e[i]).inTangent||a.outTangent)if(n){if("CUBICSPLINE"!==n){n="LINEAR",o=!0;break}}else n="CUBICSPLINE";else if(n){if("CUBICSPLINE"===n||a.interpolation&&a.interpolation===d.AnimationKeyInterpolation.STEP&&"STEP"!==n){n="LINEAR",o=!0;break}}else n=a.interpolation&&a.interpolation===d.AnimationKeyInterpolation.STEP?"STEP":"LINEAR";return n||(n="LINEAR"),{interpolationType:n,shouldBakeAnimation:o}},e._AddSplineTangent=function(e,t,r,n,a,o,i,s,u){var l,c=t===p.INTANGENT?o.inTangent:o.outTangent;if("CUBICSPLINE"===a){if("rotation"===n)if(c){if(s)l=c.asArray();else{var f=c;l=d.Quaternion.RotationYawPitchRoll(f.y,f.x,f.z).asArray()}u&&(_._GetRightHandedQuaternionArrayFromRef(l),e.parent||(l=d.Quaternion.FromArray([0,1,0,0]).multiply(d.Quaternion.FromArray(l)).asArray()))}else l=[0,0,0,0];else"weights"===n?l=c?[c]:[0]:c?(l=c.asArray(),u&&"translation"===n&&(_._GetRightHandedPositionArray3FromRef(l),e.parent||(l[0]*=-1,l[2]*=-1))):l=[0,0,0];r.push(l)}},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}(),x=function(){function e(e,t){this._includeCoordinateSystemConversionNodes=!1,this._extensions={},this._glTF={asset:{generator:"Babylon.js v".concat(d.Engine.Version),version:"2.0"}},(e=e||d.EngineStore.LastCreatedScene)&&(this._babylonScene=e,this._bufferViews=[],this._accessors=[],this._meshes=[],this._scenes=[],this._cameras=[],this._nodes=[],this._images=[],this._materials=[],this._materialMap=[],this._textures=[],this._samplers=[],this._skins=[],this._animations=[],this._imageData={},this._orderedImageData=[],this._options=t||{},this._animationSampleRate=t&&t.animationSampleRate?t.animationSampleRate:1/60,this._includeCoordinateSystemConversionNodes=!(!t||!t.includeCoordinateSystemConversionNodes),this._glTFMaterialExporter=new m(this),this._loadExtensions())}return e.prototype._applyExtension=function(e,t,r,n){var a=this;if(r>=t.length)return Promise.resolve(e);var o=n(t[r],e);return o?o.then((function(e){return a._applyExtension(e,t,r+1,n)})):this._applyExtension(e,t,r+1,n)},e.prototype._applyExtensions=function(t,r){for(var n=[],a=0,o=e._ExtensionNames;a<o.length;a++){var i=o[a];n.push(this._extensions[i])}return this._applyExtension(t,n,0,r)},e.prototype._extensionsPreExportTextureAsync=function(e,t,r){return this._applyExtensions(t,(function(t,n){return t.preExportTextureAsync&&t.preExportTextureAsync(e,n,r)}))},e.prototype._extensionsPostExportMeshPrimitiveAsync=function(e,t,r,n){return this._applyExtensions(t,(function(t,a){return t.postExportMeshPrimitiveAsync&&t.postExportMeshPrimitiveAsync(e,a,r,n)}))},e.prototype._extensionsPostExportNodeAsync=function(e,t,r,n){return this._applyExtensions(t,(function(t,a){return t.postExportNodeAsync&&t.postExportNodeAsync(e,a,r,n)}))},e.prototype._extensionsPostExportMaterialAsync=function(e,t,r){return this._applyExtensions(t,(function(t,n){return t.postExportMaterialAsync&&t.postExportMaterialAsync(e,n,r)}))},e.prototype._extensionsPostExportMaterialAdditionalTextures=function(t,r,n){for(var a=[],o=0,i=e._ExtensionNames;o<i.length;o++){var s=i[o],u=this._extensions[s];u.postExportMaterialAdditionalTextures&&a.push.apply(a,u.postExportMaterialAdditionalTextures(t,r,n))}return a},e.prototype._extensionsPostExportTextures=function(t,r,n){for(var a=0,o=e._ExtensionNames;a<o.length;a++){var i=o[a],s=this._extensions[i];s.postExportTexture&&s.postExportTexture(t,r,n)}},e.prototype._forEachExtensions=function(t){for(var r=0,n=e._ExtensionNames;r<n.length;r++){var a=n[r],o=this._extensions[a];o.enabled&&t(o)}},e.prototype._extensionsOnExporting=function(){var e=this;this._forEachExtensions((function(t){t.wasUsed&&(null==e._glTF.extensionsUsed&&(e._glTF.extensionsUsed=[]),-1===e._glTF.extensionsUsed.indexOf(t.name)&&e._glTF.extensionsUsed.push(t.name),t.required&&(null==e._glTF.extensionsRequired&&(e._glTF.extensionsRequired=[]),-1===e._glTF.extensionsRequired.indexOf(t.name)&&e._glTF.extensionsRequired.push(t.name)),null==e._glTF.extensions&&(e._glTF.extensions={}),t.onExporting&&t.onExporting())}))},e.prototype._loadExtensions=function(){for(var t=0,r=e._ExtensionNames;t<r.length;t++){var n=r[t],a=e._ExtensionFactories[n](this);this._extensions[n]=a}},e.prototype.dispose=function(){for(var e in this._extensions)this._extensions[e].dispose()},e.RegisterExtension=function(t,r){e.UnregisterExtension(t)&&d.Tools.Warn("Extension with the name ".concat(t," already exists")),e._ExtensionFactories[t]=r,e._ExtensionNames.push(t)},e.UnregisterExtension=function(t){if(!e._ExtensionFactories[t])return!1;delete e._ExtensionFactories[t];var r=e._ExtensionNames.indexOf(t);return-1!==r&&e._ExtensionNames.splice(r,1),!0},e.prototype._reorderIndicesBasedOnPrimitiveMode=function(e,t,r,n,a){switch(t){case d.Material.TriangleFillMode:n||(n=0);for(var o=e.indexStart,i=e.indexStart+e.indexCount;o<i;o+=3){var s=n+4*o,u=a.getUInt32(s+4),l=a.getUInt32(s+8);a.setUInt32(l,s+4),a.setUInt32(u,s+8)}break;case d.Material.TriangleFanDrawMode:o=e.indexStart+e.indexCount-1;for(var c=e.indexStart;o>=c;--o)a.setUInt32(r[o],n),n+=4;break;case d.Material.TriangleStripDrawMode:e.indexCount>=3&&(a.setUInt32(r[e.indexStart+2],n+4),a.setUInt32(r[e.indexStart+1],n+8))}},e.prototype._reorderVertexAttributeDataBasedOnPrimitiveMode=function(e,t,r,n,a,o,i,s){if(s&&r===d.Material.ClockWiseSideOrientation)switch(t){case d.Material.TriangleFillMode:this._reorderTriangleFillMode(e,t,r,n,a,o,i,s);break;case d.Material.TriangleStripDrawMode:this._reorderTriangleStripDrawMode(e,t,r,n,a,o,i,s);break;case d.Material.TriangleFanDrawMode:this._reorderTriangleFanMode(e,t,r,n,a,o,i,s)}},e.prototype._reorderTriangleFillMode=function(e,t,r,n,a,o,i,s){var u=this._getVertexBufferFromMesh(n,e.getMesh());if(u){var l=u.byteStride/d.VertexBuffer.GetTypeByteLength(u.type);if(e.verticesCount%3!=0)d.Tools.Error("The submesh vertices for the triangle fill mode is not divisible by 3!");else{var c=[],f=0;switch(n){case d.VertexBuffer.PositionKind:case d.VertexBuffer.NormalKind:for(var h=e.verticesStart;h<e.verticesStart+e.verticesCount;h+=3)f=h*l,c.push(d.Vector3.FromArray(a,f)),c.push(d.Vector3.FromArray(a,f+2*l)),c.push(d.Vector3.FromArray(a,f+l));break;case d.VertexBuffer.TangentKind:for(h=e.verticesStart;h<e.verticesStart+e.verticesCount;h+=3)f=h*l,c.push(d.Vector4.FromArray(a,f)),c.push(d.Vector4.FromArray(a,f+2*l)),c.push(d.Vector4.FromArray(a,f+l));break;case d.VertexBuffer.ColorKind:var p=u.getSize();for(h=e.verticesStart;h<e.verticesStart+e.verticesCount;h+=p)f=h*l,4===p?(c.push(d.Vector4.FromArray(a,f)),c.push(d.Vector4.FromArray(a,f+2*l)),c.push(d.Vector4.FromArray(a,f+l))):(c.push(d.Vector3.FromArray(a,f)),c.push(d.Vector3.FromArray(a,f+2*l)),c.push(d.Vector3.FromArray(a,f+l)));break;case d.VertexBuffer.UVKind:case d.VertexBuffer.UV2Kind:for(h=e.verticesStart;h<e.verticesStart+e.verticesCount;h+=3)f=h*l,c.push(d.Vector2.FromArray(a,f)),c.push(d.Vector2.FromArray(a,f+2*l)),c.push(d.Vector2.FromArray(a,f+l));break;default:d.Tools.Error("Unsupported Vertex Buffer type: ".concat(n))}this._writeVertexAttributeData(c,o,n,a,i,s)}}else d.Tools.Warn("reorderTriangleFillMode: Vertex Buffer Kind ".concat(n," not present!"))},e.prototype._reorderTriangleStripDrawMode=function(e,t,r,n,a,o,i,s){var u=this._getVertexBufferFromMesh(n,e.getMesh());if(u){var l=u.byteStride/d.VertexBuffer.GetTypeByteLength(u.type),c=[],f=0;switch(n){case d.VertexBuffer.PositionKind:case d.VertexBuffer.NormalKind:f=e.verticesStart,c.push(d.Vector3.FromArray(a,f+2*l)),c.push(d.Vector3.FromArray(a,f+l));break;case d.VertexBuffer.TangentKind:for(var h=e.verticesStart+e.verticesCount-1;h>=e.verticesStart;--h)f=h*l,c.push(d.Vector4.FromArray(a,f));break;case d.VertexBuffer.ColorKind:for(h=e.verticesStart+e.verticesCount-1;h>=e.verticesStart;--h)f=h*l,4===u.getSize()?c.push(d.Vector4.FromArray(a,f)):c.push(d.Vector3.FromArray(a,f));break;case d.VertexBuffer.UVKind:case d.VertexBuffer.UV2Kind:for(h=e.verticesStart+e.verticesCount-1;h>=e.verticesStart;--h)f=h*l,c.push(d.Vector2.FromArray(a,f));break;default:d.Tools.Error("Unsupported Vertex Buffer type: ".concat(n))}this._writeVertexAttributeData(c,o+12,n,a,i,s)}else d.Tools.Warn("reorderTriangleStripDrawMode: Vertex buffer kind ".concat(n," not present!"))},e.prototype._reorderTriangleFanMode=function(e,t,r,n,a,o,i,s){var u=this._getVertexBufferFromMesh(n,e.getMesh());if(u){var l=u.byteStride/d.VertexBuffer.GetTypeByteLength(u.type),c=[],f=0;switch(n){case d.VertexBuffer.PositionKind:case d.VertexBuffer.NormalKind:for(var h=e.verticesStart+e.verticesCount-1;h>=e.verticesStart;--h)f=h*l,c.push(d.Vector3.FromArray(a,f));break;case d.VertexBuffer.TangentKind:for(h=e.verticesStart+e.verticesCount-1;h>=e.verticesStart;--h)f=h*l,c.push(d.Vector4.FromArray(a,f));break;case d.VertexBuffer.ColorKind:for(h=e.verticesStart+e.verticesCount-1;h>=e.verticesStart;--h)f=h*l,c.push(d.Vector4.FromArray(a,f)),4===u.getSize()?c.push(d.Vector4.FromArray(a,f)):c.push(d.Vector3.FromArray(a,f));break;case d.VertexBuffer.UVKind:case d.VertexBuffer.UV2Kind:for(h=e.verticesStart+e.verticesCount-1;h>=e.verticesStart;--h)f=h*l,c.push(d.Vector2.FromArray(a,f));break;default:d.Tools.Error("Unsupported Vertex Buffer type: ".concat(n))}this._writeVertexAttributeData(c,o,n,a,i,s)}else d.Tools.Warn("reorderTriangleFanMode: Vertex buffer kind ".concat(n," not present!"))},e.prototype._writeVertexAttributeData=function(e,t,r,n,a,o){for(var i=0,s=e;i<s.length;i++){var u=s[i];!o||r===d.VertexBuffer.ColorKind||u instanceof d.Vector2||(u instanceof d.Vector3?r===d.VertexBuffer.NormalKind?_._GetRightHandedNormalVector3FromRef(u):r===d.VertexBuffer.PositionKind?_._GetRightHandedPositionVector3FromRef(u):d.Tools.Error("Unsupported vertex attribute kind!"):_._GetRightHandedVector4FromRef(u)),r===d.VertexBuffer.NormalKind?u.normalize():r===d.VertexBuffer.TangentKind&&u instanceof d.Vector4&&_._NormalizeTangentFromRef(u);for(var l=0,c=u.asArray();l<c.length;l++){var f=c[l];a.setFloat32(f,t),t+=4}}},e.prototype._writeAttributeData=function(e,t,r,n,a,o,i){var s,u,l=[];switch(e){case d.VertexBuffer.PositionKind:for(var c=0,f=r.length/n;c<f;++c){s=c*n;var h=d.Vector3.FromArray(r,s);o&&_._GetRightHandedPositionVector3FromRef(h),l.push(h.asArray())}break;case d.VertexBuffer.NormalKind:c=0;for(var p=r.length/n;c<p;++c)s=c*n,h=d.Vector3.FromArray(r,s),o&&_._GetRightHandedNormalVector3FromRef(h),h.normalize(),l.push(h.asArray());break;case d.VertexBuffer.TangentKind:c=0;for(var m=r.length/n;c<m;++c)s=c*n,h=d.Vector4.FromArray(r,s),o&&_._GetRightHandedVector4FromRef(h),_._NormalizeTangentFromRef(h),l.push(h.asArray());break;case d.VertexBuffer.ColorKind:for(var g=i.material,x=!g||"StandardMaterial"===g.getClassName(),y=(h=3===n?new d.Color3:new d.Color4,c=0,r.length/n);c<y;++c)s=c*n,3===n?(d.Color3.FromArrayToRef(r,s,h),x&&h.toLinearSpaceToRef(h)):(d.Color4.FromArrayToRef(r,s,h),x&&h.toLinearSpaceToRef(h)),l.push(h.asArray());break;case d.VertexBuffer.UVKind:case d.VertexBuffer.UV2Kind:c=0;for(var T=r.length/n;c<T;++c)s=c*n,l.push([r[s],r[s+1]]);break;case d.VertexBuffer.MatricesIndicesKind:case d.VertexBuffer.MatricesIndicesExtraKind:c=0;for(var v=r.length/n;c<v;++c)s=c*n,h=d.Vector4.FromArray(r,s),l.push(h.asArray());break;case d.VertexBuffer.MatricesWeightsKind:case d.VertexBuffer.MatricesWeightsExtraKind:c=0;for(var b=r.length/n;c<b;++c)s=c*n,h=d.Vector4.FromArray(r,s),l.push(h.asArray());break;default:d.Tools.Warn("Unsupported Vertex Buffer Type: "+e),l=[]}switch(t){case 5121:u=a.setUInt8.bind(a);break;case 5123:u=a.setUInt16.bind(a);break;case 5125:u=a.setUInt32.bind(a);break;case 5126:u=a.setFloat32.bind(a);break;default:return void d.Tools.Warn("Unsupported Attribute Component kind: "+t)}for(var A=0,E=l;A<E.length;A++)for(var F=0,M=E[A];F<M.length;F++)u(M[F])},e.prototype.writeMorphTargetAttributeData=function(e,t,r,n,a,o,i,s,u,l){var c,f,h=[],p=new d.Vector3,m=new d.Vector4(0,0,0,0);switch(e){case d.VertexBuffer.PositionKind:for(var g=r.verticesStart;g<r.verticesCount;++g){c=r.indexStart+g*i;var x=d.Vector3.FromArray(a,c);p=(y=d.Vector3.FromArray(o,c)).subtractToRef(x,p),u&&_._GetRightHandedPositionVector3FromRef(p),l&&(l.min.copyFromFloats(Math.min(p.x,l.min.x),Math.min(p.y,l.min.y),Math.min(p.z,l.min.z)),l.max.copyFromFloats(Math.max(p.x,l.max.x),Math.max(p.y,l.max.y),Math.max(p.z,l.max.z))),h.push(p.asArray())}break;case d.VertexBuffer.NormalKind:for(g=r.verticesStart;g<r.verticesCount;++g)c=r.indexStart+g*i,(x=d.Vector3.FromArray(a,c)).normalize(),(y=d.Vector3.FromArray(o,c)).normalize(),p=y.subtractToRef(x,p),u&&_._GetRightHandedNormalVector3FromRef(p),h.push(p.asArray());break;case d.VertexBuffer.TangentKind:for(g=r.verticesStart;g<r.verticesCount;++g){c=r.indexStart+g*(i+1),x=d.Vector4.FromArray(a,c),_._NormalizeTangentFromRef(x);var y=d.Vector4.FromArray(o,c);_._NormalizeTangentFromRef(y),m=y.subtractToRef(x,m),u&&_._GetRightHandedVector4FromRef(m),h.push([m.x,m.y,m.z])}break;default:d.Tools.Warn("Unsupported Vertex Buffer Type: "+e),h=[]}switch(t){case 5121:f=s.setUInt8.bind(s);break;case 5123:f=s.setUInt16.bind(s);break;case 5125:f=s.setUInt32.bind(s);break;case 5126:f=s.setFloat32.bind(s);break;default:return void d.Tools.Warn("Unsupported Attribute Component kind: "+t)}for(var T=0,v=h;T<v.length;T++)for(var b=0,A=v[T];b<A.length;b++)f(A[b])},e.prototype._generateJSON=function(e,t,r){var n,a,o,i=this,s={byteLength:this._totalByteLength},u=this._totalByteLength;return s.byteLength&&(this._glTF.buffers=[s]),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&&(e?(this._glTF.images=[],this._images.forEach((function(e){e.uri&&(a=i._imageData[e.uri],i._orderedImageData.push(a),n=e.uri.split(".")[0]+" image",o=_._CreateBufferView(0,u,a.data.length,void 0,n),u+=a.data.buffer.byteLength,i._bufferViews.push(o),e.bufferView=i._bufferViews.length-1,e.name=n,e.mimeType=a.mimeType,e.uri=void 0,i._glTF.images||(i._glTF.images=[]),i._glTF.images.push(e))})),s.byteLength=u):this._glTF.images=this._images),e||(s.uri=t+".bin"),r?JSON.stringify(this._glTF,null,2):JSON.stringify(this._glTF)},e.prototype._generateGLTFAsync=function(e,t){var r=this;return void 0===t&&(t=!0),this._generateBinaryAsync().then((function(n){r._extensionsOnExporting();var a=r._generateJSON(!1,e,!0),o=new Blob([n],{type:"application/octet-stream"}),i=e+".gltf",s=e+".bin",u=new l;if(u.glTFFiles[i]=a,u.glTFFiles[s]=o,r._imageData)for(var c in r._imageData)u.glTFFiles[c]=new Blob([r._imageData[c].data],{type:r._imageData[c].mimeType});return t&&r.dispose(),u}))},e.prototype._generateBinaryAsync=function(){var e=this,t=new y(4);return this._createSceneAsync(this._babylonScene,t).then((function(){return e._localEngine&&e._localEngine.dispose(),t.getArrayBuffer()}))},e.prototype._getPadding=function(e){var t=e%4;return 0===t?t:4-t},e.prototype._generateGLBAsync=function(e,t){var r=this;return void 0===t&&(t=!0),this._generateBinaryAsync().then((function(n){r._extensionsOnExporting();var a,o=r._generateJSON(!0),i=e+".glb",s=o.length,u=0;"undefined"!=typeof TextEncoder&&(s=(a=(new TextEncoder).encode(o)).length);for(var c=0;c<r._orderedImageData.length;++c)u+=r._orderedImageData[c].data.byteLength;var f=r._getPadding(s),h=r._getPadding(n.byteLength),p=r._getPadding(u),d=28+s+f+n.byteLength+h+u+p,m=new ArrayBuffer(12),_=new DataView(m);_.setUint32(0,1179937895,!0),_.setUint32(4,2,!0),_.setUint32(8,d,!0);var g=new ArrayBuffer(8+s+f),x=new DataView(g);x.setUint32(0,s+f,!0),x.setUint32(4,1313821514,!0);var y=new Uint8Array(g,8);if(a)y.set(a);else{var T="_".charCodeAt(0);for(c=0;c<s;++c){var v=o.charCodeAt(c);v!=o.codePointAt(c)?y[c]=T:y[c]=v}}var b=new Uint8Array(g,8+s);for(c=0;c<f;++c)b[c]=32;var A=new ArrayBuffer(8),E=new DataView(A);E.setUint32(0,n.byteLength+u+p,!0),E.setUint32(4,5130562,!0);var F=new ArrayBuffer(h),M=new Uint8Array(F);for(c=0;c<h;++c)M[c]=0;var R=new ArrayBuffer(p),w=new Uint8Array(R);for(c=0;c<p;++c)w[c]=0;var C=[m,g,A,n];for(c=0;c<r._orderedImageData.length;++c)C.push(r._orderedImageData[c].data.buffer);C.push(F),C.push(R);var V=new Blob(C,{type:"application/octet-stream"}),S=new l;return S.glTFFiles[i]=V,null!=r._localEngine&&r._localEngine.dispose(),t&&r.dispose(),S}))},e.prototype._setNodeTransformation=function(e,t,r){t.getPivotPoint().equalsToFloats(0,0,0)||d.Tools.Warn("Pivot points are not supported in the glTF serializer"),t.position.equalsToFloats(0,0,0)||(e.translation=r?_._GetRightHandedPositionVector3(t.position).asArray():t.position.asArray()),t.scaling.equalsToFloats(1,1,1)||(e.scale=t.scaling.asArray());var n=d.Quaternion.RotationYawPitchRoll(t.rotation.y,t.rotation.x,t.rotation.z);t.rotationQuaternion&&n.multiplyInPlace(t.rotationQuaternion),d.Quaternion.IsIdentity(n)||(r&&_._GetRightHandedQuaternionFromRef(n),e.rotation=n.normalize().asArray())},e.prototype._setCameraTransformation=function(e,t,r){t.position.equalsToFloats(0,0,0)||(e.translation=r?_._GetRightHandedPositionVector3(t.position).asArray():t.position.asArray());var n=t.absoluteRotation;d.Quaternion.IsIdentity(n)||(r&&_._GetRightHandedQuaternionFromRef(n),e.rotation=n.normalize().asArray())},e.prototype._getVertexBufferFromMesh=function(e,t){if(t.isVerticesDataPresent(e)){var r=t.getVertexBuffer(e);if(r)return r}return null},e.prototype._createBufferViewKind=function(e,t,r,n,a,o){var i=r instanceof d.Mesh?r:r instanceof d.InstancedMesh?r.sourceMesh:null;if(i){var s=i.getVertexBuffer(e),u=i.getVerticesData(e);if(s&&u){var l=d.VertexBuffer.GetTypeByteLength(t),c=u.length*l,f=_._CreateBufferView(0,n.getByteOffset(),c,a,e+" - "+i.name);this._bufferViews.push(f),this._writeAttributeData(e,t,u,a/l,n,o,r)}}},e.prototype._setMorphTargetAttributes=function(e,t,r,n,a){if(r){t.targets||(t.targets=[]);var o={};if(r.hasNormals){var i=e.getMesh().getVerticesData(d.VertexBuffer.NormalKind),s=r.getNormals(),u=(g=e.verticesCount)*(x=12),l=_._CreateBufferView(0,n.getByteOffset(),u,x,r.name+"_NORMAL");this._bufferViews.push(l);var c=this._bufferViews.length-1,f=_._CreateAccessor(c,r.name+" - NORMAL","VEC3",5126,g,0,null,null);this._accessors.push(f),o.NORMAL=this._accessors.length-1,this.writeMorphTargetAttributeData(d.VertexBuffer.NormalKind,5126,e,r,i,s,x/4,n,a)}if(r.hasPositions){var h=e.getMesh().getVerticesData(d.VertexBuffer.PositionKind),p=r.getPositions();u=(g=e.verticesCount)*(x=12),l=_._CreateBufferView(0,n.getByteOffset(),u,x,r.name+"_POSITION"),this._bufferViews.push(l),c=this._bufferViews.length-1;var m={min:new d.Vector3(1/0,1/0,1/0),max:new d.Vector3(-1/0,-1/0,-1/0)};f=_._CreateAccessor(c,r.name+" - POSITION","VEC3",5126,g,0,null,null),this._accessors.push(f),o.POSITION=this._accessors.length-1,this.writeMorphTargetAttributeData(d.VertexBuffer.PositionKind,5126,e,r,h,p,x/4,n,a,m),f.min=m.min.asArray(),f.max=m.max.asArray()}if(r.hasTangents){var g,x,y=e.getMesh().getVerticesData(d.VertexBuffer.TangentKind),T=r.getTangents();u=(g=e.verticesCount)*(x=12),l=_._CreateBufferView(0,n.getByteOffset(),u,x,r.name+"_NORMAL"),this._bufferViews.push(l),c=this._bufferViews.length-1,f=_._CreateAccessor(c,r.name+" - TANGENT","VEC3",5126,g,0,null,null),this._accessors.push(f),o.TANGENT=this._accessors.length-1,this.writeMorphTargetAttributeData(d.VertexBuffer.TangentKind,5126,e,r,y,T,x/4,n,a)}t.targets.push(o)}},e.prototype._getMeshPrimitiveMode=function(e){return e instanceof d.LinesMesh?d.Material.LineListDrawMode:e.material?e.material.fillMode:d.Material.TriangleFillMode},e.prototype._setPrimitiveMode=function(e,t){switch(t){case d.Material.TriangleFillMode:break;case d.Material.TriangleStripDrawMode:e.mode=5;break;case d.Material.TriangleFanDrawMode:e.mode=6;break;case d.Material.PointListDrawMode:case d.Material.PointFillMode:e.mode=0;break;case d.Material.LineLoopDrawMode:e.mode=2;break;case d.Material.LineListDrawMode:e.mode=1;break;case d.Material.LineStripDrawMode:e.mode=3}},e.prototype._setAttributeKind=function(e,t){switch(t){case d.VertexBuffer.PositionKind:e.attributes.POSITION=this._accessors.length-1;break;case d.VertexBuffer.NormalKind:e.attributes.NORMAL=this._accessors.length-1;break;case d.VertexBuffer.ColorKind:e.attributes.COLOR_0=this._accessors.length-1;break;case d.VertexBuffer.TangentKind:e.attributes.TANGENT=this._accessors.length-1;break;case d.VertexBuffer.UVKind:e.attributes.TEXCOORD_0=this._accessors.length-1;break;case d.VertexBuffer.UV2Kind:e.attributes.TEXCOORD_1=this._accessors.length-1;break;case d.VertexBuffer.MatricesIndicesKind:e.attributes.JOINTS_0=this._accessors.length-1;break;case d.VertexBuffer.MatricesIndicesExtraKind:e.attributes.JOINTS_1=this._accessors.length-1;break;case d.VertexBuffer.MatricesWeightsKind:e.attributes.WEIGHTS_0=this._accessors.length-1;break;case d.VertexBuffer.MatricesWeightsExtraKind:e.attributes.WEIGHTS_1=this._accessors.length-1;break;default:d.Tools.Warn("Unsupported Vertex Buffer Type: "+t)}},e.prototype._setPrimitiveAttributesAsync=function(e,t,r,n){var a,o,i,s=[],u=null;t instanceof d.Mesh?u=t:t instanceof d.InstancedMesh&&(u=t.sourceMesh);var l=[{kind:d.VertexBuffer.PositionKind,accessorType:"VEC3",accessorComponentType:5126,byteStride:12},{kind:d.VertexBuffer.NormalKind,accessorType:"VEC3",accessorComponentType:5126,byteStride:12},{kind:d.VertexBuffer.ColorKind,accessorType:"VEC4",accessorComponentType:5126,byteStride:16},{kind:d.VertexBuffer.TangentKind,accessorType:"VEC4",accessorComponentType:5126,byteStride:16},{kind:d.VertexBuffer.UVKind,accessorType:"VEC2",accessorComponentType:5126,byteStride:8},{kind:d.VertexBuffer.UV2Kind,accessorType:"VEC2",accessorComponentType:5126,byteStride:8},{kind:d.VertexBuffer.MatricesIndicesKind,accessorType:"VEC4",accessorComponentType:5123,byteStride:8},{kind:d.VertexBuffer.MatricesIndicesExtraKind,accessorType:"VEC4",accessorComponentType:5123,byteStride:8},{kind:d.VertexBuffer.MatricesWeightsKind,accessorType:"VEC4",accessorComponentType:5126,byteStride:16},{kind:d.VertexBuffer.MatricesWeightsExtraKind,accessorType:"VEC4",accessorComponentType:5126,byteStride:16}];if(u){for(var c=null,f=this._getMeshPrimitiveMode(u),h={},p=u.morphTargetManager,m=0,g=l;m<g.length;m++){var x=(W=g[m]).kind,y=W.accessorComponentType;if(u.isVerticesDataPresent(x)){var T=this._getVertexBufferFromMesh(x,u);W.byteStride=T?T.getSize()*d.VertexBuffer.GetTypeByteLength(W.accessorComponentType):4*d.VertexBuffer.DeduceStride(x),12===W.byteStride&&(W.accessorType="VEC3"),this._createBufferViewKind(x,y,t,r,W.byteStride,n),W.bufferViewIndex=this._bufferViews.length-1,h[x]=W.bufferViewIndex}}if(u.getTotalIndices()){var v=u.getIndices();if(v){var b=4*v.length;o=_._CreateBufferView(0,r.getByteOffset(),b,void 0,"Indices - "+u.name),this._bufferViews.push(o),c=this._bufferViews.length-1;for(var A=0,E=v.length;A<E;++A)r.setUInt32(v[A])}}if(u.subMeshes)for(var F=0,M=u.subMeshes;F<M.length;F++){var R=M[F],w=R.getMaterial()||u.getScene().defaultMaterial,C=null;if(w)if(u instanceof d.LinesMesh){var V={name:u.name+" material"};(!u.color.equals(d.Color3.White())||u.alpha<1)&&(V.pbrMetallicRoughness={baseColorFactor:u.color.asArray().concat([u.alpha])}),this._materials.push(V),C=this._materials.length-1}else if(w instanceof d.MultiMaterial){var S=w.subMaterials[R.materialIndex];S&&(w=S,C=this._materialMap[w.uniqueId])}else C=this._materialMap[w.uniqueId];var B=null!=C?this._materials[C]:null,I={attributes:{}};this._setPrimitiveMode(I,f);for(var P=0,N=l;P<N.length;P++)if(((x=(W=N[P]).kind)!==d.VertexBuffer.UVKind&&x!==d.VertexBuffer.UV2Kind||this._options.exportUnusedUVs||B&&this._glTFMaterialExporter._hasTexturesPresent(B))&&(z=u.getVerticesData(x))&&(T=this._getVertexBufferFromMesh(x,u))){var L=T.getSize(),O=W.bufferViewIndex;if(null!=O){i={min:null,max:null},x==d.VertexBuffer.PositionKind&&(i=_._CalculateMinMaxPositions(z,0,z.length/L,n));var k=_._CreateAccessor(O,x+" - "+t.name,W.accessorType,W.accessorComponentType,z.length/L,0,i.min,i.max);this._accessors.push(k),this._setAttributeKind(I,x)}}if(c&&(k=_._CreateAccessor(c,"indices - "+t.name,"SCALAR",5125,R.indexCount,4*R.indexStart,null,null),this._accessors.push(k),I.indices=this._accessors.length-1),null!=C&&Object.keys(I.attributes).length>0){var U=null!==u.overrideMaterialSideOrientation?u.overrideMaterialSideOrientation:w.sideOrientation;if(U==d.Material.ClockWiseSideOrientation&&this._babylonScene.useRightHandedSystem||U==d.Material.ClockWiseSideOrientation&&n&&u.overrideMaterialSideOrientation!==(null===(a=u.material)||void 0===a?void 0:a.sideOrientation)){var K=null!=c?this._bufferViews[c].byteOffset:null;null==K&&(K=0);var G=null;if(null!=c&&(G=u.getIndices()),G)this._reorderIndicesBasedOnPrimitiveMode(R,f,G,K,r);else for(var D=0,H=l;D<H.length;D++){var z,W=H[D];if(z=u.getVerticesData(W.kind)){var q=this._bufferViews[h[W.kind]].byteOffset;q||(q=0),this._reorderVertexAttributeDataBasedOnPrimitiveMode(R,f,U,W.kind,z,q,r,n)}}}I.material=C}if(p)for(var Q=void 0,j=0;j<p.numTargets;++j)Q=p.getTarget(j),this._setMorphTargetAttributes(R,I,Q,r,n);e.primitives.push(I),this._extensionsPostExportMeshPrimitiveAsync("postExport",I,R,r),s.push()}}return Promise.all(s).then((function(){}))},e.prototype._isBabylonCoordinateSystemConvertingNode=function(e){return e instanceof d.TransformNode&&"__root__"===e.name&&1!==e.getWorldMatrix().determinant()&&!(e instanceof d.Mesh&&null!==e.geometry||e instanceof d.InstancedMesh&&null!==e.sourceMesh.geometry)&&!this._includeCoordinateSystemConversionNodes},e.prototype._createSceneAsync=function(e,t){var r,n,a,o=this,i={nodes:[]},s=h(h(h(h([],e.transformNodes,!0),e.meshes,!0),e.lights,!0),e.cameras,!0),u=[];this._convertToRightHandedSystem=!e.useRightHandedSystem,this._convertToRightHandedSystemMap={},e.rootNodes.forEach((function(e){o._convertToRightHandedSystemMap[e.uniqueId]=o._convertToRightHandedSystem,e.getDescendants(!1).forEach((function(e){o._convertToRightHandedSystemMap[e.uniqueId]=o._convertToRightHandedSystem}))})),e.rootNodes.forEach((function(e){if(o._isBabylonCoordinateSystemConvertingNode(e)){u.push(e);var t=s.indexOf(e);-1!==t&&s.splice(t,1),e.getDescendants(!1).forEach((function(e){o._convertToRightHandedSystemMap[e.uniqueId]=!1}))}}));var l=new Map;e.cameras.forEach((function(e){if(!o._options.shouldExportNode||o._options.shouldExportNode(e)){var t={type:e.mode===d.Camera.PERSPECTIVE_CAMERA?"perspective":"orthographic"};if(e.name&&(t.name=e.name),"perspective"===t.type)t.perspective={aspectRatio:e.getEngine().getAspectRatio(e),yfov:e.fovMode===d.Camera.FOVMODE_VERTICAL_FIXED?e.fov:e.fov*e.getEngine().getAspectRatio(e),znear:e.minZ,zfar:e.maxZ};else if("orthographic"===t.type){var r=e.orthoLeft&&e.orthoRight?.5*(e.orthoRight-e.orthoLeft):.5*e.getEngine().getRenderWidth(),n=e.orthoBottom&&e.orthoTop?.5*(e.orthoTop-e.orthoBottom):.5*e.getEngine().getRenderHeight();t.orthographic={xmag:r,ymag:n,znear:e.minZ,zfar:e.maxZ}}l.set(e,o._cameras.length),o._cameras.push(t)}}));var c=this._getExportNodes(s),f=c[0],p=c[1];return this._glTFMaterialExporter._convertMaterialsToGLTFAsync(p,"image/png",!0).then((function(){return o._createNodeMapAndAnimationsAsync(e,f,t).then((function(c){return o._createSkinsAsync(e,c,t).then((function(e){if(o._nodeMap=c,o._totalByteLength=t.getByteOffset(),null==o._totalByteLength)throw new Error("undefined byte length!");for(var f=0,h=s;f<h.length;f++){var p=h[f];if(void 0!==(r=o._nodeMap[p.uniqueId])){if(n=o._nodes[r],p.metadata&&(o._options.metadataSelector?n.extras=o._options.metadataSelector(p.metadata):p.metadata.gltf&&(n.extras=p.metadata.gltf.extras)),p instanceof d.Camera&&(n.camera=l.get(p)),p.parent&&-1===u.indexOf(p.parent)||(o._options.shouldExportNode&&!o._options.shouldExportNode(p)?d.Tools.Log("Omitting "+p.name+" from scene."):(o._convertToRightHandedSystemMap[p.uniqueId]&&(n.translation&&(n.translation[2]*=-1,n.translation[0]*=-1),n.rotation=n.rotation?d.Quaternion.FromArray([0,1,0,0]).multiply(d.Quaternion.FromArray(n.rotation)).asArray():d.Quaternion.FromArray([0,1,0,0]).asArray()),i.nodes.push(r))),p instanceof d.Mesh){var m=p;m.skeleton&&(n.skin=e[m.skeleton.uniqueId])}if(a=p.getDescendants(!0),!n.children&&a&&a.length){for(var _=[],g=0,x=a;g<x.length;g++){var y=x[g];null!=o._nodeMap[y.uniqueId]&&_.push(o._nodeMap[y.uniqueId])}_.length&&(n.children=_)}}}i.nodes.length&&o._scenes.push(i)}))}))}))},e.prototype._getExportNodes=function(e){for(var t=[],r=new Set,n=0,a=e;n<a.length;n++){var o=a[n];if(!this._options.shouldExportNode||this._options.shouldExportNode(o)){if(t.push(o),o instanceof d.AbstractMesh){var i=o.material||o.getScene().defaultMaterial;if(i instanceof d.MultiMaterial)for(var s=0,u=i.subMaterials;s<u.length;s++){var l=u[s];l&&r.add(l)}else r.add(i)}}else"Excluding node ".concat(o.name)}return[t,r]},e.prototype._createNodeMapAndAnimationsAsync=function(e,t,r){for(var n,a=this,o=Promise.resolve(),i={},s={name:"runtime animations",channels:[],samplers:[]},u=[],l=function(t){o=o.then((function(){var o=a._convertToRightHandedSystemMap[t.uniqueId];return a._createNodeAsync(t,r,o).then((function(l){var c=a._extensionsPostExportNodeAsync("createNodeAsync",l,t,i);return null==c?(d.Tools.Warn("Not exporting node ".concat(t.name)),Promise.resolve()):c.then((function(l){l&&(a._nodes.push(l),n=a._nodes.length-1,i[t.uniqueId]=n,e.animationGroups.length||(g._CreateMorphTargetAnimationFromMorphTargetAnimations(t,s,u,i,a._nodes,r,a._bufferViews,a._accessors,o,a._animationSampleRate),t.animations.length&&g._CreateNodeAnimationFromNodeAnimations(t,s,u,i,a._nodes,r,a._bufferViews,a._accessors,o,a._animationSampleRate)))}))}))}))},c=0,f=t;c<f.length;c++)l(f[c]);return o.then((function(){return s.channels.length&&s.samplers.length&&a._animations.push(s),u.forEach((function(e){e.channels.length&&e.samplers.length&&a._animations.push(e)})),e.animationGroups.length&&g._CreateNodeAndMorphAnimationFromAnimationGroups(e,a._animations,i,a._nodes,r,a._bufferViews,a._accessors,a._convertToRightHandedSystemMap,a._animationSampleRate),i}))},e.prototype._createNodeAsync=function(e,t,r){var n=this;return Promise.resolve().then((function(){var a={},o={primitives:[]};if(e.name&&(a.name=e.name),e instanceof d.TransformNode){if(n._setNodeTransformation(a,e,r),e instanceof d.Mesh){var i=e.morphTargetManager;if(i&&i.numTargets>0){o.weights=[];for(var s=0;s<i.numTargets;++s)o.weights.push(i.getTarget(s).influence)}}return n._setPrimitiveAttributesAsync(o,e,t,r).then((function(){return o.primitives.length&&(n._meshes.push(o),a.mesh=n._meshes.length-1),a}))}return e instanceof d.Camera?(n._setCameraTransformation(a,e,r),a):a}))},e.prototype._createSkinsAsync=function(e,t,r){for(var n,a=Promise.resolve(),o={},i=0,s=e.skeletons;i<s.length;i++){for(var u=s[i],l={joints:[]},c=[],f={},h=-1,p=0;p<u.bones.length;++p)-1!==(m=null!==(n=(g=u.bones[p]).getIndex())&&void 0!==n?n:p)&&(f[m]=g,m>h&&(h=m));for(var m=0;m<=h;++m){var g=f[m];c.push(g.getInvertedAbsoluteTransform());var x=g.getTransformNode();x?l.joints.push(t[x.uniqueId]):d.Tools.Warn("Exporting a bone without a linked transform node is currently unsupported")}var y=64*c.length,T=r.getByteOffset(),v=_._CreateBufferView(0,T,y,void 0,"InverseBindMatrices - "+u.name);this._bufferViews.push(v);var b=this._bufferViews.length-1,A=_._CreateAccessor(b,"InverseBindMatrices - "+u.name,"MAT4",5126,c.length,null,null,null),E=this._accessors.push(A)-1;l.inverseBindMatrices=E,this._skins.push(l),o[u.uniqueId]=this._skins.length-1,c.forEach((function(e){e.m.forEach((function(e){r.setFloat32(e)}))}))}return a.then((function(){return o}))},e._ExtensionNames=new Array,e._ExtensionFactories={},e}(),y=function(){function e(e){this._arrayBuffer=new ArrayBuffer(e),this._dataView=new DataView(this._arrayBuffer),this._byteOffset=0}return e.prototype._resizeBuffer=function(e){for(var t=new ArrayBuffer(e),r=new Uint8Array(this._arrayBuffer),n=new Uint8Array(t),a=0,o=n.byteLength;a<o;++a)n[a]=r[a];return this._arrayBuffer=t,this._dataView=new DataView(this._arrayBuffer),t},e.prototype.getArrayBuffer=function(){return this._resizeBuffer(this.getByteOffset())},e.prototype.getByteOffset=function(){if(null==this._byteOffset)throw new Error("Byte offset is undefined!");return this._byteOffset},e.prototype.setUInt8=function(e,t){null!=t?t<this._byteOffset?this._dataView.setUint8(t,e):d.Tools.Error("BinaryWriter: byteoffset is greater than the current binary buffer length!"):(this._byteOffset+1>this._arrayBuffer.byteLength&&this._resizeBuffer(2*this._arrayBuffer.byteLength),this._dataView.setUint8(this._byteOffset,e),this._byteOffset+=1)},e.prototype.setUInt16=function(e,t){null!=t?t<this._byteOffset?this._dataView.setUint16(t,e,!0):d.Tools.Error("BinaryWriter: byteoffset is greater than the current binary buffer length!"):(this._byteOffset+2>this._arrayBuffer.byteLength&&this._resizeBuffer(2*this._arrayBuffer.byteLength),this._dataView.setUint16(this._byteOffset,e,!0),this._byteOffset+=2)},e.prototype.getUInt32=function(e){if(e<this._byteOffset)return this._dataView.getUint32(e,!0);throw d.Tools.Error("BinaryWriter: byteoffset is greater than the current binary buffer length!"),new Error("BinaryWriter: byteoffset is greater than the current binary buffer length!")},e.prototype.getVector3Float32FromRef=function(e,t){t+8>this._byteOffset?d.Tools.Error("BinaryWriter: byteoffset is greater than the current binary buffer length!"):(e.x=this._dataView.getFloat32(t,!0),e.y=this._dataView.getFloat32(t+4,!0),e.z=this._dataView.getFloat32(t+8,!0))},e.prototype.setVector3Float32FromRef=function(e,t){t+8>this._byteOffset?d.Tools.Error("BinaryWriter: byteoffset is greater than the current binary buffer length!"):(this._dataView.setFloat32(t,e.x,!0),this._dataView.setFloat32(t+4,e.y,!0),this._dataView.setFloat32(t+8,e.z,!0))},e.prototype.getVector4Float32FromRef=function(e,t){t+12>this._byteOffset?d.Tools.Error("BinaryWriter: byteoffset is greater than the current binary buffer length!"):(e.x=this._dataView.getFloat32(t,!0),e.y=this._dataView.getFloat32(t+4,!0),e.z=this._dataView.getFloat32(t+8,!0),e.w=this._dataView.getFloat32(t+12,!0))},e.prototype.setVector4Float32FromRef=function(e,t){t+12>this._byteOffset?d.Tools.Error("BinaryWriter: byteoffset is greater than the current binary buffer length!"):(this._dataView.setFloat32(t,e.x,!0),this._dataView.setFloat32(t+4,e.y,!0),this._dataView.setFloat32(t+8,e.z,!0),this._dataView.setFloat32(t+12,e.w,!0))},e.prototype.setFloat32=function(e,t){isNaN(e)&&d.Tools.Error("Invalid data being written!"),null!=t&&(t<this._byteOffset?this._dataView.setFloat32(t,e,!0):d.Tools.Error("BinaryWriter: byteoffset is greater than the current binary length!")),this._byteOffset+4>this._arrayBuffer.byteLength&&this._resizeBuffer(2*this._arrayBuffer.byteLength),this._dataView.setFloat32(this._byteOffset,e,!0),this._byteOffset+=4},e.prototype.setUInt32=function(e,t){null!=t?t<this._byteOffset?this._dataView.setUint32(t,e,!0):d.Tools.Error("BinaryWriter: byteoffset is greater than the current binary buffer length!"):(this._byteOffset+4>this._arrayBuffer.byteLength&&this._resizeBuffer(2*this._arrayBuffer.byteLength),this._dataView.setUint32(this._byteOffset,e,!0),this._byteOffset+=4)},e}(),T=function(){function e(){}return e.GLTFAsync=function(e,t,r){return e.whenReadyAsync().then((function(){var n=t.replace(/\.[^/.]+$/,"");return new x(e,r)._generateGLTFAsync(n)}))},e._PreExportAsync=function(e,t){return Promise.resolve().then((function(){return t&&t.exportWithoutWaitingForScene?Promise.resolve():e.whenReadyAsync()}))},e._PostExportAsync=function(e,t,r){return Promise.resolve().then((function(){return r&&r.exportWithoutWaitingForScene,t}))},e.GLBAsync=function(e,t,r){var n=this;return this._PreExportAsync(e,r).then((function(){var a=t.replace(/\.[^/.]+$/,"");return new x(e,r)._generateGLBAsync(a).then((function(t){return n._PostExportAsync(e,t,r)}))}))},e}();d.ShaderStore.ShadersStore.textureTransformPixelShader="precision highp float;varying vec2 vUV;uniform sampler2D textureSampler;uniform mat4 textureTransformMat;void main(void) {\n#define CUSTOM_FRAGMENT_MAIN_BEGIN\nvec2 uvTransformed=(textureTransformMat*vec4(vUV.xy,1,1)).xy;gl_FragColor=texture2D(textureSampler,uvTransformed);\n#define CUSTOM_FRAGMENT_MAIN_END\n}";var v="KHR_texture_transform",b=function(){function e(){this._recordedTextures=[],this.name=v,this.enabled=!0,this.required=!1,this._wasUsed=!1}return e.prototype.dispose=function(){for(var e=0,t=this._recordedTextures;e<t.length;e++)t[e].dispose()},Object.defineProperty(e.prototype,"wasUsed",{get:function(){return this._wasUsed},enumerable:!1,configurable:!0}),e.prototype.postExportTexture=function(e,t,r){if(r&&(0===r.uAng&&0===r.wAng&&0===r.vAng||0===r.uRotationCenter&&0===r.vRotationCenter)){var n={},a=!1;if(0===r.uOffset&&0===r.vOffset||(n.offset=[r.uOffset,r.vOffset],a=!0),1===r.uScale&&1===r.vScale||(n.scale=[r.uScale,r.vScale],a=!0),0!==r.wAng&&(n.rotation=r.wAng,a=!0),0!==r.coordinatesIndex&&(n.texCoord=r.coordinatesIndex,a=!0),!a)return;this._wasUsed=!0,t.extensions||(t.extensions={}),t.extensions[v]=n}},e.prototype.preExportTextureAsync=function(e,t){var r=this;return new Promise((function(n,a){var o=t.getScene();if(o){var i=!1;if(0===t.uAng&&0===t.wAng&&0===t.vAng||0===t.uRotationCenter&&0===t.vRotationCenter||(i=!0),i)return r._textureTransformTextureAsync(t,o).then((function(e){n(e)})).catch((function(e){a(e)}));n(t)}else a("".concat(e,': "scene" is not defined for Babylon texture ').concat(t.name,"!"))}))},e.prototype._textureTransformTextureAsync=function(e,t){var r=this;return new Promise((function(n){var a=new d.ProceduralTexture("".concat(e.name),e.getSize(),"textureTransform",t);a||(d.Tools.Log("Cannot create procedural texture for ".concat(e.name,"!")),n(e)),a.reservedDataStore={hidden:!0,source:e},r._recordedTextures.push(a),a.coordinatesIndex=e.coordinatesIndex,a.setTexture("textureSampler",e),a.setMatrix("textureTransformMat",e.getTextureMatrix()),a.isReady()?(a.render(),n(a)):a.getEffect().executeWhenCompiled((function(){a.render(),n(a)}))}))},e}();x.RegisterExtension(v,(function(){return new b}));var A="KHR_lights_punctual",E=function(){function e(e){this.name=A,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.KHR_lights_punctual=this._lights},e.prototype.postExportNodeAsync=function(e,t,r,n){var a=this;return new Promise((function(o){if(t&&r instanceof d.ShadowLight){var i=r,s=void 0,u=i.getTypeID()==d.Light.LIGHTTYPEID_POINTLIGHT?"point":i.getTypeID()==d.Light.LIGHTTYPEID_DIRECTIONALLIGHT?"directional":i.getTypeID()==d.Light.LIGHTTYPEID_SPOTLIGHT?"spot":null;if(null==u)d.Logger.Warn("".concat(e,": Light ").concat(i.name," is not supported in ").concat(A));else{var l=i.position.clone(),c=a._exporter._convertToRightHandedSystemMap[r.uniqueId];if(l.equals(d.Vector3.Zero())||(c&&_._GetRightHandedPositionVector3FromRef(l),t.translation=l.asArray()),"point"!==u){var f=i.direction,h=-Math.atan2(f.z*(a._exporter._babylonScene.useRightHandedSystem?-1:1),f.x)+Math.PI/2,p=Math.sqrt(f.x*f.x+f.z*f.z),m=-Math.atan2(f.y,p),g=d.Quaternion.RotationYawPitchRoll(h,m,0);c&&_._GetRightHandedQuaternionFromRef(g),g.equals(d.Quaternion.Identity())||(t.rotation=g.asArray())}if(i.falloffType!==d.Light.FALLOFF_GLTF&&d.Logger.Warn("".concat(e,": Light falloff for ").concat(i.name," does not match the ").concat(A," specification!")),s={type:u},i.diffuse.equals(d.Color3.White())||(s.color=i.diffuse.asArray()),1!==i.intensity&&(s.intensity=i.intensity),i.range!==Number.MAX_VALUE&&(s.range=i.range),"spot"===u){var x=i;x.angle!==Math.PI/2&&(null==s.spot&&(s.spot={}),s.spot.outerConeAngle=x.angle/2),0!==x.innerAngle&&(null==s.spot&&(s.spot={}),s.spot.innerConeAngle=x.innerAngle/2)}null==a._lights&&(a._lights={lights:[]}),a._lights.lights.push(s);var y={light:a._lights.lights.length-1},T=r.parent;if(T&&1==T.getChildren().length){var v=a._exporter._nodes[n[T.uniqueId]];if(v){var b=d.TmpVectors.Matrix[0],E=d.TmpVectors.Matrix[1],F=v.translation?new d.Vector3(v.translation[0],v.translation[1],v.translation[2]):d.Vector3.Zero(),M=v.rotation?new d.Quaternion(v.rotation[0],v.rotation[1],v.rotation[2],v.rotation[3]):d.Quaternion.Identity(),R=v.scale?new d.Vector3(v.scale[0],v.scale[1],v.scale[2]):d.Vector3.One();d.Matrix.ComposeToRef(R,M,F,b),b.invertToRef(E);var w=d.TmpVectors.Matrix[2],C=t.translation?new d.Vector3(t.translation[0],t.translation[1],t.translation[2]):d.Vector3.Zero();i instanceof d.DirectionalLight&&C.subtractInPlace(a._exporter._babylonScene.useRightHandedSystem?i.direction:_._GetRightHandedPositionVector3(i.direction));var V=a._exporter._babylonScene.useRightHandedSystem?d.Quaternion.Identity():new d.Quaternion(0,1,0,0);t.rotation&&V.multiplyInPlace(new d.Quaternion(t.rotation[0],t.rotation[1],t.rotation[2],t.rotation[3]));var S=t.scale?new d.Vector3(t.scale[0],t.scale[1],t.scale[2]):d.Vector3.One();d.Matrix.ComposeToRef(S,V,C,w),w.multiplyToRef(E,w);var B=d.TmpVectors.Vector3[0],I=d.TmpVectors.Quaternion[0],P=d.TmpVectors.Vector3[1];return w.decompose(B,I,P),v.scale=B.asArray(),v.rotation=I.asArray(),v.translation=P.asArray(),null==v.extensions&&(v.extensions={}),v.extensions.KHR_lights_punctual=y,void o(null)}}null==t.extensions&&(t.extensions={}),t.extensions.KHR_lights_punctual=y}}o(t)}))},e}();x.RegisterExtension(A,(function(e){return new E(e)}));var F="KHR_materials_clearcoat",M=function(){function e(e){this.name=F,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.postExportMaterialAdditionalTextures=function(e,t,r){var n=[];return r instanceof d.PBRBaseMaterial&&r.clearCoat.isEnabled?(r.clearCoat.texture&&n.push(r.clearCoat.texture),!r.clearCoat.useRoughnessFromMainTexture&&r.clearCoat.textureRoughness&&n.push(r.clearCoat.textureRoughness),r.clearCoat.bumpTexture&&n.push(r.clearCoat.bumpTexture),n):[]},e.prototype.postExportMaterialAsync=function(e,t,r){var n=this;return new Promise((function(e){if(r instanceof d.PBRBaseMaterial){if(!r.clearCoat.isEnabled)return void e(t);n._wasUsed=!0,t.extensions=t.extensions||{};var a,o=n._exporter._glTFMaterialExporter._getTextureInfo(r.clearCoat.texture);a=r.clearCoat.useRoughnessFromMainTexture?n._exporter._glTFMaterialExporter._getTextureInfo(r.clearCoat.texture):n._exporter._glTFMaterialExporter._getTextureInfo(r.clearCoat.textureRoughness),r.clearCoat.isTintEnabled&&d.Tools.Warn("Clear Color tint is not supported for glTF export. Ignoring for: ".concat(r.name)),r.clearCoat.remapF0OnInterfaceChange&&d.Tools.Warn("Clear Color F0 remapping is not supported for glTF export. Ignoring for: ".concat(r.name));var i=n._exporter._glTFMaterialExporter._getTextureInfo(r.clearCoat.bumpTexture),s={clearcoatFactor:r.clearCoat.intensity,clearcoatTexture:null!=o?o:void 0,clearcoatRoughnessFactor:r.clearCoat.roughness,clearcoatRoughnessTexture:null!=a?a:void 0,clearcoatNormalTexture:null!=i?i:void 0,hasTextures:function(){return null!==s.clearcoatTexture||null!==s.clearcoatRoughnessTexture||null!==s.clearcoatRoughnessTexture}};t.extensions.KHR_materials_clearcoat=s}e(t)}))},e}();x.RegisterExtension(F,(function(e){return new M(e)}));var R="KHR_materials_iridescence",w=function(){function e(e){this.name=R,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.postExportMaterialAdditionalTextures=function(e,t,r){var n=[];return r instanceof d.PBRBaseMaterial&&r.iridescence.isEnabled?(r.iridescence.texture&&n.push(r.iridescence.texture),r.iridescence.thicknessTexture&&r.iridescence.thicknessTexture!==r.iridescence.texture&&n.push(r.iridescence.thicknessTexture),n):[]},e.prototype.postExportMaterialAsync=function(e,t,r){var n=this;return new Promise((function(e){if(r instanceof d.PBRBaseMaterial){if(!r.iridescence.isEnabled)return void e(t);n._wasUsed=!0,t.extensions=t.extensions||{};var a=n._exporter._glTFMaterialExporter._getTextureInfo(r.iridescence.texture),o=n._exporter._glTFMaterialExporter._getTextureInfo(r.iridescence.thicknessTexture),i={iridescenceFactor:r.iridescence.intensity,iridescenceIor:r.iridescence.indexOfRefraction,iridescenceThicknessMinimum:r.iridescence.minimumThickness,iridescenceThicknessMaximum:r.iridescence.maximumThickness,iridescenceTexture:null!=a?a:void 0,iridescenceThicknessTexture:null!=o?o:void 0,hasTextures:function(){return null!==i.iridescenceTexture||null!==i.iridescenceThicknessTexture}};t.extensions.KHR_materials_iridescence=i}e(t)}))},e}();x.RegisterExtension(R,(function(e){return new w(e)}));var C="KHR_materials_sheen",V=function(){function e(e){this.name=C,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.postExportMaterialAdditionalTextures=function(e,t,r){return r instanceof d.PBRMaterial&&r.sheen.isEnabled&&r.sheen.texture?[r.sheen.texture]:[]},e.prototype.postExportMaterialAsync=function(e,t,r){var n=this;return new Promise((function(e){var a,o,i,s;if(r instanceof d.PBRMaterial){if(!r.sheen.isEnabled)return void e(t);n._wasUsed=!0,null==t.extensions&&(t.extensions={});var u={sheenColorFactor:r.sheen.color.asArray(),sheenRoughnessFactor:null!==(a=r.sheen.roughness)&&void 0!==a?a:0,hasTextures:function(){return null!==u.sheenColorTexture||null!==u.sheenRoughnessTexture}};r.sheen.texture&&(u.sheenColorTexture=null!==(o=n._exporter._glTFMaterialExporter._getTextureInfo(r.sheen.texture))&&void 0!==o?o:void 0),r.sheen.textureRoughness&&!r.sheen.useRoughnessFromMainTexture?u.sheenRoughnessTexture=null!==(i=n._exporter._glTFMaterialExporter._getTextureInfo(r.sheen.textureRoughness))&&void 0!==i?i:void 0:r.sheen.texture&&r.sheen.useRoughnessFromMainTexture&&(u.sheenRoughnessTexture=null!==(s=n._exporter._glTFMaterialExporter._getTextureInfo(r.sheen.texture))&&void 0!==s?s:void 0),t.extensions.KHR_materials_sheen=u}e(t)}))},e}();x.RegisterExtension(C,(function(e){return new V(e)}));var S="KHR_materials_unlit",B=function(){function e(){this.name=S,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 a=!1;r instanceof d.PBRMaterial?a=r.unlit:r instanceof d.StandardMaterial&&(a=r.disableLighting),a&&(n._wasUsed=!0,null==t.extensions&&(t.extensions={}),t.extensions.KHR_materials_unlit={}),e(t)}))},e}();x.RegisterExtension(S,(function(){return new B}));var I="KHR_materials_ior",P=function(){function e(){this.name=I,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 d.PBRMaterial&&n._isExtensionEnabled(r)){n._wasUsed=!0;var a={ior:r.indexOfRefraction};t.extensions=t.extensions||{},t.extensions.KHR_materials_ior=a}e(t)}))},e}();x.RegisterExtension(I,(function(e){return new P}));var N="KHR_materials_specular",L=function(){function e(e){this.name=N,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.postExportMaterialAdditionalTextures=function(e,t,r){var n=[];return r instanceof d.PBRMaterial&&this._isExtensionEnabled(r)?(r.metallicReflectanceTexture&&n.push(r.metallicReflectanceTexture),r.reflectanceTexture&&n.push(r.reflectanceTexture),n):n},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 a,o;if(r instanceof d.PBRMaterial&&n._isExtensionEnabled(r)){n._wasUsed=!0,t.extensions=t.extensions||{};var i=null!==(a=n._exporter._glTFMaterialExporter._getTextureInfo(r.metallicReflectanceTexture))&&void 0!==a?a:void 0,s=null!==(o=n._exporter._glTFMaterialExporter._getTextureInfo(r.reflectanceTexture))&&void 0!==o?o:void 0,u={specularFactor:1==r.metallicF0Factor?void 0:r.metallicF0Factor,specularTexture:i,specularColorFactor:r.metallicReflectanceColor.equalsFloats(1,1,1)?void 0:r.metallicReflectanceColor.asArray(),specularColorTexture:s,hasTextures:function(){return n._hasTexturesExtension(r)}};t.extensions.KHR_materials_specular=u}e(t)}))},e}();x.RegisterExtension(N,(function(e){return new L(e)}));var O="KHR_materials_volume",k=function(){function e(e){this.name=O,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.postExportMaterialAdditionalTextures=function(e,t,r){var n=[];return r instanceof d.PBRMaterial&&this._isExtensionEnabled(r)?(r.subSurface.thicknessTexture&&n.push(r.subSurface.thicknessTexture),n):n},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!=d.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 a;if(r instanceof d.PBRMaterial&&n._isExtensionEnabled(r)){n._wasUsed=!0;var o=r.subSurface,i={thicknessFactor:0==o.maximumThickness?void 0:o.maximumThickness,thicknessTexture:null!==(a=n._exporter._glTFMaterialExporter._getTextureInfo(o.thicknessTexture))&&void 0!==a?a:void 0,attenuationDistance:o.tintColorAtDistance==Number.POSITIVE_INFINITY?void 0:o.tintColorAtDistance,attenuationColor:o.tintColor.equalsFloats(1,1,1)?void 0:o.tintColor.asArray(),hasTextures:function(){return n._hasTexturesExtension(r)}};t.extensions=t.extensions||{},t.extensions.KHR_materials_volume=i}e(t)}))},e}();x.RegisterExtension(O,(function(e){return new k(e)}));var U="KHR_materials_transmission",K=function(){function e(e){this.name=U,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.postExportMaterialAdditionalTextures=function(e,t,r){var n=[];return r instanceof d.PBRMaterial&&this._isExtensionEnabled(r)?(r.subSurface.thicknessTexture&&n.push(r.subSurface.thicknessTexture),n):n},e.prototype._isExtensionEnabled=function(e){if(e.unlit)return!1;var t=e.subSurface;return t.isRefractionEnabled&&null!=t.refractionIntensity&&0!=t.refractionIntensity||this._hasTexturesExtension(e)},e.prototype._hasTexturesExtension=function(e){return null!=e.subSurface.refractionIntensityTexture},e.prototype.postExportMaterialAsync=function(e,t,r){var n=this;return new Promise((function(e){var a;if(r instanceof d.PBRMaterial&&n._isExtensionEnabled(r)){n._wasUsed=!0;var o=r.subSurface,i={transmissionFactor:0===o.refractionIntensity?void 0:o.refractionIntensity,transmissionTexture:null!==(a=n._exporter._glTFMaterialExporter._getTextureInfo(o.refractionIntensityTexture))&&void 0!==a?a:void 0,hasTextures:function(){return n._hasTexturesExtension(r)}};t.extensions=t.extensions||{},t.extensions.KHR_materials_transmission=i}e(t)}))},e}();x.RegisterExtension(U,(function(e){return new K(e)}));var G=0,D=void 0!==n.g?n.g:"undefined"!=typeof window?window:void 0;if(void 0!==D){D.BABYLON=D.BABYLON||{};var H=D.BABYLON;H.GLTF2=H.GLTF2||{},H.GLTF2.Exporter=H.GLTF2.Exporter||{},H.GLTF2.Exporter.Extensions=H.GLTF2.Exporter.Extensions||{};var z=[];for(var W in e)H[W]=e[W],z.push(W);for(var W in t)H[W]=t[W],z.push(W);for(var W in r)H[W]=r[W],z.push(W);for(var W in o)H.GLTF2.Exporter.Extensions[W]=o[W],z.push(W);for(var W in i)z.indexOf(W)>-1||(H.GLTF2.Exporter[W]=i[W])}const q=s})(),a.default})()}));
|
|
2
2
|
//# sourceMappingURL=babylon.glTF2Serializer.min.js.map
|