@splnlss/3d-story-viewer 0.5.7 → 0.7.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@splnlss/3d-story-viewer",
3
- "version": "0.5.7",
3
+ "version": "0.7.0",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "registry": "https://registry.npmjs.org/"
@@ -33,6 +33,7 @@
33
33
  "preview": "vite preview",
34
34
  "pretest": "yarn patch:spark",
35
35
  "test": "vitest run",
36
+ "test:precision": "vitest run tests/precision",
36
37
  "pretest:browser": "yarn patch:spark",
37
38
  "test:browser": "playwright test",
38
39
  "test:all": "npm run test && npm run test:browser",
@@ -1 +0,0 @@
1
- !function(){"use strict";const t=2e3,s={};function e(...t){t=function(t){const s=t[0];if("string"==typeof s&&s.startsWith("TSL:")){const s=t[1];s&&s.isStackTrace?t[0]+=" "+s.getLocation():t[1]='Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.'}return t}(t);t.shift();{const s=t[0];s&&s.isStackTrace}}function i(...t){const i=t.join(" ");i in s||(s[i]=!0,e(...t))}const r=["00","01","02","03","04","05","06","07","08","09","0a","0b","0c","0d","0e","0f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f","20","21","22","23","24","25","26","27","28","29","2a","2b","2c","2d","2e","2f","30","31","32","33","34","35","36","37","38","39","3a","3b","3c","3d","3e","3f","40","41","42","43","44","45","46","47","48","49","4a","4b","4c","4d","4e","4f","50","51","52","53","54","55","56","57","58","59","5a","5b","5c","5d","5e","5f","60","61","62","63","64","65","66","67","68","69","6a","6b","6c","6d","6e","6f","70","71","72","73","74","75","76","77","78","79","7a","7b","7c","7d","7e","7f","80","81","82","83","84","85","86","87","88","89","8a","8b","8c","8d","8e","8f","90","91","92","93","94","95","96","97","98","99","9a","9b","9c","9d","9e","9f","a0","a1","a2","a3","a4","a5","a6","a7","a8","a9","aa","ab","ac","ad","ae","af","b0","b1","b2","b3","b4","b5","b6","b7","b8","b9","ba","bb","bc","bd","be","bf","c0","c1","c2","c3","c4","c5","c6","c7","c8","c9","ca","cb","cc","cd","ce","cf","d0","d1","d2","d3","d4","d5","d6","d7","d8","d9","da","db","dc","dd","de","df","e0","e1","e2","e3","e4","e5","e6","e7","e8","e9","ea","eb","ec","ed","ee","ef","f0","f1","f2","f3","f4","f5","f6","f7","f8","f9","fa","fb","fc","fd","fe","ff"];let h=1234567;const n=Math.PI/180,a=180/Math.PI;function o(t,s,e){return Math.max(s,Math.min(e,t))}function u(t,s){return(t%s+s)%s}function l(t,s,e){return(1-e)*t+e*s}const c={DEG2RAD:n,RAD2DEG:a,generateUUID:function(){const t=4294967295*Math.random()|0,s=4294967295*Math.random()|0,e=4294967295*Math.random()|0,i=4294967295*Math.random()|0;return(r[255&t]+r[t>>8&255]+r[t>>16&255]+r[t>>24&255]+"-"+r[255&s]+r[s>>8&255]+"-"+r[s>>16&15|64]+r[s>>24&255]+"-"+r[63&e|128]+r[e>>8&255]+"-"+r[e>>16&255]+r[e>>24&255]+r[255&i]+r[i>>8&255]+r[i>>16&255]+r[i>>24&255]).toLowerCase()},clamp:o,euclideanModulo:u,mapLinear:function(t,s,e,i,r){return i+(t-s)*(r-i)/(e-s)},inverseLerp:function(t,s,e){return t!==s?(e-t)/(s-t):0},lerp:l,damp:function(t,s,e,i){return l(t,s,1-Math.exp(-e*i))},pingpong:function(t,s=1){return s-Math.abs(u(t,2*s)-s)},smoothstep:function(t,s,e){return t<=s?0:t>=e?1:(t=(t-s)/(e-s))*t*(3-2*t)},smootherstep:function(t,s,e){return t<=s?0:t>=e?1:(t=(t-s)/(e-s))*t*t*(t*(6*t-15)+10)},randInt:function(t,s){return t+Math.floor(Math.random()*(s-t+1))},randFloat:function(t,s){return t+Math.random()*(s-t)},randFloatSpread:function(t){return t*(.5-Math.random())},seededRandom:function(t){void 0!==t&&(h=t);let s=h+=1831565813;return s=Math.imul(s^s>>>15,1|s),s^=s+Math.imul(s^s>>>7,61|s),((s^s>>>14)>>>0)/4294967296},degToRad:function(t){return t*n},radToDeg:function(t){return t*a},isPowerOfTwo:function(t){return!(t&t-1)&&0!==t},ceilPowerOfTwo:function(t){return Math.pow(2,Math.ceil(Math.log(t)/Math.LN2))},floorPowerOfTwo:function(t){return Math.pow(2,Math.floor(Math.log(t)/Math.LN2))},setQuaternionFromProperEuler:function(t,s,i,r,h){const n=Math.cos,a=Math.sin,o=n(i/2),u=a(i/2),l=n((s+r)/2),c=a((s+r)/2),x=n((s-r)/2),y=a((s-r)/2),m=n((r-s)/2),d=a((r-s)/2);switch(h){case"XYX":t.set(o*c,u*x,u*y,o*l);break;case"YZY":t.set(u*y,o*c,u*x,o*l);break;case"ZXZ":t.set(u*x,u*y,o*c,o*l);break;case"XZX":t.set(o*c,u*d,u*m,o*l);break;case"YXY":t.set(u*m,o*c,u*d,o*l);break;case"ZYZ":t.set(u*d,u*m,o*c,o*l);break;default:e("MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: "+h)}},normalize:function(t,s){switch(s.constructor){case Float32Array:return t;case Uint32Array:return Math.round(4294967295*t);case Uint16Array:return Math.round(65535*t);case Uint8Array:return Math.round(255*t);case Int32Array:return Math.round(2147483647*t);case Int16Array:return Math.round(32767*t);case Int8Array:return Math.round(127*t);default:throw new Error("THREE.MathUtils: Invalid component type.")}},denormalize:function(t,s){switch(s.constructor){case Float32Array:return t;case Uint32Array:return t/4294967295;case Uint16Array:return t/65535;case Uint8Array:return t/255;case Int32Array:return Math.max(t/2147483647,-1);case Int16Array:return Math.max(t/32767,-1);case Int8Array:return Math.max(t/127,-1);default:throw new Error("THREE.MathUtils: Invalid component type.")}}},x=class{constructor(t=0,s=0){this.x=t,this.y=s}get width(){return this.x}set width(t){this.x=t}get height(){return this.y}set height(t){this.y=t}set(t,s){return this.x=t,this.y=s,this}setScalar(t){return this.x=t,this.y=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setComponent(t,s){switch(t){case 0:this.x=s;break;case 1:this.y=s;break;default:throw new Error("THREE.Vector2: index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;default:throw new Error("THREE.Vector2: index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y)}copy(t){return this.x=t.x,this.y=t.y,this}add(t){return this.x+=t.x,this.y+=t.y,this}addScalar(t){return this.x+=t,this.y+=t,this}addVectors(t,s){return this.x=t.x+s.x,this.y=t.y+s.y,this}addScaledVector(t,s){return this.x+=t.x*s,this.y+=t.y*s,this}sub(t){return this.x-=t.x,this.y-=t.y,this}subScalar(t){return this.x-=t,this.y-=t,this}subVectors(t,s){return this.x=t.x-s.x,this.y=t.y-s.y,this}multiply(t){return this.x*=t.x,this.y*=t.y,this}multiplyScalar(t){return this.x*=t,this.y*=t,this}divide(t){return this.x/=t.x,this.y/=t.y,this}divideScalar(t){return this.multiplyScalar(1/t)}applyMatrix3(t){const s=this.x,e=this.y,i=t.elements;return this.x=i[0]*s+i[3]*e+i[6],this.y=i[1]*s+i[4]*e+i[7],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this}clamp(t,s){return this.x=o(this.x,t.x,s.x),this.y=o(this.y,t.y,s.y),this}clampScalar(t,s){return this.x=o(this.x,t,s),this.y=o(this.y,t,s),this}clampLength(t,s){const e=this.length();return this.divideScalar(e||1).multiplyScalar(o(e,t,s))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(t){return this.x*t.x+this.y*t.y}cross(t){return this.x*t.y-this.y*t.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(t){const s=Math.sqrt(this.lengthSq()*t.lengthSq());if(0===s)return Math.PI/2;const e=this.dot(t)/s;return Math.acos(o(e,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const s=this.x-t.x,e=this.y-t.y;return s*s+e*e}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,s){return this.x+=(t.x-this.x)*s,this.y+=(t.y-this.y)*s,this}lerpVectors(t,s,e){return this.x=t.x+(s.x-t.x)*e,this.y=t.y+(s.y-t.y)*e,this}equals(t){return t.x===this.x&&t.y===this.y}fromArray(t,s=0){return this.x=t[s],this.y=t[s+1],this}toArray(t=[],s=0){return t[s]=this.x,t[s+1]=this.y,t}fromBufferAttribute(t,s){return this.x=t.getX(s),this.y=t.getY(s),this}rotateAround(t,s){const e=Math.cos(s),i=Math.sin(s),r=this.x-t.x,h=this.y-t.y;return this.x=r*e-h*i+t.x,this.y=r*i+h*e+t.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y}};x.prototype.isVector2=!0;class y{constructor(t=0,s=0,e=0,i=1){this.isQuaternion=!0,this._x=t,this._y=s,this._z=e,this._w=i}static slerpFlat(t,s,e,i,r,h,n){let a=e[i+0],o=e[i+1],u=e[i+2],l=e[i+3],c=r[h+0],x=r[h+1],y=r[h+2],m=r[h+3];if(l!==m||a!==c||o!==x||u!==y){let t=a*c+o*x+u*y+l*m;t<0&&(c=-c,x=-x,y=-y,m=-m,t=-t);let s=1-n;if(t<.9995){const e=Math.acos(t),i=Math.sin(e);s=Math.sin(s*e)/i,a=a*s+c*(n=Math.sin(n*e)/i),o=o*s+x*n,u=u*s+y*n,l=l*s+m*n}else{a=a*s+c*n,o=o*s+x*n,u=u*s+y*n,l=l*s+m*n;const t=1/Math.sqrt(a*a+o*o+u*u+l*l);a*=t,o*=t,u*=t,l*=t}}t[s]=a,t[s+1]=o,t[s+2]=u,t[s+3]=l}static multiplyQuaternionsFlat(t,s,e,i,r,h){const n=e[i],a=e[i+1],o=e[i+2],u=e[i+3],l=r[h],c=r[h+1],x=r[h+2],y=r[h+3];return t[s]=n*y+u*l+a*x-o*c,t[s+1]=a*y+u*c+o*l-n*x,t[s+2]=o*y+u*x+n*c-a*l,t[s+3]=u*y-n*l-a*c-o*x,t}get x(){return this._x}set x(t){this._x=t,this._onChangeCallback()}get y(){return this._y}set y(t){this._y=t,this._onChangeCallback()}get z(){return this._z}set z(t){this._z=t,this._onChangeCallback()}get w(){return this._w}set w(t){this._w=t,this._onChangeCallback()}set(t,s,e,i){return this._x=t,this._y=s,this._z=e,this._w=i,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(t){return this._x=t.x,this._y=t.y,this._z=t.z,this._w=t.w,this._onChangeCallback(),this}setFromEuler(t,s=!0){const i=t._x,r=t._y,h=t._z,n=t._order,a=Math.cos,o=Math.sin,u=a(i/2),l=a(r/2),c=a(h/2),x=o(i/2),y=o(r/2),m=o(h/2);switch(n){case"XYZ":this._x=x*l*c+u*y*m,this._y=u*y*c-x*l*m,this._z=u*l*m+x*y*c,this._w=u*l*c-x*y*m;break;case"YXZ":this._x=x*l*c+u*y*m,this._y=u*y*c-x*l*m,this._z=u*l*m-x*y*c,this._w=u*l*c+x*y*m;break;case"ZXY":this._x=x*l*c-u*y*m,this._y=u*y*c+x*l*m,this._z=u*l*m+x*y*c,this._w=u*l*c-x*y*m;break;case"ZYX":this._x=x*l*c-u*y*m,this._y=u*y*c+x*l*m,this._z=u*l*m-x*y*c,this._w=u*l*c+x*y*m;break;case"YZX":this._x=x*l*c+u*y*m,this._y=u*y*c+x*l*m,this._z=u*l*m-x*y*c,this._w=u*l*c-x*y*m;break;case"XZY":this._x=x*l*c-u*y*m,this._y=u*y*c-x*l*m,this._z=u*l*m+x*y*c,this._w=u*l*c+x*y*m;break;default:e("Quaternion: .setFromEuler() encountered an unknown order: "+n)}return!0===s&&this._onChangeCallback(),this}setFromAxisAngle(t,s){const e=s/2,i=Math.sin(e);return this._x=t.x*i,this._y=t.y*i,this._z=t.z*i,this._w=Math.cos(e),this._onChangeCallback(),this}setFromRotationMatrix(t){const s=t.elements,e=s[0],i=s[4],r=s[8],h=s[1],n=s[5],a=s[9],o=s[2],u=s[6],l=s[10],c=e+n+l;if(c>0){const t=.5/Math.sqrt(c+1);this._w=.25/t,this._x=(u-a)*t,this._y=(r-o)*t,this._z=(h-i)*t}else if(e>n&&e>l){const t=2*Math.sqrt(1+e-n-l);this._w=(u-a)/t,this._x=.25*t,this._y=(i+h)/t,this._z=(r+o)/t}else if(n>l){const t=2*Math.sqrt(1+n-e-l);this._w=(r-o)/t,this._x=(i+h)/t,this._y=.25*t,this._z=(a+u)/t}else{const t=2*Math.sqrt(1+l-e-n);this._w=(h-i)/t,this._x=(r+o)/t,this._y=(a+u)/t,this._z=.25*t}return this._onChangeCallback(),this}setFromUnitVectors(t,s){let e=t.dot(s)+1;return e<1e-8?(e=0,Math.abs(t.x)>Math.abs(t.z)?(this._x=-t.y,this._y=t.x,this._z=0,this._w=e):(this._x=0,this._y=-t.z,this._z=t.y,this._w=e)):(this._x=t.y*s.z-t.z*s.y,this._y=t.z*s.x-t.x*s.z,this._z=t.x*s.y-t.y*s.x,this._w=e),this.normalize()}angleTo(t){return 2*Math.acos(Math.abs(o(this.dot(t),-1,1)))}rotateTowards(t,s){const e=this.angleTo(t);if(0===e)return this;const i=Math.min(1,s/e);return this.slerp(t,i),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(t){return this._x*t._x+this._y*t._y+this._z*t._z+this._w*t._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let t=this.length();return 0===t?(this._x=0,this._y=0,this._z=0,this._w=1):(t=1/t,this._x=this._x*t,this._y=this._y*t,this._z=this._z*t,this._w=this._w*t),this._onChangeCallback(),this}multiply(t){return this.multiplyQuaternions(this,t)}premultiply(t){return this.multiplyQuaternions(t,this)}multiplyQuaternions(t,s){const e=t._x,i=t._y,r=t._z,h=t._w,n=s._x,a=s._y,o=s._z,u=s._w;return this._x=e*u+h*n+i*o-r*a,this._y=i*u+h*a+r*n-e*o,this._z=r*u+h*o+e*a-i*n,this._w=h*u-e*n-i*a-r*o,this._onChangeCallback(),this}slerp(t,s){let e=t._x,i=t._y,r=t._z,h=t._w,n=this.dot(t);n<0&&(e=-e,i=-i,r=-r,h=-h,n=-n);let a=1-s;if(n<.9995){const t=Math.acos(n),o=Math.sin(t);a=Math.sin(a*t)/o,s=Math.sin(s*t)/o,this._x=this._x*a+e*s,this._y=this._y*a+i*s,this._z=this._z*a+r*s,this._w=this._w*a+h*s,this._onChangeCallback()}else this._x=this._x*a+e*s,this._y=this._y*a+i*s,this._z=this._z*a+r*s,this._w=this._w*a+h*s,this.normalize();return this}slerpQuaternions(t,s,e){return this.copy(t).slerp(s,e)}random(){const t=2*Math.PI*Math.random(),s=2*Math.PI*Math.random(),e=Math.random(),i=Math.sqrt(1-e),r=Math.sqrt(e);return this.set(i*Math.sin(t),i*Math.cos(t),r*Math.sin(s),r*Math.cos(s))}equals(t){return t._x===this._x&&t._y===this._y&&t._z===this._z&&t._w===this._w}fromArray(t,s=0){return this._x=t[s],this._y=t[s+1],this._z=t[s+2],this._w=t[s+3],this._onChangeCallback(),this}toArray(t=[],s=0){return t[s]=this._x,t[s+1]=this._y,t[s+2]=this._z,t[s+3]=this._w,t}fromBufferAttribute(t,s){return this._x=t.getX(s),this._y=t.getY(s),this._z=t.getZ(s),this._w=t.getW(s),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(t){return this._onChangeCallback=t,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w}}const m=class{constructor(t=0,s=0,e=0){this.x=t,this.y=s,this.z=e}set(t,s,e){return void 0===e&&(e=this.z),this.x=t,this.y=s,this.z=e,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setComponent(t,s){switch(t){case 0:this.x=s;break;case 1:this.y=s;break;case 2:this.z=s;break;default:throw new Error("THREE.Vector3: index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("THREE.Vector3: index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this}addVectors(t,s){return this.x=t.x+s.x,this.y=t.y+s.y,this.z=t.z+s.z,this}addScaledVector(t,s){return this.x+=t.x*s,this.y+=t.y*s,this.z+=t.z*s,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this}subVectors(t,s){return this.x=t.x-s.x,this.y=t.y-s.y,this.z=t.z-s.z,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this}multiplyVectors(t,s){return this.x=t.x*s.x,this.y=t.y*s.y,this.z=t.z*s.z,this}applyEuler(t){return this.applyQuaternion(z.setFromEuler(t))}applyAxisAngle(t,s){return this.applyQuaternion(z.setFromAxisAngle(t,s))}applyMatrix3(t){const s=this.x,e=this.y,i=this.z,r=t.elements;return this.x=r[0]*s+r[3]*e+r[6]*i,this.y=r[1]*s+r[4]*e+r[7]*i,this.z=r[2]*s+r[5]*e+r[8]*i,this}applyNormalMatrix(t){return this.applyMatrix3(t).normalize()}applyMatrix4(t){const s=this.x,e=this.y,i=this.z,r=t.elements,h=1/(r[3]*s+r[7]*e+r[11]*i+r[15]);return this.x=(r[0]*s+r[4]*e+r[8]*i+r[12])*h,this.y=(r[1]*s+r[5]*e+r[9]*i+r[13])*h,this.z=(r[2]*s+r[6]*e+r[10]*i+r[14])*h,this}applyQuaternion(t){const s=this.x,e=this.y,i=this.z,r=t.x,h=t.y,n=t.z,a=t.w,o=2*(h*i-n*e),u=2*(n*s-r*i),l=2*(r*e-h*s);return this.x=s+a*o+h*l-n*u,this.y=e+a*u+n*o-r*l,this.z=i+a*l+r*u-h*o,this}project(t){return this.applyMatrix4(t.matrixWorldInverse).applyMatrix4(t.projectionMatrix)}unproject(t){return this.applyMatrix4(t.projectionMatrixInverse).applyMatrix4(t.matrixWorld)}transformDirection(t){const s=this.x,e=this.y,i=this.z,r=t.elements;return this.x=r[0]*s+r[4]*e+r[8]*i,this.y=r[1]*s+r[5]*e+r[9]*i,this.z=r[2]*s+r[6]*e+r[10]*i,this.normalize()}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this}divideScalar(t){return this.multiplyScalar(1/t)}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this}clamp(t,s){return this.x=o(this.x,t.x,s.x),this.y=o(this.y,t.y,s.y),this.z=o(this.z,t.z,s.z),this}clampScalar(t,s){return this.x=o(this.x,t,s),this.y=o(this.y,t,s),this.z=o(this.z,t,s),this}clampLength(t,s){const e=this.length();return this.divideScalar(e||1).multiplyScalar(o(e,t,s))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,s){return this.x+=(t.x-this.x)*s,this.y+=(t.y-this.y)*s,this.z+=(t.z-this.z)*s,this}lerpVectors(t,s,e){return this.x=t.x+(s.x-t.x)*e,this.y=t.y+(s.y-t.y)*e,this.z=t.z+(s.z-t.z)*e,this}cross(t){return this.crossVectors(this,t)}crossVectors(t,s){const e=t.x,i=t.y,r=t.z,h=s.x,n=s.y,a=s.z;return this.x=i*a-r*n,this.y=r*h-e*a,this.z=e*n-i*h,this}projectOnVector(t){const s=t.lengthSq();if(0===s)return this.set(0,0,0);const e=t.dot(this)/s;return this.copy(t).multiplyScalar(e)}projectOnPlane(t){return M.copy(this).projectOnVector(t),this.sub(M)}reflect(t){return this.sub(M.copy(t).multiplyScalar(2*this.dot(t)))}angleTo(t){const s=Math.sqrt(this.lengthSq()*t.lengthSq());if(0===s)return Math.PI/2;const e=this.dot(t)/s;return Math.acos(o(e,-1,1))}distanceTo(t){return Math.sqrt(this.distanceToSquared(t))}distanceToSquared(t){const s=this.x-t.x,e=this.y-t.y,i=this.z-t.z;return s*s+e*e+i*i}manhattanDistanceTo(t){return Math.abs(this.x-t.x)+Math.abs(this.y-t.y)+Math.abs(this.z-t.z)}setFromSpherical(t){return this.setFromSphericalCoords(t.radius,t.phi,t.theta)}setFromSphericalCoords(t,s,e){const i=Math.sin(s)*t;return this.x=i*Math.sin(e),this.y=Math.cos(s)*t,this.z=i*Math.cos(e),this}setFromCylindrical(t){return this.setFromCylindricalCoords(t.radius,t.theta,t.y)}setFromCylindricalCoords(t,s,e){return this.x=t*Math.sin(s),this.y=e,this.z=t*Math.cos(s),this}setFromMatrixPosition(t){const s=t.elements;return this.x=s[12],this.y=s[13],this.z=s[14],this}setFromMatrixScale(t){const s=this.setFromMatrixColumn(t,0).length(),e=this.setFromMatrixColumn(t,1).length(),i=this.setFromMatrixColumn(t,2).length();return this.x=s,this.y=e,this.z=i,this}setFromMatrixColumn(t,s){return this.fromArray(t.elements,4*s)}setFromMatrix3Column(t,s){return this.fromArray(t.elements,3*s)}setFromEuler(t){return this.x=t._x,this.y=t._y,this.z=t._z,this}setFromColor(t){return this.x=t.r,this.y=t.g,this.z=t.b,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z}fromArray(t,s=0){return this.x=t[s],this.y=t[s+1],this.z=t[s+2],this}toArray(t=[],s=0){return t[s]=this.x,t[s+1]=this.y,t[s+2]=this.z,t}fromBufferAttribute(t,s){return this.x=t.getX(s),this.y=t.getY(s),this.z=t.getZ(s),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){const t=Math.random()*Math.PI*2,s=2*Math.random()-1,e=Math.sqrt(1-s*s);return this.x=e*Math.cos(t),this.y=s,this.z=e*Math.sin(t),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z}};m.prototype.isVector3=!0;let d=m;const M=new d,z=new y,f=class{constructor(t,s,e,i,r,h,n,a,o){this.elements=[1,0,0,0,1,0,0,0,1],void 0!==t&&this.set(t,s,e,i,r,h,n,a,o)}set(t,s,e,i,r,h,n,a,o){const u=this.elements;return u[0]=t,u[1]=i,u[2]=n,u[3]=s,u[4]=r,u[5]=a,u[6]=e,u[7]=h,u[8]=o,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(t){const s=this.elements,e=t.elements;return s[0]=e[0],s[1]=e[1],s[2]=e[2],s[3]=e[3],s[4]=e[4],s[5]=e[5],s[6]=e[6],s[7]=e[7],s[8]=e[8],this}extractBasis(t,s,e){return t.setFromMatrix3Column(this,0),s.setFromMatrix3Column(this,1),e.setFromMatrix3Column(this,2),this}setFromMatrix4(t){const s=t.elements;return this.set(s[0],s[4],s[8],s[1],s[5],s[9],s[2],s[6],s[10]),this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,s){const e=t.elements,i=s.elements,r=this.elements,h=e[0],n=e[3],a=e[6],o=e[1],u=e[4],l=e[7],c=e[2],x=e[5],y=e[8],m=i[0],d=i[3],M=i[6],z=i[1],f=i[4],p=i[7],w=i[2],_=i[5],g=i[8];return r[0]=h*m+n*z+a*w,r[3]=h*d+n*f+a*_,r[6]=h*M+n*p+a*g,r[1]=o*m+u*z+l*w,r[4]=o*d+u*f+l*_,r[7]=o*M+u*p+l*g,r[2]=c*m+x*z+y*w,r[5]=c*d+x*f+y*_,r[8]=c*M+x*p+y*g,this}multiplyScalar(t){const s=this.elements;return s[0]*=t,s[3]*=t,s[6]*=t,s[1]*=t,s[4]*=t,s[7]*=t,s[2]*=t,s[5]*=t,s[8]*=t,this}determinant(){const t=this.elements,s=t[0],e=t[1],i=t[2],r=t[3],h=t[4],n=t[5],a=t[6],o=t[7],u=t[8];return s*h*u-s*n*o-e*r*u+e*n*a+i*r*o-i*h*a}invert(){const t=this.elements,s=t[0],e=t[1],i=t[2],r=t[3],h=t[4],n=t[5],a=t[6],o=t[7],u=t[8],l=u*h-n*o,c=n*a-u*r,x=o*r-h*a,y=s*l+e*c+i*x;if(0===y)return this.set(0,0,0,0,0,0,0,0,0);const m=1/y;return t[0]=l*m,t[1]=(i*o-u*e)*m,t[2]=(n*e-i*h)*m,t[3]=c*m,t[4]=(u*s-i*a)*m,t[5]=(i*r-n*s)*m,t[6]=x*m,t[7]=(e*a-o*s)*m,t[8]=(h*s-e*r)*m,this}transpose(){let t;const s=this.elements;return t=s[1],s[1]=s[3],s[3]=t,t=s[2],s[2]=s[6],s[6]=t,t=s[5],s[5]=s[7],s[7]=t,this}getNormalMatrix(t){return this.setFromMatrix4(t).invert().transpose()}transposeIntoArray(t){const s=this.elements;return t[0]=s[0],t[1]=s[3],t[2]=s[6],t[3]=s[1],t[4]=s[4],t[5]=s[7],t[6]=s[2],t[7]=s[5],t[8]=s[8],this}setUvTransform(t,s,e,i,r,h,n){const a=Math.cos(r),o=Math.sin(r);return this.set(e*a,e*o,-e*(a*h+o*n)+h+t,-i*o,i*a,-i*(-o*h+a*n)+n+s,0,0,1),this}scale(t,s){return i("Matrix3: .scale() is deprecated. Use .makeScale() instead."),this.premultiply(w.makeScale(t,s)),this}rotate(t){return i("Matrix3: .rotate() is deprecated. Use .makeRotation() instead."),this.premultiply(w.makeRotation(-t)),this}translate(t,s){return i("Matrix3: .translate() is deprecated. Use .makeTranslation() instead."),this.premultiply(w.makeTranslation(t,s)),this}makeTranslation(t,s){return t.isVector2?this.set(1,0,t.x,0,1,t.y,0,0,1):this.set(1,0,t,0,1,s,0,0,1),this}makeRotation(t){const s=Math.cos(t),e=Math.sin(t);return this.set(s,-e,0,e,s,0,0,0,1),this}makeScale(t,s){return this.set(t,0,0,0,s,0,0,0,1),this}equals(t){const s=this.elements,e=t.elements;for(let i=0;i<9;i++)if(s[i]!==e[i])return!1;return!0}fromArray(t,s=0){for(let e=0;e<9;e++)this.elements[e]=t[e+s];return this}toArray(t=[],s=0){const e=this.elements;return t[s]=e[0],t[s+1]=e[1],t[s+2]=e[2],t[s+3]=e[3],t[s+4]=e[4],t[s+5]=e[5],t[s+6]=e[6],t[s+7]=e[7],t[s+8]=e[8],t}clone(){return(new this.constructor).fromArray(this.elements)}};f.prototype.isMatrix3=!0;let p=f;const w=new p,_=class{constructor(t=0,s=0,e=0,i=1){this.x=t,this.y=s,this.z=e,this.w=i}get width(){return this.z}set width(t){this.z=t}get height(){return this.w}set height(t){this.w=t}set(t,s,e,i){return this.x=t,this.y=s,this.z=e,this.w=i,this}setScalar(t){return this.x=t,this.y=t,this.z=t,this.w=t,this}setX(t){return this.x=t,this}setY(t){return this.y=t,this}setZ(t){return this.z=t,this}setW(t){return this.w=t,this}setComponent(t,s){switch(t){case 0:this.x=s;break;case 1:this.y=s;break;case 2:this.z=s;break;case 3:this.w=s;break;default:throw new Error("THREE.Vector4: index is out of range: "+t)}return this}getComponent(t){switch(t){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("THREE.Vector4: index is out of range: "+t)}}clone(){return new this.constructor(this.x,this.y,this.z,this.w)}copy(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=void 0!==t.w?t.w:1,this}add(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this}addScalar(t){return this.x+=t,this.y+=t,this.z+=t,this.w+=t,this}addVectors(t,s){return this.x=t.x+s.x,this.y=t.y+s.y,this.z=t.z+s.z,this.w=t.w+s.w,this}addScaledVector(t,s){return this.x+=t.x*s,this.y+=t.y*s,this.z+=t.z*s,this.w+=t.w*s,this}sub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this}subScalar(t){return this.x-=t,this.y-=t,this.z-=t,this.w-=t,this}subVectors(t,s){return this.x=t.x-s.x,this.y=t.y-s.y,this.z=t.z-s.z,this.w=t.w-s.w,this}multiply(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this.w*=t.w,this}multiplyScalar(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this}applyMatrix4(t){const s=this.x,e=this.y,i=this.z,r=this.w,h=t.elements;return this.x=h[0]*s+h[4]*e+h[8]*i+h[12]*r,this.y=h[1]*s+h[5]*e+h[9]*i+h[13]*r,this.z=h[2]*s+h[6]*e+h[10]*i+h[14]*r,this.w=h[3]*s+h[7]*e+h[11]*i+h[15]*r,this}divide(t){return this.x/=t.x,this.y/=t.y,this.z/=t.z,this.w/=t.w,this}divideScalar(t){return this.multiplyScalar(1/t)}setAxisAngleFromQuaternion(t){this.w=2*Math.acos(t.w);const s=Math.sqrt(1-t.w*t.w);return s<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=t.x/s,this.y=t.y/s,this.z=t.z/s),this}setAxisAngleFromRotationMatrix(t){let s,e,i,r;const h=.01,n=.1,a=t.elements,o=a[0],u=a[4],l=a[8],c=a[1],x=a[5],y=a[9],m=a[2],d=a[6],M=a[10];if(Math.abs(u-c)<h&&Math.abs(l-m)<h&&Math.abs(y-d)<h){if(Math.abs(u+c)<n&&Math.abs(l+m)<n&&Math.abs(y+d)<n&&Math.abs(o+x+M-3)<n)return this.set(1,0,0,0),this;s=Math.PI;const t=(o+1)/2,a=(x+1)/2,z=(M+1)/2,f=(u+c)/4,p=(l+m)/4,w=(y+d)/4;return t>a&&t>z?t<h?(e=0,i=.707106781,r=.707106781):(e=Math.sqrt(t),i=f/e,r=p/e):a>z?a<h?(e=.707106781,i=0,r=.707106781):(i=Math.sqrt(a),e=f/i,r=w/i):z<h?(e=.707106781,i=.707106781,r=0):(r=Math.sqrt(z),e=p/r,i=w/r),this.set(e,i,r,s),this}let z=Math.sqrt((d-y)*(d-y)+(l-m)*(l-m)+(c-u)*(c-u));return Math.abs(z)<.001&&(z=1),this.x=(d-y)/z,this.y=(l-m)/z,this.z=(c-u)/z,this.w=Math.acos((o+x+M-1)/2),this}setFromMatrixPosition(t){const s=t.elements;return this.x=s[12],this.y=s[13],this.z=s[14],this.w=s[15],this}min(t){return this.x=Math.min(this.x,t.x),this.y=Math.min(this.y,t.y),this.z=Math.min(this.z,t.z),this.w=Math.min(this.w,t.w),this}max(t){return this.x=Math.max(this.x,t.x),this.y=Math.max(this.y,t.y),this.z=Math.max(this.z,t.z),this.w=Math.max(this.w,t.w),this}clamp(t,s){return this.x=o(this.x,t.x,s.x),this.y=o(this.y,t.y,s.y),this.z=o(this.z,t.z,s.z),this.w=o(this.w,t.w,s.w),this}clampScalar(t,s){return this.x=o(this.x,t,s),this.y=o(this.y,t,s),this.z=o(this.z,t,s),this.w=o(this.w,t,s),this}clampLength(t,s){const e=this.length();return this.divideScalar(e||1).multiplyScalar(o(e,t,s))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this.w=Math.trunc(this.w),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this}dot(t){return this.x*t.x+this.y*t.y+this.z*t.z+this.w*t.w}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)}normalize(){return this.divideScalar(this.length()||1)}setLength(t){return this.normalize().multiplyScalar(t)}lerp(t,s){return this.x+=(t.x-this.x)*s,this.y+=(t.y-this.y)*s,this.z+=(t.z-this.z)*s,this.w+=(t.w-this.w)*s,this}lerpVectors(t,s,e){return this.x=t.x+(s.x-t.x)*e,this.y=t.y+(s.y-t.y)*e,this.z=t.z+(s.z-t.z)*e,this.w=t.w+(s.w-t.w)*e,this}equals(t){return t.x===this.x&&t.y===this.y&&t.z===this.z&&t.w===this.w}fromArray(t,s=0){return this.x=t[s],this.y=t[s+1],this.z=t[s+2],this.w=t[s+3],this}toArray(t=[],s=0){return t[s]=this.x,t[s+1]=this.y,t[s+2]=this.z,t[s+3]=this.w,t}fromBufferAttribute(t,s){return this.x=t.getX(s),this.y=t.getY(s),this.z=t.getZ(s),this.w=t.getW(s),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this.w=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z,yield this.w}};_.prototype.isVector4=!0;const g=class s{constructor(t,s,e,i,r,h,n,a,o,u,l,c,x,y,m,d){this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],void 0!==t&&this.set(t,s,e,i,r,h,n,a,o,u,l,c,x,y,m,d)}set(t,s,e,i,r,h,n,a,o,u,l,c,x,y,m,d){const M=this.elements;return M[0]=t,M[4]=s,M[8]=e,M[12]=i,M[1]=r,M[5]=h,M[9]=n,M[13]=a,M[2]=o,M[6]=u,M[10]=l,M[14]=c,M[3]=x,M[7]=y,M[11]=m,M[15]=d,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return(new s).fromArray(this.elements)}copy(t){const s=this.elements,e=t.elements;return s[0]=e[0],s[1]=e[1],s[2]=e[2],s[3]=e[3],s[4]=e[4],s[5]=e[5],s[6]=e[6],s[7]=e[7],s[8]=e[8],s[9]=e[9],s[10]=e[10],s[11]=e[11],s[12]=e[12],s[13]=e[13],s[14]=e[14],s[15]=e[15],this}copyPosition(t){const s=this.elements,e=t.elements;return s[12]=e[12],s[13]=e[13],s[14]=e[14],this}setFromMatrix3(t){const s=t.elements;return this.set(s[0],s[3],s[6],0,s[1],s[4],s[7],0,s[2],s[5],s[8],0,0,0,0,1),this}extractBasis(t,s,e){return 0===this.determinantAffine()?(t.set(1,0,0),s.set(0,1,0),e.set(0,0,1),this):(t.setFromMatrixColumn(this,0),s.setFromMatrixColumn(this,1),e.setFromMatrixColumn(this,2),this)}makeBasis(t,s,e){return this.set(t.x,s.x,e.x,0,t.y,s.y,e.y,0,t.z,s.z,e.z,0,0,0,0,1),this}extractRotation(t){if(0===t.determinantAffine())return this.identity();const s=this.elements,e=t.elements,i=1/v.setFromMatrixColumn(t,0).length(),r=1/v.setFromMatrixColumn(t,1).length(),h=1/v.setFromMatrixColumn(t,2).length();return s[0]=e[0]*i,s[1]=e[1]*i,s[2]=e[2]*i,s[3]=0,s[4]=e[4]*r,s[5]=e[5]*r,s[6]=e[6]*r,s[7]=0,s[8]=e[8]*h,s[9]=e[9]*h,s[10]=e[10]*h,s[11]=0,s[12]=0,s[13]=0,s[14]=0,s[15]=1,this}makeRotationFromEuler(t){const s=this.elements,e=t.x,i=t.y,r=t.z,h=Math.cos(e),n=Math.sin(e),a=Math.cos(i),o=Math.sin(i),u=Math.cos(r),l=Math.sin(r);if("XYZ"===t.order){const t=h*u,e=h*l,i=n*u,r=n*l;s[0]=a*u,s[4]=-a*l,s[8]=o,s[1]=e+i*o,s[5]=t-r*o,s[9]=-n*a,s[2]=r-t*o,s[6]=i+e*o,s[10]=h*a}else if("YXZ"===t.order){const t=a*u,e=a*l,i=o*u,r=o*l;s[0]=t+r*n,s[4]=i*n-e,s[8]=h*o,s[1]=h*l,s[5]=h*u,s[9]=-n,s[2]=e*n-i,s[6]=r+t*n,s[10]=h*a}else if("ZXY"===t.order){const t=a*u,e=a*l,i=o*u,r=o*l;s[0]=t-r*n,s[4]=-h*l,s[8]=i+e*n,s[1]=e+i*n,s[5]=h*u,s[9]=r-t*n,s[2]=-h*o,s[6]=n,s[10]=h*a}else if("ZYX"===t.order){const t=h*u,e=h*l,i=n*u,r=n*l;s[0]=a*u,s[4]=i*o-e,s[8]=t*o+r,s[1]=a*l,s[5]=r*o+t,s[9]=e*o-i,s[2]=-o,s[6]=n*a,s[10]=h*a}else if("YZX"===t.order){const t=h*a,e=h*o,i=n*a,r=n*o;s[0]=a*u,s[4]=r-t*l,s[8]=i*l+e,s[1]=l,s[5]=h*u,s[9]=-n*u,s[2]=-o*u,s[6]=e*l+i,s[10]=t-r*l}else if("XZY"===t.order){const t=h*a,e=h*o,i=n*a,r=n*o;s[0]=a*u,s[4]=-l,s[8]=o*u,s[1]=t*l+r,s[5]=h*u,s[9]=e*l-i,s[2]=i*l-e,s[6]=n*u,s[10]=r*l+t}return s[3]=0,s[7]=0,s[11]=0,s[12]=0,s[13]=0,s[14]=0,s[15]=1,this}makeRotationFromQuaternion(t){return this.compose(A,t,k)}lookAt(t,s,e){const i=this.elements;return Z.subVectors(t,s),0===Z.lengthSq()&&(Z.z=1),Z.normalize(),C.crossVectors(e,Z),0===C.lengthSq()&&(1===Math.abs(e.z)?Z.x+=1e-4:Z.z+=1e-4,Z.normalize(),C.crossVectors(e,Z)),C.normalize(),E.crossVectors(Z,C),i[0]=C.x,i[4]=E.x,i[8]=Z.x,i[1]=C.y,i[5]=E.y,i[9]=Z.y,i[2]=C.z,i[6]=E.z,i[10]=Z.z,this}multiply(t){return this.multiplyMatrices(this,t)}premultiply(t){return this.multiplyMatrices(t,this)}multiplyMatrices(t,s){const e=t.elements,i=s.elements,r=this.elements,h=e[0],n=e[4],a=e[8],o=e[12],u=e[1],l=e[5],c=e[9],x=e[13],y=e[2],m=e[6],d=e[10],M=e[14],z=e[3],f=e[7],p=e[11],w=e[15],_=i[0],g=i[4],b=i[8],v=i[12],S=i[1],A=i[5],k=i[9],C=i[13],E=i[2],Z=i[6],F=i[10],T=i[14],q=i[3],V=i[7],R=i[11],I=i[15];return r[0]=h*_+n*S+a*E+o*q,r[4]=h*g+n*A+a*Z+o*V,r[8]=h*b+n*k+a*F+o*R,r[12]=h*v+n*C+a*T+o*I,r[1]=u*_+l*S+c*E+x*q,r[5]=u*g+l*A+c*Z+x*V,r[9]=u*b+l*k+c*F+x*R,r[13]=u*v+l*C+c*T+x*I,r[2]=y*_+m*S+d*E+M*q,r[6]=y*g+m*A+d*Z+M*V,r[10]=y*b+m*k+d*F+M*R,r[14]=y*v+m*C+d*T+M*I,r[3]=z*_+f*S+p*E+w*q,r[7]=z*g+f*A+p*Z+w*V,r[11]=z*b+f*k+p*F+w*R,r[15]=z*v+f*C+p*T+w*I,this}multiplyScalar(t){const s=this.elements;return s[0]*=t,s[4]*=t,s[8]*=t,s[12]*=t,s[1]*=t,s[5]*=t,s[9]*=t,s[13]*=t,s[2]*=t,s[6]*=t,s[10]*=t,s[14]*=t,s[3]*=t,s[7]*=t,s[11]*=t,s[15]*=t,this}determinant(){const t=this.elements,s=t[0],e=t[4],i=t[8],r=t[12],h=t[1],n=t[5],a=t[9],o=t[13],u=t[2],l=t[6],c=t[10],x=t[14],y=t[3],m=t[7],d=t[11],M=t[15],z=a*x-o*c,f=n*x-o*l,p=n*c-a*l,w=h*x-o*u,_=h*c-a*u,g=h*l-n*u;return s*(m*z-d*f+M*p)-e*(y*z-d*w+M*_)+i*(y*f-m*w+M*g)-r*(y*p-m*_+d*g)}determinantAffine(){const t=this.elements,s=t[0],e=t[4],i=t[8],r=t[1],h=t[5],n=t[9],a=t[2],o=t[6],u=t[10];return s*(h*u-n*o)-e*(r*u-n*a)+i*(r*o-h*a)}transpose(){const t=this.elements;let s;return s=t[1],t[1]=t[4],t[4]=s,s=t[2],t[2]=t[8],t[8]=s,s=t[6],t[6]=t[9],t[9]=s,s=t[3],t[3]=t[12],t[12]=s,s=t[7],t[7]=t[13],t[13]=s,s=t[11],t[11]=t[14],t[14]=s,this}setPosition(t,s,e){const i=this.elements;return t.isVector3?(i[12]=t.x,i[13]=t.y,i[14]=t.z):(i[12]=t,i[13]=s,i[14]=e),this}invert(){const t=this.elements,s=t[0],e=t[1],i=t[2],r=t[3],h=t[4],n=t[5],a=t[6],o=t[7],u=t[8],l=t[9],c=t[10],x=t[11],y=t[12],m=t[13],d=t[14],M=t[15],z=s*n-e*h,f=s*a-i*h,p=s*o-r*h,w=e*a-i*n,_=e*o-r*n,g=i*o-r*a,b=u*m-l*y,v=u*d-c*y,S=u*M-x*y,A=l*d-c*m,k=l*M-x*m,C=c*M-x*d,E=z*C-f*k+p*A+w*S-_*v+g*b;if(0===E)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);const Z=1/E;return t[0]=(n*C-a*k+o*A)*Z,t[1]=(i*k-e*C-r*A)*Z,t[2]=(m*g-d*_+M*w)*Z,t[3]=(c*_-l*g-x*w)*Z,t[4]=(a*S-h*C-o*v)*Z,t[5]=(s*C-i*S+r*v)*Z,t[6]=(d*p-y*g-M*f)*Z,t[7]=(u*g-c*p+x*f)*Z,t[8]=(h*k-n*S+o*b)*Z,t[9]=(e*S-s*k-r*b)*Z,t[10]=(y*_-m*p+M*z)*Z,t[11]=(l*p-u*_-x*z)*Z,t[12]=(n*v-h*A-a*b)*Z,t[13]=(s*A-e*v+i*b)*Z,t[14]=(m*f-y*w-d*z)*Z,t[15]=(u*w-l*f+c*z)*Z,this}scale(t){const s=this.elements,e=t.x,i=t.y,r=t.z;return s[0]*=e,s[4]*=i,s[8]*=r,s[1]*=e,s[5]*=i,s[9]*=r,s[2]*=e,s[6]*=i,s[10]*=r,s[3]*=e,s[7]*=i,s[11]*=r,this}getMaxScaleOnAxis(){const t=this.elements,s=t[0]*t[0]+t[1]*t[1]+t[2]*t[2],e=t[4]*t[4]+t[5]*t[5]+t[6]*t[6],i=t[8]*t[8]+t[9]*t[9]+t[10]*t[10];return Math.sqrt(Math.max(s,e,i))}makeTranslation(t,s,e){return t.isVector3?this.set(1,0,0,t.x,0,1,0,t.y,0,0,1,t.z,0,0,0,1):this.set(1,0,0,t,0,1,0,s,0,0,1,e,0,0,0,1),this}makeRotationX(t){const s=Math.cos(t),e=Math.sin(t);return this.set(1,0,0,0,0,s,-e,0,0,e,s,0,0,0,0,1),this}makeRotationY(t){const s=Math.cos(t),e=Math.sin(t);return this.set(s,0,e,0,0,1,0,0,-e,0,s,0,0,0,0,1),this}makeRotationZ(t){const s=Math.cos(t),e=Math.sin(t);return this.set(s,-e,0,0,e,s,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(t,s){const e=Math.cos(s),i=Math.sin(s),r=1-e,h=t.x,n=t.y,a=t.z,o=r*h,u=r*n;return this.set(o*h+e,o*n-i*a,o*a+i*n,0,o*n+i*a,u*n+e,u*a-i*h,0,o*a-i*n,u*a+i*h,r*a*a+e,0,0,0,0,1),this}makeScale(t,s,e){return this.set(t,0,0,0,0,s,0,0,0,0,e,0,0,0,0,1),this}makeShear(t,s,e,i,r,h){return this.set(1,e,r,0,t,1,h,0,s,i,1,0,0,0,0,1),this}compose(t,s,e){const i=this.elements,r=s._x,h=s._y,n=s._z,a=s._w,o=r+r,u=h+h,l=n+n,c=r*o,x=r*u,y=r*l,m=h*u,d=h*l,M=n*l,z=a*o,f=a*u,p=a*l,w=e.x,_=e.y,g=e.z;return i[0]=(1-(m+M))*w,i[1]=(x+p)*w,i[2]=(y-f)*w,i[3]=0,i[4]=(x-p)*_,i[5]=(1-(c+M))*_,i[6]=(d+z)*_,i[7]=0,i[8]=(y+f)*g,i[9]=(d-z)*g,i[10]=(1-(c+m))*g,i[11]=0,i[12]=t.x,i[13]=t.y,i[14]=t.z,i[15]=1,this}decompose(t,s,e){const i=this.elements;t.x=i[12],t.y=i[13],t.z=i[14];const r=this.determinantAffine();if(0===r)return e.set(1,1,1),s.identity(),this;let h=v.set(i[0],i[1],i[2]).length();const n=v.set(i[4],i[5],i[6]).length(),a=v.set(i[8],i[9],i[10]).length();r<0&&(h=-h),S.copy(this);const o=1/h,u=1/n,l=1/a;return S.elements[0]*=o,S.elements[1]*=o,S.elements[2]*=o,S.elements[4]*=u,S.elements[5]*=u,S.elements[6]*=u,S.elements[8]*=l,S.elements[9]*=l,S.elements[10]*=l,s.setFromRotationMatrix(S),e.x=h,e.y=n,e.z=a,this}makePerspective(s,e,i,r,h,n,a=2e3,o=!1){const u=this.elements,l=2*h/(e-s),c=2*h/(i-r),x=(e+s)/(e-s),y=(i+r)/(i-r);let m,d;if(o)m=h/(n-h),d=n*h/(n-h);else if(a===t)m=-(n+h)/(n-h),d=-2*n*h/(n-h);else{if(2001!==a)throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+a);m=-n/(n-h),d=-n*h/(n-h)}return u[0]=l,u[4]=0,u[8]=x,u[12]=0,u[1]=0,u[5]=c,u[9]=y,u[13]=0,u[2]=0,u[6]=0,u[10]=m,u[14]=d,u[3]=0,u[7]=0,u[11]=-1,u[15]=0,this}makeOrthographic(s,e,i,r,h,n,a=2e3,o=!1){const u=this.elements,l=2/(e-s),c=2/(i-r),x=-(e+s)/(e-s),y=-(i+r)/(i-r);let m,d;if(o)m=1/(n-h),d=n/(n-h);else if(a===t)m=-2/(n-h),d=-(n+h)/(n-h);else{if(2001!==a)throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+a);m=-1/(n-h),d=-h/(n-h)}return u[0]=l,u[4]=0,u[8]=0,u[12]=x,u[1]=0,u[5]=c,u[9]=0,u[13]=y,u[2]=0,u[6]=0,u[10]=m,u[14]=d,u[3]=0,u[7]=0,u[11]=0,u[15]=1,this}equals(t){const s=this.elements,e=t.elements;for(let i=0;i<16;i++)if(s[i]!==e[i])return!1;return!0}fromArray(t,s=0){for(let e=0;e<16;e++)this.elements[e]=t[e+s];return this}toArray(t=[],s=0){const e=this.elements;return t[s]=e[0],t[s+1]=e[1],t[s+2]=e[2],t[s+3]=e[3],t[s+4]=e[4],t[s+5]=e[5],t[s+6]=e[6],t[s+7]=e[7],t[s+8]=e[8],t[s+9]=e[9],t[s+10]=e[10],t[s+11]=e[11],t[s+12]=e[12],t[s+13]=e[13],t[s+14]=e[14],t[s+15]=e[15],t}};g.prototype.isMatrix4=!0;let b=g;const v=new d,S=new b,A=new d(0,0,0),k=new d(1,1,1),C=new d,E=new d,Z=new d,F=class{constructor(t,s,e,i){this.elements=[1,0,0,1],void 0!==t&&this.set(t,s,e,i)}identity(){return this.set(1,0,0,1),this}fromArray(t,s=0){for(let e=0;e<4;e++)this.elements[e]=t[e+s];return this}set(t,s,e,i){const r=this.elements;return r[0]=t,r[2]=s,r[1]=e,r[3]=i,this}};F.prototype.isMatrix2=!0;"undefined"!=typeof __THREE_DEVTOOLS__&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:"185"}})),"undefined"!=typeof window&&(window.__THREE__?e("WARNING: Multiple instances of Three.js being imported."):window.__THREE__="185");(new p).set(-1,0,0,0,1,0,0,0,1);function T(t,s,e){const i=.081819190842622,r=i*i,h=s*(Math.PI/180),n=t*(Math.PI/180),a=6378137/Math.sqrt(1-r*Math.sin(h)**2);return[(a+e)*Math.cos(h)*Math.cos(n),(a+e)*Math.cos(h)*Math.sin(n),((1-r)*a+e)*Math.sin(h)]}function q(t,s,e=2){const i=t.length;let r=function(t,s,e,i,r){let h;if(r===function(t,s,e,i){let r=0;for(let h=s,n=e-i;h<e;h+=i)r+=(t[n]-t[h])*(t[h+1]+t[n+1]),n=h;return r}(t,s,e,i)>0)for(let n=s;n<e;n+=i)h=G(n/i|0,t[n],t[n+1],h);else for(let n=e-i;n>=s;n-=i)h=G(n/i|0,t[n],t[n+1],h);h&&O(h,h.next)&&(J(h),h=h.next);return h}(t,0,i,e,!0);const h=[];if(!r||r.next===r.prev)return h;let n,a,o;if(t.length>80*e){n=1/0,a=1/0;let s=-1/0,r=-1/0;for(let h=e;h<i;h+=e){const e=t[h],i=t[h+1];e<n&&(n=e),i<a&&(a=i),e>s&&(s=e),i>r&&(r=i)}o=Math.max(s-n,r-a),o=0!==o?32767/o:0}return R(r,h,e,n,a,o,0),h}function V(t,s){if(!t)return t;s||(s=t);let e,i=t;do{if(e=!1,i.steiner||!O(i,i.next)&&0!==H(i.prev,i,i.next))i=i.next;else{if(J(i),i=s=i.prev,i===i.next)break;e=!0}}while(e||i!==s);return s}function R(t,s,e,i,r,h,n){if(!t)return;!n&&h&&function(t,s,e,i){let r=t;do{0===r.z&&(r.z=L(r.x,r.y,s,e,i)),r.prevZ=r.prev,r.nextZ=r.next,r=r.next}while(r!==t);r.prevZ.nextZ=null,r.prevZ=null,function(t){let s,e=1;do{let i,r=t;t=null;let h=null;for(s=0;r;){s++;let n=r,a=0;for(let t=0;t<e&&(a++,n=n.nextZ,n);t++);let o=e;for(;a>0||o>0&&n;)0!==a&&(0===o||!n||r.z<=n.z)?(i=r,r=r.nextZ,a--):(i=n,n=n.nextZ,o--),h?h.nextZ=i:t=i,i.prevZ=h,h=i;r=n}h.nextZ=null,e*=2}while(s>1)}(r)}(t,i,r,h);let a=t;for(;t.prev!==t.next;){const o=t.prev,u=t.next;if(h?X(t,i,r,h):I(t))s.push(o.i,t.i,u.i),J(t),t=u.next,a=u.next;else if((t=u)===a){n?1===n?R(t=Y(V(t),s),s,e,i,r,h,2):2===n&&P(t,s,e,i,r,h):R(V(t),s,e,i,r,h,1);break}}}function I(t){const s=t.prev,e=t,i=t.next;if(H(s,e,i)>=0)return!1;const r=s.x,h=e.x,n=i.x,a=s.y,o=e.y,u=i.y,l=Math.min(r,h,n),c=Math.min(a,o,u),x=Math.max(r,h,n),y=Math.max(a,o,u);let m=i.next;for(;m!==s;){if(m.x>=l&&m.x<=x&&m.y>=c&&m.y<=y&&U(r,a,h,o,n,u,m.x,m.y)&&H(m.prev,m,m.next)>=0)return!1;m=m.next}return!0}function X(t,s,e,i){const r=t.prev,h=t,n=t.next;if(H(r,h,n)>=0)return!1;const a=r.x,o=h.x,u=n.x,l=r.y,c=h.y,x=n.y,y=Math.min(a,o,u),m=Math.min(l,c,x),d=Math.max(a,o,u),M=Math.max(l,c,x),z=L(y,m,s,e,i),f=L(d,M,s,e,i);let p=t.prevZ,w=t.nextZ;for(;p&&p.z>=z&&w&&w.z<=f;){if(p.x>=y&&p.x<=d&&p.y>=m&&p.y<=M&&p!==r&&p!==n&&U(a,l,o,c,u,x,p.x,p.y)&&H(p.prev,p,p.next)>=0)return!1;if(p=p.prevZ,w.x>=y&&w.x<=d&&w.y>=m&&w.y<=M&&w!==r&&w!==n&&U(a,l,o,c,u,x,w.x,w.y)&&H(w.prev,w,w.next)>=0)return!1;w=w.nextZ}for(;p&&p.z>=z;){if(p.x>=y&&p.x<=d&&p.y>=m&&p.y<=M&&p!==r&&p!==n&&U(a,l,o,c,u,x,p.x,p.y)&&H(p.prev,p,p.next)>=0)return!1;p=p.prevZ}for(;w&&w.z<=f;){if(w.x>=y&&w.x<=d&&w.y>=m&&w.y<=M&&w!==r&&w!==n&&U(a,l,o,c,u,x,w.x,w.y)&&H(w.prev,w,w.next)>=0)return!1;w=w.nextZ}return!0}function Y(t,s){let e=t;do{const i=e.prev,r=e.next.next;!O(i,r)&&Q(i,e,e.next,r)&&N(i,r)&&N(r,i)&&(s.push(i.i,e.i,r.i),J(e),J(e.next),e=t=r),e=e.next}while(e!==t);return V(e)}function P(t,s,e,i,r,h){let n=t;do{let t=n.next.next;for(;t!==n.prev;){if(n.i!==t.i&&B(n,t)){let a=W(n,t);return n=V(n,n.next),a=V(a,a.next),R(n,s,e,i,r,h,0),void R(a,s,e,i,r,h,0)}t=t.next}n=n.next}while(n!==t)}function L(t,s,e,i,r){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=(t-e)*r|0)|t<<8))|t<<4))|t<<2))|t<<1))|(s=1431655765&((s=858993459&((s=252645135&((s=16711935&((s=(s-i)*r|0)|s<<8))|s<<4))|s<<2))|s<<1))<<1}function U(t,s,e,i,r,h,n,a){return!(t===n&&s===a)&&function(t,s,e,i,r,h,n,a){return(r-n)*(s-a)>=(t-n)*(h-a)&&(t-n)*(i-a)>=(e-n)*(s-a)&&(e-n)*(h-a)>=(r-n)*(i-a)}(t,s,e,i,r,h,n,a)}function B(t,s){return t.next.i!==s.i&&t.prev.i!==s.i&&!function(t,s){let e=t;do{if(e.i!==t.i&&e.next.i!==t.i&&e.i!==s.i&&e.next.i!==s.i&&Q(e,e.next,t,s))return!0;e=e.next}while(e!==t);return!1}(t,s)&&(N(t,s)&&N(s,t)&&function(t,s){let e=t,i=!1;const r=(t.x+s.x)/2,h=(t.y+s.y)/2;do{e.y>h!=e.next.y>h&&e.next.y!==e.y&&r<(e.next.x-e.x)*(h-e.y)/(e.next.y-e.y)+e.x&&(i=!i),e=e.next}while(e!==t);return i}(t,s)&&(H(t.prev,t,s.prev)||H(t,s.prev,s))||O(t,s)&&H(t.prev,t,t.next)>0&&H(s.prev,s,s.next)>0)}function H(t,s,e){return(s.y-t.y)*(e.x-s.x)-(s.x-t.x)*(e.y-s.y)}function O(t,s){return t.x===s.x&&t.y===s.y}function Q(t,s,e,i){const r=j(H(t,s,e)),h=j(H(t,s,i)),n=j(H(e,i,t)),a=j(H(e,i,s));return r!==h&&n!==a||(!(0!==r||!D(t,e,s))||(!(0!==h||!D(t,i,s))||(!(0!==n||!D(e,t,i))||!(0!==a||!D(e,s,i)))))}function D(t,s,e){return s.x<=Math.max(t.x,e.x)&&s.x>=Math.min(t.x,e.x)&&s.y<=Math.max(t.y,e.y)&&s.y>=Math.min(t.y,e.y)}function j(t){return t>0?1:t<0?-1:0}function N(t,s){return H(t.prev,t,t.next)<0?H(t,s,t.next)>=0&&H(t,t.prev,s)>=0:H(t,s,t.prev)<0||H(t,t.next,s)<0}function W(t,s){const e=K(t.i,t.x,t.y),i=K(s.i,s.x,s.y),r=t.next,h=s.prev;return t.next=s,s.prev=t,e.next=r,r.prev=e,i.next=e,e.prev=i,h.next=i,i.prev=h,i}function G(t,s,e,i){const r=K(t,s,e);return i?(r.next=i.next,r.prev=i,i.next.prev=r,i.next=r):(r.prev=r,r.next=r),r}function J(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function K(t,s,e){return{i:t,x:s,y:e,prev:null,next:null,z:0,prevZ:null,nextZ:null,steiner:!1}}function $(t){return 255*(t=(t/=255)<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4))}function tt(t){const{geometry:s}=t,e=(new d).fromArray(T(...s.coordinates[0])),i=(new d).fromArray(T(...s.coordinates[1])),r=function(t,s){const e=c.degToRad(t),i=c.degToRad(s);return new d(Math.cos(i)*Math.cos(e),Math.cos(i)*Math.sin(e),Math.sin(i)).normalize()}(s.coordinates[0][0],s.coordinates[0][1]),h=(new d).subVectors(i,e),n=h.length(),a=h.clone().normalize(),o=(new d).crossVectors(r,a).normalize().multiplyScalar(10),u=e.clone(),l=i.clone(),x=u.clone().add(a.clone().multiplyScalar(n*(1-100/n))),y=u.clone().add(o),m=u.clone().sub(o),M=x.clone().add(o.clone()),z=x.clone().sub(o.clone()),f=x.clone().add(o.clone().multiplyScalar(4)),p=x.clone().sub(o.clone().multiplyScalar(4)),w=l;return{meshVertexBuffer:new Float32Array([...y.toArray(),...m.toArray(),...M.toArray(),...M.toArray(),...m.toArray(),...z.toArray(),...f.toArray(),...p.toArray(),...w.toArray()])}}(new p).set(-1,0,0,0,1,0,0,0,1),self.addEventListener("message",(async t=>{const{type:s,data:e,color:i}=t.data;let r={};switch(s){case"arrow":r=tt(e),self.postMessage({success:!0,code:0,...r});break;case"perimeter":r=function(t,s){const e=t.geometry.coordinates[0],i=[(r=s)>>16&255,r>>8&255,255&r];var r;i[0]=$(i[0]),i[1]=$(i[1]),i[2]=$(i[2]);const h=q(e.flat(),0,e[0].length);for(let l=0;l<e.length;l++)e[l][2]||(e[l][2]=0);const n=[],a=[],o=[],u=[];for(let l=0;l<e.length;l++){const[t,s,r]=e[l],h=T(t,s,r);n.push(...h),u.push(...i),o.push(...h),a.push(...i),l>0&&(o.push(...h),a.push(...i))}return{lineVertexBuffer:new Float32Array(o),lineVertexRGBBuffer:new Uint8Array(a),meshVertexBuffer:new Float32Array(n),meshVertexRGBBuffer:new Uint8Array(u),meshIndexBuffer:new Uint16Array(h.flat())}}(e,i),self.postMessage({success:!0,code:0,...r})}}))}();