This repository was archived by the owner on Oct 15, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathC3R.standalone.js
More file actions
45 lines (42 loc) · 64.7 KB
/
C3R.standalone.js
File metadata and controls
45 lines (42 loc) · 64.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/* Copyright (c) 2015, Brandon Jones, Colin MacKenzie IV.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE. */
!function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var n=e();for(var r in n)("object"==typeof exports?exports:t)[r]=n[r]}}(this,function(){return function(n){function r(t){if(a[t])return a[t].exports;var e=a[t]={i:t,l:!1,exports:{}};return n[t].call(e.exports,e,e.exports,r),e.l=!0,e.exports}var a={};return r.m=n,r.c=a,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:n})},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=4)}([function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.setMatrixArrayType=function(t){e.ARRAY_TYPE=t},e.toRadian=function(t){return t*a},e.equals=function(t,e){return Math.abs(t-e)<=r*Math.max(1,Math.abs(t),Math.abs(e))};var r=e.EPSILON=1e-6,a=(e.ARRAY_TYPE="undefined"!=typeof Float32Array?Float32Array:Array,e.RANDOM=Math.random,Math.PI/180)},function(t,e,n){"use strict";function r(t,e,n){var r=e[0],a=e[1],o=e[2],i=e[3],u=e[4],s=e[5],c=e[6],h=e[7],l=e[8],f=n[0],v=n[1],m=n[2],d=n[3],M=n[4],p=n[5],b=n[6],y=n[7],g=n[8];return t[0]=f*r+v*i+m*c,t[1]=f*a+v*u+m*h,t[2]=f*o+v*s+m*l,t[3]=d*r+M*i+p*c,t[4]=d*a+M*u+p*h,t[5]=d*o+M*s+p*l,t[6]=b*r+y*i+g*c,t[7]=b*a+y*u+g*h,t[8]=b*o+y*s+g*l,t}function a(t,e,n){return t[0]=e[0]-n[0],t[1]=e[1]-n[1],t[2]=e[2]-n[2],t[3]=e[3]-n[3],t[4]=e[4]-n[4],t[5]=e[5]-n[5],t[6]=e[6]-n[6],t[7]=e[7]-n[7],t[8]=e[8]-n[8],t}Object.defineProperty(e,"__esModule",{value:!0}),e.sub=e.mul=void 0,e.create=function(){var t=new g.ARRAY_TYPE(9);return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=1,t[5]=0,t[6]=0,t[7]=0,t[8]=1,t},e.fromMat4=function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[4],t[4]=e[5],t[5]=e[6],t[6]=e[8],t[7]=e[9],t[8]=e[10],t},e.clone=function(t){var e=new g.ARRAY_TYPE(9);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e},e.copy=function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t},e.fromValues=function(t,e,n,r,a,o,i,u,s){var c=new g.ARRAY_TYPE(9);return c[0]=t,c[1]=e,c[2]=n,c[3]=r,c[4]=a,c[5]=o,c[6]=i,c[7]=u,c[8]=s,c},e.set=function(t,e,n,r,a,o,i,u,s,c){return t[0]=e,t[1]=n,t[2]=r,t[3]=a,t[4]=o,t[5]=i,t[6]=u,t[7]=s,t[8]=c,t},e.identity=function(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=1,t[5]=0,t[6]=0,t[7]=0,t[8]=1,t},e.transpose=function(t,e){if(t===e){var n=e[1],r=e[2],a=e[5];t[1]=e[3],t[2]=e[6],t[3]=n,t[5]=e[7],t[6]=r,t[7]=a}else t[0]=e[0],t[1]=e[3],t[2]=e[6],t[3]=e[1],t[4]=e[4],t[5]=e[7],t[6]=e[2],t[7]=e[5],t[8]=e[8];return t},e.invert=function(t,e){var n=e[0],r=e[1],a=e[2],o=e[3],i=e[4],u=e[5],s=e[6],c=e[7],h=e[8],l=h*i-u*c,f=-h*o+u*s,v=c*o-i*s,m=n*l+r*f+a*v;return m?(m=1/m,t[0]=l*m,t[1]=(-h*r+a*c)*m,t[2]=(u*r-a*i)*m,t[3]=f*m,t[4]=(h*n-a*s)*m,t[5]=(-u*n+a*o)*m,t[6]=v*m,t[7]=(-c*n+r*s)*m,t[8]=(i*n-r*o)*m,t):null},e.adjoint=function(t,e){var n=e[0],r=e[1],a=e[2],o=e[3],i=e[4],u=e[5],s=e[6],c=e[7],h=e[8];return t[0]=i*h-u*c,t[1]=a*c-r*h,t[2]=r*u-a*i,t[3]=u*s-o*h,t[4]=n*h-a*s,t[5]=a*o-n*u,t[6]=o*c-i*s,t[7]=r*s-n*c,t[8]=n*i-r*o,t},e.determinant=function(t){var e=t[0],n=t[1],r=t[2],a=t[3],o=t[4],i=t[5],u=t[6],s=t[7],c=t[8];return e*(c*o-i*s)+n*(-c*a+i*u)+r*(s*a-o*u)},e.multiply=r,e.translate=function(t,e,n){var r=e[0],a=e[1],o=e[2],i=e[3],u=e[4],s=e[5],c=e[6],h=e[7],l=e[8],f=n[0],v=n[1];return t[0]=r,t[1]=a,t[2]=o,t[3]=i,t[4]=u,t[5]=s,t[6]=f*r+v*i+c,t[7]=f*a+v*u+h,t[8]=f*o+v*s+l,t},e.rotate=function(t,e,n){var r=e[0],a=e[1],o=e[2],i=e[3],u=e[4],s=e[5],c=e[6],h=e[7],l=e[8],f=Math.sin(n),v=Math.cos(n);return t[0]=v*r+f*i,t[1]=v*a+f*u,t[2]=v*o+f*s,t[3]=v*i-f*r,t[4]=v*u-f*a,t[5]=v*s-f*o,t[6]=c,t[7]=h,t[8]=l,t},e.scale=function(t,e,n){var r=n[0],a=n[1];return t[0]=r*e[0],t[1]=r*e[1],t[2]=r*e[2],t[3]=a*e[3],t[4]=a*e[4],t[5]=a*e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t},e.fromTranslation=function(t,e){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=1,t[5]=0,t[6]=e[0],t[7]=e[1],t[8]=1,t},e.fromRotation=function(t,e){var n=Math.sin(e),r=Math.cos(e);return t[0]=r,t[1]=n,t[2]=0,t[3]=-n,t[4]=r,t[5]=0,t[6]=0,t[7]=0,t[8]=1,t},e.fromScaling=function(t,e){return t[0]=e[0],t[1]=0,t[2]=0,t[3]=0,t[4]=e[1],t[5]=0,t[6]=0,t[7]=0,t[8]=1,t},e.fromMat2d=function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=0,t[3]=e[2],t[4]=e[3],t[5]=0,t[6]=e[4],t[7]=e[5],t[8]=1,t},e.fromQuat=function(t,e){var n=e[0],r=e[1],a=e[2],o=e[3],i=n+n,u=r+r,s=a+a,c=n*i,h=r*i,l=r*u,f=a*i,v=a*u,m=a*s,d=o*i,M=o*u,p=o*s;return t[0]=1-l-m,t[3]=h-p,t[6]=f+M,t[1]=h+p,t[4]=1-c-m,t[7]=v-d,t[2]=f-M,t[5]=v+d,t[8]=1-c-l,t},e.normalFromMat4=function(t,e){var n=e[0],r=e[1],a=e[2],o=e[3],i=e[4],u=e[5],s=e[6],c=e[7],h=e[8],l=e[9],f=e[10],v=e[11],m=e[12],d=e[13],M=e[14],p=e[15],b=n*u-r*i,y=n*s-a*i,g=n*c-o*i,P=r*s-a*u,E=r*c-o*u,x=a*c-o*s,w=h*d-l*m,_=h*M-f*m,O=h*p-v*m,k=l*M-f*d,S=l*p-v*d,A=f*p-v*M,q=b*A-y*S+g*k+P*O-E*_+x*w;return q?(q=1/q,t[0]=(u*A-s*S+c*k)*q,t[1]=(s*O-i*A-c*_)*q,t[2]=(i*S-u*O+c*w)*q,t[3]=(a*S-r*A-o*k)*q,t[4]=(n*A-a*O+o*_)*q,t[5]=(r*O-n*S-o*w)*q,t[6]=(d*x-M*E+p*P)*q,t[7]=(M*g-m*x-p*y)*q,t[8]=(m*E-d*g+p*b)*q,t):null},e.projection=function(t,e,n){return t[0]=2/e,t[1]=0,t[2]=0,t[3]=0,t[4]=-2/n,t[5]=0,t[6]=-1,t[7]=1,t[8]=1,t},e.str=function(t){return"mat3("+t[0]+", "+t[1]+", "+t[2]+", "+t[3]+", "+t[4]+", "+t[5]+", "+t[6]+", "+t[7]+", "+t[8]+")"},e.frob=function(t){return Math.sqrt(Math.pow(t[0],2)+Math.pow(t[1],2)+Math.pow(t[2],2)+Math.pow(t[3],2)+Math.pow(t[4],2)+Math.pow(t[5],2)+Math.pow(t[6],2)+Math.pow(t[7],2)+Math.pow(t[8],2))},e.add=function(t,e,n){return t[0]=e[0]+n[0],t[1]=e[1]+n[1],t[2]=e[2]+n[2],t[3]=e[3]+n[3],t[4]=e[4]+n[4],t[5]=e[5]+n[5],t[6]=e[6]+n[6],t[7]=e[7]+n[7],t[8]=e[8]+n[8],t},e.subtract=a,e.multiplyScalar=function(t,e,n){return t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t[3]=e[3]*n,t[4]=e[4]*n,t[5]=e[5]*n,t[6]=e[6]*n,t[7]=e[7]*n,t[8]=e[8]*n,t},e.multiplyScalarAndAdd=function(t,e,n,r){return t[0]=e[0]+n[0]*r,t[1]=e[1]+n[1]*r,t[2]=e[2]+n[2]*r,t[3]=e[3]+n[3]*r,t[4]=e[4]+n[4]*r,t[5]=e[5]+n[5]*r,t[6]=e[6]+n[6]*r,t[7]=e[7]+n[7]*r,t[8]=e[8]+n[8]*r,t},e.exactEquals=function(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]&&t[3]===e[3]&&t[4]===e[4]&&t[5]===e[5]&&t[6]===e[6]&&t[7]===e[7]&&t[8]===e[8]},e.equals=function(t,e){var n=t[0],r=t[1],a=t[2],o=t[3],i=t[4],u=t[5],s=t[6],c=t[7],h=t[8],l=e[0],f=e[1],v=e[2],m=e[3],d=e[4],M=e[5],p=e[6],b=e[7],y=e[8];return Math.abs(n-l)<=g.EPSILON*Math.max(1,Math.abs(n),Math.abs(l))&&Math.abs(r-f)<=g.EPSILON*Math.max(1,Math.abs(r),Math.abs(f))&&Math.abs(a-v)<=g.EPSILON*Math.max(1,Math.abs(a),Math.abs(v))&&Math.abs(o-m)<=g.EPSILON*Math.max(1,Math.abs(o),Math.abs(m))&&Math.abs(i-d)<=g.EPSILON*Math.max(1,Math.abs(i),Math.abs(d))&&Math.abs(u-M)<=g.EPSILON*Math.max(1,Math.abs(u),Math.abs(M))&&Math.abs(s-p)<=g.EPSILON*Math.max(1,Math.abs(s),Math.abs(p))&&Math.abs(c-b)<=g.EPSILON*Math.max(1,Math.abs(c),Math.abs(b))&&Math.abs(h-y)<=g.EPSILON*Math.max(1,Math.abs(h),Math.abs(y))};var g=function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e.default=t,e}(n(0));e.mul=r,e.sub=a},function(t,e,n){"use strict";function r(){var t=new d.ARRAY_TYPE(3);return t[0]=0,t[1]=0,t[2]=0,t}function a(t){var e=t[0],n=t[1],r=t[2];return Math.sqrt(e*e+n*n+r*r)}function o(t,e,n){var r=new d.ARRAY_TYPE(3);return r[0]=t,r[1]=e,r[2]=n,r}function i(t,e,n){return t[0]=e[0]-n[0],t[1]=e[1]-n[1],t[2]=e[2]-n[2],t}function u(t,e,n){return t[0]=e[0]*n[0],t[1]=e[1]*n[1],t[2]=e[2]*n[2],t}function s(t,e,n){return t[0]=e[0]/n[0],t[1]=e[1]/n[1],t[2]=e[2]/n[2],t}function c(t,e){var n=e[0]-t[0],r=e[1]-t[1],a=e[2]-t[2];return Math.sqrt(n*n+r*r+a*a)}function h(t,e){var n=e[0]-t[0],r=e[1]-t[1],a=e[2]-t[2];return n*n+r*r+a*a}function l(t){var e=t[0],n=t[1],r=t[2];return e*e+n*n+r*r}function f(t,e){var n=e[0],r=e[1],a=e[2],o=n*n+r*r+a*a;return 0<o&&(o=1/Math.sqrt(o),t[0]=e[0]*o,t[1]=e[1]*o,t[2]=e[2]*o),t}function v(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]}Object.defineProperty(e,"__esModule",{value:!0}),e.forEach=e.sqrLen=e.len=e.sqrDist=e.dist=e.div=e.mul=e.sub=void 0,e.create=r,e.clone=function(t){var e=new d.ARRAY_TYPE(3);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e},e.length=a,e.fromValues=o,e.copy=function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t},e.set=function(t,e,n,r){return t[0]=e,t[1]=n,t[2]=r,t},e.add=function(t,e,n){return t[0]=e[0]+n[0],t[1]=e[1]+n[1],t[2]=e[2]+n[2],t},e.subtract=i,e.multiply=u,e.divide=s,e.ceil=function(t,e){return t[0]=Math.ceil(e[0]),t[1]=Math.ceil(e[1]),t[2]=Math.ceil(e[2]),t},e.floor=function(t,e){return t[0]=Math.floor(e[0]),t[1]=Math.floor(e[1]),t[2]=Math.floor(e[2]),t},e.min=function(t,e,n){return t[0]=Math.min(e[0],n[0]),t[1]=Math.min(e[1],n[1]),t[2]=Math.min(e[2],n[2]),t},e.max=function(t,e,n){return t[0]=Math.max(e[0],n[0]),t[1]=Math.max(e[1],n[1]),t[2]=Math.max(e[2],n[2]),t},e.round=function(t,e){return t[0]=Math.round(e[0]),t[1]=Math.round(e[1]),t[2]=Math.round(e[2]),t},e.scale=function(t,e,n){return t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t},e.scaleAndAdd=function(t,e,n,r){return t[0]=e[0]+n[0]*r,t[1]=e[1]+n[1]*r,t[2]=e[2]+n[2]*r,t},e.distance=c,e.squaredDistance=h,e.squaredLength=l,e.negate=function(t,e){return t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t},e.inverse=function(t,e){return t[0]=1/e[0],t[1]=1/e[1],t[2]=1/e[2],t},e.normalize=f,e.dot=v,e.cross=function(t,e,n){var r=e[0],a=e[1],o=e[2],i=n[0],u=n[1],s=n[2];return t[0]=a*s-o*u,t[1]=o*i-r*s,t[2]=r*u-a*i,t},e.lerp=function(t,e,n,r){var a=e[0],o=e[1],i=e[2];return t[0]=a+r*(n[0]-a),t[1]=o+r*(n[1]-o),t[2]=i+r*(n[2]-i),t},e.hermite=function(t,e,n,r,a,o){var i=o*o,u=i*(2*o-3)+1,s=i*(o-2)+o,c=i*(o-1),h=i*(3-2*o);return t[0]=e[0]*u+n[0]*s+r[0]*c+a[0]*h,t[1]=e[1]*u+n[1]*s+r[1]*c+a[1]*h,t[2]=e[2]*u+n[2]*s+r[2]*c+a[2]*h,t},e.bezier=function(t,e,n,r,a,o){var i=1-o,u=i*i,s=o*o,c=u*i,h=3*o*u,l=3*s*i,f=s*o;return t[0]=e[0]*c+n[0]*h+r[0]*l+a[0]*f,t[1]=e[1]*c+n[1]*h+r[1]*l+a[1]*f,t[2]=e[2]*c+n[2]*h+r[2]*l+a[2]*f,t},e.random=function(t,e){e=e||1;var n=2*d.RANDOM()*Math.PI,r=2*d.RANDOM()-1,a=Math.sqrt(1-r*r)*e;return t[0]=Math.cos(n)*a,t[1]=Math.sin(n)*a,t[2]=r*e,t},e.transformMat4=function(t,e,n){var r=e[0],a=e[1],o=e[2],i=n[3]*r+n[7]*a+n[11]*o+n[15];return i=i||1,t[0]=(n[0]*r+n[4]*a+n[8]*o+n[12])/i,t[1]=(n[1]*r+n[5]*a+n[9]*o+n[13])/i,t[2]=(n[2]*r+n[6]*a+n[10]*o+n[14])/i,t},e.transformMat3=function(t,e,n){var r=e[0],a=e[1],o=e[2];return t[0]=r*n[0]+a*n[3]+o*n[6],t[1]=r*n[1]+a*n[4]+o*n[7],t[2]=r*n[2]+a*n[5]+o*n[8],t},e.transformQuat=function(t,e,n){var r=e[0],a=e[1],o=e[2],i=n[0],u=n[1],s=n[2],c=n[3],h=c*r+u*o-s*a,l=c*a+s*r-i*o,f=c*o+i*a-u*r,v=-i*r-u*a-s*o;return t[0]=h*c+v*-i+l*-s-f*-u,t[1]=l*c+v*-u+f*-i-h*-s,t[2]=f*c+v*-s+h*-u-l*-i,t},e.rotateX=function(t,e,n,r){var a=[],o=[];return a[0]=e[0]-n[0],a[1]=e[1]-n[1],a[2]=e[2]-n[2],o[0]=a[0],o[1]=a[1]*Math.cos(r)-a[2]*Math.sin(r),o[2]=a[1]*Math.sin(r)+a[2]*Math.cos(r),t[0]=o[0]+n[0],t[1]=o[1]+n[1],t[2]=o[2]+n[2],t},e.rotateY=function(t,e,n,r){var a=[],o=[];return a[0]=e[0]-n[0],a[1]=e[1]-n[1],a[2]=e[2]-n[2],o[0]=a[2]*Math.sin(r)+a[0]*Math.cos(r),o[1]=a[1],o[2]=a[2]*Math.cos(r)-a[0]*Math.sin(r),t[0]=o[0]+n[0],t[1]=o[1]+n[1],t[2]=o[2]+n[2],t},e.rotateZ=function(t,e,n,r){var a=[],o=[];return a[0]=e[0]-n[0],a[1]=e[1]-n[1],a[2]=e[2]-n[2],o[0]=a[0]*Math.cos(r)-a[1]*Math.sin(r),o[1]=a[0]*Math.sin(r)+a[1]*Math.cos(r),o[2]=a[2],t[0]=o[0]+n[0],t[1]=o[1]+n[1],t[2]=o[2]+n[2],t},e.angle=function(t,e){var n=o(t[0],t[1],t[2]),r=o(e[0],e[1],e[2]);f(n,n),f(r,r);var a=v(n,r);return 1<a?0:a<-1?Math.PI:Math.acos(a)},e.str=function(t){return"vec3("+t[0]+", "+t[1]+", "+t[2]+")"},e.exactEquals=function(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]},e.equals=function(t,e){var n=t[0],r=t[1],a=t[2],o=e[0],i=e[1],u=e[2];return Math.abs(n-o)<=d.EPSILON*Math.max(1,Math.abs(n),Math.abs(o))&&Math.abs(r-i)<=d.EPSILON*Math.max(1,Math.abs(r),Math.abs(i))&&Math.abs(a-u)<=d.EPSILON*Math.max(1,Math.abs(a),Math.abs(u))};var m,d=function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e.default=t,e}(n(0));e.sub=i,e.mul=u,e.div=s,e.dist=c,e.sqrDist=h,e.len=a,e.sqrLen=l,e.forEach=(m=r(),function(t,e,n,r,a,o){var i,u=void 0;for(e||(e=3),n||(n=0),i=r?Math.min(r*e+n,t.length):t.length,u=n;u<i;u+=e)m[0]=t[u],m[1]=t[u+1],m[2]=t[u+2],a(m,m,o),t[u]=m[0],t[u+1]=m[1],t[u+2]=m[2];return t})},function(t,e,n){"use strict";function r(){var t=new m.ARRAY_TYPE(4);return t[0]=0,t[1]=0,t[2]=0,t[3]=0,t}function a(t,e,n){return t[0]=e[0]-n[0],t[1]=e[1]-n[1],t[2]=e[2]-n[2],t[3]=e[3]-n[3],t}function o(t,e,n){return t[0]=e[0]*n[0],t[1]=e[1]*n[1],t[2]=e[2]*n[2],t[3]=e[3]*n[3],t}function i(t,e,n){return t[0]=e[0]/n[0],t[1]=e[1]/n[1],t[2]=e[2]/n[2],t[3]=e[3]/n[3],t}function u(t,e,n){return t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t[3]=e[3]*n,t}function s(t,e){var n=e[0]-t[0],r=e[1]-t[1],a=e[2]-t[2],o=e[3]-t[3];return Math.sqrt(n*n+r*r+a*a+o*o)}function c(t,e){var n=e[0]-t[0],r=e[1]-t[1],a=e[2]-t[2],o=e[3]-t[3];return n*n+r*r+a*a+o*o}function h(t){var e=t[0],n=t[1],r=t[2],a=t[3];return Math.sqrt(e*e+n*n+r*r+a*a)}function l(t){var e=t[0],n=t[1],r=t[2],a=t[3];return e*e+n*n+r*r+a*a}function f(t,e){var n=e[0],r=e[1],a=e[2],o=e[3],i=n*n+r*r+a*a+o*o;return 0<i&&(i=1/Math.sqrt(i),t[0]=n*i,t[1]=r*i,t[2]=a*i,t[3]=o*i),t}Object.defineProperty(e,"__esModule",{value:!0}),e.forEach=e.sqrLen=e.len=e.sqrDist=e.dist=e.div=e.mul=e.sub=void 0,e.create=r,e.clone=function(t){var e=new m.ARRAY_TYPE(4);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e},e.fromValues=function(t,e,n,r){var a=new m.ARRAY_TYPE(4);return a[0]=t,a[1]=e,a[2]=n,a[3]=r,a},e.copy=function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t},e.set=function(t,e,n,r,a){return t[0]=e,t[1]=n,t[2]=r,t[3]=a,t},e.add=function(t,e,n){return t[0]=e[0]+n[0],t[1]=e[1]+n[1],t[2]=e[2]+n[2],t[3]=e[3]+n[3],t},e.subtract=a,e.multiply=o,e.divide=i,e.ceil=function(t,e){return t[0]=Math.ceil(e[0]),t[1]=Math.ceil(e[1]),t[2]=Math.ceil(e[2]),t[3]=Math.ceil(e[3]),t},e.floor=function(t,e){return t[0]=Math.floor(e[0]),t[1]=Math.floor(e[1]),t[2]=Math.floor(e[2]),t[3]=Math.floor(e[3]),t},e.min=function(t,e,n){return t[0]=Math.min(e[0],n[0]),t[1]=Math.min(e[1],n[1]),t[2]=Math.min(e[2],n[2]),t[3]=Math.min(e[3],n[3]),t},e.max=function(t,e,n){return t[0]=Math.max(e[0],n[0]),t[1]=Math.max(e[1],n[1]),t[2]=Math.max(e[2],n[2]),t[3]=Math.max(e[3],n[3]),t},e.round=function(t,e){return t[0]=Math.round(e[0]),t[1]=Math.round(e[1]),t[2]=Math.round(e[2]),t[3]=Math.round(e[3]),t},e.scale=u,e.scaleAndAdd=function(t,e,n,r){return t[0]=e[0]+n[0]*r,t[1]=e[1]+n[1]*r,t[2]=e[2]+n[2]*r,t[3]=e[3]+n[3]*r,t},e.distance=s,e.squaredDistance=c,e.length=h,e.squaredLength=l,e.negate=function(t,e){return t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t[3]=-e[3],t},e.inverse=function(t,e){return t[0]=1/e[0],t[1]=1/e[1],t[2]=1/e[2],t[3]=1/e[3],t},e.normalize=f,e.dot=function(t,e){return t[0]*e[0]+t[1]*e[1]+t[2]*e[2]+t[3]*e[3]},e.lerp=function(t,e,n,r){var a=e[0],o=e[1],i=e[2],u=e[3];return t[0]=a+r*(n[0]-a),t[1]=o+r*(n[1]-o),t[2]=i+r*(n[2]-i),t[3]=u+r*(n[3]-u),t},e.random=function(t,e){return e=e||1,t[0]=m.RANDOM(),t[1]=m.RANDOM(),t[2]=m.RANDOM(),t[3]=m.RANDOM(),f(t,t),u(t,t,e),t},e.transformMat4=function(t,e,n){var r=e[0],a=e[1],o=e[2],i=e[3];return t[0]=n[0]*r+n[4]*a+n[8]*o+n[12]*i,t[1]=n[1]*r+n[5]*a+n[9]*o+n[13]*i,t[2]=n[2]*r+n[6]*a+n[10]*o+n[14]*i,t[3]=n[3]*r+n[7]*a+n[11]*o+n[15]*i,t},e.transformQuat=function(t,e,n){var r=e[0],a=e[1],o=e[2],i=n[0],u=n[1],s=n[2],c=n[3],h=c*r+u*o-s*a,l=c*a+s*r-i*o,f=c*o+i*a-u*r,v=-i*r-u*a-s*o;return t[0]=h*c+v*-i+l*-s-f*-u,t[1]=l*c+v*-u+f*-i-h*-s,t[2]=f*c+v*-s+h*-u-l*-i,t[3]=e[3],t},e.str=function(t){return"vec4("+t[0]+", "+t[1]+", "+t[2]+", "+t[3]+")"},e.exactEquals=function(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]&&t[3]===e[3]},e.equals=function(t,e){var n=t[0],r=t[1],a=t[2],o=t[3],i=e[0],u=e[1],s=e[2],c=e[3];return Math.abs(n-i)<=m.EPSILON*Math.max(1,Math.abs(n),Math.abs(i))&&Math.abs(r-u)<=m.EPSILON*Math.max(1,Math.abs(r),Math.abs(u))&&Math.abs(a-s)<=m.EPSILON*Math.max(1,Math.abs(a),Math.abs(s))&&Math.abs(o-c)<=m.EPSILON*Math.max(1,Math.abs(o),Math.abs(c))};var v,m=function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e.default=t,e}(n(0));e.sub=a,e.mul=o,e.div=i,e.dist=s,e.sqrDist=c,e.len=h,e.sqrLen=l,e.forEach=(v=r(),function(t,e,n,r,a,o){var i,u=void 0;for(e||(e=4),n||(n=0),i=r?Math.min(r*e+n,t.length):t.length,u=n;u<i;u+=e)v[0]=t[u],v[1]=t[u+1],v[2]=t[u+2],v[3]=t[u+3],a(v,v,o),t[u]=v[0],t[u+1]=v[1],t[u+2]=v[2],t[u+3]=v[3];return t})},function(t,e,n){"use strict";function r(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e.default=t,e}Object.defineProperty(e,"__esModule",{value:!0}),e.vec4=e.vec3=e.vec2=e.quat=e.mat4=e.mat3=e.mat2d=e.mat2=e.glMatrix=void 0;var a=r(n(0)),o=r(n(5)),i=r(n(6)),u=r(n(1)),s=r(n(7)),c=r(n(8)),h=r(n(9)),l=r(n(2)),f=r(n(3));e.glMatrix=a,e.mat2=o,e.mat2d=i,e.mat3=u,e.mat4=s,e.quat=c,e.vec2=h,e.vec3=l,e.vec4=f},function(t,e,n){"use strict";function r(t,e,n){var r=e[0],a=e[1],o=e[2],i=e[3],u=n[0],s=n[1],c=n[2],h=n[3];return t[0]=r*u+o*s,t[1]=a*u+i*s,t[2]=r*c+o*h,t[3]=a*c+i*h,t}function a(t,e,n){return t[0]=e[0]-n[0],t[1]=e[1]-n[1],t[2]=e[2]-n[2],t[3]=e[3]-n[3],t}Object.defineProperty(e,"__esModule",{value:!0}),e.sub=e.mul=void 0,e.create=function(){var t=new h.ARRAY_TYPE(4);return t[0]=1,t[1]=0,t[2]=0,t[3]=1,t},e.clone=function(t){var e=new h.ARRAY_TYPE(4);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e},e.copy=function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t},e.identity=function(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=1,t},e.fromValues=function(t,e,n,r){var a=new h.ARRAY_TYPE(4);return a[0]=t,a[1]=e,a[2]=n,a[3]=r,a},e.set=function(t,e,n,r,a){return t[0]=e,t[1]=n,t[2]=r,t[3]=a,t},e.transpose=function(t,e){if(t===e){var n=e[1];t[1]=e[2],t[2]=n}else t[0]=e[0],t[1]=e[2],t[2]=e[1],t[3]=e[3];return t},e.invert=function(t,e){var n=e[0],r=e[1],a=e[2],o=e[3],i=n*o-a*r;return i?(i=1/i,t[0]=o*i,t[1]=-r*i,t[2]=-a*i,t[3]=n*i,t):null},e.adjoint=function(t,e){var n=e[0];return t[0]=e[3],t[1]=-e[1],t[2]=-e[2],t[3]=n,t},e.determinant=function(t){return t[0]*t[3]-t[2]*t[1]},e.multiply=r,e.rotate=function(t,e,n){var r=e[0],a=e[1],o=e[2],i=e[3],u=Math.sin(n),s=Math.cos(n);return t[0]=r*s+o*u,t[1]=a*s+i*u,t[2]=r*-u+o*s,t[3]=a*-u+i*s,t},e.scale=function(t,e,n){var r=e[0],a=e[1],o=e[2],i=e[3],u=n[0],s=n[1];return t[0]=r*u,t[1]=a*u,t[2]=o*s,t[3]=i*s,t},e.fromRotation=function(t,e){var n=Math.sin(e),r=Math.cos(e);return t[0]=r,t[1]=n,t[2]=-n,t[3]=r,t},e.fromScaling=function(t,e){return t[0]=e[0],t[1]=0,t[2]=0,t[3]=e[1],t},e.str=function(t){return"mat2("+t[0]+", "+t[1]+", "+t[2]+", "+t[3]+")"},e.frob=function(t){return Math.sqrt(Math.pow(t[0],2)+Math.pow(t[1],2)+Math.pow(t[2],2)+Math.pow(t[3],2))},e.LDU=function(t,e,n,r){return t[2]=r[2]/r[0],n[0]=r[0],n[1]=r[1],n[3]=r[3]-t[2]*n[1],[t,e,n]},e.add=function(t,e,n){return t[0]=e[0]+n[0],t[1]=e[1]+n[1],t[2]=e[2]+n[2],t[3]=e[3]+n[3],t},e.subtract=a,e.exactEquals=function(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]&&t[3]===e[3]},e.equals=function(t,e){var n=t[0],r=t[1],a=t[2],o=t[3],i=e[0],u=e[1],s=e[2],c=e[3];return Math.abs(n-i)<=h.EPSILON*Math.max(1,Math.abs(n),Math.abs(i))&&Math.abs(r-u)<=h.EPSILON*Math.max(1,Math.abs(r),Math.abs(u))&&Math.abs(a-s)<=h.EPSILON*Math.max(1,Math.abs(a),Math.abs(s))&&Math.abs(o-c)<=h.EPSILON*Math.max(1,Math.abs(o),Math.abs(c))},e.multiplyScalar=function(t,e,n){return t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t[3]=e[3]*n,t},e.multiplyScalarAndAdd=function(t,e,n,r){return t[0]=e[0]+n[0]*r,t[1]=e[1]+n[1]*r,t[2]=e[2]+n[2]*r,t[3]=e[3]+n[3]*r,t};var h=function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e.default=t,e}(n(0));e.mul=r,e.sub=a},function(t,e,n){"use strict";function r(t,e,n){var r=e[0],a=e[1],o=e[2],i=e[3],u=e[4],s=e[5],c=n[0],h=n[1],l=n[2],f=n[3],v=n[4],m=n[5];return t[0]=r*c+o*h,t[1]=a*c+i*h,t[2]=r*l+o*f,t[3]=a*l+i*f,t[4]=r*v+o*m+u,t[5]=a*v+i*m+s,t}function a(t,e,n){return t[0]=e[0]-n[0],t[1]=e[1]-n[1],t[2]=e[2]-n[2],t[3]=e[3]-n[3],t[4]=e[4]-n[4],t[5]=e[5]-n[5],t}Object.defineProperty(e,"__esModule",{value:!0}),e.sub=e.mul=void 0,e.create=function(){var t=new m.ARRAY_TYPE(6);return t[0]=1,t[1]=0,t[2]=0,t[3]=1,t[4]=0,t[5]=0,t},e.clone=function(t){var e=new m.ARRAY_TYPE(6);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e},e.copy=function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t},e.identity=function(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=1,t[4]=0,t[5]=0,t},e.fromValues=function(t,e,n,r,a,o){var i=new m.ARRAY_TYPE(6);return i[0]=t,i[1]=e,i[2]=n,i[3]=r,i[4]=a,i[5]=o,i},e.set=function(t,e,n,r,a,o,i){return t[0]=e,t[1]=n,t[2]=r,t[3]=a,t[4]=o,t[5]=i,t},e.invert=function(t,e){var n=e[0],r=e[1],a=e[2],o=e[3],i=e[4],u=e[5],s=n*o-r*a;return s?(s=1/s,t[0]=o*s,t[1]=-r*s,t[2]=-a*s,t[3]=n*s,t[4]=(a*u-o*i)*s,t[5]=(r*i-n*u)*s,t):null},e.determinant=function(t){return t[0]*t[3]-t[1]*t[2]},e.multiply=r,e.rotate=function(t,e,n){var r=e[0],a=e[1],o=e[2],i=e[3],u=e[4],s=e[5],c=Math.sin(n),h=Math.cos(n);return t[0]=r*h+o*c,t[1]=a*h+i*c,t[2]=r*-c+o*h,t[3]=a*-c+i*h,t[4]=u,t[5]=s,t},e.scale=function(t,e,n){var r=e[0],a=e[1],o=e[2],i=e[3],u=e[4],s=e[5],c=n[0],h=n[1];return t[0]=r*c,t[1]=a*c,t[2]=o*h,t[3]=i*h,t[4]=u,t[5]=s,t},e.translate=function(t,e,n){var r=e[0],a=e[1],o=e[2],i=e[3],u=e[4],s=e[5],c=n[0],h=n[1];return t[0]=r,t[1]=a,t[2]=o,t[3]=i,t[4]=r*c+o*h+u,t[5]=a*c+i*h+s,t},e.fromRotation=function(t,e){var n=Math.sin(e),r=Math.cos(e);return t[0]=r,t[1]=n,t[2]=-n,t[3]=r,t[4]=0,t[5]=0,t},e.fromScaling=function(t,e){return t[0]=e[0],t[1]=0,t[2]=0,t[3]=e[1],t[4]=0,t[5]=0,t},e.fromTranslation=function(t,e){return t[0]=1,t[1]=0,t[2]=0,t[3]=1,t[4]=e[0],t[5]=e[1],t},e.str=function(t){return"mat2d("+t[0]+", "+t[1]+", "+t[2]+", "+t[3]+", "+t[4]+", "+t[5]+")"},e.frob=function(t){return Math.sqrt(Math.pow(t[0],2)+Math.pow(t[1],2)+Math.pow(t[2],2)+Math.pow(t[3],2)+Math.pow(t[4],2)+Math.pow(t[5],2)+1)},e.add=function(t,e,n){return t[0]=e[0]+n[0],t[1]=e[1]+n[1],t[2]=e[2]+n[2],t[3]=e[3]+n[3],t[4]=e[4]+n[4],t[5]=e[5]+n[5],t},e.subtract=a,e.multiplyScalar=function(t,e,n){return t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t[3]=e[3]*n,t[4]=e[4]*n,t[5]=e[5]*n,t},e.multiplyScalarAndAdd=function(t,e,n,r){return t[0]=e[0]+n[0]*r,t[1]=e[1]+n[1]*r,t[2]=e[2]+n[2]*r,t[3]=e[3]+n[3]*r,t[4]=e[4]+n[4]*r,t[5]=e[5]+n[5]*r,t},e.exactEquals=function(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]&&t[3]===e[3]&&t[4]===e[4]&&t[5]===e[5]},e.equals=function(t,e){var n=t[0],r=t[1],a=t[2],o=t[3],i=t[4],u=t[5],s=e[0],c=e[1],h=e[2],l=e[3],f=e[4],v=e[5];return Math.abs(n-s)<=m.EPSILON*Math.max(1,Math.abs(n),Math.abs(s))&&Math.abs(r-c)<=m.EPSILON*Math.max(1,Math.abs(r),Math.abs(c))&&Math.abs(a-h)<=m.EPSILON*Math.max(1,Math.abs(a),Math.abs(h))&&Math.abs(o-l)<=m.EPSILON*Math.max(1,Math.abs(o),Math.abs(l))&&Math.abs(i-f)<=m.EPSILON*Math.max(1,Math.abs(i),Math.abs(f))&&Math.abs(u-v)<=m.EPSILON*Math.max(1,Math.abs(u),Math.abs(v))};var m=function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e.default=t,e}(n(0));e.mul=r,e.sub=a},function(t,e,n){"use strict";function r(t,e,n){var r=e[0],a=e[1],o=e[2],i=e[3],u=e[4],s=e[5],c=e[6],h=e[7],l=e[8],f=e[9],v=e[10],m=e[11],d=e[12],M=e[13],p=e[14],b=e[15],y=n[0],g=n[1],P=n[2],E=n[3];return t[0]=y*r+g*u+P*l+E*d,t[1]=y*a+g*s+P*f+E*M,t[2]=y*o+g*c+P*v+E*p,t[3]=y*i+g*h+P*m+E*b,y=n[4],g=n[5],P=n[6],E=n[7],t[4]=y*r+g*u+P*l+E*d,t[5]=y*a+g*s+P*f+E*M,t[6]=y*o+g*c+P*v+E*p,t[7]=y*i+g*h+P*m+E*b,y=n[8],g=n[9],P=n[10],E=n[11],t[8]=y*r+g*u+P*l+E*d,t[9]=y*a+g*s+P*f+E*M,t[10]=y*o+g*c+P*v+E*p,t[11]=y*i+g*h+P*m+E*b,y=n[12],g=n[13],P=n[14],E=n[15],t[12]=y*r+g*u+P*l+E*d,t[13]=y*a+g*s+P*f+E*M,t[14]=y*o+g*c+P*v+E*p,t[15]=y*i+g*h+P*m+E*b,t}function a(t,e,n){return t[0]=e[0]-n[0],t[1]=e[1]-n[1],t[2]=e[2]-n[2],t[3]=e[3]-n[3],t[4]=e[4]-n[4],t[5]=e[5]-n[5],t[6]=e[6]-n[6],t[7]=e[7]-n[7],t[8]=e[8]-n[8],t[9]=e[9]-n[9],t[10]=e[10]-n[10],t[11]=e[11]-n[11],t[12]=e[12]-n[12],t[13]=e[13]-n[13],t[14]=e[14]-n[14],t[15]=e[15]-n[15],t}Object.defineProperty(e,"__esModule",{value:!0}),e.sub=e.mul=void 0,e.create=function(){var t=new N.ARRAY_TYPE(16);return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t},e.clone=function(t){var e=new N.ARRAY_TYPE(16);return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e[4]=t[4],e[5]=t[5],e[6]=t[6],e[7]=t[7],e[8]=t[8],e[9]=t[9],e[10]=t[10],e[11]=t[11],e[12]=t[12],e[13]=t[13],e[14]=t[14],e[15]=t[15],e},e.copy=function(t,e){return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t},e.fromValues=function(t,e,n,r,a,o,i,u,s,c,h,l,f,v,m,d){var M=new N.ARRAY_TYPE(16);return M[0]=t,M[1]=e,M[2]=n,M[3]=r,M[4]=a,M[5]=o,M[6]=i,M[7]=u,M[8]=s,M[9]=c,M[10]=h,M[11]=l,M[12]=f,M[13]=v,M[14]=m,M[15]=d,M},e.set=function(t,e,n,r,a,o,i,u,s,c,h,l,f,v,m,d,M){return t[0]=e,t[1]=n,t[2]=r,t[3]=a,t[4]=o,t[5]=i,t[6]=u,t[7]=s,t[8]=c,t[9]=h,t[10]=l,t[11]=f,t[12]=v,t[13]=m,t[14]=d,t[15]=M,t},e.identity=function(t){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t},e.transpose=function(t,e){if(t===e){var n=e[1],r=e[2],a=e[3],o=e[6],i=e[7],u=e[11];t[1]=e[4],t[2]=e[8],t[3]=e[12],t[4]=n,t[6]=e[9],t[7]=e[13],t[8]=r,t[9]=o,t[11]=e[14],t[12]=a,t[13]=i,t[14]=u}else t[0]=e[0],t[1]=e[4],t[2]=e[8],t[3]=e[12],t[4]=e[1],t[5]=e[5],t[6]=e[9],t[7]=e[13],t[8]=e[2],t[9]=e[6],t[10]=e[10],t[11]=e[14],t[12]=e[3],t[13]=e[7],t[14]=e[11],t[15]=e[15];return t},e.invert=function(t,e){var n=e[0],r=e[1],a=e[2],o=e[3],i=e[4],u=e[5],s=e[6],c=e[7],h=e[8],l=e[9],f=e[10],v=e[11],m=e[12],d=e[13],M=e[14],p=e[15],b=n*u-r*i,y=n*s-a*i,g=n*c-o*i,P=r*s-a*u,E=r*c-o*u,x=a*c-o*s,w=h*d-l*m,_=h*M-f*m,O=h*p-v*m,k=l*M-f*d,S=l*p-v*d,A=f*p-v*M,q=b*A-y*S+g*k+P*O-E*_+x*w;return q?(q=1/q,t[0]=(u*A-s*S+c*k)*q,t[1]=(a*S-r*A-o*k)*q,t[2]=(d*x-M*E+p*P)*q,t[3]=(f*E-l*x-v*P)*q,t[4]=(s*O-i*A-c*_)*q,t[5]=(n*A-a*O+o*_)*q,t[6]=(M*g-m*x-p*y)*q,t[7]=(h*x-f*g+v*y)*q,t[8]=(i*S-u*O+c*w)*q,t[9]=(r*O-n*S-o*w)*q,t[10]=(m*E-d*g+p*b)*q,t[11]=(l*g-h*E-v*b)*q,t[12]=(u*_-i*k-s*w)*q,t[13]=(n*k-r*_+a*w)*q,t[14]=(d*y-m*P-M*b)*q,t[15]=(h*P-l*y+f*b)*q,t):null},e.adjoint=function(t,e){var n=e[0],r=e[1],a=e[2],o=e[3],i=e[4],u=e[5],s=e[6],c=e[7],h=e[8],l=e[9],f=e[10],v=e[11],m=e[12],d=e[13],M=e[14],p=e[15];return t[0]=u*(f*p-v*M)-l*(s*p-c*M)+d*(s*v-c*f),t[1]=-(r*(f*p-v*M)-l*(a*p-o*M)+d*(a*v-o*f)),t[2]=r*(s*p-c*M)-u*(a*p-o*M)+d*(a*c-o*s),t[3]=-(r*(s*v-c*f)-u*(a*v-o*f)+l*(a*c-o*s)),t[4]=-(i*(f*p-v*M)-h*(s*p-c*M)+m*(s*v-c*f)),t[5]=n*(f*p-v*M)-h*(a*p-o*M)+m*(a*v-o*f),t[6]=-(n*(s*p-c*M)-i*(a*p-o*M)+m*(a*c-o*s)),t[7]=n*(s*v-c*f)-i*(a*v-o*f)+h*(a*c-o*s),t[8]=i*(l*p-v*d)-h*(u*p-c*d)+m*(u*v-c*l),t[9]=-(n*(l*p-v*d)-h*(r*p-o*d)+m*(r*v-o*l)),t[10]=n*(u*p-c*d)-i*(r*p-o*d)+m*(r*c-o*u),t[11]=-(n*(u*v-c*l)-i*(r*v-o*l)+h*(r*c-o*u)),t[12]=-(i*(l*M-f*d)-h*(u*M-s*d)+m*(u*f-s*l)),t[13]=n*(l*M-f*d)-h*(r*M-a*d)+m*(r*f-a*l),t[14]=-(n*(u*M-s*d)-i*(r*M-a*d)+m*(r*s-a*u)),t[15]=n*(u*f-s*l)-i*(r*f-a*l)+h*(r*s-a*u),t},e.determinant=function(t){var e=t[0],n=t[1],r=t[2],a=t[3],o=t[4],i=t[5],u=t[6],s=t[7],c=t[8],h=t[9],l=t[10],f=t[11],v=t[12],m=t[13],d=t[14],M=t[15];return(e*i-n*o)*(l*M-f*d)-(e*u-r*o)*(h*M-f*m)+(e*s-a*o)*(h*d-l*m)+(n*u-r*i)*(c*M-f*v)-(n*s-a*i)*(c*d-l*v)+(r*s-a*u)*(c*m-h*v)},e.multiply=r,e.translate=function(t,e,n){var r=n[0],a=n[1],o=n[2],i=void 0,u=void 0,s=void 0,c=void 0,h=void 0,l=void 0,f=void 0,v=void 0,m=void 0,d=void 0,M=void 0,p=void 0;return e===t?(t[12]=e[0]*r+e[4]*a+e[8]*o+e[12],t[13]=e[1]*r+e[5]*a+e[9]*o+e[13],t[14]=e[2]*r+e[6]*a+e[10]*o+e[14],t[15]=e[3]*r+e[7]*a+e[11]*o+e[15]):(i=e[0],u=e[1],s=e[2],c=e[3],h=e[4],l=e[5],f=e[6],v=e[7],m=e[8],d=e[9],M=e[10],p=e[11],t[0]=i,t[1]=u,t[2]=s,t[3]=c,t[4]=h,t[5]=l,t[6]=f,t[7]=v,t[8]=m,t[9]=d,t[10]=M,t[11]=p,t[12]=i*r+h*a+m*o+e[12],t[13]=u*r+l*a+d*o+e[13],t[14]=s*r+f*a+M*o+e[14],t[15]=c*r+v*a+p*o+e[15]),t},e.scale=function(t,e,n){var r=n[0],a=n[1],o=n[2];return t[0]=e[0]*r,t[1]=e[1]*r,t[2]=e[2]*r,t[3]=e[3]*r,t[4]=e[4]*a,t[5]=e[5]*a,t[6]=e[6]*a,t[7]=e[7]*a,t[8]=e[8]*o,t[9]=e[9]*o,t[10]=e[10]*o,t[11]=e[11]*o,t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15],t},e.rotate=function(t,e,n,r){var a=r[0],o=r[1],i=r[2],u=Math.sqrt(a*a+o*o+i*i),s=void 0,c=void 0,h=void 0,l=void 0,f=void 0,v=void 0,m=void 0,d=void 0,M=void 0,p=void 0,b=void 0,y=void 0,g=void 0,P=void 0,E=void 0,x=void 0,w=void 0,_=void 0,O=void 0,k=void 0,S=void 0,A=void 0,q=void 0,R=void 0;return Math.abs(u)<N.EPSILON?null:(a*=u=1/u,o*=u,i*=u,s=Math.sin(n),h=1-(c=Math.cos(n)),l=e[0],f=e[1],v=e[2],m=e[3],d=e[4],M=e[5],p=e[6],b=e[7],y=e[8],g=e[9],P=e[10],E=e[11],x=a*a*h+c,w=o*a*h+i*s,_=i*a*h-o*s,O=a*o*h-i*s,k=o*o*h+c,S=i*o*h+a*s,A=a*i*h+o*s,q=o*i*h-a*s,R=i*i*h+c,t[0]=l*x+d*w+y*_,t[1]=f*x+M*w+g*_,t[2]=v*x+p*w+P*_,t[3]=m*x+b*w+E*_,t[4]=l*O+d*k+y*S,t[5]=f*O+M*k+g*S,t[6]=v*O+p*k+P*S,t[7]=m*O+b*k+E*S,t[8]=l*A+d*q+y*R,t[9]=f*A+M*q+g*R,t[10]=v*A+p*q+P*R,t[11]=m*A+b*q+E*R,e!==t&&(t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t)},e.rotateX=function(t,e,n){var r=Math.sin(n),a=Math.cos(n),o=e[4],i=e[5],u=e[6],s=e[7],c=e[8],h=e[9],l=e[10],f=e[11];return e!==t&&(t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[4]=o*a+c*r,t[5]=i*a+h*r,t[6]=u*a+l*r,t[7]=s*a+f*r,t[8]=c*a-o*r,t[9]=h*a-i*r,t[10]=l*a-u*r,t[11]=f*a-s*r,t},e.rotateY=function(t,e,n){var r=Math.sin(n),a=Math.cos(n),o=e[0],i=e[1],u=e[2],s=e[3],c=e[8],h=e[9],l=e[10],f=e[11];return e!==t&&(t[4]=e[4],t[5]=e[5],t[6]=e[6],t[7]=e[7],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=o*a-c*r,t[1]=i*a-h*r,t[2]=u*a-l*r,t[3]=s*a-f*r,t[8]=o*r+c*a,t[9]=i*r+h*a,t[10]=u*r+l*a,t[11]=s*r+f*a,t},e.rotateZ=function(t,e,n){var r=Math.sin(n),a=Math.cos(n),o=e[0],i=e[1],u=e[2],s=e[3],c=e[4],h=e[5],l=e[6],f=e[7];return e!==t&&(t[8]=e[8],t[9]=e[9],t[10]=e[10],t[11]=e[11],t[12]=e[12],t[13]=e[13],t[14]=e[14],t[15]=e[15]),t[0]=o*a+c*r,t[1]=i*a+h*r,t[2]=u*a+l*r,t[3]=s*a+f*r,t[4]=c*a-o*r,t[5]=h*a-i*r,t[6]=l*a-u*r,t[7]=f*a-s*r,t},e.fromTranslation=function(t,e){return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=e[0],t[13]=e[1],t[14]=e[2],t[15]=1,t},e.fromScaling=function(t,e){return t[0]=e[0],t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=e[1],t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=e[2],t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t},e.fromRotation=function(t,e,n){var r=n[0],a=n[1],o=n[2],i=Math.sqrt(r*r+a*a+o*o),u=void 0,s=void 0,c=void 0;return Math.abs(i)<N.EPSILON?null:(r*=i=1/i,a*=i,o*=i,u=Math.sin(e),c=1-(s=Math.cos(e)),t[0]=r*r*c+s,t[1]=a*r*c+o*u,t[2]=o*r*c-a*u,t[3]=0,t[4]=r*a*c-o*u,t[5]=a*a*c+s,t[6]=o*a*c+r*u,t[7]=0,t[8]=r*o*c+a*u,t[9]=a*o*c-r*u,t[10]=o*o*c+s,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t)},e.fromXRotation=function(t,e){var n=Math.sin(e),r=Math.cos(e);return t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=r,t[6]=n,t[7]=0,t[8]=0,t[9]=-n,t[10]=r,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t},e.fromYRotation=function(t,e){var n=Math.sin(e),r=Math.cos(e);return t[0]=r,t[1]=0,t[2]=-n,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=n,t[9]=0,t[10]=r,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t},e.fromZRotation=function(t,e){var n=Math.sin(e),r=Math.cos(e);return t[0]=r,t[1]=n,t[2]=0,t[3]=0,t[4]=-n,t[5]=r,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t},e.fromRotationTranslation=function(t,e,n){var r=e[0],a=e[1],o=e[2],i=e[3],u=r+r,s=a+a,c=o+o,h=r*u,l=r*s,f=r*c,v=a*s,m=a*c,d=o*c,M=i*u,p=i*s,b=i*c;return t[0]=1-(v+d),t[1]=l+b,t[2]=f-p,t[3]=0,t[4]=l-b,t[5]=1-(h+d),t[6]=m+M,t[7]=0,t[8]=f+p,t[9]=m-M,t[10]=1-(h+v),t[11]=0,t[12]=n[0],t[13]=n[1],t[14]=n[2],t[15]=1,t},e.getTranslation=function(t,e){return t[0]=e[12],t[1]=e[13],t[2]=e[14],t},e.getScaling=function(t,e){var n=e[0],r=e[1],a=e[2],o=e[4],i=e[5],u=e[6],s=e[8],c=e[9],h=e[10];return t[0]=Math.sqrt(n*n+r*r+a*a),t[1]=Math.sqrt(o*o+i*i+u*u),t[2]=Math.sqrt(s*s+c*c+h*h),t},e.getRotation=function(t,e){var n=e[0]+e[5]+e[10],r=0;return 0<n?(r=2*Math.sqrt(n+1),t[3]=.25*r,t[0]=(e[6]-e[9])/r,t[1]=(e[8]-e[2])/r,t[2]=(e[1]-e[4])/r):e[0]>e[5]&e[0]>e[10]?(r=2*Math.sqrt(1+e[0]-e[5]-e[10]),t[3]=(e[6]-e[9])/r,t[0]=.25*r,t[1]=(e[1]+e[4])/r,t[2]=(e[8]+e[2])/r):e[5]>e[10]?(r=2*Math.sqrt(1+e[5]-e[0]-e[10]),t[3]=(e[8]-e[2])/r,t[0]=(e[1]+e[4])/r,t[1]=.25*r,t[2]=(e[6]+e[9])/r):(r=2*Math.sqrt(1+e[10]-e[0]-e[5]),t[3]=(e[1]-e[4])/r,t[0]=(e[8]+e[2])/r,t[1]=(e[6]+e[9])/r,t[2]=.25*r),t},e.fromRotationTranslationScale=function(t,e,n,r){var a=e[0],o=e[1],i=e[2],u=e[3],s=a+a,c=o+o,h=i+i,l=a*s,f=a*c,v=a*h,m=o*c,d=o*h,M=i*h,p=u*s,b=u*c,y=u*h,g=r[0],P=r[1],E=r[2];return t[0]=(1-(m+M))*g,t[1]=(f+y)*g,t[2]=(v-b)*g,t[3]=0,t[4]=(f-y)*P,t[5]=(1-(l+M))*P,t[6]=(d+p)*P,t[7]=0,t[8]=(v+b)*E,t[9]=(d-p)*E,t[10]=(1-(l+m))*E,t[11]=0,t[12]=n[0],t[13]=n[1],t[14]=n[2],t[15]=1,t},e.fromRotationTranslationScaleOrigin=function(t,e,n,r,a){var o=e[0],i=e[1],u=e[2],s=e[3],c=o+o,h=i+i,l=u+u,f=o*c,v=o*h,m=o*l,d=i*h,M=i*l,p=u*l,b=s*c,y=s*h,g=s*l,P=r[0],E=r[1],x=r[2],w=a[0],_=a[1],O=a[2];return t[0]=(1-(d+p))*P,t[1]=(v+g)*P,t[2]=(m-y)*P,t[3]=0,t[4]=(v-g)*E,t[5]=(1-(f+p))*E,t[6]=(M+b)*E,t[7]=0,t[8]=(m+y)*x,t[9]=(M-b)*x,t[10]=(1-(f+d))*x,t[11]=0,t[12]=n[0]+w-(t[0]*w+t[4]*_+t[8]*O),t[13]=n[1]+_-(t[1]*w+t[5]*_+t[9]*O),t[14]=n[2]+O-(t[2]*w+t[6]*_+t[10]*O),t[15]=1,t},e.fromQuat=function(t,e){var n=e[0],r=e[1],a=e[2],o=e[3],i=n+n,u=r+r,s=a+a,c=n*i,h=r*i,l=r*u,f=a*i,v=a*u,m=a*s,d=o*i,M=o*u,p=o*s;return t[0]=1-l-m,t[1]=h+p,t[2]=f-M,t[3]=0,t[4]=h-p,t[5]=1-c-m,t[6]=v+d,t[7]=0,t[8]=f+M,t[9]=v-d,t[10]=1-c-l,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t},e.frustum=function(t,e,n,r,a,o,i){var u=1/(n-e),s=1/(a-r),c=1/(o-i);return t[0]=2*o*u,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=2*o*s,t[6]=0,t[7]=0,t[8]=(n+e)*u,t[9]=(a+r)*s,t[10]=(i+o)*c,t[11]=-1,t[12]=0,t[13]=0,t[14]=i*o*2*c,t[15]=0,t},e.perspective=function(t,e,n,r,a){var o=1/Math.tan(e/2),i=1/(r-a);return t[0]=o/n,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=o,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=(a+r)*i,t[11]=-1,t[12]=0,t[13]=0,t[14]=2*a*r*i,t[15]=0,t},e.perspectiveFromFieldOfView=function(t,e,n,r){var a=Math.tan(e.upDegrees*Math.PI/180),o=Math.tan(e.downDegrees*Math.PI/180),i=Math.tan(e.leftDegrees*Math.PI/180),u=Math.tan(e.rightDegrees*Math.PI/180),s=2/(i+u),c=2/(a+o);return t[0]=s,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=c,t[6]=0,t[7]=0,t[8]=-(i-u)*s*.5,t[9]=(a-o)*c*.5,t[10]=r/(n-r),t[11]=-1,t[12]=0,t[13]=0,t[14]=r*n/(n-r),t[15]=0,t},e.ortho=function(t,e,n,r,a,o,i){var u=1/(e-n),s=1/(r-a),c=1/(o-i);return t[0]=-2*u,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=-2*s,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=2*c,t[11]=0,t[12]=(e+n)*u,t[13]=(a+r)*s,t[14]=(i+o)*c,t[15]=1,t},e.lookAt=function(t,e,n,r){var a=void 0,o=void 0,i=void 0,u=void 0,s=void 0,c=void 0,h=void 0,l=void 0,f=void 0,v=void 0,m=e[0],d=e[1],M=e[2],p=r[0],b=r[1],y=r[2],g=n[0],P=n[1],E=n[2];return Math.abs(m-g)<N.EPSILON&&Math.abs(d-P)<N.EPSILON&&Math.abs(M-E)<N.EPSILON?mat4.identity(t):(h=m-g,l=d-P,f=M-E,a=b*(f*=v=1/Math.sqrt(h*h+l*l+f*f))-y*(l*=v),o=y*(h*=v)-p*f,i=p*l-b*h,(v=Math.sqrt(a*a+o*o+i*i))?(a*=v=1/v,o*=v,i*=v):i=o=a=0,u=l*i-f*o,s=f*a-h*i,c=h*o-l*a,(v=Math.sqrt(u*u+s*s+c*c))?(u*=v=1/v,s*=v,c*=v):c=s=u=0,t[0]=a,t[1]=u,t[2]=h,t[3]=0,t[4]=o,t[5]=s,t[6]=l,t[7]=0,t[8]=i,t[9]=c,t[10]=f,t[11]=0,t[12]=-(a*m+o*d+i*M),t[13]=-(u*m+s*d+c*M),t[14]=-(h*m+l*d+f*M),t[15]=1,t)},e.targetTo=function(t,e,n,r){var a=e[0],o=e[1],i=e[2],u=r[0],s=r[1],c=r[2],h=a-n[0],l=o-n[1],f=i-n[2],v=h*h+l*l+f*f;0<v&&(h*=v=1/Math.sqrt(v),l*=v,f*=v);var m=s*f-c*l,d=c*h-u*f,M=u*l-s*h;return t[0]=m,t[1]=d,t[2]=M,t[3]=0,t[4]=l*M-f*d,t[5]=f*m-h*M,t[6]=h*d-l*m,t[7]=0,t[8]=h,t[9]=l,t[10]=f,t[11]=0,t[12]=a,t[13]=o,t[14]=i,t[15]=1,t},e.str=function(t){return"mat4("+t[0]+", "+t[1]+", "+t[2]+", "+t[3]+", "+t[4]+", "+t[5]+", "+t[6]+", "+t[7]+", "+t[8]+", "+t[9]+", "+t[10]+", "+t[11]+", "+t[12]+", "+t[13]+", "+t[14]+", "+t[15]+")"},e.frob=function(t){return Math.sqrt(Math.pow(t[0],2)+Math.pow(t[1],2)+Math.pow(t[2],2)+Math.pow(t[3],2)+Math.pow(t[4],2)+Math.pow(t[5],2)+Math.pow(t[6],2)+Math.pow(t[7],2)+Math.pow(t[8],2)+Math.pow(t[9],2)+Math.pow(t[10],2)+Math.pow(t[11],2)+Math.pow(t[12],2)+Math.pow(t[13],2)+Math.pow(t[14],2)+Math.pow(t[15],2))},e.add=function(t,e,n){return t[0]=e[0]+n[0],t[1]=e[1]+n[1],t[2]=e[2]+n[2],t[3]=e[3]+n[3],t[4]=e[4]+n[4],t[5]=e[5]+n[5],t[6]=e[6]+n[6],t[7]=e[7]+n[7],t[8]=e[8]+n[8],t[9]=e[9]+n[9],t[10]=e[10]+n[10],t[11]=e[11]+n[11],t[12]=e[12]+n[12],t[13]=e[13]+n[13],t[14]=e[14]+n[14],t[15]=e[15]+n[15],t},e.subtract=a,e.multiplyScalar=function(t,e,n){return t[0]=e[0]*n,t[1]=e[1]*n,t[2]=e[2]*n,t[3]=e[3]*n,t[4]=e[4]*n,t[5]=e[5]*n,t[6]=e[6]*n,t[7]=e[7]*n,t[8]=e[8]*n,t[9]=e[9]*n,t[10]=e[10]*n,t[11]=e[11]*n,t[12]=e[12]*n,t[13]=e[13]*n,t[14]=e[14]*n,t[15]=e[15]*n,t},e.multiplyScalarAndAdd=function(t,e,n,r){return t[0]=e[0]+n[0]*r,t[1]=e[1]+n[1]*r,t[2]=e[2]+n[2]*r,t[3]=e[3]+n[3]*r,t[4]=e[4]+n[4]*r,t[5]=e[5]+n[5]*r,t[6]=e[6]+n[6]*r,t[7]=e[7]+n[7]*r,t[8]=e[8]+n[8]*r,t[9]=e[9]+n[9]*r,t[10]=e[10]+n[10]*r,t[11]=e[11]+n[11]*r,t[12]=e[12]+n[12]*r,t[13]=e[13]+n[13]*r,t[14]=e[14]+n[14]*r,t[15]=e[15]+n[15]*r,t},e.exactEquals=function(t,e){return t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2]&&t[3]===e[3]&&t[4]===e[4]&&t[5]===e[5]&&t[6]===e[6]&&t[7]===e[7]&&t[8]===e[8]&&t[9]===e[9]&&t[10]===e[10]&&t[11]===e[11]&&t[12]===e[12]&&t[13]===e[13]&&t[14]===e[14]&&t[15]===e[15]},e.equals=function(t,e){var n=t[0],r=t[1],a=t[2],o=t[3],i=t[4],u=t[5],s=t[6],c=t[7],h=t[8],l=t[9],f=t[10],v=t[11],m=t[12],d=t[13],M=t[14],p=t[15],b=e[0],y=e[1],g=e[2],P=e[3],E=e[4],x=e[5],w=e[6],_=e[7],O=e[8],k=e[9],S=e[10],A=e[11],q=e[12],R=e[13],I=e[14],L=e[15];return Math.abs(n-b)<=N.EPSILON*Math.max(1,Math.abs(n),Math.abs(b))&&Math.abs(r-y)<=N.EPSILON*Math.max(1,Math.abs(r),Math.abs(y))&&Math.abs(a-g)<=N.EPSILON*Math.max(1,Math.abs(a),Math.abs(g))&&Math.abs(o-P)<=N.EPSILON*Math.max(1,Math.abs(o),Math.abs(P))&&Math.abs(i-E)<=N.EPSILON*Math.max(1,Math.abs(i),Math.abs(E))&&Math.abs(u-x)<=N.EPSILON*Math.max(1,Math.abs(u),Math.abs(x))&&Math.abs(s-w)<=N.EPSILON*Math.max(1,Math.abs(s),Math.abs(w))&&Math.abs(c-_)<=N.EPSILON*Math.max(1,Math.abs(c),Math.abs(_))&&Math.abs(h-O)<=N.EPSILON*Math.max(1,Math.abs(h),Math.abs(O))&&Math.abs(l-k)<=N.EPSILON*Math.max(1,Math.abs(l),Math.abs(k))&&Math.abs(f-S)<=N.EPSILON*Math.max(1,Math.abs(f),Math.abs(S))&&Math.abs(v-A)<=N.EPSILON*Math.max(1,Math.abs(v),Math.abs(A))&&Math.abs(m-q)<=N.EPSILON*Math.max(1,Math.abs(m),Math.abs(q))&&Math.abs(d-R)<=N.EPSILON*Math.max(1,Math.abs(d),Math.abs(R))&&Math.abs(M-I)<=N.EPSILON*Math.max(1,Math.abs(M),Math.abs(I))&&Math.abs(p-L)<=N.EPSILON*Math.max(1,Math.abs(p),Math.abs(L))};var N=function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e.default=t,e}(n(0));e.mul=r,e.sub=a},function(t,e,n){"use strict";function r(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e.default=t,e}function a(){var t=new d.ARRAY_TYPE(4);return t[0]=0,t[1]=0,t[2]=0,t[3]=1,t}function o(t,e,n){n*=.5;var r=Math.sin(n);return t[0]=r*e[0],t[1]=r*e[1],t[2]=r*e[2],t[3]=Math.cos(n),t}function i(t,e,n){var r=e[0],a=e[1],o=e[2],i=e[3],u=n[0],s=n[1],c=n[2],h=n[3];return t[0]=r*h+i*u+a*c-o*s,t[1]=a*h+i*s+o*u-r*c,t[2]=o*h+i*c+r*s-a*u,t[3]=i*h-r*u-a*s-o*c,t}function u(t,e,n,r){var a=e[0],o=e[1],i=e[2],u=e[3],s=n[0],c=n[1],h=n[2],l=n[3],f=void 0,v=void 0,m=void 0,d=void 0,M=void 0;return(v=a*s+o*c+i*h+u*l)<0&&(v=-v,s=-s,c=-c,h=-h,l=-l),1e-6<1-v?(f=Math.acos(v),m=Math.sin(f),d=Math.sin((1-r)*f)/m,M=Math.sin(r*f)/m):(d=1-r,M=r),t[0]=d*a+M*s,t[1]=d*o+M*c,t[2]=d*i+M*h,t[3]=d*u+M*l,t}function s(t,e){var n=e[0]+e[4]+e[8],r=void 0;if(0<n)r=Math.sqrt(n+1),t[3]=.5*r,r=.5/r,t[0]=(e[5]-e[7])*r,t[1]=(e[6]-e[2])*r,t[2]=(e[1]-e[3])*r;else{var a=0;e[4]>e[0]&&(a=1),e[8]>e[3*a+a]&&(a=2);var o=(a+1)%3,i=(a+2)%3;r=Math.sqrt(e[3*a+a]-e[3*o+o]-e[3*i+i]+1),t[a]=.5*r,r=.5/r,t[3]=(e[3*o+i]-e[3*i+o])*r,t[o]=(e[3*o+a]+e[3*a+o])*r,t[i]=(e[3*i+a]+e[3*a+i])*r}return t}Object.defineProperty(e,"__esModule",{value:!0}),e.setAxes=e.sqlerp=e.rotationTo=e.equals=e.exactEquals=e.normalize=e.sqrLen=e.squaredLength=e.len=e.length=e.lerp=e.dot=e.scale=e.mul=e.add=e.set=e.copy=e.fromValues=e.clone=void 0,e.create=a,e.identity=function(t){return t[0]=0,t[1]=0,t[2]=0,t[3]=1,t},e.setAxisAngle=o,e.getAxisAngle=function(t,e){var n=2*Math.acos(e[3]),r=Math.sin(n/2);return 0!=r?(t[0]=e[0]/r,t[1]=e[1]/r,t[2]=e[2]/r):(t[0]=1,t[1]=0,t[2]=0),n},e.multiply=i,e.rotateX=function(t,e,n){n*=.5;var r=e[0],a=e[1],o=e[2],i=e[3],u=Math.sin(n),s=Math.cos(n);return t[0]=r*s+i*u,t[1]=a*s+o*u,t[2]=o*s-a*u,t[3]=i*s-r*u,t},e.rotateY=function(t,e,n){n*=.5;var r=e[0],a=e[1],o=e[2],i=e[3],u=Math.sin(n),s=Math.cos(n);return t[0]=r*s-o*u,t[1]=a*s+i*u,t[2]=o*s+r*u,t[3]=i*s-a*u,t},e.rotateZ=function(t,e,n){n*=.5;var r=e[0],a=e[1],o=e[2],i=e[3],u=Math.sin(n),s=Math.cos(n);return t[0]=r*s+a*u,t[1]=a*s-r*u,t[2]=o*s+i*u,t[3]=i*s-o*u,t},e.calculateW=function(t,e){var n=e[0],r=e[1],a=e[2];return t[0]=n,t[1]=r,t[2]=a,t[3]=Math.sqrt(Math.abs(1-n*n-r*r-a*a)),t},e.slerp=u,e.invert=function(t,e){var n=e[0],r=e[1],a=e[2],o=e[3],i=n*n+r*r+a*a+o*o,u=i?1/i:0;return t[0]=-n*u,t[1]=-r*u,t[2]=-a*u,t[3]=o*u,t},e.conjugate=function(t,e){return t[0]=-e[0],t[1]=-e[1],t[2]=-e[2],t[3]=e[3],t},e.fromMat3=s,e.fromEuler=function(t,e,n,r){var a=.5*Math.PI/180;e*=a,n*=a,r*=a;var o=Math.sin(e),i=Math.cos(e),u=Math.sin(n),s=Math.cos(n),c=Math.sin(r),h=Math.cos(r);return t[0]=o*s*h-i*u*c,t[1]=i*u*h+o*s*c,t[2]=i*s*c-o*u*h,t[3]=i*s*h+o*u*c,t},e.str=function(t){return"quat("+t[0]+", "+t[1]+", "+t[2]+", "+t[3]+")"};var c,h,l,f,v,m,d=r(n(0)),M=r(n(1)),p=r(n(2)),b=r(n(3)),y=(e.clone=b.clone,e.fromValues=b.fromValues,e.copy=b.copy,e.set=b.set,e.add=b.add,e.mul=i,e.scale=b.scale,e.dot=b.dot,e.lerp=b.lerp,e.length=b.length),g=(e.len=y,e.squaredLength=b.squaredLength),P=(e.sqrLen=g,e.normalize=b.normalize);e.exactEquals=b.exactEquals,e.equals=b.equals,e.rotationTo=(f=p.create(),v=p.fromValues(1,0,0),m=p.fromValues(0,1,0),function(t,e,n){var r=p.dot(e,n);return r<-.999999?(p.cross(f,v,e),p.len(f)<1e-6&&p.cross(f,m,e),p.normalize(f,f),o(t,f,Math.PI),t):.999999<r?(t[0]=0,t[1]=0,t[2]=0,t[3]=1,t):(p.cross(f,e,n),t[0]=f[0],t[1]=f[1],t[2]=f[2],t[3]=1+r,P(t,t))}),e.sqlerp=(h=a(),l=a(),function(t,e,n,r,a,o){return u(h,e,a,o),u(l,n,r,o),u(t,h,l,2*o*(1-o)),t}),e.setAxes=(c=M.create(),function(t,e,n,r){return c[0]=n[0],c[3]=n[1],c[6]=n[2],c[1]=r[0],c[4]=r[1],c[7]=r[2],c[2]=-e[0],c[5]=-e[1],c[8]=-e[2],P(t,s(t,c))})},function(t,e,n){"use strict";function r(){var t=new f.ARRAY_TYPE(2);return t[0]=0,t[1]=0,t}function a(t,e,n){return t[0]=e[0]-n[0],t[1]=e[1]-n[1],t}function o(t,e,n){return t[0]=e[0]*n[0],t[1]=e[1]*n[1],t}function i(t,e,n){return t[0]=e[0]/n[0],t[1]=e[1]/n[1],t}function u(t,e){var n=e[0]-t[0],r=e[1]-t[1];return Math.sqrt(n*n+r*r)}function s(t,e){var n=e[0]-t[0],r=e[1]-t[1];return n*n+r*r}function c(t){var e=t[0],n=t[1];return Math.sqrt(e*e+n*n)}function h(t){var e=t[0],n=t[1];return e*e+n*n}Object.defineProperty(e,"__esModule",{value:!0}),e.forEach=e.sqrLen=e.sqrDist=e.dist=e.div=e.mul=e.sub=e.len=void 0,e.create=r,e.clone=function(t){var e=new f.ARRAY_TYPE(2);return e[0]=t[0],e[1]=t[1],e},e.fromValues=function(t,e){var n=new f.ARRAY_TYPE(2);return n[0]=t,n[1]=e,n},e.copy=function(t,e){return t[0]=e[0],t[1]=e[1],t},e.set=function(t,e,n){return t[0]=e,t[1]=n,t},e.add=function(t,e,n){return t[0]=e[0]+n[0],t[1]=e[1]+n[1],t},e.subtract=a,e.multiply=o,e.divide=i,e.ceil=function(t,e){return t[0]=Math.ceil(e[0]),t[1]=Math.ceil(e[1]),t},e.floor=function(t,e){return t[0]=Math.floor(e[0]),t[1]=Math.floor(e[1]),t},e.min=function(t,e,n){return t[0]=Math.min(e[0],n[0]),t[1]=Math.min(e[1],n[1]),t},e.max=function(t,e,n){return t[0]=Math.max(e[0],n[0]),t[1]=Math.max(e[1],n[1]),t},e.round=function(t,e){return t[0]=Math.round(e[0]),t[1]=Math.round(e[1]),t},e.scale=function(t,e,n){return t[0]=e[0]*n,t[1]=e[1]*n,t},e.scaleAndAdd=function(t,e,n,r){return t[0]=e[0]+n[0]*r,t[1]=e[1]+n[1]*r,t},e.distance=u,e.squaredDistance=s,e.length=c,e.squaredLength=h,e.negate=function(t,e){return t[0]=-e[0],t[1]=-e[1],t},e.inverse=function(t,e){return t[0]=1/e[0],t[1]=1/e[1],t},e.normalize=function(t,e){var n=e[0],r=e[1],a=n*n+r*r;return 0<a&&(a=1/Math.sqrt(a),t[0]=e[0]*a,t[1]=e[1]*a),t},e.dot=function(t,e){return t[0]*e[0]+t[1]*e[1]},e.cross=function(t,e,n){var r=e[0]*n[1]-e[1]*n[0];return t[0]=t[1]=0,t[2]=r,t},e.lerp=function(t,e,n,r){var a=e[0],o=e[1];return t[0]=a+r*(n[0]-a),t[1]=o+r*(n[1]-o),t},e.random=function(t,e){e=e||1;var n=2*f.RANDOM()*Math.PI;return t[0]=Math.cos(n)*e,t[1]=Math.sin(n)*e,t},e.transformMat2=function(t,e,n){var r=e[0],a=e[1];return t[0]=n[0]*r+n[2]*a,t[1]=n[1]*r+n[3]*a,t},e.transformMat2d=function(t,e,n){var r=e[0],a=e[1];return t[0]=n[0]*r+n[2]*a+n[4],t[1]=n[1]*r+n[3]*a+n[5],t},e.transformMat3=function(t,e,n){var r=e[0],a=e[1];return t[0]=n[0]*r+n[3]*a+n[6],t[1]=n[1]*r+n[4]*a+n[7],t},e.transformMat4=function(t,e,n){var r=e[0],a=e[1];return t[0]=n[0]*r+n[4]*a+n[12],t[1]=n[1]*r+n[5]*a+n[13],t},e.str=function(t){return"vec2("+t[0]+", "+t[1]+")"},e.exactEquals=function(t,e){return t[0]===e[0]&&t[1]===e[1]},e.equals=function(t,e){var n=t[0],r=t[1],a=e[0],o=e[1];return Math.abs(n-a)<=f.EPSILON*Math.max(1,Math.abs(n),Math.abs(a))&&Math.abs(r-o)<=f.EPSILON*Math.max(1,Math.abs(r),Math.abs(o))};var l,f=function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e.default=t,e}(n(0));e.len=c,e.sub=a,e.mul=o,e.div=i,e.dist=u,e.sqrDist=s,e.sqrLen=h,e.forEach=(l=r(),function(t,e,n,r,a,o){var i,u=void 0;for(e||(e=2),n||(n=0),i=r?Math.min(r*e+n,t.length):t.length,u=n;u<i;u+=e)l[0]=t[u],l[1]=t[u+1],a(l,l,o),t[u]=l[0],t[u+1]=l[1];return t})}])}),
/**
* @license
* The MIT License
*
* Copyright © 2018 Adam Kecskes
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(t.C3R={})}(this,function(t){"use strict";var o=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},r=function(){function r(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}return function(t,e,n){return e&&r(t.prototype,e),n&&r(t,n),t}}(),a=function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)},i=function(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e},u=function(){function e(){o(this,e),this.class_name="c3r-"+e.id_counter++,this.properties=new Map,this.domElement=document.createElement("style")}return r(e,[{key:"init",value:function(){document.head.appendChild(this.domElement)}},{key:"unload",value:function(){document.head.removeChild(this.domElement)}},{key:"attach",value:function(t){t.classList.add(this.class_name)}},{key:"detach",value:function(t){t.classList.remove(this.class_name)}},{key:"setProperty",value:function(t,e){this.properties.set(t,e)}},{key:"setProperties",value:function(t){for(var e in t)this.setProperty(e,t[e])}},{key:"update",value:function(){this.domElement.innerHTML="."+this.class_name+"{"+Array.from(this.properties.entries()).map(function(t){return t.join(":")}).join(";")+"}"}},{key:"clone",value:function(){var t=new e;return t.properties=new Map(this.properties),t}}]),e}();u.id_counter=0;var e=function(){function t(){o(this,t),this.backgroundImageSrc=null,this.backgroundColor=null,this.opacity=1}return r(t,[{key:"apply",value:function(t){this.backgroundImageSrc?t.style.setProperty("--background-image","url('"+this.backgroundImageSrc+"')"):t.style.removeProperty("--background-image"),this.backgroundColor?t.style.setProperty("--background-color","rgba("+[Math.round(255*this.backgroundColor[0]),Math.round(255*this.backgroundColor[1]),Math.round(255*this.backgroundColor[2]),this.backgroundColor[3]].join()+")"):t.style.removeProperty("--background-color"),1==this.opacity?t.style.removeProperty("--opacity"):t.style.setProperty("--opacity",this.opacity)}}]),t}(),s=function(){function t(){o(this,t),this.matrix=mat4.create(),this.domElement=document.createElement("div"),this.material=null}return r(t,[{key:"updateMatrix",value:function(){this.domElement.style.transform="matrix3d("+this.matrix.join()+")"}},{key:"clearMatrix",value:function(){this.matrix=mat4.create(),this.domElement.style.transform=""}},{key:"updateMaterial",value:function(){this.material&&this.material.apply(this.domElement)}}],[{key:"getCommonAttributes",value:function(){return{position:"absolute",display:"block",transform:"matrix3d(1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1)","transform-origin":"0 0","-webkit-user-select":"none","-moz-user-select":"none","-ms-user-select":"none","user-select":"none","-webkit-backface-visibility":"inherit","backface-visibility":"inherit"}}}]),t}(),j=function(){function a(t,e,n,r){o(this,a),this.p1=t,this.p2=e,this.p3=n,this.edges=null,this.norm=r||this.calculateNormal()}return r(a,[{key:"updateEdges",value:function(){this.edges||(this.edges=[vec3.sub(vec3.create(),this.p1,this.p2),vec3.sub(vec3.create(),this.p2,this.p3),vec3.sub(vec3.create(),this.p3,this.p1)])}},{key:"calculateNormal",value:function(){return this.updateEdges(),vec3.normalize(vec3.create(),vec3.cross(vec3.create(),this.edges[0],this.edges[1]))}},{key:"calculateEdgeLengths",value:function(){return vec3.fromValues(vec3.len(this.edges[0]),vec3.len(this.edges[1]),vec3.len(this.edges[2]))}},{key:"getTransformationTo",value:function(t){var e=mat4.fromValues(this.p1[0],this.p1[1],this.p1[2],1,this.p2[0],this.p2[1],this.p2[2],1,this.p3[0],this.p3[1],this.p3[2],1,this.norm[0],this.norm[1],this.norm[2],0),n=mat4.fromValues(t.p1[0],t.p1[1],t.p1[2],1,t.p2[0],t.p2[1],t.p2[2],1,t.p3[0],t.p3[1],t.p3[2],1,t.norm[0],t.norm[1],t.norm[2],0);return mat4.mul(mat4.create(),n,mat4.invert(mat4.create(),e))}}]),a}(),Y=(document.documentElement.style,CSS.supports("mask-image: var(--background-image, none)"),CSS.supports("-webkit-mask-image: var(--background-image, none)"),CSS.supports("clip-path: polygon(50% 0%, 0% 100%, 100% 100%)")),T=CSS.supports("-webkit-clip-path: polygon(50% 0%, 0% 100%, 100% 100%)"),c=function(t){return Math.max(250,Math.min(t,1200))},V=function(t,e,n){return(t[0]-n[0])*(e[1]-n[1])-(t[1]-n[1])*(e[0]-n[0])},h=function(t){function C(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:null;o(this,C);var n=i(this,(C.__proto__||Object.getPrototypeOf(C)).call(this));return n.vertices=t,n.clipPath=[],n.simplify(),C.getClass().attach(n.domElement),n.getDomSize=c,n.block_width=0,n.block_height=0,n.contentElement=e||document.createElement("div"),C.getContentClass().attach(n.contentElement),n.domElement.appendChild(n.contentElement),n.uv_scale=vec2.fromValues(1,1),n.uv_offset=vec2.fromValues(0,0),n.maxi=0,n}return a(C,s),r(C,[{key:"simplify",value:function(){for(var t=[this.vertices[0]],e=1;e<this.vertices.length;e++){var n=e-1,r=(e+1)%this.vertices.length,a=this.vertices[n].position,o=this.vertices[e].position,i=this.vertices[r].position,u=vec3.sub(vec3.create(),a,o),s=vec3.sub(vec3.create(),o,i);vec3.normalize(u,u),vec3.normalize(s,s),Math.abs(vec3.dot(u,s))<.9999&&t.push(this.vertices[e])}this.vertices=t}},{key:"updateMatrix",value:function(){var t=new j(this.vertices[0].position,this.vertices[1].position,this.vertices[2].position);if(3==this.vertices.length){var e=t.calculateEdgeLengths();this.maxi=e.indexOf(Math.max.apply(Math,function(t){if(Array.isArray(t)){for(var e=0,n=Array(t.length);e<t.length;e++)n[e]=t[e];return n}return Array.from(t)}(e)));var n=this.maxi,r=(this.maxi+1)%3,a=(this.maxi+2)%3,o=e[n],i=e[r],u=e[a],s=-(i*i-u*u-o*o)/(2*o),c=Math.sqrt(u*u-s*s),h=s/o,l=this.getDomSize(o)/o;this.block_width=o*l,this.block_height=c*l,this.clipPath=[vec2.fromValues(0,0),vec2.fromValues(1,0),vec2.fromValues(h,1)];var f=[vec3.fromValues(0,0,0),vec3.fromValues(this.block_width,0,0),vec3.fromValues(s*l,this.block_height,0)];this.matrix=new j(f[n],f[r],f[a],[0,0,1]).getTransformationTo(t)}else{if(!(3<this.vertices.length))throw new Error("The polygon has not enough sides");var v=t.norm,m=Math.abs(vec3.dot(v,[0,0,1]))<.9?vec3.cross(vec3.create(),v,[0,0,1]):vec3.cross(vec3.create(),v,[0,1,0]),d=vec3.cross(vec3.create(),m,v),M=mat3.fromValues(m[0],m[1],m[2],d[0],d[1],d[2],v[0],v[1],v[2]),p=mat3.invert(mat3.create(),M);if(null===p)throw new Error("Degenerate triangle?");for(var b=this.vertices.map(function(t){return vec3.transformMat3(vec3.create(),t.position,p).slice(0,2)}),y=b.slice().sort(function(t,e){return t[0]==e[0]?t[1]-e[1]:t[0]-e[0]}),g=[],P=0;P<y.length;P++){for(;2<=g.length&&V(g[g.length-2],g[g.length-1],y[P])<=0;)g.pop();g.push(y[P])}for(var E=[],x=y.length-1;0<=x;x--){for(;2<=E.length&&V(E[E.length-2],E[E.length-1],y[x])<=0;)E.pop();E.push(y[x])}E.pop(),g.pop();for(var w=g.concat(E),_=Number.POSITIVE_INFINITY,O=[],k=(mat2.create(),mat2.create()),S=function(){var t=vec2.sub(vec2.create(),w[A],w[(A+1)%w.length]);vec2.normalize(t,t);var e=mat2.fromValues(t[0],t[1],t[1],-t[0]),n=mat2.invert(mat2.create(),e),r=w.map(function(t){return vec2.transformMat2(vec2.create(),t,n)}).map(function(t){return[t[0],t[0],t[1],t[1]]}).reduce(function(t,e){return[Math.min(t[0],e[0]),Math.max(t[1],e[1]),Math.min(t[2],e[2]),Math.max(t[3],e[3])]}),a=(r[1]-r[0])*(r[3]-r[2]);a<_&&(_=a,O=r,k=n)},A=0;A<w.length;A++)S();var q=O[1]-O[0],R=O[3]-O[2],I=1;I=R<q?this.getDomSize(q)/q:this.getDomSize(R)/R,this.block_width=q*I,this.block_height=R*I;var L=b.map(function(t){return vec2.sub(vec2.create(),vec2.transformMat2(vec2.create(),t,k),[O[0],O[2]])});this.clipPath=L.map(function(t){return vec2.fromValues(t[0]/q,t[1]/R)}),this.matrix=new j(vec3.fromValues(L[0][0]*I,L[0][1]*I,0),vec3.fromValues(L[1][0]*I,L[1][1]*I,0),vec3.fromValues(L[2][0]*I,L[2][1]*I,0)).getTransformationTo(t)}var N="polygon("+this.clipPath.map(function(t){return 100*t[0]+"% "+100*t[1]+"%"}).join()+")";Y?this.domElement.style.clipPath=N:T&&(this.domElement.style["-webkit-clip-path"]=N),this.domElement.style.setProperty("--width",this.block_width+"px"),this.domElement.style.setProperty("--height",this.block_height+"px"),function t(e,n,r){null===e&&(e=Function.prototype);var a=Object.getOwnPropertyDescriptor(e,n);if(void 0===a){var o=Object.getPrototypeOf(e);return null===o?void 0:t(o,n,r)}if("value"in a)return a.value;var i=a.get;return void 0!==i?i.call(r):void 0}(C.prototype.__proto__||Object.getPrototypeOf(C.prototype),"updateMatrix",this).call(this)}},{key:"updateContent",value:function(){var n=this,t=this.vertices.map(function(t){var e=vec2.mul(vec2.create(),t.uv,n.uv_scale);return vec2.add(e,e,n.uv_offset),e}),e=t.map(function(t){return[t[0],t[0],t[1],t[1]]}).reduce(function(t,e){return[Math.min(t[0],e[0]),Math.max(t[1],e[1]),Math.min(t[2],e[2]),Math.max(t[3],e[3])]}),r=e[0],a=e[1],o=e[2],i=a-r,u=e[3]-o,s=1/i,c=1/u;this.contentElement.style.backgroundPosition="calc(var(--width) * "+-r*s+") calc(var(--height) * "+(1+o*c)+")",this.contentElement.style.backgroundSize=100*s+"% "+100*c+"%";var h=mat3.fromValues((t[0][0]-r)/i,1-(t[0][1]-o)/u,1,(t[1][0]-r)/i,1-(t[1][1]-o)/u,1,(t[2][0]-r)/i,1-(t[2][1]-o)/u,1),l=void 0,f=void 0,v=void 0;3==this.vertices.length?(l=this.maxi,f=(this.maxi+1)%3,v=(this.maxi+2)%3):(l=0,f=1,v=2);var m=mat3.fromValues(this.clipPath[l][0],this.clipPath[l][1],1,this.clipPath[f][0],this.clipPath[f][1],1,this.clipPath[v][0],this.clipPath[v][1],1),d=mat3.mul(mat3.create(),m,mat3.invert(mat3.create(),h)),M=this.block_height/this.block_width;this.contentElement.style.transform="translate("+[100*d[6]+"%",100*d[7]+"%"].join()+")matrix("+[d[0],d[1]*M,d[3]/M,d[4],0,0].join()+")"}}],[{key:"getClass",value:function(){return n||((n=new u).setProperties({width:"var(--width, 0px)",height:"var(--height, 0px)",opacity:"var(--opacity, 1)","transform-style":"flat",overflow:"hidden"}),n.setProperties(s.getCommonAttributes()),n.update(),n.init()),n}},{key:"getContentClass",value:function(){return l||((l=new u).setProperties({width:"100%",height:"100%","background-color":"var(--background-color, white)","background-image":"var(--background-image, none)","background-size":"100% 100%","background-blend-mode":"multiply",transform:"matrix(1, 0, 0, 1, 0, 0)","transform-origin":"0 0"}),l.update(),l.init()),l}}]),C}(),n=null,l=null,f=function(t){function e(){o(this,e);var t=i(this,(e.__proto__||Object.getPrototypeOf(e)).call(this));return e.getClass().attach(t.domElement),t.children=[],t.vert_cache=null,t.norm_cache=null,t.vec2tex=null,t}return a(e,s),r(e,[{key:"addChild",value:function(t){this.children.push(t),this.domElement.appendChild(t.domElement)}},{key:"removeChild",value:function(t){var e=this.children.indexOf(t);-1<e&&this.removeChildIndex(e)}},{key:"removeChildIndex",value:function(t){var e=this.children[t];this.children.splice(t,1),this.domElement.removeChild(e.domElement)}},{key:"clear",value:function(){for(var t=this.children.length;0<t--;)this.removeChildIndex(t)}},{key:"addPolygon",value:function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:null,n=new h(t,e);return n.updateMatrix(),n.updateContent(),this.addChild(n),n}},{key:"pushPolygon",value:function(t){var n=this,e=new j(t[0].position,t[1].position,t[2].position).norm;if(this.vert_cache)if(vec3.equals(this.norm_cache,e)){for(var r=!1,a=0;a<this.vert_cache.length;a++){for(var o=this.vert_cache[a],i=0;i<t.length;i++){var u=t[i];if(vec2.equals(o.uv,u.uv)&&vec3.equals(o.position,u.position)){var s=this.vert_cache[(a+1)%this.vert_cache.length],c=t[(i+t.length-1)%t.length];if(vec2.equals(s.uv,c.uv)&&vec3.equals(s.position,c.position)){for(var h=this.vert_cache.slice(0,a+1),l=this.vert_cache.slice(a+1),f=[],v=1;v<t.length-1;v++)f.push(t[(i+v)%t.length]);if(!f.every(function(t){var e=vec3.transformMat4(vec3.create(),t.position,n.vec2tex).slice(0,2);return vec2.equals(e,t.uv)}))continue;this.vert_cache=h.concat(f,l),r=!0;break}}}if(r)break}r||this.flushPolygons()}else this.flushPolygons();this.vert_cache||(this.vert_cache=t,this.norm_cache=e,this.vec2tex=new j(t[0].position,t[1].position,t[2].position,e).getTransformationTo(new j(vec3.fromValues(this.vert_cache[0].uv[0],this.vert_cache[0].uv[1],0),vec3.fromValues(this.vert_cache[1].uv[0],this.vert_cache[1].uv[1],0),vec3.fromValues(this.vert_cache[2].uv[0],this.vert_cache[2].uv[1],0))))}},{key:"flushPolygons",value:function(){this.vert_cache&&(this.addPolygon(this.vert_cache),this.vert_cache=null,this.norm_cache=null,this.vec2tex=null)}}],[{key:"getClass",value:function(){return v||((v=new u).setProperties({width:"0px",height:"0px","transform-style":"preserve-3d",overflow:"visible"}),v.setProperties(s.getCommonAttributes()),v.update(),v.init()),v}}]),e}(),v=null,m=function(){function e(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:70;o(this,e),this.fov=t,this.matrix=mat4.create()}return r(e,[{key:"perspective_coefficient",get:function(){return 1/Math.tan(this.fov*Math.PI/360)}}]),e}(),d=function t(e,n,r,a){o(this,t),this.left=e,this.right=n,this.top=r,this.bottom=a,this.matrix=mat4.create()},M=CSS.supports("transform: translateZ(calc(100px * var(--mult-value,1)))"),p=function(t){function e(){o(this,e);var t=i(this,(e.__proto__||Object.getPrototypeOf(e)).call(this));return e.getClass().attach(t.domElement),t}return a(e,f),r(e,[{key:"updateMatrix",value:function(t){if(t instanceof m){var e=t.perspective_coefficient,n=void 0;n=M?"calc( "+e+" * var(--viewport-height) / 2 )":e*this.domElement.parentNode.offsetHeight/2+"px",this.domElement.style.transform="translateZ("+n+")scaleY(-1)matrix3d("+t.matrix.join()+")matrix3d("+this.matrix.join()+")"}else if(t instanceof d){var r=t.right-t.left,a=t.top-t.bottom,o=(t.right+t.left)/2,i=(t.top+t.bottom)/2,u=this.domElement.parentNode.offsetWidth,s=this.domElement.parentNode.offsetHeight;this.domElement.style.transform="scale("+[u/r,s/a].join()+")translate("+-o+","+-i+")scaleY(-1)matrix3d("+t.matrix.join()+")matrix3d("+this.matrix.join()+")"}}}],[{key:"getClass",value:function(){return b||((b=new u).setProperties({width:"100% !important",height:"100% !important",top:"50%",left:"50%","pointer-events":"none","-webkit-backface-visibility":"hidden !important","backface-visibility":"hidden !important"}),b.update(),b.init()),b}}]),e}(),b=null,y=CSS.supports("perspective: calc( 512px * 2 )"),g=function(){function t(){o(this,t),this.camera=new m,this.root=null,this.domElement=document.createElement("div"),t.getClass().attach(this.domElement),this.width=0,this.height=0,this.addRoot(new p)}return r(t,[{key:"updateCamera",value:function(){this.camera instanceof m?y?this.domElement.style.setProperty("perspective","calc( "+this.camera.perspective_coefficient+" * var(--viewport-height) / 2 )"):this.domElement.style.setProperty("perspective",this.camera.perspective_coefficient*this.domElement.offsetHeight/2+"px"):this.camera instanceof d&&this.domElement.style.removeProperty("perspective"),this.root.updateMatrix(this.camera)}},{key:"addRoot",value:function(t){this.root&&this.domElement.removeChild(t.domElement),this.root=t,this.domElement.appendChild(t.domElement),this.updateCamera()}},{key:"setSize",value:function(t,e){this.width==t&&this.height==e||(this.width=t,this.height=e,this.domElement.style.setProperty("--viewport-width",t+"px"),this.domElement.style.setProperty("--viewport-height",e+"px"))}},{key:"resetSize",value:function(){this.domElement.style.removeProperty("--viewport-width",width+"px"),this.domElement.style.removeProperty("--viewport-height",height+"px")}}],[{key:"getClass",value:function(){return P||((P=new u).setProperties({overflow:"hidden",position:"relative","--viewport-width":"100vw","--viewport-height":"100vh",width:"var(--viewport-width)",height:"var(--viewport-height)"}),P.update(),P.init()),P}}]),t}(),P=null,E=function(t){function n(t){o(this,n);var e=i(this,(n.__proto__||Object.getPrototypeOf(n)).call(this));return e.element=t,e.domElement.appendChild(t),e.elementScale=vec2.fromValues(1,1),e.elementCenter=vec2.fromValues(.5,.5),e.elementRotation=0,f.getClass().attach(e.domElement),n.getContentClass().attach(e.element),e.updateElementTransform(),e}return a(n,s),r(n,[{key:"setSize",value:function(t,e){this.element.style.width=t+"px",this.element.style.height=e+"px"}},{key:"setScale",value:function(t,e){this.elementScale=vec2.fromValues(t,e),this.updateElementTransform()}},{key:"setCenter",value:function(t,e){this.elementCenter=vec2.fromValues(t,e),this.updateElementTransform()}},{key:"updateElementTransform",value:function(){var t="scale("+this.elementScale[0]+","+-this.elementScale[1]+")",e="translate("+100*(.5-this.elementCenter[0])+"%,"+100*(this.elementCenter[1]-.5)+"%)",n=0==this.elementRotation?"":"rotate("+this.elementRotation+"rad)";this.element.style.transform="translate(-50%,-50%)"+t+e+n}},{key:"enablePointer",value:function(){this.element.style.pointerEvents="auto"}},{key:"disablePointer",value:function(){this.element.style.pointerEvents=""}}],[{key:"getContentClass",value:function(){return x||((x=new u).setProperties({"background-color":"var(--background-color, transparent)","background-image":"var(--background-image, white)","background-size":"100% 100%",opacity:"var(--opacity, 1)"}),x.update(),x.init()),x}}]),n}(),x=null;t.CSSClass=u,t.Material=e,t.Object3D=s,t.Group=f,t.RootObject=p,t.Container=g,t.Polygon=h,t.CustomElement=E,t.Triangle=j,t.Vertex=function t(e,n){o(this,t),this.position=e||vec3.create(),this.uv=n||vec2.create()},t.PerspectiveCamera=m,t.OrthographicCamera=d,Object.defineProperty(t,"__esModule",{value:!0})});