audio-vis/out/js/scripts.min.js

1 line
32 KiB
JavaScript
Raw Normal View History

2020-08-06 23:44:37 +02:00
class VTUtils{static random(t,e){let a=Math.random();if(void 0===t)return a;if(void 0===e)return t instanceof Array?t[Math.floor(a*t.length)]:a*t;if(t>e){let a=t;t=e,e=a}return a*(e-t)+t}static randomInt(t,e){return Math.floor(VTUtils.random(t,e))}static normalize(t,e,a){return(t-a)/(e-a)}static distance(t,e,a,i){let s=t-a,n=e-i;return Math.sqrt(s*s+n*n)}static map(t,e,a,i,s,n){let l=(t-e)/(a-e)*(s-i)+i;return n?i<s?this.constrain(l,i,s):this.constrain(l,s,i):l}static constrain(t,e,a){return Math.max(Math.min(t,a),e)}static hsvToRgb(t,e,a){let i,s,n,l=Math.floor(6*t),r=6*t-l,o=a*(1-e),d=a*(1-r*e),c=a*(1-(1-r)*e);switch(l%6){case 0:i=a,s=c,n=o;break;case 1:i=d,s=a,n=o;break;case 2:i=o,s=a,n=c;break;case 3:i=o,s=d,n=a;break;case 4:i=c,s=o,n=a;break;case 5:i=a,s=o,n=d}return{r:i,g:s,b:n}}static peakRGB(t){return{r:t,g:1-t,b:0}}}class VTVector{constructor(t,e,a){this.x=t||0,this.y=e||0,this.z=a||0}static createRandom(t,e,a){return t=t||1,e=e||1,a=a||0,new VTVector(VTUtils.random(-t,t),VTUtils.random(-e,e),VTUtils.random(-a,a))}mult(t){this.x*=t,this.y*=t,this.z*=t}set(t){this.x=t.x,this.y=t.y,this.z=t.z}add(t){this.x=this.x+t.x,this.y=this.y+t.y,this.z=this.z+t.z}addXYZ(t,e,a){this.x+=t,this.y+=e,this.z+=a}setXYZ(t,e,a){this.x=t||0,this.y=e||0,this.z=a||0}clone(){return new VTVector(this.x,this.y,this.z)}}function $(t,e){return(e=e||document).querySelector(t)}function $$(t,e){return(e=e||document).querySelectorAll(t)}function b64toBlob(t,e){const a=atob(t),i=new Array(a.length);for(let t=0;t<a.length;t++)i[t]=a.charCodeAt(t);const s=new Uint8Array(i);return new Blob([s],{type:e})}function create(t,e){let a=document.createElement(t);return e&&(a.innerHTML=e),a}function append(t,e){for(let a of e)t.appendChild(a)}function hexToRgb(t){t=t.replace("#","");let e=parseInt(t,16);return[(e>>16&255)/255,(e>>8&255)/255,(255&e)/255]}Node.prototype.addDelegatedEventListener=function(t,e,a){this.addEventListener(t,t=>{let i=t.target;if(i.matches(e))a(t,i);else{let s=i.closest(e);if(s)try{a(t,s)}catch(t){NotificationHandler.createNotification("FATAL ERROR WITHIN HANDLER!","error",1e3)}}})},Node.prototype.hasClass=function(t){let e=t.split(","),a=null;for(let t of e){if(!1===a)break;a=this.classList.contains(t.trim())}return!0===a},Node.prototype.addClass=function(t){let e=t.split(",");for(let t of e)this.classList.add(t.trim());return this},Node.prototype.removeClass=function(t){let e=t.split(",");for(let t of e)this.classList.remove(t.trim());return this},Node.prototype.toggleClass=function(t,e){let a=t.split(",");for(let t of a)this.classList.toggle(t.trim(),e)},Node.prototype.switchClass=function(t,e,a){let i=this.classList;a?(i.remove(t),i.add(e)):(i.remove(e),i.add(t))},Node.prototype.toggleCheck=function(t,e){let a=this.classList,i=t.split(",");for(let t of i){let i=t.trim();e?a.add(i):a.remove(i)}},File.prototype.toBase64=function(t){const e=new FileReader;e.onloadend=t,e.readAsDataURL(this)};class TDUtils{static lastMatrix={m:null};static multiply(t,e){let a=e[0],i=e[1],s=e[2],n=e[3],l=e[4],r=e[5],o=e[6],d=e[7],c=e[8],h=e[9],u=e[10],p=e[11],g=e[12],f=e[13],m=e[14],v=e[15],y=t[0],C=t[1],w=t[2],T=t[3],b=t[4],S=t[5],x=t[6],D=t[7],U=t[8],H=t[9],A=t[10],L=t[11],R=t[12],E=t[13],F=t[14],I=t[15];return[a*y+i*b+s*U+n*R,a*C+i*S+s*H+n*E,a*w+i*x+s*A+n*F,a*T+i*D+s*L+n*I,l*y+r*b+o*U+d*R,l*C+r*S+o*H+d*E,l*w+r*x+o*A+d*F,l*T+r*D+o*L+d*I,c*y+h*b+u*U+p*R,c*C+h*S+u*H+p*E,c*w+h*x+u*A+p*F,c*T+h*D+u*L+p*I,g*y+f*b+m*U+v*R,g*C+f*S+m*H+v*E,g*w+f*x+m*A+v*F,g*T+f*D+m*L+v*I]}static translate(t,e,a,i,s){s=s||new Float32Array(16);let n=t[0],l=t[1],r=t[2],o=t[3],d=t[4],c=t[5],h=t[6],u=t[7],p=t[8],g=t[9],f=t[10],m=t[11],v=t[12],y=t[13],C=t[14],w=t[15];return s[0]=n,s[1]=l,s[2]=r,s[3]=o,s[4]=d,s[5]=c,s[6]=h,s[7]=u,s[8]=p,s[9]=g,s[10]=f,s[11]=m,s[12]=n*e+d*a+p*i+v,s[13]=l*e+c*a+g*i+y,s[14]=r*e+h*a+f*i+C,s[15]=o*e+u*a+m*i+w,s}static xRotation(t){t=TDUtils.degToRad(t);let e=Math.cos(t),a=Math.sin(t);return[1,0,0,0,0,e,a,0,0,-a,e,0,0,0,0,1]}static yRotation(t){t=TDUtils.degToRad(t);let e=Math.cos(t),a=Math.sin(t);return[e,0,-a,0,0,1,0,0,a,0,e,0,0,0,0,1]}static zRotat