text: /*
  	@license
  	weml license:
  		MIT License
  		
  		Copyright (c) 2017 Jan Katzer
  		
  		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.
  	
  	# weml.js is based on code from JOML (https://github.com/JOML-CI/JOML)
  	JOML license:
  		The MIT License (MIT)
  		
  		Copyright (c) 2015-2017 JOML
  		
  		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.
  */
  var weml={allocateArray:function(t){return new Float32Array(t)},selectTypeprototype:function(t){var i=void 0!==window.SIMD;t.typeprototype._current=(i?t.typeprototype.simd:null)||t.typeprototype.sisd},modmod:function(t,i){return(t%i+i)%i},radmod:function(t){return this.modmod(t+Math.PI,2*Math.PI)-Math.PI},toRadians:function(t){return t*(Math.PI/180)},toDegrees:function(t){return t*(180/Math.PI)},rand:function(t,i){return t=t||0,i=i||1,Math.random()*(i-t)+t},randVec3:function(t,i,s){return s=s||new Vec3,t=t||-1,i=i||1,s[0]=this.rand(t,i),s[1]=this.rand(t,i),s[2]=this.rand(t,i),s},randQuat:function(t){return t=t||new Quat,t[0]=this.rand(-1,1),t[1]=this.rand(-1,1),t[2]=this.rand(-1,1),t[3]=this.rand(-1,1),t.normalize(),t}},Vec3=function(t,i,s){var h=weml.allocateArray(3);return Object.assign(h,Vec3.typeprototype._current),h[0]=t||0,h[1]=i||0,h[2]=s||0,h};Vec3.typeprototype={},function(){Vec3.typeprototype.sisd={toString:function(){return"Vec3["+this[0]+", "+this[1]+", "+this[2]+"]"},size:function(){return 3},clone:function(){return new Vec3(this[0],this[1],this[2])},identity:function(){return this.setXYZ(0,0,0),this},zero:function(){return this.setXYZ(0,0,0),this},set:function(t){return this[0]=t[0],this[1]=t[1],this[2]=t[2],this},setSwizzle:function(t,i,s,h){var n=t[i],r=t[s],e=t[h];return this[0]=n,this[1]=r,this[2]=e,this},setXYZ:function(t,i,s){return this[0]=t,this[1]=i,this[2]=s,this},setX:function(t){return this[0]=t,this},setY:function(t){return this[1]=t,this},setZ:function(t){return this[2]=t,this},setScalar:function(t){return this.setXYZ(t,t,t),this},get:function(t){return t[0]=this[0],t[1]=this[1],t[2]=this[2],t},getX:function(){return this[0]},getY:function(){return this[1]},getZ:function(){return this[2]},put:function(t,i){return i=i||0,t[0+i]=this[0],t[1+i]=this[1],t[2+i]=this[2],this},add:function(t,i){return i=i||this,i[0]=this[0]+t[0],i[1]=this[1]+t[1],i[2]=this[2]+t[2],i},addXYZ:function(t,i,s,h){return h=h||this,h[0]=this[0]+t,h[1]=this[1]+i,h[2]=this[2]+s,h},addScalar:function(t,i){return i=i||this,this.addXYZ(t,t,t,i),i},sub:function(t,i){return i=i||this,i[0]=this[0]-t[0],i[1]=this[1]-t[1],i[2]=this[2]-t[2],i},subXYZ:function(t,i,s,h){return h=h||this,h[0]=this[0]-t,h[1]=this[1]-i,h[2]=this[2]-s,h},subScalar:function(t,i){return i=i||this,this.subXYZ(t,t,t,i),i},mul:function(t,i){return i=i||this,i[0]=this[0]*t[0],i[1]=this[1]*t[1],i[2]=this[2]*t[2],i},mulXYZ:function(t,i,s,h){return h=h||this,h[0]=this[0]*t,h[1]=this[1]*i,h[2]=this[2]*s,h},mulScalar:function(t,i){return i=i||this,this.mulXYZ(t,t,t,i),i},div:function(t,i){return i=i||this,i[0]=this[0]/t[0],i[1]=this[1]/t[1],i[2]=this[2]/t[2],i},divXYZ:function(t,i,s,h){return h=h||this,h[0]=this[0]/t,h[1]=this[1]/i,h[2]=this[2]/s,h},divScalar:function(t,i){return i=i||this,this.divXYZ(t,t,t,i),i},muladd:function(t,i,s){return s=s||this,this.mul(t,s).add(i),s},muladdXYZ:function(t,i,s,h,n,r,e){return e=e||this,this.mulXYZ(t,i,s,e).add(h,n,r),e},dot:function(t){return this[0]*t[0]+this[1]*t[1]+this[2]*t[2]},dotXYZ:function(t,i,s){return this[0]*t+this[1]*i+this[2]*s},normalize:function(t){t=t||this;var i=this.invmagnitude();return Number.isNaN(i)||(t[0]=this[0]*i,t[1]=this[1]*i,t[2]=this[2]*i),t},cross:function(t,i){i=i||this;var s=this[1]*t[2]-this[2]*t[1],h=this[2]*t[0]-this[0]*t[2],n=this[0]*t[1]-this[1]*t[0];return i[0]=s,i[1]=h,i[2]=n,i},crossXYZ:function(t,i,s,h){h=h||this;var n=this[1]*s-this[2]*i,r=this[2]*t-this[0]*s,e=this[0]*i-this[1]*t;return h[0]=n,h[1]=r,h[2]=e,h},magnitude:function(){return Math.sqrt(this[0]*this[0]+this[1]*this[1]+this[2]*this[2])},magnitudesq:function(){return this[0]*this[0]+this[1]*this[1]+this[2]*this[2]},invmagnitude:function(){return 1/this.magnitude()},invmagnitudesq:function(){return 1/this.magnitudesq()},dist:function(t){return Math.sqrt(this.distsq(t))},distXYZ:function(t,i,s){return Math.sqrt(this.distsqXYZ(t,i,s))},distsq:function(t){var i=this[0]-t[0],s=this[1]-t[1],h=this[2]-t[2];return i*i+s*s+h*h},distsqXYZ:function(t,i,s){var h=this[0]-t,n=this[1]-i,r=this[2]-s;return h*h+n*n+r*r},negate:function(t){return t=t||this,t[0]=-this[0],t[1]=-this[1],t[2]=-this[2],t},reflect:function(t,i){i=i||this;var s=this.dot(t);return i[0]=this[0]-(s+s)*t[0],i[1]=this[1]-(s+s)*t[1],i[2]=this[2]-(s+s)*t[2],i},reflectXYZ:function(t,i,s,h){h=h||this;var n=this.dotXYZ(t,i,s);return h[0]=this[0]-(n+n)*t,h[1]=this[1]-(n+n)*i,h[2]=this[2]-(n+n)*s,h},half:function(t,i){return i=i||this,i.add(t).normalize(),i},halfXYZ:function(t,i,s,h){return h=h||this,h.addXYZ(t,i,s).normalize(),h},clampLength:function(t,i,s){s=s||this;var h=this.magnitudesq();if(t*t>h){var n=1/Math.sqrt(h);s[0]=this[0]*n*t,s[1]=this[1]*n*t,s[2]=this[2]*n*t}else if(h>i*i){var r=1/Math.sqrt(h);s[0]=this[0]*r*i,s[1]=this[1]*r*i,s[2]=this[2]*r*i}return s},lerp:function(t,i,s){return s=s||this,s[0]=this[0]+(t[0]-this[0])*i,s[1]=this[1]+(t[1]-this[1])*i,s[2]=this[2]+(t[2]-this[2])*i,s},lerpXYZ:function(t,i,s,h,n){return n=n||this,n[0]=this[0]+(t-this[0])*h,n[1]=this[1]+(i-this[1])*h,n[2]=this[2]+(s-this[2])*h,n}},Vec3.typeprototype.simd=Object.assign(Object.create(Vec3.typeprototype.sisd),{mul:function(t,i){return i=i||this,SIMD.Float32x4.mul(SIMD.Float32x4.load3(this),SIMD.Float32x4.load3(t)).store3(i),i},mulXYZ:function(t,i,s,h){return h=h||this,SIMD.Float32x4.mul(SIMD.Float32x4.load3(this),SIMD.Float32x4(t,i,s)).store3(h),h},mulScalar:function(t,i){return i=i||this,SIMD.Float32x4.mul(SIMD.Float32x4.load3(this),SIMD.Float32x4.splat(3)).store3(i),i},muladd:function(t,i,s){return s=s||this,SIMD.Float32x4.add(SIMD.Float32x4.mul(SIMD.Float32x4.load3(this),SIMD.Float32x4.load3(t)),SIMD.Float32x4.load3(i)).store3(s),s},muladdXYZ:function(t,i,s,h,n,r,e){return e=e||this,SIMD.Float32x4.add(SIMD.Float32x4.mul(SIMD.Float32x4.load3(this),SIMD.Float32x4(t,i,s)),SIMD.Float32x4(h,n,r)).store3(e),e}}),weml.selectTypeprototype(Vec3)}();var Vec4=function(t,i,s,h){var n=weml.allocateArray(4);return Object.assign(n,Vec4.typeprototype._current),n[0]=t||0,n[1]=i||0,n[2]=s||0,n[3]=h||1,n};Vec4.typeprototype={},function(){Vec4.typeprototype.sisd={toString:function(){return"Vec4["+this[0]+", "+this[1]+", "+this[2]+", "+this[3]+"]"},clone:function(){return new Vec4(this[0],this[1],this[2],this[3])},identity:function(){return this.set(0,0,0,1)},zero:function(){return this.set(0,0,0,0)},set:function(t){return this[0]=t[0],this[1]=t[1],this[2]=t[2],this[3]=t[3],this},setXYZW:function(t,i,s,h){return this[0]=t,this[1]=i,this[2]=s,this[3]=h,this},setX:function(t){return this[0]=t,this},setY:function(t){return this[1]=t,this},setZ:function(t){return this[2]=t,this},setW:function(t){return this[3]=t,this},setScalar:function(t){return this[0]=t,this[1]=t,this[2]=t,this[3]=t,this},put:function(t){return t[0]=this[0],t[1]=this[1],t[2]=this[2],t[3]=this[3],this},get:function(t){return t[0]=this[0],t[1]=this[1],t[2]=this[2],t[3]=this[3],t},getX:function(){return this[0]},getY:function(){return this[1]},getZ:function(){return this[2]},getW:function(){return this[3]},add:function(t,i){return i=i||this,i[0]=this[0]+t[0],i[1]=this[1]+t[1],i[2]=this[2]+t[2],i[3]=this[3]+t[3],i},addXYZW:function(t,i,s,h,n){return n=n||this,n[0]=this[0]+t,n[1]=this[1]+i,n[2]=this[2]+s,n[3]=this[3]+h,n},addScalar:function(t,i){return i=i||this,this.addXYZW(t,t,t,t,i),i},sub:function(t,i){return i=i||this,i[0]=this[0]-t[0],i[1]=this[1]-t[1],i[2]=this[2]-t[2],i[3]=this[3]-t[3],i},subXYZW:function(t,i,s,h,n){return n=n||this,n[0]=this[0]-t,n[1]=this[1]-i,n[2]=this[2]-s,n[3]=this[3]-h,n},subScalar:function(t,i){return i=i||this,this.subXYZW(t,t,t,t,i),i},mul:function(t,i){return i=i||this,i[0]=this[0]*t[0],i[1]=this[1]*t[1],i[2]=this[2]*t[2],i[3]=this[3]*t[3],i},mulXYZW:function(t,i,s,h,n){return n=n||this,n[0]=this[0]*t,n[1]=this[1]*i,n[2]=this[2]*s,n[3]=this[3]*h,n},mulScalar:function(t,i){return i=i||this,mulXYZW(t,t,t,t,i),i},div:function(t,i){return i=i||this,i[0]=this[0]/t[0],i[1]=this[1]/t[1],i[2]=this[2]/t[2],i[3]=this[3]/t[3],i},divXYZW:function(t,i,s,h,n){return n=n||this,n[0]=this[0]/t,n[1]=this[1]/i,n[2]=this[2]/s,n[3]=this[3]/h,n},divScalar:function(t,i){return i=i||this,this.divXYZW(t,t,t,t,i),i}},weml.selectTypeprototype(Vec4)}();var Quat=function(t,i,s,h){var n=weml.allocateArray(4);return Object.assign(n,Quat.typeprototype._current),n[0]=t||0,n[1]=i||0,n[2]=s||0,n[3]=h||1,n};Quat.typeprototype={},function(){Quat.typeprototype.sisd={clone:function(){var t=new Quat;return t.set(this),t},set:function(t){return this[0]=t[0],this[1]=t[1],this[2]=t[2],this[3]=t[3],this},setXYZW:function(t,i,s,h){return this[0]=t,this[1]=i,this[2]=s,this[3]=h,this},identity:function(){return this[0]=0,this[1]=0,this[2]=0,this[3]=1,this},zero:function(){return this[0]=0,this[1]=0,this[2]=0,this[3]=0,this},mul:function(t,i){i=i||this;var s=this[3]*t[0]+this[0]*t[3]+this[1]*t[2]-this[2]*t[1],h=this[3]*t[1]-this[0]*t[2]+this[1]*t[3]+this[2]*t[0],n=this[3]*t[2]+this[0]*t[1]-this[1]*t[0]+this[2]*t[3],r=this[3]*t[3]-this[0]*t[0]-this[1]*t[1]-this[2]*t[2];return i[0]=s,i[1]=h,i[2]=n,i[3]=r,i},mulXYZW:function(t,i,s,h,n){n=n||this;var r=this[3]*t+this[0]*h+this[1]*s-this[2]*a[1],e=this[3]*i-this[0]*s+this[1]*h+this[2]*a[0],u=this[3]*s+this[0]*i-this[1]*t+this[2]*a[3],o=this[3]*h-this[0]*t-this[1]*i-this[2]*a[2];return n[0]=r,n[1]=e,n[2]=u,n[3]=o,n},mulScalar:function(t,i){i=i||this;var s=this[3]*t+this[0]*t+this[1]*t-this[2]*a[1],h=this[3]*t-this[0]*t+this[1]*t+this[2]*a[0],n=this[3]*t+this[0]*t-this[1]*t+this[2]*a[3],r=this[3]*t-this[0]*t-this[1]*t-this[2]*a[2];return i[0]=s,i[1]=h,i[2]=n,i[3]=r,i},normalize:function(t){t=t||this;var i=1/Math.sqrt(this[0]*this[0]+this[1]*this[1]+this[2]*this[2]+this[3]*this[3]);return t[0]=this[0]*i,t[1]=this[1]*i,t[2]=this[2]*i,t[3]=this[3]*i,t},invert:function(t){t=t||this;var i=1/this.norm();return t[0]=-this[0]*i,t[1]=-this[1]*i,t[2]=-this[2]*i,t[3]=this[3]*i,t},conjugate:function(t){return t=t||this,t[0]=-this[0],t[1]=-this[1],t[2]=-this[2],t[3]=this[3],t},norm:function(){return this[0]*this[0]+this[1]*this[1]+this[2]*this[2]+this[3]*this[3]},rotateXYZ:function(t,i,s,h){h=h||this;var n=Math.sin(.5*t),r=Math.cos(.5*t),e=Math.sin(.5*i),u=Math.cos(.5*i),o=Math.sin(.5*s),a=Math.cos(.5*s),c=u*a,f=e*o,l=e*a,d=u*o,p=r*c-n*f,y=n*c+r*f,v=r*l-n*d,M=r*d+n*l,m=this[3]*y+this[0]*p+this[1]*M-this[2]*v,X=this[3]*v-this[0]*M+this[1]*p+this[2]*y,Y=this[3]*M+this[0]*v-this[1]*y+this[2]*p,Z=this[3]*p-this[0]*y-this[1]*v-this[2]*M;return h[0]=m,h[1]=X,h[2]=Y,h[3]=Z,h},rotateLocalXYZ:function(t,i,s,h){h=h||this;var n,r,e,u,o,a=.5*t,c=.5*i,f=.5*s,l=a*a+c*c+f*f;if(1e-8>l*l/24)o=1-.5*l,n=1-l/6;else{var d=Math.sqrt(l),p=Math.sin(d);n=p/d,o=Math.cos(d)}return r=a*n,e=c*n,u=f*n,h[0]=o*this[0]+r*this[3]+e*this[2]-u*this[1],h[1]=o*this[1]-r*this[2]+e*this[3]+u*this[0],h[2]=o*this[2]+r*this[1]-e*this[0]+u*this[3],h[3]=o*this[3]-r*this[0]-e*this[1]-u*this[2],h},rotateAroundAxisXYZ:function(t,i,s,h,n){n=n||this;var r=.5*h,e=Math.sin(r),u=1/Math.sqrt(t*t+i*i+s*s),o=t*u*e,a=i*u*e,c=s*u*e,f=Math.cos(r),l=this[3]*o+this[0]*f+this[1]*c-this[2]*a,d=this[3]*a-this[0]*c+this[1]*f+this[2]*o,p=this[3]*c+this[0]*a-this[1]*o+this[2]*f,y=this[3]*f-this[0]*o-this[1]*a-this[2]*c;return this[0]=l,this[1]=d,this[2]=p,this[3]=y,n},rotateAroundLocalAxisXYZ:function(){},rotateTo:function(t,i,s){s=s||this;var h=t[1]*i[2]-t[2]*i[1],n=t[2]*i[0]-t[0]*i[2],r=t[0]*i[1]-t[1]*i[0],e=Math.sqrt((t[0]*t[0]+t[1]*t[1]+t[2]*t[2])*(i[0]*i[0]+i[1]*i[1]+i[2]*i[2]))+(t[0]*i[0]+t[1]*i[1]+t[2]*i[2]),u=1/Math.sqrt(h*h+n*n+r*r+e*e);return h*=u,n*=u,r*=u,e*=u,s[0]=this[3]*h+this[0]*e+this[1]*r-this[2]*n,s[1]=this[3]*n-this[0]*r+this[1]*e+this[2]*h,s[2]=this[3]*r+this[0]*n-this[1]*h+this[2]*e,s[3]=this[3]*e-this[0]*h-this[1]*n-this[2]*r,s},diff:function(t,i){i=i||this;var s=1/this.norm(),h=-this[0]*s,n=-this[1]*s,r=-this[2]*s,e=this[3]*s,u=e*t[0]+h*t[3]+n*t[2]-r*t[1],o=e*t[1]-h*t[2]+n*t[3]+r*t[0],a=e*t[2]+h*t[1]-n*t[0]+r*t[3],c=e*t[3]-h*t[0]-n*t[1]-r*t[2];return i[0]=u,i[1]=o,i[2]=a,i[3]=c,i},slerp:function(t,i,s){s=s||this;var h,n,r=this[0]*t[0]+this[1]*t[1]+this[2]*t[2]+this[3]*t[3],e=Math.abs(r);if(1-e>1e-6){var u=1-e*e,o=1/Math.sqrt(u),a=Math.atan2(u*o,e);h=Math.sin((1-i)*a)*o,n=Math.sin(i*a)*o}else h=1-i,n=i;n=r>=0?n:-n;var c=h*this[0]+n*t[0],f=h*this[1]+n*t[1],l=h*this[2]+n*t[2],d=h*this[3]+n*t[3];return s[0]=c,s[1]=f,s[2]=l,s[3]=d,s},lerp:function(){},transformVec3:function(t,i){i=i||t;var s=2*(this[1]*t[2]-this[2]*t[1]),h=2*(this[2]*t[0]-this[0]*t[2]),n=2*(this[0]*t[1]-this[1]*t[0]);return i[0]=t[0]+s*this[3]+(this[1]*n-this[2]*h),i[1]=t[1]+h*this[3]+(this[2]*s-this[0]*n),i[2]=t[2]+n*this[3]+(this[0]*h-this[1]*s),i}},weml.selectTypeprototype(Quat)}();var Mat4=function(t,i){var s=weml.allocateArray(16);return Object.assign(s,Mat4.typeprototype._current),t?s.set(t,i):s.identity(),s};Mat4.typeprototype={},function(){Mat4.typeprototype.sisd={toString:function(){return"Mat4["+this[0]+", "+this[1]+"..."+this[14]+", "+this[15]+"]"},clone:function(){return new Mat4(this)},identity:function(){return this.fill(0),this[0]=1,this[5]=1,this[10]=1,this[15]=1,this},zero:function(){return this.fill(0),this},set:function(t,i){return 0===i?(this[0]=t[0],this[1]=t[1],this[2]=t[2],this[3]=t[3],this[4]=t[4],this[5]=t[5],this[6]=t[6],this[7]=t[7],this[8]=t[8],this[9]=t[9],this[10]=t[10],this[11]=t[11],this[12]=t[12],this[13]=t[13],this[14]=t[14],this[15]=t[15]):(this[0]=t[0+i],this[1]=t[1+i],this[2]=t[2+i],this[3]=t[3+i],this[4]=t[4+i],this[5]=t[5+i],this[6]=t[6+i],this[7]=t[7+i],this[8]=t[8+i],this[9]=t[9+i],this[10]=t[10+i],this[11]=t[11+i],this[12]=t[12+i],this[13]=t[13+i],this[14]=t[14+i],this[15]=t[15+i]),this},get:function(t){return t.set(this),t},put:function(t){return t.set(this),this},mul:function(t,i){i=i||this;var s=this[0]*t[0]+this[4]*t[1]+this[8]*t[2]+this[12]*t[3],h=this[1]*t[0]+this[5]*t[1]+this[9]*t[2]+this[13]*t[3],n=this[2]*t[0]+this[6]*t[1]+this[10]*t[2]+this[14]*t[3],r=this[3]*t[0]+this[7]*t[1]+this[11]*t[2]+this[15]*t[3],e=this[0]*t[4]+this[4]*t[5]+this[8]*t[6]+this[12]*t[7],u=this[1]*t[4]+this[5]*t[5]+this[9]*t[6]+this[13]*t[7],o=this[2]*t[4]+this[6]*t[5]+this[10]*t[6]+this[14]*t[7],a=this[3]*t[4]+this[7]*t[5]+this[11]*t[6]+this[15]*t[7],c=this[0]*t[8]+this[4]*t[9]+this[8]*t[10]+this[12]*t[11],f=this[1]*t[8]+this[5]*t[9]+this[9]*t[10]+this[13]*t[11],l=this[2]*t[8]+this[6]*t[9]+this[10]*t[10]+this[14]*t[11],d=this[3]*t[8]+this[7]*t[9]+this[11]*t[10]+this[15]*t[11],p=this[0]*t[12]+this[4]*t[13]+this[8]*t[14]+this[12]*t[15],y=this[1]*t[12]+this[5]*t[13]+this[9]*t[14]+this[13]*t[15],v=this[2]*t[12]+this[6]*t[13]+this[10]*t[14]+this[14]*t[15],M=this[3]*t[12]+this[7]*t[13]+this[11]*t[14]+this[15]*t[15];return i[0]=s,i[1]=h,i[2]=n,i[3]=r,i[4]=e,i[5]=u,i[6]=o,i[7]=a,i[8]=c,i[9]=f,i[10]=l,i[11]=d,i[12]=p,i[13]=y,i[14]=v,i[15]=M,i},transpose:function(t){t=t||this;var i=this[0],s=this[4],h=this[8],n=this[12],r=this[1],e=this[5],u=this[9],o=this[13],a=this[2],c=this[6],f=this[10],l=this[14],d=this[3],p=this[7],y=this[11],v=this[15];return t[0]=i,t[1]=s,t[2]=h,t[3]=n,t[4]=r,t[5]=e,t[6]=u,t[7]=o,t[8]=a,t[9]=c,t[10]=f,t[11]=l,t[12]=d,t[13]=p,t[14]=y,t[15]=v,t},invert:function(t){t=t||this;var i=this[0]*this[5]-this[1]*this[4],s=this[0]*this[6]-this[2]*this[4],h=this[0]*this[7]-this[3]*this[4],n=this[1]*this[6]-this[2]*this[5],r=this[1]*this[7]-this[3]*this[5],e=this[2]*this[7]-this[3]*this[6],u=this[8]*this[13]-this[9]*this[12],o=this[8]*this[14]-this[10]*this[12],a=this[8]*this[15]-this[11]*this[12],c=this[9]*this[14]-this[10]*this[13],f=this[9]*this[15]-this[11]*this[13],l=this[10]*this[15]-this[11]*this[14],d=i*l-s*f+h*c+n*a-r*o+e*u;d=1/d;var p=(this[5]*l-this[6]*f+this[7]*c)*d,y=(-this[1]*l+this[2]*f-this[3]*c)*d,v=(this[13]*e-this[14]*r+this[15]*n)*d,M=(-this[9]*e+this[10]*r-this[11]*n)*d,m=(-this[4]*l+this[6]*a-this[7]*o)*d,X=(this[0]*l-this[2]*a+this[3]*o)*d,Y=(-this[12]*e+this[14]*h-this[15]*s)*d,Z=(this[8]*e-this[10]*h+this[11]*s)*d,S=(this[4]*f-this[5]*a+this[7]*u)*d,g=(-this[0]*f+this[1]*a-this[3]*u)*d,I=(this[12]*r-this[13]*h+this[15]*i)*d,V=(-this[8]*r+this[9]*h-this[11]*i)*d,x=(-this[4]*c+this[5]*o-this[6]*u)*d,D=(this[0]*c-this[1]*o+this[2]*u)*d,F=(-this[12]*n+this[13]*s-this[14]*i)*d,q=(this[8]*n-this[9]*s+this[10]*i)*d;return t[0]=p,t[1]=y,t[2]=v,t[3]=M,t[4]=m,t[5]=X,t[6]=Y,t[7]=Z,t[8]=S,t[9]=g,t[10]=I,t[11]=V,t[12]=x,t[13]=D,t[14]=F,t[15]=q,t},applyTranslationVec3:function(t,i){return i=i||this,i[12]=this[0]*t[0]+this[4]*t[1]+this[8]*t[2]+this[12],i[13]=this[1]*t[0]+this[5]*t[1]+this[9]*t[2]+this[13],i[14]=this[2]*t[0]+this[6]*t[1]+this[10]*t[2]+this[14],i[15]=this[3]*t[0]+this[7]*t[1]+this[11]*t[2]+this[15],i},applyTranslationXYZ:function(t,i,s,h){return h=h||this,h[12]=this[0]*t+this[4]*i+this[8]*s+this[12],h[13]=this[1]*t+this[5]*i+this[9]*s+this[13],h[14]=this[2]*t+this[6]*i+this[10]*s+this[14],h[15]=this[3]*t+this[7]*i+this[11]*s+this[15],h},setTranslationVec3:function(t){return this.identity(),this[12]=t[0],this[13]=t[1],this[14]=t[2],this},setTranslationXYZ:function(t,i,s){return this.identity(),this[12]=t,this[13]=i,this[14]=s,this},applyRotationQuat:function(t,i){i=i||this;var s=t[3]*t[3],h=t[0]*t[0],n=t[1]*t[1],r=t[2]*t[2],e=t[2]*t[3],u=t[0]*t[1],o=t[0]*t[2],a=t[1]*t[3],c=t[1]*t[2],f=t[0]*t[3],l=s+h-r-n,d=u+e+e+u,p=o-a+o-a,y=-e+u-e+u,v=n-r+s-h,M=c+c+f+f,m=a+o+o+a,X=c+c-f-f,Y=r-n-h+s,Z=this[0]*l+this[4]*d+this[8]*p,S=this[1]*l+this[5]*d+this[9]*p,g=this[2]*l+this[6]*d+this[10]*p,I=this[3]*l+this[7]*d+this[11]*p,V=this[0]*y+this[4]*v+this[8]*M,x=this[1]*y+this[5]*v+this[9]*M,D=this[2]*y+this[6]*v+this[10]*M,F=this[3]*y+this[7]*v+this[11]*M;return i[8]=this[0]*m+this[4]*X+this[8]*Y,i[9]=this[1]*m+this[5]*X+this[9]*Y,i[10]=this[2]*m+this[6]*X+this[10]*Y,i[11]=this[3]*m+this[7]*X+this[11]*Y,i[0]=Z,i[1]=S,i[2]=g,i[3]=I,i[4]=V,i[5]=x,i[6]=D,i[7]=F,i[12]=this[12],i[13]=this[13],i[14]=this[14],i[15]=this[15],i},setRotationQuat:function(t){var i=t[3]*t[3],s=t[0]*t[0],h=t[1]*t[1],n=t[2]*t[2],r=t[2]*t[3],e=t[0]*t[1],u=t[0]*t[2],o=t[1]*t[3],a=t[1]*t[2],c=t[0]*t[3];return this[0]=i+s-n-h,this[1]=e+r+r+e,this[2]=u-o+u-o,this[3]=0,this[4]=-r+e-r+e,this[5]=h-n+i-s,this[6]=a+a+c+c,this[7]=0,this[8]=o+u+u+o,this[9]=a+a-c-c,this[10]=n-h-s+i,this[11]=0,this[12]=0,this[13]=0,this[14]=0,this[15]=1,this},applyRotationX:function(t,i){i=i||this;var s,h;s=Math.sin(t),h=Math.cos(t);var n=h,r=s,e=-s,u=h,o=this[4]*n+this[8]*r,a=this[5]*n+this[9]*r,c=this[6]*n+this[10]*r,f=this[7]*n+this[11]*r;return i[8]=this[4]*e+this[8]*u,i[9]=this[5]*e+this[9]*u,i[10]=this[6]*e+this[10]*u,i[11]=this[7]*e+this[11]*u,i[4]=o,i[5]=a,i[6]=c,i[7]=f,i[0]=this[0],i[1]=this[1],i[2]=this[2],i[3]=this[3],i[12]=this[12],i[13]=this[13],i[14]=this[14],i[15]=this[15],i},applyRotationY:function(t,i){i=i||this;var s,h;h=Math.sin(t),s=Math.cos(t);var n=s,r=-h,e=h,u=s,o=this[0]*n+this[8]*r,a=this[1]*n+this[9]*r,c=this[2]*n+this[10]*r,f=this[3]*n+this[11]*r;return i[8]=this[0]*e+this[8]*u,i[9]=this[1]*e+this[9]*u,i[10]=this[2]*e+this[10]*u,i[11]=this[3]*e+this[11]*u,i[0]=o,i[1]=a,i[2]=c,i[3]=f,i[4]=this[4],i[5]=this[5],i[6]=this[6],i[7]=this[7],i[12]=this[12],i[13]=this[13],i[14]=this[14],i[15]=this[15],i},applyTranslationLocalXYZ:function(t,i,s,h){h=h||this;var n=this[0]+t*this[3],r=this[1]+i*this[3],e=this[2]+s*this[3],u=this[3],o=this[4]+t*this[7],a=this[5]+i*this[7],c=this[6]+s*this[7],f=this[7],l=this[8]+t*this[11],d=this[9]+i*this[11],p=this[10]+s*this[11],y=this[11],v=this[12]+t*this[15],M=this[13]+i*this[15],m=this[14]+s*this[15],X=this[15];return h[0]=n,h[1]=r,h[2]=e,h[3]=u,h[4]=o,h[5]=a,h[6]=c,h[7]=f,h[8]=l,h[9]=d,h[10]=p,h[11]=y,h[12]=v,h[13]=M,h[14]=m,h[15]=X,h},applyScaleVec3:function(t,i){return this.applyScaleXYZ(t[0],t[1],t[2],i)},applyScaleXYZ:function(t,i,s,h){return h=h||this,h[0]=this[0]*t,h[1]=this[1]*t,h[2]=this[2]*t,h[3]=this[3]*t,h[4]=this[4]*i,h[5]=this[5]*i,h[6]=this[6]*i,h[7]=this[7]*i,h[8]=this[8]*s,h[9]=this[9]*s,h[10]=this[10]*s,h[11]=this[11]*s,h[12]=this[12],h[13]=this[13],h[14]=this[14],h[15]=this[15],h},applyScaleScalar:function(t,i){return this.applyScaleXYZ(t,t,t,i)},setScaleVec3:function(t){return this.setScaleXYZ(t[0],t[1],t[2])},setScaleXYZ:function(t,i,s){return this.identity(),this[0]=t,this[5]=i,this[10]=s,this},setScaleScalar:function(t){return this.setScaleXYZ(t,t,t)},applyPerspective:function(t,i,s,h,n){n=n||this;var r,e,u=Math.tan(.5*t),o=1/(u*i),a=1/u,c=!1;r=(c?h:h+s)/(s-h),e=(c?h:h+h)*s/(s-h);var f=this[8]*r-this[12],l=this[9]*r-this[13],d=this[10]*r-this[14],p=this[11]*r-this[15];return n[0]=this[0]*o,n[1]=this[1]*o,n[2]=this[2]*o,n[3]=this[3]*o,n[4]=this[4]*a,n[5]=this[5]*a,n[6]=this[6]*a,n[7]=this[7]*a,n[12]=this[8]*e,n[13]=this[9]*e,n[14]=this[10]*e,n[15]=this[11]*e,n[8]=f,n[9]=l,n[10]=d,n[11]=p,n},setPerspective:function(t,i,s,h){return this.identity(),this.applyPerspective(t,i,s,h,this),this},applyOrtho:function(t,i,s,h,n,r,e){e=e||this;var u=2/(i-t),o=2/(h-s),a=2/(n-r),c=(t+i)/(t-i),f=(h+s)/(s-h),l=(r+n)/(n-r);return e[12]=this[0]*c+this[4]*f+this[8]*l+this[12],e[13]=this[1]*c+this[5]*f+this[9]*l+this[13],e[14]=this[2]*c+this[6]*f+this[10]*l+this[14],e[15]=this[3]*c+this[7]*f+this[11]*l+this[15],e[0]=this[0]*u,e[1]=this[1]*u,e[2]=this[2]*u,e[3]=this[3]*u,e[4]=this[4]*o,e[5]=this[5]*o,e[6]=this[6]*o,e[7]=this[7]*o,e[8]=this[8]*a,e[9]=this[9]*a,e[10]=this[10]*a,e[11]=this[11]*a,e},setOrtho:function(t,i,s,h,n,r){return this.identity(),this.applyOrtho(t,i,s,h,n,r,this),this}},weml.selectTypeprototype(Mat4)}();