zincjs 2.2.0 → 2.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/build/zinc.js CHANGED
@@ -1,6 +1,6 @@
1
- (function(e,t){typeof exports==`object`&&typeof module<`u`?module.exports=t(require("three"),require("three-spritetext"),require("css-element-queries"),require("three/examples/jsm/loaders/GLTFLoader"),require("fflate")):typeof define==`function`&&define.amd?define([`three`,`three-spritetext`,`css-element-queries`,`three/examples/jsm/loaders/GLTFLoader`,`fflate`],t):(e=typeof globalThis<`u`?globalThis:e||self,e.Zinc=t(e.THREE,e.SpriteText,e.cssElememtQueries,e.GLTFLoader,e.fflate))})(this,function(e,t,n,r,i){var a=Object.create,o=Object.defineProperty,s=Object.getOwnPropertyDescriptor,c=Object.getOwnPropertyNames,l=Object.getPrototypeOf,u=Object.prototype.hasOwnProperty,d=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=c(t),a=0,l=i.length,d;a<l;a++)d=i[a],!u.call(e,d)&&d!==n&&o(e,d,{get:(e=>t[e]).bind(null,d),enumerable:!(r=s(t,d))||r.enumerable});return e},f=(e,t,n)=>(n=e==null?{}:a(l(e)),d(t||!e||!e.__esModule||!u.call(e,`default`)?o(n,`default`,{value:e,enumerable:!0}):n,e));e=f(e,1),t=f(t,1);var p={name:`zincjs`,version:`2.2.0`,description:`ZincJS (Web-based-Zinc-Visualisation)`,type:`module`,main:`build/zinc.js`,directories:{doc:`docs`},files:[`package.json`,`LICENSE`,`README.md`,`src/*`,`build/zinc.js`,`build/zinc.js.map`,`vite.config.js`],scripts:{"build-bundle":`vite build`,"test-watch":`vitest`,test:`vitest run --reporter=junit --outputFile=test-results.xml`,"test-standard":`vitest run`,changelog:`auto-changelog -p --output CHANGELOG.md --template keepachangelog`,jsdoc:`jsdoc -c jsdoc_conf.json`,version:`npm run build-bundle;npm run jsdoc;npm run changelog; git add CHANGELOG.md docs`,"release:beta":`npm version prerelease --preid=beta; npm publish --tag beta`,"release:major":`npm version major; npm publish`,"release:minor":`npm version minor; npm publish`,"release:patch":`npm version patch; npm publish`},repository:{type:`git`,url:`git+https://github.com/alan-wu/ZincJS.git`},keywords:[`library`,`webgl`,`3d`,`zincjs`],author:`Alan Wu <alan.wu@auckland.ac.nz>`,license:`MIT`,bugs:{url:`https://github.com/alan-wu/ZincJS/issues`},homepage:`http://alan-wu.github.io/ZincJS/`,engines:{node:`>=20`},devDependencies:{"@vitest/coverage-v8":`^4.1.11`,"auto-changelog":`^2.4.0`,chai:`^4.1.0`,gl:`^8.1.6`,"happy-dom":`^20.10.6`,jsdoc:`^4.0.2`,msw:`^2.14.6`,vite:`^8.2.1`,"vite-plugin-node-polyfills":`^0.28.0`,vitest:`^4.1.11`},dependencies:{"css-element-queries":`^1.2.2`,lodash:`^4.17.19`,"nifti-reader-js":`0.8.0`,three:`^0.130.1`,"three-spritetext":`1.6.2`}},m=new e.Matrix4,h=new e.Object3D,g=new e.Vector3,_=new e.Vector3;function v(){this.uuid=e.MathUtils.generateUUID(),this.name=``,this.type=`Geometry`,this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.normals=[],this.uvs=[],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.elementsNeedUpdate=!1,this.verticesNeedUpdate=!1,this.uvsNeedUpdate=!1,this.normalsNeedUpdate=!1,this.colorsNeedUpdate=!1,this.lineDistancesNeedUpdate=!1,this.groupsNeedUpdate=!1,this.morphNormalsReady=!1}v.prototype=Object.assign(Object.create(e.EventDispatcher.prototype),{constructor:v,isGeometry:!0,applyMatrix4:function(t){let n=new e.Matrix3().getNormalMatrix(t);for(let e=0,n=this.vertices.length;e<n;e++)this.vertices[e].applyMatrix4(t);for(let e=0,t=this.faces.length;e<t;e++){let t=this.faces[e];t.normal.applyMatrix3(n).normalize();for(let e=0,r=t.vertexNormals.length;e<r;e++)t.vertexNormals[e].applyMatrix3(n).normalize()}return this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this.verticesNeedUpdate=!0,this.normalsNeedUpdate=!0,this},rotateX:function(e){return m.makeRotationX(e),this.applyMatrix4(m),this},rotateY:function(e){return m.makeRotationY(e),this.applyMatrix4(m),this},rotateZ:function(e){return m.makeRotationZ(e),this.applyMatrix4(m),this},translate:function(e,t,n){return m.makeTranslation(e,t,n),this.applyMatrix4(m),this},scale:function(e,t,n){return m.makeScale(e,t,n),this.applyMatrix4(m),this},lookAt:function(e){return h.lookAt(e),h.updateMatrix(),this.applyMatrix4(h.matrix),this},fromBufferGeometry:function(t){let n=this,r=t.index===null?void 0:t.index,i=t.attributes;if(i.position===void 0)return console.error(`THREE.Geometry.fromBufferGeometry(): Position attribute required for conversion.`),this;let a=i.position,o=i.normal,s=i.color,c=i.uv,l=i.uv2;l!==void 0&&(this.faceVertexUvs[1]=[]);for(let t=0;t<a.count;t++)n.vertices.push(new e.Vector3().fromBufferAttribute(a,t)),s!==void 0&&n.colors.push(new e.Color().fromBufferAttribute(s,t));function u(t,r,i,a){let u=s===void 0?[]:[n.colors[t].clone(),n.colors[r].clone(),n.colors[i].clone()],d=new b(t,r,i,o===void 0?[]:[new e.Vector3().fromBufferAttribute(o,t),new e.Vector3().fromBufferAttribute(o,r),new e.Vector3().fromBufferAttribute(o,i)],u,a);n.faces.push(d),c!==void 0&&n.faceVertexUvs[0].push([new e.Vector2().fromBufferAttribute(c,t),new e.Vector2().fromBufferAttribute(c,r),new e.Vector2().fromBufferAttribute(c,i)]),l!==void 0&&n.faceVertexUvs[1].push([new e.Vector2().fromBufferAttribute(l,t),new e.Vector2().fromBufferAttribute(l,r),new e.Vector2().fromBufferAttribute(l,i)])}let d=t.groups;if(d.length>0)for(let e=0;e<d.length;e++){let t=d[e],n=t.start,i=t.count;for(let e=n,a=n+i;e<a;e+=3)r===void 0?u(e,e+1,e+2,t.materialIndex):u(r.getX(e),r.getX(e+1),r.getX(e+2),t.materialIndex)}else if(r!==void 0)for(let e=0;e<r.count;e+=3)u(r.getX(e),r.getX(e+1),r.getX(e+2));else for(let e=0;e<a.count;e+=3)u(e,e+1,e+2);return this.computeFaceNormals(),t.boundingBox!==null&&(this.boundingBox=t.boundingBox.clone()),t.boundingSphere!==null&&(this.boundingSphere=t.boundingSphere.clone()),this},center:function(){return this.computeBoundingBox(),this.boundingBox.getCenter(g).negate(),this.translate(g.x,g.y,g.z),this},normalize:function(){this.computeBoundingSphere();let t=this.boundingSphere.center,n=this.boundingSphere.radius,r=n===0?1:1/n,i=new e.Matrix4;return i.set(r,0,0,-r*t.x,0,r,0,-r*t.y,0,0,r,-r*t.z,0,0,0,1),this.applyMatrix4(i),this},computeFaceNormals:function(){let t=new e.Vector3,n=new e.Vector3;for(let e=0,r=this.faces.length;e<r;e++){let r=this.faces[e],i=this.vertices[r.a],a=this.vertices[r.b],o=this.vertices[r.c];t.subVectors(o,a),n.subVectors(i,a),t.cross(n),t.normalize(),r.normal.copy(t)}},computeVertexNormals:function(t=!0){let n=Array(this.vertices.length);for(let t=0,r=this.vertices.length;t<r;t++)n[t]=new e.Vector3;if(t){let t=new e.Vector3,r=new e.Vector3;for(let e=0,i=this.faces.length;e<i;e++){let i=this.faces[e],a=this.vertices[i.a],o=this.vertices[i.b],s=this.vertices[i.c];t.subVectors(s,o),r.subVectors(a,o),t.cross(r),n[i.a].add(t),n[i.b].add(t),n[i.c].add(t)}}else{this.computeFaceNormals();for(let e=0,t=this.faces.length;e<t;e++){let t=this.faces[e];n[t.a].add(t.normal),n[t.b].add(t.normal),n[t.c].add(t.normal)}}for(let e=0,t=this.vertices.length;e<t;e++)n[e].normalize();for(let e=0,t=this.faces.length;e<t;e++){let t=this.faces[e],r=t.vertexNormals;r.length===3?(r[0].copy(n[t.a]),r[1].copy(n[t.b]),r[2].copy(n[t.c])):(r[0]=n[t.a].clone(),r[1]=n[t.b].clone(),r[2]=n[t.c].clone())}return this.faces.length>0&&(this.normalsNeedUpdate=!0),n},computeFlatVertexNormals:function(){this.computeFaceNormals();for(let e=0,t=this.faces.length;e<t;e++){let t=this.faces[e],n=t.vertexNormals;n.length===3?(n[0].copy(t.normal),n[1].copy(t.normal),n[2].copy(t.normal)):(n[0]=t.normal.clone(),n[1]=t.normal.clone(),n[2]=t.normal.clone())}this.faces.length>0&&(this.normalsNeedUpdate=!0)},computeMorphNormals:function(){for(let e=0,t=this.faces.length;e<t;e++){let t=this.faces[e];t.__originalFaceNormal?t.__originalFaceNormal.copy(t.normal):t.__originalFaceNormal=t.normal.clone(),t.__originalVertexNormals||=[];for(let e=0,n=t.vertexNormals.length;e<n;e++)t.__originalVertexNormals[e]?t.__originalVertexNormals[e].copy(t.vertexNormals[e]):t.__originalVertexNormals[e]=t.vertexNormals[e].clone()}let t=new v;t.faces=this.faces;for(let n=0,r=this.morphTargets.length;n<r;n++){if(!this.morphNormals[n]){this.morphNormals[n]={},this.morphNormals[n].faceNormals=[],this.morphNormals[n].vertexNormals=[];let t=this.morphNormals[n].faceNormals,r=this.morphNormals[n].vertexNormals;for(let n=0,i=this.faces.length;n<i;n++){let n=new e.Vector3,i={a:new e.Vector3,b:new e.Vector3,c:new e.Vector3};t.push(n),r.push(i)}}let r=this.morphNormals[n];t.vertices=this.morphTargets[n].vertices,t.computeFaceNormals();let i=t.computeVertexNormals();if(i&&i.length>0){this.morphTargets[n].normals=Array(this.vertices.length);for(let e=0;e<i.length;e++)this.morphTargets[n].normals[e]=i[e].clone()}for(let e=0,t=this.faces.length;e<t;e++){let t=this.faces[e],n=r.faceNormals[e],i=r.vertexNormals[e];n.copy(t.normal),i.a.copy(t.vertexNormals[0]),i.b.copy(t.vertexNormals[1]),i.c.copy(t.vertexNormals[2])}}for(let e=0,t=this.faces.length;e<t;e++){let t=this.faces[e];t.normal=t.__originalFaceNormal,t.vertexNormals=t.__originalVertexNormals}this.morphNormalsReady=!0},computeBoundingBox:function(){this.boundingBox===null&&(this.boundingBox=new e.Box3),this.boundingBox.setFromPoints(this.vertices)},computeBoundingSphere:function(){this.boundingSphere===null&&(this.boundingSphere=new e.Sphere),this.boundingSphere.setFromPoints(this.vertices)},mergeMorph:function(e,t){let n=this.morphTargets.length,r=this.morphTargets,i=e.morphTargets,a=this.morphColors.length,o=this.morphColors,s=e.morphColors;if(n>0&&n==i.length)for(let e=0,n=r.length;e<n;e++){let n=r[e],a=i[e];for(let e=0,r=a.vertices.length;e<r;e++){let r=a.vertices[e].clone();t!==void 0&&r.applyMatrix4(t),n.vertices.push(r)}if(n.normals&&a.normals)for(let e=0;e<a.normals.length;e+=3)_.set(a.normals2[e],a.normals2[e+1],a.normals2[e+2]),t!==void 0&&_.applyMatrix4(t),n.normals.push(_.x,_.y,_.z)}if(a>0&&a==s.length)for(let e=0,t=o.length;e<t;e++){let t=o[e],n=s[e];for(let e=0,r=n.colors;e<r;e++)t.colors.push(n.colors[e].clone())}},merge:function(t,n,r=0){if(!(t&&t.isGeometry)){console.error(`THREE.Geometry.merge(): geometry not an instance of THREE.Geometry.`,t);return}let i,a=this.vertices.length,o=this.vertices,s=t.vertices,c=t.normals,l=this.faces,u=t.faces,d=this.colors,f=t.colors;n!==void 0&&(i=new e.Matrix3().getNormalMatrix(n));for(let e=0,t=s.length;e<t;e++){let t=s[e].clone();n!==void 0&&t.applyMatrix4(n),o.push(t)}for(let e=0;e<c.length;e+=3)_.set(c[e],c[e+1],c[e+2]),n!==void 0&&_.applyMatrix4(n),this.normals.push(_.x,_.y,_.z);for(let e=0,t=f.length;e<t;e++)typeof f[e]==`number`?d.push(f[e]):d.push(f[e].clone());for(let e=0,t=u.length;e<t;e++){let t=u[e],n,o,s=t.vertexNormals,c=t.vertexColors,d=new b(t.a+a,t.b+a,t.c+a);d.normal.copy(t.normal),i!==void 0&&d.normal.applyMatrix3(i).normalize();for(let e=0,t=s.length;e<t;e++)n=s[e].clone(),i!==void 0&&n.applyMatrix3(i).normalize(),d.vertexNormals.push(n);d.color.copy(t.color);for(let e=0,t=c.length;e<t;e++)o=c[e],d.vertexColors.push(o.clone());d.materialIndex=t.materialIndex+r,l.push(d)}for(let e=0,n=t.faceVertexUvs.length;e<n;e++){let n=t.faceVertexUvs[e];this.faceVertexUvs[e]===void 0&&(this.faceVertexUvs[e]=[]);for(let t=0,r=n.length;t<r;t++){let r=n[t],i=[];for(let e=0,t=r.length;e<t;e++)i.push(r[e].clone());this.faceVertexUvs[e].push(i)}}this.mergeMorph(t,n)},mergeMesh:function(e){if(!(e&&e.isMesh)){console.error(`THREE.Geometry.mergeMesh(): mesh not an instance of THREE.Mesh.`,e);return}e.matrixAutoUpdate&&e.updateMatrix(),this.merge(e.geometry,e.matrix)},mergeVertices:function(e=4){let t={},n=[],r=[],i=10**e;for(let e=0,a=this.vertices.length;e<a;e++){let a=this.vertices[e],o=Math.round(a.x*i)+`_`+Math.round(a.y*i)+`_`+Math.round(a.z*i);t[o]===void 0?(t[o]=e,n.push(this.vertices[e]),r[e]=n.length-1):r[e]=r[t[o]]}let a=[];for(let e=0,t=this.faces.length;e<t;e++){let t=this.faces[e];t.a=r[t.a],t.b=r[t.b],t.c=r[t.c];let n=[t.a,t.b,t.c];for(let t=0;t<3;t++)if(n[t]===n[(t+1)%3]){a.push(e);break}}for(let e=a.length-1;e>=0;e--){let t=a[e];this.faces.splice(t,1);for(let e=0,n=this.faceVertexUvs.length;e<n;e++)this.faceVertexUvs[e].splice(t,1)}let o=this.vertices.length-n.length;return this.vertices=n,o},setFromPoints:function(t){this.vertices=[];for(let n=0,r=t.length;n<r;n++){let r=t[n];this.vertices.push(new e.Vector3(r.x,r.y,r.z||0))}return this},sortFacesByMaterialIndex:function(){let e=this.faces,t=e.length;for(let n=0;n<t;n++)e[n]._id=n;function n(e,t){return e.materialIndex-t.materialIndex}e.sort(n);let r=this.faceVertexUvs[0],i=this.faceVertexUvs[1],a,o;r&&r.length===t&&(a=[]),i&&i.length===t&&(o=[]);for(let n=0;n<t;n++){let t=e[n]._id;a&&a.push(r[t]),o&&o.push(i[t])}a&&(this.faceVertexUvs[0]=a),o&&(this.faceVertexUvs[1]=o)},toJSON:function(){let e={metadata:{version:4.5,type:`Geometry`,generator:`Geometry.toJSON`}};if(e.uuid=this.uuid,e.type=this.type,this.name!==``&&(e.name=this.name),this.parameters!==void 0){let t=this.parameters;for(let n in t)t[n]!==void 0&&(e[n]=t[n]);return e}let t=[];for(let e=0;e<this.vertices.length;e++){let n=this.vertices[e];t.push(n.x,n.y,n.z)}let n=[],r=[],i={},a=[],o={},s=[],c={};for(let e=0;e<this.faces.length;e++){let t=this.faces[e],r=this.faceVertexUvs[0][e]!==void 0,i=t.normal.length()>0,a=t.vertexNormals.length>0,o=t.color.r!==1||t.color.g!==1||t.color.b!==1,s=t.vertexColors.length>0,c=0;if(c=l(c,0,0),c=l(c,1,!0),c=l(c,2,!1),c=l(c,3,r),c=l(c,4,i),c=l(c,5,a),c=l(c,6,o),c=l(c,7,s),n.push(c),n.push(t.a,t.b,t.c),n.push(t.materialIndex),r){let t=this.faceVertexUvs[0][e];n.push(f(t[0]),f(t[1]),f(t[2]))}if(i&&n.push(u(t.normal)),a){let e=t.vertexNormals;n.push(u(e[0]),u(e[1]),u(e[2]))}if(o&&n.push(d(t.color)),s){let e=t.vertexColors;n.push(d(e[0]),d(e[1]),d(e[2]))}}function l(e,t,n){return n?e|1<<t:e&~(1<<t)}function u(e){let t=e.x.toString()+e.y.toString()+e.z.toString();return i[t]===void 0?(i[t]=r.length/3,r.push(e.x,e.y,e.z),i[t]):i[t]}function d(e){let t=e.r.toString()+e.g.toString()+e.b.toString();return o[t]===void 0?(o[t]=a.length,a.push(e.getHex()),o[t]):o[t]}function f(e){let t=e.x.toString()+e.y.toString();return c[t]===void 0?(c[t]=s.length/2,s.push(e.x,e.y),c[t]):c[t]}return e.data={},e.data.vertices=t,e.data.normals=r,a.length>0&&(e.data.colors=a),s.length>0&&(e.data.uvs=[s]),e.data.faces=n,e},clone:function(){return new v().copy(this)},copy:function(e){this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.name=e.name;let t=e.vertices;for(let e=0,n=t.length;e<n;e++)this.vertices.push(t[e].clone());let n=e.colors;for(let e=0,t=n.length;e<t;e++)this.colors.push(n[e].clone());let r=e.faces;for(let e=0,t=r.length;e<t;e++)this.faces.push(r[e].clone());for(let t=0,n=e.faceVertexUvs.length;t<n;t++){let n=e.faceVertexUvs[t];this.faceVertexUvs[t]===void 0&&(this.faceVertexUvs[t]=[]);for(let e=0,r=n.length;e<r;e++){let r=n[e],i=[];for(let e=0,t=r.length;e<t;e++){let t=r[e];i.push(t.clone())}this.faceVertexUvs[t].push(i)}}let i=e.morphTargets;for(let e=0,t=i.length;e<t;e++){let t={};if(t.name=i[e].name,i[e].vertices!==void 0){t.vertices=[];for(let n=0,r=i[e].vertices.length;n<r;n++)t.vertices.push(i[e].vertices[n].clone())}if(i[e].normals!==void 0){t.normals=[];for(let n=0,r=i[e].normals.length;n<r;n++)t.normals.push(i[e].normals[n].clone())}this.morphTargets.push(t)}let a=e.morphNormals;for(let e=0,t=a.length;e<t;e++){let t={};if(a[e].vertexNormals!==void 0){t.vertexNormals=[];for(let n=0,r=a[e].vertexNormals.length;n<r;n++){let r=a[e].vertexNormals[n],i={};i.a=r.a.clone(),i.b=r.b.clone(),i.c=r.c.clone(),t.vertexNormals.push(i)}}if(a[e].faceNormals!==void 0){t.faceNormals=[];for(let n=0,r=a[e].faceNormals.length;n<r;n++)t.faceNormals.push(a[e].faceNormals[n].clone())}this.morphNormals.push(t)}let o=e.skinWeights;for(let e=0,t=o.length;e<t;e++)this.skinWeights.push(o[e].clone());let s=e.skinIndices;for(let e=0,t=s.length;e<t;e++)this.skinIndices.push(s[e].clone());let c=e.lineDistances;for(let e=0,t=c.length;e<t;e++)this.lineDistances.push(c[e]);let l=e.boundingBox;l!==null&&(this.boundingBox=l.clone());let u=e.boundingSphere;return u!==null&&(this.boundingSphere=u.clone()),this.elementsNeedUpdate=e.elementsNeedUpdate,this.verticesNeedUpdate=e.verticesNeedUpdate,this.uvsNeedUpdate=e.uvsNeedUpdate,this.normalsNeedUpdate=e.normalsNeedUpdate,this.colorsNeedUpdate=e.colorsNeedUpdate,this.lineDistancesNeedUpdate=e.lineDistancesNeedUpdate,this.groupsNeedUpdate=e.groupsNeedUpdate,this},computeGroups(){let e=[],t,n,r,i=this.faces;for(n=0;n<i.length;n++){let a=i[n];a.materialIndex!==r&&(r=a.materialIndex,t!==void 0&&(t.count=n*3-t.start,e.push(t)),t={start:n*3,materialIndex:r})}return t!==void 0&&(t.count=n*3-t.start,e.push(t)),e},toBufferGeometry:function(){let t=new y().fromGeometry(this),n=new e.BufferGeometry,r=new Float32Array(t.vertices.length*3);if(n.setAttribute(`position`,new e.BufferAttribute(r,3).copyVector3sArray(t.vertices)),t.normals.length>0){let r=new Float32Array(t.normals.length*3);n.setAttribute(`normal`,new e.BufferAttribute(r,3).copyVector3sArray(t.normals))}if(t.colors.length>0){let r=new Float32Array(t.colors.length*3);n.setAttribute(`color`,new e.BufferAttribute(r,3).copyColorsArray(t.colors))}if(t.uvs.length>0){let r=new Float32Array(t.uvs.length*2);n.setAttribute(`uv`,new e.BufferAttribute(r,2).copyVector2sArray(t.uvs))}if(t.uvs2.length>0){let r=new Float32Array(t.uvs2.length*2);n.setAttribute(`uv2`,new e.BufferAttribute(r,2).copyVector2sArray(t.uvs2))}n.groups=t.groups;for(let r in t.morphTargets){let i=[],a=t.morphTargets[r];for(let t=0,n=a.length;t<n;t++){let n=a[t],r=new e.Float32BufferAttribute(n.data.length*3,3);r.name=n.name,i.push(r.copyVector3sArray(n.data))}n.morphAttributes[r]=i}if(t.skinIndices.length>0){let r=new e.Float32BufferAttribute(t.skinIndices.length*4,4);n.setAttribute(`skinIndex`,r.copyVector4sArray(t.skinIndices))}if(t.skinWeights.length>0){let r=new e.Float32BufferAttribute(t.skinWeights.length*4,4);n.setAttribute(`skinWeight`,r.copyVector4sArray(t.skinWeights))}return t.boundingSphere!==null&&(n.boundingSphere=t.boundingSphere.clone()),t.boundingBox!==null&&(n.boundingBox=t.boundingBox.clone()),n},toIndexedBufferGeometry:function(){let t=new e.BufferGeometry,n=new Float32Array(this.vertices.length*3);if(t.setAttribute(`position`,new e.BufferAttribute(n,3).copyVector3sArray(this.vertices)),this.normals.length>0){let n=new Float32Array(this.normals.length),r=new e.BufferAttribute(n,3).copyArray(this.normals);t.setAttribute(`normal`,r)}if(this.uvs.length>0&&this.uvs[0].length>0){let n=new Float32Array(this.uvs[0].length*2);t.setAttribute(`uv`,new e.BufferAttribute(n,2).copyArray(this.uvs[0]))}if(this.uvs.length>1&&this.uvs[1].length>0){let n=new Float32Array(this.uvs[1].length*2);t.setAttribute(`uv2`,new e.BufferAttribute(n,2).copyArray(this.uvs[1]))}if(this.colors.length>0){let n=[];for(let t=0;t<this.colors.length;t++)n.push(new e.Color(this.colors[t]));let r=new Float32Array(n.length*3);t.setAttribute(`color`,new e.BufferAttribute(r,3).copyColorsArray(n))}else{let n=new Float32Array(this.vertices.length*3);for(let e=0;e<this.vertices.length*3;e++)n[e]=1;t.setAttribute(`color`,new e.BufferAttribute(n,3))}if(this.faces.length>0){let e=[],n=[];for(let t=0;t<this.faces.length;t++){n.push(this.faces[t].a,this.faces[t].b,this.faces[t].c);let r=this.faces[t].vertexColors;if(r.length===3)e.push(r[0],r[1],r[2]);else{let n=this.faces[t].color;e.push(n,n,n)}}t.setIndex(n),t.groups=this.computeGroups()}if(this.morphTargets.length>0){let n=[],r=[];for(let t=0,i=this.morphTargets.length;t<i;t++){let i=this.morphTargets[t],a=new e.Float32BufferAttribute(i.vertices.length*3,3);if(a.name=i.name,n.push(a.copyVector3sArray(i.vertices)),i.normals){let t=new e.Float32BufferAttribute(i.normals.length*3,3);t.name=i.name,r.push(t.copyVector3sArray(i.normals))}}t.morphAttributes.position=n,t.morphAttributes.normal=r}if(this.skinIndices.length>0){let n=new e.Float32BufferAttribute(this.skinIndices.length*4,4);t.setAttribute(`skinIndex`,n.copyVector4sArray(this.skinIndices))}if(this.skinWeights.length>0){let n=new e.Float32BufferAttribute(this.skinWeights.length*4,4);t.setAttribute(`skinWeight`,n.copyVector4sArray(this.skinWeights))}return this.boundingSphere!==null&&(t.boundingSphere=this.boundingSphere.clone()),this.boundingBox!==null&&(t.boundingBox=this.boundingBox.clone()),t},computeTangents:function(){console.error(`THREE.Geometry: .computeTangents() has been removed.`)},computeLineDistances:function(){console.error(`THREE.Geometry: .computeLineDistances() has been removed. Use THREE.Line.computeLineDistances() instead.`)},applyMatrix:function(e){return console.warn(`THREE.Geometry: .applyMatrix() has been renamed to .applyMatrix4().`),this.applyMatrix4(e)},dispose:function(){this.dispatchEvent({type:`dispose`})}}),v.createBufferGeometryFromObject=function(t){let n=new e.BufferGeometry,r=t.geometry;if(t.isPoints||t.isLine){let t=new e.Float32BufferAttribute(r.vertices.length*3,3),i=new e.Float32BufferAttribute(r.colors.length*3,3);if(n.setAttribute(`position`,t.copyVector3sArray(r.vertices)),n.setAttribute(`color`,i.copyColorsArray(r.colors)),r.lineDistances&&r.lineDistances.length===r.vertices.length){let t=new e.Float32BufferAttribute(r.lineDistances.length,1);n.setAttribute(`lineDistance`,t.copyArray(r.lineDistances))}r.boundingSphere!==null&&(n.boundingSphere=r.boundingSphere.clone()),r.boundingBox!==null&&(n.boundingBox=r.boundingBox.clone())}else t.isMesh&&(n=r.toBufferGeometry());return n};var y=class{constructor(){this.vertices=[],this.normals=[],this.colors=[],this.uvs=[],this.uvs2=[],this.groups=[],this.morphTargets={},this.skinWeights=[],this.skinIndices=[],this.boundingBox=null,this.boundingSphere=null,this.verticesNeedUpdate=!1,this.normalsNeedUpdate=!1,this.colorsNeedUpdate=!1,this.uvsNeedUpdate=!1,this.groupsNeedUpdate=!1}computeGroups(e){let t=[],n,r,i,a=e.faces;for(r=0;r<a.length;r++){let e=a[r];e.materialIndex!==i&&(i=e.materialIndex,n!==void 0&&(n.count=r*3-n.start,t.push(n)),n={start:r*3,materialIndex:i})}n!==void 0&&(n.count=r*3-n.start,t.push(n)),this.groups=t}fromGeometry(t){let n=t.faces,r=t.vertices,i=t.faceVertexUvs,a=i[0]&&i[0].length>0,o=i[1]&&i[1].length>0,s=t.morphTargets,c=s.length,l;if(c>0){l=[];for(let e=0;e<c;e++)l[e]={name:s[e].name,data:[]};this.morphTargets.position=l}let u=t.morphNormals,d=u.length,f;if(d>0){f=[];for(let e=0;e<d;e++)f[e]={name:u[e].name,data:[]};this.morphTargets.normal=f}let p=t.skinIndices,m=t.skinWeights,h=p.length===r.length,g=m.length===r.length;r.length>0&&n.length===0&&console.error(`THREE.DirectGeometry: Faceless geometries are not supported.`);for(let t=0;t<n.length;t++){let _=n[t];this.vertices.push(r[_.a],r[_.b],r[_.c]);let v=_.vertexNormals;if(v.length===3)this.normals.push(v[0],v[1],v[2]);else{let e=_.normal;this.normals.push(e,e,e)}let y=_.vertexColors;if(y.length===3)this.colors.push(y[0],y[1],y[2]);else{let e=_.color;this.colors.push(e,e,e)}if(a===!0){let n=i[0][t];n===void 0?(console.warn(`THREE.DirectGeometry.fromGeometry(): Undefined vertexUv `,t),this.uvs.push(new e.Vector2,new e.Vector2,new e.Vector2)):this.uvs.push(n[0],n[1],n[2])}if(o===!0){let n=i[1][t];n===void 0?(console.warn(`THREE.DirectGeometry.fromGeometry(): Undefined vertexUv2 `,t),this.uvs2.push(new e.Vector2,new e.Vector2,new e.Vector2)):this.uvs2.push(n[0],n[1],n[2])}for(let e=0;e<c;e++){let t=s[e].vertices;l[e].data.push(t[_.a],t[_.b],t[_.c])}for(let e=0;e<d;e++){let n=u[e].vertexNormals[t];f[e].data.push(n.a,n.b,n.c)}h&&this.skinIndices.push(p[_.a],p[_.b],p[_.c]),g&&this.skinWeights.push(m[_.a],m[_.b],m[_.c])}return this.computeGroups(t),this.verticesNeedUpdate=t.verticesNeedUpdate,this.normalsNeedUpdate=t.normalsNeedUpdate,this.colorsNeedUpdate=t.colorsNeedUpdate,this.uvsNeedUpdate=t.uvsNeedUpdate,this.groupsNeedUpdate=t.groupsNeedUpdate,t.boundingSphere!==null&&(this.boundingSphere=t.boundingSphere.clone()),t.boundingBox!==null&&(this.boundingBox=t.boundingBox.clone()),this}},b=class{constructor(t,n,r,i,a,o=0){this.a=t,this.b=n,this.c=r,this.normal=i&&i.isVector3?i:new e.Vector3,this.vertexNormals=Array.isArray(i)?i:[],this.color=a&&a.isColor?a:new e.Color,this.vertexColors=Array.isArray(a)?a:[],this.materialIndex=o}clone(){return new this.constructor().copy(this)}copy(e){this.a=e.a,this.b=e.b,this.c=e.c,this.normal.copy(e.normal),this.color.copy(e.color),this.materialIndex=e.materialIndex;for(let t=0,n=e.vertexNormals.length;t<n;t++)this.vertexNormals[t]=e.vertexNormals[t].clone();for(let t=0,n=e.vertexColors.length;t<n;t++)this.vertexColors[t]=e.vertexColors[t].clone();return this}},x=`data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAAAZiS0dEAAAAAAAA+UO7fwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9sHDgwCEMBJZu0AAAAdaVRYdENvbW1lbnQAAAAAAENyZWF0ZWQgd2l0aCBHSU1QZC5lBwAABM5JREFUWMO1V0tPG2cUPZ4Hxh6DazIOrjFNqJs0FIMqWFgWQkatsmvVbtggKlSVRVf5AWz4AWz4AUSKEChll19QJYSXkECuhFxsHjEhxCYm+DWGMZ5HF72DJq4bAzFXurI0M/I5997v3u9cC65vTJVn2lX/xHINQOYSBLTLEuIuCWw4Z3IGAEvf6ASmVHjNzHCXBG4A0AjACsAOwEbO0nsFQBnAGYASAIl+ZRMR7SolMEdsByD09fV5R0ZGgg8ePPjW5/N1iqLYpuu6RZblciKR2I9Go69evnwZnZ+fjwI4IS8AKBIRzeQfJWCANwKwh0KhtrGxsYehUOin1tbW+zzP23ietzY2NnIAoGmaLsuyUiqVyvl8XtrY2NiamZn589mzZxsAUgCOAeQAnFI2tI+VxIjaAeDzoaGh7xYWFuZOTk6OZVk+12uYqqq6JEnn0Wg0OT4+/geAXwGEAdwDIFJQXC1wO4DWR48e/RCPxxclSSroVzRFUbSDg4P848ePFwH8DuAhkWih83TRQWxFOXgAwvDwcOfo6OhvXV1d39tsNtuVBwTDWBwOh1UUxVsMw1hXVlbSdCgNV43uYSvrHg6H24aHh38eHBz85TrgF9FYLHA4HLzH43FvbW2d7u/vG+dANp8FpqIlbd3d3V8Fg8EfBUFw4BONZVmL3+9vHhkZCQL4AoAHgJPK8G+yzC0XDofdoVAo5PP5vkadTBAEtr+/39ff3x8gAp/RPOEqx2qjx+NpvXv3bk9DQ0NDvQgwDIOWlhZrMBj8kgi0UJdxRgYMArzL5XJ7vd57qLPZ7Xamp6fnNgBXtQxcjFuHw+Hyer3t9SYgCAITCAScAJoBNNEY/08GOFVVrfVMv7kMNDntFD1vjIAPrlRN0xjckOm6biFQ3jwNPwDMZrOnqVTqfb3Bi8Wivru7W/VCYkwPlKOjo0IikXh7EwQikYgE4Nw0CfXKDCipVCoTj8df3QABbW1tLUc6oUgkFPMkVACUNjc337148eKvw8PDbJ2jP1taWkoCyNDVXDSECmNSK4qiKNLq6urW8+fPI/UicHx8rD59+jSVy+WOAKSJhKENwFItLtoxk8mwsixzHR0dHe3t7c5PAU+n09rs7OzJkydPYqVSaQfANoDXALIk31S2smU1TWMPDg7K5XKZ7+3t9TudTut1U7+wsFCcmJiIpdPpbQBxADsAknQWymYCOukBHYCuKApisdhpMpnURFEU79y503TVyKenpzOTk5M7e3t7MQKPV0Zv1gNm+awB0MvlshqLxfLb29uyJElWURSbXC4XXyvqxcXFs6mpqeTc3Nzu3t7e3wQcA7BPZ8Cov1pNlJplmQtAG8MwHV6v95tAINA5MDBwPxAIuLu6upr8fr/VAN3c3JQjkcjZ+vp6fnl5+d2bN29SuVzuNYAEpf01CdRChUL+X1VskHACuA3Ay3Fcu9vt7nA6nZ7m5uYWQRCaNE3jVVW15PP580KhIGUymWw2m00DOAJwSP4WwPtq4LX2Ao6USxNlQyS/RcQcdLGwlNIz6vEMAaZpNzCk2Pll94LK/cDYimxERiBwG10sxjgvEZBE0UpE6vxj+0Ct5bTaXthgEhRmja8QWNkkPGsuIpfdjpkK+cZUWTC0KredVmtD/gdlSl6EG4AMvQAAAABJRU5ErkJggg==`,S=t.default.default||t.default;function C(e,t){let n=(e,t)=>{try{let n=new URL(e,t).href;if(e&&e.split(`?`).length<2){let e=t.split(`?`);e.length===2&&(n=n+`?`+e[1])}return n}catch{console.error(`There is an issue creating the url link with: ${e}.`)}};if(Array.isArray(e)){let r=[];return e.forEach(e=>{r.push(n(e,t))}),r}return n(e,t)}function w(e,t,n,r,i){let a=e.morphTargetInfluences,o;e.geometry&&(o=e.geometry.morphAttributes);let s=!1;if(a&&o&&o.position){r.set(0,0,0),i.set(0,0,0);for(let e=0;e<a.length;e++)a[e]>0&&(s=!0,n.setFromArray(o.position[e].array),r.add(n.min.multiplyScalar(a[e])),i.add(n.max.multiplyScalar(a[e])));s&&t.set(r,i)}s||t.setFromBufferAttribute(e.geometry.attributes.position),e.updateWorldMatrix(!0,!0),t.applyMatrix4(e.matrixWorld)}function T(e,t,n,r){fetch(e).then(e=>{if(!e.ok)throw Error(`HTTP error! status: ${e.status}`);return e.text()}).then(e=>{n(e,t)}).catch(t=>{console.error(`Fetch string payload retrieval failed for: ${requestURL}`,t),r(e)})}function E(e,t,n){let r=e.length,i=0,a=[];function o(e,n){a[n]=e,i++,i==r&&t(a)}for(let t=0;t<r;t++)T(e[t],t,o,n)}var D=(t,n)=>{let r=Math.floor(n/3),i=n%3,a=0;i==0?a=t[r].r:i==1?a=t[r].g:i==2&&(a=t[r].b);let o=new e.Color(a);return[o.r,o.g,o.b]},O=function(e,t){if(t&&e&&e.morphAttributes&&e.morphAttributes.color){let n=e.morphAttributes.color,r=t.morphTargetInfluences,i=r.length;e.deleteAttribute(`morphColor0`),e.deleteAttribute(`morphColor1`);let a=0,o=[];for(let e=0;1>a||e<i;e++)r[e]>0&&(a++,o.push([e,r[e]]));o.length==2?(e.setAttribute(`morphColor0`,n[o[0][0]]),e.setAttribute(`morphColor1`,n[o[1][0]])):o.length==1&&(e.setAttribute(`morphColor0`,n[o[0][0]]),e.setAttribute(`morphColor1`,n[o[0][0]]))}},k=(t,n)=>{let r;return t instanceof v?(n.localTimeEnabled&&!t.morphNormalsReady&&(t.morphNormals==null||t.morphNormals.length==0)&&t.computeMorphNormals(),r=t.toIndexedBufferGeometry(),n.localMorphColour&&A(t,r)):t instanceof e.BufferGeometry&&(r=t.clone()),r.colorsNeedUpdate=!0,r.computeBoundingBox(),r.computeBoundingSphere(),t._video&&(r._video=t._video),r},A=(t,n)=>{if(t&&t.morphColors&&t.morphColors.length>0){let r=[],i=t.morphColors;for(let t=0,n=i.length;t<n;t++){let n=i[t],a=[];for(let e=0;e<n.colors.length*3;e++){let t=D(n.colors,e);a.push(t[0],t[1],t[2])}let o=new e.Float32BufferAttribute(a,3);o.name=n.name,r.push(o)}n.morphAttributes.color=r}};function j(t){let n,r,i,a=-1,o=0;for(let e=0;e<t.length;++e){let s=t[e];if(n===void 0&&(n=s.array.constructor),n!==s.array.constructor)return console.error(`THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.array must be of consistent array types across matching attributes.`),null;if(r===void 0&&(r=s.itemSize),r!==s.itemSize)return console.error(`THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes.`),null;if(i===void 0&&(i=s.normalized),i!==s.normalized)return console.error(`THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes.`),null;if(a===-1&&(a=s.gpuType),a!==s.gpuType)return console.error(`THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.gpuType must be consistent across matching attributes.`),null;o+=s.count*r}let s=new n(o),c=new e.BufferAttribute(s,r,i),l=0;for(let e=0;e<t.length;++e){let n=t[e];if(n.isInterleavedBufferAttribute){let e=l/r;for(let t=0,i=n.count;t<i;t++)for(let i=0;i<r;i++){let r=n.getComponent(t,i);c.setComponent(t+e,i,r)}}else s.set(n.array,l);l+=n.count*r}return a!==void 0&&(c.gpuType=a),c}var M=(t,n=!1)=>{let r=t[0].index!==null,i=new Set(Object.keys(t[0].attributes)),a=new Set(Object.keys(t[0].morphAttributes)),o={},s={},c=t[0].morphTargetsRelative,l=new e.BufferGeometry,u=0;for(let e=0;e<t.length;++e){let d=t[e],f=0;if(r!==(d.index!==null))return console.error(`THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index `+e+`. All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them.`),null;for(let t in d.attributes){if(!i.has(t))return console.error(`THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index `+e+`. All geometries must have compatible attributes; make sure "`+t+`" attribute exists among all geometries, or in none of them.`),null;o[t]===void 0&&(o[t]=[]),o[t].push(d.attributes[t]),f++}if(f!==i.size)return console.error(`THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index `+e+`. Make sure all geometries have the same number of attributes.`),null;if(c!==d.morphTargetsRelative)return console.error(`THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index `+e+`. .morphTargetsRelative must be consistent throughout all geometries.`),null;for(let t in d.morphAttributes){if(!a.has(t))return console.error(`THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index `+e+`. .morphAttributes must be consistent throughout all geometries.`),null;s[t]===void 0&&(s[t]=[]),s[t].push(d.morphAttributes[t])}if(n){let t;if(r)t=d.index.count;else if(d.attributes.position!==void 0)t=d.attributes.position.count;else return console.error(`THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index `+e+`. The geometry must have either an index or a position attribute`),null;l.addGroup(u,t,e),u+=t}}if(r){let e=0,n=[];for(let r=0;r<t.length;++r){let i=t[r].index;for(let t=0;t<i.count;++t)n.push(i.getX(t)+e);e+=t[r].attributes.position.count}l.setIndex(n)}for(let e in o){let t=j(o[e]);if(!t)return console.error(`THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the `+e+` attribute.`),null;l.setAttribute(e,t)}for(let e in s){let t=s[e][0].length;if(t===0)break;l.morphAttributes=l.morphAttributes||{},l.morphAttributes[e]=[];for(let n=0;n<t;++n){let t=[];for(let r=0;r<s[e].length;++r)t.push(s[e][r][n]);let r=j(t);if(!r)return console.error(`THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the `+e+` morphAttribute.`),null;l.morphAttributes[e].push(r)}}return l};function N(t,n){if(n&&t>=n.length){let r=new e.BufferGeometry,i=new Float32Array(t*3),a=0;return n.forEach(e=>{i[a++]=e[0],i[a++]=e[1],i[a++]=e[2]}),r.setAttribute(`position`,new e.BufferAttribute(i,3)),r.setDrawRange(0,n.length),r}}function P(){let t=new Image;t.src=x;let n=new e.Texture;return n.image=t,n.needsUpdate=!0,n}function F(e,t,n,r,i,a){let o=new S(e,t,n,r,i,a);return o.fontFace=r,o.fontSize=i,o.fontWeight=a,o.material.map.generateMipmaps=!1,o.material.map.anisotropy=4,o.material.sizeAttenuation=!1,o.material.alphaTest=.5,o.material.transparent=!0,o.material.depthWrite=!1,o.material.depthTest=!1,o.center.set(.5,-1.2),o.renderOrder=1e4,o}function I(e,t,n){if(n){let r=e||``,i=t||``,a=n.lastIndexOf(`/`);if(a>-1){let e,t;if(e=n.substring(0,a),t=n.substring(a+1),(e===`*`||e===`**`||e.toLowerCase()===r.toLowerCase())&&(t===`*`||t===`**`||t.toLowerCase()===i.toLowerCase()))return!0}else if(r.toLowerCase()===n.toLowerCase()||i.toLowerCase()===n.toLowerCase())return!0}return!1}function ee(t,n,r){let i=t.getAttribute(`position`),a=t.getAttribute(`normal`);if(!i)return;let o=i.itemSize,s=n*o,c=o,l=!1,u=(n,i)=>{let a=!1,l=Array.from(n.array);if(l.length>=s+c){l.splice(s,c),r&&l.concat(Array(c).fill(0)),a=!0;let n=new Float32Array(l);t.setAttribute(i,new e.BufferAttribute(n,o)),t.getAttribute(i).needsUpdate=!0}return a};return l=u(i,`position`),a&&u(a,`normal`),t.index!==null&&console.warn(`Removing vertices from indexed geometry requires index buffer recalculation.`),l}var L=function(){return function(e){e.vertexShader=e.vertexShader.replace(`#include <color_pars_vertex>`,[`varying vec3 vColor;`,`attribute vec3 morphColor0;`,`attribute vec3 morphColor1;`].join(`
1
+ (function(e,t){typeof exports==`object`&&typeof module<`u`?module.exports=t(require("three"),require("three-spritetext"),require("css-element-queries"),require("three/examples/jsm/loaders/GLTFLoader"),require("fflate")):typeof define==`function`&&define.amd?define([`three`,`three-spritetext`,`css-element-queries`,`three/examples/jsm/loaders/GLTFLoader`,`fflate`],t):(e=typeof globalThis<`u`?globalThis:e||self,e.Zinc=t(e.THREE,e.SpriteText,e.cssElememtQueries,e.GLTFLoader,e.fflate))})(this,function(e,t,n,r,i){var a=Object.create,o=Object.defineProperty,s=Object.getOwnPropertyDescriptor,c=Object.getOwnPropertyNames,l=Object.getPrototypeOf,u=Object.prototype.hasOwnProperty,d=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=c(t),a=0,l=i.length,d;a<l;a++)d=i[a],!u.call(e,d)&&d!==n&&o(e,d,{get:(e=>t[e]).bind(null,d),enumerable:!(r=s(t,d))||r.enumerable});return e},f=(e,t,n)=>(n=e==null?{}:a(l(e)),d(t||!e||!e.__esModule||!u.call(e,`default`)?o(n,`default`,{value:e,enumerable:!0}):n,e));e=f(e,1),t=f(t,1);var p={name:`zincjs`,version:`2.3.0`,description:`ZincJS (Web-based-Zinc-Visualisation)`,type:`module`,main:`build/zinc.js`,directories:{doc:`docs`},files:[`package.json`,`LICENSE`,`README.md`,`src/*`,`build/zinc.js`,`build/zinc.js.map`,`vite.config.js`],scripts:{"build-bundle":`vite build`,"test-watch":`vitest`,test:`vitest run --reporter=junit --outputFile=test-results.xml`,"test-standard":`vitest run`,changelog:`auto-changelog -p --output CHANGELOG.md --template keepachangelog`,jsdoc:`jsdoc -c jsdoc_conf.json`,version:`npm run build-bundle;npm run jsdoc;npm run changelog; git add CHANGELOG.md docs`,"release:beta":`npm version prerelease --preid=beta; npm publish --tag beta`,"release:major":`npm version major; npm publish`,"release:minor":`npm version minor; npm publish`,"release:patch":`npm version patch; npm publish`},repository:{type:`git`,url:`git+https://github.com/alan-wu/ZincJS.git`},keywords:[`library`,`webgl`,`3d`,`zincjs`],author:`Alan Wu <alan.wu@auckland.ac.nz>`,license:`MIT`,bugs:{url:`https://github.com/alan-wu/ZincJS/issues`},homepage:`http://alan-wu.github.io/ZincJS/`,engines:{node:`24.20.0`},allowScripts:{"gl@8.1.6":!0,"msw@2.14.6":!0},devDependencies:{"@vitest/coverage-v8":`^4.1.11`,"auto-changelog":`^2.4.0`,chai:`^4.1.0`,gl:`^8.1.6`,"happy-dom":`^20.10.6`,jsdoc:`^4.0.2`,msw:`^2.14.6`,vite:`^8.2.1`,"vite-plugin-node-polyfills":`^0.28.0`,vitest:`^4.1.11`},dependencies:{"css-element-queries":`^1.2.2`,lodash:`^4.17.19`,"nifti-reader-js":`0.8.0`,three:`^0.130.1`,"three-spritetext":`1.6.2`}},m=new e.Matrix4,h=new e.Object3D,g=new e.Vector3,_=new e.Vector3;function v(){this.uuid=e.MathUtils.generateUUID(),this.name=``,this.type=`Geometry`,this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.normals=[],this.uvs=[],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.elementsNeedUpdate=!1,this.verticesNeedUpdate=!1,this.uvsNeedUpdate=!1,this.normalsNeedUpdate=!1,this.colorsNeedUpdate=!1,this.lineDistancesNeedUpdate=!1,this.groupsNeedUpdate=!1,this.morphNormalsReady=!1}v.prototype=Object.assign(Object.create(e.EventDispatcher.prototype),{constructor:v,isGeometry:!0,applyMatrix4:function(t){let n=new e.Matrix3().getNormalMatrix(t);for(let e=0,n=this.vertices.length;e<n;e++)this.vertices[e].applyMatrix4(t);for(let e=0,t=this.faces.length;e<t;e++){let t=this.faces[e];t.normal.applyMatrix3(n).normalize();for(let e=0,r=t.vertexNormals.length;e<r;e++)t.vertexNormals[e].applyMatrix3(n).normalize()}return this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this.verticesNeedUpdate=!0,this.normalsNeedUpdate=!0,this},rotateX:function(e){return m.makeRotationX(e),this.applyMatrix4(m),this},rotateY:function(e){return m.makeRotationY(e),this.applyMatrix4(m),this},rotateZ:function(e){return m.makeRotationZ(e),this.applyMatrix4(m),this},translate:function(e,t,n){return m.makeTranslation(e,t,n),this.applyMatrix4(m),this},scale:function(e,t,n){return m.makeScale(e,t,n),this.applyMatrix4(m),this},lookAt:function(e){return h.lookAt(e),h.updateMatrix(),this.applyMatrix4(h.matrix),this},fromBufferGeometry:function(t){let n=this,r=t.index===null?void 0:t.index,i=t.attributes;if(i.position===void 0)return console.error(`THREE.Geometry.fromBufferGeometry(): Position attribute required for conversion.`),this;let a=i.position,o=i.normal,s=i.color,c=i.uv,l=i.uv2;l!==void 0&&(this.faceVertexUvs[1]=[]);for(let t=0;t<a.count;t++)n.vertices.push(new e.Vector3().fromBufferAttribute(a,t)),s!==void 0&&n.colors.push(new e.Color().fromBufferAttribute(s,t));function u(t,r,i,a){let u=s===void 0?[]:[n.colors[t].clone(),n.colors[r].clone(),n.colors[i].clone()],d=new b(t,r,i,o===void 0?[]:[new e.Vector3().fromBufferAttribute(o,t),new e.Vector3().fromBufferAttribute(o,r),new e.Vector3().fromBufferAttribute(o,i)],u,a);n.faces.push(d),c!==void 0&&n.faceVertexUvs[0].push([new e.Vector2().fromBufferAttribute(c,t),new e.Vector2().fromBufferAttribute(c,r),new e.Vector2().fromBufferAttribute(c,i)]),l!==void 0&&n.faceVertexUvs[1].push([new e.Vector2().fromBufferAttribute(l,t),new e.Vector2().fromBufferAttribute(l,r),new e.Vector2().fromBufferAttribute(l,i)])}let d=t.groups;if(d.length>0)for(let e=0;e<d.length;e++){let t=d[e],n=t.start,i=t.count;for(let e=n,a=n+i;e<a;e+=3)r===void 0?u(e,e+1,e+2,t.materialIndex):u(r.getX(e),r.getX(e+1),r.getX(e+2),t.materialIndex)}else if(r!==void 0)for(let e=0;e<r.count;e+=3)u(r.getX(e),r.getX(e+1),r.getX(e+2));else for(let e=0;e<a.count;e+=3)u(e,e+1,e+2);return this.computeFaceNormals(),t.boundingBox!==null&&(this.boundingBox=t.boundingBox.clone()),t.boundingSphere!==null&&(this.boundingSphere=t.boundingSphere.clone()),this},center:function(){return this.computeBoundingBox(),this.boundingBox.getCenter(g).negate(),this.translate(g.x,g.y,g.z),this},normalize:function(){this.computeBoundingSphere();let t=this.boundingSphere.center,n=this.boundingSphere.radius,r=n===0?1:1/n,i=new e.Matrix4;return i.set(r,0,0,-r*t.x,0,r,0,-r*t.y,0,0,r,-r*t.z,0,0,0,1),this.applyMatrix4(i),this},computeFaceNormals:function(){let t=new e.Vector3,n=new e.Vector3;for(let e=0,r=this.faces.length;e<r;e++){let r=this.faces[e],i=this.vertices[r.a],a=this.vertices[r.b],o=this.vertices[r.c];t.subVectors(o,a),n.subVectors(i,a),t.cross(n),t.normalize(),r.normal.copy(t)}},computeVertexNormals:function(t=!0){let n=Array(this.vertices.length);for(let t=0,r=this.vertices.length;t<r;t++)n[t]=new e.Vector3;if(t){let t=new e.Vector3,r=new e.Vector3;for(let e=0,i=this.faces.length;e<i;e++){let i=this.faces[e],a=this.vertices[i.a],o=this.vertices[i.b],s=this.vertices[i.c];t.subVectors(s,o),r.subVectors(a,o),t.cross(r),n[i.a].add(t),n[i.b].add(t),n[i.c].add(t)}}else{this.computeFaceNormals();for(let e=0,t=this.faces.length;e<t;e++){let t=this.faces[e];n[t.a].add(t.normal),n[t.b].add(t.normal),n[t.c].add(t.normal)}}for(let e=0,t=this.vertices.length;e<t;e++)n[e].normalize();for(let e=0,t=this.faces.length;e<t;e++){let t=this.faces[e],r=t.vertexNormals;r.length===3?(r[0].copy(n[t.a]),r[1].copy(n[t.b]),r[2].copy(n[t.c])):(r[0]=n[t.a].clone(),r[1]=n[t.b].clone(),r[2]=n[t.c].clone())}return this.faces.length>0&&(this.normalsNeedUpdate=!0),n},computeFlatVertexNormals:function(){this.computeFaceNormals();for(let e=0,t=this.faces.length;e<t;e++){let t=this.faces[e],n=t.vertexNormals;n.length===3?(n[0].copy(t.normal),n[1].copy(t.normal),n[2].copy(t.normal)):(n[0]=t.normal.clone(),n[1]=t.normal.clone(),n[2]=t.normal.clone())}this.faces.length>0&&(this.normalsNeedUpdate=!0)},computeMorphNormals:function(){for(let e=0,t=this.faces.length;e<t;e++){let t=this.faces[e];t.__originalFaceNormal?t.__originalFaceNormal.copy(t.normal):t.__originalFaceNormal=t.normal.clone(),t.__originalVertexNormals||=[];for(let e=0,n=t.vertexNormals.length;e<n;e++)t.__originalVertexNormals[e]?t.__originalVertexNormals[e].copy(t.vertexNormals[e]):t.__originalVertexNormals[e]=t.vertexNormals[e].clone()}let t=new v;t.faces=this.faces;for(let n=0,r=this.morphTargets.length;n<r;n++){if(!this.morphNormals[n]){this.morphNormals[n]={},this.morphNormals[n].faceNormals=[],this.morphNormals[n].vertexNormals=[];let t=this.morphNormals[n].faceNormals,r=this.morphNormals[n].vertexNormals;for(let n=0,i=this.faces.length;n<i;n++){let n=new e.Vector3,i={a:new e.Vector3,b:new e.Vector3,c:new e.Vector3};t.push(n),r.push(i)}}let r=this.morphNormals[n];t.vertices=this.morphTargets[n].vertices,t.computeFaceNormals();let i=t.computeVertexNormals();if(i&&i.length>0){this.morphTargets[n].normals=Array(this.vertices.length);for(let e=0;e<i.length;e++)this.morphTargets[n].normals[e]=i[e].clone()}for(let e=0,t=this.faces.length;e<t;e++){let t=this.faces[e],n=r.faceNormals[e],i=r.vertexNormals[e];n.copy(t.normal),i.a.copy(t.vertexNormals[0]),i.b.copy(t.vertexNormals[1]),i.c.copy(t.vertexNormals[2])}}for(let e=0,t=this.faces.length;e<t;e++){let t=this.faces[e];t.normal=t.__originalFaceNormal,t.vertexNormals=t.__originalVertexNormals}this.morphNormalsReady=!0},computeBoundingBox:function(){this.boundingBox===null&&(this.boundingBox=new e.Box3),this.boundingBox.setFromPoints(this.vertices)},computeBoundingSphere:function(){this.boundingSphere===null&&(this.boundingSphere=new e.Sphere),this.boundingSphere.setFromPoints(this.vertices)},mergeMorph:function(e,t){let n=this.morphTargets.length,r=this.morphTargets,i=e.morphTargets,a=this.morphColors.length,o=this.morphColors,s=e.morphColors;if(n>0&&n==i.length)for(let e=0,n=r.length;e<n;e++){let n=r[e],a=i[e];for(let e=0,r=a.vertices.length;e<r;e++){let r=a.vertices[e].clone();t!==void 0&&r.applyMatrix4(t),n.vertices.push(r)}if(n.normals&&a.normals)for(let e=0;e<a.normals.length;e+=3)_.set(a.normals2[e],a.normals2[e+1],a.normals2[e+2]),t!==void 0&&_.applyMatrix4(t),n.normals.push(_.x,_.y,_.z)}if(a>0&&a==s.length)for(let e=0,t=o.length;e<t;e++){let t=o[e],n=s[e];for(let e=0,r=n.colors;e<r;e++)t.colors.push(n.colors[e].clone())}},merge:function(t,n,r=0){if(!(t&&t.isGeometry)){console.error(`THREE.Geometry.merge(): geometry not an instance of THREE.Geometry.`,t);return}let i,a=this.vertices.length,o=this.vertices,s=t.vertices,c=t.normals,l=this.faces,u=t.faces,d=this.colors,f=t.colors;n!==void 0&&(i=new e.Matrix3().getNormalMatrix(n));for(let e=0,t=s.length;e<t;e++){let t=s[e].clone();n!==void 0&&t.applyMatrix4(n),o.push(t)}for(let e=0;e<c.length;e+=3)_.set(c[e],c[e+1],c[e+2]),n!==void 0&&_.applyMatrix4(n),this.normals.push(_.x,_.y,_.z);for(let e=0,t=f.length;e<t;e++)typeof f[e]==`number`?d.push(f[e]):d.push(f[e].clone());for(let e=0,t=u.length;e<t;e++){let t=u[e],n,o,s=t.vertexNormals,c=t.vertexColors,d=new b(t.a+a,t.b+a,t.c+a);d.normal.copy(t.normal),i!==void 0&&d.normal.applyMatrix3(i).normalize();for(let e=0,t=s.length;e<t;e++)n=s[e].clone(),i!==void 0&&n.applyMatrix3(i).normalize(),d.vertexNormals.push(n);d.color.copy(t.color);for(let e=0,t=c.length;e<t;e++)o=c[e],d.vertexColors.push(o.clone());d.materialIndex=t.materialIndex+r,l.push(d)}for(let e=0,n=t.faceVertexUvs.length;e<n;e++){let n=t.faceVertexUvs[e];this.faceVertexUvs[e]===void 0&&(this.faceVertexUvs[e]=[]);for(let t=0,r=n.length;t<r;t++){let r=n[t],i=[];for(let e=0,t=r.length;e<t;e++)i.push(r[e].clone());this.faceVertexUvs[e].push(i)}}this.mergeMorph(t,n)},mergeMesh:function(e){if(!(e&&e.isMesh)){console.error(`THREE.Geometry.mergeMesh(): mesh not an instance of THREE.Mesh.`,e);return}e.matrixAutoUpdate&&e.updateMatrix(),this.merge(e.geometry,e.matrix)},mergeVertices:function(e=4){let t={},n=[],r=[],i=10**e;for(let e=0,a=this.vertices.length;e<a;e++){let a=this.vertices[e],o=Math.round(a.x*i)+`_`+Math.round(a.y*i)+`_`+Math.round(a.z*i);t[o]===void 0?(t[o]=e,n.push(this.vertices[e]),r[e]=n.length-1):r[e]=r[t[o]]}let a=[];for(let e=0,t=this.faces.length;e<t;e++){let t=this.faces[e];t.a=r[t.a],t.b=r[t.b],t.c=r[t.c];let n=[t.a,t.b,t.c];for(let t=0;t<3;t++)if(n[t]===n[(t+1)%3]){a.push(e);break}}for(let e=a.length-1;e>=0;e--){let t=a[e];this.faces.splice(t,1);for(let e=0,n=this.faceVertexUvs.length;e<n;e++)this.faceVertexUvs[e].splice(t,1)}let o=this.vertices.length-n.length;return this.vertices=n,o},setFromPoints:function(t){this.vertices=[];for(let n=0,r=t.length;n<r;n++){let r=t[n];this.vertices.push(new e.Vector3(r.x,r.y,r.z||0))}return this},sortFacesByMaterialIndex:function(){let e=this.faces,t=e.length;for(let n=0;n<t;n++)e[n]._id=n;function n(e,t){return e.materialIndex-t.materialIndex}e.sort(n);let r=this.faceVertexUvs[0],i=this.faceVertexUvs[1],a,o;r&&r.length===t&&(a=[]),i&&i.length===t&&(o=[]);for(let n=0;n<t;n++){let t=e[n]._id;a&&a.push(r[t]),o&&o.push(i[t])}a&&(this.faceVertexUvs[0]=a),o&&(this.faceVertexUvs[1]=o)},toJSON:function(){let e={metadata:{version:4.5,type:`Geometry`,generator:`Geometry.toJSON`}};if(e.uuid=this.uuid,e.type=this.type,this.name!==``&&(e.name=this.name),this.parameters!==void 0){let t=this.parameters;for(let n in t)t[n]!==void 0&&(e[n]=t[n]);return e}let t=[];for(let e=0;e<this.vertices.length;e++){let n=this.vertices[e];t.push(n.x,n.y,n.z)}let n=[],r=[],i={},a=[],o={},s=[],c={};for(let e=0;e<this.faces.length;e++){let t=this.faces[e],r=this.faceVertexUvs[0][e]!==void 0,i=t.normal.length()>0,a=t.vertexNormals.length>0,o=t.color.r!==1||t.color.g!==1||t.color.b!==1,s=t.vertexColors.length>0,c=0;if(c=l(c,0,0),c=l(c,1,!0),c=l(c,2,!1),c=l(c,3,r),c=l(c,4,i),c=l(c,5,a),c=l(c,6,o),c=l(c,7,s),n.push(c),n.push(t.a,t.b,t.c),n.push(t.materialIndex),r){let t=this.faceVertexUvs[0][e];n.push(f(t[0]),f(t[1]),f(t[2]))}if(i&&n.push(u(t.normal)),a){let e=t.vertexNormals;n.push(u(e[0]),u(e[1]),u(e[2]))}if(o&&n.push(d(t.color)),s){let e=t.vertexColors;n.push(d(e[0]),d(e[1]),d(e[2]))}}function l(e,t,n){return n?e|1<<t:e&~(1<<t)}function u(e){let t=e.x.toString()+e.y.toString()+e.z.toString();return i[t]===void 0?(i[t]=r.length/3,r.push(e.x,e.y,e.z),i[t]):i[t]}function d(e){let t=e.r.toString()+e.g.toString()+e.b.toString();return o[t]===void 0?(o[t]=a.length,a.push(e.getHex()),o[t]):o[t]}function f(e){let t=e.x.toString()+e.y.toString();return c[t]===void 0?(c[t]=s.length/2,s.push(e.x,e.y),c[t]):c[t]}return e.data={},e.data.vertices=t,e.data.normals=r,a.length>0&&(e.data.colors=a),s.length>0&&(e.data.uvs=[s]),e.data.faces=n,e},clone:function(){return new v().copy(this)},copy:function(e){this.vertices=[],this.colors=[],this.faces=[],this.faceVertexUvs=[[]],this.morphTargets=[],this.morphNormals=[],this.skinWeights=[],this.skinIndices=[],this.lineDistances=[],this.boundingBox=null,this.boundingSphere=null,this.name=e.name;let t=e.vertices;for(let e=0,n=t.length;e<n;e++)this.vertices.push(t[e].clone());let n=e.colors;for(let e=0,t=n.length;e<t;e++)this.colors.push(n[e].clone());let r=e.faces;for(let e=0,t=r.length;e<t;e++)this.faces.push(r[e].clone());for(let t=0,n=e.faceVertexUvs.length;t<n;t++){let n=e.faceVertexUvs[t];this.faceVertexUvs[t]===void 0&&(this.faceVertexUvs[t]=[]);for(let e=0,r=n.length;e<r;e++){let r=n[e],i=[];for(let e=0,t=r.length;e<t;e++){let t=r[e];i.push(t.clone())}this.faceVertexUvs[t].push(i)}}let i=e.morphTargets;for(let e=0,t=i.length;e<t;e++){let t={};if(t.name=i[e].name,i[e].vertices!==void 0){t.vertices=[];for(let n=0,r=i[e].vertices.length;n<r;n++)t.vertices.push(i[e].vertices[n].clone())}if(i[e].normals!==void 0){t.normals=[];for(let n=0,r=i[e].normals.length;n<r;n++)t.normals.push(i[e].normals[n].clone())}this.morphTargets.push(t)}let a=e.morphNormals;for(let e=0,t=a.length;e<t;e++){let t={};if(a[e].vertexNormals!==void 0){t.vertexNormals=[];for(let n=0,r=a[e].vertexNormals.length;n<r;n++){let r=a[e].vertexNormals[n],i={};i.a=r.a.clone(),i.b=r.b.clone(),i.c=r.c.clone(),t.vertexNormals.push(i)}}if(a[e].faceNormals!==void 0){t.faceNormals=[];for(let n=0,r=a[e].faceNormals.length;n<r;n++)t.faceNormals.push(a[e].faceNormals[n].clone())}this.morphNormals.push(t)}let o=e.skinWeights;for(let e=0,t=o.length;e<t;e++)this.skinWeights.push(o[e].clone());let s=e.skinIndices;for(let e=0,t=s.length;e<t;e++)this.skinIndices.push(s[e].clone());let c=e.lineDistances;for(let e=0,t=c.length;e<t;e++)this.lineDistances.push(c[e]);let l=e.boundingBox;l!==null&&(this.boundingBox=l.clone());let u=e.boundingSphere;return u!==null&&(this.boundingSphere=u.clone()),this.elementsNeedUpdate=e.elementsNeedUpdate,this.verticesNeedUpdate=e.verticesNeedUpdate,this.uvsNeedUpdate=e.uvsNeedUpdate,this.normalsNeedUpdate=e.normalsNeedUpdate,this.colorsNeedUpdate=e.colorsNeedUpdate,this.lineDistancesNeedUpdate=e.lineDistancesNeedUpdate,this.groupsNeedUpdate=e.groupsNeedUpdate,this},computeGroups(){let e=[],t,n,r,i=this.faces;for(n=0;n<i.length;n++){let a=i[n];a.materialIndex!==r&&(r=a.materialIndex,t!==void 0&&(t.count=n*3-t.start,e.push(t)),t={start:n*3,materialIndex:r})}return t!==void 0&&(t.count=n*3-t.start,e.push(t)),e},toBufferGeometry:function(){let t=new y().fromGeometry(this),n=new e.BufferGeometry,r=new Float32Array(t.vertices.length*3);if(n.setAttribute(`position`,new e.BufferAttribute(r,3).copyVector3sArray(t.vertices)),t.normals.length>0){let r=new Float32Array(t.normals.length*3);n.setAttribute(`normal`,new e.BufferAttribute(r,3).copyVector3sArray(t.normals))}if(t.colors.length>0){let r=new Float32Array(t.colors.length*3);n.setAttribute(`color`,new e.BufferAttribute(r,3).copyColorsArray(t.colors))}if(t.uvs.length>0){let r=new Float32Array(t.uvs.length*2);n.setAttribute(`uv`,new e.BufferAttribute(r,2).copyVector2sArray(t.uvs))}if(t.uvs2.length>0){let r=new Float32Array(t.uvs2.length*2);n.setAttribute(`uv2`,new e.BufferAttribute(r,2).copyVector2sArray(t.uvs2))}n.groups=t.groups;for(let r in t.morphTargets){let i=[],a=t.morphTargets[r];for(let t=0,n=a.length;t<n;t++){let n=a[t],r=new e.Float32BufferAttribute(n.data.length*3,3);r.name=n.name,i.push(r.copyVector3sArray(n.data))}n.morphAttributes[r]=i}if(t.skinIndices.length>0){let r=new e.Float32BufferAttribute(t.skinIndices.length*4,4);n.setAttribute(`skinIndex`,r.copyVector4sArray(t.skinIndices))}if(t.skinWeights.length>0){let r=new e.Float32BufferAttribute(t.skinWeights.length*4,4);n.setAttribute(`skinWeight`,r.copyVector4sArray(t.skinWeights))}return t.boundingSphere!==null&&(n.boundingSphere=t.boundingSphere.clone()),t.boundingBox!==null&&(n.boundingBox=t.boundingBox.clone()),n},toIndexedBufferGeometry:function(){let t=new e.BufferGeometry,n=new Float32Array(this.vertices.length*3);if(t.setAttribute(`position`,new e.BufferAttribute(n,3).copyVector3sArray(this.vertices)),this.normals.length>0){let n=new Float32Array(this.normals.length),r=new e.BufferAttribute(n,3).copyArray(this.normals);t.setAttribute(`normal`,r)}if(this.uvs.length>0&&this.uvs[0].length>0){let n=new Float32Array(this.uvs[0].length*2);t.setAttribute(`uv`,new e.BufferAttribute(n,2).copyArray(this.uvs[0]))}if(this.uvs.length>1&&this.uvs[1].length>0){let n=new Float32Array(this.uvs[1].length*2);t.setAttribute(`uv2`,new e.BufferAttribute(n,2).copyArray(this.uvs[1]))}if(this.colors.length>0){let n=[];for(let t=0;t<this.colors.length;t++)n.push(new e.Color(this.colors[t]));let r=new Float32Array(n.length*3);t.setAttribute(`color`,new e.BufferAttribute(r,3).copyColorsArray(n))}else{let n=new Float32Array(this.vertices.length*3);for(let e=0;e<this.vertices.length*3;e++)n[e]=1;t.setAttribute(`color`,new e.BufferAttribute(n,3))}if(this.faces.length>0){let e=[],n=[];for(let t=0;t<this.faces.length;t++){n.push(this.faces[t].a,this.faces[t].b,this.faces[t].c);let r=this.faces[t].vertexColors;if(r.length===3)e.push(r[0],r[1],r[2]);else{let n=this.faces[t].color;e.push(n,n,n)}}t.setIndex(n),t.groups=this.computeGroups()}if(this.morphTargets.length>0){let n=[],r=[];for(let t=0,i=this.morphTargets.length;t<i;t++){let i=this.morphTargets[t],a=new e.Float32BufferAttribute(i.vertices.length*3,3);if(a.name=i.name,n.push(a.copyVector3sArray(i.vertices)),i.normals){let t=new e.Float32BufferAttribute(i.normals.length*3,3);t.name=i.name,r.push(t.copyVector3sArray(i.normals))}}t.morphAttributes.position=n,t.morphAttributes.normal=r}if(this.skinIndices.length>0){let n=new e.Float32BufferAttribute(this.skinIndices.length*4,4);t.setAttribute(`skinIndex`,n.copyVector4sArray(this.skinIndices))}if(this.skinWeights.length>0){let n=new e.Float32BufferAttribute(this.skinWeights.length*4,4);t.setAttribute(`skinWeight`,n.copyVector4sArray(this.skinWeights))}return this.boundingSphere!==null&&(t.boundingSphere=this.boundingSphere.clone()),this.boundingBox!==null&&(t.boundingBox=this.boundingBox.clone()),t},computeTangents:function(){console.error(`THREE.Geometry: .computeTangents() has been removed.`)},computeLineDistances:function(){console.error(`THREE.Geometry: .computeLineDistances() has been removed. Use THREE.Line.computeLineDistances() instead.`)},applyMatrix:function(e){return console.warn(`THREE.Geometry: .applyMatrix() has been renamed to .applyMatrix4().`),this.applyMatrix4(e)},dispose:function(){this.dispatchEvent({type:`dispose`})}}),v.createBufferGeometryFromObject=function(t){let n=new e.BufferGeometry,r=t.geometry;if(t.isPoints||t.isLine){let t=new e.Float32BufferAttribute(r.vertices.length*3,3),i=new e.Float32BufferAttribute(r.colors.length*3,3);if(n.setAttribute(`position`,t.copyVector3sArray(r.vertices)),n.setAttribute(`color`,i.copyColorsArray(r.colors)),r.lineDistances&&r.lineDistances.length===r.vertices.length){let t=new e.Float32BufferAttribute(r.lineDistances.length,1);n.setAttribute(`lineDistance`,t.copyArray(r.lineDistances))}r.boundingSphere!==null&&(n.boundingSphere=r.boundingSphere.clone()),r.boundingBox!==null&&(n.boundingBox=r.boundingBox.clone())}else t.isMesh&&(n=r.toBufferGeometry());return n};var y=class{constructor(){this.vertices=[],this.normals=[],this.colors=[],this.uvs=[],this.uvs2=[],this.groups=[],this.morphTargets={},this.skinWeights=[],this.skinIndices=[],this.boundingBox=null,this.boundingSphere=null,this.verticesNeedUpdate=!1,this.normalsNeedUpdate=!1,this.colorsNeedUpdate=!1,this.uvsNeedUpdate=!1,this.groupsNeedUpdate=!1}computeGroups(e){let t=[],n,r,i,a=e.faces;for(r=0;r<a.length;r++){let e=a[r];e.materialIndex!==i&&(i=e.materialIndex,n!==void 0&&(n.count=r*3-n.start,t.push(n)),n={start:r*3,materialIndex:i})}n!==void 0&&(n.count=r*3-n.start,t.push(n)),this.groups=t}fromGeometry(t){let n=t.faces,r=t.vertices,i=t.faceVertexUvs,a=i[0]&&i[0].length>0,o=i[1]&&i[1].length>0,s=t.morphTargets,c=s.length,l;if(c>0){l=[];for(let e=0;e<c;e++)l[e]={name:s[e].name,data:[]};this.morphTargets.position=l}let u=t.morphNormals,d=u.length,f;if(d>0){f=[];for(let e=0;e<d;e++)f[e]={name:u[e].name,data:[]};this.morphTargets.normal=f}let p=t.skinIndices,m=t.skinWeights,h=p.length===r.length,g=m.length===r.length;r.length>0&&n.length===0&&console.error(`THREE.DirectGeometry: Faceless geometries are not supported.`);for(let t=0;t<n.length;t++){let _=n[t];this.vertices.push(r[_.a],r[_.b],r[_.c]);let v=_.vertexNormals;if(v.length===3)this.normals.push(v[0],v[1],v[2]);else{let e=_.normal;this.normals.push(e,e,e)}let y=_.vertexColors;if(y.length===3)this.colors.push(y[0],y[1],y[2]);else{let e=_.color;this.colors.push(e,e,e)}if(a===!0){let n=i[0][t];n===void 0?(console.warn(`THREE.DirectGeometry.fromGeometry(): Undefined vertexUv `,t),this.uvs.push(new e.Vector2,new e.Vector2,new e.Vector2)):this.uvs.push(n[0],n[1],n[2])}if(o===!0){let n=i[1][t];n===void 0?(console.warn(`THREE.DirectGeometry.fromGeometry(): Undefined vertexUv2 `,t),this.uvs2.push(new e.Vector2,new e.Vector2,new e.Vector2)):this.uvs2.push(n[0],n[1],n[2])}for(let e=0;e<c;e++){let t=s[e].vertices;l[e].data.push(t[_.a],t[_.b],t[_.c])}for(let e=0;e<d;e++){let n=u[e].vertexNormals[t];f[e].data.push(n.a,n.b,n.c)}h&&this.skinIndices.push(p[_.a],p[_.b],p[_.c]),g&&this.skinWeights.push(m[_.a],m[_.b],m[_.c])}return this.computeGroups(t),this.verticesNeedUpdate=t.verticesNeedUpdate,this.normalsNeedUpdate=t.normalsNeedUpdate,this.colorsNeedUpdate=t.colorsNeedUpdate,this.uvsNeedUpdate=t.uvsNeedUpdate,this.groupsNeedUpdate=t.groupsNeedUpdate,t.boundingSphere!==null&&(this.boundingSphere=t.boundingSphere.clone()),t.boundingBox!==null&&(this.boundingBox=t.boundingBox.clone()),this}},b=class{constructor(t,n,r,i,a,o=0){this.a=t,this.b=n,this.c=r,this.normal=i&&i.isVector3?i:new e.Vector3,this.vertexNormals=Array.isArray(i)?i:[],this.color=a&&a.isColor?a:new e.Color,this.vertexColors=Array.isArray(a)?a:[],this.materialIndex=o}clone(){return new this.constructor().copy(this)}copy(e){this.a=e.a,this.b=e.b,this.c=e.c,this.normal.copy(e.normal),this.color.copy(e.color),this.materialIndex=e.materialIndex;for(let t=0,n=e.vertexNormals.length;t<n;t++)this.vertexNormals[t]=e.vertexNormals[t].clone();for(let t=0,n=e.vertexColors.length;t<n;t++)this.vertexColors[t]=e.vertexColors[t].clone();return this}},x=`data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAAAZiS0dEAAAAAAAA+UO7fwAAAAlwSFlzAAALEwAACxMBAJqcGAAAAAd0SU1FB9sHDgwCEMBJZu0AAAAdaVRYdENvbW1lbnQAAAAAAENyZWF0ZWQgd2l0aCBHSU1QZC5lBwAABM5JREFUWMO1V0tPG2cUPZ4Hxh6DazIOrjFNqJs0FIMqWFgWQkatsmvVbtggKlSVRVf5AWz4AWz4AUSKEChll19QJYSXkECuhFxsHjEhxCYm+DWGMZ5HF72DJq4bAzFXurI0M/I5997v3u9cC65vTJVn2lX/xHINQOYSBLTLEuIuCWw4Z3IGAEvf6ASmVHjNzHCXBG4A0AjACsAOwEbO0nsFQBnAGYASAIl+ZRMR7SolMEdsByD09fV5R0ZGgg8ePPjW5/N1iqLYpuu6RZblciKR2I9Go69evnwZnZ+fjwI4IS8AKBIRzeQfJWCANwKwh0KhtrGxsYehUOin1tbW+zzP23ietzY2NnIAoGmaLsuyUiqVyvl8XtrY2NiamZn589mzZxsAUgCOAeQAnFI2tI+VxIjaAeDzoaGh7xYWFuZOTk6OZVk+12uYqqq6JEnn0Wg0OT4+/geAXwGEAdwDIFJQXC1wO4DWR48e/RCPxxclSSroVzRFUbSDg4P848ePFwH8DuAhkWih83TRQWxFOXgAwvDwcOfo6OhvXV1d39tsNtuVBwTDWBwOh1UUxVsMw1hXVlbSdCgNV43uYSvrHg6H24aHh38eHBz85TrgF9FYLHA4HLzH43FvbW2d7u/vG+dANp8FpqIlbd3d3V8Fg8EfBUFw4BONZVmL3+9vHhkZCQL4AoAHgJPK8G+yzC0XDofdoVAo5PP5vkadTBAEtr+/39ff3x8gAp/RPOEqx2qjx+NpvXv3bk9DQ0NDvQgwDIOWlhZrMBj8kgi0UJdxRgYMArzL5XJ7vd57qLPZ7Xamp6fnNgBXtQxcjFuHw+Hyer3t9SYgCAITCAScAJoBNNEY/08GOFVVrfVMv7kMNDntFD1vjIAPrlRN0xjckOm6biFQ3jwNPwDMZrOnqVTqfb3Bi8Wivru7W/VCYkwPlKOjo0IikXh7EwQikYgE4Nw0CfXKDCipVCoTj8df3QABbW1tLUc6oUgkFPMkVACUNjc337148eKvw8PDbJ2jP1taWkoCyNDVXDSECmNSK4qiKNLq6urW8+fPI/UicHx8rD59+jSVy+WOAKSJhKENwFItLtoxk8mwsixzHR0dHe3t7c5PAU+n09rs7OzJkydPYqVSaQfANoDXALIk31S2smU1TWMPDg7K5XKZ7+3t9TudTut1U7+wsFCcmJiIpdPpbQBxADsAknQWymYCOukBHYCuKApisdhpMpnURFEU79y503TVyKenpzOTk5M7e3t7MQKPV0Zv1gNm+awB0MvlshqLxfLb29uyJElWURSbXC4XXyvqxcXFs6mpqeTc3Nzu3t7e3wQcA7BPZ8Cov1pNlJplmQtAG8MwHV6v95tAINA5MDBwPxAIuLu6upr8fr/VAN3c3JQjkcjZ+vp6fnl5+d2bN29SuVzuNYAEpf01CdRChUL+X1VskHACuA3Ay3Fcu9vt7nA6nZ7m5uYWQRCaNE3jVVW15PP580KhIGUymWw2m00DOAJwSP4WwPtq4LX2Ao6USxNlQyS/RcQcdLGwlNIz6vEMAaZpNzCk2Pll94LK/cDYimxERiBwG10sxjgvEZBE0UpE6vxj+0Ct5bTaXthgEhRmja8QWNkkPGsuIpfdjpkK+cZUWTC0KredVmtD/gdlSl6EG4AMvQAAAABJRU5ErkJggg==`,S=t.default.default||t.default;function C(e,t){let n=(e,t)=>{try{let n=new URL(e,t).href;if(e&&e.split(`?`).length<2){let e=t.split(`?`);e.length===2&&(n=n+`?`+e[1])}return n}catch{console.error(`There is an issue creating the url link with: ${e}.`)}};if(Array.isArray(e)){let r=[];return e.forEach(e=>{r.push(n(e,t))}),r}return n(e,t)}function w(e,t,n,r,i){let a=e.morphTargetInfluences,o;e.geometry&&(o=e.geometry.morphAttributes);let s=!1;if(a&&o&&o.position){r.set(0,0,0),i.set(0,0,0);for(let e=0;e<a.length;e++)a[e]>0&&(s=!0,n.setFromArray(o.position[e].array),r.add(n.min.multiplyScalar(a[e])),i.add(n.max.multiplyScalar(a[e])));s&&t.set(r,i)}s||t.setFromBufferAttribute(e.geometry.attributes.position),e.updateWorldMatrix(!0,!0),t.applyMatrix4(e.matrixWorld)}function T(e,t,n,r){fetch(e).then(e=>{if(!e.ok)throw Error(`HTTP error! status: ${e.status}`);return e.text()}).then(e=>{n(e,t)}).catch(t=>{console.error(`Fetch string payload retrieval failed for: ${requestURL}`,t),r(e)})}function E(e,t,n){let r=e.length,i=0,a=[];function o(e,n){a[n]=e,i++,i==r&&t(a)}for(let t=0;t<r;t++)T(e[t],t,o,n)}var D=(t,n)=>{let r=Math.floor(n/3),i=n%3,a=0;i==0?a=t[r].r:i==1?a=t[r].g:i==2&&(a=t[r].b);let o=new e.Color(a);return[o.r,o.g,o.b]},O=function(e,t){if(t&&e&&e.morphAttributes&&e.morphAttributes.color){let n=e.morphAttributes.color,r=t.morphTargetInfluences,i=r.length;e.deleteAttribute(`morphColor0`),e.deleteAttribute(`morphColor1`);let a=0,o=[];for(let e=0;1>a||e<i;e++)r[e]>0&&(a++,o.push([e,r[e]]));o.length==2?(e.setAttribute(`morphColor0`,n[o[0][0]]),e.setAttribute(`morphColor1`,n[o[1][0]])):o.length==1&&(e.setAttribute(`morphColor0`,n[o[0][0]]),e.setAttribute(`morphColor1`,n[o[0][0]]))}},k=(t,n)=>{let r;return t instanceof v?(n.localTimeEnabled&&!t.morphNormalsReady&&(t.morphNormals==null||t.morphNormals.length==0)&&t.computeMorphNormals(),r=t.toIndexedBufferGeometry(),n.localMorphColour&&A(t,r)):t instanceof e.BufferGeometry&&(r=t.clone()),r.colorsNeedUpdate=!0,r.computeBoundingBox(),r.computeBoundingSphere(),t._video&&(r._video=t._video),r},A=(t,n)=>{if(t&&t.morphColors&&t.morphColors.length>0){let r=[],i=t.morphColors;for(let t=0,n=i.length;t<n;t++){let n=i[t],a=[];for(let e=0;e<n.colors.length*3;e++){let t=D(n.colors,e);a.push(t[0],t[1],t[2])}let o=new e.Float32BufferAttribute(a,3);o.name=n.name,r.push(o)}n.morphAttributes.color=r}};function j(t){let n,r,i,a=-1,o=0;for(let e=0;e<t.length;++e){let s=t[e];if(n===void 0&&(n=s.array.constructor),n!==s.array.constructor)return console.error(`THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.array must be of consistent array types across matching attributes.`),null;if(r===void 0&&(r=s.itemSize),r!==s.itemSize)return console.error(`THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes.`),null;if(i===void 0&&(i=s.normalized),i!==s.normalized)return console.error(`THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes.`),null;if(a===-1&&(a=s.gpuType),a!==s.gpuType)return console.error(`THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.gpuType must be consistent across matching attributes.`),null;o+=s.count*r}let s=new n(o),c=new e.BufferAttribute(s,r,i),l=0;for(let e=0;e<t.length;++e){let n=t[e];if(n.isInterleavedBufferAttribute){let e=l/r;for(let t=0,i=n.count;t<i;t++)for(let i=0;i<r;i++){let r=n.getComponent(t,i);c.setComponent(t+e,i,r)}}else s.set(n.array,l);l+=n.count*r}return a!==void 0&&(c.gpuType=a),c}var M=(t,n=!1)=>{let r=t[0].index!==null,i=new Set(Object.keys(t[0].attributes)),a=new Set(Object.keys(t[0].morphAttributes)),o={},s={},c=t[0].morphTargetsRelative,l=new e.BufferGeometry,u=0;for(let e=0;e<t.length;++e){let d=t[e],f=0;if(r!==(d.index!==null))return console.error(`THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index `+e+`. All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them.`),null;for(let t in d.attributes){if(!i.has(t))return console.error(`THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index `+e+`. All geometries must have compatible attributes; make sure "`+t+`" attribute exists among all geometries, or in none of them.`),null;o[t]===void 0&&(o[t]=[]),o[t].push(d.attributes[t]),f++}if(f!==i.size)return console.error(`THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index `+e+`. Make sure all geometries have the same number of attributes.`),null;if(c!==d.morphTargetsRelative)return console.error(`THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index `+e+`. .morphTargetsRelative must be consistent throughout all geometries.`),null;for(let t in d.morphAttributes){if(!a.has(t))return console.error(`THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index `+e+`. .morphAttributes must be consistent throughout all geometries.`),null;s[t]===void 0&&(s[t]=[]),s[t].push(d.morphAttributes[t])}if(n){let t;if(r)t=d.index.count;else if(d.attributes.position!==void 0)t=d.attributes.position.count;else return console.error(`THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index `+e+`. The geometry must have either an index or a position attribute`),null;l.addGroup(u,t,e),u+=t}}if(r){let e=0,n=[];for(let r=0;r<t.length;++r){let i=t[r].index;for(let t=0;t<i.count;++t)n.push(i.getX(t)+e);e+=t[r].attributes.position.count}l.setIndex(n)}for(let e in o){let t=j(o[e]);if(!t)return console.error(`THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the `+e+` attribute.`),null;l.setAttribute(e,t)}for(let e in s){let t=s[e][0].length;if(t===0)break;l.morphAttributes=l.morphAttributes||{},l.morphAttributes[e]=[];for(let n=0;n<t;++n){let t=[];for(let r=0;r<s[e].length;++r)t.push(s[e][r][n]);let r=j(t);if(!r)return console.error(`THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the `+e+` morphAttribute.`),null;l.morphAttributes[e].push(r)}}return l};function N(t,n){if(n&&t>=n.length){let r=new e.BufferGeometry,i=new Float32Array(t*3),a=0;return n.forEach(e=>{i[a++]=e[0],i[a++]=e[1],i[a++]=e[2]}),r.setAttribute(`position`,new e.BufferAttribute(i,3)),r.setDrawRange(0,n.length),r}}function P(){let t=new Image;t.src=x;let n=new e.Texture;return n.image=t,n.needsUpdate=!0,n}function F(e,t,n,r,i,a){let o=new S(e,t,n,r,i,a);return o.canvasScale=4,o.fontFace=r,o.fontSize=i,o.fontWeight=a,o.material.map.generateMipmaps=!0,o.material.map.anisotropy=4,o.material.sizeAttenuation=!1,o.material.alphaTest=.5,o.material.transparent=!0,o.material.depthWrite=!1,o.material.depthTest=!1,o.center.set(.5,-1.2),o.renderOrder=1e4,o}function I(e,t,n){if(n){let r=e||``,i=t||``,a=n.lastIndexOf(`/`);if(a>-1){let e,t;if(e=n.substring(0,a),t=n.substring(a+1),(e===`*`||e===`**`||e.toLowerCase()===r.toLowerCase())&&(t===`*`||t===`**`||t.toLowerCase()===i.toLowerCase()))return!0}else if(r.toLowerCase()===n.toLowerCase()||i.toLowerCase()===n.toLowerCase())return!0}return!1}function ee(t,n,r){let i=t.getAttribute(`position`),a=t.getAttribute(`normal`);if(!i)return;let o=i.itemSize,s=n*o,c=o,l=!1,u=(n,i)=>{let a=!1,l=Array.from(n.array);if(l.length>=s+c){l.splice(s,c),r&&l.concat(Array(c).fill(0)),a=!0;let n=new Float32Array(l);t.setAttribute(i,new e.BufferAttribute(n,o)),t.getAttribute(i).needsUpdate=!0}return a};return l=u(i,`position`),a&&u(a,`normal`),t.index!==null&&console.warn(`Removing vertices from indexed geometry requires index buffer recalculation.`),l}var L=function(){return function(e){e.vertexShader=e.vertexShader.replace(`#include <color_pars_vertex>`,[`varying vec3 vColor;`,`attribute vec3 morphColor0;`,`attribute vec3 morphColor1;`].join(`
2
2
  `)),e.vertexShader=e.vertexShader.replace(`#include <color_vertex>`,[`vColor.xyz = color.xyz;`,`#ifdef USE_MORPHTARGETS`,`vColor = morphColor0 * morphTargetInfluences[ 0 ];`,`vColor += morphColor1 * morphTargetInfluences[ 1 ];`,`#endif`].join(`
3
- `))}},te=new e.Vector3,R=new e.Vector3,ne=new e.Matrix4,re=new e.Ray,ie=new e.Sphere,ae=new e.Vector3,oe=new e.Vector3,se=new e.Vector3,ce=new e.Vector3,le=class extends e.Object3D{constructor(t=new e.BufferGeometry,n=new e.LineBasicMaterial){super(),this.type=`Line`,this.geometry=t,this.material=n,this.updateMorphTargets()}copy(e){return super.copy(e),this.material=e.material,this.geometry=e.geometry,this}computeLineDistances(){let t=this.geometry;if(t.isBufferGeometry){if(t.index===null){let n=t.attributes.position,r=[0];for(let e=1,t=n.count;e<t;e++)te.fromBufferAttribute(n,e-1),R.fromBufferAttribute(n,e),r[e]=r[e-1],r[e]+=te.distanceTo(R);t.setAttribute(`lineDistance`,new e.Float32BufferAttribute(r,1))}else console.warn(`THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.`)}else t.isGeometry&&console.error(`THREE.Line.computeLineDistances() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.`);return this}raycast(t,n){let r=this.geometry,i=this.matrixWorld,a=t.params.Line.threshold,o=r.drawRange,s=r.morphAttributes.position;if(r.boundingSphere===null&&r.computeBoundingSphere(),ie.copy(r.boundingSphere),ie.applyMatrix4(i),ie.radius+=a,t.ray.intersectsSphere(ie)===!1)return;ne.copy(i).invert(),re.copy(t.ray).applyMatrix4(ne);let c=a/((this.scale.x+this.scale.y+this.scale.z)/3),l=c*c,u=new e.Vector3,d=new e.Vector3,f=new e.Vector3,p=new e.Vector3,m=this.isLineSegments?2:1;if(r.isBufferGeometry){let e=r.index,i=r.attributes.position;if(e!==null){let r=Math.max(0,o.start),a=Math.min(e.count,o.start+o.count);for(let o=r,c=a-1;o<c;o+=m){let r=e.getX(o),a=e.getX(o+1);if(ue(u,d,this,i,s,r,a),re.distanceSqToSegment(u,d,p,f)>l)continue;p.applyMatrix4(this.matrixWorld);let c=t.ray.origin.distanceTo(p);c<t.near||c>t.far||n.push({distance:c,point:f.clone().applyMatrix4(this.matrixWorld),index:o,face:null,faceIndex:null,object:this})}}else{let e=Math.max(0,o.start),r=Math.min(i.count,o.start+o.count);for(let a=e,o=r-1;a<o;a+=m){if(ue(u,d,this,i,s,a,a+1),re.distanceSqToSegment(u,d,p,f)>l)continue;p.applyMatrix4(this.matrixWorld);let e=t.ray.origin.distanceTo(p);e<t.near||e>t.far||n.push({distance:e,point:f.clone().applyMatrix4(this.matrixWorld),index:a,face:null,faceIndex:null,object:this})}}}else r.isGeometry&&console.error(`THREE.Line.raycast() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.`)}updateMorphTargets(){let e=this.geometry;if(e.isBufferGeometry){let t=e.morphAttributes,n=Object.keys(t);if(n.length>0){let e=t[n[0]];if(e!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let t=0,n=e.length;t<n;t++){let n=e[t].name||String(t);this.morphTargetInfluences.push(0),this.morphTargetDictionary[n]=t}}}}else{let t=e.morphTargets;t!==void 0&&t.length>0&&console.error(`THREE.Line.updateMorphTargets() does not support THREE.Geometry. Use THREE.BufferGeometry instead.`)}}};function ue(e,t,n,r,i,a,o){e.fromBufferAttribute(r,a),t.fromBufferAttribute(r,o);var s=n.morphTargetInfluences;if(n.material.morphTargets&&i&&s){ae.set(0,0,0),oe.set(0,0,0);for(var c=0,l=i.length;c<l;c++){var u=s[c],d=i[c];u!==0&&(se.fromBufferAttribute(d,a),ce.fromBufferAttribute(d,o),ae.addScaledVector(se.sub(e),u),oe.addScaledVector(ce.sub(t),u))}e.add(ae),t.add(oe)}}le.prototype.isLine=!0;var de=new e.Vector3,fe=new e.Vector3,pe=class extends le{constructor(e,t){super(e,t),this.type=`LineSegments`}computeLineDistances(){let t=this.geometry;if(t.isBufferGeometry){if(t.index===null){let n=t.attributes.position,r=[];for(let e=0,t=n.count;e<t;e+=2)de.fromBufferAttribute(n,e),fe.fromBufferAttribute(n,e+1),r[e]=e===0?0:r[e-1],r[e+1]=r[e]+de.distanceTo(fe);t.setAttribute(`lineDistance`,new e.Float32BufferAttribute(r,1))}else console.warn(`THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.`)}else t.isGeometry&&console.error(`THREE.LineSegments.computeLineDistances() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.`);return this}};pe.prototype.isLineSegments=!0;var z=function(t){this.levels=[],this._currentLevel=0,this._renderOrder=1,this._material=void 0,this._secondaryMaterial=void 0,this._loader=void 0,this._parent=t,this.addLevel=(e,t)=>{if(e){let n=Math.abs(t),r;for(r=0;r<this.levels.length&&!(n<this.levels[r].distance);r++);let i={distance:n,morph:e,loaded:!0,loading:!1,url:``};this.levels.splice(r,0,i),e.renderOrder=this._renderOrder}},this.levelLoaded=(e,t)=>{if(e){let n=Math.abs(t);for(let t=0;t<this.levels.length;t++)if(n===this.levels[t].distance){this._parent.group.add(e),this.levels[t].morph=e,this.levels[t].loaded=!0,this.levels[t].loading=!1;break}this.checkTransparentMesh()}},this.addLevelFromURL=(e,t,n,r,i)=>{this._loader=e;let a=this.calculateDistance(t),o={distance:a,morph:void 0,loaded:!1,loading:!1,url:n,index:r},s;for(s=0;s<this.levels.length&&!(a<this.levels[s].distance);s++);this.levels.splice(s,0,o),i&&this.loadLevel(s)},this.loadLevel=e=>{let t=this.levels[e];return!t.morph&&!t.loaded&&!t.loading&&(t.loading=!0,this._loader.load(t.url,this.lodLoader(t.distance),void 0,void 0,{index:t.index})),t.morph===void 0},this.calculateDistance=function(e){this._parent.getBoundingBox();let t=this._parent.radius,n=0;return e===`far`?n=t*4.5:e===`medium`?n=t*2.5:e===`close`&&(n=0),n},this.containsLevels=()=>!!(this.levels&&this.levels.length>1),this.checkTransparentMesh=()=>{let t=this.levels[this._currentLevel];this._material&&(this._material.transparent?(this._secondaryMaterial||(this._secondaryMaterial=this._material.clone(),this._secondaryMaterial.side=e.FrontSide),this._secondaryMaterial.opacity=this._material.opacity,this._secondaryMaterial.emissive&&this._secondaryMaterial.emissive.copy(this._material.emissive),this._secondaryMaterial.needsUpdate=!0,t.secondaryMesh||(t.secondaryMesh=new e.Mesh(t.morph.geometry,this._secondaryMaterial),t.secondaryMesh.renderOrder=t.morph.renderOrder+1,t.secondaryMesh.userData=t.morph.userData,t.secondaryMesh.name=t.morph.name),this._material.side=e.BackSide,this._material.needsUpdate=!0,t.secondaryMesh.parent||(t.morph.add(t.secondaryMesh),this._parent.animationGroup&&this._parent.animationGroup.add(t.secondaryMesh))):(t.secondaryMesh&&(t.morph.remove(t.secondaryMesh),this._parent.animationGroup&&(this._parent.animationGroup.uncache(t.secondaryMesh),this._parent.animationGroup.remove(t.secondaryMesh))),this._material.side=e.DoubleSide,this._material.needsUpdate=!0))},this.dispose=()=>{this.levels.forEach(e=>{e.morph&&e.morph.geometry&&e.morph.geometry.dispose()}),this._material&&this._material.dispose(),this._secondaryMaterial&&this._secondaryMaterial.dispose()},this.getCurrentLevel=()=>this._currentLevel,this.getCurrentMorph=()=>{let e=this.levels[this._currentLevel];return e&&e.morph?e.morph:this._parent.morph},this.lodLoader=function(t){return n=>{let r=this._material,i=k(n,{localTimeEnabled:this._parent.timeEnabled,localMorphColour:this._parent.morphColour}),a;this._parent.isGeometry?a=new e.Mesh(i,r):this._parent.isLines&&(a=new pe(i,r)),a.userData=this._parent,a.renderOrder=this._renderOrder,n.dispose(),this.levelLoaded(a,t)}},this.updateMorphColorAttribute=t=>{if(this._material&&(this._material.vertexColors==e.VertexColors||this._material.vertexColors==1)){if(t){let e=this.getCurrentMorph();O(e.geometry,e)}else this.levels.forEach(e=>{e.morph&&e.morph.geometry&&O(e.morph.geometry,e.morph)})}},this.setColour=e=>{this._material.color=e,this._secondaryMaterial&&(this._secondaryMaterial.color=e),n()},this.setFrustumCulled=e=>{this.levels.forEach(t=>{t.morph&&(t.morph.frustumCulled=e),t.secondaryMesh&&(t.secondaryMesh.frustumCulled=e)})},this.setMaterial=t=>{t&&(!this._material||this._material.id!==t.id)&&(this._material=t,this._secondaryMaterial&&this._secondaryMaterial.dispose(),this._secondaryMaterial=t.clone(),this._secondaryMaterial.side=e.FrontSide,this._secondaryMaterial.transparent=!0,this.levels.forEach(e=>{e.morph&&(e.morph.material=this._material,e.morph.geometry&&(e.morph.geometry.colorsNeedUpdate=!0)),e.secondaryMesh&&(e.secondaryMesh.material=this._secondaryMaterial)}))},this.setName=e=>{this.levels.forEach(t=>{t.morph&&(t.morph.name=e),t.secondaryMesh&&(t.secondaryMesh.name=e)})},this.setRenderOrder=e=>{this._renderOrder=e,this.levels.forEach(t=>{t.morph&&(t.morph.renderOrder=e),t.secondaryMesh&&(t.secondaryMesh.renderOrder=e)})},this.setVertexColors=e=>{this._material.vertexColors=e,n(),this._secondaryMaterial&&(this._secondaryMaterial.vertexColors=e)},this.update=(e,t)=>{let n=this.levels;if(n.length>1){let r=e.cameraObject.position.distanceTo(t),i=-1,a=-1,o,s;for(o=0,s=n.length;o<s&&r>=n[o].distance;o++)n[o].morph?(i>-1&&n[i].morph&&(n[i].morph.visible=!1),i=o,n[o].morph.visible=!0,a=-1):a=o;for(a>-1&&this.loadLevel(a);o<s;o++)n[o].morph&&(i>-1?n[o].morph.visible=!1:(n[o].morph.visible=!0,i=o));this._currentLevel!=i&&(this._currentLevel=i,this.checkTransparentMesh())}},this.toggleMarker=(e,t)=>{this.levels.forEach(n=>{n.morph&&(t?n.morph.add(e):n.morph.remove(e))})};let n=()=>{this.levels.forEach(e=>{e.morph&&e.morph.geometry&&(e.morph.geometry.colorsNeedUpdate=!0)})}},me=`data:image/svg+xml,%3c?xml%20version='1.0'%20encoding='UTF-8'%20standalone='no'%20?%3e%3c!DOCTYPE%20svg%20PUBLIC%20'-//W3C//DTD%20SVG%201.1//EN'%20'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'%3e%3csvg%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20version='1.1'%20width='365'%20height='560'%20viewBox='0%200%20365%20560'%20xml:space='preserve'%3e%3cdesc%3eCreated%20with%20Fabric.js%205.2.4%3c/desc%3e%3cdefs%3e%3c/defs%3e%3crect%20x='0'%20y='0'%20width='100%25'%20height='100%25'%20fill='transparent'%3e%3c/rect%3e%3cg%20transform='matrix(0%200%200%200%200%200)'%20id='808ed283-2524-440f-88ae-3bdb47bb5749'%20%3e%3c/g%3e%3cg%20transform='matrix(1%200%200%201%20182.5%20280)'%20id='db30413d-5bff-4b98-ab59-464497ee199e'%20%3e%3crect%20style='stroke:%20none;%20stroke-width:%201;%20stroke-dasharray:%20none;%20stroke-linecap:%20butt;%20stroke-dashoffset:%200;%20stroke-linejoin:%20miter;%20stroke-miterlimit:%204;%20fill:%20rgb(255,255,255);%20fill-rule:%20nonzero;%20opacity:%201;%20visibility:%20hidden;'%20vector-effect='non-scaling-stroke'%20x='-182.5'%20y='-280'%20rx='0'%20ry='0'%20width='365'%20height='560'%20/%3e%3c/g%3e%3cg%20transform='matrix(0%200%200%200%200%2097.5)'%20%3e%3cg%20style=''%20%3e%3c/g%3e%3c/g%3e%3cg%20transform='matrix(0%200%200%200%200%2097.5)'%20%3e%3cg%20style=''%20%3e%3c/g%3e%3c/g%3e%3cg%20transform='matrix(0.99%200%200%200.99%20182.5%20280)'%20%3e%3cg%20style=''%20vector-effect='non-scaling-stroke'%20%3e%3cg%20transform='matrix(1%200%200%201%200%200)'%20%3e%3crect%20style='stroke:%20none;%20stroke-width:%201;%20stroke-dasharray:%20none;%20stroke-linecap:%20butt;%20stroke-dashoffset:%200;%20stroke-linejoin:%20miter;%20stroke-miterlimit:%204;%20fill:%20rgb(255,255,255);%20fill-rule:%20nonzero;%20opacity:%201;%20visibility:%20hidden;'%20vector-effect='non-scaling-stroke'%20x='-540'%20y='-540'%20rx='0'%20ry='0'%20width='1080'%20height='1080'%20/%3e%3c/g%3e%3cg%20transform='matrix(1%200%200%201%200%200)'%20%3e%3cpath%20style='stroke:%20rgb(0,0,0);%20stroke-width:%200;%20stroke-dasharray:%20none;%20stroke-linecap:%20butt;%20stroke-dashoffset:%200;%20stroke-linejoin:%20miter;%20stroke-miterlimit:%204;%20fill:%20rgb(0,89,116);%20fill-rule:%20nonzero;%20opacity:%201;'%20vector-effect='non-scaling-stroke'%20transform='%20translate(-182.9,%20-279.85)'%20d='M%20182.9%20551.7%20C%20182.9%20551.8000000000001%20183.1%20552%20183.1%20552%20C%20183.1%20552%20358.3%20283%20358.3%20194.6%20C%20358.3%2064.5%20269.5%207.900000000000006%20182.9%207.699999999999989%20C%2096.3%207.9%207.5%2064.5%207.5%20194.6%20C%207.5%20283%20182.8%20552%20182.8%20552%20C%20182.8%20552%20182.9%20551.7%20182.9%20551.7%20z%20M%20122.2%20187.2%20C%20122.2%20153.6%20149.4%20126.39999999999999%20183%20126.39999999999999%20C%20216.6%20126.39999999999999%20243.8%20153.6%20243.8%20187.2%20C%20243.8%20220.79999999999998%20216.5%20248%20182.9%20248%20C%20149.4%20248%20122.2%20220.8%20122.2%20187.2%20z'%20stroke-linecap='round'%20/%3e%3c/g%3e%3cg%20transform='matrix(3.82%200%200%203.82%200%20-100.77)'%20%3e%3ccircle%20style='stroke:%20rgb(0,0,0);%20stroke-width:%200;%20stroke-dasharray:%20none;%20stroke-linecap:%20butt;%20stroke-dashoffset:%200;%20stroke-linejoin:%20miter;%20stroke-miterlimit:%204;%20fill:%20rgb(255,255,255);%20fill-rule:%20nonzero;%20opacity:%201;'%20vector-effect='non-scaling-stroke'%20cx='0'%20cy='0'%20r='35'%20/%3e%3c/g%3e%3c/g%3e%3c/g%3e%3c/svg%3e`,he=new Image(128,128);he.src=me;var ge=new e.Texture;ge.image=he,ge.needsUpdate=!0;var _e=[.02,.03,1],ve=new e.SpriteMaterial({map:ge,alphaTest:.5,transparent:!0,depthTest:!1,depthWrite:!1,sizeAttenuation:!1}),ye=function(t){Object.getPrototypeOf(this)!==B.prototype&&Object.setPrototypeOf(ye.prototype,B.prototype),B.call(this),this.texture=ge;let n,r,i,a,o,s=!0;this.morph=new e.Group,this.group=this.morph,this.parent=t,this.isMarker=!0;let c=!1;this.ndc=new e.Vector3;let l,u,d=()=>{n=new e.Sprite(ve),n.center.set(.5,0),this.morph.add(n),this.morph.position.set(0,0,0),this.morph.renderOrder=1e4,n.scale.set(_e[0],_e[1],_e[2]),n.userData=this};this.updateVisual=(e,t)=>{let n=1,r=0;e!==t&&(r=1-(this.ndc.z-e)/(t-e),n=.6+r*.4),this.setSpriteSize(n)},this.updateNDC=e=>(this.ndc.copy(this.morph.position),this.ndc.project(e),this.ndc.z=Math.min(Math.max(this.ndc.z,0),1),this.ndc),this.setPosition=(e,t,n)=>{this.morph.position.set(e,t,n)},this.setSpriteSize=e=>{n.scale.set(.015,.02,1),n.scale.multiplyScalar(e)},this.setUserSprite=()=>{a&&(this.morph.add(a),s&&=(this.morph.remove(n),u&&this.morph.remove(u),!1))},this.setImageForUserSprite=(t,n)=>{a&&=(this.morph.remove(a),void 0),r&&r.dispose(),i&&i.dispose(),r=new e.Texture,r.image=t,r.needsUpdate=!0,i=new e.SpriteMaterial({map:r,alphaTest:.5,transparent:!0,depthTest:!1,depthWrite:!1,sizeAttenuation:!1}),n||=[.05,.05,1],a=new e.Sprite(i),a.center.set(.5,0),a.scale.set(n[0],n[1],n[2]),a.userData=this,this.setUserSprite()},this.setDefaultSprite=()=>{s||(s=!0,this.morph.add(n),a&&this.morph.remove(a),u&&this.morph.add(u))},this.loadUserSprite=(e,t)=>{if(e){if(e!==o){o=e;let n=new Image(128,128);n.crossOrigin=`anonymous`,n.onload=()=>{this.setImageForUserSprite(n,t)},n.src=e}else this.setUserSprite()}},this.dispose=()=>{this.morph&&this.morph.clear(),n&&=(n.clear(),void 0),u&&=(u.material.map.dispose(),u.material.dispose(),void 0)},this.isEnabled=()=>c,this.setNumber=e=>{(!e||l!=e)&&(u&&=(this.morph.remove(u),u.material.map.dispose(),u.material.dispose(),void 0)),!u&&e&&(u=F(e,.012,`black`,`Asap`,120,700),this.morph.add(u)),l=e},this.getNumber=()=>l||1,this.setVisibility=function(e){e!==this.visible&&(this.visible=e,this.group.visible=e,this.parent.region&&(this.parent.region.pickableUpdateRequired=!0))},this.enable=()=>{c=!0,this.morph.visible=!0,this.visible=!0},this.disable=()=>{c=!1,this.morph.visible=!1,this.visible=!1},d()},be=0,xe=function(){return`pr`+be++},B=function(){this.isZincObject=!0,this.geometry=void 0,this.morph=void 0,this.group=new e.Group,this._lod=new z(this),this.groupName=void 0,this.timeEnabled=!1,this.morphColour=!1,this.inbuildTime=0,this.mixer=void 0,this.animationGroup=void 0,this.duration=6e3,this.clipAction=void 0,this.userData={},this.videoHandler=void 0,this.marker=void 0,this.markerNumber=void 0,this.markerUpdateRequired=!0,this.closestVertexIndex=-1,this.boundingBoxUpdateRequired=!0,this.cachedBoundingBox=new e.Box3,this.anatomicalId=void 0,this.region=void 0,this.animationClip=void 0,this.markerMode=`inherited`,this.uuid=xe(),this._v1=new e.Vector3,this._v2=new e.Vector3,this._b1=new e.Box3,this.center=new e.Vector3,this.radius=0,this.visible=!0,this.drawRange=-1,this.origColour=void 0,this.origVertexColors=!1,this.isPickable=!0};B.prototype.setDuration=function(e){this.duration=e,this.clipAction&&this.clipAction.setDuration(this.duration)},B.prototype.getDuration=function(){return this.duration},B.prototype.setRegion=function(e){this.region=e},B.prototype.getRegion=function(){return this.region},B.prototype.getMorph=function(){return this._lod.getCurrentMorph()||this.morph},B.prototype.getGroup=function(){return this.group},B.prototype.setMorph=function(e){this.morph=e,this.group.add(this.morph);let t=this._lod.calculateDistance(`far`);this._lod.addLevel(e,t),this._lod.setMaterial(e.material)},B.prototype.checkTransparentMesh=function(){},B.prototype.setMesh=function(t,n,r){this.animationGroup=new e.AnimationObjectGroup(t),this.mixer=new e.AnimationMixer(this.animationGroup);let i=t.geometry;if(this.geometry=t.geometry,this.clipAction=void 0,i&&i.morphAttributes){let t=i.morphAttributes.position;t||=i.morphAttributes.color?i.morphAttributes.color:i.morphAttributes.normal,t&&(this.animationClip=e.AnimationClip.CreateClipsFromMorphTargetSequences(t,10,!0),this.animationClip&&this.animationClip[0]!=null&&(this.clipAction=this.mixer.clipAction(this.animationClip[0]).setDuration(this.duration),this.clipAction.loop=e.LoopRepeat,this.clipAction.clampWhenFinished=!0,this.clipAction.play()))}this.timeEnabled=n,this.morphColour=r,t.userData=this,t.matrixAutoUpdate=!1,this.setMorph(t),this.checkTransparentMesh(),this.timeEnabled?this.setFrustumCulled(!1):this.morphColour&&(i.setAttribute(`morphTarget0`,i.getAttribute(`position`)),i.setAttribute(`morphTarget1`,i.getAttribute(`position`))),this.boundingBoxUpdateRequired=!0},B.prototype.setIsPickable=function(e){this.isPickable!==e&&(this.isPickable=e,this.region&&(this.region.pickableUpdateRequired=!0))},B.prototype.setAnatomicalId=function(e){this.anatomicalId=e},B.prototype.setName=function(e){this.groupName=e,this._lod.setName(e)},B.prototype.getCurrentTime=function(){if(this.clipAction){let e=this.clipAction.time/this.clipAction._clip.duration;return this.duration*e}return this.inbuildTime},B.prototype.setMorphTime=function(e){let t=!1;if(this.clipAction){let n=e/this.duration*this.clipAction._clip.duration;n!=this.clipAction.time&&(this.clipAction.time=n,t=!0),t&&this.isTimeVarying()&&this.mixer.update(0)}else{let n=e;n=e>this.duration?this.duration:0>e?0:e,n!=this.inbuildTime&&(this.inbuildTime=n,t=!0)}t&&(this.boundingBoxUpdateRequired=!0,this._lod.updateMorphColorAttribute(!0),this.timeEnabled&&(this.markerUpdateRequired=!0))},B.prototype.isTimeVarying=function(){return!!(this.timeEnabled||this.morphColour)},B.prototype.getVisibility=function(){return this.visible},B.prototype.setVisibility=function(e){e!==this.visible&&(this.visible=e,this.group.visible=e,this.region&&(this.region.pickableUpdateRequired=!0))},B.prototype.setAlpha=function(e){let t=this._lod._material,n=!1;e<1&&(n=!0),t.opacity=e,t.transparent=n,this.checkTransparentMesh()},B.prototype.setFrustumCulled=function(e){this._lod.setFrustumCulled(e)},B.prototype.setVertexColors=function(e){this._lod.setVertexColors(e)},B.prototype.getColour=function(){if(this._lod._material)return this._lod._material.color},B.prototype.setColour=function(e){this._lod.setColour(e)},B.prototype.setGreyScale=function(t){if(t){if(!this.origColour&&this._lod._material)return this.origColour=this._lod._material.color,this.origVertexColors=this._lod._material.vertexColors,this._lod.setVertexColors(!1),this._lod.setColour(new e.Color().setHex(12303291)),!0}else if(this.origColour)return this._lod.setColour(this.origColour),this._lod.setVertexColors(this.origVertexColors),this.origColour=void 0,!0;return!1},B.prototype.getColourHex=function(){if(!this.morphColour&&this._lod._material&&this._lod._material.color)return this._lod._material.color.getHexString()},B.prototype.setColourHex=function(e){this._lod._material.color.setHex(e),this._lod._secondaryMaterial&&this._lod._secondaryMaterial.color.setHex(e)},B.prototype.setEmissiveRGB=function(e){this._lod._material&&this._lod._material.emissive&&this._lod._material.emissive.setRGB(...e),this._lod._secondaryMaterial&&this._lod._secondaryMaterial.emissive.setRGB(...e)},B.prototype.setMaterial=function(e){this._lod.setMaterial(e)},B.prototype.getClosestVertexIndex=function(){let e=-1,t=this.getMorph();if(t&&t.geometry){let n=t.geometry.attributes.position;if(n){this._b1.setFromBufferAttribute(n),this._b1.getCenter(this._v1);let t=-1,r=0;for(let i=0;i<n.count;i++)this._v2.fromArray(n.array,i*3),r=this._v2.distanceTo(this._v1),t==-1?t=r:t>r&&(t=r,e=i)}}return e},B.prototype.getClosestVertex=function(t){let n=new e.Vector3;this.closestVertexIndex==-1&&(this.closestVertexIndex=this.getClosestVertexIndex());let r=this.getMorph();if(r&&r.geometry&&this.closestVertexIndex>=0){let e=r.morphTargetInfluences,i=r.geometry.morphAttributes;if(e&&i&&i.position){let a=!1;for(let t=0;t<e.length;t++)e[t]>0&&(a=!0,this._v1.fromArray(i.position[t].array,this.closestVertexIndex*3),n.add(this._v1.multiplyScalar(e[t])));if(a)return t?n.applyMatrix4(r.matrixWorld):n}else return n.fromArray(r.geometry.attributes.position.array,this.closestVertexIndex*3),t?n.applyMatrix4(r.matrixWorld):n}return this.getBoundingBox(),n.copy(this.center),n},B.prototype.getBoundingBox=function(){if(this.visible){let e=this._lod.getCurrentMorph();if(e&&e.visible)return this.boundingBoxUpdateRequired&&=(w(e,this.cachedBoundingBox,this._b1,this._v1,this._v2),this.cachedBoundingBox.getCenter(this.center),this.radius=this.center.distanceTo(this.cachedBoundingBox.max),!1),this.cachedBoundingBox}},B.prototype.dispose=function(){this._lod.dispose(),this.animationGroup=void 0,this.mixer=void 0,this.morph=void 0,this.group=void 0,this.clipAction=void 0,this.groupName=void 0},B.prototype.markerIsRequired=function(e){return!!(this.visible&&(this.markerMode===`on`||e&&e.displayMarkers&&this.markerMode===`inherited`))},B.prototype.updateMarker=function(e,t){if(e==0&&this.markerIsRequired(t)){let e=t.ndcToBeUpdated;if(this.groupName){if(this.marker||(this.marker=new ye(this),this.markerUpdateRequired=!0),this.markerUpdateRequired){let e=this.getClosestVertex(!1);e&&(this.marker.setPosition(e.x,e.y,e.z),this.markerUpdateRequired=!1)}this.marker.isEnabled()||(t.markersList&&!(this.marker.uuid in t.markersList)&&(e=!0,t.markersList[this.marker.uuid]=this.marker),this.marker.enable(),this.group.add(this.marker.morph)),this.marker.setNumber(this.markerNumber),this.markerImgURL?this.marker.loadUserSprite(this.markerImgURL):this.marker.setDefaultSprite(),t&&t.camera&&(e||t.markerCluster.markerUpdateRequired)&&(this.marker.updateNDC(t.camera.cameraObject),t.markerCluster.markerUpdateRequired=!0)}}else this.marker&&this.marker.isEnabled()&&(this.marker.disable(),this.group.remove(this.marker.morph),t.markersList&&this.marker.uuid in t.markersList&&(t.markerCluster.markerUpdateRequired=!0,delete t.markersList[this.marker.uuid])),this.markerUpdateRequired=!0},B.prototype.processMarkerVisual=function(e,t){this.marker&&this.marker.isEnabled()&&this.marker.updateVisual(e,t)},B.prototype.initiateMorphColor=function(){this.morphColour==1&&this._lod.updateMorphColorAttribute(!1)},B.prototype.setRenderOrder=function(e){this._lod.setRenderOrder(e)},B.prototype.getClosestVertexDOMElementCoords=function(e){if(e&&e.camera){let t=!0,n=this.getClosestVertex(!0);return n.project(e.camera),n.z=Math.min(Math.max(n.z,0),1),(n.x>1||n.x<-1||n.y>1||n.y<-1)&&(t=!1),e.getZincCameraControls().getRelativeCoordsFromNDC(n.x,n.y,n),{position:n,inView:t}}},B.prototype.setMarkerMode=function(e,t){e!==this.markerMode&&(this.markerMode=e===`on`||e===`off`?e:`inherited`,this.region&&(this.region.pickableUpdateRequired=!0)),t&&(this.markerNumber=t.number,this.markerImgURL=t.imgURL)},B.prototype.render=function(e,t,n,r){if(this.visible&&!(this.timeEnabled&&t)&&this._lod.update(n,this.center),t==1){if(this.clipAction&&this.isTimeVarying())this.mixer.update(e);else{let t=this.inbuildTime+e;t>this.duration&&(t-=this.duration),this.inbuildTime=t}this.visible&&e!=0&&(this.boundingBoxUpdateRequired=!0,this.morphColour==1&&this._lod.updateMorphColorAttribute(!0))}this.updateMarker(t,r)},B.prototype.addLOD=function(e,t,n,r,i){this._lod.addLevelFromURL(e,t,n,r,i)},B.prototype.addVertices=function(e){let t=this.getMorph(),n;if(!t)n=N(500,e),this.drawRange=e.length;else if(this.drawRange>-1){let r=t.geometry.getAttribute(`position`);e.forEach(e=>{r.setXYZ(this.drawRange,e[0],e[1],e[2]),++this.drawRange}),r.needsUpdate=!0,t.geometry.setDrawRange(0,this.drawRange),t.geometry.computeBoundingBox(),t.geometry.computeBoundingSphere(),n=t.geoemtry,this.boundingBoxUpdateRequired=!0}return n},B.prototype.deleteVertices=function(e){let t=this.getMorph();return t?.geometry&&this.drawRange>=e&&ee(t.geometry,e,!0)?(--this.drawRange,t.geometry.setDrawRange(0,this.drawRange),t.geometry.computeBoundingBox(),t.geometry.computeBoundingSphere(),this.boundingBoxUpdateRequired=!0,!0):!1},B.prototype.setPosition=function(e,t,n){let r=this.getGroup();r&&(r.position.set(e,t,n),r.matrixWorldNeedsUpdate=!0,r.updateMatrix(),r.updateWorldMatrix(!0,!0),this.boundingBoxUpdateRequired=!0)},B.prototype.loadAdditionalSources=function(e,t){e.load(filename,meshloader(region,colour,opacity,localTimeEnabled,localMorphColour,void 0,void 0,void 0,void 0,finishCallback),this.onProgress(filename),this.onError(finishCallback))},B.prototype.setScaleAll=function(e){let t=this.getGroup();t&&(t.scale.set(e,e,e),t.updateMatrix(),this.boundingBoxUpdateRequired=!0)};var Se=(t,n,r)=>{let i=k(t,r),a=!1;1>r.opacity&&(a=!0);let o;if(i._video===void 0){let t=r.localTimeEnabled||r.localMorphColour;n?(o=n,o.morphTargets=t,o.morphNormals=r.localTimeEnabled):o=i instanceof e.BufferGeometry&&i.attributes.color===void 0?new e.MeshPhongMaterial({color:r.colour,morphTargets:t,morphNormals:r.localTimeEnabled,transparent:a,opacity:r.opacity,side:e.DoubleSide}):new e.MeshPhongMaterial({color:r.colour,morphTargets:t,morphNormals:r.localTimeEnabled,vertexColors:e.VertexColors,transparent:a,opacity:r.opacity,side:e.DoubleSide}),r.localMorphColour&&i.morphAttributes.color&&(o.onBeforeCompile=L())}else{let t=i._video.createCanvasVideoTexture();o=new e.MeshBasicMaterial({morphTargets:r.localTimeEnabled,color:new e.Color(1,1,1),transparent:a,opacity:r.opacity,map:t,side:e.DoubleSide}),(void 0).videoHandler=i._video}return new e.Mesh(i,o)},Ce=function(){B.call(this),this.videoHandler=void 0,this.isGeometry=!0,this.createMesh=(e,t,n)=>{if(this.morph&&this.morph.geometry&&e!=null)return;let r=Se(e,t,n);this.setMesh(r,n.localTimeEnabled,n.localMorphColour)},this.calculateUVs=()=>{this.geometry.computeBoundingBox();let t=this.geometry.boundingBox.max,n=this.geometry.boundingBox.min,r=new e.Vector2(0-n.x,0-n.y),i=new e.Vector2(t.x-n.x,t.y-n.y);this.geometry.faceVertexUvs[0]=[];for(let t=0;t<this.geometry.faces.length;t++){let n=this.geometry.vertices[this.geometry.faces[t].a],a=this.geometry.vertices[this.geometry.faces[t].b],o=this.geometry.vertices[this.geometry.faces[t].c];geometry.faceVertexUvs[0].push([new e.Vector2((n.x+r.x)/i.x,(n.y+r.y)/i.y),new e.Vector2((a.x+r.x)/i.x,(a.y+r.y)/i.y),new e.Vector2((o.x+r.x)/i.x,(o.y+r.y)/i.y)])}geometry.uvsNeedUpdate=!0},this.checkTransparentMesh=function(){this._lod.checkTransparentMesh()},this.setWireframe=e=>{this.morph.material.wireframe=e},this.editVertices=function(e,t){if(e&&e.length){let n=this.getMorph(),r=n.geometry.getAttribute(`position`);if(!n||0>t)return;{let i=t*3;e.forEach(e=>{r.array[i++]=e[0],r.array[i++]=e[1],r.array[i++]=e[2]}),r.needsUpdate=!0,n.geometry.computeBoundingBox(),n.geometry.computeBoundingSphere(),this.boundingBoxUpdateRequired=!0}}}};Ce.prototype=Object.create(B.prototype);var we=t.default.default||t.default,Te=function(e,t){let n=e,r,i=500;r=t?new we(n,.012,t.getStyle()):new we(n,.012),r.fontFace=`Asap`,r.fontWeight=i,r.material.map.generateMipmaps=!1,r.material.sizeAttenuation=!1,r.center.x=-.05,r.center.y=0;let a=[r.scale.x,r.scale.y];this.getPosition=()=>r?[r.position.x,r.position.y,r.position.z]:[0,0,0],this.setPosition=(e,t,n)=>{r&&r.position.set(e,t,n)},this.setColour=e=>{e&&(r.color=e.getStyle())},this.setScale=e=>{r&&e>0&&r.scale.set(e,e,1)},this.setDepthTest=e=>{e&&e!==r.material.depthTest&&(r.material.depthTest=e)},this.setSize=e=>{e>0&&(r.scale.x=a[0]*e,r.scale.y=a[1]*e)},this.setFontWeight=e=>{e&&e!==i&&(r.fontWeight=e,i=e)},this.setText=e=>{e&&e!==r.text&&(r.text=e,n=e)},this.setVisibility=e=>{r.visible=e},this.dispose=()=>{},this.getSprite=()=>r,this.getString=()=>n},Ee=function(t,n,r,i){B.call(this);let a;n&&(a=n.clone(),a.vertexColors=e.FaceColors);let o=i;this.id=r;let s,c;this.isGlyph=!0;let l=[0,0,0];this.fromMesh=e=>e&&e.isMesh?(this.morph=e.clone(),this.morph.userData=this,this.group.add(this.morph),!0):!1,t&&a&&this.fromMesh(new e.Mesh(t,a)),this.getGlyphset=function(){return o},this.setLabel=e=>{e&&(typeof e==`string`||e instanceof String)&&(c=e,this.morph&&(this.morph.name=e))},this.showLabel=e=>{if(s&&=(l=s.getPosition(),this.group.remove(s.getSprite()),s.dispose(),void 0),c&&(typeof c==`string`||c instanceof String)){s=new Te(c,e),s.setPosition(l[0],l[1],l[2]);let t=s.getSprite();t.material.alphaTest=.5,t.material.transparent=!0,t.material.depthWrite=!1,this.group.add(s.getSprite())}},this.hideLabel=()=>{s&&=(l=s.getPosition(),this.group.remove(s.getSprite()),s.dispose(),void 0)},this.getLabel=()=>c,this.getMesh=()=>this.morph,this.setTransformation=(e,t,n,r)=>{this.morph&&(this.morph.matrix.elements[0]=t[0],this.morph.matrix.elements[1]=t[1],this.morph.matrix.elements[2]=t[2],this.morph.matrix.elements[3]=0,this.morph.matrix.elements[4]=n[0],this.morph.matrix.elements[5]=n[1],this.morph.matrix.elements[6]=n[2],this.morph.matrix.elements[7]=0,this.morph.matrix.elements[8]=r[0],this.morph.matrix.elements[9]=r[1],this.morph.matrix.elements[10]=r[2],this.morph.matrix.elements[11]=0,this.morph.matrix.elements[12]=e[0],this.morph.matrix.elements[13]=e[1],this.morph.matrix.elements[14]=e[2],this.morph.matrix.elements[15]=1,this.morph.matrixAutoUpdate=!1),l=[...e],s&&s.setPosition(e[0],e[1],e[2])},this.setColour=e=>{s&&s.setColour(e),this.secondaryMesh&&this.secondaryMesh.material&&(this.secondaryMesh.material.color=colour),this.geometry&&(this.geometry.colorsNeedUpdate=!0)},this.dispose=()=>{this.material&&this.material.dispose(),this.morph=void 0}};Ee.prototype=Object.create(B.prototype);function De(){}De.Handlers={handlers:[],add:function(e,t){this.handlers.push(e,t)},get:function(e){for(var t=this.handlers,n=0,r=t.length;n<r;n+=2){var i=t[n],a=t[n+1];if(i.test(e))return a}return null}},Object.assign(De.prototype,{crossOrigin:`anonymous`,onLoadStart:function(){},onLoadProgress:function(){},onLoadComplete:function(){},initMaterials:function(e,t,n){for(var r=[],i=0;i<e.length;++i)r[i]=this.createMaterial(e[i],t,n);return r},createMaterial:(function(){var t={NoBlending:e.NoBlending,NormalBlending:e.NormalBlending,AdditiveBlending:e.AdditiveBlending,SubtractiveBlending:e.SubtractiveBlending,MultiplyBlending:e.MultiplyBlending,CustomBlending:e.CustomBlending},n=new e.Color,r=new e.TextureLoader,i=new e.MaterialLoader;return function(a,o,s){var c={};function l(t,n,i,a,l){var u=o+t,d=De.Handlers.get(u),f;d===null?(r.setCrossOrigin(s),f=r.load(u)):f=d.load(u),n!==void 0&&(f.repeat.fromArray(n),n[0]!==1&&(f.wrapS=e.RepeatWrapping),n[1]!==1&&(f.wrapT=e.RepeatWrapping)),i!==void 0&&f.offset.fromArray(i),a!==void 0&&(a[0]===`repeat`&&(f.wrapS=e.RepeatWrapping),a[0]===`mirror`&&(f.wrapS=e.MirroredRepeatWrapping),a[1]===`repeat`&&(f.wrapT=e.RepeatWrapping),a[1]===`mirror`&&(f.wrapT=e.MirroredRepeatWrapping)),l!==void 0&&(f.anisotropy=l);var p=e.MathUtils.generateUUID();return c[p]=f,p}var u={uuid:e.MathUtils.generateUUID(),type:`MeshLambertMaterial`};for(var d in a){var f=a[d];switch(d){case`DbgColor`:case`DbgIndex`:case`opticalDensity`:case`illumination`:break;case`DbgName`:u.name=f;break;case`blending`:u.blending=t[f];break;case`colorAmbient`:case`mapAmbient`:console.warn(`THREE.Loader.createMaterial:`,d,`is no longer supported.`);break;case`colorDiffuse`:u.color=n.fromArray(f).getHex();break;case`colorSpecular`:u.specular=n.fromArray(f).getHex();break;case`colorEmissive`:u.emissive=n.fromArray(f).getHex();break;case`specularCoef`:u.shininess=f;break;case`shading`:f.toLowerCase()===`basic`&&(u.type=`MeshBasicMaterial`),f.toLowerCase()===`phong`&&(u.type=`MeshPhongMaterial`),f.toLowerCase()===`standard`&&(u.type=`MeshStandardMaterial`);break;case`mapDiffuse`:u.map=l(f,a.mapDiffuseRepeat,a.mapDiffuseOffset,a.mapDiffuseWrap,a.mapDiffuseAnisotropy);break;case`mapDiffuseRepeat`:case`mapDiffuseOffset`:case`mapDiffuseWrap`:case`mapDiffuseAnisotropy`:break;case`mapEmissive`:u.emissiveMap=l(f,a.mapEmissiveRepeat,a.mapEmissiveOffset,a.mapEmissiveWrap,a.mapEmissiveAnisotropy);break;case`mapEmissiveRepeat`:case`mapEmissiveOffset`:case`mapEmissiveWrap`:case`mapEmissiveAnisotropy`:break;case`mapLight`:u.lightMap=l(f,a.mapLightRepeat,a.mapLightOffset,a.mapLightWrap,a.mapLightAnisotropy);break;case`mapLightRepeat`:case`mapLightOffset`:case`mapLightWrap`:case`mapLightAnisotropy`:break;case`mapAO`:u.aoMap=l(f,a.mapAORepeat,a.mapAOOffset,a.mapAOWrap,a.mapAOAnisotropy);break;case`mapAORepeat`:case`mapAOOffset`:case`mapAOWrap`:case`mapAOAnisotropy`:break;case`mapBump`:u.bumpMap=l(f,a.mapBumpRepeat,a.mapBumpOffset,a.mapBumpWrap,a.mapBumpAnisotropy);break;case`mapBumpScale`:u.bumpScale=f;break;case`mapBumpRepeat`:case`mapBumpOffset`:case`mapBumpWrap`:case`mapBumpAnisotropy`:break;case`mapNormal`:u.normalMap=l(f,a.mapNormalRepeat,a.mapNormalOffset,a.mapNormalWrap,a.mapNormalAnisotropy);break;case`mapNormalFactor`:u.normalScale=f;break;case`mapNormalRepeat`:case`mapNormalOffset`:case`mapNormalWrap`:case`mapNormalAnisotropy`:break;case`mapSpecular`:u.specularMap=l(f,a.mapSpecularRepeat,a.mapSpecularOffset,a.mapSpecularWrap,a.mapSpecularAnisotropy);break;case`mapSpecularRepeat`:case`mapSpecularOffset`:case`mapSpecularWrap`:case`mapSpecularAnisotropy`:break;case`mapMetalness`:u.metalnessMap=l(f,a.mapMetalnessRepeat,a.mapMetalnessOffset,a.mapMetalnessWrap,a.mapMetalnessAnisotropy);break;case`mapMetalnessRepeat`:case`mapMetalnessOffset`:case`mapMetalnessWrap`:case`mapMetalnessAnisotropy`:break;case`mapRoughness`:u.roughnessMap=l(f,a.mapRoughnessRepeat,a.mapRoughnessOffset,a.mapRoughnessWrap,a.mapRoughnessAnisotropy);break;case`mapRoughnessRepeat`:case`mapRoughnessOffset`:case`mapRoughnessWrap`:case`mapRoughnessAnisotropy`:break;case`mapAlpha`:u.alphaMap=l(f,a.mapAlphaRepeat,a.mapAlphaOffset,a.mapAlphaWrap,a.mapAlphaAnisotropy);break;case`mapAlphaRepeat`:case`mapAlphaOffset`:case`mapAlphaWrap`:case`mapAlphaAnisotropy`:break;case`flipSided`:u.side=e.BackSide;break;case`doubleSided`:u.side=e.DoubleSide;break;case`transparency`:console.warn(`THREE.Loader.createMaterial: transparency has been renamed to opacity`),u.opacity=f;break;case`depthTest`:case`depthWrite`:case`colorWrite`:case`opacity`:case`reflectivity`:case`transparent`:case`visible`:case`wireframe`:u[d]=f;break;case`vertexColors`:f===!0&&(u.vertexColors=e.VertexColors),f===`face`&&(u.vertexColors=e.FaceColors);break;default:console.error(`THREE.Loader.createMaterial: Unsupported`,d,f)}}return u.type===`MeshBasicMaterial`&&delete u.emissive,u.type!==`MeshPhongMaterial`&&delete u.specular,u.opacity<1&&(u.transparent=!0),i.setTextures(c),i.parse(u)}})()});var Oe=function(t){var n=this;this.video=void 0,this.videoTexture=void 0;var r=t,i=function(){document&&(n.video=document.createElement(`video`),n.video.crossOrigin=`anonymous`,n.video.src=r,n.video.load(),n.video.loop=!0)};this.setMorphTime=function(e,t){var r=e/t*n.video.duration;n.video.currentTime=r},this.getVideoDuration=function(){return n.video.duration},this.createCanvasVideoTexture=function(){return n.videoTexture=new e.VideoTexture(n.video),n.videoTexture.minFilter=e.LinearFilter,n.videoTexture.magFilter=e.LinearFilter,n.videoTexture.format=e.RGBFormat,n.video.currentTime=0,n.videoTexture},this.getCurrentTime=function(e){return n.video?e*(n.video.currentTime/n.video.duration):0},this.isReadyToPlay=function(){return!!(n.video&&n.video.readyState>=3)},i()},ke=e.AnimationClip,Ae=e.Color,je=e.DefaultLoadingManager,Me=e.FileLoader,Ne=e.LoaderUtils,Pe=e.Vector2,Fe=e.Vector3,Ie=e.Vector4;function Le(e){typeof e==`boolean`&&(console.warn(`THREE.JSONLoader: showStatus parameter has been removed from constructor.`),e=void 0),this.manager=e===void 0?je:e,this.withCredentials=!1,this.paramsString=``}Object.assign(Le.prototype,{load:function(e,t,n,r){var i=this,a=this.texturePath&&typeof this.texturePath==`string`?this.texturePath:Ne.extractUrlBase(e),o=new Me(this.manager);e.split(`?`),this.paramsString=e.length===2?paramsStrings[1]:``,o.setWithCredentials(this.withCredentials),o.load(e,function(n){var o=void 0;try{o=JSON.parse(n)}catch{if(console.error(`The loader has encountered an error while parsing the content of a resource.`),r){r({responseURL:e});return}}var s=o.metadata;if(s!==void 0){var c=s.type;if(c!==void 0&&c.toLowerCase()===`object`){console.error(`THREE.JSONLoader: `+e+` should be loaded with THREE.ObjectLoader instead.`);return}}if(i&&i.parse)try{var l=i.parse(o,a);t(l.geometry,l.materials)}catch(t){if(console.error(`The loader has encountered aon loading the geometry`),console.error(t),r){r({responseURL:e});return}}},n,r)},setTexturePath:function(e){this.texturePath=e},parse:(function(){function t(e,t){function n(e,t){return e&1<<t}var r,i,a,o,s,c,l,u,d,f,p,m,h,g,_,v,y,x,S,C,w,T,E,D,O,k,A,j=e.faces,M=e.vertices,N=e.normals,P=e.colors,F=e.scale,I=0;if(e.uvs!==void 0){for(r=0;r<e.uvs.length;r++)e.uvs[r].length&&I++;for(r=0;r<I;r++)t.faceVertexUvs[r]=[]}for(o=0,s=M.length;o<s;)x=new Fe,x.x=M[o++]*F,x.y=M[o++]*F,x.z=M[o++]*F,t.vertices.push(x);if(o=0,s=j.length,e.uvs)for(r=0;r<e.uvs.length;r++){t.uvs[r]=[];for(let n=0;n<e.uvs[r].length;n++)t.uvs[r][n]=e.uvs[r][n]}if(N)for(r=0;r<N.length;r++)t.normals[r]=N[r];if(P)for(r=0;r<P.length;r++)t.colors[r]=P[r];for(;o<s;)if(f=j[o++],p=n(f,0),m=n(f,1),h=n(f,3),g=n(f,4),_=n(f,5),v=n(f,6),y=n(f,7),p){if(C=new b,C.a=j[o],C.b=j[o+1],C.c=j[o+3],w=new b,w.a=j[o+1],w.b=j[o+2],w.c=j[o+3],o+=4,m&&(d=j[o++],C.materialIndex=d,w.materialIndex=d),a=t.faces.length,h)for(r=0;r<I;r++)for(D=e.uvs[r],t.faceVertexUvs[r][a]=[],t.faceVertexUvs[r][a+1]=[],i=0;i<4;i++)u=j[o++],k=D[u*2],A=D[u*2+1],O=new Pe(k,A),i!==2&&t.faceVertexUvs[r][a].push(O),i!==0&&t.faceVertexUvs[r][a+1].push(O);if(g&&(l=j[o++]*3,C.normal.set(N[l++],N[l++],N[l]),w.normal.copy(C.normal)),_)for(r=0;r<4;r++)l=j[o++]*3,E=new Fe(N[l++],N[l++],N[l]),r!==2&&C.vertexNormals.push(E),r!==0&&w.vertexNormals.push(E);if(v&&(c=j[o++],T=P[c],C.color.setHex(T),w.color.setHex(T)),y)for(r=0;r<4;r++)c=j[o++],T=P[c],r!==2&&C.vertexColors.push(new Ae(T)),r!==0&&w.vertexColors.push(new Ae(T));t.faces.push(C),t.faces.push(w)}else{if(S=new b,S.a=j[o++],S.b=j[o++],S.c=j[o++],S.b||(S.b=S.a),S.c||(S.c=S.b),m&&(d=j[o++],S.materialIndex=d),a=t.faces.length,h)for(r=0;r<I;r++)for(D=e.uvs[r],t.faceVertexUvs[r][a]=[],i=0;i<3;i++)u=j[o++],k=D[u*2],A=D[u*2+1],O=new Pe(k,A),t.faceVertexUvs[r][a].push(O);if(g&&(l=j[o++]*3,S.normal.set(N[l++],N[l++],N[l])),_)for(r=0;r<3;r++)l=j[o++]*3,E=new Fe(N[l++],N[l++],N[l]),S.vertexNormals.push(E);if(v&&(c=j[o++],S.color.setHex(P[c])),y)for(r=0;r<3;r++)c=j[o++],S.vertexColors.push(new Ae(P[c]));t.faces.push(S)}}function n(e,t){var n=e.influencesPerVertex===void 0?2:e.influencesPerVertex;if(e.skinWeights)for(var r=0,i=e.skinWeights.length;r<i;r+=n){var a=e.skinWeights[r],o=n>1?e.skinWeights[r+1]:0,s=n>2?e.skinWeights[r+2]:0,c=n>3?e.skinWeights[r+3]:0;t.skinWeights.push(new Ie(a,o,s,c))}if(e.skinIndices)for(var r=0,i=e.skinIndices.length;r<i;r+=n){var l=e.skinIndices[r],u=n>1?e.skinIndices[r+1]:0,d=n>2?e.skinIndices[r+2]:0,f=n>3?e.skinIndices[r+3]:0;t.skinIndices.push(new Ie(l,u,d,f))}t.bones=e.bones,t.bones&&t.bones.length>0&&(t.skinWeights.length!==t.skinIndices.length||t.skinIndices.length!==t.vertices.length)&&console.warn(`When skinning, number of vertices (`+t.vertices.length+`), skinIndices (`+t.skinIndices.length+`), and skinWeights (`+t.skinWeights.length+`) should match.`)}function r(t,n){var r=t.scale;if(t.morphTargets!==void 0)for(var i=0,a=t.morphTargets.length;i<a;i++){n.morphTargets[i]={},n.morphTargets[i].name=t.morphTargets[i].name,n.morphTargets[i].vertices=[];for(var o=n.morphTargets[i].vertices,s=t.morphTargets[i].vertices,c=0,l=s.length;c<l;c+=3){var u=new Fe;u.x=s[c]*r,u.y=s[c+1]*r,u.z=s[c+2]*r,o.push(u)}}if(t.morphNormals!==void 0){for(var i=0,a=t.morphNormals.length;i<a;i++)if(n.morphTargets[i]){n.morphTargets[i].normals=[];for(var d=n.morphTargets[i].normals,f=t.morphNormals[i].normals,c=0,l=f.length;c<l;c+=3){var p=new Fe;p.x=f[c],p.y=f[c+1],p.z=f[c+2],d.push(p)}n.morphNormalsReady=!0}}if(t.morphColors!==void 0){var i,a,m,h,g,_,v;for(i=0,a=t.morphColors.length;i<a;i++)for(n.morphColors[i]={},n.morphColors[i].name=t.morphColors[i].name,n.morphColors[i].colors=[],g=n.morphColors[i].colors,_=t.morphColors[i].colors,m=0,h=_.length;m<h;m+=3)v=new e.Color(16755200),v.setRGB(_[m],_[m+1],_[m+2]),g.push(v)}}function i(e,t){var n=[],r=[];e.animation!==void 0&&r.push(e.animation),e.animations!==void 0&&(e.animations.length?r=r.concat(e.animations):r.push(e.animations));for(var i=0;i<r.length;i++){var a=ke.parseAnimation(r[i],t.bones);a&&n.push(a)}if(t.morphTargets){var o=ke.CreateClipsFromMorphTargetSequences(t.morphTargets,10);n=n.concat(o)}n.length>0&&(t.animations=n)}return function(a,o){a.data!==void 0&&(a=a.data),a.scale===void 0?a.scale=1:a.scale=1/a.scale;var s=new v;if(s.morphColors=[],t(a,s),n(a,s),r(a,s),i(a,s),s.computeFaceNormals(),s.computeBoundingSphere(),a.materials===void 0||a.materials.length===0)return{geometry:s};var c=De.prototype.initMaterials(a.materials,o,`Anonymous`);if(a.materials[0].video){var l=o+a.materials[0].video;this.paramsString&&(l+=`?${this.paramsString}`),s._video=new Oe(l)}return c&&c.length>0&&(a.materials[0].singleSided?c[0].side=e.FrontSide:a.materials[0].flipSided?c[0].side=e.BackSide:c[0].side=e.DoubleSide,a.materials[0].specularCoef&&(c[0].shininess=Math.floor(a.materials[0].specularCoef/3))),{geometry:s,materials:c}}})()});var Re=function(){B.call(this);let t=[],n,r,i,a,o,s,c,l=0,u=0,d=[0,0,0],f=[0,0,0],p=!1,m=[0,0,0],h=`NONE`;this.ready=!1;let g=!1,_=!1;this.isGlyphset=!0;let v=new e.Matrix4,y=new e.Color,b=new e.Color,x=new e.Box3,S=new e.Box3,C=new e.Box3,w=[],T=[],E=[],D=[],O=[],k=[],A=[],j=[];this.globalScale=1;for(let t=0;t<8;t++)w[t]=new e.Vector3;this.load=(t,p,v,y,b)=>{n=t.axis1,r=t.axis2,i=t.axis3,a=t.positions,o=t.scale,s=t.colors,c=t.label,g=t.metadata.MorphColours,_=t.metadata.MorphVertices,l=t.metadata.number_of_time_steps,h=t.metadata.repeat_mode,u=t.metadata.number_of_vertices,h==`AXES_2D`||h==`MIRROR`?u*=2:h==`AXES_3D`&&(u*=3),d=t.metadata.base_size,f=t.metadata.offset,m=t.metadata.scale_factors;let x=new Le;this.geometry=new e.BufferGeometry;let S=new e.InstancedMesh(this.geometry,void 0,u);if(this.setMorph(S),y){var C=x.parse(p);ee(v,b)(C.geometry,C.materials),C.geometry.dispose()}else x.crossOrigin=`Anonymous`,x.load(p,ee(v,b))};let M=(e,t,n,r,i,a)=>{if(h==`NONE`||h==`MIRROR`){let c=[0,0,0],l=[0,0,0],u=[0,0,0],p=[0,0,0],g=[0,0,0],_=[0,0,0],v=[0,0,0],y=[0,0,0],b=[0,0,0];for(var o=0;o<3;o++){var s=i[o]<0?-1:1;c[o]=(s*d[o]+i[o]*m[o])*this.globalScale}for(var o=0;o<3;o++)l[o]=t[o]*c[0],u[o]=n[o]*c[1],p[o]=r[o]*c[2],g[o]=e[o]+f[0]*l[o]+f[1]*u[o]+f[2]*p[o],h==`MIRROR`&&(_[o]=-l[o],v[o]=-u[o],y[o]=-p[o],b[o]=g[o],i[0]<0&&(g[o]-=l[o],b[o]-=_[o]));0>p[0]*(l[1]*u[2]-l[2]*u[1])+p[1]*(l[2]*u[0]-l[0]*u[2])+p[2]*(l[0]*u[1]-l[1]*u[0])&&(p[0]=-p[0],p[1]=-p[1],p[2]=-p[2]),a[0]=[g,l,u,p],h==`MIRROR`&&(0>y[0]*(_[1]*v[2]-_[2]*v[1])+y[1]*(_[2]*v[0]-_[0]*v[2])+y[2]*(_[0]*v[1]-_[1]*v[0])&&(y[0]=-y[0],y[1]=-y[1],y[2]=-y[2]),a[1]=[b,_,v,y])}else if(h==`AXES_2D`||h==`AXES_3D`){let l=[0,0,0],u=[0,0,0];for(var o=0;o<3;o++){var s=i[o]<0?-1:1;l[o]=(s*d[0]+i[o]*m[0])*this.globalScale}for(var o=0;o<3;o++)u[o]=e[o]+f[0]*l[0]*t[o]+f[1]*l[1]*n[o]+f[2]*l[2]*r[o];let p=glyph_repeat_mode==`AXES_2D`?2:3;for(let e=0;e<p;e++){let o,s,l=i[e],f=[0,0,0],p=[0,0,0],g=[0,0,0];e==0?(o=t,s=n):e==1?(o=n,s=glyph_repeat_mode==`AXES_2D`?t:r):(o=r,s=t);let _=(d[0]+l*m[0])*this.globalScale;f[0]=o[0]*_,f[1]=o[1]*_,f[2]=o[2]*_,g[0]=f[1]*s[2]-s[1]*f[2],g[1]=f[2]*s[0]-s[2]*f[0],g[2]=f[0]*s[1]-f[1]*s[0];let v=Math.sqrt(g[0]*g[0]+g[1]*g[1]+g[2]*g[2]);if(0<v){let t=(d[2]+l*m[2])*this.globalScale/v;h==`AXES_2D`&&e>0&&(t*=-1),g[0]*=t,g[1]*=t,g[2]*=t}if(p[0]=g[1]*f[2]-f[1]*g[2],p[1]=g[2]*f[0]-f[2]*g[0],p[2]=g[0]*f[1]-g[1]*f[0],v=Math.sqrt(p[0]*p[0]+p[1]*p[1]+p[2]*p[2]),0<v){var c=(d[1]+l*m[1])*this.globalScale/v;p[0]*=c,p[1]*=c,p[2]*=c}a[e]=[u,f,p,g]}}return a},N=(e,n,r,i,a)=>{let o=1;h==`AXES_2D`||h==`MIRROR`?o=2:h==`AXES_3D`&&(o=3);let s=e.length/3,c=0;j.length=o;for(let l=0;l<s;l++){let s=l*3,u=[e[s],e[s+1],e[s+2]],d=[n[s],n[s+1],n[s+2]],f=[r[s],r[s+1],r[s+2]],p=[i[s],i[s+1],i[s+2]],m=[a[s],a[s+1],a[s+2]],h=M(u,d,f,p,m,j);if(h.length==o)for(let e=0;e<o;e++){v.elements[0]=h[e][1][0],v.elements[1]=h[e][1][1],v.elements[2]=h[e][1][2],v.elements[3]=0,v.elements[4]=h[e][2][0],v.elements[5]=h[e][2][1],v.elements[6]=h[e][2][2],v.elements[7]=0,v.elements[8]=h[e][3][0],v.elements[9]=h[e][3][1],v.elements[10]=h[e][3][2],v.elements[11]=0,v.elements[12]=h[e][0][0],v.elements[13]=h[e][0][1],v.elements[14]=h[e][0][2],v.elements[15]=1,this.morph.setMatrixAt(c,v);let n=t[c];n&&n.setTransformation(h[e][0],h[e][1],h[e][2],h[e][3]),c++}}this.morph.instanceMatrix.needsUpdate=!0},P=e=>{let n=1;h==`AXES_2D`||h==`MIRROR`?n=2:h==`AXES_3D`&&(n=3);let r=e.length,i=0;for(let a=0;a<r;a++){let r=e[a];for(let e=0;e<n;e++){y.setHex(r),this.morph.setColorAt(i,y);let e=t[i];e&&e.setColour(y),i++}}this.morph.instanceColor.needsUpdate=!0},F=()=>{let e=T,t=E,c=D,u=O,d=k,f=A,p=this.inbuildTime/this.duration*(l-1),m=Math.floor(p),h=1-(p-m),v=Math.ceil(p);if(_){let s=a[m.toString()],l=a[v.toString()],f=n[m.toString()],p=n[v.toString()],g=r[m.toString()],_=r[v.toString()],y=i[m.toString()],b=i[v.toString()],x=o[m.toString()],S=o[v.toString()];T.length=s.length,E.length=s.length,D.length=s.length,O.length=s.length,k.length=s.length;for(let n=0;n<s.length;n++)e[n]=h*s[n]+(1-h)*l[n],t[n]=h*f[n]+(1-h)*p[n],c[n]=h*g[n]+(1-h)*_[n],u[n]=h*y[n]+(1-h)*b[n],d[n]=h*x[n]+(1-h)*S[n]}else e=a[0],t=n[0],c=r[0],u=i[0],d=o[0];if(N(e,t,c,u,d),this.boundingBoxUpdateRequired=!0,s!=null){if(g){let e=s[m.toString()],t=s[v.toString()];f.length=e.length;for(let n=0;n<e.length;n++)y.setHex(e[n]),b.setHex(t[n]),y.setRGB(y.r*h+b.r*(1-h),y.g*h+b.g*(1-h),y.b*h+b.b*(1-h)),f[n]=y.getHex()}else f=s[0];P(f)}};this.getLabel=e=>{if(c&&c.length>e)return c[e]},this.isLabelDisplayed=()=>p,this.canShowLabel=()=>t?.length&&(c?.length||this.groupName),this.showLabel=()=>{if(t?.length){p=!0;for(let e=0;e<t.length;e++)t[e].showLabel(this.morph.material?this.morph.material.color:void 0)}},this.hideLabel=()=>{for(let e=0;e<t.length;e++)t[e].hideLabel();p=!1};let I=e=>{for(let e=0;e<u;e++){let n=new Ee(void 0,void 0,e,this),r=c?c[e]:void 0;r||=this.groupName,r&&n.setLabel(r),l>0&&n.setFrustumCulled(!1),t[e]=n,this.morph.add(n.getGroup())}c&&e&&this.showLabel(),N(a[0],n[0],r[0],i[0],o[0]),s!=null&&P(s[0]),this.ready=!0,this.boundingBoxUpdateRequired=!0};this.addCustomGlyph=e=>{e.isGlyph&&t.push(e),this.ready=!0,this.boundingBoxUpdateRequired=!0},this.addMeshAsGlyph=(e,n)=>{if(e.isMesh){let r=new Ee(void 0,void 0,n,this);return r.fromMesh(e),t.push(r),this.morph.add(r.getGroup()),this.ready=!0,this.boundingBoxUpdateRequired=!0,r}},this.forEachGlyph=e=>{for(let n=0;n<t.length;n++)e(t[n])};var ee=(e,t)=>(n,r)=>{let i=n.toBufferGeometry();this.geometry.copy(i),this.geometry.computeBoundingSphere(),this.geometry.computeBoundingBox(),i.dispose(),r&&r[0]&&(this.morph.material=r[0]),I(t),this.morph.name=this.groupName,this.morph.userData=this,this.setMorph(this.morph),n.dispose(),e!=null&&typeof e==`function`&&e(this)};this.getClosestVertexIndex=function(){let e=-1;if(this.morph&&this.ready){this.getBoundingBox().getCenter(this._v1);let t=a[0],n=t.length/3,r=-1,i=0;for(let a=0;a<n;a++){let n=a*3;this._v2.set(t[n],t[n+1],t[n+2]),i=this._v1.distanceTo(this._v2),(r==-1||r>i)&&(r=i,e=a)}}return e},this.getClosestVertex=function(){if(this.closestVertexIndex==-1&&(this.closestVertexIndex=this.getClosestVertexIndex()),this.closestVertexIndex>=0&&this.morph){let t=new e.Vector3;return this.morph.getMatrixAt(this.closestVertexIndex,v),t.setFromMatrixPosition(v),t}},this.getBoundingBox=()=>{if(this.morph&&this.ready&&this.morph.visible){if(this.boundingBoxUpdateRequired){x.setFromBufferAttribute(this.morph.geometry.attributes.position);for(let e=0;e<u;e++)this.morph.getMatrixAt(e,v),S.copy(x).applyMatrix4(v),e==0?C.copy(S):C.union(S);if(C)this.cachedBoundingBox.copy(C),this.morph.updateWorldMatrix(!0,!0),this.cachedBoundingBox.applyMatrix4(this.morph.matrixWorld),this.boundingBoxUpdateRequired=!1;else return}return this.cachedBoundingBox}},this.setMorphTime=e=>{this.inbuildTime=e>this.duration?this.duration:0>e?0:e,(g||_)&&(F(),_&&(this.markerUpdateRequired=!0))},this.isTimeVarying=()=>!!((this.ready===!1||l>0)&&(g||_)),this.getCurrentTime=()=>this.inbuildTime,this.setScaleAll=function(e){this.globalScale=e,F()},this.dispose=()=>{for(let e=t.length-1;e>=0;e--)t[e].dispose();this.geometry&&this.geometry.dispose(),this.morph&&this.morph.material.dispose(),n=void 0,r=void 0,i=void 0,a=void 0,o=void 0,s=void 0,this.ready=!1,this.groupName=void 0},this.render=(e,t,n)=>{if(t==1){let t=this.inbuildTime+e;t>this.duration&&(t-=this.duration),this.inbuildTime=t,(g||_)&&F()}this.updateMarker(t,n)}};Re.prototype=Object.create(B.prototype);var ze=new e.Matrix4,Be=new e.Ray,Ve=new e.Sphere,He=new e.Vector3,Ue=new e.Vector3,We=new e.Vector3,Ge=class extends e.Object3D{constructor(t=new e.BufferGeometry,n=new e.PointsMaterial){super(),this.type=`Points`,this.geometry=t,this.material=n,this.sizePerPixel=1,this.updateMorphTargets()}copy(e){return super.copy(e),this.material=e.material,this.geometry=e.geometry,this}raycast(e,t){let n=this.geometry,r=this.matrixWorld,i=e.params.Points.threshold,a=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),Ve.copy(n.boundingSphere),Ve.applyMatrix4(r),Ve.radius+=i,e.ray.intersectsSphere(Ve)===!1)return;ze.copy(r).invert(),Be.copy(e.ray).applyMatrix4(ze);let o=i/((this.scale.x+this.scale.y+this.scale.z)/3)*this.material.size*this.sizePerPixel,s=o*o;if(n.isBufferGeometry){let i=n.index,o=n.attributes.position,c=n.morphAttributes.position;if(i!==null){let n=Math.max(0,a.start),l=Math.min(i.count,a.start+a.count);for(let a=n,u=l;a<u;a++){let n=i.getX(a);qe(this,o,c,n),Ke(He,n,s,r,e,t,this)}}else{let n=Math.max(0,a.start),i=Math.min(o.count,a.start+a.count);for(let a=n,l=i;a<l;a++)qe(this,o,c,a),Ke(He,a,s,r,e,t,this)}}else console.error(`THREE.Points.raycast() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.`)}updateMorphTargets(){let e=this.geometry;if(e.isBufferGeometry){let t=e.morphAttributes,n=Object.keys(t);if(n.length>0){let e=t[n[0]];if(e!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let t=0,n=e.length;t<n;t++){let n=e[t].name||String(t);this.morphTargetInfluences.push(0),this.morphTargetDictionary[n]=t}}}}else{let t=e.morphTargets;t!==void 0&&t.length>0&&console.error(`THREE.Points.updateMorphTargets() does not support THREE.Geometry. Use THREE.BufferGeometry instead.`)}}};Ge.prototype.isPoints=!0;function Ke(t,n,r,i,a,o,s){let c=Be.distanceSqToPoint(t);if(c<r){let r=new e.Vector3;Be.closestPointToPoint(t,r),r.applyMatrix4(i);let l=a.ray.origin.distanceTo(r);if(l<a.near||l>a.far)return;o.push({distance:l,distanceToRay:Math.sqrt(c),point:r,index:n,face:null,object:s})}}function qe(e,t,n,r){He.fromBufferAttribute(t,r);let i=e.morphTargetInfluences;if(e.material.morphTargets&&n&&i){Ue.set(0,0,0);for(var a=0,o=n.length;a<o;a++){let e=i[a],t=n[a];e!==0&&(We.fromBufferAttribute(t,r),Ue.addScaledVector(We.sub(He),e))}He.add(Ue)}}var Je=function(){B.call(this),this.isPointset=!0;let t=[],n=1,r=!1,i=500,a=!0;this.createMesh=(e,t,n)=>{if(e&&t){let r=k(e,n);t.map=P();let i=new Ge(r,t);this.setMesh(i,n.localTimeEnabled,n.localMorphColour)}};let o=(o,s,c,l)=>{if(c){let u=new Te(c,new e.Color(l));u.setPosition(s[0],s[1],s[2]);let d=u.getSprite();d.material.sizeAttenuation=!1,d.material.alphaTest=.5,d.material.transparent=!0,d.material.depthWrite=!1,d.material.depthTest=r,u.setFontWeight(i),u.setSize(n),u.setVisibility(a),this.group.add(d),t[o]=u}},s=e=>{let n=t[e];if(n){let r=n.getSprite();this.group.remove(r),n.dispose(),t.splice(e,1)}};this.addPoints=(n,r,i)=>{if(n&&n.length>0){let a=this.drawRange;a===-1&&(a=0);let s=this.addVertices(n);if(!this.getMorph()){let t=new e.PointsMaterial({alphaTest:.5,size:10,color:i,sizeAttenuation:!1});s.colorsNeedUpdate=!0,this.createMesh(s,t,{localTimeEnabled:!1,localMorphColour:!1})}let c=a+n.length,l=0;if(Array.isArray(r)&&r.length===n.length||typeof r==`string`)for(t.length;a+l<c;){let e=typeof r==`string`?r:r[l];o(a+l,n[l],e,this._lod._material.color),l++}this.region&&(this.region.pickableUpdateRequired=!0)}},this.setColourHex=function(e){this._lod._material.color.setHex(e),this._lod._secondaryMaterial&&this._lod._secondaryMaterial.color.setHex(e);for(let e=0;e<t.length;e++)t[e]&&t[e].setColour(this._lod._material.color)},this.setColour=e=>{this._lod.setColour(e);for(let e=0;e<t.length;e++)t[e]&&t[e].setColour(this._lod._material.color)},this.setLabelDepthTest=e=>{r=e;for(let n=0;n<t.length;n++)t[n]&&t[n].setDepthTest(e)},this.setLabelFontWeight=e=>{i=e;for(let n=0;n<t.length;n++)t[n]&&t[n].setFontWeight(e)},this.setLabelSize=e=>{n=e;for(let e=0;e<t.length;e++)t[e]&&t[e].setSize(n)},this.displayLabels=e=>{a=e;for(let e=0;e<t.length;e++)t[e]&&t[e].setVisibility(a)},this.setSize=e=>{this.morph&&this.morph.material&&(this.morph.material.size=e,this.morph.material.needsUpdate=!0)},this.setSizeAttenuation=e=>{this.morph&&this.morph.material&&(this.morph.material.sizeAttenuation=e,this.morph.material.needsUpdate=!0)},this.getVerticesByIndex=function(e){if(e>=0&&this.drawRange>e){let t=this.getMorph().geometry.getAttribute(`position`);return[t.getX(e),t.getY(e),t.getZ(e)]}},this.editVertices=function(e,n){if(e&&e.length){let r=this.getMorph(),i=n+e.length-1;if(!r||0>n||i>=this.drawRange)return;{let i=r.geometry.getAttribute(`position`),a=n;e.forEach(e=>{let n=t[a];n&&n.setPosition(e[0],e[1],e[2]),i.setXYZ(a++,e[0],e[1],e[2])}),i.needsUpdate=!0,r.geometry.computeBoundingBox(),r.geometry.computeBoundingSphere(),this.boundingBoxUpdateRequired=!0}}},this.deleteVertices=function(e){return Je.prototype.deleteVertices.call(this,e)&&s(e),this.drawRange},this.setName=function(e){let n=this.groupName;Je.prototype.setName.call(this,e),t.forEach(t=>{t.getString()===n&&t?.setText(e)})},this.render=(e,t,n,r)=>{this.morph&&n&&(this.morph.sizePerPixel=n.pixelHeight),Je.prototype.render.call(this,e,t,n,r)}};Je.prototype=Object.create(B.prototype);var Ye=function(){B.call(this),this.isLines=!0,this.createLineSegment=(e,t,n)=>{if(e&&t){let r=k(e,n);n.localMorphColour&&r.morphAttributes.color&&(t.onBeforeCompile=L());let i=new pe(r,t);this.setMesh(i,n.localTimeEnabled,n.localMorphColour)}},this.setWidth=e=>{this.morph&&this.morph.material&&(this.morph.material.linewidth=e,this.morph.material.needsUpdate=!0)},this.addLines=(t,n)=>{if(t&&t.length>0){let r=this.addVertices(t);if(!this.getMorph()){let t=new e.LineBasicMaterial({color:n});r.colorsNeedUpdate=!0,this.createLineSegment(r,t,{localTimeEnabled:!1,localMorphColour:!1})}this.region&&(this.region.pickableUpdateRequired=!0)}}};Ye.prototype=Object.create(B.prototype);var Xe=function(){this.isTexture=!0,this.impl=void 0,this.isLoading=!1,this.size={width:1,height:1,depth:0}};Xe.prototype.loadImage=function(e,t){return new Promise((n,r)=>{e.onload=()=>n(e),e.onerror=r,e.src=t})},Xe.prototype.imageToUint8Array=async function(e,t,n,r){await e.loadImage(t,n),r.width=t.width,r.height=t.height;let i=r.getContext(`2d`);return i.drawImage(t,0,0),{array:new Uint8Array(i.getImageData(0,0,r.width,r.height).data.buffer),width:r.width,height:r.height}},Xe.prototype.loadFromImages=async function(e){},Xe.prototype.isReady=function(){return!!(this.impl&&!this.isLoading)},Xe.prototype.getMaterial=function(){if(this.impl)return new e.MeshBasicMaterial({color:new e.Color(1,1,1),transparent:!1,opacity:1,map:this.impl,side:e.DoubleSide})};var Ze=function(){Xe.call(this),this.isTextureArray=!0,this.loadFromImages=async t=>{let n=1,r=1,i=0;if(t&&t.length){this.isLoading=!0;let a=new Image;a.crossOrigin=`Anonymous`;let o=document.createElement(`canvas`),s=0,c=Array(t.length);for(let e=0;e<t.length;e++){let l=await this.imageToUint8Array(this,a,t[e],o);l&&l.array&&(n=l.width,r=l.height,c[i]=l.array,s+=c[i].length,i++)}let l=new Uint8Array(s);s=0,c.forEach(e=>{l.set(e,s),s+=e.length}),this.impl=new e.DataTexture2DArray(l,n,r,i),this.size={width:n,height:r,depth:i},this.isLoading=!1,this.impl.needsUpdate=!0}},this.getMaterial=t=>{if(this.impl){let n;if(t){if(t.vs&&t.fs){let r=!0;`transparent`in t&&(r=t.transparent);let i=e.FrontSide;t.side&&(i=t.side),n=new e.ShaderMaterial({transparent:r,uniforms:t.uniforms,vertexShader:t.vs,fragmentShader:t.fs,side:i}),t.glslVersion&&(n.glslVersion=t.glslVersion)}}else n=new e.MeshBasicMaterial({color:new e.Color(1,1,1),transparent:!1,opacity:1,map:this.impl,side:e.DoubleSide});if(n)return n.needsUpdate=!0,n}}};Ze.prototype=Object.create(Xe.prototype);var Qe=e.GLSL3,$e=`
3
+ `))}},te=new e.Vector3,R=new e.Vector3,ne=new e.Matrix4,re=new e.Ray,ie=new e.Sphere,ae=new e.Vector3,oe=new e.Vector3,se=new e.Vector3,ce=new e.Vector3,le=class extends e.Object3D{constructor(t=new e.BufferGeometry,n=new e.LineBasicMaterial){super(),this.type=`Line`,this.geometry=t,this.material=n,this.updateMorphTargets()}copy(e){return super.copy(e),this.material=e.material,this.geometry=e.geometry,this}computeLineDistances(){let t=this.geometry;if(t.isBufferGeometry){if(t.index===null){let n=t.attributes.position,r=[0];for(let e=1,t=n.count;e<t;e++)te.fromBufferAttribute(n,e-1),R.fromBufferAttribute(n,e),r[e]=r[e-1],r[e]+=te.distanceTo(R);t.setAttribute(`lineDistance`,new e.Float32BufferAttribute(r,1))}else console.warn(`THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.`)}else t.isGeometry&&console.error(`THREE.Line.computeLineDistances() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.`);return this}raycast(t,n){let r=this.geometry,i=this.matrixWorld,a=t.params.Line.threshold,o=r.drawRange,s=r.morphAttributes.position;if(r.boundingSphere===null&&r.computeBoundingSphere(),ie.copy(r.boundingSphere),ie.applyMatrix4(i),ie.radius+=a,t.ray.intersectsSphere(ie)===!1)return;ne.copy(i).invert(),re.copy(t.ray).applyMatrix4(ne);let c=a/((this.scale.x+this.scale.y+this.scale.z)/3),l=c*c,u=new e.Vector3,d=new e.Vector3,f=new e.Vector3,p=new e.Vector3,m=this.isLineSegments?2:1;if(r.isBufferGeometry){let e=r.index,i=r.attributes.position;if(e!==null){let r=Math.max(0,o.start),a=Math.min(e.count,o.start+o.count);for(let o=r,c=a-1;o<c;o+=m){let r=e.getX(o),a=e.getX(o+1);if(ue(u,d,this,i,s,r,a),re.distanceSqToSegment(u,d,p,f)>l)continue;p.applyMatrix4(this.matrixWorld);let c=t.ray.origin.distanceTo(p);c<t.near||c>t.far||n.push({distance:c,point:f.clone().applyMatrix4(this.matrixWorld),index:o,face:null,faceIndex:null,object:this})}}else{let e=Math.max(0,o.start),r=Math.min(i.count,o.start+o.count);for(let a=e,o=r-1;a<o;a+=m){if(ue(u,d,this,i,s,a,a+1),re.distanceSqToSegment(u,d,p,f)>l)continue;p.applyMatrix4(this.matrixWorld);let e=t.ray.origin.distanceTo(p);e<t.near||e>t.far||n.push({distance:e,point:f.clone().applyMatrix4(this.matrixWorld),index:a,face:null,faceIndex:null,object:this})}}}else r.isGeometry&&console.error(`THREE.Line.raycast() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.`)}updateMorphTargets(){let e=this.geometry;if(e.isBufferGeometry){let t=e.morphAttributes,n=Object.keys(t);if(n.length>0){let e=t[n[0]];if(e!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let t=0,n=e.length;t<n;t++){let n=e[t].name||String(t);this.morphTargetInfluences.push(0),this.morphTargetDictionary[n]=t}}}}else{let t=e.morphTargets;t!==void 0&&t.length>0&&console.error(`THREE.Line.updateMorphTargets() does not support THREE.Geometry. Use THREE.BufferGeometry instead.`)}}};function ue(e,t,n,r,i,a,o){e.fromBufferAttribute(r,a),t.fromBufferAttribute(r,o);var s=n.morphTargetInfluences;if(n.material.morphTargets&&i&&s){ae.set(0,0,0),oe.set(0,0,0);for(var c=0,l=i.length;c<l;c++){var u=s[c],d=i[c];u!==0&&(se.fromBufferAttribute(d,a),ce.fromBufferAttribute(d,o),ae.addScaledVector(se.sub(e),u),oe.addScaledVector(ce.sub(t),u))}e.add(ae),t.add(oe)}}le.prototype.isLine=!0;var de=new e.Vector3,fe=new e.Vector3,pe=class extends le{constructor(e,t){super(e,t),this.type=`LineSegments`}computeLineDistances(){let t=this.geometry;if(t.isBufferGeometry){if(t.index===null){let n=t.attributes.position,r=[];for(let e=0,t=n.count;e<t;e+=2)de.fromBufferAttribute(n,e),fe.fromBufferAttribute(n,e+1),r[e]=e===0?0:r[e-1],r[e+1]=r[e]+de.distanceTo(fe);t.setAttribute(`lineDistance`,new e.Float32BufferAttribute(r,1))}else console.warn(`THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.`)}else t.isGeometry&&console.error(`THREE.LineSegments.computeLineDistances() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.`);return this}};pe.prototype.isLineSegments=!0;var z=function(t){this.levels=[],this._currentLevel=0,this._renderOrder=1,this._material=void 0,this._secondaryMaterial=void 0,this._loader=void 0,this._parent=t,this.addLevel=(e,t)=>{if(e){let n=Math.abs(t),r;for(r=0;r<this.levels.length&&!(n<this.levels[r].distance);r++);let i={distance:n,morph:e,loaded:!0,loading:!1,url:``};this.levels.splice(r,0,i),e.renderOrder=this._renderOrder}},this.levelLoaded=(e,t)=>{if(e){let n=Math.abs(t);for(let t=0;t<this.levels.length;t++)if(n===this.levels[t].distance){this._parent.group.add(e),this.levels[t].morph=e,this.levels[t].loaded=!0,this.levels[t].loading=!1;break}this.checkTransparentMesh()}},this.addLevelFromURL=(e,t,n,r,i)=>{this._loader=e;let a=this.calculateDistance(t),o={distance:a,morph:void 0,loaded:!1,loading:!1,url:n,index:r},s;for(s=0;s<this.levels.length&&!(a<this.levels[s].distance);s++);this.levels.splice(s,0,o),i&&this.loadLevel(s)},this.loadLevel=e=>{let t=this.levels[e];return!t.morph&&!t.loaded&&!t.loading&&(t.loading=!0,this._loader.load(t.url,this.lodLoader(t.distance),void 0,void 0,{index:t.index})),t.morph===void 0},this.calculateDistance=function(e){this._parent.getBoundingBox();let t=this._parent.radius,n=0;return e===`far`?n=t*4.5:e===`medium`?n=t*2.5:e===`close`&&(n=0),n},this.containsLevels=()=>!!(this.levels&&this.levels.length>1),this.checkTransparentMesh=()=>{let t=this.levels[this._currentLevel];this._material&&(this._material.transparent?(this._secondaryMaterial||(this._secondaryMaterial=this._material.clone(),this._secondaryMaterial.side=e.FrontSide),this._secondaryMaterial.opacity=this._material.opacity,this._secondaryMaterial.emissive&&this._secondaryMaterial.emissive.copy(this._material.emissive),this._secondaryMaterial.needsUpdate=!0,t.secondaryMesh||(t.secondaryMesh=new e.Mesh(t.morph.geometry,this._secondaryMaterial),t.secondaryMesh.renderOrder=t.morph.renderOrder+1,t.secondaryMesh.userData=t.morph.userData,t.secondaryMesh.name=t.morph.name),this._material.side=e.BackSide,this._material.needsUpdate=!0,t.secondaryMesh.parent||(t.morph.add(t.secondaryMesh),this._parent.animationGroup&&this._parent.animationGroup.add(t.secondaryMesh))):(t.secondaryMesh&&(t.morph.remove(t.secondaryMesh),this._parent.animationGroup&&(this._parent.animationGroup.uncache(t.secondaryMesh),this._parent.animationGroup.remove(t.secondaryMesh))),this._material.side=e.DoubleSide,this._material.needsUpdate=!0))},this.dispose=()=>{this.levels.forEach(e=>{e.morph&&e.morph.geometry&&e.morph.geometry.dispose()}),this._material&&this._material.dispose(),this._secondaryMaterial&&this._secondaryMaterial.dispose()},this.getCurrentLevel=()=>this._currentLevel,this.getCurrentMorph=()=>{let e=this.levels[this._currentLevel];return e&&e.morph?e.morph:this._parent.morph},this.lodLoader=function(t){return n=>{let r=this._material,i=k(n,{localTimeEnabled:this._parent.timeEnabled,localMorphColour:this._parent.morphColour}),a;this._parent.isGeometry?a=new e.Mesh(i,r):this._parent.isLines&&(a=new pe(i,r)),a.userData=this._parent,a.renderOrder=this._renderOrder,n.dispose(),this.levelLoaded(a,t)}},this.updateMorphColorAttribute=t=>{if(this._material&&(this._material.vertexColors==e.VertexColors||this._material.vertexColors==1)){if(t){let e=this.getCurrentMorph();O(e.geometry,e)}else this.levels.forEach(e=>{e.morph&&e.morph.geometry&&O(e.morph.geometry,e.morph)})}},this.setColour=e=>{this._material.color=e,this._secondaryMaterial&&(this._secondaryMaterial.color=e),n()},this.setFrustumCulled=e=>{this.levels.forEach(t=>{t.morph&&(t.morph.frustumCulled=e),t.secondaryMesh&&(t.secondaryMesh.frustumCulled=e)})},this.setMaterial=t=>{t&&(!this._material||this._material.id!==t.id)&&(this._material=t,this._secondaryMaterial&&this._secondaryMaterial.dispose(),this._secondaryMaterial=t.clone(),this._secondaryMaterial.side=e.FrontSide,this._secondaryMaterial.transparent=!0,this.levels.forEach(e=>{e.morph&&(e.morph.material=this._material,e.morph.geometry&&(e.morph.geometry.colorsNeedUpdate=!0)),e.secondaryMesh&&(e.secondaryMesh.material=this._secondaryMaterial)}))},this.setName=e=>{this.levels.forEach(t=>{t.morph&&(t.morph.name=e),t.secondaryMesh&&(t.secondaryMesh.name=e)})},this.setRenderOrder=e=>{this._renderOrder=e,this.levels.forEach(t=>{t.morph&&(t.morph.renderOrder=e),t.secondaryMesh&&(t.secondaryMesh.renderOrder=e)})},this.setVertexColors=e=>{this._material.vertexColors=e,n(),this._secondaryMaterial&&(this._secondaryMaterial.vertexColors=e)},this.update=(e,t)=>{let n=this.levels;if(n.length>1){let r=e.cameraObject.position.distanceTo(t),i=-1,a=-1,o,s;for(o=0,s=n.length;o<s&&r>=n[o].distance;o++)n[o].morph?(i>-1&&n[i].morph&&(n[i].morph.visible=!1),i=o,n[o].morph.visible=!0,a=-1):a=o;for(a>-1&&this.loadLevel(a);o<s;o++)n[o].morph&&(i>-1?n[o].morph.visible=!1:(n[o].morph.visible=!0,i=o));this._currentLevel!=i&&(this._currentLevel=i,this.checkTransparentMesh())}},this.toggleMarker=(e,t)=>{this.levels.forEach(n=>{n.morph&&(t?n.morph.add(e):n.morph.remove(e))})};let n=()=>{this.levels.forEach(e=>{e.morph&&e.morph.geometry&&(e.morph.geometry.colorsNeedUpdate=!0)})}},me=`data:image/svg+xml,%3c?xml%20version='1.0'%20encoding='UTF-8'%20standalone='no'%20?%3e%3c!DOCTYPE%20svg%20PUBLIC%20'-//W3C//DTD%20SVG%201.1//EN'%20'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'%3e%3csvg%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20version='1.1'%20width='365'%20height='560'%20viewBox='0%200%20365%20560'%20xml:space='preserve'%3e%3cdesc%3eCreated%20with%20Fabric.js%205.2.4%3c/desc%3e%3cdefs%3e%3c/defs%3e%3crect%20x='0'%20y='0'%20width='100%25'%20height='100%25'%20fill='transparent'%3e%3c/rect%3e%3cg%20transform='matrix(0%200%200%200%200%200)'%20id='808ed283-2524-440f-88ae-3bdb47bb5749'%20%3e%3c/g%3e%3cg%20transform='matrix(1%200%200%201%20182.5%20280)'%20id='db30413d-5bff-4b98-ab59-464497ee199e'%20%3e%3crect%20style='stroke:%20none;%20stroke-width:%201;%20stroke-dasharray:%20none;%20stroke-linecap:%20butt;%20stroke-dashoffset:%200;%20stroke-linejoin:%20miter;%20stroke-miterlimit:%204;%20fill:%20rgb(255,255,255);%20fill-rule:%20nonzero;%20opacity:%201;%20visibility:%20hidden;'%20vector-effect='non-scaling-stroke'%20x='-182.5'%20y='-280'%20rx='0'%20ry='0'%20width='365'%20height='560'%20/%3e%3c/g%3e%3cg%20transform='matrix(0%200%200%200%200%2097.5)'%20%3e%3cg%20style=''%20%3e%3c/g%3e%3c/g%3e%3cg%20transform='matrix(0%200%200%200%200%2097.5)'%20%3e%3cg%20style=''%20%3e%3c/g%3e%3c/g%3e%3cg%20transform='matrix(0.99%200%200%200.99%20182.5%20280)'%20%3e%3cg%20style=''%20vector-effect='non-scaling-stroke'%20%3e%3cg%20transform='matrix(1%200%200%201%200%200)'%20%3e%3crect%20style='stroke:%20none;%20stroke-width:%201;%20stroke-dasharray:%20none;%20stroke-linecap:%20butt;%20stroke-dashoffset:%200;%20stroke-linejoin:%20miter;%20stroke-miterlimit:%204;%20fill:%20rgb(255,255,255);%20fill-rule:%20nonzero;%20opacity:%201;%20visibility:%20hidden;'%20vector-effect='non-scaling-stroke'%20x='-540'%20y='-540'%20rx='0'%20ry='0'%20width='1080'%20height='1080'%20/%3e%3c/g%3e%3cg%20transform='matrix(1%200%200%201%200%200)'%20%3e%3cpath%20style='stroke:%20rgb(0,0,0);%20stroke-width:%200;%20stroke-dasharray:%20none;%20stroke-linecap:%20butt;%20stroke-dashoffset:%200;%20stroke-linejoin:%20miter;%20stroke-miterlimit:%204;%20fill:%20rgb(0,89,116);%20fill-rule:%20nonzero;%20opacity:%201;'%20vector-effect='non-scaling-stroke'%20transform='%20translate(-182.9,%20-279.85)'%20d='M%20182.9%20551.7%20C%20182.9%20551.8000000000001%20183.1%20552%20183.1%20552%20C%20183.1%20552%20358.3%20283%20358.3%20194.6%20C%20358.3%2064.5%20269.5%207.900000000000006%20182.9%207.699999999999989%20C%2096.3%207.9%207.5%2064.5%207.5%20194.6%20C%207.5%20283%20182.8%20552%20182.8%20552%20C%20182.8%20552%20182.9%20551.7%20182.9%20551.7%20z%20M%20122.2%20187.2%20C%20122.2%20153.6%20149.4%20126.39999999999999%20183%20126.39999999999999%20C%20216.6%20126.39999999999999%20243.8%20153.6%20243.8%20187.2%20C%20243.8%20220.79999999999998%20216.5%20248%20182.9%20248%20C%20149.4%20248%20122.2%20220.8%20122.2%20187.2%20z'%20stroke-linecap='round'%20/%3e%3c/g%3e%3cg%20transform='matrix(3.82%200%200%203.82%200%20-100.77)'%20%3e%3ccircle%20style='stroke:%20rgb(0,0,0);%20stroke-width:%200;%20stroke-dasharray:%20none;%20stroke-linecap:%20butt;%20stroke-dashoffset:%200;%20stroke-linejoin:%20miter;%20stroke-miterlimit:%204;%20fill:%20rgb(255,255,255);%20fill-rule:%20nonzero;%20opacity:%201;'%20vector-effect='non-scaling-stroke'%20cx='0'%20cy='0'%20r='35'%20/%3e%3c/g%3e%3c/g%3e%3c/g%3e%3c/svg%3e`,he=new Image(128,128);he.src=me;var ge=new e.Texture;ge.image=he,ge.needsUpdate=!0;var _e=[.02,.03,1],ve=new e.SpriteMaterial({map:ge,alphaTest:.5,transparent:!0,depthTest:!1,depthWrite:!1,sizeAttenuation:!1}),ye=function(t){Object.getPrototypeOf(this)!==B.prototype&&Object.setPrototypeOf(ye.prototype,B.prototype),B.call(this),this.texture=ge;let n,r,i,a,o,s=!0;this.morph=new e.Group,this.group=this.morph,this.parent=t,this.isMarker=!0;let c=!1;this.ndc=new e.Vector3;let l,u,d=()=>{n=new e.Sprite(ve),n.center.set(.5,0),this.morph.add(n),this.morph.position.set(0,0,0),this.morph.renderOrder=1e4,n.scale.set(_e[0],_e[1],_e[2]),n.userData=this};this.updateVisual=(e,t)=>{let n=1,r=0;e!==t&&(r=1-(this.ndc.z-e)/(t-e),n=.6+r*.4),this.setSpriteSize(n)},this.updateNDC=e=>(this.ndc.copy(this.morph.position),this.ndc.project(e),this.ndc.z=Math.min(Math.max(this.ndc.z,0),1),this.ndc),this.setPosition=(e,t,n)=>{this.morph.position.set(e,t,n)},this.setSpriteSize=e=>{n.scale.set(.015,.02,1),n.scale.multiplyScalar(e)},this.setUserSprite=()=>{a&&(this.morph.add(a),s&&=(this.morph.remove(n),u&&this.morph.remove(u),!1))},this.setImageForUserSprite=(t,n)=>{a&&=(this.morph.remove(a),void 0),r&&r.dispose(),i&&i.dispose(),r=new e.Texture,r.image=t,r.needsUpdate=!0,i=new e.SpriteMaterial({map:r,alphaTest:.5,transparent:!0,depthTest:!1,depthWrite:!1,sizeAttenuation:!1}),n||=[.05,.05,1],a=new e.Sprite(i),a.center.set(.5,0),a.scale.set(n[0],n[1],n[2]),a.userData=this,this.setUserSprite()},this.setDefaultSprite=()=>{s||(s=!0,this.morph.add(n),a&&this.morph.remove(a),u&&this.morph.add(u))},this.loadUserSprite=(e,t)=>{if(e){if(e!==o){o=e;let n=new Image(128,128);n.crossOrigin=`anonymous`,n.onload=()=>{this.setImageForUserSprite(n,t)},n.src=e}else this.setUserSprite()}},this.dispose=()=>{this.morph&&this.morph.clear(),n&&=(n.clear(),void 0),u&&=(u.material.map.dispose(),u.material.dispose(),void 0)},this.isEnabled=()=>c,this.setNumber=e=>{(!e||l!=e)&&(u&&=(this.morph.remove(u),u.material.map.dispose(),u.material.dispose(),void 0)),!u&&e&&(u=F(e,.012,`black`,`Asap`,120,700),this.morph.add(u)),l=e},this.getNumber=()=>l||1,this.setVisibility=function(e){e!==this.visible&&(this.visible=e,this.group.visible=e,this.parent.region&&(this.parent.region.pickableUpdateRequired=!0))},this.enable=()=>{c=!0,this.morph.visible=!0,this.visible=!0},this.disable=()=>{c=!1,this.morph.visible=!1,this.visible=!1},d()},be=0,xe=function(){return`pr`+be++},B=function(){this.isZincObject=!0,this.geometry=void 0,this.morph=void 0,this.group=new e.Group,this._lod=new z(this),this.groupName=void 0,this.timeEnabled=!1,this.morphColour=!1,this.inbuildTime=0,this.mixer=void 0,this.animationGroup=void 0,this.duration=6e3,this.clipAction=void 0,this.userData={},this.videoHandler=void 0,this.marker=void 0,this.markerNumber=void 0,this.markerUpdateRequired=!0,this.closestVertexIndex=-1,this.boundingBoxUpdateRequired=!0,this.cachedBoundingBox=new e.Box3,this.anatomicalId=void 0,this.region=void 0,this.animationClip=void 0,this.markerMode=`inherited`,this.uuid=xe(),this._v1=new e.Vector3,this._v2=new e.Vector3,this._b1=new e.Box3,this.center=new e.Vector3,this.radius=0,this.visible=!0,this.drawRange=-1,this.origColour=void 0,this.origVertexColors=!1,this.isPickable=!0};B.prototype.setDuration=function(e){this.duration=e,this.clipAction&&this.clipAction.setDuration(this.duration)},B.prototype.getDuration=function(){return this.duration},B.prototype.setRegion=function(e){this.region=e},B.prototype.getRegion=function(){return this.region},B.prototype.getMorph=function(){return this._lod.getCurrentMorph()||this.morph},B.prototype.getGroup=function(){return this.group},B.prototype.setMorph=function(e){this.morph=e,this.group.add(this.morph);let t=this._lod.calculateDistance(`far`);this._lod.addLevel(e,t),this._lod.setMaterial(e.material)},B.prototype.checkTransparentMesh=function(){},B.prototype.setMesh=function(t,n,r){this.animationGroup=new e.AnimationObjectGroup(t),this.mixer=new e.AnimationMixer(this.animationGroup);let i=t.geometry;if(this.geometry=t.geometry,this.clipAction=void 0,i&&i.morphAttributes){let t=i.morphAttributes.position;t||=i.morphAttributes.color?i.morphAttributes.color:i.morphAttributes.normal,t&&(this.animationClip=e.AnimationClip.CreateClipsFromMorphTargetSequences(t,10,!0),this.animationClip&&this.animationClip[0]!=null&&(this.clipAction=this.mixer.clipAction(this.animationClip[0]).setDuration(this.duration),this.clipAction.loop=e.LoopRepeat,this.clipAction.clampWhenFinished=!0,this.clipAction.play()))}this.timeEnabled=n,this.morphColour=r,t.userData=this,t.matrixAutoUpdate=!1,this.setMorph(t),this.checkTransparentMesh(),this.timeEnabled?this.setFrustumCulled(!1):this.morphColour&&(i.setAttribute(`morphTarget0`,i.getAttribute(`position`)),i.setAttribute(`morphTarget1`,i.getAttribute(`position`))),this.boundingBoxUpdateRequired=!0},B.prototype.setIsPickable=function(e){this.isPickable!==e&&(this.isPickable=e,this.region&&(this.region.pickableUpdateRequired=!0))},B.prototype.setAnatomicalId=function(e){this.anatomicalId=e},B.prototype.setName=function(e){this.groupName=e,this._lod.setName(e)},B.prototype.getCurrentTime=function(){if(this.clipAction){let e=this.clipAction.time/this.clipAction._clip.duration;return this.duration*e}return this.inbuildTime},B.prototype.setMorphTime=function(e){let t=!1;if(this.clipAction){let n=e/this.duration*this.clipAction._clip.duration;n!=this.clipAction.time&&(this.clipAction.time=n,t=!0),t&&this.isTimeVarying()&&this.mixer.update(0)}else{let n=e;n=e>this.duration?this.duration:0>e?0:e,n!=this.inbuildTime&&(this.inbuildTime=n,t=!0)}t&&(this.boundingBoxUpdateRequired=!0,this._lod.updateMorphColorAttribute(!0),this.timeEnabled&&(this.markerUpdateRequired=!0))},B.prototype.isTimeVarying=function(){return!!(this.timeEnabled||this.morphColour)},B.prototype.getVisibility=function(){return this.visible},B.prototype.setVisibility=function(e){e!==this.visible&&(this.visible=e,this.group.visible=e,this.region&&(this.region.pickableUpdateRequired=!0))},B.prototype.setAlpha=function(e){let t=this._lod._material,n=!1;e<1&&(n=!0),t.opacity=e,t.transparent=n,this.checkTransparentMesh()},B.prototype.setFrustumCulled=function(e){this._lod.setFrustumCulled(e)},B.prototype.setVertexColors=function(e){this._lod.setVertexColors(e)},B.prototype.getColour=function(){if(this._lod._material)return this._lod._material.color},B.prototype.setColour=function(e){this._lod.setColour(e)},B.prototype.setGreyScale=function(t){if(t){if(!this.origColour&&this._lod._material)return this.origColour=this._lod._material.color,this.origVertexColors=this._lod._material.vertexColors,this._lod.setVertexColors(!1),this._lod.setColour(new e.Color().setHex(12303291)),!0}else if(this.origColour)return this._lod.setColour(this.origColour),this._lod.setVertexColors(this.origVertexColors),this.origColour=void 0,!0;return!1},B.prototype.getColourHex=function(){if(!this.morphColour&&this._lod._material&&this._lod._material.color)return this._lod._material.color.getHexString()},B.prototype.setColourHex=function(e){this._lod._material.color.setHex(e),this._lod._secondaryMaterial&&this._lod._secondaryMaterial.color.setHex(e)},B.prototype.setEmissiveRGB=function(e){this._lod._material&&this._lod._material.emissive&&this._lod._material.emissive.setRGB(...e),this._lod._secondaryMaterial&&this._lod._secondaryMaterial.emissive.setRGB(...e)},B.prototype.setMaterial=function(e){this._lod.setMaterial(e)},B.prototype.getClosestVertexIndex=function(){let e=-1,t=this.getMorph();if(t&&t.geometry){let n=t.geometry.attributes.position;if(n){this._b1.setFromBufferAttribute(n),this._b1.getCenter(this._v1);let t=-1,r=0;for(let i=0;i<n.count;i++)this._v2.fromArray(n.array,i*3),r=this._v2.distanceTo(this._v1),t==-1?t=r:t>r&&(t=r,e=i)}}return e},B.prototype.getClosestVertex=function(t){let n=new e.Vector3;this.closestVertexIndex==-1&&(this.closestVertexIndex=this.getClosestVertexIndex());let r=this.getMorph();if(r&&r.geometry&&this.closestVertexIndex>=0){let e=r.morphTargetInfluences,i=r.geometry.morphAttributes;if(e&&i&&i.position){let a=!1;for(let t=0;t<e.length;t++)e[t]>0&&(a=!0,this._v1.fromArray(i.position[t].array,this.closestVertexIndex*3),n.add(this._v1.multiplyScalar(e[t])));if(a)return t?n.applyMatrix4(r.matrixWorld):n}else return n.fromArray(r.geometry.attributes.position.array,this.closestVertexIndex*3),t?n.applyMatrix4(r.matrixWorld):n}return this.getBoundingBox(),n.copy(this.center),n},B.prototype.getBoundingBox=function(){if(this.visible){let e=this._lod.getCurrentMorph();if(e&&e.visible)return this.boundingBoxUpdateRequired&&=(w(e,this.cachedBoundingBox,this._b1,this._v1,this._v2),this.cachedBoundingBox.getCenter(this.center),this.radius=this.center.distanceTo(this.cachedBoundingBox.max),!1),this.cachedBoundingBox}},B.prototype.dispose=function(){this._lod.dispose(),this.animationGroup=void 0,this.mixer=void 0,this.morph=void 0,this.group=void 0,this.clipAction=void 0,this.groupName=void 0},B.prototype.markerIsRequired=function(e){return!!(this.visible&&(this.markerMode===`on`||e&&e.displayMarkers&&this.markerMode===`inherited`))},B.prototype.updateMarker=function(e,t){if(e==0&&this.markerIsRequired(t)){let e=t.ndcToBeUpdated;if(this.groupName){if(this.marker||(this.marker=new ye(this),this.markerUpdateRequired=!0),this.markerUpdateRequired){let e=this.getClosestVertex(!1);e&&(this.marker.setPosition(e.x,e.y,e.z),this.markerUpdateRequired=!1)}this.marker.isEnabled()||(t.markersList&&!(this.marker.uuid in t.markersList)&&(e=!0,t.markersList[this.marker.uuid]=this.marker),this.marker.enable(),this.group.add(this.marker.morph)),this.marker.setNumber(this.markerNumber),this.markerImgURL?this.marker.loadUserSprite(this.markerImgURL):this.marker.setDefaultSprite(),t&&t.camera&&(e||t.markerCluster.markerUpdateRequired)&&(this.marker.updateNDC(t.camera.cameraObject),t.markerCluster.markerUpdateRequired=!0)}}else this.marker&&this.marker.isEnabled()&&(this.marker.disable(),this.group.remove(this.marker.morph),t.markersList&&this.marker.uuid in t.markersList&&(t.markerCluster.markerUpdateRequired=!0,delete t.markersList[this.marker.uuid])),this.markerUpdateRequired=!0},B.prototype.processMarkerVisual=function(e,t){this.marker&&this.marker.isEnabled()&&this.marker.updateVisual(e,t)},B.prototype.initiateMorphColor=function(){this.morphColour==1&&this._lod.updateMorphColorAttribute(!1)},B.prototype.setRenderOrder=function(e){this._lod.setRenderOrder(e)},B.prototype.getClosestVertexDOMElementCoords=function(e){if(e&&e.camera){let t=!0,n=this.getClosestVertex(!0);return n.project(e.camera),n.z=Math.min(Math.max(n.z,0),1),(n.x>1||n.x<-1||n.y>1||n.y<-1)&&(t=!1),e.getZincCameraControls().getRelativeCoordsFromNDC(n.x,n.y,n),{position:n,inView:t}}},B.prototype.setMarkerMode=function(e,t){e!==this.markerMode&&(this.markerMode=e===`on`||e===`off`?e:`inherited`,this.region&&(this.region.pickableUpdateRequired=!0)),t&&(this.markerNumber=t.number,this.markerImgURL=t.imgURL)},B.prototype.render=function(e,t,n,r){if(this.visible&&!(this.timeEnabled&&t)&&this._lod.update(n,this.center),t==1){if(this.clipAction&&this.isTimeVarying())this.mixer.update(e);else{let t=this.inbuildTime+e;t>this.duration&&(t-=this.duration),this.inbuildTime=t}this.visible&&e!=0&&(this.boundingBoxUpdateRequired=!0,this.morphColour==1&&this._lod.updateMorphColorAttribute(!0))}this.updateMarker(t,r)},B.prototype.addLOD=function(e,t,n,r,i){this._lod.addLevelFromURL(e,t,n,r,i)},B.prototype.addVertices=function(e){let t=this.getMorph(),n;if(!t)n=N(500,e),this.drawRange=e.length;else if(this.drawRange>-1){let r=t.geometry.getAttribute(`position`);e.forEach(e=>{r.setXYZ(this.drawRange,e[0],e[1],e[2]),++this.drawRange}),r.needsUpdate=!0,t.geometry.setDrawRange(0,this.drawRange),t.geometry.computeBoundingBox(),t.geometry.computeBoundingSphere(),n=t.geoemtry,this.boundingBoxUpdateRequired=!0}return n},B.prototype.deleteVertices=function(e){let t=this.getMorph();return t?.geometry&&this.drawRange>=e&&ee(t.geometry,e,!0)?(--this.drawRange,t.geometry.setDrawRange(0,this.drawRange),t.geometry.computeBoundingBox(),t.geometry.computeBoundingSphere(),this.boundingBoxUpdateRequired=!0,!0):!1},B.prototype.setPosition=function(e,t,n){let r=this.getGroup();r&&(r.position.set(e,t,n),r.matrixWorldNeedsUpdate=!0,r.updateMatrix(),r.updateWorldMatrix(!0,!0),this.boundingBoxUpdateRequired=!0)},B.prototype.loadAdditionalSources=function(e,t){e.load(filename,meshloader(region,colour,opacity,localTimeEnabled,localMorphColour,void 0,void 0,void 0,void 0,finishCallback),this.onProgress(filename),this.onError(finishCallback))},B.prototype.setScaleAll=function(e){let t=this.getGroup();t&&(t.scale.set(e,e,e),t.updateMatrix(),this.boundingBoxUpdateRequired=!0)};var Se=(t,n,r)=>{let i=k(t,r),a=!1;1>r.opacity&&(a=!0);let o;if(i._video===void 0){let t=r.localTimeEnabled||r.localMorphColour;n?(o=n,o.morphTargets=t,o.morphNormals=r.localTimeEnabled):o=i instanceof e.BufferGeometry&&i.attributes.color===void 0?new e.MeshPhongMaterial({color:r.colour,morphTargets:t,morphNormals:r.localTimeEnabled,transparent:a,opacity:r.opacity,side:e.DoubleSide}):new e.MeshPhongMaterial({color:r.colour,morphTargets:t,morphNormals:r.localTimeEnabled,vertexColors:e.VertexColors,transparent:a,opacity:r.opacity,side:e.DoubleSide}),r.localMorphColour&&i.morphAttributes.color&&(o.onBeforeCompile=L())}else{let t=i._video.createCanvasVideoTexture();o=new e.MeshBasicMaterial({morphTargets:r.localTimeEnabled,color:new e.Color(1,1,1),transparent:a,opacity:r.opacity,map:t,side:e.DoubleSide}),(void 0).videoHandler=i._video}return new e.Mesh(i,o)},Ce=function(){B.call(this),this.videoHandler=void 0,this.isGeometry=!0,this.createMesh=(e,t,n)=>{if(this.morph&&this.morph.geometry&&e!=null)return;let r=Se(e,t,n);this.setMesh(r,n.localTimeEnabled,n.localMorphColour)},this.calculateUVs=()=>{this.geometry.computeBoundingBox();let t=this.geometry.boundingBox.max,n=this.geometry.boundingBox.min,r=new e.Vector2(0-n.x,0-n.y),i=new e.Vector2(t.x-n.x,t.y-n.y);this.geometry.faceVertexUvs[0]=[];for(let t=0;t<this.geometry.faces.length;t++){let n=this.geometry.vertices[this.geometry.faces[t].a],a=this.geometry.vertices[this.geometry.faces[t].b],o=this.geometry.vertices[this.geometry.faces[t].c];geometry.faceVertexUvs[0].push([new e.Vector2((n.x+r.x)/i.x,(n.y+r.y)/i.y),new e.Vector2((a.x+r.x)/i.x,(a.y+r.y)/i.y),new e.Vector2((o.x+r.x)/i.x,(o.y+r.y)/i.y)])}geometry.uvsNeedUpdate=!0},this.checkTransparentMesh=function(){this._lod.checkTransparentMesh()},this.setWireframe=e=>{this.morph.material.wireframe=e},this.editVertices=function(e,t){if(e&&e.length){let n=this.getMorph(),r=n.geometry.getAttribute(`position`);if(!n||0>t)return;{let i=t*3;e.forEach(e=>{r.array[i++]=e[0],r.array[i++]=e[1],r.array[i++]=e[2]}),r.needsUpdate=!0,n.geometry.computeBoundingBox(),n.geometry.computeBoundingSphere(),this.boundingBoxUpdateRequired=!0}}}};Ce.prototype=Object.create(B.prototype);var we=t.default.default||t.default,Te=function(t,n){let r=t,i,a=500;i=n?new we(r,.012,n.getStyle()):new we(r,.012),i.fontFace=`Asap`,i.fontSize=90,i.fontWeight=a,i.material.map.generateMipmaps=!0,i.material.map.anisotropy=4,i.material.minFilter=e.LinearMipmapLinearFilter,i.material.magFilter=e.LinearFilter,i.material.sizeAttenuation=!1,i.center.x=-.05,i.center.y=0;let o=[i.scale.x,i.scale.y];this.getPosition=()=>i?[i.position.x,i.position.y,i.position.z]:[0,0,0],this.setPosition=(e,t,n)=>{i&&i.position.set(e,t,n)},this.setColour=e=>{e&&(i.color=e.getStyle())},this.setScale=e=>{i&&e>0&&i.scale.set(e,e,1)},this.setDepthTest=e=>{e&&e!==i.material.depthTest&&(i.material.depthTest=e)},this.setSize=e=>{e>0&&(i.scale.x=o[0]*e,i.scale.y=o[1]*e)},this.setFontWeight=e=>{e&&e!==a&&(i.fontWeight=e,a=e)},this.setText=e=>{e&&e!==i.text&&(i.text=e,r=e)},this.setVisibility=e=>{i.visible=e},this.dispose=()=>{},this.getSprite=()=>i,this.getString=()=>r},Ee=function(t,n,r,i){B.call(this);let a;n&&(a=n.clone(),a.vertexColors=e.FaceColors);let o=i;this.id=r;let s,c;this.isGlyph=!0;let l=[0,0,0];this.fromMesh=e=>e&&e.isMesh?(this.morph=e.clone(),this.morph.userData=this,this.group.add(this.morph),!0):!1,t&&a&&this.fromMesh(new e.Mesh(t,a)),this.getGlyphset=function(){return o},this.setLabel=e=>{e&&(typeof e==`string`||e instanceof String)&&(c=e,this.morph&&(this.morph.name=e))},this.showLabel=e=>{if(s&&=(l=s.getPosition(),this.group.remove(s.getSprite()),s.dispose(),void 0),c&&(typeof c==`string`||c instanceof String)){s=new Te(c,e),s.setPosition(l[0],l[1],l[2]);let t=s.getSprite();t.material.alphaTest=.5,t.material.transparent=!0,t.material.depthWrite=!1,this.group.add(s.getSprite())}},this.hideLabel=()=>{s&&=(l=s.getPosition(),this.group.remove(s.getSprite()),s.dispose(),void 0)},this.getLabel=()=>c,this.getMesh=()=>this.morph,this.setTransformation=(e,t,n,r)=>{this.morph&&(this.morph.matrix.elements[0]=t[0],this.morph.matrix.elements[1]=t[1],this.morph.matrix.elements[2]=t[2],this.morph.matrix.elements[3]=0,this.morph.matrix.elements[4]=n[0],this.morph.matrix.elements[5]=n[1],this.morph.matrix.elements[6]=n[2],this.morph.matrix.elements[7]=0,this.morph.matrix.elements[8]=r[0],this.morph.matrix.elements[9]=r[1],this.morph.matrix.elements[10]=r[2],this.morph.matrix.elements[11]=0,this.morph.matrix.elements[12]=e[0],this.morph.matrix.elements[13]=e[1],this.morph.matrix.elements[14]=e[2],this.morph.matrix.elements[15]=1,this.morph.matrixAutoUpdate=!1),l=[...e],s&&s.setPosition(e[0],e[1],e[2])},this.setColour=e=>{s&&s.setColour(e),this.secondaryMesh&&this.secondaryMesh.material&&(this.secondaryMesh.material.color=colour),this.geometry&&(this.geometry.colorsNeedUpdate=!0)},this.dispose=()=>{this.material&&this.material.dispose(),this.morph=void 0}};Ee.prototype=Object.create(B.prototype);function De(){}De.Handlers={handlers:[],add:function(e,t){this.handlers.push(e,t)},get:function(e){for(var t=this.handlers,n=0,r=t.length;n<r;n+=2){var i=t[n],a=t[n+1];if(i.test(e))return a}return null}},Object.assign(De.prototype,{crossOrigin:`anonymous`,onLoadStart:function(){},onLoadProgress:function(){},onLoadComplete:function(){},initMaterials:function(e,t,n){for(var r=[],i=0;i<e.length;++i)r[i]=this.createMaterial(e[i],t,n);return r},createMaterial:(function(){var t={NoBlending:e.NoBlending,NormalBlending:e.NormalBlending,AdditiveBlending:e.AdditiveBlending,SubtractiveBlending:e.SubtractiveBlending,MultiplyBlending:e.MultiplyBlending,CustomBlending:e.CustomBlending},n=new e.Color,r=new e.TextureLoader,i=new e.MaterialLoader;return function(a,o,s){var c={};function l(t,n,i,a,l){var u=o+t,d=De.Handlers.get(u),f;d===null?(r.setCrossOrigin(s),f=r.load(u)):f=d.load(u),n!==void 0&&(f.repeat.fromArray(n),n[0]!==1&&(f.wrapS=e.RepeatWrapping),n[1]!==1&&(f.wrapT=e.RepeatWrapping)),i!==void 0&&f.offset.fromArray(i),a!==void 0&&(a[0]===`repeat`&&(f.wrapS=e.RepeatWrapping),a[0]===`mirror`&&(f.wrapS=e.MirroredRepeatWrapping),a[1]===`repeat`&&(f.wrapT=e.RepeatWrapping),a[1]===`mirror`&&(f.wrapT=e.MirroredRepeatWrapping)),l!==void 0&&(f.anisotropy=l);var p=e.MathUtils.generateUUID();return c[p]=f,p}var u={uuid:e.MathUtils.generateUUID(),type:`MeshLambertMaterial`};for(var d in a){var f=a[d];switch(d){case`DbgColor`:case`DbgIndex`:case`opticalDensity`:case`illumination`:break;case`DbgName`:u.name=f;break;case`blending`:u.blending=t[f];break;case`colorAmbient`:case`mapAmbient`:console.warn(`THREE.Loader.createMaterial:`,d,`is no longer supported.`);break;case`colorDiffuse`:u.color=n.fromArray(f).getHex();break;case`colorSpecular`:u.specular=n.fromArray(f).getHex();break;case`colorEmissive`:u.emissive=n.fromArray(f).getHex();break;case`specularCoef`:u.shininess=f;break;case`shading`:f.toLowerCase()===`basic`&&(u.type=`MeshBasicMaterial`),f.toLowerCase()===`phong`&&(u.type=`MeshPhongMaterial`),f.toLowerCase()===`standard`&&(u.type=`MeshStandardMaterial`);break;case`mapDiffuse`:u.map=l(f,a.mapDiffuseRepeat,a.mapDiffuseOffset,a.mapDiffuseWrap,a.mapDiffuseAnisotropy);break;case`mapDiffuseRepeat`:case`mapDiffuseOffset`:case`mapDiffuseWrap`:case`mapDiffuseAnisotropy`:break;case`mapEmissive`:u.emissiveMap=l(f,a.mapEmissiveRepeat,a.mapEmissiveOffset,a.mapEmissiveWrap,a.mapEmissiveAnisotropy);break;case`mapEmissiveRepeat`:case`mapEmissiveOffset`:case`mapEmissiveWrap`:case`mapEmissiveAnisotropy`:break;case`mapLight`:u.lightMap=l(f,a.mapLightRepeat,a.mapLightOffset,a.mapLightWrap,a.mapLightAnisotropy);break;case`mapLightRepeat`:case`mapLightOffset`:case`mapLightWrap`:case`mapLightAnisotropy`:break;case`mapAO`:u.aoMap=l(f,a.mapAORepeat,a.mapAOOffset,a.mapAOWrap,a.mapAOAnisotropy);break;case`mapAORepeat`:case`mapAOOffset`:case`mapAOWrap`:case`mapAOAnisotropy`:break;case`mapBump`:u.bumpMap=l(f,a.mapBumpRepeat,a.mapBumpOffset,a.mapBumpWrap,a.mapBumpAnisotropy);break;case`mapBumpScale`:u.bumpScale=f;break;case`mapBumpRepeat`:case`mapBumpOffset`:case`mapBumpWrap`:case`mapBumpAnisotropy`:break;case`mapNormal`:u.normalMap=l(f,a.mapNormalRepeat,a.mapNormalOffset,a.mapNormalWrap,a.mapNormalAnisotropy);break;case`mapNormalFactor`:u.normalScale=f;break;case`mapNormalRepeat`:case`mapNormalOffset`:case`mapNormalWrap`:case`mapNormalAnisotropy`:break;case`mapSpecular`:u.specularMap=l(f,a.mapSpecularRepeat,a.mapSpecularOffset,a.mapSpecularWrap,a.mapSpecularAnisotropy);break;case`mapSpecularRepeat`:case`mapSpecularOffset`:case`mapSpecularWrap`:case`mapSpecularAnisotropy`:break;case`mapMetalness`:u.metalnessMap=l(f,a.mapMetalnessRepeat,a.mapMetalnessOffset,a.mapMetalnessWrap,a.mapMetalnessAnisotropy);break;case`mapMetalnessRepeat`:case`mapMetalnessOffset`:case`mapMetalnessWrap`:case`mapMetalnessAnisotropy`:break;case`mapRoughness`:u.roughnessMap=l(f,a.mapRoughnessRepeat,a.mapRoughnessOffset,a.mapRoughnessWrap,a.mapRoughnessAnisotropy);break;case`mapRoughnessRepeat`:case`mapRoughnessOffset`:case`mapRoughnessWrap`:case`mapRoughnessAnisotropy`:break;case`mapAlpha`:u.alphaMap=l(f,a.mapAlphaRepeat,a.mapAlphaOffset,a.mapAlphaWrap,a.mapAlphaAnisotropy);break;case`mapAlphaRepeat`:case`mapAlphaOffset`:case`mapAlphaWrap`:case`mapAlphaAnisotropy`:break;case`flipSided`:u.side=e.BackSide;break;case`doubleSided`:u.side=e.DoubleSide;break;case`transparency`:console.warn(`THREE.Loader.createMaterial: transparency has been renamed to opacity`),u.opacity=f;break;case`depthTest`:case`depthWrite`:case`colorWrite`:case`opacity`:case`reflectivity`:case`transparent`:case`visible`:case`wireframe`:u[d]=f;break;case`vertexColors`:f===!0&&(u.vertexColors=e.VertexColors),f===`face`&&(u.vertexColors=e.FaceColors);break;default:console.error(`THREE.Loader.createMaterial: Unsupported`,d,f)}}return u.type===`MeshBasicMaterial`&&delete u.emissive,u.type!==`MeshPhongMaterial`&&delete u.specular,u.opacity<1&&(u.transparent=!0),i.setTextures(c),i.parse(u)}})()});var Oe=function(t){var n=this;this.video=void 0,this.videoTexture=void 0;var r=t,i=function(){document&&(n.video=document.createElement(`video`),n.video.crossOrigin=`anonymous`,n.video.src=r,n.video.load(),n.video.loop=!0)};this.setMorphTime=function(e,t){var r=e/t*n.video.duration;n.video.currentTime=r},this.getVideoDuration=function(){return n.video.duration},this.createCanvasVideoTexture=function(){return n.videoTexture=new e.VideoTexture(n.video),n.videoTexture.minFilter=e.LinearFilter,n.videoTexture.magFilter=e.LinearFilter,n.videoTexture.format=e.RGBFormat,n.video.currentTime=0,n.videoTexture},this.getCurrentTime=function(e){return n.video?e*(n.video.currentTime/n.video.duration):0},this.isReadyToPlay=function(){return!!(n.video&&n.video.readyState>=3)},i()},ke=e.AnimationClip,Ae=e.Color,je=e.DefaultLoadingManager,Me=e.FileLoader,Ne=e.LoaderUtils,Pe=e.Vector2,Fe=e.Vector3,Ie=e.Vector4;function Le(e){typeof e==`boolean`&&(console.warn(`THREE.JSONLoader: showStatus parameter has been removed from constructor.`),e=void 0),this.manager=e===void 0?je:e,this.withCredentials=!1,this.paramsString=``}Object.assign(Le.prototype,{load:function(e,t,n,r){var i=this,a=this.texturePath&&typeof this.texturePath==`string`?this.texturePath:Ne.extractUrlBase(e),o=new Me(this.manager);e.split(`?`),this.paramsString=e.length===2?paramsStrings[1]:``,o.setWithCredentials(this.withCredentials),o.load(e,function(n){var o=void 0;try{o=JSON.parse(n)}catch{if(console.error(`The loader has encountered an error while parsing the content of a resource.`),r){r({responseURL:e});return}}var s=o.metadata;if(s!==void 0){var c=s.type;if(c!==void 0&&c.toLowerCase()===`object`){console.error(`THREE.JSONLoader: `+e+` should be loaded with THREE.ObjectLoader instead.`);return}}if(i&&i.parse)try{var l=i.parse(o,a);t(l.geometry,l.materials)}catch(t){if(console.error(`The loader has encountered aon loading the geometry`),console.error(t),r){r({responseURL:e});return}}},n,r)},setTexturePath:function(e){this.texturePath=e},parse:(function(){function t(e,t){function n(e,t){return e&1<<t}var r,i,a,o,s,c,l,u,d,f,p,m,h,g,_,v,y,x,S,C,w,T,E,D,O,k,A,j=e.faces,M=e.vertices,N=e.normals,P=e.colors,F=e.scale,I=0;if(e.uvs!==void 0){for(r=0;r<e.uvs.length;r++)e.uvs[r].length&&I++;for(r=0;r<I;r++)t.faceVertexUvs[r]=[]}for(o=0,s=M.length;o<s;)x=new Fe,x.x=M[o++]*F,x.y=M[o++]*F,x.z=M[o++]*F,t.vertices.push(x);if(o=0,s=j.length,e.uvs)for(r=0;r<e.uvs.length;r++){t.uvs[r]=[];for(let n=0;n<e.uvs[r].length;n++)t.uvs[r][n]=e.uvs[r][n]}if(N)for(r=0;r<N.length;r++)t.normals[r]=N[r];if(P)for(r=0;r<P.length;r++)t.colors[r]=P[r];for(;o<s;)if(f=j[o++],p=n(f,0),m=n(f,1),h=n(f,3),g=n(f,4),_=n(f,5),v=n(f,6),y=n(f,7),p){if(C=new b,C.a=j[o],C.b=j[o+1],C.c=j[o+3],w=new b,w.a=j[o+1],w.b=j[o+2],w.c=j[o+3],o+=4,m&&(d=j[o++],C.materialIndex=d,w.materialIndex=d),a=t.faces.length,h)for(r=0;r<I;r++)for(D=e.uvs[r],t.faceVertexUvs[r][a]=[],t.faceVertexUvs[r][a+1]=[],i=0;i<4;i++)u=j[o++],k=D[u*2],A=D[u*2+1],O=new Pe(k,A),i!==2&&t.faceVertexUvs[r][a].push(O),i!==0&&t.faceVertexUvs[r][a+1].push(O);if(g&&(l=j[o++]*3,C.normal.set(N[l++],N[l++],N[l]),w.normal.copy(C.normal)),_)for(r=0;r<4;r++)l=j[o++]*3,E=new Fe(N[l++],N[l++],N[l]),r!==2&&C.vertexNormals.push(E),r!==0&&w.vertexNormals.push(E);if(v&&(c=j[o++],T=P[c],C.color.setHex(T),w.color.setHex(T)),y)for(r=0;r<4;r++)c=j[o++],T=P[c],r!==2&&C.vertexColors.push(new Ae(T)),r!==0&&w.vertexColors.push(new Ae(T));t.faces.push(C),t.faces.push(w)}else{if(S=new b,S.a=j[o++],S.b=j[o++],S.c=j[o++],S.b||(S.b=S.a),S.c||(S.c=S.b),m&&(d=j[o++],S.materialIndex=d),a=t.faces.length,h)for(r=0;r<I;r++)for(D=e.uvs[r],t.faceVertexUvs[r][a]=[],i=0;i<3;i++)u=j[o++],k=D[u*2],A=D[u*2+1],O=new Pe(k,A),t.faceVertexUvs[r][a].push(O);if(g&&(l=j[o++]*3,S.normal.set(N[l++],N[l++],N[l])),_)for(r=0;r<3;r++)l=j[o++]*3,E=new Fe(N[l++],N[l++],N[l]),S.vertexNormals.push(E);if(v&&(c=j[o++],S.color.setHex(P[c])),y)for(r=0;r<3;r++)c=j[o++],S.vertexColors.push(new Ae(P[c]));t.faces.push(S)}}function n(e,t){var n=e.influencesPerVertex===void 0?2:e.influencesPerVertex;if(e.skinWeights)for(var r=0,i=e.skinWeights.length;r<i;r+=n){var a=e.skinWeights[r],o=n>1?e.skinWeights[r+1]:0,s=n>2?e.skinWeights[r+2]:0,c=n>3?e.skinWeights[r+3]:0;t.skinWeights.push(new Ie(a,o,s,c))}if(e.skinIndices)for(var r=0,i=e.skinIndices.length;r<i;r+=n){var l=e.skinIndices[r],u=n>1?e.skinIndices[r+1]:0,d=n>2?e.skinIndices[r+2]:0,f=n>3?e.skinIndices[r+3]:0;t.skinIndices.push(new Ie(l,u,d,f))}t.bones=e.bones,t.bones&&t.bones.length>0&&(t.skinWeights.length!==t.skinIndices.length||t.skinIndices.length!==t.vertices.length)&&console.warn(`When skinning, number of vertices (`+t.vertices.length+`), skinIndices (`+t.skinIndices.length+`), and skinWeights (`+t.skinWeights.length+`) should match.`)}function r(t,n){var r=t.scale;if(t.morphTargets!==void 0)for(var i=0,a=t.morphTargets.length;i<a;i++){n.morphTargets[i]={},n.morphTargets[i].name=t.morphTargets[i].name,n.morphTargets[i].vertices=[];for(var o=n.morphTargets[i].vertices,s=t.morphTargets[i].vertices,c=0,l=s.length;c<l;c+=3){var u=new Fe;u.x=s[c]*r,u.y=s[c+1]*r,u.z=s[c+2]*r,o.push(u)}}if(t.morphNormals!==void 0){for(var i=0,a=t.morphNormals.length;i<a;i++)if(n.morphTargets[i]){n.morphTargets[i].normals=[];for(var d=n.morphTargets[i].normals,f=t.morphNormals[i].normals,c=0,l=f.length;c<l;c+=3){var p=new Fe;p.x=f[c],p.y=f[c+1],p.z=f[c+2],d.push(p)}n.morphNormalsReady=!0}}if(t.morphColors!==void 0){var i,a,m,h,g,_,v;for(i=0,a=t.morphColors.length;i<a;i++)for(n.morphColors[i]={},n.morphColors[i].name=t.morphColors[i].name,n.morphColors[i].colors=[],g=n.morphColors[i].colors,_=t.morphColors[i].colors,m=0,h=_.length;m<h;m+=3)v=new e.Color(16755200),v.setRGB(_[m],_[m+1],_[m+2]),g.push(v)}}function i(e,t){var n=[],r=[];e.animation!==void 0&&r.push(e.animation),e.animations!==void 0&&(e.animations.length?r=r.concat(e.animations):r.push(e.animations));for(var i=0;i<r.length;i++){var a=ke.parseAnimation(r[i],t.bones);a&&n.push(a)}if(t.morphTargets){var o=ke.CreateClipsFromMorphTargetSequences(t.morphTargets,10);n=n.concat(o)}n.length>0&&(t.animations=n)}return function(a,o){a.data!==void 0&&(a=a.data),a.scale===void 0?a.scale=1:a.scale=1/a.scale;var s=new v;if(s.morphColors=[],t(a,s),n(a,s),r(a,s),i(a,s),s.computeFaceNormals(),s.computeBoundingSphere(),a.materials===void 0||a.materials.length===0)return{geometry:s};var c=De.prototype.initMaterials(a.materials,o,`Anonymous`);if(a.materials[0].video){var l=o+a.materials[0].video;this.paramsString&&(l+=`?${this.paramsString}`),s._video=new Oe(l)}return c&&c.length>0&&(a.materials[0].singleSided?c[0].side=e.FrontSide:a.materials[0].flipSided?c[0].side=e.BackSide:c[0].side=e.DoubleSide,a.materials[0].specularCoef&&(c[0].shininess=Math.floor(a.materials[0].specularCoef/3))),{geometry:s,materials:c}}})()});var Re=function(){B.call(this);let t=[],n,r,i,a,o,s,c,l=0,u=0,d=[0,0,0],f=[0,0,0],p=!1,m=[0,0,0],h=`NONE`;this.ready=!1;let g=!1,_=!1;this.isGlyphset=!0;let v=new e.Matrix4,y=new e.Color,b=new e.Color,x=new e.Box3,S=new e.Box3,C=new e.Box3,w=[],T=[],E=[],D=[],O=[],k=[],A=[],j=[];this.globalScale=1;for(let t=0;t<8;t++)w[t]=new e.Vector3;this.load=(t,p,v,y,b)=>{n=t.axis1,r=t.axis2,i=t.axis3,a=t.positions,o=t.scale,s=t.colors,c=t.label,g=t.metadata.MorphColours,_=t.metadata.MorphVertices,l=t.metadata.number_of_time_steps,h=t.metadata.repeat_mode,u=t.metadata.number_of_vertices,h==`AXES_2D`||h==`MIRROR`?u*=2:h==`AXES_3D`&&(u*=3),d=t.metadata.base_size,f=t.metadata.offset,m=t.metadata.scale_factors;let x=new Le;this.geometry=new e.BufferGeometry;let S=new e.InstancedMesh(this.geometry,void 0,u);if(this.setMorph(S),y){var C=x.parse(p);ee(v,b)(C.geometry,C.materials),C.geometry.dispose()}else x.crossOrigin=`Anonymous`,x.load(p,ee(v,b))};let M=(e,t,n,r,i,a)=>{if(h==`NONE`||h==`MIRROR`){let c=[0,0,0],l=[0,0,0],u=[0,0,0],p=[0,0,0],g=[0,0,0],_=[0,0,0],v=[0,0,0],y=[0,0,0],b=[0,0,0];for(var o=0;o<3;o++){var s=i[o]<0?-1:1;c[o]=(s*d[o]+i[o]*m[o])*this.globalScale}for(var o=0;o<3;o++)l[o]=t[o]*c[0],u[o]=n[o]*c[1],p[o]=r[o]*c[2],g[o]=e[o]+f[0]*l[o]+f[1]*u[o]+f[2]*p[o],h==`MIRROR`&&(_[o]=-l[o],v[o]=-u[o],y[o]=-p[o],b[o]=g[o],i[0]<0&&(g[o]-=l[o],b[o]-=_[o]));0>p[0]*(l[1]*u[2]-l[2]*u[1])+p[1]*(l[2]*u[0]-l[0]*u[2])+p[2]*(l[0]*u[1]-l[1]*u[0])&&(p[0]=-p[0],p[1]=-p[1],p[2]=-p[2]),a[0]=[g,l,u,p],h==`MIRROR`&&(0>y[0]*(_[1]*v[2]-_[2]*v[1])+y[1]*(_[2]*v[0]-_[0]*v[2])+y[2]*(_[0]*v[1]-_[1]*v[0])&&(y[0]=-y[0],y[1]=-y[1],y[2]=-y[2]),a[1]=[b,_,v,y])}else if(h==`AXES_2D`||h==`AXES_3D`){let l=[0,0,0],u=[0,0,0];for(var o=0;o<3;o++){var s=i[o]<0?-1:1;l[o]=(s*d[0]+i[o]*m[0])*this.globalScale}for(var o=0;o<3;o++)u[o]=e[o]+f[0]*l[0]*t[o]+f[1]*l[1]*n[o]+f[2]*l[2]*r[o];let p=glyph_repeat_mode==`AXES_2D`?2:3;for(let e=0;e<p;e++){let o,s,l=i[e],f=[0,0,0],p=[0,0,0],g=[0,0,0];e==0?(o=t,s=n):e==1?(o=n,s=glyph_repeat_mode==`AXES_2D`?t:r):(o=r,s=t);let _=(d[0]+l*m[0])*this.globalScale;f[0]=o[0]*_,f[1]=o[1]*_,f[2]=o[2]*_,g[0]=f[1]*s[2]-s[1]*f[2],g[1]=f[2]*s[0]-s[2]*f[0],g[2]=f[0]*s[1]-f[1]*s[0];let v=Math.sqrt(g[0]*g[0]+g[1]*g[1]+g[2]*g[2]);if(0<v){let t=(d[2]+l*m[2])*this.globalScale/v;h==`AXES_2D`&&e>0&&(t*=-1),g[0]*=t,g[1]*=t,g[2]*=t}if(p[0]=g[1]*f[2]-f[1]*g[2],p[1]=g[2]*f[0]-f[2]*g[0],p[2]=g[0]*f[1]-g[1]*f[0],v=Math.sqrt(p[0]*p[0]+p[1]*p[1]+p[2]*p[2]),0<v){var c=(d[1]+l*m[1])*this.globalScale/v;p[0]*=c,p[1]*=c,p[2]*=c}a[e]=[u,f,p,g]}}return a},N=(e,n,r,i,a)=>{let o=1;h==`AXES_2D`||h==`MIRROR`?o=2:h==`AXES_3D`&&(o=3);let s=e.length/3,c=0;j.length=o;for(let l=0;l<s;l++){let s=l*3,u=[e[s],e[s+1],e[s+2]],d=[n[s],n[s+1],n[s+2]],f=[r[s],r[s+1],r[s+2]],p=[i[s],i[s+1],i[s+2]],m=[a[s],a[s+1],a[s+2]],h=M(u,d,f,p,m,j);if(h.length==o)for(let e=0;e<o;e++){v.elements[0]=h[e][1][0],v.elements[1]=h[e][1][1],v.elements[2]=h[e][1][2],v.elements[3]=0,v.elements[4]=h[e][2][0],v.elements[5]=h[e][2][1],v.elements[6]=h[e][2][2],v.elements[7]=0,v.elements[8]=h[e][3][0],v.elements[9]=h[e][3][1],v.elements[10]=h[e][3][2],v.elements[11]=0,v.elements[12]=h[e][0][0],v.elements[13]=h[e][0][1],v.elements[14]=h[e][0][2],v.elements[15]=1,this.morph.setMatrixAt(c,v);let n=t[c];n&&n.setTransformation(h[e][0],h[e][1],h[e][2],h[e][3]),c++}}this.morph.instanceMatrix.needsUpdate=!0},P=e=>{let n=1;h==`AXES_2D`||h==`MIRROR`?n=2:h==`AXES_3D`&&(n=3);let r=e.length,i=0;for(let a=0;a<r;a++){let r=e[a];for(let e=0;e<n;e++){y.setHex(r),this.morph.setColorAt(i,y);let e=t[i];e&&e.setColour(y),i++}}this.morph.instanceColor.needsUpdate=!0},F=()=>{let e=T,t=E,c=D,u=O,d=k,f=A,p=this.inbuildTime/this.duration*(l-1),m=Math.floor(p),h=1-(p-m),v=Math.ceil(p);if(_){let s=a[m.toString()],l=a[v.toString()],f=n[m.toString()],p=n[v.toString()],g=r[m.toString()],_=r[v.toString()],y=i[m.toString()],b=i[v.toString()],x=o[m.toString()],S=o[v.toString()];T.length=s.length,E.length=s.length,D.length=s.length,O.length=s.length,k.length=s.length;for(let n=0;n<s.length;n++)e[n]=h*s[n]+(1-h)*l[n],t[n]=h*f[n]+(1-h)*p[n],c[n]=h*g[n]+(1-h)*_[n],u[n]=h*y[n]+(1-h)*b[n],d[n]=h*x[n]+(1-h)*S[n]}else e=a[0],t=n[0],c=r[0],u=i[0],d=o[0];if(N(e,t,c,u,d),this.boundingBoxUpdateRequired=!0,s!=null){if(g){let e=s[m.toString()],t=s[v.toString()];f.length=e.length;for(let n=0;n<e.length;n++)y.setHex(e[n]),b.setHex(t[n]),y.setRGB(y.r*h+b.r*(1-h),y.g*h+b.g*(1-h),y.b*h+b.b*(1-h)),f[n]=y.getHex()}else f=s[0];P(f)}};this.getLabel=e=>{if(c&&c.length>e)return c[e]},this.isLabelDisplayed=()=>p,this.canShowLabel=()=>t?.length&&(c?.length||this.groupName),this.showLabel=()=>{if(t?.length){p=!0;for(let e=0;e<t.length;e++)t[e].showLabel(this.morph.material?this.morph.material.color:void 0)}},this.hideLabel=()=>{for(let e=0;e<t.length;e++)t[e].hideLabel();p=!1};let I=e=>{for(let e=0;e<u;e++){let n=new Ee(void 0,void 0,e,this),r=c?c[e]:void 0;r||=this.groupName,r&&n.setLabel(r),l>0&&n.setFrustumCulled(!1),t[e]=n,this.morph.add(n.getGroup())}c&&c.length>0&&e&&this.showLabel(),N(a[0],n[0],r[0],i[0],o[0]),s!=null&&P(s[0]),this.ready=!0,this.boundingBoxUpdateRequired=!0};this.addCustomGlyph=e=>{e.isGlyph&&t.push(e),this.ready=!0,this.boundingBoxUpdateRequired=!0},this.addMeshAsGlyph=(e,n)=>{if(e.isMesh){let r=new Ee(void 0,void 0,n,this);return r.fromMesh(e),t.push(r),this.morph.add(r.getGroup()),this.ready=!0,this.boundingBoxUpdateRequired=!0,r}},this.forEachGlyph=e=>{for(let n=0;n<t.length;n++)e(t[n])};var ee=(e,t)=>(n,r)=>{let i=n.toBufferGeometry();this.geometry.copy(i),this.geometry.computeBoundingSphere(),this.geometry.computeBoundingBox(),i.dispose(),r&&r[0]&&(this.morph.material=r[0]),I(t),this.morph.name=this.groupName,this.morph.userData=this,this.setMorph(this.morph),n.dispose(),e!=null&&typeof e==`function`&&e(this)};this.getClosestVertexIndex=function(){let e=-1;if(this.morph&&this.ready){this.getBoundingBox().getCenter(this._v1);let t=a[0],n=t.length/3,r=-1,i=0;for(let a=0;a<n;a++){let n=a*3;this._v2.set(t[n],t[n+1],t[n+2]),i=this._v1.distanceTo(this._v2),(r==-1||r>i)&&(r=i,e=a)}}return e},this.getClosestVertex=function(){if(this.closestVertexIndex==-1&&(this.closestVertexIndex=this.getClosestVertexIndex()),this.closestVertexIndex>=0&&this.morph){let t=new e.Vector3;return this.morph.getMatrixAt(this.closestVertexIndex,v),t.setFromMatrixPosition(v),t}},this.getBoundingBox=()=>{if(this.morph&&this.ready&&this.morph.visible){if(this.boundingBoxUpdateRequired){x.setFromBufferAttribute(this.morph.geometry.attributes.position);for(let e=0;e<u;e++)this.morph.getMatrixAt(e,v),S.copy(x).applyMatrix4(v),e==0?C.copy(S):C.union(S);if(C)this.cachedBoundingBox.copy(C),this.morph.updateWorldMatrix(!0,!0),this.cachedBoundingBox.applyMatrix4(this.morph.matrixWorld),this.boundingBoxUpdateRequired=!1;else return}return this.cachedBoundingBox}},this.setMorphTime=e=>{this.inbuildTime=e>this.duration?this.duration:0>e?0:e,(g||_)&&(F(),_&&(this.markerUpdateRequired=!0))},this.isTimeVarying=()=>!!((this.ready===!1||l>0)&&(g||_)),this.getCurrentTime=()=>this.inbuildTime,this.setScaleAll=function(e){this.globalScale=e,F()},this.dispose=()=>{for(let e=t.length-1;e>=0;e--)t[e].dispose();this.geometry&&this.geometry.dispose(),this.morph&&this.morph.material.dispose(),n=void 0,r=void 0,i=void 0,a=void 0,o=void 0,s=void 0,this.ready=!1,this.groupName=void 0},this.render=(e,t,n)=>{if(t==1){let t=this.inbuildTime+e;t>this.duration&&(t-=this.duration),this.inbuildTime=t,(g||_)&&F()}this.updateMarker(t,n)}};Re.prototype=Object.create(B.prototype);var ze=new e.Matrix4,Be=new e.Ray,Ve=new e.Sphere,He=new e.Vector3,Ue=new e.Vector3,We=new e.Vector3,Ge=class extends e.Object3D{constructor(t=new e.BufferGeometry,n=new e.PointsMaterial){super(),this.type=`Points`,this.geometry=t,this.material=n,this.sizePerPixel=1,this.updateMorphTargets()}copy(e){return super.copy(e),this.material=e.material,this.geometry=e.geometry,this}raycast(e,t){let n=this.geometry,r=this.matrixWorld,i=e.params.Points.threshold,a=n.drawRange;if(n.boundingSphere===null&&n.computeBoundingSphere(),Ve.copy(n.boundingSphere),Ve.applyMatrix4(r),Ve.radius+=i,e.ray.intersectsSphere(Ve)===!1)return;ze.copy(r).invert(),Be.copy(e.ray).applyMatrix4(ze);let o=i/((this.scale.x+this.scale.y+this.scale.z)/3)*this.material.size*this.sizePerPixel,s=o*o;if(n.isBufferGeometry){let i=n.index,o=n.attributes.position,c=n.morphAttributes.position;if(i!==null){let n=Math.max(0,a.start),l=Math.min(i.count,a.start+a.count);for(let a=n,u=l;a<u;a++){let n=i.getX(a);qe(this,o,c,n),Ke(He,n,s,r,e,t,this)}}else{let n=Math.max(0,a.start),i=Math.min(o.count,a.start+a.count);for(let a=n,l=i;a<l;a++)qe(this,o,c,a),Ke(He,a,s,r,e,t,this)}}else console.error(`THREE.Points.raycast() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.`)}updateMorphTargets(){let e=this.geometry;if(e.isBufferGeometry){let t=e.morphAttributes,n=Object.keys(t);if(n.length>0){let e=t[n[0]];if(e!==void 0){this.morphTargetInfluences=[],this.morphTargetDictionary={};for(let t=0,n=e.length;t<n;t++){let n=e[t].name||String(t);this.morphTargetInfluences.push(0),this.morphTargetDictionary[n]=t}}}}else{let t=e.morphTargets;t!==void 0&&t.length>0&&console.error(`THREE.Points.updateMorphTargets() does not support THREE.Geometry. Use THREE.BufferGeometry instead.`)}}};Ge.prototype.isPoints=!0;function Ke(t,n,r,i,a,o,s){let c=Be.distanceSqToPoint(t);if(c<r){let r=new e.Vector3;Be.closestPointToPoint(t,r),r.applyMatrix4(i);let l=a.ray.origin.distanceTo(r);if(l<a.near||l>a.far)return;o.push({distance:l,distanceToRay:Math.sqrt(c),point:r,index:n,face:null,object:s})}}function qe(e,t,n,r){He.fromBufferAttribute(t,r);let i=e.morphTargetInfluences;if(e.material.morphTargets&&n&&i){Ue.set(0,0,0);for(var a=0,o=n.length;a<o;a++){let e=i[a],t=n[a];e!==0&&(We.fromBufferAttribute(t,r),Ue.addScaledVector(We.sub(He),e))}He.add(Ue)}}var Je=function(){B.call(this),this.isPointset=!0;let t=[],n=1,r=!1,i=500,a=!0;this.createMesh=(e,t,n)=>{if(e&&t){let r=k(e,n);t.map=P();let i=new Ge(r,t);this.setMesh(i,n.localTimeEnabled,n.localMorphColour)}};let o=(o,s,c,l)=>{if(c){let u=new Te(c,new e.Color(l));u.setPosition(s[0],s[1],s[2]);let d=u.getSprite();d.material.sizeAttenuation=!1,d.material.alphaTest=.5,d.material.transparent=!0,d.material.depthWrite=!1,d.material.depthTest=r,u.setFontWeight(i),u.setSize(n),u.setVisibility(a),this.group.add(d),t[o]=u}},s=e=>{let n=t[e];if(n){let r=n.getSprite();this.group.remove(r),n.dispose(),t.splice(e,1)}};this.addPoints=(n,r,i)=>{if(n&&n.length>0){let a=this.drawRange;a===-1&&(a=0);let s=this.addVertices(n);if(!this.getMorph()){let t=new e.PointsMaterial({alphaTest:.5,size:10,color:i,sizeAttenuation:!1});s.colorsNeedUpdate=!0,this.createMesh(s,t,{localTimeEnabled:!1,localMorphColour:!1})}let c=a+n.length,l=0;if(Array.isArray(r)&&r.length===n.length||typeof r==`string`)for(t.length;a+l<c;){let e=typeof r==`string`?r:r[l];o(a+l,n[l],e,this._lod._material.color),l++}this.region&&(this.region.pickableUpdateRequired=!0)}},this.setColourHex=function(e){this._lod._material.color.setHex(e),this._lod._secondaryMaterial&&this._lod._secondaryMaterial.color.setHex(e);for(let e=0;e<t.length;e++)t[e]&&t[e].setColour(this._lod._material.color)},this.setColour=e=>{this._lod.setColour(e);for(let e=0;e<t.length;e++)t[e]&&t[e].setColour(this._lod._material.color)},this.setLabelDepthTest=e=>{r=e;for(let n=0;n<t.length;n++)t[n]&&t[n].setDepthTest(e)},this.setLabelFontWeight=e=>{i=e;for(let n=0;n<t.length;n++)t[n]&&t[n].setFontWeight(e)},this.setLabelSize=e=>{n=e;for(let e=0;e<t.length;e++)t[e]&&t[e].setSize(n)},this.displayLabels=e=>{a=e;for(let e=0;e<t.length;e++)t[e]&&t[e].setVisibility(a)},this.setSize=e=>{this.morph&&this.morph.material&&(this.morph.material.size=e,this.morph.material.needsUpdate=!0)},this.setSizeAttenuation=e=>{this.morph&&this.morph.material&&(this.morph.material.sizeAttenuation=e,this.morph.material.needsUpdate=!0)},this.getVerticesByIndex=function(e){if(e>=0&&this.drawRange>e){let t=this.getMorph().geometry.getAttribute(`position`);return[t.getX(e),t.getY(e),t.getZ(e)]}},this.editVertices=function(e,n){if(e&&e.length){let r=this.getMorph(),i=n+e.length-1;if(!r||0>n||i>=this.drawRange)return;{let i=r.geometry.getAttribute(`position`),a=n;e.forEach(e=>{let n=t[a];n&&n.setPosition(e[0],e[1],e[2]),i.setXYZ(a++,e[0],e[1],e[2])}),i.needsUpdate=!0,r.geometry.computeBoundingBox(),r.geometry.computeBoundingSphere(),this.boundingBoxUpdateRequired=!0}}},this.deleteVertices=function(e){return Je.prototype.deleteVertices.call(this,e)&&s(e),this.drawRange},this.setName=function(e){let n=this.groupName;Je.prototype.setName.call(this,e),t.forEach(t=>{t.getString()===n&&t?.setText(e)})},this.render=(e,t,n,r)=>{this.morph&&n&&(this.morph.sizePerPixel=n.pixelHeight),Je.prototype.render.call(this,e,t,n,r)}};Je.prototype=Object.create(B.prototype);var Ye=function(){B.call(this),this.isLines=!0,this.createLineSegment=(e,t,n)=>{if(e&&t){let r=k(e,n);n.localMorphColour&&r.morphAttributes.color&&(t.onBeforeCompile=L());let i=new pe(r,t);this.setMesh(i,n.localTimeEnabled,n.localMorphColour)}},this.setWidth=e=>{this.morph&&this.morph.material&&(this.morph.material.linewidth=e,this.morph.material.needsUpdate=!0)},this.addLines=(t,n)=>{if(t&&t.length>0){let r=this.addVertices(t);if(!this.getMorph()){let t=new e.LineBasicMaterial({color:n});r.colorsNeedUpdate=!0,this.createLineSegment(r,t,{localTimeEnabled:!1,localMorphColour:!1})}this.region&&(this.region.pickableUpdateRequired=!0)}}};Ye.prototype=Object.create(B.prototype);var Xe=function(){this.isTexture=!0,this.impl=void 0,this.isLoading=!1,this.size={width:1,height:1,depth:0}};Xe.prototype.loadImage=function(e,t){return new Promise((n,r)=>{e.onload=()=>n(e),e.onerror=r,e.src=t})},Xe.prototype.imageToUint8Array=async function(e,t,n,r){await e.loadImage(t,n),r.width=t.width,r.height=t.height;let i=r.getContext(`2d`);return i.drawImage(t,0,0),{array:new Uint8Array(i.getImageData(0,0,r.width,r.height).data.buffer),width:r.width,height:r.height}},Xe.prototype.loadFromImages=async function(e){},Xe.prototype.isReady=function(){return!!(this.impl&&!this.isLoading)},Xe.prototype.getMaterial=function(){if(this.impl)return new e.MeshBasicMaterial({color:new e.Color(1,1,1),transparent:!1,opacity:1,map:this.impl,side:e.DoubleSide})};var Ze=function(){Xe.call(this),this.isTextureArray=!0,this.loadFromImages=async t=>{let n=1,r=1,i=0;if(t&&t.length){this.isLoading=!0;let a=new Image;a.crossOrigin=`Anonymous`;let o=document.createElement(`canvas`),s=0,c=Array(t.length);for(let e=0;e<t.length;e++){let l=await this.imageToUint8Array(this,a,t[e],o);l&&l.array&&(n=l.width,r=l.height,c[i]=l.array,s+=c[i].length,i++)}let l=new Uint8Array(s);s=0,c.forEach(e=>{l.set(e,s),s+=e.length}),this.impl=new e.DataTexture2DArray(l,n,r,i),this.size={width:n,height:r,depth:i},this.isLoading=!1,this.impl.needsUpdate=!0}},this.getMaterial=t=>{if(this.impl){let n;if(t){if(t.vs&&t.fs){let r=!0;`transparent`in t&&(r=t.transparent);let i=e.FrontSide;t.side&&(i=t.side),n=new e.ShaderMaterial({transparent:r,uniforms:t.uniforms,vertexShader:t.vs,fragmentShader:t.fs,side:i}),t.glslVersion&&(n.glslVersion=t.glslVersion)}}else n=new e.MeshBasicMaterial({color:new e.Color(1,1,1),transparent:!1,opacity:1,map:this.impl,side:e.DoubleSide});if(n)return n.needsUpdate=!0,n}}};Ze.prototype=Object.create(Xe.prototype);var Qe=e.GLSL3,$e=`
4
4
  precision highp float;
5
5
  precision highp int;
6
6
  precision highp sampler2DArray;
@@ -288,7 +288,7 @@ void main() {
288
288
  `)!==-1&&(t=t.replace(/\r\n/g,`
289
289
  `)),t.indexOf(`\\
290
290
  `)!==-1&&(t=t.replace(/\\\n/g,``));let r=t.split(`
291
- `),i=``,a=``,o=0,s=[],c=typeof``.trimLeft==`function`;for(let e=0,t=r.length;e<t;e++)if(i=r[e],i=c?i.trimLeft():i.trim(),o=i.length,o!==0&&(a=i.charAt(0),a!==`#`)){if(a===`v`){let e=i.split(/\s+/);switch(e[0]){case`v`:n.vertices.push(parseFloat(e[1]),parseFloat(e[2]),parseFloat(e[3])),e.length>=7?n.colors.push(parseFloat(e[4]),parseFloat(e[5]),parseFloat(e[6])):n.colors.push(void 0,void 0,void 0);break;case`vn`:n.normals.push(parseFloat(e[1]),parseFloat(e[2]),parseFloat(e[3]));break;case`vt`:n.uvs.push(parseFloat(e[1]),parseFloat(e[2]))}}else if(a===`f`){let e=i.substr(1).trim().split(/\s+/),t=[];for(let n=0,r=e.length;n<r;n++){let r=e[n];if(r.length>0){let e=r.split(`/`);t.push(e)}}let r=t[0];for(let e=1,i=t.length-1;e<i;e++){let i=t[e],a=t[e+1];n.addFace(r[0],i[0],a[0],r[1],i[1],a[1],r[2],i[2],a[2])}}else if(a===`l`){let e=i.substring(1).trim().split(` `),t=[],r=[];if(i.indexOf(`/`)===-1)t=e;else for(let n=0,i=e.length;n<i;n++){let i=e[n].split(`/`);i[0]!==``&&t.push(i[0]),i[1]!==``&&r.push(i[1])}n.addLineGeometry(t,r)}else if(a===`p`){let e=i.substr(1).trim().split(` `);n.addPointGeometry(e)}else if((s=rn.exec(i))!==null){let e=(` `+s[0].substr(1).trim()).substr(1);n.startObject(e)}else if(on.test(i))n.object.startMaterial(i.substring(7).trim(),n.materialLibraries);else if(an.test(i))n.materialLibraries.push(i.substring(7).trim());else if(sn.test(i))console.warn(`THREE.OBJLoader: Rendering identifier "usemap" not supported. Textures must be defined in MTL files.`);else if(a===`s`){if(s=i.split(` `),s.length>1){let e=s[1].trim().toLowerCase();n.object.smooth=e!==`0`&&e!==`off`}else n.object.smooth=!0;let e=n.object.currentMaterial();e&&(e.smooth=n.object.smooth)}else{if(i===`\0`)continue;console.warn(`THREE.OBJLoader: Unexpected line: "`+i+`"`)}}n.finalize();let l=new e.Group;if(l.materialLibraries=[].concat(n.materialLibraries),n.objects.length!==1||n.objects[0].geometry.vertices.length!==0)for(let t=0,r=n.objects.length;t<r;t++){let r=n.objects[t],i=r.geometry,a=r.materials,o=i.type===`Line`,s=i.type===`Points`,c=!1;if(i.vertices.length===0)continue;let u=new e.BufferGeometry;u.setAttribute(`position`,new e.Float32BufferAttribute(i.vertices,3)),i.normals.length>0&&u.setAttribute(`normal`,new e.Float32BufferAttribute(i.normals,3)),i.colors.length>0&&(c=!0,u.setAttribute(`color`,new e.Float32BufferAttribute(i.colors,3))),i.hasUVIndices===!0&&u.setAttribute(`uv`,new e.Float32BufferAttribute(i.uvs,2));let d=[];for(let t=0,r=a.length;t<r;t++){let r=a[t],i=r.name+`_`+r.smooth+`_`+c,l=n.materials[i];if(this.materials!==null){if(l=this.materials.create(r.name),o&&l&&!(l instanceof e.LineBasicMaterial)){let t=new e.LineBasicMaterial;e.Material.prototype.copy.call(t,l),t.color.copy(l.color),l=t}else if(s&&l&&!(l instanceof e.PointsMaterial)){let t=new e.PointsMaterial({size:10,sizeAttenuation:!1});e.Material.prototype.copy.call(t,l),t.color.copy(l.color),t.map=l.map,l=t}}l===void 0&&(l=o?new e.LineBasicMaterial:s?new e.PointsMaterial({size:1,sizeAttenuation:!1}):new e.MeshPhongMaterial,l.name=r.name,l.flatShading=!r.smooth,l.vertexColors=c,n.materials[i]=l),d.push(l)}let f;if(d.length>1){for(let e=0,t=a.length;e<t;e++){let t=a[e];u.addGroup(t.groupStart,t.groupCount,e)}f=o?new e.LineSegments(u,d):s?new e.Points(u,d):new e.Mesh(u,d)}else f=o?new e.LineSegments(u,d[0]):s?new e.Points(u,d[0]):new e.Mesh(u,d[0]);f.name=r.name,l.add(f)}else if(n.vertices.length>0){let t=new e.PointsMaterial({size:1,sizeAttenuation:!1}),r=new e.BufferGeometry;r.setAttribute(`position`,new e.Float32BufferAttribute(n.vertices,3)),n.colors.length>0&&n.colors[0]!==void 0&&(r.setAttribute(`color`,new e.Float32BufferAttribute(n.colors,3)),t.vertexColors=!0);let i=new e.Points(r,t);l.add(i)}return l}},mn=e.FileLoader,hn=e=>{let t=(e,t)=>{e.metadata.number_of_vertices+=t.metadata.number_of_vertices,`labels`in e&&e.labels.push(...e.labels),[`axis1`,`axis2`,`axis3`,`colors`,`positions`,`scale`].forEach(n=>{n in e&&Object.keys(e[n]).forEach(r=>{let i=t[n][r].length;for(let a=0;a<i;a++)e[n][r].push(t[n][r][a])})})};if(e&&e.length>0)for(;e.length>1;){let n=e.splice(1,1);t(e[0],n[0])}},gn=e=>{let t=(e,t)=>{e.merge(t)};if(e&&e.length>0){for(;e.length>1;){let n=e.splice(1,1);t(e[0],n[0])}return e[0]}},_n=function(e,t,n){let r=new mn,i=new Le;r.crossOrigin=t;let a=e,o=n,s,c=!1,l=!1,u,d=[],f=e=>{let t=s[e.index];if(t){if(`GlyphGeometriesURL`in t)e.onLoad(t);else{let n=i.parse(t);e.onLoad(n.geometry,n.materials)}}else p(e,{responseURL:a})},p=e=>{e.onError&&(u||={responseURL:a},e.onError(u))};this.downloadCompleted=e=>{try{s=JSON.parse(e[0]),c=!1,l=!0,Array.isArray(s)?d.forEach(e=>f(e)):d.forEach(e=>p(e))}catch{d.forEach(e=>p(e))}};let m=()=>e=>{u=e,l=!0,c=!1,d.forEach(e=>{p(e)})},h=()=>e=>{d.forEach(t=>{t.onProgress&&t.onProgress(e)})};this.load=(e,t,n,i)=>{let g={index:e,onLoad:t,onProgress:n,onError:i};l?s?f(g):p(u):c?d.push(g):(d.push(g),c=!0,r.load(a,o,h,m))}},vn=function(e,t,n){let r=[],i=e,a=t,o=0,s=n.isGlyphsets;this.itemDownloaded=(e,t)=>{if(r[e]=t,o++,o==i&&r.length>0){if(s){let e=r.map(e=>JSON.parse(e[0]));hn(e),a(e[0])}else{let t=r[0][1],n=gn(r.map(e=>e[0]));for(let t=1;t<i;t++)r[e][0].dispose(),r[e][1].forEach(e=>e.dispose());a(n,t)}}}},yn=function(){let e=0;this.crossOrigin=`Anonymous`;let t=new Le,n=new mn;n.crossOrigin=`Anonymous`;let r=[],i={},a=(e,t,n,r,i)=>{let a=e.length,o=new vn(a,t,i),c=0;e.forEach(e=>{let a=i?{...i}:{};a.msHandler=o,a.order=c,c++,s(e,t,n,r,a)})},o=(t,n,a,o,s)=>{let l=s?{...s}:{},u=i[t];if(!u){if(20>e){let n=new c(void 0,this,l);++e,u=new _n(t,this.crossOrigin,n),i[t]=u}else r.push({url:t,onLoad:n,onProgress:a,onError:o,options:s})}u&&(l.isHandler=u,u.load(s.index,n,a,o))},s=(i,a,s,l,u)=>{if(u&&u.index!==void 0)o(i,a,s,l,u);else if(20>e){++e;let r=new c(a,this,u),o=new c(l,this,u);u.isGlyphsets?n.load(i,r,s,o):(t.crossOrigin=this.crossOrigin,t.load(i,r,s,o))}else r.push({url:i,onLoad:a,onProgress:s,onError:l,options:u})};this.load=(e,t,n,r,i)=>{Array.isArray(e)?a(e,t,n,r,i):s(e,t,n,r,i)},this.loadFromWaitingList=()=>{for(;20>e;){let e=r.shift();if(e)this.load(e.url,e.onLoad,e.onProgress,e.onError,e.options);else return}},this.itemRemainingCheck=()=>{if(r.length===0&&e===0)for(let e in i)i.hasOwnProperty(e)&&delete i[e]};let c=function(t,n,r){return(...i)=>{--e,r?.msHandler?r.msHandler.itemDownloaded(r.order,i):r?.isHandler?r.isHandler.downloadCompleted(i):t&&t(...i),n.loadFromWaitingList(),n.itemRemainingCheck()}};this.parse=e=>loader.parse(e)},bn=class extends e.Loader{constructor(e){super(e)}load(t,n,r,i){let a=this,o=new e.FileLoader(this.manager);o.setPath(this.path),o.setResponseType(`arraybuffer`),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(t,function(e){try{n(a.parse(e))}catch(e){i?i(e):console.error(e),a.manager.itemError(t)}},r,i)}parse(t){function n(e){let t=new DataView(e);if(84+t.getUint32(80,!0)*50===t.byteLength)return!0;let n=[115,111,108,105,100];for(let e=0;e<5;e++)if(r(n,t,e))return!1;return!0}function r(e,t,n){for(let r=0,i=e.length;r<i;r++)if(e[r]!==t.getUint8(n+r,!1))return!1;return!0}function i(t){let n=new DataView(t),r=n.getUint32(80,!0),i,a,o,s=!1,c,l,u,d,f;for(let e=0;e<70;e++)n.getUint32(e,!1)==1129270351&&n.getUint8(e+4)==82&&n.getUint8(e+5)==61&&(s=!0,c=new Float32Array(r*3*3),l=n.getUint8(e+6)/255,u=n.getUint8(e+7)/255,d=n.getUint8(e+8)/255,f=n.getUint8(e+9)/255);let p=new e.BufferGeometry,m=new Float32Array(r*3*3),h=new Float32Array(r*3*3);for(let e=0;e<r;e++){let t=84+e*50,r=n.getFloat32(t,!0),f=n.getFloat32(t+4,!0),p=n.getFloat32(t+8,!0);if(s){let e=n.getUint16(t+48,!0);e&32768?(i=l,a=u,o=d):(i=(e&31)/31,a=(e>>5&31)/31,o=(e>>10&31)/31)}for(let l=1;l<=3;l++){let u=t+l*12,d=e*3*3+(l-1)*3;m[d]=n.getFloat32(u,!0),m[d+1]=n.getFloat32(u+4,!0),m[d+2]=n.getFloat32(u+8,!0),h[d]=r,h[d+1]=f,h[d+2]=p,s&&(c[d]=i,c[d+1]=a,c[d+2]=o)}}return p.setAttribute(`position`,new e.BufferAttribute(m,3)),p.setAttribute(`normal`,new e.BufferAttribute(h,3)),s&&(p.setAttribute(`color`,new e.BufferAttribute(c,3)),p.hasColors=!0,p.alpha=f),p}function a(t){let n=new e.BufferGeometry,r=/solid([\s\S]*?)endsolid/g,i=/facet([\s\S]*?)endfacet/g,a=0,o=`[\\s]+([+-]?(?:\\d*)(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)`,s=RegExp(`vertex`+o+o+o,`g`),c=RegExp(`normal`+o+o+o,`g`),l=[],u=[],d=new e.Vector3,f,p=0,m=0,h=0;for(;(f=r.exec(t))!==null;){m=h;let e=f[0];for(;(f=i.exec(e))!==null;){let e=0,t=0,n=f[0];for(;(f=c.exec(n))!==null;)d.x=parseFloat(f[1]),d.y=parseFloat(f[2]),d.z=parseFloat(f[3]),t++;for(;(f=s.exec(n))!==null;)l.push(parseFloat(f[1]),parseFloat(f[2]),parseFloat(f[3])),u.push(d.x,d.y,d.z),e++,h++;t!==1&&console.error(`THREE.STLLoader: Something isn't right with the normal of face number `+a),e!==3&&console.error(`THREE.STLLoader: Something isn't right with the vertices of face number `+a),a++}let t=m,r=h-m;n.addGroup(t,r,p),p++}return n.setAttribute(`position`,new e.Float32BufferAttribute(l,3)),n.setAttribute(`normal`,new e.Float32BufferAttribute(u,3)),n}function o(t){return typeof t==`string`?t:e.LoaderUtils.decodeText(new Uint8Array(t))}function s(e){if(typeof e==`string`){let t=new Uint8Array(e.length);for(let n=0;n<e.length;n++)t[n]=e.charCodeAt(n)&255;return t.buffer||t}return e}let c=s(t);return n(c)?i(c):a(o(t))}},xn=function(){B.call(this),this.isTubeLines=!0;let t={},n={radius:1,radialSegments:8,smooth:!1};this.createLineSegment=(n,i,a)=>{if(n&&i){t={geometryIn:n,materialIn:i,options:a};let o=r(n.vertices),s=new e.MeshStandardMaterial({color:i.color}),c=new e.Mesh(o,s);this.setMesh(c,a.localTimeEnabled,a.localMorphColour)}},this.setWidth=e=>{this.morph&&this.morph.material&&(this.morph.material.linewidth=e,this.morph.material.needsUpdate=!0)},this.setAlpha=function(e){let t=this.getMorph();t.material.opacity=e,t.material.transparent=e<1,t.material.depthWrite=e>.5},this.setWireframe=e=>{let t=this.getMorph();t.material.wireframe=e},this.setTubeLines=(e,i)=>{if(e&&i){let{geometryIn:a}=t,o=this.getMorph();o.geometry.dispose(),n=Object.assign(n,{radius:e,radialSegments:i}),o.geometry=r(a.vertices)}};let r=t=>{let{radius:r,radialSegments:i,smooth:a}=n,o;if(a){let n=new e.CatmullRomCurve3(t);o=new e.TubeGeometry(n,t.length,r,i,!1)}else{let n=[];for(let a=0;a+1<t.length;a+=2){let o=new e.LineCurve3(t[a],t[a+1]),s=new e.TubeGeometry(o,1,r,i,!1);n.push(s)}o=M(n,!0),n.forEach(e=>e.dispose())}return o}};xn.prototype=Object.create(B.prototype);var Sn=function(t){let n=t;this.toBeDownloaded=0,this.progressMap={};let r=!1,i=!1,a=new yn;this.getDownloadProgress=()=>{let e=0,t=0,n=!1;for(let r in this.progressMap){let i=this.progressMap[r];e+=i[1],t+=i[0],i[1]==0&&(n=!0)}return n&&(e=0),[e,t,i]},this.onProgress=e=>t=>{this.progressMap[e]=[t.loaded,t.total]},this.onError=e=>t=>{--this.toBeDownloaded,i=!0,console.error(`There is an issue with external resource ${t?.responseURL?`: `+t?.responseURL:``}.`),e&&e({type:`Error`,xhr:t})};let o=(e,t)=>{let i=t.Default;if(t.Inline)n.setupMultipleViews(i,t.Entries);else{let a=[];for(let[n,r]of Object.entries(t.Entries))if(e){let t=C(r,e);a.push(new Promise((e,r)=>{fetch(t).then(e=>e.json()).then(t=>e({key:n,data:t})).catch(e=>r(e))}))}Promise.all(a).then(e=>{let t={};e.forEach(e=>{t[e.key]=e.data}),n.setupMultipleViews(i,t);let a=n.getZincCameraControls();a&&a.setCurrentViewport(i),r=!0})}};this.loadViewURL=(e,t)=>{this.toBeDownloaded+=1;let i=e;fetch(i).then(e=>{if(!e.ok)throw Error(`HTTP error! status: ${e.status}`);return e.json()}).then(e=>{n.setupMultipleViews(`default`,{default:e}),n.resetView(),r=!0,--this.toBeDownloaded,t!==void 0&&typeof t==`function`&&t()}).catch(e=>{console.error(`Fetch failed for URL: ${i}`,e),this.onError(t)({responseURL:i})})},this.loadModelsURL=(e,t,n,r,i,o,s)=>{let c=t.length;this.toBeDownloaded+=c;for(let l=0;l<c;l++){let c=t[l],u=$.defaultMaterialColor,d=$.defaultOpacity;n!=null&&n[l]!=null&&(u=!!n[l]),r!=null&&r[l]!=null&&(d=r[l]);let f=0;i!=null&&i[l]!=null&&(f=!!i[l]);let p=0;o!=null&&o[l]!=null&&(p=!!o[l]),a.load(c,m(e,u,d,f,p,void 0,void 0,void 0,void 0,s),this.onProgress(c),this.onError(s))}},this.loadFromViewURL=(e,t,r)=>{let i=t+`_view.json`;fetch(i).then(e=>{if(!e.ok)throw Error(`HTTP error! status: ${e.status}`);return e.json()}).then(i=>{n.loadView(i);let a=[],o=t+`_`;for(let e=0;e<i.numberOfResources;e++){let t=o+(e+1)+`.json`;a.push(t)}this.loadModelsURL(e,a,i.colour,i.opacity,i.timeEnabled,i.morphColour,r)}).catch(e=>{console.error(`Failed to load view data from: ${i}`,e)})};let s=(t,r,i,o,s,c,l,u,d)=>(f,p)=>{let m=u?new xn:new Ye,h;p&&p[0]&&(h=new e.LineBasicMaterial({color:p[0].color.clone()}),1>p[0].opacity&&(h.transparent=!0),h.opacity=p[0].opacity,h.morphTargets=r,h.vertexColors=p[0].vertexColors);let g={};if(g.localTimeEnabled=r,g.localMorphColour=i,m&&(m.createLineSegment(f,h,g),m.setName(o),m.setAnatomicalId(s),m.setRenderOrder(c),t.addZincObject(m),m.setDuration(n.getDuration()),l&&l.levels))for(let[e,t]of Object.entries(l.levels))m.addLOD(a,e,t.URL,t.Index,l.preload);--this.toBeDownloaded,f.dispose(),d!=null&&typeof d==`function`&&d(m)};this.loadLinesURL=(e,t,n,r,i,o,c)=>{let l=0;this.toBeDownloaded+=1;let u=c?.isInline?c.isInline:!1,d=c?.anatomicalId?c.anatomicalId:void 0,f=c&&`renderOrder`in c?c.renderOrder:void 0;n!=null&&(l=!!n);let p=0;r!=null&&(p=!!r);let m=c.tubeLines&&!l&&!p;if(u){let n=a.parse(t);s(e,l,p,i,d,f,c.lod,m,o)(n.geometry,n.materials)}else a.load(t,s(e,l,p,i,d,f,c.lod,m,o),this.onProgress(t),this.onError(o),c.loaderOptions)};let c=(e,t,r,i,a)=>o=>{let s=o;(typeof s==`string`||s instanceof String)&&(s=JSON.parse(o));let c=a&&a.isInline?a.isInline:void 0,l=a&&a.anatomicalId?a.anatomicalId:void 0,u=!a?.displayLabels||a.displayLabels,d=a&&`renderOrder`in a?a.renderOrder:void 0,f=new Re;f.setDuration(n.getDuration()),f.groupName=r,++this.toBeDownloaded,f.load(s,t,()=>{--this.toBeDownloaded,i!=null&&typeof i==`function`&&i(f)},c,u),f.setAnatomicalId(l),f.setRenderOrder(d),e.addZincObject(f)};this.loadGlyphsetURL=(e,t,n,r,i,o)=>{o&&o.isInline&&o.isInline?c(e,n,r,i,o)(t):a.load(t,c(e,n,r,i,o),this.onProgress(t),this.onError(i),o.loaderOptions)};let l=(t,r,i,a,o,s,c)=>(l,u)=>{let d=new Je,f=new e.PointsMaterial({alphaTest:.5,size:10,sizeAttenuation:!1});u&&u[0]&&(1>u[0].opacity&&(f.transparent=!0),f.opacity=u[0].opacity,f.color=u[0].color,f.morphTargets=r,f.vertexColors=u[0].vertexColors);let p={};p.localTimeEnabled=r,p.localMorphColour=i,d&&(d.createMesh(l,f,p),d.setName(a),d.setAnatomicalId(o),t.addZincObject(d),d.setDuration(n.getDuration()),d.setRenderOrder(s)),l.dispose(),--this.toBeDownloaded,c!=null&&typeof c==`function`&&c(d)};this.loadSTL=(e,t,n,r)=>{this.toBeDownloaded+=1;let i=$.defaultMaterialColor,a=$.defaultOpacity,o=new bn;o.crossOrigin=`Anonymous`,o.load(t,m(e,i,a,!1,!1,n,void 0,void 0,void 0,r))},this.loadOBJ=(e,t,n,r)=>{this.toBeDownloaded+=1;let i=$.defaultMaterialColor,a=$.defaultOpacity,o=new pn;o.crossOrigin=`Anonymous`,o.load(t,m(e,i,a,!1,!1,n,void 0,void 0,void 0,r))};let u=(e,t,n,r,i,o,s)=>{this.toBeDownloaded+=1;let c=$.defaultMaterialColor,l=$.defaultOpacity,u=0,d=s&&s.isInline?s.isInline:!1,f=s&&s.fileFormat?s.fileFormat:void 0,p=s&&s.anatomicalId?s.anatomicalId:void 0,h=s&&`renderOrder`in s?s.renderOrder:void 0;n!=null&&(u=!!n);let g=0;r!=null&&(g=!!r);let _=a;if(f!==void 0){if(f==`STL`)_=new bn;else if(f==`OBJ`){_=new pn,_.crossOrigin=`Anonymous`,_.load(t,objloader(e,c,l,u,g,i,p,o),this.onProgress(t),this.onError,s.loaderOptions);return}}if(d){let n=a.parse(t);m(e,c,l,u,g,i,p,h,s,o)(n.geometry,n.materials)}else _.crossOrigin=`Anonymous`,a.load(t,m(e,c,l,u,g,i,p,h,s,o),this.onProgress(t),this.onError(o),s.loaderOptions)},d=function(e,t,i){let a=0;return o=>{if(a+=1,o&&t!=null&&typeof t==`function`&&t(o),a==e&&(r===!1&&n.viewAll(),i!=null&&typeof i==`function`)){i();let e=n.getZincCameraControls();e&&e.calculateMaxAllowedDistance(n)}}};this.loadPointsetURL=(e,t,n,r,i,o,s)=>{let c=0;this.toBeDownloaded+=1,n!=null&&(c=!!n);let u=0;r!=null&&(u=!!r);let d=s&&s.isInline?s.isInline:!1,f=s&&s.anatomicalId?s.anatomicalId:void 0,p=s&&`renderOrder`in s?s.renderOrder:void 0;if(d){let n=a.parse(t);l(e,c,u,i,f,p,o)(n.geometry,n.materials)}else a.load(t,l(e,c,u,i,f,p,o),this.onProgress(t),this.onError(o),s.loaderOptions)};let f=(e,t,n,r,i,a)=>{let o=a&&a.isInline?a.isInline:void 0,s=a&&a.anatomicalId?a.anatomicalId:void 0,c=a&&`renderOrder`in a?a.renderOrder:void 0,l;if(n){if(t&&n.images&&n.images.source){let e=n.images.source;for(let r=0;r<e.length;r++){let i=C(e[r],t);n.images.source[r]=i}}n.type===`slides`&&(l=new rt),l&&(l.groupName=r,++this.toBeDownloaded,l.load(n,()=>{e.addZincObject(l),--this.toBeDownloaded,i!=null&&typeof i==`function`&&i(l)},o),l.setAnatomicalId(s),l.setRenderOrder(c))}};this.loadTextureURL=(e,t,n,r,i)=>{if(i&&i.isInline&&i.isInline)f(e,void 0,t,n,r,i);else{let a=t;fetch(a).then(e=>{if(!e.ok)throw Error(`HTTP error! status: ${e.status}`);let t=e.url||new URL(a).href;return e.json().then(e=>({textureData:e,referenceURL:t}))}).then(({textureData:t,referenceURL:a})=>{f(e,a,t,n,r,i)}).catch(e=>{console.error(`Fetch failed for texture URL: ${a}`,e)})}};let p=(e,t,r,i,a,o,s,c,l,u,d)=>{let f={};f.colour=r,f.opacity=i,f.localTimeEnabled=a,f.localMorphColour=o;let p=new Ce;if(p.createMesh(t,c,f),p.getMorph())return p.setName(l),p.setRenderOrder(u),p.setAnatomicalId(d),e&&e.addZincObject(p),p.setDuration(n.getDuration()),s!=null&&typeof s==`function`&&s(p),p.videoHandler&&n.setVideoHandler(p.videoHandler),p},m=(e,t,n,r,i,o,s,c,l,u)=>(d,f)=>{let m;f&&f[0]&&(m=f[0]);let h=p(e,d,t,n,r,i,void 0,m,o,c,s);if(l.lod&&l.lod.levels)for(let[e,t]of Object.entries(l.lod.levels))h.addLOD(a,e,t.URL,t.Index,l.lod.preload);--this.toBeDownloaded,d.dispose(),u!=null&&typeof u==`function`&&u(h)},h=e=>{let[,t,n,r,i,a,o,s]=e.match(/P(?:(\d+)Y)?(?:(\d+)M)?(?:(\d+)W)?(?:(\d+)D)?(?:T(?:(\d+)H)?(?:(\d+)M)?(?:(\d+)S)?)?$/);return{years:t,months:n,weeks:r,days:i,hours:a,mins:o,secs:s}};this.loadSettings=e=>{if(e){if(e.Duration){let t=h(e.Duration);n.setDurationFromObject(t)}if(e.OriginalDuration){let t=h(e.OriginalDuration);n.setOriginalDurationFromObject(t)}if(e.TimeStamps)for(let t in e.TimeStamps){let r=h(e.TimeStamps[t]);n.addMetadataTimeStamp(t,r)}}};let g=(e,t,n,r,i)=>{if(n){let a,o=!1;n.URL?(a=n.URL,t&&(a=C(a,t))):n.Inline&&(a=n.Inline.URL,o=!0);let s={};if(n.LOD&&n.LOD.Levels){s.preload=!!n.LOD.Preload,s.levels={};for(let[e,r]of Object.entries(n.LOD.Levels))s.levels[e]={},s.levels[e].URL=C(r.URL,t),s.levels[e].Index=r.Index}let c=n.GroupName;(c===void 0||c===``)&&(c=`_Unnamed`);let l={loaderOptions:{index:n.Index},isInline:o,fileFormat:n.FileFormat,anatomicalId:n.AnatomicalId,compression:n.compression,tubeLines:n.tubeLines,lod:s,renderOrder:r};switch(n.Type){case`Surfaces`:u(e,a,n.MorphVertices,n.MorphColours,c,i,l);break;case`Glyph`:let r;o?r=n.Inline.GlyphGeometriesURL:(r=n.GlyphGeometriesURL,r=C(n.GlyphGeometriesURL,t)),l.displayLabels=!n.displayLabels||n.displayLabels,l.loaderOptions.isGlyphsets=!0,this.loadGlyphsetURL(e,a,r,c,i,l);break;case`Points`:this.loadPointsetURL(e,a,n.MorphVertices,n.MorphColours,c,i,l);break;case`Lines`:this.loadLinesURL(e,a,n.MorphVertices,n.MorphColours,c,i,l);break;case`Texture`:this.loadTextureURL(e,a,c,i,l)}}},_=(e,t,i)=>{if(t){let a,o=!1;switch(t.URL?(a=t.URL,e&&(a=C(t.URL,e))):t.Inline&&(a=t.Inline.URL,o=!0),t.Type){case`View`:o?(n.setupMultipleViews(`default`,{default:a}),r=!0,i!=null&&typeof i==`function`&&i()):this.loadViewURL(a,i);break;case`Settings`:this.loadSettings(t)}}};this.loadGLTF=(e,t,r,i,a)=>{new nn().load(n,e,t,r,i,a)};let v=(e,t,n,r)=>{if(n.Primitives&&n.Primitives.forEach(n=>{let i=1;n.Order&&(i=n.Order),g(e,t,n,i,r)}),n.Transformation&&e.setTransformation(n.Transformation),n.Children)for(let[i,a]of Object.entries(n.Children)){let n=e.findOrCreateChildFromPath(i);n&&v(n,t,a,r)}},y=(e,t)=>{let n=e,r=t?.enabled?.include,i=t?.enabled?.exclude,a=t?.tubeLines;return(r?.length||i?.length)&&(r&&(n=e.filter(e=>{if(e.Type===`View`)return!0;for(let t=0;t<r.length;t++)if(I(e.RegionPath,e.GroupName,r[t]))return!0;return!1})),i&&(n=n.filter(e=>{if(e.Type===`View`)return!0;for(let t=0;t<i.length;t++)if(I(e.RegionPath,e.GroupName,i[t]))return!1;return!0}))),a&&n.forEach(e=>{e.Type===`Lines`&&(e.tubeLines=!0)}),n},b=(e,t)=>Array.isArray(e)?y(e,t):e,x=(e,t)=>{if(Array.isArray(e)){let n=0;for(let r=0;r<e.length;r++)e[r].Type&&(t&&e[r].Type===`View`||e[r].Type===`Surfaces`||e[r].Type===`Glyph`||e[r].Type===`Points`||e[r].Type===`Lines`||e[r].Type===`Texture`)&&n++;return n}return 0},S=e=>{let t=e.Primitives?x(e.Primitives,!1):0;return e.Children&&Object.values(e.Children).forEach(e=>{t+=S(e)}),t},w=e=>{if(Array.isArray(e))return x(e,!0);if(typeof e==`object`&&e&&e.Version===`2.0`)return S(e.Regions)},T=(e,t,n,r,i)=>{let a=e;n.RegionPath&&n.RegionPath!==``&&(a=e.findOrCreateChildFromPath(n.RegionPath)),g(a,t,n,r*2,i)},E=(e,t,n,r,i,a)=>{let o=b(t,a),s=w(o),c=new d(s,r,i);for(let e=0;e<t.length;e++)_(n,o[e],c);for(let r=0;r<t.length;r++)T(e,n,o[r],r,c)},D=(e,t,n,r,i)=>{let a=w(t),s=new d(a,r,i);t.Settings&&this.loadSettings(t.Settings),t.Views&&o(n,t.Views,n),t.Regions&&v(e,n,t.Regions,s)};this.loadMetadataURL=(e,t,i,a,o)=>{let s=t;fetch(s).then(e=>{if(!e.ok)throw Error(`HTTP error! status: ${e.status}`);let t=e.url||new URL(s).href;return e.json().then(e=>({metadata:e,referenceURL:t}))}).then(({metadata:t,referenceURL:s})=>{n.resetMetadata(),n.resetDuration(),r=!1,Array.isArray(t)?E(e,t,s,i,a,o):typeof t==`object`&&t&&t.Version===`2.0`&&D(e,t,s,i,a)}).catch(e=>{console.error(`Fetch failed for URL: ${s}`,e)})}},Cn=0,wn=function(){return`sc`+Cn++},Tn=function(){return{Duration:`6 secs`,OriginalDuration:`-`,TimeStamps:{}}},En=6e3,Dn=function(t,n){let r=t,i,a,o=new Sn(this),s,c={},l=0,u={},d=0,f=new e.Scene,p=new e.Scene,m=new Ft(void 0,this);f.add(m.getGroup());let h=new e.Group;f.add(h),this.directionalLight=void 0,this.ambient=void 0,this.camera=void 0;let g=6e3,_;this.sceneName=void 0;let v=!1,y;this.autoClearFlag=!0,this.displayMarkers=!1,this.displayMinimap=!1,this.displayMiniAxes=!1,this.minimapScissor={x_offset:16,y_offset:16,width:128,height:128,align:`top-right`,updateRequired:!0};let b={x:0,y:0},x=Tn(),S=new e.Vector2,C=[];this.forcePickableObjectsUpdate=!1,this.uuid=wn();let w=new yt(this);w.disable(),f.add(w.group);let T={main:[],mini:[]},E=new e.Vector3(0,0,0),D=()=>r?r.clientWidth===void 0?r.width:r.clientWidth:0,O=()=>r?r.clientHeight===void 0?r.height:r.clientHeight:0;this.getDownloadProgress=()=>o.getDownloadProgress(),this.onWindowResize=()=>{let e=O();this.camera.aspect=D()/e,this.camera.updateProjectionMatrix(),this.minimapScissor.updateRequired=!0,_.onResize(),_.calculateHeightPerPixelAtZeroDepth(e)},this.resetView=()=>{this.onWindowResize(),_.resetView()},this.changeZoomByScrollRateUnit=e=>{_.changeZoomByScrollRateUnit(e)},this.camera=new e.PerspectiveCamera(40,D()/O(),0,10),this.ambient=new e.AmbientLight(16777215,.2),f.add(this.ambient),this.directionalLight=new e.DirectionalLight(16777215,.8),f.add(this.directionalLight),_=new at(this.camera,n.domElement,n,this),_.setDirectionalLight(this.directionalLight),_.resetView(),s=new bt(this),this.loadView=e=>{let t=new it;return t.setFromObject(e),_.setCurrentCameraSettings(t),!0},this.setupMultipleViews=(e,t)=>{for(let[e,n]of Object.entries(t)){let t=new it;t.setFromObject(n),_.addViewport(e,t)}_.setDefaultViewport(e)},this.getBoundingBox=()=>m.getBoundingBox(!0),this.viewAllWithBoundingBox=e=>{if(e){let t=_.getViewportFromBoundingBox(e,1);_.setCurrentCameraSettings(t),_.calculateHeightPerPixelAtZeroDepth(O()),w.markerUpdateRequired=!0}},this.viewAll=()=>{let e=this.getBoundingBox();this.viewAllWithBoundingBox(e),w.markerUpdateRequired=!0},this.forEachGeometry=e=>{m.forEachGeometry(e,!0)},this.forEachGlyphset=e=>{m.forEachGlyphset(e,!0)},this.forEachPointset=e=>{m.forEachPointset(e,!0)},this.forEachLine=e=>{m.forEachLine(e,!0)},this.findGeometriesWithGroupName=e=>m.findGeometriesWithGroupName(e,!0),this.findPointsetsWithGroupName=e=>m.findPointsetsWithGroupName(e,!0),this.findGlyphsetsWithGroupName=e=>m.findGlyphsetsWithGroupName(e,!0),this.findLinesWithGroupName=e=>m.findLinesWithGroupName(e,!0),this.findObjectsWithGroupName=e=>m.findObjectsWithGroupName(e,!0),this.findObjectsWithAnatomicalId=e=>m.findObjectsWithAnatomicalId(e,!0),this.getBoundingBoxOfZincObjects=e=>{let t;for(let n=0;n<e.length;n++){let r=e[n].getBoundingBox();r&&(t?t.union(r):t=r)}return t},this.vectorToScreenXY=e=>{e.project(this.camera);let t=D(),n=O(),r=t/2,i=n/2;return e.x=e.x*r+r,e.y=-(e.y*i)+i,e},this.getObjectsScreenXY=t=>{if(t&&t.length>0){let n=this.getBoundingBoxOfZincObjects(t),r=new e.Vector3;return n.getCenter(r),this.vectorToScreenXY(r)}},this.getNamedObjectsScreenXY=e=>{let t=this.findObjectsWithGroupName(e);return this.getObjectsScreenXY(t)},this.addZincObject=e=>{e&&(m.addZincObject(e),_&&_.calculateMaxAllowedDistance(this))},this.loadGlyphsetURL=(e,t,n,r)=>{o.loadGlyphsetURL(m,e,t,n,r)},this.loadPointsetURL=(e,t,n,r,i)=>{o.loadPointsetURL(m,e,t,n,r,i)},this.loadLinesURL=(e,t,n,r,i)=>{o.loadLinesURL(m,e,t,n,r,i)},this.loadSTL=(e,t,n)=>{o.loadSTL(m,e,t,n)},this.loadOBJ=(e,t,n)=>{o.loadOBJ(m,e,t,n)},this.loadMetadataURL=(e,t,n,r)=>{o.loadMetadataURL(m,e,t,n,r)},this.loadModelsURL=(e,t,n,r,i,a)=>{o.loadModelsURL(m.urls,t,n,r,i,a)},this.loadViewURL=e=>{o.loadViewURL(e)},this.loadFromViewURL=(e,t)=>{o.loadFromViewURL(e,t)},this.loadGLTF=(e,t,n,r)=>{o.loadGLTF(m,e,t,n,r)},this.updateDirectionalLight=()=>{_.updateDirectionalLight()},this.addObject=e=>{f.add(e)},this.removeObject=e=>{f.remove(e)},this.getCurrentTime=()=>{if(a!=null)return a.getCurrentTime(g);let e=m.getCurrentTime();return e===-1?0:e},this.setMorphsTime=e=>{a?.setMorphTime(e,g),m.setMorphTime(e,!0)},this.isTimeVarying=()=>a&&a.video&&!a.video.error?!0:m.isTimeVarying(),this.renderGeometries=(e,t,n)=>{let r={};if(r.camera=_,r.displayMarkers=this.displayMarkers,r.markerCluster=w,r.markersList=w.markers,r.ndcToBeUpdated=!1,n&&(r.markerCluster.markerUpdateRequired=!0),a){if(a.isReadyToPlay()){n?a.video.play():a.video.pause();let e=a.video.currentTime/a.getVideoDuration()*g;o.toBeDownloaded==0?(_.setTime(e),r.ndcToBeUpdated=_.update(0),r.ndcToBeUpdated&&_.calculateHeightPerPixelAtZeroDepth(O()),m.setMorphTime(e,!0),m.renderGeometries(0,0,n,_,r,!0)):_.update(0)}else myPlayRate=0}else o.toBeDownloaded==0?(r.ndcToBeUpdated=_.update(t),r.ndcToBeUpdated&&_.calculateHeightPerPixelAtZeroDepth(O()),m.renderGeometries(e,t,n,_,r,!0)):_.update(0)},this.getThreeJSScene=()=>f,this.setVideoHandler=e=>{a||=e},this.setAdditionalScenesGroup=e=>{f.add(e)};let k=(e,t,n,r,i,a,o)=>{let s=0,c=0;return c=e.includes(`top`)?o-i-n:e.includes(`bottom`)?n:Math.floor((o-i)/2),s=e.includes(`left`)?t:e.includes(`right`)?a-t-r:Math.floor((a-r)/2),{x:s,y:c}},A=e=>{(this.displayMinimap||this.displayMiniAxes)&&(e.setScissorTest(!0),e.getSize(S),this.minimapScissor.updateRequired&&(b=k(this.minimapScissor.align,this.minimapScissor.x_offset,this.minimapScissor.y_offset,this.minimapScissor.width,this.minimapScissor.height,S.x,S.y),this.minimapScissor.updateRequired=!1),e.setScissor(b.x,b.y,this.minimapScissor.width,this.minimapScissor.height),e.setViewport(b.x,b.y,this.minimapScissor.width,this.minimapScissor.height),s.updateCamera(),this.displayMiniAxes?e.render(p,s.camera):(f.add(s.mask),e.render(f,s.camera),f.remove(s.mask)),e.setScissorTest(!1),e.setViewport(0,0,S.x,S.y))};this.render=e=>{this.autoClearFlag&&e.clear(),v&&y?y.render(f,this.camera):(e.render(f,this.camera),A(e))},this.setInteractiveControlEnable=e=>{e==1?_.enable():_.disable()},this.getZincCameraControls=()=>_,this.getThreeJSScene=()=>f,this.setDuration=e=>{m.setDuration(e),g=e,_.setPathDuration(e),o.duration=e},this.getDuration=()=>g,this.setStereoEffectEnable=e=>{e==1&&(y||=new dt(n)),n.setSize(D(),O()),this.camera.updateProjectionMatrix(),v=e},this.objectIsInScene=e=>m.objectIsInRegion(e,!0),this.alignBoundingBoxToCameraView=(t,n)=>{if(t){t.getCenter(E);let r=this.getZincCameraControls().getCurrentViewport(),i=new e.Vector3(r.targetPosition[0],r.targetPosition[1],r.targetPosition[2]),a=new e.Vector3(r.eyePosition[0],r.eyePosition[1],r.eyePosition[2]),o=new e.Vector3,s=new e.Vector3;o.subVectors(i,a).normalize(),s.subVectors(i,E).normalize();let c=new e.Vector3;c.crossVectors(o,s);let l=o.angleTo(s);n>0?(this.getZincCameraControls().rotateCameraTransition(c,l,n),this.getZincCameraControls().enableCameraTransition()):this.getZincCameraControls().rotateAboutLookAtpoint(c,l),w.markerUpdateRequired=!0}},this.translateBoundingBoxToCameraView=(e,t,n)=>{if(e){let r=this.getZincCameraControls().getCurrentViewport(),i=this.getZincCameraControls().getViewportFromBoundingBox(e,t);n>0&&(this.getZincCameraControls().cameraTransition(r,i,n),this.getZincCameraControls().enableCameraTransition()),w.markerUpdateRequired=!0}},this.alignObjectToCameraView=(e,t)=>{if(this.objectIsInScene(e)){let n=e.getBoundingBox();this.alignBoundingBoxToCameraView(n,t)}},this.setCameraTargetToObject=t=>{if(this.objectIsInScene(t)){let n=t.getBoundingBox(),r=this.getZincCameraControls().getCurrentViewport();n.getCenter(E);let i=new e.Vector3(r.targetPosition[0],r.targetPosition[1],r.targetPosition[2]),a=new e.Vector3(r.eyePosition[0],r.eyePosition[1],r.eyePosition[2]),o=new e.Vector3,s=new e.Vector3;o.subVectors(a,i),s.addVectors(E,o),r.eyePosition[0]=s.x,r.eyePosition[1]=s.y,r.eyePosition[2]=s.z,r.targetPosition[0]=E.x,r.targetPosition[1]=E.y,r.targetPosition[2]=E.z,this.getZincCameraControls().setCurrentCameraSettings(r),w.markerUpdateRequired=!0}},this.isStereoEffectEnable=()=>v,this.removeZincObject=e=>{m.removeZincObject(e),_&&_.calculateMaxAllowedDistance(this),w.markerUpdateRequired=!0},this.updatePickableThreeJSObjects=()=>{C.length=0,w.isEnabled&&C.push(w.group),m.getPickableThreeJSObjects(C,!0),this.forcePickableObjectsUpdate=!1},this.getPickableThreeJSObjects=()=>((this.forcePickableObjectsUpdate||m.checkPickableUpdateRequred(!0))&&this.updatePickableThreeJSObjects(),C),this.getNormalisedMinimapCoordinates=(t,n)=>{if(this.displayMinimap){let r=new e.Vector2;t.getSize(r);let i=r.y-n.clientY;if(b.x+this.minimapScissor.width>n.clientX&&n.clientX>b.x&&b.y+this.minimapScissor.height>i&&i>b.y)return{x:(n.clientX-b.x)/this.minimapScissor.width*2-1,y:(i-b.y)/this.minimapScissor.height*2-1}}},this.getMinimapDiffFromNormalised=(e,t)=>{if(s)return s.getDiffFromNormalised(e,t)},this.isWebGL2=()=>n.isWebGL2(),this.clearAll=()=>{w.clear(),m.clear(!0),this.clearZincObjectAddedCallbacks(),this.clearZincObjectRemovedCallbacks(),o.toBeDwonloaded=0,_&&_.calculateMaxAllowedDistance(this),w.markerUpdateRequired=!0},this.addMetadataTimeStamp=(e,t)=>{x.TimeStamps[e]=M(t)},this.getMetadataTag=e=>x[e],this.getMetadata=()=>x,this.setMetadataTag=(e,t)=>{x[e]=t},this.removeMetadataTag=e=>{delete x[e]},this.resetMetadata=()=>{x=Tn()},this.resetDuration=()=>{this.setDuration(En)};let j=e=>[...e.years?[`${e.years}years`]:[],...e.months?[`${e.months}months`]:[],...e.weeks?[`${e.weeks}weeks`]:[],...e.days?[`${e.days}days`]:[],...e.hours?[`${e.hours}hours`]:[],...e.mins?[`${e.mins}mins`]:[],...e.secs?[`${e.secs}secs`]:[]].join(` `),M=e=>e.years?e.years*31536e6:0+e.months?e.months*2592e6:0+e.weeks?e.weeks*6048e5:0+e.days?e.days*864e5:0+e.hours?e.hours*36e5:0+e.mins?e.mins*6e4:0+e.secs?e.secs*1e3:0;this.setDurationFromObject=e=>{let t=j(e),n=M(e);this.setMetadataTag(`Duration`,t),this.setDuration(n)},this.setOriginalDurationFromObject=e=>{let t=j(e);this.setMetadataTag(`OriginalDuration`,t)},this.exportGLTF=e=>new tn(this).exportGLTF(e),this.getRootRegion=()=>m,this.createLines=(e,t,n,r)=>{let i=m.findChildFromPath(e);return i===void 0&&(i=m.createChildFromPath(e)),i.createLines(t,n,r)},this.createPoints=(e,t,n,r,i)=>{let a=m.findChildFromPath(e);return a===void 0&&(a=m.createChildFromPath(e)),a.createPoints(t,n,r,i)},this.addZincObjectAddedCallbacks=e=>(l+=1,c[l]=e,l),this.addZincObjectRemovedCallbacks=e=>(d+=1,u[d]=e,d),this.removeZincObjectAddedCallbacks=e=>{e in l&&delete c[e]},this.removeZincObjectRemovedCallbacks=e=>{e in d&&delete u[e]},this.clearZincObjectAddedCallbacks=()=>{c={},l=0},this.clearZincObjectRemovedCallbacks=()=>{u={},d=0},this.triggerObjectAddedCallback=e=>{for(let t in c)c.hasOwnProperty(t)&&c[t](e)},this.triggerObjectRemovedCallback=e=>{for(let t in u)u.hasOwnProperty(t)&&u[t](e)},this.addTemporaryPoints=(t,n)=>{let r=N(t.length,t),i=new e.PointsMaterial({alphaTest:.5,size:15,color:n,sizeAttenuation:!1});i.map=P();let a=new Ge(r,i);return h.add(a),a},this.addTemporaryLines=(t,n)=>{let r=new pe(N(t.length,t),new e.LineBasicMaterial({color:n}));return h.add(r),r},this.enableFrustumDisplay=()=>{this.camera&&!i&&(i=new e.CameraHelper(this.camera),f.add(i))},this.disableFrustumDisplay=()=>{i&&=(f.remove(i),i.dispose(),void 0)},this.removeTemporaryPrimitive=e=>{h.remove(e),e.geometry.dispose(),e.material.dispose()},this.clearTemporaryPrimitives=()=>{let e=0;return h.children.forEach(t=>{t.geometry.dispose(),t.material.dispose(),e++}),h.clear(),e},this.addBoundingBoxPrimitive=(t,n,r,i,a,o=void 0)=>{let s=m.findChildFromPath(t);s===void 0&&(s=m.createChildFromPath(t));let c=o||this.getBoundingBox();E.set(0,0,0);let l=E.subVectors(c.max,c.min),u=new e.BoxGeometry(l.x,l.y,l.z),d=s.createGeometryFromThreeJSGeometry(n,u,r,i,a,1e4);return l.addVectors(c.min,c.max).multiplyScalar(.5),d.setPosition(l.x,l.y,l.z),d},this.addSlicesPrimitive=(t,n,r,i,a,o=void 0)=>{if(n&&n.length>=3&&r&&r.length>=3){let s=m.findChildFromPath(t);s===void 0&&(s=m.createChildFromPath(t));let c=o||this.getBoundingBox();E.set(0,0,0);let l=E.subVectors(c.max,c.min),u=[`x`,`y`,`z`],d=[],f=0;return u.forEach(t=>{let o;switch(t){case`x`:o=new e.PlaneGeometry(l.z,l.y),o.rotateY(Math.PI/2);break;case`y`:o=new e.PlaneGeometry(l.x,l.z),o.rotateX(Math.PI/2);break;case`z`:o=new e.PlaneGeometry(l.x,l.y)}let c=s.createGeometryFromThreeJSGeometry(n[f],o,r[f],i,a,10001);d.push(c),f++}),l.addVectors(c.min,c.max).multiplyScalar(.5),d.forEach(e=>{e.setPosition(l.x,l.y,l.z)}),d}},this.enableMarkerCluster=e=>{e?(w.markerUpdateRequired=!0,w.enable()):(w.markerUpdateRequired=!1,w.disable()),this.forcePickableObjectsUpdate=!0},this.destroyAxisDisplay=()=>{this.displayMiniAxes=!1,T.main&&(this.enableAxisDisplay(!1,!1),T.main.forEach(e=>{e.dispose&&e.dispose()})),T.mini&&(this.enableAxisDisplay(!1,!0),T.mini.forEach(e=>{e.dispose&&e.dispose()})),T={main:[],mini:[]}},this.createAxisDisplay=(t=!1)=>{this.destroyAxisDisplay();let n=[{name:`x`,dir:new e.Vector3(1,0,0),colour:`red`,hex:16733525},{name:`y`,dir:new e.Vector3(0,1,0),colour:`green`,hex:5635925},{name:`z`,dir:new e.Vector3(0,0,1),colour:`blue`,hex:5592575}],r=this.getBoundingBox(),i=r.min.distanceTo(r.max),a=new e.Vector3(0,0,0);t&&a.copy(r.min),n.forEach(t=>{let n=new e.ArrowHelper(t.dir,a,i,t.hex);T.main.push(n);let o=new e.ArrowHelper(t.dir,r.getCenter(E),i/2,t.hex);T.mini.push(o);let s=F(t.name,.036,t.colour,`Asap`,120,700),c=t.dir.clone().multiplyScalar(i).add(a);s.position.set(c.x,c.y,c.z),T.main.push(s)})},this.enableAxisDisplay=(e,t=!1)=>{t&&T?.mini?.length?(this.displayMiniAxes=e,T.mini.forEach(t=>{e?p.add(t):p.remove(t)})):!t&&T.main&&T.main.forEach(t=>{e?f.add(t):f.remove(t)})}},On=function(t){let r=t,i,a,o=new e.Clock(!1);this.playAnimation=!0;let s=1e3,c={},l=0,u={},d=0,f={},p=0,m={},h=0,g,_,v,y,b=[],x=[],S=new e.Group,C,w,T=!1,E=!1;this.getDrawingWidth=()=>r?r.clientWidth:C?C.clientWidth===void 0?Math.round(C.width):Math.round(C.clientWidth):0,this.getDrawingHeight=()=>r?r.clientHeight:C?C.clientHeight===void 0?Math.round(C.height):Math.round(C.clientHeight):0,this.onWindowResize=()=>{a.onWindowResize();let t=this.getDrawingWidth(),n=this.getDrawingHeight();if(i!=null){let a;r?(a=r.getBoundingClientRect(),i.setSize(t,n)):C&&(C.getBoundingClientRect===void 0?i.setSize(t,n,!1):(a=C.getBoundingClientRect(),C.width=t,C.height=n,i.setSize(t,n,!1))),a&&(a.left,a.top);let o=new e.Vector2;i.getSize(o),o.x,o.y}},this.initialiseVisualisation=t=>{if(!E){if(t||={},t.antialias===void 0){let e=!1;try{/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)&&(e=!0)}catch{e=!1}e?t.antialias=!1:t.antialias=!0}t.canvas&&(r=void 0,C=t.canvas),i=new e.WebGLRenderer(t),r!==void 0&&r.appendChild(i.domElement),i.setClearColor(16777215,1),C&&C.style&&(C.style.height=`100%`,C.style.width=`100%`);let n=i.domElement;n.addEventListener(`webglcontextlost`,D,!1),n.addEventListener(`webglcontextrestored`,O,!1),i.autoClear=!1;let a=this.createScene(`default`);this.setCurrentScene(a),E=!0}};let D=e=>{e.preventDefault();for(let e of Object.keys(c))f.hasOwnProperty(e)&&f[e].call()},O=e=>{e.preventDefault();for(let e of Object.keys(c))m.hasOwnProperty(e)&&m[e].call()};this.getCurrentScene=()=>a,this.setCurrentScene=e=>{if(e){this.removeActiveScene(e);let t=a;a=e,t&&t.setInteractiveControlEnable(!1),a.setInteractiveControlEnable(!0),a.setAdditionalScenesGroup(S),this.onWindowResize()}},this.getSceneByName=e=>b[e],this.createScene=e=>{if(b[e]==null){let t;return t=C?new Dn(C,i):new Dn(r,i),b[e]=t,t.sceneName=e,t}},this.resetView=()=>{a.resetView()},this.viewAll=()=>{if(a){let e=a.getBoundingBox();if(e){for(let t=0;t<x.length;t++){let n=x[t].getBoundingBox();n&&e.union(n)}a.viewAllWithBoundingBox(e)}}},this.loadModelsURL=(e,t,n,r,i,o)=>{a.loadModelsURL(e,t,n,r,i,o)},this.loadViewURL=e=>{a.loadViewURL(e)},this.loadFromViewURL=(e,t)=>{a.loadFromViewURL(e,t)},this.updateDirectionalLight=()=>{a.updateDirectionalLight()};let k=()=>{T?(g=requestAnimationFrame(k),this.render()):(cancelAnimationFrame(g),g=void 0)};this.stopAnimate=()=>{T&&=(o.stop(),!1)},this.animate=()=>{T||(o.start(),T=!0,k())},this.addContextLostCallbackFunction=e=>(p+=1,f[p]=e,p),this.removeContextLostCallbackFunction=e=>{e in f&&delete f[e]},this.addContextRestoredCallbackFunction=e=>(h+=1,m[h]=e,h),this.removeContextRestoredCallbackFunction=e=>{e in h&&delete h[e]},this.addPreRenderCallbackFunction=e=>(l+=1,c[l]=e,l),this.removePreRenderCallbackFunction=e=>{e in c&&delete c[e]},this.addPostRenderCallbackFunction=e=>(d+=1,u[d]=e,d),this.removePostRenderCallbackFunction=e=>{e in u&&delete u[e]},this.getPlayRate=()=>s,this.setPlayRate=e=>{s=e},this.getCurrentTime=()=>a.getCurrentTime(),this.setMorphsTime=e=>{a.setMorphsTime(e)},this.getZincGeometryByID=e=>a.getZincGeometryByID(e),this.addToScene=e=>{a.addObject(e)},this.addToOrthoScene=t=>{if(v??=new e.Scene,_==null){let t=this.getDrawingWidth(),n=this.getDrawingHeight();_=new e.OrthographicCamera(-t/2,t/2,n/2,-n/2,1,10),_.position.z=10}v.add(t)};let A=t=>n=>{n.needsUpdate=!0;let r=new e.SpriteMaterial({map:n}),i=r.map.image.width,a=r.map.image.height;t.material=r,t.scale.set(i,a,1);let o=this.getDrawingWidth(),s=this.getDrawingHeight();t.position.set((o-i)/2,(-s+a)/2,1),this.addToOrthoScene(t)};this.addLogo=()=>{y=new e.Sprite,e.ImageUtils.loadTexture(`images/abi_big_logo_transparent_small.png`,void 0,A(y))},this.render=()=>{w||(r?r.clientWidth>0&&r.clientHeight>0&&(w=new n.ResizeSensor(r,this.onWindowResize)):C&&C.width>0&&C.height>0&&(w=new n.ResizeSensor(C,this.onWindowResize)));let e=o.getDelta();a.renderGeometries(s,e,this.playAnimation);for(let t=0;t<x.length;t++)x[t].renderGeometries(s,e,this.playAnimation);_!=null&&v!=null&&(i.clearDepth(),i.render(v,_));for(let e of Object.keys(c))c.hasOwnProperty(e)&&c[e].call();a.render(i);for(let e of Object.keys(u))u.hasOwnProperty(e)&&u[e].call()},this.forceContextLoss=()=>{i.forceContextLoss()},this.forceContextRestore=()=>{i.forceContextRestore()},this.getThreeJSRenderer=()=>i,this.isSceneActive=e=>{if(a===e)return!0;for(let t=0;t<x.length;t++)if(x[t]===e)return!0;return!1},this.addActiveScene=e=>{this.isSceneActive(e)||(x.push(e),S.add(e.getThreeJSScene()))},this.removeActiveScene=e=>{for(let t=0;t<x.length;t++)if(x[t]===e){x.splice(t,1),S.remove(e.getThreeJSScene());return}},this.clearAllActiveScene=()=>{for(let e=0;e<x.length;e++)S.remove(x[e].getThreeJSScene());x.splice(0,x.length)},this.dispose=()=>{T&&cancelAnimationFrame(g);for(let e in b)b.hasOwnProperty(e)&&b[e].clearAll();b=[],x=[],S=new e.Group,this.stopAnimate(),c={},l=0,u={},u=0,f={},p=0,m={},h=0,_=void 0,v=void 0,y=void 0;let t=this.createScene(`default`);this.setCurrentScene(t),w=void 0,i?.dispose()},this.transitionScene=(e,t)=>{if(a){let n=a.getZincCameraControls(),r=e.getBoundingBox();if(r){let e=r.min.distanceTo(r.max)/2,i=(r.min.x+r.max.x)/2,a=(r.min.y+r.max.y)/2,o=(r.min.z+r.max.z)/2,s=n.getViewportFromCentreAndRadius(i,a,o,e,40,e*4),c=n.getCurrentViewport();n.cameraTransition(c,s,t),n.enableCameraTransition()}}},this.isWebGL2=()=>i?i.capabilities.isWebGL2:!1},kn=class{esize;ecode;edata;littleEndian;constructor(e,t,n,r){if(e%16!=0)throw Error(`This does not appear to be a NIFTI extension`);this.esize=e,this.ecode=t,this.edata=n,this.littleEndian=r}toArrayBuffer(){let e=new Uint8Array(this.esize),t=new Uint8Array(this.edata);e.set(t,8);let n=new DataView(e.buffer);return n.setInt32(0,this.esize,this.littleEndian),n.setInt32(4,this.ecode,this.littleEndian),e.buffer}},X=class e{static crcTable=null;static GUNZIP_MAGIC_COOKIE1=31;static GUNZIP_MAGIC_COOKIE2=139;static getStringAt(e,t,n){var r=``,i,a;for(i=t;i<n;i+=1)a=e.getUint8(i),a!==0&&(r+=String.fromCharCode(a));return r}static getByteAt=function(e,t){return e.getUint8(t)};static getShortAt=function(e,t,n){return e.getInt16(t,n)};static getIntAt(e,t,n){return e.getInt32(t,n)}static getFloatAt(e,t,n){return e.getFloat32(t,n)}static getDoubleAt(e,t,n){return e.getFloat64(t,n)}static getInt64At(e,t,n){let r=e.getUint32(t,n),i=e.getInt32(t+4,n),a;return a=n?i*2**32+r:r*2**32+i,i<0&&(a+=-1*2**32*2**32),a}static getUint64At(e,t,n){let r=e.getUint32(t+(n?0:4),n),i=e.getUint32(t+(n?4:0),n);return n?i*2**32+r:r*2**32+i}static getExtensionsAt(t,n,r,i){let a=[],o=n;for(;o<i;){let n=r,s=e.getIntAt(t,o,r);if(!s)break;if(s+o>i&&(n=!n,s=e.getIntAt(t,o,n),s+o>i))throw Error(`This does not appear to be a valid NIFTI extension`);if(s%16!=0)throw Error(`This does not appear to be a NIFTI extension`);let c=e.getIntAt(t,o+4,n),l=t.buffer.slice(o+8,o+s),u=new kn(s,c,l,n);a.push(u),o+=s}return a}static toArrayBuffer(e){var t=new ArrayBuffer(e.length),n=new Uint8Array(t),r;for(r=0;r<e.length;r+=1)n[r]=e[r];return t}static isString(e){return typeof e==`string`||e instanceof String}static formatNumber(t,n=void 0){let r;return r=e.isString(t)?Number(t):t,r=n?r.toPrecision(5):r.toPrecision(7),parseFloat(r)}static makeCRCTable(){let e,t=[];for(var n=0;n<256;n++){e=n;for(var r=0;r<8;r++)e=e&1?3988292384^e>>>1:e>>>1;t[n]=e}return t}static crc32(t){e.crcTable||=e.makeCRCTable();let n=e.crcTable,r=-1;for(var i=0;i<t.byteLength;i++)r=r>>>8^n[(r^t.getUint8(i))&255];return(r^-1)>>>0}},Z=class e{littleEndian=!1;dim_info=0;dims=[];intent_p1=0;intent_p2=0;intent_p3=0;intent_code=0;datatypeCode=0;numBitsPerVoxel=0;slice_start=0;slice_end=0;slice_code=0;pixDims=[];vox_offset=0;scl_slope=1;scl_inter=0;xyzt_units=0;cal_max=0;cal_min=0;slice_duration=0;toffset=0;description=``;aux_file=``;intent_name=``;qform_code=0;sform_code=0;quatern_a=0;quatern_b=0;quatern_c=0;quatern_d=0;qoffset_x=0;qoffset_y=0;qoffset_z=0;affine=[[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1]];qfac=1;quatern_R;magic=`0`;isHDR=!1;extensionFlag=[0,0,0,0];extensionSize=0;extensionCode=0;extensions=[];static TYPE_NONE=0;static TYPE_BINARY=1;static TYPE_UINT8=2;static TYPE_INT16=4;static TYPE_INT32=8;static TYPE_FLOAT32=16;static TYPE_COMPLEX64=32;static TYPE_FLOAT64=64;static TYPE_RGB24=128;static TYPE_INT8=256;static TYPE_UINT16=512;static TYPE_UINT32=768;static TYPE_INT64=1024;static TYPE_UINT64=1280;static TYPE_FLOAT128=1536;static TYPE_COMPLEX128=1792;static TYPE_COMPLEX256=2048;static XFORM_UNKNOWN=0;static XFORM_SCANNER_ANAT=1;static XFORM_ALIGNED_ANAT=2;static XFORM_TALAIRACH=3;static XFORM_MNI_152=4;static SPATIAL_UNITS_MASK=7;static TEMPORAL_UNITS_MASK=56;static UNITS_UNKNOWN=0;static UNITS_METER=1;static UNITS_MM=2;static UNITS_MICRON=3;static UNITS_SEC=8;static UNITS_MSEC=16;static UNITS_USEC=24;static UNITS_HZ=32;static UNITS_PPM=40;static UNITS_RADS=48;static MAGIC_COOKIE=348;static STANDARD_HEADER_SIZE=348;static MAGIC_NUMBER_LOCATION=344;static MAGIC_NUMBER=[110,43,49];static MAGIC_NUMBER2=[110,105,49];static EXTENSION_HEADER_SIZE=8;readHeader(t){var n=new DataView(t),r=X.getIntAt(n,0,this.littleEndian),i,a,o,s;if(r!==e.MAGIC_COOKIE&&(this.littleEndian=!0,r=X.getIntAt(n,0,this.littleEndian)),r!==e.MAGIC_COOKIE)throw Error(`This does not appear to be a NIFTI file!`);for(this.dim_info=X.getByteAt(n,39),i=0;i<8;i+=1)s=40+i*2,this.dims[i]=X.getShortAt(n,s,this.littleEndian);for(this.intent_p1=X.getFloatAt(n,56,this.littleEndian),this.intent_p2=X.getFloatAt(n,60,this.littleEndian),this.intent_p3=X.getFloatAt(n,64,this.littleEndian),this.intent_code=X.getShortAt(n,68,this.littleEndian),this.datatypeCode=X.getShortAt(n,70,this.littleEndian),this.numBitsPerVoxel=X.getShortAt(n,72,this.littleEndian),this.slice_start=X.getShortAt(n,74,this.littleEndian),i=0;i<8;i+=1)s=76+i*4,this.pixDims[i]=X.getFloatAt(n,s,this.littleEndian);if(this.vox_offset=X.getFloatAt(n,108,this.littleEndian),this.scl_slope=X.getFloatAt(n,112,this.littleEndian),this.scl_inter=X.getFloatAt(n,116,this.littleEndian),this.slice_end=X.getShortAt(n,120,this.littleEndian),this.slice_code=X.getByteAt(n,122),this.xyzt_units=X.getByteAt(n,123),this.cal_max=X.getFloatAt(n,124,this.littleEndian),this.cal_min=X.getFloatAt(n,128,this.littleEndian),this.slice_duration=X.getFloatAt(n,132,this.littleEndian),this.toffset=X.getFloatAt(n,136,this.littleEndian),this.description=X.getStringAt(n,148,228),this.aux_file=X.getStringAt(n,228,252),this.qform_code=X.getShortAt(n,252,this.littleEndian),this.sform_code=X.getShortAt(n,254,this.littleEndian),this.quatern_b=X.getFloatAt(n,256,this.littleEndian),this.quatern_c=X.getFloatAt(n,260,this.littleEndian),this.quatern_d=X.getFloatAt(n,264,this.littleEndian),this.quatern_a=Math.sqrt(1-(this.quatern_b**2+this.quatern_c**2+this.quatern_d**2)),this.qoffset_x=X.getFloatAt(n,268,this.littleEndian),this.qoffset_y=X.getFloatAt(n,272,this.littleEndian),this.qoffset_z=X.getFloatAt(n,276,this.littleEndian),this.qform_code<1&&this.sform_code<1&&(this.affine[0][0]=this.pixDims[1],this.affine[1][1]=this.pixDims[2],this.affine[2][2]=this.pixDims[3]),this.qform_code>0&&this.sform_code<this.qform_code){let e=this.quatern_a,t=this.quatern_b,n=this.quatern_c,r=this.quatern_d;for(this.qfac=this.pixDims[0]===0?1:this.pixDims[0],this.quatern_R=[[e*e+t*t-n*n-r*r,2*t*n-2*e*r,2*t*r+2*e*n],[2*t*n+2*e*r,e*e+n*n-t*t-r*r,2*n*r-2*e*t],[2*t*r-2*e*n,2*n*r+2*e*t,e*e+r*r-n*n-t*t]],a=0;a<3;a+=1)for(o=0;o<3;o+=1)this.affine[a][o]=this.quatern_R[a][o]*this.pixDims[o+1],o===2&&(this.affine[a][o]*=this.qfac);this.affine[0][3]=this.qoffset_x,this.affine[1][3]=this.qoffset_y,this.affine[2][3]=this.qoffset_z}else if(this.sform_code>0)for(a=0;a<3;a+=1)for(o=0;o<4;o+=1)s=280+(a*4+o)*4,this.affine[a][o]=X.getFloatAt(n,s,this.littleEndian);if(this.affine[3][0]=0,this.affine[3][1]=0,this.affine[3][2]=0,this.affine[3][3]=1,this.intent_name=X.getStringAt(n,328,344),this.magic=X.getStringAt(n,344,348),this.isHDR=this.magic===String.fromCharCode.apply(null,e.MAGIC_NUMBER2),n.byteLength>e.MAGIC_COOKIE){this.extensionFlag[0]=X.getByteAt(n,348),this.extensionFlag[1]=X.getByteAt(n,349),this.extensionFlag[2]=X.getByteAt(n,350),this.extensionFlag[3]=X.getByteAt(n,351);let e=!0;!this.isHDR&&this.vox_offset<=352&&(e=!1),n.byteLength<=368&&(e=!1),e&&this.extensionFlag[0]&&(this.extensions=X.getExtensionsAt(n,this.getExtensionLocation(),this.littleEndian,this.vox_offset),this.extensionSize=this.extensions[0].esize,this.extensionCode=this.extensions[0].ecode)}}toFormattedString(){var t=X.formatNumber,n=``;return n+=`Dim Info = `+this.dim_info+`
291
+ `),i=``,a=``,o=0,s=[],c=typeof``.trimLeft==`function`;for(let e=0,t=r.length;e<t;e++)if(i=r[e],i=c?i.trimLeft():i.trim(),o=i.length,o!==0&&(a=i.charAt(0),a!==`#`)){if(a===`v`){let e=i.split(/\s+/);switch(e[0]){case`v`:n.vertices.push(parseFloat(e[1]),parseFloat(e[2]),parseFloat(e[3])),e.length>=7?n.colors.push(parseFloat(e[4]),parseFloat(e[5]),parseFloat(e[6])):n.colors.push(void 0,void 0,void 0);break;case`vn`:n.normals.push(parseFloat(e[1]),parseFloat(e[2]),parseFloat(e[3]));break;case`vt`:n.uvs.push(parseFloat(e[1]),parseFloat(e[2]))}}else if(a===`f`){let e=i.substr(1).trim().split(/\s+/),t=[];for(let n=0,r=e.length;n<r;n++){let r=e[n];if(r.length>0){let e=r.split(`/`);t.push(e)}}let r=t[0];for(let e=1,i=t.length-1;e<i;e++){let i=t[e],a=t[e+1];n.addFace(r[0],i[0],a[0],r[1],i[1],a[1],r[2],i[2],a[2])}}else if(a===`l`){let e=i.substring(1).trim().split(` `),t=[],r=[];if(i.indexOf(`/`)===-1)t=e;else for(let n=0,i=e.length;n<i;n++){let i=e[n].split(`/`);i[0]!==``&&t.push(i[0]),i[1]!==``&&r.push(i[1])}n.addLineGeometry(t,r)}else if(a===`p`){let e=i.substr(1).trim().split(` `);n.addPointGeometry(e)}else if((s=rn.exec(i))!==null){let e=(` `+s[0].substr(1).trim()).substr(1);n.startObject(e)}else if(on.test(i))n.object.startMaterial(i.substring(7).trim(),n.materialLibraries);else if(an.test(i))n.materialLibraries.push(i.substring(7).trim());else if(sn.test(i))console.warn(`THREE.OBJLoader: Rendering identifier "usemap" not supported. Textures must be defined in MTL files.`);else if(a===`s`){if(s=i.split(` `),s.length>1){let e=s[1].trim().toLowerCase();n.object.smooth=e!==`0`&&e!==`off`}else n.object.smooth=!0;let e=n.object.currentMaterial();e&&(e.smooth=n.object.smooth)}else{if(i===`\0`)continue;console.warn(`THREE.OBJLoader: Unexpected line: "`+i+`"`)}}n.finalize();let l=new e.Group;if(l.materialLibraries=[].concat(n.materialLibraries),n.objects.length!==1||n.objects[0].geometry.vertices.length!==0)for(let t=0,r=n.objects.length;t<r;t++){let r=n.objects[t],i=r.geometry,a=r.materials,o=i.type===`Line`,s=i.type===`Points`,c=!1;if(i.vertices.length===0)continue;let u=new e.BufferGeometry;u.setAttribute(`position`,new e.Float32BufferAttribute(i.vertices,3)),i.normals.length>0&&u.setAttribute(`normal`,new e.Float32BufferAttribute(i.normals,3)),i.colors.length>0&&(c=!0,u.setAttribute(`color`,new e.Float32BufferAttribute(i.colors,3))),i.hasUVIndices===!0&&u.setAttribute(`uv`,new e.Float32BufferAttribute(i.uvs,2));let d=[];for(let t=0,r=a.length;t<r;t++){let r=a[t],i=r.name+`_`+r.smooth+`_`+c,l=n.materials[i];if(this.materials!==null){if(l=this.materials.create(r.name),o&&l&&!(l instanceof e.LineBasicMaterial)){let t=new e.LineBasicMaterial;e.Material.prototype.copy.call(t,l),t.color.copy(l.color),l=t}else if(s&&l&&!(l instanceof e.PointsMaterial)){let t=new e.PointsMaterial({size:10,sizeAttenuation:!1});e.Material.prototype.copy.call(t,l),t.color.copy(l.color),t.map=l.map,l=t}}l===void 0&&(l=o?new e.LineBasicMaterial:s?new e.PointsMaterial({size:1,sizeAttenuation:!1}):new e.MeshPhongMaterial,l.name=r.name,l.flatShading=!r.smooth,l.vertexColors=c,n.materials[i]=l),d.push(l)}let f;if(d.length>1){for(let e=0,t=a.length;e<t;e++){let t=a[e];u.addGroup(t.groupStart,t.groupCount,e)}f=o?new e.LineSegments(u,d):s?new e.Points(u,d):new e.Mesh(u,d)}else f=o?new e.LineSegments(u,d[0]):s?new e.Points(u,d[0]):new e.Mesh(u,d[0]);f.name=r.name,l.add(f)}else if(n.vertices.length>0){let t=new e.PointsMaterial({size:1,sizeAttenuation:!1}),r=new e.BufferGeometry;r.setAttribute(`position`,new e.Float32BufferAttribute(n.vertices,3)),n.colors.length>0&&n.colors[0]!==void 0&&(r.setAttribute(`color`,new e.Float32BufferAttribute(n.colors,3)),t.vertexColors=!0);let i=new e.Points(r,t);l.add(i)}return l}},mn=e.FileLoader,hn=e=>{let t=(e,t)=>{e.metadata.number_of_vertices+=t.metadata.number_of_vertices,`labels`in e&&e.labels.push(...e.labels),[`axis1`,`axis2`,`axis3`,`colors`,`positions`,`scale`].forEach(n=>{n in e&&Object.keys(e[n]).forEach(r=>{let i=t[n][r].length;for(let a=0;a<i;a++)e[n][r].push(t[n][r][a])})})};if(e&&e.length>0)for(;e.length>1;){let n=e.splice(1,1);t(e[0],n[0])}},gn=e=>{let t=(e,t)=>{e.merge(t)};if(e&&e.length>0){for(;e.length>1;){let n=e.splice(1,1);t(e[0],n[0])}return e[0]}},_n=function(e,t,n){let r=new mn,i=new Le;r.crossOrigin=t;let a=e,o=n,s,c=!1,l=!1,u,d=[],f=e=>{let t=s[e.index];if(t){if(`GlyphGeometriesURL`in t)e.onLoad(t);else{let n=i.parse(t);e.onLoad(n.geometry,n.materials)}}else p(e,{responseURL:a})},p=e=>{e.onError&&(u||={responseURL:a},e.onError(u))};this.downloadCompleted=e=>{try{s=JSON.parse(e[0]),c=!1,l=!0,Array.isArray(s)?d.forEach(e=>f(e)):d.forEach(e=>p(e))}catch{d.forEach(e=>p(e))}};let m=()=>e=>{u=e,l=!0,c=!1,d.forEach(e=>{p(e)})},h=()=>e=>{d.forEach(t=>{t.onProgress&&t.onProgress(e)})};this.load=(e,t,n,i)=>{let g={index:e,onLoad:t,onProgress:n,onError:i};l?s?f(g):p(u):c?d.push(g):(d.push(g),c=!0,r.load(a,o,h,m))}},vn=function(e,t,n){let r=[],i=e,a=t,o=0,s=n.isGlyphsets;this.itemDownloaded=(e,t)=>{if(r[e]=t,o++,o==i&&r.length>0){if(s){let e=r.map(e=>JSON.parse(e[0]));hn(e),a(e[0])}else{let t=r[0][1],n=gn(r.map(e=>e[0]));for(let t=1;t<i;t++)r[e][0].dispose(),r[e][1].forEach(e=>e.dispose());a(n,t)}}}},yn=function(){let e=0;this.crossOrigin=`Anonymous`;let t=new Le,n=new mn;n.crossOrigin=`Anonymous`;let r=[],i={},a=(e,t,n,r,i)=>{let a=e.length,o=new vn(a,t,i),c=0;e.forEach(e=>{let a=i?{...i}:{};a.msHandler=o,a.order=c,c++,s(e,t,n,r,a)})},o=(t,n,a,o,s)=>{let l=s?{...s}:{},u=i[t];if(!u){if(20>e){let n=new c(void 0,this,l);++e,u=new _n(t,this.crossOrigin,n),i[t]=u}else r.push({url:t,onLoad:n,onProgress:a,onError:o,options:s})}u&&(l.isHandler=u,u.load(s.index,n,a,o))},s=(i,a,s,l,u)=>{if(u&&u.index!==void 0)o(i,a,s,l,u);else if(20>e){++e;let r=new c(a,this,u),o=new c(l,this,u);u.isGlyphsets?n.load(i,r,s,o):(t.crossOrigin=this.crossOrigin,t.load(i,r,s,o))}else r.push({url:i,onLoad:a,onProgress:s,onError:l,options:u})};this.load=(e,t,n,r,i)=>{Array.isArray(e)?a(e,t,n,r,i):s(e,t,n,r,i)},this.loadFromWaitingList=()=>{for(;20>e;){let e=r.shift();if(e)this.load(e.url,e.onLoad,e.onProgress,e.onError,e.options);else return}},this.itemRemainingCheck=()=>{if(r.length===0&&e===0)for(let e in i)i.hasOwnProperty(e)&&delete i[e]};let c=function(t,n,r){return(...i)=>{--e,r?.msHandler?r.msHandler.itemDownloaded(r.order,i):r?.isHandler?r.isHandler.downloadCompleted(i):t&&t(...i),n.loadFromWaitingList(),n.itemRemainingCheck()}};this.parse=e=>loader.parse(e)},bn=class extends e.Loader{constructor(e){super(e)}load(t,n,r,i){let a=this,o=new e.FileLoader(this.manager);o.setPath(this.path),o.setResponseType(`arraybuffer`),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(t,function(e){try{n(a.parse(e))}catch(e){i?i(e):console.error(e),a.manager.itemError(t)}},r,i)}parse(t){function n(e){let t=new DataView(e);if(84+t.getUint32(80,!0)*50===t.byteLength)return!0;let n=[115,111,108,105,100];for(let e=0;e<5;e++)if(r(n,t,e))return!1;return!0}function r(e,t,n){for(let r=0,i=e.length;r<i;r++)if(e[r]!==t.getUint8(n+r,!1))return!1;return!0}function i(t){let n=new DataView(t),r=n.getUint32(80,!0),i,a,o,s=!1,c,l,u,d,f;for(let e=0;e<70;e++)n.getUint32(e,!1)==1129270351&&n.getUint8(e+4)==82&&n.getUint8(e+5)==61&&(s=!0,c=new Float32Array(r*3*3),l=n.getUint8(e+6)/255,u=n.getUint8(e+7)/255,d=n.getUint8(e+8)/255,f=n.getUint8(e+9)/255);let p=new e.BufferGeometry,m=new Float32Array(r*3*3),h=new Float32Array(r*3*3);for(let e=0;e<r;e++){let t=84+e*50,r=n.getFloat32(t,!0),f=n.getFloat32(t+4,!0),p=n.getFloat32(t+8,!0);if(s){let e=n.getUint16(t+48,!0);e&32768?(i=l,a=u,o=d):(i=(e&31)/31,a=(e>>5&31)/31,o=(e>>10&31)/31)}for(let l=1;l<=3;l++){let u=t+l*12,d=e*3*3+(l-1)*3;m[d]=n.getFloat32(u,!0),m[d+1]=n.getFloat32(u+4,!0),m[d+2]=n.getFloat32(u+8,!0),h[d]=r,h[d+1]=f,h[d+2]=p,s&&(c[d]=i,c[d+1]=a,c[d+2]=o)}}return p.setAttribute(`position`,new e.BufferAttribute(m,3)),p.setAttribute(`normal`,new e.BufferAttribute(h,3)),s&&(p.setAttribute(`color`,new e.BufferAttribute(c,3)),p.hasColors=!0,p.alpha=f),p}function a(t){let n=new e.BufferGeometry,r=/solid([\s\S]*?)endsolid/g,i=/facet([\s\S]*?)endfacet/g,a=0,o=`[\\s]+([+-]?(?:\\d*)(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)`,s=RegExp(`vertex`+o+o+o,`g`),c=RegExp(`normal`+o+o+o,`g`),l=[],u=[],d=new e.Vector3,f,p=0,m=0,h=0;for(;(f=r.exec(t))!==null;){m=h;let e=f[0];for(;(f=i.exec(e))!==null;){let e=0,t=0,n=f[0];for(;(f=c.exec(n))!==null;)d.x=parseFloat(f[1]),d.y=parseFloat(f[2]),d.z=parseFloat(f[3]),t++;for(;(f=s.exec(n))!==null;)l.push(parseFloat(f[1]),parseFloat(f[2]),parseFloat(f[3])),u.push(d.x,d.y,d.z),e++,h++;t!==1&&console.error(`THREE.STLLoader: Something isn't right with the normal of face number `+a),e!==3&&console.error(`THREE.STLLoader: Something isn't right with the vertices of face number `+a),a++}let t=m,r=h-m;n.addGroup(t,r,p),p++}return n.setAttribute(`position`,new e.Float32BufferAttribute(l,3)),n.setAttribute(`normal`,new e.Float32BufferAttribute(u,3)),n}function o(t){return typeof t==`string`?t:e.LoaderUtils.decodeText(new Uint8Array(t))}function s(e){if(typeof e==`string`){let t=new Uint8Array(e.length);for(let n=0;n<e.length;n++)t[n]=e.charCodeAt(n)&255;return t.buffer||t}return e}let c=s(t);return n(c)?i(c):a(o(t))}},xn=function(){B.call(this),this.isTubeLines=!0;let t={},n={radius:1,radialSegments:8,smooth:!1};this.createLineSegment=(n,i,a)=>{if(n&&i){t={geometryIn:n,materialIn:i,options:a};let o=r(n.vertices),s=new e.MeshStandardMaterial({color:i.color}),c=new e.Mesh(o,s);this.setMesh(c,a.localTimeEnabled,a.localMorphColour)}},this.setWidth=e=>{this.morph&&this.morph.material&&(this.morph.material.linewidth=e,this.morph.material.needsUpdate=!0)},this.setAlpha=function(e){let t=this.getMorph();t.material.opacity=e,t.material.transparent=e<1,t.material.depthWrite=e>.5},this.setWireframe=e=>{let t=this.getMorph();t.material.wireframe=e},this.setTubeLines=(e,i)=>{if(e&&i){let{geometryIn:a}=t,o=this.getMorph();o.geometry.dispose(),n=Object.assign(n,{radius:e,radialSegments:i}),o.geometry=r(a.vertices)}};let r=t=>{let{radius:r,radialSegments:i,smooth:a}=n,o;if(a){let n=new e.CatmullRomCurve3(t);o=new e.TubeGeometry(n,t.length,r,i,!1)}else{let n=[];for(let a=0;a+1<t.length;a+=2){let o=new e.LineCurve3(t[a],t[a+1]),s=new e.TubeGeometry(o,1,r,i,!1);n.push(s)}o=M(n,!0),n.forEach(e=>e.dispose())}return o}};xn.prototype=Object.create(B.prototype);var Sn=function(t){let n=t;this.toBeDownloaded=0,this.progressMap={};let r=!1,i=!1,a=new yn;this.getDownloadProgress=()=>{let e=0,t=0,n=!1;for(let r in this.progressMap){let i=this.progressMap[r];e+=i[1],t+=i[0],i[1]==0&&(n=!0)}return n&&(e=0),[e,t,i]},this.onProgress=e=>t=>{this.progressMap[e]=[t.loaded,t.total]},this.onError=e=>t=>{--this.toBeDownloaded,i=!0,console.error(`There is an issue with external resource ${t?.responseURL?`: `+t?.responseURL:``}.`),e&&e({type:`Error`,xhr:t})};let o=(e,t)=>{let i=t.Default;if(t.Inline)n.setupMultipleViews(i,t.Entries);else{let a=[];for(let[n,r]of Object.entries(t.Entries))if(e){let t=C(r,e);a.push(new Promise((e,r)=>{fetch(t).then(e=>e.json()).then(t=>e({key:n,data:t})).catch(e=>r(e))}))}Promise.all(a).then(e=>{let t={};e.forEach(e=>{t[e.key]=e.data}),n.setupMultipleViews(i,t);let a=n.getZincCameraControls();a&&a.setCurrentViewport(i),r=!0})}};this.loadViewURL=(e,t)=>{this.toBeDownloaded+=1;let i=e;fetch(i).then(e=>{if(!e.ok)throw Error(`HTTP error! status: ${e.status}`);return e.json()}).then(e=>{n.setupMultipleViews(`default`,{default:e}),n.resetView(),r=!0,--this.toBeDownloaded,t!==void 0&&typeof t==`function`&&t()}).catch(e=>{console.error(`Fetch failed for URL: ${i}`,e),this.onError(t)({responseURL:i})})},this.loadModelsURL=(e,t,n,r,i,o,s)=>{let c=t.length;this.toBeDownloaded+=c;for(let l=0;l<c;l++){let c=t[l],u=$.defaultMaterialColor,d=$.defaultOpacity;n!=null&&n[l]!=null&&(u=!!n[l]),r!=null&&r[l]!=null&&(d=r[l]);let f=0;i!=null&&i[l]!=null&&(f=!!i[l]);let p=0;o!=null&&o[l]!=null&&(p=!!o[l]),a.load(c,m(e,u,d,f,p,void 0,void 0,void 0,void 0,s),this.onProgress(c),this.onError(s))}},this.loadFromViewURL=(e,t,r)=>{let i=t+`_view.json`;fetch(i).then(e=>{if(!e.ok)throw Error(`HTTP error! status: ${e.status}`);return e.json()}).then(i=>{n.loadView(i);let a=[],o=t+`_`;for(let e=0;e<i.numberOfResources;e++){let t=o+(e+1)+`.json`;a.push(t)}this.loadModelsURL(e,a,i.colour,i.opacity,i.timeEnabled,i.morphColour,r)}).catch(e=>{console.error(`Failed to load view data from: ${i}`,e)})};let s=(t,r,i,o,s,c,l,u,d)=>(f,p)=>{let m=u?new xn:new Ye,h;p&&p[0]&&(h=new e.LineBasicMaterial({color:p[0].color.clone()}),1>p[0].opacity&&(h.transparent=!0),h.opacity=p[0].opacity,h.morphTargets=r,h.vertexColors=p[0].vertexColors);let g={};if(g.localTimeEnabled=r,g.localMorphColour=i,m&&(m.createLineSegment(f,h,g),m.setName(o),m.setAnatomicalId(s),m.setRenderOrder(c),t.addZincObject(m),m.setDuration(n.getDuration()),l&&l.levels))for(let[e,t]of Object.entries(l.levels))m.addLOD(a,e,t.URL,t.Index,l.preload);--this.toBeDownloaded,f.dispose(),d!=null&&typeof d==`function`&&d(m)};this.loadLinesURL=(e,t,n,r,i,o,c)=>{let l=0;this.toBeDownloaded+=1;let u=c?.isInline?c.isInline:!1,d=c?.anatomicalId?c.anatomicalId:void 0,f=c&&`renderOrder`in c?c.renderOrder:void 0;n!=null&&(l=!!n);let p=0;r!=null&&(p=!!r);let m=c.tubeLines&&!l&&!p;if(u){let n=a.parse(t);s(e,l,p,i,d,f,c.lod,m,o)(n.geometry,n.materials)}else a.load(t,s(e,l,p,i,d,f,c.lod,m,o),this.onProgress(t),this.onError(o),c.loaderOptions)};let c=(e,t,r,i,a)=>o=>{let s=o;(typeof s==`string`||s instanceof String)&&(s=JSON.parse(o));let c=a&&a.isInline?a.isInline:void 0,l=a&&a.anatomicalId?a.anatomicalId:void 0,u=a?.displayLabels;u===void 0&&(u=!0);let d=a&&`renderOrder`in a?a.renderOrder:void 0,f=new Re;f.setDuration(n.getDuration()),f.groupName=r,++this.toBeDownloaded,f.load(s,t,()=>{--this.toBeDownloaded,i!=null&&typeof i==`function`&&i(f)},c,u),f.setAnatomicalId(l),f.setRenderOrder(d),e.addZincObject(f)};this.loadGlyphsetURL=(e,t,n,r,i,o)=>{o&&o.isInline&&o.isInline?c(e,n,r,i,o)(t):a.load(t,c(e,n,r,i,o),this.onProgress(t),this.onError(i),o.loaderOptions)};let l=(t,r,i,a,o,s,c)=>(l,u)=>{let d=new Je,f=new e.PointsMaterial({alphaTest:.5,size:10,sizeAttenuation:!1});u&&u[0]&&(1>u[0].opacity&&(f.transparent=!0),f.opacity=u[0].opacity,f.color=u[0].color,f.morphTargets=r,f.vertexColors=u[0].vertexColors);let p={};p.localTimeEnabled=r,p.localMorphColour=i,d&&(d.createMesh(l,f,p),d.setName(a),d.setAnatomicalId(o),t.addZincObject(d),d.setDuration(n.getDuration()),d.setRenderOrder(s)),l.dispose(),--this.toBeDownloaded,c!=null&&typeof c==`function`&&c(d)};this.loadSTL=(e,t,n,r)=>{this.toBeDownloaded+=1;let i=$.defaultMaterialColor,a=$.defaultOpacity,o=new bn;o.crossOrigin=`Anonymous`,o.load(t,m(e,i,a,!1,!1,n,void 0,void 0,void 0,r))},this.loadOBJ=(e,t,n,r)=>{this.toBeDownloaded+=1;let i=$.defaultMaterialColor,a=$.defaultOpacity,o=new pn;o.crossOrigin=`Anonymous`,o.load(t,m(e,i,a,!1,!1,n,void 0,void 0,void 0,r))};let u=(e,t,n,r,i,o,s)=>{this.toBeDownloaded+=1;let c=$.defaultMaterialColor,l=$.defaultOpacity,u=0,d=s&&s.isInline?s.isInline:!1,f=s&&s.fileFormat?s.fileFormat:void 0,p=s&&s.anatomicalId?s.anatomicalId:void 0,h=s&&`renderOrder`in s?s.renderOrder:void 0;n!=null&&(u=!!n);let g=0;r!=null&&(g=!!r);let _=a;if(f!==void 0){if(f==`STL`)_=new bn;else if(f==`OBJ`){_=new pn,_.crossOrigin=`Anonymous`,_.load(t,objloader(e,c,l,u,g,i,p,o),this.onProgress(t),this.onError,s.loaderOptions);return}}if(d){let n=a.parse(t);m(e,c,l,u,g,i,p,h,s,o)(n.geometry,n.materials)}else _.crossOrigin=`Anonymous`,a.load(t,m(e,c,l,u,g,i,p,h,s,o),this.onProgress(t),this.onError(o),s.loaderOptions)},d=function(e,t,i){let a=0;return o=>{if(a+=1,o&&t!=null&&typeof t==`function`&&t(o),a==e&&(r===!1&&n.viewAll(),i!=null&&typeof i==`function`)){i();let e=n.getZincCameraControls();e&&e.calculateMaxAllowedDistance(n)}}};this.loadPointsetURL=(e,t,n,r,i,o,s)=>{let c=0;this.toBeDownloaded+=1,n!=null&&(c=!!n);let u=0;r!=null&&(u=!!r);let d=s&&s.isInline?s.isInline:!1,f=s&&s.anatomicalId?s.anatomicalId:void 0,p=s&&`renderOrder`in s?s.renderOrder:void 0;if(d){let n=a.parse(t);l(e,c,u,i,f,p,o)(n.geometry,n.materials)}else a.load(t,l(e,c,u,i,f,p,o),this.onProgress(t),this.onError(o),s.loaderOptions)};let f=(e,t,n,r,i,a)=>{let o=a&&a.isInline?a.isInline:void 0,s=a&&a.anatomicalId?a.anatomicalId:void 0,c=a&&`renderOrder`in a?a.renderOrder:void 0,l;if(n){if(t&&n.images&&n.images.source){let e=n.images.source;for(let r=0;r<e.length;r++){let i=C(e[r],t);n.images.source[r]=i}}n.type===`slides`&&(l=new rt),l&&(l.groupName=r,++this.toBeDownloaded,l.load(n,()=>{e.addZincObject(l),--this.toBeDownloaded,i!=null&&typeof i==`function`&&i(l)},o),l.setAnatomicalId(s),l.setRenderOrder(c))}};this.loadTextureURL=(e,t,n,r,i)=>{if(i&&i.isInline&&i.isInline)f(e,void 0,t,n,r,i);else{let a=t;fetch(a).then(e=>{if(!e.ok)throw Error(`HTTP error! status: ${e.status}`);let t=e.url||new URL(a).href;return e.json().then(e=>({textureData:e,referenceURL:t}))}).then(({textureData:t,referenceURL:a})=>{f(e,a,t,n,r,i)}).catch(e=>{console.error(`Fetch failed for texture URL: ${a}`,e)})}};let p=(e,t,r,i,a,o,s,c,l,u,d)=>{let f={};f.colour=r,f.opacity=i,f.localTimeEnabled=a,f.localMorphColour=o;let p=new Ce;if(p.createMesh(t,c,f),p.getMorph())return p.setName(l),p.setRenderOrder(u),p.setAnatomicalId(d),e&&e.addZincObject(p),p.setDuration(n.getDuration()),s!=null&&typeof s==`function`&&s(p),p.videoHandler&&n.setVideoHandler(p.videoHandler),p},m=(e,t,n,r,i,o,s,c,l,u)=>(d,f)=>{let m;f&&f[0]&&(m=f[0]);let h=p(e,d,t,n,r,i,void 0,m,o,c,s);if(l.lod&&l.lod.levels)for(let[e,t]of Object.entries(l.lod.levels))h.addLOD(a,e,t.URL,t.Index,l.lod.preload);--this.toBeDownloaded,d.dispose(),u!=null&&typeof u==`function`&&u(h)},h=e=>{let[,t,n,r,i,a,o,s]=e.match(/P(?:(\d+)Y)?(?:(\d+)M)?(?:(\d+)W)?(?:(\d+)D)?(?:T(?:(\d+)H)?(?:(\d+)M)?(?:(\d+)S)?)?$/);return{years:t,months:n,weeks:r,days:i,hours:a,mins:o,secs:s}};this.loadSettings=e=>{if(e){if(e.Duration){let t=h(e.Duration);n.setDurationFromObject(t)}if(e.OriginalDuration){let t=h(e.OriginalDuration);n.setOriginalDurationFromObject(t)}if(e.TimeStamps)for(let t in e.TimeStamps){let r=h(e.TimeStamps[t]);n.addMetadataTimeStamp(t,r)}}};let g=(e,t,n,r,i)=>{if(n){let a,o=!1;n.URL?(a=n.URL,t&&(a=C(a,t))):n.Inline&&(a=n.Inline.URL,o=!0);let s={};if(n.LOD&&n.LOD.Levels){s.preload=!!n.LOD.Preload,s.levels={};for(let[e,r]of Object.entries(n.LOD.Levels))s.levels[e]={},s.levels[e].URL=C(r.URL,t),s.levels[e].Index=r.Index}let c=n.GroupName;(c===void 0||c===``)&&(c=`_Unnamed`);let l={loaderOptions:{index:n.Index},isInline:o,fileFormat:n.FileFormat,anatomicalId:n.AnatomicalId,compression:n.compression,tubeLines:n.tubeLines,lod:s,renderOrder:r};switch(n.Type){case`Surfaces`:u(e,a,n.MorphVertices,n.MorphColours,c,i,l);break;case`Glyph`:let r;o?r=n.Inline.GlyphGeometriesURL:(r=n.GlyphGeometriesURL,r=C(n.GlyphGeometriesURL,t)),l.displayLabels=n.DisplayLabels,l.displayLabels===void 0&&(l.displayLabels=!0),l.loaderOptions.isGlyphsets=!0,this.loadGlyphsetURL(e,a,r,c,i,l);break;case`Points`:this.loadPointsetURL(e,a,n.MorphVertices,n.MorphColours,c,i,l);break;case`Lines`:this.loadLinesURL(e,a,n.MorphVertices,n.MorphColours,c,i,l);break;case`Texture`:this.loadTextureURL(e,a,c,i,l)}}},_=(e,t,i)=>{if(t){let a,o=!1;switch(t.URL?(a=t.URL,e&&(a=C(t.URL,e))):t.Inline&&(a=t.Inline.URL,o=!0),t.Type){case`View`:o?(n.setupMultipleViews(`default`,{default:a}),r=!0,i!=null&&typeof i==`function`&&i()):this.loadViewURL(a,i);break;case`Settings`:this.loadSettings(t)}}};this.loadGLTF=(e,t,r,i,a)=>{new nn().load(n,e,t,r,i,a)};let v=(e,t,n,r)=>{if(n.Primitives&&n.Primitives.forEach(n=>{let i=1;n.Order&&(i=n.Order),g(e,t,n,i,r)}),n.Transformation&&e.setTransformation(n.Transformation),n.Children)for(let[i,a]of Object.entries(n.Children)){let n=e.findOrCreateChildFromPath(i);n&&v(n,t,a,r)}},y=(e,t)=>{let n=e,r=t?.enabled?.include,i=t?.enabled?.exclude,a=t?.tubeLines;return(r?.length||i?.length)&&(r&&(n=e.filter(e=>{if(e.Type===`View`)return!0;for(let t=0;t<r.length;t++)if(I(e.RegionPath,e.GroupName,r[t]))return!0;return!1})),i&&(n=n.filter(e=>{if(e.Type===`View`)return!0;for(let t=0;t<i.length;t++)if(I(e.RegionPath,e.GroupName,i[t]))return!1;return!0}))),a&&n.forEach(e=>{e.Type===`Lines`&&(e.tubeLines=!0)}),n},b=(e,t)=>Array.isArray(e)?y(e,t):e,x=(e,t)=>{if(Array.isArray(e)){let n=0;for(let r=0;r<e.length;r++)e[r].Type&&(t&&e[r].Type===`View`||e[r].Type===`Surfaces`||e[r].Type===`Glyph`||e[r].Type===`Points`||e[r].Type===`Lines`||e[r].Type===`Texture`)&&n++;return n}return 0},S=e=>{let t=e.Primitives?x(e.Primitives,!1):0;return e.Children&&Object.values(e.Children).forEach(e=>{t+=S(e)}),t},w=e=>{if(Array.isArray(e))return x(e,!0);if(typeof e==`object`&&e&&e.Version===`2.0`)return S(e.Regions)},T=(e,t,n,r,i)=>{let a=e;n.RegionPath&&n.RegionPath!==``&&(a=e.findOrCreateChildFromPath(n.RegionPath)),g(a,t,n,r*2,i)},E=(e,t,n,r,i,a)=>{let o=b(t,a),s=w(o),c=new d(s,r,i);for(let e=0;e<t.length;e++)_(n,o[e],c);for(let r=0;r<t.length;r++)T(e,n,o[r],r,c)},D=(e,t,n,r,i)=>{let a=w(t),s=new d(a,r,i);t.Settings&&this.loadSettings(t.Settings),t.Views&&o(n,t.Views,n),t.Regions&&v(e,n,t.Regions,s)};this.loadMetadataURL=(e,t,i,a,o)=>{let s=t;fetch(s).then(e=>{if(!e.ok)throw Error(`HTTP error! status: ${e.status}`);let t=e.url||new URL(s).href;return e.json().then(e=>({metadata:e,referenceURL:t}))}).then(({metadata:t,referenceURL:s})=>{n.resetMetadata(),n.resetDuration(),r=!1,Array.isArray(t)?E(e,t,s,i,a,o):typeof t==`object`&&t&&t.Version===`2.0`&&D(e,t,s,i,a)}).catch(e=>{console.error(`Fetch failed for URL: ${s}`,e)})}},Cn=0,wn=function(){return`sc`+Cn++},Tn=function(){return{Duration:`6 secs`,OriginalDuration:`-`,TimeStamps:{}}},En=6e3,Dn=function(t,n){let r=t,i,a,o=new Sn(this),s,c={},l=0,u={},d=0,f=new e.Scene,p=new e.Scene,m=new Ft(void 0,this);f.add(m.getGroup());let h=new e.Group;f.add(h),this.directionalLight=void 0,this.ambient=void 0,this.camera=void 0;let g=6e3,_;this.sceneName=void 0;let v=!1,y;this.autoClearFlag=!0,this.displayMarkers=!1,this.displayMinimap=!1,this.displayMiniAxes=!1,this.minimapScissor={x_offset:16,y_offset:16,width:128,height:128,align:`top-right`,updateRequired:!0};let b={x:0,y:0},x=Tn(),S=new e.Vector2,C=[];this.forcePickableObjectsUpdate=!1,this.uuid=wn();let w=new yt(this);w.disable(),f.add(w.group);let T={main:[],mini:[]},E=new e.Vector3(0,0,0),D=()=>r?r.clientWidth===void 0?r.width:r.clientWidth:0,O=()=>r?r.clientHeight===void 0?r.height:r.clientHeight:0;this.getDownloadProgress=()=>o.getDownloadProgress(),this.onWindowResize=()=>{let e=O();this.camera.aspect=D()/e,this.camera.updateProjectionMatrix(),this.minimapScissor.updateRequired=!0,_.onResize(),_.calculateHeightPerPixelAtZeroDepth(e)},this.resetView=()=>{this.onWindowResize(),_.resetView()},this.changeZoomByScrollRateUnit=e=>{_.changeZoomByScrollRateUnit(e)},this.camera=new e.PerspectiveCamera(40,D()/O(),0,10),this.ambient=new e.AmbientLight(16777215,.2),f.add(this.ambient),this.directionalLight=new e.DirectionalLight(16777215,.8),f.add(this.directionalLight),_=new at(this.camera,n.domElement,n,this),_.setDirectionalLight(this.directionalLight),_.resetView(),s=new bt(this),this.loadView=e=>{let t=new it;return t.setFromObject(e),_.setCurrentCameraSettings(t),!0},this.setupMultipleViews=(e,t)=>{for(let[e,n]of Object.entries(t)){let t=new it;t.setFromObject(n),_.addViewport(e,t)}_.setDefaultViewport(e)},this.getBoundingBox=()=>m.getBoundingBox(!0),this.viewAllWithBoundingBox=e=>{if(e){let t=_.getViewportFromBoundingBox(e,1);_.setCurrentCameraSettings(t),_.calculateHeightPerPixelAtZeroDepth(O()),w.markerUpdateRequired=!0}},this.viewAll=()=>{let e=this.getBoundingBox();this.viewAllWithBoundingBox(e),w.markerUpdateRequired=!0},this.forEachGeometry=e=>{m.forEachGeometry(e,!0)},this.forEachGlyphset=e=>{m.forEachGlyphset(e,!0)},this.forEachPointset=e=>{m.forEachPointset(e,!0)},this.forEachLine=e=>{m.forEachLine(e,!0)},this.findGeometriesWithGroupName=e=>m.findGeometriesWithGroupName(e,!0),this.findPointsetsWithGroupName=e=>m.findPointsetsWithGroupName(e,!0),this.findGlyphsetsWithGroupName=e=>m.findGlyphsetsWithGroupName(e,!0),this.findLinesWithGroupName=e=>m.findLinesWithGroupName(e,!0),this.findObjectsWithGroupName=e=>m.findObjectsWithGroupName(e,!0),this.findObjectsWithAnatomicalId=e=>m.findObjectsWithAnatomicalId(e,!0),this.getBoundingBoxOfZincObjects=e=>{let t;for(let n=0;n<e.length;n++){let r=e[n].getBoundingBox();r&&(t?t.union(r):t=r)}return t},this.vectorToScreenXY=e=>{e.project(this.camera);let t=D(),n=O(),r=t/2,i=n/2;return e.x=e.x*r+r,e.y=-(e.y*i)+i,e},this.getObjectsScreenXY=t=>{if(t&&t.length>0){let n=this.getBoundingBoxOfZincObjects(t),r=new e.Vector3;return n.getCenter(r),this.vectorToScreenXY(r)}},this.getNamedObjectsScreenXY=e=>{let t=this.findObjectsWithGroupName(e);return this.getObjectsScreenXY(t)},this.addZincObject=e=>{e&&(m.addZincObject(e),_&&_.calculateMaxAllowedDistance(this))},this.loadGlyphsetURL=(e,t,n,r)=>{o.loadGlyphsetURL(m,e,t,n,r)},this.loadPointsetURL=(e,t,n,r,i)=>{o.loadPointsetURL(m,e,t,n,r,i)},this.loadLinesURL=(e,t,n,r,i)=>{o.loadLinesURL(m,e,t,n,r,i)},this.loadSTL=(e,t,n)=>{o.loadSTL(m,e,t,n)},this.loadOBJ=(e,t,n)=>{o.loadOBJ(m,e,t,n)},this.loadMetadataURL=(e,t,n,r)=>{o.loadMetadataURL(m,e,t,n,r)},this.loadModelsURL=(e,t,n,r,i,a)=>{o.loadModelsURL(m.urls,t,n,r,i,a)},this.loadViewURL=e=>{o.loadViewURL(e)},this.loadFromViewURL=(e,t)=>{o.loadFromViewURL(e,t)},this.loadGLTF=(e,t,n,r)=>{o.loadGLTF(m,e,t,n,r)},this.updateDirectionalLight=()=>{_.updateDirectionalLight()},this.addObject=e=>{f.add(e)},this.removeObject=e=>{f.remove(e)},this.getCurrentTime=()=>{if(a!=null)return a.getCurrentTime(g);let e=m.getCurrentTime();return e===-1?0:e},this.setMorphsTime=e=>{a?.setMorphTime(e,g),m.setMorphTime(e,!0)},this.isTimeVarying=()=>a&&a.video&&!a.video.error?!0:m.isTimeVarying(),this.renderGeometries=(e,t,n)=>{let r={};if(r.camera=_,r.displayMarkers=this.displayMarkers,r.markerCluster=w,r.markersList=w.markers,r.ndcToBeUpdated=!1,n&&(r.markerCluster.markerUpdateRequired=!0),a){if(a.isReadyToPlay()){n?a.video.play():a.video.pause();let e=a.video.currentTime/a.getVideoDuration()*g;o.toBeDownloaded==0?(_.setTime(e),r.ndcToBeUpdated=_.update(0),r.ndcToBeUpdated&&_.calculateHeightPerPixelAtZeroDepth(O()),m.setMorphTime(e,!0),m.renderGeometries(0,0,n,_,r,!0)):_.update(0)}else myPlayRate=0}else o.toBeDownloaded==0?(r.ndcToBeUpdated=_.update(t),r.ndcToBeUpdated&&_.calculateHeightPerPixelAtZeroDepth(O()),m.renderGeometries(e,t,n,_,r,!0)):_.update(0)},this.getThreeJSScene=()=>f,this.setVideoHandler=e=>{a||=e},this.setAdditionalScenesGroup=e=>{f.add(e)};let k=(e,t,n,r,i,a,o)=>{let s=0,c=0;return c=e.includes(`top`)?o-i-n:e.includes(`bottom`)?n:Math.floor((o-i)/2),s=e.includes(`left`)?t:e.includes(`right`)?a-t-r:Math.floor((a-r)/2),{x:s,y:c}},A=e=>{(this.displayMinimap||this.displayMiniAxes)&&(e.setScissorTest(!0),e.getSize(S),this.minimapScissor.updateRequired&&(b=k(this.minimapScissor.align,this.minimapScissor.x_offset,this.minimapScissor.y_offset,this.minimapScissor.width,this.minimapScissor.height,S.x,S.y),this.minimapScissor.updateRequired=!1),e.setScissor(b.x,b.y,this.minimapScissor.width,this.minimapScissor.height),e.setViewport(b.x,b.y,this.minimapScissor.width,this.minimapScissor.height),s.updateCamera(),this.displayMiniAxes?e.render(p,s.camera):(f.add(s.mask),e.render(f,s.camera),f.remove(s.mask)),e.setScissorTest(!1),e.setViewport(0,0,S.x,S.y))};this.render=e=>{this.autoClearFlag&&e.clear(),v&&y?y.render(f,this.camera):(e.render(f,this.camera),A(e))},this.setInteractiveControlEnable=e=>{e==1?_.enable():_.disable()},this.getZincCameraControls=()=>_,this.getThreeJSScene=()=>f,this.setDuration=e=>{m.setDuration(e),g=e,_.setPathDuration(e),o.duration=e},this.getDuration=()=>g,this.setStereoEffectEnable=e=>{e==1&&(y||=new dt(n)),n.setSize(D(),O()),this.camera.updateProjectionMatrix(),v=e},this.objectIsInScene=e=>m.objectIsInRegion(e,!0),this.alignBoundingBoxToCameraView=(t,n)=>{if(t){t.getCenter(E);let r=this.getZincCameraControls().getCurrentViewport(),i=new e.Vector3(r.targetPosition[0],r.targetPosition[1],r.targetPosition[2]),a=new e.Vector3(r.eyePosition[0],r.eyePosition[1],r.eyePosition[2]),o=new e.Vector3,s=new e.Vector3;o.subVectors(i,a).normalize(),s.subVectors(i,E).normalize();let c=new e.Vector3;c.crossVectors(o,s);let l=o.angleTo(s);n>0?(this.getZincCameraControls().rotateCameraTransition(c,l,n),this.getZincCameraControls().enableCameraTransition()):this.getZincCameraControls().rotateAboutLookAtpoint(c,l),w.markerUpdateRequired=!0}},this.translateBoundingBoxToCameraView=(e,t,n)=>{if(e){let r=this.getZincCameraControls().getCurrentViewport(),i=this.getZincCameraControls().getViewportFromBoundingBox(e,t);n>0&&(this.getZincCameraControls().cameraTransition(r,i,n),this.getZincCameraControls().enableCameraTransition()),w.markerUpdateRequired=!0}},this.alignObjectToCameraView=(e,t)=>{if(this.objectIsInScene(e)){let n=e.getBoundingBox();this.alignBoundingBoxToCameraView(n,t)}},this.setCameraTargetToObject=t=>{if(this.objectIsInScene(t)){let n=t.getBoundingBox(),r=this.getZincCameraControls().getCurrentViewport();n.getCenter(E);let i=new e.Vector3(r.targetPosition[0],r.targetPosition[1],r.targetPosition[2]),a=new e.Vector3(r.eyePosition[0],r.eyePosition[1],r.eyePosition[2]),o=new e.Vector3,s=new e.Vector3;o.subVectors(a,i),s.addVectors(E,o),r.eyePosition[0]=s.x,r.eyePosition[1]=s.y,r.eyePosition[2]=s.z,r.targetPosition[0]=E.x,r.targetPosition[1]=E.y,r.targetPosition[2]=E.z,this.getZincCameraControls().setCurrentCameraSettings(r),w.markerUpdateRequired=!0}},this.isStereoEffectEnable=()=>v,this.removeZincObject=e=>{m.removeZincObject(e),_&&_.calculateMaxAllowedDistance(this),w.markerUpdateRequired=!0},this.updatePickableThreeJSObjects=()=>{C.length=0,w.isEnabled&&C.push(w.group),m.getPickableThreeJSObjects(C,!0),this.forcePickableObjectsUpdate=!1},this.getPickableThreeJSObjects=()=>((this.forcePickableObjectsUpdate||m.checkPickableUpdateRequred(!0))&&this.updatePickableThreeJSObjects(),C),this.getNormalisedMinimapCoordinates=(t,n)=>{if(this.displayMinimap){let r=new e.Vector2;t.getSize(r);let i=r.y-n.clientY;if(b.x+this.minimapScissor.width>n.clientX&&n.clientX>b.x&&b.y+this.minimapScissor.height>i&&i>b.y)return{x:(n.clientX-b.x)/this.minimapScissor.width*2-1,y:(i-b.y)/this.minimapScissor.height*2-1}}},this.getMinimapDiffFromNormalised=(e,t)=>{if(s)return s.getDiffFromNormalised(e,t)},this.isWebGL2=()=>n.isWebGL2(),this.clearAll=()=>{w.clear(),m.clear(!0),this.clearZincObjectAddedCallbacks(),this.clearZincObjectRemovedCallbacks(),o.toBeDwonloaded=0,_&&_.calculateMaxAllowedDistance(this),w.markerUpdateRequired=!0},this.addMetadataTimeStamp=(e,t)=>{x.TimeStamps[e]=M(t)},this.getMetadataTag=e=>x[e],this.getMetadata=()=>x,this.setMetadataTag=(e,t)=>{x[e]=t},this.removeMetadataTag=e=>{delete x[e]},this.resetMetadata=()=>{x=Tn()},this.resetDuration=()=>{this.setDuration(En)};let j=e=>[...e.years?[`${e.years}years`]:[],...e.months?[`${e.months}months`]:[],...e.weeks?[`${e.weeks}weeks`]:[],...e.days?[`${e.days}days`]:[],...e.hours?[`${e.hours}hours`]:[],...e.mins?[`${e.mins}mins`]:[],...e.secs?[`${e.secs}secs`]:[]].join(` `),M=e=>e.years?e.years*31536e6:0+e.months?e.months*2592e6:0+e.weeks?e.weeks*6048e5:0+e.days?e.days*864e5:0+e.hours?e.hours*36e5:0+e.mins?e.mins*6e4:0+e.secs?e.secs*1e3:0;this.setDurationFromObject=e=>{let t=j(e),n=M(e);this.setMetadataTag(`Duration`,t),this.setDuration(n)},this.setOriginalDurationFromObject=e=>{let t=j(e);this.setMetadataTag(`OriginalDuration`,t)},this.exportGLTF=e=>new tn(this).exportGLTF(e),this.getRootRegion=()=>m,this.createLines=(e,t,n,r)=>{let i=m.findChildFromPath(e);return i===void 0&&(i=m.createChildFromPath(e)),i.createLines(t,n,r)},this.createPoints=(e,t,n,r,i)=>{let a=m.findChildFromPath(e);return a===void 0&&(a=m.createChildFromPath(e)),a.createPoints(t,n,r,i)},this.addZincObjectAddedCallbacks=e=>(l+=1,c[l]=e,l),this.addZincObjectRemovedCallbacks=e=>(d+=1,u[d]=e,d),this.removeZincObjectAddedCallbacks=e=>{e in l&&delete c[e]},this.removeZincObjectRemovedCallbacks=e=>{e in d&&delete u[e]},this.clearZincObjectAddedCallbacks=()=>{c={},l=0},this.clearZincObjectRemovedCallbacks=()=>{u={},d=0},this.triggerObjectAddedCallback=e=>{for(let t in c)c.hasOwnProperty(t)&&c[t](e)},this.triggerObjectRemovedCallback=e=>{for(let t in u)u.hasOwnProperty(t)&&u[t](e)},this.addTemporaryPoints=(t,n)=>{let r=N(t.length,t),i=new e.PointsMaterial({alphaTest:.5,size:15,color:n,sizeAttenuation:!1});i.map=P();let a=new Ge(r,i);return h.add(a),a},this.addTemporaryLines=(t,n)=>{let r=new pe(N(t.length,t),new e.LineBasicMaterial({color:n}));return h.add(r),r},this.enableFrustumDisplay=()=>{this.camera&&!i&&(i=new e.CameraHelper(this.camera),f.add(i))},this.disableFrustumDisplay=()=>{i&&=(f.remove(i),i.dispose(),void 0)},this.removeTemporaryPrimitive=e=>{h.remove(e),e.geometry.dispose(),e.material.dispose()},this.clearTemporaryPrimitives=()=>{let e=0;return h.children.forEach(t=>{t.geometry.dispose(),t.material.dispose(),e++}),h.clear(),e},this.addBoundingBoxPrimitive=(t,n,r,i,a,o=void 0)=>{let s=m.findChildFromPath(t);s===void 0&&(s=m.createChildFromPath(t));let c=o||this.getBoundingBox();E.set(0,0,0);let l=E.subVectors(c.max,c.min),u=new e.BoxGeometry(l.x,l.y,l.z),d=s.createGeometryFromThreeJSGeometry(n,u,r,i,a,1e4);return l.addVectors(c.min,c.max).multiplyScalar(.5),d.setPosition(l.x,l.y,l.z),d},this.addSlicesPrimitive=(t,n,r,i,a,o=void 0)=>{if(n&&n.length>=3&&r&&r.length>=3){let s=m.findChildFromPath(t);s===void 0&&(s=m.createChildFromPath(t));let c=o||this.getBoundingBox();E.set(0,0,0);let l=E.subVectors(c.max,c.min),u=[`x`,`y`,`z`],d=[],f=0;return u.forEach(t=>{let o;switch(t){case`x`:o=new e.PlaneGeometry(l.z,l.y),o.rotateY(Math.PI/2);break;case`y`:o=new e.PlaneGeometry(l.x,l.z),o.rotateX(Math.PI/2);break;case`z`:o=new e.PlaneGeometry(l.x,l.y)}let c=s.createGeometryFromThreeJSGeometry(n[f],o,r[f],i,a,10001);d.push(c),f++}),l.addVectors(c.min,c.max).multiplyScalar(.5),d.forEach(e=>{e.setPosition(l.x,l.y,l.z)}),d}},this.enableMarkerCluster=e=>{e?(w.markerUpdateRequired=!0,w.enable()):(w.markerUpdateRequired=!1,w.disable()),this.forcePickableObjectsUpdate=!0},this.destroyAxisDisplay=()=>{this.displayMiniAxes=!1,T.main&&(this.enableAxisDisplay(!1,!1),T.main.forEach(e=>{e.dispose&&e.dispose()})),T.mini&&(this.enableAxisDisplay(!1,!0),T.mini.forEach(e=>{e.dispose&&e.dispose()})),T={main:[],mini:[]}},this.createAxisDisplay=(t=!1)=>{this.destroyAxisDisplay();let n=[{name:`x`,dir:new e.Vector3(1,0,0),colour:`red`,hex:16733525},{name:`y`,dir:new e.Vector3(0,1,0),colour:`green`,hex:5635925},{name:`z`,dir:new e.Vector3(0,0,1),colour:`blue`,hex:5592575}],r=this.getBoundingBox(),i=r.min.distanceTo(r.max),a=new e.Vector3(0,0,0);t&&a.copy(r.min),n.forEach(t=>{let n=new e.ArrowHelper(t.dir,a,i,t.hex);T.main.push(n);let o=new e.ArrowHelper(t.dir,r.getCenter(E),i/2,t.hex);T.mini.push(o);let s=F(t.name,.036,t.colour,`Asap`,120,700),c=t.dir.clone().multiplyScalar(i).add(a);s.position.set(c.x,c.y,c.z),T.main.push(s)})},this.enableAxisDisplay=(e,t=!1)=>{t&&T?.mini?.length?(this.displayMiniAxes=e,T.mini.forEach(t=>{e?p.add(t):p.remove(t)})):!t&&T.main&&T.main.forEach(t=>{e?f.add(t):f.remove(t)})}},On=function(t){let r=t,i,a,o=new e.Clock(!1);this.playAnimation=!0;let s=1e3,c={},l=0,u={},d=0,f={},p=0,m={},h=0,g,_,v,y,b=[],x=[],S=new e.Group,C,w,T=!1,E=!1;this.getDrawingWidth=()=>r?r.clientWidth:C?C.clientWidth===void 0?Math.round(C.width):Math.round(C.clientWidth):0,this.getDrawingHeight=()=>r?r.clientHeight:C?C.clientHeight===void 0?Math.round(C.height):Math.round(C.clientHeight):0,this.onWindowResize=()=>{a.onWindowResize();let t=this.getDrawingWidth(),n=this.getDrawingHeight();if(i!=null){let a;r?(a=r.getBoundingClientRect(),i.setSize(t,n)):C&&(C.getBoundingClientRect===void 0?i.setSize(t,n,!1):(a=C.getBoundingClientRect(),C.width=t,C.height=n,i.setSize(t,n,!1))),a&&(a.left,a.top);let o=new e.Vector2;i.getSize(o),o.x,o.y}},this.initialiseVisualisation=t=>{if(!E){if(t||={},t.antialias===void 0){let e=!1;try{/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)&&(e=!0)}catch{e=!1}e?t.antialias=!1:t.antialias=!0}t.canvas&&(r=void 0,C=t.canvas),i=new e.WebGLRenderer(t),r!==void 0&&r.appendChild(i.domElement),i.setClearColor(16777215,1),C&&C.style&&(C.style.height=`100%`,C.style.width=`100%`);let n=i.domElement;n.addEventListener(`webglcontextlost`,D,!1),n.addEventListener(`webglcontextrestored`,O,!1),i.autoClear=!1;let a=this.createScene(`default`);this.setCurrentScene(a),E=!0}};let D=e=>{e.preventDefault();for(let e of Object.keys(c))f.hasOwnProperty(e)&&f[e].call()},O=e=>{e.preventDefault();for(let e of Object.keys(c))m.hasOwnProperty(e)&&m[e].call()};this.getCurrentScene=()=>a,this.setCurrentScene=e=>{if(e){this.removeActiveScene(e);let t=a;a=e,t&&t.setInteractiveControlEnable(!1),a.setInteractiveControlEnable(!0),a.setAdditionalScenesGroup(S),this.onWindowResize()}},this.getSceneByName=e=>b[e],this.createScene=e=>{if(b[e]==null){let t;return t=C?new Dn(C,i):new Dn(r,i),b[e]=t,t.sceneName=e,t}},this.resetView=()=>{a.resetView()},this.viewAll=()=>{if(a){let e=a.getBoundingBox();if(e){for(let t=0;t<x.length;t++){let n=x[t].getBoundingBox();n&&e.union(n)}a.viewAllWithBoundingBox(e)}}},this.loadModelsURL=(e,t,n,r,i,o)=>{a.loadModelsURL(e,t,n,r,i,o)},this.loadViewURL=e=>{a.loadViewURL(e)},this.loadFromViewURL=(e,t)=>{a.loadFromViewURL(e,t)},this.updateDirectionalLight=()=>{a.updateDirectionalLight()};let k=()=>{T?(g=requestAnimationFrame(k),this.render()):(cancelAnimationFrame(g),g=void 0)};this.stopAnimate=()=>{T&&=(o.stop(),!1)},this.animate=()=>{T||(o.start(),T=!0,k())},this.addContextLostCallbackFunction=e=>(p+=1,f[p]=e,p),this.removeContextLostCallbackFunction=e=>{e in f&&delete f[e]},this.addContextRestoredCallbackFunction=e=>(h+=1,m[h]=e,h),this.removeContextRestoredCallbackFunction=e=>{e in h&&delete h[e]},this.addPreRenderCallbackFunction=e=>(l+=1,c[l]=e,l),this.removePreRenderCallbackFunction=e=>{e in c&&delete c[e]},this.addPostRenderCallbackFunction=e=>(d+=1,u[d]=e,d),this.removePostRenderCallbackFunction=e=>{e in u&&delete u[e]},this.getPlayRate=()=>s,this.setPlayRate=e=>{s=e},this.getCurrentTime=()=>a.getCurrentTime(),this.setMorphsTime=e=>{a.setMorphsTime(e)},this.getZincGeometryByID=e=>a.getZincGeometryByID(e),this.addToScene=e=>{a.addObject(e)},this.addToOrthoScene=t=>{if(v??=new e.Scene,_==null){let t=this.getDrawingWidth(),n=this.getDrawingHeight();_=new e.OrthographicCamera(-t/2,t/2,n/2,-n/2,1,10),_.position.z=10}v.add(t)};let A=t=>n=>{n.needsUpdate=!0;let r=new e.SpriteMaterial({map:n}),i=r.map.image.width,a=r.map.image.height;t.material=r,t.scale.set(i,a,1);let o=this.getDrawingWidth(),s=this.getDrawingHeight();t.position.set((o-i)/2,(-s+a)/2,1),this.addToOrthoScene(t)};this.addLogo=()=>{y=new e.Sprite,e.ImageUtils.loadTexture(`images/abi_big_logo_transparent_small.png`,void 0,A(y))},this.render=()=>{w||(r?r.clientWidth>0&&r.clientHeight>0&&(w=new n.ResizeSensor(r,this.onWindowResize)):C&&C.width>0&&C.height>0&&(w=new n.ResizeSensor(C,this.onWindowResize)));let e=o.getDelta();a.renderGeometries(s,e,this.playAnimation);for(let t=0;t<x.length;t++)x[t].renderGeometries(s,e,this.playAnimation);_!=null&&v!=null&&(i.clearDepth(),i.render(v,_));for(let e of Object.keys(c))c.hasOwnProperty(e)&&c[e].call();a.render(i);for(let e of Object.keys(u))u.hasOwnProperty(e)&&u[e].call()},this.forceContextLoss=()=>{i.forceContextLoss()},this.forceContextRestore=()=>{i.forceContextRestore()},this.getThreeJSRenderer=()=>i,this.isSceneActive=e=>{if(a===e)return!0;for(let t=0;t<x.length;t++)if(x[t]===e)return!0;return!1},this.addActiveScene=e=>{this.isSceneActive(e)||(x.push(e),S.add(e.getThreeJSScene()))},this.removeActiveScene=e=>{for(let t=0;t<x.length;t++)if(x[t]===e){x.splice(t,1),S.remove(e.getThreeJSScene());return}},this.clearAllActiveScene=()=>{for(let e=0;e<x.length;e++)S.remove(x[e].getThreeJSScene());x.splice(0,x.length)},this.dispose=()=>{T&&cancelAnimationFrame(g);for(let e in b)b.hasOwnProperty(e)&&b[e].clearAll();b=[],x=[],S=new e.Group,this.stopAnimate(),c={},l=0,u={},u=0,f={},p=0,m={},h=0,_=void 0,v=void 0,y=void 0;let t=this.createScene(`default`);this.setCurrentScene(t),w=void 0,i?.dispose()},this.transitionScene=(e,t)=>{if(a){let n=a.getZincCameraControls(),r=e.getBoundingBox();if(r){let e=r.min.distanceTo(r.max)/2,i=(r.min.x+r.max.x)/2,a=(r.min.y+r.max.y)/2,o=(r.min.z+r.max.z)/2,s=n.getViewportFromCentreAndRadius(i,a,o,e,40,e*4),c=n.getCurrentViewport();n.cameraTransition(c,s,t),n.enableCameraTransition()}}},this.isWebGL2=()=>i?i.capabilities.isWebGL2:!1},kn=class{esize;ecode;edata;littleEndian;constructor(e,t,n,r){if(e%16!=0)throw Error(`This does not appear to be a NIFTI extension`);this.esize=e,this.ecode=t,this.edata=n,this.littleEndian=r}toArrayBuffer(){let e=new Uint8Array(this.esize),t=new Uint8Array(this.edata);e.set(t,8);let n=new DataView(e.buffer);return n.setInt32(0,this.esize,this.littleEndian),n.setInt32(4,this.ecode,this.littleEndian),e.buffer}},X=class e{static crcTable=null;static GUNZIP_MAGIC_COOKIE1=31;static GUNZIP_MAGIC_COOKIE2=139;static getStringAt(e,t,n){var r=``,i,a;for(i=t;i<n;i+=1)a=e.getUint8(i),a!==0&&(r+=String.fromCharCode(a));return r}static getByteAt=function(e,t){return e.getUint8(t)};static getShortAt=function(e,t,n){return e.getInt16(t,n)};static getIntAt(e,t,n){return e.getInt32(t,n)}static getFloatAt(e,t,n){return e.getFloat32(t,n)}static getDoubleAt(e,t,n){return e.getFloat64(t,n)}static getInt64At(e,t,n){let r=e.getUint32(t,n),i=e.getInt32(t+4,n),a;return a=n?i*2**32+r:r*2**32+i,i<0&&(a+=-1*2**32*2**32),a}static getUint64At(e,t,n){let r=e.getUint32(t+(n?0:4),n),i=e.getUint32(t+(n?4:0),n);return n?i*2**32+r:r*2**32+i}static getExtensionsAt(t,n,r,i){let a=[],o=n;for(;o<i;){let n=r,s=e.getIntAt(t,o,r);if(!s)break;if(s+o>i&&(n=!n,s=e.getIntAt(t,o,n),s+o>i))throw Error(`This does not appear to be a valid NIFTI extension`);if(s%16!=0)throw Error(`This does not appear to be a NIFTI extension`);let c=e.getIntAt(t,o+4,n),l=t.buffer.slice(o+8,o+s),u=new kn(s,c,l,n);a.push(u),o+=s}return a}static toArrayBuffer(e){var t=new ArrayBuffer(e.length),n=new Uint8Array(t),r;for(r=0;r<e.length;r+=1)n[r]=e[r];return t}static isString(e){return typeof e==`string`||e instanceof String}static formatNumber(t,n=void 0){let r;return r=e.isString(t)?Number(t):t,r=n?r.toPrecision(5):r.toPrecision(7),parseFloat(r)}static makeCRCTable(){let e,t=[];for(var n=0;n<256;n++){e=n;for(var r=0;r<8;r++)e=e&1?3988292384^e>>>1:e>>>1;t[n]=e}return t}static crc32(t){e.crcTable||=e.makeCRCTable();let n=e.crcTable,r=-1;for(var i=0;i<t.byteLength;i++)r=r>>>8^n[(r^t.getUint8(i))&255];return(r^-1)>>>0}},Z=class e{littleEndian=!1;dim_info=0;dims=[];intent_p1=0;intent_p2=0;intent_p3=0;intent_code=0;datatypeCode=0;numBitsPerVoxel=0;slice_start=0;slice_end=0;slice_code=0;pixDims=[];vox_offset=0;scl_slope=1;scl_inter=0;xyzt_units=0;cal_max=0;cal_min=0;slice_duration=0;toffset=0;description=``;aux_file=``;intent_name=``;qform_code=0;sform_code=0;quatern_a=0;quatern_b=0;quatern_c=0;quatern_d=0;qoffset_x=0;qoffset_y=0;qoffset_z=0;affine=[[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1]];qfac=1;quatern_R;magic=`0`;isHDR=!1;extensionFlag=[0,0,0,0];extensionSize=0;extensionCode=0;extensions=[];static TYPE_NONE=0;static TYPE_BINARY=1;static TYPE_UINT8=2;static TYPE_INT16=4;static TYPE_INT32=8;static TYPE_FLOAT32=16;static TYPE_COMPLEX64=32;static TYPE_FLOAT64=64;static TYPE_RGB24=128;static TYPE_INT8=256;static TYPE_UINT16=512;static TYPE_UINT32=768;static TYPE_INT64=1024;static TYPE_UINT64=1280;static TYPE_FLOAT128=1536;static TYPE_COMPLEX128=1792;static TYPE_COMPLEX256=2048;static XFORM_UNKNOWN=0;static XFORM_SCANNER_ANAT=1;static XFORM_ALIGNED_ANAT=2;static XFORM_TALAIRACH=3;static XFORM_MNI_152=4;static SPATIAL_UNITS_MASK=7;static TEMPORAL_UNITS_MASK=56;static UNITS_UNKNOWN=0;static UNITS_METER=1;static UNITS_MM=2;static UNITS_MICRON=3;static UNITS_SEC=8;static UNITS_MSEC=16;static UNITS_USEC=24;static UNITS_HZ=32;static UNITS_PPM=40;static UNITS_RADS=48;static MAGIC_COOKIE=348;static STANDARD_HEADER_SIZE=348;static MAGIC_NUMBER_LOCATION=344;static MAGIC_NUMBER=[110,43,49];static MAGIC_NUMBER2=[110,105,49];static EXTENSION_HEADER_SIZE=8;readHeader(t){var n=new DataView(t),r=X.getIntAt(n,0,this.littleEndian),i,a,o,s;if(r!==e.MAGIC_COOKIE&&(this.littleEndian=!0,r=X.getIntAt(n,0,this.littleEndian)),r!==e.MAGIC_COOKIE)throw Error(`This does not appear to be a NIFTI file!`);for(this.dim_info=X.getByteAt(n,39),i=0;i<8;i+=1)s=40+i*2,this.dims[i]=X.getShortAt(n,s,this.littleEndian);for(this.intent_p1=X.getFloatAt(n,56,this.littleEndian),this.intent_p2=X.getFloatAt(n,60,this.littleEndian),this.intent_p3=X.getFloatAt(n,64,this.littleEndian),this.intent_code=X.getShortAt(n,68,this.littleEndian),this.datatypeCode=X.getShortAt(n,70,this.littleEndian),this.numBitsPerVoxel=X.getShortAt(n,72,this.littleEndian),this.slice_start=X.getShortAt(n,74,this.littleEndian),i=0;i<8;i+=1)s=76+i*4,this.pixDims[i]=X.getFloatAt(n,s,this.littleEndian);if(this.vox_offset=X.getFloatAt(n,108,this.littleEndian),this.scl_slope=X.getFloatAt(n,112,this.littleEndian),this.scl_inter=X.getFloatAt(n,116,this.littleEndian),this.slice_end=X.getShortAt(n,120,this.littleEndian),this.slice_code=X.getByteAt(n,122),this.xyzt_units=X.getByteAt(n,123),this.cal_max=X.getFloatAt(n,124,this.littleEndian),this.cal_min=X.getFloatAt(n,128,this.littleEndian),this.slice_duration=X.getFloatAt(n,132,this.littleEndian),this.toffset=X.getFloatAt(n,136,this.littleEndian),this.description=X.getStringAt(n,148,228),this.aux_file=X.getStringAt(n,228,252),this.qform_code=X.getShortAt(n,252,this.littleEndian),this.sform_code=X.getShortAt(n,254,this.littleEndian),this.quatern_b=X.getFloatAt(n,256,this.littleEndian),this.quatern_c=X.getFloatAt(n,260,this.littleEndian),this.quatern_d=X.getFloatAt(n,264,this.littleEndian),this.quatern_a=Math.sqrt(1-(this.quatern_b**2+this.quatern_c**2+this.quatern_d**2)),this.qoffset_x=X.getFloatAt(n,268,this.littleEndian),this.qoffset_y=X.getFloatAt(n,272,this.littleEndian),this.qoffset_z=X.getFloatAt(n,276,this.littleEndian),this.qform_code<1&&this.sform_code<1&&(this.affine[0][0]=this.pixDims[1],this.affine[1][1]=this.pixDims[2],this.affine[2][2]=this.pixDims[3]),this.qform_code>0&&this.sform_code<this.qform_code){let e=this.quatern_a,t=this.quatern_b,n=this.quatern_c,r=this.quatern_d;for(this.qfac=this.pixDims[0]===0?1:this.pixDims[0],this.quatern_R=[[e*e+t*t-n*n-r*r,2*t*n-2*e*r,2*t*r+2*e*n],[2*t*n+2*e*r,e*e+n*n-t*t-r*r,2*n*r-2*e*t],[2*t*r-2*e*n,2*n*r+2*e*t,e*e+r*r-n*n-t*t]],a=0;a<3;a+=1)for(o=0;o<3;o+=1)this.affine[a][o]=this.quatern_R[a][o]*this.pixDims[o+1],o===2&&(this.affine[a][o]*=this.qfac);this.affine[0][3]=this.qoffset_x,this.affine[1][3]=this.qoffset_y,this.affine[2][3]=this.qoffset_z}else if(this.sform_code>0)for(a=0;a<3;a+=1)for(o=0;o<4;o+=1)s=280+(a*4+o)*4,this.affine[a][o]=X.getFloatAt(n,s,this.littleEndian);if(this.affine[3][0]=0,this.affine[3][1]=0,this.affine[3][2]=0,this.affine[3][3]=1,this.intent_name=X.getStringAt(n,328,344),this.magic=X.getStringAt(n,344,348),this.isHDR=this.magic===String.fromCharCode.apply(null,e.MAGIC_NUMBER2),n.byteLength>e.MAGIC_COOKIE){this.extensionFlag[0]=X.getByteAt(n,348),this.extensionFlag[1]=X.getByteAt(n,349),this.extensionFlag[2]=X.getByteAt(n,350),this.extensionFlag[3]=X.getByteAt(n,351);let e=!0;!this.isHDR&&this.vox_offset<=352&&(e=!1),n.byteLength<=368&&(e=!1),e&&this.extensionFlag[0]&&(this.extensions=X.getExtensionsAt(n,this.getExtensionLocation(),this.littleEndian,this.vox_offset),this.extensionSize=this.extensions[0].esize,this.extensionCode=this.extensions[0].ecode)}}toFormattedString(){var t=X.formatNumber,n=``;return n+=`Dim Info = `+this.dim_info+`
292
292
  `,n+=`Image Dimensions (1-8): `+this.dims[0]+`, `+this.dims[1]+`, `+this.dims[2]+`, `+this.dims[3]+`, `+this.dims[4]+`, `+this.dims[5]+`, `+this.dims[6]+`, `+this.dims[7]+`
293
293
  `,n+=`Intent Parameters (1-3): `+this.intent_p1+`, `+this.intent_p2+`, `+this.intent_p3+`
294
294
  `,n+=`Intent Code = `+this.intent_code+`