glmaths 0.0.3 → 0.0.4
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/README.md +561 -543
- package/dist/cjs/glmaths.d.ts +240 -198
- package/dist/cjs/glmaths.js +544 -462
- package/dist/cjs/glmaths.js.map +1 -1
- package/dist/cjs/glmaths.min.js +1 -1
- package/dist/cjs/glmaths.min.js.map +1 -1
- package/dist/esm/glmaths.d.ts +240 -198
- package/dist/esm/glmaths.js +544 -462
- package/dist/esm/glmaths.js.map +1 -1
- package/dist/esm/glmaths.min.js +1 -1
- package/dist/esm/glmaths.min.js.map +1 -1
- package/dist/glmaths.d.ts +240 -198
- package/dist/glmaths.js +544 -462
- package/dist/glmaths.js.map +1 -1
- package/dist/glmaths.min.js +1 -1
- package/dist/glmaths.min.js.map +1 -1
- package/examples/index.html +23 -0
- package/examples/main.js +134 -0
- package/examples/main.ts +159 -0
- package/package.json +1 -1
- package/src/mat2.ts +27 -27
- package/src/mat2x3.ts +37 -31
- package/src/mat3.ts +53 -54
- package/src/mat4.ts +81 -82
- package/src/quat.ts +36 -23
- package/src/quat2.ts +45 -31
- package/src/vec2.ts +90 -70
- package/src/vec3.ts +143 -121
- package/src/vec4.ts +79 -57
- package/tests/mat2.test.ts +53 -53
- package/tests/mat2x3.test.ts +46 -46
- package/tests/mat3.test.ts +59 -59
package/dist/esm/glmaths.min.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
class t extends Float32Array{static get zero(){return new t(0,0,0)}static get Zero(){return new t(0,0,0)}static get ZERO(){return new t(0,0,0)}static get one(){return new t(1,1,1)}static get One(){return new t(1,1,1)}static get ONE(){return new t(1,1,1)}static get unitX(){return new t(1,0,0)}static get UnitX(){return new t(1,0,0)}static get unitY(){return new t(0,1,0)}static get UnitY(){return new t(0,1,0)}static get unitZ(){return new t(0,0,1)}static get UnitZ(){return new t(0,0,1)}constructor(t=0,s=0,i=0){super(3),this[0]=t,this[1]=s,this[2]=i}get x(){return this[0]}set x(t){this[0]=t}get y(){return this[1]}set y(t){this[1]=t}get z(){return this[2]}set z(t){this[2]=t}plus(s,i=(U.ALWAYS_COPY?new t:this)){return"number"==typeof s?(i[0]=this[0]+s,i[1]=this[1]+s,i[2]=this[2]+s):(i[0]=this[0]+s[0],i[1]=this[1]+s[1],i[2]=this[2]+s[2]),i}minus(s,i=(U.ALWAYS_COPY?new t:this)){return"number"==typeof s?(i[0]=this[0]-s,i[1]=this[1]-s,i[2]=this[2]-s):(i[0]=this[0]-s[0],i[1]=this[1]-s[1],i[2]=this[2]-s[2]),i}mult(s,i=(U.ALWAYS_COPY?new t:this)){return"number"==typeof s?(i[0]=this[0]*s,i[1]=this[1]*s,i[2]=this[2]*s):(i[0]=this[0]*s[0],i[1]=this[1]*s[1],i[2]=this[2]*s[2]),i}div(s,i=(U.ALWAYS_COPY?new t:this)){return"number"==typeof s?(i[0]=this[0]/s,i[1]=this[1]/s,i[2]=this[2]/s):(i[0]=this[0]/s[0],i[1]=this[1]/s[1],i[2]=this[2]/s[2]),i}invDiv(s,i=(U.ALWAYS_COPY?new t:this)){return"number"==typeof s?(i[0]=s/this[0],i[1]=s/this[1],i[2]=s/this[2]):(i[0]=s[0]/this[0],i[1]=s[1]/this[1],i[2]=s[2]/this[2]),i}negate(s=(U.ALWAYS_COPY?new t:this)){return s[0]=-this[0],s[1]=-this[1],s[2]=-this[2],s}unaryPlus(s=(U.ALWAYS_COPY?new t:this)){return s.equals(this)||(s[0]=this[0],s[1]=this[1],s[2]=this[2]),s}static normalize(s,i=new t){const h=s[0],e=s[1],r=s[2];let n=h*h+e*e+r*r;return n>0&&(n=1/Math.sqrt(n)),i[0]=h*n,i[1]=e*n,i[2]=r*n,i}normalize(s=(U.ALWAYS_COPY?new t:this)){const i=this[0],h=this[1],e=this[2];let r=i*i+h*h+e*e;return r>0&&(r=1/Math.sqrt(r)),s[0]=i*r,s[1]=h*r,s[2]=e*r,s}equals(t){return n(this[0],t[0])&&n(this[1],t[1])&&n(this[2],t[2])}exactEquals(t){return this[0]===t[0]&&this[1]===t[1]&&this[2]===t[2]}squaredLength(){const t=this[0],s=this[1],i=this[2];return t*t+s*s+i*i}len(){const t=this[0],s=this[1],i=this[2];return Math.sqrt(t*t+s*s+i*i)}static floor(s,i=new t){return i[0]=Math.floor(s[0]),i[1]=Math.floor(s[1]),i[2]=Math.floor(s[2]),i}static round(s,i=new t){return i[0]=Math.round(s[0]),i[1]=Math.round(s[1]),i[2]=Math.round(s[2]),i}static ceil(s,i=new t){return i[0]=Math.ceil(s[0]),i[1]=Math.ceil(s[1]),i[2]=Math.ceil(s[2]),i}floor(s=(U.ALWAYS_COPY?new t:this)){return s[0]=Math.floor(this[0]),s[1]=Math.floor(this[1]),s[2]=Math.floor(this[2]),s}round(s=(U.ALWAYS_COPY?new t:this)){return s[0]=Math.round(this[0]),s[1]=Math.round(this[1]),s[2]=Math.round(this[2]),s}ceil(s=(U.ALWAYS_COPY?new t:this)){return s[0]=Math.ceil(this[0]),s[1]=Math.ceil(this[1]),s[2]=Math.ceil(this[2]),s}static inverse(s,i=new t){return i[0]=1/s[0],i[1]=1/s[1],i[2]=1/s[2],i}inverse(s=(U.ALWAYS_COPY?new t:this)){return s[0]=1/this[0],s[1]=1/this[1],s[2]=1/this[2],s}clone(){return new t(this[0],this[1],this[2])}toString(){return`vec3(${this[0]}, ${this[1]}, ${this[2]})`}static random(s=1){const i=2*U.RANDOM()*Math.PI,h=2*U.RANDOM()-1,e=Math.sqrt(1-h*h)*s;return new t(Math.cos(i)*e,Math.sin(i)*e,h*s)}static angle(s,i){const h=s[0],e=s[1],r=s[2],n=i[0],o=i[1],a=i[2],u=Math.sqrt((h*h+e*e+r*r)*(n*n+o*o+a*a)),c=u&&t.dot(s,i)/u;return Math.acos(Math.min(Math.max(c,-1),1))}static dot(t,s){return t[0]*s[0]+t[1]*s[1]+t[2]*s[2]}static cross(s,i,h=new t){const e=s[0],r=s[1],n=s[2],o=i[0],a=i[1],u=i[2];return h[0]=r*u-n*a,h[1]=n*o-e*u,h[2]=e*a-r*o,h}static distance(t,s){const i=t[0]-s[0],h=t[1]-s[1],e=t[2]-s[2];return Math.sqrt(i*i+h*h+e*e)}static squaredDistance(t,s){const i=t[0]-s[0],h=t[1]-s[1],e=t[2]-s[2];return i*i+h*h+e*e}static lerp(s,i,h,e=new t){const r=s[0],n=s[1],o=s[2];return e[0]=r+(i[0]-r)*h,e[1]=n+(i[1]-n)*h,e[2]=o+(i[2]-o)*h,e}static slerp(s,i,h,e=new t){const r=Math.acos(Math.min(Math.max(t.dot(s,i),-1),1)),n=Math.sin(r),o=Math.sin((1-h)*r)/n,a=Math.sin(h*r)/n;return e[0]=o*s[0]+a*i[0],e[1]=o*s[1]+a*i[1],e[2]=o*s[2]+a*i[2],e}static max(s,i,h=new t){return h[0]=Math.max(s[0],i[0]),h[1]=Math.max(s[1],i[1]),h[2]=Math.max(s[2],i[2]),h}static min(s,i,h=new t){return h[0]=Math.min(s[0],i[0]),h[1]=Math.min(s[1],i[1]),h[2]=Math.min(s[2],i[2]),h}static clamp(s,i,h,e=new t){const r="number"==typeof i?i:i[1],n="number"==typeof i?i:i[2],o="number"==typeof h?h:h[0],a="number"==typeof h?h:h[1],u="number"==typeof h?h:h[2];return e[0]=Math.min(Math.max(s[0],"number"==typeof i?i:i[0]),o),e[1]=Math.min(Math.max(s[1],r),a),e[2]=Math.min(Math.max(s[2],n),u),e}static mix(s,i,h,e=new t){return"number"==typeof h?(e[0]=s[0]+(i[0]-s[0])*h,e[1]=s[1]+(i[1]-s[1])*h,e[2]=s[2]+(i[2]-s[2])*h):(e[0]=s[0]+(i[0]-s[0])*h[0],e[1]=s[1]+(i[1]-s[1])*h[1],e[2]=s[2]+(i[2]-s[2])*h[2]),e}static smoothstep(s,i,h,e=new t){const r="number"==typeof s?s:s[0],n="number"==typeof s?s:s[1],o="number"==typeof s?s:s[2],a="number"==typeof i?i:i[1],u="number"==typeof i?i:i[2];let c=Math.min(Math.max((h[0]-r)/(("number"==typeof i?i:i[0])-r),0),1),p=Math.min(Math.max((h[1]-n)/(a-n),0),1),l=Math.min(Math.max((h[2]-o)/(u-o),0),1);return e[0]=c*c*(3-2*c),e[1]=p*p*(3-2*p),e[2]=l*l*(3-2*l),e}static rotateX(s,i,h=t.zero,e=new t){const r=s[1]-h[1],n=s[2]-h[2];return e[0]=s[0],e[1]=r*Math.cos(i)-n*Math.sin(i)+h[1],e[2]=r*Math.sin(i)+n*Math.cos(i)+h[2],e}rotateX(s,i=t.zero,h=(U.ALWAYS_COPY?new t:this)){const e=this[1]-i[1],r=this[2]-i[2];return h[0]=this[0],h[1]=e*Math.cos(s)-r*Math.sin(s)+i[1],h[2]=e*Math.sin(s)+r*Math.cos(s)+i[2],h}static rotateY(s,i,h=t.zero,e=new t){const r=s[0]-h[0],n=s[2]-h[2];return e[0]=n*Math.sin(i)+r*Math.cos(i)+h[0],e[1]=s[1],e[2]=n*Math.cos(i)-r*Math.sin(i)+h[2],e}rotateY(s,i=t.zero,h=(U.ALWAYS_COPY?new t:this)){const e=this[0]-i[0],r=this[2]-i[2];return h[0]=r*Math.sin(s)+e*Math.cos(s)+i[0],h[1]=this[1],h[2]=r*Math.cos(s)-e*Math.sin(s)+i[2],h}static rotateZ(s,i,h=t.zero,e=new t){const r=s[0]-h[0],n=s[1]-h[1];return e[0]=r*Math.cos(i)-n*Math.sin(i)+h[0],e[1]=r*Math.sin(i)+n*Math.cos(i)+h[1],e[2]=s[2],e}rotateZ(s,i=t.zero,h=(U.ALWAYS_COPY?new t:this)){const e=this[0]-i[0],r=this[1]-i[1];return h[0]=e*Math.cos(s)-r*Math.sin(s)+i[0],h[1]=e*Math.sin(s)+r*Math.cos(s)+i[1],h[2]=this[2],h}static hermite(s,i,h,e,r,n=new t){const o=r*r,a=o*(2*r-3)+1,u=o*(r-2)+r,c=o*(r-1),p=o*(3-2*r);return n[0]=s[0]*a+i[0]*u+h[0]*c+e[0]*p,n[1]=s[1]*a+i[1]*u+h[1]*c+e[1]*p,n[2]=s[2]*a+i[2]*u+h[2]*c+e[2]*p,n}static bezier(s,i,h,e,r,n=new t){const o=1-r,a=o*o,u=r*r,c=a*o,p=3*r*a,l=3*u*o,m=u*r;return n[0]=s[0]*c+i[0]*p+h[0]*l+e[0]*m,n[1]=s[1]*c+i[1]*p+h[1]*l+e[1]*m,n[2]=s[2]*c+i[2]*p+h[2]*l+e[2]*m,n}static scaleAndAdd(s,i,h,e=new t){return e[0]=s[0]+i[0]*h,e[1]=s[1]+i[1]*h,e[2]=s[2]+i[2]*h,e}static reflect(s,i,h=new t){const e=2*t.dot(i,s);return h[0]=s[0]-e*i[0],h[1]=s[1]-e*i[1],h[2]=s[2]-e*i[2],h}static refract(s,i,h,e=new t){const r=t.dot(i,s),n=1-h*h*(1-r*r);if(n<0)return e[0]=e[1]=e[2]=0,e;const o=h*r+Math.sqrt(n);return e[0]=h*s[0]-o*i[0],e[1]=h*s[1]-o*i[1],e[2]=h*s[2]-o*i[2],e}static faceforward(s,i,h,e=new t){const r=t.dot(h,i)<0?1:-1;return e[0]=s[0]*r,e[1]=s[1]*r,e[2]=s[2]*r,e}static triangleNormal(s,i,h,e=new t){const r=i[0]-s[0],n=i[1]-s[1],o=i[2]-s[2],a=h[0]-s[0],u=h[1]-s[1],c=h[2]-s[2];e[0]=n*c-o*u,e[1]=o*a-r*c,e[2]=r*u-n*a;let p=e[0]*e[0]+e[1]*e[1]+e[2]*e[2];return p>0&&(p=1/Math.sqrt(p),e[0]*=p,e[1]*=p,e[2]*=p),e}static project(s,i,h=new t){const e=t.dot(s,i)/t.dot(i,i);return h[0]=i[0]*e,h[1]=i[1]*e,h[2]=i[2]*e,h}static orientedAngle(s,i,h){const e=t.cross(s,i),r=Math.atan2(e.len(),t.dot(s,i));return t.dot(e,h)<0?-r:r}scaleAndAdd(s,i,h=(U.ALWAYS_COPY?new t:this)){return h[0]=this[0]+s[0]*i,h[1]=this[1]+s[1]*i,h[2]=this[2]+s[2]*i,h}abs(s=(U.ALWAYS_COPY?new t:this)){return s[0]=Math.abs(this[0]),s[1]=Math.abs(this[1]),s[2]=Math.abs(this[2]),s}clamp(s,i,h=(U.ALWAYS_COPY?new t:this)){const e="number"==typeof s?s:s[1],r="number"==typeof s?s:s[2],n="number"==typeof i?i:i[0],o="number"==typeof i?i:i[1],a="number"==typeof i?i:i[2];return h[0]=Math.min(Math.max(this[0],"number"==typeof s?s:s[0]),n),h[1]=Math.min(Math.max(this[1],e),o),h[2]=Math.min(Math.max(this[2],r),a),h}mix(s,i,h=(U.ALWAYS_COPY?new t:this)){return"number"==typeof i?(h[0]=this[0]+(s[0]-this[0])*i,h[1]=this[1]+(s[1]-this[1])*i,h[2]=this[2]+(s[2]-this[2])*i):(h[0]=this[0]+(s[0]-this[0])*i[0],h[1]=this[1]+(s[1]-this[1])*i[1],h[2]=this[2]+(s[2]-this[2])*i[2]),h}step(s,i=(U.ALWAYS_COPY?new t:this)){return"number"==typeof s?(i[0]=this[0]<s?0:1,i[1]=this[1]<s?0:1,i[2]=this[2]<s?0:1):(i[0]=this[0]<s[0]?0:1,i[1]=this[1]<s[1]?0:1,i[2]=this[2]<s[2]?0:1),i}smoothstep(s,i,h=(U.ALWAYS_COPY?new t:this)){const e="number"==typeof s?s:s[0],r="number"==typeof s?s:s[1],n="number"==typeof s?s:s[2],o="number"==typeof i?i:i[1],a="number"==typeof i?i:i[2];let u=Math.min(Math.max((this[0]-e)/(("number"==typeof i?i:i[0])-e),0),1),c=Math.min(Math.max((this[1]-r)/(o-r),0),1),p=Math.min(Math.max((this[2]-n)/(a-n),0),1);return h[0]=u*u*(3-2*u),h[1]=c*c*(3-2*c),h[2]=p*p*(3-2*p),h}fract(s=(U.ALWAYS_COPY?new t:this)){return s[0]=this[0]-Math.floor(this[0]),s[1]=this[1]-Math.floor(this[1]),s[2]=this[2]-Math.floor(this[2]),s}sign(s=(U.ALWAYS_COPY?new t:this)){return s[0]=this[0]>0?1:this[0]<0?-1:0,s[1]=this[1]>0?1:this[1]<0?-1:0,s[2]=this[2]>0?1:this[2]<0?-1:0,s}saturate(s=(U.ALWAYS_COPY?new t:this)){return s[0]=Math.min(Math.max(this[0],0),1),s[1]=Math.min(Math.max(this[1],0),1),s[2]=Math.min(Math.max(this[2],0),1),s}transformMat3(s,i=(U.ALWAYS_COPY?new t:this)){const h=this[0],e=this[1],r=this[2];return i[0]=h*s[0]+e*s[3]+r*s[6],i[1]=h*s[1]+e*s[4]+r*s[7],i[2]=h*s[2]+e*s[5]+r*s[8],i}transformMat4(s,i=(U.ALWAYS_COPY?new t:this)){const h=this[0],e=this[1],r=this[2];let n=s[3]*h+s[7]*e+s[11]*r+s[15];return n=n||1,i[0]=(s[0]*h+s[4]*e+s[8]*r+s[12])/n,i[1]=(s[1]*h+s[5]*e+s[9]*r+s[13])/n,i[2]=(s[2]*h+s[6]*e+s[10]*r+s[14])/n,i}transformQuat(s,i=(U.ALWAYS_COPY?new t:this)){const h=s[0],e=s[1],r=s[2],n=this[0],o=this[1],a=this[2];let u=e*a-r*o,c=r*n-h*a,p=h*o-e*n,l=e*p-r*c,m=r*u-h*p,M=h*c-e*u;const y=2*s[3];return u*=y,c*=y,p*=y,l*=2,m*=2,M*=2,i[0]=n+u+l,i[1]=o+c+m,i[2]=a+p+M,i}}o(t.prototype,3),t.dist=t.distance,t.sqrDist=t.squaredDistance,t.prototype.add=t.prototype.plus,t.prototype.sub=t.prototype.minus,t.prototype.subtract=t.prototype.minus,t.prototype.mul=t.prototype.mult,t.prototype.scale=t.prototype.mult,t.prototype.multiply=t.prototype.mult,t.prototype.times=t.prototype.mult,t.prototype.divide=t.prototype.div,t.prototype.neg=t.prototype.negate,t.prototype.unaryMinus=t.prototype.negate,t.prototype.sqrLen=t.prototype.squaredLength,t.prototype.str=t.prototype.toString,t.prototype.transformMat3x3=t.prototype.transformMat3,t.prototype.transformMat4x4=t.prototype.transformMat4;const s=(...s)=>{const i=new t;let h=0;for(const t of s)if("number"==typeof t)i[h++]=t;else for(const s of t)i[h++]=s;return 1==h&&(i[1]=i[2]=i[0]),i};Object.setPrototypeOf(s,t);const i=s;class h extends Float32Array{static get zero(){return new h(0,0,0,0)}static get Zero(){return new h(0,0,0,0)}static get ZERO(){return new h(0,0,0,0)}static get one(){return new h(1,1,1,1)}static get One(){return new h(1,1,1,1)}static get ONE(){return new h(1,1,1,1)}constructor(t=0,s=0,i=0,h=0){super(4),this[0]=t,this[1]=s,this[2]=i,this[3]=h}get x(){return this[0]}set x(t){this[0]=t}get y(){return this[1]}set y(t){this[1]=t}get z(){return this[2]}set z(t){this[2]=t}get w(){return this[3]}set w(t){this[3]=t}plus(t,s=(U.ALWAYS_COPY?new h:this)){return"number"==typeof t?(s[0]=this[0]+t,s[1]=this[1]+t,s[2]=this[2]+t,s[3]=this[3]+t):(s[0]=this[0]+t[0],s[1]=this[1]+t[1],s[2]=this[2]+t[2],s[3]=this[3]+t[3]),s}minus(t,s=(U.ALWAYS_COPY?new h:this)){return"number"==typeof t?(s[0]=this[0]-t,s[1]=this[1]-t,s[2]=this[2]-t,s[3]=this[3]-t):(s[0]=this[0]-t[0],s[1]=this[1]-t[1],s[2]=this[2]-t[2],s[3]=this[3]-t[3]),s}mult(t,s=(U.ALWAYS_COPY?new h:this)){return"number"==typeof t?(s[0]=this[0]*t,s[1]=this[1]*t,s[2]=this[2]*t,s[3]=this[3]*t):(s[0]=this[0]*t[0],s[1]=this[1]*t[1],s[2]=this[2]*t[2],s[3]=this[3]*t[3]),s}div(t,s=(U.ALWAYS_COPY?new h:this)){return"number"==typeof t?(s[0]=this[0]/t,s[1]=this[1]/t,s[2]=this[2]/t,s[3]=this[3]/t):(s[0]=this[0]/t[0],s[1]=this[1]/t[1],s[2]=this[2]/t[2],s[3]=this[3]/t[3]),s}invDiv(t,s=(U.ALWAYS_COPY?new h:this)){return"number"==typeof t?(s[0]=t/this[0],s[1]=t/this[1],s[2]=t/this[2],s[3]=t/this[3]):(s[0]=t[0]/this[0],s[1]=t[1]/this[1],s[2]=t[2]/this[2],s[3]=t[3]/this[3]),s}negate(t=(U.ALWAYS_COPY?new h:this)){return t[0]=-this[0],t[1]=-this[1],t[2]=-this[2],t[3]=-this[3],t}unaryPlus(t=(U.ALWAYS_COPY?new h:this)){return t.equals(this)||(t[0]=this[0],t[1]=this[1],t[2]=this[2],t[3]=this[3]),t}normalize(t=(U.ALWAYS_COPY?new h:this)){const s=this[0],i=this[1],e=this[2],r=this[3];let n=s*s+i*i+e*e+r*r;return n>0&&(n=1/Math.sqrt(n)),t[0]=s*n,t[1]=i*n,t[2]=e*n,t[3]=r*n,t}equals(t){return n(this[0],t[0])&&n(this[1],t[1])&&n(this[2],t[2])&&n(this[3],t[3])}exactEquals(t){return this[0]===t[0]&&this[1]===t[1]&&this[2]===t[2]&&this[3]===t[3]}squaredLength(){const t=this[0],s=this[1],i=this[2],h=this[3];return t*t+s*s+i*i+h*h}len(){const t=this[0],s=this[1],i=this[2],h=this[3];return Math.sqrt(t*t+s*s+i*i+h*h)}floor(t=(U.ALWAYS_COPY?new h:this)){return t[0]=Math.floor(this[0]),t[1]=Math.floor(this[1]),t[2]=Math.floor(this[2]),t[3]=Math.floor(this[3]),t}round(t=(U.ALWAYS_COPY?new h:this)){return t[0]=Math.round(this[0]),t[1]=Math.round(this[1]),t[2]=Math.round(this[2]),t[3]=Math.round(this[3]),t}ceil(t=(U.ALWAYS_COPY?new h:this)){return t[0]=Math.ceil(this[0]),t[1]=Math.ceil(this[1]),t[2]=Math.ceil(this[2]),t[3]=Math.ceil(this[3]),t}inverse(t=(U.ALWAYS_COPY?new h:this)){return t[0]=1/this[0],t[1]=1/this[1],t[2]=1/this[2],t[3]=1/this[3],t}clone(){return new h(this[0],this[1],this[2],this[3])}toString(){return`vec4(${this[0]}, ${this[1]}, ${this[2]}, ${this[3]})`}static random(t=1,s=new h){let i,e,r,n,o,a,u;u=U.RANDOM(),i=2*u-1,e=(4*U.RANDOM()-2)*Math.sqrt(u*-u+u),o=i*i+e*e,u=U.RANDOM(),r=2*u-1,n=(4*U.RANDOM()-2)*Math.sqrt(u*-u+u),a=r*r+n*n;const c=Math.sqrt((1-o)/a);return s[0]=t*i,s[1]=t*e,s[2]=t*r*c,s[3]=t*n*c,s}static dot(t,s){return t[0]*s[0]+t[1]*s[1]+t[2]*s[2]+t[3]*s[3]}static cross(t,s,i,e=new h){const r=s[0]*i[1]-s[1]*i[0],n=s[0]*i[2]-s[2]*i[0],o=s[0]*i[3]-s[3]*i[0],a=s[1]*i[2]-s[2]*i[1],u=s[1]*i[3]-s[3]*i[1],c=s[2]*i[3]-s[3]*i[2],p=t[0],l=t[1],m=t[2],M=t[3];return e[0]=l*c-m*u+M*a,e[1]=-p*c+m*o-M*n,e[2]=p*u-l*o+M*r,e[3]=-p*a+l*n-m*r,e}static distance(t,s){const i=t[0]-s[0],h=t[1]-s[1],e=t[2]-s[2],r=t[3]-s[3];return Math.sqrt(i*i+h*h+e*e+r*r)}static squaredDistance(t,s){const i=t[0]-s[0],h=t[1]-s[1],e=t[2]-s[2],r=t[3]-s[3];return i*i+h*h+e*e+r*r}static lerp(t,s,i,e=new h){const r=t[0],n=t[1],o=t[2],a=t[3];return e[0]=r+(s[0]-r)*i,e[1]=n+(s[1]-n)*i,e[2]=o+(s[2]-o)*i,e[3]=a+(s[3]-a)*i,e}static max(t,s,i=new h){return i[0]=Math.max(t[0],s[0]),i[1]=Math.max(t[1],s[1]),i[2]=Math.max(t[2],s[2]),i[3]=Math.max(t[3],s[3]),i}static min(t,s,i=new h){return i[0]=Math.min(t[0],s[0]),i[1]=Math.min(t[1],s[1]),i[2]=Math.min(t[2],s[2]),i[3]=Math.min(t[3],s[3]),i}static clamp(t,s,i,e=new h){const r="number"==typeof s?s:s[1],n="number"==typeof s?s:s[2],o="number"==typeof s?s:s[3],a="number"==typeof i?i:i[0],u="number"==typeof i?i:i[1],c="number"==typeof i?i:i[2],p="number"==typeof i?i:i[3];return e[0]=Math.min(Math.max(t[0],"number"==typeof s?s:s[0]),a),e[1]=Math.min(Math.max(t[1],r),u),e[2]=Math.min(Math.max(t[2],n),c),e[3]=Math.min(Math.max(t[3],o),p),e}static mix(t,s,i,e=new h){return"number"==typeof i?(e[0]=t[0]+(s[0]-t[0])*i,e[1]=t[1]+(s[1]-t[1])*i,e[2]=t[2]+(s[2]-t[2])*i,e[3]=t[3]+(s[3]-t[3])*i):(e[0]=t[0]+(s[0]-t[0])*i[0],e[1]=t[1]+(s[1]-t[1])*i[1],e[2]=t[2]+(s[2]-t[2])*i[2],e[3]=t[3]+(s[3]-t[3])*i[3]),e}static smoothstep(t,s,i,e=new h){const r="number"==typeof t?t:t[0],n="number"==typeof t?t:t[1],o="number"==typeof t?t:t[2],a="number"==typeof t?t:t[3],u="number"==typeof s?s:s[1],c="number"==typeof s?s:s[2],p="number"==typeof s?s:s[3];let l=Math.min(Math.max((i[0]-r)/(("number"==typeof s?s:s[0])-r),0),1),m=Math.min(Math.max((i[1]-n)/(u-n),0),1),M=Math.min(Math.max((i[2]-o)/(c-o),0),1),y=Math.min(Math.max((i[3]-a)/(p-a),0),1);return e[0]=l*l*(3-2*l),e[1]=m*m*(3-2*m),e[2]=M*M*(3-2*M),e[3]=y*y*(3-2*y),e}scaleAndAdd(t,s,i=(U.ALWAYS_COPY?new h:this)){return i[0]=this[0]+t[0]*s,i[1]=this[1]+t[1]*s,i[2]=this[2]+t[2]*s,i[3]=this[3]+t[3]*s,i}abs(t=(U.ALWAYS_COPY?new h:this)){return t[0]=Math.abs(this[0]),t[1]=Math.abs(this[1]),t[2]=Math.abs(this[2]),t[3]=Math.abs(this[3]),t}clamp(t,s,i=(U.ALWAYS_COPY?new h:this)){const e="number"==typeof t?t:t[1],r="number"==typeof t?t:t[2],n="number"==typeof t?t:t[3],o="number"==typeof s?s:s[0],a="number"==typeof s?s:s[1],u="number"==typeof s?s:s[2],c="number"==typeof s?s:s[3];return i[0]=Math.min(Math.max(this[0],"number"==typeof t?t:t[0]),o),i[1]=Math.min(Math.max(this[1],e),a),i[2]=Math.min(Math.max(this[2],r),u),i[3]=Math.min(Math.max(this[3],n),c),i}mix(t,s,i=(U.ALWAYS_COPY?new h:this)){return"number"==typeof s?(i[0]=this[0]+(t[0]-this[0])*s,i[1]=this[1]+(t[1]-this[1])*s,i[2]=this[2]+(t[2]-this[2])*s,i[3]=this[3]+(t[3]-this[3])*s):(i[0]=this[0]+(t[0]-this[0])*s[0],i[1]=this[1]+(t[1]-this[1])*s[1],i[2]=this[2]+(t[2]-this[2])*s[2],i[3]=this[3]+(t[3]-this[3])*s[3]),i}step(t,s=(U.ALWAYS_COPY?new h:this)){return"number"==typeof t?(s[0]=this[0]<t?0:1,s[1]=this[1]<t?0:1,s[2]=this[2]<t?0:1,s[3]=this[3]<t?0:1):(s[0]=this[0]<t[0]?0:1,s[1]=this[1]<t[1]?0:1,s[2]=this[2]<t[2]?0:1,s[3]=this[3]<t[3]?0:1),s}smoothstep(t,s,i=(U.ALWAYS_COPY?new h:this)){const e="number"==typeof t?t:t[0],r="number"==typeof t?t:t[1],n="number"==typeof t?t:t[2],o="number"==typeof t?t:t[3],a="number"==typeof s?s:s[1],u="number"==typeof s?s:s[2],c="number"==typeof s?s:s[3];let p=Math.min(Math.max((this[0]-e)/(("number"==typeof s?s:s[0])-e),0),1),l=Math.min(Math.max((this[1]-r)/(a-r),0),1),m=Math.min(Math.max((this[2]-n)/(u-n),0),1),M=Math.min(Math.max((this[3]-o)/(c-o),0),1);return i[0]=p*p*(3-2*p),i[1]=l*l*(3-2*l),i[2]=m*m*(3-2*m),i[3]=M*M*(3-2*M),i}fract(t=(U.ALWAYS_COPY?new h:this)){return t[0]=this[0]-Math.floor(this[0]),t[1]=this[1]-Math.floor(this[1]),t[2]=this[2]-Math.floor(this[2]),t[3]=this[3]-Math.floor(this[3]),t}sign(t=(U.ALWAYS_COPY?new h:this)){return t[0]=this[0]>0?1:this[0]<0?-1:0,t[1]=this[1]>0?1:this[1]<0?-1:0,t[2]=this[2]>0?1:this[2]<0?-1:0,t[3]=this[3]>0?1:this[3]<0?-1:0,t}saturate(t=(U.ALWAYS_COPY?new h:this)){return t[0]=Math.min(Math.max(this[0],0),1),t[1]=Math.min(Math.max(this[1],0),1),t[2]=Math.min(Math.max(this[2],0),1),t[3]=Math.min(Math.max(this[3],0),1),t}transformMat4(t,s=(U.ALWAYS_COPY?new h:this)){const i=this[0],e=this[1],r=this[2],n=this[3];return s[0]=t[0]*i+t[4]*e+t[8]*r+t[12]*n,s[1]=t[1]*i+t[5]*e+t[9]*r+t[13]*n,s[2]=t[2]*i+t[6]*e+t[10]*r+t[14]*n,s[3]=t[3]*i+t[7]*e+t[11]*r+t[15]*n,s}transformQuat(t,s=(U.ALWAYS_COPY?new h:this)){const i=t[0],e=t[1],r=t[2],n=this[0],o=this[1],a=this[2];let u=e*a-r*o,c=r*n-i*a,p=i*o-e*n,l=e*p-r*c,m=r*u-i*p,M=i*c-e*u;const y=2*t[3];return u*=y,c*=y,p*=y,l*=2,m*=2,M*=2,s[0]=n+u+l,s[1]=o+c+m,s[2]=a+p+M,s[3]=this[3],s}static scaleAndAdd(t,s,i,e=new h){return e[0]=t[0]+s[0]*i,e[1]=t[1]+s[1]*i,e[2]=t[2]+s[2]*i,e[3]=t[3]+s[3]*i,e}}o(h.prototype,4),h.dist=h.distance,h.sqrDist=h.squaredDistance,h.prototype.add=h.prototype.plus,h.prototype.divide=h.prototype.div,h.prototype.sub=h.prototype.minus,h.prototype.subtract=h.prototype.minus,h.prototype.mul=h.prototype.mult,h.prototype.scale=h.prototype.mult,h.prototype.times=h.prototype.mult,h.prototype.multiply=h.prototype.mult,h.prototype.neg=h.prototype.negate,h.prototype.unaryMinus=h.prototype.negate,h.prototype.sqrLen=h.prototype.squaredLength,h.prototype.str=h.prototype.toString,h.prototype.transformMat4x4=h.prototype.transformMat4;const e=(...t)=>{const s=new h;let i=0;for(const h of t)if("number"==typeof h)s[i++]=h;else for(const t of h)s[i++]=t;return 1==i&&(s[1]=s[2]=s[3]=s[0]),s};Object.setPrototypeOf(e,h);const r=e;function n(t,s){return Math.abs(t-s)<=U.EPSILON*Math.max(1,Math.abs(t),Math.abs(s))}function o(s,i=4,e=["xyzw","rgba","stpq","uv"]){for(let r of e)for(let e=2;e<=i;++e){const i="01"+r.substring(0,e);switch(e){case 2:for(let t=0;t<i.length;++t)for(let h=0;h<i.length;++h){const e=`${i[t]}${i[h]}`;/^[01]/.test(e)||Object.prototype.hasOwnProperty.call(s,e)||Object.defineProperty(s,e,{get(){return new a(t<2?t:this[t-2],h<2?h:this[h-2])}})}break;case 3:for(let h=0;h<i.length;++h)for(let e=0;e<i.length;++e)for(let r=0;r<i.length;++r){const n=`${i[h]}${i[e]}${i[r]}`;/^[01]/.test(n)||Object.prototype.hasOwnProperty.call(s,n)||Object.defineProperty(s,n,{get(){return new t(h<2?h:this[h-2],e<2?e:this[e-2],r<2?r:this[r-2])}})}break;case 4:for(let t=0;t<i.length;++t)for(let e=0;e<i.length;++e)for(let r=0;r<i.length;++r)for(let n=0;n<i.length;++n){const o=`${i[t]}${i[e]}${i[r]}${i[n]}`;/^[01]/.test(o)||Object.prototype.hasOwnProperty.call(s,o)||Object.defineProperty(s,o,{get(){return new h(t<2?t:this[t-2],e<2?e:this[e-2],r<2?r:this[r-2],n<2?n:this[n-2])}})}}}}class a extends Float32Array{static get zero(){return new a(0,0)}static get Zero(){return new a(0,0)}static get ZERO(){return new a(0,0)}static get one(){return new a(1,1)}static get One(){return new a(1,1)}static get ONE(){return new a(1,1)}constructor(t=0,s=0){super(2),this[0]=t,this[1]=s}get x(){return this[0]}set x(t){this[0]=t}get y(){return this[1]}set y(t){this[1]=t}plus(t,s=(U.ALWAYS_COPY?new a:this)){return"number"==typeof t?(s[0]=this[0]+t,s[1]=this[1]+t):(s[0]=this[0]+t[0],s[1]=this[1]+t[1]),s}minus(t,s=(U.ALWAYS_COPY?new a:this)){return"number"==typeof t?(s[0]=this[0]-t,s[1]=this[1]-t):(s[0]=this[0]-t[0],s[1]=this[1]-t[1]),s}mult(t,s=(U.ALWAYS_COPY?new a:this)){return"number"==typeof t?(s[0]=this[0]*t,s[1]=this[1]*t):(s[0]=this[0]*t[0],s[1]=this[1]*t[1]),s}div(t,s=(U.ALWAYS_COPY?new a:this)){return"number"==typeof t?(s[0]=this[0]/t,s[1]=this[1]/t):(s[0]=this[0]/t[0],s[1]=this[1]/t[1]),s}invDiv(t,s=(U.ALWAYS_COPY?new a:this)){return"number"==typeof t?(s[0]=t/this[0],s[1]=t/this[1]):(s[0]=t[0]/this[0],s[1]=t[1]/this[1]),s}rem(t,s=(U.ALWAYS_COPY?new a:this)){return"number"==typeof t?(s[0]=this[0]%t,s[1]=this[1]%t):(s[0]=this[0]%t[0],s[1]=this[1]%t[1]),s}negate(t=(U.ALWAYS_COPY?new a:this)){return t[0]=-this[0],t[1]=-this[1],t}unaryPlus(t=(U.ALWAYS_COPY?new a:this)){return t.equals(this)||(t[0]=this[0],t[1]=this[1]),t}normalize(t=(U.ALWAYS_COPY?new a:this)){const s=this[0],i=this[1];let h=s*s+i*i;return h>0&&(h=1/Math.sqrt(h)),t[0]=s*h,t[1]=i*h,t}equals(t){return n(this[0],t[0])&&n(this[1],t[1])}exactEquals(t){return this[0]===t[0]&&this[1]===t[1]}squaredLength(){const t=this[0],s=this[1];return t*t+s*s}len(){const t=this[0],s=this[1];return Math.sqrt(t*t+s*s)}floor(t=(U.ALWAYS_COPY?new a:this)){return t[0]=Math.floor(this[0]),t[1]=Math.floor(this[1]),t}round(t=(U.ALWAYS_COPY?new a:this)){return t[0]=Math.round(this[0]),t[1]=Math.round(this[1]),t}ceil(t=(U.ALWAYS_COPY?new a:this)){return t[0]=Math.ceil(this[0]),t[1]=Math.ceil(this[1]),t}inverse(t=(U.ALWAYS_COPY?new a:this)){return t[0]=1/this[0],t[1]=1/this[1],t}clone(){return new a(this[0],this[1])}rotate(t=0,s=a.ZERO,i=(U.ALWAYS_COPY?new a:this)){const h=this[0]-s[0],e=this[1]-s[1],r=Math.sin(t),n=Math.cos(t);return i[0]=h*n-e*r+s[0],i[1]=h*r+e*n+s[1],i}toString(){return`vec2(${this[0]}, ${this[1]})`}static random(t=1,s=new a){const i=2*U.RANDOM()*Math.PI;return s[0]=Math.cos(i)*t,s[1]=Math.sin(i)*t,s}static angle(t,s){const i=t[0],h=t[1],e=s[0],r=s[1];return Math.abs(Math.atan2(h*e-i*r,i*e+h*r))}static signedAngle(t,s){const i=t[0],h=t[1],e=s[0],r=s[1];return Math.atan2(i*r-h*e,i*e+h*r)}static dot(t,s){return t[0]*s[0]+t[1]*s[1]}dot(t){return this[0]*t[0]+this[1]*t[1]}static cross(s,i,h=new t){return h[0]=h[1]=0,h[2]=s[0]*i[1]-s[1]*i[0],h}static distance(t,s){const i=t[0]-s[0],h=t[1]-s[1];return Math.sqrt(i*i+h*h)}static squaredDistance(t,s){const i=t[0]-s[0],h=t[1]-s[1];return i*i+h*h}static lerp(t,s,i,h=new a){const e=t[0],r=t[1];return h[0]=e+(s[0]-e)*i,h[1]=r+(s[1]-r)*i,h}static max(t,s,i=new a){return i[0]=Math.max(t[0],s[0]),i[1]=Math.max(t[1],s[1]),i}static min(t,s,i=new a){return i[0]=Math.min(t[0],s[0]),i[1]=Math.min(t[1],s[1]),i}static clamp(t,s,i,h=new a){if("number"==typeof s&&"number"==typeof i)h[0]=Math.min(Math.max(t[0],s),i),h[1]=Math.min(Math.max(t[1],s),i);else{const e="number"==typeof s?s:s[1],r="number"==typeof i?i:i[0],n="number"==typeof i?i:i[1];h[0]=Math.min(Math.max(t[0],"number"==typeof s?s:s[0]),r),h[1]=Math.min(Math.max(t[1],e),n)}return h}static mix(t,s,i,h=new a){return"number"==typeof i?(h[0]=t[0]+(s[0]-t[0])*i,h[1]=t[1]+(s[1]-t[1])*i):(h[0]=t[0]+(s[0]-t[0])*i[0],h[1]=t[1]+(s[1]-t[1])*i[1]),h}static smoothstep(t,s,i,h=new a){const e="number"==typeof t?t:t[0],r="number"==typeof t?t:t[1],n="number"==typeof s?s:s[1];let o=Math.min(Math.max((i[0]-e)/(("number"==typeof s?s:s[0])-e),0),1),u=Math.min(Math.max((i[1]-r)/(n-r),0),1);return h[0]=o*o*(3-2*o),h[1]=u*u*(3-2*u),h}scaleAndAdd(t,s,i=(U.ALWAYS_COPY?new a:this)){return i[0]=this[0]+t[0]*s,i[1]=this[1]+t[1]*s,i}abs(t=(U.ALWAYS_COPY?new a:this)){return t[0]=Math.abs(this[0]),t[1]=Math.abs(this[1]),t}sign(t=(U.ALWAYS_COPY?new a:this)){return t[0]=this[0]>0?1:this[0]<0?-1:0,t[1]=this[1]>0?1:this[1]<0?-1:0,t}fract(t=(U.ALWAYS_COPY?new a:this)){return t[0]=this[0]-Math.floor(this[0]),t[1]=this[1]-Math.floor(this[1]),t}clamp(t,s,i=(U.ALWAYS_COPY?new a:this)){if("number"==typeof t&&"number"==typeof s)i[0]=Math.min(Math.max(this[0],t),s),i[1]=Math.min(Math.max(this[1],t),s);else{const h="number"==typeof t?t:t[1],e="number"==typeof s?s:s[0],r="number"==typeof s?s:s[1];i[0]=Math.min(Math.max(this[0],"number"==typeof t?t:t[0]),e),i[1]=Math.min(Math.max(this[1],h),r)}return i}saturate(t=(U.ALWAYS_COPY?new a:this)){return t[0]=Math.min(Math.max(this[0],0),1),t[1]=Math.min(Math.max(this[1],0),1),t}mix(t,s,i=(U.ALWAYS_COPY?new a:this)){return"number"==typeof s?(i[0]=this[0]+(t[0]-this[0])*s,i[1]=this[1]+(t[1]-this[1])*s):(i[0]=this[0]+(t[0]-this[0])*s[0],i[1]=this[1]+(t[1]-this[1])*s[1]),i}step(t,s=(U.ALWAYS_COPY?new a:this)){return"number"==typeof t?(s[0]=this[0]<t?0:1,s[1]=this[1]<t?0:1):(s[0]=this[0]<t[0]?0:1,s[1]=this[1]<t[1]?0:1),s}smoothstep(t,s,i=(U.ALWAYS_COPY?new a:this)){const h="number"==typeof t?t:t[0],e="number"==typeof t?t:t[1],r="number"==typeof s?s:s[1];let n=Math.min(Math.max((this[0]-h)/(("number"==typeof s?s:s[0])-h),0),1),o=Math.min(Math.max((this[1]-e)/(r-e),0),1);return i[0]=n*n*(3-2*n),i[1]=o*o*(3-2*o),i}transformMat2(t,s=(U.ALWAYS_COPY?new a:this)){const i=this[0],h=this[1];return s[0]=t[0]*i+t[2]*h,s[1]=t[1]*i+t[3]*h,s}transformMat2x3(t,s=(U.ALWAYS_COPY?new a:this)){const i=this[0],h=this[1];return s[0]=t[0]*i+t[2]*h+t[4],s[1]=t[1]*i+t[3]*h+t[5],s}transformMat3(t,s=(U.ALWAYS_COPY?new a:this)){const i=this[0],h=this[1];return s[0]=t[0]*i+t[3]*h+t[6],s[1]=t[1]*i+t[4]*h+t[7],s}transformMat4(t,s=(U.ALWAYS_COPY?new a:this)){const i=this[0],h=this[1];return s[0]=t[0]*i+t[4]*h+t[12],s[1]=t[1]*i+t[5]*h+t[13],s}static scaleAndAdd(t,s,i,h=new a){return h[0]=t[0]+s[0]*i,h[1]=t[1]+s[1]*i,h}static reflect(t,s,i=new a){const h=a.dot(s,t);return i[0]=t[0]-2*h*s[0],i[1]=t[1]-2*h*s[1],i}}o(a.prototype,2),a.dist=a.distance,a.sqrDist=a.squaredDistance,a.prototype.add=a.prototype.plus,a.prototype.sub=a.prototype.minus,a.prototype.subtract=a.prototype.minus,a.prototype.mul=a.prototype.mult,a.prototype.multiply=a.prototype.mult,a.prototype.scale=a.prototype.mult,a.prototype.times=a.prototype.mult,a.prototype.divide=a.prototype.div,a.prototype.neg=a.prototype.negate,a.prototype.unaryMinus=a.prototype.negate,a.prototype.sqrLen=a.prototype.squaredLength,a.prototype.str=a.prototype.toString,a.prototype.lerpV=a.prototype.mix,a.prototype.transformMat2x2=a.prototype.transformMat2,a.prototype.transformMat2d=a.prototype.transformMat2x3,a.prototype.transformMat3x3=a.prototype.transformMat3,a.prototype.transformMat4x4=a.prototype.transformMat4;const u=(...t)=>{const s=new a;let i=0;for(const h of t)if("number"==typeof h)s[i++]=h;else for(const t of h)s[i++]=t;return 1==i&&(s[1]=s[0]),s};Object.setPrototypeOf(u,a);const c=u;class p extends Float32Array{static get identity(){return new p(1,0,0,0,1,0,0,0,1)}static get Identity(){return new p(1,0,0,0,1,0,0,0,1)}static get IDENTITY(){return new p(1,0,0,0,1,0,0,0,1)}constructor(t=0,s=0,i=0,h=0,e=0,r=0,n=0,o=0,a=0){super(9),this[0]=t,this[1]=s,this[2]=i,this[3]=h,this[4]=e,this[5]=r,this[6]=n,this[7]=o,this[8]=a}clone(){return new p(this[0],this[1],this[2],this[3],this[4],this[5],this[6],this[7],this[8])}transpose(t=(U.ALWAYS_COPY?new p:this)){if(t.exactEquals(this)){const s=this[1],i=this[2],h=this[5];t[1]=this[3],t[2]=this[6],t[3]=s,t[5]=this[7],t[6]=i,t[7]=h}else t[0]=this[0],t[1]=this[3],t[2]=this[6],t[3]=this[1],t[4]=this[4],t[5]=this[7],t[6]=this[2],t[7]=this[5],t[8]=this[8];return t}invert(t=(U.ALWAYS_COPY?new p:this)){const s=this[0],i=this[1],h=this[2],e=this[3],r=this[4],n=this[5],o=this[6],a=this[7],u=this[8],c=u*r-n*a,l=-u*e+n*o,m=a*e-r*o;let M=s*c+i*l+h*m;return M?(M=1/M,t[0]=c*M,t[1]=(-u*i+h*a)*M,t[2]=(n*i-h*r)*M,t[3]=l*M,t[4]=(u*s-h*o)*M,t[5]=(-n*s+h*e)*M,t[6]=m*M,t[7]=(-a*s+i*o)*M,t[8]=(r*s-i*e)*M,t):null}adjoint(t=(U.ALWAYS_COPY?new p:this)){const s=this[0],i=this[1],h=this[2],e=this[3],r=this[4],n=this[5],o=this[6],a=this[7],u=this[8];return t[0]=r*u-n*a,t[1]=h*a-i*u,t[2]=i*n-h*r,t[3]=n*o-e*u,t[4]=s*u-h*o,t[5]=h*e-s*n,t[6]=e*a-r*o,t[7]=i*o-s*a,t[8]=s*r-i*e,t}determinant(){const t=this[3],s=this[4],i=this[5],h=this[6],e=this[7],r=this[8];return this[0]*(r*s-i*e)+this[1]*(-r*t+i*h)+this[2]*(e*t-s*h)}multiply(s,i=(U.ALWAYS_COPY?new p:this)){if(s instanceof a)return s.transformMat3(this);if(s instanceof t)return s.transformMat3(this);const h=this[0],e=this[1],r=this[2],n=this[3],o=this[4],u=this[5],c=this[6],l=this[7],m=this[8],M=s[0],y=s[1],f=s[2],A=s[3],w=s[4],Y=s[5],O=s[6],g=s[7],S=s[8];return i[0]=M*h+y*n+f*c,i[1]=M*e+y*o+f*l,i[2]=M*r+y*u+f*m,i[3]=A*h+w*n+Y*c,i[4]=A*e+w*o+Y*l,i[5]=A*r+w*u+Y*m,i[6]=O*h+g*n+S*c,i[7]=O*e+g*o+S*l,i[8]=O*r+g*u+S*m,i}translate(t,s=(U.ALWAYS_COPY?new p:this)){const i=this[0],h=this[1],e=this[2],r=this[3],n=this[4],o=this[5],a=this[6],u=this[7],c=this[8],l=t[0],m=t[1];return s[0]=i,s[1]=h,s[2]=e,s[3]=r,s[4]=n,s[5]=o,s[6]=l*i+m*r+a,s[7]=l*h+m*n+u,s[8]=l*e+m*o+c,s}rotate(t,s=(U.ALWAYS_COPY?new p:this)){const i=this[0],h=this[1],e=this[2],r=this[3],n=this[4],o=this[5],a=this[6],u=this[7],c=this[8],l=Math.sin(t),m=Math.cos(t);return s[0]=m*i+l*r,s[1]=m*h+l*n,s[2]=m*e+l*o,s[3]=m*r-l*i,s[4]=m*n-l*h,s[5]=m*o-l*e,s[6]=a,s[7]=u,s[8]=c,s}scale(t,s=(U.ALWAYS_COPY?new p:this)){const i=t[0],h=t[1];return s[0]=i*this[0],s[1]=i*this[1],s[2]=i*this[2],s[3]=h*this[3],s[4]=h*this[4],s[5]=h*this[5],s[6]=this[6],s[7]=this[7],s[8]=this[8],s}static fromTranslation(t,s=new p){return s[0]=1,s[1]=0,s[2]=0,s[3]=0,s[4]=1,s[5]=0,s[6]=t[0],s[7]=t[1],s[8]=1,s}static fromRotation(t,s=new p){const i=Math.sin(t),h=Math.cos(t);return s[0]=h,s[1]=i,s[2]=0,s[3]=-i,s[4]=h,s[5]=0,s[6]=0,s[7]=0,s[8]=1,s}static fromScaling(t,s=new p){return s[0]=t[0],s[1]=0,s[2]=0,s[3]=0,s[4]=t[1],s[5]=0,s[6]=0,s[7]=0,s[8]=1,s}static fromMat2x3(t,s=new p){return s[0]=t[0],s[1]=t[1],s[2]=0,s[3]=t[2],s[4]=t[3],s[5]=0,s[6]=t[4],s[7]=t[5],s[8]=1,s}static fromQuat(t,s=new p){const i=t[0],h=t[1],e=t[2],r=t[3],n=i+i,o=h+h,a=e+e,u=i*n,c=h*n,l=h*o,m=e*n,M=e*o,y=e*a,f=r*n,A=r*o,w=r*a;return s[0]=1-l-y,s[3]=c-w,s[6]=m+A,s[1]=c+w,s[4]=1-u-y,s[7]=M-f,s[2]=m-A,s[5]=M+f,s[8]=1-u-l,s}static normalFromMat4(t,s=new p){const i=t[0],h=t[1],e=t[2],r=t[3],n=t[4],o=t[5],a=t[6],u=t[7],c=t[8],l=t[9],m=t[10],M=t[11],y=t[12],f=t[13],A=t[14],w=t[15],Y=i*o-h*n,O=i*a-e*n,g=i*u-r*n,S=h*a-e*o,b=h*u-r*o,L=e*u-r*a,P=c*f-l*y,d=c*A-m*y,_=c*w-M*y,W=l*A-m*f,C=l*w-M*f,x=m*w-M*A;let q=Y*x-O*C+g*W+S*_-b*d+L*P;return q?(q=1/q,s[0]=(o*x-a*C+u*W)*q,s[1]=(a*_-n*x-u*d)*q,s[2]=(n*C-o*_+u*P)*q,s[3]=(e*C-h*x-r*W)*q,s[4]=(i*x-e*_+r*d)*q,s[5]=(h*_-i*C-r*P)*q,s[6]=(f*L-A*b+w*S)*q,s[7]=(A*g-y*L-w*O)*q,s[8]=(y*b-f*g+w*Y)*q,s):null}static fromMat4(t,s=new p){return s[0]=t[0],s[1]=t[1],s[2]=t[2],s[3]=t[4],s[4]=t[5],s[5]=t[6],s[6]=t[8],s[7]=t[9],s[8]=t[10],s}static projection(t,s,i=new p){return i[0]=2/t,i[1]=0,i[2]=0,i[3]=0,i[4]=-2/s,i[5]=0,i[6]=-1,i[7]=1,i[8]=1,i}frob(){return Math.sqrt(this[0]*this[0]+this[1]*this[1]+this[2]*this[2]+this[3]*this[3]+this[4]*this[4]+this[5]*this[5]+this[6]*this[6]+this[7]*this[7]+this[8]*this[8])}plus(t,s=(U.ALWAYS_COPY?new p:this)){return s[0]=this[0]+t[0],s[1]=this[1]+t[1],s[2]=this[2]+t[2],s[3]=this[3]+t[3],s[4]=this[4]+t[4],s[5]=this[5]+t[5],s[6]=this[6]+t[6],s[7]=this[7]+t[7],s[8]=this[8]+t[8],s}minus(t,s=(U.ALWAYS_COPY?new p:this)){return s[0]=this[0]-t[0],s[1]=this[1]-t[1],s[2]=this[2]-t[2],s[3]=this[3]-t[3],s[4]=this[4]-t[4],s[5]=this[5]-t[5],s[6]=this[6]-t[6],s[7]=this[7]-t[7],s[8]=this[8]-t[8],s}scaleScalar(t,s=(U.ALWAYS_COPY?new p:this)){return s[0]=this[0]*t,s[1]=this[1]*t,s[2]=this[2]*t,s[3]=this[3]*t,s[4]=this[4]*t,s[5]=this[5]*t,s[6]=this[6]*t,s[7]=this[7]*t,s[8]=this[8]*t,s}multiplyScalarAndAdd(t,s,i=(U.ALWAYS_COPY?new p:this)){return i[0]=this[0]+t[0]*s,i[1]=this[1]+t[1]*s,i[2]=this[2]+t[2]*s,i[3]=this[3]+t[3]*s,i[4]=this[4]+t[4]*s,i[5]=this[5]+t[5]*s,i[6]=this[6]+t[6]*s,i[7]=this[7]+t[7]*s,i[8]=this[8]+t[8]*s,i}toString(){return`mat3(${this[0]}, ${this[1]}, ${this[2]},\t${this[3]}, ${this[4]}, ${this[5]},\t${this[6]}, ${this[7]}, ${this[8]})`}exactEquals(t){return this[0]===t[0]&&this[1]===t[1]&&this[2]===t[2]&&this[3]===t[3]&&this[4]===t[4]&&this[5]===t[5]&&this[6]===t[6]&&this[7]===t[7]&&this[8]===t[8]}equals(t){return n(this[0],t[0])&&n(this[1],t[1])&&n(this[2],t[2])&&n(this[3],t[3])&&n(this[4],t[4])&&n(this[5],t[5])&&n(this[6],t[6])&&n(this[7],t[7])&&n(this[8],t[8])}}p.fromMat2d=p.fromMat2x3,p.fromMat4x4=p.fromMat4,p.prototype.add=p.prototype.plus,p.prototype.sub=p.prototype.minus,p.prototype.subtract=p.prototype.minus,p.prototype.mul=p.prototype.multiply,p.prototype.mult=p.prototype.multiply,p.prototype.times=p.prototype.multiply,p.prototype.str=p.prototype.toString,p.prototype.multiplyScalar=p.prototype.scaleScalar;const l=Object.assign((...t)=>{const s=new p;let i=0;for(const h of t)if("number"==typeof h)s[i++]=h;else for(const t of h)s[i++]=t;return s},p),m=l;var M;class y extends Float32Array{static get identity(){return new M(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1)}static get Identity(){return new M(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1)}static get IDENTITY(){return new M(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1)}constructor(t=0,s=0,i=0,h=0,e=0,r=0,n=0,o=0,a=0,u=0,c=0,p=0,l=0,m=0,M=0,y=0){super(16),this[0]=t,this[1]=s,this[2]=i,this[3]=h,this[4]=e,this[5]=r,this[6]=n,this[7]=o,this[8]=a,this[9]=u,this[10]=c,this[11]=p,this[12]=l,this[13]=m,this[14]=M,this[15]=y}clone(){return new M(this[0],this[1],this[2],this[3],this[4],this[5],this[6],this[7],this[8],this[9],this[10],this[11],this[12],this[13],this[14],this[15])}transpose(t=(U.ALWAYS_COPY?new M:this)){if(t.exactEquals(this)){const s=this[1],i=this[2],h=this[3],e=this[6],r=this[7],n=this[11];t[1]=this[4],t[2]=this[8],t[3]=this[12],t[4]=s,t[6]=this[9],t[7]=this[13],t[8]=i,t[9]=e,t[11]=this[14],t[12]=h,t[13]=r,t[14]=n}else t[0]=this[0],t[1]=this[4],t[2]=this[8],t[3]=this[12],t[4]=this[1],t[5]=this[5],t[6]=this[9],t[7]=this[13],t[8]=this[2],t[9]=this[6],t[10]=this[10],t[11]=this[14],t[12]=this[3],t[13]=this[7],t[14]=this[11],t[15]=this[15];return t}invert(t=(U.ALWAYS_COPY?new M:this)){const s=this[0],i=this[1],h=this[2],e=this[3],r=this[4],n=this[5],o=this[6],a=this[7],u=this[8],c=this[9],p=this[10],l=this[11],m=this[12],y=this[13],f=this[14],A=this[15],w=s*n-i*r,Y=s*o-h*r,O=s*a-e*r,g=i*o-h*n,S=i*a-e*n,b=h*a-e*o,L=u*y-c*m,P=u*f-p*m,d=u*A-l*m,_=c*f-p*y,W=c*A-l*y,C=p*A-l*f;let x=w*C-Y*W+O*_+g*d-S*P+b*L;return x?(x=1/x,t[0]=(n*C-o*W+a*_)*x,t[1]=(h*W-i*C-e*_)*x,t[2]=(y*b-f*S+A*g)*x,t[3]=(p*S-c*b-l*g)*x,t[4]=(o*d-r*C-a*P)*x,t[5]=(s*C-h*d+e*P)*x,t[6]=(f*O-m*b-A*Y)*x,t[7]=(u*b-p*O+l*Y)*x,t[8]=(r*W-n*d+a*L)*x,t[9]=(i*d-s*W-e*L)*x,t[10]=(m*S-y*O+A*w)*x,t[11]=(c*O-u*S-l*w)*x,t[12]=(n*P-r*_-o*L)*x,t[13]=(s*_-i*P+h*L)*x,t[14]=(y*Y-m*g-f*w)*x,t[15]=(u*g-c*Y+p*w)*x,t):null}adjoint(t=(U.ALWAYS_COPY?new M:this)){const s=this[0],i=this[1],h=this[2],e=this[3],r=this[4],n=this[5],o=this[6],a=this[7],u=this[8],c=this[9],p=this[10],l=this[11],m=this[12],y=this[13],f=this[14],A=this[15],w=s*n-i*r,Y=s*o-h*r,O=s*a-e*r,g=i*o-h*n,S=i*a-e*n,b=h*a-e*o,L=u*y-c*m,P=u*f-p*m,d=u*A-l*m,_=c*f-p*y,W=c*A-l*y,C=p*A-l*f;return t[0]=n*C-o*W+a*_,t[1]=h*W-i*C-e*_,t[2]=y*b-f*S+A*g,t[3]=p*S-c*b-l*g,t[4]=o*d-r*C-a*P,t[5]=s*C-h*d+e*P,t[6]=f*O-m*b-A*Y,t[7]=u*b-p*O+l*Y,t[8]=r*W-n*d+a*L,t[9]=i*d-s*W-e*L,t[10]=m*S-y*O+A*w,t[11]=c*O-u*S-l*w,t[12]=n*P-r*_-o*L,t[13]=s*_-i*P+h*L,t[14]=y*Y-m*g-f*w,t[15]=u*g-c*Y+p*w,t}determinant(){const t=this[0],s=this[1],i=this[2],h=this[3],e=this[4],r=this[5],n=this[6],o=this[7],a=this[8],u=this[9],c=this[10],p=this[11],l=this[12],m=this[13],M=this[14],y=this[15];return(t*r-s*e)*(c*y-p*M)-(t*n-i*e)*(u*y-p*m)+(t*o-h*e)*(u*M-c*m)+(s*n-i*r)*(a*y-p*l)-(s*o-h*r)*(a*M-c*l)+(i*o-h*n)*(a*m-u*l)}multiply(s,i=(U.ALWAYS_COPY?new M:this)){if(s instanceof a)return s.transformMat4(this);if(s instanceof t)return s.transformMat4(this);if(s instanceof h)return s.transformMat4(this);const e=this[0],r=this[1],n=this[2],o=this[3],u=this[4],c=this[5],p=this[6],l=this[7],m=this[8],y=this[9],f=this[10],A=this[11],w=this[12],Y=this[13],O=this[14],g=this[15];let S=s[0],b=s[1],L=s[2],P=s[3];return i[0]=S*e+b*u+L*m+P*w,i[1]=S*r+b*c+L*y+P*Y,i[2]=S*n+b*p+L*f+P*O,i[3]=S*o+b*l+L*A+P*g,S=s[4],b=s[5],L=s[6],P=s[7],i[4]=S*e+b*u+L*m+P*w,i[5]=S*r+b*c+L*y+P*Y,i[6]=S*n+b*p+L*f+P*O,i[7]=S*o+b*l+L*A+P*g,S=s[8],b=s[9],L=s[10],P=s[11],i[8]=S*e+b*u+L*m+P*w,i[9]=S*r+b*c+L*y+P*Y,i[10]=S*n+b*p+L*f+P*O,i[11]=S*o+b*l+L*A+P*g,S=s[12],b=s[13],L=s[14],P=s[15],i[12]=S*e+b*u+L*m+P*w,i[13]=S*r+b*c+L*y+P*Y,i[14]=S*n+b*p+L*f+P*O,i[15]=S*o+b*l+L*A+P*g,i}translate(t,s=(U.ALWAYS_COPY?new M:this)){const i=t[0],h=t[1],e=t[2];if(s.exactEquals(this))s[12]=this[0]*i+this[4]*h+this[8]*e+this[12],s[13]=this[1]*i+this[5]*h+this[9]*e+this[13],s[14]=this[2]*i+this[6]*h+this[10]*e+this[14],s[15]=this[3]*i+this[7]*h+this[11]*e+this[15];else{const t=this[0],r=this[1],n=this[2],o=this[3],a=this[4],u=this[5],c=this[6],p=this[7],l=this[8],m=this[9],M=this[10],y=this[11];s[0]=t,s[1]=r,s[2]=n,s[3]=o,s[4]=a,s[5]=u,s[6]=c,s[7]=p,s[8]=l,s[9]=m,s[10]=M,s[11]=y,s[12]=t*i+a*h+l*e+this[12],s[13]=r*i+u*h+m*e+this[13],s[14]=n*i+c*h+M*e+this[14],s[15]=o*i+p*h+y*e+this[15]}return s}scale(t,s=(U.ALWAYS_COPY?new M:this)){const i=t[0],h=t[1],e=t[2];return s[0]=this[0]*i,s[1]=this[1]*i,s[2]=this[2]*i,s[3]=this[3]*i,s[4]=this[4]*h,s[5]=this[5]*h,s[6]=this[6]*h,s[7]=this[7]*h,s[8]=this[8]*e,s[9]=this[9]*e,s[10]=this[10]*e,s[11]=this[11]*e,s[12]=this[12],s[13]=this[13],s[14]=this[14],s[15]=this[15],s}rotate(t,s,i=(U.ALWAYS_COPY?new M:this)){let h=s[0],e=s[1],r=s[2],n=Math.sqrt(h*h+e*e+r*r);if(n<U.EPSILON)return null;n=1/n,h*=n,e*=n,r*=n;const o=Math.sin(t),a=Math.cos(t),u=1-a,c=this[0],p=this[1],l=this[2],m=this[3],y=this[4],f=this[5],A=this[6],w=this[7],Y=this[8],O=this[9],g=this[10],S=this[11],b=h*h*u+a,L=e*h*u+r*o,P=r*h*u-e*o,d=h*e*u-r*o,_=e*e*u+a,W=r*e*u+h*o,C=h*r*u+e*o,x=e*r*u-h*o,q=r*r*u+a;return i[0]=c*b+y*L+Y*P,i[1]=p*b+f*L+O*P,i[2]=l*b+A*L+g*P,i[3]=m*b+w*L+S*P,i[4]=c*d+y*_+Y*W,i[5]=p*d+f*_+O*W,i[6]=l*d+A*_+g*W,i[7]=m*d+w*_+S*W,i[8]=c*C+y*x+Y*q,i[9]=p*C+f*x+O*q,i[10]=l*C+A*x+g*q,i[11]=m*C+w*x+S*q,i[12]=this[12],i[13]=this[13],i[14]=this[14],i[15]=this[15],i}rotateX(t,s=(U.ALWAYS_COPY?new M:this)){const i=Math.sin(t),h=Math.cos(t),e=this[4],r=this[5],n=this[6],o=this[7],a=this[8],u=this[9],c=this[10],p=this[11];return s[4]=e*h+a*i,s[5]=r*h+u*i,s[6]=n*h+c*i,s[7]=o*h+p*i,s[8]=a*h-e*i,s[9]=u*h-r*i,s[10]=c*h-n*i,s[11]=p*h-o*i,s.exactEquals(this)||(s[0]=this[0],s[1]=this[1],s[2]=this[2],s[3]=this[3],s[12]=this[12],s[13]=this[13],s[14]=this[14],s[15]=this[15]),s}rotateY(t,s=(U.ALWAYS_COPY?new M:this)){const i=Math.sin(t),h=Math.cos(t),e=this[0],r=this[1],n=this[2],o=this[3],a=this[8],u=this[9],c=this[10],p=this[11];return s[0]=e*h-a*i,s[1]=r*h-u*i,s[2]=n*h-c*i,s[3]=o*h-p*i,s[8]=e*i+a*h,s[9]=r*i+u*h,s[10]=n*i+c*h,s[11]=o*i+p*h,s.exactEquals(this)||(s[4]=this[4],s[5]=this[5],s[6]=this[6],s[7]=this[7],s[12]=this[12],s[13]=this[13],s[14]=this[14],s[15]=this[15]),s}rotateZ(t,s=(U.ALWAYS_COPY?new M:this)){const i=Math.sin(t),h=Math.cos(t),e=this[0],r=this[1],n=this[2],o=this[3],a=this[4],u=this[5],c=this[6],p=this[7];return s[0]=e*h+a*i,s[1]=r*h+u*i,s[2]=n*h+c*i,s[3]=o*h+p*i,s[4]=a*h-e*i,s[5]=u*h-r*i,s[6]=c*h-n*i,s[7]=p*h-o*i,s.exactEquals(this)||(s[8]=this[8],s[9]=this[9],s[10]=this[10],s[11]=this[11],s[12]=this[12],s[13]=this[13],s[14]=this[14],s[15]=this[15]),s}getTranslation(s=new t){return s[0]=this[12],s[1]=this[13],s[2]=this[14],s}getScaling(s=new t){const i=this[0],h=this[1],e=this[2],r=this[4],n=this[5],o=this[6],a=this[8],u=this[9],c=this[10];return s[0]=Math.sqrt(i*i+h*h+e*e),s[1]=Math.sqrt(r*r+n*n+o*o),s[2]=Math.sqrt(a*a+u*u+c*c),s}getRotation(t=new w){const s=this.getScaling(),i=1/s[0],h=1/s[1],e=1/s[2],r=this[0]*i,n=this[1]*h,o=this[2]*e,a=this[4]*i,u=this[5]*h,c=this[6]*e,p=this[8]*i,l=this[9]*h,m=this[10]*e,M=r+u+m;let y=0;return M>0?(y=2*Math.sqrt(M+1),t[3]=.25*y,t[0]=(c-l)/y,t[1]=(p-o)/y,t[2]=(n-a)/y):r>u&&r>m?(y=2*Math.sqrt(1+r-u-m),t[3]=(c-l)/y,t[0]=.25*y,t[1]=(n+a)/y,t[2]=(p+o)/y):u>m?(y=2*Math.sqrt(1+u-r-m),t[3]=(p-o)/y,t[0]=(n+a)/y,t[1]=.25*y,t[2]=(c+l)/y):(y=2*Math.sqrt(1+m-r-u),t[3]=(n-a)/y,t[0]=(p+o)/y,t[1]=(c+l)/y,t[2]=.25*y),t}decompose(s=new w,i=new t,h=new t){i[0]=this[12],i[1]=this[13],i[2]=this[14];const e=this[0],r=this[1],n=this[2],o=this[4],a=this[5],u=this[6],c=this[8],p=this[9],l=this[10];h[0]=Math.sqrt(e*e+r*r+n*n),h[1]=Math.sqrt(o*o+a*a+u*u),h[2]=Math.sqrt(c*c+p*p+l*l);const m=1/h[0],M=1/h[1],y=1/h[2],f=e*m,A=r*M,Y=n*y,O=o*m,g=a*M,S=u*y,b=c*m,L=p*M,P=l*y,d=f+g+P;let _=0;return d>0?(_=2*Math.sqrt(d+1),s[3]=.25*_,s[0]=(S-L)/_,s[1]=(b-Y)/_,s[2]=(A-O)/_):f>g&&f>P?(_=2*Math.sqrt(1+f-g-P),s[3]=(S-L)/_,s[0]=.25*_,s[1]=(A+O)/_,s[2]=(b+Y)/_):g>P?(_=2*Math.sqrt(1+g-f-P),s[3]=(b-Y)/_,s[0]=(A+O)/_,s[1]=.25*_,s[2]=(S+L)/_):(_=2*Math.sqrt(1+P-f-g),s[3]=(A-O)/_,s[0]=(b+Y)/_,s[1]=(S+L)/_,s[2]=.25*_),s}static fromTranslation(t,s=new M){return s[0]=s[5]=s[10]=s[15]=1,s[1]=s[2]=s[3]=s[4]=s[6]=s[7]=s[8]=s[9]=s[11]=0,s[12]=t[0],s[13]=t[1],s[14]=t[2],s}static fromScaling(t,s=new M){return s[0]=t[0],s[5]=t[1],s[10]=t[2],s[1]=s[2]=s[3]=s[4]=s[6]=s[7]=s[8]=s[9]=s[11]=s[12]=s[13]=s[14]=0,s[15]=1,s}static fromRotation(t,s,i=new M){let h=s[0],e=s[1],r=s[2],n=Math.sqrt(h*h+e*e+r*r);if(n<U.EPSILON)return null;n=1/n,h*=n,e*=n,r*=n;const o=Math.sin(t),a=Math.cos(t),u=1-a;return i[0]=h*h*u+a,i[1]=e*h*u+r*o,i[2]=r*h*u-e*o,i[3]=0,i[4]=h*e*u-r*o,i[5]=e*e*u+a,i[6]=r*e*u+h*o,i[7]=0,i[8]=h*r*u+e*o,i[9]=e*r*u-h*o,i[10]=r*r*u+a,i[11]=0,i[12]=i[13]=i[14]=0,i[15]=1,i}static fromXRotation(t,s=new M){const i=Math.sin(t),h=Math.cos(t);return s[0]=1,s[1]=s[2]=s[3]=s[4]=s[7]=s[8]=s[11]=s[12]=s[13]=s[14]=0,s[5]=h,s[6]=i,s[9]=-i,s[10]=h,s[15]=1,s}static fromYRotation(t,s=new M){const i=Math.sin(t),h=Math.cos(t);return s[0]=h,s[1]=s[3]=s[4]=s[6]=s[7]=s[9]=s[11]=s[12]=s[13]=s[14]=0,s[2]=-i,s[5]=s[15]=1,s[8]=i,s[10]=h,s}static fromZRotation(t,s=new M){const i=Math.sin(t),h=Math.cos(t);return s[0]=h,s[1]=i,s[4]=-i,s[5]=h,s[2]=s[3]=s[6]=s[7]=s[8]=s[9]=s[11]=s[12]=s[13]=s[14]=0,s[10]=s[15]=1,s}static fromRotationTranslation(t,s,i=new M){const h=t[0],e=t[1],r=t[2],n=t[3],o=h+h,a=e+e,u=r+r,c=h*o,p=h*a,l=h*u,m=e*a,y=e*u,f=r*u,A=n*o,w=n*a,Y=n*u;return i[0]=1-(m+f),i[1]=p+Y,i[2]=l-w,i[3]=i[7]=i[11]=0,i[4]=p-Y,i[5]=1-(c+f),i[6]=y+A,i[8]=l+w,i[9]=y-A,i[10]=1-(c+m),i[12]=s[0],i[13]=s[1],i[14]=s[2],i[15]=1,i}static fromRotationTranslationScale(t,s,i,h=new M){const e=t[0],r=t[1],n=t[2],o=t[3],a=e+e,u=r+r,c=n+n,p=e*a,l=e*u,m=e*c,y=r*u,f=r*c,A=n*c,w=o*a,Y=o*u,O=o*c,g=i[0],S=i[1],b=i[2];return h[0]=(1-(y+A))*g,h[1]=(l+O)*g,h[2]=(m-Y)*g,h[3]=h[7]=h[11]=0,h[4]=(l-O)*S,h[5]=(1-(p+A))*S,h[6]=(f+w)*S,h[8]=(m+Y)*b,h[9]=(f-w)*b,h[10]=(1-(p+y))*b,h[12]=s[0],h[13]=s[1],h[14]=s[2],h[15]=1,h}static fromRotationTranslationScaleOrigin(t,s,i,h,e=new M){const r=t[0],n=t[1],o=t[2],a=t[3],u=r+r,c=n+n,p=o+o,l=r*u,m=r*c,y=r*p,f=n*c,A=n*p,w=o*p,Y=a*u,O=a*c,g=a*p,S=i[0],b=i[1],L=i[2],P=h[0],d=h[1],_=h[2],W=(1-(f+w))*S,C=(m+g)*S,x=(y-O)*S,q=(m-g)*b,$=(1-(l+w))*b,E=(A+Y)*b,D=(y+O)*L,N=(A-Y)*L,I=(1-(l+f))*L;return e[0]=W,e[1]=C,e[2]=x,e[4]=q,e[5]=$,e[6]=E,e[8]=D,e[9]=N,e[10]=I,e[3]=e[7]=e[11]=0,e[12]=s[0]+P-(W*P+q*d+D*_),e[13]=s[1]+d-(C*P+$*d+N*_),e[14]=s[2]+_-(x*P+E*d+I*_),e[15]=1,e}static fromQuat(t,s=new M){const i=t[0],h=t[1],e=t[2],r=t[3],n=i+i,o=h+h,a=e+e,u=i*n,c=h*n,p=h*o,l=e*n,m=e*o,y=e*a,f=r*n,A=r*o,w=r*a;return s[0]=1-p-y,s[1]=c+w,s[2]=l-A,s[4]=c-w,s[5]=1-u-y,s[6]=m+f,s[8]=l+A,s[9]=m-f,s[10]=1-u-p,s[3]=s[7]=s[11]=s[12]=s[13]=s[14]=0,s[15]=1,s}static frustum(t,s,i,h,e,r,n=new M){const o=1/(s-t),a=1/(h-i),u=1/(e-r),c=U.LEFT_HANDED;return n[0]=2*e*o,n[5]=2*e*a,n[8]=(s+t)*o,n[9]=(h+i)*a,n[10]=c?-(r+e)*u:(r+e)*u,n[11]=c?1:-1,n[1]=n[2]=n[3]=n[4]=n[6]=n[7]=n[12]=n[13]=n[15]=0,n[14]=r*e*2*u,n}static perspectiveNO(t,s,i,h,e=new M){const r=1/Math.tan(t/2),n=U.LEFT_HANDED;if(e[0]=r/s,e[1]=e[2]=e[3]=e[4]=e[6]=e[7]=e[8]=e[9]=e[12]=e[13]=e[15]=0,e[5]=r,e[11]=n?1:-1,null!=h&&h!==1/0){const t=1/(i-h);e[10]=n?-(h+i)*t:(h+i)*t,e[14]=2*h*i*t}else e[10]=n?1:-1,e[14]=-2*i;return e}static perspectiveZO(t,s,i,h,e=new M){const r=1/Math.tan(t/2),n=U.LEFT_HANDED;if(e[0]=r/s,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=r,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[11]=n?1:-1,e[12]=0,e[13]=0,e[15]=0,null!=h&&h!==1/0){const t=1/(i-h);e[10]=n?-h*t:h*t,e[14]=h*i*t}else e[10]=n?1:-1,e[14]=-i;return e}static perspectiveFromFieldOfView(t,s,i,h=new M){const e=Math.tan(t.upDegrees*Math.PI/180),r=Math.tan(t.downDegrees*Math.PI/180),n=Math.tan(t.leftDegrees*Math.PI/180),o=Math.tan(t.rightDegrees*Math.PI/180),a=2/(n+o),u=2/(e+r);h[0]=a,h[1]=0,h[2]=0,h[3]=0,h[4]=0,h[5]=u,h[6]=0,h[7]=0;const c=U.LEFT_HANDED;return h[8]=-(n-o)*a*.5,h[9]=(e-r)*u*.5,h[10]=c?-i/(s-i):i/(s-i),h[11]=c?1:-1,h[12]=0,h[13]=0,h[14]=i*s/(s-i),h[15]=0,h}static orthoNO(t,s,i,h,e,r,n=new M){const o=1/(t-s),a=1/(i-h),u=1/(e-r),c=U.LEFT_HANDED?-1:1;return n[0]=-2*o,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=-2*a,n[6]=0,n[7]=0,n[8]=0,n[9]=0,n[10]=2*c*u,n[11]=0,n[12]=(t+s)*o,n[13]=(h+i)*a,n[14]=(r+e)*u,n[15]=1,n}static orthoZO(t,s,i,h,e,r,n=new M){const o=1/(t-s),a=1/(i-h),u=1/(e-r),c=U.LEFT_HANDED?-1:1;return n[0]=-2*o,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=-2*a,n[6]=0,n[7]=0,n[8]=0,n[9]=0,n[10]=c*u,n[11]=0,n[12]=(t+s)*o,n[13]=(h+i)*a,n[14]=e*u,n[15]=1,n}static lookAt(t,s,i,h=new M){let e,r,n,o,a,u,c,p,l,m;const y=t[0],f=t[1],A=t[2],w=i[0],Y=i[1],O=i[2],g=s[0],S=s[1],b=s[2];return t.equals(s)?(h[0]=1,h[1]=0,h[2]=0,h[3]=0,h[4]=0,h[5]=1,h[6]=0,h[7]=0,h[8]=0,h[9]=0,h[10]=1,h[11]=0,h[12]=0,h[13]=0,h[14]=0,h[15]=1,h):(U.LEFT_HANDED?(c=g-y,p=S-f,l=b-A):(c=y-g,p=f-S,l=A-b),m=1/Math.sqrt(c*c+p*p+l*l),c*=m,p*=m,l*=m,e=Y*l-O*p,r=O*c-w*l,n=w*p-Y*c,m=Math.sqrt(e*e+r*r+n*n),m?(m=1/m,e*=m,r*=m,n*=m):(e=0,r=0,n=0),o=p*n-l*r,a=l*e-c*n,u=c*r-p*e,m=Math.sqrt(o*o+a*a+u*u),m?(m=1/m,o*=m,a*=m,u*=m):(o=0,a=0,u=0),h[0]=e,h[1]=o,h[2]=c,h[3]=0,h[4]=r,h[5]=a,h[6]=p,h[7]=0,h[8]=n,h[9]=u,h[10]=l,h[11]=0,h[12]=-(e*y+r*f+n*A),h[13]=-(o*y+a*f+u*A),h[14]=-(c*y+p*f+l*A),h[15]=1,h)}static targetTo(t,s,i,h=new M){const e=t[0],r=t[1],n=t[2],o=i[0],a=i[1],u=i[2];let c,p,l;U.LEFT_HANDED?(c=s[0]-e,p=s[1]-r,l=s[2]-n):(c=e-s[0],p=r-s[1],l=n-s[2]);let m=c*c+p*p+l*l;m>0&&(m=1/Math.sqrt(m),c*=m,p*=m,l*=m);let y=a*l-u*p,f=u*c-o*l,A=o*p-a*c;return m=y*y+f*f+A*A,m>0&&(m=1/Math.sqrt(m),y*=m,f*=m,A*=m),h[0]=y,h[1]=f,h[2]=A,h[3]=0,h[4]=p*A-l*f,h[5]=l*y-c*A,h[6]=c*f-p*y,h[7]=0,h[8]=c,h[9]=p,h[10]=l,h[11]=0,h[12]=e,h[13]=r,h[14]=n,h[15]=1,h}static infinitePerspective(t,s,i,h=new M){const e=1/Math.tan(t/2),r=U.LEFT_HANDED;return h[0]=e/s,h[1]=h[2]=h[3]=h[4]=h[6]=h[7]=h[8]=h[9]=h[12]=h[13]=h[15]=0,h[5]=e,h[10]=r?1:-1,h[11]=r?1:-1,h[14]=-2*i,h}static project(s,i,h,e,r=new t){const n=s[0],o=s[1],a=s[2],u=i[0]*n+i[4]*o+i[8]*a+i[12],c=i[1]*n+i[5]*o+i[9]*a+i[13],p=i[2]*n+i[6]*o+i[10]*a+i[14],l=i[3]*n+i[7]*o+i[11]*a+i[15];let m=h[0]*u+h[4]*c+h[8]*p+h[12]*l,M=h[1]*u+h[5]*c+h[9]*p+h[13]*l,y=h[2]*u+h[6]*c+h[10]*p+h[14]*l,f=h[3]*u+h[7]*c+h[11]*p+h[15]*l;return f=f||1,m/=f,M/=f,y/=f,r[0]=e[0]+e[2]*(.5*m+.5),r[1]=e[1]+e[3]*(.5*M+.5),r[2]=.5*y+.5,r}static unProject(s,i,h,e,r=new t){const n=i[0],o=i[1],a=i[2],u=i[3],c=i[4],p=i[5],l=i[6],m=i[7],y=i[8],f=i[9],A=i[10],w=i[11],Y=i[12],O=i[13],g=i[14],S=i[15],b=new M;let L=h[0],P=h[1],d=h[2],_=h[3];b[0]=L*n+P*c+d*y+_*Y,b[1]=L*o+P*p+d*f+_*O,b[2]=L*a+P*l+d*A+_*g,b[3]=L*u+P*m+d*w+_*S,L=h[4],P=h[5],d=h[6],_=h[7],b[4]=L*n+P*c+d*y+_*Y,b[5]=L*o+P*p+d*f+_*O,b[6]=L*a+P*l+d*A+_*g,b[7]=L*u+P*m+d*w+_*S,L=h[8],P=h[9],d=h[10],_=h[11],b[8]=L*n+P*c+d*y+_*Y,b[9]=L*o+P*p+d*f+_*O,b[10]=L*a+P*l+d*A+_*g,b[11]=L*u+P*m+d*w+_*S,L=h[12],P=h[13],d=h[14],_=h[15],b[12]=L*n+P*c+d*y+_*Y,b[13]=L*o+P*p+d*f+_*O,b[14]=L*a+P*l+d*A+_*g,b[15]=L*u+P*m+d*w+_*S;const W=b.invert();if(!W)return null;const C=(s[0]-e[0])/e[2]*2-1,x=(s[1]-e[1])/e[3]*2-1,q=2*s[2]-1;let $=W[3]*C+W[7]*x+W[11]*q+W[15];return $=$||1,r[0]=(W[0]*C+W[4]*x+W[8]*q+W[12])/$,r[1]=(W[1]*C+W[5]*x+W[9]*q+W[13])/$,r[2]=(W[2]*C+W[6]*x+W[10]*q+W[14])/$,r}frob(){return Math.sqrt(this[0]*this[0]+this[1]*this[1]+this[2]*this[2]+this[3]*this[3]+this[4]*this[4]+this[5]*this[5]+this[6]*this[6]+this[7]*this[7]+this[8]*this[8]+this[9]*this[9]+this[10]*this[10]+this[11]*this[11]+this[12]*this[12]+this[13]*this[13]+this[14]*this[14]+this[15]*this[15])}plus(t,s=(U.ALWAYS_COPY?new M:this)){return s[0]=this[0]+t[0],s[1]=this[1]+t[1],s[2]=this[2]+t[2],s[3]=this[3]+t[3],s[4]=this[4]+t[4],s[5]=this[5]+t[5],s[6]=this[6]+t[6],s[7]=this[7]+t[7],s[8]=this[8]+t[8],s[9]=this[9]+t[9],s[10]=this[10]+t[10],s[11]=this[11]+t[11],s[12]=this[12]+t[12],s[13]=this[13]+t[13],s[14]=this[14]+t[14],s[15]=this[15]+t[15],s}minus(t,s=(U.ALWAYS_COPY?new M:this)){return s[0]=this[0]-t[0],s[1]=this[1]-t[1],s[2]=this[2]-t[2],s[3]=this[3]-t[3],s[4]=this[4]-t[4],s[5]=this[5]-t[5],s[6]=this[6]-t[6],s[7]=this[7]-t[7],s[8]=this[8]-t[8],s[9]=this[9]-t[9],s[10]=this[10]-t[10],s[11]=this[11]-t[11],s[12]=this[12]-t[12],s[13]=this[13]-t[13],s[14]=this[14]-t[14],s[15]=this[15]-t[15],s}scaleScalar(t,s=(U.ALWAYS_COPY?new M:this)){return s[0]=this[0]*t,s[1]=this[1]*t,s[2]=this[2]*t,s[3]=this[3]*t,s[4]=this[4]*t,s[5]=this[5]*t,s[6]=this[6]*t,s[7]=this[7]*t,s[8]=this[8]*t,s[9]=this[9]*t,s[10]=this[10]*t,s[11]=this[11]*t,s[12]=this[12]*t,s[13]=this[13]*t,s[14]=this[14]*t,s[15]=this[15]*t,s}multiplyScalarAndAdd(t,s,i=(U.ALWAYS_COPY?new M:this)){return i[0]=this[0]+t[0]*s,i[1]=this[1]+t[1]*s,i[2]=this[2]+t[2]*s,i[3]=this[3]+t[3]*s,i[4]=this[4]+t[4]*s,i[5]=this[5]+t[5]*s,i[6]=this[6]+t[6]*s,i[7]=this[7]+t[7]*s,i[8]=this[8]+t[8]*s,i[9]=this[9]+t[9]*s,i[10]=this[10]+t[10]*s,i[11]=this[11]+t[11]*s,i[12]=this[12]+t[12]*s,i[13]=this[13]+t[13]*s,i[14]=this[14]+t[14]*s,i[15]=this[15]+t[15]*s,i}toString(){return`mat4(${this[0]}, ${this[1]}, ${this[2]}, ${this[3]},\t${this[4]}, ${this[5]}, ${this[6]}, ${this[7]},\t${this[8]}, ${this[9]}, ${this[10]}, ${this[11]},\t${this[12]}, ${this[13]}, ${this[14]}, ${this[15]})`}exactEquals(t){return this[0]===t[0]&&this[1]===t[1]&&this[2]===t[2]&&this[3]===t[3]&&this[4]===t[4]&&this[5]===t[5]&&this[6]===t[6]&&this[7]===t[7]&&this[8]===t[8]&&this[9]===t[9]&&this[10]===t[10]&&this[11]===t[11]&&this[12]===t[12]&&this[13]===t[13]&&this[14]===t[14]&&this[15]===t[15]}equals(t){return n(this[0],t[0])&&n(this[1],t[1])&&n(this[2],t[2])&&n(this[3],t[3])&&n(this[4],t[4])&&n(this[5],t[5])&&n(this[6],t[6])&&n(this[7],t[7])&&n(this[8],t[8])&&n(this[9],t[9])&&n(this[10],t[10])&&n(this[11],t[11])&&n(this[12],t[12])&&n(this[13],t[13])&&n(this[14],t[14])&&n(this[15],t[15])}}y.perspective=(M=y).perspectiveNO,y.ortho=M.orthoNO,y.prototype.add=y.prototype.plus,y.prototype.sub=y.prototype.minus,y.prototype.subtract=y.prototype.minus,y.prototype.mul=y.prototype.multiply,y.prototype.mult=y.prototype.multiply,y.prototype.times=y.prototype.multiply,y.prototype.str=y.prototype.toString,y.prototype.multiplyScalar=y.prototype.scaleScalar;const f=Object.assign((...t)=>{const s=new y;let i=0;for(const h of t)if("number"==typeof h)s[i++]=h;else for(const t of h)s[i++]=t;return s},y),A=f;class w extends Float32Array{static get identity(){return new w(0,0,0,1)}static get Identity(){return new w(0,0,0,1)}static get IDENTITY(){return new w(0,0,0,1)}constructor(t=0,s=0,i=0,h=1){super(4),this[0]=t,this[1]=s,this[2]=i,this[3]=h}multiply(t,s=(U.ALWAYS_COPY?new w:this)){if("number"==typeof t)return s[0]=this[0]*t,s[1]=this[1]*t,s[2]=this[2]*t,s[3]=this[3]*t,s;const i=this[0],h=this[1],e=this[2],r=this[3],n=t[0],o=t[1],a=t[2],u=t[3];return s[0]=i*u+r*n+h*a-e*o,s[1]=h*u+r*o+e*n-i*a,s[2]=e*u+r*a+i*o-h*n,s[3]=r*u-i*n-h*o-e*a,s}static fromAxisAngle(t,s,i=Y()){const h=Math.sin(s*=.5);return i[0]=h*t[0],i[1]=h*t[1],i[2]=h*t[2],i[3]=Math.cos(s),i}setAxisAngle(t,s,i=(U.ALWAYS_COPY?Y():this)){const h=Math.sin(s*=.5);return i[0]=h*t[0],i[1]=h*t[1],i[2]=h*t[2],i[3]=Math.cos(s),i}getAxisAngle(t){const s=2*Math.acos(this[3]),i=Math.sin(s/2);return t&&(i>U.EPSILON?(t[0]=this[0]/i,t[1]=this[1]/i,t[2]=this[2]/i):(t[0]=1,t[1]=t[2]=0)),s}static angle(t,s){const i=w.dot(t,s);return Math.acos(2*i*i-1)}rotateX(t,s=(U.ALWAYS_COPY?Y():this)){const i=this[0],h=this[1],e=this[2],r=this[3],n=Math.sin(t*=.5),o=Math.cos(t);return s[0]=i*o+r*n,s[1]=h*o+e*n,s[2]=e*o-h*n,s[3]=r*o-i*n,s}rotateY(t,s=(U.ALWAYS_COPY?Y():this)){const i=this[0],h=this[1],e=this[2],r=this[3],n=Math.sin(t*=.5),o=Math.cos(t);return s[0]=i*o-e*n,s[1]=h*o+r*n,s[2]=e*o+i*n,s[3]=r*o-h*n,s}rotateZ(t,s=(U.ALWAYS_COPY?Y():this)){const i=this[0],h=this[1],e=this[2],r=this[3],n=Math.sin(t*=.5),o=Math.cos(t);return s[0]=i*o+h*n,s[1]=h*o-i*n,s[2]=e*o+r*n,s[3]=r*o-e*n,s}calculateW(){const t=this[0],s=this[1],i=this[2];return Math.sqrt(Math.abs(1-t*t-s*s-i*i))}static exp(t,s=Y()){const i=t[0],h=t[1],e=t[2],r=t[3],n=Math.sqrt(i*i+h*h+e*e),o=Math.exp(r),a=n>0?o*Math.sin(n)/n:0;return s[0]=i*a,s[1]=h*a,s[2]=e*a,s[3]=o*Math.cos(n),s}exp(t=(U.ALWAYS_COPY?Y():this)){const s=this[0],i=this[1],h=this[2],e=this[3],r=Math.sqrt(s*s+i*i+h*h),n=Math.exp(e),o=r>0?n*Math.sin(r)/r:0;return t[0]=s*o,t[1]=i*o,t[2]=h*o,t[3]=n*Math.cos(r),t}static ln(t,s=Y()){const i=t[0],h=t[1],e=t[2],r=t[3],n=Math.sqrt(i*i+h*h+e*e),o=n>0?Math.atan2(n,r)/n:0;return s[0]=i*o,s[1]=h*o,s[2]=e*o,s[3]=.5*Math.log(i*i+h*h+e*e+r*r),s}ln(t=(U.ALWAYS_COPY?Y():this)){const s=this[0],i=this[1],h=this[2],e=this[3],r=Math.sqrt(s*s+i*i+h*h),n=r>0?Math.atan2(r,e)/r:0;return t[0]=s*n,t[1]=i*n,t[2]=h*n,t[3]=.5*Math.log(s*s+i*i+h*h+e*e),t}pow(t){return this.ln(),this.scale(t),this.exp(),this}static slerp(t,s,i,h=Y()){let e,r,n,o,a,u=t[0],c=t[1],p=t[2],l=t[3],m=s[0],M=s[1],y=s[2],f=s[3];return r=u*m+c*M+p*y+l*f,r<0&&(r=-r,m=-m,M=-M,y=-y,f=-f),1-r>U.EPSILON?(e=Math.acos(r),n=Math.sin(e),o=Math.sin((1-i)*e)/n,a=Math.sin(i*e)/n):(o=1-i,a=i),h[0]=o*u+a*m,h[1]=o*c+a*M,h[2]=o*p+a*y,h[3]=o*l+a*f,h}slerp(t,s,i=(U.ALWAYS_COPY?Y():this)){let h,e,r,n,o,a=this[0],u=this[1],c=this[2],p=this[3],l=t[0],m=t[1],M=t[2],y=t[3];return e=a*l+u*m+c*M+p*y,e<0&&(e=-e,l=-l,m=-m,M=-M,y=-y),1-e>U.EPSILON?(h=Math.acos(e),r=Math.sin(h),n=Math.sin((1-s)*h)/r,o=Math.sin(s*h)/r):(n=1-s,o=s),i[0]=n*a+o*l,i[1]=n*u+o*m,i[2]=n*c+o*M,i[3]=n*p+o*y,i}static random(t=Y()){let s=U.RANDOM(),i=U.RANDOM(),h=U.RANDOM(),e=Math.sqrt(1-s),r=Math.sqrt(s);return t[0]=e*Math.sin(2*Math.PI*i),t[1]=e*Math.cos(2*Math.PI*i),t[2]=r*Math.sin(2*Math.PI*h),t[3]=r*Math.cos(2*Math.PI*h),t}static invert(t,s=Y()){const i=t[0],h=t[1],e=t[2],r=t[3],n=i*i+h*h+e*e+r*r,o=n?1/n:0;return s[0]=-i*o,s[1]=-h*o,s[2]=-e*o,s[3]=r*o,s}invert(t=(U.ALWAYS_COPY?Y():this)){const s=this[0],i=this[1],h=this[2],e=this[3],r=s*s+i*i+h*h+e*e,n=r?1/r:0;return t[0]=-s*n,t[1]=-i*n,t[2]=-h*n,t[3]=e*n,t}static conjugate(t,s=Y()){return s[0]=-t[0],s[1]=-t[1],s[2]=-t[2],s[3]=t[3],s}conjugate(t=(U.ALWAYS_COPY?Y():this)){return t[0]=-this[0],t[1]=-this[1],t[2]=-this[2],t[3]=this[3],t}static fromMat3(t,s=Y()){const i=t[0]+t[4]+t[8];let h;if(i>0)h=Math.sqrt(i+1),s[3]=.5*h,h=.5/h,s[0]=(t[5]-t[7])*h,s[1]=(t[6]-t[2])*h,s[2]=(t[1]-t[3])*h;else{let i=0;t[4]>t[0]&&(i=1),t[8]>t[3*i+i]&&(i=2);let e=(i+1)%3,r=(i+2)%3;h=Math.sqrt(t[3*i+i]-t[3*e+e]-t[3*r+r]+1),s[i]=.5*h,h=.5/h,s[3]=(t[3*e+r]-t[3*r+e])*h,s[e]=(t[3*e+i]+t[3*i+e])*h,s[r]=(t[3*r+i]+t[3*i+r])*h}return s}static fromEuler(t,s,i,h=U.ANGLE_ORDER,e=Y()){let r=Math.PI/360;i*=r,s*=r;let n=Math.sin(t*=r),o=Math.cos(t),a=Math.sin(s),u=Math.cos(s),c=Math.sin(i),p=Math.cos(i);switch(h){case"xyz":e[0]=n*u*p+o*a*c,e[1]=o*a*p-n*u*c,e[2]=o*u*c+n*a*p,e[3]=o*u*p-n*a*c;break;case"xzy":e[0]=n*u*p-o*a*c,e[1]=o*a*p-n*u*c,e[2]=o*u*c+n*a*p,e[3]=o*u*p+n*a*c;break;case"yxz":e[0]=n*u*p+o*a*c,e[1]=o*a*p-n*u*c,e[2]=o*u*c-n*a*p,e[3]=o*u*p+n*a*c;break;case"yzx":e[0]=n*u*p+o*a*c,e[1]=o*a*p+n*u*c,e[2]=o*u*c-n*a*p,e[3]=o*u*p-n*a*c;break;case"zxy":e[0]=n*u*p-o*a*c,e[1]=o*a*p+n*u*c,e[2]=o*u*c+n*a*p,e[3]=o*u*p-n*a*c;break;case"zyx":e[0]=n*u*p-o*a*c,e[1]=o*a*p+n*u*c,e[2]=o*u*c-n*a*p,e[3]=o*u*p+n*a*c;break;default:throw Error("Unknown angle order "+h)}return e}toString(){return`quat(${this[0]}, ${this[1]}, ${this[2]}, ${this[3]})`}static dot(t,s){return t[0]*s[0]+t[1]*s[1]+t[2]*s[2]+t[3]*s[3]}dot(t){return this[0]*t[0]+this[1]*t[1]+this[2]*t[2]+this[3]*t[3]}equals(t){return Math.abs(w.dot(this,t))>=1-U.EPSILON}static rotationTo(t,s,h=Y()){const e=i.dot(t,s);return e<-.999999?(i.cross(i.unitX,t,w.tmpVec3),w.tmpVec3.len()<1e-6&&i.cross(i.unitY,t,w.tmpVec3),this.fromAxisAngle(w.tmpVec3.normalize(),Math.PI,h)):e>.999999?(h[0]=h[1]=h[2]=0,h[3]=1,h):(i.cross(t,s,w.tmpVec3),h[0]=w.tmpVec3[0],h[1]=w.tmpVec3[1],h[2]=w.tmpVec3[2],h[3]=1+e,h.normalize(h))}static sqlerp(t,s,i,h,e,r=Y()){return w.slerp(t,h,e,w.tmp1),w.slerp(s,i,e,w.tmp2),w.slerp(w.tmp1,w.tmp2,2*e*(1-e),r),r}static setAxes(t,s,i,h=Y()){w.tmpMat3[0]=s[0],w.tmpMat3[3]=s[1],w.tmpMat3[6]=s[2],w.tmpMat3[1]=i[0],w.tmpMat3[4]=i[1],w.tmpMat3[7]=i[2];const e=U.LEFT_HANDED?1:-1;return w.tmpMat3[2]=e*t[0],w.tmpMat3[5]=e*t[1],w.tmpMat3[8]=e*t[2],w.fromMat3(w.tmpMat3,h).normalize()}normalize(t=(U.ALWAYS_COPY?new w:this)){const s=this[0],i=this[1],h=this[2],e=this[3];let r=s*s+i*i+h*h+e*e;return r>0&&(r=1/Math.sqrt(r)),t[0]=s*r,t[1]=i*r,t[2]=h*r,t[3]=e*r,t}static quatLookAt(s,h,e=new w){const r=i(s[0],s[1],s[2]).normalize(),n=t.cross(r,h).normalize(),o=t.cross(n,r),a=new p,u=U.LEFT_HANDED?1:-1;return a[0]=n[0],a[1]=o[0],a[2]=u*r[0],a[3]=n[1],a[4]=o[1],a[5]=u*r[1],a[6]=n[2],a[7]=o[2],a[8]=u*r[2],w.fromMat3(a,e)}pitch(){const t=this[0],s=this[1],i=this[2],h=this[3];return Math.atan2(2*(s*i+h*t),h*h-t*t-s*s+i*i)}yaw(){return Math.asin(Math.min(Math.max(-2*(this[0]*this[2]-this[3]*this[1]),-1),1))}roll(){const t=this[0],s=this[1],i=this[2],h=this[3];return Math.atan2(2*(t*s+h*i),h*h+t*t-s*s-i*i)}eulerAngles(s=new t){return s[0]=this.pitch(),s[1]=this.yaw(),s[2]=this.roll(),s}toMat3(t=new p){const s=this[0],i=this[1],h=this[2],e=this[3],r=s+s,n=i+i,o=h+h,a=s*r,u=s*n,c=s*o,l=i*n,m=i*o,M=h*o,y=e*r,f=e*n,A=e*o;return t[0]=1-(l+M),t[1]=u+A,t[2]=c-f,t[3]=u-A,t[4]=1-(a+M),t[5]=m+y,t[6]=c+f,t[7]=m-y,t[8]=1-(a+l),t}toMat4(t=new y){const s=this[0],i=this[1],h=this[2],e=this[3],r=s+s,n=i+i,o=h+h,a=s*r,u=s*n,c=s*o,p=i*n,l=i*o,m=h*o,M=e*r,f=e*n,A=e*o;return t[0]=1-(p+m),t[1]=u+A,t[2]=c-f,t[3]=0,t[4]=u-A,t[5]=1-(a+m),t[6]=l+M,t[7]=0,t[8]=c+f,t[9]=l-M,t[10]=1-(a+p),t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}}w.tmpVec3=i(),w.tmp1=new w,w.tmp2=new w,w.tmpMat3=new p,w.getAngle=w.angle,w.prototype.mult=w.prototype.multiply,w.prototype.mul=w.prototype.multiply,w.prototype.scale=w.prototype.multiply,w.prototype.times=w.prototype.multiply,w.prototype.str=w.prototype.toString;const Y=Object.assign((t=0,s=0,i=0,h=1)=>new w(t,s,i,h),w);class O extends Float32Array{static get identity(){return new O(0,0,0,1,0,0,0,0)}static get Identity(){return new O(0,0,0,1,0,0,0,0)}static get IDENTITY(){return new O(0,0,0,1,0,0,0,0)}constructor(t=0,s=0,i=0,h=1,e=0,r=0,n=0,o=0){super(8),this.multiply=(t,s=(U.ALWAYS_COPY?new O:this))=>{const i=this[0],h=this[1],e=this[2],r=this[3],n=t[4],o=t[5],a=t[6],u=t[7],c=this[4],p=this[5],l=this[6],m=this[7],M=t[0],y=t[1],f=t[2],A=t[3];return s[0]=i*A+r*M+h*f-e*y,s[1]=h*A+r*y+e*M-i*f,s[2]=e*A+r*f+i*y-h*M,s[3]=r*A-i*M-h*y-e*f,s[4]=i*u+r*n+h*a-e*o+c*A+m*M+p*f-l*y,s[5]=h*u+r*o+e*n-i*a+p*A+m*y+l*M-c*f,s[6]=e*u+r*a+i*o-h*n+l*A+m*f+c*y-p*M,s[7]=r*u-i*n-h*o-e*a+m*A-c*M-p*y-l*f,s},this[0]=t,this[1]=s,this[2]=i,this[3]=h,this[4]=e,this[5]=r,this[6]=n,this[7]=o}getReal(t=new w){return t[0]=this[0],t[1]=this[1],t[2]=this[2],t[3]=this[3],t}getDual(t=new w){return t[0]=this[4],t[1]=this[5],t[2]=this[6],t[3]=this[7],t}setReal(t){return this[0]=t[0],this[1]=t[1],this[2]=t[2],this[3]=t[3],this}setDual(t){return this[4]=t[0],this[5]=t[1],this[6]=t[2],this[7]=t[3],this}getTranslation(s=new t){const i=this[4],h=this[5],e=this[6],r=this[7],n=-this[0],o=-this[1],a=-this[2],u=this[3];return s[0]=2*(i*u+r*n+h*a-e*o),s[1]=2*(h*u+r*o+e*n-i*a),s[2]=2*(e*u+r*a+i*o-h*n),s}static fromRotationTranslation(t,s,i=new O){const h=.5*s[0],e=.5*s[1],r=.5*s[2],n=t[0],o=t[1],a=t[2],u=t[3];return i[0]=n,i[1]=o,i[2]=a,i[3]=u,i[4]=h*u+e*a-r*o,i[5]=e*u+r*n-h*a,i[6]=r*u+h*o-e*n,i[7]=-h*n-e*o-r*a,i}static fromTranslation(t,s=new O){return s[0]=0,s[1]=0,s[2]=0,s[3]=1,s[4]=.5*t[0],s[5]=.5*t[1],s[6]=.5*t[2],s[7]=0,s}static fromRotation(t,s=new O){return s[0]=t[0],s[1]=t[1],s[2]=t[2],s[3]=t[3],s[4]=0,s[5]=0,s[6]=0,s[7]=0,s}static fromMat4(t,s=new O){const i=t.getRotation(),h=t.getTranslation();return O.fromRotationTranslation(i,h,s)}clone(){return new O(this[0],this[1],this[2],this[3],this[4],this[5],this[6],this[7])}translate(t,s=(U.ALWAYS_COPY?new O:this)){const i=this[0],h=this[1],e=this[2],r=this[3],n=.5*t[0],o=.5*t[1],a=.5*t[2],u=this[4],c=this[5],p=this[6],l=this[7];return s[0]=i,s[1]=h,s[2]=e,s[3]=r,s[4]=r*n+h*a-e*o+u,s[5]=r*o+e*n-i*a+c,s[6]=r*a+i*o-h*n+p,s[7]=-i*n-h*o-e*a+l,s}conjugate(t=(U.ALWAYS_COPY?new O:this)){return t[0]=-this[0],t[1]=-this[1],t[2]=-this[2],t[3]=this[3],t[4]=-this[4],t[5]=-this[5],t[6]=-this[6],t[7]=this[7],t}invert(t=(U.ALWAYS_COPY?new O:this)){const s=this.squaredLength();return t[0]=-this[0]/s,t[1]=-this[1]/s,t[2]=-this[2]/s,t[3]=this[3]/s,t[4]=-this[4]/s,t[5]=-this[5]/s,t[6]=-this[6]/s,t[7]=this[7]/s,t}squaredLength(){const t=this[0],s=this[1],i=this[2],h=this[3];return t*t+s*s+i*i+h*h}len(){return Math.sqrt(this.squaredLength())}normalize(t=(U.ALWAYS_COPY?new O:this)){let s=this.squaredLength();if(s>0){s=Math.sqrt(s);const i=this[0]/s,h=this[1]/s,e=this[2]/s,r=this[3]/s,n=this[4],o=this[5],a=this[6],u=this[7],c=i*n+h*o+e*a+r*u;t[0]=i,t[1]=h,t[2]=e,t[3]=r,t[4]=(n-i*c)/s,t[5]=(o-h*c)/s,t[6]=(a-e*c)/s,t[7]=(u-r*c)/s}return t}static dot(t,s){return t[0]*s[0]+t[1]*s[1]+t[2]*s[2]+t[3]*s[3]}static lerp(t,s,i,h=new O){const e=1-i;return O.dot(t,s)<0&&(i=-i),h[0]=t[0]*e+s[0]*i,h[1]=t[1]*e+s[1]*i,h[2]=t[2]*e+s[2]*i,h[3]=t[3]*e+s[3]*i,h[4]=t[4]*e+s[4]*i,h[5]=t[5]*e+s[5]*i,h[6]=t[6]*e+s[6]*i,h[7]=t[7]*e+s[7]*i,h}plus(t,s=(U.ALWAYS_COPY?new O:this)){return s[0]=this[0]+t[0],s[1]=this[1]+t[1],s[2]=this[2]+t[2],s[3]=this[3]+t[3],s[4]=this[4]+t[4],s[5]=this[5]+t[5],s[6]=this[6]+t[6],s[7]=this[7]+t[7],s}scale(t,s=(U.ALWAYS_COPY?new O:this)){return s[0]=this[0]*t,s[1]=this[1]*t,s[2]=this[2]*t,s[3]=this[3]*t,s[4]=this[4]*t,s[5]=this[5]*t,s[6]=this[6]*t,s[7]=this[7]*t,s}equals(t){return n(this[0],t[0])&&n(this[1],t[1])&&n(this[2],t[2])&&n(this[3],t[3])&&n(this[4],t[4])&&n(this[5],t[5])&&n(this[6],t[6])&&n(this[7],t[7])}exactEquals(t){return this[0]===t[0]&&this[1]===t[1]&&this[2]===t[2]&&this[3]===t[3]&&this[4]===t[4]&&this[5]===t[5]&&this[6]===t[6]&&this[7]===t[7]}toString(){const t=(t,s)=>{if(0===t)return"";const i=Math.abs(t),h=1===i&&s?s:`${i}${s}`;return t<0?" - "+h:" + "+h},s=(s,i,h,e)=>((0!==s?""+s:"")+t(i,"i")+t(h,"j")+t(e,"k")).trim().replace(/^\+ /,"")||"0";return`(${s(this[3],this[0],this[1],this[2])}) + ε(${s(this[7],this[4],this[5],this[6])})`}}O.prototype.sqrLen=O.prototype.squaredLength,O.prototype.str=O.prototype.toString,O.prototype.add=O.prototype.plus;const g=Object.assign((t=0,s=0,i=0,h=1,e=0,r=0,n=0,o=0)=>new O(t,s,i,h,e,r,n,o),O);class S extends Float32Array{static get identity(){return new S(1,0,0,1)}static get Identity(){return new S(1,0,0,1)}static get IDENTITY(){return new S(1,0,0,1)}constructor(t=0,s=0,i=0,h=0){super(4),this[0]=t,this[1]=s,this[2]=i,this[3]=h}clone(){return new S(this[0],this[1],this[2],this[3])}transpose(t=(U.ALWAYS_COPY?new S:this)){if(t.exactEquals(this)){const s=t[1];t[1]=t[2],t[2]=s}else t[0]=this[0],t[1]=this[2],t[2]=this[1],t[3]=this[3];return t}invert(t=(U.ALWAYS_COPY?new S:this)){const s=this[0],i=this[1],h=this[2],e=this[3];let r=s*e-h*i;return r?(r=1/r,t[0]=e*r,t[1]=-i*r,t[2]=-h*r,t[3]=s*r,t):null}adjoint(t=(U.ALWAYS_COPY?new S:this)){let s=this[0];return t[0]=this[3],t[1]=-this[1],t[2]=-this[2],t[3]=s,t}determinant(){return this[0]*this[3]-this[2]*this[1]}rotate(t,s=(U.ALWAYS_COPY?new S:this)){const i=this[0],h=this[1],e=this[2],r=this[3],n=Math.sin(t),o=Math.cos(t);return s[0]=i*o+e*n,s[1]=h*o+r*n,s[2]=i*-n+e*o,s[3]=h*-n+r*o,s}scale(t,s=(U.ALWAYS_COPY?new S:this)){const i=t[0],h=t[1];return s[0]=this[0]*i,s[1]=this[1]*i,s[2]=this[2]*h,s[3]=this[3]*h,s}static fromRotation(t,s=new S){const i=Math.sin(t),h=Math.cos(t);return s[0]=h,s[1]=i,s[2]=-i,s[3]=h,s}static fromScaling(t,s=new S){return s[0]=t[0],s[1]=s[2]=0,s[3]=t[1],s}toString(){return`mat2x2(${this[0]}, ${this[1]}, ${this[2]}, ${this[3]})`}frob(){const t=this[0],s=this[1],i=this[2],h=this[3];return Math.sqrt(t*t+s*s+i*i+h*h)}LDU(t=new S,s=new S,i=new S){return t[2]=this[2]/this[0],i[0]=this[0],i[1]=this[1],i[3]=this[3]-t[2]*i[1],[t,s,i]}plus(t,s=(U.ALWAYS_COPY?new S:this)){return s[0]=this[0]+t[0],s[1]=this[1]+t[1],s[2]=this[2]+t[2],s[3]=this[3]+t[3],s}minus(t,s=(U.ALWAYS_COPY?new S:this)){return s[0]=this[0]-t[0],s[1]=this[1]-t[1],s[2]=this[2]-t[2],s[3]=this[3]-t[3],s}multiply(t,s=(U.ALWAYS_COPY?new S:this)){if(t instanceof a)return t.transformMat2(this);const i=this[0],h=this[1],e=this[2],r=this[3],n=t[0],o=t[1],u=t[2],c=t[3];return s[0]=i*n+e*o,s[1]=h*n+r*o,s[2]=i*u+e*c,s[3]=h*u+r*c,s}exactEquals(t){return this[0]===t[0]&&this[1]===t[1]&&this[2]===t[2]&&this[3]===t[3]}equals(t){return n(this[0],t[0])&&n(this[1],t[1])&&n(this[2],t[2])&&n(this[3],t[3])}scaleScalar(t,s=(U.ALWAYS_COPY?new S:this)){return s[0]=this[0]*t,s[1]=this[1]*t,s[2]=this[2]*t,s[3]=this[3]*t,s}}S.prototype.add=S.prototype.plus,S.prototype.sub=S.prototype.minus,S.prototype.subtract=S.prototype.minus,S.prototype.mul=S.prototype.multiply,S.prototype.mult=S.prototype.multiply,S.prototype.times=S.prototype.multiply,S.prototype.multiplyScalar=S.prototype.scaleScalar,S.prototype.str=S.prototype.toString;const b=(...t)=>{const s=new S;let i=0;for(const h of t)if("number"==typeof h)s[i++]=h;else for(const t of h)s[i++]=t;return s};Object.setPrototypeOf(b,S);const L=b,P=L;class d extends Float32Array{static get identity(){return new d(1,0,0,1,0,0)}static get Identity(){return new d(1,0,0,1,0,0)}static get IDENTITY(){return new d(1,0,0,1,0,0)}constructor(t=0,s=0,i=0,h=0,e=0,r=0){super(6),this[0]=t,this[1]=s,this[2]=i,this[3]=h,this[4]=e,this[5]=r}invert(t=(U.ALWAYS_COPY?new d:this)){const s=this[0],i=this[1],h=this[2],e=this[3],r=this[4],n=this[5];let o=s*e-i*h;return o?(o=1/o,t[0]=e*o,t[1]=-i*o,t[2]=-h*o,t[3]=s*o,t[4]=(h*n-e*r)*o,t[5]=(i*r-s*n)*o,t):null}determinant(){return this[0]*this[3]-this[1]*this[2]}rotate(t,s=(U.ALWAYS_COPY?new d:this)){const i=this[0],h=this[1],e=this[2],r=this[3],n=this[4],o=this[5],a=Math.sin(t),u=Math.cos(t);return s[0]=i*u+e*a,s[1]=h*u+r*a,s[2]=i*-a+e*u,s[3]=h*-a+r*u,s[4]=n,s[5]=o,s}scale(t,s=(U.ALWAYS_COPY?new d:this)){const i=this[1],h=this[2],e=this[3],r=this[4],n=this[5],o=t[0],a=t[1];return s[0]=this[0]*o,s[1]=i*o,s[2]=h*a,s[3]=e*a,s[4]=r,s[5]=n,s}translate(t,s=(U.ALWAYS_COPY?new d:this)){const i=this[0],h=this[1],e=this[2],r=this[3],n=this[4],o=this[5],a=t[0],u=t[1];return s[0]=i,s[1]=h,s[2]=e,s[3]=r,s[4]=i*a+e*u+n,s[5]=h*a+r*u+o,s}static fromRotation(t,s=new d){const i=Math.sin(t),h=Math.cos(t);return s[0]=h,s[1]=i,s[2]=-i,s[3]=h,s[4]=s[5]=0,s}static fromScaling(t,s=new d){return s[0]=t[0],s[1]=s[2]=0,s[3]=t[1],s[4]=s[5]=0,s}static fromTranslation(t,s=new d){return s[0]=s[3]=1,s[1]=s[2]=0,s[4]=t[0],s[5]=t[1],s}toString(){return`mat2x3(${this[0]}, ${this[1]},\t${this[2]}, ${this[3]},\t${this[4]}, ${this[5]})`}frob(){return Math.sqrt(this[0]*this[0]+this[1]*this[1]+this[2]*this[2]+this[3]*this[3]+this[4]*this[4]+this[5]*this[5]+1)}plus(t,s=(U.ALWAYS_COPY?new d:this)){return s[0]=this[0]+t[0],s[1]=this[1]+t[1],s[2]=this[2]+t[2],s[3]=this[3]+t[3],s[4]=this[4]+t[4],s[5]=this[5]+t[5],s}minus(t,s=(U.ALWAYS_COPY?new d:this)){return s[0]=this[0]-t[0],s[1]=this[1]-t[1],s[2]=this[2]-t[2],s[3]=this[3]-t[3],s[4]=this[4]-t[4],s[5]=this[5]-t[5],s}multiply(t,s=(U.ALWAYS_COPY?new d:this)){if(t instanceof a)return t.transformMat2x3(this);const i=this[0],h=this[1],e=this[2],r=this[3],n=this[4],o=this[5],u=t[0],c=t[1],p=t[2],l=t[3],m=t[4],M=t[5];return s[0]=i*u+e*c,s[1]=h*u+r*c,s[2]=i*p+e*l,s[3]=h*p+r*l,s[4]=i*m+e*M+n,s[5]=h*m+r*M+o,s}equals(t){return n(this[0],t[0])&&n(this[1],t[1])&&n(this[2],t[2])&&n(this[3],t[3])&&n(this[4],t[4])&&n(this[5],t[5])}exactEquals(t){return this[0]===t[0]&&this[1]===t[1]&&this[2]===t[2]&&this[3]===t[3]&&this[4]===t[4]&&this[5]===t[5]}scaleScalar(t,s=(U.ALWAYS_COPY?new d:this)){return s[0]=this[0]*t,s[1]=this[1]*t,s[2]=this[2]*t,s[3]=this[3]*t,s[4]=this[4]*t,s[5]=this[5]*t,s}clone(){return new d(this[0],this[1],this[2],this[3],this[4],this[5])}}d.prototype.add=d.prototype.plus,d.prototype.sub=d.prototype.minus,d.prototype.subtract=d.prototype.minus,d.prototype.mul=d.prototype.multiply,d.prototype.mult=d.prototype.multiply,d.prototype.times=d.prototype.multiply,d.prototype.str=d.prototype.toString,d.prototype.multiplyScalar=d.prototype.scaleScalar;const _=Object.assign((t=0,s=0,i=0,h=0,e=0,r=0)=>new d(t,s,i,h,e,r),d),W=_;function C(s){if(s instanceof a)return new a;if(s instanceof t)return new t;if(s instanceof h)return new h;if(s instanceof S)return new S;if(s instanceof d)return new d;if(s instanceof p)return new p;if(s instanceof y)return new y;if(s instanceof w)return new w;if(s instanceof O)return new O;if(s instanceof Float32Array)return new Float32Array;throw"unknown type"}function x(t,s,i){if("number"==typeof s)return t(s,0);const h=s,e=i&&i.length===h.length?i:C(h);for(let s=0;s<h.length;++s)e[s]=t(h[s],s);return e}function q(t,s){return x(t=>t/180*Math.PI,t,s)}const $=q,E=q;function D(t,s){return x(t=>t/Math.PI*180,t,s)}const N=D,I=D;function v(t,s){return x(t=>t>=0?Math.round(t):t%.5==0?Math.floor(t):Math.round(t),t,s)}function T(t,s,i,h){return x(t=>Math.min(Math.max(t,s),i),t,h)}function R(t,s){return x(t=>Math.min(Math.max(t,0),1),t,s)}const z=R;function j(t,s,i,h){if("number"==typeof t)return t*(1-i)+s*i;const e=t,r=s,n=h&&h.length===e.length?h:C(e);if(e.length!==r.length)throw`${e.length} length != ${r} length`;for(let t=0;t<e.length;++t)n[t]=e[t]*(1-i)+r[t]*i;return n}const F=j;function Z(t,s,i){if("number"==typeof s&&"number"==typeof t)return s<t?0:1;const h=s,e=i&&i.length===h.length?i:C(h);if("number"==typeof t){for(let s=0;s<h.length;++s)e[s]=h[s]<t?0:1;return e}const r=t;if(h.length!==r.length)throw`${h.length} length != ${r} length`;for(let t=0;t<h.length;++t)e[t]=h[t]<r[t]?0:1;return e}function k(t,s,i,h){if("number"==typeof t&&"number"==typeof i){const h=T((i-t)/(s-t),0,1);return h*h*(3-2*h)}const e=t,r=s;if(e.length!==r.length)throw`${e.length} length != ${r} length`;const n=h&&h.length===e.length?h:C(e);if("number"==typeof i){for(let t=0;t<e.length;++t){const s=e[t],h=T((i-s)/(r[t]-s),0,1);n[t]=h*h*(3-2*h)}return n}const o=i;if(o.length!==e.length)throw`${o.length} length != ${e} length`;for(let t=0;t<e.length;++t){const s=e[t],i=T((o[t]-s)/(r[t]-s),0,1);n[t]=i*i*(3-2*i)}return n}function H(t,s){return x(t=>t-Math.floor(t),t,s)}function V(t,s){return x(t=>t>0?1:t<0?-1:0,t,s)}function X(t,s){return x(t=>Math.abs(t),t,s)}var U={EPSILON:1e-6,RANDOM:Math.random,ANGLE_ORDER:"zyx",ALWAYS_COPY:!0,LEFT_HANDED:!1};export{S as Mat2,d as Mat2x3,p as Mat3,y as Mat4,w as Quat,O as Quat2,a as Vec2,t as Vec3,h as Vec4,X as abs,T as clamp,R as clamp01,U as default,N as deg,D as degrees,H as fract,F as lerp,L as mat2,W as mat2d,P as mat2x2,_ as mat2x3,l as mat3,m as mat3x3,f as mat4,A as mat4x4,j as mix,Y as quat,g as quat2,$ as rad,q as radians,v as round,z as saturate,V as sign,k as smoothstep,Z as step,I as toDegrees,E as toRadians,c as vec2,i as vec3,r as vec4};
|
|
1
|
+
class t extends Float32Array{static get zero(){return i(0,0,0)}static get Zero(){return i(0,0,0)}static get ZERO(){return i(0,0,0)}static get one(){return i(1,1,1)}static get One(){return i(1,1,1)}static get ONE(){return i(1,1,1)}static get unitX(){return i(1,0,0)}static get UnitX(){return i(1,0,0)}static get unitY(){return i(0,1,0)}static get UnitY(){return i(0,1,0)}static get unitZ(){return i(0,0,1)}static get UnitZ(){return i(0,0,1)}constructor(t=0,s=0,i=0){super(3),this[0]=t,this[1]=s,this[2]=i}get x(){return this[0]}set x(t){this[0]=t}get y(){return this[1]}set y(t){this[1]=t}get z(){return this[2]}set z(t){this[2]=t}plus(t,s=(K.ALWAYS_COPY?i():this)){return"number"==typeof t?(s[0]=this[0]+t,s[1]=this[1]+t,s[2]=this[2]+t):(s[0]=this[0]+t[0],s[1]=this[1]+t[1],s[2]=this[2]+t[2]),s}minus(t,s=(K.ALWAYS_COPY?i():this)){return"number"==typeof t?(s[0]=this[0]-t,s[1]=this[1]-t,s[2]=this[2]-t):(s[0]=this[0]-t[0],s[1]=this[1]-t[1],s[2]=this[2]-t[2]),s}mult(t,s=(K.ALWAYS_COPY?i():this)){return"number"==typeof t?(s[0]=this[0]*t,s[1]=this[1]*t,s[2]=this[2]*t):(s[0]=this[0]*t[0],s[1]=this[1]*t[1],s[2]=this[2]*t[2]),s}div(t,s=(K.ALWAYS_COPY?i():this)){return"number"==typeof t?(s[0]=this[0]/t,s[1]=this[1]/t,s[2]=this[2]/t):(s[0]=this[0]/t[0],s[1]=this[1]/t[1],s[2]=this[2]/t[2]),s}invDiv(t,s=(K.ALWAYS_COPY?i():this)){return"number"==typeof t?(s[0]=t/this[0],s[1]=t/this[1],s[2]=t/this[2]):(s[0]=t[0]/this[0],s[1]=t[1]/this[1],s[2]=t[2]/this[2]),s}negate(t=(K.ALWAYS_COPY?i():this)){return t[0]=-this[0],t[1]=-this[1],t[2]=-this[2],t}unaryPlus(t=(K.ALWAYS_COPY?i():this)){return t.equals(this)||(t[0]=this[0],t[1]=this[1],t[2]=this[2]),t}static normalize(t,s=i()){const h=t[0],r=t[1],e=t[2];let n=h*h+r*r+e*e;return n>0&&(n=1/Math.sqrt(n)),s[0]=h*n,s[1]=r*n,s[2]=e*n,s}normalize(t=(K.ALWAYS_COPY?i():this)){const s=this[0],h=this[1],r=this[2];let e=s*s+h*h+r*r;return e>0&&(e=1/Math.sqrt(e)),t[0]=s*e,t[1]=h*e,t[2]=r*e,t}equals(t){return n(this[0],t[0])&&n(this[1],t[1])&&n(this[2],t[2])}exactEquals(t){return this[0]===t[0]&&this[1]===t[1]&&this[2]===t[2]}squaredLength(){const t=this[0],s=this[1],i=this[2];return t*t+s*s+i*i}len(){const t=this[0],s=this[1],i=this[2];return Math.sqrt(t*t+s*s+i*i)}static floor(t,s=i()){return s[0]=Math.floor(t[0]),s[1]=Math.floor(t[1]),s[2]=Math.floor(t[2]),s}static round(t,s=i()){return s[0]=Math.round(t[0]),s[1]=Math.round(t[1]),s[2]=Math.round(t[2]),s}static ceil(t,s=i()){return s[0]=Math.ceil(t[0]),s[1]=Math.ceil(t[1]),s[2]=Math.ceil(t[2]),s}floor(t=(K.ALWAYS_COPY?i():this)){return t[0]=Math.floor(this[0]),t[1]=Math.floor(this[1]),t[2]=Math.floor(this[2]),t}round(t=(K.ALWAYS_COPY?i():this)){return t[0]=Math.round(this[0]),t[1]=Math.round(this[1]),t[2]=Math.round(this[2]),t}ceil(t=(K.ALWAYS_COPY?i():this)){return t[0]=Math.ceil(this[0]),t[1]=Math.ceil(this[1]),t[2]=Math.ceil(this[2]),t}static inverse(t,s=i()){return s[0]=1/t[0],s[1]=1/t[1],s[2]=1/t[2],s}inverse(t=(K.ALWAYS_COPY?i():this)){return t[0]=1/this[0],t[1]=1/this[1],t[2]=1/this[2],t}clone(){return i(this[0],this[1],this[2])}toString(){return`vec3(${this[0]}, ${this[1]}, ${this[2]})`}static random(t=1){const s=2*K.RANDOM()*Math.PI,h=2*K.RANDOM()-1,r=Math.sqrt(1-h*h)*t;return i(Math.cos(s)*r,Math.sin(s)*r,h*t)}static angle(s,i){const h=s[0],r=s[1],e=s[2],n=i[0],o=i[1],a=i[2],u=Math.sqrt((h*h+r*r+e*e)*(n*n+o*o+a*a)),c=u&&t.dot(s,i)/u;return Math.acos(Math.min(Math.max(c,-1),1))}static dot(t,s){return t[0]*s[0]+t[1]*s[1]+t[2]*s[2]}static cross(t,s,h=i()){const r=t[0],e=t[1],n=t[2],o=s[0],a=s[1],u=s[2];return h[0]=e*u-n*a,h[1]=n*o-r*u,h[2]=r*a-e*o,h}static distance(t,s){const i=t[0]-s[0],h=t[1]-s[1],r=t[2]-s[2];return Math.sqrt(i*i+h*h+r*r)}static squaredDistance(t,s){const i=t[0]-s[0],h=t[1]-s[1],r=t[2]-s[2];return i*i+h*h+r*r}static lerp(t,s,h,r=i()){const e=t[0],n=t[1],o=t[2];return r[0]=e+(s[0]-e)*h,r[1]=n+(s[1]-n)*h,r[2]=o+(s[2]-o)*h,r}static slerp(s,h,r,e=i()){const n=Math.acos(Math.min(Math.max(t.dot(s,h),-1),1)),o=Math.sin(n),a=Math.sin((1-r)*n)/o,u=Math.sin(r*n)/o;return e[0]=a*s[0]+u*h[0],e[1]=a*s[1]+u*h[1],e[2]=a*s[2]+u*h[2],e}static max(t,s,h=i()){return h[0]=Math.max(t[0],s[0]),h[1]=Math.max(t[1],s[1]),h[2]=Math.max(t[2],s[2]),h}static min(t,s,h=i()){return h[0]=Math.min(t[0],s[0]),h[1]=Math.min(t[1],s[1]),h[2]=Math.min(t[2],s[2]),h}static clamp(t,s,h,r=i()){const e="number"==typeof s?s:s[1],n="number"==typeof s?s:s[2],o="number"==typeof h?h:h[0],a="number"==typeof h?h:h[1],u="number"==typeof h?h:h[2];return r[0]=Math.min(Math.max(t[0],"number"==typeof s?s:s[0]),o),r[1]=Math.min(Math.max(t[1],e),a),r[2]=Math.min(Math.max(t[2],n),u),r}static mix(t,s,h,r=i()){return"number"==typeof h?(r[0]=t[0]+(s[0]-t[0])*h,r[1]=t[1]+(s[1]-t[1])*h,r[2]=t[2]+(s[2]-t[2])*h):(r[0]=t[0]+(s[0]-t[0])*h[0],r[1]=t[1]+(s[1]-t[1])*h[1],r[2]=t[2]+(s[2]-t[2])*h[2]),r}static smoothstep(t,s,h,r=i()){const e="number"==typeof t?t:t[0],n="number"==typeof t?t:t[1],o="number"==typeof t?t:t[2],a="number"==typeof s?s:s[1],u="number"==typeof s?s:s[2];let c=Math.min(Math.max((h[0]-e)/(("number"==typeof s?s:s[0])-e),0),1),p=Math.min(Math.max((h[1]-n)/(a-n),0),1),l=Math.min(Math.max((h[2]-o)/(u-o),0),1);return r[0]=c*c*(3-2*c),r[1]=p*p*(3-2*p),r[2]=l*l*(3-2*l),r}static rotateX(t,s,h=i.zero,r=i()){const e=t[1]-h[1],n=t[2]-h[2];return r[0]=t[0],r[1]=e*Math.cos(s)-n*Math.sin(s)+h[1],r[2]=e*Math.sin(s)+n*Math.cos(s)+h[2],r}rotateX(t,s=i.zero,h=(K.ALWAYS_COPY?i():this)){const r=this[1]-s[1],e=this[2]-s[2];return h[0]=this[0],h[1]=r*Math.cos(t)-e*Math.sin(t)+s[1],h[2]=r*Math.sin(t)+e*Math.cos(t)+s[2],h}static rotateY(t,s,h=i.zero,r=i()){const e=t[0]-h[0],n=t[2]-h[2];return r[0]=n*Math.sin(s)+e*Math.cos(s)+h[0],r[1]=t[1],r[2]=n*Math.cos(s)-e*Math.sin(s)+h[2],r}rotateY(t,s=i.zero,h=(K.ALWAYS_COPY?i():this)){const r=this[0]-s[0],e=this[2]-s[2];return h[0]=e*Math.sin(t)+r*Math.cos(t)+s[0],h[1]=this[1],h[2]=e*Math.cos(t)-r*Math.sin(t)+s[2],h}static rotateZ(t,s,h=i.zero,r=i()){const e=t[0]-h[0],n=t[1]-h[1];return r[0]=e*Math.cos(s)-n*Math.sin(s)+h[0],r[1]=e*Math.sin(s)+n*Math.cos(s)+h[1],r[2]=t[2],r}rotateZ(t,s=i.zero,h=(K.ALWAYS_COPY?i():this)){const r=this[0]-s[0],e=this[1]-s[1];return h[0]=r*Math.cos(t)-e*Math.sin(t)+s[0],h[1]=r*Math.sin(t)+e*Math.cos(t)+s[1],h[2]=this[2],h}static hermite(t,s,h,r,e,n=i()){const o=e*e,a=o*(2*e-3)+1,u=o*(e-2)+e,c=o*(e-1),p=o*(3-2*e);return n[0]=t[0]*a+s[0]*u+h[0]*c+r[0]*p,n[1]=t[1]*a+s[1]*u+h[1]*c+r[1]*p,n[2]=t[2]*a+s[2]*u+h[2]*c+r[2]*p,n}static bezier(t,s,h,r,e,n=i()){const o=1-e,a=o*o,u=e*e,c=a*o,p=3*e*a,l=3*u*o,m=u*e;return n[0]=t[0]*c+s[0]*p+h[0]*l+r[0]*m,n[1]=t[1]*c+s[1]*p+h[1]*l+r[1]*m,n[2]=t[2]*c+s[2]*p+h[2]*l+r[2]*m,n}static scaleAndAdd(t,s,h,r=i()){return r[0]=t[0]+s[0]*h,r[1]=t[1]+s[1]*h,r[2]=t[2]+s[2]*h,r}static reflect(s,h,r=i()){const e=2*t.dot(h,s);return r[0]=s[0]-e*h[0],r[1]=s[1]-e*h[1],r[2]=s[2]-e*h[2],r}static refract(s,h,r,e=i()){const n=t.dot(h,s),o=1-r*r*(1-n*n);if(o<0)return e[0]=e[1]=e[2]=0,e;const a=r*n+Math.sqrt(o);return e[0]=r*s[0]-a*h[0],e[1]=r*s[1]-a*h[1],e[2]=r*s[2]-a*h[2],e}static faceforward(s,h,r,e=i()){const n=t.dot(r,h)<0?1:-1;return e[0]=s[0]*n,e[1]=s[1]*n,e[2]=s[2]*n,e}static triangleNormal(t,s,h,r=i()){const e=s[0]-t[0],n=s[1]-t[1],o=s[2]-t[2],a=h[0]-t[0],u=h[1]-t[1],c=h[2]-t[2];r[0]=n*c-o*u,r[1]=o*a-e*c,r[2]=e*u-n*a;let p=r[0]*r[0]+r[1]*r[1]+r[2]*r[2];return p>0&&(p=1/Math.sqrt(p),r[0]*=p,r[1]*=p,r[2]*=p),r}static project(s,h,r=i()){const e=t.dot(s,h)/t.dot(h,h);return r[0]=h[0]*e,r[1]=h[1]*e,r[2]=h[2]*e,r}static orientedAngle(s,i,h){const r=t.cross(s,i),e=Math.atan2(r.len(),t.dot(s,i));return t.dot(r,h)<0?-e:e}scaleAndAdd(t,s,h=(K.ALWAYS_COPY?i():this)){return h[0]=this[0]+t[0]*s,h[1]=this[1]+t[1]*s,h[2]=this[2]+t[2]*s,h}abs(t=(K.ALWAYS_COPY?i():this)){return t[0]=Math.abs(this[0]),t[1]=Math.abs(this[1]),t[2]=Math.abs(this[2]),t}clamp(t,s,h=(K.ALWAYS_COPY?i():this)){const r="number"==typeof t?t:t[1],e="number"==typeof t?t:t[2],n="number"==typeof s?s:s[0],o="number"==typeof s?s:s[1],a="number"==typeof s?s:s[2];return h[0]=Math.min(Math.max(this[0],"number"==typeof t?t:t[0]),n),h[1]=Math.min(Math.max(this[1],r),o),h[2]=Math.min(Math.max(this[2],e),a),h}mix(t,s,h=(K.ALWAYS_COPY?i():this)){return"number"==typeof s?(h[0]=this[0]+(t[0]-this[0])*s,h[1]=this[1]+(t[1]-this[1])*s,h[2]=this[2]+(t[2]-this[2])*s):(h[0]=this[0]+(t[0]-this[0])*s[0],h[1]=this[1]+(t[1]-this[1])*s[1],h[2]=this[2]+(t[2]-this[2])*s[2]),h}step(t,s=(K.ALWAYS_COPY?i():this)){return"number"==typeof t?(s[0]=this[0]<t?0:1,s[1]=this[1]<t?0:1,s[2]=this[2]<t?0:1):(s[0]=this[0]<t[0]?0:1,s[1]=this[1]<t[1]?0:1,s[2]=this[2]<t[2]?0:1),s}smoothstep(t,s,h=(K.ALWAYS_COPY?i():this)){const r="number"==typeof t?t:t[0],e="number"==typeof t?t:t[1],n="number"==typeof t?t:t[2],o="number"==typeof s?s:s[1],a="number"==typeof s?s:s[2];let u=Math.min(Math.max((this[0]-r)/(("number"==typeof s?s:s[0])-r),0),1),c=Math.min(Math.max((this[1]-e)/(o-e),0),1),p=Math.min(Math.max((this[2]-n)/(a-n),0),1);return h[0]=u*u*(3-2*u),h[1]=c*c*(3-2*c),h[2]=p*p*(3-2*p),h}fract(t=(K.ALWAYS_COPY?i():this)){return t[0]=this[0]-Math.floor(this[0]),t[1]=this[1]-Math.floor(this[1]),t[2]=this[2]-Math.floor(this[2]),t}sign(t=(K.ALWAYS_COPY?i():this)){return t[0]=this[0]>0?1:this[0]<0?-1:0,t[1]=this[1]>0?1:this[1]<0?-1:0,t[2]=this[2]>0?1:this[2]<0?-1:0,t}saturate(t=(K.ALWAYS_COPY?i():this)){return t[0]=Math.min(Math.max(this[0],0),1),t[1]=Math.min(Math.max(this[1],0),1),t[2]=Math.min(Math.max(this[2],0),1),t}transformMat3(t,s=(K.ALWAYS_COPY?i():this)){const h=this[0],r=this[1],e=this[2];return s[0]=h*t[0]+r*t[3]+e*t[6],s[1]=h*t[1]+r*t[4]+e*t[7],s[2]=h*t[2]+r*t[5]+e*t[8],s}transformMat4(t,s=(K.ALWAYS_COPY?i():this)){const h=this[0],r=this[1],e=this[2];let n=t[3]*h+t[7]*r+t[11]*e+t[15];return n=n||1,s[0]=(t[0]*h+t[4]*r+t[8]*e+t[12])/n,s[1]=(t[1]*h+t[5]*r+t[9]*e+t[13])/n,s[2]=(t[2]*h+t[6]*r+t[10]*e+t[14])/n,s}transformQuat(t,s=(K.ALWAYS_COPY?i():this)){const h=t[0],r=t[1],e=t[2],n=this[0],o=this[1],a=this[2];let u=r*a-e*o,c=e*n-h*a,p=h*o-r*n,l=r*p-e*c,m=e*u-h*p,M=h*c-r*u;const y=2*t[3];return u*=y,c*=y,p*=y,l*=2,m*=2,M*=2,s[0]=n+u+l,s[1]=o+c+m,s[2]=a+p+M,s}}o(t.prototype,3),t.dist=t.distance,t.sqrDist=t.squaredDistance,t.prototype.add=t.prototype.plus,t.prototype.sub=t.prototype.minus,t.prototype.subtract=t.prototype.minus,t.prototype.mul=t.prototype.mult,t.prototype.scale=t.prototype.mult,t.prototype.multiply=t.prototype.mult,t.prototype.times=t.prototype.mult,t.prototype.divide=t.prototype.div,t.prototype.neg=t.prototype.negate,t.prototype.unaryMinus=t.prototype.negate,t.prototype.sqrLen=t.prototype.squaredLength,t.prototype.str=t.prototype.toString,t.prototype.normalized=t.prototype.normalize,t.prototype.transformMat3x3=t.prototype.transformMat3,t.prototype.transformMat4x4=t.prototype.transformMat4;const s=(...s)=>{const i=new t;let h=0;for(const t of s)if("number"==typeof t)i[h++]=t;else for(const s of t)i[h++]=s;return 1==h&&(i[1]=i[2]=i[0]),i};Object.setPrototypeOf(s,t);const i=s;class h extends Float32Array{static get zero(){return e(0,0,0,0)}static get Zero(){return e(0,0,0,0)}static get ZERO(){return e(0,0,0,0)}static get one(){return e(1,1,1,1)}static get One(){return e(1,1,1,1)}static get ONE(){return e(1,1,1,1)}constructor(t=0,s=0,i=0,h=0){super(4),this[0]=t,this[1]=s,this[2]=i,this[3]=h}get x(){return this[0]}set x(t){this[0]=t}get y(){return this[1]}set y(t){this[1]=t}get z(){return this[2]}set z(t){this[2]=t}get w(){return this[3]}set w(t){this[3]=t}plus(t,s=(K.ALWAYS_COPY?e():this)){return"number"==typeof t?(s[0]=this[0]+t,s[1]=this[1]+t,s[2]=this[2]+t,s[3]=this[3]+t):(s[0]=this[0]+t[0],s[1]=this[1]+t[1],s[2]=this[2]+t[2],s[3]=this[3]+t[3]),s}minus(t,s=(K.ALWAYS_COPY?e():this)){return"number"==typeof t?(s[0]=this[0]-t,s[1]=this[1]-t,s[2]=this[2]-t,s[3]=this[3]-t):(s[0]=this[0]-t[0],s[1]=this[1]-t[1],s[2]=this[2]-t[2],s[3]=this[3]-t[3]),s}mult(t,s=(K.ALWAYS_COPY?e():this)){return"number"==typeof t?(s[0]=this[0]*t,s[1]=this[1]*t,s[2]=this[2]*t,s[3]=this[3]*t):(s[0]=this[0]*t[0],s[1]=this[1]*t[1],s[2]=this[2]*t[2],s[3]=this[3]*t[3]),s}div(t,s=(K.ALWAYS_COPY?e():this)){return"number"==typeof t?(s[0]=this[0]/t,s[1]=this[1]/t,s[2]=this[2]/t,s[3]=this[3]/t):(s[0]=this[0]/t[0],s[1]=this[1]/t[1],s[2]=this[2]/t[2],s[3]=this[3]/t[3]),s}invDiv(t,s=(K.ALWAYS_COPY?e():this)){return"number"==typeof t?(s[0]=t/this[0],s[1]=t/this[1],s[2]=t/this[2],s[3]=t/this[3]):(s[0]=t[0]/this[0],s[1]=t[1]/this[1],s[2]=t[2]/this[2],s[3]=t[3]/this[3]),s}negate(t=(K.ALWAYS_COPY?e():this)){return t[0]=-this[0],t[1]=-this[1],t[2]=-this[2],t[3]=-this[3],t}unaryPlus(t=(K.ALWAYS_COPY?e():this)){return t.equals(this)||(t[0]=this[0],t[1]=this[1],t[2]=this[2],t[3]=this[3]),t}static normalize(t,s=e()){const i=t[0],h=t[1],r=t[2],n=t[3];let o=i*i+h*h+r*r+n*n;return o>0&&(o=1/Math.sqrt(o)),s[0]=i*o,s[1]=h*o,s[2]=r*o,s[3]=n*o,s}normalize(t=(K.ALWAYS_COPY?e():this)){const s=this[0],i=this[1],h=this[2],r=this[3];let n=s*s+i*i+h*h+r*r;return n>0&&(n=1/Math.sqrt(n)),t[0]=s*n,t[1]=i*n,t[2]=h*n,t[3]=r*n,t}equals(t){return n(this[0],t[0])&&n(this[1],t[1])&&n(this[2],t[2])&&n(this[3],t[3])}exactEquals(t){return this[0]===t[0]&&this[1]===t[1]&&this[2]===t[2]&&this[3]===t[3]}squaredLength(){const t=this[0],s=this[1],i=this[2],h=this[3];return t*t+s*s+i*i+h*h}len(){const t=this[0],s=this[1],i=this[2],h=this[3];return Math.sqrt(t*t+s*s+i*i+h*h)}floor(t=(K.ALWAYS_COPY?e():this)){return t[0]=Math.floor(this[0]),t[1]=Math.floor(this[1]),t[2]=Math.floor(this[2]),t[3]=Math.floor(this[3]),t}round(t=(K.ALWAYS_COPY?e():this)){return t[0]=Math.round(this[0]),t[1]=Math.round(this[1]),t[2]=Math.round(this[2]),t[3]=Math.round(this[3]),t}ceil(t=(K.ALWAYS_COPY?e():this)){return t[0]=Math.ceil(this[0]),t[1]=Math.ceil(this[1]),t[2]=Math.ceil(this[2]),t[3]=Math.ceil(this[3]),t}inverse(t=(K.ALWAYS_COPY?e():this)){return t[0]=1/this[0],t[1]=1/this[1],t[2]=1/this[2],t[3]=1/this[3],t}clone(){return e(this[0],this[1],this[2],this[3])}toString(){return`vec4(${this[0]}, ${this[1]}, ${this[2]}, ${this[3]})`}static random(t=1,s=e()){let i,h,r,n,o,a,u;u=K.RANDOM(),i=2*u-1,h=(4*K.RANDOM()-2)*Math.sqrt(u*-u+u),o=i*i+h*h,u=K.RANDOM(),r=2*u-1,n=(4*K.RANDOM()-2)*Math.sqrt(u*-u+u),a=r*r+n*n;const c=Math.sqrt((1-o)/a);return s[0]=t*i,s[1]=t*h,s[2]=t*r*c,s[3]=t*n*c,s}static dot(t,s){return t[0]*s[0]+t[1]*s[1]+t[2]*s[2]+t[3]*s[3]}static cross(t,s,i,h=e()){const r=s[0]*i[1]-s[1]*i[0],n=s[0]*i[2]-s[2]*i[0],o=s[0]*i[3]-s[3]*i[0],a=s[1]*i[2]-s[2]*i[1],u=s[1]*i[3]-s[3]*i[1],c=s[2]*i[3]-s[3]*i[2],p=t[0],l=t[1],m=t[2],M=t[3];return h[0]=l*c-m*u+M*a,h[1]=-p*c+m*o-M*n,h[2]=p*u-l*o+M*r,h[3]=-p*a+l*n-m*r,h}static distance(t,s){const i=t[0]-s[0],h=t[1]-s[1],r=t[2]-s[2],e=t[3]-s[3];return Math.sqrt(i*i+h*h+r*r+e*e)}static squaredDistance(t,s){const i=t[0]-s[0],h=t[1]-s[1],r=t[2]-s[2],e=t[3]-s[3];return i*i+h*h+r*r+e*e}static lerp(t,s,i,h=e()){const r=t[0],n=t[1],o=t[2],a=t[3];return h[0]=r+(s[0]-r)*i,h[1]=n+(s[1]-n)*i,h[2]=o+(s[2]-o)*i,h[3]=a+(s[3]-a)*i,h}static max(t,s,i=e()){return i[0]=Math.max(t[0],s[0]),i[1]=Math.max(t[1],s[1]),i[2]=Math.max(t[2],s[2]),i[3]=Math.max(t[3],s[3]),i}static min(t,s,i=e()){return i[0]=Math.min(t[0],s[0]),i[1]=Math.min(t[1],s[1]),i[2]=Math.min(t[2],s[2]),i[3]=Math.min(t[3],s[3]),i}static clamp(t,s,i,h=e()){const r="number"==typeof s?s:s[1],n="number"==typeof s?s:s[2],o="number"==typeof s?s:s[3],a="number"==typeof i?i:i[0],u="number"==typeof i?i:i[1],c="number"==typeof i?i:i[2],p="number"==typeof i?i:i[3];return h[0]=Math.min(Math.max(t[0],"number"==typeof s?s:s[0]),a),h[1]=Math.min(Math.max(t[1],r),u),h[2]=Math.min(Math.max(t[2],n),c),h[3]=Math.min(Math.max(t[3],o),p),h}static mix(t,s,i,h=e()){return"number"==typeof i?(h[0]=t[0]+(s[0]-t[0])*i,h[1]=t[1]+(s[1]-t[1])*i,h[2]=t[2]+(s[2]-t[2])*i,h[3]=t[3]+(s[3]-t[3])*i):(h[0]=t[0]+(s[0]-t[0])*i[0],h[1]=t[1]+(s[1]-t[1])*i[1],h[2]=t[2]+(s[2]-t[2])*i[2],h[3]=t[3]+(s[3]-t[3])*i[3]),h}static smoothstep(t,s,i,h=e()){const r="number"==typeof t?t:t[0],n="number"==typeof t?t:t[1],o="number"==typeof t?t:t[2],a="number"==typeof t?t:t[3],u="number"==typeof s?s:s[1],c="number"==typeof s?s:s[2],p="number"==typeof s?s:s[3];let l=Math.min(Math.max((i[0]-r)/(("number"==typeof s?s:s[0])-r),0),1),m=Math.min(Math.max((i[1]-n)/(u-n),0),1),M=Math.min(Math.max((i[2]-o)/(c-o),0),1),y=Math.min(Math.max((i[3]-a)/(p-a),0),1);return h[0]=l*l*(3-2*l),h[1]=m*m*(3-2*m),h[2]=M*M*(3-2*M),h[3]=y*y*(3-2*y),h}scaleAndAdd(t,s,i=(K.ALWAYS_COPY?e():this)){return i[0]=this[0]+t[0]*s,i[1]=this[1]+t[1]*s,i[2]=this[2]+t[2]*s,i[3]=this[3]+t[3]*s,i}abs(t=(K.ALWAYS_COPY?e():this)){return t[0]=Math.abs(this[0]),t[1]=Math.abs(this[1]),t[2]=Math.abs(this[2]),t[3]=Math.abs(this[3]),t}clamp(t,s,i=(K.ALWAYS_COPY?e():this)){const h="number"==typeof t?t:t[1],r="number"==typeof t?t:t[2],n="number"==typeof t?t:t[3],o="number"==typeof s?s:s[0],a="number"==typeof s?s:s[1],u="number"==typeof s?s:s[2],c="number"==typeof s?s:s[3];return i[0]=Math.min(Math.max(this[0],"number"==typeof t?t:t[0]),o),i[1]=Math.min(Math.max(this[1],h),a),i[2]=Math.min(Math.max(this[2],r),u),i[3]=Math.min(Math.max(this[3],n),c),i}mix(t,s,i=(K.ALWAYS_COPY?e():this)){return"number"==typeof s?(i[0]=this[0]+(t[0]-this[0])*s,i[1]=this[1]+(t[1]-this[1])*s,i[2]=this[2]+(t[2]-this[2])*s,i[3]=this[3]+(t[3]-this[3])*s):(i[0]=this[0]+(t[0]-this[0])*s[0],i[1]=this[1]+(t[1]-this[1])*s[1],i[2]=this[2]+(t[2]-this[2])*s[2],i[3]=this[3]+(t[3]-this[3])*s[3]),i}step(t,s=(K.ALWAYS_COPY?e():this)){return"number"==typeof t?(s[0]=this[0]<t?0:1,s[1]=this[1]<t?0:1,s[2]=this[2]<t?0:1,s[3]=this[3]<t?0:1):(s[0]=this[0]<t[0]?0:1,s[1]=this[1]<t[1]?0:1,s[2]=this[2]<t[2]?0:1,s[3]=this[3]<t[3]?0:1),s}smoothstep(t,s,i=(K.ALWAYS_COPY?e():this)){const h="number"==typeof t?t:t[0],r="number"==typeof t?t:t[1],n="number"==typeof t?t:t[2],o="number"==typeof t?t:t[3],a="number"==typeof s?s:s[1],u="number"==typeof s?s:s[2],c="number"==typeof s?s:s[3];let p=Math.min(Math.max((this[0]-h)/(("number"==typeof s?s:s[0])-h),0),1),l=Math.min(Math.max((this[1]-r)/(a-r),0),1),m=Math.min(Math.max((this[2]-n)/(u-n),0),1),M=Math.min(Math.max((this[3]-o)/(c-o),0),1);return i[0]=p*p*(3-2*p),i[1]=l*l*(3-2*l),i[2]=m*m*(3-2*m),i[3]=M*M*(3-2*M),i}fract(t=(K.ALWAYS_COPY?e():this)){return t[0]=this[0]-Math.floor(this[0]),t[1]=this[1]-Math.floor(this[1]),t[2]=this[2]-Math.floor(this[2]),t[3]=this[3]-Math.floor(this[3]),t}sign(t=(K.ALWAYS_COPY?e():this)){return t[0]=this[0]>0?1:this[0]<0?-1:0,t[1]=this[1]>0?1:this[1]<0?-1:0,t[2]=this[2]>0?1:this[2]<0?-1:0,t[3]=this[3]>0?1:this[3]<0?-1:0,t}saturate(t=(K.ALWAYS_COPY?e():this)){return t[0]=Math.min(Math.max(this[0],0),1),t[1]=Math.min(Math.max(this[1],0),1),t[2]=Math.min(Math.max(this[2],0),1),t[3]=Math.min(Math.max(this[3],0),1),t}transformMat4(t,s=(K.ALWAYS_COPY?e():this)){const i=this[0],h=this[1],r=this[2],n=this[3];return s[0]=t[0]*i+t[4]*h+t[8]*r+t[12]*n,s[1]=t[1]*i+t[5]*h+t[9]*r+t[13]*n,s[2]=t[2]*i+t[6]*h+t[10]*r+t[14]*n,s[3]=t[3]*i+t[7]*h+t[11]*r+t[15]*n,s}transformQuat(t,s=(K.ALWAYS_COPY?e():this)){const i=t[0],h=t[1],r=t[2],n=this[0],o=this[1],a=this[2];let u=h*a-r*o,c=r*n-i*a,p=i*o-h*n,l=h*p-r*c,m=r*u-i*p,M=i*c-h*u;const y=2*t[3];return u*=y,c*=y,p*=y,l*=2,m*=2,M*=2,s[0]=n+u+l,s[1]=o+c+m,s[2]=a+p+M,s[3]=this[3],s}static scaleAndAdd(t,s,i,h=e()){return h[0]=t[0]+s[0]*i,h[1]=t[1]+s[1]*i,h[2]=t[2]+s[2]*i,h[3]=t[3]+s[3]*i,h}}o(h.prototype,4),h.dist=h.distance,h.sqrDist=h.squaredDistance,h.prototype.add=h.prototype.plus,h.prototype.divide=h.prototype.div,h.prototype.sub=h.prototype.minus,h.prototype.subtract=h.prototype.minus,h.prototype.mul=h.prototype.mult,h.prototype.scale=h.prototype.mult,h.prototype.times=h.prototype.mult,h.prototype.multiply=h.prototype.mult,h.prototype.neg=h.prototype.negate,h.prototype.unaryMinus=h.prototype.negate,h.prototype.sqrLen=h.prototype.squaredLength,h.prototype.str=h.prototype.toString,h.prototype.normalized=h.prototype.normalize,h.prototype.transformMat4x4=h.prototype.transformMat4;const r=(...t)=>{const s=new h;let i=0;for(const h of t)if("number"==typeof h)s[i++]=h;else for(const t of h)s[i++]=t;return 1==i&&(s[1]=s[2]=s[3]=s[0]),s};Object.setPrototypeOf(r,h);const e=r;function n(t,s){return Math.abs(t-s)<=K.EPSILON*Math.max(1,Math.abs(t),Math.abs(s))}function o(s,i=4,r=["xyzw","rgba","stpq","uv"]){for(let e of r)for(let r=2;r<=i;++r){const i="01"+e.substring(0,r);switch(r){case 2:for(let t=0;t<i.length;++t)for(let h=0;h<i.length;++h){const r=`${i[t]}${i[h]}`;/^[01]/.test(r)||Object.prototype.hasOwnProperty.call(s,r)||Object.defineProperty(s,r,{get(){return new a(t<2?t:this[t-2],h<2?h:this[h-2])}})}break;case 3:for(let h=0;h<i.length;++h)for(let r=0;r<i.length;++r)for(let e=0;e<i.length;++e){const n=`${i[h]}${i[r]}${i[e]}`;/^[01]/.test(n)||Object.prototype.hasOwnProperty.call(s,n)||Object.defineProperty(s,n,{get(){return new t(h<2?h:this[h-2],r<2?r:this[r-2],e<2?e:this[e-2])}})}break;case 4:for(let t=0;t<i.length;++t)for(let r=0;r<i.length;++r)for(let e=0;e<i.length;++e)for(let n=0;n<i.length;++n){const o=`${i[t]}${i[r]}${i[e]}${i[n]}`;/^[01]/.test(o)||Object.prototype.hasOwnProperty.call(s,o)||Object.defineProperty(s,o,{get(){return new h(t<2?t:this[t-2],r<2?r:this[r-2],e<2?e:this[e-2],n<2?n:this[n-2])}})}}}}class a extends Float32Array{static get zero(){return c(0,0)}static get Zero(){return c(0,0)}static get ZERO(){return c(0,0)}static get one(){return c(1,1)}static get One(){return c(1,1)}static get ONE(){return c(1,1)}constructor(t=0,s=0){super(2),this[0]=t,this[1]=s}get x(){return this[0]}set x(t){this[0]=t}get y(){return this[1]}set y(t){this[1]=t}plus(t,s=(K.ALWAYS_COPY?c():this)){return"number"==typeof t?(s[0]=this[0]+t,s[1]=this[1]+t):(s[0]=this[0]+t[0],s[1]=this[1]+t[1]),s}minus(t,s=(K.ALWAYS_COPY?c():this)){return"number"==typeof t?(s[0]=this[0]-t,s[1]=this[1]-t):(s[0]=this[0]-t[0],s[1]=this[1]-t[1]),s}mult(t,s=(K.ALWAYS_COPY?c():this)){return"number"==typeof t?(s[0]=this[0]*t,s[1]=this[1]*t):(s[0]=this[0]*t[0],s[1]=this[1]*t[1]),s}div(t,s=(K.ALWAYS_COPY?c():this)){return"number"==typeof t?(s[0]=this[0]/t,s[1]=this[1]/t):(s[0]=this[0]/t[0],s[1]=this[1]/t[1]),s}invDiv(t,s=(K.ALWAYS_COPY?c():this)){return"number"==typeof t?(s[0]=t/this[0],s[1]=t/this[1]):(s[0]=t[0]/this[0],s[1]=t[1]/this[1]),s}rem(t,s=(K.ALWAYS_COPY?c():this)){return"number"==typeof t?(s[0]=this[0]%t,s[1]=this[1]%t):(s[0]=this[0]%t[0],s[1]=this[1]%t[1]),s}negate(t=(K.ALWAYS_COPY?c():this)){return t[0]=-this[0],t[1]=-this[1],t}unaryPlus(t=(K.ALWAYS_COPY?c():this)){return t.equals(this)||(t[0]=this[0],t[1]=this[1]),t}static normalize(t,s=c()){const i=t[0],h=t[1];let r=i*i+h*h;return r>0&&(r=1/Math.sqrt(r)),s[0]=i*r,s[1]=h*r,s}normalize(t=(K.ALWAYS_COPY?c():this)){const s=this[0],i=this[1];let h=s*s+i*i;return h>0&&(h=1/Math.sqrt(h)),t[0]=s*h,t[1]=i*h,t}equals(t){return n(this[0],t[0])&&n(this[1],t[1])}exactEquals(t){return this[0]===t[0]&&this[1]===t[1]}squaredLength(){const t=this[0],s=this[1];return t*t+s*s}len(){const t=this[0],s=this[1];return Math.sqrt(t*t+s*s)}floor(t=(K.ALWAYS_COPY?c():this)){return t[0]=Math.floor(this[0]),t[1]=Math.floor(this[1]),t}round(t=(K.ALWAYS_COPY?c():this)){return t[0]=Math.round(this[0]),t[1]=Math.round(this[1]),t}ceil(t=(K.ALWAYS_COPY?c():this)){return t[0]=Math.ceil(this[0]),t[1]=Math.ceil(this[1]),t}inverse(t=(K.ALWAYS_COPY?c():this)){return t[0]=1/this[0],t[1]=1/this[1],t}clone(){return c(this[0],this[1])}rotate(t=0,s=c.zero,i=(K.ALWAYS_COPY?c():this)){const h=this[0]-s[0],r=this[1]-s[1],e=Math.sin(t),n=Math.cos(t);return i[0]=h*n-r*e+s[0],i[1]=h*e+r*n+s[1],i}toString(){return`vec2(${this[0]}, ${this[1]})`}static random(t=1,s=c()){const i=2*K.RANDOM()*Math.PI;return s[0]=Math.cos(i)*t,s[1]=Math.sin(i)*t,s}static angle(t,s){const i=t[0],h=t[1],r=s[0],e=s[1];return Math.abs(Math.atan2(h*r-i*e,i*r+h*e))}static signedAngle(t,s){const i=t[0],h=t[1],r=s[0],e=s[1];return Math.atan2(i*e-h*r,i*r+h*e)}static dot(t,s){return t[0]*s[0]+t[1]*s[1]}dot(t){return this[0]*t[0]+this[1]*t[1]}static cross(s,i,h=new t){return h[0]=h[1]=0,h[2]=s[0]*i[1]-s[1]*i[0],h}static distance(t,s){const i=t[0]-s[0],h=t[1]-s[1];return Math.sqrt(i*i+h*h)}static squaredDistance(t,s){const i=t[0]-s[0],h=t[1]-s[1];return i*i+h*h}static lerp(t,s,i,h=c()){const r=t[0],e=t[1];return h[0]=r+(s[0]-r)*i,h[1]=e+(s[1]-e)*i,h}static max(t,s,i=c()){return i[0]=Math.max(t[0],s[0]),i[1]=Math.max(t[1],s[1]),i}static min(t,s,i=c()){return i[0]=Math.min(t[0],s[0]),i[1]=Math.min(t[1],s[1]),i}static clamp(t,s,i,h=c()){if("number"==typeof s&&"number"==typeof i)h[0]=Math.min(Math.max(t[0],s),i),h[1]=Math.min(Math.max(t[1],s),i);else{const r="number"==typeof s?s:s[1],e="number"==typeof i?i:i[0],n="number"==typeof i?i:i[1];h[0]=Math.min(Math.max(t[0],"number"==typeof s?s:s[0]),e),h[1]=Math.min(Math.max(t[1],r),n)}return h}static mix(t,s,i,h=c()){return"number"==typeof i?(h[0]=t[0]+(s[0]-t[0])*i,h[1]=t[1]+(s[1]-t[1])*i):(h[0]=t[0]+(s[0]-t[0])*i[0],h[1]=t[1]+(s[1]-t[1])*i[1]),h}static smoothstep(t,s,i,h=c()){const r="number"==typeof t?t:t[0],e="number"==typeof t?t:t[1],n="number"==typeof s?s:s[1];let o=Math.min(Math.max((i[0]-r)/(("number"==typeof s?s:s[0])-r),0),1),a=Math.min(Math.max((i[1]-e)/(n-e),0),1);return h[0]=o*o*(3-2*o),h[1]=a*a*(3-2*a),h}scaleAndAdd(t,s,i=(K.ALWAYS_COPY?c():this)){return i[0]=this[0]+t[0]*s,i[1]=this[1]+t[1]*s,i}abs(t=(K.ALWAYS_COPY?c():this)){return t[0]=Math.abs(this[0]),t[1]=Math.abs(this[1]),t}sign(t=(K.ALWAYS_COPY?c():this)){return t[0]=this[0]>0?1:this[0]<0?-1:0,t[1]=this[1]>0?1:this[1]<0?-1:0,t}fract(t=(K.ALWAYS_COPY?c():this)){return t[0]=this[0]-Math.floor(this[0]),t[1]=this[1]-Math.floor(this[1]),t}clamp(t,s,i=(K.ALWAYS_COPY?c():this)){if("number"==typeof t&&"number"==typeof s)i[0]=Math.min(Math.max(this[0],t),s),i[1]=Math.min(Math.max(this[1],t),s);else{const h="number"==typeof t?t:t[1],r="number"==typeof s?s:s[0],e="number"==typeof s?s:s[1];i[0]=Math.min(Math.max(this[0],"number"==typeof t?t:t[0]),r),i[1]=Math.min(Math.max(this[1],h),e)}return i}saturate(t=(K.ALWAYS_COPY?c():this)){return t[0]=Math.min(Math.max(this[0],0),1),t[1]=Math.min(Math.max(this[1],0),1),t}mix(t,s,i=(K.ALWAYS_COPY?c():this)){return"number"==typeof s?(i[0]=this[0]+(t[0]-this[0])*s,i[1]=this[1]+(t[1]-this[1])*s):(i[0]=this[0]+(t[0]-this[0])*s[0],i[1]=this[1]+(t[1]-this[1])*s[1]),i}step(t,s=(K.ALWAYS_COPY?c():this)){return"number"==typeof t?(s[0]=this[0]<t?0:1,s[1]=this[1]<t?0:1):(s[0]=this[0]<t[0]?0:1,s[1]=this[1]<t[1]?0:1),s}smoothstep(t,s,i=(K.ALWAYS_COPY?c():this)){const h="number"==typeof t?t:t[0],r="number"==typeof t?t:t[1],e="number"==typeof s?s:s[1];let n=Math.min(Math.max((this[0]-h)/(("number"==typeof s?s:s[0])-h),0),1),o=Math.min(Math.max((this[1]-r)/(e-r),0),1);return i[0]=n*n*(3-2*n),i[1]=o*o*(3-2*o),i}transformMat2(t,s=(K.ALWAYS_COPY?c():this)){const i=this[0],h=this[1];return s[0]=t[0]*i+t[2]*h,s[1]=t[1]*i+t[3]*h,s}transformMat2x3(t,s=(K.ALWAYS_COPY?c():this)){const i=this[0],h=this[1];return s[0]=t[0]*i+t[2]*h+t[4],s[1]=t[1]*i+t[3]*h+t[5],s}transformMat3(t,s=(K.ALWAYS_COPY?c():this)){const i=this[0],h=this[1];return s[0]=t[0]*i+t[3]*h+t[6],s[1]=t[1]*i+t[4]*h+t[7],s}transformMat4(t,s=(K.ALWAYS_COPY?c():this)){const i=this[0],h=this[1];return s[0]=t[0]*i+t[4]*h+t[12],s[1]=t[1]*i+t[5]*h+t[13],s}static scaleAndAdd(t,s,i,h=c()){return h[0]=t[0]+s[0]*i,h[1]=t[1]+s[1]*i,h}static reflect(t,s,i=c()){const h=a.dot(s,t);return i[0]=t[0]-2*h*s[0],i[1]=t[1]-2*h*s[1],i}}o(a.prototype,2),a.dist=a.distance,a.sqrDist=a.squaredDistance,a.prototype.add=a.prototype.plus,a.prototype.sub=a.prototype.minus,a.prototype.subtract=a.prototype.minus,a.prototype.mul=a.prototype.mult,a.prototype.multiply=a.prototype.mult,a.prototype.scale=a.prototype.mult,a.prototype.times=a.prototype.mult,a.prototype.divide=a.prototype.div,a.prototype.neg=a.prototype.negate,a.prototype.unaryMinus=a.prototype.negate,a.prototype.sqrLen=a.prototype.squaredLength,a.prototype.str=a.prototype.toString,a.prototype.lerpV=a.prototype.mix,a.prototype.normalized=a.prototype.normalize,a.prototype.transformMat2x2=a.prototype.transformMat2,a.prototype.transformMat2d=a.prototype.transformMat2x3,a.prototype.transformMat3x3=a.prototype.transformMat3,a.prototype.transformMat4x4=a.prototype.transformMat4;const u=(...t)=>{const s=new a;let i=0;for(const h of t)if("number"==typeof h)s[i++]=h;else for(const t of h)s[i++]=t;return 1==i&&(s[1]=s[0]),s};Object.setPrototypeOf(u,a);const c=u;class p extends Float32Array{static get identity(){return m(1,0,0,0,1,0,0,0,1)}static get Identity(){return m(1,0,0,0,1,0,0,0,1)}static get IDENTITY(){return m(1,0,0,0,1,0,0,0,1)}constructor(t=0,s=0,i=0,h=0,r=0,e=0,n=0,o=0,a=0){super(9),this[0]=t,this[1]=s,this[2]=i,this[3]=h,this[4]=r,this[5]=e,this[6]=n,this[7]=o,this[8]=a}clone(){return m(this[0],this[1],this[2],this[3],this[4],this[5],this[6],this[7],this[8])}transpose(t=(K.ALWAYS_COPY?m():this)){if(t.exactEquals(this)){const s=this[1],i=this[2],h=this[5];t[1]=this[3],t[2]=this[6],t[3]=s,t[5]=this[7],t[6]=i,t[7]=h}else t[0]=this[0],t[1]=this[3],t[2]=this[6],t[3]=this[1],t[4]=this[4],t[5]=this[7],t[6]=this[2],t[7]=this[5],t[8]=this[8];return t}invert(t=(K.ALWAYS_COPY?m():this)){const s=this[0],i=this[1],h=this[2],r=this[3],e=this[4],n=this[5],o=this[6],a=this[7],u=this[8],c=u*e-n*a,p=-u*r+n*o,l=a*r-e*o;let M=s*c+i*p+h*l;return M?(M=1/M,t[0]=c*M,t[1]=(-u*i+h*a)*M,t[2]=(n*i-h*e)*M,t[3]=p*M,t[4]=(u*s-h*o)*M,t[5]=(-n*s+h*r)*M,t[6]=l*M,t[7]=(-a*s+i*o)*M,t[8]=(e*s-i*r)*M,t):null}adjoint(t=(K.ALWAYS_COPY?m():this)){const s=this[0],i=this[1],h=this[2],r=this[3],e=this[4],n=this[5],o=this[6],a=this[7],u=this[8];return t[0]=e*u-n*a,t[1]=h*a-i*u,t[2]=i*n-h*e,t[3]=n*o-r*u,t[4]=s*u-h*o,t[5]=h*r-s*n,t[6]=r*a-e*o,t[7]=i*o-s*a,t[8]=s*e-i*r,t}determinant(){const t=this[3],s=this[4],i=this[5],h=this[6],r=this[7],e=this[8];return this[0]*(e*s-i*r)+this[1]*(-e*t+i*h)+this[2]*(r*t-s*h)}multiply(s,i=(K.ALWAYS_COPY?m():this)){if(s instanceof a)return s.transformMat3(this);if(s instanceof t)return s.transformMat3(this);const h=this[0],r=this[1],e=this[2],n=this[3],o=this[4],u=this[5],c=this[6],p=this[7],l=this[8],M=s[0],y=s[1],f=s[2],A=s[3],Y=s[4],O=s[5],g=s[6],S=s[7],b=s[8];return i[0]=M*h+y*n+f*c,i[1]=M*r+y*o+f*p,i[2]=M*e+y*u+f*l,i[3]=A*h+Y*n+O*c,i[4]=A*r+Y*o+O*p,i[5]=A*e+Y*u+O*l,i[6]=g*h+S*n+b*c,i[7]=g*r+S*o+b*p,i[8]=g*e+S*u+b*l,i}translate(t,s=(K.ALWAYS_COPY?m():this)){const i=this[0],h=this[1],r=this[2],e=this[3],n=this[4],o=this[5],a=this[6],u=this[7],c=this[8],p=t[0],l=t[1];return s[0]=i,s[1]=h,s[2]=r,s[3]=e,s[4]=n,s[5]=o,s[6]=p*i+l*e+a,s[7]=p*h+l*n+u,s[8]=p*r+l*o+c,s}rotate(t,s=(K.ALWAYS_COPY?m():this)){const i=this[0],h=this[1],r=this[2],e=this[3],n=this[4],o=this[5],a=this[6],u=this[7],c=this[8],p=Math.sin(t),l=Math.cos(t);return s[0]=l*i+p*e,s[1]=l*h+p*n,s[2]=l*r+p*o,s[3]=l*e-p*i,s[4]=l*n-p*h,s[5]=l*o-p*r,s[6]=a,s[7]=u,s[8]=c,s}scale(t,s=(K.ALWAYS_COPY?m():this)){const i=t[0],h=t[1];return s[0]=i*this[0],s[1]=i*this[1],s[2]=i*this[2],s[3]=h*this[3],s[4]=h*this[4],s[5]=h*this[5],s[6]=this[6],s[7]=this[7],s[8]=this[8],s}static fromTranslation(t,s=m()){return s[0]=1,s[1]=0,s[2]=0,s[3]=0,s[4]=1,s[5]=0,s[6]=t[0],s[7]=t[1],s[8]=1,s}static fromRotation(t,s=m()){const i=Math.sin(t),h=Math.cos(t);return s[0]=h,s[1]=i,s[2]=0,s[3]=-i,s[4]=h,s[5]=0,s[6]=0,s[7]=0,s[8]=1,s}static fromScaling(t,s=m()){return s[0]=t[0],s[1]=0,s[2]=0,s[3]=0,s[4]=t[1],s[5]=0,s[6]=0,s[7]=0,s[8]=1,s}static fromMat2x3(t,s=m()){return s[0]=t[0],s[1]=t[1],s[2]=0,s[3]=t[2],s[4]=t[3],s[5]=0,s[6]=t[4],s[7]=t[5],s[8]=1,s}static fromQuat(t,s=m()){const i=t[0],h=t[1],r=t[2],e=t[3],n=i+i,o=h+h,a=r+r,u=i*n,c=h*n,p=h*o,l=r*n,M=r*o,y=r*a,f=e*n,A=e*o,Y=e*a;return s[0]=1-p-y,s[3]=c-Y,s[6]=l+A,s[1]=c+Y,s[4]=1-u-y,s[7]=M-f,s[2]=l-A,s[5]=M+f,s[8]=1-u-p,s}static normalFromMat4(t,s=m()){const i=t[0],h=t[1],r=t[2],e=t[3],n=t[4],o=t[5],a=t[6],u=t[7],c=t[8],p=t[9],l=t[10],M=t[11],y=t[12],f=t[13],A=t[14],Y=t[15],O=i*o-h*n,g=i*a-r*n,S=i*u-e*n,b=h*a-r*o,P=h*u-e*o,L=r*u-e*a,d=c*f-p*y,_=c*A-l*y,W=c*Y-M*y,C=p*A-l*f,x=p*Y-M*f,q=l*Y-M*A;let $=O*q-g*x+S*C+b*W-P*_+L*d;return $?($=1/$,s[0]=(o*q-a*x+u*C)*$,s[1]=(a*W-n*q-u*_)*$,s[2]=(n*x-o*W+u*d)*$,s[3]=(r*x-h*q-e*C)*$,s[4]=(i*q-r*W+e*_)*$,s[5]=(h*W-i*x-e*d)*$,s[6]=(f*L-A*P+Y*b)*$,s[7]=(A*S-y*L-Y*g)*$,s[8]=(y*P-f*S+Y*O)*$,s):null}static fromMat4(t,s=m()){return s[0]=t[0],s[1]=t[1],s[2]=t[2],s[3]=t[4],s[4]=t[5],s[5]=t[6],s[6]=t[8],s[7]=t[9],s[8]=t[10],s}static projection(t,s,i=m()){return i[0]=2/t,i[1]=0,i[2]=0,i[3]=0,i[4]=-2/s,i[5]=0,i[6]=-1,i[7]=1,i[8]=1,i}frob(){return Math.sqrt(this[0]*this[0]+this[1]*this[1]+this[2]*this[2]+this[3]*this[3]+this[4]*this[4]+this[5]*this[5]+this[6]*this[6]+this[7]*this[7]+this[8]*this[8])}plus(t,s=(K.ALWAYS_COPY?m():this)){return s[0]=this[0]+t[0],s[1]=this[1]+t[1],s[2]=this[2]+t[2],s[3]=this[3]+t[3],s[4]=this[4]+t[4],s[5]=this[5]+t[5],s[6]=this[6]+t[6],s[7]=this[7]+t[7],s[8]=this[8]+t[8],s}minus(t,s=(K.ALWAYS_COPY?m():this)){return s[0]=this[0]-t[0],s[1]=this[1]-t[1],s[2]=this[2]-t[2],s[3]=this[3]-t[3],s[4]=this[4]-t[4],s[5]=this[5]-t[5],s[6]=this[6]-t[6],s[7]=this[7]-t[7],s[8]=this[8]-t[8],s}scaleScalar(t,s=(K.ALWAYS_COPY?m():this)){return s[0]=this[0]*t,s[1]=this[1]*t,s[2]=this[2]*t,s[3]=this[3]*t,s[4]=this[4]*t,s[5]=this[5]*t,s[6]=this[6]*t,s[7]=this[7]*t,s[8]=this[8]*t,s}multiplyScalarAndAdd(t,s,i=(K.ALWAYS_COPY?m():this)){return i[0]=this[0]+t[0]*s,i[1]=this[1]+t[1]*s,i[2]=this[2]+t[2]*s,i[3]=this[3]+t[3]*s,i[4]=this[4]+t[4]*s,i[5]=this[5]+t[5]*s,i[6]=this[6]+t[6]*s,i[7]=this[7]+t[7]*s,i[8]=this[8]+t[8]*s,i}toString(){return`mat3(${this[0]}, ${this[1]}, ${this[2]},\t${this[3]}, ${this[4]}, ${this[5]},\t${this[6]}, ${this[7]}, ${this[8]})`}exactEquals(t){return this[0]===t[0]&&this[1]===t[1]&&this[2]===t[2]&&this[3]===t[3]&&this[4]===t[4]&&this[5]===t[5]&&this[6]===t[6]&&this[7]===t[7]&&this[8]===t[8]}equals(t){return n(this[0],t[0])&&n(this[1],t[1])&&n(this[2],t[2])&&n(this[3],t[3])&&n(this[4],t[4])&&n(this[5],t[5])&&n(this[6],t[6])&&n(this[7],t[7])&&n(this[8],t[8])}}p.fromMat2d=p.fromMat2x3,p.fromMat4x4=p.fromMat4,p.prototype.add=p.prototype.plus,p.prototype.sub=p.prototype.minus,p.prototype.subtract=p.prototype.minus,p.prototype.mul=p.prototype.multiply,p.prototype.mult=p.prototype.multiply,p.prototype.times=p.prototype.multiply,p.prototype.str=p.prototype.toString,p.prototype.multiplyScalar=p.prototype.scaleScalar;const l=(...t)=>{const s=new p;let i=0;for(const h of t)if("number"==typeof h)s[i++]=h;else for(const t of h)s[i++]=t;return s};Object.setPrototypeOf(l,p);const m=l,M=m;var y;class f extends Float32Array{static get identity(){return Y(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1)}static get Identity(){return Y(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1)}static get IDENTITY(){return Y(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1)}constructor(t=0,s=0,i=0,h=0,r=0,e=0,n=0,o=0,a=0,u=0,c=0,p=0,l=0,m=0,M=0,y=0){super(16),this[0]=t,this[1]=s,this[2]=i,this[3]=h,this[4]=r,this[5]=e,this[6]=n,this[7]=o,this[8]=a,this[9]=u,this[10]=c,this[11]=p,this[12]=l,this[13]=m,this[14]=M,this[15]=y}clone(){return Y(this[0],this[1],this[2],this[3],this[4],this[5],this[6],this[7],this[8],this[9],this[10],this[11],this[12],this[13],this[14],this[15])}transpose(t=(K.ALWAYS_COPY?Y():this)){if(t.exactEquals(this)){const s=this[1],i=this[2],h=this[3],r=this[6],e=this[7],n=this[11];t[1]=this[4],t[2]=this[8],t[3]=this[12],t[4]=s,t[6]=this[9],t[7]=this[13],t[8]=i,t[9]=r,t[11]=this[14],t[12]=h,t[13]=e,t[14]=n}else t[0]=this[0],t[1]=this[4],t[2]=this[8],t[3]=this[12],t[4]=this[1],t[5]=this[5],t[6]=this[9],t[7]=this[13],t[8]=this[2],t[9]=this[6],t[10]=this[10],t[11]=this[14],t[12]=this[3],t[13]=this[7],t[14]=this[11],t[15]=this[15];return t}invert(t=(K.ALWAYS_COPY?Y():this)){const s=this[0],i=this[1],h=this[2],r=this[3],e=this[4],n=this[5],o=this[6],a=this[7],u=this[8],c=this[9],p=this[10],l=this[11],m=this[12],M=this[13],y=this[14],f=this[15],A=s*n-i*e,O=s*o-h*e,g=s*a-r*e,S=i*o-h*n,b=i*a-r*n,P=h*a-r*o,L=u*M-c*m,d=u*y-p*m,_=u*f-l*m,W=c*y-p*M,C=c*f-l*M,x=p*f-l*y;let q=A*x-O*C+g*W+S*_-b*d+P*L;return q?(q=1/q,t[0]=(n*x-o*C+a*W)*q,t[1]=(h*C-i*x-r*W)*q,t[2]=(M*P-y*b+f*S)*q,t[3]=(p*b-c*P-l*S)*q,t[4]=(o*_-e*x-a*d)*q,t[5]=(s*x-h*_+r*d)*q,t[6]=(y*g-m*P-f*O)*q,t[7]=(u*P-p*g+l*O)*q,t[8]=(e*C-n*_+a*L)*q,t[9]=(i*_-s*C-r*L)*q,t[10]=(m*b-M*g+f*A)*q,t[11]=(c*g-u*b-l*A)*q,t[12]=(n*d-e*W-o*L)*q,t[13]=(s*W-i*d+h*L)*q,t[14]=(M*O-m*S-y*A)*q,t[15]=(u*S-c*O+p*A)*q,t):null}adjoint(t=(K.ALWAYS_COPY?Y():this)){const s=this[0],i=this[1],h=this[2],r=this[3],e=this[4],n=this[5],o=this[6],a=this[7],u=this[8],c=this[9],p=this[10],l=this[11],m=this[12],M=this[13],y=this[14],f=this[15],A=s*n-i*e,O=s*o-h*e,g=s*a-r*e,S=i*o-h*n,b=i*a-r*n,P=h*a-r*o,L=u*M-c*m,d=u*y-p*m,_=u*f-l*m,W=c*y-p*M,C=c*f-l*M,x=p*f-l*y;return t[0]=n*x-o*C+a*W,t[1]=h*C-i*x-r*W,t[2]=M*P-y*b+f*S,t[3]=p*b-c*P-l*S,t[4]=o*_-e*x-a*d,t[5]=s*x-h*_+r*d,t[6]=y*g-m*P-f*O,t[7]=u*P-p*g+l*O,t[8]=e*C-n*_+a*L,t[9]=i*_-s*C-r*L,t[10]=m*b-M*g+f*A,t[11]=c*g-u*b-l*A,t[12]=n*d-e*W-o*L,t[13]=s*W-i*d+h*L,t[14]=M*O-m*S-y*A,t[15]=u*S-c*O+p*A,t}determinant(){const t=this[0],s=this[1],i=this[2],h=this[3],r=this[4],e=this[5],n=this[6],o=this[7],a=this[8],u=this[9],c=this[10],p=this[11],l=this[12],m=this[13],M=this[14],y=this[15];return(t*e-s*r)*(c*y-p*M)-(t*n-i*r)*(u*y-p*m)+(t*o-h*r)*(u*M-c*m)+(s*n-i*e)*(a*y-p*l)-(s*o-h*e)*(a*M-c*l)+(i*o-h*n)*(a*m-u*l)}multiply(s,i=(K.ALWAYS_COPY?Y():this)){if(s instanceof a)return s.transformMat4(this);if(s instanceof t)return s.transformMat4(this);if(s instanceof h)return s.transformMat4(this);const r=this[0],e=this[1],n=this[2],o=this[3],u=this[4],c=this[5],p=this[6],l=this[7],m=this[8],M=this[9],y=this[10],f=this[11],A=this[12],O=this[13],g=this[14],S=this[15];let b=s[0],P=s[1],L=s[2],d=s[3];return i[0]=b*r+P*u+L*m+d*A,i[1]=b*e+P*c+L*M+d*O,i[2]=b*n+P*p+L*y+d*g,i[3]=b*o+P*l+L*f+d*S,b=s[4],P=s[5],L=s[6],d=s[7],i[4]=b*r+P*u+L*m+d*A,i[5]=b*e+P*c+L*M+d*O,i[6]=b*n+P*p+L*y+d*g,i[7]=b*o+P*l+L*f+d*S,b=s[8],P=s[9],L=s[10],d=s[11],i[8]=b*r+P*u+L*m+d*A,i[9]=b*e+P*c+L*M+d*O,i[10]=b*n+P*p+L*y+d*g,i[11]=b*o+P*l+L*f+d*S,b=s[12],P=s[13],L=s[14],d=s[15],i[12]=b*r+P*u+L*m+d*A,i[13]=b*e+P*c+L*M+d*O,i[14]=b*n+P*p+L*y+d*g,i[15]=b*o+P*l+L*f+d*S,i}translate(t,s=(K.ALWAYS_COPY?Y():this)){const i=t[0],h=t[1],r=t[2];if(s.exactEquals(this))s[12]=this[0]*i+this[4]*h+this[8]*r+this[12],s[13]=this[1]*i+this[5]*h+this[9]*r+this[13],s[14]=this[2]*i+this[6]*h+this[10]*r+this[14],s[15]=this[3]*i+this[7]*h+this[11]*r+this[15];else{const t=this[0],e=this[1],n=this[2],o=this[3],a=this[4],u=this[5],c=this[6],p=this[7],l=this[8],m=this[9],M=this[10],y=this[11];s[0]=t,s[1]=e,s[2]=n,s[3]=o,s[4]=a,s[5]=u,s[6]=c,s[7]=p,s[8]=l,s[9]=m,s[10]=M,s[11]=y,s[12]=t*i+a*h+l*r+this[12],s[13]=e*i+u*h+m*r+this[13],s[14]=n*i+c*h+M*r+this[14],s[15]=o*i+p*h+y*r+this[15]}return s}scale(t,s=(K.ALWAYS_COPY?Y():this)){const i=t[0],h=t[1],r=t[2];return s[0]=this[0]*i,s[1]=this[1]*i,s[2]=this[2]*i,s[3]=this[3]*i,s[4]=this[4]*h,s[5]=this[5]*h,s[6]=this[6]*h,s[7]=this[7]*h,s[8]=this[8]*r,s[9]=this[9]*r,s[10]=this[10]*r,s[11]=this[11]*r,s[12]=this[12],s[13]=this[13],s[14]=this[14],s[15]=this[15],s}rotate(t,s,i=(K.ALWAYS_COPY?Y():this)){let h=s[0],r=s[1],e=s[2],n=Math.sqrt(h*h+r*r+e*e);if(n<K.EPSILON)return null;n=1/n,h*=n,r*=n,e*=n;const o=Math.sin(t),a=Math.cos(t),u=1-a,c=this[0],p=this[1],l=this[2],m=this[3],M=this[4],y=this[5],f=this[6],A=this[7],O=this[8],g=this[9],S=this[10],b=this[11],P=h*h*u+a,L=r*h*u+e*o,d=e*h*u-r*o,_=h*r*u-e*o,W=r*r*u+a,C=e*r*u+h*o,x=h*e*u+r*o,q=r*e*u-h*o,$=e*e*u+a;return i[0]=c*P+M*L+O*d,i[1]=p*P+y*L+g*d,i[2]=l*P+f*L+S*d,i[3]=m*P+A*L+b*d,i[4]=c*_+M*W+O*C,i[5]=p*_+y*W+g*C,i[6]=l*_+f*W+S*C,i[7]=m*_+A*W+b*C,i[8]=c*x+M*q+O*$,i[9]=p*x+y*q+g*$,i[10]=l*x+f*q+S*$,i[11]=m*x+A*q+b*$,i[12]=this[12],i[13]=this[13],i[14]=this[14],i[15]=this[15],i}rotateX(t,s=(K.ALWAYS_COPY?Y():this)){const i=Math.sin(t),h=Math.cos(t),r=this[4],e=this[5],n=this[6],o=this[7],a=this[8],u=this[9],c=this[10],p=this[11];return s[4]=r*h+a*i,s[5]=e*h+u*i,s[6]=n*h+c*i,s[7]=o*h+p*i,s[8]=a*h-r*i,s[9]=u*h-e*i,s[10]=c*h-n*i,s[11]=p*h-o*i,s.exactEquals(this)||(s[0]=this[0],s[1]=this[1],s[2]=this[2],s[3]=this[3],s[12]=this[12],s[13]=this[13],s[14]=this[14],s[15]=this[15]),s}rotateY(t,s=(K.ALWAYS_COPY?Y():this)){const i=Math.sin(t),h=Math.cos(t),r=this[0],e=this[1],n=this[2],o=this[3],a=this[8],u=this[9],c=this[10],p=this[11];return s[0]=r*h-a*i,s[1]=e*h-u*i,s[2]=n*h-c*i,s[3]=o*h-p*i,s[8]=r*i+a*h,s[9]=e*i+u*h,s[10]=n*i+c*h,s[11]=o*i+p*h,s.exactEquals(this)||(s[4]=this[4],s[5]=this[5],s[6]=this[6],s[7]=this[7],s[12]=this[12],s[13]=this[13],s[14]=this[14],s[15]=this[15]),s}rotateZ(t,s=(K.ALWAYS_COPY?Y():this)){const i=Math.sin(t),h=Math.cos(t),r=this[0],e=this[1],n=this[2],o=this[3],a=this[4],u=this[5],c=this[6],p=this[7];return s[0]=r*h+a*i,s[1]=e*h+u*i,s[2]=n*h+c*i,s[3]=o*h+p*i,s[4]=a*h-r*i,s[5]=u*h-e*i,s[6]=c*h-n*i,s[7]=p*h-o*i,s.exactEquals(this)||(s[8]=this[8],s[9]=this[9],s[10]=this[10],s[11]=this[11],s[12]=this[12],s[13]=this[13],s[14]=this[14],s[15]=this[15]),s}getTranslation(s=new t){return s[0]=this[12],s[1]=this[13],s[2]=this[14],s}getScaling(s=new t){const i=this[0],h=this[1],r=this[2],e=this[4],n=this[5],o=this[6],a=this[8],u=this[9],c=this[10];return s[0]=Math.sqrt(i*i+h*h+r*r),s[1]=Math.sqrt(e*e+n*n+o*o),s[2]=Math.sqrt(a*a+u*u+c*c),s}getRotation(t=new g){const s=this.getScaling(),i=1/s[0],h=1/s[1],r=1/s[2],e=this[0]*i,n=this[1]*h,o=this[2]*r,a=this[4]*i,u=this[5]*h,c=this[6]*r,p=this[8]*i,l=this[9]*h,m=this[10]*r,M=e+u+m;let y=0;return M>0?(y=2*Math.sqrt(M+1),t[3]=.25*y,t[0]=(c-l)/y,t[1]=(p-o)/y,t[2]=(n-a)/y):e>u&&e>m?(y=2*Math.sqrt(1+e-u-m),t[3]=(c-l)/y,t[0]=.25*y,t[1]=(n+a)/y,t[2]=(p+o)/y):u>m?(y=2*Math.sqrt(1+u-e-m),t[3]=(p-o)/y,t[0]=(n+a)/y,t[1]=.25*y,t[2]=(c+l)/y):(y=2*Math.sqrt(1+m-e-u),t[3]=(n-a)/y,t[0]=(p+o)/y,t[1]=(c+l)/y,t[2]=.25*y),t}decompose(s=new g,i=new t,h=new t){i[0]=this[12],i[1]=this[13],i[2]=this[14];const r=this[0],e=this[1],n=this[2],o=this[4],a=this[5],u=this[6],c=this[8],p=this[9],l=this[10];h[0]=Math.sqrt(r*r+e*e+n*n),h[1]=Math.sqrt(o*o+a*a+u*u),h[2]=Math.sqrt(c*c+p*p+l*l);const m=1/h[0],M=1/h[1],y=1/h[2],f=r*m,A=e*M,Y=n*y,O=o*m,S=a*M,b=u*y,P=c*m,L=p*M,d=l*y,_=f+S+d;let W=0;return _>0?(W=2*Math.sqrt(_+1),s[3]=.25*W,s[0]=(b-L)/W,s[1]=(P-Y)/W,s[2]=(A-O)/W):f>S&&f>d?(W=2*Math.sqrt(1+f-S-d),s[3]=(b-L)/W,s[0]=.25*W,s[1]=(A+O)/W,s[2]=(P+Y)/W):S>d?(W=2*Math.sqrt(1+S-f-d),s[3]=(P-Y)/W,s[0]=(A+O)/W,s[1]=.25*W,s[2]=(b+L)/W):(W=2*Math.sqrt(1+d-f-S),s[3]=(A-O)/W,s[0]=(P+Y)/W,s[1]=(b+L)/W,s[2]=.25*W),s}static fromTranslation(t,s=Y()){return s[0]=s[5]=s[10]=s[15]=1,s[1]=s[2]=s[3]=s[4]=s[6]=s[7]=s[8]=s[9]=s[11]=0,s[12]=t[0],s[13]=t[1],s[14]=t[2],s}static fromScaling(t,s=Y()){return s[0]=t[0],s[5]=t[1],s[10]=t[2],s[1]=s[2]=s[3]=s[4]=s[6]=s[7]=s[8]=s[9]=s[11]=s[12]=s[13]=s[14]=0,s[15]=1,s}static fromRotation(t,s,i=Y()){let h=s[0],r=s[1],e=s[2],n=Math.sqrt(h*h+r*r+e*e);if(n<K.EPSILON)return null;n=1/n,h*=n,r*=n,e*=n;const o=Math.sin(t),a=Math.cos(t),u=1-a;return i[0]=h*h*u+a,i[1]=r*h*u+e*o,i[2]=e*h*u-r*o,i[3]=0,i[4]=h*r*u-e*o,i[5]=r*r*u+a,i[6]=e*r*u+h*o,i[7]=0,i[8]=h*e*u+r*o,i[9]=r*e*u-h*o,i[10]=e*e*u+a,i[11]=0,i[12]=i[13]=i[14]=0,i[15]=1,i}static fromXRotation(t,s=Y()){const i=Math.sin(t),h=Math.cos(t);return s[0]=1,s[1]=s[2]=s[3]=s[4]=s[7]=s[8]=s[11]=s[12]=s[13]=s[14]=0,s[5]=h,s[6]=i,s[9]=-i,s[10]=h,s[15]=1,s}static fromYRotation(t,s=Y()){const i=Math.sin(t),h=Math.cos(t);return s[0]=h,s[1]=s[3]=s[4]=s[6]=s[7]=s[9]=s[11]=s[12]=s[13]=s[14]=0,s[2]=-i,s[5]=s[15]=1,s[8]=i,s[10]=h,s}static fromZRotation(t,s=Y()){const i=Math.sin(t),h=Math.cos(t);return s[0]=h,s[1]=i,s[4]=-i,s[5]=h,s[2]=s[3]=s[6]=s[7]=s[8]=s[9]=s[11]=s[12]=s[13]=s[14]=0,s[10]=s[15]=1,s}static fromRotationTranslation(t,s,i=Y()){const h=t[0],r=t[1],e=t[2],n=t[3],o=h+h,a=r+r,u=e+e,c=h*o,p=h*a,l=h*u,m=r*a,M=r*u,y=e*u,f=n*o,A=n*a,O=n*u;return i[0]=1-(m+y),i[1]=p+O,i[2]=l-A,i[3]=i[7]=i[11]=0,i[4]=p-O,i[5]=1-(c+y),i[6]=M+f,i[8]=l+A,i[9]=M-f,i[10]=1-(c+m),i[12]=s[0],i[13]=s[1],i[14]=s[2],i[15]=1,i}static fromRotationTranslationScale(t,s,i,h=Y()){const r=t[0],e=t[1],n=t[2],o=t[3],a=r+r,u=e+e,c=n+n,p=r*a,l=r*u,m=r*c,M=e*u,y=e*c,f=n*c,A=o*a,O=o*u,g=o*c,S=i[0],b=i[1],P=i[2];return h[0]=(1-(M+f))*S,h[1]=(l+g)*S,h[2]=(m-O)*S,h[3]=h[7]=h[11]=0,h[4]=(l-g)*b,h[5]=(1-(p+f))*b,h[6]=(y+A)*b,h[8]=(m+O)*P,h[9]=(y-A)*P,h[10]=(1-(p+M))*P,h[12]=s[0],h[13]=s[1],h[14]=s[2],h[15]=1,h}static fromRotationTranslationScaleOrigin(t,s,i,h,r=Y()){const e=t[0],n=t[1],o=t[2],a=t[3],u=e+e,c=n+n,p=o+o,l=e*u,m=e*c,M=e*p,y=n*c,f=n*p,A=o*p,O=a*u,g=a*c,S=a*p,b=i[0],P=i[1],L=i[2],d=h[0],_=h[1],W=h[2],C=(1-(y+A))*b,x=(m+S)*b,q=(M-g)*b,$=(m-S)*P,E=(1-(l+A))*P,w=(f+O)*P,D=(M+g)*L,z=(f-O)*L,N=(1-(l+y))*L;return r[0]=C,r[1]=x,r[2]=q,r[4]=$,r[5]=E,r[6]=w,r[8]=D,r[9]=z,r[10]=N,r[3]=r[7]=r[11]=0,r[12]=s[0]+d-(C*d+$*_+D*W),r[13]=s[1]+_-(x*d+E*_+z*W),r[14]=s[2]+W-(q*d+w*_+N*W),r[15]=1,r}static fromQuat(t,s=Y()){const i=t[0],h=t[1],r=t[2],e=t[3],n=i+i,o=h+h,a=r+r,u=i*n,c=h*n,p=h*o,l=r*n,m=r*o,M=r*a,y=e*n,f=e*o,A=e*a;return s[0]=1-p-M,s[1]=c+A,s[2]=l-f,s[4]=c-A,s[5]=1-u-M,s[6]=m+y,s[8]=l+f,s[9]=m-y,s[10]=1-u-p,s[3]=s[7]=s[11]=s[12]=s[13]=s[14]=0,s[15]=1,s}static frustum(t,s,i,h,r,e,n=Y()){const o=1/(s-t),a=1/(h-i),u=1/(r-e),c=K.LEFT_HANDED;return n[0]=2*r*o,n[5]=2*r*a,n[8]=(s+t)*o,n[9]=(h+i)*a,n[10]=c?-(e+r)*u:(e+r)*u,n[11]=c?1:-1,n[1]=n[2]=n[3]=n[4]=n[6]=n[7]=n[12]=n[13]=n[15]=0,n[14]=e*r*2*u,n}static perspectiveNO(t,s,i,h,r=Y()){const e=1/Math.tan(t/2),n=K.LEFT_HANDED;if(r[0]=e/s,r[1]=r[2]=r[3]=r[4]=r[6]=r[7]=r[8]=r[9]=r[12]=r[13]=r[15]=0,r[5]=e,r[11]=n?1:-1,null!=h&&h!==1/0){const t=1/(i-h);r[10]=n?-(h+i)*t:(h+i)*t,r[14]=2*h*i*t}else r[10]=n?1:-1,r[14]=-2*i;return r}static perspectiveZO(t,s,i,h,r=Y()){const e=1/Math.tan(t/2),n=K.LEFT_HANDED;if(r[0]=e/s,r[1]=0,r[2]=0,r[3]=0,r[4]=0,r[5]=e,r[6]=0,r[7]=0,r[8]=0,r[9]=0,r[11]=n?1:-1,r[12]=0,r[13]=0,r[15]=0,null!=h&&h!==1/0){const t=1/(i-h);r[10]=n?-h*t:h*t,r[14]=h*i*t}else r[10]=n?1:-1,r[14]=-i;return r}static perspectiveFromFieldOfView(t,s,i,h=Y()){const r=Math.tan(t.upDegrees*Math.PI/180),e=Math.tan(t.downDegrees*Math.PI/180),n=Math.tan(t.leftDegrees*Math.PI/180),o=Math.tan(t.rightDegrees*Math.PI/180),a=2/(n+o),u=2/(r+e);h[0]=a,h[1]=0,h[2]=0,h[3]=0,h[4]=0,h[5]=u,h[6]=0,h[7]=0;const c=K.LEFT_HANDED;return h[8]=-(n-o)*a*.5,h[9]=(r-e)*u*.5,h[10]=c?-i/(s-i):i/(s-i),h[11]=c?1:-1,h[12]=0,h[13]=0,h[14]=i*s/(s-i),h[15]=0,h}static orthoNO(t,s,i,h,r,e,n=Y()){const o=1/(t-s),a=1/(i-h),u=1/(r-e),c=K.LEFT_HANDED?-1:1;return n[0]=-2*o,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=-2*a,n[6]=0,n[7]=0,n[8]=0,n[9]=0,n[10]=2*c*u,n[11]=0,n[12]=(t+s)*o,n[13]=(h+i)*a,n[14]=(e+r)*u,n[15]=1,n}static orthoZO(t,s,i,h,r,e,n=Y()){const o=1/(t-s),a=1/(i-h),u=1/(r-e),c=K.LEFT_HANDED?-1:1;return n[0]=-2*o,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=-2*a,n[6]=0,n[7]=0,n[8]=0,n[9]=0,n[10]=c*u,n[11]=0,n[12]=(t+s)*o,n[13]=(h+i)*a,n[14]=r*u,n[15]=1,n}static lookAt(t,s,i,h=Y()){let r,e,n,o,a,u,c,p,l,m;const M=t[0],y=t[1],f=t[2],A=i[0],O=i[1],g=i[2],S=s[0],b=s[1],P=s[2];return t.equals(s)?(h[0]=1,h[1]=0,h[2]=0,h[3]=0,h[4]=0,h[5]=1,h[6]=0,h[7]=0,h[8]=0,h[9]=0,h[10]=1,h[11]=0,h[12]=0,h[13]=0,h[14]=0,h[15]=1,h):(K.LEFT_HANDED?(c=S-M,p=b-y,l=P-f):(c=M-S,p=y-b,l=f-P),m=1/Math.sqrt(c*c+p*p+l*l),c*=m,p*=m,l*=m,r=O*l-g*p,e=g*c-A*l,n=A*p-O*c,m=Math.sqrt(r*r+e*e+n*n),m?(m=1/m,r*=m,e*=m,n*=m):(r=0,e=0,n=0),o=p*n-l*e,a=l*r-c*n,u=c*e-p*r,m=Math.sqrt(o*o+a*a+u*u),m?(m=1/m,o*=m,a*=m,u*=m):(o=0,a=0,u=0),h[0]=r,h[1]=o,h[2]=c,h[3]=0,h[4]=e,h[5]=a,h[6]=p,h[7]=0,h[8]=n,h[9]=u,h[10]=l,h[11]=0,h[12]=-(r*M+e*y+n*f),h[13]=-(o*M+a*y+u*f),h[14]=-(c*M+p*y+l*f),h[15]=1,h)}static targetTo(t,s,i,h=Y()){const r=t[0],e=t[1],n=t[2],o=i[0],a=i[1],u=i[2];let c,p,l;K.LEFT_HANDED?(c=s[0]-r,p=s[1]-e,l=s[2]-n):(c=r-s[0],p=e-s[1],l=n-s[2]);let m=c*c+p*p+l*l;m>0&&(m=1/Math.sqrt(m),c*=m,p*=m,l*=m);let M=a*l-u*p,y=u*c-o*l,f=o*p-a*c;return m=M*M+y*y+f*f,m>0&&(m=1/Math.sqrt(m),M*=m,y*=m,f*=m),h[0]=M,h[1]=y,h[2]=f,h[3]=0,h[4]=p*f-l*y,h[5]=l*M-c*f,h[6]=c*y-p*M,h[7]=0,h[8]=c,h[9]=p,h[10]=l,h[11]=0,h[12]=r,h[13]=e,h[14]=n,h[15]=1,h}static infinitePerspective(t,s,i,h=Y()){const r=1/Math.tan(t/2),e=K.LEFT_HANDED;return h[0]=r/s,h[1]=h[2]=h[3]=h[4]=h[6]=h[7]=h[8]=h[9]=h[12]=h[13]=h[15]=0,h[5]=r,h[10]=e?1:-1,h[11]=e?1:-1,h[14]=-2*i,h}static project(s,i,h,r,e=new t){const n=s[0],o=s[1],a=s[2],u=i[0]*n+i[4]*o+i[8]*a+i[12],c=i[1]*n+i[5]*o+i[9]*a+i[13],p=i[2]*n+i[6]*o+i[10]*a+i[14],l=i[3]*n+i[7]*o+i[11]*a+i[15];let m=h[0]*u+h[4]*c+h[8]*p+h[12]*l,M=h[1]*u+h[5]*c+h[9]*p+h[13]*l,y=h[2]*u+h[6]*c+h[10]*p+h[14]*l,f=h[3]*u+h[7]*c+h[11]*p+h[15]*l;return f=f||1,m/=f,M/=f,y/=f,e[0]=r[0]+r[2]*(.5*m+.5),e[1]=r[1]+r[3]*(.5*M+.5),e[2]=.5*y+.5,e}static unProject(s,i,h,r,e=new t){const n=i[0],o=i[1],a=i[2],u=i[3],c=i[4],p=i[5],l=i[6],m=i[7],M=i[8],y=i[9],f=i[10],A=i[11],O=i[12],g=i[13],S=i[14],b=i[15],P=Y();let L=h[0],d=h[1],_=h[2],W=h[3];P[0]=L*n+d*c+_*M+W*O,P[1]=L*o+d*p+_*y+W*g,P[2]=L*a+d*l+_*f+W*S,P[3]=L*u+d*m+_*A+W*b,L=h[4],d=h[5],_=h[6],W=h[7],P[4]=L*n+d*c+_*M+W*O,P[5]=L*o+d*p+_*y+W*g,P[6]=L*a+d*l+_*f+W*S,P[7]=L*u+d*m+_*A+W*b,L=h[8],d=h[9],_=h[10],W=h[11],P[8]=L*n+d*c+_*M+W*O,P[9]=L*o+d*p+_*y+W*g,P[10]=L*a+d*l+_*f+W*S,P[11]=L*u+d*m+_*A+W*b,L=h[12],d=h[13],_=h[14],W=h[15],P[12]=L*n+d*c+_*M+W*O,P[13]=L*o+d*p+_*y+W*g,P[14]=L*a+d*l+_*f+W*S,P[15]=L*u+d*m+_*A+W*b;const C=P.invert();if(!C)return null;const x=(s[0]-r[0])/r[2]*2-1,q=(s[1]-r[1])/r[3]*2-1,$=2*s[2]-1;let E=C[3]*x+C[7]*q+C[11]*$+C[15];return E=E||1,e[0]=(C[0]*x+C[4]*q+C[8]*$+C[12])/E,e[1]=(C[1]*x+C[5]*q+C[9]*$+C[13])/E,e[2]=(C[2]*x+C[6]*q+C[10]*$+C[14])/E,e}frob(){return Math.sqrt(this[0]*this[0]+this[1]*this[1]+this[2]*this[2]+this[3]*this[3]+this[4]*this[4]+this[5]*this[5]+this[6]*this[6]+this[7]*this[7]+this[8]*this[8]+this[9]*this[9]+this[10]*this[10]+this[11]*this[11]+this[12]*this[12]+this[13]*this[13]+this[14]*this[14]+this[15]*this[15])}plus(t,s=(K.ALWAYS_COPY?Y():this)){return s[0]=this[0]+t[0],s[1]=this[1]+t[1],s[2]=this[2]+t[2],s[3]=this[3]+t[3],s[4]=this[4]+t[4],s[5]=this[5]+t[5],s[6]=this[6]+t[6],s[7]=this[7]+t[7],s[8]=this[8]+t[8],s[9]=this[9]+t[9],s[10]=this[10]+t[10],s[11]=this[11]+t[11],s[12]=this[12]+t[12],s[13]=this[13]+t[13],s[14]=this[14]+t[14],s[15]=this[15]+t[15],s}minus(t,s=(K.ALWAYS_COPY?Y():this)){return s[0]=this[0]-t[0],s[1]=this[1]-t[1],s[2]=this[2]-t[2],s[3]=this[3]-t[3],s[4]=this[4]-t[4],s[5]=this[5]-t[5],s[6]=this[6]-t[6],s[7]=this[7]-t[7],s[8]=this[8]-t[8],s[9]=this[9]-t[9],s[10]=this[10]-t[10],s[11]=this[11]-t[11],s[12]=this[12]-t[12],s[13]=this[13]-t[13],s[14]=this[14]-t[14],s[15]=this[15]-t[15],s}scaleScalar(t,s=(K.ALWAYS_COPY?Y():this)){return s[0]=this[0]*t,s[1]=this[1]*t,s[2]=this[2]*t,s[3]=this[3]*t,s[4]=this[4]*t,s[5]=this[5]*t,s[6]=this[6]*t,s[7]=this[7]*t,s[8]=this[8]*t,s[9]=this[9]*t,s[10]=this[10]*t,s[11]=this[11]*t,s[12]=this[12]*t,s[13]=this[13]*t,s[14]=this[14]*t,s[15]=this[15]*t,s}multiplyScalarAndAdd(t,s,i=(K.ALWAYS_COPY?Y():this)){return i[0]=this[0]+t[0]*s,i[1]=this[1]+t[1]*s,i[2]=this[2]+t[2]*s,i[3]=this[3]+t[3]*s,i[4]=this[4]+t[4]*s,i[5]=this[5]+t[5]*s,i[6]=this[6]+t[6]*s,i[7]=this[7]+t[7]*s,i[8]=this[8]+t[8]*s,i[9]=this[9]+t[9]*s,i[10]=this[10]+t[10]*s,i[11]=this[11]+t[11]*s,i[12]=this[12]+t[12]*s,i[13]=this[13]+t[13]*s,i[14]=this[14]+t[14]*s,i[15]=this[15]+t[15]*s,i}toString(){return`mat4(${this[0]}, ${this[1]}, ${this[2]}, ${this[3]},\t${this[4]}, ${this[5]}, ${this[6]}, ${this[7]},\t${this[8]}, ${this[9]}, ${this[10]}, ${this[11]},\t${this[12]}, ${this[13]}, ${this[14]}, ${this[15]})`}exactEquals(t){return this[0]===t[0]&&this[1]===t[1]&&this[2]===t[2]&&this[3]===t[3]&&this[4]===t[4]&&this[5]===t[5]&&this[6]===t[6]&&this[7]===t[7]&&this[8]===t[8]&&this[9]===t[9]&&this[10]===t[10]&&this[11]===t[11]&&this[12]===t[12]&&this[13]===t[13]&&this[14]===t[14]&&this[15]===t[15]}equals(t){return n(this[0],t[0])&&n(this[1],t[1])&&n(this[2],t[2])&&n(this[3],t[3])&&n(this[4],t[4])&&n(this[5],t[5])&&n(this[6],t[6])&&n(this[7],t[7])&&n(this[8],t[8])&&n(this[9],t[9])&&n(this[10],t[10])&&n(this[11],t[11])&&n(this[12],t[12])&&n(this[13],t[13])&&n(this[14],t[14])&&n(this[15],t[15])}}f.perspective=(y=f).perspectiveNO,f.ortho=y.orthoNO,f.prototype.add=f.prototype.plus,f.prototype.sub=f.prototype.minus,f.prototype.subtract=f.prototype.minus,f.prototype.mul=f.prototype.multiply,f.prototype.mult=f.prototype.multiply,f.prototype.times=f.prototype.multiply,f.prototype.str=f.prototype.toString,f.prototype.multiplyScalar=f.prototype.scaleScalar;const A=(...t)=>{const s=new f;let i=0;for(const h of t)if("number"==typeof h)s[i++]=h;else for(const t of h)s[i++]=t;return s};Object.setPrototypeOf(A,f);const Y=A,O=Y;class g extends Float32Array{static get identity(){return b(0,0,0,1)}static get Identity(){return b(0,0,0,1)}static get IDENTITY(){return b(0,0,0,1)}constructor(t=0,s=0,i=0,h=1){super(4),this[0]=t,this[1]=s,this[2]=i,this[3]=h}multiply(t,s=(K.ALWAYS_COPY?b():this)){if("number"==typeof t)return s[0]=this[0]*t,s[1]=this[1]*t,s[2]=this[2]*t,s[3]=this[3]*t,s;const i=this[0],h=this[1],r=this[2],e=this[3],n=t[0],o=t[1],a=t[2],u=t[3];return s[0]=i*u+e*n+h*a-r*o,s[1]=h*u+e*o+r*n-i*a,s[2]=r*u+e*a+i*o-h*n,s[3]=e*u-i*n-h*o-r*a,s}static fromAxisAngle(t,s,i=b()){const h=Math.sin(s*=.5);return i[0]=h*t[0],i[1]=h*t[1],i[2]=h*t[2],i[3]=Math.cos(s),i}setAxisAngle(t,s,i=(K.ALWAYS_COPY?b():this)){const h=Math.sin(s*=.5);return i[0]=h*t[0],i[1]=h*t[1],i[2]=h*t[2],i[3]=Math.cos(s),i}getAxisAngle(t){const s=2*Math.acos(this[3]),i=Math.sin(s/2);return t&&(i>K.EPSILON?(t[0]=this[0]/i,t[1]=this[1]/i,t[2]=this[2]/i):(t[0]=1,t[1]=t[2]=0)),s}static angle(t,s){const i=g.dot(t,s);return Math.acos(2*i*i-1)}rotateX(t,s=(K.ALWAYS_COPY?b():this)){const i=this[0],h=this[1],r=this[2],e=this[3],n=Math.sin(t*=.5),o=Math.cos(t);return s[0]=i*o+e*n,s[1]=h*o+r*n,s[2]=r*o-h*n,s[3]=e*o-i*n,s}rotateY(t,s=(K.ALWAYS_COPY?b():this)){const i=this[0],h=this[1],r=this[2],e=this[3],n=Math.sin(t*=.5),o=Math.cos(t);return s[0]=i*o-r*n,s[1]=h*o+e*n,s[2]=r*o+i*n,s[3]=e*o-h*n,s}rotateZ(t,s=(K.ALWAYS_COPY?b():this)){const i=this[0],h=this[1],r=this[2],e=this[3],n=Math.sin(t*=.5),o=Math.cos(t);return s[0]=i*o+h*n,s[1]=h*o-i*n,s[2]=r*o+e*n,s[3]=e*o-r*n,s}calculateW(){const t=this[0],s=this[1],i=this[2];return Math.sqrt(Math.abs(1-t*t-s*s-i*i))}static exp(t,s=b()){const i=t[0],h=t[1],r=t[2],e=t[3],n=Math.sqrt(i*i+h*h+r*r),o=Math.exp(e),a=n>0?o*Math.sin(n)/n:0;return s[0]=i*a,s[1]=h*a,s[2]=r*a,s[3]=o*Math.cos(n),s}exp(t=(K.ALWAYS_COPY?b():this)){const s=this[0],i=this[1],h=this[2],r=this[3],e=Math.sqrt(s*s+i*i+h*h),n=Math.exp(r),o=e>0?n*Math.sin(e)/e:0;return t[0]=s*o,t[1]=i*o,t[2]=h*o,t[3]=n*Math.cos(e),t}static ln(t,s=b()){const i=t[0],h=t[1],r=t[2],e=t[3],n=Math.sqrt(i*i+h*h+r*r),o=n>0?Math.atan2(n,e)/n:0;return s[0]=i*o,s[1]=h*o,s[2]=r*o,s[3]=.5*Math.log(i*i+h*h+r*r+e*e),s}ln(t=(K.ALWAYS_COPY?b():this)){const s=this[0],i=this[1],h=this[2],r=this[3],e=Math.sqrt(s*s+i*i+h*h),n=e>0?Math.atan2(e,r)/e:0;return t[0]=s*n,t[1]=i*n,t[2]=h*n,t[3]=.5*Math.log(s*s+i*i+h*h+r*r),t}pow(t){return this.ln(),this.scale(t),this.exp(),this}static slerp(t,s,i,h=b()){let r,e,n,o,a,u=t[0],c=t[1],p=t[2],l=t[3],m=s[0],M=s[1],y=s[2],f=s[3];return e=u*m+c*M+p*y+l*f,e<0&&(e=-e,m=-m,M=-M,y=-y,f=-f),1-e>K.EPSILON?(r=Math.acos(e),n=Math.sin(r),o=Math.sin((1-i)*r)/n,a=Math.sin(i*r)/n):(o=1-i,a=i),h[0]=o*u+a*m,h[1]=o*c+a*M,h[2]=o*p+a*y,h[3]=o*l+a*f,h}slerp(t,s,i=(K.ALWAYS_COPY?b():this)){let h,r,e,n,o,a=this[0],u=this[1],c=this[2],p=this[3],l=t[0],m=t[1],M=t[2],y=t[3];return r=a*l+u*m+c*M+p*y,r<0&&(r=-r,l=-l,m=-m,M=-M,y=-y),1-r>K.EPSILON?(h=Math.acos(r),e=Math.sin(h),n=Math.sin((1-s)*h)/e,o=Math.sin(s*h)/e):(n=1-s,o=s),i[0]=n*a+o*l,i[1]=n*u+o*m,i[2]=n*c+o*M,i[3]=n*p+o*y,i}static random(t=b()){let s=K.RANDOM(),i=K.RANDOM(),h=K.RANDOM(),r=Math.sqrt(1-s),e=Math.sqrt(s);return t[0]=r*Math.sin(2*Math.PI*i),t[1]=r*Math.cos(2*Math.PI*i),t[2]=e*Math.sin(2*Math.PI*h),t[3]=e*Math.cos(2*Math.PI*h),t}static invert(t,s=b()){const i=t[0],h=t[1],r=t[2],e=t[3],n=i*i+h*h+r*r+e*e,o=n?1/n:0;return s[0]=-i*o,s[1]=-h*o,s[2]=-r*o,s[3]=e*o,s}invert(t=(K.ALWAYS_COPY?b():this)){const s=this[0],i=this[1],h=this[2],r=this[3],e=s*s+i*i+h*h+r*r,n=e?1/e:0;return t[0]=-s*n,t[1]=-i*n,t[2]=-h*n,t[3]=r*n,t}static conjugate(t,s=b()){return s[0]=-t[0],s[1]=-t[1],s[2]=-t[2],s[3]=t[3],s}conjugate(t=(K.ALWAYS_COPY?b():this)){return t[0]=-this[0],t[1]=-this[1],t[2]=-this[2],t[3]=this[3],t}static fromMat3(t,s=b()){const i=t[0]+t[4]+t[8];let h;if(i>0)h=Math.sqrt(i+1),s[3]=.5*h,h=.5/h,s[0]=(t[5]-t[7])*h,s[1]=(t[6]-t[2])*h,s[2]=(t[1]-t[3])*h;else{let i=0;t[4]>t[0]&&(i=1),t[8]>t[3*i+i]&&(i=2);let r=(i+1)%3,e=(i+2)%3;h=Math.sqrt(t[3*i+i]-t[3*r+r]-t[3*e+e]+1),s[i]=.5*h,h=.5/h,s[3]=(t[3*r+e]-t[3*e+r])*h,s[r]=(t[3*r+i]+t[3*i+r])*h,s[e]=(t[3*e+i]+t[3*i+e])*h}return s}static fromEuler(t,s,i,h=K.ANGLE_ORDER,r=b()){let e=Math.PI/360;i*=e,s*=e;let n=Math.sin(t*=e),o=Math.cos(t),a=Math.sin(s),u=Math.cos(s),c=Math.sin(i),p=Math.cos(i);switch(h){case"xyz":r[0]=n*u*p+o*a*c,r[1]=o*a*p-n*u*c,r[2]=o*u*c+n*a*p,r[3]=o*u*p-n*a*c;break;case"xzy":r[0]=n*u*p-o*a*c,r[1]=o*a*p-n*u*c,r[2]=o*u*c+n*a*p,r[3]=o*u*p+n*a*c;break;case"yxz":r[0]=n*u*p+o*a*c,r[1]=o*a*p-n*u*c,r[2]=o*u*c-n*a*p,r[3]=o*u*p+n*a*c;break;case"yzx":r[0]=n*u*p+o*a*c,r[1]=o*a*p+n*u*c,r[2]=o*u*c-n*a*p,r[3]=o*u*p-n*a*c;break;case"zxy":r[0]=n*u*p-o*a*c,r[1]=o*a*p+n*u*c,r[2]=o*u*c+n*a*p,r[3]=o*u*p-n*a*c;break;case"zyx":r[0]=n*u*p-o*a*c,r[1]=o*a*p+n*u*c,r[2]=o*u*c-n*a*p,r[3]=o*u*p+n*a*c;break;default:throw Error("Unknown angle order "+h)}return r}toString(){return`quat(${this[0]}, ${this[1]}, ${this[2]}, ${this[3]})`}static dot(t,s){return t[0]*s[0]+t[1]*s[1]+t[2]*s[2]+t[3]*s[3]}dot(t){return this[0]*t[0]+this[1]*t[1]+this[2]*t[2]+this[3]*t[3]}equals(t){return Math.abs(g.dot(this,t))>=1-K.EPSILON}static rotationTo(t,s,h=b()){const r=i.dot(t,s);return r<-.999999?(i.cross(i.unitX,t,g.tmpVec3),g.tmpVec3.len()<1e-6&&i.cross(i.unitY,t,g.tmpVec3),this.fromAxisAngle(g.tmpVec3.normalize(),Math.PI,h)):r>.999999?(h[0]=h[1]=h[2]=0,h[3]=1,h):(i.cross(t,s,g.tmpVec3),h[0]=g.tmpVec3[0],h[1]=g.tmpVec3[1],h[2]=g.tmpVec3[2],h[3]=1+r,h.normalize(h))}static sqlerp(t,s,i,h,r,e=b()){return g.slerp(t,h,r,g.tmp1),g.slerp(s,i,r,g.tmp2),g.slerp(g.tmp1,g.tmp2,2*r*(1-r),e),e}static setAxes(t,s,i,h=b()){g.tmpMat3[0]=s[0],g.tmpMat3[3]=s[1],g.tmpMat3[6]=s[2],g.tmpMat3[1]=i[0],g.tmpMat3[4]=i[1],g.tmpMat3[7]=i[2];const r=K.LEFT_HANDED?1:-1;return g.tmpMat3[2]=r*t[0],g.tmpMat3[5]=r*t[1],g.tmpMat3[8]=r*t[2],g.fromMat3(g.tmpMat3,h).normalize()}static normalize(t,s=b()){const i=t[0],h=t[1],r=t[2],e=t[3];let n=i*i+h*h+r*r+e*e;return n>0&&(n=1/Math.sqrt(n)),s[0]=i*n,s[1]=h*n,s[2]=r*n,s[3]=e*n,s}normalize(t=(K.ALWAYS_COPY?b():this)){return g.normalize(this,t)}static quatLookAt(s,h,r=b()){const e=i(s[0],s[1],s[2]).normalize(),n=t.cross(e,h).normalize(),o=t.cross(n,e),a=new p,u=K.LEFT_HANDED?1:-1;return a[0]=n[0],a[1]=o[0],a[2]=u*e[0],a[3]=n[1],a[4]=o[1],a[5]=u*e[1],a[6]=n[2],a[7]=o[2],a[8]=u*e[2],g.fromMat3(a,r)}pitch(){const t=this[0],s=this[1],i=this[2],h=this[3];return Math.atan2(2*(s*i+h*t),h*h-t*t-s*s+i*i)}yaw(){return Math.asin(Math.min(Math.max(-2*(this[0]*this[2]-this[3]*this[1]),-1),1))}roll(){const t=this[0],s=this[1],i=this[2],h=this[3];return Math.atan2(2*(t*s+h*i),h*h+t*t-s*s-i*i)}eulerAngles(s=new t){return s[0]=this.pitch(),s[1]=this.yaw(),s[2]=this.roll(),s}toMat3(t=new p){const s=this[0],i=this[1],h=this[2],r=this[3],e=s+s,n=i+i,o=h+h,a=s*e,u=s*n,c=s*o,l=i*n,m=i*o,M=h*o,y=r*e,f=r*n,A=r*o;return t[0]=1-(l+M),t[1]=u+A,t[2]=c-f,t[3]=u-A,t[4]=1-(a+M),t[5]=m+y,t[6]=c+f,t[7]=m-y,t[8]=1-(a+l),t}toMat4(t=new f){const s=this[0],i=this[1],h=this[2],r=this[3],e=s+s,n=i+i,o=h+h,a=s*e,u=s*n,c=s*o,p=i*n,l=i*o,m=h*o,M=r*e,y=r*n,A=r*o;return t[0]=1-(p+m),t[1]=u+A,t[2]=c-y,t[3]=0,t[4]=u-A,t[5]=1-(a+m),t[6]=l+M,t[7]=0,t[8]=c+y,t[9]=l-M,t[10]=1-(a+p),t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t}}g.tmpVec3=i(),g.tmp1=new g,g.tmp2=new g,g.tmpMat3=new p,g.getAngle=g.angle,g.prototype.mult=g.prototype.multiply,g.prototype.mul=g.prototype.multiply,g.prototype.scale=g.prototype.multiply,g.prototype.times=g.prototype.multiply,g.prototype.str=g.prototype.toString,g.prototype.normalized=g.prototype.normalize;const S=(t=0,s=0,i=0,h=1)=>new g(t,s,i,h);Object.setPrototypeOf(S,g);const b=S;class P extends Float32Array{static get identity(){return d(0,0,0,1,0,0,0,0)}static get Identity(){return d(0,0,0,1,0,0,0,0)}static get IDENTITY(){return d(0,0,0,1,0,0,0,0)}constructor(t=0,s=0,i=0,h=1,r=0,e=0,n=0,o=0){super(8),this.multiply=(t,s=(K.ALWAYS_COPY?d():this))=>{const i=this[0],h=this[1],r=this[2],e=this[3],n=t[4],o=t[5],a=t[6],u=t[7],c=this[4],p=this[5],l=this[6],m=this[7],M=t[0],y=t[1],f=t[2],A=t[3];return s[0]=i*A+e*M+h*f-r*y,s[1]=h*A+e*y+r*M-i*f,s[2]=r*A+e*f+i*y-h*M,s[3]=e*A-i*M-h*y-r*f,s[4]=i*u+e*n+h*a-r*o+c*A+m*M+p*f-l*y,s[5]=h*u+e*o+r*n-i*a+p*A+m*y+l*M-c*f,s[6]=r*u+e*a+i*o-h*n+l*A+m*f+c*y-p*M,s[7]=e*u-i*n-h*o-r*a+m*A-c*M-p*y-l*f,s},this[0]=t,this[1]=s,this[2]=i,this[3]=h,this[4]=r,this[5]=e,this[6]=n,this[7]=o}getReal(t=new g){return t[0]=this[0],t[1]=this[1],t[2]=this[2],t[3]=this[3],t}getDual(t=new g){return t[0]=this[4],t[1]=this[5],t[2]=this[6],t[3]=this[7],t}setReal(t){return this[0]=t[0],this[1]=t[1],this[2]=t[2],this[3]=t[3],this}setDual(t){return this[4]=t[0],this[5]=t[1],this[6]=t[2],this[7]=t[3],this}getTranslation(s=new t){const i=this[4],h=this[5],r=this[6],e=this[7],n=-this[0],o=-this[1],a=-this[2],u=this[3];return s[0]=2*(i*u+e*n+h*a-r*o),s[1]=2*(h*u+e*o+r*n-i*a),s[2]=2*(r*u+e*a+i*o-h*n),s}static fromRotationTranslation(t,s,i=d()){const h=.5*s[0],r=.5*s[1],e=.5*s[2],n=t[0],o=t[1],a=t[2],u=t[3];return i[0]=n,i[1]=o,i[2]=a,i[3]=u,i[4]=h*u+r*a-e*o,i[5]=r*u+e*n-h*a,i[6]=e*u+h*o-r*n,i[7]=-h*n-r*o-e*a,i}static fromTranslation(t,s=d()){return s[0]=0,s[1]=0,s[2]=0,s[3]=1,s[4]=.5*t[0],s[5]=.5*t[1],s[6]=.5*t[2],s[7]=0,s}static fromRotation(t,s=d()){return s[0]=t[0],s[1]=t[1],s[2]=t[2],s[3]=t[3],s[4]=0,s[5]=0,s[6]=0,s[7]=0,s}static fromMat4(t,s=d()){const i=t.getRotation(),h=t.getTranslation();return P.fromRotationTranslation(i,h,s)}clone(){return d(this[0],this[1],this[2],this[3],this[4],this[5],this[6],this[7])}translate(t,s=(K.ALWAYS_COPY?d():this)){const i=this[0],h=this[1],r=this[2],e=this[3],n=.5*t[0],o=.5*t[1],a=.5*t[2],u=this[4],c=this[5],p=this[6],l=this[7];return s[0]=i,s[1]=h,s[2]=r,s[3]=e,s[4]=e*n+h*a-r*o+u,s[5]=e*o+r*n-i*a+c,s[6]=e*a+i*o-h*n+p,s[7]=-i*n-h*o-r*a+l,s}conjugate(t=(K.ALWAYS_COPY?d():this)){return t[0]=-this[0],t[1]=-this[1],t[2]=-this[2],t[3]=this[3],t[4]=-this[4],t[5]=-this[5],t[6]=-this[6],t[7]=this[7],t}invert(t=(K.ALWAYS_COPY?d():this)){const s=this.squaredLength();return t[0]=-this[0]/s,t[1]=-this[1]/s,t[2]=-this[2]/s,t[3]=this[3]/s,t[4]=-this[4]/s,t[5]=-this[5]/s,t[6]=-this[6]/s,t[7]=this[7]/s,t}squaredLength(){const t=this[0],s=this[1],i=this[2],h=this[3];return t*t+s*s+i*i+h*h}len(){return Math.sqrt(this.squaredLength())}static normalize(t,s=d()){let i=t.squaredLength();if(i>0){i=Math.sqrt(i);const h=t[0]/i,r=t[1]/i,e=t[2]/i,n=t[3]/i,o=t[4],a=t[5],u=t[6],c=t[7],p=h*o+r*a+e*u+n*c;s[0]=h,s[1]=r,s[2]=e,s[3]=n,s[4]=(o-h*p)/i,s[5]=(a-r*p)/i,s[6]=(u-e*p)/i,s[7]=(c-n*p)/i}return s}normalize(t=(K.ALWAYS_COPY?d():this)){return P.normalize(this,t)}static dot(t,s){return t[0]*s[0]+t[1]*s[1]+t[2]*s[2]+t[3]*s[3]}static lerp(t,s,i,h=d()){const r=1-i;return P.dot(t,s)<0&&(i=-i),h[0]=t[0]*r+s[0]*i,h[1]=t[1]*r+s[1]*i,h[2]=t[2]*r+s[2]*i,h[3]=t[3]*r+s[3]*i,h[4]=t[4]*r+s[4]*i,h[5]=t[5]*r+s[5]*i,h[6]=t[6]*r+s[6]*i,h[7]=t[7]*r+s[7]*i,h}plus(t,s=(K.ALWAYS_COPY?d():this)){return s[0]=this[0]+t[0],s[1]=this[1]+t[1],s[2]=this[2]+t[2],s[3]=this[3]+t[3],s[4]=this[4]+t[4],s[5]=this[5]+t[5],s[6]=this[6]+t[6],s[7]=this[7]+t[7],s}scale(t,s=(K.ALWAYS_COPY?d():this)){return s[0]=this[0]*t,s[1]=this[1]*t,s[2]=this[2]*t,s[3]=this[3]*t,s[4]=this[4]*t,s[5]=this[5]*t,s[6]=this[6]*t,s[7]=this[7]*t,s}equals(t){return n(this[0],t[0])&&n(this[1],t[1])&&n(this[2],t[2])&&n(this[3],t[3])&&n(this[4],t[4])&&n(this[5],t[5])&&n(this[6],t[6])&&n(this[7],t[7])}exactEquals(t){return this[0]===t[0]&&this[1]===t[1]&&this[2]===t[2]&&this[3]===t[3]&&this[4]===t[4]&&this[5]===t[5]&&this[6]===t[6]&&this[7]===t[7]}toString(){const t=(t,s)=>{if(0===t)return"";const i=Math.abs(t),h=1===i&&s?s:`${i}${s}`;return t<0?" - "+h:" + "+h},s=(s,i,h,r)=>((0!==s?""+s:"")+t(i,"i")+t(h,"j")+t(r,"k")).trim().replace(/^\+ /,"")||"0";return`(${s(this[3],this[0],this[1],this[2])}) + ε(${s(this[7],this[4],this[5],this[6])})`}}P.prototype.sqrLen=P.prototype.squaredLength,P.prototype.normalized=P.prototype.normalize,P.prototype.str=P.prototype.toString,P.prototype.add=P.prototype.plus;const L=(t=0,s=0,i=0,h=1,r=0,e=0,n=0,o=0)=>new P(t,s,i,h,r,e,n,o);Object.setPrototypeOf(L,P);const d=L;class _ extends Float32Array{static get identity(){return C(1,0,0,1)}static get Identity(){return C(1,0,0,1)}static get IDENTITY(){return C(1,0,0,1)}constructor(t=0,s=0,i=0,h=0){super(4),this[0]=t,this[1]=s,this[2]=i,this[3]=h}clone(){return C(this[0],this[1],this[2],this[3])}transpose(t=(K.ALWAYS_COPY?C():this)){if(t.exactEquals(this)){const s=t[1];t[1]=t[2],t[2]=s}else t[0]=this[0],t[1]=this[2],t[2]=this[1],t[3]=this[3];return t}invert(t=(K.ALWAYS_COPY?C():this)){const s=this[0],i=this[1],h=this[2],r=this[3];let e=s*r-h*i;return e?(e=1/e,t[0]=r*e,t[1]=-i*e,t[2]=-h*e,t[3]=s*e,t):null}adjoint(t=(K.ALWAYS_COPY?C():this)){let s=this[0];return t[0]=this[3],t[1]=-this[1],t[2]=-this[2],t[3]=s,t}determinant(){return this[0]*this[3]-this[2]*this[1]}rotate(t,s=(K.ALWAYS_COPY?C():this)){const i=this[0],h=this[1],r=this[2],e=this[3],n=Math.sin(t),o=Math.cos(t);return s[0]=i*o+r*n,s[1]=h*o+e*n,s[2]=i*-n+r*o,s[3]=h*-n+e*o,s}scale(t,s=(K.ALWAYS_COPY?C():this)){const i=t[0],h=t[1];return s[0]=this[0]*i,s[1]=this[1]*i,s[2]=this[2]*h,s[3]=this[3]*h,s}static fromRotation(t,s=C()){const i=Math.sin(t),h=Math.cos(t);return s[0]=h,s[1]=i,s[2]=-i,s[3]=h,s}static fromScaling(t,s=C()){return s[0]=t[0],s[1]=s[2]=0,s[3]=t[1],s}toString(){return`mat2x2(${this[0]}, ${this[1]}, ${this[2]}, ${this[3]})`}frob(){const t=this[0],s=this[1],i=this[2],h=this[3];return Math.sqrt(t*t+s*s+i*i+h*h)}LDU(t=C(),s=C(),i=C()){return t[2]=this[2]/this[0],i[0]=this[0],i[1]=this[1],i[3]=this[3]-t[2]*i[1],[t,s,i]}plus(t,s=(K.ALWAYS_COPY?C():this)){return s[0]=this[0]+t[0],s[1]=this[1]+t[1],s[2]=this[2]+t[2],s[3]=this[3]+t[3],s}minus(t,s=(K.ALWAYS_COPY?C():this)){return s[0]=this[0]-t[0],s[1]=this[1]-t[1],s[2]=this[2]-t[2],s[3]=this[3]-t[3],s}multiply(t,s=(K.ALWAYS_COPY?C():this)){if(t instanceof a)return t.transformMat2(this);const i=this[0],h=this[1],r=this[2],e=this[3],n=t[0],o=t[1],u=t[2],c=t[3];return s[0]=i*n+r*o,s[1]=h*n+e*o,s[2]=i*u+r*c,s[3]=h*u+e*c,s}exactEquals(t){return this[0]===t[0]&&this[1]===t[1]&&this[2]===t[2]&&this[3]===t[3]}equals(t){return n(this[0],t[0])&&n(this[1],t[1])&&n(this[2],t[2])&&n(this[3],t[3])}scaleScalar(t,s=(K.ALWAYS_COPY?C():this)){return s[0]=this[0]*t,s[1]=this[1]*t,s[2]=this[2]*t,s[3]=this[3]*t,s}}_.prototype.add=_.prototype.plus,_.prototype.sub=_.prototype.minus,_.prototype.subtract=_.prototype.minus,_.prototype.mul=_.prototype.multiply,_.prototype.mult=_.prototype.multiply,_.prototype.times=_.prototype.multiply,_.prototype.multiplyScalar=_.prototype.scaleScalar,_.prototype.str=_.prototype.toString;const W=(...t)=>{const s=new _;let i=0;for(const h of t)if("number"==typeof h)s[i++]=h;else for(const t of h)s[i++]=t;return s};Object.setPrototypeOf(W,_);const C=W,x=C;class q extends Float32Array{static get identity(){return E(1,0,0,1,0,0)}static get Identity(){return E(1,0,0,1,0,0)}static get IDENTITY(){return E(1,0,0,1,0,0)}constructor(t=0,s=0,i=0,h=0,r=0,e=0){super(6),this[0]=t,this[1]=s,this[2]=i,this[3]=h,this[4]=r,this[5]=e}invert(t=(K.ALWAYS_COPY?E():this)){const s=this[0],i=this[1],h=this[2],r=this[3],e=this[4],n=this[5];let o=s*r-i*h;return o?(o=1/o,t[0]=r*o,t[1]=-i*o,t[2]=-h*o,t[3]=s*o,t[4]=(h*n-r*e)*o,t[5]=(i*e-s*n)*o,t):null}determinant(){return this[0]*this[3]-this[1]*this[2]}rotate(t,s=(K.ALWAYS_COPY?E():this)){const i=this[0],h=this[1],r=this[2],e=this[3],n=this[4],o=this[5],a=Math.sin(t),u=Math.cos(t);return s[0]=i*u+r*a,s[1]=h*u+e*a,s[2]=i*-a+r*u,s[3]=h*-a+e*u,s[4]=n,s[5]=o,s}scale(t,s=(K.ALWAYS_COPY?E():this)){const i=this[1],h=this[2],r=this[3],e=this[4],n=this[5],o=t[0],a=t[1];return s[0]=this[0]*o,s[1]=i*o,s[2]=h*a,s[3]=r*a,s[4]=e,s[5]=n,s}translate(t,s=(K.ALWAYS_COPY?E():this)){const i=this[0],h=this[1],r=this[2],e=this[3],n=this[4],o=this[5],a=t[0],u=t[1];return s[0]=i,s[1]=h,s[2]=r,s[3]=e,s[4]=i*a+r*u+n,s[5]=h*a+e*u+o,s}static fromRotation(t,s=E()){const i=Math.sin(t),h=Math.cos(t);return s[0]=h,s[1]=i,s[2]=-i,s[3]=h,s[4]=s[5]=0,s}static fromScaling(t,s=E()){return s[0]=t[0],s[1]=s[2]=0,s[3]=t[1],s[4]=s[5]=0,s}static fromTranslation(t,s=E()){return s[0]=s[3]=1,s[1]=s[2]=0,s[4]=t[0],s[5]=t[1],s}toString(){return`mat2x3(${this[0]}, ${this[1]},\t${this[2]}, ${this[3]},\t${this[4]}, ${this[5]})`}frob(){return Math.sqrt(this[0]*this[0]+this[1]*this[1]+this[2]*this[2]+this[3]*this[3]+this[4]*this[4]+this[5]*this[5]+1)}plus(t,s=(K.ALWAYS_COPY?E():this)){return s[0]=this[0]+t[0],s[1]=this[1]+t[1],s[2]=this[2]+t[2],s[3]=this[3]+t[3],s[4]=this[4]+t[4],s[5]=this[5]+t[5],s}minus(t,s=(K.ALWAYS_COPY?E():this)){return s[0]=this[0]-t[0],s[1]=this[1]-t[1],s[2]=this[2]-t[2],s[3]=this[3]-t[3],s[4]=this[4]-t[4],s[5]=this[5]-t[5],s}multiply(t,s=(K.ALWAYS_COPY?E():this)){if(t instanceof a)return t.transformMat2x3(this);const i=this[0],h=this[1],r=this[2],e=this[3],n=this[4],o=this[5],u=t[0],c=t[1],p=t[2],l=t[3],m=t[4],M=t[5];return s[0]=i*u+r*c,s[1]=h*u+e*c,s[2]=i*p+r*l,s[3]=h*p+e*l,s[4]=i*m+r*M+n,s[5]=h*m+e*M+o,s}equals(t){return n(this[0],t[0])&&n(this[1],t[1])&&n(this[2],t[2])&&n(this[3],t[3])&&n(this[4],t[4])&&n(this[5],t[5])}exactEquals(t){return this[0]===t[0]&&this[1]===t[1]&&this[2]===t[2]&&this[3]===t[3]&&this[4]===t[4]&&this[5]===t[5]}scaleScalar(t,s=(K.ALWAYS_COPY?E():this)){return s[0]=this[0]*t,s[1]=this[1]*t,s[2]=this[2]*t,s[3]=this[3]*t,s[4]=this[4]*t,s[5]=this[5]*t,s}clone(){return E(this[0],this[1],this[2],this[3],this[4],this[5])}}q.prototype.add=q.prototype.plus,q.prototype.sub=q.prototype.minus,q.prototype.subtract=q.prototype.minus,q.prototype.mul=q.prototype.multiply,q.prototype.mult=q.prototype.multiply,q.prototype.times=q.prototype.multiply,q.prototype.str=q.prototype.toString,q.prototype.multiplyScalar=q.prototype.scaleScalar;const $=(...t)=>{const s=new q;let i=0;for(const h of t)if("number"==typeof h)s[i++]=h;else for(const t of h)s[i++]=t;return s};Object.setPrototypeOf($,q);const E=$,w=E;function D(s){if(s instanceof a)return new a;if(s instanceof t)return new t;if(s instanceof h)return new h;if(s instanceof _)return new _;if(s instanceof q)return new q;if(s instanceof p)return new p;if(s instanceof f)return new f;if(s instanceof g)return new g;if(s instanceof P)return new P;if(s instanceof Float32Array)return new Float32Array;throw"unknown type"}function z(t,s,i){if("number"==typeof s)return t(s,0);const h=s,r=i&&i.length===h.length?i:D(h);for(let s=0;s<h.length;++s)r[s]=t(h[s],s);return r}function N(t,s){return z(t=>t/180*Math.PI,t,s)}const I=N,v=N;function T(t,s){return z(t=>t/Math.PI*180,t,s)}const R=T,j=T;function F(t,s){return z(t=>t>=0?Math.round(t):t%.5==0?Math.floor(t):Math.round(t),t,s)}function Z(t,s,i,h){return z(t=>Math.min(Math.max(t,s),i),t,h)}function k(t,s){return z(t=>Math.min(Math.max(t,0),1),t,s)}const H=k;function V(t,s,i,h){if("number"==typeof t)return t*(1-i)+s*i;const r=t,e=s,n=h&&h.length===r.length?h:D(r);if(r.length!==e.length)throw`${r.length} length != ${e} length`;for(let t=0;t<r.length;++t)n[t]=r[t]*(1-i)+e[t]*i;return n}const X=V;function U(t,s,i){if("number"==typeof s&&"number"==typeof t)return s<t?0:1;const h=s,r=i&&i.length===h.length?i:D(h);if("number"==typeof t){for(let s=0;s<h.length;++s)r[s]=h[s]<t?0:1;return r}const e=t;if(h.length!==e.length)throw`${h.length} length != ${e} length`;for(let t=0;t<h.length;++t)r[t]=h[t]<e[t]?0:1;return r}function Q(t,s,i,h){if("number"==typeof t&&"number"==typeof i){const h=Z((i-t)/(s-t),0,1);return h*h*(3-2*h)}const r=t,e=s;if(r.length!==e.length)throw`${r.length} length != ${e} length`;const n=h&&h.length===r.length?h:D(r);if("number"==typeof i){for(let t=0;t<r.length;++t){const s=r[t],h=Z((i-s)/(e[t]-s),0,1);n[t]=h*h*(3-2*h)}return n}const o=i;if(o.length!==r.length)throw`${o.length} length != ${r} length`;for(let t=0;t<r.length;++t){const s=r[t],i=Z((o[t]-s)/(e[t]-s),0,1);n[t]=i*i*(3-2*i)}return n}function G(t,s){return z(t=>t-Math.floor(t),t,s)}function B(t,s){return z(t=>t>0?1:t<0?-1:0,t,s)}function J(t,s){return z(t=>Math.abs(t),t,s)}var K={EPSILON:1e-6,RANDOM:Math.random,ANGLE_ORDER:"zyx",ALWAYS_COPY:!0,LEFT_HANDED:!1};export{_ as Mat2,q as Mat2x3,p as Mat3,f as Mat4,g as Quat,P as Quat2,a as Vec2,t as Vec3,h as Vec4,J as abs,Z as clamp,k as clamp01,K as default,R as deg,T as degrees,G as fract,X as lerp,C as mat2,w as mat2d,x as mat2x2,E as mat2x3,m as mat3,M as mat3x3,Y as mat4,O as mat4x4,V as mix,b as quat,d as quat2,I as rad,N as radians,F as round,H as saturate,B as sign,Q as smoothstep,U as step,j as toDegrees,v as toRadians,c as vec2,i as vec3,e as vec4};
|
|
2
2
|
//# sourceMappingURL=glmaths.min.js.map
|