From 1fc9d024cf8c549282e9851a297886f67c9e5484 Mon Sep 17 00:00:00 2001 From: xeolabs Date: Tue, 9 Aug 2022 18:06:00 +0200 Subject: [PATCH] Rebuild --- dist/convert2xkt.cjs.js | 40 ++++++++++++++++++++------------------ dist/xeokit-convert.cjs.js | 2 +- dist/xeokit-convert.es.js | 40 ++++++++++++++++++++------------------ 3 files changed, 43 insertions(+), 39 deletions(-) diff --git a/dist/convert2xkt.cjs.js b/dist/convert2xkt.cjs.js index d3598be..004eb08 100644 --- a/dist/convert2xkt.cjs.js +++ b/dist/convert2xkt.cjs.js @@ -25387,28 +25387,13 @@ function getModelData(xktModel, stats) { data.eachTextureSetTextures[eachTextureSetTexturesIndex++] = textureSet.occlusionTexture ? textureSet.occlusionTexture.textureIndex : -1; // Occlusion map } - // Meshes - - for (let meshIndex = 0, matricesIndex = 0, eachMeshMaterialAttributesIndex = 0; meshIndex < numMeshes; meshIndex++) { - const mesh = meshesList [meshIndex]; - if (mesh.geometry.numInstances > 1) { - data.matrices.set(mesh.matrix, matricesIndex); - data.eachMeshMatricesPortion [meshIndex] = matricesIndex; - matricesIndex += 16; - } - data.eachMeshTextureSet[meshIndex] = mesh.textureSet ? mesh.textureSet.textureSetIndex : -1; - data.eachMeshMaterialAttributes[eachMeshMaterialAttributesIndex++] = (mesh.color[0] * 255); // Color RGB - data.eachMeshMaterialAttributes[eachMeshMaterialAttributesIndex++] = (mesh.color[1] * 255); - data.eachMeshMaterialAttributes[eachMeshMaterialAttributesIndex++] = (mesh.color[2] * 255); - data.eachMeshMaterialAttributes[eachMeshMaterialAttributesIndex++] = (mesh.opacity * 255); // Opacity - data.eachMeshMaterialAttributes[eachMeshMaterialAttributesIndex++] = (mesh.metallic * 255); // Metallic - data.eachMeshMaterialAttributes[eachMeshMaterialAttributesIndex++] = (mesh.roughness * 255); // Roughness - } - - // Entities, geometry instances, and tiles + // Tiles -> Entities -> Meshes let entityIndex = 0; let countEntityMeshesPortion = 0; + let eachMeshMaterialAttributesIndex = 0; + let matricesIndex = 0; + let meshIndex= 0; for (let tileIndex = 0; tileIndex < numTiles; tileIndex++) { @@ -25437,6 +25422,23 @@ function getModelData(xktModel, stats) { const geometryIndex = geometry.geometryIndex; data.eachMeshGeometriesPortion [countEntityMeshesPortion + k] = geometryIndex; + + if (mesh.geometry.numInstances > 1) { + data.matrices.set(mesh.matrix, matricesIndex); + data.eachMeshMatricesPortion [meshIndex] = matricesIndex; + matricesIndex += 16; + } + + data.eachMeshTextureSet[meshIndex] = mesh.textureSet ? mesh.textureSet.textureSetIndex : -1; + + data.eachMeshMaterialAttributes[eachMeshMaterialAttributesIndex++] = (mesh.color[0] * 255); // Color RGB + data.eachMeshMaterialAttributes[eachMeshMaterialAttributesIndex++] = (mesh.color[1] * 255); + data.eachMeshMaterialAttributes[eachMeshMaterialAttributesIndex++] = (mesh.color[2] * 255); + data.eachMeshMaterialAttributes[eachMeshMaterialAttributesIndex++] = (mesh.opacity * 255); // Opacity + data.eachMeshMaterialAttributes[eachMeshMaterialAttributesIndex++] = (mesh.metallic * 255); // Metallic + data.eachMeshMaterialAttributes[eachMeshMaterialAttributesIndex++] = (mesh.roughness * 255); // Roughness + + meshIndex++; } data.eachEntityId [entityIndex] = entity.entityId; diff --git a/dist/xeokit-convert.cjs.js b/dist/xeokit-convert.cjs.js index e8e69ef..b5fba82 100644 --- a/dist/xeokit-convert.cjs.js +++ b/dist/xeokit-convert.cjs.js @@ -1,3 +1,3 @@ /*! For license information please see xeokit-convert.cjs.js.LICENSE.txt */ -!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.convert2xkt=t():e.convert2xkt=t()}(global,(()=>(()=>{"use strict";var e={231:e=>{e.exports=require("fs")}},t={};function r(n){var i=t[n];if(void 0!==i)return i.exports;var o=t[n]={exports:{}};return e[n](o,o.exports,r),o.exports}r.d=(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var n={};return(()=>{r.r(n),r.d(n,{ClampToEdgeWrapping:()=>p,GIFMediaType:()=>O,JPEGMediaType:()=>L,LinearFilter:()=>M,LinearMipMapLinearFilter:()=>S,LinearMipMapNearestFilter:()=>T,LinearMipmapLinearFilter:()=>A,LinearMipmapNearestFilter:()=>I,MirroredRepeatWrapping:()=>m,NearestFilter:()=>y,NearestMipMapLinearFilter:()=>b,NearestMipMapNearestFilter:()=>g,NearestMipmapLinearFilter:()=>w,NearestMipmapNearestFilter:()=>x,PNGMediaType:()=>P,RepeatWrapping:()=>d,XKTModel:()=>Xe,XKT_INFO:()=>f,buildBoxGeometry:()=>Nr,buildBoxLinesGeometry:()=>Fr,buildCylinderGeometry:()=>Vr,buildGridGeometry:()=>Cr,buildPlaneGeometry:()=>Br,buildSphereGeometry:()=>Ur,buildTorusGeometry:()=>zr,buildVectorTextGeometry:()=>Xr,convert2xkt:()=>Wr,parseCityJSONIntoXKTModel:()=>Pt,parseGLTFIntoXKTModel:()=>Bt,parseGLTFJSONIntoXKTModel:()=>Jt,parseIFCIntoXKTModel:()=>ar,parseLASIntoXKTModel:()=>lr,parseMetaModelIntoXKTModel:()=>pr,parsePCDIntoXKTModel:()=>vr,parsePLYIntoXKTModel:()=>br,parseSTLIntoXKTModel:()=>Or,writeXKTModelToArrayBuffer:()=>Ze});const e=require("@loaders.gl/polyfills");var t,i,o,a,s,u,c,l,h,f={xktVersion:10},d=1e3,p=1001,m=1002,y=1003,g=1004,x=1004,w=1005,b=1005,M=1006,I=1007,T=1007,A=1008,S=1008,O=1e4,L=10001,P=10002,E=Float64Array,j=new E(16),G=new E(16),_=new E(4),k={MIN_DOUBLE:-Number.MAX_SAFE_INTEGER,MAX_DOUBLE:Number.MAX_SAFE_INTEGER,DEGTORAD:.0174532925,RADTODEG:57.295779513,vec2:function(e){return new E(e||2)},vec3:function(e){return new E(e||3)},vec4:function(e){return new E(e||4)},mat3:function(e){return new E(e||9)},mat3ToMat4:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new E(16);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=0,t[4]=e[3],t[5]=e[4],t[6]=e[5],t[7]=0,t[8]=e[6],t[9]=e[7],t[10]=e[8],t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t},mat4:function(e){return new E(e||16)},mat4ToMat3:function(e,t){},createUUID:function(){for(var e=[],t=0;t<256;t++)e[t]=(t<16?"0":"")+t.toString(16);return function(){var t=4294967295*Math.random()|0,r=4294967295*Math.random()|0,n=4294967295*Math.random()|0,i=4294967295*Math.random()|0;return"".concat(e[255&t]+e[t>>8&255]+e[t>>16&255]+e[t>>24&255],"-").concat(e[255&r]).concat(e[r>>8&255],"-").concat(e[r>>16&15|64]).concat(e[r>>24&255],"-").concat(e[63&n|128]).concat(e[n>>8&255],"-").concat(e[n>>16&255]).concat(e[n>>24&255]).concat(e[255&i]).concat(e[i>>8&255]).concat(e[i>>16&255]).concat(e[i>>24&255])}}(),clamp:function(e,t,r){return Math.max(t,Math.min(r,e))},fmod:function(e,t){if(e1?1:r,Math.acos(r)},vec3FromMat4Scale:(u=new E(3),function(e,t){return u[0]=e[0],u[1]=e[1],u[2]=e[2],t[0]=k.lenVec3(u),u[0]=e[4],u[1]=e[5],u[2]=e[6],t[1]=k.lenVec3(u),u[0]=e[8],u[1]=e[9],u[2]=e[10],t[2]=k.lenVec3(u),t}),vecToArray:function(){function e(e){return Math.round(1e5*e)/1e5}return function(t){for(var r=0,n=(t=Array.prototype.slice.call(t)).length;r0&&void 0!==arguments[0]?arguments[0]:new E(16);return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e},identityMat3:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new E(9);return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=1,e[5]=0,e[6]=0,e[7]=0,e[8]=1,e},isIdentityMat4:function(e){return 1===e[0]&&0===e[1]&&0===e[2]&&0===e[3]&&0===e[4]&&1===e[5]&&0===e[6]&&0===e[7]&&0===e[8]&&0===e[9]&&1===e[10]&&0===e[11]&&0===e[12]&&0===e[13]&&0===e[14]&&1===e[15]},negateMat4:function(e,t){return t||(t=e),t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t[3]=-e[3],t[4]=-e[4],t[5]=-e[5],t[6]=-e[6],t[7]=-e[7],t[8]=-e[8],t[9]=-e[9],t[10]=-e[10],t[11]=-e[11],t[12]=-e[12],t[13]=-e[13],t[14]=-e[14],t[15]=-e[15],t},addMat4:function(e,t,r){return r||(r=e),r[0]=e[0]+t[0],r[1]=e[1]+t[1],r[2]=e[2]+t[2],r[3]=e[3]+t[3],r[4]=e[4]+t[4],r[5]=e[5]+t[5],r[6]=e[6]+t[6],r[7]=e[7]+t[7],r[8]=e[8]+t[8],r[9]=e[9]+t[9],r[10]=e[10]+t[10],r[11]=e[11]+t[11],r[12]=e[12]+t[12],r[13]=e[13]+t[13],r[14]=e[14]+t[14],r[15]=e[15]+t[15],r},addMat4Scalar:function(e,t,r){return r||(r=e),r[0]=e[0]+t,r[1]=e[1]+t,r[2]=e[2]+t,r[3]=e[3]+t,r[4]=e[4]+t,r[5]=e[5]+t,r[6]=e[6]+t,r[7]=e[7]+t,r[8]=e[8]+t,r[9]=e[9]+t,r[10]=e[10]+t,r[11]=e[11]+t,r[12]=e[12]+t,r[13]=e[13]+t,r[14]=e[14]+t,r[15]=e[15]+t,r},addScalarMat4:function(e,t,r){return k.addMat4Scalar(t,e,r)},subMat4:function(e,t,r){return r||(r=e),r[0]=e[0]-t[0],r[1]=e[1]-t[1],r[2]=e[2]-t[2],r[3]=e[3]-t[3],r[4]=e[4]-t[4],r[5]=e[5]-t[5],r[6]=e[6]-t[6],r[7]=e[7]-t[7],r[8]=e[8]-t[8],r[9]=e[9]-t[9],r[10]=e[10]-t[10],r[11]=e[11]-t[11],r[12]=e[12]-t[12],r[13]=e[13]-t[13],r[14]=e[14]-t[14],r[15]=e[15]-t[15],r},subMat4Scalar:function(e,t,r){return r||(r=e),r[0]=e[0]-t,r[1]=e[1]-t,r[2]=e[2]-t,r[3]=e[3]-t,r[4]=e[4]-t,r[5]=e[5]-t,r[6]=e[6]-t,r[7]=e[7]-t,r[8]=e[8]-t,r[9]=e[9]-t,r[10]=e[10]-t,r[11]=e[11]-t,r[12]=e[12]-t,r[13]=e[13]-t,r[14]=e[14]-t,r[15]=e[15]-t,r},subScalarMat4:function(e,t,r){return r||(r=t),r[0]=e-t[0],r[1]=e-t[1],r[2]=e-t[2],r[3]=e-t[3],r[4]=e-t[4],r[5]=e-t[5],r[6]=e-t[6],r[7]=e-t[7],r[8]=e-t[8],r[9]=e-t[9],r[10]=e-t[10],r[11]=e-t[11],r[12]=e-t[12],r[13]=e-t[13],r[14]=e-t[14],r[15]=e-t[15],r},mulMat4:function(e,t,r){r||(r=e);var n=e[0],i=e[1],o=e[2],a=e[3],s=e[4],u=e[5],c=e[6],l=e[7],h=e[8],f=e[9],d=e[10],p=e[11],v=e[12],m=e[13],y=e[14],g=e[15],x=t[0],w=t[1],b=t[2],M=t[3],I=t[4],T=t[5],A=t[6],S=t[7],O=t[8],L=t[9],P=t[10],E=t[11],j=t[12],G=t[13],_=t[14],k=t[15];return r[0]=x*n+w*s+b*h+M*v,r[1]=x*i+w*u+b*f+M*m,r[2]=x*o+w*c+b*d+M*y,r[3]=x*a+w*l+b*p+M*g,r[4]=I*n+T*s+A*h+S*v,r[5]=I*i+T*u+A*f+S*m,r[6]=I*o+T*c+A*d+S*y,r[7]=I*a+T*l+A*p+S*g,r[8]=O*n+L*s+P*h+E*v,r[9]=O*i+L*u+P*f+E*m,r[10]=O*o+L*c+P*d+E*y,r[11]=O*a+L*l+P*p+E*g,r[12]=j*n+G*s+_*h+k*v,r[13]=j*i+G*u+_*f+k*m,r[14]=j*o+G*c+_*d+k*y,r[15]=j*a+G*l+_*p+k*g,r},mulMat3:function(e,t,r){r||(r=new E(9));var n=e[0],i=e[3],o=e[6],a=e[1],s=e[4],u=e[7],c=e[2],l=e[5],h=e[8],f=t[0],d=t[3],p=t[6],v=t[1],m=t[4],y=t[7],g=t[2],x=t[5],w=t[8];return r[0]=n*f+i*v+o*g,r[3]=n*d+i*m+o*x,r[6]=n*p+i*y+o*w,r[1]=a*f+s*v+u*g,r[4]=a*d+s*m+u*x,r[7]=a*p+s*y+u*w,r[2]=c*f+l*v+h*g,r[5]=c*d+l*m+h*x,r[8]=c*p+l*y+h*w,r},mulMat4Scalar:function(e,t,r){return r||(r=e),r[0]=e[0]*t,r[1]=e[1]*t,r[2]=e[2]*t,r[3]=e[3]*t,r[4]=e[4]*t,r[5]=e[5]*t,r[6]=e[6]*t,r[7]=e[7]*t,r[8]=e[8]*t,r[9]=e[9]*t,r[10]=e[10]*t,r[11]=e[11]*t,r[12]=e[12]*t,r[13]=e[13]*t,r[14]=e[14]*t,r[15]=e[15]*t,r},mulMat4v4:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:k.vec4(),n=t[0],i=t[1],o=t[2],a=t[3];return r[0]=e[0]*n+e[4]*i+e[8]*o+e[12]*a,r[1]=e[1]*n+e[5]*i+e[9]*o+e[13]*a,r[2]=e[2]*n+e[6]*i+e[10]*o+e[14]*a,r[3]=e[3]*n+e[7]*i+e[11]*o+e[15]*a,r},transposeMat4:function(e,t){var r=e[4],n=e[14],i=e[8],o=e[13],a=e[12],s=e[9];if(!t||e===t){var u=e[1],c=e[2],l=e[3],h=e[6],f=e[7],d=e[11];return e[1]=r,e[2]=i,e[3]=a,e[4]=u,e[6]=s,e[7]=o,e[8]=c,e[9]=h,e[11]=n,e[12]=l,e[13]=f,e[14]=d,e}return t[0]=e[0],t[1]=r,t[2]=i,t[3]=a,t[4]=e[1],t[5]=e[5],t[6]=s,t[7]=o,t[8]=e[2],t[9]=e[6],t[10]=e[10],t[11]=n,t[12]=e[3],t[13]=e[7],t[14]=e[11],t[15]=e[15],t},transposeMat3:function(e,t){if(t===e){var r=e[1],n=e[2],i=e[5];t[1]=e[3],t[2]=e[6],t[3]=r,t[5]=e[7],t[6]=n,t[7]=i}else t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8];return t},determinantMat4:function(e){var t=e[0],r=e[1],n=e[2],i=e[3],o=e[4],a=e[5],s=e[6],u=e[7],c=e[8],l=e[9],h=e[10],f=e[11],d=e[12],p=e[13],v=e[14],m=e[15];return d*l*s*i-c*p*s*i-d*a*h*i+o*p*h*i+c*a*v*i-o*l*v*i-d*l*n*u+c*p*n*u+d*r*h*u-t*p*h*u-c*r*v*u+t*l*v*u+d*a*n*f-o*p*n*f-d*r*s*f+t*p*s*f+o*r*v*f-t*a*v*f-c*a*n*m+o*l*n*m+c*r*s*m-t*l*s*m-o*r*h*m+t*a*h*m},inverseMat4:function(e,t){t||(t=e);var r=e[0],n=e[1],i=e[2],o=e[3],a=e[4],s=e[5],u=e[6],c=e[7],l=e[8],h=e[9],f=e[10],d=e[11],p=e[12],v=e[13],m=e[14],y=e[15],g=r*s-n*a,x=r*u-i*a,w=r*c-o*a,b=n*u-i*s,M=n*c-o*s,I=i*c-o*u,T=l*v-h*p,A=l*m-f*p,S=l*y-d*p,O=h*m-f*v,L=h*y-d*v,P=f*y-d*m,E=1/(g*P-x*L+w*O+b*S-M*A+I*T);return t[0]=(s*P-u*L+c*O)*E,t[1]=(-n*P+i*L-o*O)*E,t[2]=(v*I-m*M+y*b)*E,t[3]=(-h*I+f*M-d*b)*E,t[4]=(-a*P+u*S-c*A)*E,t[5]=(r*P-i*S+o*A)*E,t[6]=(-p*I+m*w-y*x)*E,t[7]=(l*I-f*w+d*x)*E,t[8]=(a*L-s*S+c*T)*E,t[9]=(-r*L+n*S-o*T)*E,t[10]=(p*M-v*w+y*g)*E,t[11]=(-l*M+h*w-d*g)*E,t[12]=(-a*O+s*A-u*T)*E,t[13]=(r*O-n*A+i*T)*E,t[14]=(-p*b+v*x-m*g)*E,t[15]=(l*b-h*x+f*g)*E,t},traceMat4:function(e){return e[0]+e[5]+e[10]+e[15]},translationMat4v:function(e,t){var r=t||k.identityMat4();return r[12]=e[0],r[13]=e[1],r[14]=e[2],r},translationMat3v:function(e,t){var r=t||k.identityMat3();return r[6]=e[0],r[7]=e[1],r},translationMat4c:(s=new E(3),function(e,t,r,n){return s[0]=e,s[1]=t,s[2]=r,k.translationMat4v(s,n)}),translationMat4s:function(e,t){return k.translationMat4c(e,e,e,t)},translateMat4v:function(e,t){return k.translateMat4c(e[0],e[1],e[2],t)},OLDtranslateMat4c:function(e,t,r,n){var i=n[12];n[0]+=i*e,n[4]+=i*t,n[8]+=i*r;var o=n[13];n[1]+=o*e,n[5]+=o*t,n[9]+=o*r;var a=n[14];n[2]+=a*e,n[6]+=a*t,n[10]+=a*r;var s=n[15];return n[3]+=s*e,n[7]+=s*t,n[11]+=s*r,n},translateMat4c:function(e,t,r,n){var i=n[3];n[0]+=i*e,n[1]+=i*t,n[2]+=i*r;var o=n[7];n[4]+=o*e,n[5]+=o*t,n[6]+=o*r;var a=n[11];n[8]+=a*e,n[9]+=a*t,n[10]+=a*r;var s=n[15];return n[12]+=s*e,n[13]+=s*t,n[14]+=s*r,n},rotationMat4v:function(e,t,r){var n,i,o,a,s,u,c=k.normalizeVec4([t[0],t[1],t[2],0],[]),l=Math.sin(e),h=Math.cos(e),f=1-h,d=c[0],p=c[1],v=c[2];return n=d*p,i=p*v,o=v*d,a=d*l,s=p*l,u=v*l,(r=r||k.mat4())[0]=f*d*d+h,r[1]=f*n+u,r[2]=f*o-s,r[3]=0,r[4]=f*n-u,r[5]=f*p*p+h,r[6]=f*i+a,r[7]=0,r[8]=f*o+s,r[9]=f*i-a,r[10]=f*v*v+h,r[11]=0,r[12]=0,r[13]=0,r[14]=0,r[15]=1,r},rotationMat4c:function(e,t,r,n,i){return k.rotationMat4v(e,[t,r,n],i)},scalingMat4v:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:k.identityMat4();return t[0]=e[0],t[5]=e[1],t[10]=e[2],t},scalingMat3v:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:k.identityMat3();return t[0]=e[0],t[4]=e[1],t},scalingMat4c:function(){var e=new E(3);return function(t,r,n,i){return e[0]=t,e[1]=r,e[2]=n,k.scalingMat4v(e,i)}}(),scaleMat4c:function(e,t,r,n){return n[0]*=e,n[4]*=t,n[8]*=r,n[1]*=e,n[5]*=t,n[9]*=r,n[2]*=e,n[6]*=t,n[10]*=r,n[3]*=e,n[7]*=t,n[11]*=r,n},scaleMat4v:function(e,t){var r=e[0],n=e[1],i=e[2];return t[0]*=r,t[4]*=n,t[8]*=i,t[1]*=r,t[5]*=n,t[9]*=i,t[2]*=r,t[6]*=n,t[10]*=i,t[3]*=r,t[7]*=n,t[11]*=i,t},scalingMat4s:function(e){return k.scalingMat4c(e,e,e)},rotationTranslationMat4:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:k.mat4(),n=e[0],i=e[1],o=e[2],a=e[3],s=n+n,u=i+i,c=o+o,l=n*s,h=n*u,f=n*c,d=i*u,p=i*c,v=o*c,m=a*s,y=a*u,g=a*c;return r[0]=1-(d+v),r[1]=h+g,r[2]=f-y,r[3]=0,r[4]=h-g,r[5]=1-(l+v),r[6]=p+m,r[7]=0,r[8]=f+y,r[9]=p-m,r[10]=1-(l+d),r[11]=0,r[12]=t[0],r[13]=t[1],r[14]=t[2],r[15]=1,r},mat4ToEuler:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:k.vec4(),n=k.clamp,i=e[0],o=e[4],a=e[8],s=e[1],u=e[5],c=e[9],l=e[2],h=e[6],f=e[10];return"XYZ"===t?(r[1]=Math.asin(n(a,-1,1)),Math.abs(a)<.99999?(r[0]=Math.atan2(-c,f),r[2]=Math.atan2(-o,i)):(r[0]=Math.atan2(h,u),r[2]=0)):"YXZ"===t?(r[0]=Math.asin(-n(c,-1,1)),Math.abs(c)<.99999?(r[1]=Math.atan2(a,f),r[2]=Math.atan2(s,u)):(r[1]=Math.atan2(-l,i),r[2]=0)):"ZXY"===t?(r[0]=Math.asin(n(h,-1,1)),Math.abs(h)<.99999?(r[1]=Math.atan2(-l,f),r[2]=Math.atan2(-o,u)):(r[1]=0,r[2]=Math.atan2(s,i))):"ZYX"===t?(r[1]=Math.asin(-n(l,-1,1)),Math.abs(l)<.99999?(r[0]=Math.atan2(h,f),r[2]=Math.atan2(s,i)):(r[0]=0,r[2]=Math.atan2(-o,u))):"YZX"===t?(r[2]=Math.asin(n(s,-1,1)),Math.abs(s)<.99999?(r[0]=Math.atan2(-c,u),r[1]=Math.atan2(-l,i)):(r[0]=0,r[1]=Math.atan2(a,f))):"XZY"===t&&(r[2]=Math.asin(-n(o,-1,1)),Math.abs(o)<.99999?(r[0]=Math.atan2(h,u),r[1]=Math.atan2(a,i)):(r[0]=Math.atan2(-c,f),r[1]=0)),r},composeMat4:function(e,t,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:k.mat4();return k.quaternionToRotationMat4(t,n),k.scaleMat4v(r,n),k.translateMat4v(e,n),n},decomposeMat4:function(){var e=new E(3),t=new E(16);return function(r,n,i,o){e[0]=r[0],e[1]=r[1],e[2]=r[2];var a=k.lenVec3(e);e[0]=r[4],e[1]=r[5],e[2]=r[6];var s=k.lenVec3(e);e[8]=r[8],e[9]=r[9],e[10]=r[10];var u=k.lenVec3(e);k.determinantMat4(r)<0&&(a=-a),n[0]=r[12],n[1]=r[13],n[2]=r[14],t.set(r);var c=1/a,l=1/s,h=1/u;return t[0]*=c,t[1]*=c,t[2]*=c,t[4]*=l,t[5]*=l,t[6]*=l,t[8]*=h,t[9]*=h,t[10]*=h,k.mat4ToQuaternion(t,i),o[0]=a,o[1]=s,o[2]=u,this}}(),lookAtMat4v:function(e,t,r,n){n||(n=k.mat4());var i,o,a,s,u,c,l,h,f,d,p=e[0],v=e[1],m=e[2],y=r[0],g=r[1],x=r[2],w=t[0],b=t[1],M=t[2];return p===w&&v===b&&m===M?k.identityMat4():(i=p-w,o=v-b,a=m-M,s=g*(a*=d=1/Math.sqrt(i*i+o*o+a*a))-x*(o*=d),u=x*(i*=d)-y*a,c=y*o-g*i,(d=Math.sqrt(s*s+u*u+c*c))?(s*=d=1/d,u*=d,c*=d):(s=0,u=0,c=0),l=o*c-a*u,h=a*s-i*c,f=i*u-o*s,(d=Math.sqrt(l*l+h*h+f*f))?(l*=d=1/d,h*=d,f*=d):(l=0,h=0,f=0),n[0]=s,n[1]=l,n[2]=i,n[3]=0,n[4]=u,n[5]=h,n[6]=o,n[7]=0,n[8]=c,n[9]=f,n[10]=a,n[11]=0,n[12]=-(s*p+u*v+c*m),n[13]=-(l*p+h*v+f*m),n[14]=-(i*p+o*v+a*m),n[15]=1,n)},lookAtMat4c:function(e,t,r,n,i,o,a,s,u){return k.lookAtMat4v([e,t,r],[n,i,o],[a,s,u],[])},orthoMat4c:function(e,t,r,n,i,o,a){a||(a=k.mat4());var s=t-e,u=n-r,c=o-i;return a[0]=2/s,a[1]=0,a[2]=0,a[3]=0,a[4]=0,a[5]=2/u,a[6]=0,a[7]=0,a[8]=0,a[9]=0,a[10]=-2/c,a[11]=0,a[12]=-(e+t)/s,a[13]=-(n+r)/u,a[14]=-(o+i)/c,a[15]=1,a},frustumMat4v:function(e,t,r){r||(r=k.mat4());var n=[e[0],e[1],e[2],0],i=[t[0],t[1],t[2],0];k.addVec4(i,n,j),k.subVec4(i,n,G);var o=2*n[2],a=G[0],s=G[1],u=G[2];return r[0]=o/a,r[1]=0,r[2]=0,r[3]=0,r[4]=0,r[5]=o/s,r[6]=0,r[7]=0,r[8]=j[0]/a,r[9]=j[1]/s,r[10]=-j[2]/u,r[11]=-1,r[12]=0,r[13]=0,r[14]=-o*i[2]/u,r[15]=0,r},frustumMat4:function(e,t,r,n,i,o,a){a||(a=k.mat4());var s=t-e,u=n-r,c=o-i;return a[0]=2*i/s,a[1]=0,a[2]=0,a[3]=0,a[4]=0,a[5]=2*i/u,a[6]=0,a[7]=0,a[8]=(t+e)/s,a[9]=(n+r)/u,a[10]=-(o+i)/c,a[11]=-1,a[12]=0,a[13]=0,a[14]=-o*i*2/c,a[15]=0,a},perspectiveMat4:function(e,t,r,n,i){var o=[],a=[];return o[2]=r,a[2]=n,a[1]=o[2]*Math.tan(e/2),o[1]=-a[1],a[0]=a[1]*t,o[0]=-a[0],k.frustumMat4v(o,a,i)},transformPoint3:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:k.vec3(),n=t[0],i=t[1],o=t[2];return r[0]=e[0]*n+e[4]*i+e[8]*o+e[12],r[1]=e[1]*n+e[5]*i+e[9]*o+e[13],r[2]=e[2]*n+e[6]*i+e[10]*o+e[14],r},transformPoint4:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:k.vec4();return r[0]=e[0]*t[0]+e[4]*t[1]+e[8]*t[2]+e[12]*t[3],r[1]=e[1]*t[0]+e[5]*t[1]+e[9]*t[2]+e[13]*t[3],r[2]=e[2]*t[0]+e[6]*t[1]+e[10]*t[2]+e[14]*t[3],r[3]=e[3]*t[0]+e[7]*t[1]+e[11]*t[2]+e[15]*t[3],r},transformPoints3:function(e,t,r){for(var n,i,o,a,s,u=r||[],c=t.length,l=e[0],h=e[1],f=e[2],d=e[3],p=e[4],v=e[5],m=e[6],y=e[7],g=e[8],x=e[9],w=e[10],b=e[11],M=e[12],I=e[13],T=e[14],A=e[15],S=0;S2&&void 0!==arguments[2]?arguments[2]:t,s=t.length,u=e[0],c=e[1],l=e[2],h=e[3],f=e[4],d=e[5],p=e[6],v=e[7],m=e[8],y=e[9],g=e[10],x=e[11],w=e[12],b=e[13],M=e[14],I=e[15];for(r=0;r2&&void 0!==arguments[2]?arguments[2]:t,s=t.length,u=e[0],c=e[1],l=e[2],h=e[3],f=e[4],d=e[5],p=e[6],v=e[7],m=e[8],y=e[9],g=e[10],x=e[11],w=e[12],b=e[13],M=e[14],I=e[15];for(r=0;r0&&void 0!==arguments[0]?arguments[0]:k.vec4();return e[0]=0,e[1]=0,e[2]=0,e[3]=1,e},eulerToQuaternion:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:k.vec4(),n=e[0]*k.DEGTORAD/2,i=e[1]*k.DEGTORAD/2,o=e[2]*k.DEGTORAD/2,a=Math.cos(n),s=Math.cos(i),u=Math.cos(o),c=Math.sin(n),l=Math.sin(i),h=Math.sin(o);return"XYZ"===t?(r[0]=c*s*u+a*l*h,r[1]=a*l*u-c*s*h,r[2]=a*s*h+c*l*u,r[3]=a*s*u-c*l*h):"YXZ"===t?(r[0]=c*s*u+a*l*h,r[1]=a*l*u-c*s*h,r[2]=a*s*h-c*l*u,r[3]=a*s*u+c*l*h):"ZXY"===t?(r[0]=c*s*u-a*l*h,r[1]=a*l*u+c*s*h,r[2]=a*s*h+c*l*u,r[3]=a*s*u-c*l*h):"ZYX"===t?(r[0]=c*s*u-a*l*h,r[1]=a*l*u+c*s*h,r[2]=a*s*h-c*l*u,r[3]=a*s*u+c*l*h):"YZX"===t?(r[0]=c*s*u+a*l*h,r[1]=a*l*u+c*s*h,r[2]=a*s*h-c*l*u,r[3]=a*s*u-c*l*h):"XZY"===t&&(r[0]=c*s*u-a*l*h,r[1]=a*l*u-c*s*h,r[2]=a*s*h+c*l*u,r[3]=a*s*u+c*l*h),r},mat4ToQuaternion:function(e){var t,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:k.vec4(),n=e[0],i=e[4],o=e[8],a=e[1],s=e[5],u=e[9],c=e[2],l=e[6],h=e[10],f=n+s+h;return f>0?(t=.5/Math.sqrt(f+1),r[3]=.25/t,r[0]=(l-u)*t,r[1]=(o-c)*t,r[2]=(a-i)*t):n>s&&n>h?(t=2*Math.sqrt(1+n-s-h),r[3]=(l-u)/t,r[0]=.25*t,r[1]=(i+a)/t,r[2]=(o+c)/t):s>h?(t=2*Math.sqrt(1+s-n-h),r[3]=(o-c)/t,r[0]=(i+a)/t,r[1]=.25*t,r[2]=(u+l)/t):(t=2*Math.sqrt(1+h-n-s),r[3]=(a-i)/t,r[0]=(o+c)/t,r[1]=(u+l)/t,r[2]=.25*t),r},vec3PairToQuaternion:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:k.vec4(),n=Math.sqrt(k.dotVec3(e,e)*k.dotVec3(t,t)),i=n+k.dotVec3(e,t);return i<1e-8*n?(i=0,Math.abs(e[0])>Math.abs(e[2])?(r[0]=-e[1],r[1]=e[0],r[2]=0):(r[0]=0,r[1]=-e[2],r[2]=e[1])):k.cross3Vec3(e,t,r),r[3]=i,k.normalizeQuaternion(r)},angleAxisToQuaternion:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:k.vec4(),r=e[3]/2,n=Math.sin(r);return t[0]=n*e[0],t[1]=n*e[1],t[2]=n*e[2],t[3]=Math.cos(r),t},quaternionToEuler:function(){var e=new E(16);return function(t,r,n){return n=n||k.vec3(),k.quaternionToRotationMat4(t,e),k.mat4ToEuler(e,r,n),n}}(),mulQuaternions:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:k.vec4(),n=e[0],i=e[1],o=e[2],a=e[3],s=t[0],u=t[1],c=t[2],l=t[3];return r[0]=a*s+n*l+i*c-o*u,r[1]=a*u+i*l+o*s-n*c,r[2]=a*c+o*l+n*u-i*s,r[3]=a*l-n*s-i*u-o*c,r},vec3ApplyQuaternion:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:k.vec3(),n=t[0],i=t[1],o=t[2],a=e[0],s=e[1],u=e[2],c=e[3],l=c*n+s*o-u*i,h=c*i+u*n-a*o,f=c*o+a*i-s*n,d=-a*n-s*i-u*o;return r[0]=l*c+d*-a+h*-u-f*-s,r[1]=h*c+d*-s+f*-a-l*-u,r[2]=f*c+d*-u+l*-s-h*-a,r},quaternionToMat4:function(e,t){t=k.identityMat4(t);var r=e[0],n=e[1],i=e[2],o=e[3],a=2*r,s=2*n,u=2*i,c=a*o,l=s*o,h=u*o,f=a*r,d=s*r,p=u*r,v=s*n,m=u*n,y=u*i;return t[0]=1-(v+y),t[1]=d+h,t[2]=p-l,t[4]=d-h,t[5]=1-(f+y),t[6]=m+c,t[8]=p+l,t[9]=m-c,t[10]=1-(f+v),t},quaternionToRotationMat4:function(e,t){var r=e[0],n=e[1],i=e[2],o=e[3],a=r+r,s=n+n,u=i+i,c=r*a,l=r*s,h=r*u,f=n*s,d=n*u,p=i*u,v=o*a,m=o*s,y=o*u;return t[0]=1-(f+p),t[4]=l-y,t[8]=h+m,t[1]=l+y,t[5]=1-(c+p),t[9]=d-v,t[2]=h-m,t[6]=d+v,t[10]=1-(c+f),t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t},normalizeQuaternion:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:e,r=k.lenVec4([e[0],e[1],e[2],e[3]]);return t[0]=e[0]/r,t[1]=e[1]/r,t[2]=e[2]/r,t[3]=e[3]/r,t},conjugateQuaternion:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:e;return t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t[3]=e[3],t},inverseQuaternion:function(e,t){return k.normalizeQuaternion(k.conjugateQuaternion(e,t))},quaternionToAngleAxis:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:k.vec4(),r=(e=k.normalizeQuaternion(e,_))[3],n=2*Math.acos(r),i=Math.sqrt(1-r*r);return i<.001?(t[0]=e[0],t[1]=e[1],t[2]=e[2]):(t[0]=e[0]/i,t[1]=e[1]/i,t[2]=e[2]/i),t[3]=n,t},AABB3:function(e){return new E(e||6)},AABB2:function(e){return new E(e||4)},OBB3:function(e){return new E(e||32)},OBB2:function(e){return new E(e||16)},Sphere3:function(e,t,r,n){return new E([e,t,r,n])},transformOBB3:function(e,t){var r,n,i,o,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:t,s=t.length,u=e[0],c=e[1],l=e[2],h=e[3],f=e[4],d=e[5],p=e[6],v=e[7],m=e[8],y=e[9],g=e[10],x=e[11],w=e[12],b=e[13],M=e[14],I=e[15];for(r=0;rs?a:s,o[1]+=u>c?u:c,o[2]+=l>h?l:h,Math.abs(k.lenVec3(o))}}(),getAABB3Center:function(e,t){var r=t||k.vec3();return r[0]=(e[0]+e[3])/2,r[1]=(e[1]+e[4])/2,r[2]=(e[2]+e[5])/2,r},getAABB2Center:function(e,t){var r=t||k.vec2();return r[0]=(e[2]+e[0])/2,r[1]=(e[3]+e[1])/2,r},collapseAABB3:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:k.AABB3();return e[0]=k.MAX_DOUBLE,e[1]=k.MAX_DOUBLE,e[2]=k.MAX_DOUBLE,e[3]=-k.MAX_DOUBLE,e[4]=-k.MAX_DOUBLE,e[5]=-k.MAX_DOUBLE,e},AABB3ToOBB3:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:k.OBB3();return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=1,t[4]=e[3],t[5]=e[1],t[6]=e[2],t[7]=1,t[8]=e[3],t[9]=e[4],t[10]=e[2],t[11]=1,t[12]=e[0],t[13]=e[4],t[14]=e[2],t[15]=1,t[16]=e[0],t[17]=e[1],t[18]=e[5],t[19]=1,t[20]=e[3],t[21]=e[1],t[22]=e[5],t[23]=1,t[24]=e[3],t[25]=e[4],t[26]=e[5],t[27]=1,t[28]=e[0],t[29]=e[4],t[30]=e[5],t[31]=1,t},positions3ToAABB3:(t=new E(3),function(e,r,n){r=r||k.AABB3();for(var i,o,a,s=k.MAX_DOUBLE,u=k.MAX_DOUBLE,c=k.MAX_DOUBLE,l=-k.MAX_DOUBLE,h=-k.MAX_DOUBLE,f=-k.MAX_DOUBLE,d=0,p=e.length;dl&&(l=i),o>h&&(h=o),a>f&&(f=a);return r[0]=s,r[1]=u,r[2]=c,r[3]=l,r[4]=h,r[5]=f,r}),OBB3ToAABB3:function(e){for(var t,r,n,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:k.AABB3(),o=k.MAX_DOUBLE,a=k.MAX_DOUBLE,s=k.MAX_DOUBLE,u=-k.MAX_DOUBLE,c=-k.MAX_DOUBLE,l=-k.MAX_DOUBLE,h=0,f=e.length;hu&&(u=t),r>c&&(c=r),n>l&&(l=n);return i[0]=o,i[1]=a,i[2]=s,i[3]=u,i[4]=c,i[5]=l,i},points3ToAABB3:function(e){for(var t,r,n,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:k.AABB3(),o=k.MAX_DOUBLE,a=k.MAX_DOUBLE,s=k.MAX_DOUBLE,u=-k.MAX_DOUBLE,c=-k.MAX_DOUBLE,l=-k.MAX_DOUBLE,h=0,f=e.length;hu&&(u=t),r>c&&(c=r),n>l&&(l=n);return i[0]=o,i[1]=a,i[2]=s,i[3]=u,i[4]=c,i[5]=l,i},points3ToSphere3:function(){var e=new E(3);return function(t,r){r=r||k.vec4();var n,i=0,o=0,a=0,s=t.length;for(n=0;nc&&(c=u);return r[3]=c,r}}(),positions3ToSphere3:function(){var e=new E(3),t=new E(3);return function(r,n){n=n||k.vec4();var i,o=0,a=0,s=0,u=r.length,c=0;for(i=0;ic&&(c=l);return n[3]=c,n}}(),OBB3ToSphere3:function(){var e=new E(3),t=new E(3);return function(r,n){n=n||k.vec4();var i,o=0,a=0,s=0,u=r.length,c=u/4;for(i=0;ih&&(h=l);return n[3]=h,n}}(),getSphere3Center:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:k.vec3();return t[0]=e[0],t[1]=e[1],t[2]=e[2],t},expandAABB3:function(e,t){return e[0]>t[0]&&(e[0]=t[0]),e[1]>t[1]&&(e[1]=t[1]),e[2]>t[2]&&(e[2]=t[2]),e[3]t[0]&&(e[0]=t[0]),e[1]>t[1]&&(e[1]=t[1]),e[2]>t[2]&&(e[2]=t[2]),e[3]3&&void 0!==arguments[3]?arguments[3]:k.vec3(),i=t[0]-e[0],o=t[1]-e[1],a=t[2]-e[2],s=r[0]-e[0],u=r[1]-e[1],c=r[2]-e[2],l=o*c-a*u,h=a*s-i*c,f=i*u-o*s,d=Math.sqrt(l*l+h*h+f*f);return 0===d?(n[0]=0,n[1]=0,n[2]=0):(n[0]=l/d,n[1]=h/d,n[2]=f/d),n}};function D(e,t,r,n){var i=e[t]/(Math.abs(e[t])+Math.abs(e[t+1])+Math.abs(e[t+2])),o=e[t+1]/(Math.abs(e[t])+Math.abs(e[t+1])+Math.abs(e[t+2]));if(e[t+2]<0){var a=(1-Math.abs(o))*(i>=0?1:-1),s=(1-Math.abs(i))*(o>=0?1:-1);i=a,o=s}return new Int8Array([Math[r](127.5*i+(i<0?-1:0)),Math[n](127.5*o+(o<0?-1:0))])}function N(e){var t=e[0],r=e[1];t/=t<0?127:128,r/=r<0?127:128;var n=1-Math.abs(t)-Math.abs(r);n<0&&(t=(1-Math.abs(r))*(t>=0?1:-1),r=(1-Math.abs(t))*(r>=0?1:-1));var i=Math.sqrt(t*t+r*r+n*n);return[t/i,r/i,n/i]}function F(e,t,r){return e[t]*r[0]+e[t+1]*r[1]+e[t+2]*r[2]}var V,C,B,U,z,R,X,K,q,Z,Y,Q,W,J,H,$,ee,te={quantizePositions:function(e,t,r,n){for(var i=r[0],o=r[1],a=r[2],s=65535,u=s/(r[3]-i),c=s/(r[4]-o),l=s/(r[5]-a),h=function(e){return e>=0?e:0},f=0;fu&&(a=o,u=s),(s=F(h,0,N(o=D(h,0,"floor","ceil"))))>u&&(a=o,u=s),(s=F(h,0,N(o=D(h,0,"ceil","ceil"))))>u&&(a=o,u=s),n[i+c+0]=a[0],n[i+c+1]=a[1],n[i+c+2]=0;return i+r},octEncodeNormals:function(e,t,r,n){for(var i,o,a,s,u=0;us&&(o=i,s=a),(a=F(e,u,N(i=D(e,u,"floor","ceil"))))>s&&(o=i,s=a),(a=F(e,u,N(i=D(e,u,"ceil","ceil"))))>s&&(o=i,s=a),r[n+u+0]=o[0],r[n+u+1]=o[1],r[n+u+2]=0;return n+t}},re=(V=[],C=[],B=[],U=[],z=[],R=0,X=new Uint16Array(3),K=new Uint16Array(3),q=new Uint16Array(3),Z=k.vec3(),Y=k.vec3(),Q=k.vec3(),W=k.vec3(),J=k.vec3(),H=k.vec3(),$=k.vec3(),ee=k.vec3(),function(e,t,r,n){!function(e,t){var r,n,i,o,a,s,u={},c=Math.pow(10,4),l=0;for(a=0,s=e.length;am&&I>m)continue}d=B[c.index1],p=B[c.index2],(!g&&d>65535||p>65535)&&(g=!0),v.push(d),v.push(p)}return g?new Uint32Array(v):new Uint16Array(v)}),ne=function(e,t,r,n){function i(e,r){for(var n,i,o=0;o<3;o++)if((n=t[3*e+o])!==(i=t[3*r+o]))return i-n;return 0}for(var o=e.slice().sort(i),a=null,s=0,u=o.length;sf&&h>d?f>d?(p=h,v=f,m=d):(p=h,v=d,m=f):f>h&&f>d?h>d?(p=f,v=h,m=d):(p=f,v=d,m=h):d>h&&d>f&&(h>f?(p=d,v=h,m=f):(p=d,v=f,m=h)),n[c+0]=[p,v],n[c+1]=[v,m],p>m){var y=m;m=p,p=y}n[c+2]=[m,p]}function g(e,t){for(var r,n,i=0;i<2;i++)if(r=e[i],(n=t[i])!==r)return n-r;return 0}(n=n.slice(0,e.length)).sort(g);for(var x=0,w=0;w0&&2!==x)};function ie(e,t){for(var r=0;r1}}])&&se(t.prototype,r),Object.defineProperty(t,"prototype",{writable:!1}),e}();function ce(e,t){for(var r=0;r=0;--i){var o=this.tryEntries[i],a=o.completion;if("root"===o.tryLoc)return n("end");if(o.tryLoc<=this.prev){var s=r.call(o,"catchLoc"),u=r.call(o,"finallyLoc");if(s&&u){if(this.prev=0;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&r.call(i,"finallyLoc")&&this.prev=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),M(r),l}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var i=n.arg;M(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:T(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=void 0),l}},e}function De(e,t,r,n,i,o,a){try{var s=e[o](a),u=s.value}catch(e){return void r(e)}s.done?t(u):Promise.resolve(u).then(n,i)}function Ne(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Fe(e,t){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:{};Ne(this,e),this.modelId=t.modelId||"default",this.projectId=t.projectId||"",this.revisionId=t.revisionId||"",this.author=t.author||"",this.createdAt=t.createdAt||"",this.creatingApplication=t.creatingApplication||"",this.schema=t.schema||"",this.xktVersion=f.xktVersion,this.edgeThreshold=t.edgeThreshold||10,this.minTileSize=t.minTileSize||500,this.propertySets={},this.propertySetsList=[],this.metaObjects={},this.metaObjectsList=[],this.reusedGeometriesDecodeMatrix=new Float32Array(16),this.geometries={},this.geometriesList=[],this.textures={},this.texturesList=[],this.textureSets={},this.textureSetsList=[],this.meshes={},this.meshesList=[],this.entities={},this.entitiesList=[],this.tilesList=[],this.aabb=k.AABB3(),this.finalized=!1}var t,r,n,i;return t=e,r=[{key:"createPropertySet",value:function(e){if(!e)throw"Parameters expected: params";if(null===e.propertySetId||void 0===e.propertySetId)throw"Parameter expected: params.propertySetId";if(null===e.properties||void 0===e.properties)throw"Parameter expected: params.properties";if(this.finalized)console.error("XKTModel has been finalized, can't add more property sets");else if(!this.propertySets[e.propertySetId]){var t=e.propertySetId,r=e.propertySetType||"Default",n=e.propertySetName||e.propertySetId,i=e.properties||[],o=new Ie(t,r,n,i);return this.propertySets[t]=o,this.propertySetsList.push(o),o}}},{key:"createMetaObject",value:function(e){if(!e)throw"Parameters expected: params";if(null===e.metaObjectId||void 0===e.metaObjectId)throw"Parameter expected: params.metaObjectId";if(this.finalized)console.error("XKTModel has been finalized, can't add more meta objects");else if(!this.metaObjects[e.metaObjectId]){var t=e.metaObjectId,r=e.propertySetIds,n=e.metaObjectType||"Default",i=e.metaObjectName||e.metaObjectId,o=e.parentMetaObjectId,a=new we(t,r,n,i,o);return this.metaObjects[t]=a,this.metaObjectsList.push(a),o||this._rootMetaObject||(this._rootMetaObject=a),a}}},{key:"createTexture",value:function(e){if(!e)throw"Parameters expected: params";if(null===e.textureId||void 0===e.textureId)throw"Parameter expected: params.textureId";if(!e.imageData&&!e.src)throw"Parameter expected: params.imageData or params.src";if(this.finalized)console.error("XKTModel has been finalized, can't add more textures");else{if(!this.textures[e.textureId]){if(e.src){var t=e.src.split(".").pop();if("jpg"!==t&&"jpeg"!==t&&"png"!==t)return void console.error("XKTModel does not support image files with extension '".concat(t,"' - won't create texture '").concat(e.textureId))}var r=e.textureId,n=new Se({textureId:r,imageData:e.imageData,mediaType:e.mediaType,minFilter:e.minFilter,magFilter:e.magFilter,wrapS:e.wrapS,wrapT:e.wrapT,wrapR:e.wrapR,width:e.width,height:e.height,compressed:!1!==e.compressed,src:e.src});return this.textures[r]=n,this.texturesList.push(n),n}console.error("XKTTexture already exists with this ID: "+e.textureId)}}},{key:"createTextureSet",value:function(e){if(!e)throw"Parameters expected: params";if(null===e.textureSetId||void 0===e.textureSetId)throw"Parameter expected: params.textureSetId";if(this.finalized)console.error("XKTModel has been finalized, can't add more textureSets");else{if(!this.textureSets[e.textureSetId]){var t,r,n,i,o;if(void 0!==e.colorTextureId&&null!==e.colorTextureId){if(!(t=this.textures[e.colorTextureId]))return void console.error("Texture not found: ".concat(e.colorTextureId," - ensure that you create it first with createTexture()"));t.channel=0}if(void 0!==e.metallicRoughnessTextureId&&null!==e.metallicRoughnessTextureId){if(!(r=this.textures[e.metallicRoughnessTextureId]))return void console.error("Texture not found: ".concat(e.metallicRoughnessTextureId," - ensure that you create it first with createTexture()"));r.channel=1}if(void 0!==e.normalsTextureId&&null!==e.normalsTextureId){if(!(n=this.textures[e.normalsTextureId]))return void console.error("Texture not found: ".concat(e.normalsTextureId," - ensure that you create it first with createTexture()"));n.channel=2}if(void 0!==e.emissiveTextureId&&null!==e.emissiveTextureId){if(!(i=this.textures[e.emissiveTextureId]))return void console.error("Texture not found: ".concat(e.emissiveTextureId," - ensure that you create it first with createTexture()"));i.channel=3}if(void 0!==e.occlusionTextureId&&null!==e.occlusionTextureId){if(!(o=this.textures[e.occlusionTextureId]))return void console.error("Texture not found: ".concat(e.occlusionTextureId," - ensure that you create it first with createTexture()"));o.channel=4}var a=new Pe({textureSetId:e.textureSetId,textureSetIndex:this.textureSetsList.length,colorTexture:t,metallicRoughnessTexture:r,normalsTexture:n,emissiveTexture:i,occlusionTexture:o});return this.textureSets[e.textureSetId]=a,this.textureSetsList.push(a),a}console.error("XKTTextureSet already exists with this ID: "+e.textureSetId)}}},{key:"createGeometry",value:function(e){if(!e)throw"Parameters expected: params";if(null===e.geometryId||void 0===e.geometryId)throw"Parameter expected: params.geometryId";if(!e.primitiveType)throw"Parameter expected: params.primitiveType";if(!e.positions)throw"Parameter expected: params.positions";var t="triangles"===e.primitiveType,r="points"===e.primitiveType,n="lines"===e.primitiveType;if(!t&&!r&&!n)throw"Unsupported value for params.primitiveType: "+e.primitiveType+"' - supported values are 'triangles', 'points' and 'lines'";if(t&&!e.indices)throw"Parameter expected for 'triangles' primitive: params.indices";if(r&&!e.colors&&!e.colorsCompressed)throw"Parameter expected for 'points' primitive: params.colors or params.colorsCompressed";if(n&&!e.indices)throw"Parameter expected for 'lines' primitive: params.indices";if(this.finalized)console.error("XKTModel has been finalized, can't add more geometries");else{if(!this.geometries[e.geometryId]){var i=e.geometryId,o=e.primitiveType,a=new Float64Array(e.positions),s={geometryId:i,geometryIndex:this.geometriesList.length,primitiveType:o,positions:a,uvs:e.uvs||e.uv};if(t&&(e.normals&&(s.normals=new Float32Array(e.normals)),s.indices=e.indices),r)if(e.colorsCompressed)s.colorsCompressed=new Uint8Array(e.colorsCompressed);else{for(var u=e.colors,c=new Uint8Array(u.length),l=0,h=u.length;l1)te.octEncodeNormals(n.normals,n.normals.length,n.normalsOctEncoded,0);else{var i=k.inverseMat4(k.transposeMat4(r.matrix,Be),Ue);te.transformAndOctEncodeNormals(i,n.normals,n.normals.length,n.normalsOctEncoded,0)}}}},{key:"_createEntityAABBs",value:function(){for(var e=0,t=this.entitiesList.length;e1)for(var l=u.positions,h=0,f=l.length;hze[i]&&(i=1),ze[2]>ze[i]&&(i=2),!e.left){var o=r.slice();if(o[i+3]=(r[i]+r[i+3])/2,e.left=new ye(o),k.containsAABB3(o,n))return void this._insertEntityIntoKDTree(e.left,t)}if(!e.right){var a=r.slice();if(a[i]=(r[i]+r[i+3])/2,e.right=new ye(a),k.containsAABB3(a,n))return void this._insertEntityIntoKDTree(e.right,t)}e.entities=e.entities||[],e.entities.push(t),k.expandAABB3(r,n)}}},{key:"_createTilesFromKDTree",value:function(e){this._createTilesFromKDNode(e)}},{key:"_createTilesFromKDNode",value:function(e){e.entities&&e.entities.length>0&&this._createTileFromEntities(e.entities),e.left&&this._createTilesFromKDNode(e.left),e.right&&this._createTilesFromKDNode(e.right)}},{key:"_createTileFromEntities",value:function(e){var t=k.AABB3();k.collapseAABB3(t);for(var r=0;r0){te.createPositionsDecodeMatrix(t,this.reusedGeometriesDecodeMatrix);for(var c=0,l=this.geometriesList.length;ce&&(e=i.positionsQuantized.length),i.indices.length>t&&(t=i.indices.length))}for(var o=new Array(e/3),a=new Array(t),s=0,u=this.geometriesList.length;s1&&void 0!==arguments[1]?arguments[1]:{},r=Ye(e,t),n=Qe(r);t.texturesSize+=n.textureData.byteLength;var i=We(n);return i}function Ye(e,t){for(var r=e.propertySetsList,n=e.metaObjectsList,i=e.geometriesList,o=e.texturesList,a=e.textureSetsList,s=e.meshesList,u=e.entitiesList,c=e.tilesList,l=r.length,h=n.length,f=i.length,d=o.length,p=a.length,v=s.length,m=u.length,y=c.length,g=0,x=0,w=0,b=0,M=0,I=0,T=0,A=0,S=0;S1&&(T+=16);var j={metadata:{},textureData:new Uint8Array(A),eachTextureDataPortion:new Uint32Array(d),eachTextureAttributes:new Uint16Array(9*d),positions:new Uint16Array(g),normals:new Int8Array(x),colors:new Uint8Array(w),uvs:new Float32Array(b),indices:new Uint32Array(M),edgeIndices:new Uint32Array(I),eachTextureSetTextures:new Int32Array(5*p),matrices:new Float32Array(T),reusedGeometriesDecodeMatrix:new Float32Array(e.reusedGeometriesDecodeMatrix),eachGeometryPrimitiveType:new Uint8Array(f),eachGeometryPositionsPortion:new Uint32Array(f),eachGeometryNormalsPortion:new Uint32Array(f),eachGeometryColorsPortion:new Uint32Array(f),eachGeometryUVsPortion:new Uint32Array(f),eachGeometryIndicesPortion:new Uint32Array(f),eachGeometryEdgeIndicesPortion:new Uint32Array(f),eachMeshGeometriesPortion:new Uint32Array(v),eachMeshMatricesPortion:new Uint32Array(v),eachMeshTextureSet:new Int32Array(v),eachMeshMaterialAttributes:new Uint8Array(6*v),eachEntityId:[],eachEntityMeshesPortion:new Uint32Array(m),eachTileAABB:new Float64Array(6*y),eachTileEntitiesPortion:new Uint32Array(y)},G=0,_=0,k=0,D=0,N=0,F=0;j.metadata={id:e.modelId,projectId:e.projectId,revisionId:e.revisionId,author:e.author,createdAt:e.createdAt,creatingApplication:e.creatingApplication,schema:e.schema,propertySets:[],metaObjects:[]};for(var V=0;V0&&(R.propertySetIds=z.propertySetIds),z.external&&(R.external=z.external),j.metadata.metaObjects.push(R)}for(var X=0;X1&&(j.matrices.set(ae.matrix,ie),j.eachMeshMatricesPortion[ne]=ie,ie+=16),j.eachMeshTextureSet[ne]=ae.textureSet?ae.textureSet.textureSetIndex:-1,j.eachMeshMaterialAttributes[oe++]=255*ae.color[0],j.eachMeshMaterialAttributes[oe++]=255*ae.color[1],j.eachMeshMaterialAttributes[oe++]=255*ae.color[2],j.eachMeshMaterialAttributes[oe++]=255*ae.opacity,j.eachMeshMaterialAttributes[oe++]=255*ae.metallic,j.eachMeshMaterialAttributes[oe++]=255*ae.roughness}for(var se=0,ue=0,ce=0;ce80*r){n=o=e[0],i=a=e[1];for(var p=r;po&&(o=s),u>a&&(a=u);c=0!==(c=Math.max(o-n,a-i))?1/c:0}return et(f,d,r,n,i,c),d}function He(e,t,r,n,i){var o,a;if(i===Mt(e,t,r,n)>0)for(o=t;o=t;o-=n)a=xt(o,e[o],e[o+1],a);return a&&dt(a,a.next)&&(wt(a),a=a.next),a}function $e(e,t){if(!e)return e;t||(t=e);var r,n=e;do{if(r=!1,n.steiner||!dt(n,n.next)&&0!==ft(n.prev,n,n.next))n=n.next;else{if(wt(n),(n=t=n.prev)===n.next)break;r=!0}}while(r||n!==t);return t}function et(e,t,r,n,i,o,a){if(e){!a&&o&&function(e,t,r,n){var i=e;do{null===i.z&&(i.z=ut(i.x,i.y,t,r,n)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next}while(i!==e);i.prevZ.nextZ=null,i.prevZ=null,function(e){var t,r,n,i,o,a,s,u,c=1;do{for(r=e,e=null,o=null,a=0;r;){for(a++,n=r,s=0,t=0;t0||u>0&&n;)0!==s&&(0===u||!n||r.z<=n.z)?(i=r,r=r.nextZ,s--):(i=n,n=n.nextZ,u--),o?o.nextZ=i:e=i,i.prevZ=o,o=i;r=n}o.nextZ=null,c*=2}while(a>1)}(i)}(e,n,i,o);for(var s,u,c=e;e.prev!==e.next;)if(s=e.prev,u=e.next,o?rt(e,n,i,o):tt(e))t.push(s.i/r),t.push(e.i/r),t.push(u.i/r),wt(e),e=u.next,c=u.next;else if((e=u)===c){a?1===a?et(e=nt($e(e),t,r),t,r,n,i,o,2):2===a&&it(e,t,r,n,i,o):et($e(e),t,r,n,i,o,1);break}}}function tt(e){var t=e.prev,r=e,n=e.next;if(ft(t,r,n)>=0)return!1;for(var i=e.next.next;i!==e.prev;){if(lt(t.x,t.y,r.x,r.y,n.x,n.y,i.x,i.y)&&ft(i.prev,i,i.next)>=0)return!1;i=i.next}return!0}function rt(e,t,r,n){var i=e.prev,o=e,a=e.next;if(ft(i,o,a)>=0)return!1;for(var s=i.xo.x?i.x>a.x?i.x:a.x:o.x>a.x?o.x:a.x,l=i.y>o.y?i.y>a.y?i.y:a.y:o.y>a.y?o.y:a.y,h=ut(s,u,t,r,n),f=ut(c,l,t,r,n),d=e.prevZ,p=e.nextZ;d&&d.z>=h&&p&&p.z<=f;){if(d!==e.prev&&d!==e.next&<(i.x,i.y,o.x,o.y,a.x,a.y,d.x,d.y)&&ft(d.prev,d,d.next)>=0)return!1;if(d=d.prevZ,p!==e.prev&&p!==e.next&<(i.x,i.y,o.x,o.y,a.x,a.y,p.x,p.y)&&ft(p.prev,p,p.next)>=0)return!1;p=p.nextZ}for(;d&&d.z>=h;){if(d!==e.prev&&d!==e.next&<(i.x,i.y,o.x,o.y,a.x,a.y,d.x,d.y)&&ft(d.prev,d,d.next)>=0)return!1;d=d.prevZ}for(;p&&p.z<=f;){if(p!==e.prev&&p!==e.next&<(i.x,i.y,o.x,o.y,a.x,a.y,p.x,p.y)&&ft(p.prev,p,p.next)>=0)return!1;p=p.nextZ}return!0}function nt(e,t,r){var n=e;do{var i=n.prev,o=n.next.next;!dt(i,o)&&pt(i,n,n.next,o)&&yt(i,o)&&yt(o,i)&&(t.push(i.i/r),t.push(n.i/r),t.push(o.i/r),wt(n),wt(n.next),n=e=o),n=n.next}while(n!==e);return $e(n)}function it(e,t,r,n,i,o){var a=e;do{for(var s=a.next.next;s!==a.prev;){if(a.i!==s.i&&ht(a,s)){var u=gt(a,s);return a=$e(a,a.next),u=$e(u,u.next),et(a,t,r,n,i,o),void et(u,t,r,n,i,o)}s=s.next}a=a.next}while(a!==e)}function ot(e,t){return e.x-t.x}function at(e,t){if(t=function(e,t){var r,n=t,i=e.x,o=e.y,a=-1/0;do{if(o<=n.y&&o>=n.next.y&&n.next.y!==n.y){var s=n.x+(o-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(s<=i&&s>a){if(a=s,s===i){if(o===n.y)return n;if(o===n.next.y)return n.next}r=n.x=n.x&&n.x>=l&&i!==n.x&<(or.x||n.x===r.x&&st(r,n)))&&(r=n,f=u)),n=n.next}while(n!==c);return r}(e,t),t){var r=gt(t,e);$e(t,t.next),$e(r,r.next)}}function st(e,t){return ft(e.prev,e,t.prev)<0&&ft(t.next,e,e.next)<0}function ut(e,t,r,n,i){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-r)*i)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-n)*i)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function ct(e){var t=e,r=e;do{(t.x=0&&(e-a)*(n-s)-(r-a)*(t-s)>=0&&(r-a)*(o-s)-(i-a)*(n-s)>=0}function ht(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!function(e,t){var r=e;do{if(r.i!==e.i&&r.next.i!==e.i&&r.i!==t.i&&r.next.i!==t.i&&pt(r,r.next,e,t))return!0;r=r.next}while(r!==e);return!1}(e,t)&&(yt(e,t)&&yt(t,e)&&function(e,t){var r=e,n=!1,i=(e.x+t.x)/2,o=(e.y+t.y)/2;do{r.y>o!=r.next.y>o&&r.next.y!==r.y&&i<(r.next.x-r.x)*(o-r.y)/(r.next.y-r.y)+r.x&&(n=!n),r=r.next}while(r!==e);return n}(e,t)&&(ft(e.prev,e,t.prev)||ft(e,t.prev,t))||dt(e,t)&&ft(e.prev,e,e.next)>0&&ft(t.prev,t,t.next)>0)}function ft(e,t,r){return(t.y-e.y)*(r.x-t.x)-(t.x-e.x)*(r.y-t.y)}function dt(e,t){return e.x===t.x&&e.y===t.y}function pt(e,t,r,n){var i=mt(ft(e,t,r)),o=mt(ft(e,t,n)),a=mt(ft(r,n,e)),s=mt(ft(r,n,t));return i!==o&&a!==s||!(0!==i||!vt(e,r,t))||!(0!==o||!vt(e,n,t))||!(0!==a||!vt(r,e,n))||!(0!==s||!vt(r,t,n))}function vt(e,t,r){return t.x<=Math.max(e.x,r.x)&&t.x>=Math.min(e.x,r.x)&&t.y<=Math.max(e.y,r.y)&&t.y>=Math.min(e.y,r.y)}function mt(e){return e>0?1:e<0?-1:0}function yt(e,t){return ft(e.prev,e,e.next)<0?ft(e,t,e.next)>=0&&ft(e,e.prev,t)>=0:ft(e,t,e.prev)<0||ft(e,e.next,t)<0}function gt(e,t){var r=new bt(e.i,e.x,e.y),n=new bt(t.i,t.x,t.y),i=e.next,o=t.prev;return e.next=t,t.prev=e,r.next=i,i.prev=r,n.next=r,r.prev=n,o.next=n,n.prev=o,n}function xt(e,t,r,n){var i=new bt(e,t,r);return n?(i.next=n.next,i.prev=n,n.next.prev=i,n.next=i):(i.prev=i,i.next=i),i}function wt(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function bt(e,t,r){this.i=e,this.x=t,this.y=r,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function Mt(e,t,r,n){for(var i=0,o=t,a=r-n;oe.length)&&(t=e.length);for(var r=0,n=new Array(t);r0&&(n+=e[i-1].length,r.holes.push(n))}return r};var At=k.vec2(),St=k.vec3(),Ot=k.vec3(),Lt=k.vec3();function Pt(e){var t=e.data,r=e.xktModel,n=e.stats,i=void 0===n?{}:n,o=e.log;return new Promise((function(e,n){if(t)if("CityJSON"===t.type)if(r){var a=t.transform?function(e,t){for(var r=[],n=t.scale||k.vec3([1,1,1]),i=t.translate||k.vec3([0,0,0]),o=0,a=0;o0){for(var c=[],l=0,h=t.geometry.length;l0){var x=y[g[0]];if(void 0!==x.value)d=m[x.value];else{var w=x.values;if(w){p=[];for(var b=0,M=w.length;b0&&(n.createEntity({entityId:r,meshIds:c}),e.stats.numObjects++)}}function jt(e,t,r,n){switch(t.type){case"MultiPoint":case"MultiLineString":case"GeometryInstance":break;case"MultiSurface":case"CompositeSurface":Gt(e,r,t.boundaries,n);break;case"Solid":for(var i=t.boundaries,o=0;o0&&l.push(c.length);var p=Dt(e,s[d],h,f);c.push.apply(c,It(p))}if(3===c.length)f.indices.push(c[0]),f.indices.push(c[1]),f.indices.push(c[2]);else if(c.length>3){for(var v=[],m=0;m0&&s.push(a.length);var c=Dt(e,t[o][u],r,n);a.push.apply(a,It(c))}if(3===a.length)n.indices.push(a[0]),n.indices.push(a[1]),n.indices.push(a[2]);else if(a.length>3){for(var l=[],h=0;h0)for(var u=0;u0){var x=g||k.createUUID();for(o.entities[x]&&e.error("Two or more glTF nodes found with same 'name' attribute: '"+g+"'");!x||o.entities[x];)x="entity-"+e.nextId++;if(e.metaModelCorrections){var w=e.metaModelCorrections.eachChildRoot[x];if(w){var b=e.metaModelCorrections.eachRootStats[w.id];b.countChildren++,b.countChildren>=b.numChildren&&(o.createEntity({entityId:w.id,meshIds:qt}),e.stats.numObjects++,qt.length=0)}else e.metaModelCorrections.metaObjectsMap[x]&&(o.createEntity({entityId:x,meshIds:qt}),e.stats.numObjects++,qt.length=0)}else o.createEntity({entityId:x,meshIds:qt}),e.stats.numObjects++,qt.length=0}}var Yt="undefined"!=typeof atob?atob:function(e){return Buffer.from(e,"base64").toString("binary")},Qt={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},Wt={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16};function Jt(e){var t=e.data,r=e.xktModel,n=e.metaModelData,i=e.includeNormals,o=e.reuseGeometries,a=e.getAttachment,s=e.stats,u=void 0===s?{}:s,c=e.log;return c&&c("Using parser: parseGLTFJSONIntoXKTModel"),new Promise((function(e,s){if(t)if(r){u.sourceFormat="glTF",u.schemaVersion="2.0",u.title="",u.author="",u.created="",u.numTriangles=0,u.numVertices=0,u.numNormals=0,u.numObjects=0,u.numGeometries=0;var l={gltf:t,metaModelCorrections:n?Ht(n):null,getAttachment:a||function(){throw new Error("You must define getAttachment() method to convert glTF with external resources")},log:c||function(e){},xktModel:r,includeNormals:i,createXKTGeometryIds:{},nextMeshId:0,reuseGeometries:!1!==o,stats:u};l.log("Parsing normals: ".concat(l.includeNormals?"enabled":"disabled")),function(e){var t=e.gltf.buffers;return t?Promise.all(t.map((function(t){return function(e,t){return new Promise((function(r,n){if(t._arrayBuffer)return t._buffer=t._arrayBuffer,void r(t);var i=t.uri;i?function(e,t){return new Promise((function(r,n){var i=t.match(/^data:(.*?)(;base64)?,(.*)$/);if(i){var o=!!i[2],a=i[3];a=decodeURIComponent(a),o&&(a=Yt(a));for(var s=new ArrayBuffer(a.length),u=new Uint8Array(s),c=0;c0)for(var l=0;l0){var G=j;if(e.metaModelCorrections){var _=e.metaModelCorrections.eachChildRoot[G];if(_){var D=e.metaModelCorrections.eachRootStats[_.id];D.countChildren++,D.countChildren>=D.numChildren&&(a.createEntity({entityId:_.id,meshIds:tr}),e.stats.numObjects++,tr=[])}else e.metaModelCorrections.metaObjectsMap[G]&&(a.createEntity({entityId:G,meshIds:tr}),e.stats.numObjects++,tr=[])}else a.createEntity({entityId:G,meshIds:tr}),e.stats.numObjects++,tr=[]}}function nr(e){if(!e.attributes)return"empty";var t=e.mode,r=(e.material,e.indices),n=e.attributes.POSITION,i=e.attributes.NORMAL,o=e.attributes.COLOR_0,a=e.attributes.TEXCOORD_0;return[t,null!=r?r:"-",null!=n?n:"-",null!=i?i:"-",null!=o?o:"-",null!=a?a:"-"].join(";")}function ir(e,t,r){var n=t.attributes;if(n){switch(t.mode){case 0:r.primitive="points";break;case 1:case 2:case 3:r.primitive="lines";break;case 4:default:r.primitive="triangles";break;case 5:console.log("TRIANGLE_STRIP"),r.primitive="triangles";break;case 6:console.log("TRIANGLE_FAN"),r.primitive="triangles"}var i=e.gltf.accessors,o=t.indices;if(null!=o){var a=i[o];r.indices=or(e,a)}var s=n.POSITION;if(null!=s){var u=i[s];r.positions=or(e,u)}var c=n.NORMAL;if(null!=c){var l=i[c];r.normals=or(e,l)}var h=n.COLOR_0;if(null!=h){var f=i[h];r.colors=or(e,f)}}}function or(e,t){var r=e.gltf.bufferViews[t.bufferView],n=Wt[t.type],i=Qt[t.componentType],o=i.BYTES_PER_ELEMENT*n;if(t.byteStride&&t.byteStride!==o)throw new Error("interleaved buffer!");return new i(r._buffer,t.byteOffset||0,t.count*n)}function ar(e){var t=e.WebIFC,r=e.data,n=e.xktModel,i=e.autoNormals,o=void 0===i||i,a=e.includeTypes,s=e.excludeTypes,u=e.wasmPath,c=e.stats,l=void 0===c?{}:c,h=e.log;return h&&h("Using parser: parseIFCIntoXKTModel"),new Promise((function(e,i){if(r)if(n)if(u){var c=new t.IfcAPI;u&&c.SetWasmPath(u),c.Init().then((function(){var i=new Uint8Array(r),u=c.OpenModel(i);l.sourceFormat="IFC",l.schemaVersion="",l.title="",l.author="",l.created="",l.numMetaObjects=0,l.numPropertySets=0,l.numObjects=0,l.numGeometries=0,l.numTriangles=0,l.numVertices=0;var f={WebIFC:t,modelID:u,ifcAPI:c,xktModel:n,autoNormals:o,log:h||function(e){},nextId:0,stats:l};if(a){f.includeTypes={};for(var d=0,p=a.length;d0){for(var d=o.Name.value,p=[],v=0,m=f.length;v0?L:null}),M++}}o&&o("Converted meta objects: "+M),e()}))}function vr(e){var t=e.data,r=e.xktModel,n=e.littleEndian,i=void 0===n||n,o=e.stats,a=e.log;return a&&a("Using parser: parsePCDIntoXKTModel"),new Promise((function(e,n){var s=function(e){if("undefined"!=typeof TextDecoder)return(new TextDecoder).decode(e);for(var t="",r=0,n=e.length;r>16&255,g=m>>8&255,x=m>>0&255;l.push(y,g,x,255)}else l.push(255),l.push(255),l.push(255)}if("binary_compressed"===u.data)for(var w=new Uint32Array(t.slice(u.headerLen,u.headerLen+8)),b=w[0],M=w[1],I=function(e,t){var r,n,i,o=e.length,a=new Uint8Array(t),s=0,u=0;do{if((r=e[s++])<32){if(u+ ++r>t)throw new Error("Output buffer is not large enough");if(s+r>o)throw new Error("Invalid compressed data");do{a[u++]=e[s++]}while(--r)}else{if(n=r>>5,i=u-((31&r)<<8)-1,s>=o)throw new Error("Invalid compressed data");if(7===n&&(n+=e[s++],s>=o))throw new Error("Invalid compressed data");if(i-=e[s++],u+n+2>t)throw new Error("Output buffer is not large enough");if(i<0)throw new Error("Invalid compressed data");if(i>=u)throw new Error("Invalid compressed data");do{a[u++]=a[i++]}while(2+--n)}}while(s0?l:null}),r.createMesh({meshId:"pointsMesh",geometryId:"pointsGeometry"}),r.createEntity({entityId:"geometries",meshIds:["pointsMesh"]}),a&&(a("Converted drawable objects: 1"),a("Converted geometries: 1"),a("Converted vertices: "+c.length/3)),o&&(o.sourceFormat="PCD",o.schemaVersion="",o.title="",o.author="",o.created="",o.numObjects=1,o.numGeometries=1,o.numVertices=c.length/3),e()}))}const mr=require("@loaders.gl/ply");function yr(e){return yr="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},yr(e)}function gr(){gr=function(){return e};var e={},t=Object.prototype,r=t.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},i=n.iterator||"@@iterator",o=n.asyncIterator||"@@asyncIterator",a=n.toStringTag||"@@toStringTag";function s(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{s({},"")}catch(e){s=function(e,t,r){return e[t]=r}}function u(e,t,r,n){var i=t&&t.prototype instanceof h?t:h,o=Object.create(i.prototype),a=new I(n||[]);return o._invoke=function(e,t,r){var n="suspendedStart";return function(i,o){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===i)throw o;return{value:void 0,done:!0}}for(r.method=i,r.arg=o;;){var a=r.delegate;if(a){var s=w(a,r);if(s){if(s===l)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var u=c(e,t,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===l)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}(e,r,a),o}function c(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}e.wrap=u;var l={};function h(){}function f(){}function d(){}var p={};s(p,i,(function(){return this}));var v=Object.getPrototypeOf,m=v&&v(v(T([])));m&&m!==t&&r.call(m,i)&&(p=m);var y=d.prototype=h.prototype=Object.create(p);function g(e){["next","throw","return"].forEach((function(t){s(e,t,(function(e){return this._invoke(t,e)}))}))}function x(e,t){function n(i,o,a,s){var u=c(e[i],e,o);if("throw"!==u.type){var l=u.arg,h=l.value;return h&&"object"==yr(h)&&r.call(h,"__await")?t.resolve(h.__await).then((function(e){n("next",e,a,s)}),(function(e){n("throw",e,a,s)})):t.resolve(h).then((function(e){l.value=e,a(l)}),(function(e){return n("throw",e,a,s)}))}s(u.arg)}var i;this._invoke=function(e,r){function o(){return new t((function(t,i){n(e,r,t,i)}))}return i=i?i.then(o,o):o()}}function w(e,t){var r=e.iterator[t.method];if(void 0===r){if(t.delegate=null,"throw"===t.method){if(e.iterator.return&&(t.method="return",t.arg=void 0,w(e,t),"throw"===t.method))return l;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var n=c(r,e.iterator,t.arg);if("throw"===n.type)return t.method="throw",t.arg=n.arg,t.delegate=null,l;var i=n.arg;return i?i.done?(t[e.resultName]=i.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,l):i:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,l)}function b(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function M(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function I(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(b,this),this.reset(!0)}function T(e){if(e){var t=e[i];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,o=function t(){for(;++n=0;--i){var o=this.tryEntries[i],a=o.completion;if("root"===o.tryLoc)return n("end");if(o.tryLoc<=this.prev){var s=r.call(o,"catchLoc"),u=r.call(o,"finallyLoc");if(s&&u){if(this.prev=0;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&r.call(i,"finallyLoc")&&this.prev=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),M(r),l}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var i=n.arg;M(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:T(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=void 0),l}},e}function xr(e,t,r,n,i,o,a){try{var s=e[o](a),u=s.value}catch(e){return void r(e)}s.done?t(u):Promise.resolve(u).then(n,i)}function wr(e){return function(){var t=this,r=arguments;return new Promise((function(n,i){var o=e.apply(t,r);function a(e){xr(o,n,i,a,s,"next",e)}function s(e){xr(o,n,i,a,s,"throw",e)}a(void 0)}))}}function br(e){return Mr.apply(this,arguments)}function Mr(){return(Mr=wr(gr().mark((function e(t){var r,n,i,o,a,s,u,c,l,h,f;return gr().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=t.data,n=t.xktModel,i=t.stats,(o=t.log)&&o("Using parser: parsePLYIntoXKTModel"),r){e.next=4;break}throw"Argument expected: data";case 4:if(n){e.next=6;break}throw"Argument expected: xktModel";case 6:return e.prev=6,e.next=9,(0,Ee.parse)(r,mr.PLYLoader);case 9:a=e.sent,e.next=16;break;case 12:return e.prev=12,e.t0=e.catch(6),o&&o("Error: "+e.t0),e.abrupt("return");case 16:if(s=a.attributes,u=!!s.COLOR_0){for(c=u?s.COLOR_0.value:null,l=[],h=0,f=c.length;h=0;--i){var o=this.tryEntries[i],a=o.completion;if("root"===o.tryLoc)return n("end");if(o.tryLoc<=this.prev){var s=r.call(o,"catchLoc"),u=r.call(o,"finallyLoc");if(s&&u){if(this.prev=0;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&r.call(i,"finallyLoc")&&this.prev=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),M(r),l}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var i=n.arg;M(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:T(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=void 0),l}},e}function Ar(e,t,r,n,i,o,a){try{var s=e[o](a),u=s.value}catch(e){return void r(e)}s.done?t(u):Promise.resolve(u).then(n,i)}function Sr(e){return function(){var t=this,r=arguments;return new Promise((function(n,i){var o=e.apply(t,r);function a(e){Ar(o,n,i,a,s,"next",e)}function s(e){Ar(o,n,i,a,s,"throw",e)}a(void 0)}))}}function Or(e){return Lr.apply(this,arguments)}function Lr(){return(Lr=Sr(Tr().mark((function e(t){var r,n,i,o,a,s,u,c;return Tr().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.data,n=t.splitMeshes,i=t.autoNormals,o=t.smoothNormals,a=t.smoothNormalsAngleThreshold,s=t.xktModel,u=t.stats,(c=t.log)&&c("Using parser: parseSTLIntoXKTModel"),e.abrupt("return",new Promise((function(e,t){if(r)if(s){var l=k.createUUID(),h=s.createMetaObject({metaObjectId:l,metaObjectType:"Model",metaObjectName:"Model"}),f={data:r,splitMeshes:n,autoNormals:i,smoothNormals:o,smoothNormalsAngleThreshold:a,xktModel:s,rootMetaObject:h,nextId:0,log:c||function(e){},stats:{numObjects:0,numGeometries:0,numTriangles:0,numVertices:0}},d=Dr(r);Pr(d)?Er(f,d):jr(f,kr(r)),u&&(u.sourceFormat="STL",u.schemaVersion="",u.title="",u.author="",u.created="",u.numMetaObjects=2,u.numPropertySets=0,u.numObjects=1,u.numGeometries=1,u.numTriangles=f.stats.numTriangles,u.numVertices=f.stats.numVertices),e()}else t("Argument expected: xktModel");else t("Argument expected: data")})));case 3:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Pr(e){var t=new DataView(e);if(84+50*t.getUint32(80,!0)===t.byteLength)return!0;for(var r=[115,111,108,105,100],n=0;n<5;n++)if(r[n]!==t.getUint8(n,!1))return!0;return!1}function Er(e,t){for(var r,n,i,o,a,s,u,c=new DataView(t),l=c.getUint32(80,!0),h=!1,f=null,d=null,p=null,v=!1,m=0;m<70;m++)1129270351===c.getUint32(m,!1)&&82===c.getUint8(m+4)&&61===c.getUint8(m+5)&&(h=!0,o=[],a=c.getUint8(m+6)/255,s=c.getUint8(m+7)/255,u=c.getUint8(m+8)/255,c.getUint8(m+9));for(var y=[],g=[],x=e.splitMeshes,w=0;w>5&31)/31,i=(A>>10&31)/31):(r=a,n=s,i=u),(x&&r!==f||n!==d||i!==p)&&(null!==f&&(v=!0),f=r,d=n,p=i)}for(var S=1;S<=3;S++){var O=b+12*S;y.push(c.getFloat32(O,!0)),y.push(c.getFloat32(O+4,!0)),y.push(c.getFloat32(O+8,!0)),e.autoNormals||g.push(M,I,T),h&&o.push(r,n,i,1)}x&&v&&(_r(e,y,g,o),y=[],g=[],o=o?[]:null,v=!1)}y.length>0&&_r(e,y,g,o)}function jr(e,t){for(var r,n,i,o,a,s,u,c=/facet([\s\S]*?)endfacet/g,l=0,h=/[\s]+([+-]?(?:\d+.\d+|\d+.|\d+|.\d+)(?:[eE][+-]?\d+)?)/.source,f=new RegExp("vertex"+h+h+h,"g"),d=new RegExp("normal"+h+h+h,"g"),p=[],v=[];null!==(o=c.exec(t));){for(a=0,s=0,u=o[0];null!==(o=d.exec(u));)r=parseFloat(o[1]),n=parseFloat(o[2]),i=parseFloat(o[3]),s++;for(;null!==(o=f.exec(u));)p.push(parseFloat(o[1]),parseFloat(o[2]),parseFloat(o[3])),v.push(r,n,i),a++;if(1!==s)return e.log("Error in normal of face "+l),-1;if(3!==a)return e.log("Error in positions of face "+l),-1;l++}_r(e,p,v,null)}var Gr=0;function _r(e,t,r,n){for(var i=new Int32Array(t.length/3),o=0,a=i.length;o0?r:null,n=n&&n.length>0?n:null,!e.autoNormals&&e.smoothNormals&&function(e,t){var r,n,i,o,a,s,u,c,l,h,f,d=(arguments.length>2&&void 0!==arguments[2]?arguments[2]:{}).smoothNormalsAngleThreshold||20,p={},v=[],m={},y=4,g=Math.pow(10,y);for(u=0,l=e.length;u0&&void 0!==arguments[0]?arguments[0]:{},t=e.xSize||1;t<0&&(console.error("negative xSize not allowed - will invert"),t*=-1);var r=e.ySize||1;r<0&&(console.error("negative ySize not allowed - will invert"),r*=-1);var n=e.zSize||1;n<0&&(console.error("negative zSize not allowed - will invert"),n*=-1);var i=e.center,o=i?i[0]:0,a=i?i[1]:0,s=i?i[2]:0,u=-t+o,c=-r+a,l=-n+s,h=t+o,f=r+a,d=n+s;return{primitiveType:"triangles",positions:[h,f,d,u,f,d,u,c,d,h,c,d,h,f,d,h,c,d,h,c,l,h,f,l,h,f,d,h,f,l,u,f,l,u,f,d,u,f,d,u,f,l,u,c,l,u,c,d,u,c,l,h,c,l,h,c,d,u,c,d,h,c,l,u,c,l,u,f,l,h,f,l],normals:[0,0,1,0,0,1,0,0,1,0,0,1,1,0,0,1,0,0,1,0,0,1,0,0,0,1,0,0,1,0,0,1,0,0,1,0,-1,0,0,-1,0,0,-1,0,0,-1,0,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,0,0,-1,0,0,-1,0,0,-1,0,0,-1],uv:[1,0,0,0,0,1,1,1,0,0,0,1,1,1,1,0,1,1,1,0,0,0,0,1,1,0,0,0,0,1,1,1,0,1,1,1,1,0,0,0,0,1,1,1,1,0,0,0],indices:[0,1,2,0,2,3,4,5,6,4,6,7,8,9,10,8,10,11,12,13,14,12,14,15,16,17,18,16,18,19,20,21,22,20,22,23]}}function Fr(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.xSize||1;t<0&&(console.error("negative xSize not allowed - will invert"),t*=-1);var r=e.ySize||1;r<0&&(console.error("negative ySize not allowed - will invert"),r*=-1);var n=e.zSize||1;n<0&&(console.error("negative zSize not allowed - will invert"),n*=-1);var i=e.center,o=i?i[0]:0,a=i?i[1]:0,s=i?i[2]:0,u=-t+o,c=-r+a,l=-n+s,h=t+o,f=r+a,d=n+s;return{primitiveType:"lines",positions:[u,c,l,u,c,d,u,f,l,u,f,d,h,c,l,h,c,d,h,f,l,h,f,d],indices:[0,1,1,3,3,2,2,0,4,5,5,7,7,6,6,4,0,4,1,5,2,6,3,7]}}function Vr(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.radiusTop||1;t<0&&(console.error("negative radiusTop not allowed - will invert"),t*=-1);var r=e.radiusBottom||1;r<0&&(console.error("negative radiusBottom not allowed - will invert"),r*=-1);var n=e.height||1;n<0&&(console.error("negative height not allowed - will invert"),n*=-1);var i=e.radialSegments||32;i<0&&(console.error("negative radialSegments not allowed - will invert"),i*=-1),i<3&&(i=3);var o=e.heightSegments||1;o<0&&(console.error("negative heightSegments not allowed - will invert"),o*=-1),o<1&&(o=1);var a,s,u,c,l,h,f,d,p,v,m,y=!!e.openEnded,g=e.center,x=g?g[0]:0,w=g?g[1]:0,b=g?g[2]:0,M=n/2,I=n/o,T=2*Math.PI/i,A=1/i,S=(t-r)/o,O=[],L=[],P=[],E=[],j=(90-180*Math.atan(n/(r-t))/Math.PI)/90;for(a=0;a<=o;a++)for(l=t-a*S,h=M-a*I,s=0;s<=i;s++)u=Math.sin(s*T),c=Math.cos(s*T),L.push(l*u),L.push(j),L.push(l*c),P.push(s*A),P.push(1*a/o),O.push(l*u+x),O.push(h+w),O.push(l*c+b);for(a=0;a0){for(p=O.length/3,L.push(0),L.push(1),L.push(0),P.push(.5),P.push(.5),O.push(0+x),O.push(M+w),O.push(0+b),s=0;s<=i;s++)u=Math.sin(s*T),c=Math.cos(s*T),v=.5*Math.sin(s*T)+.5,m=.5*Math.cos(s*T)+.5,L.push(t*u),L.push(1),L.push(t*c),P.push(v),P.push(m),O.push(t*u+x),O.push(M+w),O.push(t*c+b);for(s=0;s0){for(p=O.length/3,L.push(0),L.push(-1),L.push(0),P.push(.5),P.push(.5),O.push(0+x),O.push(0-M+w),O.push(0+b),s=0;s<=i;s++)u=Math.sin(s*T),c=Math.cos(s*T),v=.5*Math.sin(s*T)+.5,m=.5*Math.cos(s*T)+.5,L.push(r*u),L.push(-1),L.push(r*c),P.push(v),P.push(m),O.push(r*u+x),O.push(0-M+w),O.push(r*c+b);for(s=0;s0&&void 0!==arguments[0]?arguments[0]:{},t=e.size||1;t<0&&(console.error("negative size not allowed - will invert"),t*=-1);var r=e.divisions||1;r<0&&(console.error("negative divisions not allowed - will invert"),r*=-1),r<1&&(r=1);for(var n=(t=t||10)/(r=r||10),i=t/2,o=[],a=[],s=0,u=0,c=-i;u<=r;u++,c+=n)o.push(-i),o.push(0),o.push(c),o.push(i),o.push(0),o.push(c),o.push(c),o.push(0),o.push(-i),o.push(c),o.push(0),o.push(i),a.push(s++),a.push(s++),a.push(s++),a.push(s++);return{primitiveType:"lines",positions:o,indices:a}}function Br(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.xSize||1;t<0&&(console.error("negative xSize not allowed - will invert"),t*=-1);var r=e.zSize||1;r<0&&(console.error("negative zSize not allowed - will invert"),r*=-1);var n=e.xSegments||1;n<0&&(console.error("negative xSegments not allowed - will invert"),n*=-1),n<1&&(n=1);var i=e.xSegments||1;i<0&&(console.error("negative zSegments not allowed - will invert"),i*=-1),i<1&&(i=1);var o,a,s,u,c,l,h,f=e.center,d=f?f[0]:0,p=f?f[1]:0,v=f?f[2]:0,m=t/2,y=r/2,g=Math.floor(n)||1,x=Math.floor(i)||1,w=g+1,b=x+1,M=t/g,I=r/x,T=new Float32Array(w*b*3),A=new Float32Array(w*b*3),S=new Float32Array(w*b*2),O=0,L=0;for(o=0;o65535?Uint32Array:Uint16Array)(g*x*6);for(o=0;o0&&void 0!==arguments[0]?arguments[0]:{},t=e.lod||1,r=e.center?e.center[0]:0,n=e.center?e.center[1]:0,i=e.center?e.center[2]:0,o=e.radius||1;o<0&&(console.error("negative radius not allowed - will invert"),o*=-1);var a=e.heightSegments||18;a<0&&(console.error("negative heightSegments not allowed - will invert"),a*=-1),(a=Math.floor(t*a))<18&&(a=18);var s=e.widthSegments||18;s<0&&(console.error("negative widthSegments not allowed - will invert"),s*=-1),(s=Math.floor(t*s))<18&&(s=18);var u,c,l,h,f,d,p,v,m,y,g,x,w,b,M=[],I=[],T=[],A=[];for(u=0;u<=a;u++)for(l=u*Math.PI/a,h=Math.sin(l),f=Math.cos(l),c=0;c<=s;c++)d=2*c*Math.PI/s,p=Math.sin(d),v=Math.cos(d)*h,m=f,y=p*h,g=1-c/s,x=u/a,I.push(v),I.push(m),I.push(y),T.push(g),T.push(x),M.push(r+o*v),M.push(n+o*m),M.push(i+o*y);for(u=0;u0&&void 0!==arguments[0]?arguments[0]:{},t=e.radius||1;t<0&&(console.error("negative radius not allowed - will invert"),t*=-1),t*=.5;var r=e.tube||.3;r<0&&(console.error("negative tube not allowed - will invert"),r*=-1);var n=e.radialSegments||32;n<0&&(console.error("negative radialSegments not allowed - will invert"),n*=-1),n<4&&(n=4);var i=e.tubeSegments||24;i<0&&(console.error("negative tubeSegments not allowed - will invert"),i*=-1),i<4&&(i=4);var o=e.arc||2*Math.PI;o<0&&(console.warn("negative arc not allowed - will invert"),o*=-1),o>360&&(o=360);var a,s,u,c,l,h,f,d,p,v,m,y,g=e.center,x=g?g[0]:0,w=g?g[1]:0,b=g?g[2]:0,M=[],I=[],T=[],A=[];for(d=0;d<=i;d++)for(f=0;f<=n;f++)a=f/n*o,s=.785398+d/i*Math.PI*2,x=t*Math.cos(a),w=t*Math.sin(a),u=(t+r*Math.cos(s))*Math.cos(a),c=(t+r*Math.cos(s))*Math.sin(a),l=r*Math.sin(s),M.push(u+x),M.push(c+w),M.push(l+b),T.push(1-f/n),T.push(d/i),h=k.normalizeVec3(k.subVec3([u,c,l],[x,w,b],[]),[]),I.push(h[0]),I.push(h[1]),I.push(h[2]);for(d=1;d<=i;d++)for(f=1;f<=n;f++)p=(n+1)*d+f-1,v=(n+1)*(d-1)+f-1,m=(n+1)*(d-1)+f,y=(n+1)*d+f,A.push(p),A.push(v),A.push(m),A.push(m),A.push(y),A.push(p);return{primitiveType:"triangles",positions:M,normals:I,uv:T,uvs:T,indices:A}}var Rr={" ":{width:16,points:[]},"!":{width:10,points:[[5,21],[5,7],[-1,-1],[5,2],[4,1],[5,0],[6,1],[5,2]]},'"':{width:16,points:[[4,21],[4,14],[-1,-1],[12,21],[12,14]]},"#":{width:21,points:[[11,25],[4,-7],[-1,-1],[17,25],[10,-7],[-1,-1],[4,12],[18,12],[-1,-1],[3,6],[17,6]]},$:{width:20,points:[[8,25],[8,-4],[-1,-1],[12,25],[12,-4],[-1,-1],[17,18],[15,20],[12,21],[8,21],[5,20],[3,18],[3,16],[4,14],[5,13],[7,12],[13,10],[15,9],[16,8],[17,6],[17,3],[15,1],[12,0],[8,0],[5,1],[3,3]]},"%":{width:24,points:[[21,21],[3,0],[-1,-1],[8,21],[10,19],[10,17],[9,15],[7,14],[5,14],[3,16],[3,18],[4,20],[6,21],[8,21],[10,20],[13,19],[16,19],[19,20],[21,21],[-1,-1],[17,7],[15,6],[14,4],[14,2],[16,0],[18,0],[20,1],[21,3],[21,5],[19,7],[17,7]]},"&":{width:26,points:[[23,12],[23,13],[22,14],[21,14],[20,13],[19,11],[17,6],[15,3],[13,1],[11,0],[7,0],[5,1],[4,2],[3,4],[3,6],[4,8],[5,9],[12,13],[13,14],[14,16],[14,18],[13,20],[11,21],[9,20],[8,18],[8,16],[9,13],[11,10],[16,3],[18,1],[20,0],[22,0],[23,1],[23,2]]},"'":{width:10,points:[[5,19],[4,20],[5,21],[6,20],[6,18],[5,16],[4,15]]},"(":{width:14,points:[[11,25],[9,23],[7,20],[5,16],[4,11],[4,7],[5,2],[7,-2],[9,-5],[11,-7]]},")":{width:14,points:[[3,25],[5,23],[7,20],[9,16],[10,11],[10,7],[9,2],[7,-2],[5,-5],[3,-7]]},"*":{width:16,points:[[8,21],[8,9],[-1,-1],[3,18],[13,12],[-1,-1],[13,18],[3,12]]},"+":{width:26,points:[[13,18],[13,0],[-1,-1],[4,9],[22,9]]},",":{width:10,points:[[6,1],[5,0],[4,1],[5,2],[6,1],[6,-1],[5,-3],[4,-4]]},"-":{width:26,points:[[4,9],[22,9]]},".":{width:10,points:[[5,2],[4,1],[5,0],[6,1],[5,2]]},"/":{width:22,points:[[20,25],[2,-7]]},0:{width:20,points:[[9,21],[6,20],[4,17],[3,12],[3,9],[4,4],[6,1],[9,0],[11,0],[14,1],[16,4],[17,9],[17,12],[16,17],[14,20],[11,21],[9,21]]},1:{width:20,points:[[6,17],[8,18],[11,21],[11,0]]},2:{width:20,points:[[4,16],[4,17],[5,19],[6,20],[8,21],[12,21],[14,20],[15,19],[16,17],[16,15],[15,13],[13,10],[3,0],[17,0]]},3:{width:20,points:[[5,21],[16,21],[10,13],[13,13],[15,12],[16,11],[17,8],[17,6],[16,3],[14,1],[11,0],[8,0],[5,1],[4,2],[3,4]]},4:{width:20,points:[[13,21],[3,7],[18,7],[-1,-1],[13,21],[13,0]]},5:{width:20,points:[[15,21],[5,21],[4,12],[5,13],[8,14],[11,14],[14,13],[16,11],[17,8],[17,6],[16,3],[14,1],[11,0],[8,0],[5,1],[4,2],[3,4]]},6:{width:20,points:[[16,18],[15,20],[12,21],[10,21],[7,20],[5,17],[4,12],[4,7],[5,3],[7,1],[10,0],[11,0],[14,1],[16,3],[17,6],[17,7],[16,10],[14,12],[11,13],[10,13],[7,12],[5,10],[4,7]]},7:{width:20,points:[[17,21],[7,0],[-1,-1],[3,21],[17,21]]},8:{width:20,points:[[8,21],[5,20],[4,18],[4,16],[5,14],[7,13],[11,12],[14,11],[16,9],[17,7],[17,4],[16,2],[15,1],[12,0],[8,0],[5,1],[4,2],[3,4],[3,7],[4,9],[6,11],[9,12],[13,13],[15,14],[16,16],[16,18],[15,20],[12,21],[8,21]]},9:{width:20,points:[[16,14],[15,11],[13,9],[10,8],[9,8],[6,9],[4,11],[3,14],[3,15],[4,18],[6,20],[9,21],[10,21],[13,20],[15,18],[16,14],[16,9],[15,4],[13,1],[10,0],[8,0],[5,1],[4,3]]},":":{width:10,points:[[5,14],[4,13],[5,12],[6,13],[5,14],[-1,-1],[5,2],[4,1],[5,0],[6,1],[5,2]]},";":{width:10,points:[[5,14],[4,13],[5,12],[6,13],[5,14],[-1,-1],[6,1],[5,0],[4,1],[5,2],[6,1],[6,-1],[5,-3],[4,-4]]},"<":{width:24,points:[[20,18],[4,9],[20,0]]},"=":{width:26,points:[[4,12],[22,12],[-1,-1],[4,6],[22,6]]},">":{width:24,points:[[4,18],[20,9],[4,0]]},"?":{width:18,points:[[3,16],[3,17],[4,19],[5,20],[7,21],[11,21],[13,20],[14,19],[15,17],[15,15],[14,13],[13,12],[9,10],[9,7],[-1,-1],[9,2],[8,1],[9,0],[10,1],[9,2]]},"@":{width:27,points:[[18,13],[17,15],[15,16],[12,16],[10,15],[9,14],[8,11],[8,8],[9,6],[11,5],[14,5],[16,6],[17,8],[-1,-1],[12,16],[10,14],[9,11],[9,8],[10,6],[11,5],[-1,-1],[18,16],[17,8],[17,6],[19,5],[21,5],[23,7],[24,10],[24,12],[23,15],[22,17],[20,19],[18,20],[15,21],[12,21],[9,20],[7,19],[5,17],[4,15],[3,12],[3,9],[4,6],[5,4],[7,2],[9,1],[12,0],[15,0],[18,1],[20,2],[21,3],[-1,-1],[19,16],[18,8],[18,6],[19,5]]},A:{width:18,points:[[9,21],[1,0],[-1,-1],[9,21],[17,0],[-1,-1],[4,7],[14,7]]},B:{width:21,points:[[4,21],[4,0],[-1,-1],[4,21],[13,21],[16,20],[17,19],[18,17],[18,15],[17,13],[16,12],[13,11],[-1,-1],[4,11],[13,11],[16,10],[17,9],[18,7],[18,4],[17,2],[16,1],[13,0],[4,0]]},C:{width:21,points:[[18,16],[17,18],[15,20],[13,21],[9,21],[7,20],[5,18],[4,16],[3,13],[3,8],[4,5],[5,3],[7,1],[9,0],[13,0],[15,1],[17,3],[18,5]]},D:{width:21,points:[[4,21],[4,0],[-1,-1],[4,21],[11,21],[14,20],[16,18],[17,16],[18,13],[18,8],[17,5],[16,3],[14,1],[11,0],[4,0]]},E:{width:19,points:[[4,21],[4,0],[-1,-1],[4,21],[17,21],[-1,-1],[4,11],[12,11],[-1,-1],[4,0],[17,0]]},F:{width:18,points:[[4,21],[4,0],[-1,-1],[4,21],[17,21],[-1,-1],[4,11],[12,11]]},G:{width:21,points:[[18,16],[17,18],[15,20],[13,21],[9,21],[7,20],[5,18],[4,16],[3,13],[3,8],[4,5],[5,3],[7,1],[9,0],[13,0],[15,1],[17,3],[18,5],[18,8],[-1,-1],[13,8],[18,8]]},H:{width:22,points:[[4,21],[4,0],[-1,-1],[18,21],[18,0],[-1,-1],[4,11],[18,11]]},I:{width:8,points:[[4,21],[4,0]]},J:{width:16,points:[[12,21],[12,5],[11,2],[10,1],[8,0],[6,0],[4,1],[3,2],[2,5],[2,7]]},K:{width:21,points:[[4,21],[4,0],[-1,-1],[18,21],[4,7],[-1,-1],[9,12],[18,0]]},L:{width:17,points:[[4,21],[4,0],[-1,-1],[4,0],[16,0]]},M:{width:24,points:[[4,21],[4,0],[-1,-1],[4,21],[12,0],[-1,-1],[20,21],[12,0],[-1,-1],[20,21],[20,0]]},N:{width:22,points:[[4,21],[4,0],[-1,-1],[4,21],[18,0],[-1,-1],[18,21],[18,0]]},O:{width:22,points:[[9,21],[7,20],[5,18],[4,16],[3,13],[3,8],[4,5],[5,3],[7,1],[9,0],[13,0],[15,1],[17,3],[18,5],[19,8],[19,13],[18,16],[17,18],[15,20],[13,21],[9,21]]},P:{width:21,points:[[4,21],[4,0],[-1,-1],[4,21],[13,21],[16,20],[17,19],[18,17],[18,14],[17,12],[16,11],[13,10],[4,10]]},Q:{width:22,points:[[9,21],[7,20],[5,18],[4,16],[3,13],[3,8],[4,5],[5,3],[7,1],[9,0],[13,0],[15,1],[17,3],[18,5],[19,8],[19,13],[18,16],[17,18],[15,20],[13,21],[9,21],[-1,-1],[12,4],[18,-2]]},R:{width:21,points:[[4,21],[4,0],[-1,-1],[4,21],[13,21],[16,20],[17,19],[18,17],[18,15],[17,13],[16,12],[13,11],[4,11],[-1,-1],[11,11],[18,0]]},S:{width:20,points:[[17,18],[15,20],[12,21],[8,21],[5,20],[3,18],[3,16],[4,14],[5,13],[7,12],[13,10],[15,9],[16,8],[17,6],[17,3],[15,1],[12,0],[8,0],[5,1],[3,3]]},T:{width:16,points:[[8,21],[8,0],[-1,-1],[1,21],[15,21]]},U:{width:22,points:[[4,21],[4,6],[5,3],[7,1],[10,0],[12,0],[15,1],[17,3],[18,6],[18,21]]},V:{width:18,points:[[1,21],[9,0],[-1,-1],[17,21],[9,0]]},W:{width:24,points:[[2,21],[7,0],[-1,-1],[12,21],[7,0],[-1,-1],[12,21],[17,0],[-1,-1],[22,21],[17,0]]},X:{width:20,points:[[3,21],[17,0],[-1,-1],[17,21],[3,0]]},Y:{width:18,points:[[1,21],[9,11],[9,0],[-1,-1],[17,21],[9,11]]},Z:{width:20,points:[[17,21],[3,0],[-1,-1],[3,21],[17,21],[-1,-1],[3,0],[17,0]]},"[":{width:14,points:[[4,25],[4,-7],[-1,-1],[5,25],[5,-7],[-1,-1],[4,25],[11,25],[-1,-1],[4,-7],[11,-7]]},"\\":{width:14,points:[[0,21],[14,-3]]},"]":{width:14,points:[[9,25],[9,-7],[-1,-1],[10,25],[10,-7],[-1,-1],[3,25],[10,25],[-1,-1],[3,-7],[10,-7]]},"^":{width:16,points:[[6,15],[8,18],[10,15],[-1,-1],[3,12],[8,17],[13,12],[-1,-1],[8,17],[8,0]]},_:{width:16,points:[[0,-2],[16,-2]]},"`":{width:10,points:[[6,21],[5,20],[4,18],[4,16],[5,15],[6,16],[5,17]]},a:{width:19,points:[[15,14],[15,0],[-1,-1],[15,11],[13,13],[11,14],[8,14],[6,13],[4,11],[3,8],[3,6],[4,3],[6,1],[8,0],[11,0],[13,1],[15,3]]},b:{width:19,points:[[4,21],[4,0],[-1,-1],[4,11],[6,13],[8,14],[11,14],[13,13],[15,11],[16,8],[16,6],[15,3],[13,1],[11,0],[8,0],[6,1],[4,3]]},c:{width:18,points:[[15,11],[13,13],[11,14],[8,14],[6,13],[4,11],[3,8],[3,6],[4,3],[6,1],[8,0],[11,0],[13,1],[15,3]]},d:{width:19,points:[[15,21],[15,0],[-1,-1],[15,11],[13,13],[11,14],[8,14],[6,13],[4,11],[3,8],[3,6],[4,3],[6,1],[8,0],[11,0],[13,1],[15,3]]},e:{width:18,points:[[3,8],[15,8],[15,10],[14,12],[13,13],[11,14],[8,14],[6,13],[4,11],[3,8],[3,6],[4,3],[6,1],[8,0],[11,0],[13,1],[15,3]]},f:{width:12,points:[[10,21],[8,21],[6,20],[5,17],[5,0],[-1,-1],[2,14],[9,14]]},g:{width:19,points:[[15,14],[15,-2],[14,-5],[13,-6],[11,-7],[8,-7],[6,-6],[-1,-1],[15,11],[13,13],[11,14],[8,14],[6,13],[4,11],[3,8],[3,6],[4,3],[6,1],[8,0],[11,0],[13,1],[15,3]]},h:{width:19,points:[[4,21],[4,0],[-1,-1],[4,10],[7,13],[9,14],[12,14],[14,13],[15,10],[15,0]]},i:{width:8,points:[[3,21],[4,20],[5,21],[4,22],[3,21],[-1,-1],[4,14],[4,0]]},j:{width:10,points:[[5,21],[6,20],[7,21],[6,22],[5,21],[-1,-1],[6,14],[6,-3],[5,-6],[3,-7],[1,-7]]},k:{width:17,points:[[4,21],[4,0],[-1,-1],[14,14],[4,4],[-1,-1],[8,8],[15,0]]},l:{width:8,points:[[4,21],[4,0]]},m:{width:30,points:[[4,14],[4,0],[-1,-1],[4,10],[7,13],[9,14],[12,14],[14,13],[15,10],[15,0],[-1,-1],[15,10],[18,13],[20,14],[23,14],[25,13],[26,10],[26,0]]},n:{width:19,points:[[4,14],[4,0],[-1,-1],[4,10],[7,13],[9,14],[12,14],[14,13],[15,10],[15,0]]},o:{width:19,points:[[8,14],[6,13],[4,11],[3,8],[3,6],[4,3],[6,1],[8,0],[11,0],[13,1],[15,3],[16,6],[16,8],[15,11],[13,13],[11,14],[8,14]]},p:{width:19,points:[[4,14],[4,-7],[-1,-1],[4,11],[6,13],[8,14],[11,14],[13,13],[15,11],[16,8],[16,6],[15,3],[13,1],[11,0],[8,0],[6,1],[4,3]]},q:{width:19,points:[[15,14],[15,-7],[-1,-1],[15,11],[13,13],[11,14],[8,14],[6,13],[4,11],[3,8],[3,6],[4,3],[6,1],[8,0],[11,0],[13,1],[15,3]]},r:{width:13,points:[[4,14],[4,0],[-1,-1],[4,8],[5,11],[7,13],[9,14],[12,14]]},s:{width:17,points:[[14,11],[13,13],[10,14],[7,14],[4,13],[3,11],[4,9],[6,8],[11,7],[13,6],[14,4],[14,3],[13,1],[10,0],[7,0],[4,1],[3,3]]},t:{width:12,points:[[5,21],[5,4],[6,1],[8,0],[10,0],[-1,-1],[2,14],[9,14]]},u:{width:19,points:[[4,14],[4,4],[5,1],[7,0],[10,0],[12,1],[15,4],[-1,-1],[15,14],[15,0]]},v:{width:16,points:[[2,14],[8,0],[-1,-1],[14,14],[8,0]]},w:{width:22,points:[[3,14],[7,0],[-1,-1],[11,14],[7,0],[-1,-1],[11,14],[15,0],[-1,-1],[19,14],[15,0]]},x:{width:17,points:[[3,14],[14,0],[-1,-1],[14,14],[3,0]]},y:{width:16,points:[[2,14],[8,0],[-1,-1],[14,14],[8,0],[6,-4],[4,-6],[2,-7],[1,-7]]},z:{width:17,points:[[14,14],[3,0],[-1,-1],[3,14],[14,14],[-1,-1],[3,0],[14,0]]},"{":{width:14,points:[[9,25],[7,24],[6,23],[5,21],[5,19],[6,17],[7,16],[8,14],[8,12],[6,10],[-1,-1],[7,24],[6,22],[6,20],[7,18],[8,17],[9,15],[9,13],[8,11],[4,9],[8,7],[9,5],[9,3],[8,1],[7,0],[6,-2],[6,-4],[7,-6],[-1,-1],[6,8],[8,6],[8,4],[7,2],[6,1],[5,-1],[5,-3],[6,-5],[7,-6],[9,-7]]},"|":{width:8,points:[[4,25],[4,-7]]},"}":{width:14,points:[[5,25],[7,24],[8,23],[9,21],[9,19],[8,17],[7,16],[6,14],[6,12],[8,10],[-1,-1],[7,24],[8,22],[8,20],[7,18],[6,17],[5,15],[5,13],[6,11],[10,9],[6,7],[5,5],[5,3],[6,1],[7,0],[8,-2],[8,-4],[7,-6],[-1,-1],[8,8],[6,6],[6,4],[7,2],[8,1],[9,-1],[9,-3],[8,-5],[7,-6],[5,-7]]},"~":{width:24,points:[[3,6],[3,8],[4,11],[6,12],[8,12],[10,11],[14,8],[16,7],[18,7],[20,8],[21,10],[-1,-1],[3,8],[4,10],[6,11],[8,11],[10,10],[14,7],[16,6],[18,6],[20,7],[21,10],[21,12]]}};function Xr(){for(var e,t,r,n,i,o,a,s,u,c=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},l=c.origin||[0,0,0],h=l[0],f=l[1],d=l[2],p=c.size||1,v=[],m=[],y=(""+c.text).trim(),g=(y||"").split("\n"),x=0,w=0,b=.04,M=0;M=0;--i){var o=this.tryEntries[i],a=o.completion;if("root"===o.tryLoc)return n("end");if(o.tryLoc<=this.prev){var s=r.call(o,"catchLoc"),u=r.call(o,"finallyLoc");if(s&&u){if(this.prev=0;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&r.call(i,"finallyLoc")&&this.prev=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),M(r),l}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var i=n.arg;M(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:T(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=void 0),l}},e}function Yr(e,t,r,n,i,o,a){try{var s=e[o](a),u=s.value}catch(e){return void r(e)}s.done?t(u):Promise.resolve(u).then(n,i)}var Qr=r(231);function Wr(e){var t=e.WebIFC,r=e.source,n=e.sourceData,i=e.sourceFormat,o=e.metaModelSource,a=e.metaModelData,s=e.output,u=e.outputXKTModel,c=e.outputXKT,l=e.includeTypes,h=e.excludeTypes,d=e.reuseGeometries,p=void 0===d||d,v=e.minTileSize,m=void 0===v?200:v,y=e.stats,g=void 0===y?{}:y,x=e.outputStats,w=e.rotateX,b=void 0!==w&&w,M=e.includeTextures,I=void 0===M||M,T=e.includeNormals,A=void 0===T||T,S=e.log,O=void 0===S?function(e){}:S;return g.sourceFormat="",g.schemaVersion="",g.title="",g.author="",g.created="",g.numMetaObjects=0,g.numPropertySets=0,g.numTriangles=0,g.numVertices=0,g.numNormals=0,g.numUVs=0,g.numTextures=0,g.numTextureSets=0,g.numObjects=0,g.numGeometries=0,g.sourceSize=0,g.xktSize=0,g.texturesSize=0,g.xktVersion="",g.compressionRatio=0,g.conversionTime=0,g.aabb=null,g.minTileSize=m||200,new Promise((function(e,d){var v=O;if(O=function(e){v("[convert2xkt] ".concat(e))},r||n)if(i||!n)if(s||u||c){r&&O("Reading input file: "+r);var y=new Date,w=i||r.split(".").pop();if(!n)try{n=Qr.readFileSync(r)}catch(e){return void d(e)}var M=n.byteLength;if(O("Input file size: "+(M/1e3).toFixed(2)+" kB"),!a&&o){O("Reading input metadata file: "+o);try{var T=Qr.readFileSync(o);a=JSON.parse(T)}catch(e){return void d(e)}}!1===p&&O("Geometry reuse is disabled");var S=new Xe({minTileSize:m});a?pr({metaModelData:a,xktModel:S}).then((function(){L()}),(function(e){d(e)})):L()}else d("Argument expected: output, outputXKTModel or outputXKT");else d("Argument expected: sourceFormat is required with sourceData");else d("Argument expected: source or sourceData");function L(){switch(w){case"json":P(Pt,{data:JSON.parse(n),xktModel:S,stats:g,rotateX:b,log:O});break;case"glb":case"gltf":var e=r?Jr(r):"",i="glb"!==w&&!I;P(i?Jt:Bt,{data:i?JSON.parse(n):n,reuseGeometries:p,includeTextures:I,includeNormals:A,metaModelData:a,xktModel:S,getAttachment:(o=Zr().mark((function t(r){var n;return Zr().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return O("Reading attachment file: ".concat(n=e+r)),t.abrupt("return",Kr(Qr.readFileSync(n)));case 3:case"end":return t.stop()}}),t)})),s=function(){var e=this,t=arguments;return new Promise((function(r,n){var i=o.apply(e,t);function a(e){Yr(i,r,n,a,s,"next",e)}function s(e){Yr(i,r,n,a,s,"throw",e)}a(void 0)}))},function(e){return s.apply(this,arguments)}),stats:g,log:O});break;case"ifc":P(ar,{WebIFC:t,data:n,xktModel:S,wasmPath:"./",includeTypes:l,excludeTypes:h,stats:g,log:O});break;case"laz":P(lr,{data:n,xktModel:S,stats:g,rotateX:b,log:O});break;case"las":P(lr,{data:n,xktModel:S,stats:g,log:O});break;case"pcd":P(vr,{data:n,xktModel:S,stats:g,log:O});break;case"ply":P(br,{data:n,xktModel:S,stats:g,log:O});break;case"stl":P(Or,{data:n,xktModel:S,stats:g,log:O});break;default:return void d('Error: unsupported source format: "'.concat(w,'".'))}var o,s}function P(t,r){t(r).then((function(){S.createDefaultMetaObjects(),O("Input file parsed OK. Building XKT document..."),S.finalize().then((function(){O("XKT document built OK. Writing to XKT file...");var t=Ze(S,g),r=Buffer.from(t),n=t.byteLength;if(g.sourceSize=(M/1e3).toFixed(2),g.xktSize=(n/1e3).toFixed(2),g.xktVersion=f.xktVersion,g.compressionRatio=(M/n).toFixed(2),g.conversionTime=((new Date-y)/1e3).toFixed(2),g.aabb=S.aabb,O("Converted to: XKT v".concat(g.xktVersion)),l&&O("Include types: "+(l||"(include all)")),h&&O("Exclude types: "+(h||"(exclude none)")),O("XKT size: "+g.xktSize+" kB"),O("XKT textures size: "+(g.texturesSize/1e3).toFixed(2)+"kB"),O("Compression ratio: "+g.compressionRatio),O("Conversion time: "+g.conversionTime+" s"),O("Converted metaobjects: "+g.numMetaObjects),O("Converted property sets: "+g.numPropertySets),O("Converted drawable objects: "+g.numObjects),O("Converted geometries: "+g.numGeometries),O("Converted textures: "+g.numTextures),O("Converted textureSets: "+g.numTextureSets),O("Converted triangles: "+g.numTriangles),O("Converted vertices: "+g.numVertices),O("Converted UVs: "+g.numUVs),O("Converted normals: "+g.numNormals),O("minTileSize: "+g.minTileSize),s){var i=Jr(s).trim();""===i||Qr.existsSync(i)||Qr.mkdirSync(i,{recursive:!0}),O("Writing XKT file: "+s),Qr.writeFileSync(s,r)}u&&u(S),c&&c(r),x&&x(g),e()}))}),(function(e){d(e)}))}}))}function Jr(e){var t=e.lastIndexOf("/");return 0!==t?e.substring(0,t+1):""}(0,e.installFilePolyfills)()})(),n})())); +!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.convert2xkt=t():e.convert2xkt=t()}(global,(()=>(()=>{"use strict";var e={231:e=>{e.exports=require("fs")}},t={};function r(n){var i=t[n];if(void 0!==i)return i.exports;var o=t[n]={exports:{}};return e[n](o,o.exports,r),o.exports}r.d=(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var n={};return(()=>{r.r(n),r.d(n,{ClampToEdgeWrapping:()=>p,GIFMediaType:()=>O,JPEGMediaType:()=>L,LinearFilter:()=>M,LinearMipMapLinearFilter:()=>S,LinearMipMapNearestFilter:()=>T,LinearMipmapLinearFilter:()=>A,LinearMipmapNearestFilter:()=>I,MirroredRepeatWrapping:()=>m,NearestFilter:()=>y,NearestMipMapLinearFilter:()=>b,NearestMipMapNearestFilter:()=>g,NearestMipmapLinearFilter:()=>w,NearestMipmapNearestFilter:()=>x,PNGMediaType:()=>P,RepeatWrapping:()=>d,XKTModel:()=>Xe,XKT_INFO:()=>f,buildBoxGeometry:()=>Nr,buildBoxLinesGeometry:()=>Fr,buildCylinderGeometry:()=>Vr,buildGridGeometry:()=>Cr,buildPlaneGeometry:()=>Br,buildSphereGeometry:()=>Ur,buildTorusGeometry:()=>zr,buildVectorTextGeometry:()=>Xr,convert2xkt:()=>Wr,parseCityJSONIntoXKTModel:()=>Pt,parseGLTFIntoXKTModel:()=>Bt,parseGLTFJSONIntoXKTModel:()=>Jt,parseIFCIntoXKTModel:()=>ar,parseLASIntoXKTModel:()=>lr,parseMetaModelIntoXKTModel:()=>pr,parsePCDIntoXKTModel:()=>vr,parsePLYIntoXKTModel:()=>br,parseSTLIntoXKTModel:()=>Or,writeXKTModelToArrayBuffer:()=>Ze});const e=require("@loaders.gl/polyfills");var t,i,o,a,s,u,c,l,h,f={xktVersion:10},d=1e3,p=1001,m=1002,y=1003,g=1004,x=1004,w=1005,b=1005,M=1006,I=1007,T=1007,A=1008,S=1008,O=1e4,L=10001,P=10002,E=Float64Array,j=new E(16),G=new E(16),_=new E(4),k={MIN_DOUBLE:-Number.MAX_SAFE_INTEGER,MAX_DOUBLE:Number.MAX_SAFE_INTEGER,DEGTORAD:.0174532925,RADTODEG:57.295779513,vec2:function(e){return new E(e||2)},vec3:function(e){return new E(e||3)},vec4:function(e){return new E(e||4)},mat3:function(e){return new E(e||9)},mat3ToMat4:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new E(16);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=0,t[4]=e[3],t[5]=e[4],t[6]=e[5],t[7]=0,t[8]=e[6],t[9]=e[7],t[10]=e[8],t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t},mat4:function(e){return new E(e||16)},mat4ToMat3:function(e,t){},createUUID:function(){for(var e=[],t=0;t<256;t++)e[t]=(t<16?"0":"")+t.toString(16);return function(){var t=4294967295*Math.random()|0,r=4294967295*Math.random()|0,n=4294967295*Math.random()|0,i=4294967295*Math.random()|0;return"".concat(e[255&t]+e[t>>8&255]+e[t>>16&255]+e[t>>24&255],"-").concat(e[255&r]).concat(e[r>>8&255],"-").concat(e[r>>16&15|64]).concat(e[r>>24&255],"-").concat(e[63&n|128]).concat(e[n>>8&255],"-").concat(e[n>>16&255]).concat(e[n>>24&255]).concat(e[255&i]).concat(e[i>>8&255]).concat(e[i>>16&255]).concat(e[i>>24&255])}}(),clamp:function(e,t,r){return Math.max(t,Math.min(r,e))},fmod:function(e,t){if(e1?1:r,Math.acos(r)},vec3FromMat4Scale:(u=new E(3),function(e,t){return u[0]=e[0],u[1]=e[1],u[2]=e[2],t[0]=k.lenVec3(u),u[0]=e[4],u[1]=e[5],u[2]=e[6],t[1]=k.lenVec3(u),u[0]=e[8],u[1]=e[9],u[2]=e[10],t[2]=k.lenVec3(u),t}),vecToArray:function(){function e(e){return Math.round(1e5*e)/1e5}return function(t){for(var r=0,n=(t=Array.prototype.slice.call(t)).length;r0&&void 0!==arguments[0]?arguments[0]:new E(16);return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e},identityMat3:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new E(9);return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=1,e[5]=0,e[6]=0,e[7]=0,e[8]=1,e},isIdentityMat4:function(e){return 1===e[0]&&0===e[1]&&0===e[2]&&0===e[3]&&0===e[4]&&1===e[5]&&0===e[6]&&0===e[7]&&0===e[8]&&0===e[9]&&1===e[10]&&0===e[11]&&0===e[12]&&0===e[13]&&0===e[14]&&1===e[15]},negateMat4:function(e,t){return t||(t=e),t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t[3]=-e[3],t[4]=-e[4],t[5]=-e[5],t[6]=-e[6],t[7]=-e[7],t[8]=-e[8],t[9]=-e[9],t[10]=-e[10],t[11]=-e[11],t[12]=-e[12],t[13]=-e[13],t[14]=-e[14],t[15]=-e[15],t},addMat4:function(e,t,r){return r||(r=e),r[0]=e[0]+t[0],r[1]=e[1]+t[1],r[2]=e[2]+t[2],r[3]=e[3]+t[3],r[4]=e[4]+t[4],r[5]=e[5]+t[5],r[6]=e[6]+t[6],r[7]=e[7]+t[7],r[8]=e[8]+t[8],r[9]=e[9]+t[9],r[10]=e[10]+t[10],r[11]=e[11]+t[11],r[12]=e[12]+t[12],r[13]=e[13]+t[13],r[14]=e[14]+t[14],r[15]=e[15]+t[15],r},addMat4Scalar:function(e,t,r){return r||(r=e),r[0]=e[0]+t,r[1]=e[1]+t,r[2]=e[2]+t,r[3]=e[3]+t,r[4]=e[4]+t,r[5]=e[5]+t,r[6]=e[6]+t,r[7]=e[7]+t,r[8]=e[8]+t,r[9]=e[9]+t,r[10]=e[10]+t,r[11]=e[11]+t,r[12]=e[12]+t,r[13]=e[13]+t,r[14]=e[14]+t,r[15]=e[15]+t,r},addScalarMat4:function(e,t,r){return k.addMat4Scalar(t,e,r)},subMat4:function(e,t,r){return r||(r=e),r[0]=e[0]-t[0],r[1]=e[1]-t[1],r[2]=e[2]-t[2],r[3]=e[3]-t[3],r[4]=e[4]-t[4],r[5]=e[5]-t[5],r[6]=e[6]-t[6],r[7]=e[7]-t[7],r[8]=e[8]-t[8],r[9]=e[9]-t[9],r[10]=e[10]-t[10],r[11]=e[11]-t[11],r[12]=e[12]-t[12],r[13]=e[13]-t[13],r[14]=e[14]-t[14],r[15]=e[15]-t[15],r},subMat4Scalar:function(e,t,r){return r||(r=e),r[0]=e[0]-t,r[1]=e[1]-t,r[2]=e[2]-t,r[3]=e[3]-t,r[4]=e[4]-t,r[5]=e[5]-t,r[6]=e[6]-t,r[7]=e[7]-t,r[8]=e[8]-t,r[9]=e[9]-t,r[10]=e[10]-t,r[11]=e[11]-t,r[12]=e[12]-t,r[13]=e[13]-t,r[14]=e[14]-t,r[15]=e[15]-t,r},subScalarMat4:function(e,t,r){return r||(r=t),r[0]=e-t[0],r[1]=e-t[1],r[2]=e-t[2],r[3]=e-t[3],r[4]=e-t[4],r[5]=e-t[5],r[6]=e-t[6],r[7]=e-t[7],r[8]=e-t[8],r[9]=e-t[9],r[10]=e-t[10],r[11]=e-t[11],r[12]=e-t[12],r[13]=e-t[13],r[14]=e-t[14],r[15]=e-t[15],r},mulMat4:function(e,t,r){r||(r=e);var n=e[0],i=e[1],o=e[2],a=e[3],s=e[4],u=e[5],c=e[6],l=e[7],h=e[8],f=e[9],d=e[10],p=e[11],v=e[12],m=e[13],y=e[14],g=e[15],x=t[0],w=t[1],b=t[2],M=t[3],I=t[4],T=t[5],A=t[6],S=t[7],O=t[8],L=t[9],P=t[10],E=t[11],j=t[12],G=t[13],_=t[14],k=t[15];return r[0]=x*n+w*s+b*h+M*v,r[1]=x*i+w*u+b*f+M*m,r[2]=x*o+w*c+b*d+M*y,r[3]=x*a+w*l+b*p+M*g,r[4]=I*n+T*s+A*h+S*v,r[5]=I*i+T*u+A*f+S*m,r[6]=I*o+T*c+A*d+S*y,r[7]=I*a+T*l+A*p+S*g,r[8]=O*n+L*s+P*h+E*v,r[9]=O*i+L*u+P*f+E*m,r[10]=O*o+L*c+P*d+E*y,r[11]=O*a+L*l+P*p+E*g,r[12]=j*n+G*s+_*h+k*v,r[13]=j*i+G*u+_*f+k*m,r[14]=j*o+G*c+_*d+k*y,r[15]=j*a+G*l+_*p+k*g,r},mulMat3:function(e,t,r){r||(r=new E(9));var n=e[0],i=e[3],o=e[6],a=e[1],s=e[4],u=e[7],c=e[2],l=e[5],h=e[8],f=t[0],d=t[3],p=t[6],v=t[1],m=t[4],y=t[7],g=t[2],x=t[5],w=t[8];return r[0]=n*f+i*v+o*g,r[3]=n*d+i*m+o*x,r[6]=n*p+i*y+o*w,r[1]=a*f+s*v+u*g,r[4]=a*d+s*m+u*x,r[7]=a*p+s*y+u*w,r[2]=c*f+l*v+h*g,r[5]=c*d+l*m+h*x,r[8]=c*p+l*y+h*w,r},mulMat4Scalar:function(e,t,r){return r||(r=e),r[0]=e[0]*t,r[1]=e[1]*t,r[2]=e[2]*t,r[3]=e[3]*t,r[4]=e[4]*t,r[5]=e[5]*t,r[6]=e[6]*t,r[7]=e[7]*t,r[8]=e[8]*t,r[9]=e[9]*t,r[10]=e[10]*t,r[11]=e[11]*t,r[12]=e[12]*t,r[13]=e[13]*t,r[14]=e[14]*t,r[15]=e[15]*t,r},mulMat4v4:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:k.vec4(),n=t[0],i=t[1],o=t[2],a=t[3];return r[0]=e[0]*n+e[4]*i+e[8]*o+e[12]*a,r[1]=e[1]*n+e[5]*i+e[9]*o+e[13]*a,r[2]=e[2]*n+e[6]*i+e[10]*o+e[14]*a,r[3]=e[3]*n+e[7]*i+e[11]*o+e[15]*a,r},transposeMat4:function(e,t){var r=e[4],n=e[14],i=e[8],o=e[13],a=e[12],s=e[9];if(!t||e===t){var u=e[1],c=e[2],l=e[3],h=e[6],f=e[7],d=e[11];return e[1]=r,e[2]=i,e[3]=a,e[4]=u,e[6]=s,e[7]=o,e[8]=c,e[9]=h,e[11]=n,e[12]=l,e[13]=f,e[14]=d,e}return t[0]=e[0],t[1]=r,t[2]=i,t[3]=a,t[4]=e[1],t[5]=e[5],t[6]=s,t[7]=o,t[8]=e[2],t[9]=e[6],t[10]=e[10],t[11]=n,t[12]=e[3],t[13]=e[7],t[14]=e[11],t[15]=e[15],t},transposeMat3:function(e,t){if(t===e){var r=e[1],n=e[2],i=e[5];t[1]=e[3],t[2]=e[6],t[3]=r,t[5]=e[7],t[6]=n,t[7]=i}else t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8];return t},determinantMat4:function(e){var t=e[0],r=e[1],n=e[2],i=e[3],o=e[4],a=e[5],s=e[6],u=e[7],c=e[8],l=e[9],h=e[10],f=e[11],d=e[12],p=e[13],v=e[14],m=e[15];return d*l*s*i-c*p*s*i-d*a*h*i+o*p*h*i+c*a*v*i-o*l*v*i-d*l*n*u+c*p*n*u+d*r*h*u-t*p*h*u-c*r*v*u+t*l*v*u+d*a*n*f-o*p*n*f-d*r*s*f+t*p*s*f+o*r*v*f-t*a*v*f-c*a*n*m+o*l*n*m+c*r*s*m-t*l*s*m-o*r*h*m+t*a*h*m},inverseMat4:function(e,t){t||(t=e);var r=e[0],n=e[1],i=e[2],o=e[3],a=e[4],s=e[5],u=e[6],c=e[7],l=e[8],h=e[9],f=e[10],d=e[11],p=e[12],v=e[13],m=e[14],y=e[15],g=r*s-n*a,x=r*u-i*a,w=r*c-o*a,b=n*u-i*s,M=n*c-o*s,I=i*c-o*u,T=l*v-h*p,A=l*m-f*p,S=l*y-d*p,O=h*m-f*v,L=h*y-d*v,P=f*y-d*m,E=1/(g*P-x*L+w*O+b*S-M*A+I*T);return t[0]=(s*P-u*L+c*O)*E,t[1]=(-n*P+i*L-o*O)*E,t[2]=(v*I-m*M+y*b)*E,t[3]=(-h*I+f*M-d*b)*E,t[4]=(-a*P+u*S-c*A)*E,t[5]=(r*P-i*S+o*A)*E,t[6]=(-p*I+m*w-y*x)*E,t[7]=(l*I-f*w+d*x)*E,t[8]=(a*L-s*S+c*T)*E,t[9]=(-r*L+n*S-o*T)*E,t[10]=(p*M-v*w+y*g)*E,t[11]=(-l*M+h*w-d*g)*E,t[12]=(-a*O+s*A-u*T)*E,t[13]=(r*O-n*A+i*T)*E,t[14]=(-p*b+v*x-m*g)*E,t[15]=(l*b-h*x+f*g)*E,t},traceMat4:function(e){return e[0]+e[5]+e[10]+e[15]},translationMat4v:function(e,t){var r=t||k.identityMat4();return r[12]=e[0],r[13]=e[1],r[14]=e[2],r},translationMat3v:function(e,t){var r=t||k.identityMat3();return r[6]=e[0],r[7]=e[1],r},translationMat4c:(s=new E(3),function(e,t,r,n){return s[0]=e,s[1]=t,s[2]=r,k.translationMat4v(s,n)}),translationMat4s:function(e,t){return k.translationMat4c(e,e,e,t)},translateMat4v:function(e,t){return k.translateMat4c(e[0],e[1],e[2],t)},OLDtranslateMat4c:function(e,t,r,n){var i=n[12];n[0]+=i*e,n[4]+=i*t,n[8]+=i*r;var o=n[13];n[1]+=o*e,n[5]+=o*t,n[9]+=o*r;var a=n[14];n[2]+=a*e,n[6]+=a*t,n[10]+=a*r;var s=n[15];return n[3]+=s*e,n[7]+=s*t,n[11]+=s*r,n},translateMat4c:function(e,t,r,n){var i=n[3];n[0]+=i*e,n[1]+=i*t,n[2]+=i*r;var o=n[7];n[4]+=o*e,n[5]+=o*t,n[6]+=o*r;var a=n[11];n[8]+=a*e,n[9]+=a*t,n[10]+=a*r;var s=n[15];return n[12]+=s*e,n[13]+=s*t,n[14]+=s*r,n},rotationMat4v:function(e,t,r){var n,i,o,a,s,u,c=k.normalizeVec4([t[0],t[1],t[2],0],[]),l=Math.sin(e),h=Math.cos(e),f=1-h,d=c[0],p=c[1],v=c[2];return n=d*p,i=p*v,o=v*d,a=d*l,s=p*l,u=v*l,(r=r||k.mat4())[0]=f*d*d+h,r[1]=f*n+u,r[2]=f*o-s,r[3]=0,r[4]=f*n-u,r[5]=f*p*p+h,r[6]=f*i+a,r[7]=0,r[8]=f*o+s,r[9]=f*i-a,r[10]=f*v*v+h,r[11]=0,r[12]=0,r[13]=0,r[14]=0,r[15]=1,r},rotationMat4c:function(e,t,r,n,i){return k.rotationMat4v(e,[t,r,n],i)},scalingMat4v:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:k.identityMat4();return t[0]=e[0],t[5]=e[1],t[10]=e[2],t},scalingMat3v:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:k.identityMat3();return t[0]=e[0],t[4]=e[1],t},scalingMat4c:function(){var e=new E(3);return function(t,r,n,i){return e[0]=t,e[1]=r,e[2]=n,k.scalingMat4v(e,i)}}(),scaleMat4c:function(e,t,r,n){return n[0]*=e,n[4]*=t,n[8]*=r,n[1]*=e,n[5]*=t,n[9]*=r,n[2]*=e,n[6]*=t,n[10]*=r,n[3]*=e,n[7]*=t,n[11]*=r,n},scaleMat4v:function(e,t){var r=e[0],n=e[1],i=e[2];return t[0]*=r,t[4]*=n,t[8]*=i,t[1]*=r,t[5]*=n,t[9]*=i,t[2]*=r,t[6]*=n,t[10]*=i,t[3]*=r,t[7]*=n,t[11]*=i,t},scalingMat4s:function(e){return k.scalingMat4c(e,e,e)},rotationTranslationMat4:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:k.mat4(),n=e[0],i=e[1],o=e[2],a=e[3],s=n+n,u=i+i,c=o+o,l=n*s,h=n*u,f=n*c,d=i*u,p=i*c,v=o*c,m=a*s,y=a*u,g=a*c;return r[0]=1-(d+v),r[1]=h+g,r[2]=f-y,r[3]=0,r[4]=h-g,r[5]=1-(l+v),r[6]=p+m,r[7]=0,r[8]=f+y,r[9]=p-m,r[10]=1-(l+d),r[11]=0,r[12]=t[0],r[13]=t[1],r[14]=t[2],r[15]=1,r},mat4ToEuler:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:k.vec4(),n=k.clamp,i=e[0],o=e[4],a=e[8],s=e[1],u=e[5],c=e[9],l=e[2],h=e[6],f=e[10];return"XYZ"===t?(r[1]=Math.asin(n(a,-1,1)),Math.abs(a)<.99999?(r[0]=Math.atan2(-c,f),r[2]=Math.atan2(-o,i)):(r[0]=Math.atan2(h,u),r[2]=0)):"YXZ"===t?(r[0]=Math.asin(-n(c,-1,1)),Math.abs(c)<.99999?(r[1]=Math.atan2(a,f),r[2]=Math.atan2(s,u)):(r[1]=Math.atan2(-l,i),r[2]=0)):"ZXY"===t?(r[0]=Math.asin(n(h,-1,1)),Math.abs(h)<.99999?(r[1]=Math.atan2(-l,f),r[2]=Math.atan2(-o,u)):(r[1]=0,r[2]=Math.atan2(s,i))):"ZYX"===t?(r[1]=Math.asin(-n(l,-1,1)),Math.abs(l)<.99999?(r[0]=Math.atan2(h,f),r[2]=Math.atan2(s,i)):(r[0]=0,r[2]=Math.atan2(-o,u))):"YZX"===t?(r[2]=Math.asin(n(s,-1,1)),Math.abs(s)<.99999?(r[0]=Math.atan2(-c,u),r[1]=Math.atan2(-l,i)):(r[0]=0,r[1]=Math.atan2(a,f))):"XZY"===t&&(r[2]=Math.asin(-n(o,-1,1)),Math.abs(o)<.99999?(r[0]=Math.atan2(h,u),r[1]=Math.atan2(a,i)):(r[0]=Math.atan2(-c,f),r[1]=0)),r},composeMat4:function(e,t,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:k.mat4();return k.quaternionToRotationMat4(t,n),k.scaleMat4v(r,n),k.translateMat4v(e,n),n},decomposeMat4:function(){var e=new E(3),t=new E(16);return function(r,n,i,o){e[0]=r[0],e[1]=r[1],e[2]=r[2];var a=k.lenVec3(e);e[0]=r[4],e[1]=r[5],e[2]=r[6];var s=k.lenVec3(e);e[8]=r[8],e[9]=r[9],e[10]=r[10];var u=k.lenVec3(e);k.determinantMat4(r)<0&&(a=-a),n[0]=r[12],n[1]=r[13],n[2]=r[14],t.set(r);var c=1/a,l=1/s,h=1/u;return t[0]*=c,t[1]*=c,t[2]*=c,t[4]*=l,t[5]*=l,t[6]*=l,t[8]*=h,t[9]*=h,t[10]*=h,k.mat4ToQuaternion(t,i),o[0]=a,o[1]=s,o[2]=u,this}}(),lookAtMat4v:function(e,t,r,n){n||(n=k.mat4());var i,o,a,s,u,c,l,h,f,d,p=e[0],v=e[1],m=e[2],y=r[0],g=r[1],x=r[2],w=t[0],b=t[1],M=t[2];return p===w&&v===b&&m===M?k.identityMat4():(i=p-w,o=v-b,a=m-M,s=g*(a*=d=1/Math.sqrt(i*i+o*o+a*a))-x*(o*=d),u=x*(i*=d)-y*a,c=y*o-g*i,(d=Math.sqrt(s*s+u*u+c*c))?(s*=d=1/d,u*=d,c*=d):(s=0,u=0,c=0),l=o*c-a*u,h=a*s-i*c,f=i*u-o*s,(d=Math.sqrt(l*l+h*h+f*f))?(l*=d=1/d,h*=d,f*=d):(l=0,h=0,f=0),n[0]=s,n[1]=l,n[2]=i,n[3]=0,n[4]=u,n[5]=h,n[6]=o,n[7]=0,n[8]=c,n[9]=f,n[10]=a,n[11]=0,n[12]=-(s*p+u*v+c*m),n[13]=-(l*p+h*v+f*m),n[14]=-(i*p+o*v+a*m),n[15]=1,n)},lookAtMat4c:function(e,t,r,n,i,o,a,s,u){return k.lookAtMat4v([e,t,r],[n,i,o],[a,s,u],[])},orthoMat4c:function(e,t,r,n,i,o,a){a||(a=k.mat4());var s=t-e,u=n-r,c=o-i;return a[0]=2/s,a[1]=0,a[2]=0,a[3]=0,a[4]=0,a[5]=2/u,a[6]=0,a[7]=0,a[8]=0,a[9]=0,a[10]=-2/c,a[11]=0,a[12]=-(e+t)/s,a[13]=-(n+r)/u,a[14]=-(o+i)/c,a[15]=1,a},frustumMat4v:function(e,t,r){r||(r=k.mat4());var n=[e[0],e[1],e[2],0],i=[t[0],t[1],t[2],0];k.addVec4(i,n,j),k.subVec4(i,n,G);var o=2*n[2],a=G[0],s=G[1],u=G[2];return r[0]=o/a,r[1]=0,r[2]=0,r[3]=0,r[4]=0,r[5]=o/s,r[6]=0,r[7]=0,r[8]=j[0]/a,r[9]=j[1]/s,r[10]=-j[2]/u,r[11]=-1,r[12]=0,r[13]=0,r[14]=-o*i[2]/u,r[15]=0,r},frustumMat4:function(e,t,r,n,i,o,a){a||(a=k.mat4());var s=t-e,u=n-r,c=o-i;return a[0]=2*i/s,a[1]=0,a[2]=0,a[3]=0,a[4]=0,a[5]=2*i/u,a[6]=0,a[7]=0,a[8]=(t+e)/s,a[9]=(n+r)/u,a[10]=-(o+i)/c,a[11]=-1,a[12]=0,a[13]=0,a[14]=-o*i*2/c,a[15]=0,a},perspectiveMat4:function(e,t,r,n,i){var o=[],a=[];return o[2]=r,a[2]=n,a[1]=o[2]*Math.tan(e/2),o[1]=-a[1],a[0]=a[1]*t,o[0]=-a[0],k.frustumMat4v(o,a,i)},transformPoint3:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:k.vec3(),n=t[0],i=t[1],o=t[2];return r[0]=e[0]*n+e[4]*i+e[8]*o+e[12],r[1]=e[1]*n+e[5]*i+e[9]*o+e[13],r[2]=e[2]*n+e[6]*i+e[10]*o+e[14],r},transformPoint4:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:k.vec4();return r[0]=e[0]*t[0]+e[4]*t[1]+e[8]*t[2]+e[12]*t[3],r[1]=e[1]*t[0]+e[5]*t[1]+e[9]*t[2]+e[13]*t[3],r[2]=e[2]*t[0]+e[6]*t[1]+e[10]*t[2]+e[14]*t[3],r[3]=e[3]*t[0]+e[7]*t[1]+e[11]*t[2]+e[15]*t[3],r},transformPoints3:function(e,t,r){for(var n,i,o,a,s,u=r||[],c=t.length,l=e[0],h=e[1],f=e[2],d=e[3],p=e[4],v=e[5],m=e[6],y=e[7],g=e[8],x=e[9],w=e[10],b=e[11],M=e[12],I=e[13],T=e[14],A=e[15],S=0;S2&&void 0!==arguments[2]?arguments[2]:t,s=t.length,u=e[0],c=e[1],l=e[2],h=e[3],f=e[4],d=e[5],p=e[6],v=e[7],m=e[8],y=e[9],g=e[10],x=e[11],w=e[12],b=e[13],M=e[14],I=e[15];for(r=0;r2&&void 0!==arguments[2]?arguments[2]:t,s=t.length,u=e[0],c=e[1],l=e[2],h=e[3],f=e[4],d=e[5],p=e[6],v=e[7],m=e[8],y=e[9],g=e[10],x=e[11],w=e[12],b=e[13],M=e[14],I=e[15];for(r=0;r0&&void 0!==arguments[0]?arguments[0]:k.vec4();return e[0]=0,e[1]=0,e[2]=0,e[3]=1,e},eulerToQuaternion:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:k.vec4(),n=e[0]*k.DEGTORAD/2,i=e[1]*k.DEGTORAD/2,o=e[2]*k.DEGTORAD/2,a=Math.cos(n),s=Math.cos(i),u=Math.cos(o),c=Math.sin(n),l=Math.sin(i),h=Math.sin(o);return"XYZ"===t?(r[0]=c*s*u+a*l*h,r[1]=a*l*u-c*s*h,r[2]=a*s*h+c*l*u,r[3]=a*s*u-c*l*h):"YXZ"===t?(r[0]=c*s*u+a*l*h,r[1]=a*l*u-c*s*h,r[2]=a*s*h-c*l*u,r[3]=a*s*u+c*l*h):"ZXY"===t?(r[0]=c*s*u-a*l*h,r[1]=a*l*u+c*s*h,r[2]=a*s*h+c*l*u,r[3]=a*s*u-c*l*h):"ZYX"===t?(r[0]=c*s*u-a*l*h,r[1]=a*l*u+c*s*h,r[2]=a*s*h-c*l*u,r[3]=a*s*u+c*l*h):"YZX"===t?(r[0]=c*s*u+a*l*h,r[1]=a*l*u+c*s*h,r[2]=a*s*h-c*l*u,r[3]=a*s*u-c*l*h):"XZY"===t&&(r[0]=c*s*u-a*l*h,r[1]=a*l*u-c*s*h,r[2]=a*s*h+c*l*u,r[3]=a*s*u+c*l*h),r},mat4ToQuaternion:function(e){var t,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:k.vec4(),n=e[0],i=e[4],o=e[8],a=e[1],s=e[5],u=e[9],c=e[2],l=e[6],h=e[10],f=n+s+h;return f>0?(t=.5/Math.sqrt(f+1),r[3]=.25/t,r[0]=(l-u)*t,r[1]=(o-c)*t,r[2]=(a-i)*t):n>s&&n>h?(t=2*Math.sqrt(1+n-s-h),r[3]=(l-u)/t,r[0]=.25*t,r[1]=(i+a)/t,r[2]=(o+c)/t):s>h?(t=2*Math.sqrt(1+s-n-h),r[3]=(o-c)/t,r[0]=(i+a)/t,r[1]=.25*t,r[2]=(u+l)/t):(t=2*Math.sqrt(1+h-n-s),r[3]=(a-i)/t,r[0]=(o+c)/t,r[1]=(u+l)/t,r[2]=.25*t),r},vec3PairToQuaternion:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:k.vec4(),n=Math.sqrt(k.dotVec3(e,e)*k.dotVec3(t,t)),i=n+k.dotVec3(e,t);return i<1e-8*n?(i=0,Math.abs(e[0])>Math.abs(e[2])?(r[0]=-e[1],r[1]=e[0],r[2]=0):(r[0]=0,r[1]=-e[2],r[2]=e[1])):k.cross3Vec3(e,t,r),r[3]=i,k.normalizeQuaternion(r)},angleAxisToQuaternion:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:k.vec4(),r=e[3]/2,n=Math.sin(r);return t[0]=n*e[0],t[1]=n*e[1],t[2]=n*e[2],t[3]=Math.cos(r),t},quaternionToEuler:function(){var e=new E(16);return function(t,r,n){return n=n||k.vec3(),k.quaternionToRotationMat4(t,e),k.mat4ToEuler(e,r,n),n}}(),mulQuaternions:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:k.vec4(),n=e[0],i=e[1],o=e[2],a=e[3],s=t[0],u=t[1],c=t[2],l=t[3];return r[0]=a*s+n*l+i*c-o*u,r[1]=a*u+i*l+o*s-n*c,r[2]=a*c+o*l+n*u-i*s,r[3]=a*l-n*s-i*u-o*c,r},vec3ApplyQuaternion:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:k.vec3(),n=t[0],i=t[1],o=t[2],a=e[0],s=e[1],u=e[2],c=e[3],l=c*n+s*o-u*i,h=c*i+u*n-a*o,f=c*o+a*i-s*n,d=-a*n-s*i-u*o;return r[0]=l*c+d*-a+h*-u-f*-s,r[1]=h*c+d*-s+f*-a-l*-u,r[2]=f*c+d*-u+l*-s-h*-a,r},quaternionToMat4:function(e,t){t=k.identityMat4(t);var r=e[0],n=e[1],i=e[2],o=e[3],a=2*r,s=2*n,u=2*i,c=a*o,l=s*o,h=u*o,f=a*r,d=s*r,p=u*r,v=s*n,m=u*n,y=u*i;return t[0]=1-(v+y),t[1]=d+h,t[2]=p-l,t[4]=d-h,t[5]=1-(f+y),t[6]=m+c,t[8]=p+l,t[9]=m-c,t[10]=1-(f+v),t},quaternionToRotationMat4:function(e,t){var r=e[0],n=e[1],i=e[2],o=e[3],a=r+r,s=n+n,u=i+i,c=r*a,l=r*s,h=r*u,f=n*s,d=n*u,p=i*u,v=o*a,m=o*s,y=o*u;return t[0]=1-(f+p),t[4]=l-y,t[8]=h+m,t[1]=l+y,t[5]=1-(c+p),t[9]=d-v,t[2]=h-m,t[6]=d+v,t[10]=1-(c+f),t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t},normalizeQuaternion:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:e,r=k.lenVec4([e[0],e[1],e[2],e[3]]);return t[0]=e[0]/r,t[1]=e[1]/r,t[2]=e[2]/r,t[3]=e[3]/r,t},conjugateQuaternion:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:e;return t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t[3]=e[3],t},inverseQuaternion:function(e,t){return k.normalizeQuaternion(k.conjugateQuaternion(e,t))},quaternionToAngleAxis:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:k.vec4(),r=(e=k.normalizeQuaternion(e,_))[3],n=2*Math.acos(r),i=Math.sqrt(1-r*r);return i<.001?(t[0]=e[0],t[1]=e[1],t[2]=e[2]):(t[0]=e[0]/i,t[1]=e[1]/i,t[2]=e[2]/i),t[3]=n,t},AABB3:function(e){return new E(e||6)},AABB2:function(e){return new E(e||4)},OBB3:function(e){return new E(e||32)},OBB2:function(e){return new E(e||16)},Sphere3:function(e,t,r,n){return new E([e,t,r,n])},transformOBB3:function(e,t){var r,n,i,o,a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:t,s=t.length,u=e[0],c=e[1],l=e[2],h=e[3],f=e[4],d=e[5],p=e[6],v=e[7],m=e[8],y=e[9],g=e[10],x=e[11],w=e[12],b=e[13],M=e[14],I=e[15];for(r=0;rs?a:s,o[1]+=u>c?u:c,o[2]+=l>h?l:h,Math.abs(k.lenVec3(o))}}(),getAABB3Center:function(e,t){var r=t||k.vec3();return r[0]=(e[0]+e[3])/2,r[1]=(e[1]+e[4])/2,r[2]=(e[2]+e[5])/2,r},getAABB2Center:function(e,t){var r=t||k.vec2();return r[0]=(e[2]+e[0])/2,r[1]=(e[3]+e[1])/2,r},collapseAABB3:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:k.AABB3();return e[0]=k.MAX_DOUBLE,e[1]=k.MAX_DOUBLE,e[2]=k.MAX_DOUBLE,e[3]=-k.MAX_DOUBLE,e[4]=-k.MAX_DOUBLE,e[5]=-k.MAX_DOUBLE,e},AABB3ToOBB3:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:k.OBB3();return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=1,t[4]=e[3],t[5]=e[1],t[6]=e[2],t[7]=1,t[8]=e[3],t[9]=e[4],t[10]=e[2],t[11]=1,t[12]=e[0],t[13]=e[4],t[14]=e[2],t[15]=1,t[16]=e[0],t[17]=e[1],t[18]=e[5],t[19]=1,t[20]=e[3],t[21]=e[1],t[22]=e[5],t[23]=1,t[24]=e[3],t[25]=e[4],t[26]=e[5],t[27]=1,t[28]=e[0],t[29]=e[4],t[30]=e[5],t[31]=1,t},positions3ToAABB3:(t=new E(3),function(e,r,n){r=r||k.AABB3();for(var i,o,a,s=k.MAX_DOUBLE,u=k.MAX_DOUBLE,c=k.MAX_DOUBLE,l=-k.MAX_DOUBLE,h=-k.MAX_DOUBLE,f=-k.MAX_DOUBLE,d=0,p=e.length;dl&&(l=i),o>h&&(h=o),a>f&&(f=a);return r[0]=s,r[1]=u,r[2]=c,r[3]=l,r[4]=h,r[5]=f,r}),OBB3ToAABB3:function(e){for(var t,r,n,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:k.AABB3(),o=k.MAX_DOUBLE,a=k.MAX_DOUBLE,s=k.MAX_DOUBLE,u=-k.MAX_DOUBLE,c=-k.MAX_DOUBLE,l=-k.MAX_DOUBLE,h=0,f=e.length;hu&&(u=t),r>c&&(c=r),n>l&&(l=n);return i[0]=o,i[1]=a,i[2]=s,i[3]=u,i[4]=c,i[5]=l,i},points3ToAABB3:function(e){for(var t,r,n,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:k.AABB3(),o=k.MAX_DOUBLE,a=k.MAX_DOUBLE,s=k.MAX_DOUBLE,u=-k.MAX_DOUBLE,c=-k.MAX_DOUBLE,l=-k.MAX_DOUBLE,h=0,f=e.length;hu&&(u=t),r>c&&(c=r),n>l&&(l=n);return i[0]=o,i[1]=a,i[2]=s,i[3]=u,i[4]=c,i[5]=l,i},points3ToSphere3:function(){var e=new E(3);return function(t,r){r=r||k.vec4();var n,i=0,o=0,a=0,s=t.length;for(n=0;nc&&(c=u);return r[3]=c,r}}(),positions3ToSphere3:function(){var e=new E(3),t=new E(3);return function(r,n){n=n||k.vec4();var i,o=0,a=0,s=0,u=r.length,c=0;for(i=0;ic&&(c=l);return n[3]=c,n}}(),OBB3ToSphere3:function(){var e=new E(3),t=new E(3);return function(r,n){n=n||k.vec4();var i,o=0,a=0,s=0,u=r.length,c=u/4;for(i=0;ih&&(h=l);return n[3]=h,n}}(),getSphere3Center:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:k.vec3();return t[0]=e[0],t[1]=e[1],t[2]=e[2],t},expandAABB3:function(e,t){return e[0]>t[0]&&(e[0]=t[0]),e[1]>t[1]&&(e[1]=t[1]),e[2]>t[2]&&(e[2]=t[2]),e[3]t[0]&&(e[0]=t[0]),e[1]>t[1]&&(e[1]=t[1]),e[2]>t[2]&&(e[2]=t[2]),e[3]3&&void 0!==arguments[3]?arguments[3]:k.vec3(),i=t[0]-e[0],o=t[1]-e[1],a=t[2]-e[2],s=r[0]-e[0],u=r[1]-e[1],c=r[2]-e[2],l=o*c-a*u,h=a*s-i*c,f=i*u-o*s,d=Math.sqrt(l*l+h*h+f*f);return 0===d?(n[0]=0,n[1]=0,n[2]=0):(n[0]=l/d,n[1]=h/d,n[2]=f/d),n}};function D(e,t,r,n){var i=e[t]/(Math.abs(e[t])+Math.abs(e[t+1])+Math.abs(e[t+2])),o=e[t+1]/(Math.abs(e[t])+Math.abs(e[t+1])+Math.abs(e[t+2]));if(e[t+2]<0){var a=(1-Math.abs(o))*(i>=0?1:-1),s=(1-Math.abs(i))*(o>=0?1:-1);i=a,o=s}return new Int8Array([Math[r](127.5*i+(i<0?-1:0)),Math[n](127.5*o+(o<0?-1:0))])}function N(e){var t=e[0],r=e[1];t/=t<0?127:128,r/=r<0?127:128;var n=1-Math.abs(t)-Math.abs(r);n<0&&(t=(1-Math.abs(r))*(t>=0?1:-1),r=(1-Math.abs(t))*(r>=0?1:-1));var i=Math.sqrt(t*t+r*r+n*n);return[t/i,r/i,n/i]}function F(e,t,r){return e[t]*r[0]+e[t+1]*r[1]+e[t+2]*r[2]}var V,C,B,U,z,R,X,K,q,Z,Y,Q,W,J,H,$,ee,te={quantizePositions:function(e,t,r,n){for(var i=r[0],o=r[1],a=r[2],s=65535,u=s/(r[3]-i),c=s/(r[4]-o),l=s/(r[5]-a),h=function(e){return e>=0?e:0},f=0;fu&&(a=o,u=s),(s=F(h,0,N(o=D(h,0,"floor","ceil"))))>u&&(a=o,u=s),(s=F(h,0,N(o=D(h,0,"ceil","ceil"))))>u&&(a=o,u=s),n[i+c+0]=a[0],n[i+c+1]=a[1],n[i+c+2]=0;return i+r},octEncodeNormals:function(e,t,r,n){for(var i,o,a,s,u=0;us&&(o=i,s=a),(a=F(e,u,N(i=D(e,u,"floor","ceil"))))>s&&(o=i,s=a),(a=F(e,u,N(i=D(e,u,"ceil","ceil"))))>s&&(o=i,s=a),r[n+u+0]=o[0],r[n+u+1]=o[1],r[n+u+2]=0;return n+t}},re=(V=[],C=[],B=[],U=[],z=[],R=0,X=new Uint16Array(3),K=new Uint16Array(3),q=new Uint16Array(3),Z=k.vec3(),Y=k.vec3(),Q=k.vec3(),W=k.vec3(),J=k.vec3(),H=k.vec3(),$=k.vec3(),ee=k.vec3(),function(e,t,r,n){!function(e,t){var r,n,i,o,a,s,u={},c=Math.pow(10,4),l=0;for(a=0,s=e.length;am&&I>m)continue}d=B[c.index1],p=B[c.index2],(!g&&d>65535||p>65535)&&(g=!0),v.push(d),v.push(p)}return g?new Uint32Array(v):new Uint16Array(v)}),ne=function(e,t,r,n){function i(e,r){for(var n,i,o=0;o<3;o++)if((n=t[3*e+o])!==(i=t[3*r+o]))return i-n;return 0}for(var o=e.slice().sort(i),a=null,s=0,u=o.length;sf&&h>d?f>d?(p=h,v=f,m=d):(p=h,v=d,m=f):f>h&&f>d?h>d?(p=f,v=h,m=d):(p=f,v=d,m=h):d>h&&d>f&&(h>f?(p=d,v=h,m=f):(p=d,v=f,m=h)),n[c+0]=[p,v],n[c+1]=[v,m],p>m){var y=m;m=p,p=y}n[c+2]=[m,p]}function g(e,t){for(var r,n,i=0;i<2;i++)if(r=e[i],(n=t[i])!==r)return n-r;return 0}(n=n.slice(0,e.length)).sort(g);for(var x=0,w=0;w0&&2!==x)};function ie(e,t){for(var r=0;r1}}])&&se(t.prototype,r),Object.defineProperty(t,"prototype",{writable:!1}),e}();function ce(e,t){for(var r=0;r=0;--i){var o=this.tryEntries[i],a=o.completion;if("root"===o.tryLoc)return n("end");if(o.tryLoc<=this.prev){var s=r.call(o,"catchLoc"),u=r.call(o,"finallyLoc");if(s&&u){if(this.prev=0;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&r.call(i,"finallyLoc")&&this.prev=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),M(r),l}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var i=n.arg;M(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:T(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=void 0),l}},e}function De(e,t,r,n,i,o,a){try{var s=e[o](a),u=s.value}catch(e){return void r(e)}s.done?t(u):Promise.resolve(u).then(n,i)}function Ne(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Fe(e,t){for(var r=0;r0&&void 0!==arguments[0]?arguments[0]:{};Ne(this,e),this.modelId=t.modelId||"default",this.projectId=t.projectId||"",this.revisionId=t.revisionId||"",this.author=t.author||"",this.createdAt=t.createdAt||"",this.creatingApplication=t.creatingApplication||"",this.schema=t.schema||"",this.xktVersion=f.xktVersion,this.edgeThreshold=t.edgeThreshold||10,this.minTileSize=t.minTileSize||500,this.propertySets={},this.propertySetsList=[],this.metaObjects={},this.metaObjectsList=[],this.reusedGeometriesDecodeMatrix=new Float32Array(16),this.geometries={},this.geometriesList=[],this.textures={},this.texturesList=[],this.textureSets={},this.textureSetsList=[],this.meshes={},this.meshesList=[],this.entities={},this.entitiesList=[],this.tilesList=[],this.aabb=k.AABB3(),this.finalized=!1}var t,r,n,i;return t=e,r=[{key:"createPropertySet",value:function(e){if(!e)throw"Parameters expected: params";if(null===e.propertySetId||void 0===e.propertySetId)throw"Parameter expected: params.propertySetId";if(null===e.properties||void 0===e.properties)throw"Parameter expected: params.properties";if(this.finalized)console.error("XKTModel has been finalized, can't add more property sets");else if(!this.propertySets[e.propertySetId]){var t=e.propertySetId,r=e.propertySetType||"Default",n=e.propertySetName||e.propertySetId,i=e.properties||[],o=new Ie(t,r,n,i);return this.propertySets[t]=o,this.propertySetsList.push(o),o}}},{key:"createMetaObject",value:function(e){if(!e)throw"Parameters expected: params";if(null===e.metaObjectId||void 0===e.metaObjectId)throw"Parameter expected: params.metaObjectId";if(this.finalized)console.error("XKTModel has been finalized, can't add more meta objects");else if(!this.metaObjects[e.metaObjectId]){var t=e.metaObjectId,r=e.propertySetIds,n=e.metaObjectType||"Default",i=e.metaObjectName||e.metaObjectId,o=e.parentMetaObjectId,a=new we(t,r,n,i,o);return this.metaObjects[t]=a,this.metaObjectsList.push(a),o||this._rootMetaObject||(this._rootMetaObject=a),a}}},{key:"createTexture",value:function(e){if(!e)throw"Parameters expected: params";if(null===e.textureId||void 0===e.textureId)throw"Parameter expected: params.textureId";if(!e.imageData&&!e.src)throw"Parameter expected: params.imageData or params.src";if(this.finalized)console.error("XKTModel has been finalized, can't add more textures");else{if(!this.textures[e.textureId]){if(e.src){var t=e.src.split(".").pop();if("jpg"!==t&&"jpeg"!==t&&"png"!==t)return void console.error("XKTModel does not support image files with extension '".concat(t,"' - won't create texture '").concat(e.textureId))}var r=e.textureId,n=new Se({textureId:r,imageData:e.imageData,mediaType:e.mediaType,minFilter:e.minFilter,magFilter:e.magFilter,wrapS:e.wrapS,wrapT:e.wrapT,wrapR:e.wrapR,width:e.width,height:e.height,compressed:!1!==e.compressed,src:e.src});return this.textures[r]=n,this.texturesList.push(n),n}console.error("XKTTexture already exists with this ID: "+e.textureId)}}},{key:"createTextureSet",value:function(e){if(!e)throw"Parameters expected: params";if(null===e.textureSetId||void 0===e.textureSetId)throw"Parameter expected: params.textureSetId";if(this.finalized)console.error("XKTModel has been finalized, can't add more textureSets");else{if(!this.textureSets[e.textureSetId]){var t,r,n,i,o;if(void 0!==e.colorTextureId&&null!==e.colorTextureId){if(!(t=this.textures[e.colorTextureId]))return void console.error("Texture not found: ".concat(e.colorTextureId," - ensure that you create it first with createTexture()"));t.channel=0}if(void 0!==e.metallicRoughnessTextureId&&null!==e.metallicRoughnessTextureId){if(!(r=this.textures[e.metallicRoughnessTextureId]))return void console.error("Texture not found: ".concat(e.metallicRoughnessTextureId," - ensure that you create it first with createTexture()"));r.channel=1}if(void 0!==e.normalsTextureId&&null!==e.normalsTextureId){if(!(n=this.textures[e.normalsTextureId]))return void console.error("Texture not found: ".concat(e.normalsTextureId," - ensure that you create it first with createTexture()"));n.channel=2}if(void 0!==e.emissiveTextureId&&null!==e.emissiveTextureId){if(!(i=this.textures[e.emissiveTextureId]))return void console.error("Texture not found: ".concat(e.emissiveTextureId," - ensure that you create it first with createTexture()"));i.channel=3}if(void 0!==e.occlusionTextureId&&null!==e.occlusionTextureId){if(!(o=this.textures[e.occlusionTextureId]))return void console.error("Texture not found: ".concat(e.occlusionTextureId," - ensure that you create it first with createTexture()"));o.channel=4}var a=new Pe({textureSetId:e.textureSetId,textureSetIndex:this.textureSetsList.length,colorTexture:t,metallicRoughnessTexture:r,normalsTexture:n,emissiveTexture:i,occlusionTexture:o});return this.textureSets[e.textureSetId]=a,this.textureSetsList.push(a),a}console.error("XKTTextureSet already exists with this ID: "+e.textureSetId)}}},{key:"createGeometry",value:function(e){if(!e)throw"Parameters expected: params";if(null===e.geometryId||void 0===e.geometryId)throw"Parameter expected: params.geometryId";if(!e.primitiveType)throw"Parameter expected: params.primitiveType";if(!e.positions)throw"Parameter expected: params.positions";var t="triangles"===e.primitiveType,r="points"===e.primitiveType,n="lines"===e.primitiveType;if(!t&&!r&&!n)throw"Unsupported value for params.primitiveType: "+e.primitiveType+"' - supported values are 'triangles', 'points' and 'lines'";if(t&&!e.indices)throw"Parameter expected for 'triangles' primitive: params.indices";if(r&&!e.colors&&!e.colorsCompressed)throw"Parameter expected for 'points' primitive: params.colors or params.colorsCompressed";if(n&&!e.indices)throw"Parameter expected for 'lines' primitive: params.indices";if(this.finalized)console.error("XKTModel has been finalized, can't add more geometries");else{if(!this.geometries[e.geometryId]){var i=e.geometryId,o=e.primitiveType,a=new Float64Array(e.positions),s={geometryId:i,geometryIndex:this.geometriesList.length,primitiveType:o,positions:a,uvs:e.uvs||e.uv};if(t&&(e.normals&&(s.normals=new Float32Array(e.normals)),s.indices=e.indices),r)if(e.colorsCompressed)s.colorsCompressed=new Uint8Array(e.colorsCompressed);else{for(var u=e.colors,c=new Uint8Array(u.length),l=0,h=u.length;l1)te.octEncodeNormals(n.normals,n.normals.length,n.normalsOctEncoded,0);else{var i=k.inverseMat4(k.transposeMat4(r.matrix,Be),Ue);te.transformAndOctEncodeNormals(i,n.normals,n.normals.length,n.normalsOctEncoded,0)}}}},{key:"_createEntityAABBs",value:function(){for(var e=0,t=this.entitiesList.length;e1)for(var l=u.positions,h=0,f=l.length;hze[i]&&(i=1),ze[2]>ze[i]&&(i=2),!e.left){var o=r.slice();if(o[i+3]=(r[i]+r[i+3])/2,e.left=new ye(o),k.containsAABB3(o,n))return void this._insertEntityIntoKDTree(e.left,t)}if(!e.right){var a=r.slice();if(a[i]=(r[i]+r[i+3])/2,e.right=new ye(a),k.containsAABB3(a,n))return void this._insertEntityIntoKDTree(e.right,t)}e.entities=e.entities||[],e.entities.push(t),k.expandAABB3(r,n)}}},{key:"_createTilesFromKDTree",value:function(e){this._createTilesFromKDNode(e)}},{key:"_createTilesFromKDNode",value:function(e){e.entities&&e.entities.length>0&&this._createTileFromEntities(e.entities),e.left&&this._createTilesFromKDNode(e.left),e.right&&this._createTilesFromKDNode(e.right)}},{key:"_createTileFromEntities",value:function(e){var t=k.AABB3();k.collapseAABB3(t);for(var r=0;r0){te.createPositionsDecodeMatrix(t,this.reusedGeometriesDecodeMatrix);for(var c=0,l=this.geometriesList.length;ce&&(e=i.positionsQuantized.length),i.indices.length>t&&(t=i.indices.length))}for(var o=new Array(e/3),a=new Array(t),s=0,u=this.geometriesList.length;s1&&void 0!==arguments[1]?arguments[1]:{},r=Ye(e,t),n=Qe(r);t.texturesSize+=n.textureData.byteLength;var i=We(n);return i}function Ye(e,t){for(var r=e.propertySetsList,n=e.metaObjectsList,i=e.geometriesList,o=e.texturesList,a=e.textureSetsList,s=e.meshesList,u=e.entitiesList,c=e.tilesList,l=r.length,h=n.length,f=i.length,d=o.length,p=a.length,v=s.length,m=u.length,y=c.length,g=0,x=0,w=0,b=0,M=0,I=0,T=0,A=0,S=0;S1&&(T+=16);var j={metadata:{},textureData:new Uint8Array(A),eachTextureDataPortion:new Uint32Array(d),eachTextureAttributes:new Uint16Array(9*d),positions:new Uint16Array(g),normals:new Int8Array(x),colors:new Uint8Array(w),uvs:new Float32Array(b),indices:new Uint32Array(M),edgeIndices:new Uint32Array(I),eachTextureSetTextures:new Int32Array(5*p),matrices:new Float32Array(T),reusedGeometriesDecodeMatrix:new Float32Array(e.reusedGeometriesDecodeMatrix),eachGeometryPrimitiveType:new Uint8Array(f),eachGeometryPositionsPortion:new Uint32Array(f),eachGeometryNormalsPortion:new Uint32Array(f),eachGeometryColorsPortion:new Uint32Array(f),eachGeometryUVsPortion:new Uint32Array(f),eachGeometryIndicesPortion:new Uint32Array(f),eachGeometryEdgeIndicesPortion:new Uint32Array(f),eachMeshGeometriesPortion:new Uint32Array(v),eachMeshMatricesPortion:new Uint32Array(v),eachMeshTextureSet:new Int32Array(v),eachMeshMaterialAttributes:new Uint8Array(6*v),eachEntityId:[],eachEntityMeshesPortion:new Uint32Array(m),eachTileAABB:new Float64Array(6*y),eachTileEntitiesPortion:new Uint32Array(y)},G=0,_=0,k=0,D=0,N=0,F=0;j.metadata={id:e.modelId,projectId:e.projectId,revisionId:e.revisionId,author:e.author,createdAt:e.createdAt,creatingApplication:e.creatingApplication,schema:e.schema,propertySets:[],metaObjects:[]};for(var V=0;V0&&(R.propertySetIds=z.propertySetIds),z.external&&(R.external=z.external),j.metadata.metaObjects.push(R)}for(var X=0;X1&&(j.matrices.set(ge.matrix,ae),j.eachMeshMatricesPortion[se]=ae,ae+=16),j.eachMeshTextureSet[se]=ge.textureSet?ge.textureSet.textureSetIndex:-1,j.eachMeshMaterialAttributes[oe++]=255*ge.color[0],j.eachMeshMaterialAttributes[oe++]=255*ge.color[1],j.eachMeshMaterialAttributes[oe++]=255*ge.color[2],j.eachMeshMaterialAttributes[oe++]=255*ge.opacity,j.eachMeshMaterialAttributes[oe++]=255*ge.metallic,j.eachMeshMaterialAttributes[oe++]=255*ge.roughness,se++}j.eachEntityId[ne]=pe.entityId,j.eachEntityMeshesPortion[ne]=ie,ne++,ie+=me}var we=6*ue;j.eachTileAABB.set(fe,we)}}return j}function Qe(e){return{metadata:Ke.deflate((t=e.metadata,JSON.stringify(t).replace(/[\u007F-\uFFFF]/g,(function(e){return"\\u"+("0000"+e.charCodeAt(0).toString(16)).substr(-4)})))),textureData:Ke.deflate(e.textureData.buffer),eachTextureDataPortion:Ke.deflate(e.eachTextureDataPortion.buffer),eachTextureAttributes:Ke.deflate(e.eachTextureAttributes.buffer),positions:Ke.deflate(e.positions.buffer),normals:Ke.deflate(e.normals.buffer),colors:Ke.deflate(e.colors.buffer),uvs:Ke.deflate(e.uvs.buffer),indices:Ke.deflate(e.indices.buffer),edgeIndices:Ke.deflate(e.edgeIndices.buffer),eachTextureSetTextures:Ke.deflate(e.eachTextureSetTextures.buffer),matrices:Ke.deflate(e.matrices.buffer),reusedGeometriesDecodeMatrix:Ke.deflate(e.reusedGeometriesDecodeMatrix.buffer),eachGeometryPrimitiveType:Ke.deflate(e.eachGeometryPrimitiveType.buffer),eachGeometryPositionsPortion:Ke.deflate(e.eachGeometryPositionsPortion.buffer),eachGeometryNormalsPortion:Ke.deflate(e.eachGeometryNormalsPortion.buffer),eachGeometryColorsPortion:Ke.deflate(e.eachGeometryColorsPortion.buffer),eachGeometryUVsPortion:Ke.deflate(e.eachGeometryUVsPortion.buffer),eachGeometryIndicesPortion:Ke.deflate(e.eachGeometryIndicesPortion.buffer),eachGeometryEdgeIndicesPortion:Ke.deflate(e.eachGeometryEdgeIndicesPortion.buffer),eachMeshGeometriesPortion:Ke.deflate(e.eachMeshGeometriesPortion.buffer),eachMeshMatricesPortion:Ke.deflate(e.eachMeshMatricesPortion.buffer),eachMeshTextureSet:Ke.deflate(e.eachMeshTextureSet.buffer),eachMeshMaterialAttributes:Ke.deflate(e.eachMeshMaterialAttributes.buffer),eachEntityId:Ke.deflate(JSON.stringify(e.eachEntityId).replace(/[\u007F-\uFFFF]/g,(function(e){return"\\u"+("0000"+e.charCodeAt(0).toString(16)).substr(-4)}))),eachEntityMeshesPortion:Ke.deflate(e.eachEntityMeshesPortion.buffer),eachTileAABB:Ke.deflate(e.eachTileAABB.buffer),eachTileEntitiesPortion:Ke.deflate(e.eachTileEntitiesPortion.buffer)};var t}function We(e){return function(e){var t=new Uint32Array(e.length+2);t[0]=qe,t[1]=e.length;for(var r=0,n=0,i=e.length;n80*r){n=o=e[0],i=a=e[1];for(var p=r;po&&(o=s),u>a&&(a=u);c=0!==(c=Math.max(o-n,a-i))?1/c:0}return et(f,d,r,n,i,c),d}function He(e,t,r,n,i){var o,a;if(i===Mt(e,t,r,n)>0)for(o=t;o=t;o-=n)a=xt(o,e[o],e[o+1],a);return a&&dt(a,a.next)&&(wt(a),a=a.next),a}function $e(e,t){if(!e)return e;t||(t=e);var r,n=e;do{if(r=!1,n.steiner||!dt(n,n.next)&&0!==ft(n.prev,n,n.next))n=n.next;else{if(wt(n),(n=t=n.prev)===n.next)break;r=!0}}while(r||n!==t);return t}function et(e,t,r,n,i,o,a){if(e){!a&&o&&function(e,t,r,n){var i=e;do{null===i.z&&(i.z=ut(i.x,i.y,t,r,n)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next}while(i!==e);i.prevZ.nextZ=null,i.prevZ=null,function(e){var t,r,n,i,o,a,s,u,c=1;do{for(r=e,e=null,o=null,a=0;r;){for(a++,n=r,s=0,t=0;t0||u>0&&n;)0!==s&&(0===u||!n||r.z<=n.z)?(i=r,r=r.nextZ,s--):(i=n,n=n.nextZ,u--),o?o.nextZ=i:e=i,i.prevZ=o,o=i;r=n}o.nextZ=null,c*=2}while(a>1)}(i)}(e,n,i,o);for(var s,u,c=e;e.prev!==e.next;)if(s=e.prev,u=e.next,o?rt(e,n,i,o):tt(e))t.push(s.i/r),t.push(e.i/r),t.push(u.i/r),wt(e),e=u.next,c=u.next;else if((e=u)===c){a?1===a?et(e=nt($e(e),t,r),t,r,n,i,o,2):2===a&&it(e,t,r,n,i,o):et($e(e),t,r,n,i,o,1);break}}}function tt(e){var t=e.prev,r=e,n=e.next;if(ft(t,r,n)>=0)return!1;for(var i=e.next.next;i!==e.prev;){if(lt(t.x,t.y,r.x,r.y,n.x,n.y,i.x,i.y)&&ft(i.prev,i,i.next)>=0)return!1;i=i.next}return!0}function rt(e,t,r,n){var i=e.prev,o=e,a=e.next;if(ft(i,o,a)>=0)return!1;for(var s=i.xo.x?i.x>a.x?i.x:a.x:o.x>a.x?o.x:a.x,l=i.y>o.y?i.y>a.y?i.y:a.y:o.y>a.y?o.y:a.y,h=ut(s,u,t,r,n),f=ut(c,l,t,r,n),d=e.prevZ,p=e.nextZ;d&&d.z>=h&&p&&p.z<=f;){if(d!==e.prev&&d!==e.next&<(i.x,i.y,o.x,o.y,a.x,a.y,d.x,d.y)&&ft(d.prev,d,d.next)>=0)return!1;if(d=d.prevZ,p!==e.prev&&p!==e.next&<(i.x,i.y,o.x,o.y,a.x,a.y,p.x,p.y)&&ft(p.prev,p,p.next)>=0)return!1;p=p.nextZ}for(;d&&d.z>=h;){if(d!==e.prev&&d!==e.next&<(i.x,i.y,o.x,o.y,a.x,a.y,d.x,d.y)&&ft(d.prev,d,d.next)>=0)return!1;d=d.prevZ}for(;p&&p.z<=f;){if(p!==e.prev&&p!==e.next&<(i.x,i.y,o.x,o.y,a.x,a.y,p.x,p.y)&&ft(p.prev,p,p.next)>=0)return!1;p=p.nextZ}return!0}function nt(e,t,r){var n=e;do{var i=n.prev,o=n.next.next;!dt(i,o)&&pt(i,n,n.next,o)&&yt(i,o)&&yt(o,i)&&(t.push(i.i/r),t.push(n.i/r),t.push(o.i/r),wt(n),wt(n.next),n=e=o),n=n.next}while(n!==e);return $e(n)}function it(e,t,r,n,i,o){var a=e;do{for(var s=a.next.next;s!==a.prev;){if(a.i!==s.i&&ht(a,s)){var u=gt(a,s);return a=$e(a,a.next),u=$e(u,u.next),et(a,t,r,n,i,o),void et(u,t,r,n,i,o)}s=s.next}a=a.next}while(a!==e)}function ot(e,t){return e.x-t.x}function at(e,t){if(t=function(e,t){var r,n=t,i=e.x,o=e.y,a=-1/0;do{if(o<=n.y&&o>=n.next.y&&n.next.y!==n.y){var s=n.x+(o-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(s<=i&&s>a){if(a=s,s===i){if(o===n.y)return n;if(o===n.next.y)return n.next}r=n.x=n.x&&n.x>=l&&i!==n.x&<(or.x||n.x===r.x&&st(r,n)))&&(r=n,f=u)),n=n.next}while(n!==c);return r}(e,t),t){var r=gt(t,e);$e(t,t.next),$e(r,r.next)}}function st(e,t){return ft(e.prev,e,t.prev)<0&&ft(t.next,e,e.next)<0}function ut(e,t,r,n,i){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-r)*i)|e<<8))|e<<4))|e<<2))|e<<1))|(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-n)*i)|t<<8))|t<<4))|t<<2))|t<<1))<<1}function ct(e){var t=e,r=e;do{(t.x=0&&(e-a)*(n-s)-(r-a)*(t-s)>=0&&(r-a)*(o-s)-(i-a)*(n-s)>=0}function ht(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!function(e,t){var r=e;do{if(r.i!==e.i&&r.next.i!==e.i&&r.i!==t.i&&r.next.i!==t.i&&pt(r,r.next,e,t))return!0;r=r.next}while(r!==e);return!1}(e,t)&&(yt(e,t)&&yt(t,e)&&function(e,t){var r=e,n=!1,i=(e.x+t.x)/2,o=(e.y+t.y)/2;do{r.y>o!=r.next.y>o&&r.next.y!==r.y&&i<(r.next.x-r.x)*(o-r.y)/(r.next.y-r.y)+r.x&&(n=!n),r=r.next}while(r!==e);return n}(e,t)&&(ft(e.prev,e,t.prev)||ft(e,t.prev,t))||dt(e,t)&&ft(e.prev,e,e.next)>0&&ft(t.prev,t,t.next)>0)}function ft(e,t,r){return(t.y-e.y)*(r.x-t.x)-(t.x-e.x)*(r.y-t.y)}function dt(e,t){return e.x===t.x&&e.y===t.y}function pt(e,t,r,n){var i=mt(ft(e,t,r)),o=mt(ft(e,t,n)),a=mt(ft(r,n,e)),s=mt(ft(r,n,t));return i!==o&&a!==s||!(0!==i||!vt(e,r,t))||!(0!==o||!vt(e,n,t))||!(0!==a||!vt(r,e,n))||!(0!==s||!vt(r,t,n))}function vt(e,t,r){return t.x<=Math.max(e.x,r.x)&&t.x>=Math.min(e.x,r.x)&&t.y<=Math.max(e.y,r.y)&&t.y>=Math.min(e.y,r.y)}function mt(e){return e>0?1:e<0?-1:0}function yt(e,t){return ft(e.prev,e,e.next)<0?ft(e,t,e.next)>=0&&ft(e,e.prev,t)>=0:ft(e,t,e.prev)<0||ft(e,e.next,t)<0}function gt(e,t){var r=new bt(e.i,e.x,e.y),n=new bt(t.i,t.x,t.y),i=e.next,o=t.prev;return e.next=t,t.prev=e,r.next=i,i.prev=r,n.next=r,r.prev=n,o.next=n,n.prev=o,n}function xt(e,t,r,n){var i=new bt(e,t,r);return n?(i.next=n.next,i.prev=n,n.next.prev=i,n.next=i):(i.prev=i,i.next=i),i}function wt(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function bt(e,t,r){this.i=e,this.x=t,this.y=r,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function Mt(e,t,r,n){for(var i=0,o=t,a=r-n;oe.length)&&(t=e.length);for(var r=0,n=new Array(t);r0&&(n+=e[i-1].length,r.holes.push(n))}return r};var At=k.vec2(),St=k.vec3(),Ot=k.vec3(),Lt=k.vec3();function Pt(e){var t=e.data,r=e.xktModel,n=e.stats,i=void 0===n?{}:n,o=e.log;return new Promise((function(e,n){if(t)if("CityJSON"===t.type)if(r){var a=t.transform?function(e,t){for(var r=[],n=t.scale||k.vec3([1,1,1]),i=t.translate||k.vec3([0,0,0]),o=0,a=0;o0){for(var c=[],l=0,h=t.geometry.length;l0){var x=y[g[0]];if(void 0!==x.value)d=m[x.value];else{var w=x.values;if(w){p=[];for(var b=0,M=w.length;b0&&(n.createEntity({entityId:r,meshIds:c}),e.stats.numObjects++)}}function jt(e,t,r,n){switch(t.type){case"MultiPoint":case"MultiLineString":case"GeometryInstance":break;case"MultiSurface":case"CompositeSurface":Gt(e,r,t.boundaries,n);break;case"Solid":for(var i=t.boundaries,o=0;o0&&l.push(c.length);var p=Dt(e,s[d],h,f);c.push.apply(c,It(p))}if(3===c.length)f.indices.push(c[0]),f.indices.push(c[1]),f.indices.push(c[2]);else if(c.length>3){for(var v=[],m=0;m0&&s.push(a.length);var c=Dt(e,t[o][u],r,n);a.push.apply(a,It(c))}if(3===a.length)n.indices.push(a[0]),n.indices.push(a[1]),n.indices.push(a[2]);else if(a.length>3){for(var l=[],h=0;h0)for(var u=0;u0){var x=g||k.createUUID();for(o.entities[x]&&e.error("Two or more glTF nodes found with same 'name' attribute: '"+g+"'");!x||o.entities[x];)x="entity-"+e.nextId++;if(e.metaModelCorrections){var w=e.metaModelCorrections.eachChildRoot[x];if(w){var b=e.metaModelCorrections.eachRootStats[w.id];b.countChildren++,b.countChildren>=b.numChildren&&(o.createEntity({entityId:w.id,meshIds:qt}),e.stats.numObjects++,qt.length=0)}else e.metaModelCorrections.metaObjectsMap[x]&&(o.createEntity({entityId:x,meshIds:qt}),e.stats.numObjects++,qt.length=0)}else o.createEntity({entityId:x,meshIds:qt}),e.stats.numObjects++,qt.length=0}}var Yt="undefined"!=typeof atob?atob:function(e){return Buffer.from(e,"base64").toString("binary")},Qt={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},Wt={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16};function Jt(e){var t=e.data,r=e.xktModel,n=e.metaModelData,i=e.includeNormals,o=e.reuseGeometries,a=e.getAttachment,s=e.stats,u=void 0===s?{}:s,c=e.log;return c&&c("Using parser: parseGLTFJSONIntoXKTModel"),new Promise((function(e,s){if(t)if(r){u.sourceFormat="glTF",u.schemaVersion="2.0",u.title="",u.author="",u.created="",u.numTriangles=0,u.numVertices=0,u.numNormals=0,u.numObjects=0,u.numGeometries=0;var l={gltf:t,metaModelCorrections:n?Ht(n):null,getAttachment:a||function(){throw new Error("You must define getAttachment() method to convert glTF with external resources")},log:c||function(e){},xktModel:r,includeNormals:i,createXKTGeometryIds:{},nextMeshId:0,reuseGeometries:!1!==o,stats:u};l.log("Parsing normals: ".concat(l.includeNormals?"enabled":"disabled")),function(e){var t=e.gltf.buffers;return t?Promise.all(t.map((function(t){return function(e,t){return new Promise((function(r,n){if(t._arrayBuffer)return t._buffer=t._arrayBuffer,void r(t);var i=t.uri;i?function(e,t){return new Promise((function(r,n){var i=t.match(/^data:(.*?)(;base64)?,(.*)$/);if(i){var o=!!i[2],a=i[3];a=decodeURIComponent(a),o&&(a=Yt(a));for(var s=new ArrayBuffer(a.length),u=new Uint8Array(s),c=0;c0)for(var l=0;l0){var G=j;if(e.metaModelCorrections){var _=e.metaModelCorrections.eachChildRoot[G];if(_){var D=e.metaModelCorrections.eachRootStats[_.id];D.countChildren++,D.countChildren>=D.numChildren&&(a.createEntity({entityId:_.id,meshIds:tr}),e.stats.numObjects++,tr=[])}else e.metaModelCorrections.metaObjectsMap[G]&&(a.createEntity({entityId:G,meshIds:tr}),e.stats.numObjects++,tr=[])}else a.createEntity({entityId:G,meshIds:tr}),e.stats.numObjects++,tr=[]}}function nr(e){if(!e.attributes)return"empty";var t=e.mode,r=(e.material,e.indices),n=e.attributes.POSITION,i=e.attributes.NORMAL,o=e.attributes.COLOR_0,a=e.attributes.TEXCOORD_0;return[t,null!=r?r:"-",null!=n?n:"-",null!=i?i:"-",null!=o?o:"-",null!=a?a:"-"].join(";")}function ir(e,t,r){var n=t.attributes;if(n){switch(t.mode){case 0:r.primitive="points";break;case 1:case 2:case 3:r.primitive="lines";break;case 4:default:r.primitive="triangles";break;case 5:console.log("TRIANGLE_STRIP"),r.primitive="triangles";break;case 6:console.log("TRIANGLE_FAN"),r.primitive="triangles"}var i=e.gltf.accessors,o=t.indices;if(null!=o){var a=i[o];r.indices=or(e,a)}var s=n.POSITION;if(null!=s){var u=i[s];r.positions=or(e,u)}var c=n.NORMAL;if(null!=c){var l=i[c];r.normals=or(e,l)}var h=n.COLOR_0;if(null!=h){var f=i[h];r.colors=or(e,f)}}}function or(e,t){var r=e.gltf.bufferViews[t.bufferView],n=Wt[t.type],i=Qt[t.componentType],o=i.BYTES_PER_ELEMENT*n;if(t.byteStride&&t.byteStride!==o)throw new Error("interleaved buffer!");return new i(r._buffer,t.byteOffset||0,t.count*n)}function ar(e){var t=e.WebIFC,r=e.data,n=e.xktModel,i=e.autoNormals,o=void 0===i||i,a=e.includeTypes,s=e.excludeTypes,u=e.wasmPath,c=e.stats,l=void 0===c?{}:c,h=e.log;return h&&h("Using parser: parseIFCIntoXKTModel"),new Promise((function(e,i){if(r)if(n)if(u){var c=new t.IfcAPI;u&&c.SetWasmPath(u),c.Init().then((function(){var i=new Uint8Array(r),u=c.OpenModel(i);l.sourceFormat="IFC",l.schemaVersion="",l.title="",l.author="",l.created="",l.numMetaObjects=0,l.numPropertySets=0,l.numObjects=0,l.numGeometries=0,l.numTriangles=0,l.numVertices=0;var f={WebIFC:t,modelID:u,ifcAPI:c,xktModel:n,autoNormals:o,log:h||function(e){},nextId:0,stats:l};if(a){f.includeTypes={};for(var d=0,p=a.length;d0){for(var d=o.Name.value,p=[],v=0,m=f.length;v0?L:null}),M++}}o&&o("Converted meta objects: "+M),e()}))}function vr(e){var t=e.data,r=e.xktModel,n=e.littleEndian,i=void 0===n||n,o=e.stats,a=e.log;return a&&a("Using parser: parsePCDIntoXKTModel"),new Promise((function(e,n){var s=function(e){if("undefined"!=typeof TextDecoder)return(new TextDecoder).decode(e);for(var t="",r=0,n=e.length;r>16&255,g=m>>8&255,x=m>>0&255;l.push(y,g,x,255)}else l.push(255),l.push(255),l.push(255)}if("binary_compressed"===u.data)for(var w=new Uint32Array(t.slice(u.headerLen,u.headerLen+8)),b=w[0],M=w[1],I=function(e,t){var r,n,i,o=e.length,a=new Uint8Array(t),s=0,u=0;do{if((r=e[s++])<32){if(u+ ++r>t)throw new Error("Output buffer is not large enough");if(s+r>o)throw new Error("Invalid compressed data");do{a[u++]=e[s++]}while(--r)}else{if(n=r>>5,i=u-((31&r)<<8)-1,s>=o)throw new Error("Invalid compressed data");if(7===n&&(n+=e[s++],s>=o))throw new Error("Invalid compressed data");if(i-=e[s++],u+n+2>t)throw new Error("Output buffer is not large enough");if(i<0)throw new Error("Invalid compressed data");if(i>=u)throw new Error("Invalid compressed data");do{a[u++]=a[i++]}while(2+--n)}}while(s0?l:null}),r.createMesh({meshId:"pointsMesh",geometryId:"pointsGeometry"}),r.createEntity({entityId:"geometries",meshIds:["pointsMesh"]}),a&&(a("Converted drawable objects: 1"),a("Converted geometries: 1"),a("Converted vertices: "+c.length/3)),o&&(o.sourceFormat="PCD",o.schemaVersion="",o.title="",o.author="",o.created="",o.numObjects=1,o.numGeometries=1,o.numVertices=c.length/3),e()}))}const mr=require("@loaders.gl/ply");function yr(e){return yr="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},yr(e)}function gr(){gr=function(){return e};var e={},t=Object.prototype,r=t.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},i=n.iterator||"@@iterator",o=n.asyncIterator||"@@asyncIterator",a=n.toStringTag||"@@toStringTag";function s(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{s({},"")}catch(e){s=function(e,t,r){return e[t]=r}}function u(e,t,r,n){var i=t&&t.prototype instanceof h?t:h,o=Object.create(i.prototype),a=new I(n||[]);return o._invoke=function(e,t,r){var n="suspendedStart";return function(i,o){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===i)throw o;return{value:void 0,done:!0}}for(r.method=i,r.arg=o;;){var a=r.delegate;if(a){var s=w(a,r);if(s){if(s===l)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var u=c(e,t,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===l)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}(e,r,a),o}function c(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}e.wrap=u;var l={};function h(){}function f(){}function d(){}var p={};s(p,i,(function(){return this}));var v=Object.getPrototypeOf,m=v&&v(v(T([])));m&&m!==t&&r.call(m,i)&&(p=m);var y=d.prototype=h.prototype=Object.create(p);function g(e){["next","throw","return"].forEach((function(t){s(e,t,(function(e){return this._invoke(t,e)}))}))}function x(e,t){function n(i,o,a,s){var u=c(e[i],e,o);if("throw"!==u.type){var l=u.arg,h=l.value;return h&&"object"==yr(h)&&r.call(h,"__await")?t.resolve(h.__await).then((function(e){n("next",e,a,s)}),(function(e){n("throw",e,a,s)})):t.resolve(h).then((function(e){l.value=e,a(l)}),(function(e){return n("throw",e,a,s)}))}s(u.arg)}var i;this._invoke=function(e,r){function o(){return new t((function(t,i){n(e,r,t,i)}))}return i=i?i.then(o,o):o()}}function w(e,t){var r=e.iterator[t.method];if(void 0===r){if(t.delegate=null,"throw"===t.method){if(e.iterator.return&&(t.method="return",t.arg=void 0,w(e,t),"throw"===t.method))return l;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var n=c(r,e.iterator,t.arg);if("throw"===n.type)return t.method="throw",t.arg=n.arg,t.delegate=null,l;var i=n.arg;return i?i.done?(t[e.resultName]=i.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,l):i:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,l)}function b(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function M(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function I(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(b,this),this.reset(!0)}function T(e){if(e){var t=e[i];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,o=function t(){for(;++n=0;--i){var o=this.tryEntries[i],a=o.completion;if("root"===o.tryLoc)return n("end");if(o.tryLoc<=this.prev){var s=r.call(o,"catchLoc"),u=r.call(o,"finallyLoc");if(s&&u){if(this.prev=0;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&r.call(i,"finallyLoc")&&this.prev=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),M(r),l}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var i=n.arg;M(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:T(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=void 0),l}},e}function xr(e,t,r,n,i,o,a){try{var s=e[o](a),u=s.value}catch(e){return void r(e)}s.done?t(u):Promise.resolve(u).then(n,i)}function wr(e){return function(){var t=this,r=arguments;return new Promise((function(n,i){var o=e.apply(t,r);function a(e){xr(o,n,i,a,s,"next",e)}function s(e){xr(o,n,i,a,s,"throw",e)}a(void 0)}))}}function br(e){return Mr.apply(this,arguments)}function Mr(){return(Mr=wr(gr().mark((function e(t){var r,n,i,o,a,s,u,c,l,h,f;return gr().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=t.data,n=t.xktModel,i=t.stats,(o=t.log)&&o("Using parser: parsePLYIntoXKTModel"),r){e.next=4;break}throw"Argument expected: data";case 4:if(n){e.next=6;break}throw"Argument expected: xktModel";case 6:return e.prev=6,e.next=9,(0,Ee.parse)(r,mr.PLYLoader);case 9:a=e.sent,e.next=16;break;case 12:return e.prev=12,e.t0=e.catch(6),o&&o("Error: "+e.t0),e.abrupt("return");case 16:if(s=a.attributes,u=!!s.COLOR_0){for(c=u?s.COLOR_0.value:null,l=[],h=0,f=c.length;h=0;--i){var o=this.tryEntries[i],a=o.completion;if("root"===o.tryLoc)return n("end");if(o.tryLoc<=this.prev){var s=r.call(o,"catchLoc"),u=r.call(o,"finallyLoc");if(s&&u){if(this.prev=0;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&r.call(i,"finallyLoc")&&this.prev=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),M(r),l}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var i=n.arg;M(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:T(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=void 0),l}},e}function Ar(e,t,r,n,i,o,a){try{var s=e[o](a),u=s.value}catch(e){return void r(e)}s.done?t(u):Promise.resolve(u).then(n,i)}function Sr(e){return function(){var t=this,r=arguments;return new Promise((function(n,i){var o=e.apply(t,r);function a(e){Ar(o,n,i,a,s,"next",e)}function s(e){Ar(o,n,i,a,s,"throw",e)}a(void 0)}))}}function Or(e){return Lr.apply(this,arguments)}function Lr(){return(Lr=Sr(Tr().mark((function e(t){var r,n,i,o,a,s,u,c;return Tr().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=t.data,n=t.splitMeshes,i=t.autoNormals,o=t.smoothNormals,a=t.smoothNormalsAngleThreshold,s=t.xktModel,u=t.stats,(c=t.log)&&c("Using parser: parseSTLIntoXKTModel"),e.abrupt("return",new Promise((function(e,t){if(r)if(s){var l=k.createUUID(),h=s.createMetaObject({metaObjectId:l,metaObjectType:"Model",metaObjectName:"Model"}),f={data:r,splitMeshes:n,autoNormals:i,smoothNormals:o,smoothNormalsAngleThreshold:a,xktModel:s,rootMetaObject:h,nextId:0,log:c||function(e){},stats:{numObjects:0,numGeometries:0,numTriangles:0,numVertices:0}},d=Dr(r);Pr(d)?Er(f,d):jr(f,kr(r)),u&&(u.sourceFormat="STL",u.schemaVersion="",u.title="",u.author="",u.created="",u.numMetaObjects=2,u.numPropertySets=0,u.numObjects=1,u.numGeometries=1,u.numTriangles=f.stats.numTriangles,u.numVertices=f.stats.numVertices),e()}else t("Argument expected: xktModel");else t("Argument expected: data")})));case 3:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function Pr(e){var t=new DataView(e);if(84+50*t.getUint32(80,!0)===t.byteLength)return!0;for(var r=[115,111,108,105,100],n=0;n<5;n++)if(r[n]!==t.getUint8(n,!1))return!0;return!1}function Er(e,t){for(var r,n,i,o,a,s,u,c=new DataView(t),l=c.getUint32(80,!0),h=!1,f=null,d=null,p=null,v=!1,m=0;m<70;m++)1129270351===c.getUint32(m,!1)&&82===c.getUint8(m+4)&&61===c.getUint8(m+5)&&(h=!0,o=[],a=c.getUint8(m+6)/255,s=c.getUint8(m+7)/255,u=c.getUint8(m+8)/255,c.getUint8(m+9));for(var y=[],g=[],x=e.splitMeshes,w=0;w>5&31)/31,i=(A>>10&31)/31):(r=a,n=s,i=u),(x&&r!==f||n!==d||i!==p)&&(null!==f&&(v=!0),f=r,d=n,p=i)}for(var S=1;S<=3;S++){var O=b+12*S;y.push(c.getFloat32(O,!0)),y.push(c.getFloat32(O+4,!0)),y.push(c.getFloat32(O+8,!0)),e.autoNormals||g.push(M,I,T),h&&o.push(r,n,i,1)}x&&v&&(_r(e,y,g,o),y=[],g=[],o=o?[]:null,v=!1)}y.length>0&&_r(e,y,g,o)}function jr(e,t){for(var r,n,i,o,a,s,u,c=/facet([\s\S]*?)endfacet/g,l=0,h=/[\s]+([+-]?(?:\d+.\d+|\d+.|\d+|.\d+)(?:[eE][+-]?\d+)?)/.source,f=new RegExp("vertex"+h+h+h,"g"),d=new RegExp("normal"+h+h+h,"g"),p=[],v=[];null!==(o=c.exec(t));){for(a=0,s=0,u=o[0];null!==(o=d.exec(u));)r=parseFloat(o[1]),n=parseFloat(o[2]),i=parseFloat(o[3]),s++;for(;null!==(o=f.exec(u));)p.push(parseFloat(o[1]),parseFloat(o[2]),parseFloat(o[3])),v.push(r,n,i),a++;if(1!==s)return e.log("Error in normal of face "+l),-1;if(3!==a)return e.log("Error in positions of face "+l),-1;l++}_r(e,p,v,null)}var Gr=0;function _r(e,t,r,n){for(var i=new Int32Array(t.length/3),o=0,a=i.length;o0?r:null,n=n&&n.length>0?n:null,!e.autoNormals&&e.smoothNormals&&function(e,t){var r,n,i,o,a,s,u,c,l,h,f,d=(arguments.length>2&&void 0!==arguments[2]?arguments[2]:{}).smoothNormalsAngleThreshold||20,p={},v=[],m={},y=4,g=Math.pow(10,y);for(u=0,l=e.length;u0&&void 0!==arguments[0]?arguments[0]:{},t=e.xSize||1;t<0&&(console.error("negative xSize not allowed - will invert"),t*=-1);var r=e.ySize||1;r<0&&(console.error("negative ySize not allowed - will invert"),r*=-1);var n=e.zSize||1;n<0&&(console.error("negative zSize not allowed - will invert"),n*=-1);var i=e.center,o=i?i[0]:0,a=i?i[1]:0,s=i?i[2]:0,u=-t+o,c=-r+a,l=-n+s,h=t+o,f=r+a,d=n+s;return{primitiveType:"triangles",positions:[h,f,d,u,f,d,u,c,d,h,c,d,h,f,d,h,c,d,h,c,l,h,f,l,h,f,d,h,f,l,u,f,l,u,f,d,u,f,d,u,f,l,u,c,l,u,c,d,u,c,l,h,c,l,h,c,d,u,c,d,h,c,l,u,c,l,u,f,l,h,f,l],normals:[0,0,1,0,0,1,0,0,1,0,0,1,1,0,0,1,0,0,1,0,0,1,0,0,0,1,0,0,1,0,0,1,0,0,1,0,-1,0,0,-1,0,0,-1,0,0,-1,0,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,0,0,-1,0,0,-1,0,0,-1,0,0,-1],uv:[1,0,0,0,0,1,1,1,0,0,0,1,1,1,1,0,1,1,1,0,0,0,0,1,1,0,0,0,0,1,1,1,0,1,1,1,1,0,0,0,0,1,1,1,1,0,0,0],indices:[0,1,2,0,2,3,4,5,6,4,6,7,8,9,10,8,10,11,12,13,14,12,14,15,16,17,18,16,18,19,20,21,22,20,22,23]}}function Fr(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.xSize||1;t<0&&(console.error("negative xSize not allowed - will invert"),t*=-1);var r=e.ySize||1;r<0&&(console.error("negative ySize not allowed - will invert"),r*=-1);var n=e.zSize||1;n<0&&(console.error("negative zSize not allowed - will invert"),n*=-1);var i=e.center,o=i?i[0]:0,a=i?i[1]:0,s=i?i[2]:0,u=-t+o,c=-r+a,l=-n+s,h=t+o,f=r+a,d=n+s;return{primitiveType:"lines",positions:[u,c,l,u,c,d,u,f,l,u,f,d,h,c,l,h,c,d,h,f,l,h,f,d],indices:[0,1,1,3,3,2,2,0,4,5,5,7,7,6,6,4,0,4,1,5,2,6,3,7]}}function Vr(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.radiusTop||1;t<0&&(console.error("negative radiusTop not allowed - will invert"),t*=-1);var r=e.radiusBottom||1;r<0&&(console.error("negative radiusBottom not allowed - will invert"),r*=-1);var n=e.height||1;n<0&&(console.error("negative height not allowed - will invert"),n*=-1);var i=e.radialSegments||32;i<0&&(console.error("negative radialSegments not allowed - will invert"),i*=-1),i<3&&(i=3);var o=e.heightSegments||1;o<0&&(console.error("negative heightSegments not allowed - will invert"),o*=-1),o<1&&(o=1);var a,s,u,c,l,h,f,d,p,v,m,y=!!e.openEnded,g=e.center,x=g?g[0]:0,w=g?g[1]:0,b=g?g[2]:0,M=n/2,I=n/o,T=2*Math.PI/i,A=1/i,S=(t-r)/o,O=[],L=[],P=[],E=[],j=(90-180*Math.atan(n/(r-t))/Math.PI)/90;for(a=0;a<=o;a++)for(l=t-a*S,h=M-a*I,s=0;s<=i;s++)u=Math.sin(s*T),c=Math.cos(s*T),L.push(l*u),L.push(j),L.push(l*c),P.push(s*A),P.push(1*a/o),O.push(l*u+x),O.push(h+w),O.push(l*c+b);for(a=0;a0){for(p=O.length/3,L.push(0),L.push(1),L.push(0),P.push(.5),P.push(.5),O.push(0+x),O.push(M+w),O.push(0+b),s=0;s<=i;s++)u=Math.sin(s*T),c=Math.cos(s*T),v=.5*Math.sin(s*T)+.5,m=.5*Math.cos(s*T)+.5,L.push(t*u),L.push(1),L.push(t*c),P.push(v),P.push(m),O.push(t*u+x),O.push(M+w),O.push(t*c+b);for(s=0;s0){for(p=O.length/3,L.push(0),L.push(-1),L.push(0),P.push(.5),P.push(.5),O.push(0+x),O.push(0-M+w),O.push(0+b),s=0;s<=i;s++)u=Math.sin(s*T),c=Math.cos(s*T),v=.5*Math.sin(s*T)+.5,m=.5*Math.cos(s*T)+.5,L.push(r*u),L.push(-1),L.push(r*c),P.push(v),P.push(m),O.push(r*u+x),O.push(0-M+w),O.push(r*c+b);for(s=0;s0&&void 0!==arguments[0]?arguments[0]:{},t=e.size||1;t<0&&(console.error("negative size not allowed - will invert"),t*=-1);var r=e.divisions||1;r<0&&(console.error("negative divisions not allowed - will invert"),r*=-1),r<1&&(r=1);for(var n=(t=t||10)/(r=r||10),i=t/2,o=[],a=[],s=0,u=0,c=-i;u<=r;u++,c+=n)o.push(-i),o.push(0),o.push(c),o.push(i),o.push(0),o.push(c),o.push(c),o.push(0),o.push(-i),o.push(c),o.push(0),o.push(i),a.push(s++),a.push(s++),a.push(s++),a.push(s++);return{primitiveType:"lines",positions:o,indices:a}}function Br(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.xSize||1;t<0&&(console.error("negative xSize not allowed - will invert"),t*=-1);var r=e.zSize||1;r<0&&(console.error("negative zSize not allowed - will invert"),r*=-1);var n=e.xSegments||1;n<0&&(console.error("negative xSegments not allowed - will invert"),n*=-1),n<1&&(n=1);var i=e.xSegments||1;i<0&&(console.error("negative zSegments not allowed - will invert"),i*=-1),i<1&&(i=1);var o,a,s,u,c,l,h,f=e.center,d=f?f[0]:0,p=f?f[1]:0,v=f?f[2]:0,m=t/2,y=r/2,g=Math.floor(n)||1,x=Math.floor(i)||1,w=g+1,b=x+1,M=t/g,I=r/x,T=new Float32Array(w*b*3),A=new Float32Array(w*b*3),S=new Float32Array(w*b*2),O=0,L=0;for(o=0;o65535?Uint32Array:Uint16Array)(g*x*6);for(o=0;o0&&void 0!==arguments[0]?arguments[0]:{},t=e.lod||1,r=e.center?e.center[0]:0,n=e.center?e.center[1]:0,i=e.center?e.center[2]:0,o=e.radius||1;o<0&&(console.error("negative radius not allowed - will invert"),o*=-1);var a=e.heightSegments||18;a<0&&(console.error("negative heightSegments not allowed - will invert"),a*=-1),(a=Math.floor(t*a))<18&&(a=18);var s=e.widthSegments||18;s<0&&(console.error("negative widthSegments not allowed - will invert"),s*=-1),(s=Math.floor(t*s))<18&&(s=18);var u,c,l,h,f,d,p,v,m,y,g,x,w,b,M=[],I=[],T=[],A=[];for(u=0;u<=a;u++)for(l=u*Math.PI/a,h=Math.sin(l),f=Math.cos(l),c=0;c<=s;c++)d=2*c*Math.PI/s,p=Math.sin(d),v=Math.cos(d)*h,m=f,y=p*h,g=1-c/s,x=u/a,I.push(v),I.push(m),I.push(y),T.push(g),T.push(x),M.push(r+o*v),M.push(n+o*m),M.push(i+o*y);for(u=0;u0&&void 0!==arguments[0]?arguments[0]:{},t=e.radius||1;t<0&&(console.error("negative radius not allowed - will invert"),t*=-1),t*=.5;var r=e.tube||.3;r<0&&(console.error("negative tube not allowed - will invert"),r*=-1);var n=e.radialSegments||32;n<0&&(console.error("negative radialSegments not allowed - will invert"),n*=-1),n<4&&(n=4);var i=e.tubeSegments||24;i<0&&(console.error("negative tubeSegments not allowed - will invert"),i*=-1),i<4&&(i=4);var o=e.arc||2*Math.PI;o<0&&(console.warn("negative arc not allowed - will invert"),o*=-1),o>360&&(o=360);var a,s,u,c,l,h,f,d,p,v,m,y,g=e.center,x=g?g[0]:0,w=g?g[1]:0,b=g?g[2]:0,M=[],I=[],T=[],A=[];for(d=0;d<=i;d++)for(f=0;f<=n;f++)a=f/n*o,s=.785398+d/i*Math.PI*2,x=t*Math.cos(a),w=t*Math.sin(a),u=(t+r*Math.cos(s))*Math.cos(a),c=(t+r*Math.cos(s))*Math.sin(a),l=r*Math.sin(s),M.push(u+x),M.push(c+w),M.push(l+b),T.push(1-f/n),T.push(d/i),h=k.normalizeVec3(k.subVec3([u,c,l],[x,w,b],[]),[]),I.push(h[0]),I.push(h[1]),I.push(h[2]);for(d=1;d<=i;d++)for(f=1;f<=n;f++)p=(n+1)*d+f-1,v=(n+1)*(d-1)+f-1,m=(n+1)*(d-1)+f,y=(n+1)*d+f,A.push(p),A.push(v),A.push(m),A.push(m),A.push(y),A.push(p);return{primitiveType:"triangles",positions:M,normals:I,uv:T,uvs:T,indices:A}}var Rr={" ":{width:16,points:[]},"!":{width:10,points:[[5,21],[5,7],[-1,-1],[5,2],[4,1],[5,0],[6,1],[5,2]]},'"':{width:16,points:[[4,21],[4,14],[-1,-1],[12,21],[12,14]]},"#":{width:21,points:[[11,25],[4,-7],[-1,-1],[17,25],[10,-7],[-1,-1],[4,12],[18,12],[-1,-1],[3,6],[17,6]]},$:{width:20,points:[[8,25],[8,-4],[-1,-1],[12,25],[12,-4],[-1,-1],[17,18],[15,20],[12,21],[8,21],[5,20],[3,18],[3,16],[4,14],[5,13],[7,12],[13,10],[15,9],[16,8],[17,6],[17,3],[15,1],[12,0],[8,0],[5,1],[3,3]]},"%":{width:24,points:[[21,21],[3,0],[-1,-1],[8,21],[10,19],[10,17],[9,15],[7,14],[5,14],[3,16],[3,18],[4,20],[6,21],[8,21],[10,20],[13,19],[16,19],[19,20],[21,21],[-1,-1],[17,7],[15,6],[14,4],[14,2],[16,0],[18,0],[20,1],[21,3],[21,5],[19,7],[17,7]]},"&":{width:26,points:[[23,12],[23,13],[22,14],[21,14],[20,13],[19,11],[17,6],[15,3],[13,1],[11,0],[7,0],[5,1],[4,2],[3,4],[3,6],[4,8],[5,9],[12,13],[13,14],[14,16],[14,18],[13,20],[11,21],[9,20],[8,18],[8,16],[9,13],[11,10],[16,3],[18,1],[20,0],[22,0],[23,1],[23,2]]},"'":{width:10,points:[[5,19],[4,20],[5,21],[6,20],[6,18],[5,16],[4,15]]},"(":{width:14,points:[[11,25],[9,23],[7,20],[5,16],[4,11],[4,7],[5,2],[7,-2],[9,-5],[11,-7]]},")":{width:14,points:[[3,25],[5,23],[7,20],[9,16],[10,11],[10,7],[9,2],[7,-2],[5,-5],[3,-7]]},"*":{width:16,points:[[8,21],[8,9],[-1,-1],[3,18],[13,12],[-1,-1],[13,18],[3,12]]},"+":{width:26,points:[[13,18],[13,0],[-1,-1],[4,9],[22,9]]},",":{width:10,points:[[6,1],[5,0],[4,1],[5,2],[6,1],[6,-1],[5,-3],[4,-4]]},"-":{width:26,points:[[4,9],[22,9]]},".":{width:10,points:[[5,2],[4,1],[5,0],[6,1],[5,2]]},"/":{width:22,points:[[20,25],[2,-7]]},0:{width:20,points:[[9,21],[6,20],[4,17],[3,12],[3,9],[4,4],[6,1],[9,0],[11,0],[14,1],[16,4],[17,9],[17,12],[16,17],[14,20],[11,21],[9,21]]},1:{width:20,points:[[6,17],[8,18],[11,21],[11,0]]},2:{width:20,points:[[4,16],[4,17],[5,19],[6,20],[8,21],[12,21],[14,20],[15,19],[16,17],[16,15],[15,13],[13,10],[3,0],[17,0]]},3:{width:20,points:[[5,21],[16,21],[10,13],[13,13],[15,12],[16,11],[17,8],[17,6],[16,3],[14,1],[11,0],[8,0],[5,1],[4,2],[3,4]]},4:{width:20,points:[[13,21],[3,7],[18,7],[-1,-1],[13,21],[13,0]]},5:{width:20,points:[[15,21],[5,21],[4,12],[5,13],[8,14],[11,14],[14,13],[16,11],[17,8],[17,6],[16,3],[14,1],[11,0],[8,0],[5,1],[4,2],[3,4]]},6:{width:20,points:[[16,18],[15,20],[12,21],[10,21],[7,20],[5,17],[4,12],[4,7],[5,3],[7,1],[10,0],[11,0],[14,1],[16,3],[17,6],[17,7],[16,10],[14,12],[11,13],[10,13],[7,12],[5,10],[4,7]]},7:{width:20,points:[[17,21],[7,0],[-1,-1],[3,21],[17,21]]},8:{width:20,points:[[8,21],[5,20],[4,18],[4,16],[5,14],[7,13],[11,12],[14,11],[16,9],[17,7],[17,4],[16,2],[15,1],[12,0],[8,0],[5,1],[4,2],[3,4],[3,7],[4,9],[6,11],[9,12],[13,13],[15,14],[16,16],[16,18],[15,20],[12,21],[8,21]]},9:{width:20,points:[[16,14],[15,11],[13,9],[10,8],[9,8],[6,9],[4,11],[3,14],[3,15],[4,18],[6,20],[9,21],[10,21],[13,20],[15,18],[16,14],[16,9],[15,4],[13,1],[10,0],[8,0],[5,1],[4,3]]},":":{width:10,points:[[5,14],[4,13],[5,12],[6,13],[5,14],[-1,-1],[5,2],[4,1],[5,0],[6,1],[5,2]]},";":{width:10,points:[[5,14],[4,13],[5,12],[6,13],[5,14],[-1,-1],[6,1],[5,0],[4,1],[5,2],[6,1],[6,-1],[5,-3],[4,-4]]},"<":{width:24,points:[[20,18],[4,9],[20,0]]},"=":{width:26,points:[[4,12],[22,12],[-1,-1],[4,6],[22,6]]},">":{width:24,points:[[4,18],[20,9],[4,0]]},"?":{width:18,points:[[3,16],[3,17],[4,19],[5,20],[7,21],[11,21],[13,20],[14,19],[15,17],[15,15],[14,13],[13,12],[9,10],[9,7],[-1,-1],[9,2],[8,1],[9,0],[10,1],[9,2]]},"@":{width:27,points:[[18,13],[17,15],[15,16],[12,16],[10,15],[9,14],[8,11],[8,8],[9,6],[11,5],[14,5],[16,6],[17,8],[-1,-1],[12,16],[10,14],[9,11],[9,8],[10,6],[11,5],[-1,-1],[18,16],[17,8],[17,6],[19,5],[21,5],[23,7],[24,10],[24,12],[23,15],[22,17],[20,19],[18,20],[15,21],[12,21],[9,20],[7,19],[5,17],[4,15],[3,12],[3,9],[4,6],[5,4],[7,2],[9,1],[12,0],[15,0],[18,1],[20,2],[21,3],[-1,-1],[19,16],[18,8],[18,6],[19,5]]},A:{width:18,points:[[9,21],[1,0],[-1,-1],[9,21],[17,0],[-1,-1],[4,7],[14,7]]},B:{width:21,points:[[4,21],[4,0],[-1,-1],[4,21],[13,21],[16,20],[17,19],[18,17],[18,15],[17,13],[16,12],[13,11],[-1,-1],[4,11],[13,11],[16,10],[17,9],[18,7],[18,4],[17,2],[16,1],[13,0],[4,0]]},C:{width:21,points:[[18,16],[17,18],[15,20],[13,21],[9,21],[7,20],[5,18],[4,16],[3,13],[3,8],[4,5],[5,3],[7,1],[9,0],[13,0],[15,1],[17,3],[18,5]]},D:{width:21,points:[[4,21],[4,0],[-1,-1],[4,21],[11,21],[14,20],[16,18],[17,16],[18,13],[18,8],[17,5],[16,3],[14,1],[11,0],[4,0]]},E:{width:19,points:[[4,21],[4,0],[-1,-1],[4,21],[17,21],[-1,-1],[4,11],[12,11],[-1,-1],[4,0],[17,0]]},F:{width:18,points:[[4,21],[4,0],[-1,-1],[4,21],[17,21],[-1,-1],[4,11],[12,11]]},G:{width:21,points:[[18,16],[17,18],[15,20],[13,21],[9,21],[7,20],[5,18],[4,16],[3,13],[3,8],[4,5],[5,3],[7,1],[9,0],[13,0],[15,1],[17,3],[18,5],[18,8],[-1,-1],[13,8],[18,8]]},H:{width:22,points:[[4,21],[4,0],[-1,-1],[18,21],[18,0],[-1,-1],[4,11],[18,11]]},I:{width:8,points:[[4,21],[4,0]]},J:{width:16,points:[[12,21],[12,5],[11,2],[10,1],[8,0],[6,0],[4,1],[3,2],[2,5],[2,7]]},K:{width:21,points:[[4,21],[4,0],[-1,-1],[18,21],[4,7],[-1,-1],[9,12],[18,0]]},L:{width:17,points:[[4,21],[4,0],[-1,-1],[4,0],[16,0]]},M:{width:24,points:[[4,21],[4,0],[-1,-1],[4,21],[12,0],[-1,-1],[20,21],[12,0],[-1,-1],[20,21],[20,0]]},N:{width:22,points:[[4,21],[4,0],[-1,-1],[4,21],[18,0],[-1,-1],[18,21],[18,0]]},O:{width:22,points:[[9,21],[7,20],[5,18],[4,16],[3,13],[3,8],[4,5],[5,3],[7,1],[9,0],[13,0],[15,1],[17,3],[18,5],[19,8],[19,13],[18,16],[17,18],[15,20],[13,21],[9,21]]},P:{width:21,points:[[4,21],[4,0],[-1,-1],[4,21],[13,21],[16,20],[17,19],[18,17],[18,14],[17,12],[16,11],[13,10],[4,10]]},Q:{width:22,points:[[9,21],[7,20],[5,18],[4,16],[3,13],[3,8],[4,5],[5,3],[7,1],[9,0],[13,0],[15,1],[17,3],[18,5],[19,8],[19,13],[18,16],[17,18],[15,20],[13,21],[9,21],[-1,-1],[12,4],[18,-2]]},R:{width:21,points:[[4,21],[4,0],[-1,-1],[4,21],[13,21],[16,20],[17,19],[18,17],[18,15],[17,13],[16,12],[13,11],[4,11],[-1,-1],[11,11],[18,0]]},S:{width:20,points:[[17,18],[15,20],[12,21],[8,21],[5,20],[3,18],[3,16],[4,14],[5,13],[7,12],[13,10],[15,9],[16,8],[17,6],[17,3],[15,1],[12,0],[8,0],[5,1],[3,3]]},T:{width:16,points:[[8,21],[8,0],[-1,-1],[1,21],[15,21]]},U:{width:22,points:[[4,21],[4,6],[5,3],[7,1],[10,0],[12,0],[15,1],[17,3],[18,6],[18,21]]},V:{width:18,points:[[1,21],[9,0],[-1,-1],[17,21],[9,0]]},W:{width:24,points:[[2,21],[7,0],[-1,-1],[12,21],[7,0],[-1,-1],[12,21],[17,0],[-1,-1],[22,21],[17,0]]},X:{width:20,points:[[3,21],[17,0],[-1,-1],[17,21],[3,0]]},Y:{width:18,points:[[1,21],[9,11],[9,0],[-1,-1],[17,21],[9,11]]},Z:{width:20,points:[[17,21],[3,0],[-1,-1],[3,21],[17,21],[-1,-1],[3,0],[17,0]]},"[":{width:14,points:[[4,25],[4,-7],[-1,-1],[5,25],[5,-7],[-1,-1],[4,25],[11,25],[-1,-1],[4,-7],[11,-7]]},"\\":{width:14,points:[[0,21],[14,-3]]},"]":{width:14,points:[[9,25],[9,-7],[-1,-1],[10,25],[10,-7],[-1,-1],[3,25],[10,25],[-1,-1],[3,-7],[10,-7]]},"^":{width:16,points:[[6,15],[8,18],[10,15],[-1,-1],[3,12],[8,17],[13,12],[-1,-1],[8,17],[8,0]]},_:{width:16,points:[[0,-2],[16,-2]]},"`":{width:10,points:[[6,21],[5,20],[4,18],[4,16],[5,15],[6,16],[5,17]]},a:{width:19,points:[[15,14],[15,0],[-1,-1],[15,11],[13,13],[11,14],[8,14],[6,13],[4,11],[3,8],[3,6],[4,3],[6,1],[8,0],[11,0],[13,1],[15,3]]},b:{width:19,points:[[4,21],[4,0],[-1,-1],[4,11],[6,13],[8,14],[11,14],[13,13],[15,11],[16,8],[16,6],[15,3],[13,1],[11,0],[8,0],[6,1],[4,3]]},c:{width:18,points:[[15,11],[13,13],[11,14],[8,14],[6,13],[4,11],[3,8],[3,6],[4,3],[6,1],[8,0],[11,0],[13,1],[15,3]]},d:{width:19,points:[[15,21],[15,0],[-1,-1],[15,11],[13,13],[11,14],[8,14],[6,13],[4,11],[3,8],[3,6],[4,3],[6,1],[8,0],[11,0],[13,1],[15,3]]},e:{width:18,points:[[3,8],[15,8],[15,10],[14,12],[13,13],[11,14],[8,14],[6,13],[4,11],[3,8],[3,6],[4,3],[6,1],[8,0],[11,0],[13,1],[15,3]]},f:{width:12,points:[[10,21],[8,21],[6,20],[5,17],[5,0],[-1,-1],[2,14],[9,14]]},g:{width:19,points:[[15,14],[15,-2],[14,-5],[13,-6],[11,-7],[8,-7],[6,-6],[-1,-1],[15,11],[13,13],[11,14],[8,14],[6,13],[4,11],[3,8],[3,6],[4,3],[6,1],[8,0],[11,0],[13,1],[15,3]]},h:{width:19,points:[[4,21],[4,0],[-1,-1],[4,10],[7,13],[9,14],[12,14],[14,13],[15,10],[15,0]]},i:{width:8,points:[[3,21],[4,20],[5,21],[4,22],[3,21],[-1,-1],[4,14],[4,0]]},j:{width:10,points:[[5,21],[6,20],[7,21],[6,22],[5,21],[-1,-1],[6,14],[6,-3],[5,-6],[3,-7],[1,-7]]},k:{width:17,points:[[4,21],[4,0],[-1,-1],[14,14],[4,4],[-1,-1],[8,8],[15,0]]},l:{width:8,points:[[4,21],[4,0]]},m:{width:30,points:[[4,14],[4,0],[-1,-1],[4,10],[7,13],[9,14],[12,14],[14,13],[15,10],[15,0],[-1,-1],[15,10],[18,13],[20,14],[23,14],[25,13],[26,10],[26,0]]},n:{width:19,points:[[4,14],[4,0],[-1,-1],[4,10],[7,13],[9,14],[12,14],[14,13],[15,10],[15,0]]},o:{width:19,points:[[8,14],[6,13],[4,11],[3,8],[3,6],[4,3],[6,1],[8,0],[11,0],[13,1],[15,3],[16,6],[16,8],[15,11],[13,13],[11,14],[8,14]]},p:{width:19,points:[[4,14],[4,-7],[-1,-1],[4,11],[6,13],[8,14],[11,14],[13,13],[15,11],[16,8],[16,6],[15,3],[13,1],[11,0],[8,0],[6,1],[4,3]]},q:{width:19,points:[[15,14],[15,-7],[-1,-1],[15,11],[13,13],[11,14],[8,14],[6,13],[4,11],[3,8],[3,6],[4,3],[6,1],[8,0],[11,0],[13,1],[15,3]]},r:{width:13,points:[[4,14],[4,0],[-1,-1],[4,8],[5,11],[7,13],[9,14],[12,14]]},s:{width:17,points:[[14,11],[13,13],[10,14],[7,14],[4,13],[3,11],[4,9],[6,8],[11,7],[13,6],[14,4],[14,3],[13,1],[10,0],[7,0],[4,1],[3,3]]},t:{width:12,points:[[5,21],[5,4],[6,1],[8,0],[10,0],[-1,-1],[2,14],[9,14]]},u:{width:19,points:[[4,14],[4,4],[5,1],[7,0],[10,0],[12,1],[15,4],[-1,-1],[15,14],[15,0]]},v:{width:16,points:[[2,14],[8,0],[-1,-1],[14,14],[8,0]]},w:{width:22,points:[[3,14],[7,0],[-1,-1],[11,14],[7,0],[-1,-1],[11,14],[15,0],[-1,-1],[19,14],[15,0]]},x:{width:17,points:[[3,14],[14,0],[-1,-1],[14,14],[3,0]]},y:{width:16,points:[[2,14],[8,0],[-1,-1],[14,14],[8,0],[6,-4],[4,-6],[2,-7],[1,-7]]},z:{width:17,points:[[14,14],[3,0],[-1,-1],[3,14],[14,14],[-1,-1],[3,0],[14,0]]},"{":{width:14,points:[[9,25],[7,24],[6,23],[5,21],[5,19],[6,17],[7,16],[8,14],[8,12],[6,10],[-1,-1],[7,24],[6,22],[6,20],[7,18],[8,17],[9,15],[9,13],[8,11],[4,9],[8,7],[9,5],[9,3],[8,1],[7,0],[6,-2],[6,-4],[7,-6],[-1,-1],[6,8],[8,6],[8,4],[7,2],[6,1],[5,-1],[5,-3],[6,-5],[7,-6],[9,-7]]},"|":{width:8,points:[[4,25],[4,-7]]},"}":{width:14,points:[[5,25],[7,24],[8,23],[9,21],[9,19],[8,17],[7,16],[6,14],[6,12],[8,10],[-1,-1],[7,24],[8,22],[8,20],[7,18],[6,17],[5,15],[5,13],[6,11],[10,9],[6,7],[5,5],[5,3],[6,1],[7,0],[8,-2],[8,-4],[7,-6],[-1,-1],[8,8],[6,6],[6,4],[7,2],[8,1],[9,-1],[9,-3],[8,-5],[7,-6],[5,-7]]},"~":{width:24,points:[[3,6],[3,8],[4,11],[6,12],[8,12],[10,11],[14,8],[16,7],[18,7],[20,8],[21,10],[-1,-1],[3,8],[4,10],[6,11],[8,11],[10,10],[14,7],[16,6],[18,6],[20,7],[21,10],[21,12]]}};function Xr(){for(var e,t,r,n,i,o,a,s,u,c=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},l=c.origin||[0,0,0],h=l[0],f=l[1],d=l[2],p=c.size||1,v=[],m=[],y=(""+c.text).trim(),g=(y||"").split("\n"),x=0,w=0,b=.04,M=0;M=0;--i){var o=this.tryEntries[i],a=o.completion;if("root"===o.tryLoc)return n("end");if(o.tryLoc<=this.prev){var s=r.call(o,"catchLoc"),u=r.call(o,"finallyLoc");if(s&&u){if(this.prev=0;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&r.call(i,"finallyLoc")&&this.prev=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),M(r),l}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var i=n.arg;M(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:T(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=void 0),l}},e}function Yr(e,t,r,n,i,o,a){try{var s=e[o](a),u=s.value}catch(e){return void r(e)}s.done?t(u):Promise.resolve(u).then(n,i)}var Qr=r(231);function Wr(e){var t=e.WebIFC,r=e.source,n=e.sourceData,i=e.sourceFormat,o=e.metaModelSource,a=e.metaModelData,s=e.output,u=e.outputXKTModel,c=e.outputXKT,l=e.includeTypes,h=e.excludeTypes,d=e.reuseGeometries,p=void 0===d||d,v=e.minTileSize,m=void 0===v?200:v,y=e.stats,g=void 0===y?{}:y,x=e.outputStats,w=e.rotateX,b=void 0!==w&&w,M=e.includeTextures,I=void 0===M||M,T=e.includeNormals,A=void 0===T||T,S=e.log,O=void 0===S?function(e){}:S;return g.sourceFormat="",g.schemaVersion="",g.title="",g.author="",g.created="",g.numMetaObjects=0,g.numPropertySets=0,g.numTriangles=0,g.numVertices=0,g.numNormals=0,g.numUVs=0,g.numTextures=0,g.numTextureSets=0,g.numObjects=0,g.numGeometries=0,g.sourceSize=0,g.xktSize=0,g.texturesSize=0,g.xktVersion="",g.compressionRatio=0,g.conversionTime=0,g.aabb=null,g.minTileSize=m||200,new Promise((function(e,d){var v=O;if(O=function(e){v("[convert2xkt] ".concat(e))},r||n)if(i||!n)if(s||u||c){r&&O("Reading input file: "+r);var y=new Date,w=i||r.split(".").pop();if(!n)try{n=Qr.readFileSync(r)}catch(e){return void d(e)}var M=n.byteLength;if(O("Input file size: "+(M/1e3).toFixed(2)+" kB"),!a&&o){O("Reading input metadata file: "+o);try{var T=Qr.readFileSync(o);a=JSON.parse(T)}catch(e){return void d(e)}}!1===p&&O("Geometry reuse is disabled");var S=new Xe({minTileSize:m});a?pr({metaModelData:a,xktModel:S}).then((function(){L()}),(function(e){d(e)})):L()}else d("Argument expected: output, outputXKTModel or outputXKT");else d("Argument expected: sourceFormat is required with sourceData");else d("Argument expected: source or sourceData");function L(){switch(w){case"json":P(Pt,{data:JSON.parse(n),xktModel:S,stats:g,rotateX:b,log:O});break;case"glb":case"gltf":var e=r?Jr(r):"",i="glb"!==w&&!I;P(i?Jt:Bt,{data:i?JSON.parse(n):n,reuseGeometries:p,includeTextures:I,includeNormals:A,metaModelData:a,xktModel:S,getAttachment:(o=Zr().mark((function t(r){var n;return Zr().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return O("Reading attachment file: ".concat(n=e+r)),t.abrupt("return",Kr(Qr.readFileSync(n)));case 3:case"end":return t.stop()}}),t)})),s=function(){var e=this,t=arguments;return new Promise((function(r,n){var i=o.apply(e,t);function a(e){Yr(i,r,n,a,s,"next",e)}function s(e){Yr(i,r,n,a,s,"throw",e)}a(void 0)}))},function(e){return s.apply(this,arguments)}),stats:g,log:O});break;case"ifc":P(ar,{WebIFC:t,data:n,xktModel:S,wasmPath:"./",includeTypes:l,excludeTypes:h,stats:g,log:O});break;case"laz":P(lr,{data:n,xktModel:S,stats:g,rotateX:b,log:O});break;case"las":P(lr,{data:n,xktModel:S,stats:g,log:O});break;case"pcd":P(vr,{data:n,xktModel:S,stats:g,log:O});break;case"ply":P(br,{data:n,xktModel:S,stats:g,log:O});break;case"stl":P(Or,{data:n,xktModel:S,stats:g,log:O});break;default:return void d('Error: unsupported source format: "'.concat(w,'".'))}var o,s}function P(t,r){t(r).then((function(){S.createDefaultMetaObjects(),O("Input file parsed OK. Building XKT document..."),S.finalize().then((function(){O("XKT document built OK. Writing to XKT file...");var t=Ze(S,g),r=Buffer.from(t),n=t.byteLength;if(g.sourceSize=(M/1e3).toFixed(2),g.xktSize=(n/1e3).toFixed(2),g.xktVersion=f.xktVersion,g.compressionRatio=(M/n).toFixed(2),g.conversionTime=((new Date-y)/1e3).toFixed(2),g.aabb=S.aabb,O("Converted to: XKT v".concat(g.xktVersion)),l&&O("Include types: "+(l||"(include all)")),h&&O("Exclude types: "+(h||"(exclude none)")),O("XKT size: "+g.xktSize+" kB"),O("XKT textures size: "+(g.texturesSize/1e3).toFixed(2)+"kB"),O("Compression ratio: "+g.compressionRatio),O("Conversion time: "+g.conversionTime+" s"),O("Converted metaobjects: "+g.numMetaObjects),O("Converted property sets: "+g.numPropertySets),O("Converted drawable objects: "+g.numObjects),O("Converted geometries: "+g.numGeometries),O("Converted textures: "+g.numTextures),O("Converted textureSets: "+g.numTextureSets),O("Converted triangles: "+g.numTriangles),O("Converted vertices: "+g.numVertices),O("Converted UVs: "+g.numUVs),O("Converted normals: "+g.numNormals),O("minTileSize: "+g.minTileSize),s){var i=Jr(s).trim();""===i||Qr.existsSync(i)||Qr.mkdirSync(i,{recursive:!0}),O("Writing XKT file: "+s),Qr.writeFileSync(s,r)}u&&u(S),c&&c(r),x&&x(g),e()}))}),(function(e){d(e)}))}}))}function Jr(e){var t=e.lastIndexOf("/");return 0!==t?e.substring(0,t+1):""}(0,e.installFilePolyfills)()})(),n})())); //# sourceMappingURL=xeokit-convert.cjs.js.map \ No newline at end of file diff --git a/dist/xeokit-convert.es.js b/dist/xeokit-convert.es.js index 46167a6..b332717 100644 --- a/dist/xeokit-convert.es.js +++ b/dist/xeokit-convert.es.js @@ -17273,28 +17273,13 @@ function getModelData(xktModel, stats) { data.eachTextureSetTextures[eachTextureSetTexturesIndex++] = textureSet.occlusionTexture ? textureSet.occlusionTexture.textureIndex : -1; // Occlusion map } - // Meshes - - for (let meshIndex = 0, matricesIndex = 0, eachMeshMaterialAttributesIndex = 0; meshIndex < numMeshes; meshIndex++) { - const mesh = meshesList [meshIndex]; - if (mesh.geometry.numInstances > 1) { - data.matrices.set(mesh.matrix, matricesIndex); - data.eachMeshMatricesPortion [meshIndex] = matricesIndex; - matricesIndex += 16; - } - data.eachMeshTextureSet[meshIndex] = mesh.textureSet ? mesh.textureSet.textureSetIndex : -1; - data.eachMeshMaterialAttributes[eachMeshMaterialAttributesIndex++] = (mesh.color[0] * 255); // Color RGB - data.eachMeshMaterialAttributes[eachMeshMaterialAttributesIndex++] = (mesh.color[1] * 255); - data.eachMeshMaterialAttributes[eachMeshMaterialAttributesIndex++] = (mesh.color[2] * 255); - data.eachMeshMaterialAttributes[eachMeshMaterialAttributesIndex++] = (mesh.opacity * 255); // Opacity - data.eachMeshMaterialAttributes[eachMeshMaterialAttributesIndex++] = (mesh.metallic * 255); // Metallic - data.eachMeshMaterialAttributes[eachMeshMaterialAttributesIndex++] = (mesh.roughness * 255); // Roughness - } - - // Entities, geometry instances, and tiles + // Tiles -> Entities -> Meshes let entityIndex = 0; let countEntityMeshesPortion = 0; + let eachMeshMaterialAttributesIndex = 0; + let matricesIndex = 0; + let meshIndex= 0; for (let tileIndex = 0; tileIndex < numTiles; tileIndex++) { @@ -17323,6 +17308,23 @@ function getModelData(xktModel, stats) { const geometryIndex = geometry.geometryIndex; data.eachMeshGeometriesPortion [countEntityMeshesPortion + k] = geometryIndex; + + if (mesh.geometry.numInstances > 1) { + data.matrices.set(mesh.matrix, matricesIndex); + data.eachMeshMatricesPortion [meshIndex] = matricesIndex; + matricesIndex += 16; + } + + data.eachMeshTextureSet[meshIndex] = mesh.textureSet ? mesh.textureSet.textureSetIndex : -1; + + data.eachMeshMaterialAttributes[eachMeshMaterialAttributesIndex++] = (mesh.color[0] * 255); // Color RGB + data.eachMeshMaterialAttributes[eachMeshMaterialAttributesIndex++] = (mesh.color[1] * 255); + data.eachMeshMaterialAttributes[eachMeshMaterialAttributesIndex++] = (mesh.color[2] * 255); + data.eachMeshMaterialAttributes[eachMeshMaterialAttributesIndex++] = (mesh.opacity * 255); // Opacity + data.eachMeshMaterialAttributes[eachMeshMaterialAttributesIndex++] = (mesh.metallic * 255); // Metallic + data.eachMeshMaterialAttributes[eachMeshMaterialAttributesIndex++] = (mesh.roughness * 255); // Roughness + + meshIndex++; } data.eachEntityId [entityIndex] = entity.entityId;