zincjs 2.4.1-beta.6 → 2.4.1-beta.7
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 +3 -3
- package/build/zinc.js.map +1 -1
- package/package.json +1 -1
- package/src/primitives/glyphset.js +14 -2
- package/src/renderer.js +4 -0
- package/src/tsl/glyphTransform.js +22 -1
package/build/zinc.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
(function(e,t){typeof exports==`object`&&typeof module<`u`?module.exports=t(require("three/webgpu"),require("three-spritetext"),require("three/tsl"),require("css-element-queries"),require("three/examples/jsm/exporters/GLTFExporter"),require("three/examples/jsm/loaders/GLTFLoader"),require("fflate")):typeof define==`function`&&define.amd?define([`three/webgpu`,`three-spritetext`,`three/tsl`,`css-element-queries`,`three/examples/jsm/exporters/GLTFExporter`,`three/examples/jsm/loaders/GLTFLoader`,`fflate`],t):(e=typeof globalThis<`u`?globalThis:e||self,e.Zinc=t(e.THREE,e.SpriteText,e.THREE,e.cssElememtQueries,e.GLTFExporter,e.GLTFLoader,e.fflate))})(this,function(e,t,n,r,i,a,o){var s=Object.create,c=Object.defineProperty,l=Object.getOwnPropertyDescriptor,u=Object.getOwnPropertyNames,d=Object.getPrototypeOf,f=Object.prototype.hasOwnProperty,p=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=u(t),a=0,o=i.length,s;a<o;a++)s=i[a],!f.call(e,s)&&s!==n&&c(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=l(t,s))||r.enumerable});return e},m=(e,t,n)=>(n=e==null?{}:s(d(e)),p(t||!e||!e.__esModule||!f.call(e,`default`)?c(n,`default`,{value:e,enumerable:!0}):n,e));e=m(e,1),t=m(t,1);var h={name:`zincjs`,version:`2.4.1-beta.6`,description:`ZincJS (Web-based-Zinc-Visualisation)`,type:`module`,main:`build/zinc.js`,engines:{node:`^24.20.0`},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/`,allowScripts:{"msw@2.14.6":!0},devDependencies:{"@vitest/coverage-v8":`^4.1.11`,"auto-changelog":`^2.4.0`,chai:`^4.1.0`,"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`,webgpu:`^0.4.0`},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`}},g=`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==`,_=new Set,v=e=>{_.add(e)},y=e=>{_.delete(e)},b=()=>{_.forEach(e=>e())},x=t.default.default||t.default,S=1.5,C=16,w=256,T=.1,E=1e3/(2*Math.tan(20*Math.PI/180)),D=new Set,O=!1,k=e=>{let t=Math.round(e*E*S);return Math.min(Math.max(t,C),w)},A=t=>{let n=t.material?.map;n&&(n.generateMipmaps=!1,n.minFilter=e.LinearFilter,n.magFilter=e.LinearFilter,n.anisotropy=1)},j=(e,t,n,r)=>{`_fontFace`in e&&typeof e._genCanvas==`function`?(e._fontFace=t,e._fontSize=n,e._fontWeight=r,e._genCanvas()):(e.fontFace=t,e.fontSize=n,e.fontWeight=r)},M=(e,t=!1)=>{let n=k(e.textHeight);(t||n!==e.fontSize)&&(j(e,e.fontFace,n,e.fontWeight),A(e))},N=e=>{D.forEach(t=>{let n=t.deref();n?e(n):D.delete(t)})},P=()=>{N(e=>M(e,!0)),b()},F=e=>{if(typeof document>`u`||!document.fonts)return;!O&&document.fonts.addEventListener&&(document.fonts.addEventListener(`loadingdone`,P),O=!0);let t=`${e.fontWeight} ${e.fontSize}px ${e.fontFace}`;try{document.fonts.check(t)||document.fonts.load(t).then(()=>{M(e,!0),b()}).catch(()=>{})}catch{}},I=e=>{D.add(new WeakRef(e))},L=e=>{D.forEach(t=>{let n=t.deref();(!n||n===e)&&D.delete(t)})},R=(t,n,r,i,a)=>{let o=r?new x(t,n,r):new x(t,n);j(o,i,k(n),a);let s=o.material;return o.material=new e.SpriteNodeMaterial({map:s.map}),s.map=null,s.dispose(),o.material.sizeAttenuation=!1,A(o),I(o),F(o),o},z=(e,t)=>{`_textHeight`in e?(e._textHeight=t,M(e,!0)):(e.textHeight=t,M(e))},B=e=>{!(e>0)||!isFinite(e)||Math.abs(e/E-1)>T&&(E=e,N(e=>M(e)),b())};function ee(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 te(e){return e.parent&&te(e.parent),e.matrixAutoUpdate&&e.updateMatrix(),e.matrixWorldAutoUpdate!==!1&&(e.parent?e.matrixWorld.multiplyMatrices(e.parent.matrixWorld,e.matrix):e.matrixWorld.copy(e.matrix)),e.matrixWorld}function ne(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),t.applyMatrix4(te(e))}function re(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 ie(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++)re(e[t],t,o,n)}var ae=(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]},oe=new WeakMap,se=function(t,n){if(n&&t&&t.morphAttributes&&t.morphAttributes.color){let r=t.morphAttributes.color,i=n.morphTargetInfluences,a=i.length,o=0,s=0,c=0,l=0,u=0;for(let e=0;e<a&&o<2;e++)i[e]>0&&(o===0?(s=c=e,l=i[e]):(c=e,u=i[e]),o++);let d=0;if(o>=2){let e=l+u;d=e>0?u/e:0}let f=t.getAttribute(`morphColor0`),p=t.getAttribute(`morphColor1`);(!f||!p)&&(f=new e.Float32BufferAttribute(new Float32Array(r[0].array.length),r[0].itemSize),p=new e.Float32BufferAttribute(new Float32Array(r[0].array.length),r[0].itemSize),f.setUsage(e.DynamicDrawUsage),p.setUsage(e.DynamicDrawUsage),t.setAttribute(`morphColor0`,f),t.setAttribute(`morphColor1`,p));let m=r[s],h=r[c];oe.get(f)!==m&&(f.array.set(m.array),f.needsUpdate=!0,oe.set(f,m)),oe.get(p)!==h&&(p.array.set(h.array),p.needsUpdate=!0,oe.set(p,h));let g=n.material&&n.material.userData&&n.material.userData.uniforms&&n.material.userData.uniforms.morphColorMix;g&&(g.value=d)}},ce=e=>{let t=e.clone();return t.colorsNeedUpdate=!0,t.computeBoundingBox(),t.computeBoundingSphere(),e._video&&(t._video=e._video),t};function le(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 ue=(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=le(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=le(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 de(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}}var V=class extends Uint16Array{};function fe(e){let t=e?.index;if(t&&t.array.constructor===Uint16Array){let e=t.array;t.array=new V(e.buffer,e.byteOffset,e.length)}}function pe(e){let t=[];return e.traverse(e=>{let n=e.geometry?.index;if(n&&n.array instanceof V){let e=n.array;n.array=new Uint16Array(e.buffer,e.byteOffset,e.length),t.push([n,e,n.array])}}),()=>{t.forEach(([e,t,n])=>{e.array===n&&(e.array=t)})}}var me=void 0;function he(){if(me)return me;let t=new Image,n=new e.Texture;return n.image=t,t.onload=()=>{n.needsUpdate=!0,b()},t.src=g,t.complete&&t.naturalWidth>0&&(n.needsUpdate=!0),me=n,n}function ge(e,t,n,r,i,a){let o=R(e,t,n,r,a);return o.material.alphaTest=.05,o.material.transparent=!0,o.material.depthWrite=!1,o.material.depthTest=!1,o.center.set(.5,-1.2),o.renderOrder=10001,o}function _e(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 ve(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=n.array;if(a.length<s+c)return!1;if(r)a.copyWithin(s,s+c),a.fill(0,a.length-c),n.needsUpdate=!0;else{let n=new a.constructor(a.length-c);n.set(a.subarray(0,s)),n.set(a.subarray(s+c),s),t.setAttribute(i,new e.BufferAttribute(n,o)),t.getAttribute(i).needsUpdate=!0}return!0};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 ye(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}var be={MeshBasicMaterial:e.MeshBasicNodeMaterial,MeshLambertMaterial:e.MeshLambertNodeMaterial,MeshPhongMaterial:e.MeshPhongNodeMaterial,MeshStandardMaterial:e.MeshStandardNodeMaterial,LineBasicMaterial:e.LineBasicNodeMaterial},xe=t=>{let r=t;r.isNodeMaterial||(r=new(be[t.type]||e.MeshBasicNodeMaterial),r.copy(t));let i=(0,n.uniform)(0);return r.colorNode=(0,n.Fn)(()=>{let e=(0,n.attribute)(`morphColor0`,`vec3`),t=(0,n.attribute)(`morphColor1`,`vec3`),r=(0,n.mix)(e,t,i);return(0,n.vec4)(r.mul(n.materialColor),n.materialOpacity)})(),r.userData.uniforms={...r.userData.uniforms,morphColorMix:i},r},Se=new e.Vector3,Ce=new e.Vector3,we=new e.Matrix4,Te=new e.Ray,Ee=new e.Sphere,De=new e.Vector3,Oe=new e.Vector3,ke=new e.Vector3,Ae=new e.Vector3,je=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++)Se.fromBufferAttribute(n,e-1),Ce.fromBufferAttribute(n,e),r[e]=r[e-1],r[e]+=Se.distanceTo(Ce);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(),Ee.copy(r.boundingSphere),Ee.applyMatrix4(i),Ee.radius+=a,t.ray.intersectsSphere(Ee)===!1)return;we.copy(i).invert(),Te.copy(t.ray).applyMatrix4(we);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(Me(u,d,this,i,s,r,a),Te.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(Me(u,d,this,i,s,a,a+1),Te.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 Me(e,t,n,r,i,a,o){e.fromBufferAttribute(r,a),t.fromBufferAttribute(r,o);var s=n.morphTargetInfluences;if(i&&s){De.set(0,0,0),Oe.set(0,0,0);for(var c=0,l=i.length;c<l;c++){var u=s[c],d=i[c];u!==0&&(ke.fromBufferAttribute(d,a),Ae.fromBufferAttribute(d,o),De.addScaledVector(ke.sub(e),u),Oe.addScaledVector(Ae.sub(t),u))}e.add(De),t.add(Oe)}}je.prototype.isLine=!0;var Ne=new e.Vector3,Pe=new e.Vector3,Fe=class extends je{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)Ne.fromBufferAttribute(n,e),Pe.fromBufferAttribute(n,e+1),r[e]=e===0?0:r[e-1],r[e+1]=r[e]+Ne.distanceTo(Pe);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}};Fe.prototype.isLineSegments=!0;var Ie=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._disposed=!1,this.addLevel=(e,t)=>{if(e){fe(e.geometry);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){fe(e.geometry);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._parent?.requestRender?.()}},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._disposed=!0,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=>{if(this._disposed){n.dispose();return}let r=this._material,i=ce(n,{localTimeEnabled:this._parent.timeEnabled,localMorphColour:this._parent.morphColour,isLines:this._parent.isLines}),a;this._parent.isGeometry?a=new e.Mesh(i,r):this._parent.isLines&&(a=new Fe(i,r)),a.userData=this._parent,a.renderOrder=this._renderOrder,n.dispose(),this.levelLoaded(a,t)}},this.updateMorphColorAttribute=e=>{if(this._material&&this._material.userData&&this._material.userData.uniforms&&this._material.userData.uniforms.morphColorMix){if(e){let e=this.getCurrentMorph();se(e.geometry,e)}else this.levels.forEach(e=>{e.morph&&e.morph.geometry&&se(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(),void 0),(t.transparent||this.levels.some(e=>e.secondaryMesh))&&(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._parent?.requestRender?.())}},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)})}},Le=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`,b);Le.colorSpace=e.SRGBColorSpace;var Re=[.02,.03,1],ze=new e.SpriteMaterial({map:Le,alphaTest:.5,transparent:!0,depthTest:!1,depthWrite:!1,sizeAttenuation:!1}),Be=function(t){Object.getPrototypeOf(this)!==H.prototype&&Object.setPrototypeOf(Be.prototype,H.prototype),H.call(this),this.texture=Le;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(ze),n.center.set(.5,0),this.morph.add(n),this.morph.position.set(0,0,0),this.morph.renderOrder=1e4,n.scale.set(Re[0],Re[1],Re[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),this.parent?.requestRender?.()},n.src=e}else this.setUserSprite()}},this.dispose=()=>{this.morph&&this.morph.clear(),n&&=(n.clear(),void 0),u&&=(L(u),u.material.map.dispose(),u.material.dispose(),void 0)},this.isEnabled=()=>c,this.setNumber=e=>{(!e||l!=e)&&(u&&=(this.morph.remove(u),L(u),u.material.map.dispose(),u.material.dispose(),void 0)),!u&&e&&(u=ge(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()},Ve=0,He=function(){return`pr`+Ve++},H=function(){this.isZincObject=!0,this.geometry=void 0,this.morph=void 0,this.group=new e.Group,this._lod=new Ie(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=He(),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};H.prototype.setDuration=function(e){this.duration=e,this.clipAction&&this.clipAction.setDuration(this.duration)},H.prototype.getDuration=function(){return this.duration},H.prototype.setRegion=function(e){this.region=e},H.prototype.getRegion=function(){return this.region},H.prototype.requestRender=function(){this.region?.getScene?.()?.invalidate?.()},H.prototype.getMorph=function(){return this._lod.getCurrentMorph()||this.morph},H.prototype.getGroup=function(){return this.group},H.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)},H.prototype.checkTransparentMesh=function(){},H.prototype.setMesh=function(t,n,r){this.requestRender(),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.mixer.update(0)))}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.morphColour&&this.initiateMorphColor(),this.boundingBoxUpdateRequired=!0},H.prototype.setIsPickable=function(e){this.isPickable!==e&&(this.isPickable=e,this.region&&(this.region.pickableUpdateRequired=!0))},H.prototype.setAnatomicalId=function(e){this.anatomicalId=e},H.prototype.setName=function(e){this.groupName=e,this._lod.setName(e)},H.prototype.getCurrentTime=function(){if(this.clipAction){let e=this.clipAction.time/this.clipAction._clip.duration;return this.duration*e}return this.inbuildTime},H.prototype.setMorphTime=function(e){this.requestRender();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.hasMorphPositions()&&(this.boundingBoxUpdateRequired=!0),this._lod.updateMorphColorAttribute(!0),this.timeEnabled&&(this.markerUpdateRequired=!0))},H.prototype.isTimeVarying=function(){return!!(this.timeEnabled||this.morphColour)},H.prototype.getVisibility=function(){return this.visible},H.prototype.setVisibility=function(e){this.requestRender(),e!==this.visible&&(this.visible=e,this.group.visible=e,this.region&&(this.region.pickableUpdateRequired=!0))},H.prototype.setAlpha=function(e){this.requestRender();let t=this._lod._material,n=!1;e<1&&(n=!0),t.opacity=e,t.transparent=n,this.checkTransparentMesh()},H.prototype.setFrustumCulled=function(e){this.requestRender(),this._lod.setFrustumCulled(e)},H.prototype.setVertexColors=function(e){this.requestRender(),this._lod.setVertexColors(e)},H.prototype.getColour=function(){if(this._lod._material)return this._lod._material.color},H.prototype.setColour=function(e){this.requestRender(),this._lod.setColour(e)},H.prototype.setGreyScale=function(t){if(this.requestRender(),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},H.prototype.getColourHex=function(){if(!this.morphColour&&this._lod._material&&this._lod._material.color)return this._lod._material.color.getHexString()},H.prototype.setColourHex=function(e){this.requestRender(),this._lod._material.color.setHex(e),this._lod._secondaryMaterial&&this._lod._secondaryMaterial.color.setHex(e)},H.prototype.setEmissiveRGB=function(e){this.requestRender(),this._lod._material&&this._lod._material.emissive&&this._lod._material.emissive.setRGB(...e),this._lod._secondaryMaterial&&this._lod._secondaryMaterial.emissive.setRGB(...e)},H.prototype.setMaterial=function(e){this.requestRender(),this._lod.setMaterial(e)},H.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.distanceToSquared(this._v1),(t==-1||t>r)&&(t=r,e=i)}}return e},H.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},H.prototype.getBoundingBox=function(){if(this.visible){let e=this._lod.getCurrentMorph();if(e&&e.visible)return this.boundingBoxUpdateRequired&&=(ne(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}},H.prototype.dispose=function(){this._lod.dispose(),this.marker&&=(this.marker.dispose(),void 0),this.animationGroup=void 0,this.mixer=void 0,this.morph=void 0,this.group=void 0,this.clipAction=void 0,this.groupName=void 0},H.prototype.markerIsRequired=function(e){return!!(this.visible&&(this.markerMode===`on`||e&&e.displayMarkers&&this.markerMode===`inherited`))};var Ue=new WeakMap;H.prototype.hasMorphPositions=function(){let e=this.getMorph()?.geometry,t=e?.morphAttributes?.position;if(!t||t.length===0)return!1;let n=Ue.get(e);if(n&&n.morphPositions===t)return n.result;let r=e.getAttribute(`position`)?.array,i=!1;for(let e=0;e<t.length&&!i;e++){let n=t[e].array;if(!r||n.length!==r.length)i=!0;else if(n!==r){for(let e=0;e<n.length;e++)if(n[e]!==r[e]){i=!0;break}}}return Ue.set(e,{morphPositions:t,result:i}),i},H.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 t=this.getClosestVertex(!1);t&&(this.marker.setPosition(t.x,t.y,t.z),this.markerUpdateRequired=!1,e=!0)}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&&(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},H.prototype.processMarkerVisual=function(e,t){this.marker&&this.marker.isEnabled()&&this.marker.updateVisual(e,t)},H.prototype.initiateMorphColor=function(){this.morphColour==1&&this._lod.updateMorphColorAttribute(!1)},H.prototype.setRenderOrder=function(e){this.requestRender(),this._lod.setRenderOrder(e)},H.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}}},H.prototype.setMarkerMode=function(e,t){this.requestRender(),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)},H.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.hasMorphPositions()&&(this.boundingBoxUpdateRequired=!0),this.morphColour==1&&this._lod.updateMorphColorAttribute(!0))}this.updateMarker(t,r)},H.prototype.addLOD=function(e,t,n,r,i){this._lod.addLevelFromURL(e,t,n,r,i)},H.prototype.addVertices=function(e){this.requestRender();let t=this.getMorph(),n;if(!t)n=de(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},H.prototype.deleteVertices=function(e){this.requestRender();let t=this.getMorph();return t?.geometry&&this.drawRange>=e&&ve(t.geometry,e,!0)?(--this.drawRange,t.geometry.setDrawRange(0,this.drawRange),t.geometry.computeBoundingBox(),t.geometry.computeBoundingSphere(),this.boundingBoxUpdateRequired=!0,!0):!1},H.prototype.setPosition=function(e,t,n){this.requestRender();let r=this.getGroup();r&&(r.position.set(e,t,n),r.matrixWorldNeedsUpdate=!0,r.updateMatrix(),r.updateWorldMatrix(!0,!0),this.boundingBoxUpdateRequired=!0)},H.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))},H.prototype.setScaleAll=function(e){this.requestRender();let t=this.getGroup();t&&(t.scale.set(e,e,e),t.updateMatrix(),this.boundingBoxUpdateRequired=!0)};var We=(t,n,r)=>{let i=ce(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=!1,o=xe(o));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)},Ge=function(){H.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=We(e,t,n);this.videoHandler=r.geometry._video,this.setMesh(r,n.localTimeEnabled,n.localMorphColour)},this.checkTransparentMesh=function(){this._lod.checkTransparentMesh()},this.setWireframe=e=>{this.requestRender(),this.morph.material.wireframe=e},this.editVertices=function(e,t){if(this.requestRender(),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)}};Ge.prototype=Object.create(H.prototype);var Ke=function(e,t){let n=e,r,i=1,a=500,o=.012;r=R(n,o,t?t.getStyle():void 0,`Asap`,a),r.center.x=-.05,r.center.y=0;let s=()=>{A(r)};this.getPosition=()=>r?[r.position.x,r.position.y,r.position.z]:[0,0,0],this.setPosition=(e,t,n)=>{r&&r.position.set(e,t,n)},this.setColour=e=>{if(e){let t=e.getStyle();t!==r.color&&(r.color=t,s())}},this.setScale=e=>{r&&e>0&&r.scale.set(e,e,1)},this.setDepthTest=e=>{e&&e!==r.material.depthTest&&(r.material.depthTest=e)},this.setSize=e=>{e>0&&(z(r,o*e),i=e)},this.setFontWeight=e=>{e&&e!==a&&(r.fontWeight=e,s(),a=e)},this.setText=e=>{if(e&&e!==r.text){if(r._canvas,r.material&&r.material.map&&r.material.map.dispose(),r._canvas){let e=r._canvas.getContext(`2d`);e&&e.clearRect(0,0,r._canvas.width,r._canvas.height),r._canvas.width=1,r._canvas.height=1}r.text=e,z(r,o*i),n=e,r.material&&r.material.map&&(s(),r.material.map.needsUpdate=!0)}},this.setVisibility=e=>{r.visible=e},this.dispose=()=>{r&&(L(r),r.removeFromParent(),r.material&&(r.material.map?.dispose(),r.material.dispose()),r._canvas&&(r._canvas.width=0,r._canvas.height=0))},this.getSprite=()=>r,this.getString=()=>n},qe=function(t,n,r,i){H.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],u;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=>{o?.requestRender?.(),e&&(typeof e==`string`||e instanceof String)&&(c=e,this.morph&&(this.morph.name=e))},this.showLabel=e=>{if(o?.requestRender?.(),s&&=(l=s.getPosition(),this.group.remove(s.getSprite()),s.dispose(),void 0),c&&(typeof c==`string`||c instanceof String)){s=new Ke(c,u||e),s.setPosition(l[0],l[1],l[2]);let t=s.getSprite();t.material.alphaTest=.05,t.material.transparent=!0,t.material.depthWrite=!1,this.group.add(s.getSprite())}},this.hideLabel=()=>{o?.requestRender?.(),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)=>{o?.requestRender?.(),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=>{o?.requestRender?.(),u=e?e.clone():void 0,s&&s.setColour(e),this.secondaryMesh&&this.secondaryMesh.material&&(this.secondaryMesh.material.color=e),this.geometry&&(this.geometry.colorsNeedUpdate=!0)},this.getColour=()=>u,this.dispose=()=>{s&&=(s.dispose(),void 0),this.material&&this.material.dispose(),this.morph=void 0}};qe.prototype=Object.create(H.prototype);function Je(){}Je.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(Je.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=Je.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 Ye=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.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()},Xe=e.BufferAttribute,Ze=e.BufferGeometry,Qe=e.Color,$e=e.DefaultLoadingManager,et=e.FileLoader,tt=e.Float32BufferAttribute,nt=e.LoaderUtils;function rt(e){typeof e==`boolean`&&(console.warn(`THREE.JSONLoader: showStatus parameter has been removed from constructor.`),e=void 0),this.manager=e===void 0?$e:e,this.withCredentials=!1,this.paramsString=``}Object.assign(rt.prototype,{load:function(e,t,n,r){var i=this,a=this.texturePath&&typeof this.texturePath==`string`?this.texturePath:nt.extractUrlBase(e),o=new et(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){return e&1<<t}function n(e){let n=e.faces,r=0;if(e.uvs!==void 0)for(let t=0;t<e.uvs.length;t++)e.uvs[t].length&&r++;let i=[],a=[],o=0,s=n.length;for(;o<s;){let e=n[o++],s=t(e,0),c=t(e,1),l=t(e,3),u=t(e,4),d=t(e,5),f=t(e,6),p=t(e,7),m,h,g;if(s){let e=n[o],t=n[o+1],s=n[o+2],m=n[o+3];o+=4;let h=0;c&&(h=n[o++]),l&&(o+=r*4),u&&(o+=1),d&&(o+=4),f&&(o+=1),p&&(o+=4),i.push(e,t,m),a.push(h),i.push(t,s,m),a.push(h);continue}m=n[o++],h=n[o++],g=n[o++],h||=m,g||=h;let _=0;c&&(_=n[o++]),l&&(o+=r*3),u&&(o+=1),d&&(o+=3),f&&(o+=1),p&&(o+=3),i.push(m,h,g),a.push(_)}return{indices:i,materialIndices:a}}function r(e){let t=[],n,r;for(let i=0;i<e.length;i++)e[i]!==r&&(r=e[i],n!==void 0&&(n.count=i*3-n.start,t.push(n)),n={start:i*3,materialIndex:r});return n!==void 0&&(n.count=e.length*3-n.start,t.push(n)),t}function i(e,t){let n=new Ze;n.setIndex(t),n.setAttribute(`position`,e),n.computeVertexNormals();let r=n.getAttribute(`normal`);return r.name=e.name,r}function a(e,t){let n=[];if(e.morphTargets!==void 0)for(let r=0,i=e.morphTargets.length;r<i;r++){let i=e.morphTargets[r].vertices,a=new Float32Array(i.length);for(let e=0,n=i.length;e<n;e++)a[e]=i[e]*t;let o=new Xe(a,3);o.name=e.morphTargets[r].name,n.push(o)}let r=[];if(e.morphNormals!==void 0){for(let t=0,i=e.morphNormals.length;t<i;t++)if(n[t]){let i=e.morphNormals[t].normals,a=new Xe(Float32Array.from(i),3);a.name=n[t].name,r[t]=a}}return{morphPositions:n,morphNormals:r}}function o(e){if(e.morphColors===void 0)return;let t=[];for(let n=0,r=e.morphColors.length;n<r;n++){let r=e.morphColors[n].colors,i=[];for(let e=0,t=r.length;e<t;e+=3){let t=new Qe(16755200);t.setRGB(r[e],r[e+1],r[e+2]),i.push(t)}let a=[];for(let e=0,t=i.length*3;e<t;e++){let t=ae(i,e);a.push(t[0],t[1],t[2])}let o=new tt(a,3);o.name=e.morphColors[n].name,t.push(o)}return t}return function(t,s){t.data!==void 0&&(t=t.data);let c=t.scale===void 0?1:1/t.scale,l=t.vertices,u=l.length/3,d=new Float32Array(l.length);for(let e=0,t=l.length;e<t;e++)d[e]=l[e]*c;let f=new Ze;if(f.setAttribute(`position`,new Xe(d,3)),t.normals!==void 0&&t.normals.length>0&&f.setAttribute(`normal`,new Xe(Float32Array.from(t.normals),3)),t.uvs!==void 0&&(t.uvs[0]&&t.uvs[0].length>0&&f.setAttribute(`uv`,new Xe(Float32Array.from(t.uvs[0]),2)),t.uvs[1]&&t.uvs[1].length>0&&f.setAttribute(`uv2`,new Xe(Float32Array.from(t.uvs[1]),2))),t.colors!==void 0&&t.colors.length>0){let e=new Float32Array(t.colors.length*3);for(let n=0,r=t.colors.length;n<r;n++){let r=new Qe(t.colors[n]);e[n*3]=r.r,e[n*3+1]=r.g,e[n*3+2]=r.b}f.setAttribute(`color`,new Xe(e,3))}else{let e=new Float32Array(u*3).fill(1);f.setAttribute(`color`,new Xe(e,3))}let{indices:p,materialIndices:m}=n(t);p.length>0&&(f.setIndex(p),f.groups=r(m));let{morphPositions:h,morphNormals:g}=a(t,c);if(h.length>0){f.morphAttributes.position=h;let e=[];for(let t=0;t<h.length;t++)g[t]?e.push(g[t]):p.length>0&&e.push(i(h[t],p));e.length>0&&(f.morphAttributes.normal=e)}let _=o(t);if(_!==void 0&&(f.morphAttributes.color=_,f.morphAttributes.position===void 0)){let e=f.getAttribute(`position`);f.morphAttributes.position=_.map(t=>{let n=new Xe(e.array,e.itemSize);return n.name=t.name,n})}if(f.computeBoundingBox(),f.computeBoundingSphere(),t.materials===void 0||t.materials.length===0)return{geometry:f};var v=Je.prototype.initMaterials(t.materials,s,`Anonymous`);if(t.materials[0].video){var y=s+t.materials[0].video;this.paramsString&&(y+=`?${this.paramsString}`),f._video=new Ye(y)}return v&&v.length>0&&(t.materials[0].singleSided?v[0].side=e.FrontSide:t.materials[0].flipSided?v[0].side=e.BackSide:v[0].side=e.DoubleSide,t.materials[0].specularCoef&&(v[0].shininess=Math.floor(t.materials[0].specularCoef/3))),{geometry:f,materials:v}}})()});var it={NONE:0,MIRROR:1,AXES_2D:2,AXES_3D:3},at=e=>{switch(e){case`MIRROR`:return it.MIRROR;case`AXES_2D`:return it.AXES_2D;case`AXES_3D`:return it.AXES_3D;default:return it.NONE}},U={position:0,axis1:1,axis2:2,axis3:3,color:4},ot=e=>e==`AXES_2D`||e==`MIRROR`?2:e==`AXES_3D`?3:1;function st({baseCount:t,outputCount:r,repeat_mode:i,positionsData:a,axis1Data:o,axis2Data:s,axis3Data:c,scaleData:l,colorData:u,baseSize:d,offset:f,scaleFactors:p,globalScale:m}){let h=ot(i),g=!!u,_=[a,o,s,c,l];g&&_.push(u);let v=_.length,y=g?U.color+1:U.axis3+1,b=a.length/3,x=new Float32Array(b*v*4);for(let e=0;e<b;e++)for(let t=0;t<v;t++){let n=_[t],r=(e*v+t)*4;x[r]=n[e*3],x[r+1]=n[e*3+1],x[r+2]=n[e*3+2]}let S=(0,n.attributeArray)(x,`vec4`),C=(0,n.attributeArray)(r*y,`vec4`),w=(e,t)=>S.element(e.mul((0,n.int)(v)).add((0,n.int)(t))).xyz,T=(e,t,r)=>C.element(e.mul((0,n.int)(y)).add((0,n.int)(t))).assign((0,n.vec4)(r,0)),E=e=>({element:t=>C.element((0,n.int)(t).mul((0,n.int)(y)).add((0,n.int)(e))).xyz}),D={bottomFrame:(0,n.uniform)(0,`int`),topFrame:(0,n.uniform)(0,`int`),proportion:(0,n.uniform)(1),repeatMode:(0,n.uniform)(at(i),`int`),baseSize:(0,n.uniform)(new e.Vector3(...d)),offset:(0,n.uniform)(new e.Vector3(...f)),scaleFactors:(0,n.uniform)(new e.Vector3(...p)),globalScale:(0,n.uniform)(m)};return{uniforms:D,compute:(0,n.Fn)(()=>{let e=(0,n.int)(n.instanceIndex),r=e.div((0,n.int)(h)),i=e.mod((0,n.int)(h)),a=D.bottomFrame.mul((0,n.int)(t)).add(r),o=D.topFrame.mul((0,n.int)(t)).add(r),s=(0,n.mix)(w(o,0),w(a,0),D.proportion),c=(0,n.mix)(w(o,1),w(a,1),D.proportion),l=(0,n.mix)(w(o,2),w(a,2),D.proportion),u=(0,n.mix)(w(o,3),w(a,3),D.proportion),d=(0,n.mix)(w(o,4),w(a,4),D.proportion),f=D.repeatMode.equal((0,n.int)(it.NONE)).or(D.repeatMode.equal((0,n.int)(it.MIRROR)));if((0,n.If)(f,()=>{let t=(0,n.vec3)((0,n.select)(d.x.lessThan(0),(0,n.float)(-1),(0,n.float)(1)),(0,n.select)(d.y.lessThan(0),(0,n.float)(-1),(0,n.float)(1)),(0,n.select)(d.z.lessThan(0),(0,n.float)(-1),(0,n.float)(1))).mul(D.baseSize).add(d.mul(D.scaleFactors)).mul(D.globalScale),r=c.mul(t.x),a=l.mul(t.y),o=u.mul(t.z),f=s.add(r.mul(D.offset.x)).add(a.mul(D.offset.y)).add(o.mul(D.offset.z)),p=D.repeatMode.equal((0,n.int)(it.MIRROR)).and(i.equal((0,n.int)(1))),m=(0,n.select)(p,r.negate(),r).toVar(),h=(0,n.select)(p,a.negate(),a).toVar(),g=(0,n.select)(p,o.negate(),o).toVar(),_=f.toVar();(0,n.If)(D.repeatMode.equal((0,n.int)(it.MIRROR)).and(d.x.lessThan(0)),()=>{_.subAssign(m)});let v=g.dot(m.cross(h));(0,n.If)(v.lessThan(0),()=>{g.assign(g.negate())}),T(e,U.position,_),T(e,U.axis1,m),T(e,U.axis2,h),T(e,U.axis3,g)}).Else(()=>{let t=(0,n.vec3)((0,n.select)(d.x.lessThan(0),(0,n.float)(-1),(0,n.float)(1)),(0,n.select)(d.y.lessThan(0),(0,n.float)(-1),(0,n.float)(1)),(0,n.select)(d.z.lessThan(0),(0,n.float)(-1),(0,n.float)(1))).mul(D.baseSize.x).add(d.mul(D.scaleFactors.x)).mul(D.globalScale),r=s.add(c.mul(t.x).mul(D.offset.x)).add(l.mul(t.y).mul(D.offset.y)).add(u.mul(t.z).mul(D.offset.z)),a=(0,n.select)(i.equal((0,n.int)(0)),d.x,(0,n.select)(i.equal((0,n.int)(1)),d.y,d.z)),o=D.repeatMode.equal((0,n.int)(it.AXES_2D)),f=(0,n.select)(i.equal((0,n.int)(0)),c,(0,n.select)(i.equal((0,n.int)(1)),l,u)),p=(0,n.select)(i.equal((0,n.int)(0)),l,(0,n.select)(i.equal((0,n.int)(1)),(0,n.select)(o,c,u),c)),m=D.baseSize.x.add(a.mul(D.scaleFactors.x)).mul(D.globalScale),h=f.mul(m),g=h.cross(p),_=g.length(),v=D.baseSize.z.add(a.mul(D.scaleFactors.z)).mul(D.globalScale).div((0,n.max)(_,1e-8));v=(0,n.select)(o.and(i.greaterThan((0,n.int)(0))),v.mul(-1),v);let y=(0,n.select)(_.greaterThan(0),g.mul(v),g),b=y.cross(h),x=b.length(),S=D.baseSize.y.add(a.mul(D.scaleFactors.y)).mul(D.globalScale).div((0,n.max)(x,1e-8)),C=(0,n.select)(x.greaterThan(0),b.mul(S),b);T(e,U.position,r),T(e,U.axis1,h),T(e,U.axis2,C),T(e,U.axis3,y)}),g){let t=(0,n.mix)(w(o,5),w(a,5),D.proportion);T(e,U.color,t)}})().compute(r),outputs:{buffer:C,stride:y,count:r,position:E(U.position),axis1:E(U.axis1),axis2:E(U.axis2),axis3:E(U.axis3),color:g?E(U.color):void 0}}}async function ct(e,t){let{buffer:n,stride:r,count:i,color:a}=t.outputs,o=new Float32Array(await e.getArrayBufferAsync(n.value)),s=e=>{let t=new Float32Array(i*4);for(let n=0;n<i;n++){let i=(n*r+e)*4;t[n*4]=o[i],t[n*4+1]=o[i+1],t[n*4+2]=o[i+2]}return t};return{position:s(U.position),axis1:s(U.axis1),axis2:s(U.axis2),axis3:s(U.axis3),color:a?s(U.color):void 0}}async function lt(e,t){return e.compute(t.compute),ct(e,t)}function ut(t,r){let i=t;(!i||!i.isNodeMaterial)&&(i=new(t&&be[t.type]||e.MeshPhongNodeMaterial),t&&i.copy(t));let{position:a,axis1:o,axis2:s,axis3:c,color:l}=r.outputs;return i.positionNode=(0,n.Fn)(()=>{let e=n.instanceIndex;return a.element(e).add(o.element(e).mul(n.positionGeometry.x)).add(s.element(e).mul(n.positionGeometry.y)).add(c.element(e).mul(n.positionGeometry.z))})(),l&&(i.colorNode=(0,n.Fn)(()=>(0,n.vec4)(l.element(n.instanceIndex).mul(n.materialColor),n.materialOpacity))()),i}var dt=function(){H.call(this);let t=[],n,r,i,a,o=!1,s,c,l,u=0,d=0,f=[0,0,0],p=[0,0,0],m=!1,h=[0,0,0],g=`NONE`;this.ready=!1;let _=!1,v=!1;this.isGlyphset=!0;let y=new e.Matrix4,b=new e.Color,x=new e.Color,S=new e.Box3,C=new e.Box3,w=new e.Box3,T=[],E=[],D=[],O=[],k=[],A=[],j=[],M=[];this.globalScale=1;let N,P=!1,F=!0,I=!1,L=!1,R,z,B=!1;for(let t=0;t<8;t++)T[t]=new e.Vector3;let ee=(e,t)=>{e.elements[0]=t[1][0],e.elements[1]=t[1][1],e.elements[2]=t[1][2],e.elements[3]=0,e.elements[4]=t[2][0],e.elements[5]=t[2][1],e.elements[6]=t[2][2],e.elements[7]=0,e.elements[8]=t[3][0],e.elements[9]=t[3][1],e.elements[10]=t[3][2],e.elements[11]=0,e.elements[12]=t[0][0],e.elements[13]=t[0][1],e.elements[14]=t[0][2],e.elements[15]=1},ne=(e,t,n)=>{let r=new Float32Array(t*n*3);for(let i=0;i<t;i++){let t=e[i.toString()];t&&r.set(t,i*n*3)}return r},re=(t,n,r)=>{let i=new Float32Array(n*r*3),a=new e.Color;for(let e=0;e<n;e++){let n=t[e.toString()];if(n)for(let t=0;t<r;t++){a.setHex(n[t]);let o=(e*r+t)*3;i[o]=a.r,i[o+1]=a.g,i[o+2]=a.b}}return i};this.load=(t,m,y,b,x)=>{if(o=!1,n=t.axis1,r=t.axis2,i=t.axis3,a=t.positions,s=t.scale,c=t.colors,l=t.label,_=t.metadata.MorphColours,v=t.metadata.MorphVertices,u=t.metadata.number_of_time_steps,g=t.metadata.repeat_mode,d=t.metadata.number_of_vertices,g==`AXES_2D`||g==`MIRROR`?d*=2:g==`AXES_3D`&&(d*=3),f=t.metadata.base_size,p=t.metadata.offset,h=t.metadata.scale_factors,N=void 0,v&&u>1&&a&&a[0]){let e=a[0].length/3;try{N=st({baseCount:e,outputCount:d,repeat_mode:g,positionsData:ne(a,u,e),axis1Data:ne(n,u,e),axis2Data:ne(r,u,e),axis3Data:ne(i,u,e),scaleData:ne(s,u,e),colorData:_&&c?re(c,u,e):void 0,baseSize:f,offset:p,scaleFactors:h,globalScale:this.globalScale})}catch(e){console.error(`Failed to set up GPU glyph transform compute, falling back to CPU animation.`,e),N=void 0}}let S=new rt;this.geometry=new e.BufferGeometry;let C=new e.InstancedMesh(this.geometry,void 0,d);if(this.setMorph(C),b){var w=S.parse(m);he(y,x)(w.geometry,w.materials),w.geometry.dispose()}else S.crossOrigin=`Anonymous`,S.load(m,he(y,x))};let ie=(e,t,n,r,i,a)=>{if(g==`NONE`||g==`MIRROR`){let c=[0,0,0],l=[0,0,0],u=[0,0,0],d=[0,0,0],m=[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*f[o]+i[o]*h[o])*this.globalScale}for(var o=0;o<3;o++)l[o]=t[o]*c[0],u[o]=n[o]*c[1],d[o]=r[o]*c[2],m[o]=e[o]+p[0]*l[o]+p[1]*u[o]+p[2]*d[o],g==`MIRROR`&&(_[o]=-l[o],v[o]=-u[o],y[o]=-d[o],b[o]=m[o],i[0]<0&&(m[o]-=l[o],b[o]-=_[o]));0>d[0]*(l[1]*u[2]-l[2]*u[1])+d[1]*(l[2]*u[0]-l[0]*u[2])+d[2]*(l[0]*u[1]-l[1]*u[0])&&(d[0]=-d[0],d[1]=-d[1],d[2]=-d[2]),a[0]=[m,l,u,d],g==`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(g==`AXES_2D`||g==`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*f[0]+i[o]*h[0])*this.globalScale}for(var o=0;o<3;o++)u[o]=e[o]+p[0]*l[0]*t[o]+p[1]*l[1]*n[o]+p[2]*l[2]*r[o];let d=g==`AXES_2D`?2:3;for(let e=0;e<d;e++){let o,s,l=i[e],d=[0,0,0],p=[0,0,0],m=[0,0,0];e==0?(o=t,s=n):e==1?(o=n,s=g==`AXES_2D`?t:r):(o=r,s=t);let _=(f[0]+l*h[0])*this.globalScale;d[0]=o[0]*_,d[1]=o[1]*_,d[2]=o[2]*_,m[0]=d[1]*s[2]-s[1]*d[2],m[1]=d[2]*s[0]-s[2]*d[0],m[2]=d[0]*s[1]-d[1]*s[0];let v=Math.sqrt(m[0]*m[0]+m[1]*m[1]+m[2]*m[2]);if(0<v){let t=(f[2]+l*h[2])*this.globalScale/v;g==`AXES_2D`&&e>0&&(t*=-1),m[0]*=t,m[1]*=t,m[2]*=t}if(p[0]=m[1]*d[2]-d[1]*m[2],p[1]=m[2]*d[0]-d[2]*m[0],p[2]=m[0]*d[1]-m[1]*d[0],v=Math.sqrt(p[0]*p[0]+p[1]*p[1]+p[2]*p[2]),0<v){var c=(f[1]+l*h[1])*this.globalScale/v;p[0]*=c,p[1]*=c,p[2]*=c}a[e]=[u,d,p,m]}}return a},ae=(e,n,r,i,a)=>{let o=1;g==`AXES_2D`||g==`MIRROR`?o=2:g==`AXES_3D`&&(o=3);let s=e.length/3,c=0;M.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=ie(u,d,f,p,m,M);if(h.length==o)for(let e=0;e<o;e++){ee(y,h[e]),this.morph.setMatrixAt(c,y);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()},oe=(e,n)=>{let r=1;g==`AXES_2D`||g==`MIRROR`?r=2:g==`AXES_3D`&&(r=3);let i=e.length,a=0;for(let o=0;o<i;o++){let i=e[o];for(let e=0;e<r;e++){b.setHex(i),n||this.morph.setColorAt(a,b);let e=t[a];e&&e.setColour(b),a++}}n||(this.morph.instanceColor.needsUpdate=!0)},se=e=>{this.requestRender();let n=this.morph.instanceMatrix.array,r=this.canShowLabel();for(let i=0;i<d;i++){let a=i*4,o=i*16;if(n[o]=e.axis1[a],n[o+1]=e.axis1[a+1],n[o+2]=e.axis1[a+2],n[o+3]=0,n[o+4]=e.axis2[a],n[o+5]=e.axis2[a+1],n[o+6]=e.axis2[a+2],n[o+7]=0,n[o+8]=e.axis3[a],n[o+9]=e.axis3[a+1],n[o+10]=e.axis3[a+2],n[o+11]=0,n[o+12]=e.position[a],n[o+13]=e.position[a+1],n[o+14]=e.position[a+2],n[o+15]=1,r){let n=t[i];n&&n.setTransformation([e.position[a],e.position[a+1],e.position[a+2]],[e.axis1[a],e.axis1[a+1],e.axis1[a+2]],[e.axis2[a],e.axis2[a+1],e.axis2[a+2]],[e.axis3[a],e.axis3[a+1],e.axis3[a+2]])}}if(this.morph.instanceMatrix.needsUpdate=!0,this.boundingBoxUpdateRequired=!0,this.morph.computeBoundingSphere(),e.color){let n=this.morph.instanceColor?this.morph.instanceColor.array:void 0;for(let i=0;i<d;i++){let a=i*4;if(n){let t=i*3;n[t]=e.color[a],n[t+1]=e.color[a+1],n[t+2]=e.color[a+2]}if(r){let n=t[i];n&&(b.setRGB(e.color[a],e.color[a+1],e.color[a+2]),n.setColour(b))}}n&&(this.morph.instanceColor.needsUpdate=!0)}},ce=(e,t,n)=>{if(P)return;let r=this.region?.getScene?.()?.getRenderer?.();r&&(N.uniforms.bottomFrame.value=e,N.uniforms.topFrame.value=t,N.uniforms.proportion.value=n,N.uniforms.globalScale.value=this.globalScale,P=!0,F=!1,lt(r,N).then(e=>{P=!1,se(e),F=!0,delete this.morph.raycast}).catch(e=>{P=!1,console.error(`Glyph transform compute readback failed.`,e)}))},le=(e,t,n)=>{this.requestRender();let r=this.region?.getScene?.()?.getRenderer?.();return r?(N.uniforms.bottomFrame.value=e,N.uniforms.topFrame.value=t,N.uniforms.proportion.value=n,N.uniforms.globalScale.value=this.globalScale,r.compute(N.compute),F=!1,this.morph.raycast=()=>{},I=!0,!0):!1},ue=()=>{if(P)return;let e=this.region?.getScene?.()?.getRenderer?.();e&&(P=!0,ct(e,N).then(e=>{P=!1,se(e),F=!0,delete this.morph.raycast}).catch(e=>{P=!1,console.error(`Glyph transform compute readback failed.`,e)}))},de=()=>{z!==void 0&&(clearTimeout(z),z=void 0)},V=()=>{de(),z=setTimeout(()=>{z=void 0,ue()},500)},fe=e=>{let t=this.inbuildTime/this.duration*(u-1),o=Math.floor(t),l=1-(t-o),d=Math.ceil(t);if(v&&N){e?(le(o,d,l),V()):(de(),ce(o,d,l));return}let f=E,p=D,m=O,h=k,g=A,y=j;if(v){let e=a[o.toString()],t=a[d.toString()],c=n[o.toString()],u=n[d.toString()],_=r[o.toString()],v=r[d.toString()],y=i[o.toString()],b=i[d.toString()],x=s[o.toString()],S=s[d.toString()];E.length=e.length,D.length=e.length,O.length=e.length,k.length=e.length,A.length=e.length;for(let n=0;n<e.length;n++)f[n]=l*e[n]+(1-l)*t[n],p[n]=l*c[n]+(1-l)*u[n],m[n]=l*_[n]+(1-l)*v[n],h[n]=l*y[n]+(1-l)*b[n],g[n]=l*x[n]+(1-l)*S[n]}else f=a[0],p=n[0],m=r[0],h=i[0],g=s[0];if((v||!B)&&(ae(f,p,m,h,g),B=!v),c!=null){if(_){let e=c[o.toString()],t=c[d.toString()];y.length=e.length;for(let n=0;n<e.length;n++)b.setHex(e[n]),x.setHex(t[n]),b.setRGB(b.r*l+x.r*(1-l),b.g*l+x.g*(1-l),b.b*l+x.b*(1-l)),y[n]=b.getHex()}else y=c[0];oe(y,!1)}};this.getLabel=e=>{if(l&&l.length>e)return l[e]},this.isLabelDisplayed=()=>m,this.canShowLabel=()=>t?.length&&(l?.length||this.groupName),this.showLabel=()=>{if(this.requestRender(),t?.length){m=!0;for(let e=0;e<t.length;e++)t[e].showLabel(this.morph.material?this.morph.material.color:void 0)}},this.hideLabel=()=>{this.requestRender();for(let e=0;e<t.length;e++)t[e].hideLabel();m=!1};let pe=()=>{let t=new e.Box3().setFromBufferAttribute(this.geometry.attributes.position),o=new e.Matrix4,c=new e.Box3,l=[],d=new e.Box3,f=!0;for(let e=0;e<u;e++){let u=a[e.toString()],p=n[e.toString()],m=r[e.toString()],h=i[e.toString()],g=s[e.toString()];if(!u)continue;let _=u.length/3;for(let e=0;e<_;e++){let n=e*3,r=[u[n],u[n+1],u[n+2]],i=[p[n],p[n+1],p[n+2]],a=[m[n],m[n+1],m[n+2]],s=[h[n],h[n+1],h[n+2]],_=[g[n],g[n+1],g[n+2]],v=ie(r,i,a,s,_,l);for(let e=0;e<v.length;e++)ee(o,v[e]),c.copy(t).applyMatrix4(o),f?(d.copy(c),f=!1):d.union(c)}}return f?void 0:d},me=e=>{for(let e=0;e<d;e++){let n=new qe(void 0,void 0,e,this),r=l?l[e]:void 0;r||=this.groupName,r&&n.setLabel(r),u>0&&n.setFrustumCulled(!1),t[e]=n,this.morph.add(n.getGroup())}l&&l.length>0&&e&&this.showLabel(),ae(a[0],n[0],r[0],i[0],s[0]),B=!0,c!=null&&oe(c[0],!!(N&&N.outputs.color)),N&&(R=pe()),this.ready=!0};this.addCustomGlyph=e=>{this.requestRender(),e.isGlyph&&t.push(e),this.ready=!0,this.boundingBoxUpdateRequired=!0},this.addMeshAsGlyph=(e,n)=>{if(this.requestRender(),e.isMesh){let r=new qe(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 he=(e,t)=>(n,r)=>{if(o){n.dispose();return}this.geometry.copy(n),this.geometry.computeBoundingSphere(),this.geometry.computeBoundingBox(),r&&r[0]&&(this.morph.material=r[0]),N&&(this.morph.material=ut(this.morph.material,N)),me(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,y),t.setFromMatrixPosition(y),t}},this.getBoundingBox=()=>{if(this.morph&&this.ready&&this.morph.visible){if(N&&!F&&R)return this.cachedBoundingBox.copy(R),this.cachedBoundingBox.applyMatrix4(te(this.morph)),this.cachedBoundingBox;if(this.boundingBoxUpdateRequired){S.setFromBufferAttribute(this.morph.geometry.attributes.position);for(let e=0;e<d;e++)this.morph.getMatrixAt(e,y),C.copy(S).applyMatrix4(y),e==0?w.copy(C):w.union(C);if(w)this.cachedBoundingBox.copy(w),this.cachedBoundingBox.applyMatrix4(te(this.morph)),this.boundingBoxUpdateRequired=!1;else return}return this.cachedBoundingBox}},this.setMorphTime=e=>{this.requestRender(),this.inbuildTime=e>this.duration?this.duration:0>e?0:e,(_||v)&&(fe(!0),v&&(this.markerUpdateRequired=!0))},this.isTimeVarying=()=>!!((this.ready===!1||u>0)&&(_||v)),this.getCurrentTime=()=>this.inbuildTime,this.prepareColorForExport=async()=>{if(!(N&&N.outputs.color))return;let e=this.region?.getScene?.()?.getRenderer?.();if(!e)return;e.compute(N.compute);let t=(await ct(e,N)).color;this.morph.setColorAt(0,b);let n=this.morph.instanceColor.array;for(let e=0;e<d;e++){let r=e*4,i=e*3;n[i]=t[r],n[i+1]=t[r+1],n[i+2]=t[r+2]}this.morph.instanceColor.needsUpdate=!0},this.clearColorExportState=()=>{N&&N.outputs.color&&this.morph.instanceColor&&(this.morph.instanceColor=null,this.morph.material&&(this.morph.material.needsUpdate=!0))},this.setScaleAll=function(e){this.requestRender(),this.globalScale=e,B=!1,fe(!1)},this.dispose=()=>{o=!0;for(let e=t.length-1;e>=0;e--)t[e].dispose();this.geometry&&this.geometry.dispose(),this.morph&&this.morph.material.dispose(),de(),n=void 0,r=void 0,i=void 0,a=void 0,s=void 0,c=void 0,N=void 0,P=!1,F=!0,I=!1,L=!1,R=void 0,this.ready=!1,this.groupName=void 0},this.render=(e,t,n,r)=>{if(N&&!I){let e=this.region?.getScene?.()?.getRenderer?.();e&&(e.compute(N.compute),I=!0,this.requestRender())}if(t==1){let t=this.inbuildTime+e;if(t>this.duration&&(t-=this.duration),this.inbuildTime=t,v&&N){de();let e=this.inbuildTime/this.duration*(u-1),t=Math.floor(e),n=1-(e-t);le(t,Math.ceil(e),n)}else(_||v)&&fe(!1);L=!0}else L&&N&&fe(!1),L=!1;this.updateMarker(t,r)}};dt.prototype=Object.create(H.prototype);var ft=new e.Matrix4,pt=new e.Ray,mt=new e.Vector3,ht=class extends e.InstancedMesh{constructor(e,t,n){super(e,t,n),this.type=`InstancedPoints`,this.isInstancedPoints=!0,this.frustumCulled=!1,this.pointSize=10,this.sizePerPixel=1,this.pointPositions=new Float32Array}raycast(t,n){let r=this.matrixWorld,i=t.params.Points?t.params.Points.threshold:1,a=this.count,o=this.pointPositions;if(!a||!o||o.length<a*3)return;ft.copy(r).invert(),pt.copy(t.ray).applyMatrix4(ft);let s=i/((this.scale.x+this.scale.y+this.scale.z)/3)*this.pointSize*this.sizePerPixel,c=s*s;for(let i=0;i<a;i++){mt.fromArray(o,i*3);let a=pt.distanceSqToPoint(mt);if(a<c){let o=new e.Vector3;pt.closestPointToPoint(mt,o),o.applyMatrix4(r);let s=t.ray.origin.distanceTo(o);if(s<t.near||s>t.far)continue;n.push({distance:s,distanceToRay:Math.sqrt(a),point:o,index:i,face:null,object:this})}}}},gt=new e.Vector2,_t=t=>{let r=new e.MeshBasicNodeMaterial,i={pointSize:(0,n.uniform)(10),sizeAttenuation:(0,n.uniform)(0),viewportScale:(0,n.uniform)(1).onFrameUpdate(function({renderer:e}){let t=e.getSize(gt);this.value=.5*t.y})};return r.vertexNode=(0,n.Fn)(()=>{let e=(0,n.attribute)(`instancePosition`,`vec3`),t=n.modelViewMatrix.mul((0,n.vec4)(e,1)),r=i.pointSize.mul(n.screenDPR),a=r.mul(i.viewportScale.div(t.z.negate()));r=(0,n.mix)(r,a,i.sizeAttenuation);let o=n.positionGeometry.xy.mul(r);o=o.div(n.viewportSize.div(2));let s=n.cameraProjectionMatrix.mul(t);return o=o.mul(s.w),(0,n.vec4)(s.xy.add(o),s.z,s.w)})(),r.colorNode=(0,n.Fn)(()=>{let e=(0,n.texture)(t,(0,n.uv)());return(0,n.vec4)(e.rgb.mul(n.materialColor),e.a.mul(n.materialOpacity))})(),r.userData.uniforms=i,r.size=i.pointSize.value,r.sizeAttenuation=!!i.sizeAttenuation.value,r},vt=500,yt=t=>{let n=new e.PlaneGeometry(1,1),r=new e.InstancedBufferAttribute(new Float32Array(t*3),3);return r.setUsage(e.DynamicDrawUsage),n.setAttribute(`instancePosition`,r),n},bt=(e,t)=>{let n=e.getAttribute(`position`),r=e.morphAttributes.position;if(t&&r&&r.length>0){let t=e.morphTargetsRelative;return r.map(e=>{if(!t)return Float32Array.from(e.array);let r=new Float32Array(n.array.length);for(let t=0;t<r.length;t++)r[t]=n.array[t]+e.array[t];return r})}return[Float32Array.from(n.array)]},xt=(e,t)=>{let n=e.morphAttributes.color;if(t&&n&&n.length>0)return n.map(e=>Float32Array.from(e.array))},St=e=>{let t=e.getAttribute(`color`);return t?Float32Array.from(t.array):void 0},Ct=function(){H.call(this),this.isPointset=!0;let t=[],n=1,r=!1,i=500,a=!0,o=[],s,c=!1,l=!1,u=new e.Color,d=()=>{let e=this.getMorph();if(!e||o.length===0)return;let t=e.count,n=o.length,r=0,i=0,a=1;if(n>1){let e=this.inbuildTime/this.duration*(n-1);r=Math.floor(e),i=Math.ceil(e),a=1-(e-r)}if(c){let n=o[r],s=o[i],c=e.pointPositions,l=t*3;for(let e=0;e<l;e++)c[e]=a*n[e]+(1-a)*s[e];e.geometry.getAttribute(`instancePosition`).needsUpdate=!0,this.boundingBoxUpdateRequired=!0}if(l&&s){let n=s[Math.min(r,s.length-1)],o=s[Math.min(i,s.length-1)];e.instanceColor||e.setColorAt(0,u);let c=e.instanceColor.array,l=t*3;for(let e=0;e<l;e++)c[e]=a*n[e]+(1-a)*o[e];e.instanceColor.needsUpdate=!0}};this.createMesh=(e,t,n)=>{if(!e||!t)return;let r=ce(e,n);o=bt(r,n.localTimeEnabled),s=xt(r,n.localMorphColour),c=o.length>1,l=!!s,this.timeEnabled=c,this.morphColour=l;let i=o[0].length/3,a=yt(i),d=_t(he());t.color&&d.color.copy(t.color),t.opacity!==void 0&&(d.opacity=t.opacity),d.transparent=!!t.transparent,d.alphaTest=t.alphaTest===void 0?.5:t.alphaTest;let f=new ht(a,d,i);f.count=i;let p=a.getAttribute(`instancePosition`);p.array.set(o[0]),p.needsUpdate=!0,f.pointPositions=p.array,f.userData=this,this.drawRange=i;let m=s?s[0]:St(r);if(m)for(let e=0;e<i;e++)u.setRGB(m[e*3],m[e*3+1],m[e*3+2]),f.setColorAt(e,u);this.setMorph(f),r.dispose(),this.boundingBoxUpdateRequired=!0},this.setMesh=(e,t,n)=>{this.createMesh(e.geometry,e.material,{localTimeEnabled:t,localMorphColour:n});let r=this.getMorph();r&&(r.name=e.name)};let f=(o,s,c,l)=>{if(c){let u=new Ke(c,new e.Color(l));u.setPosition(s[0],s[1],s[2]);let d=u.getSprite();d.material.sizeAttenuation=!1,d.material.alphaTest=.05,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}},p=e=>{let n=t[e];if(n){let r=n.getSprite();this.group.remove(r),n.dispose(),t.splice(e,1)}};this.addPoints=(e,t,n)=>{if(this.requestRender(),e&&e.length>0){let r=this.getMorph(),i=this.drawRange;if(!r){i=0,this.drawRange=0;let e=yt(vt),t=_t(he());t.color.set(n),t.alphaTest=.5,r=new ht(e,t,vt),r.pointPositions=e.getAttribute(`instancePosition`).array,r.count=0,r.userData=this,this.setMorph(r)}let a=r.geometry.getAttribute(`instancePosition`);e.forEach(e=>{this.drawRange<vt&&(a.setXYZ(this.drawRange,e[0],e[1],e[2]),this.drawRange++)}),a.needsUpdate=!0,r.count=this.drawRange;let o=i+e.length,s=0;if(Array.isArray(t)&&t.length===e.length||typeof t==`string`)for(;i+s<o;){let n=typeof t==`string`?t:t[s];f(i+s,e[s],n,this._lod._material.color),s++}this.boundingBoxUpdateRequired=!0,this.region&&(this.region.pickableUpdateRequired=!0)}},this.setColourHex=function(e){this.requestRender(),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.requestRender(),this._lod.setColour(e);for(let e=0;e<t.length;e++)t[e]&&t[e].setColour(this._lod._material.color)},this.setLabelDepthTest=e=>{this.requestRender(),r=e;for(let n=0;n<t.length;n++)t[n]&&t[n].setDepthTest(e)},this.setLabelFontWeight=e=>{this.requestRender(),i=e;for(let n=0;n<t.length;n++)t[n]&&t[n].setFontWeight(e)},this.setLabelSize=e=>{this.requestRender(),n=e;for(let e=0;e<t.length;e++)t[e]&&t[e].setSize(n)},this.displayLabels=e=>{this.requestRender(),a=e;for(let e=0;e<t.length;e++)t[e]&&t[e].setVisibility(a)},this.setSize=e=>{this.requestRender(),this.morph&&this.morph.material&&(this.morph.material.size=e,this.morph.material.userData.uniforms.pointSize.value=e,this.morph.pointSize=e)},this.setSizeAttenuation=e=>{this.requestRender(),this.morph&&this.morph.material&&(this.morph.material.sizeAttenuation=e,this.morph.material.userData.uniforms.sizeAttenuation.value=+!!e)},this.getVerticesByIndex=function(e){let t=this.getMorph();if(t&&e>=0&&this.drawRange>e)return[t.pointPositions[e*3],t.pointPositions[e*3+1],t.pointPositions[e*3+2]]},this.editVertices=function(e,n){if(this.requestRender(),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(`instancePosition`),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]),o[0]&&(o[0][a*3]=e[0],o[0][a*3+1]=e[1],o[0][a*3+2]=e[2]),a++}),i.needsUpdate=!0,this.boundingBoxUpdateRequired=!0}}},this.deleteVertices=function(e){this.requestRender();let t=this.getMorph();if(!t||0>e||e>=this.drawRange)return this.drawRange;let n=t.geometry.getAttribute(`instancePosition`),r=this.drawRange-1;return n.array.copyWithin(e*3,(e+1)*3,this.drawRange*3),t.pointPositions!==n.array&&t.pointPositions.copyWithin(e*3,(e+1)*3,this.drawRange*3),t.instanceColor&&(t.instanceColor.array.copyWithin(e*3,(e+1)*3,this.drawRange*3),t.instanceColor.needsUpdate=!0),n.needsUpdate=!0,this.drawRange=r,t.count=this.drawRange,p(e),this.boundingBoxUpdateRequired=!0,this.drawRange},this.setName=function(e){let n=this.groupName;Ct.prototype.setName.call(this,e),t.forEach(t=>{t.getString()===n&&t?.setText(e)})},this.getClosestVertexIndex=function(){let e=-1,t=this.getMorph();if(t&&this.drawRange>0){this._b1.setFromArray(t.pointPositions.subarray(0,this.drawRange*3)),this._b1.getCenter(this._v1);let n=-1;for(let r=0;r<this.drawRange;r++){this._v2.fromArray(t.pointPositions,r*3);let i=this._v1.distanceTo(this._v2);(n===-1||i<n)&&(n=i,e=r)}}return e},this.getClosestVertex=function(t){let n=this.getMorph();this.closestVertexIndex===-1&&(this.closestVertexIndex=this.getClosestVertexIndex());let r=new e.Vector3;return n&&this.closestVertexIndex>=0?(r.fromArray(n.pointPositions,this.closestVertexIndex*3),t?r.applyMatrix4(n.matrixWorld):r):(this.getBoundingBox(),r.copy(this.center),r)},this.getBoundingBox=function(){let e=this.getMorph();if(this.visible&&e&&e.visible&&this.drawRange>0)return this.boundingBoxUpdateRequired&&=(this._b1.setFromArray(e.pointPositions.subarray(0,this.drawRange*3)),this.cachedBoundingBox.copy(this._b1),this.cachedBoundingBox.applyMatrix4(te(e)),this.cachedBoundingBox.getCenter(this.center),this.radius=this.center.distanceTo(this.cachedBoundingBox.max),!1),this.cachedBoundingBox},this.isTimeVarying=()=>c||l,this.setMorphTime=e=>{this.requestRender(),this.inbuildTime=e>this.duration?this.duration:0>e?0:e,(c||l)&&d()},this.render=(e,t,n,r)=>{if(this.morph&&n&&(this.morph.sizePerPixel=n.pixelHeight),this.visible&&this._lod.update(n,this.center),t===!0&&(c||l)){let t=this.inbuildTime+e;t>this.duration&&(t-=this.duration),this.inbuildTime=t,d()}this.updateMarker(t,r)}};Ct.prototype=Object.create(H.prototype);var wt=function(){H.call(this),this.isLines=!0,this.createLineSegment=(e,t,n)=>{if(e&&t){let r=ce(e,n);n.localMorphColour&&r.morphAttributes.color&&(t.vertexColors=!1,t=xe(t));let i=new Fe(r,t);this.setMesh(i,n.localTimeEnabled,n.localMorphColour)}},this.setWidth=e=>{this.requestRender(),this.morph&&this.morph.material&&(this.morph.material.linewidth=e,this.morph.material.needsUpdate=!0)},this.addLines=(t,n)=>{if(this.requestRender(),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)}}};wt.prototype=Object.create(H.prototype);var Tt=function(){this.isTexture=!0,this.impl=void 0,this.isLoading=!1,this.size={width:1,height:1,depth:0}};Tt.prototype.loadImage=function(e,t){return new Promise((n,r)=>{e.onload=()=>n(e),e.onerror=r,e.src=t})},Tt.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}},Tt.prototype.loadFromImages=async function(e){},Tt.prototype.dispose=function(){this.impl&&=(this.impl.dispose(),void 0)},Tt.prototype.isReady=function(){return!!(this.impl&&!this.isLoading)},Tt.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(){Tt.call(this),this.isTextureArray=!0,this.imageData=void 0,this.setDataTexture=e=>{this.impl=e,console.log(`setDataTexture`,e),this.imageData=e.image.data},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.Data3DTexture(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(Tt.prototype),Et.prototype.dispose=function(){Tt.prototype.dispose.call(this),this.imageData=void 0};function Dt(){let t=new e.MeshBasicNodeMaterial({side:e.DoubleSide}),r=new Uint8Array(32),i=new e.Data3DTexture(r,2,2,2);i.image={data:r,width:2,height:2,depth:2},i.format=e.RGBAFormat,i.type=e.UnsignedByteType,i.minFilter=e.LinearFilter,i.magFilter=e.LinearFilter,i.generateMipmaps=!1,i.unpackAlignment=1,i.needsUpdate=!0;let a={brightness:(0,n.uniform)(0),contrast:(0,n.uniform)(1),depth:(0,n.uniform)(1),discardAlpha:(0,n.uniform)(!0),direction:(0,n.uniform)(1),flipY:(0,n.uniform)(!0),flipZ:(0,n.uniform)(!1),nChannels:(0,n.uniform)(1),maskEnabled:(0,n.uniform)(!1),slide:(0,n.uniform)(new e.Vector3(0,0,1)),time:(0,n.uniform)(0)},o=(0,n.varying)((0,n.vec3)(0),`vUw`);a.diffuse0=(0,n.texture3D)(i,o),a.diffuse1=(0,n.texture3D)(i,o),a.mask=(0,n.texture3D)(i,o);let s=(0,n.Fn)(()=>{let e=(0,n.vec3)(n.positionLocal).toVar();return(0,n.If)(a.direction.equal(1),()=>{e.assign((0,n.vec3)(a.slide.x,n.positionLocal.y,n.positionLocal.x))}),(0,n.If)(a.direction.equal(2),()=>{e.assign((0,n.vec3)(n.positionLocal.x,a.slide.y,n.positionLocal.y))}),(0,n.If)(a.direction.equal(3),()=>{e.assign((0,n.vec3)(n.positionLocal.x,n.positionLocal.y,a.slide.z))}),(0,n.If)(a.flipY,()=>{e.y.assign((0,n.float)(1).sub(e.y))}),(0,n.If)(a.flipZ,()=>{e.z.assign((0,n.float)(1).sub(e.z))}),o.assign((0,n.vec3)(e.x,e.y,e.z)),n.positionLocal}),c=(0,n.Fn)(()=>{let e=a.diffuse0.r,t=a.diffuse1.r,r=(0,n.mix)(e,t,a.time).toVar();(0,n.If)(a.maskEnabled.and(a.discardAlpha),()=>{let e=a.mask.r;(0,n.If)(e.equal(0),()=>{(0,n.Discard)()})});let i=(0,n.vec3)(r).add((0,n.vec3)(a.brightness)).sub((0,n.vec3)(.5)).mul(a.contrast).add((0,n.vec3)(.5));return(0,n.vec4)((0,n.sRGBTransferEOTF)(i),1)});return t.positionNode=s(),t.colorNode=c(),t.userData.uniforms=a,t}var Ot=function(e){H.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)}};Ot.prototype=Object.create(H.prototype),Ot.prototype.constructor=Ot,Ot.prototype.dispose=function(){let e=new Set(this.textureList);this.texture&&e.add(this.texture),e.forEach(e=>e.dispose()),this.texture=void 0,this.textureList=[],H.prototype.dispose.call(this)};var kt=t=>{let n=t.image,r=n.width,i=n.height,a=n.depth,o=n.data,s=new e.Data3DTexture(o,r,i,a);return s.format=t.format,s.type=t.type,s.minFilter=t.minFilter,s.magFilter=t.magFilter,s.wrapS=t.wrapS,s.wrapT=t.wrapT,s.wrapR=t.wrapR,s.colorSpace=t.colorSpace,s.anisotropy=t.anisotropy,s.needsUpdate=!0,s},At=function(t){Ot.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=>{this.requestRender(),e.forEach(e=>this.createSlide(e))};let g=(e,t)=>{let n=e.material.userData.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 r=-Math.PI/2;e.rotation.y=r,n.direction.value=1,n.slide.value.set(t.value,0,0),e.position.x=t.value;break;case`y`:e.rotation.x=Math.PI/2,n.direction.value=2,n.slide.value.set(0,t.value,0),e.position.y=t.value;break;case`z`:n.direction.value=3,n.slide.value.set(0,0,t.value),e.position.z=t.value}this.boundingBoxUpdateRequired=!0};this.modifySlideSettings=e=>{this.requestRender(),e&&e.id&&e.id in r&&r[e.id]&&g(r[e.id],e)},this.createSlide=t=>{if(this.requestRender(),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=Dt();p.userData.uniforms.brightness.value=s,p.userData.uniforms.contrast.value=c,p.userData.uniforms.diffuse0.value=kt(this.texture.impl),p.userData.uniforms.diffuse1.value=kt(this.texture.impl),p.userData.uniforms.discardAlpha.value=f,p.userData.uniforms.depth.value=this.texture.size.depth,p.userData.uniforms.flipY.value=a,p.userData.uniforms.flipZ.value=o,u&&(p.userData.uniforms.mask.value=u),p.userData.uniforms.maskEnabled.value=d,p.userData.uniforms.nChannels.value=l;let m=new e.Mesh(i,p);m.name=this.groupName,m.userData=this;let h={value:t.value,direction:t.direction,id:m.id};return n.push(h),g(m,h),r[m.id]=m,this.morph.add(m),this.boundingBoxUpdateRequired=!0,this.updateTimeTexture(),h}},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=>{this.requestRender(),e&&this.removeSlideWithId(e.id)},this.removeSlideWithId=e=>{if(this.requestRender(),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()}),u&&(u.dispose(),u=void 0,d=!1),Ot.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.userData.uniforms,t)}),this.cachedBoundingBox.applyMatrix4(te(this.morph)),this.boundingBoxUpdateRequired=!1}return this.cachedBoundingBox},this.applyTransformation=(t,n,r)=>{this.requestRender();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.requestRender(),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(this.requestRender(),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.requestRender(),this.morph.children.forEach(n=>{let r=n.material;if(r.userData.uniforms){let n=r.userData.uniforms;n[e].value=t}})},this.isAlphaPixelDiscarded=()=>f,this.discardAlphaPixel=e=>{this.requestRender(),f=e,this.setUniformsValue(`discardAlpha`,f)},this.getBrightness=()=>s,this.setBrightness=e=>{this.requestRender(),s=e,this.setUniformsValue(`brightness`,s)},this.getContrast=()=>c,this.setContrast=e=>{this.requestRender(),c>=0&&(c=e,this.setUniformsValue(`contrast`,c))},this.getNumberOfChannels=()=>l,this.setNumberOfChannels=e=>{this.requestRender(),l=e,this.setUniformsValue(`nChannels`,l)},this.getMask=()=>u,this.setMask=e=>{this.requestRender(),u=e,d=!!u,this.morph.children.forEach(e=>{let t=e.material;if(t.userData.uniforms){let e=t.userData.uniforms;u&&(e.mask.value=u)}}),this.setUniformsValue(`maskEnabled`,d)},this.hideEdges=()=>{this.requestRender(),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.userData.uniforms){let e=t.userData.uniforms;p!==r&&(e.diffuse0.value.image.data=this.textureList[r].imageData,e.diffuse0.value.needsUpdate=!0),m!==i&&(e.diffuse1.value.image.data=this.textureList[i].imageData,e.diffuse1.value.needsUpdate=!0),e.time.value=a}}),p=r,m=i,h=t}},this.setMorphTime=e=>{this.requestRender();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,r)=>{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()}}};At.prototype=Object.create(Ot.prototype),At.prototype.constructor=At;var jt=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}},Mt=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,L=!1,R,z=0,B={default:new jt};B.default.nearPlane=.1,B.default.farPlane=2e3,B.default.eyePosition=[0,0,0],B.default.targetPosition=[0,0,-1],B.default.upVector=[0,1,0],this.cameraObject.target===void 0&&(this.cameraObject.target=new e.Vector3(...B.default.targetPosition)),this.calculateMaxAllowedDistance=e=>{let t=e.getBoundingBox();if(t){t.getBoundingSphere(F),z=F.radius*6;let e=0;this.cameraObject&&(e=this.cameraObject.position.distanceTo(F.center)),z=e>z?e*1.5:z}else z=0};let ee=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&&(B[e]=t)},this.setDefaultViewport=e=>e&&e in B?(v=e,!0):!1,this.getDefaultViewport=()=>v,this.getViewportOfName=e=>B[e],this.setCurrentViewport=e=>e in B&&(this.setCurrentCameraSettings(B[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=()=>{L=!0,E&&=void 0,R&&R.setCurrentCameraSettings(this.cameraObject,B[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)=>{V(!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)=>{V(!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 te=(e,t)=>{e instanceof HTMLCanvasElement&&(e.tabIndex=t)},ne=()=>{if(z>0){let e=I.distanceTo(F.center);return z>e||this.cameraObject.position.distanceTo(F.center)>e}return!0},re=e=>{L=!0,I.copy(this.cameraObject.position).add(e),ne()&&(this.cameraObject.target.add(e),this.cameraObject.position.add(e),this.updateDirectionalLight())},ie=e=>{V(!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);re(e)}},ae=e=>{if(V(!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);re(e)}}else this._state===o.NONE&&T!==void 0&&T.move(this,e.clientX,e.clientY,this.renderer)}},oe=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)},se=e=>{this._state=o.NONE},ce=e=>{V(!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)},le=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)},ue=e=>{let t=this._state;if(this.touchZoomDistanceStart=this.touchZoomDistanceEnd=0,this.targetTouchId=-1,this._state=o.NONE,t===o.TOUCH_ROTATE&&e.touches.length===0&&e.changedTouches&&e.changedTouches.length===1&&E&&T!==void 0){let t=e.changedTouches[0];this.pointer_x_start==t.clientX-E.left&&this.pointer_y_start==t.clientY-E.top&&T.pick(this,t.clientX,t.clientY,this.renderer)}},de=()=>{V(!0)},V=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)}},fe=e=>{V(!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()},pe=e=>{V(!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()},me=e=>{this._state=o.NONE},he=()=>{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),re(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)=>{L=!0;let n=this.getVectorsFromRotateAboutLookAtPoints(e,t);this.cameraObject.position.copy(n.position),this.updateDirectionalLight(),this.cameraObject.up.copy(n.up)};let ge=()=>{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},_e=()=>{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=N.copy(this.cameraObject.position);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,ne()&&(this.cameraObject.position.copy(I),this.updateDirectionalLight(),ee(i),L=!0))}};let ve=()=>{let e=_e();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=()=>{L=!0,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&&(te(this.domElement,0),this.domElement.addEventListener(`mousedown`,ie,!1),this.domElement.addEventListener(`mousemove`,ae,!1),this.domElement.addEventListener(`mouseup`,oe,!1),this.domElement.addEventListener(`mouseleave`,se,!1),this.domElement.addEventListener(`touchstart`,ce,!1),this.domElement.addEventListener(`touchmove`,le,!1),this.domElement.addEventListener(`touchend`,ue,!1),this.domElement.addEventListener(`wheel`,fe,!1),this.domElement.addEventListener(`mouseenter`,de,!1),this.domElement.addEventListener(`contextmenu`,e=>{e.preventDefault()},!1),this.domElement.addEventListener(`keydown`,pe,!1),this.domElement.addEventListener(`keyup`,me,!1))},this.disable=function(){d=!1,this._state=o.NONE,this.domElement&&this.domElement.removeEventListener&&(this.domElement.removeEventListener(`mousedown`,ie,!1),this.domElement.removeEventListener(`mousemove`,ae,!1),this.domElement.removeEventListener(`mouseup`,oe,!1),this.domElement.removeEventListener(`mouseleave`,se,!1),this.domElement.removeEventListener(`touchstart`,ce,!1),this.domElement.removeEventListener(`touchmove`,le,!1),this.domElement.removeEventListener(`touchend`,ue,!1),this.domElement.removeEventListener(`wheel`,fe,!1),this.domElement.removeEventListener(`mouseenter`,de,!1),this.domElement.removeEventListener(`contextmenu`,e=>{e.preventDefault()},!1),this.domElement.removeEventListener(`keydown`,pe,!1),this.domElement.removeEventListener(`keyup`,me,!1),te(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 ye=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=>{L=!0,m>2&&(f=u*e/(m-1),f<0&&(f=0),f>u&&(f=u))};let be=e=>{if(y===a.PATH&&(ye(e),p)){let e=this.getCurrentTimeFrame(),t=e[0],n=e[1],r=e[2],i=t*3,a=n*3,o=r*p[i]+(1-r)*p[a],s=r*p[i+1]+(1-r)*p[a+1],c=r*p[i+2]+(1-r)*p[a+2];this.cameraObject.position.set(o,s,c),this.cameraObject.target.set(p[a],p[a+1],p[a+2]),_&&this.cameraObject.lookAt(this.cameraObject.target),h&&(this.directionalLight.position.set(o,s,c),this.directionalLight.target.position.set(p[a],p[a+1],p[a+2]))}};this.calculatePathNow=()=>{L=!0,be(0)};let xe=()=>{this._state===o.ROTATE||this._state===o.TOUCH_ROTATE||this._state===o.KEYBOARD_ROTATE?ge():this._state===o.PAN||this._state===o.TOUCH_PAN||this._state===o.KEYBOARD_PAN?(he(),R.triggerCallback()):(this._state===o.ZOOM||this._state===o.TOUCH_ZOOM||this._state===o.SCROLL||this._state===o.KEYBOARD_ZOOM)&&(R.zoom(_e()),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,R.triggerCallback())};this.update=e=>{let t=e*g,n=d,r=!0;return y===a.PATH?be(t):y===a.SMOOTH_CAMERA_TRANSITION&&b?(b.update(t),b.isTransitionCompleted()&&(b=void 0,y=a.DEFAULT),n=!1):y===a.ROTATE_TRANSITION&&x?(x.update(t),x.isTransitionCompleted()&&(x=void 0,y=a.DEFAULT),n=!1):y===a.AUTO_TUMBLE&&S?S.update(t):y===a.SYNC_CONTROL&&R?(xe(),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?ge():this._state===o.PAN||this._state===o.TOUCH_PAN||this._state===o.KEYBOARD_PAN?he():(this._state===o.ZOOM||this._state===o.TOUCH_ZOOM||this._state===o.SCROLL||this._state===o.KEYBOARD_ZOOM)&&ve(),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||=L,L=!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 zt(this.cameraObject)},this.disableDeviceOrientation=()=>{_&&=(_.dispose(),void 0)},this.isDeviceOrientationEnabled=()=>!!_,this.resetView=()=>{L=!0;let e=B[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(),L=!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 jt;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 jt;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 Nt(e,t,this,n))},this.rotateCameraTransition=(e,t,n)=>{b??(x=new Pt(e,t,this,n))},this.enableCameraTransition=()=>{b&&(y=a.SMOOTH_CAMERA_TRANSITION),x&&(y=a.ROTATE_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_TRANSITION,this.autoTumble=(e,t,n)=>{S=new It(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 Ft(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,R||=new Bt,R.setCurrentCameraSettings(this.cameraObject,B[v]),R),this.disableSyncControl=()=>{y=a.DEFAULT,this.cameraObject.zoom=1,this.cameraObject.updateProjectionMatrix()},this.enable()},Nt=function(e,t,n,r){let i=e.eyePosition,a=e.targetPosition,o=t.eyePosition,s=t.targetPosition,c=n,l=r,u=0,d=!1;c.near=Math.min(e.nearPlane,t.nearPlane),c.far=Math.max(e.farPlane,t.farPlane),c.cameraObject.up.set(t.upVector[0],t.upVector[1],t.upVector[2]),this.setDuration=e=>{l=e};let f=e=>{let t=u+e;t>l&&(t=l),u=t},p=()=>{let e=u/l,t=1-e;c.cameraObject.position.set(i[0]*t+o[0]*e,i[1]*t+o[1]*e,i[2]*t+o[2]*e),c.cameraObject.target.set(a[0]*t+s[0]*e,a[1]*t+s[1]*e,a[2]*t+s[2]*e)};this.update=e=>{this.enabled!==!1&&(f(e),p(),u==l&&(d=!0))},this.isTransitionCompleted=()=>d},Pt=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},Ft=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=!1,x;this.enable=()=>{d=!0},this.disable=()=>{d=!1},this.getIntersectsObject=e=>{s!==o&&o.getThreeJSScene().updateMatrixWorld();let t=x||o.getPickableThreeJSObjects();return v.length=0,f.intersectObjects(t,!0,v)},this.setPickableObjects=e=>{e===void 0?x=void 0:(x=[],e.forEach(e=>{e.getGroup()&&e.getGroup().visible&&x.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),s?.invalidate?.()}};let S=(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),s?.invalidate?.()}};this.move=(e,t,n)=>{d&&c&&o&&e&&u&&(y.zincCamera=e,y.x=t,y.y=n,o.displayMarkers?typeof requestAnimationFrame==`function`?b||(b=!0,requestAnimationFrame(()=>{b=!1,S(y.zincCamera,y.x,y.y)})):S(e,t,n):m||(_=h?Date.now()-h.getTime():250,_>=250?S(e,t,n):(m=!0,setTimeout(C(y),250-_))))};let C=e=>function(){m=!1,S(e.zincCamera,e.x,e.y)}},It=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))}},Lt=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(Lt.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.MathUtils.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 Rt=function(e){let t=new Lt;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)}},zt=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)),a=new e.Vector3,o=new e.Quaternion;return(e,s,c,l,u)=>{a.subVectors(e.target,e.position),n.set(c,s,-l,`YXZ`),o.setFromEuler(n),o.multiply(i),o.multiply(r.setFromAxisAngle(t,-u)),a.applyQuaternion(o),a.addVectors(e.position,a),e.lookAt(a)}})();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.MathUtils.degToRad(n.deviceOrientation.alpha):0,r=n.deviceOrientation.beta?e.MathUtils.degToRad(n.deviceOrientation.beta):0,i=n.deviceOrientation.gamma?e.MathUtils.degToRad(n.deviceOrientation.gamma):0,o=n.screenOrientation?e.MathUtils.degToRad(n.screenOrientation):0;a(n.object,t,r,i,o)},this.dispose=function(){this.disconnect()},this.connect()},Bt=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()}},Vt=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`,b);Vt.colorSpace=e.SRGBColorSpace;var Ht=[.02,.03,1],Ut=new e.SpriteMaterial({map:Vt,alphaTest:.5,transparent:!0,depthTest:!1,depthWrite:!1,sizeAttenuation:!1}),Wt=function(t){H.call(this),this.texture=Vt;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(Ut);return r.clusterIndex=t,r.center.set(.5,0),r.position.set(0,0,0),r.renderOrder=1e4,r.scale.set(Ht[0],Ht[1],Ht[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),L(e.label),e.label.material.map.dispose(),e.label.material.dispose()),e.label=ge(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),n?.invalidate?.(),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};Wt.prototype=Object.create(H.prototype);var Gt=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,l=new e.Vector3,u=new e.Vector3,d=new e.Vector3,f=[new e.Vector3,new e.Vector3,new e.Vector3,new e.Vector3],p=[f[0],f[1],f[2],f[2],f[3],f[0]],m=new e.Box3,h=new e.Matrix4,g=new e.Matrix4,_,v=!1,y=(e,t)=>{for(let n=0;n<16;n++)if(!Object.is(e.elements[n],t.elements[n]))return!1;return!0};this.getDiffFromNormalised=(t,n)=>(s.setFromBufferAttribute(a).getCenter(c),l.copy(c).project(this.camera),new e.Vector3(t,n,l.z).unproject(this.camera).sub(c));let b=(e,t)=>{n.camera.near&&(this.camera.near=n.camera.near),t.farPlane&&(this.camera.far=t.farPlane),t.eyePosition&&this.camera.position.set(t.eyePosition[0],t.eyePosition[1],t.eyePosition[2]),t.upVector&&this.camera.up.set(t.upVector[0],t.upVector[1],t.upVector[2]),t.targetPosition&&this.camera.lookAt(u.set(t.targetPosition[0],t.targetPosition[1],t.targetPosition[2])),this.camera.zoom=1/e,this.camera.updateProjectionMatrix()};this.getBoundary=()=>{let e=n.camera;d.copy(e.target).project(e),f[0].set(-1,-1,d.z).unproject(e),f[1].set(1,-1,d.z).unproject(e),f[2].set(1,1,d.z).unproject(e),f[3].set(-1,1,d.z).unproject(e),ye(a,p)},this.updateCamera=()=>{let e=n.camera,t=n.getBoundingBox();if(v&&t&&t.equals(m)&&_===e.near&&y(h,e.matrixWorld)&&y(g,e.projectionMatrix))return;this.getBoundary(),h.copy(e.matrixWorld),g.copy(e.projectionMatrix),_=e.near,v=!1;let r=n.getZincCameraControls();if(t){m.copy(t),v=!0;let e=t.min.distanceTo(t.max),n=e/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=r.getViewportFromCentreAndRadius(i,a,o,n,40,n*4);b(e,s)}}},Kt=new e.Box3,qt=new e.Vector3,Jt=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),Kt.setFromBufferAttribute(n),this.boundingBox.union(Kt))}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++)qt.fromBufferAttribute(t,i),r=Math.max(r,e.distanceToSquared(qt)),qt.fromBufferAttribute(n,i),r=Math.max(r,e.distanceToSquared(qt));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(){}},Yt=new e.Vector3,Xt=new e.Vector3,W=new e.Vector4,G=new e.Vector4,K=new e.Vector4,Zt=new e.Vector3,Qt=new e.Matrix4,q=new e.Line3,$t=new e.Vector3,en=new e.Box3,tn=new e.Sphere,J=new e.Vector4,nn=new e.Vector4,Y,rn;function an(e,t,n){return J.set(0,0,-t,1).applyMatrix4(e.projectionMatrix),J.multiplyScalar(1/J.w),J.x=rn/n.width,J.y=rn/n.height,J.applyMatrix4(e.projectionMatrixInverse),J.multiplyScalar(1/J.w),Math.abs(Math.max(J.x,J.y))}function on(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++){q.start.fromBufferAttribute(a,i),q.end.fromBufferAttribute(o,i),q.applyMatrix4(r);let s=new e.Vector3,c=new e.Vector3;Y.distanceSqToSegment(q.start,q.end,c,s),c.distanceTo(s)<rn*.5&&n.push({point:c,pointOnLine:s,distance:Y.origin.distanceTo(c),object:t,face:null,faceIndex:i,uv:null,uv1:null})}}function sn(t,n,r){let i=n.projectionMatrix,a=t.matrixWorld,o=t._resolution,s=t.geometry,c=s.attributes.instanceStart,l=s.attributes.instanceEnd,u=Math.min(s.instanceCount,c.count),d=-n.near;Y.at(1,K),K.w=1,K.applyMatrix4(n.matrixWorldInverse),K.applyMatrix4(i),K.multiplyScalar(1/K.w),K.x*=o.x/2,K.y*=o.y/2,K.z=0,Zt.copy(K),Qt.multiplyMatrices(n.matrixWorldInverse,a);for(let n=0,s=u;n<s;n++){if(W.fromBufferAttribute(c,n),G.fromBufferAttribute(l,n),W.w=1,G.w=1,W.applyMatrix4(Qt),G.applyMatrix4(Qt),W.z>d&&G.z>d)continue;if(W.z>d){let e=W.z-G.z,t=(W.z-d)/e;W.lerp(G,t)}else if(G.z>d){let e=G.z-W.z,t=(G.z-d)/e;G.lerp(W,t)}W.applyMatrix4(i),G.applyMatrix4(i),W.multiplyScalar(1/W.w),G.multiplyScalar(1/G.w),W.x*=o.x/2,W.y*=o.y/2,G.x*=o.x/2,G.y*=o.y/2,q.start.copy(W),q.start.z=0,q.end.copy(G),q.end.z=0;let s=q.closestPointToPointParameter(Zt,!0);q.at(s,$t);let u=e.MathUtils.lerp(W.z,G.z,s),f=u>=-1&&u<=1,p=Zt.distanceTo($t)<rn*.5;if(f&&p){q.start.fromBufferAttribute(c,n),q.end.fromBufferAttribute(l,n),q.start.applyMatrix4(a),q.end.applyMatrix4(a);let i=new e.Vector3,o=new e.Vector3;Y.distanceSqToSegment(q.start,q.end,o,i),r.push({point:o,pointOnLine:i,distance:Y.origin.distanceTo(o),object:t,face:null,faceIndex:n,uv:null,uv1:null})}}}var cn=class extends e.Mesh{constructor(t=new Jt,n=new e.Line2NodeMaterial({color:Math.random()*16777215})){super(t,n),this.isLineSegments2=!0,this.type=`LineSegments2`,this._resolution=new e.Vector2}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)Yt.fromBufferAttribute(n,e),Xt.fromBufferAttribute(r,e),i[t]=t===0?0:i[t-1],i[t+1]=i[t]+Yt.distanceTo(Xt);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}onBeforeRender(e){e.getViewport(nn),this._resolution.set(nn.z,nn.w)}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._resolution.x===0||this._resolution.y===0))return;let i=e.params.Line2===void 0?0:e.params.Line2.threshold||0;Y=e.ray;let a=this.matrixWorld,o=this.geometry;rn=this.material.linewidth+i,o.boundingSphere===null&&o.computeBoundingSphere(),tn.copy(o.boundingSphere).applyMatrix4(a);let s;if(s=n?rn*.5:an(r,Math.max(r.near,tn.distanceToPoint(Y.origin)),this._resolution),tn.radius+=s,Y.intersectsSphere(tn)===!1)return;o.boundingBox===null&&o.computeBoundingBox(),en.copy(o.boundingBox).applyMatrix4(a);let c;c=n?rn*.5:an(r,Math.max(r.near,en.distanceToPoint(Y.origin)),this._resolution),en.expandByScalar(c),Y.intersectsBox(en)!==!1&&(n?on(this,t):sn(this,r,t))}},ln=function(){wt.call(this),this.isLines2=!0;let t=new Float32Array(300),n=e=>{if(e>t.length){let n=Math.ceil(Math.max(t.length*2,e)/6)*6,r=new Float32Array(n);return r.set(t),t=r,!0}return!1},r=(e,n)=>{for(let r=e;r+2<t.length;r+=3)t[r]=n[0],t[r+1]=n[1],t[r+2]=n[2]},i=e=>{let n=e.geometry,r=n.attributes.instanceDistanceStart,i=n.attributes.instanceStart;if(!r||r.data.array.length!==i.count*2){e.computeLineDistances();return}let a=r.data.array,o=0;for(let e=0;e<i.count;e++){let n=e*6,r=t[n+3]-t[n],i=t[n+4]-t[n+1],s=t[n+5]-t[n+2];a[e*2]=o,o+=Math.sqrt(r*r+i*i+s*s),a[e*2+1]=o}r.data.needsUpdate=!0},a=(e,n)=>{let r=e.geometry.getAttribute(`instanceStart`);n||!r||r.data.array!==t?(e.geometry.setPositions(t),e.computeLineDistances()):(r.data.needsUpdate=!0,i(e),e.geometry.computeBoundingBox(),e.geometry.computeBoundingSphere()),this.boundingBoxUpdateRequired=!0};this.createLineSegment=(e,t,n)=>{if(e&&t){let r=new Jt;r.setPositions(e),r.colorsNeedUpdate=!0;let i=new cn(r,t);i.scale.set(1,1,1),i.computeLineDistances(),this.setMesh(i,n.localTimeEnabled,n.localMorphColour)}},this.setWidth=e=>{this.requestRender(),this.morph&&this.morph.material&&(this.morph.material.linewidth=e,this.morph.material.needsUpdate=!0)},this.addVertices=function(e){if(this.requestRender(),e&&e.length){let i=this.getMorph();i||(this.drawRange=0);let o=this.drawRange*3,s=n(o+e.length*3);e.forEach(e=>{t[o++]=e[0],t[o++]=e[1],t[o++]=e[2],this.drawRange++}),i?(s&&r(o,e[0]),a(i,s)):r(o,e[0])}return t},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(e,n){if(this.requestRender(),e&&e.length){let i=this.getMorph(),o=n+e.length-1;if(!i||0>n||o>=this.drawRange)return;{let o=n*3;e.forEach(e=>{t[o++]=e[0],t[o++]=e[1],t[o++]=e[2]}),r(this.drawRange*3,e[0]),a(i,!1)}}return t},this.addLines=(n,r)=>{if(this.requestRender(),n&&n.length>0){if(this.addVertices(n),!this.getMorph()){let n=new e.Line2NodeMaterial({color:r,linewidth:1,vertexColors:!1,worldUnits:!1});this.createLineSegment(t,n,{localTimeEnabled:!1,localMorphColour:!1})}this.region&&(this.region.pickableUpdateRequired=!0)}}};ln.prototype=Object.create(wt.prototype),ln.prototype.constructor=ln;var un=0,dn=function(){return`re`+un++},fn=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=dn();let d=()=>{c?.invalidate?.()};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=>{d(),e!=i.visible&&(i.visible=e,this.pickableUpdateRequired=!0)},this.getVisibility=()=>i.visible,this.getGroup=()=>i,this.setTransformation=e=>{d(),l.set(...e),i.matrix.copy(l),te(i),i.updateMatrixWorld(!0),this.getAllObjects(!0).forEach(e=>{e.boundingBoxUpdateRequired=!0})},this.setName=e=>{e&&e!==``&&(o=e)},this.getName=()=>o,this.getParent=()=>r,this.getScene=()=>c,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=>{d();let t=new fn(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=>{d(),e&&(e.setRegion(this),i.add(e.getGroup()),s.push(e),this.pickableUpdateRequired=!0,c&&c.triggerObjectAddedCallback(e))},this.removeZincObject=e=>{d();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.clearPickableUpdateRequired=e=>{this.pickableUpdateRequired=!1,e&&a.forEach(t=>{t.clearPickableUpdateRequired(e)})},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):this.clearPickableUpdateRequired(t),e),this.setDuration=e=>{u=e,s.forEach(t=>t.setDuration(e)),a.forEach(t=>t.setDuration(e))},this.getDuration=()=>u,this.getBoundingBox=t=>{let n=new e.Box3;if(this.accumulateBoundingBox(n,t))return n},this.accumulateBoundingBox=(e,t)=>{let n=!1;for(let t=0;t<s.length;t++){let r=s[t].getBoundingBox();r&&(e.union(r),n=!0)}if(t)for(let r=0;r<a.length;r++)a[r].accumulateBoundingBox(e,t)&&(n=!0);return n},this.clear=e=>{d(),e&&a.forEach(t=>{t.clear(e),i.remove(t.getGroup())}),s.forEach(e=>{i.remove(e.getGroup()),e.dispose()}),e&&(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,t=[])=>{for(let e=0;e<s.length;e++)t.push(s[e]);if(e)for(let n=0;n<a.length;n++)a[n].getAllObjects(e,t);return 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(n=>{n.setMorphTime(e,t)})},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.renderObjects=(e,t,n,r,i)=>{for(let i=0;i<s.length;i++)s[i].render(e,t,n,r);if(i)for(let o=0;o<a.length;o++)a[o].renderObjects(e,t,n,r,i)},this.renderGeometries=(e,t,n,r,i,a)=>{this.renderObjects(e*t,n,r,i,a),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 Ct;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 ln;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 Ge,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}},pn=class{constructor(e){this.writer=e,this.name=`ZINC_morph_colour`}writeMesh(t,n){let r=t.geometry,i=r&&r.morphAttributes?r.morphAttributes.color:void 0,a=r?r.attributes.color:void 0,o=n.primitives?n.primitives[0]:void 0;if(!i||!a||!o||!o.targets)return;let s=o.targets,c=a.itemSize,l=a.count;for(let t=0;t<s.length&&t<i.length;t++){let n=i[t];if(n.itemSize!==c||n.count<l){console.warn(`GLTFExporter: Colour morph target does not match the base colour, skipped.`);return}let o=new Float32Array(l*c);for(let e=0;e<l;e++)for(let t=0;t<c;t++){let i=n.getComponent(e,t);o[e*c+t]=r.morphTargetsRelative?i:i-a.getComponent(e,t)}s[t].COLOR_0=this.writer.processAccessor(new e.BufferAttribute(o,c),r)}}},mn=function(e){let t=e,n=e=>{for(let t=e;t;t=t.parent)if(t.visible===!1)return!1;return!0};this.exportGLTF=async e=>{let r=t.getRootRegion().getAllObjects(!0),a=[],o=[];for(let e of r){if(e.animationClip&&e.animationClip[0]){let t=e.getMorph();if(t&&n(t)){let n=e.animationClip[0].clone();n.tracks.forEach(e=>{e.name=t.uuid+e.name}),a.push(n)}}e.isGlyphset&&e.prepareColorForExport&&(await e.prepareColorForExport(),o.push(e))}let s=pe(t.getThreeJSScene()),c=new i.GLTFExporter;c.register(e=>new pn(e));let l={binary:e,animations:a,onlyVisible:!0};try{return await new Promise((e,n)=>{c.parse(t.getThreeJSScene(),function(t){e(t)},function(e){console.error(`Unable to export GLTF.`,e),n(e)},l)})}finally{s(),o.forEach(e=>e.clearColorExportState())}}},hn=function(){let e=this,t=e=>{let t=e.geometry;if(!t||!t.morphAttributes)return;let n=[];if(e.morphTargetDictionary)for(let t in e.morphTargetDictionary)n[e.morphTargetDictionary[t]]=t;for(let e in t.morphAttributes){let r=t.attributes[e];t.morphAttributes[e].forEach((e,i)=>{if(t.morphTargetsRelative&&r){let t=e.array,n=r.array,i=Math.min(t.length,n.length);for(let e=0;e<i;e++)t[e]+=n[e];e.needsUpdate=!0}n[i]!==void 0&&(e.name=n[i])})}t.morphTargetsRelative=!1},n=e=>{let t=e=>(e.vertexColors=!1,xe(e));e.material=Array.isArray(e.material)?e.material.map(t):t(e.material)};this.parseGLTFObjects=(r,i,a,o)=>{let s=i;if(a!==0){if(r.type===`Object3D`){if(r.name!==``&&(i&&(s=i.findOrCreateChildFromPath(r.name)),s)){let e=s.getGroup();e.position.copy(r.position),e.rotation.copy(r.rotation),e.quaternion.copy(r.quaternion),e.matrixAutoUpdate=!0}}else{let e;if(r.type===`Mesh`?e=new Ge:r.type===`LineSegments`?e=new wt:r.type===`Points`&&(e=new Ct),e){let a=!1,s=!1;r.geometry&&r.geometry.morphAttributes&&(t(r),a=!!r.geometry.morphAttributes.position,s=!!r.geometry.morphAttributes.color);let c=r.clone();s&&!e.isPointset&&n(c),e.setMesh(c,a,s);let l=e.getMorph();e.groupName=l.name,l.matrixAutoUpdate=!0,i.addZincObject(e),o!=null&&typeof o==`function`&&o(e)}}}a++,r.children.forEach(t=>{e.parseGLTFObjects(t,s,a,o)})},this.setCamera=e=>{e.viewAll();let t=e.getZincCameraControls(),n=t.getCurrentViewport();t.addViewport(`default`,n),t.setDefaultViewport(`default`)},this.load=(t,n,r,i,o,s,c)=>{let l=r.substring(0,r.lastIndexOf(`/`)+1),u=r.substring(r.lastIndexOf(`/`)+1,r.length);new a.GLTFLoader().setPath(l).load(u,function(r){c&&c()||(console.log(r),e.parseGLTFObjects(r.scene,n,0,i),e.setCamera(t),o!=null&&typeof o==`function`&&o())})}},gn=/^[og]\s*(.+)?/,_n=/^mtllib /,vn=/^usemtl /,yn=/^usemap /,bn=new e.Vector3,xn=new e.Vector3,Sn=new e.Vector3,Cn=new e.Vector3,X=new e.Vector3;function wn(){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;bn.fromArray(r,e),xn.fromArray(r,t),Sn.fromArray(r,n),X.subVectors(Sn,xn),Cn.subVectors(bn,xn),X.cross(Cn),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 Tn=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 wn;t.indexOf(`\r
|
|
1
|
+
(function(e,t){typeof exports==`object`&&typeof module<`u`?module.exports=t(require("three/webgpu"),require("three-spritetext"),require("three/tsl"),require("css-element-queries"),require("three/examples/jsm/exporters/GLTFExporter"),require("three/examples/jsm/loaders/GLTFLoader"),require("fflate")):typeof define==`function`&&define.amd?define([`three/webgpu`,`three-spritetext`,`three/tsl`,`css-element-queries`,`three/examples/jsm/exporters/GLTFExporter`,`three/examples/jsm/loaders/GLTFLoader`,`fflate`],t):(e=typeof globalThis<`u`?globalThis:e||self,e.Zinc=t(e.THREE,e.SpriteText,e.THREE,e.cssElememtQueries,e.GLTFExporter,e.GLTFLoader,e.fflate))})(this,function(e,t,n,r,i,a,o){var s=Object.create,c=Object.defineProperty,l=Object.getOwnPropertyDescriptor,u=Object.getOwnPropertyNames,d=Object.getPrototypeOf,f=Object.prototype.hasOwnProperty,p=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=u(t),a=0,o=i.length,s;a<o;a++)s=i[a],!f.call(e,s)&&s!==n&&c(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=l(t,s))||r.enumerable});return e},m=(e,t,n)=>(n=e==null?{}:s(d(e)),p(t||!e||!e.__esModule||!f.call(e,`default`)?c(n,`default`,{value:e,enumerable:!0}):n,e));e=m(e,1),t=m(t,1);var h={name:`zincjs`,version:`2.4.1-beta.7`,description:`ZincJS (Web-based-Zinc-Visualisation)`,type:`module`,main:`build/zinc.js`,engines:{node:`^24.20.0`},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/`,allowScripts:{"msw@2.14.6":!0},devDependencies:{"@vitest/coverage-v8":`^4.1.11`,"auto-changelog":`^2.4.0`,chai:`^4.1.0`,"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`,webgpu:`^0.4.0`},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`}},g=`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==`,_=new Set,v=e=>{_.add(e)},y=e=>{_.delete(e)},b=()=>{_.forEach(e=>e())},x=t.default.default||t.default,S=1.5,C=16,w=256,T=.1,E=1e3/(2*Math.tan(20*Math.PI/180)),D=new Set,O=!1,k=e=>{let t=Math.round(e*E*S);return Math.min(Math.max(t,C),w)},A=t=>{let n=t.material?.map;n&&(n.generateMipmaps=!1,n.minFilter=e.LinearFilter,n.magFilter=e.LinearFilter,n.anisotropy=1)},j=(e,t,n,r)=>{`_fontFace`in e&&typeof e._genCanvas==`function`?(e._fontFace=t,e._fontSize=n,e._fontWeight=r,e._genCanvas()):(e.fontFace=t,e.fontSize=n,e.fontWeight=r)},M=(e,t=!1)=>{let n=k(e.textHeight);(t||n!==e.fontSize)&&(j(e,e.fontFace,n,e.fontWeight),A(e))},N=e=>{D.forEach(t=>{let n=t.deref();n?e(n):D.delete(t)})},P=()=>{N(e=>M(e,!0)),b()},F=e=>{if(typeof document>`u`||!document.fonts)return;!O&&document.fonts.addEventListener&&(document.fonts.addEventListener(`loadingdone`,P),O=!0);let t=`${e.fontWeight} ${e.fontSize}px ${e.fontFace}`;try{document.fonts.check(t)||document.fonts.load(t).then(()=>{M(e,!0),b()}).catch(()=>{})}catch{}},I=e=>{D.add(new WeakRef(e))},L=e=>{D.forEach(t=>{let n=t.deref();(!n||n===e)&&D.delete(t)})},R=(t,n,r,i,a)=>{let o=r?new x(t,n,r):new x(t,n);j(o,i,k(n),a);let s=o.material;return o.material=new e.SpriteNodeMaterial({map:s.map}),s.map=null,s.dispose(),o.material.sizeAttenuation=!1,A(o),I(o),F(o),o},z=(e,t)=>{`_textHeight`in e?(e._textHeight=t,M(e,!0)):(e.textHeight=t,M(e))},B=e=>{!(e>0)||!isFinite(e)||Math.abs(e/E-1)>T&&(E=e,N(e=>M(e)),b())};function ee(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 te(e){return e.parent&&te(e.parent),e.matrixAutoUpdate&&e.updateMatrix(),e.matrixWorldAutoUpdate!==!1&&(e.parent?e.matrixWorld.multiplyMatrices(e.parent.matrixWorld,e.matrix):e.matrixWorld.copy(e.matrix)),e.matrixWorld}function ne(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),t.applyMatrix4(te(e))}function re(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 ie(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++)re(e[t],t,o,n)}var ae=(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]},oe=new WeakMap,se=function(t,n){if(n&&t&&t.morphAttributes&&t.morphAttributes.color){let r=t.morphAttributes.color,i=n.morphTargetInfluences,a=i.length,o=0,s=0,c=0,l=0,u=0;for(let e=0;e<a&&o<2;e++)i[e]>0&&(o===0?(s=c=e,l=i[e]):(c=e,u=i[e]),o++);let d=0;if(o>=2){let e=l+u;d=e>0?u/e:0}let f=t.getAttribute(`morphColor0`),p=t.getAttribute(`morphColor1`);(!f||!p)&&(f=new e.Float32BufferAttribute(new Float32Array(r[0].array.length),r[0].itemSize),p=new e.Float32BufferAttribute(new Float32Array(r[0].array.length),r[0].itemSize),f.setUsage(e.DynamicDrawUsage),p.setUsage(e.DynamicDrawUsage),t.setAttribute(`morphColor0`,f),t.setAttribute(`morphColor1`,p));let m=r[s],h=r[c];oe.get(f)!==m&&(f.array.set(m.array),f.needsUpdate=!0,oe.set(f,m)),oe.get(p)!==h&&(p.array.set(h.array),p.needsUpdate=!0,oe.set(p,h));let g=n.material&&n.material.userData&&n.material.userData.uniforms&&n.material.userData.uniforms.morphColorMix;g&&(g.value=d)}},ce=e=>{let t=e.clone();return t.colorsNeedUpdate=!0,t.computeBoundingBox(),t.computeBoundingSphere(),e._video&&(t._video=e._video),t};function le(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 ue=(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=le(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=le(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 de(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}}var V=class extends Uint16Array{};function fe(e){let t=e?.index;if(t&&t.array.constructor===Uint16Array){let e=t.array;t.array=new V(e.buffer,e.byteOffset,e.length)}}function pe(e){let t=[];return e.traverse(e=>{let n=e.geometry?.index;if(n&&n.array instanceof V){let e=n.array;n.array=new Uint16Array(e.buffer,e.byteOffset,e.length),t.push([n,e,n.array])}}),()=>{t.forEach(([e,t,n])=>{e.array===n&&(e.array=t)})}}var me=void 0;function he(){if(me)return me;let t=new Image,n=new e.Texture;return n.image=t,t.onload=()=>{n.needsUpdate=!0,b()},t.src=g,t.complete&&t.naturalWidth>0&&(n.needsUpdate=!0),me=n,n}function ge(e,t,n,r,i,a){let o=R(e,t,n,r,a);return o.material.alphaTest=.05,o.material.transparent=!0,o.material.depthWrite=!1,o.material.depthTest=!1,o.center.set(.5,-1.2),o.renderOrder=10001,o}function _e(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 ve(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=n.array;if(a.length<s+c)return!1;if(r)a.copyWithin(s,s+c),a.fill(0,a.length-c),n.needsUpdate=!0;else{let n=new a.constructor(a.length-c);n.set(a.subarray(0,s)),n.set(a.subarray(s+c),s),t.setAttribute(i,new e.BufferAttribute(n,o)),t.getAttribute(i).needsUpdate=!0}return!0};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 ye(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}var be={MeshBasicMaterial:e.MeshBasicNodeMaterial,MeshLambertMaterial:e.MeshLambertNodeMaterial,MeshPhongMaterial:e.MeshPhongNodeMaterial,MeshStandardMaterial:e.MeshStandardNodeMaterial,LineBasicMaterial:e.LineBasicNodeMaterial},xe=t=>{let r=t;r.isNodeMaterial||(r=new(be[t.type]||e.MeshBasicNodeMaterial),r.copy(t));let i=(0,n.uniform)(0);return r.colorNode=(0,n.Fn)(()=>{let e=(0,n.attribute)(`morphColor0`,`vec3`),t=(0,n.attribute)(`morphColor1`,`vec3`),r=(0,n.mix)(e,t,i);return(0,n.vec4)(r.mul(n.materialColor),n.materialOpacity)})(),r.userData.uniforms={...r.userData.uniforms,morphColorMix:i},r},Se=new e.Vector3,Ce=new e.Vector3,we=new e.Matrix4,Te=new e.Ray,Ee=new e.Sphere,De=new e.Vector3,Oe=new e.Vector3,ke=new e.Vector3,Ae=new e.Vector3,je=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++)Se.fromBufferAttribute(n,e-1),Ce.fromBufferAttribute(n,e),r[e]=r[e-1],r[e]+=Se.distanceTo(Ce);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(),Ee.copy(r.boundingSphere),Ee.applyMatrix4(i),Ee.radius+=a,t.ray.intersectsSphere(Ee)===!1)return;we.copy(i).invert(),Te.copy(t.ray).applyMatrix4(we);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(Me(u,d,this,i,s,r,a),Te.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(Me(u,d,this,i,s,a,a+1),Te.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 Me(e,t,n,r,i,a,o){e.fromBufferAttribute(r,a),t.fromBufferAttribute(r,o);var s=n.morphTargetInfluences;if(i&&s){De.set(0,0,0),Oe.set(0,0,0);for(var c=0,l=i.length;c<l;c++){var u=s[c],d=i[c];u!==0&&(ke.fromBufferAttribute(d,a),Ae.fromBufferAttribute(d,o),De.addScaledVector(ke.sub(e),u),Oe.addScaledVector(Ae.sub(t),u))}e.add(De),t.add(Oe)}}je.prototype.isLine=!0;var Ne=new e.Vector3,Pe=new e.Vector3,Fe=class extends je{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)Ne.fromBufferAttribute(n,e),Pe.fromBufferAttribute(n,e+1),r[e]=e===0?0:r[e-1],r[e+1]=r[e]+Ne.distanceTo(Pe);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}};Fe.prototype.isLineSegments=!0;var Ie=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._disposed=!1,this.addLevel=(e,t)=>{if(e){fe(e.geometry);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){fe(e.geometry);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._parent?.requestRender?.()}},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._disposed=!0,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=>{if(this._disposed){n.dispose();return}let r=this._material,i=ce(n,{localTimeEnabled:this._parent.timeEnabled,localMorphColour:this._parent.morphColour,isLines:this._parent.isLines}),a;this._parent.isGeometry?a=new e.Mesh(i,r):this._parent.isLines&&(a=new Fe(i,r)),a.userData=this._parent,a.renderOrder=this._renderOrder,n.dispose(),this.levelLoaded(a,t)}},this.updateMorphColorAttribute=e=>{if(this._material&&this._material.userData&&this._material.userData.uniforms&&this._material.userData.uniforms.morphColorMix){if(e){let e=this.getCurrentMorph();se(e.geometry,e)}else this.levels.forEach(e=>{e.morph&&e.morph.geometry&&se(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(),void 0),(t.transparent||this.levels.some(e=>e.secondaryMesh))&&(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._parent?.requestRender?.())}},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)})}},Le=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`,b);Le.colorSpace=e.SRGBColorSpace;var Re=[.02,.03,1],ze=new e.SpriteMaterial({map:Le,alphaTest:.5,transparent:!0,depthTest:!1,depthWrite:!1,sizeAttenuation:!1}),Be=function(t){Object.getPrototypeOf(this)!==H.prototype&&Object.setPrototypeOf(Be.prototype,H.prototype),H.call(this),this.texture=Le;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(ze),n.center.set(.5,0),this.morph.add(n),this.morph.position.set(0,0,0),this.morph.renderOrder=1e4,n.scale.set(Re[0],Re[1],Re[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),this.parent?.requestRender?.()},n.src=e}else this.setUserSprite()}},this.dispose=()=>{this.morph&&this.morph.clear(),n&&=(n.clear(),void 0),u&&=(L(u),u.material.map.dispose(),u.material.dispose(),void 0)},this.isEnabled=()=>c,this.setNumber=e=>{(!e||l!=e)&&(u&&=(this.morph.remove(u),L(u),u.material.map.dispose(),u.material.dispose(),void 0)),!u&&e&&(u=ge(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()},Ve=0,He=function(){return`pr`+Ve++},H=function(){this.isZincObject=!0,this.geometry=void 0,this.morph=void 0,this.group=new e.Group,this._lod=new Ie(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=He(),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};H.prototype.setDuration=function(e){this.duration=e,this.clipAction&&this.clipAction.setDuration(this.duration)},H.prototype.getDuration=function(){return this.duration},H.prototype.setRegion=function(e){this.region=e},H.prototype.getRegion=function(){return this.region},H.prototype.requestRender=function(){this.region?.getScene?.()?.invalidate?.()},H.prototype.getMorph=function(){return this._lod.getCurrentMorph()||this.morph},H.prototype.getGroup=function(){return this.group},H.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)},H.prototype.checkTransparentMesh=function(){},H.prototype.setMesh=function(t,n,r){this.requestRender(),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.mixer.update(0)))}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.morphColour&&this.initiateMorphColor(),this.boundingBoxUpdateRequired=!0},H.prototype.setIsPickable=function(e){this.isPickable!==e&&(this.isPickable=e,this.region&&(this.region.pickableUpdateRequired=!0))},H.prototype.setAnatomicalId=function(e){this.anatomicalId=e},H.prototype.setName=function(e){this.groupName=e,this._lod.setName(e)},H.prototype.getCurrentTime=function(){if(this.clipAction){let e=this.clipAction.time/this.clipAction._clip.duration;return this.duration*e}return this.inbuildTime},H.prototype.setMorphTime=function(e){this.requestRender();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.hasMorphPositions()&&(this.boundingBoxUpdateRequired=!0),this._lod.updateMorphColorAttribute(!0),this.timeEnabled&&(this.markerUpdateRequired=!0))},H.prototype.isTimeVarying=function(){return!!(this.timeEnabled||this.morphColour)},H.prototype.getVisibility=function(){return this.visible},H.prototype.setVisibility=function(e){this.requestRender(),e!==this.visible&&(this.visible=e,this.group.visible=e,this.region&&(this.region.pickableUpdateRequired=!0))},H.prototype.setAlpha=function(e){this.requestRender();let t=this._lod._material,n=!1;e<1&&(n=!0),t.opacity=e,t.transparent=n,this.checkTransparentMesh()},H.prototype.setFrustumCulled=function(e){this.requestRender(),this._lod.setFrustumCulled(e)},H.prototype.setVertexColors=function(e){this.requestRender(),this._lod.setVertexColors(e)},H.prototype.getColour=function(){if(this._lod._material)return this._lod._material.color},H.prototype.setColour=function(e){this.requestRender(),this._lod.setColour(e)},H.prototype.setGreyScale=function(t){if(this.requestRender(),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},H.prototype.getColourHex=function(){if(!this.morphColour&&this._lod._material&&this._lod._material.color)return this._lod._material.color.getHexString()},H.prototype.setColourHex=function(e){this.requestRender(),this._lod._material.color.setHex(e),this._lod._secondaryMaterial&&this._lod._secondaryMaterial.color.setHex(e)},H.prototype.setEmissiveRGB=function(e){this.requestRender(),this._lod._material&&this._lod._material.emissive&&this._lod._material.emissive.setRGB(...e),this._lod._secondaryMaterial&&this._lod._secondaryMaterial.emissive.setRGB(...e)},H.prototype.setMaterial=function(e){this.requestRender(),this._lod.setMaterial(e)},H.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.distanceToSquared(this._v1),(t==-1||t>r)&&(t=r,e=i)}}return e},H.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},H.prototype.getBoundingBox=function(){if(this.visible){let e=this._lod.getCurrentMorph();if(e&&e.visible)return this.boundingBoxUpdateRequired&&=(ne(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}},H.prototype.dispose=function(){this._lod.dispose(),this.marker&&=(this.marker.dispose(),void 0),this.animationGroup=void 0,this.mixer=void 0,this.morph=void 0,this.group=void 0,this.clipAction=void 0,this.groupName=void 0},H.prototype.markerIsRequired=function(e){return!!(this.visible&&(this.markerMode===`on`||e&&e.displayMarkers&&this.markerMode===`inherited`))};var Ue=new WeakMap;H.prototype.hasMorphPositions=function(){let e=this.getMorph()?.geometry,t=e?.morphAttributes?.position;if(!t||t.length===0)return!1;let n=Ue.get(e);if(n&&n.morphPositions===t)return n.result;let r=e.getAttribute(`position`)?.array,i=!1;for(let e=0;e<t.length&&!i;e++){let n=t[e].array;if(!r||n.length!==r.length)i=!0;else if(n!==r){for(let e=0;e<n.length;e++)if(n[e]!==r[e]){i=!0;break}}}return Ue.set(e,{morphPositions:t,result:i}),i},H.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 t=this.getClosestVertex(!1);t&&(this.marker.setPosition(t.x,t.y,t.z),this.markerUpdateRequired=!1,e=!0)}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&&(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},H.prototype.processMarkerVisual=function(e,t){this.marker&&this.marker.isEnabled()&&this.marker.updateVisual(e,t)},H.prototype.initiateMorphColor=function(){this.morphColour==1&&this._lod.updateMorphColorAttribute(!1)},H.prototype.setRenderOrder=function(e){this.requestRender(),this._lod.setRenderOrder(e)},H.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}}},H.prototype.setMarkerMode=function(e,t){this.requestRender(),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)},H.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.hasMorphPositions()&&(this.boundingBoxUpdateRequired=!0),this.morphColour==1&&this._lod.updateMorphColorAttribute(!0))}this.updateMarker(t,r)},H.prototype.addLOD=function(e,t,n,r,i){this._lod.addLevelFromURL(e,t,n,r,i)},H.prototype.addVertices=function(e){this.requestRender();let t=this.getMorph(),n;if(!t)n=de(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},H.prototype.deleteVertices=function(e){this.requestRender();let t=this.getMorph();return t?.geometry&&this.drawRange>=e&&ve(t.geometry,e,!0)?(--this.drawRange,t.geometry.setDrawRange(0,this.drawRange),t.geometry.computeBoundingBox(),t.geometry.computeBoundingSphere(),this.boundingBoxUpdateRequired=!0,!0):!1},H.prototype.setPosition=function(e,t,n){this.requestRender();let r=this.getGroup();r&&(r.position.set(e,t,n),r.matrixWorldNeedsUpdate=!0,r.updateMatrix(),r.updateWorldMatrix(!0,!0),this.boundingBoxUpdateRequired=!0)},H.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))},H.prototype.setScaleAll=function(e){this.requestRender();let t=this.getGroup();t&&(t.scale.set(e,e,e),t.updateMatrix(),this.boundingBoxUpdateRequired=!0)};var We=(t,n,r)=>{let i=ce(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=!1,o=xe(o));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)},Ge=function(){H.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=We(e,t,n);this.videoHandler=r.geometry._video,this.setMesh(r,n.localTimeEnabled,n.localMorphColour)},this.checkTransparentMesh=function(){this._lod.checkTransparentMesh()},this.setWireframe=e=>{this.requestRender(),this.morph.material.wireframe=e},this.editVertices=function(e,t){if(this.requestRender(),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)}};Ge.prototype=Object.create(H.prototype);var Ke=function(e,t){let n=e,r,i=1,a=500,o=.012;r=R(n,o,t?t.getStyle():void 0,`Asap`,a),r.center.x=-.05,r.center.y=0;let s=()=>{A(r)};this.getPosition=()=>r?[r.position.x,r.position.y,r.position.z]:[0,0,0],this.setPosition=(e,t,n)=>{r&&r.position.set(e,t,n)},this.setColour=e=>{if(e){let t=e.getStyle();t!==r.color&&(r.color=t,s())}},this.setScale=e=>{r&&e>0&&r.scale.set(e,e,1)},this.setDepthTest=e=>{e&&e!==r.material.depthTest&&(r.material.depthTest=e)},this.setSize=e=>{e>0&&(z(r,o*e),i=e)},this.setFontWeight=e=>{e&&e!==a&&(r.fontWeight=e,s(),a=e)},this.setText=e=>{if(e&&e!==r.text){if(r._canvas,r.material&&r.material.map&&r.material.map.dispose(),r._canvas){let e=r._canvas.getContext(`2d`);e&&e.clearRect(0,0,r._canvas.width,r._canvas.height),r._canvas.width=1,r._canvas.height=1}r.text=e,z(r,o*i),n=e,r.material&&r.material.map&&(s(),r.material.map.needsUpdate=!0)}},this.setVisibility=e=>{r.visible=e},this.dispose=()=>{r&&(L(r),r.removeFromParent(),r.material&&(r.material.map?.dispose(),r.material.dispose()),r._canvas&&(r._canvas.width=0,r._canvas.height=0))},this.getSprite=()=>r,this.getString=()=>n},qe=function(t,n,r,i){H.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],u;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=>{o?.requestRender?.(),e&&(typeof e==`string`||e instanceof String)&&(c=e,this.morph&&(this.morph.name=e))},this.showLabel=e=>{if(o?.requestRender?.(),s&&=(l=s.getPosition(),this.group.remove(s.getSprite()),s.dispose(),void 0),c&&(typeof c==`string`||c instanceof String)){s=new Ke(c,u||e),s.setPosition(l[0],l[1],l[2]);let t=s.getSprite();t.material.alphaTest=.05,t.material.transparent=!0,t.material.depthWrite=!1,this.group.add(s.getSprite())}},this.hideLabel=()=>{o?.requestRender?.(),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)=>{o?.requestRender?.(),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=>{o?.requestRender?.(),u=e?e.clone():void 0,s&&s.setColour(e),this.secondaryMesh&&this.secondaryMesh.material&&(this.secondaryMesh.material.color=e),this.geometry&&(this.geometry.colorsNeedUpdate=!0)},this.getColour=()=>u,this.dispose=()=>{s&&=(s.dispose(),void 0),this.material&&this.material.dispose(),this.morph=void 0}};qe.prototype=Object.create(H.prototype);function Je(){}Je.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(Je.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=Je.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 Ye=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.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()},Xe=e.BufferAttribute,Ze=e.BufferGeometry,Qe=e.Color,$e=e.DefaultLoadingManager,et=e.FileLoader,tt=e.Float32BufferAttribute,nt=e.LoaderUtils;function rt(e){typeof e==`boolean`&&(console.warn(`THREE.JSONLoader: showStatus parameter has been removed from constructor.`),e=void 0),this.manager=e===void 0?$e:e,this.withCredentials=!1,this.paramsString=``}Object.assign(rt.prototype,{load:function(e,t,n,r){var i=this,a=this.texturePath&&typeof this.texturePath==`string`?this.texturePath:nt.extractUrlBase(e),o=new et(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){return e&1<<t}function n(e){let n=e.faces,r=0;if(e.uvs!==void 0)for(let t=0;t<e.uvs.length;t++)e.uvs[t].length&&r++;let i=[],a=[],o=0,s=n.length;for(;o<s;){let e=n[o++],s=t(e,0),c=t(e,1),l=t(e,3),u=t(e,4),d=t(e,5),f=t(e,6),p=t(e,7),m,h,g;if(s){let e=n[o],t=n[o+1],s=n[o+2],m=n[o+3];o+=4;let h=0;c&&(h=n[o++]),l&&(o+=r*4),u&&(o+=1),d&&(o+=4),f&&(o+=1),p&&(o+=4),i.push(e,t,m),a.push(h),i.push(t,s,m),a.push(h);continue}m=n[o++],h=n[o++],g=n[o++],h||=m,g||=h;let _=0;c&&(_=n[o++]),l&&(o+=r*3),u&&(o+=1),d&&(o+=3),f&&(o+=1),p&&(o+=3),i.push(m,h,g),a.push(_)}return{indices:i,materialIndices:a}}function r(e){let t=[],n,r;for(let i=0;i<e.length;i++)e[i]!==r&&(r=e[i],n!==void 0&&(n.count=i*3-n.start,t.push(n)),n={start:i*3,materialIndex:r});return n!==void 0&&(n.count=e.length*3-n.start,t.push(n)),t}function i(e,t){let n=new Ze;n.setIndex(t),n.setAttribute(`position`,e),n.computeVertexNormals();let r=n.getAttribute(`normal`);return r.name=e.name,r}function a(e,t){let n=[];if(e.morphTargets!==void 0)for(let r=0,i=e.morphTargets.length;r<i;r++){let i=e.morphTargets[r].vertices,a=new Float32Array(i.length);for(let e=0,n=i.length;e<n;e++)a[e]=i[e]*t;let o=new Xe(a,3);o.name=e.morphTargets[r].name,n.push(o)}let r=[];if(e.morphNormals!==void 0){for(let t=0,i=e.morphNormals.length;t<i;t++)if(n[t]){let i=e.morphNormals[t].normals,a=new Xe(Float32Array.from(i),3);a.name=n[t].name,r[t]=a}}return{morphPositions:n,morphNormals:r}}function o(e){if(e.morphColors===void 0)return;let t=[];for(let n=0,r=e.morphColors.length;n<r;n++){let r=e.morphColors[n].colors,i=[];for(let e=0,t=r.length;e<t;e+=3){let t=new Qe(16755200);t.setRGB(r[e],r[e+1],r[e+2]),i.push(t)}let a=[];for(let e=0,t=i.length*3;e<t;e++){let t=ae(i,e);a.push(t[0],t[1],t[2])}let o=new tt(a,3);o.name=e.morphColors[n].name,t.push(o)}return t}return function(t,s){t.data!==void 0&&(t=t.data);let c=t.scale===void 0?1:1/t.scale,l=t.vertices,u=l.length/3,d=new Float32Array(l.length);for(let e=0,t=l.length;e<t;e++)d[e]=l[e]*c;let f=new Ze;if(f.setAttribute(`position`,new Xe(d,3)),t.normals!==void 0&&t.normals.length>0&&f.setAttribute(`normal`,new Xe(Float32Array.from(t.normals),3)),t.uvs!==void 0&&(t.uvs[0]&&t.uvs[0].length>0&&f.setAttribute(`uv`,new Xe(Float32Array.from(t.uvs[0]),2)),t.uvs[1]&&t.uvs[1].length>0&&f.setAttribute(`uv2`,new Xe(Float32Array.from(t.uvs[1]),2))),t.colors!==void 0&&t.colors.length>0){let e=new Float32Array(t.colors.length*3);for(let n=0,r=t.colors.length;n<r;n++){let r=new Qe(t.colors[n]);e[n*3]=r.r,e[n*3+1]=r.g,e[n*3+2]=r.b}f.setAttribute(`color`,new Xe(e,3))}else{let e=new Float32Array(u*3).fill(1);f.setAttribute(`color`,new Xe(e,3))}let{indices:p,materialIndices:m}=n(t);p.length>0&&(f.setIndex(p),f.groups=r(m));let{morphPositions:h,morphNormals:g}=a(t,c);if(h.length>0){f.morphAttributes.position=h;let e=[];for(let t=0;t<h.length;t++)g[t]?e.push(g[t]):p.length>0&&e.push(i(h[t],p));e.length>0&&(f.morphAttributes.normal=e)}let _=o(t);if(_!==void 0&&(f.morphAttributes.color=_,f.morphAttributes.position===void 0)){let e=f.getAttribute(`position`);f.morphAttributes.position=_.map(t=>{let n=new Xe(e.array,e.itemSize);return n.name=t.name,n})}if(f.computeBoundingBox(),f.computeBoundingSphere(),t.materials===void 0||t.materials.length===0)return{geometry:f};var v=Je.prototype.initMaterials(t.materials,s,`Anonymous`);if(t.materials[0].video){var y=s+t.materials[0].video;this.paramsString&&(y+=`?${this.paramsString}`),f._video=new Ye(y)}return v&&v.length>0&&(t.materials[0].singleSided?v[0].side=e.FrontSide:t.materials[0].flipSided?v[0].side=e.BackSide:v[0].side=e.DoubleSide,t.materials[0].specularCoef&&(v[0].shininess=Math.floor(t.materials[0].specularCoef/3))),{geometry:f,materials:v}}})()});var it={NONE:0,MIRROR:1,AXES_2D:2,AXES_3D:3},at=e=>{switch(e){case`MIRROR`:return it.MIRROR;case`AXES_2D`:return it.AXES_2D;case`AXES_3D`:return it.AXES_3D;default:return it.NONE}},U={position:0,axis1:1,axis2:2,axis3:3,color:4},ot=e=>e==`AXES_2D`||e==`MIRROR`?2:e==`AXES_3D`?3:1;function st({baseCount:t,outputCount:r,repeat_mode:i,positionsData:a,axis1Data:o,axis2Data:s,axis3Data:c,scaleData:l,colorData:u,baseSize:d,offset:f,scaleFactors:p,globalScale:m}){let h=ot(i),g=!!u,_=[a,o,s,c,l];g&&_.push(u);let v=_.length,y=g?U.color+1:U.axis3+1,b=a.length/3,x=new Float32Array(b*v*4);for(let e=0;e<b;e++)for(let t=0;t<v;t++){let n=_[t],r=(e*v+t)*4;x[r]=n[e*3],x[r+1]=n[e*3+1],x[r+2]=n[e*3+2]}let S=(0,n.attributeArray)(x,`vec4`),C=(0,n.attributeArray)(r*y,`vec4`),w=(e,t)=>S.element(e.mul((0,n.int)(v)).add((0,n.int)(t))).xyz,T=(e,t,r)=>C.element(e.mul((0,n.int)(y)).add((0,n.int)(t))).assign((0,n.vec4)(r,0)),E=e=>({element:t=>C.element((0,n.int)(t).mul((0,n.int)(y)).add((0,n.int)(e))).xyz}),D={bottomFrame:(0,n.uniform)(0,`int`),topFrame:(0,n.uniform)(0,`int`),proportion:(0,n.uniform)(1),repeatMode:(0,n.uniform)(at(i),`int`),baseSize:(0,n.uniform)(new e.Vector3(...d)),offset:(0,n.uniform)(new e.Vector3(...f)),scaleFactors:(0,n.uniform)(new e.Vector3(...p)),globalScale:(0,n.uniform)(m)};return{uniforms:D,compute:(0,n.Fn)(()=>{let e=(0,n.int)(n.instanceIndex),r=e.div((0,n.int)(h)),i=e.mod((0,n.int)(h)),a=D.bottomFrame.mul((0,n.int)(t)).add(r),o=D.topFrame.mul((0,n.int)(t)).add(r),s=(0,n.mix)(w(o,0),w(a,0),D.proportion),c=(0,n.mix)(w(o,1),w(a,1),D.proportion),l=(0,n.mix)(w(o,2),w(a,2),D.proportion),u=(0,n.mix)(w(o,3),w(a,3),D.proportion),d=(0,n.mix)(w(o,4),w(a,4),D.proportion),f=D.repeatMode.equal((0,n.int)(it.NONE)).or(D.repeatMode.equal((0,n.int)(it.MIRROR)));if((0,n.If)(f,()=>{let t=(0,n.vec3)((0,n.select)(d.x.lessThan(0),(0,n.float)(-1),(0,n.float)(1)),(0,n.select)(d.y.lessThan(0),(0,n.float)(-1),(0,n.float)(1)),(0,n.select)(d.z.lessThan(0),(0,n.float)(-1),(0,n.float)(1))).mul(D.baseSize).add(d.mul(D.scaleFactors)).mul(D.globalScale),r=c.mul(t.x),a=l.mul(t.y),o=u.mul(t.z),f=s.add(r.mul(D.offset.x)).add(a.mul(D.offset.y)).add(o.mul(D.offset.z)),p=D.repeatMode.equal((0,n.int)(it.MIRROR)).and(i.equal((0,n.int)(1))),m=(0,n.select)(p,r.negate(),r).toVar(),h=(0,n.select)(p,a.negate(),a).toVar(),g=(0,n.select)(p,o.negate(),o).toVar(),_=f.toVar();(0,n.If)(D.repeatMode.equal((0,n.int)(it.MIRROR)).and(d.x.lessThan(0)),()=>{_.subAssign(m)});let v=g.dot(m.cross(h));(0,n.If)(v.lessThan(0),()=>{g.assign(g.negate())}),T(e,U.position,_),T(e,U.axis1,m),T(e,U.axis2,h),T(e,U.axis3,g)}).Else(()=>{let t=(0,n.vec3)((0,n.select)(d.x.lessThan(0),(0,n.float)(-1),(0,n.float)(1)),(0,n.select)(d.y.lessThan(0),(0,n.float)(-1),(0,n.float)(1)),(0,n.select)(d.z.lessThan(0),(0,n.float)(-1),(0,n.float)(1))).mul(D.baseSize.x).add(d.mul(D.scaleFactors.x)).mul(D.globalScale),r=s.add(c.mul(t.x).mul(D.offset.x)).add(l.mul(t.y).mul(D.offset.y)).add(u.mul(t.z).mul(D.offset.z)),a=(0,n.select)(i.equal((0,n.int)(0)),d.x,(0,n.select)(i.equal((0,n.int)(1)),d.y,d.z)),o=D.repeatMode.equal((0,n.int)(it.AXES_2D)),f=(0,n.select)(i.equal((0,n.int)(0)),c,(0,n.select)(i.equal((0,n.int)(1)),l,u)),p=(0,n.select)(i.equal((0,n.int)(0)),l,(0,n.select)(i.equal((0,n.int)(1)),(0,n.select)(o,c,u),c)),m=D.baseSize.x.add(a.mul(D.scaleFactors.x)).mul(D.globalScale),h=f.mul(m),g=h.cross(p),_=g.length(),v=D.baseSize.z.add(a.mul(D.scaleFactors.z)).mul(D.globalScale).div((0,n.max)(_,1e-8));v=(0,n.select)(o.and(i.greaterThan((0,n.int)(0))),v.mul(-1),v);let y=(0,n.select)(_.greaterThan(0),g.mul(v),g),b=y.cross(h),x=b.length(),S=D.baseSize.y.add(a.mul(D.scaleFactors.y)).mul(D.globalScale).div((0,n.max)(x,1e-8)),C=(0,n.select)(x.greaterThan(0),b.mul(S),b);T(e,U.position,r),T(e,U.axis1,h),T(e,U.axis2,C),T(e,U.axis3,y)}),g){let t=(0,n.mix)(w(o,5),w(a,5),D.proportion);T(e,U.color,t)}})().compute(r),outputs:{buffer:C,stride:y,count:r,position:E(U.position),axis1:E(U.axis1),axis2:E(U.axis2),axis3:E(U.axis3),color:g?E(U.color):void 0}}}async function ct(e,t){let{buffer:n,stride:r,count:i,color:a}=t.outputs,o=new Float32Array(await e.getArrayBufferAsync(n.value)),s=e=>{let t=new Float32Array(i*4);for(let n=0;n<i;n++){let i=(n*r+e)*4;t[n*4]=o[i],t[n*4+1]=o[i+1],t[n*4+2]=o[i+2]}return t};return{position:s(U.position),axis1:s(U.axis1),axis2:s(U.axis2),axis3:s(U.axis3),color:a?s(U.color):void 0}}async function lt(e,t){return e.compute(t.compute),ct(e,t)}var ut=!0,dt=e=>{ut=!!e},ft=()=>ut;function pt(t,r){let i=t;(!i||!i.isNodeMaterial)&&(i=new(t&&be[t.type]||e.MeshPhongNodeMaterial),t&&i.copy(t));let{position:a,axis1:o,axis2:s,axis3:c,color:l}=r.outputs;return i.positionNode=(0,n.Fn)(()=>{let e=n.instanceIndex;return a.element(e).add(o.element(e).mul(n.positionGeometry.x)).add(s.element(e).mul(n.positionGeometry.y)).add(c.element(e).mul(n.positionGeometry.z))})(),l&&(i.colorNode=(0,n.Fn)(()=>(0,n.vec4)(l.element(n.instanceIndex).mul(n.materialColor),n.materialOpacity))()),i}var mt=function(){H.call(this);let t=[],n,r,i,a,o=!1,s,c,l,u=0,d=0,f=[0,0,0],p=[0,0,0],m=!1,h=[0,0,0],g=`NONE`;this.ready=!1;let _=!1,v=!1;this.isGlyphset=!0;let y=new e.Matrix4,b=new e.Color,x=new e.Color,S=new e.Box3,C=new e.Box3,w=new e.Box3,T=[],E=[],D=[],O=[],k=[],A=[],j=[],M=[];this.globalScale=1;let N,P=!1,F=!0,I=!1,L=!1,R,z,B=!1;for(let t=0;t<8;t++)T[t]=new e.Vector3;let ee=(e,t)=>{e.elements[0]=t[1][0],e.elements[1]=t[1][1],e.elements[2]=t[1][2],e.elements[3]=0,e.elements[4]=t[2][0],e.elements[5]=t[2][1],e.elements[6]=t[2][2],e.elements[7]=0,e.elements[8]=t[3][0],e.elements[9]=t[3][1],e.elements[10]=t[3][2],e.elements[11]=0,e.elements[12]=t[0][0],e.elements[13]=t[0][1],e.elements[14]=t[0][2],e.elements[15]=1},ne=(e,t,n)=>{let r=new Float32Array(t*n*3);for(let i=0;i<t;i++){let t=e[i.toString()];t&&r.set(t,i*n*3)}return r},re=(t,n,r)=>{let i=new Float32Array(n*r*3),a=new e.Color;for(let e=0;e<n;e++){let n=t[e.toString()];if(n)for(let t=0;t<r;t++){a.setHex(n[t]);let o=(e*r+t)*3;i[o]=a.r,i[o+1]=a.g,i[o+2]=a.b}}return i};this.load=(t,m,y,b,x)=>{if(o=!1,n=t.axis1,r=t.axis2,i=t.axis3,a=t.positions,s=t.scale,c=t.colors,l=t.label,_=t.metadata.MorphColours,v=t.metadata.MorphVertices,u=t.metadata.number_of_time_steps,g=t.metadata.repeat_mode,d=t.metadata.number_of_vertices,g==`AXES_2D`||g==`MIRROR`?d*=2:g==`AXES_3D`&&(d*=3),f=t.metadata.base_size,p=t.metadata.offset,h=t.metadata.scale_factors,N=void 0,v&&u>1&&a&&a[0]&&ft()){let e=a[0].length/3;try{N=st({baseCount:e,outputCount:d,repeat_mode:g,positionsData:ne(a,u,e),axis1Data:ne(n,u,e),axis2Data:ne(r,u,e),axis3Data:ne(i,u,e),scaleData:ne(s,u,e),colorData:_&&c?re(c,u,e):void 0,baseSize:f,offset:p,scaleFactors:h,globalScale:this.globalScale})}catch(e){console.error(`Failed to set up GPU glyph transform compute, falling back to CPU animation.`,e),N=void 0}}let S=new rt;this.geometry=new e.BufferGeometry;let C=new e.InstancedMesh(this.geometry,void 0,d);if(this.setMorph(C),b){var w=S.parse(m);he(y,x)(w.geometry,w.materials),w.geometry.dispose()}else S.crossOrigin=`Anonymous`,S.load(m,he(y,x))};let ie=(e,t,n,r,i,a)=>{if(g==`NONE`||g==`MIRROR`){let c=[0,0,0],l=[0,0,0],u=[0,0,0],d=[0,0,0],m=[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*f[o]+i[o]*h[o])*this.globalScale}for(var o=0;o<3;o++)l[o]=t[o]*c[0],u[o]=n[o]*c[1],d[o]=r[o]*c[2],m[o]=e[o]+p[0]*l[o]+p[1]*u[o]+p[2]*d[o],g==`MIRROR`&&(_[o]=-l[o],v[o]=-u[o],y[o]=-d[o],b[o]=m[o],i[0]<0&&(m[o]-=l[o],b[o]-=_[o]));0>d[0]*(l[1]*u[2]-l[2]*u[1])+d[1]*(l[2]*u[0]-l[0]*u[2])+d[2]*(l[0]*u[1]-l[1]*u[0])&&(d[0]=-d[0],d[1]=-d[1],d[2]=-d[2]),a[0]=[m,l,u,d],g==`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(g==`AXES_2D`||g==`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*f[0]+i[o]*h[0])*this.globalScale}for(var o=0;o<3;o++)u[o]=e[o]+p[0]*l[0]*t[o]+p[1]*l[1]*n[o]+p[2]*l[2]*r[o];let d=g==`AXES_2D`?2:3;for(let e=0;e<d;e++){let o,s,l=i[e],d=[0,0,0],p=[0,0,0],m=[0,0,0];e==0?(o=t,s=n):e==1?(o=n,s=g==`AXES_2D`?t:r):(o=r,s=t);let _=(f[0]+l*h[0])*this.globalScale;d[0]=o[0]*_,d[1]=o[1]*_,d[2]=o[2]*_,m[0]=d[1]*s[2]-s[1]*d[2],m[1]=d[2]*s[0]-s[2]*d[0],m[2]=d[0]*s[1]-d[1]*s[0];let v=Math.sqrt(m[0]*m[0]+m[1]*m[1]+m[2]*m[2]);if(0<v){let t=(f[2]+l*h[2])*this.globalScale/v;g==`AXES_2D`&&e>0&&(t*=-1),m[0]*=t,m[1]*=t,m[2]*=t}if(p[0]=m[1]*d[2]-d[1]*m[2],p[1]=m[2]*d[0]-d[2]*m[0],p[2]=m[0]*d[1]-m[1]*d[0],v=Math.sqrt(p[0]*p[0]+p[1]*p[1]+p[2]*p[2]),0<v){var c=(f[1]+l*h[1])*this.globalScale/v;p[0]*=c,p[1]*=c,p[2]*=c}a[e]=[u,d,p,m]}}return a},ae=(e,n,r,i,a)=>{let o=1;g==`AXES_2D`||g==`MIRROR`?o=2:g==`AXES_3D`&&(o=3);let s=e.length/3,c=0;M.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=ie(u,d,f,p,m,M);if(h.length==o)for(let e=0;e<o;e++){ee(y,h[e]),this.morph.setMatrixAt(c,y);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()},oe=(e,n)=>{let r=1;g==`AXES_2D`||g==`MIRROR`?r=2:g==`AXES_3D`&&(r=3);let i=e.length,a=0;for(let o=0;o<i;o++){let i=e[o];for(let e=0;e<r;e++){b.setHex(i),n||this.morph.setColorAt(a,b);let e=t[a];e&&e.setColour(b),a++}}n||(this.morph.instanceColor.needsUpdate=!0)},se=e=>{this.requestRender();let n=this.morph.instanceMatrix.array,r=this.canShowLabel();for(let i=0;i<d;i++){let a=i*4,o=i*16;if(n[o]=e.axis1[a],n[o+1]=e.axis1[a+1],n[o+2]=e.axis1[a+2],n[o+3]=0,n[o+4]=e.axis2[a],n[o+5]=e.axis2[a+1],n[o+6]=e.axis2[a+2],n[o+7]=0,n[o+8]=e.axis3[a],n[o+9]=e.axis3[a+1],n[o+10]=e.axis3[a+2],n[o+11]=0,n[o+12]=e.position[a],n[o+13]=e.position[a+1],n[o+14]=e.position[a+2],n[o+15]=1,r){let n=t[i];n&&n.setTransformation([e.position[a],e.position[a+1],e.position[a+2]],[e.axis1[a],e.axis1[a+1],e.axis1[a+2]],[e.axis2[a],e.axis2[a+1],e.axis2[a+2]],[e.axis3[a],e.axis3[a+1],e.axis3[a+2]])}}if(this.morph.instanceMatrix.needsUpdate=!0,this.boundingBoxUpdateRequired=!0,this.morph.computeBoundingSphere(),e.color){let n=this.morph.instanceColor?this.morph.instanceColor.array:void 0;for(let i=0;i<d;i++){let a=i*4;if(n){let t=i*3;n[t]=e.color[a],n[t+1]=e.color[a+1],n[t+2]=e.color[a+2]}if(r){let n=t[i];n&&(b.setRGB(e.color[a],e.color[a+1],e.color[a+2]),n.setColour(b))}}n&&(this.morph.instanceColor.needsUpdate=!0)}},ce=(e,t,n)=>{if(P)return;let r=this.region?.getScene?.()?.getRenderer?.();r&&(N.uniforms.bottomFrame.value=e,N.uniforms.topFrame.value=t,N.uniforms.proportion.value=n,N.uniforms.globalScale.value=this.globalScale,P=!0,F=!1,lt(r,N).then(e=>{P=!1,se(e),F=!0,delete this.morph.raycast}).catch(e=>{P=!1,console.error(`Glyph transform compute readback failed.`,e)}))},le=(e,t,n)=>{this.requestRender();let r=this.region?.getScene?.()?.getRenderer?.();return r?(N.uniforms.bottomFrame.value=e,N.uniforms.topFrame.value=t,N.uniforms.proportion.value=n,N.uniforms.globalScale.value=this.globalScale,r.compute(N.compute),F=!1,this.morph.raycast=()=>{},I=!0,!0):!1},ue=()=>{if(P)return;let e=this.region?.getScene?.()?.getRenderer?.();e&&(P=!0,ct(e,N).then(e=>{P=!1,se(e),F=!0,delete this.morph.raycast}).catch(e=>{P=!1,console.error(`Glyph transform compute readback failed.`,e)}))},de=()=>{z!==void 0&&(clearTimeout(z),z=void 0)},V=()=>{de(),z=setTimeout(()=>{z=void 0,ue()},500)},fe=e=>{let t=this.inbuildTime/this.duration*(u-1),o=Math.floor(t),l=1-(t-o),d=Math.ceil(t);if(v&&N){e?(le(o,d,l),V()):(de(),ce(o,d,l));return}let f=E,p=D,m=O,h=k,g=A,y=j;if(v){let e=a[o.toString()],t=a[d.toString()],c=n[o.toString()],u=n[d.toString()],_=r[o.toString()],v=r[d.toString()],y=i[o.toString()],b=i[d.toString()],x=s[o.toString()],S=s[d.toString()];E.length=e.length,D.length=e.length,O.length=e.length,k.length=e.length,A.length=e.length;for(let n=0;n<e.length;n++)f[n]=l*e[n]+(1-l)*t[n],p[n]=l*c[n]+(1-l)*u[n],m[n]=l*_[n]+(1-l)*v[n],h[n]=l*y[n]+(1-l)*b[n],g[n]=l*x[n]+(1-l)*S[n]}else f=a[0],p=n[0],m=r[0],h=i[0],g=s[0];if((v||!B)&&(ae(f,p,m,h,g),B=!v),c!=null){if(_){let e=c[o.toString()],t=c[d.toString()];y.length=e.length;for(let n=0;n<e.length;n++)b.setHex(e[n]),x.setHex(t[n]),b.setRGB(b.r*l+x.r*(1-l),b.g*l+x.g*(1-l),b.b*l+x.b*(1-l)),y[n]=b.getHex()}else y=c[0];oe(y,!1)}};this.isUsingGPUCompute=()=>N!==void 0,this.getLabel=e=>{if(l&&l.length>e)return l[e]},this.isLabelDisplayed=()=>m,this.canShowLabel=()=>t?.length&&(l?.length||this.groupName),this.showLabel=()=>{if(this.requestRender(),t?.length){m=!0;for(let e=0;e<t.length;e++)t[e].showLabel(this.morph.material?this.morph.material.color:void 0)}},this.hideLabel=()=>{this.requestRender();for(let e=0;e<t.length;e++)t[e].hideLabel();m=!1};let pe=()=>{let t=new e.Box3().setFromBufferAttribute(this.geometry.attributes.position),o=new e.Matrix4,c=new e.Box3,l=[],d=new e.Box3,f=!0;for(let e=0;e<u;e++){let u=a[e.toString()],p=n[e.toString()],m=r[e.toString()],h=i[e.toString()],g=s[e.toString()];if(!u)continue;let _=u.length/3;for(let e=0;e<_;e++){let n=e*3,r=[u[n],u[n+1],u[n+2]],i=[p[n],p[n+1],p[n+2]],a=[m[n],m[n+1],m[n+2]],s=[h[n],h[n+1],h[n+2]],_=[g[n],g[n+1],g[n+2]],v=ie(r,i,a,s,_,l);for(let e=0;e<v.length;e++)ee(o,v[e]),c.copy(t).applyMatrix4(o),f?(d.copy(c),f=!1):d.union(c)}}return f?void 0:d},me=e=>{for(let e=0;e<d;e++){let n=new qe(void 0,void 0,e,this),r=l?l[e]:void 0;r||=this.groupName,r&&n.setLabel(r),u>0&&n.setFrustumCulled(!1),t[e]=n,this.morph.add(n.getGroup())}l&&l.length>0&&e&&this.showLabel(),ae(a[0],n[0],r[0],i[0],s[0]),B=!0,c!=null&&oe(c[0],!!(N&&N.outputs.color)),N&&(R=pe()),this.ready=!0};this.addCustomGlyph=e=>{this.requestRender(),e.isGlyph&&t.push(e),this.ready=!0,this.boundingBoxUpdateRequired=!0},this.addMeshAsGlyph=(e,n)=>{if(this.requestRender(),e.isMesh){let r=new qe(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 he=(e,t)=>(n,r)=>{if(o){n.dispose();return}this.geometry.copy(n),this.geometry.computeBoundingSphere(),this.geometry.computeBoundingBox(),r&&r[0]&&(this.morph.material=r[0]),N&&(this.morph.material=pt(this.morph.material,N)),me(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,y),t.setFromMatrixPosition(y),t}},this.getBoundingBox=()=>{if(this.morph&&this.ready&&this.morph.visible){if(N&&!F&&R)return this.cachedBoundingBox.copy(R),this.cachedBoundingBox.applyMatrix4(te(this.morph)),this.cachedBoundingBox;if(this.boundingBoxUpdateRequired){S.setFromBufferAttribute(this.morph.geometry.attributes.position);for(let e=0;e<d;e++)this.morph.getMatrixAt(e,y),C.copy(S).applyMatrix4(y),e==0?w.copy(C):w.union(C);if(w)this.cachedBoundingBox.copy(w),this.cachedBoundingBox.applyMatrix4(te(this.morph)),this.boundingBoxUpdateRequired=!1;else return}return this.cachedBoundingBox}},this.setMorphTime=e=>{this.requestRender(),this.inbuildTime=e>this.duration?this.duration:0>e?0:e,(_||v)&&(fe(!0),v&&(this.markerUpdateRequired=!0))},this.isTimeVarying=()=>!!((this.ready===!1||u>0)&&(_||v)),this.getCurrentTime=()=>this.inbuildTime,this.prepareColorForExport=async()=>{if(!(N&&N.outputs.color))return;let e=this.region?.getScene?.()?.getRenderer?.();if(!e)return;e.compute(N.compute);let t=(await ct(e,N)).color;this.morph.setColorAt(0,b);let n=this.morph.instanceColor.array;for(let e=0;e<d;e++){let r=e*4,i=e*3;n[i]=t[r],n[i+1]=t[r+1],n[i+2]=t[r+2]}this.morph.instanceColor.needsUpdate=!0},this.clearColorExportState=()=>{N&&N.outputs.color&&this.morph.instanceColor&&(this.morph.instanceColor=null,this.morph.material&&(this.morph.material.needsUpdate=!0))},this.setScaleAll=function(e){this.requestRender(),this.globalScale=e,B=!1,fe(!1)},this.dispose=()=>{o=!0;for(let e=t.length-1;e>=0;e--)t[e].dispose();this.geometry&&this.geometry.dispose(),this.morph&&this.morph.material.dispose(),de(),n=void 0,r=void 0,i=void 0,a=void 0,s=void 0,c=void 0,N=void 0,P=!1,F=!0,I=!1,L=!1,R=void 0,this.ready=!1,this.groupName=void 0},this.render=(e,t,n,r)=>{if(N&&!I){let e=this.region?.getScene?.()?.getRenderer?.();e&&(e.compute(N.compute),I=!0,this.requestRender())}if(t==1){let t=this.inbuildTime+e;if(t>this.duration&&(t-=this.duration),this.inbuildTime=t,v&&N){de();let e=this.inbuildTime/this.duration*(u-1),t=Math.floor(e),n=1-(e-t);le(t,Math.ceil(e),n)}else(_||v)&&fe(!1);L=!0}else L&&N&&fe(!1),L=!1;this.updateMarker(t,r)}};mt.prototype=Object.create(H.prototype);var ht=new e.Matrix4,gt=new e.Ray,_t=new e.Vector3,vt=class extends e.InstancedMesh{constructor(e,t,n){super(e,t,n),this.type=`InstancedPoints`,this.isInstancedPoints=!0,this.frustumCulled=!1,this.pointSize=10,this.sizePerPixel=1,this.pointPositions=new Float32Array}raycast(t,n){let r=this.matrixWorld,i=t.params.Points?t.params.Points.threshold:1,a=this.count,o=this.pointPositions;if(!a||!o||o.length<a*3)return;ht.copy(r).invert(),gt.copy(t.ray).applyMatrix4(ht);let s=i/((this.scale.x+this.scale.y+this.scale.z)/3)*this.pointSize*this.sizePerPixel,c=s*s;for(let i=0;i<a;i++){_t.fromArray(o,i*3);let a=gt.distanceSqToPoint(_t);if(a<c){let o=new e.Vector3;gt.closestPointToPoint(_t,o),o.applyMatrix4(r);let s=t.ray.origin.distanceTo(o);if(s<t.near||s>t.far)continue;n.push({distance:s,distanceToRay:Math.sqrt(a),point:o,index:i,face:null,object:this})}}}},yt=new e.Vector2,bt=t=>{let r=new e.MeshBasicNodeMaterial,i={pointSize:(0,n.uniform)(10),sizeAttenuation:(0,n.uniform)(0),viewportScale:(0,n.uniform)(1).onFrameUpdate(function({renderer:e}){let t=e.getSize(yt);this.value=.5*t.y})};return r.vertexNode=(0,n.Fn)(()=>{let e=(0,n.attribute)(`instancePosition`,`vec3`),t=n.modelViewMatrix.mul((0,n.vec4)(e,1)),r=i.pointSize.mul(n.screenDPR),a=r.mul(i.viewportScale.div(t.z.negate()));r=(0,n.mix)(r,a,i.sizeAttenuation);let o=n.positionGeometry.xy.mul(r);o=o.div(n.viewportSize.div(2));let s=n.cameraProjectionMatrix.mul(t);return o=o.mul(s.w),(0,n.vec4)(s.xy.add(o),s.z,s.w)})(),r.colorNode=(0,n.Fn)(()=>{let e=(0,n.texture)(t,(0,n.uv)());return(0,n.vec4)(e.rgb.mul(n.materialColor),e.a.mul(n.materialOpacity))})(),r.userData.uniforms=i,r.size=i.pointSize.value,r.sizeAttenuation=!!i.sizeAttenuation.value,r},xt=500,St=t=>{let n=new e.PlaneGeometry(1,1),r=new e.InstancedBufferAttribute(new Float32Array(t*3),3);return r.setUsage(e.DynamicDrawUsage),n.setAttribute(`instancePosition`,r),n},Ct=(e,t)=>{let n=e.getAttribute(`position`),r=e.morphAttributes.position;if(t&&r&&r.length>0){let t=e.morphTargetsRelative;return r.map(e=>{if(!t)return Float32Array.from(e.array);let r=new Float32Array(n.array.length);for(let t=0;t<r.length;t++)r[t]=n.array[t]+e.array[t];return r})}return[Float32Array.from(n.array)]},wt=(e,t)=>{let n=e.morphAttributes.color;if(t&&n&&n.length>0)return n.map(e=>Float32Array.from(e.array))},Tt=e=>{let t=e.getAttribute(`color`);return t?Float32Array.from(t.array):void 0},Et=function(){H.call(this),this.isPointset=!0;let t=[],n=1,r=!1,i=500,a=!0,o=[],s,c=!1,l=!1,u=new e.Color,d=()=>{let e=this.getMorph();if(!e||o.length===0)return;let t=e.count,n=o.length,r=0,i=0,a=1;if(n>1){let e=this.inbuildTime/this.duration*(n-1);r=Math.floor(e),i=Math.ceil(e),a=1-(e-r)}if(c){let n=o[r],s=o[i],c=e.pointPositions,l=t*3;for(let e=0;e<l;e++)c[e]=a*n[e]+(1-a)*s[e];e.geometry.getAttribute(`instancePosition`).needsUpdate=!0,this.boundingBoxUpdateRequired=!0}if(l&&s){let n=s[Math.min(r,s.length-1)],o=s[Math.min(i,s.length-1)];e.instanceColor||e.setColorAt(0,u);let c=e.instanceColor.array,l=t*3;for(let e=0;e<l;e++)c[e]=a*n[e]+(1-a)*o[e];e.instanceColor.needsUpdate=!0}};this.createMesh=(e,t,n)=>{if(!e||!t)return;let r=ce(e,n);o=Ct(r,n.localTimeEnabled),s=wt(r,n.localMorphColour),c=o.length>1,l=!!s,this.timeEnabled=c,this.morphColour=l;let i=o[0].length/3,a=St(i),d=bt(he());t.color&&d.color.copy(t.color),t.opacity!==void 0&&(d.opacity=t.opacity),d.transparent=!!t.transparent,d.alphaTest=t.alphaTest===void 0?.5:t.alphaTest;let f=new vt(a,d,i);f.count=i;let p=a.getAttribute(`instancePosition`);p.array.set(o[0]),p.needsUpdate=!0,f.pointPositions=p.array,f.userData=this,this.drawRange=i;let m=s?s[0]:Tt(r);if(m)for(let e=0;e<i;e++)u.setRGB(m[e*3],m[e*3+1],m[e*3+2]),f.setColorAt(e,u);this.setMorph(f),r.dispose(),this.boundingBoxUpdateRequired=!0},this.setMesh=(e,t,n)=>{this.createMesh(e.geometry,e.material,{localTimeEnabled:t,localMorphColour:n});let r=this.getMorph();r&&(r.name=e.name)};let f=(o,s,c,l)=>{if(c){let u=new Ke(c,new e.Color(l));u.setPosition(s[0],s[1],s[2]);let d=u.getSprite();d.material.sizeAttenuation=!1,d.material.alphaTest=.05,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}},p=e=>{let n=t[e];if(n){let r=n.getSprite();this.group.remove(r),n.dispose(),t.splice(e,1)}};this.addPoints=(e,t,n)=>{if(this.requestRender(),e&&e.length>0){let r=this.getMorph(),i=this.drawRange;if(!r){i=0,this.drawRange=0;let e=St(xt),t=bt(he());t.color.set(n),t.alphaTest=.5,r=new vt(e,t,xt),r.pointPositions=e.getAttribute(`instancePosition`).array,r.count=0,r.userData=this,this.setMorph(r)}let a=r.geometry.getAttribute(`instancePosition`);e.forEach(e=>{this.drawRange<xt&&(a.setXYZ(this.drawRange,e[0],e[1],e[2]),this.drawRange++)}),a.needsUpdate=!0,r.count=this.drawRange;let o=i+e.length,s=0;if(Array.isArray(t)&&t.length===e.length||typeof t==`string`)for(;i+s<o;){let n=typeof t==`string`?t:t[s];f(i+s,e[s],n,this._lod._material.color),s++}this.boundingBoxUpdateRequired=!0,this.region&&(this.region.pickableUpdateRequired=!0)}},this.setColourHex=function(e){this.requestRender(),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.requestRender(),this._lod.setColour(e);for(let e=0;e<t.length;e++)t[e]&&t[e].setColour(this._lod._material.color)},this.setLabelDepthTest=e=>{this.requestRender(),r=e;for(let n=0;n<t.length;n++)t[n]&&t[n].setDepthTest(e)},this.setLabelFontWeight=e=>{this.requestRender(),i=e;for(let n=0;n<t.length;n++)t[n]&&t[n].setFontWeight(e)},this.setLabelSize=e=>{this.requestRender(),n=e;for(let e=0;e<t.length;e++)t[e]&&t[e].setSize(n)},this.displayLabels=e=>{this.requestRender(),a=e;for(let e=0;e<t.length;e++)t[e]&&t[e].setVisibility(a)},this.setSize=e=>{this.requestRender(),this.morph&&this.morph.material&&(this.morph.material.size=e,this.morph.material.userData.uniforms.pointSize.value=e,this.morph.pointSize=e)},this.setSizeAttenuation=e=>{this.requestRender(),this.morph&&this.morph.material&&(this.morph.material.sizeAttenuation=e,this.morph.material.userData.uniforms.sizeAttenuation.value=+!!e)},this.getVerticesByIndex=function(e){let t=this.getMorph();if(t&&e>=0&&this.drawRange>e)return[t.pointPositions[e*3],t.pointPositions[e*3+1],t.pointPositions[e*3+2]]},this.editVertices=function(e,n){if(this.requestRender(),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(`instancePosition`),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]),o[0]&&(o[0][a*3]=e[0],o[0][a*3+1]=e[1],o[0][a*3+2]=e[2]),a++}),i.needsUpdate=!0,this.boundingBoxUpdateRequired=!0}}},this.deleteVertices=function(e){this.requestRender();let t=this.getMorph();if(!t||0>e||e>=this.drawRange)return this.drawRange;let n=t.geometry.getAttribute(`instancePosition`),r=this.drawRange-1;return n.array.copyWithin(e*3,(e+1)*3,this.drawRange*3),t.pointPositions!==n.array&&t.pointPositions.copyWithin(e*3,(e+1)*3,this.drawRange*3),t.instanceColor&&(t.instanceColor.array.copyWithin(e*3,(e+1)*3,this.drawRange*3),t.instanceColor.needsUpdate=!0),n.needsUpdate=!0,this.drawRange=r,t.count=this.drawRange,p(e),this.boundingBoxUpdateRequired=!0,this.drawRange},this.setName=function(e){let n=this.groupName;Et.prototype.setName.call(this,e),t.forEach(t=>{t.getString()===n&&t?.setText(e)})},this.getClosestVertexIndex=function(){let e=-1,t=this.getMorph();if(t&&this.drawRange>0){this._b1.setFromArray(t.pointPositions.subarray(0,this.drawRange*3)),this._b1.getCenter(this._v1);let n=-1;for(let r=0;r<this.drawRange;r++){this._v2.fromArray(t.pointPositions,r*3);let i=this._v1.distanceTo(this._v2);(n===-1||i<n)&&(n=i,e=r)}}return e},this.getClosestVertex=function(t){let n=this.getMorph();this.closestVertexIndex===-1&&(this.closestVertexIndex=this.getClosestVertexIndex());let r=new e.Vector3;return n&&this.closestVertexIndex>=0?(r.fromArray(n.pointPositions,this.closestVertexIndex*3),t?r.applyMatrix4(n.matrixWorld):r):(this.getBoundingBox(),r.copy(this.center),r)},this.getBoundingBox=function(){let e=this.getMorph();if(this.visible&&e&&e.visible&&this.drawRange>0)return this.boundingBoxUpdateRequired&&=(this._b1.setFromArray(e.pointPositions.subarray(0,this.drawRange*3)),this.cachedBoundingBox.copy(this._b1),this.cachedBoundingBox.applyMatrix4(te(e)),this.cachedBoundingBox.getCenter(this.center),this.radius=this.center.distanceTo(this.cachedBoundingBox.max),!1),this.cachedBoundingBox},this.isTimeVarying=()=>c||l,this.setMorphTime=e=>{this.requestRender(),this.inbuildTime=e>this.duration?this.duration:0>e?0:e,(c||l)&&d()},this.render=(e,t,n,r)=>{if(this.morph&&n&&(this.morph.sizePerPixel=n.pixelHeight),this.visible&&this._lod.update(n,this.center),t===!0&&(c||l)){let t=this.inbuildTime+e;t>this.duration&&(t-=this.duration),this.inbuildTime=t,d()}this.updateMarker(t,r)}};Et.prototype=Object.create(H.prototype);var Dt=function(){H.call(this),this.isLines=!0,this.createLineSegment=(e,t,n)=>{if(e&&t){let r=ce(e,n);n.localMorphColour&&r.morphAttributes.color&&(t.vertexColors=!1,t=xe(t));let i=new Fe(r,t);this.setMesh(i,n.localTimeEnabled,n.localMorphColour)}},this.setWidth=e=>{this.requestRender(),this.morph&&this.morph.material&&(this.morph.material.linewidth=e,this.morph.material.needsUpdate=!0)},this.addLines=(t,n)=>{if(this.requestRender(),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)}}};Dt.prototype=Object.create(H.prototype);var Ot=function(){this.isTexture=!0,this.impl=void 0,this.isLoading=!1,this.size={width:1,height:1,depth:0}};Ot.prototype.loadImage=function(e,t){return new Promise((n,r)=>{e.onload=()=>n(e),e.onerror=r,e.src=t})},Ot.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}},Ot.prototype.loadFromImages=async function(e){},Ot.prototype.dispose=function(){this.impl&&=(this.impl.dispose(),void 0)},Ot.prototype.isReady=function(){return!!(this.impl&&!this.isLoading)},Ot.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 kt=function(){Ot.call(this),this.isTextureArray=!0,this.imageData=void 0,this.setDataTexture=e=>{this.impl=e,console.log(`setDataTexture`,e),this.imageData=e.image.data},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.Data3DTexture(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}}};kt.prototype=Object.create(Ot.prototype),kt.prototype.dispose=function(){Ot.prototype.dispose.call(this),this.imageData=void 0};function At(){let t=new e.MeshBasicNodeMaterial({side:e.DoubleSide}),r=new Uint8Array(32),i=new e.Data3DTexture(r,2,2,2);i.image={data:r,width:2,height:2,depth:2},i.format=e.RGBAFormat,i.type=e.UnsignedByteType,i.minFilter=e.LinearFilter,i.magFilter=e.LinearFilter,i.generateMipmaps=!1,i.unpackAlignment=1,i.needsUpdate=!0;let a={brightness:(0,n.uniform)(0),contrast:(0,n.uniform)(1),depth:(0,n.uniform)(1),discardAlpha:(0,n.uniform)(!0),direction:(0,n.uniform)(1),flipY:(0,n.uniform)(!0),flipZ:(0,n.uniform)(!1),nChannels:(0,n.uniform)(1),maskEnabled:(0,n.uniform)(!1),slide:(0,n.uniform)(new e.Vector3(0,0,1)),time:(0,n.uniform)(0)},o=(0,n.varying)((0,n.vec3)(0),`vUw`);a.diffuse0=(0,n.texture3D)(i,o),a.diffuse1=(0,n.texture3D)(i,o),a.mask=(0,n.texture3D)(i,o);let s=(0,n.Fn)(()=>{let e=(0,n.vec3)(n.positionLocal).toVar();return(0,n.If)(a.direction.equal(1),()=>{e.assign((0,n.vec3)(a.slide.x,n.positionLocal.y,n.positionLocal.x))}),(0,n.If)(a.direction.equal(2),()=>{e.assign((0,n.vec3)(n.positionLocal.x,a.slide.y,n.positionLocal.y))}),(0,n.If)(a.direction.equal(3),()=>{e.assign((0,n.vec3)(n.positionLocal.x,n.positionLocal.y,a.slide.z))}),(0,n.If)(a.flipY,()=>{e.y.assign((0,n.float)(1).sub(e.y))}),(0,n.If)(a.flipZ,()=>{e.z.assign((0,n.float)(1).sub(e.z))}),o.assign((0,n.vec3)(e.x,e.y,e.z)),n.positionLocal}),c=(0,n.Fn)(()=>{let e=a.diffuse0.r,t=a.diffuse1.r,r=(0,n.mix)(e,t,a.time).toVar();(0,n.If)(a.maskEnabled.and(a.discardAlpha),()=>{let e=a.mask.r;(0,n.If)(e.equal(0),()=>{(0,n.Discard)()})});let i=(0,n.vec3)(r).add((0,n.vec3)(a.brightness)).sub((0,n.vec3)(.5)).mul(a.contrast).add((0,n.vec3)(.5));return(0,n.vec4)((0,n.sRGBTransferEOTF)(i),1)});return t.positionNode=s(),t.colorNode=c(),t.userData.uniforms=a,t}var jt=function(e){H.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 kt,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)}};jt.prototype=Object.create(H.prototype),jt.prototype.constructor=jt,jt.prototype.dispose=function(){let e=new Set(this.textureList);this.texture&&e.add(this.texture),e.forEach(e=>e.dispose()),this.texture=void 0,this.textureList=[],H.prototype.dispose.call(this)};var Mt=t=>{let n=t.image,r=n.width,i=n.height,a=n.depth,o=n.data,s=new e.Data3DTexture(o,r,i,a);return s.format=t.format,s.type=t.type,s.minFilter=t.minFilter,s.magFilter=t.magFilter,s.wrapS=t.wrapS,s.wrapT=t.wrapT,s.wrapR=t.wrapR,s.colorSpace=t.colorSpace,s.anisotropy=t.anisotropy,s.needsUpdate=!0,s},Nt=function(t){jt.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=>{this.requestRender(),e.forEach(e=>this.createSlide(e))};let g=(e,t)=>{let n=e.material.userData.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 r=-Math.PI/2;e.rotation.y=r,n.direction.value=1,n.slide.value.set(t.value,0,0),e.position.x=t.value;break;case`y`:e.rotation.x=Math.PI/2,n.direction.value=2,n.slide.value.set(0,t.value,0),e.position.y=t.value;break;case`z`:n.direction.value=3,n.slide.value.set(0,0,t.value),e.position.z=t.value}this.boundingBoxUpdateRequired=!0};this.modifySlideSettings=e=>{this.requestRender(),e&&e.id&&e.id in r&&r[e.id]&&g(r[e.id],e)},this.createSlide=t=>{if(this.requestRender(),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=At();p.userData.uniforms.brightness.value=s,p.userData.uniforms.contrast.value=c,p.userData.uniforms.diffuse0.value=Mt(this.texture.impl),p.userData.uniforms.diffuse1.value=Mt(this.texture.impl),p.userData.uniforms.discardAlpha.value=f,p.userData.uniforms.depth.value=this.texture.size.depth,p.userData.uniforms.flipY.value=a,p.userData.uniforms.flipZ.value=o,u&&(p.userData.uniforms.mask.value=u),p.userData.uniforms.maskEnabled.value=d,p.userData.uniforms.nChannels.value=l;let m=new e.Mesh(i,p);m.name=this.groupName,m.userData=this;let h={value:t.value,direction:t.direction,id:m.id};return n.push(h),g(m,h),r[m.id]=m,this.morph.add(m),this.boundingBoxUpdateRequired=!0,this.updateTimeTexture(),h}},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=>{this.requestRender(),e&&this.removeSlideWithId(e.id)},this.removeSlideWithId=e=>{if(this.requestRender(),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()}),u&&(u.dispose(),u=void 0,d=!1),jt.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.userData.uniforms,t)}),this.cachedBoundingBox.applyMatrix4(te(this.morph)),this.boundingBoxUpdateRequired=!1}return this.cachedBoundingBox},this.applyTransformation=(t,n,r)=>{this.requestRender();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.requestRender(),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(this.requestRender(),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.requestRender(),this.morph.children.forEach(n=>{let r=n.material;if(r.userData.uniforms){let n=r.userData.uniforms;n[e].value=t}})},this.isAlphaPixelDiscarded=()=>f,this.discardAlphaPixel=e=>{this.requestRender(),f=e,this.setUniformsValue(`discardAlpha`,f)},this.getBrightness=()=>s,this.setBrightness=e=>{this.requestRender(),s=e,this.setUniformsValue(`brightness`,s)},this.getContrast=()=>c,this.setContrast=e=>{this.requestRender(),c>=0&&(c=e,this.setUniformsValue(`contrast`,c))},this.getNumberOfChannels=()=>l,this.setNumberOfChannels=e=>{this.requestRender(),l=e,this.setUniformsValue(`nChannels`,l)},this.getMask=()=>u,this.setMask=e=>{this.requestRender(),u=e,d=!!u,this.morph.children.forEach(e=>{let t=e.material;if(t.userData.uniforms){let e=t.userData.uniforms;u&&(e.mask.value=u)}}),this.setUniformsValue(`maskEnabled`,d)},this.hideEdges=()=>{this.requestRender(),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.userData.uniforms){let e=t.userData.uniforms;p!==r&&(e.diffuse0.value.image.data=this.textureList[r].imageData,e.diffuse0.value.needsUpdate=!0),m!==i&&(e.diffuse1.value.image.data=this.textureList[i].imageData,e.diffuse1.value.needsUpdate=!0),e.time.value=a}}),p=r,m=i,h=t}},this.setMorphTime=e=>{this.requestRender();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,r)=>{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()}}};Nt.prototype=Object.create(jt.prototype),Nt.prototype.constructor=Nt;var Pt=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}},Ft=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,L=!1,R,z=0,B={default:new Pt};B.default.nearPlane=.1,B.default.farPlane=2e3,B.default.eyePosition=[0,0,0],B.default.targetPosition=[0,0,-1],B.default.upVector=[0,1,0],this.cameraObject.target===void 0&&(this.cameraObject.target=new e.Vector3(...B.default.targetPosition)),this.calculateMaxAllowedDistance=e=>{let t=e.getBoundingBox();if(t){t.getBoundingSphere(F),z=F.radius*6;let e=0;this.cameraObject&&(e=this.cameraObject.position.distanceTo(F.center)),z=e>z?e*1.5:z}else z=0};let ee=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&&(B[e]=t)},this.setDefaultViewport=e=>e&&e in B?(v=e,!0):!1,this.getDefaultViewport=()=>v,this.getViewportOfName=e=>B[e],this.setCurrentViewport=e=>e in B&&(this.setCurrentCameraSettings(B[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=()=>{L=!0,E&&=void 0,R&&R.setCurrentCameraSettings(this.cameraObject,B[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)=>{V(!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)=>{V(!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 te=(e,t)=>{e instanceof HTMLCanvasElement&&(e.tabIndex=t)},ne=()=>{if(z>0){let e=I.distanceTo(F.center);return z>e||this.cameraObject.position.distanceTo(F.center)>e}return!0},re=e=>{L=!0,I.copy(this.cameraObject.position).add(e),ne()&&(this.cameraObject.target.add(e),this.cameraObject.position.add(e),this.updateDirectionalLight())},ie=e=>{V(!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);re(e)}},ae=e=>{if(V(!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);re(e)}}else this._state===o.NONE&&T!==void 0&&T.move(this,e.clientX,e.clientY,this.renderer)}},oe=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)},se=e=>{this._state=o.NONE},ce=e=>{V(!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)},le=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)},ue=e=>{let t=this._state;if(this.touchZoomDistanceStart=this.touchZoomDistanceEnd=0,this.targetTouchId=-1,this._state=o.NONE,t===o.TOUCH_ROTATE&&e.touches.length===0&&e.changedTouches&&e.changedTouches.length===1&&E&&T!==void 0){let t=e.changedTouches[0];this.pointer_x_start==t.clientX-E.left&&this.pointer_y_start==t.clientY-E.top&&T.pick(this,t.clientX,t.clientY,this.renderer)}},de=()=>{V(!0)},V=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)}},fe=e=>{V(!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()},pe=e=>{V(!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()},me=e=>{this._state=o.NONE},he=()=>{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),re(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)=>{L=!0;let n=this.getVectorsFromRotateAboutLookAtPoints(e,t);this.cameraObject.position.copy(n.position),this.updateDirectionalLight(),this.cameraObject.up.copy(n.up)};let ge=()=>{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},_e=()=>{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=N.copy(this.cameraObject.position);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,ne()&&(this.cameraObject.position.copy(I),this.updateDirectionalLight(),ee(i),L=!0))}};let ve=()=>{let e=_e();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=()=>{L=!0,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&&(te(this.domElement,0),this.domElement.addEventListener(`mousedown`,ie,!1),this.domElement.addEventListener(`mousemove`,ae,!1),this.domElement.addEventListener(`mouseup`,oe,!1),this.domElement.addEventListener(`mouseleave`,se,!1),this.domElement.addEventListener(`touchstart`,ce,!1),this.domElement.addEventListener(`touchmove`,le,!1),this.domElement.addEventListener(`touchend`,ue,!1),this.domElement.addEventListener(`wheel`,fe,!1),this.domElement.addEventListener(`mouseenter`,de,!1),this.domElement.addEventListener(`contextmenu`,e=>{e.preventDefault()},!1),this.domElement.addEventListener(`keydown`,pe,!1),this.domElement.addEventListener(`keyup`,me,!1))},this.disable=function(){d=!1,this._state=o.NONE,this.domElement&&this.domElement.removeEventListener&&(this.domElement.removeEventListener(`mousedown`,ie,!1),this.domElement.removeEventListener(`mousemove`,ae,!1),this.domElement.removeEventListener(`mouseup`,oe,!1),this.domElement.removeEventListener(`mouseleave`,se,!1),this.domElement.removeEventListener(`touchstart`,ce,!1),this.domElement.removeEventListener(`touchmove`,le,!1),this.domElement.removeEventListener(`touchend`,ue,!1),this.domElement.removeEventListener(`wheel`,fe,!1),this.domElement.removeEventListener(`mouseenter`,de,!1),this.domElement.removeEventListener(`contextmenu`,e=>{e.preventDefault()},!1),this.domElement.removeEventListener(`keydown`,pe,!1),this.domElement.removeEventListener(`keyup`,me,!1),te(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 ye=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=>{L=!0,m>2&&(f=u*e/(m-1),f<0&&(f=0),f>u&&(f=u))};let be=e=>{if(y===a.PATH&&(ye(e),p)){let e=this.getCurrentTimeFrame(),t=e[0],n=e[1],r=e[2],i=t*3,a=n*3,o=r*p[i]+(1-r)*p[a],s=r*p[i+1]+(1-r)*p[a+1],c=r*p[i+2]+(1-r)*p[a+2];this.cameraObject.position.set(o,s,c),this.cameraObject.target.set(p[a],p[a+1],p[a+2]),_&&this.cameraObject.lookAt(this.cameraObject.target),h&&(this.directionalLight.position.set(o,s,c),this.directionalLight.target.position.set(p[a],p[a+1],p[a+2]))}};this.calculatePathNow=()=>{L=!0,be(0)};let xe=()=>{this._state===o.ROTATE||this._state===o.TOUCH_ROTATE||this._state===o.KEYBOARD_ROTATE?ge():this._state===o.PAN||this._state===o.TOUCH_PAN||this._state===o.KEYBOARD_PAN?(he(),R.triggerCallback()):(this._state===o.ZOOM||this._state===o.TOUCH_ZOOM||this._state===o.SCROLL||this._state===o.KEYBOARD_ZOOM)&&(R.zoom(_e()),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,R.triggerCallback())};this.update=e=>{let t=e*g,n=d,r=!0;return y===a.PATH?be(t):y===a.SMOOTH_CAMERA_TRANSITION&&b?(b.update(t),b.isTransitionCompleted()&&(b=void 0,y=a.DEFAULT),n=!1):y===a.ROTATE_TRANSITION&&x?(x.update(t),x.isTransitionCompleted()&&(x=void 0,y=a.DEFAULT),n=!1):y===a.AUTO_TUMBLE&&S?S.update(t):y===a.SYNC_CONTROL&&R?(xe(),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?ge():this._state===o.PAN||this._state===o.TOUCH_PAN||this._state===o.KEYBOARD_PAN?he():(this._state===o.ZOOM||this._state===o.TOUCH_ZOOM||this._state===o.SCROLL||this._state===o.KEYBOARD_ZOOM)&&ve(),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||=L,L=!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=()=>{L=!0;let e=B[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(),L=!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 Pt;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 Pt;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 It(e,t,this,n))},this.rotateCameraTransition=(e,t,n)=>{b??(x=new Lt(e,t,this,n))},this.enableCameraTransition=()=>{b&&(y=a.SMOOTH_CAMERA_TRANSITION),x&&(y=a.ROTATE_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_TRANSITION,this.autoTumble=(e,t,n)=>{S=new zt(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 Rt(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,R||=new Ut,R.setCurrentCameraSettings(this.cameraObject,B[v]),R),this.disableSyncControl=()=>{y=a.DEFAULT,this.cameraObject.zoom=1,this.cameraObject.updateProjectionMatrix()},this.enable()},It=function(e,t,n,r){let i=e.eyePosition,a=e.targetPosition,o=t.eyePosition,s=t.targetPosition,c=n,l=r,u=0,d=!1;c.near=Math.min(e.nearPlane,t.nearPlane),c.far=Math.max(e.farPlane,t.farPlane),c.cameraObject.up.set(t.upVector[0],t.upVector[1],t.upVector[2]),this.setDuration=e=>{l=e};let f=e=>{let t=u+e;t>l&&(t=l),u=t},p=()=>{let e=u/l,t=1-e;c.cameraObject.position.set(i[0]*t+o[0]*e,i[1]*t+o[1]*e,i[2]*t+o[2]*e),c.cameraObject.target.set(a[0]*t+s[0]*e,a[1]*t+s[1]*e,a[2]*t+s[2]*e)};this.update=e=>{this.enabled!==!1&&(f(e),p(),u==l&&(d=!0))},this.isTransitionCompleted=()=>d},Lt=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},Rt=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=!1,x;this.enable=()=>{d=!0},this.disable=()=>{d=!1},this.getIntersectsObject=e=>{s!==o&&o.getThreeJSScene().updateMatrixWorld();let t=x||o.getPickableThreeJSObjects();return v.length=0,f.intersectObjects(t,!0,v)},this.setPickableObjects=e=>{e===void 0?x=void 0:(x=[],e.forEach(e=>{e.getGroup()&&e.getGroup().visible&&x.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),s?.invalidate?.()}};let S=(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),s?.invalidate?.()}};this.move=(e,t,n)=>{d&&c&&o&&e&&u&&(y.zincCamera=e,y.x=t,y.y=n,o.displayMarkers?typeof requestAnimationFrame==`function`?b||(b=!0,requestAnimationFrame(()=>{b=!1,S(y.zincCamera,y.x,y.y)})):S(e,t,n):m||(_=h?Date.now()-h.getTime():250,_>=250?S(e,t,n):(m=!0,setTimeout(C(y),250-_))))};let C=e=>function(){m=!1,S(e.zincCamera,e.x,e.y)}},zt=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))}},Bt=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(Bt.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.MathUtils.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 Vt=function(e){let t=new Bt;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)),a=new e.Vector3,o=new e.Quaternion;return(e,s,c,l,u)=>{a.subVectors(e.target,e.position),n.set(c,s,-l,`YXZ`),o.setFromEuler(n),o.multiply(i),o.multiply(r.setFromAxisAngle(t,-u)),a.applyQuaternion(o),a.addVectors(e.position,a),e.lookAt(a)}})();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.MathUtils.degToRad(n.deviceOrientation.alpha):0,r=n.deviceOrientation.beta?e.MathUtils.degToRad(n.deviceOrientation.beta):0,i=n.deviceOrientation.gamma?e.MathUtils.degToRad(n.deviceOrientation.gamma):0,o=n.screenOrientation?e.MathUtils.degToRad(n.screenOrientation):0;a(n.object,t,r,i,o)},this.dispose=function(){this.disconnect()},this.connect()},Ut=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()}},Wt=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`,b);Wt.colorSpace=e.SRGBColorSpace;var Gt=[.02,.03,1],Kt=new e.SpriteMaterial({map:Wt,alphaTest:.5,transparent:!0,depthTest:!1,depthWrite:!1,sizeAttenuation:!1}),qt=function(t){H.call(this),this.texture=Wt;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(Kt);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),L(e.label),e.label.material.map.dispose(),e.label.material.dispose()),e.label=ge(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),n?.invalidate?.(),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};qt.prototype=Object.create(H.prototype);var Jt=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,l=new e.Vector3,u=new e.Vector3,d=new e.Vector3,f=[new e.Vector3,new e.Vector3,new e.Vector3,new e.Vector3],p=[f[0],f[1],f[2],f[2],f[3],f[0]],m=new e.Box3,h=new e.Matrix4,g=new e.Matrix4,_,v=!1,y=(e,t)=>{for(let n=0;n<16;n++)if(!Object.is(e.elements[n],t.elements[n]))return!1;return!0};this.getDiffFromNormalised=(t,n)=>(s.setFromBufferAttribute(a).getCenter(c),l.copy(c).project(this.camera),new e.Vector3(t,n,l.z).unproject(this.camera).sub(c));let b=(e,t)=>{n.camera.near&&(this.camera.near=n.camera.near),t.farPlane&&(this.camera.far=t.farPlane),t.eyePosition&&this.camera.position.set(t.eyePosition[0],t.eyePosition[1],t.eyePosition[2]),t.upVector&&this.camera.up.set(t.upVector[0],t.upVector[1],t.upVector[2]),t.targetPosition&&this.camera.lookAt(u.set(t.targetPosition[0],t.targetPosition[1],t.targetPosition[2])),this.camera.zoom=1/e,this.camera.updateProjectionMatrix()};this.getBoundary=()=>{let e=n.camera;d.copy(e.target).project(e),f[0].set(-1,-1,d.z).unproject(e),f[1].set(1,-1,d.z).unproject(e),f[2].set(1,1,d.z).unproject(e),f[3].set(-1,1,d.z).unproject(e),ye(a,p)},this.updateCamera=()=>{let e=n.camera,t=n.getBoundingBox();if(v&&t&&t.equals(m)&&_===e.near&&y(h,e.matrixWorld)&&y(g,e.projectionMatrix))return;this.getBoundary(),h.copy(e.matrixWorld),g.copy(e.projectionMatrix),_=e.near,v=!1;let r=n.getZincCameraControls();if(t){m.copy(t),v=!0;let e=t.min.distanceTo(t.max),n=e/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=r.getViewportFromCentreAndRadius(i,a,o,n,40,n*4);b(e,s)}}},Yt=new e.Box3,Xt=new e.Vector3,Zt=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),Yt.setFromBufferAttribute(n),this.boundingBox.union(Yt))}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(){}},Qt=new e.Vector3,$t=new e.Vector3,W=new e.Vector4,G=new e.Vector4,K=new e.Vector4,en=new e.Vector3,tn=new e.Matrix4,q=new e.Line3,nn=new e.Vector3,rn=new e.Box3,an=new e.Sphere,J=new e.Vector4,on=new e.Vector4,Y,sn;function cn(e,t,n){return J.set(0,0,-t,1).applyMatrix4(e.projectionMatrix),J.multiplyScalar(1/J.w),J.x=sn/n.width,J.y=sn/n.height,J.applyMatrix4(e.projectionMatrixInverse),J.multiplyScalar(1/J.w),Math.abs(Math.max(J.x,J.y))}function ln(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++){q.start.fromBufferAttribute(a,i),q.end.fromBufferAttribute(o,i),q.applyMatrix4(r);let s=new e.Vector3,c=new e.Vector3;Y.distanceSqToSegment(q.start,q.end,c,s),c.distanceTo(s)<sn*.5&&n.push({point:c,pointOnLine:s,distance:Y.origin.distanceTo(c),object:t,face:null,faceIndex:i,uv:null,uv1:null})}}function un(t,n,r){let i=n.projectionMatrix,a=t.matrixWorld,o=t._resolution,s=t.geometry,c=s.attributes.instanceStart,l=s.attributes.instanceEnd,u=Math.min(s.instanceCount,c.count),d=-n.near;Y.at(1,K),K.w=1,K.applyMatrix4(n.matrixWorldInverse),K.applyMatrix4(i),K.multiplyScalar(1/K.w),K.x*=o.x/2,K.y*=o.y/2,K.z=0,en.copy(K),tn.multiplyMatrices(n.matrixWorldInverse,a);for(let n=0,s=u;n<s;n++){if(W.fromBufferAttribute(c,n),G.fromBufferAttribute(l,n),W.w=1,G.w=1,W.applyMatrix4(tn),G.applyMatrix4(tn),W.z>d&&G.z>d)continue;if(W.z>d){let e=W.z-G.z,t=(W.z-d)/e;W.lerp(G,t)}else if(G.z>d){let e=G.z-W.z,t=(G.z-d)/e;G.lerp(W,t)}W.applyMatrix4(i),G.applyMatrix4(i),W.multiplyScalar(1/W.w),G.multiplyScalar(1/G.w),W.x*=o.x/2,W.y*=o.y/2,G.x*=o.x/2,G.y*=o.y/2,q.start.copy(W),q.start.z=0,q.end.copy(G),q.end.z=0;let s=q.closestPointToPointParameter(en,!0);q.at(s,nn);let u=e.MathUtils.lerp(W.z,G.z,s),f=u>=-1&&u<=1,p=en.distanceTo(nn)<sn*.5;if(f&&p){q.start.fromBufferAttribute(c,n),q.end.fromBufferAttribute(l,n),q.start.applyMatrix4(a),q.end.applyMatrix4(a);let i=new e.Vector3,o=new e.Vector3;Y.distanceSqToSegment(q.start,q.end,o,i),r.push({point:o,pointOnLine:i,distance:Y.origin.distanceTo(o),object:t,face:null,faceIndex:n,uv:null,uv1:null})}}}var dn=class extends e.Mesh{constructor(t=new Zt,n=new e.Line2NodeMaterial({color:Math.random()*16777215})){super(t,n),this.isLineSegments2=!0,this.type=`LineSegments2`,this._resolution=new e.Vector2}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)Qt.fromBufferAttribute(n,e),$t.fromBufferAttribute(r,e),i[t]=t===0?0:i[t-1],i[t+1]=i[t]+Qt.distanceTo($t);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}onBeforeRender(e){e.getViewport(on),this._resolution.set(on.z,on.w)}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._resolution.x===0||this._resolution.y===0))return;let i=e.params.Line2===void 0?0:e.params.Line2.threshold||0;Y=e.ray;let a=this.matrixWorld,o=this.geometry;sn=this.material.linewidth+i,o.boundingSphere===null&&o.computeBoundingSphere(),an.copy(o.boundingSphere).applyMatrix4(a);let s;if(s=n?sn*.5:cn(r,Math.max(r.near,an.distanceToPoint(Y.origin)),this._resolution),an.radius+=s,Y.intersectsSphere(an)===!1)return;o.boundingBox===null&&o.computeBoundingBox(),rn.copy(o.boundingBox).applyMatrix4(a);let c;c=n?sn*.5:cn(r,Math.max(r.near,rn.distanceToPoint(Y.origin)),this._resolution),rn.expandByScalar(c),Y.intersectsBox(rn)!==!1&&(n?ln(this,t):un(this,r,t))}},fn=function(){Dt.call(this),this.isLines2=!0;let t=new Float32Array(300),n=e=>{if(e>t.length){let n=Math.ceil(Math.max(t.length*2,e)/6)*6,r=new Float32Array(n);return r.set(t),t=r,!0}return!1},r=(e,n)=>{for(let r=e;r+2<t.length;r+=3)t[r]=n[0],t[r+1]=n[1],t[r+2]=n[2]},i=e=>{let n=e.geometry,r=n.attributes.instanceDistanceStart,i=n.attributes.instanceStart;if(!r||r.data.array.length!==i.count*2){e.computeLineDistances();return}let a=r.data.array,o=0;for(let e=0;e<i.count;e++){let n=e*6,r=t[n+3]-t[n],i=t[n+4]-t[n+1],s=t[n+5]-t[n+2];a[e*2]=o,o+=Math.sqrt(r*r+i*i+s*s),a[e*2+1]=o}r.data.needsUpdate=!0},a=(e,n)=>{let r=e.geometry.getAttribute(`instanceStart`);n||!r||r.data.array!==t?(e.geometry.setPositions(t),e.computeLineDistances()):(r.data.needsUpdate=!0,i(e),e.geometry.computeBoundingBox(),e.geometry.computeBoundingSphere()),this.boundingBoxUpdateRequired=!0};this.createLineSegment=(e,t,n)=>{if(e&&t){let r=new Zt;r.setPositions(e),r.colorsNeedUpdate=!0;let i=new dn(r,t);i.scale.set(1,1,1),i.computeLineDistances(),this.setMesh(i,n.localTimeEnabled,n.localMorphColour)}},this.setWidth=e=>{this.requestRender(),this.morph&&this.morph.material&&(this.morph.material.linewidth=e,this.morph.material.needsUpdate=!0)},this.addVertices=function(e){if(this.requestRender(),e&&e.length){let i=this.getMorph();i||(this.drawRange=0);let o=this.drawRange*3,s=n(o+e.length*3);e.forEach(e=>{t[o++]=e[0],t[o++]=e[1],t[o++]=e[2],this.drawRange++}),i?(s&&r(o,e[0]),a(i,s)):r(o,e[0])}return t},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(e,n){if(this.requestRender(),e&&e.length){let i=this.getMorph(),o=n+e.length-1;if(!i||0>n||o>=this.drawRange)return;{let o=n*3;e.forEach(e=>{t[o++]=e[0],t[o++]=e[1],t[o++]=e[2]}),r(this.drawRange*3,e[0]),a(i,!1)}}return t},this.addLines=(n,r)=>{if(this.requestRender(),n&&n.length>0){if(this.addVertices(n),!this.getMorph()){let n=new e.Line2NodeMaterial({color:r,linewidth:1,vertexColors:!1,worldUnits:!1});this.createLineSegment(t,n,{localTimeEnabled:!1,localMorphColour:!1})}this.region&&(this.region.pickableUpdateRequired=!0)}}};fn.prototype=Object.create(Dt.prototype),fn.prototype.constructor=fn;var pn=0,mn=function(){return`re`+pn++},hn=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=mn();let d=()=>{c?.invalidate?.()};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=>{d(),e!=i.visible&&(i.visible=e,this.pickableUpdateRequired=!0)},this.getVisibility=()=>i.visible,this.getGroup=()=>i,this.setTransformation=e=>{d(),l.set(...e),i.matrix.copy(l),te(i),i.updateMatrixWorld(!0),this.getAllObjects(!0).forEach(e=>{e.boundingBoxUpdateRequired=!0})},this.setName=e=>{e&&e!==``&&(o=e)},this.getName=()=>o,this.getParent=()=>r,this.getScene=()=>c,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=>{d();let t=new hn(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=>{d(),e&&(e.setRegion(this),i.add(e.getGroup()),s.push(e),this.pickableUpdateRequired=!0,c&&c.triggerObjectAddedCallback(e))},this.removeZincObject=e=>{d();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.clearPickableUpdateRequired=e=>{this.pickableUpdateRequired=!1,e&&a.forEach(t=>{t.clearPickableUpdateRequired(e)})},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):this.clearPickableUpdateRequired(t),e),this.setDuration=e=>{u=e,s.forEach(t=>t.setDuration(e)),a.forEach(t=>t.setDuration(e))},this.getDuration=()=>u,this.getBoundingBox=t=>{let n=new e.Box3;if(this.accumulateBoundingBox(n,t))return n},this.accumulateBoundingBox=(e,t)=>{let n=!1;for(let t=0;t<s.length;t++){let r=s[t].getBoundingBox();r&&(e.union(r),n=!0)}if(t)for(let r=0;r<a.length;r++)a[r].accumulateBoundingBox(e,t)&&(n=!0);return n},this.clear=e=>{d(),e&&a.forEach(t=>{t.clear(e),i.remove(t.getGroup())}),s.forEach(e=>{i.remove(e.getGroup()),e.dispose()}),e&&(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,t=[])=>{for(let e=0;e<s.length;e++)t.push(s[e]);if(e)for(let n=0;n<a.length;n++)a[n].getAllObjects(e,t);return 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(n=>{n.setMorphTime(e,t)})},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.renderObjects=(e,t,n,r,i)=>{for(let i=0;i<s.length;i++)s[i].render(e,t,n,r);if(i)for(let o=0;o<a.length;o++)a[o].renderObjects(e,t,n,r,i)},this.renderGeometries=(e,t,n,r,i,a)=>{this.renderObjects(e*t,n,r,i,a),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 Et;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 fn;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 Ge,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}},gn=class{constructor(e){this.writer=e,this.name=`ZINC_morph_colour`}writeMesh(t,n){let r=t.geometry,i=r&&r.morphAttributes?r.morphAttributes.color:void 0,a=r?r.attributes.color:void 0,o=n.primitives?n.primitives[0]:void 0;if(!i||!a||!o||!o.targets)return;let s=o.targets,c=a.itemSize,l=a.count;for(let t=0;t<s.length&&t<i.length;t++){let n=i[t];if(n.itemSize!==c||n.count<l){console.warn(`GLTFExporter: Colour morph target does not match the base colour, skipped.`);return}let o=new Float32Array(l*c);for(let e=0;e<l;e++)for(let t=0;t<c;t++){let i=n.getComponent(e,t);o[e*c+t]=r.morphTargetsRelative?i:i-a.getComponent(e,t)}s[t].COLOR_0=this.writer.processAccessor(new e.BufferAttribute(o,c),r)}}},_n=function(e){let t=e,n=e=>{for(let t=e;t;t=t.parent)if(t.visible===!1)return!1;return!0};this.exportGLTF=async e=>{let r=t.getRootRegion().getAllObjects(!0),a=[],o=[];for(let e of r){if(e.animationClip&&e.animationClip[0]){let t=e.getMorph();if(t&&n(t)){let n=e.animationClip[0].clone();n.tracks.forEach(e=>{e.name=t.uuid+e.name}),a.push(n)}}e.isGlyphset&&e.prepareColorForExport&&(await e.prepareColorForExport(),o.push(e))}let s=pe(t.getThreeJSScene()),c=new i.GLTFExporter;c.register(e=>new gn(e));let l={binary:e,animations:a,onlyVisible:!0};try{return await new Promise((e,n)=>{c.parse(t.getThreeJSScene(),function(t){e(t)},function(e){console.error(`Unable to export GLTF.`,e),n(e)},l)})}finally{s(),o.forEach(e=>e.clearColorExportState())}}},vn=function(){let e=this,t=e=>{let t=e.geometry;if(!t||!t.morphAttributes)return;let n=[];if(e.morphTargetDictionary)for(let t in e.morphTargetDictionary)n[e.morphTargetDictionary[t]]=t;for(let e in t.morphAttributes){let r=t.attributes[e];t.morphAttributes[e].forEach((e,i)=>{if(t.morphTargetsRelative&&r){let t=e.array,n=r.array,i=Math.min(t.length,n.length);for(let e=0;e<i;e++)t[e]+=n[e];e.needsUpdate=!0}n[i]!==void 0&&(e.name=n[i])})}t.morphTargetsRelative=!1},n=e=>{let t=e=>(e.vertexColors=!1,xe(e));e.material=Array.isArray(e.material)?e.material.map(t):t(e.material)};this.parseGLTFObjects=(r,i,a,o)=>{let s=i;if(a!==0){if(r.type===`Object3D`){if(r.name!==``&&(i&&(s=i.findOrCreateChildFromPath(r.name)),s)){let e=s.getGroup();e.position.copy(r.position),e.rotation.copy(r.rotation),e.quaternion.copy(r.quaternion),e.matrixAutoUpdate=!0}}else{let e;if(r.type===`Mesh`?e=new Ge:r.type===`LineSegments`?e=new Dt:r.type===`Points`&&(e=new Et),e){let a=!1,s=!1;r.geometry&&r.geometry.morphAttributes&&(t(r),a=!!r.geometry.morphAttributes.position,s=!!r.geometry.morphAttributes.color);let c=r.clone();s&&!e.isPointset&&n(c),e.setMesh(c,a,s);let l=e.getMorph();e.groupName=l.name,l.matrixAutoUpdate=!0,i.addZincObject(e),o!=null&&typeof o==`function`&&o(e)}}}a++,r.children.forEach(t=>{e.parseGLTFObjects(t,s,a,o)})},this.setCamera=e=>{e.viewAll();let t=e.getZincCameraControls(),n=t.getCurrentViewport();t.addViewport(`default`,n),t.setDefaultViewport(`default`)},this.load=(t,n,r,i,o,s,c)=>{let l=r.substring(0,r.lastIndexOf(`/`)+1),u=r.substring(r.lastIndexOf(`/`)+1,r.length);new a.GLTFLoader().setPath(l).load(u,function(r){c&&c()||(console.log(r),e.parseGLTFObjects(r.scene,n,0,i),e.setCamera(t),o!=null&&typeof o==`function`&&o())})}},yn=/^[og]\s*(.+)?/,bn=/^mtllib /,xn=/^usemtl /,Sn=/^usemap /,Cn=new e.Vector3,wn=new e.Vector3,Tn=new e.Vector3,En=new e.Vector3,X=new e.Vector3;function Dn(){let e={objects:[],object:{},vertices:[],normals:[],colors:[],uvs:[],materials:{},materialLibraries:[],startObject:function(e,t){if(this.object&&this.object.fromDeclaration===!1){this.object.name=e,this.object.fromDeclaration=t!==!1;return}let n=this.object&&typeof this.object.currentMaterial==`function`?this.object.currentMaterial():void 0;if(this.object&&typeof this.object._finalize==`function`&&this.object._finalize(!0),this.object={name:e||``,fromDeclaration:t!==!1,geometry:{vertices:[],normals:[],colors:[],uvs:[],hasUVIndices:!1},materials:[],smooth:!0,startMaterial:function(e,t){let n=this._finalize(!1);n&&(n.inherited||n.groupCount<=0)&&this.materials.splice(n.index,1);let r={index:this.materials.length,name:e||``,mtllib:Array.isArray(t)&&t.length>0?t[t.length-1]:``,smooth:n===void 0?this.smooth:n.smooth,groupStart:n===void 0?0:n.groupEnd,groupEnd:-1,groupCount:-1,inherited:!1,clone:function(e){let t={index:typeof e==`number`?e:this.index,name:this.name,mtllib:this.mtllib,smooth:this.smooth,groupStart:0,groupEnd:-1,groupCount:-1,inherited:!1};return t.clone=this.clone.bind(t),t}};return this.materials.push(r),r},currentMaterial:function(){if(this.materials.length>0)return this.materials[this.materials.length-1]},_finalize:function(e){let t=this.currentMaterial();if(t&&t.groupEnd===-1&&(t.groupEnd=this.geometry.vertices.length/3,t.groupCount=t.groupEnd-t.groupStart,t.inherited=!1),e&&this.materials.length>1)for(let e=this.materials.length-1;e>=0;e--)this.materials[e].groupCount<=0&&this.materials.splice(e,1);return e&&this.materials.length===0&&this.materials.push({name:``,smooth:this.smooth}),t}},n&&n.name&&typeof n.clone==`function`){let e=n.clone(0);e.inherited=!0,this.object.materials.push(e)}this.objects.push(this.object)},finalize:function(){this.object&&typeof this.object._finalize==`function`&&this.object._finalize(!0)},parseVertexIndex:function(e,t){let n=parseInt(e,10);return(n>=0?n-1:n+t/3)*3},parseNormalIndex:function(e,t){let n=parseInt(e,10);return(n>=0?n-1:n+t/3)*3},parseUVIndex:function(e,t){let n=parseInt(e,10);return(n>=0?n-1:n+t/2)*2},addVertex:function(e,t,n){let r=this.vertices,i=this.object.geometry.vertices;i.push(r[e+0],r[e+1],r[e+2]),i.push(r[t+0],r[t+1],r[t+2]),i.push(r[n+0],r[n+1],r[n+2])},addVertexPoint:function(e){let t=this.vertices;this.object.geometry.vertices.push(t[e+0],t[e+1],t[e+2])},addVertexLine:function(e){let t=this.vertices;this.object.geometry.vertices.push(t[e+0],t[e+1],t[e+2])},addNormal:function(e,t,n){let r=this.normals,i=this.object.geometry.normals;i.push(r[e+0],r[e+1],r[e+2]),i.push(r[t+0],r[t+1],r[t+2]),i.push(r[n+0],r[n+1],r[n+2])},addFaceNormal:function(e,t,n){let r=this.vertices,i=this.object.geometry.normals;Cn.fromArray(r,e),wn.fromArray(r,t),Tn.fromArray(r,n),X.subVectors(Tn,wn),En.subVectors(Cn,wn),X.cross(En),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 On=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 Dn;t.indexOf(`\r
|
|
2
2
|
`)!==-1&&(t=t.replace(/\r\n/g,`
|
|
3
3
|
`)),t.indexOf(`\\
|
|
4
4
|
`)!==-1&&(t=t.replace(/\\\n/g,``));let r=t.split(`
|
|
5
|
-
`),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=gn.exec(i))!==null){let e=(` `+s[0].substr(1).trim()).substr(1);n.startObject(e)}else if(vn.test(i))n.object.startMaterial(i.substring(7).trim(),n.materialLibraries);else if(_n.test(i))n.materialLibraries.push(i.substring(7).trim());else if(yn.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}},En=e.FileLoader,Dn=e=>{let t=(e,t)=>{if(e.metadata.number_of_vertices+=t.metadata.number_of_vertices,`labels`in e&&t.labels){let n=t.labels;for(let t=0;t<n.length;t++)e.labels.push(n[t])}[`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])}},On=e=>{if(e&&e.length>0){if(e.length===1)return e[0];let t=ue(e);return e.forEach(e=>e.dispose()),t}},kn=function(e,t,n,r){let i=new En,a=new rt;i.crossOrigin=t;let o=e,s=n,c=r,l,u=!1,d=!1,f,p=[],m=e=>{let t=l[e.index];if(t){if(`GlyphGeometriesURL`in t)e.onLoad(t);else{let n=a.parse(t);e.onLoad(n.geometry,n.materials)}}else h(e,{responseURL:o})},h=e=>{e.onError&&(f||={responseURL:o},e.onError(f))};this.downloadCompleted=e=>{try{l=JSON.parse(e[0]),u=!1,d=!0,Array.isArray(l)?p.forEach(e=>m(e)):p.forEach(e=>h(e))}catch{p.forEach(e=>h(e))}};let g=()=>e=>{f=e,d=!0,u=!1,p.forEach(e=>{h(e)}),c&&c(e)},_=()=>e=>{p.forEach(t=>{t.onProgress&&t.onProgress(e)})};this.load=(e,t,n,r)=>{let a={index:e,onLoad:t,onProgress:n,onError:r};d?l?m(a):h(a):u?p.push(a):(p.push(a),u=!0,i.load(o,s,_(),g()))}},An=function(e,t,n,r){let i=[],a=e,o=t,s=n,c=0,l,u=r?.isGlyphsets,d=()=>{u||i.forEach(e=>{e&&(e[0]?.dispose?.(),e[1]?.forEach(e=>e.dispose()))}),s&&s(...l)};this.itemFailed=(e,t)=>{l||=t,c++,c==a&&d()},this.itemDownloaded=(e,t)=>{if(i[e]=t,c++,c==a){if(l)d();else if(i.length>0){if(u){let e=i.map(e=>JSON.parse(e[0]));Dn(e),o(e[0])}else{let e=i[0][1],t=On(i.map(e=>e[0]));for(let e=1;e<a;e++)i[e][1]?.forEach(e=>e.dispose());o(t,e)}}}}},jn=function(){let e=0;this.crossOrigin=`Anonymous`;let t=new rt,n=new En;n.crossOrigin=`Anonymous`;let r=[],i={},a=(e,t,n,r,i)=>{let a=e.length,o=new An(a,t,r,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),r=new c(void 0,this,{});++e,u=new kn(t,this.crossOrigin,n,r),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,!0);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,i=!1){return(...a)=>{--e,r?.msHandler?i?r.msHandler.itemFailed(r.order,a):r.msHandler.itemDownloaded(r.order,a):r?.isHandler?r.isHandler.downloadCompleted(a):t&&t(...a),n.loadFromWaitingList(),n.itemRemainingCheck()}};this.parse=e=>t.parse(e)},Mn=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))}},Nn=function(){H.call(this),this.isTubeLines=!0;let t={},n={radius:1,radialSegments:8,smooth:!1};this.createLineSegment=(n,a,o)=>{if(n&&a){t={geometryIn:n,materialIn:a,options:o};let s=i(r(n)),c=new e.MeshStandardMaterial({color:a.color}),l=new e.Mesh(s,c);this.setMesh(l,o.localTimeEnabled,o.localMorphColour)}},this.setWidth=e=>{this.requestRender(),this.morph&&this.morph.material&&(this.morph.material.linewidth=e,this.morph.material.needsUpdate=!0)},this.setAlpha=function(e){this.requestRender();let t=this.getMorph();t.material.opacity=e,t.material.transparent=e<1,t.material.depthWrite=e>.5},this.setWireframe=e=>{this.requestRender();let t=this.getMorph();t.material.wireframe=e},this.setTubeLines=(e,a)=>{if(this.requestRender(),e&&a){let{geometryIn:o}=t,s=this.getMorph();s.geometry.dispose(),n=Object.assign(n,{radius:e,radialSegments:a}),s.geometry=i(r(o))}};let r=t=>{let n=t.getAttribute(`position`),r=[];for(let t=0;t<n.count;t++)r.push(new e.Vector3().fromBufferAttribute(n,t));return r},i=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=ue(n,!0),n.forEach(e=>e.dispose())}return o}};Nn.prototype=Object.create(H.prototype);var Pn=function(t){let n=t;this.toBeDownloaded=0,this.progressMap={};let r=!1,i=!1,a=0,o=new jn;this.cancelPendingLoads=()=>{a++,this.toBeDownloaded=0,this.progressMap={},r=!1,i=!1};let s=()=>{let e=a;return()=>e!==a};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=>{let t=s();return n=>{t()||(--this.toBeDownloaded,i=!0,console.error(`There is an issue with external resource ${n?.responseURL?`: `+n?.responseURL:``}.`),e&&e({type:`Error`,xhr:n}))}};let c=(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=ee(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,a=s();fetch(i).then(e=>{if(!e.ok)throw Error(`HTTP error! status: ${e.status}`);return e.json()}).then(e=>{a()||(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,a,s)=>{let c=t.length;this.toBeDownloaded+=c;for(let l=0;l<c;l++){let c=t[l],u=lr.defaultMaterialColor,d=lr.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;a!=null&&a[l]!=null&&(p=!!a[l]),o.load(c,g(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`,a=s();fetch(i).then(e=>{if(!e.ok)throw Error(`HTTP error! status: ${e.status}`);return e.json()}).then(i=>{if(a())return;n.loadView(i);let o=[],s=t+`_`;for(let e=0;e<i.numberOfResources;e++){let t=s+(e+1)+`.json`;o.push(t)}this.loadModelsURL(e,o,i.colour,i.opacity,i.timeEnabled,i.morphColour,r)}).catch(e=>{console.error(`Failed to load view data from: ${i}`,e)})};let l=(t,r,i,a,c,l,u,d,f)=>{let p=s();return(s,m)=>{if(p()){s.dispose();return}let h=d?new Nn:new wt,g;m&&m[0]&&(g=new e.LineBasicMaterial({color:m[0].color.clone()}),1>m[0].opacity&&(g.transparent=!0),g.opacity=m[0].opacity,g.vertexColors=m[0].vertexColors);let _={};if(_.localTimeEnabled=r,_.localMorphColour=i,h&&(h.createLineSegment(s,g,_),h.setName(a),h.setAnatomicalId(c),h.setRenderOrder(l),t.addZincObject(h),h.setDuration(n.getDuration()),u&&u.levels))for(let[e,t]of Object.entries(u.levels))h.addLOD(o,e,t.URL,t.Index,u.preload);--this.toBeDownloaded,s.dispose(),f!=null&&typeof f==`function`&&f(h)}};this.loadLinesURL=(e,t,n,r,i,a,s)=>{let c=0;this.toBeDownloaded+=1;let u=s?.isInline?s.isInline:!1,d=s?.anatomicalId?s.anatomicalId:void 0,f=s&&`renderOrder`in s?s.renderOrder:void 0;n!=null&&(c=!!n);let p=0;r!=null&&(p=!!r);let m=s.tubeLines&&!c&&!p;if(u){let n=o.parse(t);l(e,c,p,i,d,f,s.lod,m,a)(n.geometry,n.materials)}else o.load(t,l(e,c,p,i,d,f,s.lod,m,a),this.onProgress(t),this.onError(a),s.loaderOptions)};let u=(e,t,r,i,a)=>{let o=s();return s=>{if(o())return;let c=s;(typeof c==`string`||c instanceof String)&&(c=JSON.parse(s));let l=a&&a.isInline?a.isInline:void 0,u=a&&a.anatomicalId?a.anatomicalId:void 0,d=a?.displayLabels;d===void 0&&(d=!0);let f=a&&`renderOrder`in a?a.renderOrder:void 0,p=new dt;p.setDuration(n.getDuration()),p.groupName=r,++this.toBeDownloaded,p.load(c,t,()=>{o()||(--this.toBeDownloaded,i!=null&&typeof i==`function`&&i(p))},l,d),p.setAnatomicalId(u),p.setRenderOrder(f),e.addZincObject(p)}};this.loadGlyphsetURL=(e,t,n,r,i,a)=>{a&&a.isInline&&a.isInline?u(e,n,r,i,a)(t):o.load(t,u(e,n,r,i,a),this.onProgress(t),this.onError(i),a.loaderOptions)};let d=(t,r,i,a,o,c,l)=>{let u=s();return(s,d)=>{if(u()){s.dispose();return}let f=new Ct,p=new e.PointsMaterial({alphaTest:.05,size:10,sizeAttenuation:!1});d&&d[0]&&(1>d[0].opacity&&(p.transparent=!0),p.opacity=d[0].opacity,p.color=d[0].color,p.vertexColors=!1);let m={};m.localTimeEnabled=r,m.localMorphColour=i,f&&(f.createMesh(s,p,m),f.setName(a),f.setAnatomicalId(o),t.addZincObject(f),f.setDuration(n.getDuration()),f.setRenderOrder(c)),s.dispose(),--this.toBeDownloaded,l!=null&&typeof l==`function`&&l(f)}};this.loadSTL=(e,t,n,r)=>{this.toBeDownloaded+=1;let i=lr.defaultMaterialColor,a=lr.defaultOpacity,o=new Mn;o.crossOrigin=`Anonymous`,o.load(t,g(e,i,a,!1,!1,n,void 0,void 0,{},r),this.onProgress(t),this.onError(r))},this.loadOBJ=(e,t,n,r)=>{this.toBeDownloaded+=1;let i=lr.defaultMaterialColor,a=lr.defaultOpacity,o=new Tn;o.crossOrigin=`Anonymous`,o.load(t,_(e,i,a,!1,!1,n,void 0,void 0,{},r),this.onProgress(t),this.onError(r))};let f=(e,t,n,r,i,a,s)=>{this.toBeDownloaded+=1;let c=lr.defaultMaterialColor,l=lr.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,m=s&&`renderOrder`in s?s.renderOrder:void 0;n!=null&&(u=!!n);let h=0;r!=null&&(h=!!r);let v=o;if(f==`STL`||f==`OBJ`){let n=f==`STL`?g:_;v=f==`STL`?new Mn:new Tn,v.crossOrigin=`Anonymous`,v.load(t,n(e,c,l,u,h,i,p,m,s||{},a),this.onProgress(t),this.onError(a));return}if(d){let n=o.parse(t);g(e,c,l,u,h,i,p,m,s,a)(n.geometry,n.materials)}else v.crossOrigin=`Anonymous`,o.load(t,g(e,c,l,u,h,i,p,m,s,a),this.onProgress(t),this.onError(a),s.loaderOptions)},p=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,a,s)=>{let c=0;this.toBeDownloaded+=1,n!=null&&(c=!!n);let l=0;r!=null&&(l=!!r);let u=s&&s.isInline?s.isInline:!1,f=s&&s.anatomicalId?s.anatomicalId:void 0,p=s&&`renderOrder`in s?s.renderOrder:void 0;if(u){let n=o.parse(t);d(e,c,l,i,f,p,a)(n.geometry,n.materials)}else o.load(t,d(e,c,l,i,f,p,a),this.onProgress(t),this.onError(a),s.loaderOptions)};let m=(e,t,n,r,i,a)=>{let o=a&&a.isInline?a.isInline:void 0,c=a&&a.anatomicalId?a.anatomicalId:void 0,l=a&&`renderOrder`in a?a.renderOrder:void 0,u;if(n){if(t&&n.images&&n.images.source){let e=n.images.source;for(let r=0;r<e.length;r++){let i=ee(e[r],t);n.images.source[r]=i}}if(n.type===`slides`&&(u=new At),u){u.groupName=r;let t=s();++this.toBeDownloaded,u.load(n,()=>{if(t()){u.dispose();return}e.addZincObject(u),--this.toBeDownloaded,i!=null&&typeof i==`function`&&i(u)},o),u.setAnatomicalId(c),u.setRenderOrder(l)}}};this.loadTextureURL=(e,t,n,r,i)=>{if(i&&i.isInline&&i.isInline)m(e,void 0,t,n,r,i);else{let a=t,o=s();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})=>{o()||m(e,a,t,n,r,i)}).catch(e=>{console.error(`Fetch failed for texture URL: ${a}`,e)})}};let h=(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 Ge;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},g=(e,t,n,r,i,a,c,l,u,d)=>{let f=s();return(s,p)=>{if(f()){s.dispose();return}let m;p&&p[0]&&(m=p[0]);let g=h(e,s,t,n,r,i,void 0,m,a,l,c);if(u?.lod?.levels)for(let[e,t]of Object.entries(u.lod.levels))g.addLOD(o,e,t.URL,t.Index,u.lod.preload);--this.toBeDownloaded,s.dispose(),d!=null&&typeof d==`function`&&d(g)}},_=(e,t,n,r,i,a,o,c,l,u)=>{let d=s(),f=g(e,t,n,r,i,a,o,c,l,u);return e=>{let t=[];if(e.traverse(e=>{e.isMesh&&e.geometry&&t.push(e),e.material&&(Array.isArray(e.material)?e.material:[e.material]).forEach(e=>e.dispose())}),d()){t.forEach(e=>e.geometry.dispose());return}if(t.length===0){--this.toBeDownloaded;return}this.toBeDownloaded+=t.length-1,t.forEach(e=>f(e.geometry))}},v=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=v(e.Duration);n.setDurationFromObject(t)}if(e.OriginalDuration){let t=v(e.OriginalDuration);n.setOriginalDurationFromObject(t)}if(e.TimeStamps)for(let t in e.TimeStamps){let r=v(e.TimeStamps[t]);n.addMetadataTimeStamp(t,r)}}};let y=(e,t,n,r,i)=>{if(n){let a,o=!1;n.URL?(a=n.URL,t&&(a=ee(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=ee(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`:f(e,a,n.MorphVertices,n.MorphColours,c,i,l);break;case`Glyph`:let r;o?r=n.Inline.GlyphGeometriesURL:(r=n.GlyphGeometriesURL,r=ee(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)}}},b=(e,t,i)=>{if(t){let a,o=!1;switch(t.URL?(a=t.URL,e&&(a=ee(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 hn().load(n,e,t,r,i,a,s())};let x=(e,t,n,r)=>{if(n.Primitives&&n.Primitives.forEach(n=>{let i=1;n.Order&&(i=n.Order),y(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&&x(n,t,a,r)}},S=(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(_e(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(_e(e.RegionPath,e.GroupName,i[t]))return!1;return!0}))),a&&n.forEach(e=>{e.Type===`Lines`&&(e.tubeLines=!0)}),n},C=(e,t)=>Array.isArray(e)?S(e,t):e,w=(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},T=e=>{let t=e.Primitives?w(e.Primitives,!1):0;return e.Children&&Object.values(e.Children).forEach(e=>{t+=T(e)}),t},E=e=>{if(Array.isArray(e))return w(e,!0);if(typeof e==`object`&&e&&e.Version===`2.0`)return T(e.Regions)},D=(e,t,n,r,i)=>{let a=e;n.RegionPath&&n.RegionPath!==``&&(a=e.findOrCreateChildFromPath(n.RegionPath)),y(a,t,n,r*2,i)},O=(e,t,n,r,i,a)=>{let o=C(t,a),s=E(o),c=new p(s,r,i);for(let e=0;e<o.length;e++)b(n,o[e],c);for(let t=0;t<o.length;t++)D(e,n,o[t],t,c)},k=(e,t,n,r,i)=>{let a=E(t),o=new p(a,r,i);t.Settings&&this.loadSettings(t.Settings),t.Views&&c(n,t.Views,n),t.Regions&&x(e,n,t.Regions,o)};this.loadMetadataURL=(e,t,i,a,o)=>{let c=t,l=s();fetch(c).then(e=>{if(!e.ok)throw Error(`HTTP error! status: ${e.status}`);let t=e.url||new URL(c).href;return e.json().then(e=>({metadata:e,referenceURL:t}))}).then(({metadata:t,referenceURL:s})=>{l()||(n.resetMetadata(),n.resetDuration(),r=!1,Array.isArray(t)?O(e,t,s,i,a,o):typeof t==`object`&&t&&t.Version===`2.0`&&k(e,t,s,i,a))}).catch(e=>{console.error(`Fetch failed for URL: ${c}`,e)})}},Fn=0,In=function(){return`sc`+Fn++},Ln=function(){return{Duration:`6 secs`,OriginalDuration:`-`,TimeStamps:{}}},Rn=6e3,zn=function(t,n){let r=t,i,a,o=!0,s=!1,c={},l={displayMarkers:void 0,displayMinimap:void 0,displayMiniAxes:void 0,playAnimation:void 0},u=new Pn(this),d,f={},p=0,m={},h=0,g=new e.Scene,_=new e.Scene,v=new fn(void 0,this);g.add(v.getGroup());let y=new e.Group;g.add(y),this.directionalLight=void 0,this.ambient=void 0,this.camera=void 0;let b=6e3,x;this.sceneName=void 0;let S=!1,C;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 w={x:0,y:0},T=Ln(),E=new e.Vector2,D=[];this.forcePickableObjectsUpdate=!1,this.uuid=In();let O=new Wt(this);O.disable(),g.add(O.group);let k={main:[],mini:[]},A=new e.Vector3(0,0,0),j=()=>r?r.clientWidth===void 0?r.width:r.clientWidth:0,M=()=>r?r.clientHeight===void 0?r.height:r.clientHeight:0;this.getDownloadProgress=()=>u.getDownloadProgress(),this.onWindowResize=()=>{o=!0;let e=M();this.camera.aspect=j()/e,this.camera.updateProjectionMatrix(),this.minimapScissor.updateRequired=!0,x.onResize(),x.calculateHeightPerPixelAtZeroDepth(e)},this.resetView=()=>{o=!0,this.onWindowResize(),x.resetView()},this.changeZoomByScrollRateUnit=e=>{o=!0,x.changeZoomByScrollRateUnit(e)},this.camera=new e.PerspectiveCamera(40,j()/M(),0,10),this.ambient=new e.AmbientLight(16777215,.2),g.add(this.ambient),this.directionalLight=new e.DirectionalLight(16777215,.7*Math.PI),g.add(this.directionalLight),x=new Mt(this.camera,n.domElement,n,this),x.setDirectionalLight(this.directionalLight),x.resetView(),d=new Gt(this),this.loadView=e=>{o=!0;let t=new jt;return t.setFromObject(e),x.setCurrentCameraSettings(t),!0},this.setupMultipleViews=(e,t)=>{for(let[e,n]of Object.entries(t)){let t=new jt;t.setFromObject(n),x.addViewport(e,t)}x.setDefaultViewport(e)},this.getBoundingBox=()=>v.getBoundingBox(!0),this.viewAllWithBoundingBox=e=>{if(o=!0,e){let t=x.getViewportFromBoundingBox(e,1);x.setCurrentCameraSettings(t),x.calculateHeightPerPixelAtZeroDepth(M()),O.markerUpdateRequired=!0}},this.viewAll=()=>{o=!0;let e=this.getBoundingBox();this.viewAllWithBoundingBox(e),O.markerUpdateRequired=!0},this.forEachGeometry=e=>{v.forEachGeometry(e,!0)},this.forEachGlyphset=e=>{v.forEachGlyphset(e,!0)},this.forEachPointset=e=>{v.forEachPointset(e,!0)},this.forEachLine=e=>{v.forEachLine(e,!0)},this.findGeometriesWithGroupName=e=>v.findGeometriesWithGroupName(e,!0),this.findPointsetsWithGroupName=e=>v.findPointsetsWithGroupName(e,!0),this.findGlyphsetsWithGroupName=e=>v.findGlyphsetsWithGroupName(e,!0),this.findLinesWithGroupName=e=>v.findLinesWithGroupName(e,!0),this.findObjectsWithGroupName=e=>v.findObjectsWithGroupName(e,!0),this.findObjectsWithAnatomicalId=e=>v.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=j(),n=M(),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=>{o=!0,e&&(v.addZincObject(e),x&&x.calculateMaxAllowedDistance(this))},this.loadGlyphsetURL=(e,t,n,r)=>{u.loadGlyphsetURL(v,e,t,n,r)},this.loadPointsetURL=(e,t,n,r,i)=>{u.loadPointsetURL(v,e,t,n,r,i)},this.loadLinesURL=(e,t,n,r,i)=>{u.loadLinesURL(v,e,t,n,r,i)},this.loadSTL=(e,t,n)=>{u.loadSTL(v,e,t,n)},this.loadOBJ=(e,t,n)=>{u.loadOBJ(v,e,t,n)},this.loadMetadataURL=(e,t,n,r)=>{u.loadMetadataURL(v,e,t,n,r)},this.loadModelsURL=(e,t,n,r,i,a)=>{u.loadModelsURL(v.urls,t,n,r,i,a)},this.loadViewURL=e=>{u.loadViewURL(e)},this.loadFromViewURL=(e,t)=>{u.loadFromViewURL(e,t)},this.loadGLTF=(e,t,n,r)=>{u.loadGLTF(v,e,t,n,r)},this.updateDirectionalLight=()=>{o=!0,x.updateDirectionalLight()},this.addObject=e=>{o=!0,g.add(e)},this.removeObject=e=>{o=!0,g.remove(e)},this.getCurrentTime=()=>{if(a!=null)return a.getCurrentTime(b);let e=v.getCurrentTime();return e===-1?0:e},this.setMorphsTime=e=>{o=!0,a?.setMorphTime(e,b),v.setMorphTime(e,!0)},this.isTimeVarying=()=>a&&a.video&&!a.video.error?!0:v.isTimeVarying(),this.renderGeometries=(e,t,n,r)=>{let i=o;o=!1,s=!1;let d=r?r.controls:x,f=c;if(f.camera=d,f.displayMarkers=this.displayMarkers,f.markerCluster=O,f.markersList=O.markers,f.ndcToBeUpdated=r?r.updated:!1,n&&(f.markerCluster.markerUpdateRequired=!0),a){if(a.isReadyToPlay()){n?a.video.play():a.video.pause();let e=a.video.currentTime/a.getVideoDuration()*b;u.toBeDownloaded==0?(r||(x.setTime(e),f.ndcToBeUpdated=x.update(0),f.ndcToBeUpdated&&x.calculateHeightPerPixelAtZeroDepth(M())),v.setMorphTime(e,!0),v.renderGeometries(0,0,n,d,f,!0)):!r&&x.update(0)&&(i=!0,s=!0)}(n||!a.isReadyToPlay())&&(i=!0)}else u.toBeDownloaded==0?(r||(f.ndcToBeUpdated=x.update(t),f.ndcToBeUpdated&&x.calculateHeightPerPixelAtZeroDepth(M())),v.renderGeometries(e,t,n,d,f,!0)):!r&&x.update(0)&&(i=!0,s=!0);return(l.displayMarkers!==this.displayMarkers||l.displayMinimap!==this.displayMinimap||l.displayMiniAxes!==this.displayMiniAxes||l.playAnimation!==n)&&(l.displayMarkers=this.displayMarkers,l.displayMinimap=this.displayMinimap,l.displayMiniAxes=this.displayMiniAxes,l.playAnimation=n,i=!0),this.minimapScissor.updateRequired&&(this.displayMinimap||this.displayMiniAxes)&&(i=!0),!r&&f.ndcToBeUpdated&&(s=!0),(f.ndcToBeUpdated||n&&this.isTimeVarying()||u.toBeDownloaded>0||O.isEnabled()&&O.markerUpdateRequired)&&(i=!0),o&&=(i=!0,!1),i},this.invalidate=()=>{o=!0},this.isCameraUpdated=()=>s,this.getThreeJSScene=()=>g,this.setVideoHandler=e=>{o=!0,a||=e},this.setAdditionalScenesGroup=e=>{g.add(e)};let N=(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}},P=e=>{(this.displayMinimap||this.displayMiniAxes)&&(e.setScissorTest(!0),e.getSize(E),this.minimapScissor.updateRequired&&(w=N(this.minimapScissor.align,this.minimapScissor.x_offset,this.minimapScissor.y_offset,this.minimapScissor.width,this.minimapScissor.height,E.x,E.y),this.minimapScissor.updateRequired=!1),e.setScissor(w.x,w.y,this.minimapScissor.width,this.minimapScissor.height),e.setViewport(w.x,w.y,this.minimapScissor.width,this.minimapScissor.height),d.updateCamera(),this.displayMiniAxes?e.render(_,d.camera):(g.add(d.mask),e.render(g,d.camera),g.remove(d.mask)),e.setScissorTest(!1),e.setViewport(0,0,E.x,E.y))};this.render=e=>{this.autoClearFlag&&e.clear(),S&&C?C.render(g,this.camera):(e.render(g,this.camera),P(e))},this.setInteractiveControlEnable=e=>{e==1?x.enable():x.disable()},this.getZincCameraControls=()=>x,this.getThreeJSScene=()=>g,this.setDuration=e=>{o=!0,v.setDuration(e),b=e,x.setPathDuration(e),u.duration=e},this.getDuration=()=>b,this.setStereoEffectEnable=e=>{o=!0,e==1&&(C||=new Rt(n)),n.setSize(j(),M()),this.camera.updateProjectionMatrix(),S=e},this.objectIsInScene=e=>v.objectIsInRegion(e,!0),this.alignBoundingBoxToCameraView=(t,n)=>{if(o=!0,t){t.getCenter(A);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,A).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),O.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()),O.markerUpdateRequired=!0}},this.alignObjectToCameraView=(e,t)=>{if(this.objectIsInScene(e)){let n=e.getBoundingBox();this.alignBoundingBoxToCameraView(n,t)}},this.setCameraTargetToObject=t=>{if(o=!0,this.objectIsInScene(t)){let n=t.getBoundingBox(),r=this.getZincCameraControls().getCurrentViewport();n.getCenter(A);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(A,o),r.eyePosition[0]=s.x,r.eyePosition[1]=s.y,r.eyePosition[2]=s.z,r.targetPosition[0]=A.x,r.targetPosition[1]=A.y,r.targetPosition[2]=A.z,this.getZincCameraControls().setCurrentCameraSettings(r),O.markerUpdateRequired=!0}},this.isStereoEffectEnable=()=>S,this.removeZincObject=e=>{o=!0,v.removeZincObject(e),x&&x.calculateMaxAllowedDistance(this),O.markerUpdateRequired=!0},this.updatePickableThreeJSObjects=()=>{D.length=0,O.isEnabled&&D.push(O.group),v.getPickableThreeJSObjects(D,!0),this.forcePickableObjectsUpdate=!1},this.getPickableThreeJSObjects=()=>((this.forcePickableObjectsUpdate||v.checkPickableUpdateRequred(!0))&&this.updatePickableThreeJSObjects(),D),this.getNormalisedMinimapCoordinates=(t,n)=>{if(this.displayMinimap){let r=new e.Vector2;t.getSize(r);let i=r.y-n.clientY;if(w.x+this.minimapScissor.width>n.clientX&&n.clientX>w.x&&w.y+this.minimapScissor.height>i&&i>w.y)return{x:(n.clientX-w.x)/this.minimapScissor.width*2-1,y:(i-w.y)/this.minimapScissor.height*2-1}}},this.getMinimapDiffFromNormalised=(e,t)=>{if(d)return d.getDiffFromNormalised(e,t)},this.isWebGL2=()=>n?.backend?.isWebGLBackend===!0,this.isWebGPU=()=>n?.backend?.isWebGPUBackend===!0,this.getRenderer=()=>n,this.clearAll=()=>{o=!0,O.clear(),v.clear(!0),this.clearZincObjectAddedCallbacks(),this.clearZincObjectRemovedCallbacks(),u.cancelPendingLoads(),x&&x.calculateMaxAllowedDistance(this),O.markerUpdateRequired=!0},this.addMetadataTimeStamp=(e,t)=>{T.TimeStamps[e]=I(t)},this.getMetadataTag=e=>T[e],this.getMetadata=()=>T,this.setMetadataTag=(e,t)=>{T[e]=t},this.removeMetadataTag=e=>{delete T[e]},this.resetMetadata=()=>{T=Ln()},this.resetDuration=()=>{this.setDuration(Rn)};let F=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(` `),I=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=F(e),n=I(e);this.setMetadataTag(`Duration`,t),this.setDuration(n)},this.setOriginalDurationFromObject=e=>{let t=F(e);this.setMetadataTag(`OriginalDuration`,t)},this.exportGLTF=e=>new mn(this).exportGLTF(e),this.getRootRegion=()=>v,this.createLines=(e,t,n,r)=>{let i=v.findChildFromPath(e);return i===void 0&&(i=v.createChildFromPath(e)),i.createLines(t,n,r)},this.createPoints=(e,t,n,r,i)=>{let a=v.findChildFromPath(e);return a===void 0&&(a=v.createChildFromPath(e)),a.createPoints(t,n,r,i)},this.addZincObjectAddedCallbacks=e=>(p+=1,f[p]=e,p),this.addZincObjectRemovedCallbacks=e=>(h+=1,m[h]=e,h),this.removeZincObjectAddedCallbacks=e=>{e in p&&delete f[e]},this.removeZincObjectRemovedCallbacks=e=>{e in h&&delete m[e]},this.clearZincObjectAddedCallbacks=()=>{f={},p=0},this.clearZincObjectRemovedCallbacks=()=>{m={},h=0},this.triggerObjectAddedCallback=e=>{for(let t in f)f.hasOwnProperty(t)&&f[t](e)},this.triggerObjectRemovedCallback=e=>{for(let t in m)m.hasOwnProperty(t)&&m[t](e)},this.addTemporaryPoints=(e,t)=>{o=!0;let n=yt(e.length),r=_t(he());r.color.set(t),r.size=15,r.userData.uniforms.pointSize.value=15,r.alphaTest=.5;let i=new ht(n,r,e.length),a=n.getAttribute(`instancePosition`);return i.pointPositions=a.array,e.forEach((e,t)=>{a.setXYZ(t,e[0],e[1],e[2])}),a.needsUpdate=!0,y.add(i),i},this.addTemporaryLines=(t,n)=>{o=!0;let r=new Fe(de(t.length,t),new e.LineBasicMaterial({color:n}));return y.add(r),r},this.enableFrustumDisplay=()=>{o=!0,this.camera&&!i&&(i=new e.CameraHelper(this.camera),g.add(i))},this.disableFrustumDisplay=()=>{o=!0,i&&=(g.remove(i),i.dispose(),void 0)},this.removeTemporaryPrimitive=e=>{o=!0,y.remove(e),e.geometry.dispose(),e.material.dispose()},this.clearTemporaryPrimitives=()=>{o=!0;let e=0;return y.children.forEach(t=>{t.geometry.dispose(),t.material.dispose(),e++}),y.clear(),e},this.addBoundingBoxPrimitive=(t,n,r,i,a,s=void 0)=>{o=!0;let c=v.findChildFromPath(t);c===void 0&&(c=v.createChildFromPath(t));let l=s||this.getBoundingBox();A.set(0,0,0);let u=A.subVectors(l.max,l.min),d=new e.BoxGeometry(u.x,u.y,u.z),f=c.createGeometryFromThreeJSGeometry(n,d,r,i,a,1e4);return u.addVectors(l.min,l.max).multiplyScalar(.5),f.setPosition(u.x,u.y,u.z),f},this.addSlicesPrimitive=(t,n,r,i,a,s=void 0)=>{if(o=!0,n&&n.length>=3&&r&&r.length>=3){let o=v.findChildFromPath(t);o===void 0&&(o=v.createChildFromPath(t));let c=s||this.getBoundingBox();A.set(0,0,0);let l=A.subVectors(c.max,c.min),u=[`x`,`y`,`z`],d=[],f=0;return u.forEach(t=>{let s;switch(t){case`x`:s=new e.PlaneGeometry(l.z,l.y),s.rotateY(Math.PI/2);break;case`y`:s=new e.PlaneGeometry(l.x,l.z),s.rotateX(Math.PI/2);break;case`z`:s=new e.PlaneGeometry(l.x,l.y)}let c=o.createGeometryFromThreeJSGeometry(n[f],s,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=>{o=!0,e?(O.markerUpdateRequired=!0,O.enable()):(O.markerUpdateRequired=!1,O.disable()),this.forcePickableObjectsUpdate=!0},this.destroyAxisDisplay=()=>{o=!0,this.displayMiniAxes=!1,k.main&&(this.enableAxisDisplay(!1,!1),k.main.forEach(e=>{e.dispose&&e.dispose()})),k.mini&&(this.enableAxisDisplay(!1,!0),k.mini.forEach(e=>{e.dispose&&e.dispose()})),k={main:[],mini:[]}},this.createAxisDisplay=(t=!1)=>{o=!0,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);k.main.push(n);let o=new e.ArrowHelper(t.dir,r.getCenter(A),i/2,t.hex);k.mini.push(o);let s=ge(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),k.main.push(s)})},this.enableAxisDisplay=(e,t=!1)=>{o=!0,t&&k?.mini?.length?(this.displayMiniAxes=e,k.mini.forEach(t=>{e?_.add(t):_.remove(t)})):!t&&k.main&&k.main.forEach(t=>{e?g.add(t):g.remove(t)})}},Bn=function(t){let n=t,i,a,o=new e.Timer;this.playAnimation=!0;let s=1e3,c={},l=0,u={},d=0,f={},p=0,m={},h=0,g,_,b,x,S=[],C=[],w=new e.Group,T,E,D=!1,O=!1,k=[0,0],A=!1,j=!0,M=()=>{j=!0},N={controls:void 0,updated:!1};this.getDrawingWidth=()=>n?n.clientWidth:T?T.clientWidth===void 0?Math.round(T.width):Math.round(T.clientWidth):0,this.getDrawingHeight=()=>n?n.clientHeight:T?T.clientHeight===void 0?Math.round(T.height):Math.round(T.clientHeight):0,this.onWindowResize=()=>{j=!0,a.onWindowResize();let t=this.getDrawingWidth()||1,r=this.getDrawingHeight()||1;if(i!=null){let o;n?(o=n.getBoundingClientRect(),i.setSize(t,r)):T&&(T.getBoundingClientRect===void 0?i.setSize(t,r,!1):(o=T.getBoundingClientRect(),T.width=t,T.height=r,i.setSize(t,r,!1))),o&&(o.left,o.top);let s=new e.Vector2;i.getSize(s),k[0]=s.x,k[1]=s.y;let c=a?.camera?.fov;c&&B(k[1]*i.getPixelRatio()/(2*Math.tan(c*Math.PI/360)))}},this.initialiseVisualisation=async t=>{if(!O){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}if(t.canvas&&(n=void 0,T=t.canvas),t.device===void 0&&t.requiredLimits===void 0&&typeof navigator<`u`&&navigator.gpu)try{let e=await navigator.gpu.requestAdapter({powerPreference:t.powerPreference});e&&(t.requiredLimits={maxTextureArrayLayers:e.limits.maxTextureArrayLayers,maxStorageBuffersPerShaderStage:e.limits.maxStorageBuffersPerShaderStage})}catch{}i=new e.WebGPURenderer(t),await i.init(),n!==void 0&&n.appendChild(i.domElement),i.setClearColor(16777215,1),T&&T.style&&(T.style.height=`100%`,T.style.width=`100%`);let r=i.domElement;r.addEventListener(`webglcontextlost`,P,!1),r.addEventListener(`webglcontextrestored`,F,!1),i.autoClear=!1;let a=this.createScene(`default`);this.setCurrentScene(a),v(M),O=!0}};let P=e=>{e.preventDefault();for(let e of Object.keys(c))f.hasOwnProperty(e)&&f[e].call()},F=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(w),j=!0,this.onWindowResize()}},this.getSceneByName=e=>S[e],this.createScene=e=>{if(S[e]==null){let t;return t=T?new zn(T,i):new zn(n,i),S[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<C.length;t++){let n=C[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 I=()=>{D?(g=requestAnimationFrame(I),this.render()):(cancelAnimationFrame(g),g=void 0)};this.stopAnimate=()=>{D&&=!1},this.animate=()=>{D||(o.reset(),D=!0,j=!0,I())},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,j=!0},this.setRenderOnDemand=e=>{A=!!e,j=!0},this.isRenderOnDemand=()=>A,this.invalidate=()=>{j=!0},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(b??=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}b.add(t),j=!0};let L=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=()=>{x=new e.Sprite,e.ImageUtils.loadTexture(`images/abi_big_logo_transparent_small.png`,void 0,L(x))},this.render=()=>{E||(n?n.clientWidth>0&&n.clientHeight>0&&(E=new r.ResizeSensor(n,this.onWindowResize)):T&&T.width>0&&T.height>0&&(E=new r.ResizeSensor(T,this.onWindowResize))),o.update();let e=o.getDelta(),t=a.renderGeometries(s,e,this.playAnimation);C.length>0&&(N.controls=a.getZincCameraControls(),N.updated=a.isCameraUpdated());for(let n=0;n<C.length;n++)C[n].renderGeometries(s,e,this.playAnimation,N)&&(t=!0);for(let e in c)c.hasOwnProperty(e)&&c[e].call();if(!(A&&!t&&!j)){j=!1,a.render(i),_!=null&&b!=null&&(i.clearDepth(),i.render(b,_));for(let e in u)u.hasOwnProperty(e)&&u[e].call()}},this.forceContextLoss=()=>{},this.forceContextRestore=()=>{},this.getThreeJSRenderer=()=>i,this.isSceneActive=e=>{if(a===e)return!0;for(let t=0;t<C.length;t++)if(C[t]===e)return!0;return!1},this.addActiveScene=e=>{this.isSceneActive(e)||(C.push(e),w.add(e.getThreeJSScene()),j=!0)},this.removeActiveScene=e=>{for(let t=0;t<C.length;t++)if(C[t]===e){C.splice(t,1),w.remove(e.getThreeJSScene()),j=!0;return}},this.clearAllActiveScene=()=>{for(let e=0;e<C.length;e++)w.remove(C[e].getThreeJSScene());C.splice(0,C.length),j=!0},this.dispose=()=>{D&&cancelAnimationFrame(g);for(let e in S)S.hasOwnProperty(e)&&S[e].clearAll();S=[],C=[],w=new e.Group,this.stopAnimate(),c={},l=0,u={},d=0,f={},p=0,m={},h=0,_=void 0,b=void 0,x=void 0;let t=this.createScene(`default`);this.setCurrentScene(t),E=void 0,y(M),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?.backend?.isWebGLBackend===!0,this.isWebGPU=()=>i?.backend?.isWebGPUBackend===!0},Vn=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 Vn(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+`
|
|
5
|
+
`),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=yn.exec(i))!==null){let e=(` `+s[0].substr(1).trim()).substr(1);n.startObject(e)}else if(xn.test(i))n.object.startMaterial(i.substring(7).trim(),n.materialLibraries);else if(bn.test(i))n.materialLibraries.push(i.substring(7).trim());else if(Sn.test(i))console.warn(`THREE.OBJLoader: Rendering identifier "usemap" not supported. Textures must be defined in MTL files.`);else if(a===`s`){if(s=i.split(` `),s.length>1){let e=s[1].trim().toLowerCase();n.object.smooth=e!==`0`&&e!==`off`}else n.object.smooth=!0;let e=n.object.currentMaterial();e&&(e.smooth=n.object.smooth)}else{if(i===`\0`)continue;console.warn(`THREE.OBJLoader: Unexpected line: "`+i+`"`)}}n.finalize();let l=new e.Group;if(l.materialLibraries=[].concat(n.materialLibraries),n.objects.length!==1||n.objects[0].geometry.vertices.length!==0)for(let t=0,r=n.objects.length;t<r;t++){let r=n.objects[t],i=r.geometry,a=r.materials,o=i.type===`Line`,s=i.type===`Points`,c=!1;if(i.vertices.length===0)continue;let u=new e.BufferGeometry;u.setAttribute(`position`,new e.Float32BufferAttribute(i.vertices,3)),i.normals.length>0&&u.setAttribute(`normal`,new e.Float32BufferAttribute(i.normals,3)),i.colors.length>0&&(c=!0,u.setAttribute(`color`,new e.Float32BufferAttribute(i.colors,3))),i.hasUVIndices===!0&&u.setAttribute(`uv`,new e.Float32BufferAttribute(i.uvs,2));let d=[];for(let t=0,r=a.length;t<r;t++){let r=a[t],i=r.name+`_`+r.smooth+`_`+c,l=n.materials[i];if(this.materials!==null){if(l=this.materials.create(r.name),o&&l&&!(l instanceof e.LineBasicMaterial)){let t=new e.LineBasicMaterial;e.Material.prototype.copy.call(t,l),t.color.copy(l.color),l=t}else if(s&&l&&!(l instanceof e.PointsMaterial)){let t=new e.PointsMaterial({size:10,sizeAttenuation:!1});e.Material.prototype.copy.call(t,l),t.color.copy(l.color),t.map=l.map,l=t}}l===void 0&&(l=o?new e.LineBasicMaterial:s?new e.PointsMaterial({size:1,sizeAttenuation:!1}):new e.MeshPhongMaterial,l.name=r.name,l.flatShading=!r.smooth,l.vertexColors=c,n.materials[i]=l),d.push(l)}let f;if(d.length>1){for(let e=0,t=a.length;e<t;e++){let t=a[e];u.addGroup(t.groupStart,t.groupCount,e)}f=o?new e.LineSegments(u,d):s?new e.Points(u,d):new e.Mesh(u,d)}else f=o?new e.LineSegments(u,d[0]):s?new e.Points(u,d[0]):new e.Mesh(u,d[0]);f.name=r.name,l.add(f)}else if(n.vertices.length>0){let t=new e.PointsMaterial({size:1,sizeAttenuation:!1}),r=new e.BufferGeometry;r.setAttribute(`position`,new e.Float32BufferAttribute(n.vertices,3)),n.colors.length>0&&n.colors[0]!==void 0&&(r.setAttribute(`color`,new e.Float32BufferAttribute(n.colors,3)),t.vertexColors=!0);let i=new e.Points(r,t);l.add(i)}return l}},kn=e.FileLoader,An=e=>{let t=(e,t)=>{if(e.metadata.number_of_vertices+=t.metadata.number_of_vertices,`labels`in e&&t.labels){let n=t.labels;for(let t=0;t<n.length;t++)e.labels.push(n[t])}[`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])}},jn=e=>{if(e&&e.length>0){if(e.length===1)return e[0];let t=ue(e);return e.forEach(e=>e.dispose()),t}},Mn=function(e,t,n,r){let i=new kn,a=new rt;i.crossOrigin=t;let o=e,s=n,c=r,l,u=!1,d=!1,f,p=[],m=e=>{let t=l[e.index];if(t){if(`GlyphGeometriesURL`in t)e.onLoad(t);else{let n=a.parse(t);e.onLoad(n.geometry,n.materials)}}else h(e,{responseURL:o})},h=e=>{e.onError&&(f||={responseURL:o},e.onError(f))};this.downloadCompleted=e=>{try{l=JSON.parse(e[0]),u=!1,d=!0,Array.isArray(l)?p.forEach(e=>m(e)):p.forEach(e=>h(e))}catch{p.forEach(e=>h(e))}};let g=()=>e=>{f=e,d=!0,u=!1,p.forEach(e=>{h(e)}),c&&c(e)},_=()=>e=>{p.forEach(t=>{t.onProgress&&t.onProgress(e)})};this.load=(e,t,n,r)=>{let a={index:e,onLoad:t,onProgress:n,onError:r};d?l?m(a):h(a):u?p.push(a):(p.push(a),u=!0,i.load(o,s,_(),g()))}},Nn=function(e,t,n,r){let i=[],a=e,o=t,s=n,c=0,l,u=r?.isGlyphsets,d=()=>{u||i.forEach(e=>{e&&(e[0]?.dispose?.(),e[1]?.forEach(e=>e.dispose()))}),s&&s(...l)};this.itemFailed=(e,t)=>{l||=t,c++,c==a&&d()},this.itemDownloaded=(e,t)=>{if(i[e]=t,c++,c==a){if(l)d();else if(i.length>0){if(u){let e=i.map(e=>JSON.parse(e[0]));An(e),o(e[0])}else{let e=i[0][1],t=jn(i.map(e=>e[0]));for(let e=1;e<a;e++)i[e][1]?.forEach(e=>e.dispose());o(t,e)}}}}},Pn=function(){let e=0;this.crossOrigin=`Anonymous`;let t=new rt,n=new kn;n.crossOrigin=`Anonymous`;let r=[],i={},a=(e,t,n,r,i)=>{let a=e.length,o=new Nn(a,t,r,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),r=new c(void 0,this,{});++e,u=new Mn(t,this.crossOrigin,n,r),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,!0);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,i=!1){return(...a)=>{--e,r?.msHandler?i?r.msHandler.itemFailed(r.order,a):r.msHandler.itemDownloaded(r.order,a):r?.isHandler?r.isHandler.downloadCompleted(a):t&&t(...a),n.loadFromWaitingList(),n.itemRemainingCheck()}};this.parse=e=>t.parse(e)},Fn=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))}},In=function(){H.call(this),this.isTubeLines=!0;let t={},n={radius:1,radialSegments:8,smooth:!1};this.createLineSegment=(n,a,o)=>{if(n&&a){t={geometryIn:n,materialIn:a,options:o};let s=i(r(n)),c=new e.MeshStandardMaterial({color:a.color}),l=new e.Mesh(s,c);this.setMesh(l,o.localTimeEnabled,o.localMorphColour)}},this.setWidth=e=>{this.requestRender(),this.morph&&this.morph.material&&(this.morph.material.linewidth=e,this.morph.material.needsUpdate=!0)},this.setAlpha=function(e){this.requestRender();let t=this.getMorph();t.material.opacity=e,t.material.transparent=e<1,t.material.depthWrite=e>.5},this.setWireframe=e=>{this.requestRender();let t=this.getMorph();t.material.wireframe=e},this.setTubeLines=(e,a)=>{if(this.requestRender(),e&&a){let{geometryIn:o}=t,s=this.getMorph();s.geometry.dispose(),n=Object.assign(n,{radius:e,radialSegments:a}),s.geometry=i(r(o))}};let r=t=>{let n=t.getAttribute(`position`),r=[];for(let t=0;t<n.count;t++)r.push(new e.Vector3().fromBufferAttribute(n,t));return r},i=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=ue(n,!0),n.forEach(e=>e.dispose())}return o}};In.prototype=Object.create(H.prototype);var Ln=function(t){let n=t;this.toBeDownloaded=0,this.progressMap={};let r=!1,i=!1,a=0,o=new Pn;this.cancelPendingLoads=()=>{a++,this.toBeDownloaded=0,this.progressMap={},r=!1,i=!1};let s=()=>{let e=a;return()=>e!==a};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=>{let t=s();return n=>{t()||(--this.toBeDownloaded,i=!0,console.error(`There is an issue with external resource ${n?.responseURL?`: `+n?.responseURL:``}.`),e&&e({type:`Error`,xhr:n}))}};let c=(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=ee(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,a=s();fetch(i).then(e=>{if(!e.ok)throw Error(`HTTP error! status: ${e.status}`);return e.json()}).then(e=>{a()||(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,a,s)=>{let c=t.length;this.toBeDownloaded+=c;for(let l=0;l<c;l++){let c=t[l],u=fr.defaultMaterialColor,d=fr.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;a!=null&&a[l]!=null&&(p=!!a[l]),o.load(c,g(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`,a=s();fetch(i).then(e=>{if(!e.ok)throw Error(`HTTP error! status: ${e.status}`);return e.json()}).then(i=>{if(a())return;n.loadView(i);let o=[],s=t+`_`;for(let e=0;e<i.numberOfResources;e++){let t=s+(e+1)+`.json`;o.push(t)}this.loadModelsURL(e,o,i.colour,i.opacity,i.timeEnabled,i.morphColour,r)}).catch(e=>{console.error(`Failed to load view data from: ${i}`,e)})};let l=(t,r,i,a,c,l,u,d,f)=>{let p=s();return(s,m)=>{if(p()){s.dispose();return}let h=d?new In:new Dt,g;m&&m[0]&&(g=new e.LineBasicMaterial({color:m[0].color.clone()}),1>m[0].opacity&&(g.transparent=!0),g.opacity=m[0].opacity,g.vertexColors=m[0].vertexColors);let _={};if(_.localTimeEnabled=r,_.localMorphColour=i,h&&(h.createLineSegment(s,g,_),h.setName(a),h.setAnatomicalId(c),h.setRenderOrder(l),t.addZincObject(h),h.setDuration(n.getDuration()),u&&u.levels))for(let[e,t]of Object.entries(u.levels))h.addLOD(o,e,t.URL,t.Index,u.preload);--this.toBeDownloaded,s.dispose(),f!=null&&typeof f==`function`&&f(h)}};this.loadLinesURL=(e,t,n,r,i,a,s)=>{let c=0;this.toBeDownloaded+=1;let u=s?.isInline?s.isInline:!1,d=s?.anatomicalId?s.anatomicalId:void 0,f=s&&`renderOrder`in s?s.renderOrder:void 0;n!=null&&(c=!!n);let p=0;r!=null&&(p=!!r);let m=s.tubeLines&&!c&&!p;if(u){let n=o.parse(t);l(e,c,p,i,d,f,s.lod,m,a)(n.geometry,n.materials)}else o.load(t,l(e,c,p,i,d,f,s.lod,m,a),this.onProgress(t),this.onError(a),s.loaderOptions)};let u=(e,t,r,i,a)=>{let o=s();return s=>{if(o())return;let c=s;(typeof c==`string`||c instanceof String)&&(c=JSON.parse(s));let l=a&&a.isInline?a.isInline:void 0,u=a&&a.anatomicalId?a.anatomicalId:void 0,d=a?.displayLabels;d===void 0&&(d=!0);let f=a&&`renderOrder`in a?a.renderOrder:void 0,p=new mt;p.setDuration(n.getDuration()),p.groupName=r,++this.toBeDownloaded,p.load(c,t,()=>{o()||(--this.toBeDownloaded,i!=null&&typeof i==`function`&&i(p))},l,d),p.setAnatomicalId(u),p.setRenderOrder(f),e.addZincObject(p)}};this.loadGlyphsetURL=(e,t,n,r,i,a)=>{a&&a.isInline&&a.isInline?u(e,n,r,i,a)(t):o.load(t,u(e,n,r,i,a),this.onProgress(t),this.onError(i),a.loaderOptions)};let d=(t,r,i,a,o,c,l)=>{let u=s();return(s,d)=>{if(u()){s.dispose();return}let f=new Et,p=new e.PointsMaterial({alphaTest:.05,size:10,sizeAttenuation:!1});d&&d[0]&&(1>d[0].opacity&&(p.transparent=!0),p.opacity=d[0].opacity,p.color=d[0].color,p.vertexColors=!1);let m={};m.localTimeEnabled=r,m.localMorphColour=i,f&&(f.createMesh(s,p,m),f.setName(a),f.setAnatomicalId(o),t.addZincObject(f),f.setDuration(n.getDuration()),f.setRenderOrder(c)),s.dispose(),--this.toBeDownloaded,l!=null&&typeof l==`function`&&l(f)}};this.loadSTL=(e,t,n,r)=>{this.toBeDownloaded+=1;let i=fr.defaultMaterialColor,a=fr.defaultOpacity,o=new Fn;o.crossOrigin=`Anonymous`,o.load(t,g(e,i,a,!1,!1,n,void 0,void 0,{},r),this.onProgress(t),this.onError(r))},this.loadOBJ=(e,t,n,r)=>{this.toBeDownloaded+=1;let i=fr.defaultMaterialColor,a=fr.defaultOpacity,o=new On;o.crossOrigin=`Anonymous`,o.load(t,_(e,i,a,!1,!1,n,void 0,void 0,{},r),this.onProgress(t),this.onError(r))};let f=(e,t,n,r,i,a,s)=>{this.toBeDownloaded+=1;let c=fr.defaultMaterialColor,l=fr.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,m=s&&`renderOrder`in s?s.renderOrder:void 0;n!=null&&(u=!!n);let h=0;r!=null&&(h=!!r);let v=o;if(f==`STL`||f==`OBJ`){let n=f==`STL`?g:_;v=f==`STL`?new Fn:new On,v.crossOrigin=`Anonymous`,v.load(t,n(e,c,l,u,h,i,p,m,s||{},a),this.onProgress(t),this.onError(a));return}if(d){let n=o.parse(t);g(e,c,l,u,h,i,p,m,s,a)(n.geometry,n.materials)}else v.crossOrigin=`Anonymous`,o.load(t,g(e,c,l,u,h,i,p,m,s,a),this.onProgress(t),this.onError(a),s.loaderOptions)},p=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,a,s)=>{let c=0;this.toBeDownloaded+=1,n!=null&&(c=!!n);let l=0;r!=null&&(l=!!r);let u=s&&s.isInline?s.isInline:!1,f=s&&s.anatomicalId?s.anatomicalId:void 0,p=s&&`renderOrder`in s?s.renderOrder:void 0;if(u){let n=o.parse(t);d(e,c,l,i,f,p,a)(n.geometry,n.materials)}else o.load(t,d(e,c,l,i,f,p,a),this.onProgress(t),this.onError(a),s.loaderOptions)};let m=(e,t,n,r,i,a)=>{let o=a&&a.isInline?a.isInline:void 0,c=a&&a.anatomicalId?a.anatomicalId:void 0,l=a&&`renderOrder`in a?a.renderOrder:void 0,u;if(n){if(t&&n.images&&n.images.source){let e=n.images.source;for(let r=0;r<e.length;r++){let i=ee(e[r],t);n.images.source[r]=i}}if(n.type===`slides`&&(u=new Nt),u){u.groupName=r;let t=s();++this.toBeDownloaded,u.load(n,()=>{if(t()){u.dispose();return}e.addZincObject(u),--this.toBeDownloaded,i!=null&&typeof i==`function`&&i(u)},o),u.setAnatomicalId(c),u.setRenderOrder(l)}}};this.loadTextureURL=(e,t,n,r,i)=>{if(i&&i.isInline&&i.isInline)m(e,void 0,t,n,r,i);else{let a=t,o=s();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})=>{o()||m(e,a,t,n,r,i)}).catch(e=>{console.error(`Fetch failed for texture URL: ${a}`,e)})}};let h=(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 Ge;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},g=(e,t,n,r,i,a,c,l,u,d)=>{let f=s();return(s,p)=>{if(f()){s.dispose();return}let m;p&&p[0]&&(m=p[0]);let g=h(e,s,t,n,r,i,void 0,m,a,l,c);if(u?.lod?.levels)for(let[e,t]of Object.entries(u.lod.levels))g.addLOD(o,e,t.URL,t.Index,u.lod.preload);--this.toBeDownloaded,s.dispose(),d!=null&&typeof d==`function`&&d(g)}},_=(e,t,n,r,i,a,o,c,l,u)=>{let d=s(),f=g(e,t,n,r,i,a,o,c,l,u);return e=>{let t=[];if(e.traverse(e=>{e.isMesh&&e.geometry&&t.push(e),e.material&&(Array.isArray(e.material)?e.material:[e.material]).forEach(e=>e.dispose())}),d()){t.forEach(e=>e.geometry.dispose());return}if(t.length===0){--this.toBeDownloaded;return}this.toBeDownloaded+=t.length-1,t.forEach(e=>f(e.geometry))}},v=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=v(e.Duration);n.setDurationFromObject(t)}if(e.OriginalDuration){let t=v(e.OriginalDuration);n.setOriginalDurationFromObject(t)}if(e.TimeStamps)for(let t in e.TimeStamps){let r=v(e.TimeStamps[t]);n.addMetadataTimeStamp(t,r)}}};let y=(e,t,n,r,i)=>{if(n){let a,o=!1;n.URL?(a=n.URL,t&&(a=ee(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=ee(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`:f(e,a,n.MorphVertices,n.MorphColours,c,i,l);break;case`Glyph`:let r;o?r=n.Inline.GlyphGeometriesURL:(r=n.GlyphGeometriesURL,r=ee(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)}}},b=(e,t,i)=>{if(t){let a,o=!1;switch(t.URL?(a=t.URL,e&&(a=ee(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 vn().load(n,e,t,r,i,a,s())};let x=(e,t,n,r)=>{if(n.Primitives&&n.Primitives.forEach(n=>{let i=1;n.Order&&(i=n.Order),y(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&&x(n,t,a,r)}},S=(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(_e(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(_e(e.RegionPath,e.GroupName,i[t]))return!1;return!0}))),a&&n.forEach(e=>{e.Type===`Lines`&&(e.tubeLines=!0)}),n},C=(e,t)=>Array.isArray(e)?S(e,t):e,w=(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},T=e=>{let t=e.Primitives?w(e.Primitives,!1):0;return e.Children&&Object.values(e.Children).forEach(e=>{t+=T(e)}),t},E=e=>{if(Array.isArray(e))return w(e,!0);if(typeof e==`object`&&e&&e.Version===`2.0`)return T(e.Regions)},D=(e,t,n,r,i)=>{let a=e;n.RegionPath&&n.RegionPath!==``&&(a=e.findOrCreateChildFromPath(n.RegionPath)),y(a,t,n,r*2,i)},O=(e,t,n,r,i,a)=>{let o=C(t,a),s=E(o),c=new p(s,r,i);for(let e=0;e<o.length;e++)b(n,o[e],c);for(let t=0;t<o.length;t++)D(e,n,o[t],t,c)},k=(e,t,n,r,i)=>{let a=E(t),o=new p(a,r,i);t.Settings&&this.loadSettings(t.Settings),t.Views&&c(n,t.Views,n),t.Regions&&x(e,n,t.Regions,o)};this.loadMetadataURL=(e,t,i,a,o)=>{let c=t,l=s();fetch(c).then(e=>{if(!e.ok)throw Error(`HTTP error! status: ${e.status}`);let t=e.url||new URL(c).href;return e.json().then(e=>({metadata:e,referenceURL:t}))}).then(({metadata:t,referenceURL:s})=>{l()||(n.resetMetadata(),n.resetDuration(),r=!1,Array.isArray(t)?O(e,t,s,i,a,o):typeof t==`object`&&t&&t.Version===`2.0`&&k(e,t,s,i,a))}).catch(e=>{console.error(`Fetch failed for URL: ${c}`,e)})}},Rn=0,zn=function(){return`sc`+Rn++},Bn=function(){return{Duration:`6 secs`,OriginalDuration:`-`,TimeStamps:{}}},Vn=6e3,Hn=function(t,n){let r=t,i,a,o=!0,s=!1,c={},l={displayMarkers:void 0,displayMinimap:void 0,displayMiniAxes:void 0,playAnimation:void 0},u=new Ln(this),d,f={},p=0,m={},h=0,g=new e.Scene,_=new e.Scene,v=new hn(void 0,this);g.add(v.getGroup());let y=new e.Group;g.add(y),this.directionalLight=void 0,this.ambient=void 0,this.camera=void 0;let b=6e3,x;this.sceneName=void 0;let S=!1,C;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 w={x:0,y:0},T=Bn(),E=new e.Vector2,D=[];this.forcePickableObjectsUpdate=!1,this.uuid=zn();let O=new qt(this);O.disable(),g.add(O.group);let k={main:[],mini:[]},A=new e.Vector3(0,0,0),j=()=>r?r.clientWidth===void 0?r.width:r.clientWidth:0,M=()=>r?r.clientHeight===void 0?r.height:r.clientHeight:0;this.getDownloadProgress=()=>u.getDownloadProgress(),this.onWindowResize=()=>{o=!0;let e=M();this.camera.aspect=j()/e,this.camera.updateProjectionMatrix(),this.minimapScissor.updateRequired=!0,x.onResize(),x.calculateHeightPerPixelAtZeroDepth(e)},this.resetView=()=>{o=!0,this.onWindowResize(),x.resetView()},this.changeZoomByScrollRateUnit=e=>{o=!0,x.changeZoomByScrollRateUnit(e)},this.camera=new e.PerspectiveCamera(40,j()/M(),0,10),this.ambient=new e.AmbientLight(16777215,.2),g.add(this.ambient),this.directionalLight=new e.DirectionalLight(16777215,.7*Math.PI),g.add(this.directionalLight),x=new Ft(this.camera,n.domElement,n,this),x.setDirectionalLight(this.directionalLight),x.resetView(),d=new Jt(this),this.loadView=e=>{o=!0;let t=new Pt;return t.setFromObject(e),x.setCurrentCameraSettings(t),!0},this.setupMultipleViews=(e,t)=>{for(let[e,n]of Object.entries(t)){let t=new Pt;t.setFromObject(n),x.addViewport(e,t)}x.setDefaultViewport(e)},this.getBoundingBox=()=>v.getBoundingBox(!0),this.viewAllWithBoundingBox=e=>{if(o=!0,e){let t=x.getViewportFromBoundingBox(e,1);x.setCurrentCameraSettings(t),x.calculateHeightPerPixelAtZeroDepth(M()),O.markerUpdateRequired=!0}},this.viewAll=()=>{o=!0;let e=this.getBoundingBox();this.viewAllWithBoundingBox(e),O.markerUpdateRequired=!0},this.forEachGeometry=e=>{v.forEachGeometry(e,!0)},this.forEachGlyphset=e=>{v.forEachGlyphset(e,!0)},this.forEachPointset=e=>{v.forEachPointset(e,!0)},this.forEachLine=e=>{v.forEachLine(e,!0)},this.findGeometriesWithGroupName=e=>v.findGeometriesWithGroupName(e,!0),this.findPointsetsWithGroupName=e=>v.findPointsetsWithGroupName(e,!0),this.findGlyphsetsWithGroupName=e=>v.findGlyphsetsWithGroupName(e,!0),this.findLinesWithGroupName=e=>v.findLinesWithGroupName(e,!0),this.findObjectsWithGroupName=e=>v.findObjectsWithGroupName(e,!0),this.findObjectsWithAnatomicalId=e=>v.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=j(),n=M(),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=>{o=!0,e&&(v.addZincObject(e),x&&x.calculateMaxAllowedDistance(this))},this.loadGlyphsetURL=(e,t,n,r)=>{u.loadGlyphsetURL(v,e,t,n,r)},this.loadPointsetURL=(e,t,n,r,i)=>{u.loadPointsetURL(v,e,t,n,r,i)},this.loadLinesURL=(e,t,n,r,i)=>{u.loadLinesURL(v,e,t,n,r,i)},this.loadSTL=(e,t,n)=>{u.loadSTL(v,e,t,n)},this.loadOBJ=(e,t,n)=>{u.loadOBJ(v,e,t,n)},this.loadMetadataURL=(e,t,n,r)=>{u.loadMetadataURL(v,e,t,n,r)},this.loadModelsURL=(e,t,n,r,i,a)=>{u.loadModelsURL(v.urls,t,n,r,i,a)},this.loadViewURL=e=>{u.loadViewURL(e)},this.loadFromViewURL=(e,t)=>{u.loadFromViewURL(e,t)},this.loadGLTF=(e,t,n,r)=>{u.loadGLTF(v,e,t,n,r)},this.updateDirectionalLight=()=>{o=!0,x.updateDirectionalLight()},this.addObject=e=>{o=!0,g.add(e)},this.removeObject=e=>{o=!0,g.remove(e)},this.getCurrentTime=()=>{if(a!=null)return a.getCurrentTime(b);let e=v.getCurrentTime();return e===-1?0:e},this.setMorphsTime=e=>{o=!0,a?.setMorphTime(e,b),v.setMorphTime(e,!0)},this.isTimeVarying=()=>a&&a.video&&!a.video.error?!0:v.isTimeVarying(),this.renderGeometries=(e,t,n,r)=>{let i=o;o=!1,s=!1;let d=r?r.controls:x,f=c;if(f.camera=d,f.displayMarkers=this.displayMarkers,f.markerCluster=O,f.markersList=O.markers,f.ndcToBeUpdated=r?r.updated:!1,n&&(f.markerCluster.markerUpdateRequired=!0),a){if(a.isReadyToPlay()){n?a.video.play():a.video.pause();let e=a.video.currentTime/a.getVideoDuration()*b;u.toBeDownloaded==0?(r||(x.setTime(e),f.ndcToBeUpdated=x.update(0),f.ndcToBeUpdated&&x.calculateHeightPerPixelAtZeroDepth(M())),v.setMorphTime(e,!0),v.renderGeometries(0,0,n,d,f,!0)):!r&&x.update(0)&&(i=!0,s=!0)}(n||!a.isReadyToPlay())&&(i=!0)}else u.toBeDownloaded==0?(r||(f.ndcToBeUpdated=x.update(t),f.ndcToBeUpdated&&x.calculateHeightPerPixelAtZeroDepth(M())),v.renderGeometries(e,t,n,d,f,!0)):!r&&x.update(0)&&(i=!0,s=!0);return(l.displayMarkers!==this.displayMarkers||l.displayMinimap!==this.displayMinimap||l.displayMiniAxes!==this.displayMiniAxes||l.playAnimation!==n)&&(l.displayMarkers=this.displayMarkers,l.displayMinimap=this.displayMinimap,l.displayMiniAxes=this.displayMiniAxes,l.playAnimation=n,i=!0),this.minimapScissor.updateRequired&&(this.displayMinimap||this.displayMiniAxes)&&(i=!0),!r&&f.ndcToBeUpdated&&(s=!0),(f.ndcToBeUpdated||n&&this.isTimeVarying()||u.toBeDownloaded>0||O.isEnabled()&&O.markerUpdateRequired)&&(i=!0),o&&=(i=!0,!1),i},this.invalidate=()=>{o=!0},this.isCameraUpdated=()=>s,this.getThreeJSScene=()=>g,this.setVideoHandler=e=>{o=!0,a||=e},this.setAdditionalScenesGroup=e=>{g.add(e)};let N=(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}},P=e=>{(this.displayMinimap||this.displayMiniAxes)&&(e.setScissorTest(!0),e.getSize(E),this.minimapScissor.updateRequired&&(w=N(this.minimapScissor.align,this.minimapScissor.x_offset,this.minimapScissor.y_offset,this.minimapScissor.width,this.minimapScissor.height,E.x,E.y),this.minimapScissor.updateRequired=!1),e.setScissor(w.x,w.y,this.minimapScissor.width,this.minimapScissor.height),e.setViewport(w.x,w.y,this.minimapScissor.width,this.minimapScissor.height),d.updateCamera(),this.displayMiniAxes?e.render(_,d.camera):(g.add(d.mask),e.render(g,d.camera),g.remove(d.mask)),e.setScissorTest(!1),e.setViewport(0,0,E.x,E.y))};this.render=e=>{this.autoClearFlag&&e.clear(),S&&C?C.render(g,this.camera):(e.render(g,this.camera),P(e))},this.setInteractiveControlEnable=e=>{e==1?x.enable():x.disable()},this.getZincCameraControls=()=>x,this.getThreeJSScene=()=>g,this.setDuration=e=>{o=!0,v.setDuration(e),b=e,x.setPathDuration(e),u.duration=e},this.getDuration=()=>b,this.setStereoEffectEnable=e=>{o=!0,e==1&&(C||=new Vt(n)),n.setSize(j(),M()),this.camera.updateProjectionMatrix(),S=e},this.objectIsInScene=e=>v.objectIsInRegion(e,!0),this.alignBoundingBoxToCameraView=(t,n)=>{if(o=!0,t){t.getCenter(A);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,A).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),O.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()),O.markerUpdateRequired=!0}},this.alignObjectToCameraView=(e,t)=>{if(this.objectIsInScene(e)){let n=e.getBoundingBox();this.alignBoundingBoxToCameraView(n,t)}},this.setCameraTargetToObject=t=>{if(o=!0,this.objectIsInScene(t)){let n=t.getBoundingBox(),r=this.getZincCameraControls().getCurrentViewport();n.getCenter(A);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(A,o),r.eyePosition[0]=s.x,r.eyePosition[1]=s.y,r.eyePosition[2]=s.z,r.targetPosition[0]=A.x,r.targetPosition[1]=A.y,r.targetPosition[2]=A.z,this.getZincCameraControls().setCurrentCameraSettings(r),O.markerUpdateRequired=!0}},this.isStereoEffectEnable=()=>S,this.removeZincObject=e=>{o=!0,v.removeZincObject(e),x&&x.calculateMaxAllowedDistance(this),O.markerUpdateRequired=!0},this.updatePickableThreeJSObjects=()=>{D.length=0,O.isEnabled&&D.push(O.group),v.getPickableThreeJSObjects(D,!0),this.forcePickableObjectsUpdate=!1},this.getPickableThreeJSObjects=()=>((this.forcePickableObjectsUpdate||v.checkPickableUpdateRequred(!0))&&this.updatePickableThreeJSObjects(),D),this.getNormalisedMinimapCoordinates=(t,n)=>{if(this.displayMinimap){let r=new e.Vector2;t.getSize(r);let i=r.y-n.clientY;if(w.x+this.minimapScissor.width>n.clientX&&n.clientX>w.x&&w.y+this.minimapScissor.height>i&&i>w.y)return{x:(n.clientX-w.x)/this.minimapScissor.width*2-1,y:(i-w.y)/this.minimapScissor.height*2-1}}},this.getMinimapDiffFromNormalised=(e,t)=>{if(d)return d.getDiffFromNormalised(e,t)},this.isWebGL2=()=>n?.backend?.isWebGLBackend===!0,this.isWebGPU=()=>n?.backend?.isWebGPUBackend===!0,this.getRenderer=()=>n,this.clearAll=()=>{o=!0,O.clear(),v.clear(!0),this.clearZincObjectAddedCallbacks(),this.clearZincObjectRemovedCallbacks(),u.cancelPendingLoads(),x&&x.calculateMaxAllowedDistance(this),O.markerUpdateRequired=!0},this.addMetadataTimeStamp=(e,t)=>{T.TimeStamps[e]=I(t)},this.getMetadataTag=e=>T[e],this.getMetadata=()=>T,this.setMetadataTag=(e,t)=>{T[e]=t},this.removeMetadataTag=e=>{delete T[e]},this.resetMetadata=()=>{T=Bn()},this.resetDuration=()=>{this.setDuration(Vn)};let F=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(` `),I=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=F(e),n=I(e);this.setMetadataTag(`Duration`,t),this.setDuration(n)},this.setOriginalDurationFromObject=e=>{let t=F(e);this.setMetadataTag(`OriginalDuration`,t)},this.exportGLTF=e=>new _n(this).exportGLTF(e),this.getRootRegion=()=>v,this.createLines=(e,t,n,r)=>{let i=v.findChildFromPath(e);return i===void 0&&(i=v.createChildFromPath(e)),i.createLines(t,n,r)},this.createPoints=(e,t,n,r,i)=>{let a=v.findChildFromPath(e);return a===void 0&&(a=v.createChildFromPath(e)),a.createPoints(t,n,r,i)},this.addZincObjectAddedCallbacks=e=>(p+=1,f[p]=e,p),this.addZincObjectRemovedCallbacks=e=>(h+=1,m[h]=e,h),this.removeZincObjectAddedCallbacks=e=>{e in p&&delete f[e]},this.removeZincObjectRemovedCallbacks=e=>{e in h&&delete m[e]},this.clearZincObjectAddedCallbacks=()=>{f={},p=0},this.clearZincObjectRemovedCallbacks=()=>{m={},h=0},this.triggerObjectAddedCallback=e=>{for(let t in f)f.hasOwnProperty(t)&&f[t](e)},this.triggerObjectRemovedCallback=e=>{for(let t in m)m.hasOwnProperty(t)&&m[t](e)},this.addTemporaryPoints=(e,t)=>{o=!0;let n=St(e.length),r=bt(he());r.color.set(t),r.size=15,r.userData.uniforms.pointSize.value=15,r.alphaTest=.5;let i=new vt(n,r,e.length),a=n.getAttribute(`instancePosition`);return i.pointPositions=a.array,e.forEach((e,t)=>{a.setXYZ(t,e[0],e[1],e[2])}),a.needsUpdate=!0,y.add(i),i},this.addTemporaryLines=(t,n)=>{o=!0;let r=new Fe(de(t.length,t),new e.LineBasicMaterial({color:n}));return y.add(r),r},this.enableFrustumDisplay=()=>{o=!0,this.camera&&!i&&(i=new e.CameraHelper(this.camera),g.add(i))},this.disableFrustumDisplay=()=>{o=!0,i&&=(g.remove(i),i.dispose(),void 0)},this.removeTemporaryPrimitive=e=>{o=!0,y.remove(e),e.geometry.dispose(),e.material.dispose()},this.clearTemporaryPrimitives=()=>{o=!0;let e=0;return y.children.forEach(t=>{t.geometry.dispose(),t.material.dispose(),e++}),y.clear(),e},this.addBoundingBoxPrimitive=(t,n,r,i,a,s=void 0)=>{o=!0;let c=v.findChildFromPath(t);c===void 0&&(c=v.createChildFromPath(t));let l=s||this.getBoundingBox();A.set(0,0,0);let u=A.subVectors(l.max,l.min),d=new e.BoxGeometry(u.x,u.y,u.z),f=c.createGeometryFromThreeJSGeometry(n,d,r,i,a,1e4);return u.addVectors(l.min,l.max).multiplyScalar(.5),f.setPosition(u.x,u.y,u.z),f},this.addSlicesPrimitive=(t,n,r,i,a,s=void 0)=>{if(o=!0,n&&n.length>=3&&r&&r.length>=3){let o=v.findChildFromPath(t);o===void 0&&(o=v.createChildFromPath(t));let c=s||this.getBoundingBox();A.set(0,0,0);let l=A.subVectors(c.max,c.min),u=[`x`,`y`,`z`],d=[],f=0;return u.forEach(t=>{let s;switch(t){case`x`:s=new e.PlaneGeometry(l.z,l.y),s.rotateY(Math.PI/2);break;case`y`:s=new e.PlaneGeometry(l.x,l.z),s.rotateX(Math.PI/2);break;case`z`:s=new e.PlaneGeometry(l.x,l.y)}let c=o.createGeometryFromThreeJSGeometry(n[f],s,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=>{o=!0,e?(O.markerUpdateRequired=!0,O.enable()):(O.markerUpdateRequired=!1,O.disable()),this.forcePickableObjectsUpdate=!0},this.destroyAxisDisplay=()=>{o=!0,this.displayMiniAxes=!1,k.main&&(this.enableAxisDisplay(!1,!1),k.main.forEach(e=>{e.dispose&&e.dispose()})),k.mini&&(this.enableAxisDisplay(!1,!0),k.mini.forEach(e=>{e.dispose&&e.dispose()})),k={main:[],mini:[]}},this.createAxisDisplay=(t=!1)=>{o=!0,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);k.main.push(n);let o=new e.ArrowHelper(t.dir,r.getCenter(A),i/2,t.hex);k.mini.push(o);let s=ge(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),k.main.push(s)})},this.enableAxisDisplay=(e,t=!1)=>{o=!0,t&&k?.mini?.length?(this.displayMiniAxes=e,k.mini.forEach(t=>{e?_.add(t):_.remove(t)})):!t&&k.main&&k.main.forEach(t=>{e?g.add(t):g.remove(t)})}},Un=function(t){let n=t,i,a,o=new e.Timer;this.playAnimation=!0;let s=1e3,c={},l=0,u={},d=0,f={},p=0,m={},h=0,g,_,b,x,S=[],C=[],w=new e.Group,T,E,D=!1,O=!1,k=[0,0],A=!1,j=!0,M=()=>{j=!0},N={controls:void 0,updated:!1};this.getDrawingWidth=()=>n?n.clientWidth:T?T.clientWidth===void 0?Math.round(T.width):Math.round(T.clientWidth):0,this.getDrawingHeight=()=>n?n.clientHeight:T?T.clientHeight===void 0?Math.round(T.height):Math.round(T.clientHeight):0,this.onWindowResize=()=>{j=!0,a.onWindowResize();let t=this.getDrawingWidth()||1,r=this.getDrawingHeight()||1;if(i!=null){let o;n?(o=n.getBoundingClientRect(),i.setSize(t,r)):T&&(T.getBoundingClientRect===void 0?i.setSize(t,r,!1):(o=T.getBoundingClientRect(),T.width=t,T.height=r,i.setSize(t,r,!1))),o&&(o.left,o.top);let s=new e.Vector2;i.getSize(s),k[0]=s.x,k[1]=s.y;let c=a?.camera?.fov;c&&B(k[1]*i.getPixelRatio()/(2*Math.tan(c*Math.PI/360)))}},this.initialiseVisualisation=async t=>{if(!O){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}if(t.canvas&&(n=void 0,T=t.canvas),t.device===void 0&&t.requiredLimits===void 0&&typeof navigator<`u`&&navigator.gpu)try{let e=await navigator.gpu.requestAdapter({powerPreference:t.powerPreference});e&&(t.requiredLimits={maxTextureArrayLayers:e.limits.maxTextureArrayLayers,maxStorageBuffersPerShaderStage:e.limits.maxStorageBuffersPerShaderStage})}catch{}i=new e.WebGPURenderer(t),await i.init(),dt(i.backend?.isWebGPUBackend===!0),n!==void 0&&n.appendChild(i.domElement),i.setClearColor(16777215,1),T&&T.style&&(T.style.height=`100%`,T.style.width=`100%`);let r=i.domElement;r.addEventListener(`webglcontextlost`,P,!1),r.addEventListener(`webglcontextrestored`,F,!1),i.autoClear=!1;let a=this.createScene(`default`);this.setCurrentScene(a),v(M),O=!0}};let P=e=>{e.preventDefault();for(let e of Object.keys(c))f.hasOwnProperty(e)&&f[e].call()},F=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(w),j=!0,this.onWindowResize()}},this.getSceneByName=e=>S[e],this.createScene=e=>{if(S[e]==null){let t;return t=T?new Hn(T,i):new Hn(n,i),S[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<C.length;t++){let n=C[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 I=()=>{D?(g=requestAnimationFrame(I),this.render()):(cancelAnimationFrame(g),g=void 0)};this.stopAnimate=()=>{D&&=!1},this.animate=()=>{D||(o.reset(),D=!0,j=!0,I())},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,j=!0},this.setRenderOnDemand=e=>{A=!!e,j=!0},this.isRenderOnDemand=()=>A,this.invalidate=()=>{j=!0},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(b??=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}b.add(t),j=!0};let L=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=()=>{x=new e.Sprite,e.ImageUtils.loadTexture(`images/abi_big_logo_transparent_small.png`,void 0,L(x))},this.render=()=>{E||(n?n.clientWidth>0&&n.clientHeight>0&&(E=new r.ResizeSensor(n,this.onWindowResize)):T&&T.width>0&&T.height>0&&(E=new r.ResizeSensor(T,this.onWindowResize))),o.update();let e=o.getDelta(),t=a.renderGeometries(s,e,this.playAnimation);C.length>0&&(N.controls=a.getZincCameraControls(),N.updated=a.isCameraUpdated());for(let n=0;n<C.length;n++)C[n].renderGeometries(s,e,this.playAnimation,N)&&(t=!0);for(let e in c)c.hasOwnProperty(e)&&c[e].call();if(!(A&&!t&&!j)){j=!1,a.render(i),_!=null&&b!=null&&(i.clearDepth(),i.render(b,_));for(let e in u)u.hasOwnProperty(e)&&u[e].call()}},this.forceContextLoss=()=>{},this.forceContextRestore=()=>{},this.getThreeJSRenderer=()=>i,this.isSceneActive=e=>{if(a===e)return!0;for(let t=0;t<C.length;t++)if(C[t]===e)return!0;return!1},this.addActiveScene=e=>{this.isSceneActive(e)||(C.push(e),w.add(e.getThreeJSScene()),j=!0)},this.removeActiveScene=e=>{for(let t=0;t<C.length;t++)if(C[t]===e){C.splice(t,1),w.remove(e.getThreeJSScene()),j=!0;return}},this.clearAllActiveScene=()=>{for(let e=0;e<C.length;e++)w.remove(C[e].getThreeJSScene());C.splice(0,C.length),j=!0},this.dispose=()=>{D&&cancelAnimationFrame(g);for(let e in S)S.hasOwnProperty(e)&&S[e].clearAll();S=[],C=[],w=new e.Group,this.stopAnimate(),c={},l=0,u={},d=0,f={},p=0,m={},h=0,_=void 0,b=void 0,x=void 0;let t=this.createScene(`default`);this.setCurrentScene(t),E=void 0,y(M),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?.backend?.isWebGLBackend===!0,this.isWebGPU=()=>i?.backend?.isWebGPUBackend===!0},Wn=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 Wn(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+`
|
|
6
6
|
`,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]+`
|
|
7
7
|
`,n+=`Intent Parameters (1-3): `+this.intent_p1+`, `+this.intent_p2+`, `+this.intent_p3+`
|
|
8
8
|
`,n+=`Intent Code = `+this.intent_code+`
|
|
@@ -55,5 +55,5 @@
|
|
|
55
55
|
`,t+=`Intent Code = `+this.intent_code+`
|
|
56
56
|
`,t+=`Intent Name: "`+this.intent_name+`"
|
|
57
57
|
`,t+=`Dim Info = `+this.dim_info+`
|
|
58
|
-
`,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
|
|
58
|
+
`,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 Gn(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 Kn(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 qn(e,t=!1){return Gn(e,t)||Kn(e,t)}function Jn(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 Yn(e){return(0,o.decompressSync)(new Uint8Array(e)).buffer}function Xn(e,t=!1){let n=null;if(Jn(e)&&(e=Yn(e)),Gn(e,t)?n=new Q:Kn(e,t)&&(n=new $),n)n.readHeader(e);else throw Error(`That file does not appear to be NIFTI!`);return n}function Zn(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 Qn={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`},$n={hideBlackPixel:!0,keepScalePosition:!0,filterByValue:!0,timeEnabled:!1};function er(e){let t=Jn(e)?Yn(e):e;if(qn(t)){let e=Xn(t);return{niftiHeader:e,niftiImage:Zn(e,t)}}return t=void 0,{niftiHeader:void 0,niftiImage:void 0}}function tr(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 nr(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=tr(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=tr(n,r))}return{data:c,maskData:l,width:i,height:a,depth:o,isRGB:s}}}function rr(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 ir(e,t){return e&&e.sform_code?rr(e,t):{position:void 0,scale:void 0}}function ar(t,n,r,i,a){let o=new e.Data3DTexture(t,n,r,i);return o.anisotropy=4,a||(o.format=e.RedFormat),o.colorSpace=e.NoColorSpace,o.minFilter=e.NearestFilter,o.magFilter=e.NearestFilter,o.needsUpdate=!0,o}function or(e){if(e?.data){let t=new kt,n=ar(e.data,e.width,e.height,e.depth);return t.setDataTexture(n),t.size={width:e.width,height:e.height,depth:e.depth},t.isLoading=!1,t}}function sr(e,t,n,r,i){if(t?.data){let a={...$n};i&&Object.assign(a,i);let o=new Nt,s=or(t);if(s){o.groupName=`Images`,o.morph.renderOrder=1,o.texture=s;let i=structuredClone(Qn);if(Object.assign(i,r),n&&e){let{position:t,scale:n}=ir(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=ar(t.maskData,t.width,t.height,t.depth,!1);o.setMask(e)}return o.setNumberOfChannels(t.isRGB?3:1),o}}}async function cr(e,t){let n,r;if(t){let e=er(await(await fetch(t)).arrayBuffer());n=e.niftiHeader,r=e.niftiImage}let{niftiHeader:i,niftiImage:a}=er(await(await fetch(e)).arrayBuffer());return{sources:nr(i,a,n,r),niftiHeader:i}}async function lr(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 cr(s,n,i);o=sr(a,e,t,r,i)}if(a&&o){for(let t=1;t<e.length;t++){let r=await ur(e[t],n,i);o.addTextureArray(r)}o.timeEnabled=!0}return o}async function ur(e,t,n){let{sources:r}=await cr(e,t,n);return or(r)}var dr=h.version,fr=new function(){this.Revision=dr,this.defaultMaterialColor=16777215,this.defaultOpacity=1,this.Geometry=Ge,this.Glyph=qe,this.Glyphset=mt,this.Pointset=Et,this.Label=Ke,this.Lines=Dt,this.TextureSlides=Nt,this.TextureArray=kt,this.Renderer=Un,this.Scene=Hn,this.Viewport=Pt,this.CameraControls=Ft,this.SmoothCameraTransition=It,this.RayCaster=Rt,this.CameraAutoTumble=zt,this.StereoEffect=Vt,this.loadExternalFile=re,this.loadExternalFiles=ie,this.createPrimitivesFromNIFTI=lr,this.createTextureFromNIFTI=ur,this.THREE=e};return fr});
|
|
59
59
|
//# sourceMappingURL=zinc.js.map
|