zincjs 2.0.0 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/zinc.js +60 -7
- package/build/zinc.js.map +1 -1
- package/package.json +2 -2
- package/src/loaders/niftiReader.js +3 -5
- package/src/primitives/glyphset.js +19 -3
- package/src/sceneLoader.js +2 -4
- package/src/zinc.js +6 -0
- package/vite.config.js +7 -2
package/build/zinc.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
(function(v,Oe){typeof exports=="object"&&typeof module<"u"?module.exports=Oe(require("three"),require("three-spritetext"),require("css-element-queries"),require("three/examples/jsm/loaders/GLTFLoader")):typeof define=="function"&&define.amd?define(["three","three-spritetext","css-element-queries","three/examples/jsm/loaders/GLTFLoader"],Oe):(v=typeof globalThis<"u"?globalThis:v||self,v.Zinc=Oe(v.THREE,v.SpriteText,v.cssElememtQueries,v.GLTFLoader))})(this,function(v,Oe,Ot,Bi){"use strict";function Ui(n){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(n){for(const t in n)if(t!=="default"){const s=Object.getOwnPropertyDescriptor(n,t);Object.defineProperty(e,t,s.get?s:{enumerable:!0,get:()=>n[t]})}}return e.default=n,Object.freeze(e)}const S=Ui(v),Ni={version:"2.0.0"},we=new v.Matrix4,rt=new v.Object3D,qe=new v.Vector3,Ae=new v.Vector3;function Be(){this.uuid=v.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}Be.prototype=Object.assign(Object.create(v.EventDispatcher.prototype),{constructor:Be,isGeometry:!0,applyMatrix4:function(n){const e=new v.Matrix3().getNormalMatrix(n);for(let t=0,s=this.vertices.length;t<s;t++)this.vertices[t].applyMatrix4(n);for(let t=0,s=this.faces.length;t<s;t++){const i=this.faces[t];i.normal.applyMatrix3(e).normalize();for(let r=0,o=i.vertexNormals.length;r<o;r++)i.vertexNormals[r].applyMatrix3(e).normalize()}return this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this.verticesNeedUpdate=!0,this.normalsNeedUpdate=!0,this},rotateX:function(n){return we.makeRotationX(n),this.applyMatrix4(we),this},rotateY:function(n){return we.makeRotationY(n),this.applyMatrix4(we),this},rotateZ:function(n){return we.makeRotationZ(n),this.applyMatrix4(we),this},translate:function(n,e,t){return we.makeTranslation(n,e,t),this.applyMatrix4(we),this},scale:function(n,e,t){return we.makeScale(n,e,t),this.applyMatrix4(we),this},lookAt:function(n){return rt.lookAt(n),rt.updateMatrix(),this.applyMatrix4(rt.matrix),this},fromBufferGeometry:function(n){const e=this,t=n.index!==null?n.index:void 0,s=n.attributes;if(s.position===void 0)return console.error("THREE.Geometry.fromBufferGeometry(): Position attribute required for conversion."),this;const i=s.position,r=s.normal,o=s.color,a=s.uv,u=s.uv2;u!==void 0&&(this.faceVertexUvs[1]=[]);for(let c=0;c<i.count;c++)e.vertices.push(new v.Vector3().fromBufferAttribute(i,c)),o!==void 0&&e.colors.push(new v.Color().fromBufferAttribute(o,c));function f(c,d,h,p){const w=o===void 0?[]:[e.colors[c].clone(),e.colors[d].clone(),e.colors[h].clone()],y=r===void 0?[]:[new v.Vector3().fromBufferAttribute(r,c),new v.Vector3().fromBufferAttribute(r,d),new v.Vector3().fromBufferAttribute(r,h)],g=new De(c,d,h,y,w,p);e.faces.push(g),a!==void 0&&e.faceVertexUvs[0].push([new v.Vector2().fromBufferAttribute(a,c),new v.Vector2().fromBufferAttribute(a,d),new v.Vector2().fromBufferAttribute(a,h)]),u!==void 0&&e.faceVertexUvs[1].push([new v.Vector2().fromBufferAttribute(u,c),new v.Vector2().fromBufferAttribute(u,d),new v.Vector2().fromBufferAttribute(u,h)])}const l=n.groups;if(l.length>0)for(let c=0;c<l.length;c++){const d=l[c],h=d.start,p=d.count;for(let w=h,y=h+p;w<y;w+=3)t!==void 0?f(t.getX(w),t.getX(w+1),t.getX(w+2),d.materialIndex):f(w,w+1,w+2,d.materialIndex)}else if(t!==void 0)for(let c=0;c<t.count;c+=3)f(t.getX(c),t.getX(c+1),t.getX(c+2));else for(let c=0;c<i.count;c+=3)f(c,c+1,c+2);return this.computeFaceNormals(),n.boundingBox!==null&&(this.boundingBox=n.boundingBox.clone()),n.boundingSphere!==null&&(this.boundingSphere=n.boundingSphere.clone()),this},center:function(){return this.computeBoundingBox(),this.boundingBox.getCenter(qe).negate(),this.translate(qe.x,qe.y,qe.z),this},normalize:function(){this.computeBoundingSphere();const n=this.boundingSphere.center,e=this.boundingSphere.radius,t=e===0?1:1/e,s=new v.Matrix4;return s.set(t,0,0,-t*n.x,0,t,0,-t*n.y,0,0,t,-t*n.z,0,0,0,1),this.applyMatrix4(s),this},computeFaceNormals:function(){const n=new v.Vector3,e=new v.Vector3;for(let t=0,s=this.faces.length;t<s;t++){const i=this.faces[t],r=this.vertices[i.a],o=this.vertices[i.b],a=this.vertices[i.c];n.subVectors(a,o),e.subVectors(r,o),n.cross(e),n.normalize(),i.normal.copy(n)}},computeVertexNormals:function(n=!0){const e=new Array(this.vertices.length);for(let t=0,s=this.vertices.length;t<s;t++)e[t]=new v.Vector3;if(n){const t=new v.Vector3,s=new v.Vector3;for(let i=0,r=this.faces.length;i<r;i++){const o=this.faces[i],a=this.vertices[o.a],u=this.vertices[o.b],f=this.vertices[o.c];t.subVectors(f,u),s.subVectors(a,u),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],r=i.vertexNormals;r.length===3?(r[0].copy(e[i.a]),r[1].copy(e[i.b]),r[2].copy(e[i.c])):(r[0]=e[i.a].clone(),r[1]=e[i.b].clone(),r[2]=e[i.c].clone())}return this.faces.length>0&&(this.normalsNeedUpdate=!0),e},computeFlatVertexNormals:function(){this.computeFaceNormals();for(let n=0,e=this.faces.length;n<e;n++){const t=this.faces[n],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,r=s.vertexNormals.length;i<r;i++)s.__originalVertexNormals[i]?s.__originalVertexNormals[i].copy(s.vertexNormals[i]):s.__originalVertexNormals[i]=s.vertexNormals[i].clone()}const n=new Be;n.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 r=this.morphNormals[e].faceNormals,o=this.morphNormals[e].vertexNormals;for(let a=0,u=this.faces.length;a<u;a++){const f=new v.Vector3,l={a:new v.Vector3,b:new v.Vector3,c:new v.Vector3};r.push(f),o.push(l)}}const s=this.morphNormals[e];n.vertices=this.morphTargets[e].vertices,n.computeFaceNormals();let i=n.computeVertexNormals();if(i&&i.length>0){this.morphTargets[e].normals=new Array(this.vertices.length);for(let r=0;r<i.length;r++)this.morphTargets[e].normals[r]=i[r].clone()}for(let r=0,o=this.faces.length;r<o;r++){const a=this.faces[r],u=s.faceNormals[r],f=s.vertexNormals[r];u.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 v.Box3),this.boundingBox.setFromPoints(this.vertices)},computeBoundingSphere:function(){this.boundingSphere===null&&(this.boundingSphere=new v.Sphere),this.boundingSphere.setFromPoints(this.vertices)},mergeMorph:function(n,e){const t=this.morphTargets.length,s=this.morphTargets,i=n.morphTargets,r=this.morphColors.length,o=this.morphColors,a=n.morphColors;if(t>0&&t==i.length)for(let u=0,f=s.length;u<f;u++){const l=s[u],c=i[u];for(let d=0,h=c.vertices.length;d<h;d++){const w=c.vertices[d].clone();e!==void 0&&w.applyMatrix4(e),l.vertices.push(w)}if(l.normals&&c.normals)for(let d=0;d<c.normals.length;d=d+3)Ae.set(c.normals2[d],c.normals2[d+1],c.normals2[d+2]),e!==void 0&&Ae.applyMatrix4(e),l.normals.push(Ae.x,Ae.y,Ae.z)}if(r>0&&r==a.length)for(let u=0,f=o.length;u<f;u++){const l=o[u],c=a[u];for(let d=0,h=c.colors;d<h;d++)l.colors.push(c.colors[d].clone())}},merge:function(n,e,t=0){if(!(n&&n.isGeometry)){console.error("THREE.Geometry.merge(): geometry not an instance of THREE.Geometry.",n);return}let s;const i=this.vertices.length,r=this.vertices,o=n.vertices,a=n.normals,u=this.faces,f=n.faces,l=this.colors,c=n.colors;e!==void 0&&(s=new v.Matrix3().getNormalMatrix(e));for(let d=0,h=o.length;d<h;d++){const w=o[d].clone();e!==void 0&&w.applyMatrix4(e),r.push(w)}for(let d=0;d<a.length;d=d+3)Ae.set(a[d],a[d+1],a[d+2]),e!==void 0&&Ae.applyMatrix4(e),this.normals.push(Ae.x,Ae.y,Ae.z);for(let d=0,h=c.length;d<h;d++)typeof c[d]=="number"?l.push(c[d]):l.push(c[d].clone());for(let d=0,h=f.length;d<h;d++){const p=f[d];let w,y;const g=p.vertexNormals,_=p.vertexColors,A=new De(p.a+i,p.b+i,p.c+i);A.normal.copy(p.normal),s!==void 0&&A.normal.applyMatrix3(s).normalize();for(let N=0,I=g.length;N<I;N++)w=g[N].clone(),s!==void 0&&w.applyMatrix3(s).normalize(),A.vertexNormals.push(w);A.color.copy(p.color);for(let N=0,I=_.length;N<I;N++)y=_[N],A.vertexColors.push(y.clone());A.materialIndex=p.materialIndex+t,u.push(A)}for(let d=0,h=n.faceVertexUvs.length;d<h;d++){const p=n.faceVertexUvs[d];this.faceVertexUvs[d]===void 0&&(this.faceVertexUvs[d]=[]);for(let w=0,y=p.length;w<y;w++){const g=p[w],_=[];for(let A=0,N=g.length;A<N;A++)_.push(g[A].clone());this.faceVertexUvs[d].push(_)}}this.mergeMorph(n,e)},mergeMesh:function(n){if(!(n&&n.isMesh)){console.error("THREE.Geometry.mergeMesh(): mesh not an instance of THREE.Mesh.",n);return}n.matrixAutoUpdate&&n.updateMatrix(),this.merge(n.geometry,n.matrix)},mergeVertices:function(n=4){const e={},t=[],s=[],i=Math.pow(10,n);for(let a=0,u=this.vertices.length;a<u;a++){const f=this.vertices[a],l=Math.round(f.x*i)+"_"+Math.round(f.y*i)+"_"+Math.round(f.z*i);e[l]===void 0?(e[l]=a,t.push(this.vertices[a]),s[a]=t.length-1):s[a]=s[e[l]]}const r=[];for(let a=0,u=this.faces.length;a<u;a++){const f=this.faces[a];f.a=s[f.a],f.b=s[f.b],f.c=s[f.c];const l=[f.a,f.b,f.c];for(let c=0;c<3;c++)if(l[c]===l[(c+1)%3]){r.push(a);break}}for(let a=r.length-1;a>=0;a--){const u=r[a];this.faces.splice(u,1);for(let f=0,l=this.faceVertexUvs.length;f<l;f++)this.faceVertexUvs[f].splice(u,1)}const o=this.vertices.length-t.length;return this.vertices=t,o},setFromPoints:function(n){this.vertices=[];for(let e=0,t=n.length;e<t;e++){const s=n[e];this.vertices.push(new v.Vector3(s.x,s.y,s.z||0))}return this},sortFacesByMaterialIndex:function(){const n=this.faces,e=n.length;for(let a=0;a<e;a++)n[a]._id=a;function t(a,u){return a.materialIndex-u.materialIndex}n.sort(t);const s=this.faceVertexUvs[0],i=this.faceVertexUvs[1];let r,o;s&&s.length===e&&(r=[]),i&&i.length===e&&(o=[]);for(let a=0;a<e;a++){const u=n[a]._id;r&&r.push(s[u]),o&&o.push(i[u])}r&&(this.faceVertexUvs[0]=r),o&&(this.faceVertexUvs[1]=o)},toJSON:function(){const n={metadata:{version:4.5,type:"Geometry",generator:"Geometry.toJSON"}};if(n.uuid=this.uuid,n.type=this.type,this.name!==""&&(n.name=this.name),this.parameters!==void 0){const h=this.parameters;for(const p in h)h[p]!==void 0&&(n[p]=h[p]);return n}const e=[];for(let h=0;h<this.vertices.length;h++){const p=this.vertices[h];e.push(p.x,p.y,p.z)}const t=[],s=[],i={},r=[],o={},a=[],u={};for(let h=0;h<this.faces.length;h++){const p=this.faces[h],w=!0,y=!1,g=this.faceVertexUvs[0][h]!==void 0,_=p.normal.length()>0,A=p.vertexNormals.length>0,N=p.color.r!==1||p.color.g!==1||p.color.b!==1,I=p.vertexColors.length>0;let D=0;if(D=f(D,0,0),D=f(D,1,w),D=f(D,2,y),D=f(D,3,g),D=f(D,4,_),D=f(D,5,A),D=f(D,6,N),D=f(D,7,I),t.push(D),t.push(p.a,p.b,p.c),t.push(p.materialIndex),g){const F=this.faceVertexUvs[0][h];t.push(d(F[0]),d(F[1]),d(F[2]))}if(_&&t.push(l(p.normal)),A){const F=p.vertexNormals;t.push(l(F[0]),l(F[1]),l(F[2]))}if(N&&t.push(c(p.color)),I){const F=p.vertexColors;t.push(c(F[0]),c(F[1]),c(F[2]))}}function f(h,p,w){return w?h|1<<p:h&~(1<<p)}function l(h){const p=h.x.toString()+h.y.toString()+h.z.toString();return i[p]!==void 0||(i[p]=s.length/3,s.push(h.x,h.y,h.z)),i[p]}function c(h){const p=h.r.toString()+h.g.toString()+h.b.toString();return o[p]!==void 0||(o[p]=r.length,r.push(h.getHex())),o[p]}function d(h){const p=h.x.toString()+h.y.toString();return u[p]!==void 0||(u[p]=a.length/2,a.push(h.x,h.y)),u[p]}return n.data={},n.data.vertices=e,n.data.normals=s,r.length>0&&(n.data.colors=r),a.length>0&&(n.data.uvs=[a]),n.data.faces=t,n},clone:function(){return new Be().copy(this)},copy:function(n){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=n.name;const e=n.vertices;for(let c=0,d=e.length;c<d;c++)this.vertices.push(e[c].clone());const t=n.colors;for(let c=0,d=t.length;c<d;c++)this.colors.push(t[c].clone());const s=n.faces;for(let c=0,d=s.length;c<d;c++)this.faces.push(s[c].clone());for(let c=0,d=n.faceVertexUvs.length;c<d;c++){const h=n.faceVertexUvs[c];this.faceVertexUvs[c]===void 0&&(this.faceVertexUvs[c]=[]);for(let p=0,w=h.length;p<w;p++){const y=h[p],g=[];for(let _=0,A=y.length;_<A;_++){const N=y[_];g.push(N.clone())}this.faceVertexUvs[c].push(g)}}const i=n.morphTargets;for(let c=0,d=i.length;c<d;c++){const h={};if(h.name=i[c].name,i[c].vertices!==void 0){h.vertices=[];for(let p=0,w=i[c].vertices.length;p<w;p++)h.vertices.push(i[c].vertices[p].clone())}if(i[c].normals!==void 0){h.normals=[];for(let p=0,w=i[c].normals.length;p<w;p++)h.normals.push(i[c].normals[p].clone())}this.morphTargets.push(h)}const r=n.morphNormals;for(let c=0,d=r.length;c<d;c++){const h={};if(r[c].vertexNormals!==void 0){h.vertexNormals=[];for(let p=0,w=r[c].vertexNormals.length;p<w;p++){const y=r[c].vertexNormals[p],g={};g.a=y.a.clone(),g.b=y.b.clone(),g.c=y.c.clone(),h.vertexNormals.push(g)}}if(r[c].faceNormals!==void 0){h.faceNormals=[];for(let p=0,w=r[c].faceNormals.length;p<w;p++)h.faceNormals.push(r[c].faceNormals[p].clone())}this.morphNormals.push(h)}const o=n.skinWeights;for(let c=0,d=o.length;c<d;c++)this.skinWeights.push(o[c].clone());const a=n.skinIndices;for(let c=0,d=a.length;c<d;c++)this.skinIndices.push(a[c].clone());const u=n.lineDistances;for(let c=0,d=u.length;c<d;c++)this.lineDistances.push(u[c]);const f=n.boundingBox;f!==null&&(this.boundingBox=f.clone());const l=n.boundingSphere;return l!==null&&(this.boundingSphere=l.clone()),this.elementsNeedUpdate=n.elementsNeedUpdate,this.verticesNeedUpdate=n.verticesNeedUpdate,this.uvsNeedUpdate=n.uvsNeedUpdate,this.normalsNeedUpdate=n.normalsNeedUpdate,this.colorsNeedUpdate=n.colorsNeedUpdate,this.lineDistancesNeedUpdate=n.lineDistancesNeedUpdate,this.groupsNeedUpdate=n.groupsNeedUpdate,this},computeGroups(){const n=[];let e,t,s;const i=this.faces;for(t=0;t<i.length;t++){const r=i[t];r.materialIndex!==s&&(s=r.materialIndex,e!==void 0&&(e.count=t*3-e.start,n.push(e)),e={start:t*3,materialIndex:s})}return e!==void 0&&(e.count=t*3-e.start,n.push(e)),n},toBufferGeometry:function(){const n=new Pi().fromGeometry(this),e=new v.BufferGeometry,t=new Float32Array(n.vertices.length*3);if(e.setAttribute("position",new v.BufferAttribute(t,3).copyVector3sArray(n.vertices)),n.normals.length>0){const s=new Float32Array(n.normals.length*3);e.setAttribute("normal",new v.BufferAttribute(s,3).copyVector3sArray(n.normals))}if(n.colors.length>0){const s=new Float32Array(n.colors.length*3);e.setAttribute("color",new v.BufferAttribute(s,3).copyColorsArray(n.colors))}if(n.uvs.length>0){const s=new Float32Array(n.uvs.length*2);e.setAttribute("uv",new v.BufferAttribute(s,2).copyVector2sArray(n.uvs))}if(n.uvs2.length>0){const s=new Float32Array(n.uvs2.length*2);e.setAttribute("uv2",new v.BufferAttribute(s,2).copyVector2sArray(n.uvs2))}e.groups=n.groups;for(const s in n.morphTargets){const i=[],r=n.morphTargets[s];for(let o=0,a=r.length;o<a;o++){const u=r[o],f=new v.Float32BufferAttribute(u.data.length*3,3);f.name=u.name,i.push(f.copyVector3sArray(u.data))}e.morphAttributes[s]=i}if(n.skinIndices.length>0){const s=new v.Float32BufferAttribute(n.skinIndices.length*4,4);e.setAttribute("skinIndex",s.copyVector4sArray(n.skinIndices))}if(n.skinWeights.length>0){const s=new v.Float32BufferAttribute(n.skinWeights.length*4,4);e.setAttribute("skinWeight",s.copyVector4sArray(n.skinWeights))}return n.boundingSphere!==null&&(e.boundingSphere=n.boundingSphere.clone()),n.boundingBox!==null&&(e.boundingBox=n.boundingBox.clone()),e},toIndexedBufferGeometry:function(){const n=new v.BufferGeometry,e=new Float32Array(this.vertices.length*3);if(n.setAttribute("position",new v.BufferAttribute(e,3).copyVector3sArray(this.vertices)),this.normals.length>0){const t=new Float32Array(this.normals.length);let s=new v.BufferAttribute(t,3).copyArray(this.normals);n.setAttribute("normal",s)}if(this.uvs.length>0&&this.uvs[0].length>0){const t=new Float32Array(this.uvs[0].length*2);n.setAttribute("uv",new v.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);n.setAttribute("uv2",new v.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 v.Color(this.colors[i]));const s=new Float32Array(t.length*3);n.setAttribute("color",new v.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;n.setAttribute("color",new v.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 r=this.faces[i].vertexColors;if(r.length===3)t.push(r[0],r[1],r[2]);else{const o=this.faces[i].color;t.push(o,o,o)}}n.setIndex(s),n.groups=this.computeGroups()}if(this.morphTargets.length>0){const t=[],s=[];for(let i=0,r=this.morphTargets.length;i<r;i++){const o=this.morphTargets[i],a=new v.Float32BufferAttribute(o.vertices.length*3,3);if(a.name=o.name,t.push(a.copyVector3sArray(o.vertices)),o.normals){const u=new v.Float32BufferAttribute(o.normals.length*3,3);u.name=o.name,s.push(u.copyVector3sArray(o.normals))}}n.morphAttributes.position=t,n.morphAttributes.normal=s}if(this.skinIndices.length>0){const t=new v.Float32BufferAttribute(this.skinIndices.length*4,4);n.setAttribute("skinIndex",t.copyVector4sArray(this.skinIndices))}if(this.skinWeights.length>0){const t=new v.Float32BufferAttribute(this.skinWeights.length*4,4);n.setAttribute("skinWeight",t.copyVector4sArray(this.skinWeights))}return this.boundingSphere!==null&&(n.boundingSphere=this.boundingSphere.clone()),this.boundingBox!==null&&(n.boundingBox=this.boundingBox.clone()),n},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(n){return console.warn("THREE.Geometry: .applyMatrix() has been renamed to .applyMatrix4()."),this.applyMatrix4(n)},dispose:function(){this.dispatchEvent({type:"dispose"})}}),Be.createBufferGeometryFromObject=function(n){let e=new v.BufferGeometry;const t=n.geometry;if(n.isPoints||n.isLine){const s=new v.Float32BufferAttribute(t.vertices.length*3,3),i=new v.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 r=new v.Float32BufferAttribute(t.lineDistances.length,1);e.setAttribute("lineDistance",r.copyArray(t.lineDistances))}t.boundingSphere!==null&&(e.boundingSphere=t.boundingSphere.clone()),t.boundingBox!==null&&(e.boundingBox=t.boundingBox.clone())}else n.isMesh&&(e=t.toBufferGeometry());return e};class Pi{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,r;const o=e.faces;for(i=0;i<o.length;i++){const a=o[i];a.materialIndex!==r&&(r=a.materialIndex,s!==void 0&&(s.count=i*3-s.start,t.push(s)),s={start:i*3,materialIndex:r})}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,r=i[0]&&i[0].length>0,o=i[1]&&i[1].length>0,a=e.morphTargets,u=a.length;let f;if(u>0){f=[];for(let g=0;g<u;g++)f[g]={name:a[g].name,data:[]};this.morphTargets.position=f}const l=e.morphNormals,c=l.length;let d;if(c>0){d=[];for(let g=0;g<c;g++)d[g]={name:l[g].name,data:[]};this.morphTargets.normal=d}const h=e.skinIndices,p=e.skinWeights,w=h.length===s.length,y=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 _=t[g];this.vertices.push(s[_.a],s[_.b],s[_.c]);const A=_.vertexNormals;if(A.length===3)this.normals.push(A[0],A[1],A[2]);else{const I=_.normal;this.normals.push(I,I,I)}const N=_.vertexColors;if(N.length===3)this.colors.push(N[0],N[1],N[2]);else{const I=_.color;this.colors.push(I,I,I)}if(r===!0){const I=i[0][g];I!==void 0?this.uvs.push(I[0],I[1],I[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv ",g),this.uvs.push(new v.Vector2,new v.Vector2,new v.Vector2))}if(o===!0){const I=i[1][g];I!==void 0?this.uvs2.push(I[0],I[1],I[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv2 ",g),this.uvs2.push(new v.Vector2,new v.Vector2,new v.Vector2))}for(let I=0;I<u;I++){const D=a[I].vertices;f[I].data.push(D[_.a],D[_.b],D[_.c])}for(let I=0;I<c;I++){const D=l[I].vertexNormals[g];d[I].data.push(D.a,D.b,D.c)}w&&this.skinIndices.push(h[_.a],h[_.b],h[_.c]),y&&this.skinWeights.push(p[_.a],p[_.b],p[_.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 De{constructor(e,t,s,i,r,o=0){this.a=e,this.b=t,this.c=s,this.normal=i&&i.isVector3?i:new v.Vector3,this.vertexNormals=Array.isArray(i)?i:[],this.color=r&&r.isColor?r:new v.Color,this.vertexColors=Array.isArray(r)?r:[],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 Vi="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==",ki=Oe.default||Oe;function ye(n){let e=n,t=Se.modelPrefix;return t&&(t[t.length-1]!="/"&&(t=t+"/"),new RegExp("^(?:[a-z]+:)?//","i").test(n)||(e=t+n)),e}function Pe(n,e){const t=(s,i)=>{try{let r=new URL(s,i).href;if(s&&s.split("?").length<2){const o=i.split("?");o.length===2&&(r=r+"?"+o[1])}return r}catch{console.error(`There is an issue creating the url link with: ${s}.`)}};if(Array.isArray(n)){const s=[];return n.forEach(i=>{s.push(t(i,e))}),s}else return t(n,e)}function Ii(n,e,t,s,i){let r=n.morphTargetInfluences,o;n.geometry&&(o=n.geometry.morphAttributes);let a=!1;if(r&&o&&o.position){s.set(0,0,0),i.set(0,0,0);for(let u=0;u<r.length;u++)r[u]>0&&(a=!0,t.setFromArray(o.position[u].array),s.add(t.min.multiplyScalar(r[u])),i.add(t.max.multiplyScalar(r[u])));a&&e.set(s,i)}a||e.setFromBufferAttribute(n.geometry.attributes.position),n.updateWorldMatrix(!0,!0),e.applyMatrix4(n.matrixWorld)}function Tt(n,e,t,s){fetch(ye(n)).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(n)})}function Ri(n,e,t){const s=n.length;let i=0;const r=[];function o(a,u){r[u]=a,i++,i==s&&e(r)}for(let a=0;a<s;a++)Tt(n[a],a,o,t)}const Di=(n,e)=>{const t=Math.floor(e/3),s=e%3;let i=0;s==0?i=n[t].r:s==1?i=n[t].g:s==2&&(i=n[t].b);const r=new S.Color(i);return[r.r,r.g,r.b]},Lt=function(n,e){if(e&&n&&n.morphAttributes&&n.morphAttributes.color){const t=n.morphAttributes.color,s=e.morphTargetInfluences,i=s.length;n.deleteAttribute("morphColor0"),n.deleteAttribute("morphColor1");let r=0,o=[];for(let a=0;1>r||a<i;a++)s[a]>0&&(r++,o.push([a,s[a]]));o.length==2?(n.setAttribute("morphColor0",t[o[0][0]]),n.setAttribute("morphColor1",t[o[1][0]])):o.length==1&&(n.setAttribute("morphColor0",t[o[0][0]]),n.setAttribute("morphColor1",t[o[0][0]]))}},Ze=(n,e)=>{let t;return n instanceof Be?(e.localTimeEnabled&&!n.morphNormalsReady&&(n.morphNormals==null||n.morphNormals.length==0)&&n.computeMorphNormals(),t=n.toIndexedBufferGeometry(),e.localMorphColour&&Fi(n,t)):n instanceof S.BufferGeometry&&(t=n.clone()),t.colorsNeedUpdate=!0,t.computeBoundingBox(),t.computeBoundingSphere(),n._video&&(t._video=n._video),t},Fi=(n,e)=>{if(n&&n.morphColors&&n.morphColors.length>0){let t=[],s=n.morphColors;for(let i=0,r=s.length;i<r;i++){const o=s[i],a=[];for(let f=0;f<o.colors.length*3;f++){let l=Di(o.colors,f);a.push(l[0],l[1],l[2])}const u=new S.Float32BufferAttribute(a,3);u.name=o.name,t.push(u)}e.morphAttributes.color=t}};function Bt(n){let e,t,s,i=-1,r=0;for(let f=0;f<n.length;++f){const l=n[f];if(e===void 0&&(e=l.array.constructor),e!==l.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=l.itemSize),t!==l.itemSize)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes."),null;if(s===void 0&&(s=l.normalized),s!==l.normalized)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes."),null;if(i===-1&&(i=l.gpuType),i!==l.gpuType)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.gpuType must be consistent across matching attributes."),null;r+=l.count*t}const o=new e(r),a=new S.BufferAttribute(o,t,s);let u=0;for(let f=0;f<n.length;++f){const l=n[f];if(l.isInterleavedBufferAttribute){const c=u/t;for(let d=0,h=l.count;d<h;d++)for(let p=0;p<t;p++){const w=l.getComponent(d,p);a.setComponent(d+c,p,w)}}else o.set(l.array,u);u+=l.count*t}return i!==void 0&&(a.gpuType=i),a}const Gi=(n,e=!1)=>{const t=n[0].index!==null,s=new Set(Object.keys(n[0].attributes)),i=new Set(Object.keys(n[0].morphAttributes)),r={},o={},a=n[0].morphTargetsRelative,u=new S.BufferGeometry;let f=0;for(let l=0;l<n.length;++l){const c=n[l];let d=0;if(t!==(c.index!==null))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+l+". All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them."),null;for(const h in c.attributes){if(!s.has(h))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+l+'. All geometries must have compatible attributes; make sure "'+h+'" attribute exists among all geometries, or in none of them.'),null;r[h]===void 0&&(r[h]=[]),r[h].push(c.attributes[h]),d++}if(d!==s.size)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+l+". Make sure all geometries have the same number of attributes."),null;if(a!==c.morphTargetsRelative)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+l+". .morphTargetsRelative must be consistent throughout all geometries."),null;for(const h in c.morphAttributes){if(!i.has(h))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+l+". .morphAttributes must be consistent throughout all geometries."),null;o[h]===void 0&&(o[h]=[]),o[h].push(c.morphAttributes[h])}if(e){let h;if(t)h=c.index.count;else if(c.attributes.position!==void 0)h=c.attributes.position.count;else return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+l+". The geometry must have either an index or a position attribute"),null;u.addGroup(f,h,l),f+=h}}if(t){let l=0;const c=[];for(let d=0;d<n.length;++d){const h=n[d].index;for(let p=0;p<h.count;++p)c.push(h.getX(p)+l);l+=n[d].attributes.position.count}u.setIndex(c)}for(const l in r){const c=Bt(r[l]);if(!c)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+l+" attribute."),null;u.setAttribute(l,c)}for(const l in o){const c=o[l][0].length;if(c===0)break;u.morphAttributes=u.morphAttributes||{},u.morphAttributes[l]=[];for(let d=0;d<c;++d){const h=[];for(let w=0;w<o[l].length;++w)h.push(o[l][w][d]);const p=Bt(h);if(!p)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+l+" morphAttribute."),null;u.morphAttributes[l].push(p)}}return u};function nt(n,e){if(e&&n>=e.length){const t=new S.BufferGeometry,s=new Float32Array(n*3);let i=0;return e.forEach(r=>{s[i++]=r[0],s[i++]=r[1],s[i++]=r[2]}),t.setAttribute("position",new S.BufferAttribute(s,3)),t.setDrawRange(0,e.length),t}}function Ut(){const n=new Image;n.src=Vi;const e=new S.Texture;return e.image=n,e.needsUpdate=!0,e}function ot(n,e,t,s,i,r){const o=new ki(n,e,t,s,i,r);return o.fontFace=s,o.fontSize=i,o.fontWeight=r,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 Nt(n,e,t){if(t){const s=n||"",i=e||"",r=t.lastIndexOf("/");if(r>-1){let o,a;if(o=t.substring(0,r),a=t.substring(r+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 ji(n,e,t){const s=n.getAttribute("position"),i=n.getAttribute("normal");if(!s)return;const r=s.itemSize,o=e*r,a=r;let u=!1;const f=(l,c)=>{let d=!1;const h=Array.from(l.array);if(h.length>=o+a){h.splice(o,a),h.concat(new Array(a).fill(0)),d=!0;const p=new Float32Array(h);n.setAttribute(c,new S.BufferAttribute(p,r)),n.getAttribute(c).needsUpdate=!0}return d};return u=f(s,"position"),i&&f(i,"normal"),n.index!==null&&console.warn("Removing vertices from indexed geometry requires index buffer recalculation."),u}const Pt=function(){return function(n){n.vertexShader=n.vertexShader.replace("#include <color_pars_vertex>",["varying vec3 vColor;","attribute vec3 morphColor0;","attribute vec3 morphColor1;"].join(`
|
|
2
|
-
`)),
|
|
3
|
-
`))}},Vt=new v.Vector3,kt=new v.Vector3,It=new v.Matrix4,at=new v.Ray,Ye=new v.Sphere,lt=new v.Vector3,ct=new v.Vector3,Rt=new v.Vector3,Dt=new v.Vector3;class Ft extends v.Object3D{constructor(e=new v.BufferGeometry,t=new v.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,r=t.count;i<r;i++)Vt.fromBufferAttribute(t,i-1),kt.fromBufferAttribute(t,i),s[i]=s[i-1],s[i]+=Vt.distanceTo(kt);e.setAttribute("lineDistance",new v.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,r=e.params.Line.threshold,o=s.drawRange,a=s.morphAttributes.position;if(s.boundingSphere===null&&s.computeBoundingSphere(),Ye.copy(s.boundingSphere),Ye.applyMatrix4(i),Ye.radius+=r,e.ray.intersectsSphere(Ye)===!1)return;It.copy(i).invert(),at.copy(e.ray).applyMatrix4(It);const u=r/((this.scale.x+this.scale.y+this.scale.z)/3),f=u*u,l=new v.Vector3,c=new v.Vector3,d=new v.Vector3,h=new v.Vector3,p=this.isLineSegments?2:1;if(s.isBufferGeometry){const w=s.index,g=s.attributes.position;if(w!==null){const _=Math.max(0,o.start),A=Math.min(w.count,o.start+o.count);for(let N=_,I=A-1;N<I;N+=p){const D=w.getX(N),F=w.getX(N+1);if(Gt(l,c,this,g,a,D,F),at.distanceSqToSegment(l,c,h,d)>f)continue;h.applyMatrix4(this.matrixWorld);const G=e.ray.origin.distanceTo(h);G<e.near||G>e.far||t.push({distance:G,point:d.clone().applyMatrix4(this.matrixWorld),index:N,face:null,faceIndex:null,object:this})}}else{const _=Math.max(0,o.start),A=Math.min(g.count,o.start+o.count);for(let N=_,I=A-1;N<I;N+=p){if(Gt(l,c,this,g,a,N,N+1),at.distanceSqToSegment(l,c,h,d)>f)continue;h.applyMatrix4(this.matrixWorld);const F=e.ray.origin.distanceTo(h);F<e.near||F>e.far||t.push({distance:F,point:d.clone().applyMatrix4(this.matrixWorld),index:N,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 r=0,o=i.length;r<o;r++){const a=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=r}}}}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 Gt(n,e,t,s,i,r,o){n.fromBufferAttribute(s,r),e.fromBufferAttribute(s,o);var a=t.morphTargetInfluences;if(t.material.morphTargets&&i&&a){lt.set(0,0,0),ct.set(0,0,0);for(var u=0,f=i.length;u<f;u++){var l=a[u],c=i[u];l!==0&&(Rt.fromBufferAttribute(c,r),Dt.fromBufferAttribute(c,o),lt.addScaledVector(Rt.sub(n),l),ct.addScaledVector(Dt.sub(e),l))}n.add(lt),e.add(ct)}}Ft.prototype.isLine=!0;const jt=new v.Vector3,Et=new v.Vector3;class Xe extends Ft{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,r=t.count;i<r;i+=2)jt.fromBufferAttribute(t,i),Et.fromBufferAttribute(t,i+1),s[i]=i===0?0:s[i-1],s[i+1]=s[i]+jt.distanceTo(Et);e.setAttribute("lineDistance",new v.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}}Xe.prototype.isLineSegments=!0;const Ei=function(n){this.levels=[],this._currentLevel=0,this._renderOrder=1,this._material=void 0,this._secondaryMaterial=void 0,this._loader=void 0,this._parent=n,this.addLevel=(t,s)=>{if(t){const i=Math.abs(s);let r;for(r=0;r<this.levels.length&&!(i<this.levels[r].distance);r++);const o={distance:i,morph:t,loaded:!0,loading:!1,url:""};this.levels.splice(r,0,o),t.renderOrder=this._renderOrder}},this.levelLoaded=(t,s)=>{if(t){const i=Math.abs(s);for(let r=0;r<this.levels.length;r++)if(i===this.levels[r].distance){this._parent.group.add(t),this.levels[r].morph=t,this.levels[r].loaded=!0,this.levels[r].loading=!1;break}this.checkTransparentMesh()}},this.addLevelFromURL=(t,s,i,r,o)=>{this._loader=t;const a=this.calculateDistance(s),u={distance:a,morph:void 0,loaded:!1,loading:!1,url:i,index:r};let f;for(f=0;f<this.levels.length&&!(a<this.levels[f].distance);f++);this.levels.splice(f,0,u),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=S.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 S.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=S.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=S.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,r={localTimeEnabled:this._parent.timeEnabled,localMorphColour:this._parent.morphColour},o=Ze(s,r);let a;this._parent.isGeometry?a=new S.Mesh(o,i):this._parent.isLines&&(a=new Xe(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==S.VertexColors||this._material.vertexColors==!0))if(t){const s=this.getCurrentMorph();Lt(s.geometry,s)}else this.levels.forEach(s=>{s.morph&&s.morph.geometry&&Lt(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=S.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 r=t.cameraObject.position.distanceTo(s);let o=-1,a=-1,u,f;for(u=0,f=i.length;u<f&&r>=i[u].distance;u++)i[u].morph?(o>-1&&i[o].morph&&(i[o].morph.visible=!1),o=u,i[u].morph.visible=!0,a=-1):a=u;for(a>-1&&this.loadLevel(a);u<f;u++)i[u].morph&&(o>-1?i[u].morph.visible=!1:(i[u].morph.visible=!0,o=u));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)})}},zi="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",zt=new Image(128,128);zt.src=zi;const Je=new S.Texture;Je.image=zt,Je.needsUpdate=!0;const ht=[.02,.03,1],Wi=new S.SpriteMaterial({map:Je,alphaTest:.5,transparent:!0,depthTest:!1,depthWrite:!1,sizeAttenuation:!1}),Wt=function(n){Object.getPrototypeOf(this)!==Y.prototype&&Object.setPrototypeOf(Wt.prototype,Y.prototype),Y.call(this),this.texture=Je;let e,t,s,i,r,o=!0;this.morph=new S.Group,this.group=this.morph,this.parent=n,this.isMarker=!0;let a=!1;this.ndc=new S.Vector3;let u,f,l=()=>{e=new S.Sprite(Wi),e.center.set(.5,0),this.morph.add(e),this.morph.position.set(0,0,0),this.morph.renderOrder=1e4,e.scale.set(ht[0],ht[1],ht[2]),e.userData=this};this.updateVisual=(c,d)=>{let h=1,p=0;c!==d&&(p=1-(this.ndc.z-c)/(d-c),h=.6+p*.4),this.setSpriteSize(h)},this.updateNDC=c=>(this.ndc.copy(this.morph.position),this.ndc.project(c),this.ndc.z=Math.min(Math.max(this.ndc.z,0),1),this.ndc),this.setPosition=(c,d,h)=>{this.morph.position.set(c,d,h)},this.setSpriteSize=c=>{e.scale.set(.015,.02,1),e.scale.multiplyScalar(c)},this.setUserSprite=()=>{i&&(this.morph.add(i),o&&(this.morph.remove(e),f&&this.morph.remove(f),o=!1))},this.setImageForUserSprite=(c,d)=>{i&&(this.morph.remove(i),i=void 0),t&&t.dispose(),s&&s.dispose(),t=new S.Texture,t.image=c,t.needsUpdate=!0,s=new S.SpriteMaterial({map:t,alphaTest:.5,transparent:!0,depthTest:!1,depthWrite:!1,sizeAttenuation:!1}),d||(d=[.05,.05,1]),i=new S.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=(c,d)=>{if(c)if(c!==r){r=c;const h=new Image(128,128);h.crossOrigin="anonymous",h.onload=()=>{this.setImageForUserSprite(h,d)},h.src=c}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=c=>{(!c||u!=c)&&f&&(this.morph.remove(f),f.material.map.dispose(),f.material.dispose(),f=void 0),!f&&c&&(f=ot(c,.012,"black","Asap",120,700),this.morph.add(f)),u=c},this.getNumber=()=>u||1,this.setVisibility=function(c){c!==this.visible&&(this.visible=c,this.group.visible=c,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},l()};let qi=0;const Zi=function(){return"pr"+qi++},Y=function(){this.isZincObject=!0,this.geometry=void 0,this.morph=void 0,this.group=new S.Group,this._lod=new Ei(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 S.Box3,this.anatomicalId=void 0,this.region=void 0,this.animationClip=void 0,this.markerMode="inherited",this.uuid=Zi(),this._v1=new S.Vector3,this._v2=new S.Vector3,this._b1=new S.Box3,this.center=new S.Vector3,this.radius=0,this.visible=!0,this.drawRange=-1,this.origColour=void 0,this.origVertexColors=!1,this.isPickable=!0};Y.prototype.setDuration=function(n){this.duration=n,this.clipAction&&this.clipAction.setDuration(this.duration)},Y.prototype.getDuration=function(){return this.duration},Y.prototype.setRegion=function(n){this.region=n},Y.prototype.getRegion=function(){return this.region},Y.prototype.getMorph=function(){const n=this._lod.getCurrentMorph();return n||this.morph},Y.prototype.getGroup=function(){return this.group},Y.prototype.setMorph=function(n){this.morph=n,this.group.add(this.morph);const e=this._lod.calculateDistance("far");this._lod.addLevel(n,e),this._lod.setMaterial(n.material)},Y.prototype.checkTransparentMesh=function(){},Y.prototype.setMesh=function(n,e,t){this.animationGroup=new S.AnimationObjectGroup(n),this.mixer=new S.AnimationMixer(this.animationGroup);const s=n.geometry;if(this.geometry=n.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=S.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=S.loopOnce,this.clipAction.clampWhenFinished=!0,this.clipAction.play()))}this.timeEnabled=e,this.morphColour=t,n.userData=this,n.matrixAutoUpdate=!1,this.setMorph(n),this.checkTransparentMesh(),this.timeEnabled?this.setFrustumCulled(!1):this.morphColour&&(s.setAttribute("morphTarget0",s.getAttribute("position")),s.setAttribute("morphTarget1",s.getAttribute("position"))),this.boundingBoxUpdateRequired=!0},Y.prototype.setIsPickable=function(n){this.isPickable!==n&&(this.isPickable=n,this.region&&(this.region.pickableUpdateRequired=!0))},Y.prototype.setAnatomicalId=function(n){this.anatomicalId=n},Y.prototype.setName=function(n){this.groupName=n,this._lod.setName(n)},Y.prototype.getCurrentTime=function(){if(this.clipAction){const n=this.clipAction.time/this.clipAction._clip.duration;return this.duration*n}else return this.inbuildTime},Y.prototype.setMorphTime=function(n){let e=!1;if(this.clipAction){const t=n/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=n;n>this.duration?t=this.duration:0>n?t=0:t=n,t!=this.inbuildTime&&(this.inbuildTime=t,e=!0)}e&&(this.boundingBoxUpdateRequired=!0,this._lod.updateMorphColorAttribute(!0),this.timeEnabled&&(this.markerUpdateRequired=!0))},Y.prototype.isTimeVarying=function(){return!!(this.timeEnabled||this.morphColour)},Y.prototype.getVisibility=function(){return this.visible},Y.prototype.setVisibility=function(n){n!==this.visible&&(this.visible=n,this.group.visible=n,this.region&&(this.region.pickableUpdateRequired=!0))},Y.prototype.setAlpha=function(n){const e=this._lod._material;let t=!1;n<1&&(t=!0),e.opacity=n,e.transparent=t,this.checkTransparentMesh()},Y.prototype.setFrustumCulled=function(n){this._lod.setFrustumCulled(n)},Y.prototype.setVertexColors=function(n){this._lod.setVertexColors(n)},Y.prototype.getColour=function(){if(this._lod._material)return this._lod._material.color},Y.prototype.setColour=function(n){this._lod.setColour(n)},Y.prototype.setGreyScale=function(n){if(n){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 S.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},Y.prototype.getColourHex=function(){if(!this.morphColour&&this._lod._material&&this._lod._material.color)return this._lod._material.color.getHexString()},Y.prototype.setColourHex=function(n){this._lod._material.color.setHex(n),this._lod._secondaryMaterial&&this._lod._secondaryMaterial.color.setHex(n)},Y.prototype.setEmissiveRGB=function(n){this._lod._material&&this._lod._material.emissive&&this._lod._material.emissive.setRGB(...n),this._lod._secondaryMaterial&&this._lod._secondaryMaterial.emissive.setRGB(...n)},Y.prototype.setMaterial=function(n){this._lod.setMaterial(n)},Y.prototype.getClosestVertexIndex=function(){let n=-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 r=0;r<t.count;r++)this._v2.fromArray(t.array,r*3),i=this._v2.distanceTo(this._v1),s==-1?s=i:s>i&&(s=i,n=r)}}return n},Y.prototype.getClosestVertex=function(n){let e=new S.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 r=!1;for(let o=0;o<s.length;o++)s[o]>0&&(r=!0,this._v1.fromArray(i.position[o].array,this.closestVertexIndex*3),e.add(this._v1.multiplyScalar(s[o])));if(r)return n?e.applyMatrix4(t.matrixWorld):e}else return e.fromArray(t.geometry.attributes.position.array,this.closestVertexIndex*3),n?e.applyMatrix4(t.matrixWorld):e}return this.getBoundingBox(),e.copy(this.center),e},Y.prototype.getBoundingBox=function(){if(this.visible){let n=this._lod.getCurrentMorph();if(n&&n.visible)return this.boundingBoxUpdateRequired&&(Ii(n,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}},Y.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},Y.prototype.markerIsRequired=function(n){return!!(this.visible&&(this.markerMode==="on"||n&&n.displayMarkers&&this.markerMode==="inherited"))},Y.prototype.updateMarker=function(n,e){if(n==!1&&this.markerIsRequired(e)){let t=e.ndcToBeUpdated;if(this.groupName){if(this.marker||(this.marker=new Wt(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},Y.prototype.processMarkerVisual=function(n,e){this.marker&&this.marker.isEnabled()&&this.marker.updateVisual(n,e)},Y.prototype.initiateMorphColor=function(){this.morphColour==1&&this._lod.updateMorphColorAttribute(!1)},Y.prototype.setRenderOrder=function(n){this._lod.setRenderOrder(n)},Y.prototype.getClosestVertexDOMElementCoords=function(n){if(n&&n.camera){let e=!0;const t=this.getClosestVertex(!0);return t.project(n.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),n.getZincCameraControls().getRelativeCoordsFromNDC(t.x,t.y,t),{position:t,inView:e}}else return},Y.prototype.setMarkerMode=function(n,e){n!==this.markerMode&&(n==="on"||n==="off"?this.markerMode=n:this.markerMode="inherited",this.region&&(this.region.pickableUpdateRequired=!0)),e&&(this.markerNumber=e.number,this.markerImgURL=e.imgURL)},Y.prototype.render=function(n,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(n);else{let i=this.inbuildTime+n;i>this.duration&&(i=i-this.duration),this.inbuildTime=i}this.visible&&n!=0&&(this.boundingBoxUpdateRequired=!0,this.morphColour==1&&this._lod.updateMorphColorAttribute(!0))}this.updateMarker(e,s)},Y.prototype.addLOD=function(n,e,t,s,i){this._lod.addLevelFromURL(n,e,t,s,i)},Y.prototype.addVertices=function(n){let e=this.getMorph(),t;if(!e)t=nt(500,n),this.drawRange=n.length;else if(this.drawRange>-1){const s=e.geometry.getAttribute("position");n.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},Y.prototype.deleteVertices=function(n){let e=this.getMorph();return e!=null&&e.geometry&&this.drawRange>=n&&ji(e.geometry,n)?(--this.drawRange,e.geometry.setDrawRange(0,this.drawRange),e.geometry.computeBoundingBox(),e.geometry.computeBoundingSphere(),this.boundingBoxUpdateRequired=!0,!0):!1},Y.prototype.setPosition=function(n,e,t){const s=this.getGroup();s&&(s.position.set(n,e,t),s.matrixWorldNeedsUpdate=!0,s.updateMatrix(),s.updateWorldMatrix(!0,!0),this.boundingBoxUpdateRequired=!0)},Y.prototype.loadAdditionalSources=function(n,e){n.load(ye(filename),meshloader(region,colour,opacity,localTimeEnabled,localMorphColour,void 0,void 0,void 0,void 0,finishCallback),this.onProgress(filename),this.onError(finishCallback))},Y.prototype.setScaleAll=function(n){const e=this.getGroup();e&&(e.scale.set(n,n,n),e.updateMatrix(),this.boundingBoxUpdateRequired=!0)};const Yi=(n,e,t)=>{let s=Ze(n,t),i=!1;1>t.opacity&&(i=!0);let r;if(s._video===void 0){const o=t.localTimeEnabled||t.localMorphColour;e?(r=e,r.morphTargets=o,r.morphNormals=t.localTimeEnabled):s instanceof S.BufferGeometry&&s.attributes.color===void 0?r=new S.MeshPhongMaterial({color:t.colour,morphTargets:o,morphNormals:t.localTimeEnabled,transparent:i,opacity:t.opacity,side:S.DoubleSide}):r=new S.MeshPhongMaterial({color:t.colour,morphTargets:o,morphNormals:t.localTimeEnabled,vertexColors:S.VertexColors,transparent:i,opacity:t.opacity,side:S.DoubleSide}),t.localMorphColour&&s.morphAttributes.color&&(r.onBeforeCompile=Pt())}else{let o=s._video.createCanvasVideoTexture();r=new S.MeshBasicMaterial({morphTargets:t.localTimeEnabled,color:new S.Color(1,1,1),transparent:i,opacity:t.opacity,map:o,side:S.DoubleSide}),(void 0).videoHandler=s._video}return new S.Mesh(s,r)},Fe=function(){Y.call(this),this.videoHandler=void 0,this.isGeometry=!0,this.createMesh=(n,e,t)=>{if(this.morph&&this.morph.geometry&&n!=null)return;const s=Yi(n,e,t);this.setMesh(s,t.localTimeEnabled,t.localMorphColour)},this.calculateUVs=()=>{this.geometry.computeBoundingBox();const n=this.geometry.boundingBox.max,e=this.geometry.boundingBox.min,t=new S.Vector2(0-e.x,0-e.y),s=new S.Vector2(n.x-e.x,n.y-e.y);this.geometry.faceVertexUvs[0]=[];for(let i=0;i<this.geometry.faces.length;i++){const r=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 S.Vector2((r.x+t.x)/s.x,(r.y+t.y)/s.y),new S.Vector2((o.x+t.x)/s.x,(o.y+t.y)/s.y),new S.Vector2((a.x+t.x)/s.x,(a.y+t.y)/s.y)])}geometry.uvsNeedUpdate=!0},this.checkTransparentMesh=function(){this._lod.checkTransparentMesh()},this.setWireframe=n=>{this.morph.material.wireframe=n},this.editVertices=function(n,e){if(n&&n.length){let t=this.getMorph();const s=t.geometry.getAttribute("position");if(!t||0>e)return;{let i=e*3;n.forEach(r=>{s.array[i++]=r[0],s.array[i++]=r[1],s.array[i++]=r[2]}),s.needsUpdate=!0,t.geometry.computeBoundingBox(),t.geometry.computeBoundingSphere(),this.boundingBoxUpdateRequired=!0}}}};Fe.prototype=Object.create(Y.prototype);const qt=Oe.default||Oe,ut=function(n,e){let t=n,s,i=500;e?s=new qt(t,.012,e.getStyle()):s=new qt(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 r=[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,u)=>{s&&s.position.set(o,a,u)},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=r[0]*o,s.scale.y=r[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},Ke=function(n,e,t,s){Y.call(this);let i;e&&(i=e.clone(),i.vertexColors=S.FaceColors);const r=s;this.id=t;let o,a;this.isGlyph=!0;let u=[0,0,0];this.fromMesh=f=>f&&f.isMesh?(this.morph=f.clone(),this.morph.userData=this,this.group.add(this.morph),!0):!1,n&&i&&this.fromMesh(new S.Mesh(n,i)),this.getGlyphset=function(){return r},this.setLabel=f=>{f&&(typeof f=="string"||f instanceof String)&&(a=f,this.morph&&(this.morph.name=f))},this.showLabel=f=>{if(o&&(u=o.getPosition(),this.group.remove(o.getSprite()),o.dispose(),o=void 0),a&&(typeof a=="string"||a instanceof String)){o=new ut(a,f),o.setPosition(u[0],u[1],u[2]);const l=o.getSprite();l.material.alphaTest=.5,l.material.transparent=!0,l.material.depthWrite=!1,this.group.add(o.getSprite())}},this.hideLabel=()=>{o&&(u=o.getPosition(),this.group.remove(o.getSprite()),o.dispose(),o=void 0)},this.getLabel=()=>a,this.getMesh=()=>this.morph,this.setTransformation=(f,l,c,d)=>{this.morph&&(this.morph.matrix.elements[0]=l[0],this.morph.matrix.elements[1]=l[1],this.morph.matrix.elements[2]=l[2],this.morph.matrix.elements[3]=0,this.morph.matrix.elements[4]=c[0],this.morph.matrix.elements[5]=c[1],this.morph.matrix.elements[6]=c[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),u=[...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}};Ke.prototype=Object.create(Y.prototype);function $e(){}$e.Handlers={handlers:[],add:function(n,e){this.handlers.push(n,e)},get:function(n){for(var e=this.handlers,t=0,s=e.length;t<s;t+=2){var i=e[t],r=e[t+1];if(i.test(n))return r}return null}},Object.assign($e.prototype,{crossOrigin:"anonymous",onLoadStart:function(){},onLoadProgress:function(){},onLoadComplete:function(){},initMaterials:function(n,e,t){for(var s=[],i=0;i<n.length;++i)s[i]=this.createMaterial(n[i],e,t);return s},createMaterial:function(){var n={NoBlending:v.NoBlending,NormalBlending:v.NormalBlending,AdditiveBlending:v.AdditiveBlending,SubtractiveBlending:v.SubtractiveBlending,MultiplyBlending:v.MultiplyBlending,CustomBlending:v.CustomBlending},e=new v.Color,t=new v.TextureLoader,s=new v.MaterialLoader;return function(r,o,a){var u={};function f(h,p,w,y,g){var _=o+h,A=$e.Handlers.get(_),N;A!==null?N=A.load(_):(t.setCrossOrigin(a),N=t.load(_)),p!==void 0&&(N.repeat.fromArray(p),p[0]!==1&&(N.wrapS=v.RepeatWrapping),p[1]!==1&&(N.wrapT=v.RepeatWrapping)),w!==void 0&&N.offset.fromArray(w),y!==void 0&&(y[0]==="repeat"&&(N.wrapS=v.RepeatWrapping),y[0]==="mirror"&&(N.wrapS=v.MirroredRepeatWrapping),y[1]==="repeat"&&(N.wrapT=v.RepeatWrapping),y[1]==="mirror"&&(N.wrapT=v.MirroredRepeatWrapping)),g!==void 0&&(N.anisotropy=g);var I=v.MathUtils.generateUUID();return u[I]=N,I}var l={uuid:v.MathUtils.generateUUID(),type:"MeshLambertMaterial"};for(var c in r){var d=r[c];switch(c){case"DbgColor":case"DbgIndex":case"opticalDensity":case"illumination":break;case"DbgName":l.name=d;break;case"blending":l.blending=n[d];break;case"colorAmbient":case"mapAmbient":console.warn("THREE.Loader.createMaterial:",c,"is no longer supported.");break;case"colorDiffuse":l.color=e.fromArray(d).getHex();break;case"colorSpecular":l.specular=e.fromArray(d).getHex();break;case"colorEmissive":l.emissive=e.fromArray(d).getHex();break;case"specularCoef":l.shininess=d;break;case"shading":d.toLowerCase()==="basic"&&(l.type="MeshBasicMaterial"),d.toLowerCase()==="phong"&&(l.type="MeshPhongMaterial"),d.toLowerCase()==="standard"&&(l.type="MeshStandardMaterial");break;case"mapDiffuse":l.map=f(d,r.mapDiffuseRepeat,r.mapDiffuseOffset,r.mapDiffuseWrap,r.mapDiffuseAnisotropy);break;case"mapDiffuseRepeat":case"mapDiffuseOffset":case"mapDiffuseWrap":case"mapDiffuseAnisotropy":break;case"mapEmissive":l.emissiveMap=f(d,r.mapEmissiveRepeat,r.mapEmissiveOffset,r.mapEmissiveWrap,r.mapEmissiveAnisotropy);break;case"mapEmissiveRepeat":case"mapEmissiveOffset":case"mapEmissiveWrap":case"mapEmissiveAnisotropy":break;case"mapLight":l.lightMap=f(d,r.mapLightRepeat,r.mapLightOffset,r.mapLightWrap,r.mapLightAnisotropy);break;case"mapLightRepeat":case"mapLightOffset":case"mapLightWrap":case"mapLightAnisotropy":break;case"mapAO":l.aoMap=f(d,r.mapAORepeat,r.mapAOOffset,r.mapAOWrap,r.mapAOAnisotropy);break;case"mapAORepeat":case"mapAOOffset":case"mapAOWrap":case"mapAOAnisotropy":break;case"mapBump":l.bumpMap=f(d,r.mapBumpRepeat,r.mapBumpOffset,r.mapBumpWrap,r.mapBumpAnisotropy);break;case"mapBumpScale":l.bumpScale=d;break;case"mapBumpRepeat":case"mapBumpOffset":case"mapBumpWrap":case"mapBumpAnisotropy":break;case"mapNormal":l.normalMap=f(d,r.mapNormalRepeat,r.mapNormalOffset,r.mapNormalWrap,r.mapNormalAnisotropy);break;case"mapNormalFactor":l.normalScale=d;break;case"mapNormalRepeat":case"mapNormalOffset":case"mapNormalWrap":case"mapNormalAnisotropy":break;case"mapSpecular":l.specularMap=f(d,r.mapSpecularRepeat,r.mapSpecularOffset,r.mapSpecularWrap,r.mapSpecularAnisotropy);break;case"mapSpecularRepeat":case"mapSpecularOffset":case"mapSpecularWrap":case"mapSpecularAnisotropy":break;case"mapMetalness":l.metalnessMap=f(d,r.mapMetalnessRepeat,r.mapMetalnessOffset,r.mapMetalnessWrap,r.mapMetalnessAnisotropy);break;case"mapMetalnessRepeat":case"mapMetalnessOffset":case"mapMetalnessWrap":case"mapMetalnessAnisotropy":break;case"mapRoughness":l.roughnessMap=f(d,r.mapRoughnessRepeat,r.mapRoughnessOffset,r.mapRoughnessWrap,r.mapRoughnessAnisotropy);break;case"mapRoughnessRepeat":case"mapRoughnessOffset":case"mapRoughnessWrap":case"mapRoughnessAnisotropy":break;case"mapAlpha":l.alphaMap=f(d,r.mapAlphaRepeat,r.mapAlphaOffset,r.mapAlphaWrap,r.mapAlphaAnisotropy);break;case"mapAlphaRepeat":case"mapAlphaOffset":case"mapAlphaWrap":case"mapAlphaAnisotropy":break;case"flipSided":l.side=v.BackSide;break;case"doubleSided":l.side=v.DoubleSide;break;case"transparency":console.warn("THREE.Loader.createMaterial: transparency has been renamed to opacity"),l.opacity=d;break;case"depthTest":case"depthWrite":case"colorWrite":case"opacity":case"reflectivity":case"transparent":case"visible":case"wireframe":l[c]=d;break;case"vertexColors":d===!0&&(l.vertexColors=v.VertexColors),d==="face"&&(l.vertexColors=v.FaceColors);break;default:console.error("THREE.Loader.createMaterial: Unsupported",c,d);break}}return l.type==="MeshBasicMaterial"&&delete l.emissive,l.type!=="MeshPhongMaterial"&&delete l.specular,l.opacity<1&&(l.transparent=!0),s.setTextures(u),s.parse(l)}}()});const Xi=function(n){var e=this;this.video=void 0,this.videoTexture=void 0;var t=n,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,r){var o=i/r*e.video.duration;e.video.currentTime=o},this.getVideoDuration=function(){return e.video.duration},this.createCanvasVideoTexture=function(){return e.videoTexture=new S.VideoTexture(e.video),e.videoTexture.minFilter=S.LinearFilter,e.videoTexture.magFilter=S.LinearFilter,e.videoTexture.format=S.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()},Zt=S.AnimationClip,dt=S.Color,Ji=S.DefaultLoadingManager,Ki=S.FileLoader,$i=S.LoaderUtils,Yt=S.Vector2,Ge=S.Vector3,Xt=S.Vector4;function Qe(n){typeof n=="boolean"&&(console.warn("THREE.JSONLoader: showStatus parameter has been removed from constructor."),n=void 0),this.manager=n!==void 0?n:Ji,this.withCredentials=!1,this.paramsString=""}Object.assign(Qe.prototype,{load:function(n,e,t,s){var i=this,r=this.texturePath&&typeof this.texturePath=="string"?this.texturePath:$i.extractUrlBase(n),o=new Ki(this.manager);n.split("?"),n.length===2?this.paramsString=paramsStrings[1]:this.paramsString="",o.setWithCredentials(this.withCredentials),o.load(n,function(a){var u=void 0;try{u=JSON.parse(a)}catch{if(console.error("The loader has encountered an error while parsing the content of a resource."),s){s({responseURL:n});return}}var f=u.metadata;if(f!==void 0){var l=f.type;if(l!==void 0&&l.toLowerCase()==="object"){console.error("THREE.JSONLoader: "+n+" should be loaded with THREE.ObjectLoader instead.");return}}if(i&&i.parse)try{var c=i.parse(u,r);e(c.geometry,c.materials)}catch(d){if(console.error("The loader has encountered aon loading the geometry"),console.error(d),s){s({responseURL:n});return}}},t,s)},setTexturePath:function(n){this.texturePath=n},parse:function(){function n(i,r){function o(Z,E){return Z&1<<E}var a,u,f,l,c,d,h,p,w,y,g,_,A,N,I,D,F,q,G,T,C,U,M,O,k,P,m,L=i.faces,b=i.vertices,B=i.normals,V=i.colors,R=i.scale,z=0;if(i.uvs!==void 0){for(a=0;a<i.uvs.length;a++)i.uvs[a].length&&z++;for(a=0;a<z;a++)r.faceVertexUvs[a]=[]}for(l=0,c=b.length;l<c;)q=new Ge,q.x=b[l++]*R,q.y=b[l++]*R,q.z=b[l++]*R,r.vertices.push(q);if(l=0,c=L.length,i.uvs)for(a=0;a<i.uvs.length;a++){r.uvs[a]=[];for(let Z=0;Z<i.uvs[a].length;Z++)r.uvs[a][Z]=i.uvs[a][Z]}if(B)for(a=0;a<B.length;a++)r.normals[a]=B[a];if(V)for(a=0;a<V.length;a++)r.colors[a]=V[a];for(;l<c;)if(y=L[l++],g=o(y,0),_=o(y,1),A=o(y,3),N=o(y,4),I=o(y,5),D=o(y,6),F=o(y,7),g){if(T=new De,T.a=L[l],T.b=L[l+1],T.c=L[l+3],C=new De,C.a=L[l+1],C.b=L[l+2],C.c=L[l+3],l+=4,_&&(w=L[l++],T.materialIndex=w,C.materialIndex=w),f=r.faces.length,A)for(a=0;a<z;a++)for(O=i.uvs[a],r.faceVertexUvs[a][f]=[],r.faceVertexUvs[a][f+1]=[],u=0;u<4;u++)p=L[l++],P=O[p*2],m=O[p*2+1],k=new Yt(P,m),u!==2&&r.faceVertexUvs[a][f].push(k),u!==0&&r.faceVertexUvs[a][f+1].push(k);if(N&&(h=L[l++]*3,T.normal.set(B[h++],B[h++],B[h]),C.normal.copy(T.normal)),I)for(a=0;a<4;a++)h=L[l++]*3,M=new Ge(B[h++],B[h++],B[h]),a!==2&&T.vertexNormals.push(M),a!==0&&C.vertexNormals.push(M);if(D&&(d=L[l++],U=V[d],T.color.setHex(U),C.color.setHex(U)),F)for(a=0;a<4;a++)d=L[l++],U=V[d],a!==2&&T.vertexColors.push(new dt(U)),a!==0&&C.vertexColors.push(new dt(U));r.faces.push(T),r.faces.push(C)}else{if(G=new De,G.a=L[l++],G.b=L[l++],G.c=L[l++],G.b||(G.b=G.a),G.c||(G.c=G.b),_&&(w=L[l++],G.materialIndex=w),f=r.faces.length,A)for(a=0;a<z;a++)for(O=i.uvs[a],r.faceVertexUvs[a][f]=[],u=0;u<3;u++)p=L[l++],P=O[p*2],m=O[p*2+1],k=new Yt(P,m),r.faceVertexUvs[a][f].push(k);if(N&&(h=L[l++]*3,G.normal.set(B[h++],B[h++],B[h])),I)for(a=0;a<3;a++)h=L[l++]*3,M=new Ge(B[h++],B[h++],B[h]),G.vertexNormals.push(M);if(D&&(d=L[l++],G.color.setHex(V[d])),F)for(a=0;a<3;a++)d=L[l++],G.vertexColors.push(new dt(V[d]));r.faces.push(G)}}function e(i,r){var o=i.influencesPerVertex!==void 0?i.influencesPerVertex:2;if(i.skinWeights)for(var a=0,u=i.skinWeights.length;a<u;a+=o){var f=i.skinWeights[a],l=o>1?i.skinWeights[a+1]:0,c=o>2?i.skinWeights[a+2]:0,d=o>3?i.skinWeights[a+3]:0;r.skinWeights.push(new Xt(f,l,c,d))}if(i.skinIndices)for(var a=0,u=i.skinIndices.length;a<u;a+=o){var h=i.skinIndices[a],p=o>1?i.skinIndices[a+1]:0,w=o>2?i.skinIndices[a+2]:0,y=o>3?i.skinIndices[a+3]:0;r.skinIndices.push(new Xt(h,p,w,y))}r.bones=i.bones,r.bones&&r.bones.length>0&&(r.skinWeights.length!==r.skinIndices.length||r.skinIndices.length!==r.vertices.length)&&console.warn("When skinning, number of vertices ("+r.vertices.length+"), skinIndices ("+r.skinIndices.length+"), and skinWeights ("+r.skinWeights.length+") should match.")}function t(i,r){var o=i.scale;if(i.morphTargets!==void 0)for(var a=0,u=i.morphTargets.length;a<u;a++){r.morphTargets[a]={},r.morphTargets[a].name=i.morphTargets[a].name,r.morphTargets[a].vertices=[];for(var f=r.morphTargets[a].vertices,l=i.morphTargets[a].vertices,c=0,d=l.length;c<d;c+=3){var h=new Ge;h.x=l[c]*o,h.y=l[c+1]*o,h.z=l[c+2]*o,f.push(h)}}if(i.morphNormals!==void 0){for(var a=0,u=i.morphNormals.length;a<u;a++)if(r.morphTargets[a]){r.morphTargets[a].normals=[];for(var p=r.morphTargets[a].normals,w=i.morphNormals[a].normals,c=0,d=w.length;c<d;c+=3){var y=new Ge;y.x=w[c],y.y=w[c+1],y.z=w[c+2],p.push(y)}r.morphNormalsReady=!0}}if(i.morphColors!==void 0){var a,u,g,_,A,N,I;for(a=0,u=i.morphColors.length;a<u;a++)for(r.morphColors[a]={},r.morphColors[a].name=i.morphColors[a].name,r.morphColors[a].colors=[],A=r.morphColors[a].colors,N=i.morphColors[a].colors,g=0,_=N.length;g<_;g+=3)I=new S.Color(16755200),I.setRGB(N[g],N[g+1],N[g+2]),A.push(I)}}function s(i,r){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 u=0;u<a.length;u++){var f=Zt.parseAnimation(a[u],r.bones);f&&o.push(f)}if(r.morphTargets){var l=Zt.CreateClipsFromMorphTargetSequences(r.morphTargets,10);o=o.concat(l)}o.length>0&&(r.animations=o)}return function(r,o){r.data!==void 0&&(r=r.data),r.scale!==void 0?r.scale=1/r.scale:r.scale=1;var a=new Be;if(a.morphColors=[],n(r,a),e(r,a),t(r,a),s(r,a),a.computeFaceNormals(),a.computeBoundingSphere(),r.materials===void 0||r.materials.length===0)return{geometry:a};var u=$e.prototype.initMaterials(r.materials,o,"Anonymous");if(r.materials[0].video){var f=o+r.materials[0].video;this.paramsString&&(f=f+`?${this.paramsString}`);const l=new Xi(f);a._video=l}return u&&u.length>0&&(r.materials[0].singleSided?u[0].side=S.FrontSide:r.materials[0].flipSided?u[0].side=S.BackSide:u[0].side=S.DoubleSide,r.materials[0].specularCoef&&(u[0].shininess=Math.floor(r.materials[0].specularCoef/3))),{geometry:a,materials:u}}}()});const ft=function(){Y.call(this);const n=[];let e,t,s,i,r,o,a,u=0,f=0,l=[0,0,0],c=[0,0,0],d=[0,0,0],h="NONE";this.ready=!1;let p=!1,w=!1;this.isGlyphset=!0;let y=new S.Matrix4;const g=new S.Color,_=new S.Color,A=new S.Box3,N=new S.Box3,I=new S.Box3,D=[],F=[],q=[],G=[],T=[],C=[],U=[];this.globalScale=1;for(let b=0;b<8;b++)new S.Vector3;this.load=(b,B,V,R,z)=>{e=b.axis1,t=b.axis2,s=b.axis3,i=b.positions,r=b.scale,o=b.colors,a=b.label,p=b.metadata.MorphColours,w=b.metadata.MorphVertices,u=b.metadata.number_of_time_steps,h=b.metadata.repeat_mode,f=b.metadata.number_of_vertices,h=="AXES_2D"||h=="MIRROR"?f=f*2:h=="AXES_3D"&&(f=f*3),l=b.metadata.base_size,c=b.metadata.offset,d=b.metadata.scale_factors;const Z=new Qe;this.geometry=new S.BufferGeometry;const E=new S.InstancedMesh(this.geometry,void 0,f);if(this.setMorph(E),R){var $=Z.parse(B);L(V,z)($.geometry,$.materials),$.geometry.dispose()}else Z.crossOrigin="Anonymous",Z.load(B,L(V,z))};const M=(b,B,V,R,z,Z)=>{if(h=="NONE"||h=="MIRROR"){let K=[0,0,0],ee=[0,0,0],re=[0,0,0],Q=[0,0,0],ue=[0,0,0];const ne=[0,0,0],te=[0,0,0],J=[0,0,0],ie=[0,0,0];for(var E=0;E<3;E++){var $=z[E]<0?-1:1;K[E]=($*l[E]+z[E]*d[E])*this.globalScale}for(var E=0;E<3;E++)ee[E]=B[E]*K[0],re[E]=V[E]*K[1],Q[E]=R[E]*K[2],ue[E]=b[E]+c[0]*ee[E]+c[1]*re[E]+c[2]*Q[E],h=="MIRROR"&&(ne[E]=-ee[E],te[E]=-re[E],J[E]=-Q[E],ie[E]=ue[E],z[0]<0&&(ue[E]-=ee[E],ie[E]-=ne[E]));0>Q[0]*(ee[1]*re[2]-ee[2]*re[1])+Q[1]*(ee[2]*re[0]-ee[0]*re[2])+Q[2]*(ee[0]*re[1]-ee[1]*re[0])&&(Q[0]=-Q[0],Q[1]=-Q[1],Q[2]=-Q[2]),Z[0]=[ue,ee,re,Q],h=="MIRROR"&&(0>J[0]*(ne[1]*te[2]-ne[2]*te[1])+J[1]*(ne[2]*te[0]-ne[0]*te[2])+J[2]*(ne[0]*te[1]-ne[1]*te[0])&&(J[0]=-J[0],J[1]=-J[1],J[2]=-J[2]),Z[1]=[ie,ne,te,J])}else if(h=="AXES_2D"||h=="AXES_3D"){let K=[0,0,0],ee=[0,0,0];for(var E=0;E<3;E++){var $=z[E]<0?-1:1;K[E]=($*l[0]+z[E]*d[0])*this.globalScale}for(var E=0;E<3;E++)ee[E]=b[E]+c[0]*K[0]*B[E]+c[1]*K[1]*V[E]+c[2]*K[2]*R[E];const re=glyph_repeat_mode=="AXES_2D"?2:3;for(let Q=0;Q<re;Q++){let ue,ne;const te=z[Q];let J=[0,0,0],ie=[0,0,0],ae=[0,0,0];Q==0?(ue=B,ne=V):Q==1?(ue=V,ne=glyph_repeat_mode=="AXES_2D"?B:R):(ue=R,ne=B);const Le=(l[0]+te*d[0])*this.globalScale;J[0]=ue[0]*Le,J[1]=ue[1]*Le,J[2]=ue[2]*Le,ae[0]=J[1]*ne[2]-ne[1]*J[2],ae[1]=J[2]*ne[0]-ne[2]*J[0],ae[2]=J[0]*ne[1]-J[1]*ne[0];let oe=Math.sqrt(ae[0]*ae[0]+ae[1]*ae[1]+ae[2]*ae[2]);if(0<oe){let Ne=(l[2]+te*d[2])*this.globalScale/oe;h=="AXES_2D"&&Q>0&&(Ne*=-1),ae[0]*=Ne,ae[1]*=Ne,ae[2]*=Ne}if(ie[0]=ae[1]*J[2]-J[1]*ae[2],ie[1]=ae[2]*J[0]-J[2]*ae[0],ie[2]=ae[0]*J[1]-ae[1]*J[0],oe=Math.sqrt(ie[0]*ie[0]+ie[1]*ie[1]+ie[2]*ie[2]),0<oe){var H=(l[1]+te*d[1])*this.globalScale/oe;ie[0]*=H,ie[1]*=H,ie[2]*=H}Z[Q]=[ee,J,ie,ae]}}return Z},O=(b,B,V,R,z)=>{let Z=1;h=="AXES_2D"||h=="MIRROR"?Z=2:h=="AXES_3D"&&(Z=3);const E=b.length/3;let $=0;U.length=Z;for(let H=0;H<E;H++){const K=H*3,ee=[b[K],b[K+1],b[K+2]],re=[B[K],B[K+1],B[K+2]],Q=[V[K],V[K+1],V[K+2]],ue=[R[K],R[K+1],R[K+2]],ne=[z[K],z[K+1],z[K+2]],te=M(ee,re,Q,ue,ne,U);if(te.length==Z)for(let J=0;J<Z;J++){y.elements[0]=te[J][1][0],y.elements[1]=te[J][1][1],y.elements[2]=te[J][1][2],y.elements[3]=0,y.elements[4]=te[J][2][0],y.elements[5]=te[J][2][1],y.elements[6]=te[J][2][2],y.elements[7]=0,y.elements[8]=te[J][3][0],y.elements[9]=te[J][3][1],y.elements[10]=te[J][3][2],y.elements[11]=0,y.elements[12]=te[J][0][0],y.elements[13]=te[J][0][1],y.elements[14]=te[J][0][2],y.elements[15]=1,this.morph.setMatrixAt($,y);const ie=n[$];ie&&ie.setTransformation(te[J][0],te[J][1],te[J][2],te[J][3]),$++}}this.morph.instanceMatrix.needsUpdate=!0},k=b=>{let B=1;h=="AXES_2D"||h=="MIRROR"?B=2:h=="AXES_3D"&&(B=3);const V=b.length;let R=0;for(let z=0;z<V;z++){const Z=b[z];for(let E=0;E<B;E++){g.setHex(Z),this.morph.setColorAt(R,g);const $=n[R];$&&$.setColour(g),R++}}this.morph.instanceColor.needsUpdate=!0},P=()=>{let b=D,B=F,V=q,R=G,z=T,Z=C;const E=this.inbuildTime/this.duration*(u-1),$=Math.floor(E),H=1-(E-$),K=Math.ceil(E);if(w){const ee=i[$.toString()],re=i[K.toString()],Q=e[$.toString()],ue=e[K.toString()],ne=t[$.toString()],te=t[K.toString()],J=s[$.toString()],ie=s[K.toString()],ae=r[$.toString()],Le=r[K.toString()];D.length=ee.length,F.length=ee.length,q.length=ee.length,G.length=ee.length,T.length=ee.length;for(let oe=0;oe<ee.length;oe++)b[oe]=H*ee[oe]+(1-H)*re[oe],B[oe]=H*Q[oe]+(1-H)*ue[oe],V[oe]=H*ne[oe]+(1-H)*te[oe],R[oe]=H*J[oe]+(1-H)*ie[oe],z[oe]=H*ae[oe]+(1-H)*Le[oe]}else b=i[0],B=e[0],V=t[0],R=s[0],z=r[0];if(O(b,B,V,R,z),this.boundingBoxUpdateRequired=!0,o!=null){if(p){const ee=o[$.toString()],re=o[K.toString()];Z.length=ee.length;for(let Q=0;Q<ee.length;Q++)g.setHex(ee[Q]),_.setHex(re[Q]),g.setRGB(g.r*H+_.r*(1-H),g.g*H+_.g*(1-H),g.b*H+_.b*(1-H)),Z[Q]=g.getHex()}else Z=o[0];k(Z)}};this.getLabel=b=>{if(a&&a.length>b)return a[b]},this.showLabel=()=>{for(let b=0;b<n.length;b++)n[b].showLabel(this.morph.material?this.morph.material.color:void 0)},this.hideLabel=()=>{for(let b=0;b<n.length;b++)n[b].hideLabel()};const m=b=>{for(let B=0;B<f;B++){const V=new Ke(void 0,void 0,B,this);let R=a?a[B]:void 0;R=R||this.groupName,R&&V.setLabel(R),u>0&&V.setFrustumCulled(!1),n[B]=V,this.morph.add(V.getGroup())}b&&this.showLabel(),O(i[0],e[0],t[0],s[0],r[0]),o!=null&&k(o[0]),this.ready=!0,this.boundingBoxUpdateRequired=!0};this.addCustomGlyph=b=>{b.isGlyph&&n.push(b),this.ready=!0,this.boundingBoxUpdateRequired=!0},this.addMeshAsGlyph=(b,B)=>{if(b.isMesh){const V=new Ke(void 0,void 0,B,this);return V.fromMesh(b),n.push(V),this.morph.add(V.getGroup()),this.ready=!0,this.boundingBoxUpdateRequired=!0,V}},this.forEachGlyph=b=>{for(let B=0;B<n.length;B++)b(n[B])};var L=(b,B)=>(V,R)=>{const z=V.toBufferGeometry();this.geometry.copy(z),this.geometry.computeBoundingSphere(),this.geometry.computeBoundingBox(),z.dispose(),R&&R[0]&&(this.morph.material=R[0]),m(B),this.morph.name=this.groupName,this.morph.userData=this,this.setMorph(this.morph),V.dispose(),b!=null&&typeof b=="function"&&b(this)};this.getClosestVertexIndex=function(){let b=-1;if(this.morph&&this.ready){this.getBoundingBox().getCenter(this._v1);let B=i[0];const V=B.length/3;let R=-1,z=0;for(let Z=0;Z<V;Z++){const E=Z*3;this._v2.set(B[E],B[E+1],B[E+2]),z=this._v1.distanceTo(this._v2),(R==-1||R>z)&&(R=z,b=Z)}}return b},this.getClosestVertex=function(){if(this.closestVertexIndex==-1&&(this.closestVertexIndex=this.getClosestVertexIndex()),this.closestVertexIndex>=0&&this.morph){let b=new S.Vector3;return this.morph.getMatrixAt(this.closestVertexIndex,y),b.setFromMatrixPosition(y),b}},this.getBoundingBox=()=>{if(this.morph&&this.ready&&this.morph.visible){if(this.boundingBoxUpdateRequired){A.setFromBufferAttribute(this.morph.geometry.attributes.position);for(let b=0;b<f;b++)this.morph.getMatrixAt(b,y),N.copy(A).applyMatrix4(y),b==0?I.copy(N):I.union(N);if(I)this.cachedBoundingBox.copy(I),this.morph.updateWorldMatrix(!0,!0),this.cachedBoundingBox.applyMatrix4(this.morph.matrixWorld),this.boundingBoxUpdateRequired=!1;else return}return this.cachedBoundingBox}},this.setMorphTime=b=>{b>this.duration?this.inbuildTime=this.duration:0>b?this.inbuildTime=0:this.inbuildTime=b,(p||w)&&(P(),w&&(this.markerUpdateRequired=!0))},this.isTimeVarying=()=>!!((this.ready===!1||u>0)&&(p||w)),this.getCurrentTime=()=>this.inbuildTime,this.setScaleAll=function(b){this.globalScale=b,P()},this.dispose=()=>{for(let b=n.length-1;b>=0;b--)n[b].dispose();this.geometry&&this.geometry.dispose(),this.morph&&this.morph.material.dispose(),e=void 0,t=void 0,s=void 0,i=void 0,r=void 0,o=void 0,this.ready=!1,this.groupName=void 0},this.render=(b,B,V)=>{if(B==!0){let R=this.inbuildTime+b;R>this.duration&&(R=R-this.duration),this.inbuildTime=R,(p||w)&&P()}this.updateMarker(B,V)}};ft.prototype=Object.create(Y.prototype);const Jt=new v.Matrix4,pt=new v.Ray,He=new v.Sphere,je=new v.Vector3,mt=new v.Vector3,Kt=new v.Vector3;class gt extends v.Object3D{constructor(e=new v.BufferGeometry,t=new v.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,r=e.params.Points.threshold,o=s.drawRange;if(s.boundingSphere===null&&s.computeBoundingSphere(),He.copy(s.boundingSphere),He.applyMatrix4(i),He.radius+=r,e.ray.intersectsSphere(He)===!1)return;Jt.copy(i).invert(),pt.copy(e.ray).applyMatrix4(Jt);const a=r/((this.scale.x+this.scale.y+this.scale.z)/3)*this.material.size*this.sizePerPixel,u=a*a;if(s.isBufferGeometry){const f=s.index,c=s.attributes.position,d=s.morphAttributes.position;if(f!==null){const h=Math.max(0,o.start),p=Math.min(f.count,o.start+o.count);for(let w=h,y=p;w<y;w++){const g=f.getX(w);Qt(this,c,d,g),$t(je,g,u,i,e,t,this)}}else{const h=Math.max(0,o.start),p=Math.min(c.count,o.start+o.count);for(let w=h,y=p;w<y;w++)Qt(this,c,d,w),$t(je,w,u,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 r=0,o=i.length;r<o;r++){const a=i[r].name||String(r);this.morphTargetInfluences.push(0),this.morphTargetDictionary[a]=r}}}}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.")}}}gt.prototype.isPoints=!0;function $t(n,e,t,s,i,r,o){const a=pt.distanceSqToPoint(n);if(a<t){const u=new v.Vector3;pt.closestPointToPoint(n,u),u.applyMatrix4(s);const f=i.ray.origin.distanceTo(u);if(f<i.near||f>i.far)return;r.push({distance:f,distanceToRay:Math.sqrt(a),point:u,index:e,face:null,object:o})}}function Qt(n,e,t,s){je.fromBufferAttribute(e,s);const i=n.morphTargetInfluences;if(n.material.morphTargets&&t&&i){mt.set(0,0,0);for(var r=0,o=t.length;r<o;r++){const a=i[r],u=t[r];a!==0&&(Kt.fromBufferAttribute(u,s),mt.addScaledVector(Kt.sub(je),a))}je.add(mt)}}const Te=function(){Y.call(this),this.isPointset=!0;const n=[];let e=1,t=!1,s=500,i=!0;this.createMesh=(a,u,f)=>{if(a&&u){let l=Ze(a,f);const c=Ut();u.map=c;let d=new gt(l,u);this.setMesh(d,f.localTimeEnabled,f.localMorphColour)}};const r=(a,u,f,l)=>{if(f){const c=new S.Color(l),d=new ut(f,c);d.setPosition(u[0],u[1],u[2]);const h=d.getSprite();h.material.sizeAttenuation=!1,h.material.alphaTest=.5,h.material.transparent=!0,h.material.depthWrite=!1,h.material.depthTest=t,d.setFontWeight(s),d.setSize(e),d.setVisibility(i),this.group.add(h),n[a]=d}},o=a=>{const u=n[a];if(u){const f=u.getSprite();this.group.remove(f),u.dispose(),n.splice(a,1)}};this.addPoints=(a,u,f)=>{if(a&&a.length>0){let l=this.drawRange;l===-1&&(l=0);const c=this.addVertices(a);if(!this.getMorph()){let w=new S.PointsMaterial({alphaTest:.5,size:10,color:f,sizeAttenuation:!1});const y={localTimeEnabled:!1,localMorphColour:!1};c.colorsNeedUpdate=!0,this.createMesh(c,w,y)}let h=l+a.length,p=0;if(Array.isArray(u)&&u.length===a.length||typeof u=="string")for(n.length,l;l+p<h;){const w=typeof u=="string"?u:u[p];r(l+p,a[p],w,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 u=0;u<n.length;u++)n[u]&&n[u].setColour(this._lod._material.color)},this.setColour=a=>{this._lod.setColour(a);for(let u=0;u<n.length;u++)n[u]&&n[u].setColour(this._lod._material.color)},this.setLabelDepthTest=a=>{t=a;for(let u=0;u<n.length;u++)n[u]&&n[u].setDepthTest(a)},this.setLabelFontWeight=a=>{s=a;for(let u=0;u<n.length;u++)n[u]&&n[u].setFontWeight(a)},this.setLabelSize=a=>{e=a;for(let u=0;u<n.length;u++)n[u]&&n[u].setSize(e)},this.displayLabels=a=>{i=a;for(let u=0;u<n.length;u++)n[u]&&n[u].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 u=this.getMorph().geometry.getAttribute("position");return[u.getX(a),u.getY(a),u.getZ(a)]}},this.editVertices=function(a,u){if(a&&a.length){let f=this.getMorph();const l=u+a.length-1;if(!f||0>u||l>=this.drawRange)return;{const c=f.geometry.getAttribute("position");let d=u;a.forEach(h=>{const p=n[d];p&&p.setPosition(h[0],h[1],h[2]),c.setXYZ(d++,h[0],h[1],h[2])}),c.needsUpdate=!0,f.geometry.computeBoundingBox(),f.geometry.computeBoundingSphere(),this.boundingBoxUpdateRequired=!0}}},this.deleteVertices=function(a){return Te.prototype.deleteVertices.call(this,a)&&o(a),this.drawRange},this.setName=function(a){const u=this.groupName;Te.prototype.setName.call(this,a),n.forEach(f=>{f.getString()===u&&(f==null||f.setText(a))})},this.render=(a,u,f,l)=>{this.morph&&f&&(this.morph.sizePerPixel=f.pixelHeight),Te.prototype.render.call(this,a,u,f,l)}};Te.prototype=Object.create(Y.prototype);const Ve=function(){Y.call(this),this.isLines=!0,this.createLineSegment=(n,e,t)=>{if(n&&e){let s=Ze(n,t);t.localMorphColour&&s.morphAttributes.color&&(e.onBeforeCompile=Pt());let i=new Xe(s,e);this.setMesh(i,t.localTimeEnabled,t.localMorphColour)}},this.setWidth=n=>{this.morph&&this.morph.material&&(this.morph.material.linewidth=n,this.morph.material.needsUpdate=!0)},this.addLines=(n,e)=>{if(n&&n.length>0){const t=this.addVertices(n);if(!this.getMorph()){let i=new S.LineBasicMaterial({color:e});const r={localTimeEnabled:!1,localMorphColour:!1};t.colorsNeedUpdate=!0,this.createLineSegment(t,i,r)}this.region&&(this.region.pickableUpdateRequired=!0)}}};Ve.prototype=Object.create(Y.prototype);const Ue=function(){this.isTexture=!0,this.impl=void 0,this.isLoading=!1,this.size={width:1,height:1,depth:0}};Ue.prototype.loadImage=function(n,e){return new Promise((t,s)=>{n.onload=()=>t(n),n.onerror=s,n.src=e})},Ue.prototype.imageToUint8Array=async function(n,e,t,s){await n.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}},Ue.prototype.loadFromImages=async function(n){},Ue.prototype.isReady=function(){return!!(this.impl&&!this.isLoading)},Ue.prototype.getMaterial=function(){if(this.impl)return new S.MeshBasicMaterial({color:new S.Color(1,1,1),transparent:!1,opacity:1,map:this.impl,side:S.DoubleSide})};const yt=function(){Ue.call(this),this.isTextureArray=!0,this.loadFromImages=async n=>{let e=1,t=1,s=0;if(n&&n.length){this.isLoading=!0;const i=new Image;i.crossOrigin="Anonymous";const r=document.createElement("canvas");let o=0;const a=new Array(n.length);for(let f=0;f<n.length;f++){const l=await this.imageToUint8Array(this,i,n[f],r);l&&l.array&&(e=l.width,t=l.height,a[s]=l.array,o+=a[s].length,s++)}const u=new Uint8Array(o);o=0,a.forEach(f=>{u.set(f,o),o+=f.length}),this.impl=new S.DataTexture2DArray(u,e,t,s),this.size={width:e,height:t,depth:s},this.isLoading=!1,this.impl.needsUpdate=!0}},this.getMaterial=n=>{if(this.impl){let e;if(n){if(n.vs&&n.fs){let t=!0;"transparent"in n&&(t=n.transparent);let s=S.FrontSide;n.side&&(s=n.side),e=new S.ShaderMaterial({transparent:t,uniforms:n.uniforms,vertexShader:n.vs,fragmentShader:n.fs,side:s}),n.glslVersion&&(e.glslVersion=n.glslVersion)}}else e=new S.MeshBasicMaterial({color:new S.Color(1,1,1),transparent:!1,opacity:1,map:this.impl,side:S.DoubleSide});if(e)return e.needsUpdate=!0,e}}};yt.prototype=Object.create(Ue.prototype);const Qi=S.GLSL3,Hi=`
|
|
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(`
|
|
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=`
|
|
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
|
-
`,
|
|
40
|
+
`,xs=`
|
|
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
|
-
`,ts=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 S.Vector3(0,0,1)},time:{value:0}}},ke=function(n){Y.call(this),this.isTexturePrimitive=!0,this.texture=n,this.textureList=[],this.texture&&this.textureList.push(this.texture),this.load=(e,t,s)=>{if(e&&e.images&&e.images.source){const i=new yt,r=[];e.images.source.forEach(a=>{r.push(ye(a))});const o=this;i.loadFromImages(r).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)}};ke.prototype=Object.create(Y.prototype),ke.prototype.constructor=ke;const Ee=function(n){ke.call(this,n),this.isTextureSlides=!0;const e=[],t={};this.morph=new S.Group,this.group=this.morph,this.morph.userData=this;let s,i=!0,r=!1,o=0,a=1,u=1,f,l=!1,c=!0,d=0,h=0,p=-.1;this.createSlides=g=>{g.forEach(_=>this.createSlide(_))};const w=(g,_)=>{const A=g.material,N=A.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,_.direction){case"x":const I=-Math.PI/2;g.rotation.y=I,N.direction.value=1,N.slide.value.set(_.value,0,0),g.position.x=_.value;break;case"y":g.rotation.x=Math.PI/2,N.direction.value=2,N.slide.value.set(0,_.value,0),g.position.y=_.value;break;case"z":N.direction.value=3,N.slide.value.set(0,0,_.value),g.position.z=_.value;break}A.needsUpdate=!0,this.boundingBoxUpdateRequired=!0};this.modifySlideSettings=g=>{g&&g.id&&g.id in t&&t[g.id]&&w(t[g.id],g)},this.createSlide=g=>{if(this.texture&&this.texture.isTextureArray&&this.texture.isReady()&&g&&g.direction&&g.value!==void 0){const _=new S.PlaneGeometry(1,1);_.translate(.5,.5,0);const A=ts();A.brightness.value=o,A.contrast.value=a,A.diffuse0.value=this.texture.impl,A.diffuse1.value=this.texture.impl,A.discardAlpha.value=c,A.depth.value=this.texture.size.depth,A.flipY.value=i,A.flipZ.value=r,A.mask.value=f,A.maskEnabled.value=l,A.nChannels.value=u;const N={fs:Hi,vs:es,uniforms:A,glslVersion:Qi,side:S.DoubleSide,transparent:!1},I=this.texture.getMaterial(N);I.needsUpdate=!0;const D=new S.Mesh(_,I);D.name=this.groupName,D.userData=this;const F={value:g.value,direction:g.direction,id:D.id};return e.push(F),w(D,F),t[D.id]=D,this.morph.add(D),this.boundingBoxUpdateRequired=!0,this.updateTimeTexture(),F}},this.getTextureSettings=()=>[...e],this.getTextureSettingsWithId=g=>{for(let _=0;_<e.length;_++)if(g===e[_].id)return{...e[_]}},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 A=t[g];this.morph.remove(A),A.clear(),A.geometry&&A.geometry.dispose(),A.material&&A.material.dispose(),this.boundingBoxUpdateRequired=!0}const _=e.findIndex(A=>A.id===g);_>-1&&e.splice(_,1)}},this.dispose=()=>{this.morph.children.forEach(g=>{g.geometry&&g.geometry.dispose(),g.material&&g.material.dispose()}),ke.prototype.dispose.call(this),this.boundingBoxUpdateRequired=!0};const y=(g,_,A)=>{if(_)switch(_.direction.value){case 1:A.copy(_.slide.value),g.expandByPoint(A),A.setY(1),A.setZ(1),g.expandByPoint(A);break;case 2:A.copy(_.slide.value),g.expandByPoint(A),A.setX(1),A.setZ(1),g.expandByPoint(A);break;case 3:A.copy(_.slide.value),g.expandByPoint(A),A.setX(1),A.setY(1),g.expandByPoint(A);break}};this.getBoundingBox=()=>{if(this.morph&&this.morph.children&&this.morph.visible&&this.boundingBoxUpdateRequired){this.cachedBoundingBox.makeEmpty();const g=new S.Vector3(0,0,0);this.morph.children.forEach(_=>{y(this.cachedBoundingBox,_.material.uniforms,g)}),this.morph.updateMatrixWorld(!0,!0),this.cachedBoundingBox.applyMatrix4(this.morph.matrixWorld),this.boundingBoxUpdateRequired=!1}return this.cachedBoundingBox},this.applyTransformation=(g,_,A)=>{const N=new S.Matrix4;N.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 I=new S.Quaternion().setFromRotationMatrix(N);this.morph.position.set(..._),this.morph.quaternion.copy(I),this.morph.scale.set(...A),this.morph.updateMatrix(),this.boundingBoxUpdateRequired=!0},this.setRenderOrder=g=>{this.morph.renderOrder=g},this.initialise=(g,_)=>{if(g){const A=g.locations;A&&A.length>0&&(this.applyTransformation(A[0].orientation,A[0].position,A[0].scale),"flipY"in A[0]&&(i=A[0].flipY),"flipZ"in A[0]&&(r=A[0].flipZ)),this.createSlides(g.settings.slides),_!=null&&typeof _=="function"&&_(this)}},this.showEdges=g=>{if(s)s.material.color=g;else{const _=new S.BoxGeometry(1,1,1);_.translate(.5,.5,.5);const A=new S.EdgesGeometry(_);s=new S.LineSegments(A,new S.LineBasicMaterial({color:g})),this.group.add(s)}s.visible=!0},this.setUniformsValue=(g,_)=>{this.morph.children.forEach(A=>{const N=A.material;if(N.type==="ShaderMaterial"){const I=N.uniforms;I[g].value=_,N.needsUpdate=!0}})},this.isAlphaPixelDiscarded=()=>c,this.discardAlphaPixel=g=>{c=g,this.setUniformsValue("discardAlpha",c)},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=()=>u,this.setNumberOfChannels=g=>{u=g,this.setUniformsValue("nChannels",u)},this.getMask=()=>f,this.setMask=g=>{f=g,l=!!f,this.setUniformsValue("mask",f),this.setUniformsValue("maskEnabled",l)},this.hideEdges=()=>{s&&(s.visible=!1)},this.updateTimeTexture=()=>{const g=this.textureList.length-1,_=this.inbuildTime/this.duration;if(this.timeEnabled&&g>0&&p!==_){const A=_*g,N=Math.floor(A),I=Math.ceil(A),D=A-N;this.morph.children.forEach(F=>{const q=F.material;if(q.type==="ShaderMaterial"){const G=q.uniforms;d!==N&&(G.diffuse0.value=this.textureList[N].impl),h!==I&&(G.diffuse1.value=this.textureList[I].impl),G.time.value=D,q.needsUpdate=!0}}),d=N,h=I,p=_}},this.setMorphTime=g=>{let _=g;g>this.duration?_=this.duration:0>g?_=0:_=g,_!=this.inbuildTime&&(this.inbuildTime=_,this.updateTimeTexture())},this.render=(g,_,A)=>{if(_==!0&&this.timeEnabled&&this.textureList.length>1){let N=this.inbuildTime+g;N>this.duration&&(N=N-this.duration),this.inbuildTime=N,this.updateTimeTexture()}}};Ee.prototype=Object.create(ke.prototype),Ee.prototype.constructor=Ee;const Ie=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 n=this;this.setFromObject=({nearPlane:e,farPlane:t,eyePosition:s,targetPosition:i,upVector:r})=>{n.nearPlane=e,n.farPlane=t,n.eyePosition=s,n.targetPosition=i,n.upVector=r}},Ht=function(n,e,t,s){const i={DEFAULT:0,PATH:1,SMOOTH_CAMERA_TRANSITION:2,AUTO_TUMBLE:3,MINIMAP:5,SYNC_CONTROL:6},r={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},u={};u.MAIN=r.ROTATE,u.AUXILIARY=r.ZOOM,u.SECONDARY=r.PAN,this.cameraObject=n,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,l=!0,c=0,d,h,p=!1,w=500,y,g="default",_=i.DEFAULT,A,N,I,D=0,F=o.FREE;this._state=r.NONE;let q;this.targetTouchId=-1;let G;const T=new S.Vector3,C=new S.Vector3,U=new S.Vector3,M=new S.Vector3,O=new S.Vector3,k=new S.Vector3,P=new S.Vector3,m=new S.Vector3,L=new S.Sphere,b=new S.Vector3;let B=!1,V,R=0;const z={default:new Ie};z.default.nearPlane=.1,z.default.farPlane=2e3,z.default.eyePosition=[0,0,0],z.default.targetPosition=[0,0,-1],z.default.upVector=[0,1,0],this.cameraObject.target===void 0&&(this.cameraObject.target=new S.Vector3(...z.default.targetPosition)),this.calculateMaxAllowedDistance=x=>{const j=x.getBoundingBox();if(j){j.getBoundingSphere(L),R=L.radius*6;let W=0;this.cameraObject&&(W=this.cameraObject.position.distanceTo(L.center)),R=W>R?W*1.5:R}else R=0};const Z=x=>{T.copy(this.cameraObject.position);const W=T.sub(this.cameraObject.target).length();this.cameraObject.near=Math.max(1e-4,W*.001),this.cameraObject.far=this.cameraObject.near*1e4};this.addViewport=(x,j)=>{x&&j&&(z[x]=j)},this.setDefaultViewport=x=>x&&x in z?(g=x,!0):!1,this.getDefaultViewport=()=>g,this.getViewportOfName=x=>z[x],this.setCurrentViewport=x=>x in z?(this.setCurrentCameraSettings(z[x]),!0):!1,this.setRotationMode=x=>{switch(x){case"none":F=o.NONE;break;case"horizontal":F=o.HORIZONTAL;break;case"vertical":F=o.VERTICAL;break;case"free":default:F=o.FREE}},this.onResize=()=>{G&&(G=void 0),V&&V.setCurrentCameraSettings(this.cameraObject,z[g])},this.getVisibleHeightAtZDepth=x=>{const j=this.cameraObject.position.distanceTo(this.cameraObject.target);x<j?x-=j:x+=j;const W=this.cameraObject.fov*Math.PI/180;return 2*Math.tan(W/2)*Math.abs(x)},this.calculateHeightPerPixelAtZeroDepth=x=>{const j=this.getVisibleHeightAtZDepth(0);return this.pixelHeight=j/x,this.pixelHeight},this.getNDCFromDocumentCoords=(x,j,W)=>{ie(!1);const X=W||new S.Vector2,he=(x-G.left)/G.width*2-1,le=-((j-G.top)/G.height)*2+1;return X.set(he,le)},this.getRelativeCoordsFromNDC=(x,j,W)=>{ie(!1);const X=W||new S.Vector2;return X.x=(x+1)*G.width/2,X.y=(1-j)*G.height/2,X},this.setMouseButtonAction=(x,j)=>{u[x]=r[j]};const E=(x,j)=>{x instanceof HTMLCanvasElement&&(x.tabIndex=j)},$=()=>{if(R>0){const x=b.distanceTo(L.center);return R>x||this.cameraObject.position.distanceTo(L.center)>x}return!0},H=x=>{b.copy(this.cameraObject.position).add(x),$()&&(this.cameraObject.target.add(x),this.cameraObject.position.add(x),this.updateDirectionalLight())},K=x=>{ie(!1);let j;if(_===i.DEFAULT&&(j=this.scene.getNormalisedMinimapCoordinates(this.renderer,x)),!j)x.button==0?x.ctrlKey?this._state=u.AUXILIARY:x.shiftKey?this._state=u.SECONDARY:this._state=u.MAIN:x.button==1?(x.preventDefault(),this._state=u.AUXILIARY):x.button==2&&(this._state=u.SECONDARY),this.pointer_x=x.clientX-G.left,this.pointer_y=x.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{_=i.MINIMAP;let W=this.scene.getMinimapDiffFromNormalised(j.x,j.y);H(W)}},ee=x=>{if(ie(!1),G)if(this.pointer_x=x.clientX-G.left,this.pointer_y=x.clientY-G.top,_===i.MINIMAP){let j=this.scene.getNormalisedMinimapCoordinates(this.renderer,x);if(j){let W=this.scene.getMinimapDiffFromNormalised(j.x,j.y);H(W)}}else this._state===r.NONE&&q!==void 0&&q.move(this,x.clientX,x.clientY,this.renderer)},re=x=>{this._state=r.NONE,_==i.MINIMAP&&(_=i.DEFAULT),q!==void 0&&this.pointer_x_start==x.clientX-G.left&&this.pointer_y_start==x.clientY-G.top&&q.pick(this,x.clientX,x.clientY,this.renderer)},Q=x=>{this._state=r.NONE},ue=x=>{ie(!1);const j=x.touches.length;if(j==1)this._state=r.TOUCH_ROTATE,this.pointer_x=x.touches[0].clientX-(G==null?void 0:G.left),this.pointer_y=x.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(j==2){this._state=r.TOUCH_ZOOM;const W=x.touches[0].clientX-x.touches[1].clientX,X=x.touches[0].clientY-x.touches[1].clientY;this.touchZoomDistanceEnd=this.touchZoomDistanceStart=Math.sqrt(W*W+X*X)}else j==3&&(this._state=r.TOUCH_PAN,this.targetTouchId=x.touches[0].identifier,this.pointer_x=x.touches[0].clientX-(G==null?void 0:G.left),this.pointer_y=x.touches[0].clientY-(G==null?void 0:G.top),this.previous_pointer_x=this.pointer_x,this.previous_pointer_y=this.pointer_y)},ne=x=>{x.preventDefault(),x.stopPropagation();const j=x.touches.length;if(j==1)this.pointer_x=x.touches[0].clientX-G.left,this.pointer_y=x.touches[0].clientY-G.top;else if(j==2){if(this._state===r.TOUCH_ZOOM){const W=x.touches[0].clientX-x.touches[1].clientX,X=x.touches[0].clientY-x.touches[1].clientY;this.touchZoomDistanceEnd=Math.sqrt(W*W+X*X)}}else if(j==3&&this._state===r.TOUCH_PAN)for(let W=0;W<3;W++)x.touches[W].identifier==this.targetTouchId&&(this.pointer_x=x.touches[0].clientX-G.left,this.pointer_y=x.touches[0].clientY-G.top)},te=x=>{const j=x.touches.length;this.touchZoomDistanceStart=this.touchZoomDistanceEnd=0,this.targetTouchId=-1,this._state=r.NONE,j==1&&q!==void 0&&this.pointer_x_start==x.touches[0].clientX-G.left&&this.pointer_y_start==x.touches[0].clientY-G.top&&q.pick(this.cameraObject,x.touches[0].clientX,x.touches[0].clientY,this.renderer)},J=()=>{ie(!0)},ie=x=>{if(x||G===void 0){const j=new IntersectionObserver(W=>{for(const X of W)G=X.boundingClientRect;j.disconnect()});j.observe(this.domElement)}},ae=x=>{ie(!1),this._state=r.SCROLL;let j=0;x.deltaY>0?j=this.zoomRate:x.deltaY<0&&(j=this.zoomRate*-1),D=D+j,x.preventDefault(),x.stopImmediatePropagation()},Le=x=>{ie(!1);let j=0;if(x.keyCode===a.EQUAL||x.keyCode===a.MINUS||x.keyCode===a.NUMPADADD||x.keyCode===a.NUMPADSUBTRACT){this._state=r.KEYBOARD_ZOOM;let W=1;x.shiftKey&&(W=W*2),x.keyCode===a.EQUAL||x.keyCode===a.NUMPADADD?j=this.zoomRate*W*-1:(x.keyCode===a.MINUS||x.keyCode===a.NUMPADSUBTRACT)&&(j=this.zoomRate*W),D=D+j}else(x.keyCode===a.ARROWLEFT||x.keyCode===a.ARROWUP||x.keyCode===a.ARROWRIGHT||x.keyCode===a.ARROWDOWN)&&(x.shiftKey?(this._state=r.KEYBOARD_ROTATE,this.pointer_x_start=this.pointer_x,this.pointer_y_start=this.pointer_y,j=this.rotateRate):(this._state=r.KEYBOARD_PAN,j=this.panRate),this.previous_pointer_x=this.pointer_x,this.previous_pointer_y=this.pointer_y,x.keyCode===a.ARROWLEFT?this.pointer_x=this.pointer_x-j:x.keyCode===a.ARROWUP?this.pointer_y=this.pointer_y-j:x.keyCode===a.ARROWRIGHT?this.pointer_x=this.pointer_x+j:x.keyCode===a.ARROWDOWN&&(this.pointer_y=this.pointer_y+j));Object.values(a).includes(x.keyCode)&&x.preventDefault()},oe=x=>{this._state=r.NONE},Ne=()=>{if(typeof this.cameraObject<"u"){const x=G.height,j=this.cameraObject.position.distanceTo(this.cameraObject.target);let W=0;this.cameraObject.far>this.cameraObject.near&&j>=this.cameraObject.near&&j<=this.cameraObject.far&&(W=(j-this.cameraObject.near)/(this.cameraObject.far-this.cameraObject.near)),C.set(this.previous_pointer_x,x-this.previous_pointer_y,0),U.set(this.previous_pointer_x,x-this.previous_pointer_y,1),M.set(this.pointer_x,x-this.pointer_y,0),O.set(this.pointer_x,x-this.pointer_y,1),C.unproject(this.cameraObject),U.unproject(this.cameraObject),M.unproject(this.cameraObject),O.unproject(this.cameraObject);const X=-.002;M.sub(C).multiplyScalar(1-W),O.sub(U).multiplyScalar(W),M.add(O).multiplyScalar(X),H(M)}this.previous_pointer_x=this.pointer_x,this.previous_pointer_y=this.pointer_y};this.getVectorsFromRotateAboutLookAtPoints=(x,j)=>{x.normalize(),P.copy(this.cameraObject.position).sub(this.cameraObject.target),m.copy(P),P.normalize(),.8<Math.abs(P.dot(x))&&P.copy(this.cameraObject.up),C.crossVectors(x,P).normalize(),U.crossVectors(x,C);const W=x.dot(m),X=C.dot(m),he=U.dot(m),le=x.dot(this.cameraObject.up),pe=C.dot(this.cameraObject.up),ce=U.dot(this.cameraObject.up),me=Math.cos(j),ve=Math.sin(j);return M.set(me*C.x+ve*U.x,me*C.y+ve*U.y,me*C.z+ve*U.z),O.set(me*U.x-ve*C.x,me*U.y-ve*C.y,me*U.z-ve*C.z),P.copy(this.cameraObject.target),P.x=P.x+x.x*W+M.x*X+O.x*he,P.y=P.y+x.y*W+M.y*X+O.y*he,P.z=P.z+x.z*W+M.z*X+O.z*he,T.set(x.x*le+M.x*pe+O.x*ce,x.y*le+M.y*pe+O.y*ce,x.z*le+M.z*pe+O.z*ce),{position:P,up:T}},this.rotateAboutLookAtpoint=(x,j)=>{const W=this.getVectorsFromRotateAboutLookAtPoints(x,j);this.cameraObject.position.copy(W.position),this.updateDirectionalLight(),this.cameraObject.up.copy(W.up)};const Ci=()=>{if(typeof this.cameraObject<"u"){const x=G==null?void 0:G.width,j=G==null?void 0:G.height;if(0<x&&0<j){const W=.25*(x+j);let X=0,he=0;(F===o.FREE||F===o.HORIZONTAL)&&(X=this.pointer_x-this.previous_pointer_x),(F===o.FREE||F===o.VERTICAL)&&(he=this.previous_pointer_y-this.pointer_y);const le=Math.sqrt(X*X+he*he);if(le>0){const pe=-he*1/le,ce=X*1/le;let me=0;F===o.FREE&&pe*(this.pointer_x-.5*(x-1))+ce*(.5*(j-1)-this.pointer_y);const ve=Math.acos(me/W)-.5*Math.PI,We=this.tumble_rate*le/W;T.copy(this.cameraObject.position).sub(this.cameraObject.target).normalize(),C.copy(this.cameraObject.up).normalize(),U.copy(C).cross(T).normalize().multiplyScalar(pe),C.multiplyScalar(ce),k.addVectors(U,C).multiplyScalar(Math.cos(ve)),T.multiplyScalar(Math.sin(ve)),k.add(T),this.rotateAboutLookAtpoint(k,-We)}}}this.previous_pointer_x=this.pointer_x,this.previous_pointer_y=this.pointer_y},Oi=()=>{let x=0;return this._state===r.ZOOM?x=this.previous_pointer_y-this.pointer_y:this._state===r.SCROLL||this._state===r.KEYBOARD_ZOOM?x=D:(x=-1*(this.touchZoomDistanceEnd-this.touchZoomDistanceStart),this.touchZoomDistanceStart=this.touchZoomDistanceEnd),x};this.changeZoomByScrollRateUnit=x=>{const j=x*this.zoomRate;this.changeZoomByValue(j)},this.changeZoomByValue=x=>{if(typeof this.cameraObject<"u"){const j=G.height,W=this.cameraObject.position.clone();W.sub(this.cameraObject.target);const X=W.length(),he=1.5*x/j,le=X*he;X+le>.01&&(W.normalize(),b.copy(this.cameraObject.position),b.x+=W.x*le,b.y+=W.y*le,b.z+=W.z*le,$()&&(this.cameraObject.position.copy(b),this.updateDirectionalLight(),Z(),B=!0))}};const Gs=()=>{const x=Oi();this.changeZoomByValue(x),this._state===r.ZOOM&&(this.previous_pointer_x=this.pointer_x,this.previous_pointer_y=this.pointer_y),(this._state===r.SCROLL||this._state===r.KEYBOARD_ZOOM)&&(D=0,this._state=r.NONE)};this.setDirectionalLight=x=>{this.directionalLight=x},this.updateDirectionalLight=()=>{this.directionalLight!=0&&this.directionalLight.position.set(this.cameraObject.position.x,this.cameraObject.position.y,this.cameraObject.position.z)},this.enable=function(){l=!0,this.domElement&&this.domElement.addEventListener&&(E(this.domElement,0),this.domElement.addEventListener("mousedown",K,!1),this.domElement.addEventListener("mousemove",ee,!1),this.domElement.addEventListener("mouseup",re,!1),this.domElement.addEventListener("mouseleave",Q,!1),this.domElement.addEventListener("touchstart",ue,!1),this.domElement.addEventListener("touchmove",ne,!1),this.domElement.addEventListener("touchend",te,!1),this.domElement.addEventListener("wheel",ae,!1),this.domElement.addEventListener("mouseenter",J,!1),this.domElement.addEventListener("contextmenu",x=>{x.preventDefault()},!1),this.domElement.addEventListener("keydown",Le,!1),this.domElement.addEventListener("keyup",oe,!1))},this.disable=function(){l=!1,this.domElement&&this.domElement.removeEventListener&&(this.domElement.removeEventListener("mousedown",K,!1),this.domElement.removeEventListener("mousemove",ee,!1),this.domElement.removeEventListener("mouseup",re,!1),this.domElement.removeEventListener("mouseleave",Q,!1),this.domElement.removeEventListener("touchstart",ue,!1),this.domElement.removeEventListener("touchmove",ne,!1),this.domElement.removeEventListener("touchend",te,!1),this.domElement.removeEventListener("wheel",ae,!1),this.domElement.removeEventListener("mouseenter",J,!1),this.domElement.removeEventListener("contextmenu",x=>{x.preventDefault()},!1),this.domElement.removeEventListener("keydown",Le,!1),this.domElement.removeEventListener("keyup",oe,!1),E(this.domElement,-1))},this.loadPath=x=>{d=x.CameraPath,h=x.NumberOfPoints},this.loadPathURL=(x,j)=>{const W=ye(x);fetch(W).then(X=>{if(!X.ok)throw new Error(`HTTP error! status: ${X.status}`);return X.json()}).then(X=>{this.loadPath(X),j!==void 0&&typeof j=="function"&&j()}).catch(X=>{console.error(`Failed to load path asset from: ${W}`,X)})},this.setPathDuration=x=>{f=x,A&&A.setDuration(f),N&&N.setDuration(f)},this.getPlayRate=()=>w,this.setPlayRate=x=>{w=x};const js=x=>{let j=c+x;j>f&&(j=j-f),c=j};this.getTime=()=>c,this.setTime=x=>{x>f?c=f:x<0?c=0:c=x},this.getNumberOfTimeFrame=()=>h,this.getCurrentTimeFrame=()=>{if(h>2){const x=c/f*(h-1),j=Math.floor(x),W=1-(x-j),X=Math.ceil(x);return j==X?j==h-1?[j-1,X,0]:[j,X+1,1]:[j,X,W]}else if(h==1)return[0,0,0]},this.setCurrentTimeFrame=x=>{h>2&&(c=f*x/(h-1),c<0&&(c=0),c>f&&(c=f))};const Ti=x=>{if(_===i.PATH&&(js(x),d)){const j=this.getCurrentTimeFrame(),W=j[0],X=j[1],he=j[2],le=[d[W*3],d[W*3+1],d[W*3+2]],pe=[d[X*3],d[X*3+1],d[X*3+2]],ce=[];for(let me=0;me<le.length;me++)ce.push(he*le[me]+(1-he)*pe[me]);this.cameraObject.position.set(ce[0],ce[1],ce[2]),this.cameraObject.target.set(pe[0],pe[1],pe[2]),y&&this.cameraObject.lookAt(this.cameraObject.target),p&&(this.directionalLight.position.set(ce[0],ce[1],ce[2]),this.directionalLight.target.position.set(pe[0],pe[1],pe[2]))}};this.calculatePathNow=()=>{Ti(0)};const Es=()=>{this._state===r.ROTATE||this._state===r.TOUCH_ROTATE||this._state===r.KEYBOARD_ROTATE?Ci():this._state===r.PAN||this._state===r.TOUCH_PAN||this._state===r.KEYBOARD_PAN?(Ne(),V.triggerCallback()):(this._state===r.ZOOM||this._state===r.TOUCH_ZOOM||this._state===r.SCROLL||this._state===r.KEYBOARD_ZOOM)&&(V.zoom(Oi()),this.previous_pointer_x=this.pointer_x,this.previous_pointer_y=this.pointer_y,(this._state===r.SCROLL||this._state===r.KEYBOARD_ZOOM)&&(this._state=r.NONE),D=0,V.triggerCallback())};this.update=x=>{const j=x*w;let W=l,X=!0;return _===i.PATH?Ti(j):_===i.SMOOTH_CAMERA_TRANSITION&&A?(A.update(j),A.isTransitionCompleted()&&(_=i.DEFAULT),W=!1):_===i.ROTATE_CAMERA_TRANSITION&&N?(N.update(j),N.isTransitionCompleted()&&(_=i.DEFAULT),W=!1):_===i.AUTO_TUMBLE&&I?I.update(j):_===i.SYNC_CONTROL&&V?(Es(),W=!1):X=!1,W&&(this._state!==r.NONE&&(X=!0),this._state===r.ROTATE||this._state===r.TOUCH_ROTATE||this._state===r.KEYBOARD_ROTATE?Ci():this._state===r.PAN||this._state===r.TOUCH_PAN||this._state===r.KEYBOARD_PAN?Ne():(this._state===r.ZOOM||this._state===r.TOUCH_ZOOM||this._state===r.SCROLL||this._state===r.KEYBOARD_ZOOM)&&Gs(),this._state!==r.NONE&&_===i.AUTO_TUMBLE&&I&&I.stopOnCameraInput,this._state===r.SCROLL&&(this._state=r.NONE)),y?(X=!0,y.update()):this.cameraObject.lookAt(this.cameraObject.target),X=X||B,B=!1,X},this.playPath=()=>{_=i.PATH},this.stopPath=()=>{_=i.DEFAULT},this.isPlayingPath=()=>_===i.PATH,this.enableDirectionalLightUpdateWithPath=x=>{p=x},this.enableDeviceOrientation=()=>{y||(y=new ss(this.cameraObject))},this.disableDeviceOrientation=()=>{y&&(y.dispose(),y=void 0)},this.isDeviceOrientationEnabled=()=>!!y,this.resetView=()=>{const x=z[g];this.cameraObject.near=x.nearPlane,this.cameraObject.far=x.farPlane,this.cameraObject.position.set(x.eyePosition[0],x.eyePosition[1],x.eyePosition[2]),this.cameraObject.target.set(x.targetPosition[0],x.targetPosition[1],x.targetPosition[2]),this.cameraObject.up.set(x.upVector[0],x.upVector[1],x.upVector[2]),this.cameraObject.updateProjectionMatrix(),this.updateDirectionalLight()},this.setCurrentCameraSettings=x=>{x.nearPlane&&(this.cameraObject.near=x.nearPlane),x.farPlane&&(this.cameraObject.far=x.farPlane),x.eyePosition&&this.cameraObject.position.set(x.eyePosition[0],x.eyePosition[1],x.eyePosition[2]),x.targetPosition&&this.cameraObject.target.set(x.targetPosition[0],x.targetPosition[1],x.targetPosition[2]),x.upVector&&this.cameraObject.up.set(x.upVector[0],x.upVector[1],x.upVector[2]),this.cameraObject.updateProjectionMatrix(),this.updateDirectionalLight(),B=!0},this.getViewportFromCentreAndRadius=(x,j,W,X,he,le)=>{T.copy(this.cameraObject.position),T.sub(this.cameraObject.target),T.normalize();const pe=[x,j,W],ce=X/Math.tan(he*Math.PI/360),me=[x+T.x*ce,j+T.y*ce,W+T.z*ce],ve=ce+le;let We=0;const Li=.95;le>Li*ce?We=(1-Li)*ce:We=ce-le;const Re=new Ie;return Re.nearPlane=We,Re.farPlane=ve,Re.eyePosition=me,Re.targetPosition=pe,Re.upVector=[this.cameraObject.up.x,this.cameraObject.up.y,this.cameraObject.up.z],Re},this.getViewportFromBoundingBox=(x,j)=>{const W=x.min.distanceTo(x.max)/2*j,X=(x.min.x+x.max.x)/2,he=(x.min.y+x.max.y)/2,le=(x.min.z+x.max.z)/2;return this.getViewportFromCentreAndRadius(X,he,le,W,40,W*4)},this.getCurrentViewport=()=>{const x=new Ie;return x.nearPlane=this.cameraObject.near,x.farPlane=this.cameraObject.far,x.eyePosition[0]=this.cameraObject.position.x,x.eyePosition[1]=this.cameraObject.position.y,x.eyePosition[2]=this.cameraObject.position.z,x.targetPosition[0]=this.cameraObject.target.x,x.targetPosition[1]=this.cameraObject.target.y,x.targetPosition[2]=this.cameraObject.target.z,x.upVector[0]=this.cameraObject.up.x,x.upVector[1]=this.cameraObject.up.y,x.upVector[2]=this.cameraObject.up.z,x},this.getDefaultEyePosition=()=>eyePosition,this.getDefaultTargetPosition=()=>targetPosition,this.cameraTransition=(x,j,W)=>{N==null&&(A=new ei(x,j,this,W))},this.rotateCameraTransition=(x,j,W)=>{A==null&&(N=new is(x,j,this,W))},this.enableCameraTransition=()=>{A&&(_=i.SMOOTH_CAMERA_TRANSITION),N&&(_=i.ROTATE_CAMERA_TRANSITION)},this.pauseCameraTransition=()=>{_=i.DEFAULT},this.stopCameraTransition=()=>{_=i.DEFAULT,A=void 0,N=void 0},this.isTransitioningCamera=()=>_===i.SMOOTH_CAMERA_TRANSITION||_===i.ROTATE_CAMERA_TRANSITION,this.autoTumble=(x,j,W)=>{I=new ii(x,j,W,this)},this.enableAutoTumble=()=>{_=i.AUTO_TUMBLE},this.stopAutoTumble=()=>{_=i.DEFAULT,I=void 0},this.updateAutoTumble=()=>{I&&(I.requireUpdate=!0)},this.isAutoTumble=()=>_===i.AUTO_TUMBLE,this.enableRaycaster=(x,j,W)=>{q==null&&(q=new ti(x,this.scene,j,W,this.renderer))},this.disableRaycaster=()=>{q.disable(),q=void 0},this.isSyncControl=()=>currentMpde===i.SYNC_CONTROL,this.enableSyncControl=()=>(_=i.SYNC_CONTROL,V||(V=new rs),V.setCurrentCameraSettings(this.cameraObject,z[g]),V),this.disableSyncControl=()=>{_=i.DEFAULT,this.cameraObject.zoom=1,this.cameraObject.updateProjectionMatrix()},this.enable()},ei=function(n,e,t,s){const i=n.eyePosition,r=n.targetPosition,o=n.upVector,a=e.eyePosition,u=e.targetPosition,f=e.upVector,l=t;let c=s,d=0,h=!1;l.near=Math.min(n.nearPlane,e.nearPlane),l.far=Math.max(n.farPlane,e.farPlane),l.cameraObject.up.set(e.upVector[0],e.upVector[1],e.upVector[2]),this.setDuration=y=>{c=y};const p=y=>{let g=d+y;g>c&&(g=c),d=g},w=()=>{const y=d/c,g=[i[0]*(1-y)+a[0]*y,i[1]*(1-y)+a[1]*y,i[2]*(1-y)+a[2]*y],_=[r[0]*(1-y)+u[0]*y,r[1]*(1-y)+u[1]*y,r[2]*(1-y)+u[2]*y];o[0]*(1-y)+f[0]*y,o[1]*(1-y)+f[1]*y,o[2]*(1-y)+f[2]*y,l.cameraObject.position.set(g[0],g[1],g[2]),l.cameraObject.target.set(_[0],_[1],_[2])};this.update=y=>{this.enabled!==!1&&(p(y),w(),d==c&&(h=!0))},this.isTransitionCompleted=()=>h},is=function(n,e,t,s){const i=n,r=e,o=t;let a=s,u=0,f=!1;this.setDuration=c=>{a=c};const l=c=>{const d=u;let h=u+c;h>a&&(h=a),u=h;const y=(u-d)/a*r;o.rotateAboutLookAtpoint(i,y)};this.update=c=>{this.enabled!==!1&&(l(c),u==a&&(f=!0))},this.isTransitionCompleted=()=>f},ti=function(n,e,t,s,i){const r=n,o=e,a=i,u=t,f=s;let l=!0;const c=new S.Raycaster;c.params.Line.threshold=.1,c.params.Points.threshold=1;const d=new S.Vector2;let h=!1,p=new Date,w=!1,y=0,g=new Array,_={zincCamera:void 0,x:-1,y:-1},A;this.enable=()=>{l=!0},this.disable=()=>{l=!1},this.getIntersectsObject=D=>{if(o!==r){const q=r.getThreeJSScene();a.render(q,D.cameraObject)}let F=A||r.getPickableThreeJSObjects();return g.length=0,c.intersectObjects(F,!0,g)},this.setPickableObjects=D=>{D===void 0?A=void 0:(A=[],D.forEach(F=>{F.getGroup()&&F.getGroup().visible&&A.push(F.getGroup())}))},this.getIntersectsObjectWithOrigin=(D,F,q)=>(c.set(F,q),this.getIntersectsObject(D)),this.getIntersectsObjectWithCamera=(D,F,q)=>(D.getNDCFromDocumentCoords(F,q,d),c.setFromCamera(d,D.cameraObject),this.getIntersectsObject(D)),this.pick=(D,F,q)=>{if(l&&a&&r&&D&&u){this.getIntersectsObjectWithCamera(D,F,q);const G=g.length;for(let T=0;T<G;T++){let C=g[T].object?g[T].object.userData:void 0;if(C&&C.isMarkerCluster&&C.visible&&C.clusterIsVisible(g[T].object.clusterIndex)&&C.zoomToCluster(g[T].object.clusterIndex))return}u(g,F,q)}};let N=(D,F,q)=>{if(l&&a&&r&&D&&f){if(this.getIntersectsObjectWithCamera(D,F,q),p.setTime(Date.now()),g.length===0){if(w)return;w=!0}else w=!1;f(g,F,q)}};this.move=(D,F,q)=>{l&&a&&r&&D&&f&&(r.displayMarkers?N(D,F,q):(_.zincCamera=D,_.x=F,_.y=q,h||(y=p?Date.now()-p.getTime():250,y>=250?N(D,F,q):(h=!0,setTimeout(I(_),y)))))};let I=D=>function(){h=!1,N(D.zincCamera,D.x,D.y)}},ii=function(n,e,t,s){const i=new S.Vector3,r=-e,o=s,a=n;this.stopOnCameraInput=t,this.requireUpdate=!0;const u=new S.Vector3,f=new S.Vector3,l=c=>{const d=Math.sqrt(c[0]*c[0]+c[1]*c[1]),h=Math.abs(c[0])*4,p=Math.abs(c[1])*4,w=.25*(h+p),y=-c[1]/d,g=c[0]/d;let _=y*c[0]+g*-c[1];_>w?_=w:_<-w&&(_=-w);const A=Math.acos(_/w)-.5*Math.PI;i.copy(o.cameraObject.position).sub(o.cameraObject.target).normalize(),u.copy(o.cameraObject.up).normalize(),f.crossVectors(u,i).normalize().multiplyScalar(y),u.multiplyScalar(g),u.add(f).multiplyScalar(Math.cos(A)),i.multiplyScalar(Math.sin(A)).add(u)};this.update=c=>{this.enabled!==!1&&(this.requireUpdate&&(l(a),this.requireUpdate=!1),o.rotateAboutLookAtpoint(i,r*c/1e3))}},si=function(){this.type="StereoCamera",this.aspect=1,this.cameraL=new S.PerspectiveCamera,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new S.PerspectiveCamera,this.cameraR.layers.enable(2),this.cameraR.matrixAutoUpdate=!1};Object.assign(si.prototype,{update:(()=>{let n,e,t,s,i,r;const o=new S.Matrix4,a=new S.Matrix4;return function(f){if(n!==f.focus||e!==f.fov||t!==f.aspect*this.aspect||s!==f.near||i!==f.far||r!==f.zoom){n=f.focus,e=f.fov,t=f.aspect*this.aspect,s=f.near,i=f.far,r=f.zoom;const c=f.projectionMatrix.clone(),d=.064/2,h=d*s/n,p=s*Math.tan(S.Math.DEG2RAD*e*.5)/f.zoom;let w,y;a.elements[12]=-d,o.elements[12]=d,w=-p*t+h,y=p*t+h,c.elements[0]=2*s/(y-w),c.elements[8]=(y+w)/(y-w),this.cameraL.projectionMatrix.copy(c),w=-p*t-h,y=p*t-h,c.elements[0]=2*s/(y-w),c.elements[8]=(y+w)/(y-w),this.cameraR.projectionMatrix.copy(c)}this.cameraL.matrixWorld.copy(f.matrixWorld).multiply(a),this.cameraR.matrixWorld.copy(f.matrixWorld).multiply(o)}})()});const ri=function(n){const e=new si;e.aspect=.5,this.setSize=(t,s)=>{n.setSize(t,s)},this.render=(t,s)=>{t.updateMatrixWorld(),s.parent===null&&s.updateMatrixWorld(),e.update(s);const i=n.getSize();n.setScissorTest(!0),n.clear(),n.setScissor(0,0,i.width/2,i.height),n.setViewport(0,0,i.width/2,i.height),n.render(t,e.cameraL),n.setScissor(i.width/2,0,i.width/2,i.height),n.setViewport(i.width/2,0,i.width/2,i.height),n.render(t,e.cameraR),n.setScissorTest(!1)}},ss=function(n){const e=this;this.object=n,this.object.rotation.reorder("YXZ"),this.enabled=!0,this.deviceOrientation={},this.screenOrientation=0;const t=r=>{e.deviceOrientation=r},s=()=>{typeof window<"u"&&(e.screenOrientation=window.orientation||0)},i=(()=>{const r=new S.Vector3(0,0,1),o=new S.Euler,a=new S.Quaternion,u=new S.Quaternion(-Math.sqrt(.5),0,0,Math.sqrt(.5));return(f,l,c,d,h)=>{const p=new S.Vector3(0,0,1);p.subVectors(f.target,f.position),o.set(c,l,-d,"YXZ");const w=new S.Quaternion;w.setFromEuler(o),w.multiply(u),w.multiply(a.setFromAxisAngle(r,-h)),p.applyQuaternion(w),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 r=e.deviceOrientation.alpha?S.Math.degToRad(e.deviceOrientation.alpha):0,o=e.deviceOrientation.beta?S.Math.degToRad(e.deviceOrientation.beta):0,a=e.deviceOrientation.gamma?S.Math.degToRad(e.deviceOrientation.gamma):0,u=e.screenOrientation?S.Math.degToRad(e.screenOrientation):0;i(e.object,r,o,a,u)},this.dispose=function(){this.disconnect()},this.connect()},rs=function(){let n,e,t;const s=new S.Vector3,i=new S.Vector3,r=new S.Vector3,o=new S.Vector3;let a;this.setCurrentCameraSettings=(u,f)=>{this.near_plane_fly_debt==0,n=u.clone(),e=u,t=f,n.near=t.nearPlane,t.farPlane&&(n.far=t.farPlane),t.eyePosition&&n.position.set(t.eyePosition[0],t.eyePosition[1],t.eyePosition[2]),t.upVector&&n.up.set(t.upVector[0],t.upVector[1],t.upVector[2]),t.targetPosition&&(n.target=new S.Vector3(t.targetPosition[0],t.targetPosition[1],t.targetPosition[2]),n.lookAt(n.target)),n.updateProjectionMatrix(),s.copy(n.position).project(n),i.copy(n.target).project(n)},this.getCurrentPosition=()=>(i.copy(e.target).project(n),[i.x,i.y]),this.zoom=u=>{let f=u*.002,l=Math.max(e.zoom-f,1);e.zoom=l,e.updateProjectionMatrix()},this.zoomToBox=(u,f)=>{u.getCenter(r),r.project(n),this.setCenterZoom([r.x,r.y],f)},this.getPanZoom=()=>({target:this.getCurrentPosition(),zoom:e.zoom}),this.setCenterZoom=(u,f)=>{r.set(u[0],u[1],i.z).unproject(n),o.copy(r).sub(e.target),e.target.copy(r),e.lookAt(e.target),e.position.add(o),e.zoom=f,e.updateProjectionMatrix()},this.setEventCallback=u=>{(u===void 0||typeof u=="function")&&(a=u)},this.triggerCallback=()=>{a!==void 0&&typeof a=="function"&&a()}},ns="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",ni=new Image(128,128);ni.src=ns;const et=new S.Texture;et.image=ni,et.needsUpdate=!0;const bt=[.02,.03,1],os=new S.SpriteMaterial({map:et,alphaTest:.5,transparent:!0,depthTest:!1,depthWrite:!1,sizeAttenuation:!1}),oi=function(n){Y.call(this),this.texture=et;let e,t=n;this.morph=new S.Group,this.group=this.morph,this.isMarkerCluster=!0;let s=!0,i=[];this.markers={};let r=new S.Vector2,o=new S.Vector2,a=.1,u=Date.now();this.setSpriteSize=h=>{e.scale.set(.015,.02,1),e.scale.multiplyScalar(h)},this.clear=()=>{this.group.clear(),this.markers={}},this.dispose=()=>{this.clear(),this.morph&&this.morph.clear()};const f=h=>{const p=new S.Group,w=new S.Sprite(os);return w.clusterIndex=h,w.center.set(.5,0),w.position.set(0,0,0),w.renderOrder=1e4,w.scale.set(bt[0],bt[1],bt[2]),w.userData=this,p.add(w),this.group.add(p),{group:p,marker:w,label:void 0,number:0,min:[0,0,0],max:[1,1,1]}},l=(h,p,w)=>{h.group.visible=!0,h.group.position.set(p.coords[0],p.coords[1],p.coords[2]),(h.label===void 0||w!==h.number)&&(h.label&&(h.group.remove(h.label),h.label.material.map.dispose(),h.label.material.dispose()),h.label=ot(w,.012,"black","Asap",120,700),h.number=w,h.group.add(h.label)),h.min=p.min,h.max=p.max},c=h=>{let p=0;for(h.forEach(w=>{const y=w.members.length;let g=0;y===1?w.members[0].setVisibility(!0):(w.members.forEach(_=>{g+=_.getNumber(),_.setVisibility(!1)}),i[p]||i.push(f(p)),l(i[p],w,g),p++)}),p;p<i.length;p++)i[p].group.visible=!1},d=(h,p)=>{let w=!0,y={members:[],coords:[0,0,0],min:[0,0,0],max:[1,1,1]},g=0;for(let _ in h)w?(r.set(h[_].ndc.x,h[_].ndc.y),this._b1.setFromPoints([h[_].morph.position]),w=!1,y.members.push(h[_]),y.coords=[h[_].morph.position.x,h[_].morph.position.y,h[_].morph.position.z],p.push(y),delete h[_]):(o.set(h[_].ndc.x,h[_].ndc.y),g=r.distanceTo(o),a>g&&(y.members.push(h[_]),this._b1.expandByPoint(h[_].morph.position),delete h[_]));y.min=[this._b1.min.x,this._b1.min.y,this._b1.min.z],y.max=[this._b1.max.x,this._b1.max.y,this._b1.max.z],w!==!0&&d(h,p)};this.calculate=()=>{if(s&&Date.now()-u>500){let p=[];d({...this.markers},p),c(p),u=Date.now(),this.markerUpdateRequired=!1}},this.isEnabled=()=>s,this.enable=()=>{s=!0,this.morph.visible=!0},this.disable=()=>{var h;s=!1,this.morph.visible=!1;for(let p in this.markers)(h=this.markers[p])!=null&&h.isMarker&&this.markers[p].isEnabled()&&this.markers[p].setVisibility(!0)},this.zoomToCluster=h=>h!==void 0&&h>-1&&(this._v1.set(...i[h].min),this._v2.set(...i[h].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=h=>{var p;return h!==void 0&&h>-1&&i[h]?(p=i[h].group)==null?void 0:p.visible:!1}};oi.prototype=Object.create(Y.prototype);const as=function(n){let e=n;this.camera=new S.OrthographicCamera(-.5,.5,.5,-.5,.01,10),this.helper=void 0;let t=new S.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 S.BufferAttribute(s,3);t.setAttribute("position",i);var r=new S.MeshBasicMaterial({color:3355443,depthTest:!1,depthWrite:!1,opacity:.5,transparent:!0});this.mask=new S.Mesh(t,r);let o=new S.Box3,a=new S.Vector3;this.getDiffFromNormalised=(f,l)=>{o.setFromBufferAttribute(i).getCenter(a);let c=a.clone().project(this.camera);return new S.Vector3(f,l,c.z).unproject(this.camera).sub(a)};let u=(f,l)=>{e.camera.near&&(this.camera.near=e.camera.near),l.farPlane&&(this.camera.far=l.farPlane),l.eyePosition&&this.camera.position.set(l.eyePosition[0],l.eyePosition[1],l.eyePosition[2]),l.upVector&&this.camera.up.set(l.upVector[0],l.upVector[1],l.upVector[2]),l.targetPosition&&this.camera.lookAt(new S.Vector3(l.targetPosition[0],l.targetPosition[1],l.targetPosition[2])),this.camera.zoom=1/f,this.camera.updateProjectionMatrix()};this.getBoundary=()=>{let f=new S.Vector3().copy(e.camera.target).project(e.camera),l=new S.Vector3(-1,-1,f.z).unproject(e.camera),c=new S.Vector3(1,-1,f.z).unproject(e.camera),d=new S.Vector3(1,1,f.z).unproject(e.camera),h=new S.Vector3(-1,1,f.z).unproject(e.camera),p=[l,c,d,d,h,l];i.copyVector3sArray(p),i.needsUpdate=!0},this.updateCamera=()=>{this.getBoundary();let f=e.getZincCameraControls(),l=e.getBoundingBox();if(l){const c=l.min.distanceTo(l.max),d=c/2,h=(l.min.x+l.max.x)/2,p=(l.min.y+l.max.y)/2,w=(l.min.z+l.max.z)/2,g=f.getViewportFromCentreAndRadius(h,p,w,d,40,d*4);u(c,g)}}},ai=new v.Box3,tt=new v.Vector3;class xt extends v.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 v.Float32BufferAttribute(e,3)),this.setAttribute("uv",new v.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 v.InstancedInterleavedBuffer(t,6,1);return this.setAttribute("instanceStart",new v.InterleavedBufferAttribute(s,3,0)),this.setAttribute("instanceEnd",new v.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 v.InstancedInterleavedBuffer(t,6,1);return this.setAttribute("instanceColorStart",new v.InterleavedBufferAttribute(s,3,0)),this.setAttribute("instanceColorEnd",new v.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 v.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 v.Box3);const e=this.attributes.instanceStart,t=this.attributes.instanceEnd;e!==void 0&&t!==void 0&&(this.boundingBox.setFromBufferAttribute(e),ai.setFromBufferAttribute(t),this.boundingBox.union(ai))}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new v.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 r=0,o=e.count;r<o;r++)tt.fromBufferAttribute(e,r),i=Math.max(i,s.distanceToSquared(tt)),tt.fromBufferAttribute(t,r),i=Math.max(i,s.distanceToSquared(tt));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)}}xt.prototype.isLineSegmentsGeometry=!0,v.UniformsLib.line={linewidth:{value:1},resolution:{value:new v.Vector2(1,1)},dashScale:{value:1},dashSize:{value:1},dashOffset:{value:0},gapSize:{value:1},opacity:{value:1}},v.ShaderLib.line={uniforms:v.UniformsUtils.merge([v.UniformsLib.common,v.UniformsLib.fog,v.UniformsLib.line]),vertexShader:`
|
|
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:`
|
|
69
69
|
#include <common>
|
|
70
70
|
#include <color_pars_vertex>
|
|
71
71
|
#include <fog_pars_vertex>
|
|
@@ -284,9 +284,62 @@ void main() {
|
|
|
284
284
|
#include <fog_fragment>
|
|
285
285
|
#include <premultiplied_alpha_fragment>
|
|
286
286
|
|
|
287
|
-
}`};class vt extends v.ShaderMaterial{constructor(e){super({type:"LineMaterial",uniforms:v.UniformsUtils.clone(v.ShaderLib.line.uniforms),vertexShader:v.ShaderLib.line.vertexShader,fragmentShader:v.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)}}vt.prototype.isLineMaterial=!0;const li=new v.Vector3,ci=new v.Vector3,de=new v.Vector4,fe=new v.Vector4,Me=new v.Vector4,wt=new v.Vector3,At=new v.Matrix4,be=new v.Line3,hi=new v.Vector3,Ce=new v.Box3,it=new v.Sphere,_e=new v.Vector4;class ui extends v.Mesh{constructor(e=new xt,t=new vt({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,u=t.count;o<u;o++,a+=2)li.fromBufferAttribute(t,o),ci.fromBufferAttribute(s,o),i[a]=a===0?0:i[a-1],i[a+1]=i[a]+li.distanceTo(ci);const r=new v.InstancedInterleavedBuffer(i,2,1);return e.setAttribute("instanceDistanceStart",new v.InterleavedBufferAttribute(r,1,0)),e.setAttribute("instanceDistanceEnd",new v.InterleavedBufferAttribute(r,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,r=e.camera,o=r.projectionMatrix,a=this.matrixWorld,u=this.geometry,f=this.material,l=f.resolution,c=f.linewidth+s,d=u.attributes.instanceStart,h=u.attributes.instanceEnd,p=-r.near,w=2*Math.max(c/l.width,c/l.height);u.boundingSphere===null&&u.computeBoundingSphere(),it.copy(u.boundingSphere).applyMatrix4(a);const y=Math.max(r.near,it.distanceToPoint(i.origin));_e.set(0,0,-y,1).applyMatrix4(r.projectionMatrix),_e.multiplyScalar(1/_e.w),_e.applyMatrix4(r.projectionMatrixInverse);const g=Math.abs(w/_e.w)*.5;if(it.radius+=g,e.ray.intersectsSphere(it)===!1)return;u.boundingBox===null&&u.computeBoundingBox(),Ce.copy(u.boundingBox).applyMatrix4(a);const _=Math.max(r.near,Ce.distanceToPoint(i.origin));_e.set(0,0,-_,1).applyMatrix4(r.projectionMatrix),_e.multiplyScalar(1/_e.w),_e.applyMatrix4(r.projectionMatrixInverse);const A=Math.abs(w/_e.w)*.5;if(Ce.max.x+=A,Ce.max.y+=A,Ce.max.z+=A,Ce.min.x-=A,Ce.min.y-=A,Ce.min.z-=A,e.ray.intersectsBox(Ce)!==!1){i.at(1,Me),Me.w=1,Me.applyMatrix4(r.matrixWorldInverse),Me.applyMatrix4(o),Me.multiplyScalar(1/Me.w),Me.x*=l.x/2,Me.y*=l.y/2,Me.z=0,wt.copy(Me),At.multiplyMatrices(r.matrixWorldInverse,a);for(let I=0,D=d.count;I<D;I++){de.fromBufferAttribute(d,I),fe.fromBufferAttribute(h,I),de.w=1,fe.w=1,de.applyMatrix4(At),fe.applyMatrix4(At);var N=de.z>p&&fe.z>p;if(N)continue;if(de.z>p){const C=de.z-fe.z,U=(de.z-p)/C;de.lerp(fe,U)}else if(fe.z>p){const C=fe.z-de.z,U=(fe.z-p)/C;fe.lerp(de,U)}de.applyMatrix4(o),fe.applyMatrix4(o),de.multiplyScalar(1/de.w),fe.multiplyScalar(1/fe.w),de.x*=l.x/2,de.y*=l.y/2,fe.x*=l.x/2,fe.y*=l.y/2,be.start.copy(de),be.start.z=0,be.end.copy(fe),be.end.z=0;const F=be.closestPointToPointParameter(wt,!0);be.at(F,hi);const q=v.MathUtils.lerp(de.z,fe.z,F),G=q>=-1&&q<=1,T=wt.distanceTo(hi)<c*.5;if(G&&T){be.start.fromBufferAttribute(d,I),be.end.fromBufferAttribute(h,I),be.start.applyMatrix4(a),be.end.applyMatrix4(a);const C=new v.Vector3,U=new v.Vector3;i.distanceSqToSegment(be.start,be.end,U,C),t.push({point:U,pointOnLine:C,distance:i.origin.distanceTo(U),object:this,face:null,faceIndex:I,uv:null,uv2:null})}}}}}ui.prototype.LineSegments2=!0;const st=function(){Ve.call(this),this.isLines2=!0;let n=new Array(300);this.createLineSegment=(e,t,s)=>{if(e&&t){const i=new xt;i.setPositions(e),i.colorsNeedUpdate=!0;const r=new ui(i,t);r.scale.set(1,1,1),r.computeLineDistances(),this.setMesh(r,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=>{n[s++]=i[0],n[s++]=i[1],n[s++]=i[2],this.drawRange++}),!t)for(;s<300;)n[s++]=e[0][0],n[s++]=e[0][1],n[s++]=e[0][2];t&&(t.geometry.setPositions(n),t.computeLineDistances(),t.geometry.computeBoundingBox(),t.geometry.computeBoundingSphere(),this.boundingBoxUpdateRequired=!0)}return n},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 r=t*3;for(e.forEach(o=>{n[r++]=o[0],n[r++]=o[1],n[r++]=o[2]}),r=this.drawRange*3;r<300;)n[r++]=e[0][0],n[r++]=e[0][1],n[r++]=e[0][2];s.geometry.setPositions(n),s.computeLineDistances(),s.geometry.computeBoundingBox(),s.geometry.computeBoundingSphere(),this.boundingBoxUpdateRequired=!0}}return n},this.addLines=(e,t)=>{if(e&&e.length>0){if(this.addVertices(e),!this.getMorph()){const i=new vt({color:t,linewidth:1,vertexColors:!1,worldUnits:!1});i.resolution.set(window.innerWidth,window.innerHeight);const r={localTimeEnabled:!1,localMorphColour:!1};this.createLineSegment(n,i,r)}this.region&&(this.region.pickableUpdateRequired=!0)}},this.render=(e,t,s,i)=>{this.getMorph().material.resolution.set(window.innerWidth,window.innerHeight)}};st.prototype=Object.create(Ve.prototype),st.prototype.constructor=st;let ls=0;const cs=function(){return"re"+ls++};let di=function(n,e){let t=n,s=new S.Group;s.matrixAutoUpdate=!1,s.userData=this;let i=[],r="",o=[],a=e;const u=new S.Matrix4;let f=3e3;u.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(l=>l.hideAllPrimitives()),o.forEach(l=>l.setVisibility(!1))},this.showAllPrimitives=()=>{i.forEach(l=>l.showAllPrimitives()),o.forEach(l=>l.setVisibility(!0))},this.setVisibility=l=>{l!=s.visible&&(s.visible=l,this.pickableUpdateRequired=!0)},this.getVisibility=()=>s.visible,this.getGroup=()=>s,this.setTransformation=l=>{u.set(...l),s.matrix.copy(u),s.updateMatrixWorld()},this.setName=l=>{l&&l!==""&&(r=l)},this.getName=()=>r,this.getParent=()=>t,this.getFullSeparatedPath=()=>{const l=[];if(r!==""){l.push(r);for(let c=t;c!==void 0;){const d=c.getName();d!==""&&l.unshift(d),c=c.getParent()}}return l},this.getFullPath=()=>{const l=this.getFullSeparatedPath();if(l.length>0){let c=l.shift();return l.forEach(d=>{c=c.concat("/",d)}),c}return""},this.createChild=l=>{let c=new di(this,a);return c.setName(l),i.push(c),s.add(c.getGroup()),c},this.getChildWithName=l=>{if(l){const c=l.toLowerCase();for(let d=0;d<i.length;d++)if(i[d].getName().toLowerCase()===c)return i[d]}},this.findChildFromSeparatedPath=l=>{if(l&&l.length>0&&l[0]===""&&l.shift(),l&&l.length>0){const c=this.getChildWithName(l[0]);return c?(l.shift(),c.findChildFromSeparatedPath(l)):void 0}return this},this.findChildFromPath=l=>{const c=l.split("/");return this.findChildFromSeparatedPath(c)},this.createChildFromSeparatedPath=l=>{if(l.length>0&&l[0]===""&&l.shift(),l.length>0){let c=this.getChildWithName(l[0]);return c||(c=this.createChild(l[0])),l.shift(),c.createChildFromSeparatedPath(l)}return this},this.createChildFromPath=l=>{const c=l.split("/");return this.createChildFromSeparatedPath(c)},this.findOrCreateChildFromPath=l=>{let c=this.findChildFromPath(l);return c||(c=this.createChildFromPath(l)),c},this.addZincObject=l=>{l&&(l.setRegion(this),s.add(l.getGroup()),o.push(l),this.pickableUpdateRequired=!0,a&&a.triggerObjectAddedCallback(l))},this.removeZincObject=l=>{for(let c=0;c<o.length;c++)if(l===o[c]){s.remove(l.getGroup()),o.splice(c,1),a&&a.triggerObjectRemovedCallback(l),l.dispose(),this.pickableUpdateRequired=!0;return}},this.checkPickableUpdateRequred=l=>{if(this.pickableUpdateRequired)return!0;if(l){let c=!1;for(let d=0;d<i.length;d++)if(c=i[d].checkPickableUpdateRequred(l),c)return!0}return!1},this.getPickableThreeJSObjects=(l,c)=>(s.visible&&(o.forEach(d=>{if(d.isPickable&&d.getGroup()&&d.getGroup().visible){let h=d.marker;h&&h.isEnabled()&&l.push(h.getMorph()),l.push(d.getGroup())}}),c&&i.forEach(d=>{d.getPickableThreeJSObjects(l,c)}),this.pickableUpdateRequired=!1),l),this.setDuration=l=>{f=l,o.forEach(c=>c.setDuration(l)),i.forEach(c=>c.setDuration(l))},this.getDuration=()=>f,this.getBoundingBox=l=>{let c,d;return o.forEach(h=>{d=h.getBoundingBox(),d&&(c==null?c=d.clone():c.union(d))}),l&&i.forEach(h=>{d=h.getBoundingBox(l),d&&(c==null?c=d.clone():c.union(d))}),c},this.clear=l=>{l&&i.forEach(c=>c.clear(l)),o.forEach(c=>{s.remove(c.getGroup()),c.dispose()}),i=[],o=[]},this.objectIsInRegion=(l,c)=>{for(let d=0;d<o.length;d++)if(l===o[d])return!0;if(c){for(let d=0;d<i.length;d++)if(i[d].objectIsInRegion(l,c))return!0}return!1},this.forEachGeometry=(l,c)=>{o.forEach(d=>{d.isGeometry&&l(d)}),c&&i.forEach(d=>d.forEachGeometry(l,c))},this.forEachGlyphset=(l,c)=>{o.forEach(d=>{d.isGlyphset&&l(d)}),c&&i.forEach(d=>d.forEachGlyphset(l,c))},this.forEachPointset=(l,c)=>{o.forEach(d=>{d.isPointset&&l(d)}),c&&i.forEach(d=>d.forEachPointset(l,c))},this.forEachLine=(l,c)=>{o.forEach(d=>{d.isLines&&l(d)}),c&&i.forEach(d=>d.forEachLine(l,c))},this.findObjectsWithAnatomicalId=(l,c)=>{const d=[];return o.forEach(h=>{h.anatomicalId===l&&d.push(h)}),c&&i.forEach(h=>{let p=h.findObjectsWithAnatomicalId(l,c);d.push(...p)}),d},this.findObjectsWithGroupName=(l,c)=>{const d=[];return o.forEach(h=>{const p=h.groupName?h.groupName.toLowerCase():h.groupName,w=l&&l.toLowerCase();p===w&&d.push(h)}),c&&i.forEach(h=>{let p=h.findObjectsWithGroupName(l,c);d.push(...p)}),d},this.findGeometriesWithGroupName=(l,c)=>this.findObjectsWithGroupName(l,c).filter(p=>p.isGeometry),this.findPointsetsWithGroupName=(l,c)=>this.findObjectsWithGroupName(l,c).filter(p=>p.isPointset),this.findGlyphsetsWithGroupName=(l,c)=>this.findObjectsWithGroupName(l,c).filter(p=>p.isGlyphset),this.findLinesWithGroupName=(l,c)=>this.findObjectsWithGroupName(l,c).filter(p=>p.isLines),this.getAllObjects=l=>{const c=[...o];return l&&i.forEach(d=>{let h=d.getAllObjects(l);c.push(...h)}),c},this.getChildRegions=l=>{const c=[...i];return l&&i.forEach(d=>{const h=d.getChildRegions(l);c.push(...h)}),c},this.getCurrentTime=()=>{if(o[0]!=null)return o[0].getCurrentTime();for(let l=0;l<i.length;l++){const c=i[l].getCurrentTime();if(c!==-1)return c}return-1},this.setMorphTime=(l,c)=>{o.forEach(d=>{d.setMorphTime(l)}),c&&i.forEach(d=>{d.setMorphTime(l)})},this.isTimeVarying=()=>{for(let l=0;l<o.length;l++)if(o[l].isTimeVarying())return!0;for(let l=0;l<i.length;l++)if(i[l].isTimeVarying())return!0;return!1},this.renderGeometries=(l,c,d,h,p,w)=>{var g;this.getAllObjects(w).forEach(_=>{_.render(l*c,d,h,p)}),p&&d===!1&&((g=p.markerCluster)!=null&&g.markerUpdateRequired)&&p.markerCluster.calculate()},this.createPoints=(l,c,d,h)=>{let p=!1;const w=this.findObjectsWithGroupName(l,!1),y=w.findIndex(_=>_.isPointset),g=y>-1?w[y]:new Te;return g.addPoints(c,d,h),y===-1?(g.setName(l),this.addZincObject(g),p=!0):this.pickableUpdateRequired=!0,{zincObject:g,isNew:p}},this.createLines=(l,c,d)=>{let h=!1;const p=this.findObjectsWithGroupName(l,!1),w=p.findIndex(g=>g.isLines),y=w>-1?p[w]:new st;return y.addLines(c,d),w===-1?(y.setName(l),this.addZincObject(y),h=!0):this.pickableUpdateRequired=!0,{zincObject:y,isNew:h}},this.createGeometryFromThreeJSGeometry=(l,c,d,h,p,w)=>{const y=new Fe,g=new S.MeshPhongMaterial({color:d,morphTargets:!1,morphNormals:!1,transparent:!0,opacity:h,side:S.DoubleSide});if(y.createMesh(c,g,{localTimeEnabled:!1,localMorphColour:!1}),y.getMorph())return y.setVisibility(!1),y.setName(l),y.setRenderOrder(w),this.addZincObject(y),y}};class Mt{constructor(){this.pluginCallbacks=[],this.register(function(e){return new bs(e)}),this.register(function(e){return new xs(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 ys,r=[];for(let o=0,a=this.pluginCallbacks.length;o<a;o++)r.push(this.pluginCallbacks[o](i));i.setPlugins(r),i.write(e,t,s)}}const se={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},ge={};ge[v.NearestFilter]=se.NEAREST,ge[v.NearestMipmapNearestFilter]=se.NEAREST_MIPMAP_NEAREST,ge[v.NearestMipmapLinearFilter]=se.NEAREST_MIPMAP_LINEAR,ge[v.LinearFilter]=se.LINEAR,ge[v.LinearMipmapNearestFilter]=se.LINEAR_MIPMAP_NEAREST,ge[v.LinearMipmapLinearFilter]=se.LINEAR_MIPMAP_LINEAR,ge[v.ClampToEdgeWrapping]=se.CLAMP_TO_EDGE,ge[v.RepeatWrapping]=se.REPEAT,ge[v.MirroredRepeatWrapping]=se.MIRRORED_REPEAT;const fi={scale:"scale",position:"translation",quaternion:"rotation",morphTargetInfluences:"weights"},pi=12,hs=1179937895,us=2,mi=8,ds=1313821514,fs=5130562;function ze(n,e){return n.length===e.length&&n.every(function(t,s){return t===e[s]})}function ps(n){if(window.TextEncoder!==void 0)return new TextEncoder().encode(n).buffer;const e=new Uint8Array(new ArrayBuffer(n.length));for(let t=0,s=n.length;t<s;t++){const i=n.charCodeAt(t);e[t]=i>255?32:i}return e.buffer}function ms(n){return ze(n.elements,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}function gs(n,e,t){const s={min:new Array(n.itemSize).fill(Number.POSITIVE_INFINITY),max:new Array(n.itemSize).fill(Number.NEGATIVE_INFINITY)};for(let i=e;i<e+t;i++)for(let r=0;r<n.itemSize;r++){let o;n.itemSize>4?o=n.array[i*n.itemSize+r]:r===0?o=n.getX(i):r===1?o=n.getY(i):r===2?o=n.getZ(i):r===3&&(o=n.getW(i)),s.min[r]=Math.min(s.min[r],o),s.max[r]=Math.max(s.max[r],o)}return s}function gi(n){return Math.ceil(n/4)*4}function _t(n,e=0){const t=gi(n.byteLength);if(t!==n.byteLength){const s=new Uint8Array(t);if(s.set(new Uint8Array(n)),e!==0)for(let i=n.byteLength;i<t;i++)s[i]=e;return s.buffer}return n}let yi=null;class ys{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 r=i.buffers,o=i.json,a=i.options,u=i.extensionsUsed,f=new Blob(r,{type:"application/octet-stream"}),l=Object.keys(u);if(l.length>0&&(o.extensionsUsed=l),o.buffers&&o.buffers.length>0&&(o.buffers[0].byteLength=f.size),a.binary===!0){const c=new window.FileReader;c.readAsArrayBuffer(f),c.onloadend=function(){const d=_t(c.result),h=new DataView(new ArrayBuffer(mi));h.setUint32(0,d.byteLength,!0),h.setUint32(4,fs,!0);const p=_t(ps(JSON.stringify(o)),32),w=new DataView(new ArrayBuffer(mi));w.setUint32(0,p.byteLength,!0),w.setUint32(4,ds,!0);const y=new ArrayBuffer(pi),g=new DataView(y);g.setUint32(0,hs,!0),g.setUint32(4,us,!0);const _=pi+w.byteLength+p.byteLength+h.byteLength+d.byteLength;g.setUint32(8,_,!0);const A=new Blob([y,w,p,h,d],{type:"application/octet-stream"}),N=new window.FileReader;N.readAsArrayBuffer(A),N.onloadend=function(){t(N.result)}}}else if(o.buffers&&o.buffers.length>0){const c=new window.FileReader;c.readAsDataURL(f),c.onloadend=function(){const d=c.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 r=JSON.parse(JSON.stringify(e.userData));if(s.includeCustomExtensions&&r.gltfExtensions){t.extensions===void 0&&(t.extensions={});for(const o in r.gltfExtensions)t.extensions[o]=r.gltfExtensions[o],i[o]=!0;delete r.gltfExtensions}Object.keys(r).length>0&&(t.extras=r)}catch(r){console.warn("THREE.GLTFExporter: userData of '"+e.name+"' won't be serialized because of JSON.stringify error - "+r.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 v.Vector3;for(let i=0,r=e.count;i<r;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 v.Vector3;for(let r=0,o=s.count;r<o;r++)i.fromBufferAttribute(s,r),i.x===0&&i.y===0&&i.z===0?i.setX(1):i.normalize(),s.setXYZ(r,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,r){const o=this.json;o.bufferViews||(o.bufferViews=[]);let a;t===se.UNSIGNED_BYTE?a=1:t===se.UNSIGNED_SHORT?a=2:a=4;const u=gi(i*e.itemSize*a),f=new DataView(new ArrayBuffer(u));let l=0;for(let h=s;h<s+i;h++)for(let p=0;p<e.itemSize;p++){let w;e.itemSize>4?w=e.array[h*e.itemSize+p]:p===0?w=e.getX(h):p===1?w=e.getY(h):p===2?w=e.getZ(h):p===3&&(w=e.getW(h)),t===se.FLOAT?f.setFloat32(l,w,!0):t===se.UNSIGNED_INT?f.setUint32(l,w,!0):t===se.UNSIGNED_SHORT?f.setUint16(l,w,!0):t===se.UNSIGNED_BYTE&&f.setUint8(l,w),l+=a}const c={buffer:this.processBuffer(f.buffer),byteOffset:this.byteOffset,byteLength:u};return r!==void 0&&(c.target=r),r===se.ARRAY_BUFFER&&(c.byteStride=e.itemSize*a),this.byteOffset+=u,o.bufferViews.push(c),{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 r=new window.FileReader;r.readAsArrayBuffer(e),r.onloadend=function(){const o=_t(r.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 r=this.options,o=this.json,a={1:"SCALAR",2:"VEC2",3:"VEC3",4:"VEC4",16:"MAT4"};let u;if(e.array.constructor===Float32Array)u=se.FLOAT;else if(e.array.constructor===Uint32Array)u=se.UNSIGNED_INT;else if(e.array.constructor===Uint16Array)u=se.UNSIGNED_SHORT;else if(e.array.constructor===Uint8Array)u=se.UNSIGNED_BYTE;else throw new Error("THREE.GLTFExporter: Unsupported bufferAttribute component type.");if(s===void 0&&(s=0),i===void 0&&(i=e.count),r.truncateDrawRange&&t!==void 0&&t.index===null){const h=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(h,p)-s,i<0&&(i=0)}if(i===0)return null;const f=gs(e,s,i);let l;t!==void 0&&(l=e===t.index?se.ELEMENT_ARRAY_BUFFER:se.ARRAY_BUFFER);const c=this.processBufferView(e,u,s,i,l),d={bufferView:c.id,byteOffset:c.byteOffset,componentType:u,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,r=i.cache,o=i.json,a=i.options,u=i.pending;r.images.has(e)||r.images.set(e,{});const f=r.images.get(e),l=t===v.RGBAFormat?"image/png":"image/jpeg",c=l+":flipY/"+s.toString();if(f[c]!==void 0)return f[c];o.images||(o.images=[]);const d={mimeType:l};if(a.embedImages){const p=yi=yi||document.createElement("canvas");p.width=Math.min(e.width,a.maxTextureSize),p.height=Math.min(e.height,a.maxTextureSize);const w=p.getContext("2d");if(s===!0&&(w.translate(0,p.height),w.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)w.drawImage(e,0,0,p.width,p.height);else{t!==v.RGBAFormat&&t!==v.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 y=new Uint8ClampedArray(e.height*e.width*4);if(t===v.RGBAFormat)for(let g=0;g<y.length;g+=4)y[g+0]=e.data[g+0],y[g+1]=e.data[g+1],y[g+2]=e.data[g+2],y[g+3]=e.data[g+3];else for(let g=0,_=0;g<y.length;g+=4,_+=3)y[g+0]=e.data[_+0],y[g+1]=e.data[_+1],y[g+2]=e.data[_+2],y[g+3]=255;w.putImageData(new ImageData(y,e.width,e.height),0,0)}a.binary===!0?u.push(new Promise(function(y){p.toBlob(function(g){i.processBufferViewImage(g).then(function(_){d.bufferView=_,y()})},l)})):d.uri=p.toDataURL(l)}else d.uri=e.src;const h=o.images.push(d)-1;return f[c]=h,h}processSampler(e){const t=this.json;t.samplers||(t.samplers=[]);const s={magFilter:ge[e.magFilter],minFilter:ge[e.minFilter],wrapS:ge[e.wrapS],wrapT:ge[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 r=s.textures.push(i)-1;return t.textures.set(e,r),r}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 r=e.color.toArray().concat([e.opacity]);if(ze(r,[1,1,1,1])||(i.pbrMetallicRoughness.baseColorFactor=r),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),u=Math.max(a.r,a.g,a.b);if(u>1&&(a.multiplyScalar(1/u),console.warn("THREE.GLTFExporter: Some emissive components exceed 1; emissive has been limited")),u>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===v.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 A=0,N=e.material.length;A<N;A++)i.push(e.material[A].uuid);else i.push(e.material.uuid);const r=i.join(":");if(t.meshes.has(r))return t.meshes.get(r);const o=e.geometry;let a;if(e.isLineSegments?a=se.LINES:e.isLineLoop?a=se.LINE_LOOP:e.isLine?a=se.LINE_STRIP:e.isPoints?a=se.POINTS:a=e.material.wireframe?se.LINES:se.TRIANGLES,o.isBufferGeometry!==!0)throw new Error("THREE.GLTFExporter: Geometry is not of type THREE.BufferGeometry.");const u={},f={},l=[],c=[],d={uv:"TEXCOORD_0",uv2:"TEXCOORD_1",color:"COLOR_0",skinWeight:"WEIGHTS_0",skinIndex:"JOINTS_0"},h=o.getAttribute("normal");h!==void 0&&!this.isNormalizedNormalAttribute(h)&&(console.warn("THREE.GLTFExporter: Creating normalized normal attribute from the non-normalized one."),o.setAttribute("normal",this.createNormalizedNormalAttribute(h)));let p=null;for(let A in o.attributes){if(A.substr(0,5)==="morph")continue;const N=o.attributes[A];if(A=d[A]||A.toUpperCase(),/^(POSITION|NORMAL|TANGENT|TEXCOORD_\d+|COLOR_\d+|JOINTS_\d+|WEIGHTS_\d+)$/.test(A)||(A="_"+A),t.attributes.has(this.getUID(N))){f[A]=t.attributes.get(this.getUID(N));continue}p=null;const D=N.array;A==="JOINTS_0"&&!(D instanceof Uint16Array)&&!(D instanceof Uint8Array)&&(console.warn('GLTFExporter: Attribute "skinIndex" converted to type UNSIGNED_SHORT.'),p=new v.BufferAttribute(new Uint16Array(D),N.itemSize,N.normalized));const F=this.processAccessor(p||N,o);F!==null&&(f[A]=F,t.attributes.set(this.getUID(N),F))}if(h!==void 0&&o.setAttribute("normal",h),Object.keys(f).length===0)return null;if(e.morphTargetInfluences!==void 0&&e.morphTargetInfluences.length>0){const A=[],N=[],I={};if(e.morphTargetDictionary!==void 0)for(const D in e.morphTargetDictionary)I[e.morphTargetDictionary[D]]=D;for(let D=0;D<e.morphTargetInfluences.length;++D){const F={};let q=!1;for(const G in o.morphAttributes){if(G!=="position"&&G!=="normal"&&G!=="color"){q||(console.warn("GLTFExporter: Only POSITION and NORMAL morph are supported."),q=!0);continue}const T=o.morphAttributes[G][D];let C=G.toUpperCase();d[G]&&(C=d[G]);const U=o.attributes[G];if(t.attributes.has(this.getUID(T))){F[C]=t.attributes.get(this.getUID(T));continue}const M=U.clone();if(!o.morphTargetsRelative)if(U)for(let O=0,k=T.count;O<k;O++)U.count>O&&M.setXYZ(O,T.getX(O)-U.getX(O),T.getY(O)-U.getY(O),T.getZ(O)-U.getZ(O));else for(let O=0,k=T.count;O<k;O++)M.setXYZ(O,0,0,0);F[C]=this.processAccessor(M,o),t.attributes.set(this.getUID(U),F[C])}c.push(F),A.push(e.morphTargetInfluences[D]),e.morphTargetDictionary!==void 0&&N.push(I[D])}u.weights=A,N.length>0&&(u.extras={},u.extras.targetNames=N)}const w=Array.isArray(e.material);if(w&&o.groups.length===0)return null;const y=w?e.material:[e.material],g=w?o.groups:[{materialIndex:0,start:void 0,count:void 0}];for(let A=0,N=g.length;A<N;A++){const I={mode:a,attributes:f};if(this.serializeUserData(o,I),c.length>0&&(I.targets=c),o.index!==null){let F=this.getUID(o.index);(g[A].start!==void 0||g[A].count!==void 0)&&(F+=":"+g[A].start+":"+g[A].count),t.attributes.has(F)?I.indices=t.attributes.get(F):(I.indices=this.processAccessor(o.index,o,g[A].start,g[A].count),t.attributes.set(F,I.indices)),I.indices===null&&delete I.indices}const D=this.processMaterial(y[g[A].materialIndex]);D!==null&&(I.material=D),l.push(I)}u.primitives=l,s.meshes||(s.meshes=[]),this._invokeAll(function(A){A.writeMesh&&A.writeMesh(e,u)});const _=s.meshes.push(u)-1;return t.meshes.set(r,_),_}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:v.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=Mt.Utils.mergeMorphTargetTracks(e.clone(),t);const r=e.tracks,o=[],a=[];for(let u=0;u<r.length;++u){const f=r[u],l=v.PropertyBinding.parseTrackName(f.name);let c=v.PropertyBinding.findNode(t,l.nodeName);const d=fi[l.propertyName];if(l.objectName==="bones"&&(c.isSkinnedMesh===!0?c=c.skeleton.getBoneByName(l.objectIndex):c=void 0),!c||!d)return console.warn('THREE.GLTFExporter: Could not export animation track "%s".',f.name),null;const h=1;let p=f.values.length/f.times.length;d===fi.morphTargetInfluences&&(p/=c.morphTargetInfluences.length);let w;f.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline===!0?(w="CUBICSPLINE",p/=3):f.getInterpolation()===v.InterpolateDiscrete?w="STEP":w="LINEAR",a.push({input:this.processAccessor(new v.BufferAttribute(f.times,h)),output:this.processAccessor(new v.BufferAttribute(f.values,p)),interpolation:w}),o.push({sampler:a.length-1,target:{node:i.get(c),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)],r=e.skeleton;if(r===void 0)return null;const o=e.skeleton.bones[0];if(o===void 0)return null;const a=[],u=new Float32Array(r.bones.length*16),f=new v.Matrix4;for(let c=0;c<r.bones.length;++c)a.push(s.get(r.bones[c])),f.copy(r.boneInverses[c]),f.multiply(e.bindMatrix).toArray(u,c*16);return t.skins===void 0&&(t.skins=[]),t.skins.push({inverseBindMatrices:this.processAccessor(new v.BufferAttribute(u,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 r={};if(s.trs){const a=e.quaternion.toArray(),u=e.position.toArray(),f=e.scale.toArray();ze(a,[0,0,0,1])||(r.rotation=a),ze(u,[0,0,0])||(r.translation=u),ze(f,[1,1,1])||(r.scale=f)}else e.matrixAutoUpdate&&e.updateMatrix(),ms(e.matrix)===!1&&(r.matrix=e.matrix.elements);if(e.name!==""&&(r.name=String(e.name)),this.serializeUserData(e,r),e.isMesh||e.isLine||e.isPoints){const a=this.processMesh(e);a!==null&&(r.mesh=a)}else e.isCamera&&(r.camera=this.processCamera(e));if(e.isSkinnedMesh&&this.skins.push(e),e.children.length>0){const a=[];for(let u=0,f=e.children.length;u<f;u++){const l=e.children[u];if(l.visible||s.onlyVisible===!1){const c=this.processNode(l);c!==null&&a.push(c)}}a.length>0&&(r.children=a)}this._invokeAll(function(a){a.writeNode&&a.writeNode(e,r)});const o=t.nodes.push(r)-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 r=[];for(let o=0,a=e.children.length;o<a;o++){const u=e.children[o];if(u.visible||s.onlyVisible===!1){const f=this.processNode(u);f!==null&&r.push(f)}}r.length>0&&(i.nodes=r),this.serializeUserData(e,i)}processObjects(e){const t=new v.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 v.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 bs{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,r=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."),r[this.name]||(i.extensions=i.extensions||{},i.extensions[this.name]={lights:[]},r[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 xs{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,r={};t.pbrMetallicRoughness.baseColorFactor&&(r.diffuseFactor=t.pbrMetallicRoughness.baseColorFactor);const o=[1,1,1];if(e.specular.toArray(o,0),r.specularFactor=o,r.glossinessFactor=e.glossiness,t.pbrMetallicRoughness.baseColorTexture&&(r.diffuseTexture=t.pbrMetallicRoughness.baseColorTexture),e.specularMap){const a={index:s.processTexture(e.specularMap)};s.applyTextureTransform(a,e.specularMap),r.specularGlossinessTexture=a}t.extensions=t.extensions||{},t.extensions[this.name]=r,i[this.name]=!0}}Mt.Utils={insertKeyframe:function(n,e){const s=n.getValueSize(),i=new n.TimeBufferType(n.times.length+1),r=new n.ValueBufferType(n.values.length+s),o=n.createInterpolant(new n.ValueBufferType(s));let a;if(n.times.length===0){i[0]=e;for(let u=0;u<s;u++)r[u]=0;a=0}else if(e<n.times[0]){if(Math.abs(n.times[0]-e)<.001)return 0;i[0]=e,i.set(n.times,1),r.set(o.evaluate(e),0),r.set(n.values,s),a=0}else if(e>n.times[n.times.length-1]){if(Math.abs(n.times[n.times.length-1]-e)<.001)return n.times.length-1;i[i.length-1]=e,i.set(n.times,0),r.set(n.values,0),r.set(o.evaluate(e),n.values.length),a=i.length-1}else for(let u=0;u<n.times.length;u++){if(Math.abs(n.times[u]-e)<.001)return u;if(n.times[u]<e&&n.times[u+1]>e){i.set(n.times.slice(0,u+1),0),i[u+1]=e,i.set(n.times.slice(u+1),u+2),r.set(n.values.slice(0,(u+1)*s),0),r.set(o.evaluate(e),(u+1)*s),r.set(n.values.slice((u+1)*s),(u+2)*s),a=u+1;break}}return n.times=i,n.values=r,a},mergeMorphTargetTracks:function(n,e){const t=[],s={},i=n.tracks;for(let r=0;r<i.length;++r){let o=i[r];const a=v.PropertyBinding.parseTrackName(o.name),u=v.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(v.InterpolateLinear)}const f=u.morphTargetInfluences.length,l=u.morphTargetDictionary[a.propertyIndex];if(l===void 0)throw new Error("THREE.GLTFExporter: Morph target name not found: "+a.propertyIndex);let c;if(s[u.uuid]===void 0){c=o.clone();const h=new c.ValueBufferType(f*c.times.length);for(let p=0;p<c.times.length;p++)h[p*f+l]=c.values[p];c.name=(a.nodeName||"")+".morphTargetInfluences",c.values=h,s[u.uuid]=c,t.push(c);continue}const d=o.createInterpolant(new o.ValueBufferType(1));c=s[u.uuid];for(let h=0;h<c.times.length;h++)c.values[h*f+l]=d.evaluate(c.times[h]);for(let h=0;h<o.times.length;h++){const p=this.insertKeyframe(c,o.times[h]);c.values[p*f+l]=o.values[h]}}return n.tracks=t,n}};const ws=function(n){const e=n;this.exportGLTF=t=>{const i=e.getRootRegion().getAllObjects(!0),r=[];i.forEach(u=>{u.animationClip&&r.push({clip:u.animationClip[0],mesh:u.getMorph()})});const o=new Mt,a={binary:t,animations:r};return new Promise((u,f)=>{o.parse(e.getThreeJSScene(),function(l){u(l)},a)})}},As=function(){const n=this;this.parseGLTFObjects=(e,t,s,i)=>{let r=t;if(s!==0)if(e.type==="Object3D"){if(e.name!==""&&(t&&(r=t.findOrCreateChildFromPath(e.name)),r)){const o=r.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 Fe:e.type==="LineSegments"?o=new Ve:e.type==="Points"&&(o=new Te),o){let a=!1,u=!1;e.geometry&&e.geometry.morphAttributes&&(a=!!e.geometry.morphAttributes.position,u=!!e.geometry.morphAttributes.color),o.setMesh(e.clone(),a,u);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=>{n.parseGLTFObjects(o,r,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,r,o)=>{const a=s.substring(0,s.lastIndexOf("/")+1),u=s.substring(s.lastIndexOf("/")+1,s.length);new Bi.GLTFLoader().setPath(a).load(u,function(l){console.log(l),n.parseGLTFObjects(l.scene,t,0,i),n.setCamera(e),r!=null&&typeof r=="function"&&r()})}},Ms=/^[og]\s*(.+)?/,_s=/^mtllib /,Ss=/^usemtl /,Cs=/^usemap /,bi=new v.Vector3,St=new v.Vector3,xi=new v.Vector3,vi=new v.Vector3,xe=new v.Vector3;function Os(){const n={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,r){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(r)&&r.length>0?r[r.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(u){const f={index:typeof u=="number"?u: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 r=this.currentMaterial();if(r&&r.groupEnd===-1&&(r.groupEnd=this.geometry.vertices.length/3,r.groupCount=r.groupEnd-r.groupStart,r.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}),r}},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,r=this.object.geometry.vertices;r.push(i[e+0],i[e+1],i[e+2]),r.push(i[t+0],i[t+1],i[t+2]),r.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,r=this.object.geometry.normals;r.push(i[e+0],i[e+1],i[e+2]),r.push(i[t+0],i[t+1],i[t+2]),r.push(i[s+0],i[s+1],i[s+2])},addFaceNormal:function(e,t,s){const i=this.vertices,r=this.object.geometry.normals;bi.fromArray(i,e),St.fromArray(i,t),xi.fromArray(i,s),xe.subVectors(xi,St),vi.subVectors(bi,St),xe.cross(vi),xe.normalize(),r.push(xe.x,xe.y,xe.z),r.push(xe.x,xe.y,xe.z),r.push(xe.x,xe.y,xe.z)},addColor:function(e,t,s){const i=this.colors,r=this.object.geometry.colors;i[e]!==void 0&&r.push(i[e+0],i[e+1],i[e+2]),i[t]!==void 0&&r.push(i[t+0],i[t+1],i[t+2]),i[s]!==void 0&&r.push(i[s+0],i[s+1],i[s+2])},addUV:function(e,t,s){const i=this.uvs,r=this.object.geometry.uvs;r.push(i[e+0],i[e+1]),r.push(i[t+0],i[t+1]),r.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,r,o,a,u,f){const l=this.vertices.length;let c=this.parseVertexIndex(e,l),d=this.parseVertexIndex(t,l),h=this.parseVertexIndex(s,l);if(this.addVertex(c,d,h),this.addColor(c,d,h),a!==void 0&&a!==""){const p=this.normals.length;c=this.parseNormalIndex(a,p),d=this.parseNormalIndex(u,p),h=this.parseNormalIndex(f,p),this.addNormal(c,d,h)}else this.addFaceNormal(c,d,h);if(i!==void 0&&i!==""){const p=this.uvs.length;c=this.parseUVIndex(i,p),d=this.parseUVIndex(r,p),h=this.parseUVIndex(o,p),this.addUV(c,d,h),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 r=this.parseVertexIndex(e[s],t);this.addVertexPoint(r),this.addColor(r)}},addLineGeometry:function(e,t){this.object.geometry.type="Line";const s=this.vertices.length,i=this.uvs.length;for(let r=0,o=e.length;r<o;r++)this.addVertexLine(this.parseVertexIndex(e[r],s));for(let r=0,o=t.length;r<o;r++)this.addUVLine(this.parseUVIndex(t[r],i))}};return n.startObject("",!1),n}class wi extends v.Loader{constructor(e){super(e),this.materials=null}load(e,t,s,i){const r=this,o=new v.FileLoader(this.manager);o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(e,function(a){try{t(r.parse(a))}catch(u){i?i(u):console.error(u),r.manager.itemError(e)}},s,i)}setMaterials(e){return this.materials=e,this}parse(e){const t=new Os;e.indexOf(`\r
|
|
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
|
|
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="",r="",o=0,a=[];const u=typeof"".trimLeft=="function";for(let c=0,d=s.length;c<d;c++)if(i=s[c],i=u?i.trimLeft():i.trim(),o=i.length,o!==0&&(r=i.charAt(0),r!=="#"))if(r==="v"){const h=i.split(/\s+/);switch(h[0]){case"v":t.vertices.push(parseFloat(h[1]),parseFloat(h[2]),parseFloat(h[3])),h.length>=7?t.colors.push(parseFloat(h[4]),parseFloat(h[5]),parseFloat(h[6])):t.colors.push(void 0,void 0,void 0);break;case"vn":t.normals.push(parseFloat(h[1]),parseFloat(h[2]),parseFloat(h[3]));break;case"vt":t.uvs.push(parseFloat(h[1]),parseFloat(h[2]));break}}else if(r==="f"){const p=i.substr(1).trim().split(/\s+/),w=[];for(let g=0,_=p.length;g<_;g++){const A=p[g];if(A.length>0){const N=A.split("/");w.push(N)}}const y=w[0];for(let g=1,_=w.length-1;g<_;g++){const A=w[g],N=w[g+1];t.addFace(y[0],A[0],N[0],y[1],A[1],N[1],y[2],A[2],N[2])}}else if(r==="l"){const h=i.substring(1).trim().split(" ");let p=[];const w=[];if(i.indexOf("/")===-1)p=h;else for(let y=0,g=h.length;y<g;y++){const _=h[y].split("/");_[0]!==""&&p.push(_[0]),_[1]!==""&&w.push(_[1])}t.addLineGeometry(p,w)}else if(r==="p"){const p=i.substr(1).trim().split(" ");t.addPointGeometry(p)}else if((a=Ms.exec(i))!==null){const h=(" "+a[0].substr(1).trim()).substr(1);t.startObject(h)}else if(Ss.test(i))t.object.startMaterial(i.substring(7).trim(),t.materialLibraries);else if(_s.test(i))t.materialLibraries.push(i.substring(7).trim());else if(Cs.test(i))console.warn('THREE.OBJLoader: Rendering identifier "usemap" not supported. Textures must be defined in MTL files.');else if(r==="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 h=t.object.currentMaterial();h&&(h.smooth=t.object.smooth)}else{if(i==="\0")continue;console.warn('THREE.OBJLoader: Unexpected line: "'+i+'"')}t.finalize();const f=new v.Group;if(f.materialLibraries=[].concat(t.materialLibraries),!(t.objects.length===1&&t.objects[0].geometry.vertices.length===0)===!0)for(let c=0,d=t.objects.length;c<d;c++){const h=t.objects[c],p=h.geometry,w=h.materials,y=p.type==="Line",g=p.type==="Points";let _=!1;if(p.vertices.length===0)continue;const A=new v.BufferGeometry;A.setAttribute("position",new v.Float32BufferAttribute(p.vertices,3)),p.normals.length>0&&A.setAttribute("normal",new v.Float32BufferAttribute(p.normals,3)),p.colors.length>0&&(_=!0,A.setAttribute("color",new v.Float32BufferAttribute(p.colors,3))),p.hasUVIndices===!0&&A.setAttribute("uv",new v.Float32BufferAttribute(p.uvs,2));const N=[];for(let D=0,F=w.length;D<F;D++){const q=w[D],G=q.name+"_"+q.smooth+"_"+_;let T=t.materials[G];if(this.materials!==null){if(T=this.materials.create(q.name),y&&T&&!(T instanceof v.LineBasicMaterial)){const C=new v.LineBasicMaterial;v.Material.prototype.copy.call(C,T),C.color.copy(T.color),T=C}else if(g&&T&&!(T instanceof v.PointsMaterial)){const C=new v.PointsMaterial({size:10,sizeAttenuation:!1});v.Material.prototype.copy.call(C,T),C.color.copy(T.color),C.map=T.map,T=C}}T===void 0&&(y?T=new v.LineBasicMaterial:g?T=new v.PointsMaterial({size:1,sizeAttenuation:!1}):T=new v.MeshPhongMaterial,T.name=q.name,T.flatShading=!q.smooth,T.vertexColors=_,t.materials[G]=T),N.push(T)}let I;if(N.length>1){for(let D=0,F=w.length;D<F;D++){const q=w[D];A.addGroup(q.groupStart,q.groupCount,D)}y?I=new v.LineSegments(A,N):g?I=new v.Points(A,N):I=new v.Mesh(A,N)}else y?I=new v.LineSegments(A,N[0]):g?I=new v.Points(A,N[0]):I=new v.Mesh(A,N[0]);I.name=h.name,f.add(I)}else if(t.vertices.length>0){const c=new v.PointsMaterial({size:1,sizeAttenuation:!1}),d=new v.BufferGeometry;d.setAttribute("position",new v.Float32BufferAttribute(t.vertices,3)),t.colors.length>0&&t.colors[0]!==void 0&&(d.setAttribute("color",new v.Float32BufferAttribute(t.colors,3)),c.vertexColors=!0);const h=new v.Points(d,c);f.add(h)}return f}}const Ai=S.FileLoader,Ts=n=>{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(r=>{r in t&&Object.keys(t[r]).forEach(o=>{const a=s[r][o].length;for(let u=0;u<a;u++)t[r][o].push(s[r][o][u])})})};if(n&&n.length>0)for(;n.length>1;){const t=n.splice(1,1);e(n[0],t[0])}},Ls=n=>{const e=(t,s)=>{t.merge(s)};if(n&&n.length>0){for(;n.length>1;){const t=n.splice(1,1);e(n[0],t[0])}return n[0]}},Bs=function(n,e,t){const s=new Ai,i=new Qe;s.crossOrigin=e;const r=n,o=t;let a,u=!1,f=!1,l;const c=[],d=y=>{const g=a[y.index];if(g)if("GlyphGeometriesURL"in g)y.onLoad(g);else{let _=i.parse(g);y.onLoad(_.geometry,_.materials)}else h(y)},h=y=>{y.onError&&(l||(l={responseURL:r}),y.onError(l))};this.downloadCompleted=y=>{try{a=JSON.parse(y[0]),u=!1,f=!0,Array.isArray(a)?c.forEach(g=>d(g)):c.forEach(g=>h(g))}catch{c.forEach(g=>h(g))}};const p=()=>y=>{l=y,f=!0,u=!1,c.forEach(g=>{h(g)})},w=()=>y=>{c.forEach(g=>{g.onProgress&&g.onProgress(y)})};this.load=(y,g,_,A)=>{const N={index:y,onLoad:g,onProgress:_,onError:A};f?a?d(N):h(l):u?c.push(N):(c.push(N),u=!0,s.load(r,o,w,p))}},Us=function(n,e,t){const s=[],i=n,r=e;let o=0;const a=t.isGlyphsets;this.itemDownloaded=(u,f)=>{if(s[u]=f,o++,o==i&&s.length>0)if(a){const l=s.map(c=>JSON.parse(c[0]));Ts(l),r(l[0])}else{const l=s[0][1],c=s.map(h=>h[0]),d=Ls(c);for(let h=1;h<i;h++)s[u][0].dispose(),s[u][1].forEach(p=>p.dispose());r(d,l)}}},Ns=function(){let n=0;const e=20;this.crossOrigin="Anonymous";const t=new Qe,s=new Ai;s.crossOrigin="Anonymous";const i=[],r={},o=(l,c,d,h,p)=>{const w=l.length,y=new Us(w,c,p);let g=0;l.forEach(_=>{const A=p?{...p}:{};A.msHandler=y,A.order=g,g++,u(_,c,d,h,A)})},a=(l,c,d,h,p)=>{const w=p?{...p}:{};let y=r[l];if(!y)if(e>n){const g=new f(void 0,this,w);++n,y=new Bs(l,this.crossOrigin,g),r[l]=y}else i.push({url:l,onLoad:c,onProgress:d,onError:h,options:p});y&&(w.isHandler=y,y.load(p.index,c,d,h))},u=(l,c,d,h,p)=>{if(p&&p.index!==void 0)a(l,c,d,h,p);else if(e>n){++n;const w=new f(c,this,p),y=new f(h,this,p);p.isGlyphsets?s.load(l,w,d,y):(t.crossOrigin=this.crossOrigin,t.load(l,w,d,y))}else i.push({url:l,onLoad:c,onProgress:d,onError:h,options:p})};this.load=(l,c,d,h,p)=>{Array.isArray(l)?o(l,c,d,h,p):u(l,c,d,h,p)},this.loadFromWaitingList=()=>{for(;e>n;){const l=i.shift();if(l)this.load(l.url,l.onLoad,l.onProgress,l.onError,l.options);else return}},this.itemRemainingCheck=()=>{if(i.length===0&&n===0)for(let l in r)r.hasOwnProperty(l)&&delete r[l]};const f=function(l,c,d){return(...h)=>{--n,d!=null&&d.msHandler?d.msHandler.itemDownloaded(d.order,h):d!=null&&d.isHandler?d.isHandler.downloadCompleted(h):l&&l(...h),c.loadFromWaitingList(),c.itemRemainingCheck()}};this.parse=l=>loader.parse(l)};class Mi extends v.Loader{constructor(e){super(e)}load(e,t,s,i){const r=this,o=new v.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(r.parse(a))}catch(u){i?i(u):console.error(u),r.manager.itemError(e)}},s,i)}parse(e){function t(f){const l=new DataView(f),c=32/8*3+32/8*3*3+16/8,d=l.getUint32(80,!0);if(80+32/8+d*c===l.byteLength)return!0;const p=[115,111,108,105,100];for(let w=0;w<5;w++)if(s(p,l,w))return!1;return!0}function s(f,l,c){for(let d=0,h=f.length;d<h;d++)if(f[d]!==l.getUint8(c+d,!1))return!1;return!0}function i(f){const l=new DataView(f),c=l.getUint32(80,!0);let d,h,p,w=!1,y,g,_,A,N;for(let T=0;T<70;T++)l.getUint32(T,!1)==1129270351&&l.getUint8(T+4)==82&&l.getUint8(T+5)==61&&(w=!0,y=new Float32Array(c*3*3),g=l.getUint8(T+6)/255,_=l.getUint8(T+7)/255,A=l.getUint8(T+8)/255,N=l.getUint8(T+9)/255);const I=84,D=12*4+2,F=new v.BufferGeometry,q=new Float32Array(c*3*3),G=new Float32Array(c*3*3);for(let T=0;T<c;T++){const C=I+T*D,U=l.getFloat32(C,!0),M=l.getFloat32(C+4,!0),O=l.getFloat32(C+8,!0);if(w){const k=l.getUint16(C+48,!0);k&32768?(d=g,h=_,p=A):(d=(k&31)/31,h=(k>>5&31)/31,p=(k>>10&31)/31)}for(let k=1;k<=3;k++){const P=C+k*12,m=T*3*3+(k-1)*3;q[m]=l.getFloat32(P,!0),q[m+1]=l.getFloat32(P+4,!0),q[m+2]=l.getFloat32(P+8,!0),G[m]=U,G[m+1]=M,G[m+2]=O,w&&(y[m]=d,y[m+1]=h,y[m+2]=p)}}return F.setAttribute("position",new v.BufferAttribute(q,3)),F.setAttribute("normal",new v.BufferAttribute(G,3)),w&&(F.setAttribute("color",new v.BufferAttribute(y,3)),F.hasColors=!0,F.alpha=N),F}function r(f){const l=new v.BufferGeometry,c=/solid([\s\S]*?)endsolid/g,d=/facet([\s\S]*?)endfacet/g;let h=0;const p=/[\s]+([+-]?(?:\d*)(?:\.\d*)?(?:[eE][+-]?\d+)?)/.source,w=new RegExp("vertex"+p+p+p,"g"),y=new RegExp("normal"+p+p+p,"g"),g=[],_=[],A=new v.Vector3;let N,I=0,D=0,F=0;for(;(N=c.exec(f))!==null;){D=F;const q=N[0];for(;(N=d.exec(q))!==null;){let C=0,U=0;const M=N[0];for(;(N=y.exec(M))!==null;)A.x=parseFloat(N[1]),A.y=parseFloat(N[2]),A.z=parseFloat(N[3]),U++;for(;(N=w.exec(M))!==null;)g.push(parseFloat(N[1]),parseFloat(N[2]),parseFloat(N[3])),_.push(A.x,A.y,A.z),C++,F++;U!==1&&console.error("THREE.STLLoader: Something isn't right with the normal of face number "+h),C!==3&&console.error("THREE.STLLoader: Something isn't right with the vertices of face number "+h),h++}const G=D,T=F-D;l.addGroup(G,T,I),I++}return l.setAttribute("position",new v.Float32BufferAttribute(g,3)),l.setAttribute("normal",new v.Float32BufferAttribute(_,3)),l}function o(f){return typeof f!="string"?v.LoaderUtils.decodeText(new Uint8Array(f)):f}function a(f){if(typeof f=="string"){const l=new Uint8Array(f.length);for(let c=0;c<f.length;c++)l[c]=f.charCodeAt(c)&255;return l.buffer||l}else return f}const u=a(e);return t(u)?i(u):r(o(e))}}const _i=function(){Y.call(this),this.isTubeLines=!0;let n={},e={radius:1,radialSegments:8,smooth:!1};this.createLineSegment=(s,i,r)=>{if(s&&i){n={geometryIn:s,materialIn:i,options:r};const o=t(s.vertices),a=new S.MeshStandardMaterial({color:i.color}),u=new S.Mesh(o,a);this.setMesh(u,r.localTimeEnabled,r.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:r}=n;let o=this.getMorph();o.geometry.dispose(),e=Object.assign(e,{radius:s,radialSegments:i}),o.geometry=t(r.vertices)}};const t=s=>{const{radius:i,radialSegments:r,smooth:o}=e;let a;if(o){const u=new S.CatmullRomCurve3(s);a=new S.TubeGeometry(u,s.length,i,r,!1)}else{const u=[];for(let f=0;f+1<s.length;f=f+2){const l=new S.LineCurve3(s[f],s[f+1]),c=new S.TubeGeometry(l,1,i,r,!1);u.push(c)}a=Gi(u,!0),u.forEach(f=>f.dispose())}return a}};_i.prototype=Object.create(Y.prototype);const Ps=function(n){const e=n;this.toBeDownloaded=0,this.progressMap={};let t=!1,s=!1;const i=new Ns;this.getDownloadProgress=()=>{let T=0,C=0,U=!1;for(const M in this.progressMap){const O=this.progressMap[M];T+=O[1],C+=O[0],O[1]==0&&(U=!0)}return U&&(T=0),[T,C,s]},this.onProgress=T=>C=>{this.progressMap[T]=[C.loaded,C.total]},this.onError=T=>C=>{this.toBeDownloaded=this.toBeDownloaded-1,s=!0,console.error(`There is an issue with external resource ${C!=null&&C.responseURL?": "+(C==null?void 0:C.responseURL):""}.`),T&&T({type:"Error",xhr:C})};let r=(T,C)=>{const U=C.Default;if(C.Inline)e.setupMultipleViews(U,C.Entries);else{const M=[];for(const[O,k]of Object.entries(C.Entries))if(T){const P=Pe(k,T);M.push(new Promise((m,L)=>{fetch(P).then(b=>b.json()).then(b=>m({key:O,data:b})).catch(b=>L(b))}))}Promise.all(M).then(O=>{const k={};O.forEach(m=>{k[m.key]=m.data}),e.setupMultipleViews(U,k);let P=e.getZincCameraControls();P&&P.setCurrentViewport(U),t=!0})}};this.loadViewURL=(T,C)=>{this.toBeDownloaded+=1;const U=ye(T);fetch(U).then(M=>{if(!M.ok)throw new Error(`HTTP error! status: ${M.status}`);return M.json()}).then(M=>{e.setupMultipleViews("default",{default:M}),e.resetView(),t=!0,--this.toBeDownloaded,C!==void 0&&typeof C=="function"&&C()}).catch(M=>{console.error(`Fetch failed for URL: ${U}`,M),this.onError(C)({responseURL:U})})},this.loadModelsURL=(T,C,U,M,O,k,P)=>{const m=C.length;this.toBeDownloaded+=m;for(let L=0;L<m;L++){const b=C[L];let B=Se.defaultMaterialColor,V=Se.defaultOpacity;U!=null&&U[L]!=null&&(B=!!U[L]),M!=null&&M[L]!=null&&(V=M[L]);let R=0;O!=null&&O[L]!=null&&(R=!!O[L]);let z=0;k!=null&&k[L]!=null&&(z=!!k[L]),i.load(ye(b),h(T,B,V,R,z,void 0,void 0,void 0,void 0,P),this.onProgress(b),this.onError(P))}},this.loadFromViewURL=(T,C,U)=>{const M=ye(C+"_view.json");fetch(M).then(O=>{if(!O.ok)throw new Error(`HTTP error! status: ${O.status}`);return O.json()}).then(O=>{e.loadView(O);const k=[],P=C+"_";for(let m=0;m<O.numberOfResources;m++){const L=P+(m+1)+".json";k.push(L)}this.loadModelsURL(T,k,O.colour,O.opacity,O.timeEnabled,O.morphColour,U)}).catch(O=>{console.error(`Failed to load view data from: ${M}`,O)})};const o=(T,C,U,M,O,k,P,m,L)=>(b,B)=>{const V=m?new _i:new Ve;let R;B&&B[0]&&(R=new S.LineBasicMaterial({color:B[0].color.clone()}),1>B[0].opacity&&(R.transparent=!0),R.opacity=B[0].opacity,R.morphTargets=C,R.vertexColors=B[0].vertexColors);let z={};if(z.localTimeEnabled=C,z.localMorphColour=U,V&&(V.createLineSegment(b,R,z),V.setName(M),V.setAnatomicalId(O),V.setRenderOrder(k),T.addZincObject(V),V.setDuration(e.getDuration()),P&&P.levels))for(const[Z,E]of Object.entries(P.levels))V.addLOD(i,Z,E.URL,E.Index,P.preload);--this.toBeDownloaded,b.dispose(),L!=null&&typeof L=="function"&&L(V)};this.loadLinesURL=(T,C,U,M,O,k,P)=>{let m=0;this.toBeDownloaded+=1;let L=P!=null&&P.isInline?P.isInline:!1,b=P!=null&&P.anatomicalId?P.anatomicalId:void 0,B=P&&"renderOrder"in P?P.renderOrder:void 0;U!=null&&(m=!!U);let V=0;M!=null&&(V=!!M);let R=P.tubeLines&&!m&&!V;if(L){let z=i.parse(C);o(T,m,V,O,b,B,P.lod,R,k)(z.geometry,z.materials)}else i.load(C,o(T,m,V,O,b,B,P.lod,R,k),this.onProgress(C),this.onError(k),P.loaderOptions)};const a=(T,C,U,M,O)=>k=>{let P=k;(typeof P=="string"||P instanceof String)&&(P=JSON.parse(k));let m=O&&O.isInline?O.isInline:void 0,L=O&&O.anatomicalId?O.anatomicalId:void 0,b=O&&O.displayLabels?O.displayLabels:void 0,B=O&&"renderOrder"in O?O.renderOrder:void 0;const V=new ft;V.setDuration(e.getDuration()),V.groupName=U;let R=()=>{--this.toBeDownloaded,M!=null&&typeof M=="function"&&M(V)};++this.toBeDownloaded,m?V.load(P,C,R,m,b):V.load(P,ye(C),R,m,b),V.setAnatomicalId(L),V.setRenderOrder(B),T.addZincObject(V)};this.loadGlyphsetURL=(T,C,U,M,O,k)=>{(k&&k.isInline?k.isInline:!1)?a(T,U,M,O,k)(C):i.load(C,a(T,U,M,O,k),this.onProgress(C),this.onError(O),k.loaderOptions)};const u=(T,C,U,M,O,k,P)=>(m,L)=>{const b=new Te;let B=new S.PointsMaterial({alphaTest:.5,size:10,sizeAttenuation:!1});L&&L[0]&&(1>L[0].opacity&&(B.transparent=!0),B.opacity=L[0].opacity,B.color=L[0].color,B.morphTargets=C,B.vertexColors=L[0].vertexColors);let V={};V.localTimeEnabled=C,V.localMorphColour=U,b&&(b.createMesh(m,B,V),b.setName(M),b.setAnatomicalId(O),T.addZincObject(b),b.setDuration(e.getDuration()),b.setRenderOrder(k)),m.dispose(),--this.toBeDownloaded,P!=null&&typeof P=="function"&&P(b)};this.loadSTL=(T,C,U,M)=>{this.toBeDownloaded+=1;const O=Se.defaultMaterialColor,k=Se.defaultOpacity,P=new Mi;P.crossOrigin="Anonymous",P.load(ye(C),h(T,O,k,!1,!1,U,void 0,void 0,void 0,M))},this.loadOBJ=(T,C,U,M)=>{this.toBeDownloaded+=1;const O=Se.defaultMaterialColor,k=Se.defaultOpacity,P=new wi;P.crossOrigin="Anonymous",P.load(ye(C),h(T,O,k,!1,!1,U,void 0,void 0,void 0,M))};const f=(T,C,U,M,O,k,P)=>{this.toBeDownloaded+=1;const m=Se.defaultMaterialColor,L=Se.defaultOpacity;let b=0,B=P&&P.isInline?P.isInline:!1,V=P&&P.fileFormat?P.fileFormat:void 0,R=P&&P.anatomicalId?P.anatomicalId:void 0,z=P&&"renderOrder"in P?P.renderOrder:void 0;U!=null&&(b=!!U);let Z=0;M!=null&&(Z=!!M);let E=i;if(V!==void 0){if(V=="STL")E=new Mi;else if(V=="OBJ"){E=new wi,E.crossOrigin="Anonymous",E.load(C,objloader(T,m,L,b,Z,O,R,k),this.onProgress(C),this.onError,P.loaderOptions);return}}if(B){const $=i.parse(C);h(T,m,L,b,Z,O,R,z,P,k)($.geometry,$.materials)}else E.crossOrigin="Anonymous",i.load(C,h(T,m,L,b,Z,O,R,z,P,k),this.onProgress(C),this.onError(k),P.loaderOptions)},l=function(T,C,U){let M=0;return O=>{if(M=M+1,O&&C!=null&&typeof C=="function"&&C(O),M==T&&(t===!1&&e.viewAll(),U!=null&&typeof U=="function")){U();let k=e.getZincCameraControls();k&&k.calculateMaxAllowedDistance(e)}}};this.loadPointsetURL=(T,C,U,M,O,k,P)=>{let m=0;this.toBeDownloaded+=1,U!=null&&(m=!!U);let L=0;M!=null&&(L=!!M);let b=P&&P.isInline?P.isInline:!1,B=P&&P.anatomicalId?P.anatomicalId:void 0,V=P&&"renderOrder"in P?P.renderOrder:void 0;if(b){const R=i.parse(C);u(T,m,L,O,B,V,k)(R.geometry,R.materials)}else i.load(C,u(T,m,L,O,B,V,k),this.onProgress(C),this.onError(k),P.loaderOptions)};const c=(T,C,U,M,O,k)=>{let P=k&&k.isInline?k.isInline:void 0,m=k&&k.anatomicalId?k.anatomicalId:void 0,L=k&&"renderOrder"in k?k.renderOrder:void 0,b;if(U){if(C&&U.images&&U.images.source){const B=U.images.source;for(let V=0;V<B.length;V++){const R=Pe(B[V],C);U.images.source[V]=R}}if(U.type==="slides"&&(b=new Ee),b){b.groupName=M;let B=()=>{T.addZincObject(b),--this.toBeDownloaded,O!=null&&typeof O=="function"&&O(b)};++this.toBeDownloaded,b.load(U,B,P),b.setAnatomicalId(m),b.setRenderOrder(L)}}};this.loadTextureURL=(T,C,U,M,O)=>{if(O&&O.isInline?O.isInline:!1)c(T,void 0,C,U,M,O);else{const P=ye(C);fetch(P).then(m=>{if(!m.ok)throw new Error(`HTTP error! status: ${m.status}`);const L=m.url||new URL(P).href;return m.json().then(b=>({textureData:b,referenceURL:L}))}).then(({textureData:m,referenceURL:L})=>{c(T,L,m,U,M,O)}).catch(m=>{console.error(`Fetch failed for texture URL: ${P}`,m)})}};const d=(T,C,U,M,O,k,P,m,L,b,B)=>{let V={};V.colour=U,V.opacity=M,V.localTimeEnabled=O,V.localMorphColour=k;const R=new Fe;if(R.createMesh(C,m,V),R.getMorph())return R.setName(L),R.setRenderOrder(b),R.setAnatomicalId(B),T&&T.addZincObject(R),R.setDuration(e.getDuration()),R.videoHandler&&e.setVideoHandler(R.videoHandler),R},h=(T,C,U,M,O,k,P,m,L,b)=>(B,V)=>{let R;V&&V[0]&&(R=V[0]);const z=d(T,B,C,U,M,O,void 0,R,k,m,P);if(L.lod&&L.lod.levels)for(const[Z,E]of Object.entries(L.lod.levels))z.addLOD(i,Z,E.URL,E.Index,L.lod.preload);--this.toBeDownloaded,B.dispose(),b!=null&&typeof b=="function"&&b(z)},p=T=>{const C=/P(?:(\d+)Y)?(?:(\d+)M)?(?:(\d+)W)?(?:(\d+)D)?(?:T(?:(\d+)H)?(?:(\d+)M)?(?:(\d+)S)?)?$/,[,U,M,O,k,P,m,L]=T.match(C);return{years:U,months:M,weeks:O,days:k,hours:P,mins:m,secs:L}};this.loadSettings=T=>{if(T){if(T.Duration){const C=p(T.Duration);e.setDurationFromObject(C)}if(T.OriginalDuration){const C=p(T.OriginalDuration);e.setOriginalDurationFromObject(C)}if(T.TimeStamps)for(const C in T.TimeStamps){const U=p(T.TimeStamps[C]);e.addMetadataTimeStamp(C,U)}}};const w=(T,C,U,M,O)=>{if(U){let k,P=!1;U.URL?(k=U.URL,C&&(k=Pe(k,C))):U.Inline&&(k=U.Inline.URL,P=!0);const m={};if(U.LOD&&U.LOD.Levels){m.preload=!!U.LOD.Preload,m.levels={};for(const[B,V]of Object.entries(U.LOD.Levels))m.levels[B]={},m.levels[B].URL=Pe(V.URL,C),m.levels[B].Index=V.Index}let L=U.GroupName;(L===void 0||L==="")&&(L="_Unnamed");let b={loaderOptions:{index:U.Index},isInline:P,fileFormat:U.FileFormat,anatomicalId:U.AnatomicalId,compression:U.compression,tubeLines:U.tubeLines,lod:m,renderOrder:M};switch(U.Type){case"Surfaces":f(T,k,U.MorphVertices,U.MorphColours,L,O,b);break;case"Glyph":let B;P?B=U.Inline.GlyphGeometriesURL:(B=U.GlyphGeometriesURL,B=Pe(U.GlyphGeometriesURL,C)),U.DisplayLabels&&(b.displayLabels=!0),b.loaderOptions.isGlyphsets=!0,this.loadGlyphsetURL(T,k,B,L,O,b);break;case"Points":this.loadPointsetURL(T,k,U.MorphVertices,U.MorphColours,L,O,b);break;case"Lines":this.loadLinesURL(T,k,U.MorphVertices,U.MorphColours,L,O,b);break;case"Texture":this.loadTextureURL(T,k,L,O,b);break}}},y=(T,C,U)=>{if(C){let M,O=!1;switch(C.URL?(M=C.URL,T&&(M=Pe(C.URL,T))):C.Inline&&(M=C.Inline.URL,O=!0),C.Type){case"View":O?(e.setupMultipleViews("default",{default:M}),t=!0,U!=null&&typeof U=="function"&&U()):this.loadViewURL(M,U);break;case"Settings":this.loadSettings(C);break}}};this.loadGLTF=(T,C,U,M,O)=>{new As().load(e,T,C,U,M,O)};let g=(T,C,U,M)=>{if(U.Primitives&&U.Primitives.forEach(O=>{let k=1;O.Order&&(k=O.Order),w(T,C,O,k,M)}),U.Transformation&&T.setTransformation(U.Transformation),U.Children)for(const[O,k]of Object.entries(U.Children)){const P=T.findOrCreateChildFromPath(O);P&&g(P,C,k,M)}},_=(T,C)=>{var P,m;let U=T;const M=(P=C==null?void 0:C.enabled)==null?void 0:P.include,O=(m=C==null?void 0:C.enabled)==null?void 0:m.exclude,k=C==null?void 0:C.tubeLines;return(M!=null&&M.length||O!=null&&O.length)&&(M&&(U=T.filter(L=>{if(L.Type==="View")return!0;for(let b=0;b<M.length;b++)if(Nt(L.RegionPath,L.GroupName,M[b]))return!0;return!1})),O&&(U=U.filter(L=>{if(L.Type==="View")return!0;for(let b=0;b<O.length;b++)if(Nt(L.RegionPath,L.GroupName,O[b]))return!1;return!0}))),k&&U.forEach(L=>{L.Type==="Lines"&&(L.tubeLines=!0)}),U},A=(T,C)=>Array.isArray(T)?_(T,C):T,N=(T,C)=>{if(Array.isArray(T)){let U=0;for(let M=0;M<T.length;M++)T[M].Type&&(C&&T[M].Type==="View"||T[M].Type==="Surfaces"||T[M].Type==="Glyph"||T[M].Type==="Points"||T[M].Type==="Lines"||T[M].Type==="Texture")&&U++;return U}return 0},I=T=>{let C=T.Primitives?N(T.Primitives,!1):0;return T.Children&&Object.values(T.Children).forEach(U=>{C+=I(U)}),C},D=T=>{if(Array.isArray(T))return N(T,!0);if(typeof T=="object"&&T!==null&&T.Version==="2.0")return I(T.Regions)},F=(T,C,U,M,O)=>{let k=T;U.RegionPath&&U.RegionPath!==""&&(k=T.findOrCreateChildFromPath(U.RegionPath)),w(k,C,U,M*2,O)},q=(T,C,U,M,O,k)=>{const P=A(C,k);let m=D(P),L=new l(m,M,O);for(let b=0;b<C.length;b++)y(U,P[b],L);for(let b=0;b<C.length;b++)F(T,U,P[b],b,L)},G=(T,C,U,M,O)=>{let k=D(C),P=new l(k,M,O);C.Settings&&this.loadSettings(C.Settings),C.Views&&r(U,C.Views),C.Regions&&g(T,U,C.Regions,P)};this.loadMetadataURL=(T,C,U,M,O)=>{const k=ye(C);fetch(k).then(P=>{if(!P.ok)throw new Error(`HTTP error! status: ${P.status}`);const m=P.url||new URL(k).href;return P.json().then(L=>({metadata:L,referenceURL:m}))}).then(({metadata:P,referenceURL:m})=>{e.resetMetadata(),e.resetDuration(),t=!1,Array.isArray(P)?q(T,P,m,U,M,O):typeof P=="object"&&P!==null&&P.Version==="2.0"&&G(T,P,m,U,M)}).catch(P=>{console.error(`Fetch failed for URL: ${k}`,P)})}};let Vs=0;const ks=function(){return"sc"+Vs++},Si=function(){return{Duration:"6 secs",OriginalDuration:"-",TimeStamps:{}}},Is=6e3,Ct=function(n,e){const t=n;let s,i,r=new Ps(this),o,a={},u=0,f={},l=0;const c=new S.Scene,d=new S.Scene,h=new di(void 0,this);c.add(h.getGroup());const p=new S.Group;c.add(p),this.directionalLight=void 0,this.ambient=void 0,this.camera=void 0;let w=6e3,y;this.sceneName=void 0;let g=!1,_;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 A={x:0,y:0},N=Si(),I=new S.Vector2,D=[];this.forcePickableObjectsUpdate=!1,this.uuid=ks();let F=new oi(this);F.disable(),c.add(F.group);let q={main:[],mini:[]};const G=new S.Vector3(0,0,0),T=()=>t?typeof t.clientWidth<"u"?t.clientWidth:t.width:0,C=()=>t?typeof t.clientHeight<"u"?t.clientHeight:t.height:0;this.getDownloadProgress=()=>r.getDownloadProgress(),this.onWindowResize=()=>{const m=C();this.camera.aspect=T()/m,this.camera.updateProjectionMatrix(),this.minimapScissor.updateRequired=!0,y.onResize(),y.calculateHeightPerPixelAtZeroDepth(m)},this.resetView=()=>{this.onWindowResize(),y.resetView()},this.changeZoomByScrollRateUnit=m=>{y.changeZoomByScrollRateUnit(m)},(()=>{this.camera=new S.PerspectiveCamera(40,T()/C(),0,10),this.ambient=new S.AmbientLight(16777215,.2),c.add(this.ambient),this.directionalLight=new S.DirectionalLight(16777215,.8),c.add(this.directionalLight),y=new Ht(this.camera,e.domElement,e,this),y.setDirectionalLight(this.directionalLight),y.resetView(),o=new as(this)})(),this.loadView=m=>{const L=new Ie;return L.setFromObject(m),y.setCurrentCameraSettings(L),!0},this.setupMultipleViews=(m,L)=>{for(const[b,B]of Object.entries(L)){const V=new Ie;V.setFromObject(B),y.addViewport(b,V)}y.setDefaultViewport(m)},this.getBoundingBox=()=>h.getBoundingBox(!0),this.viewAllWithBoundingBox=m=>{if(m){const L=y.getViewportFromBoundingBox(m,1);y.setCurrentCameraSettings(L),y.calculateHeightPerPixelAtZeroDepth(C()),F.markerUpdateRequired=!0}},this.viewAll=()=>{const m=this.getBoundingBox();this.viewAllWithBoundingBox(m),F.markerUpdateRequired=!0},this.forEachGeometry=m=>{h.forEachGeometry(m,!0)},this.forEachGlyphset=m=>{h.forEachGlyphset(m,!0)},this.forEachPointset=m=>{h.forEachPointset(m,!0)},this.forEachLine=m=>{h.forEachLine(m,!0)},this.findGeometriesWithGroupName=m=>h.findGeometriesWithGroupName(m,!0),this.findPointsetsWithGroupName=m=>h.findPointsetsWithGroupName(m,!0),this.findGlyphsetsWithGroupName=m=>h.findGlyphsetsWithGroupName(m,!0),this.findLinesWithGroupName=m=>h.findLinesWithGroupName(m,!0),this.findObjectsWithGroupName=m=>h.findObjectsWithGroupName(m,!0),this.findObjectsWithAnatomicalId=m=>h.findObjectsWithAnatomicalId(m,!0),this.getBoundingBoxOfZincObjects=m=>{let L;for(let b=0;b<m.length;b++){let B=m[b].getBoundingBox();B&&(L?L.union(B):L=B)}return L},this.vectorToScreenXY=m=>{m.project(this.camera);let L=T(),b=C(),B=L/2,V=b/2;return m.x=m.x*B+B,m.y=-(m.y*V)+V,m},this.getObjectsScreenXY=m=>{if(m&&m.length>0){let L=this.getBoundingBoxOfZincObjects(m);const b=new S.Vector3;return L.getCenter(b),this.vectorToScreenXY(b)}},this.getNamedObjectsScreenXY=m=>{let L=this.findObjectsWithGroupName(m);return this.getObjectsScreenXY(L)},this.addZincObject=m=>{m&&(h.addZincObject(m),y&&y.calculateMaxAllowedDistance(this))},this.loadGlyphsetURL=(m,L,b,B)=>{r.loadGlyphsetURL(h,m,L,b,B)},this.loadPointsetURL=(m,L,b,B,V)=>{r.loadPointsetURL(h,m,L,b,B,V)},this.loadLinesURL=(m,L,b,B,V)=>{r.loadLinesURL(h,m,L,b,B,V)},this.loadSTL=(m,L,b)=>{r.loadSTL(h,m,L,b)},this.loadOBJ=(m,L,b)=>{r.loadOBJ(h,m,L,b)},this.loadMetadataURL=(m,L,b,B)=>{r.loadMetadataURL(h,m,L,b,B)},this.loadModelsURL=(m,L,b,B,V,R)=>{r.loadModelsURL(h.urls,L,b,B,V,R)},this.loadViewURL=m=>{r.loadViewURL(m)},this.loadFromViewURL=(m,L)=>{r.loadFromViewURL(m,L)},this.loadGLTF=(m,L,b,B)=>{r.loadGLTF(h,m,L,b,B)},this.updateDirectionalLight=()=>{y.updateDirectionalLight()},this.addObject=m=>{c.add(m)},this.removeObject=m=>{c.remove(m)},this.getCurrentTime=()=>{if(i!=null)return i.getCurrentTime(w);const m=h.getCurrentTime();return m!==-1?m:0},this.setMorphsTime=m=>{i!=null&&i.setMorphTime(m,w),h.setMorphTime(m,!0)},this.isTimeVarying=()=>i&&i.video&&!i.video.error?!0:h.isTimeVarying(),this.renderGeometries=(m,L,b)=>{let B={};if(B.camera=y,B.displayMarkers=this.displayMarkers,B.markerCluster=F,B.markersList=F.markers,B.ndcToBeUpdated=!1,b&&(B.markerCluster.markerUpdateRequired=!0),i)if(i.isReadyToPlay()){b?i.video.play():i.video.pause();const V=i.video.currentTime/i.getVideoDuration()*w;r.toBeDownloaded==0?(y.setTime(V),B.ndcToBeUpdated=y.update(0),B.ndcToBeUpdated&&y.calculateHeightPerPixelAtZeroDepth(C()),h.setMorphTime(V,!0),h.renderGeometries(0,0,b,y,B,!0)):y.update(0)}else myPlayRate=0;else r.toBeDownloaded==0?(B.ndcToBeUpdated=y.update(L),B.ndcToBeUpdated&&y.calculateHeightPerPixelAtZeroDepth(C()),h.renderGeometries(m,L,b,y,B,!0)):y.update(0)},this.getThreeJSScene=()=>c,this.setVideoHandler=m=>{i||(i=m)},this.setAdditionalScenesGroup=m=>{c.add(m)};let M=(m,L,b,B,V,R,z)=>{let Z=0,E=0;return m.includes("top")?E=z-V-b:m.includes("bottom")?E=b:E=Math.floor((z-V)/2),m.includes("left")?Z=L:m.includes("right")?Z=R-L-B:Z=Math.floor((R-B)/2),{x:Z,y:E}};const O=m=>{(this.displayMinimap||this.displayMiniAxes)&&(m.setScissorTest(!0),m.getSize(I),this.minimapScissor.updateRequired&&(A=M(this.minimapScissor.align,this.minimapScissor.x_offset,this.minimapScissor.y_offset,this.minimapScissor.width,this.minimapScissor.height,I.x,I.y),this.minimapScissor.updateRequired=!1),m.setScissor(A.x,A.y,this.minimapScissor.width,this.minimapScissor.height),m.setViewport(A.x,A.y,this.minimapScissor.width,this.minimapScissor.height),o.updateCamera(),this.displayMiniAxes?m.render(d,o.camera):(c.add(o.mask),m.render(c,o.camera),c.remove(o.mask)),m.setScissorTest(!1),m.setViewport(0,0,I.x,I.y))};this.render=m=>{this.autoClearFlag&&m.clear(),g&&_?_.render(c,this.camera):(m.render(c,this.camera),O(m))},this.setInteractiveControlEnable=m=>{m==!0?y.enable():y.disable()},this.getZincCameraControls=()=>y,this.getThreeJSScene=()=>c,this.setDuration=m=>{h.setDuration(m),w=m,y.setPathDuration(m),r.duration=m},this.getDuration=()=>w,this.setStereoEffectEnable=m=>{m==!0&&(_||(_=new ri(e))),e.setSize(T(),C()),this.camera.updateProjectionMatrix(),g=m},this.objectIsInScene=m=>h.objectIsInRegion(m,!0),this.alignBoundingBoxToCameraView=(m,L)=>{if(m){m.getCenter(G);const b=this.getZincCameraControls().getCurrentViewport(),B=new S.Vector3(b.targetPosition[0],b.targetPosition[1],b.targetPosition[2]),V=new S.Vector3(b.eyePosition[0],b.eyePosition[1],b.eyePosition[2]),R=new S.Vector3,z=new S.Vector3;R.subVectors(B,V).normalize(),z.subVectors(B,G).normalize();const Z=new S.Vector3;Z.crossVectors(R,z);const E=R.angleTo(z);L>0?(this.getZincCameraControls().rotateCameraTransition(Z,E,L),this.getZincCameraControls().enableCameraTransition()):this.getZincCameraControls().rotateAboutLookAtpoint(Z,E),F.markerUpdateRequired=!0}},this.translateBoundingBoxToCameraView=(m,L,b)=>{if(m){const B=this.getZincCameraControls().getCurrentViewport(),V=this.getZincCameraControls().getViewportFromBoundingBox(m,L);b>0&&(this.getZincCameraControls().cameraTransition(B,V,b),this.getZincCameraControls().enableCameraTransition()),F.markerUpdateRequired=!0}},this.alignObjectToCameraView=(m,L)=>{if(this.objectIsInScene(m)){const b=m.getBoundingBox();this.alignBoundingBoxToCameraView(b,L)}},this.setCameraTargetToObject=m=>{if(this.objectIsInScene(m)){const L=m.getBoundingBox(),b=this.getZincCameraControls().getCurrentViewport();L.getCenter(G);const B=new S.Vector3(b.targetPosition[0],b.targetPosition[1],b.targetPosition[2]),V=new S.Vector3(b.eyePosition[0],b.eyePosition[1],b.eyePosition[2]),R=new S.Vector3,z=new S.Vector3;R.subVectors(V,B),z.addVectors(G,R),b.eyePosition[0]=z.x,b.eyePosition[1]=z.y,b.eyePosition[2]=z.z,b.targetPosition[0]=G.x,b.targetPosition[1]=G.y,b.targetPosition[2]=G.z,this.getZincCameraControls().setCurrentCameraSettings(b),F.markerUpdateRequired=!0}},this.isStereoEffectEnable=()=>g,this.removeZincObject=m=>{h.removeZincObject(m),y&&y.calculateMaxAllowedDistance(this),F.markerUpdateRequired=!0},this.updatePickableThreeJSObjects=()=>{D.length=0,F.isEnabled&&D.push(F.group),h.getPickableThreeJSObjects(D,!0),this.forcePickableObjectsUpdate=!1},this.getPickableThreeJSObjects=()=>((this.forcePickableObjectsUpdate||h.checkPickableUpdateRequred(!0))&&this.updatePickableThreeJSObjects(),D),this.getNormalisedMinimapCoordinates=(m,L)=>{if(this.displayMinimap){const b=new S.Vector2;m.getSize(b);let B=b.y-L.clientY;if(A.x+this.minimapScissor.width>L.clientX&&L.clientX>A.x&&A.y+this.minimapScissor.height>B&&B>A.y){let V=(L.clientX-A.x)/this.minimapScissor.width*2-1,R=(B-A.y)/this.minimapScissor.height*2-1;return{x:V,y:R}}}},this.getMinimapDiffFromNormalised=(m,L)=>{if(o)return o.getDiffFromNormalised(m,L)},this.isWebGL2=()=>e.isWebGL2(),this.clearAll=()=>{F.clear(),h.clear(!0),this.clearZincObjectAddedCallbacks(),this.clearZincObjectRemovedCallbacks(),r.toBeDwonloaded=0,y&&y.calculateMaxAllowedDistance(this),F.markerUpdateRequired=!0},this.addMetadataTimeStamp=(m,L)=>{N.TimeStamps[m]=P(L)},this.getMetadataTag=m=>N[m],this.getMetadata=()=>N,this.setMetadataTag=(m,L)=>{N[m]=L},this.removeMetadataTag=m=>{delete N[m]},this.resetMetadata=()=>{N=Si()},this.resetDuration=()=>{this.setDuration(Is)};const k=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(" "),P=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 L=k(m),b=P(m);this.setMetadataTag("Duration",L),this.setDuration(b)},this.setOriginalDurationFromObject=m=>{const L=k(m);this.setMetadataTag("OriginalDuration",L)},this.exportGLTF=m=>new ws(this).exportGLTF(m),this.getRootRegion=()=>h,this.createLines=(m,L,b,B)=>{let V=h.findChildFromPath(m);return V===void 0&&(V=h.createChildFromPath(m)),V.createLines(L,b,B)},this.createPoints=(m,L,b,B,V)=>{let R=h.findChildFromPath(m);return R===void 0&&(R=h.createChildFromPath(m)),R.createPoints(L,b,B,V)},this.addZincObjectAddedCallbacks=m=>(u=u+1,a[u]=m,u),this.addZincObjectRemovedCallbacks=m=>(l=l+1,f[l]=m,l),this.removeZincObjectAddedCallbacks=m=>{m in u&&delete a[m]},this.removeZincObjectRemovedCallbacks=m=>{m in l&&delete f[m]},this.clearZincObjectAddedCallbacks=()=>{a={},u=0},this.clearZincObjectRemovedCallbacks=()=>{f={},l=0},this.triggerObjectAddedCallback=m=>{for(let L in a)a.hasOwnProperty(L)&&a[L](m)},this.triggerObjectRemovedCallback=m=>{for(let L in f)f.hasOwnProperty(L)&&f[L](m)},this.addTemporaryPoints=(m,L)=>{const b=nt(m.length,m);let B=new S.PointsMaterial({alphaTest:.5,size:15,color:L,sizeAttenuation:!1});const V=Ut();B.map=V;let R=new gt(b,B);return p.add(R),R},this.addTemporaryLines=(m,L)=>{const b=nt(m.length,m),B=new S.LineBasicMaterial({color:L}),V=new Xe(b,B);return p.add(V),V},this.enableFrustumDisplay=()=>{this.camera&&!s&&(s=new S.CameraHelper(this.camera),c.add(s))},this.disableFrustumDisplay=()=>{s&&(c.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,L,b,B,V,R=void 0)=>{let z=h.findChildFromPath(m);z===void 0&&(z=h.createChildFromPath(m));const Z=R||this.getBoundingBox();G.set(0,0,0);const E=G.subVectors(Z.max,Z.min),$=new S.BoxGeometry(E.x,E.y,E.z),H=z.createGeometryFromThreeJSGeometry(L,$,b,B,V,1e4);return E.addVectors(Z.min,Z.max).multiplyScalar(.5),H.setPosition(E.x,E.y,E.z),H},this.addSlicesPrimitive=(m,L,b,B,V,R=void 0)=>{if(L&&L.length>=3&&b&&b.length>=3){let z=h.findChildFromPath(m);z===void 0&&(z=h.createChildFromPath(m));const Z=R||this.getBoundingBox();G.set(0,0,0);const E=G.subVectors(Z.max,Z.min),$=["x","y","z"],H=[];let K=0;return $.forEach(ee=>{let re;switch(ee){case"x":re=new S.PlaneGeometry(E.z,E.y),re.rotateY(Math.PI/2);break;case"y":re=new S.PlaneGeometry(E.x,E.z),re.rotateX(Math.PI/2);break;case"z":re=new S.PlaneGeometry(E.x,E.y);break}const Q=z.createGeometryFromThreeJSGeometry(L[K],re,b[K],B,V,10001);H.push(Q),K++}),E.addVectors(Z.min,Z.max).multiplyScalar(.5),H.forEach(ee=>{ee.setPosition(E.x,E.y,E.z)}),H}},this.enableMarkerCluster=m=>{m?(F.markerUpdateRequired=!0,F.enable()):(F.markerUpdateRequired=!1,F.disable()),this.forcePickableObjectsUpdate=!0},this.destroyAxisDisplay=()=>{this.displayMiniAxes=!1,q.main&&(this.enableAxisDisplay(!1,!1),q.main.forEach(m=>{m.dispose&&m.dispose()})),q.mini&&(this.enableAxisDisplay(!1,!0),q.mini.forEach(m=>{m.dispose&&m.dispose()})),q={main:[],mini:[]}},this.createAxisDisplay=(m=!1)=>{this.destroyAxisDisplay();const L=[{name:"x",dir:new S.Vector3(1,0,0),colour:"red",hex:16733525},{name:"y",dir:new S.Vector3(0,1,0),colour:"green",hex:5635925},{name:"z",dir:new S.Vector3(0,0,1),colour:"blue",hex:5592575}],b=this.getBoundingBox(),B=b.min.distanceTo(b.max);let V=new S.Vector3(0,0,0);m&&V.copy(b.min),L.forEach(R=>{const z=new S.ArrowHelper(R.dir,V,B,R.hex);q.main.push(z);const Z=new S.ArrowHelper(R.dir,b.getCenter(G),B/2,R.hex);q.mini.push(Z);const E=ot(R.name,.036,R.colour,"Asap",120,700),$=R.dir.clone().multiplyScalar(B).add(V);E.position.set($.x,$.y,$.z),q.main.push(E)})},this.enableAxisDisplay=(m,L=!1)=>{var b;L&&((b=q==null?void 0:q.mini)!=null&&b.length)?(this.displayMiniAxes=m,q.mini.forEach(B=>{m?d.add(B):d.remove(B)})):!L&&q.main&&q.main.forEach(B=>{m?c.add(B):c.remove(B)})}},Rs=function(n){let e=n,t,s;const i=new S.Clock(!1);this.playAnimation=!0;let r=1e3,o={},a=0,u={},f=0,l={},c=0,d={},h=0,p,w,y,g,_=[],A=[],N=new S.Group,I,D,F=!1,q=!1;this.getDrawingWidth=()=>e?e.clientWidth:I?typeof I.clientWidth<"u"?Math.round(I.clientWidth):Math.round(I.width):0,this.getDrawingHeight=()=>e?e.clientHeight:I?typeof I.clientHeight<"u"?Math.round(I.clientHeight):Math.round(I.height):0,this.onWindowResize=()=>{s.onWindowResize();const M=this.getDrawingWidth(),O=this.getDrawingHeight();if(t!=null){let k;e?(k=e.getBoundingClientRect(),t.setSize(M,O)):I&&(typeof I.getBoundingClientRect<"u"&&(k=I.getBoundingClientRect(),I.width=M,I.height=O),t.setSize(M,O,!1)),k&&(k.left,k.top);const P=new S.Vector2;t.getSize(P),P.x,P.y}},this.initialiseVisualisation=M=>{if(!q){if(M=M||{},M.antialias===void 0){let P=!1;try{/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)&&(P=!0)}catch{P=!1}P?M.antialias=!1:M.antialias=!0}M.canvas&&(e=void 0,I=M.canvas),t=new S.WebGLRenderer(M),e!==void 0&&e.appendChild(t.domElement),t.setClearColor(16777215,1),I&&I.style&&(I.style.height="100%",I.style.width="100%");const O=t.domElement;O.addEventListener("webglcontextlost",G,!1),O.addEventListener("webglcontextrestored",T,!1),t.autoClear=!1;const k=this.createScene("default");this.setCurrentScene(k),q=!0}};const G=M=>{M.preventDefault();for(let O of Object.keys(o))l.hasOwnProperty(O)&&l[O].call()},T=M=>{M.preventDefault();for(let O of Object.keys(o))d.hasOwnProperty(O)&&d[O].call()};this.getCurrentScene=()=>s,this.setCurrentScene=M=>{if(M){this.removeActiveScene(M);const O=s;s=M,O&&O.setInteractiveControlEnable(!1),s.setInteractiveControlEnable(!0),s.setAdditionalScenesGroup(N),this.onWindowResize()}},this.getSceneByName=M=>_[M],this.createScene=M=>{if(_[M]==null){let O;return I?O=new Ct(I,t):O=new Ct(e,t),_[M]=O,O.sceneName=M,O}},this.resetView=()=>{s.resetView()},this.viewAll=()=>{if(s){const M=s.getBoundingBox();if(M){for(let O=0;O<A.length;O++){const k=A[O].getBoundingBox();k&&M.union(k)}s.viewAllWithBoundingBox(M)}}},this.loadModelsURL=(M,O,k,P,m,L)=>{s.loadModelsURL(M,O,k,P,m,L)},this.loadViewURL=M=>{s.loadViewURL(M)},this.loadFromViewURL=(M,O)=>{s.loadFromViewURL(M,O)},this.updateDirectionalLight=()=>{s.updateDirectionalLight()};let C=()=>{F?(p=requestAnimationFrame(C),this.render()):(cancelAnimationFrame(p),p=void 0)};this.stopAnimate=()=>{F&&(i.stop(),F=!1)},this.animate=()=>{F||(i.start(),F=!0,C())},this.addContextLostCallbackFunction=M=>(c=c+1,l[c]=M,c),this.removeContextLostCallbackFunction=M=>{M in l&&delete l[M]},this.addContextRestoredCallbackFunction=M=>(h=h+1,d[h]=M,h),this.removeContextRestoredCallbackFunction=M=>{M in h&&delete h[M]},this.addPreRenderCallbackFunction=M=>(a=a+1,o[a]=M,a),this.removePreRenderCallbackFunction=M=>{M in o&&delete o[M]},this.addPostRenderCallbackFunction=M=>(f=f+1,u[f]=M,f),this.removePostRenderCallbackFunction=M=>{M in u&&delete u[M]},this.getPlayRate=()=>r,this.setPlayRate=M=>{r=M},this.getCurrentTime=()=>s.getCurrentTime(),this.setMorphsTime=M=>{s.setMorphsTime(M)},this.getZincGeometryByID=M=>s.getZincGeometryByID(M),this.addToScene=M=>{s.addObject(M)},this.addToOrthoScene=M=>{if(y==null&&(y=new S.Scene),w==null){const O=this.getDrawingWidth(),k=this.getDrawingHeight();w=new S.OrthographicCamera(-O/2,O/2,k/2,-k/2,1,10),w.position.z=10}y.add(M)};const U=M=>O=>{O.needsUpdate=!0;const k=new S.SpriteMaterial({map:O}),P=k.map.image.width,m=k.map.image.height;M.material=k,M.scale.set(P,m,1);const L=this.getDrawingWidth(),b=this.getDrawingHeight();M.position.set((L-P)/2,(-b+m)/2,1),this.addToOrthoScene(M)};this.addLogo=()=>{g=new S.Sprite,S.ImageUtils.loadTexture("images/abi_big_logo_transparent_small.png",void 0,U(g))},this.render=()=>{D||(e?e.clientWidth>0&&e.clientHeight>0&&(D=new Ot.ResizeSensor(e,this.onWindowResize)):I&&I.width>0&&I.height>0&&(D=new Ot.ResizeSensor(I,this.onWindowResize)));const M=i.getDelta();s.renderGeometries(r,M,this.playAnimation);for(let O=0;O<A.length;O++)A[O].renderGeometries(r,M,this.playAnimation);w!=null&&y!=null&&(t.clearDepth(),t.render(y,w));for(let O of Object.keys(o))o.hasOwnProperty(O)&&o[O].call();s.render(t);for(let O of Object.keys(u))u.hasOwnProperty(O)&&u[O].call()},this.forceContextLoss=()=>{t.forceContextLoss()},this.forceContextRestore=()=>{t.forceContextRestore()},this.getThreeJSRenderer=()=>t,this.isSceneActive=M=>{if(s===M)return!0;for(let O=0;O<A.length;O++)if(A[O]===M)return!0;return!1},this.addActiveScene=M=>{this.isSceneActive(M)||(A.push(M),N.add(M.getThreeJSScene()))},this.removeActiveScene=M=>{for(let O=0;O<A.length;O++)if(A[O]===M){A.splice(O,1),N.remove(M.getThreeJSScene());return}},this.clearAllActiveScene=()=>{for(let M=0;M<A.length;M++)N.remove(A[M].getThreeJSScene());A.splice(0,A.length)},this.dispose=()=>{F&&cancelAnimationFrame(p);for(const O in _)_.hasOwnProperty(O)&&_[O].clearAll();_=[],A=[],N=new S.Group,this.stopAnimate(),o={},a=0,u={},u=0,l={},c=0,d={},h=0,w=void 0,y=void 0,g=void 0;const M=this.createScene("default");this.setCurrentScene(M),D=void 0,t==null||t.dispose()},this.transitionScene=(M,O)=>{if(s){const k=s.getZincCameraControls(),P=M.getBoundingBox();if(P){const m=P.min.distanceTo(P.max)/2,L=(P.min.x+P.max.x)/2,b=(P.min.y+P.max.y)/2,B=(P.min.z+P.max.z)/2,R=k.getViewportFromCentreAndRadius(L,b,B,m,40,m*4),z=k.getCurrentViewport();k.cameraTransition(z,R,O),k.enableCameraTransition()}}},this.isWebGL2=()=>t?t.capabilities.isWebGL2:!1},Ds=Ni.version,Fs=function(){this.Revision=Ds,this.defaultMaterialColor=16777215,this.defaultOpacity=1,this.modelPrefix=void 0,this.Geometry=Fe,this.Glyph=Ke,this.Glyphset=ft,this.Pointset=Te,this.Label=ut,this.Lines=Ve,this.TextureArray=yt,this.TextureSlides=Ee,this.Renderer=Rs,this.Scene=Ct,this.Viewport=Ie,this.CameraControls=Ht,this.SmoothCameraTransition=ei,this.RayCaster=ti,this.CameraAutoTumble=ii,this.StereoEffect=ri,this.loadExternalFile=Tt,this.loadExternalFiles=Ri,this.THREE=S},Se=new Fs;return Se});
|
|
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+`
|
|
292
|
+
`,t+="Image Dimensions (1-8): "+this.dims[0]+", "+this.dims[1]+", "+this.dims[2]+", "+this.dims[3]+", "+this.dims[4]+", "+this.dims[5]+", "+this.dims[6]+", "+this.dims[7]+`
|
|
293
|
+
`,t+="Intent Parameters (1-3): "+this.intent_p1+", "+this.intent_p2+", "+this.intent_p3+`
|
|
294
|
+
`,t+="Intent Code = "+this.intent_code+`
|
|
295
|
+
`,t+="Datatype = "+this.datatypeCode+" ("+this.getDatatypeCodeString(this.datatypeCode)+`)
|
|
296
|
+
`,t+="Bits Per Voxel = "+this.numBitsPerVoxel+`
|
|
297
|
+
`,t+="Slice Start = "+this.slice_start+`
|
|
298
|
+
`,t+="Voxel Dimensions (1-8): "+e(this.pixDims[0])+", "+e(this.pixDims[1])+", "+e(this.pixDims[2])+", "+e(this.pixDims[3])+", "+e(this.pixDims[4])+", "+e(this.pixDims[5])+", "+e(this.pixDims[6])+", "+e(this.pixDims[7])+`
|
|
299
|
+
`,t+="Image Offset = "+this.vox_offset+`
|
|
300
|
+
`,t+="Data Scale: Slope = "+e(this.scl_slope)+" Intercept = "+e(this.scl_inter)+`
|
|
301
|
+
`,t+="Slice End = "+this.slice_end+`
|
|
302
|
+
`,t+="Slice Code = "+this.slice_code+`
|
|
303
|
+
`,t+="Units Code = "+this.xyzt_units+" ("+this.getUnitsCodeString(K.SPATIAL_UNITS_MASK&this.xyzt_units)+", "+this.getUnitsCodeString(K.TEMPORAL_UNITS_MASK&this.xyzt_units)+`)
|
|
304
|
+
`,t+="Display Range: Max = "+e(this.cal_max)+" Min = "+e(this.cal_min)+`
|
|
305
|
+
`,t+="Slice Duration = "+this.slice_duration+`
|
|
306
|
+
`,t+="Time Axis Shift = "+this.toffset+`
|
|
307
|
+
`,t+='Description: "'+this.description+`"
|
|
308
|
+
`,t+='Auxiliary File: "'+this.aux_file+`"
|
|
309
|
+
`,t+="Q-Form Code = "+this.qform_code+" ("+this.getTransformCodeString(this.qform_code)+`)
|
|
310
|
+
`,t+="S-Form Code = "+this.sform_code+" ("+this.getTransformCodeString(this.sform_code)+`)
|
|
311
|
+
`,t+="Quaternion Parameters: b = "+e(this.quatern_b)+" c = "+e(this.quatern_c)+" d = "+e(this.quatern_d)+`
|
|
312
|
+
`,t+="Quaternion Offsets: x = "+this.qoffset_x+" y = "+this.qoffset_y+" z = "+this.qoffset_z+`
|
|
313
|
+
`,t+="S-Form Parameters X: "+e(this.affine[0][0])+", "+e(this.affine[0][1])+", "+e(this.affine[0][2])+", "+e(this.affine[0][3])+`
|
|
314
|
+
`,t+="S-Form Parameters Y: "+e(this.affine[1][0])+", "+e(this.affine[1][1])+", "+e(this.affine[1][2])+", "+e(this.affine[1][3])+`
|
|
315
|
+
`,t+="S-Form Parameters Z: "+e(this.affine[2][0])+", "+e(this.affine[2][1])+", "+e(this.affine[2][2])+", "+e(this.affine[2][3])+`
|
|
316
|
+
`,t+='Intent Name: "'+this.intent_name+`"
|
|
317
|
+
`,this.extensionFlag[0]&&(t+="Extension: Size = "+this.extensionSize+" Code = "+this.extensionCode+`
|
|
318
|
+
`),t}getQformMat(){return this.convertNiftiQFormToNiftiSForm(this.quatern_b,this.quatern_c,this.quatern_d,this.qoffset_x,this.qoffset_y,this.qoffset_z,this.pixDims[1],this.pixDims[2],this.pixDims[3],this.pixDims[0])}convertNiftiQFormToNiftiSForm(e,t,s,i,n,o,a,h,f,c){var l=[[0,0,0,0],[0,0,0,0],[0,0,0,0],[0,0,0,0]],d,u=e,p=t,y=s,x,g,v;return l[3][0]=l[3][1]=l[3][2]=0,l[3][3]=1,d=1-(u*u+p*p+y*y),d<1e-7?(d=1/Math.sqrt(u*u+p*p+y*y),u*=d,p*=d,y*=d,d=0):d=Math.sqrt(d),x=a>0?a:1,g=h>0?h:1,v=f>0?f:1,c<0&&(v=-v),l[0][0]=(d*d+u*u-p*p-y*y)*x,l[0][1]=2*(u*p-d*y)*g,l[0][2]=2*(u*y+d*p)*v,l[1][0]=2*(u*p+d*y)*x,l[1][1]=(d*d+p*p-u*u-y*y)*g,l[1][2]=2*(p*y-d*u)*v,l[2][0]=2*(u*y-d*p)*x,l[2][1]=2*(p*y+d*u)*g,l[2][2]=(d*d+y*y-p*p-u*u)*v,l[0][3]=i,l[1][3]=n,l[2][3]=o,l}convertNiftiSFormToNEMA(e){var t,s,i,n,o,a,h,f,c,l,d,u,p,y,x,g,v,_,I,k,V,R,W,G,L,T,U,w,C,E,N,m,O,B;if(x=0,U=[[0,0,0],[0,0,0],[0,0,0]],w=[[0,0,0],[0,0,0],[0,0,0]],t=e[0][0],s=e[0][1],i=e[0][2],n=e[1][0],o=e[1][1],a=e[1][2],h=e[2][0],f=e[2][1],c=e[2][2],l=Math.sqrt(t*t+n*n+h*h),l===0||(t/=l,n/=l,h/=l,l=Math.sqrt(s*s+o*o+f*f),l===0))return null;if(s/=l,o/=l,f/=l,l=t*s+n*o+h*f,Math.abs(l)>1e-4){if(s-=l*t,o-=l*n,f-=l*h,l=Math.sqrt(s*s+o*o+f*f),l===0)return null;s/=l,o/=l,f/=l}if(l=Math.sqrt(i*i+a*a+c*c),l===0?(i=n*f-h*o,a=h*s-f*t,c=t*o-n*s):(i/=l,a/=l,c/=l),l=t*i+n*a+h*c,Math.abs(l)>1e-4){if(i-=l*t,a-=l*n,c-=l*h,l=Math.sqrt(i*i+a*a+c*c),l===0)return null;i/=l,a/=l,c/=l}if(l=s*i+o*a+f*c,Math.abs(l)>1e-4){if(i-=l*s,a-=l*o,c-=l*f,l=Math.sqrt(i*i+a*a+c*c),l===0)return null;i/=l,a/=l,c/=l}if(U[0][0]=t,U[0][1]=s,U[0][2]=i,U[1][0]=n,U[1][1]=o,U[1][2]=a,U[2][0]=h,U[2][1]=f,U[2][2]=c,d=this.nifti_mat33_determ(U),d===0)return null;for(T=-666,I=R=W=G=1,k=2,V=3,p=1;p<=3;p+=1)for(y=1;y<=3;y+=1)if(p!==y){for(x=1;x<=3;x+=1)if(!(p===x||y===x))for(w[0][0]=w[0][1]=w[0][2]=w[1][0]=w[1][1]=w[1][2]=w[2][0]=w[2][1]=w[2][2]=0,g=-1;g<=1;g+=2)for(v=-1;v<=1;v+=2)for(_=-1;_<=1;_+=2)w[0][p-1]=g,w[1][y-1]=v,w[2][x-1]=_,u=this.nifti_mat33_determ(w),u*d>0&&(L=this.nifti_mat33_mul(w,U),l=L[0][0]+L[1][1]+L[2][2],l>T&&(T=l,I=p,k=y,V=x,R=g,W=v,G=_))}switch(C=E=N=m=O=B="",I*R){case 1:C="X",m="+";break;case-1:C="X",m="-";break;case 2:C="Y",m="+";break;case-2:C="Y",m="-";break;case 3:C="Z",m="+";break;case-3:C="Z",m="-";break}switch(k*W){case 1:E="X",O="+";break;case-1:E="X",O="-";break;case 2:E="Y",O="+";break;case-2:E="Y",O="-";break;case 3:E="Z",O="+";break;case-3:E="Z",O="-";break}switch(V*G){case 1:N="X",B="+";break;case-1:N="X",B="-";break;case 2:N="Y",B="+";break;case-2:N="Y",B="-";break;case 3:N="Z",B="+";break;case-3:N="Z",B="-";break}return C+E+N+m+O+B}getExtensionLocation(){return K.MAGIC_COOKIE+4}getExtensionSize(e){return q.getIntAt(e,this.getExtensionLocation(),this.littleEndian)}getExtensionCode(e){return q.getIntAt(e,this.getExtensionLocation()+4,this.littleEndian)}addExtension(e,t=-1){t==-1?this.extensions.push(e):this.extensions.splice(t,0,e),this.vox_offset+=e.esize}removeExtension(e){let t=this.extensions[e];t&&(this.vox_offset-=t.esize),this.extensions.splice(e,1)}toArrayBuffer(e=!1){let i=352;if(e)for(let h of this.extensions)i+=h.esize;let n=new Uint8Array(i),o=new DataView(n.buffer);o.setInt32(0,348,this.littleEndian),o.setUint8(39,this.dim_info);for(let h=0;h<8;h++)o.setUint16(40+2*h,this.dims[h],this.littleEndian);o.setFloat32(56,this.intent_p1,this.littleEndian),o.setFloat32(60,this.intent_p2,this.littleEndian),o.setFloat32(64,this.intent_p3,this.littleEndian),o.setInt16(68,this.intent_code,this.littleEndian),o.setInt16(70,this.datatypeCode,this.littleEndian),o.setInt16(72,this.numBitsPerVoxel,this.littleEndian),o.setInt16(74,this.slice_start,this.littleEndian);for(let h=0;h<8;h++)o.setFloat32(76+4*h,this.pixDims[h],this.littleEndian);o.setFloat32(108,this.vox_offset,this.littleEndian),o.setFloat32(112,this.scl_slope,this.littleEndian),o.setFloat32(116,this.scl_inter,this.littleEndian),o.setInt16(120,this.slice_end,this.littleEndian),o.setUint8(122,this.slice_code),o.setUint8(123,this.xyzt_units),o.setFloat32(124,this.cal_max,this.littleEndian),o.setFloat32(128,this.cal_min,this.littleEndian),o.setFloat32(132,this.slice_duration,this.littleEndian),o.setFloat32(136,this.toffset,this.littleEndian),n.set(new TextEncoder().encode(this.description),148),n.set(new TextEncoder().encode(this.aux_file),228),o.setInt16(252,this.qform_code,this.littleEndian),o.setInt16(254,this.sform_code,this.littleEndian),o.setFloat32(256,this.quatern_b,this.littleEndian),o.setFloat32(260,this.quatern_c,this.littleEndian),o.setFloat32(264,this.quatern_d,this.littleEndian),o.setFloat32(268,this.qoffset_x,this.littleEndian),o.setFloat32(272,this.qoffset_y,this.littleEndian),o.setFloat32(276,this.qoffset_z,this.littleEndian);const a=this.affine.flat();for(let h=0;h<12;h++)o.setFloat32(280+4*h,a[h],this.littleEndian);if(n.set(new TextEncoder().encode(this.intent_name),328),n.set(new TextEncoder().encode(this.magic),344),e){n.set(Uint8Array.from([1,0,0,0]),348);let h=this.getExtensionLocation();for(const f of this.extensions)o.setInt32(h,f.esize,f.littleEndian),o.setInt32(h+4,f.ecode,f.littleEndian),n.set(new Uint8Array(f.edata),h+8),h+=f.esize}else n.set(new Uint8Array(4).fill(0),348);return n.buffer}};D(K,"TYPE_NONE",0),D(K,"TYPE_BINARY",1),D(K,"TYPE_UINT8",2),D(K,"TYPE_INT16",4),D(K,"TYPE_INT32",8),D(K,"TYPE_FLOAT32",16),D(K,"TYPE_COMPLEX64",32),D(K,"TYPE_FLOAT64",64),D(K,"TYPE_RGB24",128),D(K,"TYPE_INT8",256),D(K,"TYPE_UINT16",512),D(K,"TYPE_UINT32",768),D(K,"TYPE_INT64",1024),D(K,"TYPE_UINT64",1280),D(K,"TYPE_FLOAT128",1536),D(K,"TYPE_COMPLEX128",1792),D(K,"TYPE_COMPLEX256",2048),D(K,"XFORM_UNKNOWN",0),D(K,"XFORM_SCANNER_ANAT",1),D(K,"XFORM_ALIGNED_ANAT",2),D(K,"XFORM_TALAIRACH",3),D(K,"XFORM_MNI_152",4),D(K,"SPATIAL_UNITS_MASK",7),D(K,"TEMPORAL_UNITS_MASK",56),D(K,"UNITS_UNKNOWN",0),D(K,"UNITS_METER",1),D(K,"UNITS_MM",2),D(K,"UNITS_MICRON",3),D(K,"UNITS_SEC",8),D(K,"UNITS_MSEC",16),D(K,"UNITS_USEC",24),D(K,"UNITS_HZ",32),D(K,"UNITS_PPM",40),D(K,"UNITS_RADS",48),D(K,"MAGIC_COOKIE",348),D(K,"STANDARD_HEADER_SIZE",348),D(K,"MAGIC_NUMBER_LOCATION",344),D(K,"MAGIC_NUMBER",[110,43,49]),D(K,"MAGIC_NUMBER2",[110,105,49]),D(K,"EXTENSION_HEADER_SIZE",8);let ie=K;const 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)+`)
|
|
319
|
+
`,t+="Bits Per Voxel = = "+this.numBitsPerVoxel+`
|
|
320
|
+
`,t+="Image Dimensions (1-8): "+this.dims[0]+", "+this.dims[1]+", "+this.dims[2]+", "+this.dims[3]+", "+this.dims[4]+", "+this.dims[5]+", "+this.dims[6]+", "+this.dims[7]+`
|
|
321
|
+
`,t+="Intent Parameters (1-3): "+this.intent_p1+", "+this.intent_p2+", "+this.intent_p3+`
|
|
322
|
+
`,t+="Voxel Dimensions (1-8): "+e(this.pixDims[0])+", "+e(this.pixDims[1])+", "+e(this.pixDims[2])+", "+e(this.pixDims[3])+", "+e(this.pixDims[4])+", "+e(this.pixDims[5])+", "+e(this.pixDims[6])+", "+e(this.pixDims[7])+`
|
|
323
|
+
`,t+="Image Offset = "+this.vox_offset+`
|
|
324
|
+
`,t+="Data Scale: Slope = "+e(this.scl_slope)+" Intercept = "+e(this.scl_inter)+`
|
|
325
|
+
`,t+="Display Range: Max = "+e(this.cal_max)+" Min = "+e(this.cal_min)+`
|
|
326
|
+
`,t+="Slice Duration = "+this.slice_duration+`
|
|
327
|
+
`,t+="Time Axis Shift = "+this.toffset+`
|
|
328
|
+
`,t+="Slice Start = "+this.slice_start+`
|
|
329
|
+
`,t+="Slice End = "+this.slice_end+`
|
|
330
|
+
`,t+='Description: "'+this.description+`"
|
|
331
|
+
`,t+='Auxiliary File: "'+this.aux_file+`"
|
|
332
|
+
`,t+="Q-Form Code = "+this.qform_code+" ("+this.getTransformCodeString(this.qform_code)+`)
|
|
333
|
+
`,t+="S-Form Code = "+this.sform_code+" ("+this.getTransformCodeString(this.sform_code)+`)
|
|
334
|
+
`,t+="Quaternion Parameters: b = "+e(this.quatern_b)+" c = "+e(this.quatern_c)+" d = "+e(this.quatern_d)+`
|
|
335
|
+
`,t+="Quaternion Offsets: x = "+this.qoffset_x+" y = "+this.qoffset_y+" z = "+this.qoffset_z+`
|
|
336
|
+
`,t+="S-Form Parameters X: "+e(this.affine[0][0])+", "+e(this.affine[0][1])+", "+e(this.affine[0][2])+", "+e(this.affine[0][3])+`
|
|
337
|
+
`,t+="S-Form Parameters Y: "+e(this.affine[1][0])+", "+e(this.affine[1][1])+", "+e(this.affine[1][2])+", "+e(this.affine[1][3])+`
|
|
338
|
+
`,t+="S-Form Parameters Z: "+e(this.affine[2][0])+", "+e(this.affine[2][1])+", "+e(this.affine[2][2])+", "+e(this.affine[2][3])+`
|
|
339
|
+
`,t+="Slice Code = "+this.slice_code+`
|
|
340
|
+
`,t+="Units Code = "+this.xyzt_units+" ("+this.getUnitsCodeString(ie.SPATIAL_UNITS_MASK&this.xyzt_units)+", "+this.getUnitsCodeString(ie.TEMPORAL_UNITS_MASK&this.xyzt_units)+`)
|
|
341
|
+
`,t+="Intent Code = "+this.intent_code+`
|
|
342
|
+
`,t+='Intent Name: "'+this.intent_name+`"
|
|
343
|
+
`,t+="Dim Info = "+this.dim_info+`
|
|
344
|
+
`,t}toArrayBuffer(e=!1){let i=544;if(e)for(let h of this.extensions)i+=h.esize;let n=new Uint8Array(i),o=new DataView(n.buffer);o.setInt32(0,540,this.littleEndian),n.set(new TextEncoder().encode(this.magic),4),o.setInt16(12,this.datatypeCode,this.littleEndian),o.setInt16(14,this.numBitsPerVoxel,this.littleEndian);for(let h=0;h<8;h++)o.setBigInt64(16+8*h,BigInt(this.dims[h]),this.littleEndian);o.setFloat64(80,this.intent_p1,this.littleEndian),o.setFloat64(88,this.intent_p2,this.littleEndian),o.setFloat64(96,this.intent_p3,this.littleEndian);for(let h=0;h<8;h++)o.setFloat64(104+8*h,this.pixDims[h],this.littleEndian);o.setBigInt64(168,BigInt(this.vox_offset),this.littleEndian),o.setFloat64(176,this.scl_slope,this.littleEndian),o.setFloat64(184,this.scl_inter,this.littleEndian),o.setFloat64(192,this.cal_max,this.littleEndian),o.setFloat64(200,this.cal_min,this.littleEndian),o.setFloat64(208,this.slice_duration,this.littleEndian),o.setFloat64(216,this.toffset,this.littleEndian),o.setBigInt64(224,BigInt(this.slice_start),this.littleEndian),o.setBigInt64(232,BigInt(this.slice_end),this.littleEndian),n.set(new TextEncoder().encode(this.description),240),n.set(new TextEncoder().encode(this.aux_file),320),o.setInt32(344,this.qform_code,this.littleEndian),o.setInt32(348,this.sform_code,this.littleEndian),o.setFloat64(352,this.quatern_b,this.littleEndian),o.setFloat64(360,this.quatern_c,this.littleEndian),o.setFloat64(368,this.quatern_d,this.littleEndian),o.setFloat64(376,this.qoffset_x,this.littleEndian),o.setFloat64(384,this.qoffset_y,this.littleEndian),o.setFloat64(392,this.qoffset_z,this.littleEndian);const a=this.affine.flat();for(let h=0;h<12;h++)o.setFloat64(400+8*h,a[h],this.littleEndian);if(o.setInt32(496,this.slice_code,this.littleEndian),o.setInt32(500,this.xyzt_units,this.littleEndian),o.setInt32(504,this.intent_code,this.littleEndian),n.set(new TextEncoder().encode(this.intent_name),508),o.setUint8(524,this.dim_info),e){n.set(Uint8Array.from([1,0,0,0]),540);let h=this.getExtensionLocation();for(const f of this.extensions)o.setInt32(h,f.esize,f.littleEndian),o.setInt32(h+4,f.ecode,f.littleEndian),n.set(new Uint8Array(f.edata),h+8),h+=f.esize}else n.set(new Uint8Array(4).fill(0),540);return n.buffer}};D(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});
|
|
292
345
|
//# sourceMappingURL=zinc.js.map
|