!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:()=>z});var e={};n.r(e),n.d(e,{OBJExport:()=>h});var t={};n.r(t),n.d(t,{__IGLTFExporterExtension:()=>p});var r={};n.r(r),n.d(r,{GLTFData:()=>g});var o={};n.r(o),n.d(o,{GLTF2Export:()=>F});var i={};n.r(i),n.d(i,{KHR_lights_punctual:()=>C,KHR_materials_clearcoat:()=>w,KHR_materials_sheen:()=>B,KHR_materials_unlit:()=>P,KHR_texture_transform:()=>E});var s={};n.r(s),n.d(s,{GLTF2Export:()=>F,GLTFData:()=>g,KHR_lights_punctual:()=>C,KHR_materials_clearcoat:()=>w,KHR_materials_sheen:()=>B,KHR_materials_unlit:()=>P,KHR_texture_transform:()=>E,_BinaryWriter:()=>b,_Exporter:()=>v,_GLTFAnimation:()=>m,_GLTFMaterialExporter:()=>T,_GLTFUtilities:()=>d,__IGLTFExporterExtensionV2:()=>A});var u={};n.r(u),n.d(u,{STLExport:()=>N});var l={};n.r(l),n.d(l,{GLTF2Export:()=>F,GLTFData:()=>g,KHR_lights_punctual:()=>C,KHR_materials_clearcoat:()=>w,KHR_materials_sheen:()=>B,KHR_materials_unlit:()=>P,KHR_texture_transform:()=>E,OBJExport:()=>h,STLExport:()=>N,_BinaryWriter:()=>b,_Exporter:()=>v,_GLTFAnimation:()=>m,_GLTFMaterialExporter:()=>T,_GLTFUtilities:()=>d,__IGLTFExporterExtension:()=>p,__IGLTFExporterExtensionV2:()=>A});var c,f=n(520),h=function(){function e(){}return e.OBJ=function(e,t,r,n){var a=[],o=1,i=1;t&&(r||(r="mat"),a.push("mtllib "+r+".mtl"));for(var s=0;sl[p]&&(l[p]=d),++o}}return{min:u,max:l}},e._GetRightHandedPositionVector3=function(e){return new f.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 f.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"}(c||(c={}));var m=function(){function e(){}return e._CreateNodeAnimation=function(t,r,n,a,o,i){var s=[],u=[],l=r.getKeys(),c=e.calculateMinMaxKeyFrames(l),h=e._DeduceInterpolation(l,n,o),p=c.max-c.min,d=h.interpolationType,m=h.shouldBakeAnimation;return m?e._CreateBakedAnimation(t,r,n,c.min,c.max,r.framePerSecond,i,s,u,c,a,o):"LINEAR"===d||"STEP"===d?e._CreateLinearOrStepAnimation(t,r,n,p,s,u,a,o):"CUBICSPLINE"===d?e._CreateCubicSplineAnimation(t,r,n,p,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:d,inputsMin:m?c.min:f.Tools.FloatRound(c.min/r.framePerSecond),inputsMax:m?c.max:f.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:f.Tools.Error("Unsupported animatable property ".concat(a[0]))}return t?{animationChannelTargetPath:t,dataAccessorType:r,useQuaternion:n}:(f.Tools.Error("animation channel target path and data accessor type could be deduced"),null)},e._CreateNodeAnimationFromNodeAnimations=function(t,r,n,a,o,i,s,u,l,c){var h;if(t instanceof f.TransformNode&&t.animations)for(var p=0,d=t.animations;p0;)M=A.inputs.shift(),F%m==0&&E.push(M),F++;A.inputs=E}var R=s[n.uniqueId],C=4*A.inputs.length;g=d._CreateBufferView(0,u.getByteOffset(),C,void 0,"".concat(t," keyframe data view")),l.push(g),A.inputs.forEach((function(e){u.setFloat32(e)})),_=d._CreateAccessor(l.length-1,"".concat(t," keyframes"),"SCALAR",5126,A.inputs.length,null,[A.inputsMin],[A.inputsMax]),c.push(_),x=c.length-1,T=A.outputs.length,C=4*d._GetDataAccessorElementCount(o)*A.outputs.length,g=d._CreateBufferView(0,u.getByteOffset(),C,void 0,"".concat(t," data view")),l.push(g),A.outputs.forEach((function(e){e.forEach((function(e){u.setFloat32(e)}))})),_=d._CreateAccessor(l.length-1,"".concat(t," data"),o,5126,T,null,null,null),c.push(_),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,h,p){var d,m,g=f.Quaternion.Identity(),_=null,x=null,y=null,T=null,v=null,b=null;c.min=f.Tools.FloatRound(a/i);for(var A=r.getKeys(),F=0,M=A.length;F0&&a[a.length-1])||6!==o[0]&&2!==o[0])){i=0;continue}if(3===o[0]&&(!a||o[1]>a[0]&&o[1]i.width?(a=t&&t instanceof f.Texture?f.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;ne._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=f.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,f.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=f.Color3.FromInts(255,y[N+1],y[N+2]),e.FuzzyEquals(k,f.Color3.White(),e._Epsilon)||(S=!0);return S&&(G=this._createBase64FromCanvasAsync(y,p,d,a).then((function(e){w.metallicRoughnessTextureBase64=e})),i.push(G)),B&&(G=this._createBase64FromCanvasAsync(T,p,d,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=f.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 f.Texture?e.samplingMode:null;if(null!=r)switch(r){case f.Texture.LINEAR_LINEAR:t.magFilter=9729,t.minFilter=9729;break;case f.Texture.LINEAR_NEAREST:t.magFilter=9729,t.minFilter=9728;break;case f.Texture.NEAREST_LINEAR:t.magFilter=9728,t.minFilter=9729;break;case f.Texture.NEAREST_LINEAR_MIPLINEAR:t.magFilter=9728,t.minFilter=9987;break;case f.Texture.NEAREST_NEAREST:t.magFilter=9728,t.minFilter=9728;break;case f.Texture.NEAREST_LINEAR_MIPNEAREST:t.magFilter=9728,t.minFilter=9985;break;case f.Texture.LINEAR_NEAREST_MIPNEAREST:t.magFilter=9729,t.minFilter=9984;break;case f.Texture.LINEAR_NEAREST_MIPLINEAR:t.magFilter=9729,t.minFilter=9986;break;case f.Texture.NEAREST_NEAREST_MIPLINEAR:t.magFilter=9728,t.minFilter=9986;break;case f.Texture.LINEAR_LINEAR_MIPLINEAR:t.magFilter=9729,t.minFilter=9987;break;case f.Texture.LINEAR_LINEAR_MIPNEAREST:t.magFilter=9729,t.minFilter=9985;break;case f.Texture.NEAREST_NEAREST_MIPNEAREST:t.magFilter=9728,t.minFilter=9984}return t},e.prototype._getGLTFTextureWrapMode=function(e){switch(e){case f.Texture.WRAP_ADDRESSMODE:return 10497;case f.Texture.CLAMP_ADDRESSMODE:return 33071;case f.Texture.MIRROR_ADDRESSMODE:return 33648;default:return f.Tools.Error("Unsupported Texture Wrap Mode ".concat(e,"!")),10497}},e.prototype._getGLTFTextureWrapModesSampler=function(e){var t=this._getGLTFTextureWrapMode(e instanceof f.Texture?e.wrapU:f.Texture.WRAP_ADDRESSMODE),r=this._getGLTFTextureWrapMode(e instanceof f.Texture?e.wrapV:f.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,f.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||f.Tools.Warn(r.name+": Back-face culling enabled and two-sided lighting disabled is not supported in glTF."),n.doubleSided=!0),i){var c=r._bumpTexture;if(c){var h=this._exportTextureAsync(c,o).then((function(e){e&&(n.normalTexture=e,1!==c.level&&(n.normalTexture.scale=c.level))}));l.push(h)}var p=r._ambientTexture;p&&(h=this._exportTextureAsync(p,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(h));var d=r._emissiveTexture;d&&(h=this._exportTextureAsync(d,o).then((function(e){e&&(n.emissiveTexture=e)})),l.push(h))}var m=r._emissiveColor;e.FuzzyEquals(m,f.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,f.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 _(r,void 0,void 0,(function(){var r,n,a,o,i,s,u,l,c,f=this;return x(this,(function(h){switch(h.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=h.sent()))return[2,null];for(a=this._exporter._samplers,o=this._getGLTFTextureSampler(e),i=null,s=null,u=0;u=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=c;--o)a.setUInt32(r[o],n),n+=4;break;case f.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===f.Material.ClockWiseSideOrientation)switch(t){case f.Material.TriangleFillMode:this.reorderTriangleFillMode(e,t,r,n,a,o,i,s);break;case f.Material.TriangleStripDrawMode:this.reorderTriangleStripDrawMode(e,t,r,n,a,o,i,s);break;case f.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/f.VertexBuffer.GetTypeByteLength(u.type);if(e.verticesCount%3!=0)f.Tools.Error("The submesh vertices for the triangle fill mode is not divisible by 3!");else{var c=[],h=0;switch(n){case f.VertexBuffer.PositionKind:case f.VertexBuffer.NormalKind:for(var p=e.verticesStart;p=e.verticesStart;--p)h=p*l,c.push(f.Vector4.FromArray(a,h));break;case f.VertexBuffer.ColorKind:for(p=e.verticesStart+e.verticesCount-1;p>=e.verticesStart;--p)h=p*l,4===u.getSize()?c.push(f.Vector4.FromArray(a,h)):c.push(f.Vector3.FromArray(a,h));break;case f.VertexBuffer.UVKind:case f.VertexBuffer.UV2Kind:for(p=e.verticesStart+e.verticesCount-1;p>=e.verticesStart;--p)h=p*l,c.push(f.Vector2.FromArray(a,h));break;default:f.Tools.Error("Unsupported Vertex Buffer type: ".concat(n))}this.writeVertexAttributeData(c,o+12,n,a,i,s)}else f.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/f.VertexBuffer.GetTypeByteLength(u.type),c=[],h=0;switch(n){case f.VertexBuffer.PositionKind:case f.VertexBuffer.NormalKind:for(var p=e.verticesStart+e.verticesCount-1;p>=e.verticesStart;--p)h=p*l,c.push(f.Vector3.FromArray(a,h));break;case f.VertexBuffer.TangentKind:for(p=e.verticesStart+e.verticesCount-1;p>=e.verticesStart;--p)h=p*l,c.push(f.Vector4.FromArray(a,h));break;case f.VertexBuffer.ColorKind:for(p=e.verticesStart+e.verticesCount-1;p>=e.verticesStart;--p)h=p*l,c.push(f.Vector4.FromArray(a,h)),4===u.getSize()?c.push(f.Vector4.FromArray(a,h)):c.push(f.Vector3.FromArray(a,h));break;case f.VertexBuffer.UVKind:case f.VertexBuffer.UV2Kind:for(p=e.verticesStart+e.verticesCount-1;p>=e.verticesStart;--p)h=p*l,c.push(f.Vector2.FromArray(a,h));break;default:f.Tools.Error("Unsupported Vertex Buffer type: ".concat(n))}this.writeVertexAttributeData(c,o,n,a,i,s)}else f.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;i0){var G=null!==u.overrideMaterialSideOrientation?u.overrideMaterialSideOrientation:C.sideOrientation;if(G==f.Material.ClockWiseSideOrientation&&this._babylonScene.useRightHandedSystem||G==f.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 D=null;if(null!=c&&(D=u.getIndices()),D)this.reorderIndicesBasedOnPrimitiveMode(R,h,D,U,r);else for(var K=0,H=l;K0){o.weights=[];for(var s=0;sp&&(p=g));for(var g=0;g<=p;++g){var _=h[g];c.push(_.getInvertedAbsoluteTransform());var x=_.getTransformNode();x?l.joints.push(t[x.uniqueId]):f.Tools.Warn("Exporting a bone without a linked transform node is currently unsupported")}var y=64*c.length,T=r.getByteOffset(),v=d._CreateBufferView(0,T,y,void 0,"InverseBindMatrices - "+u.name);this._bufferViews.push(v);var b=this._bufferViews.length-1,A=d._CreateAccessor(b,"InverseBindMatrices - "+u.name,"MAT4",5126,c.length,null,null,null),F=this._accessors.push(A)-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}(),b=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;athis._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?tthis._arrayBuffer.byteLength&&this.resizeBuffer(2*this._arrayBuffer.byteLength),this._dataView.setUint16(this._byteOffset,e,!0),this._byteOffset+=2)},e.prototype.getUInt32=function(e){if(ethis._byteOffset?f.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?f.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?f.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?f.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)&&f.Tools.Error("Invalid data being written!"),null!=t&&(tthis._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?tthis._arrayBuffer.byteLength&&this.resizeBuffer(2*this._arrayBuffer.byteLength),this._dataView.setUint32(this._byteOffset,e,!0),this._byteOffset+=4)},e}(),A=0,F=function(){function e(){}return e.GLTFAsync=function(e,t,r){return e.whenReadyAsync().then((function(){var n=t.replace(/\.[^/.]+$/,"");return new v(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 v(e,r)._generateGLBAsync(a).then((function(t){return n._PostExportAsync(e,t,r)}))}))},e}();f.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 M="KHR_texture_transform",E=function(){function e(e){this._recordedTextures=[],this.name=M,this.enabled=!0,this.required=!1,this._wasUsed=!1}return e.prototype.dispose=function(){for(var e=0,t=this._recordedTextures;e-1||(O.GLTF2.Exporter[G]=s[G])}var U=void 0!==n.g?n.g:"undefined"!=typeof window?window:void 0;if(void 0!==U)for(var D in e)U.BABYLON[D]=e[D];var K=void 0!==n.g?n.g:"undefined"!=typeof window?window:void 0;if(void 0!==K)for(var H in u)K.BABYLON[H]=u[H];const z=l})(),a.default})()})); //# sourceMappingURL=babylonjs.serializers.min.js.map