New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

babylonjs-serializers

Package Overview
Dependencies
Maintainers
0
Versions
685
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babylonjs-serializers - npm Package Compare versions

Comparing version

to
7.53.2

2

babylon.usdzSerializer.min.js

@@ -1,2 +0,2 @@

!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 a(t){var o=n[t];if(void 0!==o)return o.exports;var r=n[t]={exports:{}};return e[t](r,r.exports,a),r.exports}a.d=(t,e)=>{for(var n in e)a.o(e,n)&&!a.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},a.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),a.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),a.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var o={};a.d(o,{default:()=>C});var r={};a.r(r),a.d(r,{USDZExportAsync:()=>b});var i={};a.r(i),a.d(i,{USDZExportAsync:()=>b});var c=function(){return c=Object.assign||function(t){for(var e,n=1,a=arguments.length;n<a;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},c.apply(this,arguments)};Object.create,Object.create,"function"==typeof SuppressedError&&SuppressedError;var s=a(597);function u(t,e,n){void 0===n&&(n=3);for(var a=[],o=0;o<t.length/n;o++){var r=t[o*n],i=t[o*n+1],c=t[o*n+2];a.push("(".concat(r.toPrecision(e.precision),", ").concat(i.toPrecision(e.precision),", ").concat(c.toPrecision(e.precision),")"))}return a.join(", ")}function l(t,e){for(var n=[],a=0;a<t.length/2;a++){var o=t[2*a],r=t[2*a+1];n.push("(".concat(o.toPrecision(e.precision),", ").concat((1-r).toPrecision(e.precision),")"))}return n.join(", ")}function p(t,e){var n=function(t,e){var n=t.getVerticesData(s.VertexBuffer.PositionKind),a=t.getVerticesData(s.VertexBuffer.PositionKind);if(n&&a)return'\n\tdef Mesh "'.concat("Geometry",'"\n\t{\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=t.getIndices(),n=[];if(null!==e)for(var a=0;a<e.length;a++)n.push(e[a]);else{var o=t.getTotalVertices();for(a=0;a<o;a++)n.push(a)}return n.join(", ")}(t),"]\n\t\tnormal3f[] normals = [").concat(u(a,e),'] (\n\t\t\tinterpolation = "vertex"\n\t\t)\n\t\tpoint3f[] points = [').concat(u(n,e),"]\n ").concat(function(t,e){for(var n="",a=0;a<4;a++){var o=a>0?a:"",r=t.getVerticesData(s.VertexBuffer.UVKind+(o||""));r&&(n+="\n\t\ttexCoord2f[] primvars:st".concat(o," = [").concat(l(r,e),'] (\n\t\t\tinterpolation = "vertex"\n\t\t)'))}var i=t.getVerticesData(s.VertexBuffer.ColorKind);return i&&(n+="\n\tcolor3f[] primvars:displayColor = [".concat(u(i,e,4),'] (\n\t\tinterpolation = "vertex"\n\t\t)')),n}(t,e),'\n\t\tuniform token subdivisionScheme = "none"\n\t}\n')}(t,e);return'\n def "Geometry"\n {\n '.concat(n,"\n }\n ")}function f(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 d(t){var e=t.m;return"( ".concat(m(e,0),", ").concat(m(e,4),", ").concat(m(e,8),", ").concat(m(e,12)," )")}function m(t,e){return"(".concat(t[e+0],", ").concat(t[e+1],", ").concat(t[e+2],", ").concat(t[e+3],")")}function h(t){var e="Object_"+t.uniqueId,n=t.getWorldMatrix().clone();n.determinant()<0&&n.multiplyToRef(s.Matrix.Scaling(-1,1,1),n);var a=d(n);return'def Xform "'.concat(e,'" (\n\tprepend references = @./geometries/Geometry_').concat(t.geometry.uniqueId,'.usda@</Geometry>\n\tprepend apiSchemas = ["MaterialBindingAPI"]\n)\n{\n\tmatrix4d xformOp:transform = ').concat(a,'\n\tuniform token[] xformOpOrder = ["xformOp:transform"]\t\n\n rel material:binding = </Materials/Material_').concat(t.material.uniqueId,">\n}\n\n")}function g(t){switch(t){case s.Constants.TEXTURE_CLAMP_ADDRESSMODE:return"clamp";case s.Constants.TEXTURE_MIRROR_ADDRESSMODE:return"mirror";case s.Constants.TEXTURE_WRAP_ADDRESSMODE:default:return"repeat"}}function M(t){return"(".concat(t.x,", ").concat(t.y,")")}function v(t){return"(".concat(t.r,", ").concat(t.g,", ").concat(t.b,")")}function x(t,e,n,a,o,r){var i=t.getInternalTexture().uniqueId+"_"+t.invertY;o[i]=t;var c=t.coordinatesIndex>0?"st"+t.coordinatesIndex:"st",u=new s.Vector2(t.uScale,t.vScale),l=new s.Vector2(t.uOffset,t.vOffset),p=t.wAng,f=Math.sin(p),d=Math.cos(p);return l.y=1-l.y-u.y,l.x+=f*u.x,l.y+=(1-d)*u.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(c,'"\n float2 outputs:result\n }\n\n def Shader "Transform2d_').concat(n,'"\n {\n uniform token info:id = "UsdTransform2d"\n token inputs:in.connect = </Materials/Material_').concat(e.uniqueId,"/PrimvarReader_").concat(n,".outputs:result>\n float inputs:rotation = ").concat((p*(180/Math.PI)).toFixed(r.precision),"\n float2 inputs:scale = ").concat(M(u),"\n float2 inputs:translation = ").concat(M(l),'\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(i,".png@\n float2 inputs:st.connect = </Materials/Material_").concat(e.uniqueId,"/Transform2d_").concat(n,".outputs:result>\n ").concat(a?"float4 inputs:scale = "+function(t){return"(".concat(t.r,", ").concat(t.g,", ").concat(t.b,", 1.0)")}(a):"",'\n token inputs:sourceColorSpace = "').concat(t.gammaSpace?"raw":"sRGB",'"\n token inputs:wrapS = "').concat(g(t.wrapU),'"\n token inputs:wrapT = "').concat(g(t.wrapV),'"\n float outputs:r\n float outputs:g\n float outputs:b\n float3 outputs:rgb\n ').concat(e.needAlphaBlending()?"float outputs:a":"","\n }")}function y(t,e,n){var a="\t\t\t",o=[],r=[],i=function(t){switch(t.getClassName()){case"StandardMaterial":return{diffuseMap:t.diffuseTexture,diffuse:t.diffuseColor,alphaCutOff:t.alphaCutOff,emissiveMap:t.emissiveTexture,emissive:t.emissiveColor,roughnessMap:null,normalMap:null,metalnessMap:null,roughness:1,metalness:0,aoMap:null,aoMapIntensity:0,alphaMap:t.opacityTexture,ior:1};case"PBRMaterial":return{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:t.roughness||1,metalnessMap:t.metallicTexture,metalnessChannel:t.useMetallnessFromMetallicTextureBlue?"b":"r",metalness:t.metallic||0,aoMap:t.ambientTexture,aoMapChannel:t.useAmbientInGrayScale?"r":"rgb",aoMapIntensity:t.ambientTextureStrength,alphaMap:t.opacityTexture,ior:t.indexOfRefraction};case"PBRMetallicRoughnessMaterial":return{diffuseMap:t.baseTexture,diffuse:t.baseColor,alphaCutOff:t.alphaCutOff,emissiveMap:t.emissiveTexture,emissive:t.emissiveColor,normalMap:t.normalTexture,roughnessMap:t.metallicTexture,roughnessChannel:t.useRoughnessFromMetallicTextureAlpha?"a":"g",roughness:t.roughness||1,metalnessMap:t.metallicTexture,metalnessChannel:t.useMetallnessFromMetallicTextureBlue?"b":"r",metalness:t.metallic||0,aoMap:t.ambientTexture,aoMapChannel:t.useAmbientInGrayScale?"r":"rgb",aoMapIntensity:t.ambientTextureStrength,alphaMap:t.opacityTexture,ior:t.indexOfRefraction};default:return{diffuseMap:null,diffuse:null,emissiveMap:null,emissemissiveiveColor:null,normalMap:null,roughnessMap:null,metalnessMap:null,alphaCutOff:0,roughness:0,metalness:0,aoMap:null,aoMapIntensity:0,alphaMap:null,ior:1}}}(t),c=i.diffuseMap,u=i.diffuse,l=i.alphaCutOff,p=i.emissiveMap,f=i.emissive,d=i.normalMap,m=i.roughnessMap,h=i.roughnessChannel,g=i.roughness,M=i.metalnessMap,y=i.metalnessChannel,b=i.metalness,T=i.aoMap,_=i.aoMapChannel,C=i.aoMapIntensity,I=i.alphaMap,S=i.ior;return null!==c?(o.push("".concat(a,"color3f inputs:diffuseColor.connect = </Materials/Material_").concat(t.uniqueId,"/Texture_").concat(c.uniqueId,"_diffuse.outputs:rgb>")),t.needAlphaBlending()?o.push("".concat(a,"float inputs:opacity.connect = </Materials/Material_").concat(t.uniqueId,"/Texture_").concat(c.uniqueId,"_diffuse.outputs:a>")):t.needAlphaTesting()&&(o.push("".concat(a,"float inputs:opacity.connect = </Materials/Material_").concat(t.uniqueId,"/Texture_").concat(c.uniqueId,"_diffuse.outputs:a>")),o.push("".concat(a,"float inputs:opacityThreshold = ").concat(l))),r.push(x(c,t,"diffuse",u,e,n))):o.push("".concat(a,"color3f inputs:diffuseColor = ").concat(v(u||s.Color3.White()))),null!==p?(o.push("".concat(a,"color3f inputs:emissiveColor.connect = </Materials/Material_").concat(t.uniqueId,"/Texture_").concat(p.uniqueId,"_emissive.outputs:rgb>")),r.push(x(p,t,"emissive",f,e,n))):f&&f.toLuminance()>0&&o.push("".concat(a,"color3f inputs:emissiveColor = ").concat(v(f))),null!==d&&(o.push("".concat(a,"normal3f inputs:normal.connect = </Materials/Material_").concat(t.uniqueId,"/Texture_").concat(d.uniqueId,"_normal.outputs:rgb>")),r.push(x(d,t,"normal",null,e,n))),null!==T&&(o.push("".concat(a,"float inputs:occlusion.connect = </Materials/Material_").concat(t.uniqueId,"/Texture_").concat(T.uniqueId,"_occlusion.outputs:").concat(_,">")),r.push(x(T,t,"occlusion",new s.Color3(C,C,C),e,n))),null!==m?(o.push("".concat(a,"float inputs:roughness.connect = </Materials/Material_").concat(t.uniqueId,"/Texture_").concat(m.uniqueId,"_roughness.outputs:").concat(h,">")),r.push(x(m,t,"roughness",new s.Color3(g,g,g),e,n))):o.push("".concat(a,"float inputs:roughness = ").concat(g)),null!==M?(o.push("".concat(a,"float inputs:metallic.connect = </Materials/Material_").concat(t.uniqueId,"/Texture_").concat(M.uniqueId,"_metallic.outputs:").concat(y,">")),r.push(x(M,t,"metallic",new s.Color3(b,b,b),e,n))):o.push("".concat(a,"float inputs:metallic = ").concat(b)),null!==I?(o.push("".concat(a,"float inputs:opacity.connect = </Materials/Material_").concat(t.uniqueId,"/Texture_").concat(I.uniqueId,"_opacity.outputs:r>")),o.push("".concat(a,"float inputs:opacityThreshold = 0.0001")),r.push(x(I,t,"opacity",null,e,n))):o.push("".concat(a,"float inputs:opacity = ").concat(t.alpha)),o.push("".concat(a,"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(o.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 = </Materials/Material_").concat(t.uniqueId,"/PreviewSurface.outputs:surface>\n\n").concat(r.join("\n"),"\n\n\t}\n")}function b(t,e,n){return a=this,o=void 0,i=function(){var a,o,r,i,u,l,m,g,M,v,x,b,T,_,C,I,S,O,P,w,A,R,q,j,k,E,D,U;return function(t,e){var n,a,o,r={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=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,a&&(o=2&c[0]?a.return:c[0]?a.throw||((o=a.return)&&o.call(a),0):a.next)&&!(o=o.call(a,c[1])).done)return o;switch(a=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return r.label++,{value:c[1],done:!1};case 5:r.label++,a=c[1],c=[0];continue;case 7:c=r.ops.pop(),r.trys.pop();continue;default:if(!((o=(o=r.trys).length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){r=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){r.label=c[1];break}if(6===c[0]&&r.label<o[1]){r.label=o[1],o=c;break}if(o&&r.label<o[2]){r.label=o[2],r.ops.push(c);break}o[2]&&r.ops.pop(),r.trys.pop();continue}c=e.call(t,r)}catch(t){c=[6,t],a=0}finally{n=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,s])}}}(this,(function(B){switch(B.label){case 0:return a=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,s.Tools.LoadScriptAsync(a.fflateUrl)];case 1:B.sent(),B.label=2;case 2:for((o={})[a.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 ")}(a),i={},u=0,l=t.meshes;u<l.length;u++)0!==(m=l[u]).getTotalVertices()&&(M=(g=m).geometry,(v=g.material)&&M&&(!n||n(g))&&(-1!==["StandardMaterial","PBRMaterial","PBRMetallicRoughnessMaterial"].indexOf(v.getClassName())?((x="geometries/Geometry_"+M.uniqueId+".usda")in o||(b=p(M,a),o[x]=f(b)),v.uniqueId in i||(i[v.uniqueId]=v),r+=h(g)):s.Tools.Warn("USDZExportAsync does not support this material type: "+v.getClassName())));for(I in t.activeCamera&&a.exportCamera&&(r+=function(t,e){var n="Camera_"+t.uniqueId,a=d(s.Matrix.RotationY(Math.PI).multiply(t.getWorldMatrix()));if(t.mode===s.Constants.ORTHOGRAPHIC_CAMERA)return'def Camera "'.concat(n,'"\n\t\t{\n\t\t\tmatrix4d xformOp:transform = ').concat(a,'\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 o=t.getEngine().getAspectRatio(t),r=e.cameraSensorWidth||35;return'def Camera "'.concat(n,'"\n\t\t{\n\t\t\tmatrix4d xformOp:transform = ').concat(a,'\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*o).toPrecision(e.precision),"\n\t\t\tfloat verticalAperture = ").concat((r/o).toPrecision(e.precision)," \n\t\t}\n\t\n\t")}(t.activeCamera,a)),r+="\n }\n }\n }",r+=function(t,e,n){var a=[];for(var o in t){var r=t[o];a.push(y(r,e,n))}return'\n def "Materials"\n{\n'.concat(a.join(""),"\n}\n\n")}(i,T={},a),o[a.modelFileName]=fflate.strToU8(r),C=[],_=T)C.push(I);S=0,B.label=3;case 3:return S<C.length?(I=C[S])in _?(P=T[O=I],w=P.getSize(),[4,P.readPixels()]):[3,6]:[3,7];case 4:if(!(A=B.sent()))throw new Error("Texture data is not available");return[4,s.DumpTools.DumpDataAsync(w.width,w.height,A,"image/png",void 0,!1,!0)];case 5:R=B.sent(),o["textures/Texture_".concat(O,".png")]=new Uint8Array(R).slice(),B.label=6;case 6:return S++,[3,3];case 7:for(j in q=0,o)(k=o[j])&&(E=34+j.length,4!=(D=63&(q+=E))&&(U=new Uint8Array(64-D),o[j]=[k,{extra:{12345:U}}]),q=k.length);return[2,fflate.zipSync(o,{level:0})]}}))},new((r=void 0)||(r=Promise))((function(t,e){function n(t){try{s(i.next(t))}catch(t){e(t)}}function c(t){try{s(i.throw(t))}catch(t){e(t)}}function s(e){var a;e.done?t(e.value):(a=e.value,a instanceof r?a:new r((function(t){t(a)}))).then(n,c)}s((i=i.apply(a,o||[])).next())}));var a,o,r,i}var T=void 0!==a.g?a.g:"undefined"!=typeof window?window:void 0;if(void 0!==T)for(var _ in r)T.BABYLON[_]=r[_];const C=i;return o.default})()));
!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 a(t){var o=n[t];if(void 0!==o)return o.exports;var r=n[t]={exports:{}};return e[t](r,r.exports,a),r.exports}a.d=(t,e)=>{for(var n in e)a.o(e,n)&&!a.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},a.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),a.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),a.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var o={};a.d(o,{default:()=>C});var r={};a.r(r),a.d(r,{USDZExportAsync:()=>b});var i={};a.r(i),a.d(i,{USDZExportAsync:()=>b});var c=function(){return c=Object.assign||function(t){for(var e,n=1,a=arguments.length;n<a;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},c.apply(this,arguments)};Object.create,Object.create,"function"==typeof SuppressedError&&SuppressedError;var s=a(597);function u(t,e,n){void 0===n&&(n=3);for(var a=[],o=0;o<t.length/n;o++){var r=t[o*n],i=t[o*n+1],c=t[o*n+2];a.push("(".concat(r.toPrecision(e.precision),", ").concat(i.toPrecision(e.precision),", ").concat(c.toPrecision(e.precision),")"))}return a.join(", ")}function l(t,e){for(var n=[],a=0;a<t.length/2;a++){var o=t[2*a],r=t[2*a+1];n.push("(".concat(o.toPrecision(e.precision),", ").concat((1-r).toPrecision(e.precision),")"))}return n.join(", ")}function p(t,e){var n=function(t,e){var n=t.getVerticesData(s.VertexBuffer.PositionKind),a=t.getVerticesData(s.VertexBuffer.PositionKind);if(n&&a)return'\n\tdef Mesh "'.concat("Geometry",'"\n\t{\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=t.getIndices(),n=[];if(null!==e)for(var a=0;a<e.length;a++)n.push(e[a]);else{var o=t.getTotalVertices();for(a=0;a<o;a++)n.push(a)}return n.join(", ")}(t),"]\n\t\tnormal3f[] normals = [").concat(u(a,e),'] (\n\t\t\tinterpolation = "vertex"\n\t\t)\n\t\tpoint3f[] points = [').concat(u(n,e),"]\n ").concat(function(t,e){for(var n="",a=0;a<4;a++){var o=a>0?a:"",r=t.getVerticesData(s.VertexBuffer.UVKind+(o||""));r&&(n+="\n\t\ttexCoord2f[] primvars:st".concat(o," = [").concat(l(r,e),'] (\n\t\t\tinterpolation = "vertex"\n\t\t)'))}var i=t.getVerticesData(s.VertexBuffer.ColorKind);return i&&(n+="\n\tcolor3f[] primvars:displayColor = [".concat(u(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);return'\n def "Geometry"\n {\n '.concat(n,"\n }\n ")}function f(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 d(t){var e=t.m;return"( ".concat(m(e,0),", ").concat(m(e,4),", ").concat(m(e,8),", ").concat(m(e,12)," )")}function m(t,e){return"(".concat(t[e+0],", ").concat(t[e+1],", ").concat(t[e+2],", ").concat(t[e+3],")")}function h(t){var e="Object_"+t.uniqueId,n=t.getWorldMatrix().clone();n.determinant()<0&&n.multiplyToRef(s.Matrix.Scaling(-1,1,1),n);var a=d(n);return'def Xform "'.concat(e,'" (\n\tprepend references = @./geometries/Geometry_').concat(t.geometry.uniqueId,'.usda@</Geometry>\n\tprepend apiSchemas = ["MaterialBindingAPI"]\n)\n{\n\tmatrix4d xformOp:transform = ').concat(a,'\n\tuniform token[] xformOpOrder = ["xformOp:transform"]\t\n\n rel material:binding = </Materials/Material_').concat(t.material.uniqueId,">\n}\n\n")}function g(t){switch(t){case s.Constants.TEXTURE_CLAMP_ADDRESSMODE:return"clamp";case s.Constants.TEXTURE_MIRROR_ADDRESSMODE:return"mirror";case s.Constants.TEXTURE_WRAP_ADDRESSMODE:default:return"repeat"}}function M(t){return"(".concat(t.x,", ").concat(t.y,")")}function v(t){return"(".concat(t.r,", ").concat(t.g,", ").concat(t.b,")")}function x(t,e,n,a,o,r){var i=t.getInternalTexture().uniqueId+"_"+t.invertY;o[i]=t;var c=t.coordinatesIndex>0?"st"+t.coordinatesIndex:"st",u=new s.Vector2(t.uScale,t.vScale),l=new s.Vector2(t.uOffset,t.vOffset),p=t.wAng,f=Math.sin(p),d=Math.cos(p);return l.y=1-l.y-u.y,l.x+=f*u.x,l.y+=(1-d)*u.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(c,'"\n float2 outputs:result\n }\n\n def Shader "Transform2d_').concat(n,'"\n {\n uniform token info:id = "UsdTransform2d"\n token inputs:in.connect = </Materials/Material_').concat(e.uniqueId,"/PrimvarReader_").concat(n,".outputs:result>\n float inputs:rotation = ").concat((p*(180/Math.PI)).toFixed(r.precision),"\n float2 inputs:scale = ").concat(M(u),"\n float2 inputs:translation = ").concat(M(l),'\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(i,".png@\n float2 inputs:st.connect = </Materials/Material_").concat(e.uniqueId,"/Transform2d_").concat(n,".outputs:result>\n ").concat(a?"float4 inputs:scale = "+function(t){return"(".concat(t.r,", ").concat(t.g,", ").concat(t.b,", 1.0)")}(a):"",'\n token inputs:sourceColorSpace = "').concat(t.gammaSpace?"raw":"sRGB",'"\n token inputs:wrapS = "').concat(g(t.wrapU),'"\n token inputs:wrapT = "').concat(g(t.wrapV),'"\n float outputs:r\n float outputs:g\n float outputs:b\n float3 outputs:rgb\n ').concat(e.needAlphaBlending()?"float outputs:a":"","\n }")}function y(t,e,n){var a="\t\t\t",o=[],r=[],i=function(t){switch(t.getClassName()){case"StandardMaterial":return{diffuseMap:t.diffuseTexture,diffuse:t.diffuseColor,alphaCutOff:t.alphaCutOff,emissiveMap:t.emissiveTexture,emissive:t.emissiveColor,roughnessMap:null,normalMap:null,metalnessMap:null,roughness:1,metalness:0,aoMap:null,aoMapIntensity:0,alphaMap:t.opacityTexture,ior:1};case"PBRMaterial":return{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:t.roughness||1,metalnessMap:t.metallicTexture,metalnessChannel:t.useMetallnessFromMetallicTextureBlue?"b":"r",metalness:t.metallic||0,aoMap:t.ambientTexture,aoMapChannel:t.useAmbientInGrayScale?"r":"rgb",aoMapIntensity:t.ambientTextureStrength,alphaMap:t.opacityTexture,ior:t.indexOfRefraction};case"PBRMetallicRoughnessMaterial":return{diffuseMap:t.baseTexture,diffuse:t.baseColor,alphaCutOff:t.alphaCutOff,emissiveMap:t.emissiveTexture,emissive:t.emissiveColor,normalMap:t.normalTexture,roughnessMap:t.metallicTexture,roughnessChannel:t.useRoughnessFromMetallicTextureAlpha?"a":"g",roughness:t.roughness||1,metalnessMap:t.metallicTexture,metalnessChannel:t.useMetallnessFromMetallicTextureBlue?"b":"r",metalness:t.metallic||0,aoMap:t.ambientTexture,aoMapChannel:t.useAmbientInGrayScale?"r":"rgb",aoMapIntensity:t.ambientTextureStrength,alphaMap:t.opacityTexture,ior:t.indexOfRefraction};default:return{diffuseMap:null,diffuse:null,emissiveMap:null,emissemissiveiveColor:null,normalMap:null,roughnessMap:null,metalnessMap:null,alphaCutOff:0,roughness:0,metalness:0,aoMap:null,aoMapIntensity:0,alphaMap:null,ior:1}}}(t),c=i.diffuseMap,u=i.diffuse,l=i.alphaCutOff,p=i.emissiveMap,f=i.emissive,d=i.normalMap,m=i.roughnessMap,h=i.roughnessChannel,g=i.roughness,M=i.metalnessMap,y=i.metalnessChannel,b=i.metalness,T=i.aoMap,_=i.aoMapChannel,C=i.aoMapIntensity,I=i.alphaMap,S=i.ior;return null!==c?(o.push("".concat(a,"color3f inputs:diffuseColor.connect = </Materials/Material_").concat(t.uniqueId,"/Texture_").concat(c.uniqueId,"_diffuse.outputs:rgb>")),t.needAlphaBlending()?o.push("".concat(a,"float inputs:opacity.connect = </Materials/Material_").concat(t.uniqueId,"/Texture_").concat(c.uniqueId,"_diffuse.outputs:a>")):t.needAlphaTesting()&&(o.push("".concat(a,"float inputs:opacity.connect = </Materials/Material_").concat(t.uniqueId,"/Texture_").concat(c.uniqueId,"_diffuse.outputs:a>")),o.push("".concat(a,"float inputs:opacityThreshold = ").concat(l))),r.push(x(c,t,"diffuse",u,e,n))):o.push("".concat(a,"color3f inputs:diffuseColor = ").concat(v(u||s.Color3.White()))),null!==p?(o.push("".concat(a,"color3f inputs:emissiveColor.connect = </Materials/Material_").concat(t.uniqueId,"/Texture_").concat(p.uniqueId,"_emissive.outputs:rgb>")),r.push(x(p,t,"emissive",f,e,n))):f&&f.toLuminance()>0&&o.push("".concat(a,"color3f inputs:emissiveColor = ").concat(v(f))),null!==d&&(o.push("".concat(a,"normal3f inputs:normal.connect = </Materials/Material_").concat(t.uniqueId,"/Texture_").concat(d.uniqueId,"_normal.outputs:rgb>")),r.push(x(d,t,"normal",null,e,n))),null!==T&&(o.push("".concat(a,"float inputs:occlusion.connect = </Materials/Material_").concat(t.uniqueId,"/Texture_").concat(T.uniqueId,"_occlusion.outputs:").concat(_,">")),r.push(x(T,t,"occlusion",new s.Color3(C,C,C),e,n))),null!==m?(o.push("".concat(a,"float inputs:roughness.connect = </Materials/Material_").concat(t.uniqueId,"/Texture_").concat(m.uniqueId,"_roughness.outputs:").concat(h,">")),r.push(x(m,t,"roughness",new s.Color3(g,g,g),e,n))):o.push("".concat(a,"float inputs:roughness = ").concat(g)),null!==M?(o.push("".concat(a,"float inputs:metallic.connect = </Materials/Material_").concat(t.uniqueId,"/Texture_").concat(M.uniqueId,"_metallic.outputs:").concat(y,">")),r.push(x(M,t,"metallic",new s.Color3(b,b,b),e,n))):o.push("".concat(a,"float inputs:metallic = ").concat(b)),null!==I?(o.push("".concat(a,"float inputs:opacity.connect = </Materials/Material_").concat(t.uniqueId,"/Texture_").concat(I.uniqueId,"_opacity.outputs:r>")),o.push("".concat(a,"float inputs:opacityThreshold = 0.0001")),r.push(x(I,t,"opacity",null,e,n))):o.push("".concat(a,"float inputs:opacity = ").concat(t.alpha)),o.push("".concat(a,"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(o.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 = </Materials/Material_").concat(t.uniqueId,"/PreviewSurface.outputs:surface>\n\n").concat(r.join("\n"),"\n\n\t}\n")}function b(t,e,n){return a=this,o=void 0,i=function(){var a,o,r,i,u,l,m,g,M,v,x,b,T,_,C,I,S,O,P,w,A,R,q,j,k,E,D,U;return function(t,e){var n,a,o,r={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=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,a&&(o=2&c[0]?a.return:c[0]?a.throw||((o=a.return)&&o.call(a),0):a.next)&&!(o=o.call(a,c[1])).done)return o;switch(a=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return r.label++,{value:c[1],done:!1};case 5:r.label++,a=c[1],c=[0];continue;case 7:c=r.ops.pop(),r.trys.pop();continue;default:if(!((o=(o=r.trys).length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){r=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){r.label=c[1];break}if(6===c[0]&&r.label<o[1]){r.label=o[1],o=c;break}if(o&&r.label<o[2]){r.label=o[2],r.ops.push(c);break}o[2]&&r.ops.pop(),r.trys.pop();continue}c=e.call(t,r)}catch(t){c=[6,t],a=0}finally{n=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,s])}}}(this,(function(B){switch(B.label){case 0:return a=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,s.Tools.LoadScriptAsync(a.fflateUrl)];case 1:B.sent(),B.label=2;case 2:for((o={})[a.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 ")}(a),i={},u=0,l=t.meshes;u<l.length;u++)0!==(m=l[u]).getTotalVertices()&&(M=(g=m).geometry,(v=g.material)&&M&&(!n||n(g))&&(-1!==["StandardMaterial","PBRMaterial","PBRMetallicRoughnessMaterial"].indexOf(v.getClassName())?((x="geometries/Geometry_"+M.uniqueId+".usda")in o||(b=p(M,a),o[x]=f(b)),v.uniqueId in i||(i[v.uniqueId]=v),r+=h(g)):s.Tools.Warn("USDZExportAsync does not support this material type: "+v.getClassName())));for(I in t.activeCamera&&a.exportCamera&&(r+=function(t,e){var n="Camera_"+t.uniqueId,a=d(s.Matrix.RotationY(Math.PI).multiply(t.getWorldMatrix()));if(t.mode===s.Constants.ORTHOGRAPHIC_CAMERA)return'def Camera "'.concat(n,'"\n\t\t{\n\t\t\tmatrix4d xformOp:transform = ').concat(a,'\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 o=t.getEngine().getAspectRatio(t),r=e.cameraSensorWidth||35;return'def Camera "'.concat(n,'"\n\t\t{\n\t\t\tmatrix4d xformOp:transform = ').concat(a,'\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*o).toPrecision(e.precision),"\n\t\t\tfloat verticalAperture = ").concat((r/o).toPrecision(e.precision)," \n\t\t}\n\t\n\t")}(t.activeCamera,a)),r+="\n }\n }\n }",r+=function(t,e,n){var a=[];for(var o in t){var r=t[o];a.push(y(r,e,n))}return'\n def "Materials"\n{\n'.concat(a.join(""),"\n}\n\n")}(i,T={},a),o[a.modelFileName]=fflate.strToU8(r),C=[],_=T)C.push(I);S=0,B.label=3;case 3:return S<C.length?(I=C[S])in _?(P=T[O=I],w=P.getSize(),[4,P.readPixels()]):[3,6]:[3,7];case 4:if(!(A=B.sent()))throw new Error("Texture data is not available");return[4,s.DumpTools.DumpDataAsync(w.width,w.height,A,"image/png",void 0,!1,!0)];case 5:R=B.sent(),o["textures/Texture_".concat(O,".png")]=new Uint8Array(R).slice(),B.label=6;case 6:return S++,[3,3];case 7:for(j in q=0,o)(k=o[j])&&(E=34+j.length,4!=(D=63&(q+=E))&&(U=new Uint8Array(64-D),o[j]=[k,{extra:{12345:U}}]),q=k.length);return[2,fflate.zipSync(o,{level:0})]}}))},new((r=void 0)||(r=Promise))((function(t,e){function n(t){try{s(i.next(t))}catch(t){e(t)}}function c(t){try{s(i.throw(t))}catch(t){e(t)}}function s(e){var a;e.done?t(e.value):(a=e.value,a instanceof r?a:new r((function(t){t(a)}))).then(n,c)}s((i=i.apply(a,o||[])).next())}));var a,o,r,i}var T=void 0!==a.g?a.g:"undefined"!=typeof window?window:void 0;if(void 0!==T)for(var _ in r)T.BABYLON[_]=r[_];const C=i;return o.default})()));
//# sourceMappingURL=babylon.usdzSerializer.min.js.map
{
"name": "babylonjs-serializers",
"version": "7.53.1",
"version": "7.53.2",
"main": "babylonjs.serializers.js",

@@ -18,4 +18,4 @@ "types": "babylonjs.serializers.module.d.ts",

"dependencies": {
"babylonjs": "^7.53.1",
"babylonjs-gltf2interface": "^7.53.1"
"babylonjs": "^7.53.2",
"babylonjs-gltf2interface": "^7.53.2"
},

@@ -22,0 +22,0 @@ "devDependencies": {

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet