zincjs 2.4.1-beta.7 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/build/zinc.js CHANGED
@@ -1,4 +1,4 @@
1
- (function(e,t){typeof exports==`object`&&typeof module<`u`?module.exports=t(require("three/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
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:`3.0.0`,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,"webgpu@0.4.0":!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(`