babylonjs-serializers 9.4.0 → 9.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "babylonjs-serializers",
3
- "version": "9.4.0",
3
+ "version": "9.5.0",
4
4
  "main": "babylonjs.serializers.min.js",
5
5
  "types": "babylonjs.serializers.module.d.ts",
6
6
  "files": [
@@ -8,25 +8,20 @@
8
8
  ],
9
9
  "scripts": {
10
10
  "build": "npm run clean && npm run build:prod && npm run build:declaration",
11
- "build:dev": "webpack --env development",
12
- "build:prod": "webpack --env production",
11
+ "build:dev": "rollup -c rollup.config.umd.mjs",
12
+ "build:prod": "rollup -c rollup.config.umd.mjs --environment ROLLUP_MODE:production",
13
13
  "build:declaration": "build-tools -c pud --config ./config.json",
14
14
  "clean": "rimraf dist && rimraf babylon*.* -g",
15
15
  "test:escheck": "es-check es6 ./babylonjs.serializers.js"
16
16
  },
17
17
  "dependencies": {
18
- "babylonjs": "9.4.0",
19
- "babylonjs-gltf2interface": "9.4.0"
18
+ "babylonjs": "9.5.0",
19
+ "babylonjs-gltf2interface": "9.5.0"
20
20
  },
21
21
  "devDependencies": {
22
22
  "@dev/build-tools": "1.0.0",
23
23
  "@dev/core": "1.0.0",
24
- "@dev/serializers": "^1.0.0",
25
- "source-map-loader": "^4.0.0",
26
- "ts-loader": "^9.2.6",
27
- "webpack": "^5.103.0",
28
- "webpack-cli": "6.0.1",
29
- "webpack-merge": "^5.8.0"
24
+ "@dev/serializers": "^1.0.0"
30
25
  },
31
26
  "keywords": [
32
27
  "3D",
@@ -0,0 +1,25 @@
1
+ import { commonUMDRollupConfiguration } from "../../rollupUMDHelper.mjs";
2
+ import path from "path";
3
+
4
+ const mode = process.env.ROLLUP_MODE === "production" ? "production" : "development";
5
+ const production = mode === "production";
6
+
7
+ export default commonUMDRollupConfiguration({
8
+ mode,
9
+ devPackageName: "serializers",
10
+ outputPath: path.resolve("."),
11
+ entryPoints: {
12
+ serializers: "./src/index.ts",
13
+ glTF2: "./src/glTF2.ts",
14
+ obj: "./src/obj.ts",
15
+ stl: "./src/stl.ts",
16
+ usdz: "./src/USDZ.ts",
17
+ threemf: "./src/3mf.ts",
18
+ },
19
+ alias: {
20
+ serializers: path.resolve("../../../dev/serializers/src"),
21
+ },
22
+ overrideFilename: (pathData) =>
23
+ pathData.chunk.name === "serializers" ? `babylonjs.serializers${production ? ".min" : ""}.js` : `babylon.${pathData.chunk.name}Serializer${production ? ".min" : ""}.js`,
24
+ minToMax: true,
25
+ });
@@ -1,2 +0,0 @@
1
- !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("babylonjs")):"function"==typeof define&&define.amd?define("babylonjs-serializers",["babylonjs"],t):"object"==typeof exports?exports["babylonjs-serializers"]=t(require("babylonjs")):e.SERIALIZERS=t(e.BABYLON)}("undefined"!=typeof self?self:"undefined"!=typeof global?global:this,e=>(()=>{"use strict";var t={597(t){t.exports=e}},r={};function n(e){var s=r[e];if(void 0!==s)return s.exports;var o=r[e]={exports:{}};return t[e](o,o.exports,n),o.exports}n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var s={};n.d(s,{default:()=>Mt});var o={};n.r(o),n.d(o,{__IGLTFExporterExtension:()=>h});var i={};n.r(i),n.d(i,{GLTFData:()=>p});var a={};n.r(a),n.d(a,{GLTF2Export:()=>oe});var u={};n.r(u),n.d(u,{EXT_lights_area:()=>ve,EXT_mesh_gpu_instancing:()=>ue,EXT_texture_avif:()=>Tt,EXT_texture_webp:()=>_t,KHR_draco_mesh_compression:()=>he,KHR_lights_punctual:()=>ge,KHR_materials_anisotropy:()=>Me,KHR_materials_clearcoat:()=>Ce,KHR_materials_coat:()=>Oe,KHR_materials_diffuse_roughness:()=>ct,KHR_materials_diffuse_transmission:()=>Pe,KHR_materials_dispersion:()=>Le,KHR_materials_emissive_strength:()=>Ke,KHR_materials_fuzz:()=>Ze,KHR_materials_ior:()=>Ge,KHR_materials_iridescence:()=>He,KHR_materials_openpbr:()=>ht,KHR_materials_sheen:()=>je,KHR_materials_specular:()=>$e,KHR_materials_transmission:()=>tt,KHR_materials_unlit:()=>nt,KHR_materials_volume:()=>ot,KHR_materials_volume_scatter:()=>at,KHR_texture_basisu:()=>xt,KHR_texture_transform:()=>pt});var c={};n.r(c),n.d(c,{EXT_lights_area:()=>ve,EXT_mesh_gpu_instancing:()=>ue,EXT_texture_avif:()=>Tt,EXT_texture_webp:()=>_t,GLTF2Export:()=>oe,GLTFData:()=>p,KHR_draco_mesh_compression:()=>he,KHR_lights_punctual:()=>ge,KHR_materials_anisotropy:()=>Me,KHR_materials_clearcoat:()=>Ce,KHR_materials_coat:()=>Oe,KHR_materials_diffuse_roughness:()=>ct,KHR_materials_diffuse_transmission:()=>Pe,KHR_materials_dispersion:()=>Le,KHR_materials_emissive_strength:()=>Ke,KHR_materials_fuzz:()=>Ze,KHR_materials_ior:()=>Ge,KHR_materials_iridescence:()=>He,KHR_materials_openpbr:()=>ht,KHR_materials_sheen:()=>je,KHR_materials_specular:()=>$e,KHR_materials_transmission:()=>tt,KHR_materials_unlit:()=>nt,KHR_materials_volume:()=>ot,KHR_materials_volume_scatter:()=>at,KHR_texture_basisu:()=>xt,KHR_texture_transform:()=>pt,_ConvertToGLTFPBRMetallicRoughness:()=>R,_SolveMetallic:()=>A});var l={};n.r(l),n.d(l,{EXT_lights_area:()=>ve,EXT_mesh_gpu_instancing:()=>ue,EXT_texture_avif:()=>Tt,EXT_texture_webp:()=>_t,GLTF2Export:()=>oe,GLTFData:()=>p,KHR_draco_mesh_compression:()=>he,KHR_lights_punctual:()=>ge,KHR_materials_anisotropy:()=>Me,KHR_materials_clearcoat:()=>Ce,KHR_materials_coat:()=>Oe,KHR_materials_diffuse_roughness:()=>ct,KHR_materials_diffuse_transmission:()=>Pe,KHR_materials_dispersion:()=>Le,KHR_materials_emissive_strength:()=>Ke,KHR_materials_fuzz:()=>Ze,KHR_materials_ior:()=>Ge,KHR_materials_iridescence:()=>He,KHR_materials_openpbr:()=>ht,KHR_materials_sheen:()=>je,KHR_materials_specular:()=>$e,KHR_materials_transmission:()=>tt,KHR_materials_unlit:()=>nt,KHR_materials_volume:()=>ot,KHR_materials_volume_scatter:()=>at,KHR_texture_basisu:()=>xt,KHR_texture_transform:()=>pt,_ConvertToGLTFPBRMetallicRoughness:()=>R,_SolveMetallic:()=>A,__IGLTFExporterExtension:()=>h});var h=0,f=n(597),p=function(){function e(){this.files={}}return Object.defineProperty(e.prototype,"glTFFiles",{get:function(){return this.files},enumerable:!1,configurable:!0}),e.prototype.downloadFiles=function(){for(var e in this.files){var t=this.files[e],r=new Blob([t],{type:(0,f.GetMimeType)(e)});f.Tools.Download(r,e)}},e}(),d=function(){return d=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var s in t=arguments[r])Object.prototype.hasOwnProperty.call(t,s)&&(e[s]=t[s]);return e},d.apply(this,arguments)};function x(e,t,r,n){return new(r||(r=Promise))(function(s,o){function i(e){try{u(n.next(e))}catch(e){o(e)}}function a(e){try{u(n.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?s(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(i,a)}u((n=n.apply(e,t||[])).next())})}function g(e,t){var r,n,s,o={label:0,sent:function(){if(1&s[0])throw s[1];return s[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=a(0),i.throw=a(1),i.return=a(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(a){return function(u){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,a[0]&&(o=0)),o;)try{if(r=1,n&&(s=2&a[0]?n.return:a[0]?n.throw||((s=n.return)&&s.call(n),0):n.next)&&!(s=s.call(n,a[1])).done)return s;switch(n=0,s&&(a=[2&a[0],s.value]),a[0]){case 0:case 1:s=a;break;case 4:return o.label++,{value:a[1],done:!1};case 5:o.label++,n=a[1],a=[0];continue;case 7:a=o.ops.pop(),o.trys.pop();continue;default:if(!((s=(s=o.trys).length>0&&s[s.length-1])||6!==a[0]&&2!==a[0])){o=0;continue}if(3===a[0]&&(!s||a[1]>s[0]&&a[1]<s[3])){o.label=a[1];break}if(6===a[0]&&o.label<s[1]){o.label=s[1],s=a;break}if(s&&o.label<s[2]){o.label=s[2],o.ops.push(a);break}s[2]&&o.ops.pop(),o.trys.pop();continue}a=t.call(e,o)}catch(e){a=[6,e],n=0}finally{r=s=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}}function _(e,t,r){if(r||2===arguments.length)for(var n,s=0,o=t.length;s<o;s++)!n&&s in t||(n||(n=Array.prototype.slice.call(t,0,s)),n[s]=t[s]);return e.concat(n||Array.prototype.slice.call(t))}Object.create,Object.create,"function"==typeof SuppressedError&&SuppressedError;var m=1e-6,T=new f.Color3(.04,.04,.04),y=1024,v=f.Color3.White(),b=f.Color3.BlackReadOnly;function w(e){switch(e){case"image/jpeg":case"image/png":case"image/webp":case"image/avif":case"image/ktx2":return!0;default:return!1}}function M(e){return x(this,void 0,void 0,function(){var t,r,n,s;return g(this,function(o){switch(o.label){case 0:if(!(t=e.getInternalTexture())||1!==t.source)return[2,null];if(t.invertY)return[2,null];r=t._buffer,s=e.mimeType,o.label=1;case 1:return o.trys.push([1,12,,13]),r?[3,3]:[4,f.Tools.LoadFileAsync(t.url)];case 2:return n=o.sent(),s=(0,f.GetMimeType)(t.url)||s,[3,11];case 3:return ArrayBuffer.isView(r)?(n=r.buffer.slice(r.byteOffset,r.byteOffset+r.byteLength),[3,11]):[3,4];case 4:return r instanceof ArrayBuffer?(n=r,[3,11]):[3,5];case 5:return r instanceof Blob?[4,r.arrayBuffer()]:[3,7];case 6:return n=o.sent(),s=r.type||s,[3,11];case 7:return"string"!=typeof r?[3,9]:[4,f.Tools.LoadFileAsync(r)];case 8:return n=o.sent(),s=(0,f.GetMimeType)(r)||s,[3,11];case 9:return"undefined"!=typeof HTMLImageElement&&r instanceof HTMLImageElement?[4,f.Tools.LoadFileAsync(r.src)]:[3,11];case 10:n=o.sent(),s=(0,f.GetMimeType)(r.src)||s,o.label=11;case 11:return[3,13];case 12:return o.sent(),[2,null];case 13:return n&&w(s)?[2,new Blob([n],{type:s})]:[2,null]}})})}function A(e,t,r){if(t<T.r)return 0;var n=T.r,s=e*r/(1-T.r)+t-2*T.r,o=s*s-4*n*(T.r-t);return f.Scalar.Clamp((-s+Math.sqrt(o))/(2*n),0,1)}function R(e){var t=e.diffuseColor.toLinearSpace(e.getScene().getEngine().useExactSrgbConversions).scale(.5),r=e.alpha,n=f.Scalar.Clamp(e.specularPower,0,y),s=(0,f.SpecularPowerToRoughness)(n);return{baseColorFactor:[t.r,t.g,t.b,r],metallicFactor:0,roughnessFactor:s}}function E(e,t){t.needAlphaBlending()?e.alphaMode="BLEND":t.needAlphaTesting()&&(e.alphaMode="MASK",e.alphaCutoff=t.alphaCutOff)}function C(e,t,r){for(var n=new Uint8Array(e*t*4),s=0;s<n.length;s+=4)n[s]=n[s+1]=n[s+2]=n[s+3]=255;return f.RawTexture.CreateRGBATexture(n,e,t,r)}function I(e){if(e instanceof Uint8Array){for(var t=e.length,r=new Float32Array(e.length),n=0;n<t;++n)r[n]=e[n]/255;return r}if(e instanceof Float32Array)return e;throw new Error("Unsupported pixel format!")}var V=function(){function e(e){this._exporter=e,this._textureMap=new Map,this._internalTextureToImage={}}return e.prototype.getTextureInfo=function(e){var t;return e&&null!==(t=this._textureMap.get(e.uniqueId))&&void 0!==t?t:null},e.prototype.exportStandardMaterialAsync=function(e,t){return x(this,void 0,void 0,function(){var r,n,s,o,i,a,u,c;return g(this,function(l){switch(l.label){case 0:return r=R(e),n={name:e.name},null==e.backFaceCulling||e.backFaceCulling||(e.twoSidedLighting||f.Tools.Warn(e.name+": Back-face culling disabled and two-sided lighting disabled is not supported in glTF."),n.doubleSided=!0),t?(s=[],(o=e.diffuseTexture)&&s.push(this.exportTextureAsync(o).then(function(e){e&&(r.baseColorTexture=e)})),(i=e.bumpTexture)&&s.push(this.exportTextureAsync(i).then(function(e){e&&(n.normalTexture=e,1!==i.level&&(n.normalTexture.scale=i.level))})),(a=e.emissiveTexture)&&(n.emissiveFactor=[1,1,1],s.push(this.exportTextureAsync(a).then(function(e){e&&(n.emissiveTexture=e)}))),(u=e.ambientTexture)&&s.push(this.exportTextureAsync(u).then(function(e){if(e){var t={index:e.index};n.occlusionTexture=t}})),s.length>0?(this._exporter._materialNeedsUVsSet.add(e),[4,Promise.all(s)]):[3,2]):[3,2];case 1:l.sent(),l.label=2;case 2:return(e.alpha<1||e.opacityTexture)&&(e.alphaMode===f.Constants.ALPHA_COMBINE?n.alphaMode="BLEND":f.Tools.Warn(e.name+": glTF 2.0 does not support alpha mode: "+e.alphaMode.toString())),e.emissiveColor&&!e.emissiveColor.equalsWithEpsilon(b,m)&&(n.emissiveFactor=e.emissiveColor.asArray()),n.pbrMetallicRoughness=r,E(n,e),[4,this._finishMaterialAsync(n,e)];case 3:return l.sent(),(c=this._exporter._materials).push(n),[2,c.length-1]}})})},e.prototype._finishMaterialAsync=function(e,t){return x(this,void 0,void 0,function(){var r,n,s,o,i;return g(this,function(a){switch(a.label){case 0:return[4,this._exporter._extensionsPostExportMaterialAdditionalTexturesAsync("exportMaterial",e,t)];case 1:for(r=a.sent(),n=[],s=0,o=r;s<o.length;s++)i=o[s],n.push(this.exportTextureAsync(i));return[4,Promise.all(n)];case 2:return a.sent(),[4,this._exporter._extensionsPostExportMaterialAsync("exportMaterial",e,t)];case 3:return a.sent(),[2]}})})},e.prototype._resizeTexturesToSameDimensions=function(e,t,r){var n,s,o=e?e.getSize():{width:0,height:0},i=t?t.getSize():{width:0,height:0};return o.width<i.width?(n=e&&e instanceof f.Texture?f.TextureTools.CreateResizedCopy(e,i.width,i.height,!0):C(i.width,i.height,r),s=t):o.width>i.width?(s=t&&t instanceof f.Texture?f.TextureTools.CreateResizedCopy(t,o.width,o.height,!0):C(o.width,o.height,r),n=e):(n=e,s=t),{texture1:n,texture2:s}},e.prototype._convertSpecularGlossinessTexturesToMetallicRoughnessAsync=function(e,t,r){return x(this,void 0,void 0,function(){var n,s,o,i,a,u,c,l,h,p,d,x,_,T,y,b,w,M,A,R,E,C,V,S,F,B,O,N,U,P,W;return g(this,function(g){switch(g.label){case 0:return n=new Array,e||t?[3,2]:[4,Promise.reject("diffuse and specular glossiness textures are not defined!")];case 1:case 6:case 9:case 11:case 13:return[2,g.sent()];case 2:return(s=e?e.getScene():t?t.getScene():null)?(o=this._resizeTexturesToSameDimensions(e,t,s),i=null===(W=o.texture1)||void 0===W?void 0:W.getSize(),a=void 0,u=void 0,c=i.width,l=i.height,[4,o.texture1.readPixels()]):[3,12];case 3:return h=g.sent(),[4,o.texture2.readPixels()];case 4:return p=g.sent(),h?(a=I(h),[3,7]):[3,5];case 5:return[4,Promise.reject("Failed to retrieve pixels from diffuse texture!")];case 7:return p?(u=I(p),[3,10]):[3,8];case 8:return[4,Promise.reject("Failed to retrieve pixels from specular glossiness texture!")];case 10:for(d=u.byteLength,x=new Uint8Array(d),_=new Uint8Array(d),T=new f.Color3(0,0,0),y=0,b=0,B=0;B<l;++B)for(O=0;O<c;++O)w=4*(c*B+O),M=new f.Color3(a[w],a[w+1],a[w+2]).toLinearSpace(s.getEngine().useExactSrgbConversions).multiply(r.diffuseColor),A=new f.Color3(u[w],u[w+1],u[w+2]).toLinearSpace(s.getEngine().useExactSrgbConversions).multiply(r.specularColor),R=u[w+3]*r.glossiness,E={diffuseColor:M,specularColor:A,glossiness:R},C=this._convertSpecularGlossinessToMetallicRoughness(E),T.r=Math.max(T.r,C.baseColor.r),T.g=Math.max(T.g,C.baseColor.g),T.b=Math.max(T.b,C.baseColor.b),y=Math.max(y,C.metallic),b=Math.max(b,C.roughness),_[w]=255*C.baseColor.r,_[w+1]=255*C.baseColor.g,_[w+2]=255*C.baseColor.b,_[w+3]=o.texture1.hasAlpha?255*a[w+3]:255,x[w]=0,x[w+1]=255*C.roughness,x[w+2]=255*C.metallic,x[w+3]=255;for(V={baseColor:T,metallic:y,roughness:b},S=!1,F=!1,B=0;B<l;++B)for(O=0;O<c;++O)_[N=4*(c*B+O)]/=V.baseColor.r>m?V.baseColor.r:1,_[N+1]/=V.baseColor.g>m?V.baseColor.g:1,_[N+2]/=V.baseColor.b>m?V.baseColor.b:1,U=f.Color3.FromInts(_[N],_[N+1],_[N+2]),P=U.toGammaSpace(s.getEngine().useExactSrgbConversions),_[N]=255*P.r,_[N+1]=255*P.g,_[N+2]=255*P.b,P.equalsWithEpsilon(v,m)||(F=!0),x[N+1]/=V.roughness>m?V.roughness:1,x[N+2]/=V.metallic>m?V.metallic:1,f.Color3.FromInts(255,x[N+1],x[N+2]).equalsWithEpsilon(v,m)||(S=!0);return S&&n.push((0,f.EncodeImageAsync)(x,c,l).then(function(e){V.metallicRoughnessTextureData=e})),F&&n.push((0,f.EncodeImageAsync)(_,c,l).then(function(e){V.baseColorTextureData=e})),[4,Promise.all(n).then(function(){return V})];case 12:return[4,Promise.reject("_ConvertSpecularGlossinessTexturesToMetallicRoughness: Scene from textures is missing!")]}})})},e.prototype._convertSpecularGlossinessToMetallicRoughness=function(e){var t=this._getPerceivedBrightness(e.diffuseColor),r=this._getPerceivedBrightness(e.specularColor),n=1-this._getMaxComponent(e.specularColor),s=A(t,r,n),o=e.diffuseColor.scale(n/(1-T.r)/Math.max(1-s,m)),i=e.specularColor.subtract(T.scale(1-s)).scale(1/Math.max(s,m)),a=f.Color3.Lerp(o,i,s*s);return{baseColor:a=a.clampToRef(0,1,a),metallic:s,roughness:1-e.glossiness}},e.prototype._getPerceivedBrightness=function(e){return Math.sqrt(.299*e.r*e.r+.587*e.g*e.g+.114*e.b*e.b)},e.prototype._getMaxComponent=function(e){return Math.max(e.r,Math.max(e.g,e.b))},e.prototype._convertMetalRoughFactorsToMetallicRoughnessAsync=function(e,t,r,n,s,o,i,a,u){return x(this,void 0,void 0,function(){var c,l,h,p,d,_,m,T,y,v=this;return g(this,function(b){switch(b.label){case 0:return c=[],l={baseColor:e,metallic:t,roughness:r},u&&(i instanceof f.OpenPBRMaterial?(i.geometryOpacityTexture?(h=n&&n.getInternalTexture()?n.getInternalTexture().uniqueId:0,p=i.geometryOpacityTexture&&i.geometryOpacityTexture.getInternalTexture()?i.geometryOpacityTexture.getInternalTexture().uniqueId:0,d=Number("".concat(h).concat(p)),(y=this._textureMap.get(d))?a.baseColorTexture=y:c.push((0,f.MergeTexturesAsync)("baseColorOpacityTexture",(0,f.CreateRGBAConfiguration)(n?(0,f.CreateTextureInput)(n,0):(0,f.CreateConstantInput)(1),n?(0,f.CreateTextureInput)(n,1):(0,f.CreateConstantInput)(1),n?(0,f.CreateTextureInput)(n,2):(0,f.CreateConstantInput)(1),(0,f.CreateTextureInput)(i.geometryOpacityTexture,0)),i.getScene()).then(function(e){return x(v,void 0,void 0,function(){var t;return g(this,function(r){switch(r.label){case 0:return[4,this.exportTextureAsync(e,d)];case 1:return(t=r.sent())&&(a.baseColorTexture=t),[2]}})})}))):n&&c.push(this.exportTextureAsync(n).then(function(e){e&&(a.baseColorTexture=e)})),i._useMetallicFromMetallicTextureBlue&&s?c.push(this.exportTextureAsync(s).then(function(e){e&&(a.metallicRoughnessTexture=e)})):(o||s)&&(_=s&&s.getInternalTexture()?s.getInternalTexture().uniqueId:0,m=o&&o.getInternalTexture()?o.getInternalTexture().uniqueId:0,T=Number("".concat(_).concat(m)),(y=this._textureMap.get(T))?a.metallicRoughnessTexture=y:c.push((0,f.MergeTexturesAsync)("MetalRoughTexture",(0,f.CreateRGBAConfiguration)(i.ambientOcclusionTexture?(0,f.CreateTextureInput)(i.ambientOcclusionTexture,0):(0,f.CreateConstantInput)(1),o?(0,f.CreateTextureInput)(o,0):(0,f.CreateConstantInput)(1),s?(0,f.CreateTextureInput)(s,0):(0,f.CreateConstantInput)(1)),i.getScene()).then(function(e){return x(v,void 0,void 0,function(){var t;return g(this,function(r){switch(r.label){case 0:return[4,this.exportTextureAsync(e,T)];case 1:return(t=r.sent())&&(a.metallicRoughnessTexture=t),[2]}})})})))):(n&&c.push(this.exportTextureAsync(n).then(function(e){e&&(a.baseColorTexture=e)})),s&&c.push(this.exportTextureAsync(s).then(function(e){e&&(a.metallicRoughnessTexture=e)})))),c.length>0?(this._exporter._materialNeedsUVsSet.add(i),[4,Promise.all(c)]):[3,2];case 1:b.sent(),b.label=2;case 2:return[2,l]}})})},e.prototype._getTextureSampler=function(e){var t={};if(!(e&&e instanceof f.Texture))return t;var r=this._getGLTFTextureWrapMode(e.wrapU);10497!==r&&(t.wrapS=r);var n=this._getGLTFTextureWrapMode(e.wrapV);switch(10497!==n&&(t.wrapT=n),e.samplingMode){case f.Texture.LINEAR_LINEAR:t.magFilter=9729,t.minFilter=9729;break;case f.Texture.LINEAR_NEAREST:t.magFilter=9729,t.minFilter=9728;break;case f.Texture.NEAREST_LINEAR:t.magFilter=9728,t.minFilter=9729;break;case f.Texture.NEAREST_LINEAR_MIPLINEAR:t.magFilter=9728,t.minFilter=9987;break;case f.Texture.NEAREST_NEAREST:t.magFilter=9728,t.minFilter=9728;break;case f.Texture.NEAREST_LINEAR_MIPNEAREST:t.magFilter=9728,t.minFilter=9985;break;case f.Texture.LINEAR_NEAREST_MIPNEAREST:t.magFilter=9729,t.minFilter=9984;break;case f.Texture.LINEAR_NEAREST_MIPLINEAR:t.magFilter=9729,t.minFilter=9986;break;case f.Texture.NEAREST_NEAREST_MIPLINEAR:t.magFilter=9728,t.minFilter=9986;break;case f.Texture.LINEAR_LINEAR_MIPLINEAR:t.magFilter=9729,t.minFilter=9987;break;case f.Texture.LINEAR_LINEAR_MIPNEAREST:t.magFilter=9729,t.minFilter=9985;break;case f.Texture.NEAREST_NEAREST_MIPNEAREST:t.magFilter=9728,t.minFilter=9984}return t},e.prototype._getGLTFTextureWrapMode=function(e){switch(e){case f.Texture.WRAP_ADDRESSMODE:return 10497;case f.Texture.CLAMP_ADDRESSMODE:return 33071;case f.Texture.MIRROR_ADDRESSMODE:return 33648;default:return f.Tools.Error("Unsupported Texture Wrap Mode ".concat(e,"!")),10497}},e.prototype._convertSpecGlossFactorsToMetallicRoughnessAsync=function(e,t,r){return x(this,void 0,void 0,function(){var n,s,o,i,a,u,c,l;return g(this,function(h){switch(h.label){case 0:return n={diffuseColor:e._albedoColor,specularColor:e._reflectivityColor,glossiness:e._microSurface},s=e._albedoTexture,o=e._reflectivityTexture,i=e._useMicroSurfaceFromReflectivityMapAlpha,!o||i?[3,2]:[4,Promise.reject("_ConvertPBRMaterial: Glossiness values not included in the reflectivity texture are currently not supported")];case 1:return[2,h.sent()];case 2:return(s||o)&&r?(this._exporter._materialNeedsUVsSet.add(e),a=this._exportTextureSampler(s||o),[4,this._convertSpecularGlossinessTexturesToMetallicRoughnessAsync(s,o,n)]):[3,8];case 3:return u=h.sent(),c=this._exporter._textures,u.baseColorTextureData?[4,this._exportImageAsync("baseColor".concat(c.length),u.baseColorTextureData)]:[3,5];case 4:l=h.sent(),t.baseColorTexture=this._exportTextureInfo(l,a,null==s?void 0:s.coordinatesIndex),h.label=5;case 5:return u.metallicRoughnessTextureData?[4,this._exportImageAsync("metallicRoughness".concat(c.length),u.metallicRoughnessTextureData)]:[3,7];case 6:l=h.sent(),t.metallicRoughnessTexture=this._exportTextureInfo(l,a,null==o?void 0:o.coordinatesIndex),h.label=7;case 7:return[2,u];case 8:return[2,this._convertSpecularGlossinessToMetallicRoughness(n)]}})})},e.prototype.exportPBRMaterialAsync=function(e,t){return x(this,void 0,void 0,function(){var r,n,s,o,i,a,u,c;return g(this,function(l){switch(l.label){case 0:return r={},n={name:e.name},(s=e.isMetallicWorkflow())&&(o=e._albedoColor,i=e.alpha,o&&(r.baseColorFactor=[o.r,o.g,o.b,i])),s?[4,this._convertMetalRoughFactorsToMetallicRoughnessAsync(e._albedoColor,e._metallic,e._roughness,e._albedoTexture,e._metallicTexture,e._metallicTexture,e,r,t)]:[3,2];case 1:return u=l.sent(),[3,4];case 2:return[4,this._convertSpecGlossFactorsToMetallicRoughnessAsync(e,r,t)];case 3:u=l.sent(),l.label=4;case 4:return a=u,[4,this._setMetallicRoughnessPbrMaterialAsync(a,e,n,r,t)];case 5:return l.sent(),[4,this._finishMaterialAsync(n,e)];case 6:return l.sent(),(c=this._exporter._materials).push(n),[2,c.length-1]}})})},e.prototype._setMetallicRoughnessPbrMaterialAsync=function(e,t,r,n,s){return x(this,void 0,void 0,function(){var o,i,a,u,c,l=this;return g(this,function(h){switch(h.label){case 0:return E(r,t),e.baseColor.equalsWithEpsilon(v,m)&&f.Scalar.WithinEpsilon(t.alpha,1,m)||(n.baseColorFactor=[e.baseColor.r,e.baseColor.g,e.baseColor.b,t.alpha]),null!=e.metallic&&1!==e.metallic&&(n.metallicFactor=e.metallic),null!=e.roughness&&1!==e.roughness&&(n.roughnessFactor=e.roughness),null==t.backFaceCulling||t.backFaceCulling||(t._twoSidedLighting||f.Tools.Warn(t.name+": Back-face culling disabled and two-sided lighting disabled is not supported in glTF."),r.doubleSided=!0),s?(o=[],(i=t instanceof f.PBRBaseMaterial?t._bumpTexture:t.geometryNormalTexture)&&o.push(this.exportTextureAsync(i).then(function(e){e&&(r.normalTexture=e,1!==i.level&&(r.normalTexture.scale=i.level))})),(a=t instanceof f.PBRBaseMaterial?t._ambientTexture:t.ambientOcclusionTexture)&&o.push(new Promise(function(e){return x(l,void 0,void 0,function(){var r,s,o,i;return g(this,function(u){switch(u.label){case 0:return t instanceof f.OpenPBRMaterial&&n.metallicRoughnessTexture?(r=this._exportTextureSampler(a),s=this._exporter._textures[n.metallicRoughnessTexture.index].source,o=this._exportTextureInfo(s,r,a.coordinatesIndex),this._textureMap.set(a.uniqueId,o),this._exporter._extensionsPostExportTextures("exporter",o,a),[2,e(o)]):[3,1];case 1:return i=e,[4,this.exportTextureAsync(a)];case 2:return[2,i.apply(void 0,[u.sent()])]}})})}).then(function(e){return x(l,void 0,void 0,function(){var n;return g(this,function(s){return e&&(n={index:e.index,texCoord:e.texCoord,extensions:e.extensions},r.occlusionTexture=n,t instanceof f.PBRBaseMaterial?n.strength=t._ambientTextureStrength:n.strength=t.ambientOcclusionTexture.level),[2]})})})),(u=t instanceof f.PBRBaseMaterial?t._emissiveTexture:t.emissionColorTexture)&&o.push(this.exportTextureAsync(u).then(function(e){e&&(r.emissiveTexture=e)})),o.length>0?(this._exporter._materialNeedsUVsSet.add(t),[4,Promise.all(o)]):[3,2]):[3,2];case 1:h.sent(),h.label=2;case 2:return(c=t instanceof f.PBRBaseMaterial?t._emissiveColor:t.emissionColor).equalsWithEpsilon(b,m)||(r.emissiveFactor=c.asArray()),r.pbrMetallicRoughness=n,[2]}})})},e.prototype.exportOpenPBRMaterialAsync=function(e,t){return x(this,void 0,void 0,function(){var r,n,s,o,i,a;return g(this,function(u){switch(u.label){case 0:return r={},n={name:e.name},s=e.baseColor,o=e.geometryOpacity,s&&(r.baseColorFactor=[s.r,s.g,s.b,o]),[4,this._convertMetalRoughFactorsToMetallicRoughnessAsync(e.baseColor,e.baseMetalness,e.specularRoughness,e.baseColorTexture,e.baseMetalnessTexture,e.specularRoughnessTexture,e,r,t)];case 1:return i=u.sent(),[4,this._setMetallicRoughnessPbrMaterialAsync(i,e,n,r,t)];case 2:return u.sent(),[4,this._finishMaterialAsync(n,e)];case 3:return u.sent(),(a=this._exporter._materials).push(n),[2,a.length-1]}})})},e.prototype.exportTextureAsync=function(e){return x(this,arguments,void 0,function(e,t){var r,n,s;return void 0===t&&(t=null),g(this,function(o){switch(o.label){case 0:return(r=this._textureMap.get(null!=t?t:e.uniqueId))?[2,r]:(n=this._exportTextureSampler(e),[4,this._exportTextureImageAsync(e)]);case 1:return s=o.sent(),r=this._exportTextureInfo(s,n,e.coordinatesIndex),this._textureMap.set(null!=t?t:e.uniqueId,r),this._exporter._extensionsPostExportTextures("exporter",r,e),[2,r]}})})},e.prototype._exportTextureImageAsync=function(e){return x(this,void 0,void 0,function(){var t,r,n,s,o,i=this;return g(this,function(a){switch(a.label){case 0:return t=null!==(o=e.mimeType)&&void 0!==o?o:"none",r=this._internalTextureToImage,n=e.getInternalTexture().uniqueId,r[n]=r[n]||{},void 0===(s=r[n][t])&&(s=x(i,void 0,void 0,function(){var r,n,s,o,i;return g(this,function(a){switch(a.label){case 0:return[4,M(e)];case 1:return!(r=a.sent())||"none"!==t&&r.type!==t?[3,3]:[4,this._exportImageAsync(e.name,r)];case 2:case 6:return[2,a.sent()];case 3:return n="image/png","none"!==t&&(w(t)?n=t:(n="image/png",f.Tools.Warn("Unsupported media type: ".concat(t,". Exporting texture as PNG.")))),s=e.getSize(),[4,(0,f.GetTextureDataAsync)(e)];case 4:return o=a.sent(),[4,(0,f.EncodeImageAsync)(o,s.width,s.height,n)];case 5:return i=a.sent(),[4,this._exportImageAsync(e.name,i)]}})}),r[n][t]=s),[4,s];case 1:return[2,a.sent()]}})})},e.prototype._exportImageAsync=function(e,t){return x(this,void 0,void 0,function(){var r,n,s,o,i,a,u;return g(this,function(c){switch(c.label){case 0:return r=this._exporter._images,this._exporter._shouldUseGlb?(n={name:e,mimeType:t.type,bufferView:void 0},[4,t.arrayBuffer()]):[3,2];case 1:return s=c.sent(),o=this._exporter._bufferManager.createBufferView(new Uint8Array(s)),this._exporter._bufferManager.setBufferView(n,o),[3,3];case 2:i=e.replace(/\.\/|\/|\.\\|\\/g,"_"),a=function(e){switch(e){case"image/jpeg":return".jpg";case"image/png":return".png";case"image/webp":return".webp";case"image/avif":return".avif";case"image/ktx2":return".ktx2"}}(t.type),u=i+a,r.some(function(e){return e.uri===u})&&(u="".concat(i,"_").concat(f.Tools.RandomId()).concat(a)),n={name:e,uri:u},this._exporter._imageData[u]=t,c.label=3;case 3:return r.push(n),[2,r.length-1]}})})},e.prototype._exportTextureInfo=function(e,t,r){var n=this._exporter._textures,s=n.findIndex(function(r){return r.sampler==t&&r.source===e});-1===s&&(s=n.length,n.push({source:e,sampler:t}));var o={index:s};return r&&(o.texCoord=r),o},e.prototype._exportTextureSampler=function(e){var t=this._getTextureSampler(e),r=this._exporter._samplers,n=r.findIndex(function(e){return e.minFilter===t.minFilter&&e.magFilter===t.magFilter&&e.wrapS===t.wrapS&&e.wrapT===t.wrapT});return-1!==n?n:(r.push(t),r.length-1)},e}(),S=f.Matrix.Compose(new f.Vector3(-1,1,1),f.Quaternion.Identity(),f.Vector3.Zero());function F(e,t){if(!(e instanceof f.TransformNode))return!1;if(t){if(!e.getWorldMatrix().equalsWithEpsilon(f.Matrix.IdentityReadOnly,f.Epsilon))return!1}else if(!e.getWorldMatrix().multiplyToRef(S,f.TmpVectors.Matrix[0]).equalsWithEpsilon(f.Matrix.IdentityReadOnly,f.Epsilon))return!1;return!(e instanceof f.AbstractMesh&&e.geometry)}var B=f.Vector3.ZeroReadOnly,O=f.Quaternion.Identity(),N=f.Vector3.OneReadOnly,U=new f.Vector3(-1,1,1);function P(e,t){var r=e.byteOffset,n=e.byteStride,s=e.type,o=e.normalized,i=e.getSize(),a=t.reduce(function(e,t){return t.getTotalVertices()>e?t.getTotalVertices():e},-Number.MAX_VALUE);return{byteOffset:r,byteStride:n,componentCount:i,type:s,count:a*i,normalized:o,totalVertices:a,kind:e.getKind()}}function W(e){switch(e){case"MAT2":case"VEC4":return 4;case"MAT3":return 9;case"MAT4":return 16;case"SCALAR":return 1;case"VEC2":return 2;case"VEC3":return 3}}function L(e){return e.some(function(e){return e>=256})}function z(e){switch(e){case f.VertexBuffer.PositionKind:case f.VertexBuffer.NormalKind:case f.VertexBuffer.TangentKind:case f.VertexBuffer.ColorKind:case f.VertexBuffer.MatricesIndicesKind:case f.VertexBuffer.MatricesIndicesExtraKind:case f.VertexBuffer.MatricesWeightsKind:case f.VertexBuffer.MatricesWeightsExtraKind:case f.VertexBuffer.UVKind:case f.VertexBuffer.UV2Kind:case f.VertexBuffer.UV3Kind:case f.VertexBuffer.UV4Kind:case f.VertexBuffer.UV5Kind:case f.VertexBuffer.UV6Kind:return!0}return!1}function K(e){var t=Math.sqrt(e.x*e.x+e.y*e.y+e.z*e.z);t>0&&(e.x/=t,e.y/=t,e.z/=t)}function k(e){return e.x*=-1,e}function G(e){return S.invertToRef(f.TmpVectors.Matrix[0]).multiplyToRef(e,e).multiplyToRef(S,e),e}function D(e){if(e.x*e.x+e.y*e.y>.5){var t=Math.abs(e.x),r=Math.abs(e.y);if(t>r){var n=Math.sign(e.x);e.x=t,e.y*=-n,e.z*=-n,e.w*=n}else n=Math.sign(e.y),e.x*=-n,e.y=r,e.z*=n,e.w*=-n}else{var s=Math.abs(e.z),o=Math.abs(e.w);s>o?(n=Math.sign(e.z),e.x*=-n,e.y*=n,e.z=s,e.w*=-n):(n=Math.sign(e.w),e.x*=n,e.y*=-n,e.z*=-n,e.w=o)}return e}function H(e){e.copyFromFloats(-e.z,e.w,e.x,-e.y)}function q(e,t){var r=f.Vector3.FromArrayToRef(t.translation||[0,0,0],0,f.TmpVectors.Vector3[0]),n=f.Quaternion.FromArrayToRef(t.rotation||[0,0,0,1],0,f.TmpVectors.Quaternion[0]),s=f.Matrix.ComposeToRef(N,n,r,f.TmpVectors.Matrix[0]),o=f.Vector3.FromArrayToRef(e.translation||[0,0,0],0,f.TmpVectors.Vector3[2]),i=f.Quaternion.FromArrayToRef(e.rotation||[0,0,0,1],0,f.TmpVectors.Quaternion[1]),a=f.Matrix.ComposeToRef(N,i,o,f.TmpVectors.Matrix[1]);s.multiplyToRef(a,a),a.decompose(void 0,n,r),r.equalsWithEpsilon(B,f.Epsilon)?delete t.translation:t.translation=r.asArray(),n.equalsWithEpsilon(O,f.Epsilon)?delete t.rotation:t.rotation=n.asArray(),t.scale&&delete t.scale}function j(e,t){if(!(t instanceof f.TransformNode))return!1;if(1!==t.getChildren().length||0!==e.getChildren().length||e.parent!==t)return!1;var r=e.getScene(),n=e instanceof f.TargetCamera&&!r.useRightHandedSystem?U:N;return!!t.scaling.equalsWithEpsilon(n,f.Epsilon)||(f.Logger.Warn("Cannot collapse node ".concat(e.name," into parent node ").concat(t.name," with modified scaling.")),!1)}function Q(e,t){for(var r=0,n=Object.entries(e);r<n.length;r++){var s=n[r],o=s[0],i=s[1],a=t[o];(Array.isArray(i)&&Array.isArray(a)&&X(i,a)||i===a)&&delete e[o]}return e}function X(e,t){return e.length===t.length&&e.every(function(e,r){return e===t[r]})}var Y=new Map([[Int8Array,function(e,t,r){return e.setInt8(t,r)}],[Uint8Array,function(e,t,r){return e.setUint8(t,r)}],[Uint8ClampedArray,function(e,t,r){return e.setUint8(t,r)}],[Int16Array,function(e,t,r){return e.setInt16(t,r,!0)}],[Uint16Array,function(e,t,r){return e.setUint16(t,r,!0)}],[Int32Array,function(e,t,r){return e.setInt32(t,r,!0)}],[Uint32Array,function(e,t,r){return e.setUint32(t,r,!0)}],[Float32Array,function(e,t,r){return e.setFloat32(t,r,!0)}],[Float64Array,function(e,t,r){return e.setFloat64(t,r,!0)}]]),Z=function(){function e(e){this._data=new Uint8Array(e),this._dataView=new DataView(this._data.buffer),this._byteOffset=0}return e.prototype.writeTypedArray=function(e){this._checkGrowBuffer(e.byteLength);for(var t=Y.get(e.constructor),r=0;r<e.length;r++)t(this._dataView,this._byteOffset,e[r]),this._byteOffset+=e.BYTES_PER_ELEMENT},Object.defineProperty(e.prototype,"byteOffset",{get:function(){return this._byteOffset},enumerable:!1,configurable:!0}),e.prototype.getOutputData=function(){return new Uint8Array(this._data.buffer,0,this._byteOffset)},e.prototype.writeUInt8=function(e){this._checkGrowBuffer(1),this._dataView.setUint8(this._byteOffset,e),this._byteOffset++},e.prototype.writeInt8=function(e){this._checkGrowBuffer(1),this._dataView.setInt8(this._byteOffset,e),this._byteOffset++},e.prototype.writeInt16=function(e){this._checkGrowBuffer(2),this._dataView.setInt16(this._byteOffset,e,!0),this._byteOffset+=2},e.prototype.writeUInt16=function(e){this._checkGrowBuffer(2),this._dataView.setUint16(this._byteOffset,e,!0),this._byteOffset+=2},e.prototype.writeInt32=function(e){this._checkGrowBuffer(4),this._dataView.setInt32(this._byteOffset,e,!0),this._byteOffset+=4},e.prototype.writeUInt32=function(e){this._checkGrowBuffer(4),this._dataView.setUint32(this._byteOffset,e,!0),this._byteOffset+=4},e.prototype.writeFloat32=function(e){this._checkGrowBuffer(4),this._dataView.setFloat32(this._byteOffset,e,!0),this._byteOffset+=4},e.prototype.writeFloat64=function(e){this._checkGrowBuffer(8),this._dataView.setFloat64(this._byteOffset,e,!0),this._byteOffset+=8},e.prototype._checkGrowBuffer=function(e){var t=this.byteOffset+e;if(t>this._data.byteLength){var r=new Uint8Array(2*t);r.set(this._data),this._data=r,this._dataView=new DataView(this._data.buffer)}},e}();function J(e){return e%4==0?4:e%2==0?2:1}var $,ee=function(){function e(){this._bufferViewToData=new Map,this._bufferViewToProperties=new Map,this._accessorToBufferView=new Map}return e.prototype.generateBinary=function(e){var t=0;this._bufferViewToData.forEach(function(e){t+=e.byteLength});for(var r=new Z(t),n=0,s=Array.from(this._bufferViewToData.keys()).sort(function(e,t){return J(t.byteLength)-J(e.byteLength)});n<s.length;n++){var o=s[n];o.byteOffset=r.byteOffset,e.push(o);for(var i=e.length-1,a=0,u=this.getPropertiesWithBufferView(o);a<u.length;a++)u[a].bufferView=i;r.writeTypedArray(this._bufferViewToData.get(o)),this._bufferViewToData.delete(o)}return r.getOutputData()},e.prototype.createBufferView=function(e,t){var r={buffer:0,byteOffset:void 0,byteLength:e.byteLength,byteStride:t};return this._bufferViewToData.set(r,e),r},e.prototype.createAccessor=function(e,t,r,n,s,o,i){this._verifyBufferView(e);var a={bufferView:void 0,componentType:r,count:n,type:t,min:null==o?void 0:o.min,max:null==o?void 0:o.max,normalized:i,byteOffset:s};return this.setBufferView(a,e),this._accessorToBufferView.set(a,e),a},e.prototype.setBufferView=function(e,t){this._verifyBufferView(t),this.getPropertiesWithBufferView(t).push(e)},e.prototype.removeBufferView=function(e){for(var t=this,r=0,n=this.getPropertiesWithBufferView(e);r<n.length;r++){var s=n[r];void 0!==s.bufferView&&delete s.bufferView}this._bufferViewToData.delete(e),this._bufferViewToProperties.delete(e),this._accessorToBufferView.forEach(function(r,n){r===e&&(void 0!==n.byteOffset&&delete n.byteOffset,t._accessorToBufferView.delete(n))})},e.prototype.getBufferView=function(e){var t=this._accessorToBufferView.get(e);return this._verifyBufferView(t),t},e.prototype.getPropertiesWithBufferView=function(e){var t;return this._verifyBufferView(e),this._bufferViewToProperties.set(e,null!==(t=this._bufferViewToProperties.get(e))&&void 0!==t?t:[]),this._bufferViewToProperties.get(e)},e.prototype.getData=function(e){return this._verifyBufferView(e),this._bufferViewToData.get(e)},e.prototype._verifyBufferView=function(e){if(void 0===e||!this._bufferViewToData.has(e))throw new Error("BufferView ".concat(e," not found in BufferManager."))},e}();!function(e){e[e.INTANGENT=0]="INTANGENT",e[e.OUTTANGENT=1]="OUTTANGENT"}($||($={}));var te=function(){function e(){}return e._IsTransformable=function(e){return e&&(e instanceof f.TransformNode||e instanceof f.Camera||e instanceof f.Light)},e._CreateNodeAnimation=function(t,r,n,s,o){if(this._IsTransformable(t)){var i=[],a=[],u=r.getKeys(),c=e._CalculateMinMaxKeyFrames(u),l=e._DeduceInterpolation(u,n,s),h=l.interpolationType,p=l.shouldBakeAnimation;if(p?e._CreateBakedAnimation(t,r,n,c.min,c.max,r.framePerSecond,o,i,a,c,s):"LINEAR"===h||"STEP"===h?e._CreateLinearOrStepAnimation(t,r,n,i,a,s):"CUBICSPLINE"===h?e._CreateCubicSplineAnimation(t,r,n,i,a,s):e._CreateBakedAnimation(t,r,n,c.min,c.max,r.framePerSecond,o,i,a,c,s),i.length&&a.length)return{inputs:i,outputs:a,samplerInterpolation:h,inputsMin:p?c.min:f.Tools.FloatRound(c.min/r.framePerSecond),inputsMax:p?c.max:f.Tools.FloatRound(c.max/r.framePerSecond)}}return null},e._DeduceAnimationInfo=function(e){var t=null,r="VEC3",n=!1,s=e.targetProperty.split(".");switch(s[0]){case"scaling":t="scale";break;case"position":t="translation";break;case"rotation":r="VEC4",t="rotation";break;case"rotationQuaternion":r="VEC4",n=!0,t="rotation";break;case"influence":r="SCALAR",t="weights";break;default:f.Tools.Error("Unsupported animatable property ".concat(s[0]))}return t?{animationChannelTargetPath:t,dataAccessorType:r,useQuaternion:n}:(f.Tools.Error("animation channel target path and data accessor type could be deduced"),null)},e._CreateNodeAnimationFromNodeAnimations=function(t,r,n,s,o,i,a,u,c,l,h){var f;if(e._IsTransformable(t)&&t.animations)for(var p=0,d=t.animations;p<d.length;p++){var x=d[p];if(!h||h(x)){var g=e._DeduceAnimationInfo(x);g&&(f={name:x.name,samplers:[],channels:[]},e._AddAnimation("".concat(x.name),x.hasRunningRuntimeAnimations?r:f,t,x,g.dataAccessorType,g.animationChannelTargetPath,s,i,a,u,g.useQuaternion,c,l),f.samplers.length&&f.channels.length&&n.push(f))}}},e._CreateMorphTargetAnimationFromMorphTargetAnimations=function(t,r,n,s,o,i,a,u,c,l,h){var p;if(t instanceof f.Mesh){var d=t.morphTargetManager;if(d)for(var x=0;x<d.numTargets;++x)for(var g=0,_=d.getTarget(x).animations;g<_.length;g++){var m=_[g];if(!h||h(m)){for(var T=new f.Animation("".concat(m.name),"influence",m.framePerSecond,m.dataType,m.loopMode,m.enableBlending),y=[],v=m.getKeys(),b=0;b<v.length;++b)for(var w=v[b],M=0;M<d.numTargets;++M)M==x?y.push(w):y.push({frame:w.frame,value:0});T.setKeys(y,!0);var A=e._DeduceAnimationInfo(T);A&&(p={name:T.name,samplers:[],channels:[]},e._AddAnimation(m.name,m.hasRunningRuntimeAnimations?r:p,t,T,A.dataAccessorType,A.animationChannelTargetPath,s,i,a,u,A.useQuaternion,c,l,d.numTargets),p.samplers.length&&p.channels.length&&n.push(p))}}}},e._CreateNodeAndMorphAnimationFromAnimationGroups=function(t,r,n,s,o,i,a,u,c){var l,h;if(t.animationGroups)for(var p=t.animationGroups,d=function(p){var d=new Map,g=new Map,_=new Set,m=p.to-p.from;h={name:p.name,channels:[],samplers:[]};for(var T=function(r){var m=p.targetedAnimations[r],T=m.target,y=m.animation;if(c&&!c(y))return"continue";var v=u.has(T);if(x._IsTransformable(T)||1===T.length&&x._IsTransformable(T[0])){if(w=e._DeduceAnimationInfo(m.animation)){var b=x._IsTransformable(T)?T:x._IsTransformable(T[0])?T[0]:null;b&&e._AddAnimation("".concat(y.name),h,b,y,w.dataAccessorType,w.animationChannelTargetPath,n,s,o,i,w.useQuaternion,a,v)}}else if(T instanceof f.MorphTarget||1===T.length&&T[0]instanceof f.MorphTarget){var w;if(w=e._DeduceAnimationInfo(m.animation)){var M=T instanceof f.MorphTarget?T:T[0];if(M){var A=t.morphTargetManagers.find(function(e){for(var t=0;t<e.numTargets;++t)if(e.getTarget(t)===M)return!0;return!1});if(A){var R=t.meshes.find(function(e){return e.morphTargetManager===A});R&&(d.has(R)||d.set(R,new Map),null===(l=d.get(R))||void 0===l||l.set(M,y),_.add(R),g.set(R,y))}}}}},y=0;y<p.targetedAnimations.length;++y)T(y);_.forEach(function(t){for(var r=t.morphTargetManager,u=null,c=[],l=g.get(t).getKeys(),x=l.length,_=0;_<x;++_)for(var T=0;T<r.numTargets;++T){var y=r.getTarget(T),v=d.get(t);if(v){var b=v.get(y);b?(u||(u=new f.Animation("".concat(p.name,"_").concat(t.name,"_MorphWeightAnimation"),"influence",b.framePerSecond,f.Animation.ANIMATIONTYPE_FLOAT,b.loopMode,b.enableBlending)),c.push(b.getKeys()[_])):c.push({frame:p.from+m/x*_,value:y.influence,inTangent:l[0].inTangent?0:void 0,outTangent:l[0].outTangent?0:void 0})}}u.setKeys(c,!0);var w=e._DeduceAnimationInfo(u);w&&e._AddAnimation("".concat(p.name,"_").concat(t.name,"_MorphWeightAnimation"),h,t,u,w.dataAccessorType,w.animationChannelTargetPath,n,s,o,i,w.useQuaternion,a,!1,null==r?void 0:r.numTargets)}),h.channels.length&&h.samplers.length&&r.push(h)},x=this,g=0,_=p;g<_.length;g++)d(_[g])},e._AddAnimation=function(t,r,n,s,o,i,a,u,c,l,h,p,d,x){var g,_,m,T,y,v,b=e._CreateNodeAnimation(n,s,i,h,p);if(b){if(x){for(var w=0,M=void 0,A=[];b.inputs.length>0;)M=b.inputs.shift(),w%x==0&&A.push(M),w++;b.inputs=A}var R=a.get(n),E=new Float32Array(b.inputs);g=u.createBufferView(E),_=u.createAccessor(g,"SCALAR",5126,b.inputs.length,void 0,{min:[b.inputsMin],max:[b.inputsMax]}),l.push(_),m=l.length-1;var C=new f.Quaternion,I=new f.Vector3,V=new f.Vector3,S=n instanceof f.Camera,F=W(o),B=new Float32Array(b.outputs.length*F);b.outputs.forEach(function(e,t){var r=e;switch(i){case"translation":d&&(f.Vector3.FromArrayToRef(e,0,V),k(V),V.toArray(r));break;case"rotation":4===e.length?f.Quaternion.FromArrayToRef(e,0,C):(r=new Array(4),f.Vector3.FromArrayToRef(e,0,I),f.Quaternion.FromEulerVectorToRef(I,C)),d&&(D(C),S&&H(C)),C.toArray(r)}B.set(r,t*F)}),g=u.createBufferView(B),_=u.createAccessor(g,o,5126,b.outputs.length),l.push(_),T=l.length-1,y={interpolation:b.samplerInterpolation,input:m,output:T},r.samplers.push(y),v={sampler:r.samplers.length-1,target:{node:R,path:i}},r.channels.push(v)}},e._CreateBakedAnimation=function(t,r,n,s,o,i,a,u,c,l,h){var p,d,x,g,_,m,T=f.Quaternion.Identity(),y=null,v=null;l.min=f.Tools.FloatRound(s/i);for(var b=r.getKeys(),w=0,M=b.length;w<M;++w){if(x=b[w],w+1<M)if(g=b[w+1],x.value.equals&&x.value.equals(g.value)||x.value===g.value){if(0!==w)continue;m=x.frame}else m=g.frame;else{if(_=b[w-1],x.value.equals&&x.value.equals(_.value)||x.value===_.value)continue;m=o}if(m)for(var A=x.frame;A<=m;A+=a)if((d=f.Tools.FloatRound(A/i))!==y){y=d,v=d;var R={key:0,repeatCount:0,loopMode:r.loopMode};p=r._interpolate(A,R),e._SetInterpolatedValue(t,p,d,r,n,T,u,c,h)}}v&&(l.max=v)},e._ConvertFactorToVector3OrQuaternion=function(t,r,n,s,o){var i=e._GetBasePositionRotationOrScale(r,s,o),a=n.targetProperty.split("."),u=a?a[1]:"",c=o?f.Quaternion.FromArray(i).normalize():f.Vector3.FromArray(i);switch(u){case"x":case"y":case"z":c[u]=t;break;case"w":c.w=t;break;default:f.Tools.Error('glTFAnimation: Unsupported component name "'.concat(u,'"!'))}return c},e._SetInterpolatedValue=function(e,t,r,n,s,o,i,a,u){var c;i.push(r),"weights"!==s?(n.dataType===f.Animation.ANIMATIONTYPE_FLOAT&&(t=this._ConvertFactorToVector3OrQuaternion(t,e,n,s,u)),"rotation"===s?(u?o=t:(c=t,f.Quaternion.RotationYawPitchRollToRef(c.y,c.x,c.z,o)),a.push(o.asArray())):(c=t,a.push(c.asArray()))):a.push([t])},e._CreateLinearOrStepAnimation=function(t,r,n,s,o,i){for(var a=0,u=r.getKeys();a<u.length;a++){var c=u[a];s.push(c.frame/r.framePerSecond),e._AddKeyframeValue(c,r,o,n,t,i)}},e._CreateCubicSplineAnimation=function(t,r,n,s,o,i){r.getKeys().forEach(function(a){s.push(a.frame/r.framePerSecond),e._AddSplineTangent($.INTANGENT,o,n,"CUBICSPLINE",a,i),e._AddKeyframeValue(a,r,o,n,t,i),e._AddSplineTangent($.OUTTANGENT,o,n,"CUBICSPLINE",a,i)})},e._GetBasePositionRotationOrScale=function(e,t,r){var n;if("rotation"===t)if(r){var s=e.rotationQuaternion;n=(null!=s?s:f.Quaternion.Identity()).asArray()}else{var o=e.rotation;n=(null!=o?o:f.Vector3.Zero()).asArray()}else if("translation"===t){var i=e.position;n=(null!=i?i:f.Vector3.Zero()).asArray()}else{var a=e.scaling;n=(null!=a?a:f.Vector3.One()).asArray()}return n},e._AddKeyframeValue=function(e,t,r,n,s,o){var i,a=t.dataType;if(a===f.Animation.ANIMATIONTYPE_VECTOR3){var u=e.value.asArray();if("rotation"===n){var c=f.Vector3.FromArray(u);u=f.Quaternion.RotationYawPitchRoll(c.y,c.x,c.z).asArray()}r.push(u)}else if(a===f.Animation.ANIMATIONTYPE_FLOAT){if("weights"===n)r.push([e.value]);else if(i=this._ConvertFactorToVector3OrQuaternion(e.value,s,t,n,o)){if("rotation"===n){var l=o?i:f.Quaternion.RotationYawPitchRoll(i.y,i.x,i.z).normalize();r.push(l.asArray())}r.push(i.asArray())}}else a===f.Animation.ANIMATIONTYPE_QUATERNION?r.push(e.value.normalize().asArray()):f.Tools.Error("glTFAnimation: Unsupported key frame values for animation!")},e._DeduceInterpolation=function(e,t,r){var n,s,o=!1;if("rotation"===t&&!r)return{interpolationType:"LINEAR",shouldBakeAnimation:!0};for(var i=0,a=e.length;i<a;++i)if((s=e[i]).inTangent||s.outTangent)if(n){if("CUBICSPLINE"!==n){n="LINEAR",o=!0;break}}else n="CUBICSPLINE";else if(n){if("CUBICSPLINE"===n||s.interpolation&&1===s.interpolation&&"STEP"!==n){n="LINEAR",o=!0;break}}else n=s.interpolation&&1===s.interpolation?"STEP":"LINEAR";return n||(n="LINEAR"),{interpolationType:n,shouldBakeAnimation:o}},e._AddSplineTangent=function(e,t,r,n,s,o){var i,a=e===$.INTANGENT?s.inTangent:s.outTangent;if("CUBICSPLINE"===n){if("rotation"===r)if(a)if(o)i=a.asArray();else{var u=a;i=f.Quaternion.RotationYawPitchRoll(u.y,u.x,u.z).asArray()}else i=[0,0,0,0];else i="weights"===r?a?[a]:[0]:a?a.asArray():[0,0,0];t.push(i)}},e._CalculateMinMaxKeyFrames=function(e){var t=1/0,r=-1/0;return e.forEach(function(e){t=Math.min(t,e.frame),r=Math.max(r,e.frame)}),{min:t,max:r}},e}();function re(e,t,r,n,s,o){var i={attributes:{},influence:e.influence,name:e.name},a=t.geometry;if(!a)return f.Tools.Warn("Attempted to export morph target data from a mesh without geometry. This should not happen."),i;var u,c=o?-1:1,l=f.Vector3.Zero();if(e.hasPositions){var h=e.getPositions(),p=a.getVerticesData(f.VertexBuffer.PositionKind);if(p){var d=new Float32Array(p.length),x=[1/0,1/0,1/0],g=[-1/0,-1/0,-1/0];u=p.length/3;for(var _=0;_<u;++_){var m=f.Vector3.FromArray(p,3*_);f.Vector3.FromArray(h,3*_).subtractToRef(m,l),l.x*=c,x[0]=Math.min(x[0],l.x),g[0]=Math.max(g[0],l.x),x[1]=Math.min(x[1],l.y),g[1]=Math.max(g[1],l.y),x[2]=Math.min(x[2],l.z),g[2]=Math.max(g[2],l.z),d[3*_]=l.x,d[3*_+1]=l.y,d[3*_+2]=l.z}var T=r.createBufferView(d,12),y=r.createAccessor(T,"VEC3",5126,h.length/3,0,{min:x,max:g});s.push(y),i.attributes.POSITION=s.length-1}else f.Tools.Warn("Morph target positions for mesh ".concat(t.name," were not exported. Mesh does not have position vertex data"))}if(e.hasNormals){var v=e.getNormals(),b=a.getVerticesData(f.VertexBuffer.NormalKind);if(b){var w=new Float32Array(b.length);for(u=b.length/3,_=0;_<u;++_){var M=f.Vector3.FromArray(b,3*_).normalize();f.Vector3.FromArray(v,3*_).normalize().subtractToRef(M,l),w[3*_]=l.x*c,w[3*_+1]=l.y,w[3*_+2]=l.z}T=r.createBufferView(w,12),y=r.createAccessor(T,"VEC3",5126,v.length/3,0),s.push(y),i.attributes.NORMAL=s.length-1}else f.Tools.Warn("Morph target normals for mesh ".concat(t.name," were not exported. Mesh does not have normals vertex data"))}if(e.hasTangents){var A=e.getTangents(),R=a.getVerticesData(f.VertexBuffer.TangentKind);if(R){u=R.length/4;var E=new Float32Array(3*u);for(_=0;_<u;++_){var C=f.Vector3.FromArray(R,4*_);K(C);var I=f.Vector3.FromArray(A,3*_);K(I),I.subtractToRef(C,l),E[3*_]=l.x*c,E[3*_+1]=l.y,E[3*_+2]=l.z}T=r.createBufferView(E,12),y=r.createAccessor(T,"VEC3",5126,u,0),s.push(y),i.attributes.TANGENT=s.length-1}else f.Tools.Warn("Morph target tangents for mesh ".concat(t.name," were not exported. Mesh does not have tangents vertex data"))}if(e.hasColors){var V=e.getColors(),S=a.getVerticesData(f.VertexBuffer.ColorKind),F=a.getVertexBuffer(f.VertexBuffer.ColorKind);if(S&&F){var B=F.getSize();u=S.length/B;var O=new Float32Array(u*B);for(_=0;_<u;++_)if(3===B){var N=f.Vector3.FromArray(S,_*B);f.Vector3.FromArray(V,_*B).subtractToRef(N,l),O[3*_]=l.x,O[3*_+1]=l.y,O[3*_+2]=l.z}else if(4===B){var U=new f.Vector4;N=f.Vector4.FromArray(S,_*B),f.Vector4.FromArray(V,_*B).subtractToRef(N,U),O[4*_]=U.x,O[4*_+1]=U.y,O[4*_+2]=U.z,O[4*_+3]=U.w}else f.Tools.Warn("Unsupported number of components for color attribute: ".concat(B));T=r.createBufferView(O,4*B),y=r.createAccessor(T,3===B?"VEC3":"VEC4",5126,u,0),s.push(y),i.attributes.COLOR_0=s.length-1}else f.Tools.Warn("Morph target colors for mesh ".concat(t.name," were not exported. Mesh does not have colors vertex data"))}return i}var ne=function(){function e(e,t){this._indicesAccessorMap=new Map,this._vertexBufferViewMap=new Map,this._vertexAccessorMap=new Map,this._remappedBufferView=new Map,this._meshMorphTargetMap=new Map,this._vertexMapColorAlpha=new Map,this._exportedNodes=new Set,this._meshMap=new Map,this.convertedToRightHandedBuffers=new Map,this.convertToRightHanded=e,this.wasAddedByNoopNode=t}return e.prototype.getIndicesAccessor=function(e,t,r,n,s){var o,i,a,u;return null===(u=null===(a=null===(i=null===(o=this._indicesAccessorMap.get(e))||void 0===o?void 0:o.get(t))||void 0===i?void 0:i.get(r))||void 0===a?void 0:a.get(n))||void 0===u?void 0:u.get(s)},e.prototype.setIndicesAccessor=function(e,t,r,n,s,o){var i=this._indicesAccessorMap.get(e);i||(i=new Map,this._indicesAccessorMap.set(e,i));var a=i.get(t);a||(a=new Map,i.set(t,a));var u=a.get(r);u||(u=new Map,a.set(r,u));var c=u.get(n);c||(c=new Map,u.set(n,c)),c.set(s,o)},e.prototype.pushExportedNode=function(e){this._exportedNodes.has(e)||this._exportedNodes.add(e)},e.prototype.getNodesSet=function(){return this._exportedNodes},e.prototype.getVertexBufferView=function(e){return this._vertexBufferViewMap.get(e)},e.prototype.setVertexBufferView=function(e,t){this._vertexBufferViewMap.set(e,t)},e.prototype.setRemappedBufferView=function(e,t,r){this._remappedBufferView.set(e,new Map),this._remappedBufferView.get(e).set(t,r)},e.prototype.getRemappedBufferView=function(e,t){var r;return null===(r=this._remappedBufferView.get(e))||void 0===r?void 0:r.get(t)},e.prototype.getVertexAccessor=function(e,t,r){var n,s;return null===(s=null===(n=this._vertexAccessorMap.get(e))||void 0===n?void 0:n.get(t))||void 0===s?void 0:s.get(r)},e.prototype.setVertexAccessor=function(e,t,r,n){var s=this._vertexAccessorMap.get(e);s||(s=new Map,this._vertexAccessorMap.set(e,s));var o=s.get(t);o||(o=new Map,s.set(t,o)),o.set(r,n)},e.prototype.hasVertexColorAlpha=function(e){return this._vertexMapColorAlpha.get(e)||!1},e.prototype.setHasVertexColorAlpha=function(e,t){return this._vertexMapColorAlpha.set(e,t)},e.prototype.getMesh=function(e){return this._meshMap.get(e)},e.prototype.setMesh=function(e,t){this._meshMap.set(e,t)},e.prototype.bindMorphDataToMesh=function(e,t){var r=this._meshMorphTargetMap.get(e)||[];this._meshMorphTargetMap.set(e,r),-1===r.indexOf(t)&&r.push(t)},e.prototype.getMorphTargetsFromMesh=function(e){return this._meshMorphTargetMap.get(e)},e}(),se=function(){function e(e,t){if(void 0===e&&(e=f.EngineStore.LastCreatedScene),this._glTF={asset:{generator:"Babylon.js v".concat(f.Engine.Version),version:"2.0"}},this._animations=[],this._accessors=[],this._bufferViews=[],this._cameras=[],this._images=[],this._materials=[],this._meshes=[],this._nodes=[],this._samplers=[],this._scenes=[],this._skins=[],this._textures=[],this._imageData={},this._shouldUseGlb=!1,this._materialExporter=new V(this),this._extensions={},this._bufferManager=new ee,this._shouldExportNodeMap=new Map,this._nodeMap=new Map,this._materialMap=new Map,this._camerasMap=new Map,this._nodesCameraMap=new Map,this._skinMap=new Map,this._nodesSkinMap=new Map,this._materialNeedsUVsSet=new Set,!e)throw new Error("No scene available to export");this._babylonScene=e,this._options=d({shouldExportNode:function(){return!0},shouldExportAnimation:function(){return!0},metadataSelector:function(e){var t;return null===(t=null==e?void 0:e.gltf)||void 0===t?void 0:t.extras},animationSampleRate:1/60,exportWithoutWaitingForScene:!1,exportUnusedUVs:!1,removeNoopRootNodes:!0,includeCoordinateSystemConversionNodes:!1,meshCompressionMethod:"None"},t),this._loadExtensions()}return e.prototype._ApplyExtension=function(e,t,r,n){var s=this;if(r>=t.length)return Promise.resolve(e);var o=n(t[r],e);return o?o.then(function(e){return x(s,void 0,void 0,function(){var s;return g(this,function(o){switch(o.label){case 0:return e?[4,this._ApplyExtension(e,t,r+1,n)]:[3,2];case 1:return s=o.sent(),[3,3];case 2:s=null,o.label=3;case 3:return[2,s]}})})}):this._ApplyExtension(e,t,r+1,n)},e.prototype._ApplyExtensions=function(t,r){for(var n=[],s=0,o=e._ExtensionNames;s<o.length;s++){var i=o[s];n.push(this._extensions[i])}return this._ApplyExtension(t,n,0,r)},e.prototype._extensionsPostExportNodeAsync=function(e,t,r,n,s){var o=this;return this._ApplyExtensions(t,function(t,i){return t.postExportNodeAsync&&t.postExportNodeAsync(e,i,r,n,s,o._bufferManager)})},e.prototype._extensionsPostExportMaterialAsync=function(e,t,r){return this._ApplyExtensions(t,function(t,n){return t.postExportMaterialAsync&&t.postExportMaterialAsync(e,n,r)})},e.prototype._extensionsPostExportMaterialAdditionalTexturesAsync=function(t,r,n){return x(this,void 0,void 0,function(){var s,o=this;return g(this,function(i){switch(i.label){case 0:return s=[],[4,Promise.all(e._ExtensionNames.map(function(e){return x(o,void 0,void 0,function(){var o,i;return g(this,function(a){switch(a.label){case 0:return(o=this._extensions[e]).postExportMaterialAdditionalTexturesAsync?[4,o.postExportMaterialAdditionalTexturesAsync(t,r,n)]:[3,2];case 1:i=a.sent(),s.push.apply(s,i),a.label=2;case 2:return[2]}})})}))];case 1:return i.sent(),[2,s]}})})},e.prototype._extensionsPostExportTextures=function(t,r,n){for(var s=0,o=e._ExtensionNames;s<o.length;s++){var i=o[s],a=this._extensions[i];a.postExportTexture&&a.postExportTexture(t,r,n)}},e.prototype._extensionsPostExportMeshPrimitive=function(t){for(var r=0,n=e._ExtensionNames;r<n.length;r++){var s=n[r],o=this._extensions[s];o.postExportMeshPrimitive&&o.postExportMeshPrimitive(t,this._bufferManager,this._accessors)}},e.prototype._extensionsPreGenerateBinaryAsync=function(){return x(this,void 0,void 0,function(){var t,r,n,s;return g(this,function(o){switch(o.label){case 0:t=0,r=e._ExtensionNames,o.label=1;case 1:return t<r.length?(n=r[t],(s=this._extensions[n]).preGenerateBinaryAsync?[4,s.preGenerateBinaryAsync(this._bufferManager)]:[3,3]):[3,4];case 2:o.sent(),o.label=3;case 3:return t++,[3,1];case 4:return[2]}})})},e.prototype._forEachExtensions=function(t){for(var r=0,n=e._ExtensionNames;r<n.length;r++){var s=n[r],o=this._extensions[s];o.enabled&&t(o)}},e.prototype._extensionsOnExporting=function(){var e=this;this._forEachExtensions(function(t){var r,n,s;t.wasUsed&&((r=e._glTF).extensionsUsed||(r.extensionsUsed=[]),-1===e._glTF.extensionsUsed.indexOf(t.name)&&e._glTF.extensionsUsed.push(t.name),t.required&&((n=e._glTF).extensionsRequired||(n.extensionsRequired=[]),-1===e._glTF.extensionsRequired.indexOf(t.name)&&e._glTF.extensionsRequired.push(t.name)),(s=e._glTF).extensions||(s.extensions={}),t.onExporting&&t.onExporting())})},e.prototype._loadExtensions=function(){for(var t=0,r=e._ExtensionNames;t<r.length;t++){var n=r[t],s=e._ExtensionFactories[n](this);this._extensions[n]=s}},e.prototype.dispose=function(){for(var e in this._extensions)this._extensions[e].dispose()},Object.defineProperty(e.prototype,"options",{get:function(){return this._options},enumerable:!1,configurable:!0}),e.RegisterExtension=function(t,r,n){void 0===n&&(n=100),e.UnregisterExtension(t)&&f.Tools.Warn("Extension with the name ".concat(t," already exists")),e._ExtensionFactories[t]=r;var s=null!=n?n:0;e._ExtensionOrders[t]=s;for(var o=e._ExtensionNames.length,i=0;i<e._ExtensionNames.length;i++){var a=e._ExtensionNames[i];if(s<e._ExtensionOrders[a]){o=i;break}}e._ExtensionNames.splice(o,0,t)},e.UnregisterExtension=function(t){if(!e._ExtensionFactories[t])return!1;delete e._ExtensionFactories[t],delete e._ExtensionOrders[t];var r=e._ExtensionNames.indexOf(t);return-1!==r&&e._ExtensionNames.splice(r,1),!0},e.prototype._generateJSON=function(e,t,r){var n={byteLength:e};return n.byteLength&&(this._glTF.buffers=[n]),this._nodes&&this._nodes.length&&(this._glTF.nodes=this._nodes),this._meshes&&this._meshes.length&&(this._glTF.meshes=this._meshes),this._scenes&&this._scenes.length&&(this._glTF.scenes=this._scenes,this._glTF.scene=0),this._cameras&&this._cameras.length&&(this._glTF.cameras=this._cameras),this._bufferViews&&this._bufferViews.length&&(this._glTF.bufferViews=this._bufferViews),this._accessors&&this._accessors.length&&(this._glTF.accessors=this._accessors),this._animations&&this._animations.length&&(this._glTF.animations=this._animations),this._materials&&this._materials.length&&(this._glTF.materials=this._materials),this._textures&&this._textures.length&&(this._glTF.textures=this._textures),this._samplers&&this._samplers.length&&(this._glTF.samplers=this._samplers),this._skins&&this._skins.length&&(this._glTF.skins=this._skins),this._images&&this._images.length&&(this._glTF.images=this._images),this._shouldUseGlb||(n.uri=t+".bin"),r?JSON.stringify(this._glTF,null,2):JSON.stringify(this._glTF)},e.prototype.generateGLTFAsync=function(e){return x(this,void 0,void 0,function(){var t,r,n,s,o,i,a;return g(this,function(u){switch(u.label){case 0:return[4,this._generateBinaryAsync()];case 1:if(t=u.sent(),this._extensionsOnExporting(),r=this._generateJSON(t.byteLength,e,!0),n=new Blob([t],{type:"application/octet-stream"}),s=e+".gltf",o=e+".bin",(i=new p).files[s]=r,i.files[o]=n,this._imageData)for(a in this._imageData)i.files[a]=this._imageData[a];return[2,i]}})})},e.prototype._generateBinaryAsync=function(){return x(this,void 0,void 0,function(){return g(this,function(e){switch(e.label){case 0:return[4,this._exportSceneAsync()];case 1:return e.sent(),[4,this._extensionsPreGenerateBinaryAsync()];case 2:return e.sent(),[2,this._bufferManager.generateBinary(this._bufferViews)]}})})},e.prototype._getPadding=function(e){var t=e%4;return 0===t?t:4-t},e.prototype.generateGLBAsync=function(e){return x(this,void 0,void 0,function(){var t,r,n,s,o,i,a,u,c,l,h,f,d,x;return g(this,function(g){switch(g.label){case 0:return this._shouldUseGlb=!0,[4,this._generateBinaryAsync()];case 1:if(t=g.sent(),this._extensionsOnExporting(),r=this._generateJSON(t.byteLength),n=e+".glb",s=r.length,"undefined"!=typeof TextEncoder&&(i=new TextEncoder,o=i.encode(r),s=o.length),a=this._getPadding(s),u=this._getPadding(t.byteLength),c=28+s+a+t.byteLength+u,(l=new Z(c)).writeUInt32(1179937895),l.writeUInt32(2),l.writeUInt32(c),l.writeUInt32(s+a),l.writeUInt32(1313821514),o)l.writeTypedArray(o);else for(h="_".charCodeAt(0),d=0;d<s;++d)(f=r.charCodeAt(d))!=r.codePointAt(d)?l.writeUInt8(h):l.writeUInt8(f);for(d=0;d<a;++d)l.writeUInt8(32);for(l.writeUInt32(t.byteLength+u),l.writeUInt32(5130562),l.writeTypedArray(t),d=0;d<u;++d)l.writeUInt8(0);return(x=new p).files[n]=new Blob([l.getOutputData()],{type:"application/octet-stream"}),[2,x]}})})},e.prototype._setNodeTransformation=function(e,t,r){var n;if(t.getPivotPoint().equalsWithEpsilon(B,f.Epsilon)||f.Tools.Warn("Pivot points are not supported in the glTF serializer"),!t.position.equalsWithEpsilon(B,f.Epsilon)){var s=f.TmpVectors.Vector3[0].copyFrom(t.position);r&&k(s),e.translation=s.asArray()}t.scaling.equalsWithEpsilon(N,f.Epsilon)||(e.scale=t.scaling.asArray());var o=(null===(n=t.rotationQuaternion)||void 0===n?void 0:n.clone())||f.Quaternion.FromEulerAngles(t.rotation.x,t.rotation.y,t.rotation.z);o.equalsWithEpsilon(O,f.Epsilon)||(r&&D(o),e.rotation=o.normalize().asArray())},e.prototype._setCameraTransformation=function(e,t,r){var n=f.TmpVectors.Vector3[0],s=f.TmpVectors.Quaternion[0],o=t.getWorldMatrix();if(t.parent){var i=t.parent.getWorldMatrix().invertToRef(f.TmpVectors.Matrix[0]);o.multiplyToRef(i,f.TmpVectors.Matrix[1]).decompose(void 0,s,n)}else o.decompose(void 0,s,n);n.equalsWithEpsilon(B,f.Epsilon)||(r&&k(n),e.translation=n.asArray()),r&&D(s),this._babylonScene.useRightHandedSystem||H(s),s.equalsWithEpsilon(O,f.Epsilon)||(e.rotation=s.asArray())},e.prototype._listAvailableCameras=function(){for(var e=0,t=this._babylonScene.cameras;e<t.length;e++){var r=t[e],n={type:r.mode===f.Camera.PERSPECTIVE_CAMERA?"perspective":"orthographic"};if(r.name&&(n.name=r.name),"perspective"===n.type)n.perspective={aspectRatio:r.getEngine().getAspectRatio(r),yfov:r.fovMode===f.Camera.FOVMODE_VERTICAL_FIXED?r.fov:r.fov*r.getEngine().getAspectRatio(r),znear:r.minZ,zfar:r.maxZ};else if("orthographic"===n.type){var s=r.orthoLeft&&r.orthoRight?.5*(r.orthoRight-r.orthoLeft):.5*r.getEngine().getRenderWidth(),o=r.orthoBottom&&r.orthoTop?.5*(r.orthoTop-r.orthoBottom):.5*r.getEngine().getRenderHeight();n.orthographic={xmag:s,ymag:o,znear:r.minZ,zfar:r.maxZ}}this._camerasMap.set(r,n)}},e.prototype._exportAndAssignCameras=function(){for(var e=0,t=Array.from(this._camerasMap.values());e<t.length;e++){var r=t[e],n=this._nodesCameraMap.get(r);if(void 0!==n){this._cameras.push(r);for(var s=0,o=n;s<o.length;s++)o[s].camera=this._cameras.length-1}}},e.prototype._listAvailableSkeletons=function(){for(var e=0,t=this._babylonScene.skeletons;e<t.length;e++){var r=t[e];r.bones.length<=0||this._skinMap.set(r,{joints:[]})}},e.prototype._exportAndAssignSkeletons=function(e){for(var t,r=function(r){if(r.bones.length<=0)return"continue";var s=n._skinMap.get(r);if(null==s)return"continue";for(var o={},i=-1,a=0;a<r.bones.length;++a){var u=r.bones[a];-1!==(l=null!==(t=u.getIndex())&&void 0!==t?t:a)&&(o[l]=u,l>i&&(i=l))}for(var c=[],l=0;l<=i;++l){var h=(u=o[l]).getTransformNode(),p=h?n._nodeMap.get(h):void 0;if(void 0!==p){s.joints.push(p);var d=u.getAbsoluteInverseBindMatrix().clone();e.has(h)&&G(d),c.push(d)}else f.Tools.Warn("Exporting a bone without a linked transform node is currently unsupported.")}var x=n._nodesSkinMap.get(s);if(s.joints.length>0&&void 0!==x){var g=new Float32Array(16*c.length);c.forEach(function(e,t){g.set(e.m,16*t)});var _=n._bufferManager.createBufferView(g);n._accessors.push(n._bufferManager.createAccessor(_,"MAT4",5126,c.length)),s.inverseBindMatrices=n._accessors.length-1,n._skins.push(s);for(var m=n._skins.length-1,T=0,y=x;T<y.length;T++)y[T].skin=m}},n=this,s=0,o=this._babylonScene.skeletons;s<o.length;s++)r(o[s])},e.prototype._exportSceneAsync=function(){return x(this,void 0,void 0,function(){var e,t,r,n,s,o,i,a,u,c,l,h,p,d,x,_,m,T,y,v,b,w,M,A,R,E,C,I,V,S,B,O,N;return g(this,function(g){switch(g.label){case 0:if(e={nodes:[]},this._babylonScene.metadata&&(t=this._options.metadataSelector(this._babylonScene.metadata))&&(e.extras=t),r=new Array,n=new Array,s=new Array,this._options.removeNoopRootNodes&&!this._options.includeCoordinateSystemConversionNodes)for(i=0,a=this._babylonScene.animationGroups;i<a.length;i++)for(u=a[i],c=0,l=u.targetedAnimations;c<l.length;c++)h=l[c],(p=h.target)instanceof f.TransformNode&&!p.parent&&(null!=o?o:o=new Set).add(p);for(d=0,x=this._babylonScene.rootNodes;d<x.length;d++)_=x[d],m=_.animations,T=!!m&&m.length>0||(null==o?void 0:o.has(_)),this._options.removeNoopRootNodes&&!this._options.includeCoordinateSystemConversionNodes&&F(_,this._babylonScene.useRightHandedSystem)&&!T?s.push.apply(s,_.getChildren()):this._babylonScene.useRightHandedSystem?r.push(_):n.push(_);return this._listAvailableCameras(),this._listAvailableSkeletons(),y=new ne(!0,!1),b=(v=(B=e.nodes).push).apply,w=[B],[4,this._exportNodesAsync(n,y)];case 1:return b.apply(v,w.concat([g.sent()])),M=new ne(!1,!1),R=(A=(O=e.nodes).push).apply,E=[O],[4,this._exportNodesAsync(r,M)];case 2:return R.apply(A,E.concat([g.sent()])),C=new ne(!1,!0),V=(I=(N=e.nodes).push).apply,S=[N],[4,this._exportNodesAsync(s,C)];case 3:return V.apply(I,S.concat([g.sent()])),e.nodes.length&&this._scenes.push(e),this._exportAndAssignCameras(),this._exportAndAssignSkeletons(y.getNodesSet()),this._babylonScene.animationGroups.length&&te._CreateNodeAndMorphAnimationFromAnimationGroups(this._babylonScene,this._animations,this._nodeMap,this._bufferManager,this._bufferViews,this._accessors,this._animationSampleRate,y.getNodesSet(),this._options.shouldExportAnimation),[2]}})})},e.prototype._shouldExportNode=function(e){var t=this._shouldExportNodeMap.get(e);return void 0===t&&(t=this._options.shouldExportNode(e),this._shouldExportNodeMap.set(e,t)),t},e.prototype._exportNodesAsync=function(e,t){return x(this,void 0,void 0,function(){var r,n,s,o;return g(this,function(i){switch(i.label){case 0:r=new Array,this._exportBuffers(e,t),n=0,s=e,i.label=1;case 1:return n<s.length?(o=s[n],[4,this._exportNodeAsync(o,r,t)]):[3,4];case 2:i.sent(),i.label=3;case 3:return n++,[3,1];case 4:return[2,r]}})})},e.prototype._collectBuffers=function(e,t,r,n,s){if(this._shouldExportNode(e)&&e instanceof f.AbstractMesh&&e.geometry){var o=e.geometry.getVertexBuffers();if(o)for(var i in o)if(z(i)){var a=o[i];s.setHasVertexColorAlpha(a,e.hasVertexAlpha);var u=a._buffer,c=t.get(u)||[];t.set(u,c),-1===c.indexOf(a)&&c.push(a);var l=r.get(a)||[];r.set(a,l),-1===l.indexOf(e)&&l.push(e)}var h=e.morphTargetManager;if(h)for(var p=0;p<h.numTargets;p++){var d=h.getTarget(p);l=n.get(d)||[],n.set(d,l),-1===l.indexOf(e)&&l.push(e)}}for(var x=0,g=e.getChildren();x<g.length;x++){var _=g[x];this._collectBuffers(_,t,r,n,s)}},e.prototype._exportBuffers=function(e,t){for(var r=new Map,n=new Map,s=new Map,o=0,i=e;o<i.length;o++){var a=i[o];this._collectBuffers(a,r,n,s,t)}for(var u=Array.from(r.keys()),c=function(e){var s=e.getData();if(!s)throw new Error("Buffer data is not available");var o=r.get(e);if(!o)return"continue";var i=o[0].byteStride;if(o.some(function(e){return e.byteStride!==i}))throw new Error("Vertex buffers pointing to the same buffer must have the same byte stride");for(var a=function(e){if(e instanceof Array){var t=new Float32Array(e);return new Uint8Array(t.buffer,t.byteOffset,t.byteLength)}return ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):new Uint8Array(e)}(s).slice(),u=function(e){var t=n.get(e),r=P(e,t),s=r.byteOffset,o=r.byteStride,i=r.componentCount,u=r.type,c=r.count,h=r.normalized;switch(r.kind){case f.VertexBuffer.NormalKind:case f.VertexBuffer.TangentKind:(0,f.EnumerateFloatValues)(a,s,o,i,u,c,h,function(e){var t=Math.sqrt(e[0]*e[0]+e[1]*e[1]+e[2]*e[2]);if(t>0){var r=1/t;e[0]*=r,e[1]*=r,e[2]*=r}});break;case f.VertexBuffer.ColorKind:var p=t.filter(function(e){return e.material instanceof f.StandardMaterial||null==e.material}).length;if(0==p)break;if(p!=t.length){f.Logger.Warn("Not converting vertex color space, as buffer is shared by StandardMaterials and other material types. Results may look incorrect.");break}u==f.VertexBuffer.UNSIGNED_BYTE&&f.Logger.Warn("Converting uint8 vertex colors to linear space. Results may look incorrect.");var d=new f.Color3,x=new f.Color4,g=l._babylonScene.getEngine().useExactSrgbConversions;(0,f.EnumerateFloatValues)(a,s,o,i,u,c,h,function(e){3===e.length?(d.fromArray(e,0),d.toLinearSpaceToRef(d,g),d.toArray(e,0)):(x.fromArray(e,0),x.toLinearSpaceToRef(x,g),x.toArray(e,0))})}},c=0,h=o;c<h.length;c++)u(F=h[c]);if(t.convertToRightHanded){for(var p=0,d=o;p<d.length;p++){var x=P(F=d[p],n.get(F)),g=x.byteOffset,_=x.byteStride,m=x.componentCount,T=x.type,y=x.count,v=x.normalized;switch(E=x.kind){case f.VertexBuffer.PositionKind:case f.VertexBuffer.NormalKind:case f.VertexBuffer.TangentKind:(0,f.EnumerateFloatValues)(a,g,_,m,T,y,v,function(e){e[0]=-e[0]})}}t.convertedToRightHandedBuffers.set(e,a)}var b=l._bufferManager.createBufferView(a,i);t.setVertexBufferView(e,b);for(var w=new Map,M=0,A=o;M<A.length;M++){var R=P(F=A[M],n.get(F)),E=R.kind,C=R.totalVertices;switch(E){case f.VertexBuffer.MatricesIndicesKind:case f.VertexBuffer.MatricesIndicesExtraKind:if(F.type==f.VertexBuffer.FLOAT){var I=F.getFloatData(C);null!==I&&w.set(F,I)}}}0!==w.size&&f.Logger.Warn("Joint indices conversion needed: some joint indices are stored as floats in Babylon but GLTF requires UNSIGNED BYTES. We will perform the conversion but this might lead to unused data in the buffer.");for(var V=0,S=Array.from(w.keys());V<S.length;V++){var F=S[V],B=w.get(F);if(B){for(var O=L(B),N=new(O?Uint16Array:Uint8Array)(B.length),U=0;U<B.length;U++)N[U]=B[U];var W=l._bufferManager.createBufferView(N,4*(O?2:1));t.setRemappedBufferView(e,F,W)}}},l=this,h=0,p=u;h<p.length;h++)c(p[h]);for(var d=0,x=Array.from(s.keys());d<x.length;d++){var g=x[d],_=s.get(g);if(_)for(var m=re(g,_[0],this._bufferManager,this._bufferViews,this._accessors,t.convertToRightHanded),T=0,y=_;T<y.length;T++){var v=y[T];t.bindMorphDataToMesh(v,m)}}},e.prototype._exportNodeAsync=function(e,t,r){return x(this,void 0,void 0,function(){var n,s,o,i,a,u,c,l,h=this;return g(this,function(f){switch(f.label){case 0:return void 0!==(n=this._nodeMap.get(e))?(t.includes(n)||t.push(n),[2]):[4,this._createNodeAsync(e,r)];case 1:(s=f.sent())&&(n=this._nodes.length,this._nodes.push(s),this._nodeMap.set(e,n),r.pushExportedNode(e),t.push(n),o={name:"runtime animations",channels:[],samplers:[]},i=[],this._babylonScene.animationGroups.length||(te._CreateMorphTargetAnimationFromMorphTargetAnimations(e,o,i,this._nodeMap,this._nodes,this._bufferManager,this._bufferViews,this._accessors,this._animationSampleRate,r.convertToRightHanded,this._options.shouldExportAnimation),e.animations.length&&te._CreateNodeAnimationFromNodeAnimations(e,o,i,this._nodeMap,this._nodes,this._bufferManager,this._bufferViews,this._accessors,this._animationSampleRate,r.convertToRightHanded,this._options.shouldExportAnimation)),o.channels.length&&o.samplers.length&&this._animations.push(o),i.forEach(function(e){e.channels.length&&e.samplers.length&&h._animations.push(e)})),a=s?[]:t,u=0,c=e.getChildren(),f.label=2;case 2:return u<c.length?(l=c[u],[4,this._exportNodeAsync(l,a,r)]):[3,5];case 3:f.sent(),f.label=4;case 4:return u++,[3,2];case 5:return s&&a.length&&(s.children=a),[2]}})})},e.prototype._createNodeAsync=function(e,t){return x(this,void 0,void 0,function(){var r,n,s,o,i,a,u,c,l,h,p,d;return g(this,function(x){switch(x.label){case 0:return this._shouldExportNode(e)?(r={},e.name&&(r.name=e.name),e.metadata&&(n=this._options.metadataSelector(e.metadata))&&(r.extras=n),e instanceof f.TransformNode?(this._setNodeTransformation(r,e,t.convertToRightHanded),e instanceof f.AbstractMesh?(s=e instanceof f.InstancedMesh?e.sourceMesh:e).subMeshes&&s.subMeshes.length>0?(o=r,[4,this._exportMeshAsync(s,t)]):[3,2]:[3,3]):[3,3]):[2,null];case 1:o.mesh=x.sent(),x.label=2;case 2:e.skeleton&&void 0!==(i=this._skinMap.get(e.skeleton))&&(void 0===this._nodesSkinMap.get(i)&&this._nodesSkinMap.set(i,[]),null===(h=this._nodesSkinMap.get(i))||void 0===h||h.push(r)),x.label=3;case 3:if(e instanceof f.TargetCamera&&(a=this._camerasMap.get(e))){if(void 0===this._nodesCameraMap.get(a)&&this._nodesCameraMap.set(a,[]),this._setCameraTransformation(r,e,t.convertToRightHanded),null!==(u=e.parent)&&j(e,u)&&void 0!==(c=this._nodeMap.get(u)))return l=this._nodes[c],q(r,l),null===(p=this._nodesCameraMap.get(a))||void 0===p||p.push(l),[2,null];null===(d=this._nodesCameraMap.get(a))||void 0===d||d.push(r)}return[4,this._extensionsPostExportNodeAsync("exportNodeAsync",r,e,this._nodeMap,t.convertToRightHanded)];case 4:return x.sent()?[2,r]:(f.Logger.Warn("Not exporting node ".concat(e.name)),[2,null])}})})},e.prototype._exportIndices=function(e,t,r,n,s,o,i,a,u){var c=null;u.mode=function(e){switch(e){case f.Material.TriangleFillMode:return 4;case f.Material.TriangleStripDrawMode:return 5;case f.Material.TriangleFanDrawMode:return 6;case f.Material.PointListDrawMode:case f.Material.PointFillMode:return 0;case f.Material.LineLoopDrawMode:return 2;case f.Material.LineListDrawMode:return 1;case f.Material.LineStripDrawMode:return 3}throw new Error("Unknown fill mode: ".concat(e))}(o);var l=i!==f.Material.CounterClockWiseSideOrientation&&function(e){switch(e){case f.Material.TriangleFillMode:case f.Material.TriangleStripDrawMode:case f.Material.TriangleFanDrawMode:return!0}return!1}(o);if(l){if(o===f.Material.TriangleStripDrawMode||o===f.Material.TriangleFanDrawMode)throw new Error("Triangle strip/fan fill mode is not implemented");var h=t?new Uint32Array(n):new Uint16Array(n);if(e)for(var p=0;p+2<n;p+=3)h[p]=e[r+p]+s,h[p+1]=e[r+p+2]+s,h[p+2]=e[r+p+1]+s;else for(p=0;p+2<n;p+=3)h[p]=p,h[p+1]=p+2,h[p+2]=p+1;c=h}else if(e&&0!==s){for(h=t?new Uint32Array(n):new Uint16Array(n),p=0;p<n;p++)h[p]=e[r+p]+s;c=h}else e&&(c=function(e,t,r,n){var s=e;return 0===t&&r===e.length||(s=Array.isArray(e)?e.slice(t,t+r):e.subarray(t,t+r)),s instanceof Int32Array?new Uint32Array(s.buffer,s.byteOffset,s.length):Array.isArray(s)?n?new Uint32Array(s):new Uint16Array(s):s}(e,r,n,t));if(c){var d=a.getIndicesAccessor(e,r,n,s,l);if(void 0===d){var x=this._bufferManager.createBufferView(c),g=t?5125:5123;this._accessors.push(this._bufferManager.createAccessor(x,"SCALAR",g,n,0)),d=this._accessors.length-1,a.setIndicesAccessor(e,r,n,s,l,d)}u.indices=d}},e.prototype._exportVertexBuffer=function(e,t,r,n,s,o){var i=e.getKind();if(z(i)&&(!i.startsWith("uv")||this._options.exportUnusedUVs||t&&this._materialNeedsUVsSet.has(t))){var a=s.getVertexAccessor(e,r,n);if(void 0===a){var u=s.convertedToRightHandedBuffers.get(e._buffer)||e._buffer.getData(),c=i===f.VertexBuffer.PositionKind?function(e,t,r,n){var s=t.byteOffset,o=t.byteStride,i=t.type,a=t.normalized,u=t.getSize(),c=new Array(u).fill(1/0),l=new Array(u).fill(-1/0);return(0,f.EnumerateFloatValues)(e,s+r*o,o,u,i,n*u,a,function(e){for(var t=0;t<u;t++)c[t]=Math.min(c[t],e[t]),l[t]=Math.max(l[t],e[t])}),{min:c,max:l}}(u,e,r,n):void 0,l=(i===f.VertexBuffer.MatricesIndicesKind||i===f.VertexBuffer.MatricesIndicesExtraKind)&&e.type===f.VertexBuffer.FLOAT,h=l?f.VertexBuffer.UNSIGNED_BYTE:e.type,p=l?void 0:e.normalized,d=l?s.getRemappedBufferView(e._buffer,e):s.getVertexBufferView(e._buffer),x=e.byteOffset+r*e.byteStride;this._accessors.push(this._bufferManager.createAccessor(d,function(e,t){if(e==f.VertexBuffer.ColorKind)return t?"VEC4":"VEC3";switch(e){case f.VertexBuffer.PositionKind:case f.VertexBuffer.NormalKind:return"VEC3";case f.VertexBuffer.TangentKind:case f.VertexBuffer.MatricesIndicesKind:case f.VertexBuffer.MatricesIndicesExtraKind:case f.VertexBuffer.MatricesWeightsKind:case f.VertexBuffer.MatricesWeightsExtraKind:return"VEC4";case f.VertexBuffer.UVKind:case f.VertexBuffer.UV2Kind:case f.VertexBuffer.UV3Kind:case f.VertexBuffer.UV4Kind:case f.VertexBuffer.UV5Kind:case f.VertexBuffer.UV6Kind:return"VEC2"}throw new Error("Unknown kind ".concat(e))}(i,s.hasVertexColorAlpha(e)),h,n,x,c,p)),a=this._accessors.length-1,s.setVertexAccessor(e,r,n,a)}o.attributes[function(e){switch(e){case f.VertexBuffer.PositionKind:return"POSITION";case f.VertexBuffer.NormalKind:return"NORMAL";case f.VertexBuffer.TangentKind:return"TANGENT";case f.VertexBuffer.ColorKind:return"COLOR_0";case f.VertexBuffer.UVKind:return"TEXCOORD_0";case f.VertexBuffer.UV2Kind:return"TEXCOORD_1";case f.VertexBuffer.UV3Kind:return"TEXCOORD_2";case f.VertexBuffer.UV4Kind:return"TEXCOORD_3";case f.VertexBuffer.UV5Kind:return"TEXCOORD_4";case f.VertexBuffer.UV6Kind:return"TEXCOORD_5";case f.VertexBuffer.MatricesIndicesKind:return"JOINTS_0";case f.VertexBuffer.MatricesIndicesExtraKind:return"JOINTS_1";case f.VertexBuffer.MatricesWeightsKind:return"WEIGHTS_0";case f.VertexBuffer.MatricesWeightsExtraKind:return"WEIGHTS_1"}throw new Error("Unknown kind: ".concat(e))}(i)]=a}},e.prototype._exportMaterialAsync=function(e,t,r,n){return x(this,void 0,void 0,function(){var s,o;return g(this,function(i){switch(i.label){case 0:return void 0!==(s=this._materialMap.get(e))?[3,8]:(o=t&&Object.keys(t).some(function(e){return e.startsWith("uv")}),(e=e instanceof f.MultiMaterial?e.subMaterials[r.materialIndex]:e)instanceof f.PBRBaseMaterial?[4,this._materialExporter.exportPBRMaterialAsync(e,o)]:[3,2]);case 1:return s=i.sent(),[3,7];case 2:return e instanceof f.StandardMaterial?[4,this._materialExporter.exportStandardMaterialAsync(e,o)]:[3,4];case 3:return s=i.sent(),[3,7];case 4:return e instanceof f.OpenPBRMaterial?[4,this._materialExporter.exportOpenPBRMaterialAsync(e,o)]:[3,6];case 5:return s=i.sent(),[3,7];case 6:return f.Logger.Warn("Unsupported material '".concat(e.name,"' with type ").concat(e.getClassName())),[2];case 7:this._materialMap.set(e,s),i.label=8;case 8:return n.material=s,[2]}})})},e.prototype._exportMeshAsync=function(e,t){return x(this,void 0,void 0,function(){var r,n,s,o,i,a,u,c,l,h,p,d,x,m,T,y,v,b,w,M,A,R,E,C,I,V,S,F,B,O,N,U,P,W;return g(this,function(g){switch(g.label){case 0:if(void 0!==(r=t.getMesh(e)))return[2,r];if(n={primitives:[]},r=this._meshes.length,this._meshes.push(n),t.setMesh(e,r),s=e.isUnIndexed?null:e.getIndices(),o=null===(B=e.geometry)||void 0===B?void 0:B.getVertexBuffers(),i=t.getMorphTargetsFromMesh(e),a=e instanceof f.LinesMesh,u=e instanceof f.GreasedLineBaseMesh,c=e.subMeshes,!(o&&c&&c.length>0))return[3,7];l=0,h=c,g.label=1;case 1:return l<h.length?(p=h[l],d={attributes:{}},x=p.getMaterial()||this._babylonScene.defaultMaterial,u?(v={name:x.name},b=e,m=f.Color3.White(),T=null!==(N=null===(O=b.material)||void 0===O?void 0:O.alpha)&&void 0!==N?N:1,(!(y=null!==(P=null===(U=b.greasedLineMaterial)||void 0===U?void 0:U.color)&&void 0!==P?P:m).equalsWithEpsilon(m,f.Epsilon)||T<1)&&(v.pbrMetallicRoughness={baseColorFactor:_(_([],y.asArray(),!0),[T],!1)}),this._materials.push(v),d.material=this._materials.length-1,[3,5]):[3,2]):[3,7];case 2:return a?(v={name:x.name},(!(b=e).color.equalsWithEpsilon(f.Color3.White(),f.Epsilon)||b.alpha<1)&&(v.pbrMetallicRoughness={baseColorFactor:_(_([],b.color.asArray(),!0),[b.alpha],!1)}),this._materials.push(v),d.material=this._materials.length-1,[3,5]):[3,3];case 3:return[4,this._exportMaterialAsync(x,o,p,d)];case 4:g.sent(),g.label=5;case 5:for(w=a||u?f.Material.LineListDrawMode:null!==(W=e.overrideRenderingFillMode)&&void 0!==W?W:x.fillMode,M=x._getEffectiveOrientation(e),t.wasAddedByNoopNode&&!e.getScene().useRightHandedSystem&&(M=M===f.Material.ClockWiseSideOrientation?f.Material.CounterClockWiseSideOrientation:f.Material.ClockWiseSideOrientation),this._exportIndices(s,s?(0,f.AreIndices32Bits)(s,p.indexCount,p.indexStart,p.verticesStart):p.verticesCount>65535,s?p.indexStart:p.verticesStart,s?p.indexCount:p.verticesCount,-p.verticesStart,w,M,t,d),A=0,R=Object.values(o);A<R.length;A++)E=R[A],this._exportVertexBuffer(E,x,p.verticesStart,p.verticesCount,t,d);if(i)for(d.targets=[],C=0,I=i;C<I.length;C++)F=I[C],d.targets.push(F.attributes);n.primitives.push(d),this._extensionsPostExportMeshPrimitive(d),g.label=6;case 6:return l++,[3,1];case 7:if(i)for(n.weights=[],n.extras||(n.extras={}),n.extras.targetNames=[],V=0,S=i;V<S.length;V++)F=S[V],n.weights.push(F.influence),n.extras.targetNames.push(F.name);return[2,r]}})})},e._ExtensionNames=new Array,e._ExtensionFactories={},e._ExtensionOrders={},e}(),oe=function(){function e(){}return e.GLTFAsync=function(e,t,r){return x(this,void 0,void 0,function(){var n,s;return g(this,function(o){switch(o.label){case 0:return r&&r.exportWithoutWaitingForScene?[3,2]:[4,e.whenReadyAsync()];case 1:o.sent(),o.label=2;case 2:return[4,(n=new se(e,r)).generateGLTFAsync(t.replace(/\.[^/.]+$/,""))];case 3:return s=o.sent(),n.dispose(),[2,s]}})})},e.GLBAsync=function(e,t,r){return x(this,void 0,void 0,function(){var n,s;return g(this,function(o){switch(o.label){case 0:return r&&r.exportWithoutWaitingForScene?[3,2]:[4,e.whenReadyAsync()];case 1:o.sent(),o.label=2;case 2:return[4,(n=new se(e,r)).generateGLBAsync(t.replace(/\.[^/.]+$/,""))];case 3:return s=o.sent(),n.dispose(),[2,s]}})})},e}(),ie="EXT_mesh_gpu_instancing";function ae(e,t){for(var r=new Float32Array(3*t),n=0;n<t;n++)r[3*n+0]=e[4*n+0],r[3*n+1]=e[4*n+1],r[3*n+2]=e[4*n+2];return r}var ue=function(){function e(e){this.name=ie,this.enabled=!0,this.required=!1,this._instanceColorWarned=!1,this._wasUsed=!1,this._exporter=e}return e.prototype.dispose=function(){},Object.defineProperty(e.prototype,"wasUsed",{get:function(){return this._wasUsed},enumerable:!1,configurable:!0}),e.prototype.postExportNodeAsync=function(e,t,r,n,s,o){return x(this,void 0,void 0,function(){var e=this;return g(this,function(n){switch(n.label){case 0:return[4,new Promise(function(n){var i,a;if(t&&r instanceof f.Mesh&&r.hasThinInstances&&e._exporter){e._wasUsed=!0;for(var u=f.Vector3.Zero(),c=f.Quaternion.Identity(),l=f.Vector3.One(),h=r.thinInstanceGetWorldMatrices(),p=f.TmpVectors.Vector3[2],d=f.TmpVectors.Quaternion[1],x=f.TmpVectors.Vector3[3],g=!1,_=!1,m=!1,T=new Float32Array(3*r.thinInstanceCount),y=new Float32Array(4*r.thinInstanceCount),v=new Float32Array(3*r.thinInstanceCount),b=0,w=0,M=h;w<M.length;w++)M[w].decompose(x,d,p),s&&(k(p),D(d)),T.set(p.asArray(),3*b),y.set(d.normalize().asArray(),4*b),v.set(x.asArray(),3*b),g=g||!p.equalsWithEpsilon(u),_=_||!d.equalsWithEpsilon(c),m=m||!x.equalsWithEpsilon(l),b++;var A={attributes:{}};g&&(A.attributes.TRANSLATION=e._buildAccessor(T,"VEC3",r.thinInstanceCount,o)),_&&(A.attributes.ROTATION=e._buildAccessor(y,"VEC4",r.thinInstanceCount,o)),m&&(A.attributes.SCALE=e._buildAccessor(v,"VEC3",r.thinInstanceCount,o));var R=null===(a=null===(i=r._userThinInstanceBuffersStorage)||void 0===i?void 0:i.data)||void 0===a?void 0:a.instanceColor;if(R){var E=r.thinInstanceCount;r.hasVertexAlpha&&R.length===4*E?(e._instanceColorWarned||(f.Logger.Warn("EXT_mesh_gpu_instancing: Exporting instance colors as RGB, alpha channel of instance color is not exported"),e._instanceColorWarned=!0),R=ae(R,E)):R.length===4*E&&(R=ae(R,E)),R.length===3*E&&(A.attributes._COLOR_0=e._buildAccessor(R,"VEC3",E,o))}t.extensions=t.extensions||{},t.extensions[ie]=A}n(t)})];case 1:return[2,n.sent()]}})})},e.prototype._buildAccessor=function(e,t,r,n){var s=n.createBufferView(e),o=n.createAccessor(s,t,5126,r);return this._exporter._accessors.push(o),this._exporter._accessors.length-1},e}();se.RegisterExtension(ie,function(e){return new ue(e)});var ce="KHR_draco_mesh_compression";function le(e){return"POSITION"===e?"POSITION":"NORMAL"===e?"NORMAL":e.startsWith("COLOR")?"COLOR":e.startsWith("TEXCOORD")?"TEX_COORD":"GENERIC"}var he=function(){function e(e){this.name=ce,this.required=!0,this._bufferViewsUsed=new Set,this._accessorsUsed=new Set,this._encodePromises=[],this._wasUsed=!1,this.enabled="Draco"===e.options.meshCompressionMethod&&f.DracoEncoder.DefaultAvailable}return Object.defineProperty(e.prototype,"wasUsed",{get:function(){return this._wasUsed},enumerable:!1,configurable:!0}),e.prototype.dispose=function(){},e.prototype.postExportMeshPrimitive=function(e,t,r){var n=this;if(this.enabled)if(4===e.mode||5===e.mode){var s=[],o=[],i=null;if(void 0!==e.indices){var a=r[e.indices],u=t.getBufferView(a);i=t.getData(u).slice(),s.push(u),o.push(a)}for(var c=[],l=0,h=Object.entries(e.attributes);l<h.length;l++){var p=h[l],d=p[0],x=(a=r[p[1]],u=t.getBufferView(a),W(a.type)),g=(0,f.GetTypedArrayData)(t.getData(u),x,a.componentType,a.byteOffset||0,u.byteStride||(0,f.GetTypeByteLength)(a.componentType)*x,a.count,!0);c.push({kind:d,dracoName:le(d),size:W(a.type),data:g}),s.push(u),o.push(a)}var _={method:e.targets?"MESH_SEQUENTIAL_ENCODING":"MESH_EDGEBREAKER_ENCODING"},m=f.DracoEncoder.Default._encodeAsync(c,i,_).then(function(r){var i={bufferView:-1,attributes:r.attributeIds},a=t.createBufferView(r.data);t.setBufferView(i,a);for(var u=0,c=s;u<c.length;u++){var l=c[u];n._bufferViewsUsed.add(l)}for(var h=0,f=o;h<f.length;h++){var p=f[h];n._accessorsUsed.add(p)}e.extensions||(e.extensions={}),e.extensions[ce]=i}).catch(function(e){f.Logger.Error("KHR_draco_mesh_compression: Failed to export Draco-encoded primitive. Resulting glTF may be invalid. "+e.message)});this._encodePromises.push(m),this._wasUsed=!0}else f.Logger.Warn("Cannot compress primitive with mode "+e.mode+".")},e.prototype.preGenerateBinaryAsync=function(e){return x(this,void 0,void 0,function(){var t=this;return g(this,function(r){switch(r.label){case 0:return this.enabled?[4,Promise.all(this._encodePromises)]:[2];case 1:return r.sent(),this._bufferViewsUsed.forEach(function(r){e.getPropertiesWithBufferView(r).every(function(e){return t._accessorsUsed.has(e)})&&e.removeBufferView(r)}),this._bufferViewsUsed.clear(),this._accessorsUsed.clear(),[2]}})})},e}();se.RegisterExtension(ce,function(e){return new he(e)});var fe="KHR_lights_punctual",pe={name:"",color:[1,1,1],intensity:1,range:Number.MAX_VALUE},de={innerConeAngle:0,outerConeAngle:Math.PI/4},xe=f.Vector3.Backward(),ge=function(){function e(e){this.name=fe,this.enabled=!0,this.required=!1,this._exporter=e}return e.prototype.dispose=function(){this._lights=null},Object.defineProperty(e.prototype,"wasUsed",{get:function(){return!!this._lights},enumerable:!1,configurable:!0}),e.prototype.onExporting=function(){this._exporter._glTF.extensions[fe]=this._lights},e.prototype.postExportNodeAsync=function(e,t,r,n,s){return x(this,void 0,void 0,function(){var o=this;return g(this,function(i){switch(i.label){case 0:return[4,new Promise(function(i){if(r instanceof f.Light){var a=r.getTypeID()==f.Light.LIGHTTYPEID_POINTLIGHT?"point":r.getTypeID()==f.Light.LIGHTTYPEID_DIRECTIONALLIGHT?"directional":r.getTypeID()==f.Light.LIGHTTYPEID_SPOTLIGHT?"spot":null;if(!(a&&r instanceof f.ShadowLight))return f.Logger.Warn("".concat(e,": Light ").concat(r.name," is not supported in ").concat(fe)),void i(t);if(r.falloffType!==f.Light.FALLOFF_GLTF&&f.Logger.Warn("".concat(e,": Light falloff for ").concat(r.name," does not match the ").concat(fe," specification!")),!r.position.equalsToFloats(0,0,0)){var u=f.TmpVectors.Vector3[0].copyFrom(r.position);s&&k(u),t.translation=u.asArray()}if("point"!==a){var c=r.direction.normalizeToRef(f.TmpVectors.Vector3[0]);s&&k(c);var l=f.Quaternion.FromUnitVectorsToRef(xe,c,f.TmpVectors.Quaternion[0]);f.Quaternion.IsIdentity(l)||(t.rotation=l.asArray())}var h={type:a,name:r.name,color:r.diffuse.asArray(),intensity:r.intensity,range:r.range};if(Q(h,pe),"spot"===a){var p=r;h.spot={innerConeAngle:p.innerAngle/2,outerConeAngle:p.angle/2},Q(h.spot,de)}o._lights||(o._lights={lights:[]}),o._lights.lights.push(h);var d={light:o._lights.lights.length-1},x=r.parent;if(x&&j(r,x)){var g=n.get(x);if(g){var _=o._exporter._nodes[g];return q(t,_),_.extensions||(_.extensions={}),_.extensions[fe]=d,void i(null)}}t.extensions||(t.extensions={}),t.extensions[fe]=d,i(t)}else i(t)})];case 1:return[2,i.sent()]}})})},e}();se.RegisterExtension(fe,function(e){return new ge(e)});var _e="EXT_lights_area",me={name:"",color:[1,1,1],intensity:1,size:1},Te={aspect:1},ye=f.Vector3.Backward(),ve=function(){function e(e){this.name=_e,this.enabled=!0,this.required=!1,this._exporter=e}return e.prototype.dispose=function(){this._lights=null},Object.defineProperty(e.prototype,"wasUsed",{get:function(){return!!this._lights},enumerable:!1,configurable:!0}),e.prototype.onExporting=function(){this._exporter._glTF.extensions[_e]=this._lights},e.prototype.postExportNodeAsync=function(e,t,r,n,s){return x(this,void 0,void 0,function(){var o=this;return g(this,function(i){switch(i.label){case 0:return[4,new Promise(function(i){if(r instanceof f.Light){var a=r.getTypeID()==f.Light.LIGHTTYPEID_RECT_AREALIGHT?"rect":null;if(!a)return f.Logger.Warn("".concat(e,": Light ").concat(r.name," is not supported in ").concat(_e)),void i(t);var u=r;if(u.falloffType!==f.Light.FALLOFF_GLTF&&f.Logger.Warn("".concat(e,": Light falloff for ").concat(r.name," does not match the ").concat(_e," specification!")),!u.position.equalsToFloats(0,0,0)){var c=f.TmpVectors.Vector3[0].copyFrom(u.position);s&&k(c),t.translation=c.asArray()}var l=f.Vector3.Forward();s&&k(l);var h=f.Quaternion.FromUnitVectorsToRef(ye,l,f.TmpVectors.Quaternion[0]);f.Quaternion.IsIdentity(h)||(t.rotation=h.asArray());var p={type:a,name:u.name,color:u.diffuse.asArray(),intensity:u.intensity,size:u.height,rect:{aspect:u.width/u.height}};Q(p,me),p.rect&&Q(p.rect,Te),o._lights||(o._lights={lights:[]}),o._lights.lights.push(p);var d={light:o._lights.lights.length-1},x=r.parent;if(x&&j(u,x)){var g=n.get(x);if(g){var _=o._exporter._nodes[g];return q(t,_),_.extensions||(_.extensions={}),_.extensions[_e]=d,void i(null)}}t.extensions||(t.extensions={}),t.extensions[_e]=d,i(t)}else i(t)})];case 1:return[2,i.sent()]}})})},e}();se.RegisterExtension(_e,function(e){return new ve(e)});var be="KHR_materials_anisotropy";function we(e){return x(this,void 0,void 0,function(){var t,r,n;return g(this,function(s){switch(s.label){case 0:return t=e.getScene(),r=e.specularRoughnessAnisotropyTexture,n=e.geometryTangentTexture,r||n?[4,(0,f.MergeTexturesAsync)("AnisotropyTexture",(0,f.CreateRGBAConfiguration)(n?(0,f.CreateTextureInput)(n,0):(0,f.CreateConstantInput)(1),n?(0,f.CreateTextureInput)(n,1):(0,f.CreateConstantInput)(0),r?(0,f.CreateTextureInput)(r,0):(0,f.CreateConstantInput)(1)),t)]:[2,null];case 1:return[2,s.sent()]}})})}var Me=function(){function e(e){this.name=be,this.enabled=!0,this.required=!1,this._wasUsed=!1,this._anisoTexturesMap={},this._exporter=e}return e.prototype.dispose=function(){},Object.defineProperty(e.prototype,"wasUsed",{get:function(){return this._wasUsed},enumerable:!1,configurable:!0}),e.prototype.postExportMaterialAdditionalTexturesAsync=function(e,t,r){return x(this,void 0,void 0,function(){var e,t,n;return g(this,function(s){switch(s.label){case 0:return e=[],r instanceof f.PBRBaseMaterial?r.anisotropy.isEnabled&&!r.anisotropy.legacy?(r.anisotropy.texture&&e.push(r.anisotropy.texture),[2,e]):[3,5]:[3,1];case 1:return r instanceof f.OpenPBRMaterial&&r.specularRoughnessAnisotropy>0?(t=function(e){var t=e.specularRoughnessAnisotropyTexture,r=e.geometryTangentTexture,n=t&&t.getInternalTexture()?t.getInternalTexture().uniqueId:"NoStrength",s=r&&r.getInternalTexture()?r.getInternalTexture().uniqueId:"NoTangent";return"".concat(n,"_").concat(s)}(r),this._anisoTexturesMap[t]?(e.push(this._anisoTexturesMap[t]),[3,4]):[3,2]):[3,5];case 2:return[4,we(r)];case 3:(n=s.sent())&&(e.push(n),this._anisoTexturesMap[t]=n),s.label=4;case 4:return[2,e];case 5:return[2,[]]}})})},e.prototype.postExportMaterialAsync=function(e,t,r){var n=this;return new Promise(function(e){var s,o,i,a,u,c;if(r instanceof f.PBRBaseMaterial){if(!r.anisotropy.isEnabled||r.anisotropy.legacy)return void e(t);n._wasUsed=!0,t.extensions=t.extensions||{};var l=n._exporter._materialExporter.getTextureInfo(r.anisotropy.texture);null!==(T={anisotropyStrength:r.anisotropy.intensity,anisotropyRotation:r.anisotropy.angle,anisotropyTexture:null!=l?l:void 0}).anisotropyTexture&&n._exporter._materialNeedsUVsSet.add(r),t.extensions[be]=T}else if(r instanceof f.OpenPBRMaterial&&r.specularRoughnessAnisotropy>0){n._wasUsed=!0,t.extensions=t.extensions||{};var h=r.specularRoughnessTexture;r._useRoughnessFromMetallicTextureGreen&&(h=r.baseMetalnessTexture);var p=n._anisoTexturesMap[r.id];if(!h&&!p){var d=r.specularRoughness,x=r.specularRoughnessAnisotropy;if(!r._useGltfStyleAnisotropy){var g=(o=r.specularRoughness,c=(1-(i=r.specularRoughnessAnisotropy))*(u=(a=o*o)*Math.sqrt(2/(1+(1-i)*(1-i)))),{newBaseRoughness:Math.sqrt(c),newAnisotropyStrength:Math.min(Math.sqrt((u-a)/Math.max(1-a,1e-4)),1)});d=g.newBaseRoughness,x=g.newAnisotropyStrength}t.pbrMetallicRoughness&&(t.pbrMetallicRoughness.roughnessFactor=d);var _={anisotropyStrength:x,anisotropyRotation:r.geometryTangentAngle+.5*Math.PI,anisotropyTexture:void 0};return t.extensions[be]=_,e(t)}var m=p?n._exporter._materialExporter.getTextureInfo(p):null,T={anisotropyStrength:r.specularRoughnessAnisotropy,anisotropyRotation:r.geometryTangentAngle,anisotropyTexture:m||void 0,extensions:{}};r._useGltfStyleAnisotropy||(t.extensions.KHR_materials_openpbr={},(s=n._exporter._glTF).extensionsUsed||(s.extensionsUsed=[]),-1===n._exporter._glTF.extensionsUsed.indexOf("KHR_materials_openpbr")&&n._exporter._glTF.extensionsUsed.push("KHR_materials_openpbr")),n._exporter._materialNeedsUVsSet.add(r),t.extensions[be]=T}e(t)})},e}();se.RegisterExtension(be,function(e){return new Me(e)});var Ae="KHR_materials_clearcoat";function Re(e){return x(this,void 0,void 0,function(){var t,r,n;return g(this,function(s){switch(s.label){case 0:return t=e.getScene(),r=e.coatWeightTexture,n=e.coatRoughnessTexture,r||n?[4,(0,f.MergeTexturesAsync)("CoatTexture",(0,f.CreateRGBAConfiguration)(r?(0,f.CreateTextureInput)(r,0):(0,f.CreateConstantInput)(1),n?(0,f.CreateTextureInput)(n,e._useCoatRoughnessFromGreenChannel?1:0):(0,f.CreateConstantInput)(1)),t)]:[2,null];case 1:return[2,s.sent().getInternalTexture()]}})})}function Ee(e,t){var r=new f.Texture(t.name,t.getScene());return r._texture=e,r.coordinatesIndex=t.coordinatesIndex,t instanceof f.Texture&&(r.uOffset=t.uOffset,r.vOffset=t.vOffset,r.uScale=t.uScale,r.vScale=t.vScale,r.wAng=t.wAng),r.wrapU=t.wrapU,r.wrapV=t.wrapV,r}var Ce=function(){function e(e){this.name=Ae,this.enabled=!0,this.required=!1,this._wasUsed=!1,this._mergedTexturesMap={},this._cachedInternalTexturesMap={},this._exporter=e}return e.prototype.dispose=function(){for(var e=0,t=Object.keys(this._mergedTexturesMap);e<t.length;e++){var r=t[e];this._mergedTexturesMap[r].dispose()}this._mergedTexturesMap={};for(var n=0,s=Object.keys(this._cachedInternalTexturesMap);n<s.length;n++)r=s[n],this._cachedInternalTexturesMap[r].dispose();this._cachedInternalTexturesMap={}},Object.defineProperty(e.prototype,"wasUsed",{get:function(){return this._wasUsed},enumerable:!1,configurable:!0}),e.prototype.postExportMaterialAdditionalTexturesAsync=function(e,t,r){return x(this,void 0,void 0,function(){var e,t,n,s;return g(this,function(o){switch(o.label){case 0:return e=[],r instanceof f.PBRBaseMaterial?r.clearCoat.isEnabled?(r.clearCoat.texture&&e.push(r.clearCoat.texture),!r.clearCoat.useRoughnessFromMainTexture&&r.clearCoat.textureRoughness&&e.push(r.clearCoat.textureRoughness),r.clearCoat.bumpTexture&&e.push(r.clearCoat.bumpTexture),[2,e]):[3,5]:[3,1];case 1:return r instanceof f.OpenPBRMaterial&&r.coatWeight>0?(t=!1,r.coatWeightTexture?r.coatRoughnessTexture?r._useCoatRoughnessFromGreenChannel&&r.coatWeightTexture.getInternalTexture()===r.coatRoughnessTexture.getInternalTexture()?(e.push(r.coatWeightTexture),e.push(r.coatRoughnessTexture)):t=!0:e.push(r.coatWeightTexture):r.coatRoughnessTexture&&(r._useCoatRoughnessFromGreenChannel?e.push(r.coatRoughnessTexture):t=!0),t?(n=function(e){var t=e.coatWeightTexture,r=t&&t.getInternalTexture()?t.getInternalTexture().uniqueId:"NoCoat",n=e.coatRoughnessTexture,s=n&&n.getInternalTexture()?n.getInternalTexture().uniqueId:"NoRoughness";return"".concat(r,"_").concat(s)}(r),this._cachedInternalTexturesMap[n]?[3,3]:[4,Re(r)]):[3,4]):[3,5];case 2:(s=o.sent())&&(this._cachedInternalTexturesMap[n]=s),o.label=3;case 3:this._cachedInternalTexturesMap[n]&&(r.coatWeightTexture&&(this._mergedTexturesMap[r.coatWeightTexture.uniqueId]=Ee(this._cachedInternalTexturesMap[n],r.coatWeightTexture),e.push(this._mergedTexturesMap[r.coatWeightTexture.uniqueId])),r.coatRoughnessTexture&&(this._mergedTexturesMap[r.coatRoughnessTexture.uniqueId]=Ee(this._cachedInternalTexturesMap[n],r.coatRoughnessTexture),e.push(this._mergedTexturesMap[r.coatRoughnessTexture.uniqueId]))),o.label=4;case 4:return r.geometryCoatNormalTexture&&e.push(r.geometryCoatNormalTexture),[2,e];case 5:return[2,[]]}})})},e.prototype.postExportMaterialAsync=function(e,t,r){var n=this;return new Promise(function(e){if(r instanceof f.PBRBaseMaterial){if(!r.clearCoat.isEnabled)return void e(t);n._wasUsed=!0,t.extensions=t.extensions||{};var s,o=n._exporter._materialExporter.getTextureInfo(r.clearCoat.texture);s=r.clearCoat.useRoughnessFromMainTexture?n._exporter._materialExporter.getTextureInfo(r.clearCoat.texture):n._exporter._materialExporter.getTextureInfo(r.clearCoat.textureRoughness),r.clearCoat.isTintEnabled&&f.Tools.Warn("Clear Color tint is not supported for glTF export. Ignoring for: ".concat(r.name)),r.clearCoat.remapF0OnInterfaceChange&&f.Tools.Warn("Clear Color F0 remapping is not supported for glTF export. Ignoring for: ".concat(r.name));var i=n._exporter._materialExporter.getTextureInfo(r.clearCoat.bumpTexture);null===(c={clearcoatFactor:r.clearCoat.intensity,clearcoatTexture:null!=o?o:void 0,clearcoatRoughnessFactor:r.clearCoat.roughness,clearcoatRoughnessTexture:null!=s?s:void 0,clearcoatNormalTexture:null!=i?i:void 0}).clearcoatTexture&&null===c.clearcoatRoughnessTexture&&null===c.clearcoatRoughnessTexture||n._exporter._materialNeedsUVsSet.add(r),t.extensions[Ae]=c}else if(r instanceof f.OpenPBRMaterial){if(0==r.coatWeight)return void e(t);n._wasUsed=!0,t.extensions=t.extensions||{};var a=void 0,u=void 0;r.coatWeightTexture&&(a=n._mergedTexturesMap[r.coatWeightTexture.uniqueId],u=n._exporter._materialExporter.getTextureInfo(a));var c,l=void 0,h=void 0;r.coatRoughnessTexture&&(l=n._mergedTexturesMap[r.coatRoughnessTexture.uniqueId],h=n._exporter._materialExporter.getTextureInfo(l)),r.coatColorTexture&&f.Tools.Warn("Clear Color tint is not supported for glTF export. Ignoring for: ".concat(r.name)),i=n._exporter._materialExporter.getTextureInfo(r.geometryCoatNormalTexture),null===(c={clearcoatFactor:r.coatWeight,clearcoatTexture:null!=u?u:void 0,clearcoatRoughnessFactor:r.coatRoughness,clearcoatRoughnessTexture:null!=h?h:void 0,clearcoatNormalTexture:null!=i?i:void 0}).clearcoatTexture&&null===c.clearcoatRoughnessTexture&&null===c.clearcoatRoughnessTexture||n._exporter._materialNeedsUVsSet.add(r),t.extensions[Ae]=c}e(t)})},e}();se.RegisterExtension(Ae,function(e){return new Ce(e)});var Ie="KHR_materials_coat";function Ve(e){var t=e.coatRoughnessAnisotropyTexture,r=e.geometryCoatTangentTexture,n=t&&t.getInternalTexture()?t.getInternalTexture().uniqueId:"NoStrength",s=r&&r.getInternalTexture()?r.getInternalTexture().uniqueId:"NoTangent";return"".concat(n,"_").concat(s)}function Se(e){return x(this,void 0,void 0,function(){var t,r,n;return g(this,function(s){switch(s.label){case 0:return t=e.getScene(),r=e.coatRoughnessAnisotropyTexture,n=e.geometryCoatTangentTexture,r||n?[4,(0,f.MergeTexturesAsync)("AnisotropyTexture",(0,f.CreateRGBAConfiguration)(n?(0,f.CreateTextureInput)(n,0):(0,f.CreateConstantInput)(1),n?(0,f.CreateTextureInput)(n,1):(0,f.CreateConstantInput)(0),r?(0,f.CreateTextureInput)(r,0):(0,f.CreateConstantInput)(1)),t)]:[2,null];case 1:return[2,s.sent()]}})})}function Fe(e){return x(this,void 0,void 0,function(){var t,r,n;return g(this,function(s){switch(s.label){case 0:return t=e.getScene(),r=e.coatWeightTexture,n=e.coatRoughnessTexture,r||n?[4,(0,f.MergeTexturesAsync)("CoatTexture",(0,f.CreateRGBAConfiguration)(r?(0,f.CreateTextureInput)(r,0):(0,f.CreateConstantInput)(1),n?(0,f.CreateTextureInput)(n,e._useCoatRoughnessFromGreenChannel?1:0):(0,f.CreateConstantInput)(1)),t)]:[2,null];case 1:return[2,s.sent().getInternalTexture()]}})})}function Be(e,t){var r=new f.Texture(t.name,t.getScene());return r._texture=e,r.coordinatesIndex=t.coordinatesIndex,t instanceof f.Texture&&(r.uOffset=t.uOffset,r.vOffset=t.vOffset,r.uScale=t.uScale,r.vScale=t.vScale,r.wAng=t.wAng),r.wrapU=t.wrapU,r.wrapV=t.wrapV,r}var Oe=function(){function e(e){this.name=Ie,this.enabled=!0,this.required=!1,this._wasUsed=!1,this._mergedTexturesMap={},this._cachedInternalTexturesMap={},this._exporter=e}return e.prototype.dispose=function(){for(var e=0,t=Object.keys(this._mergedTexturesMap);e<t.length;e++){var r=t[e];this._mergedTexturesMap[r].dispose()}this._mergedTexturesMap={};for(var n=0,s=Object.keys(this._cachedInternalTexturesMap);n<s.length;n++)r=s[n],this._cachedInternalTexturesMap[r].dispose();this._cachedInternalTexturesMap={}},Object.defineProperty(e.prototype,"wasUsed",{get:function(){return this._wasUsed},enumerable:!1,configurable:!0}),e.prototype.postExportMaterialAdditionalTexturesAsync=function(e,t,r){return x(this,void 0,void 0,function(){var e,t,n,s,o;return g(this,function(i){switch(i.label){case 0:return e=[],r instanceof f.PBRBaseMaterial?r.clearCoat.isEnabled?(r.clearCoat.texture&&e.push(r.clearCoat.texture),!r.clearCoat.useRoughnessFromMainTexture&&r.clearCoat.textureRoughness&&e.push(r.clearCoat.textureRoughness),r.clearCoat.bumpTexture&&e.push(r.clearCoat.bumpTexture),r.clearCoat.tintTexture&&e.push(r.clearCoat.tintTexture),[2,e]):[3,9]:[3,1];case 1:return r instanceof f.OpenPBRMaterial&&r.coatWeight>0?(t=!1,r.coatWeightTexture?r.coatRoughnessTexture?r._useCoatRoughnessFromGreenChannel&&r.coatWeightTexture.getInternalTexture()===r.coatRoughnessTexture.getInternalTexture()?(e.push(r.coatWeightTexture),e.push(r.coatRoughnessTexture)):t=!0:e.push(r.coatWeightTexture):r.coatRoughnessTexture&&(r._useCoatRoughnessFromGreenChannel?e.push(r.coatRoughnessTexture):t=!0),t?(s=function(e){var t=e.coatWeightTexture,r=t&&t.getInternalTexture()?t.getInternalTexture().uniqueId:"NoCoat",n=e.coatRoughnessTexture,s=n&&n.getInternalTexture()?n.getInternalTexture().uniqueId:"NoRoughness";return"".concat(r,"_").concat(s)}(r),this._cachedInternalTexturesMap[s]?[3,3]:[4,Fe(r)]):[3,4]):[3,9];case 2:(n=i.sent())&&(this._cachedInternalTexturesMap[s]=n),i.label=3;case 3:this._cachedInternalTexturesMap[s]&&(r.coatWeightTexture&&(this._mergedTexturesMap[r.coatWeightTexture.uniqueId]=Be(this._cachedInternalTexturesMap[s],r.coatWeightTexture),e.push(this._mergedTexturesMap[r.coatWeightTexture.uniqueId])),r.coatRoughnessTexture&&(this._mergedTexturesMap[r.coatRoughnessTexture.uniqueId]=Be(this._cachedInternalTexturesMap[s],r.coatRoughnessTexture),e.push(this._mergedTexturesMap[r.coatRoughnessTexture.uniqueId]))),i.label=4;case 4:return r.geometryCoatNormalTexture&&e.push(r.geometryCoatNormalTexture),r.coatColorTexture&&e.push(r.coatColorTexture),r.coatRoughnessAnisotropy>0?(s=Ve(r),this._mergedTexturesMap[s]?(e.push(this._mergedTexturesMap[s]),[3,7]):[3,5]):[3,8];case 5:return[4,Se(r)];case 6:(o=i.sent())&&(e.push(o),this._mergedTexturesMap[s]=o),i.label=7;case 7:case 8:return[2,e];case 9:return[2,[]]}})})},e.prototype.postExportMaterialAsync=function(e,t,r){var n=this;return new Promise(function(e){var s,o,i,a,u,c;if(r instanceof f.PBRBaseMaterial){if(!r.clearCoat.isEnabled)return void e(t);n._wasUsed=!0,t.extensions=t.extensions||{};var l,h=n._exporter._materialExporter.getTextureInfo(r.clearCoat.texture);l=r.clearCoat.useRoughnessFromMainTexture?n._exporter._materialExporter.getTextureInfo(r.clearCoat.texture):n._exporter._materialExporter.getTextureInfo(r.clearCoat.textureRoughness);var p=void 0;r.clearCoat.isTintEnabled&&(p=n._exporter._materialExporter.getTextureInfo(r.clearCoat.tintTexture));var d=n._exporter._materialExporter.getTextureInfo(r.clearCoat.bumpTexture),x=r.clearCoat.indexOfRefraction;null===(T={coatFactor:r.clearCoat.intensity,coatTexture:null!=h?h:void 0,coatRoughnessFactor:r.clearCoat.roughness,coatRoughnessTexture:null!=l?l:void 0,coatNormalTexture:null!=d?d:void 0,coatColorFactor:r.clearCoat.tintColor.asArray(),coatColorTexture:null!=p?p:void 0,coatIor:1.5!==x?x:void 0}).coatTexture&&null===T.coatRoughnessTexture&&null===T.coatRoughnessTexture&&null===T.coatColorTexture||n._exporter._materialNeedsUVsSet.add(r),t.extensions[Ie]=T}else if(r instanceof f.OpenPBRMaterial){if(0==r.coatWeight)return void e(t);n._wasUsed=!0,t.extensions=t.extensions||{};var g=void 0;h=void 0,r.coatWeightTexture&&(g=n._mergedTexturesMap[r.coatWeightTexture.uniqueId]?n._mergedTexturesMap[r.coatWeightTexture.uniqueId]:r.coatWeightTexture,h=n._exporter._materialExporter.getTextureInfo(g));var _=void 0,m=void 0;r.coatRoughnessTexture&&(_=n._mergedTexturesMap[r.coatRoughnessTexture.uniqueId]?n._mergedTexturesMap[r.coatRoughnessTexture.uniqueId]:r.coatRoughnessTexture,m=n._exporter._materialExporter.getTextureInfo(_)),d=n._exporter._materialExporter.getTextureInfo(r.geometryCoatNormalTexture),p=n._exporter._materialExporter.getTextureInfo(r.coatColorTexture),x=r.coatIor;var T,y=r.coatDarkening,v=r.coatRoughnessTexture,b=Ve(r),w=n._mergedTexturesMap[b],M=0,A=0,R=void 0;if(r.coatRoughnessAnisotropy>0){if(v||w){var E=w?n._exporter._materialExporter.getTextureInfo(w):null;M=r.coatRoughnessAnisotropy,A=r.geometryCoatTangentAngle,R=E||void 0}else{var C=r.coatRoughness,I=r.coatRoughnessAnisotropy;if(!r._useGltfStyleAnisotropy){var V=(o=r.coatRoughness,c=(1-(i=r.coatRoughnessAnisotropy))*(u=(a=o*o)*Math.sqrt(2/(1+(1-i)*(1-i)))),{newBaseRoughness:Math.sqrt(c),newAnisotropyStrength:Math.min(Math.sqrt((u-a)/Math.max(1-a,1e-4)),1)});C=V.newBaseRoughness,I=V.newAnisotropyStrength}t.pbrMetallicRoughness&&(t.pbrMetallicRoughness.roughnessFactor=C),M=I,A=r.geometryCoatTangentAngle+.5*Math.PI,R=void 0}r._useGltfStyleAnisotropy||(t.extensions.KHR_materials_openpbr={},(s=n._exporter._glTF).extensionsUsed||(s.extensionsUsed=[]),-1===n._exporter._glTF.extensionsUsed.indexOf("KHR_materials_openpbr")&&n._exporter._glTF.extensionsUsed.push("KHR_materials_openpbr"))}null===(T={coatFactor:r.coatWeight,coatTexture:null!=h?h:void 0,coatRoughnessFactor:r.coatRoughness,coatRoughnessTexture:null!=m?m:void 0,coatNormalTexture:null!=d?d:void 0,coatColorFactor:r.coatColor.asArray(),coatColorTexture:null!=p?p:void 0,coatIor:1.5!==x?x:void 0,coatDarkeningFactor:1!==y?y:void 0,coatAnisotropyRotation:A,coatAnisotropyStrength:M,coatAnisotropyTexture:R}).coatTexture&&null===T.coatRoughnessTexture&&null===T.coatRoughnessTexture&&null===T.coatAnisotropyTexture&&null===T.coatColorTexture||n._exporter._materialNeedsUVsSet.add(r),t.extensions[Ie]=T}e(t)})},e}();se.RegisterExtension(Ie,function(e){return new Oe(e)});var Ne="KHR_materials_diffuse_transmission";function Ue(e,t){var r=t.subSurface,n=null;return r.translucencyIntensityTexture?n=r.translucencyIntensityTexture:r.thicknessTexture&&r.useMaskFromThicknessTexture&&(n=r.thicknessTexture),n&&!r.useGltfStyleTextures?(f.Logger.Warn("".concat(e,": Translucency intensity texture is not supported when useGltfStyleTextures = false. Ignoring for: ").concat(t.name),1),null):n}var Pe=function(){function e(e){this.name=Ne,this.enabled=!0,this.required=!1,this._wasUsed=!1,this._exporter=e}return e.prototype.dispose=function(){},Object.defineProperty(e.prototype,"wasUsed",{get:function(){return this._wasUsed},enumerable:!1,configurable:!0}),e.prototype.postExportMaterialAdditionalTexturesAsync=function(e,t,r){return x(this,void 0,void 0,function(){var t,n;return g(this,function(s){return t=[],r instanceof f.PBRMaterial&&this._isExtensionEnabled(r)?((n=Ue(e,r))&&t.push(n),r.subSurface.translucencyColorTexture&&t.push(r.subSurface.translucencyColorTexture),[2,t]):[2,t]})})},e.prototype._isExtensionEnabled=function(e){if(e.unlit)return!1;var t=e.subSurface;return!!t.isTranslucencyEnabled&&!e.unlit&&!t.useAlbedoToTintTranslucency&&t.useGltfStyleTextures&&1===t.volumeIndexOfRefraction&&0===t.minimumThickness&&0===t.maximumThickness},e.prototype.postExportMaterialAsync=function(e,t,r){var n=this;return new Promise(function(s){var o,i;if(r instanceof f.PBRMaterial&&n._isExtensionEnabled(r)){n._wasUsed=!0;var a=r.subSurface,u=Ue(e,r),c=0==a.translucencyIntensity?void 0:a.translucencyIntensity,l=null!==(o=n._exporter._materialExporter.getTextureInfo(u))&&void 0!==o?o:void 0,h=!a.translucencyColor||a.translucencyColor.equalsFloats(1,1,1)?void 0:a.translucencyColor.asArray(),p=null!==(i=n._exporter._materialExporter.getTextureInfo(a.translucencyColorTexture))&&void 0!==i?i:void 0,d={diffuseTransmissionFactor:c,diffuseTransmissionTexture:l,diffuseTransmissionColorFactor:h,diffuseTransmissionColorTexture:p};(l||p)&&n._exporter._materialNeedsUVsSet.add(r),t.extensions=t.extensions||{},t.extensions[Ne]=d}s(t)})},e}();se.RegisterExtension(Ne,function(e){return new Pe(e)});var We="KHR_materials_dispersion",Le=function(){function e(){this.name=We,this.enabled=!0,this.required=!1,this._wasUsed=!1}return e.prototype.dispose=function(){},Object.defineProperty(e.prototype,"wasUsed",{get:function(){return this._wasUsed},enumerable:!1,configurable:!0}),e.prototype._isExtensionEnabled=function(e){if(e.unlit)return!1;var t=e.subSurface;return!(!t.isRefractionEnabled&&!t.isDispersionEnabled)},e.prototype.postExportMaterialAsync=function(e,t,r){var n=this;return new Promise(function(e){if(r instanceof f.PBRMaterial&&n._isExtensionEnabled(r)){n._wasUsed=!0;var s={dispersion:r.subSurface.dispersion};t.extensions=t.extensions||{},t.extensions[We]=s}e(t)})},e}();se.RegisterExtension(We,function(){return new Le});var ze="KHR_materials_emissive_strength",Ke=function(){function e(){this.name=ze,this.enabled=!0,this.required=!1,this._wasUsed=!1}return e.prototype.dispose=function(){},Object.defineProperty(e.prototype,"wasUsed",{get:function(){return this._wasUsed},enumerable:!1,configurable:!0}),e.prototype.postExportMaterialAsync=function(e,t,r){return x(this,void 0,void 0,function(){var e=this;return g(this,function(n){switch(n.label){case 0:return[4,new Promise(function(n){if(!(r instanceof f.PBRMaterial))return n(t);var s=r.emissiveColor.scale(r.emissiveIntensity),o=Math.max.apply(Math,s.asArray());if(o>1){t.emissiveFactor=s.scale(1/o).asArray(),e._wasUsed=!0;var i={emissiveStrength:o};t.extensions||(t.extensions={}),t.extensions[ze]=i}else t.emissiveFactor=s.asArray();return n(t)})];case 1:return[2,n.sent()]}})})},e}();se.RegisterExtension(ze,function(){return new Ke});var ke="KHR_materials_ior",Ge=function(){function e(){this.name=ke,this.enabled=!0,this.required=!1,this._wasUsed=!1}return e.prototype.dispose=function(){},Object.defineProperty(e.prototype,"wasUsed",{get:function(){return this._wasUsed},enumerable:!1,configurable:!0}),e.prototype._isExtensionEnabled=function(e){return!e.unlit&&null!=e.indexOfRefraction&&1.5!=e.indexOfRefraction},e.prototype.postExportMaterialAsync=function(e,t,r){var n=this;return new Promise(function(e){if(r instanceof f.PBRMaterial&&n._isExtensionEnabled(r)){n._wasUsed=!0;var s={ior:r.indexOfRefraction};t.extensions=t.extensions||{},t.extensions[ke]=s}e(t)})},e}();se.RegisterExtension(ke,function(e){return new Ge});var De="KHR_materials_iridescence",He=function(){function e(e){this.name=De,this.enabled=!0,this.required=!1,this._wasUsed=!1,this._exporter=e}return e.prototype.dispose=function(){},Object.defineProperty(e.prototype,"wasUsed",{get:function(){return this._wasUsed},enumerable:!1,configurable:!0}),e.prototype.postExportMaterialAdditionalTexturesAsync=function(e,t,r){return x(this,void 0,void 0,function(){var e;return g(this,function(t){if(e=[],r instanceof f.PBRBaseMaterial){if(r.iridescence.isEnabled)return r.iridescence.texture&&e.push(r.iridescence.texture),r.iridescence.thicknessTexture&&r.iridescence.thicknessTexture!==r.iridescence.texture&&e.push(r.iridescence.thicknessTexture),[2,e]}else if(r instanceof f.OpenPBRMaterial&&r.thinFilmWeight>0)return r.thinFilmWeightTexture&&e.push(r.thinFilmWeightTexture),r.thinFilmThicknessTexture&&r.thinFilmThicknessTexture!==r.thinFilmWeightTexture&&e.push(r.thinFilmThicknessTexture),[2,e];return[2,[]]})})},e.prototype.postExportMaterialAsync=function(e,t,r){var n=this;return new Promise(function(e){if(r instanceof f.PBRBaseMaterial){if(!r.iridescence.isEnabled)return void e(t);n._wasUsed=!0,t.extensions=t.extensions||{};var s=n._exporter._materialExporter.getTextureInfo(r.iridescence.texture),o=n._exporter._materialExporter.getTextureInfo(r.iridescence.thicknessTexture);null===(i={iridescenceFactor:r.iridescence.intensity,iridescenceIor:r.iridescence.indexOfRefraction,iridescenceThicknessMinimum:r.iridescence.minimumThickness,iridescenceThicknessMaximum:r.iridescence.maximumThickness,iridescenceTexture:null!=s?s:void 0,iridescenceThicknessTexture:null!=o?o:void 0}).iridescenceTexture&&null===i.iridescenceThicknessTexture||n._exporter._materialNeedsUVsSet.add(r),t.extensions[De]=i}else if(r instanceof f.OpenPBRMaterial){if(r.thinFilmWeight<=0)return void e(t);n._wasUsed=!0,t.extensions=t.extensions||{};var i,a=n._exporter._materialExporter.getTextureInfo(r.thinFilmWeightTexture),u=n._exporter._materialExporter.getTextureInfo(r.thinFilmThicknessTexture);null===(i={iridescenceFactor:r.thinFilmWeight,iridescenceIor:r.thinFilmIor,iridescenceThicknessMinimum:1e3*r.thinFilmThicknessMin,iridescenceThicknessMaximum:1e3*r.thinFilmThickness,iridescenceTexture:null!=a?a:void 0,iridescenceThicknessTexture:null!=u?u:void 0}).iridescenceTexture&&null===i.iridescenceThicknessTexture||n._exporter._materialNeedsUVsSet.add(r),t.extensions[De]=i}e(t)})},e}();se.RegisterExtension(De,function(e){return new He(e)});var qe="KHR_materials_sheen",je=function(){function e(e){this.name=qe,this.enabled=!0,this.required=!1,this._wasUsed=!1,this._exporter=e}return e.prototype.dispose=function(){},Object.defineProperty(e.prototype,"wasUsed",{get:function(){return this._wasUsed},enumerable:!1,configurable:!0}),e.prototype.postExportMaterialAdditionalTexturesAsync=function(e,t,r){return x(this,void 0,void 0,function(){return g(this,function(e){return r instanceof f.PBRMaterial&&r.sheen.isEnabled&&r.sheen.texture?[2,[r.sheen.texture]]:[2,[]]})})},e.prototype.postExportMaterialAsync=function(e,t,r){return x(this,void 0,void 0,function(){var e=this;return g(this,function(n){switch(n.label){case 0:return[4,new Promise(function(n){var s,o,i,a;if(r instanceof f.PBRMaterial){if(!r.sheen.isEnabled)return void n(t);e._wasUsed=!0,null==t.extensions&&(t.extensions={});var u={sheenColorFactor:r.sheen.color.asArray(),sheenRoughnessFactor:null!==(s=r.sheen.roughness)&&void 0!==s?s:0};null===u.sheenColorTexture&&null===u.sheenRoughnessTexture||e._exporter._materialNeedsUVsSet.add(r),r.sheen.texture&&(u.sheenColorTexture=null!==(o=e._exporter._materialExporter.getTextureInfo(r.sheen.texture))&&void 0!==o?o:void 0),r.sheen.textureRoughness&&!r.sheen.useRoughnessFromMainTexture?u.sheenRoughnessTexture=null!==(i=e._exporter._materialExporter.getTextureInfo(r.sheen.textureRoughness))&&void 0!==i?i:void 0:r.sheen.texture&&r.sheen.useRoughnessFromMainTexture&&(u.sheenRoughnessTexture=null!==(a=e._exporter._materialExporter.getTextureInfo(r.sheen.texture))&&void 0!==a?a:void 0),t.extensions[qe]=u}n(t)})];case 1:return[2,n.sent()]}})})},e}();se.RegisterExtension(qe,function(e){return new je(e)});var Qe="KHR_materials_fuzz";function Xe(e){return x(this,void 0,void 0,function(){var t,r,n;return g(this,function(s){switch(s.label){case 0:return t=e.getScene(),r=e.fuzzColorTexture,n=e.fuzzRoughnessTexture,r||n?[4,(0,f.MergeTexturesAsync)("FuzzTexture",(0,f.CreateRGBAConfiguration)(r?(0,f.CreateTextureInput)(r,0):(0,f.CreateConstantInput)(1),r?(0,f.CreateTextureInput)(r,1):(0,f.CreateConstantInput)(1),r?(0,f.CreateTextureInput)(r,2):(0,f.CreateConstantInput)(1),n?(0,f.CreateTextureInput)(n,e._useFuzzRoughnessFromTextureAlpha?3:0):(0,f.CreateConstantInput)(1)),t)]:[2,null];case 1:return[2,s.sent().getInternalTexture()]}})})}function Ye(e,t){var r=new f.Texture(t.name,t.getScene());return r._texture=e,r.coordinatesIndex=t.coordinatesIndex,t instanceof f.Texture&&(r.uOffset=t.uOffset,r.vOffset=t.vOffset,r.uScale=t.uScale,r.vScale=t.vScale,r.wAng=t.wAng),r.wrapU=t.wrapU,r.wrapV=t.wrapV,r}var Ze=function(){function e(e){this.name=Qe,this.enabled=!0,this.required=!1,this._wasUsed=!1,this._mergedTexturesMap={},this._cachedInternalTexturesMap={},this._exporter=e}return e.prototype.dispose=function(){for(var e=0,t=Object.keys(this._mergedTexturesMap);e<t.length;e++){var r=t[e];this._mergedTexturesMap[r].dispose()}this._mergedTexturesMap={};for(var n=0,s=Object.keys(this._cachedInternalTexturesMap);n<s.length;n++)r=s[n],this._cachedInternalTexturesMap[r].dispose();this._cachedInternalTexturesMap={}},Object.defineProperty(e.prototype,"wasUsed",{get:function(){return this._wasUsed},enumerable:!1,configurable:!0}),e.prototype.postExportMaterialAdditionalTexturesAsync=function(e,t,r){return x(this,void 0,void 0,function(){var e,t,n,s;return g(this,function(o){switch(o.label){case 0:return r instanceof f.OpenPBRMaterial?(e=[],r.fuzzWeight>0?(r.fuzzWeightTexture&&e.push(r.fuzzWeightTexture),t=!1,r.fuzzRoughnessTexture&&(r._useFuzzRoughnessFromTextureAlpha?e.push(r.fuzzRoughnessTexture):t=!0),r.fuzzColorTexture&&!t&&e.push(r.fuzzColorTexture),t?(n=function(e){var t=e.fuzzColorTexture,r=t&&t.getInternalTexture()?t.getInternalTexture().uniqueId:"NoFuzzColor",n=e.fuzzRoughnessTexture,s=n&&n.getInternalTexture()?n.getInternalTexture().uniqueId:"NoFuzzRoughness";return"FuzzColor_".concat(r,"_FuzzRoughness_").concat(s)}(r),this._cachedInternalTexturesMap[n]?[3,2]:[4,Xe(r)]):[3,3]):[3,3]):[3,4];case 1:(s=o.sent())&&(this._cachedInternalTexturesMap[n]=s),o.label=2;case 2:this._cachedInternalTexturesMap[n]&&(r.fuzzColorTexture&&(this._mergedTexturesMap[r.fuzzColorTexture.uniqueId]=Ye(this._cachedInternalTexturesMap[n],r.fuzzColorTexture),e.push(this._mergedTexturesMap[r.fuzzColorTexture.uniqueId])),r.fuzzRoughnessTexture&&(this._mergedTexturesMap[r.fuzzRoughnessTexture.uniqueId]=Ye(this._cachedInternalTexturesMap[n],r.fuzzRoughnessTexture),e.push(this._mergedTexturesMap[r.fuzzRoughnessTexture.uniqueId]))),o.label=3;case 3:return[2,e];case 4:return[2,[]]}})})},e.prototype.postExportMaterialAsync=function(e,t,r){return x(this,void 0,void 0,function(){var e=this;return g(this,function(n){switch(n.label){case 0:return[4,new Promise(function(n){var s,o,i;if(r instanceof f.OpenPBRMaterial){if(0==r.fuzzWeight)return void n(t);e._wasUsed=!0,null==t.extensions&&(t.extensions={});var a={fuzzFactor:r.fuzzWeight,fuzzColorFactor:r.fuzzColor.asArray(),fuzzRoughnessFactor:r.fuzzRoughness};r.fuzzWeightTexture&&(a.fuzzTexture=null!==(s=e._exporter._materialExporter.getTextureInfo(r.fuzzWeightTexture))&&void 0!==s?s:void 0);var u=void 0;r.fuzzColorTexture&&(u=e._mergedTexturesMap[r.fuzzColorTexture.uniqueId]?e._mergedTexturesMap[r.fuzzColorTexture.uniqueId]:r.fuzzColorTexture,a.fuzzColorTexture=null!==(o=e._exporter._materialExporter.getTextureInfo(u))&&void 0!==o?o:void 0);var c=void 0;r.fuzzRoughnessTexture&&(c=e._mergedTexturesMap[r.fuzzRoughnessTexture.uniqueId]?e._mergedTexturesMap[r.fuzzRoughnessTexture.uniqueId]:r.fuzzRoughnessTexture,a.fuzzRoughnessTexture=null!==(i=e._exporter._materialExporter.getTextureInfo(c))&&void 0!==i?i:void 0),null===a.fuzzColorTexture&&null===a.fuzzRoughnessTexture||e._exporter._materialNeedsUVsSet.add(r),t.extensions[Qe]=a}n(t)})];case 1:return[2,n.sent()]}})})},e}();se.RegisterExtension(Qe,function(e){return new Ze(e)});var Je="KHR_materials_specular",$e=function(){function e(e){this.name=Je,this.enabled=!0,this.required=!1,this._wasUsed=!1,this._exporter=e}return e.prototype.dispose=function(){},Object.defineProperty(e.prototype,"wasUsed",{get:function(){return this._wasUsed},enumerable:!1,configurable:!0}),e.prototype.postExportMaterialAdditionalTexturesAsync=function(e,t,r){return x(this,void 0,void 0,function(){var e;return g(this,function(t){return e=[],r instanceof f.PBRMaterial&&this._isExtensionEnabled(r)?(r.metallicReflectanceTexture&&e.push(r.metallicReflectanceTexture),r.reflectanceTexture&&e.push(r.reflectanceTexture),[2,e]):[2,e]})})},e.prototype._isExtensionEnabled=function(e){return!e.unlit&&(null!=e.metallicF0Factor&&1!=e.metallicF0Factor||null!=e.metallicReflectanceColor&&!e.metallicReflectanceColor.equalsFloats(1,1,1)||this._hasTexturesExtension(e))},e.prototype._hasTexturesExtension=function(e){return null!=e.metallicReflectanceTexture||null!=e.reflectanceTexture},e.prototype.postExportMaterialAsync=function(e,t,r){var n=this;return new Promise(function(e){var s,o,i,a,u;if(r instanceof f.PBRMaterial&&n._isExtensionEnabled(r)){n._wasUsed=!0,t.extensions=t.extensions||{};var c=null!==(s=n._exporter._materialExporter.getTextureInfo(r.metallicReflectanceTexture))&&void 0!==s?s:void 0,l=null!==(o=n._exporter._materialExporter.getTextureInfo(r.reflectanceTexture))&&void 0!==o?o:void 0,h={specularFactor:1==r.metallicF0Factor?void 0:r.metallicF0Factor,specularTexture:c,specularColorFactor:r.metallicReflectanceColor.equalsFloats(1,1,1)?void 0:r.metallicReflectanceColor.asArray(),specularColorTexture:l};n._hasTexturesExtension(r)&&n._exporter._materialNeedsUVsSet.add(r),t.extensions[Je]=h}else if(r instanceof f.OpenPBRMaterial){t.extensions=t.extensions||{};var p=null!==(i=n._exporter._materialExporter.getTextureInfo(r.specularWeightTexture))&&void 0!==i?i:void 0,d=null!==(a=n._exporter._materialExporter.getTextureInfo(r.specularColorTexture))&&void 0!==a?a:void 0,x=1==r.specularWeight?void 0:r.specularWeight,g=r.specularColor.equalsFloats(1,1,1)?void 0:r.specularColor.asArray();if(!d&&!p&&void 0===x&&void 0===g)return e(t);n._wasUsed=!0,(h={specularFactor:x,specularTexture:p,specularColorFactor:g,specularColorTexture:d,extensions:{}}).extensions.EXT_materials_specular_edge_color={specularEdgeColorEnabled:!0},(u=n._exporter._glTF).extensionsUsed||(u.extensionsUsed=[]),-1===n._exporter._glTF.extensionsUsed.indexOf("EXT_materials_specular_edge_color")&&n._exporter._glTF.extensionsUsed.push("EXT_materials_specular_edge_color"),(p||d)&&n._exporter._materialNeedsUVsSet.add(r),t.extensions[Je]=h}e(t)})},e}();se.RegisterExtension(Je,function(e){return new $e(e)});var et="KHR_materials_transmission",tt=function(){function e(e){this.name=et,this.enabled=!0,this.required=!1,this._wasUsed=!1,this._exporter=e}return e.prototype.dispose=function(){},Object.defineProperty(e.prototype,"wasUsed",{get:function(){return this._wasUsed},enumerable:!1,configurable:!0}),e.prototype.postExportMaterialAdditionalTexturesAsync=function(e,t,r){return x(this,void 0,void 0,function(){var e;return g(this,function(t){if(e=[],r instanceof f.PBRMaterial){if(this._isExtensionEnabled(r))return r.subSurface.refractionIntensityTexture&&r.subSurface.useGltfStyleTextures&&e.push(r.subSurface.refractionIntensityTexture),[2,e]}else r instanceof f.OpenPBRMaterial&&(r.transmissionWeight>0&&r.transmissionWeightTexture&&e.push(r.transmissionWeightTexture),r.subsurfaceWeight>0&&r.subsurfaceWeightTexture&&e.push(r.subsurfaceWeightTexture));return[2,e]})})},e.prototype._isExtensionEnabled=function(e){if(e instanceof f.OpenPBRMaterial&&!e.unlit)return e.transmissionWeight>0||e.subsurfaceWeight>0;if(e instanceof f.PBRMaterial&&!e.unlit){var t=e.subSurface;return t.isRefractionEnabled&&null!=t.refractionIntensity&&0!=t.refractionIntensity||null!=t.refractionIntensityTexture&&t.useGltfStyleTextures}return!1},e.prototype.postExportMaterialAsync=function(e,t,r){return x(this,void 0,void 0,function(){var n,s,o,i,a,u;return g(this,function(c){return this._isExtensionEnabled(r)?(r instanceof f.PBRMaterial?(this._wasUsed=!0,n=r.subSurface,o=0===n.refractionIntensity?void 0:n.refractionIntensity,i={transmissionFactor:o},n.refractionIntensityTexture&&(n.useGltfStyleTextures?(this._exporter._materialNeedsUVsSet.add(r),(a=this._exporter._materialExporter.getTextureInfo(n.refractionIntensityTexture))&&(i.transmissionTexture=a)):f.Logger.Warn("".concat(e,": Exporting a subsurface refraction intensity texture without `useGltfStyleTextures` is not supported"))),t.extensions||(t.extensions={}),t.extensions[et]=i):r instanceof f.OpenPBRMaterial&&(this._wasUsed=!0,s=(1-r.transmissionWeight)*r.subsurfaceWeight,o=s+r.transmissionWeight,i={transmissionFactor:o},r.transmissionWeightTexture?(this._exporter._materialNeedsUVsSet.add(r),(a=this._exporter._materialExporter.getTextureInfo(r.transmissionWeightTexture))&&(i.transmissionTexture=a)):r.subsurfaceWeightTexture&&(this._exporter._materialNeedsUVsSet.add(r),(u=this._exporter._materialExporter.getTextureInfo(r.subsurfaceWeightTexture))&&(i.transmissionTexture=u)),1===o&&t.pbrMetallicRoughness&&(t.pbrMetallicRoughness.baseColorFactor=void 0),t.extensions||(t.extensions={}),t.extensions[et]=i),[2,t]):[2,t]})})},e}();se.RegisterExtension(et,function(e){return new tt(e)});var rt="KHR_materials_unlit",nt=function(){function e(){this.name=rt,this.enabled=!0,this.required=!1,this._wasUsed=!1}return Object.defineProperty(e.prototype,"wasUsed",{get:function(){return this._wasUsed},enumerable:!1,configurable:!0}),e.prototype.dispose=function(){},e.prototype.postExportMaterialAsync=function(e,t,r){var n=this;return new Promise(function(e){var s=!1;r instanceof f.PBRMaterial?s=r.unlit:r instanceof f.StandardMaterial&&(s=r.disableLighting),s&&(n._wasUsed=!0,null==t.extensions&&(t.extensions={}),t.extensions[rt]={}),e(t)})},e}();se.RegisterExtension(rt,function(){return new nt});var st="KHR_materials_volume",ot=function(){function e(e){this.name=st,this.enabled=!0,this.required=!1,this._wasUsed=!1,this._exporter=e}return e.prototype.dispose=function(){},Object.defineProperty(e.prototype,"wasUsed",{get:function(){return this._wasUsed},enumerable:!1,configurable:!0}),e.prototype.postExportMaterialAdditionalTexturesAsync=function(e,t,r){return x(this,void 0,void 0,function(){var e;return g(this,function(t){if(e=[],r instanceof f.PBRMaterial){if(this._isExtensionEnabled(r))return r.subSurface.thicknessTexture&&e.push(r.subSurface.thicknessTexture),[2,e]}else r instanceof f.OpenPBRMaterial&&(r.transmissionWeight>0||r.subsurfaceWeight>0)&&r.geometryThicknessTexture&&e.push(r.geometryThicknessTexture);return[2,e]})})},e.prototype._isExtensionEnabled=function(e){if(e.unlit)return!1;var t=e.subSurface;return!(!t.isRefractionEnabled&&!t.isTranslucencyEnabled)&&(null!=t.maximumThickness&&0!=t.maximumThickness||null!=t.tintColorAtDistance&&t.tintColorAtDistance!=Number.POSITIVE_INFINITY||null!=t.tintColor&&t.tintColor!=f.Color3.White()||this._hasTexturesExtension(e))},e.prototype._hasTexturesExtension=function(e){return null!=e.subSurface.thicknessTexture},e.prototype.postExportMaterialAsync=function(e,t,r){var n=this;return new Promise(function(e){var s,o;if(r instanceof f.PBRMaterial&&n._isExtensionEnabled(r)){n._wasUsed=!0;var i=r.subSurface,a={thicknessFactor:h=0==i.maximumThickness?void 0:i.maximumThickness,thicknessTexture:l=null!==(s=n._exporter._materialExporter.getTextureInfo(i.thicknessTexture))&&void 0!==s?s:void 0,attenuationDistance:i.tintColorAtDistance==Number.POSITIVE_INFINITY?void 0:i.tintColorAtDistance,attenuationColor:S=i.tintColor.equalsFloats(1,1,1)?void 0:i.tintColor.asArray()};n._hasTexturesExtension(r)&&n._exporter._materialNeedsUVsSet.add(r),t.extensions=t.extensions||{},t.extensions[st]=a}else if(r instanceof f.OpenPBRMaterial){var u=r.transmissionWeight>0&&!r.geometryThinWalled&&r.transmissionDepth>0,c=r.subsurfaceWeight>0&&!r.geometryThinWalled;if(u||c){n._wasUsed=!0;var l,h=r.geometryThickness;(l=null!==(o=n._exporter._materialExporter.getTextureInfo(r.geometryThicknessTexture))&&void 0!==o?o:void 0)&&n._exporter._materialNeedsUVsSet.add(r);var p=1,d=f.Color3.White().asArray();if(u){var x=1/r.transmissionDepth,g=new f.Vector3(-Math.log(r.transmissionColor.r)*x,-Math.log(r.transmissionColor.g)*x,-Math.log(r.transmissionColor.b)*x),_=new f.Vector3(r.transmissionScatter.r*x,r.transmissionScatter.g*x,r.transmissionScatter.b*x),m=g.subtract(_),T=Math.min(m.x,m.y,m.z);T<0&&(m.x=m.x-T,m.y=m.y-T,m.z=m.z-T),g=m.add(_),p=1/Math.max(g.x,g.y,g.z),d[0]=Math.exp(-g.x*p),d[1]=Math.exp(-g.y*p),d[2]=Math.exp(-g.z*p)}var y=1,v=f.Color3.White().asArray();if(c){var b=r.subsurfaceRadius,w=r.subsurfaceRadiusScale,M=new f.Vector3(w.r,w.g,w.b).multiplyByFloats(b,b,b),A=new f.Vector3(1/Math.max(M.x,1e-6),1/Math.max(M.y,1e-6),1/Math.max(M.z,1e-6));y=1/Math.max(A.x,A.y,A.z),v[0]=Math.exp(-A.x*y),v[1]=Math.exp(-A.y*y),v[2]=Math.exp(-A.z*y)}var R=(1-r.transmissionWeight)*r.subsurfaceWeight,E=R+r.transmissionWeight,C=1/Math.max(E,1e-6),I=r.transmissionWeight*C,V=R*C,S=d.map(function(e,t){return e*I+v[t]*V});a={thicknessFactor:h,thicknessTexture:l,attenuationDistance:p*I+y*V,attenuationColor:S},t.extensions=t.extensions||{},t.extensions[st]=a}}e(t)})},e}();se.RegisterExtension(st,function(e){return new ot(e)});var it="KHR_materials_volume_scatter",at=function(){function e(e){this.name=it,this.enabled=!0,this.required=!1,this._wasUsed=!1,this._exporter=e}return e.prototype.dispose=function(){},Object.defineProperty(e.prototype,"wasUsed",{get:function(){return this._wasUsed},enumerable:!1,configurable:!0}),e.prototype.postExportMaterialAdditionalTexturesAsync=function(e,t,r){return x(this,void 0,void 0,function(){var e;return g(this,function(t){return e=[],r instanceof f.OpenPBRMaterial&&(r.transmissionWeight>0&&r.transmissionScatterTexture&&e.push(r.transmissionScatterTexture),r.subsurfaceWeight>0&&r.subsurfaceColorTexture&&e.push(r.subsurfaceColorTexture)),[2,e]})})},e.prototype._isExtensionEnabled=function(e){if(e.unlit)return!1;var t=e.transmissionWeight>0&&!e.geometryThinWalled&&e.transmissionDepth>0&&!e.transmissionScatter.equals(f.Color3.Black()),r=e.subsurfaceWeight>0&&!e.geometryThinWalled;return!(!t&&!r)},e.prototype.postExportMaterialAsync=function(e,t,r){var n=this;return new Promise(function(e){if(r instanceof f.OpenPBRMaterial&&n._isExtensionEnabled(r)){n._wasUsed=!0;var s=f.Vector3.Zero(),o=0;if(r.transmissionWeight>0){var i=1/r.transmissionDepth,a=new f.Vector3(-Math.log(r.transmissionColor.r)*i,-Math.log(r.transmissionColor.g)*i,-Math.log(r.transmissionColor.b)*i),u=new f.Vector3(r.transmissionScatter.r*i,r.transmissionScatter.g*i,r.transmissionScatter.b*i),c=a.subtract(u),l=Math.min(c.x,c.y,c.z);l<0&&(c.x=c.x-l,c.y=c.y-l,c.z=c.z-l),a=c.add(u),b=new f.Vector3(u.x/Math.max(a.x,1e-6),u.y/Math.max(a.y,1e-6),u.z/Math.max(a.z,1e-6)),w=new f.Vector3(Math.sqrt(1-b.x),Math.sqrt(1-b.y),Math.sqrt(1-b.z)),A=(M=new f.Vector3(1,1,1)).subtract(w),R=M.subtract(new f.Vector3(.139,.139,.139).multiplyInPlace(w)),E=M.add(new f.Vector3(1.17,1.17,1.17).multiplyInPlace(w)),s=A.multiplyInPlace(R).divideInPlace(E),o=r.transmissionScatterAnisotropy}var h=f.Vector3.Zero(),p=0;r.subsurfaceWeight>0&&(h.set(r.subsurfaceColor.r,r.subsurfaceColor.g,r.subsurfaceColor.b),p=r.subsurfaceScatterAnisotropy);var d=(1-r.transmissionWeight)*r.subsurfaceWeight,x=d+r.transmissionWeight,g=1/Math.max(x,1e-6),_=r.transmissionWeight*g,m=d*g,T={multiscatterColorFactor:s.multiplyByFloats(_,_,_).addInPlace(h.multiplyByFloats(m,m,m)).asArray(),scatterAnisotropy:o*_+p*m};if(r.subsurfaceWeight>0&&r.subsurfaceColorTexture){n._exporter._materialNeedsUVsSet.add(r);var y=n._exporter._materialExporter.getTextureInfo(r.subsurfaceColorTexture);y&&(T.multiscatterColorTexture=y)}else if(r.transmissionWeight>0&&r.transmissionScatterTexture){n._exporter._materialNeedsUVsSet.add(r);var v=n._exporter._materialExporter.getTextureInfo(r.transmissionScatterTexture);v&&(T.multiscatterColorTexture=v)}t.extensions=t.extensions||{},t.extensions[it]=T}var b,w,M,A,R,E;e(t)})},e}();se.RegisterExtension(it,function(e){return new at(e)},101);var ut="KHR_materials_diffuse_roughness",ct=function(){function e(e){this.name=ut,this.enabled=!0,this.required=!1,this._wasUsed=!1,this._exporter=e}return e.prototype.dispose=function(){},Object.defineProperty(e.prototype,"wasUsed",{get:function(){return this._wasUsed},enumerable:!1,configurable:!0}),e.prototype.postExportMaterialAdditionalTexturesAsync=function(e,t,r){return x(this,void 0,void 0,function(){var e;return g(this,function(t){if(e=[],r instanceof f.PBRBaseMaterial){if(r._baseDiffuseRoughness)return r._baseDiffuseRoughnessTexture&&e.push(r._baseDiffuseRoughnessTexture),[2,e]}else if(r instanceof f.OpenPBRMaterial&&r.baseDiffuseRoughness)return r.baseDiffuseRoughnessTexture&&e.push(r.baseDiffuseRoughnessTexture),[2,e];return[2,[]]})})},e.prototype.postExportMaterialAsync=function(e,t,r){var n=this;return new Promise(function(e){var s=null,o=null;if(r instanceof f.PBRBaseMaterial?(s=r._baseDiffuseRoughness,o=r._baseDiffuseRoughnessTexture):r instanceof f.OpenPBRMaterial&&(s=r.baseDiffuseRoughness,o=r.baseDiffuseRoughnessTexture),s){n._wasUsed=!0,t.extensions=t.extensions||{};var i=n._exporter._materialExporter.getTextureInfo(o),a={diffuseRoughnessFactor:s,diffuseRoughnessTexture:null!=i?i:void 0};null!==a.diffuseRoughnessTexture&&n._exporter._materialNeedsUVsSet.add(r),t.extensions[ut]=a,e(t)}else e(t)})},e}();se.RegisterExtension(ut,function(e){return new ct(e)});var lt="KHR_materials_openpbr",ht=function(){function e(){this.name=lt,this.enabled=!0,this.required=!1,this._wasUsed=!1}return e.prototype.dispose=function(){},Object.defineProperty(e.prototype,"wasUsed",{get:function(){return this._wasUsed},enumerable:!1,configurable:!0}),e.prototype.postExportMaterialAsync=function(e,t,r){var n=this;return new Promise(function(e){r instanceof f.OpenPBRMaterial&&(n._wasUsed=!0,t.extensions=t.extensions||{},t.extensions[lt]={}),e(t)})},e}();se.RegisterExtension(lt,function(e){return new ht});var ft="KHR_texture_transform",pt=function(){function e(){this.name=ft,this.enabled=!0,this.required=!1,this._wasUsed=!1}return e.prototype.dispose=function(){},Object.defineProperty(e.prototype,"wasUsed",{get:function(){return this._wasUsed},enumerable:!1,configurable:!0}),e.prototype.postExportTexture=function(e,t,r){if(r.getScene()||f.Tools.Warn("".concat(e,': "scene" is not defined for Babylon texture ').concat(r.name,"!")),0===r.uAng&&0===r.vAng||(f.Tools.Warn("".concat(e,": Texture ").concat(r.name," with rotation in the u or v axis is not supported in glTF.")),0===r.uRotationCenter&&0===r.vRotationCenter)){var n={},s=!1;if(0===r.uOffset&&0===r.vOffset||(n.offset=[r.uOffset,r.vOffset],s=!0),1===r.uScale&&1===r.vScale||(n.scale=[r.uScale,r.vScale],s=!0),0!==r.wAng){if(0!==r.uRotationCenter||0!==r.vRotationCenter){if(r.homogeneousRotationInUVTransform&&r.uScale!==r.vScale)return void f.Tools.Warn("".concat(e,": Texture ").concat(r.name," with homogenousRotationInUVTransform, non-uniform scaling, and non-zero rotation cannot be exported with ").concat(ft,"."));f.Tools.Warn("".concat(e,": Texture ").concat(r.name," with non-origin rotation center will be exported using an adjusted offset with ").concat(ft,".")),n.offset=function(e){var t=e.uOffset,r=e.vOffset,n=e.uRotationCenter,s=e.vRotationCenter,o=e.uScale,i=e.vScale,a=e.wAng,u=Math.cos(a),c=Math.sin(a),l=n*o,h=s*i;return[t+(l*(1-u)+h*c),r+(h*(1-u)-l*c)]}(r)}n.rotation=-r.wAng,s=!0}0!==r.coordinatesIndex&&(n.texCoord=r.coordinatesIndex,s=!0),s&&(this._wasUsed=!0,t.extensions||(t.extensions={}),t.extensions[ft]=n)}},e}();se.RegisterExtension(ft,function(){return new pt});var dt="KHR_texture_basisu",xt=function(){function e(e){this.name=dt,this.enabled=!0,this.required=!0,this._wasUsed=!1,this._exporter=e}return Object.defineProperty(e.prototype,"wasUsed",{get:function(){return this._wasUsed},enumerable:!1,configurable:!0}),e.prototype.dispose=function(){},e.prototype.postExportTexture=function(e,t){var r=this._exporter._textures[t.index],n=r.source;if(void 0!==n){var s=this._exporter._images[n];"image/ktx2"===(s.mimeType||(0,f.GetMimeType)(s.uri))&&(r.source=void 0,r.extensions||(r.extensions={}),r.extensions[dt]={source:n},this._wasUsed=!0)}},e}();se.RegisterExtension(dt,function(e){return new xt(e)});var gt="EXT_texture_webp",_t=function(){function e(e){this.name=gt,this.enabled=!0,this.required=!0,this._wasUsed=!1,this._exporter=e}return Object.defineProperty(e.prototype,"wasUsed",{get:function(){return this._wasUsed},enumerable:!1,configurable:!0}),e.prototype.dispose=function(){},e.prototype.postExportTexture=function(e,t){var r=this._exporter._textures[t.index],n=r.source;if(void 0!==n){var s=this._exporter._images[n];"image/webp"===(s.mimeType||(0,f.GetMimeType)(s.uri))&&(r.source=void 0,r.extensions||(r.extensions={}),r.extensions[gt]={source:n},this._wasUsed=!0)}},e}();se.RegisterExtension(gt,function(e){return new _t(e)});var mt="EXT_texture_avif",Tt=function(){function e(e){this.name=mt,this.enabled=!0,this.required=!0,this._wasUsed=!1,this._exporter=e}return Object.defineProperty(e.prototype,"wasUsed",{get:function(){return this._wasUsed},enumerable:!1,configurable:!0}),e.prototype.dispose=function(){},e.prototype.postExportTexture=function(e,t){var r=this._exporter._textures[t.index],n=r.source;if(void 0!==n){var s=this._exporter._images[n];"image/avif"===(s.mimeType||(0,f.GetMimeType)(s.uri))&&(r.source=void 0,r.extensions||(r.extensions={}),r.extensions[mt]={source:n},this._wasUsed=!0)}},e}();se.RegisterExtension(mt,function(e){return new Tt(e)});var yt=void 0!==n.g?n.g:"undefined"!=typeof window?window:void 0;if(void 0!==yt){yt.BABYLON=yt.BABYLON||{};var vt=yt.BABYLON;vt.GLTF2=vt.GLTF2||{},vt.GLTF2.Exporter=vt.GLTF2.Exporter||{},vt.GLTF2.Exporter.Extensions=vt.GLTF2.Exporter.Extensions||{};var bt=[];for(var wt in o)vt[wt]=o[wt],bt.push(wt);for(var wt in i)vt[wt]=i[wt],bt.push(wt);for(var wt in a)vt[wt]=a[wt],bt.push(wt);for(var wt in u)vt.GLTF2.Exporter.Extensions[wt]=u[wt],bt.push(wt);for(var wt in c)bt.indexOf(wt)>-1||(vt.GLTF2.Exporter[wt]=c[wt])}const Mt=l;return s.default})());
2
- //# sourceMappingURL=babylon.glTF2Serializer.min.js.map
@@ -1,2 +0,0 @@
1
- !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("babylonjs")):"function"==typeof define&&define.amd?define("babylonjs-serializers",["babylonjs"],t):"object"==typeof exports?exports["babylonjs-serializers"]=t(require("babylonjs")):e.SERIALIZERS=t(e.BABYLON)}("undefined"!=typeof self?self:"undefined"!=typeof global?global:this,e=>(()=>{"use strict";var t={597(t){t.exports=e}},r={};function o(e){var i=r[e];if(void 0!==i)return i.exports;var n=r[e]={exports:{}};return t[e](n,n.exports,o),n.exports}o.d=(e,t)=>{for(var r in t)o.o(t,r)&&!o.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},o.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),o.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),o.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var i={};o.d(i,{default:()=>f});var n={};o.r(n),o.d(n,{OBJExport:()=>u});var a={};o.r(a),o.d(a,{OBJExport:()=>u});var s=o(597),u=function(){function e(){}return e.OBJ=function(e,t,r,o){var i=[],n=1,a=1;t&&(r||(r="mat"),i.push("mtllib "+r+".mtl"));for(var u=0;u<e.length;u++){var l=e[u],p=l.name||"mesh".concat(u,"}");i.push("o ".concat(p));var f=null;if(o){var d=l.computeWorldMatrix(!0);f=new s.Matrix,d.invertToRef(f),l.bakeTransformIntoVertices(d)}if(t){var m=l.material;m&&i.push("usemtl "+m.id)}var c=l.geometry;if(c){var h=c.getVerticesData("position"),b=c.getVerticesData("normal"),g=c.getVerticesData("uv"),v=c.getIndices(),x=0,y=0;if(h&&v){for(var T=e[0].getScene().useRightHandedSystem?1:-1,S=0;S<h.length;S+=3)i.push("v "+h[S]*T+" "+h[S+1]+" "+h[S+2]),x++;if(null!=b)for(S=0;S<b.length;S+=3)i.push("vn "+b[S]*T+" "+b[S+1]+" "+b[S+2]);if(null!=g)for(S=0;S<g.length;S+=2)i.push("vt "+g[S]+" "+g[S+1]),y++;var j=["","",""],F=(l.material||l.getScene().defaultMaterial)._getEffectiveOrientation(l)===s.Material.ClockWiseSideOrientation?[2,1]:[1,2],w=F[0],C=F[1];for(S=0;S<v.length;S+=3){var O=[String(v[S]+n),String(v[S+w]+n),String(v[S+C]+n)],_=[String(v[S]+a),String(v[S+w]+a),String(v[S+C]+a)],B=O,K=null!=g?_:j,M=null!=b?O:j;i.push("f "+B[0]+"/"+K[0]+"/"+M[0]+" "+B[1]+"/"+K[1]+"/"+M[1]+" "+B[2]+"/"+K[2]+"/"+M[2])}o&&f&&l.bakeTransformIntoVertices(f),n+=x,a+=y}else s.Tools.Warn("There are no position vertices or indices on the mesh!")}else s.Tools.Warn("No geometry is present on the mesh")}return i.join("\n")},e.MTL=function(e){var t=[],r=e.material;return t.push("newmtl mat1"),t.push(" Ns "+r.specularPower.toFixed(4)),t.push(" Ni 1.5000"),t.push(" d "+r.alpha.toFixed(4)),t.push(" Tr 0.0000"),t.push(" Tf 1.0000 1.0000 1.0000"),t.push(" illum 2"),t.push(" Ka "+r.ambientColor.r.toFixed(4)+" "+r.ambientColor.g.toFixed(4)+" "+r.ambientColor.b.toFixed(4)),t.push(" Kd "+r.diffuseColor.r.toFixed(4)+" "+r.diffuseColor.g.toFixed(4)+" "+r.diffuseColor.b.toFixed(4)),t.push(" Ks "+r.specularColor.r.toFixed(4)+" "+r.specularColor.g.toFixed(4)+" "+r.specularColor.b.toFixed(4)),t.push(" Ke "+r.emissiveColor.r.toFixed(4)+" "+r.emissiveColor.g.toFixed(4)+" "+r.emissiveColor.b.toFixed(4)),r.ambientTexture&&t.push(" map_Ka "+r.ambientTexture.name),r.diffuseTexture&&t.push(" map_Kd "+r.diffuseTexture.name),r.specularTexture&&t.push(" map_Ks "+r.specularTexture.name),r.bumpTexture&&t.push(" map_bump -imfchan z "+r.bumpTexture.name),r.opacityTexture&&t.push(" map_d "+r.opacityTexture.name),t.join("\n")},e}(),l=void 0!==o.g?o.g:"undefined"!=typeof window?window:void 0;if(void 0!==l)for(var p in n)l.BABYLON[p]=n[p];const f=a;return i.default})());
2
- //# sourceMappingURL=babylon.objSerializer.min.js.map
@@ -1,2 +0,0 @@
1
- !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("babylonjs")):"function"==typeof define&&define.amd?define("babylonjs-serializers",["babylonjs"],t):"object"==typeof exports?exports["babylonjs-serializers"]=t(require("babylonjs")):e.SERIALIZERS=t(e.BABYLON)}("undefined"!=typeof self?self:"undefined"!=typeof global?global:this,e=>(()=>{"use strict";var t={597(t){t.exports=e}},r={};function o(e){var n=r[e];if(void 0!==n)return n.exports;var i=r[e]={exports:{}};return t[e](i,i.exports,o),i.exports}o.d=(e,t)=>{for(var r in t)o.o(t,r)&&!o.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},o.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),o.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),o.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var n={};o.d(n,{default:()=>c});var i={};o.r(i),o.d(i,{STLExport:()=>f});var a={};o.r(a),o.d(a,{STLExport:()=>f});var s=o(597),f=function(){function e(){}return e.CreateSTL=function(e,t,r,o,n,i,a,f){void 0===t&&(t=!0),void 0===r&&(r="stlmesh"),void 0===o&&(o=!1),void 0===n&&(n=!0),void 0===i&&(i=!1),void 0===a&&(a=!1),void 0===f&&(f=!1);var d=function(e,t,r){var o=[3*e[r],3*e[r+1],3*e[r+2]],n=[new s.Vector3(t[o[0]],t[o[0]+2],t[o[0]+1]),new s.Vector3(t[o[1]],t[o[1]+2],t[o[1]+1]),new s.Vector3(t[o[2]],t[o[2]+2],t[o[2]+1])],i=n[0].subtract(n[1]),a=n[2].subtract(n[1]);return{v:n,n:s.Vector3.Cross(a,i).normalize()}},l=function(e,t,r,o){return t=c(e,t,r.x,o),t=c(e,t,r.y,o),c(e,t,r.z,o)},c=function(e,t,r,o){return e.setFloat32(t,r,o),t+4},u=function(e){if(a){var t=e;e instanceof s.InstancedMesh&&(t=e.sourceMesh);var r=t.getVerticesData(s.VertexBuffer.PositionKind,!0,!0);if(!r)return[];var o=s.Vector3.Zero(),n=void 0;for(n=0;n<r.length;n+=3)s.Vector3.TransformCoordinatesFromFloatsToRef(r[n],r[n+1],r[n+2],e.computeWorldMatrix(!0),o).toArray(r,n);return r}return e.getVerticesData(s.VertexBuffer.PositionKind)||[]};a&&(i=!0);var v="",p=0,b=0;if(o){for(var y=0;y<e.length;y++)p+=(w=(g=e[y]).getIndices())?w.length/3:0;var x=new ArrayBuffer(84+50*p);b+=80,(v=new DataView(x)).setUint32(b,p,n),b+=4}else f||(v="solid stlmesh\r\n");for(y=0;y<e.length;y++){var g=e[y];!o&&f&&(v+="solid "+g.name+"\r\n"),!i&&g instanceof s.Mesh&&g.bakeCurrentTransformIntoVertices();for(var m=u(g),w=g.getIndices()||[],h=0;h<w.length;h+=3){var j=d(w,m,h);o?(b=l(v,b,j.n,n),b=l(v,b,j.v[0],n),b=l(v,b,j.v[1],n),b=l(v,b,j.v[2],n),b+=2):(v+="\tfacet normal "+j.n.x+" "+j.n.y+" "+j.n.z+"\r\n",v+="\t\touter loop\r\n",v+="\t\t\tvertex "+j.v[0].x+" "+j.v[0].y+" "+j.v[0].z+"\r\n",v+="\t\t\tvertex "+j.v[1].x+" "+j.v[1].y+" "+j.v[1].z+"\r\n",v+="\t\t\tvertex "+j.v[2].x+" "+j.v[2].y+" "+j.v[2].z+"\r\n",v+="\t\tendloop\r\n",v+="\tendfacet\r\n")}!o&&f&&(v+="endsolid "+name+"\r\n")}if(o||f||(v+="endsolid stlmesh"),t){var V=document.createElement("a"),S=new Blob([v],{type:"application/octet-stream"});V.href=window.URL.createObjectURL(S),V.download=r+".stl",V.click()}return v},e}(),d=void 0!==o.g?o.g:"undefined"!=typeof window?window:void 0;if(void 0!==d)for(var l in i)d.BABYLON[l]=i[l];const c=a;return n.default})());
2
- //# sourceMappingURL=babylon.stlSerializer.min.js.map
@@ -1,2 +0,0 @@
1
- !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("babylonjs")):"function"==typeof define&&define.amd?define("babylonjs-serializers",["babylonjs"],e):"object"==typeof exports?exports["babylonjs-serializers"]=e(require("babylonjs")):t.SERIALIZERS=e(t.BABYLON)}("undefined"!=typeof self?self:"undefined"!=typeof global?global:this,t=>(()=>{"use strict";var e={597(e){e.exports=t}},n={};function r(t){var i=n[t];if(void 0!==i)return i.exports;var o=n[t]={exports:{}};return e[t](o,o.exports,r),o.exports}r.d=(t,e)=>{for(var n in e)r.o(e,n)&&!r.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},r.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),r.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var i={};r.d(i,{default:()=>zt});var o={};r.r(o),r.d(o,{AbstractThreeMfSerializer:()=>Dt,ContentTypeFileName:()=>tt,DefaultXmlSerializerFormatOptions:()=>N,DefaultXmlSerializerNumberOptions:()=>C,GetXmlFieldMeta:()=>T,GetXmlName:()=>M,IsQualifiedName:()=>m,Known3mfRelationshipTypes:()=>et,KnownI3mfContentType:()=>V,Matrix3d:()=>st,MatrixFormatter:()=>ut,ModelFileName:()=>J,NumberFormatter:()=>D,Object3dDirName:()=>H,OpenXmlContentTypesNamespace:()=>W,OpenXmlRelationshipsNamespace:()=>q,RelationshipDirName:()=>$,RelationshipFileName:()=>Y,ResolveFormatOptions:()=>k,ResolveNumberOptions:()=>O,ST_ObjectType:()=>Z,ST_Unit:()=>z,StringXmlWriter:()=>L,ThreeDimModelNamespace:()=>G,ThreeMf:()=>At,ThreeMfBase:()=>Tt,ThreeMfBaseMaterials:()=>wt,ThreeMfBuild:()=>Mt,ThreeMfComponent:()=>bt,ThreeMfComponents:()=>gt,ThreeMfComponentsBuilder:()=>jt,ThreeMfContentType:()=>rt,ThreeMfContentTypes:()=>nt,ThreeMfDocument:()=>at,ThreeMfDocumentBuilder:()=>kt,ThreeMfItem:()=>xt,ThreeMfMaterialBuilder:()=>Nt,ThreeMfMesh:()=>mt,ThreeMfMeshBuilder:()=>Ct,ThreeMfMeta:()=>ct,ThreeMfMetadataGroup:()=>pt,ThreeMfModel:()=>lt,ThreeMfModelBuilder:()=>Ot,ThreeMfObject:()=>ft,ThreeMfObjectBuilder:()=>St,ThreeMfRelationship:()=>ot,ThreeMfRelationships:()=>it,ThreeMfResources:()=>ht,ThreeMfSerializer:()=>Bt,ThreeMfSerializerGlobalConfiguration:()=>Rt,ThreeMfTriangle:()=>_t,ThreeMfTriangles:()=>yt,ThreeMfVertex:()=>vt,ThreeMfVertices:()=>dt,ToQualifiedString:()=>j,TokenType:()=>E,TriangleSetsNamespace:()=>Q,Utf8XmlWriterToBytes:()=>U,XmlAttr:()=>b,XmlBuilder:()=>K,XmlElem:()=>w,XmlIgnore:()=>g,XmlName:()=>_,XmlNameToParts:()=>S,XmlSerializer:()=>I});var a={};r.r(a),r.d(a,{AbstractThreeMfSerializer:()=>Dt,ContentTypeFileName:()=>tt,DefaultXmlSerializerFormatOptions:()=>N,DefaultXmlSerializerNumberOptions:()=>C,GetXmlFieldMeta:()=>T,GetXmlName:()=>M,IsQualifiedName:()=>m,Known3mfRelationshipTypes:()=>et,KnownI3mfContentType:()=>V,Matrix3d:()=>st,MatrixFormatter:()=>ut,ModelFileName:()=>J,NumberFormatter:()=>D,Object3dDirName:()=>H,OpenXmlContentTypesNamespace:()=>W,OpenXmlRelationshipsNamespace:()=>q,RelationshipDirName:()=>$,RelationshipFileName:()=>Y,ResolveFormatOptions:()=>k,ResolveNumberOptions:()=>O,ST_ObjectType:()=>Z,ST_Unit:()=>z,StringXmlWriter:()=>L,ThreeDimModelNamespace:()=>G,ThreeMf:()=>At,ThreeMfBase:()=>Tt,ThreeMfBaseMaterials:()=>wt,ThreeMfBuild:()=>Mt,ThreeMfComponent:()=>bt,ThreeMfComponents:()=>gt,ThreeMfComponentsBuilder:()=>jt,ThreeMfContentType:()=>rt,ThreeMfContentTypes:()=>nt,ThreeMfDocument:()=>at,ThreeMfDocumentBuilder:()=>kt,ThreeMfItem:()=>xt,ThreeMfMaterialBuilder:()=>Nt,ThreeMfMesh:()=>mt,ThreeMfMeshBuilder:()=>Ct,ThreeMfMeta:()=>ct,ThreeMfMetadataGroup:()=>pt,ThreeMfModel:()=>lt,ThreeMfModelBuilder:()=>Ot,ThreeMfObject:()=>ft,ThreeMfObjectBuilder:()=>St,ThreeMfRelationship:()=>ot,ThreeMfRelationships:()=>it,ThreeMfResources:()=>ht,ThreeMfSerializer:()=>Bt,ThreeMfSerializerGlobalConfiguration:()=>Rt,ThreeMfTriangle:()=>_t,ThreeMfTriangles:()=>yt,ThreeMfVertex:()=>vt,ThreeMfVertices:()=>dt,ToQualifiedString:()=>j,TokenType:()=>E,TriangleSetsNamespace:()=>Q,Utf8XmlWriterToBytes:()=>U,XmlAttr:()=>b,XmlBuilder:()=>K,XmlElem:()=>w,XmlIgnore:()=>g,XmlName:()=>_,XmlNameToParts:()=>S,XmlSerializer:()=>I});var s=function(t,e){return s=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},s(t,e)};function u(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=t}s(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}var l=function(){return l=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},l.apply(this,arguments)};function c(t,e,n,r){var i,o=arguments.length,a=o<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,e,n,r);else for(var s=t.length-1;s>=0;s--)(i=t[s])&&(a=(o<3?i(a):o>3?i(e,n,a):i(e,n))||a);return o>3&&a&&Object.defineProperty(e,n,a),a}function p(t,e,n,r){return new(n||(n=Promise))(function(i,o){function a(t){try{u(r.next(t))}catch(t){o(t)}}function s(t){try{u(r.throw(t))}catch(t){o(t)}}function u(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(a,s)}u((r=r.apply(t,e||[])).next())})}function h(t,e){var n,r,i,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=s(0),a.throw=s(1),a.return=s(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function s(s){return function(u){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,s[0]&&(o=0)),o;)try{if(n=1,r&&(i=2&s[0]?r.return:s[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,s[1])).done)return i;switch(r=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return o.label++,{value:s[1],done:!1};case 5:o.label++,r=s[1],s=[0];continue;case 7:s=o.ops.pop(),o.trys.pop();continue;default:if(!((i=(i=o.trys).length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){o=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){o.label=s[1];break}if(6===s[0]&&o.label<i[1]){o.label=i[1],i=s;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(s);break}i[2]&&o.ops.pop(),o.trys.pop();continue}s=e.call(t,o)}catch(t){s=[6,t],r=0}finally{n=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,u])}}}function f(t,e,n){if(n||2===arguments.length)for(var r,i=0,o=e.length;i<o;i++)!r&&i in e||(r||(r=Array.prototype.slice.call(e,0,i)),r[i]=e[i]);return t.concat(r||Array.prototype.slice.call(e))}function m(t){return"string"==typeof(null==t?void 0:t.name)}Object.create,Object.create,"function"==typeof SuppressedError&&SuppressedError;var d=Symbol("__xml:meta$__"),v=Symbol("__xml:name$__");function y(t,e){var n,r=t.constructor;(null!==(n=r[d])&&void 0!==n?n:r[d]=[]).push(e)}function _(t){return function(e){e[v]=t}}function g(){return function(t,e){return y(t,{kind:"none",prop:e,ignore:!0})}}function b(t){return function(e,n){return y(e,l({kind:"attr",prop:n},t))}}function w(t){return function(e,n){return y(e,l({kind:"elem",prop:n},t))}}function T(t){var e,n;return null!==(n=null===(e=null==t?void 0:t.constructor)||void 0===e?void 0:e[d])&&void 0!==n?n:[]}function M(t){var e;return(null===(e=null==t?void 0:t.constructor)||void 0===e?void 0:e[v])||void 0}function x(t){return/^[A-Za-z_][A-Za-z0-9._-]*$/.test(t)}function S(t){if(m(t))return t;var e=(null!=t?t:"").trim();if(!e)return{name:""};var n=e.indexOf(":");if(-1===n)return{name:e};if(-1!==e.indexOf(":",n+1))return{name:e};var r=e.slice(0,n),i=e.slice(n+1);return x(r)&&x(i)?{ns:r,name:i}:{name:e}}function j(t,e){return e?"".concat(e,":").concat(t):t}var C=Object.freeze({eps:1e-6,maxDecimalsCap:15,trimTrailingZeros:!0,allowScientific:!1,snapNearZero:!0}),N=Object.freeze({number:C});function O(t){var e,n,r,i,o,a,s=null!==(e=null==t?void 0:t.eps)&&void 0!==e?e:C.eps;return{eps:s,maxDecimalsCap:null!==(n=null==t?void 0:t.maxDecimalsCap)&&void 0!==n?n:C.maxDecimalsCap,trimTrailingZeros:null!==(r=null==t?void 0:t.trimTrailingZeros)&&void 0!==r?r:C.trimTrailingZeros,fixedDecimals:null==t?void 0:t.fixedDecimals,allowScientific:null!==(i=null==t?void 0:t.allowScientific)&&void 0!==i?i:C.allowScientific,snapNearZero:null!==(o=null==t?void 0:t.snapNearZero)&&void 0!==o?o:C.snapNearZero,zeroThreshold:null!==(a=null==t?void 0:t.zeroThreshold)&&void 0!==a?a:s,perAttributeEps:null==t?void 0:t.perAttributeEps}}function k(t){return{number:O(null==t?void 0:t.number)}}var D=function(){function t(t){if(this.o=t,this._o=t.number,!Number.isFinite(this._o.eps)||this._o.eps<=0)throw new Error("opts.eps must be a finite, positive number")}return t.prototype.toString=function(t){var e,n,r,i;if(!Number.isFinite(t))throw new Error("Cannot format non-finite number: ".concat(t));var o,a=this._o,s=this._clampInt(null!==(e=a.maxDecimalsCap)&&void 0!==e?e:15,0,20),u=null===(n=a.trimTrailingZeros)||void 0===n||n,l=null===(r=a.snapNearZero)||void 0===r||r,c=null!==(i=a.zeroThreshold)&&void 0!==i?i:a.eps,p=1/a.eps,h=Math.round(t*p)/p;if(Object.is(h,-0)&&(h=0),l&&Math.abs(h)<=c&&(h=0),o=void 0!==a.fixedDecimals?this._clampInt(a.fixedDecimals,0,s):this._clampInt(Math.ceil(-Math.log10(a.eps)),0,s),a.allowScientific,0===o)return String(Math.trunc(h));var f=h.toFixed(o);if(u&&void 0===a.fixedDecimals&&(f=f.replace(/(\.\d*?[1-9])0+$/,"$1").replace(/\.0+$/,"").replace(/\.$/,"")),/[eE]/.test(f))throw new Error("Scientific notation not allowed in XML output: ".concat(f));return f},t.prototype._clampInt=function(t,e,n){return Number.isFinite(t)?(t=Math.trunc(t),Math.max(e,Math.min(n,t))):e},t}();function A(t){return t instanceof Date}function X(t){return"string"==typeof t}function R(t){return"number"==typeof t}function P(t){return"string"==typeof t||"number"==typeof t||"boolean"==typeof t||"bigint"==typeof t||A(t)}function B(t){return"number"==typeof t||"boolean"==typeof t||"bigint"==typeof t||A(t)}var E,I=function(){function t(t,e){this._ns=new Map,this._prefixCount=0,this._builder=t,this._format=k(e),this._nFmt=new D(this._format)}return t.prototype.withNamespace=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];for(var n=0,r=t;n<r.length;n++){var i=r[n];this._assignNamespace(i)}return this},t.prototype.serialize=function(t,e){if(!(e=null!=e?e:M(t)))throw new Error("can not find name for given object");var n=S(e);n.ns&&this._assignNamespace(n.ns,"xmlns"),this._gatherNamespaces(t,new WeakSet);for(var r=this._builder.ele(null,n.name),i=0,o=Array.from(this._ns.entries());i<o.length;i++){var a=o[i],s=a[0],u=a[1];r.att("xmlns",u,s)}this._writeObjectContent(r,t,(new WeakSet).add(t)),this._builder.end()},t.prototype._writeObject=function(t,e,n){if(!n.has(e))if(n.add(e),Array.isArray(e))for(var r=0,i=e;r<i.length;r++){var o=i[r];B(o)||(X(o)?this._builder.text(o):this._writeObject(t,o,n))}else{var a=M(e);if(a){var s=S(a),u=this._getPrefix(s),l=j(s.name,u);t.ele(null,l),this._writeObjectContent(t,e,n),this._builder.end()}}},t.prototype._getPrefix=function(t){if(t.ns){var e=this._ns.get(t.ns.toLowerCase());if("xmlns"!==e)return e}},t.prototype._writeObjectContent=function(t,e,n){for(var r,i,o,a=null!==(r=T(e))&&void 0!==r?r:[],s=new Map,u=0,l=a;u<l.length;u++){var c=l[u],p=null!==(i=s.get(c.prop))&&void 0!==i?i:[];p.push(c),s.set(c.prop,p)}for(var h=Object.keys(e).sort(function(t,e){var n,r,i=(null!==(n=s.get(t))&&void 0!==n?n:[]).some(function(t){return"attr"===t.kind}),o=(null!==(r=s.get(e))&&void 0!==r?r:[]).some(function(t){return"attr"===t.kind});return i===o?0:i?-1:1}),f=0,m=h;f<m.length;f++){var d=m[f],v=e[d];if(null!=v){var y=s.get(d);if(y){var _=y.some(function(t){return!0===t.ignore||"none"===t.kind});if(_)continue;for(var g=0,b=y;g<b.length;g++){var w=null!==(o=(c=b[g]).name)&&void 0!==o?o:c.prop.toLowerCase();if(w&&"attr"===c.kind){var M=null;if(R(v)&&this._nFmt&&(M=this._nFmt.toString(v)),c.formatter&&(M=new c.formatter(this._format).toString(v)),M=null!=M?M:v.toString()){var x=S(w),C=this._getPrefix(x),N=j(x.name,C);t.att(null,N,M)}}}}else B(v)||(X(v)?this._builder.text(v):this._writeObject(t,v,n))}}},t.prototype._gatherNamespaces=function(t,e){var n,r;if(!e.has(t))if(e.add(t),Array.isArray(t))for(var i=0,o=t;i<o.length;i++){var a=o[i];P(a)||this._gatherNamespaces(a,e)}else{var s=M(t);s&&this._assignNamespace(s);for(var u=null!==(n=T(t))&&void 0!==n?n:[],l=new Map,c=0,p=u;c<p.length;c++){var h=p[c],f=null!==(r=l.get(h.prop))&&void 0!==r?r:[];f.push(h),l.set(h.prop,f)}for(var m=[],d=0,v=Object.keys(t);d<v.length;d++){var y=v[d],_=t[y];if(null!=_){var g=l.get(y);if(g){var b=g.some(function(t){return!0===t.ignore||"none"===t.kind});if(b)continue;for(var w=0,x=g;w<x.length;w++)(h=x[w]).name&&this._assignNamespace(h.name)}m.push(_)}}for(var S=0,j=m;S<j.length;S++){var C=j[S];P(C)||this._gatherNamespaces(C,e)}}},t.prototype._assignNamespace=function(t,e){var n=S(t);if(null==n?void 0:n.ns){var r=n.ns.toLowerCase();this._ns.get(r)||this._ns.set(r,null!=e?e:this._buildNsPrefix(r))}else"xmlns"===e&&(r=n.name.toLowerCase(),this._ns.get(r)||this._ns.set(r,null!=e?e:this._buildNsPrefix(r)))},t.prototype._buildNsPrefix=function(t){var e,n=!1;do{e="ns".concat(this._prefixCount++);for(var r=0,i=Array.from(this._ns.values());r<i.length;r++)if(i[r]===e){n=!0;break}}while(n);return e},t}(),F=function(){function t(){}return t.OpenTag="<",t.CloseTag=">",t.Slash="/",t.Question="?",t.Quote='"',t.Equal="=",t.Space=" ",t.Semicolon=":",t.Dec="<?xml",t.Xml="xml",t.Xmlns="xmlns",t.Xsi="xsi",t.VersionKeyword="version",t.EncodingKeyword="encoding",t.StandaloneKeyword="standalone",t}();!function(t){t[t.Declaration=0]="Declaration",t[t.Tag=1]="Tag",t[t.Attribute=2]="Attribute",t[t.Text=3]="Text"}(E||(E={}));var z,Z,K=function(){function t(t){this._ctxStack=[],this._d=0,this._w=t}return t.prototype.dec=function(t,e,n){return this._w.write(F.Dec),this._writeAttStr(F.VersionKeyword,t),e&&this._writeAttStr(F.EncodingKeyword,e),void 0!==n&&this._writeAttStr(F.StandaloneKeyword,n?"yes":"no"),this._w.write(F.Question,F.CloseTag),this},t.prototype.att=function(t,e,n){var r=this._peekContext();if(!r)throw new Error("att() without open element");if(r.closed)throw new Error("att() after start tag closed for <".concat(r.name,">"));if(this._isXmlnsDecl(t,e)){if(e===F.Xmlns)r.defaultNs=n,this._registerNamespace(r,"",n),this._writeAttStr(F.Xmlns,n);else if(t)this._registerNamespace(r,e,n),this._writeAttStr("".concat(t,":").concat(e),n);else{var i=e.slice(6);this._registerNamespace(r,i,n),this._writeAttStr(e,n)}return r.lastToken=E.Attribute,this}var o=e;if(t){var a=this._ensurePrefixDeclared(r,t);o="".concat(a,":").concat(e)}return r.lastToken=E.Attribute,this._writeAttStr(o,n),this},t.prototype.ele=function(t,e){var n,r=this._peekContext();r&&this._closeOpenTagIfNeeded(r);var i=e;if(t){var o=null!==(n=this._lookupPrefix(t))&&void 0!==n?n:t;i="".concat(o,":").concat(e)}return this._pushContext(i,++this._d),this._w.write(F.OpenTag,i),this},t.prototype.text=function(t){var e=this._peekContext();if(!e)throw new Error("text() without open element");return this._closeOpenTagIfNeeded(e),e.lastToken=E.Text,this._w.write(this._escText(t)),this},t.prototype.end=function(){var t=this._popContext();return t&&(this._d--,t.closed?this._w.write(F.OpenTag,F.Slash,t.name,F.CloseTag):this._w.write(F.Slash,F.CloseTag)),this},t.prototype._pushContext=function(e,n){var r=new t.Context(e,n);return this._ctxStack.push(r),r},t.prototype._popContext=function(){return this._ctxStack.pop()},t.prototype._peekContext=function(){return this._ctxStack[this._ctxStack.length-1]},Object.defineProperty(t.prototype,"_contextDepth",{get:function(){return this._ctxStack.length},enumerable:!1,configurable:!0}),t.prototype._writeAttStr=function(t,e){this._w.write(F.Space,t,F.Equal,F.Quote,this._escAttr(e),F.Quote)},t.prototype._lookupPrefix=function(t){var e,n=this._ctxStack.length-1;if(n>=0)do{var r=null===(e=this._ctxStack[n--].ns2prefix)||void 0===e?void 0:e.get(t);if(r)return r}while(n>=0)},t.prototype._escText=function(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")},t.prototype._escAttr=function(t){return this._escText(t).replace(/"/g,"&quot;").replace(/'/g,"&apos;")},t.prototype._isXmlnsDecl=function(t,e){if(t)return t===F.Xmlns;var n=e.length,r=F.Xmlns.length;return n>=r&&e.startsWith(F.Xmlns)&&(e.length==r||e[r]==F.Semicolon)},t.prototype._registerNamespace=function(t,e,n){if(e===F.Xml||e===F.Xmlns)throw new Error("reserved prefix '".concat(e,"'"));var r=t.prefix2ns.get(e);if(r&&r!==n)throw new Error("prefix '".concat(e,"' already bound to a different namespace"));t.ns2prefix.get(n)||t.ns2prefix.set(n,e),t.prefix2ns.set(e,n)},t.prototype._allocPrefix=function(t){for(var e=1;;){var n="ns".concat(e++);if(!t.prefix2ns.has(n))return n}},t.prototype._ensurePrefixDeclared=function(t,e){var n=this._lookupPrefix(e);if(n)return n;if(t.closed)throw new Error("can not declare namespace after start tag closed for <".concat(t.name,">"));var r=this._allocPrefix(t);return this._writeAttStr("".concat(F.Xmlns,":").concat(r),e),this._registerNamespace(t,r,e),r},t.prototype._closeOpenTagIfNeeded=function(t){t.closed||(this._w.write(F.CloseTag),t.closed=!0)},t.Context=function(t,e){this.name="",this.closed=!1,this.lastToken=null,this.ns2prefix=new Map,this.prefix2ns=new Map,this.defaultNs=null,this.name=t,this.depth=e},t}(),L=function(){function t(){this.count=0,this._chunks=[]}return t.prototype.write=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];if(0===t.length)return this;var n=t.join("");return this._chunks.push(n),this.count+=n.length,this},t.prototype.toString=function(){return this._chunks.join("")},t.prototype.clear=function(){this._chunks=[],this.count=0},t}(),U=function(){function t(t,e){void 0===e&&(e={}),this._sink=t,this._opts=e,this.count=0,this._encoder=new TextEncoder,this._pending="",this._pendingChars=0}return t.prototype.write=function(){for(var t,e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];if(0===e.length)return this;var r=e.join("");if(0===r.length)return this;this._pending+=r,this._pendingChars+=r.length;var i=null!==(t=this._opts.flushChars)&&void 0!==t?t:65536;return this._pendingChars>=i&&this.flush(),this},t.prototype.flush=function(){if(0===this._pendingChars)return this;var t=this._encoder.encode(this._pending);return this._sink.push(t),this.count+=t.length,this._pending="",this._pendingChars=0,this},t.prototype.finish=function(){this.flush(),this._sink.push(new Uint8Array(0),!0)},t.prototype.clear=function(){this._pending="",this._pendingChars=0,this.count=0},t}(),G="http://schemas.microsoft.com/3dmanufacturing/core/2015/02",Q="http://schemas.microsoft.com/3dmanufacturing/trianglesets/2021/07";!function(t){t.micron="micron",t.millimeter="millimeter",t.centimeter="centimeter",t.inch="inch",t.foot="foot",t.meter="meter"}(z||(z={})),function(t){t.model="model",t.solidsupport="solidsupport",t.support="support",t.surface="surface",t.other="other"}(Z||(Z={}));var V,W="http://schemas.openxmlformats.org/package/2006/content-types",q="http://schemas.openxmlformats.org/package/2006/relationships";!function(t){t.Relationships="application/vnd.openxmlformats-package.relationships+xml",t.Model="application/vnd.ms-package.3dmanufacturing-3dmodel+xml",t.Materials="application/vnd.ms-package.3dmanufacturing-material+xml",t.Colors="application/vnd.ms-package.3dmanufacturing-colors+xml",t.Texture="application/vnd.ms-package.3dmanufacturing-texture+xml",t.Texture2D="application/vnd.ms-package.3dmanufacturing-texture2d+xml",t.Production="application/vnd.ms-package.3dmanufacturing-production+xml",t.Slice="application/vnd.ms-package.3dmanufacturing-slice+xml",t.BeamLattice="application/vnd.ms-package.3dmanufacturing-beamlattice+xml",t.SecureContent="application/vnd.ms-package.3dmanufacturing-securecontent+xml",t.Png="image/png",t.Jpeg="image/jpeg",t.Tiff="image/tiff",t.Xml="application/xml"}(V||(V={}));var $="_rels/",H="3D/",J="3dmodel.model",Y=".rels",tt="[Content_Types].xml",et=function(){function t(){}return t.IsKnown=function(e){return t.Known.has(e)},t.IsThreeDimModel=function(e){return e===t.ThreeDimModel},t.ThreeDimModel="http://schemas.microsoft.com/3dmanufacturing/2013/01/3dmodel",t.Thumbnail="http://schemas.openxmlformats.org/package/2006/relationships/metadata/thumbnail",t.PrintTicket="http://schemas.microsoft.com/3dmanufacturing/2013/01/printticket",t.MustPreserve="http://schemas.openxmlformats.org/package/2006/relationships/mustpreserve",t.Known=new Set([t.ThreeDimModel,t.Thumbnail,t.PrintTicket,t.MustPreserve]),t}(),nt=function(){function t(){this.items=[]}return c([_({ns:W,name:"Types"})],t)}(),rt=function(){function t(t,e){this.ext=t,this.ct=e}return c([b({name:{ns:W,name:"Extension"}})],t.prototype,"ext",void 0),c([b({name:{ns:W,name:"ContentType"}})],t.prototype,"ct",void 0),c([_({ns:W,name:"Default"})],t)}(),it=function(){function t(){this.items=[]}return c([_({ns:q,name:"Relationships"})],t)}(),ot=function(){function t(t,e,n){this.id=t,this.type=e,this.target=n}return c([b({name:"Id"})],t.prototype,"id",void 0),c([b({name:"Type"})],t.prototype,"type",void 0),c([b({name:"Target"})],t.prototype,"target",void 0),c([_({ns:q,name:"Relationship"})],t)}(),at=function(t,e,n){this.contentTypes=t,this.relationships=e,this.model=n},st=function(){function t(t){this.values=t}return t.Zero=function(){return new t([0,0,0,0,0,0,0,0,0,0,0,0])},t.prototype.toString=function(){return this.values.join(" ")},t}(),ut=function(){function t(t){this.o=t,this._f=new D(t)}return t.prototype.toString=function(t){var e=this;return t.values.map(function(t){return e._f.toString(t)}).join(" ")},t}(),lt=function(){function t(){this.unit=z.millimeter}return t.KnownMeta=["Title","Designer","Description","Copyright","LicenseTerms","Rating","CreationDate","ModificationDate","Application"],c([b({name:"unit"})],t.prototype,"unit",void 0),c([b({name:"requiredextensions"})],t.prototype,"requiredextensions",void 0),c([b({name:"recommendedextensions"})],t.prototype,"recommendedextensions",void 0),c([_({ns:G,name:"model"})],t)}(),ct=function(){function t(t,e,n,r){this.name=t,this.value=e,this.preserve=n,this.type=r}return c([b({name:"name"})],t.prototype,"name",void 0),c([b({name:"preserve"})],t.prototype,"preserve",void 0),c([b({name:"type"})],t.prototype,"type",void 0),c([_({ns:G,name:"meta"})],t)}(),pt=function(){function t(){this.metadata=[]}return c([_({ns:G,name:"metadatagroup"})],t)}(),ht=function(){function t(){this.object=[]}return c([_({ns:G,name:"resources"})],t)}(),ft=function(){function t(t,e){void 0===e&&(e=Z.model),this.id=t,this.type=e}return c([b({name:"id"})],t.prototype,"id",void 0),c([b({name:"type"})],t.prototype,"type",void 0),c([b({name:"thumbnail"})],t.prototype,"thumbnail",void 0),c([b({name:"partnumber"})],t.prototype,"partnumber",void 0),c([b({name:"name"})],t.prototype,"name",void 0),c([b({name:"pid"})],t.prototype,"pid",void 0),c([b({name:"pindex"})],t.prototype,"pindex",void 0),c([_({ns:G,name:"object"})],t)}(),mt=function(){function t(t,e){this.vertices=null!=t?t:new dt,this.triangles=null!=e?e:new yt}return c([_({ns:G,name:"mesh"})],t)}(),dt=function(){function t(){this.vertex=[]}return c([_({ns:G,name:"vertices"})],t)}(),vt=function(){function t(t,e,n){void 0===t&&(t=0),void 0===e&&(e=0),void 0===n&&(n=0),this.x=t,this.y=e,this.z=n}return c([b({name:"x"})],t.prototype,"x",void 0),c([b({name:"y"})],t.prototype,"y",void 0),c([b({name:"z"})],t.prototype,"z",void 0),c([_({ns:G,name:"vertex"})],t)}(),yt=function(){function t(){this.triangle=[]}return c([_({ns:G,name:"triangles"})],t)}(),_t=function(){function t(t,e,n){this.v1=t,this.v2=e,this.v3=n}return c([b({name:"v1"})],t.prototype,"v1",void 0),c([b({name:"v2"})],t.prototype,"v2",void 0),c([b({name:"v3"})],t.prototype,"v3",void 0),c([b({name:"p1"})],t.prototype,"p1",void 0),c([b({name:"p2"})],t.prototype,"p2",void 0),c([b({name:"p3"})],t.prototype,"p3",void 0),c([b({name:"pid"})],t.prototype,"pid",void 0),c([_({ns:G,name:"triangle"})],t)}(),gt=function(){function t(){this.component=[]}return c([_({ns:G,name:"components"})],t)}(),bt=function(){function t(t,e){this.objectid=t,this.transform=e}return c([b({name:"objectid"})],t.prototype,"objectid",void 0),c([b({name:"transform",formatter:ut})],t.prototype,"transform",void 0),c([_({ns:G,name:"component"})],t)}(),wt=function(){function t(t){this.base=[],this.id=t}return c([b({name:"id"})],t.prototype,"id",void 0),c([_({ns:G,name:"basematerials"})],t)}(),Tt=function(){function t(t,e){this.name=t,this.displaycolor=e}return c([b({name:"name"})],t.prototype,"name",void 0),c([b({name:"displaycolor"})],t.prototype,"displaycolor",void 0),c([_({ns:G,name:"base"})],t)}(),Mt=function(){function t(){this.item=[]}return c([_({ns:G,name:"build"})],t)}(),xt=function(){function t(t,e,n){this.objectid=t,this.transform=e,this.partnumber=n}return c([b({name:"objectid"})],t.prototype,"objectid",void 0),c([b({name:"transform",formatter:ut})],t.prototype,"transform",void 0),c([b({name:"partnumber"})],t.prototype,"partnumber",void 0),c([_({ns:G,name:"item"})],t)}(),St=function(){function t(t,e){this._object=new ft(t,e)}return t.prototype.withName=function(t){return this._object.name=t,this},t.prototype.withThumbnail=function(t){return this._object.thumbnail=t,this},t.prototype.withProperty=function(t,e){return void 0===e&&(e=0),this._object.pid=t,this._object.id=e,this},t.prototype.build=function(){return this._object},t.prototype.reset=function(t,e){this._object=new ft(t,e)},t}(),jt=function(t){function e(e,n){void 0===n&&(n=Z.model);var r=t.call(this,e,n)||this;return r._object.content=new gt,r}return u(e,t),e.prototype.withComponent=function(t,e){return this._object.content.component.push(new bt(t,e)),this},e}(St),Ct=function(t){function e(e){return t.call(this,e,Z.model)||this}return u(e,t),e.prototype.withPostProcessHandlers=function(t,e){return this._vh=t,this._th=e,this},e.prototype.withData=function(t){return this._object.content=this._buildMesh(t),this},e.prototype.withMaterial=function(t,e){return this._object.pid=t,this._object.pindex=e,this},e.prototype._buildMesh=function(t){var e=this._buildVertices(t.positions),n=this._buildTriangle(t.indices);return new mt(e,n)},e.prototype._buildVertices=function(t){var e=new dt;if(t)for(var n=0;n<t.length;){var r=t[n++],i=t[n++],o=t[n++],a=new vt(r,i,o);this._vh&&(a=this._vh(a)),e.vertex.push(a)}return e},e.prototype._buildTriangle=function(t){var e=new yt;if(t)for(var n=0;n<t.length;){var r=t[n++],i=t[n++],o=t[n++],a=new _t(r,i,o);this._th&&(a=this._th(a)),e.triangle.push(a)}return e},e}(St),Nt=function(){function t(t){this._m=new wt(t)}return t.prototype.withColor=function(t,e){var n;this._m.base=null!==(n=this._m.base)&&void 0!==n?n:[];var r=this._m.base.find(function(e){return e.name.toLowerCase()===t.toLowerCase()});return r?(r.displaycolor=this._rgbaToHex(e),this):(r=new Tt(t,this._rgbaToHex(e)),this._m.base.push(r),this)},t.prototype.build=function(){return this._m},t.prototype._rgbaToHex=function(t){var e=function(t){return Math.round(Math.min(255,Math.max(0,255*Math.pow(t,1/2.2))))},n=e(t.r).toString(16).padStart(2,"0").toUpperCase(),r=e(t.g).toString(16).padStart(2,"0").toUpperCase(),i=e(t.b).toString(16).padStart(2,"0").toUpperCase();if("number"==typeof t.a){var o=Math.round(Math.min(255,Math.max(0,255*t.a))).toString(16).padStart(2,"0").toUpperCase();return"#".concat(n).concat(r).concat(i).concat(o)}return"#".concat(n).concat(r).concat(i)},t}(),Ot=function(){function t(){this._model=new lt,this._objects=new Map}return t.prototype.withMetaData=function(t,e,n,r){return this._model.metadata||(this._model.metadata=new Array),this._model.metadata.push(new ct(t,e,n,r)),this},t.prototype.withMaterial=function(t){var e,n;return t instanceof Nt&&(t=t.build()),t&&(this._model.resources=null!==(e=this._model.resources)&&void 0!==e?e:new ht,this._model.resources.basematerials=null!==(n=this._model.resources.basematerials)&&void 0!==n?n:[],this._model.resources.basematerials.push(t)),this},t.prototype.withMesh=function(t){var e;return t instanceof Ct&&(t=t.build()),this._model.resources=null!==(e=this._model.resources)&&void 0!==e?e:new ht,this._model.resources.object.push(t),this},t.prototype.withComponents=function(t){var e;return t instanceof jt&&(t=t.build()),this._model.resources=null!==(e=this._model.resources)&&void 0!==e?e:new ht,this._model.resources.object.push(t),this},t.prototype.withBuild=function(t,e,n){var r,i;return this._model.build=null!==(r=this._model.build)&&void 0!==r?r:new Mt,null===(i=this._model.build.item)||void 0===i||i.push(new xt(t,e,n)),this},t.prototype.withUnit=function(t){return this._model.unit=t,this},t.prototype.reset=function(){return this._model=new lt,this._objects=new Map,this},t.prototype.build=function(){var t,e,n,r;if(!(null===(e=null===(t=this._model.resources)||void 0===t?void 0:t.object)||void 0===e?void 0:e.length))throw new Error("Invalid state: resources MUST be defined ");if(!(null===(r=null===(n=this._model.build)||void 0===n?void 0:n.item)||void 0===r?void 0:r.length))throw new Error("Invalid state: Build MUST be defined ");return this._model},t.KnownMetaSet=new Set(lt.KnownMeta.map(function(t){return t.toLowerCase()})),t}(),kt=function(){function t(){}return t.prototype.withContentType=function(t){this._cts||(this._cts=new nt);var e=this._cts.items;return e.some(function(e){return e.ext===t.ext&&e.ct===t.ct})||e.push(t),this},t.prototype.withRelationship=function(t){this._rs||(this._rs=new it);var e=this._rs.items;return e.some(function(e){return e.id===t.id})||e.push(t),this.withContentType(new rt("rels",V.Relationships)),this},t.prototype.withModel=function(t){return t instanceof Ot&&(t=t.build()),this._m=t,this.withContentType(new rt("model",V.Model)),this},t.prototype.build=function(){if(!this._m)throw new Error("Invalid state: you Must provide at least a model.");var t="".concat(H).concat(J);if(!this._rs){var e="/".concat(t);this.withRelationship(new ot("rel".concat(0),et.ThreeDimModel,e))}return new at(this._cts,this._rs,this._m)},t}(),Dt=function(){function t(t){this._o=t}return Object.defineProperty(t.prototype,"options",{get:function(){return this._o},enumerable:!1,configurable:!0}),t.prototype.serializeAsync=function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];return p(this,void 0,void 0,function(){var n,r,i,o,a,s,u;return h(this,function(l){switch(l.label){case 0:return[4,this.ensureZipLibReadyAsync()];case 1:if(!(n=l.sent()))return[2];if(r=n.Zip,i=n.ZipDeflate,!r||!i)throw new Error("fflate Zip / ZipDeflate not available");return o=function(t){return{push:function(e,n){return t.push(e,n)}}},a=function(t,e,n){var r=new i(e,{level:6});t.add(r);var a=o(r),s=new U(a),u=new K(s).dec("1.0","UTF-8");new I(u).serialize(n),s.finish()},(s=this.toDocument.apply(this,e))?(u=new r(t),a(u,tt,s.contentTypes),a(u,"".concat($).concat(Y),s.relationships),a(u,"".concat(H).concat(J),s.model),u.end(),[2]):[2]}})})},t.prototype.toDocument=function(){for(var t,e,n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];var i=(new Ot).withUnit(null!==(e=null===(t=this._o)||void 0===t?void 0:t.unit)&&void 0!==e?e:z.millimeter);if(this.options.metadata)for(var o in this.options.metadata)i.withMetaData(o,this.options.metadata[o]);return(new kt).withModel(this.toModel.apply(this,f([i],n,!1))).build()},t}(),At=function(){function t(){}return t.SerializeToMemoryAsync=function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];return p(this,void 0,void 0,function(){var n,r,i,o,a,s,u,l;return h(this,function(c){switch(c.label){case 0:return n=new Array,r=0,i=function(t,e,i){n.push(e),r+=e.length},[4,t.serializeAsync.apply(t,f([i],e,!1))];case 1:if(c.sent(),!r)return[2,void 0];for(o=new Uint8Array(r),a=0,s=0,u=n;s<u.length;s++)l=u[s],o.set(l,a),a+=l.length;return[2,o]}})})},t}(),Xt=r(597),Rt=function(){function t(){}return t.FFLATEUrl="https://unpkg.com/fflate@0.8.2",t}(),Pt=function(){function t(t,e,n){void 0===t&&(t=0),void 0===e&&(e=Number.MIN_SAFE_INTEGER),void 0===n&&(n=1),this._from=t,this._to=e,this._step=n,this._i=t}return t.prototype.next=function(){if(this._i<this._to)throw new Error("ST_ResourceID out of bound");var t=this._i;return this._i+=this._step,t},t.prototype.reset=function(){return this._i=this._from,this},t}(),Bt=function(t){function e(n){return void 0===n&&(n={}),t.call(this,l(l({},e.DefaultOptions),n))||this}return u(e,t),e.prototype.toModel=function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];e=e.filter(function(t){return t instanceof Xt.Mesh||t instanceof Xt.InstancedMesh});for(var r=new Pt,i=t,o=new Map,a=this.options.exportInstances?[]:null,s=0;s<e.length;s++){var u=e[s];if(u instanceof Xt.InstancedMesh)null==a||a.push(u);else{var l=u.name||"mesh".concat(s),c=u.getWorldMatrix(),p=this._handleBabylonTo3mfMatrixTransformToRef(c,st.Zero());if(void 0!==(x=u.subMeshes))for(var h=1==x.length,f=0;f<x.length;f++){var m=x[f],d=this._extractSubMesh(u,m);if(d){var v=h?"".concat(l):"".concat(l,"_").concat(f),y=new Ct(r.next()).withData(d).withName(v).build();i.withMesh(y),i.withBuild(y.id,p),o.set(m,y)}}}}if(a&&a.length)for(var _=this._groupBy(a,function(t){return t.sourceMesh}),g=0,b=Array.from(_.entries());g<b.length;g++){var w=b[g],T=w[0],M=w[1];if(M&&M.length)for(s=0;s<M.length;s++){c=M[s].getWorldMatrix();var x=T.subMeshes;for(f=0;f<x.length;f++){m=x[f];var S=o.get(m);S&&i.withBuild(S.id,this._handleBabylonTo3mfMatrixTransformToRef(c,st.Zero()))}}}return i.build()},e.prototype.ensureZipLibReadyAsync=function(){return p(this,void 0,void 0,function(){var t=this;return h(this,function(e){switch(e.label){case 0:return this._fflateReadyPromise?[4,this._fflateReadyPromise]:[3,2];case 1:case 3:return[2,e.sent()];case 2:return this._fflateReadyPromise=p(t,void 0,void 0,function(){var t;return h(this,function(e){switch(e.label){case 0:return(t=globalThis).fflate?[3,2]:[4,Xt.Tools.LoadScriptAsync(Rt.FFLATEUrl)];case 1:e.sent(),e.label=2;case 2:return[2,t.fflate]}})}),[4,this._fflateReadyPromise]}})})},e.prototype._extractSubMesh=function(t,n){var r=t.getIndices();if(r){var i=t.getVerticesData(e._PositionKind);if(i){if(0==n.indexStart&&n.indexCount==r.length)return{positions:i,indices:r};for(var o=n.indexStart,a=new Map,s=[],u=new Uint32Array(n.indexCount),l=0;l<n.indexCount;l++){var c=r[o+l],p=a.get(c);if(void 0===p){p=a.size,a.set(c,p);var h=3*c;s.push(i[h],i[h+1],i[h+2])}u[l]=p}return{positions:new Float32Array(s),indices:u}}}},e.prototype._groupBy=function(t,e){for(var n=new Map,r=0,i=t;r<i.length;r++){var o=i[r],a=e(o),s=n.get(a);s?s.push(o):n.set(a,[o])}return n},e.prototype._handleBabylonTo3mfMatrixTransformToRef=function(t,n){var r=t.multiplyToRef(e._R_BJS_TO_3MF,Xt.Matrix.Zero()).m;return n.values=[r[0],r[1],r[2],r[4],r[5],r[6],r[8],r[9],r[10],r[12],r[13],r[14]],n},e.DefaultOptions={unit:z.meter,exportInstances:!1},e._PositionKind="position",e._R_BJS_TO_3MF=Xt.Matrix.RotationX(Math.PI/2).multiply(Xt.Matrix.Scaling(1,-1,1)),e}(Dt),Et=void 0!==r.g?r.g:"undefined"!=typeof window?window:void 0;if(void 0!==Et){var It=[];for(var Ft in o)It.indexOf(Ft)>-1||(Et.BABYLON[Ft]=o[Ft],It.push(Ft))}const zt=a;return i.default})());
2
- //# sourceMappingURL=babylon.threemfSerializer.min.js.map
@@ -1,2 +0,0 @@
1
- !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("babylonjs")):"function"==typeof define&&define.amd?define("babylonjs-serializers",["babylonjs"],e):"object"==typeof exports?exports["babylonjs-serializers"]=e(require("babylonjs")):t.SERIALIZERS=e(t.BABYLON)}("undefined"!=typeof self?self:"undefined"!=typeof global?global:this,t=>(()=>{"use strict";var e={597(e){e.exports=t}},n={};function o(t){var a=n[t];if(void 0!==a)return a.exports;var r=n[t]={exports:{}};return e[t](r,r.exports,o),r.exports}o.d=(t,e)=>{for(var n in e)o.o(e,n)&&!o.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},o.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),o.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),o.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var a={};o.d(a,{default:()=>w});var r={};o.r(r),o.d(r,{USDZExportAsync:()=>S});var i={};o.r(i),o.d(i,{USDZExportAsync:()=>S});var c=function(){return c=Object.assign||function(t){for(var e,n=1,o=arguments.length;n<o;n++)for(var a in e=arguments[n])Object.prototype.hasOwnProperty.call(e,a)&&(t[a]=e[a]);return t},c.apply(this,arguments)};function s(t,e,n,o){return new(n||(n=Promise))(function(a,r){function i(t){try{s(o.next(t))}catch(t){r(t)}}function c(t){try{s(o.throw(t))}catch(t){r(t)}}function s(t){var e;t.done?a(t.value):(e=t.value,e instanceof n?e:new n(function(t){t(e)})).then(i,c)}s((o=o.apply(t,e||[])).next())})}function u(t,e){var n,o,a,r={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=c(0),i.throw=c(1),i.return=c(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(s){return function(c){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,c[0]&&(r=0)),r;)try{if(n=1,o&&(a=2&c[0]?o.return:c[0]?o.throw||((a=o.return)&&a.call(o),0):o.next)&&!(a=a.call(o,c[1])).done)return a;switch(o=0,a&&(c=[2&c[0],a.value]),c[0]){case 0:case 1:a=c;break;case 4:return r.label++,{value:c[1],done:!1};case 5:r.label++,o=c[1],c=[0];continue;case 7:c=r.ops.pop(),r.trys.pop();continue;default:if(!((a=(a=r.trys).length>0&&a[a.length-1])||6!==c[0]&&2!==c[0])){r=0;continue}if(3===c[0]&&(!a||c[1]>a[0]&&c[1]<a[3])){r.label=c[1];break}if(6===c[0]&&r.label<a[1]){r.label=a[1],a=c;break}if(a&&r.label<a[2]){r.label=a[2],r.ops.push(c);break}a[2]&&r.ops.pop(),r.trys.pop();continue}c=e.call(t,r)}catch(t){c=[6,t],o=0}finally{n=a=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,s])}}}Object.create,Object.create,"function"==typeof SuppressedError&&SuppressedError;var l=o(597),f=l.Matrix.Compose(new l.Vector3(-1,1,1),l.Quaternion.Identity(),l.Vector3.Zero());function p(t,e){if(!(t instanceof l.TransformNode))return!1;if(e){if(!t.getWorldMatrix().equalsWithEpsilon(l.Matrix.IdentityReadOnly,l.Epsilon))return!1}else if(!t.getWorldMatrix().multiplyToRef(f,l.TmpVectors.Matrix[0]).equalsWithEpsilon(l.Matrix.IdentityReadOnly,l.Epsilon))return!1;return!(t instanceof l.AbstractMesh&&t.geometry)}function d(t,e,n,o){void 0===n&&(n=3),void 0===o&&(o=!1);for(var a=[],r=0;r<t.length/n;r++){var i=t[r*n]*(o?-1:1),c=t[r*n+1],s=t[r*n+2];a.push("(".concat(i.toPrecision(e.precision),", ").concat(c.toPrecision(e.precision),", ").concat(s.toPrecision(e.precision),")"))}return a.join(", ")}function h(t,e){for(var n=[],o=0;o<t.length/2;o++){var a=t[2*o],r=t[2*o+1];n.push("(".concat(a.toPrecision(e.precision),", ").concat((1-r).toPrecision(e.precision),")"))}return n.join(", ")}function m(t,e,n,o){var a=function(t,e,n,o){var a=t.getVerticesData(l.VertexBuffer.PositionKind),r=t.getVerticesData(l.VertexBuffer.NormalKind);if(a&&r)return'\n\tdef Mesh "'.concat("Geometry",'"\n\t{\n uniform token orientation = "').concat(n,'"\n\t\tint[] faceVertexCounts = [').concat(function(t){var e,n=(null===(e=t.getIndices())||void 0===e?void 0:e.length)?t.getTotalIndices():t.getTotalVertices();return Array(n/3).fill(3).join(", ")}(t),"]\n\t\tint[] faceVertexIndices = [").concat(function(t){var e,n=t.getIndices(),o=null!==(e=null==n?void 0:n.length)&&void 0!==e?e:t.getTotalVertices(),a=[];if(null!==n)for(var r=0;r<o;r++)a.push(n[r]);else for(r=0;r<o;r++)a.push(r);return a.join(", ")}(t),"]\n\t\tnormal3f[] normals = [").concat(d(r,e,void 0,o),'] (\n\t\t\tinterpolation = "vertex"\n\t\t)\n\t\tpoint3f[] points = [').concat(d(a,e,void 0,o),"]\n ").concat(function(t,e){for(var n="",o=0;o<4;o++){var a=o>0?o:"",r=t.getVerticesData(l.VertexBuffer.UVKind+(a?a+1:""));r&&(n+="\n\t\ttexCoord2f[] primvars:st".concat(a," = [").concat(h(r,e),'] (\n\t\t\tinterpolation = "vertex"\n\t\t)'))}var i=t.getVerticesData(l.VertexBuffer.ColorKind);return i&&(n+="\n\tcolor3f[] primvars:displayColor = [".concat(d(i,e,i.length/t.getTotalVertices()),'] (\n\t\tinterpolation = "vertex"\n\t\t)')),n}(t,e),'\n\t\tuniform token subdivisionScheme = "none"\n\t}\n')}(t,e,n,o);return'\n def "Geometry"\n {\n '.concat(a,"\n }\n ")}function g(t){var e='#usda 1.0\n (\n customLayerData = {\n string creator = "Babylon.js USDZExportAsync"\n }\n defaultPrim = "Root"\n metersPerUnit = 1\n upAxis = "Y"\n )';return e+=t,fflate.strToU8(e)}function y(t){var e=t.m;return"( ".concat(v(e,0),", ").concat(v(e,4),", ").concat(v(e,8),", ").concat(v(e,12)," )")}function v(t,e){return"(".concat(t[e+0],", ").concat(t[e+1],", ").concat(t[e+2],", ").concat(t[e+3],")")}function M(t,e){var n="Object_"+t.uniqueId,o=y(e);return'def Xform "'.concat(n,'" (\n\tprepend references = @./geometries/Geometry_').concat(t.geometry.uniqueId,'.usda@</Geometry>\n\tprepend apiSchemas = ["MaterialBindingAPI"]\n)\n{\n\tmatrix4d xformOp:transform = ').concat(o,'\n\tuniform token[] xformOpOrder = ["xformOp:transform"]\t\n\n rel material:binding = </Root/Materials/Material_').concat(t.material.uniqueId,">\n}\n\n")}function x(t){switch(t){case l.Constants.TEXTURE_CLAMP_ADDRESSMODE:return"clamp";case l.Constants.TEXTURE_MIRROR_ADDRESSMODE:return"mirror";case l.Constants.TEXTURE_WRAP_ADDRESSMODE:default:return"repeat"}}function b(t){return"(".concat(t.x,", ").concat(t.y,")")}function T(t){return"(".concat(t.r,", ").concat(t.g,", ").concat(t.b,")")}function _(t,e,n,o,a,r){var i,c,s=t.getInternalTexture().uniqueId+"_"+t.invertY,u="image/jpeg"===(t.mimeType||(0,l.GetMimeType)(null!==(c=null===(i=t.getInternalTexture())||void 0===i?void 0:i.url)&&void 0!==c?c:""))?"jpg":"png";a[s]={texture:t,ext:u};var f=t.coordinatesIndex>0?"st"+t.coordinatesIndex:"st",p=new l.Vector2(t.uScale,t.vScale),d=new l.Vector2(t.uOffset,t.vOffset),h=t.wAng,m=Math.sin(h),g=Math.cos(h);return d.y=1-d.y-p.y,d.x+=m*p.x,d.y+=(1-g)*p.y,'\n def Shader "PrimvarReader_'.concat(n,'"\n {\n uniform token info:id = "UsdPrimvarReader_float2"\n float2 inputs:fallback = (0.0, 0.0)\n token inputs:varname = "').concat(f,'"\n float2 outputs:result\n }\n\n def Shader "Transform2d_').concat(n,'"\n {\n uniform token info:id = "UsdTransform2d"\n token inputs:in.connect = </Root/Materials/Material_').concat(e.uniqueId,"/PrimvarReader_").concat(n,".outputs:result>\n float inputs:rotation = ").concat((h*(180/Math.PI)).toFixed(r.precision),"\n float2 inputs:scale = ").concat(b(p),"\n float2 inputs:translation = ").concat(b(d),'\n float2 outputs:result\n }\n\n def Shader "Texture_').concat(t.uniqueId,"_").concat(n,'"\n {\n uniform token info:id = "UsdUVTexture"\n asset inputs:file = @textures/Texture_').concat(s,".").concat(u,"@\n float2 inputs:st.connect = </Root/Materials/Material_").concat(e.uniqueId,"/Transform2d_").concat(n,".outputs:result>\n ").concat(o?"float4 inputs:scale = "+function(t){return"(".concat(t.r,", ").concat(t.g,", ").concat(t.b,", 1.0)")}(o):"",'\n token inputs:sourceColorSpace = "').concat(t.gammaSpace?"sRGB":"raw",'"\n token inputs:wrapS = "').concat(x(t.wrapU),'"\n token inputs:wrapT = "').concat(x(t.wrapV),'"\n float outputs:r\n float outputs:g\n float outputs:b\n float3 outputs:rgb\n ').concat(e.needAlphaBlending()||e.needAlphaTesting()?"float outputs:a":"","\n }")}function C(t,e,n){var o="\t\t\t",a=[],r=[],i=function(t){var e,n,o={diffuseMap:null,diffuse:null,alphaCutOff:0,emissiveMap:null,emissive:null,normalMap:null,roughnessMap:null,roughnessChannel:"a",roughness:0,metalnessMap:null,metalnessChannel:"r",metalness:0,aoMap:null,aoMapChannel:"rgb",aoMapIntensity:0,alphaMap:null,ior:1,clearCoatEnabled:!1,clearCoat:0,clearCoatMap:null,clearCoatRoughness:0,clearCoatRoughnessMap:null};return t instanceof l.StandardMaterial?c(c({},o),{diffuseMap:t.diffuseTexture,diffuse:t.diffuseColor,alphaCutOff:t.alphaCutOff,emissiveMap:t.emissiveTexture,emissive:t.emissiveColor,roughness:1,alphaMap:t.opacityTexture}):t instanceof l.PBRBaseMaterial?c(c({},o),{diffuseMap:t._albedoTexture,diffuse:t._albedoColor,alphaCutOff:t._alphaCutOff,emissiveMap:t._emissiveTexture,emissive:t._emissiveColor,normalMap:t._bumpTexture,roughnessMap:t._metallicTexture,roughnessChannel:t._useRoughnessFromMetallicTextureAlpha?"a":"g",roughness:null!==(e=t._roughness)&&void 0!==e?e:1,metalnessMap:t._metallicTexture,metalnessChannel:t._useMetallnessFromMetallicTextureBlue?"b":"r",metalness:null!==(n=t._metallic)&&void 0!==n?n:0,aoMap:t._ambientTexture,aoMapChannel:t._useAmbientInGrayScale?"r":"rgb",aoMapIntensity:t._ambientTextureStrength,alphaMap:t._opacityTexture,ior:t.subSurface.indexOfRefraction,clearCoatEnabled:t.clearCoat.isEnabled,clearCoat:t.clearCoat.intensity,clearCoatMap:t.clearCoat.texture,clearCoatRoughness:t.clearCoat.roughness,clearCoatRoughnessMap:t.clearCoat.useRoughnessFromMainTexture?t.clearCoat.texture:t.clearCoat.textureRoughness}):o}(t),s=i.diffuseMap,u=i.diffuse,f=i.alphaCutOff,p=i.emissiveMap,d=i.emissive,h=i.normalMap,m=i.roughnessMap,g=i.roughnessChannel,y=i.roughness,v=i.metalnessMap,M=i.metalnessChannel,x=i.metalness,b=i.aoMap,C=i.aoMapChannel,R=i.aoMapIntensity,I=i.alphaMap,S=i.ior,O=i.clearCoatEnabled,A=i.clearCoat,w=i.clearCoatMap,P=i.clearCoatRoughness,q=i.clearCoatRoughnessMap;return null!==s?(a.push("".concat(o,"color3f inputs:diffuseColor.connect = </Root/Materials/Material_").concat(t.uniqueId,"/Texture_").concat(s.uniqueId,"_diffuse.outputs:rgb>")),t.needAlphaBlending()?a.push("".concat(o,"float inputs:opacity.connect = </Root/Materials/Material_").concat(t.uniqueId,"/Texture_").concat(s.uniqueId,"_diffuse.outputs:a>")):t.needAlphaTesting()&&(a.push("".concat(o,"float inputs:opacity.connect = </Root/Materials/Material_").concat(t.uniqueId,"/Texture_").concat(s.uniqueId,"_diffuse.outputs:a>")),a.push("".concat(o,"float inputs:opacityThreshold = ").concat(f))),r.push(_(s,t,"diffuse",u,e,n))):a.push("".concat(o,"color3f inputs:diffuseColor = ").concat(T(u||l.Color3.White()))),null!==p?(a.push("".concat(o,"color3f inputs:emissiveColor.connect = </Root/Materials/Material_").concat(t.uniqueId,"/Texture_").concat(p.uniqueId,"_emissive.outputs:rgb>")),r.push(_(p,t,"emissive",d,e,n))):d&&d.toLuminance()>0&&a.push("".concat(o,"color3f inputs:emissiveColor = ").concat(T(d))),null!==h&&(a.push("".concat(o,"normal3f inputs:normal.connect = </Root/Materials/Material_").concat(t.uniqueId,"/Texture_").concat(h.uniqueId,"_normal.outputs:rgb>")),r.push(_(h,t,"normal",null,e,n))),null!==b&&(a.push("".concat(o,"float inputs:occlusion.connect = </Root/Materials/Material_").concat(t.uniqueId,"/Texture_").concat(b.uniqueId,"_occlusion.outputs:").concat(C,">")),r.push(_(b,t,"occlusion",new l.Color3(R,R,R),e,n))),null!==m?(a.push("".concat(o,"float inputs:roughness.connect = </Root/Materials/Material_").concat(t.uniqueId,"/Texture_").concat(m.uniqueId,"_roughness.outputs:").concat(g,">")),r.push(_(m,t,"roughness",new l.Color3(y,y,y),e,n))):a.push("".concat(o,"float inputs:roughness = ").concat(y)),null!==v?(a.push("".concat(o,"float inputs:metallic.connect = </Root/Materials/Material_").concat(t.uniqueId,"/Texture_").concat(v.uniqueId,"_metallic.outputs:").concat(M,">")),r.push(_(v,t,"metallic",new l.Color3(x,x,x),e,n))):a.push("".concat(o,"float inputs:metallic = ").concat(x)),null!==I?(a.push("".concat(o,"float inputs:opacity.connect = </Root/Materials/Material_").concat(t.uniqueId,"/Texture_").concat(I.uniqueId,"_opacity.outputs:r>")),a.push("".concat(o,"float inputs:opacityThreshold = 0.0001")),r.push(_(I,t,"opacity",null,e,n))):a.push("".concat(o,"float inputs:opacity = ").concat(t.alpha)),O&&(null!==w?(a.push("".concat(o,"float inputs:clearcoat.connect = </Root/Materials/Material_").concat(t.uniqueId,"/Texture_").concat(w.uniqueId,"_clearcoat.outputs:r>")),r.push(_(w,t,"clearcoat",new l.Color3(A,A,A),e,n))):a.push("".concat(o,"float inputs:clearcoat = ").concat(A)),null!==q?(a.push("".concat(o,"float inputs:clearcoatRoughness.connect = </Root/Materials/Material_").concat(t.uniqueId,"/Texture_").concat(q.uniqueId,"_clearcoatRoughness.outputs:g>")),r.push(_(q,t,"clearcoatRoughness",new l.Color3(P,P,P),e,n))):a.push("".concat(o,"float inputs:clearcoatRoughness = ").concat(P))),a.push("".concat(o,"float inputs:ior = ").concat(S)),'\n\tdef Material "Material_'.concat(t.uniqueId,'"\n\t{\n\t\tdef Shader "PreviewSurface"\n\t\t{\n\t\t\tuniform token info:id = "UsdPreviewSurface"\n').concat(a.join("\n"),"\n\t\t\tint inputs:useSpecularWorkflow = 0\n\t\t\ttoken outputs:surface\n\t\t}\n\n\t\ttoken outputs:surface.connect = </Root/Materials/Material_").concat(t.uniqueId,"/PreviewSurface.outputs:surface>\n\n").concat(r.join("\n"),"\n\n\t}\n")}function R(t){var e,n;t.computeWorldMatrix(!0);for(var o=t.getWorldMatrix().clone(),a=t.getScene().useRightHandedSystem,r=null!==(n=null===(e=t.material)||void 0===e?void 0:e._getEffectiveOrientation(t))&&void 0!==n?n:t.sideOrientation,i=!a,c=t.parent;c;){if(p(c,a)&&null===c.parent){a||(o.multiplyToRef(c.getWorldMatrix().invert(),o),r=r===l.Material.ClockWiseSideOrientation?l.Material.CounterClockWiseSideOrientation:l.Material.ClockWiseSideOrientation),i=!1;break}c=c.parent}return o.determinant()<0&&l.Tools.Warn("Mesh ".concat(t.name," has a negative scale, which may look incorrect in destinations like QuickLook.")),{matrix:o,windingOrder:r===l.Material.ClockWiseSideOrientation?"leftHanded":"rightHanded",convertToRightHanded:i}}function I(t){return s(this,void 0,void 0,function(){var e,n,o,a,r;return u(this,function(i){switch(i.label){case 0:if(!(e=t.getInternalTexture())||1!==e.source)return[2,null];n=e._buffer,a=t.mimeType,i.label=1;case 1:return i.trys.push([1,12,,13]),n?[3,3]:[4,l.Tools.LoadFileAsync(e.url)];case 2:return o=i.sent(),a=(0,l.GetMimeType)(e.url)||a,[3,11];case 3:return ArrayBuffer.isView(n)?(o=n.buffer.slice(n.byteOffset,n.byteOffset+n.byteLength),[3,11]):[3,4];case 4:return n instanceof ArrayBuffer?(o=n,[3,11]):[3,5];case 5:return n instanceof Blob?[4,n.arrayBuffer()]:[3,7];case 6:return o=i.sent(),a=n.type||a,[3,11];case 7:return"string"!=typeof n?[3,9]:[4,l.Tools.LoadFileAsync(n)];case 8:return o=i.sent(),a=(0,l.GetMimeType)(n)||a,[3,11];case 9:return"undefined"!=typeof HTMLImageElement&&n instanceof HTMLImageElement?[4,l.Tools.LoadFileAsync(n.src)]:[3,11];case 10:o=i.sent(),a=(0,l.GetMimeType)(n.src)||a,i.label=11;case 11:return[3,13];case 12:return i.sent(),[2,null];case 13:return o&&!a&&e.url&&(r=e.url.match(/^data:([^;,]+)/),a=r?r[1]:(0,l.GetMimeType)(e.url)),o&&a?[2,{data:o,mimeType:a}]:[2,null]}})})}function S(t,e,n){return s(this,void 0,void 0,function(){var o,a,r,i,s,f,p,d,h,v,x,b,T,_,S,O,A,w,P,q,k,E,j,D,B,U,V,W,L,G,F,N,Z,H,z;return u(this,function(u){switch(u.label){case 0:return o=c({fflateUrl:"https://unpkg.com/fflate@0.8.2",includeAnchoringProperties:!0,anchoringType:"plane",planeAnchoringAlignment:"horizontal",modelFileName:"model.usda",precision:5,exportCamera:!1,cameraSensorWidth:35},e),"undefined"!=typeof fflate?[3,2]:[4,l.Tools.LoadScriptAsync(o.fflateUrl)];case 1:u.sent(),u.label=2;case 2:for((a={})[o.modelFileName]=null,r='#usda 1.0\n (\n customLayerData = {\n string creator = "Babylon.js USDZExportAsync"\n }\n defaultPrim = "Root"\n metersPerUnit = 1\n upAxis = "Y"\n )',r+=function(t){var e=!0===t.includeAnchoringProperties?'\n\t\ttoken preliminary:anchoring:type = "'.concat(t.anchoringType,'"\n\t\ttoken preliminary:planeAnchoring:alignment = "').concat(t.planeAnchoringAlignment,'"'):"";return'def Xform "Root"\n {\n def Scope "Scenes" (\n kind = "sceneLibrary"\n )\n {\n def Xform "Scene" (\n customData = {\n bool preliminary_collidesWithEnvironment = 0\n string sceneName = "Scene"\n }\n sceneName = "Scene"\n )\n {'.concat(e,"\n ")}(o),i={},s=0,f=t.meshes;s<f.length;s++)0!==(p=f[s]).getTotalVertices()&&(h=(d=p).geometry,(v=d.material)&&h&&(!n||n(d))&&(-1!==["StandardMaterial","PBRMaterial","PBRMetallicRoughnessMaterial"].indexOf(v.getClassName())?(x="geometries/Geometry_"+h.uniqueId+".usda",b=R(d),T=b.matrix,_=b.windingOrder,S=b.convertToRightHanded,x in a||(O=m(h,o,_,S),a[x]=g(O)),v.uniqueId in i||(i[v.uniqueId]=v),r+=M(d,T)):l.Tools.Warn("USDZExportAsync does not support this material type: "+v.getClassName())));for(q in t.activeCamera&&o.exportCamera&&(r+=function(t,e){var n="Camera_"+t.uniqueId,o=y(l.Matrix.RotationY(Math.PI).multiply(t.getWorldMatrix()));if(t.mode===l.Constants.ORTHOGRAPHIC_CAMERA)return'def Camera "'.concat(n,'"\n\t\t{\n\t\t\tmatrix4d xformOp:transform = ').concat(o,'\n\t\t\tuniform token[] xformOpOrder = ["xformOp:transform"]\n\n\t\t\tfloat2 clippingRange = (').concat(t.minZ.toPrecision(e.precision),", ").concat(t.maxZ.toPrecision(e.precision),")\n\t\t\tfloat horizontalAperture = ").concat((10*(Math.abs(t.orthoLeft||1)+Math.abs(t.orthoRight||1))).toPrecision(e.precision),"\n\t\t\tfloat verticalAperture = ").concat((10*(Math.abs(t.orthoTop||1)+Math.abs(t.orthoBottom||1))).toPrecision(e.precision),'\n\t\t\ttoken projection = "orthographic"\n\t\t}\n\t\n\t');var a=t.getEngine().getAspectRatio(t),r=e.cameraSensorWidth||35;return'def Camera "'.concat(n,'"\n\t\t{\n\t\t\tmatrix4d xformOp:transform = ').concat(o,'\n\t\t\tuniform token[] xformOpOrder = ["xformOp:transform"]\n\n\t\t\tfloat2 clippingRange = (').concat(t.minZ.toPrecision(e.precision),", ").concat(t.maxZ.toPrecision(e.precision),")\n\t\t\tfloat focalLength = ").concat((r/(2*Math.tan(.5*t.fov))).toPrecision(e.precision),'\n token projection = "perspective"\n\t\t\tfloat horizontalAperture = ').concat((r*a).toPrecision(e.precision),"\n\t\t\tfloat verticalAperture = ").concat((r/a).toPrecision(e.precision)," \n\t\t}\n\t\n\t")}(t.activeCamera,o)),r+="\n }\n }",r+=function(t,e,n){var o=[];for(var a in t){var r=t[a];o.push(C(r,e,n))}return'\n def "Materials"\n{\n'.concat(o.join(""),"\n}\n\n")}(i,A={},o),r+="\n }",a[o.modelFileName]=fflate.strToU8(r),P=[],w=A)P.push(q);k=0,u.label=3;case 3:return k<P.length?(q=P[k])in w?(j=A[E=q],D=j.texture,B=j.ext,[4,I(D)]):[3,8]:[3,9];case 4:return(U=u.sent())?(a["textures/Texture_".concat(E,".").concat(B)]=new Uint8Array(U.data),[3,8]):[3,5];case 5:return V=D.getSize(),[4,(0,l.GetTextureDataAsync)(D)];case 6:return W=u.sent(),[4,l.DumpTools.DumpDataAsync(V.width,V.height,W,"image/png",void 0,!1,!0)];case 7:L=u.sent(),a["textures/Texture_".concat(E,".").concat(B)]=new Uint8Array(L).slice(),u.label=8;case 8:return k++,[3,3];case 9:for(F in G=0,a)(N=a[F])&&(Z=34+F.length,4!=(H=63&(G+=Z))&&(z=new Uint8Array(64-H),a[F]=[N,{extra:{12345:z}}]),G=N.length);return[2,fflate.zipSync(a,{level:0})]}})})}var O=void 0!==o.g?o.g:"undefined"!=typeof window?window:void 0;if(void 0!==O)for(var A in r)O.BABYLON[A]=r[A];const w=i;return a.default})());
2
- //# sourceMappingURL=babylon.usdzSerializer.min.js.map