babylonjs-serializers 8.54.3 → 8.55.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/babylon.threemfSerializer.js +1 -1
- package/babylon.threemfSerializer.min.js +1 -1
- package/babylon.threemfSerializer.min.js.map +1 -1
- package/babylonjs.serializers.d.ts +8 -8
- package/babylonjs.serializers.js +1 -1
- package/babylonjs.serializers.min.js +1 -1
- package/babylonjs.serializers.min.js.map +1 -1
- package/babylonjs.serializers.module.d.ts +17 -17
- package/package.json +3 -3
|
@@ -1,2 +1,2 @@
|
|
|
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:()=>Ft});var o={};r.r(o),r.d(o,{AbstractThreeMfSerializer:()=>kt,BjsThreeMfSerializer:()=>Pt,ContentTypeFileName:()=>Y,DefaultXmlSerializerFormatOptions:()=>N,DefaultXmlSerializerNumberOptions:()=>C,GetXmlFieldMeta:()=>T,GetXmlName:()=>M,IsQualifiedName:()=>m,Known3mfRelationshipTypes:()=>tt,KnownI3mfContentType:()=>Q,Matrix3d:()=>at,MatrixFormatter:()=>st,ModelFileName:()=>H,NumberFormatter:()=>D,Object3dDirName:()=>$,OpenXmlContentTypesNamespace:()=>V,OpenXmlRelationshipsNamespace:()=>W,RelationshipDirName:()=>q,RelationshipFileName:()=>J,ResolveFormatOptions:()=>k,ResolveNumberOptions:()=>O,ST_ObjectType:()=>z,ST_Unit:()=>F,StringXmlWriter:()=>K,ThreeDimModelNamespace:()=>U,ThreeMf:()=>Dt,ThreeMfBase:()=>bt,ThreeMfBaseMaterials:()=>wt,ThreeMfBuild:()=>Tt,ThreeMfComponent:()=>gt,ThreeMfComponents:()=>_t,ThreeMfComponentsBuilder:()=>St,ThreeMfContentType:()=>nt,ThreeMfContentTypes:()=>et,ThreeMfDocument:()=>ot,ThreeMfDocumentBuilder:()=>Ot,ThreeMfItem:()=>Mt,ThreeMfMaterialBuilder:()=>Ct,ThreeMfMesh:()=>ft,ThreeMfMeshBuilder:()=>jt,ThreeMfMeta:()=>lt,ThreeMfMetadataGroup:()=>ct,ThreeMfModel:()=>ut,ThreeMfModelBuilder:()=>Nt,ThreeMfObject:()=>ht,ThreeMfObjectBuilder:()=>xt,ThreeMfRelationship:()=>it,ThreeMfRelationships:()=>rt,ThreeMfResources:()=>pt,ThreeMfSerializerGlobalConfiguration:()=>Xt,ThreeMfTriangle:()=>yt,ThreeMfTriangles:()=>vt,ThreeMfVertex:()=>dt,ThreeMfVertices:()=>mt,ToQualifiedString:()=>j,TokenType:()=>B,TriangleSetsNamespace:()=>G,Utf8XmlWriterToBytes:()=>L,XmlAttr:()=>w,XmlBuilder:()=>Z,XmlElem:()=>b,XmlIgnore:()=>g,XmlName:()=>_,XmlNameToParts:()=>S,XmlSerializer:()=>E});var a={};r.r(a),r.d(a,{AbstractThreeMfSerializer:()=>kt,BjsThreeMfSerializer:()=>Pt,ContentTypeFileName:()=>Y,DefaultXmlSerializerFormatOptions:()=>N,DefaultXmlSerializerNumberOptions:()=>C,GetXmlFieldMeta:()=>T,GetXmlName:()=>M,IsQualifiedName:()=>m,Known3mfRelationshipTypes:()=>tt,KnownI3mfContentType:()=>Q,Matrix3d:()=>at,MatrixFormatter:()=>st,ModelFileName:()=>H,NumberFormatter:()=>D,Object3dDirName:()=>$,OpenXmlContentTypesNamespace:()=>V,OpenXmlRelationshipsNamespace:()=>W,RelationshipDirName:()=>q,RelationshipFileName:()=>J,ResolveFormatOptions:()=>k,ResolveNumberOptions:()=>O,ST_ObjectType:()=>z,ST_Unit:()=>F,StringXmlWriter:()=>K,ThreeDimModelNamespace:()=>U,ThreeMf:()=>Dt,ThreeMfBase:()=>bt,ThreeMfBaseMaterials:()=>wt,ThreeMfBuild:()=>Tt,ThreeMfComponent:()=>gt,ThreeMfComponents:()=>_t,ThreeMfComponentsBuilder:()=>St,ThreeMfContentType:()=>nt,ThreeMfContentTypes:()=>et,ThreeMfDocument:()=>ot,ThreeMfDocumentBuilder:()=>Ot,ThreeMfItem:()=>Mt,ThreeMfMaterialBuilder:()=>Ct,ThreeMfMesh:()=>ft,ThreeMfMeshBuilder:()=>jt,ThreeMfMeta:()=>lt,ThreeMfMetadataGroup:()=>ct,ThreeMfModel:()=>ut,ThreeMfModelBuilder:()=>Nt,ThreeMfObject:()=>ht,ThreeMfObjectBuilder:()=>xt,ThreeMfRelationship:()=>it,ThreeMfRelationships:()=>rt,ThreeMfResources:()=>pt,ThreeMfSerializerGlobalConfiguration:()=>Xt,ThreeMfTriangle:()=>yt,ThreeMfTriangles:()=>vt,ThreeMfVertex:()=>dt,ThreeMfVertices:()=>mt,ToQualifiedString:()=>j,TokenType:()=>B,TriangleSetsNamespace:()=>G,Utf8XmlWriterToBytes:()=>L,XmlAttr:()=>w,XmlBuilder:()=>Z,XmlElem:()=>b,XmlIgnore:()=>g,XmlName:()=>_,XmlNameToParts:()=>S,XmlSerializer:()=>E});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 w(t){return function(e,n){return y(e,l({kind:"attr",prop:n},t))}}function b(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"string"==typeof t||"number"==typeof t||"boolean"==typeof t||"bigint"==typeof t||A(t)}function P(t){return"number"==typeof t||"boolean"==typeof t||"bigint"==typeof t||A(t)}var B,E=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];P(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,w=y;g<w.length;g++){var b=null!==(o=(c=w[g]).name)&&void 0!==o?o:c.prop.toLowerCase();if(b&&"attr"===c.kind){var M=null;if("number"==typeof 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(b),C=this._getPrefix(x),N=j(x.name,C);t.att(null,N,M)}}}}else P(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];R(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 w=g.some((function(t){return!0===t.ignore||"none"===t.kind}));if(w)continue;for(var b=0,x=g;b<x.length;b++)(h=x[b]).name&&this._assignNamespace(h.name)}m.push(_)}}for(var S=0,j=m;S<j.length;S++){var C=j[S];R(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}(),I=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"}(B||(B={}));var F,z,Z=function(){function t(t){this._ctxStack=[],this._d=0,this._w=t}return t.prototype.dec=function(t,e,n){return this._w.write(I.Dec),this._writeAttStr(I.VersionKeyword,t),e&&this._writeAttStr(I.EncodingKeyword,e),void 0!==n&&this._writeAttStr(I.StandaloneKeyword,n?"yes":"no"),this._w.write(I.Question,I.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===I.Xmlns)r.defaultNs=n,this._registerNamespace(r,"",n),this._writeAttStr(I.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=B.Attribute,this}var o=e;if(t){var a=this._ensurePrefixDeclared(r,t);o="".concat(a,":").concat(e)}return r.lastToken=B.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(I.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=B.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(I.OpenTag,I.Slash,t.name,I.CloseTag):this._w.write(I.Slash,I.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(I.Space,t,I.Equal,I.Quote,this._escAttr(e),I.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,"&").replace(/</g,"<").replace(/>/g,">")},t.prototype._escAttr=function(t){return this._escText(t).replace(/"/g,""").replace(/'/g,"'")},t.prototype._isXmlnsDecl=function(t,e){if(t)return t===I.Xmlns;var n=e.length,r=I.Xmlns.length;return n>=r&&e.startsWith(I.Xmlns)&&(e.length==r||e[r]==I.Semicolon)},t.prototype._registerNamespace=function(t,e,n){if(e===I.Xml||e===I.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(I.Xmlns,":").concat(r),e),this._registerNamespace(t,r,e),r},t.prototype._closeOpenTagIfNeeded=function(t){t.closed||(this._w.write(I.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}(),K=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}(),L=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}(),U="http://schemas.microsoft.com/3dmanufacturing/core/2015/02",G="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"}(F||(F={})),function(t){t.model="model",t.solidsupport="solidsupport",t.support="support",t.surface="surface",t.other="other"}(z||(z={}));var Q,V="http://schemas.openxmlformats.org/package/2006/content-types",W="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"}(Q||(Q={}));var q="_rels/",$="3D/",H="3dmodel.model",J=".rels",Y="[Content_Types].xml",tt=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}(),et=function(){function t(){this.items=[]}return c([_({ns:V,name:"Types"})],t)}(),nt=function(){function t(t,e){this.ext=t,this.ct=e}return c([w({name:{ns:V,name:"Extension"}})],t.prototype,"ext",void 0),c([w({name:{ns:V,name:"ContentType"}})],t.prototype,"ct",void 0),c([_({ns:V,name:"Default"})],t)}(),rt=function(){function t(){this.items=[]}return c([_({ns:W,name:"Relationships"})],t)}(),it=function(){function t(t,e,n){this.id=t,this.type=e,this.target=n}return c([w({name:"Id"})],t.prototype,"id",void 0),c([w({name:"Type"})],t.prototype,"type",void 0),c([w({name:"Target"})],t.prototype,"target",void 0),c([_({ns:W,name:"Relationship"})],t)}(),ot=function(t,e,n){this.contentTypes=t,this.relationships=e,this.model=n},at=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}(),st=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}(),ut=function(){function t(){this.unit=F.millimeter}return t.KnownMeta=["Title","Designer","Description","Copyright","LicenseTerms","Rating","CreationDate","ModificationDate","Application"],c([w({name:"unit"})],t.prototype,"unit",void 0),c([w({name:"requiredextensions"})],t.prototype,"requiredextensions",void 0),c([w({name:"recommendedextensions"})],t.prototype,"recommendedextensions",void 0),c([_({ns:U,name:"model"})],t)}(),lt=function(){function t(t,e,n,r){this.name=t,this.value=e,this.preserve=n,this.type=r}return c([w({name:"name"})],t.prototype,"name",void 0),c([w({name:"preserve"})],t.prototype,"preserve",void 0),c([w({name:"type"})],t.prototype,"type",void 0),c([_({ns:U,name:"meta"})],t)}(),ct=function(){function t(){this.metadata=[]}return c([_({ns:U,name:"metadatagroup"})],t)}(),pt=function(){function t(){this.object=[]}return c([_({ns:U,name:"resources"})],t)}(),ht=function(){function t(t,e){void 0===e&&(e=z.model),this.id=t,this.type=e}return c([w({name:"id"})],t.prototype,"id",void 0),c([w({name:"type"})],t.prototype,"type",void 0),c([w({name:"thumbnail"})],t.prototype,"thumbnail",void 0),c([w({name:"partnumber"})],t.prototype,"partnumber",void 0),c([w({name:"name"})],t.prototype,"name",void 0),c([w({name:"pid"})],t.prototype,"pid",void 0),c([w({name:"pindex"})],t.prototype,"pindex",void 0),c([_({ns:U,name:"object"})],t)}(),ft=function(){function t(t,e){this.vertices=null!=t?t:new mt,this.triangles=null!=e?e:new vt}return c([_({ns:U,name:"mesh"})],t)}(),mt=function(){function t(){this.vertex=[]}return c([_({ns:U,name:"vertices"})],t)}(),dt=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([w({name:"x"})],t.prototype,"x",void 0),c([w({name:"y"})],t.prototype,"y",void 0),c([w({name:"z"})],t.prototype,"z",void 0),c([_({ns:U,name:"vertex"})],t)}(),vt=function(){function t(){this.triangle=[]}return c([_({ns:U,name:"triangles"})],t)}(),yt=function(){function t(t,e,n){this.v1=t,this.v2=e,this.v3=n}return c([w({name:"v1"})],t.prototype,"v1",void 0),c([w({name:"v2"})],t.prototype,"v2",void 0),c([w({name:"v3"})],t.prototype,"v3",void 0),c([w({name:"p1"})],t.prototype,"p1",void 0),c([w({name:"p2"})],t.prototype,"p2",void 0),c([w({name:"p3"})],t.prototype,"p3",void 0),c([w({name:"pid"})],t.prototype,"pid",void 0),c([_({ns:U,name:"triangle"})],t)}(),_t=function(){function t(){this.component=[]}return c([_({ns:U,name:"components"})],t)}(),gt=function(){function t(t,e){this.objectid=t,this.transform=e}return c([w({name:"objectid"})],t.prototype,"objectid",void 0),c([w({name:"transform",formatter:st})],t.prototype,"transform",void 0),c([_({ns:U,name:"component"})],t)}(),wt=function(){function t(t){this.base=[],this.id=t}return c([w({name:"id"})],t.prototype,"id",void 0),c([_({ns:U,name:"basematerials"})],t)}(),bt=function(){function t(t,e){this.name=t,this.displaycolor=e}return c([w({name:"name"})],t.prototype,"name",void 0),c([w({name:"displaycolor"})],t.prototype,"displaycolor",void 0),c([_({ns:U,name:"base"})],t)}(),Tt=function(){function t(){this.item=[]}return c([_({ns:U,name:"build"})],t)}(),Mt=function(){function t(t,e,n){this.objectid=t,this.transform=e,this.partnumber=n}return c([w({name:"objectid"})],t.prototype,"objectid",void 0),c([w({name:"transform",formatter:st})],t.prototype,"transform",void 0),c([w({name:"partnumber"})],t.prototype,"partnumber",void 0),c([_({ns:U,name:"item"})],t)}(),xt=function(){function t(t,e){this._object=new ht(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 ht(t,e)},t}(),St=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 _t,r}return u(e,t),e.prototype.withComponent=function(t,e){return this._object.content.component.push(new gt(t,e)),this},e}(xt),jt=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 ft(e,n)},e.prototype._buildVertices=function(t){var e=new mt;if(t)for(var n=0;n<t.length;){var r=t[n++],i=t[n++],o=t[n++],a=new dt(r,i,o);this._vh&&(a=this._vh(a)),e.vertex.push(a)}return e},e.prototype._buildTriangle=function(t){var e=new vt;if(t)for(var n=0;n<t.length;){var r=t[n++],i=t[n++],o=t[n++],a=new yt(r,i,o);this._th&&(a=this._th(a)),e.triangle.push(a)}return e},e}(xt),Ct=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 bt(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}(),Nt=function(){function t(){this._model=new ut,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 lt(t,e,n,r)),this},t.prototype.withMaterial=function(t){var e,n;return t instanceof Ct&&(t=t.build()),t&&(this._model.resources=null!==(e=this._model.resources)&&void 0!==e?e:new pt,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 jt&&(t=t.build()),this._model.resources=null!==(e=this._model.resources)&&void 0!==e?e:new pt,this._model.resources.object.push(t),this},t.prototype.withComponents=function(t){var e;return t instanceof St&&(t=t.build()),this._model.resources=null!==(e=this._model.resources)&&void 0!==e?e:new pt,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 Tt,null===(i=this._model.build.item)||void 0===i||i.push(new Mt(t,e,n)),this},t.prototype.withUnit=function(t){return this._model.unit=t,this},t.prototype.reset=function(){return this._model=new ut,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(ut.KnownMeta.map((function(t){return t.toLowerCase()}))),t}(),Ot=function(){function t(){}return t.prototype.withContentType=function(t){this._cts||(this._cts=new et);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 rt);var e=this._rs.items;return e.some((function(e){return e.id===t.id}))||e.push(t),this.withContentType(new nt("rels",Q.Relationships)),this},t.prototype.withModel=function(t){return t instanceof Nt&&(t=t.build()),this._m=t,this.withContentType(new nt("model",Q.Model)),this},t.prototype.build=function(){if(!this._m)throw new Error("Invalid state: you Must provide at least a model.");var t="".concat($).concat(H);if(!this._rs){var e="/".concat(t);this.withRelationship(new it("rel".concat(0),tt.ThreeDimModel,e))}return new ot(this._cts,this._rs,this._m)},t}(),kt=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 L(a),u=new Z(s).dec("1.0","UTF-8");new E(u).serialize(n),s.finish()},(s=this.toDocument.apply(this,e))?(u=new r(t),a(u,Y,s.contentTypes),a(u,"".concat(q).concat(J),s.relationships),a(u,"".concat($).concat(H),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 Nt).withUnit(null!==(e=null===(t=this._o)||void 0===t?void 0:t.unit)&&void 0!==e?e:F.millimeter);if(this.options.metadata)for(var o in this.options.metadata)i.withMetaData(o,this.options.metadata[o]);return(new Ot).withModel(this.toModel.apply(this,f([i],n,!1))).build()},t}(),Dt=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}(),At=r(597),Xt=function(){function t(){}return t.FFLATEUrl="https://unpkg.com/fflate@0.8.2",t}(),Rt=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}(),Pt=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 At.Mesh||t instanceof At.InstancedMesh}));for(var r=new Rt,i=t,o=new Map,a=this.options.exportInstances?[]:null,s=0;s<e.length;s++){var u=e[s];if(u instanceof At.InstancedMesh)null==a||a.push(u);else{var l=u.name||"mesh".concat(s),c=u.getWorldMatrix(),p=this._handleBjsTo3mfMatrixTransformToRef(c,at.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 jt(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,w=Array.from(_.entries());g<w.length;g++){var b=w[g],T=b[0],M=b[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._handleBjsTo3mfMatrixTransformToRef(c,at.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,At.Tools.LoadScriptAsync(Xt.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._handleBjsTo3mfMatrixTransformToRef=function(t,n){var r=t.multiplyToRef(e._R_BJS_TO_3MF,At.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:F.meter,exportInstances:!1},e._PositionKind="position",e._R_BJS_TO_3MF=At.Matrix.RotationX(Math.PI/2).multiply(At.Matrix.Scaling(1,-1,1)),e}(kt),Bt=void 0!==r.g?r.g:"undefined"!=typeof window?window:void 0;if(void 0!==Bt){var Et=[];for(var It in o)Et.indexOf(It)>-1||(Bt.BABYLON[It]=o[It],Et.push(It))}const Ft=a;return i.default})()));
|
|
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:()=>Ft});var o={};r.r(o),r.d(o,{AbstractThreeMfSerializer:()=>kt,ContentTypeFileName:()=>Y,DefaultXmlSerializerFormatOptions:()=>N,DefaultXmlSerializerNumberOptions:()=>C,GetXmlFieldMeta:()=>T,GetXmlName:()=>M,IsQualifiedName:()=>m,Known3mfRelationshipTypes:()=>tt,KnownI3mfContentType:()=>Q,Matrix3d:()=>at,MatrixFormatter:()=>st,ModelFileName:()=>H,NumberFormatter:()=>D,Object3dDirName:()=>$,OpenXmlContentTypesNamespace:()=>V,OpenXmlRelationshipsNamespace:()=>W,RelationshipDirName:()=>q,RelationshipFileName:()=>J,ResolveFormatOptions:()=>k,ResolveNumberOptions:()=>O,ST_ObjectType:()=>z,ST_Unit:()=>F,StringXmlWriter:()=>K,ThreeDimModelNamespace:()=>U,ThreeMf:()=>Dt,ThreeMfBase:()=>wt,ThreeMfBaseMaterials:()=>bt,ThreeMfBuild:()=>Tt,ThreeMfComponent:()=>gt,ThreeMfComponents:()=>_t,ThreeMfComponentsBuilder:()=>St,ThreeMfContentType:()=>nt,ThreeMfContentTypes:()=>et,ThreeMfDocument:()=>ot,ThreeMfDocumentBuilder:()=>Ot,ThreeMfItem:()=>Mt,ThreeMfMaterialBuilder:()=>Ct,ThreeMfMesh:()=>ft,ThreeMfMeshBuilder:()=>jt,ThreeMfMeta:()=>lt,ThreeMfMetadataGroup:()=>ct,ThreeMfModel:()=>ut,ThreeMfModelBuilder:()=>Nt,ThreeMfObject:()=>ht,ThreeMfObjectBuilder:()=>xt,ThreeMfRelationship:()=>it,ThreeMfRelationships:()=>rt,ThreeMfResources:()=>pt,ThreeMfSerializer:()=>Pt,ThreeMfSerializerGlobalConfiguration:()=>Xt,ThreeMfTriangle:()=>yt,ThreeMfTriangles:()=>vt,ThreeMfVertex:()=>dt,ThreeMfVertices:()=>mt,ToQualifiedString:()=>j,TokenType:()=>B,TriangleSetsNamespace:()=>G,Utf8XmlWriterToBytes:()=>L,XmlAttr:()=>b,XmlBuilder:()=>Z,XmlElem:()=>w,XmlIgnore:()=>g,XmlName:()=>_,XmlNameToParts:()=>S,XmlSerializer:()=>E});var a={};r.r(a),r.d(a,{AbstractThreeMfSerializer:()=>kt,ContentTypeFileName:()=>Y,DefaultXmlSerializerFormatOptions:()=>N,DefaultXmlSerializerNumberOptions:()=>C,GetXmlFieldMeta:()=>T,GetXmlName:()=>M,IsQualifiedName:()=>m,Known3mfRelationshipTypes:()=>tt,KnownI3mfContentType:()=>Q,Matrix3d:()=>at,MatrixFormatter:()=>st,ModelFileName:()=>H,NumberFormatter:()=>D,Object3dDirName:()=>$,OpenXmlContentTypesNamespace:()=>V,OpenXmlRelationshipsNamespace:()=>W,RelationshipDirName:()=>q,RelationshipFileName:()=>J,ResolveFormatOptions:()=>k,ResolveNumberOptions:()=>O,ST_ObjectType:()=>z,ST_Unit:()=>F,StringXmlWriter:()=>K,ThreeDimModelNamespace:()=>U,ThreeMf:()=>Dt,ThreeMfBase:()=>wt,ThreeMfBaseMaterials:()=>bt,ThreeMfBuild:()=>Tt,ThreeMfComponent:()=>gt,ThreeMfComponents:()=>_t,ThreeMfComponentsBuilder:()=>St,ThreeMfContentType:()=>nt,ThreeMfContentTypes:()=>et,ThreeMfDocument:()=>ot,ThreeMfDocumentBuilder:()=>Ot,ThreeMfItem:()=>Mt,ThreeMfMaterialBuilder:()=>Ct,ThreeMfMesh:()=>ft,ThreeMfMeshBuilder:()=>jt,ThreeMfMeta:()=>lt,ThreeMfMetadataGroup:()=>ct,ThreeMfModel:()=>ut,ThreeMfModelBuilder:()=>Nt,ThreeMfObject:()=>ht,ThreeMfObjectBuilder:()=>xt,ThreeMfRelationship:()=>it,ThreeMfRelationships:()=>rt,ThreeMfResources:()=>pt,ThreeMfSerializer:()=>Pt,ThreeMfSerializerGlobalConfiguration:()=>Xt,ThreeMfTriangle:()=>yt,ThreeMfTriangles:()=>vt,ThreeMfVertex:()=>dt,ThreeMfVertices:()=>mt,ToQualifiedString:()=>j,TokenType:()=>B,TriangleSetsNamespace:()=>G,Utf8XmlWriterToBytes:()=>L,XmlAttr:()=>b,XmlBuilder:()=>Z,XmlElem:()=>w,XmlIgnore:()=>g,XmlName:()=>_,XmlNameToParts:()=>S,XmlSerializer:()=>E});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"string"==typeof t||"number"==typeof t||"boolean"==typeof t||"bigint"==typeof t||A(t)}function P(t){return"number"==typeof t||"boolean"==typeof t||"bigint"==typeof t||A(t)}var B,E=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];P(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("number"==typeof 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 P(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];R(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];R(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}(),I=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"}(B||(B={}));var F,z,Z=function(){function t(t){this._ctxStack=[],this._d=0,this._w=t}return t.prototype.dec=function(t,e,n){return this._w.write(I.Dec),this._writeAttStr(I.VersionKeyword,t),e&&this._writeAttStr(I.EncodingKeyword,e),void 0!==n&&this._writeAttStr(I.StandaloneKeyword,n?"yes":"no"),this._w.write(I.Question,I.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===I.Xmlns)r.defaultNs=n,this._registerNamespace(r,"",n),this._writeAttStr(I.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=B.Attribute,this}var o=e;if(t){var a=this._ensurePrefixDeclared(r,t);o="".concat(a,":").concat(e)}return r.lastToken=B.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(I.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=B.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(I.OpenTag,I.Slash,t.name,I.CloseTag):this._w.write(I.Slash,I.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(I.Space,t,I.Equal,I.Quote,this._escAttr(e),I.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,"&").replace(/</g,"<").replace(/>/g,">")},t.prototype._escAttr=function(t){return this._escText(t).replace(/"/g,""").replace(/'/g,"'")},t.prototype._isXmlnsDecl=function(t,e){if(t)return t===I.Xmlns;var n=e.length,r=I.Xmlns.length;return n>=r&&e.startsWith(I.Xmlns)&&(e.length==r||e[r]==I.Semicolon)},t.prototype._registerNamespace=function(t,e,n){if(e===I.Xml||e===I.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(I.Xmlns,":").concat(r),e),this._registerNamespace(t,r,e),r},t.prototype._closeOpenTagIfNeeded=function(t){t.closed||(this._w.write(I.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}(),K=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}(),L=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}(),U="http://schemas.microsoft.com/3dmanufacturing/core/2015/02",G="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"}(F||(F={})),function(t){t.model="model",t.solidsupport="solidsupport",t.support="support",t.surface="surface",t.other="other"}(z||(z={}));var Q,V="http://schemas.openxmlformats.org/package/2006/content-types",W="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"}(Q||(Q={}));var q="_rels/",$="3D/",H="3dmodel.model",J=".rels",Y="[Content_Types].xml",tt=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}(),et=function(){function t(){this.items=[]}return c([_({ns:V,name:"Types"})],t)}(),nt=function(){function t(t,e){this.ext=t,this.ct=e}return c([b({name:{ns:V,name:"Extension"}})],t.prototype,"ext",void 0),c([b({name:{ns:V,name:"ContentType"}})],t.prototype,"ct",void 0),c([_({ns:V,name:"Default"})],t)}(),rt=function(){function t(){this.items=[]}return c([_({ns:W,name:"Relationships"})],t)}(),it=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:W,name:"Relationship"})],t)}(),ot=function(t,e,n){this.contentTypes=t,this.relationships=e,this.model=n},at=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}(),st=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}(),ut=function(){function t(){this.unit=F.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:U,name:"model"})],t)}(),lt=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:U,name:"meta"})],t)}(),ct=function(){function t(){this.metadata=[]}return c([_({ns:U,name:"metadatagroup"})],t)}(),pt=function(){function t(){this.object=[]}return c([_({ns:U,name:"resources"})],t)}(),ht=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:U,name:"object"})],t)}(),ft=function(){function t(t,e){this.vertices=null!=t?t:new mt,this.triangles=null!=e?e:new vt}return c([_({ns:U,name:"mesh"})],t)}(),mt=function(){function t(){this.vertex=[]}return c([_({ns:U,name:"vertices"})],t)}(),dt=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:U,name:"vertex"})],t)}(),vt=function(){function t(){this.triangle=[]}return c([_({ns:U,name:"triangles"})],t)}(),yt=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:U,name:"triangle"})],t)}(),_t=function(){function t(){this.component=[]}return c([_({ns:U,name:"components"})],t)}(),gt=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:st})],t.prototype,"transform",void 0),c([_({ns:U,name:"component"})],t)}(),bt=function(){function t(t){this.base=[],this.id=t}return c([b({name:"id"})],t.prototype,"id",void 0),c([_({ns:U,name:"basematerials"})],t)}(),wt=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:U,name:"base"})],t)}(),Tt=function(){function t(){this.item=[]}return c([_({ns:U,name:"build"})],t)}(),Mt=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:st})],t.prototype,"transform",void 0),c([b({name:"partnumber"})],t.prototype,"partnumber",void 0),c([_({ns:U,name:"item"})],t)}(),xt=function(){function t(t,e){this._object=new ht(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 ht(t,e)},t}(),St=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 _t,r}return u(e,t),e.prototype.withComponent=function(t,e){return this._object.content.component.push(new gt(t,e)),this},e}(xt),jt=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 ft(e,n)},e.prototype._buildVertices=function(t){var e=new mt;if(t)for(var n=0;n<t.length;){var r=t[n++],i=t[n++],o=t[n++],a=new dt(r,i,o);this._vh&&(a=this._vh(a)),e.vertex.push(a)}return e},e.prototype._buildTriangle=function(t){var e=new vt;if(t)for(var n=0;n<t.length;){var r=t[n++],i=t[n++],o=t[n++],a=new yt(r,i,o);this._th&&(a=this._th(a)),e.triangle.push(a)}return e},e}(xt),Ct=function(){function t(t){this._m=new bt(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 wt(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}(),Nt=function(){function t(){this._model=new ut,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 lt(t,e,n,r)),this},t.prototype.withMaterial=function(t){var e,n;return t instanceof Ct&&(t=t.build()),t&&(this._model.resources=null!==(e=this._model.resources)&&void 0!==e?e:new pt,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 jt&&(t=t.build()),this._model.resources=null!==(e=this._model.resources)&&void 0!==e?e:new pt,this._model.resources.object.push(t),this},t.prototype.withComponents=function(t){var e;return t instanceof St&&(t=t.build()),this._model.resources=null!==(e=this._model.resources)&&void 0!==e?e:new pt,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 Tt,null===(i=this._model.build.item)||void 0===i||i.push(new Mt(t,e,n)),this},t.prototype.withUnit=function(t){return this._model.unit=t,this},t.prototype.reset=function(){return this._model=new ut,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(ut.KnownMeta.map((function(t){return t.toLowerCase()}))),t}(),Ot=function(){function t(){}return t.prototype.withContentType=function(t){this._cts||(this._cts=new et);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 rt);var e=this._rs.items;return e.some((function(e){return e.id===t.id}))||e.push(t),this.withContentType(new nt("rels",Q.Relationships)),this},t.prototype.withModel=function(t){return t instanceof Nt&&(t=t.build()),this._m=t,this.withContentType(new nt("model",Q.Model)),this},t.prototype.build=function(){if(!this._m)throw new Error("Invalid state: you Must provide at least a model.");var t="".concat($).concat(H);if(!this._rs){var e="/".concat(t);this.withRelationship(new it("rel".concat(0),tt.ThreeDimModel,e))}return new ot(this._cts,this._rs,this._m)},t}(),kt=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 L(a),u=new Z(s).dec("1.0","UTF-8");new E(u).serialize(n),s.finish()},(s=this.toDocument.apply(this,e))?(u=new r(t),a(u,Y,s.contentTypes),a(u,"".concat(q).concat(J),s.relationships),a(u,"".concat($).concat(H),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 Nt).withUnit(null!==(e=null===(t=this._o)||void 0===t?void 0:t.unit)&&void 0!==e?e:F.millimeter);if(this.options.metadata)for(var o in this.options.metadata)i.withMetaData(o,this.options.metadata[o]);return(new Ot).withModel(this.toModel.apply(this,f([i],n,!1))).build()},t}(),Dt=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}(),At=r(597),Xt=function(){function t(){}return t.FFLATEUrl="https://unpkg.com/fflate@0.8.2",t}(),Rt=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}(),Pt=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 At.Mesh||t instanceof At.InstancedMesh}));for(var r=new Rt,i=t,o=new Map,a=this.options.exportInstances?[]:null,s=0;s<e.length;s++){var u=e[s];if(u instanceof At.InstancedMesh)null==a||a.push(u);else{var l=u.name||"mesh".concat(s),c=u.getWorldMatrix(),p=this._handleBabylonTo3mfMatrixTransformToRef(c,at.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 jt(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,at.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,At.Tools.LoadScriptAsync(Xt.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,At.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:F.meter,exportInstances:!1},e._PositionKind="position",e._R_BJS_TO_3MF=At.Matrix.RotationX(Math.PI/2).multiply(At.Matrix.Scaling(1,-1,1)),e}(kt),Bt=void 0!==r.g?r.g:"undefined"!=typeof window?window:void 0;if(void 0!==Bt){var Et=[];for(var It in o)Et.indexOf(It)>-1||(Bt.BABYLON[It]=o[It],Et.push(It))}const Ft=a;return i.default})()));
|
|
2
2
|
//# sourceMappingURL=babylon.threemfSerializer.min.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
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:()=>Ft});var o={};r.r(o),r.d(o,{AbstractThreeMfSerializer:()=>kt,BjsThreeMfSerializer:()=>Pt,ContentTypeFileName:()=>Y,DefaultXmlSerializerFormatOptions:()=>N,DefaultXmlSerializerNumberOptions:()=>C,GetXmlFieldMeta:()=>T,GetXmlName:()=>M,IsQualifiedName:()=>m,Known3mfRelationshipTypes:()=>tt,KnownI3mfContentType:()=>Q,Matrix3d:()=>at,MatrixFormatter:()=>st,ModelFileName:()=>H,NumberFormatter:()=>D,Object3dDirName:()=>$,OpenXmlContentTypesNamespace:()=>V,OpenXmlRelationshipsNamespace:()=>W,RelationshipDirName:()=>q,RelationshipFileName:()=>J,ResolveFormatOptions:()=>k,ResolveNumberOptions:()=>O,ST_ObjectType:()=>z,ST_Unit:()=>F,StringXmlWriter:()=>K,ThreeDimModelNamespace:()=>U,ThreeMf:()=>Dt,ThreeMfBase:()=>bt,ThreeMfBaseMaterials:()=>wt,ThreeMfBuild:()=>Tt,ThreeMfComponent:()=>gt,ThreeMfComponents:()=>_t,ThreeMfComponentsBuilder:()=>St,ThreeMfContentType:()=>nt,ThreeMfContentTypes:()=>et,ThreeMfDocument:()=>ot,ThreeMfDocumentBuilder:()=>Ot,ThreeMfItem:()=>Mt,ThreeMfMaterialBuilder:()=>Ct,ThreeMfMesh:()=>ft,ThreeMfMeshBuilder:()=>jt,ThreeMfMeta:()=>lt,ThreeMfMetadataGroup:()=>ct,ThreeMfModel:()=>ut,ThreeMfModelBuilder:()=>Nt,ThreeMfObject:()=>ht,ThreeMfObjectBuilder:()=>xt,ThreeMfRelationship:()=>it,ThreeMfRelationships:()=>rt,ThreeMfResources:()=>pt,ThreeMfSerializerGlobalConfiguration:()=>Xt,ThreeMfTriangle:()=>yt,ThreeMfTriangles:()=>vt,ThreeMfVertex:()=>dt,ThreeMfVertices:()=>mt,ToQualifiedString:()=>j,TokenType:()=>B,TriangleSetsNamespace:()=>G,Utf8XmlWriterToBytes:()=>L,XmlAttr:()=>w,XmlBuilder:()=>Z,XmlElem:()=>b,XmlIgnore:()=>g,XmlName:()=>_,XmlNameToParts:()=>S,XmlSerializer:()=>E});var a={};r.r(a),r.d(a,{AbstractThreeMfSerializer:()=>kt,BjsThreeMfSerializer:()=>Pt,ContentTypeFileName:()=>Y,DefaultXmlSerializerFormatOptions:()=>N,DefaultXmlSerializerNumberOptions:()=>C,GetXmlFieldMeta:()=>T,GetXmlName:()=>M,IsQualifiedName:()=>m,Known3mfRelationshipTypes:()=>tt,KnownI3mfContentType:()=>Q,Matrix3d:()=>at,MatrixFormatter:()=>st,ModelFileName:()=>H,NumberFormatter:()=>D,Object3dDirName:()=>$,OpenXmlContentTypesNamespace:()=>V,OpenXmlRelationshipsNamespace:()=>W,RelationshipDirName:()=>q,RelationshipFileName:()=>J,ResolveFormatOptions:()=>k,ResolveNumberOptions:()=>O,ST_ObjectType:()=>z,ST_Unit:()=>F,StringXmlWriter:()=>K,ThreeDimModelNamespace:()=>U,ThreeMf:()=>Dt,ThreeMfBase:()=>bt,ThreeMfBaseMaterials:()=>wt,ThreeMfBuild:()=>Tt,ThreeMfComponent:()=>gt,ThreeMfComponents:()=>_t,ThreeMfComponentsBuilder:()=>St,ThreeMfContentType:()=>nt,ThreeMfContentTypes:()=>et,ThreeMfDocument:()=>ot,ThreeMfDocumentBuilder:()=>Ot,ThreeMfItem:()=>Mt,ThreeMfMaterialBuilder:()=>Ct,ThreeMfMesh:()=>ft,ThreeMfMeshBuilder:()=>jt,ThreeMfMeta:()=>lt,ThreeMfMetadataGroup:()=>ct,ThreeMfModel:()=>ut,ThreeMfModelBuilder:()=>Nt,ThreeMfObject:()=>ht,ThreeMfObjectBuilder:()=>xt,ThreeMfRelationship:()=>it,ThreeMfRelationships:()=>rt,ThreeMfResources:()=>pt,ThreeMfSerializerGlobalConfiguration:()=>Xt,ThreeMfTriangle:()=>yt,ThreeMfTriangles:()=>vt,ThreeMfVertex:()=>dt,ThreeMfVertices:()=>mt,ToQualifiedString:()=>j,TokenType:()=>B,TriangleSetsNamespace:()=>G,Utf8XmlWriterToBytes:()=>L,XmlAttr:()=>w,XmlBuilder:()=>Z,XmlElem:()=>b,XmlIgnore:()=>g,XmlName:()=>_,XmlNameToParts:()=>S,XmlSerializer:()=>E});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 w(t){return function(e,n){return y(e,l({kind:"attr",prop:n},t))}}function b(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"string"==typeof t||"number"==typeof t||"boolean"==typeof t||"bigint"==typeof t||A(t)}function P(t){return"number"==typeof t||"boolean"==typeof t||"bigint"==typeof t||A(t)}var B,E=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];P(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,w=y;g<w.length;g++){var b=null!==(o=(c=w[g]).name)&&void 0!==o?o:c.prop.toLowerCase();if(b&&"attr"===c.kind){var M=null;if("number"==typeof 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(b),C=this._getPrefix(x),N=j(x.name,C);t.att(null,N,M)}}}}else P(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];R(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 w=g.some((function(t){return!0===t.ignore||"none"===t.kind}));if(w)continue;for(var b=0,x=g;b<x.length;b++)(h=x[b]).name&&this._assignNamespace(h.name)}m.push(_)}}for(var S=0,j=m;S<j.length;S++){var C=j[S];R(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}(),I=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"}(B||(B={}));var F,z,Z=function(){function t(t){this._ctxStack=[],this._d=0,this._w=t}return t.prototype.dec=function(t,e,n){return this._w.write(I.Dec),this._writeAttStr(I.VersionKeyword,t),e&&this._writeAttStr(I.EncodingKeyword,e),void 0!==n&&this._writeAttStr(I.StandaloneKeyword,n?"yes":"no"),this._w.write(I.Question,I.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===I.Xmlns)r.defaultNs=n,this._registerNamespace(r,"",n),this._writeAttStr(I.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=B.Attribute,this}var o=e;if(t){var a=this._ensurePrefixDeclared(r,t);o="".concat(a,":").concat(e)}return r.lastToken=B.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(I.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=B.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(I.OpenTag,I.Slash,t.name,I.CloseTag):this._w.write(I.Slash,I.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(I.Space,t,I.Equal,I.Quote,this._escAttr(e),I.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,"&").replace(/</g,"<").replace(/>/g,">")},t.prototype._escAttr=function(t){return this._escText(t).replace(/"/g,""").replace(/'/g,"'")},t.prototype._isXmlnsDecl=function(t,e){if(t)return t===I.Xmlns;var n=e.length,r=I.Xmlns.length;return n>=r&&e.startsWith(I.Xmlns)&&(e.length==r||e[r]==I.Semicolon)},t.prototype._registerNamespace=function(t,e,n){if(e===I.Xml||e===I.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(I.Xmlns,":").concat(r),e),this._registerNamespace(t,r,e),r},t.prototype._closeOpenTagIfNeeded=function(t){t.closed||(this._w.write(I.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}(),K=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}(),L=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}(),U="http://schemas.microsoft.com/3dmanufacturing/core/2015/02",G="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"}(F||(F={})),function(t){t.model="model",t.solidsupport="solidsupport",t.support="support",t.surface="surface",t.other="other"}(z||(z={}));var Q,V="http://schemas.openxmlformats.org/package/2006/content-types",W="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"}(Q||(Q={}));var q="_rels/",$="3D/",H="3dmodel.model",J=".rels",Y="[Content_Types].xml",tt=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}(),et=function(){function t(){this.items=[]}return c([_({ns:V,name:"Types"})],t)}(),nt=function(){function t(t,e){this.ext=t,this.ct=e}return c([w({name:{ns:V,name:"Extension"}})],t.prototype,"ext",void 0),c([w({name:{ns:V,name:"ContentType"}})],t.prototype,"ct",void 0),c([_({ns:V,name:"Default"})],t)}(),rt=function(){function t(){this.items=[]}return c([_({ns:W,name:"Relationships"})],t)}(),it=function(){function t(t,e,n){this.id=t,this.type=e,this.target=n}return c([w({name:"Id"})],t.prototype,"id",void 0),c([w({name:"Type"})],t.prototype,"type",void 0),c([w({name:"Target"})],t.prototype,"target",void 0),c([_({ns:W,name:"Relationship"})],t)}(),ot=function(t,e,n){this.contentTypes=t,this.relationships=e,this.model=n},at=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}(),st=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}(),ut=function(){function t(){this.unit=F.millimeter}return t.KnownMeta=["Title","Designer","Description","Copyright","LicenseTerms","Rating","CreationDate","ModificationDate","Application"],c([w({name:"unit"})],t.prototype,"unit",void 0),c([w({name:"requiredextensions"})],t.prototype,"requiredextensions",void 0),c([w({name:"recommendedextensions"})],t.prototype,"recommendedextensions",void 0),c([_({ns:U,name:"model"})],t)}(),lt=function(){function t(t,e,n,r){this.name=t,this.value=e,this.preserve=n,this.type=r}return c([w({name:"name"})],t.prototype,"name",void 0),c([w({name:"preserve"})],t.prototype,"preserve",void 0),c([w({name:"type"})],t.prototype,"type",void 0),c([_({ns:U,name:"meta"})],t)}(),ct=function(){function t(){this.metadata=[]}return c([_({ns:U,name:"metadatagroup"})],t)}(),pt=function(){function t(){this.object=[]}return c([_({ns:U,name:"resources"})],t)}(),ht=function(){function t(t,e){void 0===e&&(e=z.model),this.id=t,this.type=e}return c([w({name:"id"})],t.prototype,"id",void 0),c([w({name:"type"})],t.prototype,"type",void 0),c([w({name:"thumbnail"})],t.prototype,"thumbnail",void 0),c([w({name:"partnumber"})],t.prototype,"partnumber",void 0),c([w({name:"name"})],t.prototype,"name",void 0),c([w({name:"pid"})],t.prototype,"pid",void 0),c([w({name:"pindex"})],t.prototype,"pindex",void 0),c([_({ns:U,name:"object"})],t)}(),ft=function(){function t(t,e){this.vertices=null!=t?t:new mt,this.triangles=null!=e?e:new vt}return c([_({ns:U,name:"mesh"})],t)}(),mt=function(){function t(){this.vertex=[]}return c([_({ns:U,name:"vertices"})],t)}(),dt=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([w({name:"x"})],t.prototype,"x",void 0),c([w({name:"y"})],t.prototype,"y",void 0),c([w({name:"z"})],t.prototype,"z",void 0),c([_({ns:U,name:"vertex"})],t)}(),vt=function(){function t(){this.triangle=[]}return c([_({ns:U,name:"triangles"})],t)}(),yt=function(){function t(t,e,n){this.v1=t,this.v2=e,this.v3=n}return c([w({name:"v1"})],t.prototype,"v1",void 0),c([w({name:"v2"})],t.prototype,"v2",void 0),c([w({name:"v3"})],t.prototype,"v3",void 0),c([w({name:"p1"})],t.prototype,"p1",void 0),c([w({name:"p2"})],t.prototype,"p2",void 0),c([w({name:"p3"})],t.prototype,"p3",void 0),c([w({name:"pid"})],t.prototype,"pid",void 0),c([_({ns:U,name:"triangle"})],t)}(),_t=function(){function t(){this.component=[]}return c([_({ns:U,name:"components"})],t)}(),gt=function(){function t(t,e){this.objectid=t,this.transform=e}return c([w({name:"objectid"})],t.prototype,"objectid",void 0),c([w({name:"transform",formatter:st})],t.prototype,"transform",void 0),c([_({ns:U,name:"component"})],t)}(),wt=function(){function t(t){this.base=[],this.id=t}return c([w({name:"id"})],t.prototype,"id",void 0),c([_({ns:U,name:"basematerials"})],t)}(),bt=function(){function t(t,e){this.name=t,this.displaycolor=e}return c([w({name:"name"})],t.prototype,"name",void 0),c([w({name:"displaycolor"})],t.prototype,"displaycolor",void 0),c([_({ns:U,name:"base"})],t)}(),Tt=function(){function t(){this.item=[]}return c([_({ns:U,name:"build"})],t)}(),Mt=function(){function t(t,e,n){this.objectid=t,this.transform=e,this.partnumber=n}return c([w({name:"objectid"})],t.prototype,"objectid",void 0),c([w({name:"transform",formatter:st})],t.prototype,"transform",void 0),c([w({name:"partnumber"})],t.prototype,"partnumber",void 0),c([_({ns:U,name:"item"})],t)}(),xt=function(){function t(t,e){this._object=new ht(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 ht(t,e)},t}(),St=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 _t,r}return u(e,t),e.prototype.withComponent=function(t,e){return this._object.content.component.push(new gt(t,e)),this},e}(xt),jt=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 ft(e,n)},e.prototype._buildVertices=function(t){var e=new mt;if(t)for(var n=0;n<t.length;){var r=t[n++],i=t[n++],o=t[n++],a=new dt(r,i,o);this._vh&&(a=this._vh(a)),e.vertex.push(a)}return e},e.prototype._buildTriangle=function(t){var e=new vt;if(t)for(var n=0;n<t.length;){var r=t[n++],i=t[n++],o=t[n++],a=new yt(r,i,o);this._th&&(a=this._th(a)),e.triangle.push(a)}return e},e}(xt),Ct=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 bt(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}(),Nt=function(){function t(){this._model=new ut,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 lt(t,e,n,r)),this},t.prototype.withMaterial=function(t){var e,n;return t instanceof Ct&&(t=t.build()),t&&(this._model.resources=null!==(e=this._model.resources)&&void 0!==e?e:new pt,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 jt&&(t=t.build()),this._model.resources=null!==(e=this._model.resources)&&void 0!==e?e:new pt,this._model.resources.object.push(t),this},t.prototype.withComponents=function(t){var e;return t instanceof St&&(t=t.build()),this._model.resources=null!==(e=this._model.resources)&&void 0!==e?e:new pt,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 Tt,null===(i=this._model.build.item)||void 0===i||i.push(new Mt(t,e,n)),this},t.prototype.withUnit=function(t){return this._model.unit=t,this},t.prototype.reset=function(){return this._model=new ut,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(ut.KnownMeta.map((function(t){return t.toLowerCase()}))),t}(),Ot=function(){function t(){}return t.prototype.withContentType=function(t){this._cts||(this._cts=new et);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 rt);var e=this._rs.items;return e.some((function(e){return e.id===t.id}))||e.push(t),this.withContentType(new nt("rels",Q.Relationships)),this},t.prototype.withModel=function(t){return t instanceof Nt&&(t=t.build()),this._m=t,this.withContentType(new nt("model",Q.Model)),this},t.prototype.build=function(){if(!this._m)throw new Error("Invalid state: you Must provide at least a model.");var t="".concat($).concat(H);if(!this._rs){var e="/".concat(t);this.withRelationship(new it("rel".concat(0),tt.ThreeDimModel,e))}return new ot(this._cts,this._rs,this._m)},t}(),kt=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 L(a),u=new Z(s).dec("1.0","UTF-8");new E(u).serialize(n),s.finish()},(s=this.toDocument.apply(this,e))?(u=new r(t),a(u,Y,s.contentTypes),a(u,"".concat(q).concat(J),s.relationships),a(u,"".concat($).concat(H),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 Nt).withUnit(null!==(e=null===(t=this._o)||void 0===t?void 0:t.unit)&&void 0!==e?e:F.millimeter);if(this.options.metadata)for(var o in this.options.metadata)i.withMetaData(o,this.options.metadata[o]);return(new Ot).withModel(this.toModel.apply(this,f([i],n,!1))).build()},t}(),Dt=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}(),At=r(597),Xt=function(){function t(){}return t.FFLATEUrl="https://unpkg.com/fflate@0.8.2",t}(),Rt=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}(),Pt=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 At.Mesh||t instanceof At.InstancedMesh}));for(var r=new Rt,i=t,o=new Map,a=this.options.exportInstances?[]:null,s=0;s<e.length;s++){var u=e[s];if(u instanceof At.InstancedMesh)null==a||a.push(u);else{var l=u.name||"mesh".concat(s),c=u.getWorldMatrix(),p=this._handleBjsTo3mfMatrixTransformToRef(c,at.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 jt(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,w=Array.from(_.entries());g<w.length;g++){var b=w[g],T=b[0],M=b[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._handleBjsTo3mfMatrixTransformToRef(c,at.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,At.Tools.LoadScriptAsync(Xt.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._handleBjsTo3mfMatrixTransformToRef=function(t,n){var r=t.multiplyToRef(e._R_BJS_TO_3MF,At.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:F.meter,exportInstances:!1},e._PositionKind="position",e._R_BJS_TO_3MF=At.Matrix.RotationX(Math.PI/2).multiply(At.Matrix.Scaling(1,-1,1)),e}(kt),Bt=void 0!==r.g?r.g:"undefined"!=typeof window?window:void 0;if(void 0!==Bt){var Et=[];for(var It in o)Et.indexOf(It)>-1||(Bt.BABYLON[It]=o[It],Et.push(It))}const Ft=a;return i.default})()));
|
|
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:()=>Ft});var o={};r.r(o),r.d(o,{AbstractThreeMfSerializer:()=>kt,ContentTypeFileName:()=>Y,DefaultXmlSerializerFormatOptions:()=>N,DefaultXmlSerializerNumberOptions:()=>C,GetXmlFieldMeta:()=>T,GetXmlName:()=>M,IsQualifiedName:()=>m,Known3mfRelationshipTypes:()=>tt,KnownI3mfContentType:()=>Q,Matrix3d:()=>at,MatrixFormatter:()=>st,ModelFileName:()=>H,NumberFormatter:()=>D,Object3dDirName:()=>$,OpenXmlContentTypesNamespace:()=>V,OpenXmlRelationshipsNamespace:()=>W,RelationshipDirName:()=>q,RelationshipFileName:()=>J,ResolveFormatOptions:()=>k,ResolveNumberOptions:()=>O,ST_ObjectType:()=>z,ST_Unit:()=>F,StringXmlWriter:()=>K,ThreeDimModelNamespace:()=>U,ThreeMf:()=>Dt,ThreeMfBase:()=>wt,ThreeMfBaseMaterials:()=>bt,ThreeMfBuild:()=>Tt,ThreeMfComponent:()=>gt,ThreeMfComponents:()=>_t,ThreeMfComponentsBuilder:()=>St,ThreeMfContentType:()=>nt,ThreeMfContentTypes:()=>et,ThreeMfDocument:()=>ot,ThreeMfDocumentBuilder:()=>Ot,ThreeMfItem:()=>Mt,ThreeMfMaterialBuilder:()=>Ct,ThreeMfMesh:()=>ft,ThreeMfMeshBuilder:()=>jt,ThreeMfMeta:()=>lt,ThreeMfMetadataGroup:()=>ct,ThreeMfModel:()=>ut,ThreeMfModelBuilder:()=>Nt,ThreeMfObject:()=>ht,ThreeMfObjectBuilder:()=>xt,ThreeMfRelationship:()=>it,ThreeMfRelationships:()=>rt,ThreeMfResources:()=>pt,ThreeMfSerializer:()=>Pt,ThreeMfSerializerGlobalConfiguration:()=>Xt,ThreeMfTriangle:()=>yt,ThreeMfTriangles:()=>vt,ThreeMfVertex:()=>dt,ThreeMfVertices:()=>mt,ToQualifiedString:()=>j,TokenType:()=>B,TriangleSetsNamespace:()=>G,Utf8XmlWriterToBytes:()=>L,XmlAttr:()=>b,XmlBuilder:()=>Z,XmlElem:()=>w,XmlIgnore:()=>g,XmlName:()=>_,XmlNameToParts:()=>S,XmlSerializer:()=>E});var a={};r.r(a),r.d(a,{AbstractThreeMfSerializer:()=>kt,ContentTypeFileName:()=>Y,DefaultXmlSerializerFormatOptions:()=>N,DefaultXmlSerializerNumberOptions:()=>C,GetXmlFieldMeta:()=>T,GetXmlName:()=>M,IsQualifiedName:()=>m,Known3mfRelationshipTypes:()=>tt,KnownI3mfContentType:()=>Q,Matrix3d:()=>at,MatrixFormatter:()=>st,ModelFileName:()=>H,NumberFormatter:()=>D,Object3dDirName:()=>$,OpenXmlContentTypesNamespace:()=>V,OpenXmlRelationshipsNamespace:()=>W,RelationshipDirName:()=>q,RelationshipFileName:()=>J,ResolveFormatOptions:()=>k,ResolveNumberOptions:()=>O,ST_ObjectType:()=>z,ST_Unit:()=>F,StringXmlWriter:()=>K,ThreeDimModelNamespace:()=>U,ThreeMf:()=>Dt,ThreeMfBase:()=>wt,ThreeMfBaseMaterials:()=>bt,ThreeMfBuild:()=>Tt,ThreeMfComponent:()=>gt,ThreeMfComponents:()=>_t,ThreeMfComponentsBuilder:()=>St,ThreeMfContentType:()=>nt,ThreeMfContentTypes:()=>et,ThreeMfDocument:()=>ot,ThreeMfDocumentBuilder:()=>Ot,ThreeMfItem:()=>Mt,ThreeMfMaterialBuilder:()=>Ct,ThreeMfMesh:()=>ft,ThreeMfMeshBuilder:()=>jt,ThreeMfMeta:()=>lt,ThreeMfMetadataGroup:()=>ct,ThreeMfModel:()=>ut,ThreeMfModelBuilder:()=>Nt,ThreeMfObject:()=>ht,ThreeMfObjectBuilder:()=>xt,ThreeMfRelationship:()=>it,ThreeMfRelationships:()=>rt,ThreeMfResources:()=>pt,ThreeMfSerializer:()=>Pt,ThreeMfSerializerGlobalConfiguration:()=>Xt,ThreeMfTriangle:()=>yt,ThreeMfTriangles:()=>vt,ThreeMfVertex:()=>dt,ThreeMfVertices:()=>mt,ToQualifiedString:()=>j,TokenType:()=>B,TriangleSetsNamespace:()=>G,Utf8XmlWriterToBytes:()=>L,XmlAttr:()=>b,XmlBuilder:()=>Z,XmlElem:()=>w,XmlIgnore:()=>g,XmlName:()=>_,XmlNameToParts:()=>S,XmlSerializer:()=>E});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"string"==typeof t||"number"==typeof t||"boolean"==typeof t||"bigint"==typeof t||A(t)}function P(t){return"number"==typeof t||"boolean"==typeof t||"bigint"==typeof t||A(t)}var B,E=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];P(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("number"==typeof 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 P(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];R(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];R(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}(),I=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"}(B||(B={}));var F,z,Z=function(){function t(t){this._ctxStack=[],this._d=0,this._w=t}return t.prototype.dec=function(t,e,n){return this._w.write(I.Dec),this._writeAttStr(I.VersionKeyword,t),e&&this._writeAttStr(I.EncodingKeyword,e),void 0!==n&&this._writeAttStr(I.StandaloneKeyword,n?"yes":"no"),this._w.write(I.Question,I.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===I.Xmlns)r.defaultNs=n,this._registerNamespace(r,"",n),this._writeAttStr(I.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=B.Attribute,this}var o=e;if(t){var a=this._ensurePrefixDeclared(r,t);o="".concat(a,":").concat(e)}return r.lastToken=B.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(I.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=B.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(I.OpenTag,I.Slash,t.name,I.CloseTag):this._w.write(I.Slash,I.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(I.Space,t,I.Equal,I.Quote,this._escAttr(e),I.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,"&").replace(/</g,"<").replace(/>/g,">")},t.prototype._escAttr=function(t){return this._escText(t).replace(/"/g,""").replace(/'/g,"'")},t.prototype._isXmlnsDecl=function(t,e){if(t)return t===I.Xmlns;var n=e.length,r=I.Xmlns.length;return n>=r&&e.startsWith(I.Xmlns)&&(e.length==r||e[r]==I.Semicolon)},t.prototype._registerNamespace=function(t,e,n){if(e===I.Xml||e===I.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(I.Xmlns,":").concat(r),e),this._registerNamespace(t,r,e),r},t.prototype._closeOpenTagIfNeeded=function(t){t.closed||(this._w.write(I.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}(),K=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}(),L=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}(),U="http://schemas.microsoft.com/3dmanufacturing/core/2015/02",G="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"}(F||(F={})),function(t){t.model="model",t.solidsupport="solidsupport",t.support="support",t.surface="surface",t.other="other"}(z||(z={}));var Q,V="http://schemas.openxmlformats.org/package/2006/content-types",W="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"}(Q||(Q={}));var q="_rels/",$="3D/",H="3dmodel.model",J=".rels",Y="[Content_Types].xml",tt=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}(),et=function(){function t(){this.items=[]}return c([_({ns:V,name:"Types"})],t)}(),nt=function(){function t(t,e){this.ext=t,this.ct=e}return c([b({name:{ns:V,name:"Extension"}})],t.prototype,"ext",void 0),c([b({name:{ns:V,name:"ContentType"}})],t.prototype,"ct",void 0),c([_({ns:V,name:"Default"})],t)}(),rt=function(){function t(){this.items=[]}return c([_({ns:W,name:"Relationships"})],t)}(),it=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:W,name:"Relationship"})],t)}(),ot=function(t,e,n){this.contentTypes=t,this.relationships=e,this.model=n},at=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}(),st=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}(),ut=function(){function t(){this.unit=F.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:U,name:"model"})],t)}(),lt=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:U,name:"meta"})],t)}(),ct=function(){function t(){this.metadata=[]}return c([_({ns:U,name:"metadatagroup"})],t)}(),pt=function(){function t(){this.object=[]}return c([_({ns:U,name:"resources"})],t)}(),ht=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:U,name:"object"})],t)}(),ft=function(){function t(t,e){this.vertices=null!=t?t:new mt,this.triangles=null!=e?e:new vt}return c([_({ns:U,name:"mesh"})],t)}(),mt=function(){function t(){this.vertex=[]}return c([_({ns:U,name:"vertices"})],t)}(),dt=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:U,name:"vertex"})],t)}(),vt=function(){function t(){this.triangle=[]}return c([_({ns:U,name:"triangles"})],t)}(),yt=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:U,name:"triangle"})],t)}(),_t=function(){function t(){this.component=[]}return c([_({ns:U,name:"components"})],t)}(),gt=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:st})],t.prototype,"transform",void 0),c([_({ns:U,name:"component"})],t)}(),bt=function(){function t(t){this.base=[],this.id=t}return c([b({name:"id"})],t.prototype,"id",void 0),c([_({ns:U,name:"basematerials"})],t)}(),wt=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:U,name:"base"})],t)}(),Tt=function(){function t(){this.item=[]}return c([_({ns:U,name:"build"})],t)}(),Mt=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:st})],t.prototype,"transform",void 0),c([b({name:"partnumber"})],t.prototype,"partnumber",void 0),c([_({ns:U,name:"item"})],t)}(),xt=function(){function t(t,e){this._object=new ht(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 ht(t,e)},t}(),St=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 _t,r}return u(e,t),e.prototype.withComponent=function(t,e){return this._object.content.component.push(new gt(t,e)),this},e}(xt),jt=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 ft(e,n)},e.prototype._buildVertices=function(t){var e=new mt;if(t)for(var n=0;n<t.length;){var r=t[n++],i=t[n++],o=t[n++],a=new dt(r,i,o);this._vh&&(a=this._vh(a)),e.vertex.push(a)}return e},e.prototype._buildTriangle=function(t){var e=new vt;if(t)for(var n=0;n<t.length;){var r=t[n++],i=t[n++],o=t[n++],a=new yt(r,i,o);this._th&&(a=this._th(a)),e.triangle.push(a)}return e},e}(xt),Ct=function(){function t(t){this._m=new bt(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 wt(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}(),Nt=function(){function t(){this._model=new ut,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 lt(t,e,n,r)),this},t.prototype.withMaterial=function(t){var e,n;return t instanceof Ct&&(t=t.build()),t&&(this._model.resources=null!==(e=this._model.resources)&&void 0!==e?e:new pt,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 jt&&(t=t.build()),this._model.resources=null!==(e=this._model.resources)&&void 0!==e?e:new pt,this._model.resources.object.push(t),this},t.prototype.withComponents=function(t){var e;return t instanceof St&&(t=t.build()),this._model.resources=null!==(e=this._model.resources)&&void 0!==e?e:new pt,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 Tt,null===(i=this._model.build.item)||void 0===i||i.push(new Mt(t,e,n)),this},t.prototype.withUnit=function(t){return this._model.unit=t,this},t.prototype.reset=function(){return this._model=new ut,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(ut.KnownMeta.map((function(t){return t.toLowerCase()}))),t}(),Ot=function(){function t(){}return t.prototype.withContentType=function(t){this._cts||(this._cts=new et);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 rt);var e=this._rs.items;return e.some((function(e){return e.id===t.id}))||e.push(t),this.withContentType(new nt("rels",Q.Relationships)),this},t.prototype.withModel=function(t){return t instanceof Nt&&(t=t.build()),this._m=t,this.withContentType(new nt("model",Q.Model)),this},t.prototype.build=function(){if(!this._m)throw new Error("Invalid state: you Must provide at least a model.");var t="".concat($).concat(H);if(!this._rs){var e="/".concat(t);this.withRelationship(new it("rel".concat(0),tt.ThreeDimModel,e))}return new ot(this._cts,this._rs,this._m)},t}(),kt=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 L(a),u=new Z(s).dec("1.0","UTF-8");new E(u).serialize(n),s.finish()},(s=this.toDocument.apply(this,e))?(u=new r(t),a(u,Y,s.contentTypes),a(u,"".concat(q).concat(J),s.relationships),a(u,"".concat($).concat(H),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 Nt).withUnit(null!==(e=null===(t=this._o)||void 0===t?void 0:t.unit)&&void 0!==e?e:F.millimeter);if(this.options.metadata)for(var o in this.options.metadata)i.withMetaData(o,this.options.metadata[o]);return(new Ot).withModel(this.toModel.apply(this,f([i],n,!1))).build()},t}(),Dt=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}(),At=r(597),Xt=function(){function t(){}return t.FFLATEUrl="https://unpkg.com/fflate@0.8.2",t}(),Rt=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}(),Pt=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 At.Mesh||t instanceof At.InstancedMesh}));for(var r=new Rt,i=t,o=new Map,a=this.options.exportInstances?[]:null,s=0;s<e.length;s++){var u=e[s];if(u instanceof At.InstancedMesh)null==a||a.push(u);else{var l=u.name||"mesh".concat(s),c=u.getWorldMatrix(),p=this._handleBabylonTo3mfMatrixTransformToRef(c,at.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 jt(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,at.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,At.Tools.LoadScriptAsync(Xt.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,At.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:F.meter,exportInstances:!1},e._PositionKind="position",e._R_BJS_TO_3MF=At.Matrix.RotationX(Math.PI/2).multiply(At.Matrix.Scaling(1,-1,1)),e}(kt),Bt=void 0!==r.g?r.g:"undefined"!=typeof window?window:void 0;if(void 0!==Bt){var Et=[];for(var It in o)Et.indexOf(It)>-1||(Bt.BABYLON[It]=o[It],Et.push(It))}const Ft=a;return i.default})()));
|
|
2
2
|
//# sourceMappingURL=babylon.threemfSerializer.min.js.map
|