zincjs 2.3.1-beta.0 → 2.4.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,4 +1,4 @@
|
|
|
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.1-beta.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.185.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`,R(new e.BufferAttribute(r,3),t.vertices)),t.normals.length>0){let r=new Float32Array(t.normals.length*3);n.setAttribute(`normal`,R(new e.BufferAttribute(r,3),t.normals))}if(t.colors.length>0){let r=new Float32Array(t.colors.length*3);n.setAttribute(`color`,R(new e.BufferAttribute(r,3),t.colors))}if(t.uvs.length>0){let r=new Float32Array(t.uvs.length*2);n.setAttribute(`uv`,L(new e.BufferAttribute(r,2),t.uvs))}if(t.uvs2.length>0){let r=new Float32Array(t.uvs2.length*2);n.setAttribute(`uv2`,L(new e.BufferAttribute(r,2),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(r,n.data))}n.morphAttributes[r]=i}if(t.skinIndices.length>0){let r=new e.Float32BufferAttribute(t.skinIndices.length*4,4);z(r,t.skinIndices),n.setAttribute(`skinIndex`,r)}if(t.skinWeights.length>0){let r=new e.Float32BufferAttribute(t.skinWeights.length*4,4);z(r,t.skinWeights),n.setAttribute(`skinWeight`,r)}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`,R(new e.BufferAttribute(n,3),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`,te(new e.BufferAttribute(r,3),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(R(a,i.vertices)),i.normals){let t=new e.Float32BufferAttribute(i.normals.length*3,3);t.name=i.name,r.push(R(t,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);R(t,r.vertices);let i=new e.Float32BufferAttribute(r.colors.length*3,3);if(te(i,r.colors),n.setAttribute(`position`,t),n.setAttribute(`color`,i),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}function L(e,t){let n=e.array,r=0;for(let e=0;e<t.length;e++){let i=t[e];n[r++]=i.x,n[r++]=i.y}return e.needsUpdate=!0,e}function R(e,t){let n=e.array,r=0;for(let e=0;e<t.length;e++){let i=t[e];n[r++]=i.x,n[r++]=i.y,n[r++]=i.z}return e.needsUpdate=!0,e}function z(e,t){let n=e.array,r=0;for(let e=0;e<t.length;e++){let i=t[e];n[r++]=i.x,n[r++]=i.y,n[r++]=i.z,n[r++]=i.w}return e.needsUpdate=!0,e}function te(e,t){let n=e.array,r=0;for(let e=0;e<t.length;e++){let i=t[e];n[r++]=i.r,n[r++]=i.g,n[r++]=i.b}return e.needsUpdate=!0,e}var ne=function(e){e.vertexShader=e.vertexShader.replace(`#include <morphcolor_vertex>`,`
|
|
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.4.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.185.1`,"three-spritetext":`1.10.0`}},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`,R(new e.BufferAttribute(r,3),t.vertices)),t.normals.length>0){let r=new Float32Array(t.normals.length*3);n.setAttribute(`normal`,R(new e.BufferAttribute(r,3),t.normals))}if(t.colors.length>0){let r=new Float32Array(t.colors.length*3);n.setAttribute(`color`,R(new e.BufferAttribute(r,3),t.colors))}if(t.uvs.length>0){let r=new Float32Array(t.uvs.length*2);n.setAttribute(`uv`,L(new e.BufferAttribute(r,2),t.uvs))}if(t.uvs2.length>0){let r=new Float32Array(t.uvs2.length*2);n.setAttribute(`uv2`,L(new e.BufferAttribute(r,2),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(r,n.data))}n.morphAttributes[r]=i}if(t.skinIndices.length>0){let r=new e.Float32BufferAttribute(t.skinIndices.length*4,4);z(r,t.skinIndices),n.setAttribute(`skinIndex`,r)}if(t.skinWeights.length>0){let r=new e.Float32BufferAttribute(t.skinWeights.length*4,4);z(r,t.skinWeights),n.setAttribute(`skinWeight`,r)}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`,R(new e.BufferAttribute(n,3),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`,te(new e.BufferAttribute(r,3),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(R(a,i.vertices)),i.normals){let t=new e.Float32BufferAttribute(i.normals.length*3,3);t.name=i.name,r.push(R(t,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);R(t,r.vertices);let i=new e.Float32BufferAttribute(r.colors.length*3,3);if(te(i,r.colors),n.setAttribute(`position`,t),n.setAttribute(`color`,i),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=10001,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}function L(e,t){let n=e.array,r=0;for(let e=0;e<t.length;e++){let i=t[e];n[r++]=i.x,n[r++]=i.y}return e.needsUpdate=!0,e}function R(e,t){let n=e.array,r=0;for(let e=0;e<t.length;e++){let i=t[e];n[r++]=i.x,n[r++]=i.y,n[r++]=i.z}return e.needsUpdate=!0,e}function z(e,t){let n=e.array,r=0;for(let e=0;e<t.length;e++){let i=t[e];n[r++]=i.x,n[r++]=i.y,n[r++]=i.z,n[r++]=i.w}return e.needsUpdate=!0,e}function te(e,t){let n=e.array,r=0;for(let e=0;e<t.length;e++){let i=t[e];n[r++]=i.r,n[r++]=i.g,n[r++]=i.b}return e.needsUpdate=!0,e}var ne=function(e){e.vertexShader=e.vertexShader.replace(`#include <morphcolor_vertex>`,`
|
|
2
2
|
#if defined( USE_MORPHCOLORS )
|
|
3
3
|
|
|
4
4
|
// morphTargetBaseInfluence is set based on BufferGeometry.morphTargetsRelative value:
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
#endif
|
|
27
|
-
`)},re=new e.Vector3,ie=new e.Vector3,ae=new e.Matrix4,oe=new e.Ray,se=new e.Sphere,ce=new e.Vector3,le=new e.Vector3,ue=new e.Vector3,de=new e.Vector3,fe=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++)re.fromBufferAttribute(n,e-1),ie.fromBufferAttribute(n,e),r[e]=r[e-1],r[e]+=re.distanceTo(ie);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(),se.copy(r.boundingSphere),se.applyMatrix4(i),se.radius+=a,t.ray.intersectsSphere(se)===!1)return;ae.copy(i).invert(),oe.copy(t.ray).applyMatrix4(ae);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(B(u,d,this,i,s,r,a),oe.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(B(u,d,this,i,s,a,a+1),oe.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 B(e,t,n,r,i,a,o){e.fromBufferAttribute(r,a),t.fromBufferAttribute(r,o);var s=n.morphTargetInfluences;if(i&&s){ce.set(0,0,0),le.set(0,0,0);for(var c=0,l=i.length;c<l;c++){var u=s[c],d=i[c];u!==0&&(ue.fromBufferAttribute(d,a),de.fromBufferAttribute(d,o),ce.addScaledVector(ue.sub(e),u),le.addScaledVector(de.sub(t),u))}e.add(ce),t.add(le)}}fe.prototype.isLine=!0;var pe=new e.Vector3,me=new e.Vector3,he=class extends fe{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)pe.fromBufferAttribute(n,e),me.fromBufferAttribute(n,e+1),r[e]=e===0?0:r[e-1],r[e+1]=r[e]+pe.distanceTo(me);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}};he.prototype.isLineSegments=!0;var ge=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 he(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)})}},_e=`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`,ve=new Image(128,128);ve.src=_e;var ye=new e.Texture;ye.image=ve,ye.needsUpdate=!0;var be=[.02,.03,1],xe=new e.SpriteMaterial({map:ye,alphaTest:.5,transparent:!0,depthTest:!1,depthWrite:!1,sizeAttenuation:!1}),Se=function(t){Object.getPrototypeOf(this)!==V.prototype&&Object.setPrototypeOf(Se.prototype,V.prototype),V.call(this),this.texture=ye;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(xe),n.center.set(.5,0),this.morph.add(n),this.morph.position.set(0,0,0),this.morph.renderOrder=1e4,n.scale.set(be[0],be[1],be[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()},Ce=0,we=function(){return`pr`+Ce++},V=function(){this.isZincObject=!0,this.geometry=void 0,this.morph=void 0,this.group=new e.Group,this._lod=new ge(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.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=we(),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};V.prototype.setDuration=function(e){this.duration=e,this.clipAction&&this.clipAction.setDuration(this.duration)},V.prototype.getDuration=function(){return this.duration},V.prototype.setRegion=function(e){this.region=e},V.prototype.getRegion=function(){return this.region},V.prototype.getMorph=function(){return this._lod.getCurrentMorph()||this.morph},V.prototype.getGroup=function(){return this.group},V.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)},V.prototype.checkTransparentMesh=function(){},V.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},V.prototype.setIsPickable=function(e){this.isPickable!==e&&(this.isPickable=e,this.region&&(this.region.pickableUpdateRequired=!0))},V.prototype.setAnatomicalId=function(e){this.anatomicalId=e},V.prototype.setName=function(e){this.groupName=e,this._lod.setName(e)},V.prototype.getCurrentTime=function(){if(this.clipAction){let e=this.clipAction.time/this.clipAction._clip.duration;return this.duration*e}return this.inbuildTime},V.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))},V.prototype.isTimeVarying=function(){return!!(this.timeEnabled||this.morphColour)},V.prototype.getVisibility=function(){return this.visible},V.prototype.setVisibility=function(e){e!==this.visible&&(this.visible=e,this.group.visible=e,this.region&&(this.region.pickableUpdateRequired=!0))},V.prototype.setAlpha=function(e){let t=this._lod._material,n=!1;e<1&&(n=!0),t.opacity=e,t.transparent=n,this.checkTransparentMesh()},V.prototype.setFrustumCulled=function(e){this._lod.setFrustumCulled(e)},V.prototype.setVertexColors=function(e){this._lod.setVertexColors(e)},V.prototype.getColour=function(){if(this._lod._material)return this._lod._material.color},V.prototype.setColour=function(e){this._lod.setColour(e)},V.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},V.prototype.getColourHex=function(){if(!this.morphColour&&this._lod._material&&this._lod._material.color)return this._lod._material.color.getHexString()},V.prototype.setColourHex=function(e){this._lod._material.color.setHex(e),this._lod._secondaryMaterial&&this._lod._secondaryMaterial.color.setHex(e)},V.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)},V.prototype.setMaterial=function(e){this._lod.setMaterial(e)},V.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},V.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},V.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}},V.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},V.prototype.markerIsRequired=function(e){return!!(this.visible&&(this.markerMode===`on`||e&&e.displayMarkers&&this.markerMode===`inherited`))},V.prototype.updateMarker=function(e,t){if(e==0&&this.markerIsRequired(t)){let e=t.ndcToBeUpdated;if(this.groupName){if(this.marker||(this.marker=new Se(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},V.prototype.processMarkerVisual=function(e,t){this.marker&&this.marker.isEnabled()&&this.marker.updateVisual(e,t)},V.prototype.initiateMorphColor=function(){this.morphColour==1&&this._lod.updateMorphColorAttribute(!1)},V.prototype.setRenderOrder=function(e){this._lod.setRenderOrder(e)},V.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}}},V.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)},V.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)},V.prototype.addLOD=function(e,t,n,r,i){this._lod.addLevelFromURL(e,t,n,r,i)},V.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},V.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},V.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)},V.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))},V.prototype.setScaleAll=function(e){let t=this.getGroup();t&&(t.scale.set(e,e,e),t.updateMatrix(),this.boundingBoxUpdateRequired=!0)};var Te=(t,n,r)=>{let i=k(t,r),a=!1;1>r.opacity&&(a=!0);let o;if(i._video===void 0)o=n||new e.MeshPhongMaterial({color:r.colour,vertexColors:!1,transparent:a,opacity:r.opacity,side:e.DoubleSide}),r.localMorphColour&&i.morphAttributes.color&&(o.vertexColors=!0,o.onBeforeCompile=ne);else{let t=i._video.createCanvasVideoTexture();o=new e.MeshBasicMaterial({color:new e.Color(1,1,1),transparent:a,opacity:r.opacity,map:t,side:e.DoubleSide})}return new e.Mesh(i,o)},Ee=function(){V.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=Te(e,t,n);this.videoHandler=r.geometry._video,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}}},this.isTimeVarying=function(){return!!(this.timeEnabled||this.morphColour||this.videoHandler)}};Ee.prototype=Object.create(V.prototype);var De=t.default.default||t.default,Oe=function(t,n){let r=t,i,a=500;i=n?new De(r,.012,n.getStyle()):new De(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},ke=function(t,n,r,i){V.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 Oe(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}};ke.prototype=Object.create(V.prototype);function Ae(){}Ae.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(Ae.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=Ae.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`video`: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 je=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){let r=e/t*n.video.duration;Number.isFinite(r)||(r=0),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()},Me=e.AnimationClip,Ne=e.Color,Pe=e.DefaultLoadingManager,Fe=e.FileLoader,Ie=e.LoaderUtils,Le=e.Vector2,Re=e.Vector3,ze=e.Vector4;function Be(e){typeof e==`boolean`&&(console.warn(`THREE.JSONLoader: showStatus parameter has been removed from constructor.`),e=void 0),this.manager=e===void 0?Pe:e,this.withCredentials=!1,this.paramsString=``}Object.assign(Be.prototype,{load:function(e,t,n,r){var i=this,a=this.texturePath&&typeof this.texturePath==`string`?this.texturePath:Ie.extractUrlBase(e),o=new Fe(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 Re,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 Le(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 Re(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 Ne(T)),r!==0&&w.vertexColors.push(new Ne(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 Le(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 Re(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 Ne(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 ze(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 ze(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 Re;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 Re;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=Me.parseAnimation(r[i],t.bones);a&&n.push(a)}if(t.morphTargets){var o=Me.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=Ae.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 je(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 Ve=function(){V.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 Be;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,this.boundingBoxUpdateRequired=!0,this.morph.computeBoundingSphere()},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),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 ke(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.addCustomGlyph=e=>{e.isGlyph&&t.push(e),this.ready=!0,this.boundingBoxUpdateRequired=!0},this.addMeshAsGlyph=(e,n)=>{if(e.isMesh){let r=new ke(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)}};Ve.prototype=Object.create(V.prototype);var He=new e.Matrix4,Ue=new e.Ray,We=new e.Sphere,Ge=new e.Vector3,Ke=new e.Vector3,qe=new e.Vector3,Je=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(),We.copy(n.boundingSphere),We.applyMatrix4(r),We.radius+=i,e.ray.intersectsSphere(We)===!1)return;He.copy(r).invert(),Ue.copy(e.ray).applyMatrix4(He);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);Xe(this,o,c,n),Ye(Ge,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++)Xe(this,o,c,a),Ye(Ge,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.`)}}};Je.prototype.isPoints=!0;function Ye(t,n,r,i,a,o,s){let c=Ue.distanceSqToPoint(t);if(c<r){let r=new e.Vector3;Ue.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 Xe(e,t,n,r){Ge.fromBufferAttribute(t,r);let i=e.morphTargetInfluences;if(e.material.morphTargets&&n&&i){Ke.set(0,0,0);for(var a=0,o=n.length;a<o;a++){let e=i[a],t=n[a];e!==0&&(qe.fromBufferAttribute(t,r),Ke.addScaledVector(qe.sub(Ge),e))}Ge.add(Ke)}}var Ze=function(){V.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);console.log(r,n),n.localMorphColour&&r.morphAttributes.color&&(t.vertexColors=!0,t.onBeforeCompile=ne),t.map=P();let i=new Je(r,t);this.setMesh(i,n.localTimeEnabled,n.localMorphColour)}};let o=(o,s,c,l)=>{if(c){let u=new Oe(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 Ze.prototype.deleteVertices.call(this,e)&&s(e),this.drawRange},this.setName=function(e){let n=this.groupName;Ze.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),Ze.prototype.render.call(this,e,t,n,r)}};Ze.prototype=Object.create(V.prototype);var Qe=function(){V.call(this),this.isLines=!0,this.createLineSegment=(e,t,n)=>{if(e&&t){let r=k(e,n);n.localMorphColour&&r.morphAttributes.color&&(t.vertexColors=!0,t.onBeforeCompile=ne);let i=new he(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)}}};Qe.prototype=Object.create(V.prototype);var $e=function(){this.isTexture=!0,this.impl=void 0,this.isLoading=!1,this.size={width:1,height:1,depth:0}};$e.prototype.loadImage=function(e,t){return new Promise((n,r)=>{e.onload=()=>n(e),e.onerror=r,e.src=t})},$e.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}},$e.prototype.loadFromImages=async function(e){},$e.prototype.isReady=function(){return!!(this.impl&&!this.isLoading)},$e.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 et=function(){$e.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.DataArrayTexture(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}}};et.prototype=Object.create($e.prototype);var tt=e.GLSL3,nt=`
|
|
27
|
+
`)},re=new e.Vector3,ie=new e.Vector3,ae=new e.Matrix4,oe=new e.Ray,se=new e.Sphere,ce=new e.Vector3,le=new e.Vector3,ue=new e.Vector3,de=new e.Vector3,fe=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++)re.fromBufferAttribute(n,e-1),ie.fromBufferAttribute(n,e),r[e]=r[e-1],r[e]+=re.distanceTo(ie);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(),se.copy(r.boundingSphere),se.applyMatrix4(i),se.radius+=a,t.ray.intersectsSphere(se)===!1)return;ae.copy(i).invert(),oe.copy(t.ray).applyMatrix4(ae);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(B(u,d,this,i,s,r,a),oe.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(B(u,d,this,i,s,a,a+1),oe.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 B(e,t,n,r,i,a,o){e.fromBufferAttribute(r,a),t.fromBufferAttribute(r,o);var s=n.morphTargetInfluences;if(i&&s){ce.set(0,0,0),le.set(0,0,0);for(var c=0,l=i.length;c<l;c++){var u=s[c],d=i[c];u!==0&&(ue.fromBufferAttribute(d,a),de.fromBufferAttribute(d,o),ce.addScaledVector(ue.sub(e),u),le.addScaledVector(de.sub(t),u))}e.add(ce),t.add(le)}}fe.prototype.isLine=!0;var pe=new e.Vector3,me=new e.Vector3,he=class extends fe{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)pe.fromBufferAttribute(n,e),me.fromBufferAttribute(n,e+1),r[e]=e===0?0:r[e-1],r[e+1]=r[e]+pe.distanceTo(me);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}};he.prototype.isLineSegments=!0;var ge=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 he(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)})}},_e=new e.TextureLoader().load(`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`);_e.colorSpace=e.SRGBColorSpace;var ve=[.02,.03,1],ye=new e.SpriteMaterial({map:_e,alphaTest:.5,transparent:!0,depthTest:!1,depthWrite:!1,sizeAttenuation:!1}),be=function(t){Object.getPrototypeOf(this)!==V.prototype&&Object.setPrototypeOf(be.prototype,V.prototype),V.call(this),this.texture=_e;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(ye),n.center.set(.5,0),this.morph.add(n),this.morph.position.set(0,0,0),this.morph.renderOrder=1e4,n.scale.set(ve[0],ve[1],ve[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),u.renderOrder=10001,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()},xe=0,Se=function(){return`pr`+xe++},V=function(){this.isZincObject=!0,this.geometry=void 0,this.morph=void 0,this.group=new e.Group,this._lod=new ge(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.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=Se(),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};V.prototype.setDuration=function(e){this.duration=e,this.clipAction&&this.clipAction.setDuration(this.duration)},V.prototype.getDuration=function(){return this.duration},V.prototype.setRegion=function(e){this.region=e},V.prototype.getRegion=function(){return this.region},V.prototype.getMorph=function(){return this._lod.getCurrentMorph()||this.morph},V.prototype.getGroup=function(){return this.group},V.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)},V.prototype.checkTransparentMesh=function(){},V.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},V.prototype.setIsPickable=function(e){this.isPickable!==e&&(this.isPickable=e,this.region&&(this.region.pickableUpdateRequired=!0))},V.prototype.setAnatomicalId=function(e){this.anatomicalId=e},V.prototype.setName=function(e){this.groupName=e,this._lod.setName(e)},V.prototype.getCurrentTime=function(){if(this.clipAction){let e=this.clipAction.time/this.clipAction._clip.duration;return this.duration*e}return this.inbuildTime},V.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))},V.prototype.isTimeVarying=function(){return!!(this.timeEnabled||this.morphColour)},V.prototype.getVisibility=function(){return this.visible},V.prototype.setVisibility=function(e){e!==this.visible&&(this.visible=e,this.group.visible=e,this.region&&(this.region.pickableUpdateRequired=!0))},V.prototype.setAlpha=function(e){let t=this._lod._material,n=!1;e<1&&(n=!0),t.opacity=e,t.transparent=n,this.checkTransparentMesh()},V.prototype.setFrustumCulled=function(e){this._lod.setFrustumCulled(e)},V.prototype.setVertexColors=function(e){this._lod.setVertexColors(e)},V.prototype.getColour=function(){if(this._lod._material)return this._lod._material.color},V.prototype.setColour=function(e){this._lod.setColour(e)},V.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},V.prototype.getColourHex=function(){if(!this.morphColour&&this._lod._material&&this._lod._material.color)return this._lod._material.color.getHexString()},V.prototype.setColourHex=function(e){this._lod._material.color.setHex(e),this._lod._secondaryMaterial&&this._lod._secondaryMaterial.color.setHex(e)},V.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)},V.prototype.setMaterial=function(e){this._lod.setMaterial(e)},V.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},V.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},V.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}},V.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},V.prototype.markerIsRequired=function(e){return!!(this.visible&&(this.markerMode===`on`||e&&e.displayMarkers&&this.markerMode===`inherited`))},V.prototype.updateMarker=function(e,t){if(e==0&&this.markerIsRequired(t)){let e=t.ndcToBeUpdated;if(this.groupName){if(this.marker||(this.marker=new be(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},V.prototype.processMarkerVisual=function(e,t){this.marker&&this.marker.isEnabled()&&this.marker.updateVisual(e,t)},V.prototype.initiateMorphColor=function(){this.morphColour==1&&this._lod.updateMorphColorAttribute(!1)},V.prototype.setRenderOrder=function(e){this._lod.setRenderOrder(e)},V.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}}},V.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)},V.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)},V.prototype.addLOD=function(e,t,n,r,i){this._lod.addLevelFromURL(e,t,n,r,i)},V.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},V.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},V.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)},V.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))},V.prototype.setScaleAll=function(e){let t=this.getGroup();t&&(t.scale.set(e,e,e),t.updateMatrix(),this.boundingBoxUpdateRequired=!0)};var Ce=(t,n,r)=>{let i=k(t,r),a=!1;1>r.opacity&&(a=!0);let o;if(i._video===void 0)o=n||new e.MeshPhongMaterial({color:r.colour,vertexColors:!1,transparent:a,opacity:r.opacity,side:e.DoubleSide}),r.localMorphColour&&i.morphAttributes.color&&(o.vertexColors=!0,o.onBeforeCompile=ne);else{let t=i._video.createCanvasVideoTexture();o=new e.MeshBasicMaterial({color:new e.Color(1,1,1),transparent:a,opacity:r.opacity,map:t,side:e.DoubleSide})}return new e.Mesh(i,o)},we=function(){V.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=Ce(e,t,n);this.videoHandler=r.geometry._video,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}}},this.isTimeVarying=function(){return!!(this.timeEnabled||this.morphColour||this.videoHandler)}};we.prototype=Object.create(V.prototype);var Te=t.default.default||t.default,Ee=function(t,n){let r=t,i,a=1,o=500,s=.012;i=n?new Te(r,s,n.getStyle()):new Te(r,s),i.fontFace=`Asap`,i.fontSize=90,i.fontWeight=o,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,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.textHeight=s*e,a=e)},this.setFontWeight=e=>{e&&e!==o&&(i.fontWeight=e,o=e)},this.setText=e=>{if(e&&e!==i.text){if(i._canvas,i.material&&i.material.map&&i.material.map.dispose(),i._canvas){let e=i._canvas.getContext(`2d`);e&&e.clearRect(0,0,i._canvas.width,i._canvas.height),i._canvas.width=1,i._canvas.height=1}i.text=e,i.textHeight=s*a,r=e,i.material&&i.material.map&&(i.material.map.needsUpdate=!0)}},this.setVisibility=e=>{i.visible=e},this.dispose=()=>{},this.getSprite=()=>i,this.getString=()=>r},De=function(t,n,r,i){V.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 Ee(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}};De.prototype=Object.create(V.prototype);function Oe(){}Oe.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(Oe.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=Oe.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`video`: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 ke=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){let r=e/t*n.video.duration;Number.isFinite(r)||(r=0),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()},Ae=e.AnimationClip,je=e.Color,Me=e.DefaultLoadingManager,Ne=e.FileLoader,Pe=e.LoaderUtils,Fe=e.Vector2,Ie=e.Vector3,Le=e.Vector4;function Re(e){typeof e==`boolean`&&(console.warn(`THREE.JSONLoader: showStatus parameter has been removed from constructor.`),e=void 0),this.manager=e===void 0?Me:e,this.withCredentials=!1,this.paramsString=``}Object.assign(Re.prototype,{load:function(e,t,n,r){var i=this,a=this.texturePath&&typeof this.texturePath==`string`?this.texturePath:Pe.extractUrlBase(e),o=new Ne(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 Ie,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 Fe(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 Ie(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 je(T)),r!==0&&w.vertexColors.push(new je(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 Fe(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 Ie(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 je(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 Le(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 Le(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 Ie;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 Ie;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=Ae.parseAnimation(r[i],t.bones);a&&n.push(a)}if(t.morphTargets){var o=Ae.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=Oe.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 ke(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 ze=function(){V.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 Re;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,this.boundingBoxUpdateRequired=!0,this.morph.computeBoundingSphere()},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),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 De(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.addCustomGlyph=e=>{e.isGlyph&&t.push(e),this.ready=!0,this.boundingBoxUpdateRequired=!0},this.addMeshAsGlyph=(e,n)=>{if(e.isMesh){let r=new De(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)}};ze.prototype=Object.create(V.prototype);var Be=new e.Matrix4,Ve=new e.Ray,He=new e.Sphere,Ue=new e.Vector3,We=new e.Vector3,Ge=new e.Vector3,Ke=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(),He.copy(n.boundingSphere),He.applyMatrix4(r),He.radius+=i,e.ray.intersectsSphere(He)===!1)return;Be.copy(r).invert(),Ve.copy(e.ray).applyMatrix4(Be);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);Je(this,o,c,n),qe(Ue,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++)Je(this,o,c,a),qe(Ue,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.`)}}};Ke.prototype.isPoints=!0;function qe(t,n,r,i,a,o,s){let c=Ve.distanceSqToPoint(t);if(c<r){let r=new e.Vector3;Ve.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 Je(e,t,n,r){Ue.fromBufferAttribute(t,r);let i=e.morphTargetInfluences;if(e.material.morphTargets&&n&&i){We.set(0,0,0);for(var a=0,o=n.length;a<o;a++){let e=i[a],t=n[a];e!==0&&(Ge.fromBufferAttribute(t,r),We.addScaledVector(Ge.sub(Ue),e))}Ue.add(We)}}var Ye=function(){V.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);console.log(r,n),n.localMorphColour&&r.morphAttributes.color&&(t.vertexColors=!0,t.onBeforeCompile=ne),t.map=P();let i=new Ke(r,t);this.setMesh(i,n.localTimeEnabled,n.localMorphColour)}};let o=(o,s,c,l)=>{if(c){let u=new Ee(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 Ye.prototype.deleteVertices.call(this,e)&&s(e),this.drawRange},this.setName=function(e){let n=this.groupName;Ye.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),Ye.prototype.render.call(this,e,t,n,r)}};Ye.prototype=Object.create(V.prototype);var Xe=function(){V.call(this),this.isLines=!0,this.createLineSegment=(e,t,n)=>{if(e&&t){let r=k(e,n);n.localMorphColour&&r.morphAttributes.color&&(t.vertexColors=!0,t.onBeforeCompile=ne);let i=new he(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)}}};Xe.prototype=Object.create(V.prototype);var Ze=function(){this.isTexture=!0,this.impl=void 0,this.isLoading=!1,this.size={width:1,height:1,depth:0}};Ze.prototype.loadImage=function(e,t){return new Promise((n,r)=>{e.onload=()=>n(e),e.onerror=r,e.src=t})},Ze.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}},Ze.prototype.loadFromImages=async function(e){},Ze.prototype.isReady=function(){return!!(this.impl&&!this.isLoading)},Ze.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 Qe=function(){Ze.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.DataArrayTexture(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}}};Qe.prototype=Object.create(Ze.prototype);var $e=e.GLSL3,et=`
|
|
28
28
|
precision highp float;
|
|
29
29
|
precision highp int;
|
|
30
30
|
precision highp sampler2DArray;
|
|
@@ -61,7 +61,7 @@ void main() {
|
|
|
61
61
|
vec3 contrastedColor = (brightenedColor - vec3(0.5)) * contrast + vec3(0.5);
|
|
62
62
|
outColor = vec4(contrastedColor, 1.0);
|
|
63
63
|
}
|
|
64
|
-
`,
|
|
64
|
+
`,tt=`
|
|
65
65
|
out vec3 vUw;
|
|
66
66
|
uniform float depth;
|
|
67
67
|
uniform vec3 slide;
|
|
@@ -89,7 +89,7 @@ void main() {
|
|
|
89
89
|
vUw.xyz = vec3(slidePos.x, slidePos.y, slidePos.z * depth);
|
|
90
90
|
|
|
91
91
|
}
|
|
92
|
-
`,it=function(){return{brightness:{value:0},contrast:{value:1},depth:{value:1},discardAlpha:{value:!0},diffuse0:{value:void 0},diffuse1:{value:void 0},direction:{value:1},flipY:{value:!0},flipZ:{value:!1},nChannels:{value:1},mask:{value:void 0},maskEnabled:{value:!1},slide:{value:new e.Vector3(0,0,1)},time:{value:0}}},at=function(e){V.call(this),this.isTexturePrimitive=!0,this.texture=e,this.textureList=[],this.texture&&this.textureList.push(this.texture),this.load=(e,t,n)=>{if(e&&e.images&&e.images.source){let n=new et,r=[];e.images.source.forEach(e=>{r.push(e)});let i=this;n.loadFromImages(r).then(()=>{i.texture=n,i.textureList.push(this.texture),i.initialise(e,t)})}},this.addTextureArray=e=>{this.textureList.length===0&&this.texture&&this.textureList.push(this.texture),e&&e.isTextureArray&&this.textureList.push(e)},this.initialise=(e,t)=>{t!=null&&typeof t==`function`&&t(this)}};at.prototype=Object.create(V.prototype),at.prototype.constructor=at;var ot=function(t){at.call(this,t),this.isTextureSlides=!0;let n=[],r={};this.morph=new e.Group,this.group=this.morph,this.morph.userData=this;let i,a=!0,o=!1,s=0,c=1,l=1,u,d=!1,f=!0,p=0,m=0,h=-.1;this.createSlides=e=>{e.forEach(e=>this.createSlide(e))};let g=(e,t)=>{let n=e.material,r=n.uniforms;switch(e.rotation.x=0,e.rotation.y=0,e.rotation.z=0,e.position.x=0,e.position.y=0,e.position.z=0,t.direction){case`x`:let n=-Math.PI/2;e.rotation.y=n,r.direction.value=1,r.slide.value.set(t.value,0,0),e.position.x=t.value;break;case`y`:e.rotation.x=Math.PI/2,r.direction.value=2,r.slide.value.set(0,t.value,0),e.position.y=t.value;break;case`z`:r.direction.value=3,r.slide.value.set(0,0,t.value),e.position.z=t.value}n.needsUpdate=!0,this.boundingBoxUpdateRequired=!0};this.modifySlideSettings=e=>{e&&e.id&&e.id in r&&r[e.id]&&g(r[e.id],e)},this.createSlide=t=>{if(this.texture&&this.texture.isTextureArray&&this.texture.isReady()&&t&&t.direction&&t.value!==void 0){let i=new e.PlaneGeometry(1,1);i.translate(.5,.5,0);let p=it();p.brightness.value=s,p.contrast.value=c,p.diffuse0.value=this.texture.impl,p.diffuse1.value=this.texture.impl,p.discardAlpha.value=f,p.depth.value=this.texture.size.depth,p.flipY.value=a,p.flipZ.value=o,p.mask.value=u,p.maskEnabled.value=d,p.nChannels.value=l;let m={fs:nt,vs:rt,uniforms:p,glslVersion:tt,side:e.DoubleSide,transparent:!1},h=this.texture.getMaterial(m);h.needsUpdate=!0;let _=new e.Mesh(i,h);_.name=this.groupName,_.userData=this;let v={value:t.value,direction:t.direction,id:_.id};return n.push(v),g(_,v),r[_.id]=_,this.morph.add(_),this.boundingBoxUpdateRequired=!0,this.updateTimeTexture(),v}},this.getTextureSettings=()=>[...n],this.getTextureSettingsWithId=e=>{for(let t=0;t<n.length;t++)if(e===n[t].id)return{...n[t]}},this.getSlides=()=>this.morph?[...this.morph.children]:[],this.removeSlide=e=>{e&&this.removeSlideWithId(e.id)},this.removeSlideWithId=e=>{if(this.morph&&e in r&&r[e]){if(this.morph.getObjectById(e)){let t=r[e];this.morph.remove(t),t.clear(),t.geometry&&t.geometry.dispose(),t.material&&t.material.dispose(),this.boundingBoxUpdateRequired=!0}let t=n.findIndex(t=>t.id===e);t>-1&&n.splice(t,1)}},this.dispose=()=>{this.morph.children.forEach(e=>{e.geometry&&e.geometry.dispose(),e.material&&e.material.dispose()}),at.prototype.dispose.call(this),this.boundingBoxUpdateRequired=!0};let _=(e,t,n)=>{if(t)switch(t.direction.value){case 1:n.copy(t.slide.value),e.expandByPoint(n),n.setY(1),n.setZ(1),e.expandByPoint(n);break;case 2:n.copy(t.slide.value),e.expandByPoint(n),n.setX(1),n.setZ(1),e.expandByPoint(n);break;case 3:n.copy(t.slide.value),e.expandByPoint(n),n.setX(1),n.setY(1),e.expandByPoint(n)}};this.getBoundingBox=()=>{if(this.morph&&this.morph.children&&this.morph.visible&&this.boundingBoxUpdateRequired){this.cachedBoundingBox.makeEmpty();let t=new e.Vector3(0,0,0);this.morph.children.forEach(e=>{_(this.cachedBoundingBox,e.material.uniforms,t)}),this.morph.updateMatrixWorld(!0,!0),this.cachedBoundingBox.applyMatrix4(this.morph.matrixWorld),this.boundingBoxUpdateRequired=!1}return this.cachedBoundingBox},this.applyTransformation=(t,n,r)=>{let i=new e.Matrix4;i.set(t[0],t[1],t[2],0,t[3],t[4],t[5],0,t[6],t[7],t[8],0,0,0,0,0);let a=new e.Quaternion().setFromRotationMatrix(i);this.morph.position.set(...n),this.morph.quaternion.copy(a),this.morph.scale.set(...r),this.morph.updateMatrix(),this.boundingBoxUpdateRequired=!0},this.setRenderOrder=e=>{this.morph.renderOrder=e},this.initialise=(e,t)=>{if(e){let n=e.locations;n&&n.length>0&&(this.applyTransformation(n[0].orientation,n[0].position,n[0].scale),`flipY`in n[0]&&(a=n[0].flipY),`flipZ`in n[0]&&(o=n[0].flipZ)),this.createSlides(e.settings.slides),t!=null&&typeof t==`function`&&t(this)}},this.showEdges=t=>{if(i)i.material.color=t;else{let n=new e.BoxGeometry(1,1,1);n.translate(.5,.5,.5);let r=new e.EdgesGeometry(n);i=new e.LineSegments(r,new e.LineBasicMaterial({color:t})),this.group.add(i)}i.visible=!0},this.setUniformsValue=(e,t)=>{this.morph.children.forEach(n=>{let r=n.material;if(r.type===`ShaderMaterial`){let n=r.uniforms;n[e].value=t,r.needsUpdate=!0}})},this.isAlphaPixelDiscarded=()=>f,this.discardAlphaPixel=e=>{f=e,this.setUniformsValue(`discardAlpha`,f)},this.getBrightness=()=>s,this.setBrightness=e=>{s=e,this.setUniformsValue(`brightness`,s)},this.getContrast=()=>c,this.setContrast=e=>{c>=0&&(c=e,this.setUniformsValue(`contrast`,c))},this.getNumberOfChannels=()=>l,this.setNumberOfChannels=e=>{l=e,this.setUniformsValue(`nChannels`,l)},this.getMask=()=>u,this.setMask=e=>{u=e,d=!!u,this.setUniformsValue(`mask`,u),this.setUniformsValue(`maskEnabled`,d)},this.hideEdges=()=>{i&&(i.visible=!1)},this.updateTimeTexture=()=>{let e=this.textureList.length-1,t=this.inbuildTime/this.duration;if(this.timeEnabled&&e>0&&h!==t){let n=t*e,r=Math.floor(n),i=Math.ceil(n),a=n-r;this.morph.children.forEach(e=>{let t=e.material;if(t.type===`ShaderMaterial`){let e=t.uniforms;p!==r&&(e.diffuse0.value=this.textureList[r].impl),m!==i&&(e.diffuse1.value=this.textureList[i].impl),e.time.value=a,t.needsUpdate=!0}}),p=r,m=i,h=t}},this.setMorphTime=e=>{let t=e;t=e>this.duration?this.duration:0>e?0:e,t!=this.inbuildTime&&(this.inbuildTime=t,this.updateTimeTexture())},this.render=(e,t,n)=>{if(t==1&&this.timeEnabled&&this.textureList.length>1){let t=this.inbuildTime+e;t>this.duration&&(t-=this.duration),this.inbuildTime=t,this.updateTimeTexture()}}};ot.prototype=Object.create(at.prototype),ot.prototype.constructor=ot;var st=function(){this.nearPlane=.168248,this.farPlane=6.82906,this.eyePosition=[.5,-2.86496,.5],this.targetPosition=[.5,.5,.5],this.upVector=[0,0,1];let e=this;this.setFromObject=({nearPlane:t,farPlane:n,eyePosition:r,targetPosition:i,upVector:a})=>{e.nearPlane=t,e.farPlane=n,e.eyePosition=r,e.targetPosition=i,e.upVector=a}},ct=function(t,n,r,i){let a={NONE:-1,DEFAULT:0,PATH:1,SMOOTH_CAMERA_TRANSITION:2,AUTO_TUMBLE:3,ROTATE_TRANSITION:4,MINIMAP:5,SYNC_CONTROL:6},o={NONE:-1,ROTATE:0,ZOOM:1,PAN:2,TOUCH_ROTATE:3,TOUCH_ZOOM:4,TOUCH_PAN:5,SCROLL:6,KEYBOARD_ZOOM:7,KEYBOARD_ROTATE:8,KEYBOARD_PAN:9},s={NONE:-1,FREE:1,HORIZONTAL:2,VERTICAL:3},c={ARROWLEFT:37,ARROWUP:38,ARROWRIGHT:39,ARROWDOWN:40,NUMPADADD:107,NUMPADSUBTRACT:109,EQUAL:187,MINUS:189},l={};l.MAIN=o.ROTATE,l.AUXILIARY=o.ZOOM,l.SECONDARY=o.PAN,this.cameraObject=t,this.domElement=n===void 0?document:n,this.renderer=r,this.scene=i,this.tumble_rate=1.5,this.pointer_x=0,this.pointer_y=0,this.pointer_x_start=0,this.pointer_y_start=0,this.previous_pointer_x=0,this.previous_pointer_y=0,this.near_plane_fly_debt=0,this.touchZoomDistanceStart=0,this.touchZoomDistanceEnd=0,this.directionalLight=0,this.zoomRate=50,this.rotateRate=50,this.panRate=100,this.pixelHeight=1;let u=6e3,d=!0,f=0,p,m,h=!1,g=500,_,v=`default`,y=a.DEFAULT,b,x,S,C=0,w=s.FREE;this._state=o.NONE;let T;this.targetTouchId=-1;let E,D=new e.Vector3,O=new e.Vector3,k=new e.Vector3,A=new e.Vector3,j=new e.Vector3,M=new e.Vector3,N=new e.Vector3,P=new e.Vector3,F=new e.Sphere,I=new e.Vector3,ee=!1,L,R=0,z={default:new st};z.default.nearPlane=.1,z.default.farPlane=2e3,z.default.eyePosition=[0,0,0],z.default.targetPosition=[0,0,-1],z.default.upVector=[0,1,0],this.cameraObject.target===void 0&&(this.cameraObject.target=new e.Vector3(...z.default.targetPosition)),this.calculateMaxAllowedDistance=e=>{let t=e.getBoundingBox();if(t){t.getBoundingSphere(F),R=F.radius*6;let e=0;this.cameraObject&&(e=this.cameraObject.position.distanceTo(F.center)),R=e>R?e*1.5:R}else R=0};let te=e=>{D.copy(this.cameraObject.position);let t=D.sub(this.cameraObject.target).length();this.cameraObject.near=Math.max(1e-4,t*.001),this.cameraObject.far=this.cameraObject.near*1e4};this.addViewport=(e,t)=>{e&&t&&(z[e]=t)},this.setDefaultViewport=e=>e&&e in z?(v=e,!0):!1,this.getDefaultViewport=()=>v,this.getViewportOfName=e=>z[e],this.setCurrentViewport=e=>e in z&&(this.setCurrentCameraSettings(z[e]),!0),this.setRotationMode=e=>{switch(e){case`none`:w=s.NONE;break;case`horizontal`:w=s.HORIZONTAL;break;case`vertical`:w=s.VERTICAL;break;default:w=s.FREE}},this.onResize=()=>{E&&=void 0,L&&L.setCurrentCameraSettings(this.cameraObject,z[v])},this.getVisibleHeightAtZDepth=e=>{let t=this.cameraObject.position.distanceTo(this.cameraObject.target);e<t?e-=t:e+=t;let n=this.cameraObject.fov*Math.PI/180;return 2*Math.tan(n/2)*Math.abs(e)},this.calculateHeightPerPixelAtZeroDepth=e=>{let t=this.getVisibleHeightAtZDepth(0);return this.pixelHeight=t/e,this.pixelHeight},this.getNDCFromDocumentCoords=(t,n,r)=>{B(!1);let i=r||new e.Vector2,a=(t-E.left)/E.width*2-1,o=-((n-E.top)/E.height)*2+1;return i.set(a,o)},this.getRelativeCoordsFromNDC=(t,n,r)=>{B(!1);let i=r||new e.Vector2;return i.x=(t+1)*E.width/2,i.y=(1-n)*E.height/2,i},this.setMouseButtonAction=(e,t)=>{l[e]=o[t]};let ne=(e,t)=>{e instanceof HTMLCanvasElement&&(e.tabIndex=t)},re=()=>{if(R>0){let e=I.distanceTo(F.center);return R>e||this.cameraObject.position.distanceTo(F.center)>e}return!0},ie=e=>{I.copy(this.cameraObject.position).add(e),re()&&(this.cameraObject.target.add(e),this.cameraObject.position.add(e),this.updateDirectionalLight())},ae=e=>{B(!1);let t;if(y===a.DEFAULT&&(t=this.scene.getNormalisedMinimapCoordinates(this.renderer,e)),!t)e.button==0?this._state=e.ctrlKey?l.AUXILIARY:e.shiftKey?l.SECONDARY:l.MAIN:e.button==1?(e.preventDefault(),this._state=l.AUXILIARY):e.button==2&&(this._state=l.SECONDARY),this.pointer_x=e.clientX-E.left,this.pointer_y=e.clientY-E.top,this.pointer_x_start=this.pointer_x,this.pointer_y_start=this.pointer_y,this.previous_pointer_x=this.pointer_x,this.previous_pointer_y=this.pointer_y;else{y=a.MINIMAP;let e=this.scene.getMinimapDiffFromNormalised(t.x,t.y);ie(e)}},oe=e=>{if(B(!1),E){if(this.pointer_x=e.clientX-E.left,this.pointer_y=e.clientY-E.top,y===a.MINIMAP){let t=this.scene.getNormalisedMinimapCoordinates(this.renderer,e);if(t){let e=this.scene.getMinimapDiffFromNormalised(t.x,t.y);ie(e)}}else this._state===o.NONE&&T!==void 0&&T.move(this,e.clientX,e.clientY,this.renderer)}},se=e=>{this._state=o.NONE,y==a.MINIMAP&&(y=a.DEFAULT),T!==void 0&&this.pointer_x_start==e.clientX-E.left&&this.pointer_y_start==e.clientY-E.top&&T.pick(this,e.clientX,e.clientY,this.renderer)},ce=e=>{this._state=o.NONE},le=e=>{B(!1);let t=e.touches.length;if(t==1)this._state=o.TOUCH_ROTATE,this.pointer_x=e.touches[0].clientX-E?.left,this.pointer_y=e.touches[0].clientY-E?.top,this.pointer_x_start=this.pointer_x,this.pointer_y_start=this.pointer_y,this.previous_pointer_x=this.pointer_x,this.previous_pointer_y=this.pointer_y;else if(t==2){this._state=o.TOUCH_ZOOM;let t=e.touches[0].clientX-e.touches[1].clientX,n=e.touches[0].clientY-e.touches[1].clientY;this.touchZoomDistanceEnd=this.touchZoomDistanceStart=Math.sqrt(t*t+n*n)}else t==3&&(this._state=o.TOUCH_PAN,this.targetTouchId=e.touches[0].identifier,this.pointer_x=e.touches[0].clientX-E?.left,this.pointer_y=e.touches[0].clientY-E?.top,this.previous_pointer_x=this.pointer_x,this.previous_pointer_y=this.pointer_y)},ue=e=>{e.preventDefault(),e.stopPropagation();let t=e.touches.length;if(t==1)this.pointer_x=e.touches[0].clientX-E.left,this.pointer_y=e.touches[0].clientY-E.top;else if(t==2){if(this._state===o.TOUCH_ZOOM){let t=e.touches[0].clientX-e.touches[1].clientX,n=e.touches[0].clientY-e.touches[1].clientY;this.touchZoomDistanceEnd=Math.sqrt(t*t+n*n)}}else if(t==3&&this._state===o.TOUCH_PAN)for(let t=0;t<3;t++)e.touches[t].identifier==this.targetTouchId&&(this.pointer_x=e.touches[0].clientX-E.left,this.pointer_y=e.touches[0].clientY-E.top)},de=e=>{let t=e.touches.length;this.touchZoomDistanceStart=this.touchZoomDistanceEnd=0,this.targetTouchId=-1,this._state=o.NONE,t==1&&T!==void 0&&this.pointer_x_start==e.touches[0].clientX-E.left&&this.pointer_y_start==e.touches[0].clientY-E.top&&T.pick(this.cameraObject,e.touches[0].clientX,e.touches[0].clientY,this.renderer)},fe=()=>{B(!0)},B=e=>{if(e||E===void 0){let e=new IntersectionObserver(t=>{for(let e of t)E=e.boundingClientRect;e.disconnect()});e.observe(this.domElement)}},pe=e=>{B(!1),this._state=o.SCROLL;let t=0;e.deltaY>0?t=this.zoomRate:e.deltaY<0&&(t=this.zoomRate*-1),C+=t,e.preventDefault(),e.stopImmediatePropagation()},me=e=>{B(!1);let t=0;if(e.keyCode===c.EQUAL||e.keyCode===c.MINUS||e.keyCode===c.NUMPADADD||e.keyCode===c.NUMPADSUBTRACT){this._state=o.KEYBOARD_ZOOM;let n=1;e.shiftKey&&(n*=2),e.keyCode===c.EQUAL||e.keyCode===c.NUMPADADD?t=this.zoomRate*n*-1:(e.keyCode===c.MINUS||e.keyCode===c.NUMPADSUBTRACT)&&(t=this.zoomRate*n),C+=t}else(e.keyCode===c.ARROWLEFT||e.keyCode===c.ARROWUP||e.keyCode===c.ARROWRIGHT||e.keyCode===c.ARROWDOWN)&&(e.shiftKey?(this._state=o.KEYBOARD_ROTATE,this.pointer_x_start=this.pointer_x,this.pointer_y_start=this.pointer_y,t=this.rotateRate):(this._state=o.KEYBOARD_PAN,t=this.panRate),this.previous_pointer_x=this.pointer_x,this.previous_pointer_y=this.pointer_y,e.keyCode===c.ARROWLEFT?this.pointer_x-=t:e.keyCode===c.ARROWUP?this.pointer_y-=t:e.keyCode===c.ARROWRIGHT?this.pointer_x+=t:e.keyCode===c.ARROWDOWN&&(this.pointer_y+=t));Object.values(c).includes(e.keyCode)&&e.preventDefault()},he=e=>{this._state=o.NONE},ge=()=>{if(this.cameraObject!==void 0){let e=E.height,t=this.cameraObject.position.distanceTo(this.cameraObject.target),n=0;this.cameraObject.far>this.cameraObject.near&&t>=this.cameraObject.near&&t<=this.cameraObject.far&&(n=(t-this.cameraObject.near)/(this.cameraObject.far-this.cameraObject.near)),O.set(this.previous_pointer_x,e-this.previous_pointer_y,0),k.set(this.previous_pointer_x,e-this.previous_pointer_y,1),A.set(this.pointer_x,e-this.pointer_y,0),j.set(this.pointer_x,e-this.pointer_y,1),O.unproject(this.cameraObject),k.unproject(this.cameraObject),A.unproject(this.cameraObject),j.unproject(this.cameraObject),A.sub(O).multiplyScalar(1-n),j.sub(k).multiplyScalar(n),A.add(j).multiplyScalar(-.002),ie(A)}this.previous_pointer_x=this.pointer_x,this.previous_pointer_y=this.pointer_y};this.getVectorsFromRotateAboutLookAtPoints=(e,t)=>{e.normalize(),N.copy(this.cameraObject.position).sub(this.cameraObject.target),P.copy(N),N.normalize(),.8<Math.abs(N.dot(e))&&N.copy(this.cameraObject.up),O.crossVectors(e,N).normalize(),k.crossVectors(e,O);let n=e.dot(P),r=O.dot(P),i=k.dot(P),a=e.dot(this.cameraObject.up),o=O.dot(this.cameraObject.up),s=k.dot(this.cameraObject.up),c=Math.cos(t),l=Math.sin(t);return A.set(c*O.x+l*k.x,c*O.y+l*k.y,c*O.z+l*k.z),j.set(c*k.x-l*O.x,c*k.y-l*O.y,c*k.z-l*O.z),N.copy(this.cameraObject.target),N.x=N.x+e.x*n+A.x*r+j.x*i,N.y=N.y+e.y*n+A.y*r+j.y*i,N.z=N.z+e.z*n+A.z*r+j.z*i,D.set(e.x*a+A.x*o+j.x*s,e.y*a+A.y*o+j.y*s,e.z*a+A.z*o+j.z*s),{position:N,up:D}},this.rotateAboutLookAtpoint=(e,t)=>{let n=this.getVectorsFromRotateAboutLookAtPoints(e,t);this.cameraObject.position.copy(n.position),this.updateDirectionalLight(),this.cameraObject.up.copy(n.up)};let _e=()=>{if(this.cameraObject!==void 0){let e=E?.width,t=E?.height;if(0<e&&0<t){let n=.25*(e+t),r=0,i=0;(w===s.FREE||w===s.HORIZONTAL)&&(r=this.pointer_x-this.previous_pointer_x),(w===s.FREE||w===s.VERTICAL)&&(i=this.previous_pointer_y-this.pointer_y);let a=Math.sqrt(r*r+i*i);if(a>0){let o=-i*1/a,c=r*1/a;if(w===s.FREE){let r=o*(this.pointer_x-.5*(e-1))+c*(.5*(t-1)-this.pointer_y);r>n?r=n:r<-n&&(r=-n)}let l=Math.acos(0/n)-.5*Math.PI,u=this.tumble_rate*a/n;D.copy(this.cameraObject.position).sub(this.cameraObject.target).normalize(),O.copy(this.cameraObject.up).normalize(),k.copy(O).cross(D).normalize().multiplyScalar(o),O.multiplyScalar(c),M.addVectors(k,O).multiplyScalar(Math.cos(l)),D.multiplyScalar(Math.sin(l)),M.add(D),this.rotateAboutLookAtpoint(M,-u)}}}this.previous_pointer_x=this.pointer_x,this.previous_pointer_y=this.pointer_y},ve=()=>{let e=0;return this._state===o.ZOOM?e=this.previous_pointer_y-this.pointer_y:this._state===o.SCROLL||this._state===o.KEYBOARD_ZOOM?e=C:(e=-1*(this.touchZoomDistanceEnd-this.touchZoomDistanceStart),this.touchZoomDistanceStart=this.touchZoomDistanceEnd),e};this.changeZoomByScrollRateUnit=e=>{let t=e*this.zoomRate;this.changeZoomByValue(t)},this.changeZoomByValue=e=>{if(this.cameraObject!==void 0){let t=E.height,n=this.cameraObject.position.clone();n.sub(this.cameraObject.target);let r=n.length(),i=r*(1.5*e/t);r+i>.01&&(n.normalize(),I.copy(this.cameraObject.position),I.x+=n.x*i,I.y+=n.y*i,I.z+=n.z*i,re()&&(this.cameraObject.position.copy(I),this.updateDirectionalLight(),te(i),ee=!0))}};let ye=()=>{let e=ve();this.changeZoomByValue(e),this._state===o.ZOOM&&(this.previous_pointer_x=this.pointer_x,this.previous_pointer_y=this.pointer_y),(this._state===o.SCROLL||this._state===o.KEYBOARD_ZOOM)&&(C=0,this._state=o.NONE)};this.setDirectionalLight=e=>{this.directionalLight=e},this.updateDirectionalLight=()=>{this.directionalLight!=0&&this.directionalLight.position.set(this.cameraObject.position.x,this.cameraObject.position.y,this.cameraObject.position.z)},this.enable=function(){d=!0,this.domElement&&this.domElement.addEventListener&&(ne(this.domElement,0),this.domElement.addEventListener(`mousedown`,ae,!1),this.domElement.addEventListener(`mousemove`,oe,!1),this.domElement.addEventListener(`mouseup`,se,!1),this.domElement.addEventListener(`mouseleave`,ce,!1),this.domElement.addEventListener(`touchstart`,le,!1),this.domElement.addEventListener(`touchmove`,ue,!1),this.domElement.addEventListener(`touchend`,de,!1),this.domElement.addEventListener(`wheel`,pe,!1),this.domElement.addEventListener(`mouseenter`,fe,!1),this.domElement.addEventListener(`contextmenu`,e=>{e.preventDefault()},!1),this.domElement.addEventListener(`keydown`,me,!1),this.domElement.addEventListener(`keyup`,he,!1))},this.disable=function(){d=!1,this.domElement&&this.domElement.removeEventListener&&(this.domElement.removeEventListener(`mousedown`,ae,!1),this.domElement.removeEventListener(`mousemove`,oe,!1),this.domElement.removeEventListener(`mouseup`,se,!1),this.domElement.removeEventListener(`mouseleave`,ce,!1),this.domElement.removeEventListener(`touchstart`,le,!1),this.domElement.removeEventListener(`touchmove`,ue,!1),this.domElement.removeEventListener(`touchend`,de,!1),this.domElement.removeEventListener(`wheel`,pe,!1),this.domElement.removeEventListener(`mouseenter`,fe,!1),this.domElement.removeEventListener(`contextmenu`,e=>{e.preventDefault()},!1),this.domElement.removeEventListener(`keydown`,me,!1),this.domElement.removeEventListener(`keyup`,he,!1),ne(this.domElement,-1))},this.loadPath=e=>{p=e.CameraPath,m=e.NumberOfPoints},this.loadPathURL=(e,t)=>{let n=e;fetch(n).then(e=>{if(!e.ok)throw Error(`HTTP error! status: ${e.status}`);return e.json()}).then(e=>{this.loadPath(e),t!==void 0&&typeof t==`function`&&t()}).catch(e=>{console.error(`Failed to load path asset from: ${n}`,e)})},this.setPathDuration=e=>{u=e,b&&b.setDuration(u),x&&x.setDuration(u)},this.getPlayRate=()=>g,this.setPlayRate=e=>{g=e};let be=e=>{let t=f+e;t>u&&(t-=u),f=t};this.getTime=()=>f,this.setTime=e=>{f=e>u?u:e<0?0:e},this.getNumberOfTimeFrame=()=>m,this.getCurrentTimeFrame=()=>{if(m>2){let e=f/u*(m-1),t=Math.floor(e),n=1-(e-t),r=Math.ceil(e);return t==r?t==m-1?[t-1,r,0]:[t,r+1,1]:[t,r,n]}if(m==1)return[0,0,0]},this.setCurrentTimeFrame=e=>{m>2&&(f=u*e/(m-1),f<0&&(f=0),f>u&&(f=u))};let xe=e=>{if(y===a.PATH&&(be(e),p)){let e=this.getCurrentTimeFrame(),t=e[0],n=e[1],r=e[2],i=[p[t*3],p[t*3+1],p[t*3+2]],a=[p[n*3],p[n*3+1],p[n*3+2]],o=[];for(let e=0;e<i.length;e++)o.push(r*i[e]+(1-r)*a[e]);this.cameraObject.position.set(o[0],o[1],o[2]),this.cameraObject.target.set(a[0],a[1],a[2]),_&&this.cameraObject.lookAt(this.cameraObject.target),h&&(this.directionalLight.position.set(o[0],o[1],o[2]),this.directionalLight.target.position.set(a[0],a[1],a[2]))}};this.calculatePathNow=()=>{xe(0)};let Se=()=>{this._state===o.ROTATE||this._state===o.TOUCH_ROTATE||this._state===o.KEYBOARD_ROTATE?_e():this._state===o.PAN||this._state===o.TOUCH_PAN||this._state===o.KEYBOARD_PAN?(ge(),L.triggerCallback()):(this._state===o.ZOOM||this._state===o.TOUCH_ZOOM||this._state===o.SCROLL||this._state===o.KEYBOARD_ZOOM)&&(L.zoom(ve()),this.previous_pointer_x=this.pointer_x,this.previous_pointer_y=this.pointer_y,(this._state===o.SCROLL||this._state===o.KEYBOARD_ZOOM)&&(this._state=o.NONE),C=0,L.triggerCallback())};this.update=e=>{let t=e*g,n=d,r=!0;return y===a.PATH?xe(t):y===a.SMOOTH_CAMERA_TRANSITION&&b?(b.update(t),b.isTransitionCompleted()&&(y=a.DEFAULT),n=!1):y===a.ROTATE_CAMERA_TRANSITION&&x?(x.update(t),x.isTransitionCompleted()&&(y=a.DEFAULT),n=!1):y===a.AUTO_TUMBLE&&S?S.update(t):y===a.SYNC_CONTROL&&L?(Se(),n=!1):r=!1,n&&(this._state!==o.NONE&&(r=!0),this._state===o.ROTATE||this._state===o.TOUCH_ROTATE||this._state===o.KEYBOARD_ROTATE?_e():this._state===o.PAN||this._state===o.TOUCH_PAN||this._state===o.KEYBOARD_PAN?ge():(this._state===o.ZOOM||this._state===o.TOUCH_ZOOM||this._state===o.SCROLL||this._state===o.KEYBOARD_ZOOM)&&ye(),this._state!==o.NONE&&y===a.AUTO_TUMBLE&&S&&S.stopOnCameraInput,this._state===o.SCROLL&&(this._state=o.NONE)),_?(r=!0,_.update()):this.cameraObject.lookAt(this.cameraObject.target),r||=ee,ee=!1,r},this.playPath=()=>{y=a.PATH},this.stopPath=()=>{y=a.DEFAULT},this.isPlayingPath=()=>y===a.PATH,this.enableDirectionalLightUpdateWithPath=e=>{h=e},this.enableDeviceOrientation=()=>{_||=new ht(this.cameraObject)},this.disableDeviceOrientation=()=>{_&&=(_.dispose(),void 0)},this.isDeviceOrientationEnabled=()=>!!_,this.resetView=()=>{let e=z[v];this.cameraObject.near=e.nearPlane,this.cameraObject.far=e.farPlane,this.cameraObject.position.set(e.eyePosition[0],e.eyePosition[1],e.eyePosition[2]),this.cameraObject.target.set(e.targetPosition[0],e.targetPosition[1],e.targetPosition[2]),this.cameraObject.up.set(e.upVector[0],e.upVector[1],e.upVector[2]),this.cameraObject.updateProjectionMatrix(),this.updateDirectionalLight()},this.setCurrentCameraSettings=e=>{e.nearPlane&&(this.cameraObject.near=e.nearPlane),e.farPlane&&(this.cameraObject.far=e.farPlane),e.eyePosition&&this.cameraObject.position.set(e.eyePosition[0],e.eyePosition[1],e.eyePosition[2]),e.targetPosition&&this.cameraObject.target.set(e.targetPosition[0],e.targetPosition[1],e.targetPosition[2]),e.upVector&&this.cameraObject.up.set(e.upVector[0],e.upVector[1],e.upVector[2]),this.cameraObject.updateProjectionMatrix(),this.updateDirectionalLight(),ee=!0},this.getViewportFromCentreAndRadius=(e,t,n,r,i,a)=>{D.copy(this.cameraObject.position),D.sub(this.cameraObject.target),D.normalize();let o=[e,t,n],s=r/Math.tan(i*Math.PI/360),c=[e+D.x*s,t+D.y*s,n+D.z*s],l=s+a,u=0;u=a>.95*s?.050000000000000044*s:s-a;let d=new st;return d.nearPlane=u,d.farPlane=l,d.eyePosition=c,d.targetPosition=o,d.upVector=[this.cameraObject.up.x,this.cameraObject.up.y,this.cameraObject.up.z],d},this.getViewportFromBoundingBox=(e,t)=>{let n=e.min.distanceTo(e.max)/2*t,r=(e.min.x+e.max.x)/2,i=(e.min.y+e.max.y)/2,a=(e.min.z+e.max.z)/2;return this.getViewportFromCentreAndRadius(r,i,a,n,40,n*4)},this.getCurrentViewport=()=>{let e=new st;return e.nearPlane=this.cameraObject.near,e.farPlane=this.cameraObject.far,e.eyePosition[0]=this.cameraObject.position.x,e.eyePosition[1]=this.cameraObject.position.y,e.eyePosition[2]=this.cameraObject.position.z,e.targetPosition[0]=this.cameraObject.target.x,e.targetPosition[1]=this.cameraObject.target.y,e.targetPosition[2]=this.cameraObject.target.z,e.upVector[0]=this.cameraObject.up.x,e.upVector[1]=this.cameraObject.up.y,e.upVector[2]=this.cameraObject.up.z,e},this.getDefaultEyePosition=()=>eyePosition,this.getDefaultTargetPosition=()=>targetPosition,this.cameraTransition=(e,t,n)=>{x??(b=new lt(e,t,this,n))},this.rotateCameraTransition=(e,t,n)=>{b??(x=new ut(e,t,this,n))},this.enableCameraTransition=()=>{b&&(y=a.SMOOTH_CAMERA_TRANSITION),x&&(y=a.ROTATE_CAMERA_TRANSITION)},this.pauseCameraTransition=()=>{y=a.DEFAULT},this.stopCameraTransition=()=>{y=a.DEFAULT,b=void 0,x=void 0},this.isTransitioningCamera=()=>y===a.SMOOTH_CAMERA_TRANSITION||y===a.ROTATE_CAMERA_TRANSITION,this.autoTumble=(e,t,n)=>{S=new ft(e,t,n,this)},this.enableAutoTumble=()=>{y=a.AUTO_TUMBLE},this.stopAutoTumble=()=>{y=a.DEFAULT,S=void 0},this.updateAutoTumble=()=>{S&&(S.requireUpdate=!0)},this.isAutoTumble=()=>y===a.AUTO_TUMBLE,this.enableRaycaster=(e,t,n)=>{T??=new dt(e,this.scene,t,n,this.renderer)},this.disableRaycaster=()=>{T.disable(),T=void 0},this.isSyncControl=()=>currentMpde===a.SYNC_CONTROL,this.enableSyncControl=()=>(y=a.SYNC_CONTROL,L||=new gt,L.setCurrentCameraSettings(this.cameraObject,z[v]),L),this.disableSyncControl=()=>{y=a.DEFAULT,this.cameraObject.zoom=1,this.cameraObject.updateProjectionMatrix()},this.enable()},lt=function(e,t,n,r){let i=e.eyePosition,a=e.targetPosition,o=e.upVector,s=t.eyePosition,c=t.targetPosition,l=t.upVector,u=n,d=r,f=0,p=!1;u.near=Math.min(e.nearPlane,t.nearPlane),u.far=Math.max(e.farPlane,t.farPlane),u.cameraObject.up.set(t.upVector[0],t.upVector[1],t.upVector[2]),this.setDuration=e=>{d=e};let m=e=>{let t=f+e;t>d&&(t=d),f=t},h=()=>{let e=f/d,t=[i[0]*(1-e)+s[0]*e,i[1]*(1-e)+s[1]*e,i[2]*(1-e)+s[2]*e],n=[a[0]*(1-e)+c[0]*e,a[1]*(1-e)+c[1]*e,a[2]*(1-e)+c[2]*e];o[0]*(1-e)+l[0]*e,o[1]*(1-e)+l[1]*e,o[2]*(1-e)+l[2]*e,u.cameraObject.position.set(t[0],t[1],t[2]),u.cameraObject.target.set(n[0],n[1],n[2])};this.update=e=>{this.enabled!==!1&&(m(e),h(),f==d&&(p=!0))},this.isTransitionCompleted=()=>p},ut=function(e,t,n,r){let i=e,a=t,o=n,s=r,c=0;c/s;let l=!1;this.setDuration=e=>{s=e};let u=e=>{let t=c,n=c+e;n>s&&(n=s),c=n;let r=(c-t)/s*a;o.rotateAboutLookAtpoint(i,r)};this.update=e=>{this.enabled!==!1&&(u(e),c==s&&(l=!0))},this.isTransitionCompleted=()=>l},dt=function(t,n,r,i,a){let o=t,s=n,c=a,l=r,u=i,d=!0,f=new e.Raycaster;f.params.Line.threshold=.1,f.params.Points.threshold=1;let p=new e.Vector2,m=!1,h=new Date,g=!1,_=0,v=[],y={zincCamera:void 0,x:-1,y:-1},b;this.enable=()=>{d=!0},this.disable=()=>{d=!1},this.getIntersectsObject=e=>{if(s!==o){let t=o.getThreeJSScene();c.render(t,e.cameraObject)}let t=b||o.getPickableThreeJSObjects();return v.length=0,f.intersectObjects(t,!0,v)},this.setPickableObjects=e=>{e===void 0?b=void 0:(b=[],e.forEach(e=>{e.getGroup()&&e.getGroup().visible&&b.push(e.getGroup())}))},this.getIntersectsObjectWithOrigin=(e,t,n)=>(f.set(t,n),this.getIntersectsObject(e)),this.getIntersectsObjectWithCamera=(e,t,n)=>(e.getNDCFromDocumentCoords(t,n,p),f.setFromCamera(p,e.cameraObject),this.getIntersectsObject(e)),this.pick=(e,t,n)=>{if(d&&c&&o&&e&&l){this.getIntersectsObjectWithCamera(e,t,n);let r=v.length;for(let e=0;e<r;e++){let t=v[e].object?v[e].object.userData:void 0;if(t&&t.isMarkerCluster&&t.visible&&t.clusterIsVisible(v[e].object.clusterIndex)&&t.zoomToCluster(v[e].object.clusterIndex))return}l(v,t,n)}};let x=(e,t,n)=>{if(d&&c&&o&&e&&u){if(this.getIntersectsObjectWithCamera(e,t,n),h.setTime(Date.now()),v.length===0){if(g)return;g=!0}else g=!1;u(v,t,n)}};this.move=(e,t,n)=>{d&&c&&o&&e&&u&&(o.displayMarkers?x(e,t,n):(y.zincCamera=e,y.x=t,y.y=n,m||(_=h?Date.now()-h.getTime():250,_>=250?x(e,t,n):(m=!0,setTimeout(S(y),_)))))};let S=e=>function(){m=!1,x(e.zincCamera,e.x,e.y)}},ft=function(t,n,r,i){let a=new e.Vector3,o=-n,s=i,c=t;this.stopOnCameraInput=r,this.requireUpdate=!0;let l=new e.Vector3,u=new e.Vector3,d=e=>{let t=Math.sqrt(e[0]*e[0]+e[1]*e[1]),n=.25*(Math.abs(e[0])*4+Math.abs(e[1])*4),r=-e[1]/t,i=e[0]/t,o=r*e[0]+i*-e[1];o>n?o=n:o<-n&&(o=-n);let c=Math.acos(o/n)-.5*Math.PI;a.copy(s.cameraObject.position).sub(s.cameraObject.target).normalize(),l.copy(s.cameraObject.up).normalize(),u.crossVectors(l,a).normalize().multiplyScalar(r),l.multiplyScalar(i),l.add(u).multiplyScalar(Math.cos(c)),a.multiplyScalar(Math.sin(c)).add(l)};this.update=e=>{this.enabled!==!1&&(this.requireUpdate&&=(d(c),!1),s.rotateAboutLookAtpoint(a,o*e/1e3))}},pt=function(){this.type=`StereoCamera`,this.aspect=1,this.cameraL=new e.PerspectiveCamera,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new e.PerspectiveCamera,this.cameraR.layers.enable(2),this.cameraR.matrixAutoUpdate=!1};Object.assign(pt.prototype,{update:(()=>{let t,n,r,i,a,o,s=new e.Matrix4,c=new e.Matrix4;return function(l){if(t!==l.focus||n!==l.fov||r!==l.aspect*this.aspect||i!==l.near||a!==l.far||o!==l.zoom){t=l.focus,n=l.fov,r=l.aspect*this.aspect,i=l.near,a=l.far,o=l.zoom;let u=l.projectionMatrix.clone(),d=.064/2,f=d*i/t,p=i*Math.tan(e.Math.DEG2RAD*n*.5)/l.zoom,m,h;c.elements[12]=-.032,s.elements[12]=d,m=-p*r+f,h=p*r+f,u.elements[0]=2*i/(h-m),u.elements[8]=(h+m)/(h-m),this.cameraL.projectionMatrix.copy(u),m=-p*r-f,h=p*r-f,u.elements[0]=2*i/(h-m),u.elements[8]=(h+m)/(h-m),this.cameraR.projectionMatrix.copy(u)}this.cameraL.matrixWorld.copy(l.matrixWorld).multiply(c),this.cameraR.matrixWorld.copy(l.matrixWorld).multiply(s)}})()});var mt=function(e){let t=new pt;t.aspect=.5,this.setSize=(t,n)=>{e.setSize(t,n)},this.render=(n,r)=>{n.updateMatrixWorld(),r.parent===null&&r.updateMatrixWorld(),t.update(r);let i=e.getSize();e.setScissorTest(!0),e.clear(),e.setScissor(0,0,i.width/2,i.height),e.setViewport(0,0,i.width/2,i.height),e.render(n,t.cameraL),e.setScissor(i.width/2,0,i.width/2,i.height),e.setViewport(i.width/2,0,i.width/2,i.height),e.render(n,t.cameraR),e.setScissorTest(!1)}},ht=function(t){let n=this;this.object=t,this.object.rotation.reorder(`YXZ`),this.enabled=!0,this.deviceOrientation={},this.screenOrientation=0;let r=e=>{n.deviceOrientation=e},i=()=>{typeof window<`u`&&(n.screenOrientation=window.orientation||0)},a=(()=>{let t=new e.Vector3(0,0,1),n=new e.Euler,r=new e.Quaternion,i=new e.Quaternion(-Math.sqrt(.5),0,0,Math.sqrt(.5));return(a,o,s,c,l)=>{let u=new e.Vector3(0,0,1);u.subVectors(a.target,a.position),n.set(s,o,-c,`YXZ`);let d=new e.Quaternion;d.setFromEuler(n),d.multiply(i),d.multiply(r.setFromAxisAngle(t,-l)),u.applyQuaternion(d),u.addVectors(a.position,u),a.lookAt(u)}})();this.connect=()=>{i(),typeof window<`u`&&(window.addEventListener(`orientationchange`,i,!1),window.addEventListener(`deviceorientation`,r,!1)),n.enabled=!0},this.disconnect=()=>{typeof window<`u`&&(window.removeEventListener(`orientationchange`,i,!1),window.removeEventListener(`deviceorientation`,r,!1)),n.enabled=!1},this.update=()=>{if(n.enabled===!1)return;let t=n.deviceOrientation.alpha?e.Math.degToRad(n.deviceOrientation.alpha):0,r=n.deviceOrientation.beta?e.Math.degToRad(n.deviceOrientation.beta):0,i=n.deviceOrientation.gamma?e.Math.degToRad(n.deviceOrientation.gamma):0,o=n.screenOrientation?e.Math.degToRad(n.screenOrientation):0;a(n.object,t,r,i,o)},this.dispose=function(){this.disconnect()},this.connect()},gt=function(){let t,n,r,i=new e.Vector3,a=new e.Vector3,o=new e.Vector3,s=new e.Vector3,c;this.setCurrentCameraSettings=(o,s)=>{this.near_plane_fly_debt,t=o.clone(),n=o,r=s,t.near=r.nearPlane,r.farPlane&&(t.far=r.farPlane),r.eyePosition&&t.position.set(r.eyePosition[0],r.eyePosition[1],r.eyePosition[2]),r.upVector&&t.up.set(r.upVector[0],r.upVector[1],r.upVector[2]),r.targetPosition&&(t.target=new e.Vector3(r.targetPosition[0],r.targetPosition[1],r.targetPosition[2]),t.lookAt(t.target)),t.updateProjectionMatrix(),i.copy(t.position).project(t),a.copy(t.target).project(t)},this.getCurrentPosition=()=>(a.copy(n.target).project(t),[a.x,a.y]),this.zoom=e=>{let t=e*.002,r=Math.max(n.zoom-t,1);n.zoom=r,n.updateProjectionMatrix()},this.zoomToBox=(e,n)=>{e.getCenter(o),o.project(t),this.setCenterZoom([o.x,o.y],n)},this.getPanZoom=()=>({target:this.getCurrentPosition(),zoom:n.zoom}),this.setCenterZoom=(e,r)=>{o.set(e[0],e[1],a.z).unproject(t),s.copy(o).sub(n.target),n.target.copy(o),n.lookAt(n.target),n.position.add(s),n.zoom=r,n.updateProjectionMatrix()},this.setEventCallback=e=>{(e===void 0||typeof e==`function`)&&(c=e)},this.triggerCallback=()=>{c!==void 0&&typeof c==`function`&&c()}},_t=`data:image/svg+xml,%3c?xml%20version='1.0'%20encoding='UTF-8'%20standalone='no'%20?%3e%3c!DOCTYPE%20svg%20PUBLIC%20'-//W3C//DTD%20SVG%201.1//EN'%20'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'%3e%3csvg%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20version='1.1'%20width='365'%20height='560'%20viewBox='0%200%20365%20560'%20xml:space='preserve'%3e%3cdesc%3eCreated%20with%20Fabric.js%205.2.4%3c/desc%3e%3cdefs%3e%3c/defs%3e%3crect%20x='0'%20y='0'%20width='100%25'%20height='100%25'%20fill='transparent'%3e%3c/rect%3e%3cg%20transform='matrix(0%200%200%200%200%200)'%20id='808ed283-2524-440f-88ae-3bdb47bb5749'%20%3e%3c/g%3e%3cg%20transform='matrix(1%200%200%201%20182.5%20280)'%20id='db30413d-5bff-4b98-ab59-464497ee199e'%20%3e%3crect%20style='stroke:%20none;%20stroke-width:%201;%20stroke-dasharray:%20none;%20stroke-linecap:%20butt;%20stroke-dashoffset:%200;%20stroke-linejoin:%20miter;%20stroke-miterlimit:%204;%20fill:%20rgb(255,255,255);%20fill-rule:%20nonzero;%20opacity:%201;%20visibility:%20hidden;'%20vector-effect='non-scaling-stroke'%20x='-182.5'%20y='-280'%20rx='0'%20ry='0'%20width='365'%20height='560'%20/%3e%3c/g%3e%3cg%20transform='matrix(0%200%200%200%200%2097.5)'%20%3e%3cg%20style=''%20%3e%3c/g%3e%3c/g%3e%3cg%20transform='matrix(0%200%200%200%200%2097.5)'%20%3e%3cg%20style=''%20%3e%3c/g%3e%3c/g%3e%3cg%20transform='matrix(0.99%200%200%200.99%20182.5%20280)'%20%3e%3cg%20style=''%20vector-effect='non-scaling-stroke'%20%3e%3cg%20transform='matrix(1%200%200%201%200%200)'%20%3e%3crect%20style='stroke:%20none;%20stroke-width:%201;%20stroke-dasharray:%20none;%20stroke-linecap:%20butt;%20stroke-dashoffset:%200;%20stroke-linejoin:%20miter;%20stroke-miterlimit:%204;%20fill:%20rgb(255,255,255);%20fill-rule:%20nonzero;%20opacity:%201;%20visibility:%20hidden;'%20vector-effect='non-scaling-stroke'%20x='-540'%20y='-540'%20rx='0'%20ry='0'%20width='1080'%20height='1080'%20/%3e%3c/g%3e%3cg%20transform='matrix(1%200%200%201%200%200)'%20%3e%3cpath%20style='stroke:%20rgb(0,0,0);%20stroke-width:%200;%20stroke-dasharray:%20none;%20stroke-linecap:%20butt;%20stroke-dashoffset:%200;%20stroke-linejoin:%20miter;%20stroke-miterlimit:%204;%20fill:%20rgb(255,165,0);%20fill-rule:%20nonzero;%20opacity:%201;'%20vector-effect='non-scaling-stroke'%20transform='%20translate(-182.9,%20-279.85)'%20d='M%20182.9%20551.7%20C%20182.9%20551.8000000000001%20183.1%20552%20183.1%20552%20C%20183.1%20552%20358.3%20283%20358.3%20194.6%20C%20358.3%2064.5%20269.5%207.900000000000006%20182.9%207.699999999999989%20C%2096.3%207.9%207.5%2064.5%207.5%20194.6%20C%207.5%20283%20182.8%20552%20182.8%20552%20C%20182.8%20552%20182.9%20551.7%20182.9%20551.7%20z%20M%20122.2%20187.2%20C%20122.2%20153.6%20149.4%20126.39999999999999%20183%20126.39999999999999%20C%20216.6%20126.39999999999999%20243.8%20153.6%20243.8%20187.2%20C%20243.8%20220.79999999999998%20216.5%20248%20182.9%20248%20C%20149.4%20248%20122.2%20220.8%20122.2%20187.2%20z'%20stroke-linecap='round'%20/%3e%3c/g%3e%3cg%20transform='matrix(3.82%200%200%203.82%200%20-100.77)'%20%3e%3ccircle%20style='stroke:%20rgb(0,0,0);%20stroke-width:%200;%20stroke-dasharray:%20none;%20stroke-linecap:%20butt;%20stroke-dashoffset:%200;%20stroke-linejoin:%20miter;%20stroke-miterlimit:%204;%20fill:%20rgb(255,255,255);%20fill-rule:%20nonzero;%20opacity:%201;'%20vector-effect='non-scaling-stroke'%20cx='0'%20cy='0'%20r='35'%20/%3e%3c/g%3e%3c/g%3e%3c/g%3e%3c/svg%3e`,vt=new Image(128,128);vt.src=_t;var yt=new e.Texture;yt.image=vt,yt.needsUpdate=!0;var bt=[.02,.03,1],xt=new e.SpriteMaterial({map:yt,alphaTest:.5,transparent:!0,depthTest:!1,depthWrite:!1,sizeAttenuation:!1}),St=function(t){V.call(this),this.texture=yt;let n=t;this.morph=new e.Group,this.group=this.morph,this.isMarkerCluster=!0;let r=!0,i=[];this.markers={};let a=new e.Vector2,o=new e.Vector2,s=Date.now();this.setSpriteSize=e=>{(void 0).scale.set(.015,.02,1),(void 0).scale.multiplyScalar(e)},this.clear=()=>{this.group.clear(),this.markers={}},this.dispose=()=>{this.clear(),this.morph&&this.morph.clear()};let c=t=>{let n=new e.Group,r=new e.Sprite(xt);return r.clusterIndex=t,r.center.set(.5,0),r.position.set(0,0,0),r.renderOrder=1e4,r.scale.set(bt[0],bt[1],bt[2]),r.userData=this,n.add(r),this.group.add(n),{group:n,marker:r,label:void 0,number:0,min:[0,0,0],max:[1,1,1]}},l=(e,t,n)=>{e.group.visible=!0,e.group.position.set(t.coords[0],t.coords[1],t.coords[2]),(e.label===void 0||n!==e.number)&&(e.label&&(e.group.remove(e.label),e.label.material.map.dispose(),e.label.material.dispose()),e.label=F(n,.012,`black`,`Asap`,120,700),e.number=n,e.group.add(e.label)),e.min=t.min,e.max=t.max},u=e=>{let t=0;for(e.forEach(e=>{let n=e.members.length,r=0;n===1?e.members[0].setVisibility(!0):(e.members.forEach(e=>{r+=e.getNumber(),e.setVisibility(!1)}),i[t]||i.push(c(t)),l(i[t],e,r),t++)});t<i.length;t++)i[t].group.visible=!1},d=(e,t)=>{let n=!0,r={members:[],coords:[0,0,0],min:[0,0,0],max:[1,1,1]},i=0;for(let s in e)n?(a.set(e[s].ndc.x,e[s].ndc.y),this._b1.setFromPoints([e[s].morph.position]),n=!1,r.members.push(e[s]),r.coords=[e[s].morph.position.x,e[s].morph.position.y,e[s].morph.position.z],t.push(r),delete e[s]):(o.set(e[s].ndc.x,e[s].ndc.y),i=a.distanceTo(o),.1>i&&(r.members.push(e[s]),this._b1.expandByPoint(e[s].morph.position),delete e[s]));r.min=[this._b1.min.x,this._b1.min.y,this._b1.min.z],r.max=[this._b1.max.x,this._b1.max.y,this._b1.max.z],n!==!0&&d(e,t)};this.calculate=()=>{if(r&&Date.now()-s>500){let e=[];d({...this.markers},e),u(e),s=Date.now(),this.markerUpdateRequired=!1}},this.isEnabled=()=>r,this.enable=()=>{r=!0,this.morph.visible=!0},this.disable=()=>{r=!1,this.morph.visible=!1;for(let e in this.markers)this.markers[e]?.isMarker&&this.markers[e].isEnabled()&&this.markers[e].setVisibility(!0)},this.zoomToCluster=e=>e!==void 0&&e>-1&&(this._v1.set(...i[e].min),this._v2.set(...i[e].max),Math.abs(this._v1.distanceTo(this._v2)>0))?(this._b1.set(this._v1,this._v2),n.translateBoundingBoxToCameraView(this._b1,3,300),this.markerUpdateRequired=!0,!0):!1,this.clusterIsVisible=e=>e!==void 0&&e>-1&&i[e]?i[e].group?.visible:!1};St.prototype=Object.create(V.prototype);var Ct=function(t){let n=t;this.camera=new e.OrthographicCamera(-.5,.5,.5,-.5,.01,10),this.helper=void 0;let r=new e.BufferGeometry;var i=new Float32Array([-1,-1,1,1,-1,1,1,1,1,1,1,1,-1,1,1,-1,-1,1]);let a=new e.BufferAttribute(i,3);r.setAttribute(`position`,a);var o=new e.MeshBasicMaterial({color:3355443,depthTest:!1,depthWrite:!1,opacity:.5,transparent:!0});this.mask=new e.Mesh(r,o);let s=new e.Box3,c=new e.Vector3;this.getDiffFromNormalised=(t,n)=>{s.setFromBufferAttribute(a).getCenter(c);let r=c.clone().project(this.camera);return new e.Vector3(t,n,r.z).unproject(this.camera).sub(c)};let l=(t,r)=>{n.camera.near&&(this.camera.near=n.camera.near),r.farPlane&&(this.camera.far=r.farPlane),r.eyePosition&&this.camera.position.set(r.eyePosition[0],r.eyePosition[1],r.eyePosition[2]),r.upVector&&this.camera.up.set(r.upVector[0],r.upVector[1],r.upVector[2]),r.targetPosition&&this.camera.lookAt(new e.Vector3(r.targetPosition[0],r.targetPosition[1],r.targetPosition[2])),this.camera.zoom=1/t,this.camera.updateProjectionMatrix()};this.getBoundary=()=>{let t=new e.Vector3().copy(n.camera.target).project(n.camera),r=new e.Vector3(-1,-1,t.z).unproject(n.camera),i=new e.Vector3(1,-1,t.z).unproject(n.camera),o=new e.Vector3(1,1,t.z).unproject(n.camera),s=[r,i,o,o,new e.Vector3(-1,1,t.z).unproject(n.camera),r];R(a,s)},this.updateCamera=()=>{this.getBoundary();let e=n.getZincCameraControls(),t=n.getBoundingBox();if(t){let n=t.min.distanceTo(t.max),r=n/2,i=(t.min.x+t.max.x)/2,a=(t.min.y+t.max.y)/2,o=(t.min.z+t.max.z)/2,s=e.getViewportFromCentreAndRadius(i,a,o,r,40,r*4);l(n,s)}}},wt=new e.Box3,Tt=new e.Vector3,Et=class extends e.InstancedBufferGeometry{constructor(){super(),this.isLineSegmentsGeometry=!0,this.type=`LineSegmentsGeometry`,this.setIndex([0,2,1,2,3,1,2,4,3,4,5,3,4,6,5,6,7,5]),this.setAttribute(`position`,new e.Float32BufferAttribute([-1,2,0,1,2,0,-1,1,0,1,1,0,-1,0,0,1,0,0,-1,-1,0,1,-1,0],3)),this.setAttribute(`uv`,new e.Float32BufferAttribute([-1,2,1,2,-1,1,1,1,-1,-1,1,-1,-1,-2,1,-2],2))}applyMatrix4(e){let t=this.attributes.instanceStart,n=this.attributes.instanceEnd;return t!==void 0&&(t.applyMatrix4(e),n.applyMatrix4(e),t.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}setPositions(t){let n;t instanceof Float32Array?n=t:Array.isArray(t)&&(n=new Float32Array(t));let r=new e.InstancedInterleavedBuffer(n,6,1);return this.setAttribute(`instanceStart`,new e.InterleavedBufferAttribute(r,3,0)),this.setAttribute(`instanceEnd`,new e.InterleavedBufferAttribute(r,3,3)),this.instanceCount=this.attributes.instanceStart.count,this.computeBoundingBox(),this.computeBoundingSphere(),this}setColors(t){let n;t instanceof Float32Array?n=t:Array.isArray(t)&&(n=new Float32Array(t));let r=new e.InstancedInterleavedBuffer(n,6,1);return this.setAttribute(`instanceColorStart`,new e.InterleavedBufferAttribute(r,3,0)),this.setAttribute(`instanceColorEnd`,new e.InterleavedBufferAttribute(r,3,3)),this}fromWireframeGeometry(e){return this.setPositions(e.attributes.position.array),this}fromEdgesGeometry(e){return this.setPositions(e.attributes.position.array),this}fromMesh(t){return this.fromWireframeGeometry(new e.WireframeGeometry(t.geometry)),this}fromLineSegments(e){let t=e.geometry;return this.setPositions(t.attributes.position.array),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new e.Box3);let t=this.attributes.instanceStart,n=this.attributes.instanceEnd;t!==void 0&&n!==void 0&&(this.boundingBox.setFromBufferAttribute(t),wt.setFromBufferAttribute(n),this.boundingBox.union(wt))}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new e.Sphere),this.boundingBox===null&&this.computeBoundingBox();let t=this.attributes.instanceStart,n=this.attributes.instanceEnd;if(t!==void 0&&n!==void 0){let e=this.boundingSphere.center;this.boundingBox.getCenter(e);let r=0;for(let i=0,a=t.count;i<a;i++)Tt.fromBufferAttribute(t,i),r=Math.max(r,e.distanceToSquared(Tt)),Tt.fromBufferAttribute(n,i),r=Math.max(r,e.distanceToSquared(Tt));this.boundingSphere.radius=Math.sqrt(r),isNaN(this.boundingSphere.radius)&&console.error(`THREE.LineSegmentsGeometry.computeBoundingSphere(): Computed radius is NaN. The instanced position data is likely to have NaN values.`,this)}}toJSON(){}};e.UniformsLib.line={worldUnits:{value:1},linewidth:{value:1},resolution:{value:new e.Vector2},dashOffset:{value:0},dashScale:{value:1},dashSize:{value:1},gapSize:{value:1}},e.ShaderLib.line={uniforms:e.UniformsUtils.merge([e.UniformsLib.common,e.UniformsLib.fog,e.UniformsLib.line]),vertexShader:`
|
|
92
|
+
`,nt=function(){return{brightness:{value:0},contrast:{value:1},depth:{value:1},discardAlpha:{value:!0},diffuse0:{value:void 0},diffuse1:{value:void 0},direction:{value:1},flipY:{value:!0},flipZ:{value:!1},nChannels:{value:1},mask:{value:void 0},maskEnabled:{value:!1},slide:{value:new e.Vector3(0,0,1)},time:{value:0}}},rt=function(e){V.call(this),this.isTexturePrimitive=!0,this.texture=e,this.textureList=[],this.texture&&this.textureList.push(this.texture),this.load=(e,t,n)=>{if(e&&e.images&&e.images.source){let n=new Qe,r=[];e.images.source.forEach(e=>{r.push(e)});let i=this;n.loadFromImages(r).then(()=>{i.texture=n,i.textureList.push(this.texture),i.initialise(e,t)})}},this.addTextureArray=e=>{this.textureList.length===0&&this.texture&&this.textureList.push(this.texture),e&&e.isTextureArray&&this.textureList.push(e)},this.initialise=(e,t)=>{t!=null&&typeof t==`function`&&t(this)}};rt.prototype=Object.create(V.prototype),rt.prototype.constructor=rt;var it=function(t){rt.call(this,t),this.isTextureSlides=!0;let n=[],r={};this.morph=new e.Group,this.group=this.morph,this.morph.userData=this;let i,a=!0,o=!1,s=0,c=1,l=1,u,d=!1,f=!0,p=0,m=0,h=-.1;this.createSlides=e=>{e.forEach(e=>this.createSlide(e))};let g=(e,t)=>{let n=e.material,r=n.uniforms;switch(e.rotation.x=0,e.rotation.y=0,e.rotation.z=0,e.position.x=0,e.position.y=0,e.position.z=0,t.direction){case`x`:let n=-Math.PI/2;e.rotation.y=n,r.direction.value=1,r.slide.value.set(t.value,0,0),e.position.x=t.value;break;case`y`:e.rotation.x=Math.PI/2,r.direction.value=2,r.slide.value.set(0,t.value,0),e.position.y=t.value;break;case`z`:r.direction.value=3,r.slide.value.set(0,0,t.value),e.position.z=t.value}n.needsUpdate=!0,this.boundingBoxUpdateRequired=!0};this.modifySlideSettings=e=>{e&&e.id&&e.id in r&&r[e.id]&&g(r[e.id],e)},this.createSlide=t=>{if(this.texture&&this.texture.isTextureArray&&this.texture.isReady()&&t&&t.direction&&t.value!==void 0){let i=new e.PlaneGeometry(1,1);i.translate(.5,.5,0);let p=nt();p.brightness.value=s,p.contrast.value=c,p.diffuse0.value=this.texture.impl,p.diffuse1.value=this.texture.impl,p.discardAlpha.value=f,p.depth.value=this.texture.size.depth,p.flipY.value=a,p.flipZ.value=o,p.mask.value=u,p.maskEnabled.value=d,p.nChannels.value=l;let m={fs:et,vs:tt,uniforms:p,glslVersion:$e,side:e.DoubleSide,transparent:!1},h=this.texture.getMaterial(m);h.needsUpdate=!0;let _=new e.Mesh(i,h);_.name=this.groupName,_.userData=this;let v={value:t.value,direction:t.direction,id:_.id};return n.push(v),g(_,v),r[_.id]=_,this.morph.add(_),this.boundingBoxUpdateRequired=!0,this.updateTimeTexture(),v}},this.getTextureSettings=()=>[...n],this.getTextureSettingsWithId=e=>{for(let t=0;t<n.length;t++)if(e===n[t].id)return{...n[t]}},this.getSlides=()=>this.morph?[...this.morph.children]:[],this.removeSlide=e=>{e&&this.removeSlideWithId(e.id)},this.removeSlideWithId=e=>{if(this.morph&&e in r&&r[e]){if(this.morph.getObjectById(e)){let t=r[e];this.morph.remove(t),t.clear(),t.geometry&&t.geometry.dispose(),t.material&&t.material.dispose(),this.boundingBoxUpdateRequired=!0}let t=n.findIndex(t=>t.id===e);t>-1&&n.splice(t,1)}},this.dispose=()=>{this.morph.children.forEach(e=>{e.geometry&&e.geometry.dispose(),e.material&&e.material.dispose()}),rt.prototype.dispose.call(this),this.boundingBoxUpdateRequired=!0};let _=(e,t,n)=>{if(t)switch(t.direction.value){case 1:n.copy(t.slide.value),e.expandByPoint(n),n.setY(1),n.setZ(1),e.expandByPoint(n);break;case 2:n.copy(t.slide.value),e.expandByPoint(n),n.setX(1),n.setZ(1),e.expandByPoint(n);break;case 3:n.copy(t.slide.value),e.expandByPoint(n),n.setX(1),n.setY(1),e.expandByPoint(n)}};this.getBoundingBox=()=>{if(this.morph&&this.morph.children&&this.morph.visible&&this.boundingBoxUpdateRequired){this.cachedBoundingBox.makeEmpty();let t=new e.Vector3(0,0,0);this.morph.children.forEach(e=>{_(this.cachedBoundingBox,e.material.uniforms,t)}),this.morph.updateMatrixWorld(!0,!0),this.cachedBoundingBox.applyMatrix4(this.morph.matrixWorld),this.boundingBoxUpdateRequired=!1}return this.cachedBoundingBox},this.applyTransformation=(t,n,r)=>{let i=new e.Matrix4;i.set(t[0],t[1],t[2],0,t[3],t[4],t[5],0,t[6],t[7],t[8],0,0,0,0,0);let a=new e.Quaternion().setFromRotationMatrix(i);this.morph.position.set(...n),this.morph.quaternion.copy(a),this.morph.scale.set(...r),this.morph.updateMatrix(),this.boundingBoxUpdateRequired=!0},this.setRenderOrder=e=>{this.morph.renderOrder=e},this.initialise=(e,t)=>{if(e){let n=e.locations;n&&n.length>0&&(this.applyTransformation(n[0].orientation,n[0].position,n[0].scale),`flipY`in n[0]&&(a=n[0].flipY),`flipZ`in n[0]&&(o=n[0].flipZ)),this.createSlides(e.settings.slides),t!=null&&typeof t==`function`&&t(this)}},this.showEdges=t=>{if(i)i.material.color=t;else{let n=new e.BoxGeometry(1,1,1);n.translate(.5,.5,.5);let r=new e.EdgesGeometry(n);i=new e.LineSegments(r,new e.LineBasicMaterial({color:t})),this.group.add(i)}i.visible=!0},this.setUniformsValue=(e,t)=>{this.morph.children.forEach(n=>{let r=n.material;if(r.type===`ShaderMaterial`){let n=r.uniforms;n[e].value=t,r.needsUpdate=!0}})},this.isAlphaPixelDiscarded=()=>f,this.discardAlphaPixel=e=>{f=e,this.setUniformsValue(`discardAlpha`,f)},this.getBrightness=()=>s,this.setBrightness=e=>{s=e,this.setUniformsValue(`brightness`,s)},this.getContrast=()=>c,this.setContrast=e=>{c>=0&&(c=e,this.setUniformsValue(`contrast`,c))},this.getNumberOfChannels=()=>l,this.setNumberOfChannels=e=>{l=e,this.setUniformsValue(`nChannels`,l)},this.getMask=()=>u,this.setMask=e=>{u=e,d=!!u,this.setUniformsValue(`mask`,u),this.setUniformsValue(`maskEnabled`,d)},this.hideEdges=()=>{i&&(i.visible=!1)},this.updateTimeTexture=()=>{let e=this.textureList.length-1,t=this.inbuildTime/this.duration;if(this.timeEnabled&&e>0&&h!==t){let n=t*e,r=Math.floor(n),i=Math.ceil(n),a=n-r;this.morph.children.forEach(e=>{let t=e.material;if(t.type===`ShaderMaterial`){let e=t.uniforms;p!==r&&(e.diffuse0.value=this.textureList[r].impl),m!==i&&(e.diffuse1.value=this.textureList[i].impl),e.time.value=a,t.needsUpdate=!0}}),p=r,m=i,h=t}},this.setMorphTime=e=>{let t=e;t=e>this.duration?this.duration:0>e?0:e,t!=this.inbuildTime&&(this.inbuildTime=t,this.updateTimeTexture())},this.render=(e,t,n)=>{if(t==1&&this.timeEnabled&&this.textureList.length>1){let t=this.inbuildTime+e;t>this.duration&&(t-=this.duration),this.inbuildTime=t,this.updateTimeTexture()}}};it.prototype=Object.create(rt.prototype),it.prototype.constructor=it;var at=function(){this.nearPlane=.168248,this.farPlane=6.82906,this.eyePosition=[.5,-2.86496,.5],this.targetPosition=[.5,.5,.5],this.upVector=[0,0,1];let e=this;this.setFromObject=({nearPlane:t,farPlane:n,eyePosition:r,targetPosition:i,upVector:a})=>{e.nearPlane=t,e.farPlane=n,e.eyePosition=r,e.targetPosition=i,e.upVector=a}},ot=function(t,n,r,i){let a={NONE:-1,DEFAULT:0,PATH:1,SMOOTH_CAMERA_TRANSITION:2,AUTO_TUMBLE:3,ROTATE_TRANSITION:4,MINIMAP:5,SYNC_CONTROL:6},o={NONE:-1,ROTATE:0,ZOOM:1,PAN:2,TOUCH_ROTATE:3,TOUCH_ZOOM:4,TOUCH_PAN:5,SCROLL:6,KEYBOARD_ZOOM:7,KEYBOARD_ROTATE:8,KEYBOARD_PAN:9},s={NONE:-1,FREE:1,HORIZONTAL:2,VERTICAL:3},c={ARROWLEFT:37,ARROWUP:38,ARROWRIGHT:39,ARROWDOWN:40,NUMPADADD:107,NUMPADSUBTRACT:109,EQUAL:187,MINUS:189},l={};l.MAIN=o.ROTATE,l.AUXILIARY=o.ZOOM,l.SECONDARY=o.PAN,this.cameraObject=t,this.domElement=n===void 0?document:n,this.renderer=r,this.scene=i,this.tumble_rate=1.5,this.pointer_x=0,this.pointer_y=0,this.pointer_x_start=0,this.pointer_y_start=0,this.previous_pointer_x=0,this.previous_pointer_y=0,this.near_plane_fly_debt=0,this.touchZoomDistanceStart=0,this.touchZoomDistanceEnd=0,this.directionalLight=0,this.zoomRate=50,this.rotateRate=50,this.panRate=100,this.pixelHeight=1;let u=6e3,d=!0,f=0,p,m,h=!1,g=500,_,v=`default`,y=a.DEFAULT,b,x,S,C=0,w=s.FREE;this._state=o.NONE;let T;this.targetTouchId=-1;let E,D=new e.Vector3,O=new e.Vector3,k=new e.Vector3,A=new e.Vector3,j=new e.Vector3,M=new e.Vector3,N=new e.Vector3,P=new e.Vector3,F=new e.Sphere,I=new e.Vector3,ee=!1,L,R=0,z={default:new at};z.default.nearPlane=.1,z.default.farPlane=2e3,z.default.eyePosition=[0,0,0],z.default.targetPosition=[0,0,-1],z.default.upVector=[0,1,0],this.cameraObject.target===void 0&&(this.cameraObject.target=new e.Vector3(...z.default.targetPosition)),this.calculateMaxAllowedDistance=e=>{let t=e.getBoundingBox();if(t){t.getBoundingSphere(F),R=F.radius*6;let e=0;this.cameraObject&&(e=this.cameraObject.position.distanceTo(F.center)),R=e>R?e*1.5:R}else R=0};let te=e=>{D.copy(this.cameraObject.position);let t=D.sub(this.cameraObject.target).length();this.cameraObject.near=Math.max(1e-4,t*.001),this.cameraObject.far=this.cameraObject.near*1e4};this.addViewport=(e,t)=>{e&&t&&(z[e]=t)},this.setDefaultViewport=e=>e&&e in z?(v=e,!0):!1,this.getDefaultViewport=()=>v,this.getViewportOfName=e=>z[e],this.setCurrentViewport=e=>e in z&&(this.setCurrentCameraSettings(z[e]),!0),this.setRotationMode=e=>{switch(e){case`none`:w=s.NONE;break;case`horizontal`:w=s.HORIZONTAL;break;case`vertical`:w=s.VERTICAL;break;default:w=s.FREE}},this.onResize=()=>{E&&=void 0,L&&L.setCurrentCameraSettings(this.cameraObject,z[v])},this.getVisibleHeightAtZDepth=e=>{let t=this.cameraObject.position.distanceTo(this.cameraObject.target);e<t?e-=t:e+=t;let n=this.cameraObject.fov*Math.PI/180;return 2*Math.tan(n/2)*Math.abs(e)},this.calculateHeightPerPixelAtZeroDepth=e=>{let t=this.getVisibleHeightAtZDepth(0);return this.pixelHeight=t/e,this.pixelHeight},this.getNDCFromDocumentCoords=(t,n,r)=>{B(!1);let i=r||new e.Vector2,a=(t-E.left)/E.width*2-1,o=-((n-E.top)/E.height)*2+1;return i.set(a,o)},this.getRelativeCoordsFromNDC=(t,n,r)=>{B(!1);let i=r||new e.Vector2;return i.x=(t+1)*E.width/2,i.y=(1-n)*E.height/2,i},this.setMouseButtonAction=(e,t)=>{l[e]=o[t]};let ne=(e,t)=>{e instanceof HTMLCanvasElement&&(e.tabIndex=t)},re=()=>{if(R>0){let e=I.distanceTo(F.center);return R>e||this.cameraObject.position.distanceTo(F.center)>e}return!0},ie=e=>{I.copy(this.cameraObject.position).add(e),re()&&(this.cameraObject.target.add(e),this.cameraObject.position.add(e),this.updateDirectionalLight())},ae=e=>{B(!1);let t;if(y===a.DEFAULT&&(t=this.scene.getNormalisedMinimapCoordinates(this.renderer,e)),!t)e.button==0?this._state=e.ctrlKey?l.AUXILIARY:e.shiftKey?l.SECONDARY:l.MAIN:e.button==1?(e.preventDefault(),this._state=l.AUXILIARY):e.button==2&&(this._state=l.SECONDARY),this.pointer_x=e.clientX-E.left,this.pointer_y=e.clientY-E.top,this.pointer_x_start=this.pointer_x,this.pointer_y_start=this.pointer_y,this.previous_pointer_x=this.pointer_x,this.previous_pointer_y=this.pointer_y;else{y=a.MINIMAP;let e=this.scene.getMinimapDiffFromNormalised(t.x,t.y);ie(e)}},oe=e=>{if(B(!1),E){if(this.pointer_x=e.clientX-E.left,this.pointer_y=e.clientY-E.top,y===a.MINIMAP){let t=this.scene.getNormalisedMinimapCoordinates(this.renderer,e);if(t){let e=this.scene.getMinimapDiffFromNormalised(t.x,t.y);ie(e)}}else this._state===o.NONE&&T!==void 0&&T.move(this,e.clientX,e.clientY,this.renderer)}},se=e=>{this._state=o.NONE,y==a.MINIMAP&&(y=a.DEFAULT),T!==void 0&&this.pointer_x_start==e.clientX-E.left&&this.pointer_y_start==e.clientY-E.top&&T.pick(this,e.clientX,e.clientY,this.renderer)},ce=e=>{this._state=o.NONE},le=e=>{B(!1);let t=e.touches.length;if(t==1)this._state=o.TOUCH_ROTATE,this.pointer_x=e.touches[0].clientX-E?.left,this.pointer_y=e.touches[0].clientY-E?.top,this.pointer_x_start=this.pointer_x,this.pointer_y_start=this.pointer_y,this.previous_pointer_x=this.pointer_x,this.previous_pointer_y=this.pointer_y;else if(t==2){this._state=o.TOUCH_ZOOM;let t=e.touches[0].clientX-e.touches[1].clientX,n=e.touches[0].clientY-e.touches[1].clientY;this.touchZoomDistanceEnd=this.touchZoomDistanceStart=Math.sqrt(t*t+n*n)}else t==3&&(this._state=o.TOUCH_PAN,this.targetTouchId=e.touches[0].identifier,this.pointer_x=e.touches[0].clientX-E?.left,this.pointer_y=e.touches[0].clientY-E?.top,this.previous_pointer_x=this.pointer_x,this.previous_pointer_y=this.pointer_y)},ue=e=>{e.preventDefault(),e.stopPropagation();let t=e.touches.length;if(t==1)this.pointer_x=e.touches[0].clientX-E.left,this.pointer_y=e.touches[0].clientY-E.top;else if(t==2){if(this._state===o.TOUCH_ZOOM){let t=e.touches[0].clientX-e.touches[1].clientX,n=e.touches[0].clientY-e.touches[1].clientY;this.touchZoomDistanceEnd=Math.sqrt(t*t+n*n)}}else if(t==3&&this._state===o.TOUCH_PAN)for(let t=0;t<3;t++)e.touches[t].identifier==this.targetTouchId&&(this.pointer_x=e.touches[0].clientX-E.left,this.pointer_y=e.touches[0].clientY-E.top)},de=e=>{let t=e.touches.length;this.touchZoomDistanceStart=this.touchZoomDistanceEnd=0,this.targetTouchId=-1,this._state=o.NONE,t==1&&T!==void 0&&this.pointer_x_start==e.touches[0].clientX-E.left&&this.pointer_y_start==e.touches[0].clientY-E.top&&T.pick(this.cameraObject,e.touches[0].clientX,e.touches[0].clientY,this.renderer)},fe=()=>{B(!0)},B=e=>{if(e||E===void 0){let e=new IntersectionObserver(t=>{for(let e of t)E=e.boundingClientRect;e.disconnect()});e.observe(this.domElement)}},pe=e=>{B(!1),this._state=o.SCROLL;let t=0;e.deltaY>0?t=this.zoomRate:e.deltaY<0&&(t=this.zoomRate*-1),C+=t,e.preventDefault(),e.stopImmediatePropagation()},me=e=>{B(!1);let t=0;if(e.keyCode===c.EQUAL||e.keyCode===c.MINUS||e.keyCode===c.NUMPADADD||e.keyCode===c.NUMPADSUBTRACT){this._state=o.KEYBOARD_ZOOM;let n=1;e.shiftKey&&(n*=2),e.keyCode===c.EQUAL||e.keyCode===c.NUMPADADD?t=this.zoomRate*n*-1:(e.keyCode===c.MINUS||e.keyCode===c.NUMPADSUBTRACT)&&(t=this.zoomRate*n),C+=t}else(e.keyCode===c.ARROWLEFT||e.keyCode===c.ARROWUP||e.keyCode===c.ARROWRIGHT||e.keyCode===c.ARROWDOWN)&&(e.shiftKey?(this._state=o.KEYBOARD_ROTATE,this.pointer_x_start=this.pointer_x,this.pointer_y_start=this.pointer_y,t=this.rotateRate):(this._state=o.KEYBOARD_PAN,t=this.panRate),this.previous_pointer_x=this.pointer_x,this.previous_pointer_y=this.pointer_y,e.keyCode===c.ARROWLEFT?this.pointer_x-=t:e.keyCode===c.ARROWUP?this.pointer_y-=t:e.keyCode===c.ARROWRIGHT?this.pointer_x+=t:e.keyCode===c.ARROWDOWN&&(this.pointer_y+=t));Object.values(c).includes(e.keyCode)&&e.preventDefault()},he=e=>{this._state=o.NONE},ge=()=>{if(this.cameraObject!==void 0){let e=E.height,t=this.cameraObject.position.distanceTo(this.cameraObject.target),n=0;this.cameraObject.far>this.cameraObject.near&&t>=this.cameraObject.near&&t<=this.cameraObject.far&&(n=(t-this.cameraObject.near)/(this.cameraObject.far-this.cameraObject.near)),O.set(this.previous_pointer_x,e-this.previous_pointer_y,0),k.set(this.previous_pointer_x,e-this.previous_pointer_y,1),A.set(this.pointer_x,e-this.pointer_y,0),j.set(this.pointer_x,e-this.pointer_y,1),O.unproject(this.cameraObject),k.unproject(this.cameraObject),A.unproject(this.cameraObject),j.unproject(this.cameraObject),A.sub(O).multiplyScalar(1-n),j.sub(k).multiplyScalar(n),A.add(j).multiplyScalar(-.002),ie(A)}this.previous_pointer_x=this.pointer_x,this.previous_pointer_y=this.pointer_y};this.getVectorsFromRotateAboutLookAtPoints=(e,t)=>{e.normalize(),N.copy(this.cameraObject.position).sub(this.cameraObject.target),P.copy(N),N.normalize(),.8<Math.abs(N.dot(e))&&N.copy(this.cameraObject.up),O.crossVectors(e,N).normalize(),k.crossVectors(e,O);let n=e.dot(P),r=O.dot(P),i=k.dot(P),a=e.dot(this.cameraObject.up),o=O.dot(this.cameraObject.up),s=k.dot(this.cameraObject.up),c=Math.cos(t),l=Math.sin(t);return A.set(c*O.x+l*k.x,c*O.y+l*k.y,c*O.z+l*k.z),j.set(c*k.x-l*O.x,c*k.y-l*O.y,c*k.z-l*O.z),N.copy(this.cameraObject.target),N.x=N.x+e.x*n+A.x*r+j.x*i,N.y=N.y+e.y*n+A.y*r+j.y*i,N.z=N.z+e.z*n+A.z*r+j.z*i,D.set(e.x*a+A.x*o+j.x*s,e.y*a+A.y*o+j.y*s,e.z*a+A.z*o+j.z*s),{position:N,up:D}},this.rotateAboutLookAtpoint=(e,t)=>{let n=this.getVectorsFromRotateAboutLookAtPoints(e,t);this.cameraObject.position.copy(n.position),this.updateDirectionalLight(),this.cameraObject.up.copy(n.up)};let _e=()=>{if(this.cameraObject!==void 0){let e=E?.width,t=E?.height;if(0<e&&0<t){let n=.25*(e+t),r=0,i=0;(w===s.FREE||w===s.HORIZONTAL)&&(r=this.pointer_x-this.previous_pointer_x),(w===s.FREE||w===s.VERTICAL)&&(i=this.previous_pointer_y-this.pointer_y);let a=Math.sqrt(r*r+i*i);if(a>0){let o=-i*1/a,c=r*1/a;if(w===s.FREE){let r=o*(this.pointer_x-.5*(e-1))+c*(.5*(t-1)-this.pointer_y);r>n?r=n:r<-n&&(r=-n)}let l=Math.acos(0/n)-.5*Math.PI,u=this.tumble_rate*a/n;D.copy(this.cameraObject.position).sub(this.cameraObject.target).normalize(),O.copy(this.cameraObject.up).normalize(),k.copy(O).cross(D).normalize().multiplyScalar(o),O.multiplyScalar(c),M.addVectors(k,O).multiplyScalar(Math.cos(l)),D.multiplyScalar(Math.sin(l)),M.add(D),this.rotateAboutLookAtpoint(M,-u)}}}this.previous_pointer_x=this.pointer_x,this.previous_pointer_y=this.pointer_y},ve=()=>{let e=0;return this._state===o.ZOOM?e=this.previous_pointer_y-this.pointer_y:this._state===o.SCROLL||this._state===o.KEYBOARD_ZOOM?e=C:(e=-1*(this.touchZoomDistanceEnd-this.touchZoomDistanceStart),this.touchZoomDistanceStart=this.touchZoomDistanceEnd),e};this.changeZoomByScrollRateUnit=e=>{let t=e*this.zoomRate;this.changeZoomByValue(t)},this.changeZoomByValue=e=>{if(this.cameraObject!==void 0){let t=E.height,n=this.cameraObject.position.clone();n.sub(this.cameraObject.target);let r=n.length(),i=r*(1.5*e/t);r+i>.01&&(n.normalize(),I.copy(this.cameraObject.position),I.x+=n.x*i,I.y+=n.y*i,I.z+=n.z*i,re()&&(this.cameraObject.position.copy(I),this.updateDirectionalLight(),te(i),ee=!0))}};let ye=()=>{let e=ve();this.changeZoomByValue(e),this._state===o.ZOOM&&(this.previous_pointer_x=this.pointer_x,this.previous_pointer_y=this.pointer_y),(this._state===o.SCROLL||this._state===o.KEYBOARD_ZOOM)&&(C=0,this._state=o.NONE)};this.setDirectionalLight=e=>{this.directionalLight=e},this.updateDirectionalLight=()=>{this.directionalLight!=0&&this.directionalLight.position.set(this.cameraObject.position.x,this.cameraObject.position.y,this.cameraObject.position.z)},this.enable=function(){d=!0,this.domElement&&this.domElement.addEventListener&&(ne(this.domElement,0),this.domElement.addEventListener(`mousedown`,ae,!1),this.domElement.addEventListener(`mousemove`,oe,!1),this.domElement.addEventListener(`mouseup`,se,!1),this.domElement.addEventListener(`mouseleave`,ce,!1),this.domElement.addEventListener(`touchstart`,le,!1),this.domElement.addEventListener(`touchmove`,ue,!1),this.domElement.addEventListener(`touchend`,de,!1),this.domElement.addEventListener(`wheel`,pe,!1),this.domElement.addEventListener(`mouseenter`,fe,!1),this.domElement.addEventListener(`contextmenu`,e=>{e.preventDefault()},!1),this.domElement.addEventListener(`keydown`,me,!1),this.domElement.addEventListener(`keyup`,he,!1))},this.disable=function(){d=!1,this.domElement&&this.domElement.removeEventListener&&(this.domElement.removeEventListener(`mousedown`,ae,!1),this.domElement.removeEventListener(`mousemove`,oe,!1),this.domElement.removeEventListener(`mouseup`,se,!1),this.domElement.removeEventListener(`mouseleave`,ce,!1),this.domElement.removeEventListener(`touchstart`,le,!1),this.domElement.removeEventListener(`touchmove`,ue,!1),this.domElement.removeEventListener(`touchend`,de,!1),this.domElement.removeEventListener(`wheel`,pe,!1),this.domElement.removeEventListener(`mouseenter`,fe,!1),this.domElement.removeEventListener(`contextmenu`,e=>{e.preventDefault()},!1),this.domElement.removeEventListener(`keydown`,me,!1),this.domElement.removeEventListener(`keyup`,he,!1),ne(this.domElement,-1))},this.loadPath=e=>{p=e.CameraPath,m=e.NumberOfPoints},this.loadPathURL=(e,t)=>{let n=e;fetch(n).then(e=>{if(!e.ok)throw Error(`HTTP error! status: ${e.status}`);return e.json()}).then(e=>{this.loadPath(e),t!==void 0&&typeof t==`function`&&t()}).catch(e=>{console.error(`Failed to load path asset from: ${n}`,e)})},this.setPathDuration=e=>{u=e,b&&b.setDuration(u),x&&x.setDuration(u)},this.getPlayRate=()=>g,this.setPlayRate=e=>{g=e};let be=e=>{let t=f+e;t>u&&(t-=u),f=t};this.getTime=()=>f,this.setTime=e=>{f=e>u?u:e<0?0:e},this.getNumberOfTimeFrame=()=>m,this.getCurrentTimeFrame=()=>{if(m>2){let e=f/u*(m-1),t=Math.floor(e),n=1-(e-t),r=Math.ceil(e);return t==r?t==m-1?[t-1,r,0]:[t,r+1,1]:[t,r,n]}if(m==1)return[0,0,0]},this.setCurrentTimeFrame=e=>{m>2&&(f=u*e/(m-1),f<0&&(f=0),f>u&&(f=u))};let xe=e=>{if(y===a.PATH&&(be(e),p)){let e=this.getCurrentTimeFrame(),t=e[0],n=e[1],r=e[2],i=[p[t*3],p[t*3+1],p[t*3+2]],a=[p[n*3],p[n*3+1],p[n*3+2]],o=[];for(let e=0;e<i.length;e++)o.push(r*i[e]+(1-r)*a[e]);this.cameraObject.position.set(o[0],o[1],o[2]),this.cameraObject.target.set(a[0],a[1],a[2]),_&&this.cameraObject.lookAt(this.cameraObject.target),h&&(this.directionalLight.position.set(o[0],o[1],o[2]),this.directionalLight.target.position.set(a[0],a[1],a[2]))}};this.calculatePathNow=()=>{xe(0)};let Se=()=>{this._state===o.ROTATE||this._state===o.TOUCH_ROTATE||this._state===o.KEYBOARD_ROTATE?_e():this._state===o.PAN||this._state===o.TOUCH_PAN||this._state===o.KEYBOARD_PAN?(ge(),L.triggerCallback()):(this._state===o.ZOOM||this._state===o.TOUCH_ZOOM||this._state===o.SCROLL||this._state===o.KEYBOARD_ZOOM)&&(L.zoom(ve()),this.previous_pointer_x=this.pointer_x,this.previous_pointer_y=this.pointer_y,(this._state===o.SCROLL||this._state===o.KEYBOARD_ZOOM)&&(this._state=o.NONE),C=0,L.triggerCallback())};this.update=e=>{let t=e*g,n=d,r=!0;return y===a.PATH?xe(t):y===a.SMOOTH_CAMERA_TRANSITION&&b?(b.update(t),b.isTransitionCompleted()&&(y=a.DEFAULT),n=!1):y===a.ROTATE_CAMERA_TRANSITION&&x?(x.update(t),x.isTransitionCompleted()&&(y=a.DEFAULT),n=!1):y===a.AUTO_TUMBLE&&S?S.update(t):y===a.SYNC_CONTROL&&L?(Se(),n=!1):r=!1,n&&(this._state!==o.NONE&&(r=!0),this._state===o.ROTATE||this._state===o.TOUCH_ROTATE||this._state===o.KEYBOARD_ROTATE?_e():this._state===o.PAN||this._state===o.TOUCH_PAN||this._state===o.KEYBOARD_PAN?ge():(this._state===o.ZOOM||this._state===o.TOUCH_ZOOM||this._state===o.SCROLL||this._state===o.KEYBOARD_ZOOM)&&ye(),this._state!==o.NONE&&y===a.AUTO_TUMBLE&&S&&S.stopOnCameraInput,this._state===o.SCROLL&&(this._state=o.NONE)),_?(r=!0,_.update()):this.cameraObject.lookAt(this.cameraObject.target),r||=ee,ee=!1,r},this.playPath=()=>{y=a.PATH},this.stopPath=()=>{y=a.DEFAULT},this.isPlayingPath=()=>y===a.PATH,this.enableDirectionalLightUpdateWithPath=e=>{h=e},this.enableDeviceOrientation=()=>{_||=new pt(this.cameraObject)},this.disableDeviceOrientation=()=>{_&&=(_.dispose(),void 0)},this.isDeviceOrientationEnabled=()=>!!_,this.resetView=()=>{let e=z[v];this.cameraObject.near=e.nearPlane,this.cameraObject.far=e.farPlane,this.cameraObject.position.set(e.eyePosition[0],e.eyePosition[1],e.eyePosition[2]),this.cameraObject.target.set(e.targetPosition[0],e.targetPosition[1],e.targetPosition[2]),this.cameraObject.up.set(e.upVector[0],e.upVector[1],e.upVector[2]),this.cameraObject.updateProjectionMatrix(),this.updateDirectionalLight()},this.setCurrentCameraSettings=e=>{e.nearPlane&&(this.cameraObject.near=e.nearPlane),e.farPlane&&(this.cameraObject.far=e.farPlane),e.eyePosition&&this.cameraObject.position.set(e.eyePosition[0],e.eyePosition[1],e.eyePosition[2]),e.targetPosition&&this.cameraObject.target.set(e.targetPosition[0],e.targetPosition[1],e.targetPosition[2]),e.upVector&&this.cameraObject.up.set(e.upVector[0],e.upVector[1],e.upVector[2]),this.cameraObject.updateProjectionMatrix(),this.updateDirectionalLight(),ee=!0},this.getViewportFromCentreAndRadius=(e,t,n,r,i,a)=>{D.copy(this.cameraObject.position),D.sub(this.cameraObject.target),D.normalize();let o=[e,t,n],s=r/Math.tan(i*Math.PI/360),c=[e+D.x*s,t+D.y*s,n+D.z*s],l=s+a,u=0;u=a>.95*s?.050000000000000044*s:s-a;let d=new at;return d.nearPlane=u,d.farPlane=l,d.eyePosition=c,d.targetPosition=o,d.upVector=[this.cameraObject.up.x,this.cameraObject.up.y,this.cameraObject.up.z],d},this.getViewportFromBoundingBox=(e,t)=>{let n=e.min.distanceTo(e.max)/2*t,r=(e.min.x+e.max.x)/2,i=(e.min.y+e.max.y)/2,a=(e.min.z+e.max.z)/2;return this.getViewportFromCentreAndRadius(r,i,a,n,40,n*4)},this.getCurrentViewport=()=>{let e=new at;return e.nearPlane=this.cameraObject.near,e.farPlane=this.cameraObject.far,e.eyePosition[0]=this.cameraObject.position.x,e.eyePosition[1]=this.cameraObject.position.y,e.eyePosition[2]=this.cameraObject.position.z,e.targetPosition[0]=this.cameraObject.target.x,e.targetPosition[1]=this.cameraObject.target.y,e.targetPosition[2]=this.cameraObject.target.z,e.upVector[0]=this.cameraObject.up.x,e.upVector[1]=this.cameraObject.up.y,e.upVector[2]=this.cameraObject.up.z,e},this.getDefaultEyePosition=()=>eyePosition,this.getDefaultTargetPosition=()=>targetPosition,this.cameraTransition=(e,t,n)=>{x??(b=new st(e,t,this,n))},this.rotateCameraTransition=(e,t,n)=>{b??(x=new ct(e,t,this,n))},this.enableCameraTransition=()=>{b&&(y=a.SMOOTH_CAMERA_TRANSITION),x&&(y=a.ROTATE_CAMERA_TRANSITION)},this.pauseCameraTransition=()=>{y=a.DEFAULT},this.stopCameraTransition=()=>{y=a.DEFAULT,b=void 0,x=void 0},this.isTransitioningCamera=()=>y===a.SMOOTH_CAMERA_TRANSITION||y===a.ROTATE_CAMERA_TRANSITION,this.autoTumble=(e,t,n)=>{S=new ut(e,t,n,this)},this.enableAutoTumble=()=>{y=a.AUTO_TUMBLE},this.stopAutoTumble=()=>{y=a.DEFAULT,S=void 0},this.updateAutoTumble=()=>{S&&(S.requireUpdate=!0)},this.isAutoTumble=()=>y===a.AUTO_TUMBLE,this.enableRaycaster=(e,t,n)=>{T??=new lt(e,this.scene,t,n,this.renderer)},this.disableRaycaster=()=>{T.disable(),T=void 0},this.isSyncControl=()=>currentMpde===a.SYNC_CONTROL,this.enableSyncControl=()=>(y=a.SYNC_CONTROL,L||=new mt,L.setCurrentCameraSettings(this.cameraObject,z[v]),L),this.disableSyncControl=()=>{y=a.DEFAULT,this.cameraObject.zoom=1,this.cameraObject.updateProjectionMatrix()},this.enable()},st=function(e,t,n,r){let i=e.eyePosition,a=e.targetPosition,o=e.upVector,s=t.eyePosition,c=t.targetPosition,l=t.upVector,u=n,d=r,f=0,p=!1;u.near=Math.min(e.nearPlane,t.nearPlane),u.far=Math.max(e.farPlane,t.farPlane),u.cameraObject.up.set(t.upVector[0],t.upVector[1],t.upVector[2]),this.setDuration=e=>{d=e};let m=e=>{let t=f+e;t>d&&(t=d),f=t},h=()=>{let e=f/d,t=[i[0]*(1-e)+s[0]*e,i[1]*(1-e)+s[1]*e,i[2]*(1-e)+s[2]*e],n=[a[0]*(1-e)+c[0]*e,a[1]*(1-e)+c[1]*e,a[2]*(1-e)+c[2]*e];o[0]*(1-e)+l[0]*e,o[1]*(1-e)+l[1]*e,o[2]*(1-e)+l[2]*e,u.cameraObject.position.set(t[0],t[1],t[2]),u.cameraObject.target.set(n[0],n[1],n[2])};this.update=e=>{this.enabled!==!1&&(m(e),h(),f==d&&(p=!0))},this.isTransitionCompleted=()=>p},ct=function(e,t,n,r){let i=e,a=t,o=n,s=r,c=0;c/s;let l=!1;this.setDuration=e=>{s=e};let u=e=>{let t=c,n=c+e;n>s&&(n=s),c=n;let r=(c-t)/s*a;o.rotateAboutLookAtpoint(i,r)};this.update=e=>{this.enabled!==!1&&(u(e),c==s&&(l=!0))},this.isTransitionCompleted=()=>l},lt=function(t,n,r,i,a){let o=t,s=n,c=a,l=r,u=i,d=!0,f=new e.Raycaster;f.params.Line.threshold=.1,f.params.Points.threshold=1;let p=new e.Vector2,m=!1,h=new Date,g=!1,_=0,v=[],y={zincCamera:void 0,x:-1,y:-1},b;this.enable=()=>{d=!0},this.disable=()=>{d=!1},this.getIntersectsObject=e=>{if(s!==o){let t=o.getThreeJSScene();c.render(t,e.cameraObject)}let t=b||o.getPickableThreeJSObjects();return v.length=0,f.intersectObjects(t,!0,v)},this.setPickableObjects=e=>{e===void 0?b=void 0:(b=[],e.forEach(e=>{e.getGroup()&&e.getGroup().visible&&b.push(e.getGroup())}))},this.getIntersectsObjectWithOrigin=(e,t,n)=>(f.set(t,n),this.getIntersectsObject(e)),this.getIntersectsObjectWithCamera=(e,t,n)=>(e.getNDCFromDocumentCoords(t,n,p),f.setFromCamera(p,e.cameraObject),this.getIntersectsObject(e)),this.pick=(e,t,n)=>{if(d&&c&&o&&e&&l){this.getIntersectsObjectWithCamera(e,t,n);let r=v.length;for(let e=0;e<r;e++){let t=v[e].object?v[e].object.userData:void 0;if(t&&t.isMarkerCluster&&t.visible&&t.clusterIsVisible(v[e].object.clusterIndex)&&t.zoomToCluster(v[e].object.clusterIndex))return}l(v,t,n)}};let x=(e,t,n)=>{if(d&&c&&o&&e&&u){if(this.getIntersectsObjectWithCamera(e,t,n),h.setTime(Date.now()),v.length===0){if(g)return;g=!0}else g=!1;u(v,t,n)}};this.move=(e,t,n)=>{d&&c&&o&&e&&u&&(o.displayMarkers?x(e,t,n):(y.zincCamera=e,y.x=t,y.y=n,m||(_=h?Date.now()-h.getTime():250,_>=250?x(e,t,n):(m=!0,setTimeout(S(y),_)))))};let S=e=>function(){m=!1,x(e.zincCamera,e.x,e.y)}},ut=function(t,n,r,i){let a=new e.Vector3,o=-n,s=i,c=t;this.stopOnCameraInput=r,this.requireUpdate=!0;let l=new e.Vector3,u=new e.Vector3,d=e=>{let t=Math.sqrt(e[0]*e[0]+e[1]*e[1]),n=.25*(Math.abs(e[0])*4+Math.abs(e[1])*4),r=-e[1]/t,i=e[0]/t,o=r*e[0]+i*-e[1];o>n?o=n:o<-n&&(o=-n);let c=Math.acos(o/n)-.5*Math.PI;a.copy(s.cameraObject.position).sub(s.cameraObject.target).normalize(),l.copy(s.cameraObject.up).normalize(),u.crossVectors(l,a).normalize().multiplyScalar(r),l.multiplyScalar(i),l.add(u).multiplyScalar(Math.cos(c)),a.multiplyScalar(Math.sin(c)).add(l)};this.update=e=>{this.enabled!==!1&&(this.requireUpdate&&=(d(c),!1),s.rotateAboutLookAtpoint(a,o*e/1e3))}},dt=function(){this.type=`StereoCamera`,this.aspect=1,this.cameraL=new e.PerspectiveCamera,this.cameraL.layers.enable(1),this.cameraL.matrixAutoUpdate=!1,this.cameraR=new e.PerspectiveCamera,this.cameraR.layers.enable(2),this.cameraR.matrixAutoUpdate=!1};Object.assign(dt.prototype,{update:(()=>{let t,n,r,i,a,o,s=new e.Matrix4,c=new e.Matrix4;return function(l){if(t!==l.focus||n!==l.fov||r!==l.aspect*this.aspect||i!==l.near||a!==l.far||o!==l.zoom){t=l.focus,n=l.fov,r=l.aspect*this.aspect,i=l.near,a=l.far,o=l.zoom;let u=l.projectionMatrix.clone(),d=.064/2,f=d*i/t,p=i*Math.tan(e.Math.DEG2RAD*n*.5)/l.zoom,m,h;c.elements[12]=-.032,s.elements[12]=d,m=-p*r+f,h=p*r+f,u.elements[0]=2*i/(h-m),u.elements[8]=(h+m)/(h-m),this.cameraL.projectionMatrix.copy(u),m=-p*r-f,h=p*r-f,u.elements[0]=2*i/(h-m),u.elements[8]=(h+m)/(h-m),this.cameraR.projectionMatrix.copy(u)}this.cameraL.matrixWorld.copy(l.matrixWorld).multiply(c),this.cameraR.matrixWorld.copy(l.matrixWorld).multiply(s)}})()});var ft=function(e){let t=new dt;t.aspect=.5,this.setSize=(t,n)=>{e.setSize(t,n)},this.render=(n,r)=>{n.updateMatrixWorld(),r.parent===null&&r.updateMatrixWorld(),t.update(r);let i=e.getSize();e.setScissorTest(!0),e.clear(),e.setScissor(0,0,i.width/2,i.height),e.setViewport(0,0,i.width/2,i.height),e.render(n,t.cameraL),e.setScissor(i.width/2,0,i.width/2,i.height),e.setViewport(i.width/2,0,i.width/2,i.height),e.render(n,t.cameraR),e.setScissorTest(!1)}},pt=function(t){let n=this;this.object=t,this.object.rotation.reorder(`YXZ`),this.enabled=!0,this.deviceOrientation={},this.screenOrientation=0;let r=e=>{n.deviceOrientation=e},i=()=>{typeof window<`u`&&(n.screenOrientation=window.orientation||0)},a=(()=>{let t=new e.Vector3(0,0,1),n=new e.Euler,r=new e.Quaternion,i=new e.Quaternion(-Math.sqrt(.5),0,0,Math.sqrt(.5));return(a,o,s,c,l)=>{let u=new e.Vector3(0,0,1);u.subVectors(a.target,a.position),n.set(s,o,-c,`YXZ`);let d=new e.Quaternion;d.setFromEuler(n),d.multiply(i),d.multiply(r.setFromAxisAngle(t,-l)),u.applyQuaternion(d),u.addVectors(a.position,u),a.lookAt(u)}})();this.connect=()=>{i(),typeof window<`u`&&(window.addEventListener(`orientationchange`,i,!1),window.addEventListener(`deviceorientation`,r,!1)),n.enabled=!0},this.disconnect=()=>{typeof window<`u`&&(window.removeEventListener(`orientationchange`,i,!1),window.removeEventListener(`deviceorientation`,r,!1)),n.enabled=!1},this.update=()=>{if(n.enabled===!1)return;let t=n.deviceOrientation.alpha?e.Math.degToRad(n.deviceOrientation.alpha):0,r=n.deviceOrientation.beta?e.Math.degToRad(n.deviceOrientation.beta):0,i=n.deviceOrientation.gamma?e.Math.degToRad(n.deviceOrientation.gamma):0,o=n.screenOrientation?e.Math.degToRad(n.screenOrientation):0;a(n.object,t,r,i,o)},this.dispose=function(){this.disconnect()},this.connect()},mt=function(){let t,n,r,i=new e.Vector3,a=new e.Vector3,o=new e.Vector3,s=new e.Vector3,c;this.setCurrentCameraSettings=(o,s)=>{this.near_plane_fly_debt,t=o.clone(),n=o,r=s,t.near=r.nearPlane,r.farPlane&&(t.far=r.farPlane),r.eyePosition&&t.position.set(r.eyePosition[0],r.eyePosition[1],r.eyePosition[2]),r.upVector&&t.up.set(r.upVector[0],r.upVector[1],r.upVector[2]),r.targetPosition&&(t.target=new e.Vector3(r.targetPosition[0],r.targetPosition[1],r.targetPosition[2]),t.lookAt(t.target)),t.updateProjectionMatrix(),i.copy(t.position).project(t),a.copy(t.target).project(t)},this.getCurrentPosition=()=>(a.copy(n.target).project(t),[a.x,a.y]),this.zoom=e=>{let t=e*.002,r=Math.max(n.zoom-t,1);n.zoom=r,n.updateProjectionMatrix()},this.zoomToBox=(e,n)=>{e.getCenter(o),o.project(t),this.setCenterZoom([o.x,o.y],n)},this.getPanZoom=()=>({target:this.getCurrentPosition(),zoom:n.zoom}),this.setCenterZoom=(e,r)=>{o.set(e[0],e[1],a.z).unproject(t),s.copy(o).sub(n.target),n.target.copy(o),n.lookAt(n.target),n.position.add(s),n.zoom=r,n.updateProjectionMatrix()},this.setEventCallback=e=>{(e===void 0||typeof e==`function`)&&(c=e)},this.triggerCallback=()=>{c!==void 0&&typeof c==`function`&&c()}},ht=new e.TextureLoader().load(`data:image/svg+xml,%3c?xml%20version='1.0'%20encoding='UTF-8'%20standalone='no'%20?%3e%3c!DOCTYPE%20svg%20PUBLIC%20'-//W3C//DTD%20SVG%201.1//EN'%20'http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd'%3e%3csvg%20xmlns='http://www.w3.org/2000/svg'%20xmlns:xlink='http://www.w3.org/1999/xlink'%20version='1.1'%20width='365'%20height='560'%20viewBox='0%200%20365%20560'%20xml:space='preserve'%3e%3cdesc%3eCreated%20with%20Fabric.js%205.2.4%3c/desc%3e%3cdefs%3e%3c/defs%3e%3crect%20x='0'%20y='0'%20width='100%25'%20height='100%25'%20fill='transparent'%3e%3c/rect%3e%3cg%20transform='matrix(0%200%200%200%200%200)'%20id='808ed283-2524-440f-88ae-3bdb47bb5749'%20%3e%3c/g%3e%3cg%20transform='matrix(1%200%200%201%20182.5%20280)'%20id='db30413d-5bff-4b98-ab59-464497ee199e'%20%3e%3crect%20style='stroke:%20none;%20stroke-width:%201;%20stroke-dasharray:%20none;%20stroke-linecap:%20butt;%20stroke-dashoffset:%200;%20stroke-linejoin:%20miter;%20stroke-miterlimit:%204;%20fill:%20rgb(255,255,255);%20fill-rule:%20nonzero;%20opacity:%201;%20visibility:%20hidden;'%20vector-effect='non-scaling-stroke'%20x='-182.5'%20y='-280'%20rx='0'%20ry='0'%20width='365'%20height='560'%20/%3e%3c/g%3e%3cg%20transform='matrix(0%200%200%200%200%2097.5)'%20%3e%3cg%20style=''%20%3e%3c/g%3e%3c/g%3e%3cg%20transform='matrix(0%200%200%200%200%2097.5)'%20%3e%3cg%20style=''%20%3e%3c/g%3e%3c/g%3e%3cg%20transform='matrix(0.99%200%200%200.99%20182.5%20280)'%20%3e%3cg%20style=''%20vector-effect='non-scaling-stroke'%20%3e%3cg%20transform='matrix(1%200%200%201%200%200)'%20%3e%3crect%20style='stroke:%20none;%20stroke-width:%201;%20stroke-dasharray:%20none;%20stroke-linecap:%20butt;%20stroke-dashoffset:%200;%20stroke-linejoin:%20miter;%20stroke-miterlimit:%204;%20fill:%20rgb(255,255,255);%20fill-rule:%20nonzero;%20opacity:%201;%20visibility:%20hidden;'%20vector-effect='non-scaling-stroke'%20x='-540'%20y='-540'%20rx='0'%20ry='0'%20width='1080'%20height='1080'%20/%3e%3c/g%3e%3cg%20transform='matrix(1%200%200%201%200%200)'%20%3e%3cpath%20style='stroke:%20rgb(0,0,0);%20stroke-width:%200;%20stroke-dasharray:%20none;%20stroke-linecap:%20butt;%20stroke-dashoffset:%200;%20stroke-linejoin:%20miter;%20stroke-miterlimit:%204;%20fill:%20rgb(255,165,0);%20fill-rule:%20nonzero;%20opacity:%201;'%20vector-effect='non-scaling-stroke'%20transform='%20translate(-182.9,%20-279.85)'%20d='M%20182.9%20551.7%20C%20182.9%20551.8000000000001%20183.1%20552%20183.1%20552%20C%20183.1%20552%20358.3%20283%20358.3%20194.6%20C%20358.3%2064.5%20269.5%207.900000000000006%20182.9%207.699999999999989%20C%2096.3%207.9%207.5%2064.5%207.5%20194.6%20C%207.5%20283%20182.8%20552%20182.8%20552%20C%20182.8%20552%20182.9%20551.7%20182.9%20551.7%20z%20M%20122.2%20187.2%20C%20122.2%20153.6%20149.4%20126.39999999999999%20183%20126.39999999999999%20C%20216.6%20126.39999999999999%20243.8%20153.6%20243.8%20187.2%20C%20243.8%20220.79999999999998%20216.5%20248%20182.9%20248%20C%20149.4%20248%20122.2%20220.8%20122.2%20187.2%20z'%20stroke-linecap='round'%20/%3e%3c/g%3e%3cg%20transform='matrix(3.82%200%200%203.82%200%20-100.77)'%20%3e%3ccircle%20style='stroke:%20rgb(0,0,0);%20stroke-width:%200;%20stroke-dasharray:%20none;%20stroke-linecap:%20butt;%20stroke-dashoffset:%200;%20stroke-linejoin:%20miter;%20stroke-miterlimit:%204;%20fill:%20rgb(255,255,255);%20fill-rule:%20nonzero;%20opacity:%201;'%20vector-effect='non-scaling-stroke'%20cx='0'%20cy='0'%20r='35'%20/%3e%3c/g%3e%3c/g%3e%3c/g%3e%3c/svg%3e`);ht.colorSpace=e.SRGBColorSpace;var gt=[.02,.03,1],_t=new e.SpriteMaterial({map:ht,alphaTest:.5,transparent:!0,depthTest:!1,depthWrite:!1,sizeAttenuation:!1}),vt=function(t){V.call(this),this.texture=ht;let n=t;this.morph=new e.Group,this.group=this.morph,this.isMarkerCluster=!0;let r=!0,i=[];this.markers={};let a=new e.Vector2,o=new e.Vector2,s=Date.now();this.setSpriteSize=e=>{(void 0).scale.set(.015,.02,1),(void 0).scale.multiplyScalar(e)},this.clear=()=>{this.group.clear(),this.markers={}},this.dispose=()=>{this.clear(),this.morph&&this.morph.clear()};let c=t=>{let n=new e.Group,r=new e.Sprite(_t);return r.clusterIndex=t,r.center.set(.5,0),r.position.set(0,0,0),r.renderOrder=1e4,r.scale.set(gt[0],gt[1],gt[2]),r.userData=this,n.add(r),this.group.add(n),{group:n,marker:r,label:void 0,number:0,min:[0,0,0],max:[1,1,1]}},l=(e,t,n)=>{e.group.visible=!0,e.group.position.set(t.coords[0],t.coords[1],t.coords[2]),(e.label===void 0||n!==e.number)&&(e.label&&(e.group.remove(e.label),e.label.material.map.dispose(),e.label.material.dispose()),e.label=F(n,.012,`black`,`Asap`,120,700),e.label.renderOrder=10001,e.number=n,e.group.add(e.label)),e.min=t.min,e.max=t.max},u=e=>{let t=0;for(e.forEach(e=>{let n=e.members.length,r=0;n===1?e.members[0].setVisibility(!0):(e.members.forEach(e=>{r+=e.getNumber(),e.setVisibility(!1)}),i[t]||i.push(c(t)),l(i[t],e,r),t++)});t<i.length;t++)i[t].group.visible=!1},d=(e,t)=>{let n=!0,r={members:[],coords:[0,0,0],min:[0,0,0],max:[1,1,1]},i=0;for(let s in e)n?(a.set(e[s].ndc.x,e[s].ndc.y),this._b1.setFromPoints([e[s].morph.position]),n=!1,r.members.push(e[s]),r.coords=[e[s].morph.position.x,e[s].morph.position.y,e[s].morph.position.z],t.push(r),delete e[s]):(o.set(e[s].ndc.x,e[s].ndc.y),i=a.distanceTo(o),.1>i&&(r.members.push(e[s]),this._b1.expandByPoint(e[s].morph.position),delete e[s]));r.min=[this._b1.min.x,this._b1.min.y,this._b1.min.z],r.max=[this._b1.max.x,this._b1.max.y,this._b1.max.z],n!==!0&&d(e,t)};this.calculate=()=>{if(r&&Date.now()-s>500){let e=[];d({...this.markers},e),u(e),s=Date.now(),this.markerUpdateRequired=!1}},this.isEnabled=()=>r,this.enable=()=>{r=!0,this.morph.visible=!0},this.disable=()=>{r=!1,this.morph.visible=!1;for(let e in this.markers)this.markers[e]?.isMarker&&this.markers[e].isEnabled()&&this.markers[e].setVisibility(!0)},this.zoomToCluster=e=>e!==void 0&&e>-1&&(this._v1.set(...i[e].min),this._v2.set(...i[e].max),Math.abs(this._v1.distanceTo(this._v2)>0))?(this._b1.set(this._v1,this._v2),n.translateBoundingBoxToCameraView(this._b1,3,300),this.markerUpdateRequired=!0,!0):!1,this.clusterIsVisible=e=>e!==void 0&&e>-1&&i[e]?i[e].group?.visible:!1};vt.prototype=Object.create(V.prototype);var yt=function(t){let n=t;this.camera=new e.OrthographicCamera(-.5,.5,.5,-.5,.01,10),this.helper=void 0;let r=new e.BufferGeometry;var i=new Float32Array([-1,-1,1,1,-1,1,1,1,1,1,1,1,-1,1,1,-1,-1,1]);let a=new e.BufferAttribute(i,3);r.setAttribute(`position`,a);var o=new e.MeshBasicMaterial({color:3355443,depthTest:!1,depthWrite:!1,opacity:.5,transparent:!0});this.mask=new e.Mesh(r,o);let s=new e.Box3,c=new e.Vector3;this.getDiffFromNormalised=(t,n)=>{s.setFromBufferAttribute(a).getCenter(c);let r=c.clone().project(this.camera);return new e.Vector3(t,n,r.z).unproject(this.camera).sub(c)};let l=(t,r)=>{n.camera.near&&(this.camera.near=n.camera.near),r.farPlane&&(this.camera.far=r.farPlane),r.eyePosition&&this.camera.position.set(r.eyePosition[0],r.eyePosition[1],r.eyePosition[2]),r.upVector&&this.camera.up.set(r.upVector[0],r.upVector[1],r.upVector[2]),r.targetPosition&&this.camera.lookAt(new e.Vector3(r.targetPosition[0],r.targetPosition[1],r.targetPosition[2])),this.camera.zoom=1/t,this.camera.updateProjectionMatrix()};this.getBoundary=()=>{let t=new e.Vector3().copy(n.camera.target).project(n.camera),r=new e.Vector3(-1,-1,t.z).unproject(n.camera),i=new e.Vector3(1,-1,t.z).unproject(n.camera),o=new e.Vector3(1,1,t.z).unproject(n.camera),s=[r,i,o,o,new e.Vector3(-1,1,t.z).unproject(n.camera),r];R(a,s)},this.updateCamera=()=>{this.getBoundary();let e=n.getZincCameraControls(),t=n.getBoundingBox();if(t){let n=t.min.distanceTo(t.max),r=n/2,i=(t.min.x+t.max.x)/2,a=(t.min.y+t.max.y)/2,o=(t.min.z+t.max.z)/2,s=e.getViewportFromCentreAndRadius(i,a,o,r,40,r*4);l(n,s)}}},bt=new e.Box3,xt=new e.Vector3,St=class extends e.InstancedBufferGeometry{constructor(){super(),this.isLineSegmentsGeometry=!0,this.type=`LineSegmentsGeometry`,this.setIndex([0,2,1,2,3,1,2,4,3,4,5,3,4,6,5,6,7,5]),this.setAttribute(`position`,new e.Float32BufferAttribute([-1,2,0,1,2,0,-1,1,0,1,1,0,-1,0,0,1,0,0,-1,-1,0,1,-1,0],3)),this.setAttribute(`uv`,new e.Float32BufferAttribute([-1,2,1,2,-1,1,1,1,-1,-1,1,-1,-1,-2,1,-2],2))}applyMatrix4(e){let t=this.attributes.instanceStart,n=this.attributes.instanceEnd;return t!==void 0&&(t.applyMatrix4(e),n.applyMatrix4(e),t.needsUpdate=!0),this.boundingBox!==null&&this.computeBoundingBox(),this.boundingSphere!==null&&this.computeBoundingSphere(),this}setPositions(t){let n;t instanceof Float32Array?n=t:Array.isArray(t)&&(n=new Float32Array(t));let r=new e.InstancedInterleavedBuffer(n,6,1);return this.setAttribute(`instanceStart`,new e.InterleavedBufferAttribute(r,3,0)),this.setAttribute(`instanceEnd`,new e.InterleavedBufferAttribute(r,3,3)),this.instanceCount=this.attributes.instanceStart.count,this.computeBoundingBox(),this.computeBoundingSphere(),this}setColors(t){let n;t instanceof Float32Array?n=t:Array.isArray(t)&&(n=new Float32Array(t));let r=new e.InstancedInterleavedBuffer(n,6,1);return this.setAttribute(`instanceColorStart`,new e.InterleavedBufferAttribute(r,3,0)),this.setAttribute(`instanceColorEnd`,new e.InterleavedBufferAttribute(r,3,3)),this}fromWireframeGeometry(e){return this.setPositions(e.attributes.position.array),this}fromEdgesGeometry(e){return this.setPositions(e.attributes.position.array),this}fromMesh(t){return this.fromWireframeGeometry(new e.WireframeGeometry(t.geometry)),this}fromLineSegments(e){let t=e.geometry;return this.setPositions(t.attributes.position.array),this}computeBoundingBox(){this.boundingBox===null&&(this.boundingBox=new e.Box3);let t=this.attributes.instanceStart,n=this.attributes.instanceEnd;t!==void 0&&n!==void 0&&(this.boundingBox.setFromBufferAttribute(t),bt.setFromBufferAttribute(n),this.boundingBox.union(bt))}computeBoundingSphere(){this.boundingSphere===null&&(this.boundingSphere=new e.Sphere),this.boundingBox===null&&this.computeBoundingBox();let t=this.attributes.instanceStart,n=this.attributes.instanceEnd;if(t!==void 0&&n!==void 0){let e=this.boundingSphere.center;this.boundingBox.getCenter(e);let r=0;for(let i=0,a=t.count;i<a;i++)xt.fromBufferAttribute(t,i),r=Math.max(r,e.distanceToSquared(xt)),xt.fromBufferAttribute(n,i),r=Math.max(r,e.distanceToSquared(xt));this.boundingSphere.radius=Math.sqrt(r),isNaN(this.boundingSphere.radius)&&console.error(`THREE.LineSegmentsGeometry.computeBoundingSphere(): Computed radius is NaN. The instanced position data is likely to have NaN values.`,this)}}toJSON(){}};e.UniformsLib.line={worldUnits:{value:1},linewidth:{value:1},resolution:{value:new e.Vector2},dashOffset:{value:0},dashScale:{value:1},dashSize:{value:1},gapSize:{value:1}},e.ShaderLib.line={uniforms:e.UniformsUtils.merge([e.UniformsLib.common,e.UniformsLib.fog,e.UniformsLib.line]),vertexShader:`
|
|
93
93
|
#include <common>
|
|
94
94
|
#include <color_pars_vertex>
|
|
95
95
|
#include <fog_pars_vertex>
|
|
@@ -481,11 +481,11 @@ void main() {
|
|
|
481
481
|
#include <premultiplied_alpha_fragment>
|
|
482
482
|
|
|
483
483
|
}
|
|
484
|
-
`};var Dt=class extends e.ShaderMaterial{constructor(t){super({type:`LineMaterial`,uniforms:e.UniformsUtils.clone(e.ShaderLib.line.uniforms),vertexShader:e.ShaderLib.line.vertexShader,fragmentShader:e.ShaderLib.line.fragmentShader,clipping:!0}),this.isLineMaterial=!0,this.setValues(t)}get color(){return this.uniforms.diffuse.value}set color(e){this.uniforms.diffuse.value=e}get worldUnits(){return`WORLD_UNITS`in this.defines}set worldUnits(e){e===!0!==this.worldUnits&&(this.needsUpdate=!0),e===!0?this.defines.WORLD_UNITS=``:delete this.defines.WORLD_UNITS}get linewidth(){return this.uniforms.linewidth.value}set linewidth(e){this.uniforms.linewidth&&(this.uniforms.linewidth.value=e)}get dashed(){return`USE_DASH`in this.defines}set dashed(e){e===!0!==this.dashed&&(this.needsUpdate=!0),e===!0?this.defines.USE_DASH=``:delete this.defines.USE_DASH}get dashScale(){return this.uniforms.dashScale.value}set dashScale(e){this.uniforms.dashScale.value=e}get dashSize(){return this.uniforms.dashSize.value}set dashSize(e){this.uniforms.dashSize.value=e}get dashOffset(){return this.uniforms.dashOffset.value}set dashOffset(e){this.uniforms.dashOffset.value=e}get gapSize(){return this.uniforms.gapSize.value}set gapSize(e){this.uniforms.gapSize.value=e}get opacity(){return this.uniforms.opacity.value}set opacity(e){this.uniforms&&(this.uniforms.opacity.value=e)}get resolution(){return this.uniforms.resolution.value}set resolution(e){this.uniforms.resolution.value.copy(e)}get alphaToCoverage(){return`USE_ALPHA_TO_COVERAGE`in this.defines}set alphaToCoverage(e){this.defines&&(e===!0!==this.alphaToCoverage&&(this.needsUpdate=!0),e===!0?this.defines.USE_ALPHA_TO_COVERAGE=``:delete this.defines.USE_ALPHA_TO_COVERAGE)}},Ot=new e.Vector4,kt=new e.Vector3,At=new e.Vector3,H=new e.Vector4,U=new e.Vector4,W=new e.Vector4,jt=new e.Vector3,Mt=new e.Matrix4,G=new e.Line3,Nt=new e.Vector3,Pt=new e.Box3,Ft=new e.Sphere,K=new e.Vector4,q,It;function Lt(e,t,n){return K.set(0,0,-t,1).applyMatrix4(e.projectionMatrix),K.multiplyScalar(1/K.w),K.x=It/n.width,K.y=It/n.height,K.applyMatrix4(e.projectionMatrixInverse),K.multiplyScalar(1/K.w),Math.abs(Math.max(K.x,K.y))}function Rt(t,n){let r=t.matrixWorld,i=t.geometry,a=i.attributes.instanceStart,o=i.attributes.instanceEnd,s=Math.min(i.instanceCount,a.count);for(let i=0,c=s;i<c;i++){G.start.fromBufferAttribute(a,i),G.end.fromBufferAttribute(o,i),G.applyMatrix4(r);let s=new e.Vector3,c=new e.Vector3;q.distanceSqToSegment(G.start,G.end,c,s),c.distanceTo(s)<It*.5&&n.push({point:c,pointOnLine:s,distance:q.origin.distanceTo(c),object:t,face:null,faceIndex:i,uv:null,uv1:null})}}function zt(t,n,r){let i=n.projectionMatrix,a=t.material.resolution,o=t.matrixWorld,s=t.geometry,c=s.attributes.instanceStart,l=s.attributes.instanceEnd,u=Math.min(s.instanceCount,c.count),d=-n.near;q.at(1,W),W.w=1,W.applyMatrix4(n.matrixWorldInverse),W.applyMatrix4(i),W.multiplyScalar(1/W.w),W.x*=a.x/2,W.y*=a.y/2,W.z=0,jt.copy(W),Mt.multiplyMatrices(n.matrixWorldInverse,o);for(let n=0,s=u;n<s;n++){if(H.fromBufferAttribute(c,n),U.fromBufferAttribute(l,n),H.w=1,U.w=1,H.applyMatrix4(Mt),U.applyMatrix4(Mt),H.z>d&&U.z>d)continue;if(H.z>d){let e=H.z-U.z,t=(H.z-d)/e;H.lerp(U,t)}else if(U.z>d){let e=U.z-H.z,t=(U.z-d)/e;U.lerp(H,t)}H.applyMatrix4(i),U.applyMatrix4(i),H.multiplyScalar(1/H.w),U.multiplyScalar(1/U.w),H.x*=a.x/2,H.y*=a.y/2,U.x*=a.x/2,U.y*=a.y/2,G.start.copy(H),G.start.z=0,G.end.copy(U),G.end.z=0;let s=G.closestPointToPointParameter(jt,!0);G.at(s,Nt);let u=e.MathUtils.lerp(H.z,U.z,s),f=u>=-1&&u<=1,p=jt.distanceTo(Nt)<It*.5;if(f&&p){G.start.fromBufferAttribute(c,n),G.end.fromBufferAttribute(l,n),G.start.applyMatrix4(o),G.end.applyMatrix4(o);let i=new e.Vector3,a=new e.Vector3;q.distanceSqToSegment(G.start,G.end,a,i),r.push({point:a,pointOnLine:i,distance:q.origin.distanceTo(a),object:t,face:null,faceIndex:n,uv:null,uv1:null})}}}var Bt=class extends e.Mesh{constructor(e=new Et,t=new Dt({color:Math.random()*16777215})){super(e,t),this.isLineSegments2=!0,this.type=`LineSegments2`}computeLineDistances(){let t=this.geometry,n=t.attributes.instanceStart,r=t.attributes.instanceEnd,i=new Float32Array(2*n.count);for(let e=0,t=0,a=n.count;e<a;e++,t+=2)kt.fromBufferAttribute(n,e),At.fromBufferAttribute(r,e),i[t]=t===0?0:i[t-1],i[t+1]=i[t]+kt.distanceTo(At);let a=new e.InstancedInterleavedBuffer(i,2,1);return t.setAttribute(`instanceDistanceStart`,new e.InterleavedBufferAttribute(a,1,0)),t.setAttribute(`instanceDistanceEnd`,new e.InterleavedBufferAttribute(a,1,1)),this}raycast(e,t){let n=this.material.worldUnits,r=e.camera;if(r===null&&!n&&console.error(`LineSegments2: "Raycaster.camera" needs to be set in order to raycast against LineSegments2 while worldUnits is set to false.`),n===!1&&(this.material.resolution.x===0||this.material.resolution.y===0))return;let i=e.params.Line2===void 0?0:e.params.Line2.threshold||0;q=e.ray;let a=this.matrixWorld,o=this.geometry,s=this.material;It=s.linewidth+i,o.boundingSphere===null&&o.computeBoundingSphere(),Ft.copy(o.boundingSphere).applyMatrix4(a);let c;if(c=n?It*.5:Lt(r,Math.max(r.near,Ft.distanceToPoint(q.origin)),s.resolution),Ft.radius+=c,q.intersectsSphere(Ft)===!1)return;o.boundingBox===null&&o.computeBoundingBox(),Pt.copy(o.boundingBox).applyMatrix4(a);let l;l=n?It*.5:Lt(r,Math.max(r.near,Pt.distanceToPoint(q.origin)),s.resolution),Pt.expandByScalar(l),q.intersectsBox(Pt)!==!1&&(n?Rt(this,t):zt(this,r,t))}onBeforeRender(e){let t=this.material.uniforms;t&&t.resolution&&(e.getViewport(Ot),this.material.uniforms.resolution.value.set(Ot.z,Ot.w))}},Vt=function(){Qe.call(this),this.isLines2=!0;let e=Array(300);this.createLineSegment=(e,t,n)=>{if(e&&t){let r=new Et;r.setPositions(e),r.colorsNeedUpdate=!0;let i=new Bt(r,t);i.scale.set(1,1,1),i.computeLineDistances(),this.setMesh(i,n.localTimeEnabled,n.localMorphColour)}},this.setWidth=e=>{this.morph&&this.morph.material&&(this.morph.material.linewidth=e,this.morph.material.needsUpdate=!0)},this.addVertices=function(t){if(t&&t.length){let n=this.getMorph();n||(this.drawRange=0);let r=this.drawRange*3;if(t.forEach(t=>{e[r++]=t[0],e[r++]=t[1],e[r++]=t[2],this.drawRange++}),!n)for(;r<300;)e[r++]=t[0][0],e[r++]=t[0][1],e[r++]=t[0][2];n&&(n.geometry.setPositions(e),n.computeLineDistances(),n.geometry.computeBoundingBox(),n.geometry.computeBoundingSphere(),this.boundingBoxUpdateRequired=!0)}return e},this.getVerticesByFaceIndex=function(e){let t=e*2*3,n=this.getMorph();if(n&&this.drawRange*3>t){let e=n.geometry.getAttribute(`instanceStart`);return[[e.data.array[t],e.data.array[++t],e.data.array[++t]],[e.data.array[++t],e.data.array[++t],e.data.array[++t]]]}return[]},this.editVertices=function(t,n){if(t&&t.length){let r=this.getMorph(),i=n+t.length-1;if(!r||0>n||i>=this.drawRange)return;{let i=n*3;for(t.forEach(t=>{e[i++]=t[0],e[i++]=t[1],e[i++]=t[2]}),i=this.drawRange*3;i<300;)e[i++]=t[0][0],e[i++]=t[0][1],e[i++]=t[0][2];r.geometry.setPositions(e),r.computeLineDistances(),r.geometry.computeBoundingBox(),r.geometry.computeBoundingSphere(),this.boundingBoxUpdateRequired=!0}}return e},this.addLines=(t,n)=>{if(t&&t.length>0){if(this.addVertices(t),!this.getMorph()){let t=new Dt({color:n,linewidth:1,vertexColors:!1,worldUnits:!1});t.resolution.set(window.innerWidth,window.innerHeight),this.createLineSegment(e,t,{localTimeEnabled:!1,localMorphColour:!1})}this.region&&(this.region.pickableUpdateRequired=!0)}},this.render=(e,t,n,r)=>{this.getMorph().material.resolution.set(window.innerWidth,window.innerHeight)}};Vt.prototype=Object.create(Qe.prototype),Vt.prototype.constructor=Vt;var Ht=0,Ut=function(){return`re`+Ht++},Wt=function(t,n){let r=t,i=new e.Group;i.matrixAutoUpdate=!1,i.userData=this;let a=[],o=``,s=[],c=n,l=new e.Matrix4,u=3e3;l.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this.pickableUpdateRequired=!0,this.isRegion=!0,this.uuid=Ut(),this.hideAllPrimitives=()=>{a.forEach(e=>e.hideAllPrimitives()),s.forEach(e=>e.setVisibility(!1))},this.showAllPrimitives=()=>{a.forEach(e=>e.showAllPrimitives()),s.forEach(e=>e.setVisibility(!0))},this.setVisibility=e=>{e!=i.visible&&(i.visible=e,this.pickableUpdateRequired=!0)},this.getVisibility=()=>i.visible,this.getGroup=()=>i,this.setTransformation=e=>{l.set(...e),i.matrix.copy(l),i.updateMatrixWorld()},this.setName=e=>{e&&e!==``&&(o=e)},this.getName=()=>o,this.getParent=()=>r,this.getFullSeparatedPath=()=>{let e=[];if(o!==``){e.push(o);for(let t=r;t!==void 0;){let n=t.getName();n!==``&&e.unshift(n),t=t.getParent()}}return e},this.getFullPath=()=>{let e=this.getFullSeparatedPath();if(e.length>0){let t=e.shift();return e.forEach(e=>{t=t.concat(`/`,e)}),t}return``},this.createChild=e=>{let t=new Wt(this,c);return t.setName(e),a.push(t),i.add(t.getGroup()),t},this.getChildWithName=e=>{if(e){let t=e.toLowerCase();for(let e=0;e<a.length;e++)if(a[e].getName().toLowerCase()===t)return a[e]}},this.findChildFromSeparatedPath=e=>{if(e&&e.length>0&&e[0]===``&&e.shift(),e&&e.length>0){let t=this.getChildWithName(e[0]);return t?(e.shift(),t.findChildFromSeparatedPath(e)):void 0}return this},this.findChildFromPath=e=>{let t=e.split(`/`);return this.findChildFromSeparatedPath(t)},this.createChildFromSeparatedPath=e=>{if(e.length>0&&e[0]===``&&e.shift(),e.length>0){let t=this.getChildWithName(e[0]);return t||=this.createChild(e[0]),e.shift(),t.createChildFromSeparatedPath(e)}return this},this.createChildFromPath=e=>{let t=e.split(`/`);return this.createChildFromSeparatedPath(t)},this.findOrCreateChildFromPath=e=>{let t=this.findChildFromPath(e);return t||=this.createChildFromPath(e),t},this.addZincObject=e=>{e&&(e.setRegion(this),i.add(e.getGroup()),s.push(e),this.pickableUpdateRequired=!0,c&&c.triggerObjectAddedCallback(e))},this.removeZincObject=e=>{for(let t=0;t<s.length;t++)if(e===s[t]){i.remove(e.getGroup()),s.splice(t,1),c&&c.triggerObjectRemovedCallback(e),e.dispose(),this.pickableUpdateRequired=!0;return}},this.checkPickableUpdateRequred=e=>{if(this.pickableUpdateRequired)return!0;if(e){let t=!1;for(let n=0;n<a.length;n++)if(t=a[n].checkPickableUpdateRequred(e),t)return!0}return!1},this.getPickableThreeJSObjects=(e,t)=>(i.visible&&(s.forEach(t=>{if(t.isPickable&&t.getGroup()&&t.getGroup().visible){let n=t.marker;n&&n.isEnabled()&&e.push(n.getMorph()),e.push(t.getGroup())}}),t&&a.forEach(n=>{n.getPickableThreeJSObjects(e,t)}),this.pickableUpdateRequired=!1),e),this.setDuration=e=>{u=e,s.forEach(t=>t.setDuration(e)),a.forEach(t=>t.setDuration(e))},this.getDuration=()=>u,this.getBoundingBox=e=>{let t,n;return s.forEach(e=>{n=e.getBoundingBox(),n&&(t==null?t=n.clone():t.union(n))}),e&&a.forEach(r=>{n=r.getBoundingBox(e),n&&(t==null?t=n.clone():t.union(n))}),t},this.clear=e=>{e&&a.forEach(t=>t.clear(e)),s.forEach(e=>{i.remove(e.getGroup()),e.dispose()}),a=[],s=[]},this.objectIsInRegion=(e,t)=>{for(let t=0;t<s.length;t++)if(e===s[t])return!0;if(t){for(let n=0;n<a.length;n++)if(a[n].objectIsInRegion(e,t))return!0}return!1},this.forEachGeometry=(e,t)=>{s.forEach(t=>{t.isGeometry&&e(t)}),t&&a.forEach(n=>n.forEachGeometry(e,t))},this.forEachGlyphset=(e,t)=>{s.forEach(t=>{t.isGlyphset&&e(t)}),t&&a.forEach(n=>n.forEachGlyphset(e,t))},this.forEachPointset=(e,t)=>{s.forEach(t=>{t.isPointset&&e(t)}),t&&a.forEach(n=>n.forEachPointset(e,t))},this.forEachLine=(e,t)=>{s.forEach(t=>{t.isLines&&e(t)}),t&&a.forEach(n=>n.forEachLine(e,t))},this.findObjectsWithAnatomicalId=(e,t)=>{let n=[];return s.forEach(t=>{t.anatomicalId===e&&n.push(t)}),t&&a.forEach(r=>{let i=r.findObjectsWithAnatomicalId(e,t);n.push(...i)}),n},this.findObjectsWithGroupName=(e,t)=>{let n=[];return s.forEach(t=>{(t.groupName?t.groupName.toLowerCase():t.groupName)===(e&&e.toLowerCase())&&n.push(t)}),t&&a.forEach(r=>{let i=r.findObjectsWithGroupName(e,t);n.push(...i)}),n},this.findGeometriesWithGroupName=(e,t)=>this.findObjectsWithGroupName(e,t).filter(e=>e.isGeometry),this.findPointsetsWithGroupName=(e,t)=>this.findObjectsWithGroupName(e,t).filter(e=>e.isPointset),this.findGlyphsetsWithGroupName=(e,t)=>this.findObjectsWithGroupName(e,t).filter(e=>e.isGlyphset),this.findLinesWithGroupName=(e,t)=>this.findObjectsWithGroupName(e,t).filter(e=>e.isLines),this.getAllObjects=e=>{let t=[...s];return e&&a.forEach(n=>{let r=n.getAllObjects(e);t.push(...r)}),t},this.getChildRegions=e=>{let t=[...a];return e&&a.forEach(n=>{let r=n.getChildRegions(e);t.push(...r)}),t},this.getCurrentTime=()=>{if(s[0]!=null)return s[0].getCurrentTime();for(let e=0;e<a.length;e++){let t=a[e].getCurrentTime();if(t!==-1)return t}return-1},this.setMorphTime=(e,t)=>{s.forEach(t=>{t.setMorphTime(e)}),t&&a.forEach(t=>{t.setMorphTime(e)})},this.isTimeVarying=()=>{for(let e=0;e<s.length;e++)if(s[e].isTimeVarying())return!0;for(let e=0;e<a.length;e++)if(a[e].isTimeVarying())return!0;return!1},this.renderGeometries=(e,t,n,r,i,a)=>{this.getAllObjects(a).forEach(a=>{a.render(e*t,n,r,i)}),i&&n===!1&&i.markerCluster?.markerUpdateRequired&&i.markerCluster.calculate()},this.createPoints=(e,t,n,r)=>{let i=!1,a=this.findObjectsWithGroupName(e,!1),o=a.findIndex(e=>e.isPointset),s=o>-1?a[o]:new Ze;return s.addPoints(t,n,r),o===-1?(s.setName(e),this.addZincObject(s),i=!0):this.pickableUpdateRequired=!0,{zincObject:s,isNew:i}},this.createLines=(e,t,n)=>{let r=!1,i=this.findObjectsWithGroupName(e,!1),a=i.findIndex(e=>e.isLines),o=a>-1?i[a]:new Vt;return o.addLines(t,n),a===-1?(o.setName(e),this.addZincObject(o),r=!0):this.pickableUpdateRequired=!0,{zincObject:o,isNew:r}},this.createGeometryFromThreeJSGeometry=(t,n,r,i,a,o)=>{let s=new Ee,c=new e.MeshPhongMaterial({color:r,transparent:!0,opacity:i,side:e.DoubleSide});if(s.createMesh(n,c,{localTimeEnabled:!1,localMorphColour:!1}),s.getMorph())return s.setVisibility(!1),s.setName(t),s.setRenderOrder(o),this.addZincObject(s),s}},Gt=class{constructor(){this.pluginCallbacks=[],this.register(function(e){return new cn(e)}),this.register(function(e){return new ln(e)}),this.register(function(e){return new un(e)})}register(e){return this.pluginCallbacks.indexOf(e)===-1&&this.pluginCallbacks.push(e),this}unregister(e){return this.pluginCallbacks.indexOf(e)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,n){let r=new sn,i=[];for(let e=0,t=this.pluginCallbacks.length;e<t;e++)i.push(this.pluginCallbacks[e](r));r.setPlugins(i),r.write(e,t,n)}},J={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,UNSIGNED_BYTE:5121,UNSIGNED_SHORT:5123,FLOAT:5126,UNSIGNED_INT:5125,ARRAY_BUFFER:34962,ELEMENT_ARRAY_BUFFER:34963,NEAREST:9728,LINEAR:9729,NEAREST_MIPMAP_NEAREST:9984,LINEAR_MIPMAP_NEAREST:9985,NEAREST_MIPMAP_LINEAR:9986,LINEAR_MIPMAP_LINEAR:9987,CLAMP_TO_EDGE:33071,MIRRORED_REPEAT:33648,REPEAT:10497},Y={};Y[e.NearestFilter]=J.NEAREST,Y[e.NearestMipmapNearestFilter]=J.NEAREST_MIPMAP_NEAREST,Y[e.NearestMipmapLinearFilter]=J.NEAREST_MIPMAP_LINEAR,Y[e.LinearFilter]=J.LINEAR,Y[e.LinearMipmapNearestFilter]=J.LINEAR_MIPMAP_NEAREST,Y[e.LinearMipmapLinearFilter]=J.LINEAR_MIPMAP_LINEAR,Y[e.ClampToEdgeWrapping]=J.CLAMP_TO_EDGE,Y[e.RepeatWrapping]=J.REPEAT,Y[e.MirroredRepeatWrapping]=J.MIRRORED_REPEAT;var Kt={scale:`scale`,position:`translation`,quaternion:`rotation`,morphTargetInfluences:`weights`},qt=12,Jt=1179937895,Yt=2,Xt=8,Zt=1313821514,Qt=5130562;function $t(e,t){return e.length===t.length&&e.every(function(e,n){return e===t[n]})}function en(e){if(window.TextEncoder!==void 0)return new TextEncoder().encode(e).buffer;let t=new Uint8Array(new ArrayBuffer(e.length));for(let n=0,r=e.length;n<r;n++){let r=e.charCodeAt(n);t[n]=r>255?32:r}return t.buffer}function tn(e){return $t(e.elements,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}function nn(e,t,n){let r={min:Array(e.itemSize).fill(1/0),max:Array(e.itemSize).fill(-1/0)};for(let i=t;i<t+n;i++)for(let t=0;t<e.itemSize;t++){let n;e.itemSize>4?n=e.array[i*e.itemSize+t]:t===0?n=e.getX(i):t===1?n=e.getY(i):t===2?n=e.getZ(i):t===3&&(n=e.getW(i)),r.min[t]=Math.min(r.min[t],n),r.max[t]=Math.max(r.max[t],n)}return r}function rn(e){return Math.ceil(e/4)*4}function an(e,t=0){let n=rn(e.byteLength);if(n!==e.byteLength){let r=new Uint8Array(n);if(r.set(new Uint8Array(e)),t!==0)for(let i=e.byteLength;i<n;i++)r[i]=t;return r.buffer}return e}var on=null,sn=class{constructor(){this.plugins=[],this.options={},this.pending=[],this.buffers=[],this.byteOffset=0,this.buffers=[],this.nodeMap=new Map,this.skins=[],this.extensionsUsed={},this.uids=new Map,this.uid=0,this.json={asset:{version:`2.0`,generator:`THREE.GLTFExporter`}},this.cache={meshes:new Map,attributes:new Map,attributesNormalized:new Map,materials:new Map,textures:new Map,images:new Map}}setPlugins(e){this.plugins=e}write(e,t,n){this.options=Object.assign({},{binary:!1,trs:!1,onlyVisible:!0,truncateDrawRange:!0,embedImages:!0,maxTextureSize:1/0,animations:[],includeCustomExtensions:!1},n),this.options.animations.length>0&&(this.options.trs=!0),this.processInput(e);let r=this;Promise.all(this.pending).then(function(){let e=r.buffers,n=r.json,i=r.options,a=r.extensionsUsed,o=new Blob(e,{type:`application/octet-stream`}),s=Object.keys(a);if(s.length>0&&(n.extensionsUsed=s),n.buffers&&n.buffers.length>0&&(n.buffers[0].byteLength=o.size),i.binary===!0){let e=new window.FileReader;e.readAsArrayBuffer(o),e.onloadend=function(){let r=an(e.result),i=new DataView(new ArrayBuffer(Xt));i.setUint32(0,r.byteLength,!0),i.setUint32(4,Qt,!0);let a=an(en(JSON.stringify(n)),32),o=new DataView(new ArrayBuffer(Xt));o.setUint32(0,a.byteLength,!0),o.setUint32(4,Zt,!0);let s=new ArrayBuffer(qt),c=new DataView(s);c.setUint32(0,Jt,!0),c.setUint32(4,Yt,!0);let l=qt+o.byteLength+a.byteLength+i.byteLength+r.byteLength;c.setUint32(8,l,!0);let u=new Blob([s,o,a,i,r],{type:`application/octet-stream`}),d=new window.FileReader;d.readAsArrayBuffer(u),d.onloadend=function(){t(d.result)}}}else if(n.buffers&&n.buffers.length>0){let e=new window.FileReader;e.readAsDataURL(o),e.onloadend=function(){let r=e.result;n.buffers[0].uri=r,t(n)}}else t(n)})}serializeUserData(e,t){if(e.userData&&e.userData.isZincObject||Object.keys(e.userData).length===0)return;let n=this.options,r=this.extensionsUsed;try{let i=JSON.parse(JSON.stringify(e.userData));if(n.includeCustomExtensions&&i.gltfExtensions){t.extensions===void 0&&(t.extensions={});for(let e in i.gltfExtensions)t.extensions[e]=i.gltfExtensions[e],r[e]=!0;delete i.gltfExtensions}Object.keys(i).length>0&&(t.extras=i)}catch(t){console.warn(`THREE.GLTFExporter: userData of '`+e.name+`' won't be serialized because of JSON.stringify error - `+t.message)}}getUID(e){return this.uids.has(e)||this.uids.set(e,this.uid++),this.uids.get(e)}isNormalizedNormalAttribute(t){if(this.cache.attributesNormalized.has(t))return!1;let n=new e.Vector3;for(let e=0,r=t.count;e<r;e++)if(Math.abs(n.fromBufferAttribute(t,e).length()-1)>5e-4)return!1;return!0}createNormalizedNormalAttribute(t){let n=this.cache;if(n.attributesNormalized.has(t))return n.attributesNormalized.get(t);let r=t.clone(),i=new e.Vector3;for(let e=0,t=r.count;e<t;e++)i.fromBufferAttribute(r,e),i.x===0&&i.y===0&&i.z===0?i.setX(1):i.normalize(),r.setXYZ(e,i.x,i.y,i.z);return n.attributesNormalized.set(t,r),r}applyTextureTransform(e,t){let n=!1,r={};(t.offset.x!==0||t.offset.y!==0)&&(r.offset=t.offset.toArray(),n=!0),t.rotation!==0&&(r.rotation=t.rotation,n=!0),(t.repeat.x!==1||t.repeat.y!==1)&&(r.scale=t.repeat.toArray(),n=!0),n&&(e.extensions=e.extensions||{},e.extensions.KHR_texture_transform=r,this.extensionsUsed.KHR_texture_transform=!0)}processBuffer(e){let t=this.json,n=this.buffers;return t.buffers||=[{byteLength:0}],n.push(e),0}processBufferView(e,t,n,r,i){let a=this.json;a.bufferViews||=[];let o;o=t===J.UNSIGNED_BYTE?1:t===J.UNSIGNED_SHORT?2:4;let s=rn(r*e.itemSize*o),c=new DataView(new ArrayBuffer(s)),l=0;for(let i=n;i<n+r;i++)for(let n=0;n<e.itemSize;n++){let r;e.itemSize>4?r=e.array[i*e.itemSize+n]:n===0?r=e.getX(i):n===1?r=e.getY(i):n===2?r=e.getZ(i):n===3&&(r=e.getW(i)),t===J.FLOAT?c.setFloat32(l,r,!0):t===J.UNSIGNED_INT?c.setUint32(l,r,!0):t===J.UNSIGNED_SHORT?c.setUint16(l,r,!0):t===J.UNSIGNED_BYTE&&c.setUint8(l,r),l+=o}let u={buffer:this.processBuffer(c.buffer),byteOffset:this.byteOffset,byteLength:s};return i!==void 0&&(u.target=i),i===J.ARRAY_BUFFER&&(u.byteStride=e.itemSize*o),this.byteOffset+=s,a.bufferViews.push(u),{id:a.bufferViews.length-1,byteLength:0}}processBufferViewImage(e){let t=this,n=t.json;return n.bufferViews||=[],new Promise(function(r){let i=new window.FileReader;i.readAsArrayBuffer(e),i.onloadend=function(){let e=an(i.result),a={buffer:t.processBuffer(e),byteOffset:t.byteOffset,byteLength:e.byteLength};t.byteOffset+=e.byteLength,r(n.bufferViews.push(a)-1)}})}processAccessor(e,t,n,r){let i=this.options,a=this.json,o={1:`SCALAR`,2:`VEC2`,3:`VEC3`,4:`VEC4`,16:`MAT4`},s;if(e.array.constructor===Float32Array)s=J.FLOAT;else if(e.array.constructor===Uint32Array)s=J.UNSIGNED_INT;else if(e.array.constructor===Uint16Array)s=J.UNSIGNED_SHORT;else if(e.array.constructor===Uint8Array)s=J.UNSIGNED_BYTE;else throw Error(`THREE.GLTFExporter: Unsupported bufferAttribute component type.`);if(n===void 0&&(n=0),r===void 0&&(r=e.count),i.truncateDrawRange&&t!==void 0&&t.index===null){let i=n+r,a=t.drawRange.count===1/0?e.count:t.drawRange.start+t.drawRange.count;n=Math.max(n,t.drawRange.start),r=Math.min(i,a)-n,r<0&&(r=0)}if(r===0)return null;let c=nn(e,n,r),l;t!==void 0&&(l=e===t.index?J.ELEMENT_ARRAY_BUFFER:J.ARRAY_BUFFER);let u=this.processBufferView(e,s,n,r,l),d={bufferView:u.id,byteOffset:u.byteOffset,componentType:s,count:r,max:c.max,min:c.min,type:o[e.itemSize]};return e.normalized===!0&&(d.normalized=!0),a.accessors||=[],a.accessors.push(d)-1}processImage(t,n,r){let i=this,a=i.cache,o=i.json,s=i.options,c=i.pending;a.images.has(t)||a.images.set(t,{});let l=a.images.get(t),u=n===e.RGBAFormat?`image/png`:`image/jpeg`,d=u+`:flipY/`+r.toString();if(l[d]!==void 0)return l[d];o.images||=[];let f={mimeType:u};if(s.embedImages){let a=on||=document.createElement(`canvas`);a.width=Math.min(t.width,s.maxTextureSize),a.height=Math.min(t.height,s.maxTextureSize);let o=a.getContext(`2d`);if(r===!0&&(o.translate(0,a.height),o.scale(1,-1)),typeof HTMLImageElement<`u`&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<`u`&&t instanceof HTMLCanvasElement||typeof OffscreenCanvas<`u`&&t instanceof OffscreenCanvas||typeof ImageBitmap<`u`&&t instanceof ImageBitmap)o.drawImage(t,0,0,a.width,a.height);else{n!==e.RGBAFormat&&n!==e.RGBFormat&&console.error(`GLTFExporter: Only RGB and RGBA formats are supported.`),(t.width>s.maxTextureSize||t.height>s.maxTextureSize)&&console.warn(`GLTFExporter: Image size is bigger than maxTextureSize`,t);let r=new Uint8ClampedArray(t.height*t.width*4);if(n===e.RGBAFormat)for(let e=0;e<r.length;e+=4)r[e+0]=t.data[e+0],r[e+1]=t.data[e+1],r[e+2]=t.data[e+2],r[e+3]=t.data[e+3];else for(let e=0,n=0;e<r.length;e+=4,n+=3)r[e+0]=t.data[n+0],r[e+1]=t.data[n+1],r[e+2]=t.data[n+2],r[e+3]=255;o.putImageData(new ImageData(r,t.width,t.height),0,0)}s.binary===!0?c.push(new Promise(function(e){a.toBlob(function(t){i.processBufferViewImage(t).then(function(t){f.bufferView=t,e()})},u)})):f.uri=a.toDataURL(u)}else f.uri=t.src;let p=o.images.push(f)-1;return l[d]=p,p}processSampler(e){let t=this.json;t.samplers||=[];let n={magFilter:Y[e.magFilter],minFilter:Y[e.minFilter],wrapS:Y[e.wrapS],wrapT:Y[e.wrapT]};return t.samplers.push(n)-1}processTexture(e){let t=this.cache,n=this.json;if(t.textures.has(e))return t.textures.get(e);n.textures||=[];let r={sampler:this.processSampler(e),source:this.processImage(e.image,e.format,e.flipY)};e.name&&(r.name=e.name),this._invokeAll(function(t){t.writeTexture&&t.writeTexture(e,r)});let i=n.textures.push(r)-1;return t.textures.set(e,i),i}processMaterial(t){let n=this.cache,r=this.json;if(n.materials.has(t))return n.materials.get(t);if(t.isShaderMaterial)return console.warn(`GLTFExporter: THREE.ShaderMaterial not supported.`),null;r.materials||=[];let i={pbrMetallicRoughness:{}};t.isMeshStandardMaterial!==!0&&t.isMeshBasicMaterial!==!0&&console.warn(`GLTFExporter: Use MeshStandardMaterial or MeshBasicMaterial for best results.`);let a=t.color.toArray().concat([t.opacity]);if($t(a,[1,1,1,1])||(i.pbrMetallicRoughness.baseColorFactor=a),t.isMeshStandardMaterial?(i.pbrMetallicRoughness.metallicFactor=t.metalness,i.pbrMetallicRoughness.roughnessFactor=t.roughness):(i.pbrMetallicRoughness.metallicFactor=.5,i.pbrMetallicRoughness.roughnessFactor=.5),t.metalnessMap||t.roughnessMap){if(t.metalnessMap===t.roughnessMap){let e={index:this.processTexture(t.metalnessMap)};this.applyTextureTransform(e,t.metalnessMap),i.pbrMetallicRoughness.metallicRoughnessTexture=e}else console.warn(`THREE.GLTFExporter: Ignoring metalnessMap and roughnessMap because they are not the same Texture.`)}if(t.map){let e={index:this.processTexture(t.map)};this.applyTextureTransform(e,t.map),i.pbrMetallicRoughness.baseColorTexture=e}if(t.emissive){let e=t.emissive.clone().multiplyScalar(t.emissiveIntensity),n=Math.max(e.r,e.g,e.b);if(n>1&&(e.multiplyScalar(1/n),console.warn(`THREE.GLTFExporter: Some emissive components exceed 1; emissive has been limited`)),n>0&&(i.emissiveFactor=e.toArray()),t.emissiveMap){let e={index:this.processTexture(t.emissiveMap)};this.applyTextureTransform(e,t.emissiveMap),i.emissiveTexture=e}}if(t.normalMap){let e={index:this.processTexture(t.normalMap)};t.normalScale&&t.normalScale.x!==-1&&(t.normalScale.x!==t.normalScale.y&&console.warn(`THREE.GLTFExporter: Normal scale components are different, ignoring Y and exporting X.`),e.scale=t.normalScale.x),this.applyTextureTransform(e,t.normalMap),i.normalTexture=e}if(t.aoMap){let e={index:this.processTexture(t.aoMap),texCoord:1};t.aoMapIntensity!==1&&(e.strength=t.aoMapIntensity),this.applyTextureTransform(e,t.aoMap),i.occlusionTexture=e}t.transparent?i.alphaMode=`BLEND`:t.alphaTest>0&&(i.alphaMode=`MASK`,i.alphaCutoff=t.alphaTest),t.side===e.DoubleSide&&(i.doubleSided=!0),t.name!==``&&(i.name=t.name),this.serializeUserData(t,i),this._invokeAll(function(e){e.writeMaterial&&e.writeMaterial(t,i)});let o=r.materials.push(i)-1;return n.materials.set(t,o),o}processMesh(t){let n=this.cache,r=this.json,i=[t.geometry.uuid];if(Array.isArray(t.material))for(let e=0,n=t.material.length;e<n;e++)i.push(t.material[e].uuid);else i.push(t.material.uuid);let a=i.join(`:`);if(n.meshes.has(a))return n.meshes.get(a);let o=t.geometry,s;if(s=t.isLineSegments?J.LINES:t.isLineLoop?J.LINE_LOOP:t.isLine?J.LINE_STRIP:t.isPoints?J.POINTS:t.material.wireframe?J.LINES:J.TRIANGLES,o.isBufferGeometry!==!0)throw Error(`THREE.GLTFExporter: Geometry is not of type THREE.BufferGeometry.`);let c={},l={},u=[],d=[],f={uv:`TEXCOORD_0`,uv2:`TEXCOORD_1`,color:`COLOR_0`,skinWeight:`WEIGHTS_0`,skinIndex:`JOINTS_0`},p=o.getAttribute(`normal`);p!==void 0&&!this.isNormalizedNormalAttribute(p)&&(console.warn(`THREE.GLTFExporter: Creating normalized normal attribute from the non-normalized one.`),o.setAttribute(`normal`,this.createNormalizedNormalAttribute(p)));let m=null;for(let t in o.attributes){if(t.substr(0,5)===`morph`)continue;let r=o.attributes[t];if(t=f[t]||t.toUpperCase(),/^(POSITION|NORMAL|TANGENT|TEXCOORD_\d+|COLOR_\d+|JOINTS_\d+|WEIGHTS_\d+)$/.test(t)||(t=`_`+t),n.attributes.has(this.getUID(r))){l[t]=n.attributes.get(this.getUID(r));continue}m=null;let i=r.array;t===`JOINTS_0`&&!(i instanceof Uint16Array)&&!(i instanceof Uint8Array)&&(console.warn(`GLTFExporter: Attribute "skinIndex" converted to type UNSIGNED_SHORT.`),m=new e.BufferAttribute(new Uint16Array(i),r.itemSize,r.normalized));let a=this.processAccessor(m||r,o);a!==null&&(l[t]=a,n.attributes.set(this.getUID(r),a))}if(p!==void 0&&o.setAttribute(`normal`,p),Object.keys(l).length===0)return null;if(t.morphTargetInfluences!==void 0&&t.morphTargetInfluences.length>0){let e=[],r=[],i={};if(t.morphTargetDictionary!==void 0)for(let e in t.morphTargetDictionary)i[t.morphTargetDictionary[e]]=e;for(let a=0;a<t.morphTargetInfluences.length;++a){let s={},c=!1;for(let e in o.morphAttributes){if(e!==`position`&&e!==`normal`&&e!==`color`){c||=(console.warn(`GLTFExporter: Only POSITION and NORMAL morph are supported.`),!0);continue}let t=o.morphAttributes[e][a],r=e.toUpperCase();f[e]&&(r=f[e]);let i=o.attributes[e];if(n.attributes.has(this.getUID(t))){s[r]=n.attributes.get(this.getUID(t));continue}let l=i.clone();if(!o.morphTargetsRelative){if(i)for(let e=0,n=t.count;e<n;e++)i.count>e&&l.setXYZ(e,t.getX(e)-i.getX(e),t.getY(e)-i.getY(e),t.getZ(e)-i.getZ(e));else for(let e=0,n=t.count;e<n;e++)l.setXYZ(e,0,0,0)}s[r]=this.processAccessor(l,o),n.attributes.set(this.getUID(i),s[r])}d.push(s),e.push(t.morphTargetInfluences[a]),t.morphTargetDictionary!==void 0&&r.push(i[a])}c.weights=e,r.length>0&&(c.extras={},c.extras.targetNames=r)}let h=Array.isArray(t.material);if(h&&o.groups.length===0)return null;let g=h?t.material:[t.material],_=h?o.groups:[{materialIndex:0,start:void 0,count:void 0}];for(let e=0,t=_.length;e<t;e++){let t={mode:s,attributes:l};if(this.serializeUserData(o,t),d.length>0&&(t.targets=d),o.index!==null){let r=this.getUID(o.index);(_[e].start!==void 0||_[e].count!==void 0)&&(r+=`:`+_[e].start+`:`+_[e].count),n.attributes.has(r)?t.indices=n.attributes.get(r):(t.indices=this.processAccessor(o.index,o,_[e].start,_[e].count),n.attributes.set(r,t.indices)),t.indices===null&&delete t.indices}let r=this.processMaterial(g[_[e].materialIndex]);r!==null&&(t.material=r),u.push(t)}c.primitives=u,r.meshes||=[],this._invokeAll(function(e){e.writeMesh&&e.writeMesh(t,c)});let v=r.meshes.push(c)-1;return n.meshes.set(a,v),v}processCamera(t){let n=this.json;n.cameras||=[];let r=t.isOrthographicCamera,i={type:r?`orthographic`:`perspective`};return r?i.orthographic={xmag:t.right*2,ymag:t.top*2,zfar:t.far<=0?.001:t.far,znear:t.near<0?0:t.near}:i.perspective={aspectRatio:t.aspect,yfov:e.MathUtils.degToRad(t.fov),zfar:t.far<=0?.001:t.far,znear:t.near<0?0:t.near},t.name!==``&&(i.name=t.type),n.cameras.push(i)-1}processAnimation(t,n){let r=this.json,i=this.nodeMap;r.animations||=[],t=Gt.Utils.mergeMorphTargetTracks(t.clone(),n);let a=t.tracks,o=[],s=[];for(let t=0;t<a.length;++t){let r=a[t],c=e.PropertyBinding.parseTrackName(r.name),l=e.PropertyBinding.findNode(n,c.nodeName),u=Kt[c.propertyName];if(c.objectName===`bones`&&(l=l.isSkinnedMesh===!0?l.skeleton.getBoneByName(c.objectIndex):void 0),!l||!u)return console.warn(`THREE.GLTFExporter: Could not export animation track "%s".`,r.name),null;let d=r.values.length/r.times.length;u===Kt.morphTargetInfluences&&(d/=l.morphTargetInfluences.length);let f;r.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline===!0?(f=`CUBICSPLINE`,d/=3):f=r.getInterpolation()===e.InterpolateDiscrete?`STEP`:`LINEAR`,s.push({input:this.processAccessor(new e.BufferAttribute(r.times,1)),output:this.processAccessor(new e.BufferAttribute(r.values,d)),interpolation:f}),o.push({sampler:s.length-1,target:{node:i.get(l),path:u}})}return r.animations.push({name:t.name||`clip_`+r.animations.length,samplers:s,channels:o}),r.animations.length-1}processSkin(t){let n=this.json,r=this.nodeMap,i=n.nodes[r.get(t)],a=t.skeleton;if(a===void 0)return null;let o=t.skeleton.bones[0];if(o===void 0)return null;let s=[],c=new Float32Array(a.bones.length*16),l=new e.Matrix4;for(let e=0;e<a.bones.length;++e)s.push(r.get(a.bones[e])),l.copy(a.boneInverses[e]),l.multiply(t.bindMatrix).toArray(c,e*16);return n.skins===void 0&&(n.skins=[]),n.skins.push({inverseBindMatrices:this.processAccessor(new e.BufferAttribute(c,16)),joints:s,skeleton:r.get(o)}),i.skin=n.skins.length-1}processNode(e){let t=this.json,n=this.options,r=this.nodeMap;t.nodes||=[];let i={};if(n.trs){let t=e.quaternion.toArray(),n=e.position.toArray(),r=e.scale.toArray();$t(t,[0,0,0,1])||(i.rotation=t),$t(n,[0,0,0])||(i.translation=n),$t(r,[1,1,1])||(i.scale=r)}else e.matrixAutoUpdate&&e.updateMatrix(),tn(e.matrix)===!1&&(i.matrix=e.matrix.elements);if(e.name!==``&&(i.name=String(e.name)),this.serializeUserData(e,i),e.isMesh||e.isLine||e.isPoints){let t=this.processMesh(e);t!==null&&(i.mesh=t)}else e.isCamera&&(i.camera=this.processCamera(e));if(e.isSkinnedMesh&&this.skins.push(e),e.children.length>0){let t=[];for(let r=0,i=e.children.length;r<i;r++){let i=e.children[r];if(i.visible||n.onlyVisible===!1){let e=this.processNode(i);e!==null&&t.push(e)}}t.length>0&&(i.children=t)}this._invokeAll(function(t){t.writeNode&&t.writeNode(e,i)});let a=t.nodes.push(i)-1;return r.set(e,a),a}processScene(e){let t=this.json,n=this.options;t.scenes||(t.scenes=[],t.scene=0);let r={};e.name!==``&&(r.name=e.name),t.scenes.push(r);let i=[];for(let t=0,r=e.children.length;t<r;t++){let r=e.children[t];if(r.visible||n.onlyVisible===!1){let e=this.processNode(r);e!==null&&i.push(e)}}i.length>0&&(r.nodes=i),this.serializeUserData(e,r)}processObjects(t){let n=new e.Scene;n.name=`AuxScene`;for(let e=0;e<t.length;e++)n.children.push(t[e]);this.processScene(n)}processInput(t){let n=this.options;t=t instanceof Array?t:[t],this._invokeAll(function(e){e.beforeParse&&e.beforeParse(t)});let r=[];for(let n=0;n<t.length;n++)t[n]instanceof e.Scene?this.processScene(t[n]):r.push(t[n]);r.length>0&&this.processObjects(r);for(let e=0;e<this.skins.length;++e)this.processSkin(this.skins[e]);for(let e=0;e<n.animations.length;++e)this.processAnimation(n.animations[e].clip,n.animations[e].mesh);this._invokeAll(function(e){e.afterParse&&e.afterParse(t)})}_invokeAll(e){for(let t=0,n=this.plugins.length;t<n;t++)e(this.plugins[t])}},cn=class{constructor(e){this.writer=e,this.name=`KHR_lights_punctual`}writeNode(e,t){if(!e.isLight)return;if(!e.isDirectionalLight&&!e.isPointLight&&!e.isSpotLight){console.warn(`THREE.GLTFExporter: Only directional, point, and spot lights are supported.`,e);return}let n=this.writer,r=n.json,i=n.extensionsUsed,a={};e.name&&(a.name=e.name),a.color=e.color.toArray(),a.intensity=e.intensity,e.isDirectionalLight?a.type=`directional`:e.isPointLight?(a.type=`point`,e.distance>0&&(a.range=e.distance)):e.isSpotLight&&(a.type=`spot`,e.distance>0&&(a.range=e.distance),a.spot={},a.spot.innerConeAngle=(e.penumbra-1)*e.angle*-1,a.spot.outerConeAngle=e.angle),e.decay!==void 0&&e.decay!==2&&console.warn(`THREE.GLTFExporter: Light decay may be lost. glTF is physically-based, and expects light.decay=2.`),e.target&&(e.target.parent!==e||e.target.position.x!==0||e.target.position.y!==0||e.target.position.z!==-1)&&console.warn(`THREE.GLTFExporter: Light direction may be lost. For best results, make light.target a child of the light with position 0,0,-1.`),i[this.name]||(r.extensions=r.extensions||{},r.extensions[this.name]={lights:[]},i[this.name]=!0);let o=r.extensions[this.name].lights;o.push(a),t.extensions=t.extensions||{},t.extensions[this.name]={light:o.length-1}}},ln=class{constructor(e){this.writer=e,this.name=`KHR_materials_unlit`}writeMaterial(e,t){if(!e.isMeshBasicMaterial)return;let n=this.writer.extensionsUsed;t.extensions=t.extensions||{},t.extensions[this.name]={},n[this.name]=!0,t.pbrMetallicRoughness.metallicFactor=0,t.pbrMetallicRoughness.roughnessFactor=.9}},un=class{constructor(e){this.writer=e,this.name=`KHR_materials_pbrSpecularGlossiness`}writeMaterial(e,t){if(!e.isGLTFSpecularGlossinessMaterial)return;let n=this.writer,r=n.extensionsUsed,i={};t.pbrMetallicRoughness.baseColorFactor&&(i.diffuseFactor=t.pbrMetallicRoughness.baseColorFactor);let a=[1,1,1];if(e.specular.toArray(a,0),i.specularFactor=a,i.glossinessFactor=e.glossiness,t.pbrMetallicRoughness.baseColorTexture&&(i.diffuseTexture=t.pbrMetallicRoughness.baseColorTexture),e.specularMap){let t={index:n.processTexture(e.specularMap)};n.applyTextureTransform(t,e.specularMap),i.specularGlossinessTexture=t}t.extensions=t.extensions||{},t.extensions[this.name]=i,r[this.name]=!0}};Gt.Utils={insertKeyframe:function(e,t){let n=.001,r=e.getValueSize(),i=new e.TimeBufferType(e.times.length+1),a=new e.ValueBufferType(e.values.length+r),o=e.createInterpolant(new e.ValueBufferType(r)),s;if(e.times.length===0){i[0]=t;for(let e=0;e<r;e++)a[e]=0;s=0}else if(t<e.times[0]){if(Math.abs(e.times[0]-t)<n)return 0;i[0]=t,i.set(e.times,1),a.set(o.evaluate(t),0),a.set(e.values,r),s=0}else if(t>e.times[e.times.length-1]){if(Math.abs(e.times[e.times.length-1]-t)<n)return e.times.length-1;i[i.length-1]=t,i.set(e.times,0),a.set(e.values,0),a.set(o.evaluate(t),e.values.length),s=i.length-1}else for(let c=0;c<e.times.length;c++){if(Math.abs(e.times[c]-t)<n)return c;if(e.times[c]<t&&e.times[c+1]>t){i.set(e.times.slice(0,c+1),0),i[c+1]=t,i.set(e.times.slice(c+1),c+2),a.set(e.values.slice(0,(c+1)*r),0),a.set(o.evaluate(t),(c+1)*r),a.set(e.values.slice((c+1)*r),(c+2)*r),s=c+1;break}}return e.times=i,e.values=a,s},mergeMorphTargetTracks:function(t,n){let r=[],i={},a=t.tracks;for(let t=0;t<a.length;++t){let o=a[t],s=e.PropertyBinding.parseTrackName(o.name),c=e.PropertyBinding.findNode(n,s.nodeName);if(s.propertyName!==`morphTargetInfluences`||s.propertyIndex===void 0){r.push(o);continue}if(o.createInterpolant!==o.InterpolantFactoryMethodDiscrete&&o.createInterpolant!==o.InterpolantFactoryMethodLinear){if(o.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline)throw Error(`THREE.GLTFExporter: Cannot merge tracks with glTF CUBICSPLINE interpolation.`);console.warn(`THREE.GLTFExporter: Morph target interpolation mode not yet supported. Using LINEAR instead.`),o=o.clone(),o.setInterpolation(e.InterpolateLinear)}let l=c.morphTargetInfluences.length,u=c.morphTargetDictionary[s.propertyIndex];if(u===void 0)throw Error(`THREE.GLTFExporter: Morph target name not found: `+s.propertyIndex);let d;if(i[c.uuid]===void 0){d=o.clone();let e=new d.ValueBufferType(l*d.times.length);for(let t=0;t<d.times.length;t++)e[t*l+u]=d.values[t];d.name=(s.nodeName||``)+`.morphTargetInfluences`,d.values=e,i[c.uuid]=d,r.push(d);continue}let f=o.createInterpolant(new o.ValueBufferType(1));d=i[c.uuid];for(let e=0;e<d.times.length;e++)d.values[e*l+u]=f.evaluate(d.times[e]);for(let e=0;e<o.times.length;e++){let t=this.insertKeyframe(d,o.times[e]);d.values[t*l+u]=o.values[e]}}return t.tracks=r,t}};var dn=function(e){let t=e;this.exportGLTF=e=>{let n=t.getRootRegion().getAllObjects(!0),r=[];n.forEach(e=>{e.animationClip&&r.push({clip:e.animationClip[0],mesh:e.getMorph()})});let i=new Gt,a={binary:e,animations:r};return new Promise((e,n)=>{i.parse(t.getThreeJSScene(),function(t){e(t)},a)})}},fn=function(){let e=this;this.parseGLTFObjects=(t,n,r,i)=>{let a=n;if(r!==0){if(t.type===`Object3D`){if(t.name!==``&&(n&&(a=n.findOrCreateChildFromPath(t.name)),a)){let e=a.getGroup();e.position.copy(t.position),e.rotation.copy(t.rotation),e.quaternion.copy(t.quaternion),e.matrixAutoUpdate=!0}}else{let e;if(t.type===`Mesh`?e=new Ee:t.type===`LineSegments`?e=new Qe:t.type===`Points`&&(e=new Ze),e){let r=!1,a=!1;t.geometry&&t.geometry.morphAttributes&&(r=!!t.geometry.morphAttributes.position,a=!!t.geometry.morphAttributes.color),e.setMesh(t.clone(),r,a);let o=e.getMorph();e.groupName=o.name,o.matrixAutoUpdate=!0,n.addZincObject(e),i!=null&&typeof i==`function`&&i(e)}}}r++,t.children.forEach(t=>{e.parseGLTFObjects(t,a,r,i)})},this.setCamera=e=>{e.viewAll();let t=e.getZincCameraControls(),n=t.getCurrentViewport();t.addViewport(`default`,n),t.setDefaultViewport(`default`)},this.load=(t,n,i,a,o,s)=>{let c=i.substring(0,i.lastIndexOf(`/`)+1),l=i.substring(i.lastIndexOf(`/`)+1,i.length);new r.GLTFLoader().setPath(c).load(l,function(r){console.log(r),e.parseGLTFObjects(r.scene,n,0,a),e.setCamera(t),o!=null&&typeof o==`function`&&o()})}},pn=/^[og]\s*(.+)?/,mn=/^mtllib /,hn=/^usemtl /,gn=/^usemap /,_n=new e.Vector3,vn=new e.Vector3,yn=new e.Vector3,bn=new e.Vector3,X=new e.Vector3;function xn(){let e={objects:[],object:{},vertices:[],normals:[],colors:[],uvs:[],materials:{},materialLibraries:[],startObject:function(e,t){if(this.object&&this.object.fromDeclaration===!1){this.object.name=e,this.object.fromDeclaration=t!==!1;return}let n=this.object&&typeof this.object.currentMaterial==`function`?this.object.currentMaterial():void 0;if(this.object&&typeof this.object._finalize==`function`&&this.object._finalize(!0),this.object={name:e||``,fromDeclaration:t!==!1,geometry:{vertices:[],normals:[],colors:[],uvs:[],hasUVIndices:!1},materials:[],smooth:!0,startMaterial:function(e,t){let n=this._finalize(!1);n&&(n.inherited||n.groupCount<=0)&&this.materials.splice(n.index,1);let r={index:this.materials.length,name:e||``,mtllib:Array.isArray(t)&&t.length>0?t[t.length-1]:``,smooth:n===void 0?this.smooth:n.smooth,groupStart:n===void 0?0:n.groupEnd,groupEnd:-1,groupCount:-1,inherited:!1,clone:function(e){let t={index:typeof e==`number`?e:this.index,name:this.name,mtllib:this.mtllib,smooth:this.smooth,groupStart:0,groupEnd:-1,groupCount:-1,inherited:!1};return t.clone=this.clone.bind(t),t}};return this.materials.push(r),r},currentMaterial:function(){if(this.materials.length>0)return this.materials[this.materials.length-1]},_finalize:function(e){let t=this.currentMaterial();if(t&&t.groupEnd===-1&&(t.groupEnd=this.geometry.vertices.length/3,t.groupCount=t.groupEnd-t.groupStart,t.inherited=!1),e&&this.materials.length>1)for(let e=this.materials.length-1;e>=0;e--)this.materials[e].groupCount<=0&&this.materials.splice(e,1);return e&&this.materials.length===0&&this.materials.push({name:``,smooth:this.smooth}),t}},n&&n.name&&typeof n.clone==`function`){let e=n.clone(0);e.inherited=!0,this.object.materials.push(e)}this.objects.push(this.object)},finalize:function(){this.object&&typeof this.object._finalize==`function`&&this.object._finalize(!0)},parseVertexIndex:function(e,t){let n=parseInt(e,10);return(n>=0?n-1:n+t/3)*3},parseNormalIndex:function(e,t){let n=parseInt(e,10);return(n>=0?n-1:n+t/3)*3},parseUVIndex:function(e,t){let n=parseInt(e,10);return(n>=0?n-1:n+t/2)*2},addVertex:function(e,t,n){let r=this.vertices,i=this.object.geometry.vertices;i.push(r[e+0],r[e+1],r[e+2]),i.push(r[t+0],r[t+1],r[t+2]),i.push(r[n+0],r[n+1],r[n+2])},addVertexPoint:function(e){let t=this.vertices;this.object.geometry.vertices.push(t[e+0],t[e+1],t[e+2])},addVertexLine:function(e){let t=this.vertices;this.object.geometry.vertices.push(t[e+0],t[e+1],t[e+2])},addNormal:function(e,t,n){let r=this.normals,i=this.object.geometry.normals;i.push(r[e+0],r[e+1],r[e+2]),i.push(r[t+0],r[t+1],r[t+2]),i.push(r[n+0],r[n+1],r[n+2])},addFaceNormal:function(e,t,n){let r=this.vertices,i=this.object.geometry.normals;_n.fromArray(r,e),vn.fromArray(r,t),yn.fromArray(r,n),X.subVectors(yn,vn),bn.subVectors(_n,vn),X.cross(bn),X.normalize(),i.push(X.x,X.y,X.z),i.push(X.x,X.y,X.z),i.push(X.x,X.y,X.z)},addColor:function(e,t,n){let r=this.colors,i=this.object.geometry.colors;r[e]!==void 0&&i.push(r[e+0],r[e+1],r[e+2]),r[t]!==void 0&&i.push(r[t+0],r[t+1],r[t+2]),r[n]!==void 0&&i.push(r[n+0],r[n+1],r[n+2])},addUV:function(e,t,n){let r=this.uvs,i=this.object.geometry.uvs;i.push(r[e+0],r[e+1]),i.push(r[t+0],r[t+1]),i.push(r[n+0],r[n+1])},addDefaultUV:function(){let e=this.object.geometry.uvs;e.push(0,0),e.push(0,0),e.push(0,0)},addUVLine:function(e){let t=this.uvs;this.object.geometry.uvs.push(t[e+0],t[e+1])},addFace:function(e,t,n,r,i,a,o,s,c){let l=this.vertices.length,u=this.parseVertexIndex(e,l),d=this.parseVertexIndex(t,l),f=this.parseVertexIndex(n,l);if(this.addVertex(u,d,f),this.addColor(u,d,f),o!==void 0&&o!==``){let e=this.normals.length;u=this.parseNormalIndex(o,e),d=this.parseNormalIndex(s,e),f=this.parseNormalIndex(c,e),this.addNormal(u,d,f)}else this.addFaceNormal(u,d,f);if(r!==void 0&&r!==``){let e=this.uvs.length;u=this.parseUVIndex(r,e),d=this.parseUVIndex(i,e),f=this.parseUVIndex(a,e),this.addUV(u,d,f),this.object.geometry.hasUVIndices=!0}else this.addDefaultUV()},addPointGeometry:function(e){this.object.geometry.type=`Points`;let t=this.vertices.length;for(let n=0,r=e.length;n<r;n++){let r=this.parseVertexIndex(e[n],t);this.addVertexPoint(r),this.addColor(r)}},addLineGeometry:function(e,t){this.object.geometry.type=`Line`;let n=this.vertices.length,r=this.uvs.length;for(let t=0,r=e.length;t<r;t++)this.addVertexLine(this.parseVertexIndex(e[t],n));for(let e=0,n=t.length;e<n;e++)this.addUVLine(this.parseUVIndex(t[e],r))}};return e.startObject(``,!1),e}var Sn=class extends e.Loader{constructor(e){super(e),this.materials=null}load(t,n,r,i){let a=this,o=new e.FileLoader(this.manager);o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(t,function(e){try{n(a.parse(e))}catch(e){i?i(e):console.error(e),a.manager.itemError(t)}},r,i)}setMaterials(e){return this.materials=e,this}parse(t){let n=new xn;t.indexOf(`\r
|
|
484
|
+
`};var Ct=class extends e.ShaderMaterial{constructor(t){super({type:`LineMaterial`,uniforms:e.UniformsUtils.clone(e.ShaderLib.line.uniforms),vertexShader:e.ShaderLib.line.vertexShader,fragmentShader:e.ShaderLib.line.fragmentShader,clipping:!0}),this.isLineMaterial=!0,this.setValues(t)}get color(){return this.uniforms.diffuse.value}set color(e){this.uniforms.diffuse.value=e}get worldUnits(){return`WORLD_UNITS`in this.defines}set worldUnits(e){e===!0!==this.worldUnits&&(this.needsUpdate=!0),e===!0?this.defines.WORLD_UNITS=``:delete this.defines.WORLD_UNITS}get linewidth(){return this.uniforms.linewidth.value}set linewidth(e){this.uniforms.linewidth&&(this.uniforms.linewidth.value=e)}get dashed(){return`USE_DASH`in this.defines}set dashed(e){e===!0!==this.dashed&&(this.needsUpdate=!0),e===!0?this.defines.USE_DASH=``:delete this.defines.USE_DASH}get dashScale(){return this.uniforms.dashScale.value}set dashScale(e){this.uniforms.dashScale.value=e}get dashSize(){return this.uniforms.dashSize.value}set dashSize(e){this.uniforms.dashSize.value=e}get dashOffset(){return this.uniforms.dashOffset.value}set dashOffset(e){this.uniforms.dashOffset.value=e}get gapSize(){return this.uniforms.gapSize.value}set gapSize(e){this.uniforms.gapSize.value=e}get opacity(){return this.uniforms.opacity.value}set opacity(e){this.uniforms&&(this.uniforms.opacity.value=e)}get resolution(){return this.uniforms.resolution.value}set resolution(e){this.uniforms.resolution.value.copy(e)}get alphaToCoverage(){return`USE_ALPHA_TO_COVERAGE`in this.defines}set alphaToCoverage(e){this.defines&&(e===!0!==this.alphaToCoverage&&(this.needsUpdate=!0),e===!0?this.defines.USE_ALPHA_TO_COVERAGE=``:delete this.defines.USE_ALPHA_TO_COVERAGE)}},wt=new e.Vector4,Tt=new e.Vector3,Et=new e.Vector3,H=new e.Vector4,U=new e.Vector4,W=new e.Vector4,Dt=new e.Vector3,Ot=new e.Matrix4,G=new e.Line3,kt=new e.Vector3,At=new e.Box3,jt=new e.Sphere,K=new e.Vector4,q,Mt;function Nt(e,t,n){return K.set(0,0,-t,1).applyMatrix4(e.projectionMatrix),K.multiplyScalar(1/K.w),K.x=Mt/n.width,K.y=Mt/n.height,K.applyMatrix4(e.projectionMatrixInverse),K.multiplyScalar(1/K.w),Math.abs(Math.max(K.x,K.y))}function Pt(t,n){let r=t.matrixWorld,i=t.geometry,a=i.attributes.instanceStart,o=i.attributes.instanceEnd,s=Math.min(i.instanceCount,a.count);for(let i=0,c=s;i<c;i++){G.start.fromBufferAttribute(a,i),G.end.fromBufferAttribute(o,i),G.applyMatrix4(r);let s=new e.Vector3,c=new e.Vector3;q.distanceSqToSegment(G.start,G.end,c,s),c.distanceTo(s)<Mt*.5&&n.push({point:c,pointOnLine:s,distance:q.origin.distanceTo(c),object:t,face:null,faceIndex:i,uv:null,uv1:null})}}function Ft(t,n,r){let i=n.projectionMatrix,a=t.material.resolution,o=t.matrixWorld,s=t.geometry,c=s.attributes.instanceStart,l=s.attributes.instanceEnd,u=Math.min(s.instanceCount,c.count),d=-n.near;q.at(1,W),W.w=1,W.applyMatrix4(n.matrixWorldInverse),W.applyMatrix4(i),W.multiplyScalar(1/W.w),W.x*=a.x/2,W.y*=a.y/2,W.z=0,Dt.copy(W),Ot.multiplyMatrices(n.matrixWorldInverse,o);for(let n=0,s=u;n<s;n++){if(H.fromBufferAttribute(c,n),U.fromBufferAttribute(l,n),H.w=1,U.w=1,H.applyMatrix4(Ot),U.applyMatrix4(Ot),H.z>d&&U.z>d)continue;if(H.z>d){let e=H.z-U.z,t=(H.z-d)/e;H.lerp(U,t)}else if(U.z>d){let e=U.z-H.z,t=(U.z-d)/e;U.lerp(H,t)}H.applyMatrix4(i),U.applyMatrix4(i),H.multiplyScalar(1/H.w),U.multiplyScalar(1/U.w),H.x*=a.x/2,H.y*=a.y/2,U.x*=a.x/2,U.y*=a.y/2,G.start.copy(H),G.start.z=0,G.end.copy(U),G.end.z=0;let s=G.closestPointToPointParameter(Dt,!0);G.at(s,kt);let u=e.MathUtils.lerp(H.z,U.z,s),f=u>=-1&&u<=1,p=Dt.distanceTo(kt)<Mt*.5;if(f&&p){G.start.fromBufferAttribute(c,n),G.end.fromBufferAttribute(l,n),G.start.applyMatrix4(o),G.end.applyMatrix4(o);let i=new e.Vector3,a=new e.Vector3;q.distanceSqToSegment(G.start,G.end,a,i),r.push({point:a,pointOnLine:i,distance:q.origin.distanceTo(a),object:t,face:null,faceIndex:n,uv:null,uv1:null})}}}var It=class extends e.Mesh{constructor(e=new St,t=new Ct({color:Math.random()*16777215})){super(e,t),this.isLineSegments2=!0,this.type=`LineSegments2`}computeLineDistances(){let t=this.geometry,n=t.attributes.instanceStart,r=t.attributes.instanceEnd,i=new Float32Array(2*n.count);for(let e=0,t=0,a=n.count;e<a;e++,t+=2)Tt.fromBufferAttribute(n,e),Et.fromBufferAttribute(r,e),i[t]=t===0?0:i[t-1],i[t+1]=i[t]+Tt.distanceTo(Et);let a=new e.InstancedInterleavedBuffer(i,2,1);return t.setAttribute(`instanceDistanceStart`,new e.InterleavedBufferAttribute(a,1,0)),t.setAttribute(`instanceDistanceEnd`,new e.InterleavedBufferAttribute(a,1,1)),this}raycast(e,t){let n=this.material.worldUnits,r=e.camera;if(r===null&&!n&&console.error(`LineSegments2: "Raycaster.camera" needs to be set in order to raycast against LineSegments2 while worldUnits is set to false.`),n===!1&&(this.material.resolution.x===0||this.material.resolution.y===0))return;let i=e.params.Line2===void 0?0:e.params.Line2.threshold||0;q=e.ray;let a=this.matrixWorld,o=this.geometry,s=this.material;Mt=s.linewidth+i,o.boundingSphere===null&&o.computeBoundingSphere(),jt.copy(o.boundingSphere).applyMatrix4(a);let c;if(c=n?Mt*.5:Nt(r,Math.max(r.near,jt.distanceToPoint(q.origin)),s.resolution),jt.radius+=c,q.intersectsSphere(jt)===!1)return;o.boundingBox===null&&o.computeBoundingBox(),At.copy(o.boundingBox).applyMatrix4(a);let l;l=n?Mt*.5:Nt(r,Math.max(r.near,At.distanceToPoint(q.origin)),s.resolution),At.expandByScalar(l),q.intersectsBox(At)!==!1&&(n?Pt(this,t):Ft(this,r,t))}onBeforeRender(e){let t=this.material.uniforms;t&&t.resolution&&(e.getViewport(wt),this.material.uniforms.resolution.value.set(wt.z,wt.w))}},Lt=function(){Xe.call(this),this.isLines2=!0;let e=Array(300);this.createLineSegment=(e,t,n)=>{if(e&&t){let r=new St;r.setPositions(e),r.colorsNeedUpdate=!0;let i=new It(r,t);i.scale.set(1,1,1),i.computeLineDistances(),this.setMesh(i,n.localTimeEnabled,n.localMorphColour)}},this.setWidth=e=>{this.morph&&this.morph.material&&(this.morph.material.linewidth=e,this.morph.material.needsUpdate=!0)},this.addVertices=function(t){if(t&&t.length){let n=this.getMorph();n||(this.drawRange=0);let r=this.drawRange*3;if(t.forEach(t=>{e[r++]=t[0],e[r++]=t[1],e[r++]=t[2],this.drawRange++}),!n)for(;r<300;)e[r++]=t[0][0],e[r++]=t[0][1],e[r++]=t[0][2];n&&(n.geometry.setPositions(e),n.computeLineDistances(),n.geometry.computeBoundingBox(),n.geometry.computeBoundingSphere(),this.boundingBoxUpdateRequired=!0)}return e},this.getVerticesByFaceIndex=function(e){let t=e*2*3,n=this.getMorph();if(n&&this.drawRange*3>t){let e=n.geometry.getAttribute(`instanceStart`);return[[e.data.array[t],e.data.array[++t],e.data.array[++t]],[e.data.array[++t],e.data.array[++t],e.data.array[++t]]]}return[]},this.editVertices=function(t,n){if(t&&t.length){let r=this.getMorph(),i=n+t.length-1;if(!r||0>n||i>=this.drawRange)return;{let i=n*3;for(t.forEach(t=>{e[i++]=t[0],e[i++]=t[1],e[i++]=t[2]}),i=this.drawRange*3;i<300;)e[i++]=t[0][0],e[i++]=t[0][1],e[i++]=t[0][2];r.geometry.setPositions(e),r.computeLineDistances(),r.geometry.computeBoundingBox(),r.geometry.computeBoundingSphere(),this.boundingBoxUpdateRequired=!0}}return e},this.addLines=(t,n)=>{if(t&&t.length>0){if(this.addVertices(t),!this.getMorph()){let t=new Ct({color:n,linewidth:1,vertexColors:!1,worldUnits:!1});t.resolution.set(window.innerWidth,window.innerHeight),this.createLineSegment(e,t,{localTimeEnabled:!1,localMorphColour:!1})}this.region&&(this.region.pickableUpdateRequired=!0)}},this.render=(e,t,n,r)=>{this.getMorph().material.resolution.set(window.innerWidth,window.innerHeight)}};Lt.prototype=Object.create(Xe.prototype),Lt.prototype.constructor=Lt;var Rt=0,zt=function(){return`re`+Rt++},Bt=function(t,n){let r=t,i=new e.Group;i.matrixAutoUpdate=!1,i.userData=this;let a=[],o=``,s=[],c=n,l=new e.Matrix4,u=3e3;l.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this.pickableUpdateRequired=!0,this.isRegion=!0,this.uuid=zt(),this.hideAllPrimitives=()=>{a.forEach(e=>e.hideAllPrimitives()),s.forEach(e=>e.setVisibility(!1))},this.showAllPrimitives=()=>{a.forEach(e=>e.showAllPrimitives()),s.forEach(e=>e.setVisibility(!0))},this.setVisibility=e=>{e!=i.visible&&(i.visible=e,this.pickableUpdateRequired=!0)},this.getVisibility=()=>i.visible,this.getGroup=()=>i,this.setTransformation=e=>{l.set(...e),i.matrix.copy(l),i.updateMatrixWorld()},this.setName=e=>{e&&e!==``&&(o=e)},this.getName=()=>o,this.getParent=()=>r,this.getFullSeparatedPath=()=>{let e=[];if(o!==``){e.push(o);for(let t=r;t!==void 0;){let n=t.getName();n!==``&&e.unshift(n),t=t.getParent()}}return e},this.getFullPath=()=>{let e=this.getFullSeparatedPath();if(e.length>0){let t=e.shift();return e.forEach(e=>{t=t.concat(`/`,e)}),t}return``},this.createChild=e=>{let t=new Bt(this,c);return t.setName(e),a.push(t),i.add(t.getGroup()),t},this.getChildWithName=e=>{if(e){let t=e.toLowerCase();for(let e=0;e<a.length;e++)if(a[e].getName().toLowerCase()===t)return a[e]}},this.findChildFromSeparatedPath=e=>{if(e&&e.length>0&&e[0]===``&&e.shift(),e&&e.length>0){let t=this.getChildWithName(e[0]);return t?(e.shift(),t.findChildFromSeparatedPath(e)):void 0}return this},this.findChildFromPath=e=>{let t=e.split(`/`);return this.findChildFromSeparatedPath(t)},this.createChildFromSeparatedPath=e=>{if(e.length>0&&e[0]===``&&e.shift(),e.length>0){let t=this.getChildWithName(e[0]);return t||=this.createChild(e[0]),e.shift(),t.createChildFromSeparatedPath(e)}return this},this.createChildFromPath=e=>{let t=e.split(`/`);return this.createChildFromSeparatedPath(t)},this.findOrCreateChildFromPath=e=>{let t=this.findChildFromPath(e);return t||=this.createChildFromPath(e),t},this.addZincObject=e=>{e&&(e.setRegion(this),i.add(e.getGroup()),s.push(e),this.pickableUpdateRequired=!0,c&&c.triggerObjectAddedCallback(e))},this.removeZincObject=e=>{for(let t=0;t<s.length;t++)if(e===s[t]){i.remove(e.getGroup()),s.splice(t,1),c&&c.triggerObjectRemovedCallback(e),e.dispose(),this.pickableUpdateRequired=!0;return}},this.checkPickableUpdateRequred=e=>{if(this.pickableUpdateRequired)return!0;if(e){let t=!1;for(let n=0;n<a.length;n++)if(t=a[n].checkPickableUpdateRequred(e),t)return!0}return!1},this.getPickableThreeJSObjects=(e,t)=>(i.visible&&(s.forEach(t=>{if(t.isPickable&&t.getGroup()&&t.getGroup().visible){let n=t.marker;n&&n.isEnabled()&&e.push(n.getMorph()),e.push(t.getGroup())}}),t&&a.forEach(n=>{n.getPickableThreeJSObjects(e,t)}),this.pickableUpdateRequired=!1),e),this.setDuration=e=>{u=e,s.forEach(t=>t.setDuration(e)),a.forEach(t=>t.setDuration(e))},this.getDuration=()=>u,this.getBoundingBox=e=>{let t,n;return s.forEach(e=>{n=e.getBoundingBox(),n&&(t==null?t=n.clone():t.union(n))}),e&&a.forEach(r=>{n=r.getBoundingBox(e),n&&(t==null?t=n.clone():t.union(n))}),t},this.clear=e=>{e&&a.forEach(t=>t.clear(e)),s.forEach(e=>{i.remove(e.getGroup()),e.dispose()}),a=[],s=[]},this.objectIsInRegion=(e,t)=>{for(let t=0;t<s.length;t++)if(e===s[t])return!0;if(t){for(let n=0;n<a.length;n++)if(a[n].objectIsInRegion(e,t))return!0}return!1},this.forEachGeometry=(e,t)=>{s.forEach(t=>{t.isGeometry&&e(t)}),t&&a.forEach(n=>n.forEachGeometry(e,t))},this.forEachGlyphset=(e,t)=>{s.forEach(t=>{t.isGlyphset&&e(t)}),t&&a.forEach(n=>n.forEachGlyphset(e,t))},this.forEachPointset=(e,t)=>{s.forEach(t=>{t.isPointset&&e(t)}),t&&a.forEach(n=>n.forEachPointset(e,t))},this.forEachLine=(e,t)=>{s.forEach(t=>{t.isLines&&e(t)}),t&&a.forEach(n=>n.forEachLine(e,t))},this.findObjectsWithAnatomicalId=(e,t)=>{let n=[];return s.forEach(t=>{t.anatomicalId===e&&n.push(t)}),t&&a.forEach(r=>{let i=r.findObjectsWithAnatomicalId(e,t);n.push(...i)}),n},this.findObjectsWithGroupName=(e,t)=>{let n=[];return s.forEach(t=>{(t.groupName?t.groupName.toLowerCase():t.groupName)===(e&&e.toLowerCase())&&n.push(t)}),t&&a.forEach(r=>{let i=r.findObjectsWithGroupName(e,t);n.push(...i)}),n},this.findGeometriesWithGroupName=(e,t)=>this.findObjectsWithGroupName(e,t).filter(e=>e.isGeometry),this.findPointsetsWithGroupName=(e,t)=>this.findObjectsWithGroupName(e,t).filter(e=>e.isPointset),this.findGlyphsetsWithGroupName=(e,t)=>this.findObjectsWithGroupName(e,t).filter(e=>e.isGlyphset),this.findLinesWithGroupName=(e,t)=>this.findObjectsWithGroupName(e,t).filter(e=>e.isLines),this.getAllObjects=e=>{let t=[...s];return e&&a.forEach(n=>{let r=n.getAllObjects(e);t.push(...r)}),t},this.getChildRegions=e=>{let t=[...a];return e&&a.forEach(n=>{let r=n.getChildRegions(e);t.push(...r)}),t},this.getCurrentTime=()=>{if(s[0]!=null)return s[0].getCurrentTime();for(let e=0;e<a.length;e++){let t=a[e].getCurrentTime();if(t!==-1)return t}return-1},this.setMorphTime=(e,t)=>{s.forEach(t=>{t.setMorphTime(e)}),t&&a.forEach(t=>{t.setMorphTime(e)})},this.isTimeVarying=()=>{for(let e=0;e<s.length;e++)if(s[e].isTimeVarying())return!0;for(let e=0;e<a.length;e++)if(a[e].isTimeVarying())return!0;return!1},this.renderGeometries=(e,t,n,r,i,a)=>{this.getAllObjects(a).forEach(a=>{a.render(e*t,n,r,i)}),i&&n===!1&&i.markerCluster?.markerUpdateRequired&&i.markerCluster.calculate()},this.createPoints=(e,t,n,r)=>{let i=!1,a=this.findObjectsWithGroupName(e,!1),o=a.findIndex(e=>e.isPointset),s=o>-1?a[o]:new Ye;return s.addPoints(t,n,r),o===-1?(s.setName(e),this.addZincObject(s),i=!0):this.pickableUpdateRequired=!0,{zincObject:s,isNew:i}},this.createLines=(e,t,n)=>{let r=!1,i=this.findObjectsWithGroupName(e,!1),a=i.findIndex(e=>e.isLines),o=a>-1?i[a]:new Lt;return o.addLines(t,n),a===-1?(o.setName(e),this.addZincObject(o),r=!0):this.pickableUpdateRequired=!0,{zincObject:o,isNew:r}},this.createGeometryFromThreeJSGeometry=(t,n,r,i,a,o)=>{let s=new we,c=new e.MeshPhongMaterial({color:r,transparent:!0,opacity:i,side:e.DoubleSide});if(s.createMesh(n,c,{localTimeEnabled:!1,localMorphColour:!1}),s.getMorph())return s.setVisibility(!1),s.setName(t),s.setRenderOrder(o),this.addZincObject(s),s}},Vt=class{constructor(){this.pluginCallbacks=[],this.register(function(e){return new rn(e)}),this.register(function(e){return new an(e)}),this.register(function(e){return new on(e)})}register(e){return this.pluginCallbacks.indexOf(e)===-1&&this.pluginCallbacks.push(e),this}unregister(e){return this.pluginCallbacks.indexOf(e)!==-1&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,n){let r=new nn,i=[];for(let e=0,t=this.pluginCallbacks.length;e<t;e++)i.push(this.pluginCallbacks[e](r));r.setPlugins(i),r.write(e,t,n)}},J={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,UNSIGNED_BYTE:5121,UNSIGNED_SHORT:5123,FLOAT:5126,UNSIGNED_INT:5125,ARRAY_BUFFER:34962,ELEMENT_ARRAY_BUFFER:34963,NEAREST:9728,LINEAR:9729,NEAREST_MIPMAP_NEAREST:9984,LINEAR_MIPMAP_NEAREST:9985,NEAREST_MIPMAP_LINEAR:9986,LINEAR_MIPMAP_LINEAR:9987,CLAMP_TO_EDGE:33071,MIRRORED_REPEAT:33648,REPEAT:10497},Y={};Y[e.NearestFilter]=J.NEAREST,Y[e.NearestMipmapNearestFilter]=J.NEAREST_MIPMAP_NEAREST,Y[e.NearestMipmapLinearFilter]=J.NEAREST_MIPMAP_LINEAR,Y[e.LinearFilter]=J.LINEAR,Y[e.LinearMipmapNearestFilter]=J.LINEAR_MIPMAP_NEAREST,Y[e.LinearMipmapLinearFilter]=J.LINEAR_MIPMAP_LINEAR,Y[e.ClampToEdgeWrapping]=J.CLAMP_TO_EDGE,Y[e.RepeatWrapping]=J.REPEAT,Y[e.MirroredRepeatWrapping]=J.MIRRORED_REPEAT;var Ht={scale:`scale`,position:`translation`,quaternion:`rotation`,morphTargetInfluences:`weights`},Ut=12,Wt=1179937895,Gt=2,Kt=8,qt=1313821514,Jt=5130562;function Yt(e,t){return e.length===t.length&&e.every(function(e,n){return e===t[n]})}function Xt(e){if(window.TextEncoder!==void 0)return new TextEncoder().encode(e).buffer;let t=new Uint8Array(new ArrayBuffer(e.length));for(let n=0,r=e.length;n<r;n++){let r=e.charCodeAt(n);t[n]=r>255?32:r}return t.buffer}function Zt(e){return Yt(e.elements,[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}function Qt(e,t,n){let r={min:Array(e.itemSize).fill(1/0),max:Array(e.itemSize).fill(-1/0)};for(let i=t;i<t+n;i++)for(let t=0;t<e.itemSize;t++){let n;e.itemSize>4?n=e.array[i*e.itemSize+t]:t===0?n=e.getX(i):t===1?n=e.getY(i):t===2?n=e.getZ(i):t===3&&(n=e.getW(i)),r.min[t]=Math.min(r.min[t],n),r.max[t]=Math.max(r.max[t],n)}return r}function $t(e){return Math.ceil(e/4)*4}function en(e,t=0){let n=$t(e.byteLength);if(n!==e.byteLength){let r=new Uint8Array(n);if(r.set(new Uint8Array(e)),t!==0)for(let i=e.byteLength;i<n;i++)r[i]=t;return r.buffer}return e}var tn=null,nn=class{constructor(){this.plugins=[],this.options={},this.pending=[],this.buffers=[],this.byteOffset=0,this.buffers=[],this.nodeMap=new Map,this.skins=[],this.extensionsUsed={},this.uids=new Map,this.uid=0,this.json={asset:{version:`2.0`,generator:`THREE.GLTFExporter`}},this.cache={meshes:new Map,attributes:new Map,attributesNormalized:new Map,materials:new Map,textures:new Map,images:new Map}}setPlugins(e){this.plugins=e}write(e,t,n){this.options=Object.assign({},{binary:!1,trs:!1,onlyVisible:!0,truncateDrawRange:!0,embedImages:!0,maxTextureSize:1/0,animations:[],includeCustomExtensions:!1},n),this.options.animations.length>0&&(this.options.trs=!0),this.processInput(e);let r=this;Promise.all(this.pending).then(function(){let e=r.buffers,n=r.json,i=r.options,a=r.extensionsUsed,o=new Blob(e,{type:`application/octet-stream`}),s=Object.keys(a);if(s.length>0&&(n.extensionsUsed=s),n.buffers&&n.buffers.length>0&&(n.buffers[0].byteLength=o.size),i.binary===!0){let e=new window.FileReader;e.readAsArrayBuffer(o),e.onloadend=function(){let r=en(e.result),i=new DataView(new ArrayBuffer(Kt));i.setUint32(0,r.byteLength,!0),i.setUint32(4,Jt,!0);let a=en(Xt(JSON.stringify(n)),32),o=new DataView(new ArrayBuffer(Kt));o.setUint32(0,a.byteLength,!0),o.setUint32(4,qt,!0);let s=new ArrayBuffer(Ut),c=new DataView(s);c.setUint32(0,Wt,!0),c.setUint32(4,Gt,!0);let l=Ut+o.byteLength+a.byteLength+i.byteLength+r.byteLength;c.setUint32(8,l,!0);let u=new Blob([s,o,a,i,r],{type:`application/octet-stream`}),d=new window.FileReader;d.readAsArrayBuffer(u),d.onloadend=function(){t(d.result)}}}else if(n.buffers&&n.buffers.length>0){let e=new window.FileReader;e.readAsDataURL(o),e.onloadend=function(){let r=e.result;n.buffers[0].uri=r,t(n)}}else t(n)})}serializeUserData(e,t){if(e.userData&&e.userData.isZincObject||Object.keys(e.userData).length===0)return;let n=this.options,r=this.extensionsUsed;try{let i=JSON.parse(JSON.stringify(e.userData));if(n.includeCustomExtensions&&i.gltfExtensions){t.extensions===void 0&&(t.extensions={});for(let e in i.gltfExtensions)t.extensions[e]=i.gltfExtensions[e],r[e]=!0;delete i.gltfExtensions}Object.keys(i).length>0&&(t.extras=i)}catch(t){console.warn(`THREE.GLTFExporter: userData of '`+e.name+`' won't be serialized because of JSON.stringify error - `+t.message)}}getUID(e){return this.uids.has(e)||this.uids.set(e,this.uid++),this.uids.get(e)}isNormalizedNormalAttribute(t){if(this.cache.attributesNormalized.has(t))return!1;let n=new e.Vector3;for(let e=0,r=t.count;e<r;e++)if(Math.abs(n.fromBufferAttribute(t,e).length()-1)>5e-4)return!1;return!0}createNormalizedNormalAttribute(t){let n=this.cache;if(n.attributesNormalized.has(t))return n.attributesNormalized.get(t);let r=t.clone(),i=new e.Vector3;for(let e=0,t=r.count;e<t;e++)i.fromBufferAttribute(r,e),i.x===0&&i.y===0&&i.z===0?i.setX(1):i.normalize(),r.setXYZ(e,i.x,i.y,i.z);return n.attributesNormalized.set(t,r),r}applyTextureTransform(e,t){let n=!1,r={};(t.offset.x!==0||t.offset.y!==0)&&(r.offset=t.offset.toArray(),n=!0),t.rotation!==0&&(r.rotation=t.rotation,n=!0),(t.repeat.x!==1||t.repeat.y!==1)&&(r.scale=t.repeat.toArray(),n=!0),n&&(e.extensions=e.extensions||{},e.extensions.KHR_texture_transform=r,this.extensionsUsed.KHR_texture_transform=!0)}processBuffer(e){let t=this.json,n=this.buffers;return t.buffers||=[{byteLength:0}],n.push(e),0}processBufferView(e,t,n,r,i){let a=this.json;a.bufferViews||=[];let o;o=t===J.UNSIGNED_BYTE?1:t===J.UNSIGNED_SHORT?2:4;let s=$t(r*e.itemSize*o),c=new DataView(new ArrayBuffer(s)),l=0;for(let i=n;i<n+r;i++)for(let n=0;n<e.itemSize;n++){let r;e.itemSize>4?r=e.array[i*e.itemSize+n]:n===0?r=e.getX(i):n===1?r=e.getY(i):n===2?r=e.getZ(i):n===3&&(r=e.getW(i)),t===J.FLOAT?c.setFloat32(l,r,!0):t===J.UNSIGNED_INT?c.setUint32(l,r,!0):t===J.UNSIGNED_SHORT?c.setUint16(l,r,!0):t===J.UNSIGNED_BYTE&&c.setUint8(l,r),l+=o}let u={buffer:this.processBuffer(c.buffer),byteOffset:this.byteOffset,byteLength:s};return i!==void 0&&(u.target=i),i===J.ARRAY_BUFFER&&(u.byteStride=e.itemSize*o),this.byteOffset+=s,a.bufferViews.push(u),{id:a.bufferViews.length-1,byteLength:0}}processBufferViewImage(e){let t=this,n=t.json;return n.bufferViews||=[],new Promise(function(r){let i=new window.FileReader;i.readAsArrayBuffer(e),i.onloadend=function(){let e=en(i.result),a={buffer:t.processBuffer(e),byteOffset:t.byteOffset,byteLength:e.byteLength};t.byteOffset+=e.byteLength,r(n.bufferViews.push(a)-1)}})}processAccessor(e,t,n,r){let i=this.options,a=this.json,o={1:`SCALAR`,2:`VEC2`,3:`VEC3`,4:`VEC4`,16:`MAT4`},s;if(e.array.constructor===Float32Array)s=J.FLOAT;else if(e.array.constructor===Uint32Array)s=J.UNSIGNED_INT;else if(e.array.constructor===Uint16Array)s=J.UNSIGNED_SHORT;else if(e.array.constructor===Uint8Array)s=J.UNSIGNED_BYTE;else throw Error(`THREE.GLTFExporter: Unsupported bufferAttribute component type.`);if(n===void 0&&(n=0),r===void 0&&(r=e.count),i.truncateDrawRange&&t!==void 0&&t.index===null){let i=n+r,a=t.drawRange.count===1/0?e.count:t.drawRange.start+t.drawRange.count;n=Math.max(n,t.drawRange.start),r=Math.min(i,a)-n,r<0&&(r=0)}if(r===0)return null;let c=Qt(e,n,r),l;t!==void 0&&(l=e===t.index?J.ELEMENT_ARRAY_BUFFER:J.ARRAY_BUFFER);let u=this.processBufferView(e,s,n,r,l),d={bufferView:u.id,byteOffset:u.byteOffset,componentType:s,count:r,max:c.max,min:c.min,type:o[e.itemSize]};return e.normalized===!0&&(d.normalized=!0),a.accessors||=[],a.accessors.push(d)-1}processImage(t,n,r){let i=this,a=i.cache,o=i.json,s=i.options,c=i.pending;a.images.has(t)||a.images.set(t,{});let l=a.images.get(t),u=n===e.RGBAFormat?`image/png`:`image/jpeg`,d=u+`:flipY/`+r.toString();if(l[d]!==void 0)return l[d];o.images||=[];let f={mimeType:u};if(s.embedImages){let a=tn||=document.createElement(`canvas`);a.width=Math.min(t.width,s.maxTextureSize),a.height=Math.min(t.height,s.maxTextureSize);let o=a.getContext(`2d`);if(r===!0&&(o.translate(0,a.height),o.scale(1,-1)),typeof HTMLImageElement<`u`&&t instanceof HTMLImageElement||typeof HTMLCanvasElement<`u`&&t instanceof HTMLCanvasElement||typeof OffscreenCanvas<`u`&&t instanceof OffscreenCanvas||typeof ImageBitmap<`u`&&t instanceof ImageBitmap)o.drawImage(t,0,0,a.width,a.height);else{n!==e.RGBAFormat&&n!==e.RGBFormat&&console.error(`GLTFExporter: Only RGB and RGBA formats are supported.`),(t.width>s.maxTextureSize||t.height>s.maxTextureSize)&&console.warn(`GLTFExporter: Image size is bigger than maxTextureSize`,t);let r=new Uint8ClampedArray(t.height*t.width*4);if(n===e.RGBAFormat)for(let e=0;e<r.length;e+=4)r[e+0]=t.data[e+0],r[e+1]=t.data[e+1],r[e+2]=t.data[e+2],r[e+3]=t.data[e+3];else for(let e=0,n=0;e<r.length;e+=4,n+=3)r[e+0]=t.data[n+0],r[e+1]=t.data[n+1],r[e+2]=t.data[n+2],r[e+3]=255;o.putImageData(new ImageData(r,t.width,t.height),0,0)}s.binary===!0?c.push(new Promise(function(e){a.toBlob(function(t){i.processBufferViewImage(t).then(function(t){f.bufferView=t,e()})},u)})):f.uri=a.toDataURL(u)}else f.uri=t.src;let p=o.images.push(f)-1;return l[d]=p,p}processSampler(e){let t=this.json;t.samplers||=[];let n={magFilter:Y[e.magFilter],minFilter:Y[e.minFilter],wrapS:Y[e.wrapS],wrapT:Y[e.wrapT]};return t.samplers.push(n)-1}processTexture(e){let t=this.cache,n=this.json;if(t.textures.has(e))return t.textures.get(e);n.textures||=[];let r={sampler:this.processSampler(e),source:this.processImage(e.image,e.format,e.flipY)};e.name&&(r.name=e.name),this._invokeAll(function(t){t.writeTexture&&t.writeTexture(e,r)});let i=n.textures.push(r)-1;return t.textures.set(e,i),i}processMaterial(t){let n=this.cache,r=this.json;if(n.materials.has(t))return n.materials.get(t);if(t.isShaderMaterial)return console.warn(`GLTFExporter: THREE.ShaderMaterial not supported.`),null;r.materials||=[];let i={pbrMetallicRoughness:{}};t.isMeshStandardMaterial!==!0&&t.isMeshBasicMaterial!==!0&&console.warn(`GLTFExporter: Use MeshStandardMaterial or MeshBasicMaterial for best results.`);let a=t.color.toArray().concat([t.opacity]);if(Yt(a,[1,1,1,1])||(i.pbrMetallicRoughness.baseColorFactor=a),t.isMeshStandardMaterial?(i.pbrMetallicRoughness.metallicFactor=t.metalness,i.pbrMetallicRoughness.roughnessFactor=t.roughness):(i.pbrMetallicRoughness.metallicFactor=.5,i.pbrMetallicRoughness.roughnessFactor=.5),t.metalnessMap||t.roughnessMap){if(t.metalnessMap===t.roughnessMap){let e={index:this.processTexture(t.metalnessMap)};this.applyTextureTransform(e,t.metalnessMap),i.pbrMetallicRoughness.metallicRoughnessTexture=e}else console.warn(`THREE.GLTFExporter: Ignoring metalnessMap and roughnessMap because they are not the same Texture.`)}if(t.map){let e={index:this.processTexture(t.map)};this.applyTextureTransform(e,t.map),i.pbrMetallicRoughness.baseColorTexture=e}if(t.emissive){let e=t.emissive.clone().multiplyScalar(t.emissiveIntensity),n=Math.max(e.r,e.g,e.b);if(n>1&&(e.multiplyScalar(1/n),console.warn(`THREE.GLTFExporter: Some emissive components exceed 1; emissive has been limited`)),n>0&&(i.emissiveFactor=e.toArray()),t.emissiveMap){let e={index:this.processTexture(t.emissiveMap)};this.applyTextureTransform(e,t.emissiveMap),i.emissiveTexture=e}}if(t.normalMap){let e={index:this.processTexture(t.normalMap)};t.normalScale&&t.normalScale.x!==-1&&(t.normalScale.x!==t.normalScale.y&&console.warn(`THREE.GLTFExporter: Normal scale components are different, ignoring Y and exporting X.`),e.scale=t.normalScale.x),this.applyTextureTransform(e,t.normalMap),i.normalTexture=e}if(t.aoMap){let e={index:this.processTexture(t.aoMap),texCoord:1};t.aoMapIntensity!==1&&(e.strength=t.aoMapIntensity),this.applyTextureTransform(e,t.aoMap),i.occlusionTexture=e}t.transparent?i.alphaMode=`BLEND`:t.alphaTest>0&&(i.alphaMode=`MASK`,i.alphaCutoff=t.alphaTest),t.side===e.DoubleSide&&(i.doubleSided=!0),t.name!==``&&(i.name=t.name),this.serializeUserData(t,i),this._invokeAll(function(e){e.writeMaterial&&e.writeMaterial(t,i)});let o=r.materials.push(i)-1;return n.materials.set(t,o),o}processMesh(t){let n=this.cache,r=this.json,i=[t.geometry.uuid];if(Array.isArray(t.material))for(let e=0,n=t.material.length;e<n;e++)i.push(t.material[e].uuid);else i.push(t.material.uuid);let a=i.join(`:`);if(n.meshes.has(a))return n.meshes.get(a);let o=t.geometry,s;if(s=t.isLineSegments?J.LINES:t.isLineLoop?J.LINE_LOOP:t.isLine?J.LINE_STRIP:t.isPoints?J.POINTS:t.material.wireframe?J.LINES:J.TRIANGLES,o.isBufferGeometry!==!0)throw Error(`THREE.GLTFExporter: Geometry is not of type THREE.BufferGeometry.`);let c={},l={},u=[],d=[],f={uv:`TEXCOORD_0`,uv2:`TEXCOORD_1`,color:`COLOR_0`,skinWeight:`WEIGHTS_0`,skinIndex:`JOINTS_0`},p=o.getAttribute(`normal`);p!==void 0&&!this.isNormalizedNormalAttribute(p)&&(console.warn(`THREE.GLTFExporter: Creating normalized normal attribute from the non-normalized one.`),o.setAttribute(`normal`,this.createNormalizedNormalAttribute(p)));let m=null;for(let t in o.attributes){if(t.substr(0,5)===`morph`)continue;let r=o.attributes[t];if(t=f[t]||t.toUpperCase(),/^(POSITION|NORMAL|TANGENT|TEXCOORD_\d+|COLOR_\d+|JOINTS_\d+|WEIGHTS_\d+)$/.test(t)||(t=`_`+t),n.attributes.has(this.getUID(r))){l[t]=n.attributes.get(this.getUID(r));continue}m=null;let i=r.array;t===`JOINTS_0`&&!(i instanceof Uint16Array)&&!(i instanceof Uint8Array)&&(console.warn(`GLTFExporter: Attribute "skinIndex" converted to type UNSIGNED_SHORT.`),m=new e.BufferAttribute(new Uint16Array(i),r.itemSize,r.normalized));let a=this.processAccessor(m||r,o);a!==null&&(l[t]=a,n.attributes.set(this.getUID(r),a))}if(p!==void 0&&o.setAttribute(`normal`,p),Object.keys(l).length===0)return null;if(t.morphTargetInfluences!==void 0&&t.morphTargetInfluences.length>0){let e=[],r=[],i={};if(t.morphTargetDictionary!==void 0)for(let e in t.morphTargetDictionary)i[t.morphTargetDictionary[e]]=e;for(let a=0;a<t.morphTargetInfluences.length;++a){let s={},c=!1;for(let e in o.morphAttributes){if(e!==`position`&&e!==`normal`&&e!==`color`){c||=(console.warn(`GLTFExporter: Only POSITION and NORMAL morph are supported.`),!0);continue}let t=o.morphAttributes[e][a],r=e.toUpperCase();f[e]&&(r=f[e]);let i=o.attributes[e];if(n.attributes.has(this.getUID(t))){s[r]=n.attributes.get(this.getUID(t));continue}let l=i.clone();if(!o.morphTargetsRelative){if(i)for(let e=0,n=t.count;e<n;e++)i.count>e&&l.setXYZ(e,t.getX(e)-i.getX(e),t.getY(e)-i.getY(e),t.getZ(e)-i.getZ(e));else for(let e=0,n=t.count;e<n;e++)l.setXYZ(e,0,0,0)}s[r]=this.processAccessor(l,o),n.attributes.set(this.getUID(i),s[r])}d.push(s),e.push(t.morphTargetInfluences[a]),t.morphTargetDictionary!==void 0&&r.push(i[a])}c.weights=e,r.length>0&&(c.extras={},c.extras.targetNames=r)}let h=Array.isArray(t.material);if(h&&o.groups.length===0)return null;let g=h?t.material:[t.material],_=h?o.groups:[{materialIndex:0,start:void 0,count:void 0}];for(let e=0,t=_.length;e<t;e++){let t={mode:s,attributes:l};if(this.serializeUserData(o,t),d.length>0&&(t.targets=d),o.index!==null){let r=this.getUID(o.index);(_[e].start!==void 0||_[e].count!==void 0)&&(r+=`:`+_[e].start+`:`+_[e].count),n.attributes.has(r)?t.indices=n.attributes.get(r):(t.indices=this.processAccessor(o.index,o,_[e].start,_[e].count),n.attributes.set(r,t.indices)),t.indices===null&&delete t.indices}let r=this.processMaterial(g[_[e].materialIndex]);r!==null&&(t.material=r),u.push(t)}c.primitives=u,r.meshes||=[],this._invokeAll(function(e){e.writeMesh&&e.writeMesh(t,c)});let v=r.meshes.push(c)-1;return n.meshes.set(a,v),v}processCamera(t){let n=this.json;n.cameras||=[];let r=t.isOrthographicCamera,i={type:r?`orthographic`:`perspective`};return r?i.orthographic={xmag:t.right*2,ymag:t.top*2,zfar:t.far<=0?.001:t.far,znear:t.near<0?0:t.near}:i.perspective={aspectRatio:t.aspect,yfov:e.MathUtils.degToRad(t.fov),zfar:t.far<=0?.001:t.far,znear:t.near<0?0:t.near},t.name!==``&&(i.name=t.type),n.cameras.push(i)-1}processAnimation(t,n){let r=this.json,i=this.nodeMap;r.animations||=[],t=Vt.Utils.mergeMorphTargetTracks(t.clone(),n);let a=t.tracks,o=[],s=[];for(let t=0;t<a.length;++t){let r=a[t],c=e.PropertyBinding.parseTrackName(r.name),l=e.PropertyBinding.findNode(n,c.nodeName),u=Ht[c.propertyName];if(c.objectName===`bones`&&(l=l.isSkinnedMesh===!0?l.skeleton.getBoneByName(c.objectIndex):void 0),!l||!u)return console.warn(`THREE.GLTFExporter: Could not export animation track "%s".`,r.name),null;let d=r.values.length/r.times.length;u===Ht.morphTargetInfluences&&(d/=l.morphTargetInfluences.length);let f;r.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline===!0?(f=`CUBICSPLINE`,d/=3):f=r.getInterpolation()===e.InterpolateDiscrete?`STEP`:`LINEAR`,s.push({input:this.processAccessor(new e.BufferAttribute(r.times,1)),output:this.processAccessor(new e.BufferAttribute(r.values,d)),interpolation:f}),o.push({sampler:s.length-1,target:{node:i.get(l),path:u}})}return r.animations.push({name:t.name||`clip_`+r.animations.length,samplers:s,channels:o}),r.animations.length-1}processSkin(t){let n=this.json,r=this.nodeMap,i=n.nodes[r.get(t)],a=t.skeleton;if(a===void 0)return null;let o=t.skeleton.bones[0];if(o===void 0)return null;let s=[],c=new Float32Array(a.bones.length*16),l=new e.Matrix4;for(let e=0;e<a.bones.length;++e)s.push(r.get(a.bones[e])),l.copy(a.boneInverses[e]),l.multiply(t.bindMatrix).toArray(c,e*16);return n.skins===void 0&&(n.skins=[]),n.skins.push({inverseBindMatrices:this.processAccessor(new e.BufferAttribute(c,16)),joints:s,skeleton:r.get(o)}),i.skin=n.skins.length-1}processNode(e){let t=this.json,n=this.options,r=this.nodeMap;t.nodes||=[];let i={};if(n.trs){let t=e.quaternion.toArray(),n=e.position.toArray(),r=e.scale.toArray();Yt(t,[0,0,0,1])||(i.rotation=t),Yt(n,[0,0,0])||(i.translation=n),Yt(r,[1,1,1])||(i.scale=r)}else e.matrixAutoUpdate&&e.updateMatrix(),Zt(e.matrix)===!1&&(i.matrix=e.matrix.elements);if(e.name!==``&&(i.name=String(e.name)),this.serializeUserData(e,i),e.isMesh||e.isLine||e.isPoints){let t=this.processMesh(e);t!==null&&(i.mesh=t)}else e.isCamera&&(i.camera=this.processCamera(e));if(e.isSkinnedMesh&&this.skins.push(e),e.children.length>0){let t=[];for(let r=0,i=e.children.length;r<i;r++){let i=e.children[r];if(i.visible||n.onlyVisible===!1){let e=this.processNode(i);e!==null&&t.push(e)}}t.length>0&&(i.children=t)}this._invokeAll(function(t){t.writeNode&&t.writeNode(e,i)});let a=t.nodes.push(i)-1;return r.set(e,a),a}processScene(e){let t=this.json,n=this.options;t.scenes||(t.scenes=[],t.scene=0);let r={};e.name!==``&&(r.name=e.name),t.scenes.push(r);let i=[];for(let t=0,r=e.children.length;t<r;t++){let r=e.children[t];if(r.visible||n.onlyVisible===!1){let e=this.processNode(r);e!==null&&i.push(e)}}i.length>0&&(r.nodes=i),this.serializeUserData(e,r)}processObjects(t){let n=new e.Scene;n.name=`AuxScene`;for(let e=0;e<t.length;e++)n.children.push(t[e]);this.processScene(n)}processInput(t){let n=this.options;t=t instanceof Array?t:[t],this._invokeAll(function(e){e.beforeParse&&e.beforeParse(t)});let r=[];for(let n=0;n<t.length;n++)t[n]instanceof e.Scene?this.processScene(t[n]):r.push(t[n]);r.length>0&&this.processObjects(r);for(let e=0;e<this.skins.length;++e)this.processSkin(this.skins[e]);for(let e=0;e<n.animations.length;++e)this.processAnimation(n.animations[e].clip,n.animations[e].mesh);this._invokeAll(function(e){e.afterParse&&e.afterParse(t)})}_invokeAll(e){for(let t=0,n=this.plugins.length;t<n;t++)e(this.plugins[t])}},rn=class{constructor(e){this.writer=e,this.name=`KHR_lights_punctual`}writeNode(e,t){if(!e.isLight)return;if(!e.isDirectionalLight&&!e.isPointLight&&!e.isSpotLight){console.warn(`THREE.GLTFExporter: Only directional, point, and spot lights are supported.`,e);return}let n=this.writer,r=n.json,i=n.extensionsUsed,a={};e.name&&(a.name=e.name),a.color=e.color.toArray(),a.intensity=e.intensity,e.isDirectionalLight?a.type=`directional`:e.isPointLight?(a.type=`point`,e.distance>0&&(a.range=e.distance)):e.isSpotLight&&(a.type=`spot`,e.distance>0&&(a.range=e.distance),a.spot={},a.spot.innerConeAngle=(e.penumbra-1)*e.angle*-1,a.spot.outerConeAngle=e.angle),e.decay!==void 0&&e.decay!==2&&console.warn(`THREE.GLTFExporter: Light decay may be lost. glTF is physically-based, and expects light.decay=2.`),e.target&&(e.target.parent!==e||e.target.position.x!==0||e.target.position.y!==0||e.target.position.z!==-1)&&console.warn(`THREE.GLTFExporter: Light direction may be lost. For best results, make light.target a child of the light with position 0,0,-1.`),i[this.name]||(r.extensions=r.extensions||{},r.extensions[this.name]={lights:[]},i[this.name]=!0);let o=r.extensions[this.name].lights;o.push(a),t.extensions=t.extensions||{},t.extensions[this.name]={light:o.length-1}}},an=class{constructor(e){this.writer=e,this.name=`KHR_materials_unlit`}writeMaterial(e,t){if(!e.isMeshBasicMaterial)return;let n=this.writer.extensionsUsed;t.extensions=t.extensions||{},t.extensions[this.name]={},n[this.name]=!0,t.pbrMetallicRoughness.metallicFactor=0,t.pbrMetallicRoughness.roughnessFactor=.9}},on=class{constructor(e){this.writer=e,this.name=`KHR_materials_pbrSpecularGlossiness`}writeMaterial(e,t){if(!e.isGLTFSpecularGlossinessMaterial)return;let n=this.writer,r=n.extensionsUsed,i={};t.pbrMetallicRoughness.baseColorFactor&&(i.diffuseFactor=t.pbrMetallicRoughness.baseColorFactor);let a=[1,1,1];if(e.specular.toArray(a,0),i.specularFactor=a,i.glossinessFactor=e.glossiness,t.pbrMetallicRoughness.baseColorTexture&&(i.diffuseTexture=t.pbrMetallicRoughness.baseColorTexture),e.specularMap){let t={index:n.processTexture(e.specularMap)};n.applyTextureTransform(t,e.specularMap),i.specularGlossinessTexture=t}t.extensions=t.extensions||{},t.extensions[this.name]=i,r[this.name]=!0}};Vt.Utils={insertKeyframe:function(e,t){let n=.001,r=e.getValueSize(),i=new e.TimeBufferType(e.times.length+1),a=new e.ValueBufferType(e.values.length+r),o=e.createInterpolant(new e.ValueBufferType(r)),s;if(e.times.length===0){i[0]=t;for(let e=0;e<r;e++)a[e]=0;s=0}else if(t<e.times[0]){if(Math.abs(e.times[0]-t)<n)return 0;i[0]=t,i.set(e.times,1),a.set(o.evaluate(t),0),a.set(e.values,r),s=0}else if(t>e.times[e.times.length-1]){if(Math.abs(e.times[e.times.length-1]-t)<n)return e.times.length-1;i[i.length-1]=t,i.set(e.times,0),a.set(e.values,0),a.set(o.evaluate(t),e.values.length),s=i.length-1}else for(let c=0;c<e.times.length;c++){if(Math.abs(e.times[c]-t)<n)return c;if(e.times[c]<t&&e.times[c+1]>t){i.set(e.times.slice(0,c+1),0),i[c+1]=t,i.set(e.times.slice(c+1),c+2),a.set(e.values.slice(0,(c+1)*r),0),a.set(o.evaluate(t),(c+1)*r),a.set(e.values.slice((c+1)*r),(c+2)*r),s=c+1;break}}return e.times=i,e.values=a,s},mergeMorphTargetTracks:function(t,n){let r=[],i={},a=t.tracks;for(let t=0;t<a.length;++t){let o=a[t],s=e.PropertyBinding.parseTrackName(o.name),c=e.PropertyBinding.findNode(n,s.nodeName);if(s.propertyName!==`morphTargetInfluences`||s.propertyIndex===void 0){r.push(o);continue}if(o.createInterpolant!==o.InterpolantFactoryMethodDiscrete&&o.createInterpolant!==o.InterpolantFactoryMethodLinear){if(o.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline)throw Error(`THREE.GLTFExporter: Cannot merge tracks with glTF CUBICSPLINE interpolation.`);console.warn(`THREE.GLTFExporter: Morph target interpolation mode not yet supported. Using LINEAR instead.`),o=o.clone(),o.setInterpolation(e.InterpolateLinear)}let l=c.morphTargetInfluences.length,u=c.morphTargetDictionary[s.propertyIndex];if(u===void 0)throw Error(`THREE.GLTFExporter: Morph target name not found: `+s.propertyIndex);let d;if(i[c.uuid]===void 0){d=o.clone();let e=new d.ValueBufferType(l*d.times.length);for(let t=0;t<d.times.length;t++)e[t*l+u]=d.values[t];d.name=(s.nodeName||``)+`.morphTargetInfluences`,d.values=e,i[c.uuid]=d,r.push(d);continue}let f=o.createInterpolant(new o.ValueBufferType(1));d=i[c.uuid];for(let e=0;e<d.times.length;e++)d.values[e*l+u]=f.evaluate(d.times[e]);for(let e=0;e<o.times.length;e++){let t=this.insertKeyframe(d,o.times[e]);d.values[t*l+u]=o.values[e]}}return t.tracks=r,t}};var sn=function(e){let t=e;this.exportGLTF=e=>{let n=t.getRootRegion().getAllObjects(!0),r=[];n.forEach(e=>{e.animationClip&&r.push({clip:e.animationClip[0],mesh:e.getMorph()})});let i=new Vt,a={binary:e,animations:r};return new Promise((e,n)=>{i.parse(t.getThreeJSScene(),function(t){e(t)},a)})}},cn=function(){let e=this;this.parseGLTFObjects=(t,n,r,i)=>{let a=n;if(r!==0){if(t.type===`Object3D`){if(t.name!==``&&(n&&(a=n.findOrCreateChildFromPath(t.name)),a)){let e=a.getGroup();e.position.copy(t.position),e.rotation.copy(t.rotation),e.quaternion.copy(t.quaternion),e.matrixAutoUpdate=!0}}else{let e;if(t.type===`Mesh`?e=new we:t.type===`LineSegments`?e=new Xe:t.type===`Points`&&(e=new Ye),e){let r=!1,a=!1;t.geometry&&t.geometry.morphAttributes&&(r=!!t.geometry.morphAttributes.position,a=!!t.geometry.morphAttributes.color),e.setMesh(t.clone(),r,a);let o=e.getMorph();e.groupName=o.name,o.matrixAutoUpdate=!0,n.addZincObject(e),i!=null&&typeof i==`function`&&i(e)}}}r++,t.children.forEach(t=>{e.parseGLTFObjects(t,a,r,i)})},this.setCamera=e=>{e.viewAll();let t=e.getZincCameraControls(),n=t.getCurrentViewport();t.addViewport(`default`,n),t.setDefaultViewport(`default`)},this.load=(t,n,i,a,o,s)=>{let c=i.substring(0,i.lastIndexOf(`/`)+1),l=i.substring(i.lastIndexOf(`/`)+1,i.length);new r.GLTFLoader().setPath(c).load(l,function(r){console.log(r),e.parseGLTFObjects(r.scene,n,0,a),e.setCamera(t),o!=null&&typeof o==`function`&&o()})}},ln=/^[og]\s*(.+)?/,un=/^mtllib /,dn=/^usemtl /,fn=/^usemap /,pn=new e.Vector3,mn=new e.Vector3,hn=new e.Vector3,gn=new e.Vector3,X=new e.Vector3;function _n(){let e={objects:[],object:{},vertices:[],normals:[],colors:[],uvs:[],materials:{},materialLibraries:[],startObject:function(e,t){if(this.object&&this.object.fromDeclaration===!1){this.object.name=e,this.object.fromDeclaration=t!==!1;return}let n=this.object&&typeof this.object.currentMaterial==`function`?this.object.currentMaterial():void 0;if(this.object&&typeof this.object._finalize==`function`&&this.object._finalize(!0),this.object={name:e||``,fromDeclaration:t!==!1,geometry:{vertices:[],normals:[],colors:[],uvs:[],hasUVIndices:!1},materials:[],smooth:!0,startMaterial:function(e,t){let n=this._finalize(!1);n&&(n.inherited||n.groupCount<=0)&&this.materials.splice(n.index,1);let r={index:this.materials.length,name:e||``,mtllib:Array.isArray(t)&&t.length>0?t[t.length-1]:``,smooth:n===void 0?this.smooth:n.smooth,groupStart:n===void 0?0:n.groupEnd,groupEnd:-1,groupCount:-1,inherited:!1,clone:function(e){let t={index:typeof e==`number`?e:this.index,name:this.name,mtllib:this.mtllib,smooth:this.smooth,groupStart:0,groupEnd:-1,groupCount:-1,inherited:!1};return t.clone=this.clone.bind(t),t}};return this.materials.push(r),r},currentMaterial:function(){if(this.materials.length>0)return this.materials[this.materials.length-1]},_finalize:function(e){let t=this.currentMaterial();if(t&&t.groupEnd===-1&&(t.groupEnd=this.geometry.vertices.length/3,t.groupCount=t.groupEnd-t.groupStart,t.inherited=!1),e&&this.materials.length>1)for(let e=this.materials.length-1;e>=0;e--)this.materials[e].groupCount<=0&&this.materials.splice(e,1);return e&&this.materials.length===0&&this.materials.push({name:``,smooth:this.smooth}),t}},n&&n.name&&typeof n.clone==`function`){let e=n.clone(0);e.inherited=!0,this.object.materials.push(e)}this.objects.push(this.object)},finalize:function(){this.object&&typeof this.object._finalize==`function`&&this.object._finalize(!0)},parseVertexIndex:function(e,t){let n=parseInt(e,10);return(n>=0?n-1:n+t/3)*3},parseNormalIndex:function(e,t){let n=parseInt(e,10);return(n>=0?n-1:n+t/3)*3},parseUVIndex:function(e,t){let n=parseInt(e,10);return(n>=0?n-1:n+t/2)*2},addVertex:function(e,t,n){let r=this.vertices,i=this.object.geometry.vertices;i.push(r[e+0],r[e+1],r[e+2]),i.push(r[t+0],r[t+1],r[t+2]),i.push(r[n+0],r[n+1],r[n+2])},addVertexPoint:function(e){let t=this.vertices;this.object.geometry.vertices.push(t[e+0],t[e+1],t[e+2])},addVertexLine:function(e){let t=this.vertices;this.object.geometry.vertices.push(t[e+0],t[e+1],t[e+2])},addNormal:function(e,t,n){let r=this.normals,i=this.object.geometry.normals;i.push(r[e+0],r[e+1],r[e+2]),i.push(r[t+0],r[t+1],r[t+2]),i.push(r[n+0],r[n+1],r[n+2])},addFaceNormal:function(e,t,n){let r=this.vertices,i=this.object.geometry.normals;pn.fromArray(r,e),mn.fromArray(r,t),hn.fromArray(r,n),X.subVectors(hn,mn),gn.subVectors(pn,mn),X.cross(gn),X.normalize(),i.push(X.x,X.y,X.z),i.push(X.x,X.y,X.z),i.push(X.x,X.y,X.z)},addColor:function(e,t,n){let r=this.colors,i=this.object.geometry.colors;r[e]!==void 0&&i.push(r[e+0],r[e+1],r[e+2]),r[t]!==void 0&&i.push(r[t+0],r[t+1],r[t+2]),r[n]!==void 0&&i.push(r[n+0],r[n+1],r[n+2])},addUV:function(e,t,n){let r=this.uvs,i=this.object.geometry.uvs;i.push(r[e+0],r[e+1]),i.push(r[t+0],r[t+1]),i.push(r[n+0],r[n+1])},addDefaultUV:function(){let e=this.object.geometry.uvs;e.push(0,0),e.push(0,0),e.push(0,0)},addUVLine:function(e){let t=this.uvs;this.object.geometry.uvs.push(t[e+0],t[e+1])},addFace:function(e,t,n,r,i,a,o,s,c){let l=this.vertices.length,u=this.parseVertexIndex(e,l),d=this.parseVertexIndex(t,l),f=this.parseVertexIndex(n,l);if(this.addVertex(u,d,f),this.addColor(u,d,f),o!==void 0&&o!==``){let e=this.normals.length;u=this.parseNormalIndex(o,e),d=this.parseNormalIndex(s,e),f=this.parseNormalIndex(c,e),this.addNormal(u,d,f)}else this.addFaceNormal(u,d,f);if(r!==void 0&&r!==``){let e=this.uvs.length;u=this.parseUVIndex(r,e),d=this.parseUVIndex(i,e),f=this.parseUVIndex(a,e),this.addUV(u,d,f),this.object.geometry.hasUVIndices=!0}else this.addDefaultUV()},addPointGeometry:function(e){this.object.geometry.type=`Points`;let t=this.vertices.length;for(let n=0,r=e.length;n<r;n++){let r=this.parseVertexIndex(e[n],t);this.addVertexPoint(r),this.addColor(r)}},addLineGeometry:function(e,t){this.object.geometry.type=`Line`;let n=this.vertices.length,r=this.uvs.length;for(let t=0,r=e.length;t<r;t++)this.addVertexLine(this.parseVertexIndex(e[t],n));for(let e=0,n=t.length;e<n;e++)this.addUVLine(this.parseUVIndex(t[e],r))}};return e.startObject(``,!1),e}var vn=class extends e.Loader{constructor(e){super(e),this.materials=null}load(t,n,r,i){let a=this,o=new e.FileLoader(this.manager);o.setPath(this.path),o.setRequestHeader(this.requestHeader),o.setWithCredentials(this.withCredentials),o.load(t,function(e){try{n(a.parse(e))}catch(e){i?i(e):console.error(e),a.manager.itemError(t)}},r,i)}setMaterials(e){return this.materials=e,this}parse(t){let n=new _n;t.indexOf(`\r
|
|
485
485
|
`)!==-1&&(t=t.replace(/\r\n/g,`
|
|
486
486
|
`)),t.indexOf(`\\
|
|
487
487
|
`)!==-1&&(t=t.replace(/\\\n/g,``));let r=t.split(`
|
|
488
|
-
`),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=pn.exec(i))!==null){let e=(` `+s[0].substr(1).trim()).substr(1);n.startObject(e)}else if(hn.test(i))n.object.startMaterial(i.substring(7).trim(),n.materialLibraries);else if(mn.test(i))n.materialLibraries.push(i.substring(7).trim());else if(gn.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}},Cn=e.FileLoader,wn=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])}},Tn=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]}},En=function(e,t,n){let r=new Cn,i=new Be;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))}},Dn=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]));wn(e),a(e[0])}else{let t=r[0][1],n=Tn(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)}}}},On=function(){let e=0;this.crossOrigin=`Anonymous`;let t=new Be,n=new Cn;n.crossOrigin=`Anonymous`;let r=[],i={},a=(e,t,n,r,i)=>{let a=e.length,o=new Dn(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 En(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)},kn=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))}},An=function(){V.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}};An.prototype=Object.create(V.prototype);var jn=function(t){let n=t;this.toBeDownloaded=0,this.progressMap={};let r=!1,i=!1,a=new On;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=or.defaultMaterialColor,d=or.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=!1;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 An:new Qe,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.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 Ve;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 Ze,f=new e.PointsMaterial({alphaTest:.05,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.vertexColors=!1);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=or.defaultMaterialColor,a=or.defaultOpacity,o=new kn;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=or.defaultMaterialColor,a=or.defaultOpacity,o=new Sn;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=or.defaultMaterialColor,l=or.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 kn;else if(f==`OBJ`){_=new Sn,_.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 ot),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 Ee;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 fn().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)})}},Mn=0,Nn=function(){return`sc`+Mn++},Pn=function(){return{Duration:`6 secs`,OriginalDuration:`-`,TimeStamps:{}}},Fn=6e3,In=function(t,n){let r=t,i,a,o=new jn(this),s,c={},l=0,u={},d=0,f=new e.Scene,p=new e.Scene,m=new Wt(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=Pn(),S=new e.Vector2,C=[];this.forcePickableObjectsUpdate=!1,this.uuid=Nn();let w=new St(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,.7*Math.PI),f.add(this.directionalLight),_=new ct(this.camera,n.domElement,n,this),_.setDirectionalLight(this.directionalLight),_.resetView(),s=new Ct(this),this.loadView=e=>{let t=new st;return t.setFromObject(e),_.setCurrentCameraSettings(t),!0},this.setupMultipleViews=(e,t)=>{for(let[e,n]of Object.entries(t)){let t=new st;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 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 mt(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=Pn()},this.resetDuration=()=>{this.setDuration(Fn)};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 dn(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 Je(r,i);return h.add(a),a},this.addTemporaryLines=(t,n)=>{let r=new he(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)})}},Ln=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 In(C,i):new In(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},Rn=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}},Z=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 Rn(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}},Q=class e{littleEndian=!1;dim_info=0;dims=[];intent_p1=0;intent_p2=0;intent_p3=0;intent_code=0;datatypeCode=0;numBitsPerVoxel=0;slice_start=0;slice_end=0;slice_code=0;pixDims=[];vox_offset=0;scl_slope=1;scl_inter=0;xyzt_units=0;cal_max=0;cal_min=0;slice_duration=0;toffset=0;description=``;aux_file=``;intent_name=``;qform_code=0;sform_code=0;quatern_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=Z.getIntAt(n,0,this.littleEndian),i,a,o,s;if(r!==e.MAGIC_COOKIE&&(this.littleEndian=!0,r=Z.getIntAt(n,0,this.littleEndian)),r!==e.MAGIC_COOKIE)throw Error(`This does not appear to be a NIFTI file!`);for(this.dim_info=Z.getByteAt(n,39),i=0;i<8;i+=1)s=40+i*2,this.dims[i]=Z.getShortAt(n,s,this.littleEndian);for(this.intent_p1=Z.getFloatAt(n,56,this.littleEndian),this.intent_p2=Z.getFloatAt(n,60,this.littleEndian),this.intent_p3=Z.getFloatAt(n,64,this.littleEndian),this.intent_code=Z.getShortAt(n,68,this.littleEndian),this.datatypeCode=Z.getShortAt(n,70,this.littleEndian),this.numBitsPerVoxel=Z.getShortAt(n,72,this.littleEndian),this.slice_start=Z.getShortAt(n,74,this.littleEndian),i=0;i<8;i+=1)s=76+i*4,this.pixDims[i]=Z.getFloatAt(n,s,this.littleEndian);if(this.vox_offset=Z.getFloatAt(n,108,this.littleEndian),this.scl_slope=Z.getFloatAt(n,112,this.littleEndian),this.scl_inter=Z.getFloatAt(n,116,this.littleEndian),this.slice_end=Z.getShortAt(n,120,this.littleEndian),this.slice_code=Z.getByteAt(n,122),this.xyzt_units=Z.getByteAt(n,123),this.cal_max=Z.getFloatAt(n,124,this.littleEndian),this.cal_min=Z.getFloatAt(n,128,this.littleEndian),this.slice_duration=Z.getFloatAt(n,132,this.littleEndian),this.toffset=Z.getFloatAt(n,136,this.littleEndian),this.description=Z.getStringAt(n,148,228),this.aux_file=Z.getStringAt(n,228,252),this.qform_code=Z.getShortAt(n,252,this.littleEndian),this.sform_code=Z.getShortAt(n,254,this.littleEndian),this.quatern_b=Z.getFloatAt(n,256,this.littleEndian),this.quatern_c=Z.getFloatAt(n,260,this.littleEndian),this.quatern_d=Z.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=Z.getFloatAt(n,268,this.littleEndian),this.qoffset_y=Z.getFloatAt(n,272,this.littleEndian),this.qoffset_z=Z.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]=Z.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=Z.getStringAt(n,328,344),this.magic=Z.getStringAt(n,344,348),this.isHDR=this.magic===String.fromCharCode.apply(null,e.MAGIC_NUMBER2),n.byteLength>e.MAGIC_COOKIE){this.extensionFlag[0]=Z.getByteAt(n,348),this.extensionFlag[1]=Z.getByteAt(n,349),this.extensionFlag[2]=Z.getByteAt(n,350),this.extensionFlag[3]=Z.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=Z.getExtensionsAt(n,this.getExtensionLocation(),this.littleEndian,this.vox_offset),this.extensionSize=this.extensions[0].esize,this.extensionCode=this.extensions[0].ecode)}}toFormattedString(){var t=Z.formatNumber,n=``;return n+=`Dim Info = `+this.dim_info+`
|
|
488
|
+
`),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=ln.exec(i))!==null){let e=(` `+s[0].substr(1).trim()).substr(1);n.startObject(e)}else if(dn.test(i))n.object.startMaterial(i.substring(7).trim(),n.materialLibraries);else if(un.test(i))n.materialLibraries.push(i.substring(7).trim());else if(fn.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}},yn=e.FileLoader,bn=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])}},xn=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]}},Sn=function(e,t,n){let r=new yn,i=new Re;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))}},Cn=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]));bn(e),a(e[0])}else{let t=r[0][1],n=xn(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)}}}},wn=function(){let e=0;this.crossOrigin=`Anonymous`;let t=new Re,n=new yn;n.crossOrigin=`Anonymous`;let r=[],i={},a=(e,t,n,r,i)=>{let a=e.length,o=new Cn(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 Sn(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)},Tn=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))}},En=function(){V.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}};En.prototype=Object.create(V.prototype);var Dn=function(t){let n=t;this.toBeDownloaded=0,this.progressMap={};let r=!1,i=!1,a=new wn;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=nr.defaultMaterialColor,d=nr.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=!1;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 En:new Xe,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.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 ze;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 Ye,f=new e.PointsMaterial({alphaTest:.05,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.vertexColors=!1);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=nr.defaultMaterialColor,a=nr.defaultOpacity,o=new Tn;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=nr.defaultMaterialColor,a=nr.defaultOpacity,o=new vn;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=nr.defaultMaterialColor,l=nr.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 Tn;else if(f==`OBJ`){_=new vn,_.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 it),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 we;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 cn().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)})}},On=0,kn=function(){return`sc`+On++},An=function(){return{Duration:`6 secs`,OriginalDuration:`-`,TimeStamps:{}}},jn=6e3,Mn=function(t,n){let r=t,i,a,o=new Dn(this),s,c={},l=0,u={},d=0,f=new e.Scene,p=new e.Scene,m=new Bt(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=An(),S=new e.Vector2,C=[];this.forcePickableObjectsUpdate=!1,this.uuid=kn();let w=new vt(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,.7*Math.PI),f.add(this.directionalLight),_=new ot(this.camera,n.domElement,n,this),_.setDirectionalLight(this.directionalLight),_.resetView(),s=new yt(this),this.loadView=e=>{let t=new at;return t.setFromObject(e),_.setCurrentCameraSettings(t),!0},this.setupMultipleViews=(e,t)=>{for(let[e,n]of Object.entries(t)){let t=new at;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 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 ft(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=An()},this.resetDuration=()=>{this.setDuration(jn)};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 sn(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 Ke(r,i);return h.add(a),a},this.addTemporaryLines=(t,n)=>{let r=new he(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)})}},Nn=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 Mn(C,i):new Mn(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},Pn=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}},Z=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 Pn(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}},Q=class e{littleEndian=!1;dim_info=0;dims=[];intent_p1=0;intent_p2=0;intent_p3=0;intent_code=0;datatypeCode=0;numBitsPerVoxel=0;slice_start=0;slice_end=0;slice_code=0;pixDims=[];vox_offset=0;scl_slope=1;scl_inter=0;xyzt_units=0;cal_max=0;cal_min=0;slice_duration=0;toffset=0;description=``;aux_file=``;intent_name=``;qform_code=0;sform_code=0;quatern_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=Z.getIntAt(n,0,this.littleEndian),i,a,o,s;if(r!==e.MAGIC_COOKIE&&(this.littleEndian=!0,r=Z.getIntAt(n,0,this.littleEndian)),r!==e.MAGIC_COOKIE)throw Error(`This does not appear to be a NIFTI file!`);for(this.dim_info=Z.getByteAt(n,39),i=0;i<8;i+=1)s=40+i*2,this.dims[i]=Z.getShortAt(n,s,this.littleEndian);for(this.intent_p1=Z.getFloatAt(n,56,this.littleEndian),this.intent_p2=Z.getFloatAt(n,60,this.littleEndian),this.intent_p3=Z.getFloatAt(n,64,this.littleEndian),this.intent_code=Z.getShortAt(n,68,this.littleEndian),this.datatypeCode=Z.getShortAt(n,70,this.littleEndian),this.numBitsPerVoxel=Z.getShortAt(n,72,this.littleEndian),this.slice_start=Z.getShortAt(n,74,this.littleEndian),i=0;i<8;i+=1)s=76+i*4,this.pixDims[i]=Z.getFloatAt(n,s,this.littleEndian);if(this.vox_offset=Z.getFloatAt(n,108,this.littleEndian),this.scl_slope=Z.getFloatAt(n,112,this.littleEndian),this.scl_inter=Z.getFloatAt(n,116,this.littleEndian),this.slice_end=Z.getShortAt(n,120,this.littleEndian),this.slice_code=Z.getByteAt(n,122),this.xyzt_units=Z.getByteAt(n,123),this.cal_max=Z.getFloatAt(n,124,this.littleEndian),this.cal_min=Z.getFloatAt(n,128,this.littleEndian),this.slice_duration=Z.getFloatAt(n,132,this.littleEndian),this.toffset=Z.getFloatAt(n,136,this.littleEndian),this.description=Z.getStringAt(n,148,228),this.aux_file=Z.getStringAt(n,228,252),this.qform_code=Z.getShortAt(n,252,this.littleEndian),this.sform_code=Z.getShortAt(n,254,this.littleEndian),this.quatern_b=Z.getFloatAt(n,256,this.littleEndian),this.quatern_c=Z.getFloatAt(n,260,this.littleEndian),this.quatern_d=Z.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=Z.getFloatAt(n,268,this.littleEndian),this.qoffset_y=Z.getFloatAt(n,272,this.littleEndian),this.qoffset_z=Z.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]=Z.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=Z.getStringAt(n,328,344),this.magic=Z.getStringAt(n,344,348),this.isHDR=this.magic===String.fromCharCode.apply(null,e.MAGIC_NUMBER2),n.byteLength>e.MAGIC_COOKIE){this.extensionFlag[0]=Z.getByteAt(n,348),this.extensionFlag[1]=Z.getByteAt(n,349),this.extensionFlag[2]=Z.getByteAt(n,350),this.extensionFlag[3]=Z.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=Z.getExtensionsAt(n,this.getExtensionLocation(),this.littleEndian,this.vox_offset),this.extensionSize=this.extensions[0].esize,this.extensionCode=this.extensions[0].ecode)}}toFormattedString(){var t=Z.formatNumber,n=``;return n+=`Dim Info = `+this.dim_info+`
|
|
489
489
|
`,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]+`
|
|
490
490
|
`,n+=`Intent Parameters (1-3): `+this.intent_p1+`, `+this.intent_p2+`, `+this.intent_p3+`
|
|
491
491
|
`,n+=`Intent Code = `+this.intent_code+`
|
|
@@ -538,5 +538,5 @@ void main() {
|
|
|
538
538
|
`,t+=`Intent Code = `+this.intent_code+`
|
|
539
539
|
`,t+=`Intent Name: "`+this.intent_name+`"
|
|
540
540
|
`,t+=`Dim Info = `+this.dim_info+`
|
|
541
|
-
`,t}getExtensionLocation=function(){return e.MAGIC_COOKIE+4};getExtensionSize=Q.prototype.getExtensionSize;getExtensionCode=Q.prototype.getExtensionCode;addExtension=Q.prototype.addExtension;removeExtension=Q.prototype.removeExtension;getDatatypeCodeString=Q.prototype.getDatatypeCodeString;getTransformCodeString=Q.prototype.getTransformCodeString;getUnitsCodeString=Q.prototype.getUnitsCodeString;getQformMat=Q.prototype.getQformMat;convertNiftiQFormToNiftiSForm=Q.prototype.convertNiftiQFormToNiftiSForm;convertNiftiSFormToNEMA=Q.prototype.convertNiftiSFormToNEMA;nifti_mat33_mul=Q.prototype.nifti_mat33_mul;nifti_mat33_determ=Q.prototype.nifti_mat33_determ;toArrayBuffer(e=!1){let t=544;if(e)for(let e of this.extensions)t+=e.esize;let n=new Uint8Array(t),r=new DataView(n.buffer);r.setInt32(0,540,this.littleEndian),n.set(new TextEncoder().encode(this.magic),4),r.setInt16(12,this.datatypeCode,this.littleEndian),r.setInt16(14,this.numBitsPerVoxel,this.littleEndian);for(let e=0;e<8;e++)r.setBigInt64(16+8*e,BigInt(this.dims[e]),this.littleEndian);r.setFloat64(80,this.intent_p1,this.littleEndian),r.setFloat64(88,this.intent_p2,this.littleEndian),r.setFloat64(96,this.intent_p3,this.littleEndian);for(let e=0;e<8;e++)r.setFloat64(104+8*e,this.pixDims[e],this.littleEndian);r.setBigInt64(168,BigInt(this.vox_offset),this.littleEndian),r.setFloat64(176,this.scl_slope,this.littleEndian),r.setFloat64(184,this.scl_inter,this.littleEndian),r.setFloat64(192,this.cal_max,this.littleEndian),r.setFloat64(200,this.cal_min,this.littleEndian),r.setFloat64(208,this.slice_duration,this.littleEndian),r.setFloat64(216,this.toffset,this.littleEndian),r.setBigInt64(224,BigInt(this.slice_start),this.littleEndian),r.setBigInt64(232,BigInt(this.slice_end),this.littleEndian),n.set(new TextEncoder().encode(this.description),240),n.set(new TextEncoder().encode(this.aux_file),320),r.setInt32(344,this.qform_code,this.littleEndian),r.setInt32(348,this.sform_code,this.littleEndian),r.setFloat64(352,this.quatern_b,this.littleEndian),r.setFloat64(360,this.quatern_c,this.littleEndian),r.setFloat64(368,this.quatern_d,this.littleEndian),r.setFloat64(376,this.qoffset_x,this.littleEndian),r.setFloat64(384,this.qoffset_y,this.littleEndian),r.setFloat64(392,this.qoffset_z,this.littleEndian);let i=this.affine.flat();for(let e=0;e<12;e++)r.setFloat64(400+8*e,i[e],this.littleEndian);if(r.setInt32(496,this.slice_code,this.littleEndian),r.setInt32(500,this.xyzt_units,this.littleEndian),r.setInt32(504,this.intent_code,this.littleEndian),n.set(new TextEncoder().encode(this.intent_name),508),r.setUint8(524,this.dim_info),e){n.set(Uint8Array.from([1,0,0,0]),540);let e=this.getExtensionLocation();for(let t of this.extensions)r.setInt32(e,t.esize,t.littleEndian),r.setInt32(e+4,t.ecode,t.littleEndian),n.set(new Uint8Array(t.edata),e+8),e+=t.esize}else n.set(new Uint8Array(4).fill(0),540);return n.buffer}};function
|
|
541
|
+
`,t}getExtensionLocation=function(){return e.MAGIC_COOKIE+4};getExtensionSize=Q.prototype.getExtensionSize;getExtensionCode=Q.prototype.getExtensionCode;addExtension=Q.prototype.addExtension;removeExtension=Q.prototype.removeExtension;getDatatypeCodeString=Q.prototype.getDatatypeCodeString;getTransformCodeString=Q.prototype.getTransformCodeString;getUnitsCodeString=Q.prototype.getUnitsCodeString;getQformMat=Q.prototype.getQformMat;convertNiftiQFormToNiftiSForm=Q.prototype.convertNiftiQFormToNiftiSForm;convertNiftiSFormToNEMA=Q.prototype.convertNiftiSFormToNEMA;nifti_mat33_mul=Q.prototype.nifti_mat33_mul;nifti_mat33_determ=Q.prototype.nifti_mat33_determ;toArrayBuffer(e=!1){let t=544;if(e)for(let e of this.extensions)t+=e.esize;let n=new Uint8Array(t),r=new DataView(n.buffer);r.setInt32(0,540,this.littleEndian),n.set(new TextEncoder().encode(this.magic),4),r.setInt16(12,this.datatypeCode,this.littleEndian),r.setInt16(14,this.numBitsPerVoxel,this.littleEndian);for(let e=0;e<8;e++)r.setBigInt64(16+8*e,BigInt(this.dims[e]),this.littleEndian);r.setFloat64(80,this.intent_p1,this.littleEndian),r.setFloat64(88,this.intent_p2,this.littleEndian),r.setFloat64(96,this.intent_p3,this.littleEndian);for(let e=0;e<8;e++)r.setFloat64(104+8*e,this.pixDims[e],this.littleEndian);r.setBigInt64(168,BigInt(this.vox_offset),this.littleEndian),r.setFloat64(176,this.scl_slope,this.littleEndian),r.setFloat64(184,this.scl_inter,this.littleEndian),r.setFloat64(192,this.cal_max,this.littleEndian),r.setFloat64(200,this.cal_min,this.littleEndian),r.setFloat64(208,this.slice_duration,this.littleEndian),r.setFloat64(216,this.toffset,this.littleEndian),r.setBigInt64(224,BigInt(this.slice_start),this.littleEndian),r.setBigInt64(232,BigInt(this.slice_end),this.littleEndian),n.set(new TextEncoder().encode(this.description),240),n.set(new TextEncoder().encode(this.aux_file),320),r.setInt32(344,this.qform_code,this.littleEndian),r.setInt32(348,this.sform_code,this.littleEndian),r.setFloat64(352,this.quatern_b,this.littleEndian),r.setFloat64(360,this.quatern_c,this.littleEndian),r.setFloat64(368,this.quatern_d,this.littleEndian),r.setFloat64(376,this.qoffset_x,this.littleEndian),r.setFloat64(384,this.qoffset_y,this.littleEndian),r.setFloat64(392,this.qoffset_z,this.littleEndian);let i=this.affine.flat();for(let e=0;e<12;e++)r.setFloat64(400+8*e,i[e],this.littleEndian);if(r.setInt32(496,this.slice_code,this.littleEndian),r.setInt32(500,this.xyzt_units,this.littleEndian),r.setInt32(504,this.intent_code,this.littleEndian),n.set(new TextEncoder().encode(this.intent_name),508),r.setUint8(524,this.dim_info),e){n.set(Uint8Array.from([1,0,0,0]),540);let e=this.getExtensionLocation();for(let t of this.extensions)r.setInt32(e,t.esize,t.littleEndian),r.setInt32(e+4,t.ecode,t.littleEndian),n.set(new Uint8Array(t.edata),e+8),e+=t.esize}else n.set(new Uint8Array(4).fill(0),540);return n.buffer}};function Fn(e,t=!1){var n,r,i,a;return e.byteLength<Q.STANDARD_HEADER_SIZE?!1:(n=new DataView(e),n&&(r=n.getUint8(Q.MAGIC_NUMBER_LOCATION)),i=n.getUint8(Q.MAGIC_NUMBER_LOCATION+1),a=n.getUint8(Q.MAGIC_NUMBER_LOCATION+2),t&&r===Q.MAGIC_NUMBER2[0]&&i===Q.MAGIC_NUMBER2[1]&&a===Q.MAGIC_NUMBER2[2]?!0:r===Q.MAGIC_NUMBER[0]&&i===Q.MAGIC_NUMBER[1]&&a===Q.MAGIC_NUMBER[2])}function In(e,t=!1){var n,r,i,a;return e.byteLength<Q.STANDARD_HEADER_SIZE?!1:(n=new DataView(e),r=n.getUint8($.MAGIC_NUMBER_LOCATION),i=n.getUint8($.MAGIC_NUMBER_LOCATION+1),a=n.getUint8($.MAGIC_NUMBER_LOCATION+2),t&&r===$.MAGIC_NUMBER2[0]&&i===$.MAGIC_NUMBER2[1]&&a===$.MAGIC_NUMBER2[2]?!0:r===$.MAGIC_NUMBER[0]&&i===$.MAGIC_NUMBER[1]&&a===$.MAGIC_NUMBER[2])}function Ln(e,t=!1){return Fn(e,t)||In(e,t)}function Rn(e){var t,n,r;return!!(e&&(t=new DataView(e),n=t.getUint8(0),r=t.getUint8(1),n===Z.GUNZIP_MAGIC_COOKIE1||r===Z.GUNZIP_MAGIC_COOKIE2))}function zn(e){return(0,i.decompressSync)(new Uint8Array(e)).buffer}function Bn(e,t=!1){let n=null;if(Rn(e)&&(e=zn(e)),Fn(e,t)?n=new Q:In(e,t)&&(n=new $),n)n.readHeader(e);else throw Error(`That file does not appear to be NIFTI!`);return n}function Vn(e,t){var n=e.vox_offset,r=1,i=1;e.dims[4]&&(r=e.dims[4]),e.dims[5]&&(i=e.dims[5]);var a=e.dims[1]*e.dims[2]*e.dims[3]*r*i*(e.numBitsPerVoxel/8);return t.slice(n,n+a)}var Hn={id:`mesh-location-orientation`,locations:[{identifier:1,label:`original`,orientation:[1,0,0,0,1,0,0,0,1],position:[0,0,0],scale:[1,1,1],flipY:!1,flipZ:!1,reference_point:`corner`}],settings:{slides:[{direction:`x`,value:.5},{direction:`y`,value:.5},{direction:`z`,value:.5}]},type:`slides`},Un={hideBlackPixel:!0,keepScalePosition:!0,filterByValue:!0,timeEnabled:!1};function Wn(e){let t=Rn(e)?zn(e):e;if(Ln(t)){let e=Bn(t);return{niftiHeader:e,niftiImage:Vn(e,t)}}return t=void 0,{niftiHeader:void 0,niftiImage:void 0}}function Gn(e,t){let n;switch(e.datatypeCode){case Q.TYPE_UINT8:n=new Uint8Array(t);break;case Q.TYPE_INT8:n=new Int8Array(t);break;case Q.TYPE_UINT16:n=new Uint16Array(t);break;case Q.TYPE_INT16:n=new Int16Array(t);break;case Q.TYPE_UINT32:n=new Uint32Array(t);break;case Q.TYPE_INT32:n=new Int32Array(t);break;case Q.TYPE_FLOAT32:n=new Float32Array(t);break;case Q.TYPE_FLOAT64:n=new Float64Array(t);break;default:throw Error(`Unsupported NIfTI data type`)}let r=1/0,i=-1/0,a=n.length;for(let e=0;e<a;e++){let t=n[e];t<r&&(r=t),t>i&&(i=t)}let o=new Uint8Array(a),s=i-r;for(let e=0;e<a;e++){let t=(n[e]-r)/s;t=Math.max(0,Math.min(1,t)),o[e]=Math.round(t*255)}return o}function Kn(e,t,n,r){if(e?.dims&&e.dims[0]===3){let i=e.dims[1],a=e.dims[2],o=e.dims[3],s=!1;(e.intent_code===1007||e.intent_code===1008||e.datatypeCode===128||e.datatypeCode===2304)&&(s=!0);let c=Gn(e,t),l;if(n&&r){let e=n.dims[1],t=n.dims[2],s=n.dims[3];e===i&&t===a&&s===o&&(l=Gn(n,r))}return{data:c,maskData:l,width:i,height:a,depth:o,isRGB:s}}}function qn(e,t){if(e?.affine&&e.dims){let n=e.affine,r=[0,0,0],i=[0,0,0];return r[0]=n[0][3],r[1]=n[1][3],r[2]=n[2][3],i[0]=n[0][0]*e.dims[1],i[1]=n[1][1]*e.dims[2],i[2]=n[2][2]*e.dims[3],t.keepScalePosition&&(i[0]=Math.abs(i[0]),i[1]=Math.abs(i[1]),i[2]=Math.abs(i[2])),{position:r,scale:i}}return{position:void 0,scale:void 0}}function Jn(e,t){return e&&e.sform_code?qn(e,t):{position:void 0,scale:void 0}}function Yn(t,n,r,i,a){let o=new e.DataArrayTexture(t,n,r,i);return o.anisotropy=4,a||(o.format=e.RedFormat),o.minFilter=e.NearestFilter,o.magFilter=e.NearestFilter,o.needsUpdate=!0,o}function Xn(e){if(e?.data){let t=new Qe;return t.impl=new Yn(e.data,e.width,e.height,e.depth),t.size={width:e.width,height:e.height,depth:e.depth},t.isLoading=!1,t}}function Zn(e,t,n,r,i){if(t?.data){let a={...Un};i&&Object.assign(a,i);let o=new it,s=Xn(t);if(s){o.groupName=`Images`,o.morph.renderOrder=1,o.texture=s;let i=structuredClone(Hn);if(Object.assign(i,r),n&&e){let{position:t,scale:n}=Jn(e,a);t&&n&&(i.locations[0].scale=n,i.locations[0].position=t)}if(o.initialise(i,void 0),o.showEdges(10066329),t.maskData&&!a.timeEnabled){let e=Yn(t.maskData,t.width,t.height,t.depth,!1);o.setMask(e)}return o.setNumberOfChannels(t.isRGB?3:1),o}}}async function Qn(e,t){let n,r;if(t){let e=Wn(await(await fetch(t)).arrayBuffer());n=e.niftiHeader,r=e.niftiImage}let{niftiHeader:i,niftiImage:a}=Wn(await(await fetch(e)).arrayBuffer());return{sources:Kn(i,a,n,r),niftiHeader:i}}async function $n(e,t,n,r,i){let a=!1,o,s=e;if(Array.isArray(e)&&(s=e[0],e.length>1&&i?.timeEnabled&&(a=!0)),typeof s==`string`){let{sources:e,niftiHeader:a}=await Qn(s,n,i);o=Zn(a,e,t,r,i)}if(a&&o){for(let t=1;t<e.length;t++){let r=await er(e[t],n,i);o.addTextureArray(r)}o.timeEnabled=!0}return o}async function er(e,t,n){let{sources:r}=await Qn(e,t,n);return Xn(r)}var tr=p.version,nr=new function(){this.Revision=tr,this.defaultMaterialColor=16777215,this.defaultOpacity=1,this.Geometry=we,this.Glyph=De,this.Glyphset=ze,this.Pointset=Ye,this.Label=Ee,this.Lines=Xe,this.TextureSlides=it,this.TextureArray=Qe,this.Renderer=Nn,this.Scene=Mn,this.Viewport=at,this.CameraControls=ot,this.SmoothCameraTransition=st,this.RayCaster=lt,this.CameraAutoTumble=ut,this.StereoEffect=ft,this.loadExternalFile=T,this.loadExternalFiles=E,this.createPrimitivesFromNIFTI=$n,this.createTextureFromNIFTI=er,this.THREE=e};return nr});
|
|
542
542
|
//# sourceMappingURL=zinc.js.map
|