@jscad/regl-renderer
Version:
Renderer for JSCAD Geometries
260 lines (174 loc) • 141 kB
JavaScript
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.jscadReglRenderer = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
const flatten=t=>t.reduce((t,a)=>Array.isArray(a)?t.concat(flatten(a)):t.concat(a),[]);module.exports=flatten;
},{}],2:[function(require,module,exports){
const fnNumberSort=(o,r)=>o-r;module.exports=fnNumberSort;
},{}],3:[function(require,module,exports){
const head=r=>{if(Array.isArray(r)&&0!==r.length)return r[0]};module.exports=head;
},{}],4:[function(require,module,exports){
module.exports={flatten:require("./flatten"),fnNumberSort:require("./fnNumberSort"),head:require("./head"),insertSorted:require("./insertSorted"),nth:require("./nth"),padToLength:require("./padToLength"),toArray:require("./toArray")};
},{"./flatten":1,"./fnNumberSort":2,"./head":3,"./insertSorted":5,"./nth":6,"./padToLength":7,"./toArray":8}],5:[function(require,module,exports){
const insertSorted=(t,e,o)=>{let r=0,n=t.length;for(;n>r;){const s=Math.floor((r+n)/2);o(e,t[s])>0?r=s+1:n=s}return t.splice(r,0,e),t};module.exports=insertSorted;
},{}],6:[function(require,module,exports){
const nth=(r,t)=>{if(Array.isArray(r)&&!(r.length<t))return r[t]};module.exports=nth;
},{}],7:[function(require,module,exports){
const padToLength=(e,o,t)=>{for(e=e.slice();e.length<t;)e.push(o);return e};module.exports=padToLength;
},{}],8:[function(require,module,exports){
const toArray=r=>Array.isArray(r)?r:null==r?[]:[r];module.exports=toArray;
},{}],9:[function(require,module,exports){
var transform=require("./lib/projectMat4");function unproject(r,t,e,o){var n=e[0],u=e[1],a=e[2],c=e[3],p=t[0],f=t[1],i=t[2];return p-=n,f=c-f-1,f-=u,r[0]=2*p/a-1,r[1]=2*f/c-1,r[2]=2*i-1,transform(r,r,o)}module.exports=unproject;
},{"./lib/projectMat4":10}],10:[function(require,module,exports){
function project(r,e,o){var t=e[0],c=e[1],n=e[2],p=o[0],u=o[1],j=o[2],a=o[3],d=o[4],f=o[5],i=o[6],l=o[7],m=o[8],s=o[9],v=o[10],x=o[11],b=o[12],g=o[13],h=o[14],k=1/(t*a+c*l+n*x+o[15]);return r[0]=(t*p+c*d+n*m+b)*k,r[1]=(t*u+c*f+n*s+g)*k,r[2]=(t*j+c*i+n*v+h)*k,r}module.exports=project;
},{}],11:[function(require,module,exports){
function adjoint(n,o){var t=o[0],r=o[1],a=o[2],d=o[3],e=o[4],i=o[5],u=o[6],j=o[7],c=o[8],f=o[9],l=o[10],m=o[11],p=o[12],s=o[13],v=o[14],x=o[15];return n[0]=i*(l*x-m*v)-f*(u*x-j*v)+s*(u*m-j*l),n[1]=-(r*(l*x-m*v)-f*(a*x-d*v)+s*(a*m-d*l)),n[2]=r*(u*x-j*v)-i*(a*x-d*v)+s*(a*j-d*u),n[3]=-(r*(u*m-j*l)-i*(a*m-d*l)+f*(a*j-d*u)),n[4]=-(e*(l*x-m*v)-c*(u*x-j*v)+p*(u*m-j*l)),n[5]=t*(l*x-m*v)-c*(a*x-d*v)+p*(a*m-d*l),n[6]=-(t*(u*x-j*v)-e*(a*x-d*v)+p*(a*j-d*u)),n[7]=t*(u*m-j*l)-e*(a*m-d*l)+c*(a*j-d*u),n[8]=e*(f*x-m*s)-c*(i*x-j*s)+p*(i*m-j*f),n[9]=-(t*(f*x-m*s)-c*(r*x-d*s)+p*(r*m-d*f)),n[10]=t*(i*x-j*s)-e*(r*x-d*s)+p*(r*j-d*i),n[11]=-(t*(i*m-j*f)-e*(r*m-d*f)+c*(r*j-d*i)),n[12]=-(e*(f*v-l*s)-c*(i*v-u*s)+p*(i*l-u*f)),n[13]=t*(f*v-l*s)-c*(r*v-a*s)+p*(r*l-a*f),n[14]=-(t*(i*v-u*s)-e*(r*v-a*s)+p*(r*u-a*i)),n[15]=t*(i*l-u*f)-e*(r*l-a*f)+c*(r*u-a*i),n}module.exports=adjoint;
},{}],12:[function(require,module,exports){
function clone(e){var n=new Float32Array(16);return n[0]=e[0],n[1]=e[1],n[2]=e[2],n[3]=e[3],n[4]=e[4],n[5]=e[5],n[6]=e[6],n[7]=e[7],n[8]=e[8],n[9]=e[9],n[10]=e[10],n[11]=e[11],n[12]=e[12],n[13]=e[13],n[14]=e[14],n[15]=e[15],n}module.exports=clone;
},{}],13:[function(require,module,exports){
function copy(o,c){return o[0]=c[0],o[1]=c[1],o[2]=c[2],o[3]=c[3],o[4]=c[4],o[5]=c[5],o[6]=c[6],o[7]=c[7],o[8]=c[8],o[9]=c[9],o[10]=c[10],o[11]=c[11],o[12]=c[12],o[13]=c[13],o[14]=c[14],o[15]=c[15],o}module.exports=copy;
},{}],14:[function(require,module,exports){
function create(){var e=new Float32Array(16);return e[0]=1,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=1,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=1,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}module.exports=create;
},{}],15:[function(require,module,exports){
function determinant(e){var n=e[0],t=e[1],r=e[2],a=e[3],d=e[4],i=e[5],m=e[6],o=e[7],u=e[8],c=e[9],f=e[10],l=e[11],p=e[12],s=e[13],v=e[14],x=e[15];return(n*i-t*d)*(f*x-l*v)-(n*m-r*d)*(c*x-l*s)+(n*o-a*d)*(c*v-f*s)+(t*m-r*i)*(u*x-l*p)-(t*o-a*i)*(u*v-f*p)+(r*o-a*m)*(u*s-c*p)}module.exports=determinant;
},{}],16:[function(require,module,exports){
function fromQuat(r,o){var t=o[0],u=o[1],a=o[2],e=o[3],f=t+t,m=u+u,n=a+a,Q=t*f,c=u*f,d=u*m,i=a*f,l=a*m,p=a*n,s=e*f,v=e*m,x=e*n;return r[0]=1-d-p,r[1]=c+x,r[2]=i-v,r[3]=0,r[4]=c-x,r[5]=1-Q-p,r[6]=l+s,r[7]=0,r[8]=i+v,r[9]=l-s,r[10]=1-Q-d,r[11]=0,r[12]=0,r[13]=0,r[14]=0,r[15]=1,r}module.exports=fromQuat;
},{}],17:[function(require,module,exports){
function fromRotation(t,o,a){var n,r,s,e=a[0],h=a[1],i=a[2],u=Math.sqrt(e*e+h*h+i*i);return Math.abs(u)<1e-6?null:(e*=u=1/u,h*=u,i*=u,n=Math.sin(o),s=1-(r=Math.cos(o)),t[0]=e*e*s+r,t[1]=h*e*s+i*n,t[2]=i*e*s-h*n,t[3]=0,t[4]=e*h*s-i*n,t[5]=h*h*s+r,t[6]=i*h*s+e*n,t[7]=0,t[8]=e*i*s+h*n,t[9]=h*i*s-e*n,t[10]=i*i*s+r,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t)}module.exports=fromRotation;
},{}],18:[function(require,module,exports){
function fromRotationTranslation(o,n,t){var r=n[0],a=n[1],i=n[2],e=n[3],f=r+r,l=a+a,m=i+i,s=r*f,u=r*l,R=r*m,T=a*l,c=a*m,d=i*m,p=e*f,v=e*l,x=e*m;return o[0]=1-(T+d),o[1]=u+x,o[2]=R-v,o[3]=0,o[4]=u-x,o[5]=1-(s+d),o[6]=c+p,o[7]=0,o[8]=R+v,o[9]=c-p,o[10]=1-(s+T),o[11]=0,o[12]=t[0],o[13]=t[1],o[14]=t[2],o[15]=1,o}module.exports=fromRotationTranslation;
},{}],19:[function(require,module,exports){
function fromScaling(n,o){return n[0]=o[0],n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=o[1],n[6]=0,n[7]=0,n[8]=0,n[9]=0,n[10]=o[2],n[11]=0,n[12]=0,n[13]=0,n[14]=0,n[15]=1,n}module.exports=fromScaling;
},{}],20:[function(require,module,exports){
function fromTranslation(n,o){return n[0]=1,n[1]=0,n[2]=0,n[3]=0,n[4]=0,n[5]=1,n[6]=0,n[7]=0,n[8]=0,n[9]=0,n[10]=1,n[11]=0,n[12]=o[0],n[13]=o[1],n[14]=o[2],n[15]=1,n}module.exports=fromTranslation;
},{}],21:[function(require,module,exports){
function fromXRotation(o,t){var n=Math.sin(t),r=Math.cos(t);return o[0]=1,o[1]=0,o[2]=0,o[3]=0,o[4]=0,o[5]=r,o[6]=n,o[7]=0,o[8]=0,o[9]=-n,o[10]=r,o[11]=0,o[12]=0,o[13]=0,o[14]=0,o[15]=1,o}module.exports=fromXRotation;
},{}],22:[function(require,module,exports){
function fromYRotation(o,t){var n=Math.sin(t),r=Math.cos(t);return o[0]=r,o[1]=0,o[2]=-n,o[3]=0,o[4]=0,o[5]=1,o[6]=0,o[7]=0,o[8]=n,o[9]=0,o[10]=r,o[11]=0,o[12]=0,o[13]=0,o[14]=0,o[15]=1,o}module.exports=fromYRotation;
},{}],23:[function(require,module,exports){
function fromZRotation(o,t){var n=Math.sin(t),r=Math.cos(t);return o[0]=r,o[1]=n,o[2]=0,o[3]=0,o[4]=-n,o[5]=r,o[6]=0,o[7]=0,o[8]=0,o[9]=0,o[10]=1,o[11]=0,o[12]=0,o[13]=0,o[14]=0,o[15]=1,o}module.exports=fromZRotation;
},{}],24:[function(require,module,exports){
function frustum(u,r,t,e,f,m,n){var o=1/(t-r),s=1/(f-e),a=1/(m-n);return u[0]=2*m*o,u[1]=0,u[2]=0,u[3]=0,u[4]=0,u[5]=2*m*s,u[6]=0,u[7]=0,u[8]=(t+r)*o,u[9]=(f+e)*s,u[10]=(n+m)*a,u[11]=-1,u[12]=0,u[13]=0,u[14]=n*m*2*a,u[15]=0,u}module.exports=frustum;
},{}],25:[function(require,module,exports){
function identity(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}module.exports=identity;
},{}],26:[function(require,module,exports){
module.exports={create:require("./create"),clone:require("./clone"),copy:require("./copy"),identity:require("./identity"),transpose:require("./transpose"),invert:require("./invert"),adjoint:require("./adjoint"),determinant:require("./determinant"),multiply:require("./multiply"),translate:require("./translate"),scale:require("./scale"),rotate:require("./rotate"),rotateX:require("./rotateX"),rotateY:require("./rotateY"),rotateZ:require("./rotateZ"),fromRotation:require("./fromRotation"),fromRotationTranslation:require("./fromRotationTranslation"),fromScaling:require("./fromScaling"),fromTranslation:require("./fromTranslation"),fromXRotation:require("./fromXRotation"),fromYRotation:require("./fromYRotation"),fromZRotation:require("./fromZRotation"),fromQuat:require("./fromQuat"),frustum:require("./frustum"),perspective:require("./perspective"),perspectiveFromFieldOfView:require("./perspectiveFromFieldOfView"),ortho:require("./ortho"),lookAt:require("./lookAt"),str:require("./str")};
},{"./adjoint":11,"./clone":12,"./copy":13,"./create":14,"./determinant":15,"./fromQuat":16,"./fromRotation":17,"./fromRotationTranslation":18,"./fromScaling":19,"./fromTranslation":20,"./fromXRotation":21,"./fromYRotation":22,"./fromZRotation":23,"./frustum":24,"./identity":25,"./invert":27,"./lookAt":28,"./multiply":29,"./ortho":30,"./perspective":31,"./perspectiveFromFieldOfView":32,"./rotate":33,"./rotateX":34,"./rotateY":35,"./rotateZ":36,"./scale":37,"./str":38,"./translate":39,"./transpose":40}],27:[function(require,module,exports){
function invert(n,r){var e=r[0],t=r[1],u=r[2],i=r[3],l=r[4],o=r[5],v=r[6],a=r[7],c=r[8],d=r[9],f=r[10],m=r[11],p=r[12],s=r[13],x=r[14],b=r[15],g=e*o-t*l,h=e*v-u*l,j=e*a-i*l,k=t*v-u*o,q=t*a-i*o,w=u*a-i*v,y=c*s-d*p,z=c*x-f*p,A=c*b-m*p,B=d*x-f*s,C=d*b-m*s,D=f*b-m*x,E=g*D-h*C+j*B+k*A-q*z+w*y;return E?(E=1/E,n[0]=(o*D-v*C+a*B)*E,n[1]=(u*C-t*D-i*B)*E,n[2]=(s*w-x*q+b*k)*E,n[3]=(f*q-d*w-m*k)*E,n[4]=(v*A-l*D-a*z)*E,n[5]=(e*D-u*A+i*z)*E,n[6]=(x*j-p*w-b*h)*E,n[7]=(c*w-f*j+m*h)*E,n[8]=(l*C-o*A+a*y)*E,n[9]=(t*A-e*C-i*y)*E,n[10]=(p*q-s*j+b*g)*E,n[11]=(d*j-c*q-m*g)*E,n[12]=(o*z-l*B-v*y)*E,n[13]=(e*B-t*z+u*y)*E,n[14]=(s*h-p*k-x*g)*E,n[15]=(c*k-d*h+f*g)*E,n):null}module.exports=invert;
},{}],28:[function(require,module,exports){
var identity=require("./identity");function lookAt(t,a,e,r){var i,o,s,h,n,M,d,q,u,b,l=a[0],y=a[1],k=a[2],v=r[0],A=r[1],c=r[2],f=e[0],m=e[1],p=e[2];return Math.abs(l-f)<1e-6&&Math.abs(y-m)<1e-6&&Math.abs(k-p)<1e-6?identity(t):(d=l-f,q=y-m,u=k-p,i=A*(u*=b=1/Math.sqrt(d*d+q*q+u*u))-c*(q*=b),o=c*(d*=b)-v*u,s=v*q-A*d,(b=Math.sqrt(i*i+o*o+s*s))?(i*=b=1/b,o*=b,s*=b):(i=0,o=0,s=0),h=q*s-u*o,n=u*i-d*s,M=d*o-q*i,(b=Math.sqrt(h*h+n*n+M*M))?(h*=b=1/b,n*=b,M*=b):(h=0,n=0,M=0),t[0]=i,t[1]=h,t[2]=d,t[3]=0,t[4]=o,t[5]=n,t[6]=q,t[7]=0,t[8]=s,t[9]=M,t[10]=u,t[11]=0,t[12]=-(i*l+o*y+s*k),t[13]=-(h*l+n*y+M*k),t[14]=-(d*l+q*y+u*k),t[15]=1,t)}module.exports=lookAt;
},{"./identity":25}],29:[function(require,module,exports){
function multiply(l,t,u){var r=t[0],e=t[1],i=t[2],m=t[3],n=t[4],o=t[5],p=t[6],y=t[7],a=t[8],c=t[9],d=t[10],f=t[11],s=t[12],v=t[13],x=t[14],b=t[15],g=u[0],h=u[1],j=u[2],k=u[3];return l[0]=g*r+h*n+j*a+k*s,l[1]=g*e+h*o+j*c+k*v,l[2]=g*i+h*p+j*d+k*x,l[3]=g*m+h*y+j*f+k*b,g=u[4],h=u[5],j=u[6],k=u[7],l[4]=g*r+h*n+j*a+k*s,l[5]=g*e+h*o+j*c+k*v,l[6]=g*i+h*p+j*d+k*x,l[7]=g*m+h*y+j*f+k*b,g=u[8],h=u[9],j=u[10],k=u[11],l[8]=g*r+h*n+j*a+k*s,l[9]=g*e+h*o+j*c+k*v,l[10]=g*i+h*p+j*d+k*x,l[11]=g*m+h*y+j*f+k*b,g=u[12],h=u[13],j=u[14],k=u[15],l[12]=g*r+h*n+j*a+k*s,l[13]=g*e+h*o+j*c+k*v,l[14]=g*i+h*p+j*d+k*x,l[15]=g*m+h*y+j*f+k*b,l}module.exports=multiply;
},{}],30:[function(require,module,exports){
function ortho(o,r,t,e,n,u,h){var a=1/(r-t),c=1/(e-n),d=1/(u-h);return o[0]=-2*a,o[1]=0,o[2]=0,o[3]=0,o[4]=0,o[5]=-2*c,o[6]=0,o[7]=0,o[8]=0,o[9]=0,o[10]=2*d,o[11]=0,o[12]=(r+t)*a,o[13]=(n+e)*c,o[14]=(h+u)*d,o[15]=1,o}module.exports=ortho;
},{}],31:[function(require,module,exports){
function perspective(e,t,r,p,n){var a=1/Math.tan(t/2),c=1/(p-n);return e[0]=a/r,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=a,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=(n+p)*c,e[11]=-1,e[12]=0,e[13]=0,e[14]=2*n*p*c,e[15]=0,e}module.exports=perspective;
},{}],32:[function(require,module,exports){
function perspectiveFromFieldOfView(e,t,a,r){var h=Math.tan(t.upDegrees*Math.PI/180),i=Math.tan(t.downDegrees*Math.PI/180),n=Math.tan(t.leftDegrees*Math.PI/180),M=Math.tan(t.rightDegrees*Math.PI/180),s=2/(n+M),o=2/(h+i);return e[0]=s,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=o,e[6]=0,e[7]=0,e[8]=-(n-M)*s*.5,e[9]=(h-i)*o*.5,e[10]=r/(a-r),e[11]=-1,e[12]=0,e[13]=0,e[14]=r*a/(a-r),e[15]=0,e}module.exports=perspectiveFromFieldOfView;
},{}],33:[function(require,module,exports){
function rotate(t,a,r,e){var o,n,s,h,u,M,l,c,i,b,d,f,m,p,q,v,x,g,j,k,w,y,z,A,B=e[0],C=e[1],D=e[2],E=Math.sqrt(B*B+C*C+D*D);return Math.abs(E)<1e-6?null:(B*=E=1/E,C*=E,D*=E,o=Math.sin(r),s=1-(n=Math.cos(r)),h=a[0],u=a[1],M=a[2],l=a[3],c=a[4],i=a[5],b=a[6],d=a[7],f=a[8],m=a[9],p=a[10],q=a[11],v=B*B*s+n,x=C*B*s+D*o,g=D*B*s-C*o,j=B*C*s-D*o,k=C*C*s+n,w=D*C*s+B*o,y=B*D*s+C*o,z=C*D*s-B*o,A=D*D*s+n,t[0]=h*v+c*x+f*g,t[1]=u*v+i*x+m*g,t[2]=M*v+b*x+p*g,t[3]=l*v+d*x+q*g,t[4]=h*j+c*k+f*w,t[5]=u*j+i*k+m*w,t[6]=M*j+b*k+p*w,t[7]=l*j+d*k+q*w,t[8]=h*y+c*z+f*A,t[9]=u*y+i*z+m*A,t[10]=M*y+b*z+p*A,t[11]=l*y+d*z+q*A,a!==t&&(t[12]=a[12],t[13]=a[13],t[14]=a[14],t[15]=a[15]),t)}module.exports=rotate;
},{}],34:[function(require,module,exports){
function rotateX(t,o,r){var a=Math.sin(r),e=Math.cos(r),n=o[4],s=o[5],u=o[6],c=o[7],h=o[8],i=o[9],M=o[10],X=o[11];return o!==t&&(t[0]=o[0],t[1]=o[1],t[2]=o[2],t[3]=o[3],t[12]=o[12],t[13]=o[13],t[14]=o[14],t[15]=o[15]),t[4]=n*e+h*a,t[5]=s*e+i*a,t[6]=u*e+M*a,t[7]=c*e+X*a,t[8]=h*e-n*a,t[9]=i*e-s*a,t[10]=M*e-u*a,t[11]=X*e-c*a,t}module.exports=rotateX;
},{}],35:[function(require,module,exports){
function rotateY(t,o,r){var a=Math.sin(r),e=Math.cos(r),n=o[0],s=o[1],u=o[2],c=o[3],h=o[8],i=o[9],M=o[10],Y=o[11];return o!==t&&(t[4]=o[4],t[5]=o[5],t[6]=o[6],t[7]=o[7],t[12]=o[12],t[13]=o[13],t[14]=o[14],t[15]=o[15]),t[0]=n*e-h*a,t[1]=s*e-i*a,t[2]=u*e-M*a,t[3]=c*e-Y*a,t[8]=n*a+h*e,t[9]=s*a+i*e,t[10]=u*a+M*e,t[11]=c*a+Y*e,t}module.exports=rotateY;
},{}],36:[function(require,module,exports){
function rotateZ(t,o,r){var a=Math.sin(r),e=Math.cos(r),n=o[0],s=o[1],u=o[2],c=o[3],h=o[4],i=o[5],M=o[6],Z=o[7];return o!==t&&(t[8]=o[8],t[9]=o[9],t[10]=o[10],t[11]=o[11],t[12]=o[12],t[13]=o[13],t[14]=o[14],t[15]=o[15]),t[0]=n*e+h*a,t[1]=s*e+i*a,t[2]=u*e+M*a,t[3]=c*e+Z*a,t[4]=h*e-n*a,t[5]=i*e-s*a,t[6]=M*e-u*a,t[7]=Z*e-c*a,t}module.exports=rotateZ;
},{}],37:[function(require,module,exports){
function scale(e,r,a){var c=a[0],l=a[1],n=a[2];return e[0]=r[0]*c,e[1]=r[1]*c,e[2]=r[2]*c,e[3]=r[3]*c,e[4]=r[4]*l,e[5]=r[5]*l,e[6]=r[6]*l,e[7]=r[7]*l,e[8]=r[8]*n,e[9]=r[9]*n,e[10]=r[10]*n,e[11]=r[11]*n,e[12]=r[12],e[13]=r[13],e[14]=r[14],e[15]=r[15],e}module.exports=scale;
},{}],38:[function(require,module,exports){
function str(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]+")"}module.exports=str;
},{}],39:[function(require,module,exports){
function translate(t,r,a){var e,n,l,o,s,u,c,d,f,i,m,p,v=a[0],x=a[1],b=a[2];return r===t?(t[12]=r[0]*v+r[4]*x+r[8]*b+r[12],t[13]=r[1]*v+r[5]*x+r[9]*b+r[13],t[14]=r[2]*v+r[6]*x+r[10]*b+r[14],t[15]=r[3]*v+r[7]*x+r[11]*b+r[15]):(e=r[0],n=r[1],l=r[2],o=r[3],s=r[4],u=r[5],c=r[6],d=r[7],f=r[8],i=r[9],m=r[10],p=r[11],t[0]=e,t[1]=n,t[2]=l,t[3]=o,t[4]=s,t[5]=u,t[6]=c,t[7]=d,t[8]=f,t[9]=i,t[10]=m,t[11]=p,t[12]=e*v+s*x+f*b+r[12],t[13]=n*v+u*x+i*b+r[13],t[14]=l*v+c*x+m*b+r[14],t[15]=o*v+d*x+p*b+r[15]),t}module.exports=translate;
},{}],40:[function(require,module,exports){
function transpose(e,r){if(e===r){var s=r[1],n=r[2],o=r[3],t=r[6],a=r[7],p=r[11];e[1]=r[4],e[2]=r[8],e[3]=r[12],e[4]=s,e[6]=r[9],e[7]=r[13],e[8]=n,e[9]=t,e[11]=r[14],e[12]=o,e[13]=a,e[14]=p}else e[0]=r[0],e[1]=r[4],e[2]=r[8],e[3]=r[12],e[4]=r[1],e[5]=r[5],e[6]=r[9],e[7]=r[13],e[8]=r[2],e[9]=r[6],e[10]=r[10],e[11]=r[14],e[12]=r[3],e[13]=r[7],e[14]=r[11],e[15]=r[15];return e}module.exports=transpose;
},{}],41:[function(require,module,exports){
function add(d,e,n){return d[0]=e[0]+n[0],d[1]=e[1]+n[1],d[2]=e[2]+n[2],d}module.exports=add;
},{}],42:[function(require,module,exports){
module.exports=angle;var fromValues=require("./fromValues"),normalize=require("./normalize"),dot=require("./dot");function angle(r,e){var a=fromValues(r[0],r[1],r[2]),o=fromValues(e[0],e[1],e[2]);normalize(a,a),normalize(o,o);var l=dot(a,o);return l>1?0:Math.acos(l)}
},{"./dot":52,"./fromValues":58,"./normalize":69}],43:[function(require,module,exports){
function ceil(e,c){return e[0]=Math.ceil(c[0]),e[1]=Math.ceil(c[1]),e[2]=Math.ceil(c[2]),e}module.exports=ceil;
},{}],44:[function(require,module,exports){
function clone(e){var n=new Float32Array(3);return n[0]=e[0],n[1]=e[1],n[2]=e[2],n}module.exports=clone;
},{}],45:[function(require,module,exports){
function copy(o,c){return o[0]=c[0],o[1]=c[1],o[2]=c[2],o}module.exports=copy;
},{}],46:[function(require,module,exports){
function create(){var e=new Float32Array(3);return e[0]=0,e[1]=0,e[2]=0,e}module.exports=create;
},{}],47:[function(require,module,exports){
function cross(r,o,s){var c=o[0],e=o[1],n=o[2],t=s[0],u=s[1],a=s[2];return r[0]=e*a-n*u,r[1]=n*t-c*a,r[2]=c*u-e*t,r}module.exports=cross;
},{}],48:[function(require,module,exports){
module.exports=require("./distance");
},{"./distance":49}],49:[function(require,module,exports){
function distance(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)}module.exports=distance;
},{}],50:[function(require,module,exports){
module.exports=require("./divide");
},{"./divide":51}],51:[function(require,module,exports){
function divide(d,e,i){return d[0]=e[0]/i[0],d[1]=e[1]/i[1],d[2]=e[2]/i[2],d}module.exports=divide;
},{}],52:[function(require,module,exports){
function dot(o,t){return o[0]*t[0]+o[1]*t[1]+o[2]*t[2]}module.exports=dot;
},{}],53:[function(require,module,exports){
module.exports=1e-6;
},{}],54:[function(require,module,exports){
module.exports=equals;var EPSILON=require("./epsilon");function equals(a,t){var s=a[0],h=a[1],M=a[2],b=t[0],e=t[1],r=t[2];return Math.abs(s-b)<=EPSILON*Math.max(1,Math.abs(s),Math.abs(b))&&Math.abs(h-e)<=EPSILON*Math.max(1,Math.abs(h),Math.abs(e))&&Math.abs(M-r)<=EPSILON*Math.max(1,Math.abs(M),Math.abs(r))}
},{"./epsilon":53}],55:[function(require,module,exports){
function exactEquals(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]}module.exports=exactEquals;
},{}],56:[function(require,module,exports){
function floor(o,r){return o[0]=Math.floor(r[0]),o[1]=Math.floor(r[1]),o[2]=Math.floor(r[2]),o}module.exports=floor;
},{}],57:[function(require,module,exports){
module.exports=forEach;var vec=require("./create")();function forEach(e,c,r,v,t,a){var n,o;for(c||(c=3),r||(r=0),o=v?Math.min(v*c+r,e.length):e.length,n=r;n<o;n+=c)vec[0]=e[n],vec[1]=e[n+1],vec[2]=e[n+2],t(vec,vec,a),e[n]=vec[0],e[n+1]=vec[1],e[n+2]=vec[2];return e}
},{"./create":46}],58:[function(require,module,exports){
function fromValues(r,e,o){var a=new Float32Array(3);return a[0]=r,a[1]=e,a[2]=o,a}module.exports=fromValues;
},{}],59:[function(require,module,exports){
module.exports={EPSILON:require("./epsilon"),create:require("./create"),clone:require("./clone"),angle:require("./angle"),fromValues:require("./fromValues"),copy:require("./copy"),set:require("./set"),equals:require("./equals"),exactEquals:require("./exactEquals"),add:require("./add"),subtract:require("./subtract"),sub:require("./sub"),multiply:require("./multiply"),mul:require("./mul"),divide:require("./divide"),div:require("./div"),min:require("./min"),max:require("./max"),floor:require("./floor"),ceil:require("./ceil"),round:require("./round"),scale:require("./scale"),scaleAndAdd:require("./scaleAndAdd"),distance:require("./distance"),dist:require("./dist"),squaredDistance:require("./squaredDistance"),sqrDist:require("./sqrDist"),length:require("./length"),len:require("./len"),squaredLength:require("./squaredLength"),sqrLen:require("./sqrLen"),negate:require("./negate"),inverse:require("./inverse"),normalize:require("./normalize"),dot:require("./dot"),cross:require("./cross"),lerp:require("./lerp"),random:require("./random"),transformMat4:require("./transformMat4"),transformMat3:require("./transformMat3"),transformQuat:require("./transformQuat"),rotateX:require("./rotateX"),rotateY:require("./rotateY"),rotateZ:require("./rotateZ"),forEach:require("./forEach")};
},{"./add":41,"./angle":42,"./ceil":43,"./clone":44,"./copy":45,"./create":46,"./cross":47,"./dist":48,"./distance":49,"./div":50,"./divide":51,"./dot":52,"./epsilon":53,"./equals":54,"./exactEquals":55,"./floor":56,"./forEach":57,"./fromValues":58,"./inverse":60,"./len":61,"./length":62,"./lerp":63,"./max":64,"./min":65,"./mul":66,"./multiply":67,"./negate":68,"./normalize":69,"./random":70,"./rotateX":71,"./rotateY":72,"./rotateZ":73,"./round":74,"./scale":75,"./scaleAndAdd":76,"./set":77,"./sqrDist":78,"./sqrLen":79,"./squaredDistance":80,"./squaredLength":81,"./sub":82,"./subtract":83,"./transformMat3":84,"./transformMat4":85,"./transformQuat":86}],60:[function(require,module,exports){
function inverse(e,n){return e[0]=1/n[0],e[1]=1/n[1],e[2]=1/n[2],e}module.exports=inverse;
},{}],61:[function(require,module,exports){
module.exports=require("./length");
},{"./length":62}],62:[function(require,module,exports){
function length(t){var e=t[0],n=t[1],r=t[2];return Math.sqrt(e*e+n*n+r*r)}module.exports=length;
},{}],63:[function(require,module,exports){
function lerp(r,e,l,n){var o=e[0],p=e[1],t=e[2];return r[0]=o+n*(l[0]-o),r[1]=p+n*(l[1]-p),r[2]=t+n*(l[2]-t),r}module.exports=lerp;
},{}],64:[function(require,module,exports){
function max(a,m,t){return a[0]=Math.max(m[0],t[0]),a[1]=Math.max(m[1],t[1]),a[2]=Math.max(m[2],t[2]),a}module.exports=max;
},{}],65:[function(require,module,exports){
function min(n,i,m){return n[0]=Math.min(i[0],m[0]),n[1]=Math.min(i[1],m[1]),n[2]=Math.min(i[2],m[2]),n}module.exports=min;
},{}],66:[function(require,module,exports){
module.exports=require("./multiply");
},{"./multiply":67}],67:[function(require,module,exports){
function multiply(l,t,u){return l[0]=t[0]*u[0],l[1]=t[1]*u[1],l[2]=t[2]*u[2],l}module.exports=multiply;
},{}],68:[function(require,module,exports){
function negate(e,n){return e[0]=-n[0],e[1]=-n[1],e[2]=-n[2],e}module.exports=negate;
},{}],69:[function(require,module,exports){
function normalize(r,e){var n=e[0],o=e[1],t=e[2],a=n*n+o*o+t*t;return a>0&&(a=1/Math.sqrt(a),r[0]=e[0]*a,r[1]=e[1]*a,r[2]=e[2]*a),r}module.exports=normalize;
},{}],70:[function(require,module,exports){
function random(a,t){t=t||1;var r=2*Math.random()*Math.PI,n=2*Math.random()-1,o=Math.sqrt(1-n*n)*t;return a[0]=Math.cos(r)*o,a[1]=Math.sin(r)*o,a[2]=n*t,a}module.exports=random;
},{}],71:[function(require,module,exports){
function rotateX(t,o,r,a){var e=r[1],n=r[2],s=o[1]-e,u=o[2]-n,c=Math.sin(a),h=Math.cos(a);return t[0]=o[0],t[1]=e+s*h-u*c,t[2]=n+s*c+u*h,t}module.exports=rotateX;
},{}],72:[function(require,module,exports){
function rotateY(t,o,r,a){var e=r[0],n=r[2],s=o[0]-e,u=o[2]-n,c=Math.sin(a),h=Math.cos(a);return t[0]=e+u*c+s*h,t[1]=o[1],t[2]=n+u*h-s*c,t}module.exports=rotateY;
},{}],73:[function(require,module,exports){
function rotateZ(t,o,r,a){var e=r[0],n=r[1],s=o[0]-e,u=o[1]-n,c=Math.sin(a),h=Math.cos(a);return t[0]=e+s*h-u*c,t[1]=n+s*c+u*h,t[2]=o[2],t}module.exports=rotateZ;
},{}],74:[function(require,module,exports){
function round(n,o){return n[0]=Math.round(o[0]),n[1]=Math.round(o[1]),n[2]=Math.round(o[2]),n}module.exports=round;
},{}],75:[function(require,module,exports){
function scale(e,c,l){return e[0]=c[0]*l,e[1]=c[1]*l,e[2]=c[2]*l,e}module.exports=scale;
},{}],76:[function(require,module,exports){
function scaleAndAdd(d,e,n,A){return d[0]=e[0]+n[0]*A,d[1]=e[1]+n[1]*A,d[2]=e[2]+n[2]*A,d}module.exports=scaleAndAdd;
},{}],77:[function(require,module,exports){
function set(e,t,n,o){return e[0]=t,e[1]=n,e[2]=o,e}module.exports=set;
},{}],78:[function(require,module,exports){
module.exports=require("./squaredDistance");
},{"./squaredDistance":80}],79:[function(require,module,exports){
module.exports=require("./squaredLength");
},{"./squaredLength":81}],80:[function(require,module,exports){
function squaredDistance(e,r){var a=r[0]-e[0],n=r[1]-e[1],s=r[2]-e[2];return a*a+n*n+s*s}module.exports=squaredDistance;
},{}],81:[function(require,module,exports){
function squaredLength(e){var r=e[0],n=e[1],t=e[2];return r*r+n*n+t*t}module.exports=squaredLength;
},{}],82:[function(require,module,exports){
module.exports=require("./subtract");
},{"./subtract":83}],83:[function(require,module,exports){
function subtract(t,r,u){return t[0]=r[0]-u[0],t[1]=r[1]-u[1],t[2]=r[2]-u[2],t}module.exports=subtract;
},{}],84:[function(require,module,exports){
function transformMat3(r,t,a){var n=t[0],o=t[1],e=t[2];return r[0]=n*a[0]+o*a[3]+e*a[6],r[1]=n*a[1]+o*a[4]+e*a[7],r[2]=n*a[2]+o*a[5]+e*a[8],r}module.exports=transformMat3;
},{}],85:[function(require,module,exports){
function transformMat4(r,t,a){var n=t[0],o=t[1],e=t[2],f=a[3]*n+a[7]*o+a[11]*e+a[15];return f=f||1,r[0]=(a[0]*n+a[4]*o+a[8]*e+a[12])/f,r[1]=(a[1]*n+a[5]*o+a[9]*e+a[13])/f,r[2]=(a[2]*n+a[6]*o+a[10]*e+a[14])/f,r}module.exports=transformMat4;
},{}],86:[function(require,module,exports){
function transformQuat(r,t,a){var n=t[0],o=t[1],u=t[2],e=a[0],f=a[1],m=a[2],s=a[3],Q=s*n+f*u-m*o,c=s*o+m*n-e*u,d=s*u+e*o-f*n,i=-e*n-f*o-m*u;return r[0]=Q*s+i*-e+c*-m-d*-f,r[1]=c*s+i*-f+d*-e-Q*-m,r[2]=d*s+i*-m+Q*-f-c*-e,r}module.exports=transformQuat;
},{}],87:[function(require,module,exports){
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):e.createREGL=t()}(this,function(){function e(e,t){this.id=H++,this.type=e,this.data=t}function t(e){return"["+function e(t){if(0===t.length)return[];var r=t.charAt(0),n=t.charAt(t.length-1);if(1<t.length&&r===n&&('"'===r||"'"===r))return['"'+t.substr(1,t.length-2).replace(/\\/g,"\\\\").replace(/"/g,'\\"')+'"'];if(r=/\[(false|true|null|\d+|'[^']*'|"[^"]*")\]/.exec(t))return e(t.substr(0,r.index)).concat(e(r[1])).concat(e(t.substr(r.index+r[0].length)));if(1===(r=t.split(".")).length)return['"'+t.replace(/\\/g,"\\\\").replace(/"/g,'\\"')+'"'];for(t=[],n=0;n<r.length;++n)t=t.concat(e(r[n]));return t}(e).join("][")+"]"}function r(e){return"string"==typeof e?e.split():e}function n(e){return"string"==typeof e?document.querySelector(e):e}function i(e){var t,i,a,f,o=e||{};e={};var u=[],s=[],c="undefined"==typeof window?1:window.devicePixelRatio,l=!1,p=function(e){},d=function(){};if("string"==typeof o?t=document.querySelector(o):"object"==typeof o&&("string"==typeof o.nodeName&&"function"==typeof o.appendChild&&"function"==typeof o.getBoundingClientRect?t=o:"function"==typeof o.drawArrays||"function"==typeof o.drawElements?a=(f=o).canvas:("gl"in o?f=o.gl:"canvas"in o?a=n(o.canvas):"container"in o&&(i=n(o.container)),"attributes"in o&&(e=o.attributes),"extensions"in o&&(u=r(o.extensions)),"optionalExtensions"in o&&(s=r(o.optionalExtensions)),"onDone"in o&&(p=o.onDone),"profile"in o&&(l=!!o.profile),"pixelRatio"in o&&(c=+o.pixelRatio))),t&&("canvas"===t.nodeName.toLowerCase()?a=t:i=t),!f){if(!a){if(!(t=function(e,t,r){function n(){var t=window.innerWidth,n=window.innerHeight;e!==document.body&&(t=(n=a.getBoundingClientRect()).right-n.left,n=n.bottom-n.top),a.width=r*t,a.height=r*n}var i,a=document.createElement("canvas");return R(a.style,{border:0,margin:0,padding:0,top:0,left:0,width:"100%",height:"100%"}),e.appendChild(a),e===document.body&&(a.style.position="absolute",R(e.style,{margin:0,padding:0})),e!==document.body&&"function"==typeof ResizeObserver?(i=new ResizeObserver(function(){setTimeout(n)})).observe(e):window.addEventListener("resize",n,!1),n(),{canvas:a,onDestroy:function(){i?i.disconnect():window.removeEventListener("resize",n),e.removeChild(a)}}}(i||document.body,0,c)))return null;a=t.canvas,d=t.onDestroy}void 0===e.premultipliedAlpha&&(e.premultipliedAlpha=!0),f=function(e,t){function r(r){try{return e.getContext(r,t)}catch(e){return null}}return r("webgl")||r("experimental-webgl")||r("webgl-experimental")}(a,e)}return f?{gl:f,canvas:a,container:i,extensions:u,optionalExtensions:s,pixelRatio:c,profile:l,onDone:p,onDestroy:d}:(d(),p("webgl not supported, try upgrading your browser or graphics drivers http://get.webgl.org"),null)}function a(e,t){for(var r=Array(e),n=0;n<e;++n)r[n]=t(n);return r}function f(e){var t,r;return t=(65535<e)<<4,t|=r=(255<(e>>>=t))<<3,(t|=r=(15<(e>>>=r))<<2)|(r=(3<(e>>>=r))<<1)|e>>>r>>1}function o(){function e(e){e:{for(var t=16;268435456>=t;t*=16)if(e<=t){e=t;break e}e=0}return 0<(t=r[f(e)>>2]).length?t.pop():new ArrayBuffer(e)}function t(e){r[f(e.byteLength)>>2].push(e)}var r=a(8,function(){return[]});return{alloc:e,free:t,allocType:function(t,r){var n=null;switch(t){case 5120:n=new Int8Array(e(r),0,r);break;case 5121:n=new Uint8Array(e(r),0,r);break;case 5122:n=new Int16Array(e(2*r),0,r);break;case 5123:n=new Uint16Array(e(2*r),0,r);break;case 5124:n=new Int32Array(e(4*r),0,r);break;case 5125:n=new Uint32Array(e(4*r),0,r);break;case 5126:n=new Float32Array(e(4*r),0,r);break;default:return null}return n.length!==r?n.subarray(0,r):n},freeType:function(e){t(e.buffer)}}}function u(e){return!!e&&"object"==typeof e&&Array.isArray(e.shape)&&Array.isArray(e.stride)&&"number"==typeof e.offset&&e.shape.length===e.stride.length&&(Array.isArray(e.data)||G(e.data))}function s(e,t,r,n,i,a){for(var f=0;f<t;++f)for(var o=e[f],u=0;u<r;++u)for(var s=o[u],c=0;c<n;++c)i[a++]=s[c]}function c(e){return 0|J[Object.prototype.toString.call(e)]}function l(e,t){for(var r=0;r<t.length;++r)e[r]=t[r]}function p(e,t,r,n,i,a,f){for(var o=0,u=0;u<r;++u)for(var s=0;s<n;++s)e[o++]=t[i*u+a*s+f]}function d(e,t,r,n){function i(t){this.id=s++,this.buffer=e.createBuffer(),this.type=t,this.usage=35044,this.byteLength=0,this.dimension=1,this.dtype=5121,this.persistentData=null,r.profile&&(this.stats={size:0})}function a(t,r,n){t.byteLength=r.byteLength,e.bufferData(t.type,r,n)}function f(e,t,r,n,i,f){if(e.usage=r,Array.isArray(t)){if(e.dtype=n||5126,0<t.length)if(Array.isArray(t[0])){i=ee(t);for(var o=n=1;o<i.length;++o)n*=i[o];e.dimension=n,a(e,t=$(t,i,e.dtype),r),f?e.persistentData=t:q.freeType(t)}else"number"==typeof t[0]?(e.dimension=i,l(i=q.allocType(e.dtype,t.length),t),a(e,i,r),f?e.persistentData=i:q.freeType(i)):G(t[0])&&(e.dimension=t[0].length,e.dtype=n||c(t[0])||5126,a(e,t=$(t,[t.length,t[0].length],e.dtype),r),f?e.persistentData=t:q.freeType(t))}else if(G(t))e.dtype=n||c(t),e.dimension=i,a(e,t,r),f&&(e.persistentData=new Uint8Array(new Uint8Array(t.buffer)));else if(u(t)){i=t.shape;var s=t.stride,d=(o=t.offset,0),h=0,m=0,b=0;1===i.length?(d=i[0],h=1,m=s[0],b=0):2===i.length&&(d=i[0],h=i[1],m=s[0],b=s[1]),e.dtype=n||c(t.data)||5126,e.dimension=h,p(i=q.allocType(e.dtype,d*h),t.data,d,h,m,b,o),a(e,i,r),f?e.persistentData=i:q.freeType(i)}else t instanceof ArrayBuffer&&(e.dtype=5121,e.dimension=i,a(e,t,r),f&&(e.persistentData=new Uint8Array(new Uint8Array(t))))}function o(r){t.bufferCount--,n(r),e.deleteBuffer(r.buffer),r.buffer=null,delete d[r.id]}var s=0,d={};i.prototype.bind=function(){e.bindBuffer(this.type,this.buffer)},i.prototype.destroy=function(){o(this)};var h=[];return r.profile&&(t.getTotalBufferSize=function(){var e=0;return Object.keys(d).forEach(function(t){e+=d[t].stats.size}),e}),{create:function(n,a,s,h){function m(t){var n=35044,i=null,a=0,o=0,s=1;return Array.isArray(t)||G(t)||u(t)||t instanceof ArrayBuffer?i=t:"number"==typeof t?a=0|t:t&&("data"in t&&(i=t.data),"usage"in t&&(n=Z[t.usage]),"type"in t&&(o=K[t.type]),"dimension"in t&&(s=0|t.dimension),"length"in t&&(a=0|t.length)),b.bind(),i?f(b,i,n,o,s,h):(a&&e.bufferData(b.type,a,n),b.dtype=o||5121,b.usage=n,b.dimension=s,b.byteLength=a),r.profile&&(b.stats.size=b.byteLength*te[b.dtype]),m}t.bufferCount++;var b=new i(a);return d[b.id]=b,s||m(n),m._reglType="buffer",m._buffer=b,m.subdata=function(t,r){var n,i=0|(r||0);if(b.bind(),G(t)||t instanceof ArrayBuffer)e.bufferSubData(b.type,i,t);else if(Array.isArray(t)){if(0<t.length)if("number"==typeof t[0]){var a=q.allocType(b.dtype,t.length);l(a,t),e.bufferSubData(b.type,i,a),q.freeType(a)}else(Array.isArray(t[0])||G(t[0]))&&(n=ee(t),a=$(t,n,b.dtype),e.bufferSubData(b.type,i,a),q.freeType(a))}else if(u(t)){n=t.shape;var f=t.stride,o=a=0,s=0,d=0;1===n.length?(a=n[0],o=1,s=f[0],d=0):2===n.length&&(a=n[0],o=n[1],s=f[0],d=f[1]),n=Array.isArray(t.data)?b.dtype:c(t.data),p(n=q.allocType(n,a*o),t.data,a,o,s,d,t.offset),e.bufferSubData(b.type,i,n),q.freeType(n)}return m},r.profile&&(m.stats=b.stats),m.destroy=function(){o(b)},m},createStream:function(e,t){var r=h.pop();return r||(r=new i(e)),r.bind(),f(r,t,35040,0,1,!1),r},destroyStream:function(e){h.push(e)},clear:function(){Y(d).forEach(o),h.forEach(o)},getBuffer:function(e){return e&&e._buffer instanceof i?e._buffer:null},restore:function(){Y(d).forEach(function(t){t.buffer=e.createBuffer(),e.bindBuffer(t.type,t.buffer),e.bufferData(t.type,t.persistentData||t.byteLength,t.usage)})},_initBuffer:f}}function h(e,t,r,n){function i(e){this.id=s++,o[this.id]=this,this.buffer=e,this.primType=4,this.type=this.vertCount=0}function a(n,i,a,f,o,s,c){var l;if(n.buffer.bind(),i?((l=c)||G(i)&&(!u(i)||G(i.data))||(l=t.oes_element_index_uint?5125:5123),r._initBuffer(n.buffer,i,a,l,3)):(e.bufferData(34963,s,a),n.buffer.dtype=l||5121,n.buffer.usage=a,n.buffer.dimension=3,n.buffer.byteLength=s),l=c,!c){switch(n.buffer.dtype){case 5121:case 5120:l=5121;break;case 5123:case 5122:l=5123;break;case 5125:case 5124:l=5125}n.buffer.dtype=l}n.type=l,0>(i=o)&&(i=n.buffer.byteLength,5123===l?i>>=1:5125===l&&(i>>=2)),n.vertCount=i,i=f,0>f&&(i=4,1===(f=n.buffer.dimension)&&(i=0),2===f&&(i=1),3===f&&(i=4)),n.primType=i}function f(e){n.elementsCount--,delete o[e.id],e.buffer.destroy(),e.buffer=null}var o={},s=0,c={uint8:5121,uint16:5123};t.oes_element_index_uint&&(c.uint32=5125),i.prototype.bind=function(){this.buffer.bind()};var l=[];return{create:function(e,t){function o(e){if(e)if("number"==typeof e)s(e),l.primType=4,l.vertCount=0|e,l.type=5121;else{var t=null,r=35044,n=-1,i=-1,f=0,p=0;Array.isArray(e)||G(e)||u(e)?t=e:("data"in e&&(t=e.data),"usage"in e&&(r=Z[e.usage]),"primitive"in e&&(n=re[e.primitive]),"count"in e&&(i=0|e.count),"type"in e&&(p=c[e.type]),"length"in e?f=0|e.length:(f=i,5123===p||5122===p?f*=2:5125!==p&&5124!==p||(f*=4))),a(l,t,r,n,i,f,p)}else s(),l.primType=4,l.vertCount=0,l.type=5121;return o}var s=r.create(null,34963,!0),l=new i(s._buffer);return n.elementsCount++,o(e),o._reglType="elements",o._elements=l,o.subdata=function(e,t){return s.subdata(e,t),o},o.destroy=function(){f(l)},o},createStream:function(e){var t=l.pop();return t||(t=new i(r.create(null,34963,!0,!1)._buffer)),a(t,e,35040,-1,-1,0,0),t},destroyStream:function(e){l.push(e)},getElements:function(e){return"function"==typeof e&&e._elements instanceof i?e._elements:null},clear:function(){Y(o).forEach(f)}}}function m(e){for(var t=q.allocType(5123,e.length),r=0;r<e.length;++r)if(isNaN(e[r]))t[r]=65535;else if(1/0===e[r])t[r]=31744;else if(-1/0===e[r])t[r]=64512;else{ne[0]=e[r];var n=(a=ie[0])>>>31<<15,i=(a<<1>>>24)-127,a=a>>13&1023;t[r]=-24>i?n:-14>i?n+(a+1024>>-14-i):15<i?n+31744:n+(i+15<<10)+a}return t}function b(e){return Array.isArray(e)||G(e)}function g(e){return"[object "+e+"]"}function y(e){return Array.isArray(e)&&(0===e.length||"number"==typeof e[0])}function v(e){return!(!Array.isArray(e)||0===e.length||!b(e[0]))}function x(e){return Object.prototype.toString.call(e)}function w(e){if(!e)return!1;var t=x(e);return 0<=he.indexOf(t)||(y(e)||v(e)||u(e))}function A(e,t){36193===e.type?(e.data=m(t),q.freeType(t)):e.data=t}function k(e,t,r,n,i,a){if(e=void 0!==be[e]?be[e]:oe[e]*me[t],a&&(e*=6),i){for(n=0;1<=r;)n+=e*r*r,r/=2;return n}return e*r*n}function _(e,t,r,n,i,a,f){function o(){this.format=this.internalformat=6408,this.type=5121,this.flipY=this.premultiplyAlpha=this.compressed=!1,this.unpackAlignment=1,this.colorSpace=37444,this.channels=this.height=this.width=0}function s(e,t){e.internalformat=t.internalformat,e.format=t.format,e.type=t.type,e.compressed=t.compressed,e.premultiplyAlpha=t.premultiplyAlpha,e.flipY=t.flipY,e.unpackAlignment=t.unpackAlignment,e.colorSpace=t.colorSpace,e.width=t.width,e.height=t.height,e.channels=t.channels}function c(e,t){if("object"==typeof t&&t){"premultiplyAlpha"in t&&(e.premultiplyAlpha=t.premultiplyAlpha),"flipY"in t&&(e.flipY=t.flipY),"alignment"in t&&(e.unpackAlignment=t.alignment),"colorSpace"in t&&(e.colorSpace=U[t.colorSpace]),"type"in t&&(e.type=N[t.type]);var r=e.width,n=e.height,i=e.channels,a=!1;"shape"in t?(r=t.shape[0],n=t.shape[1],3===t.shape.length&&(i=t.shape[2],a=!0)):("radius"in t&&(r=n=t.radius),"width"in t&&(r=t.width),"height"in t&&(n=t.height),"channels"in t&&(i=t.channels,a=!0)),e.width=0|r,e.height=0|n,e.channels=0|i,r=!1,"format"in t&&(r=t.format,n=e.internalformat=Q[r],e.format=he[n],r in N&&!("type"in t)&&(e.type=N[r]),r in K&&(e.compressed=!0),r=!0),!a&&r?e.channels=oe[e.format]:a&&!r&&e.channels!==fe[e.format]&&(e.format=e.internalformat=fe[e.channels])}}function l(t){e.pixelStorei(37440,t.flipY),e.pixelStorei(37441,t.premultiplyAlpha),e.pixelStorei(37443,t.colorSpace),e.pixelStorei(3317,t.unpackAlignment)}function p(){o.call(this),this.yOffset=this.xOffset=0,this.data=null,this.needsFree=!1,this.element=null,this.needsCopy=!1}function d(e,t){var r=null;if(w(t)?r=t:t&&(c(e,t),"x"in t&&(e.xOffset=0|t.x),"y"in t&&(e.yOffset=0|t.y),w(t.data)&&(r=t.data)),t.copy){var n=i.viewportWidth,a=i.viewportHeight;e.width=e.width||n-e.xOffset,e.height=e.height||a-e.yOffset,e.needsCopy=!0}else if(r){if(G(r))e.channels=e.channels||4,e.data=r,"type"in t||5121!==e.type||(e.type=0|J[Object.prototype.toString.call(r)]);else if(y(r)){switch(e.channels=e.channels||4,a=(n=r).length,e.type){case 5121:case 5123:case 5125:case 5126:(a=q.allocType(e.type,a)).set(n),e.data=a;break;case 36193:e.data=m(n)}e.alignment=1,e.needsFree=!0}else if(u(r)){n=r.data,Array.isArray(n)||5121!==e.type||(e.type=0|J[Object.prototype.toString.call(n)]);a=r.shape;var f,o,s,l,p=r.stride;3===a.length?(s=a[2],l=p[2]):l=s=1,f=a[0],o=a[1],a=p[0],p=p[1],e.alignment=1,e.width=f,e.height=o,e.channels=s,e.format=e.internalformat=fe[s],e.needsFree=!0,f=l,r=r.offset,s=e.width,l=e.height,o=e.channels;for(var d=q.allocType(36193===e.type?5126:e.type,s*l*o),h=0,g=0;g<l;++g)for(var k=0;k<s;++k)for(var _=0;_<o;++_)d[h++]=n[a*k+p*g+f*_+r];A(e,d)}else if(x(r)===ue||x(r)===se||x(r)===ce)x(r)===ue||x(r)===se?e.element=r:e.element=r.canvas,e.width=e.element.width,e.height=e.element.height,e.channels=4;else if(x(r)===le)e.element=r,e.width=r.width,e.height=r.height,e.channels=4;else if(x(r)===pe)e.element=r,e.width=r.naturalWidth,e.height=r.naturalHeight,e.channels=4;else if(x(r)===de)e.element=r,e.width=r.videoWidth,e.height=r.videoHeight,e.channels=4;else if(v(r)){for(n=e.width||r[0].length,a=e.height||r.length,p=e.channels,p=b(r[0][0])?p||r[0][0].length:p||1,f=X.shape(r),s=1,l=0;l<f.length;++l)s*=f[l];s=q.allocType(36193===e.type?5126:e.type,s),X.flatten(r,f,"",s),A(e,s),e.alignment=1,e.width=n,e.height=a,e.channels=p,e.format=e.internalformat=fe[p],e.needsFree=!0}}else e.width=e.width||1,e.height=e.height||1,e.channels=e.channels||4}function h(t,r,i,a,f){var o=t.element,u=t.data,s=t.internalformat,c=t.format,p=t.type,d=t.width,h=t.height;l(t),o?e.texSubImage2D(r,f,i,a,c,p,o):t.compressed?e.compressedTexSubImage2D(r,f,i,a,s,d,h,u):t.needsCopy?(n(),e.copyTexSubImage2D(r,f,i,a,t.xOffset,t.yOffset,d,h)):e.texSubImage2D(r,f,i,a,d,h,c,p,u)}function g(){return me.pop()||new p}function _(e){e.needsFree&&q.freeType(e.data),p.call(e),me.push(e)}function O(){o.call(this),this.genMipmaps=!1,this.mipmapHint=4352,this.mipmask=0,this.images=Array(16)}function E(e,t,r){var n=e.images[0]=g();e.mipmask=1,n.width=e.width=t,n.height=e.height=r,n.channels=e.channels=4}function D(e,t){var r=null;if(w(t))s(r=e.images[0]=g(),e),d(r,t),e.mipmask=1;else if(c(e,t),Array.isArray(t.mipmap))for(var n=t.mipmap,i=0;i<n.length;++i)s(r=e.images[i]=g(),e),r.width>>=i,r.height>>=i,d(r,n[i]),e.mipmask|=1<<i;else s(r=e.images[0]=g(),e),d(r,t),e.mipmask=1;s(e,e.images[0])}function T(t,r){for(var i=t.images,a=0;a<i.length&&i[a];++a){var f=i[a],o=r,u=a,s=f.element,c=f.data,p=f.internalformat,d=f.format,h=f.type,m=f.width,b=f.height;l(f),s?e.texImage2D(o,u,d,d,h,s):f.compressed?e.compressedTexImage2D(o,u,p,m,b,0,c):f.needsCopy?(n(),e.copyTexImage2D(o,u,d,f.xOffset,f.yOffset,m,b,0)):e.texImage2D(o,u,d,m,b,0,d,h,c||null)}}function S(){var e=be.pop()||new O;o.call(e);for(var t=e.mipmask=0;16>t;++t)e.images[t]=null;return e}function j(e){for(var t=e.images,r=0;r<t.length;++r)t[r]&&_(t[r]),t[r]=null;be.push(e)}function C(){this.magFilter=this.minFilter=9728,this.wrapT=this.wrapS=33071,this.anisotropic=1,this.genMipmaps=!1,this.mipmapHint=4352}function V(e,t){"min"in t&&(e.minFilter=W[t.min],0<=ae.indexOf(e.minFilter)&&!("faces"in t)&&(e.genMipmaps=!0)),"mag"in t&&(e.magFilter=H[t.mag]);var r=e.wrapS,n=e.wrapT;if("wrap"in t){var i=t.wrap;"string"==typeof i?r=n=M[i]:Array.isArray(i)&&(r=M[i[0]],n=M[i[1]])}else"wrapS"in t&&(r=M[t.wrapS]),"wrapT"in t&&(n=M[t.wrapT]);if(e.wrapS=r,e.wrapT=n,"anisotropic"in t&&(e.anisotropic=t.anisotropic),"mipmap"in t){switch(r=!1,typeof t.mipmap){case"string":e.mipmapHint=L[t.mipmap],r=e.genMipmaps=!0;break;case"boolean":r=e.genMipmaps=t.mipmap;break;case"object":e.genMipmaps=!1,r=!0}!r||"min"in t||(e.minFilter=9984)}}function F(r,n){e.texParameteri(n,10241,r.minFilter),e.texParameteri(n,10240,r.magFilter),e.texParameteri(n,10242,r.wrapS),e.texParameteri(n,10243,r.wrapT),t.ext_texture_filter_anisotropic&&e.texParameteri(n,34046,r.anisotropic),r.genMipmaps&&(e.hint(33170,r.mipmapHint),e.generateMipmap(n))}function B(t){o.call(this),this.mipmask=0,this.internalformat=6408,this.id=ge++,this.refCount=1,this.target=t,this.texture=e.createTexture(),this.unit=-1,this.bindCount=0,this.texInfo=new C,f.profile&&(this.stats={size:0})}function z(t){e.activeTexture(33984),e.bindTexture(t.target,t.texture)}function I(){var t=xe[0];t?e.bindTexture(t.target,t.texture):e.bindTexture(3553,null)}function P(t){var r=t.texture,n=t.unit,i=t.target;0<=n&&(e.activeTexture(33984+n),e.bindTexture(i,null),xe[n]=null),e.deleteTexture(r),t.texture=null,t.params=null,t.pixels=null,t.refCount=0,delete ye[t.id],a.textureCount--}var L={"don't care":4352,"dont care":4352,nice:4354,fast:4353},M={repeat:10497,clamp:33071,mirror:33648},H={nearest:9728,linear:9729},W=R({mipmap:9987,"nearest mipmap nearest":9984,"linear mipmap nearest":9985,"nearest mipmap linear":9986,"linear mipmap linear":9987},H),U={none:0,browser:37444},N={uint8:5121,rgba4:32819,rgb565:33635,"rgb5 a1":32820},Q={alpha:6406,luminance:6409,"luminance alpha":6410,rgb:6407,rgba:6408,rgba4:32854,"rgb5 a1":32855,rgb565:36194},K={};t.ext_srgb&&(Q.srgb=35904,Q.srgba=35906),t.oes_texture_float&&(N.float32=N.float=5126),t.oes_texture_half_float&&(N.float16=N["half float"]=36193),t.webgl_depth_texture&&(R(Q,{depth:6402,"depth stencil":34041}),R(N,{uint16:5123,uint32:5125,"depth stencil":34042})),t.webgl_compressed_texture_s3tc&&R(K,{"rgb s3tc dxt1":33776,"rgba s3tc dxt1":33777,"rgba s3tc dxt3":33778,"rgba s3tc dxt5":33779}),t.webgl_compressed_texture_atc&&R(K,{"rgb atc":35986,"rgba atc explicit alpha":35987,"rgba atc interpolated alpha":34798}),t.webgl_compressed_texture_pvrtc&&R(K,{"rgb pvrtc 4bppv1":35840,"rgb pvrtc 2bppv1":35841,"rgba pvrtc 4bppv1":35842,"rgba pvrtc 2bppv1":35843}),t.webgl_compressed_texture_etc1&&(K["rgb etc1"]=36196);var Z=Array.prototype.slice.call(e.getParameter(34467));Object.keys(K).forEach(function(e){var t=K[e];0<=Z.indexOf(t)&&(Q[e]=t)});var $=Object.keys(Q);r.textureFormats=$;var ee=[];Object.keys(Q).forEach(function(e){ee[Q[e]]=e});var te=[];Object.keys(N).forEach(function(e){te[N[e]]=e});var re=[];Object.keys(H).forEach(function(e){re[H[e]]=e});var ne=[];Object.keys(W).forEach(function(e){ne[W[e]]=e});var ie=[];Object.keys(M).forEach(function(e){ie[M[e]]=e});var he=$.reduce(function(e,r){var n=Q[r];return 6409===n||6406===n||6409===n||6410===n||6402===n||34041===n||t.ext_srgb&&(35904===n||35906===n)?e[n]=n:32855===n||0<=r.indexOf("rgba")?e[n]=6408:e[n]=6407,e},{}),me=[],be=[],ge=0,ye={},ve=r.maxTextureUnits,xe=Array(ve).map(function(){return null});return R(B.prototype,{bind:function(){this.bindCount+=1;var t=this.unit;if(0>t){for(var r=0;r<ve;++r){var n=xe[r];if(n){if(0<n.bindCount)continue;n.unit=-1}xe[r]=this,t=r;break}f.profile&&a.maxTextureUnits<t+1&&(a.maxTextureUnits=t+1),this.unit=t,e.activeTexture(33984+t),e.bindTexture(this.target,this.texture)}return t},unbind:function(){--this.bindCount},decRef:function(){0>=--this.refCount&&P(this)}}),f.profile&&(a.getTotalTextureSize=function(){var e=0;return Object.keys(ye).forEach(function(t){e+=ye[t].stats.size}),e}),{create2D:function(t,r){function n(e,t){var r=i.texInfo;C.call(r);var a=S();return"number"==typeof e?E(a,0|e,"number"==typeof t?0|t:0|e):e?(V(r,e),D(a,e)):E(a,1,1),r.genMipmaps&&(a.mipmask=(a.width<<1)-1),i.mipmask=a.mipmask,s(i,a),i.internalformat=a.internalformat,n.width=a.width,n.height=a.height,z(i),T(a,3553),F(r,3553),I(),j(a),f.profile&&(i.stats.size=k(i.internalformat,i.type,a.width,a.height,r.genMipmaps,!1)),n.format=ee[i.internalformat],n.type=te[i.type],n.mag=re[r.magFilter],n.min=ne[r.minFilter],n.wrapS=ie[r.wrapS],n.wrapT=ie[r.wrapT],n}var i=new B(3553);return ye[i.id]=i,a.textureCount++,n(t,r),n.subimage=function(e,t,r,a){t|=0,r|=0,a|=0;var f=g();return s(f,i),f.width=0,f.height=0,d(f,e),f.width=f.width||(i.width>>a)-t,f.height=f.height||(i.height>>a)-r,z(i),h(f,3553,t,r,a),I(),_(f),n},n.resize=function(t,r){var a=0|t,o=0|r||a;if(a===i.width&&o===i.height)return n;n.width=i.width=a,n.height=i.height=o,z(i);for(var u=0;i.mipmask>>u;++u){var s=a>>u,c=o>>u;if(!s||!c)break;e.texImage2D(3553,u,i.format,s,c,0,i.format,i.type,null)}return I(),f.profile&&(i.stats.size=k(i.internalformat,i.type,a,o,!1,!1)),n},n._reglType="texture2d",n._texture=i,f.profile&&(n.stats=i.stats),n.destroy=function(){i.decRef()},n},createCube:function(t,r,n,i,o,u){function l(e,t,r,n,i,a){var o,u=p.texInfo;for(C.call(u),o=0;6>o;++o)m[o]=S();if("number"!=typeof e&&e){if("object"==typeof e)if(t)D(m[0],e),D(m[1],t),D(m[2],r),D(m[3],n),D(m[4],i),D(m[5],a);else if(V(u,e),c(p,e),"faces"in e)for(e=e.faces,o=0;6>o;++o)s(m[o],p),D(m[o],e[o]);else for(o=0;6>o;++o)D(m[o],e)}else for(e=0|e||1,o=0;6>o;++o)E(m[o],e,e);for(s(p,m[0]),p.mipmask=u.genMipmaps?(m[0].width<<1)-1:m[0].mipmask,p.internalformat=m[0].internalformat,l.width=m[0].width,l.height=m[0].height,z(p),o=0;6>o;++o)T(m[o],34069+o);for(F(u,34067),I(),f.profile&&(p.stats.size=k(p.internalformat,p.type,l.width,l.height,u.genMipmaps,!0)),l.format=ee[p.internalformat],l.type=te[p.type],l.mag=re[u.magFilter],l.min=ne[u.minFilter],l.wrapS=ie[u.wrapS],l.wrapT=ie[u.wrapT],o=0;6>o;++o)j(m[o]);return l}var p=new B(34067);ye[p.id]=p,a.cubeCount++;var m=Array(6);return l(t,r,n,i,o,u),l.subimage=function(e,t,r,n,i){r|=0,n|=0,i|=0;var a=g();return s(a,p),a.width=0,a.height=0,d(a,t),a.width=a.width||(p.width>>i)-r,a.height=a.height||(p.height>>i)-n,z(p),h(a,34069+e,r,n,i),I(),_(a),l},l.resize=function(t){if((t|=0)!==p.width){l.width=p.width=t,l.height=p.height=t,z(p);for(var r=0;6>r;++r)for(var n=0;p.mipmask>>n;++n)e.texImage2D(34069+r,n,p.format,t>>n,t>>n,0,p.format,p.type,null);return I(),f.profile&&(p.stats.size=k(p.internalformat,p.type,l.width,l.height,!1,!0)),l}},l._reglType="textureCube",l._texture=p,f.profile&&(l.stats=p.stats),l.destroy=function(){p.decRef()},l},clear:function(){for(var t=0;t<ve;++t)e.activeTexture(33984+t),e.bindTexture(3553,null),xe[t]=null;Y(ye).forEach(P),a.cubeCount=0,a.textureCount=0},getTexture:function(e){return null},restore:function(){for(var t=0;t<ve;++t){var r=xe[t];r&&(r.bindCount=0,r.unit=-1,xe[t]=null)}Y(ye).forEach(function(t){t.texture=e.createTexture(),e.bindTexture(t.target,t.texture);for(var r=0;32>r;++r)if(0!=(t.mipmask&1<<r))if(3553===t.target)e.texImage2D(3553,r,t.internalformat,t.width>>r,t.height>>r,0,t.internalformat,t.type,null);else for(var n=0;6>n;++n)e.texImage2D(34069+n,r,t.internalformat,t.width>>r,t.height>>r,0,t.internalformat,t.type,null);F(t.texInfo,t.target)})},refresh:function(){for(var t=0;t<ve;++t){var r=xe[t];r&&(r.bindCount=0,r.unit=-1,xe[t]=null),e.activeTexture(33984+t),e.bindTexture(3553,null),e.bindTexture(34067,null)}}}}function O(e,t,r,n,i,a){function f(e,t,r){this.target=e,this.texture=t,this.renderbuffer=r;var n=e=0;t?(e=t.width,n=t.height):r&&(e=r.width,n=r.height),this.width=e,this.height=n}function o(e){e&&(e.texture&&e.texture._texture.decRef(),e.renderbuffer&&e.renderbuffer._renderbuffer.decRef())}function u(e,t,r){e&&(e.texture?e.texture._texture.refCount+=1:e.renderbuffer._renderbuffer.refCount+=1)}function s(t,r){r&&(r.texture?e.framebufferTexture2D(36160,t,r.target,r.texture._texture.texture,0):e.framebufferRenderbuffer(36160,t,36161,r.renderbuffer._renderbuffer.renderbuffer))}function c(e){var t=3553,r=null,n=null,i=e;return"object"==typeof e&&(i=e.data,"target"in e&&(t=0|e.target)),"texture2d"===(e=i._reglType)?r=i:"textureCube"===e?r=i:"renderbuffer"===e&&(n=i,t=36161),new f(t,r,n)}function l(e,t,r,a,o){return r?((e=n.create2D({width:e,height:t,format:a,type:o}))._texture.refCount=0,new f(3553,e,null)):((e=i.create({width:e,height:t,format:a}))._renderbuffer.refCount=0,new f(36161,null,e))}function p(e){return e&&(e.texture||e.renderbuffer)}function d(e,t,r){e&&(e.texture?e.texture.resize(t,r):e.renderbuffer&&e.renderbuffer.resize(t,r),e.width=t,e.height=r)}function h(){this.id=k++,_[this.id]=this,this.framebuffer=e.createFramebuffer(),this.height=this.width=0,this.colorAttachments=[],this.depthStencilAttachment=this.stencilAttachment=this.depthAttachment=null}function m(e){e.colorAttachments.forEach(o),o(e.depthAttachment),o(e.stencilAttachment),o(e.depthStenci