acc-viewer
Version:
Acc Viewer
2 lines • 1000 kB
JavaScript
var OV=(()=>{var ph=Object.defineProperty;var F0=Object.getOwnPropertyDescriptor;var U0=Object.getOwnPropertyNames;var k0=Object.prototype.hasOwnProperty;var B0=(r,e)=>{for(var t in e)ph(r,t,{get:e[t],enumerable:!0})},G0=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of U0(e))!k0.call(r,i)&&i!==t&&ph(r,i,{get:()=>e[i],enumerable:!(n=F0(e,i))||n.enumerable});return r};var V0=r=>G0(ph({},"__esModule",{value:!0}),r);var Ub={};B0(Ub,{AddCoord2D:()=>tp,AddCoord3D:()=>bc,AddDiv:()=>x0,AddDomElement:()=>Ud,ArrayBufferToAsciiString:()=>ap,ArrayBufferToUtf8String:()=>on,ArrayToCoord3D:()=>Kr,ArrayToQuaternion:()=>To,ArrayToRGBColor:()=>sp,AsciiStringToArrayBuffer:()=>lp,Base64DataURIToArrayBuffer:()=>Cs,BezierTweenFunction:()=>dp,BigEps:()=>$d,BinaryReader:()=>jn,BinaryWriter:()=>Di,BoundingBoxCalculator3D:()=>Co,Box3D:()=>Ps,CalculateSurfaceArea:()=>g0,CalculateTriangleNormal:()=>Is,CalculateVolume:()=>Dd,Camera:()=>Ri,CameraIsEqual3D:()=>nh,CameraMode:()=>Gn,CameraValidator:()=>sc,CheckModel:()=>Ag,ClearDomElement:()=>_0,ClickDetector:()=>rc,ColorComponentFromFloat:()=>Mn,ColorComponentToFloat:()=>As,ColorToMaterialConverter:()=>ti,ConvertColorToThreeColor:()=>Fn,ConvertMeshToMeshBuffer:()=>vo,ConvertModelToThreeObject:()=>rh,ConvertThreeColorToColor:()=>Gl,ConvertThreeGeometryToMesh:()=>Wi,Coord2D:()=>wt,Coord3D:()=>Ge,Coord4D:()=>ai,CoordDistance2D:()=>nl,CoordDistance3D:()=>zn,CoordIsEqual2D:()=>Li,CoordIsEqual3D:()=>oi,CopyObjectAttributes:()=>co,CreateDiv:()=>R0,CreateDomElement:()=>lh,CreateModelUrlParameters:()=>y0,CreateObjectUrl:()=>Rs,CreateObjectUrlWithMimeType:()=>Ac,CreateUrlBuilder:()=>Fd,CreateUrlParser:()=>v0,CrossVector3D:()=>Oi,DegRad:()=>tr,Direction:()=>ut,DisposeThreeObjects:()=>ku,DotVector3D:()=>rl,EdgeSettings:()=>Hr,EmbeddedViewer:()=>Qa,EnvironmentSettings:()=>Xr,Eps:()=>Jd,EscapeHtmlChars:()=>dc,EventNotifier:()=>pc,ExportedFile:()=>Yt,Exporter:()=>Lc,Exporter3dm:()=>xo,ExporterBase:()=>Sn,ExporterBim:()=>_o,ExporterGltf:()=>Eo,ExporterModel:()=>Mo,ExporterObj:()=>bo,ExporterOff:()=>So,ExporterPly:()=>Ao,ExporterSettings:()=>cl,ExporterStl:()=>wo,FaceMaterial:()=>mo,FileFormat:()=>tn,FileSource:()=>Pi,FinalizeModel:()=>Bu,FlipMeshTrianglesOrientation:()=>Pc,GenerateCone:()=>Ld,GenerateCuboid:()=>f0,GenerateCylinder:()=>d0,GeneratePlatonicSolid:()=>m0,GenerateSphere:()=>p0,Generator:()=>Ts,GeneratorHelper:()=>Xa,GeneratorParams:()=>Jl,GetBoundingBox:()=>gh,GetDefaultCamera:()=>ch,GetDomElementClientCoordinates:()=>Wr,GetDomElementExternalHeight:()=>oh,GetDomElementExternalWidth:()=>sh,GetDomElementInnerDimensions:()=>ah,GetDomElementOuterHeight:()=>A0,GetDomElementOuterWidth:()=>S0,GetExternalLibPath:()=>bs,GetFileExtension:()=>er,GetFileExtensionFromMimeType:()=>Zr,GetFileName:()=>vn,GetIntegerFromStyle:()=>In,GetMeshType:()=>Jr,GetShadingType:()=>Uu,GetShadingTypeOfObject:()=>Gd,GetTetrahedronSignedVolume:()=>Od,GetTopology:()=>vh,GetTriangleArea:()=>Nd,HasDefaultMaterial:()=>mp,HasHighpDriverIssue:()=>Fu,HexStringToRGBAColor:()=>rp,HexStringToRGBColor:()=>ip,ImportError:()=>_s,ImportErrorCode:()=>yr,ImportResult:()=>Kl,ImportSettings:()=>Ha,Importer:()=>Wa,Importer3dm:()=>Sa,Importer3ds:()=>Aa,ImporterBase:()=>Bt,ImporterBim:()=>Oa,ImporterFcstd:()=>za,ImporterFile:()=>Ns,ImporterFileAccessor:()=>Zl,ImporterFileList:()=>Os,ImporterGltf:()=>wa,ImporterIfc:()=>Ca,ImporterObj:()=>Ra,ImporterOcct:()=>La,ImporterOff:()=>Ia,ImporterPly:()=>Pa,ImporterStl:()=>Na,ImporterThree3mf:()=>Va,ImporterThreeBase:()=>gr,ImporterThreeDae:()=>Ba,ImporterThreeFbx:()=>ka,ImporterThreeSvg:()=>th,ImporterThreeWrl:()=>Ga,ImporterUnv:()=>Da,Init3DViewerElements:()=>P0,Init3DViewerFromFileList:()=>I0,Init3DViewerFromUrlList:()=>Vd,InputFile:()=>Po,InputFilesFromFileObjects:()=>Dc,InputFilesFromUrls:()=>Oc,InsertDomElementAfter:()=>E0,InsertDomElementBefore:()=>T0,IntegerToHexString:()=>yn,IsDefined:()=>lo,IsDomElementVisible:()=>b0,IsEqual:()=>It,IsEqualEps:()=>ep,IsGreater:()=>Ec,IsGreaterOrEqual:()=>po,IsLower:()=>ho,IsLowerOrEqual:()=>fo,IsModelEmpty:()=>No,IsNegative:()=>Er,IsObjectEmpty:()=>fc,IsPositive:()=>vi,IsPowerOfTwo:()=>jf,IsTwoManifold:()=>yh,IsUrl:()=>Zd,IsZero:()=>Ss,LinearToSRGB:()=>ws,LinearTweenFunction:()=>pp,LoadExternalLibrary:()=>Qi,MaterialBase:()=>il,MaterialType:()=>Pn,Matrix:()=>Wt,MatrixIsEqual:()=>Ic,Mesh:()=>Xt,MeshBuffer:()=>ol,MeshInstance:()=>br,MeshInstanceId:()=>yi,MeshPrimitiveBuffer:()=>sl,MeshType:()=>ir,Model:()=>or,ModelObject3D:()=>sr,ModelToThreeConversionOutput:()=>Ya,ModelToThreeConversionParams:()=>qa,MouseInteraction:()=>nc,NameFromLine:()=>Gr,Navigation:()=>Za,NavigationType:()=>qn,NextPowerOfTwo:()=>wg,Node:()=>wn,Object3D:()=>al,Octree:()=>Ro,OctreeNode:()=>Ls,ParabolicTweenFunction:()=>Nc,ParameterConverter:()=>rn,ParameterListBuilder:()=>$l,ParameterListParser:()=>Ql,ParametersFromLine:()=>Xi,PhongMaterial:()=>cn,PhysicalMaterial:()=>Yr,Property:()=>jt,PropertyGroup:()=>An,PropertyToString:()=>Cc,PropertyType:()=>zt,Quaternion:()=>Hn,QuaternionFromAxisAngle:()=>Rc,QuaternionFromXYZ:()=>up,QuaternionIsEqual:()=>cp,RGBAColor:()=>Ni,RGBAColorToHexString:()=>np,RGBColor:()=>yt,RGBColorFromFloatComponents:()=>si,RGBColorIsEqual:()=>Mr,RGBColorToHexString:()=>Mc,RadDeg:()=>Qd,ReadFile:()=>_c,ReadLines:()=>wi,ReplaceDefaultMaterialColor:()=>gp,RequestUrl:()=>xc,RevokeObjectUrl:()=>wc,RunTaskAsync:()=>el,RunTasks:()=>mc,RunTasksBatch:()=>gc,SRGBToLinear:()=>nr,SetDomElementHeight:()=>Bd,SetDomElementOuterHeight:()=>C0,SetDomElementOuterWidth:()=>w0,SetDomElementWidth:()=>kd,SetExternalLibLocation:()=>Kd,SetThreeMeshPolygonOffset:()=>ih,ShadingModel:()=>Ja,ShadingType:()=>Bn,ShowDomElement:()=>M0,SubCoord2D:()=>tl,SubCoord3D:()=>bn,TaskRunner:()=>uo,TextWriter:()=>Zn,TextureIsEqual:()=>op,TextureMap:()=>Kn,TextureMapIsEqual:()=>qr,ThreeColorConverter:()=>Ea,ThreeConversionStateHandler:()=>ec,ThreeLinearToSRGBColorConverter:()=>Ma,ThreeModelLoader:()=>Ka,ThreeNodeTree:()=>tc,ThreeSRGBToLinearColorConverter:()=>ba,Topology:()=>Lo,TopologyEdge:()=>hl,TopologyTriangle:()=>dl,TopologyTriangleEdge:()=>fl,TopologyVertex:()=>ul,TouchInteraction:()=>ic,TransformFileHostUrls:()=>Tc,TransformMesh:()=>rr,Transformation:()=>Kt,TransformationIsEqual:()=>hp,TraverseThreeObject:()=>uh,Triangle:()=>Nt,TweenCoord3D:()=>Io,UpVector:()=>oc,UpdateMaterialTransparency:()=>ni,Utf8StringToArrayBuffer:()=>yo,ValueOrDefault:()=>qd,VectorAngle3D:()=>Sc,VectorLength3D:()=>go,Viewer:()=>$a,ViewerMainModel:()=>ja,ViewerModel:()=>Es,WaitWhile:()=>vc});function lo(r){return r!=null}function qd(r,e){return r??e}function co(r,e){if(lo(r))for(let t of Object.keys(r))lo(r[t])&&(e[t]=r[t])}function fc(r){return Object.keys(r).length===0}function dc(r){return r.replace(/</g,"<").replace(/>/g,">")}var pc=class{constructor(){this.eventListeners=new Map}AddEventListener(e,t){this.eventListeners.has(e)||this.eventListeners.set(e,[]),this.eventListeners.get(e).push(t)}HasEventListener(e){return this.eventListeners.has(e)}GetEventNotifier(e){return()=>{this.NotifyEventListeners(e)}}NotifyEventListeners(e,...t){if(!this.eventListeners.has(e))return;let n=this.eventListeners.get(e);for(let i of n)i(...t)}};var uo=class{constructor(){this.count=null,this.current=null,this.callbacks=null}Run(e,t){this.count=e,this.current=0,this.callbacks=t,e===0?this.TaskReady():this.RunOnce()}RunBatch(e,t,n){let i=0;e>0&&(i=parseInt((e-1)/t,10)+1),this.Run(i,{runTask:(s,o)=>{let a=s*t,c=Math.min((s+1)*t,e)-1;n.runTask(a,c,o)},onReady:n.onReady})}RunOnce(){setTimeout(()=>{this.callbacks.runTask(this.current,this.TaskReady.bind(this))},0)}TaskReady(){this.current+=1,this.current<this.count?this.RunOnce():this.callbacks.onReady&&this.callbacks.onReady()}};function el(r){setTimeout(()=>{r()},10)}function mc(r,e){new uo().Run(r,e)}function gc(r,e,t){new uo().RunBatch(r,e,t)}function vc(r){function e(t){t()&&setTimeout(()=>{e(t)},10)}e(r)}var yc=null,Yd=new Set;function Kd(r){yc=r}function bs(r){return yc===null?null:yc+"/"+r}function Qi(r){return new Promise((e,t)=>{if(yc===null){t();return}if(Yd.has(r)){e();return}let n=document.createElement("script");n.type="text/javascript",n.src=bs(r),n.onload=()=>{Yd.add(r),e()},n.onerror=()=>{t()},document.head.appendChild(n)})}var Pi={Url:1,File:2,Decompressed:3},tn={Text:1,Binary:2};function vn(r){let e=r,t=e.indexOf("?");t!==-1&&(e=e.substring(0,t));let n=e.lastIndexOf("/");return n===-1&&(n=e.lastIndexOf("\\")),n!==-1&&(e=e.substring(n+1)),decodeURI(e)}function er(r){let e=vn(r),t=e.lastIndexOf(".");return t===-1?"":e.substring(t+1).toLowerCase()}function xc(r,e){return new Promise((t,n)=>{let i=new XMLHttpRequest;i.open("GET",r,!0),i.onprogress=s=>{e(s.loaded,s.total)},i.onload=()=>{i.status===200?t(i.response):n()},i.onerror=()=>{n()},i.responseType="arraybuffer",i.send(null)})}function _c(r,e){return new Promise((t,n)=>{let i=new FileReader;i.onprogress=s=>{e(s.loaded,s.total)},i.onloadend=s=>{s.target.readyState===FileReader.DONE&&t(s.target.result)},i.onerror=()=>{n()},i.readAsArrayBuffer(r)})}function Tc(r){for(let e=0;e<r.length;e++){let t=r[e];if(t.search(/www\.dropbox\.com/u)!==-1){t=t.replace("www.dropbox.com","dl.dropbox.com");let n=t.indexOf("?");n!==-1&&(t=t.substring(0,n)),r[e]=t}else if(t.search(/github\.com/u)!==-1){t=t.replace("github.com","raw.githubusercontent.com"),t=t.replace("/blob","");let n=t.indexOf("?");n!==-1&&(t=t.substring(0,n)),r[e]=t}}}function Zd(r){let e=/^https?:\/\/\S+$/g;return r.match(e)!==null}var Jd=1e-8,$d=1e-4,Qd=57.29577951308232,tr=.017453292519943;function Ss(r){return Math.abs(r)<1e-8}function ho(r,e){return e-r>1e-8}function Ec(r,e){return r-e>1e-8}function fo(r,e){return e-r>-1e-8}function po(r,e){return r-e>-1e-8}function It(r,e){return Math.abs(e-r)<1e-8}function ep(r,e,t){return Math.abs(e-r)<t}function vi(r){return r>1e-8}function Er(r){return r<-1e-8}var ut={X:1,Y:2,Z:3};var wt=class{constructor(e,t){this.x=e,this.y=t}Clone(){return new wt(this.x,this.y)}};function Li(r,e){return It(r.x,e.x)&&It(r.y,e.y)}function tp(r,e){return new wt(r.x+e.x,r.y+e.y)}function tl(r,e){return new wt(r.x-e.x,r.y-e.y)}function nl(r,e){return Math.sqrt((r.x-e.x)*(r.x-e.x)+(r.y-e.y)*(r.y-e.y))}var yt=class{constructor(e,t,n){this.r=e,this.g=t,this.b=n}Set(e,t,n){this.r=e,this.g=t,this.b=n}Clone(){return new yt(this.r,this.g,this.b)}},Ni=class{constructor(e,t,n,i){this.r=e,this.g=t,this.b=n,this.a=i}Set(e,t,n,i){this.r=e,this.g=t,this.b=n,this.a=i}Clone(){return new Ni(this.r,this.g,this.b,this.a)}};function Mn(r){return parseInt(Math.round(r*255),10)}function As(r){return r/255}function si(r,e,t){return new yt(Mn(r),Mn(e),Mn(t))}function nr(r){return r<.04045?r*.0773993808:Math.pow(r*.9478672986+.0521327014,2.4)}function ws(r){return r<.0031308?r*12.92:1.055*Math.pow(r,.41666)-.055}function yn(r){let e=parseInt(r,10).toString(16);for(;e.length<2;)e="0"+e;return e}function Mc(r){let e=yn(r.r),t=yn(r.g),n=yn(r.b);return e+t+n}function np(r){let e=yn(r.r),t=yn(r.g),n=yn(r.b),i=yn(r.a);return e+t+n+i}function ip(r){if(r.length!==6)return null;let e=parseInt(r.substring(0,2),16),t=parseInt(r.substring(2,4),16),n=parseInt(r.substring(4,6),16);return new yt(e,t,n)}function rp(r){if(r.length!==6&&r.length!==8)return null;let e=parseInt(r.substring(0,2),16),t=parseInt(r.substring(2,4),16),n=parseInt(r.substring(4,6),16),i=255;return r.length===8&&(i=parseInt(r.substring(6,8),16)),new Ni(e,t,n,i)}function sp(r){return new yt(r[0],r[1],r[2])}function Mr(r,e){return r.r===e.r&&r.g===e.g&&r.b===e.b}var Kn=class{constructor(){this.name=null,this.mimeType=null,this.buffer=null,this.offset=new wt(0,0),this.scale=new wt(1,1),this.rotation=0}IsValid(){return this.name!==null&&this.buffer!==null}HasTransformation(){return!Li(this.offset,new wt(0,0))||!Li(this.scale,new wt(1,1))||!It(this.rotation,0)}IsEqual(e){return!(this.name!==e.name||this.mimeType!==e.mimeType||!Li(this.offset,e.offset)||!Li(this.scale,e.scale)||!It(this.rotation,e.rotation))}};function qr(r,e){return r===null&&e===null?!0:r===null||e===null?!1:r.IsEqual(e)}var Pn={Phong:1,Physical:2},il=class{constructor(e){this.type=e,this.isDefault=!1,this.name="",this.color=new yt(0,0,0),this.vertexColors=!1}IsEqual(e){return!(this.type!==e.type||this.isDefault!==e.isDefault||this.name!==e.name||!Mr(this.color,e.color)||this.vertexColors!==e.vertexColors)}},mo=class extends il{constructor(e){super(e),this.emissive=new yt(0,0,0),this.opacity=1,this.transparent=!1,this.diffuseMap=null,this.bumpMap=null,this.normalMap=null,this.emissiveMap=null,this.alphaTest=0,this.multiplyDiffuseMap=!1}IsEqual(e){return!(!super.IsEqual(e)||!Mr(this.emissive,e.emissive)||!It(this.opacity,e.opacity)||this.transparent!==e.transparent||!qr(this.diffuseMap,e.diffuseMap)||!qr(this.bumpMap,e.bumpMap)||!qr(this.normalMap,e.normalMap)||!qr(this.emissiveMap,e.emissiveMap)||!It(this.alphaTest,e.alphaTest)||this.multiplyDiffuseMap!==e.multiplyDiffuseMap)}},cn=class extends mo{constructor(){super(Pn.Phong),this.ambient=new yt(0,0,0),this.specular=new yt(0,0,0),this.shininess=0,this.specularMap=null}IsEqual(e){return!(!super.IsEqual(e)||!Mr(this.ambient,e.ambient)||!Mr(this.specular,e.specular)||!It(this.shininess,e.shininess)||!qr(this.specularMap,e.specularMap))}},Yr=class extends mo{constructor(){super(Pn.Physical),this.metalness=0,this.roughness=1,this.metalnessMap=null}IsEqual(e){return!(!super.IsEqual(e)||!It(this.metalness,e.metalness)||!It(this.roughness,e.roughness)||!qr(this.metalnessMap,e.metalnessMap))}};function op(r,e){return!(r.name!==e.name||r.mimeType!==e.mimeType||!Li(r.offset,e.offset)||!Li(r.scale,e.scale)||!It(r.rotation,e.rotation))}var Ge=class{constructor(e,t,n){this.x=e,this.y=t,this.z=n}Length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}MultiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}Normalize(){let e=this.Length();return e>0&&this.MultiplyScalar(1/e),this}Offset(e,t){let n=e.Clone().Normalize();return this.x+=n.x*t,this.y+=n.y*t,this.z+=n.z*t,this}Rotate(e,t,n){let i=e.Clone().Normalize(),s=i.x,o=i.y,a=i.z,c=this.x-n.x,l=this.y-n.y,u=this.z-n.z,h=Math.sin(t),f=Math.cos(t);return this.x=-s*(-s*c-o*l-a*u)*(1-f)+c*f+(-a*l+o*u)*h,this.y=-o*(-s*c-o*l-a*u)*(1-f)+l*f+(a*c-s*u)*h,this.z=-a*(-s*c-o*l-a*u)*(1-f)+u*f+(-o*c+s*l)*h,this.x+=n.x,this.y+=n.y,this.z+=n.z,this}Clone(){return new Ge(this.x,this.y,this.z)}};function oi(r,e){return It(r.x,e.x)&&It(r.y,e.y)&&It(r.z,e.z)}function bc(r,e){return new Ge(r.x+e.x,r.y+e.y,r.z+e.z)}function bn(r,e){return new Ge(r.x-e.x,r.y-e.y,r.z-e.z)}function zn(r,e){return Math.sqrt((r.x-e.x)*(r.x-e.x)+(r.y-e.y)*(r.y-e.y)+(r.z-e.z)*(r.z-e.z))}function rl(r,e){return r.x*e.x+r.y*e.y+r.z*e.z}function Sc(r,e){let t=r.Clone().Normalize(),n=e.Clone().Normalize();if(oi(t,n))return 0;let i=rl(t,n);return Math.acos(i)}function Oi(r,e){let t=new Ge(0,0,0);return t.x=r.y*e.z-r.z*e.y,t.y=r.z*e.x-r.x*e.z,t.z=r.x*e.y-r.y*e.x,t}function go(r,e,t){return Math.sqrt(r*r+e*e+t*t)}function Kr(r){return new Ge(r[0],r[1],r[2])}var sl=class{constructor(){this.indices=[],this.vertices=[],this.colors=[],this.normals=[],this.uvs=[],this.material=null}GetBounds(){let e=[1/0,1/0,1/0],t=[-1/0,-1/0,-1/0];for(let n=0;n<this.vertices.length/3;n++)for(let i=0;i<3;i++)e[i]=Math.min(e[i],this.vertices[n*3+i]),t[i]=Math.max(t[i],this.vertices[n*3+i]);return{min:e,max:t}}GetByteLength(e,t){let n=this.indices.length,i=this.vertices.length+this.colors.length+this.normals.length+this.uvs.length;return n*e+i*t}},ol=class{constructor(){this.primitives=[]}PrimitiveCount(){return this.primitives.length}GetPrimitive(e){return this.primitives[e]}GetByteLength(e,t){let n=0;for(let i=0;i<this.primitives.length;i++){let s=this.primitives[i];n+=s.GetByteLength(e,t)}return n}};function vo(r){function e(a,c,l,u){function h(v,p,d){return p!==null?v.GetVertexColor(p):d?new yt(0,0,0):null}function f(v,p,d){return p!==null?v.GetTextureUV(p):d?new wt(0,0):null}function m(v,p,d){let x=v.VertexColorCount()>0,y=v.TextureUVCount()>0,_=v.GetVertex(p.vertex),S=v.GetNormal(p.normal),P=d.vertices.length/3;d.indices.push(P),d.vertices.push(_.x,_.y,_.z);let I=h(v,p.color,x);I!==null&&d.colors.push(I.r/255,I.g/255,I.b/255),d.normals.push(S.x,S.y,S.z);let N=f(v,p.uv,y);return N!==null&&d.uvs.push(N.x,N.y),{index:P,color:I,normal:S,uv:N}}function g(v,p,d){function x(S,P,I){if(I===null&&P===null)return!0;let N=h(S,P,!0);return Mr(I,N)}function y(S,P,I){let N=S.GetNormal(P);return oi(I,N)}function _(S,P,I){if(I===null&&P===null)return!0;let N=f(S,P,!0);return Li(I,N)}for(let S=0;S<p.length;S++){let P=p[S],I=x(v,d.color,P.color),N=y(v,d.normal,P.normal),E=_(v,d.uv,P.uv);if(I&&N&&E)return P}return null}if(u.has(c.vertex)){let v=u.get(c.vertex),p=g(a,v,c);if(p!==null)l.indices.push(p.index);else{let d=m(a,c,l);v.push(d)}}else{let v=m(a,c,l);u.set(c.vertex,[v])}}let t=new ol,n=r.TriangleCount();if(n===0)return null;let i=[];for(let a=0;a<n;a++)i.push(a);i.sort((a,c)=>{let l=r.GetTriangle(a),u=r.GetTriangle(c);return l.mat-u.mat});let s=null,o=null;for(let a=0;a<i.length;a++){let c=i[a],l=r.GetTriangle(c);(s===null||s.material!==l.mat)&&(s=new sl,s.material=l.mat,o=new Map,t.primitives.push(s));let u={vertex:l.v0,color:l.c0,normal:l.n0,uv:l.u0},h={vertex:l.v1,color:l.c1,normal:l.n1,uv:l.u1},f={vertex:l.v2,color:l.c2,normal:l.n2,uv:l.u2};e(r,u,s,o),e(r,h,s,o),e(r,f,s,o)}return t}function on(r){return new TextDecoder("utf-8").decode(r)}function ap(r){let e="",t=new Uint8Array(r);for(let n=0;n<t.byteLength;n++)e+=String.fromCharCode(t[n]);return e}function lp(r){let e=new ArrayBuffer(r.length),t=new Uint8Array(e);for(let n=0;n<r.length;n++)t[n]=r.charCodeAt(n);return e}function yo(r){return new TextEncoder().encode(r).buffer}function Cs(r){let e="data:";if(!r.startsWith(e))return null;let t=r.indexOf(";");if(t===-1)return null;let n=r.indexOf(",");if(n===-1)return null;let i=r.substring(e.length,e.length+t-5),s=atob(r.substring(n+1)),o=new ArrayBuffer(s.length),a=new Uint8Array(o);for(let c=0;c<s.length;c++)a[c]=s.charCodeAt(c);return{mimeType:i,buffer:o}}function Zr(r){if(r==null)return"";let e=r.split("/");return e.length===0?"":e[e.length-1]}function Rs(r){let e=new Blob([r]);return URL.createObjectURL(e)}function Ac(r,e){let t=new Blob([r],{type:e});return URL.createObjectURL(t)}function wc(r){URL.revokeObjectURL(r)}var Yt=class{constructor(e){this.name=e,this.content=null}GetName(){return this.name}SetName(e){this.name=e}GetTextContent(){return on(this.content)}GetBufferContent(){return this.content}SetTextContent(e){let t=yo(e);this.content=t}SetBufferContent(e){this.content=e}},Sn=class{constructor(){}CanExport(e,t){return!1}Export(e,t,n){let i=[];this.ExportContent(e,t,i,()=>{n(i)})}ExportContent(e,t,n,i){}GetExportedMaterialName(e){return this.GetExportedName(e,"Material")}GetExportedMeshName(e){return this.GetExportedName(e,"Mesh")}GetExportedName(e,t){return e.length===0?t:e}};var xo=class extends Sn{constructor(){super(),this.rhino=null}CanExport(e,t){return e===tn.Binary&&t==="3dm"}ExportContent(e,t,n,i){this.rhino===null?Qi("loaders/rhino3dm.min.js").then(()=>{rhino3dm().then(s=>{this.rhino=s,this.ExportRhinoContent(e,n,i)})}).catch(()=>{i()}):this.ExportRhinoContent(e,n,i)}ExportRhinoContent(e,t,n){function i(l){return{r:l.r,g:l.g,b:l.b,a:255}}let s=new Yt("model.3dm");t.push(s);let o=new this.rhino.File3dm;e.EnumerateTransformedMeshInstances(l=>{let u=vo(l);for(let h=0;h<u.PrimitiveCount();h++){let f=u.GetPrimitive(h),m={data:{attributes:{position:{itemSize:3,type:"Float32Array",array:f.vertices},normal:{itemSize:3,type:"Float32Array",array:f.normals}},index:{type:"Uint16Array",array:f.indices}}},g=e.GetMaterial(f.material),v=new this.rhino.Material;v.name=this.GetExportedMaterialName(g.name),g.type===Pn.Phong&&(v.ambientColor=i(g.ambient),v.specularColor=i(g.specular)),v.diffuseColor=i(g.color),v.transparency=1-g.opacity;let p=o.materials().count();o.materials().add(v);let d=new this.rhino.Mesh.createFromThreejsJSON(m),x=new this.rhino.ObjectAttributes;x.name=this.GetExportedMeshName(l.GetName()),x.materialSource=this.rhino.ObjectMaterialSource.MaterialFromObject,x.materialIndex=p,o.objects().add(d,x)}});let a=new this.rhino.File3dmWriteOptions;a.version=6;let c=o.toByteArray(a);s.SetBufferContent(c),n()}};var zt={Text:1,Integer:2,Number:3,Boolean:4,Percent:5,Color:6},jt=class{constructor(e,t,n){this.type=e,this.name=t,this.value=n}Clone(){return this.type===zt.Color?new jt(this.type,this.name,this.value.Clone()):new jt(this.type,this.name,this.value)}},An=class{constructor(e){this.name=e,this.properties=[]}PropertyCount(){return this.properties.length}AddProperty(e){this.properties.push(e)}GetProperty(e){return this.properties[e]}Clone(){let e=new An(this.name);for(let t of this.properties)e.AddProperty(t.Clone());return e}};function Cc(r){return r.type===zt.Text?dc(r.value):r.type===zt.Integer?r.value.toLocaleString():r.type===zt.Number?r.value.toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:2}):r.type===zt.Boolean?r.value?"True":"False":r.type===zt.Percent?parseInt(r.value*100,10).toString()+"%":r.type===zt.Color?"#"+Mc(r.value):null}function z0(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)})}var _o=class extends Sn{constructor(){super()}CanExport(e,t){return e===tn.Text&&t==="bim"}ExportContent(e,t,n,i){let s={schema_version:"1.1.0",meshes:[],elements:[],info:{}};this.ExportProperties(e.GetModel(),s.info);let o=0;e.EnumerateTransformedMeshInstances(c=>{let l={mesh_id:o,coordinates:[],indices:[]};c.EnumerateVertices(g=>{l.coordinates.push(g.x,g.y,g.z)}),c.EnumerateTriangleVertexIndices((g,v,p)=>{l.indices.push(g,v,p)});let u={mesh_id:o,type:"Other",color:{r:200,g:200,b:200,a:255},vector:{x:0,y:0,z:0},rotation:{qx:0,qy:0,qz:0,qw:1},guid:z0(),info:{}},h=null,f=!0,m=[];for(let g=0;g<c.TriangleCount();g++){let v=c.GetTriangle(g),p=e.GetMaterial(v.mat),d={r:p.color.r,g:p.color.g,b:p.color.b,a:Mn(p.opacity)};m.push(d.r,d.g,d.b,d.a),f&&(h===null?h=d:(h.r!==d.r||h.g!==d.g||h.b!==d.b||h.a!==d.a)&&(f=!1,h=null))}f?u.color=h:u.face_colors=m,u.info.Name=c.GetName(),this.ExportProperties(c,u.info),s.meshes.push(l),s.elements.push(u),o+=1});let a=new Yt("model.bim");a.SetTextContent(JSON.stringify(s,null,4)),n.push(a),i()}ExportProperties(e,t){for(let n=0;n<e.PropertyGroupCount();n++){let i=e.GetPropertyGroup(n);for(let s=0;s<i.PropertyCount();s++){let o=i.GetProperty(s);t[o.name]=Cc(o)}}}};var Di=class{constructor(e,t){this.arrayBuffer=new ArrayBuffer(e),this.dataView=new DataView(this.arrayBuffer),this.isLittleEndian=t,this.position=0}GetPosition(){return this.position}SetPosition(e){this.position=e}End(){return this.position>=this.arrayBuffer.byteLength}GetBuffer(){return this.arrayBuffer}WriteArrayBuffer(e){let t=new Uint8Array(e);new Uint8Array(this.arrayBuffer).set(t,this.position),this.position+=e.byteLength}WriteBoolean8(e){this.dataView.setInt8(this.position,e?1:0),this.position=this.position+1}WriteCharacter8(e){this.dataView.setInt8(this.position,e),this.position=this.position+1}WriteUnsignedCharacter8(e){this.dataView.setUint8(this.position,e),this.position=this.position+1}WriteInteger16(e){this.dataView.setInt16(this.position,e,this.isLittleEndian),this.position=this.position+2}WriteUnsignedInteger16(e){this.dataView.setUint16(this.position,e,this.isLittleEndian),this.position=this.position+2}WriteInteger32(e){this.dataView.setInt32(this.position,e,this.isLittleEndian),this.position=this.position+4}WriteUnsignedInteger32(e){this.dataView.setUint32(this.position,e,this.isLittleEndian),this.position=this.position+4}WriteFloat32(e){this.dataView.setFloat32(this.position,e,this.isLittleEndian),this.position=this.position+4}WriteDouble64(e){this.dataView.setFloat64(this.position,e,this.isLittleEndian),this.position=this.position+8}};var ai=class{constructor(e,t,n,i){this.x=e,this.y=t,this.z=n,this.w=i}Clone(){return new ai(this.x,this.y,this.z,this.w)}};var Hn=class{constructor(e,t,n,i){this.x=e,this.y=t,this.z=n,this.w=i}};function cp(r,e){return It(r.x,e.x)&&It(r.y,e.y)&&It(r.z,e.z)&&It(r.w,e.w)}function To(r){return new Hn(r[0],r[1],r[2],r[3])}function Rc(r,e){let t=e/2,n=Math.sin(t);return new Hn(r.x*n,r.y*n,r.z*n,Math.cos(t))}function up(r,e,t,n){let i=Math.cos(r/2),s=Math.cos(e/2),o=Math.cos(t/2),a=Math.sin(r/2),c=Math.sin(e/2),l=Math.sin(t/2),u=new Hn(0,0,0,1);if(n==="XYZ")u.x=a*s*o+i*c*l,u.y=i*c*o-a*s*l,u.z=i*s*l+a*c*o,u.w=i*s*o-a*c*l;else if(n==="YXZ")u.x=a*s*o+i*c*l,u.y=i*c*o-a*s*l,u.z=i*s*l-a*c*o,u.w=i*s*o+a*c*l;else if(n==="ZXY")u.x=a*s*o-i*c*l,u.y=i*c*o+a*s*l,u.z=i*s*l+a*c*o,u.w=i*s*o-a*c*l;else if(n==="ZYX")u.x=a*s*o-i*c*l,u.y=i*c*o+a*s*l,u.z=i*s*l-a*c*o,u.w=i*s*o+a*c*l;else if(n==="YZX")u.x=a*s*o+i*c*l,u.y=i*c*o+a*s*l,u.z=i*s*l-a*c*o,u.w=i*s*o-a*c*l;else if(n==="XZY")u.x=a*s*o-i*c*l,u.y=i*c*o-a*s*l,u.z=i*s*l+a*c*o,u.w=i*s*o+a*c*l;else return null;return u}var Wt=class{constructor(e){this.matrix=null,e!=null&&(this.matrix=e)}IsValid(){return this.matrix!==null}Set(e){return this.matrix=e,this}Get(){return this.matrix}Clone(){let e=[this.matrix[0],this.matrix[1],this.matrix[2],this.matrix[3],this.matrix[4],this.matrix[5],this.matrix[6],this.matrix[7],this.matrix[8],this.matrix[9],this.matrix[10],this.matrix[11],this.matrix[12],this.matrix[13],this.matrix[14],this.matrix[15]];return new Wt(e)}CreateIdentity(){return this.matrix=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],this}IsIdentity(){let e=new Wt().CreateIdentity().Get();for(let t=0;t<16;t++)if(!It(this.matrix[t],e[t]))return!1;return!0}CreateTranslation(e,t,n){return this.matrix=[1,0,0,0,0,1,0,0,0,0,1,0,e,t,n,1],this}CreateRotation(e,t,n,i){let s=e+e,o=t+t,a=n+n,c=e*s,l=e*o,u=e*a,h=t*o,f=t*a,m=n*a,g=i*s,v=i*o,p=i*a;return this.matrix=[1-(h+m),l+p,u-v,0,l-p,1-(c+m),f+g,0,u+v,f-g,1-(c+h),0,0,0,0,1],this}CreateRotationAxisAngle(e,t){let n=Rc(e,t);return this.CreateRotation(n.x,n.y,n.z,n.w)}CreateScale(e,t,n){return this.matrix=[e,0,0,0,0,t,0,0,0,0,n,0,0,0,0,1],this}ComposeTRS(e,t,n){let i=e.x,s=e.y,o=e.z,a=t.x,c=t.y,l=t.z,u=t.w,h=n.x,f=n.y,m=n.z,g=a+a,v=c+c,p=l+l,d=a*g,x=a*v,y=a*p,_=c*v,S=c*p,P=l*p,I=u*g,N=u*v,E=u*p;return this.matrix=[(1-(_+P))*h,(x+E)*h,(y-N)*h,0,(x-E)*f,(1-(d+P))*f,(S+I)*f,0,(y+N)*m,(S-I)*m,(1-(d+_))*m,0,i,s,o,1],this}DecomposeTRS(){let e=new Ge(this.matrix[12],this.matrix[13],this.matrix[14]),t=go(this.matrix[0],this.matrix[1],this.matrix[2]),n=go(this.matrix[4],this.matrix[5],this.matrix[6]),i=go(this.matrix[8],this.matrix[9],this.matrix[10]),s=this.Determinant();Er(s)&&(t*=-1);let o=new Ge(t,n,i),a=this.matrix[0]/t,c=this.matrix[4]/n,l=this.matrix[8]/i,u=this.matrix[1]/t,h=this.matrix[5]/n,f=this.matrix[9]/i,m=this.matrix[2]/t,g=this.matrix[6]/n,v=this.matrix[10]/i,p=null,d=a+h+v;if(d>0){let x=Math.sqrt(d+1)*2;p=new Hn((g-f)/x,(l-m)/x,(u-c)/x,.25*x)}else if(a>h&&a>v){let x=Math.sqrt(1+a-h-v)*2;p=new Hn(.25*x,(c+u)/x,(l+m)/x,(g-f)/x)}else if(h>v){let x=Math.sqrt(1+h-a-v)*2;p=new Hn((c+u)/x,.25*x,(f+g)/x,(l-m)/x)}else{let x=Math.sqrt(1+v-a-h)*2;p=new Hn((l+m)/x,(f+g)/x,.25*x,(u-c)/x)}return{translation:e,rotation:p,scale:o}}Determinant(){let e=this.matrix[0],t=this.matrix[1],n=this.matrix[2],i=this.matrix[3],s=this.matrix[4],o=this.matrix[5],a=this.matrix[6],c=this.matrix[7],l=this.matrix[8],u=this.matrix[9],h=this.matrix[10],f=this.matrix[11],m=this.matrix[12],g=this.matrix[13],v=this.matrix[14],p=this.matrix[15],d=e*o-t*s,x=e*a-n*s,y=e*c-i*s,_=t*a-n*o,S=t*c-i*o,P=n*c-i*a,I=l*g-u*m,N=l*v-h*m,E=l*p-f*m,R=u*v-h*g,V=u*p-f*g,F=h*p-f*v;return d*F-x*V+y*R+_*E-S*N+P*I}Invert(){let e=this.matrix[0],t=this.matrix[1],n=this.matrix[2],i=this.matrix[3],s=this.matrix[4],o=this.matrix[5],a=this.matrix[6],c=this.matrix[7],l=this.matrix[8],u=this.matrix[9],h=this.matrix[10],f=this.matrix[11],m=this.matrix[12],g=this.matrix[13],v=this.matrix[14],p=this.matrix[15],d=e*o-t*s,x=e*a-n*s,y=e*c-i*s,_=t*a-n*o,S=t*c-i*o,P=n*c-i*a,I=l*g-u*m,N=l*v-h*m,E=l*p-f*m,R=u*v-h*g,V=u*p-f*g,F=h*p-f*v,U=d*F-x*V+y*R+_*E-S*N+P*I;if(It(U,0))return null;let k=[(o*F-a*V+c*R)/U,(n*V-t*F-i*R)/U,(g*P-v*S+p*_)/U,(h*S-u*P-f*_)/U,(a*E-s*F-c*N)/U,(e*F-n*E+i*N)/U,(v*y-m*P-p*x)/U,(l*P-h*y+f*x)/U,(s*V-o*E+c*I)/U,(t*E-e*V-i*I)/U,(m*S-g*y+p*d)/U,(u*y-l*S-f*d)/U,(o*N-s*R-a*I)/U,(e*R-t*N+n*I)/U,(g*x-m*_-v*d)/U,(l*_-u*x+h*d)/U];return new Wt(k)}Transpose(){let e=[this.matrix[0],this.matrix[4],this.matrix[8],this.matrix[12],this.matrix[1],this.matrix[5],this.matrix[9],this.matrix[13],this.matrix[2],this.matrix[6],this.matrix[10],this.matrix[14],this.matrix[3],this.matrix[7],this.matrix[11],this.matrix[15]];return new Wt(e)}InvertTranspose(){let e=this.Invert();return e===null?null:e.Transpose()}MultiplyVector(e){let t=e.x,n=e.y,i=e.z,s=e.w,o=this.matrix[0],a=this.matrix[1],c=this.matrix[2],l=this.matrix[3],u=this.matrix[4],h=this.matrix[5],f=this.matrix[6],m=this.matrix[7],g=this.matrix[8],v=this.matrix[9],p=this.matrix[10],d=this.matrix[11],x=this.matrix[12],y=this.matrix[13],_=this.matrix[14],S=this.matrix[15];return new ai(t*o+n*u+i*g+s*x,t*a+n*h+i*v+s*y,t*c+n*f+i*p+s*_,t*l+n*m+i*d+s*S)}MultiplyMatrix(e){let t=this.matrix[0],n=this.matrix[1],i=this.matrix[2],s=this.matrix[3],o=this.matrix[4],a=this.matrix[5],c=this.matrix[6],l=this.matrix[7],u=this.matrix[8],h=this.matrix[9],f=this.matrix[10],m=this.matrix[11],g=this.matrix[12],v=this.matrix[13],p=this.matrix[14],d=this.matrix[15],x=e.matrix[0],y=e.matrix[1],_=e.matrix[2],S=e.matrix[3],P=e.matrix[4],I=e.matrix[5],N=e.matrix[6],E=e.matrix[7],R=e.matrix[8],V=e.matrix[9],F=e.matrix[10],U=e.matrix[11],k=e.matrix[12],$=e.matrix[13],Y=e.matrix[14],J=e.matrix[15],X=[t*x+n*P+i*R+s*k,t*y+n*I+i*V+s*$,t*_+n*N+i*F+s*Y,t*S+n*E+i*U+s*J,o*x+a*P+c*R+l*k,o*y+a*I+c*V+l*$,o*_+a*N+c*F+l*Y,o*S+a*E+c*U+l*J,u*x+h*P+f*R+m*k,u*y+h*I+f*V+m*$,u*_+h*N+f*F+m*Y,u*S+h*E+f*U+m*J,g*x+v*P+p*R+d*k,g*y+v*I+p*V+d*$,g*_+v*N+p*F+d*Y,g*S+v*E+p*U+d*J];return new Wt(X)}};function Ic(r,e){let t=r.Get(),n=e.Get();for(let i=0;i<16;i++)if(!It(t[i],n[i]))return!1;return!0}var Kt=class{constructor(e){e!=null?this.matrix=e:(this.matrix=new Wt,this.matrix.CreateIdentity())}SetMatrix(e){return this.matrix=e,this}GetMatrix(){return this.matrix}IsIdentity(){return this.matrix.IsIdentity()}AppendMatrix(e){return this.matrix=this.matrix.MultiplyMatrix(e),this}Append(e){return this.AppendMatrix(e.GetMatrix()),this}TransformCoord3D(e){let t=new ai(e.x,e.y,e.z,1),n=this.matrix.MultiplyVector(t);return new Ge(n.x,n.y,n.z)}Clone(){let e=this.matrix.Clone();return new Kt(e)}};function hp(r,e){return Ic(r.GetMatrix(),e.GetMatrix())}var ir={Empty:0,TriangleMesh:1};function Jr(r){return r.TriangleCount()>0?ir.TriangleMesh:ir.Empty}function Is(r,e,t){let n=bn(e,r),i=bn(t,r),s=Oi(n,i);return s.Normalize(),s}function rr(r,e){if(!e.IsIdentity()){for(let t=0;t<r.VertexCount();t++){let n=r.GetVertex(t),i=e.TransformCoord3D(n);n.x=i.x,n.y=i.y,n.z=i.z}if(r.NormalCount()>0){let t=e.GetMatrix().InvertTranspose();if(t!==null){let n=new Kt(t);for(let i=0;i<r.NormalCount();i++){let s=r.GetNormal(i),o=n.TransformCoord3D(s);s.x=o.x,s.y=o.y,s.z=o.z}}}}}function Pc(r){for(let e=0;e<r.TriangleCount();e++){let t=r.GetTriangle(e),n=t.v1;t.v1=t.v2,t.v2=n}}var al=class{constructor(){}VertexCount(){return 0}VertexColorCount(){return 0}NormalCount(){return 0}TextureUVCount(){return 0}TriangleCount(){return 0}EnumerateVertices(e){}EnumerateTriangleVertexIndices(e){}EnumerateTriangleVertices(e){}},sr=class extends al{constructor(){super(),this.name="",this.propertyGroups=[]}GetName(){return this.name}SetName(e){this.name=e}PropertyGroupCount(){return this.propertyGroups.length}AddPropertyGroup(e){return this.propertyGroups.push(e),this.propertyGroups.length-1}GetPropertyGroup(e){return this.propertyGroups[e]}CloneProperties(e){for(let t of this.propertyGroups)e.AddPropertyGroup(t.Clone())}};var yi=class{constructor(e,t){this.nodeId=e,this.meshIndex=t}IsEqual(e){return this.nodeId===e.nodeId&&this.meshIndex===e.meshIndex}GetKey(){return this.nodeId.toString()+":"+this.meshIndex.toString()}},br=class extends sr{constructor(e,t,n){super(),this.id=e,this.node=t,this.mesh=n}GetId(){return this.id}GetTransformation(){return this.node.GetWorldTransformation()}GetMesh(){return this.mesh}VertexCount(){return this.mesh.VertexCount()}VertexColorCount(){return this.mesh.VertexColorCount()}NormalCount(){return this.mesh.NormalCount()}TextureUVCount(){return this.mesh.TextureUVCount()}TriangleCount(){return this.mesh.TriangleCount()}EnumerateVertices(e){let t=this.node.GetWorldTransformation();t.IsIdentity()?this.mesh.EnumerateVertices(e):this.mesh.EnumerateVertices(n=>{let i=t.TransformCoord3D(n);e(i)})}EnumerateTriangleVertexIndices(e){this.mesh.EnumerateTriangleVertexIndices(e)}EnumerateTriangleVertices(e){let t=this.node.GetWorldTransformation();t.IsIdentity()?this.mesh.EnumerateTriangleVertices(e):this.mesh.EnumerateTriangleVertices((n,i,s)=>{let o=t.TransformCoord3D(n),a=t.TransformCoord3D(i),c=t.TransformCoord3D(s);e(o,a,c)})}PropertyGroupCount(){return this.mesh.PropertyGroupCount()}AddPropertyGroup(e){return this.mesh.AddPropertyGroup(e)}GetPropertyGroup(e){return this.mesh.GetPropertyGroup(e)}GetTransformedMesh(){let e=this.node.GetWorldTransformation(),t=this.mesh.Clone();return rr(t,e),t}};var fp={UNSIGNED_INT:5125,FLOAT:5126},ll={ARRAY_BUFFER:34962,ELEMENT_ARRAY_BUFFER:34963},Eo=class extends Sn{constructor(){super(),this.components={index:{type:fp.UNSIGNED_INT,size:4},number:{type:fp.FLOAT,size:4}}}CanExport(e,t){return e===tn.Text&&t==="gltf"||e===tn.Binary&&t==="glb"}ExportContent(e,t,n,i){t===tn.Text?this.ExportAsciiContent(e,n):t===tn.Binary&&this.ExportBinaryContent(e,n),i()}ExportAsciiContent(e,t){let n=new Yt("model.gltf"),i=new Yt("model.bin");t.push(n),t.push(i);let s=this.GetMeshData(e),o=this.GetMainBuffer(s),a=this.GetMainJson(e,s);a.buffers.push({uri:i.GetName(),byteLength:o.byteLength});let c=new Map;this.ExportMaterials(e,a,l=>{let u=vn(l.name);if(c.has(u))return c.get(u);{let h=new Yt(u);h.SetBufferContent(l.buffer),t.push(h);let f=a.textures.length;return c.set(u,f),a.images.push({uri:u}),a.textures.push({source:f}),f}}),n.SetTextContent(JSON.stringify(a,null,4)),i.SetBufferContent(o)}ExportBinaryContent(e,t){function n(_){let S=_%4;return S===0?_:_+(4-S)}function i(_,S,P){for(let I=0;I<P;I++)_.WriteUnsignedCharacter8(S)}let s=new Yt("model.glb");t.push(s);let o=this.GetMeshData(e),a=this.GetMainBuffer(o),c=this.GetMainJson(e,o),l=[],u=a.byteLength,h=new Map;this.ExportMaterials(e,c,_=>{let S=vn(_.name),P=er(_.name);if(h.has(S))return h.get(S);{let I=c.bufferViews.length,N=c.textures.length;h.set(S,N);let E=_.buffer;return l.push(E),c.bufferViews.push({buffer:0,byteOffset:u,byteLength:E.byteLength}),u+=E.byteLength,c.images.push({bufferView:I,mimeType:"image/"+P}),c.textures.push({source:N}),N}});let f=a.byteLength;for(let _=0;_<l.length;_++){let S=l[_];f+=S.byteLength}let m=n(f);c.buffers.push({byteLength:m});let g=JSON.stringify(c),v=yo(g),p=v.byteLength,d=n(p),x=12+8+d+8+m,y=new Di(x,!0);y.WriteUnsignedInteger32(1179937895),y.WriteUnsignedInteger32(2),y.WriteUnsignedInteger32(x),y.WriteUnsignedInteger32(d),y.WriteUnsignedInteger32(1313821514),y.WriteArrayBuffer(v),i(y,32,d-p),y.WriteUnsignedInteger32(m),y.WriteUnsignedInteger32(5130562),y.WriteArrayBuffer(a);for(let _=0;_<l.length;_++){let S=l[_];y.WriteArrayBuffer(S)}i(y,0,m-f),s.SetBufferContent(y.GetBuffer())}GetMeshData(e){let t=[];return e.EnumerateMeshes(n=>{let i=vo(n);t.push({name:n.GetName(),buffer:i,offsets:[],sizes:[]})}),t}GetMainBuffer(e){let t=0;for(let i of e)t+=i.buffer.GetByteLength(this.components.index.size,this.components.number.size);let n=new Di(t,!0);for(let i of e)for(let s=0;s<i.buffer.PrimitiveCount();s++){let o=i.buffer.GetPrimitive(s),a=n.GetPosition();for(let c=0;c<o.indices.length;c++)n.WriteUnsignedInteger32(o.indices[c]);for(let c=0;c<o.vertices.length;c++)n.WriteFloat32(o.vertices[c]);for(let c=0;c<o.colors.length;c++)n.WriteFloat32(nr(o.colors[c]));for(let c=0;c<o.normals.length;c++)n.WriteFloat32(o.normals[c]);for(let c=0;c<o.uvs.length;c++){let l=o.uvs[c];c%2===1&&(l*=-1),n.WriteFloat32(l)}i.offsets.push(a),i.sizes.push(n.GetPosition()-a)}return n.GetBuffer()}GetMainJson(e,t){class n{constructor(h,f){this.mainJson=h,this.byteOffset=f}AddBufferView(h,f){let m={buffer:0,byteOffset:this.byteOffset,byteLength:h,target:f};return this.mainJson.bufferViews.push(m),this.byteOffset+=h,this.mainJson.bufferViews.length-1}}function i(u,h){for(let f of h.GetMeshIndices()){let m=new yi(h.GetId(),f);if(u.IsMeshInstanceVisible(m))return!0}for(let f of h.GetChildNodes())if(i(u,f))return!0;return!1}function s(u,h,f,m){if(m.IsMeshNode())for(let g of m.GetMeshIndices())o(u,h,f,m,g,!0);else if(i(u,m)){let g={},v=m.GetName();v.length>0&&(g.name=v),m.GetTransformation().IsIdentity()||(g.matrix=m.GetTransformation().GetMatrix().Get()),f.push(g),h.push(f.length-1),g.children=[],a(u,g.children,f,m)}}function o(u,h,f,m,g,v){let p=new yi(m.GetId(),g);if(!u.IsMeshInstanceVisible(p))return;let d={mesh:u.MapMeshIndex(g)};v&&(m.GetTransformation().IsIdentity()||(d.matrix=m.GetTransformation().GetMatrix().Get())),f.push(d),h.push(f.length-1)}function a(u,h,f,m){for(let g of m.GetChildNodes())s(u,h,f,g);for(let g of m.GetMeshIndices())o(u,h,f,m,g,!1)}let c={asset:{generator:"https://3dviewer.net",version:"2.0"},scene:0,scenes:[{nodes:[]}],nodes:[],materials:[],meshes:[],buffers:[],bufferViews:[],accessors:[]},l=e.GetModel().GetRootNode();a(e,c.scenes[0].nodes,c.nodes,l);for(let u of t){let h={name:this.GetExportedMeshName(u.name),primitives:[]},f=u.buffer.primitives;for(let m=0;m<f.length;m++){let g=f[m],v=new n(c,u.offsets[m]),p=v.AddBufferView(g.indices.length*this.components.index.size,ll.ELEMENT_ARRAY_BUFFER),d=v.AddBufferView(g.vertices.length*this.components.number.size,ll.ARRAY_BUFFER),x=null;g.colors.length>0&&(x=v.AddBufferView(g.colors.length*this.components.number.size,ll.ARRAY_BUFFER));let y=v.AddBufferView(g.normals.length*this.components.number.size,ll.ARRAY_BUFFER),_=null;g.uvs.length>0&&(_=v.AddBufferView(g.uvs.length*this.components.number.size,ll.ARRAY_BUFFER));let S={attributes:{},mode:4,material:g.material},P=g.GetBounds();c.accessors.push({bufferView:p,byteOffset:0,componentType:this.components.index.type,count:g.indices.length,type:"SCALAR"}),S.indices=c.accessors.length-1,c.accessors.push({bufferView:d,byteOffset:0,componentType:this.components.number.type,count:g.vertices.length/3,min:P.min,max:P.max,type:"VEC3"}),S.attributes.POSITION=c.accessors.length-1,x!==null&&(c.accessors.push({bufferView:x,byteOffset:0,componentType:this.components.number.type,count:g.colors.length/3,type:"VEC3"}),S.attributes.COLOR_0=c.accessors.length-1),c.accessors.push({bufferView:y,byteOffset:0,componentType:this.components.number.type,count:g.normals.length/3,type:"VEC3"}),S.attributes.NORMAL=c.accessors.length-1,_!==null&&(c.accessors.push({bufferView:_,byteOffset:0,componentType:this.components.number.type,count:g.uvs.length/2,type:"VEC2"}),S.attributes.TEXCOORD_0=c.accessors.length-1),h.primitives.push(S)}c.meshes.push(h)}return c}ExportMaterials(e,t,n){function i(s,o,a,c){function l(p,d){return[nr(p.r/255),nr(p.g/255),nr(p.b/255),d]}function u(p){return[nr(p.r/255),nr(p.g/255),nr(p.b/255)]}function h(p,d,x){if(d===null||!d.IsValid())return null;p.images===void 0&&(p.images=[]),p.textures===void 0&&(p.textures=[]);let _={index:x(d)};if(d.HasTransformation()){let S="KHR_texture_transform";p.extensionsUsed===void 0&&(p.extensionsUsed=[]),p.extensionsUsed.indexOf(S)===-1&&p.extensionsUsed.push(S),_.extensions={KHR_texture_transform:{offset:[d.offset.x,-d.offset.y],scale:[d.scale.x,d.scale.y],rotation:-d.rotation}}}return _}let f={name:s.GetExportedMaterialName(a.name),pbrMetallicRoughness:{baseColorFactor:l(a.color,a.opacity)},emissiveFactor:u(a.emissive),doubleSided:!0,alphaMode:"OPAQUE"};a.transparent&&(f.alphaMode="BLEND");let m=h(o,a.diffuseMap,c);if(m!==null&&(a.multiplyDiffuseMap||(f.pbrMetallicRoughness.baseColorFactor=l(new yt(255,255,255),a.opacity)),f.pbrMetallicRoughness.baseColorTexture=m),a.type===Pn.Physical){let p=h(o,a.metalnessMap,c);p!==null?f.pbrMetallicRoughness.metallicRoughnessTexture=p:(f.pbrMetallicRoughness.metallicFactor=a.metalness,f.pbrMetallicRoughness.roughnessFactor=a.roughness)}let g=h(o,a.normalMap,c);g!==null&&(f.normalTexture=g);let v=h(o,a.emissiveMap,c);v!==null&&(f.emissiveTexture=v),o.materials.push(f)}for(let s=0;s<e.MaterialCount();s++){let o=e.GetMaterial(s);i(this,t,o,n)}}};var cl=class{constructor(e){this.transformation=new Kt,this.isMeshVisible=t=>!0,co(e,this)}},Mo=class{constructor(e,t){this.model=e,this.settings=t||new cl,this.visibleMeshes=null,this.meshToVisibleMeshIndex=null}GetModel(){return this.model}MaterialCount(){return this.model.MaterialCount()}GetMaterial(e){return this.model.GetMaterial(e)}VertexCount(){let e=0;return this.EnumerateMeshInstances(t=>{e+=t.VertexCount()}),e}TriangleCount(){let e=0;return this.EnumerateMeshInstances(t=>{e+=t.TriangleCount()}),e}MeshCount(){let e=0;return this.EnumerateMeshes(t=>{e+=1}),e}EnumerateMeshes(e){this.FillVisibleMeshCache();for(let t=0;t<this.model.MeshCount();t++)if(this.visibleMeshes.has(t)){let n=this.model.GetMesh(t);e(n)}}MapMeshIndex(e){return this.FillVisibleMeshCache(),this.meshToVisibleMeshIndex.get(e)}IsMeshInstanceVisible(e){return this.settings.isMeshVisible(e)}MeshInstanceCount(){let e=0;return this.EnumerateMeshInstances(t=>{e+=1}),e}EnumerateMeshInstances(e){this.model.EnumerateMeshInstances(t=>{this.settings.isMeshVisible(t.GetId())&&e(t)})}EnumerateTransformedMeshInstances(e){this.EnumerateMeshInstances(t=>{let n=t.GetTransformation();this.settings.transformation.IsIdentity()||n.Append(this.settings.transformation);let s=t.GetMesh().Clone();n.IsIdentity()||rr(s,n),e(s)})}EnumerateVerticesAndTriangles(e){let t=[];this.EnumerateTransformedMeshInstances(i=>{t.push(i)});for(let i of t)i.EnumerateVertices(s=>{e.onVertex(s.x,s.y,s.z)});let n=0;for(let i of t)i.EnumerateTriangleVertexIndices((s,o,a)=>{e.onTriangle(s+n,o+n,a+n)}),n+=i.VertexCount()}EnumerateTrianglesWithNormals(e){this.EnumerateTransformedMeshInstances(t=>{t.EnumerateTriangleVertices((n,i,s)=>{let o=Is(n,i,s);e(n,i,s,o)})})}FillVisibleMeshCache(){if(this.visibleMeshes!==null&&this.meshToVisibleMeshIndex!==null)return;this.visibleMeshes=new Set,this.model.EnumerateMeshInstances(t=>{let n=t.GetId();this.settings.isMeshVisible(n)&&this.visibleMeshes.add(n.meshIndex)}),this.meshToVisibleMeshIndex=new Map;let e=0;for(let t=0;t<this.model.MeshCount();t++)this.visibleMeshes.has(t)&&(this.meshToVisibleMeshIndex.set(t,e),e+=1)}};var Zn=class{constructor(){this.text="",this.indentation=0}GetText(){return this.text}Indent(e){this.indentation+=e}WriteArrayLine(e){this.WriteLine(e.join(" "))}WriteLine(e){this.WriteIndentation(),this.Write(e+`
`)}WriteIndentation(){for(let e=0;e<this.indentation;e++)this.Write(" ")}Write(e){this.text+=e}};var bo=class extends Sn{constructor(){super()}CanExport(e,t){return e===tn.Text&&t==="obj"}ExportContent(e,t,n,i){function s(g,v,p,d){if(p===null||!p.IsValid())return;let x=vn(p.name);if(g.WriteArrayLine([v,x]),d.findIndex(_=>_.GetName()===x)===-1){let _=new Yt(x);_.SetBufferContent(p.buffer),d.push(_)}}let o=new Yt("model.mtl"),a=new Yt("model.obj");n.push(o),n.push(a);let c=new Zn;c.WriteLine(this.GetHeaderText());for(let g=0;g<e.MaterialCount();g++){let v=e.GetMaterial(g);c.WriteArrayLine(["newmtl",this.GetExportedMaterialName(v.name)]),c.WriteArrayLine(["Kd",v.color.r/255,v.color.g/255,v.color.b/255]),c.WriteArrayLine(["d",v.opacity]),v.type===Pn.Phong&&(c.WriteArrayLine(["Ka",v.ambient.r/255,v.ambient.g/255,v.ambient.b/255]),c.WriteArrayLine(["Ks",v.specular.r/255,v.specular.g/255,v.specular.b/255]),c.WriteArrayLine(["Ns",v.shininess*1e3])),s(c,"map_Kd",v.diffuseMap,n),v.type===Pn.Phong&&s(c,"map_Ks",v.specularMap,n),s(c,"bump",v.bumpMap,n)}o.SetTextContent(c.GetText());let l=new Zn;l.WriteLine(this.GetHeaderText()),l.WriteArrayLine(["mtllib",o.GetName()]);let u=0,h=0,f=0,m=null;e.EnumerateTransformedMeshInstances(g=>{l.WriteArrayLine(["g",this.GetExportedMeshName(g.GetName())]);for(let v=0;v<g.VertexCount();v++){let p=g.GetVertex(v);l.WriteArrayLine(["v",p.x,p.y,p.z])}for(let v=0;v<g.NormalCount();v++){let p=g.GetNormal(v);l.WriteArrayLine(["vn",p.x,p.y,p.z])}for(let v=0;v<g.TextureUVCount();v++){let p=g.GetTextureUV(v);l.WriteArrayLine(["vt",p.x,p.y])}for(let v=0;v<g.TriangleCount();v++){let p=g.GetTriangle(v),d=p.v0+u+1,x=p.v1+u+1,y=p.v2+u+1,_=p.n0+h+1,S=p.n1+h+1,P=p.n2+h+1;if(p.mat!==null){let R=e.GetMaterial(p.mat),V=this.GetExportedMaterialName(R.name);V!==m&&(l.WriteArrayLine(["usemtl",V]),m=V)}let I="",N="",E="";p.HasTextureUVs()&&(I=p.u0+f+1,N=p.u1+f+1,E=p.u2+f+1),l.WriteArrayLine(["f",[d,I,_].join("/"),[x,N,S].join("/"),[y,E,P].join("/")])}u+=g.VertexCount(),h+=g.NormalCount(),f+=g.TextureUVCount()}),a.SetTextContent(l.GetText()),i()}GetHeaderText(){return"# exported by https://3dviewer.net"}};var So=class extends Sn{constructor(){super()}CanExport(e,t){return e===tn.Text&&t==="off"}ExportContent(e,t,n,i){let s=new Yt("model.off");n.push(s);let o=new Zn;o.WriteLine("OFF"),o.WriteArrayLine([e.VertexCount(),e.TriangleCount(),0]),e.EnumerateVerticesAndTriangles({onVertex:function(a,c,l){o.WriteArrayLine([a,c,l])},onTriangle:function(a,c,l){o.WriteArrayLine([3,a,c,l])}}),s.SetTextContent(o.GetText()),i()}};var Ao=class extends Sn{constructor(){super()}CanExport(e,t){return(e===tn.Text||e===tn.Binary)&&t==="ply"}ExportContent(e,t,n,i){t===tn.Text?this.ExportText(e,n):this.ExportBinary(e,n),i()}ExportText(e,t){let n=new Yt("model.ply");t.push(n);let i=new Zn,s=e.VertexCount(),o=e.TriangleCount(),a=this.GetHeaderText("ascii",s,o);i.Write(a),e.EnumerateVerticesAndTriangles({onVertex:function(c,l,u){i.WriteArrayLine([c,l,u])},onTriangle:function(c,l,u){i.WriteArrayLine([3,c,l,u])}}),n.SetTextContent(i.GetText())}ExportBinary(e,t){let n=new Yt("model.ply");t.push(n);let i=e.VertexCount(),s=e.TriangleCount(),o=this.GetHeaderText("binary_little_endian",i,s),a=o.length+i*3*4+s*(1+3*4),c=new Di(a,!0);for(let l=0;l<o.length;l++)c.WriteUnsignedCharacter8(o.charCodeAt(l));e.EnumerateVerticesAndTriangles({onVertex:function(l,u,h){c.WriteFloat32(l),c.WriteFloat32(u),c.WriteFloat32(h)},onTriangle:function(l,u,h){c.WriteUnsignedCharacter8(3),c.WriteInteger32(l),c.WriteInteger32(u),c.WriteInteger32(h)}}),n.SetBufferContent(c.GetBuffer())}GetHeaderText(e,t,n){let i=new Zn;return i.WriteLine("ply"),i.WriteLine("format "+e+" 1.0"),i.WriteLine("element vertex "+t),i.WriteLine("property float x"),i.WriteLine("property float y"),i.WriteLine("property float z"),i.WriteLine("element face "+n),i.WriteLine("property list uchar int vertex_index"),i.WriteLine("end_header"),i.GetText()}};var wo=class extends Sn{constructor(){super()}CanExport(e,t){return(e===tn.Text||e===tn.Binary)&&t==="stl"}ExportContent(e,t,n,i){t===tn.Text?this.ExportText(e,n):this.ExportBinary(e,n),i()}ExportText(e,t){let n=new Yt("model.stl");t.push(n);let i=new Zn;i.WriteLine("solid Model"),e.EnumerateTrianglesWithNormals((s,o,a,c)=>{i.WriteArrayLine(["facet","normal",c.x,c.y,c.z]),i.Indent(1),i.WriteLine("outer loop"),i.Indent(1),i.WriteArrayLine(["vertex",s.x,s.y,s.z]),i.WriteArrayLine(["vertex",o.x,o.y,o.z]),i.WriteArrayLine(["vertex",a.x,a.y,a.z]),i.Indent(-1),i.WriteLine("endloop"),i.Indent(-1),i.WriteLine("endfacet")}),i.WriteLine("endsolid Model"),n.SetTextContent(i.GetText())}ExportBinary(e,t){let n=new Yt("model.stl");t.push(n);let i=e.TriangleCount(),s=80,o=s+4+i*50,a=new Di(o,!0);for(let c=0;c<s;c++)a.WriteUnsignedCharacter8(0);a.WriteUnsignedInteger32(i),e.EnumerateTrianglesWithNormals((c,l,u,h)=>{a.WriteFloat32(h.x),a.WriteFloat32(h.y),a.WriteFloat32(h.z),a.WriteFloat32(c.x),a.WriteFloat32(c.y),a.WriteFloat32(c.z),a.WriteFloat32(l.x),a.WriteFloat32(l.y),a.WriteFloat32(l.z),a.WriteFloat32(u.x),a.WriteFloat32(u.y),a.WriteFloat32(u.z),a.WriteUnsignedInteger16(0)}),n.SetBufferContent(a.GetBuffer())}};var Lc=class{constructor(){this.exporters=[new bo,new wo,new Ao,new So,new Eo,new xo,new _o]}AddExporter(e){this.exporters.push(e)}Export(e,t,n,i,s){let o=null;for(let c=0;c<this.exporters.length;c++){let l=this.exporters[c];if(l.CanExport(n,i)){o=l;break}}if(o===null){s.onError();return}let a=new Mo(e,t);o.Export(a,n,c=>{c.length===0?s.onError():s.onSuccess(c)})}};var Ps=class{constructor(e,t){this.min=e,this.max=t}GetMin(){return this.min}GetMax(){return this.max}GetCenter(){return new Ge((this.min.x+this.max.x)/2,(this.min.y+this.max.y)/2,(this.min.z+this.max.z)/2)}},Co=class{constructor(){this.box=new Ps(new Ge(1/0,1/0,1/0),new Ge(-1/0,-1/0,-1/0)),this.isValid=!1}GetBox(){return this.isValid?this.box:null}AddPoint(e){this.box.min.x=Math.min(this.box.min.x,e.x),this.box.min.y=Math.min(this.box.min.y,e.y),this.box.min.z=Math.min(this.box.min.z,e.z),this.box.max.x=Math.max(this.box.max.x,e.x),this.box.max.y=Math.max(this.box.max.y,e.y),this.box.max.z=Math.max(this.box.max.z,e.z),this.isValid=!0}};var Ls=class{constructor(e,t){this.boundingBox=e,this.level=t,this.pointItems=[],this.childNodes=[]}AddPoint(e,t,n){let i=this.FindNodeForPoint(e);if(i===null||i.FindPointDirectly(e)!==null)return!1;if(i.pointItems.length<n.maxPointsPerNode||i.level>=n.maxTreeDepth)return i.AddPointDirectly(e,t),!0;{i.CreateChildNodes();let s=i.pointItems;i.pointItems=[];for(let o=0;o<s.length;o++){let a=s[o];if(!i.AddPoint(a.point,a.data,n))return!1}return i.AddPoint(e,t,n)}}FindPoint(e){let t=this.FindNodeForPoint(e);return t===null?null:t.FindPointDirectly(e)}AddPointDirectly(e,t){this.pointItems.push({point:e,data:t})}FindPointDirectly(e){for(let t=0;t<this.pointItems.length;t++){let n=this.pointItems[t];if(oi(e,n.point))return n.data}return null}FindNodeForPoint(e){if(!this.IsPointInBounds(e))return null;if(this.childNodes.length===0)return this;for(let t=0;t<this.childNodes.length;t++){let i=this.childNodes[t].FindNodeForPoint(e);if(i!==null)return i}return null}CreateChildNodes(){function e(a,c,l,u,h,f,m){let g=new Ps(new Ge(c,l,u),new Ge(c+h,l+f,u+m));a.childNodes.push(new Ls(g,a.level+1))}let t=this.boundingBox.min,n=this.bou