zincjs 2.1.1 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/build/zinc.js CHANGED
@@ -1,6 +1,6 @@
1
- (function(b,Ae){typeof exports=="object"&&typeof module<"u"?module.exports=Ae(require("three"),require("three-spritetext"),require("css-element-queries"),require("three/examples/jsm/loaders/GLTFLoader"),require("fflate")):typeof define=="function"&&define.amd?define(["three","three-spritetext","css-element-queries","three/examples/jsm/loaders/GLTFLoader","fflate"],Ae):(b=typeof globalThis<"u"?globalThis:b||self,b.Zinc=Ae(b.THREE,b.SpriteText,b.cssElememtQueries,b.GLTFLoader,b.fflate))})(this,function(b,Ae,ke,Zi,Yi){"use strict";var xn=Object.defineProperty;var bn=(b,Ae,ke)=>Ae in b?xn(b,Ae,{enumerable:!0,configurable:!0,writable:!0,value:ke}):b[Ae]=ke;var D=(b,Ae,ke)=>bn(b,typeof Ae!="symbol"?Ae+"":Ae,ke);function Xi(r){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(r){for(const t in r)if(t!=="default"){const s=Object.getOwnPropertyDescriptor(r,t);Object.defineProperty(e,t,s.get?s:{enumerable:!0,get:()=>r[t]})}}return e.default=r,Object.freeze(e)}const M=Xi(b),Ki={version:"2.1.1"},Oe=new b.Matrix4,dt=new b.Object3D,He=new b.Vector3,Le=new b.Vector3;function Ve(){this.uuid=b.MathUtils.generateUUID(),this.name="",this.type="Geometry",this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.normals=[],this.uvs=[],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.elementsNeedUpdate=!1,this.verticesNeedUpdate=!1,this.uvsNeedUpdate=!1,this.normalsNeedUpdate=!1,this.colorsNeedUpdate=!1,this.lineDistancesNeedUpdate=!1,this.groupsNeedUpdate=!1,this.morphNormalsReady=!1}Ve.prototype=Object.assign(Object.create(b.EventDispatcher.prototype),{constructor:Ve,isGeometry:!0,applyMatrix4:function(r){const e=new b.Matrix3().getNormalMatrix(r);for(let t=0,s=this.vertices.length;t<s;t++)this.vertices[t].applyMatrix4(r);for(let t=0,s=this.faces.length;t<s;t++){const i=this.faces[t];i.normal.applyMatrix3(e).normalize();for(let n=0,o=i.vertexNormals.length;n<o;n++)i.vertexNormals[n].applyMatrix3(e).normalize()}return this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this.verticesNeedUpdate=!0,this.normalsNeedUpdate=!0,this},rotateX:function(r){return Oe.makeRotationX(r),this.applyMatrix4(Oe),this},rotateY:function(r){return Oe.makeRotationY(r),this.applyMatrix4(Oe),this},rotateZ:function(r){return Oe.makeRotationZ(r),this.applyMatrix4(Oe),this},translate:function(r,e,t){return Oe.makeTranslation(r,e,t),this.applyMatrix4(Oe),this},scale:function(r,e,t){return Oe.makeScale(r,e,t),this.applyMatrix4(Oe),this},lookAt:function(r){return dt.lookAt(r),dt.updateMatrix(),this.applyMatrix4(dt.matrix),this},fromBufferGeometry:function(r){const e=this,t=r.index!==null?r.index:void 0,s=r.attributes;if(s.position===void 0)return console.error("THREE.Geometry.fromBufferGeometry(): Position attribute required for conversion."),this;const i=s.position,n=s.normal,o=s.color,a=s.uv,h=s.uv2;h!==void 0&&(this.faceVertexUvs[1]=[]);for(let l=0;l<i.count;l++)e.vertices.push(new b.Vector3().fromBufferAttribute(i,l)),o!==void 0&&e.colors.push(new b.Color().fromBufferAttribute(o,l));function f(l,d,u,p){const y=o===void 0?[]:[e.colors[l].clone(),e.colors[d].clone(),e.colors[u].clone()],x=n===void 0?[]:[new b.Vector3().fromBufferAttribute(n,l),new b.Vector3().fromBufferAttribute(n,d),new b.Vector3().fromBufferAttribute(n,u)],g=new Ye(l,d,u,x,y,p);e.faces.push(g),a!==void 0&&e.faceVertexUvs[0].push([new b.Vector2().fromBufferAttribute(a,l),new b.Vector2().fromBufferAttribute(a,d),new b.Vector2().fromBufferAttribute(a,u)]),h!==void 0&&e.faceVertexUvs[1].push([new b.Vector2().fromBufferAttribute(h,l),new b.Vector2().fromBufferAttribute(h,d),new b.Vector2().fromBufferAttribute(h,u)])}const c=r.groups;if(c.length>0)for(let l=0;l<c.length;l++){const d=c[l],u=d.start,p=d.count;for(let y=u,x=u+p;y<x;y+=3)t!==void 0?f(t.getX(y),t.getX(y+1),t.getX(y+2),d.materialIndex):f(y,y+1,y+2,d.materialIndex)}else if(t!==void 0)for(let l=0;l<t.count;l+=3)f(t.getX(l),t.getX(l+1),t.getX(l+2));else for(let l=0;l<i.count;l+=3)f(l,l+1,l+2);return this.computeFaceNormals(),r.boundingBox!==null&&(this.boundingBox=r.boundingBox.clone()),r.boundingSphere!==null&&(this.boundingSphere=r.boundingSphere.clone()),this},center:function(){return this.computeBoundingBox(),this.boundingBox.getCenter(He).negate(),this.translate(He.x,He.y,He.z),this},normalize:function(){this.computeBoundingSphere();const r=this.boundingSphere.center,e=this.boundingSphere.radius,t=e===0?1:1/e,s=new b.Matrix4;return s.set(t,0,0,-t*r.x,0,t,0,-t*r.y,0,0,t,-t*r.z,0,0,0,1),this.applyMatrix4(s),this},computeFaceNormals:function(){const r=new b.Vector3,e=new b.Vector3;for(let t=0,s=this.faces.length;t<s;t++){const i=this.faces[t],n=this.vertices[i.a],o=this.vertices[i.b],a=this.vertices[i.c];r.subVectors(a,o),e.subVectors(n,o),r.cross(e),r.normalize(),i.normal.copy(r)}},computeVertexNormals:function(r=!0){const e=new Array(this.vertices.length);for(let t=0,s=this.vertices.length;t<s;t++)e[t]=new b.Vector3;if(r){const t=new b.Vector3,s=new b.Vector3;for(let i=0,n=this.faces.length;i<n;i++){const o=this.faces[i],a=this.vertices[o.a],h=this.vertices[o.b],f=this.vertices[o.c];t.subVectors(f,h),s.subVectors(a,h),t.cross(s),e[o.a].add(t),e[o.b].add(t),e[o.c].add(t)}}else{this.computeFaceNormals();for(let t=0,s=this.faces.length;t<s;t++){const i=this.faces[t];e[i.a].add(i.normal),e[i.b].add(i.normal),e[i.c].add(i.normal)}}for(let t=0,s=this.vertices.length;t<s;t++)e[t].normalize();for(let t=0,s=this.faces.length;t<s;t++){const i=this.faces[t],n=i.vertexNormals;n.length===3?(n[0].copy(e[i.a]),n[1].copy(e[i.b]),n[2].copy(e[i.c])):(n[0]=e[i.a].clone(),n[1]=e[i.b].clone(),n[2]=e[i.c].clone())}return this.faces.length>0&&(this.normalsNeedUpdate=!0),e},computeFlatVertexNormals:function(){this.computeFaceNormals();for(let r=0,e=this.faces.length;r<e;r++){const t=this.faces[r],s=t.vertexNormals;s.length===3?(s[0].copy(t.normal),s[1].copy(t.normal),s[2].copy(t.normal)):(s[0]=t.normal.clone(),s[1]=t.normal.clone(),s[2]=t.normal.clone())}this.faces.length>0&&(this.normalsNeedUpdate=!0)},computeMorphNormals:function(){for(let e=0,t=this.faces.length;e<t;e++){const s=this.faces[e];s.__originalFaceNormal?s.__originalFaceNormal.copy(s.normal):s.__originalFaceNormal=s.normal.clone(),s.__originalVertexNormals||(s.__originalVertexNormals=[]);for(let i=0,n=s.vertexNormals.length;i<n;i++)s.__originalVertexNormals[i]?s.__originalVertexNormals[i].copy(s.vertexNormals[i]):s.__originalVertexNormals[i]=s.vertexNormals[i].clone()}const r=new Ve;r.faces=this.faces;for(let e=0,t=this.morphTargets.length;e<t;e++){if(!this.morphNormals[e]){this.morphNormals[e]={},this.morphNormals[e].faceNormals=[],this.morphNormals[e].vertexNormals=[];const n=this.morphNormals[e].faceNormals,o=this.morphNormals[e].vertexNormals;for(let a=0,h=this.faces.length;a<h;a++){const f=new b.Vector3,c={a:new b.Vector3,b:new b.Vector3,c:new b.Vector3};n.push(f),o.push(c)}}const s=this.morphNormals[e];r.vertices=this.morphTargets[e].vertices,r.computeFaceNormals();let i=r.computeVertexNormals();if(i&&i.length>0){this.morphTargets[e].normals=new Array(this.vertices.length);for(let n=0;n<i.length;n++)this.morphTargets[e].normals[n]=i[n].clone()}for(let n=0,o=this.faces.length;n<o;n++){const a=this.faces[n],h=s.faceNormals[n],f=s.vertexNormals[n];h.copy(a.normal),f.a.copy(a.vertexNormals[0]),f.b.copy(a.vertexNormals[1]),f.c.copy(a.vertexNormals[2])}}for(let e=0,t=this.faces.length;e<t;e++){const s=this.faces[e];s.normal=s.__originalFaceNormal,s.vertexNormals=s.__originalVertexNormals}this.morphNormalsReady=!0},computeBoundingBox:function(){this.boundingBox===null&&(this.boundingBox=new b.Box3),this.boundingBox.setFromPoints(this.vertices)},computeBoundingSphere:function(){this.boundingSphere===null&&(this.boundingSphere=new b.Sphere),this.boundingSphere.setFromPoints(this.vertices)},mergeMorph:function(r,e){const t=this.morphTargets.length,s=this.morphTargets,i=r.morphTargets,n=this.morphColors.length,o=this.morphColors,a=r.morphColors;if(t>0&&t==i.length)for(let h=0,f=s.length;h<f;h++){const c=s[h],l=i[h];for(let d=0,u=l.vertices.length;d<u;d++){const y=l.vertices[d].clone();e!==void 0&&y.applyMatrix4(e),c.vertices.push(y)}if(c.normals&&l.normals)for(let d=0;d<l.normals.length;d=d+3)Le.set(l.normals2[d],l.normals2[d+1],l.normals2[d+2]),e!==void 0&&Le.applyMatrix4(e),c.normals.push(Le.x,Le.y,Le.z)}if(n>0&&n==a.length)for(let h=0,f=o.length;h<f;h++){const c=o[h],l=a[h];for(let d=0,u=l.colors;d<u;d++)c.colors.push(l.colors[d].clone())}},merge:function(r,e,t=0){if(!(r&&r.isGeometry)){console.error("THREE.Geometry.merge(): geometry not an instance of THREE.Geometry.",r);return}let s;const i=this.vertices.length,n=this.vertices,o=r.vertices,a=r.normals,h=this.faces,f=r.faces,c=this.colors,l=r.colors;e!==void 0&&(s=new b.Matrix3().getNormalMatrix(e));for(let d=0,u=o.length;d<u;d++){const y=o[d].clone();e!==void 0&&y.applyMatrix4(e),n.push(y)}for(let d=0;d<a.length;d=d+3)Le.set(a[d],a[d+1],a[d+2]),e!==void 0&&Le.applyMatrix4(e),this.normals.push(Le.x,Le.y,Le.z);for(let d=0,u=l.length;d<u;d++)typeof l[d]=="number"?c.push(l[d]):c.push(l[d].clone());for(let d=0,u=f.length;d<u;d++){const p=f[d];let y,x;const g=p.vertexNormals,v=p.vertexColors,_=new Ye(p.a+i,p.b+i,p.c+i);_.normal.copy(p.normal),s!==void 0&&_.normal.applyMatrix3(s).normalize();for(let I=0,k=g.length;I<k;I++)y=g[I].clone(),s!==void 0&&y.applyMatrix3(s).normalize(),_.vertexNormals.push(y);_.color.copy(p.color);for(let I=0,k=v.length;I<k;I++)x=v[I],_.vertexColors.push(x.clone());_.materialIndex=p.materialIndex+t,h.push(_)}for(let d=0,u=r.faceVertexUvs.length;d<u;d++){const p=r.faceVertexUvs[d];this.faceVertexUvs[d]===void 0&&(this.faceVertexUvs[d]=[]);for(let y=0,x=p.length;y<x;y++){const g=p[y],v=[];for(let _=0,I=g.length;_<I;_++)v.push(g[_].clone());this.faceVertexUvs[d].push(v)}}this.mergeMorph(r,e)},mergeMesh:function(r){if(!(r&&r.isMesh)){console.error("THREE.Geometry.mergeMesh(): mesh not an instance of THREE.Mesh.",r);return}r.matrixAutoUpdate&&r.updateMatrix(),this.merge(r.geometry,r.matrix)},mergeVertices:function(r=4){const e={},t=[],s=[],i=Math.pow(10,r);for(let a=0,h=this.vertices.length;a<h;a++){const f=this.vertices[a],c=Math.round(f.x*i)+"_"+Math.round(f.y*i)+"_"+Math.round(f.z*i);e[c]===void 0?(e[c]=a,t.push(this.vertices[a]),s[a]=t.length-1):s[a]=s[e[c]]}const n=[];for(let a=0,h=this.faces.length;a<h;a++){const f=this.faces[a];f.a=s[f.a],f.b=s[f.b],f.c=s[f.c];const c=[f.a,f.b,f.c];for(let l=0;l<3;l++)if(c[l]===c[(l+1)%3]){n.push(a);break}}for(let a=n.length-1;a>=0;a--){const h=n[a];this.faces.splice(h,1);for(let f=0,c=this.faceVertexUvs.length;f<c;f++)this.faceVertexUvs[f].splice(h,1)}const o=this.vertices.length-t.length;return this.vertices=t,o},setFromPoints:function(r){this.vertices=[];for(let e=0,t=r.length;e<t;e++){const s=r[e];this.vertices.push(new b.Vector3(s.x,s.y,s.z||0))}return this},sortFacesByMaterialIndex:function(){const r=this.faces,e=r.length;for(let a=0;a<e;a++)r[a]._id=a;function t(a,h){return a.materialIndex-h.materialIndex}r.sort(t);const s=this.faceVertexUvs[0],i=this.faceVertexUvs[1];let n,o;s&&s.length===e&&(n=[]),i&&i.length===e&&(o=[]);for(let a=0;a<e;a++){const h=r[a]._id;n&&n.push(s[h]),o&&o.push(i[h])}n&&(this.faceVertexUvs[0]=n),o&&(this.faceVertexUvs[1]=o)},toJSON:function(){const r={metadata:{version:4.5,type:"Geometry",generator:"Geometry.toJSON"}};if(r.uuid=this.uuid,r.type=this.type,this.name!==""&&(r.name=this.name),this.parameters!==void 0){const u=this.parameters;for(const p in u)u[p]!==void 0&&(r[p]=u[p]);return r}const e=[];for(let u=0;u<this.vertices.length;u++){const p=this.vertices[u];e.push(p.x,p.y,p.z)}const t=[],s=[],i={},n=[],o={},a=[],h={};for(let u=0;u<this.faces.length;u++){const p=this.faces[u],y=!0,x=!1,g=this.faceVertexUvs[0][u]!==void 0,v=p.normal.length()>0,_=p.vertexNormals.length>0,I=p.color.r!==1||p.color.g!==1||p.color.b!==1,k=p.vertexColors.length>0;let V=0;if(V=f(V,0,0),V=f(V,1,y),V=f(V,2,x),V=f(V,3,g),V=f(V,4,v),V=f(V,5,_),V=f(V,6,I),V=f(V,7,k),t.push(V),t.push(p.a,p.b,p.c),t.push(p.materialIndex),g){const R=this.faceVertexUvs[0][u];t.push(d(R[0]),d(R[1]),d(R[2]))}if(v&&t.push(c(p.normal)),_){const R=p.vertexNormals;t.push(c(R[0]),c(R[1]),c(R[2]))}if(I&&t.push(l(p.color)),k){const R=p.vertexColors;t.push(l(R[0]),l(R[1]),l(R[2]))}}function f(u,p,y){return y?u|1<<p:u&~(1<<p)}function c(u){const p=u.x.toString()+u.y.toString()+u.z.toString();return i[p]!==void 0||(i[p]=s.length/3,s.push(u.x,u.y,u.z)),i[p]}function l(u){const p=u.r.toString()+u.g.toString()+u.b.toString();return o[p]!==void 0||(o[p]=n.length,n.push(u.getHex())),o[p]}function d(u){const p=u.x.toString()+u.y.toString();return h[p]!==void 0||(h[p]=a.length/2,a.push(u.x,u.y)),h[p]}return r.data={},r.data.vertices=e,r.data.normals=s,n.length>0&&(r.data.colors=n),a.length>0&&(r.data.uvs=[a]),r.data.faces=t,r},clone:function(){return new Ve().copy(this)},copy:function(r){this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.name=r.name;const e=r.vertices;for(let l=0,d=e.length;l<d;l++)this.vertices.push(e[l].clone());const t=r.colors;for(let l=0,d=t.length;l<d;l++)this.colors.push(t[l].clone());const s=r.faces;for(let l=0,d=s.length;l<d;l++)this.faces.push(s[l].clone());for(let l=0,d=r.faceVertexUvs.length;l<d;l++){const u=r.faceVertexUvs[l];this.faceVertexUvs[l]===void 0&&(this.faceVertexUvs[l]=[]);for(let p=0,y=u.length;p<y;p++){const x=u[p],g=[];for(let v=0,_=x.length;v<_;v++){const I=x[v];g.push(I.clone())}this.faceVertexUvs[l].push(g)}}const i=r.morphTargets;for(let l=0,d=i.length;l<d;l++){const u={};if(u.name=i[l].name,i[l].vertices!==void 0){u.vertices=[];for(let p=0,y=i[l].vertices.length;p<y;p++)u.vertices.push(i[l].vertices[p].clone())}if(i[l].normals!==void 0){u.normals=[];for(let p=0,y=i[l].normals.length;p<y;p++)u.normals.push(i[l].normals[p].clone())}this.morphTargets.push(u)}const n=r.morphNormals;for(let l=0,d=n.length;l<d;l++){const u={};if(n[l].vertexNormals!==void 0){u.vertexNormals=[];for(let p=0,y=n[l].vertexNormals.length;p<y;p++){const x=n[l].vertexNormals[p],g={};g.a=x.a.clone(),g.b=x.b.clone(),g.c=x.c.clone(),u.vertexNormals.push(g)}}if(n[l].faceNormals!==void 0){u.faceNormals=[];for(let p=0,y=n[l].faceNormals.length;p<y;p++)u.faceNormals.push(n[l].faceNormals[p].clone())}this.morphNormals.push(u)}const o=r.skinWeights;for(let l=0,d=o.length;l<d;l++)this.skinWeights.push(o[l].clone());const a=r.skinIndices;for(let l=0,d=a.length;l<d;l++)this.skinIndices.push(a[l].clone());const h=r.lineDistances;for(let l=0,d=h.length;l<d;l++)this.lineDistances.push(h[l]);const f=r.boundingBox;f!==null&&(this.boundingBox=f.clone());const c=r.boundingSphere;return c!==null&&(this.boundingSphere=c.clone()),this.elementsNeedUpdate=r.elementsNeedUpdate,this.verticesNeedUpdate=r.verticesNeedUpdate,this.uvsNeedUpdate=r.uvsNeedUpdate,this.normalsNeedUpdate=r.normalsNeedUpdate,this.colorsNeedUpdate=r.colorsNeedUpdate,this.lineDistancesNeedUpdate=r.lineDistancesNeedUpdate,this.groupsNeedUpdate=r.groupsNeedUpdate,this},computeGroups(){const r=[];let e,t,s;const i=this.faces;for(t=0;t<i.length;t++){const n=i[t];n.materialIndex!==s&&(s=n.materialIndex,e!==void 0&&(e.count=t*3-e.start,r.push(e)),e={start:t*3,materialIndex:s})}return e!==void 0&&(e.count=t*3-e.start,r.push(e)),r},toBufferGeometry:function(){const r=new Ji().fromGeometry(this),e=new b.BufferGeometry,t=new Float32Array(r.vertices.length*3);if(e.setAttribute("position",new b.BufferAttribute(t,3).copyVector3sArray(r.vertices)),r.normals.length>0){const s=new Float32Array(r.normals.length*3);e.setAttribute("normal",new b.BufferAttribute(s,3).copyVector3sArray(r.normals))}if(r.colors.length>0){const s=new Float32Array(r.colors.length*3);e.setAttribute("color",new b.BufferAttribute(s,3).copyColorsArray(r.colors))}if(r.uvs.length>0){const s=new Float32Array(r.uvs.length*2);e.setAttribute("uv",new b.BufferAttribute(s,2).copyVector2sArray(r.uvs))}if(r.uvs2.length>0){const s=new Float32Array(r.uvs2.length*2);e.setAttribute("uv2",new b.BufferAttribute(s,2).copyVector2sArray(r.uvs2))}e.groups=r.groups;for(const s in r.morphTargets){const i=[],n=r.morphTargets[s];for(let o=0,a=n.length;o<a;o++){const h=n[o],f=new b.Float32BufferAttribute(h.data.length*3,3);f.name=h.name,i.push(f.copyVector3sArray(h.data))}e.morphAttributes[s]=i}if(r.skinIndices.length>0){const s=new b.Float32BufferAttribute(r.skinIndices.length*4,4);e.setAttribute("skinIndex",s.copyVector4sArray(r.skinIndices))}if(r.skinWeights.length>0){const s=new b.Float32BufferAttribute(r.skinWeights.length*4,4);e.setAttribute("skinWeight",s.copyVector4sArray(r.skinWeights))}return r.boundingSphere!==null&&(e.boundingSphere=r.boundingSphere.clone()),r.boundingBox!==null&&(e.boundingBox=r.boundingBox.clone()),e},toIndexedBufferGeometry:function(){const r=new b.BufferGeometry,e=new Float32Array(this.vertices.length*3);if(r.setAttribute("position",new b.BufferAttribute(e,3).copyVector3sArray(this.vertices)),this.normals.length>0){const t=new Float32Array(this.normals.length);let s=new b.BufferAttribute(t,3).copyArray(this.normals);r.setAttribute("normal",s)}if(this.uvs.length>0&&this.uvs[0].length>0){const t=new Float32Array(this.uvs[0].length*2);r.setAttribute("uv",new b.BufferAttribute(t,2).copyArray(this.uvs[0]))}if(this.uvs.length>1&&this.uvs[1].length>0){const t=new Float32Array(this.uvs[1].length*2);r.setAttribute("uv2",new b.BufferAttribute(t,2).copyArray(this.uvs[1]))}if(this.colors.length>0){const t=[];for(let i=0;i<this.colors.length;i++)t.push(new b.Color(this.colors[i]));const s=new Float32Array(t.length*3);r.setAttribute("color",new b.BufferAttribute(s,3).copyColorsArray(t))}else{const t=new Float32Array(this.vertices.length*3);for(let s=0;s<this.vertices.length*3;s++)t[s]=1;r.setAttribute("color",new b.BufferAttribute(t,3))}if(this.faces.length>0){let t=[],s=[];for(let i=0;i<this.faces.length;i++){s.push(this.faces[i].a,this.faces[i].b,this.faces[i].c);const n=this.faces[i].vertexColors;if(n.length===3)t.push(n[0],n[1],n[2]);else{const o=this.faces[i].color;t.push(o,o,o)}}r.setIndex(s),r.groups=this.computeGroups()}if(this.morphTargets.length>0){const t=[],s=[];for(let i=0,n=this.morphTargets.length;i<n;i++){const o=this.morphTargets[i],a=new b.Float32BufferAttribute(o.vertices.length*3,3);if(a.name=o.name,t.push(a.copyVector3sArray(o.vertices)),o.normals){const h=new b.Float32BufferAttribute(o.normals.length*3,3);h.name=o.name,s.push(h.copyVector3sArray(o.normals))}}r.morphAttributes.position=t,r.morphAttributes.normal=s}if(this.skinIndices.length>0){const t=new b.Float32BufferAttribute(this.skinIndices.length*4,4);r.setAttribute("skinIndex",t.copyVector4sArray(this.skinIndices))}if(this.skinWeights.length>0){const t=new b.Float32BufferAttribute(this.skinWeights.length*4,4);r.setAttribute("skinWeight",t.copyVector4sArray(this.skinWeights))}return this.boundingSphere!==null&&(r.boundingSphere=this.boundingSphere.clone()),this.boundingBox!==null&&(r.boundingBox=this.boundingBox.clone()),r},computeTangents:function(){console.error("THREE.Geometry: .computeTangents() has been removed.")},computeLineDistances:function(){console.error("THREE.Geometry: .computeLineDistances() has been removed. Use THREE.Line.computeLineDistances() instead.")},applyMatrix:function(r){return console.warn("THREE.Geometry: .applyMatrix() has been renamed to .applyMatrix4()."),this.applyMatrix4(r)},dispose:function(){this.dispatchEvent({type:"dispose"})}}),Ve.createBufferGeometryFromObject=function(r){let e=new b.BufferGeometry;const t=r.geometry;if(r.isPoints||r.isLine){const s=new b.Float32BufferAttribute(t.vertices.length*3,3),i=new b.Float32BufferAttribute(t.colors.length*3,3);if(e.setAttribute("position",s.copyVector3sArray(t.vertices)),e.setAttribute("color",i.copyColorsArray(t.colors)),t.lineDistances&&t.lineDistances.length===t.vertices.length){const n=new b.Float32BufferAttribute(t.lineDistances.length,1);e.setAttribute("lineDistance",n.copyArray(t.lineDistances))}t.boundingSphere!==null&&(e.boundingSphere=t.boundingSphere.clone()),t.boundingBox!==null&&(e.boundingBox=t.boundingBox.clone())}else r.isMesh&&(e=t.toBufferGeometry());return e};class Ji{constructor(){this.vertices=[],this.normals=[],this.colors=[],this.uvs=[],this.uvs2=[],this.groups=[],this.morphTargets={},this.skinWeights=[],this.skinIndices=[],this.boundingBox=null,this.boundingSphere=null,this.verticesNeedUpdate=!1,this.normalsNeedUpdate=!1,this.colorsNeedUpdate=!1,this.uvsNeedUpdate=!1,this.groupsNeedUpdate=!1}computeGroups(e){const t=[];let s,i,n;const o=e.faces;for(i=0;i<o.length;i++){const a=o[i];a.materialIndex!==n&&(n=a.materialIndex,s!==void 0&&(s.count=i*3-s.start,t.push(s)),s={start:i*3,materialIndex:n})}s!==void 0&&(s.count=i*3-s.start,t.push(s)),this.groups=t}fromGeometry(e){const t=e.faces,s=e.vertices,i=e.faceVertexUvs,n=i[0]&&i[0].length>0,o=i[1]&&i[1].length>0,a=e.morphTargets,h=a.length;let f;if(h>0){f=[];for(let g=0;g<h;g++)f[g]={name:a[g].name,data:[]};this.morphTargets.position=f}const c=e.morphNormals,l=c.length;let d;if(l>0){d=[];for(let g=0;g<l;g++)d[g]={name:c[g].name,data:[]};this.morphTargets.normal=d}const u=e.skinIndices,p=e.skinWeights,y=u.length===s.length,x=p.length===s.length;s.length>0&&t.length===0&&console.error("THREE.DirectGeometry: Faceless geometries are not supported.");for(let g=0;g<t.length;g++){const v=t[g];this.vertices.push(s[v.a],s[v.b],s[v.c]);const _=v.vertexNormals;if(_.length===3)this.normals.push(_[0],_[1],_[2]);else{const k=v.normal;this.normals.push(k,k,k)}const I=v.vertexColors;if(I.length===3)this.colors.push(I[0],I[1],I[2]);else{const k=v.color;this.colors.push(k,k,k)}if(n===!0){const k=i[0][g];k!==void 0?this.uvs.push(k[0],k[1],k[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv ",g),this.uvs.push(new b.Vector2,new b.Vector2,new b.Vector2))}if(o===!0){const k=i[1][g];k!==void 0?this.uvs2.push(k[0],k[1],k[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv2 ",g),this.uvs2.push(new b.Vector2,new b.Vector2,new b.Vector2))}for(let k=0;k<h;k++){const V=a[k].vertices;f[k].data.push(V[v.a],V[v.b],V[v.c])}for(let k=0;k<l;k++){const V=c[k].vertexNormals[g];d[k].data.push(V.a,V.b,V.c)}y&&this.skinIndices.push(u[v.a],u[v.b],u[v.c]),x&&this.skinWeights.push(p[v.a],p[v.b],p[v.c])}return this.computeGroups(e),this.verticesNeedUpdate=e.verticesNeedUpdate,this.normalsNeedUpdate=e.normalsNeedUpdate,this.colorsNeedUpdate=e.colorsNeedUpdate,this.uvsNeedUpdate=e.uvsNeedUpdate,this.groupsNeedUpdate=e.groupsNeedUpdate,e.boundingSphere!==null&&(this.boundingSphere=e.boundingSphere.clone()),e.boundingBox!==null&&(this.boundingBox=e.boundingBox.clone()),this}}class Ye{constructor(e,t,s,i,n,o=0){this.a=e,this.b=t,this.c=s,this.normal=i&&i.isVector3?i:new b.Vector3,this.vertexNormals=Array.isArray(i)?i:[],this.color=n&&n.isColor?n:new b.Color,this.vertexColors=Array.isArray(n)?n:[],this.materialIndex=o}clone(){return new this.constructor().copy(this)}copy(e){this.a=e.a,this.b=e.b,this.c=e.c,this.normal.copy(e.normal),this.color.copy(e.color),this.materialIndex=e.materialIndex;for(let t=0,s=e.vertexNormals.length;t<s;t++)this.vertexNormals[t]=e.vertexNormals[t].clone();for(let t=0,s=e.vertexColors.length;t<s;t++)this.vertexColors[t]=e.vertexColors[t].clone();return this}}const Qi="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAAAZiS0dEAAAAAAAA+UO7fwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9sHDgwCEMBJZu0AAAAdaVRYdENvbW1lbnQAAAAAAENyZWF0ZWQgd2l0aCBHSU1QZC5lBwAABM5JREFUWMO1V0tPG2cUPZ4Hxh6DazIOrjFNqJs0FIMqWFgWQkatsmvVbtggKlSVRVf5AWz4AWz4AUSKEChll19QJYSXkECuhFxsHjEhxCYm+DWGMZ5HF72DJq4bAzFXurI0M/I5997v3u9cC65vTJVn2lX/xHINQOYSBLTLEuIuCWw4Z3IGAEvf6ASmVHjNzHCXBG4A0AjACsAOwEbO0nsFQBnAGYASAIl+ZRMR7SolMEdsByD09fV5R0ZGgg8ePPjW5/N1iqLYpuu6RZblciKR2I9Go69evnwZnZ+fjwI4IS8AKBIRzeQfJWCANwKwh0KhtrGxsYehUOin1tbW+zzP23ietzY2NnIAoGmaLsuyUiqVyvl8XtrY2NiamZn589mzZxsAUgCOAeQAnFI2tI+VxIjaAeDzoaGh7xYWFuZOTk6OZVk+12uYqqq6JEnn0Wg0OT4+/geAXwGEAdwDIFJQXC1wO4DWR48e/RCPxxclSSroVzRFUbSDg4P848ePFwH8DuAhkWih83TRQWxFOXgAwvDwcOfo6OhvXV1d39tsNtuVBwTDWBwOh1UUxVsMw1hXVlbSdCgNV43uYSvrHg6H24aHh38eHBz85TrgF9FYLHA4HLzH43FvbW2d7u/vG+dANp8FpqIlbd3d3V8Fg8EfBUFw4BONZVmL3+9vHhkZCQL4AoAHgJPK8G+yzC0XDofdoVAo5PP5vkadTBAEtr+/39ff3x8gAp/RPOEqx2qjx+NpvXv3bk9DQ0NDvQgwDIOWlhZrMBj8kgi0UJdxRgYMArzL5XJ7vd57qLPZ7Xamp6fnNgBXtQxcjFuHw+Hyer3t9SYgCAITCAScAJoBNNEY/08GOFVVrfVMv7kMNDntFD1vjIAPrlRN0xjckOm6biFQ3jwNPwDMZrOnqVTqfb3Bi8Wivru7W/VCYkwPlKOjo0IikXh7EwQikYgE4Nw0CfXKDCipVCoTj8df3QABbW1tLUc6oUgkFPMkVACUNjc337148eKvw8PDbJ2jP1taWkoCyNDVXDSECmNSK4qiKNLq6urW8+fPI/UicHx8rD59+jSVy+WOAKSJhKENwFItLtoxk8mwsixzHR0dHe3t7c5PAU+n09rs7OzJkydPYqVSaQfANoDXALIk31S2smU1TWMPDg7K5XKZ7+3t9TudTut1U7+wsFCcmJiIpdPpbQBxADsAknQWymYCOukBHYCuKApisdhpMpnURFEU79y503TVyKenpzOTk5M7e3t7MQKPV0Zv1gNm+awB0MvlshqLxfLb29uyJElWURSbXC4XXyvqxcXFs6mpqeTc3Nzu3t7e3wQcA7BPZ8Cov1pNlJplmQtAG8MwHV6v95tAINA5MDBwPxAIuLu6upr8fr/VAN3c3JQjkcjZ+vp6fnl5+d2bN29SuVzuNYAEpf01CdRChUL+X1VskHACuA3Ay3Fcu9vt7nA6nZ7m5uYWQRCaNE3jVVW15PP580KhIGUymWw2m00DOAJwSP4WwPtq4LX2Ao6USxNlQyS/RcQcdLGwlNIz6vEMAaZpNzCk2Pll94LK/cDYimxERiBwG10sxjgvEZBE0UpE6vxj+0Ct5bTaXthgEhRmja8QWNkkPGsuIpfdjpkK+cZUWTC0KredVmtD/gdlSl6EG4AMvQAAAABJRU5ErkJggg==",$i=Ae.default||Ae;function Ge(r,e){const t=(s,i)=>{try{let n=new URL(s,i).href;if(s&&s.split("?").length<2){const o=i.split("?");o.length===2&&(n=n+"?"+o[1])}return n}catch{console.error(`There is an issue creating the url link with: ${s}.`)}};if(Array.isArray(r)){const s=[];return r.forEach(i=>{s.push(t(i,e))}),s}else return t(r,e)}function Hi(r,e,t,s,i){let n=r.morphTargetInfluences,o;r.geometry&&(o=r.geometry.morphAttributes);let a=!1;if(n&&o&&o.position){s.set(0,0,0),i.set(0,0,0);for(let h=0;h<n.length;h++)n[h]>0&&(a=!0,t.setFromArray(o.position[h].array),s.add(t.min.multiplyScalar(n[h])),i.add(t.max.multiplyScalar(n[h])));a&&e.set(s,i)}a||e.setFromBufferAttribute(r.geometry.attributes.position),r.updateWorldMatrix(!0,!0),e.applyMatrix4(r.matrixWorld)}function Et(r,e,t,s){fetch(r).then(i=>{if(!i.ok)throw new Error(`HTTP error! status: ${i.status}`);return i.text()}).then(i=>{t(i,e)}).catch(i=>{console.error(`Fetch string payload retrieval failed for: ${requestURL}`,i),s(r)})}function es(r,e,t){const s=r.length;let i=0;const n=[];function o(a,h){n[h]=a,i++,i==s&&e(n)}for(let a=0;a<s;a++)Et(r[a],a,o,t)}const ts=(r,e)=>{const t=Math.floor(e/3),s=e%3;let i=0;s==0?i=r[t].r:s==1?i=r[t].g:s==2&&(i=r[t].b);const n=new M.Color(i);return[n.r,n.g,n.b]},Dt=function(r,e){if(e&&r&&r.morphAttributes&&r.morphAttributes.color){const t=r.morphAttributes.color,s=e.morphTargetInfluences,i=s.length;r.deleteAttribute("morphColor0"),r.deleteAttribute("morphColor1");let n=0,o=[];for(let a=0;1>n||a<i;a++)s[a]>0&&(n++,o.push([a,s[a]]));o.length==2?(r.setAttribute("morphColor0",t[o[0][0]]),r.setAttribute("morphColor1",t[o[1][0]])):o.length==1&&(r.setAttribute("morphColor0",t[o[0][0]]),r.setAttribute("morphColor1",t[o[0][0]]))}},et=(r,e)=>{let t;return r instanceof Ve?(e.localTimeEnabled&&!r.morphNormalsReady&&(r.morphNormals==null||r.morphNormals.length==0)&&r.computeMorphNormals(),t=r.toIndexedBufferGeometry(),e.localMorphColour&&is(r,t)):r instanceof M.BufferGeometry&&(t=r.clone()),t.colorsNeedUpdate=!0,t.computeBoundingBox(),t.computeBoundingSphere(),r._video&&(t._video=r._video),t},is=(r,e)=>{if(r&&r.morphColors&&r.morphColors.length>0){let t=[],s=r.morphColors;for(let i=0,n=s.length;i<n;i++){const o=s[i],a=[];for(let f=0;f<o.colors.length*3;f++){let c=ts(o.colors,f);a.push(c[0],c[1],c[2])}const h=new M.Float32BufferAttribute(a,3);h.name=o.name,t.push(h)}e.morphAttributes.color=t}};function kt(r){let e,t,s,i=-1,n=0;for(let f=0;f<r.length;++f){const c=r[f];if(e===void 0&&(e=c.array.constructor),e!==c.array.constructor)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.array must be of consistent array types across matching attributes."),null;if(t===void 0&&(t=c.itemSize),t!==c.itemSize)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes."),null;if(s===void 0&&(s=c.normalized),s!==c.normalized)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes."),null;if(i===-1&&(i=c.gpuType),i!==c.gpuType)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.gpuType must be consistent across matching attributes."),null;n+=c.count*t}const o=new e(n),a=new M.BufferAttribute(o,t,s);let h=0;for(let f=0;f<r.length;++f){const c=r[f];if(c.isInterleavedBufferAttribute){const l=h/t;for(let d=0,u=c.count;d<u;d++)for(let p=0;p<t;p++){const y=c.getComponent(d,p);a.setComponent(d+l,p,y)}}else o.set(c.array,h);h+=c.count*t}return i!==void 0&&(a.gpuType=i),a}const ss=(r,e=!1)=>{const t=r[0].index!==null,s=new Set(Object.keys(r[0].attributes)),i=new Set(Object.keys(r[0].morphAttributes)),n={},o={},a=r[0].morphTargetsRelative,h=new M.BufferGeometry;let f=0;for(let c=0;c<r.length;++c){const l=r[c];let d=0;if(t!==(l.index!==null))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+c+". All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them."),null;for(const u in l.attributes){if(!s.has(u))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+c+'. All geometries must have compatible attributes; make sure "'+u+'" attribute exists among all geometries, or in none of them.'),null;n[u]===void 0&&(n[u]=[]),n[u].push(l.attributes[u]),d++}if(d!==s.size)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+c+". Make sure all geometries have the same number of attributes."),null;if(a!==l.morphTargetsRelative)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+c+". .morphTargetsRelative must be consistent throughout all geometries."),null;for(const u in l.morphAttributes){if(!i.has(u))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+c+". .morphAttributes must be consistent throughout all geometries."),null;o[u]===void 0&&(o[u]=[]),o[u].push(l.morphAttributes[u])}if(e){let u;if(t)u=l.index.count;else if(l.attributes.position!==void 0)u=l.attributes.position.count;else return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+c+". The geometry must have either an index or a position attribute"),null;h.addGroup(f,u,c),f+=u}}if(t){let c=0;const l=[];for(let d=0;d<r.length;++d){const u=r[d].index;for(let p=0;p<u.count;++p)l.push(u.getX(p)+c);c+=r[d].attributes.position.count}h.setIndex(l)}for(const c in n){const l=kt(n[c]);if(!l)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+c+" attribute."),null;h.setAttribute(c,l)}for(const c in o){const l=o[c][0].length;if(l===0)break;h.morphAttributes=h.morphAttributes||{},h.morphAttributes[c]=[];for(let d=0;d<l;++d){const u=[];for(let y=0;y<o[c].length;++y)u.push(o[c][y][d]);const p=kt(u);if(!p)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+c+" morphAttribute."),null;h.morphAttributes[c].push(p)}}return h};function pt(r,e){if(e&&r>=e.length){const t=new M.BufferGeometry,s=new Float32Array(r*3);let i=0;return e.forEach(n=>{s[i++]=n[0],s[i++]=n[1],s[i++]=n[2]}),t.setAttribute("position",new M.BufferAttribute(s,3)),t.setDrawRange(0,e.length),t}}function Vt(){const r=new Image;r.src=Qi;const e=new M.Texture;return e.image=r,e.needsUpdate=!0,e}function mt(r,e,t,s,i,n){const o=new $i(r,e,t,s,i,n);return o.fontFace=s,o.fontSize=i,o.fontWeight=n,o.material.map.generateMipmaps=!1,o.material.map.anisotropy=4,o.material.sizeAttenuation=!1,o.material.alphaTest=.5,o.material.transparent=!0,o.material.depthWrite=!1,o.material.depthTest=!1,o.center.set(.5,-1.2),o.renderOrder=1e4,o}function Rt(r,e,t){if(t){const s=r||"",i=e||"",n=t.lastIndexOf("/");if(n>-1){let o,a;if(o=t.substring(0,n),a=t.substring(n+1),(o==="*"||o==="**"||o.toLowerCase()===s.toLowerCase())&&(a==="*"||a==="**"||a.toLowerCase()===i.toLowerCase()))return!0}else if(s.toLowerCase()===t.toLowerCase()||i.toLowerCase()===t.toLowerCase())return!0}return!1}function ns(r,e,t){const s=r.getAttribute("position"),i=r.getAttribute("normal");if(!s)return;const n=s.itemSize,o=e*n,a=n;let h=!1;const f=(c,l)=>{let d=!1;const u=Array.from(c.array);if(u.length>=o+a){u.splice(o,a),u.concat(new Array(a).fill(0)),d=!0;const p=new Float32Array(u);r.setAttribute(l,new M.BufferAttribute(p,n)),r.getAttribute(l).needsUpdate=!0}return d};return h=f(s,"position"),i&&f(i,"normal"),r.index!==null&&console.warn("Removing vertices from indexed geometry requires index buffer recalculation."),h}const Ft=function(){return function(r){r.vertexShader=r.vertexShader.replace("#include <color_pars_vertex>",["varying vec3 vColor;","attribute vec3 morphColor0;","attribute vec3 morphColor1;"].join(`
2
- `)),r.vertexShader=r.vertexShader.replace("#include <color_vertex>",["vColor.xyz = color.xyz;","#ifdef USE_MORPHTARGETS","vColor = morphColor0 * morphTargetInfluences[ 0 ];","vColor += morphColor1 * morphTargetInfluences[ 1 ];","#endif"].join(`
3
- `))}},Gt=new b.Vector3,zt=new b.Vector3,jt=new b.Matrix4,gt=new b.Ray,tt=new b.Sphere,yt=new b.Vector3,xt=new b.Vector3,qt=new b.Vector3,Wt=new b.Vector3;class Zt extends b.Object3D{constructor(e=new b.BufferGeometry,t=new b.LineBasicMaterial){super(),this.type="Line",this.geometry=e,this.material=t,this.updateMorphTargets()}copy(e){return super.copy(e),this.material=e.material,this.geometry=e.geometry,this}computeLineDistances(){const e=this.geometry;if(e.isBufferGeometry)if(e.index===null){const t=e.attributes.position,s=[0];for(let i=1,n=t.count;i<n;i++)Gt.fromBufferAttribute(t,i-1),zt.fromBufferAttribute(t,i),s[i]=s[i-1],s[i]+=Gt.distanceTo(zt);e.setAttribute("lineDistance",new b.Float32BufferAttribute(s,1))}else console.warn("THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");else e.isGeometry&&console.error("THREE.Line.computeLineDistances() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.");return this}raycast(e,t){const s=this.geometry,i=this.matrixWorld,n=e.params.Line.threshold,o=s.drawRange,a=s.morphAttributes.position;if(s.boundingSphere===null&&s.computeBoundingSphere(),tt.copy(s.boundingSphere),tt.applyMatrix4(i),tt.radius+=n,e.ray.intersectsSphere(tt)===!1)return;jt.copy(i).invert(),gt.copy(e.ray).applyMatrix4(jt);const h=n/((this.scale.x+this.scale.y+this.scale.z)/3),f=h*h,c=new b.Vector3,l=new b.Vector3,d=new b.Vector3,u=new b.Vector3,p=this.isLineSegments?2:1;if(s.isBufferGeometry){const y=s.index,g=s.attributes.position;if(y!==null){const v=Math.max(0,o.start),_=Math.min(y.count,o.start+o.count);for(let I=v,k=_-1;I<k;I+=p){const V=y.getX(I),R=y.getX(I+1);if(Yt(c,l,this,g,a,V,R),gt.distanceSqToSegment(c,l,u,d)>f)continue;u.applyMatrix4(this.matrixWorld);const G=e.ray.origin.distanceTo(u);G<e.near||G>e.far||t.push({distance:G,point:d.clone().applyMatrix4(this.matrixWorld),index:I,face:null,faceIndex:null,object:this})}}else{const v=Math.max(0,o.start),_=Math.min(g.count,o.start+o.count);for(let I=v,k=_-1;I<k;I+=p){if(Yt(c,l,this,g,a,I,I+1),gt.distanceSqToSegment(c,l,u,d)>f)continue;u.applyMatrix4(this.matrixWorld);const R=e.ray.origin.distanceTo(u);R<e.near||R>e.far||t.push({distance:R,point:d.clone().applyMatrix4(this.matrixWorld),index:I,face:null,faceIndex:null,object:this})}}}else s.isGeometry&&console.error("THREE.Line.raycast() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.")}updateMorphTargets(){const e=this.geometry;if(e.isBufferGeometry){const t=e.morphAttributes,s=Object.keys(t);if(s.length>0){const i=t[s[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let n=0,o=i.length;n<o;n++){const a=i[n].name||String(n);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=n}}}}else{const t=e.morphTargets;t!==void 0&&t.length>0&&console.error("THREE.Line.updateMorphTargets() does not support THREE.Geometry. Use THREE.BufferGeometry instead.")}}}function Yt(r,e,t,s,i,n,o){r.fromBufferAttribute(s,n),e.fromBufferAttribute(s,o);var a=t.morphTargetInfluences;if(t.material.morphTargets&&i&&a){yt.set(0,0,0),xt.set(0,0,0);for(var h=0,f=i.length;h<f;h++){var c=a[h],l=i[h];c!==0&&(qt.fromBufferAttribute(l,n),Wt.fromBufferAttribute(l,o),yt.addScaledVector(qt.sub(r),c),xt.addScaledVector(Wt.sub(e),c))}r.add(yt),e.add(xt)}}Zt.prototype.isLine=!0;const Xt=new b.Vector3,Kt=new b.Vector3;class it extends Zt{constructor(e,t){super(e,t),this.type="LineSegments"}computeLineDistances(){const e=this.geometry;if(e.isBufferGeometry)if(e.index===null){const t=e.attributes.position,s=[];for(let i=0,n=t.count;i<n;i+=2)Xt.fromBufferAttribute(t,i),Kt.fromBufferAttribute(t,i+1),s[i]=i===0?0:s[i-1],s[i+1]=s[i]+Xt.distanceTo(Kt);e.setAttribute("lineDistance",new b.Float32BufferAttribute(s,1))}else console.warn("THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.");else e.isGeometry&&console.error("THREE.LineSegments.computeLineDistances() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.");return this}}it.prototype.isLineSegments=!0;const rs=function(r){this.levels=[],this._currentLevel=0,this._renderOrder=1,this._material=void 0,this._secondaryMaterial=void 0,this._loader=void 0,this._parent=r,this.addLevel=(t,s)=>{if(t){const i=Math.abs(s);let n;for(n=0;n<this.levels.length&&!(i<this.levels[n].distance);n++);const o={distance:i,morph:t,loaded:!0,loading:!1,url:""};this.levels.splice(n,0,o),t.renderOrder=this._renderOrder}},this.levelLoaded=(t,s)=>{if(t){const i=Math.abs(s);for(let n=0;n<this.levels.length;n++)if(i===this.levels[n].distance){this._parent.group.add(t),this.levels[n].morph=t,this.levels[n].loaded=!0,this.levels[n].loading=!1;break}this.checkTransparentMesh()}},this.addLevelFromURL=(t,s,i,n,o)=>{this._loader=t;const a=this.calculateDistance(s),h={distance:a,morph:void 0,loaded:!1,loading:!1,url:i,index:n};let f;for(f=0;f<this.levels.length&&!(a<this.levels[f].distance);f++);this.levels.splice(f,0,h),o&&this.loadLevel(f)},this.loadLevel=t=>{const s=this.levels[t];return!s.morph&&!s.loaded&&!s.loading&&(s.loading=!0,this._loader.load(s.url,this.lodLoader(s.distance),void 0,void 0,{index:s.index})),s.morph===void 0},this.calculateDistance=function(t){this._parent.getBoundingBox();const s=this._parent.radius;let i=0;return t==="far"?i=s*4.5:t==="medium"?i=s*2.5:t==="close"&&(i=0),i},this.containsLevels=()=>!!(this.levels&&this.levels.length>1),this.checkTransparentMesh=()=>{const t=this.levels[this._currentLevel];this._material&&(this._material.transparent?(this._secondaryMaterial||(this._secondaryMaterial=this._material.clone(),this._secondaryMaterial.side=M.FrontSide),this._secondaryMaterial.opacity=this._material.opacity,this._secondaryMaterial.emissive&&this._secondaryMaterial.emissive.copy(this._material.emissive),this._secondaryMaterial.needsUpdate=!0,t.secondaryMesh||(t.secondaryMesh=new M.Mesh(t.morph.geometry,this._secondaryMaterial),t.secondaryMesh.renderOrder=t.morph.renderOrder+1,t.secondaryMesh.userData=t.morph.userData,t.secondaryMesh.name=t.morph.name),this._material.side=M.BackSide,this._material.needsUpdate=!0,t.secondaryMesh.parent||(t.morph.add(t.secondaryMesh),this._parent.animationGroup&&this._parent.animationGroup.add(t.secondaryMesh))):(t.secondaryMesh&&(t.morph.remove(t.secondaryMesh),this._parent.animationGroup&&(this._parent.animationGroup.uncache(t.secondaryMesh),this._parent.animationGroup.remove(t.secondaryMesh))),this._material.side=M.DoubleSide,this._material.needsUpdate=!0))},this.dispose=()=>{this.levels.forEach(t=>{t.morph&&t.morph.geometry&&t.morph.geometry.dispose()}),this._material&&this._material.dispose(),this._secondaryMaterial&&this._secondaryMaterial.dispose()},this.getCurrentLevel=()=>this._currentLevel,this.getCurrentMorph=()=>{const t=this.levels[this._currentLevel];return t&&t.morph?t.morph:this._parent.morph},this.lodLoader=function(t){return s=>{const i=this._material,n={localTimeEnabled:this._parent.timeEnabled,localMorphColour:this._parent.morphColour},o=et(s,n);let a;this._parent.isGeometry?a=new M.Mesh(o,i):this._parent.isLines&&(a=new it(o,i)),a.userData=this._parent,a.renderOrder=this._renderOrder,s.dispose(),this.levelLoaded(a,t)}},this.updateMorphColorAttribute=t=>{if(this._material&&(this._material.vertexColors==M.VertexColors||this._material.vertexColors==!0))if(t){const s=this.getCurrentMorph();Dt(s.geometry,s)}else this.levels.forEach(s=>{s.morph&&s.morph.geometry&&Dt(s.morph.geometry,s.morph)})},this.setColour=t=>{this._material.color=t,this._secondaryMaterial&&(this._secondaryMaterial.color=t),e()},this.setFrustumCulled=t=>{this.levels.forEach(s=>{s.morph&&(s.morph.frustumCulled=t),s.secondaryMesh&&(s.secondaryMesh.frustumCulled=t)})},this.setMaterial=t=>{t&&(!this._material||this._material.id!==t.id)&&(this._material=t,this._secondaryMaterial&&this._secondaryMaterial.dispose(),this._secondaryMaterial=t.clone(),this._secondaryMaterial.side=M.FrontSide,this._secondaryMaterial.transparent=!0,this.levels.forEach(s=>{s.morph&&(s.morph.material=this._material,s.morph.geometry&&(s.morph.geometry.colorsNeedUpdate=!0)),s.secondaryMesh&&(s.secondaryMesh.material=this._secondaryMaterial)}))},this.setName=t=>{this.levels.forEach(s=>{s.morph&&(s.morph.name=t),s.secondaryMesh&&(s.secondaryMesh.name=t)})},this.setRenderOrder=t=>{this._renderOrder=t,this.levels.forEach(s=>{s.morph&&(s.morph.renderOrder=t),s.secondaryMesh&&(s.secondaryMesh.renderOrder=t)})},this.setVertexColors=t=>{this._material.vertexColors=t,e(),this._secondaryMaterial&&(this._secondaryMaterial.vertexColors=t)},this.update=(t,s)=>{const i=this.levels;if(i.length>1){const n=t.cameraObject.position.distanceTo(s);let o=-1,a=-1,h,f;for(h=0,f=i.length;h<f&&n>=i[h].distance;h++)i[h].morph?(o>-1&&i[o].morph&&(i[o].morph.visible=!1),o=h,i[h].morph.visible=!0,a=-1):a=h;for(a>-1&&this.loadLevel(a);h<f;h++)i[h].morph&&(o>-1?i[h].morph.visible=!1:(i[h].morph.visible=!0,o=h));this._currentLevel!=o&&(this._currentLevel=o,this.checkTransparentMesh())}},this.toggleMarker=(t,s)=>{this.levels.forEach(i=>{i.morph&&(s?i.morph.add(t):i.morph.remove(t))})};const e=()=>{this.levels.forEach(t=>{t.morph&&t.morph.geometry&&(t.morph.geometry.colorsNeedUpdate=!0)})}},os="data:image/svg+xml,%3c?xml%20version='1.0'%20encoding='UTF-8'%20standalone='no'%20?%3e%3c!DOCTYPE%20svg%20PUBLIC%20'-//W3C//DTD%20SVG%201.1//EN'%20'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'%3e%3csvg%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20version='1.1'%20width='365'%20height='560'%20viewBox='0%200%20365%20560'%20xml:space='preserve'%3e%3cdesc%3eCreated%20with%20Fabric.js%205.2.4%3c/desc%3e%3cdefs%3e%3c/defs%3e%3crect%20x='0'%20y='0'%20width='100%25'%20height='100%25'%20fill='transparent'%3e%3c/rect%3e%3cg%20transform='matrix(0%200%200%200%200%200)'%20id='808ed283-2524-440f-88ae-3bdb47bb5749'%20%3e%3c/g%3e%3cg%20transform='matrix(1%200%200%201%20182.5%20280)'%20id='db30413d-5bff-4b98-ab59-464497ee199e'%20%3e%3crect%20style='stroke:%20none;%20stroke-width:%201;%20stroke-dasharray:%20none;%20stroke-linecap:%20butt;%20stroke-dashoffset:%200;%20stroke-linejoin:%20miter;%20stroke-miterlimit:%204;%20fill:%20rgb(255,255,255);%20fill-rule:%20nonzero;%20opacity:%201;%20visibility:%20hidden;'%20vector-effect='non-scaling-stroke'%20x='-182.5'%20y='-280'%20rx='0'%20ry='0'%20width='365'%20height='560'%20/%3e%3c/g%3e%3cg%20transform='matrix(0%200%200%200%200%2097.5)'%20%3e%3cg%20style=''%20%3e%3c/g%3e%3c/g%3e%3cg%20transform='matrix(0%200%200%200%200%2097.5)'%20%3e%3cg%20style=''%20%3e%3c/g%3e%3c/g%3e%3cg%20transform='matrix(0.99%200%200%200.99%20182.5%20280)'%20%3e%3cg%20style=''%20vector-effect='non-scaling-stroke'%20%3e%3cg%20transform='matrix(1%200%200%201%200%200)'%20%3e%3crect%20style='stroke:%20none;%20stroke-width:%201;%20stroke-dasharray:%20none;%20stroke-linecap:%20butt;%20stroke-dashoffset:%200;%20stroke-linejoin:%20miter;%20stroke-miterlimit:%204;%20fill:%20rgb(255,255,255);%20fill-rule:%20nonzero;%20opacity:%201;%20visibility:%20hidden;'%20vector-effect='non-scaling-stroke'%20x='-540'%20y='-540'%20rx='0'%20ry='0'%20width='1080'%20height='1080'%20/%3e%3c/g%3e%3cg%20transform='matrix(1%200%200%201%200%200)'%20%3e%3cpath%20style='stroke:%20rgb(0,0,0);%20stroke-width:%200;%20stroke-dasharray:%20none;%20stroke-linecap:%20butt;%20stroke-dashoffset:%200;%20stroke-linejoin:%20miter;%20stroke-miterlimit:%204;%20fill:%20rgb(0,89,116);%20fill-rule:%20nonzero;%20opacity:%201;'%20vector-effect='non-scaling-stroke'%20transform='%20translate(-182.9,%20-279.85)'%20d='M%20182.9%20551.7%20C%20182.9%20551.8000000000001%20183.1%20552%20183.1%20552%20C%20183.1%20552%20358.3%20283%20358.3%20194.6%20C%20358.3%2064.5%20269.5%207.900000000000006%20182.9%207.699999999999989%20C%2096.3%207.9%207.5%2064.5%207.5%20194.6%20C%207.5%20283%20182.8%20552%20182.8%20552%20C%20182.8%20552%20182.9%20551.7%20182.9%20551.7%20z%20M%20122.2%20187.2%20C%20122.2%20153.6%20149.4%20126.39999999999999%20183%20126.39999999999999%20C%20216.6%20126.39999999999999%20243.8%20153.6%20243.8%20187.2%20C%20243.8%20220.79999999999998%20216.5%20248%20182.9%20248%20C%20149.4%20248%20122.2%20220.8%20122.2%20187.2%20z'%20stroke-linecap='round'%20/%3e%3c/g%3e%3cg%20transform='matrix(3.82%200%200%203.82%200%20-100.77)'%20%3e%3ccircle%20style='stroke:%20rgb(0,0,0);%20stroke-width:%200;%20stroke-dasharray:%20none;%20stroke-linecap:%20butt;%20stroke-dashoffset:%200;%20stroke-linejoin:%20miter;%20stroke-miterlimit:%204;%20fill:%20rgb(255,255,255);%20fill-rule:%20nonzero;%20opacity:%201;'%20vector-effect='non-scaling-stroke'%20cx='0'%20cy='0'%20r='35'%20/%3e%3c/g%3e%3c/g%3e%3c/g%3e%3c/svg%3e",Jt=new Image(128,128);Jt.src=os;const st=new M.Texture;st.image=Jt,st.needsUpdate=!0;const bt=[.02,.03,1],as=new M.SpriteMaterial({map:st,alphaTest:.5,transparent:!0,depthTest:!1,depthWrite:!1,sizeAttenuation:!1}),Qt=function(r){Object.getPrototypeOf(this)!==Q.prototype&&Object.setPrototypeOf(Qt.prototype,Q.prototype),Q.call(this),this.texture=st;let e,t,s,i,n,o=!0;this.morph=new M.Group,this.group=this.morph,this.parent=r,this.isMarker=!0;let a=!1;this.ndc=new M.Vector3;let h,f,c=()=>{e=new M.Sprite(as),e.center.set(.5,0),this.morph.add(e),this.morph.position.set(0,0,0),this.morph.renderOrder=1e4,e.scale.set(bt[0],bt[1],bt[2]),e.userData=this};this.updateVisual=(l,d)=>{let u=1,p=0;l!==d&&(p=1-(this.ndc.z-l)/(d-l),u=.6+p*.4),this.setSpriteSize(u)},this.updateNDC=l=>(this.ndc.copy(this.morph.position),this.ndc.project(l),this.ndc.z=Math.min(Math.max(this.ndc.z,0),1),this.ndc),this.setPosition=(l,d,u)=>{this.morph.position.set(l,d,u)},this.setSpriteSize=l=>{e.scale.set(.015,.02,1),e.scale.multiplyScalar(l)},this.setUserSprite=()=>{i&&(this.morph.add(i),o&&(this.morph.remove(e),f&&this.morph.remove(f),o=!1))},this.setImageForUserSprite=(l,d)=>{i&&(this.morph.remove(i),i=void 0),t&&t.dispose(),s&&s.dispose(),t=new M.Texture,t.image=l,t.needsUpdate=!0,s=new M.SpriteMaterial({map:t,alphaTest:.5,transparent:!0,depthTest:!1,depthWrite:!1,sizeAttenuation:!1}),d||(d=[.05,.05,1]),i=new M.Sprite(s),i.center.set(.5,0),i.scale.set(d[0],d[1],d[2]),i.userData=this,this.setUserSprite()},this.setDefaultSprite=()=>{o||(o=!0,this.morph.add(e),i&&this.morph.remove(i),f&&this.morph.add(f))},this.loadUserSprite=(l,d)=>{if(l)if(l!==n){n=l;const u=new Image(128,128);u.crossOrigin="anonymous",u.onload=()=>{this.setImageForUserSprite(u,d)},u.src=l}else this.setUserSprite()},this.dispose=()=>{this.morph&&this.morph.clear(),e&&(e.clear(),e=void 0),f&&(f.material.map.dispose(),f.material.dispose(),f=void 0)},this.isEnabled=()=>a,this.setNumber=l=>{(!l||h!=l)&&f&&(this.morph.remove(f),f.material.map.dispose(),f.material.dispose(),f=void 0),!f&&l&&(f=mt(l,.012,"black","Asap",120,700),this.morph.add(f)),h=l},this.getNumber=()=>h||1,this.setVisibility=function(l){l!==this.visible&&(this.visible=l,this.group.visible=l,this.parent.region&&(this.parent.region.pickableUpdateRequired=!0))},this.enable=()=>{a=!0,this.morph.visible=!0,this.visible=!0},this.disable=()=>{a=!1,this.morph.visible=!1,this.visible=!1},c()};let ls=0;const cs=function(){return"pr"+ls++},Q=function(){this.isZincObject=!0,this.geometry=void 0,this.morph=void 0,this.group=new M.Group,this._lod=new rs(this),this.groupName=void 0,this.timeEnabled=!1,this.morphColour=!1,this.inbuildTime=0,this.mixer=void 0,this.animationGroup=void 0,this.duration=6e3,this.clipAction=void 0,this.userData={},this.videoHandler=void 0,this.marker=void 0,this.markerNumber=void 0,this.markerUpdateRequired=!0,this.closestVertexIndex=-1,this.boundingBoxUpdateRequired=!0,this.cachedBoundingBox=new M.Box3,this.anatomicalId=void 0,this.region=void 0,this.animationClip=void 0,this.markerMode="inherited",this.uuid=cs(),this._v1=new M.Vector3,this._v2=new M.Vector3,this._b1=new M.Box3,this.center=new M.Vector3,this.radius=0,this.visible=!0,this.drawRange=-1,this.origColour=void 0,this.origVertexColors=!1,this.isPickable=!0};Q.prototype.setDuration=function(r){this.duration=r,this.clipAction&&this.clipAction.setDuration(this.duration)},Q.prototype.getDuration=function(){return this.duration},Q.prototype.setRegion=function(r){this.region=r},Q.prototype.getRegion=function(){return this.region},Q.prototype.getMorph=function(){const r=this._lod.getCurrentMorph();return r||this.morph},Q.prototype.getGroup=function(){return this.group},Q.prototype.setMorph=function(r){this.morph=r,this.group.add(this.morph);const e=this._lod.calculateDistance("far");this._lod.addLevel(r,e),this._lod.setMaterial(r.material)},Q.prototype.checkTransparentMesh=function(){},Q.prototype.setMesh=function(r,e,t){this.animationGroup=new M.AnimationObjectGroup(r),this.mixer=new M.AnimationMixer(this.animationGroup);const s=r.geometry;if(this.geometry=r.geometry,this.clipAction=void 0,s&&s.morphAttributes){let i=s.morphAttributes.position;i||(i=s.morphAttributes.color?s.morphAttributes.color:s.morphAttributes.normal),i&&(this.animationClip=M.AnimationClip.CreateClipsFromMorphTargetSequences(i,10,!0),this.animationClip&&this.animationClip[0]!=null&&(this.clipAction=this.mixer.clipAction(this.animationClip[0]).setDuration(this.duration),this.clipAction.loop=M.LoopOnce,this.clipAction.clampWhenFinished=!0,this.clipAction.play()))}this.timeEnabled=e,this.morphColour=t,r.userData=this,r.matrixAutoUpdate=!1,this.setMorph(r),this.checkTransparentMesh(),this.timeEnabled?this.setFrustumCulled(!1):this.morphColour&&(s.setAttribute("morphTarget0",s.getAttribute("position")),s.setAttribute("morphTarget1",s.getAttribute("position"))),this.boundingBoxUpdateRequired=!0},Q.prototype.setIsPickable=function(r){this.isPickable!==r&&(this.isPickable=r,this.region&&(this.region.pickableUpdateRequired=!0))},Q.prototype.setAnatomicalId=function(r){this.anatomicalId=r},Q.prototype.setName=function(r){this.groupName=r,this._lod.setName(r)},Q.prototype.getCurrentTime=function(){if(this.clipAction){const r=this.clipAction.time/this.clipAction._clip.duration;return this.duration*r}else return this.inbuildTime},Q.prototype.setMorphTime=function(r){let e=!1;if(this.clipAction){const t=r/this.duration,s=this.clipAction._clip.duration;let i=t*s;i!=this.clipAction.time&&(this.clipAction.time=i,e=!0),e&&this.isTimeVarying()&&this.mixer.update(0)}else{let t=r;r>this.duration?t=this.duration:0>r?t=0:t=r,t!=this.inbuildTime&&(this.inbuildTime=t,e=!0)}e&&(this.boundingBoxUpdateRequired=!0,this._lod.updateMorphColorAttribute(!0),this.timeEnabled&&(this.markerUpdateRequired=!0))},Q.prototype.isTimeVarying=function(){return!!(this.timeEnabled||this.morphColour)},Q.prototype.getVisibility=function(){return this.visible},Q.prototype.setVisibility=function(r){r!==this.visible&&(this.visible=r,this.group.visible=r,this.region&&(this.region.pickableUpdateRequired=!0))},Q.prototype.setAlpha=function(r){const e=this._lod._material;let t=!1;r<1&&(t=!0),e.opacity=r,e.transparent=t,this.checkTransparentMesh()},Q.prototype.setFrustumCulled=function(r){this._lod.setFrustumCulled(r)},Q.prototype.setVertexColors=function(r){this._lod.setVertexColors(r)},Q.prototype.getColour=function(){if(this._lod._material)return this._lod._material.color},Q.prototype.setColour=function(r){this._lod.setColour(r)},Q.prototype.setGreyScale=function(r){if(r){if(!this.origColour&&this._lod._material)return this.origColour=this._lod._material.color,this.origVertexColors=this._lod._material.vertexColors,this._lod.setVertexColors(!1),this._lod.setColour(new M.Color().setHex(12303291)),!0}else if(this.origColour)return this._lod.setColour(this.origColour),this._lod.setVertexColors(this.origVertexColors),this.origColour=void 0,!0;return!1},Q.prototype.getColourHex=function(){if(!this.morphColour&&this._lod._material&&this._lod._material.color)return this._lod._material.color.getHexString()},Q.prototype.setColourHex=function(r){this._lod._material.color.setHex(r),this._lod._secondaryMaterial&&this._lod._secondaryMaterial.color.setHex(r)},Q.prototype.setEmissiveRGB=function(r){this._lod._material&&this._lod._material.emissive&&this._lod._material.emissive.setRGB(...r),this._lod._secondaryMaterial&&this._lod._secondaryMaterial.emissive.setRGB(...r)},Q.prototype.setMaterial=function(r){this._lod.setMaterial(r)},Q.prototype.getClosestVertexIndex=function(){let r=-1;const e=this.getMorph();if(e&&e.geometry){let t=e.geometry.attributes.position;if(t){this._b1.setFromBufferAttribute(t),this._b1.getCenter(this._v1);let s=-1,i=0;for(let n=0;n<t.count;n++)this._v2.fromArray(t.array,n*3),i=this._v2.distanceTo(this._v1),s==-1?s=i:s>i&&(s=i,r=n)}}return r},Q.prototype.getClosestVertex=function(r){let e=new M.Vector3;this.closestVertexIndex==-1&&(this.closestVertexIndex=this.getClosestVertexIndex());const t=this.getMorph();if(t&&t.geometry&&this.closestVertexIndex>=0){let s=t.morphTargetInfluences,i=t.geometry.morphAttributes;if(s&&i&&i.position){let n=!1;for(let o=0;o<s.length;o++)s[o]>0&&(n=!0,this._v1.fromArray(i.position[o].array,this.closestVertexIndex*3),e.add(this._v1.multiplyScalar(s[o])));if(n)return r?e.applyMatrix4(t.matrixWorld):e}else return e.fromArray(t.geometry.attributes.position.array,this.closestVertexIndex*3),r?e.applyMatrix4(t.matrixWorld):e}return this.getBoundingBox(),e.copy(this.center),e},Q.prototype.getBoundingBox=function(){if(this.visible){let r=this._lod.getCurrentMorph();if(r&&r.visible)return this.boundingBoxUpdateRequired&&(Hi(r,this.cachedBoundingBox,this._b1,this._v1,this._v2),this.cachedBoundingBox.getCenter(this.center),this.radius=this.center.distanceTo(this.cachedBoundingBox.max),this.boundingBoxUpdateRequired=!1),this.cachedBoundingBox}},Q.prototype.dispose=function(){this._lod.dispose(),this.animationGroup=void 0,this.mixer=void 0,this.morph=void 0,this.group=void 0,this.clipAction=void 0,this.groupName=void 0},Q.prototype.markerIsRequired=function(r){return!!(this.visible&&(this.markerMode==="on"||r&&r.displayMarkers&&this.markerMode==="inherited"))},Q.prototype.updateMarker=function(r,e){if(r==!1&&this.markerIsRequired(e)){let t=e.ndcToBeUpdated;if(this.groupName){if(this.marker||(this.marker=new Qt(this),this.markerUpdateRequired=!0),this.markerUpdateRequired){let s=this.getClosestVertex(!1);s&&(this.marker.setPosition(s.x,s.y,s.z),this.markerUpdateRequired=!1)}this.marker.isEnabled()||(e.markersList&&!(this.marker.uuid in e.markersList)&&(t=!0,e.markersList[this.marker.uuid]=this.marker),this.marker.enable(),this.group.add(this.marker.morph)),this.marker.setNumber(this.markerNumber),this.markerImgURL?this.marker.loadUserSprite(this.markerImgURL):this.marker.setDefaultSprite(),e&&e.camera&&(t||e.markerCluster.markerUpdateRequired)&&(this.marker.updateNDC(e.camera.cameraObject),e.markerCluster.markerUpdateRequired=!0)}}else this.marker&&this.marker.isEnabled()&&(this.marker.disable(),this.group.remove(this.marker.morph),e.markersList&&this.marker.uuid in e.markersList&&(e.markerCluster.markerUpdateRequired=!0,delete e.markersList[this.marker.uuid])),this.markerUpdateRequired=!0},Q.prototype.processMarkerVisual=function(r,e){this.marker&&this.marker.isEnabled()&&this.marker.updateVisual(r,e)},Q.prototype.initiateMorphColor=function(){this.morphColour==1&&this._lod.updateMorphColorAttribute(!1)},Q.prototype.setRenderOrder=function(r){this._lod.setRenderOrder(r)},Q.prototype.getClosestVertexDOMElementCoords=function(r){if(r&&r.camera){let e=!0;const t=this.getClosestVertex(!0);return t.project(r.camera),t.z=Math.min(Math.max(t.z,0),1),(t.x>1||t.x<-1||t.y>1||t.y<-1)&&(e=!1),r.getZincCameraControls().getRelativeCoordsFromNDC(t.x,t.y,t),{position:t,inView:e}}else return},Q.prototype.setMarkerMode=function(r,e){r!==this.markerMode&&(r==="on"||r==="off"?this.markerMode=r:this.markerMode="inherited",this.region&&(this.region.pickableUpdateRequired=!0)),e&&(this.markerNumber=e.number,this.markerImgURL=e.imgURL)},Q.prototype.render=function(r,e,t,s){if(this.visible&&!(this.timeEnabled&&e)&&this._lod.update(t,this.center),e==!0){if(this.clipAction&&this.isTimeVarying())this.mixer.update(r);else{let i=this.inbuildTime+r;i>this.duration&&(i=i-this.duration),this.inbuildTime=i}this.visible&&r!=0&&(this.boundingBoxUpdateRequired=!0,this.morphColour==1&&this._lod.updateMorphColorAttribute(!0))}this.updateMarker(e,s)},Q.prototype.addLOD=function(r,e,t,s,i){this._lod.addLevelFromURL(r,e,t,s,i)},Q.prototype.addVertices=function(r){let e=this.getMorph(),t;if(!e)t=pt(500,r),this.drawRange=r.length;else if(this.drawRange>-1){const s=e.geometry.getAttribute("position");r.forEach(i=>{s.setXYZ(this.drawRange,i[0],i[1],i[2]),++this.drawRange}),s.needsUpdate=!0,e.geometry.setDrawRange(0,this.drawRange),e.geometry.computeBoundingBox(),e.geometry.computeBoundingSphere(),t=e.geoemtry,this.boundingBoxUpdateRequired=!0}return t},Q.prototype.deleteVertices=function(r){let e=this.getMorph();return e!=null&&e.geometry&&this.drawRange>=r&&ns(e.geometry,r)?(--this.drawRange,e.geometry.setDrawRange(0,this.drawRange),e.geometry.computeBoundingBox(),e.geometry.computeBoundingSphere(),this.boundingBoxUpdateRequired=!0,!0):!1},Q.prototype.setPosition=function(r,e,t){const s=this.getGroup();s&&(s.position.set(r,e,t),s.matrixWorldNeedsUpdate=!0,s.updateMatrix(),s.updateWorldMatrix(!0,!0),this.boundingBoxUpdateRequired=!0)},Q.prototype.loadAdditionalSources=function(r,e){r.load(filename,meshloader(region,colour,opacity,localTimeEnabled,localMorphColour,void 0,void 0,void 0,void 0,finishCallback),this.onProgress(filename),this.onError(finishCallback))},Q.prototype.setScaleAll=function(r){const e=this.getGroup();e&&(e.scale.set(r,r,r),e.updateMatrix(),this.boundingBoxUpdateRequired=!0)};const hs=(r,e,t)=>{let s=et(r,t),i=!1;1>t.opacity&&(i=!0);let n;if(s._video===void 0){const o=t.localTimeEnabled||t.localMorphColour;e?(n=e,n.morphTargets=o,n.morphNormals=t.localTimeEnabled):s instanceof M.BufferGeometry&&s.attributes.color===void 0?n=new M.MeshPhongMaterial({color:t.colour,morphTargets:o,morphNormals:t.localTimeEnabled,transparent:i,opacity:t.opacity,side:M.DoubleSide}):n=new M.MeshPhongMaterial({color:t.colour,morphTargets:o,morphNormals:t.localTimeEnabled,vertexColors:M.VertexColors,transparent:i,opacity:t.opacity,side:M.DoubleSide}),t.localMorphColour&&s.morphAttributes.color&&(n.onBeforeCompile=Ft())}else{let o=s._video.createCanvasVideoTexture();n=new M.MeshBasicMaterial({morphTargets:t.localTimeEnabled,color:new M.Color(1,1,1),transparent:i,opacity:t.opacity,map:o,side:M.DoubleSide}),(void 0).videoHandler=s._video}return new M.Mesh(s,n)},Xe=function(){Q.call(this),this.videoHandler=void 0,this.isGeometry=!0,this.createMesh=(r,e,t)=>{if(this.morph&&this.morph.geometry&&r!=null)return;const s=hs(r,e,t);this.setMesh(s,t.localTimeEnabled,t.localMorphColour)},this.calculateUVs=()=>{this.geometry.computeBoundingBox();const r=this.geometry.boundingBox.max,e=this.geometry.boundingBox.min,t=new M.Vector2(0-e.x,0-e.y),s=new M.Vector2(r.x-e.x,r.y-e.y);this.geometry.faceVertexUvs[0]=[];for(let i=0;i<this.geometry.faces.length;i++){const n=this.geometry.vertices[this.geometry.faces[i].a],o=this.geometry.vertices[this.geometry.faces[i].b],a=this.geometry.vertices[this.geometry.faces[i].c];geometry.faceVertexUvs[0].push([new M.Vector2((n.x+t.x)/s.x,(n.y+t.y)/s.y),new M.Vector2((o.x+t.x)/s.x,(o.y+t.y)/s.y),new M.Vector2((a.x+t.x)/s.x,(a.y+t.y)/s.y)])}geometry.uvsNeedUpdate=!0},this.checkTransparentMesh=function(){this._lod.checkTransparentMesh()},this.setWireframe=r=>{this.morph.material.wireframe=r},this.editVertices=function(r,e){if(r&&r.length){let t=this.getMorph();const s=t.geometry.getAttribute("position");if(!t||0>e)return;{let i=e*3;r.forEach(n=>{s.array[i++]=n[0],s.array[i++]=n[1],s.array[i++]=n[2]}),s.needsUpdate=!0,t.geometry.computeBoundingBox(),t.geometry.computeBoundingSphere(),this.boundingBoxUpdateRequired=!0}}}};Xe.prototype=Object.create(Q.prototype);const $t=Ae.default||Ae,At=function(r,e){let t=r,s,i=500;e?s=new $t(t,.012,e.getStyle()):s=new $t(t,.012),s.fontFace="Asap",s.fontWeight=i,s.material.map.generateMipmaps=!1,s.material.sizeAttenuation=!1,s.center.x=-.05,s.center.y=0;const n=[s.scale.x,s.scale.y];this.getPosition=()=>s?[s.position.x,s.position.y,s.position.z]:[0,0,0],this.setPosition=(o,a,h)=>{s&&s.position.set(o,a,h)},this.setColour=o=>{o&&(s.color=o.getStyle())},this.setScale=o=>{s&&o>0&&s.scale.set(o,o,1)},this.setDepthTest=o=>{o&&o!==s.material.depthTest&&(s.material.depthTest=o)},this.setSize=o=>{o>0&&(s.scale.x=n[0]*o,s.scale.y=n[1]*o)},this.setFontWeight=o=>{o&&o!==i&&(s.fontWeight=o,i=o)},this.setText=o=>{o&&o!==s.text&&(s.text=o,t=o)},this.setVisibility=o=>{s.visible=o},this.dispose=()=>{},this.getSprite=()=>s,this.getString=()=>t},nt=function(r,e,t,s){Q.call(this);let i;e&&(i=e.clone(),i.vertexColors=M.FaceColors);const n=s;this.id=t;let o,a;this.isGlyph=!0;let h=[0,0,0];this.fromMesh=f=>f&&f.isMesh?(this.morph=f.clone(),this.morph.userData=this,this.group.add(this.morph),!0):!1,r&&i&&this.fromMesh(new M.Mesh(r,i)),this.getGlyphset=function(){return n},this.setLabel=f=>{f&&(typeof f=="string"||f instanceof String)&&(a=f,this.morph&&(this.morph.name=f))},this.showLabel=f=>{if(o&&(h=o.getPosition(),this.group.remove(o.getSprite()),o.dispose(),o=void 0),a&&(typeof a=="string"||a instanceof String)){o=new At(a,f),o.setPosition(h[0],h[1],h[2]);const c=o.getSprite();c.material.alphaTest=.5,c.material.transparent=!0,c.material.depthWrite=!1,this.group.add(o.getSprite())}},this.hideLabel=()=>{o&&(h=o.getPosition(),this.group.remove(o.getSprite()),o.dispose(),o=void 0)},this.getLabel=()=>a,this.getMesh=()=>this.morph,this.setTransformation=(f,c,l,d)=>{this.morph&&(this.morph.matrix.elements[0]=c[0],this.morph.matrix.elements[1]=c[1],this.morph.matrix.elements[2]=c[2],this.morph.matrix.elements[3]=0,this.morph.matrix.elements[4]=l[0],this.morph.matrix.elements[5]=l[1],this.morph.matrix.elements[6]=l[2],this.morph.matrix.elements[7]=0,this.morph.matrix.elements[8]=d[0],this.morph.matrix.elements[9]=d[1],this.morph.matrix.elements[10]=d[2],this.morph.matrix.elements[11]=0,this.morph.matrix.elements[12]=f[0],this.morph.matrix.elements[13]=f[1],this.morph.matrix.elements[14]=f[2],this.morph.matrix.elements[15]=1,this.morph.matrixAutoUpdate=!1),h=[...f],o&&o.setPosition(f[0],f[1],f[2])},this.setColour=f=>{o&&o.setColour(f),this.secondaryMesh&&this.secondaryMesh.material&&(this.secondaryMesh.material.color=colour),this.geometry&&(this.geometry.colorsNeedUpdate=!0)},this.dispose=()=>{this.material&&this.material.dispose(),this.morph=void 0}};nt.prototype=Object.create(Q.prototype);function rt(){}rt.Handlers={handlers:[],add:function(r,e){this.handlers.push(r,e)},get:function(r){for(var e=this.handlers,t=0,s=e.length;t<s;t+=2){var i=e[t],n=e[t+1];if(i.test(r))return n}return null}},Object.assign(rt.prototype,{crossOrigin:"anonymous",onLoadStart:function(){},onLoadProgress:function(){},onLoadComplete:function(){},initMaterials:function(r,e,t){for(var s=[],i=0;i<r.length;++i)s[i]=this.createMaterial(r[i],e,t);return s},createMaterial:function(){var r={NoBlending:b.NoBlending,NormalBlending:b.NormalBlending,AdditiveBlending:b.AdditiveBlending,SubtractiveBlending:b.SubtractiveBlending,MultiplyBlending:b.MultiplyBlending,CustomBlending:b.CustomBlending},e=new b.Color,t=new b.TextureLoader,s=new b.MaterialLoader;return function(n,o,a){var h={};function f(u,p,y,x,g){var v=o+u,_=rt.Handlers.get(v),I;_!==null?I=_.load(v):(t.setCrossOrigin(a),I=t.load(v)),p!==void 0&&(I.repeat.fromArray(p),p[0]!==1&&(I.wrapS=b.RepeatWrapping),p[1]!==1&&(I.wrapT=b.RepeatWrapping)),y!==void 0&&I.offset.fromArray(y),x!==void 0&&(x[0]==="repeat"&&(I.wrapS=b.RepeatWrapping),x[0]==="mirror"&&(I.wrapS=b.MirroredRepeatWrapping),x[1]==="repeat"&&(I.wrapT=b.RepeatWrapping),x[1]==="mirror"&&(I.wrapT=b.MirroredRepeatWrapping)),g!==void 0&&(I.anisotropy=g);var k=b.MathUtils.generateUUID();return h[k]=I,k}var c={uuid:b.MathUtils.generateUUID(),type:"MeshLambertMaterial"};for(var l in n){var d=n[l];switch(l){case"DbgColor":case"DbgIndex":case"opticalDensity":case"illumination":break;case"DbgName":c.name=d;break;case"blending":c.blending=r[d];break;case"colorAmbient":case"mapAmbient":console.warn("THREE.Loader.createMaterial:",l,"is no longer supported.");break;case"colorDiffuse":c.color=e.fromArray(d).getHex();break;case"colorSpecular":c.specular=e.fromArray(d).getHex();break;case"colorEmissive":c.emissive=e.fromArray(d).getHex();break;case"specularCoef":c.shininess=d;break;case"shading":d.toLowerCase()==="basic"&&(c.type="MeshBasicMaterial"),d.toLowerCase()==="phong"&&(c.type="MeshPhongMaterial"),d.toLowerCase()==="standard"&&(c.type="MeshStandardMaterial");break;case"mapDiffuse":c.map=f(d,n.mapDiffuseRepeat,n.mapDiffuseOffset,n.mapDiffuseWrap,n.mapDiffuseAnisotropy);break;case"mapDiffuseRepeat":case"mapDiffuseOffset":case"mapDiffuseWrap":case"mapDiffuseAnisotropy":break;case"mapEmissive":c.emissiveMap=f(d,n.mapEmissiveRepeat,n.mapEmissiveOffset,n.mapEmissiveWrap,n.mapEmissiveAnisotropy);break;case"mapEmissiveRepeat":case"mapEmissiveOffset":case"mapEmissiveWrap":case"mapEmissiveAnisotropy":break;case"mapLight":c.lightMap=f(d,n.mapLightRepeat,n.mapLightOffset,n.mapLightWrap,n.mapLightAnisotropy);break;case"mapLightRepeat":case"mapLightOffset":case"mapLightWrap":case"mapLightAnisotropy":break;case"mapAO":c.aoMap=f(d,n.mapAORepeat,n.mapAOOffset,n.mapAOWrap,n.mapAOAnisotropy);break;case"mapAORepeat":case"mapAOOffset":case"mapAOWrap":case"mapAOAnisotropy":break;case"mapBump":c.bumpMap=f(d,n.mapBumpRepeat,n.mapBumpOffset,n.mapBumpWrap,n.mapBumpAnisotropy);break;case"mapBumpScale":c.bumpScale=d;break;case"mapBumpRepeat":case"mapBumpOffset":case"mapBumpWrap":case"mapBumpAnisotropy":break;case"mapNormal":c.normalMap=f(d,n.mapNormalRepeat,n.mapNormalOffset,n.mapNormalWrap,n.mapNormalAnisotropy);break;case"mapNormalFactor":c.normalScale=d;break;case"mapNormalRepeat":case"mapNormalOffset":case"mapNormalWrap":case"mapNormalAnisotropy":break;case"mapSpecular":c.specularMap=f(d,n.mapSpecularRepeat,n.mapSpecularOffset,n.mapSpecularWrap,n.mapSpecularAnisotropy);break;case"mapSpecularRepeat":case"mapSpecularOffset":case"mapSpecularWrap":case"mapSpecularAnisotropy":break;case"mapMetalness":c.metalnessMap=f(d,n.mapMetalnessRepeat,n.mapMetalnessOffset,n.mapMetalnessWrap,n.mapMetalnessAnisotropy);break;case"mapMetalnessRepeat":case"mapMetalnessOffset":case"mapMetalnessWrap":case"mapMetalnessAnisotropy":break;case"mapRoughness":c.roughnessMap=f(d,n.mapRoughnessRepeat,n.mapRoughnessOffset,n.mapRoughnessWrap,n.mapRoughnessAnisotropy);break;case"mapRoughnessRepeat":case"mapRoughnessOffset":case"mapRoughnessWrap":case"mapRoughnessAnisotropy":break;case"mapAlpha":c.alphaMap=f(d,n.mapAlphaRepeat,n.mapAlphaOffset,n.mapAlphaWrap,n.mapAlphaAnisotropy);break;case"mapAlphaRepeat":case"mapAlphaOffset":case"mapAlphaWrap":case"mapAlphaAnisotropy":break;case"flipSided":c.side=b.BackSide;break;case"doubleSided":c.side=b.DoubleSide;break;case"transparency":console.warn("THREE.Loader.createMaterial: transparency has been renamed to opacity"),c.opacity=d;break;case"depthTest":case"depthWrite":case"colorWrite":case"opacity":case"reflectivity":case"transparent":case"visible":case"wireframe":c[l]=d;break;case"vertexColors":d===!0&&(c.vertexColors=b.VertexColors),d==="face"&&(c.vertexColors=b.FaceColors);break;default:console.error("THREE.Loader.createMaterial: Unsupported",l,d);break}}return c.type==="MeshBasicMaterial"&&delete c.emissive,c.type!=="MeshPhongMaterial"&&delete c.specular,c.opacity<1&&(c.transparent=!0),s.setTextures(h),s.parse(c)}}()});const us=function(r){var e=this;this.video=void 0,this.videoTexture=void 0;var t=r,s=function(){document&&(e.video=document.createElement("video"),e.video.crossOrigin="anonymous",e.video.src=t,e.video.load(),e.video.loop=!0)};this.setMorphTime=function(i,n){var o=i/n*e.video.duration;e.video.currentTime=o},this.getVideoDuration=function(){return e.video.duration},this.createCanvasVideoTexture=function(){return e.videoTexture=new M.VideoTexture(e.video),e.videoTexture.minFilter=M.LinearFilter,e.videoTexture.magFilter=M.LinearFilter,e.videoTexture.format=M.RGBFormat,e.video.currentTime=0,e.videoTexture},this.getCurrentTime=function(i){return e.video?i*(e.video.currentTime/e.video.duration):0},this.isReadyToPlay=function(){return!!(e.video&&e.video.readyState>=3)},s()},Ht=M.AnimationClip,wt=M.Color,fs=M.DefaultLoadingManager,ds=M.FileLoader,ps=M.LoaderUtils,ei=M.Vector2,Ke=M.Vector3,ti=M.Vector4;function ot(r){typeof r=="boolean"&&(console.warn("THREE.JSONLoader: showStatus parameter has been removed from constructor."),r=void 0),this.manager=r!==void 0?r:fs,this.withCredentials=!1,this.paramsString=""}Object.assign(ot.prototype,{load:function(r,e,t,s){var i=this,n=this.texturePath&&typeof this.texturePath=="string"?this.texturePath:ps.extractUrlBase(r),o=new ds(this.manager);r.split("?"),r.length===2?this.paramsString=paramsStrings[1]:this.paramsString="",o.setWithCredentials(this.withCredentials),o.load(r,function(a){var h=void 0;try{h=JSON.parse(a)}catch{if(console.error("The loader has encountered an error while parsing the content of a resource."),s){s({responseURL:r});return}}var f=h.metadata;if(f!==void 0){var c=f.type;if(c!==void 0&&c.toLowerCase()==="object"){console.error("THREE.JSONLoader: "+r+" should be loaded with THREE.ObjectLoader instead.");return}}if(i&&i.parse)try{var l=i.parse(h,n);e(l.geometry,l.materials)}catch(d){if(console.error("The loader has encountered aon loading the geometry"),console.error(d),s){s({responseURL:r});return}}},t,s)},setTexturePath:function(r){this.texturePath=r},parse:function(){function r(i,n){function o(J,X){return J&1<<X}var a,h,f,c,l,d,u,p,y,x,g,v,_,I,k,V,R,W,G,L,T,U,w,C,E,N,m,O=i.faces,B=i.vertices,S=i.normals,P=i.colors,F=i.scale,j=0;if(i.uvs!==void 0){for(a=0;a<i.uvs.length;a++)i.uvs[a].length&&j++;for(a=0;a<j;a++)n.faceVertexUvs[a]=[]}for(c=0,l=B.length;c<l;)W=new Ke,W.x=B[c++]*F,W.y=B[c++]*F,W.z=B[c++]*F,n.vertices.push(W);if(c=0,l=O.length,i.uvs)for(a=0;a<i.uvs.length;a++){n.uvs[a]=[];for(let J=0;J<i.uvs[a].length;J++)n.uvs[a][J]=i.uvs[a][J]}if(S)for(a=0;a<S.length;a++)n.normals[a]=S[a];if(P)for(a=0;a<P.length;a++)n.colors[a]=P[a];for(;c<l;)if(x=O[c++],g=o(x,0),v=o(x,1),_=o(x,3),I=o(x,4),k=o(x,5),V=o(x,6),R=o(x,7),g){if(L=new Ye,L.a=O[c],L.b=O[c+1],L.c=O[c+3],T=new Ye,T.a=O[c+1],T.b=O[c+2],T.c=O[c+3],c+=4,v&&(y=O[c++],L.materialIndex=y,T.materialIndex=y),f=n.faces.length,_)for(a=0;a<j;a++)for(C=i.uvs[a],n.faceVertexUvs[a][f]=[],n.faceVertexUvs[a][f+1]=[],h=0;h<4;h++)p=O[c++],N=C[p*2],m=C[p*2+1],E=new ei(N,m),h!==2&&n.faceVertexUvs[a][f].push(E),h!==0&&n.faceVertexUvs[a][f+1].push(E);if(I&&(u=O[c++]*3,L.normal.set(S[u++],S[u++],S[u]),T.normal.copy(L.normal)),k)for(a=0;a<4;a++)u=O[c++]*3,w=new Ke(S[u++],S[u++],S[u]),a!==2&&L.vertexNormals.push(w),a!==0&&T.vertexNormals.push(w);if(V&&(d=O[c++],U=P[d],L.color.setHex(U),T.color.setHex(U)),R)for(a=0;a<4;a++)d=O[c++],U=P[d],a!==2&&L.vertexColors.push(new wt(U)),a!==0&&T.vertexColors.push(new wt(U));n.faces.push(L),n.faces.push(T)}else{if(G=new Ye,G.a=O[c++],G.b=O[c++],G.c=O[c++],G.b||(G.b=G.a),G.c||(G.c=G.b),v&&(y=O[c++],G.materialIndex=y),f=n.faces.length,_)for(a=0;a<j;a++)for(C=i.uvs[a],n.faceVertexUvs[a][f]=[],h=0;h<3;h++)p=O[c++],N=C[p*2],m=C[p*2+1],E=new ei(N,m),n.faceVertexUvs[a][f].push(E);if(I&&(u=O[c++]*3,G.normal.set(S[u++],S[u++],S[u])),k)for(a=0;a<3;a++)u=O[c++]*3,w=new Ke(S[u++],S[u++],S[u]),G.vertexNormals.push(w);if(V&&(d=O[c++],G.color.setHex(P[d])),R)for(a=0;a<3;a++)d=O[c++],G.vertexColors.push(new wt(P[d]));n.faces.push(G)}}function e(i,n){var o=i.influencesPerVertex!==void 0?i.influencesPerVertex:2;if(i.skinWeights)for(var a=0,h=i.skinWeights.length;a<h;a+=o){var f=i.skinWeights[a],c=o>1?i.skinWeights[a+1]:0,l=o>2?i.skinWeights[a+2]:0,d=o>3?i.skinWeights[a+3]:0;n.skinWeights.push(new ti(f,c,l,d))}if(i.skinIndices)for(var a=0,h=i.skinIndices.length;a<h;a+=o){var u=i.skinIndices[a],p=o>1?i.skinIndices[a+1]:0,y=o>2?i.skinIndices[a+2]:0,x=o>3?i.skinIndices[a+3]:0;n.skinIndices.push(new ti(u,p,y,x))}n.bones=i.bones,n.bones&&n.bones.length>0&&(n.skinWeights.length!==n.skinIndices.length||n.skinIndices.length!==n.vertices.length)&&console.warn("When skinning, number of vertices ("+n.vertices.length+"), skinIndices ("+n.skinIndices.length+"), and skinWeights ("+n.skinWeights.length+") should match.")}function t(i,n){var o=i.scale;if(i.morphTargets!==void 0)for(var a=0,h=i.morphTargets.length;a<h;a++){n.morphTargets[a]={},n.morphTargets[a].name=i.morphTargets[a].name,n.morphTargets[a].vertices=[];for(var f=n.morphTargets[a].vertices,c=i.morphTargets[a].vertices,l=0,d=c.length;l<d;l+=3){var u=new Ke;u.x=c[l]*o,u.y=c[l+1]*o,u.z=c[l+2]*o,f.push(u)}}if(i.morphNormals!==void 0){for(var a=0,h=i.morphNormals.length;a<h;a++)if(n.morphTargets[a]){n.morphTargets[a].normals=[];for(var p=n.morphTargets[a].normals,y=i.morphNormals[a].normals,l=0,d=y.length;l<d;l+=3){var x=new Ke;x.x=y[l],x.y=y[l+1],x.z=y[l+2],p.push(x)}n.morphNormalsReady=!0}}if(i.morphColors!==void 0){var a,h,g,v,_,I,k;for(a=0,h=i.morphColors.length;a<h;a++)for(n.morphColors[a]={},n.morphColors[a].name=i.morphColors[a].name,n.morphColors[a].colors=[],_=n.morphColors[a].colors,I=i.morphColors[a].colors,g=0,v=I.length;g<v;g+=3)k=new M.Color(16755200),k.setRGB(I[g],I[g+1],I[g+2]),_.push(k)}}function s(i,n){var o=[],a=[];i.animation!==void 0&&a.push(i.animation),i.animations!==void 0&&(i.animations.length?a=a.concat(i.animations):a.push(i.animations));for(var h=0;h<a.length;h++){var f=Ht.parseAnimation(a[h],n.bones);f&&o.push(f)}if(n.morphTargets){var c=Ht.CreateClipsFromMorphTargetSequences(n.morphTargets,10);o=o.concat(c)}o.length>0&&(n.animations=o)}return function(n,o){n.data!==void 0&&(n=n.data),n.scale!==void 0?n.scale=1/n.scale:n.scale=1;var a=new Ve;if(a.morphColors=[],r(n,a),e(n,a),t(n,a),s(n,a),a.computeFaceNormals(),a.computeBoundingSphere(),n.materials===void 0||n.materials.length===0)return{geometry:a};var h=rt.prototype.initMaterials(n.materials,o,"Anonymous");if(n.materials[0].video){var f=o+n.materials[0].video;this.paramsString&&(f=f+`?${this.paramsString}`);const c=new us(f);a._video=c}return h&&h.length>0&&(n.materials[0].singleSided?h[0].side=M.FrontSide:n.materials[0].flipSided?h[0].side=M.BackSide:h[0].side=M.DoubleSide,n.materials[0].specularCoef&&(h[0].shininess=Math.floor(n.materials[0].specularCoef/3))),{geometry:a,materials:h}}}()});const vt=function(){Q.call(this);const r=[];let e,t,s,i,n,o,a,h=0,f=0,c=[0,0,0],l=[0,0,0],d=!1,u=[0,0,0],p="NONE";this.ready=!1;let y=!1,x=!1;this.isGlyphset=!0;let g=new M.Matrix4;const v=new M.Color,_=new M.Color,I=new M.Box3,k=new M.Box3,V=new M.Box3,R=[],W=[],G=[],L=[],T=[],U=[],w=[];this.globalScale=1;for(let S=0;S<8;S++)new M.Vector3;this.load=(S,P,F,j,J)=>{e=S.axis1,t=S.axis2,s=S.axis3,i=S.positions,n=S.scale,o=S.colors,a=S.label,y=S.metadata.MorphColours,x=S.metadata.MorphVertices,h=S.metadata.number_of_time_steps,p=S.metadata.repeat_mode,f=S.metadata.number_of_vertices,p=="AXES_2D"||p=="MIRROR"?f=f*2:p=="AXES_3D"&&(f=f*3),c=S.metadata.base_size,l=S.metadata.offset,u=S.metadata.scale_factors;const X=new ot;this.geometry=new M.BufferGeometry;const Y=new M.InstancedMesh(this.geometry,void 0,f);if(this.setMorph(Y),j){var re=X.parse(P);B(F,J)(re.geometry,re.materials),re.geometry.dispose()}else X.crossOrigin="Anonymous",X.load(P,B(F,J))};const C=(S,P,F,j,J,X)=>{if(p=="NONE"||p=="MIRROR"){let ee=[0,0,0],te=[0,0,0],de=[0,0,0],ne=[0,0,0],ge=[0,0,0];const le=[0,0,0],se=[0,0,0],$=[0,0,0],he=[0,0,0];for(var Y=0;Y<3;Y++){var re=J[Y]<0?-1:1;ee[Y]=(re*c[Y]+J[Y]*u[Y])*this.globalScale}for(var Y=0;Y<3;Y++)te[Y]=P[Y]*ee[0],de[Y]=F[Y]*ee[1],ne[Y]=j[Y]*ee[2],ge[Y]=S[Y]+l[0]*te[Y]+l[1]*de[Y]+l[2]*ne[Y],p=="MIRROR"&&(le[Y]=-te[Y],se[Y]=-de[Y],$[Y]=-ne[Y],he[Y]=ge[Y],J[0]<0&&(ge[Y]-=te[Y],he[Y]-=le[Y]));0>ne[0]*(te[1]*de[2]-te[2]*de[1])+ne[1]*(te[2]*de[0]-te[0]*de[2])+ne[2]*(te[0]*de[1]-te[1]*de[0])&&(ne[0]=-ne[0],ne[1]=-ne[1],ne[2]=-ne[2]),X[0]=[ge,te,de,ne],p=="MIRROR"&&(0>$[0]*(le[1]*se[2]-le[2]*se[1])+$[1]*(le[2]*se[0]-le[0]*se[2])+$[2]*(le[0]*se[1]-le[1]*se[0])&&($[0]=-$[0],$[1]=-$[1],$[2]=-$[2]),X[1]=[he,le,se,$])}else if(p=="AXES_2D"||p=="AXES_3D"){let ee=[0,0,0],te=[0,0,0];for(var Y=0;Y<3;Y++){var re=J[Y]<0?-1:1;ee[Y]=(re*c[0]+J[Y]*u[0])*this.globalScale}for(var Y=0;Y<3;Y++)te[Y]=S[Y]+l[0]*ee[0]*P[Y]+l[1]*ee[1]*F[Y]+l[2]*ee[2]*j[Y];const de=glyph_repeat_mode=="AXES_2D"?2:3;for(let ne=0;ne<de;ne++){let ge,le;const se=J[ne];let $=[0,0,0],he=[0,0,0],ue=[0,0,0];ne==0?(ge=P,le=F):ne==1?(ge=F,le=glyph_repeat_mode=="AXES_2D"?P:j):(ge=j,le=P);const De=(c[0]+se*u[0])*this.globalScale;$[0]=ge[0]*De,$[1]=ge[1]*De,$[2]=ge[2]*De,ue[0]=$[1]*le[2]-le[1]*$[2],ue[1]=$[2]*le[0]-le[2]*$[0],ue[2]=$[0]*le[1]-$[1]*le[0];let ce=Math.sqrt(ue[0]*ue[0]+ue[1]*ue[1]+ue[2]*ue[2]);if(0<ce){let Fe=(c[2]+se*u[2])*this.globalScale/ce;p=="AXES_2D"&&ne>0&&(Fe*=-1),ue[0]*=Fe,ue[1]*=Fe,ue[2]*=Fe}if(he[0]=ue[1]*$[2]-$[1]*ue[2],he[1]=ue[2]*$[0]-$[2]*ue[0],he[2]=ue[0]*$[1]-ue[1]*$[0],ce=Math.sqrt(he[0]*he[0]+he[1]*he[1]+he[2]*he[2]),0<ce){var oe=(c[1]+se*u[1])*this.globalScale/ce;he[0]*=oe,he[1]*=oe,he[2]*=oe}X[ne]=[te,$,he,ue]}}return X},E=(S,P,F,j,J)=>{let X=1;p=="AXES_2D"||p=="MIRROR"?X=2:p=="AXES_3D"&&(X=3);const Y=S.length/3;let re=0;w.length=X;for(let oe=0;oe<Y;oe++){const ee=oe*3,te=[S[ee],S[ee+1],S[ee+2]],de=[P[ee],P[ee+1],P[ee+2]],ne=[F[ee],F[ee+1],F[ee+2]],ge=[j[ee],j[ee+1],j[ee+2]],le=[J[ee],J[ee+1],J[ee+2]],se=C(te,de,ne,ge,le,w);if(se.length==X)for(let $=0;$<X;$++){g.elements[0]=se[$][1][0],g.elements[1]=se[$][1][1],g.elements[2]=se[$][1][2],g.elements[3]=0,g.elements[4]=se[$][2][0],g.elements[5]=se[$][2][1],g.elements[6]=se[$][2][2],g.elements[7]=0,g.elements[8]=se[$][3][0],g.elements[9]=se[$][3][1],g.elements[10]=se[$][3][2],g.elements[11]=0,g.elements[12]=se[$][0][0],g.elements[13]=se[$][0][1],g.elements[14]=se[$][0][2],g.elements[15]=1,this.morph.setMatrixAt(re,g);const he=r[re];he&&he.setTransformation(se[$][0],se[$][1],se[$][2],se[$][3]),re++}}this.morph.instanceMatrix.needsUpdate=!0},N=S=>{let P=1;p=="AXES_2D"||p=="MIRROR"?P=2:p=="AXES_3D"&&(P=3);const F=S.length;let j=0;for(let J=0;J<F;J++){const X=S[J];for(let Y=0;Y<P;Y++){v.setHex(X),this.morph.setColorAt(j,v);const re=r[j];re&&re.setColour(v),j++}}this.morph.instanceColor.needsUpdate=!0},m=()=>{let S=R,P=W,F=G,j=L,J=T,X=U;const Y=this.inbuildTime/this.duration*(h-1),re=Math.floor(Y),oe=1-(Y-re),ee=Math.ceil(Y);if(x){const te=i[re.toString()],de=i[ee.toString()],ne=e[re.toString()],ge=e[ee.toString()],le=t[re.toString()],se=t[ee.toString()],$=s[re.toString()],he=s[ee.toString()],ue=n[re.toString()],De=n[ee.toString()];R.length=te.length,W.length=te.length,G.length=te.length,L.length=te.length,T.length=te.length;for(let ce=0;ce<te.length;ce++)S[ce]=oe*te[ce]+(1-oe)*de[ce],P[ce]=oe*ne[ce]+(1-oe)*ge[ce],F[ce]=oe*le[ce]+(1-oe)*se[ce],j[ce]=oe*$[ce]+(1-oe)*he[ce],J[ce]=oe*ue[ce]+(1-oe)*De[ce]}else S=i[0],P=e[0],F=t[0],j=s[0],J=n[0];if(E(S,P,F,j,J),this.boundingBoxUpdateRequired=!0,o!=null){if(y){const te=o[re.toString()],de=o[ee.toString()];X.length=te.length;for(let ne=0;ne<te.length;ne++)v.setHex(te[ne]),_.setHex(de[ne]),v.setRGB(v.r*oe+_.r*(1-oe),v.g*oe+_.g*(1-oe),v.b*oe+_.b*(1-oe)),X[ne]=v.getHex()}else X=o[0];N(X)}};this.getLabel=S=>{if(a&&a.length>S)return a[S]},this.isLabelDisplayed=()=>d,this.canShowLabel=()=>(r==null?void 0:r.length)&&((a==null?void 0:a.length)||this.groupName),this.showLabel=()=>{if(r!=null&&r.length){d=!0;for(let S=0;S<r.length;S++)r[S].showLabel(this.morph.material?this.morph.material.color:void 0)}},this.hideLabel=()=>{for(let S=0;S<r.length;S++)r[S].hideLabel();d=!1};const O=S=>{for(let P=0;P<f;P++){const F=new nt(void 0,void 0,P,this);let j=a?a[P]:void 0;j=j||this.groupName,j&&F.setLabel(j),h>0&&F.setFrustumCulled(!1),r[P]=F,this.morph.add(F.getGroup())}a&&S&&this.showLabel(),E(i[0],e[0],t[0],s[0],n[0]),o!=null&&N(o[0]),this.ready=!0,this.boundingBoxUpdateRequired=!0};this.addCustomGlyph=S=>{S.isGlyph&&r.push(S),this.ready=!0,this.boundingBoxUpdateRequired=!0},this.addMeshAsGlyph=(S,P)=>{if(S.isMesh){const F=new nt(void 0,void 0,P,this);return F.fromMesh(S),r.push(F),this.morph.add(F.getGroup()),this.ready=!0,this.boundingBoxUpdateRequired=!0,F}},this.forEachGlyph=S=>{for(let P=0;P<r.length;P++)S(r[P])};var B=(S,P)=>(F,j)=>{const J=F.toBufferGeometry();this.geometry.copy(J),this.geometry.computeBoundingSphere(),this.geometry.computeBoundingBox(),J.dispose(),j&&j[0]&&(this.morph.material=j[0]),O(P),this.morph.name=this.groupName,this.morph.userData=this,this.setMorph(this.morph),F.dispose(),S!=null&&typeof S=="function"&&S(this)};this.getClosestVertexIndex=function(){let S=-1;if(this.morph&&this.ready){this.getBoundingBox().getCenter(this._v1);let P=i[0];const F=P.length/3;let j=-1,J=0;for(let X=0;X<F;X++){const Y=X*3;this._v2.set(P[Y],P[Y+1],P[Y+2]),J=this._v1.distanceTo(this._v2),(j==-1||j>J)&&(j=J,S=X)}}return S},this.getClosestVertex=function(){if(this.closestVertexIndex==-1&&(this.closestVertexIndex=this.getClosestVertexIndex()),this.closestVertexIndex>=0&&this.morph){let S=new M.Vector3;return this.morph.getMatrixAt(this.closestVertexIndex,g),S.setFromMatrixPosition(g),S}},this.getBoundingBox=()=>{if(this.morph&&this.ready&&this.morph.visible){if(this.boundingBoxUpdateRequired){I.setFromBufferAttribute(this.morph.geometry.attributes.position);for(let S=0;S<f;S++)this.morph.getMatrixAt(S,g),k.copy(I).applyMatrix4(g),S==0?V.copy(k):V.union(k);if(V)this.cachedBoundingBox.copy(V),this.morph.updateWorldMatrix(!0,!0),this.cachedBoundingBox.applyMatrix4(this.morph.matrixWorld),this.boundingBoxUpdateRequired=!1;else return}return this.cachedBoundingBox}},this.setMorphTime=S=>{S>this.duration?this.inbuildTime=this.duration:0>S?this.inbuildTime=0:this.inbuildTime=S,(y||x)&&(m(),x&&(this.markerUpdateRequired=!0))},this.isTimeVarying=()=>!!((this.ready===!1||h>0)&&(y||x)),this.getCurrentTime=()=>this.inbuildTime,this.setScaleAll=function(S){this.globalScale=S,m()},this.dispose=()=>{for(let S=r.length-1;S>=0;S--)r[S].dispose();this.geometry&&this.geometry.dispose(),this.morph&&this.morph.material.dispose(),e=void 0,t=void 0,s=void 0,i=void 0,n=void 0,o=void 0,this.ready=!1,this.groupName=void 0},this.render=(S,P,F)=>{if(P==!0){let j=this.inbuildTime+S;j>this.duration&&(j=j-this.duration),this.inbuildTime=j,(y||x)&&m()}this.updateMarker(P,F)}};vt.prototype=Object.create(Q.prototype);const ii=new b.Matrix4,_t=new b.Ray,at=new b.Sphere,Je=new b.Vector3,Mt=new b.Vector3,si=new b.Vector3;class St extends b.Object3D{constructor(e=new b.BufferGeometry,t=new b.PointsMaterial){super(),this.type="Points",this.geometry=e,this.material=t,this.sizePerPixel=1,this.updateMorphTargets()}copy(e){return super.copy(e),this.material=e.material,this.geometry=e.geometry,this}raycast(e,t){const s=this.geometry,i=this.matrixWorld,n=e.params.Points.threshold,o=s.drawRange;if(s.boundingSphere===null&&s.computeBoundingSphere(),at.copy(s.boundingSphere),at.applyMatrix4(i),at.radius+=n,e.ray.intersectsSphere(at)===!1)return;ii.copy(i).invert(),_t.copy(e.ray).applyMatrix4(ii);const a=n/((this.scale.x+this.scale.y+this.scale.z)/3)*this.material.size*this.sizePerPixel,h=a*a;if(s.isBufferGeometry){const f=s.index,l=s.attributes.position,d=s.morphAttributes.position;if(f!==null){const u=Math.max(0,o.start),p=Math.min(f.count,o.start+o.count);for(let y=u,x=p;y<x;y++){const g=f.getX(y);ri(this,l,d,g),ni(Je,g,h,i,e,t,this)}}else{const u=Math.max(0,o.start),p=Math.min(l.count,o.start+o.count);for(let y=u,x=p;y<x;y++)ri(this,l,d,y),ni(Je,y,h,i,e,t,this)}}else console.error("THREE.Points.raycast() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.")}updateMorphTargets(){const e=this.geometry;if(e.isBufferGeometry){const t=e.morphAttributes,s=Object.keys(t);if(s.length>0){const i=t[s[0]];if(i!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let n=0,o=i.length;n<o;n++){const a=i[n].name||String(n);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=n}}}}else{const t=e.morphTargets;t!==void 0&&t.length>0&&console.error("THREE.Points.updateMorphTargets() does not support THREE.Geometry. Use THREE.BufferGeometry instead.")}}}St.prototype.isPoints=!0;function ni(r,e,t,s,i,n,o){const a=_t.distanceSqToPoint(r);if(a<t){const h=new b.Vector3;_t.closestPointToPoint(r,h),h.applyMatrix4(s);const f=i.ray.origin.distanceTo(h);if(f<i.near||f>i.far)return;n.push({distance:f,distanceToRay:Math.sqrt(a),point:h,index:e,face:null,object:o})}}function ri(r,e,t,s){Je.fromBufferAttribute(e,s);const i=r.morphTargetInfluences;if(r.material.morphTargets&&t&&i){Mt.set(0,0,0);for(var n=0,o=t.length;n<o;n++){const a=i[n],h=t[n];a!==0&&(si.fromBufferAttribute(h,s),Mt.addScaledVector(si.sub(Je),a))}Je.add(Mt)}}const Ee=function(){Q.call(this),this.isPointset=!0;const r=[];let e=1,t=!1,s=500,i=!0;this.createMesh=(a,h,f)=>{if(a&&h){let c=et(a,f);const l=Vt();h.map=l;let d=new St(c,h);this.setMesh(d,f.localTimeEnabled,f.localMorphColour)}};const n=(a,h,f,c)=>{if(f){const l=new M.Color(c),d=new At(f,l);d.setPosition(h[0],h[1],h[2]);const u=d.getSprite();u.material.sizeAttenuation=!1,u.material.alphaTest=.5,u.material.transparent=!0,u.material.depthWrite=!1,u.material.depthTest=t,d.setFontWeight(s),d.setSize(e),d.setVisibility(i),this.group.add(u),r[a]=d}},o=a=>{const h=r[a];if(h){const f=h.getSprite();this.group.remove(f),h.dispose(),r.splice(a,1)}};this.addPoints=(a,h,f)=>{if(a&&a.length>0){let c=this.drawRange;c===-1&&(c=0);const l=this.addVertices(a);if(!this.getMorph()){let y=new M.PointsMaterial({alphaTest:.5,size:10,color:f,sizeAttenuation:!1});const x={localTimeEnabled:!1,localMorphColour:!1};l.colorsNeedUpdate=!0,this.createMesh(l,y,x)}let u=c+a.length,p=0;if(Array.isArray(h)&&h.length===a.length||typeof h=="string")for(r.length,c;c+p<u;){const y=typeof h=="string"?h:h[p];n(c+p,a[p],y,this._lod._material.color),p++}this.region&&(this.region.pickableUpdateRequired=!0)}},this.setColourHex=function(a){this._lod._material.color.setHex(a),this._lod._secondaryMaterial&&this._lod._secondaryMaterial.color.setHex(a);for(let h=0;h<r.length;h++)r[h]&&r[h].setColour(this._lod._material.color)},this.setColour=a=>{this._lod.setColour(a);for(let h=0;h<r.length;h++)r[h]&&r[h].setColour(this._lod._material.color)},this.setLabelDepthTest=a=>{t=a;for(let h=0;h<r.length;h++)r[h]&&r[h].setDepthTest(a)},this.setLabelFontWeight=a=>{s=a;for(let h=0;h<r.length;h++)r[h]&&r[h].setFontWeight(a)},this.setLabelSize=a=>{e=a;for(let h=0;h<r.length;h++)r[h]&&r[h].setSize(e)},this.displayLabels=a=>{i=a;for(let h=0;h<r.length;h++)r[h]&&r[h].setVisibility(i)},this.setSize=a=>{this.morph&&this.morph.material&&(this.morph.material.size=a,this.morph.material.needsUpdate=!0)},this.setSizeAttenuation=a=>{this.morph&&this.morph.material&&(this.morph.material.sizeAttenuation=a,this.morph.material.needsUpdate=!0)},this.getVerticesByIndex=function(a){if(a>=0&&this.drawRange>a){const h=this.getMorph().geometry.getAttribute("position");return[h.getX(a),h.getY(a),h.getZ(a)]}},this.editVertices=function(a,h){if(a&&a.length){let f=this.getMorph();const c=h+a.length-1;if(!f||0>h||c>=this.drawRange)return;{const l=f.geometry.getAttribute("position");let d=h;a.forEach(u=>{const p=r[d];p&&p.setPosition(u[0],u[1],u[2]),l.setXYZ(d++,u[0],u[1],u[2])}),l.needsUpdate=!0,f.geometry.computeBoundingBox(),f.geometry.computeBoundingSphere(),this.boundingBoxUpdateRequired=!0}}},this.deleteVertices=function(a){return Ee.prototype.deleteVertices.call(this,a)&&o(a),this.drawRange},this.setName=function(a){const h=this.groupName;Ee.prototype.setName.call(this,a),r.forEach(f=>{f.getString()===h&&(f==null||f.setText(a))})},this.render=(a,h,f,c)=>{this.morph&&f&&(this.morph.sizePerPixel=f.pixelHeight),Ee.prototype.render.call(this,a,h,f,c)}};Ee.prototype=Object.create(Q.prototype);const ze=function(){Q.call(this),this.isLines=!0,this.createLineSegment=(r,e,t)=>{if(r&&e){let s=et(r,t);t.localMorphColour&&s.morphAttributes.color&&(e.onBeforeCompile=Ft());let i=new it(s,e);this.setMesh(i,t.localTimeEnabled,t.localMorphColour)}},this.setWidth=r=>{this.morph&&this.morph.material&&(this.morph.material.linewidth=r,this.morph.material.needsUpdate=!0)},this.addLines=(r,e)=>{if(r&&r.length>0){const t=this.addVertices(r);if(!this.getMorph()){let i=new M.LineBasicMaterial({color:e});const n={localTimeEnabled:!1,localMorphColour:!1};t.colorsNeedUpdate=!0,this.createLineSegment(t,i,n)}this.region&&(this.region.pickableUpdateRequired=!0)}}};ze.prototype=Object.create(Q.prototype);const Re=function(){this.isTexture=!0,this.impl=void 0,this.isLoading=!1,this.size={width:1,height:1,depth:0}};Re.prototype.loadImage=function(r,e){return new Promise((t,s)=>{r.onload=()=>t(r),r.onerror=s,r.src=e})},Re.prototype.imageToUint8Array=async function(r,e,t,s){await r.loadImage(e,t),s.width=e.width,s.height=e.height;const i=s.getContext("2d");return i.drawImage(e,0,0),{array:new Uint8Array(i.getImageData(0,0,s.width,s.height).data.buffer),width:s.width,height:s.height}},Re.prototype.loadFromImages=async function(r){},Re.prototype.isReady=function(){return!!(this.impl&&!this.isLoading)},Re.prototype.getMaterial=function(){if(this.impl)return new M.MeshBasicMaterial({color:new M.Color(1,1,1),transparent:!1,opacity:1,map:this.impl,side:M.DoubleSide})};const lt=function(){Re.call(this),this.isTextureArray=!0,this.loadFromImages=async r=>{let e=1,t=1,s=0;if(r&&r.length){this.isLoading=!0;const i=new Image;i.crossOrigin="Anonymous";const n=document.createElement("canvas");let o=0;const a=new Array(r.length);for(let f=0;f<r.length;f++){const c=await this.imageToUint8Array(this,i,r[f],n);c&&c.array&&(e=c.width,t=c.height,a[s]=c.array,o+=a[s].length,s++)}const h=new Uint8Array(o);o=0,a.forEach(f=>{h.set(f,o),o+=f.length}),this.impl=new M.DataTexture2DArray(h,e,t,s),this.size={width:e,height:t,depth:s},this.isLoading=!1,this.impl.needsUpdate=!0}},this.getMaterial=r=>{if(this.impl){let e;if(r){if(r.vs&&r.fs){let t=!0;"transparent"in r&&(t=r.transparent);let s=M.FrontSide;r.side&&(s=r.side),e=new M.ShaderMaterial({transparent:t,uniforms:r.uniforms,vertexShader:r.vs,fragmentShader:r.fs,side:s}),r.glslVersion&&(e.glslVersion=r.glslVersion)}}else e=new M.MeshBasicMaterial({color:new M.Color(1,1,1),transparent:!1,opacity:1,map:this.impl,side:M.DoubleSide});if(e)return e.needsUpdate=!0,e}}};lt.prototype=Object.create(Re.prototype);const ms=M.GLSL3,gs=`
1
+ (function(e,t){typeof exports==`object`&&typeof module<`u`?module.exports=t(require("three"),require("three-spritetext"),require("css-element-queries"),require("three/examples/jsm/loaders/GLTFLoader"),require("fflate")):typeof define==`function`&&define.amd?define([`three`,`three-spritetext`,`css-element-queries`,`three/examples/jsm/loaders/GLTFLoader`,`fflate`],t):(e=typeof globalThis<`u`?globalThis:e||self,e.Zinc=t(e.THREE,e.SpriteText,e.cssElememtQueries,e.GLTFLoader,e.fflate))})(this,function(e,t,n,r,i){var a=Object.create,o=Object.defineProperty,s=Object.getOwnPropertyDescriptor,c=Object.getOwnPropertyNames,l=Object.getPrototypeOf,u=Object.prototype.hasOwnProperty,d=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=c(t),a=0,l=i.length,d;a<l;a++)d=i[a],!u.call(e,d)&&d!==n&&o(e,d,{get:(e=>t[e]).bind(null,d),enumerable:!(r=s(t,d))||r.enumerable});return e},f=(e,t,n)=>(n=e==null?{}:a(l(e)),d(t||!e||!e.__esModule||!u.call(e,`default`)?o(n,`default`,{value:e,enumerable:!0}):n,e));e=f(e,1),t=f(t,1);var p={name:`zincjs`,version:`2.2.0`,description:`ZincJS (Web-based-Zinc-Visualisation)`,type:`module`,main:`build/zinc.js`,directories:{doc:`docs`},files:[`package.json`,`LICENSE`,`README.md`,`src/*`,`build/zinc.js`,`build/zinc.js.map`,`vite.config.js`],scripts:{"build-bundle":`vite build`,"test-watch":`vitest`,test:`vitest run --reporter=junit --outputFile=test-results.xml`,"test-standard":`vitest run`,changelog:`auto-changelog -p --output CHANGELOG.md --template keepachangelog`,jsdoc:`jsdoc -c jsdoc_conf.json`,version:`npm run build-bundle;npm run jsdoc;npm run changelog; git add CHANGELOG.md docs`,"release:beta":`npm version prerelease --preid=beta; npm publish --tag beta`,"release:major":`npm version major; npm publish`,"release:minor":`npm version minor; npm publish`,"release:patch":`npm version patch; npm publish`},repository:{type:`git`,url:`git+https://github.com/alan-wu/ZincJS.git`},keywords:[`library`,`webgl`,`3d`,`zincjs`],author:`Alan Wu <alan.wu@auckland.ac.nz>`,license:`MIT`,bugs:{url:`https://github.com/alan-wu/ZincJS/issues`},homepage:`http://alan-wu.github.io/ZincJS/`,engines:{node:`>=20`},devDependencies:{"@vitest/coverage-v8":`^4.1.11`,"auto-changelog":`^2.4.0`,chai:`^4.1.0`,gl:`^8.1.6`,"happy-dom":`^20.10.6`,jsdoc:`^4.0.2`,msw:`^2.14.6`,vite:`^8.2.1`,"vite-plugin-node-polyfills":`^0.28.0`,vitest:`^4.1.11`},dependencies:{"css-element-queries":`^1.2.2`,lodash:`^4.17.19`,"nifti-reader-js":`0.8.0`,three:`^0.130.1`,"three-spritetext":`1.6.2`}},m=new e.Matrix4,h=new e.Object3D,g=new e.Vector3,_=new e.Vector3;function v(){this.uuid=e.MathUtils.generateUUID(),this.name=``,this.type=`Geometry`,this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.normals=[],this.uvs=[],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.elementsNeedUpdate=!1,this.verticesNeedUpdate=!1,this.uvsNeedUpdate=!1,this.normalsNeedUpdate=!1,this.colorsNeedUpdate=!1,this.lineDistancesNeedUpdate=!1,this.groupsNeedUpdate=!1,this.morphNormalsReady=!1}v.prototype=Object.assign(Object.create(e.EventDispatcher.prototype),{constructor:v,isGeometry:!0,applyMatrix4:function(t){let n=new e.Matrix3().getNormalMatrix(t);for(let e=0,n=this.vertices.length;e<n;e++)this.vertices[e].applyMatrix4(t);for(let e=0,t=this.faces.length;e<t;e++){let t=this.faces[e];t.normal.applyMatrix3(n).normalize();for(let e=0,r=t.vertexNormals.length;e<r;e++)t.vertexNormals[e].applyMatrix3(n).normalize()}return this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this.verticesNeedUpdate=!0,this.normalsNeedUpdate=!0,this},rotateX:function(e){return m.makeRotationX(e),this.applyMatrix4(m),this},rotateY:function(e){return m.makeRotationY(e),this.applyMatrix4(m),this},rotateZ:function(e){return m.makeRotationZ(e),this.applyMatrix4(m),this},translate:function(e,t,n){return m.makeTranslation(e,t,n),this.applyMatrix4(m),this},scale:function(e,t,n){return m.makeScale(e,t,n),this.applyMatrix4(m),this},lookAt:function(e){return h.lookAt(e),h.updateMatrix(),this.applyMatrix4(h.matrix),this},fromBufferGeometry:function(t){let n=this,r=t.index===null?void 0:t.index,i=t.attributes;if(i.position===void 0)return console.error(`THREE.Geometry.fromBufferGeometry(): Position attribute required for conversion.`),this;let a=i.position,o=i.normal,s=i.color,c=i.uv,l=i.uv2;l!==void 0&&(this.faceVertexUvs[1]=[]);for(let t=0;t<a.count;t++)n.vertices.push(new e.Vector3().fromBufferAttribute(a,t)),s!==void 0&&n.colors.push(new e.Color().fromBufferAttribute(s,t));function u(t,r,i,a){let u=s===void 0?[]:[n.colors[t].clone(),n.colors[r].clone(),n.colors[i].clone()],d=new b(t,r,i,o===void 0?[]:[new e.Vector3().fromBufferAttribute(o,t),new e.Vector3().fromBufferAttribute(o,r),new e.Vector3().fromBufferAttribute(o,i)],u,a);n.faces.push(d),c!==void 0&&n.faceVertexUvs[0].push([new e.Vector2().fromBufferAttribute(c,t),new e.Vector2().fromBufferAttribute(c,r),new e.Vector2().fromBufferAttribute(c,i)]),l!==void 0&&n.faceVertexUvs[1].push([new e.Vector2().fromBufferAttribute(l,t),new e.Vector2().fromBufferAttribute(l,r),new e.Vector2().fromBufferAttribute(l,i)])}let d=t.groups;if(d.length>0)for(let e=0;e<d.length;e++){let t=d[e],n=t.start,i=t.count;for(let e=n,a=n+i;e<a;e+=3)r===void 0?u(e,e+1,e+2,t.materialIndex):u(r.getX(e),r.getX(e+1),r.getX(e+2),t.materialIndex)}else if(r!==void 0)for(let e=0;e<r.count;e+=3)u(r.getX(e),r.getX(e+1),r.getX(e+2));else for(let e=0;e<a.count;e+=3)u(e,e+1,e+2);return this.computeFaceNormals(),t.boundingBox!==null&&(this.boundingBox=t.boundingBox.clone()),t.boundingSphere!==null&&(this.boundingSphere=t.boundingSphere.clone()),this},center:function(){return this.computeBoundingBox(),this.boundingBox.getCenter(g).negate(),this.translate(g.x,g.y,g.z),this},normalize:function(){this.computeBoundingSphere();let t=this.boundingSphere.center,n=this.boundingSphere.radius,r=n===0?1:1/n,i=new e.Matrix4;return i.set(r,0,0,-r*t.x,0,r,0,-r*t.y,0,0,r,-r*t.z,0,0,0,1),this.applyMatrix4(i),this},computeFaceNormals:function(){let t=new e.Vector3,n=new e.Vector3;for(let e=0,r=this.faces.length;e<r;e++){let r=this.faces[e],i=this.vertices[r.a],a=this.vertices[r.b],o=this.vertices[r.c];t.subVectors(o,a),n.subVectors(i,a),t.cross(n),t.normalize(),r.normal.copy(t)}},computeVertexNormals:function(t=!0){let n=Array(this.vertices.length);for(let t=0,r=this.vertices.length;t<r;t++)n[t]=new e.Vector3;if(t){let t=new e.Vector3,r=new e.Vector3;for(let e=0,i=this.faces.length;e<i;e++){let i=this.faces[e],a=this.vertices[i.a],o=this.vertices[i.b],s=this.vertices[i.c];t.subVectors(s,o),r.subVectors(a,o),t.cross(r),n[i.a].add(t),n[i.b].add(t),n[i.c].add(t)}}else{this.computeFaceNormals();for(let e=0,t=this.faces.length;e<t;e++){let t=this.faces[e];n[t.a].add(t.normal),n[t.b].add(t.normal),n[t.c].add(t.normal)}}for(let e=0,t=this.vertices.length;e<t;e++)n[e].normalize();for(let e=0,t=this.faces.length;e<t;e++){let t=this.faces[e],r=t.vertexNormals;r.length===3?(r[0].copy(n[t.a]),r[1].copy(n[t.b]),r[2].copy(n[t.c])):(r[0]=n[t.a].clone(),r[1]=n[t.b].clone(),r[2]=n[t.c].clone())}return this.faces.length>0&&(this.normalsNeedUpdate=!0),n},computeFlatVertexNormals:function(){this.computeFaceNormals();for(let e=0,t=this.faces.length;e<t;e++){let t=this.faces[e],n=t.vertexNormals;n.length===3?(n[0].copy(t.normal),n[1].copy(t.normal),n[2].copy(t.normal)):(n[0]=t.normal.clone(),n[1]=t.normal.clone(),n[2]=t.normal.clone())}this.faces.length>0&&(this.normalsNeedUpdate=!0)},computeMorphNormals:function(){for(let e=0,t=this.faces.length;e<t;e++){let t=this.faces[e];t.__originalFaceNormal?t.__originalFaceNormal.copy(t.normal):t.__originalFaceNormal=t.normal.clone(),t.__originalVertexNormals||=[];for(let e=0,n=t.vertexNormals.length;e<n;e++)t.__originalVertexNormals[e]?t.__originalVertexNormals[e].copy(t.vertexNormals[e]):t.__originalVertexNormals[e]=t.vertexNormals[e].clone()}let t=new v;t.faces=this.faces;for(let n=0,r=this.morphTargets.length;n<r;n++){if(!this.morphNormals[n]){this.morphNormals[n]={},this.morphNormals[n].faceNormals=[],this.morphNormals[n].vertexNormals=[];let t=this.morphNormals[n].faceNormals,r=this.morphNormals[n].vertexNormals;for(let n=0,i=this.faces.length;n<i;n++){let n=new e.Vector3,i={a:new e.Vector3,b:new e.Vector3,c:new e.Vector3};t.push(n),r.push(i)}}let r=this.morphNormals[n];t.vertices=this.morphTargets[n].vertices,t.computeFaceNormals();let i=t.computeVertexNormals();if(i&&i.length>0){this.morphTargets[n].normals=Array(this.vertices.length);for(let e=0;e<i.length;e++)this.morphTargets[n].normals[e]=i[e].clone()}for(let e=0,t=this.faces.length;e<t;e++){let t=this.faces[e],n=r.faceNormals[e],i=r.vertexNormals[e];n.copy(t.normal),i.a.copy(t.vertexNormals[0]),i.b.copy(t.vertexNormals[1]),i.c.copy(t.vertexNormals[2])}}for(let e=0,t=this.faces.length;e<t;e++){let t=this.faces[e];t.normal=t.__originalFaceNormal,t.vertexNormals=t.__originalVertexNormals}this.morphNormalsReady=!0},computeBoundingBox:function(){this.boundingBox===null&&(this.boundingBox=new e.Box3),this.boundingBox.setFromPoints(this.vertices)},computeBoundingSphere:function(){this.boundingSphere===null&&(this.boundingSphere=new e.Sphere),this.boundingSphere.setFromPoints(this.vertices)},mergeMorph:function(e,t){let n=this.morphTargets.length,r=this.morphTargets,i=e.morphTargets,a=this.morphColors.length,o=this.morphColors,s=e.morphColors;if(n>0&&n==i.length)for(let e=0,n=r.length;e<n;e++){let n=r[e],a=i[e];for(let e=0,r=a.vertices.length;e<r;e++){let r=a.vertices[e].clone();t!==void 0&&r.applyMatrix4(t),n.vertices.push(r)}if(n.normals&&a.normals)for(let e=0;e<a.normals.length;e+=3)_.set(a.normals2[e],a.normals2[e+1],a.normals2[e+2]),t!==void 0&&_.applyMatrix4(t),n.normals.push(_.x,_.y,_.z)}if(a>0&&a==s.length)for(let e=0,t=o.length;e<t;e++){let t=o[e],n=s[e];for(let e=0,r=n.colors;e<r;e++)t.colors.push(n.colors[e].clone())}},merge:function(t,n,r=0){if(!(t&&t.isGeometry)){console.error(`THREE.Geometry.merge(): geometry not an instance of THREE.Geometry.`,t);return}let i,a=this.vertices.length,o=this.vertices,s=t.vertices,c=t.normals,l=this.faces,u=t.faces,d=this.colors,f=t.colors;n!==void 0&&(i=new e.Matrix3().getNormalMatrix(n));for(let e=0,t=s.length;e<t;e++){let t=s[e].clone();n!==void 0&&t.applyMatrix4(n),o.push(t)}for(let e=0;e<c.length;e+=3)_.set(c[e],c[e+1],c[e+2]),n!==void 0&&_.applyMatrix4(n),this.normals.push(_.x,_.y,_.z);for(let e=0,t=f.length;e<t;e++)typeof f[e]==`number`?d.push(f[e]):d.push(f[e].clone());for(let e=0,t=u.length;e<t;e++){let t=u[e],n,o,s=t.vertexNormals,c=t.vertexColors,d=new b(t.a+a,t.b+a,t.c+a);d.normal.copy(t.normal),i!==void 0&&d.normal.applyMatrix3(i).normalize();for(let e=0,t=s.length;e<t;e++)n=s[e].clone(),i!==void 0&&n.applyMatrix3(i).normalize(),d.vertexNormals.push(n);d.color.copy(t.color);for(let e=0,t=c.length;e<t;e++)o=c[e],d.vertexColors.push(o.clone());d.materialIndex=t.materialIndex+r,l.push(d)}for(let e=0,n=t.faceVertexUvs.length;e<n;e++){let n=t.faceVertexUvs[e];this.faceVertexUvs[e]===void 0&&(this.faceVertexUvs[e]=[]);for(let t=0,r=n.length;t<r;t++){let r=n[t],i=[];for(let e=0,t=r.length;e<t;e++)i.push(r[e].clone());this.faceVertexUvs[e].push(i)}}this.mergeMorph(t,n)},mergeMesh:function(e){if(!(e&&e.isMesh)){console.error(`THREE.Geometry.mergeMesh(): mesh not an instance of THREE.Mesh.`,e);return}e.matrixAutoUpdate&&e.updateMatrix(),this.merge(e.geometry,e.matrix)},mergeVertices:function(e=4){let t={},n=[],r=[],i=10**e;for(let e=0,a=this.vertices.length;e<a;e++){let a=this.vertices[e],o=Math.round(a.x*i)+`_`+Math.round(a.y*i)+`_`+Math.round(a.z*i);t[o]===void 0?(t[o]=e,n.push(this.vertices[e]),r[e]=n.length-1):r[e]=r[t[o]]}let a=[];for(let e=0,t=this.faces.length;e<t;e++){let t=this.faces[e];t.a=r[t.a],t.b=r[t.b],t.c=r[t.c];let n=[t.a,t.b,t.c];for(let t=0;t<3;t++)if(n[t]===n[(t+1)%3]){a.push(e);break}}for(let e=a.length-1;e>=0;e--){let t=a[e];this.faces.splice(t,1);for(let e=0,n=this.faceVertexUvs.length;e<n;e++)this.faceVertexUvs[e].splice(t,1)}let o=this.vertices.length-n.length;return this.vertices=n,o},setFromPoints:function(t){this.vertices=[];for(let n=0,r=t.length;n<r;n++){let r=t[n];this.vertices.push(new e.Vector3(r.x,r.y,r.z||0))}return this},sortFacesByMaterialIndex:function(){let e=this.faces,t=e.length;for(let n=0;n<t;n++)e[n]._id=n;function n(e,t){return e.materialIndex-t.materialIndex}e.sort(n);let r=this.faceVertexUvs[0],i=this.faceVertexUvs[1],a,o;r&&r.length===t&&(a=[]),i&&i.length===t&&(o=[]);for(let n=0;n<t;n++){let t=e[n]._id;a&&a.push(r[t]),o&&o.push(i[t])}a&&(this.faceVertexUvs[0]=a),o&&(this.faceVertexUvs[1]=o)},toJSON:function(){let e={metadata:{version:4.5,type:`Geometry`,generator:`Geometry.toJSON`}};if(e.uuid=this.uuid,e.type=this.type,this.name!==``&&(e.name=this.name),this.parameters!==void 0){let t=this.parameters;for(let n in t)t[n]!==void 0&&(e[n]=t[n]);return e}let t=[];for(let e=0;e<this.vertices.length;e++){let n=this.vertices[e];t.push(n.x,n.y,n.z)}let n=[],r=[],i={},a=[],o={},s=[],c={};for(let e=0;e<this.faces.length;e++){let t=this.faces[e],r=this.faceVertexUvs[0][e]!==void 0,i=t.normal.length()>0,a=t.vertexNormals.length>0,o=t.color.r!==1||t.color.g!==1||t.color.b!==1,s=t.vertexColors.length>0,c=0;if(c=l(c,0,0),c=l(c,1,!0),c=l(c,2,!1),c=l(c,3,r),c=l(c,4,i),c=l(c,5,a),c=l(c,6,o),c=l(c,7,s),n.push(c),n.push(t.a,t.b,t.c),n.push(t.materialIndex),r){let t=this.faceVertexUvs[0][e];n.push(f(t[0]),f(t[1]),f(t[2]))}if(i&&n.push(u(t.normal)),a){let e=t.vertexNormals;n.push(u(e[0]),u(e[1]),u(e[2]))}if(o&&n.push(d(t.color)),s){let e=t.vertexColors;n.push(d(e[0]),d(e[1]),d(e[2]))}}function l(e,t,n){return n?e|1<<t:e&~(1<<t)}function u(e){let t=e.x.toString()+e.y.toString()+e.z.toString();return i[t]===void 0?(i[t]=r.length/3,r.push(e.x,e.y,e.z),i[t]):i[t]}function d(e){let t=e.r.toString()+e.g.toString()+e.b.toString();return o[t]===void 0?(o[t]=a.length,a.push(e.getHex()),o[t]):o[t]}function f(e){let t=e.x.toString()+e.y.toString();return c[t]===void 0?(c[t]=s.length/2,s.push(e.x,e.y),c[t]):c[t]}return e.data={},e.data.vertices=t,e.data.normals=r,a.length>0&&(e.data.colors=a),s.length>0&&(e.data.uvs=[s]),e.data.faces=n,e},clone:function(){return new v().copy(this)},copy:function(e){this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.name=e.name;let t=e.vertices;for(let e=0,n=t.length;e<n;e++)this.vertices.push(t[e].clone());let n=e.colors;for(let e=0,t=n.length;e<t;e++)this.colors.push(n[e].clone());let r=e.faces;for(let e=0,t=r.length;e<t;e++)this.faces.push(r[e].clone());for(let t=0,n=e.faceVertexUvs.length;t<n;t++){let n=e.faceVertexUvs[t];this.faceVertexUvs[t]===void 0&&(this.faceVertexUvs[t]=[]);for(let e=0,r=n.length;e<r;e++){let r=n[e],i=[];for(let e=0,t=r.length;e<t;e++){let t=r[e];i.push(t.clone())}this.faceVertexUvs[t].push(i)}}let i=e.morphTargets;for(let e=0,t=i.length;e<t;e++){let t={};if(t.name=i[e].name,i[e].vertices!==void 0){t.vertices=[];for(let n=0,r=i[e].vertices.length;n<r;n++)t.vertices.push(i[e].vertices[n].clone())}if(i[e].normals!==void 0){t.normals=[];for(let n=0,r=i[e].normals.length;n<r;n++)t.normals.push(i[e].normals[n].clone())}this.morphTargets.push(t)}let a=e.morphNormals;for(let e=0,t=a.length;e<t;e++){let t={};if(a[e].vertexNormals!==void 0){t.vertexNormals=[];for(let n=0,r=a[e].vertexNormals.length;n<r;n++){let r=a[e].vertexNormals[n],i={};i.a=r.a.clone(),i.b=r.b.clone(),i.c=r.c.clone(),t.vertexNormals.push(i)}}if(a[e].faceNormals!==void 0){t.faceNormals=[];for(let n=0,r=a[e].faceNormals.length;n<r;n++)t.faceNormals.push(a[e].faceNormals[n].clone())}this.morphNormals.push(t)}let o=e.skinWeights;for(let e=0,t=o.length;e<t;e++)this.skinWeights.push(o[e].clone());let s=e.skinIndices;for(let e=0,t=s.length;e<t;e++)this.skinIndices.push(s[e].clone());let c=e.lineDistances;for(let e=0,t=c.length;e<t;e++)this.lineDistances.push(c[e]);let l=e.boundingBox;l!==null&&(this.boundingBox=l.clone());let u=e.boundingSphere;return u!==null&&(this.boundingSphere=u.clone()),this.elementsNeedUpdate=e.elementsNeedUpdate,this.verticesNeedUpdate=e.verticesNeedUpdate,this.uvsNeedUpdate=e.uvsNeedUpdate,this.normalsNeedUpdate=e.normalsNeedUpdate,this.colorsNeedUpdate=e.colorsNeedUpdate,this.lineDistancesNeedUpdate=e.lineDistancesNeedUpdate,this.groupsNeedUpdate=e.groupsNeedUpdate,this},computeGroups(){let e=[],t,n,r,i=this.faces;for(n=0;n<i.length;n++){let a=i[n];a.materialIndex!==r&&(r=a.materialIndex,t!==void 0&&(t.count=n*3-t.start,e.push(t)),t={start:n*3,materialIndex:r})}return t!==void 0&&(t.count=n*3-t.start,e.push(t)),e},toBufferGeometry:function(){let t=new y().fromGeometry(this),n=new e.BufferGeometry,r=new Float32Array(t.vertices.length*3);if(n.setAttribute(`position`,new e.BufferAttribute(r,3).copyVector3sArray(t.vertices)),t.normals.length>0){let r=new Float32Array(t.normals.length*3);n.setAttribute(`normal`,new e.BufferAttribute(r,3).copyVector3sArray(t.normals))}if(t.colors.length>0){let r=new Float32Array(t.colors.length*3);n.setAttribute(`color`,new e.BufferAttribute(r,3).copyColorsArray(t.colors))}if(t.uvs.length>0){let r=new Float32Array(t.uvs.length*2);n.setAttribute(`uv`,new e.BufferAttribute(r,2).copyVector2sArray(t.uvs))}if(t.uvs2.length>0){let r=new Float32Array(t.uvs2.length*2);n.setAttribute(`uv2`,new e.BufferAttribute(r,2).copyVector2sArray(t.uvs2))}n.groups=t.groups;for(let r in t.morphTargets){let i=[],a=t.morphTargets[r];for(let t=0,n=a.length;t<n;t++){let n=a[t],r=new e.Float32BufferAttribute(n.data.length*3,3);r.name=n.name,i.push(r.copyVector3sArray(n.data))}n.morphAttributes[r]=i}if(t.skinIndices.length>0){let r=new e.Float32BufferAttribute(t.skinIndices.length*4,4);n.setAttribute(`skinIndex`,r.copyVector4sArray(t.skinIndices))}if(t.skinWeights.length>0){let r=new e.Float32BufferAttribute(t.skinWeights.length*4,4);n.setAttribute(`skinWeight`,r.copyVector4sArray(t.skinWeights))}return t.boundingSphere!==null&&(n.boundingSphere=t.boundingSphere.clone()),t.boundingBox!==null&&(n.boundingBox=t.boundingBox.clone()),n},toIndexedBufferGeometry:function(){let t=new e.BufferGeometry,n=new Float32Array(this.vertices.length*3);if(t.setAttribute(`position`,new e.BufferAttribute(n,3).copyVector3sArray(this.vertices)),this.normals.length>0){let n=new Float32Array(this.normals.length),r=new e.BufferAttribute(n,3).copyArray(this.normals);t.setAttribute(`normal`,r)}if(this.uvs.length>0&&this.uvs[0].length>0){let n=new Float32Array(this.uvs[0].length*2);t.setAttribute(`uv`,new e.BufferAttribute(n,2).copyArray(this.uvs[0]))}if(this.uvs.length>1&&this.uvs[1].length>0){let n=new Float32Array(this.uvs[1].length*2);t.setAttribute(`uv2`,new e.BufferAttribute(n,2).copyArray(this.uvs[1]))}if(this.colors.length>0){let n=[];for(let t=0;t<this.colors.length;t++)n.push(new e.Color(this.colors[t]));let r=new Float32Array(n.length*3);t.setAttribute(`color`,new e.BufferAttribute(r,3).copyColorsArray(n))}else{let n=new Float32Array(this.vertices.length*3);for(let e=0;e<this.vertices.length*3;e++)n[e]=1;t.setAttribute(`color`,new e.BufferAttribute(n,3))}if(this.faces.length>0){let e=[],n=[];for(let t=0;t<this.faces.length;t++){n.push(this.faces[t].a,this.faces[t].b,this.faces[t].c);let r=this.faces[t].vertexColors;if(r.length===3)e.push(r[0],r[1],r[2]);else{let n=this.faces[t].color;e.push(n,n,n)}}t.setIndex(n),t.groups=this.computeGroups()}if(this.morphTargets.length>0){let n=[],r=[];for(let t=0,i=this.morphTargets.length;t<i;t++){let i=this.morphTargets[t],a=new e.Float32BufferAttribute(i.vertices.length*3,3);if(a.name=i.name,n.push(a.copyVector3sArray(i.vertices)),i.normals){let t=new e.Float32BufferAttribute(i.normals.length*3,3);t.name=i.name,r.push(t.copyVector3sArray(i.normals))}}t.morphAttributes.position=n,t.morphAttributes.normal=r}if(this.skinIndices.length>0){let n=new e.Float32BufferAttribute(this.skinIndices.length*4,4);t.setAttribute(`skinIndex`,n.copyVector4sArray(this.skinIndices))}if(this.skinWeights.length>0){let n=new e.Float32BufferAttribute(this.skinWeights.length*4,4);t.setAttribute(`skinWeight`,n.copyVector4sArray(this.skinWeights))}return this.boundingSphere!==null&&(t.boundingSphere=this.boundingSphere.clone()),this.boundingBox!==null&&(t.boundingBox=this.boundingBox.clone()),t},computeTangents:function(){console.error(`THREE.Geometry: .computeTangents() has been removed.`)},computeLineDistances:function(){console.error(`THREE.Geometry: .computeLineDistances() has been removed. Use THREE.Line.computeLineDistances() instead.`)},applyMatrix:function(e){return console.warn(`THREE.Geometry: .applyMatrix() has been renamed to .applyMatrix4().`),this.applyMatrix4(e)},dispose:function(){this.dispatchEvent({type:`dispose`})}}),v.createBufferGeometryFromObject=function(t){let n=new e.BufferGeometry,r=t.geometry;if(t.isPoints||t.isLine){let t=new e.Float32BufferAttribute(r.vertices.length*3,3),i=new e.Float32BufferAttribute(r.colors.length*3,3);if(n.setAttribute(`position`,t.copyVector3sArray(r.vertices)),n.setAttribute(`color`,i.copyColorsArray(r.colors)),r.lineDistances&&r.lineDistances.length===r.vertices.length){let t=new e.Float32BufferAttribute(r.lineDistances.length,1);n.setAttribute(`lineDistance`,t.copyArray(r.lineDistances))}r.boundingSphere!==null&&(n.boundingSphere=r.boundingSphere.clone()),r.boundingBox!==null&&(n.boundingBox=r.boundingBox.clone())}else t.isMesh&&(n=r.toBufferGeometry());return n};var y=class{constructor(){this.vertices=[],this.normals=[],this.colors=[],this.uvs=[],this.uvs2=[],this.groups=[],this.morphTargets={},this.skinWeights=[],this.skinIndices=[],this.boundingBox=null,this.boundingSphere=null,this.verticesNeedUpdate=!1,this.normalsNeedUpdate=!1,this.colorsNeedUpdate=!1,this.uvsNeedUpdate=!1,this.groupsNeedUpdate=!1}computeGroups(e){let t=[],n,r,i,a=e.faces;for(r=0;r<a.length;r++){let e=a[r];e.materialIndex!==i&&(i=e.materialIndex,n!==void 0&&(n.count=r*3-n.start,t.push(n)),n={start:r*3,materialIndex:i})}n!==void 0&&(n.count=r*3-n.start,t.push(n)),this.groups=t}fromGeometry(t){let n=t.faces,r=t.vertices,i=t.faceVertexUvs,a=i[0]&&i[0].length>0,o=i[1]&&i[1].length>0,s=t.morphTargets,c=s.length,l;if(c>0){l=[];for(let e=0;e<c;e++)l[e]={name:s[e].name,data:[]};this.morphTargets.position=l}let u=t.morphNormals,d=u.length,f;if(d>0){f=[];for(let e=0;e<d;e++)f[e]={name:u[e].name,data:[]};this.morphTargets.normal=f}let p=t.skinIndices,m=t.skinWeights,h=p.length===r.length,g=m.length===r.length;r.length>0&&n.length===0&&console.error(`THREE.DirectGeometry: Faceless geometries are not supported.`);for(let t=0;t<n.length;t++){let _=n[t];this.vertices.push(r[_.a],r[_.b],r[_.c]);let v=_.vertexNormals;if(v.length===3)this.normals.push(v[0],v[1],v[2]);else{let e=_.normal;this.normals.push(e,e,e)}let y=_.vertexColors;if(y.length===3)this.colors.push(y[0],y[1],y[2]);else{let e=_.color;this.colors.push(e,e,e)}if(a===!0){let n=i[0][t];n===void 0?(console.warn(`THREE.DirectGeometry.fromGeometry(): Undefined vertexUv `,t),this.uvs.push(new e.Vector2,new e.Vector2,new e.Vector2)):this.uvs.push(n[0],n[1],n[2])}if(o===!0){let n=i[1][t];n===void 0?(console.warn(`THREE.DirectGeometry.fromGeometry(): Undefined vertexUv2 `,t),this.uvs2.push(new e.Vector2,new e.Vector2,new e.Vector2)):this.uvs2.push(n[0],n[1],n[2])}for(let e=0;e<c;e++){let t=s[e].vertices;l[e].data.push(t[_.a],t[_.b],t[_.c])}for(let e=0;e<d;e++){let n=u[e].vertexNormals[t];f[e].data.push(n.a,n.b,n.c)}h&&this.skinIndices.push(p[_.a],p[_.b],p[_.c]),g&&this.skinWeights.push(m[_.a],m[_.b],m[_.c])}return this.computeGroups(t),this.verticesNeedUpdate=t.verticesNeedUpdate,this.normalsNeedUpdate=t.normalsNeedUpdate,this.colorsNeedUpdate=t.colorsNeedUpdate,this.uvsNeedUpdate=t.uvsNeedUpdate,this.groupsNeedUpdate=t.groupsNeedUpdate,t.boundingSphere!==null&&(this.boundingSphere=t.boundingSphere.clone()),t.boundingBox!==null&&(this.boundingBox=t.boundingBox.clone()),this}},b=class{constructor(t,n,r,i,a,o=0){this.a=t,this.b=n,this.c=r,this.normal=i&&i.isVector3?i:new e.Vector3,this.vertexNormals=Array.isArray(i)?i:[],this.color=a&&a.isColor?a:new e.Color,this.vertexColors=Array.isArray(a)?a:[],this.materialIndex=o}clone(){return new this.constructor().copy(this)}copy(e){this.a=e.a,this.b=e.b,this.c=e.c,this.normal.copy(e.normal),this.color.copy(e.color),this.materialIndex=e.materialIndex;for(let t=0,n=e.vertexNormals.length;t<n;t++)this.vertexNormals[t]=e.vertexNormals[t].clone();for(let t=0,n=e.vertexColors.length;t<n;t++)this.vertexColors[t]=e.vertexColors[t].clone();return this}},x=`data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAAAZiS0dEAAAAAAAA+UO7fwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9sHDgwCEMBJZu0AAAAdaVRYdENvbW1lbnQAAAAAAENyZWF0ZWQgd2l0aCBHSU1QZC5lBwAABM5JREFUWMO1V0tPG2cUPZ4Hxh6DazIOrjFNqJs0FIMqWFgWQkatsmvVbtggKlSVRVf5AWz4AWz4AUSKEChll19QJYSXkECuhFxsHjEhxCYm+DWGMZ5HF72DJq4bAzFXurI0M/I5997v3u9cC65vTJVn2lX/xHINQOYSBLTLEuIuCWw4Z3IGAEvf6ASmVHjNzHCXBG4A0AjACsAOwEbO0nsFQBnAGYASAIl+ZRMR7SolMEdsByD09fV5R0ZGgg8ePPjW5/N1iqLYpuu6RZblciKR2I9Go69evnwZnZ+fjwI4IS8AKBIRzeQfJWCANwKwh0KhtrGxsYehUOin1tbW+zzP23ietzY2NnIAoGmaLsuyUiqVyvl8XtrY2NiamZn589mzZxsAUgCOAeQAnFI2tI+VxIjaAeDzoaGh7xYWFuZOTk6OZVk+12uYqqq6JEnn0Wg0OT4+/geAXwGEAdwDIFJQXC1wO4DWR48e/RCPxxclSSroVzRFUbSDg4P848ePFwH8DuAhkWih83TRQWxFOXgAwvDwcOfo6OhvXV1d39tsNtuVBwTDWBwOh1UUxVsMw1hXVlbSdCgNV43uYSvrHg6H24aHh38eHBz85TrgF9FYLHA4HLzH43FvbW2d7u/vG+dANp8FpqIlbd3d3V8Fg8EfBUFw4BONZVmL3+9vHhkZCQL4AoAHgJPK8G+yzC0XDofdoVAo5PP5vkadTBAEtr+/39ff3x8gAp/RPOEqx2qjx+NpvXv3bk9DQ0NDvQgwDIOWlhZrMBj8kgi0UJdxRgYMArzL5XJ7vd57qLPZ7Xamp6fnNgBXtQxcjFuHw+Hyer3t9SYgCAITCAScAJoBNNEY/08GOFVVrfVMv7kMNDntFD1vjIAPrlRN0xjckOm6biFQ3jwNPwDMZrOnqVTqfb3Bi8Wivru7W/VCYkwPlKOjo0IikXh7EwQikYgE4Nw0CfXKDCipVCoTj8df3QABbW1tLUc6oUgkFPMkVACUNjc337148eKvw8PDbJ2jP1taWkoCyNDVXDSECmNSK4qiKNLq6urW8+fPI/UicHx8rD59+jSVy+WOAKSJhKENwFItLtoxk8mwsixzHR0dHe3t7c5PAU+n09rs7OzJkydPYqVSaQfANoDXALIk31S2smU1TWMPDg7K5XKZ7+3t9TudTut1U7+wsFCcmJiIpdPpbQBxADsAknQWymYCOukBHYCuKApisdhpMpnURFEU79y503TVyKenpzOTk5M7e3t7MQKPV0Zv1gNm+awB0MvlshqLxfLb29uyJElWURSbXC4XXyvqxcXFs6mpqeTc3Nzu3t7e3wQcA7BPZ8Cov1pNlJplmQtAG8MwHV6v95tAINA5MDBwPxAIuLu6upr8fr/VAN3c3JQjkcjZ+vp6fnl5+d2bN29SuVzuNYAEpf01CdRChUL+X1VskHACuA3Ay3Fcu9vt7nA6nZ7m5uYWQRCaNE3jVVW15PP580KhIGUymWw2m00DOAJwSP4WwPtq4LX2Ao6USxNlQyS/RcQcdLGwlNIz6vEMAaZpNzCk2Pll94LK/cDYimxERiBwG10sxjgvEZBE0UpE6vxj+0Ct5bTaXthgEhRmja8QWNkkPGsuIpfdjpkK+cZUWTC0KredVmtD/gdlSl6EG4AMvQAAAABJRU5ErkJggg==`,S=t.default.default||t.default;function C(e,t){let n=(e,t)=>{try{let n=new URL(e,t).href;if(e&&e.split(`?`).length<2){let e=t.split(`?`);e.length===2&&(n=n+`?`+e[1])}return n}catch{console.error(`There is an issue creating the url link with: ${e}.`)}};if(Array.isArray(e)){let r=[];return e.forEach(e=>{r.push(n(e,t))}),r}return n(e,t)}function w(e,t,n,r,i){let a=e.morphTargetInfluences,o;e.geometry&&(o=e.geometry.morphAttributes);let s=!1;if(a&&o&&o.position){r.set(0,0,0),i.set(0,0,0);for(let e=0;e<a.length;e++)a[e]>0&&(s=!0,n.setFromArray(o.position[e].array),r.add(n.min.multiplyScalar(a[e])),i.add(n.max.multiplyScalar(a[e])));s&&t.set(r,i)}s||t.setFromBufferAttribute(e.geometry.attributes.position),e.updateWorldMatrix(!0,!0),t.applyMatrix4(e.matrixWorld)}function T(e,t,n,r){fetch(e).then(e=>{if(!e.ok)throw Error(`HTTP error! status: ${e.status}`);return e.text()}).then(e=>{n(e,t)}).catch(t=>{console.error(`Fetch string payload retrieval failed for: ${requestURL}`,t),r(e)})}function E(e,t,n){let r=e.length,i=0,a=[];function o(e,n){a[n]=e,i++,i==r&&t(a)}for(let t=0;t<r;t++)T(e[t],t,o,n)}var D=(t,n)=>{let r=Math.floor(n/3),i=n%3,a=0;i==0?a=t[r].r:i==1?a=t[r].g:i==2&&(a=t[r].b);let o=new e.Color(a);return[o.r,o.g,o.b]},O=function(e,t){if(t&&e&&e.morphAttributes&&e.morphAttributes.color){let n=e.morphAttributes.color,r=t.morphTargetInfluences,i=r.length;e.deleteAttribute(`morphColor0`),e.deleteAttribute(`morphColor1`);let a=0,o=[];for(let e=0;1>a||e<i;e++)r[e]>0&&(a++,o.push([e,r[e]]));o.length==2?(e.setAttribute(`morphColor0`,n[o[0][0]]),e.setAttribute(`morphColor1`,n[o[1][0]])):o.length==1&&(e.setAttribute(`morphColor0`,n[o[0][0]]),e.setAttribute(`morphColor1`,n[o[0][0]]))}},k=(t,n)=>{let r;return t instanceof v?(n.localTimeEnabled&&!t.morphNormalsReady&&(t.morphNormals==null||t.morphNormals.length==0)&&t.computeMorphNormals(),r=t.toIndexedBufferGeometry(),n.localMorphColour&&A(t,r)):t instanceof e.BufferGeometry&&(r=t.clone()),r.colorsNeedUpdate=!0,r.computeBoundingBox(),r.computeBoundingSphere(),t._video&&(r._video=t._video),r},A=(t,n)=>{if(t&&t.morphColors&&t.morphColors.length>0){let r=[],i=t.morphColors;for(let t=0,n=i.length;t<n;t++){let n=i[t],a=[];for(let e=0;e<n.colors.length*3;e++){let t=D(n.colors,e);a.push(t[0],t[1],t[2])}let o=new e.Float32BufferAttribute(a,3);o.name=n.name,r.push(o)}n.morphAttributes.color=r}};function j(t){let n,r,i,a=-1,o=0;for(let e=0;e<t.length;++e){let s=t[e];if(n===void 0&&(n=s.array.constructor),n!==s.array.constructor)return console.error(`THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.array must be of consistent array types across matching attributes.`),null;if(r===void 0&&(r=s.itemSize),r!==s.itemSize)return console.error(`THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes.`),null;if(i===void 0&&(i=s.normalized),i!==s.normalized)return console.error(`THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes.`),null;if(a===-1&&(a=s.gpuType),a!==s.gpuType)return console.error(`THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.gpuType must be consistent across matching attributes.`),null;o+=s.count*r}let s=new n(o),c=new e.BufferAttribute(s,r,i),l=0;for(let e=0;e<t.length;++e){let n=t[e];if(n.isInterleavedBufferAttribute){let e=l/r;for(let t=0,i=n.count;t<i;t++)for(let i=0;i<r;i++){let r=n.getComponent(t,i);c.setComponent(t+e,i,r)}}else s.set(n.array,l);l+=n.count*r}return a!==void 0&&(c.gpuType=a),c}var M=(t,n=!1)=>{let r=t[0].index!==null,i=new Set(Object.keys(t[0].attributes)),a=new Set(Object.keys(t[0].morphAttributes)),o={},s={},c=t[0].morphTargetsRelative,l=new e.BufferGeometry,u=0;for(let e=0;e<t.length;++e){let d=t[e],f=0;if(r!==(d.index!==null))return console.error(`THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index `+e+`. All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them.`),null;for(let t in d.attributes){if(!i.has(t))return console.error(`THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index `+e+`. All geometries must have compatible attributes; make sure "`+t+`" attribute exists among all geometries, or in none of them.`),null;o[t]===void 0&&(o[t]=[]),o[t].push(d.attributes[t]),f++}if(f!==i.size)return console.error(`THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index `+e+`. Make sure all geometries have the same number of attributes.`),null;if(c!==d.morphTargetsRelative)return console.error(`THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index `+e+`. .morphTargetsRelative must be consistent throughout all geometries.`),null;for(let t in d.morphAttributes){if(!a.has(t))return console.error(`THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index `+e+`. .morphAttributes must be consistent throughout all geometries.`),null;s[t]===void 0&&(s[t]=[]),s[t].push(d.morphAttributes[t])}if(n){let t;if(r)t=d.index.count;else if(d.attributes.position!==void 0)t=d.attributes.position.count;else return console.error(`THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index `+e+`. The geometry must have either an index or a position attribute`),null;l.addGroup(u,t,e),u+=t}}if(r){let e=0,n=[];for(let r=0;r<t.length;++r){let i=t[r].index;for(let t=0;t<i.count;++t)n.push(i.getX(t)+e);e+=t[r].attributes.position.count}l.setIndex(n)}for(let e in o){let t=j(o[e]);if(!t)return console.error(`THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the `+e+` attribute.`),null;l.setAttribute(e,t)}for(let e in s){let t=s[e][0].length;if(t===0)break;l.morphAttributes=l.morphAttributes||{},l.morphAttributes[e]=[];for(let n=0;n<t;++n){let t=[];for(let r=0;r<s[e].length;++r)t.push(s[e][r][n]);let r=j(t);if(!r)return console.error(`THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the `+e+` morphAttribute.`),null;l.morphAttributes[e].push(r)}}return l};function N(t,n){if(n&&t>=n.length){let r=new e.BufferGeometry,i=new Float32Array(t*3),a=0;return n.forEach(e=>{i[a++]=e[0],i[a++]=e[1],i[a++]=e[2]}),r.setAttribute(`position`,new e.BufferAttribute(i,3)),r.setDrawRange(0,n.length),r}}function P(){let t=new Image;t.src=x;let n=new e.Texture;return n.image=t,n.needsUpdate=!0,n}function F(e,t,n,r,i,a){let o=new S(e,t,n,r,i,a);return o.fontFace=r,o.fontSize=i,o.fontWeight=a,o.material.map.generateMipmaps=!1,o.material.map.anisotropy=4,o.material.sizeAttenuation=!1,o.material.alphaTest=.5,o.material.transparent=!0,o.material.depthWrite=!1,o.material.depthTest=!1,o.center.set(.5,-1.2),o.renderOrder=1e4,o}function I(e,t,n){if(n){let r=e||``,i=t||``,a=n.lastIndexOf(`/`);if(a>-1){let e,t;if(e=n.substring(0,a),t=n.substring(a+1),(e===`*`||e===`**`||e.toLowerCase()===r.toLowerCase())&&(t===`*`||t===`**`||t.toLowerCase()===i.toLowerCase()))return!0}else if(r.toLowerCase()===n.toLowerCase()||i.toLowerCase()===n.toLowerCase())return!0}return!1}function ee(t,n,r){let i=t.getAttribute(`position`),a=t.getAttribute(`normal`);if(!i)return;let o=i.itemSize,s=n*o,c=o,l=!1,u=(n,i)=>{let a=!1,l=Array.from(n.array);if(l.length>=s+c){l.splice(s,c),r&&l.concat(Array(c).fill(0)),a=!0;let n=new Float32Array(l);t.setAttribute(i,new e.BufferAttribute(n,o)),t.getAttribute(i).needsUpdate=!0}return a};return l=u(i,`position`),a&&u(a,`normal`),t.index!==null&&console.warn(`Removing vertices from indexed geometry requires index buffer recalculation.`),l}var L=function(){return function(e){e.vertexShader=e.vertexShader.replace(`#include <color_pars_vertex>`,[`varying vec3 vColor;`,`attribute vec3 morphColor0;`,`attribute vec3 morphColor1;`].join(`
2
+ `)),e.vertexShader=e.vertexShader.replace(`#include <color_vertex>`,[`vColor.xyz = color.xyz;`,`#ifdef USE_MORPHTARGETS`,`vColor = morphColor0 * morphTargetInfluences[ 0 ];`,`vColor += morphColor1 * morphTargetInfluences[ 1 ];`,`#endif`].join(`
3
+ `))}},te=new e.Vector3,R=new e.Vector3,ne=new e.Matrix4,re=new e.Ray,ie=new e.Sphere,ae=new e.Vector3,oe=new e.Vector3,se=new e.Vector3,ce=new e.Vector3,le=class extends e.Object3D{constructor(t=new e.BufferGeometry,n=new e.LineBasicMaterial){super(),this.type=`Line`,this.geometry=t,this.material=n,this.updateMorphTargets()}copy(e){return super.copy(e),this.material=e.material,this.geometry=e.geometry,this}computeLineDistances(){let t=this.geometry;if(t.isBufferGeometry){if(t.index===null){let n=t.attributes.position,r=[0];for(let e=1,t=n.count;e<t;e++)te.fromBufferAttribute(n,e-1),R.fromBufferAttribute(n,e),r[e]=r[e-1],r[e]+=te.distanceTo(R);t.setAttribute(`lineDistance`,new e.Float32BufferAttribute(r,1))}else console.warn(`THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.`)}else t.isGeometry&&console.error(`THREE.Line.computeLineDistances() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.`);return this}raycast(t,n){let r=this.geometry,i=this.matrixWorld,a=t.params.Line.threshold,o=r.drawRange,s=r.morphAttributes.position;if(r.boundingSphere===null&&r.computeBoundingSphere(),ie.copy(r.boundingSphere),ie.applyMatrix4(i),ie.radius+=a,t.ray.intersectsSphere(ie)===!1)return;ne.copy(i).invert(),re.copy(t.ray).applyMatrix4(ne);let c=a/((this.scale.x+this.scale.y+this.scale.z)/3),l=c*c,u=new e.Vector3,d=new e.Vector3,f=new e.Vector3,p=new e.Vector3,m=this.isLineSegments?2:1;if(r.isBufferGeometry){let e=r.index,i=r.attributes.position;if(e!==null){let r=Math.max(0,o.start),a=Math.min(e.count,o.start+o.count);for(let o=r,c=a-1;o<c;o+=m){let r=e.getX(o),a=e.getX(o+1);if(ue(u,d,this,i,s,r,a),re.distanceSqToSegment(u,d,p,f)>l)continue;p.applyMatrix4(this.matrixWorld);let c=t.ray.origin.distanceTo(p);c<t.near||c>t.far||n.push({distance:c,point:f.clone().applyMatrix4(this.matrixWorld),index:o,face:null,faceIndex:null,object:this})}}else{let e=Math.max(0,o.start),r=Math.min(i.count,o.start+o.count);for(let a=e,o=r-1;a<o;a+=m){if(ue(u,d,this,i,s,a,a+1),re.distanceSqToSegment(u,d,p,f)>l)continue;p.applyMatrix4(this.matrixWorld);let e=t.ray.origin.distanceTo(p);e<t.near||e>t.far||n.push({distance:e,point:f.clone().applyMatrix4(this.matrixWorld),index:a,face:null,faceIndex:null,object:this})}}}else r.isGeometry&&console.error(`THREE.Line.raycast() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.`)}updateMorphTargets(){let e=this.geometry;if(e.isBufferGeometry){let t=e.morphAttributes,n=Object.keys(t);if(n.length>0){let e=t[n[0]];if(e!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let t=0,n=e.length;t<n;t++){let n=e[t].name||String(t);this.morphTargetInfluences.push(0),this.morphTargetDictionary[n]=t}}}}else{let t=e.morphTargets;t!==void 0&&t.length>0&&console.error(`THREE.Line.updateMorphTargets() does not support THREE.Geometry. Use THREE.BufferGeometry instead.`)}}};function ue(e,t,n,r,i,a,o){e.fromBufferAttribute(r,a),t.fromBufferAttribute(r,o);var s=n.morphTargetInfluences;if(n.material.morphTargets&&i&&s){ae.set(0,0,0),oe.set(0,0,0);for(var c=0,l=i.length;c<l;c++){var u=s[c],d=i[c];u!==0&&(se.fromBufferAttribute(d,a),ce.fromBufferAttribute(d,o),ae.addScaledVector(se.sub(e),u),oe.addScaledVector(ce.sub(t),u))}e.add(ae),t.add(oe)}}le.prototype.isLine=!0;var de=new e.Vector3,fe=new e.Vector3,pe=class extends le{constructor(e,t){super(e,t),this.type=`LineSegments`}computeLineDistances(){let t=this.geometry;if(t.isBufferGeometry){if(t.index===null){let n=t.attributes.position,r=[];for(let e=0,t=n.count;e<t;e+=2)de.fromBufferAttribute(n,e),fe.fromBufferAttribute(n,e+1),r[e]=e===0?0:r[e-1],r[e+1]=r[e]+de.distanceTo(fe);t.setAttribute(`lineDistance`,new e.Float32BufferAttribute(r,1))}else console.warn(`THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.`)}else t.isGeometry&&console.error(`THREE.LineSegments.computeLineDistances() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.`);return this}};pe.prototype.isLineSegments=!0;var z=function(t){this.levels=[],this._currentLevel=0,this._renderOrder=1,this._material=void 0,this._secondaryMaterial=void 0,this._loader=void 0,this._parent=t,this.addLevel=(e,t)=>{if(e){let n=Math.abs(t),r;for(r=0;r<this.levels.length&&!(n<this.levels[r].distance);r++);let i={distance:n,morph:e,loaded:!0,loading:!1,url:``};this.levels.splice(r,0,i),e.renderOrder=this._renderOrder}},this.levelLoaded=(e,t)=>{if(e){let n=Math.abs(t);for(let t=0;t<this.levels.length;t++)if(n===this.levels[t].distance){this._parent.group.add(e),this.levels[t].morph=e,this.levels[t].loaded=!0,this.levels[t].loading=!1;break}this.checkTransparentMesh()}},this.addLevelFromURL=(e,t,n,r,i)=>{this._loader=e;let a=this.calculateDistance(t),o={distance:a,morph:void 0,loaded:!1,loading:!1,url:n,index:r},s;for(s=0;s<this.levels.length&&!(a<this.levels[s].distance);s++);this.levels.splice(s,0,o),i&&this.loadLevel(s)},this.loadLevel=e=>{let t=this.levels[e];return!t.morph&&!t.loaded&&!t.loading&&(t.loading=!0,this._loader.load(t.url,this.lodLoader(t.distance),void 0,void 0,{index:t.index})),t.morph===void 0},this.calculateDistance=function(e){this._parent.getBoundingBox();let t=this._parent.radius,n=0;return e===`far`?n=t*4.5:e===`medium`?n=t*2.5:e===`close`&&(n=0),n},this.containsLevels=()=>!!(this.levels&&this.levels.length>1),this.checkTransparentMesh=()=>{let t=this.levels[this._currentLevel];this._material&&(this._material.transparent?(this._secondaryMaterial||(this._secondaryMaterial=this._material.clone(),this._secondaryMaterial.side=e.FrontSide),this._secondaryMaterial.opacity=this._material.opacity,this._secondaryMaterial.emissive&&this._secondaryMaterial.emissive.copy(this._material.emissive),this._secondaryMaterial.needsUpdate=!0,t.secondaryMesh||(t.secondaryMesh=new e.Mesh(t.morph.geometry,this._secondaryMaterial),t.secondaryMesh.renderOrder=t.morph.renderOrder+1,t.secondaryMesh.userData=t.morph.userData,t.secondaryMesh.name=t.morph.name),this._material.side=e.BackSide,this._material.needsUpdate=!0,t.secondaryMesh.parent||(t.morph.add(t.secondaryMesh),this._parent.animationGroup&&this._parent.animationGroup.add(t.secondaryMesh))):(t.secondaryMesh&&(t.morph.remove(t.secondaryMesh),this._parent.animationGroup&&(this._parent.animationGroup.uncache(t.secondaryMesh),this._parent.animationGroup.remove(t.secondaryMesh))),this._material.side=e.DoubleSide,this._material.needsUpdate=!0))},this.dispose=()=>{this.levels.forEach(e=>{e.morph&&e.morph.geometry&&e.morph.geometry.dispose()}),this._material&&this._material.dispose(),this._secondaryMaterial&&this._secondaryMaterial.dispose()},this.getCurrentLevel=()=>this._currentLevel,this.getCurrentMorph=()=>{let e=this.levels[this._currentLevel];return e&&e.morph?e.morph:this._parent.morph},this.lodLoader=function(t){return n=>{let r=this._material,i=k(n,{localTimeEnabled:this._parent.timeEnabled,localMorphColour:this._parent.morphColour}),a;this._parent.isGeometry?a=new e.Mesh(i,r):this._parent.isLines&&(a=new pe(i,r)),a.userData=this._parent,a.renderOrder=this._renderOrder,n.dispose(),this.levelLoaded(a,t)}},this.updateMorphColorAttribute=t=>{if(this._material&&(this._material.vertexColors==e.VertexColors||this._material.vertexColors==1)){if(t){let e=this.getCurrentMorph();O(e.geometry,e)}else this.levels.forEach(e=>{e.morph&&e.morph.geometry&&O(e.morph.geometry,e.morph)})}},this.setColour=e=>{this._material.color=e,this._secondaryMaterial&&(this._secondaryMaterial.color=e),n()},this.setFrustumCulled=e=>{this.levels.forEach(t=>{t.morph&&(t.morph.frustumCulled=e),t.secondaryMesh&&(t.secondaryMesh.frustumCulled=e)})},this.setMaterial=t=>{t&&(!this._material||this._material.id!==t.id)&&(this._material=t,this._secondaryMaterial&&this._secondaryMaterial.dispose(),this._secondaryMaterial=t.clone(),this._secondaryMaterial.side=e.FrontSide,this._secondaryMaterial.transparent=!0,this.levels.forEach(e=>{e.morph&&(e.morph.material=this._material,e.morph.geometry&&(e.morph.geometry.colorsNeedUpdate=!0)),e.secondaryMesh&&(e.secondaryMesh.material=this._secondaryMaterial)}))},this.setName=e=>{this.levels.forEach(t=>{t.morph&&(t.morph.name=e),t.secondaryMesh&&(t.secondaryMesh.name=e)})},this.setRenderOrder=e=>{this._renderOrder=e,this.levels.forEach(t=>{t.morph&&(t.morph.renderOrder=e),t.secondaryMesh&&(t.secondaryMesh.renderOrder=e)})},this.setVertexColors=e=>{this._material.vertexColors=e,n(),this._secondaryMaterial&&(this._secondaryMaterial.vertexColors=e)},this.update=(e,t)=>{let n=this.levels;if(n.length>1){let r=e.cameraObject.position.distanceTo(t),i=-1,a=-1,o,s;for(o=0,s=n.length;o<s&&r>=n[o].distance;o++)n[o].morph?(i>-1&&n[i].morph&&(n[i].morph.visible=!1),i=o,n[o].morph.visible=!0,a=-1):a=o;for(a>-1&&this.loadLevel(a);o<s;o++)n[o].morph&&(i>-1?n[o].morph.visible=!1:(n[o].morph.visible=!0,i=o));this._currentLevel!=i&&(this._currentLevel=i,this.checkTransparentMesh())}},this.toggleMarker=(e,t)=>{this.levels.forEach(n=>{n.morph&&(t?n.morph.add(e):n.morph.remove(e))})};let n=()=>{this.levels.forEach(e=>{e.morph&&e.morph.geometry&&(e.morph.geometry.colorsNeedUpdate=!0)})}},me=`data:image/svg+xml,%3c?xml%20version='1.0'%20encoding='UTF-8'%20standalone='no'%20?%3e%3c!DOCTYPE%20svg%20PUBLIC%20'-//W3C//DTD%20SVG%201.1//EN'%20'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'%3e%3csvg%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20version='1.1'%20width='365'%20height='560'%20viewBox='0%200%20365%20560'%20xml:space='preserve'%3e%3cdesc%3eCreated%20with%20Fabric.js%205.2.4%3c/desc%3e%3cdefs%3e%3c/defs%3e%3crect%20x='0'%20y='0'%20width='100%25'%20height='100%25'%20fill='transparent'%3e%3c/rect%3e%3cg%20transform='matrix(0%200%200%200%200%200)'%20id='808ed283-2524-440f-88ae-3bdb47bb5749'%20%3e%3c/g%3e%3cg%20transform='matrix(1%200%200%201%20182.5%20280)'%20id='db30413d-5bff-4b98-ab59-464497ee199e'%20%3e%3crect%20style='stroke:%20none;%20stroke-width:%201;%20stroke-dasharray:%20none;%20stroke-linecap:%20butt;%20stroke-dashoffset:%200;%20stroke-linejoin:%20miter;%20stroke-miterlimit:%204;%20fill:%20rgb(255,255,255);%20fill-rule:%20nonzero;%20opacity:%201;%20visibility:%20hidden;'%20vector-effect='non-scaling-stroke'%20x='-182.5'%20y='-280'%20rx='0'%20ry='0'%20width='365'%20height='560'%20/%3e%3c/g%3e%3cg%20transform='matrix(0%200%200%200%200%2097.5)'%20%3e%3cg%20style=''%20%3e%3c/g%3e%3c/g%3e%3cg%20transform='matrix(0%200%200%200%200%2097.5)'%20%3e%3cg%20style=''%20%3e%3c/g%3e%3c/g%3e%3cg%20transform='matrix(0.99%200%200%200.99%20182.5%20280)'%20%3e%3cg%20style=''%20vector-effect='non-scaling-stroke'%20%3e%3cg%20transform='matrix(1%200%200%201%200%200)'%20%3e%3crect%20style='stroke:%20none;%20stroke-width:%201;%20stroke-dasharray:%20none;%20stroke-linecap:%20butt;%20stroke-dashoffset:%200;%20stroke-linejoin:%20miter;%20stroke-miterlimit:%204;%20fill:%20rgb(255,255,255);%20fill-rule:%20nonzero;%20opacity:%201;%20visibility:%20hidden;'%20vector-effect='non-scaling-stroke'%20x='-540'%20y='-540'%20rx='0'%20ry='0'%20width='1080'%20height='1080'%20/%3e%3c/g%3e%3cg%20transform='matrix(1%200%200%201%200%200)'%20%3e%3cpath%20style='stroke:%20rgb(0,0,0);%20stroke-width:%200;%20stroke-dasharray:%20none;%20stroke-linecap:%20butt;%20stroke-dashoffset:%200;%20stroke-linejoin:%20miter;%20stroke-miterlimit:%204;%20fill:%20rgb(0,89,116);%20fill-rule:%20nonzero;%20opacity:%201;'%20vector-effect='non-scaling-stroke'%20transform='%20translate(-182.9,%20-279.85)'%20d='M%20182.9%20551.7%20C%20182.9%20551.8000000000001%20183.1%20552%20183.1%20552%20C%20183.1%20552%20358.3%20283%20358.3%20194.6%20C%20358.3%2064.5%20269.5%207.900000000000006%20182.9%207.699999999999989%20C%2096.3%207.9%207.5%2064.5%207.5%20194.6%20C%207.5%20283%20182.8%20552%20182.8%20552%20C%20182.8%20552%20182.9%20551.7%20182.9%20551.7%20z%20M%20122.2%20187.2%20C%20122.2%20153.6%20149.4%20126.39999999999999%20183%20126.39999999999999%20C%20216.6%20126.39999999999999%20243.8%20153.6%20243.8%20187.2%20C%20243.8%20220.79999999999998%20216.5%20248%20182.9%20248%20C%20149.4%20248%20122.2%20220.8%20122.2%20187.2%20z'%20stroke-linecap='round'%20/%3e%3c/g%3e%3cg%20transform='matrix(3.82%200%200%203.82%200%20-100.77)'%20%3e%3ccircle%20style='stroke:%20rgb(0,0,0);%20stroke-width:%200;%20stroke-dasharray:%20none;%20stroke-linecap:%20butt;%20stroke-dashoffset:%200;%20stroke-linejoin:%20miter;%20stroke-miterlimit:%204;%20fill:%20rgb(255,255,255);%20fill-rule:%20nonzero;%20opacity:%201;'%20vector-effect='non-scaling-stroke'%20cx='0'%20cy='0'%20r='35'%20/%3e%3c/g%3e%3c/g%3e%3c/g%3e%3c/svg%3e`,he=new Image(128,128);he.src=me;var ge=new e.Texture;ge.image=he,ge.needsUpdate=!0;var _e=[.02,.03,1],ve=new e.SpriteMaterial({map:ge,alphaTest:.5,transparent:!0,depthTest:!1,depthWrite:!1,sizeAttenuation:!1}),ye=function(t){Object.getPrototypeOf(this)!==B.prototype&&Object.setPrototypeOf(ye.prototype,B.prototype),B.call(this),this.texture=ge;let n,r,i,a,o,s=!0;this.morph=new e.Group,this.group=this.morph,this.parent=t,this.isMarker=!0;let c=!1;this.ndc=new e.Vector3;let l,u,d=()=>{n=new e.Sprite(ve),n.center.set(.5,0),this.morph.add(n),this.morph.position.set(0,0,0),this.morph.renderOrder=1e4,n.scale.set(_e[0],_e[1],_e[2]),n.userData=this};this.updateVisual=(e,t)=>{let n=1,r=0;e!==t&&(r=1-(this.ndc.z-e)/(t-e),n=.6+r*.4),this.setSpriteSize(n)},this.updateNDC=e=>(this.ndc.copy(this.morph.position),this.ndc.project(e),this.ndc.z=Math.min(Math.max(this.ndc.z,0),1),this.ndc),this.setPosition=(e,t,n)=>{this.morph.position.set(e,t,n)},this.setSpriteSize=e=>{n.scale.set(.015,.02,1),n.scale.multiplyScalar(e)},this.setUserSprite=()=>{a&&(this.morph.add(a),s&&=(this.morph.remove(n),u&&this.morph.remove(u),!1))},this.setImageForUserSprite=(t,n)=>{a&&=(this.morph.remove(a),void 0),r&&r.dispose(),i&&i.dispose(),r=new e.Texture,r.image=t,r.needsUpdate=!0,i=new e.SpriteMaterial({map:r,alphaTest:.5,transparent:!0,depthTest:!1,depthWrite:!1,sizeAttenuation:!1}),n||=[.05,.05,1],a=new e.Sprite(i),a.center.set(.5,0),a.scale.set(n[0],n[1],n[2]),a.userData=this,this.setUserSprite()},this.setDefaultSprite=()=>{s||(s=!0,this.morph.add(n),a&&this.morph.remove(a),u&&this.morph.add(u))},this.loadUserSprite=(e,t)=>{if(e){if(e!==o){o=e;let n=new Image(128,128);n.crossOrigin=`anonymous`,n.onload=()=>{this.setImageForUserSprite(n,t)},n.src=e}else this.setUserSprite()}},this.dispose=()=>{this.morph&&this.morph.clear(),n&&=(n.clear(),void 0),u&&=(u.material.map.dispose(),u.material.dispose(),void 0)},this.isEnabled=()=>c,this.setNumber=e=>{(!e||l!=e)&&(u&&=(this.morph.remove(u),u.material.map.dispose(),u.material.dispose(),void 0)),!u&&e&&(u=F(e,.012,`black`,`Asap`,120,700),this.morph.add(u)),l=e},this.getNumber=()=>l||1,this.setVisibility=function(e){e!==this.visible&&(this.visible=e,this.group.visible=e,this.parent.region&&(this.parent.region.pickableUpdateRequired=!0))},this.enable=()=>{c=!0,this.morph.visible=!0,this.visible=!0},this.disable=()=>{c=!1,this.morph.visible=!1,this.visible=!1},d()},be=0,xe=function(){return`pr`+be++},B=function(){this.isZincObject=!0,this.geometry=void 0,this.morph=void 0,this.group=new e.Group,this._lod=new z(this),this.groupName=void 0,this.timeEnabled=!1,this.morphColour=!1,this.inbuildTime=0,this.mixer=void 0,this.animationGroup=void 0,this.duration=6e3,this.clipAction=void 0,this.userData={},this.videoHandler=void 0,this.marker=void 0,this.markerNumber=void 0,this.markerUpdateRequired=!0,this.closestVertexIndex=-1,this.boundingBoxUpdateRequired=!0,this.cachedBoundingBox=new e.Box3,this.anatomicalId=void 0,this.region=void 0,this.animationClip=void 0,this.markerMode=`inherited`,this.uuid=xe(),this._v1=new e.Vector3,this._v2=new e.Vector3,this._b1=new e.Box3,this.center=new e.Vector3,this.radius=0,this.visible=!0,this.drawRange=-1,this.origColour=void 0,this.origVertexColors=!1,this.isPickable=!0};B.prototype.setDuration=function(e){this.duration=e,this.clipAction&&this.clipAction.setDuration(this.duration)},B.prototype.getDuration=function(){return this.duration},B.prototype.setRegion=function(e){this.region=e},B.prototype.getRegion=function(){return this.region},B.prototype.getMorph=function(){return this._lod.getCurrentMorph()||this.morph},B.prototype.getGroup=function(){return this.group},B.prototype.setMorph=function(e){this.morph=e,this.group.add(this.morph);let t=this._lod.calculateDistance(`far`);this._lod.addLevel(e,t),this._lod.setMaterial(e.material)},B.prototype.checkTransparentMesh=function(){},B.prototype.setMesh=function(t,n,r){this.animationGroup=new e.AnimationObjectGroup(t),this.mixer=new e.AnimationMixer(this.animationGroup);let i=t.geometry;if(this.geometry=t.geometry,this.clipAction=void 0,i&&i.morphAttributes){let t=i.morphAttributes.position;t||=i.morphAttributes.color?i.morphAttributes.color:i.morphAttributes.normal,t&&(this.animationClip=e.AnimationClip.CreateClipsFromMorphTargetSequences(t,10,!0),this.animationClip&&this.animationClip[0]!=null&&(this.clipAction=this.mixer.clipAction(this.animationClip[0]).setDuration(this.duration),this.clipAction.loop=e.LoopRepeat,this.clipAction.clampWhenFinished=!0,this.clipAction.play()))}this.timeEnabled=n,this.morphColour=r,t.userData=this,t.matrixAutoUpdate=!1,this.setMorph(t),this.checkTransparentMesh(),this.timeEnabled?this.setFrustumCulled(!1):this.morphColour&&(i.setAttribute(`morphTarget0`,i.getAttribute(`position`)),i.setAttribute(`morphTarget1`,i.getAttribute(`position`))),this.boundingBoxUpdateRequired=!0},B.prototype.setIsPickable=function(e){this.isPickable!==e&&(this.isPickable=e,this.region&&(this.region.pickableUpdateRequired=!0))},B.prototype.setAnatomicalId=function(e){this.anatomicalId=e},B.prototype.setName=function(e){this.groupName=e,this._lod.setName(e)},B.prototype.getCurrentTime=function(){if(this.clipAction){let e=this.clipAction.time/this.clipAction._clip.duration;return this.duration*e}return this.inbuildTime},B.prototype.setMorphTime=function(e){let t=!1;if(this.clipAction){let n=e/this.duration*this.clipAction._clip.duration;n!=this.clipAction.time&&(this.clipAction.time=n,t=!0),t&&this.isTimeVarying()&&this.mixer.update(0)}else{let n=e;n=e>this.duration?this.duration:0>e?0:e,n!=this.inbuildTime&&(this.inbuildTime=n,t=!0)}t&&(this.boundingBoxUpdateRequired=!0,this._lod.updateMorphColorAttribute(!0),this.timeEnabled&&(this.markerUpdateRequired=!0))},B.prototype.isTimeVarying=function(){return!!(this.timeEnabled||this.morphColour)},B.prototype.getVisibility=function(){return this.visible},B.prototype.setVisibility=function(e){e!==this.visible&&(this.visible=e,this.group.visible=e,this.region&&(this.region.pickableUpdateRequired=!0))},B.prototype.setAlpha=function(e){let t=this._lod._material,n=!1;e<1&&(n=!0),t.opacity=e,t.transparent=n,this.checkTransparentMesh()},B.prototype.setFrustumCulled=function(e){this._lod.setFrustumCulled(e)},B.prototype.setVertexColors=function(e){this._lod.setVertexColors(e)},B.prototype.getColour=function(){if(this._lod._material)return this._lod._material.color},B.prototype.setColour=function(e){this._lod.setColour(e)},B.prototype.setGreyScale=function(t){if(t){if(!this.origColour&&this._lod._material)return this.origColour=this._lod._material.color,this.origVertexColors=this._lod._material.vertexColors,this._lod.setVertexColors(!1),this._lod.setColour(new e.Color().setHex(12303291)),!0}else if(this.origColour)return this._lod.setColour(this.origColour),this._lod.setVertexColors(this.origVertexColors),this.origColour=void 0,!0;return!1},B.prototype.getColourHex=function(){if(!this.morphColour&&this._lod._material&&this._lod._material.color)return this._lod._material.color.getHexString()},B.prototype.setColourHex=function(e){this._lod._material.color.setHex(e),this._lod._secondaryMaterial&&this._lod._secondaryMaterial.color.setHex(e)},B.prototype.setEmissiveRGB=function(e){this._lod._material&&this._lod._material.emissive&&this._lod._material.emissive.setRGB(...e),this._lod._secondaryMaterial&&this._lod._secondaryMaterial.emissive.setRGB(...e)},B.prototype.setMaterial=function(e){this._lod.setMaterial(e)},B.prototype.getClosestVertexIndex=function(){let e=-1,t=this.getMorph();if(t&&t.geometry){let n=t.geometry.attributes.position;if(n){this._b1.setFromBufferAttribute(n),this._b1.getCenter(this._v1);let t=-1,r=0;for(let i=0;i<n.count;i++)this._v2.fromArray(n.array,i*3),r=this._v2.distanceTo(this._v1),t==-1?t=r:t>r&&(t=r,e=i)}}return e},B.prototype.getClosestVertex=function(t){let n=new e.Vector3;this.closestVertexIndex==-1&&(this.closestVertexIndex=this.getClosestVertexIndex());let r=this.getMorph();if(r&&r.geometry&&this.closestVertexIndex>=0){let e=r.morphTargetInfluences,i=r.geometry.morphAttributes;if(e&&i&&i.position){let a=!1;for(let t=0;t<e.length;t++)e[t]>0&&(a=!0,this._v1.fromArray(i.position[t].array,this.closestVertexIndex*3),n.add(this._v1.multiplyScalar(e[t])));if(a)return t?n.applyMatrix4(r.matrixWorld):n}else return n.fromArray(r.geometry.attributes.position.array,this.closestVertexIndex*3),t?n.applyMatrix4(r.matrixWorld):n}return this.getBoundingBox(),n.copy(this.center),n},B.prototype.getBoundingBox=function(){if(this.visible){let e=this._lod.getCurrentMorph();if(e&&e.visible)return this.boundingBoxUpdateRequired&&=(w(e,this.cachedBoundingBox,this._b1,this._v1,this._v2),this.cachedBoundingBox.getCenter(this.center),this.radius=this.center.distanceTo(this.cachedBoundingBox.max),!1),this.cachedBoundingBox}},B.prototype.dispose=function(){this._lod.dispose(),this.animationGroup=void 0,this.mixer=void 0,this.morph=void 0,this.group=void 0,this.clipAction=void 0,this.groupName=void 0},B.prototype.markerIsRequired=function(e){return!!(this.visible&&(this.markerMode===`on`||e&&e.displayMarkers&&this.markerMode===`inherited`))},B.prototype.updateMarker=function(e,t){if(e==0&&this.markerIsRequired(t)){let e=t.ndcToBeUpdated;if(this.groupName){if(this.marker||(this.marker=new ye(this),this.markerUpdateRequired=!0),this.markerUpdateRequired){let e=this.getClosestVertex(!1);e&&(this.marker.setPosition(e.x,e.y,e.z),this.markerUpdateRequired=!1)}this.marker.isEnabled()||(t.markersList&&!(this.marker.uuid in t.markersList)&&(e=!0,t.markersList[this.marker.uuid]=this.marker),this.marker.enable(),this.group.add(this.marker.morph)),this.marker.setNumber(this.markerNumber),this.markerImgURL?this.marker.loadUserSprite(this.markerImgURL):this.marker.setDefaultSprite(),t&&t.camera&&(e||t.markerCluster.markerUpdateRequired)&&(this.marker.updateNDC(t.camera.cameraObject),t.markerCluster.markerUpdateRequired=!0)}}else this.marker&&this.marker.isEnabled()&&(this.marker.disable(),this.group.remove(this.marker.morph),t.markersList&&this.marker.uuid in t.markersList&&(t.markerCluster.markerUpdateRequired=!0,delete t.markersList[this.marker.uuid])),this.markerUpdateRequired=!0},B.prototype.processMarkerVisual=function(e,t){this.marker&&this.marker.isEnabled()&&this.marker.updateVisual(e,t)},B.prototype.initiateMorphColor=function(){this.morphColour==1&&this._lod.updateMorphColorAttribute(!1)},B.prototype.setRenderOrder=function(e){this._lod.setRenderOrder(e)},B.prototype.getClosestVertexDOMElementCoords=function(e){if(e&&e.camera){let t=!0,n=this.getClosestVertex(!0);return n.project(e.camera),n.z=Math.min(Math.max(n.z,0),1),(n.x>1||n.x<-1||n.y>1||n.y<-1)&&(t=!1),e.getZincCameraControls().getRelativeCoordsFromNDC(n.x,n.y,n),{position:n,inView:t}}},B.prototype.setMarkerMode=function(e,t){e!==this.markerMode&&(this.markerMode=e===`on`||e===`off`?e:`inherited`,this.region&&(this.region.pickableUpdateRequired=!0)),t&&(this.markerNumber=t.number,this.markerImgURL=t.imgURL)},B.prototype.render=function(e,t,n,r){if(this.visible&&!(this.timeEnabled&&t)&&this._lod.update(n,this.center),t==1){if(this.clipAction&&this.isTimeVarying())this.mixer.update(e);else{let t=this.inbuildTime+e;t>this.duration&&(t-=this.duration),this.inbuildTime=t}this.visible&&e!=0&&(this.boundingBoxUpdateRequired=!0,this.morphColour==1&&this._lod.updateMorphColorAttribute(!0))}this.updateMarker(t,r)},B.prototype.addLOD=function(e,t,n,r,i){this._lod.addLevelFromURL(e,t,n,r,i)},B.prototype.addVertices=function(e){let t=this.getMorph(),n;if(!t)n=N(500,e),this.drawRange=e.length;else if(this.drawRange>-1){let r=t.geometry.getAttribute(`position`);e.forEach(e=>{r.setXYZ(this.drawRange,e[0],e[1],e[2]),++this.drawRange}),r.needsUpdate=!0,t.geometry.setDrawRange(0,this.drawRange),t.geometry.computeBoundingBox(),t.geometry.computeBoundingSphere(),n=t.geoemtry,this.boundingBoxUpdateRequired=!0}return n},B.prototype.deleteVertices=function(e){let t=this.getMorph();return t?.geometry&&this.drawRange>=e&&ee(t.geometry,e,!0)?(--this.drawRange,t.geometry.setDrawRange(0,this.drawRange),t.geometry.computeBoundingBox(),t.geometry.computeBoundingSphere(),this.boundingBoxUpdateRequired=!0,!0):!1},B.prototype.setPosition=function(e,t,n){let r=this.getGroup();r&&(r.position.set(e,t,n),r.matrixWorldNeedsUpdate=!0,r.updateMatrix(),r.updateWorldMatrix(!0,!0),this.boundingBoxUpdateRequired=!0)},B.prototype.loadAdditionalSources=function(e,t){e.load(filename,meshloader(region,colour,opacity,localTimeEnabled,localMorphColour,void 0,void 0,void 0,void 0,finishCallback),this.onProgress(filename),this.onError(finishCallback))},B.prototype.setScaleAll=function(e){let t=this.getGroup();t&&(t.scale.set(e,e,e),t.updateMatrix(),this.boundingBoxUpdateRequired=!0)};var Se=(t,n,r)=>{let i=k(t,r),a=!1;1>r.opacity&&(a=!0);let o;if(i._video===void 0){let t=r.localTimeEnabled||r.localMorphColour;n?(o=n,o.morphTargets=t,o.morphNormals=r.localTimeEnabled):o=i instanceof e.BufferGeometry&&i.attributes.color===void 0?new e.MeshPhongMaterial({color:r.colour,morphTargets:t,morphNormals:r.localTimeEnabled,transparent:a,opacity:r.opacity,side:e.DoubleSide}):new e.MeshPhongMaterial({color:r.colour,morphTargets:t,morphNormals:r.localTimeEnabled,vertexColors:e.VertexColors,transparent:a,opacity:r.opacity,side:e.DoubleSide}),r.localMorphColour&&i.morphAttributes.color&&(o.onBeforeCompile=L())}else{let t=i._video.createCanvasVideoTexture();o=new e.MeshBasicMaterial({morphTargets:r.localTimeEnabled,color:new e.Color(1,1,1),transparent:a,opacity:r.opacity,map:t,side:e.DoubleSide}),(void 0).videoHandler=i._video}return new e.Mesh(i,o)},Ce=function(){B.call(this),this.videoHandler=void 0,this.isGeometry=!0,this.createMesh=(e,t,n)=>{if(this.morph&&this.morph.geometry&&e!=null)return;let r=Se(e,t,n);this.setMesh(r,n.localTimeEnabled,n.localMorphColour)},this.calculateUVs=()=>{this.geometry.computeBoundingBox();let t=this.geometry.boundingBox.max,n=this.geometry.boundingBox.min,r=new e.Vector2(0-n.x,0-n.y),i=new e.Vector2(t.x-n.x,t.y-n.y);this.geometry.faceVertexUvs[0]=[];for(let t=0;t<this.geometry.faces.length;t++){let n=this.geometry.vertices[this.geometry.faces[t].a],a=this.geometry.vertices[this.geometry.faces[t].b],o=this.geometry.vertices[this.geometry.faces[t].c];geometry.faceVertexUvs[0].push([new e.Vector2((n.x+r.x)/i.x,(n.y+r.y)/i.y),new e.Vector2((a.x+r.x)/i.x,(a.y+r.y)/i.y),new e.Vector2((o.x+r.x)/i.x,(o.y+r.y)/i.y)])}geometry.uvsNeedUpdate=!0},this.checkTransparentMesh=function(){this._lod.checkTransparentMesh()},this.setWireframe=e=>{this.morph.material.wireframe=e},this.editVertices=function(e,t){if(e&&e.length){let n=this.getMorph(),r=n.geometry.getAttribute(`position`);if(!n||0>t)return;{let i=t*3;e.forEach(e=>{r.array[i++]=e[0],r.array[i++]=e[1],r.array[i++]=e[2]}),r.needsUpdate=!0,n.geometry.computeBoundingBox(),n.geometry.computeBoundingSphere(),this.boundingBoxUpdateRequired=!0}}}};Ce.prototype=Object.create(B.prototype);var we=t.default.default||t.default,Te=function(e,t){let n=e,r,i=500;r=t?new we(n,.012,t.getStyle()):new we(n,.012),r.fontFace=`Asap`,r.fontWeight=i,r.material.map.generateMipmaps=!1,r.material.sizeAttenuation=!1,r.center.x=-.05,r.center.y=0;let a=[r.scale.x,r.scale.y];this.getPosition=()=>r?[r.position.x,r.position.y,r.position.z]:[0,0,0],this.setPosition=(e,t,n)=>{r&&r.position.set(e,t,n)},this.setColour=e=>{e&&(r.color=e.getStyle())},this.setScale=e=>{r&&e>0&&r.scale.set(e,e,1)},this.setDepthTest=e=>{e&&e!==r.material.depthTest&&(r.material.depthTest=e)},this.setSize=e=>{e>0&&(r.scale.x=a[0]*e,r.scale.y=a[1]*e)},this.setFontWeight=e=>{e&&e!==i&&(r.fontWeight=e,i=e)},this.setText=e=>{e&&e!==r.text&&(r.text=e,n=e)},this.setVisibility=e=>{r.visible=e},this.dispose=()=>{},this.getSprite=()=>r,this.getString=()=>n},Ee=function(t,n,r,i){B.call(this);let a;n&&(a=n.clone(),a.vertexColors=e.FaceColors);let o=i;this.id=r;let s,c;this.isGlyph=!0;let l=[0,0,0];this.fromMesh=e=>e&&e.isMesh?(this.morph=e.clone(),this.morph.userData=this,this.group.add(this.morph),!0):!1,t&&a&&this.fromMesh(new e.Mesh(t,a)),this.getGlyphset=function(){return o},this.setLabel=e=>{e&&(typeof e==`string`||e instanceof String)&&(c=e,this.morph&&(this.morph.name=e))},this.showLabel=e=>{if(s&&=(l=s.getPosition(),this.group.remove(s.getSprite()),s.dispose(),void 0),c&&(typeof c==`string`||c instanceof String)){s=new Te(c,e),s.setPosition(l[0],l[1],l[2]);let t=s.getSprite();t.material.alphaTest=.5,t.material.transparent=!0,t.material.depthWrite=!1,this.group.add(s.getSprite())}},this.hideLabel=()=>{s&&=(l=s.getPosition(),this.group.remove(s.getSprite()),s.dispose(),void 0)},this.getLabel=()=>c,this.getMesh=()=>this.morph,this.setTransformation=(e,t,n,r)=>{this.morph&&(this.morph.matrix.elements[0]=t[0],this.morph.matrix.elements[1]=t[1],this.morph.matrix.elements[2]=t[2],this.morph.matrix.elements[3]=0,this.morph.matrix.elements[4]=n[0],this.morph.matrix.elements[5]=n[1],this.morph.matrix.elements[6]=n[2],this.morph.matrix.elements[7]=0,this.morph.matrix.elements[8]=r[0],this.morph.matrix.elements[9]=r[1],this.morph.matrix.elements[10]=r[2],this.morph.matrix.elements[11]=0,this.morph.matrix.elements[12]=e[0],this.morph.matrix.elements[13]=e[1],this.morph.matrix.elements[14]=e[2],this.morph.matrix.elements[15]=1,this.morph.matrixAutoUpdate=!1),l=[...e],s&&s.setPosition(e[0],e[1],e[2])},this.setColour=e=>{s&&s.setColour(e),this.secondaryMesh&&this.secondaryMesh.material&&(this.secondaryMesh.material.color=colour),this.geometry&&(this.geometry.colorsNeedUpdate=!0)},this.dispose=()=>{this.material&&this.material.dispose(),this.morph=void 0}};Ee.prototype=Object.create(B.prototype);function De(){}De.Handlers={handlers:[],add:function(e,t){this.handlers.push(e,t)},get:function(e){for(var t=this.handlers,n=0,r=t.length;n<r;n+=2){var i=t[n],a=t[n+1];if(i.test(e))return a}return null}},Object.assign(De.prototype,{crossOrigin:`anonymous`,onLoadStart:function(){},onLoadProgress:function(){},onLoadComplete:function(){},initMaterials:function(e,t,n){for(var r=[],i=0;i<e.length;++i)r[i]=this.createMaterial(e[i],t,n);return r},createMaterial:(function(){var t={NoBlending:e.NoBlending,NormalBlending:e.NormalBlending,AdditiveBlending:e.AdditiveBlending,SubtractiveBlending:e.SubtractiveBlending,MultiplyBlending:e.MultiplyBlending,CustomBlending:e.CustomBlending},n=new e.Color,r=new e.TextureLoader,i=new e.MaterialLoader;return function(a,o,s){var c={};function l(t,n,i,a,l){var u=o+t,d=De.Handlers.get(u),f;d===null?(r.setCrossOrigin(s),f=r.load(u)):f=d.load(u),n!==void 0&&(f.repeat.fromArray(n),n[0]!==1&&(f.wrapS=e.RepeatWrapping),n[1]!==1&&(f.wrapT=e.RepeatWrapping)),i!==void 0&&f.offset.fromArray(i),a!==void 0&&(a[0]===`repeat`&&(f.wrapS=e.RepeatWrapping),a[0]===`mirror`&&(f.wrapS=e.MirroredRepeatWrapping),a[1]===`repeat`&&(f.wrapT=e.RepeatWrapping),a[1]===`mirror`&&(f.wrapT=e.MirroredRepeatWrapping)),l!==void 0&&(f.anisotropy=l);var p=e.MathUtils.generateUUID();return c[p]=f,p}var u={uuid:e.MathUtils.generateUUID(),type:`MeshLambertMaterial`};for(var d in a){var f=a[d];switch(d){case`DbgColor`:case`DbgIndex`:case`opticalDensity`:case`illumination`:break;case`DbgName`:u.name=f;break;case`blending`:u.blending=t[f];break;case`colorAmbient`:case`mapAmbient`:console.warn(`THREE.Loader.createMaterial:`,d,`is no longer supported.`);break;case`colorDiffuse`:u.color=n.fromArray(f).getHex();break;case`colorSpecular`:u.specular=n.fromArray(f).getHex();break;case`colorEmissive`:u.emissive=n.fromArray(f).getHex();break;case`specularCoef`:u.shininess=f;break;case`shading`:f.toLowerCase()===`basic`&&(u.type=`MeshBasicMaterial`),f.toLowerCase()===`phong`&&(u.type=`MeshPhongMaterial`),f.toLowerCase()===`standard`&&(u.type=`MeshStandardMaterial`);break;case`mapDiffuse`:u.map=l(f,a.mapDiffuseRepeat,a.mapDiffuseOffset,a.mapDiffuseWrap,a.mapDiffuseAnisotropy);break;case`mapDiffuseRepeat`:case`mapDiffuseOffset`:case`mapDiffuseWrap`:case`mapDiffuseAnisotropy`:break;case`mapEmissive`:u.emissiveMap=l(f,a.mapEmissiveRepeat,a.mapEmissiveOffset,a.mapEmissiveWrap,a.mapEmissiveAnisotropy);break;case`mapEmissiveRepeat`:case`mapEmissiveOffset`:case`mapEmissiveWrap`:case`mapEmissiveAnisotropy`:break;case`mapLight`:u.lightMap=l(f,a.mapLightRepeat,a.mapLightOffset,a.mapLightWrap,a.mapLightAnisotropy);break;case`mapLightRepeat`:case`mapLightOffset`:case`mapLightWrap`:case`mapLightAnisotropy`:break;case`mapAO`:u.aoMap=l(f,a.mapAORepeat,a.mapAOOffset,a.mapAOWrap,a.mapAOAnisotropy);break;case`mapAORepeat`:case`mapAOOffset`:case`mapAOWrap`:case`mapAOAnisotropy`:break;case`mapBump`:u.bumpMap=l(f,a.mapBumpRepeat,a.mapBumpOffset,a.mapBumpWrap,a.mapBumpAnisotropy);break;case`mapBumpScale`:u.bumpScale=f;break;case`mapBumpRepeat`:case`mapBumpOffset`:case`mapBumpWrap`:case`mapBumpAnisotropy`:break;case`mapNormal`:u.normalMap=l(f,a.mapNormalRepeat,a.mapNormalOffset,a.mapNormalWrap,a.mapNormalAnisotropy);break;case`mapNormalFactor`:u.normalScale=f;break;case`mapNormalRepeat`:case`mapNormalOffset`:case`mapNormalWrap`:case`mapNormalAnisotropy`:break;case`mapSpecular`:u.specularMap=l(f,a.mapSpecularRepeat,a.mapSpecularOffset,a.mapSpecularWrap,a.mapSpecularAnisotropy);break;case`mapSpecularRepeat`:case`mapSpecularOffset`:case`mapSpecularWrap`:case`mapSpecularAnisotropy`:break;case`mapMetalness`:u.metalnessMap=l(f,a.mapMetalnessRepeat,a.mapMetalnessOffset,a.mapMetalnessWrap,a.mapMetalnessAnisotropy);break;case`mapMetalnessRepeat`:case`mapMetalnessOffset`:case`mapMetalnessWrap`:case`mapMetalnessAnisotropy`:break;case`mapRoughness`:u.roughnessMap=l(f,a.mapRoughnessRepeat,a.mapRoughnessOffset,a.mapRoughnessWrap,a.mapRoughnessAnisotropy);break;case`mapRoughnessRepeat`:case`mapRoughnessOffset`:case`mapRoughnessWrap`:case`mapRoughnessAnisotropy`:break;case`mapAlpha`:u.alphaMap=l(f,a.mapAlphaRepeat,a.mapAlphaOffset,a.mapAlphaWrap,a.mapAlphaAnisotropy);break;case`mapAlphaRepeat`:case`mapAlphaOffset`:case`mapAlphaWrap`:case`mapAlphaAnisotropy`:break;case`flipSided`:u.side=e.BackSide;break;case`doubleSided`:u.side=e.DoubleSide;break;case`transparency`:console.warn(`THREE.Loader.createMaterial: transparency has been renamed to opacity`),u.opacity=f;break;case`depthTest`:case`depthWrite`:case`colorWrite`:case`opacity`:case`reflectivity`:case`transparent`:case`visible`:case`wireframe`:u[d]=f;break;case`vertexColors`:f===!0&&(u.vertexColors=e.VertexColors),f===`face`&&(u.vertexColors=e.FaceColors);break;default:console.error(`THREE.Loader.createMaterial: Unsupported`,d,f)}}return u.type===`MeshBasicMaterial`&&delete u.emissive,u.type!==`MeshPhongMaterial`&&delete u.specular,u.opacity<1&&(u.transparent=!0),i.setTextures(c),i.parse(u)}})()});var Oe=function(t){var n=this;this.video=void 0,this.videoTexture=void 0;var r=t,i=function(){document&&(n.video=document.createElement(`video`),n.video.crossOrigin=`anonymous`,n.video.src=r,n.video.load(),n.video.loop=!0)};this.setMorphTime=function(e,t){var r=e/t*n.video.duration;n.video.currentTime=r},this.getVideoDuration=function(){return n.video.duration},this.createCanvasVideoTexture=function(){return n.videoTexture=new e.VideoTexture(n.video),n.videoTexture.minFilter=e.LinearFilter,n.videoTexture.magFilter=e.LinearFilter,n.videoTexture.format=e.RGBFormat,n.video.currentTime=0,n.videoTexture},this.getCurrentTime=function(e){return n.video?e*(n.video.currentTime/n.video.duration):0},this.isReadyToPlay=function(){return!!(n.video&&n.video.readyState>=3)},i()},ke=e.AnimationClip,Ae=e.Color,je=e.DefaultLoadingManager,Me=e.FileLoader,Ne=e.LoaderUtils,Pe=e.Vector2,Fe=e.Vector3,Ie=e.Vector4;function Le(e){typeof e==`boolean`&&(console.warn(`THREE.JSONLoader: showStatus parameter has been removed from constructor.`),e=void 0),this.manager=e===void 0?je:e,this.withCredentials=!1,this.paramsString=``}Object.assign(Le.prototype,{load:function(e,t,n,r){var i=this,a=this.texturePath&&typeof this.texturePath==`string`?this.texturePath:Ne.extractUrlBase(e),o=new Me(this.manager);e.split(`?`),this.paramsString=e.length===2?paramsStrings[1]:``,o.setWithCredentials(this.withCredentials),o.load(e,function(n){var o=void 0;try{o=JSON.parse(n)}catch{if(console.error(`The loader has encountered an error while parsing the content of a resource.`),r){r({responseURL:e});return}}var s=o.metadata;if(s!==void 0){var c=s.type;if(c!==void 0&&c.toLowerCase()===`object`){console.error(`THREE.JSONLoader: `+e+` should be loaded with THREE.ObjectLoader instead.`);return}}if(i&&i.parse)try{var l=i.parse(o,a);t(l.geometry,l.materials)}catch(t){if(console.error(`The loader has encountered aon loading the geometry`),console.error(t),r){r({responseURL:e});return}}},n,r)},setTexturePath:function(e){this.texturePath=e},parse:(function(){function t(e,t){function n(e,t){return e&1<<t}var r,i,a,o,s,c,l,u,d,f,p,m,h,g,_,v,y,x,S,C,w,T,E,D,O,k,A,j=e.faces,M=e.vertices,N=e.normals,P=e.colors,F=e.scale,I=0;if(e.uvs!==void 0){for(r=0;r<e.uvs.length;r++)e.uvs[r].length&&I++;for(r=0;r<I;r++)t.faceVertexUvs[r]=[]}for(o=0,s=M.length;o<s;)x=new Fe,x.x=M[o++]*F,x.y=M[o++]*F,x.z=M[o++]*F,t.vertices.push(x);if(o=0,s=j.length,e.uvs)for(r=0;r<e.uvs.length;r++){t.uvs[r]=[];for(let n=0;n<e.uvs[r].length;n++)t.uvs[r][n]=e.uvs[r][n]}if(N)for(r=0;r<N.length;r++)t.normals[r]=N[r];if(P)for(r=0;r<P.length;r++)t.colors[r]=P[r];for(;o<s;)if(f=j[o++],p=n(f,0),m=n(f,1),h=n(f,3),g=n(f,4),_=n(f,5),v=n(f,6),y=n(f,7),p){if(C=new b,C.a=j[o],C.b=j[o+1],C.c=j[o+3],w=new b,w.a=j[o+1],w.b=j[o+2],w.c=j[o+3],o+=4,m&&(d=j[o++],C.materialIndex=d,w.materialIndex=d),a=t.faces.length,h)for(r=0;r<I;r++)for(D=e.uvs[r],t.faceVertexUvs[r][a]=[],t.faceVertexUvs[r][a+1]=[],i=0;i<4;i++)u=j[o++],k=D[u*2],A=D[u*2+1],O=new Pe(k,A),i!==2&&t.faceVertexUvs[r][a].push(O),i!==0&&t.faceVertexUvs[r][a+1].push(O);if(g&&(l=j[o++]*3,C.normal.set(N[l++],N[l++],N[l]),w.normal.copy(C.normal)),_)for(r=0;r<4;r++)l=j[o++]*3,E=new Fe(N[l++],N[l++],N[l]),r!==2&&C.vertexNormals.push(E),r!==0&&w.vertexNormals.push(E);if(v&&(c=j[o++],T=P[c],C.color.setHex(T),w.color.setHex(T)),y)for(r=0;r<4;r++)c=j[o++],T=P[c],r!==2&&C.vertexColors.push(new Ae(T)),r!==0&&w.vertexColors.push(new Ae(T));t.faces.push(C),t.faces.push(w)}else{if(S=new b,S.a=j[o++],S.b=j[o++],S.c=j[o++],S.b||(S.b=S.a),S.c||(S.c=S.b),m&&(d=j[o++],S.materialIndex=d),a=t.faces.length,h)for(r=0;r<I;r++)for(D=e.uvs[r],t.faceVertexUvs[r][a]=[],i=0;i<3;i++)u=j[o++],k=D[u*2],A=D[u*2+1],O=new Pe(k,A),t.faceVertexUvs[r][a].push(O);if(g&&(l=j[o++]*3,S.normal.set(N[l++],N[l++],N[l])),_)for(r=0;r<3;r++)l=j[o++]*3,E=new Fe(N[l++],N[l++],N[l]),S.vertexNormals.push(E);if(v&&(c=j[o++],S.color.setHex(P[c])),y)for(r=0;r<3;r++)c=j[o++],S.vertexColors.push(new Ae(P[c]));t.faces.push(S)}}function n(e,t){var n=e.influencesPerVertex===void 0?2:e.influencesPerVertex;if(e.skinWeights)for(var r=0,i=e.skinWeights.length;r<i;r+=n){var a=e.skinWeights[r],o=n>1?e.skinWeights[r+1]:0,s=n>2?e.skinWeights[r+2]:0,c=n>3?e.skinWeights[r+3]:0;t.skinWeights.push(new Ie(a,o,s,c))}if(e.skinIndices)for(var r=0,i=e.skinIndices.length;r<i;r+=n){var l=e.skinIndices[r],u=n>1?e.skinIndices[r+1]:0,d=n>2?e.skinIndices[r+2]:0,f=n>3?e.skinIndices[r+3]:0;t.skinIndices.push(new Ie(l,u,d,f))}t.bones=e.bones,t.bones&&t.bones.length>0&&(t.skinWeights.length!==t.skinIndices.length||t.skinIndices.length!==t.vertices.length)&&console.warn(`When skinning, number of vertices (`+t.vertices.length+`), skinIndices (`+t.skinIndices.length+`), and skinWeights (`+t.skinWeights.length+`) should match.`)}function r(t,n){var r=t.scale;if(t.morphTargets!==void 0)for(var i=0,a=t.morphTargets.length;i<a;i++){n.morphTargets[i]={},n.morphTargets[i].name=t.morphTargets[i].name,n.morphTargets[i].vertices=[];for(var o=n.morphTargets[i].vertices,s=t.morphTargets[i].vertices,c=0,l=s.length;c<l;c+=3){var u=new Fe;u.x=s[c]*r,u.y=s[c+1]*r,u.z=s[c+2]*r,o.push(u)}}if(t.morphNormals!==void 0){for(var i=0,a=t.morphNormals.length;i<a;i++)if(n.morphTargets[i]){n.morphTargets[i].normals=[];for(var d=n.morphTargets[i].normals,f=t.morphNormals[i].normals,c=0,l=f.length;c<l;c+=3){var p=new Fe;p.x=f[c],p.y=f[c+1],p.z=f[c+2],d.push(p)}n.morphNormalsReady=!0}}if(t.morphColors!==void 0){var i,a,m,h,g,_,v;for(i=0,a=t.morphColors.length;i<a;i++)for(n.morphColors[i]={},n.morphColors[i].name=t.morphColors[i].name,n.morphColors[i].colors=[],g=n.morphColors[i].colors,_=t.morphColors[i].colors,m=0,h=_.length;m<h;m+=3)v=new e.Color(16755200),v.setRGB(_[m],_[m+1],_[m+2]),g.push(v)}}function i(e,t){var n=[],r=[];e.animation!==void 0&&r.push(e.animation),e.animations!==void 0&&(e.animations.length?r=r.concat(e.animations):r.push(e.animations));for(var i=0;i<r.length;i++){var a=ke.parseAnimation(r[i],t.bones);a&&n.push(a)}if(t.morphTargets){var o=ke.CreateClipsFromMorphTargetSequences(t.morphTargets,10);n=n.concat(o)}n.length>0&&(t.animations=n)}return function(a,o){a.data!==void 0&&(a=a.data),a.scale===void 0?a.scale=1:a.scale=1/a.scale;var s=new v;if(s.morphColors=[],t(a,s),n(a,s),r(a,s),i(a,s),s.computeFaceNormals(),s.computeBoundingSphere(),a.materials===void 0||a.materials.length===0)return{geometry:s};var c=De.prototype.initMaterials(a.materials,o,`Anonymous`);if(a.materials[0].video){var l=o+a.materials[0].video;this.paramsString&&(l+=`?${this.paramsString}`),s._video=new Oe(l)}return c&&c.length>0&&(a.materials[0].singleSided?c[0].side=e.FrontSide:a.materials[0].flipSided?c[0].side=e.BackSide:c[0].side=e.DoubleSide,a.materials[0].specularCoef&&(c[0].shininess=Math.floor(a.materials[0].specularCoef/3))),{geometry:s,materials:c}}})()});var Re=function(){B.call(this);let t=[],n,r,i,a,o,s,c,l=0,u=0,d=[0,0,0],f=[0,0,0],p=!1,m=[0,0,0],h=`NONE`;this.ready=!1;let g=!1,_=!1;this.isGlyphset=!0;let v=new e.Matrix4,y=new e.Color,b=new e.Color,x=new e.Box3,S=new e.Box3,C=new e.Box3,w=[],T=[],E=[],D=[],O=[],k=[],A=[],j=[];this.globalScale=1;for(let t=0;t<8;t++)w[t]=new e.Vector3;this.load=(t,p,v,y,b)=>{n=t.axis1,r=t.axis2,i=t.axis3,a=t.positions,o=t.scale,s=t.colors,c=t.label,g=t.metadata.MorphColours,_=t.metadata.MorphVertices,l=t.metadata.number_of_time_steps,h=t.metadata.repeat_mode,u=t.metadata.number_of_vertices,h==`AXES_2D`||h==`MIRROR`?u*=2:h==`AXES_3D`&&(u*=3),d=t.metadata.base_size,f=t.metadata.offset,m=t.metadata.scale_factors;let x=new Le;this.geometry=new e.BufferGeometry;let S=new e.InstancedMesh(this.geometry,void 0,u);if(this.setMorph(S),y){var C=x.parse(p);ee(v,b)(C.geometry,C.materials),C.geometry.dispose()}else x.crossOrigin=`Anonymous`,x.load(p,ee(v,b))};let M=(e,t,n,r,i,a)=>{if(h==`NONE`||h==`MIRROR`){let c=[0,0,0],l=[0,0,0],u=[0,0,0],p=[0,0,0],g=[0,0,0],_=[0,0,0],v=[0,0,0],y=[0,0,0],b=[0,0,0];for(var o=0;o<3;o++){var s=i[o]<0?-1:1;c[o]=(s*d[o]+i[o]*m[o])*this.globalScale}for(var o=0;o<3;o++)l[o]=t[o]*c[0],u[o]=n[o]*c[1],p[o]=r[o]*c[2],g[o]=e[o]+f[0]*l[o]+f[1]*u[o]+f[2]*p[o],h==`MIRROR`&&(_[o]=-l[o],v[o]=-u[o],y[o]=-p[o],b[o]=g[o],i[0]<0&&(g[o]-=l[o],b[o]-=_[o]));0>p[0]*(l[1]*u[2]-l[2]*u[1])+p[1]*(l[2]*u[0]-l[0]*u[2])+p[2]*(l[0]*u[1]-l[1]*u[0])&&(p[0]=-p[0],p[1]=-p[1],p[2]=-p[2]),a[0]=[g,l,u,p],h==`MIRROR`&&(0>y[0]*(_[1]*v[2]-_[2]*v[1])+y[1]*(_[2]*v[0]-_[0]*v[2])+y[2]*(_[0]*v[1]-_[1]*v[0])&&(y[0]=-y[0],y[1]=-y[1],y[2]=-y[2]),a[1]=[b,_,v,y])}else if(h==`AXES_2D`||h==`AXES_3D`){let l=[0,0,0],u=[0,0,0];for(var o=0;o<3;o++){var s=i[o]<0?-1:1;l[o]=(s*d[0]+i[o]*m[0])*this.globalScale}for(var o=0;o<3;o++)u[o]=e[o]+f[0]*l[0]*t[o]+f[1]*l[1]*n[o]+f[2]*l[2]*r[o];let p=glyph_repeat_mode==`AXES_2D`?2:3;for(let e=0;e<p;e++){let o,s,l=i[e],f=[0,0,0],p=[0,0,0],g=[0,0,0];e==0?(o=t,s=n):e==1?(o=n,s=glyph_repeat_mode==`AXES_2D`?t:r):(o=r,s=t);let _=(d[0]+l*m[0])*this.globalScale;f[0]=o[0]*_,f[1]=o[1]*_,f[2]=o[2]*_,g[0]=f[1]*s[2]-s[1]*f[2],g[1]=f[2]*s[0]-s[2]*f[0],g[2]=f[0]*s[1]-f[1]*s[0];let v=Math.sqrt(g[0]*g[0]+g[1]*g[1]+g[2]*g[2]);if(0<v){let t=(d[2]+l*m[2])*this.globalScale/v;h==`AXES_2D`&&e>0&&(t*=-1),g[0]*=t,g[1]*=t,g[2]*=t}if(p[0]=g[1]*f[2]-f[1]*g[2],p[1]=g[2]*f[0]-f[2]*g[0],p[2]=g[0]*f[1]-g[1]*f[0],v=Math.sqrt(p[0]*p[0]+p[1]*p[1]+p[2]*p[2]),0<v){var c=(d[1]+l*m[1])*this.globalScale/v;p[0]*=c,p[1]*=c,p[2]*=c}a[e]=[u,f,p,g]}}return a},N=(e,n,r,i,a)=>{let o=1;h==`AXES_2D`||h==`MIRROR`?o=2:h==`AXES_3D`&&(o=3);let s=e.length/3,c=0;j.length=o;for(let l=0;l<s;l++){let s=l*3,u=[e[s],e[s+1],e[s+2]],d=[n[s],n[s+1],n[s+2]],f=[r[s],r[s+1],r[s+2]],p=[i[s],i[s+1],i[s+2]],m=[a[s],a[s+1],a[s+2]],h=M(u,d,f,p,m,j);if(h.length==o)for(let e=0;e<o;e++){v.elements[0]=h[e][1][0],v.elements[1]=h[e][1][1],v.elements[2]=h[e][1][2],v.elements[3]=0,v.elements[4]=h[e][2][0],v.elements[5]=h[e][2][1],v.elements[6]=h[e][2][2],v.elements[7]=0,v.elements[8]=h[e][3][0],v.elements[9]=h[e][3][1],v.elements[10]=h[e][3][2],v.elements[11]=0,v.elements[12]=h[e][0][0],v.elements[13]=h[e][0][1],v.elements[14]=h[e][0][2],v.elements[15]=1,this.morph.setMatrixAt(c,v);let n=t[c];n&&n.setTransformation(h[e][0],h[e][1],h[e][2],h[e][3]),c++}}this.morph.instanceMatrix.needsUpdate=!0},P=e=>{let n=1;h==`AXES_2D`||h==`MIRROR`?n=2:h==`AXES_3D`&&(n=3);let r=e.length,i=0;for(let a=0;a<r;a++){let r=e[a];for(let e=0;e<n;e++){y.setHex(r),this.morph.setColorAt(i,y);let e=t[i];e&&e.setColour(y),i++}}this.morph.instanceColor.needsUpdate=!0},F=()=>{let e=T,t=E,c=D,u=O,d=k,f=A,p=this.inbuildTime/this.duration*(l-1),m=Math.floor(p),h=1-(p-m),v=Math.ceil(p);if(_){let s=a[m.toString()],l=a[v.toString()],f=n[m.toString()],p=n[v.toString()],g=r[m.toString()],_=r[v.toString()],y=i[m.toString()],b=i[v.toString()],x=o[m.toString()],S=o[v.toString()];T.length=s.length,E.length=s.length,D.length=s.length,O.length=s.length,k.length=s.length;for(let n=0;n<s.length;n++)e[n]=h*s[n]+(1-h)*l[n],t[n]=h*f[n]+(1-h)*p[n],c[n]=h*g[n]+(1-h)*_[n],u[n]=h*y[n]+(1-h)*b[n],d[n]=h*x[n]+(1-h)*S[n]}else e=a[0],t=n[0],c=r[0],u=i[0],d=o[0];if(N(e,t,c,u,d),this.boundingBoxUpdateRequired=!0,s!=null){if(g){let e=s[m.toString()],t=s[v.toString()];f.length=e.length;for(let n=0;n<e.length;n++)y.setHex(e[n]),b.setHex(t[n]),y.setRGB(y.r*h+b.r*(1-h),y.g*h+b.g*(1-h),y.b*h+b.b*(1-h)),f[n]=y.getHex()}else f=s[0];P(f)}};this.getLabel=e=>{if(c&&c.length>e)return c[e]},this.isLabelDisplayed=()=>p,this.canShowLabel=()=>t?.length&&(c?.length||this.groupName),this.showLabel=()=>{if(t?.length){p=!0;for(let e=0;e<t.length;e++)t[e].showLabel(this.morph.material?this.morph.material.color:void 0)}},this.hideLabel=()=>{for(let e=0;e<t.length;e++)t[e].hideLabel();p=!1};let I=e=>{for(let e=0;e<u;e++){let n=new Ee(void 0,void 0,e,this),r=c?c[e]:void 0;r||=this.groupName,r&&n.setLabel(r),l>0&&n.setFrustumCulled(!1),t[e]=n,this.morph.add(n.getGroup())}c&&e&&this.showLabel(),N(a[0],n[0],r[0],i[0],o[0]),s!=null&&P(s[0]),this.ready=!0,this.boundingBoxUpdateRequired=!0};this.addCustomGlyph=e=>{e.isGlyph&&t.push(e),this.ready=!0,this.boundingBoxUpdateRequired=!0},this.addMeshAsGlyph=(e,n)=>{if(e.isMesh){let r=new Ee(void 0,void 0,n,this);return r.fromMesh(e),t.push(r),this.morph.add(r.getGroup()),this.ready=!0,this.boundingBoxUpdateRequired=!0,r}},this.forEachGlyph=e=>{for(let n=0;n<t.length;n++)e(t[n])};var ee=(e,t)=>(n,r)=>{let i=n.toBufferGeometry();this.geometry.copy(i),this.geometry.computeBoundingSphere(),this.geometry.computeBoundingBox(),i.dispose(),r&&r[0]&&(this.morph.material=r[0]),I(t),this.morph.name=this.groupName,this.morph.userData=this,this.setMorph(this.morph),n.dispose(),e!=null&&typeof e==`function`&&e(this)};this.getClosestVertexIndex=function(){let e=-1;if(this.morph&&this.ready){this.getBoundingBox().getCenter(this._v1);let t=a[0],n=t.length/3,r=-1,i=0;for(let a=0;a<n;a++){let n=a*3;this._v2.set(t[n],t[n+1],t[n+2]),i=this._v1.distanceTo(this._v2),(r==-1||r>i)&&(r=i,e=a)}}return e},this.getClosestVertex=function(){if(this.closestVertexIndex==-1&&(this.closestVertexIndex=this.getClosestVertexIndex()),this.closestVertexIndex>=0&&this.morph){let t=new e.Vector3;return this.morph.getMatrixAt(this.closestVertexIndex,v),t.setFromMatrixPosition(v),t}},this.getBoundingBox=()=>{if(this.morph&&this.ready&&this.morph.visible){if(this.boundingBoxUpdateRequired){x.setFromBufferAttribute(this.morph.geometry.attributes.position);for(let e=0;e<u;e++)this.morph.getMatrixAt(e,v),S.copy(x).applyMatrix4(v),e==0?C.copy(S):C.union(S);if(C)this.cachedBoundingBox.copy(C),this.morph.updateWorldMatrix(!0,!0),this.cachedBoundingBox.applyMatrix4(this.morph.matrixWorld),this.boundingBoxUpdateRequired=!1;else return}return this.cachedBoundingBox}},this.setMorphTime=e=>{this.inbuildTime=e>this.duration?this.duration:0>e?0:e,(g||_)&&(F(),_&&(this.markerUpdateRequired=!0))},this.isTimeVarying=()=>!!((this.ready===!1||l>0)&&(g||_)),this.getCurrentTime=()=>this.inbuildTime,this.setScaleAll=function(e){this.globalScale=e,F()},this.dispose=()=>{for(let e=t.length-1;e>=0;e--)t[e].dispose();this.geometry&&this.geometry.dispose(),this.morph&&this.morph.material.dispose(),n=void 0,r=void 0,i=void 0,a=void 0,o=void 0,s=void 0,this.ready=!1,this.groupName=void 0},this.render=(e,t,n)=>{if(t==1){let t=this.inbuildTime+e;t>this.duration&&(t-=this.duration),this.inbuildTime=t,(g||_)&&F()}this.updateMarker(t,n)}};Re.prototype=Object.create(B.prototype);var ze=new e.Matrix4,Be=new e.Ray,Ve=new e.Sphere,He=new e.Vector3,Ue=new e.Vector3,We=new e.Vector3,Ge=class extends e.Object3D{constructor(t=new e.BufferGeometry,n=new e.PointsMaterial){super(),this.type=`Points`,this.geometry=t,this.material=n,this.sizePerPixel=1,this.updateMorphTargets()}copy(e){return super.copy(e),this.material=e.material,this.geometry=e.geometry,this}raycast(e,t){let n=this.geometry,r=this.matrixWorld,i=e.params.Points.threshold,a=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),Ve.copy(n.boundingSphere),Ve.applyMatrix4(r),Ve.radius+=i,e.ray.intersectsSphere(Ve)===!1)return;ze.copy(r).invert(),Be.copy(e.ray).applyMatrix4(ze);let o=i/((this.scale.x+this.scale.y+this.scale.z)/3)*this.material.size*this.sizePerPixel,s=o*o;if(n.isBufferGeometry){let i=n.index,o=n.attributes.position,c=n.morphAttributes.position;if(i!==null){let n=Math.max(0,a.start),l=Math.min(i.count,a.start+a.count);for(let a=n,u=l;a<u;a++){let n=i.getX(a);qe(this,o,c,n),Ke(He,n,s,r,e,t,this)}}else{let n=Math.max(0,a.start),i=Math.min(o.count,a.start+a.count);for(let a=n,l=i;a<l;a++)qe(this,o,c,a),Ke(He,a,s,r,e,t,this)}}else console.error(`THREE.Points.raycast() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.`)}updateMorphTargets(){let e=this.geometry;if(e.isBufferGeometry){let t=e.morphAttributes,n=Object.keys(t);if(n.length>0){let e=t[n[0]];if(e!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let t=0,n=e.length;t<n;t++){let n=e[t].name||String(t);this.morphTargetInfluences.push(0),this.morphTargetDictionary[n]=t}}}}else{let t=e.morphTargets;t!==void 0&&t.length>0&&console.error(`THREE.Points.updateMorphTargets() does not support THREE.Geometry. Use THREE.BufferGeometry instead.`)}}};Ge.prototype.isPoints=!0;function Ke(t,n,r,i,a,o,s){let c=Be.distanceSqToPoint(t);if(c<r){let r=new e.Vector3;Be.closestPointToPoint(t,r),r.applyMatrix4(i);let l=a.ray.origin.distanceTo(r);if(l<a.near||l>a.far)return;o.push({distance:l,distanceToRay:Math.sqrt(c),point:r,index:n,face:null,object:s})}}function qe(e,t,n,r){He.fromBufferAttribute(t,r);let i=e.morphTargetInfluences;if(e.material.morphTargets&&n&&i){Ue.set(0,0,0);for(var a=0,o=n.length;a<o;a++){let e=i[a],t=n[a];e!==0&&(We.fromBufferAttribute(t,r),Ue.addScaledVector(We.sub(He),e))}He.add(Ue)}}var Je=function(){B.call(this),this.isPointset=!0;let t=[],n=1,r=!1,i=500,a=!0;this.createMesh=(e,t,n)=>{if(e&&t){let r=k(e,n);t.map=P();let i=new Ge(r,t);this.setMesh(i,n.localTimeEnabled,n.localMorphColour)}};let o=(o,s,c,l)=>{if(c){let u=new Te(c,new e.Color(l));u.setPosition(s[0],s[1],s[2]);let d=u.getSprite();d.material.sizeAttenuation=!1,d.material.alphaTest=.5,d.material.transparent=!0,d.material.depthWrite=!1,d.material.depthTest=r,u.setFontWeight(i),u.setSize(n),u.setVisibility(a),this.group.add(d),t[o]=u}},s=e=>{let n=t[e];if(n){let r=n.getSprite();this.group.remove(r),n.dispose(),t.splice(e,1)}};this.addPoints=(n,r,i)=>{if(n&&n.length>0){let a=this.drawRange;a===-1&&(a=0);let s=this.addVertices(n);if(!this.getMorph()){let t=new e.PointsMaterial({alphaTest:.5,size:10,color:i,sizeAttenuation:!1});s.colorsNeedUpdate=!0,this.createMesh(s,t,{localTimeEnabled:!1,localMorphColour:!1})}let c=a+n.length,l=0;if(Array.isArray(r)&&r.length===n.length||typeof r==`string`)for(t.length;a+l<c;){let e=typeof r==`string`?r:r[l];o(a+l,n[l],e,this._lod._material.color),l++}this.region&&(this.region.pickableUpdateRequired=!0)}},this.setColourHex=function(e){this._lod._material.color.setHex(e),this._lod._secondaryMaterial&&this._lod._secondaryMaterial.color.setHex(e);for(let e=0;e<t.length;e++)t[e]&&t[e].setColour(this._lod._material.color)},this.setColour=e=>{this._lod.setColour(e);for(let e=0;e<t.length;e++)t[e]&&t[e].setColour(this._lod._material.color)},this.setLabelDepthTest=e=>{r=e;for(let n=0;n<t.length;n++)t[n]&&t[n].setDepthTest(e)},this.setLabelFontWeight=e=>{i=e;for(let n=0;n<t.length;n++)t[n]&&t[n].setFontWeight(e)},this.setLabelSize=e=>{n=e;for(let e=0;e<t.length;e++)t[e]&&t[e].setSize(n)},this.displayLabels=e=>{a=e;for(let e=0;e<t.length;e++)t[e]&&t[e].setVisibility(a)},this.setSize=e=>{this.morph&&this.morph.material&&(this.morph.material.size=e,this.morph.material.needsUpdate=!0)},this.setSizeAttenuation=e=>{this.morph&&this.morph.material&&(this.morph.material.sizeAttenuation=e,this.morph.material.needsUpdate=!0)},this.getVerticesByIndex=function(e){if(e>=0&&this.drawRange>e){let t=this.getMorph().geometry.getAttribute(`position`);return[t.getX(e),t.getY(e),t.getZ(e)]}},this.editVertices=function(e,n){if(e&&e.length){let r=this.getMorph(),i=n+e.length-1;if(!r||0>n||i>=this.drawRange)return;{let i=r.geometry.getAttribute(`position`),a=n;e.forEach(e=>{let n=t[a];n&&n.setPosition(e[0],e[1],e[2]),i.setXYZ(a++,e[0],e[1],e[2])}),i.needsUpdate=!0,r.geometry.computeBoundingBox(),r.geometry.computeBoundingSphere(),this.boundingBoxUpdateRequired=!0}}},this.deleteVertices=function(e){return Je.prototype.deleteVertices.call(this,e)&&s(e),this.drawRange},this.setName=function(e){let n=this.groupName;Je.prototype.setName.call(this,e),t.forEach(t=>{t.getString()===n&&t?.setText(e)})},this.render=(e,t,n,r)=>{this.morph&&n&&(this.morph.sizePerPixel=n.pixelHeight),Je.prototype.render.call(this,e,t,n,r)}};Je.prototype=Object.create(B.prototype);var Ye=function(){B.call(this),this.isLines=!0,this.createLineSegment=(e,t,n)=>{if(e&&t){let r=k(e,n);n.localMorphColour&&r.morphAttributes.color&&(t.onBeforeCompile=L());let i=new pe(r,t);this.setMesh(i,n.localTimeEnabled,n.localMorphColour)}},this.setWidth=e=>{this.morph&&this.morph.material&&(this.morph.material.linewidth=e,this.morph.material.needsUpdate=!0)},this.addLines=(t,n)=>{if(t&&t.length>0){let r=this.addVertices(t);if(!this.getMorph()){let t=new e.LineBasicMaterial({color:n});r.colorsNeedUpdate=!0,this.createLineSegment(r,t,{localTimeEnabled:!1,localMorphColour:!1})}this.region&&(this.region.pickableUpdateRequired=!0)}}};Ye.prototype=Object.create(B.prototype);var Xe=function(){this.isTexture=!0,this.impl=void 0,this.isLoading=!1,this.size={width:1,height:1,depth:0}};Xe.prototype.loadImage=function(e,t){return new Promise((n,r)=>{e.onload=()=>n(e),e.onerror=r,e.src=t})},Xe.prototype.imageToUint8Array=async function(e,t,n,r){await e.loadImage(t,n),r.width=t.width,r.height=t.height;let i=r.getContext(`2d`);return i.drawImage(t,0,0),{array:new Uint8Array(i.getImageData(0,0,r.width,r.height).data.buffer),width:r.width,height:r.height}},Xe.prototype.loadFromImages=async function(e){},Xe.prototype.isReady=function(){return!!(this.impl&&!this.isLoading)},Xe.prototype.getMaterial=function(){if(this.impl)return new e.MeshBasicMaterial({color:new e.Color(1,1,1),transparent:!1,opacity:1,map:this.impl,side:e.DoubleSide})};var Ze=function(){Xe.call(this),this.isTextureArray=!0,this.loadFromImages=async t=>{let n=1,r=1,i=0;if(t&&t.length){this.isLoading=!0;let a=new Image;a.crossOrigin=`Anonymous`;let o=document.createElement(`canvas`),s=0,c=Array(t.length);for(let e=0;e<t.length;e++){let l=await this.imageToUint8Array(this,a,t[e],o);l&&l.array&&(n=l.width,r=l.height,c[i]=l.array,s+=c[i].length,i++)}let l=new Uint8Array(s);s=0,c.forEach(e=>{l.set(e,s),s+=e.length}),this.impl=new e.DataTexture2DArray(l,n,r,i),this.size={width:n,height:r,depth:i},this.isLoading=!1,this.impl.needsUpdate=!0}},this.getMaterial=t=>{if(this.impl){let n;if(t){if(t.vs&&t.fs){let r=!0;`transparent`in t&&(r=t.transparent);let i=e.FrontSide;t.side&&(i=t.side),n=new e.ShaderMaterial({transparent:r,uniforms:t.uniforms,vertexShader:t.vs,fragmentShader:t.fs,side:i}),t.glslVersion&&(n.glslVersion=t.glslVersion)}}else n=new e.MeshBasicMaterial({color:new e.Color(1,1,1),transparent:!1,opacity:1,map:this.impl,side:e.DoubleSide});if(n)return n.needsUpdate=!0,n}}};Ze.prototype=Object.create(Xe.prototype);var Qe=e.GLSL3,$e=`
4
4
  precision highp float;
5
5
  precision highp int;
6
6
  precision highp sampler2DArray;
@@ -37,7 +37,7 @@ void main() {
37
37
  vec3 contrastedColor = (brightenedColor - vec3(0.5)) * contrast + vec3(0.5);
38
38
  outColor = vec4(contrastedColor, 1.0);
39
39
  }
40
- `,ys=`
40
+ `,et=`
41
41
  out vec3 vUw;
42
42
  uniform float depth;
43
43
  uniform vec3 slide;
@@ -65,7 +65,7 @@ void main() {
65
65
  vUw.xyz = vec3(slidePos.x, slidePos.y, slidePos.z * depth);
66
66
 
67
67
  }
68
- `,xs=function(){return{brightness:{value:0},contrast:{value:1},depth:{value:1},discardAlpha:{value:!0},diffuse0:{value:void 0},diffuse1:{value:void 0},direction:{value:1},flipY:{value:!0},flipZ:{value:!1},nChannels:{value:1},mask:{value:void 0},maskEnabled:{value:!1},slide:{value:new M.Vector3(0,0,1)},time:{value:0}}},je=function(r){Q.call(this),this.isTexturePrimitive=!0,this.texture=r,this.textureList=[],this.texture&&this.textureList.push(this.texture),this.load=(e,t,s)=>{if(e&&e.images&&e.images.source){const i=new lt,n=[];e.images.source.forEach(a=>{n.push(a)});const o=this;i.loadFromImages(n).then(()=>{o.texture=i,o.textureList.push(this.texture),o.initialise(e,t)})}},this.addTextureArray=e=>{this.textureList.length===0&&this.texture&&this.textureList.push(this.texture),e&&e.isTextureArray&&this.textureList.push(e)},this.initialise=(e,t)=>{t!=null&&typeof t=="function"&&t(this)}};je.prototype=Object.create(Q.prototype),je.prototype.constructor=je;const qe=function(r){je.call(this,r),this.isTextureSlides=!0;const e=[],t={};this.morph=new M.Group,this.group=this.morph,this.morph.userData=this;let s,i=!0,n=!1,o=0,a=1,h=1,f,c=!1,l=!0,d=0,u=0,p=-.1;this.createSlides=g=>{g.forEach(v=>this.createSlide(v))};const y=(g,v)=>{const _=g.material,I=_.uniforms;switch(g.rotation.x=0,g.rotation.y=0,g.rotation.z=0,g.position.x=0,g.position.y=0,g.position.z=0,v.direction){case"x":const k=-Math.PI/2;g.rotation.y=k,I.direction.value=1,I.slide.value.set(v.value,0,0),g.position.x=v.value;break;case"y":g.rotation.x=Math.PI/2,I.direction.value=2,I.slide.value.set(0,v.value,0),g.position.y=v.value;break;case"z":I.direction.value=3,I.slide.value.set(0,0,v.value),g.position.z=v.value;break}_.needsUpdate=!0,this.boundingBoxUpdateRequired=!0};this.modifySlideSettings=g=>{g&&g.id&&g.id in t&&t[g.id]&&y(t[g.id],g)},this.createSlide=g=>{if(this.texture&&this.texture.isTextureArray&&this.texture.isReady()&&g&&g.direction&&g.value!==void 0){const v=new M.PlaneGeometry(1,1);v.translate(.5,.5,0);const _=xs();_.brightness.value=o,_.contrast.value=a,_.diffuse0.value=this.texture.impl,_.diffuse1.value=this.texture.impl,_.discardAlpha.value=l,_.depth.value=this.texture.size.depth,_.flipY.value=i,_.flipZ.value=n,_.mask.value=f,_.maskEnabled.value=c,_.nChannels.value=h;const I={fs:gs,vs:ys,uniforms:_,glslVersion:ms,side:M.DoubleSide,transparent:!1},k=this.texture.getMaterial(I);k.needsUpdate=!0;const V=new M.Mesh(v,k);V.name=this.groupName,V.userData=this;const R={value:g.value,direction:g.direction,id:V.id};return e.push(R),y(V,R),t[V.id]=V,this.morph.add(V),this.boundingBoxUpdateRequired=!0,this.updateTimeTexture(),R}},this.getTextureSettings=()=>[...e],this.getTextureSettingsWithId=g=>{for(let v=0;v<e.length;v++)if(g===e[v].id)return{...e[v]}},this.getSlides=()=>this.morph?[...this.morph.children]:[],this.removeSlide=g=>{g&&this.removeSlideWithId(g.id)},this.removeSlideWithId=g=>{if(this.morph&&g in t&&t[g]){if(this.morph.getObjectById(g)){const _=t[g];this.morph.remove(_),_.clear(),_.geometry&&_.geometry.dispose(),_.material&&_.material.dispose(),this.boundingBoxUpdateRequired=!0}const v=e.findIndex(_=>_.id===g);v>-1&&e.splice(v,1)}},this.dispose=()=>{this.morph.children.forEach(g=>{g.geometry&&g.geometry.dispose(),g.material&&g.material.dispose()}),je.prototype.dispose.call(this),this.boundingBoxUpdateRequired=!0};const x=(g,v,_)=>{if(v)switch(v.direction.value){case 1:_.copy(v.slide.value),g.expandByPoint(_),_.setY(1),_.setZ(1),g.expandByPoint(_);break;case 2:_.copy(v.slide.value),g.expandByPoint(_),_.setX(1),_.setZ(1),g.expandByPoint(_);break;case 3:_.copy(v.slide.value),g.expandByPoint(_),_.setX(1),_.setY(1),g.expandByPoint(_);break}};this.getBoundingBox=()=>{if(this.morph&&this.morph.children&&this.morph.visible&&this.boundingBoxUpdateRequired){this.cachedBoundingBox.makeEmpty();const g=new M.Vector3(0,0,0);this.morph.children.forEach(v=>{x(this.cachedBoundingBox,v.material.uniforms,g)}),this.morph.updateMatrixWorld(!0,!0),this.cachedBoundingBox.applyMatrix4(this.morph.matrixWorld),this.boundingBoxUpdateRequired=!1}return this.cachedBoundingBox},this.applyTransformation=(g,v,_)=>{const I=new M.Matrix4;I.set(g[0],g[1],g[2],0,g[3],g[4],g[5],0,g[6],g[7],g[8],0,0,0,0,0);const k=new M.Quaternion().setFromRotationMatrix(I);this.morph.position.set(...v),this.morph.quaternion.copy(k),this.morph.scale.set(..._),this.morph.updateMatrix(),this.boundingBoxUpdateRequired=!0},this.setRenderOrder=g=>{this.morph.renderOrder=g},this.initialise=(g,v)=>{if(g){const _=g.locations;_&&_.length>0&&(this.applyTransformation(_[0].orientation,_[0].position,_[0].scale),"flipY"in _[0]&&(i=_[0].flipY),"flipZ"in _[0]&&(n=_[0].flipZ)),this.createSlides(g.settings.slides),v!=null&&typeof v=="function"&&v(this)}},this.showEdges=g=>{if(s)s.material.color=g;else{const v=new M.BoxGeometry(1,1,1);v.translate(.5,.5,.5);const _=new M.EdgesGeometry(v);s=new M.LineSegments(_,new M.LineBasicMaterial({color:g})),this.group.add(s)}s.visible=!0},this.setUniformsValue=(g,v)=>{this.morph.children.forEach(_=>{const I=_.material;if(I.type==="ShaderMaterial"){const k=I.uniforms;k[g].value=v,I.needsUpdate=!0}})},this.isAlphaPixelDiscarded=()=>l,this.discardAlphaPixel=g=>{l=g,this.setUniformsValue("discardAlpha",l)},this.getBrightness=()=>o,this.setBrightness=g=>{o=g,this.setUniformsValue("brightness",o)},this.getContrast=()=>a,this.setContrast=g=>{a>=0&&(a=g,this.setUniformsValue("contrast",a))},this.getNumberOfChannels=()=>h,this.setNumberOfChannels=g=>{h=g,this.setUniformsValue("nChannels",h)},this.getMask=()=>f,this.setMask=g=>{f=g,c=!!f,this.setUniformsValue("mask",f),this.setUniformsValue("maskEnabled",c)},this.hideEdges=()=>{s&&(s.visible=!1)},this.updateTimeTexture=()=>{const g=this.textureList.length-1,v=this.inbuildTime/this.duration;if(this.timeEnabled&&g>0&&p!==v){const _=v*g,I=Math.floor(_),k=Math.ceil(_),V=_-I;this.morph.children.forEach(R=>{const W=R.material;if(W.type==="ShaderMaterial"){const G=W.uniforms;d!==I&&(G.diffuse0.value=this.textureList[I].impl),u!==k&&(G.diffuse1.value=this.textureList[k].impl),G.time.value=V,W.needsUpdate=!0}}),d=I,u=k,p=v}},this.setMorphTime=g=>{let v=g;g>this.duration?v=this.duration:0>g?v=0:v=g,v!=this.inbuildTime&&(this.inbuildTime=v,this.updateTimeTexture())},this.render=(g,v,_)=>{if(v==!0&&this.timeEnabled&&this.textureList.length>1){let I=this.inbuildTime+g;I>this.duration&&(I=I-this.duration),this.inbuildTime=I,this.updateTimeTexture()}}};qe.prototype=Object.create(je.prototype),qe.prototype.constructor=qe;const We=function(){this.nearPlane=.168248,this.farPlane=6.82906,this.eyePosition=[.5,-2.86496,.5],this.targetPosition=[.5,.5,.5],this.upVector=[0,0,1];const r=this;this.setFromObject=({nearPlane:e,farPlane:t,eyePosition:s,targetPosition:i,upVector:n})=>{r.nearPlane=e,r.farPlane=t,r.eyePosition=s,r.targetPosition=i,r.upVector=n}},oi=function(r,e,t,s){const i={DEFAULT:0,PATH:1,SMOOTH_CAMERA_TRANSITION:2,AUTO_TUMBLE:3,MINIMAP:5,SYNC_CONTROL:6},n={NONE:-1,ROTATE:0,ZOOM:1,PAN:2,TOUCH_ROTATE:3,TOUCH_ZOOM:4,TOUCH_PAN:5,SCROLL:6,KEYBOARD_ZOOM:7,KEYBOARD_ROTATE:8,KEYBOARD_PAN:9},o={NONE:-1,FREE:1,HORIZONTAL:2,VERTICAL:3},a={ARROWLEFT:37,ARROWUP:38,ARROWRIGHT:39,ARROWDOWN:40,NUMPADADD:107,NUMPADSUBTRACT:109,EQUAL:187,MINUS:189},h={};h.MAIN=n.ROTATE,h.AUXILIARY=n.ZOOM,h.SECONDARY=n.PAN,this.cameraObject=r,this.domElement=e!==void 0?e:document,this.renderer=t,this.scene=s,this.tumble_rate=1.5,this.pointer_x=0,this.pointer_y=0,this.pointer_x_start=0,this.pointer_y_start=0,this.previous_pointer_x=0,this.previous_pointer_y=0,this.near_plane_fly_debt=0,this.touchZoomDistanceStart=0,this.touchZoomDistanceEnd=0,this.directionalLight=0,this.zoomRate=50,this.rotateRate=50,this.panRate=100,this.pixelHeight=1;let f=6e3,c=!0,l=0,d,u,p=!1,y=500,x,g="default",v=i.DEFAULT,_,I,k,V=0,R=o.FREE;this._state=n.NONE;let W;this.targetTouchId=-1;let G;const L=new M.Vector3,T=new M.Vector3,U=new M.Vector3,w=new M.Vector3,C=new M.Vector3,E=new M.Vector3,N=new M.Vector3,m=new M.Vector3,O=new M.Sphere,B=new M.Vector3;let S=!1,P,F=0;const j={default:new We};j.default.nearPlane=.1,j.default.farPlane=2e3,j.default.eyePosition=[0,0,0],j.default.targetPosition=[0,0,-1],j.default.upVector=[0,1,0],this.cameraObject.target===void 0&&(this.cameraObject.target=new M.Vector3(...j.default.targetPosition)),this.calculateMaxAllowedDistance=A=>{const z=A.getBoundingBox();if(z){z.getBoundingSphere(O),F=O.radius*6;let Z=0;this.cameraObject&&(Z=this.cameraObject.position.distanceTo(O.center)),F=Z>F?Z*1.5:F}else F=0};const J=A=>{L.copy(this.cameraObject.position);const Z=L.sub(this.cameraObject.target).length();this.cameraObject.near=Math.max(1e-4,Z*.001),this.cameraObject.far=this.cameraObject.near*1e4};this.addViewport=(A,z)=>{A&&z&&(j[A]=z)},this.setDefaultViewport=A=>A&&A in j?(g=A,!0):!1,this.getDefaultViewport=()=>g,this.getViewportOfName=A=>j[A],this.setCurrentViewport=A=>A in j?(this.setCurrentCameraSettings(j[A]),!0):!1,this.setRotationMode=A=>{switch(A){case"none":R=o.NONE;break;case"horizontal":R=o.HORIZONTAL;break;case"vertical":R=o.VERTICAL;break;case"free":default:R=o.FREE}},this.onResize=()=>{G&&(G=void 0),P&&P.setCurrentCameraSettings(this.cameraObject,j[g])},this.getVisibleHeightAtZDepth=A=>{const z=this.cameraObject.position.distanceTo(this.cameraObject.target);A<z?A-=z:A+=z;const Z=this.cameraObject.fov*Math.PI/180;return 2*Math.tan(Z/2)*Math.abs(A)},this.calculateHeightPerPixelAtZeroDepth=A=>{const z=this.getVisibleHeightAtZDepth(0);return this.pixelHeight=z/A,this.pixelHeight},this.getNDCFromDocumentCoords=(A,z,Z)=>{$(!1);const H=Z||new M.Vector2,me=(A-G.left)/G.width*2-1,fe=-((z-G.top)/G.height)*2+1;return H.set(me,fe)},this.getRelativeCoordsFromNDC=(A,z,Z)=>{$(!1);const H=Z||new M.Vector2;return H.x=(A+1)*G.width/2,H.y=(1-z)*G.height/2,H},this.setMouseButtonAction=(A,z)=>{h[A]=n[z]};const X=(A,z)=>{A instanceof HTMLCanvasElement&&(A.tabIndex=z)},Y=()=>{if(F>0){const A=B.distanceTo(O.center);return F>A||this.cameraObject.position.distanceTo(O.center)>A}return!0},re=A=>{B.copy(this.cameraObject.position).add(A),Y()&&(this.cameraObject.target.add(A),this.cameraObject.position.add(A),this.updateDirectionalLight())},oe=A=>{$(!1);let z;if(v===i.DEFAULT&&(z=this.scene.getNormalisedMinimapCoordinates(this.renderer,A)),!z)A.button==0?A.ctrlKey?this._state=h.AUXILIARY:A.shiftKey?this._state=h.SECONDARY:this._state=h.MAIN:A.button==1?(A.preventDefault(),this._state=h.AUXILIARY):A.button==2&&(this._state=h.SECONDARY),this.pointer_x=A.clientX-G.left,this.pointer_y=A.clientY-G.top,this.pointer_x_start=this.pointer_x,this.pointer_y_start=this.pointer_y,this.previous_pointer_x=this.pointer_x,this.previous_pointer_y=this.pointer_y;else{v=i.MINIMAP;let Z=this.scene.getMinimapDiffFromNormalised(z.x,z.y);re(Z)}},ee=A=>{if($(!1),G)if(this.pointer_x=A.clientX-G.left,this.pointer_y=A.clientY-G.top,v===i.MINIMAP){let z=this.scene.getNormalisedMinimapCoordinates(this.renderer,A);if(z){let Z=this.scene.getMinimapDiffFromNormalised(z.x,z.y);re(Z)}}else this._state===n.NONE&&W!==void 0&&W.move(this,A.clientX,A.clientY,this.renderer)},te=A=>{this._state=n.NONE,v==i.MINIMAP&&(v=i.DEFAULT),W!==void 0&&this.pointer_x_start==A.clientX-G.left&&this.pointer_y_start==A.clientY-G.top&&W.pick(this,A.clientX,A.clientY,this.renderer)},de=A=>{this._state=n.NONE},ne=A=>{$(!1);const z=A.touches.length;if(z==1)this._state=n.TOUCH_ROTATE,this.pointer_x=A.touches[0].clientX-(G==null?void 0:G.left),this.pointer_y=A.touches[0].clientY-(G==null?void 0:G.top),this.pointer_x_start=this.pointer_x,this.pointer_y_start=this.pointer_y,this.previous_pointer_x=this.pointer_x,this.previous_pointer_y=this.pointer_y;else if(z==2){this._state=n.TOUCH_ZOOM;const Z=A.touches[0].clientX-A.touches[1].clientX,H=A.touches[0].clientY-A.touches[1].clientY;this.touchZoomDistanceEnd=this.touchZoomDistanceStart=Math.sqrt(Z*Z+H*H)}else z==3&&(this._state=n.TOUCH_PAN,this.targetTouchId=A.touches[0].identifier,this.pointer_x=A.touches[0].clientX-(G==null?void 0:G.left),this.pointer_y=A.touches[0].clientY-(G==null?void 0:G.top),this.previous_pointer_x=this.pointer_x,this.previous_pointer_y=this.pointer_y)},ge=A=>{A.preventDefault(),A.stopPropagation();const z=A.touches.length;if(z==1)this.pointer_x=A.touches[0].clientX-G.left,this.pointer_y=A.touches[0].clientY-G.top;else if(z==2){if(this._state===n.TOUCH_ZOOM){const Z=A.touches[0].clientX-A.touches[1].clientX,H=A.touches[0].clientY-A.touches[1].clientY;this.touchZoomDistanceEnd=Math.sqrt(Z*Z+H*H)}}else if(z==3&&this._state===n.TOUCH_PAN)for(let Z=0;Z<3;Z++)A.touches[Z].identifier==this.targetTouchId&&(this.pointer_x=A.touches[0].clientX-G.left,this.pointer_y=A.touches[0].clientY-G.top)},le=A=>{const z=A.touches.length;this.touchZoomDistanceStart=this.touchZoomDistanceEnd=0,this.targetTouchId=-1,this._state=n.NONE,z==1&&W!==void 0&&this.pointer_x_start==A.touches[0].clientX-G.left&&this.pointer_y_start==A.touches[0].clientY-G.top&&W.pick(this.cameraObject,A.touches[0].clientX,A.touches[0].clientY,this.renderer)},se=()=>{$(!0)},$=A=>{if(A||G===void 0){const z=new IntersectionObserver(Z=>{for(const H of Z)G=H.boundingClientRect;z.disconnect()});z.observe(this.domElement)}},he=A=>{$(!1),this._state=n.SCROLL;let z=0;A.deltaY>0?z=this.zoomRate:A.deltaY<0&&(z=this.zoomRate*-1),V=V+z,A.preventDefault(),A.stopImmediatePropagation()},ue=A=>{$(!1);let z=0;if(A.keyCode===a.EQUAL||A.keyCode===a.MINUS||A.keyCode===a.NUMPADADD||A.keyCode===a.NUMPADSUBTRACT){this._state=n.KEYBOARD_ZOOM;let Z=1;A.shiftKey&&(Z=Z*2),A.keyCode===a.EQUAL||A.keyCode===a.NUMPADADD?z=this.zoomRate*Z*-1:(A.keyCode===a.MINUS||A.keyCode===a.NUMPADSUBTRACT)&&(z=this.zoomRate*Z),V=V+z}else(A.keyCode===a.ARROWLEFT||A.keyCode===a.ARROWUP||A.keyCode===a.ARROWRIGHT||A.keyCode===a.ARROWDOWN)&&(A.shiftKey?(this._state=n.KEYBOARD_ROTATE,this.pointer_x_start=this.pointer_x,this.pointer_y_start=this.pointer_y,z=this.rotateRate):(this._state=n.KEYBOARD_PAN,z=this.panRate),this.previous_pointer_x=this.pointer_x,this.previous_pointer_y=this.pointer_y,A.keyCode===a.ARROWLEFT?this.pointer_x=this.pointer_x-z:A.keyCode===a.ARROWUP?this.pointer_y=this.pointer_y-z:A.keyCode===a.ARROWRIGHT?this.pointer_x=this.pointer_x+z:A.keyCode===a.ARROWDOWN&&(this.pointer_y=this.pointer_y+z));Object.values(a).includes(A.keyCode)&&A.preventDefault()},De=A=>{this._state=n.NONE},ce=()=>{if(typeof this.cameraObject<"u"){const A=G.height,z=this.cameraObject.position.distanceTo(this.cameraObject.target);let Z=0;this.cameraObject.far>this.cameraObject.near&&z>=this.cameraObject.near&&z<=this.cameraObject.far&&(Z=(z-this.cameraObject.near)/(this.cameraObject.far-this.cameraObject.near)),T.set(this.previous_pointer_x,A-this.previous_pointer_y,0),U.set(this.previous_pointer_x,A-this.previous_pointer_y,1),w.set(this.pointer_x,A-this.pointer_y,0),C.set(this.pointer_x,A-this.pointer_y,1),T.unproject(this.cameraObject),U.unproject(this.cameraObject),w.unproject(this.cameraObject),C.unproject(this.cameraObject);const H=-.002;w.sub(T).multiplyScalar(1-Z),C.sub(U).multiplyScalar(Z),w.add(C).multiplyScalar(H),re(w)}this.previous_pointer_x=this.pointer_x,this.previous_pointer_y=this.pointer_y};this.getVectorsFromRotateAboutLookAtPoints=(A,z)=>{A.normalize(),N.copy(this.cameraObject.position).sub(this.cameraObject.target),m.copy(N),N.normalize(),.8<Math.abs(N.dot(A))&&N.copy(this.cameraObject.up),T.crossVectors(A,N).normalize(),U.crossVectors(A,T);const Z=A.dot(m),H=T.dot(m),me=U.dot(m),fe=A.dot(this.cameraObject.up),be=T.dot(this.cameraObject.up),pe=U.dot(this.cameraObject.up),ve=Math.cos(z),Te=Math.sin(z);return w.set(ve*T.x+Te*U.x,ve*T.y+Te*U.y,ve*T.z+Te*U.z),C.set(ve*U.x-Te*T.x,ve*U.y-Te*T.y,ve*U.z-Te*T.z),N.copy(this.cameraObject.target),N.x=N.x+A.x*Z+w.x*H+C.x*me,N.y=N.y+A.y*Z+w.y*H+C.y*me,N.z=N.z+A.z*Z+w.z*H+C.z*me,L.set(A.x*fe+w.x*be+C.x*pe,A.y*fe+w.y*be+C.y*pe,A.z*fe+w.z*be+C.z*pe),{position:N,up:L}},this.rotateAboutLookAtpoint=(A,z)=>{const Z=this.getVectorsFromRotateAboutLookAtPoints(A,z);this.cameraObject.position.copy(Z.position),this.updateDirectionalLight(),this.cameraObject.up.copy(Z.up)};const Fe=()=>{if(typeof this.cameraObject<"u"){const A=G==null?void 0:G.width,z=G==null?void 0:G.height;if(0<A&&0<z){const Z=.25*(A+z);let H=0,me=0;(R===o.FREE||R===o.HORIZONTAL)&&(H=this.pointer_x-this.previous_pointer_x),(R===o.FREE||R===o.VERTICAL)&&(me=this.previous_pointer_y-this.pointer_y);const fe=Math.sqrt(H*H+me*me);if(fe>0){const be=-me*1/fe,pe=H*1/fe;let ve=0;R===o.FREE&&be*(this.pointer_x-.5*(A-1))+pe*(.5*(z-1)-this.pointer_y);const Te=Math.acos(ve/Z)-.5*Math.PI,$e=this.tumble_rate*fe/Z;L.copy(this.cameraObject.position).sub(this.cameraObject.target).normalize(),T.copy(this.cameraObject.up).normalize(),U.copy(T).cross(L).normalize().multiplyScalar(be),T.multiplyScalar(pe),E.addVectors(U,T).multiplyScalar(Math.cos(Te)),L.multiplyScalar(Math.sin(Te)),E.add(L),this.rotateAboutLookAtpoint(E,-$e)}}}this.previous_pointer_x=this.pointer_x,this.previous_pointer_y=this.pointer_y},ji=()=>{let A=0;return this._state===n.ZOOM?A=this.previous_pointer_y-this.pointer_y:this._state===n.SCROLL||this._state===n.KEYBOARD_ZOOM?A=V:(A=-1*(this.touchZoomDistanceEnd-this.touchZoomDistanceStart),this.touchZoomDistanceStart=this.touchZoomDistanceEnd),A};this.changeZoomByScrollRateUnit=A=>{const z=A*this.zoomRate;this.changeZoomByValue(z)},this.changeZoomByValue=A=>{if(typeof this.cameraObject<"u"){const z=G.height,Z=this.cameraObject.position.clone();Z.sub(this.cameraObject.target);const H=Z.length(),me=1.5*A/z,fe=H*me;H+fe>.01&&(Z.normalize(),B.copy(this.cameraObject.position),B.x+=Z.x*fe,B.y+=Z.y*fe,B.z+=Z.z*fe,Y()&&(this.cameraObject.position.copy(B),this.updateDirectionalLight(),J(),S=!0))}};const mn=()=>{const A=ji();this.changeZoomByValue(A),this._state===n.ZOOM&&(this.previous_pointer_x=this.pointer_x,this.previous_pointer_y=this.pointer_y),(this._state===n.SCROLL||this._state===n.KEYBOARD_ZOOM)&&(V=0,this._state=n.NONE)};this.setDirectionalLight=A=>{this.directionalLight=A},this.updateDirectionalLight=()=>{this.directionalLight!=0&&this.directionalLight.position.set(this.cameraObject.position.x,this.cameraObject.position.y,this.cameraObject.position.z)},this.enable=function(){c=!0,this.domElement&&this.domElement.addEventListener&&(X(this.domElement,0),this.domElement.addEventListener("mousedown",oe,!1),this.domElement.addEventListener("mousemove",ee,!1),this.domElement.addEventListener("mouseup",te,!1),this.domElement.addEventListener("mouseleave",de,!1),this.domElement.addEventListener("touchstart",ne,!1),this.domElement.addEventListener("touchmove",ge,!1),this.domElement.addEventListener("touchend",le,!1),this.domElement.addEventListener("wheel",he,!1),this.domElement.addEventListener("mouseenter",se,!1),this.domElement.addEventListener("contextmenu",A=>{A.preventDefault()},!1),this.domElement.addEventListener("keydown",ue,!1),this.domElement.addEventListener("keyup",De,!1))},this.disable=function(){c=!1,this.domElement&&this.domElement.removeEventListener&&(this.domElement.removeEventListener("mousedown",oe,!1),this.domElement.removeEventListener("mousemove",ee,!1),this.domElement.removeEventListener("mouseup",te,!1),this.domElement.removeEventListener("mouseleave",de,!1),this.domElement.removeEventListener("touchstart",ne,!1),this.domElement.removeEventListener("touchmove",ge,!1),this.domElement.removeEventListener("touchend",le,!1),this.domElement.removeEventListener("wheel",he,!1),this.domElement.removeEventListener("mouseenter",se,!1),this.domElement.removeEventListener("contextmenu",A=>{A.preventDefault()},!1),this.domElement.removeEventListener("keydown",ue,!1),this.domElement.removeEventListener("keyup",De,!1),X(this.domElement,-1))},this.loadPath=A=>{d=A.CameraPath,u=A.NumberOfPoints},this.loadPathURL=(A,z)=>{const Z=A;fetch(Z).then(H=>{if(!H.ok)throw new Error(`HTTP error! status: ${H.status}`);return H.json()}).then(H=>{this.loadPath(H),z!==void 0&&typeof z=="function"&&z()}).catch(H=>{console.error(`Failed to load path asset from: ${Z}`,H)})},this.setPathDuration=A=>{f=A,_&&_.setDuration(f),I&&I.setDuration(f)},this.getPlayRate=()=>y,this.setPlayRate=A=>{y=A};const gn=A=>{let z=l+A;z>f&&(z=z-f),l=z};this.getTime=()=>l,this.setTime=A=>{A>f?l=f:A<0?l=0:l=A},this.getNumberOfTimeFrame=()=>u,this.getCurrentTimeFrame=()=>{if(u>2){const A=l/f*(u-1),z=Math.floor(A),Z=1-(A-z),H=Math.ceil(A);return z==H?z==u-1?[z-1,H,0]:[z,H+1,1]:[z,H,Z]}else if(u==1)return[0,0,0]},this.setCurrentTimeFrame=A=>{u>2&&(l=f*A/(u-1),l<0&&(l=0),l>f&&(l=f))};const qi=A=>{if(v===i.PATH&&(gn(A),d)){const z=this.getCurrentTimeFrame(),Z=z[0],H=z[1],me=z[2],fe=[d[Z*3],d[Z*3+1],d[Z*3+2]],be=[d[H*3],d[H*3+1],d[H*3+2]],pe=[];for(let ve=0;ve<fe.length;ve++)pe.push(me*fe[ve]+(1-me)*be[ve]);this.cameraObject.position.set(pe[0],pe[1],pe[2]),this.cameraObject.target.set(be[0],be[1],be[2]),x&&this.cameraObject.lookAt(this.cameraObject.target),p&&(this.directionalLight.position.set(pe[0],pe[1],pe[2]),this.directionalLight.target.position.set(be[0],be[1],be[2]))}};this.calculatePathNow=()=>{qi(0)};const yn=()=>{this._state===n.ROTATE||this._state===n.TOUCH_ROTATE||this._state===n.KEYBOARD_ROTATE?Fe():this._state===n.PAN||this._state===n.TOUCH_PAN||this._state===n.KEYBOARD_PAN?(ce(),P.triggerCallback()):(this._state===n.ZOOM||this._state===n.TOUCH_ZOOM||this._state===n.SCROLL||this._state===n.KEYBOARD_ZOOM)&&(P.zoom(ji()),this.previous_pointer_x=this.pointer_x,this.previous_pointer_y=this.pointer_y,(this._state===n.SCROLL||this._state===n.KEYBOARD_ZOOM)&&(this._state=n.NONE),V=0,P.triggerCallback())};this.update=A=>{const z=A*y;let Z=c,H=!0;return v===i.PATH?qi(z):v===i.SMOOTH_CAMERA_TRANSITION&&_?(_.update(z),_.isTransitionCompleted()&&(v=i.DEFAULT),Z=!1):v===i.ROTATE_CAMERA_TRANSITION&&I?(I.update(z),I.isTransitionCompleted()&&(v=i.DEFAULT),Z=!1):v===i.AUTO_TUMBLE&&k?k.update(z):v===i.SYNC_CONTROL&&P?(yn(),Z=!1):H=!1,Z&&(this._state!==n.NONE&&(H=!0),this._state===n.ROTATE||this._state===n.TOUCH_ROTATE||this._state===n.KEYBOARD_ROTATE?Fe():this._state===n.PAN||this._state===n.TOUCH_PAN||this._state===n.KEYBOARD_PAN?ce():(this._state===n.ZOOM||this._state===n.TOUCH_ZOOM||this._state===n.SCROLL||this._state===n.KEYBOARD_ZOOM)&&mn(),this._state!==n.NONE&&v===i.AUTO_TUMBLE&&k&&k.stopOnCameraInput,this._state===n.SCROLL&&(this._state=n.NONE)),x?(H=!0,x.update()):this.cameraObject.lookAt(this.cameraObject.target),H=H||S,S=!1,H},this.playPath=()=>{v=i.PATH},this.stopPath=()=>{v=i.DEFAULT},this.isPlayingPath=()=>v===i.PATH,this.enableDirectionalLightUpdateWithPath=A=>{p=A},this.enableDeviceOrientation=()=>{x||(x=new As(this.cameraObject))},this.disableDeviceOrientation=()=>{x&&(x.dispose(),x=void 0)},this.isDeviceOrientationEnabled=()=>!!x,this.resetView=()=>{const A=j[g];this.cameraObject.near=A.nearPlane,this.cameraObject.far=A.farPlane,this.cameraObject.position.set(A.eyePosition[0],A.eyePosition[1],A.eyePosition[2]),this.cameraObject.target.set(A.targetPosition[0],A.targetPosition[1],A.targetPosition[2]),this.cameraObject.up.set(A.upVector[0],A.upVector[1],A.upVector[2]),this.cameraObject.updateProjectionMatrix(),this.updateDirectionalLight()},this.setCurrentCameraSettings=A=>{A.nearPlane&&(this.cameraObject.near=A.nearPlane),A.farPlane&&(this.cameraObject.far=A.farPlane),A.eyePosition&&this.cameraObject.position.set(A.eyePosition[0],A.eyePosition[1],A.eyePosition[2]),A.targetPosition&&this.cameraObject.target.set(A.targetPosition[0],A.targetPosition[1],A.targetPosition[2]),A.upVector&&this.cameraObject.up.set(A.upVector[0],A.upVector[1],A.upVector[2]),this.cameraObject.updateProjectionMatrix(),this.updateDirectionalLight(),S=!0},this.getViewportFromCentreAndRadius=(A,z,Z,H,me,fe)=>{L.copy(this.cameraObject.position),L.sub(this.cameraObject.target),L.normalize();const be=[A,z,Z],pe=H/Math.tan(me*Math.PI/360),ve=[A+L.x*pe,z+L.y*pe,Z+L.z*pe],Te=pe+fe;let $e=0;const Wi=.95;fe>Wi*pe?$e=(1-Wi)*pe:$e=pe-fe;const Ze=new We;return Ze.nearPlane=$e,Ze.farPlane=Te,Ze.eyePosition=ve,Ze.targetPosition=be,Ze.upVector=[this.cameraObject.up.x,this.cameraObject.up.y,this.cameraObject.up.z],Ze},this.getViewportFromBoundingBox=(A,z)=>{const Z=A.min.distanceTo(A.max)/2*z,H=(A.min.x+A.max.x)/2,me=(A.min.y+A.max.y)/2,fe=(A.min.z+A.max.z)/2;return this.getViewportFromCentreAndRadius(H,me,fe,Z,40,Z*4)},this.getCurrentViewport=()=>{const A=new We;return A.nearPlane=this.cameraObject.near,A.farPlane=this.cameraObject.far,A.eyePosition[0]=this.cameraObject.position.x,A.eyePosition[1]=this.cameraObject.position.y,A.eyePosition[2]=this.cameraObject.position.z,A.targetPosition[0]=this.cameraObject.target.x,A.targetPosition[1]=this.cameraObject.target.y,A.targetPosition[2]=this.cameraObject.target.z,A.upVector[0]=this.cameraObject.up.x,A.upVector[1]=this.cameraObject.up.y,A.upVector[2]=this.cameraObject.up.z,A},this.getDefaultEyePosition=()=>eyePosition,this.getDefaultTargetPosition=()=>targetPosition,this.cameraTransition=(A,z,Z)=>{I==null&&(_=new ai(A,z,this,Z))},this.rotateCameraTransition=(A,z,Z)=>{_==null&&(I=new bs(A,z,this,Z))},this.enableCameraTransition=()=>{_&&(v=i.SMOOTH_CAMERA_TRANSITION),I&&(v=i.ROTATE_CAMERA_TRANSITION)},this.pauseCameraTransition=()=>{v=i.DEFAULT},this.stopCameraTransition=()=>{v=i.DEFAULT,_=void 0,I=void 0},this.isTransitioningCamera=()=>v===i.SMOOTH_CAMERA_TRANSITION||v===i.ROTATE_CAMERA_TRANSITION,this.autoTumble=(A,z,Z)=>{k=new ci(A,z,Z,this)},this.enableAutoTumble=()=>{v=i.AUTO_TUMBLE},this.stopAutoTumble=()=>{v=i.DEFAULT,k=void 0},this.updateAutoTumble=()=>{k&&(k.requireUpdate=!0)},this.isAutoTumble=()=>v===i.AUTO_TUMBLE,this.enableRaycaster=(A,z,Z)=>{W==null&&(W=new li(A,this.scene,z,Z,this.renderer))},this.disableRaycaster=()=>{W.disable(),W=void 0},this.isSyncControl=()=>currentMpde===i.SYNC_CONTROL,this.enableSyncControl=()=>(v=i.SYNC_CONTROL,P||(P=new ws),P.setCurrentCameraSettings(this.cameraObject,j[g]),P),this.disableSyncControl=()=>{v=i.DEFAULT,this.cameraObject.zoom=1,this.cameraObject.updateProjectionMatrix()},this.enable()},ai=function(r,e,t,s){const i=r.eyePosition,n=r.targetPosition,o=r.upVector,a=e.eyePosition,h=e.targetPosition,f=e.upVector,c=t;let l=s,d=0,u=!1;c.near=Math.min(r.nearPlane,e.nearPlane),c.far=Math.max(r.farPlane,e.farPlane),c.cameraObject.up.set(e.upVector[0],e.upVector[1],e.upVector[2]),this.setDuration=x=>{l=x};const p=x=>{let g=d+x;g>l&&(g=l),d=g},y=()=>{const x=d/l,g=[i[0]*(1-x)+a[0]*x,i[1]*(1-x)+a[1]*x,i[2]*(1-x)+a[2]*x],v=[n[0]*(1-x)+h[0]*x,n[1]*(1-x)+h[1]*x,n[2]*(1-x)+h[2]*x];o[0]*(1-x)+f[0]*x,o[1]*(1-x)+f[1]*x,o[2]*(1-x)+f[2]*x,c.cameraObject.position.set(g[0],g[1],g[2]),c.cameraObject.target.set(v[0],v[1],v[2])};this.update=x=>{this.enabled!==!1&&(p(x),y(),d==l&&(u=!0))},this.isTransitionCompleted=()=>u},bs=function(r,e,t,s){const i=r,n=e,o=t;let a=s,h=0,f=!1;this.setDuration=l=>{a=l};const c=l=>{const d=h;let u=h+l;u>a&&(u=a),h=u;const x=(h-d)/a*n;o.rotateAboutLookAtpoint(i,x)};this.update=l=>{this.enabled!==!1&&(c(l),h==a&&(f=!0))},this.isTransitionCompleted=()=>f},li=function(r,e,t,s,i){const n=r,o=e,a=i,h=t,f=s;let c=!0;const l=new M.Raycaster;l.params.Line.threshold=.1,l.params.Points.threshold=1;const d=new M.Vector2;let u=!1,p=new Date,y=!1,x=0,g=new Array,v={zincCamera:void 0,x:-1,y:-1},_;this.enable=()=>{c=!0},this.disable=()=>{c=!1},this.getIntersectsObject=V=>{if(o!==n){const W=n.getThreeJSScene();a.render(W,V.cameraObject)}let R=_||n.getPickableThreeJSObjects();return g.length=0,l.intersectObjects(R,!0,g)},this.setPickableObjects=V=>{V===void 0?_=void 0:(_=[],V.forEach(R=>{R.getGroup()&&R.getGroup().visible&&_.push(R.getGroup())}))},this.getIntersectsObjectWithOrigin=(V,R,W)=>(l.set(R,W),this.getIntersectsObject(V)),this.getIntersectsObjectWithCamera=(V,R,W)=>(V.getNDCFromDocumentCoords(R,W,d),l.setFromCamera(d,V.cameraObject),this.getIntersectsObject(V)),this.pick=(V,R,W)=>{if(c&&a&&n&&V&&h){this.getIntersectsObjectWithCamera(V,R,W);const G=g.length;for(let L=0;L<G;L++){let T=g[L].object?g[L].object.userData:void 0;if(T&&T.isMarkerCluster&&T.visible&&T.clusterIsVisible(g[L].object.clusterIndex)&&T.zoomToCluster(g[L].object.clusterIndex))return}h(g,R,W)}};let I=(V,R,W)=>{if(c&&a&&n&&V&&f){if(this.getIntersectsObjectWithCamera(V,R,W),p.setTime(Date.now()),g.length===0){if(y)return;y=!0}else y=!1;f(g,R,W)}};this.move=(V,R,W)=>{c&&a&&n&&V&&f&&(n.displayMarkers?I(V,R,W):(v.zincCamera=V,v.x=R,v.y=W,u||(x=p?Date.now()-p.getTime():250,x>=250?I(V,R,W):(u=!0,setTimeout(k(v),x)))))};let k=V=>function(){u=!1,I(V.zincCamera,V.x,V.y)}},ci=function(r,e,t,s){const i=new M.Vector3,n=-e,o=s,a=r;this.stopOnCameraInput=t,this.requireUpdate=!0;const h=new M.Vector3,f=new M.Vector3,c=l=>{const d=Math.sqrt(l[0]*l[0]+l[1]*l[1]),u=Math.abs(l[0])*4,p=Math.abs(l[1])*4,y=.25*(u+p),x=-l[1]/d,g=l[0]/d;let v=x*l[0]+g*-l[1];v>y?v=y:v<-y&&(v=-y);const _=Math.acos(v/y)-.5*Math.PI;i.copy(o.cameraObject.position).sub(o.cameraObject.target).normalize(),h.copy(o.cameraObject.up).normalize(),f.crossVectors(h,i).normalize().multiplyScalar(x),h.multiplyScalar(g),h.add(f).multiplyScalar(Math.cos(_)),i.multiplyScalar(Math.sin(_)).add(h)};this.update=l=>{this.enabled!==!1&&(this.requireUpdate&&(c(a),this.requireUpdate=!1),o.rotateAboutLookAtpoint(i,n*l/1e3))}},hi=function(){this.type="StereoCamera",this.aspect=1,this.cameraL=new M.PerspectiveCamera,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new M.PerspectiveCamera,this.cameraR.layers.enable(2),this.cameraR.matrixAutoUpdate=!1};Object.assign(hi.prototype,{update:(()=>{let r,e,t,s,i,n;const o=new M.Matrix4,a=new M.Matrix4;return function(f){if(r!==f.focus||e!==f.fov||t!==f.aspect*this.aspect||s!==f.near||i!==f.far||n!==f.zoom){r=f.focus,e=f.fov,t=f.aspect*this.aspect,s=f.near,i=f.far,n=f.zoom;const l=f.projectionMatrix.clone(),d=.064/2,u=d*s/r,p=s*Math.tan(M.Math.DEG2RAD*e*.5)/f.zoom;let y,x;a.elements[12]=-d,o.elements[12]=d,y=-p*t+u,x=p*t+u,l.elements[0]=2*s/(x-y),l.elements[8]=(x+y)/(x-y),this.cameraL.projectionMatrix.copy(l),y=-p*t-u,x=p*t-u,l.elements[0]=2*s/(x-y),l.elements[8]=(x+y)/(x-y),this.cameraR.projectionMatrix.copy(l)}this.cameraL.matrixWorld.copy(f.matrixWorld).multiply(a),this.cameraR.matrixWorld.copy(f.matrixWorld).multiply(o)}})()});const ui=function(r){const e=new hi;e.aspect=.5,this.setSize=(t,s)=>{r.setSize(t,s)},this.render=(t,s)=>{t.updateMatrixWorld(),s.parent===null&&s.updateMatrixWorld(),e.update(s);const i=r.getSize();r.setScissorTest(!0),r.clear(),r.setScissor(0,0,i.width/2,i.height),r.setViewport(0,0,i.width/2,i.height),r.render(t,e.cameraL),r.setScissor(i.width/2,0,i.width/2,i.height),r.setViewport(i.width/2,0,i.width/2,i.height),r.render(t,e.cameraR),r.setScissorTest(!1)}},As=function(r){const e=this;this.object=r,this.object.rotation.reorder("YXZ"),this.enabled=!0,this.deviceOrientation={},this.screenOrientation=0;const t=n=>{e.deviceOrientation=n},s=()=>{typeof window<"u"&&(e.screenOrientation=window.orientation||0)},i=(()=>{const n=new M.Vector3(0,0,1),o=new M.Euler,a=new M.Quaternion,h=new M.Quaternion(-Math.sqrt(.5),0,0,Math.sqrt(.5));return(f,c,l,d,u)=>{const p=new M.Vector3(0,0,1);p.subVectors(f.target,f.position),o.set(l,c,-d,"YXZ");const y=new M.Quaternion;y.setFromEuler(o),y.multiply(h),y.multiply(a.setFromAxisAngle(n,-u)),p.applyQuaternion(y),p.addVectors(f.position,p),f.lookAt(p)}})();this.connect=()=>{s(),typeof window<"u"&&(window.addEventListener("orientationchange",s,!1),window.addEventListener("deviceorientation",t,!1)),e.enabled=!0},this.disconnect=()=>{typeof window<"u"&&(window.removeEventListener("orientationchange",s,!1),window.removeEventListener("deviceorientation",t,!1)),e.enabled=!1},this.update=()=>{if(e.enabled===!1)return;const n=e.deviceOrientation.alpha?M.Math.degToRad(e.deviceOrientation.alpha):0,o=e.deviceOrientation.beta?M.Math.degToRad(e.deviceOrientation.beta):0,a=e.deviceOrientation.gamma?M.Math.degToRad(e.deviceOrientation.gamma):0,h=e.screenOrientation?M.Math.degToRad(e.screenOrientation):0;i(e.object,n,o,a,h)},this.dispose=function(){this.disconnect()},this.connect()},ws=function(){let r,e,t;const s=new M.Vector3,i=new M.Vector3,n=new M.Vector3,o=new M.Vector3;let a;this.setCurrentCameraSettings=(h,f)=>{this.near_plane_fly_debt==0,r=h.clone(),e=h,t=f,r.near=t.nearPlane,t.farPlane&&(r.far=t.farPlane),t.eyePosition&&r.position.set(t.eyePosition[0],t.eyePosition[1],t.eyePosition[2]),t.upVector&&r.up.set(t.upVector[0],t.upVector[1],t.upVector[2]),t.targetPosition&&(r.target=new M.Vector3(t.targetPosition[0],t.targetPosition[1],t.targetPosition[2]),r.lookAt(r.target)),r.updateProjectionMatrix(),s.copy(r.position).project(r),i.copy(r.target).project(r)},this.getCurrentPosition=()=>(i.copy(e.target).project(r),[i.x,i.y]),this.zoom=h=>{let f=h*.002,c=Math.max(e.zoom-f,1);e.zoom=c,e.updateProjectionMatrix()},this.zoomToBox=(h,f)=>{h.getCenter(n),n.project(r),this.setCenterZoom([n.x,n.y],f)},this.getPanZoom=()=>({target:this.getCurrentPosition(),zoom:e.zoom}),this.setCenterZoom=(h,f)=>{n.set(h[0],h[1],i.z).unproject(r),o.copy(n).sub(e.target),e.target.copy(n),e.lookAt(e.target),e.position.add(o),e.zoom=f,e.updateProjectionMatrix()},this.setEventCallback=h=>{(h===void 0||typeof h=="function")&&(a=h)},this.triggerCallback=()=>{a!==void 0&&typeof a=="function"&&a()}},vs="data:image/svg+xml,%3c?xml%20version='1.0'%20encoding='UTF-8'%20standalone='no'%20?%3e%3c!DOCTYPE%20svg%20PUBLIC%20'-//W3C//DTD%20SVG%201.1//EN'%20'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'%3e%3csvg%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20version='1.1'%20width='365'%20height='560'%20viewBox='0%200%20365%20560'%20xml:space='preserve'%3e%3cdesc%3eCreated%20with%20Fabric.js%205.2.4%3c/desc%3e%3cdefs%3e%3c/defs%3e%3crect%20x='0'%20y='0'%20width='100%25'%20height='100%25'%20fill='transparent'%3e%3c/rect%3e%3cg%20transform='matrix(0%200%200%200%200%200)'%20id='808ed283-2524-440f-88ae-3bdb47bb5749'%20%3e%3c/g%3e%3cg%20transform='matrix(1%200%200%201%20182.5%20280)'%20id='db30413d-5bff-4b98-ab59-464497ee199e'%20%3e%3crect%20style='stroke:%20none;%20stroke-width:%201;%20stroke-dasharray:%20none;%20stroke-linecap:%20butt;%20stroke-dashoffset:%200;%20stroke-linejoin:%20miter;%20stroke-miterlimit:%204;%20fill:%20rgb(255,255,255);%20fill-rule:%20nonzero;%20opacity:%201;%20visibility:%20hidden;'%20vector-effect='non-scaling-stroke'%20x='-182.5'%20y='-280'%20rx='0'%20ry='0'%20width='365'%20height='560'%20/%3e%3c/g%3e%3cg%20transform='matrix(0%200%200%200%200%2097.5)'%20%3e%3cg%20style=''%20%3e%3c/g%3e%3c/g%3e%3cg%20transform='matrix(0%200%200%200%200%2097.5)'%20%3e%3cg%20style=''%20%3e%3c/g%3e%3c/g%3e%3cg%20transform='matrix(0.99%200%200%200.99%20182.5%20280)'%20%3e%3cg%20style=''%20vector-effect='non-scaling-stroke'%20%3e%3cg%20transform='matrix(1%200%200%201%200%200)'%20%3e%3crect%20style='stroke:%20none;%20stroke-width:%201;%20stroke-dasharray:%20none;%20stroke-linecap:%20butt;%20stroke-dashoffset:%200;%20stroke-linejoin:%20miter;%20stroke-miterlimit:%204;%20fill:%20rgb(255,255,255);%20fill-rule:%20nonzero;%20opacity:%201;%20visibility:%20hidden;'%20vector-effect='non-scaling-stroke'%20x='-540'%20y='-540'%20rx='0'%20ry='0'%20width='1080'%20height='1080'%20/%3e%3c/g%3e%3cg%20transform='matrix(1%200%200%201%200%200)'%20%3e%3cpath%20style='stroke:%20rgb(0,0,0);%20stroke-width:%200;%20stroke-dasharray:%20none;%20stroke-linecap:%20butt;%20stroke-dashoffset:%200;%20stroke-linejoin:%20miter;%20stroke-miterlimit:%204;%20fill:%20rgb(255,165,0);%20fill-rule:%20nonzero;%20opacity:%201;'%20vector-effect='non-scaling-stroke'%20transform='%20translate(-182.9,%20-279.85)'%20d='M%20182.9%20551.7%20C%20182.9%20551.8000000000001%20183.1%20552%20183.1%20552%20C%20183.1%20552%20358.3%20283%20358.3%20194.6%20C%20358.3%2064.5%20269.5%207.900000000000006%20182.9%207.699999999999989%20C%2096.3%207.9%207.5%2064.5%207.5%20194.6%20C%207.5%20283%20182.8%20552%20182.8%20552%20C%20182.8%20552%20182.9%20551.7%20182.9%20551.7%20z%20M%20122.2%20187.2%20C%20122.2%20153.6%20149.4%20126.39999999999999%20183%20126.39999999999999%20C%20216.6%20126.39999999999999%20243.8%20153.6%20243.8%20187.2%20C%20243.8%20220.79999999999998%20216.5%20248%20182.9%20248%20C%20149.4%20248%20122.2%20220.8%20122.2%20187.2%20z'%20stroke-linecap='round'%20/%3e%3c/g%3e%3cg%20transform='matrix(3.82%200%200%203.82%200%20-100.77)'%20%3e%3ccircle%20style='stroke:%20rgb(0,0,0);%20stroke-width:%200;%20stroke-dasharray:%20none;%20stroke-linecap:%20butt;%20stroke-dashoffset:%200;%20stroke-linejoin:%20miter;%20stroke-miterlimit:%204;%20fill:%20rgb(255,255,255);%20fill-rule:%20nonzero;%20opacity:%201;'%20vector-effect='non-scaling-stroke'%20cx='0'%20cy='0'%20r='35'%20/%3e%3c/g%3e%3c/g%3e%3c/g%3e%3c/svg%3e",fi=new Image(128,128);fi.src=vs;const ct=new M.Texture;ct.image=fi,ct.needsUpdate=!0;const Ct=[.02,.03,1],_s=new M.SpriteMaterial({map:ct,alphaTest:.5,transparent:!0,depthTest:!1,depthWrite:!1,sizeAttenuation:!1}),di=function(r){Q.call(this),this.texture=ct;let e,t=r;this.morph=new M.Group,this.group=this.morph,this.isMarkerCluster=!0;let s=!0,i=[];this.markers={};let n=new M.Vector2,o=new M.Vector2,a=.1,h=Date.now();this.setSpriteSize=u=>{e.scale.set(.015,.02,1),e.scale.multiplyScalar(u)},this.clear=()=>{this.group.clear(),this.markers={}},this.dispose=()=>{this.clear(),this.morph&&this.morph.clear()};const f=u=>{const p=new M.Group,y=new M.Sprite(_s);return y.clusterIndex=u,y.center.set(.5,0),y.position.set(0,0,0),y.renderOrder=1e4,y.scale.set(Ct[0],Ct[1],Ct[2]),y.userData=this,p.add(y),this.group.add(p),{group:p,marker:y,label:void 0,number:0,min:[0,0,0],max:[1,1,1]}},c=(u,p,y)=>{u.group.visible=!0,u.group.position.set(p.coords[0],p.coords[1],p.coords[2]),(u.label===void 0||y!==u.number)&&(u.label&&(u.group.remove(u.label),u.label.material.map.dispose(),u.label.material.dispose()),u.label=mt(y,.012,"black","Asap",120,700),u.number=y,u.group.add(u.label)),u.min=p.min,u.max=p.max},l=u=>{let p=0;for(u.forEach(y=>{const x=y.members.length;let g=0;x===1?y.members[0].setVisibility(!0):(y.members.forEach(v=>{g+=v.getNumber(),v.setVisibility(!1)}),i[p]||i.push(f(p)),c(i[p],y,g),p++)}),p;p<i.length;p++)i[p].group.visible=!1},d=(u,p)=>{let y=!0,x={members:[],coords:[0,0,0],min:[0,0,0],max:[1,1,1]},g=0;for(let v in u)y?(n.set(u[v].ndc.x,u[v].ndc.y),this._b1.setFromPoints([u[v].morph.position]),y=!1,x.members.push(u[v]),x.coords=[u[v].morph.position.x,u[v].morph.position.y,u[v].morph.position.z],p.push(x),delete u[v]):(o.set(u[v].ndc.x,u[v].ndc.y),g=n.distanceTo(o),a>g&&(x.members.push(u[v]),this._b1.expandByPoint(u[v].morph.position),delete u[v]));x.min=[this._b1.min.x,this._b1.min.y,this._b1.min.z],x.max=[this._b1.max.x,this._b1.max.y,this._b1.max.z],y!==!0&&d(u,p)};this.calculate=()=>{if(s&&Date.now()-h>500){let p=[];d({...this.markers},p),l(p),h=Date.now(),this.markerUpdateRequired=!1}},this.isEnabled=()=>s,this.enable=()=>{s=!0,this.morph.visible=!0},this.disable=()=>{var u;s=!1,this.morph.visible=!1;for(let p in this.markers)(u=this.markers[p])!=null&&u.isMarker&&this.markers[p].isEnabled()&&this.markers[p].setVisibility(!0)},this.zoomToCluster=u=>u!==void 0&&u>-1&&(this._v1.set(...i[u].min),this._v2.set(...i[u].max),Math.abs(this._v1.distanceTo(this._v2)>0))?(this._b1.set(this._v1,this._v2),t.translateBoundingBoxToCameraView(this._b1,3,300),this.markerUpdateRequired=!0,!0):!1,this.clusterIsVisible=u=>{var p;return u!==void 0&&u>-1&&i[u]?(p=i[u].group)==null?void 0:p.visible:!1}};di.prototype=Object.create(Q.prototype);const Ms=function(r){let e=r;this.camera=new M.OrthographicCamera(-.5,.5,.5,-.5,.01,10),this.helper=void 0;let t=new M.BufferGeometry;var s=new Float32Array([-1,-1,1,1,-1,1,1,1,1,1,1,1,-1,1,1,-1,-1,1]);let i=new M.BufferAttribute(s,3);t.setAttribute("position",i);var n=new M.MeshBasicMaterial({color:3355443,depthTest:!1,depthWrite:!1,opacity:.5,transparent:!0});this.mask=new M.Mesh(t,n);let o=new M.Box3,a=new M.Vector3;this.getDiffFromNormalised=(f,c)=>{o.setFromBufferAttribute(i).getCenter(a);let l=a.clone().project(this.camera);return new M.Vector3(f,c,l.z).unproject(this.camera).sub(a)};let h=(f,c)=>{e.camera.near&&(this.camera.near=e.camera.near),c.farPlane&&(this.camera.far=c.farPlane),c.eyePosition&&this.camera.position.set(c.eyePosition[0],c.eyePosition[1],c.eyePosition[2]),c.upVector&&this.camera.up.set(c.upVector[0],c.upVector[1],c.upVector[2]),c.targetPosition&&this.camera.lookAt(new M.Vector3(c.targetPosition[0],c.targetPosition[1],c.targetPosition[2])),this.camera.zoom=1/f,this.camera.updateProjectionMatrix()};this.getBoundary=()=>{let f=new M.Vector3().copy(e.camera.target).project(e.camera),c=new M.Vector3(-1,-1,f.z).unproject(e.camera),l=new M.Vector3(1,-1,f.z).unproject(e.camera),d=new M.Vector3(1,1,f.z).unproject(e.camera),u=new M.Vector3(-1,1,f.z).unproject(e.camera),p=[c,l,d,d,u,c];i.copyVector3sArray(p),i.needsUpdate=!0},this.updateCamera=()=>{this.getBoundary();let f=e.getZincCameraControls(),c=e.getBoundingBox();if(c){const l=c.min.distanceTo(c.max),d=l/2,u=(c.min.x+c.max.x)/2,p=(c.min.y+c.max.y)/2,y=(c.min.z+c.max.z)/2,g=f.getViewportFromCentreAndRadius(u,p,y,d,40,d*4);h(l,g)}}},pi=new b.Box3,ht=new b.Vector3;class Tt extends b.InstancedBufferGeometry{constructor(){super(),this.type="LineSegmentsGeometry";const e=[-1,2,0,1,2,0,-1,1,0,1,1,0,-1,0,0,1,0,0,-1,-1,0,1,-1,0],t=[-1,2,1,2,-1,1,1,1,-1,-1,1,-1,-1,-2,1,-2],s=[0,2,1,2,3,1,2,4,3,4,5,3,4,6,5,6,7,5];this.setIndex(s),this.setAttribute("position",new b.Float32BufferAttribute(e,3)),this.setAttribute("uv",new b.Float32BufferAttribute(t,2))}applyMatrix4(e){const t=this.attributes.instanceStart,s=this.attributes.instanceEnd;return t!==void 0&&(t.applyMatrix4(e),s.applyMatrix4(e),t.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}setPositions(e){let t;e instanceof Float32Array?t=e:Array.isArray(e)&&(t=new Float32Array(e));const s=new b.InstancedInterleavedBuffer(t,6,1);return this.setAttribute("instanceStart",new b.InterleavedBufferAttribute(s,3,0)),this.setAttribute("instanceEnd",new b.InterleavedBufferAttribute(s,3,3)),this.computeBoundingBox(),this.computeBoundingSphere(),this}setColors(e){let t;e instanceof Float32Array?t=e:Array.isArray(e)&&(t=new Float32Array(e));const s=new b.InstancedInterleavedBuffer(t,6,1);return this.setAttribute("instanceColorStart",new b.InterleavedBufferAttribute(s,3,0)),this.setAttribute("instanceColorEnd",new b.InterleavedBufferAttribute(s,3,3)),this}fromWireframeGeometry(e){return this.setPositions(e.attributes.position.array),this}fromEdgesGeometry(e){return this.setPositions(e.attributes.position.array),this}fromMesh(e){return this.fromWireframeGeometry(new b.WireframeGeometry(e.geometry)),this}fromLineSegments(e){const t=e.geometry;if(t.isGeometry){console.error("THREE.LineSegmentsGeometry no longer supports Geometry. Use THREE.BufferGeometry instead.");return}else t.isBufferGeometry&&this.setPositions(t.attributes.position.array);return this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new b.Box3);const e=this.attributes.instanceStart,t=this.attributes.instanceEnd;e!==void 0&&t!==void 0&&(this.boundingBox.setFromBufferAttribute(e),pi.setFromBufferAttribute(t),this.boundingBox.union(pi))}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new b.Sphere),this.boundingBox===null&&this.computeBoundingBox();const e=this.attributes.instanceStart,t=this.attributes.instanceEnd;if(e!==void 0&&t!==void 0){const s=this.boundingSphere.center;this.boundingBox.getCenter(s);let i=0;for(let n=0,o=e.count;n<o;n++)ht.fromBufferAttribute(e,n),i=Math.max(i,s.distanceToSquared(ht)),ht.fromBufferAttribute(t,n),i=Math.max(i,s.distanceToSquared(ht));this.boundingSphere.radius=Math.sqrt(i),isNaN(this.boundingSphere.radius)&&console.error("THREE.LineSegmentsGeometry.computeBoundingSphere(): Computed radius is NaN. The instanced position data is likely to have NaN values.",this)}}toJSON(){}applyMatrix(e){return console.warn("THREE.LineSegmentsGeometry: applyMatrix() has been renamed to applyMatrix4()."),this.applyMatrix4(e)}}Tt.prototype.isLineSegmentsGeometry=!0,b.UniformsLib.line={linewidth:{value:1},resolution:{value:new b.Vector2(1,1)},dashScale:{value:1},dashSize:{value:1},dashOffset:{value:0},gapSize:{value:1},opacity:{value:1}},b.ShaderLib.line={uniforms:b.UniformsUtils.merge([b.UniformsLib.common,b.UniformsLib.fog,b.UniformsLib.line]),vertexShader:`
68
+ `,tt=function(){return{brightness:{value:0},contrast:{value:1},depth:{value:1},discardAlpha:{value:!0},diffuse0:{value:void 0},diffuse1:{value:void 0},direction:{value:1},flipY:{value:!0},flipZ:{value:!1},nChannels:{value:1},mask:{value:void 0},maskEnabled:{value:!1},slide:{value:new e.Vector3(0,0,1)},time:{value:0}}},nt=function(e){B.call(this),this.isTexturePrimitive=!0,this.texture=e,this.textureList=[],this.texture&&this.textureList.push(this.texture),this.load=(e,t,n)=>{if(e&&e.images&&e.images.source){let n=new Ze,r=[];e.images.source.forEach(e=>{r.push(e)});let i=this;n.loadFromImages(r).then(()=>{i.texture=n,i.textureList.push(this.texture),i.initialise(e,t)})}},this.addTextureArray=e=>{this.textureList.length===0&&this.texture&&this.textureList.push(this.texture),e&&e.isTextureArray&&this.textureList.push(e)},this.initialise=(e,t)=>{t!=null&&typeof t==`function`&&t(this)}};nt.prototype=Object.create(B.prototype),nt.prototype.constructor=nt;var rt=function(t){nt.call(this,t),this.isTextureSlides=!0;let n=[],r={};this.morph=new e.Group,this.group=this.morph,this.morph.userData=this;let i,a=!0,o=!1,s=0,c=1,l=1,u,d=!1,f=!0,p=0,m=0,h=-.1;this.createSlides=e=>{e.forEach(e=>this.createSlide(e))};let g=(e,t)=>{let n=e.material,r=n.uniforms;switch(e.rotation.x=0,e.rotation.y=0,e.rotation.z=0,e.position.x=0,e.position.y=0,e.position.z=0,t.direction){case`x`:let n=-Math.PI/2;e.rotation.y=n,r.direction.value=1,r.slide.value.set(t.value,0,0),e.position.x=t.value;break;case`y`:e.rotation.x=Math.PI/2,r.direction.value=2,r.slide.value.set(0,t.value,0),e.position.y=t.value;break;case`z`:r.direction.value=3,r.slide.value.set(0,0,t.value),e.position.z=t.value}n.needsUpdate=!0,this.boundingBoxUpdateRequired=!0};this.modifySlideSettings=e=>{e&&e.id&&e.id in r&&r[e.id]&&g(r[e.id],e)},this.createSlide=t=>{if(this.texture&&this.texture.isTextureArray&&this.texture.isReady()&&t&&t.direction&&t.value!==void 0){let i=new e.PlaneGeometry(1,1);i.translate(.5,.5,0);let p=tt();p.brightness.value=s,p.contrast.value=c,p.diffuse0.value=this.texture.impl,p.diffuse1.value=this.texture.impl,p.discardAlpha.value=f,p.depth.value=this.texture.size.depth,p.flipY.value=a,p.flipZ.value=o,p.mask.value=u,p.maskEnabled.value=d,p.nChannels.value=l;let m={fs:$e,vs:et,uniforms:p,glslVersion:Qe,side:e.DoubleSide,transparent:!1},h=this.texture.getMaterial(m);h.needsUpdate=!0;let _=new e.Mesh(i,h);_.name=this.groupName,_.userData=this;let v={value:t.value,direction:t.direction,id:_.id};return n.push(v),g(_,v),r[_.id]=_,this.morph.add(_),this.boundingBoxUpdateRequired=!0,this.updateTimeTexture(),v}},this.getTextureSettings=()=>[...n],this.getTextureSettingsWithId=e=>{for(let t=0;t<n.length;t++)if(e===n[t].id)return{...n[t]}},this.getSlides=()=>this.morph?[...this.morph.children]:[],this.removeSlide=e=>{e&&this.removeSlideWithId(e.id)},this.removeSlideWithId=e=>{if(this.morph&&e in r&&r[e]){if(this.morph.getObjectById(e)){let t=r[e];this.morph.remove(t),t.clear(),t.geometry&&t.geometry.dispose(),t.material&&t.material.dispose(),this.boundingBoxUpdateRequired=!0}let t=n.findIndex(t=>t.id===e);t>-1&&n.splice(t,1)}},this.dispose=()=>{this.morph.children.forEach(e=>{e.geometry&&e.geometry.dispose(),e.material&&e.material.dispose()}),nt.prototype.dispose.call(this),this.boundingBoxUpdateRequired=!0};let _=(e,t,n)=>{if(t)switch(t.direction.value){case 1:n.copy(t.slide.value),e.expandByPoint(n),n.setY(1),n.setZ(1),e.expandByPoint(n);break;case 2:n.copy(t.slide.value),e.expandByPoint(n),n.setX(1),n.setZ(1),e.expandByPoint(n);break;case 3:n.copy(t.slide.value),e.expandByPoint(n),n.setX(1),n.setY(1),e.expandByPoint(n)}};this.getBoundingBox=()=>{if(this.morph&&this.morph.children&&this.morph.visible&&this.boundingBoxUpdateRequired){this.cachedBoundingBox.makeEmpty();let t=new e.Vector3(0,0,0);this.morph.children.forEach(e=>{_(this.cachedBoundingBox,e.material.uniforms,t)}),this.morph.updateMatrixWorld(!0,!0),this.cachedBoundingBox.applyMatrix4(this.morph.matrixWorld),this.boundingBoxUpdateRequired=!1}return this.cachedBoundingBox},this.applyTransformation=(t,n,r)=>{let i=new e.Matrix4;i.set(t[0],t[1],t[2],0,t[3],t[4],t[5],0,t[6],t[7],t[8],0,0,0,0,0);let a=new e.Quaternion().setFromRotationMatrix(i);this.morph.position.set(...n),this.morph.quaternion.copy(a),this.morph.scale.set(...r),this.morph.updateMatrix(),this.boundingBoxUpdateRequired=!0},this.setRenderOrder=e=>{this.morph.renderOrder=e},this.initialise=(e,t)=>{if(e){let n=e.locations;n&&n.length>0&&(this.applyTransformation(n[0].orientation,n[0].position,n[0].scale),`flipY`in n[0]&&(a=n[0].flipY),`flipZ`in n[0]&&(o=n[0].flipZ)),this.createSlides(e.settings.slides),t!=null&&typeof t==`function`&&t(this)}},this.showEdges=t=>{if(i)i.material.color=t;else{let n=new e.BoxGeometry(1,1,1);n.translate(.5,.5,.5);let r=new e.EdgesGeometry(n);i=new e.LineSegments(r,new e.LineBasicMaterial({color:t})),this.group.add(i)}i.visible=!0},this.setUniformsValue=(e,t)=>{this.morph.children.forEach(n=>{let r=n.material;if(r.type===`ShaderMaterial`){let n=r.uniforms;n[e].value=t,r.needsUpdate=!0}})},this.isAlphaPixelDiscarded=()=>f,this.discardAlphaPixel=e=>{f=e,this.setUniformsValue(`discardAlpha`,f)},this.getBrightness=()=>s,this.setBrightness=e=>{s=e,this.setUniformsValue(`brightness`,s)},this.getContrast=()=>c,this.setContrast=e=>{c>=0&&(c=e,this.setUniformsValue(`contrast`,c))},this.getNumberOfChannels=()=>l,this.setNumberOfChannels=e=>{l=e,this.setUniformsValue(`nChannels`,l)},this.getMask=()=>u,this.setMask=e=>{u=e,d=!!u,this.setUniformsValue(`mask`,u),this.setUniformsValue(`maskEnabled`,d)},this.hideEdges=()=>{i&&(i.visible=!1)},this.updateTimeTexture=()=>{let e=this.textureList.length-1,t=this.inbuildTime/this.duration;if(this.timeEnabled&&e>0&&h!==t){let n=t*e,r=Math.floor(n),i=Math.ceil(n),a=n-r;this.morph.children.forEach(e=>{let t=e.material;if(t.type===`ShaderMaterial`){let e=t.uniforms;p!==r&&(e.diffuse0.value=this.textureList[r].impl),m!==i&&(e.diffuse1.value=this.textureList[i].impl),e.time.value=a,t.needsUpdate=!0}}),p=r,m=i,h=t}},this.setMorphTime=e=>{let t=e;t=e>this.duration?this.duration:0>e?0:e,t!=this.inbuildTime&&(this.inbuildTime=t,this.updateTimeTexture())},this.render=(e,t,n)=>{if(t==1&&this.timeEnabled&&this.textureList.length>1){let t=this.inbuildTime+e;t>this.duration&&(t-=this.duration),this.inbuildTime=t,this.updateTimeTexture()}}};rt.prototype=Object.create(nt.prototype),rt.prototype.constructor=rt;var it=function(){this.nearPlane=.168248,this.farPlane=6.82906,this.eyePosition=[.5,-2.86496,.5],this.targetPosition=[.5,.5,.5],this.upVector=[0,0,1];let e=this;this.setFromObject=({nearPlane:t,farPlane:n,eyePosition:r,targetPosition:i,upVector:a})=>{e.nearPlane=t,e.farPlane=n,e.eyePosition=r,e.targetPosition=i,e.upVector=a}},at=function(t,n,r,i){let a={NONE:-1,DEFAULT:0,PATH:1,SMOOTH_CAMERA_TRANSITION:2,AUTO_TUMBLE:3,ROTATE_TRANSITION:4,MINIMAP:5,SYNC_CONTROL:6},o={NONE:-1,ROTATE:0,ZOOM:1,PAN:2,TOUCH_ROTATE:3,TOUCH_ZOOM:4,TOUCH_PAN:5,SCROLL:6,KEYBOARD_ZOOM:7,KEYBOARD_ROTATE:8,KEYBOARD_PAN:9},s={NONE:-1,FREE:1,HORIZONTAL:2,VERTICAL:3},c={ARROWLEFT:37,ARROWUP:38,ARROWRIGHT:39,ARROWDOWN:40,NUMPADADD:107,NUMPADSUBTRACT:109,EQUAL:187,MINUS:189},l={};l.MAIN=o.ROTATE,l.AUXILIARY=o.ZOOM,l.SECONDARY=o.PAN,this.cameraObject=t,this.domElement=n===void 0?document:n,this.renderer=r,this.scene=i,this.tumble_rate=1.5,this.pointer_x=0,this.pointer_y=0,this.pointer_x_start=0,this.pointer_y_start=0,this.previous_pointer_x=0,this.previous_pointer_y=0,this.near_plane_fly_debt=0,this.touchZoomDistanceStart=0,this.touchZoomDistanceEnd=0,this.directionalLight=0,this.zoomRate=50,this.rotateRate=50,this.panRate=100,this.pixelHeight=1;let u=6e3,d=!0,f=0,p,m,h=!1,g=500,_,v=`default`,y=a.DEFAULT,b,x,S,C=0,w=s.FREE;this._state=o.NONE;let T;this.targetTouchId=-1;let E,D=new e.Vector3,O=new e.Vector3,k=new e.Vector3,A=new e.Vector3,j=new e.Vector3,M=new e.Vector3,N=new e.Vector3,P=new e.Vector3,F=new e.Sphere,I=new e.Vector3,ee=!1,L,te=0,R={default:new it};R.default.nearPlane=.1,R.default.farPlane=2e3,R.default.eyePosition=[0,0,0],R.default.targetPosition=[0,0,-1],R.default.upVector=[0,1,0],this.cameraObject.target===void 0&&(this.cameraObject.target=new e.Vector3(...R.default.targetPosition)),this.calculateMaxAllowedDistance=e=>{let t=e.getBoundingBox();if(t){t.getBoundingSphere(F),te=F.radius*6;let e=0;this.cameraObject&&(e=this.cameraObject.position.distanceTo(F.center)),te=e>te?e*1.5:te}else te=0};let ne=e=>{D.copy(this.cameraObject.position);let t=D.sub(this.cameraObject.target).length();this.cameraObject.near=Math.max(1e-4,t*.001),this.cameraObject.far=this.cameraObject.near*1e4};this.addViewport=(e,t)=>{e&&t&&(R[e]=t)},this.setDefaultViewport=e=>e&&e in R?(v=e,!0):!1,this.getDefaultViewport=()=>v,this.getViewportOfName=e=>R[e],this.setCurrentViewport=e=>e in R&&(this.setCurrentCameraSettings(R[e]),!0),this.setRotationMode=e=>{switch(e){case`none`:w=s.NONE;break;case`horizontal`:w=s.HORIZONTAL;break;case`vertical`:w=s.VERTICAL;break;default:w=s.FREE}},this.onResize=()=>{E&&=void 0,L&&L.setCurrentCameraSettings(this.cameraObject,R[v])},this.getVisibleHeightAtZDepth=e=>{let t=this.cameraObject.position.distanceTo(this.cameraObject.target);e<t?e-=t:e+=t;let n=this.cameraObject.fov*Math.PI/180;return 2*Math.tan(n/2)*Math.abs(e)},this.calculateHeightPerPixelAtZeroDepth=e=>{let t=this.getVisibleHeightAtZDepth(0);return this.pixelHeight=t/e,this.pixelHeight},this.getNDCFromDocumentCoords=(t,n,r)=>{z(!1);let i=r||new e.Vector2,a=(t-E.left)/E.width*2-1,o=-((n-E.top)/E.height)*2+1;return i.set(a,o)},this.getRelativeCoordsFromNDC=(t,n,r)=>{z(!1);let i=r||new e.Vector2;return i.x=(t+1)*E.width/2,i.y=(1-n)*E.height/2,i},this.setMouseButtonAction=(e,t)=>{l[e]=o[t]};let re=(e,t)=>{e instanceof HTMLCanvasElement&&(e.tabIndex=t)},ie=()=>{if(te>0){let e=I.distanceTo(F.center);return te>e||this.cameraObject.position.distanceTo(F.center)>e}return!0},ae=e=>{I.copy(this.cameraObject.position).add(e),ie()&&(this.cameraObject.target.add(e),this.cameraObject.position.add(e),this.updateDirectionalLight())},oe=e=>{z(!1);let t;if(y===a.DEFAULT&&(t=this.scene.getNormalisedMinimapCoordinates(this.renderer,e)),!t)e.button==0?this._state=e.ctrlKey?l.AUXILIARY:e.shiftKey?l.SECONDARY:l.MAIN:e.button==1?(e.preventDefault(),this._state=l.AUXILIARY):e.button==2&&(this._state=l.SECONDARY),this.pointer_x=e.clientX-E.left,this.pointer_y=e.clientY-E.top,this.pointer_x_start=this.pointer_x,this.pointer_y_start=this.pointer_y,this.previous_pointer_x=this.pointer_x,this.previous_pointer_y=this.pointer_y;else{y=a.MINIMAP;let e=this.scene.getMinimapDiffFromNormalised(t.x,t.y);ae(e)}},se=e=>{if(z(!1),E){if(this.pointer_x=e.clientX-E.left,this.pointer_y=e.clientY-E.top,y===a.MINIMAP){let t=this.scene.getNormalisedMinimapCoordinates(this.renderer,e);if(t){let e=this.scene.getMinimapDiffFromNormalised(t.x,t.y);ae(e)}}else this._state===o.NONE&&T!==void 0&&T.move(this,e.clientX,e.clientY,this.renderer)}},ce=e=>{this._state=o.NONE,y==a.MINIMAP&&(y=a.DEFAULT),T!==void 0&&this.pointer_x_start==e.clientX-E.left&&this.pointer_y_start==e.clientY-E.top&&T.pick(this,e.clientX,e.clientY,this.renderer)},le=e=>{this._state=o.NONE},ue=e=>{z(!1);let t=e.touches.length;if(t==1)this._state=o.TOUCH_ROTATE,this.pointer_x=e.touches[0].clientX-E?.left,this.pointer_y=e.touches[0].clientY-E?.top,this.pointer_x_start=this.pointer_x,this.pointer_y_start=this.pointer_y,this.previous_pointer_x=this.pointer_x,this.previous_pointer_y=this.pointer_y;else if(t==2){this._state=o.TOUCH_ZOOM;let t=e.touches[0].clientX-e.touches[1].clientX,n=e.touches[0].clientY-e.touches[1].clientY;this.touchZoomDistanceEnd=this.touchZoomDistanceStart=Math.sqrt(t*t+n*n)}else t==3&&(this._state=o.TOUCH_PAN,this.targetTouchId=e.touches[0].identifier,this.pointer_x=e.touches[0].clientX-E?.left,this.pointer_y=e.touches[0].clientY-E?.top,this.previous_pointer_x=this.pointer_x,this.previous_pointer_y=this.pointer_y)},de=e=>{e.preventDefault(),e.stopPropagation();let t=e.touches.length;if(t==1)this.pointer_x=e.touches[0].clientX-E.left,this.pointer_y=e.touches[0].clientY-E.top;else if(t==2){if(this._state===o.TOUCH_ZOOM){let t=e.touches[0].clientX-e.touches[1].clientX,n=e.touches[0].clientY-e.touches[1].clientY;this.touchZoomDistanceEnd=Math.sqrt(t*t+n*n)}}else if(t==3&&this._state===o.TOUCH_PAN)for(let t=0;t<3;t++)e.touches[t].identifier==this.targetTouchId&&(this.pointer_x=e.touches[0].clientX-E.left,this.pointer_y=e.touches[0].clientY-E.top)},fe=e=>{let t=e.touches.length;this.touchZoomDistanceStart=this.touchZoomDistanceEnd=0,this.targetTouchId=-1,this._state=o.NONE,t==1&&T!==void 0&&this.pointer_x_start==e.touches[0].clientX-E.left&&this.pointer_y_start==e.touches[0].clientY-E.top&&T.pick(this.cameraObject,e.touches[0].clientX,e.touches[0].clientY,this.renderer)},pe=()=>{z(!0)},z=e=>{if(e||E===void 0){let e=new IntersectionObserver(t=>{for(let e of t)E=e.boundingClientRect;e.disconnect()});e.observe(this.domElement)}},me=e=>{z(!1),this._state=o.SCROLL;let t=0;e.deltaY>0?t=this.zoomRate:e.deltaY<0&&(t=this.zoomRate*-1),C+=t,e.preventDefault(),e.stopImmediatePropagation()},he=e=>{z(!1);let t=0;if(e.keyCode===c.EQUAL||e.keyCode===c.MINUS||e.keyCode===c.NUMPADADD||e.keyCode===c.NUMPADSUBTRACT){this._state=o.KEYBOARD_ZOOM;let n=1;e.shiftKey&&(n*=2),e.keyCode===c.EQUAL||e.keyCode===c.NUMPADADD?t=this.zoomRate*n*-1:(e.keyCode===c.MINUS||e.keyCode===c.NUMPADSUBTRACT)&&(t=this.zoomRate*n),C+=t}else(e.keyCode===c.ARROWLEFT||e.keyCode===c.ARROWUP||e.keyCode===c.ARROWRIGHT||e.keyCode===c.ARROWDOWN)&&(e.shiftKey?(this._state=o.KEYBOARD_ROTATE,this.pointer_x_start=this.pointer_x,this.pointer_y_start=this.pointer_y,t=this.rotateRate):(this._state=o.KEYBOARD_PAN,t=this.panRate),this.previous_pointer_x=this.pointer_x,this.previous_pointer_y=this.pointer_y,e.keyCode===c.ARROWLEFT?this.pointer_x-=t:e.keyCode===c.ARROWUP?this.pointer_y-=t:e.keyCode===c.ARROWRIGHT?this.pointer_x+=t:e.keyCode===c.ARROWDOWN&&(this.pointer_y+=t));Object.values(c).includes(e.keyCode)&&e.preventDefault()},ge=e=>{this._state=o.NONE},_e=()=>{if(this.cameraObject!==void 0){let e=E.height,t=this.cameraObject.position.distanceTo(this.cameraObject.target),n=0;this.cameraObject.far>this.cameraObject.near&&t>=this.cameraObject.near&&t<=this.cameraObject.far&&(n=(t-this.cameraObject.near)/(this.cameraObject.far-this.cameraObject.near)),O.set(this.previous_pointer_x,e-this.previous_pointer_y,0),k.set(this.previous_pointer_x,e-this.previous_pointer_y,1),A.set(this.pointer_x,e-this.pointer_y,0),j.set(this.pointer_x,e-this.pointer_y,1),O.unproject(this.cameraObject),k.unproject(this.cameraObject),A.unproject(this.cameraObject),j.unproject(this.cameraObject),A.sub(O).multiplyScalar(1-n),j.sub(k).multiplyScalar(n),A.add(j).multiplyScalar(-.002),ae(A)}this.previous_pointer_x=this.pointer_x,this.previous_pointer_y=this.pointer_y};this.getVectorsFromRotateAboutLookAtPoints=(e,t)=>{e.normalize(),N.copy(this.cameraObject.position).sub(this.cameraObject.target),P.copy(N),N.normalize(),.8<Math.abs(N.dot(e))&&N.copy(this.cameraObject.up),O.crossVectors(e,N).normalize(),k.crossVectors(e,O);let n=e.dot(P),r=O.dot(P),i=k.dot(P),a=e.dot(this.cameraObject.up),o=O.dot(this.cameraObject.up),s=k.dot(this.cameraObject.up),c=Math.cos(t),l=Math.sin(t);return A.set(c*O.x+l*k.x,c*O.y+l*k.y,c*O.z+l*k.z),j.set(c*k.x-l*O.x,c*k.y-l*O.y,c*k.z-l*O.z),N.copy(this.cameraObject.target),N.x=N.x+e.x*n+A.x*r+j.x*i,N.y=N.y+e.y*n+A.y*r+j.y*i,N.z=N.z+e.z*n+A.z*r+j.z*i,D.set(e.x*a+A.x*o+j.x*s,e.y*a+A.y*o+j.y*s,e.z*a+A.z*o+j.z*s),{position:N,up:D}},this.rotateAboutLookAtpoint=(e,t)=>{let n=this.getVectorsFromRotateAboutLookAtPoints(e,t);this.cameraObject.position.copy(n.position),this.updateDirectionalLight(),this.cameraObject.up.copy(n.up)};let ve=()=>{if(this.cameraObject!==void 0){let e=E?.width,t=E?.height;if(0<e&&0<t){let n=.25*(e+t),r=0,i=0;(w===s.FREE||w===s.HORIZONTAL)&&(r=this.pointer_x-this.previous_pointer_x),(w===s.FREE||w===s.VERTICAL)&&(i=this.previous_pointer_y-this.pointer_y);let a=Math.sqrt(r*r+i*i);if(a>0){let o=-i*1/a,c=r*1/a;if(w===s.FREE){let r=o*(this.pointer_x-.5*(e-1))+c*(.5*(t-1)-this.pointer_y);r>n?r=n:r<-n&&(r=-n)}let l=Math.acos(0/n)-.5*Math.PI,u=this.tumble_rate*a/n;D.copy(this.cameraObject.position).sub(this.cameraObject.target).normalize(),O.copy(this.cameraObject.up).normalize(),k.copy(O).cross(D).normalize().multiplyScalar(o),O.multiplyScalar(c),M.addVectors(k,O).multiplyScalar(Math.cos(l)),D.multiplyScalar(Math.sin(l)),M.add(D),this.rotateAboutLookAtpoint(M,-u)}}}this.previous_pointer_x=this.pointer_x,this.previous_pointer_y=this.pointer_y},ye=()=>{let e=0;return this._state===o.ZOOM?e=this.previous_pointer_y-this.pointer_y:this._state===o.SCROLL||this._state===o.KEYBOARD_ZOOM?e=C:(e=-1*(this.touchZoomDistanceEnd-this.touchZoomDistanceStart),this.touchZoomDistanceStart=this.touchZoomDistanceEnd),e};this.changeZoomByScrollRateUnit=e=>{let t=e*this.zoomRate;this.changeZoomByValue(t)},this.changeZoomByValue=e=>{if(this.cameraObject!==void 0){let t=E.height,n=this.cameraObject.position.clone();n.sub(this.cameraObject.target);let r=n.length(),i=r*(1.5*e/t);r+i>.01&&(n.normalize(),I.copy(this.cameraObject.position),I.x+=n.x*i,I.y+=n.y*i,I.z+=n.z*i,ie()&&(this.cameraObject.position.copy(I),this.updateDirectionalLight(),ne(i),ee=!0))}};let be=()=>{let e=ye();this.changeZoomByValue(e),this._state===o.ZOOM&&(this.previous_pointer_x=this.pointer_x,this.previous_pointer_y=this.pointer_y),(this._state===o.SCROLL||this._state===o.KEYBOARD_ZOOM)&&(C=0,this._state=o.NONE)};this.setDirectionalLight=e=>{this.directionalLight=e},this.updateDirectionalLight=()=>{this.directionalLight!=0&&this.directionalLight.position.set(this.cameraObject.position.x,this.cameraObject.position.y,this.cameraObject.position.z)},this.enable=function(){d=!0,this.domElement&&this.domElement.addEventListener&&(re(this.domElement,0),this.domElement.addEventListener(`mousedown`,oe,!1),this.domElement.addEventListener(`mousemove`,se,!1),this.domElement.addEventListener(`mouseup`,ce,!1),this.domElement.addEventListener(`mouseleave`,le,!1),this.domElement.addEventListener(`touchstart`,ue,!1),this.domElement.addEventListener(`touchmove`,de,!1),this.domElement.addEventListener(`touchend`,fe,!1),this.domElement.addEventListener(`wheel`,me,!1),this.domElement.addEventListener(`mouseenter`,pe,!1),this.domElement.addEventListener(`contextmenu`,e=>{e.preventDefault()},!1),this.domElement.addEventListener(`keydown`,he,!1),this.domElement.addEventListener(`keyup`,ge,!1))},this.disable=function(){d=!1,this.domElement&&this.domElement.removeEventListener&&(this.domElement.removeEventListener(`mousedown`,oe,!1),this.domElement.removeEventListener(`mousemove`,se,!1),this.domElement.removeEventListener(`mouseup`,ce,!1),this.domElement.removeEventListener(`mouseleave`,le,!1),this.domElement.removeEventListener(`touchstart`,ue,!1),this.domElement.removeEventListener(`touchmove`,de,!1),this.domElement.removeEventListener(`touchend`,fe,!1),this.domElement.removeEventListener(`wheel`,me,!1),this.domElement.removeEventListener(`mouseenter`,pe,!1),this.domElement.removeEventListener(`contextmenu`,e=>{e.preventDefault()},!1),this.domElement.removeEventListener(`keydown`,he,!1),this.domElement.removeEventListener(`keyup`,ge,!1),re(this.domElement,-1))},this.loadPath=e=>{p=e.CameraPath,m=e.NumberOfPoints},this.loadPathURL=(e,t)=>{let n=e;fetch(n).then(e=>{if(!e.ok)throw Error(`HTTP error! status: ${e.status}`);return e.json()}).then(e=>{this.loadPath(e),t!==void 0&&typeof t==`function`&&t()}).catch(e=>{console.error(`Failed to load path asset from: ${n}`,e)})},this.setPathDuration=e=>{u=e,b&&b.setDuration(u),x&&x.setDuration(u)},this.getPlayRate=()=>g,this.setPlayRate=e=>{g=e};let xe=e=>{let t=f+e;t>u&&(t-=u),f=t};this.getTime=()=>f,this.setTime=e=>{f=e>u?u:e<0?0:e},this.getNumberOfTimeFrame=()=>m,this.getCurrentTimeFrame=()=>{if(m>2){let e=f/u*(m-1),t=Math.floor(e),n=1-(e-t),r=Math.ceil(e);return t==r?t==m-1?[t-1,r,0]:[t,r+1,1]:[t,r,n]}if(m==1)return[0,0,0]},this.setCurrentTimeFrame=e=>{m>2&&(f=u*e/(m-1),f<0&&(f=0),f>u&&(f=u))};let B=e=>{if(y===a.PATH&&(xe(e),p)){let e=this.getCurrentTimeFrame(),t=e[0],n=e[1],r=e[2],i=[p[t*3],p[t*3+1],p[t*3+2]],a=[p[n*3],p[n*3+1],p[n*3+2]],o=[];for(let e=0;e<i.length;e++)o.push(r*i[e]+(1-r)*a[e]);this.cameraObject.position.set(o[0],o[1],o[2]),this.cameraObject.target.set(a[0],a[1],a[2]),_&&this.cameraObject.lookAt(this.cameraObject.target),h&&(this.directionalLight.position.set(o[0],o[1],o[2]),this.directionalLight.target.position.set(a[0],a[1],a[2]))}};this.calculatePathNow=()=>{B(0)};let Se=()=>{this._state===o.ROTATE||this._state===o.TOUCH_ROTATE||this._state===o.KEYBOARD_ROTATE?ve():this._state===o.PAN||this._state===o.TOUCH_PAN||this._state===o.KEYBOARD_PAN?(_e(),L.triggerCallback()):(this._state===o.ZOOM||this._state===o.TOUCH_ZOOM||this._state===o.SCROLL||this._state===o.KEYBOARD_ZOOM)&&(L.zoom(ye()),this.previous_pointer_x=this.pointer_x,this.previous_pointer_y=this.pointer_y,(this._state===o.SCROLL||this._state===o.KEYBOARD_ZOOM)&&(this._state=o.NONE),C=0,L.triggerCallback())};this.update=e=>{let t=e*g,n=d,r=!0;return y===a.PATH?B(t):y===a.SMOOTH_CAMERA_TRANSITION&&b?(b.update(t),b.isTransitionCompleted()&&(y=a.DEFAULT),n=!1):y===a.ROTATE_CAMERA_TRANSITION&&x?(x.update(t),x.isTransitionCompleted()&&(y=a.DEFAULT),n=!1):y===a.AUTO_TUMBLE&&S?S.update(t):y===a.SYNC_CONTROL&&L?(Se(),n=!1):r=!1,n&&(this._state!==o.NONE&&(r=!0),this._state===o.ROTATE||this._state===o.TOUCH_ROTATE||this._state===o.KEYBOARD_ROTATE?ve():this._state===o.PAN||this._state===o.TOUCH_PAN||this._state===o.KEYBOARD_PAN?_e():(this._state===o.ZOOM||this._state===o.TOUCH_ZOOM||this._state===o.SCROLL||this._state===o.KEYBOARD_ZOOM)&&be(),this._state!==o.NONE&&y===a.AUTO_TUMBLE&&S&&S.stopOnCameraInput,this._state===o.SCROLL&&(this._state=o.NONE)),_?(r=!0,_.update()):this.cameraObject.lookAt(this.cameraObject.target),r||=ee,ee=!1,r},this.playPath=()=>{y=a.PATH},this.stopPath=()=>{y=a.DEFAULT},this.isPlayingPath=()=>y===a.PATH,this.enableDirectionalLightUpdateWithPath=e=>{h=e},this.enableDeviceOrientation=()=>{_||=new ft(this.cameraObject)},this.disableDeviceOrientation=()=>{_&&=(_.dispose(),void 0)},this.isDeviceOrientationEnabled=()=>!!_,this.resetView=()=>{let e=R[v];this.cameraObject.near=e.nearPlane,this.cameraObject.far=e.farPlane,this.cameraObject.position.set(e.eyePosition[0],e.eyePosition[1],e.eyePosition[2]),this.cameraObject.target.set(e.targetPosition[0],e.targetPosition[1],e.targetPosition[2]),this.cameraObject.up.set(e.upVector[0],e.upVector[1],e.upVector[2]),this.cameraObject.updateProjectionMatrix(),this.updateDirectionalLight()},this.setCurrentCameraSettings=e=>{e.nearPlane&&(this.cameraObject.near=e.nearPlane),e.farPlane&&(this.cameraObject.far=e.farPlane),e.eyePosition&&this.cameraObject.position.set(e.eyePosition[0],e.eyePosition[1],e.eyePosition[2]),e.targetPosition&&this.cameraObject.target.set(e.targetPosition[0],e.targetPosition[1],e.targetPosition[2]),e.upVector&&this.cameraObject.up.set(e.upVector[0],e.upVector[1],e.upVector[2]),this.cameraObject.updateProjectionMatrix(),this.updateDirectionalLight(),ee=!0},this.getViewportFromCentreAndRadius=(e,t,n,r,i,a)=>{D.copy(this.cameraObject.position),D.sub(this.cameraObject.target),D.normalize();let o=[e,t,n],s=r/Math.tan(i*Math.PI/360),c=[e+D.x*s,t+D.y*s,n+D.z*s],l=s+a,u=0;u=a>.95*s?.050000000000000044*s:s-a;let d=new it;return d.nearPlane=u,d.farPlane=l,d.eyePosition=c,d.targetPosition=o,d.upVector=[this.cameraObject.up.x,this.cameraObject.up.y,this.cameraObject.up.z],d},this.getViewportFromBoundingBox=(e,t)=>{let n=e.min.distanceTo(e.max)/2*t,r=(e.min.x+e.max.x)/2,i=(e.min.y+e.max.y)/2,a=(e.min.z+e.max.z)/2;return this.getViewportFromCentreAndRadius(r,i,a,n,40,n*4)},this.getCurrentViewport=()=>{let e=new it;return e.nearPlane=this.cameraObject.near,e.farPlane=this.cameraObject.far,e.eyePosition[0]=this.cameraObject.position.x,e.eyePosition[1]=this.cameraObject.position.y,e.eyePosition[2]=this.cameraObject.position.z,e.targetPosition[0]=this.cameraObject.target.x,e.targetPosition[1]=this.cameraObject.target.y,e.targetPosition[2]=this.cameraObject.target.z,e.upVector[0]=this.cameraObject.up.x,e.upVector[1]=this.cameraObject.up.y,e.upVector[2]=this.cameraObject.up.z,e},this.getDefaultEyePosition=()=>eyePosition,this.getDefaultTargetPosition=()=>targetPosition,this.cameraTransition=(e,t,n)=>{x??(b=new ot(e,t,this,n))},this.rotateCameraTransition=(e,t,n)=>{b??(x=new st(e,t,this,n))},this.enableCameraTransition=()=>{b&&(y=a.SMOOTH_CAMERA_TRANSITION),x&&(y=a.ROTATE_CAMERA_TRANSITION)},this.pauseCameraTransition=()=>{y=a.DEFAULT},this.stopCameraTransition=()=>{y=a.DEFAULT,b=void 0,x=void 0},this.isTransitioningCamera=()=>y===a.SMOOTH_CAMERA_TRANSITION||y===a.ROTATE_CAMERA_TRANSITION,this.autoTumble=(e,t,n)=>{S=new lt(e,t,n,this)},this.enableAutoTumble=()=>{y=a.AUTO_TUMBLE},this.stopAutoTumble=()=>{y=a.DEFAULT,S=void 0},this.updateAutoTumble=()=>{S&&(S.requireUpdate=!0)},this.isAutoTumble=()=>y===a.AUTO_TUMBLE,this.enableRaycaster=(e,t,n)=>{T??=new ct(e,this.scene,t,n,this.renderer)},this.disableRaycaster=()=>{T.disable(),T=void 0},this.isSyncControl=()=>currentMpde===a.SYNC_CONTROL,this.enableSyncControl=()=>(y=a.SYNC_CONTROL,L||=new pt,L.setCurrentCameraSettings(this.cameraObject,R[v]),L),this.disableSyncControl=()=>{y=a.DEFAULT,this.cameraObject.zoom=1,this.cameraObject.updateProjectionMatrix()},this.enable()},ot=function(e,t,n,r){let i=e.eyePosition,a=e.targetPosition,o=e.upVector,s=t.eyePosition,c=t.targetPosition,l=t.upVector,u=n,d=r,f=0,p=!1;u.near=Math.min(e.nearPlane,t.nearPlane),u.far=Math.max(e.farPlane,t.farPlane),u.cameraObject.up.set(t.upVector[0],t.upVector[1],t.upVector[2]),this.setDuration=e=>{d=e};let m=e=>{let t=f+e;t>d&&(t=d),f=t},h=()=>{let e=f/d,t=[i[0]*(1-e)+s[0]*e,i[1]*(1-e)+s[1]*e,i[2]*(1-e)+s[2]*e],n=[a[0]*(1-e)+c[0]*e,a[1]*(1-e)+c[1]*e,a[2]*(1-e)+c[2]*e];o[0]*(1-e)+l[0]*e,o[1]*(1-e)+l[1]*e,o[2]*(1-e)+l[2]*e,u.cameraObject.position.set(t[0],t[1],t[2]),u.cameraObject.target.set(n[0],n[1],n[2])};this.update=e=>{this.enabled!==!1&&(m(e),h(),f==d&&(p=!0))},this.isTransitionCompleted=()=>p},st=function(e,t,n,r){let i=e,a=t,o=n,s=r,c=0;c/s;let l=!1;this.setDuration=e=>{s=e};let u=e=>{let t=c,n=c+e;n>s&&(n=s),c=n;let r=(c-t)/s*a;o.rotateAboutLookAtpoint(i,r)};this.update=e=>{this.enabled!==!1&&(u(e),c==s&&(l=!0))},this.isTransitionCompleted=()=>l},ct=function(t,n,r,i,a){let o=t,s=n,c=a,l=r,u=i,d=!0,f=new e.Raycaster;f.params.Line.threshold=.1,f.params.Points.threshold=1;let p=new e.Vector2,m=!1,h=new Date,g=!1,_=0,v=[],y={zincCamera:void 0,x:-1,y:-1},b;this.enable=()=>{d=!0},this.disable=()=>{d=!1},this.getIntersectsObject=e=>{if(s!==o){let t=o.getThreeJSScene();c.render(t,e.cameraObject)}let t=b||o.getPickableThreeJSObjects();return v.length=0,f.intersectObjects(t,!0,v)},this.setPickableObjects=e=>{e===void 0?b=void 0:(b=[],e.forEach(e=>{e.getGroup()&&e.getGroup().visible&&b.push(e.getGroup())}))},this.getIntersectsObjectWithOrigin=(e,t,n)=>(f.set(t,n),this.getIntersectsObject(e)),this.getIntersectsObjectWithCamera=(e,t,n)=>(e.getNDCFromDocumentCoords(t,n,p),f.setFromCamera(p,e.cameraObject),this.getIntersectsObject(e)),this.pick=(e,t,n)=>{if(d&&c&&o&&e&&l){this.getIntersectsObjectWithCamera(e,t,n);let r=v.length;for(let e=0;e<r;e++){let t=v[e].object?v[e].object.userData:void 0;if(t&&t.isMarkerCluster&&t.visible&&t.clusterIsVisible(v[e].object.clusterIndex)&&t.zoomToCluster(v[e].object.clusterIndex))return}l(v,t,n)}};let x=(e,t,n)=>{if(d&&c&&o&&e&&u){if(this.getIntersectsObjectWithCamera(e,t,n),h.setTime(Date.now()),v.length===0){if(g)return;g=!0}else g=!1;u(v,t,n)}};this.move=(e,t,n)=>{d&&c&&o&&e&&u&&(o.displayMarkers?x(e,t,n):(y.zincCamera=e,y.x=t,y.y=n,m||(_=h?Date.now()-h.getTime():250,_>=250?x(e,t,n):(m=!0,setTimeout(S(y),_)))))};let S=e=>function(){m=!1,x(e.zincCamera,e.x,e.y)}},lt=function(t,n,r,i){let a=new e.Vector3,o=-n,s=i,c=t;this.stopOnCameraInput=r,this.requireUpdate=!0;let l=new e.Vector3,u=new e.Vector3,d=e=>{let t=Math.sqrt(e[0]*e[0]+e[1]*e[1]),n=.25*(Math.abs(e[0])*4+Math.abs(e[1])*4),r=-e[1]/t,i=e[0]/t,o=r*e[0]+i*-e[1];o>n?o=n:o<-n&&(o=-n);let c=Math.acos(o/n)-.5*Math.PI;a.copy(s.cameraObject.position).sub(s.cameraObject.target).normalize(),l.copy(s.cameraObject.up).normalize(),u.crossVectors(l,a).normalize().multiplyScalar(r),l.multiplyScalar(i),l.add(u).multiplyScalar(Math.cos(c)),a.multiplyScalar(Math.sin(c)).add(l)};this.update=e=>{this.enabled!==!1&&(this.requireUpdate&&=(d(c),!1),s.rotateAboutLookAtpoint(a,o*e/1e3))}},ut=function(){this.type=`StereoCamera`,this.aspect=1,this.cameraL=new e.PerspectiveCamera,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new e.PerspectiveCamera,this.cameraR.layers.enable(2),this.cameraR.matrixAutoUpdate=!1};Object.assign(ut.prototype,{update:(()=>{let t,n,r,i,a,o,s=new e.Matrix4,c=new e.Matrix4;return function(l){if(t!==l.focus||n!==l.fov||r!==l.aspect*this.aspect||i!==l.near||a!==l.far||o!==l.zoom){t=l.focus,n=l.fov,r=l.aspect*this.aspect,i=l.near,a=l.far,o=l.zoom;let u=l.projectionMatrix.clone(),d=.064/2,f=d*i/t,p=i*Math.tan(e.Math.DEG2RAD*n*.5)/l.zoom,m,h;c.elements[12]=-.032,s.elements[12]=d,m=-p*r+f,h=p*r+f,u.elements[0]=2*i/(h-m),u.elements[8]=(h+m)/(h-m),this.cameraL.projectionMatrix.copy(u),m=-p*r-f,h=p*r-f,u.elements[0]=2*i/(h-m),u.elements[8]=(h+m)/(h-m),this.cameraR.projectionMatrix.copy(u)}this.cameraL.matrixWorld.copy(l.matrixWorld).multiply(c),this.cameraR.matrixWorld.copy(l.matrixWorld).multiply(s)}})()});var dt=function(e){let t=new ut;t.aspect=.5,this.setSize=(t,n)=>{e.setSize(t,n)},this.render=(n,r)=>{n.updateMatrixWorld(),r.parent===null&&r.updateMatrixWorld(),t.update(r);let i=e.getSize();e.setScissorTest(!0),e.clear(),e.setScissor(0,0,i.width/2,i.height),e.setViewport(0,0,i.width/2,i.height),e.render(n,t.cameraL),e.setScissor(i.width/2,0,i.width/2,i.height),e.setViewport(i.width/2,0,i.width/2,i.height),e.render(n,t.cameraR),e.setScissorTest(!1)}},ft=function(t){let n=this;this.object=t,this.object.rotation.reorder(`YXZ`),this.enabled=!0,this.deviceOrientation={},this.screenOrientation=0;let r=e=>{n.deviceOrientation=e},i=()=>{typeof window<`u`&&(n.screenOrientation=window.orientation||0)},a=(()=>{let t=new e.Vector3(0,0,1),n=new e.Euler,r=new e.Quaternion,i=new e.Quaternion(-Math.sqrt(.5),0,0,Math.sqrt(.5));return(a,o,s,c,l)=>{let u=new e.Vector3(0,0,1);u.subVectors(a.target,a.position),n.set(s,o,-c,`YXZ`);let d=new e.Quaternion;d.setFromEuler(n),d.multiply(i),d.multiply(r.setFromAxisAngle(t,-l)),u.applyQuaternion(d),u.addVectors(a.position,u),a.lookAt(u)}})();this.connect=()=>{i(),typeof window<`u`&&(window.addEventListener(`orientationchange`,i,!1),window.addEventListener(`deviceorientation`,r,!1)),n.enabled=!0},this.disconnect=()=>{typeof window<`u`&&(window.removeEventListener(`orientationchange`,i,!1),window.removeEventListener(`deviceorientation`,r,!1)),n.enabled=!1},this.update=()=>{if(n.enabled===!1)return;let t=n.deviceOrientation.alpha?e.Math.degToRad(n.deviceOrientation.alpha):0,r=n.deviceOrientation.beta?e.Math.degToRad(n.deviceOrientation.beta):0,i=n.deviceOrientation.gamma?e.Math.degToRad(n.deviceOrientation.gamma):0,o=n.screenOrientation?e.Math.degToRad(n.screenOrientation):0;a(n.object,t,r,i,o)},this.dispose=function(){this.disconnect()},this.connect()},pt=function(){let t,n,r,i=new e.Vector3,a=new e.Vector3,o=new e.Vector3,s=new e.Vector3,c;this.setCurrentCameraSettings=(o,s)=>{this.near_plane_fly_debt,t=o.clone(),n=o,r=s,t.near=r.nearPlane,r.farPlane&&(t.far=r.farPlane),r.eyePosition&&t.position.set(r.eyePosition[0],r.eyePosition[1],r.eyePosition[2]),r.upVector&&t.up.set(r.upVector[0],r.upVector[1],r.upVector[2]),r.targetPosition&&(t.target=new e.Vector3(r.targetPosition[0],r.targetPosition[1],r.targetPosition[2]),t.lookAt(t.target)),t.updateProjectionMatrix(),i.copy(t.position).project(t),a.copy(t.target).project(t)},this.getCurrentPosition=()=>(a.copy(n.target).project(t),[a.x,a.y]),this.zoom=e=>{let t=e*.002,r=Math.max(n.zoom-t,1);n.zoom=r,n.updateProjectionMatrix()},this.zoomToBox=(e,n)=>{e.getCenter(o),o.project(t),this.setCenterZoom([o.x,o.y],n)},this.getPanZoom=()=>({target:this.getCurrentPosition(),zoom:n.zoom}),this.setCenterZoom=(e,r)=>{o.set(e[0],e[1],a.z).unproject(t),s.copy(o).sub(n.target),n.target.copy(o),n.lookAt(n.target),n.position.add(s),n.zoom=r,n.updateProjectionMatrix()},this.setEventCallback=e=>{(e===void 0||typeof e==`function`)&&(c=e)},this.triggerCallback=()=>{c!==void 0&&typeof c==`function`&&c()}},mt=`data:image/svg+xml,%3c?xml%20version='1.0'%20encoding='UTF-8'%20standalone='no'%20?%3e%3c!DOCTYPE%20svg%20PUBLIC%20'-//W3C//DTD%20SVG%201.1//EN'%20'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'%3e%3csvg%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20version='1.1'%20width='365'%20height='560'%20viewBox='0%200%20365%20560'%20xml:space='preserve'%3e%3cdesc%3eCreated%20with%20Fabric.js%205.2.4%3c/desc%3e%3cdefs%3e%3c/defs%3e%3crect%20x='0'%20y='0'%20width='100%25'%20height='100%25'%20fill='transparent'%3e%3c/rect%3e%3cg%20transform='matrix(0%200%200%200%200%200)'%20id='808ed283-2524-440f-88ae-3bdb47bb5749'%20%3e%3c/g%3e%3cg%20transform='matrix(1%200%200%201%20182.5%20280)'%20id='db30413d-5bff-4b98-ab59-464497ee199e'%20%3e%3crect%20style='stroke:%20none;%20stroke-width:%201;%20stroke-dasharray:%20none;%20stroke-linecap:%20butt;%20stroke-dashoffset:%200;%20stroke-linejoin:%20miter;%20stroke-miterlimit:%204;%20fill:%20rgb(255,255,255);%20fill-rule:%20nonzero;%20opacity:%201;%20visibility:%20hidden;'%20vector-effect='non-scaling-stroke'%20x='-182.5'%20y='-280'%20rx='0'%20ry='0'%20width='365'%20height='560'%20/%3e%3c/g%3e%3cg%20transform='matrix(0%200%200%200%200%2097.5)'%20%3e%3cg%20style=''%20%3e%3c/g%3e%3c/g%3e%3cg%20transform='matrix(0%200%200%200%200%2097.5)'%20%3e%3cg%20style=''%20%3e%3c/g%3e%3c/g%3e%3cg%20transform='matrix(0.99%200%200%200.99%20182.5%20280)'%20%3e%3cg%20style=''%20vector-effect='non-scaling-stroke'%20%3e%3cg%20transform='matrix(1%200%200%201%200%200)'%20%3e%3crect%20style='stroke:%20none;%20stroke-width:%201;%20stroke-dasharray:%20none;%20stroke-linecap:%20butt;%20stroke-dashoffset:%200;%20stroke-linejoin:%20miter;%20stroke-miterlimit:%204;%20fill:%20rgb(255,255,255);%20fill-rule:%20nonzero;%20opacity:%201;%20visibility:%20hidden;'%20vector-effect='non-scaling-stroke'%20x='-540'%20y='-540'%20rx='0'%20ry='0'%20width='1080'%20height='1080'%20/%3e%3c/g%3e%3cg%20transform='matrix(1%200%200%201%200%200)'%20%3e%3cpath%20style='stroke:%20rgb(0,0,0);%20stroke-width:%200;%20stroke-dasharray:%20none;%20stroke-linecap:%20butt;%20stroke-dashoffset:%200;%20stroke-linejoin:%20miter;%20stroke-miterlimit:%204;%20fill:%20rgb(255,165,0);%20fill-rule:%20nonzero;%20opacity:%201;'%20vector-effect='non-scaling-stroke'%20transform='%20translate(-182.9,%20-279.85)'%20d='M%20182.9%20551.7%20C%20182.9%20551.8000000000001%20183.1%20552%20183.1%20552%20C%20183.1%20552%20358.3%20283%20358.3%20194.6%20C%20358.3%2064.5%20269.5%207.900000000000006%20182.9%207.699999999999989%20C%2096.3%207.9%207.5%2064.5%207.5%20194.6%20C%207.5%20283%20182.8%20552%20182.8%20552%20C%20182.8%20552%20182.9%20551.7%20182.9%20551.7%20z%20M%20122.2%20187.2%20C%20122.2%20153.6%20149.4%20126.39999999999999%20183%20126.39999999999999%20C%20216.6%20126.39999999999999%20243.8%20153.6%20243.8%20187.2%20C%20243.8%20220.79999999999998%20216.5%20248%20182.9%20248%20C%20149.4%20248%20122.2%20220.8%20122.2%20187.2%20z'%20stroke-linecap='round'%20/%3e%3c/g%3e%3cg%20transform='matrix(3.82%200%200%203.82%200%20-100.77)'%20%3e%3ccircle%20style='stroke:%20rgb(0,0,0);%20stroke-width:%200;%20stroke-dasharray:%20none;%20stroke-linecap:%20butt;%20stroke-dashoffset:%200;%20stroke-linejoin:%20miter;%20stroke-miterlimit:%204;%20fill:%20rgb(255,255,255);%20fill-rule:%20nonzero;%20opacity:%201;'%20vector-effect='non-scaling-stroke'%20cx='0'%20cy='0'%20r='35'%20/%3e%3c/g%3e%3c/g%3e%3c/g%3e%3c/svg%3e`,ht=new Image(128,128);ht.src=mt;var gt=new e.Texture;gt.image=ht,gt.needsUpdate=!0;var _t=[.02,.03,1],vt=new e.SpriteMaterial({map:gt,alphaTest:.5,transparent:!0,depthTest:!1,depthWrite:!1,sizeAttenuation:!1}),yt=function(t){B.call(this),this.texture=gt;let n=t;this.morph=new e.Group,this.group=this.morph,this.isMarkerCluster=!0;let r=!0,i=[];this.markers={};let a=new e.Vector2,o=new e.Vector2,s=Date.now();this.setSpriteSize=e=>{(void 0).scale.set(.015,.02,1),(void 0).scale.multiplyScalar(e)},this.clear=()=>{this.group.clear(),this.markers={}},this.dispose=()=>{this.clear(),this.morph&&this.morph.clear()};let c=t=>{let n=new e.Group,r=new e.Sprite(vt);return r.clusterIndex=t,r.center.set(.5,0),r.position.set(0,0,0),r.renderOrder=1e4,r.scale.set(_t[0],_t[1],_t[2]),r.userData=this,n.add(r),this.group.add(n),{group:n,marker:r,label:void 0,number:0,min:[0,0,0],max:[1,1,1]}},l=(e,t,n)=>{e.group.visible=!0,e.group.position.set(t.coords[0],t.coords[1],t.coords[2]),(e.label===void 0||n!==e.number)&&(e.label&&(e.group.remove(e.label),e.label.material.map.dispose(),e.label.material.dispose()),e.label=F(n,.012,`black`,`Asap`,120,700),e.number=n,e.group.add(e.label)),e.min=t.min,e.max=t.max},u=e=>{let t=0;for(e.forEach(e=>{let n=e.members.length,r=0;n===1?e.members[0].setVisibility(!0):(e.members.forEach(e=>{r+=e.getNumber(),e.setVisibility(!1)}),i[t]||i.push(c(t)),l(i[t],e,r),t++)});t<i.length;t++)i[t].group.visible=!1},d=(e,t)=>{let n=!0,r={members:[],coords:[0,0,0],min:[0,0,0],max:[1,1,1]},i=0;for(let s in e)n?(a.set(e[s].ndc.x,e[s].ndc.y),this._b1.setFromPoints([e[s].morph.position]),n=!1,r.members.push(e[s]),r.coords=[e[s].morph.position.x,e[s].morph.position.y,e[s].morph.position.z],t.push(r),delete e[s]):(o.set(e[s].ndc.x,e[s].ndc.y),i=a.distanceTo(o),.1>i&&(r.members.push(e[s]),this._b1.expandByPoint(e[s].morph.position),delete e[s]));r.min=[this._b1.min.x,this._b1.min.y,this._b1.min.z],r.max=[this._b1.max.x,this._b1.max.y,this._b1.max.z],n!==!0&&d(e,t)};this.calculate=()=>{if(r&&Date.now()-s>500){let e=[];d({...this.markers},e),u(e),s=Date.now(),this.markerUpdateRequired=!1}},this.isEnabled=()=>r,this.enable=()=>{r=!0,this.morph.visible=!0},this.disable=()=>{r=!1,this.morph.visible=!1;for(let e in this.markers)this.markers[e]?.isMarker&&this.markers[e].isEnabled()&&this.markers[e].setVisibility(!0)},this.zoomToCluster=e=>e!==void 0&&e>-1&&(this._v1.set(...i[e].min),this._v2.set(...i[e].max),Math.abs(this._v1.distanceTo(this._v2)>0))?(this._b1.set(this._v1,this._v2),n.translateBoundingBoxToCameraView(this._b1,3,300),this.markerUpdateRequired=!0,!0):!1,this.clusterIsVisible=e=>e!==void 0&&e>-1&&i[e]?i[e].group?.visible:!1};yt.prototype=Object.create(B.prototype);var bt=function(t){let n=t;this.camera=new e.OrthographicCamera(-.5,.5,.5,-.5,.01,10),this.helper=void 0;let r=new e.BufferGeometry;var i=new Float32Array([-1,-1,1,1,-1,1,1,1,1,1,1,1,-1,1,1,-1,-1,1]);let a=new e.BufferAttribute(i,3);r.setAttribute(`position`,a);var o=new e.MeshBasicMaterial({color:3355443,depthTest:!1,depthWrite:!1,opacity:.5,transparent:!0});this.mask=new e.Mesh(r,o);let s=new e.Box3,c=new e.Vector3;this.getDiffFromNormalised=(t,n)=>{s.setFromBufferAttribute(a).getCenter(c);let r=c.clone().project(this.camera);return new e.Vector3(t,n,r.z).unproject(this.camera).sub(c)};let l=(t,r)=>{n.camera.near&&(this.camera.near=n.camera.near),r.farPlane&&(this.camera.far=r.farPlane),r.eyePosition&&this.camera.position.set(r.eyePosition[0],r.eyePosition[1],r.eyePosition[2]),r.upVector&&this.camera.up.set(r.upVector[0],r.upVector[1],r.upVector[2]),r.targetPosition&&this.camera.lookAt(new e.Vector3(r.targetPosition[0],r.targetPosition[1],r.targetPosition[2])),this.camera.zoom=1/t,this.camera.updateProjectionMatrix()};this.getBoundary=()=>{let t=new e.Vector3().copy(n.camera.target).project(n.camera),r=new e.Vector3(-1,-1,t.z).unproject(n.camera),i=new e.Vector3(1,-1,t.z).unproject(n.camera),o=new e.Vector3(1,1,t.z).unproject(n.camera),s=[r,i,o,o,new e.Vector3(-1,1,t.z).unproject(n.camera),r];a.copyVector3sArray(s),a.needsUpdate=!0},this.updateCamera=()=>{this.getBoundary();let e=n.getZincCameraControls(),t=n.getBoundingBox();if(t){let n=t.min.distanceTo(t.max),r=n/2,i=(t.min.x+t.max.x)/2,a=(t.min.y+t.max.y)/2,o=(t.min.z+t.max.z)/2,s=e.getViewportFromCentreAndRadius(i,a,o,r,40,r*4);l(n,s)}}},xt=new e.Box3,St=new e.Vector3,Ct=class extends e.InstancedBufferGeometry{constructor(){super(),this.type=`LineSegmentsGeometry`,this.setIndex([0,2,1,2,3,1,2,4,3,4,5,3,4,6,5,6,7,5]),this.setAttribute(`position`,new e.Float32BufferAttribute([-1,2,0,1,2,0,-1,1,0,1,1,0,-1,0,0,1,0,0,-1,-1,0,1,-1,0],3)),this.setAttribute(`uv`,new e.Float32BufferAttribute([-1,2,1,2,-1,1,1,1,-1,-1,1,-1,-1,-2,1,-2],2))}applyMatrix4(e){let t=this.attributes.instanceStart,n=this.attributes.instanceEnd;return t!==void 0&&(t.applyMatrix4(e),n.applyMatrix4(e),t.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}setPositions(t){let n;t instanceof Float32Array?n=t:Array.isArray(t)&&(n=new Float32Array(t));let r=new e.InstancedInterleavedBuffer(n,6,1);return this.setAttribute(`instanceStart`,new e.InterleavedBufferAttribute(r,3,0)),this.setAttribute(`instanceEnd`,new e.InterleavedBufferAttribute(r,3,3)),this.computeBoundingBox(),this.computeBoundingSphere(),this}setColors(t){let n;t instanceof Float32Array?n=t:Array.isArray(t)&&(n=new Float32Array(t));let r=new e.InstancedInterleavedBuffer(n,6,1);return this.setAttribute(`instanceColorStart`,new e.InterleavedBufferAttribute(r,3,0)),this.setAttribute(`instanceColorEnd`,new e.InterleavedBufferAttribute(r,3,3)),this}fromWireframeGeometry(e){return this.setPositions(e.attributes.position.array),this}fromEdgesGeometry(e){return this.setPositions(e.attributes.position.array),this}fromMesh(t){return this.fromWireframeGeometry(new e.WireframeGeometry(t.geometry)),this}fromLineSegments(e){let t=e.geometry;if(t.isGeometry){console.error(`THREE.LineSegmentsGeometry no longer supports Geometry. Use THREE.BufferGeometry instead.`);return}return t.isBufferGeometry&&this.setPositions(t.attributes.position.array),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new e.Box3);let t=this.attributes.instanceStart,n=this.attributes.instanceEnd;t!==void 0&&n!==void 0&&(this.boundingBox.setFromBufferAttribute(t),xt.setFromBufferAttribute(n),this.boundingBox.union(xt))}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new e.Sphere),this.boundingBox===null&&this.computeBoundingBox();let t=this.attributes.instanceStart,n=this.attributes.instanceEnd;if(t!==void 0&&n!==void 0){let e=this.boundingSphere.center;this.boundingBox.getCenter(e);let r=0;for(let i=0,a=t.count;i<a;i++)St.fromBufferAttribute(t,i),r=Math.max(r,e.distanceToSquared(St)),St.fromBufferAttribute(n,i),r=Math.max(r,e.distanceToSquared(St));this.boundingSphere.radius=Math.sqrt(r),isNaN(this.boundingSphere.radius)&&console.error(`THREE.LineSegmentsGeometry.computeBoundingSphere(): Computed radius is NaN. The instanced position data is likely to have NaN values.`,this)}}toJSON(){}applyMatrix(e){return console.warn(`THREE.LineSegmentsGeometry: applyMatrix() has been renamed to applyMatrix4().`),this.applyMatrix4(e)}};Ct.prototype.isLineSegmentsGeometry=!0,e.UniformsLib.line={linewidth:{value:1},resolution:{value:new e.Vector2(1,1)},dashScale:{value:1},dashSize:{value:1},dashOffset:{value:0},gapSize:{value:1},opacity:{value:1}},e.ShaderLib.line={uniforms:e.UniformsUtils.merge([e.UniformsLib.common,e.UniformsLib.fog,e.UniformsLib.line]),vertexShader:`
69
69
  #include <common>
70
70
  #include <color_pars_vertex>
71
71
  #include <fog_pars_vertex>
@@ -284,62 +284,62 @@ void main() {
284
284
  #include <fog_fragment>
285
285
  #include <premultiplied_alpha_fragment>
286
286
 
287
- }`};class Ot extends b.ShaderMaterial{constructor(e){super({type:"LineMaterial",uniforms:b.UniformsUtils.clone(b.ShaderLib.line.uniforms),vertexShader:b.ShaderLib.line.vertexShader,fragmentShader:b.ShaderLib.line.fragmentShader,clipping:!0}),Object.defineProperties(this,{color:{enumerable:!0,get:function(){return this.uniforms.diffuse.value},set:function(t){this.uniforms.diffuse.value=t}},linewidth:{enumerable:!0,get:function(){return this.uniforms.linewidth.value},set:function(t){this.uniforms.linewidth.value=t}},dashed:{enumerable:!0,get:function(){return"USE_DASH"in this.defines},set(t){!!t!="USE_DASH"in this.defines&&(this.needsUpdate=!0),t===!0?this.defines.USE_DASH="":delete this.defines.USE_DASH}},dashScale:{enumerable:!0,get:function(){return this.uniforms.dashScale.value},set:function(t){this.uniforms.dashScale.value=t}},dashSize:{enumerable:!0,get:function(){return this.uniforms.dashSize.value},set:function(t){this.uniforms.dashSize.value=t}},dashOffset:{enumerable:!0,get:function(){return this.uniforms.dashOffset.value},set:function(t){this.uniforms.dashOffset.value=t}},gapSize:{enumerable:!0,get:function(){return this.uniforms.gapSize.value},set:function(t){this.uniforms.gapSize.value=t}},opacity:{enumerable:!0,get:function(){return this.uniforms.opacity.value},set:function(t){this.uniforms.opacity.value=t}},resolution:{enumerable:!0,get:function(){return this.uniforms.resolution.value},set:function(t){this.uniforms.resolution.value.copy(t)}},alphaToCoverage:{enumerable:!0,get:function(){return"ALPHA_TO_COVERAGE"in this.defines},set:function(t){!!t!="ALPHA_TO_COVERAGE"in this.defines&&(this.needsUpdate=!0),t===!0?(this.defines.ALPHA_TO_COVERAGE="",this.extensions.derivatives=!0):(delete this.defines.ALPHA_TO_COVERAGE,this.extensions.derivatives=!1)}}}),this.setValues(e)}}Ot.prototype.isLineMaterial=!0;const mi=new b.Vector3,gi=new b.Vector3,ye=new b.Vector4,xe=new b.Vector4,Be=new b.Vector4,Lt=new b.Vector3,Bt=new b.Matrix4,Me=new b.Line3,yi=new b.Vector3,Ie=new b.Box3,ut=new b.Sphere,Ue=new b.Vector4;class xi extends b.Mesh{constructor(e=new Tt,t=new Ot({color:Math.random()*16777215})){super(e,t),this.type="LineSegments2"}computeLineDistances(){const e=this.geometry,t=e.attributes.instanceStart,s=e.attributes.instanceEnd,i=new Float32Array(2*t.count);for(let o=0,a=0,h=t.count;o<h;o++,a+=2)mi.fromBufferAttribute(t,o),gi.fromBufferAttribute(s,o),i[a]=a===0?0:i[a-1],i[a+1]=i[a]+mi.distanceTo(gi);const n=new b.InstancedInterleavedBuffer(i,2,1);return e.setAttribute("instanceDistanceStart",new b.InterleavedBufferAttribute(n,1,0)),e.setAttribute("instanceDistanceEnd",new b.InterleavedBufferAttribute(n,1,1)),this}raycast(e,t){e.camera===null&&console.error('LineSegments2: "Raycaster.camera" needs to be set in order to raycast against LineSegments2.');const s=e.params.Line2!==void 0&&e.params.Line2.threshold||0,i=e.ray,n=e.camera,o=n.projectionMatrix,a=this.matrixWorld,h=this.geometry,f=this.material,c=f.resolution,l=f.linewidth+s,d=h.attributes.instanceStart,u=h.attributes.instanceEnd,p=-n.near,y=2*Math.max(l/c.width,l/c.height);h.boundingSphere===null&&h.computeBoundingSphere(),ut.copy(h.boundingSphere).applyMatrix4(a);const x=Math.max(n.near,ut.distanceToPoint(i.origin));Ue.set(0,0,-x,1).applyMatrix4(n.projectionMatrix),Ue.multiplyScalar(1/Ue.w),Ue.applyMatrix4(n.projectionMatrixInverse);const g=Math.abs(y/Ue.w)*.5;if(ut.radius+=g,e.ray.intersectsSphere(ut)===!1)return;h.boundingBox===null&&h.computeBoundingBox(),Ie.copy(h.boundingBox).applyMatrix4(a);const v=Math.max(n.near,Ie.distanceToPoint(i.origin));Ue.set(0,0,-v,1).applyMatrix4(n.projectionMatrix),Ue.multiplyScalar(1/Ue.w),Ue.applyMatrix4(n.projectionMatrixInverse);const _=Math.abs(y/Ue.w)*.5;if(Ie.max.x+=_,Ie.max.y+=_,Ie.max.z+=_,Ie.min.x-=_,Ie.min.y-=_,Ie.min.z-=_,e.ray.intersectsBox(Ie)!==!1){i.at(1,Be),Be.w=1,Be.applyMatrix4(n.matrixWorldInverse),Be.applyMatrix4(o),Be.multiplyScalar(1/Be.w),Be.x*=c.x/2,Be.y*=c.y/2,Be.z=0,Lt.copy(Be),Bt.multiplyMatrices(n.matrixWorldInverse,a);for(let k=0,V=d.count;k<V;k++){ye.fromBufferAttribute(d,k),xe.fromBufferAttribute(u,k),ye.w=1,xe.w=1,ye.applyMatrix4(Bt),xe.applyMatrix4(Bt);var I=ye.z>p&&xe.z>p;if(I)continue;if(ye.z>p){const T=ye.z-xe.z,U=(ye.z-p)/T;ye.lerp(xe,U)}else if(xe.z>p){const T=xe.z-ye.z,U=(xe.z-p)/T;xe.lerp(ye,U)}ye.applyMatrix4(o),xe.applyMatrix4(o),ye.multiplyScalar(1/ye.w),xe.multiplyScalar(1/xe.w),ye.x*=c.x/2,ye.y*=c.y/2,xe.x*=c.x/2,xe.y*=c.y/2,Me.start.copy(ye),Me.start.z=0,Me.end.copy(xe),Me.end.z=0;const R=Me.closestPointToPointParameter(Lt,!0);Me.at(R,yi);const W=b.MathUtils.lerp(ye.z,xe.z,R),G=W>=-1&&W<=1,L=Lt.distanceTo(yi)<l*.5;if(G&&L){Me.start.fromBufferAttribute(d,k),Me.end.fromBufferAttribute(u,k),Me.start.applyMatrix4(a),Me.end.applyMatrix4(a);const T=new b.Vector3,U=new b.Vector3;i.distanceSqToSegment(Me.start,Me.end,U,T),t.push({point:U,pointOnLine:T,distance:i.origin.distanceTo(U),object:this,face:null,faceIndex:k,uv:null,uv2:null})}}}}}xi.prototype.LineSegments2=!0;const ft=function(){ze.call(this),this.isLines2=!0;let r=new Array(300);this.createLineSegment=(e,t,s)=>{if(e&&t){const i=new Tt;i.setPositions(e),i.colorsNeedUpdate=!0;const n=new xi(i,t);n.scale.set(1,1,1),n.computeLineDistances(),this.setMesh(n,s.localTimeEnabled,s.localMorphColour)}},this.setWidth=e=>{this.morph&&this.morph.material&&(this.morph.material.linewidth=e,this.morph.material.needsUpdate=!0)},this.addVertices=function(e){if(e&&e.length){let t=this.getMorph();t||(this.drawRange=0);let s=this.drawRange*3;if(e.forEach(i=>{r[s++]=i[0],r[s++]=i[1],r[s++]=i[2],this.drawRange++}),!t)for(;s<300;)r[s++]=e[0][0],r[s++]=e[0][1],r[s++]=e[0][2];t&&(t.geometry.setPositions(r),t.computeLineDistances(),t.geometry.computeBoundingBox(),t.geometry.computeBoundingSphere(),this.boundingBoxUpdateRequired=!0)}return r},this.getVerticesByFaceIndex=function(e){let t=e*2*3;const s=this.getMorph();if(s&&this.drawRange*3>t){const i=s.geometry.getAttribute("instanceStart");return[[i.data.array[t],i.data.array[++t],i.data.array[++t]],[i.data.array[++t],i.data.array[++t],i.data.array[++t]]]}return[]},this.editVertices=function(e,t){if(e&&e.length){let s=this.getMorph();const i=t+e.length-1;if(!s||0>t||i>=this.drawRange)return;{let n=t*3;for(e.forEach(o=>{r[n++]=o[0],r[n++]=o[1],r[n++]=o[2]}),n=this.drawRange*3;n<300;)r[n++]=e[0][0],r[n++]=e[0][1],r[n++]=e[0][2];s.geometry.setPositions(r),s.computeLineDistances(),s.geometry.computeBoundingBox(),s.geometry.computeBoundingSphere(),this.boundingBoxUpdateRequired=!0}}return r},this.addLines=(e,t)=>{if(e&&e.length>0){if(this.addVertices(e),!this.getMorph()){const i=new Ot({color:t,linewidth:1,vertexColors:!1,worldUnits:!1});i.resolution.set(window.innerWidth,window.innerHeight);const n={localTimeEnabled:!1,localMorphColour:!1};this.createLineSegment(r,i,n)}this.region&&(this.region.pickableUpdateRequired=!0)}},this.render=(e,t,s,i)=>{this.getMorph().material.resolution.set(window.innerWidth,window.innerHeight)}};ft.prototype=Object.create(ze.prototype),ft.prototype.constructor=ft;let Ss=0;const Cs=function(){return"re"+Ss++};let bi=function(r,e){let t=r,s=new M.Group;s.matrixAutoUpdate=!1,s.userData=this;let i=[],n="",o=[],a=e;const h=new M.Matrix4;let f=3e3;h.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this.pickableUpdateRequired=!0,this.isRegion=!0,this.uuid=Cs(),this.hideAllPrimitives=()=>{i.forEach(c=>c.hideAllPrimitives()),o.forEach(c=>c.setVisibility(!1))},this.showAllPrimitives=()=>{i.forEach(c=>c.showAllPrimitives()),o.forEach(c=>c.setVisibility(!0))},this.setVisibility=c=>{c!=s.visible&&(s.visible=c,this.pickableUpdateRequired=!0)},this.getVisibility=()=>s.visible,this.getGroup=()=>s,this.setTransformation=c=>{h.set(...c),s.matrix.copy(h),s.updateMatrixWorld()},this.setName=c=>{c&&c!==""&&(n=c)},this.getName=()=>n,this.getParent=()=>t,this.getFullSeparatedPath=()=>{const c=[];if(n!==""){c.push(n);for(let l=t;l!==void 0;){const d=l.getName();d!==""&&c.unshift(d),l=l.getParent()}}return c},this.getFullPath=()=>{const c=this.getFullSeparatedPath();if(c.length>0){let l=c.shift();return c.forEach(d=>{l=l.concat("/",d)}),l}return""},this.createChild=c=>{let l=new bi(this,a);return l.setName(c),i.push(l),s.add(l.getGroup()),l},this.getChildWithName=c=>{if(c){const l=c.toLowerCase();for(let d=0;d<i.length;d++)if(i[d].getName().toLowerCase()===l)return i[d]}},this.findChildFromSeparatedPath=c=>{if(c&&c.length>0&&c[0]===""&&c.shift(),c&&c.length>0){const l=this.getChildWithName(c[0]);return l?(c.shift(),l.findChildFromSeparatedPath(c)):void 0}return this},this.findChildFromPath=c=>{const l=c.split("/");return this.findChildFromSeparatedPath(l)},this.createChildFromSeparatedPath=c=>{if(c.length>0&&c[0]===""&&c.shift(),c.length>0){let l=this.getChildWithName(c[0]);return l||(l=this.createChild(c[0])),c.shift(),l.createChildFromSeparatedPath(c)}return this},this.createChildFromPath=c=>{const l=c.split("/");return this.createChildFromSeparatedPath(l)},this.findOrCreateChildFromPath=c=>{let l=this.findChildFromPath(c);return l||(l=this.createChildFromPath(c)),l},this.addZincObject=c=>{c&&(c.setRegion(this),s.add(c.getGroup()),o.push(c),this.pickableUpdateRequired=!0,a&&a.triggerObjectAddedCallback(c))},this.removeZincObject=c=>{for(let l=0;l<o.length;l++)if(c===o[l]){s.remove(c.getGroup()),o.splice(l,1),a&&a.triggerObjectRemovedCallback(c),c.dispose(),this.pickableUpdateRequired=!0;return}},this.checkPickableUpdateRequred=c=>{if(this.pickableUpdateRequired)return!0;if(c){let l=!1;for(let d=0;d<i.length;d++)if(l=i[d].checkPickableUpdateRequred(c),l)return!0}return!1},this.getPickableThreeJSObjects=(c,l)=>(s.visible&&(o.forEach(d=>{if(d.isPickable&&d.getGroup()&&d.getGroup().visible){let u=d.marker;u&&u.isEnabled()&&c.push(u.getMorph()),c.push(d.getGroup())}}),l&&i.forEach(d=>{d.getPickableThreeJSObjects(c,l)}),this.pickableUpdateRequired=!1),c),this.setDuration=c=>{f=c,o.forEach(l=>l.setDuration(c)),i.forEach(l=>l.setDuration(c))},this.getDuration=()=>f,this.getBoundingBox=c=>{let l,d;return o.forEach(u=>{d=u.getBoundingBox(),d&&(l==null?l=d.clone():l.union(d))}),c&&i.forEach(u=>{d=u.getBoundingBox(c),d&&(l==null?l=d.clone():l.union(d))}),l},this.clear=c=>{c&&i.forEach(l=>l.clear(c)),o.forEach(l=>{s.remove(l.getGroup()),l.dispose()}),i=[],o=[]},this.objectIsInRegion=(c,l)=>{for(let d=0;d<o.length;d++)if(c===o[d])return!0;if(l){for(let d=0;d<i.length;d++)if(i[d].objectIsInRegion(c,l))return!0}return!1},this.forEachGeometry=(c,l)=>{o.forEach(d=>{d.isGeometry&&c(d)}),l&&i.forEach(d=>d.forEachGeometry(c,l))},this.forEachGlyphset=(c,l)=>{o.forEach(d=>{d.isGlyphset&&c(d)}),l&&i.forEach(d=>d.forEachGlyphset(c,l))},this.forEachPointset=(c,l)=>{o.forEach(d=>{d.isPointset&&c(d)}),l&&i.forEach(d=>d.forEachPointset(c,l))},this.forEachLine=(c,l)=>{o.forEach(d=>{d.isLines&&c(d)}),l&&i.forEach(d=>d.forEachLine(c,l))},this.findObjectsWithAnatomicalId=(c,l)=>{const d=[];return o.forEach(u=>{u.anatomicalId===c&&d.push(u)}),l&&i.forEach(u=>{let p=u.findObjectsWithAnatomicalId(c,l);d.push(...p)}),d},this.findObjectsWithGroupName=(c,l)=>{const d=[];return o.forEach(u=>{const p=u.groupName?u.groupName.toLowerCase():u.groupName,y=c&&c.toLowerCase();p===y&&d.push(u)}),l&&i.forEach(u=>{let p=u.findObjectsWithGroupName(c,l);d.push(...p)}),d},this.findGeometriesWithGroupName=(c,l)=>this.findObjectsWithGroupName(c,l).filter(p=>p.isGeometry),this.findPointsetsWithGroupName=(c,l)=>this.findObjectsWithGroupName(c,l).filter(p=>p.isPointset),this.findGlyphsetsWithGroupName=(c,l)=>this.findObjectsWithGroupName(c,l).filter(p=>p.isGlyphset),this.findLinesWithGroupName=(c,l)=>this.findObjectsWithGroupName(c,l).filter(p=>p.isLines),this.getAllObjects=c=>{const l=[...o];return c&&i.forEach(d=>{let u=d.getAllObjects(c);l.push(...u)}),l},this.getChildRegions=c=>{const l=[...i];return c&&i.forEach(d=>{const u=d.getChildRegions(c);l.push(...u)}),l},this.getCurrentTime=()=>{if(o[0]!=null)return o[0].getCurrentTime();for(let c=0;c<i.length;c++){const l=i[c].getCurrentTime();if(l!==-1)return l}return-1},this.setMorphTime=(c,l)=>{o.forEach(d=>{d.setMorphTime(c)}),l&&i.forEach(d=>{d.setMorphTime(c)})},this.isTimeVarying=()=>{for(let c=0;c<o.length;c++)if(o[c].isTimeVarying())return!0;for(let c=0;c<i.length;c++)if(i[c].isTimeVarying())return!0;return!1},this.renderGeometries=(c,l,d,u,p,y)=>{var g;this.getAllObjects(y).forEach(v=>{v.render(c*l,d,u,p)}),p&&d===!1&&((g=p.markerCluster)!=null&&g.markerUpdateRequired)&&p.markerCluster.calculate()},this.createPoints=(c,l,d,u)=>{let p=!1;const y=this.findObjectsWithGroupName(c,!1),x=y.findIndex(v=>v.isPointset),g=x>-1?y[x]:new Ee;return g.addPoints(l,d,u),x===-1?(g.setName(c),this.addZincObject(g),p=!0):this.pickableUpdateRequired=!0,{zincObject:g,isNew:p}},this.createLines=(c,l,d)=>{let u=!1;const p=this.findObjectsWithGroupName(c,!1),y=p.findIndex(g=>g.isLines),x=y>-1?p[y]:new ft;return x.addLines(l,d),y===-1?(x.setName(c),this.addZincObject(x),u=!0):this.pickableUpdateRequired=!0,{zincObject:x,isNew:u}},this.createGeometryFromThreeJSGeometry=(c,l,d,u,p,y)=>{const x=new Xe,g=new M.MeshPhongMaterial({color:d,morphTargets:!1,morphNormals:!1,transparent:!0,opacity:u,side:M.DoubleSide});if(x.createMesh(l,g,{localTimeEnabled:!1,localMorphColour:!1}),x.getMorph())return x.setVisibility(!1),x.setName(c),x.setRenderOrder(y),this.addZincObject(x),x}};class Ut{constructor(){this.pluginCallbacks=[],this.register(function(e){return new Es(e)}),this.register(function(e){return new Ds(e)}),this.register(function(e){return new ks(e)})}register(e){return this.pluginCallbacks.indexOf(e)===-1&&this.pluginCallbacks.push(e),this}unregister(e){return this.pluginCallbacks.indexOf(e)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,s){const i=new Ps,n=[];for(let o=0,a=this.pluginCallbacks.length;o<a;o++)n.push(this.pluginCallbacks[o](i));i.setPlugins(n),i.write(e,t,s)}}const ae={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,UNSIGNED_BYTE:5121,UNSIGNED_SHORT:5123,FLOAT:5126,UNSIGNED_INT:5125,ARRAY_BUFFER:34962,ELEMENT_ARRAY_BUFFER:34963,NEAREST:9728,LINEAR:9729,NEAREST_MIPMAP_NEAREST:9984,LINEAR_MIPMAP_NEAREST:9985,NEAREST_MIPMAP_LINEAR:9986,LINEAR_MIPMAP_LINEAR:9987,CLAMP_TO_EDGE:33071,MIRRORED_REPEAT:33648,REPEAT:10497},_e={};_e[b.NearestFilter]=ae.NEAREST,_e[b.NearestMipmapNearestFilter]=ae.NEAREST_MIPMAP_NEAREST,_e[b.NearestMipmapLinearFilter]=ae.NEAREST_MIPMAP_LINEAR,_e[b.LinearFilter]=ae.LINEAR,_e[b.LinearMipmapNearestFilter]=ae.LINEAR_MIPMAP_NEAREST,_e[b.LinearMipmapLinearFilter]=ae.LINEAR_MIPMAP_LINEAR,_e[b.ClampToEdgeWrapping]=ae.CLAMP_TO_EDGE,_e[b.RepeatWrapping]=ae.REPEAT,_e[b.MirroredRepeatWrapping]=ae.MIRRORED_REPEAT;const Ai={scale:"scale",position:"translation",quaternion:"rotation",morphTargetInfluences:"weights"},wi=12,Ts=1179937895,Os=2,vi=8,Ls=1313821514,Bs=5130562;function Qe(r,e){return r.length===e.length&&r.every(function(t,s){return t===e[s]})}function Us(r){if(window.TextEncoder!==void 0)return new TextEncoder().encode(r).buffer;const e=new Uint8Array(new ArrayBuffer(r.length));for(let t=0,s=r.length;t<s;t++){const i=r.charCodeAt(t);e[t]=i>255?32:i}return e.buffer}function Ns(r){return Qe(r.elements,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}function Is(r,e,t){const s={min:new Array(r.itemSize).fill(Number.POSITIVE_INFINITY),max:new Array(r.itemSize).fill(Number.NEGATIVE_INFINITY)};for(let i=e;i<e+t;i++)for(let n=0;n<r.itemSize;n++){let o;r.itemSize>4?o=r.array[i*r.itemSize+n]:n===0?o=r.getX(i):n===1?o=r.getY(i):n===2?o=r.getZ(i):n===3&&(o=r.getW(i)),s.min[n]=Math.min(s.min[n],o),s.max[n]=Math.max(s.max[n],o)}return s}function _i(r){return Math.ceil(r/4)*4}function Nt(r,e=0){const t=_i(r.byteLength);if(t!==r.byteLength){const s=new Uint8Array(t);if(s.set(new Uint8Array(r)),e!==0)for(let i=r.byteLength;i<t;i++)s[i]=e;return s.buffer}return r}let Mi=null;class Ps{constructor(){this.plugins=[],this.options={},this.pending=[],this.buffers=[],this.byteOffset=0,this.buffers=[],this.nodeMap=new Map,this.skins=[],this.extensionsUsed={},this.uids=new Map,this.uid=0,this.json={asset:{version:"2.0",generator:"THREE.GLTFExporter"}},this.cache={meshes:new Map,attributes:new Map,attributesNormalized:new Map,materials:new Map,textures:new Map,images:new Map}}setPlugins(e){this.plugins=e}write(e,t,s){this.options=Object.assign({},{binary:!1,trs:!1,onlyVisible:!0,truncateDrawRange:!0,embedImages:!0,maxTextureSize:1/0,animations:[],includeCustomExtensions:!1},s),this.options.animations.length>0&&(this.options.trs=!0),this.processInput(e);const i=this;Promise.all(this.pending).then(function(){const n=i.buffers,o=i.json,a=i.options,h=i.extensionsUsed,f=new Blob(n,{type:"application/octet-stream"}),c=Object.keys(h);if(c.length>0&&(o.extensionsUsed=c),o.buffers&&o.buffers.length>0&&(o.buffers[0].byteLength=f.size),a.binary===!0){const l=new window.FileReader;l.readAsArrayBuffer(f),l.onloadend=function(){const d=Nt(l.result),u=new DataView(new ArrayBuffer(vi));u.setUint32(0,d.byteLength,!0),u.setUint32(4,Bs,!0);const p=Nt(Us(JSON.stringify(o)),32),y=new DataView(new ArrayBuffer(vi));y.setUint32(0,p.byteLength,!0),y.setUint32(4,Ls,!0);const x=new ArrayBuffer(wi),g=new DataView(x);g.setUint32(0,Ts,!0),g.setUint32(4,Os,!0);const v=wi+y.byteLength+p.byteLength+u.byteLength+d.byteLength;g.setUint32(8,v,!0);const _=new Blob([x,y,p,u,d],{type:"application/octet-stream"}),I=new window.FileReader;I.readAsArrayBuffer(_),I.onloadend=function(){t(I.result)}}}else if(o.buffers&&o.buffers.length>0){const l=new window.FileReader;l.readAsDataURL(f),l.onloadend=function(){const d=l.result;o.buffers[0].uri=d,t(o)}}else t(o)})}serializeUserData(e,t){if(e.userData&&e.userData.isZincObject||Object.keys(e.userData).length===0)return;const s=this.options,i=this.extensionsUsed;try{const n=JSON.parse(JSON.stringify(e.userData));if(s.includeCustomExtensions&&n.gltfExtensions){t.extensions===void 0&&(t.extensions={});for(const o in n.gltfExtensions)t.extensions[o]=n.gltfExtensions[o],i[o]=!0;delete n.gltfExtensions}Object.keys(n).length>0&&(t.extras=n)}catch(n){console.warn("THREE.GLTFExporter: userData of '"+e.name+"' won't be serialized because of JSON.stringify error - "+n.message)}}getUID(e){return this.uids.has(e)||this.uids.set(e,this.uid++),this.uids.get(e)}isNormalizedNormalAttribute(e){if(this.cache.attributesNormalized.has(e))return!1;const s=new b.Vector3;for(let i=0,n=e.count;i<n;i++)if(Math.abs(s.fromBufferAttribute(e,i).length()-1)>5e-4)return!1;return!0}createNormalizedNormalAttribute(e){const t=this.cache;if(t.attributesNormalized.has(e))return t.attributesNormalized.get(e);const s=e.clone(),i=new b.Vector3;for(let n=0,o=s.count;n<o;n++)i.fromBufferAttribute(s,n),i.x===0&&i.y===0&&i.z===0?i.setX(1):i.normalize(),s.setXYZ(n,i.x,i.y,i.z);return t.attributesNormalized.set(e,s),s}applyTextureTransform(e,t){let s=!1;const i={};(t.offset.x!==0||t.offset.y!==0)&&(i.offset=t.offset.toArray(),s=!0),t.rotation!==0&&(i.rotation=t.rotation,s=!0),(t.repeat.x!==1||t.repeat.y!==1)&&(i.scale=t.repeat.toArray(),s=!0),s&&(e.extensions=e.extensions||{},e.extensions.KHR_texture_transform=i,this.extensionsUsed.KHR_texture_transform=!0)}processBuffer(e){const t=this.json,s=this.buffers;return t.buffers||(t.buffers=[{byteLength:0}]),s.push(e),0}processBufferView(e,t,s,i,n){const o=this.json;o.bufferViews||(o.bufferViews=[]);let a;t===ae.UNSIGNED_BYTE?a=1:t===ae.UNSIGNED_SHORT?a=2:a=4;const h=_i(i*e.itemSize*a),f=new DataView(new ArrayBuffer(h));let c=0;for(let u=s;u<s+i;u++)for(let p=0;p<e.itemSize;p++){let y;e.itemSize>4?y=e.array[u*e.itemSize+p]:p===0?y=e.getX(u):p===1?y=e.getY(u):p===2?y=e.getZ(u):p===3&&(y=e.getW(u)),t===ae.FLOAT?f.setFloat32(c,y,!0):t===ae.UNSIGNED_INT?f.setUint32(c,y,!0):t===ae.UNSIGNED_SHORT?f.setUint16(c,y,!0):t===ae.UNSIGNED_BYTE&&f.setUint8(c,y),c+=a}const l={buffer:this.processBuffer(f.buffer),byteOffset:this.byteOffset,byteLength:h};return n!==void 0&&(l.target=n),n===ae.ARRAY_BUFFER&&(l.byteStride=e.itemSize*a),this.byteOffset+=h,o.bufferViews.push(l),{id:o.bufferViews.length-1,byteLength:0}}processBufferViewImage(e){const t=this,s=t.json;return s.bufferViews||(s.bufferViews=[]),new Promise(function(i){const n=new window.FileReader;n.readAsArrayBuffer(e),n.onloadend=function(){const o=Nt(n.result),a={buffer:t.processBuffer(o),byteOffset:t.byteOffset,byteLength:o.byteLength};t.byteOffset+=o.byteLength,i(s.bufferViews.push(a)-1)}})}processAccessor(e,t,s,i){const n=this.options,o=this.json,a={1:"SCALAR",2:"VEC2",3:"VEC3",4:"VEC4",16:"MAT4"};let h;if(e.array.constructor===Float32Array)h=ae.FLOAT;else if(e.array.constructor===Uint32Array)h=ae.UNSIGNED_INT;else if(e.array.constructor===Uint16Array)h=ae.UNSIGNED_SHORT;else if(e.array.constructor===Uint8Array)h=ae.UNSIGNED_BYTE;else throw new Error("THREE.GLTFExporter: Unsupported bufferAttribute component type.");if(s===void 0&&(s=0),i===void 0&&(i=e.count),n.truncateDrawRange&&t!==void 0&&t.index===null){const u=s+i,p=t.drawRange.count===1/0?e.count:t.drawRange.start+t.drawRange.count;s=Math.max(s,t.drawRange.start),i=Math.min(u,p)-s,i<0&&(i=0)}if(i===0)return null;const f=Is(e,s,i);let c;t!==void 0&&(c=e===t.index?ae.ELEMENT_ARRAY_BUFFER:ae.ARRAY_BUFFER);const l=this.processBufferView(e,h,s,i,c),d={bufferView:l.id,byteOffset:l.byteOffset,componentType:h,count:i,max:f.max,min:f.min,type:a[e.itemSize]};return e.normalized===!0&&(d.normalized=!0),o.accessors||(o.accessors=[]),o.accessors.push(d)-1}processImage(e,t,s){const i=this,n=i.cache,o=i.json,a=i.options,h=i.pending;n.images.has(e)||n.images.set(e,{});const f=n.images.get(e),c=t===b.RGBAFormat?"image/png":"image/jpeg",l=c+":flipY/"+s.toString();if(f[l]!==void 0)return f[l];o.images||(o.images=[]);const d={mimeType:c};if(a.embedImages){const p=Mi=Mi||document.createElement("canvas");p.width=Math.min(e.width,a.maxTextureSize),p.height=Math.min(e.height,a.maxTextureSize);const y=p.getContext("2d");if(s===!0&&(y.translate(0,p.height),y.scale(1,-1)),typeof HTMLImageElement<"u"&&e instanceof HTMLImageElement||typeof HTMLCanvasElement<"u"&&e instanceof HTMLCanvasElement||typeof OffscreenCanvas<"u"&&e instanceof OffscreenCanvas||typeof ImageBitmap<"u"&&e instanceof ImageBitmap)y.drawImage(e,0,0,p.width,p.height);else{t!==b.RGBAFormat&&t!==b.RGBFormat&&console.error("GLTFExporter: Only RGB and RGBA formats are supported."),(e.width>a.maxTextureSize||e.height>a.maxTextureSize)&&console.warn("GLTFExporter: Image size is bigger than maxTextureSize",e);const x=new Uint8ClampedArray(e.height*e.width*4);if(t===b.RGBAFormat)for(let g=0;g<x.length;g+=4)x[g+0]=e.data[g+0],x[g+1]=e.data[g+1],x[g+2]=e.data[g+2],x[g+3]=e.data[g+3];else for(let g=0,v=0;g<x.length;g+=4,v+=3)x[g+0]=e.data[v+0],x[g+1]=e.data[v+1],x[g+2]=e.data[v+2],x[g+3]=255;y.putImageData(new ImageData(x,e.width,e.height),0,0)}a.binary===!0?h.push(new Promise(function(x){p.toBlob(function(g){i.processBufferViewImage(g).then(function(v){d.bufferView=v,x()})},c)})):d.uri=p.toDataURL(c)}else d.uri=e.src;const u=o.images.push(d)-1;return f[l]=u,u}processSampler(e){const t=this.json;t.samplers||(t.samplers=[]);const s={magFilter:_e[e.magFilter],minFilter:_e[e.minFilter],wrapS:_e[e.wrapS],wrapT:_e[e.wrapT]};return t.samplers.push(s)-1}processTexture(e){const t=this.cache,s=this.json;if(t.textures.has(e))return t.textures.get(e);s.textures||(s.textures=[]);const i={sampler:this.processSampler(e),source:this.processImage(e.image,e.format,e.flipY)};e.name&&(i.name=e.name),this._invokeAll(function(o){o.writeTexture&&o.writeTexture(e,i)});const n=s.textures.push(i)-1;return t.textures.set(e,n),n}processMaterial(e){const t=this.cache,s=this.json;if(t.materials.has(e))return t.materials.get(e);if(e.isShaderMaterial)return console.warn("GLTFExporter: THREE.ShaderMaterial not supported."),null;s.materials||(s.materials=[]);const i={pbrMetallicRoughness:{}};e.isMeshStandardMaterial!==!0&&e.isMeshBasicMaterial!==!0&&console.warn("GLTFExporter: Use MeshStandardMaterial or MeshBasicMaterial for best results.");const n=e.color.toArray().concat([e.opacity]);if(Qe(n,[1,1,1,1])||(i.pbrMetallicRoughness.baseColorFactor=n),e.isMeshStandardMaterial?(i.pbrMetallicRoughness.metallicFactor=e.metalness,i.pbrMetallicRoughness.roughnessFactor=e.roughness):(i.pbrMetallicRoughness.metallicFactor=.5,i.pbrMetallicRoughness.roughnessFactor=.5),e.metalnessMap||e.roughnessMap)if(e.metalnessMap===e.roughnessMap){const a={index:this.processTexture(e.metalnessMap)};this.applyTextureTransform(a,e.metalnessMap),i.pbrMetallicRoughness.metallicRoughnessTexture=a}else console.warn("THREE.GLTFExporter: Ignoring metalnessMap and roughnessMap because they are not the same Texture.");if(e.map){const a={index:this.processTexture(e.map)};this.applyTextureTransform(a,e.map),i.pbrMetallicRoughness.baseColorTexture=a}if(e.emissive){const a=e.emissive.clone().multiplyScalar(e.emissiveIntensity),h=Math.max(a.r,a.g,a.b);if(h>1&&(a.multiplyScalar(1/h),console.warn("THREE.GLTFExporter: Some emissive components exceed 1; emissive has been limited")),h>0&&(i.emissiveFactor=a.toArray()),e.emissiveMap){const f={index:this.processTexture(e.emissiveMap)};this.applyTextureTransform(f,e.emissiveMap),i.emissiveTexture=f}}if(e.normalMap){const a={index:this.processTexture(e.normalMap)};e.normalScale&&e.normalScale.x!==-1&&(e.normalScale.x!==e.normalScale.y&&console.warn("THREE.GLTFExporter: Normal scale components are different, ignoring Y and exporting X."),a.scale=e.normalScale.x),this.applyTextureTransform(a,e.normalMap),i.normalTexture=a}if(e.aoMap){const a={index:this.processTexture(e.aoMap),texCoord:1};e.aoMapIntensity!==1&&(a.strength=e.aoMapIntensity),this.applyTextureTransform(a,e.aoMap),i.occlusionTexture=a}e.transparent?i.alphaMode="BLEND":e.alphaTest>0&&(i.alphaMode="MASK",i.alphaCutoff=e.alphaTest),e.side===b.DoubleSide&&(i.doubleSided=!0),e.name!==""&&(i.name=e.name),this.serializeUserData(e,i),this._invokeAll(function(a){a.writeMaterial&&a.writeMaterial(e,i)});const o=s.materials.push(i)-1;return t.materials.set(e,o),o}processMesh(e){const t=this.cache,s=this.json,i=[e.geometry.uuid];if(Array.isArray(e.material))for(let _=0,I=e.material.length;_<I;_++)i.push(e.material[_].uuid);else i.push(e.material.uuid);const n=i.join(":");if(t.meshes.has(n))return t.meshes.get(n);const o=e.geometry;let a;if(e.isLineSegments?a=ae.LINES:e.isLineLoop?a=ae.LINE_LOOP:e.isLine?a=ae.LINE_STRIP:e.isPoints?a=ae.POINTS:a=e.material.wireframe?ae.LINES:ae.TRIANGLES,o.isBufferGeometry!==!0)throw new Error("THREE.GLTFExporter: Geometry is not of type THREE.BufferGeometry.");const h={},f={},c=[],l=[],d={uv:"TEXCOORD_0",uv2:"TEXCOORD_1",color:"COLOR_0",skinWeight:"WEIGHTS_0",skinIndex:"JOINTS_0"},u=o.getAttribute("normal");u!==void 0&&!this.isNormalizedNormalAttribute(u)&&(console.warn("THREE.GLTFExporter: Creating normalized normal attribute from the non-normalized one."),o.setAttribute("normal",this.createNormalizedNormalAttribute(u)));let p=null;for(let _ in o.attributes){if(_.substr(0,5)==="morph")continue;const I=o.attributes[_];if(_=d[_]||_.toUpperCase(),/^(POSITION|NORMAL|TANGENT|TEXCOORD_\d+|COLOR_\d+|JOINTS_\d+|WEIGHTS_\d+)$/.test(_)||(_="_"+_),t.attributes.has(this.getUID(I))){f[_]=t.attributes.get(this.getUID(I));continue}p=null;const V=I.array;_==="JOINTS_0"&&!(V instanceof Uint16Array)&&!(V instanceof Uint8Array)&&(console.warn('GLTFExporter: Attribute "skinIndex" converted to type UNSIGNED_SHORT.'),p=new b.BufferAttribute(new Uint16Array(V),I.itemSize,I.normalized));const R=this.processAccessor(p||I,o);R!==null&&(f[_]=R,t.attributes.set(this.getUID(I),R))}if(u!==void 0&&o.setAttribute("normal",u),Object.keys(f).length===0)return null;if(e.morphTargetInfluences!==void 0&&e.morphTargetInfluences.length>0){const _=[],I=[],k={};if(e.morphTargetDictionary!==void 0)for(const V in e.morphTargetDictionary)k[e.morphTargetDictionary[V]]=V;for(let V=0;V<e.morphTargetInfluences.length;++V){const R={};let W=!1;for(const G in o.morphAttributes){if(G!=="position"&&G!=="normal"&&G!=="color"){W||(console.warn("GLTFExporter: Only POSITION and NORMAL morph are supported."),W=!0);continue}const L=o.morphAttributes[G][V];let T=G.toUpperCase();d[G]&&(T=d[G]);const U=o.attributes[G];if(t.attributes.has(this.getUID(L))){R[T]=t.attributes.get(this.getUID(L));continue}const w=U.clone();if(!o.morphTargetsRelative)if(U)for(let C=0,E=L.count;C<E;C++)U.count>C&&w.setXYZ(C,L.getX(C)-U.getX(C),L.getY(C)-U.getY(C),L.getZ(C)-U.getZ(C));else for(let C=0,E=L.count;C<E;C++)w.setXYZ(C,0,0,0);R[T]=this.processAccessor(w,o),t.attributes.set(this.getUID(U),R[T])}l.push(R),_.push(e.morphTargetInfluences[V]),e.morphTargetDictionary!==void 0&&I.push(k[V])}h.weights=_,I.length>0&&(h.extras={},h.extras.targetNames=I)}const y=Array.isArray(e.material);if(y&&o.groups.length===0)return null;const x=y?e.material:[e.material],g=y?o.groups:[{materialIndex:0,start:void 0,count:void 0}];for(let _=0,I=g.length;_<I;_++){const k={mode:a,attributes:f};if(this.serializeUserData(o,k),l.length>0&&(k.targets=l),o.index!==null){let R=this.getUID(o.index);(g[_].start!==void 0||g[_].count!==void 0)&&(R+=":"+g[_].start+":"+g[_].count),t.attributes.has(R)?k.indices=t.attributes.get(R):(k.indices=this.processAccessor(o.index,o,g[_].start,g[_].count),t.attributes.set(R,k.indices)),k.indices===null&&delete k.indices}const V=this.processMaterial(x[g[_].materialIndex]);V!==null&&(k.material=V),c.push(k)}h.primitives=c,s.meshes||(s.meshes=[]),this._invokeAll(function(_){_.writeMesh&&_.writeMesh(e,h)});const v=s.meshes.push(h)-1;return t.meshes.set(n,v),v}processCamera(e){const t=this.json;t.cameras||(t.cameras=[]);const s=e.isOrthographicCamera,i={type:s?"orthographic":"perspective"};return s?i.orthographic={xmag:e.right*2,ymag:e.top*2,zfar:e.far<=0?.001:e.far,znear:e.near<0?0:e.near}:i.perspective={aspectRatio:e.aspect,yfov:b.MathUtils.degToRad(e.fov),zfar:e.far<=0?.001:e.far,znear:e.near<0?0:e.near},e.name!==""&&(i.name=e.type),t.cameras.push(i)-1}processAnimation(e,t){const s=this.json,i=this.nodeMap;s.animations||(s.animations=[]),e=Ut.Utils.mergeMorphTargetTracks(e.clone(),t);const n=e.tracks,o=[],a=[];for(let h=0;h<n.length;++h){const f=n[h],c=b.PropertyBinding.parseTrackName(f.name);let l=b.PropertyBinding.findNode(t,c.nodeName);const d=Ai[c.propertyName];if(c.objectName==="bones"&&(l.isSkinnedMesh===!0?l=l.skeleton.getBoneByName(c.objectIndex):l=void 0),!l||!d)return console.warn('THREE.GLTFExporter: Could not export animation track "%s".',f.name),null;const u=1;let p=f.values.length/f.times.length;d===Ai.morphTargetInfluences&&(p/=l.morphTargetInfluences.length);let y;f.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline===!0?(y="CUBICSPLINE",p/=3):f.getInterpolation()===b.InterpolateDiscrete?y="STEP":y="LINEAR",a.push({input:this.processAccessor(new b.BufferAttribute(f.times,u)),output:this.processAccessor(new b.BufferAttribute(f.values,p)),interpolation:y}),o.push({sampler:a.length-1,target:{node:i.get(l),path:d}})}return s.animations.push({name:e.name||"clip_"+s.animations.length,samplers:a,channels:o}),s.animations.length-1}processSkin(e){const t=this.json,s=this.nodeMap,i=t.nodes[s.get(e)],n=e.skeleton;if(n===void 0)return null;const o=e.skeleton.bones[0];if(o===void 0)return null;const a=[],h=new Float32Array(n.bones.length*16),f=new b.Matrix4;for(let l=0;l<n.bones.length;++l)a.push(s.get(n.bones[l])),f.copy(n.boneInverses[l]),f.multiply(e.bindMatrix).toArray(h,l*16);return t.skins===void 0&&(t.skins=[]),t.skins.push({inverseBindMatrices:this.processAccessor(new b.BufferAttribute(h,16)),joints:a,skeleton:s.get(o)}),i.skin=t.skins.length-1}processNode(e){const t=this.json,s=this.options,i=this.nodeMap;t.nodes||(t.nodes=[]);const n={};if(s.trs){const a=e.quaternion.toArray(),h=e.position.toArray(),f=e.scale.toArray();Qe(a,[0,0,0,1])||(n.rotation=a),Qe(h,[0,0,0])||(n.translation=h),Qe(f,[1,1,1])||(n.scale=f)}else e.matrixAutoUpdate&&e.updateMatrix(),Ns(e.matrix)===!1&&(n.matrix=e.matrix.elements);if(e.name!==""&&(n.name=String(e.name)),this.serializeUserData(e,n),e.isMesh||e.isLine||e.isPoints){const a=this.processMesh(e);a!==null&&(n.mesh=a)}else e.isCamera&&(n.camera=this.processCamera(e));if(e.isSkinnedMesh&&this.skins.push(e),e.children.length>0){const a=[];for(let h=0,f=e.children.length;h<f;h++){const c=e.children[h];if(c.visible||s.onlyVisible===!1){const l=this.processNode(c);l!==null&&a.push(l)}}a.length>0&&(n.children=a)}this._invokeAll(function(a){a.writeNode&&a.writeNode(e,n)});const o=t.nodes.push(n)-1;return i.set(e,o),o}processScene(e){const t=this.json,s=this.options;t.scenes||(t.scenes=[],t.scene=0);const i={};e.name!==""&&(i.name=e.name),t.scenes.push(i);const n=[];for(let o=0,a=e.children.length;o<a;o++){const h=e.children[o];if(h.visible||s.onlyVisible===!1){const f=this.processNode(h);f!==null&&n.push(f)}}n.length>0&&(i.nodes=n),this.serializeUserData(e,i)}processObjects(e){const t=new b.Scene;t.name="AuxScene";for(let s=0;s<e.length;s++)t.children.push(e[s]);this.processScene(t)}processInput(e){const t=this.options;e=e instanceof Array?e:[e],this._invokeAll(function(i){i.beforeParse&&i.beforeParse(e)});const s=[];for(let i=0;i<e.length;i++)e[i]instanceof b.Scene?this.processScene(e[i]):s.push(e[i]);s.length>0&&this.processObjects(s);for(let i=0;i<this.skins.length;++i)this.processSkin(this.skins[i]);for(let i=0;i<t.animations.length;++i)this.processAnimation(t.animations[i].clip,t.animations[i].mesh);this._invokeAll(function(i){i.afterParse&&i.afterParse(e)})}_invokeAll(e){for(let t=0,s=this.plugins.length;t<s;t++)e(this.plugins[t])}}class Es{constructor(e){this.writer=e,this.name="KHR_lights_punctual"}writeNode(e,t){if(!e.isLight)return;if(!e.isDirectionalLight&&!e.isPointLight&&!e.isSpotLight){console.warn("THREE.GLTFExporter: Only directional, point, and spot lights are supported.",e);return}const s=this.writer,i=s.json,n=s.extensionsUsed,o={};e.name&&(o.name=e.name),o.color=e.color.toArray(),o.intensity=e.intensity,e.isDirectionalLight?o.type="directional":e.isPointLight?(o.type="point",e.distance>0&&(o.range=e.distance)):e.isSpotLight&&(o.type="spot",e.distance>0&&(o.range=e.distance),o.spot={},o.spot.innerConeAngle=(e.penumbra-1)*e.angle*-1,o.spot.outerConeAngle=e.angle),e.decay!==void 0&&e.decay!==2&&console.warn("THREE.GLTFExporter: Light decay may be lost. glTF is physically-based, and expects light.decay=2."),e.target&&(e.target.parent!==e||e.target.position.x!==0||e.target.position.y!==0||e.target.position.z!==-1)&&console.warn("THREE.GLTFExporter: Light direction may be lost. For best results, make light.target a child of the light with position 0,0,-1."),n[this.name]||(i.extensions=i.extensions||{},i.extensions[this.name]={lights:[]},n[this.name]=!0);const a=i.extensions[this.name].lights;a.push(o),t.extensions=t.extensions||{},t.extensions[this.name]={light:a.length-1}}}class Ds{constructor(e){this.writer=e,this.name="KHR_materials_unlit"}writeMaterial(e,t){if(!e.isMeshBasicMaterial)return;const i=this.writer.extensionsUsed;t.extensions=t.extensions||{},t.extensions[this.name]={},i[this.name]=!0,t.pbrMetallicRoughness.metallicFactor=0,t.pbrMetallicRoughness.roughnessFactor=.9}}class ks{constructor(e){this.writer=e,this.name="KHR_materials_pbrSpecularGlossiness"}writeMaterial(e,t){if(!e.isGLTFSpecularGlossinessMaterial)return;const s=this.writer,i=s.extensionsUsed,n={};t.pbrMetallicRoughness.baseColorFactor&&(n.diffuseFactor=t.pbrMetallicRoughness.baseColorFactor);const o=[1,1,1];if(e.specular.toArray(o,0),n.specularFactor=o,n.glossinessFactor=e.glossiness,t.pbrMetallicRoughness.baseColorTexture&&(n.diffuseTexture=t.pbrMetallicRoughness.baseColorTexture),e.specularMap){const a={index:s.processTexture(e.specularMap)};s.applyTextureTransform(a,e.specularMap),n.specularGlossinessTexture=a}t.extensions=t.extensions||{},t.extensions[this.name]=n,i[this.name]=!0}}Ut.Utils={insertKeyframe:function(r,e){const s=r.getValueSize(),i=new r.TimeBufferType(r.times.length+1),n=new r.ValueBufferType(r.values.length+s),o=r.createInterpolant(new r.ValueBufferType(s));let a;if(r.times.length===0){i[0]=e;for(let h=0;h<s;h++)n[h]=0;a=0}else if(e<r.times[0]){if(Math.abs(r.times[0]-e)<.001)return 0;i[0]=e,i.set(r.times,1),n.set(o.evaluate(e),0),n.set(r.values,s),a=0}else if(e>r.times[r.times.length-1]){if(Math.abs(r.times[r.times.length-1]-e)<.001)return r.times.length-1;i[i.length-1]=e,i.set(r.times,0),n.set(r.values,0),n.set(o.evaluate(e),r.values.length),a=i.length-1}else for(let h=0;h<r.times.length;h++){if(Math.abs(r.times[h]-e)<.001)return h;if(r.times[h]<e&&r.times[h+1]>e){i.set(r.times.slice(0,h+1),0),i[h+1]=e,i.set(r.times.slice(h+1),h+2),n.set(r.values.slice(0,(h+1)*s),0),n.set(o.evaluate(e),(h+1)*s),n.set(r.values.slice((h+1)*s),(h+2)*s),a=h+1;break}}return r.times=i,r.values=n,a},mergeMorphTargetTracks:function(r,e){const t=[],s={},i=r.tracks;for(let n=0;n<i.length;++n){let o=i[n];const a=b.PropertyBinding.parseTrackName(o.name),h=b.PropertyBinding.findNode(e,a.nodeName);if(a.propertyName!=="morphTargetInfluences"||a.propertyIndex===void 0){t.push(o);continue}if(o.createInterpolant!==o.InterpolantFactoryMethodDiscrete&&o.createInterpolant!==o.InterpolantFactoryMethodLinear){if(o.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline)throw new Error("THREE.GLTFExporter: Cannot merge tracks with glTF CUBICSPLINE interpolation.");console.warn("THREE.GLTFExporter: Morph target interpolation mode not yet supported. Using LINEAR instead."),o=o.clone(),o.setInterpolation(b.InterpolateLinear)}const f=h.morphTargetInfluences.length,c=h.morphTargetDictionary[a.propertyIndex];if(c===void 0)throw new Error("THREE.GLTFExporter: Morph target name not found: "+a.propertyIndex);let l;if(s[h.uuid]===void 0){l=o.clone();const u=new l.ValueBufferType(f*l.times.length);for(let p=0;p<l.times.length;p++)u[p*f+c]=l.values[p];l.name=(a.nodeName||"")+".morphTargetInfluences",l.values=u,s[h.uuid]=l,t.push(l);continue}const d=o.createInterpolant(new o.ValueBufferType(1));l=s[h.uuid];for(let u=0;u<l.times.length;u++)l.values[u*f+c]=d.evaluate(l.times[u]);for(let u=0;u<o.times.length;u++){const p=this.insertKeyframe(l,o.times[u]);l.values[p*f+c]=o.values[u]}}return r.tracks=t,r}};const Vs=function(r){const e=r;this.exportGLTF=t=>{const i=e.getRootRegion().getAllObjects(!0),n=[];i.forEach(h=>{h.animationClip&&n.push({clip:h.animationClip[0],mesh:h.getMorph()})});const o=new Ut,a={binary:t,animations:n};return new Promise((h,f)=>{o.parse(e.getThreeJSScene(),function(c){h(c)},a)})}},Rs=function(){const r=this;this.parseGLTFObjects=(e,t,s,i)=>{let n=t;if(s!==0)if(e.type==="Object3D"){if(e.name!==""&&(t&&(n=t.findOrCreateChildFromPath(e.name)),n)){const o=n.getGroup();o.position.copy(e.position),o.rotation.copy(e.rotation),o.quaternion.copy(e.quaternion),o.matrixAutoUpdate=!0}}else{let o;if(e.type==="Mesh"?o=new Xe:e.type==="LineSegments"?o=new ze:e.type==="Points"&&(o=new Ee),o){let a=!1,h=!1;e.geometry&&e.geometry.morphAttributes&&(a=!!e.geometry.morphAttributes.position,h=!!e.geometry.morphAttributes.color),o.setMesh(e.clone(),a,h);const f=o.getMorph();o.groupName=f.name,f.matrixAutoUpdate=!0,t.addZincObject(o),i!=null&&typeof i=="function"&&i(o)}}s++,e.children.forEach(o=>{r.parseGLTFObjects(o,n,s,i)})},this.setCamera=e=>{e.viewAll();const t=e.getZincCameraControls(),s=t.getCurrentViewport();t.addViewport("default",s),t.setDefaultViewport("default")},this.load=(e,t,s,i,n,o)=>{const a=s.substring(0,s.lastIndexOf("/")+1),h=s.substring(s.lastIndexOf("/")+1,s.length);new Zi.GLTFLoader().setPath(a).load(h,function(c){console.log(c),r.parseGLTFObjects(c.scene,t,0,i),r.setCamera(e),n!=null&&typeof n=="function"&&n()})}},Fs=/^[og]\s*(.+)?/,Gs=/^mtllib /,zs=/^usemtl /,js=/^usemap /,Si=new b.Vector3,It=new b.Vector3,Ci=new b.Vector3,Ti=new b.Vector3,Se=new b.Vector3;function qs(){const r={objects:[],object:{},vertices:[],normals:[],colors:[],uvs:[],materials:{},materialLibraries:[],startObject:function(e,t){if(this.object&&this.object.fromDeclaration===!1){this.object.name=e,this.object.fromDeclaration=t!==!1;return}const s=this.object&&typeof this.object.currentMaterial=="function"?this.object.currentMaterial():void 0;if(this.object&&typeof this.object._finalize=="function"&&this.object._finalize(!0),this.object={name:e||"",fromDeclaration:t!==!1,geometry:{vertices:[],normals:[],colors:[],uvs:[],hasUVIndices:!1},materials:[],smooth:!0,startMaterial:function(i,n){const o=this._finalize(!1);o&&(o.inherited||o.groupCount<=0)&&this.materials.splice(o.index,1);const a={index:this.materials.length,name:i||"",mtllib:Array.isArray(n)&&n.length>0?n[n.length-1]:"",smooth:o!==void 0?o.smooth:this.smooth,groupStart:o!==void 0?o.groupEnd:0,groupEnd:-1,groupCount:-1,inherited:!1,clone:function(h){const f={index:typeof h=="number"?h:this.index,name:this.name,mtllib:this.mtllib,smooth:this.smooth,groupStart:0,groupEnd:-1,groupCount:-1,inherited:!1};return f.clone=this.clone.bind(f),f}};return this.materials.push(a),a},currentMaterial:function(){if(this.materials.length>0)return this.materials[this.materials.length-1]},_finalize:function(i){const n=this.currentMaterial();if(n&&n.groupEnd===-1&&(n.groupEnd=this.geometry.vertices.length/3,n.groupCount=n.groupEnd-n.groupStart,n.inherited=!1),i&&this.materials.length>1)for(let o=this.materials.length-1;o>=0;o--)this.materials[o].groupCount<=0&&this.materials.splice(o,1);return i&&this.materials.length===0&&this.materials.push({name:"",smooth:this.smooth}),n}},s&&s.name&&typeof s.clone=="function"){const i=s.clone(0);i.inherited=!0,this.object.materials.push(i)}this.objects.push(this.object)},finalize:function(){this.object&&typeof this.object._finalize=="function"&&this.object._finalize(!0)},parseVertexIndex:function(e,t){const s=parseInt(e,10);return(s>=0?s-1:s+t/3)*3},parseNormalIndex:function(e,t){const s=parseInt(e,10);return(s>=0?s-1:s+t/3)*3},parseUVIndex:function(e,t){const s=parseInt(e,10);return(s>=0?s-1:s+t/2)*2},addVertex:function(e,t,s){const i=this.vertices,n=this.object.geometry.vertices;n.push(i[e+0],i[e+1],i[e+2]),n.push(i[t+0],i[t+1],i[t+2]),n.push(i[s+0],i[s+1],i[s+2])},addVertexPoint:function(e){const t=this.vertices;this.object.geometry.vertices.push(t[e+0],t[e+1],t[e+2])},addVertexLine:function(e){const t=this.vertices;this.object.geometry.vertices.push(t[e+0],t[e+1],t[e+2])},addNormal:function(e,t,s){const i=this.normals,n=this.object.geometry.normals;n.push(i[e+0],i[e+1],i[e+2]),n.push(i[t+0],i[t+1],i[t+2]),n.push(i[s+0],i[s+1],i[s+2])},addFaceNormal:function(e,t,s){const i=this.vertices,n=this.object.geometry.normals;Si.fromArray(i,e),It.fromArray(i,t),Ci.fromArray(i,s),Se.subVectors(Ci,It),Ti.subVectors(Si,It),Se.cross(Ti),Se.normalize(),n.push(Se.x,Se.y,Se.z),n.push(Se.x,Se.y,Se.z),n.push(Se.x,Se.y,Se.z)},addColor:function(e,t,s){const i=this.colors,n=this.object.geometry.colors;i[e]!==void 0&&n.push(i[e+0],i[e+1],i[e+2]),i[t]!==void 0&&n.push(i[t+0],i[t+1],i[t+2]),i[s]!==void 0&&n.push(i[s+0],i[s+1],i[s+2])},addUV:function(e,t,s){const i=this.uvs,n=this.object.geometry.uvs;n.push(i[e+0],i[e+1]),n.push(i[t+0],i[t+1]),n.push(i[s+0],i[s+1])},addDefaultUV:function(){const e=this.object.geometry.uvs;e.push(0,0),e.push(0,0),e.push(0,0)},addUVLine:function(e){const t=this.uvs;this.object.geometry.uvs.push(t[e+0],t[e+1])},addFace:function(e,t,s,i,n,o,a,h,f){const c=this.vertices.length;let l=this.parseVertexIndex(e,c),d=this.parseVertexIndex(t,c),u=this.parseVertexIndex(s,c);if(this.addVertex(l,d,u),this.addColor(l,d,u),a!==void 0&&a!==""){const p=this.normals.length;l=this.parseNormalIndex(a,p),d=this.parseNormalIndex(h,p),u=this.parseNormalIndex(f,p),this.addNormal(l,d,u)}else this.addFaceNormal(l,d,u);if(i!==void 0&&i!==""){const p=this.uvs.length;l=this.parseUVIndex(i,p),d=this.parseUVIndex(n,p),u=this.parseUVIndex(o,p),this.addUV(l,d,u),this.object.geometry.hasUVIndices=!0}else this.addDefaultUV()},addPointGeometry:function(e){this.object.geometry.type="Points";const t=this.vertices.length;for(let s=0,i=e.length;s<i;s++){const n=this.parseVertexIndex(e[s],t);this.addVertexPoint(n),this.addColor(n)}},addLineGeometry:function(e,t){this.object.geometry.type="Line";const s=this.vertices.length,i=this.uvs.length;for(let n=0,o=e.length;n<o;n++)this.addVertexLine(this.parseVertexIndex(e[n],s));for(let n=0,o=t.length;n<o;n++)this.addUVLine(this.parseUVIndex(t[n],i))}};return r.startObject("",!1),r}class Oi extends b.Loader{constructor(e){super(e),this.materials=null}load(e,t,s,i){const n=this,o=new b.FileLoader(this.manager);o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,function(a){try{t(n.parse(a))}catch(h){i?i(h):console.error(h),n.manager.itemError(e)}},s,i)}setMaterials(e){return this.materials=e,this}parse(e){const t=new qs;e.indexOf(`\r
288
- `)!==-1&&(e=e.replace(/\r\n/g,`
289
- `)),e.indexOf(`\\
290
- `)!==-1&&(e=e.replace(/\\\n/g,""));const s=e.split(`
291
- `);let i="",n="",o=0,a=[];const h=typeof"".trimLeft=="function";for(let l=0,d=s.length;l<d;l++)if(i=s[l],i=h?i.trimLeft():i.trim(),o=i.length,o!==0&&(n=i.charAt(0),n!=="#"))if(n==="v"){const u=i.split(/\s+/);switch(u[0]){case"v":t.vertices.push(parseFloat(u[1]),parseFloat(u[2]),parseFloat(u[3])),u.length>=7?t.colors.push(parseFloat(u[4]),parseFloat(u[5]),parseFloat(u[6])):t.colors.push(void 0,void 0,void 0);break;case"vn":t.normals.push(parseFloat(u[1]),parseFloat(u[2]),parseFloat(u[3]));break;case"vt":t.uvs.push(parseFloat(u[1]),parseFloat(u[2]));break}}else if(n==="f"){const p=i.substr(1).trim().split(/\s+/),y=[];for(let g=0,v=p.length;g<v;g++){const _=p[g];if(_.length>0){const I=_.split("/");y.push(I)}}const x=y[0];for(let g=1,v=y.length-1;g<v;g++){const _=y[g],I=y[g+1];t.addFace(x[0],_[0],I[0],x[1],_[1],I[1],x[2],_[2],I[2])}}else if(n==="l"){const u=i.substring(1).trim().split(" ");let p=[];const y=[];if(i.indexOf("/")===-1)p=u;else for(let x=0,g=u.length;x<g;x++){const v=u[x].split("/");v[0]!==""&&p.push(v[0]),v[1]!==""&&y.push(v[1])}t.addLineGeometry(p,y)}else if(n==="p"){const p=i.substr(1).trim().split(" ");t.addPointGeometry(p)}else if((a=Fs.exec(i))!==null){const u=(" "+a[0].substr(1).trim()).substr(1);t.startObject(u)}else if(zs.test(i))t.object.startMaterial(i.substring(7).trim(),t.materialLibraries);else if(Gs.test(i))t.materialLibraries.push(i.substring(7).trim());else if(js.test(i))console.warn('THREE.OBJLoader: Rendering identifier "usemap" not supported. Textures must be defined in MTL files.');else if(n==="s"){if(a=i.split(" "),a.length>1){const p=a[1].trim().toLowerCase();t.object.smooth=p!=="0"&&p!=="off"}else t.object.smooth=!0;const u=t.object.currentMaterial();u&&(u.smooth=t.object.smooth)}else{if(i==="\0")continue;console.warn('THREE.OBJLoader: Unexpected line: "'+i+'"')}t.finalize();const f=new b.Group;if(f.materialLibraries=[].concat(t.materialLibraries),!(t.objects.length===1&&t.objects[0].geometry.vertices.length===0)===!0)for(let l=0,d=t.objects.length;l<d;l++){const u=t.objects[l],p=u.geometry,y=u.materials,x=p.type==="Line",g=p.type==="Points";let v=!1;if(p.vertices.length===0)continue;const _=new b.BufferGeometry;_.setAttribute("position",new b.Float32BufferAttribute(p.vertices,3)),p.normals.length>0&&_.setAttribute("normal",new b.Float32BufferAttribute(p.normals,3)),p.colors.length>0&&(v=!0,_.setAttribute("color",new b.Float32BufferAttribute(p.colors,3))),p.hasUVIndices===!0&&_.setAttribute("uv",new b.Float32BufferAttribute(p.uvs,2));const I=[];for(let V=0,R=y.length;V<R;V++){const W=y[V],G=W.name+"_"+W.smooth+"_"+v;let L=t.materials[G];if(this.materials!==null){if(L=this.materials.create(W.name),x&&L&&!(L instanceof b.LineBasicMaterial)){const T=new b.LineBasicMaterial;b.Material.prototype.copy.call(T,L),T.color.copy(L.color),L=T}else if(g&&L&&!(L instanceof b.PointsMaterial)){const T=new b.PointsMaterial({size:10,sizeAttenuation:!1});b.Material.prototype.copy.call(T,L),T.color.copy(L.color),T.map=L.map,L=T}}L===void 0&&(x?L=new b.LineBasicMaterial:g?L=new b.PointsMaterial({size:1,sizeAttenuation:!1}):L=new b.MeshPhongMaterial,L.name=W.name,L.flatShading=!W.smooth,L.vertexColors=v,t.materials[G]=L),I.push(L)}let k;if(I.length>1){for(let V=0,R=y.length;V<R;V++){const W=y[V];_.addGroup(W.groupStart,W.groupCount,V)}x?k=new b.LineSegments(_,I):g?k=new b.Points(_,I):k=new b.Mesh(_,I)}else x?k=new b.LineSegments(_,I[0]):g?k=new b.Points(_,I[0]):k=new b.Mesh(_,I[0]);k.name=u.name,f.add(k)}else if(t.vertices.length>0){const l=new b.PointsMaterial({size:1,sizeAttenuation:!1}),d=new b.BufferGeometry;d.setAttribute("position",new b.Float32BufferAttribute(t.vertices,3)),t.colors.length>0&&t.colors[0]!==void 0&&(d.setAttribute("color",new b.Float32BufferAttribute(t.colors,3)),l.vertexColors=!0);const u=new b.Points(d,l);f.add(u)}return f}}const Li=M.FileLoader,Ws=r=>{const e=(t,s)=>{t.metadata.number_of_vertices+=s.metadata.number_of_vertices,"labels"in t&&t.labels.push(...t.labels),["axis1","axis2","axis3","colors","positions","scale"].forEach(n=>{n in t&&Object.keys(t[n]).forEach(o=>{const a=s[n][o].length;for(let h=0;h<a;h++)t[n][o].push(s[n][o][h])})})};if(r&&r.length>0)for(;r.length>1;){const t=r.splice(1,1);e(r[0],t[0])}},Zs=r=>{const e=(t,s)=>{t.merge(s)};if(r&&r.length>0){for(;r.length>1;){const t=r.splice(1,1);e(r[0],t[0])}return r[0]}},Ys=function(r,e,t){const s=new Li,i=new ot;s.crossOrigin=e;const n=r,o=t;let a,h=!1,f=!1,c;const l=[],d=x=>{const g=a[x.index];if(g)if("GlyphGeometriesURL"in g)x.onLoad(g);else{let v=i.parse(g);x.onLoad(v.geometry,v.materials)}else u(x)},u=x=>{x.onError&&(c||(c={responseURL:n}),x.onError(c))};this.downloadCompleted=x=>{try{a=JSON.parse(x[0]),h=!1,f=!0,Array.isArray(a)?l.forEach(g=>d(g)):l.forEach(g=>u(g))}catch{l.forEach(g=>u(g))}};const p=()=>x=>{c=x,f=!0,h=!1,l.forEach(g=>{u(g)})},y=()=>x=>{l.forEach(g=>{g.onProgress&&g.onProgress(x)})};this.load=(x,g,v,_)=>{const I={index:x,onLoad:g,onProgress:v,onError:_};f?a?d(I):u(c):h?l.push(I):(l.push(I),h=!0,s.load(n,o,y,p))}},Xs=function(r,e,t){const s=[],i=r,n=e;let o=0;const a=t.isGlyphsets;this.itemDownloaded=(h,f)=>{if(s[h]=f,o++,o==i&&s.length>0)if(a){const c=s.map(l=>JSON.parse(l[0]));Ws(c),n(c[0])}else{const c=s[0][1],l=s.map(u=>u[0]),d=Zs(l);for(let u=1;u<i;u++)s[h][0].dispose(),s[h][1].forEach(p=>p.dispose());n(d,c)}}},Ks=function(){let r=0;const e=20;this.crossOrigin="Anonymous";const t=new ot,s=new Li;s.crossOrigin="Anonymous";const i=[],n={},o=(c,l,d,u,p)=>{const y=c.length,x=new Xs(y,l,p);let g=0;c.forEach(v=>{const _=p?{...p}:{};_.msHandler=x,_.order=g,g++,h(v,l,d,u,_)})},a=(c,l,d,u,p)=>{const y=p?{...p}:{};let x=n[c];if(!x)if(e>r){const g=new f(void 0,this,y);++r,x=new Ys(c,this.crossOrigin,g),n[c]=x}else i.push({url:c,onLoad:l,onProgress:d,onError:u,options:p});x&&(y.isHandler=x,x.load(p.index,l,d,u))},h=(c,l,d,u,p)=>{if(p&&p.index!==void 0)a(c,l,d,u,p);else if(e>r){++r;const y=new f(l,this,p),x=new f(u,this,p);p.isGlyphsets?s.load(c,y,d,x):(t.crossOrigin=this.crossOrigin,t.load(c,y,d,x))}else i.push({url:c,onLoad:l,onProgress:d,onError:u,options:p})};this.load=(c,l,d,u,p)=>{Array.isArray(c)?o(c,l,d,u,p):h(c,l,d,u,p)},this.loadFromWaitingList=()=>{for(;e>r;){const c=i.shift();if(c)this.load(c.url,c.onLoad,c.onProgress,c.onError,c.options);else return}},this.itemRemainingCheck=()=>{if(i.length===0&&r===0)for(let c in n)n.hasOwnProperty(c)&&delete n[c]};const f=function(c,l,d){return(...u)=>{--r,d!=null&&d.msHandler?d.msHandler.itemDownloaded(d.order,u):d!=null&&d.isHandler?d.isHandler.downloadCompleted(u):c&&c(...u),l.loadFromWaitingList(),l.itemRemainingCheck()}};this.parse=c=>loader.parse(c)};class Bi extends b.Loader{constructor(e){super(e)}load(e,t,s,i){const n=this,o=new b.FileLoader(this.manager);o.setPath(this.path),o.setResponseType("arraybuffer"),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,function(a){try{t(n.parse(a))}catch(h){i?i(h):console.error(h),n.manager.itemError(e)}},s,i)}parse(e){function t(f){const c=new DataView(f),l=32/8*3+32/8*3*3+16/8,d=c.getUint32(80,!0);if(80+32/8+d*l===c.byteLength)return!0;const p=[115,111,108,105,100];for(let y=0;y<5;y++)if(s(p,c,y))return!1;return!0}function s(f,c,l){for(let d=0,u=f.length;d<u;d++)if(f[d]!==c.getUint8(l+d,!1))return!1;return!0}function i(f){const c=new DataView(f),l=c.getUint32(80,!0);let d,u,p,y=!1,x,g,v,_,I;for(let L=0;L<70;L++)c.getUint32(L,!1)==1129270351&&c.getUint8(L+4)==82&&c.getUint8(L+5)==61&&(y=!0,x=new Float32Array(l*3*3),g=c.getUint8(L+6)/255,v=c.getUint8(L+7)/255,_=c.getUint8(L+8)/255,I=c.getUint8(L+9)/255);const k=84,V=12*4+2,R=new b.BufferGeometry,W=new Float32Array(l*3*3),G=new Float32Array(l*3*3);for(let L=0;L<l;L++){const T=k+L*V,U=c.getFloat32(T,!0),w=c.getFloat32(T+4,!0),C=c.getFloat32(T+8,!0);if(y){const E=c.getUint16(T+48,!0);E&32768?(d=g,u=v,p=_):(d=(E&31)/31,u=(E>>5&31)/31,p=(E>>10&31)/31)}for(let E=1;E<=3;E++){const N=T+E*12,m=L*3*3+(E-1)*3;W[m]=c.getFloat32(N,!0),W[m+1]=c.getFloat32(N+4,!0),W[m+2]=c.getFloat32(N+8,!0),G[m]=U,G[m+1]=w,G[m+2]=C,y&&(x[m]=d,x[m+1]=u,x[m+2]=p)}}return R.setAttribute("position",new b.BufferAttribute(W,3)),R.setAttribute("normal",new b.BufferAttribute(G,3)),y&&(R.setAttribute("color",new b.BufferAttribute(x,3)),R.hasColors=!0,R.alpha=I),R}function n(f){const c=new b.BufferGeometry,l=/solid([\s\S]*?)endsolid/g,d=/facet([\s\S]*?)endfacet/g;let u=0;const p=/[\s]+([+-]?(?:\d*)(?:\.\d*)?(?:[eE][+-]?\d+)?)/.source,y=new RegExp("vertex"+p+p+p,"g"),x=new RegExp("normal"+p+p+p,"g"),g=[],v=[],_=new b.Vector3;let I,k=0,V=0,R=0;for(;(I=l.exec(f))!==null;){V=R;const W=I[0];for(;(I=d.exec(W))!==null;){let T=0,U=0;const w=I[0];for(;(I=x.exec(w))!==null;)_.x=parseFloat(I[1]),_.y=parseFloat(I[2]),_.z=parseFloat(I[3]),U++;for(;(I=y.exec(w))!==null;)g.push(parseFloat(I[1]),parseFloat(I[2]),parseFloat(I[3])),v.push(_.x,_.y,_.z),T++,R++;U!==1&&console.error("THREE.STLLoader: Something isn't right with the normal of face number "+u),T!==3&&console.error("THREE.STLLoader: Something isn't right with the vertices of face number "+u),u++}const G=V,L=R-V;c.addGroup(G,L,k),k++}return c.setAttribute("position",new b.Float32BufferAttribute(g,3)),c.setAttribute("normal",new b.Float32BufferAttribute(v,3)),c}function o(f){return typeof f!="string"?b.LoaderUtils.decodeText(new Uint8Array(f)):f}function a(f){if(typeof f=="string"){const c=new Uint8Array(f.length);for(let l=0;l<f.length;l++)c[l]=f.charCodeAt(l)&255;return c.buffer||c}else return f}const h=a(e);return t(h)?i(h):n(o(e))}}const Ui=function(){Q.call(this),this.isTubeLines=!0;let r={},e={radius:1,radialSegments:8,smooth:!1};this.createLineSegment=(s,i,n)=>{if(s&&i){r={geometryIn:s,materialIn:i,options:n};const o=t(s.vertices),a=new M.MeshStandardMaterial({color:i.color}),h=new M.Mesh(o,a);this.setMesh(h,n.localTimeEnabled,n.localMorphColour)}},this.setWidth=s=>{this.morph&&this.morph.material&&(this.morph.material.linewidth=s,this.morph.material.needsUpdate=!0)},this.setAlpha=function(s){let i=this.getMorph();i.material.opacity=s,i.material.transparent=s<1,i.material.depthWrite=s>.5},this.setWireframe=s=>{let i=this.getMorph();i.material.wireframe=s},this.setTubeLines=(s,i)=>{if(s&&i){const{geometryIn:n}=r;let o=this.getMorph();o.geometry.dispose(),e=Object.assign(e,{radius:s,radialSegments:i}),o.geometry=t(n.vertices)}};const t=s=>{const{radius:i,radialSegments:n,smooth:o}=e;let a;if(o){const h=new M.CatmullRomCurve3(s);a=new M.TubeGeometry(h,s.length,i,n,!1)}else{const h=[];for(let f=0;f+1<s.length;f=f+2){const c=new M.LineCurve3(s[f],s[f+1]),l=new M.TubeGeometry(c,1,i,n,!1);h.push(l)}a=ss(h,!0),h.forEach(f=>f.dispose())}return a}};Ui.prototype=Object.create(Q.prototype);const Js=function(r){const e=r;this.toBeDownloaded=0,this.progressMap={};let t=!1,s=!1;const i=new Ks;this.getDownloadProgress=()=>{let L=0,T=0,U=!1;for(const w in this.progressMap){const C=this.progressMap[w];L+=C[1],T+=C[0],C[1]==0&&(U=!0)}return U&&(L=0),[L,T,s]},this.onProgress=L=>T=>{this.progressMap[L]=[T.loaded,T.total]},this.onError=L=>T=>{this.toBeDownloaded=this.toBeDownloaded-1,s=!0,console.error(`There is an issue with external resource ${T!=null&&T.responseURL?": "+(T==null?void 0:T.responseURL):""}.`),L&&L({type:"Error",xhr:T})};let n=(L,T)=>{const U=T.Default;if(T.Inline)e.setupMultipleViews(U,T.Entries);else{const w=[];for(const[C,E]of Object.entries(T.Entries))if(L){const N=Ge(E,L);w.push(new Promise((m,O)=>{fetch(N).then(B=>B.json()).then(B=>m({key:C,data:B})).catch(B=>O(B))}))}Promise.all(w).then(C=>{const E={};C.forEach(m=>{E[m.key]=m.data}),e.setupMultipleViews(U,E);let N=e.getZincCameraControls();N&&N.setCurrentViewport(U),t=!0})}};this.loadViewURL=(L,T)=>{this.toBeDownloaded+=1;const U=L;fetch(U).then(w=>{if(!w.ok)throw new Error(`HTTP error! status: ${w.status}`);return w.json()}).then(w=>{e.setupMultipleViews("default",{default:w}),e.resetView(),t=!0,--this.toBeDownloaded,T!==void 0&&typeof T=="function"&&T()}).catch(w=>{console.error(`Fetch failed for URL: ${U}`,w),this.onError(T)({responseURL:U})})},this.loadModelsURL=(L,T,U,w,C,E,N)=>{const m=T.length;this.toBeDownloaded+=m;for(let O=0;O<m;O++){const B=T[O];let S=Pe.defaultMaterialColor,P=Pe.defaultOpacity;U!=null&&U[O]!=null&&(S=!!U[O]),w!=null&&w[O]!=null&&(P=w[O]);let F=0;C!=null&&C[O]!=null&&(F=!!C[O]);let j=0;E!=null&&E[O]!=null&&(j=!!E[O]),i.load(B,u(L,S,P,F,j,void 0,void 0,void 0,void 0,N),this.onProgress(B),this.onError(N))}},this.loadFromViewURL=(L,T,U)=>{const w=T+"_view.json";fetch(w).then(C=>{if(!C.ok)throw new Error(`HTTP error! status: ${C.status}`);return C.json()}).then(C=>{e.loadView(C);const E=[],N=T+"_";for(let m=0;m<C.numberOfResources;m++){const O=N+(m+1)+".json";E.push(O)}this.loadModelsURL(L,E,C.colour,C.opacity,C.timeEnabled,C.morphColour,U)}).catch(C=>{console.error(`Failed to load view data from: ${w}`,C)})};const o=(L,T,U,w,C,E,N,m,O)=>(B,S)=>{const P=m?new Ui:new ze;let F;S&&S[0]&&(F=new M.LineBasicMaterial({color:S[0].color.clone()}),1>S[0].opacity&&(F.transparent=!0),F.opacity=S[0].opacity,F.morphTargets=T,F.vertexColors=S[0].vertexColors);let j={};if(j.localTimeEnabled=T,j.localMorphColour=U,P&&(P.createLineSegment(B,F,j),P.setName(w),P.setAnatomicalId(C),P.setRenderOrder(E),L.addZincObject(P),P.setDuration(e.getDuration()),N&&N.levels))for(const[J,X]of Object.entries(N.levels))P.addLOD(i,J,X.URL,X.Index,N.preload);--this.toBeDownloaded,B.dispose(),O!=null&&typeof O=="function"&&O(P)};this.loadLinesURL=(L,T,U,w,C,E,N)=>{let m=0;this.toBeDownloaded+=1;let O=N!=null&&N.isInline?N.isInline:!1,B=N!=null&&N.anatomicalId?N.anatomicalId:void 0,S=N&&"renderOrder"in N?N.renderOrder:void 0;U!=null&&(m=!!U);let P=0;w!=null&&(P=!!w);let F=N.tubeLines&&!m&&!P;if(O){let j=i.parse(T);o(L,m,P,C,B,S,N.lod,F,E)(j.geometry,j.materials)}else i.load(T,o(L,m,P,C,B,S,N.lod,F,E),this.onProgress(T),this.onError(E),N.loaderOptions)};const a=(L,T,U,w,C)=>E=>{let N=E;(typeof N=="string"||N instanceof String)&&(N=JSON.parse(E));let m=C&&C.isInline?C.isInline:void 0,O=C&&C.anatomicalId?C.anatomicalId:void 0,B=C!=null&&C.displayLabels?C.displayLabels:!0,S=C&&"renderOrder"in C?C.renderOrder:void 0;const P=new vt;P.setDuration(e.getDuration()),P.groupName=U;let F=()=>{--this.toBeDownloaded,w!=null&&typeof w=="function"&&w(P)};++this.toBeDownloaded,P.load(N,T,F,m,B),P.setAnatomicalId(O),P.setRenderOrder(S),L.addZincObject(P)};this.loadGlyphsetURL=(L,T,U,w,C,E)=>{(E&&E.isInline?E.isInline:!1)?a(L,U,w,C,E)(T):i.load(T,a(L,U,w,C,E),this.onProgress(T),this.onError(C),E.loaderOptions)};const h=(L,T,U,w,C,E,N)=>(m,O)=>{const B=new Ee;let S=new M.PointsMaterial({alphaTest:.5,size:10,sizeAttenuation:!1});O&&O[0]&&(1>O[0].opacity&&(S.transparent=!0),S.opacity=O[0].opacity,S.color=O[0].color,S.morphTargets=T,S.vertexColors=O[0].vertexColors);let P={};P.localTimeEnabled=T,P.localMorphColour=U,B&&(B.createMesh(m,S,P),B.setName(w),B.setAnatomicalId(C),L.addZincObject(B),B.setDuration(e.getDuration()),B.setRenderOrder(E)),m.dispose(),--this.toBeDownloaded,N!=null&&typeof N=="function"&&N(B)};this.loadSTL=(L,T,U,w)=>{this.toBeDownloaded+=1;const C=Pe.defaultMaterialColor,E=Pe.defaultOpacity,N=new Bi;N.crossOrigin="Anonymous",N.load(T,u(L,C,E,!1,!1,U,void 0,void 0,void 0,w))},this.loadOBJ=(L,T,U,w)=>{this.toBeDownloaded+=1;const C=Pe.defaultMaterialColor,E=Pe.defaultOpacity,N=new Oi;N.crossOrigin="Anonymous",N.load(T,u(L,C,E,!1,!1,U,void 0,void 0,void 0,w))};const f=(L,T,U,w,C,E,N)=>{this.toBeDownloaded+=1;const m=Pe.defaultMaterialColor,O=Pe.defaultOpacity;let B=0,S=N&&N.isInline?N.isInline:!1,P=N&&N.fileFormat?N.fileFormat:void 0,F=N&&N.anatomicalId?N.anatomicalId:void 0,j=N&&"renderOrder"in N?N.renderOrder:void 0;U!=null&&(B=!!U);let J=0;w!=null&&(J=!!w);let X=i;if(P!==void 0){if(P=="STL")X=new Bi;else if(P=="OBJ"){X=new Oi,X.crossOrigin="Anonymous",X.load(T,objloader(L,m,O,B,J,C,F,E),this.onProgress(T),this.onError,N.loaderOptions);return}}if(S){const Y=i.parse(T);u(L,m,O,B,J,C,F,j,N,E)(Y.geometry,Y.materials)}else X.crossOrigin="Anonymous",i.load(T,u(L,m,O,B,J,C,F,j,N,E),this.onProgress(T),this.onError(E),N.loaderOptions)},c=function(L,T,U){let w=0;return C=>{if(w=w+1,C&&T!=null&&typeof T=="function"&&T(C),w==L&&(t===!1&&e.viewAll(),U!=null&&typeof U=="function")){U();let E=e.getZincCameraControls();E&&E.calculateMaxAllowedDistance(e)}}};this.loadPointsetURL=(L,T,U,w,C,E,N)=>{let m=0;this.toBeDownloaded+=1,U!=null&&(m=!!U);let O=0;w!=null&&(O=!!w);let B=N&&N.isInline?N.isInline:!1,S=N&&N.anatomicalId?N.anatomicalId:void 0,P=N&&"renderOrder"in N?N.renderOrder:void 0;if(B){const F=i.parse(T);h(L,m,O,C,S,P,E)(F.geometry,F.materials)}else i.load(T,h(L,m,O,C,S,P,E),this.onProgress(T),this.onError(E),N.loaderOptions)};const l=(L,T,U,w,C,E)=>{let N=E&&E.isInline?E.isInline:void 0,m=E&&E.anatomicalId?E.anatomicalId:void 0,O=E&&"renderOrder"in E?E.renderOrder:void 0,B;if(U){if(T&&U.images&&U.images.source){const S=U.images.source;for(let P=0;P<S.length;P++){const F=Ge(S[P],T);U.images.source[P]=F}}if(U.type==="slides"&&(B=new qe),B){B.groupName=w;let S=()=>{L.addZincObject(B),--this.toBeDownloaded,C!=null&&typeof C=="function"&&C(B)};++this.toBeDownloaded,B.load(U,S,N),B.setAnatomicalId(m),B.setRenderOrder(O)}}};this.loadTextureURL=(L,T,U,w,C)=>{if(C&&C.isInline?C.isInline:!1)l(L,void 0,T,U,w,C);else{const N=T;fetch(N).then(m=>{if(!m.ok)throw new Error(`HTTP error! status: ${m.status}`);const O=m.url||new URL(N).href;return m.json().then(B=>({textureData:B,referenceURL:O}))}).then(({textureData:m,referenceURL:O})=>{l(L,O,m,U,w,C)}).catch(m=>{console.error(`Fetch failed for texture URL: ${N}`,m)})}};const d=(L,T,U,w,C,E,N,m,O,B,S)=>{let P={};P.colour=U,P.opacity=w,P.localTimeEnabled=C,P.localMorphColour=E;const F=new Xe;if(F.createMesh(T,m,P),F.getMorph())return F.setName(O),F.setRenderOrder(B),F.setAnatomicalId(S),L&&L.addZincObject(F),F.setDuration(e.getDuration()),F.videoHandler&&e.setVideoHandler(F.videoHandler),F},u=(L,T,U,w,C,E,N,m,O,B)=>(S,P)=>{let F;P&&P[0]&&(F=P[0]);const j=d(L,S,T,U,w,C,void 0,F,E,m,N);if(O.lod&&O.lod.levels)for(const[J,X]of Object.entries(O.lod.levels))j.addLOD(i,J,X.URL,X.Index,O.lod.preload);--this.toBeDownloaded,S.dispose(),B!=null&&typeof B=="function"&&B(j)},p=L=>{const T=/P(?:(\d+)Y)?(?:(\d+)M)?(?:(\d+)W)?(?:(\d+)D)?(?:T(?:(\d+)H)?(?:(\d+)M)?(?:(\d+)S)?)?$/,[,U,w,C,E,N,m,O]=L.match(T);return{years:U,months:w,weeks:C,days:E,hours:N,mins:m,secs:O}};this.loadSettings=L=>{if(L){if(L.Duration){const T=p(L.Duration);e.setDurationFromObject(T)}if(L.OriginalDuration){const T=p(L.OriginalDuration);e.setOriginalDurationFromObject(T)}if(L.TimeStamps)for(const T in L.TimeStamps){const U=p(L.TimeStamps[T]);e.addMetadataTimeStamp(T,U)}}};const y=(L,T,U,w,C)=>{if(U){let E,N=!1;U.URL?(E=U.URL,T&&(E=Ge(E,T))):U.Inline&&(E=U.Inline.URL,N=!0);const m={};if(U.LOD&&U.LOD.Levels){m.preload=!!U.LOD.Preload,m.levels={};for(const[S,P]of Object.entries(U.LOD.Levels))m.levels[S]={},m.levels[S].URL=Ge(P.URL,T),m.levels[S].Index=P.Index}let O=U.GroupName;(O===void 0||O==="")&&(O="_Unnamed");let B={loaderOptions:{index:U.Index},isInline:N,fileFormat:U.FileFormat,anatomicalId:U.AnatomicalId,compression:U.compression,tubeLines:U.tubeLines,lod:m,renderOrder:w};switch(U.Type){case"Surfaces":f(L,E,U.MorphVertices,U.MorphColours,O,C,B);break;case"Glyph":let S;N?S=U.Inline.GlyphGeometriesURL:(S=U.GlyphGeometriesURL,S=Ge(U.GlyphGeometriesURL,T)),B.displayLabels=U.displayLabels?U.displayLabels:!0,B.loaderOptions.isGlyphsets=!0,this.loadGlyphsetURL(L,E,S,O,C,B);break;case"Points":this.loadPointsetURL(L,E,U.MorphVertices,U.MorphColours,O,C,B);break;case"Lines":this.loadLinesURL(L,E,U.MorphVertices,U.MorphColours,O,C,B);break;case"Texture":this.loadTextureURL(L,E,O,C,B);break}}},x=(L,T,U)=>{if(T){let w,C=!1;switch(T.URL?(w=T.URL,L&&(w=Ge(T.URL,L))):T.Inline&&(w=T.Inline.URL,C=!0),T.Type){case"View":C?(e.setupMultipleViews("default",{default:w}),t=!0,U!=null&&typeof U=="function"&&U()):this.loadViewURL(w,U);break;case"Settings":this.loadSettings(T);break}}};this.loadGLTF=(L,T,U,w,C)=>{new Rs().load(e,L,T,U,w,C)};let g=(L,T,U,w)=>{if(U.Primitives&&U.Primitives.forEach(C=>{let E=1;C.Order&&(E=C.Order),y(L,T,C,E,w)}),U.Transformation&&L.setTransformation(U.Transformation),U.Children)for(const[C,E]of Object.entries(U.Children)){const N=L.findOrCreateChildFromPath(C);N&&g(N,T,E,w)}},v=(L,T)=>{var N,m;let U=L;const w=(N=T==null?void 0:T.enabled)==null?void 0:N.include,C=(m=T==null?void 0:T.enabled)==null?void 0:m.exclude,E=T==null?void 0:T.tubeLines;return(w!=null&&w.length||C!=null&&C.length)&&(w&&(U=L.filter(O=>{if(O.Type==="View")return!0;for(let B=0;B<w.length;B++)if(Rt(O.RegionPath,O.GroupName,w[B]))return!0;return!1})),C&&(U=U.filter(O=>{if(O.Type==="View")return!0;for(let B=0;B<C.length;B++)if(Rt(O.RegionPath,O.GroupName,C[B]))return!1;return!0}))),E&&U.forEach(O=>{O.Type==="Lines"&&(O.tubeLines=!0)}),U},_=(L,T)=>Array.isArray(L)?v(L,T):L,I=(L,T)=>{if(Array.isArray(L)){let U=0;for(let w=0;w<L.length;w++)L[w].Type&&(T&&L[w].Type==="View"||L[w].Type==="Surfaces"||L[w].Type==="Glyph"||L[w].Type==="Points"||L[w].Type==="Lines"||L[w].Type==="Texture")&&U++;return U}return 0},k=L=>{let T=L.Primitives?I(L.Primitives,!1):0;return L.Children&&Object.values(L.Children).forEach(U=>{T+=k(U)}),T},V=L=>{if(Array.isArray(L))return I(L,!0);if(typeof L=="object"&&L!==null&&L.Version==="2.0")return k(L.Regions)},R=(L,T,U,w,C)=>{let E=L;U.RegionPath&&U.RegionPath!==""&&(E=L.findOrCreateChildFromPath(U.RegionPath)),y(E,T,U,w*2,C)},W=(L,T,U,w,C,E)=>{const N=_(T,E);let m=V(N),O=new c(m,w,C);for(let B=0;B<T.length;B++)x(U,N[B],O);for(let B=0;B<T.length;B++)R(L,U,N[B],B,O)},G=(L,T,U,w,C)=>{let E=V(T),N=new c(E,w,C);T.Settings&&this.loadSettings(T.Settings),T.Views&&n(U,T.Views),T.Regions&&g(L,U,T.Regions,N)};this.loadMetadataURL=(L,T,U,w,C)=>{const E=T;fetch(E).then(N=>{if(!N.ok)throw new Error(`HTTP error! status: ${N.status}`);const m=N.url||new URL(E).href;return N.json().then(O=>({metadata:O,referenceURL:m}))}).then(({metadata:N,referenceURL:m})=>{e.resetMetadata(),e.resetDuration(),t=!1,Array.isArray(N)?W(L,N,m,U,w,C):typeof N=="object"&&N!==null&&N.Version==="2.0"&&G(L,N,m,U,w)}).catch(N=>{console.error(`Fetch failed for URL: ${E}`,N)})}};let Qs=0;const $s=function(){return"sc"+Qs++},Ni=function(){return{Duration:"6 secs",OriginalDuration:"-",TimeStamps:{}}},Hs=6e3,Pt=function(r,e){const t=r;let s,i,n=new Js(this),o,a={},h=0,f={},c=0;const l=new M.Scene,d=new M.Scene,u=new bi(void 0,this);l.add(u.getGroup());const p=new M.Group;l.add(p),this.directionalLight=void 0,this.ambient=void 0,this.camera=void 0;let y=6e3,x;this.sceneName=void 0;let g=!1,v;this.autoClearFlag=!0,this.displayMarkers=!1,this.displayMinimap=!1,this.displayMiniAxes=!1,this.minimapScissor={x_offset:16,y_offset:16,width:128,height:128,align:"top-right",updateRequired:!0};let _={x:0,y:0},I=Ni(),k=new M.Vector2,V=[];this.forcePickableObjectsUpdate=!1,this.uuid=$s();let R=new di(this);R.disable(),l.add(R.group);let W={main:[],mini:[]};const G=new M.Vector3(0,0,0),L=()=>t?typeof t.clientWidth<"u"?t.clientWidth:t.width:0,T=()=>t?typeof t.clientHeight<"u"?t.clientHeight:t.height:0;this.getDownloadProgress=()=>n.getDownloadProgress(),this.onWindowResize=()=>{const m=T();this.camera.aspect=L()/m,this.camera.updateProjectionMatrix(),this.minimapScissor.updateRequired=!0,x.onResize(),x.calculateHeightPerPixelAtZeroDepth(m)},this.resetView=()=>{this.onWindowResize(),x.resetView()},this.changeZoomByScrollRateUnit=m=>{x.changeZoomByScrollRateUnit(m)},(()=>{this.camera=new M.PerspectiveCamera(40,L()/T(),0,10),this.ambient=new M.AmbientLight(16777215,.2),l.add(this.ambient),this.directionalLight=new M.DirectionalLight(16777215,.8),l.add(this.directionalLight),x=new oi(this.camera,e.domElement,e,this),x.setDirectionalLight(this.directionalLight),x.resetView(),o=new Ms(this)})(),this.loadView=m=>{const O=new We;return O.setFromObject(m),x.setCurrentCameraSettings(O),!0},this.setupMultipleViews=(m,O)=>{for(const[B,S]of Object.entries(O)){const P=new We;P.setFromObject(S),x.addViewport(B,P)}x.setDefaultViewport(m)},this.getBoundingBox=()=>u.getBoundingBox(!0),this.viewAllWithBoundingBox=m=>{if(m){const O=x.getViewportFromBoundingBox(m,1);x.setCurrentCameraSettings(O),x.calculateHeightPerPixelAtZeroDepth(T()),R.markerUpdateRequired=!0}},this.viewAll=()=>{const m=this.getBoundingBox();this.viewAllWithBoundingBox(m),R.markerUpdateRequired=!0},this.forEachGeometry=m=>{u.forEachGeometry(m,!0)},this.forEachGlyphset=m=>{u.forEachGlyphset(m,!0)},this.forEachPointset=m=>{u.forEachPointset(m,!0)},this.forEachLine=m=>{u.forEachLine(m,!0)},this.findGeometriesWithGroupName=m=>u.findGeometriesWithGroupName(m,!0),this.findPointsetsWithGroupName=m=>u.findPointsetsWithGroupName(m,!0),this.findGlyphsetsWithGroupName=m=>u.findGlyphsetsWithGroupName(m,!0),this.findLinesWithGroupName=m=>u.findLinesWithGroupName(m,!0),this.findObjectsWithGroupName=m=>u.findObjectsWithGroupName(m,!0),this.findObjectsWithAnatomicalId=m=>u.findObjectsWithAnatomicalId(m,!0),this.getBoundingBoxOfZincObjects=m=>{let O;for(let B=0;B<m.length;B++){let S=m[B].getBoundingBox();S&&(O?O.union(S):O=S)}return O},this.vectorToScreenXY=m=>{m.project(this.camera);let O=L(),B=T(),S=O/2,P=B/2;return m.x=m.x*S+S,m.y=-(m.y*P)+P,m},this.getObjectsScreenXY=m=>{if(m&&m.length>0){let O=this.getBoundingBoxOfZincObjects(m);const B=new M.Vector3;return O.getCenter(B),this.vectorToScreenXY(B)}},this.getNamedObjectsScreenXY=m=>{let O=this.findObjectsWithGroupName(m);return this.getObjectsScreenXY(O)},this.addZincObject=m=>{m&&(u.addZincObject(m),x&&x.calculateMaxAllowedDistance(this))},this.loadGlyphsetURL=(m,O,B,S)=>{n.loadGlyphsetURL(u,m,O,B,S)},this.loadPointsetURL=(m,O,B,S,P)=>{n.loadPointsetURL(u,m,O,B,S,P)},this.loadLinesURL=(m,O,B,S,P)=>{n.loadLinesURL(u,m,O,B,S,P)},this.loadSTL=(m,O,B)=>{n.loadSTL(u,m,O,B)},this.loadOBJ=(m,O,B)=>{n.loadOBJ(u,m,O,B)},this.loadMetadataURL=(m,O,B,S)=>{n.loadMetadataURL(u,m,O,B,S)},this.loadModelsURL=(m,O,B,S,P,F)=>{n.loadModelsURL(u.urls,O,B,S,P,F)},this.loadViewURL=m=>{n.loadViewURL(m)},this.loadFromViewURL=(m,O)=>{n.loadFromViewURL(m,O)},this.loadGLTF=(m,O,B,S)=>{n.loadGLTF(u,m,O,B,S)},this.updateDirectionalLight=()=>{x.updateDirectionalLight()},this.addObject=m=>{l.add(m)},this.removeObject=m=>{l.remove(m)},this.getCurrentTime=()=>{if(i!=null)return i.getCurrentTime(y);const m=u.getCurrentTime();return m!==-1?m:0},this.setMorphsTime=m=>{i!=null&&i.setMorphTime(m,y),u.setMorphTime(m,!0)},this.isTimeVarying=()=>i&&i.video&&!i.video.error?!0:u.isTimeVarying(),this.renderGeometries=(m,O,B)=>{let S={};if(S.camera=x,S.displayMarkers=this.displayMarkers,S.markerCluster=R,S.markersList=R.markers,S.ndcToBeUpdated=!1,B&&(S.markerCluster.markerUpdateRequired=!0),i)if(i.isReadyToPlay()){B?i.video.play():i.video.pause();const P=i.video.currentTime/i.getVideoDuration()*y;n.toBeDownloaded==0?(x.setTime(P),S.ndcToBeUpdated=x.update(0),S.ndcToBeUpdated&&x.calculateHeightPerPixelAtZeroDepth(T()),u.setMorphTime(P,!0),u.renderGeometries(0,0,B,x,S,!0)):x.update(0)}else myPlayRate=0;else n.toBeDownloaded==0?(S.ndcToBeUpdated=x.update(O),S.ndcToBeUpdated&&x.calculateHeightPerPixelAtZeroDepth(T()),u.renderGeometries(m,O,B,x,S,!0)):x.update(0)},this.getThreeJSScene=()=>l,this.setVideoHandler=m=>{i||(i=m)},this.setAdditionalScenesGroup=m=>{l.add(m)};let w=(m,O,B,S,P,F,j)=>{let J=0,X=0;return m.includes("top")?X=j-P-B:m.includes("bottom")?X=B:X=Math.floor((j-P)/2),m.includes("left")?J=O:m.includes("right")?J=F-O-S:J=Math.floor((F-S)/2),{x:J,y:X}};const C=m=>{(this.displayMinimap||this.displayMiniAxes)&&(m.setScissorTest(!0),m.getSize(k),this.minimapScissor.updateRequired&&(_=w(this.minimapScissor.align,this.minimapScissor.x_offset,this.minimapScissor.y_offset,this.minimapScissor.width,this.minimapScissor.height,k.x,k.y),this.minimapScissor.updateRequired=!1),m.setScissor(_.x,_.y,this.minimapScissor.width,this.minimapScissor.height),m.setViewport(_.x,_.y,this.minimapScissor.width,this.minimapScissor.height),o.updateCamera(),this.displayMiniAxes?m.render(d,o.camera):(l.add(o.mask),m.render(l,o.camera),l.remove(o.mask)),m.setScissorTest(!1),m.setViewport(0,0,k.x,k.y))};this.render=m=>{this.autoClearFlag&&m.clear(),g&&v?v.render(l,this.camera):(m.render(l,this.camera),C(m))},this.setInteractiveControlEnable=m=>{m==!0?x.enable():x.disable()},this.getZincCameraControls=()=>x,this.getThreeJSScene=()=>l,this.setDuration=m=>{u.setDuration(m),y=m,x.setPathDuration(m),n.duration=m},this.getDuration=()=>y,this.setStereoEffectEnable=m=>{m==!0&&(v||(v=new ui(e))),e.setSize(L(),T()),this.camera.updateProjectionMatrix(),g=m},this.objectIsInScene=m=>u.objectIsInRegion(m,!0),this.alignBoundingBoxToCameraView=(m,O)=>{if(m){m.getCenter(G);const B=this.getZincCameraControls().getCurrentViewport(),S=new M.Vector3(B.targetPosition[0],B.targetPosition[1],B.targetPosition[2]),P=new M.Vector3(B.eyePosition[0],B.eyePosition[1],B.eyePosition[2]),F=new M.Vector3,j=new M.Vector3;F.subVectors(S,P).normalize(),j.subVectors(S,G).normalize();const J=new M.Vector3;J.crossVectors(F,j);const X=F.angleTo(j);O>0?(this.getZincCameraControls().rotateCameraTransition(J,X,O),this.getZincCameraControls().enableCameraTransition()):this.getZincCameraControls().rotateAboutLookAtpoint(J,X),R.markerUpdateRequired=!0}},this.translateBoundingBoxToCameraView=(m,O,B)=>{if(m){const S=this.getZincCameraControls().getCurrentViewport(),P=this.getZincCameraControls().getViewportFromBoundingBox(m,O);B>0&&(this.getZincCameraControls().cameraTransition(S,P,B),this.getZincCameraControls().enableCameraTransition()),R.markerUpdateRequired=!0}},this.alignObjectToCameraView=(m,O)=>{if(this.objectIsInScene(m)){const B=m.getBoundingBox();this.alignBoundingBoxToCameraView(B,O)}},this.setCameraTargetToObject=m=>{if(this.objectIsInScene(m)){const O=m.getBoundingBox(),B=this.getZincCameraControls().getCurrentViewport();O.getCenter(G);const S=new M.Vector3(B.targetPosition[0],B.targetPosition[1],B.targetPosition[2]),P=new M.Vector3(B.eyePosition[0],B.eyePosition[1],B.eyePosition[2]),F=new M.Vector3,j=new M.Vector3;F.subVectors(P,S),j.addVectors(G,F),B.eyePosition[0]=j.x,B.eyePosition[1]=j.y,B.eyePosition[2]=j.z,B.targetPosition[0]=G.x,B.targetPosition[1]=G.y,B.targetPosition[2]=G.z,this.getZincCameraControls().setCurrentCameraSettings(B),R.markerUpdateRequired=!0}},this.isStereoEffectEnable=()=>g,this.removeZincObject=m=>{u.removeZincObject(m),x&&x.calculateMaxAllowedDistance(this),R.markerUpdateRequired=!0},this.updatePickableThreeJSObjects=()=>{V.length=0,R.isEnabled&&V.push(R.group),u.getPickableThreeJSObjects(V,!0),this.forcePickableObjectsUpdate=!1},this.getPickableThreeJSObjects=()=>((this.forcePickableObjectsUpdate||u.checkPickableUpdateRequred(!0))&&this.updatePickableThreeJSObjects(),V),this.getNormalisedMinimapCoordinates=(m,O)=>{if(this.displayMinimap){const B=new M.Vector2;m.getSize(B);let S=B.y-O.clientY;if(_.x+this.minimapScissor.width>O.clientX&&O.clientX>_.x&&_.y+this.minimapScissor.height>S&&S>_.y){let P=(O.clientX-_.x)/this.minimapScissor.width*2-1,F=(S-_.y)/this.minimapScissor.height*2-1;return{x:P,y:F}}}},this.getMinimapDiffFromNormalised=(m,O)=>{if(o)return o.getDiffFromNormalised(m,O)},this.isWebGL2=()=>e.isWebGL2(),this.clearAll=()=>{R.clear(),u.clear(!0),this.clearZincObjectAddedCallbacks(),this.clearZincObjectRemovedCallbacks(),n.toBeDwonloaded=0,x&&x.calculateMaxAllowedDistance(this),R.markerUpdateRequired=!0},this.addMetadataTimeStamp=(m,O)=>{I.TimeStamps[m]=N(O)},this.getMetadataTag=m=>I[m],this.getMetadata=()=>I,this.setMetadataTag=(m,O)=>{I[m]=O},this.removeMetadataTag=m=>{delete I[m]},this.resetMetadata=()=>{I=Ni()},this.resetDuration=()=>{this.setDuration(Hs)};const E=m=>[...m.years?[`${m.years}years`]:[],...m.months?[`${m.months}months`]:[],...m.weeks?[`${m.weeks}weeks`]:[],...m.days?[`${m.days}days`]:[],...m.hours?[`${m.hours}hours`]:[],...m.mins?[`${m.mins}mins`]:[],...m.secs?[`${m.secs}secs`]:[]].join(" "),N=m=>m.years?m.years*31536e6:0+m.months?m.months*2592e6:0+m.weeks?m.weeks*6048e5:0+m.days?m.days*864e5:0+m.hours?m.hours*36e5:0+m.mins?m.mins*6e4:0+m.secs?m.secs*1e3:0;this.setDurationFromObject=m=>{const O=E(m),B=N(m);this.setMetadataTag("Duration",O),this.setDuration(B)},this.setOriginalDurationFromObject=m=>{const O=E(m);this.setMetadataTag("OriginalDuration",O)},this.exportGLTF=m=>new Vs(this).exportGLTF(m),this.getRootRegion=()=>u,this.createLines=(m,O,B,S)=>{let P=u.findChildFromPath(m);return P===void 0&&(P=u.createChildFromPath(m)),P.createLines(O,B,S)},this.createPoints=(m,O,B,S,P)=>{let F=u.findChildFromPath(m);return F===void 0&&(F=u.createChildFromPath(m)),F.createPoints(O,B,S,P)},this.addZincObjectAddedCallbacks=m=>(h=h+1,a[h]=m,h),this.addZincObjectRemovedCallbacks=m=>(c=c+1,f[c]=m,c),this.removeZincObjectAddedCallbacks=m=>{m in h&&delete a[m]},this.removeZincObjectRemovedCallbacks=m=>{m in c&&delete f[m]},this.clearZincObjectAddedCallbacks=()=>{a={},h=0},this.clearZincObjectRemovedCallbacks=()=>{f={},c=0},this.triggerObjectAddedCallback=m=>{for(let O in a)a.hasOwnProperty(O)&&a[O](m)},this.triggerObjectRemovedCallback=m=>{for(let O in f)f.hasOwnProperty(O)&&f[O](m)},this.addTemporaryPoints=(m,O)=>{const B=pt(m.length,m);let S=new M.PointsMaterial({alphaTest:.5,size:15,color:O,sizeAttenuation:!1});const P=Vt();S.map=P;let F=new St(B,S);return p.add(F),F},this.addTemporaryLines=(m,O)=>{const B=pt(m.length,m),S=new M.LineBasicMaterial({color:O}),P=new it(B,S);return p.add(P),P},this.enableFrustumDisplay=()=>{this.camera&&!s&&(s=new M.CameraHelper(this.camera),l.add(s))},this.disableFrustumDisplay=()=>{s&&(l.remove(s),s.dispose(),s=void 0)},this.removeTemporaryPrimitive=m=>{p.remove(m),m.geometry.dispose(),m.material.dispose()},this.clearTemporaryPrimitives=()=>{let m=0;return p.children.forEach(B=>{B.geometry.dispose(),B.material.dispose(),m++}),p.clear(),m},this.addBoundingBoxPrimitive=(m,O,B,S,P,F=void 0)=>{let j=u.findChildFromPath(m);j===void 0&&(j=u.createChildFromPath(m));const J=F||this.getBoundingBox();G.set(0,0,0);const X=G.subVectors(J.max,J.min),Y=new M.BoxGeometry(X.x,X.y,X.z),re=j.createGeometryFromThreeJSGeometry(O,Y,B,S,P,1e4);return X.addVectors(J.min,J.max).multiplyScalar(.5),re.setPosition(X.x,X.y,X.z),re},this.addSlicesPrimitive=(m,O,B,S,P,F=void 0)=>{if(O&&O.length>=3&&B&&B.length>=3){let j=u.findChildFromPath(m);j===void 0&&(j=u.createChildFromPath(m));const J=F||this.getBoundingBox();G.set(0,0,0);const X=G.subVectors(J.max,J.min),Y=["x","y","z"],re=[];let oe=0;return Y.forEach(ee=>{let te;switch(ee){case"x":te=new M.PlaneGeometry(X.z,X.y),te.rotateY(Math.PI/2);break;case"y":te=new M.PlaneGeometry(X.x,X.z),te.rotateX(Math.PI/2);break;case"z":te=new M.PlaneGeometry(X.x,X.y);break}const de=j.createGeometryFromThreeJSGeometry(O[oe],te,B[oe],S,P,10001);re.push(de),oe++}),X.addVectors(J.min,J.max).multiplyScalar(.5),re.forEach(ee=>{ee.setPosition(X.x,X.y,X.z)}),re}},this.enableMarkerCluster=m=>{m?(R.markerUpdateRequired=!0,R.enable()):(R.markerUpdateRequired=!1,R.disable()),this.forcePickableObjectsUpdate=!0},this.destroyAxisDisplay=()=>{this.displayMiniAxes=!1,W.main&&(this.enableAxisDisplay(!1,!1),W.main.forEach(m=>{m.dispose&&m.dispose()})),W.mini&&(this.enableAxisDisplay(!1,!0),W.mini.forEach(m=>{m.dispose&&m.dispose()})),W={main:[],mini:[]}},this.createAxisDisplay=(m=!1)=>{this.destroyAxisDisplay();const O=[{name:"x",dir:new M.Vector3(1,0,0),colour:"red",hex:16733525},{name:"y",dir:new M.Vector3(0,1,0),colour:"green",hex:5635925},{name:"z",dir:new M.Vector3(0,0,1),colour:"blue",hex:5592575}],B=this.getBoundingBox(),S=B.min.distanceTo(B.max);let P=new M.Vector3(0,0,0);m&&P.copy(B.min),O.forEach(F=>{const j=new M.ArrowHelper(F.dir,P,S,F.hex);W.main.push(j);const J=new M.ArrowHelper(F.dir,B.getCenter(G),S/2,F.hex);W.mini.push(J);const X=mt(F.name,.036,F.colour,"Asap",120,700),Y=F.dir.clone().multiplyScalar(S).add(P);X.position.set(Y.x,Y.y,Y.z),W.main.push(X)})},this.enableAxisDisplay=(m,O=!1)=>{var B;O&&((B=W==null?void 0:W.mini)!=null&&B.length)?(this.displayMiniAxes=m,W.mini.forEach(S=>{m?d.add(S):d.remove(S)})):!O&&W.main&&W.main.forEach(S=>{m?l.add(S):l.remove(S)})}},en=function(r){let e=r,t,s;const i=new M.Clock(!1);this.playAnimation=!0;let n=1e3,o={},a=0,h={},f=0,c={},l=0,d={},u=0,p,y,x,g,v=[],_=[],I=new M.Group,k,V,R=!1,W=!1;this.getDrawingWidth=()=>e?e.clientWidth:k?typeof k.clientWidth<"u"?Math.round(k.clientWidth):Math.round(k.width):0,this.getDrawingHeight=()=>e?e.clientHeight:k?typeof k.clientHeight<"u"?Math.round(k.clientHeight):Math.round(k.height):0,this.onWindowResize=()=>{s.onWindowResize();const w=this.getDrawingWidth(),C=this.getDrawingHeight();if(t!=null){let E;e?(E=e.getBoundingClientRect(),t.setSize(w,C)):k&&(typeof k.getBoundingClientRect<"u"&&(E=k.getBoundingClientRect(),k.width=w,k.height=C),t.setSize(w,C,!1)),E&&(E.left,E.top);const N=new M.Vector2;t.getSize(N),N.x,N.y}},this.initialiseVisualisation=w=>{if(!W){if(w=w||{},w.antialias===void 0){let N=!1;try{/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)&&(N=!0)}catch{N=!1}N?w.antialias=!1:w.antialias=!0}w.canvas&&(e=void 0,k=w.canvas),t=new M.WebGLRenderer(w),e!==void 0&&e.appendChild(t.domElement),t.setClearColor(16777215,1),k&&k.style&&(k.style.height="100%",k.style.width="100%");const C=t.domElement;C.addEventListener("webglcontextlost",G,!1),C.addEventListener("webglcontextrestored",L,!1),t.autoClear=!1;const E=this.createScene("default");this.setCurrentScene(E),W=!0}};const G=w=>{w.preventDefault();for(let C of Object.keys(o))c.hasOwnProperty(C)&&c[C].call()},L=w=>{w.preventDefault();for(let C of Object.keys(o))d.hasOwnProperty(C)&&d[C].call()};this.getCurrentScene=()=>s,this.setCurrentScene=w=>{if(w){this.removeActiveScene(w);const C=s;s=w,C&&C.setInteractiveControlEnable(!1),s.setInteractiveControlEnable(!0),s.setAdditionalScenesGroup(I),this.onWindowResize()}},this.getSceneByName=w=>v[w],this.createScene=w=>{if(v[w]==null){let C;return k?C=new Pt(k,t):C=new Pt(e,t),v[w]=C,C.sceneName=w,C}},this.resetView=()=>{s.resetView()},this.viewAll=()=>{if(s){const w=s.getBoundingBox();if(w){for(let C=0;C<_.length;C++){const E=_[C].getBoundingBox();E&&w.union(E)}s.viewAllWithBoundingBox(w)}}},this.loadModelsURL=(w,C,E,N,m,O)=>{s.loadModelsURL(w,C,E,N,m,O)},this.loadViewURL=w=>{s.loadViewURL(w)},this.loadFromViewURL=(w,C)=>{s.loadFromViewURL(w,C)},this.updateDirectionalLight=()=>{s.updateDirectionalLight()};let T=()=>{R?(p=requestAnimationFrame(T),this.render()):(cancelAnimationFrame(p),p=void 0)};this.stopAnimate=()=>{R&&(i.stop(),R=!1)},this.animate=()=>{R||(i.start(),R=!0,T())},this.addContextLostCallbackFunction=w=>(l=l+1,c[l]=w,l),this.removeContextLostCallbackFunction=w=>{w in c&&delete c[w]},this.addContextRestoredCallbackFunction=w=>(u=u+1,d[u]=w,u),this.removeContextRestoredCallbackFunction=w=>{w in u&&delete u[w]},this.addPreRenderCallbackFunction=w=>(a=a+1,o[a]=w,a),this.removePreRenderCallbackFunction=w=>{w in o&&delete o[w]},this.addPostRenderCallbackFunction=w=>(f=f+1,h[f]=w,f),this.removePostRenderCallbackFunction=w=>{w in h&&delete h[w]},this.getPlayRate=()=>n,this.setPlayRate=w=>{n=w},this.getCurrentTime=()=>s.getCurrentTime(),this.setMorphsTime=w=>{s.setMorphsTime(w)},this.getZincGeometryByID=w=>s.getZincGeometryByID(w),this.addToScene=w=>{s.addObject(w)},this.addToOrthoScene=w=>{if(x==null&&(x=new M.Scene),y==null){const C=this.getDrawingWidth(),E=this.getDrawingHeight();y=new M.OrthographicCamera(-C/2,C/2,E/2,-E/2,1,10),y.position.z=10}x.add(w)};const U=w=>C=>{C.needsUpdate=!0;const E=new M.SpriteMaterial({map:C}),N=E.map.image.width,m=E.map.image.height;w.material=E,w.scale.set(N,m,1);const O=this.getDrawingWidth(),B=this.getDrawingHeight();w.position.set((O-N)/2,(-B+m)/2,1),this.addToOrthoScene(w)};this.addLogo=()=>{g=new M.Sprite,M.ImageUtils.loadTexture("images/abi_big_logo_transparent_small.png",void 0,U(g))},this.render=()=>{V||(e?e.clientWidth>0&&e.clientHeight>0&&(V=new ke.ResizeSensor(e,this.onWindowResize)):k&&k.width>0&&k.height>0&&(V=new ke.ResizeSensor(k,this.onWindowResize)));const w=i.getDelta();s.renderGeometries(n,w,this.playAnimation);for(let C=0;C<_.length;C++)_[C].renderGeometries(n,w,this.playAnimation);y!=null&&x!=null&&(t.clearDepth(),t.render(x,y));for(let C of Object.keys(o))o.hasOwnProperty(C)&&o[C].call();s.render(t);for(let C of Object.keys(h))h.hasOwnProperty(C)&&h[C].call()},this.forceContextLoss=()=>{t.forceContextLoss()},this.forceContextRestore=()=>{t.forceContextRestore()},this.getThreeJSRenderer=()=>t,this.isSceneActive=w=>{if(s===w)return!0;for(let C=0;C<_.length;C++)if(_[C]===w)return!0;return!1},this.addActiveScene=w=>{this.isSceneActive(w)||(_.push(w),I.add(w.getThreeJSScene()))},this.removeActiveScene=w=>{for(let C=0;C<_.length;C++)if(_[C]===w){_.splice(C,1),I.remove(w.getThreeJSScene());return}},this.clearAllActiveScene=()=>{for(let w=0;w<_.length;w++)I.remove(_[w].getThreeJSScene());_.splice(0,_.length)},this.dispose=()=>{R&&cancelAnimationFrame(p);for(const C in v)v.hasOwnProperty(C)&&v[C].clearAll();v=[],_=[],I=new M.Group,this.stopAnimate(),o={},a=0,h={},h=0,c={},l=0,d={},u=0,y=void 0,x=void 0,g=void 0;const w=this.createScene("default");this.setCurrentScene(w),V=void 0,t==null||t.dispose()},this.transitionScene=(w,C)=>{if(s){const E=s.getZincCameraControls(),N=w.getBoundingBox();if(N){const m=N.min.distanceTo(N.max)/2,O=(N.min.x+N.max.x)/2,B=(N.min.y+N.max.y)/2,S=(N.min.z+N.max.z)/2,F=E.getViewportFromCentreAndRadius(O,B,S,m,40,m*4),j=E.getCurrentViewport();E.cameraTransition(j,F,C),E.enableCameraTransition()}}},this.isWebGL2=()=>t?t.capabilities.isWebGL2:!1};class tn{constructor(e,t,s,i){D(this,"esize");D(this,"ecode");D(this,"edata");D(this,"littleEndian");if(e%16!=0)throw new Error("This does not appear to be a NIFTI extension");this.esize=e,this.ecode=t,this.edata=s,this.littleEndian=i}toArrayBuffer(){let e=new Uint8Array(this.esize),t=new Uint8Array(this.edata);e.set(t,8);let s=new DataView(e.buffer);return s.setInt32(0,this.esize,this.littleEndian),s.setInt32(4,this.ecode,this.littleEndian),e.buffer}}const we=class we{static getStringAt(e,t,s){var i="",n,o;for(n=t;n<s;n+=1)o=e.getUint8(n),o!==0&&(i+=String.fromCharCode(o));return i}static getIntAt(e,t,s){return e.getInt32(t,s)}static getFloatAt(e,t,s){return e.getFloat32(t,s)}static getDoubleAt(e,t,s){return e.getFloat64(t,s)}static getInt64At(e,t,s){const i=e.getUint32(t,s),n=e.getInt32(t+4,s);let o;return s?o=n*2**32+i:o=i*2**32+n,n<0&&(o+=-1*2**32*2**32),o}static getUint64At(e,t,s){const i=e.getUint32(t+(s?0:4),s),n=e.getUint32(t+(s?4:0),s);return s?n*2**32+i:i*2**32+n}static getExtensionsAt(e,t,s,i){let n=[],o=t;for(;o<i;){let a=s,h=we.getIntAt(e,o,s);if(!h)break;if(h+o>i&&(a=!a,h=we.getIntAt(e,o,a),h+o>i))throw new Error("This does not appear to be a valid NIFTI extension");if(h%16!=0)throw new Error("This does not appear to be a NIFTI extension");let f=we.getIntAt(e,o+4,a),c=e.buffer.slice(o+8,o+h),l=new tn(h,f,c,a);n.push(l),o+=h}return n}static toArrayBuffer(e){var t,s,i;for(t=new ArrayBuffer(e.length),s=new Uint8Array(t),i=0;i<e.length;i+=1)s[i]=e[i];return t}static isString(e){return typeof e=="string"||e instanceof String}static formatNumber(e,t=void 0){let s;return we.isString(e)?s=Number(e):s=e,t?s=s.toPrecision(5):s=s.toPrecision(7),parseFloat(s)}static makeCRCTable(){let e,t=[];for(var s=0;s<256;s++){e=s;for(var i=0;i<8;i++)e=e&1?3988292384^e>>>1:e>>>1;t[s]=e}return t}static crc32(e){we.crcTable||(we.crcTable=we.makeCRCTable());const t=we.crcTable;let s=-1;for(var i=0;i<e.byteLength;i++)s=s>>>8^t[(s^e.getUint8(i))&255];return(s^-1)>>>0}};D(we,"crcTable",null),D(we,"GUNZIP_MAGIC_COOKIE1",31),D(we,"GUNZIP_MAGIC_COOKIE2",139),D(we,"getByteAt",function(e,t){return e.getUint8(t)}),D(we,"getShortAt",function(e,t,s){return e.getInt16(t,s)});let q=we;const K=class K{constructor(){D(this,"littleEndian",!1);D(this,"dim_info",0);D(this,"dims",[]);D(this,"intent_p1",0);D(this,"intent_p2",0);D(this,"intent_p3",0);D(this,"intent_code",0);D(this,"datatypeCode",0);D(this,"numBitsPerVoxel",0);D(this,"slice_start",0);D(this,"slice_end",0);D(this,"slice_code",0);D(this,"pixDims",[]);D(this,"vox_offset",0);D(this,"scl_slope",1);D(this,"scl_inter",0);D(this,"xyzt_units",0);D(this,"cal_max",0);D(this,"cal_min",0);D(this,"slice_duration",0);D(this,"toffset",0);D(this,"description","");D(this,"aux_file","");D(this,"intent_name","");D(this,"qform_code",0);D(this,"sform_code",0);D(this,"quatern_a",0);D(this,"quatern_b",0);D(this,"quatern_c",0);D(this,"quatern_d",0);D(this,"qoffset_x",0);D(this,"qoffset_y",0);D(this,"qoffset_z",0);D(this,"affine",[[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1]]);D(this,"qfac",1);D(this,"quatern_R");D(this,"magic","0");D(this,"isHDR",!1);D(this,"extensionFlag",[0,0,0,0]);D(this,"extensionSize",0);D(this,"extensionCode",0);D(this,"extensions",[]);D(this,"getDatatypeCodeString",function(e){return e===K.TYPE_UINT8?"1-Byte Unsigned Integer":e===K.TYPE_INT16?"2-Byte Signed Integer":e===K.TYPE_INT32?"4-Byte Signed Integer":e===K.TYPE_FLOAT32?"4-Byte Float":e===K.TYPE_FLOAT64?"8-Byte Float":e===K.TYPE_RGB24?"RGB":e===K.TYPE_INT8?"1-Byte Signed Integer":e===K.TYPE_UINT16?"2-Byte Unsigned Integer":e===K.TYPE_UINT32?"4-Byte Unsigned Integer":e===K.TYPE_INT64?"8-Byte Signed Integer":e===K.TYPE_UINT64?"8-Byte Unsigned Integer":"Unknown"});D(this,"getTransformCodeString",function(e){return e===K.XFORM_SCANNER_ANAT?"Scanner":e===K.XFORM_ALIGNED_ANAT?"Aligned":e===K.XFORM_TALAIRACH?"Talairach":e===K.XFORM_MNI_152?"MNI":"Unknown"});D(this,"getUnitsCodeString",function(e){return e===K.UNITS_METER?"Meters":e===K.UNITS_MM?"Millimeters":e===K.UNITS_MICRON?"Microns":e===K.UNITS_SEC?"Seconds":e===K.UNITS_MSEC?"Milliseconds":e===K.UNITS_USEC?"Microseconds":e===K.UNITS_HZ?"Hz":e===K.UNITS_PPM?"PPM":e===K.UNITS_RADS?"Rads":"Unknown"});D(this,"nifti_mat33_mul",function(e,t){var s=[[0,0,0],[0,0,0],[0,0,0]],i,n;for(i=0;i<3;i+=1)for(n=0;n<3;n+=1)s[i][n]=e[i][0]*t[0][n]+e[i][1]*t[1][n]+e[i][2]*t[2][n];return s});D(this,"nifti_mat33_determ",function(e){var t,s,i,n,o,a,h,f,c;return t=e[0][0],s=e[0][1],i=e[0][2],n=e[1][0],o=e[1][1],a=e[1][2],h=e[2][0],f=e[2][1],c=e[2][2],t*o*c-t*f*a-n*s*c+n*f*i+h*s*a-h*o*i})}readHeader(e){var t=new DataView(e),s=q.getIntAt(t,0,this.littleEndian),i,n,o,a;if(s!==K.MAGIC_COOKIE&&(this.littleEndian=!0,s=q.getIntAt(t,0,this.littleEndian)),s!==K.MAGIC_COOKIE)throw new Error("This does not appear to be a NIFTI file!");for(this.dim_info=q.getByteAt(t,39),i=0;i<8;i+=1)a=40+i*2,this.dims[i]=q.getShortAt(t,a,this.littleEndian);for(this.intent_p1=q.getFloatAt(t,56,this.littleEndian),this.intent_p2=q.getFloatAt(t,60,this.littleEndian),this.intent_p3=q.getFloatAt(t,64,this.littleEndian),this.intent_code=q.getShortAt(t,68,this.littleEndian),this.datatypeCode=q.getShortAt(t,70,this.littleEndian),this.numBitsPerVoxel=q.getShortAt(t,72,this.littleEndian),this.slice_start=q.getShortAt(t,74,this.littleEndian),i=0;i<8;i+=1)a=76+i*4,this.pixDims[i]=q.getFloatAt(t,a,this.littleEndian);if(this.vox_offset=q.getFloatAt(t,108,this.littleEndian),this.scl_slope=q.getFloatAt(t,112,this.littleEndian),this.scl_inter=q.getFloatAt(t,116,this.littleEndian),this.slice_end=q.getShortAt(t,120,this.littleEndian),this.slice_code=q.getByteAt(t,122),this.xyzt_units=q.getByteAt(t,123),this.cal_max=q.getFloatAt(t,124,this.littleEndian),this.cal_min=q.getFloatAt(t,128,this.littleEndian),this.slice_duration=q.getFloatAt(t,132,this.littleEndian),this.toffset=q.getFloatAt(t,136,this.littleEndian),this.description=q.getStringAt(t,148,228),this.aux_file=q.getStringAt(t,228,252),this.qform_code=q.getShortAt(t,252,this.littleEndian),this.sform_code=q.getShortAt(t,254,this.littleEndian),this.quatern_b=q.getFloatAt(t,256,this.littleEndian),this.quatern_c=q.getFloatAt(t,260,this.littleEndian),this.quatern_d=q.getFloatAt(t,264,this.littleEndian),this.quatern_a=Math.sqrt(1-(Math.pow(this.quatern_b,2)+Math.pow(this.quatern_c,2)+Math.pow(this.quatern_d,2))),this.qoffset_x=q.getFloatAt(t,268,this.littleEndian),this.qoffset_y=q.getFloatAt(t,272,this.littleEndian),this.qoffset_z=q.getFloatAt(t,276,this.littleEndian),this.qform_code<1&&this.sform_code<1&&(this.affine[0][0]=this.pixDims[1],this.affine[1][1]=this.pixDims[2],this.affine[2][2]=this.pixDims[3]),this.qform_code>0&&this.sform_code<this.qform_code){const h=this.quatern_a,f=this.quatern_b,c=this.quatern_c,l=this.quatern_d;for(this.qfac=this.pixDims[0]===0?1:this.pixDims[0],this.quatern_R=[[h*h+f*f-c*c-l*l,2*f*c-2*h*l,2*f*l+2*h*c],[2*f*c+2*h*l,h*h+c*c-f*f-l*l,2*c*l-2*h*f],[2*f*l-2*h*c,2*c*l+2*h*f,h*h+l*l-c*c-f*f]],n=0;n<3;n+=1)for(o=0;o<3;o+=1)this.affine[n][o]=this.quatern_R[n][o]*this.pixDims[o+1],o===2&&(this.affine[n][o]*=this.qfac);this.affine[0][3]=this.qoffset_x,this.affine[1][3]=this.qoffset_y,this.affine[2][3]=this.qoffset_z}else if(this.sform_code>0)for(n=0;n<3;n+=1)for(o=0;o<4;o+=1)a=280+(n*4+o)*4,this.affine[n][o]=q.getFloatAt(t,a,this.littleEndian);if(this.affine[3][0]=0,this.affine[3][1]=0,this.affine[3][2]=0,this.affine[3][3]=1,this.intent_name=q.getStringAt(t,328,344),this.magic=q.getStringAt(t,344,348),this.isHDR=this.magic===String.fromCharCode.apply(null,K.MAGIC_NUMBER2),t.byteLength>K.MAGIC_COOKIE){this.extensionFlag[0]=q.getByteAt(t,348),this.extensionFlag[1]=q.getByteAt(t,349),this.extensionFlag[2]=q.getByteAt(t,350),this.extensionFlag[3]=q.getByteAt(t,351);let h=!0;!this.isHDR&&this.vox_offset<=352&&(h=!1),t.byteLength<=368&&(h=!1),h&&this.extensionFlag[0]&&(this.extensions=q.getExtensionsAt(t,this.getExtensionLocation(),this.littleEndian,this.vox_offset),this.extensionSize=this.extensions[0].esize,this.extensionCode=this.extensions[0].ecode)}}toFormattedString(){var e=q.formatNumber,t="";return t+="Dim Info = "+this.dim_info+`
292
- `,t+="Image Dimensions (1-8): "+this.dims[0]+", "+this.dims[1]+", "+this.dims[2]+", "+this.dims[3]+", "+this.dims[4]+", "+this.dims[5]+", "+this.dims[6]+", "+this.dims[7]+`
293
- `,t+="Intent Parameters (1-3): "+this.intent_p1+", "+this.intent_p2+", "+this.intent_p3+`
294
- `,t+="Intent Code = "+this.intent_code+`
295
- `,t+="Datatype = "+this.datatypeCode+" ("+this.getDatatypeCodeString(this.datatypeCode)+`)
296
- `,t+="Bits Per Voxel = "+this.numBitsPerVoxel+`
297
- `,t+="Slice Start = "+this.slice_start+`
298
- `,t+="Voxel Dimensions (1-8): "+e(this.pixDims[0])+", "+e(this.pixDims[1])+", "+e(this.pixDims[2])+", "+e(this.pixDims[3])+", "+e(this.pixDims[4])+", "+e(this.pixDims[5])+", "+e(this.pixDims[6])+", "+e(this.pixDims[7])+`
299
- `,t+="Image Offset = "+this.vox_offset+`
300
- `,t+="Data Scale: Slope = "+e(this.scl_slope)+" Intercept = "+e(this.scl_inter)+`
301
- `,t+="Slice End = "+this.slice_end+`
302
- `,t+="Slice Code = "+this.slice_code+`
303
- `,t+="Units Code = "+this.xyzt_units+" ("+this.getUnitsCodeString(K.SPATIAL_UNITS_MASK&this.xyzt_units)+", "+this.getUnitsCodeString(K.TEMPORAL_UNITS_MASK&this.xyzt_units)+`)
304
- `,t+="Display Range: Max = "+e(this.cal_max)+" Min = "+e(this.cal_min)+`
305
- `,t+="Slice Duration = "+this.slice_duration+`
306
- `,t+="Time Axis Shift = "+this.toffset+`
307
- `,t+='Description: "'+this.description+`"
308
- `,t+='Auxiliary File: "'+this.aux_file+`"
309
- `,t+="Q-Form Code = "+this.qform_code+" ("+this.getTransformCodeString(this.qform_code)+`)
310
- `,t+="S-Form Code = "+this.sform_code+" ("+this.getTransformCodeString(this.sform_code)+`)
311
- `,t+="Quaternion Parameters: b = "+e(this.quatern_b)+" c = "+e(this.quatern_c)+" d = "+e(this.quatern_d)+`
312
- `,t+="Quaternion Offsets: x = "+this.qoffset_x+" y = "+this.qoffset_y+" z = "+this.qoffset_z+`
313
- `,t+="S-Form Parameters X: "+e(this.affine[0][0])+", "+e(this.affine[0][1])+", "+e(this.affine[0][2])+", "+e(this.affine[0][3])+`
314
- `,t+="S-Form Parameters Y: "+e(this.affine[1][0])+", "+e(this.affine[1][1])+", "+e(this.affine[1][2])+", "+e(this.affine[1][3])+`
315
- `,t+="S-Form Parameters Z: "+e(this.affine[2][0])+", "+e(this.affine[2][1])+", "+e(this.affine[2][2])+", "+e(this.affine[2][3])+`
316
- `,t+='Intent Name: "'+this.intent_name+`"
317
- `,this.extensionFlag[0]&&(t+="Extension: Size = "+this.extensionSize+" Code = "+this.extensionCode+`
318
- `),t}getQformMat(){return this.convertNiftiQFormToNiftiSForm(this.quatern_b,this.quatern_c,this.quatern_d,this.qoffset_x,this.qoffset_y,this.qoffset_z,this.pixDims[1],this.pixDims[2],this.pixDims[3],this.pixDims[0])}convertNiftiQFormToNiftiSForm(e,t,s,i,n,o,a,h,f,c){var l=[[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0]],d,u=e,p=t,y=s,x,g,v;return l[3][0]=l[3][1]=l[3][2]=0,l[3][3]=1,d=1-(u*u+p*p+y*y),d<1e-7?(d=1/Math.sqrt(u*u+p*p+y*y),u*=d,p*=d,y*=d,d=0):d=Math.sqrt(d),x=a>0?a:1,g=h>0?h:1,v=f>0?f:1,c<0&&(v=-v),l[0][0]=(d*d+u*u-p*p-y*y)*x,l[0][1]=2*(u*p-d*y)*g,l[0][2]=2*(u*y+d*p)*v,l[1][0]=2*(u*p+d*y)*x,l[1][1]=(d*d+p*p-u*u-y*y)*g,l[1][2]=2*(p*y-d*u)*v,l[2][0]=2*(u*y-d*p)*x,l[2][1]=2*(p*y+d*u)*g,l[2][2]=(d*d+y*y-p*p-u*u)*v,l[0][3]=i,l[1][3]=n,l[2][3]=o,l}convertNiftiSFormToNEMA(e){var t,s,i,n,o,a,h,f,c,l,d,u,p,y,x,g,v,_,I,k,V,R,W,G,L,T,U,w,C,E,N,m,O,B;if(x=0,U=[[0,0,0],[0,0,0],[0,0,0]],w=[[0,0,0],[0,0,0],[0,0,0]],t=e[0][0],s=e[0][1],i=e[0][2],n=e[1][0],o=e[1][1],a=e[1][2],h=e[2][0],f=e[2][1],c=e[2][2],l=Math.sqrt(t*t+n*n+h*h),l===0||(t/=l,n/=l,h/=l,l=Math.sqrt(s*s+o*o+f*f),l===0))return null;if(s/=l,o/=l,f/=l,l=t*s+n*o+h*f,Math.abs(l)>1e-4){if(s-=l*t,o-=l*n,f-=l*h,l=Math.sqrt(s*s+o*o+f*f),l===0)return null;s/=l,o/=l,f/=l}if(l=Math.sqrt(i*i+a*a+c*c),l===0?(i=n*f-h*o,a=h*s-f*t,c=t*o-n*s):(i/=l,a/=l,c/=l),l=t*i+n*a+h*c,Math.abs(l)>1e-4){if(i-=l*t,a-=l*n,c-=l*h,l=Math.sqrt(i*i+a*a+c*c),l===0)return null;i/=l,a/=l,c/=l}if(l=s*i+o*a+f*c,Math.abs(l)>1e-4){if(i-=l*s,a-=l*o,c-=l*f,l=Math.sqrt(i*i+a*a+c*c),l===0)return null;i/=l,a/=l,c/=l}if(U[0][0]=t,U[0][1]=s,U[0][2]=i,U[1][0]=n,U[1][1]=o,U[1][2]=a,U[2][0]=h,U[2][1]=f,U[2][2]=c,d=this.nifti_mat33_determ(U),d===0)return null;for(T=-666,I=R=W=G=1,k=2,V=3,p=1;p<=3;p+=1)for(y=1;y<=3;y+=1)if(p!==y){for(x=1;x<=3;x+=1)if(!(p===x||y===x))for(w[0][0]=w[0][1]=w[0][2]=w[1][0]=w[1][1]=w[1][2]=w[2][0]=w[2][1]=w[2][2]=0,g=-1;g<=1;g+=2)for(v=-1;v<=1;v+=2)for(_=-1;_<=1;_+=2)w[0][p-1]=g,w[1][y-1]=v,w[2][x-1]=_,u=this.nifti_mat33_determ(w),u*d>0&&(L=this.nifti_mat33_mul(w,U),l=L[0][0]+L[1][1]+L[2][2],l>T&&(T=l,I=p,k=y,V=x,R=g,W=v,G=_))}switch(C=E=N=m=O=B="",I*R){case 1:C="X",m="+";break;case-1:C="X",m="-";break;case 2:C="Y",m="+";break;case-2:C="Y",m="-";break;case 3:C="Z",m="+";break;case-3:C="Z",m="-";break}switch(k*W){case 1:E="X",O="+";break;case-1:E="X",O="-";break;case 2:E="Y",O="+";break;case-2:E="Y",O="-";break;case 3:E="Z",O="+";break;case-3:E="Z",O="-";break}switch(V*G){case 1:N="X",B="+";break;case-1:N="X",B="-";break;case 2:N="Y",B="+";break;case-2:N="Y",B="-";break;case 3:N="Z",B="+";break;case-3:N="Z",B="-";break}return C+E+N+m+O+B}getExtensionLocation(){return K.MAGIC_COOKIE+4}getExtensionSize(e){return q.getIntAt(e,this.getExtensionLocation(),this.littleEndian)}getExtensionCode(e){return q.getIntAt(e,this.getExtensionLocation()+4,this.littleEndian)}addExtension(e,t=-1){t==-1?this.extensions.push(e):this.extensions.splice(t,0,e),this.vox_offset+=e.esize}removeExtension(e){let t=this.extensions[e];t&&(this.vox_offset-=t.esize),this.extensions.splice(e,1)}toArrayBuffer(e=!1){let i=352;if(e)for(let h of this.extensions)i+=h.esize;let n=new Uint8Array(i),o=new DataView(n.buffer);o.setInt32(0,348,this.littleEndian),o.setUint8(39,this.dim_info);for(let h=0;h<8;h++)o.setUint16(40+2*h,this.dims[h],this.littleEndian);o.setFloat32(56,this.intent_p1,this.littleEndian),o.setFloat32(60,this.intent_p2,this.littleEndian),o.setFloat32(64,this.intent_p3,this.littleEndian),o.setInt16(68,this.intent_code,this.littleEndian),o.setInt16(70,this.datatypeCode,this.littleEndian),o.setInt16(72,this.numBitsPerVoxel,this.littleEndian),o.setInt16(74,this.slice_start,this.littleEndian);for(let h=0;h<8;h++)o.setFloat32(76+4*h,this.pixDims[h],this.littleEndian);o.setFloat32(108,this.vox_offset,this.littleEndian),o.setFloat32(112,this.scl_slope,this.littleEndian),o.setFloat32(116,this.scl_inter,this.littleEndian),o.setInt16(120,this.slice_end,this.littleEndian),o.setUint8(122,this.slice_code),o.setUint8(123,this.xyzt_units),o.setFloat32(124,this.cal_max,this.littleEndian),o.setFloat32(128,this.cal_min,this.littleEndian),o.setFloat32(132,this.slice_duration,this.littleEndian),o.setFloat32(136,this.toffset,this.littleEndian),n.set(new TextEncoder().encode(this.description),148),n.set(new TextEncoder().encode(this.aux_file),228),o.setInt16(252,this.qform_code,this.littleEndian),o.setInt16(254,this.sform_code,this.littleEndian),o.setFloat32(256,this.quatern_b,this.littleEndian),o.setFloat32(260,this.quatern_c,this.littleEndian),o.setFloat32(264,this.quatern_d,this.littleEndian),o.setFloat32(268,this.qoffset_x,this.littleEndian),o.setFloat32(272,this.qoffset_y,this.littleEndian),o.setFloat32(276,this.qoffset_z,this.littleEndian);const a=this.affine.flat();for(let h=0;h<12;h++)o.setFloat32(280+4*h,a[h],this.littleEndian);if(n.set(new TextEncoder().encode(this.intent_name),328),n.set(new TextEncoder().encode(this.magic),344),e){n.set(Uint8Array.from([1,0,0,0]),348);let h=this.getExtensionLocation();for(const f of this.extensions)o.setInt32(h,f.esize,f.littleEndian),o.setInt32(h+4,f.ecode,f.littleEndian),n.set(new Uint8Array(f.edata),h+8),h+=f.esize}else n.set(new Uint8Array(4).fill(0),348);return n.buffer}};D(K,"TYPE_NONE",0),D(K,"TYPE_BINARY",1),D(K,"TYPE_UINT8",2),D(K,"TYPE_INT16",4),D(K,"TYPE_INT32",8),D(K,"TYPE_FLOAT32",16),D(K,"TYPE_COMPLEX64",32),D(K,"TYPE_FLOAT64",64),D(K,"TYPE_RGB24",128),D(K,"TYPE_INT8",256),D(K,"TYPE_UINT16",512),D(K,"TYPE_UINT32",768),D(K,"TYPE_INT64",1024),D(K,"TYPE_UINT64",1280),D(K,"TYPE_FLOAT128",1536),D(K,"TYPE_COMPLEX128",1792),D(K,"TYPE_COMPLEX256",2048),D(K,"XFORM_UNKNOWN",0),D(K,"XFORM_SCANNER_ANAT",1),D(K,"XFORM_ALIGNED_ANAT",2),D(K,"XFORM_TALAIRACH",3),D(K,"XFORM_MNI_152",4),D(K,"SPATIAL_UNITS_MASK",7),D(K,"TEMPORAL_UNITS_MASK",56),D(K,"UNITS_UNKNOWN",0),D(K,"UNITS_METER",1),D(K,"UNITS_MM",2),D(K,"UNITS_MICRON",3),D(K,"UNITS_SEC",8),D(K,"UNITS_MSEC",16),D(K,"UNITS_USEC",24),D(K,"UNITS_HZ",32),D(K,"UNITS_PPM",40),D(K,"UNITS_RADS",48),D(K,"MAGIC_COOKIE",348),D(K,"STANDARD_HEADER_SIZE",348),D(K,"MAGIC_NUMBER_LOCATION",344),D(K,"MAGIC_NUMBER",[110,43,49]),D(K,"MAGIC_NUMBER2",[110,105,49]),D(K,"EXTENSION_HEADER_SIZE",8);let ie=K;const Ne=class Ne{constructor(){D(this,"littleEndian",!1);D(this,"dim_info",0);D(this,"dims",[]);D(this,"intent_p1",0);D(this,"intent_p2",0);D(this,"intent_p3",0);D(this,"intent_code",0);D(this,"datatypeCode",0);D(this,"numBitsPerVoxel",0);D(this,"slice_start",0);D(this,"slice_end",0);D(this,"slice_code",0);D(this,"pixDims",[]);D(this,"vox_offset",0);D(this,"scl_slope",1);D(this,"scl_inter",0);D(this,"xyzt_units",0);D(this,"cal_max",0);D(this,"cal_min",0);D(this,"slice_duration",0);D(this,"toffset",0);D(this,"description","");D(this,"aux_file","");D(this,"intent_name","");D(this,"qform_code",0);D(this,"sform_code",0);D(this,"quatern_b",0);D(this,"quatern_c",0);D(this,"quatern_d",0);D(this,"qoffset_x",0);D(this,"qoffset_y",0);D(this,"qoffset_z",0);D(this,"affine",[[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1]]);D(this,"magic","0");D(this,"extensionFlag",[0,0,0,0]);D(this,"extensions",[]);D(this,"extensionSize",0);D(this,"extensionCode",0);D(this,"getExtensionLocation",function(){return Ne.MAGIC_COOKIE+4});D(this,"getExtensionSize",ie.prototype.getExtensionSize);D(this,"getExtensionCode",ie.prototype.getExtensionCode);D(this,"addExtension",ie.prototype.addExtension);D(this,"removeExtension",ie.prototype.removeExtension);D(this,"getDatatypeCodeString",ie.prototype.getDatatypeCodeString);D(this,"getTransformCodeString",ie.prototype.getTransformCodeString);D(this,"getUnitsCodeString",ie.prototype.getUnitsCodeString);D(this,"getQformMat",ie.prototype.getQformMat);D(this,"convertNiftiQFormToNiftiSForm",ie.prototype.convertNiftiQFormToNiftiSForm);D(this,"convertNiftiSFormToNEMA",ie.prototype.convertNiftiSFormToNEMA);D(this,"nifti_mat33_mul",ie.prototype.nifti_mat33_mul);D(this,"nifti_mat33_determ",ie.prototype.nifti_mat33_determ)}readHeader(e){var t=new DataView(e),s=q.getIntAt(t,0,this.littleEndian),i,n,o,a;if(s!==Ne.MAGIC_COOKIE&&(this.littleEndian=!0,s=q.getIntAt(t,0,this.littleEndian)),s!==Ne.MAGIC_COOKIE)throw new Error("This does not appear to be a NIFTI file!");for(this.magic=q.getStringAt(t,4,12),this.datatypeCode=q.getShortAt(t,12,this.littleEndian),this.numBitsPerVoxel=q.getShortAt(t,14,this.littleEndian),i=0;i<8;i+=1)a=16+i*8,this.dims[i]=q.getInt64At(t,a,this.littleEndian);for(this.intent_p1=q.getDoubleAt(t,80,this.littleEndian),this.intent_p2=q.getDoubleAt(t,88,this.littleEndian),this.intent_p3=q.getDoubleAt(t,96,this.littleEndian),i=0;i<8;i+=1)a=104+i*8,this.pixDims[i]=q.getDoubleAt(t,a,this.littleEndian);for(this.vox_offset=q.getInt64At(t,168,this.littleEndian),this.scl_slope=q.getDoubleAt(t,176,this.littleEndian),this.scl_inter=q.getDoubleAt(t,184,this.littleEndian),this.cal_max=q.getDoubleAt(t,192,this.littleEndian),this.cal_min=q.getDoubleAt(t,200,this.littleEndian),this.slice_duration=q.getDoubleAt(t,208,this.littleEndian),this.toffset=q.getDoubleAt(t,216,this.littleEndian),this.slice_start=q.getInt64At(t,224,this.littleEndian),this.slice_end=q.getInt64At(t,232,this.littleEndian),this.description=q.getStringAt(t,240,320),this.aux_file=q.getStringAt(t,320,344),this.qform_code=q.getIntAt(t,344,this.littleEndian),this.sform_code=q.getIntAt(t,348,this.littleEndian),this.quatern_b=q.getDoubleAt(t,352,this.littleEndian),this.quatern_c=q.getDoubleAt(t,360,this.littleEndian),this.quatern_d=q.getDoubleAt(t,368,this.littleEndian),this.qoffset_x=q.getDoubleAt(t,376,this.littleEndian),this.qoffset_y=q.getDoubleAt(t,384,this.littleEndian),this.qoffset_z=q.getDoubleAt(t,392,this.littleEndian),n=0;n<3;n+=1)for(o=0;o<4;o+=1)a=400+(n*4+o)*8,this.affine[n][o]=q.getDoubleAt(t,a,this.littleEndian);this.affine[3][0]=0,this.affine[3][1]=0,this.affine[3][2]=0,this.affine[3][3]=1,this.slice_code=q.getIntAt(t,496,this.littleEndian),this.xyzt_units=q.getIntAt(t,500,this.littleEndian),this.intent_code=q.getIntAt(t,504,this.littleEndian),this.intent_name=q.getStringAt(t,508,524),this.dim_info=q.getByteAt(t,524),t.byteLength>Ne.MAGIC_COOKIE&&(this.extensionFlag[0]=q.getByteAt(t,540),this.extensionFlag[1]=q.getByteAt(t,541),this.extensionFlag[2]=q.getByteAt(t,542),this.extensionFlag[3]=q.getByteAt(t,543),this.extensionFlag[0]&&(this.extensions=q.getExtensionsAt(t,this.getExtensionLocation(),this.littleEndian,this.vox_offset),this.extensionSize=this.extensions[0].esize,this.extensionCode=this.extensions[0].ecode))}toFormattedString(){var e=q.formatNumber,t="";return t+="Datatype = "+ +this.datatypeCode+" ("+this.getDatatypeCodeString(this.datatypeCode)+`)
319
- `,t+="Bits Per Voxel = = "+this.numBitsPerVoxel+`
320
- `,t+="Image Dimensions (1-8): "+this.dims[0]+", "+this.dims[1]+", "+this.dims[2]+", "+this.dims[3]+", "+this.dims[4]+", "+this.dims[5]+", "+this.dims[6]+", "+this.dims[7]+`
321
- `,t+="Intent Parameters (1-3): "+this.intent_p1+", "+this.intent_p2+", "+this.intent_p3+`
322
- `,t+="Voxel Dimensions (1-8): "+e(this.pixDims[0])+", "+e(this.pixDims[1])+", "+e(this.pixDims[2])+", "+e(this.pixDims[3])+", "+e(this.pixDims[4])+", "+e(this.pixDims[5])+", "+e(this.pixDims[6])+", "+e(this.pixDims[7])+`
323
- `,t+="Image Offset = "+this.vox_offset+`
324
- `,t+="Data Scale: Slope = "+e(this.scl_slope)+" Intercept = "+e(this.scl_inter)+`
325
- `,t+="Display Range: Max = "+e(this.cal_max)+" Min = "+e(this.cal_min)+`
326
- `,t+="Slice Duration = "+this.slice_duration+`
327
- `,t+="Time Axis Shift = "+this.toffset+`
328
- `,t+="Slice Start = "+this.slice_start+`
329
- `,t+="Slice End = "+this.slice_end+`
330
- `,t+='Description: "'+this.description+`"
331
- `,t+='Auxiliary File: "'+this.aux_file+`"
332
- `,t+="Q-Form Code = "+this.qform_code+" ("+this.getTransformCodeString(this.qform_code)+`)
333
- `,t+="S-Form Code = "+this.sform_code+" ("+this.getTransformCodeString(this.sform_code)+`)
334
- `,t+="Quaternion Parameters: b = "+e(this.quatern_b)+" c = "+e(this.quatern_c)+" d = "+e(this.quatern_d)+`
335
- `,t+="Quaternion Offsets: x = "+this.qoffset_x+" y = "+this.qoffset_y+" z = "+this.qoffset_z+`
336
- `,t+="S-Form Parameters X: "+e(this.affine[0][0])+", "+e(this.affine[0][1])+", "+e(this.affine[0][2])+", "+e(this.affine[0][3])+`
337
- `,t+="S-Form Parameters Y: "+e(this.affine[1][0])+", "+e(this.affine[1][1])+", "+e(this.affine[1][2])+", "+e(this.affine[1][3])+`
338
- `,t+="S-Form Parameters Z: "+e(this.affine[2][0])+", "+e(this.affine[2][1])+", "+e(this.affine[2][2])+", "+e(this.affine[2][3])+`
339
- `,t+="Slice Code = "+this.slice_code+`
340
- `,t+="Units Code = "+this.xyzt_units+" ("+this.getUnitsCodeString(ie.SPATIAL_UNITS_MASK&this.xyzt_units)+", "+this.getUnitsCodeString(ie.TEMPORAL_UNITS_MASK&this.xyzt_units)+`)
341
- `,t+="Intent Code = "+this.intent_code+`
342
- `,t+='Intent Name: "'+this.intent_name+`"
343
- `,t+="Dim Info = "+this.dim_info+`
344
- `,t}toArrayBuffer(e=!1){let i=544;if(e)for(let h of this.extensions)i+=h.esize;let n=new Uint8Array(i),o=new DataView(n.buffer);o.setInt32(0,540,this.littleEndian),n.set(new TextEncoder().encode(this.magic),4),o.setInt16(12,this.datatypeCode,this.littleEndian),o.setInt16(14,this.numBitsPerVoxel,this.littleEndian);for(let h=0;h<8;h++)o.setBigInt64(16+8*h,BigInt(this.dims[h]),this.littleEndian);o.setFloat64(80,this.intent_p1,this.littleEndian),o.setFloat64(88,this.intent_p2,this.littleEndian),o.setFloat64(96,this.intent_p3,this.littleEndian);for(let h=0;h<8;h++)o.setFloat64(104+8*h,this.pixDims[h],this.littleEndian);o.setBigInt64(168,BigInt(this.vox_offset),this.littleEndian),o.setFloat64(176,this.scl_slope,this.littleEndian),o.setFloat64(184,this.scl_inter,this.littleEndian),o.setFloat64(192,this.cal_max,this.littleEndian),o.setFloat64(200,this.cal_min,this.littleEndian),o.setFloat64(208,this.slice_duration,this.littleEndian),o.setFloat64(216,this.toffset,this.littleEndian),o.setBigInt64(224,BigInt(this.slice_start),this.littleEndian),o.setBigInt64(232,BigInt(this.slice_end),this.littleEndian),n.set(new TextEncoder().encode(this.description),240),n.set(new TextEncoder().encode(this.aux_file),320),o.setInt32(344,this.qform_code,this.littleEndian),o.setInt32(348,this.sform_code,this.littleEndian),o.setFloat64(352,this.quatern_b,this.littleEndian),o.setFloat64(360,this.quatern_c,this.littleEndian),o.setFloat64(368,this.quatern_d,this.littleEndian),o.setFloat64(376,this.qoffset_x,this.littleEndian),o.setFloat64(384,this.qoffset_y,this.littleEndian),o.setFloat64(392,this.qoffset_z,this.littleEndian);const a=this.affine.flat();for(let h=0;h<12;h++)o.setFloat64(400+8*h,a[h],this.littleEndian);if(o.setInt32(496,this.slice_code,this.littleEndian),o.setInt32(500,this.xyzt_units,this.littleEndian),o.setInt32(504,this.intent_code,this.littleEndian),n.set(new TextEncoder().encode(this.intent_name),508),o.setUint8(524,this.dim_info),e){n.set(Uint8Array.from([1,0,0,0]),540);let h=this.getExtensionLocation();for(const f of this.extensions)o.setInt32(h,f.esize,f.littleEndian),o.setInt32(h+4,f.ecode,f.littleEndian),n.set(new Uint8Array(f.edata),h+8),h+=f.esize}else n.set(new Uint8Array(4).fill(0),540);return n.buffer}};D(Ne,"MAGIC_COOKIE",540),D(Ne,"MAGIC_NUMBER_LOCATION",4),D(Ne,"MAGIC_NUMBER",[110,43,50,0,13,10,26,10]),D(Ne,"MAGIC_NUMBER2",[110,105,50,0,13,10,26,10]);let Ce=Ne;function Ii(r,e=!1){var t,s,i,n;return r.byteLength<ie.STANDARD_HEADER_SIZE?!1:(t=new DataView(r),t&&(s=t.getUint8(ie.MAGIC_NUMBER_LOCATION)),i=t.getUint8(ie.MAGIC_NUMBER_LOCATION+1),n=t.getUint8(ie.MAGIC_NUMBER_LOCATION+2),e&&s===ie.MAGIC_NUMBER2[0]&&i===ie.MAGIC_NUMBER2[1]&&n===ie.MAGIC_NUMBER2[2]?!0:s===ie.MAGIC_NUMBER[0]&&i===ie.MAGIC_NUMBER[1]&&n===ie.MAGIC_NUMBER[2])}function Pi(r,e=!1){var t,s,i,n;return r.byteLength<ie.STANDARD_HEADER_SIZE?!1:(t=new DataView(r),s=t.getUint8(Ce.MAGIC_NUMBER_LOCATION),i=t.getUint8(Ce.MAGIC_NUMBER_LOCATION+1),n=t.getUint8(Ce.MAGIC_NUMBER_LOCATION+2),e&&s===Ce.MAGIC_NUMBER2[0]&&i===Ce.MAGIC_NUMBER2[1]&&n===Ce.MAGIC_NUMBER2[2]?!0:s===Ce.MAGIC_NUMBER[0]&&i===Ce.MAGIC_NUMBER[1]&&n===Ce.MAGIC_NUMBER[2])}function sn(r,e=!1){return Ii(r,e)||Pi(r,e)}function Ei(r){var e,t,s;return!!(r&&(e=new DataView(r),t=e.getUint8(0),s=e.getUint8(1),t===q.GUNZIP_MAGIC_COOKIE1||s===q.GUNZIP_MAGIC_COOKIE2))}function Di(r){return Yi.decompressSync(new Uint8Array(r)).buffer}function nn(r,e=!1){let t=null;if(Ei(r)&&(r=Di(r)),Ii(r,e)?t=new ie:Pi(r,e)&&(t=new Ce),t)t.readHeader(r);else throw new Error("That file does not appear to be NIFTI!");return t}function rn(r,e){var t=r.vox_offset,s=1,i=1;r.dims[4]&&(s=r.dims[4]),r.dims[5]&&(i=r.dims[5]);var n=r.dims[1]*r.dims[2]*r.dims[3]*s*i*(r.numBitsPerVoxel/8);return e.slice(t,t+n)}const on={id:"mesh-location-orientation",locations:[{identifier:1,label:"original",orientation:[1,0,0,0,1,0,0,0,1],position:[0,0,0],scale:[1,1,1],flipY:!1,flipZ:!1,reference_point:"corner"}],settings:{slides:[{direction:"x",value:.5},{direction:"y",value:.5},{direction:"z",value:.5}]},type:"slides"},an={hideBlackPixel:!0,keepScalePosition:!0,filterByValue:!0,timeEnabled:!1};function ki(r){let e=Ei(r)?Di(r):r;if(sn(e)){let t=nn(e),s=rn(t,e);return{niftiHeader:t,niftiImage:s}}return e=void 0,{niftiHeader:void 0,niftiImage:void 0}}function Vi(r,e){let t;switch(r.datatypeCode){case ie.TYPE_UINT8:t=new Uint8Array(e);break;case ie.TYPE_INT8:t=new Int8Array(e);break;case ie.TYPE_UINT16:t=new Uint16Array(e);break;case ie.TYPE_INT16:t=new Int16Array(e);break;case ie.TYPE_UINT32:t=new Uint32Array(e);break;case ie.TYPE_INT32:t=new Int32Array(e);break;case ie.TYPE_FLOAT32:t=new Float32Array(e);break;case ie.TYPE_FLOAT64:t=new Float64Array(e);break;default:throw new Error("Unsupported NIfTI data type")}let s=1/0,i=-1/0;const n=t.length;for(let h=0;h<n;h++){let f=t[h];f<s&&(s=f),f>i&&(i=f)}const o=new Uint8Array(n),a=i-s;for(let h=0;h<n;h++){let c=(t[h]-s)/a;c=Math.max(0,Math.min(1,c)),o[h]=Math.round(c*255)}return o}function ln(r,e,t,s){if(r!=null&&r.dims&&r.dims[0]===3){const i=r.dims[1],n=r.dims[2],o=r.dims[3];let a=!1;(r.intent_code===1007||r.intent_code===1008||r.datatypeCode===128||r.datatypeCode===2304)&&(a=!0);const h=Vi(r,e);let f;if(t&&s){const c=t.dims[1],l=t.dims[2],d=t.dims[3];c===i&&l===n&&d===o&&(f=Vi(t,s))}return{data:h,maskData:f,width:i,height:n,depth:o,isRGB:a}}}function cn(r,e){if(r!=null&&r.affine&&r.dims){const t=r.affine,s=[0,0,0],i=[0,0,0];return s[0]=t[0][3],s[1]=t[1][3],s[2]=t[2][3],i[0]=t[0][0]*r.dims[1],i[1]=t[1][1]*r.dims[2],i[2]=t[2][2]*r.dims[3],e.keepScalePosition&&(i[0]=Math.abs(i[0]),i[1]=Math.abs(i[1]),i[2]=Math.abs(i[2])),{position:s,scale:i}}return{position:void 0,scale:void 0}}function hn(r,e){return r&&r.sform_code?cn(r,e):{position:void 0,scale:void 0}}function Ri(r,e,t,s,i){const n=new M.DataTexture2DArray(r,e,t,s);return n.anisotropy=4,i||(n.format=M.RedFormat),n.minFilter=M.NearestFilter,n.magFilter=M.NearestFilter,n.needsUpdate=!0,n}function Fi(r){if(r!=null&&r.data){const e=new lt;return e.impl=new Ri(r.data,r.width,r.height,r.depth),e.size={width:r.width,height:r.height,depth:r.depth},e.isLoading=!1,e}}function un(r,e,t,s,i){if(e!=null&&e.data){const n={...an};i&&Object.assign(n,i);const o=new qe,a=Fi(e);if(a){o.groupName="Images",o.morph.renderOrder=1,o.texture=a;const h=structuredClone(on);if(Object.assign(h,s),t&&r){const{position:f,scale:c}=hn(r,n);f&&c&&(h.locations[0].scale=c,h.locations[0].position=f)}if(o.initialise(h,void 0),o.showEdges(10066329),e.maskData&&!n.timeEnabled){const f=Ri(e.maskData,e.width,e.height,e.depth,!1);o.setMask(f)}return o.setNumberOfChannels(e.isRGB?3:1),o}}}async function Gi(r,e){let t,s;if(e){const c=await(await fetch(e)).arrayBuffer(),l=ki(c);t=l.niftiHeader,s=l.niftiImage}const n=await(await fetch(r)).arrayBuffer(),{niftiHeader:o,niftiImage:a}=ki(n);return{sources:ln(o,a,t,s),niftiHeader:o}}async function fn(r,e,t,s,i){let n=!1,o,a=r;if(Array.isArray(r)&&(a=r[0],r.length>1&&(i!=null&&i.timeEnabled)&&(n=!0)),typeof a=="string"){const{sources:h,niftiHeader:f}=await Gi(a,t);o=un(f,h,e,s,i)}if(n&&o){for(let h=1;h<r.length;h++){const f=await zi(r[h],t);o.addTextureArray(f)}o.timeEnabled=!0}return o}async function zi(r,e,t){const{sources:s}=await Gi(r,e);return Fi(s)}const dn=Ki.version,pn=function(){this.Revision=dn,this.defaultMaterialColor=16777215,this.defaultOpacity=1,this.Geometry=Xe,this.Glyph=nt,this.Glyphset=vt,this.Pointset=Ee,this.Label=At,this.Lines=ze,this.TextureSlides=qe,this.TextureArray=lt,this.Renderer=en,this.Scene=Pt,this.Viewport=We,this.CameraControls=oi,this.SmoothCameraTransition=ai,this.RayCaster=li,this.CameraAutoTumble=ci,this.StereoEffect=ui,this.loadExternalFile=Et,this.loadExternalFiles=es,this.createPrimitivesFromNIFTI=fn,this.createTextureFromNIFTI=zi,this.THREE=M},Pe=new pn;return Pe});
345
- //# sourceMappingURL=zinc.js.map
287
+ }`};var wt=class extends e.ShaderMaterial{constructor(t){super({type:`LineMaterial`,uniforms:e.UniformsUtils.clone(e.ShaderLib.line.uniforms),vertexShader:e.ShaderLib.line.vertexShader,fragmentShader:e.ShaderLib.line.fragmentShader,clipping:!0}),Object.defineProperties(this,{color:{enumerable:!0,get:function(){return this.uniforms.diffuse.value},set:function(e){this.uniforms.diffuse.value=e}},linewidth:{enumerable:!0,get:function(){return this.uniforms.linewidth.value},set:function(e){this.uniforms.linewidth.value=e}},dashed:{enumerable:!0,get:function(){return`USE_DASH`in this.defines},set(e){!!e!=`USE_DASH`in this.defines&&(this.needsUpdate=!0),e===!0?this.defines.USE_DASH=``:delete this.defines.USE_DASH}},dashScale:{enumerable:!0,get:function(){return this.uniforms.dashScale.value},set:function(e){this.uniforms.dashScale.value=e}},dashSize:{enumerable:!0,get:function(){return this.uniforms.dashSize.value},set:function(e){this.uniforms.dashSize.value=e}},dashOffset:{enumerable:!0,get:function(){return this.uniforms.dashOffset.value},set:function(e){this.uniforms.dashOffset.value=e}},gapSize:{enumerable:!0,get:function(){return this.uniforms.gapSize.value},set:function(e){this.uniforms.gapSize.value=e}},opacity:{enumerable:!0,get:function(){return this.uniforms.opacity.value},set:function(e){this.uniforms.opacity.value=e}},resolution:{enumerable:!0,get:function(){return this.uniforms.resolution.value},set:function(e){this.uniforms.resolution.value.copy(e)}},alphaToCoverage:{enumerable:!0,get:function(){return`ALPHA_TO_COVERAGE`in this.defines},set:function(e){!!e!=`ALPHA_TO_COVERAGE`in this.defines&&(this.needsUpdate=!0),e===!0?(this.defines.ALPHA_TO_COVERAGE=``,this.extensions.derivatives=!0):(delete this.defines.ALPHA_TO_COVERAGE,this.extensions.derivatives=!1)}}}),this.setValues(t)}};wt.prototype.isLineMaterial=!0;var Tt=new e.Vector3,Et=new e.Vector3,V=new e.Vector4,H=new e.Vector4,U=new e.Vector4,Dt=new e.Vector3,Ot=new e.Matrix4,W=new e.Line3,kt=new e.Vector3,G=new e.Box3,At=new e.Sphere,K=new e.Vector4,jt=class extends e.Mesh{constructor(e=new Ct,t=new wt({color:Math.random()*16777215})){super(e,t),this.type=`LineSegments2`}computeLineDistances(){let t=this.geometry,n=t.attributes.instanceStart,r=t.attributes.instanceEnd,i=new Float32Array(2*n.count);for(let e=0,t=0,a=n.count;e<a;e++,t+=2)Tt.fromBufferAttribute(n,e),Et.fromBufferAttribute(r,e),i[t]=t===0?0:i[t-1],i[t+1]=i[t]+Tt.distanceTo(Et);let a=new e.InstancedInterleavedBuffer(i,2,1);return t.setAttribute(`instanceDistanceStart`,new e.InterleavedBufferAttribute(a,1,0)),t.setAttribute(`instanceDistanceEnd`,new e.InterleavedBufferAttribute(a,1,1)),this}raycast(t,n){t.camera===null&&console.error(`LineSegments2: "Raycaster.camera" needs to be set in order to raycast against LineSegments2.`);let r=t.params.Line2===void 0?0:t.params.Line2.threshold||0,i=t.ray,a=t.camera,o=a.projectionMatrix,s=this.matrixWorld,c=this.geometry,l=this.material,u=l.resolution,d=l.linewidth+r,f=c.attributes.instanceStart,p=c.attributes.instanceEnd,m=-a.near,h=2*Math.max(d/u.width,d/u.height);c.boundingSphere===null&&c.computeBoundingSphere(),At.copy(c.boundingSphere).applyMatrix4(s);let g=Math.max(a.near,At.distanceToPoint(i.origin));K.set(0,0,-g,1).applyMatrix4(a.projectionMatrix),K.multiplyScalar(1/K.w),K.applyMatrix4(a.projectionMatrixInverse);let _=Math.abs(h/K.w)*.5;if(At.radius+=_,t.ray.intersectsSphere(At)===!1)return;c.boundingBox===null&&c.computeBoundingBox(),G.copy(c.boundingBox).applyMatrix4(s);let v=Math.max(a.near,G.distanceToPoint(i.origin));K.set(0,0,-v,1).applyMatrix4(a.projectionMatrix),K.multiplyScalar(1/K.w),K.applyMatrix4(a.projectionMatrixInverse);let y=Math.abs(h/K.w)*.5;if(G.max.x+=y,G.max.y+=y,G.max.z+=y,G.min.x-=y,G.min.y-=y,G.min.z-=y,t.ray.intersectsBox(G)!==!1){i.at(1,U),U.w=1,U.applyMatrix4(a.matrixWorldInverse),U.applyMatrix4(o),U.multiplyScalar(1/U.w),U.x*=u.x/2,U.y*=u.y/2,U.z=0,Dt.copy(U),Ot.multiplyMatrices(a.matrixWorldInverse,s);for(let t=0,r=f.count;t<r;t++){if(V.fromBufferAttribute(f,t),H.fromBufferAttribute(p,t),V.w=1,H.w=1,V.applyMatrix4(Ot),H.applyMatrix4(Ot),V.z>m&&H.z>m)continue;if(V.z>m){let e=V.z-H.z,t=(V.z-m)/e;V.lerp(H,t)}else if(H.z>m){let e=H.z-V.z,t=(H.z-m)/e;H.lerp(V,t)}V.applyMatrix4(o),H.applyMatrix4(o),V.multiplyScalar(1/V.w),H.multiplyScalar(1/H.w),V.x*=u.x/2,V.y*=u.y/2,H.x*=u.x/2,H.y*=u.y/2,W.start.copy(V),W.start.z=0,W.end.copy(H),W.end.z=0;let r=W.closestPointToPointParameter(Dt,!0);W.at(r,kt);let a=e.MathUtils.lerp(V.z,H.z,r),c=a>=-1&&a<=1,l=Dt.distanceTo(kt)<d*.5;if(c&&l){W.start.fromBufferAttribute(f,t),W.end.fromBufferAttribute(p,t),W.start.applyMatrix4(s),W.end.applyMatrix4(s);let r=new e.Vector3,a=new e.Vector3;i.distanceSqToSegment(W.start,W.end,a,r),n.push({point:a,pointOnLine:r,distance:i.origin.distanceTo(a),object:this,face:null,faceIndex:t,uv:null,uv2:null})}}}}};jt.prototype.LineSegments2=!0;var Mt=function(){Ye.call(this),this.isLines2=!0;let e=Array(300);this.createLineSegment=(e,t,n)=>{if(e&&t){let r=new Ct;r.setPositions(e),r.colorsNeedUpdate=!0;let i=new jt(r,t);i.scale.set(1,1,1),i.computeLineDistances(),this.setMesh(i,n.localTimeEnabled,n.localMorphColour)}},this.setWidth=e=>{this.morph&&this.morph.material&&(this.morph.material.linewidth=e,this.morph.material.needsUpdate=!0)},this.addVertices=function(t){if(t&&t.length){let n=this.getMorph();n||(this.drawRange=0);let r=this.drawRange*3;if(t.forEach(t=>{e[r++]=t[0],e[r++]=t[1],e[r++]=t[2],this.drawRange++}),!n)for(;r<300;)e[r++]=t[0][0],e[r++]=t[0][1],e[r++]=t[0][2];n&&(n.geometry.setPositions(e),n.computeLineDistances(),n.geometry.computeBoundingBox(),n.geometry.computeBoundingSphere(),this.boundingBoxUpdateRequired=!0)}return e},this.getVerticesByFaceIndex=function(e){let t=e*2*3,n=this.getMorph();if(n&&this.drawRange*3>t){let e=n.geometry.getAttribute(`instanceStart`);return[[e.data.array[t],e.data.array[++t],e.data.array[++t]],[e.data.array[++t],e.data.array[++t],e.data.array[++t]]]}return[]},this.editVertices=function(t,n){if(t&&t.length){let r=this.getMorph(),i=n+t.length-1;if(!r||0>n||i>=this.drawRange)return;{let i=n*3;for(t.forEach(t=>{e[i++]=t[0],e[i++]=t[1],e[i++]=t[2]}),i=this.drawRange*3;i<300;)e[i++]=t[0][0],e[i++]=t[0][1],e[i++]=t[0][2];r.geometry.setPositions(e),r.computeLineDistances(),r.geometry.computeBoundingBox(),r.geometry.computeBoundingSphere(),this.boundingBoxUpdateRequired=!0}}return e},this.addLines=(t,n)=>{if(t&&t.length>0){if(this.addVertices(t),!this.getMorph()){let t=new wt({color:n,linewidth:1,vertexColors:!1,worldUnits:!1});t.resolution.set(window.innerWidth,window.innerHeight),this.createLineSegment(e,t,{localTimeEnabled:!1,localMorphColour:!1})}this.region&&(this.region.pickableUpdateRequired=!0)}},this.render=(e,t,n,r)=>{this.getMorph().material.resolution.set(window.innerWidth,window.innerHeight)}};Mt.prototype=Object.create(Ye.prototype),Mt.prototype.constructor=Mt;var Nt=0,Pt=function(){return`re`+Nt++},Ft=function(t,n){let r=t,i=new e.Group;i.matrixAutoUpdate=!1,i.userData=this;let a=[],o=``,s=[],c=n,l=new e.Matrix4,u=3e3;l.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this.pickableUpdateRequired=!0,this.isRegion=!0,this.uuid=Pt(),this.hideAllPrimitives=()=>{a.forEach(e=>e.hideAllPrimitives()),s.forEach(e=>e.setVisibility(!1))},this.showAllPrimitives=()=>{a.forEach(e=>e.showAllPrimitives()),s.forEach(e=>e.setVisibility(!0))},this.setVisibility=e=>{e!=i.visible&&(i.visible=e,this.pickableUpdateRequired=!0)},this.getVisibility=()=>i.visible,this.getGroup=()=>i,this.setTransformation=e=>{l.set(...e),i.matrix.copy(l),i.updateMatrixWorld()},this.setName=e=>{e&&e!==``&&(o=e)},this.getName=()=>o,this.getParent=()=>r,this.getFullSeparatedPath=()=>{let e=[];if(o!==``){e.push(o);for(let t=r;t!==void 0;){let n=t.getName();n!==``&&e.unshift(n),t=t.getParent()}}return e},this.getFullPath=()=>{let e=this.getFullSeparatedPath();if(e.length>0){let t=e.shift();return e.forEach(e=>{t=t.concat(`/`,e)}),t}return``},this.createChild=e=>{let t=new Ft(this,c);return t.setName(e),a.push(t),i.add(t.getGroup()),t},this.getChildWithName=e=>{if(e){let t=e.toLowerCase();for(let e=0;e<a.length;e++)if(a[e].getName().toLowerCase()===t)return a[e]}},this.findChildFromSeparatedPath=e=>{if(e&&e.length>0&&e[0]===``&&e.shift(),e&&e.length>0){let t=this.getChildWithName(e[0]);return t?(e.shift(),t.findChildFromSeparatedPath(e)):void 0}return this},this.findChildFromPath=e=>{let t=e.split(`/`);return this.findChildFromSeparatedPath(t)},this.createChildFromSeparatedPath=e=>{if(e.length>0&&e[0]===``&&e.shift(),e.length>0){let t=this.getChildWithName(e[0]);return t||=this.createChild(e[0]),e.shift(),t.createChildFromSeparatedPath(e)}return this},this.createChildFromPath=e=>{let t=e.split(`/`);return this.createChildFromSeparatedPath(t)},this.findOrCreateChildFromPath=e=>{let t=this.findChildFromPath(e);return t||=this.createChildFromPath(e),t},this.addZincObject=e=>{e&&(e.setRegion(this),i.add(e.getGroup()),s.push(e),this.pickableUpdateRequired=!0,c&&c.triggerObjectAddedCallback(e))},this.removeZincObject=e=>{for(let t=0;t<s.length;t++)if(e===s[t]){i.remove(e.getGroup()),s.splice(t,1),c&&c.triggerObjectRemovedCallback(e),e.dispose(),this.pickableUpdateRequired=!0;return}},this.checkPickableUpdateRequred=e=>{if(this.pickableUpdateRequired)return!0;if(e){let t=!1;for(let n=0;n<a.length;n++)if(t=a[n].checkPickableUpdateRequred(e),t)return!0}return!1},this.getPickableThreeJSObjects=(e,t)=>(i.visible&&(s.forEach(t=>{if(t.isPickable&&t.getGroup()&&t.getGroup().visible){let n=t.marker;n&&n.isEnabled()&&e.push(n.getMorph()),e.push(t.getGroup())}}),t&&a.forEach(n=>{n.getPickableThreeJSObjects(e,t)}),this.pickableUpdateRequired=!1),e),this.setDuration=e=>{u=e,s.forEach(t=>t.setDuration(e)),a.forEach(t=>t.setDuration(e))},this.getDuration=()=>u,this.getBoundingBox=e=>{let t,n;return s.forEach(e=>{n=e.getBoundingBox(),n&&(t==null?t=n.clone():t.union(n))}),e&&a.forEach(r=>{n=r.getBoundingBox(e),n&&(t==null?t=n.clone():t.union(n))}),t},this.clear=e=>{e&&a.forEach(t=>t.clear(e)),s.forEach(e=>{i.remove(e.getGroup()),e.dispose()}),a=[],s=[]},this.objectIsInRegion=(e,t)=>{for(let t=0;t<s.length;t++)if(e===s[t])return!0;if(t){for(let n=0;n<a.length;n++)if(a[n].objectIsInRegion(e,t))return!0}return!1},this.forEachGeometry=(e,t)=>{s.forEach(t=>{t.isGeometry&&e(t)}),t&&a.forEach(n=>n.forEachGeometry(e,t))},this.forEachGlyphset=(e,t)=>{s.forEach(t=>{t.isGlyphset&&e(t)}),t&&a.forEach(n=>n.forEachGlyphset(e,t))},this.forEachPointset=(e,t)=>{s.forEach(t=>{t.isPointset&&e(t)}),t&&a.forEach(n=>n.forEachPointset(e,t))},this.forEachLine=(e,t)=>{s.forEach(t=>{t.isLines&&e(t)}),t&&a.forEach(n=>n.forEachLine(e,t))},this.findObjectsWithAnatomicalId=(e,t)=>{let n=[];return s.forEach(t=>{t.anatomicalId===e&&n.push(t)}),t&&a.forEach(r=>{let i=r.findObjectsWithAnatomicalId(e,t);n.push(...i)}),n},this.findObjectsWithGroupName=(e,t)=>{let n=[];return s.forEach(t=>{(t.groupName?t.groupName.toLowerCase():t.groupName)===(e&&e.toLowerCase())&&n.push(t)}),t&&a.forEach(r=>{let i=r.findObjectsWithGroupName(e,t);n.push(...i)}),n},this.findGeometriesWithGroupName=(e,t)=>this.findObjectsWithGroupName(e,t).filter(e=>e.isGeometry),this.findPointsetsWithGroupName=(e,t)=>this.findObjectsWithGroupName(e,t).filter(e=>e.isPointset),this.findGlyphsetsWithGroupName=(e,t)=>this.findObjectsWithGroupName(e,t).filter(e=>e.isGlyphset),this.findLinesWithGroupName=(e,t)=>this.findObjectsWithGroupName(e,t).filter(e=>e.isLines),this.getAllObjects=e=>{let t=[...s];return e&&a.forEach(n=>{let r=n.getAllObjects(e);t.push(...r)}),t},this.getChildRegions=e=>{let t=[...a];return e&&a.forEach(n=>{let r=n.getChildRegions(e);t.push(...r)}),t},this.getCurrentTime=()=>{if(s[0]!=null)return s[0].getCurrentTime();for(let e=0;e<a.length;e++){let t=a[e].getCurrentTime();if(t!==-1)return t}return-1},this.setMorphTime=(e,t)=>{s.forEach(t=>{t.setMorphTime(e)}),t&&a.forEach(t=>{t.setMorphTime(e)})},this.isTimeVarying=()=>{for(let e=0;e<s.length;e++)if(s[e].isTimeVarying())return!0;for(let e=0;e<a.length;e++)if(a[e].isTimeVarying())return!0;return!1},this.renderGeometries=(e,t,n,r,i,a)=>{this.getAllObjects(a).forEach(a=>{a.render(e*t,n,r,i)}),i&&n===!1&&i.markerCluster?.markerUpdateRequired&&i.markerCluster.calculate()},this.createPoints=(e,t,n,r)=>{let i=!1,a=this.findObjectsWithGroupName(e,!1),o=a.findIndex(e=>e.isPointset),s=o>-1?a[o]:new Je;return s.addPoints(t,n,r),o===-1?(s.setName(e),this.addZincObject(s),i=!0):this.pickableUpdateRequired=!0,{zincObject:s,isNew:i}},this.createLines=(e,t,n)=>{let r=!1,i=this.findObjectsWithGroupName(e,!1),a=i.findIndex(e=>e.isLines),o=a>-1?i[a]:new Mt;return o.addLines(t,n),a===-1?(o.setName(e),this.addZincObject(o),r=!0):this.pickableUpdateRequired=!0,{zincObject:o,isNew:r}},this.createGeometryFromThreeJSGeometry=(t,n,r,i,a,o)=>{let s=new Ce,c=new e.MeshPhongMaterial({color:r,morphTargets:!1,morphNormals:!1,transparent:!0,opacity:i,side:e.DoubleSide});if(s.createMesh(n,c,{localTimeEnabled:!1,localMorphColour:!1}),s.getMorph())return s.setVisibility(!1),s.setName(t),s.setRenderOrder(o),this.addZincObject(s),s}},It=class{constructor(){this.pluginCallbacks=[],this.register(function(e){return new Qt(e)}),this.register(function(e){return new $t(e)}),this.register(function(e){return new en(e)})}register(e){return this.pluginCallbacks.indexOf(e)===-1&&this.pluginCallbacks.push(e),this}unregister(e){return this.pluginCallbacks.indexOf(e)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,n){let r=new Zt,i=[];for(let e=0,t=this.pluginCallbacks.length;e<t;e++)i.push(this.pluginCallbacks[e](r));r.setPlugins(i),r.write(e,t,n)}},q={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,UNSIGNED_BYTE:5121,UNSIGNED_SHORT:5123,FLOAT:5126,UNSIGNED_INT:5125,ARRAY_BUFFER:34962,ELEMENT_ARRAY_BUFFER:34963,NEAREST:9728,LINEAR:9729,NEAREST_MIPMAP_NEAREST:9984,LINEAR_MIPMAP_NEAREST:9985,NEAREST_MIPMAP_LINEAR:9986,LINEAR_MIPMAP_LINEAR:9987,CLAMP_TO_EDGE:33071,MIRRORED_REPEAT:33648,REPEAT:10497},J={};J[e.NearestFilter]=q.NEAREST,J[e.NearestMipmapNearestFilter]=q.NEAREST_MIPMAP_NEAREST,J[e.NearestMipmapLinearFilter]=q.NEAREST_MIPMAP_LINEAR,J[e.LinearFilter]=q.LINEAR,J[e.LinearMipmapNearestFilter]=q.LINEAR_MIPMAP_NEAREST,J[e.LinearMipmapLinearFilter]=q.LINEAR_MIPMAP_LINEAR,J[e.ClampToEdgeWrapping]=q.CLAMP_TO_EDGE,J[e.RepeatWrapping]=q.REPEAT,J[e.MirroredRepeatWrapping]=q.MIRRORED_REPEAT;var Lt={scale:`scale`,position:`translation`,quaternion:`rotation`,morphTargetInfluences:`weights`},Rt=12,zt=1179937895,Bt=2,Vt=8,Ht=1313821514,Ut=5130562;function Wt(e,t){return e.length===t.length&&e.every(function(e,n){return e===t[n]})}function Gt(e){if(window.TextEncoder!==void 0)return new TextEncoder().encode(e).buffer;let t=new Uint8Array(new ArrayBuffer(e.length));for(let n=0,r=e.length;n<r;n++){let r=e.charCodeAt(n);t[n]=r>255?32:r}return t.buffer}function Kt(e){return Wt(e.elements,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}function qt(e,t,n){let r={min:Array(e.itemSize).fill(1/0),max:Array(e.itemSize).fill(-1/0)};for(let i=t;i<t+n;i++)for(let t=0;t<e.itemSize;t++){let n;e.itemSize>4?n=e.array[i*e.itemSize+t]:t===0?n=e.getX(i):t===1?n=e.getY(i):t===2?n=e.getZ(i):t===3&&(n=e.getW(i)),r.min[t]=Math.min(r.min[t],n),r.max[t]=Math.max(r.max[t],n)}return r}function Jt(e){return Math.ceil(e/4)*4}function Yt(e,t=0){let n=Jt(e.byteLength);if(n!==e.byteLength){let r=new Uint8Array(n);if(r.set(new Uint8Array(e)),t!==0)for(let i=e.byteLength;i<n;i++)r[i]=t;return r.buffer}return e}var Xt=null,Zt=class{constructor(){this.plugins=[],this.options={},this.pending=[],this.buffers=[],this.byteOffset=0,this.buffers=[],this.nodeMap=new Map,this.skins=[],this.extensionsUsed={},this.uids=new Map,this.uid=0,this.json={asset:{version:`2.0`,generator:`THREE.GLTFExporter`}},this.cache={meshes:new Map,attributes:new Map,attributesNormalized:new Map,materials:new Map,textures:new Map,images:new Map}}setPlugins(e){this.plugins=e}write(e,t,n){this.options=Object.assign({},{binary:!1,trs:!1,onlyVisible:!0,truncateDrawRange:!0,embedImages:!0,maxTextureSize:1/0,animations:[],includeCustomExtensions:!1},n),this.options.animations.length>0&&(this.options.trs=!0),this.processInput(e);let r=this;Promise.all(this.pending).then(function(){let e=r.buffers,n=r.json,i=r.options,a=r.extensionsUsed,o=new Blob(e,{type:`application/octet-stream`}),s=Object.keys(a);if(s.length>0&&(n.extensionsUsed=s),n.buffers&&n.buffers.length>0&&(n.buffers[0].byteLength=o.size),i.binary===!0){let e=new window.FileReader;e.readAsArrayBuffer(o),e.onloadend=function(){let r=Yt(e.result),i=new DataView(new ArrayBuffer(Vt));i.setUint32(0,r.byteLength,!0),i.setUint32(4,Ut,!0);let a=Yt(Gt(JSON.stringify(n)),32),o=new DataView(new ArrayBuffer(Vt));o.setUint32(0,a.byteLength,!0),o.setUint32(4,Ht,!0);let s=new ArrayBuffer(Rt),c=new DataView(s);c.setUint32(0,zt,!0),c.setUint32(4,Bt,!0);let l=Rt+o.byteLength+a.byteLength+i.byteLength+r.byteLength;c.setUint32(8,l,!0);let u=new Blob([s,o,a,i,r],{type:`application/octet-stream`}),d=new window.FileReader;d.readAsArrayBuffer(u),d.onloadend=function(){t(d.result)}}}else if(n.buffers&&n.buffers.length>0){let e=new window.FileReader;e.readAsDataURL(o),e.onloadend=function(){let r=e.result;n.buffers[0].uri=r,t(n)}}else t(n)})}serializeUserData(e,t){if(e.userData&&e.userData.isZincObject||Object.keys(e.userData).length===0)return;let n=this.options,r=this.extensionsUsed;try{let i=JSON.parse(JSON.stringify(e.userData));if(n.includeCustomExtensions&&i.gltfExtensions){t.extensions===void 0&&(t.extensions={});for(let e in i.gltfExtensions)t.extensions[e]=i.gltfExtensions[e],r[e]=!0;delete i.gltfExtensions}Object.keys(i).length>0&&(t.extras=i)}catch(t){console.warn(`THREE.GLTFExporter: userData of '`+e.name+`' won't be serialized because of JSON.stringify error - `+t.message)}}getUID(e){return this.uids.has(e)||this.uids.set(e,this.uid++),this.uids.get(e)}isNormalizedNormalAttribute(t){if(this.cache.attributesNormalized.has(t))return!1;let n=new e.Vector3;for(let e=0,r=t.count;e<r;e++)if(Math.abs(n.fromBufferAttribute(t,e).length()-1)>5e-4)return!1;return!0}createNormalizedNormalAttribute(t){let n=this.cache;if(n.attributesNormalized.has(t))return n.attributesNormalized.get(t);let r=t.clone(),i=new e.Vector3;for(let e=0,t=r.count;e<t;e++)i.fromBufferAttribute(r,e),i.x===0&&i.y===0&&i.z===0?i.setX(1):i.normalize(),r.setXYZ(e,i.x,i.y,i.z);return n.attributesNormalized.set(t,r),r}applyTextureTransform(e,t){let n=!1,r={};(t.offset.x!==0||t.offset.y!==0)&&(r.offset=t.offset.toArray(),n=!0),t.rotation!==0&&(r.rotation=t.rotation,n=!0),(t.repeat.x!==1||t.repeat.y!==1)&&(r.scale=t.repeat.toArray(),n=!0),n&&(e.extensions=e.extensions||{},e.extensions.KHR_texture_transform=r,this.extensionsUsed.KHR_texture_transform=!0)}processBuffer(e){let t=this.json,n=this.buffers;return t.buffers||=[{byteLength:0}],n.push(e),0}processBufferView(e,t,n,r,i){let a=this.json;a.bufferViews||=[];let o;o=t===q.UNSIGNED_BYTE?1:t===q.UNSIGNED_SHORT?2:4;let s=Jt(r*e.itemSize*o),c=new DataView(new ArrayBuffer(s)),l=0;for(let i=n;i<n+r;i++)for(let n=0;n<e.itemSize;n++){let r;e.itemSize>4?r=e.array[i*e.itemSize+n]:n===0?r=e.getX(i):n===1?r=e.getY(i):n===2?r=e.getZ(i):n===3&&(r=e.getW(i)),t===q.FLOAT?c.setFloat32(l,r,!0):t===q.UNSIGNED_INT?c.setUint32(l,r,!0):t===q.UNSIGNED_SHORT?c.setUint16(l,r,!0):t===q.UNSIGNED_BYTE&&c.setUint8(l,r),l+=o}let u={buffer:this.processBuffer(c.buffer),byteOffset:this.byteOffset,byteLength:s};return i!==void 0&&(u.target=i),i===q.ARRAY_BUFFER&&(u.byteStride=e.itemSize*o),this.byteOffset+=s,a.bufferViews.push(u),{id:a.bufferViews.length-1,byteLength:0}}processBufferViewImage(e){let t=this,n=t.json;return n.bufferViews||=[],new Promise(function(r){let i=new window.FileReader;i.readAsArrayBuffer(e),i.onloadend=function(){let e=Yt(i.result),a={buffer:t.processBuffer(e),byteOffset:t.byteOffset,byteLength:e.byteLength};t.byteOffset+=e.byteLength,r(n.bufferViews.push(a)-1)}})}processAccessor(e,t,n,r){let i=this.options,a=this.json,o={1:`SCALAR`,2:`VEC2`,3:`VEC3`,4:`VEC4`,16:`MAT4`},s;if(e.array.constructor===Float32Array)s=q.FLOAT;else if(e.array.constructor===Uint32Array)s=q.UNSIGNED_INT;else if(e.array.constructor===Uint16Array)s=q.UNSIGNED_SHORT;else if(e.array.constructor===Uint8Array)s=q.UNSIGNED_BYTE;else throw Error(`THREE.GLTFExporter: Unsupported bufferAttribute component type.`);if(n===void 0&&(n=0),r===void 0&&(r=e.count),i.truncateDrawRange&&t!==void 0&&t.index===null){let i=n+r,a=t.drawRange.count===1/0?e.count:t.drawRange.start+t.drawRange.count;n=Math.max(n,t.drawRange.start),r=Math.min(i,a)-n,r<0&&(r=0)}if(r===0)return null;let c=qt(e,n,r),l;t!==void 0&&(l=e===t.index?q.ELEMENT_ARRAY_BUFFER:q.ARRAY_BUFFER);let u=this.processBufferView(e,s,n,r,l),d={bufferView:u.id,byteOffset:u.byteOffset,componentType:s,count:r,max:c.max,min:c.min,type:o[e.itemSize]};return e.normalized===!0&&(d.normalized=!0),a.accessors||=[],a.accessors.push(d)-1}processImage(t,n,r){let i=this,a=i.cache,o=i.json,s=i.options,c=i.pending;a.images.has(t)||a.images.set(t,{});let l=a.images.get(t),u=n===e.RGBAFormat?`image/png`:`image/jpeg`,d=u+`:flipY/`+r.toString();if(l[d]!==void 0)return l[d];o.images||=[];let f={mimeType:u};if(s.embedImages){let a=Xt||=document.createElement(`canvas`);a.width=Math.min(t.width,s.maxTextureSize),a.height=Math.min(t.height,s.maxTextureSize);let o=a.getContext(`2d`);if(r===!0&&(o.translate(0,a.height),o.scale(1,-1)),typeof HTMLImageElement<`u`&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<`u`&&t instanceof HTMLCanvasElement||typeof OffscreenCanvas<`u`&&t instanceof OffscreenCanvas||typeof ImageBitmap<`u`&&t instanceof ImageBitmap)o.drawImage(t,0,0,a.width,a.height);else{n!==e.RGBAFormat&&n!==e.RGBFormat&&console.error(`GLTFExporter: Only RGB and RGBA formats are supported.`),(t.width>s.maxTextureSize||t.height>s.maxTextureSize)&&console.warn(`GLTFExporter: Image size is bigger than maxTextureSize`,t);let r=new Uint8ClampedArray(t.height*t.width*4);if(n===e.RGBAFormat)for(let e=0;e<r.length;e+=4)r[e+0]=t.data[e+0],r[e+1]=t.data[e+1],r[e+2]=t.data[e+2],r[e+3]=t.data[e+3];else for(let e=0,n=0;e<r.length;e+=4,n+=3)r[e+0]=t.data[n+0],r[e+1]=t.data[n+1],r[e+2]=t.data[n+2],r[e+3]=255;o.putImageData(new ImageData(r,t.width,t.height),0,0)}s.binary===!0?c.push(new Promise(function(e){a.toBlob(function(t){i.processBufferViewImage(t).then(function(t){f.bufferView=t,e()})},u)})):f.uri=a.toDataURL(u)}else f.uri=t.src;let p=o.images.push(f)-1;return l[d]=p,p}processSampler(e){let t=this.json;t.samplers||=[];let n={magFilter:J[e.magFilter],minFilter:J[e.minFilter],wrapS:J[e.wrapS],wrapT:J[e.wrapT]};return t.samplers.push(n)-1}processTexture(e){let t=this.cache,n=this.json;if(t.textures.has(e))return t.textures.get(e);n.textures||=[];let r={sampler:this.processSampler(e),source:this.processImage(e.image,e.format,e.flipY)};e.name&&(r.name=e.name),this._invokeAll(function(t){t.writeTexture&&t.writeTexture(e,r)});let i=n.textures.push(r)-1;return t.textures.set(e,i),i}processMaterial(t){let n=this.cache,r=this.json;if(n.materials.has(t))return n.materials.get(t);if(t.isShaderMaterial)return console.warn(`GLTFExporter: THREE.ShaderMaterial not supported.`),null;r.materials||=[];let i={pbrMetallicRoughness:{}};t.isMeshStandardMaterial!==!0&&t.isMeshBasicMaterial!==!0&&console.warn(`GLTFExporter: Use MeshStandardMaterial or MeshBasicMaterial for best results.`);let a=t.color.toArray().concat([t.opacity]);if(Wt(a,[1,1,1,1])||(i.pbrMetallicRoughness.baseColorFactor=a),t.isMeshStandardMaterial?(i.pbrMetallicRoughness.metallicFactor=t.metalness,i.pbrMetallicRoughness.roughnessFactor=t.roughness):(i.pbrMetallicRoughness.metallicFactor=.5,i.pbrMetallicRoughness.roughnessFactor=.5),t.metalnessMap||t.roughnessMap){if(t.metalnessMap===t.roughnessMap){let e={index:this.processTexture(t.metalnessMap)};this.applyTextureTransform(e,t.metalnessMap),i.pbrMetallicRoughness.metallicRoughnessTexture=e}else console.warn(`THREE.GLTFExporter: Ignoring metalnessMap and roughnessMap because they are not the same Texture.`)}if(t.map){let e={index:this.processTexture(t.map)};this.applyTextureTransform(e,t.map),i.pbrMetallicRoughness.baseColorTexture=e}if(t.emissive){let e=t.emissive.clone().multiplyScalar(t.emissiveIntensity),n=Math.max(e.r,e.g,e.b);if(n>1&&(e.multiplyScalar(1/n),console.warn(`THREE.GLTFExporter: Some emissive components exceed 1; emissive has been limited`)),n>0&&(i.emissiveFactor=e.toArray()),t.emissiveMap){let e={index:this.processTexture(t.emissiveMap)};this.applyTextureTransform(e,t.emissiveMap),i.emissiveTexture=e}}if(t.normalMap){let e={index:this.processTexture(t.normalMap)};t.normalScale&&t.normalScale.x!==-1&&(t.normalScale.x!==t.normalScale.y&&console.warn(`THREE.GLTFExporter: Normal scale components are different, ignoring Y and exporting X.`),e.scale=t.normalScale.x),this.applyTextureTransform(e,t.normalMap),i.normalTexture=e}if(t.aoMap){let e={index:this.processTexture(t.aoMap),texCoord:1};t.aoMapIntensity!==1&&(e.strength=t.aoMapIntensity),this.applyTextureTransform(e,t.aoMap),i.occlusionTexture=e}t.transparent?i.alphaMode=`BLEND`:t.alphaTest>0&&(i.alphaMode=`MASK`,i.alphaCutoff=t.alphaTest),t.side===e.DoubleSide&&(i.doubleSided=!0),t.name!==``&&(i.name=t.name),this.serializeUserData(t,i),this._invokeAll(function(e){e.writeMaterial&&e.writeMaterial(t,i)});let o=r.materials.push(i)-1;return n.materials.set(t,o),o}processMesh(t){let n=this.cache,r=this.json,i=[t.geometry.uuid];if(Array.isArray(t.material))for(let e=0,n=t.material.length;e<n;e++)i.push(t.material[e].uuid);else i.push(t.material.uuid);let a=i.join(`:`);if(n.meshes.has(a))return n.meshes.get(a);let o=t.geometry,s;if(s=t.isLineSegments?q.LINES:t.isLineLoop?q.LINE_LOOP:t.isLine?q.LINE_STRIP:t.isPoints?q.POINTS:t.material.wireframe?q.LINES:q.TRIANGLES,o.isBufferGeometry!==!0)throw Error(`THREE.GLTFExporter: Geometry is not of type THREE.BufferGeometry.`);let c={},l={},u=[],d=[],f={uv:`TEXCOORD_0`,uv2:`TEXCOORD_1`,color:`COLOR_0`,skinWeight:`WEIGHTS_0`,skinIndex:`JOINTS_0`},p=o.getAttribute(`normal`);p!==void 0&&!this.isNormalizedNormalAttribute(p)&&(console.warn(`THREE.GLTFExporter: Creating normalized normal attribute from the non-normalized one.`),o.setAttribute(`normal`,this.createNormalizedNormalAttribute(p)));let m=null;for(let t in o.attributes){if(t.substr(0,5)===`morph`)continue;let r=o.attributes[t];if(t=f[t]||t.toUpperCase(),/^(POSITION|NORMAL|TANGENT|TEXCOORD_\d+|COLOR_\d+|JOINTS_\d+|WEIGHTS_\d+)$/.test(t)||(t=`_`+t),n.attributes.has(this.getUID(r))){l[t]=n.attributes.get(this.getUID(r));continue}m=null;let i=r.array;t===`JOINTS_0`&&!(i instanceof Uint16Array)&&!(i instanceof Uint8Array)&&(console.warn(`GLTFExporter: Attribute "skinIndex" converted to type UNSIGNED_SHORT.`),m=new e.BufferAttribute(new Uint16Array(i),r.itemSize,r.normalized));let a=this.processAccessor(m||r,o);a!==null&&(l[t]=a,n.attributes.set(this.getUID(r),a))}if(p!==void 0&&o.setAttribute(`normal`,p),Object.keys(l).length===0)return null;if(t.morphTargetInfluences!==void 0&&t.morphTargetInfluences.length>0){let e=[],r=[],i={};if(t.morphTargetDictionary!==void 0)for(let e in t.morphTargetDictionary)i[t.morphTargetDictionary[e]]=e;for(let a=0;a<t.morphTargetInfluences.length;++a){let s={},c=!1;for(let e in o.morphAttributes){if(e!==`position`&&e!==`normal`&&e!==`color`){c||=(console.warn(`GLTFExporter: Only POSITION and NORMAL morph are supported.`),!0);continue}let t=o.morphAttributes[e][a],r=e.toUpperCase();f[e]&&(r=f[e]);let i=o.attributes[e];if(n.attributes.has(this.getUID(t))){s[r]=n.attributes.get(this.getUID(t));continue}let l=i.clone();if(!o.morphTargetsRelative){if(i)for(let e=0,n=t.count;e<n;e++)i.count>e&&l.setXYZ(e,t.getX(e)-i.getX(e),t.getY(e)-i.getY(e),t.getZ(e)-i.getZ(e));else for(let e=0,n=t.count;e<n;e++)l.setXYZ(e,0,0,0)}s[r]=this.processAccessor(l,o),n.attributes.set(this.getUID(i),s[r])}d.push(s),e.push(t.morphTargetInfluences[a]),t.morphTargetDictionary!==void 0&&r.push(i[a])}c.weights=e,r.length>0&&(c.extras={},c.extras.targetNames=r)}let h=Array.isArray(t.material);if(h&&o.groups.length===0)return null;let g=h?t.material:[t.material],_=h?o.groups:[{materialIndex:0,start:void 0,count:void 0}];for(let e=0,t=_.length;e<t;e++){let t={mode:s,attributes:l};if(this.serializeUserData(o,t),d.length>0&&(t.targets=d),o.index!==null){let r=this.getUID(o.index);(_[e].start!==void 0||_[e].count!==void 0)&&(r+=`:`+_[e].start+`:`+_[e].count),n.attributes.has(r)?t.indices=n.attributes.get(r):(t.indices=this.processAccessor(o.index,o,_[e].start,_[e].count),n.attributes.set(r,t.indices)),t.indices===null&&delete t.indices}let r=this.processMaterial(g[_[e].materialIndex]);r!==null&&(t.material=r),u.push(t)}c.primitives=u,r.meshes||=[],this._invokeAll(function(e){e.writeMesh&&e.writeMesh(t,c)});let v=r.meshes.push(c)-1;return n.meshes.set(a,v),v}processCamera(t){let n=this.json;n.cameras||=[];let r=t.isOrthographicCamera,i={type:r?`orthographic`:`perspective`};return r?i.orthographic={xmag:t.right*2,ymag:t.top*2,zfar:t.far<=0?.001:t.far,znear:t.near<0?0:t.near}:i.perspective={aspectRatio:t.aspect,yfov:e.MathUtils.degToRad(t.fov),zfar:t.far<=0?.001:t.far,znear:t.near<0?0:t.near},t.name!==``&&(i.name=t.type),n.cameras.push(i)-1}processAnimation(t,n){let r=this.json,i=this.nodeMap;r.animations||=[],t=It.Utils.mergeMorphTargetTracks(t.clone(),n);let a=t.tracks,o=[],s=[];for(let t=0;t<a.length;++t){let r=a[t],c=e.PropertyBinding.parseTrackName(r.name),l=e.PropertyBinding.findNode(n,c.nodeName),u=Lt[c.propertyName];if(c.objectName===`bones`&&(l=l.isSkinnedMesh===!0?l.skeleton.getBoneByName(c.objectIndex):void 0),!l||!u)return console.warn(`THREE.GLTFExporter: Could not export animation track "%s".`,r.name),null;let d=r.values.length/r.times.length;u===Lt.morphTargetInfluences&&(d/=l.morphTargetInfluences.length);let f;r.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline===!0?(f=`CUBICSPLINE`,d/=3):f=r.getInterpolation()===e.InterpolateDiscrete?`STEP`:`LINEAR`,s.push({input:this.processAccessor(new e.BufferAttribute(r.times,1)),output:this.processAccessor(new e.BufferAttribute(r.values,d)),interpolation:f}),o.push({sampler:s.length-1,target:{node:i.get(l),path:u}})}return r.animations.push({name:t.name||`clip_`+r.animations.length,samplers:s,channels:o}),r.animations.length-1}processSkin(t){let n=this.json,r=this.nodeMap,i=n.nodes[r.get(t)],a=t.skeleton;if(a===void 0)return null;let o=t.skeleton.bones[0];if(o===void 0)return null;let s=[],c=new Float32Array(a.bones.length*16),l=new e.Matrix4;for(let e=0;e<a.bones.length;++e)s.push(r.get(a.bones[e])),l.copy(a.boneInverses[e]),l.multiply(t.bindMatrix).toArray(c,e*16);return n.skins===void 0&&(n.skins=[]),n.skins.push({inverseBindMatrices:this.processAccessor(new e.BufferAttribute(c,16)),joints:s,skeleton:r.get(o)}),i.skin=n.skins.length-1}processNode(e){let t=this.json,n=this.options,r=this.nodeMap;t.nodes||=[];let i={};if(n.trs){let t=e.quaternion.toArray(),n=e.position.toArray(),r=e.scale.toArray();Wt(t,[0,0,0,1])||(i.rotation=t),Wt(n,[0,0,0])||(i.translation=n),Wt(r,[1,1,1])||(i.scale=r)}else e.matrixAutoUpdate&&e.updateMatrix(),Kt(e.matrix)===!1&&(i.matrix=e.matrix.elements);if(e.name!==``&&(i.name=String(e.name)),this.serializeUserData(e,i),e.isMesh||e.isLine||e.isPoints){let t=this.processMesh(e);t!==null&&(i.mesh=t)}else e.isCamera&&(i.camera=this.processCamera(e));if(e.isSkinnedMesh&&this.skins.push(e),e.children.length>0){let t=[];for(let r=0,i=e.children.length;r<i;r++){let i=e.children[r];if(i.visible||n.onlyVisible===!1){let e=this.processNode(i);e!==null&&t.push(e)}}t.length>0&&(i.children=t)}this._invokeAll(function(t){t.writeNode&&t.writeNode(e,i)});let a=t.nodes.push(i)-1;return r.set(e,a),a}processScene(e){let t=this.json,n=this.options;t.scenes||(t.scenes=[],t.scene=0);let r={};e.name!==``&&(r.name=e.name),t.scenes.push(r);let i=[];for(let t=0,r=e.children.length;t<r;t++){let r=e.children[t];if(r.visible||n.onlyVisible===!1){let e=this.processNode(r);e!==null&&i.push(e)}}i.length>0&&(r.nodes=i),this.serializeUserData(e,r)}processObjects(t){let n=new e.Scene;n.name=`AuxScene`;for(let e=0;e<t.length;e++)n.children.push(t[e]);this.processScene(n)}processInput(t){let n=this.options;t=t instanceof Array?t:[t],this._invokeAll(function(e){e.beforeParse&&e.beforeParse(t)});let r=[];for(let n=0;n<t.length;n++)t[n]instanceof e.Scene?this.processScene(t[n]):r.push(t[n]);r.length>0&&this.processObjects(r);for(let e=0;e<this.skins.length;++e)this.processSkin(this.skins[e]);for(let e=0;e<n.animations.length;++e)this.processAnimation(n.animations[e].clip,n.animations[e].mesh);this._invokeAll(function(e){e.afterParse&&e.afterParse(t)})}_invokeAll(e){for(let t=0,n=this.plugins.length;t<n;t++)e(this.plugins[t])}},Qt=class{constructor(e){this.writer=e,this.name=`KHR_lights_punctual`}writeNode(e,t){if(!e.isLight)return;if(!e.isDirectionalLight&&!e.isPointLight&&!e.isSpotLight){console.warn(`THREE.GLTFExporter: Only directional, point, and spot lights are supported.`,e);return}let n=this.writer,r=n.json,i=n.extensionsUsed,a={};e.name&&(a.name=e.name),a.color=e.color.toArray(),a.intensity=e.intensity,e.isDirectionalLight?a.type=`directional`:e.isPointLight?(a.type=`point`,e.distance>0&&(a.range=e.distance)):e.isSpotLight&&(a.type=`spot`,e.distance>0&&(a.range=e.distance),a.spot={},a.spot.innerConeAngle=(e.penumbra-1)*e.angle*-1,a.spot.outerConeAngle=e.angle),e.decay!==void 0&&e.decay!==2&&console.warn(`THREE.GLTFExporter: Light decay may be lost. glTF is physically-based, and expects light.decay=2.`),e.target&&(e.target.parent!==e||e.target.position.x!==0||e.target.position.y!==0||e.target.position.z!==-1)&&console.warn(`THREE.GLTFExporter: Light direction may be lost. For best results, make light.target a child of the light with position 0,0,-1.`),i[this.name]||(r.extensions=r.extensions||{},r.extensions[this.name]={lights:[]},i[this.name]=!0);let o=r.extensions[this.name].lights;o.push(a),t.extensions=t.extensions||{},t.extensions[this.name]={light:o.length-1}}},$t=class{constructor(e){this.writer=e,this.name=`KHR_materials_unlit`}writeMaterial(e,t){if(!e.isMeshBasicMaterial)return;let n=this.writer.extensionsUsed;t.extensions=t.extensions||{},t.extensions[this.name]={},n[this.name]=!0,t.pbrMetallicRoughness.metallicFactor=0,t.pbrMetallicRoughness.roughnessFactor=.9}},en=class{constructor(e){this.writer=e,this.name=`KHR_materials_pbrSpecularGlossiness`}writeMaterial(e,t){if(!e.isGLTFSpecularGlossinessMaterial)return;let n=this.writer,r=n.extensionsUsed,i={};t.pbrMetallicRoughness.baseColorFactor&&(i.diffuseFactor=t.pbrMetallicRoughness.baseColorFactor);let a=[1,1,1];if(e.specular.toArray(a,0),i.specularFactor=a,i.glossinessFactor=e.glossiness,t.pbrMetallicRoughness.baseColorTexture&&(i.diffuseTexture=t.pbrMetallicRoughness.baseColorTexture),e.specularMap){let t={index:n.processTexture(e.specularMap)};n.applyTextureTransform(t,e.specularMap),i.specularGlossinessTexture=t}t.extensions=t.extensions||{},t.extensions[this.name]=i,r[this.name]=!0}};It.Utils={insertKeyframe:function(e,t){let n=.001,r=e.getValueSize(),i=new e.TimeBufferType(e.times.length+1),a=new e.ValueBufferType(e.values.length+r),o=e.createInterpolant(new e.ValueBufferType(r)),s;if(e.times.length===0){i[0]=t;for(let e=0;e<r;e++)a[e]=0;s=0}else if(t<e.times[0]){if(Math.abs(e.times[0]-t)<n)return 0;i[0]=t,i.set(e.times,1),a.set(o.evaluate(t),0),a.set(e.values,r),s=0}else if(t>e.times[e.times.length-1]){if(Math.abs(e.times[e.times.length-1]-t)<n)return e.times.length-1;i[i.length-1]=t,i.set(e.times,0),a.set(e.values,0),a.set(o.evaluate(t),e.values.length),s=i.length-1}else for(let c=0;c<e.times.length;c++){if(Math.abs(e.times[c]-t)<n)return c;if(e.times[c]<t&&e.times[c+1]>t){i.set(e.times.slice(0,c+1),0),i[c+1]=t,i.set(e.times.slice(c+1),c+2),a.set(e.values.slice(0,(c+1)*r),0),a.set(o.evaluate(t),(c+1)*r),a.set(e.values.slice((c+1)*r),(c+2)*r),s=c+1;break}}return e.times=i,e.values=a,s},mergeMorphTargetTracks:function(t,n){let r=[],i={},a=t.tracks;for(let t=0;t<a.length;++t){let o=a[t],s=e.PropertyBinding.parseTrackName(o.name),c=e.PropertyBinding.findNode(n,s.nodeName);if(s.propertyName!==`morphTargetInfluences`||s.propertyIndex===void 0){r.push(o);continue}if(o.createInterpolant!==o.InterpolantFactoryMethodDiscrete&&o.createInterpolant!==o.InterpolantFactoryMethodLinear){if(o.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline)throw Error(`THREE.GLTFExporter: Cannot merge tracks with glTF CUBICSPLINE interpolation.`);console.warn(`THREE.GLTFExporter: Morph target interpolation mode not yet supported. Using LINEAR instead.`),o=o.clone(),o.setInterpolation(e.InterpolateLinear)}let l=c.morphTargetInfluences.length,u=c.morphTargetDictionary[s.propertyIndex];if(u===void 0)throw Error(`THREE.GLTFExporter: Morph target name not found: `+s.propertyIndex);let d;if(i[c.uuid]===void 0){d=o.clone();let e=new d.ValueBufferType(l*d.times.length);for(let t=0;t<d.times.length;t++)e[t*l+u]=d.values[t];d.name=(s.nodeName||``)+`.morphTargetInfluences`,d.values=e,i[c.uuid]=d,r.push(d);continue}let f=o.createInterpolant(new o.ValueBufferType(1));d=i[c.uuid];for(let e=0;e<d.times.length;e++)d.values[e*l+u]=f.evaluate(d.times[e]);for(let e=0;e<o.times.length;e++){let t=this.insertKeyframe(d,o.times[e]);d.values[t*l+u]=o.values[e]}}return t.tracks=r,t}};var tn=function(e){let t=e;this.exportGLTF=e=>{let n=t.getRootRegion().getAllObjects(!0),r=[];n.forEach(e=>{e.animationClip&&r.push({clip:e.animationClip[0],mesh:e.getMorph()})});let i=new It,a={binary:e,animations:r};return new Promise((e,n)=>{i.parse(t.getThreeJSScene(),function(t){e(t)},a)})}},nn=function(){let e=this;this.parseGLTFObjects=(t,n,r,i)=>{let a=n;if(r!==0){if(t.type===`Object3D`){if(t.name!==``&&(n&&(a=n.findOrCreateChildFromPath(t.name)),a)){let e=a.getGroup();e.position.copy(t.position),e.rotation.copy(t.rotation),e.quaternion.copy(t.quaternion),e.matrixAutoUpdate=!0}}else{let e;if(t.type===`Mesh`?e=new Ce:t.type===`LineSegments`?e=new Ye:t.type===`Points`&&(e=new Je),e){let r=!1,a=!1;t.geometry&&t.geometry.morphAttributes&&(r=!!t.geometry.morphAttributes.position,a=!!t.geometry.morphAttributes.color),e.setMesh(t.clone(),r,a);let o=e.getMorph();e.groupName=o.name,o.matrixAutoUpdate=!0,n.addZincObject(e),i!=null&&typeof i==`function`&&i(e)}}}r++,t.children.forEach(t=>{e.parseGLTFObjects(t,a,r,i)})},this.setCamera=e=>{e.viewAll();let t=e.getZincCameraControls(),n=t.getCurrentViewport();t.addViewport(`default`,n),t.setDefaultViewport(`default`)},this.load=(t,n,i,a,o,s)=>{let c=i.substring(0,i.lastIndexOf(`/`)+1),l=i.substring(i.lastIndexOf(`/`)+1,i.length);new r.GLTFLoader().setPath(c).load(l,function(r){console.log(r),e.parseGLTFObjects(r.scene,n,0,a),e.setCamera(t),o!=null&&typeof o==`function`&&o()})}},rn=/^[og]\s*(.+)?/,an=/^mtllib /,on=/^usemtl /,sn=/^usemap /,cn=new e.Vector3,ln=new e.Vector3,un=new e.Vector3,dn=new e.Vector3,Y=new e.Vector3;function fn(){let e={objects:[],object:{},vertices:[],normals:[],colors:[],uvs:[],materials:{},materialLibraries:[],startObject:function(e,t){if(this.object&&this.object.fromDeclaration===!1){this.object.name=e,this.object.fromDeclaration=t!==!1;return}let n=this.object&&typeof this.object.currentMaterial==`function`?this.object.currentMaterial():void 0;if(this.object&&typeof this.object._finalize==`function`&&this.object._finalize(!0),this.object={name:e||``,fromDeclaration:t!==!1,geometry:{vertices:[],normals:[],colors:[],uvs:[],hasUVIndices:!1},materials:[],smooth:!0,startMaterial:function(e,t){let n=this._finalize(!1);n&&(n.inherited||n.groupCount<=0)&&this.materials.splice(n.index,1);let r={index:this.materials.length,name:e||``,mtllib:Array.isArray(t)&&t.length>0?t[t.length-1]:``,smooth:n===void 0?this.smooth:n.smooth,groupStart:n===void 0?0:n.groupEnd,groupEnd:-1,groupCount:-1,inherited:!1,clone:function(e){let t={index:typeof e==`number`?e:this.index,name:this.name,mtllib:this.mtllib,smooth:this.smooth,groupStart:0,groupEnd:-1,groupCount:-1,inherited:!1};return t.clone=this.clone.bind(t),t}};return this.materials.push(r),r},currentMaterial:function(){if(this.materials.length>0)return this.materials[this.materials.length-1]},_finalize:function(e){let t=this.currentMaterial();if(t&&t.groupEnd===-1&&(t.groupEnd=this.geometry.vertices.length/3,t.groupCount=t.groupEnd-t.groupStart,t.inherited=!1),e&&this.materials.length>1)for(let e=this.materials.length-1;e>=0;e--)this.materials[e].groupCount<=0&&this.materials.splice(e,1);return e&&this.materials.length===0&&this.materials.push({name:``,smooth:this.smooth}),t}},n&&n.name&&typeof n.clone==`function`){let e=n.clone(0);e.inherited=!0,this.object.materials.push(e)}this.objects.push(this.object)},finalize:function(){this.object&&typeof this.object._finalize==`function`&&this.object._finalize(!0)},parseVertexIndex:function(e,t){let n=parseInt(e,10);return(n>=0?n-1:n+t/3)*3},parseNormalIndex:function(e,t){let n=parseInt(e,10);return(n>=0?n-1:n+t/3)*3},parseUVIndex:function(e,t){let n=parseInt(e,10);return(n>=0?n-1:n+t/2)*2},addVertex:function(e,t,n){let r=this.vertices,i=this.object.geometry.vertices;i.push(r[e+0],r[e+1],r[e+2]),i.push(r[t+0],r[t+1],r[t+2]),i.push(r[n+0],r[n+1],r[n+2])},addVertexPoint:function(e){let t=this.vertices;this.object.geometry.vertices.push(t[e+0],t[e+1],t[e+2])},addVertexLine:function(e){let t=this.vertices;this.object.geometry.vertices.push(t[e+0],t[e+1],t[e+2])},addNormal:function(e,t,n){let r=this.normals,i=this.object.geometry.normals;i.push(r[e+0],r[e+1],r[e+2]),i.push(r[t+0],r[t+1],r[t+2]),i.push(r[n+0],r[n+1],r[n+2])},addFaceNormal:function(e,t,n){let r=this.vertices,i=this.object.geometry.normals;cn.fromArray(r,e),ln.fromArray(r,t),un.fromArray(r,n),Y.subVectors(un,ln),dn.subVectors(cn,ln),Y.cross(dn),Y.normalize(),i.push(Y.x,Y.y,Y.z),i.push(Y.x,Y.y,Y.z),i.push(Y.x,Y.y,Y.z)},addColor:function(e,t,n){let r=this.colors,i=this.object.geometry.colors;r[e]!==void 0&&i.push(r[e+0],r[e+1],r[e+2]),r[t]!==void 0&&i.push(r[t+0],r[t+1],r[t+2]),r[n]!==void 0&&i.push(r[n+0],r[n+1],r[n+2])},addUV:function(e,t,n){let r=this.uvs,i=this.object.geometry.uvs;i.push(r[e+0],r[e+1]),i.push(r[t+0],r[t+1]),i.push(r[n+0],r[n+1])},addDefaultUV:function(){let e=this.object.geometry.uvs;e.push(0,0),e.push(0,0),e.push(0,0)},addUVLine:function(e){let t=this.uvs;this.object.geometry.uvs.push(t[e+0],t[e+1])},addFace:function(e,t,n,r,i,a,o,s,c){let l=this.vertices.length,u=this.parseVertexIndex(e,l),d=this.parseVertexIndex(t,l),f=this.parseVertexIndex(n,l);if(this.addVertex(u,d,f),this.addColor(u,d,f),o!==void 0&&o!==``){let e=this.normals.length;u=this.parseNormalIndex(o,e),d=this.parseNormalIndex(s,e),f=this.parseNormalIndex(c,e),this.addNormal(u,d,f)}else this.addFaceNormal(u,d,f);if(r!==void 0&&r!==``){let e=this.uvs.length;u=this.parseUVIndex(r,e),d=this.parseUVIndex(i,e),f=this.parseUVIndex(a,e),this.addUV(u,d,f),this.object.geometry.hasUVIndices=!0}else this.addDefaultUV()},addPointGeometry:function(e){this.object.geometry.type=`Points`;let t=this.vertices.length;for(let n=0,r=e.length;n<r;n++){let r=this.parseVertexIndex(e[n],t);this.addVertexPoint(r),this.addColor(r)}},addLineGeometry:function(e,t){this.object.geometry.type=`Line`;let n=this.vertices.length,r=this.uvs.length;for(let t=0,r=e.length;t<r;t++)this.addVertexLine(this.parseVertexIndex(e[t],n));for(let e=0,n=t.length;e<n;e++)this.addUVLine(this.parseUVIndex(t[e],r))}};return e.startObject(``,!1),e}var pn=class extends e.Loader{constructor(e){super(e),this.materials=null}load(t,n,r,i){let a=this,o=new e.FileLoader(this.manager);o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(t,function(e){try{n(a.parse(e))}catch(e){i?i(e):console.error(e),a.manager.itemError(t)}},r,i)}setMaterials(e){return this.materials=e,this}parse(t){let n=new fn;t.indexOf(`\r
288
+ `)!==-1&&(t=t.replace(/\r\n/g,`
289
+ `)),t.indexOf(`\\
290
+ `)!==-1&&(t=t.replace(/\\\n/g,``));let r=t.split(`
291
+ `),i=``,a=``,o=0,s=[],c=typeof``.trimLeft==`function`;for(let e=0,t=r.length;e<t;e++)if(i=r[e],i=c?i.trimLeft():i.trim(),o=i.length,o!==0&&(a=i.charAt(0),a!==`#`)){if(a===`v`){let e=i.split(/\s+/);switch(e[0]){case`v`:n.vertices.push(parseFloat(e[1]),parseFloat(e[2]),parseFloat(e[3])),e.length>=7?n.colors.push(parseFloat(e[4]),parseFloat(e[5]),parseFloat(e[6])):n.colors.push(void 0,void 0,void 0);break;case`vn`:n.normals.push(parseFloat(e[1]),parseFloat(e[2]),parseFloat(e[3]));break;case`vt`:n.uvs.push(parseFloat(e[1]),parseFloat(e[2]))}}else if(a===`f`){let e=i.substr(1).trim().split(/\s+/),t=[];for(let n=0,r=e.length;n<r;n++){let r=e[n];if(r.length>0){let e=r.split(`/`);t.push(e)}}let r=t[0];for(let e=1,i=t.length-1;e<i;e++){let i=t[e],a=t[e+1];n.addFace(r[0],i[0],a[0],r[1],i[1],a[1],r[2],i[2],a[2])}}else if(a===`l`){let e=i.substring(1).trim().split(` `),t=[],r=[];if(i.indexOf(`/`)===-1)t=e;else for(let n=0,i=e.length;n<i;n++){let i=e[n].split(`/`);i[0]!==``&&t.push(i[0]),i[1]!==``&&r.push(i[1])}n.addLineGeometry(t,r)}else if(a===`p`){let e=i.substr(1).trim().split(` `);n.addPointGeometry(e)}else if((s=rn.exec(i))!==null){let e=(` `+s[0].substr(1).trim()).substr(1);n.startObject(e)}else if(on.test(i))n.object.startMaterial(i.substring(7).trim(),n.materialLibraries);else if(an.test(i))n.materialLibraries.push(i.substring(7).trim());else if(sn.test(i))console.warn(`THREE.OBJLoader: Rendering identifier "usemap" not supported. Textures must be defined in MTL files.`);else if(a===`s`){if(s=i.split(` `),s.length>1){let e=s[1].trim().toLowerCase();n.object.smooth=e!==`0`&&e!==`off`}else n.object.smooth=!0;let e=n.object.currentMaterial();e&&(e.smooth=n.object.smooth)}else{if(i===`\0`)continue;console.warn(`THREE.OBJLoader: Unexpected line: "`+i+`"`)}}n.finalize();let l=new e.Group;if(l.materialLibraries=[].concat(n.materialLibraries),n.objects.length!==1||n.objects[0].geometry.vertices.length!==0)for(let t=0,r=n.objects.length;t<r;t++){let r=n.objects[t],i=r.geometry,a=r.materials,o=i.type===`Line`,s=i.type===`Points`,c=!1;if(i.vertices.length===0)continue;let u=new e.BufferGeometry;u.setAttribute(`position`,new e.Float32BufferAttribute(i.vertices,3)),i.normals.length>0&&u.setAttribute(`normal`,new e.Float32BufferAttribute(i.normals,3)),i.colors.length>0&&(c=!0,u.setAttribute(`color`,new e.Float32BufferAttribute(i.colors,3))),i.hasUVIndices===!0&&u.setAttribute(`uv`,new e.Float32BufferAttribute(i.uvs,2));let d=[];for(let t=0,r=a.length;t<r;t++){let r=a[t],i=r.name+`_`+r.smooth+`_`+c,l=n.materials[i];if(this.materials!==null){if(l=this.materials.create(r.name),o&&l&&!(l instanceof e.LineBasicMaterial)){let t=new e.LineBasicMaterial;e.Material.prototype.copy.call(t,l),t.color.copy(l.color),l=t}else if(s&&l&&!(l instanceof e.PointsMaterial)){let t=new e.PointsMaterial({size:10,sizeAttenuation:!1});e.Material.prototype.copy.call(t,l),t.color.copy(l.color),t.map=l.map,l=t}}l===void 0&&(l=o?new e.LineBasicMaterial:s?new e.PointsMaterial({size:1,sizeAttenuation:!1}):new e.MeshPhongMaterial,l.name=r.name,l.flatShading=!r.smooth,l.vertexColors=c,n.materials[i]=l),d.push(l)}let f;if(d.length>1){for(let e=0,t=a.length;e<t;e++){let t=a[e];u.addGroup(t.groupStart,t.groupCount,e)}f=o?new e.LineSegments(u,d):s?new e.Points(u,d):new e.Mesh(u,d)}else f=o?new e.LineSegments(u,d[0]):s?new e.Points(u,d[0]):new e.Mesh(u,d[0]);f.name=r.name,l.add(f)}else if(n.vertices.length>0){let t=new e.PointsMaterial({size:1,sizeAttenuation:!1}),r=new e.BufferGeometry;r.setAttribute(`position`,new e.Float32BufferAttribute(n.vertices,3)),n.colors.length>0&&n.colors[0]!==void 0&&(r.setAttribute(`color`,new e.Float32BufferAttribute(n.colors,3)),t.vertexColors=!0);let i=new e.Points(r,t);l.add(i)}return l}},mn=e.FileLoader,hn=e=>{let t=(e,t)=>{e.metadata.number_of_vertices+=t.metadata.number_of_vertices,`labels`in e&&e.labels.push(...e.labels),[`axis1`,`axis2`,`axis3`,`colors`,`positions`,`scale`].forEach(n=>{n in e&&Object.keys(e[n]).forEach(r=>{let i=t[n][r].length;for(let a=0;a<i;a++)e[n][r].push(t[n][r][a])})})};if(e&&e.length>0)for(;e.length>1;){let n=e.splice(1,1);t(e[0],n[0])}},gn=e=>{let t=(e,t)=>{e.merge(t)};if(e&&e.length>0){for(;e.length>1;){let n=e.splice(1,1);t(e[0],n[0])}return e[0]}},_n=function(e,t,n){let r=new mn,i=new Le;r.crossOrigin=t;let a=e,o=n,s,c=!1,l=!1,u,d=[],f=e=>{let t=s[e.index];if(t){if(`GlyphGeometriesURL`in t)e.onLoad(t);else{let n=i.parse(t);e.onLoad(n.geometry,n.materials)}}else p(e,{responseURL:a})},p=e=>{e.onError&&(u||={responseURL:a},e.onError(u))};this.downloadCompleted=e=>{try{s=JSON.parse(e[0]),c=!1,l=!0,Array.isArray(s)?d.forEach(e=>f(e)):d.forEach(e=>p(e))}catch{d.forEach(e=>p(e))}};let m=()=>e=>{u=e,l=!0,c=!1,d.forEach(e=>{p(e)})},h=()=>e=>{d.forEach(t=>{t.onProgress&&t.onProgress(e)})};this.load=(e,t,n,i)=>{let g={index:e,onLoad:t,onProgress:n,onError:i};l?s?f(g):p(u):c?d.push(g):(d.push(g),c=!0,r.load(a,o,h,m))}},vn=function(e,t,n){let r=[],i=e,a=t,o=0,s=n.isGlyphsets;this.itemDownloaded=(e,t)=>{if(r[e]=t,o++,o==i&&r.length>0){if(s){let e=r.map(e=>JSON.parse(e[0]));hn(e),a(e[0])}else{let t=r[0][1],n=gn(r.map(e=>e[0]));for(let t=1;t<i;t++)r[e][0].dispose(),r[e][1].forEach(e=>e.dispose());a(n,t)}}}},yn=function(){let e=0;this.crossOrigin=`Anonymous`;let t=new Le,n=new mn;n.crossOrigin=`Anonymous`;let r=[],i={},a=(e,t,n,r,i)=>{let a=e.length,o=new vn(a,t,i),c=0;e.forEach(e=>{let a=i?{...i}:{};a.msHandler=o,a.order=c,c++,s(e,t,n,r,a)})},o=(t,n,a,o,s)=>{let l=s?{...s}:{},u=i[t];if(!u){if(20>e){let n=new c(void 0,this,l);++e,u=new _n(t,this.crossOrigin,n),i[t]=u}else r.push({url:t,onLoad:n,onProgress:a,onError:o,options:s})}u&&(l.isHandler=u,u.load(s.index,n,a,o))},s=(i,a,s,l,u)=>{if(u&&u.index!==void 0)o(i,a,s,l,u);else if(20>e){++e;let r=new c(a,this,u),o=new c(l,this,u);u.isGlyphsets?n.load(i,r,s,o):(t.crossOrigin=this.crossOrigin,t.load(i,r,s,o))}else r.push({url:i,onLoad:a,onProgress:s,onError:l,options:u})};this.load=(e,t,n,r,i)=>{Array.isArray(e)?a(e,t,n,r,i):s(e,t,n,r,i)},this.loadFromWaitingList=()=>{for(;20>e;){let e=r.shift();if(e)this.load(e.url,e.onLoad,e.onProgress,e.onError,e.options);else return}},this.itemRemainingCheck=()=>{if(r.length===0&&e===0)for(let e in i)i.hasOwnProperty(e)&&delete i[e]};let c=function(t,n,r){return(...i)=>{--e,r?.msHandler?r.msHandler.itemDownloaded(r.order,i):r?.isHandler?r.isHandler.downloadCompleted(i):t&&t(...i),n.loadFromWaitingList(),n.itemRemainingCheck()}};this.parse=e=>loader.parse(e)},bn=class extends e.Loader{constructor(e){super(e)}load(t,n,r,i){let a=this,o=new e.FileLoader(this.manager);o.setPath(this.path),o.setResponseType(`arraybuffer`),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(t,function(e){try{n(a.parse(e))}catch(e){i?i(e):console.error(e),a.manager.itemError(t)}},r,i)}parse(t){function n(e){let t=new DataView(e);if(84+t.getUint32(80,!0)*50===t.byteLength)return!0;let n=[115,111,108,105,100];for(let e=0;e<5;e++)if(r(n,t,e))return!1;return!0}function r(e,t,n){for(let r=0,i=e.length;r<i;r++)if(e[r]!==t.getUint8(n+r,!1))return!1;return!0}function i(t){let n=new DataView(t),r=n.getUint32(80,!0),i,a,o,s=!1,c,l,u,d,f;for(let e=0;e<70;e++)n.getUint32(e,!1)==1129270351&&n.getUint8(e+4)==82&&n.getUint8(e+5)==61&&(s=!0,c=new Float32Array(r*3*3),l=n.getUint8(e+6)/255,u=n.getUint8(e+7)/255,d=n.getUint8(e+8)/255,f=n.getUint8(e+9)/255);let p=new e.BufferGeometry,m=new Float32Array(r*3*3),h=new Float32Array(r*3*3);for(let e=0;e<r;e++){let t=84+e*50,r=n.getFloat32(t,!0),f=n.getFloat32(t+4,!0),p=n.getFloat32(t+8,!0);if(s){let e=n.getUint16(t+48,!0);e&32768?(i=l,a=u,o=d):(i=(e&31)/31,a=(e>>5&31)/31,o=(e>>10&31)/31)}for(let l=1;l<=3;l++){let u=t+l*12,d=e*3*3+(l-1)*3;m[d]=n.getFloat32(u,!0),m[d+1]=n.getFloat32(u+4,!0),m[d+2]=n.getFloat32(u+8,!0),h[d]=r,h[d+1]=f,h[d+2]=p,s&&(c[d]=i,c[d+1]=a,c[d+2]=o)}}return p.setAttribute(`position`,new e.BufferAttribute(m,3)),p.setAttribute(`normal`,new e.BufferAttribute(h,3)),s&&(p.setAttribute(`color`,new e.BufferAttribute(c,3)),p.hasColors=!0,p.alpha=f),p}function a(t){let n=new e.BufferGeometry,r=/solid([\s\S]*?)endsolid/g,i=/facet([\s\S]*?)endfacet/g,a=0,o=`[\\s]+([+-]?(?:\\d*)(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)`,s=RegExp(`vertex`+o+o+o,`g`),c=RegExp(`normal`+o+o+o,`g`),l=[],u=[],d=new e.Vector3,f,p=0,m=0,h=0;for(;(f=r.exec(t))!==null;){m=h;let e=f[0];for(;(f=i.exec(e))!==null;){let e=0,t=0,n=f[0];for(;(f=c.exec(n))!==null;)d.x=parseFloat(f[1]),d.y=parseFloat(f[2]),d.z=parseFloat(f[3]),t++;for(;(f=s.exec(n))!==null;)l.push(parseFloat(f[1]),parseFloat(f[2]),parseFloat(f[3])),u.push(d.x,d.y,d.z),e++,h++;t!==1&&console.error(`THREE.STLLoader: Something isn't right with the normal of face number `+a),e!==3&&console.error(`THREE.STLLoader: Something isn't right with the vertices of face number `+a),a++}let t=m,r=h-m;n.addGroup(t,r,p),p++}return n.setAttribute(`position`,new e.Float32BufferAttribute(l,3)),n.setAttribute(`normal`,new e.Float32BufferAttribute(u,3)),n}function o(t){return typeof t==`string`?t:e.LoaderUtils.decodeText(new Uint8Array(t))}function s(e){if(typeof e==`string`){let t=new Uint8Array(e.length);for(let n=0;n<e.length;n++)t[n]=e.charCodeAt(n)&255;return t.buffer||t}return e}let c=s(t);return n(c)?i(c):a(o(t))}},xn=function(){B.call(this),this.isTubeLines=!0;let t={},n={radius:1,radialSegments:8,smooth:!1};this.createLineSegment=(n,i,a)=>{if(n&&i){t={geometryIn:n,materialIn:i,options:a};let o=r(n.vertices),s=new e.MeshStandardMaterial({color:i.color}),c=new e.Mesh(o,s);this.setMesh(c,a.localTimeEnabled,a.localMorphColour)}},this.setWidth=e=>{this.morph&&this.morph.material&&(this.morph.material.linewidth=e,this.morph.material.needsUpdate=!0)},this.setAlpha=function(e){let t=this.getMorph();t.material.opacity=e,t.material.transparent=e<1,t.material.depthWrite=e>.5},this.setWireframe=e=>{let t=this.getMorph();t.material.wireframe=e},this.setTubeLines=(e,i)=>{if(e&&i){let{geometryIn:a}=t,o=this.getMorph();o.geometry.dispose(),n=Object.assign(n,{radius:e,radialSegments:i}),o.geometry=r(a.vertices)}};let r=t=>{let{radius:r,radialSegments:i,smooth:a}=n,o;if(a){let n=new e.CatmullRomCurve3(t);o=new e.TubeGeometry(n,t.length,r,i,!1)}else{let n=[];for(let a=0;a+1<t.length;a+=2){let o=new e.LineCurve3(t[a],t[a+1]),s=new e.TubeGeometry(o,1,r,i,!1);n.push(s)}o=M(n,!0),n.forEach(e=>e.dispose())}return o}};xn.prototype=Object.create(B.prototype);var Sn=function(t){let n=t;this.toBeDownloaded=0,this.progressMap={};let r=!1,i=!1,a=new yn;this.getDownloadProgress=()=>{let e=0,t=0,n=!1;for(let r in this.progressMap){let i=this.progressMap[r];e+=i[1],t+=i[0],i[1]==0&&(n=!0)}return n&&(e=0),[e,t,i]},this.onProgress=e=>t=>{this.progressMap[e]=[t.loaded,t.total]},this.onError=e=>t=>{--this.toBeDownloaded,i=!0,console.error(`There is an issue with external resource ${t?.responseURL?`: `+t?.responseURL:``}.`),e&&e({type:`Error`,xhr:t})};let o=(e,t)=>{let i=t.Default;if(t.Inline)n.setupMultipleViews(i,t.Entries);else{let a=[];for(let[n,r]of Object.entries(t.Entries))if(e){let t=C(r,e);a.push(new Promise((e,r)=>{fetch(t).then(e=>e.json()).then(t=>e({key:n,data:t})).catch(e=>r(e))}))}Promise.all(a).then(e=>{let t={};e.forEach(e=>{t[e.key]=e.data}),n.setupMultipleViews(i,t);let a=n.getZincCameraControls();a&&a.setCurrentViewport(i),r=!0})}};this.loadViewURL=(e,t)=>{this.toBeDownloaded+=1;let i=e;fetch(i).then(e=>{if(!e.ok)throw Error(`HTTP error! status: ${e.status}`);return e.json()}).then(e=>{n.setupMultipleViews(`default`,{default:e}),n.resetView(),r=!0,--this.toBeDownloaded,t!==void 0&&typeof t==`function`&&t()}).catch(e=>{console.error(`Fetch failed for URL: ${i}`,e),this.onError(t)({responseURL:i})})},this.loadModelsURL=(e,t,n,r,i,o,s)=>{let c=t.length;this.toBeDownloaded+=c;for(let l=0;l<c;l++){let c=t[l],u=$.defaultMaterialColor,d=$.defaultOpacity;n!=null&&n[l]!=null&&(u=!!n[l]),r!=null&&r[l]!=null&&(d=r[l]);let f=0;i!=null&&i[l]!=null&&(f=!!i[l]);let p=0;o!=null&&o[l]!=null&&(p=!!o[l]),a.load(c,m(e,u,d,f,p,void 0,void 0,void 0,void 0,s),this.onProgress(c),this.onError(s))}},this.loadFromViewURL=(e,t,r)=>{let i=t+`_view.json`;fetch(i).then(e=>{if(!e.ok)throw Error(`HTTP error! status: ${e.status}`);return e.json()}).then(i=>{n.loadView(i);let a=[],o=t+`_`;for(let e=0;e<i.numberOfResources;e++){let t=o+(e+1)+`.json`;a.push(t)}this.loadModelsURL(e,a,i.colour,i.opacity,i.timeEnabled,i.morphColour,r)}).catch(e=>{console.error(`Failed to load view data from: ${i}`,e)})};let s=(t,r,i,o,s,c,l,u,d)=>(f,p)=>{let m=u?new xn:new Ye,h;p&&p[0]&&(h=new e.LineBasicMaterial({color:p[0].color.clone()}),1>p[0].opacity&&(h.transparent=!0),h.opacity=p[0].opacity,h.morphTargets=r,h.vertexColors=p[0].vertexColors);let g={};if(g.localTimeEnabled=r,g.localMorphColour=i,m&&(m.createLineSegment(f,h,g),m.setName(o),m.setAnatomicalId(s),m.setRenderOrder(c),t.addZincObject(m),m.setDuration(n.getDuration()),l&&l.levels))for(let[e,t]of Object.entries(l.levels))m.addLOD(a,e,t.URL,t.Index,l.preload);--this.toBeDownloaded,f.dispose(),d!=null&&typeof d==`function`&&d(m)};this.loadLinesURL=(e,t,n,r,i,o,c)=>{let l=0;this.toBeDownloaded+=1;let u=c?.isInline?c.isInline:!1,d=c?.anatomicalId?c.anatomicalId:void 0,f=c&&`renderOrder`in c?c.renderOrder:void 0;n!=null&&(l=!!n);let p=0;r!=null&&(p=!!r);let m=c.tubeLines&&!l&&!p;if(u){let n=a.parse(t);s(e,l,p,i,d,f,c.lod,m,o)(n.geometry,n.materials)}else a.load(t,s(e,l,p,i,d,f,c.lod,m,o),this.onProgress(t),this.onError(o),c.loaderOptions)};let c=(e,t,r,i,a)=>o=>{let s=o;(typeof s==`string`||s instanceof String)&&(s=JSON.parse(o));let c=a&&a.isInline?a.isInline:void 0,l=a&&a.anatomicalId?a.anatomicalId:void 0,u=!a?.displayLabels||a.displayLabels,d=a&&`renderOrder`in a?a.renderOrder:void 0,f=new Re;f.setDuration(n.getDuration()),f.groupName=r,++this.toBeDownloaded,f.load(s,t,()=>{--this.toBeDownloaded,i!=null&&typeof i==`function`&&i(f)},c,u),f.setAnatomicalId(l),f.setRenderOrder(d),e.addZincObject(f)};this.loadGlyphsetURL=(e,t,n,r,i,o)=>{o&&o.isInline&&o.isInline?c(e,n,r,i,o)(t):a.load(t,c(e,n,r,i,o),this.onProgress(t),this.onError(i),o.loaderOptions)};let l=(t,r,i,a,o,s,c)=>(l,u)=>{let d=new Je,f=new e.PointsMaterial({alphaTest:.5,size:10,sizeAttenuation:!1});u&&u[0]&&(1>u[0].opacity&&(f.transparent=!0),f.opacity=u[0].opacity,f.color=u[0].color,f.morphTargets=r,f.vertexColors=u[0].vertexColors);let p={};p.localTimeEnabled=r,p.localMorphColour=i,d&&(d.createMesh(l,f,p),d.setName(a),d.setAnatomicalId(o),t.addZincObject(d),d.setDuration(n.getDuration()),d.setRenderOrder(s)),l.dispose(),--this.toBeDownloaded,c!=null&&typeof c==`function`&&c(d)};this.loadSTL=(e,t,n,r)=>{this.toBeDownloaded+=1;let i=$.defaultMaterialColor,a=$.defaultOpacity,o=new bn;o.crossOrigin=`Anonymous`,o.load(t,m(e,i,a,!1,!1,n,void 0,void 0,void 0,r))},this.loadOBJ=(e,t,n,r)=>{this.toBeDownloaded+=1;let i=$.defaultMaterialColor,a=$.defaultOpacity,o=new pn;o.crossOrigin=`Anonymous`,o.load(t,m(e,i,a,!1,!1,n,void 0,void 0,void 0,r))};let u=(e,t,n,r,i,o,s)=>{this.toBeDownloaded+=1;let c=$.defaultMaterialColor,l=$.defaultOpacity,u=0,d=s&&s.isInline?s.isInline:!1,f=s&&s.fileFormat?s.fileFormat:void 0,p=s&&s.anatomicalId?s.anatomicalId:void 0,h=s&&`renderOrder`in s?s.renderOrder:void 0;n!=null&&(u=!!n);let g=0;r!=null&&(g=!!r);let _=a;if(f!==void 0){if(f==`STL`)_=new bn;else if(f==`OBJ`){_=new pn,_.crossOrigin=`Anonymous`,_.load(t,objloader(e,c,l,u,g,i,p,o),this.onProgress(t),this.onError,s.loaderOptions);return}}if(d){let n=a.parse(t);m(e,c,l,u,g,i,p,h,s,o)(n.geometry,n.materials)}else _.crossOrigin=`Anonymous`,a.load(t,m(e,c,l,u,g,i,p,h,s,o),this.onProgress(t),this.onError(o),s.loaderOptions)},d=function(e,t,i){let a=0;return o=>{if(a+=1,o&&t!=null&&typeof t==`function`&&t(o),a==e&&(r===!1&&n.viewAll(),i!=null&&typeof i==`function`)){i();let e=n.getZincCameraControls();e&&e.calculateMaxAllowedDistance(n)}}};this.loadPointsetURL=(e,t,n,r,i,o,s)=>{let c=0;this.toBeDownloaded+=1,n!=null&&(c=!!n);let u=0;r!=null&&(u=!!r);let d=s&&s.isInline?s.isInline:!1,f=s&&s.anatomicalId?s.anatomicalId:void 0,p=s&&`renderOrder`in s?s.renderOrder:void 0;if(d){let n=a.parse(t);l(e,c,u,i,f,p,o)(n.geometry,n.materials)}else a.load(t,l(e,c,u,i,f,p,o),this.onProgress(t),this.onError(o),s.loaderOptions)};let f=(e,t,n,r,i,a)=>{let o=a&&a.isInline?a.isInline:void 0,s=a&&a.anatomicalId?a.anatomicalId:void 0,c=a&&`renderOrder`in a?a.renderOrder:void 0,l;if(n){if(t&&n.images&&n.images.source){let e=n.images.source;for(let r=0;r<e.length;r++){let i=C(e[r],t);n.images.source[r]=i}}n.type===`slides`&&(l=new rt),l&&(l.groupName=r,++this.toBeDownloaded,l.load(n,()=>{e.addZincObject(l),--this.toBeDownloaded,i!=null&&typeof i==`function`&&i(l)},o),l.setAnatomicalId(s),l.setRenderOrder(c))}};this.loadTextureURL=(e,t,n,r,i)=>{if(i&&i.isInline&&i.isInline)f(e,void 0,t,n,r,i);else{let a=t;fetch(a).then(e=>{if(!e.ok)throw Error(`HTTP error! status: ${e.status}`);let t=e.url||new URL(a).href;return e.json().then(e=>({textureData:e,referenceURL:t}))}).then(({textureData:t,referenceURL:a})=>{f(e,a,t,n,r,i)}).catch(e=>{console.error(`Fetch failed for texture URL: ${a}`,e)})}};let p=(e,t,r,i,a,o,s,c,l,u,d)=>{let f={};f.colour=r,f.opacity=i,f.localTimeEnabled=a,f.localMorphColour=o;let p=new Ce;if(p.createMesh(t,c,f),p.getMorph())return p.setName(l),p.setRenderOrder(u),p.setAnatomicalId(d),e&&e.addZincObject(p),p.setDuration(n.getDuration()),s!=null&&typeof s==`function`&&s(p),p.videoHandler&&n.setVideoHandler(p.videoHandler),p},m=(e,t,n,r,i,o,s,c,l,u)=>(d,f)=>{let m;f&&f[0]&&(m=f[0]);let h=p(e,d,t,n,r,i,void 0,m,o,c,s);if(l.lod&&l.lod.levels)for(let[e,t]of Object.entries(l.lod.levels))h.addLOD(a,e,t.URL,t.Index,l.lod.preload);--this.toBeDownloaded,d.dispose(),u!=null&&typeof u==`function`&&u(h)},h=e=>{let[,t,n,r,i,a,o,s]=e.match(/P(?:(\d+)Y)?(?:(\d+)M)?(?:(\d+)W)?(?:(\d+)D)?(?:T(?:(\d+)H)?(?:(\d+)M)?(?:(\d+)S)?)?$/);return{years:t,months:n,weeks:r,days:i,hours:a,mins:o,secs:s}};this.loadSettings=e=>{if(e){if(e.Duration){let t=h(e.Duration);n.setDurationFromObject(t)}if(e.OriginalDuration){let t=h(e.OriginalDuration);n.setOriginalDurationFromObject(t)}if(e.TimeStamps)for(let t in e.TimeStamps){let r=h(e.TimeStamps[t]);n.addMetadataTimeStamp(t,r)}}};let g=(e,t,n,r,i)=>{if(n){let a,o=!1;n.URL?(a=n.URL,t&&(a=C(a,t))):n.Inline&&(a=n.Inline.URL,o=!0);let s={};if(n.LOD&&n.LOD.Levels){s.preload=!!n.LOD.Preload,s.levels={};for(let[e,r]of Object.entries(n.LOD.Levels))s.levels[e]={},s.levels[e].URL=C(r.URL,t),s.levels[e].Index=r.Index}let c=n.GroupName;(c===void 0||c===``)&&(c=`_Unnamed`);let l={loaderOptions:{index:n.Index},isInline:o,fileFormat:n.FileFormat,anatomicalId:n.AnatomicalId,compression:n.compression,tubeLines:n.tubeLines,lod:s,renderOrder:r};switch(n.Type){case`Surfaces`:u(e,a,n.MorphVertices,n.MorphColours,c,i,l);break;case`Glyph`:let r;o?r=n.Inline.GlyphGeometriesURL:(r=n.GlyphGeometriesURL,r=C(n.GlyphGeometriesURL,t)),l.displayLabels=!n.displayLabels||n.displayLabels,l.loaderOptions.isGlyphsets=!0,this.loadGlyphsetURL(e,a,r,c,i,l);break;case`Points`:this.loadPointsetURL(e,a,n.MorphVertices,n.MorphColours,c,i,l);break;case`Lines`:this.loadLinesURL(e,a,n.MorphVertices,n.MorphColours,c,i,l);break;case`Texture`:this.loadTextureURL(e,a,c,i,l)}}},_=(e,t,i)=>{if(t){let a,o=!1;switch(t.URL?(a=t.URL,e&&(a=C(t.URL,e))):t.Inline&&(a=t.Inline.URL,o=!0),t.Type){case`View`:o?(n.setupMultipleViews(`default`,{default:a}),r=!0,i!=null&&typeof i==`function`&&i()):this.loadViewURL(a,i);break;case`Settings`:this.loadSettings(t)}}};this.loadGLTF=(e,t,r,i,a)=>{new nn().load(n,e,t,r,i,a)};let v=(e,t,n,r)=>{if(n.Primitives&&n.Primitives.forEach(n=>{let i=1;n.Order&&(i=n.Order),g(e,t,n,i,r)}),n.Transformation&&e.setTransformation(n.Transformation),n.Children)for(let[i,a]of Object.entries(n.Children)){let n=e.findOrCreateChildFromPath(i);n&&v(n,t,a,r)}},y=(e,t)=>{let n=e,r=t?.enabled?.include,i=t?.enabled?.exclude,a=t?.tubeLines;return(r?.length||i?.length)&&(r&&(n=e.filter(e=>{if(e.Type===`View`)return!0;for(let t=0;t<r.length;t++)if(I(e.RegionPath,e.GroupName,r[t]))return!0;return!1})),i&&(n=n.filter(e=>{if(e.Type===`View`)return!0;for(let t=0;t<i.length;t++)if(I(e.RegionPath,e.GroupName,i[t]))return!1;return!0}))),a&&n.forEach(e=>{e.Type===`Lines`&&(e.tubeLines=!0)}),n},b=(e,t)=>Array.isArray(e)?y(e,t):e,x=(e,t)=>{if(Array.isArray(e)){let n=0;for(let r=0;r<e.length;r++)e[r].Type&&(t&&e[r].Type===`View`||e[r].Type===`Surfaces`||e[r].Type===`Glyph`||e[r].Type===`Points`||e[r].Type===`Lines`||e[r].Type===`Texture`)&&n++;return n}return 0},S=e=>{let t=e.Primitives?x(e.Primitives,!1):0;return e.Children&&Object.values(e.Children).forEach(e=>{t+=S(e)}),t},w=e=>{if(Array.isArray(e))return x(e,!0);if(typeof e==`object`&&e&&e.Version===`2.0`)return S(e.Regions)},T=(e,t,n,r,i)=>{let a=e;n.RegionPath&&n.RegionPath!==``&&(a=e.findOrCreateChildFromPath(n.RegionPath)),g(a,t,n,r*2,i)},E=(e,t,n,r,i,a)=>{let o=b(t,a),s=w(o),c=new d(s,r,i);for(let e=0;e<t.length;e++)_(n,o[e],c);for(let r=0;r<t.length;r++)T(e,n,o[r],r,c)},D=(e,t,n,r,i)=>{let a=w(t),s=new d(a,r,i);t.Settings&&this.loadSettings(t.Settings),t.Views&&o(n,t.Views,n),t.Regions&&v(e,n,t.Regions,s)};this.loadMetadataURL=(e,t,i,a,o)=>{let s=t;fetch(s).then(e=>{if(!e.ok)throw Error(`HTTP error! status: ${e.status}`);let t=e.url||new URL(s).href;return e.json().then(e=>({metadata:e,referenceURL:t}))}).then(({metadata:t,referenceURL:s})=>{n.resetMetadata(),n.resetDuration(),r=!1,Array.isArray(t)?E(e,t,s,i,a,o):typeof t==`object`&&t&&t.Version===`2.0`&&D(e,t,s,i,a)}).catch(e=>{console.error(`Fetch failed for URL: ${s}`,e)})}},Cn=0,wn=function(){return`sc`+Cn++},Tn=function(){return{Duration:`6 secs`,OriginalDuration:`-`,TimeStamps:{}}},En=6e3,Dn=function(t,n){let r=t,i,a,o=new Sn(this),s,c={},l=0,u={},d=0,f=new e.Scene,p=new e.Scene,m=new Ft(void 0,this);f.add(m.getGroup());let h=new e.Group;f.add(h),this.directionalLight=void 0,this.ambient=void 0,this.camera=void 0;let g=6e3,_;this.sceneName=void 0;let v=!1,y;this.autoClearFlag=!0,this.displayMarkers=!1,this.displayMinimap=!1,this.displayMiniAxes=!1,this.minimapScissor={x_offset:16,y_offset:16,width:128,height:128,align:`top-right`,updateRequired:!0};let b={x:0,y:0},x=Tn(),S=new e.Vector2,C=[];this.forcePickableObjectsUpdate=!1,this.uuid=wn();let w=new yt(this);w.disable(),f.add(w.group);let T={main:[],mini:[]},E=new e.Vector3(0,0,0),D=()=>r?r.clientWidth===void 0?r.width:r.clientWidth:0,O=()=>r?r.clientHeight===void 0?r.height:r.clientHeight:0;this.getDownloadProgress=()=>o.getDownloadProgress(),this.onWindowResize=()=>{let e=O();this.camera.aspect=D()/e,this.camera.updateProjectionMatrix(),this.minimapScissor.updateRequired=!0,_.onResize(),_.calculateHeightPerPixelAtZeroDepth(e)},this.resetView=()=>{this.onWindowResize(),_.resetView()},this.changeZoomByScrollRateUnit=e=>{_.changeZoomByScrollRateUnit(e)},this.camera=new e.PerspectiveCamera(40,D()/O(),0,10),this.ambient=new e.AmbientLight(16777215,.2),f.add(this.ambient),this.directionalLight=new e.DirectionalLight(16777215,.8),f.add(this.directionalLight),_=new at(this.camera,n.domElement,n,this),_.setDirectionalLight(this.directionalLight),_.resetView(),s=new bt(this),this.loadView=e=>{let t=new it;return t.setFromObject(e),_.setCurrentCameraSettings(t),!0},this.setupMultipleViews=(e,t)=>{for(let[e,n]of Object.entries(t)){let t=new it;t.setFromObject(n),_.addViewport(e,t)}_.setDefaultViewport(e)},this.getBoundingBox=()=>m.getBoundingBox(!0),this.viewAllWithBoundingBox=e=>{if(e){let t=_.getViewportFromBoundingBox(e,1);_.setCurrentCameraSettings(t),_.calculateHeightPerPixelAtZeroDepth(O()),w.markerUpdateRequired=!0}},this.viewAll=()=>{let e=this.getBoundingBox();this.viewAllWithBoundingBox(e),w.markerUpdateRequired=!0},this.forEachGeometry=e=>{m.forEachGeometry(e,!0)},this.forEachGlyphset=e=>{m.forEachGlyphset(e,!0)},this.forEachPointset=e=>{m.forEachPointset(e,!0)},this.forEachLine=e=>{m.forEachLine(e,!0)},this.findGeometriesWithGroupName=e=>m.findGeometriesWithGroupName(e,!0),this.findPointsetsWithGroupName=e=>m.findPointsetsWithGroupName(e,!0),this.findGlyphsetsWithGroupName=e=>m.findGlyphsetsWithGroupName(e,!0),this.findLinesWithGroupName=e=>m.findLinesWithGroupName(e,!0),this.findObjectsWithGroupName=e=>m.findObjectsWithGroupName(e,!0),this.findObjectsWithAnatomicalId=e=>m.findObjectsWithAnatomicalId(e,!0),this.getBoundingBoxOfZincObjects=e=>{let t;for(let n=0;n<e.length;n++){let r=e[n].getBoundingBox();r&&(t?t.union(r):t=r)}return t},this.vectorToScreenXY=e=>{e.project(this.camera);let t=D(),n=O(),r=t/2,i=n/2;return e.x=e.x*r+r,e.y=-(e.y*i)+i,e},this.getObjectsScreenXY=t=>{if(t&&t.length>0){let n=this.getBoundingBoxOfZincObjects(t),r=new e.Vector3;return n.getCenter(r),this.vectorToScreenXY(r)}},this.getNamedObjectsScreenXY=e=>{let t=this.findObjectsWithGroupName(e);return this.getObjectsScreenXY(t)},this.addZincObject=e=>{e&&(m.addZincObject(e),_&&_.calculateMaxAllowedDistance(this))},this.loadGlyphsetURL=(e,t,n,r)=>{o.loadGlyphsetURL(m,e,t,n,r)},this.loadPointsetURL=(e,t,n,r,i)=>{o.loadPointsetURL(m,e,t,n,r,i)},this.loadLinesURL=(e,t,n,r,i)=>{o.loadLinesURL(m,e,t,n,r,i)},this.loadSTL=(e,t,n)=>{o.loadSTL(m,e,t,n)},this.loadOBJ=(e,t,n)=>{o.loadOBJ(m,e,t,n)},this.loadMetadataURL=(e,t,n,r)=>{o.loadMetadataURL(m,e,t,n,r)},this.loadModelsURL=(e,t,n,r,i,a)=>{o.loadModelsURL(m.urls,t,n,r,i,a)},this.loadViewURL=e=>{o.loadViewURL(e)},this.loadFromViewURL=(e,t)=>{o.loadFromViewURL(e,t)},this.loadGLTF=(e,t,n,r)=>{o.loadGLTF(m,e,t,n,r)},this.updateDirectionalLight=()=>{_.updateDirectionalLight()},this.addObject=e=>{f.add(e)},this.removeObject=e=>{f.remove(e)},this.getCurrentTime=()=>{if(a!=null)return a.getCurrentTime(g);let e=m.getCurrentTime();return e===-1?0:e},this.setMorphsTime=e=>{a?.setMorphTime(e,g),m.setMorphTime(e,!0)},this.isTimeVarying=()=>a&&a.video&&!a.video.error?!0:m.isTimeVarying(),this.renderGeometries=(e,t,n)=>{let r={};if(r.camera=_,r.displayMarkers=this.displayMarkers,r.markerCluster=w,r.markersList=w.markers,r.ndcToBeUpdated=!1,n&&(r.markerCluster.markerUpdateRequired=!0),a){if(a.isReadyToPlay()){n?a.video.play():a.video.pause();let e=a.video.currentTime/a.getVideoDuration()*g;o.toBeDownloaded==0?(_.setTime(e),r.ndcToBeUpdated=_.update(0),r.ndcToBeUpdated&&_.calculateHeightPerPixelAtZeroDepth(O()),m.setMorphTime(e,!0),m.renderGeometries(0,0,n,_,r,!0)):_.update(0)}else myPlayRate=0}else o.toBeDownloaded==0?(r.ndcToBeUpdated=_.update(t),r.ndcToBeUpdated&&_.calculateHeightPerPixelAtZeroDepth(O()),m.renderGeometries(e,t,n,_,r,!0)):_.update(0)},this.getThreeJSScene=()=>f,this.setVideoHandler=e=>{a||=e},this.setAdditionalScenesGroup=e=>{f.add(e)};let k=(e,t,n,r,i,a,o)=>{let s=0,c=0;return c=e.includes(`top`)?o-i-n:e.includes(`bottom`)?n:Math.floor((o-i)/2),s=e.includes(`left`)?t:e.includes(`right`)?a-t-r:Math.floor((a-r)/2),{x:s,y:c}},A=e=>{(this.displayMinimap||this.displayMiniAxes)&&(e.setScissorTest(!0),e.getSize(S),this.minimapScissor.updateRequired&&(b=k(this.minimapScissor.align,this.minimapScissor.x_offset,this.minimapScissor.y_offset,this.minimapScissor.width,this.minimapScissor.height,S.x,S.y),this.minimapScissor.updateRequired=!1),e.setScissor(b.x,b.y,this.minimapScissor.width,this.minimapScissor.height),e.setViewport(b.x,b.y,this.minimapScissor.width,this.minimapScissor.height),s.updateCamera(),this.displayMiniAxes?e.render(p,s.camera):(f.add(s.mask),e.render(f,s.camera),f.remove(s.mask)),e.setScissorTest(!1),e.setViewport(0,0,S.x,S.y))};this.render=e=>{this.autoClearFlag&&e.clear(),v&&y?y.render(f,this.camera):(e.render(f,this.camera),A(e))},this.setInteractiveControlEnable=e=>{e==1?_.enable():_.disable()},this.getZincCameraControls=()=>_,this.getThreeJSScene=()=>f,this.setDuration=e=>{m.setDuration(e),g=e,_.setPathDuration(e),o.duration=e},this.getDuration=()=>g,this.setStereoEffectEnable=e=>{e==1&&(y||=new dt(n)),n.setSize(D(),O()),this.camera.updateProjectionMatrix(),v=e},this.objectIsInScene=e=>m.objectIsInRegion(e,!0),this.alignBoundingBoxToCameraView=(t,n)=>{if(t){t.getCenter(E);let r=this.getZincCameraControls().getCurrentViewport(),i=new e.Vector3(r.targetPosition[0],r.targetPosition[1],r.targetPosition[2]),a=new e.Vector3(r.eyePosition[0],r.eyePosition[1],r.eyePosition[2]),o=new e.Vector3,s=new e.Vector3;o.subVectors(i,a).normalize(),s.subVectors(i,E).normalize();let c=new e.Vector3;c.crossVectors(o,s);let l=o.angleTo(s);n>0?(this.getZincCameraControls().rotateCameraTransition(c,l,n),this.getZincCameraControls().enableCameraTransition()):this.getZincCameraControls().rotateAboutLookAtpoint(c,l),w.markerUpdateRequired=!0}},this.translateBoundingBoxToCameraView=(e,t,n)=>{if(e){let r=this.getZincCameraControls().getCurrentViewport(),i=this.getZincCameraControls().getViewportFromBoundingBox(e,t);n>0&&(this.getZincCameraControls().cameraTransition(r,i,n),this.getZincCameraControls().enableCameraTransition()),w.markerUpdateRequired=!0}},this.alignObjectToCameraView=(e,t)=>{if(this.objectIsInScene(e)){let n=e.getBoundingBox();this.alignBoundingBoxToCameraView(n,t)}},this.setCameraTargetToObject=t=>{if(this.objectIsInScene(t)){let n=t.getBoundingBox(),r=this.getZincCameraControls().getCurrentViewport();n.getCenter(E);let i=new e.Vector3(r.targetPosition[0],r.targetPosition[1],r.targetPosition[2]),a=new e.Vector3(r.eyePosition[0],r.eyePosition[1],r.eyePosition[2]),o=new e.Vector3,s=new e.Vector3;o.subVectors(a,i),s.addVectors(E,o),r.eyePosition[0]=s.x,r.eyePosition[1]=s.y,r.eyePosition[2]=s.z,r.targetPosition[0]=E.x,r.targetPosition[1]=E.y,r.targetPosition[2]=E.z,this.getZincCameraControls().setCurrentCameraSettings(r),w.markerUpdateRequired=!0}},this.isStereoEffectEnable=()=>v,this.removeZincObject=e=>{m.removeZincObject(e),_&&_.calculateMaxAllowedDistance(this),w.markerUpdateRequired=!0},this.updatePickableThreeJSObjects=()=>{C.length=0,w.isEnabled&&C.push(w.group),m.getPickableThreeJSObjects(C,!0),this.forcePickableObjectsUpdate=!1},this.getPickableThreeJSObjects=()=>((this.forcePickableObjectsUpdate||m.checkPickableUpdateRequred(!0))&&this.updatePickableThreeJSObjects(),C),this.getNormalisedMinimapCoordinates=(t,n)=>{if(this.displayMinimap){let r=new e.Vector2;t.getSize(r);let i=r.y-n.clientY;if(b.x+this.minimapScissor.width>n.clientX&&n.clientX>b.x&&b.y+this.minimapScissor.height>i&&i>b.y)return{x:(n.clientX-b.x)/this.minimapScissor.width*2-1,y:(i-b.y)/this.minimapScissor.height*2-1}}},this.getMinimapDiffFromNormalised=(e,t)=>{if(s)return s.getDiffFromNormalised(e,t)},this.isWebGL2=()=>n.isWebGL2(),this.clearAll=()=>{w.clear(),m.clear(!0),this.clearZincObjectAddedCallbacks(),this.clearZincObjectRemovedCallbacks(),o.toBeDwonloaded=0,_&&_.calculateMaxAllowedDistance(this),w.markerUpdateRequired=!0},this.addMetadataTimeStamp=(e,t)=>{x.TimeStamps[e]=M(t)},this.getMetadataTag=e=>x[e],this.getMetadata=()=>x,this.setMetadataTag=(e,t)=>{x[e]=t},this.removeMetadataTag=e=>{delete x[e]},this.resetMetadata=()=>{x=Tn()},this.resetDuration=()=>{this.setDuration(En)};let j=e=>[...e.years?[`${e.years}years`]:[],...e.months?[`${e.months}months`]:[],...e.weeks?[`${e.weeks}weeks`]:[],...e.days?[`${e.days}days`]:[],...e.hours?[`${e.hours}hours`]:[],...e.mins?[`${e.mins}mins`]:[],...e.secs?[`${e.secs}secs`]:[]].join(` `),M=e=>e.years?e.years*31536e6:0+e.months?e.months*2592e6:0+e.weeks?e.weeks*6048e5:0+e.days?e.days*864e5:0+e.hours?e.hours*36e5:0+e.mins?e.mins*6e4:0+e.secs?e.secs*1e3:0;this.setDurationFromObject=e=>{let t=j(e),n=M(e);this.setMetadataTag(`Duration`,t),this.setDuration(n)},this.setOriginalDurationFromObject=e=>{let t=j(e);this.setMetadataTag(`OriginalDuration`,t)},this.exportGLTF=e=>new tn(this).exportGLTF(e),this.getRootRegion=()=>m,this.createLines=(e,t,n,r)=>{let i=m.findChildFromPath(e);return i===void 0&&(i=m.createChildFromPath(e)),i.createLines(t,n,r)},this.createPoints=(e,t,n,r,i)=>{let a=m.findChildFromPath(e);return a===void 0&&(a=m.createChildFromPath(e)),a.createPoints(t,n,r,i)},this.addZincObjectAddedCallbacks=e=>(l+=1,c[l]=e,l),this.addZincObjectRemovedCallbacks=e=>(d+=1,u[d]=e,d),this.removeZincObjectAddedCallbacks=e=>{e in l&&delete c[e]},this.removeZincObjectRemovedCallbacks=e=>{e in d&&delete u[e]},this.clearZincObjectAddedCallbacks=()=>{c={},l=0},this.clearZincObjectRemovedCallbacks=()=>{u={},d=0},this.triggerObjectAddedCallback=e=>{for(let t in c)c.hasOwnProperty(t)&&c[t](e)},this.triggerObjectRemovedCallback=e=>{for(let t in u)u.hasOwnProperty(t)&&u[t](e)},this.addTemporaryPoints=(t,n)=>{let r=N(t.length,t),i=new e.PointsMaterial({alphaTest:.5,size:15,color:n,sizeAttenuation:!1});i.map=P();let a=new Ge(r,i);return h.add(a),a},this.addTemporaryLines=(t,n)=>{let r=new pe(N(t.length,t),new e.LineBasicMaterial({color:n}));return h.add(r),r},this.enableFrustumDisplay=()=>{this.camera&&!i&&(i=new e.CameraHelper(this.camera),f.add(i))},this.disableFrustumDisplay=()=>{i&&=(f.remove(i),i.dispose(),void 0)},this.removeTemporaryPrimitive=e=>{h.remove(e),e.geometry.dispose(),e.material.dispose()},this.clearTemporaryPrimitives=()=>{let e=0;return h.children.forEach(t=>{t.geometry.dispose(),t.material.dispose(),e++}),h.clear(),e},this.addBoundingBoxPrimitive=(t,n,r,i,a,o=void 0)=>{let s=m.findChildFromPath(t);s===void 0&&(s=m.createChildFromPath(t));let c=o||this.getBoundingBox();E.set(0,0,0);let l=E.subVectors(c.max,c.min),u=new e.BoxGeometry(l.x,l.y,l.z),d=s.createGeometryFromThreeJSGeometry(n,u,r,i,a,1e4);return l.addVectors(c.min,c.max).multiplyScalar(.5),d.setPosition(l.x,l.y,l.z),d},this.addSlicesPrimitive=(t,n,r,i,a,o=void 0)=>{if(n&&n.length>=3&&r&&r.length>=3){let s=m.findChildFromPath(t);s===void 0&&(s=m.createChildFromPath(t));let c=o||this.getBoundingBox();E.set(0,0,0);let l=E.subVectors(c.max,c.min),u=[`x`,`y`,`z`],d=[],f=0;return u.forEach(t=>{let o;switch(t){case`x`:o=new e.PlaneGeometry(l.z,l.y),o.rotateY(Math.PI/2);break;case`y`:o=new e.PlaneGeometry(l.x,l.z),o.rotateX(Math.PI/2);break;case`z`:o=new e.PlaneGeometry(l.x,l.y)}let c=s.createGeometryFromThreeJSGeometry(n[f],o,r[f],i,a,10001);d.push(c),f++}),l.addVectors(c.min,c.max).multiplyScalar(.5),d.forEach(e=>{e.setPosition(l.x,l.y,l.z)}),d}},this.enableMarkerCluster=e=>{e?(w.markerUpdateRequired=!0,w.enable()):(w.markerUpdateRequired=!1,w.disable()),this.forcePickableObjectsUpdate=!0},this.destroyAxisDisplay=()=>{this.displayMiniAxes=!1,T.main&&(this.enableAxisDisplay(!1,!1),T.main.forEach(e=>{e.dispose&&e.dispose()})),T.mini&&(this.enableAxisDisplay(!1,!0),T.mini.forEach(e=>{e.dispose&&e.dispose()})),T={main:[],mini:[]}},this.createAxisDisplay=(t=!1)=>{this.destroyAxisDisplay();let n=[{name:`x`,dir:new e.Vector3(1,0,0),colour:`red`,hex:16733525},{name:`y`,dir:new e.Vector3(0,1,0),colour:`green`,hex:5635925},{name:`z`,dir:new e.Vector3(0,0,1),colour:`blue`,hex:5592575}],r=this.getBoundingBox(),i=r.min.distanceTo(r.max),a=new e.Vector3(0,0,0);t&&a.copy(r.min),n.forEach(t=>{let n=new e.ArrowHelper(t.dir,a,i,t.hex);T.main.push(n);let o=new e.ArrowHelper(t.dir,r.getCenter(E),i/2,t.hex);T.mini.push(o);let s=F(t.name,.036,t.colour,`Asap`,120,700),c=t.dir.clone().multiplyScalar(i).add(a);s.position.set(c.x,c.y,c.z),T.main.push(s)})},this.enableAxisDisplay=(e,t=!1)=>{t&&T?.mini?.length?(this.displayMiniAxes=e,T.mini.forEach(t=>{e?p.add(t):p.remove(t)})):!t&&T.main&&T.main.forEach(t=>{e?f.add(t):f.remove(t)})}},On=function(t){let r=t,i,a,o=new e.Clock(!1);this.playAnimation=!0;let s=1e3,c={},l=0,u={},d=0,f={},p=0,m={},h=0,g,_,v,y,b=[],x=[],S=new e.Group,C,w,T=!1,E=!1;this.getDrawingWidth=()=>r?r.clientWidth:C?C.clientWidth===void 0?Math.round(C.width):Math.round(C.clientWidth):0,this.getDrawingHeight=()=>r?r.clientHeight:C?C.clientHeight===void 0?Math.round(C.height):Math.round(C.clientHeight):0,this.onWindowResize=()=>{a.onWindowResize();let t=this.getDrawingWidth(),n=this.getDrawingHeight();if(i!=null){let a;r?(a=r.getBoundingClientRect(),i.setSize(t,n)):C&&(C.getBoundingClientRect===void 0?i.setSize(t,n,!1):(a=C.getBoundingClientRect(),C.width=t,C.height=n,i.setSize(t,n,!1))),a&&(a.left,a.top);let o=new e.Vector2;i.getSize(o),o.x,o.y}},this.initialiseVisualisation=t=>{if(!E){if(t||={},t.antialias===void 0){let e=!1;try{/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)&&(e=!0)}catch{e=!1}e?t.antialias=!1:t.antialias=!0}t.canvas&&(r=void 0,C=t.canvas),i=new e.WebGLRenderer(t),r!==void 0&&r.appendChild(i.domElement),i.setClearColor(16777215,1),C&&C.style&&(C.style.height=`100%`,C.style.width=`100%`);let n=i.domElement;n.addEventListener(`webglcontextlost`,D,!1),n.addEventListener(`webglcontextrestored`,O,!1),i.autoClear=!1;let a=this.createScene(`default`);this.setCurrentScene(a),E=!0}};let D=e=>{e.preventDefault();for(let e of Object.keys(c))f.hasOwnProperty(e)&&f[e].call()},O=e=>{e.preventDefault();for(let e of Object.keys(c))m.hasOwnProperty(e)&&m[e].call()};this.getCurrentScene=()=>a,this.setCurrentScene=e=>{if(e){this.removeActiveScene(e);let t=a;a=e,t&&t.setInteractiveControlEnable(!1),a.setInteractiveControlEnable(!0),a.setAdditionalScenesGroup(S),this.onWindowResize()}},this.getSceneByName=e=>b[e],this.createScene=e=>{if(b[e]==null){let t;return t=C?new Dn(C,i):new Dn(r,i),b[e]=t,t.sceneName=e,t}},this.resetView=()=>{a.resetView()},this.viewAll=()=>{if(a){let e=a.getBoundingBox();if(e){for(let t=0;t<x.length;t++){let n=x[t].getBoundingBox();n&&e.union(n)}a.viewAllWithBoundingBox(e)}}},this.loadModelsURL=(e,t,n,r,i,o)=>{a.loadModelsURL(e,t,n,r,i,o)},this.loadViewURL=e=>{a.loadViewURL(e)},this.loadFromViewURL=(e,t)=>{a.loadFromViewURL(e,t)},this.updateDirectionalLight=()=>{a.updateDirectionalLight()};let k=()=>{T?(g=requestAnimationFrame(k),this.render()):(cancelAnimationFrame(g),g=void 0)};this.stopAnimate=()=>{T&&=(o.stop(),!1)},this.animate=()=>{T||(o.start(),T=!0,k())},this.addContextLostCallbackFunction=e=>(p+=1,f[p]=e,p),this.removeContextLostCallbackFunction=e=>{e in f&&delete f[e]},this.addContextRestoredCallbackFunction=e=>(h+=1,m[h]=e,h),this.removeContextRestoredCallbackFunction=e=>{e in h&&delete h[e]},this.addPreRenderCallbackFunction=e=>(l+=1,c[l]=e,l),this.removePreRenderCallbackFunction=e=>{e in c&&delete c[e]},this.addPostRenderCallbackFunction=e=>(d+=1,u[d]=e,d),this.removePostRenderCallbackFunction=e=>{e in u&&delete u[e]},this.getPlayRate=()=>s,this.setPlayRate=e=>{s=e},this.getCurrentTime=()=>a.getCurrentTime(),this.setMorphsTime=e=>{a.setMorphsTime(e)},this.getZincGeometryByID=e=>a.getZincGeometryByID(e),this.addToScene=e=>{a.addObject(e)},this.addToOrthoScene=t=>{if(v??=new e.Scene,_==null){let t=this.getDrawingWidth(),n=this.getDrawingHeight();_=new e.OrthographicCamera(-t/2,t/2,n/2,-n/2,1,10),_.position.z=10}v.add(t)};let A=t=>n=>{n.needsUpdate=!0;let r=new e.SpriteMaterial({map:n}),i=r.map.image.width,a=r.map.image.height;t.material=r,t.scale.set(i,a,1);let o=this.getDrawingWidth(),s=this.getDrawingHeight();t.position.set((o-i)/2,(-s+a)/2,1),this.addToOrthoScene(t)};this.addLogo=()=>{y=new e.Sprite,e.ImageUtils.loadTexture(`images/abi_big_logo_transparent_small.png`,void 0,A(y))},this.render=()=>{w||(r?r.clientWidth>0&&r.clientHeight>0&&(w=new n.ResizeSensor(r,this.onWindowResize)):C&&C.width>0&&C.height>0&&(w=new n.ResizeSensor(C,this.onWindowResize)));let e=o.getDelta();a.renderGeometries(s,e,this.playAnimation);for(let t=0;t<x.length;t++)x[t].renderGeometries(s,e,this.playAnimation);_!=null&&v!=null&&(i.clearDepth(),i.render(v,_));for(let e of Object.keys(c))c.hasOwnProperty(e)&&c[e].call();a.render(i);for(let e of Object.keys(u))u.hasOwnProperty(e)&&u[e].call()},this.forceContextLoss=()=>{i.forceContextLoss()},this.forceContextRestore=()=>{i.forceContextRestore()},this.getThreeJSRenderer=()=>i,this.isSceneActive=e=>{if(a===e)return!0;for(let t=0;t<x.length;t++)if(x[t]===e)return!0;return!1},this.addActiveScene=e=>{this.isSceneActive(e)||(x.push(e),S.add(e.getThreeJSScene()))},this.removeActiveScene=e=>{for(let t=0;t<x.length;t++)if(x[t]===e){x.splice(t,1),S.remove(e.getThreeJSScene());return}},this.clearAllActiveScene=()=>{for(let e=0;e<x.length;e++)S.remove(x[e].getThreeJSScene());x.splice(0,x.length)},this.dispose=()=>{T&&cancelAnimationFrame(g);for(let e in b)b.hasOwnProperty(e)&&b[e].clearAll();b=[],x=[],S=new e.Group,this.stopAnimate(),c={},l=0,u={},u=0,f={},p=0,m={},h=0,_=void 0,v=void 0,y=void 0;let t=this.createScene(`default`);this.setCurrentScene(t),w=void 0,i?.dispose()},this.transitionScene=(e,t)=>{if(a){let n=a.getZincCameraControls(),r=e.getBoundingBox();if(r){let e=r.min.distanceTo(r.max)/2,i=(r.min.x+r.max.x)/2,a=(r.min.y+r.max.y)/2,o=(r.min.z+r.max.z)/2,s=n.getViewportFromCentreAndRadius(i,a,o,e,40,e*4),c=n.getCurrentViewport();n.cameraTransition(c,s,t),n.enableCameraTransition()}}},this.isWebGL2=()=>i?i.capabilities.isWebGL2:!1},kn=class{esize;ecode;edata;littleEndian;constructor(e,t,n,r){if(e%16!=0)throw Error(`This does not appear to be a NIFTI extension`);this.esize=e,this.ecode=t,this.edata=n,this.littleEndian=r}toArrayBuffer(){let e=new Uint8Array(this.esize),t=new Uint8Array(this.edata);e.set(t,8);let n=new DataView(e.buffer);return n.setInt32(0,this.esize,this.littleEndian),n.setInt32(4,this.ecode,this.littleEndian),e.buffer}},X=class e{static crcTable=null;static GUNZIP_MAGIC_COOKIE1=31;static GUNZIP_MAGIC_COOKIE2=139;static getStringAt(e,t,n){var r=``,i,a;for(i=t;i<n;i+=1)a=e.getUint8(i),a!==0&&(r+=String.fromCharCode(a));return r}static getByteAt=function(e,t){return e.getUint8(t)};static getShortAt=function(e,t,n){return e.getInt16(t,n)};static getIntAt(e,t,n){return e.getInt32(t,n)}static getFloatAt(e,t,n){return e.getFloat32(t,n)}static getDoubleAt(e,t,n){return e.getFloat64(t,n)}static getInt64At(e,t,n){let r=e.getUint32(t,n),i=e.getInt32(t+4,n),a;return a=n?i*2**32+r:r*2**32+i,i<0&&(a+=-1*2**32*2**32),a}static getUint64At(e,t,n){let r=e.getUint32(t+(n?0:4),n),i=e.getUint32(t+(n?4:0),n);return n?i*2**32+r:r*2**32+i}static getExtensionsAt(t,n,r,i){let a=[],o=n;for(;o<i;){let n=r,s=e.getIntAt(t,o,r);if(!s)break;if(s+o>i&&(n=!n,s=e.getIntAt(t,o,n),s+o>i))throw Error(`This does not appear to be a valid NIFTI extension`);if(s%16!=0)throw Error(`This does not appear to be a NIFTI extension`);let c=e.getIntAt(t,o+4,n),l=t.buffer.slice(o+8,o+s),u=new kn(s,c,l,n);a.push(u),o+=s}return a}static toArrayBuffer(e){var t=new ArrayBuffer(e.length),n=new Uint8Array(t),r;for(r=0;r<e.length;r+=1)n[r]=e[r];return t}static isString(e){return typeof e==`string`||e instanceof String}static formatNumber(t,n=void 0){let r;return r=e.isString(t)?Number(t):t,r=n?r.toPrecision(5):r.toPrecision(7),parseFloat(r)}static makeCRCTable(){let e,t=[];for(var n=0;n<256;n++){e=n;for(var r=0;r<8;r++)e=e&1?3988292384^e>>>1:e>>>1;t[n]=e}return t}static crc32(t){e.crcTable||=e.makeCRCTable();let n=e.crcTable,r=-1;for(var i=0;i<t.byteLength;i++)r=r>>>8^n[(r^t.getUint8(i))&255];return(r^-1)>>>0}},Z=class e{littleEndian=!1;dim_info=0;dims=[];intent_p1=0;intent_p2=0;intent_p3=0;intent_code=0;datatypeCode=0;numBitsPerVoxel=0;slice_start=0;slice_end=0;slice_code=0;pixDims=[];vox_offset=0;scl_slope=1;scl_inter=0;xyzt_units=0;cal_max=0;cal_min=0;slice_duration=0;toffset=0;description=``;aux_file=``;intent_name=``;qform_code=0;sform_code=0;quatern_a=0;quatern_b=0;quatern_c=0;quatern_d=0;qoffset_x=0;qoffset_y=0;qoffset_z=0;affine=[[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1]];qfac=1;quatern_R;magic=`0`;isHDR=!1;extensionFlag=[0,0,0,0];extensionSize=0;extensionCode=0;extensions=[];static TYPE_NONE=0;static TYPE_BINARY=1;static TYPE_UINT8=2;static TYPE_INT16=4;static TYPE_INT32=8;static TYPE_FLOAT32=16;static TYPE_COMPLEX64=32;static TYPE_FLOAT64=64;static TYPE_RGB24=128;static TYPE_INT8=256;static TYPE_UINT16=512;static TYPE_UINT32=768;static TYPE_INT64=1024;static TYPE_UINT64=1280;static TYPE_FLOAT128=1536;static TYPE_COMPLEX128=1792;static TYPE_COMPLEX256=2048;static XFORM_UNKNOWN=0;static XFORM_SCANNER_ANAT=1;static XFORM_ALIGNED_ANAT=2;static XFORM_TALAIRACH=3;static XFORM_MNI_152=4;static SPATIAL_UNITS_MASK=7;static TEMPORAL_UNITS_MASK=56;static UNITS_UNKNOWN=0;static UNITS_METER=1;static UNITS_MM=2;static UNITS_MICRON=3;static UNITS_SEC=8;static UNITS_MSEC=16;static UNITS_USEC=24;static UNITS_HZ=32;static UNITS_PPM=40;static UNITS_RADS=48;static MAGIC_COOKIE=348;static STANDARD_HEADER_SIZE=348;static MAGIC_NUMBER_LOCATION=344;static MAGIC_NUMBER=[110,43,49];static MAGIC_NUMBER2=[110,105,49];static EXTENSION_HEADER_SIZE=8;readHeader(t){var n=new DataView(t),r=X.getIntAt(n,0,this.littleEndian),i,a,o,s;if(r!==e.MAGIC_COOKIE&&(this.littleEndian=!0,r=X.getIntAt(n,0,this.littleEndian)),r!==e.MAGIC_COOKIE)throw Error(`This does not appear to be a NIFTI file!`);for(this.dim_info=X.getByteAt(n,39),i=0;i<8;i+=1)s=40+i*2,this.dims[i]=X.getShortAt(n,s,this.littleEndian);for(this.intent_p1=X.getFloatAt(n,56,this.littleEndian),this.intent_p2=X.getFloatAt(n,60,this.littleEndian),this.intent_p3=X.getFloatAt(n,64,this.littleEndian),this.intent_code=X.getShortAt(n,68,this.littleEndian),this.datatypeCode=X.getShortAt(n,70,this.littleEndian),this.numBitsPerVoxel=X.getShortAt(n,72,this.littleEndian),this.slice_start=X.getShortAt(n,74,this.littleEndian),i=0;i<8;i+=1)s=76+i*4,this.pixDims[i]=X.getFloatAt(n,s,this.littleEndian);if(this.vox_offset=X.getFloatAt(n,108,this.littleEndian),this.scl_slope=X.getFloatAt(n,112,this.littleEndian),this.scl_inter=X.getFloatAt(n,116,this.littleEndian),this.slice_end=X.getShortAt(n,120,this.littleEndian),this.slice_code=X.getByteAt(n,122),this.xyzt_units=X.getByteAt(n,123),this.cal_max=X.getFloatAt(n,124,this.littleEndian),this.cal_min=X.getFloatAt(n,128,this.littleEndian),this.slice_duration=X.getFloatAt(n,132,this.littleEndian),this.toffset=X.getFloatAt(n,136,this.littleEndian),this.description=X.getStringAt(n,148,228),this.aux_file=X.getStringAt(n,228,252),this.qform_code=X.getShortAt(n,252,this.littleEndian),this.sform_code=X.getShortAt(n,254,this.littleEndian),this.quatern_b=X.getFloatAt(n,256,this.littleEndian),this.quatern_c=X.getFloatAt(n,260,this.littleEndian),this.quatern_d=X.getFloatAt(n,264,this.littleEndian),this.quatern_a=Math.sqrt(1-(this.quatern_b**2+this.quatern_c**2+this.quatern_d**2)),this.qoffset_x=X.getFloatAt(n,268,this.littleEndian),this.qoffset_y=X.getFloatAt(n,272,this.littleEndian),this.qoffset_z=X.getFloatAt(n,276,this.littleEndian),this.qform_code<1&&this.sform_code<1&&(this.affine[0][0]=this.pixDims[1],this.affine[1][1]=this.pixDims[2],this.affine[2][2]=this.pixDims[3]),this.qform_code>0&&this.sform_code<this.qform_code){let e=this.quatern_a,t=this.quatern_b,n=this.quatern_c,r=this.quatern_d;for(this.qfac=this.pixDims[0]===0?1:this.pixDims[0],this.quatern_R=[[e*e+t*t-n*n-r*r,2*t*n-2*e*r,2*t*r+2*e*n],[2*t*n+2*e*r,e*e+n*n-t*t-r*r,2*n*r-2*e*t],[2*t*r-2*e*n,2*n*r+2*e*t,e*e+r*r-n*n-t*t]],a=0;a<3;a+=1)for(o=0;o<3;o+=1)this.affine[a][o]=this.quatern_R[a][o]*this.pixDims[o+1],o===2&&(this.affine[a][o]*=this.qfac);this.affine[0][3]=this.qoffset_x,this.affine[1][3]=this.qoffset_y,this.affine[2][3]=this.qoffset_z}else if(this.sform_code>0)for(a=0;a<3;a+=1)for(o=0;o<4;o+=1)s=280+(a*4+o)*4,this.affine[a][o]=X.getFloatAt(n,s,this.littleEndian);if(this.affine[3][0]=0,this.affine[3][1]=0,this.affine[3][2]=0,this.affine[3][3]=1,this.intent_name=X.getStringAt(n,328,344),this.magic=X.getStringAt(n,344,348),this.isHDR=this.magic===String.fromCharCode.apply(null,e.MAGIC_NUMBER2),n.byteLength>e.MAGIC_COOKIE){this.extensionFlag[0]=X.getByteAt(n,348),this.extensionFlag[1]=X.getByteAt(n,349),this.extensionFlag[2]=X.getByteAt(n,350),this.extensionFlag[3]=X.getByteAt(n,351);let e=!0;!this.isHDR&&this.vox_offset<=352&&(e=!1),n.byteLength<=368&&(e=!1),e&&this.extensionFlag[0]&&(this.extensions=X.getExtensionsAt(n,this.getExtensionLocation(),this.littleEndian,this.vox_offset),this.extensionSize=this.extensions[0].esize,this.extensionCode=this.extensions[0].ecode)}}toFormattedString(){var t=X.formatNumber,n=``;return n+=`Dim Info = `+this.dim_info+`
292
+ `,n+=`Image Dimensions (1-8): `+this.dims[0]+`, `+this.dims[1]+`, `+this.dims[2]+`, `+this.dims[3]+`, `+this.dims[4]+`, `+this.dims[5]+`, `+this.dims[6]+`, `+this.dims[7]+`
293
+ `,n+=`Intent Parameters (1-3): `+this.intent_p1+`, `+this.intent_p2+`, `+this.intent_p3+`
294
+ `,n+=`Intent Code = `+this.intent_code+`
295
+ `,n+=`Datatype = `+this.datatypeCode+` (`+this.getDatatypeCodeString(this.datatypeCode)+`)
296
+ `,n+=`Bits Per Voxel = `+this.numBitsPerVoxel+`
297
+ `,n+=`Slice Start = `+this.slice_start+`
298
+ `,n+=`Voxel Dimensions (1-8): `+t(this.pixDims[0])+`, `+t(this.pixDims[1])+`, `+t(this.pixDims[2])+`, `+t(this.pixDims[3])+`, `+t(this.pixDims[4])+`, `+t(this.pixDims[5])+`, `+t(this.pixDims[6])+`, `+t(this.pixDims[7])+`
299
+ `,n+=`Image Offset = `+this.vox_offset+`
300
+ `,n+=`Data Scale: Slope = `+t(this.scl_slope)+` Intercept = `+t(this.scl_inter)+`
301
+ `,n+=`Slice End = `+this.slice_end+`
302
+ `,n+=`Slice Code = `+this.slice_code+`
303
+ `,n+=`Units Code = `+this.xyzt_units+` (`+this.getUnitsCodeString(e.SPATIAL_UNITS_MASK&this.xyzt_units)+`, `+this.getUnitsCodeString(e.TEMPORAL_UNITS_MASK&this.xyzt_units)+`)
304
+ `,n+=`Display Range: Max = `+t(this.cal_max)+` Min = `+t(this.cal_min)+`
305
+ `,n+=`Slice Duration = `+this.slice_duration+`
306
+ `,n+=`Time Axis Shift = `+this.toffset+`
307
+ `,n+=`Description: "`+this.description+`"
308
+ `,n+=`Auxiliary File: "`+this.aux_file+`"
309
+ `,n+=`Q-Form Code = `+this.qform_code+` (`+this.getTransformCodeString(this.qform_code)+`)
310
+ `,n+=`S-Form Code = `+this.sform_code+` (`+this.getTransformCodeString(this.sform_code)+`)
311
+ `,n+=`Quaternion Parameters: b = `+t(this.quatern_b)+` c = `+t(this.quatern_c)+` d = `+t(this.quatern_d)+`
312
+ `,n+=`Quaternion Offsets: x = `+this.qoffset_x+` y = `+this.qoffset_y+` z = `+this.qoffset_z+`
313
+ `,n+=`S-Form Parameters X: `+t(this.affine[0][0])+`, `+t(this.affine[0][1])+`, `+t(this.affine[0][2])+`, `+t(this.affine[0][3])+`
314
+ `,n+=`S-Form Parameters Y: `+t(this.affine[1][0])+`, `+t(this.affine[1][1])+`, `+t(this.affine[1][2])+`, `+t(this.affine[1][3])+`
315
+ `,n+=`S-Form Parameters Z: `+t(this.affine[2][0])+`, `+t(this.affine[2][1])+`, `+t(this.affine[2][2])+`, `+t(this.affine[2][3])+`
316
+ `,n+=`Intent Name: "`+this.intent_name+`"
317
+ `,this.extensionFlag[0]&&(n+=`Extension: Size = `+this.extensionSize+` Code = `+this.extensionCode+`
318
+ `),n}getDatatypeCodeString=function(t){return t===e.TYPE_UINT8?`1-Byte Unsigned Integer`:t===e.TYPE_INT16?`2-Byte Signed Integer`:t===e.TYPE_INT32?`4-Byte Signed Integer`:t===e.TYPE_FLOAT32?`4-Byte Float`:t===e.TYPE_FLOAT64?`8-Byte Float`:t===e.TYPE_RGB24?`RGB`:t===e.TYPE_INT8?`1-Byte Signed Integer`:t===e.TYPE_UINT16?`2-Byte Unsigned Integer`:t===e.TYPE_UINT32?`4-Byte Unsigned Integer`:t===e.TYPE_INT64?`8-Byte Signed Integer`:t===e.TYPE_UINT64?`8-Byte Unsigned Integer`:`Unknown`};getTransformCodeString=function(t){return t===e.XFORM_SCANNER_ANAT?`Scanner`:t===e.XFORM_ALIGNED_ANAT?`Aligned`:t===e.XFORM_TALAIRACH?`Talairach`:t===e.XFORM_MNI_152?`MNI`:`Unknown`};getUnitsCodeString=function(t){return t===e.UNITS_METER?`Meters`:t===e.UNITS_MM?`Millimeters`:t===e.UNITS_MICRON?`Microns`:t===e.UNITS_SEC?`Seconds`:t===e.UNITS_MSEC?`Milliseconds`:t===e.UNITS_USEC?`Microseconds`:t===e.UNITS_HZ?`Hz`:t===e.UNITS_PPM?`PPM`:t===e.UNITS_RADS?`Rads`:`Unknown`};getQformMat(){return this.convertNiftiQFormToNiftiSForm(this.quatern_b,this.quatern_c,this.quatern_d,this.qoffset_x,this.qoffset_y,this.qoffset_z,this.pixDims[1],this.pixDims[2],this.pixDims[3],this.pixDims[0])}convertNiftiQFormToNiftiSForm(e,t,n,r,i,a,o,s,c,l){var u=[[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0]],d,f=e,p=t,m=n,h,g,_;return u[3][0]=u[3][1]=u[3][2]=0,u[3][3]=1,d=1-(f*f+p*p+m*m),d<1e-7?(d=1/Math.sqrt(f*f+p*p+m*m),f*=d,p*=d,m*=d,d=0):d=Math.sqrt(d),h=o>0?o:1,g=s>0?s:1,_=c>0?c:1,l<0&&(_=-_),u[0][0]=(d*d+f*f-p*p-m*m)*h,u[0][1]=2*(f*p-d*m)*g,u[0][2]=2*(f*m+d*p)*_,u[1][0]=2*(f*p+d*m)*h,u[1][1]=(d*d+p*p-f*f-m*m)*g,u[1][2]=2*(p*m-d*f)*_,u[2][0]=2*(f*m-d*p)*h,u[2][1]=2*(p*m+d*f)*g,u[2][2]=(d*d+m*m-p*p-f*f)*_,u[0][3]=r,u[1][3]=i,u[2][3]=a,u}convertNiftiSFormToNEMA(e){var t,n,r,i,a,o,s,c,l,u,d,f,p,m,h=0,g,_,v,y,b,x,S,C,w,T,E,D=[[0,0,0],[0,0,0],[0,0,0]],O=[[0,0,0],[0,0,0],[0,0,0]],k,A,j,M,N,P;if(t=e[0][0],n=e[0][1],r=e[0][2],i=e[1][0],a=e[1][1],o=e[1][2],s=e[2][0],c=e[2][1],l=e[2][2],u=Math.sqrt(t*t+i*i+s*s),u===0||(t/=u,i/=u,s/=u,u=Math.sqrt(n*n+a*a+c*c),u===0))return null;if(n/=u,a/=u,c/=u,u=t*n+i*a+s*c,Math.abs(u)>1e-4){if(n-=u*t,a-=u*i,c-=u*s,u=Math.sqrt(n*n+a*a+c*c),u===0)return null;n/=u,a/=u,c/=u}if(u=Math.sqrt(r*r+o*o+l*l),u===0?(r=i*c-s*a,o=s*n-c*t,l=t*a-i*n):(r/=u,o/=u,l/=u),u=t*r+i*o+s*l,Math.abs(u)>1e-4){if(r-=u*t,o-=u*i,l-=u*s,u=Math.sqrt(r*r+o*o+l*l),u===0)return null;r/=u,o/=u,l/=u}if(u=n*r+a*o+c*l,Math.abs(u)>1e-4){if(r-=u*n,o-=u*a,l-=u*c,u=Math.sqrt(r*r+o*o+l*l),u===0)return null;r/=u,o/=u,l/=u}if(D[0][0]=t,D[0][1]=n,D[0][2]=r,D[1][0]=i,D[1][1]=a,D[1][2]=o,D[2][0]=s,D[2][1]=c,D[2][2]=l,d=this.nifti_mat33_determ(D),d===0)return null;for(E=-666,y=S=C=w=1,b=2,x=3,p=1;p<=3;p+=1)for(m=1;m<=3;m+=1)if(p!==m){for(h=1;h<=3;h+=1)if(p!==h&&m!==h)for(O[0][0]=O[0][1]=O[0][2]=O[1][0]=O[1][1]=O[1][2]=O[2][0]=O[2][1]=O[2][2]=0,g=-1;g<=1;g+=2)for(_=-1;_<=1;_+=2)for(v=-1;v<=1;v+=2)O[0][p-1]=g,O[1][m-1]=_,O[2][h-1]=v,f=this.nifti_mat33_determ(O),f*d>0&&(T=this.nifti_mat33_mul(O,D),u=T[0][0]+T[1][1]+T[2][2],u>E&&(E=u,y=p,b=m,x=h,S=g,C=_,w=v))}switch(k=A=j=M=N=P=``,y*S){case 1:k=`X`,M=`+`;break;case-1:k=`X`,M=`-`;break;case 2:k=`Y`,M=`+`;break;case-2:k=`Y`,M=`-`;break;case 3:k=`Z`,M=`+`;break;case-3:k=`Z`,M=`-`}switch(b*C){case 1:A=`X`,N=`+`;break;case-1:A=`X`,N=`-`;break;case 2:A=`Y`,N=`+`;break;case-2:A=`Y`,N=`-`;break;case 3:A=`Z`,N=`+`;break;case-3:A=`Z`,N=`-`}switch(x*w){case 1:j=`X`,P=`+`;break;case-1:j=`X`,P=`-`;break;case 2:j=`Y`,P=`+`;break;case-2:j=`Y`,P=`-`;break;case 3:j=`Z`,P=`+`;break;case-3:j=`Z`,P=`-`}return k+A+j+M+N+P}nifti_mat33_mul=function(e,t){var n=[[0,0,0],[0,0,0],[0,0,0]],r,i;for(r=0;r<3;r+=1)for(i=0;i<3;i+=1)n[r][i]=e[r][0]*t[0][i]+e[r][1]*t[1][i]+e[r][2]*t[2][i];return n};nifti_mat33_determ=function(e){var t=e[0][0],n=e[0][1],r=e[0][2],i=e[1][0],a=e[1][1],o=e[1][2],s=e[2][0],c=e[2][1],l=e[2][2];return t*a*l-t*c*o-i*n*l+i*c*r+s*n*o-s*a*r};getExtensionLocation(){return e.MAGIC_COOKIE+4}getExtensionSize(e){return X.getIntAt(e,this.getExtensionLocation(),this.littleEndian)}getExtensionCode(e){return X.getIntAt(e,this.getExtensionLocation()+4,this.littleEndian)}addExtension(e,t=-1){t==-1?this.extensions.push(e):this.extensions.splice(t,0,e),this.vox_offset+=e.esize}removeExtension(e){let t=this.extensions[e];t&&(this.vox_offset-=t.esize),this.extensions.splice(e,1)}toArrayBuffer(e=!1){let t=352;if(e)for(let e of this.extensions)t+=e.esize;let n=new Uint8Array(t),r=new DataView(n.buffer);r.setInt32(0,348,this.littleEndian),r.setUint8(39,this.dim_info);for(let e=0;e<8;e++)r.setUint16(40+2*e,this.dims[e],this.littleEndian);r.setFloat32(56,this.intent_p1,this.littleEndian),r.setFloat32(60,this.intent_p2,this.littleEndian),r.setFloat32(64,this.intent_p3,this.littleEndian),r.setInt16(68,this.intent_code,this.littleEndian),r.setInt16(70,this.datatypeCode,this.littleEndian),r.setInt16(72,this.numBitsPerVoxel,this.littleEndian),r.setInt16(74,this.slice_start,this.littleEndian);for(let e=0;e<8;e++)r.setFloat32(76+4*e,this.pixDims[e],this.littleEndian);r.setFloat32(108,this.vox_offset,this.littleEndian),r.setFloat32(112,this.scl_slope,this.littleEndian),r.setFloat32(116,this.scl_inter,this.littleEndian),r.setInt16(120,this.slice_end,this.littleEndian),r.setUint8(122,this.slice_code),r.setUint8(123,this.xyzt_units),r.setFloat32(124,this.cal_max,this.littleEndian),r.setFloat32(128,this.cal_min,this.littleEndian),r.setFloat32(132,this.slice_duration,this.littleEndian),r.setFloat32(136,this.toffset,this.littleEndian),n.set(new TextEncoder().encode(this.description),148),n.set(new TextEncoder().encode(this.aux_file),228),r.setInt16(252,this.qform_code,this.littleEndian),r.setInt16(254,this.sform_code,this.littleEndian),r.setFloat32(256,this.quatern_b,this.littleEndian),r.setFloat32(260,this.quatern_c,this.littleEndian),r.setFloat32(264,this.quatern_d,this.littleEndian),r.setFloat32(268,this.qoffset_x,this.littleEndian),r.setFloat32(272,this.qoffset_y,this.littleEndian),r.setFloat32(276,this.qoffset_z,this.littleEndian);let i=this.affine.flat();for(let e=0;e<12;e++)r.setFloat32(280+4*e,i[e],this.littleEndian);if(n.set(new TextEncoder().encode(this.intent_name),328),n.set(new TextEncoder().encode(this.magic),344),e){n.set(Uint8Array.from([1,0,0,0]),348);let e=this.getExtensionLocation();for(let t of this.extensions)r.setInt32(e,t.esize,t.littleEndian),r.setInt32(e+4,t.ecode,t.littleEndian),n.set(new Uint8Array(t.edata),e+8),e+=t.esize}else n.set(new Uint8Array(4).fill(0),348);return n.buffer}},Q=class e{littleEndian=!1;dim_info=0;dims=[];intent_p1=0;intent_p2=0;intent_p3=0;intent_code=0;datatypeCode=0;numBitsPerVoxel=0;slice_start=0;slice_end=0;slice_code=0;pixDims=[];vox_offset=0;scl_slope=1;scl_inter=0;xyzt_units=0;cal_max=0;cal_min=0;slice_duration=0;toffset=0;description=``;aux_file=``;intent_name=``;qform_code=0;sform_code=0;quatern_b=0;quatern_c=0;quatern_d=0;qoffset_x=0;qoffset_y=0;qoffset_z=0;affine=[[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1]];magic=`0`;extensionFlag=[0,0,0,0];extensions=[];extensionSize=0;extensionCode=0;static MAGIC_COOKIE=540;static MAGIC_NUMBER_LOCATION=4;static MAGIC_NUMBER=[110,43,50,0,13,10,26,10];static MAGIC_NUMBER2=[110,105,50,0,13,10,26,10];readHeader(t){var n=new DataView(t),r=X.getIntAt(n,0,this.littleEndian),i,a,o,s;if(r!==e.MAGIC_COOKIE&&(this.littleEndian=!0,r=X.getIntAt(n,0,this.littleEndian)),r!==e.MAGIC_COOKIE)throw Error(`This does not appear to be a NIFTI file!`);for(this.magic=X.getStringAt(n,4,12),this.datatypeCode=X.getShortAt(n,12,this.littleEndian),this.numBitsPerVoxel=X.getShortAt(n,14,this.littleEndian),i=0;i<8;i+=1)s=16+i*8,this.dims[i]=X.getInt64At(n,s,this.littleEndian);for(this.intent_p1=X.getDoubleAt(n,80,this.littleEndian),this.intent_p2=X.getDoubleAt(n,88,this.littleEndian),this.intent_p3=X.getDoubleAt(n,96,this.littleEndian),i=0;i<8;i+=1)s=104+i*8,this.pixDims[i]=X.getDoubleAt(n,s,this.littleEndian);for(this.vox_offset=X.getInt64At(n,168,this.littleEndian),this.scl_slope=X.getDoubleAt(n,176,this.littleEndian),this.scl_inter=X.getDoubleAt(n,184,this.littleEndian),this.cal_max=X.getDoubleAt(n,192,this.littleEndian),this.cal_min=X.getDoubleAt(n,200,this.littleEndian),this.slice_duration=X.getDoubleAt(n,208,this.littleEndian),this.toffset=X.getDoubleAt(n,216,this.littleEndian),this.slice_start=X.getInt64At(n,224,this.littleEndian),this.slice_end=X.getInt64At(n,232,this.littleEndian),this.description=X.getStringAt(n,240,320),this.aux_file=X.getStringAt(n,320,344),this.qform_code=X.getIntAt(n,344,this.littleEndian),this.sform_code=X.getIntAt(n,348,this.littleEndian),this.quatern_b=X.getDoubleAt(n,352,this.littleEndian),this.quatern_c=X.getDoubleAt(n,360,this.littleEndian),this.quatern_d=X.getDoubleAt(n,368,this.littleEndian),this.qoffset_x=X.getDoubleAt(n,376,this.littleEndian),this.qoffset_y=X.getDoubleAt(n,384,this.littleEndian),this.qoffset_z=X.getDoubleAt(n,392,this.littleEndian),a=0;a<3;a+=1)for(o=0;o<4;o+=1)s=400+(a*4+o)*8,this.affine[a][o]=X.getDoubleAt(n,s,this.littleEndian);this.affine[3][0]=0,this.affine[3][1]=0,this.affine[3][2]=0,this.affine[3][3]=1,this.slice_code=X.getIntAt(n,496,this.littleEndian),this.xyzt_units=X.getIntAt(n,500,this.littleEndian),this.intent_code=X.getIntAt(n,504,this.littleEndian),this.intent_name=X.getStringAt(n,508,524),this.dim_info=X.getByteAt(n,524),n.byteLength>e.MAGIC_COOKIE&&(this.extensionFlag[0]=X.getByteAt(n,540),this.extensionFlag[1]=X.getByteAt(n,541),this.extensionFlag[2]=X.getByteAt(n,542),this.extensionFlag[3]=X.getByteAt(n,543),this.extensionFlag[0]&&(this.extensions=X.getExtensionsAt(n,this.getExtensionLocation(),this.littleEndian,this.vox_offset),this.extensionSize=this.extensions[0].esize,this.extensionCode=this.extensions[0].ecode))}toFormattedString(){var e=X.formatNumber,t=``;return t+=`Datatype = `+ +this.datatypeCode+` (`+this.getDatatypeCodeString(this.datatypeCode)+`)
319
+ `,t+=`Bits Per Voxel = = `+this.numBitsPerVoxel+`
320
+ `,t+=`Image Dimensions (1-8): `+this.dims[0]+`, `+this.dims[1]+`, `+this.dims[2]+`, `+this.dims[3]+`, `+this.dims[4]+`, `+this.dims[5]+`, `+this.dims[6]+`, `+this.dims[7]+`
321
+ `,t+=`Intent Parameters (1-3): `+this.intent_p1+`, `+this.intent_p2+`, `+this.intent_p3+`
322
+ `,t+=`Voxel Dimensions (1-8): `+e(this.pixDims[0])+`, `+e(this.pixDims[1])+`, `+e(this.pixDims[2])+`, `+e(this.pixDims[3])+`, `+e(this.pixDims[4])+`, `+e(this.pixDims[5])+`, `+e(this.pixDims[6])+`, `+e(this.pixDims[7])+`
323
+ `,t+=`Image Offset = `+this.vox_offset+`
324
+ `,t+=`Data Scale: Slope = `+e(this.scl_slope)+` Intercept = `+e(this.scl_inter)+`
325
+ `,t+=`Display Range: Max = `+e(this.cal_max)+` Min = `+e(this.cal_min)+`
326
+ `,t+=`Slice Duration = `+this.slice_duration+`
327
+ `,t+=`Time Axis Shift = `+this.toffset+`
328
+ `,t+=`Slice Start = `+this.slice_start+`
329
+ `,t+=`Slice End = `+this.slice_end+`
330
+ `,t+=`Description: "`+this.description+`"
331
+ `,t+=`Auxiliary File: "`+this.aux_file+`"
332
+ `,t+=`Q-Form Code = `+this.qform_code+` (`+this.getTransformCodeString(this.qform_code)+`)
333
+ `,t+=`S-Form Code = `+this.sform_code+` (`+this.getTransformCodeString(this.sform_code)+`)
334
+ `,t+=`Quaternion Parameters: b = `+e(this.quatern_b)+` c = `+e(this.quatern_c)+` d = `+e(this.quatern_d)+`
335
+ `,t+=`Quaternion Offsets: x = `+this.qoffset_x+` y = `+this.qoffset_y+` z = `+this.qoffset_z+`
336
+ `,t+=`S-Form Parameters X: `+e(this.affine[0][0])+`, `+e(this.affine[0][1])+`, `+e(this.affine[0][2])+`, `+e(this.affine[0][3])+`
337
+ `,t+=`S-Form Parameters Y: `+e(this.affine[1][0])+`, `+e(this.affine[1][1])+`, `+e(this.affine[1][2])+`, `+e(this.affine[1][3])+`
338
+ `,t+=`S-Form Parameters Z: `+e(this.affine[2][0])+`, `+e(this.affine[2][1])+`, `+e(this.affine[2][2])+`, `+e(this.affine[2][3])+`
339
+ `,t+=`Slice Code = `+this.slice_code+`
340
+ `,t+=`Units Code = `+this.xyzt_units+` (`+this.getUnitsCodeString(Z.SPATIAL_UNITS_MASK&this.xyzt_units)+`, `+this.getUnitsCodeString(Z.TEMPORAL_UNITS_MASK&this.xyzt_units)+`)
341
+ `,t+=`Intent Code = `+this.intent_code+`
342
+ `,t+=`Intent Name: "`+this.intent_name+`"
343
+ `,t+=`Dim Info = `+this.dim_info+`
344
+ `,t}getExtensionLocation=function(){return e.MAGIC_COOKIE+4};getExtensionSize=Z.prototype.getExtensionSize;getExtensionCode=Z.prototype.getExtensionCode;addExtension=Z.prototype.addExtension;removeExtension=Z.prototype.removeExtension;getDatatypeCodeString=Z.prototype.getDatatypeCodeString;getTransformCodeString=Z.prototype.getTransformCodeString;getUnitsCodeString=Z.prototype.getUnitsCodeString;getQformMat=Z.prototype.getQformMat;convertNiftiQFormToNiftiSForm=Z.prototype.convertNiftiQFormToNiftiSForm;convertNiftiSFormToNEMA=Z.prototype.convertNiftiSFormToNEMA;nifti_mat33_mul=Z.prototype.nifti_mat33_mul;nifti_mat33_determ=Z.prototype.nifti_mat33_determ;toArrayBuffer(e=!1){let t=544;if(e)for(let e of this.extensions)t+=e.esize;let n=new Uint8Array(t),r=new DataView(n.buffer);r.setInt32(0,540,this.littleEndian),n.set(new TextEncoder().encode(this.magic),4),r.setInt16(12,this.datatypeCode,this.littleEndian),r.setInt16(14,this.numBitsPerVoxel,this.littleEndian);for(let e=0;e<8;e++)r.setBigInt64(16+8*e,BigInt(this.dims[e]),this.littleEndian);r.setFloat64(80,this.intent_p1,this.littleEndian),r.setFloat64(88,this.intent_p2,this.littleEndian),r.setFloat64(96,this.intent_p3,this.littleEndian);for(let e=0;e<8;e++)r.setFloat64(104+8*e,this.pixDims[e],this.littleEndian);r.setBigInt64(168,BigInt(this.vox_offset),this.littleEndian),r.setFloat64(176,this.scl_slope,this.littleEndian),r.setFloat64(184,this.scl_inter,this.littleEndian),r.setFloat64(192,this.cal_max,this.littleEndian),r.setFloat64(200,this.cal_min,this.littleEndian),r.setFloat64(208,this.slice_duration,this.littleEndian),r.setFloat64(216,this.toffset,this.littleEndian),r.setBigInt64(224,BigInt(this.slice_start),this.littleEndian),r.setBigInt64(232,BigInt(this.slice_end),this.littleEndian),n.set(new TextEncoder().encode(this.description),240),n.set(new TextEncoder().encode(this.aux_file),320),r.setInt32(344,this.qform_code,this.littleEndian),r.setInt32(348,this.sform_code,this.littleEndian),r.setFloat64(352,this.quatern_b,this.littleEndian),r.setFloat64(360,this.quatern_c,this.littleEndian),r.setFloat64(368,this.quatern_d,this.littleEndian),r.setFloat64(376,this.qoffset_x,this.littleEndian),r.setFloat64(384,this.qoffset_y,this.littleEndian),r.setFloat64(392,this.qoffset_z,this.littleEndian);let i=this.affine.flat();for(let e=0;e<12;e++)r.setFloat64(400+8*e,i[e],this.littleEndian);if(r.setInt32(496,this.slice_code,this.littleEndian),r.setInt32(500,this.xyzt_units,this.littleEndian),r.setInt32(504,this.intent_code,this.littleEndian),n.set(new TextEncoder().encode(this.intent_name),508),r.setUint8(524,this.dim_info),e){n.set(Uint8Array.from([1,0,0,0]),540);let e=this.getExtensionLocation();for(let t of this.extensions)r.setInt32(e,t.esize,t.littleEndian),r.setInt32(e+4,t.ecode,t.littleEndian),n.set(new Uint8Array(t.edata),e+8),e+=t.esize}else n.set(new Uint8Array(4).fill(0),540);return n.buffer}};function An(e,t=!1){var n,r,i,a;return e.byteLength<Z.STANDARD_HEADER_SIZE?!1:(n=new DataView(e),n&&(r=n.getUint8(Z.MAGIC_NUMBER_LOCATION)),i=n.getUint8(Z.MAGIC_NUMBER_LOCATION+1),a=n.getUint8(Z.MAGIC_NUMBER_LOCATION+2),t&&r===Z.MAGIC_NUMBER2[0]&&i===Z.MAGIC_NUMBER2[1]&&a===Z.MAGIC_NUMBER2[2]?!0:r===Z.MAGIC_NUMBER[0]&&i===Z.MAGIC_NUMBER[1]&&a===Z.MAGIC_NUMBER[2])}function jn(e,t=!1){var n,r,i,a;return e.byteLength<Z.STANDARD_HEADER_SIZE?!1:(n=new DataView(e),r=n.getUint8(Q.MAGIC_NUMBER_LOCATION),i=n.getUint8(Q.MAGIC_NUMBER_LOCATION+1),a=n.getUint8(Q.MAGIC_NUMBER_LOCATION+2),t&&r===Q.MAGIC_NUMBER2[0]&&i===Q.MAGIC_NUMBER2[1]&&a===Q.MAGIC_NUMBER2[2]?!0:r===Q.MAGIC_NUMBER[0]&&i===Q.MAGIC_NUMBER[1]&&a===Q.MAGIC_NUMBER[2])}function Mn(e,t=!1){return An(e,t)||jn(e,t)}function Nn(e){var t,n,r;return!!(e&&(t=new DataView(e),n=t.getUint8(0),r=t.getUint8(1),n===X.GUNZIP_MAGIC_COOKIE1||r===X.GUNZIP_MAGIC_COOKIE2))}function Pn(e){return(0,i.decompressSync)(new Uint8Array(e)).buffer}function Fn(e,t=!1){let n=null;if(Nn(e)&&(e=Pn(e)),An(e,t)?n=new Z:jn(e,t)&&(n=new Q),n)n.readHeader(e);else throw Error(`That file does not appear to be NIFTI!`);return n}function In(e,t){var n=e.vox_offset,r=1,i=1;e.dims[4]&&(r=e.dims[4]),e.dims[5]&&(i=e.dims[5]);var a=e.dims[1]*e.dims[2]*e.dims[3]*r*i*(e.numBitsPerVoxel/8);return t.slice(n,n+a)}var Ln={id:`mesh-location-orientation`,locations:[{identifier:1,label:`original`,orientation:[1,0,0,0,1,0,0,0,1],position:[0,0,0],scale:[1,1,1],flipY:!1,flipZ:!1,reference_point:`corner`}],settings:{slides:[{direction:`x`,value:.5},{direction:`y`,value:.5},{direction:`z`,value:.5}]},type:`slides`},Rn={hideBlackPixel:!0,keepScalePosition:!0,filterByValue:!0,timeEnabled:!1};function zn(e){let t=Nn(e)?Pn(e):e;if(Mn(t)){let e=Fn(t);return{niftiHeader:e,niftiImage:In(e,t)}}return t=void 0,{niftiHeader:void 0,niftiImage:void 0}}function Bn(e,t){let n;switch(e.datatypeCode){case Z.TYPE_UINT8:n=new Uint8Array(t);break;case Z.TYPE_INT8:n=new Int8Array(t);break;case Z.TYPE_UINT16:n=new Uint16Array(t);break;case Z.TYPE_INT16:n=new Int16Array(t);break;case Z.TYPE_UINT32:n=new Uint32Array(t);break;case Z.TYPE_INT32:n=new Int32Array(t);break;case Z.TYPE_FLOAT32:n=new Float32Array(t);break;case Z.TYPE_FLOAT64:n=new Float64Array(t);break;default:throw Error(`Unsupported NIfTI data type`)}let r=1/0,i=-1/0,a=n.length;for(let e=0;e<a;e++){let t=n[e];t<r&&(r=t),t>i&&(i=t)}let o=new Uint8Array(a),s=i-r;for(let e=0;e<a;e++){let t=(n[e]-r)/s;t=Math.max(0,Math.min(1,t)),o[e]=Math.round(t*255)}return o}function Vn(e,t,n,r){if(e?.dims&&e.dims[0]===3){let i=e.dims[1],a=e.dims[2],o=e.dims[3],s=!1;(e.intent_code===1007||e.intent_code===1008||e.datatypeCode===128||e.datatypeCode===2304)&&(s=!0);let c=Bn(e,t),l;if(n&&r){let e=n.dims[1],t=n.dims[2],s=n.dims[3];e===i&&t===a&&s===o&&(l=Bn(n,r))}return{data:c,maskData:l,width:i,height:a,depth:o,isRGB:s}}}function Hn(e,t){if(e?.affine&&e.dims){let n=e.affine,r=[0,0,0],i=[0,0,0];return r[0]=n[0][3],r[1]=n[1][3],r[2]=n[2][3],i[0]=n[0][0]*e.dims[1],i[1]=n[1][1]*e.dims[2],i[2]=n[2][2]*e.dims[3],t.keepScalePosition&&(i[0]=Math.abs(i[0]),i[1]=Math.abs(i[1]),i[2]=Math.abs(i[2])),{position:r,scale:i}}return{position:void 0,scale:void 0}}function Un(e,t){return e&&e.sform_code?Hn(e,t):{position:void 0,scale:void 0}}function Wn(t,n,r,i,a){let o=new e.DataTexture2DArray(t,n,r,i);return o.anisotropy=4,a||(o.format=e.RedFormat),o.minFilter=e.NearestFilter,o.magFilter=e.NearestFilter,o.needsUpdate=!0,o}function Gn(e){if(e?.data){let t=new Ze;return t.impl=new Wn(e.data,e.width,e.height,e.depth),t.size={width:e.width,height:e.height,depth:e.depth},t.isLoading=!1,t}}function Kn(e,t,n,r,i){if(t?.data){let a={...Rn};i&&Object.assign(a,i);let o=new rt,s=Gn(t);if(s){o.groupName=`Images`,o.morph.renderOrder=1,o.texture=s;let i=structuredClone(Ln);if(Object.assign(i,r),n&&e){let{position:t,scale:n}=Un(e,a);t&&n&&(i.locations[0].scale=n,i.locations[0].position=t)}if(o.initialise(i,void 0),o.showEdges(10066329),t.maskData&&!a.timeEnabled){let e=Wn(t.maskData,t.width,t.height,t.depth,!1);o.setMask(e)}return o.setNumberOfChannels(t.isRGB?3:1),o}}}async function qn(e,t){let n,r;if(t){let e=zn(await(await fetch(t)).arrayBuffer());n=e.niftiHeader,r=e.niftiImage}let{niftiHeader:i,niftiImage:a}=zn(await(await fetch(e)).arrayBuffer());return{sources:Vn(i,a,n,r),niftiHeader:i}}async function Jn(e,t,n,r,i){let a=!1,o,s=e;if(Array.isArray(e)&&(s=e[0],e.length>1&&i?.timeEnabled&&(a=!0)),typeof s==`string`){let{sources:e,niftiHeader:a}=await qn(s,n,i);o=Kn(a,e,t,r,i)}if(a&&o){for(let t=1;t<e.length;t++){let r=await Yn(e[t],n,i);o.addTextureArray(r)}o.timeEnabled=!0}return o}async function Yn(e,t,n){let{sources:r}=await qn(e,t,n);return Gn(r)}var Xn=p.version,$=new function(){this.Revision=Xn,this.defaultMaterialColor=16777215,this.defaultOpacity=1,this.Geometry=Ce,this.Glyph=Ee,this.Glyphset=Re,this.Pointset=Je,this.Label=Te,this.Lines=Ye,this.TextureSlides=rt,this.TextureArray=Ze,this.Renderer=On,this.Scene=Dn,this.Viewport=it,this.CameraControls=at,this.SmoothCameraTransition=ot,this.RayCaster=ct,this.CameraAutoTumble=lt,this.StereoEffect=dt,this.loadExternalFile=T,this.loadExternalFiles=E,this.createPrimitivesFromNIFTI=Jn,this.createTextureFromNIFTI=Yn,this.THREE=e};return $});
345
+ //# sourceMappingURL=zinc.js.map