zincjs 2.1.0 → 2.1.1

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,Ve,Yi,Xi){"use strict";var bn=Object.defineProperty;var An=(b,Ae,Ve)=>Ae in b?bn(b,Ae,{enumerable:!0,configurable:!0,writable:!0,value:Ve}):b[Ae]=Ve;var D=(b,Ae,Ve)=>An(b,typeof Ae!="symbol"?Ae+"":Ae,Ve);function Ki(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=Ki(b),Ji={version:"2.1.0"},Le=new b.Matrix4,pt=new b.Object3D,et=new b.Vector3,Be=new b.Vector3;function Re(){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}Re.prototype=Object.assign(Object.create(b.EventDispatcher.prototype),{constructor:Re,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 Le.makeRotationX(r),this.applyMatrix4(Le),this},rotateY:function(r){return Le.makeRotationY(r),this.applyMatrix4(Le),this},rotateZ:function(r){return Le.makeRotationZ(r),this.applyMatrix4(Le),this},translate:function(r,e,t){return Le.makeTranslation(r,e,t),this.applyMatrix4(Le),this},scale:function(r,e,t){return Le.makeScale(r,e,t),this.applyMatrix4(Le),this},lookAt:function(r){return pt.lookAt(r),pt.updateMatrix(),this.applyMatrix4(pt.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 Xe(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(et).negate(),this.translate(et.x,et.y,et.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 Re;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)Be.set(l.normals2[d],l.normals2[d+1],l.normals2[d+2]),e!==void 0&&Be.applyMatrix4(e),c.normals.push(Be.x,Be.y,Be.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)Be.set(a[d],a[d+1],a[d+2]),e!==void 0&&Be.applyMatrix4(e),this.normals.push(Be.x,Be.y,Be.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 Xe(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 Re().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 Qi().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"})}}),Re.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 Qi{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 Xe{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 $i="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==",Hi=Ae.default||Ae;function Me(r){let e=r,t=Ie.modelPrefix;return t&&(t[t.length-1]!="/"&&(t=t+"/"),new RegExp("^(?:[a-z]+:)?//","i").test(r)||(e=t+r)),e}function ze(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 es(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 Dt(r,e,t,s){fetch(Me(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 ts(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++)Dt(r[a],a,o,t)}const is=(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]},kt=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]]))}},tt=(r,e)=>{let t;return r instanceof Re?(e.localTimeEnabled&&!r.morphNormalsReady&&(r.morphNormals==null||r.morphNormals.length==0)&&r.computeMorphNormals(),t=r.toIndexedBufferGeometry(),e.localMorphColour&&ss(r,t)):r instanceof M.BufferGeometry&&(t=r.clone()),t.colorsNeedUpdate=!0,t.computeBoundingBox(),t.computeBoundingSphere(),r._video&&(t._video=r._video),t},ss=(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=is(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 Vt(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 ns=(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=Vt(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=Vt(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 mt(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 Rt(){const r=new Image;r.src=$i;const e=new M.Texture;return e.image=r,e.needsUpdate=!0,e}function gt(r,e,t,s,i,n){const o=new Hi(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 Ft(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 rs(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 Gt=function(){return function(r){r.vertexShader=r.vertexShader.replace("#include <color_pars_vertex>",["varying vec3 vColor;","attribute vec3 morphColor0;","attribute vec3 morphColor1;"].join(`
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
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
- `))}},zt=new b.Vector3,jt=new b.Vector3,qt=new b.Matrix4,yt=new b.Ray,it=new b.Sphere,xt=new b.Vector3,bt=new b.Vector3,Wt=new b.Vector3,Zt=new b.Vector3;class Yt 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++)zt.fromBufferAttribute(t,i-1),jt.fromBufferAttribute(t,i),s[i]=s[i-1],s[i]+=zt.distanceTo(jt);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(),it.copy(s.boundingSphere),it.applyMatrix4(i),it.radius+=n,e.ray.intersectsSphere(it)===!1)return;qt.copy(i).invert(),yt.copy(e.ray).applyMatrix4(qt);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(Xt(c,l,this,g,a,V,R),yt.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(Xt(c,l,this,g,a,I,I+1),yt.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 Xt(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){xt.set(0,0,0),bt.set(0,0,0);for(var h=0,f=i.length;h<f;h++){var c=a[h],l=i[h];c!==0&&(Wt.fromBufferAttribute(l,n),Zt.fromBufferAttribute(l,o),xt.addScaledVector(Wt.sub(r),c),bt.addScaledVector(Zt.sub(e),c))}r.add(xt),e.add(bt)}}Yt.prototype.isLine=!0;const Kt=new b.Vector3,Jt=new b.Vector3;class st extends Yt{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)Kt.fromBufferAttribute(t,i),Jt.fromBufferAttribute(t,i+1),s[i]=i===0?0:s[i-1],s[i+1]=s[i]+Kt.distanceTo(Jt);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}}st.prototype.isLineSegments=!0;const os=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=tt(s,n);let a;this._parent.isGeometry?a=new M.Mesh(o,i):this._parent.isLines&&(a=new st(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();kt(s.geometry,s)}else this.levels.forEach(s=>{s.morph&&s.morph.geometry&&kt(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)})}},as="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",Qt=new Image(128,128);Qt.src=as;const nt=new M.Texture;nt.image=Qt,nt.needsUpdate=!0;const At=[.02,.03,1],ls=new M.SpriteMaterial({map:nt,alphaTest:.5,transparent:!0,depthTest:!1,depthWrite:!1,sizeAttenuation:!1}),$t=function(r){Object.getPrototypeOf(this)!==Q.prototype&&Object.setPrototypeOf($t.prototype,Q.prototype),Q.call(this),this.texture=nt;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(ls),e.center.set(.5,0),this.morph.add(e),this.morph.position.set(0,0,0),this.morph.renderOrder=1e4,e.scale.set(At[0],At[1],At[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=gt(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 cs=0;const hs=function(){return"pr"+cs++},Q=function(){this.isZincObject=!0,this.geometry=void 0,this.morph=void 0,this.group=new M.Group,this._lod=new os(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=hs(),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&&(es(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 $t(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=mt(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&&rs(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(Me(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 us=(r,e,t)=>{let s=tt(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=Gt())}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)},Ke=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=us(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}}}};Ke.prototype=Object.create(Q.prototype);const Ht=Ae.default||Ae,wt=function(r,e){let t=r,s,i=500;e?s=new Ht(t,.012,e.getStyle()):s=new Ht(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},rt=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 wt(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}};rt.prototype=Object.create(Q.prototype);function ot(){}ot.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(ot.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,_=ot.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 fs=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()},ei=M.AnimationClip,vt=M.Color,ds=M.DefaultLoadingManager,ps=M.FileLoader,ms=M.LoaderUtils,ti=M.Vector2,Je=M.Vector3,ii=M.Vector4;function at(r){typeof r=="boolean"&&(console.warn("THREE.JSONLoader: showStatus parameter has been removed from constructor."),r=void 0),this.manager=r!==void 0?r:ds,this.withCredentials=!1,this.paramsString=""}Object.assign(at.prototype,{load:function(r,e,t,s){var i=this,n=this.texturePath&&typeof this.texturePath=="string"?this.texturePath:ms.extractUrlBase(r),o=new ps(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 Je,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 Xe,L.a=O[c],L.b=O[c+1],L.c=O[c+3],T=new Xe,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 ti(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 Je(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 vt(U)),a!==0&&T.vertexColors.push(new vt(U));n.faces.push(L),n.faces.push(T)}else{if(G=new Xe,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 ti(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 Je(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 vt(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 ii(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 ii(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 Je;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 Je;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=ei.parseAnimation(a[h],n.bones);f&&o.push(f)}if(n.morphTargets){var c=ei.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 Re;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=ot.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 fs(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 _t=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 at;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 ke=(c[0]+se*u[0])*this.globalScale;$[0]=ge[0]*ke,$[1]=ge[1]*ke,$[2]=ge[2]*ke,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 Ge=(c[2]+se*u[2])*this.globalScale/ce;p=="AXES_2D"&&ne>0&&(Ge*=-1),ue[0]*=Ge,ue[1]*=Ge,ue[2]*=Ge}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()],ke=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)*ke[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 rt(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 rt(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)}};_t.prototype=Object.create(Q.prototype);const si=new b.Matrix4,Mt=new b.Ray,lt=new b.Sphere,Qe=new b.Vector3,St=new b.Vector3,ni=new b.Vector3;class Ct 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(),lt.copy(s.boundingSphere),lt.applyMatrix4(i),lt.radius+=n,e.ray.intersectsSphere(lt)===!1)return;si.copy(i).invert(),Mt.copy(e.ray).applyMatrix4(si);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);oi(this,l,d,g),ri(Qe,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++)oi(this,l,d,y),ri(Qe,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.")}}}Ct.prototype.isPoints=!0;function ri(r,e,t,s,i,n,o){const a=Mt.distanceSqToPoint(r);if(a<t){const h=new b.Vector3;Mt.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 oi(r,e,t,s){Qe.fromBufferAttribute(e,s);const i=r.morphTargetInfluences;if(r.material.morphTargets&&t&&i){St.set(0,0,0);for(var n=0,o=t.length;n<o;n++){const a=i[n],h=t[n];a!==0&&(ni.fromBufferAttribute(h,s),St.addScaledVector(ni.sub(Qe),a))}Qe.add(St)}}const De=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=tt(a,f);const l=Rt();h.map=l;let d=new Ct(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 wt(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 De.prototype.deleteVertices.call(this,a)&&o(a),this.drawRange},this.setName=function(a){const h=this.groupName;De.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),De.prototype.render.call(this,a,h,f,c)}};De.prototype=Object.create(Q.prototype);const je=function(){Q.call(this),this.isLines=!0,this.createLineSegment=(r,e,t)=>{if(r&&e){let s=tt(r,t);t.localMorphColour&&s.morphAttributes.color&&(e.onBeforeCompile=Gt());let i=new st(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)}}};je.prototype=Object.create(Q.prototype);const Fe=function(){this.isTexture=!0,this.impl=void 0,this.isLoading=!1,this.size={width:1,height:1,depth:0}};Fe.prototype.loadImage=function(r,e){return new Promise((t,s)=>{r.onload=()=>t(r),r.onerror=s,r.src=e})},Fe.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}},Fe.prototype.loadFromImages=async function(r){},Fe.prototype.isReady=function(){return!!(this.impl&&!this.isLoading)},Fe.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 ct=function(){Fe.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}}};ct.prototype=Object.create(Fe.prototype);const gs=M.GLSL3,ys=`
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=`
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
- `,xs=`
40
+ `,ys=`
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
- `,bs=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}}},qe=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 ct,n=[];e.images.source.forEach(a=>{n.push(Me(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)}};qe.prototype=Object.create(Q.prototype),qe.prototype.constructor=qe;const We=function(r){qe.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 _=bs();_.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:ys,vs:xs,uniforms:_,glslVersion:gs,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()}),qe.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()}}};We.prototype=Object.create(qe.prototype),We.prototype.constructor=We;const Ze=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}},ai=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 Ze};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()},ke=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),Oe=Math.sin(z);return w.set(ve*T.x+Oe*U.x,ve*T.y+Oe*U.y,ve*T.z+Oe*U.z),C.set(ve*U.x-Oe*T.x,ve*U.y-Oe*T.y,ve*U.z-Oe*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 Ge=()=>{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 Oe=Math.acos(ve/Z)-.5*Math.PI,He=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(Oe)),L.multiplyScalar(Math.sin(Oe)),E.add(L),this.rotateAboutLookAtpoint(E,-He)}}}this.previous_pointer_x=this.pointer_x,this.previous_pointer_y=this.pointer_y},qi=()=>{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 gn=()=>{const A=qi();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",ke,!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",ke,!1),X(this.domElement,-1))},this.loadPath=A=>{d=A.CameraPath,u=A.NumberOfPoints},this.loadPathURL=(A,z)=>{const Z=Me(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 yn=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 Wi=A=>{if(v===i.PATH&&(yn(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=()=>{Wi(0)};const xn=()=>{this._state===n.ROTATE||this._state===n.TOUCH_ROTATE||this._state===n.KEYBOARD_ROTATE?Ge():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(qi()),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?Wi(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?(xn(),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?Ge():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)&&gn(),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 ws(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],Oe=pe+fe;let He=0;const Zi=.95;fe>Zi*pe?He=(1-Zi)*pe:He=pe-fe;const Ye=new Ze;return Ye.nearPlane=He,Ye.farPlane=Oe,Ye.eyePosition=ve,Ye.targetPosition=be,Ye.upVector=[this.cameraObject.up.x,this.cameraObject.up.y,this.cameraObject.up.z],Ye},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 Ze;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 li(A,z,this,Z))},this.rotateCameraTransition=(A,z,Z)=>{_==null&&(I=new As(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 hi(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 ci(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 vs),P.setCurrentCameraSettings(this.cameraObject,j[g]),P),this.disableSyncControl=()=>{v=i.DEFAULT,this.cameraObject.zoom=1,this.cameraObject.updateProjectionMatrix()},this.enable()},li=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},As=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},ci=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)}},hi=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))}},ui=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(ui.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 fi=function(r){const e=new ui;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)}},ws=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()},vs=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()}},_s="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",di=new Image(128,128);di.src=_s;const ht=new M.Texture;ht.image=di,ht.needsUpdate=!0;const Tt=[.02,.03,1],Ms=new M.SpriteMaterial({map:ht,alphaTest:.5,transparent:!0,depthTest:!1,depthWrite:!1,sizeAttenuation:!1}),pi=function(r){Q.call(this),this.texture=ht;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(Ms);return y.clusterIndex=u,y.center.set(.5,0),y.position.set(0,0,0),y.renderOrder=1e4,y.scale.set(Tt[0],Tt[1],Tt[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=gt(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}};pi.prototype=Object.create(Q.prototype);const Ss=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)}}},mi=new b.Box3,ut=new b.Vector3;class Ot 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),mi.setFromBufferAttribute(t),this.boundingBox.union(mi))}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++)ut.fromBufferAttribute(e,n),i=Math.max(i,s.distanceToSquared(ut)),ut.fromBufferAttribute(t,n),i=Math.max(i,s.distanceToSquared(ut));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)}}Ot.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
+ `,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:`
69
69
  #include <common>
70
70
  #include <color_pars_vertex>
71
71
  #include <fog_pars_vertex>
@@ -284,11 +284,11 @@ void main() {
284
284
  #include <fog_fragment>
285
285
  #include <premultiplied_alpha_fragment>
286
286
 
287
- }`};class Lt 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)}}Lt.prototype.isLineMaterial=!0;const gi=new b.Vector3,yi=new b.Vector3,ye=new b.Vector4,xe=new b.Vector4,Ue=new b.Vector4,Bt=new b.Vector3,Ut=new b.Matrix4,Se=new b.Line3,xi=new b.Vector3,Ee=new b.Box3,ft=new b.Sphere,Ne=new b.Vector4;class bi extends b.Mesh{constructor(e=new Ot,t=new Lt({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)gi.fromBufferAttribute(t,o),yi.fromBufferAttribute(s,o),i[a]=a===0?0:i[a-1],i[a+1]=i[a]+gi.distanceTo(yi);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(),ft.copy(h.boundingSphere).applyMatrix4(a);const x=Math.max(n.near,ft.distanceToPoint(i.origin));Ne.set(0,0,-x,1).applyMatrix4(n.projectionMatrix),Ne.multiplyScalar(1/Ne.w),Ne.applyMatrix4(n.projectionMatrixInverse);const g=Math.abs(y/Ne.w)*.5;if(ft.radius+=g,e.ray.intersectsSphere(ft)===!1)return;h.boundingBox===null&&h.computeBoundingBox(),Ee.copy(h.boundingBox).applyMatrix4(a);const v=Math.max(n.near,Ee.distanceToPoint(i.origin));Ne.set(0,0,-v,1).applyMatrix4(n.projectionMatrix),Ne.multiplyScalar(1/Ne.w),Ne.applyMatrix4(n.projectionMatrixInverse);const _=Math.abs(y/Ne.w)*.5;if(Ee.max.x+=_,Ee.max.y+=_,Ee.max.z+=_,Ee.min.x-=_,Ee.min.y-=_,Ee.min.z-=_,e.ray.intersectsBox(Ee)!==!1){i.at(1,Ue),Ue.w=1,Ue.applyMatrix4(n.matrixWorldInverse),Ue.applyMatrix4(o),Ue.multiplyScalar(1/Ue.w),Ue.x*=c.x/2,Ue.y*=c.y/2,Ue.z=0,Bt.copy(Ue),Ut.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(Ut),xe.applyMatrix4(Ut);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,Se.start.copy(ye),Se.start.z=0,Se.end.copy(xe),Se.end.z=0;const R=Se.closestPointToPointParameter(Bt,!0);Se.at(R,xi);const W=b.MathUtils.lerp(ye.z,xe.z,R),G=W>=-1&&W<=1,L=Bt.distanceTo(xi)<l*.5;if(G&&L){Se.start.fromBufferAttribute(d,k),Se.end.fromBufferAttribute(u,k),Se.start.applyMatrix4(a),Se.end.applyMatrix4(a);const T=new b.Vector3,U=new b.Vector3;i.distanceSqToSegment(Se.start,Se.end,U,T),t.push({point:U,pointOnLine:T,distance:i.origin.distanceTo(U),object:this,face:null,faceIndex:k,uv:null,uv2:null})}}}}}bi.prototype.LineSegments2=!0;const dt=function(){je.call(this),this.isLines2=!0;let r=new Array(300);this.createLineSegment=(e,t,s)=>{if(e&&t){const i=new Ot;i.setPositions(e),i.colorsNeedUpdate=!0;const n=new bi(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 Lt({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)}};dt.prototype=Object.create(je.prototype),dt.prototype.constructor=dt;let Cs=0;const Ts=function(){return"re"+Cs++};let Ai=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=Ts(),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 Ai(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 De;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 dt;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 Ke,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 Nt{constructor(){this.pluginCallbacks=[],this.register(function(e){return new Ds(e)}),this.register(function(e){return new ks(e)}),this.register(function(e){return new Vs(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 Es,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 wi={scale:"scale",position:"translation",quaternion:"rotation",morphTargetInfluences:"weights"},vi=12,Os=1179937895,Ls=2,_i=8,Bs=1313821514,Us=5130562;function $e(r,e){return r.length===e.length&&r.every(function(t,s){return t===e[s]})}function Ns(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 Is(r){return $e(r.elements,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}function Ps(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 Mi(r){return Math.ceil(r/4)*4}function It(r,e=0){const t=Mi(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 Si=null;class Es{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=It(l.result),u=new DataView(new ArrayBuffer(_i));u.setUint32(0,d.byteLength,!0),u.setUint32(4,Us,!0);const p=It(Ns(JSON.stringify(o)),32),y=new DataView(new ArrayBuffer(_i));y.setUint32(0,p.byteLength,!0),y.setUint32(4,Bs,!0);const x=new ArrayBuffer(vi),g=new DataView(x);g.setUint32(0,Os,!0),g.setUint32(4,Ls,!0);const v=vi+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=Mi(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=It(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=Ps(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=Si=Si||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($e(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=Nt.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=wi[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===wi.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();$e(a,[0,0,0,1])||(n.rotation=a),$e(h,[0,0,0])||(n.translation=h),$e(f,[1,1,1])||(n.scale=f)}else e.matrixAutoUpdate&&e.updateMatrix(),Is(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 Ds{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 ks{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 Vs{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}}Nt.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 Rs=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 Nt,a={binary:t,animations:n};return new Promise((h,f)=>{o.parse(e.getThreeJSScene(),function(c){h(c)},a)})}},Fs=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 Ke:e.type==="LineSegments"?o=new je:e.type==="Points"&&(o=new De),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 Yi.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()})}},Gs=/^[og]\s*(.+)?/,zs=/^mtllib /,js=/^usemtl /,qs=/^usemap /,Ci=new b.Vector3,Pt=new b.Vector3,Ti=new b.Vector3,Oi=new b.Vector3,Ce=new b.Vector3;function Ws(){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;Ci.fromArray(i,e),Pt.fromArray(i,t),Ti.fromArray(i,s),Ce.subVectors(Ti,Pt),Oi.subVectors(Ci,Pt),Ce.cross(Oi),Ce.normalize(),n.push(Ce.x,Ce.y,Ce.z),n.push(Ce.x,Ce.y,Ce.z),n.push(Ce.x,Ce.y,Ce.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 Li 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 Ws;e.indexOf(`\r
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
288
  `)!==-1&&(e=e.replace(/\r\n/g,`
289
289
  `)),e.indexOf(`\\
290
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=Gs.exec(i))!==null){const u=(" "+a[0].substr(1).trim()).substr(1);t.startObject(u)}else if(js.test(i))t.object.startMaterial(i.substring(7).trim(),t.materialLibraries);else if(zs.test(i))t.materialLibraries.push(i.substring(7).trim());else if(qs.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 Bi=M.FileLoader,Zs=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])}},Ys=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]}},Xs=function(r,e,t){const s=new Bi,i=new at;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))}},Ks=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]));Zs(c),n(c[0])}else{const c=s[0][1],l=s.map(u=>u[0]),d=Ys(l);for(let u=1;u<i;u++)s[h][0].dispose(),s[h][1].forEach(p=>p.dispose());n(d,c)}}},Js=function(){let r=0;const e=20;this.crossOrigin="Anonymous";const t=new at,s=new Bi;s.crossOrigin="Anonymous";const i=[],n={},o=(c,l,d,u,p)=>{const y=c.length,x=new Ks(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 Xs(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 Ui 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 Ni=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=ns(h,!0),h.forEach(f=>f.dispose())}return a}};Ni.prototype=Object.create(Q.prototype);const Qs=function(r){const e=r;this.toBeDownloaded=0,this.progressMap={};let t=!1,s=!1;const i=new Js;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=ze(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=Me(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=Ie.defaultMaterialColor,P=Ie.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(Me(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=Me(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 Ni:new je;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 _t;P.setDuration(e.getDuration()),P.groupName=U;let F=()=>{--this.toBeDownloaded,w!=null&&typeof w=="function"&&w(P)};++this.toBeDownloaded,m?P.load(N,T,F,m,B):P.load(N,Me(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 De;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=Ie.defaultMaterialColor,E=Ie.defaultOpacity,N=new Ui;N.crossOrigin="Anonymous",N.load(Me(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=Ie.defaultMaterialColor,E=Ie.defaultOpacity,N=new Li;N.crossOrigin="Anonymous",N.load(Me(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=Ie.defaultMaterialColor,O=Ie.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 Ui;else if(P=="OBJ"){X=new Li,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=ze(S[P],T);U.images.source[P]=F}}if(U.type==="slides"&&(B=new We),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=Me(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 Ke;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=ze(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=ze(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=ze(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=ze(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 Fs().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(Ft(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(Ft(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=Me(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 $s=0;const Hs=function(){return"sc"+$s++},Ii=function(){return{Duration:"6 secs",OriginalDuration:"-",TimeStamps:{}}},en=6e3,Et=function(r,e){const t=r;let s,i,n=new Qs(this),o,a={},h=0,f={},c=0;const l=new M.Scene,d=new M.Scene,u=new Ai(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=Ii(),k=new M.Vector2,V=[];this.forcePickableObjectsUpdate=!1,this.uuid=Hs();let R=new pi(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 ai(this.camera,e.domElement,e,this),x.setDirectionalLight(this.directionalLight),x.resetView(),o=new Ss(this)})(),this.loadView=m=>{const O=new Ze;return O.setFromObject(m),x.setCurrentCameraSettings(O),!0},this.setupMultipleViews=(m,O)=>{for(const[B,S]of Object.entries(O)){const P=new Ze;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 fi(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=Ii()},this.resetDuration=()=>{this.setDuration(en)};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 Rs(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=mt(m.length,m);let S=new M.PointsMaterial({alphaTest:.5,size:15,color:O,sizeAttenuation:!1});const P=Rt();S.map=P;let F=new Ct(B,S);return p.add(F),F},this.addTemporaryLines=(m,O)=>{const B=mt(m.length,m),S=new M.LineBasicMaterial({color:O}),P=new st(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=gt(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)})}},tn=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 Et(k,t):C=new Et(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 Ve.ResizeSensor(e,this.onWindowResize)):k&&k.width>0&&k.height>0&&(V=new Ve.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 sn{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 sn(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+`
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
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
293
  `,t+="Intent Parameters (1-3): "+this.intent_p1+", "+this.intent_p2+", "+this.intent_p3+`
294
294
  `,t+="Intent Code = "+this.intent_code+`
@@ -315,7 +315,7 @@ void main() {
315
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
316
  `,t+='Intent Name: "'+this.intent_name+`"
317
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 Pe=class Pe{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 Pe.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!==Pe.MAGIC_COOKIE&&(this.littleEndian=!0,s=q.getIntAt(t,0,this.littleEndian)),s!==Pe.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>Pe.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)+`)
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
319
  `,t+="Bits Per Voxel = = "+this.numBitsPerVoxel+`
320
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
321
  `,t+="Intent Parameters (1-3): "+this.intent_p1+", "+this.intent_p2+", "+this.intent_p3+`
@@ -341,5 +341,5 @@ void main() {
341
341
  `,t+="Intent Code = "+this.intent_code+`
342
342
  `,t+='Intent Name: "'+this.intent_name+`"
343
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(Pe,"MAGIC_COOKIE",540),D(Pe,"MAGIC_NUMBER_LOCATION",4),D(Pe,"MAGIC_NUMBER",[110,43,50,0,13,10,26,10]),D(Pe,"MAGIC_NUMBER2",[110,105,50,0,13,10,26,10]);let Te=Pe;function Pi(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 Ei(r,e=!1){var t,s,i,n;return r.byteLength<ie.STANDARD_HEADER_SIZE?!1:(t=new DataView(r),s=t.getUint8(Te.MAGIC_NUMBER_LOCATION),i=t.getUint8(Te.MAGIC_NUMBER_LOCATION+1),n=t.getUint8(Te.MAGIC_NUMBER_LOCATION+2),e&&s===Te.MAGIC_NUMBER2[0]&&i===Te.MAGIC_NUMBER2[1]&&n===Te.MAGIC_NUMBER2[2]?!0:s===Te.MAGIC_NUMBER[0]&&i===Te.MAGIC_NUMBER[1]&&n===Te.MAGIC_NUMBER[2])}function nn(r,e=!1){return Pi(r,e)||Ei(r,e)}function Di(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 ki(r){return Xi.decompressSync(new Uint8Array(r)).buffer}function rn(r,e=!1){let t=null;if(Di(r)&&(r=ki(r)),Pi(r,e)?t=new ie:Ei(r,e)&&(t=new Te),t)t.readHeader(r);else throw new Error("That file does not appear to be NIFTI!");return t}function on(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 an={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"},ln={hideBlackPixel:!0,keepScalePosition:!0,filterByValue:!0,timeEnabled:!1};function Vi(r){let e=Di(r)?ki(r):r;if(nn(e)){let t=rn(e),s=on(t,e);return{niftiHeader:t,niftiImage:s}}return e=void 0,{niftiHeader:void 0,niftiImage:void 0}}function Ri(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 cn(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=Ri(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=Ri(t,s))}return{data:h,maskData:f,width:i,height:n,depth:o,isRGB:a}}}function hn(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 un(r,e){return r&&r.sform_code?hn(r,e):{position:void 0,scale:void 0}}function Fi(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 Gi(r){if(r!=null&&r.data){const e=new ct;return e.impl=new Fi(r.data,r.width,r.height,r.depth),e.size={width:r.width,height:r.height,depth:r.depth},e.isLoading=!1,e}}function fn(r,e,t,s,i){if(e!=null&&e.data){const n={...ln};i&&Object.assign(n,i);const o=new We,a=Gi(e);if(a){o.groupName="Images",o.morph.renderOrder=1,o.texture=a;const h=structuredClone(an);if(Object.assign(h,s),t&&r){const{position:f,scale:c}=un(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=Fi(e.maskData,e.width,e.height,e.depth,!1);o.setMask(f)}return o.setNumberOfChannels(e.isRGB?3:1),o}}}async function zi(r,e){let t,s;if(e){const c=await(await fetch(e)).arrayBuffer(),l=Vi(c);t=l.niftiHeader,s=l.niftiImage}const n=await(await fetch(r)).arrayBuffer(),{niftiHeader:o,niftiImage:a}=Vi(n);return{sources:cn(o,a,t,s),niftiHeader:o}}async function dn(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 zi(a,t);o=fn(f,h,e,s,i)}if(n&&o){for(let h=1;h<r.length;h++){const f=await ji(r[h],t);o.addTextureArray(f)}o.timeEnabled=!0}return o}async function ji(r,e,t){const{sources:s}=await zi(r,e);return Gi(s)}const pn=Ji.version,mn=function(){this.Revision=pn,this.defaultMaterialColor=16777215,this.defaultOpacity=1,this.modelPrefix=void 0,this.Geometry=Ke,this.Glyph=rt,this.Glyphset=_t,this.Pointset=De,this.Label=wt,this.Lines=je,this.TextureArray=ct,this.TextureSlides=We,this.Renderer=tn,this.Scene=Et,this.Viewport=Ze,this.CameraControls=ai,this.SmoothCameraTransition=li,this.RayCaster=ci,this.CameraAutoTumble=hi,this.StereoEffect=fi,this.loadExternalFile=Dt,this.loadExternalFiles=ts,this.createPrimitivesFromNIFTI=dn,this.createTextureFromNIFTI=ji,this.THREE=M},Ie=new mn;return Ie});
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
345
  //# sourceMappingURL=zinc.js.map