From 9effd4bfe36d044456adb20d5a8ae9cd988ffc29 Mon Sep 17 00:00:00 2001 From: pissang Date: Wed, 15 Nov 2017 17:29:36 +0800 Subject: [PATCH] [editor] Fix electron url open problem --- editor/bundle.js | 4 ++-- editor/src/browser/open.js | 3 +++ editor/src/electron/open.js | 5 +++++ editor/src/main.js | 7 ++++++- 4 files changed, 16 insertions(+), 3 deletions(-) create mode 100644 editor/src/browser/open.js create mode 100644 editor/src/electron/open.js diff --git a/editor/bundle.js b/editor/bundle.js index e5e41d5..79c3cb0 100644 --- a/editor/bundle.js +++ b/editor/bundle.js @@ -1,4 +1,4 @@ -!function(e){function t(a){if(n[a])return n[a].exports;var i=n[a]={i:a,l:!1,exports:{}};return e[a].call(i.exports,i,i.exports,t),i.l=!0,i.exports}var n={};t.m=e,t.c=n,t.d=function(e,n,a){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:a})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=65)}([function(e,t,n){!function(e){"use strict";var n={};n.exports=t,function(e){if(!t)var t=1e-6;if(!n)var n="undefined"!=typeof Float32Array?Float32Array:Array;if(!a)var a=Math.random;var i={};i.setMatrixArrayType=function(e){n=e},void 0!==e&&(e.glMatrix=i);var r=Math.PI/180;i.toRadian=function(e){return e*r};var o={};o.create=function(){var e=new n(2);return e[0]=0,e[1]=0,e},o.clone=function(e){var t=new n(2);return t[0]=e[0],t[1]=e[1],t},o.fromValues=function(e,t){var a=new n(2);return a[0]=e,a[1]=t,a},o.copy=function(e,t){return e[0]=t[0],e[1]=t[1],e},o.set=function(e,t,n){return e[0]=t,e[1]=n,e},o.add=function(e,t,n){return e[0]=t[0]+n[0],e[1]=t[1]+n[1],e},o.subtract=function(e,t,n){return e[0]=t[0]-n[0],e[1]=t[1]-n[1],e},o.sub=o.subtract,o.multiply=function(e,t,n){return e[0]=t[0]*n[0],e[1]=t[1]*n[1],e},o.mul=o.multiply,o.divide=function(e,t,n){return e[0]=t[0]/n[0],e[1]=t[1]/n[1],e},o.div=o.divide,o.min=function(e,t,n){return e[0]=Math.min(t[0],n[0]),e[1]=Math.min(t[1],n[1]),e},o.max=function(e,t,n){return e[0]=Math.max(t[0],n[0]),e[1]=Math.max(t[1],n[1]),e},o.scale=function(e,t,n){return e[0]=t[0]*n,e[1]=t[1]*n,e},o.scaleAndAdd=function(e,t,n,a){return e[0]=t[0]+n[0]*a,e[1]=t[1]+n[1]*a,e},o.distance=function(e,t){var n=t[0]-e[0],a=t[1]-e[1];return Math.sqrt(n*n+a*a)},o.dist=o.distance,o.squaredDistance=function(e,t){var n=t[0]-e[0],a=t[1]-e[1];return n*n+a*a},o.sqrDist=o.squaredDistance,o.length=function(e){var t=e[0],n=e[1];return Math.sqrt(t*t+n*n)},o.len=o.length,o.squaredLength=function(e){var t=e[0],n=e[1];return t*t+n*n},o.sqrLen=o.squaredLength,o.negate=function(e,t){return e[0]=-t[0],e[1]=-t[1],e},o.inverse=function(e,t){return e[0]=1/t[0],e[1]=1/t[1],e},o.normalize=function(e,t){var n=t[0],a=t[1],i=n*n+a*a;return i>0&&(i=1/Math.sqrt(i),e[0]=t[0]*i,e[1]=t[1]*i),e},o.dot=function(e,t){return e[0]*t[0]+e[1]*t[1]},o.cross=function(e,t,n){var a=t[0]*n[1]-t[1]*n[0];return e[0]=e[1]=0,e[2]=a,e},o.lerp=function(e,t,n,a){var i=t[0],r=t[1];return e[0]=i+a*(n[0]-i),e[1]=r+a*(n[1]-r),e},o.random=function(e,t){t=t||1;var n=2*a()*Math.PI;return e[0]=Math.cos(n)*t,e[1]=Math.sin(n)*t,e},o.transformMat2=function(e,t,n){var a=t[0],i=t[1];return e[0]=n[0]*a+n[2]*i,e[1]=n[1]*a+n[3]*i,e},o.transformMat2d=function(e,t,n){var a=t[0],i=t[1];return e[0]=n[0]*a+n[2]*i+n[4],e[1]=n[1]*a+n[3]*i+n[5],e},o.transformMat3=function(e,t,n){var a=t[0],i=t[1];return e[0]=n[0]*a+n[3]*i+n[6],e[1]=n[1]*a+n[4]*i+n[7],e},o.transformMat4=function(e,t,n){var a=t[0],i=t[1];return e[0]=n[0]*a+n[4]*i+n[12],e[1]=n[1]*a+n[5]*i+n[13],e},o.forEach=function(){var e=o.create();return function(t,n,a,i,r,o){var s,c;for(n||(n=2),a||(a=0),c=i?Math.min(i*n+a,t.length):t.length,s=a;s0&&(r=1/Math.sqrt(r),e[0]=t[0]*r,e[1]=t[1]*r,e[2]=t[2]*r),e},s.dot=function(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]},s.cross=function(e,t,n){var a=t[0],i=t[1],r=t[2],o=n[0],s=n[1],c=n[2];return e[0]=i*c-r*s,e[1]=r*o-a*c,e[2]=a*s-i*o,e},s.lerp=function(e,t,n,a){var i=t[0],r=t[1],o=t[2];return e[0]=i+a*(n[0]-i),e[1]=r+a*(n[1]-r),e[2]=o+a*(n[2]-o),e},s.random=function(e,t){t=t||1;var n=2*a()*Math.PI,i=2*a()-1,r=Math.sqrt(1-i*i)*t;return e[0]=Math.cos(n)*r,e[1]=Math.sin(n)*r,e[2]=i*t,e},s.transformMat4=function(e,t,n){var a=t[0],i=t[1],r=t[2],o=n[3]*a+n[7]*i+n[11]*r+n[15];return o=o||1,e[0]=(n[0]*a+n[4]*i+n[8]*r+n[12])/o,e[1]=(n[1]*a+n[5]*i+n[9]*r+n[13])/o,e[2]=(n[2]*a+n[6]*i+n[10]*r+n[14])/o,e},s.transformMat3=function(e,t,n){var a=t[0],i=t[1],r=t[2];return e[0]=a*n[0]+i*n[3]+r*n[6],e[1]=a*n[1]+i*n[4]+r*n[7],e[2]=a*n[2]+i*n[5]+r*n[8],e},s.transformQuat=function(e,t,n){var a=t[0],i=t[1],r=t[2],o=n[0],s=n[1],c=n[2],l=n[3],u=l*a+s*r-c*i,p=l*i+c*a-o*r,d=l*r+o*i-s*a,f=-o*a-s*i-c*r;return e[0]=u*l+f*-o+p*-c-d*-s,e[1]=p*l+f*-s+d*-o-u*-c,e[2]=d*l+f*-c+u*-s-p*-o,e},s.rotateX=function(e,t,n,a){var i=[],r=[];return i[0]=t[0]-n[0],i[1]=t[1]-n[1],i[2]=t[2]-n[2],r[0]=i[0],r[1]=i[1]*Math.cos(a)-i[2]*Math.sin(a),r[2]=i[1]*Math.sin(a)+i[2]*Math.cos(a),e[0]=r[0]+n[0],e[1]=r[1]+n[1],e[2]=r[2]+n[2],e},s.rotateY=function(e,t,n,a){var i=[],r=[];return i[0]=t[0]-n[0],i[1]=t[1]-n[1],i[2]=t[2]-n[2],r[0]=i[2]*Math.sin(a)+i[0]*Math.cos(a),r[1]=i[1],r[2]=i[2]*Math.cos(a)-i[0]*Math.sin(a),e[0]=r[0]+n[0],e[1]=r[1]+n[1],e[2]=r[2]+n[2],e},s.rotateZ=function(e,t,n,a){var i=[],r=[];return i[0]=t[0]-n[0],i[1]=t[1]-n[1],i[2]=t[2]-n[2],r[0]=i[0]*Math.cos(a)-i[1]*Math.sin(a),r[1]=i[0]*Math.sin(a)+i[1]*Math.cos(a),r[2]=i[2],e[0]=r[0]+n[0],e[1]=r[1]+n[1],e[2]=r[2]+n[2],e},s.forEach=function(){var e=s.create();return function(t,n,a,i,r,o){var s,c;for(n||(n=3),a||(a=0),c=i?Math.min(i*n+a,t.length):t.length,s=a;s1?0:Math.acos(i)},s.str=function(e){return"vec3("+e[0]+", "+e[1]+", "+e[2]+")"},void 0!==e&&(e.vec3=s);var c={};c.create=function(){var e=new n(4);return e[0]=0,e[1]=0,e[2]=0,e[3]=0,e},c.clone=function(e){var t=new n(4);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t},c.fromValues=function(e,t,a,i){var r=new n(4);return r[0]=e,r[1]=t,r[2]=a,r[3]=i,r},c.copy=function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e},c.set=function(e,t,n,a,i){return e[0]=t,e[1]=n,e[2]=a,e[3]=i,e},c.add=function(e,t,n){return e[0]=t[0]+n[0],e[1]=t[1]+n[1],e[2]=t[2]+n[2],e[3]=t[3]+n[3],e},c.subtract=function(e,t,n){return e[0]=t[0]-n[0],e[1]=t[1]-n[1],e[2]=t[2]-n[2],e[3]=t[3]-n[3],e},c.sub=c.subtract,c.multiply=function(e,t,n){return e[0]=t[0]*n[0],e[1]=t[1]*n[1],e[2]=t[2]*n[2],e[3]=t[3]*n[3],e},c.mul=c.multiply,c.divide=function(e,t,n){return e[0]=t[0]/n[0],e[1]=t[1]/n[1],e[2]=t[2]/n[2],e[3]=t[3]/n[3],e},c.div=c.divide,c.min=function(e,t,n){return e[0]=Math.min(t[0],n[0]),e[1]=Math.min(t[1],n[1]),e[2]=Math.min(t[2],n[2]),e[3]=Math.min(t[3],n[3]),e},c.max=function(e,t,n){return e[0]=Math.max(t[0],n[0]),e[1]=Math.max(t[1],n[1]),e[2]=Math.max(t[2],n[2]),e[3]=Math.max(t[3],n[3]),e},c.scale=function(e,t,n){return e[0]=t[0]*n,e[1]=t[1]*n,e[2]=t[2]*n,e[3]=t[3]*n,e},c.scaleAndAdd=function(e,t,n,a){return e[0]=t[0]+n[0]*a,e[1]=t[1]+n[1]*a,e[2]=t[2]+n[2]*a,e[3]=t[3]+n[3]*a,e},c.distance=function(e,t){var n=t[0]-e[0],a=t[1]-e[1],i=t[2]-e[2],r=t[3]-e[3];return Math.sqrt(n*n+a*a+i*i+r*r)},c.dist=c.distance,c.squaredDistance=function(e,t){var n=t[0]-e[0],a=t[1]-e[1],i=t[2]-e[2],r=t[3]-e[3];return n*n+a*a+i*i+r*r},c.sqrDist=c.squaredDistance,c.length=function(e){var t=e[0],n=e[1],a=e[2],i=e[3];return Math.sqrt(t*t+n*n+a*a+i*i)},c.len=c.length,c.squaredLength=function(e){var t=e[0],n=e[1],a=e[2],i=e[3];return t*t+n*n+a*a+i*i},c.sqrLen=c.squaredLength,c.negate=function(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e[3]=-t[3],e},c.inverse=function(e,t){return e[0]=1/t[0],e[1]=1/t[1],e[2]=1/t[2],e[3]=1/t[3],e},c.normalize=function(e,t){var n=t[0],a=t[1],i=t[2],r=t[3],o=n*n+a*a+i*i+r*r;return o>0&&(o=1/Math.sqrt(o),e[0]=t[0]*o,e[1]=t[1]*o,e[2]=t[2]*o,e[3]=t[3]*o),e},c.dot=function(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+e[3]*t[3]},c.lerp=function(e,t,n,a){var i=t[0],r=t[1],o=t[2],s=t[3];return e[0]=i+a*(n[0]-i),e[1]=r+a*(n[1]-r),e[2]=o+a*(n[2]-o),e[3]=s+a*(n[3]-s),e},c.random=function(e,t){return t=t||1,e[0]=a(),e[1]=a(),e[2]=a(),e[3]=a(),c.normalize(e,e),c.scale(e,e,t),e},c.transformMat4=function(e,t,n){var a=t[0],i=t[1],r=t[2],o=t[3];return e[0]=n[0]*a+n[4]*i+n[8]*r+n[12]*o,e[1]=n[1]*a+n[5]*i+n[9]*r+n[13]*o,e[2]=n[2]*a+n[6]*i+n[10]*r+n[14]*o,e[3]=n[3]*a+n[7]*i+n[11]*r+n[15]*o,e},c.transformQuat=function(e,t,n){var a=t[0],i=t[1],r=t[2],o=n[0],s=n[1],c=n[2],l=n[3],u=l*a+s*r-c*i,p=l*i+c*a-o*r,d=l*r+o*i-s*a,f=-o*a-s*i-c*r;return e[0]=u*l+f*-o+p*-c-d*-s,e[1]=p*l+f*-s+d*-o-u*-c,e[2]=d*l+f*-c+u*-s-p*-o,e},c.forEach=function(){var e=c.create();return function(t,n,a,i,r,o){var s,c;for(n||(n=4),a||(a=0),c=i?Math.min(i*n+a,t.length):t.length,s=a;s.999999?(a[0]=0,a[1]=0,a[2]=0,a[3]=1,a):(s.cross(e,i,r),a[0]=e[0],a[1]=e[1],a[2]=e[2],a[3]=1+o,f.normalize(a,a))}}(),f.setAxes=function(){var e=p.create();return function(t,n,a,i){return e[0]=a[0],e[3]=a[1],e[6]=a[2],e[1]=i[0],e[4]=i[1],e[7]=i[2],e[2]=-n[0],e[5]=-n[1],e[8]=-n[2],f.normalize(t,f.fromMat3(t,e))}}(),f.clone=c.clone,f.fromValues=c.fromValues,f.copy=c.copy,f.set=c.set,f.identity=function(e){return e[0]=0,e[1]=0,e[2]=0,e[3]=1,e},f.setAxisAngle=function(e,t,n){n*=.5;var a=Math.sin(n);return e[0]=a*t[0],e[1]=a*t[1],e[2]=a*t[2],e[3]=Math.cos(n),e},f.add=c.add,f.multiply=function(e,t,n){var a=t[0],i=t[1],r=t[2],o=t[3],s=n[0],c=n[1],l=n[2],u=n[3];return e[0]=a*u+o*s+i*l-r*c,e[1]=i*u+o*c+r*s-a*l,e[2]=r*u+o*l+a*c-i*s,e[3]=o*u-a*s-i*c-r*l,e},f.mul=f.multiply,f.scale=c.scale,f.rotateX=function(e,t,n){n*=.5;var a=t[0],i=t[1],r=t[2],o=t[3],s=Math.sin(n),c=Math.cos(n);return e[0]=a*c+o*s,e[1]=i*c+r*s,e[2]=r*c-i*s,e[3]=o*c-a*s,e},f.rotateY=function(e,t,n){n*=.5;var a=t[0],i=t[1],r=t[2],o=t[3],s=Math.sin(n),c=Math.cos(n);return e[0]=a*c-r*s,e[1]=i*c+o*s,e[2]=r*c+a*s,e[3]=o*c-i*s,e},f.rotateZ=function(e,t,n){n*=.5;var a=t[0],i=t[1],r=t[2],o=t[3],s=Math.sin(n),c=Math.cos(n);return e[0]=a*c+i*s,e[1]=i*c-a*s,e[2]=r*c+o*s,e[3]=o*c-r*s,e},f.calculateW=function(e,t){var n=t[0],a=t[1],i=t[2];return e[0]=n,e[1]=a,e[2]=i,e[3]=Math.sqrt(Math.abs(1-n*n-a*a-i*i)),e},f.dot=c.dot,f.lerp=c.lerp,f.slerp=function(e,t,n,a){var i,r,o,s,c,l=t[0],u=t[1],p=t[2],d=t[3],f=n[0],h=n[1],m=n[2],v=n[3];return r=l*f+u*h+p*m+d*v,r<0&&(r=-r,f=-f,h=-h,m=-m,v=-v),1-r>1e-6?(i=Math.acos(r),o=Math.sin(i),s=Math.sin((1-a)*i)/o,c=Math.sin(a*i)/o):(s=1-a,c=a),e[0]=s*l+c*f,e[1]=s*u+c*h,e[2]=s*p+c*m,e[3]=s*d+c*v,e},f.invert=function(e,t){var n=t[0],a=t[1],i=t[2],r=t[3],o=n*n+a*a+i*i+r*r,s=o?1/o:0;return e[0]=-n*s,e[1]=-a*s,e[2]=-i*s,e[3]=r*s,e},f.conjugate=function(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e[3]=t[3],e},f.length=c.length,f.len=f.length,f.squaredLength=c.squaredLength,f.sqrLen=f.squaredLength,f.normalize=c.normalize,f.fromMat3=function(e,t){var n,a=t[0]+t[4]+t[8];if(a>0)n=Math.sqrt(a+1),e[3]=.5*n,n=.5/n,e[0]=(t[5]-t[7])*n,e[1]=(t[6]-t[2])*n,e[2]=(t[1]-t[3])*n;else{var i=0;t[4]>t[0]&&(i=1),t[8]>t[3*i+i]&&(i=2);var r=(i+1)%3,o=(i+2)%3;n=Math.sqrt(t[3*i+i]-t[3*r+r]-t[3*o+o]+1),e[i]=.5*n,n=.5/n,e[3]=(t[3*r+o]-t[3*o+r])*n,e[r]=(t[3*r+i]+t[3*i+r])*n,e[o]=(t[3*o+i]+t[3*i+o])*n}return e},f.str=function(e){return"quat("+e[0]+", "+e[1]+", "+e[2]+", "+e[3]+")"},void 0!==e&&(e.quat=f)}(n.exports)}()},function(e,t,n){"use strict";var a=n(68),i=n(22),r=n(11),o=function(){this.__GUID__=r.a.genGUID()};o.__initializers__=[function(e){r.a.extend(this,e)}],r.a.extend(o,a.a),r.a.extend(o.prototype,i.a),t.a=o},function(e,t,n){"use strict";function a(e,t,n){return en?n:e}var i=n(0),r=n.n(i),o=r.a.vec3,s=function(e,t,n){e=e||0,t=t||0,n=n||0,this._array=o.fromValues(e,t,n),this._dirty=!0};s.prototype={constructor:s,add:function(e){return o.add(this._array,this._array,e._array),this._dirty=!0,this},set:function(e,t,n){return this._array[0]=e,this._array[1]=t,this._array[2]=n,this._dirty=!0,this},setArray:function(e){return this._array[0]=e[0],this._array[1]=e[1],this._array[2]=e[2],this._dirty=!0,this},clone:function(){return new s(this.x,this.y,this.z)},copy:function(e){return o.copy(this._array,e._array),this._dirty=!0,this},cross:function(e,t){return o.cross(this._array,e._array,t._array),this._dirty=!0,this},dist:function(e){return o.dist(this._array,e._array)},distance:function(e){return o.distance(this._array,e._array)},div:function(e){return o.div(this._array,this._array,e._array),this._dirty=!0,this},divide:function(e){return o.divide(this._array,this._array,e._array),this._dirty=!0,this},dot:function(e){return o.dot(this._array,e._array)},len:function(){return o.len(this._array)},length:function(){return o.length(this._array)},lerp:function(e,t,n){return o.lerp(this._array,e._array,t._array,n),this._dirty=!0,this},min:function(e){return o.min(this._array,this._array,e._array),this._dirty=!0,this},max:function(e){return o.max(this._array,this._array,e._array),this._dirty=!0,this},mul:function(e){return o.mul(this._array,this._array,e._array),this._dirty=!0,this},multiply:function(e){return o.multiply(this._array,this._array,e._array),this._dirty=!0,this},negate:function(){return o.negate(this._array,this._array),this._dirty=!0,this},normalize:function(){return o.normalize(this._array,this._array),this._dirty=!0,this},random:function(e){return o.random(this._array,e),this._dirty=!0,this},scale:function(e){return o.scale(this._array,this._array,e),this._dirty=!0,this},scaleAndAdd:function(e,t){return o.scaleAndAdd(this._array,this._array,e._array,t),this._dirty=!0,this},sqrDist:function(e){return o.sqrDist(this._array,e._array)},squaredDistance:function(e){return o.squaredDistance(this._array,e._array)},sqrLen:function(){return o.sqrLen(this._array)},squaredLength:function(){return o.squaredLength(this._array)},sub:function(e){return o.sub(this._array,this._array,e._array),this._dirty=!0,this},subtract:function(e){return o.subtract(this._array,this._array,e._array),this._dirty=!0,this},transformMat3:function(e){return o.transformMat3(this._array,this._array,e._array),this._dirty=!0,this},transformMat4:function(e){return o.transformMat4(this._array,this._array,e._array),this._dirty=!0,this},transformQuat:function(e){return o.transformQuat(this._array,this._array,e._array),this._dirty=!0,this},applyProjection:function(e){var t=this._array;if(e=e._array,0===e[15]){var n=-1/t[2];t[0]=e[0]*t[0]*n,t[1]=e[5]*t[1]*n,t[2]=(e[10]*t[2]+e[14])*n}else t[0]=e[0]*t[0]+e[12],t[1]=e[5]*t[1]+e[13],t[2]=e[10]*t[2]+e[14];return this._dirty=!0,this},eulerFromQuat:function(e,t){s.eulerFromQuat(this,e,t)},eulerFromMat3:function(e,t){s.eulerFromMat3(this,e,t)},toString:function(){return"["+Array.prototype.join.call(this._array,",")+"]"},toArray:function(){return Array.prototype.slice.call(this._array)}};var c=Object.defineProperty;if(c){var l=s.prototype;c(l,"x",{get:function(){return this._array[0]},set:function(e){this._array[0]=e,this._dirty=!0}}),c(l,"y",{get:function(){return this._array[1]},set:function(e){this._array[1]=e,this._dirty=!0}}),c(l,"z",{get:function(){return this._array[2]},set:function(e){this._array[2]=e,this._dirty=!0}})}s.add=function(e,t,n){return o.add(e._array,t._array,n._array),e._dirty=!0,e},s.set=function(e,t,n,a){o.set(e._array,t,n,a),e._dirty=!0},s.copy=function(e,t){return o.copy(e._array,t._array),e._dirty=!0,e},s.cross=function(e,t,n){return o.cross(e._array,t._array,n._array),e._dirty=!0,e},s.dist=function(e,t){return o.distance(e._array,t._array)},s.distance=s.dist,s.div=function(e,t,n){return o.divide(e._array,t._array,n._array),e._dirty=!0,e},s.divide=s.div,s.dot=function(e,t){return o.dot(e._array,t._array)},s.len=function(e){return o.length(e._array)},s.lerp=function(e,t,n,a){return o.lerp(e._array,t._array,n._array,a),e._dirty=!0,e},s.min=function(e,t,n){return o.min(e._array,t._array,n._array),e._dirty=!0,e},s.max=function(e,t,n){return o.max(e._array,t._array,n._array),e._dirty=!0,e},s.mul=function(e,t,n){return o.multiply(e._array,t._array,n._array),e._dirty=!0,e},s.multiply=s.mul,s.negate=function(e,t){return o.negate(e._array,t._array),e._dirty=!0,e},s.normalize=function(e,t){return o.normalize(e._array,t._array),e._dirty=!0,e},s.random=function(e,t){return o.random(e._array,t),e._dirty=!0,e},s.scale=function(e,t,n){return o.scale(e._array,t._array,n),e._dirty=!0,e},s.scaleAndAdd=function(e,t,n,a){return o.scaleAndAdd(e._array,t._array,n._array,a),e._dirty=!0,e},s.sqrDist=function(e,t){return o.sqrDist(e._array,t._array)},s.squaredDistance=s.sqrDist,s.sqrLen=function(e){return o.sqrLen(e._array)},s.squaredLength=s.sqrLen,s.sub=function(e,t,n){return o.subtract(e._array,t._array,n._array),e._dirty=!0,e},s.subtract=s.sub,s.transformMat3=function(e,t,n){return o.transformMat3(e._array,t._array,n._array),e._dirty=!0,e},s.transformMat4=function(e,t,n){return o.transformMat4(e._array,t._array,n._array),e._dirty=!0,e},s.transformQuat=function(e,t,n){return o.transformQuat(e._array,t._array,n._array),e._dirty=!0,e};var u=Math.atan2,p=Math.asin,d=Math.abs;s.eulerFromQuat=function(e,t,n){e._dirty=!0,t=t._array;var i=e._array,r=t[0],o=t[1],s=t[2],c=t[3],l=r*r,d=o*o,f=s*s,h=c*c,n=(n||"XYZ").toUpperCase();switch(n){case"XYZ":i[0]=u(2*(r*c-o*s),h-l-d+f),i[1]=p(a(2*(r*s+o*c),-1,1)),i[2]=u(2*(s*c-r*o),h+l-d-f);break;case"YXZ":i[0]=p(a(2*(r*c-o*s),-1,1)),i[1]=u(2*(r*s+o*c),h-l-d+f),i[2]=u(2*(r*o+s*c),h-l+d-f);break;case"ZXY":i[0]=p(a(2*(r*c+o*s),-1,1)),i[1]=u(2*(o*c-s*r),h-l-d+f),i[2]=u(2*(s*c-r*o),h-l+d-f);break;case"ZYX":i[0]=u(2*(r*c+s*o),h-l-d+f),i[1]=p(a(2*(o*c-r*s),-1,1)),i[2]=u(2*(r*o+s*c),h+l-d-f);break;case"YZX":i[0]=u(2*(r*c-s*o),h-l+d-f),i[1]=u(2*(o*c-r*s),h+l-d-f),i[2]=p(a(2*(r*o+s*c),-1,1));break;case"XZY":i[0]=u(2*(r*c+o*s),h-l+d-f),i[1]=u(2*(r*s+o*c),h+l-d-f),i[2]=p(a(2*(s*c-r*o),-1,1));break;default:console.warn("Unkown order: "+n)}return e},s.eulerFromMat3=function(e,t,n){var i=t._array,r=i[0],o=i[3],s=i[6],c=i[1],l=i[4],f=i[7],h=i[2],m=i[5],v=i[8],_=e._array,n=(n||"XYZ").toUpperCase();switch(n){case"XYZ":_[1]=p(a(s,-1,1)),d(s)<.99999?(_[0]=u(-f,v),_[2]=u(-o,r)):(_[0]=u(m,l),_[2]=0);break;case"YXZ":_[0]=p(-a(f,-1,1)),d(f)<.99999?(_[1]=u(s,v),_[2]=u(c,l)):(_[1]=u(-h,r),_[2]=0);break;case"ZXY":_[0]=p(a(m,-1,1)),d(m)<.99999?(_[1]=u(-h,v),_[2]=u(-o,l)):(_[1]=0,_[2]=u(c,r));break;case"ZYX":_[1]=p(-a(h,-1,1)),d(h)<.99999?(_[0]=u(m,v),_[2]=u(c,r)):(_[0]=0,_[2]=u(-o,l));break;case"YZX":_[2]=p(a(c,-1,1)),d(c)<.99999?(_[0]=u(-f,l),_[1]=u(-h,r)):(_[0]=0,_[1]=u(s,v));break;case"XZY":_[2]=p(-a(o,-1,1)),d(o)<.99999?(_[0]=u(m,l),_[1]=u(s,r)):(_[0]=u(-f,v),_[1]=0);break;default:console.warn("Unkown order: "+n)}return e._dirty=!0,e},s.POSITIVE_X=new s(1,0,0),s.NEGATIVE_X=new s(-1,0,0),s.POSITIVE_Y=new s(0,1,0),s.NEGATIVE_Y=new s(0,-1,0),s.POSITIVE_Z=new s(0,0,1),s.NEGATIVE_Z=new s(0,0,-1),s.UP=new s(0,1,0),s.ZERO=new s(0,0,0),t.a=s},function(e,t,n){"use strict";var a=n(1),i=n(6),r=n(23),o=a.a.extend({width:512,height:512,type:i.a.UNSIGNED_BYTE,format:i.a.RGBA,wrapS:i.a.REPEAT,wrapT:i.a.REPEAT,minFilter:i.a.LINEAR_MIPMAP_LINEAR,magFilter:i.a.LINEAR,useMipmap:!0,anisotropic:1,flipY:!0,unpackAlignment:4,premultiplyAlpha:!1,dynamic:!1,NPOT:!1},function(){this._cache=new r.a},{getWebGLTexture:function(e){var t=e.gl,n=this._cache;return n.use(e.__GUID__),n.miss("webgl_texture")&&n.put("webgl_texture",t.createTexture()),this.dynamic?this.update(e):n.isDirty()&&(this.update(e),n.fresh()),n.get("webgl_texture")},bind:function(){},unbind:function(){},dirty:function(){this._cache&&this._cache.dirtyAll()},update:function(e){},updateCommon:function(e){var t=e.gl;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,this.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,this.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,this.unpackAlignment),this.format===i.a.DEPTH_COMPONENT&&(this.useMipmap=!1);var n=e.getGLExtension("EXT_sRGB");this.format!==o.SRGB||n||(this.format=o.RGB),this.format!==o.SRGB_ALPHA||n||(this.format=o.RGBA),this.NPOT=!this.isPowerOfTwo()},getAvailableWrapS:function(){return this.NPOT?i.a.CLAMP_TO_EDGE:this.wrapS},getAvailableWrapT:function(){return this.NPOT?i.a.CLAMP_TO_EDGE:this.wrapT},getAvailableMinFilter:function(){var e=this.minFilter;return this.NPOT||!this.useMipmap?e==i.a.NEAREST_MIPMAP_NEAREST||e==i.a.NEAREST_MIPMAP_LINEAR?i.a.NEAREST:e==i.a.LINEAR_MIPMAP_LINEAR||e==i.a.LINEAR_MIPMAP_NEAREST?i.a.LINEAR:e:e},getAvailableMagFilter:function(){return this.magFilter},nextHighestPowerOfTwo:function(e){--e;for(var t=1;t<32;t<<=1)e|=e>>t;return e+1},dispose:function(e){var t=this._cache;t.use(e.__GUID__);var n=t.get("webgl_texture");n&&e.gl.deleteTexture(n),t.deleteContext(e.__GUID__)},isRenderable:function(){},isPowerOfTwo:function(){}});Object.defineProperty(o.prototype,"width",{get:function(){return this._width},set:function(e){this._width=e}}),Object.defineProperty(o.prototype,"height",{get:function(){return this._height},set:function(e){this._height=e}}),o.BYTE=i.a.BYTE,o.UNSIGNED_BYTE=i.a.UNSIGNED_BYTE,o.SHORT=i.a.SHORT,o.UNSIGNED_SHORT=i.a.UNSIGNED_SHORT,o.INT=i.a.INT,o.UNSIGNED_INT=i.a.UNSIGNED_INT,o.FLOAT=i.a.FLOAT,o.HALF_FLOAT=36193,o.UNSIGNED_INT_24_8_WEBGL=34042,o.DEPTH_COMPONENT=i.a.DEPTH_COMPONENT,o.DEPTH_STENCIL=i.a.DEPTH_STENCIL,o.ALPHA=i.a.ALPHA,o.RGB=i.a.RGB,o.RGBA=i.a.RGBA,o.LUMINANCE=i.a.LUMINANCE,o.LUMINANCE_ALPHA=i.a.LUMINANCE_ALPHA,o.SRGB=35904,o.SRGB_ALPHA=35906,o.COMPRESSED_RGB_S3TC_DXT1_EXT=33776,o.COMPRESSED_RGBA_S3TC_DXT1_EXT=33777,o.COMPRESSED_RGBA_S3TC_DXT3_EXT=33778,o.COMPRESSED_RGBA_S3TC_DXT5_EXT=33779,o.NEAREST=i.a.NEAREST,o.LINEAR=i.a.LINEAR,o.NEAREST_MIPMAP_NEAREST=i.a.NEAREST_MIPMAP_NEAREST,o.LINEAR_MIPMAP_NEAREST=i.a.LINEAR_MIPMAP_NEAREST,o.NEAREST_MIPMAP_LINEAR=i.a.NEAREST_MIPMAP_LINEAR,o.LINEAR_MIPMAP_LINEAR=i.a.LINEAR_MIPMAP_LINEAR,o.REPEAT=i.a.REPEAT,o.CLAMP_TO_EDGE=i.a.CLAMP_TO_EDGE,o.MIRRORED_REPEAT=i.a.MIRRORED_REPEAT,t.a=o},function(e,t,n){"use strict";function a(){return{locations:{},attriblocations:{}}}function i(e,t,n){if(!e.getShaderParameter(t,e.COMPILE_STATUS))return[e.getShaderInfoLog(t),r(n)].join("\n")}function r(e){for(var t=e.split("\n"),n=0,a=t.length;n0&&a.push("#define "+i.toUpperCase()+"_COUNT "+r)}for(var o in n){n[o].enabled&&a.push("#define "+o.toUpperCase()+"_ENABLED")}for(var o in e){var s=e[o];null===s?a.push("#define "+o):a.push("#define "+o+" "+s.toString())}return a.join("\n")},_unrollLoop:function(e,t){function n(e,n,i,r){var o="";isNaN(n)&&(n=n in t?t[n]:a[n]),isNaN(i)&&(i=i in t?t[i]:a[i]);for(var s=parseInt(n);s=0)n.attribSemantics[c]={symbol:r,type:u},p=!1;else if(E.indexOf(c)>=0){var d=!1,f=c;c.match(/TRANSPOSE$/)&&(d=!0,f=c.slice(0,-9)),n.matrixSemantics[c]={symbol:r,type:u,isTranspose:d,semanticNoTranspose:f},p=!1}else if(T.indexOf(c)>=0)n.uniformSemantics[c]={symbol:r,type:u},p=!1;else if("unconfigurable"===c)p=!1;else{if(!(l=n._parseDefaultValue(i,c)))throw new Error('Unkown semantic "'+c+'"');c=""}p&&(t[r]={type:u,value:o?y.array:l||y[i],semantic:c||null})}return["uniform",i,r,o].join(" ")+";\n"}}var t={},n=this,a="vertex";this._uniformList=[],this._vertexProcessedWithoutDefine=this._vertexProcessedWithoutDefine.replace(m,e),a="fragment",this._fragmentProcessedWithoutDefine=this._fragmentProcessedWithoutDefine.replace(m,e),n.matrixSemanticKeys=Object.keys(this.matrixSemantics),this.uniformTemplates=t},_parseDefaultValue:function(e,t){var n=/\[\s*(.*)\s*\]/;{if("vec2"!==e&&"vec3"!==e&&"vec4"!==e)return"bool"===e?function(){return"true"===t.toLowerCase()}:"float"===e?function(){return parseFloat(t)}:"int"===e?function(){return parseInt(t)}:void 0;var a=n.exec(t)[1];if(a){var i=a.split(/\s*,\s*/);return function(){return new l.a.Float32Array(i)}}}},createUniforms:function(){var e={};for(var t in this.uniformTemplates){var n=this.uniformTemplates[t];e[t]={type:n.type,value:n.value()}}return e},attached:function(){this._attacheMaterialNumber++},detached:function(){this._attacheMaterialNumber--},isAttachedToAny:function(){return 0!==this._attacheMaterialNumber},_parseAttributes:function(){function e(e,a,i,r,o){if(a&&i){var s=1;switch(a){case"vec4":s=4;break;case"vec3":s=3;break;case"vec2":s=2;break;case"float":s=1}if(t[i]={type:"float",size:s,semantic:o||null},o){if(b.indexOf(o)<0)throw new Error('Unkown semantic "'+o+'"');n.attribSemantics[o]={symbol:i,type:a}}}return["attribute",a,i].join(" ")+";\n"}var t={},n=this;this._vertexProcessedWithoutDefine=this._vertexProcessedWithoutDefine.replace(v,e),this.attributeTemplates=t},_parseDefines:function(){function e(e,a,i){var r="vertex"===n?t.vertexDefines:t.fragmentDefines;return r[a]||(r[a]="false"!=i&&("true"==i||(i?isNaN(parseFloat(i))?i:parseFloat(i):null))),""}var t=this,n="vertex";this._vertexProcessedWithoutDefine=this._vertexProcessedWithoutDefine.replace(_,e),n="fragment",this._fragmentProcessedWithoutDefine=this._fragmentProcessedWithoutDefine.replace(_,e)},_buildProgram:function(e,t,n){var a=this._cache;a.get("program")&&e.deleteProgram(a.get("program"));var r=e.createProgram(),o=e.createShader(e.VERTEX_SHADER);e.shaderSource(o,t),e.compileShader(o);var s=e.createShader(e.FRAGMENT_SHADER);e.shaderSource(s,n),e.compileShader(s);var c=i(e,o,t);if(c)return c;if(c=i(e,s,n))return c;if(e.attachShader(r,o),e.attachShader(r,s),this.attribSemantics.POSITION)e.bindAttribLocation(r,0,this.attribSemantics.POSITION.symbol);else{var l=Object.keys(this.attributeTemplates);e.bindAttribLocation(r,0,l[0])}if(e.linkProgram(r),!e.getProgramParameter(r,e.LINK_STATUS))return"Could not link program\nVALIDATE_STATUS: "+e.getProgramParameter(r,e.VALIDATE_STATUS)+", gl error ["+e.getError()+"]";for(var u=0;u1&&t.texParameterf(t.TEXTURE_2D,r.TEXTURE_MAX_ANISOTROPY_EXT,this.anisotropic),36193===a){e.getGLExtension("OES_texture_half_float")||(a=i.a.FLOAT)}if(this.mipmaps.length)for(var o=this.width,s=this.height,c=0;c=a.a.COMPRESSED_RGB_S3TC_DXT1_EXT?e.compressedTexImage2D(e.TEXTURE_2D,n,o,i,r,0,t.pixels):e.texImage2D(e.TEXTURE_2D,n,o,i,r,0,o,s,t.pixels)},generateMipmap:function(e){var t=e.gl;this.useMipmap&&!this.NPOT&&(t.bindTexture(t.TEXTURE_2D,this._cache.get("webgl_texture")),t.generateMipmap(t.TEXTURE_2D))},isPowerOfTwo:function(){var e,t;return this.image?(e=this.image.width,t=this.image.height):(e=this.width,t=this.height),o(e)&&o(t)},isRenderable:function(){return this.image?"CANVAS"===this.image.nodeName||"VIDEO"===this.image.nodeName||this.image.complete:!(!this.width||!this.height)},bind:function(e){e.gl.bindTexture(e.gl.TEXTURE_2D,this.getWebGLTexture(e))},unbind:function(e){e.gl.bindTexture(e.gl.TEXTURE_2D,null)},load:function(e,t){var n=new Image;t&&(n.crossOrigin=t);var a=this;return n.onload=function(){a.dirty(),a.trigger("success",a),n.onload=null},n.onerror=function(){a.trigger("error",a),n.onerror=null},n.src=e,this.image=n,this}});Object.defineProperty(s.prototype,"width",{get:function(){return this.image?this.image.width:this._width},set:function(e){this.image?console.warn("Texture from image can't set width"):(this._width!==e&&this.dirty(),this._width=e)}}),Object.defineProperty(s.prototype,"height",{get:function(){return this.image?this.image.height:this._height},set:function(e){this.image?console.warn("Texture from image can't set height"):(this._height!==e&&this.dirty(),this._height=e)}}),t.a=s},function(e,t,n){"use strict";t.a={DEPTH_BUFFER_BIT:256,STENCIL_BUFFER_BIT:1024,COLOR_BUFFER_BIT:16384,POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,ZERO:0,ONE:1,SRC_COLOR:768,ONE_MINUS_SRC_COLOR:769,SRC_ALPHA:770,ONE_MINUS_SRC_ALPHA:771,DST_ALPHA:772,ONE_MINUS_DST_ALPHA:773,DST_COLOR:774,ONE_MINUS_DST_COLOR:775,SRC_ALPHA_SATURATE:776,FUNC_ADD:32774,BLEND_EQUATION:32777,BLEND_EQUATION_RGB:32777,BLEND_EQUATION_ALPHA:34877,FUNC_SUBTRACT:32778,FUNC_REVERSE_SUBTRACT:32779,BLEND_DST_RGB:32968,BLEND_SRC_RGB:32969,BLEND_DST_ALPHA:32970,BLEND_SRC_ALPHA:32971,CONSTANT_COLOR:32769,ONE_MINUS_CONSTANT_COLOR:32770,CONSTANT_ALPHA:32771,ONE_MINUS_CONSTANT_ALPHA:32772,BLEND_COLOR:32773,ARRAY_BUFFER:34962,ELEMENT_ARRAY_BUFFER:34963,ARRAY_BUFFER_BINDING:34964,ELEMENT_ARRAY_BUFFER_BINDING:34965,STREAM_DRAW:35040,STATIC_DRAW:35044,DYNAMIC_DRAW:35048,BUFFER_SIZE:34660,BUFFER_USAGE:34661,CURRENT_VERTEX_ATTRIB:34342,FRONT:1028,BACK:1029,FRONT_AND_BACK:1032,CULL_FACE:2884,BLEND:3042,DITHER:3024,STENCIL_TEST:2960,DEPTH_TEST:2929,SCISSOR_TEST:3089,POLYGON_OFFSET_FILL:32823,SAMPLE_ALPHA_TO_COVERAGE:32926,SAMPLE_COVERAGE:32928,NO_ERROR:0,INVALID_ENUM:1280,INVALID_VALUE:1281,INVALID_OPERATION:1282,OUT_OF_MEMORY:1285,CW:2304,CCW:2305,LINE_WIDTH:2849,ALIASED_POINT_SIZE_RANGE:33901,ALIASED_LINE_WIDTH_RANGE:33902,CULL_FACE_MODE:2885,FRONT_FACE:2886,DEPTH_RANGE:2928,DEPTH_WRITEMASK:2930,DEPTH_CLEAR_VALUE:2931,DEPTH_FUNC:2932,STENCIL_CLEAR_VALUE:2961,STENCIL_FUNC:2962,STENCIL_FAIL:2964,STENCIL_PASS_DEPTH_FAIL:2965,STENCIL_PASS_DEPTH_PASS:2966,STENCIL_REF:2967,STENCIL_VALUE_MASK:2963,STENCIL_WRITEMASK:2968,STENCIL_BACK_FUNC:34816,STENCIL_BACK_FAIL:34817,STENCIL_BACK_PASS_DEPTH_FAIL:34818,STENCIL_BACK_PASS_DEPTH_PASS:34819,STENCIL_BACK_REF:36003,STENCIL_BACK_VALUE_MASK:36004,STENCIL_BACK_WRITEMASK:36005,VIEWPORT:2978,SCISSOR_BOX:3088,COLOR_CLEAR_VALUE:3106,COLOR_WRITEMASK:3107,UNPACK_ALIGNMENT:3317,PACK_ALIGNMENT:3333,MAX_TEXTURE_SIZE:3379,MAX_VIEWPORT_DIMS:3386,SUBPIXEL_BITS:3408,RED_BITS:3410,GREEN_BITS:3411,BLUE_BITS:3412,ALPHA_BITS:3413,DEPTH_BITS:3414,STENCIL_BITS:3415,POLYGON_OFFSET_UNITS:10752,POLYGON_OFFSET_FACTOR:32824,TEXTURE_BINDING_2D:32873,SAMPLE_BUFFERS:32936,SAMPLES:32937,SAMPLE_COVERAGE_VALUE:32938,SAMPLE_COVERAGE_INVERT:32939,COMPRESSED_TEXTURE_FORMATS:34467,DONT_CARE:4352,FASTEST:4353,NICEST:4354,GENERATE_MIPMAP_HINT:33170,BYTE:5120,UNSIGNED_BYTE:5121,SHORT:5122,UNSIGNED_SHORT:5123,INT:5124,UNSIGNED_INT:5125,FLOAT:5126,DEPTH_COMPONENT:6402,ALPHA:6406,RGB:6407,RGBA:6408,LUMINANCE:6409,LUMINANCE_ALPHA:6410,UNSIGNED_SHORT_4_4_4_4:32819,UNSIGNED_SHORT_5_5_5_1:32820,UNSIGNED_SHORT_5_6_5:33635,FRAGMENT_SHADER:35632,VERTEX_SHADER:35633,MAX_VERTEX_ATTRIBS:34921,MAX_VERTEX_UNIFORM_VECTORS:36347,MAX_VARYING_VECTORS:36348,MAX_COMBINED_TEXTURE_IMAGE_UNITS:35661,MAX_VERTEX_TEXTURE_IMAGE_UNITS:35660,MAX_TEXTURE_IMAGE_UNITS:34930,MAX_FRAGMENT_UNIFORM_VECTORS:36349,SHADER_TYPE:35663,DELETE_STATUS:35712,LINK_STATUS:35714,VALIDATE_STATUS:35715,ATTACHED_SHADERS:35717,ACTIVE_UNIFORMS:35718,ACTIVE_ATTRIBUTES:35721,SHADING_LANGUAGE_VERSION:35724,CURRENT_PROGRAM:35725,NEVER:512,LESS:513,EQUAL:514,LEQUAL:515,GREATER:516,NOTEQUAL:517,GEQUAL:518,ALWAYS:519,KEEP:7680,REPLACE:7681,INCR:7682,DECR:7683,INVERT:5386,INCR_WRAP:34055,DECR_WRAP:34056,VENDOR:7936,RENDERER:7937,VERSION:7938,NEAREST:9728,LINEAR:9729,NEAREST_MIPMAP_NEAREST:9984,LINEAR_MIPMAP_NEAREST:9985,NEAREST_MIPMAP_LINEAR:9986,LINEAR_MIPMAP_LINEAR:9987,TEXTURE_MAG_FILTER:10240,TEXTURE_MIN_FILTER:10241,TEXTURE_WRAP_S:10242,TEXTURE_WRAP_T:10243,TEXTURE_2D:3553,TEXTURE:5890,TEXTURE_CUBE_MAP:34067,TEXTURE_BINDING_CUBE_MAP:34068,TEXTURE_CUBE_MAP_POSITIVE_X:34069,TEXTURE_CUBE_MAP_NEGATIVE_X:34070,TEXTURE_CUBE_MAP_POSITIVE_Y:34071,TEXTURE_CUBE_MAP_NEGATIVE_Y:34072,TEXTURE_CUBE_MAP_POSITIVE_Z:34073,TEXTURE_CUBE_MAP_NEGATIVE_Z:34074,MAX_CUBE_MAP_TEXTURE_SIZE:34076,TEXTURE0:33984,TEXTURE1:33985,TEXTURE2:33986,TEXTURE3:33987,TEXTURE4:33988,TEXTURE5:33989,TEXTURE6:33990,TEXTURE7:33991,TEXTURE8:33992,TEXTURE9:33993,TEXTURE10:33994,TEXTURE11:33995,TEXTURE12:33996,TEXTURE13:33997,TEXTURE14:33998,TEXTURE15:33999,TEXTURE16:34e3,TEXTURE17:34001,TEXTURE18:34002,TEXTURE19:34003,TEXTURE20:34004,TEXTURE21:34005,TEXTURE22:34006,TEXTURE23:34007,TEXTURE24:34008,TEXTURE25:34009,TEXTURE26:34010,TEXTURE27:34011,TEXTURE28:34012,TEXTURE29:34013,TEXTURE30:34014,TEXTURE31:34015,ACTIVE_TEXTURE:34016,REPEAT:10497,CLAMP_TO_EDGE:33071,MIRRORED_REPEAT:33648,FLOAT_VEC2:35664,FLOAT_VEC3:35665,FLOAT_VEC4:35666,INT_VEC2:35667,INT_VEC3:35668,INT_VEC4:35669,BOOL:35670,BOOL_VEC2:35671,BOOL_VEC3:35672,BOOL_VEC4:35673,FLOAT_MAT2:35674,FLOAT_MAT3:35675,FLOAT_MAT4:35676,SAMPLER_2D:35678,SAMPLER_CUBE:35680,VERTEX_ATTRIB_ARRAY_ENABLED:34338,VERTEX_ATTRIB_ARRAY_SIZE:34339,VERTEX_ATTRIB_ARRAY_STRIDE:34340,VERTEX_ATTRIB_ARRAY_TYPE:34341,VERTEX_ATTRIB_ARRAY_NORMALIZED:34922,VERTEX_ATTRIB_ARRAY_POINTER:34373,VERTEX_ATTRIB_ARRAY_BUFFER_BINDING:34975,COMPILE_STATUS:35713,LOW_FLOAT:36336,MEDIUM_FLOAT:36337,HIGH_FLOAT:36338,LOW_INT:36339,MEDIUM_INT:36340,HIGH_INT:36341,FRAMEBUFFER:36160,RENDERBUFFER:36161,RGBA4:32854,RGB5_A1:32855,RGB565:36194,DEPTH_COMPONENT16:33189,STENCIL_INDEX:6401,STENCIL_INDEX8:36168,DEPTH_STENCIL:34041,RENDERBUFFER_WIDTH:36162,RENDERBUFFER_HEIGHT:36163,RENDERBUFFER_INTERNAL_FORMAT:36164,RENDERBUFFER_RED_SIZE:36176,RENDERBUFFER_GREEN_SIZE:36177,RENDERBUFFER_BLUE_SIZE:36178,RENDERBUFFER_ALPHA_SIZE:36179,RENDERBUFFER_DEPTH_SIZE:36180,RENDERBUFFER_STENCIL_SIZE:36181,FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE:36048,FRAMEBUFFER_ATTACHMENT_OBJECT_NAME:36049,FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL:36050,FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE:36051,COLOR_ATTACHMENT0:36064,DEPTH_ATTACHMENT:36096,STENCIL_ATTACHMENT:36128,DEPTH_STENCIL_ATTACHMENT:33306,NONE:0,FRAMEBUFFER_COMPLETE:36053,FRAMEBUFFER_INCOMPLETE_ATTACHMENT:36054,FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT:36055,FRAMEBUFFER_INCOMPLETE_DIMENSIONS:36057,FRAMEBUFFER_UNSUPPORTED:36061,FRAMEBUFFER_BINDING:36006,RENDERBUFFER_BINDING:36007,MAX_RENDERBUFFER_SIZE:34024,INVALID_FRAMEBUFFER_OPERATION:1286,UNPACK_FLIP_Y_WEBGL:37440,UNPACK_PREMULTIPLY_ALPHA_WEBGL:37441,CONTEXT_LOST_WEBGL:37442,UNPACK_COLORSPACE_CONVERSION_WEBGL:37443,BROWSER_DEFAULT_WEBGL:37444}},function(e,t,n){"use strict";var a=n(2),i=n(0),r=n.n(i),o=r.a.vec3,s=o.copy,c=o.set,l=function(e,t){this.min=e||new a.a(1/0,1/0,1/0),this.max=t||new a.a(-1/0,-1/0,-1/0)};l.prototype={constructor:l,updateFromVertices:function(e){if(e.length>0){var t=this.min,n=this.max,a=t._array,i=n._array;s(a,e[0]),s(i,e[0]);for(var r=1;ri[0]&&(i[0]=o[0]),o[1]>i[1]&&(i[1]=o[1]),o[2]>i[2]&&(i[2]=o[2])}t._dirty=!0,n._dirty=!0}},union:function(e){var t=this.min,n=this.max;return o.min(t._array,t._array,e.min._array),o.max(n._array,n._array,e.max._array),t._dirty=!0,n._dirty=!0,this},intersection:function(e){var t=this.min,n=this.max;return o.max(t._array,t._array,e.min._array),o.min(n._array,n._array,e.max._array),t._dirty=!0,n._dirty=!0,this},intersectBoundingBox:function(e){var t=this.min._array,n=this.max._array,a=e.min._array,i=e.max._array;return!(t[0]>i[0]||t[1]>i[1]||t[2]>i[2]||n[0]=i[0]&&n[1]>=i[1]&&n[2]>=i[2]},containPoint:function(e){var t=this.min._array,n=this.max._array,a=e._array;return t[0]<=a[0]&&t[1]<=a[1]&&t[2]<=a[2]&&n[0]>=a[0]&&n[1]>=a[1]&&n[2]>=a[2]},isFinite:function(){var e=this.min._array,t=this.max._array;return isFinite(e[0])&&isFinite(e[1])&&isFinite(e[2])&&isFinite(t[0])&&isFinite(t[1])&&isFinite(t[2])},applyTransform:function(){var e=o.create(),t=o.create(),n=o.create(),a=o.create(),i=o.create(),r=o.create();return function(o){var s=this.min._array,c=this.max._array,l=o._array;return e[0]=l[0]*s[0],e[1]=l[1]*s[0],e[2]=l[2]*s[0],t[0]=l[0]*c[0],t[1]=l[1]*c[0],t[2]=l[2]*c[0],n[0]=l[4]*s[1],n[1]=l[5]*s[1],n[2]=l[6]*s[1],a[0]=l[4]*c[1],a[1]=l[5]*c[1],a[2]=l[6]*c[1],i[0]=l[8]*s[2],i[1]=l[9]*s[2],i[2]=l[10]*s[2],r[0]=l[8]*c[2],r[1]=l[9]*c[2],r[2]=l[10]*c[2],s[0]=Math.min(e[0],t[0])+Math.min(n[0],a[0])+Math.min(i[0],r[0])+l[12],s[1]=Math.min(e[1],t[1])+Math.min(n[1],a[1])+Math.min(i[1],r[1])+l[13],s[2]=Math.min(e[2],t[2])+Math.min(n[2],a[2])+Math.min(i[2],r[2])+l[14],c[0]=Math.max(e[0],t[0])+Math.max(n[0],a[0])+Math.max(i[0],r[0])+l[12],c[1]=Math.max(e[1],t[1])+Math.max(n[1],a[1])+Math.max(i[1],r[1])+l[13],c[2]=Math.max(e[2],t[2])+Math.max(n[2],a[2])+Math.max(i[2],r[2])+l[14],this.min._dirty=!0,this.max._dirty=!0,this}}(),applyProjection:function(e){var t=this.min._array,n=this.max._array,a=e._array,i=t[0],r=t[1],o=t[2],s=n[0],c=n[1],l=t[2],u=n[0],p=n[1],d=n[2];if(1===a[15])t[0]=a[0]*i+a[12],t[1]=a[5]*r+a[13],n[2]=a[10]*o+a[14],n[0]=a[0]*u+a[12],n[1]=a[5]*p+a[13],t[2]=a[10]*d+a[14];else{var f=-1/o;t[0]=a[0]*i*f,t[1]=a[5]*r*f,n[2]=(a[10]*o+a[14])*f,f=-1/l,n[0]=a[0]*s*f,n[1]=a[5]*c*f,f=-1/d,t[2]=(a[10]*d+a[14])*f}return this.min._dirty=!0,this.max._dirty=!0,this},updateVertices:function(){var e=this.vertices;if(!e){for(var e=[],t=0;t<8;t++)e[t]=o.fromValues(0,0,0);this.vertices=e}var n=this.min._array,a=this.max._array;return c(e[0],n[0],n[1],n[2]),c(e[1],n[0],a[1],n[2]),c(e[2],a[0],n[1],n[2]),c(e[3],a[0],a[1],n[2]),c(e[4],n[0],n[1],a[2]),c(e[5],n[0],a[1],a[2]),c(e[6],a[0],n[1],a[2]),c(e[7],a[0],a[1],a[2]),this},copy:function(e){var t=this.min,n=this.max;return s(t._array,e.min._array),s(n._array,e.max._array),t._dirty=!0,n._dirty=!0,this},clone:function(){var e=new l;return e.copy(this),e}},t.a=l},function(e,t,n){"use strict";var a=n(0),i=n.n(a),r=n(2),o=i.a.mat4,s=i.a.vec3,c=i.a.mat3,l=i.a.quat,u=function(){this._axisX=new r.a,this._axisY=new r.a,this._axisZ=new r.a,this._array=o.create(),this._dirty=!0};u.prototype={constructor:u,setArray:function(e){for(var t=0;t=0},set:function(e,t){if("object"==typeof e)for(var n in e){var a=e[n];this.set(n,a)}else{var i=this.uniforms[e];i&&(void 0===t&&(console.warn('Uniform value "'+e+'" is undefined'),t=null),i.value=t)}},get:function(e){var t=this.uniforms[e];if(t)return t.value},attachShader:function(e,t){this.shader&&this.shader.detached();var n=this.uniforms;this.uniforms=e.createUniforms(),this.shader=e;var a=this.uniforms;if(this._enabledUniforms=Object.keys(a),this._enabledUniforms.sort(),t)for(var i in n)a[i]&&(a[i].value=n[i].value);e.attached()},detachShader:function(){this.shader.detached(),this.shader=null,this.uniforms={}},clone:function(){var e=new this.constructor({name:this.name,shader:this.shader});for(var t in this.uniforms)e.uniforms[t].value=this.uniforms[t].value;return e.depthTest=this.depthTest,e.depthMask=this.depthMask,e.transparent=this.transparent,e.blend=this.blend,e},dispose:function(e,t){if(t)for(var n in this.uniforms){var a=this.uniforms[n].value;if(a)if(a instanceof i.a)a.dispose(e);else if(Array.isArray(a))for(var r=0;r=n.COLOR_ATTACHMENT0&&r<=n.COLOR_ATTACHMENT0+8&&i.push(r);a.drawBuffersEXT(i)}}this.trigger("beforerender",this,e);var o=this.clearDepth?n.DEPTH_BUFFER_BIT:0;if(n.depthMask(!0),this.clearColor){o|=n.COLOR_BUFFER_BIT,n.colorMask(!0,!0,!0,!0);var s=this.clearColor;Array.isArray(s)&&n.clearColor(s[0],s[1],s[2],s[3])}n.clear(o),this.blendWithPrevious?(n.enable(n.BLEND),this.material.transparent=!0):(n.disable(n.BLEND),this.material.transparent=!1),this.renderQuad(e),this.trigger("afterrender",this,e),t&&this.unbind(e,t)},renderQuad:function(e){d.material=this.material,e.renderQueue([d],f)},dispose:function(e){this.material.dispose(e)}});t.a=h},function(e,t,n){"use strict";var a=!0;try{var i=document.createElement("canvas");if(!(i.getContext("webgl")||i.getContext("experimental-webgl")))throw new Error}catch(e){a=!1}var r={};r.supportWebGL=function(){return a},r.Int8Array="undefined"==typeof Int8Array?Array:Int8Array,r.Uint8Array="undefined"==typeof Uint8Array?Array:Uint8Array,r.Uint16Array="undefined"==typeof Uint16Array?Array:Uint16Array,r.Uint32Array="undefined"==typeof Uint32Array?Array:Uint32Array,r.Int16Array="undefined"==typeof Int16Array?Array:Int16Array,r.Float32Array="undefined"==typeof Float32Array?Array:Float32Array,r.Float64Array="undefined"==typeof Float64Array?Array:Float64Array,t.a=r},function(e,t,n){"use strict";var a=n(15),i=a.a.extend(function(){return{color:[1,1,1],intensity:1,castShadow:!0,shadowResolution:512,group:0}},{type:"",clone:function(){var e=a.a.prototype.clone.call(this);return e.color=Array.prototype.slice.call(this.color),e.intensity=this.intensity,e.castShadow=this.castShadow,e.shadowResolution=this.shadowResolution,e}});t.a=i},function(e,t,n){"use strict";var a=n(1),i=n(2),r=n(71),o=n(8),s=n(0),c=n.n(s),l=n(7),u=c.a.mat4,p=0,d=a.a.extend({name:"",position:null,rotation:null,scale:null,worldTransform:null,localTransform:null,autoUpdateLocalTransform:!0,_parent:null,_scene:null,_needsUpdateWorldTransform:!0,_inIterating:!1,__depth:0},function(){this.name||(this.name=(this.type||"NODE")+"_"+p++),this.position||(this.position=new i.a),this.rotation||(this.rotation=new r.a),this.scale||(this.scale=new i.a(1,1,1)),this.worldTransform=new o.a,this.localTransform=new o.a,this._children=[]},{target:null,invisible:!1,isSkinnedMesh:function(){return!1},isRenderable:function(){return!1},setName:function(e){var t=this._scene;if(t){var n=t._nodeRepository;delete n[this.name],n[e]=this}this.name=e},add:function(e){this._inIterating&&console.warn("Add operation can cause unpredictable error when in iterating");var t=e._parent;if(t!==this){t&&t.remove(e),e._parent=this,this._children.push(e);var n=this._scene;n&&n!==e.scene&&e.traverse(this._addSelfToScene,this),e._needsUpdateWorldTransform=!0}},remove:function(e){this._inIterating&&console.warn("Remove operation can cause unpredictable error when in iterating");var t=this._children,n=t.indexOf(e);n<0||(t.splice(n,1),e._parent=null,this._scene&&e.traverse(this._removeSelfFromScene,this))},removeAll:function(){for(var e=this._children,t=0;t256?64:o>64?32:o>16?16:8;var s=this.getSkinMatricesTexture();s.width=r,s.height=r,s.pixels&&s.pixels.length===r*r*4||(s.pixels=new Float32Array(r*r*4)),s.pixels.set(i),s.dirty(),t.setUniform(n,"1f","skinMatricesTextureSize",r)}else t.setUniformOfSemantic(n,"SKIN_MATRIX",i)}return a.a.prototype.render.call(this,e,t)},getSkinMatricesTexture:function(){return this._skinMatricesTexture=this._skinMatricesTexture||new r.a({type:i.a.FLOAT,minFilter:i.a.NEAREST,magFilter:i.a.NEAREST,useMipmap:!1,flipY:!1}),this._skinMatricesTexture}});o.POINTS=i.a.POINTS,o.LINES=i.a.LINES,o.LINE_LOOP=i.a.LINE_LOOP,o.LINE_STRIP=i.a.LINE_STRIP,o.TRIANGLES=i.a.TRIANGLES,o.TRIANGLE_STRIP=i.a.TRIANGLE_STRIP,o.TRIANGLE_FAN=i.a.TRIANGLE_FAN,o.BACK=i.a.BACK,o.FRONT=i.a.FRONT,o.FRONT_AND_BACK=i.a.FRONT_AND_BACK,o.CW=i.a.CW,o.CCW=i.a.CCW,t.a=o},function(e,t,n){"use strict";function a(e){return"CANVAS"===e.nodeName||"VIDEO"===e.nodeName||e.complete}var i=n(3),r=n(6),o=n(11),s=n(44),c=s.a.isPowerOfTwo,l=["px","nx","py","ny","pz","nz"],u=i.a.extend(function(){return{image:{px:null,nx:null,py:null,ny:null,pz:null,nz:null},pixels:{px:null,nx:null,py:null,ny:null,pz:null,nz:null},mipmaps:[]}},{update:function(e){var t=e.gl;t.bindTexture(t.TEXTURE_CUBE_MAP,this._cache.get("webgl_texture")),this.updateCommon(e);var n=this.format,a=this.type;t.texParameteri(t.TEXTURE_CUBE_MAP,t.TEXTURE_WRAP_S,this.getAvailableWrapS()),t.texParameteri(t.TEXTURE_CUBE_MAP,t.TEXTURE_WRAP_T,this.getAvailableWrapT()),t.texParameteri(t.TEXTURE_CUBE_MAP,t.TEXTURE_MAG_FILTER,this.getAvailableMagFilter()),t.texParameteri(t.TEXTURE_CUBE_MAP,t.TEXTURE_MIN_FILTER,this.getAvailableMinFilter());var i=e.getGLExtension("EXT_texture_filter_anisotropic");if(i&&this.anisotropic>1&&t.texParameterf(t.TEXTURE_CUBE_MAP,i.TEXTURE_MAX_ANISOTROPY_EXT,this.anisotropic),36193===a){e.getGLExtension("OES_texture_half_float")||(a=r.a.FLOAT)}if(this.mipmaps.length)for(var o=this.width,s=this.height,c=0;c0&&this._updateRenderQueue(a)}},_updateLightUniforms:function(){var e=this.lights;e.sort(a);var t=this._lightUniforms;for(var n in t)for(var i in t[n])t[n][i].value.length=0;for(var r=0;rr[0]&&(r[0]=s),c>r[1]&&(r[1]=c),l>r[2]&&(r[2]=l)}n._dirty=!0,a._dirty=!0}},dirty:function(){for(var e=this.getEnabledAttributes(),t=0;t=0){t||(t=_());var n=this.indices;return t[0]=n[3*e],t[1]=n[3*e+1],t[2]=n[3*e+2],t}},setTriangleIndices:function(e,t){var n=this.indices;n[3*e]=t[0],n[3*e+1]=t[1],n[3*e+2]=t[2]},isUseIndices:function(){return!!this.indices},initIndicesFromArray:function(e){var t,n=this.vertexCount>65535?p.a.Uint32Array:p.a.Uint16Array;if(e[0]&&e[0].length){var a=0;t=new n(3*e.length);for(var i=0;i=0&&(t.splice(n,1),delete this.attributes[e],!0)},getAttribute:function(e){return this.attribute[e]},getEnabledAttributes:function(){var e=this._enabledAttributes,t=this._attributeList;if(e)return e;for(var n=[],a=this.vertexCount,i=0;i65535&&(this.indices=new p.a.Uint32Array(this.indices));for(var e=this.attributes,t=this.indices,n=this.getEnabledAttributes(),a={},i=0;i0){var t=this.outputs[e];t.keepLastFrame?(this._prevOutputTextures[e]&&this._compositor.releaseTexture(this._prevOutputTextures[e]),this._prevOutputTextures[e]=this._outputTextures[e]):this._compositor.releaseTexture(this._outputTextures[e])}}});t.a=i},function(e,t,n){"use strict";function a(e,t){this.action=e,this.context=t}var i={trigger:function(e){if(this.hasOwnProperty("__handlers__")&&this.__handlers__.hasOwnProperty(e)){var t=this.__handlers__[e],n=t.length,a=-1,i=arguments;switch(i.length){case 1:for(;++a=400?e.onerror&&e.onerror():e.onload&&e.onload(t.response)},e.onerror&&(t.onerror=e.onerror),t.send(null)}t.a={get:a}},function(e,t,n){"use strict";var a=n(46),i=a.a.extend({fov:50,aspect:1,near:.1,far:2e3},{updateProjectionMatrix:function(){var e=this.fov/180*Math.PI;this.projectionMatrix.perspective(e,this.aspect,this.near,this.far)},decomposeProjectionMatrix:function(){var e=this.projectionMatrix._array,t=2*Math.atan(1/e[5]);this.fov=t/Math.PI*180,this.aspect=e[5]/e[0],this.near=e[14]/(e[10]-1),this.far=e[14]/(e[10]+1)},clone:function(){var e=a.a.prototype.clone.call(this);return e.fov=this.fov,e.aspect=this.aspect,e.near=this.near,e.far=this.far,e}});t.a=i},function(e,t,n){"use strict";var a=n(46),i=a.a.extend({left:-1,right:1,near:-1,far:1,top:1,bottom:-1},{updateProjectionMatrix:function(){this.projectionMatrix.ortho(this.left,this.right,this.bottom,this.top,this.near,this.far)},decomposeProjectionMatrix:function(){var e=this.projectionMatrix._array;this.left=(-1-e[12])/e[0],this.right=(1-e[12])/e[0],this.top=(1-e[13])/e[5],this.bottom=(-1-e[13])/e[5],this.near=-(-1-e[14])/e[10],this.far=-(1-e[14])/e[10]},clone:function(){var e=a.a.prototype.clone.call(this);return e.left=this.left,e.right=this.right,e.near=this.near,e.far=this.far,e.top=this.top,e.bottom=this.bottom,e}});t.a=i},function(e,t,n){"use strict";function a(e,t){for(var n=0,a=1/t,i=e;i>0;)n+=a*(i%t),i=Math.floor(i/t),a/=t;return n}t.a=a},function(e,t,n){"use strict";function a(e){return!e||"none"===e}function i(e){return e instanceof HTMLCanvasElement||e instanceof HTMLImageElement||e instanceof Image}function r(e){return Math.pow(2,Math.round(Math.log(e)/Math.LN2))}function o(e){if((e.wrapS===s.a.REPEAT||e.wrapT===s.a.REPEAT)&&e.image){var t=r(e.width),n=r(e.height);if(t!==e.width||n!==e.height){var a=document.createElement("canvas");a.width=t,a.height=n;a.getContext("2d").drawImage(e.image,0,0,t,n),a.srcImage=e.image,e.image=a,e.dirty()}}}var s=n(3),c=n(9),l=n(63),u=n(33),p=n(117),d=n(122),f=n(123),h=n(125),m=n(5);c.a.prototype.setTextureImage=function(e,t,n,i){if(this.shader){var r,o=this;return o.shader.disableTexture(e),a(t)||(r=v.loadTexture(t,n,i,function(t){o.shader.enableTexture(e),n.refresh()}),o.set(e,r)),r}};var v={},_=u.a.createBlank("rgba(255,255,255,0)").image;v.firstNotNull=function(){for(var e=0,t=arguments.length;e3?t[3]=e[3]:t[3]=1,t):(t=h.a(e||"#000",t)||[0,0,0,0],t[0]/=255,t[1]/=255,t[2]/=255,t)},v.stringifyColor=function(e,t){return e=e.slice(),e[0]=Math.round(255*e[0]),e[1]=Math.round(255*e[1]),e[2]=Math.round(255*e[2]),"hex"===t?"#"+((1<<24)+(e[0]<<16)+(e[1]<<8)+e[2]).toString(16).slice(1):h.b(e,t)},v.directionFromAlphaBeta=function(e,t){var n=e/180*Math.PI+Math.PI/2,a=-t/180*Math.PI+Math.PI/2,i=[],r=Math.sin(n);return i[0]=r*Math.cos(a),i[1]=-Math.cos(n),i[2]=r*Math.sin(a),i},v.convertTextureToPowerOfTwo=o,t.a=v},function(e,t,n){"use strict";var a=n(1),i=n(69),r=n(6),o=(n(13),n(7)),s=n(8),c=(n(18),n(9)),l=n(24),u=n(4),p=n(38),d=n(39),f=n(0),h=n.n(f);u.a.import(p.a),u.a.import(d.a);var m=h.a.mat4,v=h.a.vec3,_=m.create,x={},g=a.a.extend(function(){return{canvas:null,_width:100,_height:100,devicePixelRatio:window.devicePixelRatio||1,clearColor:[0,0,0,0],clearBit:17664,alpha:!0,depth:!0,stencil:!1,antialias:!0,premultipliedAlpha:!0,preserveDrawingBuffer:!1,throwError:!0,gl:null,viewport:{},__currentFrameBuffer:null,_viewportStack:[],_clearStack:[],_sceneRendering:null}},function(){this.canvas||(this.canvas=document.createElement("canvas"));var e=this.canvas;try{var t={alpha:this.alpha,depth:this.depth,stencil:this.stencil,antialias:this.antialias,premultipliedAlpha:this.premultipliedAlpha,preserveDrawingBuffer:this.preserveDrawingBuffer};if(this.gl=e.getContext("webgl",t)||e.getContext("experimental-webgl",t),!this.gl)throw new Error;this._glinfo=new i.a(this.gl),this.gl.targetRenderer&&console.error("Already created a renderer"),this.gl.targetRenderer=this,this.resize()}catch(e){throw"Error creating WebGL Context "+e}},{resize:function(e,t){var n=this.canvas,a=this.devicePixelRatio;null!=e?(n.style.width=e+"px",n.style.height=t+"px",n.width=e*a,n.height=t*a,this._width=e,this._height=t):(this._width=n.width/a,this._height=n.height/a),this.setViewport(0,0,this._width,this._height)},getWidth:function(){return this._width},getHeight:function(){return this._height},getViewportAspect:function(){var e=this.viewport;return e.width/e.height},setDevicePixelRatio:function(e){this.devicePixelRatio=e,this.resize(this._width,this._height)},getDevicePixelRatio:function(){return this.devicePixelRatio},getGLExtension:function(e){return this._glinfo.getExtension(e)},getGLParameter:function(e){return this._glinfo.getParameter(e)},setViewport:function(e,t,n,a,i){if("object"==typeof e){var r=e;e=r.x,t=r.y,n=r.width,a=r.height,i=r.devicePixelRatio}i=i||this.devicePixelRatio,this.gl.viewport(e*i,t*i,n*i,a*i),this.viewport={x:e,y:t,width:n,height:a,devicePixelRatio:i}},saveViewport:function(){this._viewportStack.push(this.viewport)},restoreViewport:function(){this._viewportStack.length>0&&this.setViewport(this._viewportStack.pop())},saveClear:function(){this._clearStack.push({clearBit:this.clearBit,clearColor:this.clearColor})},restoreClear:function(){if(this._clearStack.length>0){var e=this._clearStack.pop();this.clearColor=e.clearColor,this.clearBit=e.clearBit}},bindSceneRendering:function(e){this._sceneRendering=e},beforeRenderObject:function(){},afterRenderObject:function(){},render:function(e,t,n,a){var i=this.gl;this._sceneRendering=e;var r=this.clearColor;if(this.clearBit){i.colorMask(!0,!0,!0,!0),i.depthMask(!0);var o=this.viewport,s=!1,c=o.devicePixelRatio;(o.width!==this._width||o.height!==this._height||c&&c!==this.devicePixelRatio||o.x||o.y)&&(s=!0,i.enable(i.SCISSOR_TEST),i.scissor(o.x*c,o.y*c,o.width*c,o.height*c)),i.clearColor(r[0],r[1],r[2],r[3]),i.clear(this.clearBit),s&&i.disable(i.SCISSOR_TEST)}n||e.update(!1),t.getScene()||t.update(!0);for(var l=e.opaqueQueue,u=e.transparentQueue,p=e.material,d=0;d0)for(var h=_(),x=v.create(),d=0;d0&&e.min._array[2]<0&&(e.max._array[2]=-1e-20),e.applyProjection(t);var c=e.min._array,l=e.max._array;if(l[0]<-1||c[0]>1||l[1]<-1||c[1]>1||l[2]<-1||c[2]>1)return!0}return!1}}(),disposeScene:function(e){this.disposeNode(e,!0,!0),e.dispose()},disposeNode:function(e,t,n){var a={};e.getParent()&&e.getParent().remove(e),e.traverse(function(e){e.geometry&&t&&e.geometry.dispose(this),e.material&&(a[e.material.__GUID__]=e.material),e.dispose&&e.dispose(this)},this);for(var i in a){a[i].dispose(this,n)}},disposeShader:function(e){e.dispose(this)},disposeGeometry:function(e){e.dispose(this)},disposeTexture:function(e){e.dispose(this)},disposeFrameBuffer:function(e){e.dispose(this)},dispose:function(){},screenToNDC:function(e,t,n){n||(n=new l.a),t=this._height-t;var a=this.viewport,i=n._array;return i[0]=(e-a.x)/a.width,i[0]=2*i[0]-1,i[1]=(t-a.y)/a.height,i[1]=2*i[1]-1,n}});g.opaqueSortFunc=g.prototype.opaqueSortFunc=function(e,t){return e.renderOrder===t.renderOrder?e.material.shader===t.material.shader?e.material===t.material?e.geometry.__GUID__-t.geometry.__GUID__:e.material.__GUID__-t.material.__GUID__:e.material.shader.__GUID__-t.material.shader.__GUID__:e.renderOrder-t.renderOrder},g.transparentSortFunc=g.prototype.transparentSortFunc=function(e,t){return e.renderOrder===t.renderOrder?e.__depth===t.__depth?e.material.shader===t.material.shader?e.material===t.material?e.geometry.__GUID__-t.geometry.__GUID__:e.material.__GUID__-t.material.__GUID__:e.material.shader.__GUID__-t.material.shader.__GUID__:e.__depth-t.__depth:e.renderOrder-t.renderOrder};var y={IDENTITY:_(),WORLD:_(),VIEW:_(),PROJECTION:_(),WORLDVIEW:_(),VIEWPROJECTION:_(),WORLDVIEWPROJECTION:_(),WORLDINVERSE:_(),VIEWINVERSE:_(),PROJECTIONINVERSE:_(),WORLDVIEWINVERSE:_(),VIEWPROJECTIONINVERSE:_(),WORLDVIEWPROJECTIONINVERSE:_(),WORLDTRANSPOSE:_(),VIEWTRANSPOSE:_(),PROJECTIONTRANSPOSE:_(),WORLDVIEWTRANSPOSE:_(),VIEWPROJECTIONTRANSPOSE:_(),WORLDVIEWPROJECTIONTRANSPOSE:_(),WORLDINVERSETRANSPOSE:_(),VIEWINVERSETRANSPOSE:_(),PROJECTIONINVERSETRANSPOSE:_(),WORLDVIEWINVERSETRANSPOSE:_(),VIEWPROJECTIONINVERSETRANSPOSE:_(),WORLDVIEWPROJECTIONINVERSETRANSPOSE:_()};g.COLOR_BUFFER_BIT=r.a.COLOR_BUFFER_BIT,g.DEPTH_BUFFER_BIT=r.a.DEPTH_BUFFER_BIT,g.STENCIL_BUFFER_BIT=r.a.STENCIL_BUFFER_BIT,t.a=g},function(e,t,n){"use strict";function a(){}var i=n(75),r=function(e){e=e||{},this.name=e.name||"",this.target=e.target,this.life=e.life||1e3,this.delay=e.delay||0,this.gap=e.gap||0,this.playbackRate=e.playbackRate||1,this._initialized=!1,this._elapsedTime=0,this._loop=null!=e.loop&&e.loop,this.setLoop(this._loop),null!=e.easing&&this.setEasing(e.easing),this.onframe=e.onframe||a,this.onfinish=e.onfinish||a,this.onrestart=e.onrestart||a,this._paused=!1};r.prototype={gap:0,life:0,delay:0,setLoop:function(e){this._loop=e,e&&(this._loopRemained="number"==typeof e?e:1e8)},setEasing:function(e){"string"==typeof e&&(e=i.a[e]),this.easing=e},step:function(e,t,n){if(this._initialized||(this._startTime=e+this.delay,this._initialized=!0),null!=this._currentTime&&(t=e-this._currentTime),this._currentTime=e,this._paused)return"paused";if(!(e0?(this._restartInLoop(e),this._loopRemained--,"restart"):(this._needsRemove=!0,"finish"):null}}},setTime:function(e){return this.step(e+this._startTime)},restart:function(e){var t=0;e&&(this._elapse(e),t=this._elapsedTime%this.life),e=e||Date.now(),this._startTime=e-t+this.delay,this._elapsedTime=0,this._needsRemove=!1,this._paused=!1},getElapsedTime:function(){return this._elapsedTime},_restartInLoop:function(e){this._startTime=e+this.gap,this._elapsedTime=0},_elapse:function(e,t){this._elapsedTime+=t*this.playbackRate},fire:function(e,t){var n="on"+e;this[n]&&this[n](this.target,t)},clone:function(){var e=new this.constructor;return e.name=this.name,e._loop=this._loop,e._loopRemained=this._loopRemained,e.life=this.life,e.gap=this.gap,e.delay=this.delay,e},pause:function(){this._paused=!0},resume:function(){this._paused=!1}},r.prototype.constructor=r,t.a=r},function(e,t,n){"use strict";var a=n(20),i=n(7),r=a.a.extend({dynamic:!1,widthSegments:1,heightSegments:1},function(){this.build()},{build:function(){for(var e=this.heightSegments,t=this.widthSegments,n=this.attributes,a=[],r=[],o=[],s=[],c=0;c<=e;c++)for(var l=c/e,u=0;u<=t;u++){var p=u/t;if(a.push([2*p-1,2*l-1,0]),r&&r.push([p,l]),o&&o.push([0,0,1]),u20)return console.warn("Given image is not a height map"),e}var d,f,h,m;c%(4*a)==0?(d=o.data[c],h=o.data[c+4]):c%(4*a)==4*(a-1)?(d=o.data[c-4],h=o.data[c]):(d=o.data[c-4],h=o.data[c+4]),c<4*a?(f=o.data[c],m=o.data[c+4*a]):c>a*(i-1)*4?(f=o.data[c-4*a],m=o.data[c]):(f=o.data[c-4*a],m=o.data[c+4*a]),s.data[c]=d-h+127,s.data[c+1]=f-m+127,s.data[c+2]=255,s.data[c+3]=255}return r.putImageData(s,0,0),n},isHeightImage:function(e,t,n){if(!e||!e.width||!e.height)return!1;var a=document.createElement("canvas"),i=a.getContext("2d"),r=t||32;n=n||20,a.width=a.height=r,i.drawImage(e,0,0,r,r);for(var o=i.getImageData(0,0,r,r),s=0;sn)return!1}return!0},_fetchTexture:function(e,t,n){r.a.get({url:e,responseType:"arraybuffer",onload:t,onerror:n})},createChessboard:function(e,t,n,i){e=e||512,t=t||64,n=n||"black",i=i||"white";var r=Math.ceil(e/t),o=document.createElement("canvas");o.width=e,o.height=e;var s=o.getContext("2d");s.fillStyle=i,s.fillRect(0,0,e,e),s.fillStyle=n;for(var c=0;c0},beforeRender:function(e){},afterRender:function(e,t){},getBoundingBox:function(e,t){return t=r.a.prototype.getBoundingBox.call(this,e,t),this.geometry&&this.geometry.boundingBox&&t.union(this.geometry.boundingBox),t},render:function(e,t){var n=e.gl,t=t||this.material.shader,r=this.geometry,u=this.mode,p=r.vertexCount,d=r.isUseIndices(),f=e.getGLExtension("OES_element_index_uint"),h=f&&p>65535,m=h?n.UNSIGNED_INT:n.UNSIGNED_SHORT,v=e.getGLExtension("OES_vertex_array_object"),_=!r.dynamic,x=this._renderInfo;x.vertexCount=p,x.triangleCount=0,x.drawCallCount=0;var g=!1;if(i=e.__GUID__+"-"+r.__GUID__+"-"+t.__GUID__,i!==s?g=!0:(p>65535&&!f&&d||v&&_||r._cache.isDirty())&&(g=!0),s=i,g){var y=this._drawCache[i];if(!y){var b=r.getBufferChunks(e);if(!b)return;y=[];for(var T=0;T>1,e|=e>>2,e|=e>>4,e|=e>>8,e|=e>>16,++e},a.nearestPowerOfTwo=function(e){return Math.pow(2,Math.round(Math.log(e)/Math.LN2))},t.a=a},function(e,t,n){"use strict";var a=n(1),i=a.a.extend({name:"",index:-1,node:null,rootNode:null});t.a=i},function(e,t,n){"use strict";var a=n(15),i=n(8),r=n(47),o=n(48),s=n(0),c=n.n(s),l=c.a.vec3,u=c.a.vec4,p=a.a.extend(function(){return{projectionMatrix:new i.a,invProjectionMatrix:new i.a,viewMatrix:new i.a,frustum:new r.a}},function(){this.update(!0)},{update:function(e){a.a.prototype.update.call(this,e),i.a.invert(this.viewMatrix,this.worldTransform),this.updateProjectionMatrix(),i.a.invert(this.invProjectionMatrix,this.projectionMatrix),this.frustum.setFromProjection(this.projectionMatrix)},setViewMatrix:function(e){i.a.copy(this.viewMatrix,e),i.a.invert(this.worldTransform,e),this.decomposeWorldTransform()},decomposeProjectionMatrix:function(){},setProjectionMatrix:function(e){i.a.copy(this.projectionMatrix,e),i.a.invert(this.invProjectionMatrix,e),this.decomposeProjectionMatrix()},updateProjectionMatrix:function(){},castRay:function(){var e=u.create();return function(t,n){var a=void 0!==n?n:new o.a,i=t._array[0],r=t._array[1];return u.set(e,i,r,-1,1),u.transformMat4(e,e,this.invProjectionMatrix._array),u.transformMat4(e,e,this.worldTransform._array),l.scale(a.origin._array,e,1/e[3]),u.set(e,i,r,1,1),u.transformMat4(e,e,this.invProjectionMatrix._array),u.transformMat4(e,e,this.worldTransform._array),l.scale(e,e,1/e[3]),l.sub(a.direction._array,e,a.origin._array),l.normalize(a.direction._array,a.direction._array),a.direction._dirty=!0,a.origin._dirty=!0,a}}()});t.a=p},function(e,t,n){"use strict";var a=(n(2),n(7)),i=n(73),r=n(0),o=n.n(r),s=o.a.vec3,c=s.set,l=s.copy,u=s.transformMat4,p=Math.min,d=Math.max,f=function(){this.planes=[];for(var e=0;e<6;e++)this.planes.push(new i.a);this.boundingBox=new a.a,this.vertices=[];for(var e=0;e<8;e++)this.vertices[e]=s.fromValues(0,0,0)};f.prototype={setFromProjection:function(e){var t=this.planes,n=e._array,a=n[0],i=n[1],r=n[2],o=n[3],s=n[4],l=n[5],u=n[6],p=n[7],d=n[8],f=n[9],h=n[10],m=n[11],v=n[12],_=n[13],x=n[14],g=n[15];c(t[0].normal._array,o-a,p-s,m-d),t[0].distance=-(g-v),t[0].normalize(),c(t[1].normal._array,o+a,p+s,m+d),t[1].distance=-(g+v),t[1].normalize(),c(t[2].normal._array,o+i,p+l,m+f),t[2].distance=-(g+_),t[2].normalize(),c(t[3].normal._array,o-i,p-l,m-f),t[3].distance=-(g-_),t[3].normalize(),c(t[4].normal._array,o-r,p-u,m-h),t[4].distance=-(g-x),t[4].normalize(),c(t[5].normal._array,o+r,p+u,m+h),t[5].distance=-(g+x),t[5].normalize();var y=this.boundingBox;if(0===g){var b=l/a,T=-x/(h-1),E=-x/(h+1),w=-E/l,S=-T/l;y.min.set(-w*b,-w,E),y.max.set(w*b,w,T);var A=this.vertices;c(A[0],-w*b,-w,E),c(A[1],-w*b,w,E),c(A[2],w*b,-w,E),c(A[3],w*b,w,E),c(A[4],-S*b,-S,T),c(A[5],-S*b,S,T),c(A[6],S*b,-S,T),c(A[7],S*b,S,T)}else{var N=(-1-v)/a,C=(1-v)/a,M=(1-_)/l,R=(-1-_)/l,L=(-1-x)/h,D=(1-x)/h;y.min.set(Math.min(N,C),Math.min(R,M),Math.min(D,L)),y.max.set(Math.max(C,N),Math.max(M,R),Math.max(L,D));var P=y.min._array,I=y.max._array,A=this.vertices;c(A[0],P[0],P[1],P[2]),c(A[1],P[0],I[1],P[2]),c(A[2],I[0],P[1],P[2]),c(A[3],I[0],I[1],P[2]),c(A[4],P[0],P[1],I[2]),c(A[5],P[0],I[1],I[2]),c(A[6],I[0],P[1],I[2]),c(A[7],I[0],I[1],I[2])}},getTransformedBoundingBox:function(){var e=s.create();return function(t,n){var a=this.vertices,i=n._array,r=t.min,o=t.max,s=r._array,c=o._array,f=a[0];u(e,f,i),l(s,e),l(c,e);for(var h=1;h<8;h++)f=a[h],u(e,f,i),s[0]=p(e[0],s[0]),s[1]=p(e[1],s[1]),s[2]=p(e[2],s[2]),c[0]=d(e[0],c[0]),c[1]=d(e[1],c[1]),c[2]=d(e[2],c[2]);return r._dirty=!0,o._dirty=!0,t}}()},t.a=f},function(e,t,n){"use strict";var a=n(2),i=n(0),r=n.n(i),o=r.a.vec3,s=function(e,t){this.origin=e||new a.a,this.direction=t||new a.a};s.prototype={constructor:s,intersectPlane:function(e,t){var n=e.normal._array,i=e.distance,r=this.origin._array,s=this.direction._array,c=o.dot(n,s);if(0===c)return null;t||(t=new a.a);var l=(o.dot(n,r)-i)/c;return o.scaleAndAdd(t._array,r,s,-l),t._dirty=!0,t},mirrorAgainstPlane:function(e){var t=o.dot(e.normal._array,this.direction._array);o.scaleAndAdd(this.direction._array,this.direction._array,e.normal._array,2*-t),this.direction._dirty=!0},distanceToPoint:function(){var e=o.create();return function(t){o.sub(e,t,this.origin._array);var n=o.dot(e,this.direction._array);if(n<0)return o.distance(this.origin._array,t);var a=o.lenSquared(e);return Math.sqrt(a-n*n)}}(),intersectSphere:function(){var e=o.create();return function(t,n,i){var r=this.origin._array,s=this.direction._array;t=t._array,o.sub(e,t,r);var c=o.dot(e,s),l=o.squaredLength(e),u=l-c*c,p=n*n;if(!(u>p)){var d=Math.sqrt(p-u),f=c-d,h=c+d;return i||(i=new a.a),f<0?h<0?null:(o.scaleAndAdd(i._array,r,s,h),i):(o.scaleAndAdd(i._array,r,s,f),i)}}}(),intersectBoundingBox:function(e,t){var n,i,r,s,c,l,u=this.direction._array,p=this.origin._array,d=e.min._array,f=e.max._array,h=1/u[0],m=1/u[1],v=1/u[2];if(h>=0?(n=(d[0]-p[0])*h,i=(f[0]-p[0])*h):(i=(d[0]-p[0])*h,n=(f[0]-p[0])*h),m>=0?(r=(d[1]-p[1])*m,s=(f[1]-p[1])*m):(s=(d[1]-p[1])*m,r=(f[1]-p[1])*m),n>s||r>i)return null;if((r>n||n!==n)&&(n=r),(s=0?(c=(d[2]-p[2])*v,l=(f[2]-p[2])*v):(l=(d[2]-p[2])*v,c=(f[2]-p[2])*v),n>l||c>i)return null;if((c>n||n!==n)&&(n=c),(l=0?n:i;return t||(t=new a.a),o.scaleAndAdd(t._array,p,u,_),t},intersectTriangle:function(){var e=o.create(),t=o.create(),n=o.create(),i=o.create();return function(r,s,c,l,u,p){var d=this.direction._array,f=this.origin._array;r=r._array,s=s._array,c=c._array,o.sub(e,s,r),o.sub(t,c,r),o.cross(i,t,d);var h=o.dot(e,i);if(l){if(h>-1e-5)return null}else if(h>-1e-5&&h<1e-5)return null;o.sub(n,f,r);var m=o.dot(i,n)/h;if(m<0||m>1)return null;o.cross(i,e,n);var v=o.dot(d,i)/h;if(v<0||v>1||m+v>1)return null;o.cross(i,e,t);var _=-o.dot(n,i)/h;return _<0?null:(u||(u=new a.a),p&&a.a.set(p,1-m-v,m,v),o.scaleAndAdd(u._array,f,d,_),u)}}(),applyTransform:function(e){a.a.add(this.direction,this.direction,this.origin),a.a.transformMat4(this.origin,this.origin,e),a.a.transformMat4(this.direction,this.direction,e),a.a.sub(this.direction,this.direction,this.origin),a.a.normalize(this.direction,this.direction)},copy:function(e){a.a.copy(this.origin,e.origin),a.a.copy(this.direction,e.direction)},clone:function(){var e=new s;return e.copy(this),e}},t.a=s},function(e,t,n){"use strict";t.a="@export qtek.basic.vertex\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\nuniform vec2 uvRepeat : [1.0, 1.0];\nuniform vec2 uvOffset : [0.0, 0.0];\nattribute vec2 texcoord : TEXCOORD_0;\nattribute vec3 position : POSITION;\nattribute vec3 barycentric;\n@import qtek.chunk.skinning_header\nvarying vec2 v_Texcoord;\nvarying vec3 v_Barycentric;\nvoid main()\n{\n vec3 skinnedPosition = position;\n#ifdef SKINNING\n @import qtek.chunk.skin_matrix\n skinnedPosition = (skinMatrixWS * vec4(position, 1.0)).xyz;\n#endif\n v_Texcoord = texcoord * uvRepeat + uvOffset;\n v_Barycentric = barycentric;\n gl_Position = worldViewProjection * vec4(skinnedPosition, 1.0);\n}\n@end\n@export qtek.basic.fragment\nvarying vec2 v_Texcoord;\nuniform sampler2D diffuseMap;\nuniform vec3 color : [1.0, 1.0, 1.0];\nuniform vec3 emission : [0.0, 0.0, 0.0];\nuniform float alpha : 1.0;\n#ifdef ALPHA_TEST\nuniform float alphaCutoff: 0.9;\n#endif\nuniform float lineWidth : 0.0;\nuniform vec4 lineColor : [0.0, 0.0, 0.0, 0.6];\nvarying vec3 v_Barycentric;\n@import qtek.util.edge_factor\n@import qtek.util.rgbm\n@import qtek.util.srgb\nvoid main()\n{\n#ifdef RENDER_TEXCOORD\n gl_FragColor = vec4(v_Texcoord, 1.0, 1.0);\n return;\n#endif\n gl_FragColor = vec4(color, alpha);\n#ifdef DIFFUSEMAP_ENABLED\n vec4 tex = decodeHDR(texture2D(diffuseMap, v_Texcoord));\n#ifdef SRGB_DECODE\n tex = sRGBToLinear(tex);\n#endif\n#if defined(DIFFUSEMAP_ALPHA_ALPHA)\n gl_FragColor.a = tex.a;\n#endif\n gl_FragColor.rgb *= tex.rgb;\n#endif\n gl_FragColor.rgb += emission;\n if( lineWidth > 0.)\n {\n gl_FragColor.rgb = mix(gl_FragColor.rgb, lineColor.rgb, (1.0 - edgeFactor(lineWidth)) * lineColor.a);\n }\n#ifdef GAMMA_ENCODE\n gl_FragColor.rgb = pow(gl_FragColor.rgb, vec3(1 / 2.2));\n#endif\n#ifdef ALPHA_TEST\n if (gl_FragColor.a < alphaCutoff) {\n discard;\n }\n#endif\n gl_FragColor = encodeHDR(gl_FragColor);\n}\n@end"},function(e,t,n){"use strict";t.a="@export qtek.skybox.vertex\nuniform mat4 world : WORLD;\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\nattribute vec3 position : POSITION;\nvarying vec3 v_WorldPosition;\nvoid main()\n{\n v_WorldPosition = (world * vec4(position, 1.0)).xyz;\n gl_Position = worldViewProjection * vec4(position, 1.0);\n}\n@end\n@export qtek.skybox.fragment\nuniform mat4 viewInverse : VIEWINVERSE;\nuniform samplerCube environmentMap;\nuniform float lod: 0.0;\nvarying vec3 v_WorldPosition;\n@import qtek.util.rgbm\nvoid main()\n{\n vec3 eyePos = viewInverse[3].xyz;\n vec3 viewDirection = normalize(v_WorldPosition - eyePos);\n vec3 tex = decodeHDR(textureCubeLodEXT(environmentMap, viewDirection, lod)).rgb;\n#ifdef SRGB_DECODE\n tex.rgb = pow(tex.rgb, vec3(2.2));\n#endif\n gl_FragColor = encodeHDR(vec4(tex, 1.0));\n}\n@end"},function(e,t,n){"use strict";t.a="@export qtek.compositor.kernel.gaussian_9\nfloat gaussianKernel[9];\ngaussianKernel[0] = 0.07;\ngaussianKernel[1] = 0.09;\ngaussianKernel[2] = 0.12;\ngaussianKernel[3] = 0.14;\ngaussianKernel[4] = 0.16;\ngaussianKernel[5] = 0.14;\ngaussianKernel[6] = 0.12;\ngaussianKernel[7] = 0.09;\ngaussianKernel[8] = 0.07;\n@end\n@export qtek.compositor.kernel.gaussian_13\nfloat gaussianKernel[13];\ngaussianKernel[0] = 0.02;\ngaussianKernel[1] = 0.03;\ngaussianKernel[2] = 0.06;\ngaussianKernel[3] = 0.08;\ngaussianKernel[4] = 0.11;\ngaussianKernel[5] = 0.13;\ngaussianKernel[6] = 0.14;\ngaussianKernel[7] = 0.13;\ngaussianKernel[8] = 0.11;\ngaussianKernel[9] = 0.08;\ngaussianKernel[10] = 0.06;\ngaussianKernel[11] = 0.03;\ngaussianKernel[12] = 0.02;\n@end\n@export qtek.compositor.gaussian_blur\n#define SHADER_NAME gaussian_blur\nuniform sampler2D texture;varying vec2 v_Texcoord;\nuniform float blurSize : 2.0;\nuniform vec2 textureSize : [512.0, 512.0];\nuniform float blurDir : 0.0;\n@import qtek.util.rgbm\n@import qtek.util.clamp_sample\nvoid main (void)\n{\n @import qtek.compositor.kernel.gaussian_9\n vec2 off = blurSize / textureSize;\n off *= vec2(1.0 - blurDir, blurDir);\n vec4 sum = vec4(0.0);\n float weightAll = 0.0;\n for (int i = 0; i < 9; i++) {\n float w = gaussianKernel[i];\n vec4 texel = decodeHDR(clampSample(texture, v_Texcoord + float(i - 4) * off));\n sum += texel * w;\n weightAll += w;\n }\n gl_FragColor = encodeHDR(sum / max(weightAll, 0.01));\n}\n@end\n"},function(e,t,n){"use strict";t.a="@export qtek.compositor.output\n#define OUTPUT_ALPHA\nvarying vec2 v_Texcoord;\nuniform sampler2D texture;\n@import qtek.util.rgbm\nvoid main()\n{\n vec4 tex = decodeHDR(texture2D(texture, v_Texcoord));\n gl_FragColor.rgb = tex.rgb;\n#ifdef OUTPUT_ALPHA\n gl_FragColor.a = tex.a;\n#else\n gl_FragColor.a = 1.0;\n#endif\n gl_FragColor = encodeHDR(gl_FragColor);\n#ifdef PREMULTIPLY_ALPHA\n gl_FragColor.rgb *= gl_FragColor.a;\n#endif\n}\n@end"},function(e,t,n){"use strict";t.a="@export qtek.compositor.bright\nuniform sampler2D texture;\nuniform float threshold : 1;\nuniform float scale : 1.0;\nuniform vec2 textureSize: [512, 512];\nvarying vec2 v_Texcoord;\nconst vec3 lumWeight = vec3(0.2125, 0.7154, 0.0721);\n@import qtek.util.rgbm\nvec4 median(vec4 a, vec4 b, vec4 c)\n{\n return a + b + c - min(min(a, b), c) - max(max(a, b), c);\n}\nvoid main()\n{\n vec4 texel = decodeHDR(texture2D(texture, v_Texcoord));\n#ifdef ANTI_FLICKER\n vec3 d = 1.0 / textureSize.xyx * vec3(1.0, 1.0, 0.0);\n vec4 s1 = decodeHDR(texture2D(texture, v_Texcoord - d.xz));\n vec4 s2 = decodeHDR(texture2D(texture, v_Texcoord + d.xz));\n vec4 s3 = decodeHDR(texture2D(texture, v_Texcoord - d.zy));\n vec4 s4 = decodeHDR(texture2D(texture, v_Texcoord + d.zy));\n texel = median(median(texel, s1, s2), s3, s4);\n#endif\n float lum = dot(texel.rgb , lumWeight);\n vec4 color;\n if (lum > threshold && texel.a > 0.0)\n {\n color = vec4(texel.rgb * scale, texel.a * scale);\n }\n else\n {\n color = vec4(0.0);\n }\n gl_FragColor = encodeHDR(color);\n}\n@end\n"},function(e,t,n){"use strict";t.a="@export qtek.compositor.downsample\nuniform sampler2D texture;\nuniform vec2 textureSize : [512, 512];\nvarying vec2 v_Texcoord;\n@import qtek.util.rgbm\nfloat brightness(vec3 c)\n{\n return max(max(c.r, c.g), c.b);\n}\n@import qtek.util.clamp_sample\nvoid main()\n{\n vec4 d = vec4(-1.0, -1.0, 1.0, 1.0) / textureSize.xyxy;\n#ifdef ANTI_FLICKER\n vec3 s1 = decodeHDR(clampSample(texture, v_Texcoord + d.xy)).rgb;\n vec3 s2 = decodeHDR(clampSample(texture, v_Texcoord + d.zy)).rgb;\n vec3 s3 = decodeHDR(clampSample(texture, v_Texcoord + d.xw)).rgb;\n vec3 s4 = decodeHDR(clampSample(texture, v_Texcoord + d.zw)).rgb;\n float s1w = 1.0 / (brightness(s1) + 1.0);\n float s2w = 1.0 / (brightness(s2) + 1.0);\n float s3w = 1.0 / (brightness(s3) + 1.0);\n float s4w = 1.0 / (brightness(s4) + 1.0);\n float oneDivideSum = 1.0 / (s1w + s2w + s3w + s4w);\n vec4 color = vec4(\n (s1 * s1w + s2 * s2w + s3 * s3w + s4 * s4w) * oneDivideSum,\n 1.0\n );\n#else\n vec4 color = decodeHDR(clampSample(texture, v_Texcoord + d.xy));\n color += decodeHDR(clampSample(texture, v_Texcoord + d.zy));\n color += decodeHDR(clampSample(texture, v_Texcoord + d.xw));\n color += decodeHDR(clampSample(texture, v_Texcoord + d.zw));\n color *= 0.25;\n#endif\n gl_FragColor = encodeHDR(color);\n}\n@end"},function(e,t,n){"use strict";t.a="\n@export qtek.compositor.upsample\n#define HIGH_QUALITY\nuniform sampler2D texture;\nuniform vec2 textureSize : [512, 512];\nuniform float sampleScale: 0.5;\nvarying vec2 v_Texcoord;\n@import qtek.util.rgbm\n@import qtek.util.clamp_sample\nvoid main()\n{\n#ifdef HIGH_QUALITY\n vec4 d = vec4(1.0, 1.0, -1.0, 0.0) / textureSize.xyxy * sampleScale;\n vec4 s;\n s = decodeHDR(clampSample(texture, v_Texcoord - d.xy));\n s += decodeHDR(clampSample(texture, v_Texcoord - d.wy)) * 2.0;\n s += decodeHDR(clampSample(texture, v_Texcoord - d.zy));\n s += decodeHDR(clampSample(texture, v_Texcoord + d.zw)) * 2.0;\n s += decodeHDR(clampSample(texture, v_Texcoord )) * 4.0;\n s += decodeHDR(clampSample(texture, v_Texcoord + d.xw)) * 2.0;\n s += decodeHDR(clampSample(texture, v_Texcoord + d.zy));\n s += decodeHDR(clampSample(texture, v_Texcoord + d.wy)) * 2.0;\n s += decodeHDR(clampSample(texture, v_Texcoord + d.xy));\n gl_FragColor = encodeHDR(s / 16.0);\n#else\n vec4 d = vec4(-1.0, -1.0, +1.0, +1.0) / textureSize.xyxy;\n vec4 s;\n s = decodeHDR(clampSample(texture, v_Texcoord + d.xy));\n s += decodeHDR(clampSample(texture, v_Texcoord + d.zy));\n s += decodeHDR(clampSample(texture, v_Texcoord + d.xw));\n s += decodeHDR(clampSample(texture, v_Texcoord + d.zw));\n gl_FragColor = encodeHDR(s / 4.0);\n#endif\n}\n@end"},function(e,t,n){"use strict";t.a="@export qtek.compositor.hdr.composite\nuniform sampler2D texture;\n#ifdef BLOOM_ENABLED\nuniform sampler2D bloom;\n#endif\n#ifdef LENSFLARE_ENABLED\nuniform sampler2D lensflare;\nuniform sampler2D lensdirt;\n#endif\n#ifdef LUM_ENABLED\nuniform sampler2D lum;\n#endif\n#ifdef LUT_ENABLED\nuniform sampler2D lut;\n#endif\n#ifdef COLOR_CORRECTION\nuniform float brightness : 0.0;\nuniform float contrast : 1.0;\nuniform float saturation : 1.0;\n#endif\n#ifdef VIGNETTE\nuniform float vignetteDarkness: 1.0;\nuniform float vignetteOffset: 1.0;\n#endif\nuniform float exposure : 1.0;\nuniform float bloomIntensity : 0.25;\nuniform float lensflareIntensity : 1;\nvarying vec2 v_Texcoord;\n@import qtek.util.srgb\nvec3 ACESToneMapping(vec3 color)\n{\n const float A = 2.51;\n const float B = 0.03;\n const float C = 2.43;\n const float D = 0.59;\n const float E = 0.14;\n return (color * (A * color + B)) / (color * (C * color + D) + E);\n}\nfloat eyeAdaption(float fLum)\n{\n return mix(0.2, fLum, 0.5);\n}\n#ifdef LUT_ENABLED\nvec3 lutTransform(vec3 color) {\n float blueColor = color.b * 63.0;\n vec2 quad1;\n quad1.y = floor(floor(blueColor) / 8.0);\n quad1.x = floor(blueColor) - (quad1.y * 8.0);\n vec2 quad2;\n quad2.y = floor(ceil(blueColor) / 8.0);\n quad2.x = ceil(blueColor) - (quad2.y * 8.0);\n vec2 texPos1;\n texPos1.x = (quad1.x * 0.125) + 0.5/512.0 + ((0.125 - 1.0/512.0) * color.r);\n texPos1.y = (quad1.y * 0.125) + 0.5/512.0 + ((0.125 - 1.0/512.0) * color.g);\n vec2 texPos2;\n texPos2.x = (quad2.x * 0.125) + 0.5/512.0 + ((0.125 - 1.0/512.0) * color.r);\n texPos2.y = (quad2.y * 0.125) + 0.5/512.0 + ((0.125 - 1.0/512.0) * color.g);\n vec4 newColor1 = texture2D(lut, texPos1);\n vec4 newColor2 = texture2D(lut, texPos2);\n vec4 newColor = mix(newColor1, newColor2, fract(blueColor));\n return newColor.rgb;\n}\n#endif\n@import qtek.util.rgbm\nvoid main()\n{\n vec4 texel = vec4(0.0);\n vec4 originalTexel = vec4(0.0);\n#ifdef TEXTURE_ENABLED\n texel = decodeHDR(texture2D(texture, v_Texcoord));\n originalTexel = texel;\n#endif\n#ifdef BLOOM_ENABLED\n vec4 bloomTexel = decodeHDR(texture2D(bloom, v_Texcoord));\n texel.rgb += bloomTexel.rgb * bloomIntensity;\n texel.a += bloomTexel.a * bloomIntensity;\n#endif\n#ifdef LENSFLARE_ENABLED\n texel += decodeHDR(texture2D(lensflare, v_Texcoord)) * texture2D(lensdirt, v_Texcoord) * lensflareIntensity;\n#endif\n texel.a = min(texel.a, 1.0);\n#ifdef LUM_ENABLED\n float fLum = texture2D(lum, vec2(0.5, 0.5)).r;\n float adaptedLumDest = 3.0 / (max(0.1, 1.0 + 10.0*eyeAdaption(fLum)));\n float exposureBias = adaptedLumDest * exposure;\n#else\n float exposureBias = exposure;\n#endif\n texel.rgb *= exposureBias;\n texel.rgb = ACESToneMapping(texel.rgb);\n texel = linearTosRGB(texel);\n#ifdef LUT_ENABLED\n texel.rgb = lutTransform(clamp(texel.rgb,vec3(0.0),vec3(1.0)));\n#endif\n#ifdef COLOR_CORRECTION\n texel.rgb = clamp(texel.rgb + vec3(brightness), 0.0, 1.0);\n texel.rgb = clamp((texel.rgb - vec3(0.5))*contrast+vec3(0.5), 0.0, 1.0);\n float lum = dot(texel.rgb, vec3(0.2125, 0.7154, 0.0721));\n texel.rgb = mix(vec3(lum), texel.rgb, saturation);\n#endif\n#ifdef VIGNETTE\n vec2 uv = (v_Texcoord - vec2(0.5)) * vec2(vignetteOffset);\n texel.rgb = mix(texel.rgb, vec3(1.0 - vignetteDarkness), dot(uv, uv));\n#endif\n gl_FragColor = encodeHDR(texel);\n#ifdef DEBUG\n #if DEBUG == 1\n gl_FragColor = encodeHDR(decodeHDR(texture2D(texture, v_Texcoord)));\n #elif DEBUG == 2\n gl_FragColor = encodeHDR(decodeHDR(texture2D(bloom, v_Texcoord)) * bloomIntensity);\n #elif DEBUG == 3\n gl_FragColor = encodeHDR(decodeHDR(texture2D(lensflare, v_Texcoord) * lensflareIntensity));\n #endif\n#endif\n if (originalTexel.a <= 0.01) {\n gl_FragColor.a = dot(gl_FragColor.rgb, vec3(0.2125, 0.7154, 0.0721));\n }\n#ifdef PREMULTIPLY_ALPHA\n gl_FragColor.rgb *= gl_FragColor.a;\n#endif\n}\n@end"},function(e,t,n){"use strict";t.a="@export qtek.compositor.blend\n#ifdef TEXTURE1_ENABLED\nuniform sampler2D texture1;\nuniform float weight1 : 1.0;\n#endif\n#ifdef TEXTURE2_ENABLED\nuniform sampler2D texture2;\nuniform float weight2 : 1.0;\n#endif\n#ifdef TEXTURE3_ENABLED\nuniform sampler2D texture3;\nuniform float weight3 : 1.0;\n#endif\n#ifdef TEXTURE4_ENABLED\nuniform sampler2D texture4;\nuniform float weight4 : 1.0;\n#endif\n#ifdef TEXTURE5_ENABLED\nuniform sampler2D texture5;\nuniform float weight5 : 1.0;\n#endif\n#ifdef TEXTURE6_ENABLED\nuniform sampler2D texture6;\nuniform float weight6 : 1.0;\n#endif\nvarying vec2 v_Texcoord;\n@import qtek.util.rgbm\nvoid main()\n{\n vec4 tex = vec4(0.0);\n#ifdef TEXTURE1_ENABLED\n tex += decodeHDR(texture2D(texture1, v_Texcoord)) * weight1;\n#endif\n#ifdef TEXTURE2_ENABLED\n tex += decodeHDR(texture2D(texture2, v_Texcoord)) * weight2;\n#endif\n#ifdef TEXTURE3_ENABLED\n tex += decodeHDR(texture2D(texture3, v_Texcoord)) * weight3;\n#endif\n#ifdef TEXTURE4_ENABLED\n tex += decodeHDR(texture2D(texture4, v_Texcoord)) * weight4;\n#endif\n#ifdef TEXTURE5_ENABLED\n tex += decodeHDR(texture2D(texture5, v_Texcoord)) * weight5;\n#endif\n#ifdef TEXTURE6_ENABLED\n tex += decodeHDR(texture2D(texture6, v_Texcoord)) * weight6;\n#endif\n gl_FragColor = encodeHDR(tex);\n}\n@end"},function(e,t,n){"use strict";t.a="@export qtek.compositor.fxaa\nuniform sampler2D texture;\nuniform vec4 viewport : VIEWPORT;\nvarying vec2 v_Texcoord;\n#define FXAA_REDUCE_MIN (1.0/128.0)\n#define FXAA_REDUCE_MUL (1.0/8.0)\n#define FXAA_SPAN_MAX 8.0\n@import qtek.util.rgbm\nvoid main()\n{\n vec2 resolution = 1.0 / viewport.zw;\n vec3 rgbNW = decodeHDR( texture2D( texture, ( gl_FragCoord.xy + vec2( -1.0, -1.0 ) ) * resolution ) ).xyz;\n vec3 rgbNE = decodeHDR( texture2D( texture, ( gl_FragCoord.xy + vec2( 1.0, -1.0 ) ) * resolution ) ).xyz;\n vec3 rgbSW = decodeHDR( texture2D( texture, ( gl_FragCoord.xy + vec2( -1.0, 1.0 ) ) * resolution ) ).xyz;\n vec3 rgbSE = decodeHDR( texture2D( texture, ( gl_FragCoord.xy + vec2( 1.0, 1.0 ) ) * resolution ) ).xyz;\n vec4 rgbaM = decodeHDR( texture2D( texture, gl_FragCoord.xy * resolution ) );\n vec3 rgbM = rgbaM.xyz;\n float opacity = rgbaM.w;\n vec3 luma = vec3( 0.299, 0.587, 0.114 );\n float lumaNW = dot( rgbNW, luma );\n float lumaNE = dot( rgbNE, luma );\n float lumaSW = dot( rgbSW, luma );\n float lumaSE = dot( rgbSE, luma );\n float lumaM = dot( rgbM, luma );\n float lumaMin = min( lumaM, min( min( lumaNW, lumaNE ), min( lumaSW, lumaSE ) ) );\n float lumaMax = max( lumaM, max( max( lumaNW, lumaNE) , max( lumaSW, lumaSE ) ) );\n vec2 dir;\n dir.x = -((lumaNW + lumaNE) - (lumaSW + lumaSE));\n dir.y = ((lumaNW + lumaSW) - (lumaNE + lumaSE));\n float dirReduce = max( ( lumaNW + lumaNE + lumaSW + lumaSE ) * ( 0.25 * FXAA_REDUCE_MUL ), FXAA_REDUCE_MIN );\n float rcpDirMin = 1.0 / ( min( abs( dir.x ), abs( dir.y ) ) + dirReduce );\n dir = min( vec2( FXAA_SPAN_MAX, FXAA_SPAN_MAX),\n max( vec2(-FXAA_SPAN_MAX, -FXAA_SPAN_MAX),\n dir * rcpDirMin)) * resolution;\n vec3 rgbA = decodeHDR( texture2D( texture, gl_FragCoord.xy * resolution + dir * ( 1.0 / 3.0 - 0.5 ) ) ).xyz;\n rgbA += decodeHDR( texture2D( texture, gl_FragCoord.xy * resolution + dir * ( 2.0 / 3.0 - 0.5 ) ) ).xyz;\n rgbA *= 0.5;\n vec3 rgbB = decodeHDR( texture2D( texture, gl_FragCoord.xy * resolution + dir * -0.5 ) ).xyz;\n rgbB += decodeHDR( texture2D( texture, gl_FragCoord.xy * resolution + dir * 0.5 ) ).xyz;\n rgbB *= 0.25;\n rgbB += rgbA * 0.5;\n float lumaB = dot( rgbB, luma );\n if ( ( lumaB < lumaMin ) || ( lumaB > lumaMax ) )\n {\n gl_FragColor = vec4( rgbA, opacity );\n }\n else {\n gl_FragColor = vec4( rgbB, opacity );\n }\n}\n@end"},function(e,t,n){"use strict";function a(e,t){var n=new s;return r.a.get({url:e,responseType:t,onload:function(e){n.resolve(e)},onerror:function(e){n.reject(e)}}),n}var i=n(22),r=n(25),o=n(11),s=function(){this._fullfilled=!1,this._rejected=!1};s.prototype.resolve=function(e){this._fullfilled=!0,this._rejected=!1,this.trigger("success",e)},s.prototype.reject=function(e){this._rejected=!0,this._fullfilled=!1,this.trigger("error",e)},s.prototype.isFullfilled=function(){return this._fullfilled},s.prototype.isRejected=function(){return this._rejected},s.prototype.isSettled=function(){return this._fullfilled||this._rejected},o.a.extend(s.prototype,i.a),s.makeRequestTask=function(e,t){if("string"==typeof e)return a(e,t);if(e.url){var n=e;return a(n.url,n.responseType)}if(Array.isArray(e)){var i=e,r=[];return i.forEach(function(e){var t,n;"string"==typeof e?t=e:Object(e)===e&&(t=e.url,n=e.responseType),r.push(a(t,n))}),r}},s.makeTask=function(){return new s},o.a.extend(s.prototype,i.a),t.a=s},function(e,t,n){"use strict";var a=n(14),i=n(2),r=a.a.extend({shadowBias:.001,shadowSlopeScale:2,shadowCascade:1,cascadeSplitLogFactor:.2},{type:"DIRECTIONAL_LIGHT",uniformTemplates:{directionalLightDirection:{type:"3f",value:function(e){return e.__dir=e.__dir||new i.a,e.__dir.copy(e.worldTransform.z).normalize().negate()._array}},directionalLightColor:{type:"3f",value:function(e){var t=e.color,n=e.intensity;return[t[0]*n,t[1]*n,t[2]*n]}}},clone:function(){var e=a.a.prototype.clone.call(this);return e.shadowBias=this.shadowBias,e.shadowSlopeScale=this.shadowSlopeScale,e}});t.a=r},function(e,t,n){"use strict";function a(e){c.a.defaultsWithPropList(e,u,p),i(e);for(var t="",n=0;n=this._maxSize&&o>0){var c=n.head;n.remove(c),delete a[c.key],i=c.value,this._lastRemovedEntry=c}s?s.value=t:s=new r(t),s.key=e,n.insertEntry(s),a[e]=s}return i},s.get=function(e){var t=this._map[e],n=this._list;if(null!=t)return t!==n.tail&&(n.remove(t),n.insertEntry(t)),t.value},s.clear=function(){this._list.clear(),this._map={}},t.a=o},function(e,t,n){"use strict";function a(){document.getElementById("timeline").style.display="block"}function i(){document.getElementById("timeline").style.display="none",c()}function r(e){if(u=e,l=Math.floor(e.getAnimationDuration()),l>0?a():i(),!(l<=0)){var t=document.getElementById("timeline-pause-resume");t.removeEventListener("click",d),t.addEventListener("click",d=function(){f?c():s(n)}),m=0,h=0,o();var n=Math.random();p=n,l>0?s(n):c();var r=null;if(!$("#timeline-progress input").data("ionRangeSlider")){$("#timeline-progress input").ionRangeSlider({from_shadow:!0,force_edges:!0,onChange:function(e){h=e.from,u.setPose(h),null==r&&(r=f),c()},onFinish:function(){r&&s(n),r=null}}),$("#timeline-range input").ionRangeSlider({from_shadow:!0,force_edges:!0,type:"double",drag_interval:!0,grid:!0,grid_num:10,onChange:function(e){l=e.to-e.from,m=e.from,h=Math.min(Math.max(e.from,h),e.to),u.setPose(h),v.update({from_min:e.from,from_max:e.to})}});var v=$("#timeline-progress input").data("ionRangeSlider"),_=$("#timeline-range input").data("ionRangeSlider");v.update({min:0,max:l,from:h,from_min:0,from_max:l}),_.update({min:0,max:l,from:0,to:l})}}}function o(){var e=$("#timeline-progress input").data("ionRangeSlider");e&&e.update({from:h})}function s(e){function t(){if(f&&e===p){u.setPose(h);var a=Math.min(Date.now()-n,20);n=Date.now(),o(),h+=a,h>m+l&&(h=m),requestAnimationFrame(t)}}if(!f){f=!0;var n=Date.now(),a=document.getElementById("timeline-pause-resume");a.classList.remove("icon-resume"),a.classList.add("icon-pause"),requestAnimationFrame(t)}}function c(){if(f){f=!1;var e=document.getElementById("timeline-pause-resume");e.classList.remove("icon-pause"),e.classList.add("icon-resume")}}n.d(t,"b",function(){return r}),n.d(t,"a",function(){return i});var l,u,p,d,f=!1,h=0,m=0},function(e,t,n){"use strict";function a(){["mainLight","secondaryLight","tertiaryLight"].forEach(function(e){z[e].alpha=90*z[e].$padAngle[1],z[e].beta=180*z[e].$padAngle[0]}),S.setMainLight(z.mainLight),S.setSecondaryLight(z.secondaryLight),S.setTertiaryLight(z.tertiaryLight),S.setAmbientLight(z.ambientLight)}function i(){S.setPostEffect(z.postEffect)}function r(){z.ambientCubemapLight.texture=O.a.ENV_TEXTURE_ROOT+z.ambientCubemapLight.$texture+".hdr",z.ambientCubemapLight.diffuseIntensity=z.ambientCubemapLight.specularIntensity=z.ambientCubemapLight.$intensity,S.setAmbientCubemapLight(z.ambientCubemapLight)}function o(){S.setGround(z.ground)}function s(){a(),i(),r(),o()}function c(){var e=Math.max(j.$textureTiling,.01);j.uvRepeat=[e,e],j.transparent=j.alpha<1,S.setMaterial(j.name,j)}function l(e){j.name=e.name;var t=S.getMaterial(e.name);t.$textureTiling=t.uvRepeat[0],k.a.extend(j,t),null==t.specularColor?(N.enable(),C.disable()):(C.enable(),N.disable()),q.update()}function u(e){return e&&"none"!==e}function p(e,t,n){var a=!1;u(n)&&([["diffuseMap","color","#fff"],["metalnessMap","metalness",.5],["roughnessMap","roughness",.5],["glossinessMap","glossiness",.5],["specularMap","specularColor","#fff"],["emissiveMap","emission","#fff"]].forEach(function(t){e===t[0]&&(console.warn("Force %s to be %s after set %s",t[1],t[2],t[0]),j[t[1]]=t[2],a=!0)},this),_(),O.a.AUTO_SAVE&&I.g(t).then(g).catch(g),R[n]=t.name,a&&q.update()),c()}function d(){document.getElementById("tip").style.display="block"}function f(){document.getElementById("tip").style.display="none"}function h(){S=new L.a.Viewer(document.getElementById("viewport"),z),S.enablePicking(),S.setCameraControl(z.viewControl),S.start(),S.on("select",function(e){S.refresh(),l(e.target.material),M=e.target}),S.on("doffocus",function(e){z.postEffect.depthOfField.enable&&(z.postEffect.depthOfField.focalDistance=e.distance,q.update())}),S.on("unselect",function(){S.refresh(),N.disable(),C.disable(),M=null}),S.on("afterrender",function(e,t,n){M&&Object(H.a)(S,[M],n)}),S.on("updatecamera",function(e){z.viewControl={center:e.center,alpha:e.alpha,beta:e.beta,distance:e.distance}})}function m(e){document.body.appendChild(G),G.querySelector("#loading-text").innerHTML=e||"LOADING"}function v(){G.parentNode.removeChild(G)}function _(){W.style.display="block",W.querySelector("#background-progress-text").innerHTML="Saving...DONT close the page."}function x(){W.style.display="block",W.querySelector("#background-progress-text").innerHTML="Preparing for download...DONT close the page."}function g(){W.style.display="none"}function y(){v(),document.getElementById("toolbar").style.display="block",document.getElementById("reset").addEventListener("click",T),document.getElementById("download").addEventListener("click",E),h(),FileAPI.event.dnd(document.getElementById("main"),function(e){},function(e){m("Loading model"),U.a(),I.a(e).then(function(e){var t=e.glTF,n=e.filesMap,a=e.buffers,i=e.allFiles;R={};for(var r in n)R[n[r]]=r;var o=!(!t.extras||!t.extras.qtekModelViewerConfig);o&&(F.merge(z,t.extras.qtekModelViewerConfig,!0),S.setCameraControl(z.viewControl),s(),q.update()),S.loadModel(t,{files:n,buffers:a,textureFlipY:z.textureFlipY,doubleSided:!0,upAxis:z.zUpToYUp?"z":"y",includeTexture:!o}).on("ready",function(){f(),v(),o&&(t.extras.qtekModelViewerConfig.materials||[]).forEach(function(e){for(var t in e)n[e[t]]&&(e[t]=n[e[t]]);S.setMaterial(e.name,e)}),setTimeout(function(){_(),O.a.AUTO_SAVE&&I.e(i).then(g).catch(g)},200)}).on("loadmodel",w).on("error",function(){v(),swal("Model load error")}),N.disable(),C.disable()}).catch(function(e){v(),S.getModelRoot()||d(),Object(U.b)(S),console.log(e),swal(e.toString())})}),b(),V=!0}function b(){function e(e){return R&&R[e]}function t(t){t.addStringOutput(j,"name",{label:"Name"}).addColor(j,"color",{label:"Base Color",onChange:c}).addSlider(j,"alpha","$alphaRange",{label:"Alpha",onChange:c}).addSlider(j,"alphaCutoff","$alphaCutoffRange",{label:"Alpha Cutoff",onChange:c}).addNumberInput(j,"$textureTiling",{label:"Tiling",onChange:c,step:.5}).addCustomComponent(B.a,j,"diffuseMap",{label:"Base Map",onChange:p.bind(null,"diffuseMap"),getFileName:e}).addCustomComponent(B.a,j,"normalMap",{label:"Normal/Bump Map",onChange:p.bind(null,"normalMap"),getFileName:e})}function n(t){t.addCustomComponent(B.a,j,"parallaxOcclusionMap",{label:"Parallax Occlusion Map",onChange:p.bind(null,"parallaxOcclusionMap"),getFileName:e}).addSlider(j,"parallaxOcclusionScale","$parallaxOcclusionScaleRange",{label:"Scale",onChange:c}).addColor(j,"emission",{label:"Emission",onChange:c}).addNumberInput(j,"emissionIntensity",{label:"Emission Intensity",onChange:c}).addCustomComponent(B.a,j,"emissiveMap",{label:"Emissive Map",onChange:p.bind(null,"emissiveMap"),getFileName:e})}A=q.addPanel({label:"Settings",width:250}),A.addGroup({label:"Global"}).addSubGroup({label:"Load Option"}).addCheckbox(z,"textureFlipY",{label:"Flip Texture",onChange:function(){S.setTextureFlipY(z.textureFlipY)}}).addCheckbox(z,"zUpToYUp",{label:"Z Up",onChange:function(){S.setModelUpAxis(z.zUpToYUp?"Z":"Y")}}).addSubGroup({label:"Ground"}).addCheckbox(z.ground,"show",{label:"Show",onChange:o}),A.addGroup({label:"Environment",enable:!1}).addSelect(z.ambientCubemapLight,"$textureOptions",{label:"HDR Texture",onChange:r,target:"$texture"}).addNumberInput(z.ambientCubemapLight,"$intensity",{label:"Intensity",onChange:r,step:.1}),A.addGroup({label:"Light",enable:!1}).addSubGroup({label:"Main",enable:!1}).addCheckbox(z.mainLight,"shadow",{label:"Cast Shadow",onChange:a}).addNumberInput(z.mainLight,"intensity",{label:"Intensity",step:.1,onChange:a}).addColor(z.mainLight,"color",{label:"Color",onChange:a}).addPad(z.mainLight,"$padAngle",{label:"Direction",onChange:a}).addSubGroup({label:"Secondary",enable:!1}).addNumberInput(z.secondaryLight,"intensity",{label:"Intensity",step:.1,onChange:a}).addColor(z.secondaryLight,"color",{label:"Color",onChange:a}).addPad(z.secondaryLight,"$padAngle",{label:"Direction",onChange:a}).addSubGroup({label:"Tertiary",enable:!1}).addNumberInput(z.tertiaryLight,"intensity",{label:"Intensity",step:.1,onChange:a}).addColor(z.tertiaryLight,"color",{label:"Color",onChange:a}).addPad(z.tertiaryLight,"$padAngle",{label:"Direction",onChange:a}).addSubGroup({label:"Ambient",enable:!1}).addNumberInput(z.ambientLight,"intensity",{label:"Intensity",step:.1,onChange:a}).addColor(z.ambientLight,"color",{label:"Color",onChange:a}),A.addGroup({label:"Post Effect",enable:!1}).addCheckbox(z.postEffect,"enable",{label:"Enable",onChange:i}).addSubGroup({label:"Bloom",enable:!1}).addCheckbox(z.postEffect.bloom,"enable",{label:"Enable",onChange:i}).addNumberInput(z.postEffect.bloom,"intensity",{label:"Intensity",step:.1,onChange:i}).addSubGroup({label:"Screen Space Ambient Occulusion",enable:!1}).addCheckbox(z.postEffect.screenSpaceAmbientOcclusion,"enable",{label:"Enable",onChange:i}).addNumberInput(z.postEffect.screenSpaceAmbientOcclusion,"radius",{label:"Radius",step:.1,onChange:i}).addNumberInput(z.postEffect.screenSpaceAmbientOcclusion,"intensity",{label:"Intensity",step:.1,onChange:i}).addSelect(z.postEffect.screenSpaceAmbientOcclusion,"$qualityOptions",{label:"Quality",onChange:i,target:"quality"}).addSubGroup({label:"Screen Space Reflection",enable:!1}).addCheckbox(z.postEffect.screenSpaceReflection,"enable",{label:"Enable",onChange:i}).addNumberInput(z.postEffect.screenSpaceReflection,"maxRoughness",{label:"Max Roughness",step:.01,onChange:i}).addSelect(z.postEffect.screenSpaceReflection,"$qualityOptions",{label:"Quality",onChange:i,target:"quality"}).addSubGroup({label:"Depth of Field",enable:!1}).addCheckbox(z.postEffect.depthOfField,"enable",{label:"Enable",onChange:i}).addNumberInput(z.postEffect.depthOfField,"fstop",{label:"f-stop",step:.1,onChange:i}).addNumberInput(z.postEffect.depthOfField,"focalDistance",{label:"Focal Distance",step:.1,onChange:i}).addNumberInput(z.postEffect.depthOfField,"focalRange",{label:"Focal Range",step:.1,onChange:i}).addNumberInput(z.postEffect.depthOfField,"blurRadius",{label:"Blur Radius",step:.1,onChange:i}).addSelect(z.postEffect.depthOfField,"$qualityOptions",{label:"Quality",onChange:i,target:"quality"}).addSubGroup({label:"Color Correction",enable:!1}).addNumberInput(z.postEffect.colorCorrection,"exposure",{label:"Exposure",step:.1,onChange:i}).addNumberInput(z.postEffect.colorCorrection,"brightness",{label:"Brightness",step:.1,onChange:i}).addNumberInput(z.postEffect.colorCorrection,"contrast",{label:"Contrast",step:.1,onChange:i}).addNumberInput(z.postEffect.colorCorrection,"saturation",{label:"Saturation",step:.1,onChange:i}),N=q.addPanel({label:"Material - Metalllic Roughness",width:240,fixed:!1,align:"left",position:[10,10]}),t(N),N.addCustomComponent(B.a,j,"metalnessMap",{label:"Metalness Map",onChange:p.bind(null,"metalnessMap"),getFileName:e}).addSlider(j,"metalness","$metalnessRange",{label:"Metalness",onChange:c}).addCustomComponent(B.a,j,"roughnessMap",{label:"Roughness Map",onChange:p.bind(null,"roughnessMap"),getFileName:e}).addSlider(j,"roughness","$roughnessRange",{label:"Roughness",onChange:c}),n(N),N.disable(),C=q.addPanel({label:"Material - Specular Glossiness",width:240,fixed:!1,align:"left",position:[10,10]}),t(C),C.addCustomComponent(B.a,j,"specularMap",{label:"Specular Map",onChange:p.bind(null,"specularMap"),getFileName:e}).addColor(j,"specularColor",{label:"Specular Factor",onChange:c}).addCustomComponent(B.a,j,"glossinessMap",{label:"Glossiness Map",onChange:p.bind(null,"glossinessMap"),getFileName:e}).addSlider(j,"glossiness","$glossinessRange",{label:"Glossiness",onChange:c}),n(C),C.disable()}function T(){swal({title:"Reset?",text:"Reset the viewer",type:"warning",showCancelButton:!0,confirmButtonColor:"#3085d6",cancelButtonColor:"#d33",confirmButtonText:"Yes!"}).then(function(){F.merge(z,Object(D.a)(),!0),F.merge(j,Object(P.a)(),!0),q.update(),N.disable(),C.disable(),M=null,S.dispose(),h(),I.d(),d(),U.b(S),g()}).catch(function(){})}function E(){swal({title:"Select download format.",input:"radio",inputOptions:{glb:"GLB",zip:"ZIP"}}).then(function(e){x(),I.b(e,g,g)})}function w(){M=null,S.stopAnimation(),U.b(S)}Object.defineProperty(t,"__esModule",{value:!0});var S,A,N,C,M,R,L=n(66),D=n(140),P=n(141),I=n(142),O=n(37),k=n(11),F=n(150),B=(n.n(F),n(151)),U=n(64),H=n(152),z=Object(D.a)(),j=Object(P.a)(),q=new ControlKit({loadAndSave:!0,useExternalStyle:!0}),G=document.getElementById("loading"),W=document.getElementById("background-progress"),V=!1;I.c(function(e,t,n){if(n&&F.merge(z,n,!0),!V)if(y(),e){R={};for(var a in t)R[t[a]]=a;S.loadModel(e,{files:t,textureFlipY:z.textureFlipY,upAxis:z.zUpToYUp?"z":"y",doubleSided:!0,includeTexture:!1}).on("ready",function(){n&&n.materials&&n.materials.forEach(function(e){for(var n in e)t[e[n]]&&(e[n]=t[e[n]]);S.setMaterial(e.name,e)})}).on("loadmodel",w).on("error",function(){d(),swal("Model load error")})}else d()}),setTimeout(function(){V||(console.warn("Init time out"),y())},5e3),setInterval(function(){if(S&&!document.hidden){var e={};z.materials=S.getMaterialsNames().map(function(t){var n=S.getMaterial(t);for(var a in n)R[n[a]]&&(n[a]=R[n[a]]);return n.targetMeshes=[],e[t]=n,n}),S.getModelRoot()&&S.getModelRoot().traverse(function(t){t.material&&e[t.material.name]&&e[t.material.name].targetMeshes.push(t.originalMeshName||t.name)}),_(),O.a.AUTO_SAVE&&I.f(z).then(function(){g(),console.log("Saved")}).catch(g)}},5e3),window.addEventListener("resize",function(){S.resize()}),window.addEventListener("dragover",function(e){e.preventDefault()}),window.addEventListener("drop",function(e){e.preventDefault()})},function(e,t,n){"use strict";var a=n(67);t.a={Viewer:a.a,version:"0.1.0"}},function(e,t,n){"use strict";function a(e,t){t=S.a(t),S.b(t,w.a),this.init(e,t)}var i=n(30),r=n(40),o=n(2),s=n(89),c=n(91),l=n(59),u=n(92),p=n(11),d=n(15),f=n(16),h=n(9),m=n(32),v=n(4),_=n(93),x=n(22),g=n(18),y=n(33),b=n(97),T=n(29),E=n(130),w=n(132),S=n(133),A=n(134),N=n(135),C=n(137),M=n(139);v.a.import(M.a);var R=["diffuseMap","normalMap","emissiveMap","metalnessMap","roughnessMap","specularMap","glossinessMap"];a.prototype.init=function(e,t){t=t||{},this.root=e,this._animation=new s.a;var n=new i.a({devicePixelRatio:t.devicePixelRatio||window.devicePixelRatio});e.appendChild(n.canvas),n.canvas.style.cssText="position:absolute;left:0;top:0",this._renderer=n,this._renderMain=new b.a(n,t.shadow,"perspective"),this._renderMain.afterRenderScene=function(e,t,n){this.trigger("renderscene",e,t,n)}.bind(this),this._renderMain.afterRenderAll=function(e,t,n){this.trigger("afterrender",e,t,n)}.bind(this),this._renderMain.preZ=t.preZ||!1;var a=this._cameraControl=new N.a({renderer:n,animation:this._animation,domElement:e});a.target=this._renderMain.camera,a.init(),this._hotspotManager=new C.a({dom:e,renderer:n,camera:this._renderMain.camera}),this._skeletons=[],this._clips=[],this._takes=[],this._materialsMap={},this._sceneHelper=new E.a(this._renderMain.scene),this._sceneHelper.initLight(this._renderMain.scene),this.resize(),t.postEffect&&this.setPostEffect(t.postEffect),t.mainLight&&this.setMainLight(t.mainLight),t.secondaryLight&&this.setSecondaryLight(t.secondaryLight),t.tertiaryLight&&this.setTertiaryLight(t.tertiaryLight),t.ambientCubemapLight&&this.setAmbientCubemapLight(t.ambientCubemapLight),t.ambientLight&&this.setAmbientLight(t.ambientLight),t.environment&&this.setEnvironment(t.environment),this._createGround(),t.ground&&this.setGround(t.ground),this.setCameraControl({distance:20,minDisntance:2,maxDistance:100,center:[0,0,0]}),this._enablePicking=t.picking||!1,this._initHandlers(),a.on("update",function(){this.trigger("updatecamera",{center:a.getCenter(),alpha:a.getAlpha(),beta:a.getBeta(),distance:a.getDistance()}),this.refresh()},this),this.shaderLibrary=g.a.createLibrary()},a.prototype._createGround=function(){var e=new f.a({isGround:!0,material:new h.a({shader:new v.a({vertex:v.a.source("qmv.ground.vertex"),fragment:v.a.source("qmv.ground.fragment")}),transparent:!0}),castShadow:!1,geometry:new m.a});e.material.set("color",[1,1,1,1]),e.scale.set(40,40,1),e.rotation.rotateX(-Math.PI/2),this._groundMesh=e,this._renderMain.scene.add(e)},a.prototype._addModel=function(e,t,n,a){this.removeModel(),this._renderMain.scene.add(e),this._skeletons=n.slice(),this._modelNode=e,this._setAnimationClips(a),t&&t.length&&(this._nodes=t);var i={};e.traverse(function(e){if(e.material){var t=e.material;i[t.name]=i[t.name]||[],i[t.name].push(t)}},this),this._materialsMap=i,this._updateMaterialsSRGB(),this._stopAccumulating()},a.prototype._removeAnimationClips=function(){this._clips.forEach(function(e){this._animation.removeClip(e)},this),this._clips=[],this._takes=[]},a.prototype._setAnimationClips=function(e){function t(){n.refresh()}var n=this;e.forEach(function(e){e.tracks.forEach(function(e){e.target||(e.target=this._nodes[e.targetNodeIndex])},this),e.onframe=t,this._animation.addClip(e),this._takes.push({name:e.name,range:[0,e.life],clip:e})},this),this._clips=e.slice()},a.prototype._initHandlers=function(){this._picking=new _.a({renderer:this._renderer,scene:this._renderMain.scene,camera:this._renderMain.camera}),this._clickHandler=this._clickHandler.bind(this),this._mouseDownHandler=this._mouseDownHandler.bind(this),this.root.addEventListener("mousedown",this._mouseDownHandler),this.root.addEventListener("click",this._clickHandler)},a.prototype._mouseDownHandler=function(e){this._startX=e.clientX,this._startY=e.clientY},a.prototype._clickHandler=function(e){if(this._enablePicking||this._renderMain.isDOFEnabled()){var t=e.clientX-this._startX,n=e.clientY-this._startY;if(!(Math.sqrt(t*t+n*n)>=40)){var a=this._picking.pick(e.clientX,e.clientY,!0);a&&!a.target.isGround?(this._renderMain.setDOFFocusOnPoint(a.distance),this.trigger("doffocus",a),this._selectResult=a,this.trigger("select",a),this.refresh()):(this._selectResult&&this.trigger("unselect",this._selectResult),this._selectResult=null)}}},a.prototype.enablePicking=function(){this._enablePicking=!0},a.prototype.disablePicking=function(){this._enablePicking=!1},a.prototype.setModelUpAxis=function(e){var t=this._modelNode;t&&(t.position.set(0,0,0),t.scale.set(1,1,1),t.rotation.identity(),"z"===e.toLowerCase()&&t.rotation.identity().rotateX(-Math.PI/2),this.autoFitModel())},a.prototype.setTextureFlipY=function(e){if(this._modelNode){for(var t in this._materialsMap)for(var n=0;n1||o<0){n=!0;break}}if(n)for(var a=0;a=0&&s.splice(a,1),c[e]=null}}t=t||{};var i=this._materialsMap[e],r=this,o=this._textureFlipY;if(!i||!i.length)return void console.warn("Material %s not exits",e);var s=i[0].shader.getEnabledTextures(),c={};["diffuseMap","normalMap","parallaxOcclusionMap","emissiveMap"].forEach(function(e){a(e)},this),i[0].shader.isDefined("fragment","USE_METALNESS")?["metalnessMap","roughnessMap"].forEach(function(e){a(e)},this):["specularMap","glossinessMap"].forEach(function(e){a(e)},this),(c.normalMap||c.parallaxOcclusionMap)&&this._modelNode.traverse(function(t){t.material&&t.material.name===e&&(t.geometry.attributes.tangent.value||t.geometry.generateTangents())}),i.forEach(function(e){null!=t.transparent&&(e.transparent=!!t.transparent,e.depthMask=!t.transparent),["color","emission","specularColor"].forEach(function(n){null!=t[n]&&e.set(n,T.a.parseColor(t[n]))}),["alpha","alphaCutoff","metalness","roughness","glossiness","emissionIntensity","uvRepeat","parallaxOcclusionScale"].forEach(function(n){null!=t[n]&&e.set(n,t[n])});for(var n in c)e.set(n,c[n]);e.attachShader(this.shaderLibrary.get("qtek."+(this._shaderName||"standard"),{fragmentDefines:e.shader.fragmentDefines,textures:s,vertexDefines:e.shader.vertexDefines,precision:e.shader.precision}),!0)},this),this.refresh()},a.prototype.getMaterial=function(e){function t(e){var t=a.get(e);if(!t)return"";for(var n=t.image;n.srcImage;)n=n.srcImage;return n&&n.src||""}var n=this._materialsMap[e];if(!n)return void console.warn("Material %s not exits",e);var a=n[0],i={name:e};return["color","emission"].forEach(function(e){i[e]=T.a.stringifyColor(a.get(e),"hex")}),["alpha","alphaCutoff","emissionIntensity","uvRepeat","parallaxOcclusionScale"].forEach(function(e){i[e]=a.get(e)}),["diffuseMap","normalMap","parallaxOcclusionMap","emissiveMap"].forEach(function(e){i[e]=t(e)}),a.shader.isDefined("fragment","USE_METALNESS")?(["metalness","roughness"].forEach(function(e){i[e]=a.get(e)}),["metalnessMap","roughnessMap"].forEach(function(e){i[e]=t(e)}),i.type="pbrMetallicRoughness"):(i.specularColor=T.a.stringifyColor(a.get("specularColor"),"hex"),i.glossiness=a.get("glossiness"),["specularMap","glossinessMap"].forEach(function(e){i[e]=t(e)}),i.type="pbrSpecularGlossiness"),i},a.prototype.setGround=function(e){this._groundMesh.invisible=!e.show,this.refresh()},a.prototype.getMaterialsNames=function(){return Object.keys(this._materialsMap)},a.prototype.setPostEffect=function(e){this._renderMain.setPostEffect(e),this._updateMaterialsSRGB(),this.refresh()},a.prototype.start=function(){if(this._disposed)return void console.warn("Viewer already disposed");this._animation.start(),this._animation.on("frame",this._loop,this)},a.prototype.stop=function(){this._animation.stop(),this._animation.off("frame",this._loop)},a.prototype.addHotspot=function(e,t){return this._hotspotManager.add(e,t)},a.prototype.setPose=function(e){this._clips.forEach(function(t){t.setTime(e)}),this._skeletons.forEach(function(e){e.update()}),this.refresh()},a.prototype.getAnimationDuration=function(){var e=0;return this._clips.forEach(function(t){e=Math.max(t.life,e)}),e},a.prototype.refresh=function(){this._needsRefresh=!0},a.prototype.getRenderer=function(){return this._renderer},a.prototype._updateMaterialsSRGB=function(){var e=this._renderMain.isLinearSpace();for(var t in this._materialsMap)for(var n=this._materialsMap[t],a=0;a0&&this._clips.splice(t,1)},removeClipsAll:function(){this._clips=[]},getClip:function(e){if(this._clips[e])return this._clips[e].clip},getClipNumber:function(){return this._clips.length},updateJointMatrices:function(){var e=l.create();return function(){this._invBindPoseMatricesArray=new Float32Array(16*this.joints.length),this._skinMatricesArray=new Float32Array(16*this.joints.length);for(var t=0;tthis.distance,i=1;i<8;i++)if(o.dot(t[i]._array,n)>this.distance!=a)return!0},intersectLine:function(){var e=o.create();return function(t,n,i){var r=this.distanceToPoint(t),s=this.distanceToPoint(n);if(r>0&&s>0||r<0&&s<0)return null;var c=this.normal._array,l=this.distance,u=t._array;o.sub(e,n._array,t._array),o.normalize(e,e);var p=o.dot(c,e);if(0===p)return null;i||(i=new a.a);var d=(o.dot(c,u)-l)/p;return o.scaleAndAdd(i._array,u,e,-d),i._dirty=!0,i}}(),applyTransform:function(){var e=s.create(),t=c.create(),n=c.create();return n[3]=1,function(a){a=a._array,o.scale(n,this.normal._array,this.distance),c.transformMat4(n,n,a),this.distance=o.dot(n,this.normal._array),s.invert(e,a),s.transpose(e,e),t[3]=0,o.copy(t,this.normal._array),c.transformMat4(t,t,e),o.copy(this.normal._array,t)}}(),copy:function(e){o.copy(this.normal._array,e.normal._array),this.normal._dirty=!0,this.distance=e.distance},clone:function(){var e=new l;return e.copy(this),e}},t.a=l},function(e,t,n){"use strict";var a=n(31),i=n(0),r=n.n(i),o=r.a.quat,s=r.a.vec3,c=function(e){e=e||{},a.a.call(this,e),this.tracks=e.tracks||[]};c.prototype=Object.create(a.a.prototype),c.prototype.constructor=c,c.prototype.step=function(e,t,n){var i=a.a.prototype.step.call(this,e,t,!0);if("finish"!==i){var e=this.getElapsedTime();this._range&&(e=this._range[0]+e),this.setTime(e)}return n||"paused"===i||this.fire("frame"),i},c.prototype.setRange=function(e){this.calcLifeFromTracks(),this._range=e,e&&(e[1]=Math.min(e[1],this.life),e[0]=Math.min(e[0],this.life),this.life=e[1]-e[0])},c.prototype.setTime=function(e){for(var t=0;t=0&&this.tracks.splice(t,1)},c.prototype.getSubClip=function(e,t,n){for(var a=new c({name:this.name}),i=0;i1e-6?(o=Math.acos(s),c=Math.sin(o),l=Math.sin((1-a)*o)/c,u=Math.sin(a*o)/c):(l=1-a,u=a),e[0]=l*p+u*m,e[1]=l*d+u*v,e[2]=l*f+u*_,e[3]=l*h+u*x,e}var r=n(77),o=n(0),s=n.n(o),c=s.a.quat,l=s.a.vec3,u=function(e){e=e||{},this.name=e.name||"",this.target=e.target||null,this.position=l.create(),this.rotation=c.create(),this.scale=l.fromValues(1,1,1),this.channels={time:null,position:null,rotation:null,scale:null},this._cacheKey=0,this._cacheTime=0};u.prototype.setTime=function(e){if(this.channels.time){var t=this.channels,n=t.time.length,r=-1;if(1===n)return t.rotation&&c.copy(this.rotation,t.rotation),t.position&&l.copy(this.position,t.position),void(t.scale&&l.copy(this.scale,t.scale));if(e<=t.time[0])e=t.time[0],r=0;else if(e>=t.time[n-1])e=t.time[n-1],r=n-2;else if(e=0;s--)if(t.time[s-1]<=e&&t.time[s]>e){r=s-1;break}}else for(var s=this._cacheKey;se){r=s;break}if(r>-1){this._cacheKey=r,this._cacheTime=e;var u=r,p=r+1,d=t.time[u],f=t.time[p],h=f-d,m=0===h?0:(e-d)/h;t.rotation&&i(this.rotation,t.rotation,t.rotation,m,4*u,4*p),t.position&&a(this.position,t.position,t.position,m,3*u,3*p),t.scale&&a(this.scale,t.scale,t.scale,m,3*u,3*p)}r==n-2&&(this._cacheKey=0,this._cacheTime=0),this.updateTarget()}},u.prototype.updateTarget=function(){var e=this.channels;this.target&&(e.position&&this.target.position.setArray(this.position),e.rotation&&this.target.rotation.setArray(this.rotation),e.scale&&this.target.scale.setArray(this.scale))},u.prototype.getMaxTime=function(){return this.channels.time[this.channels.time.length-1]},u.prototype.getSubTrack=function(e,t){var n=new u({name:this.name}),a=this.channels.time[0];e=Math.min(Math.max(e,a),this.life),t=Math.min(Math.max(t,a),this.life);var i=this._findRange(e),r=this._findRange(t),o=r[0]-i[0]+1;0===i[1]&&0===r[1]&&(o-=1),this.channels.rotation&&(n.channels.rotation=new Float32Array(4*o)),this.channels.position&&(n.channels.position=new Float32Array(3*o)),this.channels.scale&&(n.channels.scale=new Float32Array(3*o)),this.channels.time&&(n.channels.time=new Float32Array(o)),this.setTime(e);for(var s=0;s<3;s++)n.channels.rotation[s]=this.rotation[s],n.channels.position[s]=this.position[s],n.channels.scale[s]=this.scale[s];n.channels.time[0]=0,n.channels.rotation[3]=this.rotation[3];for(var s=1;se&&(a=i);var r=0;if(a>=0)var o=t.time[a],s=t.time[a+1],r=(e-o)/(s-o);return[a,r]},u.prototype.blend1D=r.a.prototype.blend1D,u.prototype.blend2D=r.a.prototype.blend2D,u.prototype.additiveBlend=r.a.prototype.additiveBlend,u.prototype.subtractiveBlend=r.a.prototype.subtractiveBlend,u.prototype.clone=function(){var e=u.prototype.clone.call(this);return e.channels={time:this.channels.time||null,position:this.channels.position||null,rotation:this.channels.rotation||null,scale:this.channels.scale||null},l.copy(e.position,this.position),c.copy(e.rotation,this.rotation),l.copy(e.scale,this.scale),e.target=this.target,e.updateTarget(),e},t.a=u},function(e,t,n){"use strict";function a(e,t){return e.time-t.time}var i=n(31),r=n(0),o=n.n(r),s=o.a.quat,c=o.a.vec3,l=function(e){this.name=e.name||"",this.keyFrames=[],e.keyFrames&&this.addKeyFrames(e.keyFrames),this.position=c.create(),this.rotation=s.create(),this.scale=c.fromValues(1,1,1),this._cacheKey=0,this._cacheTime=0};l.prototype=Object.create(i.a.prototype),l.prototype.constructor=l,l.prototype.step=function(e,t,n){var a=i.a.prototype.step.call(this,e,t,!0);return"finish"!==a&&this.setTime(this.getElapsedTime()),n||"paused"===a||this.fire("frame"),a},l.prototype.setTime=function(e){this._interpolateField(e,"position"),this._interpolateField(e,"rotation"),this._interpolateField(e,"scale")},l.prototype.getMaxTime=function(){var e=this.keyFrames[this.keyFrames.length-1];return e?e.time:0},l.prototype.addKeyFrame=function(e){for(var t=0;t=e.time)return this.keyFrames.splice(t,0,e),t}this.life=e.time,this.keyFrames.push(e)},l.prototype.addKeyFrames=function(e){for(var t=0;ti[i.length-1].time)){if(e=r-1?r-1:this._cacheKey+1,l=o;l>=0;l--)if(i[l].time<=e&&i[l][t])n=i[l],this._cacheKey=l,this._cacheTime=e;else if(i[l][t]){a=i[l];break}}else for(var l=this._cacheKey;l=0&&this._clips.splice(t,1)},removeAnimator:function(e){for(var t=e.getClips(),n=0;ni)e.length=i;else for(var r=a;r=0&&!(T[A]<=t);A--);A=Math.min(A,_-2)}else{for(A=O;A<_&&!(T[A]>t);A++);A=Math.min(A-1,_-2)}O=A,k=t;var n=T[A+1]-T[A];0!==n&&(R=(t-T[A])/n,v?(D=E[A],L=E[0===A?A:A-1],P=E[A>_-2?_-1:A+1],I=E[A>_-3?_-1:A+2],c?h(e,i,c(f(e,i),L,D,P,I,R)):g?l(L,D,P,I,R,R*R,R*R*R,f(e,i),y):h(e,i,u(L,D,P,I,R,R*R,R*R*R))):c?h(e,i,c(f(e,i),E[A],E[A+1],R)):g?o(E[A],E[A+1],R,f(e,i),y):h(e,i,r(E[A],E[A+1],R)))},B=new m.a({target:e._target,life:b,loop:e._loop,delay:e._delay,onframe:F,onfinish:n});return t&&"spline"!==t&&B.setEasing(t),B}}}function h(e,t,n,r,o){this._tracks={},this._target=e,this._loop=t||!1,this._getter=n||a,this._setter=r||i,this._interpolater=o||null,this._delay=0,this._doneList=[],this._onframeList=[],this._clipList=[]}var m=n(31),v=Array.prototype.slice;h.prototype={constructor:h,when:function(e,t){for(var n in t)this._tracks[n]||(this._tracks[n]=[],0!==e&&this._tracks[n].push({time:0,value:c(this._getter(this._target,n))})),this._tracks[n].push({time:parseInt(e),value:t[n]});return this},during:function(e){return this._onframeList.push(e),this},_doneCallback:function(){this._tracks={},this._clipList.length=0;for(var e=this._doneList,t=e.length,n=0;n=65535?new Uint32Array(3*_):new Uint16Array(3*_);for(var b=0,T=0,E=r.isUseIndices(),w=0;w0;){for(var w=[],S=[],A=[],N=0,y=0;y=0&&-1===S[P]&&(N65535?new Uint32Array(3*B.triangles.length):new Uint16Array(3*B.triangles.length);var J=0;V=0;for(var y=0;y=0?U[P]:-1}V++}G.indices[J++]=k[L]}G.updateBoundingBox(),I.add(W)}for(var ae=e.children(),y=0;y=0&&S[E]>1e-4&&(d.transformMat4(C,w,b[A[E]]),d.scaleAndAdd(N,N,C,S[E]));M.set(T,N)}}for(var T=0;T<_.length;T+=3){var R=_[T],L=_[T+1],D=_[T+2],P=u?p.attributes.skinnedPosition:x;if(P.get(R,e._array),P.get(L,t._array),P.get(D,n._array),h=v?a.intersectTriangle(e,t,n,i.culling):a.intersectTriangle(e,n,t,i.culling)){var I=new o.a;u?o.a.copy(I,h):o.a.transformMat4(I,h,i.worldTransform),c.push(new f.Intersection(h,I,i,[R,L,D],T/3,o.a.dist(I,this._ray.origin)))}}}}}}(),_intersectionCompareFunc:function(e,t){return e.distance-t.distance}});f.Intersection=function(e,t,n,a,i,r){this.point=e,this.pointWorld=t,this.target=n,this.triangle=a,this.triangleIndex=i,this.distance=r},t.a=f},function(e,t,n){"use strict";var a=n(20),i=n(7),r=a.a.extend({dynamic:!1,widthSegments:20,heightSegments:20,phiStart:0,phiLength:2*Math.PI,thetaStart:0,thetaLength:Math.PI,radius:1},function(){this.build()},{build:function(){var e=this.heightSegments,t=this.widthSegments,n=this.attributes.position,a=this.attributes.texcoord0,r=this.attributes.normal,o=(t+1)*(e+1);n.init(o),a.init(o),r.init(o);var s,c,l,u,p,d,f,h=o>65535?Uint32Array:Uint16Array,m=this.indices=new h(t*e*6),v=this.radius,_=this.phiStart,x=this.phiLength,g=this.thetaStart,y=this.thetaLength,v=this.radius,b=[],T=[],E=0,w=1/v;for(f=0;f<=e;f++)for(d=0;d<=t;d++)u=d/t,p=f/e,s=-v*Math.cos(_+u*x)*Math.sin(g+p*y),c=v*Math.cos(g+p*y),l=v*Math.sin(_+u*x)*Math.sin(g+p*y),b[0]=s,b[1]=c,b[2]=l,T[0]=u,T[1]=p,n.set(E,b),a.set(E,T),b[0]*=w,b[1]*=w,b[2]*=w,r.set(E,b),E++;var S,A,N,C,M=t+1,R=0;for(f=0;f0){var i=Math.pow(2,e[3]-128-8+a);t[n+0]=e[0]*i,t[n+1]=e[1]*i,t[n+2]=e[2]*i}else t[n+0]=0,t[n+1]=0,t[n+2]=0;return t[n+3]=1,t}function i(e,t,n){for(var a="",i=t;i0;)if(e[o][0]=t[n++],e[o][1]=t[n++],e[o][2]=t[n++],e[o][3]=t[n++],1===e[o][0]&&1===e[o][1]&&1===e[o][2]){for(var c=e[o][3]<>>0;c>0;c--)r(e[o-1],e[o]),o++,s--;i+=8}else o++,s--,i=0;return n}function s(e,t,n,a){if(ad)return o(e,t,n,a);var i=t[n++];if(2!=i)return o(e,t,n-1,a);if(e[0][1]=t[n++],e[0][2]=t[n++],i=t[n++],(e[0][2]<<8>>>0|i)>>>0!==a)return null;for(var i=0;i<4;i++)for(var r=0;r128){s=(127&s)>>>0;for(var c=t[n++];s--;)e[r++][i]=c}else for(;s--;)e[r++][i]=t[n++]}return n}var c=n(3),l=n(5),u=String.fromCharCode,p=8,d=32767,f={parseRGBE:function(e,t,n){null==n&&(n=0);var r=new Uint8Array(e),o=r.length;if("#?"===i(r,0,2)){for(var p=2;p=o)){p+=2;for(var d="";p=n.x&&t>=n.y&&e<=n.x+n.width&&t<=n.y+n.height};var d=new c.a;a.prototype.castRay=function(e,t,n){var a=this.layer.renderer,i=a.viewport;return a.viewport=this.viewport,a.screenToNDC(e,t,d),this.camera.castRay(d,n),a.viewport=i,n},a.prototype.prepareRender=function(){this.scene.update(),this.camera.update(),this._frame=0,this._temporalSS.resetFrame()},a.prototype.render=function(e){this._doRender(e,this._frame),this._frame++},a.prototype.needsAccumulate=function(){return this.needsTemporalSS()||this._needsSortProgressively},a.prototype.needsTemporalSS=function(){var e=this._enableTemporalSS;return"auto"==e&&(e=this._enablePostEffect),e},a.prototype.hasDOF=function(){return this._enableDOF},a.prototype.isAccumulateFinished=function(){return this.needsTemporalSS()?this._temporalSS.isFinished():this._frame>30},a.prototype._doRender=function(e,t){var n=this.scene,a=this.camera,i=this.renderer;if(t=t||0,!e&&this._shadowMapPass&&(this._shadowMapPass.kernelPCF=this._pcfKernels[0],this._shadowMapPass.render(i,n,a,!0)),this._updateShadowPCFKernel(t),i.gl.clearColor(0,0,0,0),this._enablePostEffect&&(this.needsTemporalSS()&&this._temporalSS.jitterProjection(i,a),this._compositor.updateNormal(i,n,a,this._temporalSS.getFrame())),this._updateSSAO(i,n,a,this._temporalSS.getFrame()),this._enablePostEffect){var r=this._compositor.getSourceFrameBuffer();r.bind(i),i.gl.clear(i.gl.DEPTH_BUFFER_BIT|i.gl.COLOR_BUFFER_BIT),i.render(n,a,!0,this.preZ),this.afterRenderScene(i,n,a),r.unbind(i),this.needsTemporalSS()&&e?(this._compositor.composite(i,a,this._temporalSS.getSourceFrameBuffer(),this._temporalSS.getFrame()),i.setViewport(this.viewport),this._temporalSS.render(i)):(i.setViewport(this.viewport),this._compositor.composite(i,a,null,0))}else if(this.needsTemporalSS()&&e){var r=this._temporalSS.getSourceFrameBuffer();r.bind(i),i.saveClear(),i.clearBit=i.gl.DEPTH_BUFFER_BIT|i.gl.COLOR_BUFFER_BIT,i.render(n,a,!0,this.preZ),this.afterRenderScene(i,n,a),i.restoreClear(),r.unbind(i),i.setViewport(this.viewport),this._temporalSS.render(i)}else i.setViewport(this.viewport),i.render(n,a,!0,this.preZ),this.afterRenderScene(i,n,a);this.afterRenderAll(i,n,a)},a.prototype.afterRenderScene=function(e,t,n){},a.prototype.afterRenderAll=function(e,t,n){},a.prototype._updateSSAO=function(e,t,n,a){function i(e){for(var t=0;tthis.camera.far||e0&&(d.define("vertex","SKINNING"),d.define("vertex","JOINT_COUNT",l)),s&&d.define("both","SHADOW_TRANSPARENT"),o.useSkinMatricesTexture&&d.define("vertex","USE_SKIN_MATRICES_TEXTURE"),this._depthShaders[r]=d),p||(p=new h.a({shader:d}),this._depthMaterials[i]=p),o.material=p,this.softShadow===C.VSM?d.define("fragment","USE_VSM"):d.undefine("fragment","USE_VSM"),p.setUniform("bias",t),p.setUniform("slopeScale",n),s&&p.set("shadowTransparentMap",c))}},_bindDistanceMaterial:function(e,t){for(var n=t.getWorldPosition()._array,a=0;a0&&(o.shader.define("vertex","SKINNING"),o.shader.define("vertex","JOINT_COUNT",r)),this._distanceMaterials[r]=o),i.material=o,this.softShadow===C.VSM?o.shader.define("fragment","USE_VSM"):o.shader.undefine("fragment","USE_VSM")),o.set("lightPosition",n),o.set("range",t.range)}},saveMaterial:function(e){for(var t=0;t1&&(v=x,x.shadowCascade>4)){console.warn("Support at most 4 cascade");continue}this.renderDirectionalLightShadow(e,t,n,x,this._opaqueCasters,h,u,l)}else x instanceof p.a?this.renderSpotLightShadow(e,x,this._opaqueCasters,c,s):x instanceof f.a&&this.renderPointLightShadow(e,x,this._opaqueCasters,m);this._shadowMapNumber[x.type]++}this.restoreMaterial(this._opaqueCasters);var g=h.slice(),y=h.slice();g.pop(),y.shift(),g.reverse(),y.reverse(),u.reverse();for(var b=s.map(i),T=l.map(i),E={},_=0;_0?(A.fragmentDefines[R]=M,N=!0):A.isDefined("fragment",R)&&(A.undefine("fragment",R),N=!0))}N&&A.dirty(),v?A.define("fragment","SHADOW_CASCADE",v.shadowCascade):A.undefine("fragment","SHADOW_CASCADE"),E[A.__GUID__]=!0}s.length>0&&(S.setUniform("spotLightShadowMaps",s),S.setUniform("spotLightMatrices",c),S.setUniform("spotLightShadowMapSizes",b)),l.length>0&&(S.setUniform("directionalLightShadowMaps",l),v&&(S.setUniform("shadowCascadeClipsNear",g),S.setUniform("shadowCascadeClipsFar",y)),S.setUniform("directionalLightMatrices",u),S.setUniform("directionalLightShadowMapSizes",T)),m.length>0&&S.setUniform("pointLightShadowMaps",m)}}},renderDirectionalLightShadow:function(){var e=new s.a,t=new c.a,n=new o.a,a=new c.a,i=new c.a,r=new c.a,u=new c.a;return function(o,s,p,d,f,h,m,v){var _=d.shadowBias;if(this._bindDepthMaterial(f,_,d.shadowSlopeScale),f.sort(l.a.opaqueSortFunc),!s.viewBoundingBoxLastFrame.isFinite()){var x=s.getBoundingBox();s.viewBoundingBoxLastFrame.copy(x).applyTransform(p.viewMatrix)}var y=Math.min(-s.viewBoundingBoxLastFrame.min.z,p.far),b=Math.max(-s.viewBoundingBoxLastFrame.max.z,p.near),T=this._getDirectionalLightCamera(d,s,p),E=r._array;u.copy(T.projectionMatrix),A.invert(i._array,T.worldTransform._array),A.multiply(i._array,i._array,p.worldTransform._array),A.multiply(E,u._array,i._array);for(var w=[],S=p instanceof g.a,N=(p.near+p.far)/(p.near-p.far),M=2*p.near*p.far/(p.near-p.far),R=0;R<=d.shadowCascade;R++){var L=b*Math.pow(y/b,R/d.shadowCascade),D=b+(y-b)*R/d.shadowCascade,P=L*d.cascadeSplitLogFactor+D*(1-d.cascadeSplitLogFactor);w.push(P),h.push(-(-P*N+M)/-P)}var I=this._getTexture(d,d.shadowCascade);v.push(I);var O=o.viewport,k=o.gl;this._frameBuffer.attach(I),this._frameBuffer.bind(o),k.clear(k.COLOR_BUFFER_BIT|k.DEPTH_BUFFER_BIT);for(var R=0;R=0||(this.nodes.push(e),this._dirty=!0)},removeNode:function(e){"string"==typeof e&&(e=this.getNodeByName(e));var t=this.nodes.indexOf(e);t>=0&&(this.nodes.splice(t,1),this._dirty=!0)},getNodeByName:function(e){for(var t=0;t=t.COLOR_ATTACHMENT0&&l<=t.COLOR_ATTACHMENT0+8&&p.push(l);u.drawBuffersEXT(p)}e.saveClear(),e.clearBit=i.a.DEPTH_BUFFER_BIT|i.a.COLOR_BUFFER_BIT,n=e.render(this.scene,this.camera,!this.autoUpdateScene,this.preZ),e.restoreClear(),a.unbind(e)}else n=e.render(this.scene,this.camera,!this.autoUpdateScene,this.preZ);this.trigger("afterrender",n),this._rendering=!1,this._rendered=!0}});t.a=o},function(e,t,n){"use strict";var a=n(21),i=a.a.extend(function(){return{texture:null,outputs:{color:{}}}},function(){},{getOutput:function(e,t){return this.texture},beforeFrame:function(){},afterFrame:function(){}});t.a=i},function(e,t,n){"use strict";var a=n(12),i=n(21),r=i.a.extend(function(){return{name:"",inputs:{},outputs:null,shader:"",inputLinks:{},outputLinks:{},pass:null,_prevOutputTextures:{},_outputTextures:{},_outputReferences:{},_rendering:!1,_rendered:!1,_compositor:null}},function(){var e=new a.a({fragment:this.shader});this.pass=e},{render:function(e,t){this.trigger("beforerender",e),this._rendering=!0;var n=e.gl;for(var a in this.inputLinks){var i=this.inputLinks[a],r=i.node.getOutput(e,i.pin);this.pass.setUniform(a,r)}if(this.outputs){this.pass.outputs={};var o={};for(var s in this.outputs){var c=this.updateParameter(s,e);isNaN(c.width)&&this.updateParameter(s,e);var l=this.outputs[s],u=this._compositor.allocateTexture(c);this._outputTextures[s]=u;var p=l.attachment||n.COLOR_ATTACHMENT0;"string"==typeof p&&(p=n[p]),o[p]=u}this._compositor.getFrameBuffer().bind(e);for(var p in o)this._compositor.getFrameBuffer().attach(o[p],p);this.pass.render(e),this._compositor.getFrameBuffer().updateMipmap(e.gl)}else this.pass.outputs=null,this._compositor.getFrameBuffer().unbind(e),this.pass.render(e,t);for(var a in this.inputLinks){var i=this.inputLinks[a];i.node.removeReference(i.pin)}this._rendering=!1,this._rendered=!0,this.trigger("afterrender",e)},updateParameter:function(e,t){var n=this.outputs[e],a=n.parameters,i=n._parametersCopy;if(i||(i=n._parametersCopy={}),a)for(var r in a)"width"!==r&&"height"!==r&&(i[r]=a[r]);var o,s;return o=a.width instanceof Function?a.width.call(this,t):a.width,s=a.height instanceof Function?a.height.call(this,t):a.height,i.width===o&&i.height===s||this._outputTextures[e]&&this._outputTextures[e].dispose(t),i.width=o,i.height=s,i},setParameter:function(e,t){this.pass.setUniform(e,t)},getParameter:function(e){return this.pass.getUniform(e)},setParameters:function(e){for(var t in e)this.setParameter(t,e[t])},setShader:function(e){var t=this.pass.material;t.shader.setFragment(e),t.attachShader(t.shader,!0)},shaderDefine:function(e,t){this.pass.material.shader.define("fragment",e,t)},shaderUndefine:function(e){this.pass.material.shader.undefine("fragment",e)},removeReference:function(e){if(0===--this._outputReferences[e]){this.outputs[e].keepLastFrame?(this._prevOutputTextures[e]&&this._compositor.releaseTexture(this._prevOutputTextures[e]),this._prevOutputTextures[e]=this._outputTextures[e]):this._compositor.releaseTexture(this._outputTextures[e])}},link:function(e,t,n){this.inputLinks[e]={node:t,pin:n},t.outputLinks[n]||(t.outputLinks[n]=[]),t.outputLinks[n].push({node:this,pin:e}),this.pass.material.shader.enableTexture(e)},clear:function(){i.a.prototype.clear.call(this),this.pass.material.shader.disableTexturesAll()},updateReference:function(e){if(!this._rendering){this._rendering=!0;for(var t in this.inputLinks){var n=this.inputLinks[t];n.node.updateReference(n.pin)}this._rendering=!1}e&&this._outputReferences[e]++},beforeFrame:function(){this._rendered=!1;for(var e in this.outputLinks)this._outputReferences[e]=0},afterFrame:function(){for(var e in this.outputLinks)if(this._outputReferences[e]>0){var t=this.outputs[e];t.keepLastFrame?(this._prevOutputTextures[e]&&this._compositor.releaseTexture(this._prevOutputTextures[e]),this._prevOutputTextures[e]=this._outputTextures[e]):this._compositor.releaseTexture(this._outputTextures[e])}}});t.a=r},function(e,t,n){"use strict";function a(e){for(var t=new Uint8Array(e*e*4),n=0,a=new c.a,i=0;i0&&(a.shader.define("vertex","SKINNING"),a.shader.define("vertex","JOINT_COUNT",e),i.shader.define("vertex","SKINNING"),i.shader.define("vertex","JOINT_COUNT",e)),n={material1:a,material2:i},t[e]=n}return n.used=!0,n},_resetGBufferMaterials:function(){for(var e in this._gBufferMaterials)this._gBufferMaterials[e].used=!1},_cleanGBufferMaterials:function(e){for(var t in this._gBufferMaterials){var n=this._gBufferMaterials[t];n.used||(n.material1.dispose(e),n.material2.dispose(e))}},_replaceGBufferMat:function(e,t){for(var n=0;n>>16)>>>0;c=((1431655765&c)<<1|(2863311530&c)>>>1)>>>0,c=((858993459&c)<<2|(3435973836&c)>>>2)>>>0,c=((252645135&c)<<4|(4042322160&c)>>>4)>>>0,c=(((16711935&c)<<8|(4278255360&c)>>>8)>>>0)/4294967296;for(var l=0;l255?255:e}function i(e){return e<0?0:e>1?1:e}function r(e){return a(e.length&&"%"===e.charAt(e.length-1)?parseFloat(e)/100*255:parseInt(e,10))}function o(e){return i(e.length&&"%"===e.charAt(e.length-1)?parseFloat(e)/100:parseFloat(e))}function s(e,t,n){return n<0?n+=1:n>1&&(n-=1),6*n<1?e+(t-e)*n*6:2*n<1?t:3*n<2?e+(t-e)*(2/3-n)*6:e}function c(e,t,n,a,i){return e[0]=t,e[1]=n,e[2]=a,e[3]=i,e}function l(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e}function u(e,t){_&&l(_,t),_=v.put(e,_||t.slice())}function p(e,t){if(e){t=t||[];var n=v.get(e);if(n)return l(t,n);e+="";var a=e.replace(/ /g,"").toLowerCase();if(a in m)return l(t,m[a]),u(e,t),t;if("#"!==a.charAt(0)){var i=a.indexOf("("),s=a.indexOf(")");if(-1!==i&&s+1===a.length){var p=a.substr(0,i),f=a.substr(i+1,s-(i+1)).split(","),h=1;switch(p){case"rgba":if(4!==f.length)return void c(t,0,0,0,1);h=o(f.pop());case"rgb":return 3!==f.length?void c(t,0,0,0,1):(c(t,r(f[0]),r(f[1]),r(f[2]),h),u(e,t),t);case"hsla":return 4!==f.length?void c(t,0,0,0,1):(f[3]=o(f[3]),d(f,t),u(e,t),t);case"hsl":return 3!==f.length?void c(t,0,0,0,1):(d(f,t),u(e,t),t);default:return}}c(t,0,0,0,1)}else{if(4===a.length){var _=parseInt(a.substr(1),16);return _>=0&&_<=4095?(c(t,(3840&_)>>4|(3840&_)>>8,240&_|(240&_)>>4,15&_|(15&_)<<4,1),u(e,t),t):void c(t,0,0,0,1)}if(7===a.length){var _=parseInt(a.substr(1),16);return _>=0&&_<=16777215?(c(t,(16711680&_)>>16,(65280&_)>>8,255&_,1),u(e,t),t):void c(t,0,0,0,1)}}}}function d(e,t){var n=(parseFloat(e[0])%360+360)%360/360,i=o(e[1]),r=o(e[2]),l=r<=.5?r*(i+1):r+i-r*i,u=2*r-l;return t=t||[],c(t,a(255*s(u,l,n+1/3)),a(255*s(u,l,n)),a(255*s(u,l,n-1/3)),1),4===e.length&&(t[3]=e[3]),t}function f(e,t){if(e&&e.length){var n=e[0]+","+e[1]+","+e[2];return"rgba"!==t&&"hsva"!==t&&"hsla"!==t||(n+=","+e[3]),t+"("+n+")"}}t.a=p,t.b=f;var h=n(63),m={transparent:[0,0,0,0],aliceblue:[240,248,255,1],antiquewhite:[250,235,215,1],aqua:[0,255,255,1],aquamarine:[127,255,212,1],azure:[240,255,255,1],beige:[245,245,220,1],bisque:[255,228,196,1],black:[0,0,0,1],blanchedalmond:[255,235,205,1],blue:[0,0,255,1],blueviolet:[138,43,226,1],brown:[165,42,42,1],burlywood:[222,184,135,1],cadetblue:[95,158,160,1],chartreuse:[127,255,0,1],chocolate:[210,105,30,1],coral:[255,127,80,1],cornflowerblue:[100,149,237,1],cornsilk:[255,248,220,1],crimson:[220,20,60,1],cyan:[0,255,255,1],darkblue:[0,0,139,1],darkcyan:[0,139,139,1],darkgoldenrod:[184,134,11,1],darkgray:[169,169,169,1],darkgreen:[0,100,0,1],darkgrey:[169,169,169,1],darkkhaki:[189,183,107,1],darkmagenta:[139,0,139,1],darkolivegreen:[85,107,47,1],darkorange:[255,140,0,1],darkorchid:[153,50,204,1],darkred:[139,0,0,1],darksalmon:[233,150,122,1],darkseagreen:[143,188,143,1],darkslateblue:[72,61,139,1],darkslategray:[47,79,79,1],darkslategrey:[47,79,79,1],darkturquoise:[0,206,209,1],darkviolet:[148,0,211,1],deeppink:[255,20,147,1],deepskyblue:[0,191,255,1],dimgray:[105,105,105,1],dimgrey:[105,105,105,1],dodgerblue:[30,144,255,1],firebrick:[178,34,34,1],floralwhite:[255,250,240,1],forestgreen:[34,139,34,1],fuchsia:[255,0,255,1],gainsboro:[220,220,220,1],ghostwhite:[248,248,255,1],gold:[255,215,0,1],goldenrod:[218,165,32,1],gray:[128,128,128,1],green:[0,128,0,1],greenyellow:[173,255,47,1],grey:[128,128,128,1],honeydew:[240,255,240,1],hotpink:[255,105,180,1],indianred:[205,92,92,1],indigo:[75,0,130,1],ivory:[255,255,240,1],khaki:[240,230,140,1],lavender:[230,230,250,1],lavenderblush:[255,240,245,1],lawngreen:[124,252,0,1],lemonchiffon:[255,250,205,1],lightblue:[173,216,230,1],lightcoral:[240,128,128,1],lightcyan:[224,255,255,1],lightgoldenrodyellow:[250,250,210,1],lightgray:[211,211,211,1],lightgreen:[144,238,144,1],lightgrey:[211,211,211,1],lightpink:[255,182,193,1],lightsalmon:[255,160,122,1],lightseagreen:[32,178,170,1],lightskyblue:[135,206,250,1],lightslategray:[119,136,153,1],lightslategrey:[119,136,153,1],lightsteelblue:[176,196,222,1],lightyellow:[255,255,224,1],lime:[0,255,0,1],limegreen:[50,205,50,1],linen:[250,240,230,1],magenta:[255,0,255,1],maroon:[128,0,0,1],mediumaquamarine:[102,205,170,1],mediumblue:[0,0,205,1],mediumorchid:[186,85,211,1],mediumpurple:[147,112,219,1],mediumseagreen:[60,179,113,1],mediumslateblue:[123,104,238,1],mediumspringgreen:[0,250,154,1],mediumturquoise:[72,209,204,1],mediumvioletred:[199,21,133,1],midnightblue:[25,25,112,1],mintcream:[245,255,250,1],mistyrose:[255,228,225,1],moccasin:[255,228,181,1],navajowhite:[255,222,173,1],navy:[0,0,128,1],oldlace:[253,245,230,1],olive:[128,128,0,1],olivedrab:[107,142,35,1],orange:[255,165,0,1],orangered:[255,69,0,1],orchid:[218,112,214,1],palegoldenrod:[238,232,170,1],palegreen:[152,251,152,1],paleturquoise:[175,238,238,1],palevioletred:[219,112,147,1],papayawhip:[255,239,213,1],peachpuff:[255,218,185,1],peru:[205,133,63,1],pink:[255,192,203,1],plum:[221,160,221,1],powderblue:[176,224,230,1],purple:[128,0,128,1],red:[255,0,0,1],rosybrown:[188,143,143,1],royalblue:[65,105,225,1],saddlebrown:[139,69,19,1],salmon:[250,128,114,1],sandybrown:[244,164,96,1],seagreen:[46,139,87,1],seashell:[255,245,238,1],sienna:[160,82,45,1],silver:[192,192,192,1],skyblue:[135,206,235,1],slateblue:[106,90,205,1],slategray:[112,128,144,1],slategrey:[112,128,144,1],snow:[255,250,250,1],springgreen:[0,255,127,1],steelblue:[70,130,180,1],tan:[210,180,140,1],teal:[0,128,128,1],thistle:[216,191,216,1],tomato:[255,99,71,1],turquoise:[64,224,208,1],violet:[238,130,238,1],wheat:[245,222,179,1],white:[255,255,255,1],whitesmoke:[245,245,245,1],yellow:[255,255,0,1],yellowgreen:[154,205,50,1]},v=new h.a(20),_=null},function(e,t,n){"use strict";t.a={type:"compositor",nodes:[{name:"source",type:"texture",outputs:{color:{}}},{name:"source_half",shader:"#source(qtek.compositor.downsample)",inputs:{texture:"source"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 2)",height:"expr(height * 1.0 / 2)",type:"HALF_FLOAT"}}},parameters:{textureSize:"expr( [width * 1.0, height * 1.0] )"}},{name:"bright",shader:"#source(qtek.compositor.bright)",inputs:{texture:"source_half"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 2)",height:"expr(height * 1.0 / 2)",type:"HALF_FLOAT"}}},parameters:{threshold:2,scale:4,textureSize:"expr([width * 1.0 / 2, height / 2])"}},{name:"bright_downsample_4",shader:"#source(qtek.compositor.downsample)",inputs:{texture:"bright"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 4)",height:"expr(height * 1.0 / 4)",type:"HALF_FLOAT"}}},parameters:{textureSize:"expr( [width * 1.0 / 2, height / 2] )"}},{name:"bright_downsample_8",shader:"#source(qtek.compositor.downsample)",inputs:{texture:"bright_downsample_4"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 8)",height:"expr(height * 1.0 / 8)",type:"HALF_FLOAT"}}},parameters:{textureSize:"expr( [width * 1.0 / 4, height / 4] )"}},{name:"bright_downsample_16",shader:"#source(qtek.compositor.downsample)",inputs:{texture:"bright_downsample_8"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 16)",height:"expr(height * 1.0 / 16)",type:"HALF_FLOAT"}}},parameters:{textureSize:"expr( [width * 1.0 / 8, height / 8] )"}},{name:"bright_downsample_32",shader:"#source(qtek.compositor.downsample)",inputs:{texture:"bright_downsample_16"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 32)",height:"expr(height * 1.0 / 32)",type:"HALF_FLOAT"}}},parameters:{textureSize:"expr( [width * 1.0 / 16, height / 16] )"}},{name:"bright_upsample_16_blur_h",shader:"#source(qtek.compositor.gaussian_blur)",inputs:{texture:"bright_downsample_32"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 16)",height:"expr(height * 1.0 / 16)",type:"HALF_FLOAT"}}},parameters:{blurSize:1,blurDir:0,textureSize:"expr( [width * 1.0 / 32, height / 32] )"}},{name:"bright_upsample_16_blur_v",shader:"#source(qtek.compositor.gaussian_blur)",inputs:{texture:"bright_upsample_16_blur_h"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 16)",height:"expr(height * 1.0 / 16)",type:"HALF_FLOAT"}}},parameters:{blurSize:1,blurDir:1,textureSize:"expr( [width * 1.0 / 32, height * 1.0 / 32] )"}},{name:"bright_upsample_8_blur_h",shader:"#source(qtek.compositor.gaussian_blur)",inputs:{texture:"bright_downsample_16"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 8)",height:"expr(height * 1.0 / 8)",type:"HALF_FLOAT"}}},parameters:{blurSize:1,blurDir:0,textureSize:"expr( [width * 1.0 / 16, height * 1.0 / 16] )"}},{name:"bright_upsample_8_blur_v",shader:"#source(qtek.compositor.gaussian_blur)",inputs:{texture:"bright_upsample_8_blur_h"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 8)",height:"expr(height * 1.0 / 8)",type:"HALF_FLOAT"}}},parameters:{blurSize:1,blurDir:1,textureSize:"expr( [width * 1.0 / 16, height * 1.0 / 16] )"}},{name:"bright_upsample_8_blend",shader:"#source(qtek.compositor.blend)",inputs:{texture1:"bright_upsample_8_blur_v",texture2:"bright_upsample_16_blur_v"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 8)",height:"expr(height * 1.0 / 8)",type:"HALF_FLOAT"}}},parameters:{weight1:.3,weight2:.7}},{name:"bright_upsample_4_blur_h",shader:"#source(qtek.compositor.gaussian_blur)",inputs:{texture:"bright_downsample_8"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 4)",height:"expr(height * 1.0 / 4)",type:"HALF_FLOAT"}}},parameters:{blurSize:1,blurDir:0,textureSize:"expr( [width * 1.0 / 8, height * 1.0 / 8] )"}},{name:"bright_upsample_4_blur_v",shader:"#source(qtek.compositor.gaussian_blur)",inputs:{texture:"bright_upsample_4_blur_h"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 4)",height:"expr(height * 1.0 / 4)",type:"HALF_FLOAT"}}},parameters:{blurSize:1,blurDir:1,textureSize:"expr( [width * 1.0 / 8, height * 1.0 / 8] )"}},{name:"bright_upsample_4_blend",shader:"#source(qtek.compositor.blend)",inputs:{texture1:"bright_upsample_4_blur_v",texture2:"bright_upsample_8_blend"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 4)",height:"expr(height * 1.0 / 4)",type:"HALF_FLOAT"}}},parameters:{weight1:.3,weight2:.7}},{name:"bright_upsample_2_blur_h",shader:"#source(qtek.compositor.gaussian_blur)",inputs:{texture:"bright_downsample_4"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 2)",height:"expr(height * 1.0 / 2)",type:"HALF_FLOAT"}}},parameters:{blurSize:1,blurDir:0,textureSize:"expr( [width * 1.0 / 4, height * 1.0 / 4] )"}},{name:"bright_upsample_2_blur_v",shader:"#source(qtek.compositor.gaussian_blur)",inputs:{texture:"bright_upsample_2_blur_h"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 2)",height:"expr(height * 1.0 / 2)",type:"HALF_FLOAT"}}},parameters:{blurSize:1,blurDir:1,textureSize:"expr( [width * 1.0 / 4, height * 1.0 / 4] )"}},{name:"bright_upsample_2_blend",shader:"#source(qtek.compositor.blend)",inputs:{texture1:"bright_upsample_2_blur_v",texture2:"bright_upsample_4_blend"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 2)",height:"expr(height * 1.0 / 2)",type:"HALF_FLOAT"}}},parameters:{weight1:.3,weight2:.7}},{name:"bright_upsample_full_blur_h",shader:"#source(qtek.compositor.gaussian_blur)",inputs:{texture:"bright"},outputs:{color:{parameters:{width:"expr(width * 1.0)",height:"expr(height * 1.0)",type:"HALF_FLOAT"}}},parameters:{blurSize:1,blurDir:0,textureSize:"expr( [width * 1.0 / 2, height * 1.0 / 2] )"}},{name:"bright_upsample_full_blur_v",shader:"#source(qtek.compositor.gaussian_blur)",inputs:{texture:"bright_upsample_full_blur_h"},outputs:{color:{parameters:{width:"expr(width * 1.0)",height:"expr(height * 1.0)",type:"HALF_FLOAT"}}},parameters:{blurSize:1,blurDir:1,textureSize:"expr( [width * 1.0 / 2, height * 1.0 / 2] )"}},{name:"bloom_composite",shader:"#source(qtek.compositor.blend)",inputs:{texture1:"bright_upsample_full_blur_v",texture2:"bright_upsample_2_blend"},outputs:{color:{parameters:{width:"expr(width * 1.0)",height:"expr(height * 1.0)",type:"HALF_FLOAT"}}},parameters:{weight1:.3,weight2:.7}},{name:"coc",shader:"#source(ecgl.dof.coc)",outputs:{color:{parameters:{minFilter:"NEAREST",magFilter:"NEAREST",width:"expr(width * 1.0)",height:"expr(height * 1.0)"}}},parameters:{focalDist:50,focalRange:30}},{name:"dof_far_blur",shader:"#source(ecgl.dof.diskBlur)",inputs:{texture:"source",coc:"coc"},outputs:{color:{parameters:{width:"expr(width * 1.0)",height:"expr(height * 1.0)",type:"HALF_FLOAT"}}},parameters:{textureSize:"expr( [width * 1.0, height * 1.0] )"}},{name:"dof_near_blur",shader:"#source(ecgl.dof.diskBlur)",inputs:{texture:"source",coc:"coc"},outputs:{color:{parameters:{width:"expr(width * 1.0)",height:"expr(height * 1.0)",type:"HALF_FLOAT"}}},parameters:{textureSize:"expr( [width * 1.0, height * 1.0] )"},defines:{BLUR_NEARFIELD:null}},{name:"dof_coc_blur",shader:"#source(ecgl.dof.diskBlur)",inputs:{texture:"coc"},outputs:{color:{parameters:{minFilter:"NEAREST",magFilter:"NEAREST",width:"expr(width * 1.0)",height:"expr(height * 1.0)"}}},parameters:{textureSize:"expr( [width * 1.0, height * 1.0] )"},defines:{BLUR_COC:null}},{name:"dof_composite",shader:"#source(ecgl.dof.composite)",inputs:{original:"source",blurred:"dof_far_blur",nearfield:"dof_near_blur",coc:"coc",nearcoc:"dof_coc_blur"},outputs:{color:{parameters:{width:"expr(width * 1.0)",height:"expr(height * 1.0)",type:"HALF_FLOAT"}}}},{name:"composite",shader:"#source(qtek.compositor.hdr.composite)",inputs:{texture:"source",bloom:"bloom_composite"},defines:{}},{name:"FXAA",shader:"#source(qtek.compositor.fxaa)",inputs:{texture:"composite"}}]}},function(e,t,n){"use strict";t.a="@export ecgl.dof.coc\n\nuniform sampler2D depth;\n\nuniform float zNear: 0.1;\nuniform float zFar: 2000;\n\nuniform float focalDistance: 3;\nuniform float focalRange: 1;\nuniform float focalLength: 30;\nuniform float fstop: 2.8;\n\nvarying vec2 v_Texcoord;\n\n@import qtek.util.encode_float\n\nvoid main()\n{\n float z = texture2D(depth, v_Texcoord).r * 2.0 - 1.0;\n\n float dist = 2.0 * zNear * zFar / (zFar + zNear - z * (zFar - zNear));\n\n float aperture = focalLength / fstop;\n\n float coc;\n\n float uppper = focalDistance + focalRange;\n float lower = focalDistance - focalRange;\n if (dist <= uppper && dist >= lower) {\n coc = 0.5;\n }\n else {\n float focalAdjusted = dist > uppper ? uppper : lower;\n\n coc = abs(aperture * (focalLength * (dist - focalAdjusted)) / (dist * (focalAdjusted - focalLength)));\n coc = clamp(coc, 0.0, 2.0) / 2.00001;\n\n if (dist < lower) {\n coc = -coc;\n }\n coc = coc * 0.5 + 0.5;\n }\n\n gl_FragColor = encodeFloat(coc);\n}\n@end\n\n\n@export ecgl.dof.composite\n\n#define DEBUG 0\n\nuniform sampler2D original;\nuniform sampler2D blurred;\nuniform sampler2D nearfield;\nuniform sampler2D coc;\nuniform sampler2D nearcoc;\nvarying vec2 v_Texcoord;\n\n@import qtek.util.rgbm\n@import qtek.util.float\n\nvoid main()\n{\n vec4 blurredColor = decodeHDR(texture2D(blurred, v_Texcoord));\n vec4 originalColor = decodeHDR(texture2D(original, v_Texcoord));\n\n float fCoc = decodeFloat(texture2D(coc, v_Texcoord));\n\n fCoc = abs(fCoc * 2.0 - 1.0);\n\n float weight = smoothstep(0.0, 1.0, fCoc);\n \n#ifdef NEARFIELD_ENABLED\n vec4 nearfieldColor = decodeHDR(texture2D(nearfield, v_Texcoord));\n float fNearCoc = decodeFloat(texture2D(nearcoc, v_Texcoord));\n fNearCoc = abs(fNearCoc * 2.0 - 1.0);\n\n gl_FragColor = encodeHDR(\n mix(\n nearfieldColor, mix(originalColor, blurredColor, weight),\n pow(1.0 - fNearCoc, 4.0)\n )\n );\n#else\n gl_FragColor = encodeHDR(mix(originalColor, blurredColor, weight));\n#endif\n\n}\n\n@end\n\n\n\n@export ecgl.dof.diskBlur\n\n#define POISSON_KERNEL_SIZE 16;\n\nuniform sampler2D texture;\nuniform sampler2D coc;\nvarying vec2 v_Texcoord;\n\nuniform float blurRadius : 10.0;\nuniform vec2 textureSize : [512.0, 512.0];\n\nuniform vec2 poissonKernel[POISSON_KERNEL_SIZE];\n\nuniform float percent;\n\nfloat nrand(const in vec2 n) {\n return fract(sin(dot(n.xy ,vec2(12.9898,78.233))) * 43758.5453);\n}\n\n@import qtek.util.rgbm\n@import qtek.util.float\n\n\nvoid main()\n{\n vec2 offset = blurRadius / textureSize;\n\n float rnd = 6.28318 * nrand(v_Texcoord + 0.07 * percent );\n float cosa = cos(rnd);\n float sina = sin(rnd);\n vec4 basis = vec4(cosa, -sina, sina, cosa);\n\n#if !defined(BLUR_NEARFIELD) && !defined(BLUR_COC)\n offset *= abs(decodeFloat(texture2D(coc, v_Texcoord)) * 2.0 - 1.0);\n#endif\n\n#ifdef BLUR_COC\n float cocSum = 0.0;\n#else\n vec4 color = vec4(0.0);\n#endif\n\n\n float weightSum = 0.0;\n\n for (int i = 0; i < POISSON_KERNEL_SIZE; i++) {\n vec2 ofs = poissonKernel[i];\n\n ofs = vec2(dot(ofs, basis.xy), dot(ofs, basis.zw));\n\n vec2 uv = v_Texcoord + ofs * offset;\n vec4 texel = texture2D(texture, uv);\n\n float w = 1.0;\n#ifdef BLUR_COC\n float fCoc = decodeFloat(texel) * 2.0 - 1.0;\n cocSum += clamp(fCoc, -1.0, 0.0) * w;\n#else\n texel = decodeHDR(texel);\n #if !defined(BLUR_NEARFIELD)\n float fCoc = decodeFloat(texture2D(coc, uv)) * 2.0 - 1.0;\n w *= abs(fCoc);\n #endif\n color += texel * w;\n#endif\n\n weightSum += w;\n }\n\n#ifdef BLUR_COC\n gl_FragColor = encodeFloat(clamp(cocSum / weightSum, -1.0, 0.0) * 0.5 + 0.5);\n#else\n color /= weightSum;\n gl_FragColor = encodeHDR(color);\n#endif\n}\n\n@end"},function(e,t,n){"use strict";t.a="@export ecgl.edge\n\nuniform sampler2D texture;\n\nuniform sampler2D normalTexture;\nuniform sampler2D depthTexture;\n\nuniform mat4 projectionInv;\n\nuniform vec2 textureSize;\n\nuniform vec4 edgeColor: [0,0,0,0.8];\n\nvarying vec2 v_Texcoord;\n\nvec3 packColor(vec2 coord) {\n float z = texture2D(depthTexture, coord).r * 2.0 - 1.0;\n vec4 p = vec4(v_Texcoord * 2.0 - 1.0, z, 1.0);\n vec4 p4 = projectionInv * p;\n\n return vec3(\n texture2D(normalTexture, coord).rg,\n -p4.z / p4.w / 5.0\n );\n}\n\nvoid main() {\n vec2 cc = v_Texcoord;\n vec3 center = packColor(cc);\n\n float size = clamp(1.0 - (center.z - 10.0) / 100.0, 0.0, 1.0) * 0.5;\n float dx = size / textureSize.x;\n float dy = size / textureSize.y;\n\n vec2 coord;\n vec3 topLeft = packColor(cc+vec2(-dx, -dy));\n vec3 top = packColor(cc+vec2(0.0, -dy));\n vec3 topRight = packColor(cc+vec2(dx, -dy));\n vec3 left = packColor(cc+vec2(-dx, 0.0));\n vec3 right = packColor(cc+vec2(dx, 0.0));\n vec3 bottomLeft = packColor(cc+vec2(-dx, dy));\n vec3 bottom = packColor(cc+vec2(0.0, dy));\n vec3 bottomRight = packColor(cc+vec2(dx, dy));\n\n vec3 v = -topLeft-2.0*top-topRight+bottomLeft+2.0*bottom+bottomRight;\n vec3 h = -bottomLeft-2.0*left-topLeft+bottomRight+2.0*right+topRight;\n\n float edge = sqrt(dot(h, h) + dot(v, v));\n\n edge = smoothstep(0.8, 1.0, edge);\n\n gl_FragColor = mix(texture2D(texture, v_Texcoord), vec4(edgeColor.rgb, 1.0), edgeColor.a * edge);\n}\n@end"},function(e,t,n){"use strict";function a(){for(var e=[],t=0;t<30;t++)e.push([Object(i.a)(t,2),Object(i.a)(t,3)]);this._haltonSequence=e,this._frame=0,this._sourceTex=new s.a,this._sourceFb=new o.a,this._sourceFb.attach(this._sourceTex),this._prevFrameTex=new s.a,this._outputTex=new s.a;var n=this._blendPass=new r.a({fragment:c.a.source("qtek.compositor.blend")});n.material.shader.disableTexturesAll(),n.material.shader.enableTexture(["texture1","texture2"]),this._blendFb=new o.a({depthBuffer:!1}),this._outputPass=new r.a({fragment:c.a.source("qtek.compositor.output"),blendWithPrevious:!0}),this._outputPass.material.shader.define("fragment","OUTPUT_ALPHA"),this._outputPass.material.blend=function(e){e.blendEquationSeparate(e.FUNC_ADD,e.FUNC_ADD),e.blendFuncSeparate(e.ONE,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA)}}var i=n(28),r=n(12),o=n(10),s=n(5),c=n(4),l=n(8);a.prototype={constructor:a,jitterProjection:function(e,t){var n=e.viewport,a=n.devicePixelRatio||e.getDevicePixelRatio(),i=n.width*a,r=n.height*a,o=this._haltonSequence[this._frame],s=new l.a;s._array[12]=(2*o[0]-1)/i,s._array[13]=(2*o[1]-1)/r,l.a.mul(t.projectionMatrix,s,t.projectionMatrix),l.a.invert(t.invProjectionMatrix,t.projectionMatrix)},resetFrame:function(){this._frame=0},getFrame:function(){return this._frame},getSourceFrameBuffer:function(){return this._sourceFb},resize:function(e,t){this._sourceTex.width===e&&this._sourceTex.height===t||(this._prevFrameTex.width=e,this._prevFrameTex.height=t,this._outputTex.width=e,this._outputTex.height=t,this._sourceTex.width=e,this._sourceTex.height=t,this._prevFrameTex.dirty(),this._outputTex.dirty(),this._sourceTex.dirty())},isFinished:function(){return this._frame>=this._haltonSequence.length},render:function(e){var t=this._blendPass;0===this._frame?(t.setUniform("weight1",0),t.setUniform("weight2",1)):(t.setUniform("weight1",.9),t.setUniform("weight2",.1)),t.setUniform("texture1",this._prevFrameTex),t.setUniform("texture2",this._sourceTex),this._blendFb.attach(this._outputTex),this._blendFb.bind(e),t.render(e),this._blendFb.unbind(e),this._outputPass.setUniform("texture",this._outputTex),this._outputPass.render(e);var n=this._prevFrameTex;this._prevFrameTex=this._outputTex,this._outputTex=n,this._frame++},dispose:function(e){this._sourceFb.dispose(e),this._blendFb.dispose(e),this._prevFrameTex.dispose(e),this._outputTex.dispose(e),this._sourceTex.dispose(e),this._outputPass.dispose(e),this._blendPass.dispose(e)}},t.a=a},function(e,t,n){"use strict";function a(e){this.setScene(e)}var i=n(29),r=n(36),o=n(35),s=n(2),c=n(60),l=n(131);a.prototype={constructor:a,setScene:function(e){this._scene=e,this._skybox&&this._skybox.attachScene(this._scene)},initLight:function(e){this._lightRoot=e,this.mainLight=new c.a({shadowBias:.005}),this.secondaryLight=new c.a({shadowBias:.005}),this.tertiaryLight=new c.a({shadowBias:.005}),this.ambientLight=new l.a},dispose:function(e){this._lightRoot&&(this._lightRoot.remove(this.mainLight),this._lightRoot.remove(this.ambientLight)),this._currentCubemapLights&&(this._lightRoot.remove(this._currentCubemapLights.diffuse),this._currentCubemapLights.specular&&(this._lightRoot.remove(this._currentCubemapLights.specular),this._currentCubemapLights.specular.cubemap.dispose(e)))},updateMainLight:function(e,t){this._updateDirectionalLight(this.mainLight,e,t)},updateSecondaryLight:function(e,t){this._updateDirectionalLight(this.secondaryLight,e,t)},updateTertiaryLight:function(e,t){this._updateDirectionalLight(this.tertiaryLight,e,t)},_updateDirectionalLight:function(e,t,n){t=t||{},null!=t.intensity&&(e.intensity=t.intensity,this._lightRoot[t.intensity?"add":"remove"](e)),null!=t.color&&(e.color=i.a.parseColor(t.color).slice(0,3));var a=i.a.firstNotNull(t.alpha,45),r=i.a.firstNotNull(t.beta,45);e.position.setArray(i.a.directionFromAlphaBeta(a,r)),e.lookAt(s.a.ZERO);var o={low:512,medium:1024,high:2048,ultra:4096}[t.quality]||1024;e.castShadow=i.a.firstNotNull(t.shadow,!0),e.shadowResolution=o},updateAmbientLight:function(e,t){e=e||{},null!=e.intensity&&(this.ambientLight.intensity=e.intensity,this._lightRoot[e.intensity?"add":"remove"](this.ambientLight)),null!=e.color&&(this.ambientLight.color=i.a.parseColor(e.color).slice(0,3))},updateAmbientCubemapLight:function(e,t){e=e||{};var n=t.getRenderer(),a=e.texture,o=this;if("texture"in e&&(!this._currentCubemapLights||a!==this._currentCubemapLights.textureUrl))if(this._currentCubemapLights&&(this._lightRoot.remove(this._currentCubemapLights.diffuse),this._currentCubemapLights.specular&&(this._lightRoot.remove(this._currentCubemapLights.specular),this._currentCubemapLights.specular.cubemap.dispose(n.gl))),a){var s=i.a.createAmbientCubemap(e,t,function(){s.specular&&o._skybox instanceof r.a&&o._skybox.setEnvironmentMap(s.specular.cubemap),t.refresh()});s.diffuse&&this._lightRoot.add(s.diffuse),s.specular&&this._lightRoot.add(s.specular),this._currentCubemapLights=s,this._currentCubemapLights.textureUrl=a}else this._currentCubemapLights&&(this._lightRoot.remove(this._currentCubemapLights.diffuse),this._lightRoot.remove(this._currentCubemapLights.specular),this._currentCubemapLights=null);this._currentCubemapLights&&(null!=e.specularIntensity&&this._currentCubemapLights.specular&&(this._currentCubemapLights.specular.intensity=e.specularIntensity),null!=e.diffuseIntensity&&this._currentCubemapLights.diffuse&&(this._currentCubemapLights.diffuse.intensity=e.diffuseIntensity))},updateSkybox:function(e,t,n){var a=n.getRenderer(),s=this;if(e&&"none"!==e)if("auto"===e)if(this._currentCubemapLights){var c=function(){return s._skybox instanceof r.a||(s._skybox&&s._skybox.dispose(a),s._skybox=new r.a),s._skybox}();if(this._currentCubemapLights.specular){var l=this._currentCubemapLights.specular.cubemap;c.setEnvironmentMap(l)}this._scene&&c.attachScene(this._scene),c.material.set("lod",2)}else this._skybox&&this._skybox.detachScene();else{var u=function(){return s._skybox instanceof o.a||(s._skybox&&s._skybox.dispose(a),s._skybox=new o.a),s._skybox}(),p=i.a.loadTexture(e,n,{flipY:!1},function(){n.refresh()});u.setEnvironmentMap(p),u.attachScene(this._scene)}else this._skybox&&this._skybox.detachScene(this._scene),this._skybox=null;if(this._skybox)if("auto"===e||e.match&&e.match(/.hdr$/))this._skybox.material.shader.undefine("fragment","SRGB_DECODE");else{var d=t?"define":"undefine";this._skybox.material.shader[d]("fragment","SRGB_DECODE")}}},t.a=a},function(e,t,n){"use strict";var a=n(14),i=a.a.extend({castShadow:!1},{type:"AMBIENT_LIGHT",uniformTemplates:{ambientLightColor:{type:"3f",value:function(e){var t=e.color,n=e.intensity;return[t[0]*n,t[1]*n,t[2]*n]}}}});t.a=i},function(e,t,n){"use strict";t.a={devicePixelRatio:null,preZ:!1,picking:!1,shadow:!0,environment:"",ground:{show:!1},mainLight:{shadow:!0,shadowQuality:"medium",intensity:.8,color:"#fff",alpha:45,beta:45},secondaryLight:{shadow:!1,shadowQuality:"medium",intensity:0,color:"#fff",alpha:60,beta:-50},tertiaryLight:{shadow:!1,shadowQuality:"medium",intensity:0,color:"#fff",alpha:89,beta:0},ambientLight:{intensity:.3,color:"#fff"},ambientCubemapLight:{texture:"",exposure:3,diffuseIntensity:.5,specularIntensity:.5},postEffect:{enable:!1,bloom:{enable:!1,intensity:.1},depthOfField:{enable:!1,focalDistance:5,focalRange:1,blurRadius:5,fstop:2.8,quality:"medium"},screenSpaceAmbientOcculusion:{enable:!1,radius:.5,quality:"medium",intensity:1},screenSpaceReflection:{enable:!1,quality:"medium",maxRoughness:.8},colorCorrection:{enable:!0,exposure:0,brightness:0,contrast:1,saturation:1,lookupTexture:""},FXAA:{enable:!1}}}},function(e,t,n){"use strict";function a(e){if(null==e||"object"!=typeof e)return e;var t=e,n=m.call(e);if("[object Array]"===n){t=[];for(var i=0,r=e.length;i=0&&i[d]>1e-6&&(c.transformMat4(s,n,r[a[d]]),c.scaleAndAdd(o,o,s,i[d]));c.min(v,v,o),c.max(_,_,o)}t.min.setArray(v),t.max.setArray(_)}function i(e,t){t=t||new r.a;var n=new r.a;return e.traverse(function(e){e.geometry&&(e.isSkinnedMesh()?(a(e,n),e.geometry.boundingBox.copy(n)):(n.copy(e.geometry.boundingBox),n.applyTransform(e.worldTransform)),t.union(n))}),t}var r=n(7),o=n(0),s=n.n(o),c=s.a.vec3;t.a=i},function(e,t,n){"use strict";function a(e){return Array.isArray(e)||(e=[e,e]),e}var i=n(1),r=n(24),o=n(2),s=n(136),c=i.a.extend(function(){return{animation:null,domElement:null,target:null,_center:new o.a,minDistance:.1,maxDistance:1e3,minAlpha:-90,maxAlpha:90,minBeta:-1/0,maxBeta:1/0,autoRotateAfterStill:0,autoRotateDirection:"cw",autoRotateSpeed:60,_mode:"rotate",damping:.8,rotateSensitivity:1,zoomSensitivity:1,panSensitivity:1,_needsUpdate:!1,_rotating:!1,_phi:0,_theta:0,_mouseX:0,_mouseY:0,_rotateVelocity:new r.a,_panVelocity:new r.a,_distance:20,_zoomSpeed:0,_stillTimeout:0,_animators:[],_gestureMgr:new s.a}},function(){this._mouseDownHandler=this._mouseDownHandler.bind(this),this._mouseWheelHandler=this._mouseWheelHandler.bind(this),this._mouseMoveHandler=this._mouseMoveHandler.bind(this),this._mouseUpHandler=this._mouseUpHandler.bind(this),this._pinchHandler=this._pinchHandler.bind(this),this.update=this.update.bind(this),this.init()},{init:function(){var e=this.domElement;e.addEventListener("touchstart",this._mouseDownHandler),e.addEventListener("mousedown",this._mouseDownHandler),e.addEventListener("mousewheel",this._mouseWheelHandler),this.animation&&this.animation.on("frame",this.update)},dispose:function(){var e=this.domElement;e.removeEventListener("touchstart",this._mouseDownHandler),e.removeEventListener("touchmove",this._mouseMoveHandler),e.removeEventListener("touchend",this._mouseUpHandler),e.removeEventListener("mousedown",this._mouseDownHandler),e.removeEventListener("mousemove",this._mouseMoveHandler),e.removeEventListener("mouseup",this._mouseUpHandler),e.removeEventListener("mousewheel",this._mouseWheelHandler),this.animation&&this.animation.off("frame",this.update),this.stopAllAnimation()},getDistance:function(){return this._distance},setDistance:function(e){this._distance=e,this._needsUpdate=!0},getAlpha:function(){return this._theta/Math.PI*180},getBeta:function(){return-this._phi/Math.PI*180},getCenter:function(){return this._center.toArray()},setAlpha:function(e){e=Math.max(Math.min(this.maxAlpha,e),this.minAlpha),this._theta=e/180*Math.PI,this._needsUpdate=!0},setBeta:function(e){e=Math.max(Math.min(this.maxBeta,e),this.minBeta),this._phi=-e/180*Math.PI,this._needsUpdate=!0},setCenter:function(e){this._center.setArray(e)},setOption:function(e){e=e||{},["autoRotate","autoRotateAfterStill","autoRotateDirection","autoRotateSpeed","damping","minDistance","maxDistance","minAlpha","maxAlpha","minBeta","maxBeta","rotateSensitivity","zoomSensitivity","panSensitivity"].forEach(function(t){null!=e[t]&&(this[t]=e[t])},this),null!=e.distance&&this.setDistance(e.distance),null!=e.alpha&&this.setAlpha(e.alpha),null!=e.beta&&this.setBeta(e.beta),e.center&&this.setCenter(e.center)},animateTo:function(e){var t=this,n={},a={},i=this.animation;if(i)return null!=e.distance&&(n.distance=this.getDistance(),a.distance=e.distance),null!=e.alpha&&(n.alpha=this.getAlpha(),a.alpha=e.alpha),null!=e.beta&&(n.beta=this.getBeta(),a.beta=e.beta),null!=e.center&&(n.center=this.getCenter(),a.center=e.center),this._addAnimator(i.animate(n).when(e.duration||1e3,a).during(function(){null!=n.alpha&&t.setAlpha(n.alpha),null!=n.beta&&t.setBeta(n.beta),null!=n.distance&&t.setDistance(n.distance),null!=n.center&&t.setCenter(n.center),t._needsUpdate=!0}).done(e.done)).start(e.easing||"linear")},stopAllAnimation:function(){for(var e=0;e0},update:function(e){if(e=e||16,this._rotating){var t=("cw"===this.autoRotateDirection?1:-1)*this.autoRotateSpeed/180*Math.PI;this._phi-=t*e/1e3,this._needsUpdate=!0}else this._rotateVelocity.len()>0&&(this._needsUpdate=!0);(Math.abs(this._zoomSpeed)>.01||this._panVelocity.len()>0)&&(this._needsUpdate=!0),this._needsUpdate&&(this._updateDistance(Math.min(e,50)),this._updatePan(Math.min(e,50)),this._updateRotate(Math.min(e,50)),this._updateTransform(),this.target.update(),this.trigger("update"),this._needsUpdate=!1)},_updateRotate:function(e){var t=this._rotateVelocity;this._phi=t.y*e/20+this._phi,this._theta=t.x*e/20+this._theta,this.setAlpha(this.getAlpha()),this.setBeta(this.getBeta()),this._vectorDamping(t,this.damping)},_updateDistance:function(e){this._setDistance(this._distance+this._zoomSpeed*e/20),this._zoomSpeed*=this.damping},_setDistance:function(e){this._distance=Math.max(Math.min(e,this.maxDistance),this.minDistance)},_updatePan:function(e){var t=this._panVelocity,n=this._distance,a=this.target,i=a.worldTransform.y,r=a.worldTransform.x;this._center.scaleAndAdd(r,-t.x*n/200).scaleAndAdd(i,-t.y*n/200),this._vectorDamping(t,0)},_updateTransform:function(){var e=this.target,t=new o.a,n=this._theta+Math.PI/2,a=this._phi+Math.PI/2,i=Math.sin(n);t.x=i*Math.cos(a),t.y=-Math.cos(n),t.z=i*Math.sin(a),e.position.copy(this._center).scaleAndAdd(t,this._distance),e.rotation.identity().rotateY(-this._phi).rotateX(-this._theta)},_startCountingStill:function(){clearTimeout(this._stillTimeout);var e=this.autoRotateAfterStill,t=this;!isNaN(e)&&e>0&&(this._stillTimeout=setTimeout(function(){t._rotating=!0},1e3*e))},_vectorDamping:function(e,t){var n=e.len();n*=t,n<1e-4&&(n=0),e.normalize().scale(n)},decomposeTransform:function(){if(this.target){var e=new o.a;e.eulerFromQuat(this.target.rotation.normalize(),"ZYX"),this._theta=-e.x,this._phi=-e.y,this.setBeta(this.getBeta()),this.setAlpha(this.getAlpha()),this._setDistance(this.target.position.dist(this._center))}},_mouseDownHandler:function(e){if(!this._isAnimating()){var t=e.clientX,n=e.clientY;if(e.targetTouches){var a=e.targetTouches[0];t=a.clientX,n=a.clientY,this._mode="rotate",this._processGesture(e,"start")}var i=this.domElement;i.addEventListener("touchmove",this._mouseMoveHandler),i.addEventListener("touchend",this._mouseUpHandler),i.addEventListener("mousemove",this._mouseMoveHandler),i.addEventListener("mouseup",this._mouseUpHandler),0===e.button?this._mode="rotate":1===e.button&&(this._mode="pan"),this._rotateVelocity.set(0,0),this._rotating=!1,this.autoRotate&&this._startCountingStill(),this._mouseX=t,this._mouseY=n}},_mouseMoveHandler:function(e){if(!this._isAnimating()){var t,n=e.clientX,i=e.clientY;if(e.targetTouches){var r=e.targetTouches[0];n=r.clientX,i=r.clientY,t=this._processGesture(e,"change")}var o=a(this.panSensitivity),s=a(this.rotateSensitivity);t||("rotate"===this._mode?(this._rotateVelocity.y=(n-this._mouseX)/this.domElement.clientHeight*2*s[0],this._rotateVelocity.x=(i-this._mouseY)/this.domElement.clientWidth*2*s[1]):"pan"===this._mode&&(this._panVelocity.x=(n-this._mouseX)/this.domElement.clientWidth*o[0]*400,this._panVelocity.y=(-i+this._mouseY)/this.domElement.clientHeight*o[1]*400)),this._mouseX=n,this._mouseY=i,e.preventDefault()}},_mouseWheelHandler:function(e){if(!this._isAnimating()){var t=e.wheelDelta||-e.detail;0!==t&&this._zoomHandler(e,t>0?-1:1)}},_pinchHandler:function(e){this._isAnimating()||this._zoomHandler(e,e.pinchScale>1?-.4:.4)},_zoomHandler:function(e,t){var n=Math.max(Math.min(this._distance-this.minDistance,this.maxDistance-this._distance));this._zoomSpeed=t*Math.max(n/40*this.zoomSensitivity,.2),this._rotating=!1,this.autoRotate&&"rotate"===this._mode&&this._startCountingStill(),e.preventDefault()},_mouseUpHandler:function(e){var t=this.domElement;t.removeEventListener("touchmove",this._mouseMoveHandler),t.removeEventListener("touchend",this._mouseUpHandler),t.removeEventListener("mousemove",this._mouseMoveHandler),t.removeEventListener("mouseup",this._mouseUpHandler),this._processGesture(e,"end")},_addAnimator:function(e){var t=this._animators;return t.push(e),e.done(function(){var n=t.indexOf(e);n>=0&&t.splice(n,1)}),e},_processGesture:function(e,t){var n=this._gestureMgr;"start"===t&&n.clear();var a=n.recognize(e,null,this.domElement);if("end"===t&&n.clear(),a){var i=a.type;e.gestureEvent=i,this._pinchHandler(a.event)}return a}});Object.defineProperty(c.prototype,"autoRotate",{get:function(){return this._autoRotate},set:function(e){this._autoRotate=e,this._rotating=e}}),Object.defineProperty(c.prototype,"target",{get:function(){return this._target},set:function(e){e&&e.target&&this.setCenter(e.target.toArray()),this._target=e,this.decomposeTransform()}}),t.a=c},function(e,t,n){"use strict";function a(e){var t=e[1][0]-e[0][0],n=e[1][1]-e[0][1];return Math.sqrt(t*t+n*n)}function i(e){return[(e[0][0]+e[1][0])/2,(e[0][1]+e[1][1])/2]}var r=function(){this._track=[]};r.prototype={constructor:r,recognize:function(e,t,n){return this._doTrack(e,t,n),this._recognize(e)},clear:function(){return this._track.length=0,this},_doTrack:function(e,t,n){var a=e.targetTouches;if(a){for(var i={points:[],touches:[],target:t,event:e},r=0,o=a.length;r1&&r&&r.length>1){var s=a(r)/a(o);!isFinite(s)&&(s=1),t.pinchScale=s;var c=i(r);return t.pinchX=c[0],t.pinchY=c[1],{type:"pinch",target:e[0].target,event:t}}}}};t.a=r},function(e,t,n){"use strict";var a=n(1),i=n(138),r=n(7),o=a.a.extend(function(){return{dom:null,renderer:null,camera:null,_boundingBox:new r.a,_hotspotRoot:null,_hotspots:[]}},function(){if(!this.dom||!this.renderer||!this.camera)throw new Error("Tip manager needs `root`, `camera`, `renderer`");var e=this._hotspotRoot=document.createElement("div");e.style.cssText="position:absolute;top:0;left:0;right:0;bottom:0;overflow:hidden;",this.dom.appendChild(e)},{setBoundingBox:function(e,t){this._boundingBox.min.setArray(e),this._boundingBox.max.setArray(t)},add:function(e,t){if("string"==typeof t){var n=document.createElement("div");n.innerHTML=t,t=n}return t.classList.add("qmv-annotation"),t.style.position="absolute",this._hotspotRoot.appendChild(t),this._hotspots.push({position:e,dom:t}),t},remove:function(e){for(var t=-1,n=0;n=0&&(this._hotspots.splice(t,1),this._hotspotRoot.removeChild(e))},update:function(){var e=new i.a,t=new r.a;this._hotspots.forEach(function(n){var a=n.position;e.set(a[0],a[1],a[2],1),e.transformMat4(this.camera.viewMatrix);var i=e.z;e.transformMat4(this.camera.projectionMatrix),e.scale(1/e.w);var r=.5*(e.x+1)*this.renderer.getWidth(),o=.5*(e.y+1)*this.renderer.getHeight();n.dom.style.left=r+"px",n.dom.style.top=this.renderer.getHeight()-o+"px";var s=null==n.farAlpha?.1:n.farAlpha,c=null==n.nearAlpha?1:n.nearAlpha;t.copy(this._boundingBox),t.applyTransform(this.camera.viewMatrix);var l=(i-t.max.z)/(t.min.z-t.max.z);Math.max(Math.min(l,1),0);n.dom.style.opacity=1,n.onupdate&&n.onupdate(r,o)},this)}});t.a=o},function(e,t,n){"use strict";var a=n(0),i=n.n(a),r=i.a.vec4,o=function(e,t,n,a){e=e||0,t=t||0,n=n||0,a=a||0,this._array=r.fromValues(e,t,n,a),this._dirty=!0};o.prototype={constructor:o,add:function(e){return r.add(this._array,this._array,e._array),this._dirty=!0,this},set:function(e,t,n,a){return this._array[0]=e,this._array[1]=t,this._array[2]=n,this._array[3]=a,this._dirty=!0,this},setArray:function(e){return this._array[0]=e[0],this._array[1]=e[1],this._array[2]=e[2],this._array[3]=e[3],this._dirty=!0,this},clone:function(){return new o(this.x,this.y,this.z,this.w)},copy:function(e){return r.copy(this._array,e._array),this._dirty=!0,this},dist:function(e){return r.dist(this._array,e._array)},distance:function(e){return r.distance(this._array,e._array)},div:function(e){return r.div(this._array,this._array,e._array),this._dirty=!0,this},divide:function(e){return r.divide(this._array,this._array,e._array),this._dirty=!0,this},dot:function(e){return r.dot(this._array,e._array)},len:function(){return r.len(this._array)},length:function(){return r.length(this._array)},lerp:function(e,t,n){return r.lerp(this._array,e._array,t._array,n),this._dirty=!0,this},min:function(e){return r.min(this._array,this._array,e._array),this._dirty=!0,this},max:function(e){return r.max(this._array,this._array,e._array),this._dirty=!0,this},mul:function(e){return r.mul(this._array,this._array,e._array),this._dirty=!0,this},multiply:function(e){return r.multiply(this._array,this._array,e._array),this._dirty=!0,this},negate:function(){return r.negate(this._array,this._array),this._dirty=!0,this},normalize:function(){return r.normalize(this._array,this._array),this._dirty=!0,this},random:function(e){return r.random(this._array,e),this._dirty=!0,this},scale:function(e){return r.scale(this._array,this._array,e),this._dirty=!0,this},scaleAndAdd:function(e,t){return r.scaleAndAdd(this._array,this._array,e._array,t),this._dirty=!0,this},sqrDist:function(e){return r.sqrDist(this._array,e._array)},squaredDistance:function(e){return r.squaredDistance(this._array,e._array)},sqrLen:function(){return r.sqrLen(this._array)},squaredLength:function(){return r.squaredLength(this._array)},sub:function(e){return r.sub(this._array,this._array,e._array),this._dirty=!0,this},subtract:function(e){return r.subtract(this._array,this._array,e._array),this._dirty=!0,this},transformMat4:function(e){return r.transformMat4(this._array,this._array,e._array),this._dirty=!0,this},transformQuat:function(e){return r.transformQuat(this._array,this._array,e._array),this._dirty=!0,this},toString:function(){return"["+Array.prototype.join.call(this._array,",")+"]"},toArray:function(){return Array.prototype.slice.call(this._array)}};var s=Object.defineProperty;if(s){var c=o.prototype;s(c,"x",{get:function(){return this._array[0]},set:function(e){this._array[0]=e,this._dirty=!0}}),s(c,"y",{get:function(){return this._array[1]},set:function(e){this._array[1]=e,this._dirty=!0}}),s(c,"z",{get:function(){return this._array[2]},set:function(e){this._array[2]=e,this._dirty=!0}}),s(c,"w",{get:function(){return this._array[3]},set:function(e){this._array[3]=e,this._dirty=!0}})}o.add=function(e,t,n){return r.add(e._array,t._array,n._array),e._dirty=!0,e},o.set=function(e,t,n,a,i){r.set(e._array,t,n,a,i),e._dirty=!0},o.copy=function(e,t){return r.copy(e._array,t._array),e._dirty=!0,e},o.dist=function(e,t){return r.distance(e._array,t._array)},o.distance=o.dist,o.div=function(e,t,n){return r.divide(e._array,t._array,n._array),e._dirty=!0,e},o.divide=o.div,o.dot=function(e,t){return r.dot(e._array,t._array)},o.len=function(e){return r.length(e._array)},o.lerp=function(e,t,n,a){return r.lerp(e._array,t._array,n._array,a),e._dirty=!0,e},o.min=function(e,t,n){return r.min(e._array,t._array,n._array),e._dirty=!0,e},o.max=function(e,t,n){return r.max(e._array,t._array,n._array),e._dirty=!0,e},o.mul=function(e,t,n){return r.multiply(e._array,t._array,n._array),e._dirty=!0,e},o.multiply=o.mul,o.negate=function(e,t){return r.negate(e._array,t._array),e._dirty=!0,e},o.normalize=function(e,t){return r.normalize(e._array,t._array),e._dirty=!0,e},o.random=function(e,t){return r.random(e._array,t),e._dirty=!0,e},o.scale=function(e,t,n){return r.scale(e._array,t._array,n),e._dirty=!0,e},o.scaleAndAdd=function(e,t,n,a){return r.scaleAndAdd(e._array,t._array,n._array,a),e._dirty=!0,e},o.sqrDist=function(e,t){return r.sqrDist(e._array,t._array)},o.squaredDistance=o.sqrDist,o.sqrLen=function(e){return r.sqrLen(e._array)},o.squaredLength=o.sqrLen,o.sub=function(e,t,n){return r.subtract(e._array,t._array,n._array),e._dirty=!0,e},o.subtract=o.sub,o.transformMat4=function(e,t,n){return r.transformMat4(e._array,t._array,n._array),e._dirty=!0,e},o.transformQuat=function(e,t,n){return r.transformQuat(e._array,t._array,n._array),e._dirty=!0,e},t.a=o},function(e,t,n){"use strict";t.a="@export qmv.ground.vertex\n@import qtek.lambert.vertex\n@end\n\n\n@export qmv.ground.fragment\n\nvarying vec2 v_Texcoord;\nvarying vec3 v_Normal;\nvarying vec3 v_WorldPosition;\n\nuniform vec4 color : [1.0, 1.0, 1.0, 1.0];\nuniform float gridSize: 5;\nuniform float gridSize2: 1;\nuniform vec4 gridColor: [0, 0, 0, 1];\nuniform vec4 gridColor2: [0.3, 0.3, 0.3, 1];\n\nuniform float glossiness: 0.7;\n\n#ifdef SSAOMAP_ENABLED\nuniform sampler2D ssaoMap;\nuniform vec4 viewport : VIEWPORT;\n#endif\n\n#ifdef AMBIENT_LIGHT_COUNT\n@import qtek.header.ambient_light\n#endif\n#ifdef AMBIENT_SH_LIGHT_COUNT\n@import qtek.header.ambient_sh_light\n#endif\n#ifdef DIRECTIONAL_LIGHT_COUNT\n@import qtek.header.directional_light\n#endif\n\n@import qtek.plugin.compute_shadow_map\n\nvoid main()\n{\n gl_FragColor = color;\n\n float wx = v_WorldPosition.x;\n float wz = v_WorldPosition.z;\n float x0 = abs(fract(wx / gridSize - 0.5) - 0.5) / fwidth(wx) * gridSize / 2.0;\n float z0 = abs(fract(wz / gridSize - 0.5) - 0.5) / fwidth(wz) * gridSize / 2.0;\n\n float x1 = abs(fract(wx / gridSize2 - 0.5) - 0.5) / fwidth(wx) * gridSize2;\n float z1 = abs(fract(wz / gridSize2 - 0.5) - 0.5) / fwidth(wz) * gridSize2;\n\n float v0 = 1.0 - clamp(min(x0, z0), 0.0, 1.0);\n float v1 = 1.0 - clamp(min(x1, z1), 0.0, 1.0);\n if (v0 > 0.1) {\n gl_FragColor = mix(gl_FragColor, gridColor, v0);\n }\n else {\n gl_FragColor = mix(gl_FragColor, gridColor2, v1);\n }\n\n vec3 diffuseColor = vec3(0.0, 0.0, 0.0);\n\n#ifdef AMBIENT_LIGHT_COUNT\n for(int _idx_ = 0; _idx_ < AMBIENT_LIGHT_COUNT; _idx_++)\n {\n diffuseColor += ambientLightColor[_idx_];\n }\n#endif\n#ifdef AMBIENT_SH_LIGHT_COUNT\n for(int _idx_ = 0; _idx_ < AMBIENT_SH_LIGHT_COUNT; _idx_++)\n {{\n diffuseColor += calcAmbientSHLight(_idx_, v_Normal) * ambientSHLightColor[_idx_];\n }}\n#endif\n\n#ifdef DIRECTIONAL_LIGHT_COUNT\n#if defined(DIRECTIONAL_LIGHT_SHADOWMAP_COUNT)\n float shadowContribsDir[DIRECTIONAL_LIGHT_COUNT];\n if(shadowEnabled)\n {\n computeShadowOfDirectionalLights(v_WorldPosition, shadowContribsDir);\n }\n#endif\n for(int i = 0; i < DIRECTIONAL_LIGHT_COUNT; i++)\n {\n vec3 lightDirection = -directionalLightDirection[i];\n vec3 lightColor = directionalLightColor[i];\n\n float ndl = dot(v_Normal, normalize(lightDirection));\n\n float shadowContrib = 1.0;\n#if defined(DIRECTIONAL_LIGHT_SHADOWMAP_COUNT)\n if( shadowEnabled )\n {\n shadowContrib = shadowContribsDir[i];\n }\n#endif\n\n diffuseColor += lightColor * clamp(ndl, 0.0, 1.0) * shadowContrib;\n }\n#endif\n\n#ifdef SSAOMAP_ENABLED\n diffuseColor *= texture2D(ssaoMap, (gl_FragCoord.xy - viewport.xy) / viewport.zw).r;\n#endif\n\n gl_FragColor.rgb *= diffuseColor;\n\n gl_FragColor.a *= 1.0 - clamp(length(v_WorldPosition.xz) / 30.0, 0.0, 1.0);\n\n}\n\n@end"},function(e,t,n){"use strict";var a=n(37);t.a=function(){return{preZ:!0,materials:[],takes:[],textureFlipY:!1,zUpToYUp:!1,shadow:!0,environment:"auto",viewControl:{alpha:20,beta:30,distance:18},ground:{show:!0},mainLight:{shadow:!0,shadowQuality:"medium",intensity:.8,color:"#fff",alpha:45,beta:45,$padAngle:[.25,.5]},secondaryLight:{shadow:!1,shadowQuality:"medium",intensity:0,color:"#fff",alpha:60,beta:-50,$padAngle:[-50/180,60/90]},tertiaryLight:{shadow:!1,shadowQuality:"medium",intensity:0,color:"#fff",alpha:89,beta:0,$padAngle:[0,89/90]},ambientLight:{intensity:0,color:"#fff"},ambientCubemapLight:{texture:a.a.ENV_TEXTURE_ROOT+"pisa.hdr",$texture:"pisa",$textureOptions:["pisa","Barce_Rooftop_C","Factory_Catwalk","Grand_Canyon_C","Ice_Lake","Hall","Old_Industrial_Hall"],exposure:3,diffuseIntensity:.5,specularIntensity:.5,$intensity:.5},postEffect:{enable:!0,bloom:{enable:!0,intensity:.1},depthOfField:{enable:!1,focalDistance:4,focalRange:1,blurRadius:5,fstop:10,quality:"medium",$qualityOptions:["low","medium","high","ultra"]},screenSpaceAmbientOcclusion:{enable:!1,radius:1.5,quality:"medium",intensity:1,$qualityOptions:["low","medium","high","ultra"]},screenSpaceReflection:{enable:!1,quality:"medium",maxRoughness:.8,$qualityOptions:["low","medium","high","ultra"]},colorCorrection:{enable:!0,exposure:0,brightness:0,contrast:1,saturation:1,lookupTexture:""},FXAA:{enable:!1}}}}},function(e,t,n){"use strict";t.a=function(){return{name:"",type:"pbrMetallicRoughness",color:"#fff",transparent:!1,alpha:1,alphaCutoff:0,diffuseMap:"",normalMap:"",parallaxOcclusionScale:.01,parallaxOcclusionMap:"",emission:"#fff",emissionIntensity:0,emissiveMap:"",uvRepeat:[1,1],metalness:0,roughness:.5,metalnessMap:"",roughnessMap:"",glossiness:.5,specularColor:"#111",glossinessMap:"",specularMap:"",$alphaRange:[0,1],$alphaCutoffRange:[0,1],$metalnessRange:[0,1],$roughnessRange:[0,1],$glossinessRange:[0,1],$parallaxOcclusionScaleRange:[0,.1],$textureTiling:1}}},function(e,t,n){"use strict";function a(e){var t=e.lastIndexOf(".");return t>=0?e.substr(t+1).toLowerCase():""}function i(e,t){var n=e.split("/");return t=t||"",0===e.indexOf("/")&&n.shift(),n=n.filter(function(e){return!!e}),new Promise(function(e,a){if(!x)return void a(E);var r=n.shift(),o=t+"/"+r;x.mkdir(o,function(t){t&&"EEXIST"!==t.code?a(t.toString()):n.length?i(n.join("/"),o).then(e).catch(a):e()})})}function r(e){return new Promise(function(t,n){if(!x)return void n(E);s(e).then(function(t){return Promise.all(t.map(function(t){return new Promise(function(n,a){var i=e+"/"+t;x.lstat(i,function(e,t){e?a(e.toString()):t.isDirectory()?r(i).then(n,a):x.unlink(i,function(e){e?a(e.toString()):n()})})})}))},n).then(function(){x.rmdir(e,function(e){e?n(e.toString()):t()})},n)})}function o(e,t){return new Promise(function(n,a){x||a(E),FileAPI.readAsArrayBuffer(t,function(i){"load"===i.type&&x.writeFile(e,T.from(i.result),function(e){e&&"EEXIST"!==e.code?a(e):(console.log("Writed file "+t.name+" "+i.result.byteLength),n())})})})}function s(e){return new Promise(function(t,n){x.readdir(e,function(e,a){e?n(e):t(a)})})}function c(e){BrowserFS.install(window),BrowserFS.configure({fs:"IndexedDB",options:{}},function(t){if(t)throw t;x=BrowserFS.BFSRequire("fs"),i("/project").then(function(){Promise.all([d(),p()]).then(function(t){t[0]?e&&e(t[0].glTF,t[0].filesMap,t[1]):e()}).catch(function(t){e()})},function(t){e()})})}function l(e){function t(){return i("/project/model").then(function(){return Promise.all(e.map(function(e){return o("/project/model/"+e.name,e)}))})}return r("/project/model").then(function(){return t()},function(e){return t()})}function u(e){return i("/project").then(function(){return o("/project/scene.json",new File([JSON.stringify(e)],"scene.json",{type:"application/json"}))})}function p(){return new Promise(function(e,t){if(!x)return void t(E);x.readFile("/project/scene.json","utf-8",function(t,n){if(t)e(null);else{var a=null;try{a=JSON.parse(n)}catch(e){console.error(e)}e(a)}})})}function d(){return m().then(function(e){return v(e)})}function f(e){return i("/project/model").then(function(){return o("/project/model/"+e.name,e)})}function h(){return r("/project")}function m(){return s("/project/model").then(function(e){return Promise.all(e.map(function(e){return new Promise(function(t,n){x.readFile("/project/model/"+e,function(i,r){i?n(i):t(new File([r],e,{type:b.a.lookup(a(e))}))})})}))})}function v(e){return new Promise(function(t,n){function a(n,a,o){function s(t){var n=0;e.forEach(function(e){e!==i&&(n++,l[e.name]=URL.createObjectURL(e))}),t&&t(l)}e=e.filter(function(e){return e.name.match(/.(gltf|bin|glb)$/)||e.type.match(/image/)});for(var c in w)URL.revokeObjectURL(w[c]);var l={};w=l,a?s(function(i){e.push(new File([a],n+".gltf",{type:"application/json"}),new File([o],n+".bin",{type:"application/octet-stream"})),t({glTF:JSON.parse(a),filesMap:i,buffers:[o],allFiles:e})}):r?FileAPI.readAsArrayBuffer(r,function(n){"load"===n.type&&s(function(a){t({glTF:n.result,filesMap:a,allFiles:e})})}):i&&FileAPI.readAsText(i,"utf-8",function(n){if("load"===n.type){var a;try{a=JSON.parse(n.result)}catch(e){return void t(null)}s(function(n){t({glTF:a,filesMap:n,allFiles:e})})}})}var i=e.find(function(e){return e.name.endsWith(".gltf")}),r=e.find(function(e){return e.name.endsWith(".glb")});if(i||r)a();else{n("No glTF file found")}})}function _(e,t,n){Promise.all([m(),p()]).then(function(a){var i,r=a[0],o=a[1],s=new JSZip,c={};if(r=(r||[]).filter(function(e){if(!e.name.endsWith(".gltf"))return c[e.name]=e,!0;i=e}),!i)return swal("No glTF file in project!"),void(n&&n());Promise.all(o.materials.map(function(e,t){if(e.metalnessMap||e.roughnessMap){var n=c[e.metalnessMap],a=c[e.roughnessMap];return new Promise(function(i){Object(g.b)(n,a,e.metalness,e.roughness).then(function(n){var a=e.name+"$"+t+"_metallicRoughness.png",r=n.toDataURL();r=r.slice("data:image/png;base64,".length),s.file(a,r,{base64:!0}),e.metalnessMap=e.roughnessMap=a,console.log("Merged %s, %s to %s",e.metalnessMap,e.roughnessMap,a),i()})})}if(e.specularMap||e.glossinessMap){var i=c[e.specularMap],r=c[e.glossinessMap];return new Promise(function(n){Object(g.c)(i,r,e.specularColor,e.glossiness).then(function(a){var i=e.name+"$"+t+"_specularGlossiness.png",r=a.toDataURL();r=r.slice("data:image/png;base64,".length),s.file(i,r,{base64:!0}),e.specularMap=e.glossinessMap=i,console.log("Merged %s, %s to %s",e.specularMap,e.glossinessMap,i),n()})})}return null}).filter(function(e){return null!=e})).then(function(){FileAPI.readAsText(i,"utf-8",function(a){if("load"==a.type){var c=Object(g.d)(JSON.parse(a.result),o);if(c.extensionsUsed=c.extensionsUsed||[],c.extensionsUsed.indexOf("KHR_materials_pbrSpecularGlossiness")<0&&c.extensionsUsed.push("KHR_materials_pbrSpecularGlossiness"),["extensionsUsed","images","textures","samplers","animations"].forEach(function(e){c[e]&&!c[e].length&&delete c[e]}),c.textures||delete c.samplers,r=r.filter(function(e){return e.type.match(/image/)?c.images&&c.images.some(function(t){return t.uri===e.name}):!!e.name.endsWith(".bin")||void 0}),r.forEach(function(e){s.file(e.name,e)}),"glb"===e){var l=[],u=[];s.forEach(function(e,t){(e.endsWith(".bin")?l:u).push({reader:s.file(e).async("arraybuffer"),name:e})}),Promise.all([Promise.all(l.map(function(e){return e.reader})),Promise.all(u.map(function(e){return e.reader}))]).then(function(e){var n=Object(g.a)(c,e[0],e[1].reduce(function(e,t,n){return e[u[n].name]=t,e},{}));saveAs(new Blob([n],{type:"model/json-binary"}),"model.glb"),t&&t()}).catch(n)}else s.file(i.name,JSON.stringify(c,null,2)),s.generateAsync({type:"blob"}).then(function(e){saveAs(e,"model.zip"),t&&t()}).catch(n)}})})}).catch(function(e){swal(e.toString()),n&&n()})}n.d(t,"c",function(){return c}),n.d(t,"e",function(){return l}),n.d(t,"a",function(){return v}),n.d(t,"f",function(){return u}),n.d(t,"g",function(){return f}),n.d(t,"d",function(){return h}),n.d(t,"b",function(){return _});var x,g=(n(37),n(143)),y=(n(144),n(145)),b=n.n(y),T=BrowserFS.BFSRequire("buffer").Buffer,E="File system not prepared yet.",w={}},function(e,t,n){"use strict";function a(e,t){return new Promise(function(t,n){Promise.all(e.map(function(e){var t=e&&URL.createObjectURL(e);return new Promise(function(e,n){if(t){var a=new Image;a.src=t,a.onload=function(){e(a)}}else e(null)})})).then(function(e){var n=e.find(function(e){return null!=e});n||t(null);var a=document.createElement("canvas"),i=a.getContext("2d"),r=a.width=n.width,o=a.height=n.height,s=e.map(function(e){return e?(i.drawImage(e,0,0,r,o),i.getImageData(0,0,r,o).data):null});t({canvas:a,imageDataList:s})})})}function i(e,t,n,i){return new Promise(function(r,o){a([e,t]).then(function(e){for(var t=e.canvas,a=t.getContext("2d"),o=e.imageDataList[0],s=e.imageDataList[1],c=a.createImageData(t.width,t.height),l=0;l<(o||s).length;l+=4){var u=n;if(o){var p=o[l+2]/255;u=Math.min(Math.max(p+2*(u-.5),0),1)}var d=i;if(s){var f=s[l+1]/255;d=Math.min(Math.max(f+2*(d-.5),0),1)}c.data[l]=c.data[l+3]=0,c.data[l+1]=Math.round(255*d),c.data[l+2]=Math.round(255*u)}a.putImageData(c,0,0),r(t)})})}function r(e,t,n,i){return n=d.a.parseColor(n).slice(0,3),new Promise(function(r,o){a([e,t]).then(function(e){for(var t=e.canvas,a=t.getContext("2d"),o=e.imageDataList[0],s=e.imageDataList[1],c=a.createImageData(t.width,t.height),l=0;l<(o||s).length;l+=4){var u=n.slice();o&&(u[0]*=o[l]/255,u[1]*=o[l+1]/255,u[2]*=o[l+2]/255);var p=i;if(s){var d=s[l+3]/255;p=Math.min(Math.max(d+2*(p-.5),0),1)}for(var f=0;f<3;f++)c.data[l+f]=Math.round(255*u[f]);c.data[l+3]=Math.round(255*p)}a.putImageData(c,0,0),r(t)})})}function o(e,t){var n={},a=0;return e.images=[],e.textures=[],e.samplers=[{minFilter:h.a.LINEAR_MIPMAP_LINEAR,magFilter:h.a.LINEAR,wrapS:h.a.REPEAT,wrapT:h.a.REPEAT}],t.materials.forEach(function(t,i){m.forEach(function(i){t[i]&&!n.hasOwnProperty(i)&&(e.images.push({uri:t[i]}),e.textures.push({sampler:0,source:a}),n[t[i]]=a++)})}),n}function s(e,t){var n={baseColorFactor:d.a.parseColor(e.color),metallicFactor:e.metalness,roughnessFactor:e.roughness};return n.baseColorFactor[3]=e.alpha,e.diffuseMap&&(n.baseColorTexture={index:t[e.diffuseMap],texCoord:0}),e.metalnessMap&&(n.metallicRoughnessTexture={index:t[e.metalnessMap],texCoord:0},n.metallicFactor=1,n.roughnessFactor=1),n}function c(e,t){var n={diffuseFactor:d.a.parseColor(e.color),specularFactor:d.a.parseColor(e.specularColor).slice(0,3),glossinessFactor:e.glossiness};return n.diffuseFactor[3]=e.alpha,e.diffuseMap&&(n.diffuseTexture={index:t[e.diffuseMap],texCoord:0}),e.specularMap&&(n.specularGlossinessTexture={index:t[e.specularMap],texCoord:0},n.specularFactor=[1,1,1],n.glossinessFactor=1),n}function l(e,t){if(e.materials){var n=o(e,t),a={};return e.materials=[],e.nodes.forEach(function(t,n){if(null!=t.mesh){var i=e.meshes[t.mesh];1===i.primitives.length?a[t.name]=i.primitives[0]:i.primitives.forEach(function(n,i){a[f.a.generateMeshName(e.meshes,t.mesh,i)]=n})}}),t.materials.forEach(function(t,i){var r={name:t.name,emissiveFactor:d.a.parseColor(t.emission).slice(0,3).map(function(e){return e*t.emissionIntensity})};t.normalMap&&(r.normalTexture={texCoord:0,scale:1,index:n[t.normalMap]}),t.emissiveMap&&(r.emissiveTexture={texCoord:0,index:n[t.emissiveMap]}),"pbrMetallicRoughness"===t.type?r.pbrMetallicRoughness=s(t,n):r.extensions={KHR_materials_pbrSpecularGlossiness:c(t,n)},t.targetMeshes.forEach(function(e){a[e].material=i}),e.materials[i]=r}),e.extras=e.extras||{},e.extras.qtekModelViewerConfig=t,e}}function u(e,t,n){function a(e){return 4*Math.ceil(e/4)}var i=0,r=[],o=t.slice();e.buffers.forEach(function(e){r.push(i),i+=a(e.byteLength),delete e.uri}),e.bufferViews.forEach(function(e){null==e.byteOffset?e.byteOffset=0:e.byteOffset=e.byteOffset+r[e.buffer]}),(e.images||[]).forEach(function(t,s){var c=t.uri,l=n[c];if(delete t.uri,l){var u={buffer:0,byteOffset:i,byteLength:l.byteLength};r.push(i),i+=a(l.byteLength),t.bufferView=e.bufferViews.length,t.mimeType=p(c),e.bufferViews.push(u),o.push(l)}});var s=i;e.buffers=[{byteLength:s}];var c,l=new TextEncoder,u=l.encode(JSON.stringify(e)),d=a(u.length);d!==u.length&&(c=d-u.length);var f=20+d+8+s,h=new ArrayBuffer(f),m=new DataView(h),v=0;m.setUint32(v,1179937895,!0),v+=4,m.setUint32(v,2,!0),v+=4,m.setUint32(v,f,!0),v+=4,m.setUint32(v,d,!0),v+=4,m.setUint32(v,1313821514,!0),v+=4;for(var _=0;_0&&(i=1/Math.sqrt(i),e[0]=t[0]*i,e[1]=t[1]*i),e},o.dot=function(e,t){return e[0]*t[0]+e[1]*t[1]},o.cross=function(e,t,n){var a=t[0]*n[1]-t[1]*n[0];return e[0]=e[1]=0,e[2]=a,e},o.lerp=function(e,t,n,a){var i=t[0],r=t[1];return e[0]=i+a*(n[0]-i),e[1]=r+a*(n[1]-r),e},o.random=function(e,t){t=t||1;var n=2*a()*Math.PI;return e[0]=Math.cos(n)*t,e[1]=Math.sin(n)*t,e},o.transformMat2=function(e,t,n){var a=t[0],i=t[1];return e[0]=n[0]*a+n[2]*i,e[1]=n[1]*a+n[3]*i,e},o.transformMat2d=function(e,t,n){var a=t[0],i=t[1];return e[0]=n[0]*a+n[2]*i+n[4],e[1]=n[1]*a+n[3]*i+n[5],e},o.transformMat3=function(e,t,n){var a=t[0],i=t[1];return e[0]=n[0]*a+n[3]*i+n[6],e[1]=n[1]*a+n[4]*i+n[7],e},o.transformMat4=function(e,t,n){var a=t[0],i=t[1];return e[0]=n[0]*a+n[4]*i+n[12],e[1]=n[1]*a+n[5]*i+n[13],e},o.forEach=function(){var e=o.create();return function(t,n,a,i,r,o){var s,c;for(n||(n=2),a||(a=0),c=i?Math.min(i*n+a,t.length):t.length,s=a;s0&&(r=1/Math.sqrt(r),e[0]=t[0]*r,e[1]=t[1]*r,e[2]=t[2]*r),e},s.dot=function(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]},s.cross=function(e,t,n){var a=t[0],i=t[1],r=t[2],o=n[0],s=n[1],c=n[2];return e[0]=i*c-r*s,e[1]=r*o-a*c,e[2]=a*s-i*o,e},s.lerp=function(e,t,n,a){var i=t[0],r=t[1],o=t[2];return e[0]=i+a*(n[0]-i),e[1]=r+a*(n[1]-r),e[2]=o+a*(n[2]-o),e},s.random=function(e,t){t=t||1;var n=2*a()*Math.PI,i=2*a()-1,r=Math.sqrt(1-i*i)*t;return e[0]=Math.cos(n)*r,e[1]=Math.sin(n)*r,e[2]=i*t,e},s.transformMat4=function(e,t,n){var a=t[0],i=t[1],r=t[2],o=n[3]*a+n[7]*i+n[11]*r+n[15];return o=o||1,e[0]=(n[0]*a+n[4]*i+n[8]*r+n[12])/o,e[1]=(n[1]*a+n[5]*i+n[9]*r+n[13])/o,e[2]=(n[2]*a+n[6]*i+n[10]*r+n[14])/o,e},s.transformMat3=function(e,t,n){var a=t[0],i=t[1],r=t[2];return e[0]=a*n[0]+i*n[3]+r*n[6],e[1]=a*n[1]+i*n[4]+r*n[7],e[2]=a*n[2]+i*n[5]+r*n[8],e},s.transformQuat=function(e,t,n){var a=t[0],i=t[1],r=t[2],o=n[0],s=n[1],c=n[2],l=n[3],u=l*a+s*r-c*i,p=l*i+c*a-o*r,d=l*r+o*i-s*a,f=-o*a-s*i-c*r;return e[0]=u*l+f*-o+p*-c-d*-s,e[1]=p*l+f*-s+d*-o-u*-c,e[2]=d*l+f*-c+u*-s-p*-o,e},s.rotateX=function(e,t,n,a){var i=[],r=[];return i[0]=t[0]-n[0],i[1]=t[1]-n[1],i[2]=t[2]-n[2],r[0]=i[0],r[1]=i[1]*Math.cos(a)-i[2]*Math.sin(a),r[2]=i[1]*Math.sin(a)+i[2]*Math.cos(a),e[0]=r[0]+n[0],e[1]=r[1]+n[1],e[2]=r[2]+n[2],e},s.rotateY=function(e,t,n,a){var i=[],r=[];return i[0]=t[0]-n[0],i[1]=t[1]-n[1],i[2]=t[2]-n[2],r[0]=i[2]*Math.sin(a)+i[0]*Math.cos(a),r[1]=i[1],r[2]=i[2]*Math.cos(a)-i[0]*Math.sin(a),e[0]=r[0]+n[0],e[1]=r[1]+n[1],e[2]=r[2]+n[2],e},s.rotateZ=function(e,t,n,a){var i=[],r=[];return i[0]=t[0]-n[0],i[1]=t[1]-n[1],i[2]=t[2]-n[2],r[0]=i[0]*Math.cos(a)-i[1]*Math.sin(a),r[1]=i[0]*Math.sin(a)+i[1]*Math.cos(a),r[2]=i[2],e[0]=r[0]+n[0],e[1]=r[1]+n[1],e[2]=r[2]+n[2],e},s.forEach=function(){var e=s.create();return function(t,n,a,i,r,o){var s,c;for(n||(n=3),a||(a=0),c=i?Math.min(i*n+a,t.length):t.length,s=a;s1?0:Math.acos(i)},s.str=function(e){return"vec3("+e[0]+", "+e[1]+", "+e[2]+")"},void 0!==e&&(e.vec3=s);var c={};c.create=function(){var e=new n(4);return e[0]=0,e[1]=0,e[2]=0,e[3]=0,e},c.clone=function(e){var t=new n(4);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t[3]=e[3],t},c.fromValues=function(e,t,a,i){var r=new n(4);return r[0]=e,r[1]=t,r[2]=a,r[3]=i,r},c.copy=function(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e},c.set=function(e,t,n,a,i){return e[0]=t,e[1]=n,e[2]=a,e[3]=i,e},c.add=function(e,t,n){return e[0]=t[0]+n[0],e[1]=t[1]+n[1],e[2]=t[2]+n[2],e[3]=t[3]+n[3],e},c.subtract=function(e,t,n){return e[0]=t[0]-n[0],e[1]=t[1]-n[1],e[2]=t[2]-n[2],e[3]=t[3]-n[3],e},c.sub=c.subtract,c.multiply=function(e,t,n){return e[0]=t[0]*n[0],e[1]=t[1]*n[1],e[2]=t[2]*n[2],e[3]=t[3]*n[3],e},c.mul=c.multiply,c.divide=function(e,t,n){return e[0]=t[0]/n[0],e[1]=t[1]/n[1],e[2]=t[2]/n[2],e[3]=t[3]/n[3],e},c.div=c.divide,c.min=function(e,t,n){return e[0]=Math.min(t[0],n[0]),e[1]=Math.min(t[1],n[1]),e[2]=Math.min(t[2],n[2]),e[3]=Math.min(t[3],n[3]),e},c.max=function(e,t,n){return e[0]=Math.max(t[0],n[0]),e[1]=Math.max(t[1],n[1]),e[2]=Math.max(t[2],n[2]),e[3]=Math.max(t[3],n[3]),e},c.scale=function(e,t,n){return e[0]=t[0]*n,e[1]=t[1]*n,e[2]=t[2]*n,e[3]=t[3]*n,e},c.scaleAndAdd=function(e,t,n,a){return e[0]=t[0]+n[0]*a,e[1]=t[1]+n[1]*a,e[2]=t[2]+n[2]*a,e[3]=t[3]+n[3]*a,e},c.distance=function(e,t){var n=t[0]-e[0],a=t[1]-e[1],i=t[2]-e[2],r=t[3]-e[3];return Math.sqrt(n*n+a*a+i*i+r*r)},c.dist=c.distance,c.squaredDistance=function(e,t){var n=t[0]-e[0],a=t[1]-e[1],i=t[2]-e[2],r=t[3]-e[3];return n*n+a*a+i*i+r*r},c.sqrDist=c.squaredDistance,c.length=function(e){var t=e[0],n=e[1],a=e[2],i=e[3];return Math.sqrt(t*t+n*n+a*a+i*i)},c.len=c.length,c.squaredLength=function(e){var t=e[0],n=e[1],a=e[2],i=e[3];return t*t+n*n+a*a+i*i},c.sqrLen=c.squaredLength,c.negate=function(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e[3]=-t[3],e},c.inverse=function(e,t){return e[0]=1/t[0],e[1]=1/t[1],e[2]=1/t[2],e[3]=1/t[3],e},c.normalize=function(e,t){var n=t[0],a=t[1],i=t[2],r=t[3],o=n*n+a*a+i*i+r*r;return o>0&&(o=1/Math.sqrt(o),e[0]=t[0]*o,e[1]=t[1]*o,e[2]=t[2]*o,e[3]=t[3]*o),e},c.dot=function(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+e[3]*t[3]},c.lerp=function(e,t,n,a){var i=t[0],r=t[1],o=t[2],s=t[3];return e[0]=i+a*(n[0]-i),e[1]=r+a*(n[1]-r),e[2]=o+a*(n[2]-o),e[3]=s+a*(n[3]-s),e},c.random=function(e,t){return t=t||1,e[0]=a(),e[1]=a(),e[2]=a(),e[3]=a(),c.normalize(e,e),c.scale(e,e,t),e},c.transformMat4=function(e,t,n){var a=t[0],i=t[1],r=t[2],o=t[3];return e[0]=n[0]*a+n[4]*i+n[8]*r+n[12]*o,e[1]=n[1]*a+n[5]*i+n[9]*r+n[13]*o,e[2]=n[2]*a+n[6]*i+n[10]*r+n[14]*o,e[3]=n[3]*a+n[7]*i+n[11]*r+n[15]*o,e},c.transformQuat=function(e,t,n){var a=t[0],i=t[1],r=t[2],o=n[0],s=n[1],c=n[2],l=n[3],u=l*a+s*r-c*i,p=l*i+c*a-o*r,d=l*r+o*i-s*a,f=-o*a-s*i-c*r;return e[0]=u*l+f*-o+p*-c-d*-s,e[1]=p*l+f*-s+d*-o-u*-c,e[2]=d*l+f*-c+u*-s-p*-o,e},c.forEach=function(){var e=c.create();return function(t,n,a,i,r,o){var s,c;for(n||(n=4),a||(a=0),c=i?Math.min(i*n+a,t.length):t.length,s=a;s.999999?(a[0]=0,a[1]=0,a[2]=0,a[3]=1,a):(s.cross(e,i,r),a[0]=e[0],a[1]=e[1],a[2]=e[2],a[3]=1+o,f.normalize(a,a))}}(),f.setAxes=function(){var e=p.create();return function(t,n,a,i){return e[0]=a[0],e[3]=a[1],e[6]=a[2],e[1]=i[0],e[4]=i[1],e[7]=i[2],e[2]=-n[0],e[5]=-n[1],e[8]=-n[2],f.normalize(t,f.fromMat3(t,e))}}(),f.clone=c.clone,f.fromValues=c.fromValues,f.copy=c.copy,f.set=c.set,f.identity=function(e){return e[0]=0,e[1]=0,e[2]=0,e[3]=1,e},f.setAxisAngle=function(e,t,n){n*=.5;var a=Math.sin(n);return e[0]=a*t[0],e[1]=a*t[1],e[2]=a*t[2],e[3]=Math.cos(n),e},f.add=c.add,f.multiply=function(e,t,n){var a=t[0],i=t[1],r=t[2],o=t[3],s=n[0],c=n[1],l=n[2],u=n[3];return e[0]=a*u+o*s+i*l-r*c,e[1]=i*u+o*c+r*s-a*l,e[2]=r*u+o*l+a*c-i*s,e[3]=o*u-a*s-i*c-r*l,e},f.mul=f.multiply,f.scale=c.scale,f.rotateX=function(e,t,n){n*=.5;var a=t[0],i=t[1],r=t[2],o=t[3],s=Math.sin(n),c=Math.cos(n);return e[0]=a*c+o*s,e[1]=i*c+r*s,e[2]=r*c-i*s,e[3]=o*c-a*s,e},f.rotateY=function(e,t,n){n*=.5;var a=t[0],i=t[1],r=t[2],o=t[3],s=Math.sin(n),c=Math.cos(n);return e[0]=a*c-r*s,e[1]=i*c+o*s,e[2]=r*c+a*s,e[3]=o*c-i*s,e},f.rotateZ=function(e,t,n){n*=.5;var a=t[0],i=t[1],r=t[2],o=t[3],s=Math.sin(n),c=Math.cos(n);return e[0]=a*c+i*s,e[1]=i*c-a*s,e[2]=r*c+o*s,e[3]=o*c-r*s,e},f.calculateW=function(e,t){var n=t[0],a=t[1],i=t[2];return e[0]=n,e[1]=a,e[2]=i,e[3]=Math.sqrt(Math.abs(1-n*n-a*a-i*i)),e},f.dot=c.dot,f.lerp=c.lerp,f.slerp=function(e,t,n,a){var i,r,o,s,c,l=t[0],u=t[1],p=t[2],d=t[3],f=n[0],h=n[1],m=n[2],v=n[3];return r=l*f+u*h+p*m+d*v,r<0&&(r=-r,f=-f,h=-h,m=-m,v=-v),1-r>1e-6?(i=Math.acos(r),o=Math.sin(i),s=Math.sin((1-a)*i)/o,c=Math.sin(a*i)/o):(s=1-a,c=a),e[0]=s*l+c*f,e[1]=s*u+c*h,e[2]=s*p+c*m,e[3]=s*d+c*v,e},f.invert=function(e,t){var n=t[0],a=t[1],i=t[2],r=t[3],o=n*n+a*a+i*i+r*r,s=o?1/o:0;return e[0]=-n*s,e[1]=-a*s,e[2]=-i*s,e[3]=r*s,e},f.conjugate=function(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e[3]=t[3],e},f.length=c.length,f.len=f.length,f.squaredLength=c.squaredLength,f.sqrLen=f.squaredLength,f.normalize=c.normalize,f.fromMat3=function(e,t){var n,a=t[0]+t[4]+t[8];if(a>0)n=Math.sqrt(a+1),e[3]=.5*n,n=.5/n,e[0]=(t[5]-t[7])*n,e[1]=(t[6]-t[2])*n,e[2]=(t[1]-t[3])*n;else{var i=0;t[4]>t[0]&&(i=1),t[8]>t[3*i+i]&&(i=2);var r=(i+1)%3,o=(i+2)%3;n=Math.sqrt(t[3*i+i]-t[3*r+r]-t[3*o+o]+1),e[i]=.5*n,n=.5/n,e[3]=(t[3*r+o]-t[3*o+r])*n,e[r]=(t[3*r+i]+t[3*i+r])*n,e[o]=(t[3*o+i]+t[3*i+o])*n}return e},f.str=function(e){return"quat("+e[0]+", "+e[1]+", "+e[2]+", "+e[3]+")"},void 0!==e&&(e.quat=f)}(n.exports)}()},function(e,t,n){"use strict";var a=n(68),i=n(22),r=n(11),o=function(){this.__GUID__=r.a.genGUID()};o.__initializers__=[function(e){r.a.extend(this,e)}],r.a.extend(o,a.a),r.a.extend(o.prototype,i.a),t.a=o},function(e,t,n){"use strict";function a(e,t,n){return en?n:e}var i=n(0),r=n.n(i),o=r.a.vec3,s=function(e,t,n){e=e||0,t=t||0,n=n||0,this._array=o.fromValues(e,t,n),this._dirty=!0};s.prototype={constructor:s,add:function(e){return o.add(this._array,this._array,e._array),this._dirty=!0,this},set:function(e,t,n){return this._array[0]=e,this._array[1]=t,this._array[2]=n,this._dirty=!0,this},setArray:function(e){return this._array[0]=e[0],this._array[1]=e[1],this._array[2]=e[2],this._dirty=!0,this},clone:function(){return new s(this.x,this.y,this.z)},copy:function(e){return o.copy(this._array,e._array),this._dirty=!0,this},cross:function(e,t){return o.cross(this._array,e._array,t._array),this._dirty=!0,this},dist:function(e){return o.dist(this._array,e._array)},distance:function(e){return o.distance(this._array,e._array)},div:function(e){return o.div(this._array,this._array,e._array),this._dirty=!0,this},divide:function(e){return o.divide(this._array,this._array,e._array),this._dirty=!0,this},dot:function(e){return o.dot(this._array,e._array)},len:function(){return o.len(this._array)},length:function(){return o.length(this._array)},lerp:function(e,t,n){return o.lerp(this._array,e._array,t._array,n),this._dirty=!0,this},min:function(e){return o.min(this._array,this._array,e._array),this._dirty=!0,this},max:function(e){return o.max(this._array,this._array,e._array),this._dirty=!0,this},mul:function(e){return o.mul(this._array,this._array,e._array),this._dirty=!0,this},multiply:function(e){return o.multiply(this._array,this._array,e._array),this._dirty=!0,this},negate:function(){return o.negate(this._array,this._array),this._dirty=!0,this},normalize:function(){return o.normalize(this._array,this._array),this._dirty=!0,this},random:function(e){return o.random(this._array,e),this._dirty=!0,this},scale:function(e){return o.scale(this._array,this._array,e),this._dirty=!0,this},scaleAndAdd:function(e,t){return o.scaleAndAdd(this._array,this._array,e._array,t),this._dirty=!0,this},sqrDist:function(e){return o.sqrDist(this._array,e._array)},squaredDistance:function(e){return o.squaredDistance(this._array,e._array)},sqrLen:function(){return o.sqrLen(this._array)},squaredLength:function(){return o.squaredLength(this._array)},sub:function(e){return o.sub(this._array,this._array,e._array),this._dirty=!0,this},subtract:function(e){return o.subtract(this._array,this._array,e._array),this._dirty=!0,this},transformMat3:function(e){return o.transformMat3(this._array,this._array,e._array),this._dirty=!0,this},transformMat4:function(e){return o.transformMat4(this._array,this._array,e._array),this._dirty=!0,this},transformQuat:function(e){return o.transformQuat(this._array,this._array,e._array),this._dirty=!0,this},applyProjection:function(e){var t=this._array;if(e=e._array,0===e[15]){var n=-1/t[2];t[0]=e[0]*t[0]*n,t[1]=e[5]*t[1]*n,t[2]=(e[10]*t[2]+e[14])*n}else t[0]=e[0]*t[0]+e[12],t[1]=e[5]*t[1]+e[13],t[2]=e[10]*t[2]+e[14];return this._dirty=!0,this},eulerFromQuat:function(e,t){s.eulerFromQuat(this,e,t)},eulerFromMat3:function(e,t){s.eulerFromMat3(this,e,t)},toString:function(){return"["+Array.prototype.join.call(this._array,",")+"]"},toArray:function(){return Array.prototype.slice.call(this._array)}};var c=Object.defineProperty;if(c){var l=s.prototype;c(l,"x",{get:function(){return this._array[0]},set:function(e){this._array[0]=e,this._dirty=!0}}),c(l,"y",{get:function(){return this._array[1]},set:function(e){this._array[1]=e,this._dirty=!0}}),c(l,"z",{get:function(){return this._array[2]},set:function(e){this._array[2]=e,this._dirty=!0}})}s.add=function(e,t,n){return o.add(e._array,t._array,n._array),e._dirty=!0,e},s.set=function(e,t,n,a){o.set(e._array,t,n,a),e._dirty=!0},s.copy=function(e,t){return o.copy(e._array,t._array),e._dirty=!0,e},s.cross=function(e,t,n){return o.cross(e._array,t._array,n._array),e._dirty=!0,e},s.dist=function(e,t){return o.distance(e._array,t._array)},s.distance=s.dist,s.div=function(e,t,n){return o.divide(e._array,t._array,n._array),e._dirty=!0,e},s.divide=s.div,s.dot=function(e,t){return o.dot(e._array,t._array)},s.len=function(e){return o.length(e._array)},s.lerp=function(e,t,n,a){return o.lerp(e._array,t._array,n._array,a),e._dirty=!0,e},s.min=function(e,t,n){return o.min(e._array,t._array,n._array),e._dirty=!0,e},s.max=function(e,t,n){return o.max(e._array,t._array,n._array),e._dirty=!0,e},s.mul=function(e,t,n){return o.multiply(e._array,t._array,n._array),e._dirty=!0,e},s.multiply=s.mul,s.negate=function(e,t){return o.negate(e._array,t._array),e._dirty=!0,e},s.normalize=function(e,t){return o.normalize(e._array,t._array),e._dirty=!0,e},s.random=function(e,t){return o.random(e._array,t),e._dirty=!0,e},s.scale=function(e,t,n){return o.scale(e._array,t._array,n),e._dirty=!0,e},s.scaleAndAdd=function(e,t,n,a){return o.scaleAndAdd(e._array,t._array,n._array,a),e._dirty=!0,e},s.sqrDist=function(e,t){return o.sqrDist(e._array,t._array)},s.squaredDistance=s.sqrDist,s.sqrLen=function(e){return o.sqrLen(e._array)},s.squaredLength=s.sqrLen,s.sub=function(e,t,n){return o.subtract(e._array,t._array,n._array),e._dirty=!0,e},s.subtract=s.sub,s.transformMat3=function(e,t,n){return o.transformMat3(e._array,t._array,n._array),e._dirty=!0,e},s.transformMat4=function(e,t,n){return o.transformMat4(e._array,t._array,n._array),e._dirty=!0,e},s.transformQuat=function(e,t,n){return o.transformQuat(e._array,t._array,n._array),e._dirty=!0,e};var u=Math.atan2,p=Math.asin,d=Math.abs;s.eulerFromQuat=function(e,t,n){e._dirty=!0,t=t._array;var i=e._array,r=t[0],o=t[1],s=t[2],c=t[3],l=r*r,d=o*o,f=s*s,h=c*c,n=(n||"XYZ").toUpperCase();switch(n){case"XYZ":i[0]=u(2*(r*c-o*s),h-l-d+f),i[1]=p(a(2*(r*s+o*c),-1,1)),i[2]=u(2*(s*c-r*o),h+l-d-f);break;case"YXZ":i[0]=p(a(2*(r*c-o*s),-1,1)),i[1]=u(2*(r*s+o*c),h-l-d+f),i[2]=u(2*(r*o+s*c),h-l+d-f);break;case"ZXY":i[0]=p(a(2*(r*c+o*s),-1,1)),i[1]=u(2*(o*c-s*r),h-l-d+f),i[2]=u(2*(s*c-r*o),h-l+d-f);break;case"ZYX":i[0]=u(2*(r*c+s*o),h-l-d+f),i[1]=p(a(2*(o*c-r*s),-1,1)),i[2]=u(2*(r*o+s*c),h+l-d-f);break;case"YZX":i[0]=u(2*(r*c-s*o),h-l+d-f),i[1]=u(2*(o*c-r*s),h+l-d-f),i[2]=p(a(2*(r*o+s*c),-1,1));break;case"XZY":i[0]=u(2*(r*c+o*s),h-l+d-f),i[1]=u(2*(r*s+o*c),h+l-d-f),i[2]=p(a(2*(s*c-r*o),-1,1));break;default:console.warn("Unkown order: "+n)}return e},s.eulerFromMat3=function(e,t,n){var i=t._array,r=i[0],o=i[3],s=i[6],c=i[1],l=i[4],f=i[7],h=i[2],m=i[5],v=i[8],_=e._array,n=(n||"XYZ").toUpperCase();switch(n){case"XYZ":_[1]=p(a(s,-1,1)),d(s)<.99999?(_[0]=u(-f,v),_[2]=u(-o,r)):(_[0]=u(m,l),_[2]=0);break;case"YXZ":_[0]=p(-a(f,-1,1)),d(f)<.99999?(_[1]=u(s,v),_[2]=u(c,l)):(_[1]=u(-h,r),_[2]=0);break;case"ZXY":_[0]=p(a(m,-1,1)),d(m)<.99999?(_[1]=u(-h,v),_[2]=u(-o,l)):(_[1]=0,_[2]=u(c,r));break;case"ZYX":_[1]=p(-a(h,-1,1)),d(h)<.99999?(_[0]=u(m,v),_[2]=u(c,r)):(_[0]=0,_[2]=u(-o,l));break;case"YZX":_[2]=p(a(c,-1,1)),d(c)<.99999?(_[0]=u(-f,l),_[1]=u(-h,r)):(_[0]=0,_[1]=u(s,v));break;case"XZY":_[2]=p(-a(o,-1,1)),d(o)<.99999?(_[0]=u(m,l),_[1]=u(s,r)):(_[0]=u(-f,v),_[1]=0);break;default:console.warn("Unkown order: "+n)}return e._dirty=!0,e},s.POSITIVE_X=new s(1,0,0),s.NEGATIVE_X=new s(-1,0,0),s.POSITIVE_Y=new s(0,1,0),s.NEGATIVE_Y=new s(0,-1,0),s.POSITIVE_Z=new s(0,0,1),s.NEGATIVE_Z=new s(0,0,-1),s.UP=new s(0,1,0),s.ZERO=new s(0,0,0),t.a=s},function(e,t,n){"use strict";var a=n(1),i=n(6),r=n(23),o=a.a.extend({width:512,height:512,type:i.a.UNSIGNED_BYTE,format:i.a.RGBA,wrapS:i.a.REPEAT,wrapT:i.a.REPEAT,minFilter:i.a.LINEAR_MIPMAP_LINEAR,magFilter:i.a.LINEAR,useMipmap:!0,anisotropic:1,flipY:!0,unpackAlignment:4,premultiplyAlpha:!1,dynamic:!1,NPOT:!1},function(){this._cache=new r.a},{getWebGLTexture:function(e){var t=e.gl,n=this._cache;return n.use(e.__GUID__),n.miss("webgl_texture")&&n.put("webgl_texture",t.createTexture()),this.dynamic?this.update(e):n.isDirty()&&(this.update(e),n.fresh()),n.get("webgl_texture")},bind:function(){},unbind:function(){},dirty:function(){this._cache&&this._cache.dirtyAll()},update:function(e){},updateCommon:function(e){var t=e.gl;t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,this.flipY),t.pixelStorei(t.UNPACK_PREMULTIPLY_ALPHA_WEBGL,this.premultiplyAlpha),t.pixelStorei(t.UNPACK_ALIGNMENT,this.unpackAlignment),this.format===i.a.DEPTH_COMPONENT&&(this.useMipmap=!1);var n=e.getGLExtension("EXT_sRGB");this.format!==o.SRGB||n||(this.format=o.RGB),this.format!==o.SRGB_ALPHA||n||(this.format=o.RGBA),this.NPOT=!this.isPowerOfTwo()},getAvailableWrapS:function(){return this.NPOT?i.a.CLAMP_TO_EDGE:this.wrapS},getAvailableWrapT:function(){return this.NPOT?i.a.CLAMP_TO_EDGE:this.wrapT},getAvailableMinFilter:function(){var e=this.minFilter;return this.NPOT||!this.useMipmap?e==i.a.NEAREST_MIPMAP_NEAREST||e==i.a.NEAREST_MIPMAP_LINEAR?i.a.NEAREST:e==i.a.LINEAR_MIPMAP_LINEAR||e==i.a.LINEAR_MIPMAP_NEAREST?i.a.LINEAR:e:e},getAvailableMagFilter:function(){return this.magFilter},nextHighestPowerOfTwo:function(e){--e;for(var t=1;t<32;t<<=1)e|=e>>t;return e+1},dispose:function(e){var t=this._cache;t.use(e.__GUID__);var n=t.get("webgl_texture");n&&e.gl.deleteTexture(n),t.deleteContext(e.__GUID__)},isRenderable:function(){},isPowerOfTwo:function(){}});Object.defineProperty(o.prototype,"width",{get:function(){return this._width},set:function(e){this._width=e}}),Object.defineProperty(o.prototype,"height",{get:function(){return this._height},set:function(e){this._height=e}}),o.BYTE=i.a.BYTE,o.UNSIGNED_BYTE=i.a.UNSIGNED_BYTE,o.SHORT=i.a.SHORT,o.UNSIGNED_SHORT=i.a.UNSIGNED_SHORT,o.INT=i.a.INT,o.UNSIGNED_INT=i.a.UNSIGNED_INT,o.FLOAT=i.a.FLOAT,o.HALF_FLOAT=36193,o.UNSIGNED_INT_24_8_WEBGL=34042,o.DEPTH_COMPONENT=i.a.DEPTH_COMPONENT,o.DEPTH_STENCIL=i.a.DEPTH_STENCIL,o.ALPHA=i.a.ALPHA,o.RGB=i.a.RGB,o.RGBA=i.a.RGBA,o.LUMINANCE=i.a.LUMINANCE,o.LUMINANCE_ALPHA=i.a.LUMINANCE_ALPHA,o.SRGB=35904,o.SRGB_ALPHA=35906,o.COMPRESSED_RGB_S3TC_DXT1_EXT=33776,o.COMPRESSED_RGBA_S3TC_DXT1_EXT=33777,o.COMPRESSED_RGBA_S3TC_DXT3_EXT=33778,o.COMPRESSED_RGBA_S3TC_DXT5_EXT=33779,o.NEAREST=i.a.NEAREST,o.LINEAR=i.a.LINEAR,o.NEAREST_MIPMAP_NEAREST=i.a.NEAREST_MIPMAP_NEAREST,o.LINEAR_MIPMAP_NEAREST=i.a.LINEAR_MIPMAP_NEAREST,o.NEAREST_MIPMAP_LINEAR=i.a.NEAREST_MIPMAP_LINEAR,o.LINEAR_MIPMAP_LINEAR=i.a.LINEAR_MIPMAP_LINEAR,o.REPEAT=i.a.REPEAT,o.CLAMP_TO_EDGE=i.a.CLAMP_TO_EDGE,o.MIRRORED_REPEAT=i.a.MIRRORED_REPEAT,t.a=o},function(e,t,n){"use strict";function a(){return{locations:{},attriblocations:{}}}function i(e,t,n){if(!e.getShaderParameter(t,e.COMPILE_STATUS))return[e.getShaderInfoLog(t),r(n)].join("\n")}function r(e){for(var t=e.split("\n"),n=0,a=t.length;n0&&a.push("#define "+i.toUpperCase()+"_COUNT "+r)}for(var o in n){n[o].enabled&&a.push("#define "+o.toUpperCase()+"_ENABLED")}for(var o in e){var s=e[o];null===s?a.push("#define "+o):a.push("#define "+o+" "+s.toString())}return a.join("\n")},_unrollLoop:function(e,t){function n(e,n,i,r){var o="";isNaN(n)&&(n=n in t?t[n]:a[n]),isNaN(i)&&(i=i in t?t[i]:a[i]);for(var s=parseInt(n);s=0)n.attribSemantics[c]={symbol:r,type:u},p=!1;else if(E.indexOf(c)>=0){var d=!1,f=c;c.match(/TRANSPOSE$/)&&(d=!0,f=c.slice(0,-9)),n.matrixSemantics[c]={symbol:r,type:u,isTranspose:d,semanticNoTranspose:f},p=!1}else if(T.indexOf(c)>=0)n.uniformSemantics[c]={symbol:r,type:u},p=!1;else if("unconfigurable"===c)p=!1;else{if(!(l=n._parseDefaultValue(i,c)))throw new Error('Unkown semantic "'+c+'"');c=""}p&&(t[r]={type:u,value:o?y.array:l||y[i],semantic:c||null})}return["uniform",i,r,o].join(" ")+";\n"}}var t={},n=this,a="vertex";this._uniformList=[],this._vertexProcessedWithoutDefine=this._vertexProcessedWithoutDefine.replace(m,e),a="fragment",this._fragmentProcessedWithoutDefine=this._fragmentProcessedWithoutDefine.replace(m,e),n.matrixSemanticKeys=Object.keys(this.matrixSemantics),this.uniformTemplates=t},_parseDefaultValue:function(e,t){var n=/\[\s*(.*)\s*\]/;{if("vec2"!==e&&"vec3"!==e&&"vec4"!==e)return"bool"===e?function(){return"true"===t.toLowerCase()}:"float"===e?function(){return parseFloat(t)}:"int"===e?function(){return parseInt(t)}:void 0;var a=n.exec(t)[1];if(a){var i=a.split(/\s*,\s*/);return function(){return new l.a.Float32Array(i)}}}},createUniforms:function(){var e={};for(var t in this.uniformTemplates){var n=this.uniformTemplates[t];e[t]={type:n.type,value:n.value()}}return e},attached:function(){this._attacheMaterialNumber++},detached:function(){this._attacheMaterialNumber--},isAttachedToAny:function(){return 0!==this._attacheMaterialNumber},_parseAttributes:function(){function e(e,a,i,r,o){if(a&&i){var s=1;switch(a){case"vec4":s=4;break;case"vec3":s=3;break;case"vec2":s=2;break;case"float":s=1}if(t[i]={type:"float",size:s,semantic:o||null},o){if(b.indexOf(o)<0)throw new Error('Unkown semantic "'+o+'"');n.attribSemantics[o]={symbol:i,type:a}}}return["attribute",a,i].join(" ")+";\n"}var t={},n=this;this._vertexProcessedWithoutDefine=this._vertexProcessedWithoutDefine.replace(v,e),this.attributeTemplates=t},_parseDefines:function(){function e(e,a,i){var r="vertex"===n?t.vertexDefines:t.fragmentDefines;return r[a]||(r[a]="false"!=i&&("true"==i||(i?isNaN(parseFloat(i))?i:parseFloat(i):null))),""}var t=this,n="vertex";this._vertexProcessedWithoutDefine=this._vertexProcessedWithoutDefine.replace(_,e),n="fragment",this._fragmentProcessedWithoutDefine=this._fragmentProcessedWithoutDefine.replace(_,e)},_buildProgram:function(e,t,n){var a=this._cache;a.get("program")&&e.deleteProgram(a.get("program"));var r=e.createProgram(),o=e.createShader(e.VERTEX_SHADER);e.shaderSource(o,t),e.compileShader(o);var s=e.createShader(e.FRAGMENT_SHADER);e.shaderSource(s,n),e.compileShader(s);var c=i(e,o,t);if(c)return c;if(c=i(e,s,n))return c;if(e.attachShader(r,o),e.attachShader(r,s),this.attribSemantics.POSITION)e.bindAttribLocation(r,0,this.attribSemantics.POSITION.symbol);else{var l=Object.keys(this.attributeTemplates);e.bindAttribLocation(r,0,l[0])}if(e.linkProgram(r),!e.getProgramParameter(r,e.LINK_STATUS))return"Could not link program\nVALIDATE_STATUS: "+e.getProgramParameter(r,e.VALIDATE_STATUS)+", gl error ["+e.getError()+"]";for(var u=0;u1&&t.texParameterf(t.TEXTURE_2D,r.TEXTURE_MAX_ANISOTROPY_EXT,this.anisotropic),36193===a){e.getGLExtension("OES_texture_half_float")||(a=i.a.FLOAT)}if(this.mipmaps.length)for(var o=this.width,s=this.height,c=0;c=a.a.COMPRESSED_RGB_S3TC_DXT1_EXT?e.compressedTexImage2D(e.TEXTURE_2D,n,o,i,r,0,t.pixels):e.texImage2D(e.TEXTURE_2D,n,o,i,r,0,o,s,t.pixels)},generateMipmap:function(e){var t=e.gl;this.useMipmap&&!this.NPOT&&(t.bindTexture(t.TEXTURE_2D,this._cache.get("webgl_texture")),t.generateMipmap(t.TEXTURE_2D))},isPowerOfTwo:function(){var e,t;return this.image?(e=this.image.width,t=this.image.height):(e=this.width,t=this.height),o(e)&&o(t)},isRenderable:function(){return this.image?"CANVAS"===this.image.nodeName||"VIDEO"===this.image.nodeName||this.image.complete:!(!this.width||!this.height)},bind:function(e){e.gl.bindTexture(e.gl.TEXTURE_2D,this.getWebGLTexture(e))},unbind:function(e){e.gl.bindTexture(e.gl.TEXTURE_2D,null)},load:function(e,t){var n=new Image;t&&(n.crossOrigin=t);var a=this;return n.onload=function(){a.dirty(),a.trigger("success",a),n.onload=null},n.onerror=function(){a.trigger("error",a),n.onerror=null},n.src=e,this.image=n,this}});Object.defineProperty(s.prototype,"width",{get:function(){return this.image?this.image.width:this._width},set:function(e){this.image?console.warn("Texture from image can't set width"):(this._width!==e&&this.dirty(),this._width=e)}}),Object.defineProperty(s.prototype,"height",{get:function(){return this.image?this.image.height:this._height},set:function(e){this.image?console.warn("Texture from image can't set height"):(this._height!==e&&this.dirty(),this._height=e)}}),t.a=s},function(e,t,n){"use strict";t.a={DEPTH_BUFFER_BIT:256,STENCIL_BUFFER_BIT:1024,COLOR_BUFFER_BIT:16384,POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,ZERO:0,ONE:1,SRC_COLOR:768,ONE_MINUS_SRC_COLOR:769,SRC_ALPHA:770,ONE_MINUS_SRC_ALPHA:771,DST_ALPHA:772,ONE_MINUS_DST_ALPHA:773,DST_COLOR:774,ONE_MINUS_DST_COLOR:775,SRC_ALPHA_SATURATE:776,FUNC_ADD:32774,BLEND_EQUATION:32777,BLEND_EQUATION_RGB:32777,BLEND_EQUATION_ALPHA:34877,FUNC_SUBTRACT:32778,FUNC_REVERSE_SUBTRACT:32779,BLEND_DST_RGB:32968,BLEND_SRC_RGB:32969,BLEND_DST_ALPHA:32970,BLEND_SRC_ALPHA:32971,CONSTANT_COLOR:32769,ONE_MINUS_CONSTANT_COLOR:32770,CONSTANT_ALPHA:32771,ONE_MINUS_CONSTANT_ALPHA:32772,BLEND_COLOR:32773,ARRAY_BUFFER:34962,ELEMENT_ARRAY_BUFFER:34963,ARRAY_BUFFER_BINDING:34964,ELEMENT_ARRAY_BUFFER_BINDING:34965,STREAM_DRAW:35040,STATIC_DRAW:35044,DYNAMIC_DRAW:35048,BUFFER_SIZE:34660,BUFFER_USAGE:34661,CURRENT_VERTEX_ATTRIB:34342,FRONT:1028,BACK:1029,FRONT_AND_BACK:1032,CULL_FACE:2884,BLEND:3042,DITHER:3024,STENCIL_TEST:2960,DEPTH_TEST:2929,SCISSOR_TEST:3089,POLYGON_OFFSET_FILL:32823,SAMPLE_ALPHA_TO_COVERAGE:32926,SAMPLE_COVERAGE:32928,NO_ERROR:0,INVALID_ENUM:1280,INVALID_VALUE:1281,INVALID_OPERATION:1282,OUT_OF_MEMORY:1285,CW:2304,CCW:2305,LINE_WIDTH:2849,ALIASED_POINT_SIZE_RANGE:33901,ALIASED_LINE_WIDTH_RANGE:33902,CULL_FACE_MODE:2885,FRONT_FACE:2886,DEPTH_RANGE:2928,DEPTH_WRITEMASK:2930,DEPTH_CLEAR_VALUE:2931,DEPTH_FUNC:2932,STENCIL_CLEAR_VALUE:2961,STENCIL_FUNC:2962,STENCIL_FAIL:2964,STENCIL_PASS_DEPTH_FAIL:2965,STENCIL_PASS_DEPTH_PASS:2966,STENCIL_REF:2967,STENCIL_VALUE_MASK:2963,STENCIL_WRITEMASK:2968,STENCIL_BACK_FUNC:34816,STENCIL_BACK_FAIL:34817,STENCIL_BACK_PASS_DEPTH_FAIL:34818,STENCIL_BACK_PASS_DEPTH_PASS:34819,STENCIL_BACK_REF:36003,STENCIL_BACK_VALUE_MASK:36004,STENCIL_BACK_WRITEMASK:36005,VIEWPORT:2978,SCISSOR_BOX:3088,COLOR_CLEAR_VALUE:3106,COLOR_WRITEMASK:3107,UNPACK_ALIGNMENT:3317,PACK_ALIGNMENT:3333,MAX_TEXTURE_SIZE:3379,MAX_VIEWPORT_DIMS:3386,SUBPIXEL_BITS:3408,RED_BITS:3410,GREEN_BITS:3411,BLUE_BITS:3412,ALPHA_BITS:3413,DEPTH_BITS:3414,STENCIL_BITS:3415,POLYGON_OFFSET_UNITS:10752,POLYGON_OFFSET_FACTOR:32824,TEXTURE_BINDING_2D:32873,SAMPLE_BUFFERS:32936,SAMPLES:32937,SAMPLE_COVERAGE_VALUE:32938,SAMPLE_COVERAGE_INVERT:32939,COMPRESSED_TEXTURE_FORMATS:34467,DONT_CARE:4352,FASTEST:4353,NICEST:4354,GENERATE_MIPMAP_HINT:33170,BYTE:5120,UNSIGNED_BYTE:5121,SHORT:5122,UNSIGNED_SHORT:5123,INT:5124,UNSIGNED_INT:5125,FLOAT:5126,DEPTH_COMPONENT:6402,ALPHA:6406,RGB:6407,RGBA:6408,LUMINANCE:6409,LUMINANCE_ALPHA:6410,UNSIGNED_SHORT_4_4_4_4:32819,UNSIGNED_SHORT_5_5_5_1:32820,UNSIGNED_SHORT_5_6_5:33635,FRAGMENT_SHADER:35632,VERTEX_SHADER:35633,MAX_VERTEX_ATTRIBS:34921,MAX_VERTEX_UNIFORM_VECTORS:36347,MAX_VARYING_VECTORS:36348,MAX_COMBINED_TEXTURE_IMAGE_UNITS:35661,MAX_VERTEX_TEXTURE_IMAGE_UNITS:35660,MAX_TEXTURE_IMAGE_UNITS:34930,MAX_FRAGMENT_UNIFORM_VECTORS:36349,SHADER_TYPE:35663,DELETE_STATUS:35712,LINK_STATUS:35714,VALIDATE_STATUS:35715,ATTACHED_SHADERS:35717,ACTIVE_UNIFORMS:35718,ACTIVE_ATTRIBUTES:35721,SHADING_LANGUAGE_VERSION:35724,CURRENT_PROGRAM:35725,NEVER:512,LESS:513,EQUAL:514,LEQUAL:515,GREATER:516,NOTEQUAL:517,GEQUAL:518,ALWAYS:519,KEEP:7680,REPLACE:7681,INCR:7682,DECR:7683,INVERT:5386,INCR_WRAP:34055,DECR_WRAP:34056,VENDOR:7936,RENDERER:7937,VERSION:7938,NEAREST:9728,LINEAR:9729,NEAREST_MIPMAP_NEAREST:9984,LINEAR_MIPMAP_NEAREST:9985,NEAREST_MIPMAP_LINEAR:9986,LINEAR_MIPMAP_LINEAR:9987,TEXTURE_MAG_FILTER:10240,TEXTURE_MIN_FILTER:10241,TEXTURE_WRAP_S:10242,TEXTURE_WRAP_T:10243,TEXTURE_2D:3553,TEXTURE:5890,TEXTURE_CUBE_MAP:34067,TEXTURE_BINDING_CUBE_MAP:34068,TEXTURE_CUBE_MAP_POSITIVE_X:34069,TEXTURE_CUBE_MAP_NEGATIVE_X:34070,TEXTURE_CUBE_MAP_POSITIVE_Y:34071,TEXTURE_CUBE_MAP_NEGATIVE_Y:34072,TEXTURE_CUBE_MAP_POSITIVE_Z:34073,TEXTURE_CUBE_MAP_NEGATIVE_Z:34074,MAX_CUBE_MAP_TEXTURE_SIZE:34076,TEXTURE0:33984,TEXTURE1:33985,TEXTURE2:33986,TEXTURE3:33987,TEXTURE4:33988,TEXTURE5:33989,TEXTURE6:33990,TEXTURE7:33991,TEXTURE8:33992,TEXTURE9:33993,TEXTURE10:33994,TEXTURE11:33995,TEXTURE12:33996,TEXTURE13:33997,TEXTURE14:33998,TEXTURE15:33999,TEXTURE16:34e3,TEXTURE17:34001,TEXTURE18:34002,TEXTURE19:34003,TEXTURE20:34004,TEXTURE21:34005,TEXTURE22:34006,TEXTURE23:34007,TEXTURE24:34008,TEXTURE25:34009,TEXTURE26:34010,TEXTURE27:34011,TEXTURE28:34012,TEXTURE29:34013,TEXTURE30:34014,TEXTURE31:34015,ACTIVE_TEXTURE:34016,REPEAT:10497,CLAMP_TO_EDGE:33071,MIRRORED_REPEAT:33648,FLOAT_VEC2:35664,FLOAT_VEC3:35665,FLOAT_VEC4:35666,INT_VEC2:35667,INT_VEC3:35668,INT_VEC4:35669,BOOL:35670,BOOL_VEC2:35671,BOOL_VEC3:35672,BOOL_VEC4:35673,FLOAT_MAT2:35674,FLOAT_MAT3:35675,FLOAT_MAT4:35676,SAMPLER_2D:35678,SAMPLER_CUBE:35680,VERTEX_ATTRIB_ARRAY_ENABLED:34338,VERTEX_ATTRIB_ARRAY_SIZE:34339,VERTEX_ATTRIB_ARRAY_STRIDE:34340,VERTEX_ATTRIB_ARRAY_TYPE:34341,VERTEX_ATTRIB_ARRAY_NORMALIZED:34922,VERTEX_ATTRIB_ARRAY_POINTER:34373,VERTEX_ATTRIB_ARRAY_BUFFER_BINDING:34975,COMPILE_STATUS:35713,LOW_FLOAT:36336,MEDIUM_FLOAT:36337,HIGH_FLOAT:36338,LOW_INT:36339,MEDIUM_INT:36340,HIGH_INT:36341,FRAMEBUFFER:36160,RENDERBUFFER:36161,RGBA4:32854,RGB5_A1:32855,RGB565:36194,DEPTH_COMPONENT16:33189,STENCIL_INDEX:6401,STENCIL_INDEX8:36168,DEPTH_STENCIL:34041,RENDERBUFFER_WIDTH:36162,RENDERBUFFER_HEIGHT:36163,RENDERBUFFER_INTERNAL_FORMAT:36164,RENDERBUFFER_RED_SIZE:36176,RENDERBUFFER_GREEN_SIZE:36177,RENDERBUFFER_BLUE_SIZE:36178,RENDERBUFFER_ALPHA_SIZE:36179,RENDERBUFFER_DEPTH_SIZE:36180,RENDERBUFFER_STENCIL_SIZE:36181,FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE:36048,FRAMEBUFFER_ATTACHMENT_OBJECT_NAME:36049,FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL:36050,FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE:36051,COLOR_ATTACHMENT0:36064,DEPTH_ATTACHMENT:36096,STENCIL_ATTACHMENT:36128,DEPTH_STENCIL_ATTACHMENT:33306,NONE:0,FRAMEBUFFER_COMPLETE:36053,FRAMEBUFFER_INCOMPLETE_ATTACHMENT:36054,FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT:36055,FRAMEBUFFER_INCOMPLETE_DIMENSIONS:36057,FRAMEBUFFER_UNSUPPORTED:36061,FRAMEBUFFER_BINDING:36006,RENDERBUFFER_BINDING:36007,MAX_RENDERBUFFER_SIZE:34024,INVALID_FRAMEBUFFER_OPERATION:1286,UNPACK_FLIP_Y_WEBGL:37440,UNPACK_PREMULTIPLY_ALPHA_WEBGL:37441,CONTEXT_LOST_WEBGL:37442,UNPACK_COLORSPACE_CONVERSION_WEBGL:37443,BROWSER_DEFAULT_WEBGL:37444}},function(e,t,n){"use strict";var a=n(2),i=n(0),r=n.n(i),o=r.a.vec3,s=o.copy,c=o.set,l=function(e,t){this.min=e||new a.a(1/0,1/0,1/0),this.max=t||new a.a(-1/0,-1/0,-1/0)};l.prototype={constructor:l,updateFromVertices:function(e){if(e.length>0){var t=this.min,n=this.max,a=t._array,i=n._array;s(a,e[0]),s(i,e[0]);for(var r=1;ri[0]&&(i[0]=o[0]),o[1]>i[1]&&(i[1]=o[1]),o[2]>i[2]&&(i[2]=o[2])}t._dirty=!0,n._dirty=!0}},union:function(e){var t=this.min,n=this.max;return o.min(t._array,t._array,e.min._array),o.max(n._array,n._array,e.max._array),t._dirty=!0,n._dirty=!0,this},intersection:function(e){var t=this.min,n=this.max;return o.max(t._array,t._array,e.min._array),o.min(n._array,n._array,e.max._array),t._dirty=!0,n._dirty=!0,this},intersectBoundingBox:function(e){var t=this.min._array,n=this.max._array,a=e.min._array,i=e.max._array;return!(t[0]>i[0]||t[1]>i[1]||t[2]>i[2]||n[0]=i[0]&&n[1]>=i[1]&&n[2]>=i[2]},containPoint:function(e){var t=this.min._array,n=this.max._array,a=e._array;return t[0]<=a[0]&&t[1]<=a[1]&&t[2]<=a[2]&&n[0]>=a[0]&&n[1]>=a[1]&&n[2]>=a[2]},isFinite:function(){var e=this.min._array,t=this.max._array;return isFinite(e[0])&&isFinite(e[1])&&isFinite(e[2])&&isFinite(t[0])&&isFinite(t[1])&&isFinite(t[2])},applyTransform:function(){var e=o.create(),t=o.create(),n=o.create(),a=o.create(),i=o.create(),r=o.create();return function(o){var s=this.min._array,c=this.max._array,l=o._array;return e[0]=l[0]*s[0],e[1]=l[1]*s[0],e[2]=l[2]*s[0],t[0]=l[0]*c[0],t[1]=l[1]*c[0],t[2]=l[2]*c[0],n[0]=l[4]*s[1],n[1]=l[5]*s[1],n[2]=l[6]*s[1],a[0]=l[4]*c[1],a[1]=l[5]*c[1],a[2]=l[6]*c[1],i[0]=l[8]*s[2],i[1]=l[9]*s[2],i[2]=l[10]*s[2],r[0]=l[8]*c[2],r[1]=l[9]*c[2],r[2]=l[10]*c[2],s[0]=Math.min(e[0],t[0])+Math.min(n[0],a[0])+Math.min(i[0],r[0])+l[12],s[1]=Math.min(e[1],t[1])+Math.min(n[1],a[1])+Math.min(i[1],r[1])+l[13],s[2]=Math.min(e[2],t[2])+Math.min(n[2],a[2])+Math.min(i[2],r[2])+l[14],c[0]=Math.max(e[0],t[0])+Math.max(n[0],a[0])+Math.max(i[0],r[0])+l[12],c[1]=Math.max(e[1],t[1])+Math.max(n[1],a[1])+Math.max(i[1],r[1])+l[13],c[2]=Math.max(e[2],t[2])+Math.max(n[2],a[2])+Math.max(i[2],r[2])+l[14],this.min._dirty=!0,this.max._dirty=!0,this}}(),applyProjection:function(e){var t=this.min._array,n=this.max._array,a=e._array,i=t[0],r=t[1],o=t[2],s=n[0],c=n[1],l=t[2],u=n[0],p=n[1],d=n[2];if(1===a[15])t[0]=a[0]*i+a[12],t[1]=a[5]*r+a[13],n[2]=a[10]*o+a[14],n[0]=a[0]*u+a[12],n[1]=a[5]*p+a[13],t[2]=a[10]*d+a[14];else{var f=-1/o;t[0]=a[0]*i*f,t[1]=a[5]*r*f,n[2]=(a[10]*o+a[14])*f,f=-1/l,n[0]=a[0]*s*f,n[1]=a[5]*c*f,f=-1/d,t[2]=(a[10]*d+a[14])*f}return this.min._dirty=!0,this.max._dirty=!0,this},updateVertices:function(){var e=this.vertices;if(!e){for(var e=[],t=0;t<8;t++)e[t]=o.fromValues(0,0,0);this.vertices=e}var n=this.min._array,a=this.max._array;return c(e[0],n[0],n[1],n[2]),c(e[1],n[0],a[1],n[2]),c(e[2],a[0],n[1],n[2]),c(e[3],a[0],a[1],n[2]),c(e[4],n[0],n[1],a[2]),c(e[5],n[0],a[1],a[2]),c(e[6],a[0],n[1],a[2]),c(e[7],a[0],a[1],a[2]),this},copy:function(e){var t=this.min,n=this.max;return s(t._array,e.min._array),s(n._array,e.max._array),t._dirty=!0,n._dirty=!0,this},clone:function(){var e=new l;return e.copy(this),e}},t.a=l},function(e,t,n){"use strict";var a=n(0),i=n.n(a),r=n(2),o=i.a.mat4,s=i.a.vec3,c=i.a.mat3,l=i.a.quat,u=function(){this._axisX=new r.a,this._axisY=new r.a,this._axisZ=new r.a,this._array=o.create(),this._dirty=!0};u.prototype={constructor:u,setArray:function(e){for(var t=0;t=0},set:function(e,t){if("object"==typeof e)for(var n in e){var a=e[n];this.set(n,a)}else{var i=this.uniforms[e];i&&(void 0===t&&(console.warn('Uniform value "'+e+'" is undefined'),t=null),i.value=t)}},get:function(e){var t=this.uniforms[e];if(t)return t.value},attachShader:function(e,t){this.shader&&this.shader.detached();var n=this.uniforms;this.uniforms=e.createUniforms(),this.shader=e;var a=this.uniforms;if(this._enabledUniforms=Object.keys(a),this._enabledUniforms.sort(),t)for(var i in n)a[i]&&(a[i].value=n[i].value);e.attached()},detachShader:function(){this.shader.detached(),this.shader=null,this.uniforms={}},clone:function(){var e=new this.constructor({name:this.name,shader:this.shader});for(var t in this.uniforms)e.uniforms[t].value=this.uniforms[t].value;return e.depthTest=this.depthTest,e.depthMask=this.depthMask,e.transparent=this.transparent,e.blend=this.blend,e},dispose:function(e,t){if(t)for(var n in this.uniforms){var a=this.uniforms[n].value;if(a)if(a instanceof i.a)a.dispose(e);else if(Array.isArray(a))for(var r=0;r=n.COLOR_ATTACHMENT0&&r<=n.COLOR_ATTACHMENT0+8&&i.push(r);a.drawBuffersEXT(i)}}this.trigger("beforerender",this,e);var o=this.clearDepth?n.DEPTH_BUFFER_BIT:0;if(n.depthMask(!0),this.clearColor){o|=n.COLOR_BUFFER_BIT,n.colorMask(!0,!0,!0,!0);var s=this.clearColor;Array.isArray(s)&&n.clearColor(s[0],s[1],s[2],s[3])}n.clear(o),this.blendWithPrevious?(n.enable(n.BLEND),this.material.transparent=!0):(n.disable(n.BLEND),this.material.transparent=!1),this.renderQuad(e),this.trigger("afterrender",this,e),t&&this.unbind(e,t)},renderQuad:function(e){d.material=this.material,e.renderQueue([d],f)},dispose:function(e){this.material.dispose(e)}});t.a=h},function(e,t,n){"use strict";var a=!0;try{var i=document.createElement("canvas");if(!(i.getContext("webgl")||i.getContext("experimental-webgl")))throw new Error}catch(e){a=!1}var r={};r.supportWebGL=function(){return a},r.Int8Array="undefined"==typeof Int8Array?Array:Int8Array,r.Uint8Array="undefined"==typeof Uint8Array?Array:Uint8Array,r.Uint16Array="undefined"==typeof Uint16Array?Array:Uint16Array,r.Uint32Array="undefined"==typeof Uint32Array?Array:Uint32Array,r.Int16Array="undefined"==typeof Int16Array?Array:Int16Array,r.Float32Array="undefined"==typeof Float32Array?Array:Float32Array,r.Float64Array="undefined"==typeof Float64Array?Array:Float64Array,t.a=r},function(e,t,n){"use strict";var a=n(15),i=a.a.extend(function(){return{color:[1,1,1],intensity:1,castShadow:!0,shadowResolution:512,group:0}},{type:"",clone:function(){var e=a.a.prototype.clone.call(this);return e.color=Array.prototype.slice.call(this.color),e.intensity=this.intensity,e.castShadow=this.castShadow,e.shadowResolution=this.shadowResolution,e}});t.a=i},function(e,t,n){"use strict";var a=n(1),i=n(2),r=n(71),o=n(8),s=n(0),c=n.n(s),l=n(7),u=c.a.mat4,p=0,d=a.a.extend({name:"",position:null,rotation:null,scale:null,worldTransform:null,localTransform:null,autoUpdateLocalTransform:!0,_parent:null,_scene:null,_needsUpdateWorldTransform:!0,_inIterating:!1,__depth:0},function(){this.name||(this.name=(this.type||"NODE")+"_"+p++),this.position||(this.position=new i.a),this.rotation||(this.rotation=new r.a),this.scale||(this.scale=new i.a(1,1,1)),this.worldTransform=new o.a,this.localTransform=new o.a,this._children=[]},{target:null,invisible:!1,isSkinnedMesh:function(){return!1},isRenderable:function(){return!1},setName:function(e){var t=this._scene;if(t){var n=t._nodeRepository;delete n[this.name],n[e]=this}this.name=e},add:function(e){this._inIterating&&console.warn("Add operation can cause unpredictable error when in iterating");var t=e._parent;if(t!==this){t&&t.remove(e),e._parent=this,this._children.push(e);var n=this._scene;n&&n!==e.scene&&e.traverse(this._addSelfToScene,this),e._needsUpdateWorldTransform=!0}},remove:function(e){this._inIterating&&console.warn("Remove operation can cause unpredictable error when in iterating");var t=this._children,n=t.indexOf(e);n<0||(t.splice(n,1),e._parent=null,this._scene&&e.traverse(this._removeSelfFromScene,this))},removeAll:function(){for(var e=this._children,t=0;t256?64:o>64?32:o>16?16:8;var s=this.getSkinMatricesTexture();s.width=r,s.height=r,s.pixels&&s.pixels.length===r*r*4||(s.pixels=new Float32Array(r*r*4)),s.pixels.set(i),s.dirty(),t.setUniform(n,"1f","skinMatricesTextureSize",r)}else t.setUniformOfSemantic(n,"SKIN_MATRIX",i)}return a.a.prototype.render.call(this,e,t)},getSkinMatricesTexture:function(){return this._skinMatricesTexture=this._skinMatricesTexture||new r.a({type:i.a.FLOAT,minFilter:i.a.NEAREST,magFilter:i.a.NEAREST,useMipmap:!1,flipY:!1}),this._skinMatricesTexture}});o.POINTS=i.a.POINTS,o.LINES=i.a.LINES,o.LINE_LOOP=i.a.LINE_LOOP,o.LINE_STRIP=i.a.LINE_STRIP,o.TRIANGLES=i.a.TRIANGLES,o.TRIANGLE_STRIP=i.a.TRIANGLE_STRIP,o.TRIANGLE_FAN=i.a.TRIANGLE_FAN,o.BACK=i.a.BACK,o.FRONT=i.a.FRONT,o.FRONT_AND_BACK=i.a.FRONT_AND_BACK,o.CW=i.a.CW,o.CCW=i.a.CCW,t.a=o},function(e,t,n){"use strict";function a(e){return"CANVAS"===e.nodeName||"VIDEO"===e.nodeName||e.complete}var i=n(3),r=n(6),o=n(11),s=n(44),c=s.a.isPowerOfTwo,l=["px","nx","py","ny","pz","nz"],u=i.a.extend(function(){return{image:{px:null,nx:null,py:null,ny:null,pz:null,nz:null},pixels:{px:null,nx:null,py:null,ny:null,pz:null,nz:null},mipmaps:[]}},{update:function(e){var t=e.gl;t.bindTexture(t.TEXTURE_CUBE_MAP,this._cache.get("webgl_texture")),this.updateCommon(e);var n=this.format,a=this.type;t.texParameteri(t.TEXTURE_CUBE_MAP,t.TEXTURE_WRAP_S,this.getAvailableWrapS()),t.texParameteri(t.TEXTURE_CUBE_MAP,t.TEXTURE_WRAP_T,this.getAvailableWrapT()),t.texParameteri(t.TEXTURE_CUBE_MAP,t.TEXTURE_MAG_FILTER,this.getAvailableMagFilter()),t.texParameteri(t.TEXTURE_CUBE_MAP,t.TEXTURE_MIN_FILTER,this.getAvailableMinFilter());var i=e.getGLExtension("EXT_texture_filter_anisotropic");if(i&&this.anisotropic>1&&t.texParameterf(t.TEXTURE_CUBE_MAP,i.TEXTURE_MAX_ANISOTROPY_EXT,this.anisotropic),36193===a){e.getGLExtension("OES_texture_half_float")||(a=r.a.FLOAT)}if(this.mipmaps.length)for(var o=this.width,s=this.height,c=0;c0&&this._updateRenderQueue(a)}},_updateLightUniforms:function(){var e=this.lights;e.sort(a);var t=this._lightUniforms;for(var n in t)for(var i in t[n])t[n][i].value.length=0;for(var r=0;rr[0]&&(r[0]=s),c>r[1]&&(r[1]=c),l>r[2]&&(r[2]=l)}n._dirty=!0,a._dirty=!0}},dirty:function(){for(var e=this.getEnabledAttributes(),t=0;t=0){t||(t=_());var n=this.indices;return t[0]=n[3*e],t[1]=n[3*e+1],t[2]=n[3*e+2],t}},setTriangleIndices:function(e,t){var n=this.indices;n[3*e]=t[0],n[3*e+1]=t[1],n[3*e+2]=t[2]},isUseIndices:function(){return!!this.indices},initIndicesFromArray:function(e){var t,n=this.vertexCount>65535?p.a.Uint32Array:p.a.Uint16Array;if(e[0]&&e[0].length){var a=0;t=new n(3*e.length);for(var i=0;i=0&&(t.splice(n,1),delete this.attributes[e],!0)},getAttribute:function(e){return this.attribute[e]},getEnabledAttributes:function(){var e=this._enabledAttributes,t=this._attributeList;if(e)return e;for(var n=[],a=this.vertexCount,i=0;i65535&&(this.indices=new p.a.Uint32Array(this.indices));for(var e=this.attributes,t=this.indices,n=this.getEnabledAttributes(),a={},i=0;i0){var t=this.outputs[e];t.keepLastFrame?(this._prevOutputTextures[e]&&this._compositor.releaseTexture(this._prevOutputTextures[e]),this._prevOutputTextures[e]=this._outputTextures[e]):this._compositor.releaseTexture(this._outputTextures[e])}}});t.a=i},function(e,t,n){"use strict";function a(e,t){this.action=e,this.context=t}var i={trigger:function(e){if(this.hasOwnProperty("__handlers__")&&this.__handlers__.hasOwnProperty(e)){var t=this.__handlers__[e],n=t.length,a=-1,i=arguments;switch(i.length){case 1:for(;++a=400?e.onerror&&e.onerror():e.onload&&e.onload(t.response)},e.onerror&&(t.onerror=e.onerror),t.send(null)}t.a={get:a}},function(e,t,n){"use strict";var a=n(46),i=a.a.extend({fov:50,aspect:1,near:.1,far:2e3},{updateProjectionMatrix:function(){var e=this.fov/180*Math.PI;this.projectionMatrix.perspective(e,this.aspect,this.near,this.far)},decomposeProjectionMatrix:function(){var e=this.projectionMatrix._array,t=2*Math.atan(1/e[5]);this.fov=t/Math.PI*180,this.aspect=e[5]/e[0],this.near=e[14]/(e[10]-1),this.far=e[14]/(e[10]+1)},clone:function(){var e=a.a.prototype.clone.call(this);return e.fov=this.fov,e.aspect=this.aspect,e.near=this.near,e.far=this.far,e}});t.a=i},function(e,t,n){"use strict";var a=n(46),i=a.a.extend({left:-1,right:1,near:-1,far:1,top:1,bottom:-1},{updateProjectionMatrix:function(){this.projectionMatrix.ortho(this.left,this.right,this.bottom,this.top,this.near,this.far)},decomposeProjectionMatrix:function(){var e=this.projectionMatrix._array;this.left=(-1-e[12])/e[0],this.right=(1-e[12])/e[0],this.top=(1-e[13])/e[5],this.bottom=(-1-e[13])/e[5],this.near=-(-1-e[14])/e[10],this.far=-(1-e[14])/e[10]},clone:function(){var e=a.a.prototype.clone.call(this);return e.left=this.left,e.right=this.right,e.near=this.near,e.far=this.far,e.top=this.top,e.bottom=this.bottom,e}});t.a=i},function(e,t,n){"use strict";function a(e,t){for(var n=0,a=1/t,i=e;i>0;)n+=a*(i%t),i=Math.floor(i/t),a/=t;return n}t.a=a},function(e,t,n){"use strict";function a(e){return!e||"none"===e}function i(e){return e instanceof HTMLCanvasElement||e instanceof HTMLImageElement||e instanceof Image}function r(e){return Math.pow(2,Math.round(Math.log(e)/Math.LN2))}function o(e){if((e.wrapS===s.a.REPEAT||e.wrapT===s.a.REPEAT)&&e.image){var t=r(e.width),n=r(e.height);if(t!==e.width||n!==e.height){var a=document.createElement("canvas");a.width=t,a.height=n;a.getContext("2d").drawImage(e.image,0,0,t,n),a.srcImage=e.image,e.image=a,e.dirty()}}}var s=n(3),c=n(9),l=n(63),u=n(33),p=n(117),d=n(122),f=n(123),h=n(125),m=n(5);c.a.prototype.setTextureImage=function(e,t,n,i){if(this.shader){var r,o=this;return o.shader.disableTexture(e),a(t)||(r=v.loadTexture(t,n,i,function(t){o.shader.enableTexture(e),n.refresh()}),o.set(e,r)),r}};var v={},_=u.a.createBlank("rgba(255,255,255,0)").image;v.firstNotNull=function(){for(var e=0,t=arguments.length;e3?t[3]=e[3]:t[3]=1,t):(t=h.a(e||"#000",t)||[0,0,0,0],t[0]/=255,t[1]/=255,t[2]/=255,t)},v.stringifyColor=function(e,t){return e=e.slice(),e[0]=Math.round(255*e[0]),e[1]=Math.round(255*e[1]),e[2]=Math.round(255*e[2]),"hex"===t?"#"+((1<<24)+(e[0]<<16)+(e[1]<<8)+e[2]).toString(16).slice(1):h.b(e,t)},v.directionFromAlphaBeta=function(e,t){var n=e/180*Math.PI+Math.PI/2,a=-t/180*Math.PI+Math.PI/2,i=[],r=Math.sin(n);return i[0]=r*Math.cos(a),i[1]=-Math.cos(n),i[2]=r*Math.sin(a),i},v.convertTextureToPowerOfTwo=o,t.a=v},function(e,t,n){"use strict";var a=n(1),i=n(69),r=n(6),o=(n(13),n(7)),s=n(8),c=(n(18),n(9)),l=n(24),u=n(4),p=n(38),d=n(39),f=n(0),h=n.n(f);u.a.import(p.a),u.a.import(d.a);var m=h.a.mat4,v=h.a.vec3,_=m.create,x={},g=a.a.extend(function(){return{canvas:null,_width:100,_height:100,devicePixelRatio:window.devicePixelRatio||1,clearColor:[0,0,0,0],clearBit:17664,alpha:!0,depth:!0,stencil:!1,antialias:!0,premultipliedAlpha:!0,preserveDrawingBuffer:!1,throwError:!0,gl:null,viewport:{},__currentFrameBuffer:null,_viewportStack:[],_clearStack:[],_sceneRendering:null}},function(){this.canvas||(this.canvas=document.createElement("canvas"));var e=this.canvas;try{var t={alpha:this.alpha,depth:this.depth,stencil:this.stencil,antialias:this.antialias,premultipliedAlpha:this.premultipliedAlpha,preserveDrawingBuffer:this.preserveDrawingBuffer};if(this.gl=e.getContext("webgl",t)||e.getContext("experimental-webgl",t),!this.gl)throw new Error;this._glinfo=new i.a(this.gl),this.gl.targetRenderer&&console.error("Already created a renderer"),this.gl.targetRenderer=this,this.resize()}catch(e){throw"Error creating WebGL Context "+e}},{resize:function(e,t){var n=this.canvas,a=this.devicePixelRatio;null!=e?(n.style.width=e+"px",n.style.height=t+"px",n.width=e*a,n.height=t*a,this._width=e,this._height=t):(this._width=n.width/a,this._height=n.height/a),this.setViewport(0,0,this._width,this._height)},getWidth:function(){return this._width},getHeight:function(){return this._height},getViewportAspect:function(){var e=this.viewport;return e.width/e.height},setDevicePixelRatio:function(e){this.devicePixelRatio=e,this.resize(this._width,this._height)},getDevicePixelRatio:function(){return this.devicePixelRatio},getGLExtension:function(e){return this._glinfo.getExtension(e)},getGLParameter:function(e){return this._glinfo.getParameter(e)},setViewport:function(e,t,n,a,i){if("object"==typeof e){var r=e;e=r.x,t=r.y,n=r.width,a=r.height,i=r.devicePixelRatio}i=i||this.devicePixelRatio,this.gl.viewport(e*i,t*i,n*i,a*i),this.viewport={x:e,y:t,width:n,height:a,devicePixelRatio:i}},saveViewport:function(){this._viewportStack.push(this.viewport)},restoreViewport:function(){this._viewportStack.length>0&&this.setViewport(this._viewportStack.pop())},saveClear:function(){this._clearStack.push({clearBit:this.clearBit,clearColor:this.clearColor})},restoreClear:function(){if(this._clearStack.length>0){var e=this._clearStack.pop();this.clearColor=e.clearColor,this.clearBit=e.clearBit}},bindSceneRendering:function(e){this._sceneRendering=e},beforeRenderObject:function(){},afterRenderObject:function(){},render:function(e,t,n,a){var i=this.gl;this._sceneRendering=e;var r=this.clearColor;if(this.clearBit){i.colorMask(!0,!0,!0,!0),i.depthMask(!0);var o=this.viewport,s=!1,c=o.devicePixelRatio;(o.width!==this._width||o.height!==this._height||c&&c!==this.devicePixelRatio||o.x||o.y)&&(s=!0,i.enable(i.SCISSOR_TEST),i.scissor(o.x*c,o.y*c,o.width*c,o.height*c)),i.clearColor(r[0],r[1],r[2],r[3]),i.clear(this.clearBit),s&&i.disable(i.SCISSOR_TEST)}n||e.update(!1),t.getScene()||t.update(!0);for(var l=e.opaqueQueue,u=e.transparentQueue,p=e.material,d=0;d0)for(var h=_(),x=v.create(),d=0;d0&&e.min._array[2]<0&&(e.max._array[2]=-1e-20),e.applyProjection(t);var c=e.min._array,l=e.max._array;if(l[0]<-1||c[0]>1||l[1]<-1||c[1]>1||l[2]<-1||c[2]>1)return!0}return!1}}(),disposeScene:function(e){this.disposeNode(e,!0,!0),e.dispose()},disposeNode:function(e,t,n){var a={};e.getParent()&&e.getParent().remove(e),e.traverse(function(e){e.geometry&&t&&e.geometry.dispose(this),e.material&&(a[e.material.__GUID__]=e.material),e.dispose&&e.dispose(this)},this);for(var i in a){a[i].dispose(this,n)}},disposeShader:function(e){e.dispose(this)},disposeGeometry:function(e){e.dispose(this)},disposeTexture:function(e){e.dispose(this)},disposeFrameBuffer:function(e){e.dispose(this)},dispose:function(){},screenToNDC:function(e,t,n){n||(n=new l.a),t=this._height-t;var a=this.viewport,i=n._array;return i[0]=(e-a.x)/a.width,i[0]=2*i[0]-1,i[1]=(t-a.y)/a.height,i[1]=2*i[1]-1,n}});g.opaqueSortFunc=g.prototype.opaqueSortFunc=function(e,t){return e.renderOrder===t.renderOrder?e.material.shader===t.material.shader?e.material===t.material?e.geometry.__GUID__-t.geometry.__GUID__:e.material.__GUID__-t.material.__GUID__:e.material.shader.__GUID__-t.material.shader.__GUID__:e.renderOrder-t.renderOrder},g.transparentSortFunc=g.prototype.transparentSortFunc=function(e,t){return e.renderOrder===t.renderOrder?e.__depth===t.__depth?e.material.shader===t.material.shader?e.material===t.material?e.geometry.__GUID__-t.geometry.__GUID__:e.material.__GUID__-t.material.__GUID__:e.material.shader.__GUID__-t.material.shader.__GUID__:e.__depth-t.__depth:e.renderOrder-t.renderOrder};var y={IDENTITY:_(),WORLD:_(),VIEW:_(),PROJECTION:_(),WORLDVIEW:_(),VIEWPROJECTION:_(),WORLDVIEWPROJECTION:_(),WORLDINVERSE:_(),VIEWINVERSE:_(),PROJECTIONINVERSE:_(),WORLDVIEWINVERSE:_(),VIEWPROJECTIONINVERSE:_(),WORLDVIEWPROJECTIONINVERSE:_(),WORLDTRANSPOSE:_(),VIEWTRANSPOSE:_(),PROJECTIONTRANSPOSE:_(),WORLDVIEWTRANSPOSE:_(),VIEWPROJECTIONTRANSPOSE:_(),WORLDVIEWPROJECTIONTRANSPOSE:_(),WORLDINVERSETRANSPOSE:_(),VIEWINVERSETRANSPOSE:_(),PROJECTIONINVERSETRANSPOSE:_(),WORLDVIEWINVERSETRANSPOSE:_(),VIEWPROJECTIONINVERSETRANSPOSE:_(),WORLDVIEWPROJECTIONINVERSETRANSPOSE:_()};g.COLOR_BUFFER_BIT=r.a.COLOR_BUFFER_BIT,g.DEPTH_BUFFER_BIT=r.a.DEPTH_BUFFER_BIT,g.STENCIL_BUFFER_BIT=r.a.STENCIL_BUFFER_BIT,t.a=g},function(e,t,n){"use strict";function a(){}var i=n(75),r=function(e){e=e||{},this.name=e.name||"",this.target=e.target,this.life=e.life||1e3,this.delay=e.delay||0,this.gap=e.gap||0,this.playbackRate=e.playbackRate||1,this._initialized=!1,this._elapsedTime=0,this._loop=null!=e.loop&&e.loop,this.setLoop(this._loop),null!=e.easing&&this.setEasing(e.easing),this.onframe=e.onframe||a,this.onfinish=e.onfinish||a,this.onrestart=e.onrestart||a,this._paused=!1};r.prototype={gap:0,life:0,delay:0,setLoop:function(e){this._loop=e,e&&(this._loopRemained="number"==typeof e?e:1e8)},setEasing:function(e){"string"==typeof e&&(e=i.a[e]),this.easing=e},step:function(e,t,n){if(this._initialized||(this._startTime=e+this.delay,this._initialized=!0),null!=this._currentTime&&(t=e-this._currentTime),this._currentTime=e,this._paused)return"paused";if(!(e0?(this._restartInLoop(e),this._loopRemained--,"restart"):(this._needsRemove=!0,"finish"):null}}},setTime:function(e){return this.step(e+this._startTime)},restart:function(e){var t=0;e&&(this._elapse(e),t=this._elapsedTime%this.life),e=e||Date.now(),this._startTime=e-t+this.delay,this._elapsedTime=0,this._needsRemove=!1,this._paused=!1},getElapsedTime:function(){return this._elapsedTime},_restartInLoop:function(e){this._startTime=e+this.gap,this._elapsedTime=0},_elapse:function(e,t){this._elapsedTime+=t*this.playbackRate},fire:function(e,t){var n="on"+e;this[n]&&this[n](this.target,t)},clone:function(){var e=new this.constructor;return e.name=this.name,e._loop=this._loop,e._loopRemained=this._loopRemained,e.life=this.life,e.gap=this.gap,e.delay=this.delay,e},pause:function(){this._paused=!0},resume:function(){this._paused=!1}},r.prototype.constructor=r,t.a=r},function(e,t,n){"use strict";var a=n(20),i=n(7),r=a.a.extend({dynamic:!1,widthSegments:1,heightSegments:1},function(){this.build()},{build:function(){for(var e=this.heightSegments,t=this.widthSegments,n=this.attributes,a=[],r=[],o=[],s=[],c=0;c<=e;c++)for(var l=c/e,u=0;u<=t;u++){var p=u/t;if(a.push([2*p-1,2*l-1,0]),r&&r.push([p,l]),o&&o.push([0,0,1]),u20)return console.warn("Given image is not a height map"),e}var d,f,h,m;c%(4*a)==0?(d=o.data[c],h=o.data[c+4]):c%(4*a)==4*(a-1)?(d=o.data[c-4],h=o.data[c]):(d=o.data[c-4],h=o.data[c+4]),c<4*a?(f=o.data[c],m=o.data[c+4*a]):c>a*(i-1)*4?(f=o.data[c-4*a],m=o.data[c]):(f=o.data[c-4*a],m=o.data[c+4*a]),s.data[c]=d-h+127,s.data[c+1]=f-m+127,s.data[c+2]=255,s.data[c+3]=255}return r.putImageData(s,0,0),n},isHeightImage:function(e,t,n){if(!e||!e.width||!e.height)return!1;var a=document.createElement("canvas"),i=a.getContext("2d"),r=t||32;n=n||20,a.width=a.height=r,i.drawImage(e,0,0,r,r);for(var o=i.getImageData(0,0,r,r),s=0;sn)return!1}return!0},_fetchTexture:function(e,t,n){r.a.get({url:e,responseType:"arraybuffer",onload:t,onerror:n})},createChessboard:function(e,t,n,i){e=e||512,t=t||64,n=n||"black",i=i||"white";var r=Math.ceil(e/t),o=document.createElement("canvas");o.width=e,o.height=e;var s=o.getContext("2d");s.fillStyle=i,s.fillRect(0,0,e,e),s.fillStyle=n;for(var c=0;c0},beforeRender:function(e){},afterRender:function(e,t){},getBoundingBox:function(e,t){return t=r.a.prototype.getBoundingBox.call(this,e,t),this.geometry&&this.geometry.boundingBox&&t.union(this.geometry.boundingBox),t},render:function(e,t){var n=e.gl,t=t||this.material.shader,r=this.geometry,u=this.mode,p=r.vertexCount,d=r.isUseIndices(),f=e.getGLExtension("OES_element_index_uint"),h=f&&p>65535,m=h?n.UNSIGNED_INT:n.UNSIGNED_SHORT,v=e.getGLExtension("OES_vertex_array_object"),_=!r.dynamic,x=this._renderInfo;x.vertexCount=p,x.triangleCount=0,x.drawCallCount=0;var g=!1;if(i=e.__GUID__+"-"+r.__GUID__+"-"+t.__GUID__,i!==s?g=!0:(p>65535&&!f&&d||v&&_||r._cache.isDirty())&&(g=!0),s=i,g){var y=this._drawCache[i];if(!y){var b=r.getBufferChunks(e);if(!b)return;y=[];for(var T=0;T>1,e|=e>>2,e|=e>>4,e|=e>>8,e|=e>>16,++e},a.nearestPowerOfTwo=function(e){return Math.pow(2,Math.round(Math.log(e)/Math.LN2))},t.a=a},function(e,t,n){"use strict";var a=n(1),i=a.a.extend({name:"",index:-1,node:null,rootNode:null});t.a=i},function(e,t,n){"use strict";var a=n(15),i=n(8),r=n(47),o=n(48),s=n(0),c=n.n(s),l=c.a.vec3,u=c.a.vec4,p=a.a.extend(function(){return{projectionMatrix:new i.a,invProjectionMatrix:new i.a,viewMatrix:new i.a,frustum:new r.a}},function(){this.update(!0)},{update:function(e){a.a.prototype.update.call(this,e),i.a.invert(this.viewMatrix,this.worldTransform),this.updateProjectionMatrix(),i.a.invert(this.invProjectionMatrix,this.projectionMatrix),this.frustum.setFromProjection(this.projectionMatrix)},setViewMatrix:function(e){i.a.copy(this.viewMatrix,e),i.a.invert(this.worldTransform,e),this.decomposeWorldTransform()},decomposeProjectionMatrix:function(){},setProjectionMatrix:function(e){i.a.copy(this.projectionMatrix,e),i.a.invert(this.invProjectionMatrix,e),this.decomposeProjectionMatrix()},updateProjectionMatrix:function(){},castRay:function(){var e=u.create();return function(t,n){var a=void 0!==n?n:new o.a,i=t._array[0],r=t._array[1];return u.set(e,i,r,-1,1),u.transformMat4(e,e,this.invProjectionMatrix._array),u.transformMat4(e,e,this.worldTransform._array),l.scale(a.origin._array,e,1/e[3]),u.set(e,i,r,1,1),u.transformMat4(e,e,this.invProjectionMatrix._array),u.transformMat4(e,e,this.worldTransform._array),l.scale(e,e,1/e[3]),l.sub(a.direction._array,e,a.origin._array),l.normalize(a.direction._array,a.direction._array),a.direction._dirty=!0,a.origin._dirty=!0,a}}()});t.a=p},function(e,t,n){"use strict";var a=(n(2),n(7)),i=n(73),r=n(0),o=n.n(r),s=o.a.vec3,c=s.set,l=s.copy,u=s.transformMat4,p=Math.min,d=Math.max,f=function(){this.planes=[];for(var e=0;e<6;e++)this.planes.push(new i.a);this.boundingBox=new a.a,this.vertices=[];for(var e=0;e<8;e++)this.vertices[e]=s.fromValues(0,0,0)};f.prototype={setFromProjection:function(e){var t=this.planes,n=e._array,a=n[0],i=n[1],r=n[2],o=n[3],s=n[4],l=n[5],u=n[6],p=n[7],d=n[8],f=n[9],h=n[10],m=n[11],v=n[12],_=n[13],x=n[14],g=n[15];c(t[0].normal._array,o-a,p-s,m-d),t[0].distance=-(g-v),t[0].normalize(),c(t[1].normal._array,o+a,p+s,m+d),t[1].distance=-(g+v),t[1].normalize(),c(t[2].normal._array,o+i,p+l,m+f),t[2].distance=-(g+_),t[2].normalize(),c(t[3].normal._array,o-i,p-l,m-f),t[3].distance=-(g-_),t[3].normalize(),c(t[4].normal._array,o-r,p-u,m-h),t[4].distance=-(g-x),t[4].normalize(),c(t[5].normal._array,o+r,p+u,m+h),t[5].distance=-(g+x),t[5].normalize();var y=this.boundingBox;if(0===g){var b=l/a,T=-x/(h-1),E=-x/(h+1),w=-E/l,S=-T/l;y.min.set(-w*b,-w,E),y.max.set(w*b,w,T);var A=this.vertices;c(A[0],-w*b,-w,E),c(A[1],-w*b,w,E),c(A[2],w*b,-w,E),c(A[3],w*b,w,E),c(A[4],-S*b,-S,T),c(A[5],-S*b,S,T),c(A[6],S*b,-S,T),c(A[7],S*b,S,T)}else{var N=(-1-v)/a,C=(1-v)/a,M=(1-_)/l,R=(-1-_)/l,L=(-1-x)/h,D=(1-x)/h;y.min.set(Math.min(N,C),Math.min(R,M),Math.min(D,L)),y.max.set(Math.max(C,N),Math.max(M,R),Math.max(L,D));var P=y.min._array,I=y.max._array,A=this.vertices;c(A[0],P[0],P[1],P[2]),c(A[1],P[0],I[1],P[2]),c(A[2],I[0],P[1],P[2]),c(A[3],I[0],I[1],P[2]),c(A[4],P[0],P[1],I[2]),c(A[5],P[0],I[1],I[2]),c(A[6],I[0],P[1],I[2]),c(A[7],I[0],I[1],I[2])}},getTransformedBoundingBox:function(){var e=s.create();return function(t,n){var a=this.vertices,i=n._array,r=t.min,o=t.max,s=r._array,c=o._array,f=a[0];u(e,f,i),l(s,e),l(c,e);for(var h=1;h<8;h++)f=a[h],u(e,f,i),s[0]=p(e[0],s[0]),s[1]=p(e[1],s[1]),s[2]=p(e[2],s[2]),c[0]=d(e[0],c[0]),c[1]=d(e[1],c[1]),c[2]=d(e[2],c[2]);return r._dirty=!0,o._dirty=!0,t}}()},t.a=f},function(e,t,n){"use strict";var a=n(2),i=n(0),r=n.n(i),o=r.a.vec3,s=function(e,t){this.origin=e||new a.a,this.direction=t||new a.a};s.prototype={constructor:s,intersectPlane:function(e,t){var n=e.normal._array,i=e.distance,r=this.origin._array,s=this.direction._array,c=o.dot(n,s);if(0===c)return null;t||(t=new a.a);var l=(o.dot(n,r)-i)/c;return o.scaleAndAdd(t._array,r,s,-l),t._dirty=!0,t},mirrorAgainstPlane:function(e){var t=o.dot(e.normal._array,this.direction._array);o.scaleAndAdd(this.direction._array,this.direction._array,e.normal._array,2*-t),this.direction._dirty=!0},distanceToPoint:function(){var e=o.create();return function(t){o.sub(e,t,this.origin._array);var n=o.dot(e,this.direction._array);if(n<0)return o.distance(this.origin._array,t);var a=o.lenSquared(e);return Math.sqrt(a-n*n)}}(),intersectSphere:function(){var e=o.create();return function(t,n,i){var r=this.origin._array,s=this.direction._array;t=t._array,o.sub(e,t,r);var c=o.dot(e,s),l=o.squaredLength(e),u=l-c*c,p=n*n;if(!(u>p)){var d=Math.sqrt(p-u),f=c-d,h=c+d;return i||(i=new a.a),f<0?h<0?null:(o.scaleAndAdd(i._array,r,s,h),i):(o.scaleAndAdd(i._array,r,s,f),i)}}}(),intersectBoundingBox:function(e,t){var n,i,r,s,c,l,u=this.direction._array,p=this.origin._array,d=e.min._array,f=e.max._array,h=1/u[0],m=1/u[1],v=1/u[2];if(h>=0?(n=(d[0]-p[0])*h,i=(f[0]-p[0])*h):(i=(d[0]-p[0])*h,n=(f[0]-p[0])*h),m>=0?(r=(d[1]-p[1])*m,s=(f[1]-p[1])*m):(s=(d[1]-p[1])*m,r=(f[1]-p[1])*m),n>s||r>i)return null;if((r>n||n!==n)&&(n=r),(s=0?(c=(d[2]-p[2])*v,l=(f[2]-p[2])*v):(l=(d[2]-p[2])*v,c=(f[2]-p[2])*v),n>l||c>i)return null;if((c>n||n!==n)&&(n=c),(l=0?n:i;return t||(t=new a.a),o.scaleAndAdd(t._array,p,u,_),t},intersectTriangle:function(){var e=o.create(),t=o.create(),n=o.create(),i=o.create();return function(r,s,c,l,u,p){var d=this.direction._array,f=this.origin._array;r=r._array,s=s._array,c=c._array,o.sub(e,s,r),o.sub(t,c,r),o.cross(i,t,d);var h=o.dot(e,i);if(l){if(h>-1e-5)return null}else if(h>-1e-5&&h<1e-5)return null;o.sub(n,f,r);var m=o.dot(i,n)/h;if(m<0||m>1)return null;o.cross(i,e,n);var v=o.dot(d,i)/h;if(v<0||v>1||m+v>1)return null;o.cross(i,e,t);var _=-o.dot(n,i)/h;return _<0?null:(u||(u=new a.a),p&&a.a.set(p,1-m-v,m,v),o.scaleAndAdd(u._array,f,d,_),u)}}(),applyTransform:function(e){a.a.add(this.direction,this.direction,this.origin),a.a.transformMat4(this.origin,this.origin,e),a.a.transformMat4(this.direction,this.direction,e),a.a.sub(this.direction,this.direction,this.origin),a.a.normalize(this.direction,this.direction)},copy:function(e){a.a.copy(this.origin,e.origin),a.a.copy(this.direction,e.direction)},clone:function(){var e=new s;return e.copy(this),e}},t.a=s},function(e,t,n){"use strict";t.a="@export qtek.basic.vertex\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\nuniform vec2 uvRepeat : [1.0, 1.0];\nuniform vec2 uvOffset : [0.0, 0.0];\nattribute vec2 texcoord : TEXCOORD_0;\nattribute vec3 position : POSITION;\nattribute vec3 barycentric;\n@import qtek.chunk.skinning_header\nvarying vec2 v_Texcoord;\nvarying vec3 v_Barycentric;\nvoid main()\n{\n vec3 skinnedPosition = position;\n#ifdef SKINNING\n @import qtek.chunk.skin_matrix\n skinnedPosition = (skinMatrixWS * vec4(position, 1.0)).xyz;\n#endif\n v_Texcoord = texcoord * uvRepeat + uvOffset;\n v_Barycentric = barycentric;\n gl_Position = worldViewProjection * vec4(skinnedPosition, 1.0);\n}\n@end\n@export qtek.basic.fragment\nvarying vec2 v_Texcoord;\nuniform sampler2D diffuseMap;\nuniform vec3 color : [1.0, 1.0, 1.0];\nuniform vec3 emission : [0.0, 0.0, 0.0];\nuniform float alpha : 1.0;\n#ifdef ALPHA_TEST\nuniform float alphaCutoff: 0.9;\n#endif\nuniform float lineWidth : 0.0;\nuniform vec4 lineColor : [0.0, 0.0, 0.0, 0.6];\nvarying vec3 v_Barycentric;\n@import qtek.util.edge_factor\n@import qtek.util.rgbm\n@import qtek.util.srgb\nvoid main()\n{\n#ifdef RENDER_TEXCOORD\n gl_FragColor = vec4(v_Texcoord, 1.0, 1.0);\n return;\n#endif\n gl_FragColor = vec4(color, alpha);\n#ifdef DIFFUSEMAP_ENABLED\n vec4 tex = decodeHDR(texture2D(diffuseMap, v_Texcoord));\n#ifdef SRGB_DECODE\n tex = sRGBToLinear(tex);\n#endif\n#if defined(DIFFUSEMAP_ALPHA_ALPHA)\n gl_FragColor.a = tex.a;\n#endif\n gl_FragColor.rgb *= tex.rgb;\n#endif\n gl_FragColor.rgb += emission;\n if( lineWidth > 0.)\n {\n gl_FragColor.rgb = mix(gl_FragColor.rgb, lineColor.rgb, (1.0 - edgeFactor(lineWidth)) * lineColor.a);\n }\n#ifdef GAMMA_ENCODE\n gl_FragColor.rgb = pow(gl_FragColor.rgb, vec3(1 / 2.2));\n#endif\n#ifdef ALPHA_TEST\n if (gl_FragColor.a < alphaCutoff) {\n discard;\n }\n#endif\n gl_FragColor = encodeHDR(gl_FragColor);\n}\n@end"},function(e,t,n){"use strict";t.a="@export qtek.skybox.vertex\nuniform mat4 world : WORLD;\nuniform mat4 worldViewProjection : WORLDVIEWPROJECTION;\nattribute vec3 position : POSITION;\nvarying vec3 v_WorldPosition;\nvoid main()\n{\n v_WorldPosition = (world * vec4(position, 1.0)).xyz;\n gl_Position = worldViewProjection * vec4(position, 1.0);\n}\n@end\n@export qtek.skybox.fragment\nuniform mat4 viewInverse : VIEWINVERSE;\nuniform samplerCube environmentMap;\nuniform float lod: 0.0;\nvarying vec3 v_WorldPosition;\n@import qtek.util.rgbm\nvoid main()\n{\n vec3 eyePos = viewInverse[3].xyz;\n vec3 viewDirection = normalize(v_WorldPosition - eyePos);\n vec3 tex = decodeHDR(textureCubeLodEXT(environmentMap, viewDirection, lod)).rgb;\n#ifdef SRGB_DECODE\n tex.rgb = pow(tex.rgb, vec3(2.2));\n#endif\n gl_FragColor = encodeHDR(vec4(tex, 1.0));\n}\n@end"},function(e,t,n){"use strict";t.a="@export qtek.compositor.kernel.gaussian_9\nfloat gaussianKernel[9];\ngaussianKernel[0] = 0.07;\ngaussianKernel[1] = 0.09;\ngaussianKernel[2] = 0.12;\ngaussianKernel[3] = 0.14;\ngaussianKernel[4] = 0.16;\ngaussianKernel[5] = 0.14;\ngaussianKernel[6] = 0.12;\ngaussianKernel[7] = 0.09;\ngaussianKernel[8] = 0.07;\n@end\n@export qtek.compositor.kernel.gaussian_13\nfloat gaussianKernel[13];\ngaussianKernel[0] = 0.02;\ngaussianKernel[1] = 0.03;\ngaussianKernel[2] = 0.06;\ngaussianKernel[3] = 0.08;\ngaussianKernel[4] = 0.11;\ngaussianKernel[5] = 0.13;\ngaussianKernel[6] = 0.14;\ngaussianKernel[7] = 0.13;\ngaussianKernel[8] = 0.11;\ngaussianKernel[9] = 0.08;\ngaussianKernel[10] = 0.06;\ngaussianKernel[11] = 0.03;\ngaussianKernel[12] = 0.02;\n@end\n@export qtek.compositor.gaussian_blur\n#define SHADER_NAME gaussian_blur\nuniform sampler2D texture;varying vec2 v_Texcoord;\nuniform float blurSize : 2.0;\nuniform vec2 textureSize : [512.0, 512.0];\nuniform float blurDir : 0.0;\n@import qtek.util.rgbm\n@import qtek.util.clamp_sample\nvoid main (void)\n{\n @import qtek.compositor.kernel.gaussian_9\n vec2 off = blurSize / textureSize;\n off *= vec2(1.0 - blurDir, blurDir);\n vec4 sum = vec4(0.0);\n float weightAll = 0.0;\n for (int i = 0; i < 9; i++) {\n float w = gaussianKernel[i];\n vec4 texel = decodeHDR(clampSample(texture, v_Texcoord + float(i - 4) * off));\n sum += texel * w;\n weightAll += w;\n }\n gl_FragColor = encodeHDR(sum / max(weightAll, 0.01));\n}\n@end\n"},function(e,t,n){"use strict";t.a="@export qtek.compositor.output\n#define OUTPUT_ALPHA\nvarying vec2 v_Texcoord;\nuniform sampler2D texture;\n@import qtek.util.rgbm\nvoid main()\n{\n vec4 tex = decodeHDR(texture2D(texture, v_Texcoord));\n gl_FragColor.rgb = tex.rgb;\n#ifdef OUTPUT_ALPHA\n gl_FragColor.a = tex.a;\n#else\n gl_FragColor.a = 1.0;\n#endif\n gl_FragColor = encodeHDR(gl_FragColor);\n#ifdef PREMULTIPLY_ALPHA\n gl_FragColor.rgb *= gl_FragColor.a;\n#endif\n}\n@end"},function(e,t,n){"use strict";t.a="@export qtek.compositor.bright\nuniform sampler2D texture;\nuniform float threshold : 1;\nuniform float scale : 1.0;\nuniform vec2 textureSize: [512, 512];\nvarying vec2 v_Texcoord;\nconst vec3 lumWeight = vec3(0.2125, 0.7154, 0.0721);\n@import qtek.util.rgbm\nvec4 median(vec4 a, vec4 b, vec4 c)\n{\n return a + b + c - min(min(a, b), c) - max(max(a, b), c);\n}\nvoid main()\n{\n vec4 texel = decodeHDR(texture2D(texture, v_Texcoord));\n#ifdef ANTI_FLICKER\n vec3 d = 1.0 / textureSize.xyx * vec3(1.0, 1.0, 0.0);\n vec4 s1 = decodeHDR(texture2D(texture, v_Texcoord - d.xz));\n vec4 s2 = decodeHDR(texture2D(texture, v_Texcoord + d.xz));\n vec4 s3 = decodeHDR(texture2D(texture, v_Texcoord - d.zy));\n vec4 s4 = decodeHDR(texture2D(texture, v_Texcoord + d.zy));\n texel = median(median(texel, s1, s2), s3, s4);\n#endif\n float lum = dot(texel.rgb , lumWeight);\n vec4 color;\n if (lum > threshold && texel.a > 0.0)\n {\n color = vec4(texel.rgb * scale, texel.a * scale);\n }\n else\n {\n color = vec4(0.0);\n }\n gl_FragColor = encodeHDR(color);\n}\n@end\n"},function(e,t,n){"use strict";t.a="@export qtek.compositor.downsample\nuniform sampler2D texture;\nuniform vec2 textureSize : [512, 512];\nvarying vec2 v_Texcoord;\n@import qtek.util.rgbm\nfloat brightness(vec3 c)\n{\n return max(max(c.r, c.g), c.b);\n}\n@import qtek.util.clamp_sample\nvoid main()\n{\n vec4 d = vec4(-1.0, -1.0, 1.0, 1.0) / textureSize.xyxy;\n#ifdef ANTI_FLICKER\n vec3 s1 = decodeHDR(clampSample(texture, v_Texcoord + d.xy)).rgb;\n vec3 s2 = decodeHDR(clampSample(texture, v_Texcoord + d.zy)).rgb;\n vec3 s3 = decodeHDR(clampSample(texture, v_Texcoord + d.xw)).rgb;\n vec3 s4 = decodeHDR(clampSample(texture, v_Texcoord + d.zw)).rgb;\n float s1w = 1.0 / (brightness(s1) + 1.0);\n float s2w = 1.0 / (brightness(s2) + 1.0);\n float s3w = 1.0 / (brightness(s3) + 1.0);\n float s4w = 1.0 / (brightness(s4) + 1.0);\n float oneDivideSum = 1.0 / (s1w + s2w + s3w + s4w);\n vec4 color = vec4(\n (s1 * s1w + s2 * s2w + s3 * s3w + s4 * s4w) * oneDivideSum,\n 1.0\n );\n#else\n vec4 color = decodeHDR(clampSample(texture, v_Texcoord + d.xy));\n color += decodeHDR(clampSample(texture, v_Texcoord + d.zy));\n color += decodeHDR(clampSample(texture, v_Texcoord + d.xw));\n color += decodeHDR(clampSample(texture, v_Texcoord + d.zw));\n color *= 0.25;\n#endif\n gl_FragColor = encodeHDR(color);\n}\n@end"},function(e,t,n){"use strict";t.a="\n@export qtek.compositor.upsample\n#define HIGH_QUALITY\nuniform sampler2D texture;\nuniform vec2 textureSize : [512, 512];\nuniform float sampleScale: 0.5;\nvarying vec2 v_Texcoord;\n@import qtek.util.rgbm\n@import qtek.util.clamp_sample\nvoid main()\n{\n#ifdef HIGH_QUALITY\n vec4 d = vec4(1.0, 1.0, -1.0, 0.0) / textureSize.xyxy * sampleScale;\n vec4 s;\n s = decodeHDR(clampSample(texture, v_Texcoord - d.xy));\n s += decodeHDR(clampSample(texture, v_Texcoord - d.wy)) * 2.0;\n s += decodeHDR(clampSample(texture, v_Texcoord - d.zy));\n s += decodeHDR(clampSample(texture, v_Texcoord + d.zw)) * 2.0;\n s += decodeHDR(clampSample(texture, v_Texcoord )) * 4.0;\n s += decodeHDR(clampSample(texture, v_Texcoord + d.xw)) * 2.0;\n s += decodeHDR(clampSample(texture, v_Texcoord + d.zy));\n s += decodeHDR(clampSample(texture, v_Texcoord + d.wy)) * 2.0;\n s += decodeHDR(clampSample(texture, v_Texcoord + d.xy));\n gl_FragColor = encodeHDR(s / 16.0);\n#else\n vec4 d = vec4(-1.0, -1.0, +1.0, +1.0) / textureSize.xyxy;\n vec4 s;\n s = decodeHDR(clampSample(texture, v_Texcoord + d.xy));\n s += decodeHDR(clampSample(texture, v_Texcoord + d.zy));\n s += decodeHDR(clampSample(texture, v_Texcoord + d.xw));\n s += decodeHDR(clampSample(texture, v_Texcoord + d.zw));\n gl_FragColor = encodeHDR(s / 4.0);\n#endif\n}\n@end"},function(e,t,n){"use strict";t.a="@export qtek.compositor.hdr.composite\nuniform sampler2D texture;\n#ifdef BLOOM_ENABLED\nuniform sampler2D bloom;\n#endif\n#ifdef LENSFLARE_ENABLED\nuniform sampler2D lensflare;\nuniform sampler2D lensdirt;\n#endif\n#ifdef LUM_ENABLED\nuniform sampler2D lum;\n#endif\n#ifdef LUT_ENABLED\nuniform sampler2D lut;\n#endif\n#ifdef COLOR_CORRECTION\nuniform float brightness : 0.0;\nuniform float contrast : 1.0;\nuniform float saturation : 1.0;\n#endif\n#ifdef VIGNETTE\nuniform float vignetteDarkness: 1.0;\nuniform float vignetteOffset: 1.0;\n#endif\nuniform float exposure : 1.0;\nuniform float bloomIntensity : 0.25;\nuniform float lensflareIntensity : 1;\nvarying vec2 v_Texcoord;\n@import qtek.util.srgb\nvec3 ACESToneMapping(vec3 color)\n{\n const float A = 2.51;\n const float B = 0.03;\n const float C = 2.43;\n const float D = 0.59;\n const float E = 0.14;\n return (color * (A * color + B)) / (color * (C * color + D) + E);\n}\nfloat eyeAdaption(float fLum)\n{\n return mix(0.2, fLum, 0.5);\n}\n#ifdef LUT_ENABLED\nvec3 lutTransform(vec3 color) {\n float blueColor = color.b * 63.0;\n vec2 quad1;\n quad1.y = floor(floor(blueColor) / 8.0);\n quad1.x = floor(blueColor) - (quad1.y * 8.0);\n vec2 quad2;\n quad2.y = floor(ceil(blueColor) / 8.0);\n quad2.x = ceil(blueColor) - (quad2.y * 8.0);\n vec2 texPos1;\n texPos1.x = (quad1.x * 0.125) + 0.5/512.0 + ((0.125 - 1.0/512.0) * color.r);\n texPos1.y = (quad1.y * 0.125) + 0.5/512.0 + ((0.125 - 1.0/512.0) * color.g);\n vec2 texPos2;\n texPos2.x = (quad2.x * 0.125) + 0.5/512.0 + ((0.125 - 1.0/512.0) * color.r);\n texPos2.y = (quad2.y * 0.125) + 0.5/512.0 + ((0.125 - 1.0/512.0) * color.g);\n vec4 newColor1 = texture2D(lut, texPos1);\n vec4 newColor2 = texture2D(lut, texPos2);\n vec4 newColor = mix(newColor1, newColor2, fract(blueColor));\n return newColor.rgb;\n}\n#endif\n@import qtek.util.rgbm\nvoid main()\n{\n vec4 texel = vec4(0.0);\n vec4 originalTexel = vec4(0.0);\n#ifdef TEXTURE_ENABLED\n texel = decodeHDR(texture2D(texture, v_Texcoord));\n originalTexel = texel;\n#endif\n#ifdef BLOOM_ENABLED\n vec4 bloomTexel = decodeHDR(texture2D(bloom, v_Texcoord));\n texel.rgb += bloomTexel.rgb * bloomIntensity;\n texel.a += bloomTexel.a * bloomIntensity;\n#endif\n#ifdef LENSFLARE_ENABLED\n texel += decodeHDR(texture2D(lensflare, v_Texcoord)) * texture2D(lensdirt, v_Texcoord) * lensflareIntensity;\n#endif\n texel.a = min(texel.a, 1.0);\n#ifdef LUM_ENABLED\n float fLum = texture2D(lum, vec2(0.5, 0.5)).r;\n float adaptedLumDest = 3.0 / (max(0.1, 1.0 + 10.0*eyeAdaption(fLum)));\n float exposureBias = adaptedLumDest * exposure;\n#else\n float exposureBias = exposure;\n#endif\n texel.rgb *= exposureBias;\n texel.rgb = ACESToneMapping(texel.rgb);\n texel = linearTosRGB(texel);\n#ifdef LUT_ENABLED\n texel.rgb = lutTransform(clamp(texel.rgb,vec3(0.0),vec3(1.0)));\n#endif\n#ifdef COLOR_CORRECTION\n texel.rgb = clamp(texel.rgb + vec3(brightness), 0.0, 1.0);\n texel.rgb = clamp((texel.rgb - vec3(0.5))*contrast+vec3(0.5), 0.0, 1.0);\n float lum = dot(texel.rgb, vec3(0.2125, 0.7154, 0.0721));\n texel.rgb = mix(vec3(lum), texel.rgb, saturation);\n#endif\n#ifdef VIGNETTE\n vec2 uv = (v_Texcoord - vec2(0.5)) * vec2(vignetteOffset);\n texel.rgb = mix(texel.rgb, vec3(1.0 - vignetteDarkness), dot(uv, uv));\n#endif\n gl_FragColor = encodeHDR(texel);\n#ifdef DEBUG\n #if DEBUG == 1\n gl_FragColor = encodeHDR(decodeHDR(texture2D(texture, v_Texcoord)));\n #elif DEBUG == 2\n gl_FragColor = encodeHDR(decodeHDR(texture2D(bloom, v_Texcoord)) * bloomIntensity);\n #elif DEBUG == 3\n gl_FragColor = encodeHDR(decodeHDR(texture2D(lensflare, v_Texcoord) * lensflareIntensity));\n #endif\n#endif\n if (originalTexel.a <= 0.01) {\n gl_FragColor.a = dot(gl_FragColor.rgb, vec3(0.2125, 0.7154, 0.0721));\n }\n#ifdef PREMULTIPLY_ALPHA\n gl_FragColor.rgb *= gl_FragColor.a;\n#endif\n}\n@end"},function(e,t,n){"use strict";t.a="@export qtek.compositor.blend\n#ifdef TEXTURE1_ENABLED\nuniform sampler2D texture1;\nuniform float weight1 : 1.0;\n#endif\n#ifdef TEXTURE2_ENABLED\nuniform sampler2D texture2;\nuniform float weight2 : 1.0;\n#endif\n#ifdef TEXTURE3_ENABLED\nuniform sampler2D texture3;\nuniform float weight3 : 1.0;\n#endif\n#ifdef TEXTURE4_ENABLED\nuniform sampler2D texture4;\nuniform float weight4 : 1.0;\n#endif\n#ifdef TEXTURE5_ENABLED\nuniform sampler2D texture5;\nuniform float weight5 : 1.0;\n#endif\n#ifdef TEXTURE6_ENABLED\nuniform sampler2D texture6;\nuniform float weight6 : 1.0;\n#endif\nvarying vec2 v_Texcoord;\n@import qtek.util.rgbm\nvoid main()\n{\n vec4 tex = vec4(0.0);\n#ifdef TEXTURE1_ENABLED\n tex += decodeHDR(texture2D(texture1, v_Texcoord)) * weight1;\n#endif\n#ifdef TEXTURE2_ENABLED\n tex += decodeHDR(texture2D(texture2, v_Texcoord)) * weight2;\n#endif\n#ifdef TEXTURE3_ENABLED\n tex += decodeHDR(texture2D(texture3, v_Texcoord)) * weight3;\n#endif\n#ifdef TEXTURE4_ENABLED\n tex += decodeHDR(texture2D(texture4, v_Texcoord)) * weight4;\n#endif\n#ifdef TEXTURE5_ENABLED\n tex += decodeHDR(texture2D(texture5, v_Texcoord)) * weight5;\n#endif\n#ifdef TEXTURE6_ENABLED\n tex += decodeHDR(texture2D(texture6, v_Texcoord)) * weight6;\n#endif\n gl_FragColor = encodeHDR(tex);\n}\n@end"},function(e,t,n){"use strict";t.a="@export qtek.compositor.fxaa\nuniform sampler2D texture;\nuniform vec4 viewport : VIEWPORT;\nvarying vec2 v_Texcoord;\n#define FXAA_REDUCE_MIN (1.0/128.0)\n#define FXAA_REDUCE_MUL (1.0/8.0)\n#define FXAA_SPAN_MAX 8.0\n@import qtek.util.rgbm\nvoid main()\n{\n vec2 resolution = 1.0 / viewport.zw;\n vec3 rgbNW = decodeHDR( texture2D( texture, ( gl_FragCoord.xy + vec2( -1.0, -1.0 ) ) * resolution ) ).xyz;\n vec3 rgbNE = decodeHDR( texture2D( texture, ( gl_FragCoord.xy + vec2( 1.0, -1.0 ) ) * resolution ) ).xyz;\n vec3 rgbSW = decodeHDR( texture2D( texture, ( gl_FragCoord.xy + vec2( -1.0, 1.0 ) ) * resolution ) ).xyz;\n vec3 rgbSE = decodeHDR( texture2D( texture, ( gl_FragCoord.xy + vec2( 1.0, 1.0 ) ) * resolution ) ).xyz;\n vec4 rgbaM = decodeHDR( texture2D( texture, gl_FragCoord.xy * resolution ) );\n vec3 rgbM = rgbaM.xyz;\n float opacity = rgbaM.w;\n vec3 luma = vec3( 0.299, 0.587, 0.114 );\n float lumaNW = dot( rgbNW, luma );\n float lumaNE = dot( rgbNE, luma );\n float lumaSW = dot( rgbSW, luma );\n float lumaSE = dot( rgbSE, luma );\n float lumaM = dot( rgbM, luma );\n float lumaMin = min( lumaM, min( min( lumaNW, lumaNE ), min( lumaSW, lumaSE ) ) );\n float lumaMax = max( lumaM, max( max( lumaNW, lumaNE) , max( lumaSW, lumaSE ) ) );\n vec2 dir;\n dir.x = -((lumaNW + lumaNE) - (lumaSW + lumaSE));\n dir.y = ((lumaNW + lumaSW) - (lumaNE + lumaSE));\n float dirReduce = max( ( lumaNW + lumaNE + lumaSW + lumaSE ) * ( 0.25 * FXAA_REDUCE_MUL ), FXAA_REDUCE_MIN );\n float rcpDirMin = 1.0 / ( min( abs( dir.x ), abs( dir.y ) ) + dirReduce );\n dir = min( vec2( FXAA_SPAN_MAX, FXAA_SPAN_MAX),\n max( vec2(-FXAA_SPAN_MAX, -FXAA_SPAN_MAX),\n dir * rcpDirMin)) * resolution;\n vec3 rgbA = decodeHDR( texture2D( texture, gl_FragCoord.xy * resolution + dir * ( 1.0 / 3.0 - 0.5 ) ) ).xyz;\n rgbA += decodeHDR( texture2D( texture, gl_FragCoord.xy * resolution + dir * ( 2.0 / 3.0 - 0.5 ) ) ).xyz;\n rgbA *= 0.5;\n vec3 rgbB = decodeHDR( texture2D( texture, gl_FragCoord.xy * resolution + dir * -0.5 ) ).xyz;\n rgbB += decodeHDR( texture2D( texture, gl_FragCoord.xy * resolution + dir * 0.5 ) ).xyz;\n rgbB *= 0.25;\n rgbB += rgbA * 0.5;\n float lumaB = dot( rgbB, luma );\n if ( ( lumaB < lumaMin ) || ( lumaB > lumaMax ) )\n {\n gl_FragColor = vec4( rgbA, opacity );\n }\n else {\n gl_FragColor = vec4( rgbB, opacity );\n }\n}\n@end"},function(e,t,n){"use strict";function a(e,t){var n=new s;return r.a.get({url:e,responseType:t,onload:function(e){n.resolve(e)},onerror:function(e){n.reject(e)}}),n}var i=n(22),r=n(25),o=n(11),s=function(){this._fullfilled=!1,this._rejected=!1};s.prototype.resolve=function(e){this._fullfilled=!0,this._rejected=!1,this.trigger("success",e)},s.prototype.reject=function(e){this._rejected=!0,this._fullfilled=!1,this.trigger("error",e)},s.prototype.isFullfilled=function(){return this._fullfilled},s.prototype.isRejected=function(){return this._rejected},s.prototype.isSettled=function(){return this._fullfilled||this._rejected},o.a.extend(s.prototype,i.a),s.makeRequestTask=function(e,t){if("string"==typeof e)return a(e,t);if(e.url){var n=e;return a(n.url,n.responseType)}if(Array.isArray(e)){var i=e,r=[];return i.forEach(function(e){var t,n;"string"==typeof e?t=e:Object(e)===e&&(t=e.url,n=e.responseType),r.push(a(t,n))}),r}},s.makeTask=function(){return new s},o.a.extend(s.prototype,i.a),t.a=s},function(e,t,n){"use strict";var a=n(14),i=n(2),r=a.a.extend({shadowBias:.001,shadowSlopeScale:2,shadowCascade:1,cascadeSplitLogFactor:.2},{type:"DIRECTIONAL_LIGHT",uniformTemplates:{directionalLightDirection:{type:"3f",value:function(e){return e.__dir=e.__dir||new i.a,e.__dir.copy(e.worldTransform.z).normalize().negate()._array}},directionalLightColor:{type:"3f",value:function(e){var t=e.color,n=e.intensity;return[t[0]*n,t[1]*n,t[2]*n]}}},clone:function(){var e=a.a.prototype.clone.call(this);return e.shadowBias=this.shadowBias,e.shadowSlopeScale=this.shadowSlopeScale,e}});t.a=r},function(e,t,n){"use strict";function a(e){c.a.defaultsWithPropList(e,u,p),i(e);for(var t="",n=0;n=this._maxSize&&o>0){var c=n.head;n.remove(c),delete a[c.key],i=c.value,this._lastRemovedEntry=c}s?s.value=t:s=new r(t),s.key=e,n.insertEntry(s),a[e]=s}return i},s.get=function(e){var t=this._map[e],n=this._list;if(null!=t)return t!==n.tail&&(n.remove(t),n.insertEntry(t)),t.value},s.clear=function(){this._list.clear(),this._map={}},t.a=o},function(e,t,n){"use strict";function a(){document.getElementById("timeline").style.display="block"}function i(){document.getElementById("timeline").style.display="none",c()}function r(e){if(u=e,l=Math.floor(e.getAnimationDuration()),l>0?a():i(),!(l<=0)){var t=document.getElementById("timeline-pause-resume");t.removeEventListener("click",d),t.addEventListener("click",d=function(){f?c():s(n)}),m=0,h=0,o();var n=Math.random();p=n,l>0?s(n):c();var r=null;if(!$("#timeline-progress input").data("ionRangeSlider")){$("#timeline-progress input").ionRangeSlider({from_shadow:!0,force_edges:!0,onChange:function(e){h=e.from,u.setPose(h),null==r&&(r=f),c()},onFinish:function(){r&&s(n),r=null}}),$("#timeline-range input").ionRangeSlider({from_shadow:!0,force_edges:!0,type:"double",drag_interval:!0,grid:!0,grid_num:10,onChange:function(e){l=e.to-e.from,m=e.from,h=Math.min(Math.max(e.from,h),e.to),u.setPose(h),v.update({from_min:e.from,from_max:e.to})}});var v=$("#timeline-progress input").data("ionRangeSlider"),_=$("#timeline-range input").data("ionRangeSlider");v.update({min:0,max:l,from:h,from_min:0,from_max:l}),_.update({min:0,max:l,from:0,to:l})}}}function o(){var e=$("#timeline-progress input").data("ionRangeSlider");e&&e.update({from:h})}function s(e){function t(){if(f&&e===p){u.setPose(h);var a=Math.min(Date.now()-n,20);n=Date.now(),o(),h+=a,h>m+l&&(h=m),requestAnimationFrame(t)}}if(!f){f=!0;var n=Date.now(),a=document.getElementById("timeline-pause-resume");a.classList.remove("icon-resume"),a.classList.add("icon-pause"),requestAnimationFrame(t)}}function c(){if(f){f=!1;var e=document.getElementById("timeline-pause-resume");e.classList.remove("icon-pause"),e.classList.add("icon-resume")}}n.d(t,"b",function(){return r}),n.d(t,"a",function(){return i});var l,u,p,d,f=!1,h=0,m=0},function(e,t,n){"use strict";function a(){["mainLight","secondaryLight","tertiaryLight"].forEach(function(e){j[e].alpha=90*j[e].$padAngle[1],j[e].beta=180*j[e].$padAngle[0]}),S.setMainLight(j.mainLight),S.setSecondaryLight(j.secondaryLight),S.setTertiaryLight(j.tertiaryLight),S.setAmbientLight(j.ambientLight)}function i(){S.setPostEffect(j.postEffect)}function r(){j.ambientCubemapLight.texture=O.a.ENV_TEXTURE_ROOT+j.ambientCubemapLight.$texture+".hdr",j.ambientCubemapLight.diffuseIntensity=j.ambientCubemapLight.specularIntensity=j.ambientCubemapLight.$intensity,S.setAmbientCubemapLight(j.ambientCubemapLight)}function o(){S.setGround(j.ground)}function s(){a(),i(),r(),o()}function c(){var e=Math.max(q.$textureTiling,.01);q.uvRepeat=[e,e],q.transparent=q.alpha<1,S.setMaterial(q.name,q)}function l(e){q.name=e.name;var t=S.getMaterial(e.name);t.$textureTiling=t.uvRepeat[0],k.a.extend(q,t),null==t.specularColor?(N.enable(),C.disable()):(C.enable(),N.disable()),G.update()}function u(e){return e&&"none"!==e}function p(e,t,n){var a=!1;u(n)&&([["diffuseMap","color","#fff"],["metalnessMap","metalness",.5],["roughnessMap","roughness",.5],["glossinessMap","glossiness",.5],["specularMap","specularColor","#fff"],["emissiveMap","emission","#fff"]].forEach(function(t){e===t[0]&&(console.warn("Force %s to be %s after set %s",t[1],t[2],t[0]),q[t[1]]=t[2],a=!0)},this),_(),O.a.AUTO_SAVE&&I.g(t).then(g).catch(g),R[n]=t.name,a&&G.update()),c()}function d(){document.getElementById("tip").style.display="block"}function f(){document.getElementById("tip").style.display="none"}function h(){S=new L.a.Viewer(document.getElementById("viewport"),j),S.enablePicking(),S.setCameraControl(j.viewControl),S.start(),S.on("select",function(e){S.refresh(),l(e.target.material),M=e.target}),S.on("doffocus",function(e){j.postEffect.depthOfField.enable&&(j.postEffect.depthOfField.focalDistance=e.distance,G.update())}),S.on("unselect",function(){S.refresh(),N.disable(),C.disable(),M=null}),S.on("afterrender",function(e,t,n){M&&Object(H.a)(S,[M],n)}),S.on("updatecamera",function(e){j.viewControl={center:e.center,alpha:e.alpha,beta:e.beta,distance:e.distance}})}function m(e){document.body.appendChild(W),W.querySelector("#loading-text").innerHTML=e||"LOADING"}function v(){W.parentNode.removeChild(W)}function _(){V.style.display="block",V.querySelector("#background-progress-text").innerHTML="Saving...DONT close the page."}function x(){V.style.display="block",V.querySelector("#background-progress-text").innerHTML="Preparing for download...DONT close the page."}function g(){V.style.display="none"}function y(){v(),document.getElementById("toolbar").style.display="block",document.getElementById("reset").addEventListener("click",T),document.getElementById("download").addEventListener("click",E),h(),FileAPI.event.dnd(document.getElementById("main"),function(e){},function(e){m("Loading model"),U.a(),I.a(e).then(function(e){var t=e.glTF,n=e.filesMap,a=e.buffers,i=e.allFiles;R={};for(var r in n)R[n[r]]=r;var o=!(!t.extras||!t.extras.qtekModelViewerConfig);o&&(F.merge(j,t.extras.qtekModelViewerConfig,!0),S.setCameraControl(j.viewControl),s(),G.update()),S.loadModel(t,{files:n,buffers:a,textureFlipY:j.textureFlipY,doubleSided:!0,upAxis:j.zUpToYUp?"z":"y",includeTexture:!o}).on("ready",function(){f(),v(),o&&(t.extras.qtekModelViewerConfig.materials||[]).forEach(function(e){for(var t in e)n[e[t]]&&(e[t]=n[e[t]]);S.setMaterial(e.name,e)}),setTimeout(function(){_(),O.a.AUTO_SAVE&&I.e(i).then(g).catch(g)},200)}).on("loadmodel",w).on("error",function(){v(),swal("Model load error")}),N.disable(),C.disable()}).catch(function(e){v(),S.getModelRoot()||d(),Object(U.b)(S),console.log(e),swal(e.toString())})}),b(),X=!0}function b(){function e(e){return R&&R[e]}function t(t){t.addStringOutput(q,"name",{label:"Name"}).addColor(q,"color",{label:"Base Color",onChange:c}).addSlider(q,"alpha","$alphaRange",{label:"Alpha",onChange:c}).addSlider(q,"alphaCutoff","$alphaCutoffRange",{label:"Alpha Cutoff",onChange:c}).addNumberInput(q,"$textureTiling",{label:"Tiling",onChange:c,step:.5}).addCustomComponent(B.a,q,"diffuseMap",{label:"Base Map",onChange:p.bind(null,"diffuseMap"),getFileName:e}).addCustomComponent(B.a,q,"normalMap",{label:"Normal/Bump Map",onChange:p.bind(null,"normalMap"),getFileName:e})}function n(t){t.addCustomComponent(B.a,q,"parallaxOcclusionMap",{label:"Parallax Occlusion Map",onChange:p.bind(null,"parallaxOcclusionMap"),getFileName:e}).addSlider(q,"parallaxOcclusionScale","$parallaxOcclusionScaleRange",{label:"Scale",onChange:c}).addColor(q,"emission",{label:"Emission",onChange:c}).addNumberInput(q,"emissionIntensity",{label:"Emission Intensity",onChange:c}).addCustomComponent(B.a,q,"emissiveMap",{label:"Emissive Map",onChange:p.bind(null,"emissiveMap"),getFileName:e})}A=G.addPanel({label:"Settings",width:250}),A.addGroup({label:"Global"}).addSubGroup({label:"Load Option"}).addCheckbox(j,"textureFlipY",{label:"Flip Texture",onChange:function(){S.setTextureFlipY(j.textureFlipY)}}).addCheckbox(j,"zUpToYUp",{label:"Z Up",onChange:function(){S.setModelUpAxis(j.zUpToYUp?"Z":"Y")}}).addSubGroup({label:"Ground"}).addCheckbox(j.ground,"show",{label:"Show",onChange:o}),A.addGroup({label:"Environment",enable:!1}).addSelect(j.ambientCubemapLight,"$textureOptions",{label:"HDR Texture",onChange:r,target:"$texture"}).addNumberInput(j.ambientCubemapLight,"$intensity",{label:"Intensity",onChange:r,step:.1}),A.addGroup({label:"Light",enable:!1}).addSubGroup({label:"Main",enable:!1}).addCheckbox(j.mainLight,"shadow",{label:"Cast Shadow",onChange:a}).addNumberInput(j.mainLight,"intensity",{label:"Intensity",step:.1,onChange:a}).addColor(j.mainLight,"color",{label:"Color",onChange:a}).addPad(j.mainLight,"$padAngle",{label:"Direction",onChange:a}).addSubGroup({label:"Secondary",enable:!1}).addNumberInput(j.secondaryLight,"intensity",{label:"Intensity",step:.1,onChange:a}).addColor(j.secondaryLight,"color",{label:"Color",onChange:a}).addPad(j.secondaryLight,"$padAngle",{label:"Direction",onChange:a}).addSubGroup({label:"Tertiary",enable:!1}).addNumberInput(j.tertiaryLight,"intensity",{label:"Intensity",step:.1,onChange:a}).addColor(j.tertiaryLight,"color",{label:"Color",onChange:a}).addPad(j.tertiaryLight,"$padAngle",{label:"Direction",onChange:a}).addSubGroup({label:"Ambient",enable:!1}).addNumberInput(j.ambientLight,"intensity",{label:"Intensity",step:.1,onChange:a}).addColor(j.ambientLight,"color",{label:"Color",onChange:a}),A.addGroup({label:"Post Effect",enable:!1}).addCheckbox(j.postEffect,"enable",{label:"Enable",onChange:i}).addSubGroup({label:"Bloom",enable:!1}).addCheckbox(j.postEffect.bloom,"enable",{label:"Enable",onChange:i}).addNumberInput(j.postEffect.bloom,"intensity",{label:"Intensity",step:.1,onChange:i}).addSubGroup({label:"Screen Space Ambient Occulusion",enable:!1}).addCheckbox(j.postEffect.screenSpaceAmbientOcclusion,"enable",{label:"Enable",onChange:i}).addNumberInput(j.postEffect.screenSpaceAmbientOcclusion,"radius",{label:"Radius",step:.1,onChange:i}).addNumberInput(j.postEffect.screenSpaceAmbientOcclusion,"intensity",{label:"Intensity",step:.1,onChange:i}).addSelect(j.postEffect.screenSpaceAmbientOcclusion,"$qualityOptions",{label:"Quality",onChange:i,target:"quality"}).addSubGroup({label:"Screen Space Reflection",enable:!1}).addCheckbox(j.postEffect.screenSpaceReflection,"enable",{label:"Enable",onChange:i}).addNumberInput(j.postEffect.screenSpaceReflection,"maxRoughness",{label:"Max Roughness",step:.01,onChange:i}).addSelect(j.postEffect.screenSpaceReflection,"$qualityOptions",{label:"Quality",onChange:i,target:"quality"}).addSubGroup({label:"Depth of Field",enable:!1}).addCheckbox(j.postEffect.depthOfField,"enable",{label:"Enable",onChange:i}).addNumberInput(j.postEffect.depthOfField,"fstop",{label:"f-stop",step:.1,onChange:i}).addNumberInput(j.postEffect.depthOfField,"focalDistance",{label:"Focal Distance",step:.1,onChange:i}).addNumberInput(j.postEffect.depthOfField,"focalRange",{label:"Focal Range",step:.1,onChange:i}).addNumberInput(j.postEffect.depthOfField,"blurRadius",{label:"Blur Radius",step:.1,onChange:i}).addSelect(j.postEffect.depthOfField,"$qualityOptions",{label:"Quality",onChange:i,target:"quality"}).addSubGroup({label:"Color Correction",enable:!1}).addNumberInput(j.postEffect.colorCorrection,"exposure",{label:"Exposure",step:.1,onChange:i}).addNumberInput(j.postEffect.colorCorrection,"brightness",{label:"Brightness",step:.1,onChange:i}).addNumberInput(j.postEffect.colorCorrection,"contrast",{label:"Contrast",step:.1,onChange:i}).addNumberInput(j.postEffect.colorCorrection,"saturation",{label:"Saturation",step:.1,onChange:i}),N=G.addPanel({label:"Material - Metalllic Roughness",width:240,fixed:!1,align:"left",position:[10,10]}),t(N),N.addCustomComponent(B.a,q,"metalnessMap",{label:"Metalness Map",onChange:p.bind(null,"metalnessMap"),getFileName:e}).addSlider(q,"metalness","$metalnessRange",{label:"Metalness",onChange:c}).addCustomComponent(B.a,q,"roughnessMap",{label:"Roughness Map",onChange:p.bind(null,"roughnessMap"),getFileName:e}).addSlider(q,"roughness","$roughnessRange",{label:"Roughness",onChange:c}),n(N),N.disable(),C=G.addPanel({label:"Material - Specular Glossiness",width:240,fixed:!1,align:"left",position:[10,10]}),t(C),C.addCustomComponent(B.a,q,"specularMap",{label:"Specular Map",onChange:p.bind(null,"specularMap"),getFileName:e}).addColor(q,"specularColor",{label:"Specular Factor",onChange:c}).addCustomComponent(B.a,q,"glossinessMap",{label:"Glossiness Map",onChange:p.bind(null,"glossinessMap"),getFileName:e}).addSlider(q,"glossiness","$glossinessRange",{label:"Glossiness",onChange:c}),n(C),C.disable()}function T(){swal({title:"Reset?",text:"Reset the viewer",type:"warning",showCancelButton:!0,confirmButtonColor:"#3085d6",cancelButtonColor:"#d33",confirmButtonText:"Yes!"}).then(function(){F.merge(j,Object(D.a)(),!0),F.merge(q,Object(P.a)(),!0),G.update(),N.disable(),C.disable(),M=null,S.dispose(),h(),I.d(),d(),U.b(S),g()}).catch(function(){})}function E(){swal({title:"Select download format.",input:"radio",inputOptions:{glb:"GLB",zip:"ZIP"}}).then(function(e){x(),I.b(e,g,g)})}function w(){M=null,S.stopAnimation(),U.b(S)}Object.defineProperty(t,"__esModule",{value:!0});var S,A,N,C,M,R,L=n(66),D=n(140),P=n(141),I=n(142),O=n(37),k=n(11),F=n(150),B=(n.n(F),n(151)),U=n(64),H=n(152),z=n(154),j=Object(D.a)(),q=Object(P.a)(),G=new ControlKit({loadAndSave:!0,useExternalStyle:!0}),W=document.getElementById("loading"),V=document.getElementById("background-progress"),X=!1;I.c(function(e,t,n){if(n&&F.merge(j,n,!0),!X)if(y(),e){R={};for(var a in t)R[t[a]]=a;S.loadModel(e,{files:t,textureFlipY:j.textureFlipY,upAxis:j.zUpToYUp?"z":"y",doubleSided:!0,includeTexture:!1}).on("ready",function(){n&&n.materials&&n.materials.forEach(function(e){for(var n in e)t[e[n]]&&(e[n]=t[e[n]]);S.setMaterial(e.name,e)})}).on("loadmodel",w).on("error",function(){d(),swal("Model load error")})}else d()}),setTimeout(function(){X||(console.warn("Init time out"),y())},5e3),setInterval(function(){if(S&&!document.hidden){var e={};j.materials=S.getMaterialsNames().map(function(t){var n=S.getMaterial(t);for(var a in n)R[n[a]]&&(n[a]=R[n[a]]);return n.targetMeshes=[],e[t]=n,n}),S.getModelRoot()&&S.getModelRoot().traverse(function(t){t.material&&e[t.material.name]&&e[t.material.name].targetMeshes.push(t.originalMeshName||t.name)}),_(),O.a.AUTO_SAVE&&I.f(j).then(function(){g(),console.log("Saved")}).catch(g)}},5e3),window.addEventListener("resize",function(){S.resize()}),window.addEventListener("dragover",function(e){e.preventDefault()}),window.addEventListener("drop",function(e){e.preventDefault()}),$(document).on("click",'a[href^="http"]',function(e){e.preventDefault(),Object(z.a)(this.href)})},function(e,t,n){"use strict";var a=n(67);t.a={Viewer:a.a,version:"0.1.0"}},function(e,t,n){"use strict";function a(e,t){t=S.a(t),S.b(t,w.a),this.init(e,t)}var i=n(30),r=n(40),o=n(2),s=n(89),c=n(91),l=n(59),u=n(92),p=n(11),d=n(15),f=n(16),h=n(9),m=n(32),v=n(4),_=n(93),x=n(22),g=n(18),y=n(33),b=n(97),T=n(29),E=n(130),w=n(132),S=n(133),A=n(134),N=n(135),C=n(137),M=n(139);v.a.import(M.a);var R=["diffuseMap","normalMap","emissiveMap","metalnessMap","roughnessMap","specularMap","glossinessMap"];a.prototype.init=function(e,t){t=t||{},this.root=e,this._animation=new s.a;var n=new i.a({devicePixelRatio:t.devicePixelRatio||window.devicePixelRatio});e.appendChild(n.canvas),n.canvas.style.cssText="position:absolute;left:0;top:0",this._renderer=n,this._renderMain=new b.a(n,t.shadow,"perspective"),this._renderMain.afterRenderScene=function(e,t,n){this.trigger("renderscene",e,t,n)}.bind(this),this._renderMain.afterRenderAll=function(e,t,n){this.trigger("afterrender",e,t,n)}.bind(this),this._renderMain.preZ=t.preZ||!1;var a=this._cameraControl=new N.a({renderer:n,animation:this._animation,domElement:e});a.target=this._renderMain.camera,a.init(),this._hotspotManager=new C.a({dom:e,renderer:n,camera:this._renderMain.camera}),this._skeletons=[],this._clips=[],this._takes=[],this._materialsMap={},this._sceneHelper=new E.a(this._renderMain.scene),this._sceneHelper.initLight(this._renderMain.scene),this.resize(),t.postEffect&&this.setPostEffect(t.postEffect),t.mainLight&&this.setMainLight(t.mainLight),t.secondaryLight&&this.setSecondaryLight(t.secondaryLight),t.tertiaryLight&&this.setTertiaryLight(t.tertiaryLight),t.ambientCubemapLight&&this.setAmbientCubemapLight(t.ambientCubemapLight),t.ambientLight&&this.setAmbientLight(t.ambientLight),t.environment&&this.setEnvironment(t.environment),this._createGround(),t.ground&&this.setGround(t.ground),this.setCameraControl({distance:20,minDisntance:2,maxDistance:100,center:[0,0,0]}),this._enablePicking=t.picking||!1,this._initHandlers(),a.on("update",function(){this.trigger("updatecamera",{center:a.getCenter(),alpha:a.getAlpha(),beta:a.getBeta(),distance:a.getDistance()}),this.refresh()},this),this.shaderLibrary=g.a.createLibrary()},a.prototype._createGround=function(){var e=new f.a({isGround:!0,material:new h.a({shader:new v.a({vertex:v.a.source("qmv.ground.vertex"),fragment:v.a.source("qmv.ground.fragment")}),transparent:!0}),castShadow:!1,geometry:new m.a});e.material.set("color",[1,1,1,1]),e.scale.set(40,40,1),e.rotation.rotateX(-Math.PI/2),this._groundMesh=e,this._renderMain.scene.add(e)},a.prototype._addModel=function(e,t,n,a){this.removeModel(),this._renderMain.scene.add(e),this._skeletons=n.slice(),this._modelNode=e,this._setAnimationClips(a),t&&t.length&&(this._nodes=t);var i={};e.traverse(function(e){if(e.material){var t=e.material;i[t.name]=i[t.name]||[],i[t.name].push(t)}},this),this._materialsMap=i,this._updateMaterialsSRGB(),this._stopAccumulating()},a.prototype._removeAnimationClips=function(){this._clips.forEach(function(e){this._animation.removeClip(e)},this),this._clips=[],this._takes=[]},a.prototype._setAnimationClips=function(e){function t(){n.refresh()}var n=this;e.forEach(function(e){e.tracks.forEach(function(e){e.target||(e.target=this._nodes[e.targetNodeIndex])},this),e.onframe=t,this._animation.addClip(e),this._takes.push({name:e.name,range:[0,e.life],clip:e})},this),this._clips=e.slice()},a.prototype._initHandlers=function(){this._picking=new _.a({renderer:this._renderer,scene:this._renderMain.scene,camera:this._renderMain.camera}),this._clickHandler=this._clickHandler.bind(this),this._mouseDownHandler=this._mouseDownHandler.bind(this),this.root.addEventListener("mousedown",this._mouseDownHandler),this.root.addEventListener("click",this._clickHandler)},a.prototype._mouseDownHandler=function(e){this._startX=e.clientX,this._startY=e.clientY},a.prototype._clickHandler=function(e){if(this._enablePicking||this._renderMain.isDOFEnabled()){var t=e.clientX-this._startX,n=e.clientY-this._startY;if(!(Math.sqrt(t*t+n*n)>=40)){var a=this._picking.pick(e.clientX,e.clientY,!0);a&&!a.target.isGround?(this._renderMain.setDOFFocusOnPoint(a.distance),this.trigger("doffocus",a),this._selectResult=a,this.trigger("select",a),this.refresh()):(this._selectResult&&this.trigger("unselect",this._selectResult),this._selectResult=null)}}},a.prototype.enablePicking=function(){this._enablePicking=!0},a.prototype.disablePicking=function(){this._enablePicking=!1},a.prototype.setModelUpAxis=function(e){var t=this._modelNode;t&&(t.position.set(0,0,0),t.scale.set(1,1,1),t.rotation.identity(),"z"===e.toLowerCase()&&t.rotation.identity().rotateX(-Math.PI/2),this.autoFitModel())},a.prototype.setTextureFlipY=function(e){if(this._modelNode){for(var t in this._materialsMap)for(var n=0;n1||o<0){n=!0;break}}if(n)for(var a=0;a=0&&s.splice(a,1),c[e]=null}}t=t||{};var i=this._materialsMap[e],r=this,o=this._textureFlipY;if(!i||!i.length)return void console.warn("Material %s not exits",e);var s=i[0].shader.getEnabledTextures(),c={};["diffuseMap","normalMap","parallaxOcclusionMap","emissiveMap"].forEach(function(e){a(e)},this),i[0].shader.isDefined("fragment","USE_METALNESS")?["metalnessMap","roughnessMap"].forEach(function(e){a(e)},this):["specularMap","glossinessMap"].forEach(function(e){a(e)},this),(c.normalMap||c.parallaxOcclusionMap)&&this._modelNode.traverse(function(t){t.material&&t.material.name===e&&(t.geometry.attributes.tangent.value||t.geometry.generateTangents())}),i.forEach(function(e){null!=t.transparent&&(e.transparent=!!t.transparent,e.depthMask=!t.transparent),["color","emission","specularColor"].forEach(function(n){null!=t[n]&&e.set(n,T.a.parseColor(t[n]))}),["alpha","alphaCutoff","metalness","roughness","glossiness","emissionIntensity","uvRepeat","parallaxOcclusionScale"].forEach(function(n){null!=t[n]&&e.set(n,t[n])});for(var n in c)e.set(n,c[n]);e.attachShader(this.shaderLibrary.get("qtek."+(this._shaderName||"standard"),{fragmentDefines:e.shader.fragmentDefines,textures:s,vertexDefines:e.shader.vertexDefines,precision:e.shader.precision}),!0)},this),this.refresh()},a.prototype.getMaterial=function(e){function t(e){var t=a.get(e);if(!t)return"";for(var n=t.image;n.srcImage;)n=n.srcImage;return n&&n.src||""}var n=this._materialsMap[e];if(!n)return void console.warn("Material %s not exits",e);var a=n[0],i={name:e};return["color","emission"].forEach(function(e){i[e]=T.a.stringifyColor(a.get(e),"hex")}),["alpha","alphaCutoff","emissionIntensity","uvRepeat","parallaxOcclusionScale"].forEach(function(e){i[e]=a.get(e)}),["diffuseMap","normalMap","parallaxOcclusionMap","emissiveMap"].forEach(function(e){i[e]=t(e)}),a.shader.isDefined("fragment","USE_METALNESS")?(["metalness","roughness"].forEach(function(e){i[e]=a.get(e)}),["metalnessMap","roughnessMap"].forEach(function(e){i[e]=t(e)}),i.type="pbrMetallicRoughness"):(i.specularColor=T.a.stringifyColor(a.get("specularColor"),"hex"),i.glossiness=a.get("glossiness"),["specularMap","glossinessMap"].forEach(function(e){i[e]=t(e)}),i.type="pbrSpecularGlossiness"),i},a.prototype.setGround=function(e){this._groundMesh.invisible=!e.show,this.refresh()},a.prototype.getMaterialsNames=function(){return Object.keys(this._materialsMap)},a.prototype.setPostEffect=function(e){this._renderMain.setPostEffect(e),this._updateMaterialsSRGB(),this.refresh()},a.prototype.start=function(){if(this._disposed)return void console.warn("Viewer already disposed");this._animation.start(),this._animation.on("frame",this._loop,this)},a.prototype.stop=function(){this._animation.stop(),this._animation.off("frame",this._loop)},a.prototype.addHotspot=function(e,t){return this._hotspotManager.add(e,t)},a.prototype.setPose=function(e){this._clips.forEach(function(t){t.setTime(e)}),this._skeletons.forEach(function(e){e.update()}),this.refresh()},a.prototype.getAnimationDuration=function(){var e=0;return this._clips.forEach(function(t){e=Math.max(t.life,e)}),e},a.prototype.refresh=function(){this._needsRefresh=!0},a.prototype.getRenderer=function(){return this._renderer},a.prototype._updateMaterialsSRGB=function(){var e=this._renderMain.isLinearSpace();for(var t in this._materialsMap)for(var n=this._materialsMap[t],a=0;a0&&this._clips.splice(t,1)},removeClipsAll:function(){this._clips=[]},getClip:function(e){if(this._clips[e])return this._clips[e].clip},getClipNumber:function(){return this._clips.length},updateJointMatrices:function(){var e=l.create();return function(){this._invBindPoseMatricesArray=new Float32Array(16*this.joints.length),this._skinMatricesArray=new Float32Array(16*this.joints.length);for(var t=0;tthis.distance,i=1;i<8;i++)if(o.dot(t[i]._array,n)>this.distance!=a)return!0},intersectLine:function(){var e=o.create();return function(t,n,i){var r=this.distanceToPoint(t),s=this.distanceToPoint(n);if(r>0&&s>0||r<0&&s<0)return null;var c=this.normal._array,l=this.distance,u=t._array;o.sub(e,n._array,t._array),o.normalize(e,e);var p=o.dot(c,e);if(0===p)return null;i||(i=new a.a);var d=(o.dot(c,u)-l)/p;return o.scaleAndAdd(i._array,u,e,-d),i._dirty=!0,i}}(),applyTransform:function(){var e=s.create(),t=c.create(),n=c.create();return n[3]=1,function(a){a=a._array,o.scale(n,this.normal._array,this.distance),c.transformMat4(n,n,a),this.distance=o.dot(n,this.normal._array),s.invert(e,a),s.transpose(e,e),t[3]=0,o.copy(t,this.normal._array),c.transformMat4(t,t,e),o.copy(this.normal._array,t)}}(),copy:function(e){o.copy(this.normal._array,e.normal._array),this.normal._dirty=!0,this.distance=e.distance},clone:function(){var e=new l;return e.copy(this),e}},t.a=l},function(e,t,n){"use strict";var a=n(31),i=n(0),r=n.n(i),o=r.a.quat,s=r.a.vec3,c=function(e){e=e||{},a.a.call(this,e),this.tracks=e.tracks||[]};c.prototype=Object.create(a.a.prototype),c.prototype.constructor=c,c.prototype.step=function(e,t,n){var i=a.a.prototype.step.call(this,e,t,!0);if("finish"!==i){var e=this.getElapsedTime();this._range&&(e=this._range[0]+e),this.setTime(e)}return n||"paused"===i||this.fire("frame"),i},c.prototype.setRange=function(e){this.calcLifeFromTracks(),this._range=e,e&&(e[1]=Math.min(e[1],this.life),e[0]=Math.min(e[0],this.life),this.life=e[1]-e[0])},c.prototype.setTime=function(e){for(var t=0;t=0&&this.tracks.splice(t,1)},c.prototype.getSubClip=function(e,t,n){for(var a=new c({name:this.name}),i=0;i1e-6?(o=Math.acos(s),c=Math.sin(o),l=Math.sin((1-a)*o)/c,u=Math.sin(a*o)/c):(l=1-a,u=a),e[0]=l*p+u*m,e[1]=l*d+u*v,e[2]=l*f+u*_,e[3]=l*h+u*x,e}var r=n(77),o=n(0),s=n.n(o),c=s.a.quat,l=s.a.vec3,u=function(e){e=e||{},this.name=e.name||"",this.target=e.target||null,this.position=l.create(),this.rotation=c.create(),this.scale=l.fromValues(1,1,1),this.channels={time:null,position:null,rotation:null,scale:null},this._cacheKey=0,this._cacheTime=0};u.prototype.setTime=function(e){if(this.channels.time){var t=this.channels,n=t.time.length,r=-1;if(1===n)return t.rotation&&c.copy(this.rotation,t.rotation),t.position&&l.copy(this.position,t.position),void(t.scale&&l.copy(this.scale,t.scale));if(e<=t.time[0])e=t.time[0],r=0;else if(e>=t.time[n-1])e=t.time[n-1],r=n-2;else if(e=0;s--)if(t.time[s-1]<=e&&t.time[s]>e){r=s-1;break}}else for(var s=this._cacheKey;se){r=s;break}if(r>-1){this._cacheKey=r,this._cacheTime=e;var u=r,p=r+1,d=t.time[u],f=t.time[p],h=f-d,m=0===h?0:(e-d)/h;t.rotation&&i(this.rotation,t.rotation,t.rotation,m,4*u,4*p),t.position&&a(this.position,t.position,t.position,m,3*u,3*p),t.scale&&a(this.scale,t.scale,t.scale,m,3*u,3*p)}r==n-2&&(this._cacheKey=0,this._cacheTime=0),this.updateTarget()}},u.prototype.updateTarget=function(){var e=this.channels;this.target&&(e.position&&this.target.position.setArray(this.position),e.rotation&&this.target.rotation.setArray(this.rotation),e.scale&&this.target.scale.setArray(this.scale))},u.prototype.getMaxTime=function(){return this.channels.time[this.channels.time.length-1]},u.prototype.getSubTrack=function(e,t){var n=new u({name:this.name}),a=this.channels.time[0];e=Math.min(Math.max(e,a),this.life),t=Math.min(Math.max(t,a),this.life);var i=this._findRange(e),r=this._findRange(t),o=r[0]-i[0]+1;0===i[1]&&0===r[1]&&(o-=1),this.channels.rotation&&(n.channels.rotation=new Float32Array(4*o)),this.channels.position&&(n.channels.position=new Float32Array(3*o)),this.channels.scale&&(n.channels.scale=new Float32Array(3*o)),this.channels.time&&(n.channels.time=new Float32Array(o)),this.setTime(e);for(var s=0;s<3;s++)n.channels.rotation[s]=this.rotation[s],n.channels.position[s]=this.position[s],n.channels.scale[s]=this.scale[s];n.channels.time[0]=0,n.channels.rotation[3]=this.rotation[3];for(var s=1;se&&(a=i);var r=0;if(a>=0)var o=t.time[a],s=t.time[a+1],r=(e-o)/(s-o);return[a,r]},u.prototype.blend1D=r.a.prototype.blend1D,u.prototype.blend2D=r.a.prototype.blend2D,u.prototype.additiveBlend=r.a.prototype.additiveBlend,u.prototype.subtractiveBlend=r.a.prototype.subtractiveBlend,u.prototype.clone=function(){var e=u.prototype.clone.call(this);return e.channels={time:this.channels.time||null,position:this.channels.position||null,rotation:this.channels.rotation||null,scale:this.channels.scale||null},l.copy(e.position,this.position),c.copy(e.rotation,this.rotation),l.copy(e.scale,this.scale),e.target=this.target,e.updateTarget(),e},t.a=u},function(e,t,n){"use strict";function a(e,t){return e.time-t.time}var i=n(31),r=n(0),o=n.n(r),s=o.a.quat,c=o.a.vec3,l=function(e){this.name=e.name||"",this.keyFrames=[],e.keyFrames&&this.addKeyFrames(e.keyFrames),this.position=c.create(),this.rotation=s.create(),this.scale=c.fromValues(1,1,1),this._cacheKey=0,this._cacheTime=0};l.prototype=Object.create(i.a.prototype),l.prototype.constructor=l,l.prototype.step=function(e,t,n){var a=i.a.prototype.step.call(this,e,t,!0);return"finish"!==a&&this.setTime(this.getElapsedTime()),n||"paused"===a||this.fire("frame"),a},l.prototype.setTime=function(e){this._interpolateField(e,"position"),this._interpolateField(e,"rotation"),this._interpolateField(e,"scale")},l.prototype.getMaxTime=function(){var e=this.keyFrames[this.keyFrames.length-1];return e?e.time:0},l.prototype.addKeyFrame=function(e){for(var t=0;t=e.time)return this.keyFrames.splice(t,0,e),t}this.life=e.time,this.keyFrames.push(e)},l.prototype.addKeyFrames=function(e){for(var t=0;ti[i.length-1].time)){if(e=r-1?r-1:this._cacheKey+1,l=o;l>=0;l--)if(i[l].time<=e&&i[l][t])n=i[l],this._cacheKey=l,this._cacheTime=e;else if(i[l][t]){a=i[l];break}}else for(var l=this._cacheKey;l=0&&this._clips.splice(t,1)},removeAnimator:function(e){for(var t=e.getClips(),n=0;ni)e.length=i;else for(var r=a;r=0&&!(T[A]<=t);A--);A=Math.min(A,_-2)}else{for(A=O;A<_&&!(T[A]>t);A++);A=Math.min(A-1,_-2)}O=A,k=t;var n=T[A+1]-T[A];0!==n&&(R=(t-T[A])/n,v?(D=E[A],L=E[0===A?A:A-1],P=E[A>_-2?_-1:A+1],I=E[A>_-3?_-1:A+2],c?h(e,i,c(f(e,i),L,D,P,I,R)):g?l(L,D,P,I,R,R*R,R*R*R,f(e,i),y):h(e,i,u(L,D,P,I,R,R*R,R*R*R))):c?h(e,i,c(f(e,i),E[A],E[A+1],R)):g?o(E[A],E[A+1],R,f(e,i),y):h(e,i,r(E[A],E[A+1],R)))},B=new m.a({target:e._target,life:b,loop:e._loop,delay:e._delay,onframe:F,onfinish:n});return t&&"spline"!==t&&B.setEasing(t),B}}}function h(e,t,n,r,o){this._tracks={},this._target=e,this._loop=t||!1,this._getter=n||a,this._setter=r||i,this._interpolater=o||null,this._delay=0,this._doneList=[],this._onframeList=[],this._clipList=[]}var m=n(31),v=Array.prototype.slice;h.prototype={constructor:h,when:function(e,t){for(var n in t)this._tracks[n]||(this._tracks[n]=[],0!==e&&this._tracks[n].push({time:0,value:c(this._getter(this._target,n))})),this._tracks[n].push({time:parseInt(e),value:t[n]});return this},during:function(e){return this._onframeList.push(e),this},_doneCallback:function(){this._tracks={},this._clipList.length=0;for(var e=this._doneList,t=e.length,n=0;n=65535?new Uint32Array(3*_):new Uint16Array(3*_);for(var b=0,T=0,E=r.isUseIndices(),w=0;w0;){for(var w=[],S=[],A=[],N=0,y=0;y=0&&-1===S[P]&&(N65535?new Uint32Array(3*B.triangles.length):new Uint16Array(3*B.triangles.length);var J=0;V=0;for(var y=0;y=0?U[P]:-1}V++}G.indices[J++]=k[L]}G.updateBoundingBox(),I.add(W)}for(var ae=e.children(),y=0;y=0&&S[E]>1e-4&&(d.transformMat4(C,w,b[A[E]]),d.scaleAndAdd(N,N,C,S[E]));M.set(T,N)}}for(var T=0;T<_.length;T+=3){var R=_[T],L=_[T+1],D=_[T+2],P=u?p.attributes.skinnedPosition:x;if(P.get(R,e._array),P.get(L,t._array),P.get(D,n._array),h=v?a.intersectTriangle(e,t,n,i.culling):a.intersectTriangle(e,n,t,i.culling)){var I=new o.a;u?o.a.copy(I,h):o.a.transformMat4(I,h,i.worldTransform),c.push(new f.Intersection(h,I,i,[R,L,D],T/3,o.a.dist(I,this._ray.origin)))}}}}}}(),_intersectionCompareFunc:function(e,t){return e.distance-t.distance}});f.Intersection=function(e,t,n,a,i,r){this.point=e,this.pointWorld=t,this.target=n,this.triangle=a,this.triangleIndex=i,this.distance=r},t.a=f},function(e,t,n){"use strict";var a=n(20),i=n(7),r=a.a.extend({dynamic:!1,widthSegments:20,heightSegments:20,phiStart:0,phiLength:2*Math.PI,thetaStart:0,thetaLength:Math.PI,radius:1},function(){this.build()},{build:function(){var e=this.heightSegments,t=this.widthSegments,n=this.attributes.position,a=this.attributes.texcoord0,r=this.attributes.normal,o=(t+1)*(e+1);n.init(o),a.init(o),r.init(o);var s,c,l,u,p,d,f,h=o>65535?Uint32Array:Uint16Array,m=this.indices=new h(t*e*6),v=this.radius,_=this.phiStart,x=this.phiLength,g=this.thetaStart,y=this.thetaLength,v=this.radius,b=[],T=[],E=0,w=1/v;for(f=0;f<=e;f++)for(d=0;d<=t;d++)u=d/t,p=f/e,s=-v*Math.cos(_+u*x)*Math.sin(g+p*y),c=v*Math.cos(g+p*y),l=v*Math.sin(_+u*x)*Math.sin(g+p*y),b[0]=s,b[1]=c,b[2]=l,T[0]=u,T[1]=p,n.set(E,b),a.set(E,T),b[0]*=w,b[1]*=w,b[2]*=w,r.set(E,b),E++;var S,A,N,C,M=t+1,R=0;for(f=0;f0){var i=Math.pow(2,e[3]-128-8+a);t[n+0]=e[0]*i,t[n+1]=e[1]*i,t[n+2]=e[2]*i}else t[n+0]=0,t[n+1]=0,t[n+2]=0;return t[n+3]=1,t}function i(e,t,n){for(var a="",i=t;i0;)if(e[o][0]=t[n++],e[o][1]=t[n++],e[o][2]=t[n++],e[o][3]=t[n++],1===e[o][0]&&1===e[o][1]&&1===e[o][2]){for(var c=e[o][3]<>>0;c>0;c--)r(e[o-1],e[o]),o++,s--;i+=8}else o++,s--,i=0;return n}function s(e,t,n,a){if(ad)return o(e,t,n,a);var i=t[n++];if(2!=i)return o(e,t,n-1,a);if(e[0][1]=t[n++],e[0][2]=t[n++],i=t[n++],(e[0][2]<<8>>>0|i)>>>0!==a)return null;for(var i=0;i<4;i++)for(var r=0;r128){s=(127&s)>>>0;for(var c=t[n++];s--;)e[r++][i]=c}else for(;s--;)e[r++][i]=t[n++]}return n}var c=n(3),l=n(5),u=String.fromCharCode,p=8,d=32767,f={parseRGBE:function(e,t,n){null==n&&(n=0);var r=new Uint8Array(e),o=r.length;if("#?"===i(r,0,2)){for(var p=2;p=o)){p+=2;for(var d="";p=n.x&&t>=n.y&&e<=n.x+n.width&&t<=n.y+n.height};var d=new c.a;a.prototype.castRay=function(e,t,n){var a=this.layer.renderer,i=a.viewport;return a.viewport=this.viewport,a.screenToNDC(e,t,d),this.camera.castRay(d,n),a.viewport=i,n},a.prototype.prepareRender=function(){this.scene.update(),this.camera.update(),this._frame=0,this._temporalSS.resetFrame()},a.prototype.render=function(e){this._doRender(e,this._frame),this._frame++},a.prototype.needsAccumulate=function(){return this.needsTemporalSS()||this._needsSortProgressively},a.prototype.needsTemporalSS=function(){var e=this._enableTemporalSS;return"auto"==e&&(e=this._enablePostEffect),e},a.prototype.hasDOF=function(){return this._enableDOF},a.prototype.isAccumulateFinished=function(){return this.needsTemporalSS()?this._temporalSS.isFinished():this._frame>30},a.prototype._doRender=function(e,t){var n=this.scene,a=this.camera,i=this.renderer;if(t=t||0,!e&&this._shadowMapPass&&(this._shadowMapPass.kernelPCF=this._pcfKernels[0],this._shadowMapPass.render(i,n,a,!0)),this._updateShadowPCFKernel(t),i.gl.clearColor(0,0,0,0),this._enablePostEffect&&(this.needsTemporalSS()&&this._temporalSS.jitterProjection(i,a),this._compositor.updateNormal(i,n,a,this._temporalSS.getFrame())),this._updateSSAO(i,n,a,this._temporalSS.getFrame()),this._enablePostEffect){var r=this._compositor.getSourceFrameBuffer();r.bind(i),i.gl.clear(i.gl.DEPTH_BUFFER_BIT|i.gl.COLOR_BUFFER_BIT),i.render(n,a,!0,this.preZ),this.afterRenderScene(i,n,a),r.unbind(i),this.needsTemporalSS()&&e?(this._compositor.composite(i,a,this._temporalSS.getSourceFrameBuffer(),this._temporalSS.getFrame()),i.setViewport(this.viewport),this._temporalSS.render(i)):(i.setViewport(this.viewport),this._compositor.composite(i,a,null,0))}else if(this.needsTemporalSS()&&e){var r=this._temporalSS.getSourceFrameBuffer();r.bind(i),i.saveClear(),i.clearBit=i.gl.DEPTH_BUFFER_BIT|i.gl.COLOR_BUFFER_BIT,i.render(n,a,!0,this.preZ),this.afterRenderScene(i,n,a),i.restoreClear(),r.unbind(i),i.setViewport(this.viewport),this._temporalSS.render(i)}else i.setViewport(this.viewport),i.render(n,a,!0,this.preZ),this.afterRenderScene(i,n,a);this.afterRenderAll(i,n,a)},a.prototype.afterRenderScene=function(e,t,n){},a.prototype.afterRenderAll=function(e,t,n){},a.prototype._updateSSAO=function(e,t,n,a){function i(e){for(var t=0;tthis.camera.far||e0&&(d.define("vertex","SKINNING"),d.define("vertex","JOINT_COUNT",l)),s&&d.define("both","SHADOW_TRANSPARENT"),o.useSkinMatricesTexture&&d.define("vertex","USE_SKIN_MATRICES_TEXTURE"),this._depthShaders[r]=d),p||(p=new h.a({shader:d}),this._depthMaterials[i]=p),o.material=p,this.softShadow===C.VSM?d.define("fragment","USE_VSM"):d.undefine("fragment","USE_VSM"),p.setUniform("bias",t),p.setUniform("slopeScale",n),s&&p.set("shadowTransparentMap",c))}},_bindDistanceMaterial:function(e,t){for(var n=t.getWorldPosition()._array,a=0;a0&&(o.shader.define("vertex","SKINNING"),o.shader.define("vertex","JOINT_COUNT",r)),this._distanceMaterials[r]=o),i.material=o,this.softShadow===C.VSM?o.shader.define("fragment","USE_VSM"):o.shader.undefine("fragment","USE_VSM")),o.set("lightPosition",n),o.set("range",t.range)}},saveMaterial:function(e){for(var t=0;t1&&(v=x,x.shadowCascade>4)){console.warn("Support at most 4 cascade");continue}this.renderDirectionalLightShadow(e,t,n,x,this._opaqueCasters,h,u,l)}else x instanceof p.a?this.renderSpotLightShadow(e,x,this._opaqueCasters,c,s):x instanceof f.a&&this.renderPointLightShadow(e,x,this._opaqueCasters,m);this._shadowMapNumber[x.type]++}this.restoreMaterial(this._opaqueCasters);var g=h.slice(),y=h.slice();g.pop(),y.shift(),g.reverse(),y.reverse(),u.reverse();for(var b=s.map(i),T=l.map(i),E={},_=0;_0?(A.fragmentDefines[R]=M,N=!0):A.isDefined("fragment",R)&&(A.undefine("fragment",R),N=!0))}N&&A.dirty(),v?A.define("fragment","SHADOW_CASCADE",v.shadowCascade):A.undefine("fragment","SHADOW_CASCADE"),E[A.__GUID__]=!0}s.length>0&&(S.setUniform("spotLightShadowMaps",s),S.setUniform("spotLightMatrices",c),S.setUniform("spotLightShadowMapSizes",b)),l.length>0&&(S.setUniform("directionalLightShadowMaps",l),v&&(S.setUniform("shadowCascadeClipsNear",g),S.setUniform("shadowCascadeClipsFar",y)),S.setUniform("directionalLightMatrices",u),S.setUniform("directionalLightShadowMapSizes",T)),m.length>0&&S.setUniform("pointLightShadowMaps",m)}}},renderDirectionalLightShadow:function(){var e=new s.a,t=new c.a,n=new o.a,a=new c.a,i=new c.a,r=new c.a,u=new c.a;return function(o,s,p,d,f,h,m,v){var _=d.shadowBias;if(this._bindDepthMaterial(f,_,d.shadowSlopeScale),f.sort(l.a.opaqueSortFunc),!s.viewBoundingBoxLastFrame.isFinite()){var x=s.getBoundingBox();s.viewBoundingBoxLastFrame.copy(x).applyTransform(p.viewMatrix)}var y=Math.min(-s.viewBoundingBoxLastFrame.min.z,p.far),b=Math.max(-s.viewBoundingBoxLastFrame.max.z,p.near),T=this._getDirectionalLightCamera(d,s,p),E=r._array;u.copy(T.projectionMatrix),A.invert(i._array,T.worldTransform._array),A.multiply(i._array,i._array,p.worldTransform._array),A.multiply(E,u._array,i._array);for(var w=[],S=p instanceof g.a,N=(p.near+p.far)/(p.near-p.far),M=2*p.near*p.far/(p.near-p.far),R=0;R<=d.shadowCascade;R++){var L=b*Math.pow(y/b,R/d.shadowCascade),D=b+(y-b)*R/d.shadowCascade,P=L*d.cascadeSplitLogFactor+D*(1-d.cascadeSplitLogFactor);w.push(P),h.push(-(-P*N+M)/-P)}var I=this._getTexture(d,d.shadowCascade);v.push(I);var O=o.viewport,k=o.gl;this._frameBuffer.attach(I),this._frameBuffer.bind(o),k.clear(k.COLOR_BUFFER_BIT|k.DEPTH_BUFFER_BIT);for(var R=0;R=0||(this.nodes.push(e),this._dirty=!0)},removeNode:function(e){"string"==typeof e&&(e=this.getNodeByName(e));var t=this.nodes.indexOf(e);t>=0&&(this.nodes.splice(t,1),this._dirty=!0)},getNodeByName:function(e){for(var t=0;t=t.COLOR_ATTACHMENT0&&l<=t.COLOR_ATTACHMENT0+8&&p.push(l);u.drawBuffersEXT(p)}e.saveClear(),e.clearBit=i.a.DEPTH_BUFFER_BIT|i.a.COLOR_BUFFER_BIT,n=e.render(this.scene,this.camera,!this.autoUpdateScene,this.preZ),e.restoreClear(),a.unbind(e)}else n=e.render(this.scene,this.camera,!this.autoUpdateScene,this.preZ);this.trigger("afterrender",n),this._rendering=!1,this._rendered=!0}});t.a=o},function(e,t,n){"use strict";var a=n(21),i=a.a.extend(function(){return{texture:null,outputs:{color:{}}}},function(){},{getOutput:function(e,t){return this.texture},beforeFrame:function(){},afterFrame:function(){}});t.a=i},function(e,t,n){"use strict";var a=n(12),i=n(21),r=i.a.extend(function(){return{name:"",inputs:{},outputs:null,shader:"",inputLinks:{},outputLinks:{},pass:null,_prevOutputTextures:{},_outputTextures:{},_outputReferences:{},_rendering:!1,_rendered:!1,_compositor:null}},function(){var e=new a.a({fragment:this.shader});this.pass=e},{render:function(e,t){this.trigger("beforerender",e),this._rendering=!0;var n=e.gl;for(var a in this.inputLinks){var i=this.inputLinks[a],r=i.node.getOutput(e,i.pin);this.pass.setUniform(a,r)}if(this.outputs){this.pass.outputs={};var o={};for(var s in this.outputs){var c=this.updateParameter(s,e);isNaN(c.width)&&this.updateParameter(s,e);var l=this.outputs[s],u=this._compositor.allocateTexture(c);this._outputTextures[s]=u;var p=l.attachment||n.COLOR_ATTACHMENT0;"string"==typeof p&&(p=n[p]),o[p]=u}this._compositor.getFrameBuffer().bind(e);for(var p in o)this._compositor.getFrameBuffer().attach(o[p],p);this.pass.render(e),this._compositor.getFrameBuffer().updateMipmap(e.gl)}else this.pass.outputs=null,this._compositor.getFrameBuffer().unbind(e),this.pass.render(e,t);for(var a in this.inputLinks){var i=this.inputLinks[a];i.node.removeReference(i.pin)}this._rendering=!1,this._rendered=!0,this.trigger("afterrender",e)},updateParameter:function(e,t){var n=this.outputs[e],a=n.parameters,i=n._parametersCopy;if(i||(i=n._parametersCopy={}),a)for(var r in a)"width"!==r&&"height"!==r&&(i[r]=a[r]);var o,s;return o=a.width instanceof Function?a.width.call(this,t):a.width,s=a.height instanceof Function?a.height.call(this,t):a.height,i.width===o&&i.height===s||this._outputTextures[e]&&this._outputTextures[e].dispose(t),i.width=o,i.height=s,i},setParameter:function(e,t){this.pass.setUniform(e,t)},getParameter:function(e){return this.pass.getUniform(e)},setParameters:function(e){for(var t in e)this.setParameter(t,e[t])},setShader:function(e){var t=this.pass.material;t.shader.setFragment(e),t.attachShader(t.shader,!0)},shaderDefine:function(e,t){this.pass.material.shader.define("fragment",e,t)},shaderUndefine:function(e){this.pass.material.shader.undefine("fragment",e)},removeReference:function(e){if(0===--this._outputReferences[e]){this.outputs[e].keepLastFrame?(this._prevOutputTextures[e]&&this._compositor.releaseTexture(this._prevOutputTextures[e]),this._prevOutputTextures[e]=this._outputTextures[e]):this._compositor.releaseTexture(this._outputTextures[e])}},link:function(e,t,n){this.inputLinks[e]={node:t,pin:n},t.outputLinks[n]||(t.outputLinks[n]=[]),t.outputLinks[n].push({node:this,pin:e}),this.pass.material.shader.enableTexture(e)},clear:function(){i.a.prototype.clear.call(this),this.pass.material.shader.disableTexturesAll()},updateReference:function(e){if(!this._rendering){this._rendering=!0;for(var t in this.inputLinks){var n=this.inputLinks[t];n.node.updateReference(n.pin)}this._rendering=!1}e&&this._outputReferences[e]++},beforeFrame:function(){this._rendered=!1;for(var e in this.outputLinks)this._outputReferences[e]=0},afterFrame:function(){for(var e in this.outputLinks)if(this._outputReferences[e]>0){var t=this.outputs[e];t.keepLastFrame?(this._prevOutputTextures[e]&&this._compositor.releaseTexture(this._prevOutputTextures[e]),this._prevOutputTextures[e]=this._outputTextures[e]):this._compositor.releaseTexture(this._outputTextures[e])}}});t.a=r},function(e,t,n){"use strict";function a(e){for(var t=new Uint8Array(e*e*4),n=0,a=new c.a,i=0;i0&&(a.shader.define("vertex","SKINNING"),a.shader.define("vertex","JOINT_COUNT",e),i.shader.define("vertex","SKINNING"),i.shader.define("vertex","JOINT_COUNT",e)),n={material1:a,material2:i},t[e]=n}return n.used=!0,n},_resetGBufferMaterials:function(){for(var e in this._gBufferMaterials)this._gBufferMaterials[e].used=!1},_cleanGBufferMaterials:function(e){for(var t in this._gBufferMaterials){var n=this._gBufferMaterials[t];n.used||(n.material1.dispose(e),n.material2.dispose(e))}},_replaceGBufferMat:function(e,t){for(var n=0;n>>16)>>>0;c=((1431655765&c)<<1|(2863311530&c)>>>1)>>>0,c=((858993459&c)<<2|(3435973836&c)>>>2)>>>0,c=((252645135&c)<<4|(4042322160&c)>>>4)>>>0,c=(((16711935&c)<<8|(4278255360&c)>>>8)>>>0)/4294967296;for(var l=0;l255?255:e}function i(e){return e<0?0:e>1?1:e}function r(e){return a(e.length&&"%"===e.charAt(e.length-1)?parseFloat(e)/100*255:parseInt(e,10))}function o(e){return i(e.length&&"%"===e.charAt(e.length-1)?parseFloat(e)/100:parseFloat(e))}function s(e,t,n){return n<0?n+=1:n>1&&(n-=1),6*n<1?e+(t-e)*n*6:2*n<1?t:3*n<2?e+(t-e)*(2/3-n)*6:e}function c(e,t,n,a,i){return e[0]=t,e[1]=n,e[2]=a,e[3]=i,e}function l(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e}function u(e,t){_&&l(_,t),_=v.put(e,_||t.slice())}function p(e,t){if(e){t=t||[];var n=v.get(e);if(n)return l(t,n);e+="";var a=e.replace(/ /g,"").toLowerCase();if(a in m)return l(t,m[a]),u(e,t),t;if("#"!==a.charAt(0)){var i=a.indexOf("("),s=a.indexOf(")");if(-1!==i&&s+1===a.length){var p=a.substr(0,i),f=a.substr(i+1,s-(i+1)).split(","),h=1;switch(p){case"rgba":if(4!==f.length)return void c(t,0,0,0,1);h=o(f.pop());case"rgb":return 3!==f.length?void c(t,0,0,0,1):(c(t,r(f[0]),r(f[1]),r(f[2]),h),u(e,t),t);case"hsla":return 4!==f.length?void c(t,0,0,0,1):(f[3]=o(f[3]),d(f,t),u(e,t),t);case"hsl":return 3!==f.length?void c(t,0,0,0,1):(d(f,t),u(e,t),t);default:return}}c(t,0,0,0,1)}else{if(4===a.length){var _=parseInt(a.substr(1),16);return _>=0&&_<=4095?(c(t,(3840&_)>>4|(3840&_)>>8,240&_|(240&_)>>4,15&_|(15&_)<<4,1),u(e,t),t):void c(t,0,0,0,1)}if(7===a.length){var _=parseInt(a.substr(1),16);return _>=0&&_<=16777215?(c(t,(16711680&_)>>16,(65280&_)>>8,255&_,1),u(e,t),t):void c(t,0,0,0,1)}}}}function d(e,t){var n=(parseFloat(e[0])%360+360)%360/360,i=o(e[1]),r=o(e[2]),l=r<=.5?r*(i+1):r+i-r*i,u=2*r-l;return t=t||[],c(t,a(255*s(u,l,n+1/3)),a(255*s(u,l,n)),a(255*s(u,l,n-1/3)),1),4===e.length&&(t[3]=e[3]),t}function f(e,t){if(e&&e.length){var n=e[0]+","+e[1]+","+e[2];return"rgba"!==t&&"hsva"!==t&&"hsla"!==t||(n+=","+e[3]),t+"("+n+")"}}t.a=p,t.b=f;var h=n(63),m={transparent:[0,0,0,0],aliceblue:[240,248,255,1],antiquewhite:[250,235,215,1],aqua:[0,255,255,1],aquamarine:[127,255,212,1],azure:[240,255,255,1],beige:[245,245,220,1],bisque:[255,228,196,1],black:[0,0,0,1],blanchedalmond:[255,235,205,1],blue:[0,0,255,1],blueviolet:[138,43,226,1],brown:[165,42,42,1],burlywood:[222,184,135,1],cadetblue:[95,158,160,1],chartreuse:[127,255,0,1],chocolate:[210,105,30,1],coral:[255,127,80,1],cornflowerblue:[100,149,237,1],cornsilk:[255,248,220,1],crimson:[220,20,60,1],cyan:[0,255,255,1],darkblue:[0,0,139,1],darkcyan:[0,139,139,1],darkgoldenrod:[184,134,11,1],darkgray:[169,169,169,1],darkgreen:[0,100,0,1],darkgrey:[169,169,169,1],darkkhaki:[189,183,107,1],darkmagenta:[139,0,139,1],darkolivegreen:[85,107,47,1],darkorange:[255,140,0,1],darkorchid:[153,50,204,1],darkred:[139,0,0,1],darksalmon:[233,150,122,1],darkseagreen:[143,188,143,1],darkslateblue:[72,61,139,1],darkslategray:[47,79,79,1],darkslategrey:[47,79,79,1],darkturquoise:[0,206,209,1],darkviolet:[148,0,211,1],deeppink:[255,20,147,1],deepskyblue:[0,191,255,1],dimgray:[105,105,105,1],dimgrey:[105,105,105,1],dodgerblue:[30,144,255,1],firebrick:[178,34,34,1],floralwhite:[255,250,240,1],forestgreen:[34,139,34,1],fuchsia:[255,0,255,1],gainsboro:[220,220,220,1],ghostwhite:[248,248,255,1],gold:[255,215,0,1],goldenrod:[218,165,32,1],gray:[128,128,128,1],green:[0,128,0,1],greenyellow:[173,255,47,1],grey:[128,128,128,1],honeydew:[240,255,240,1],hotpink:[255,105,180,1],indianred:[205,92,92,1],indigo:[75,0,130,1],ivory:[255,255,240,1],khaki:[240,230,140,1],lavender:[230,230,250,1],lavenderblush:[255,240,245,1],lawngreen:[124,252,0,1],lemonchiffon:[255,250,205,1],lightblue:[173,216,230,1],lightcoral:[240,128,128,1],lightcyan:[224,255,255,1],lightgoldenrodyellow:[250,250,210,1],lightgray:[211,211,211,1],lightgreen:[144,238,144,1],lightgrey:[211,211,211,1],lightpink:[255,182,193,1],lightsalmon:[255,160,122,1],lightseagreen:[32,178,170,1],lightskyblue:[135,206,250,1],lightslategray:[119,136,153,1],lightslategrey:[119,136,153,1],lightsteelblue:[176,196,222,1],lightyellow:[255,255,224,1],lime:[0,255,0,1],limegreen:[50,205,50,1],linen:[250,240,230,1],magenta:[255,0,255,1],maroon:[128,0,0,1],mediumaquamarine:[102,205,170,1],mediumblue:[0,0,205,1],mediumorchid:[186,85,211,1],mediumpurple:[147,112,219,1],mediumseagreen:[60,179,113,1],mediumslateblue:[123,104,238,1],mediumspringgreen:[0,250,154,1],mediumturquoise:[72,209,204,1],mediumvioletred:[199,21,133,1],midnightblue:[25,25,112,1],mintcream:[245,255,250,1],mistyrose:[255,228,225,1],moccasin:[255,228,181,1],navajowhite:[255,222,173,1],navy:[0,0,128,1],oldlace:[253,245,230,1],olive:[128,128,0,1],olivedrab:[107,142,35,1],orange:[255,165,0,1],orangered:[255,69,0,1],orchid:[218,112,214,1],palegoldenrod:[238,232,170,1],palegreen:[152,251,152,1],paleturquoise:[175,238,238,1],palevioletred:[219,112,147,1],papayawhip:[255,239,213,1],peachpuff:[255,218,185,1],peru:[205,133,63,1],pink:[255,192,203,1],plum:[221,160,221,1],powderblue:[176,224,230,1],purple:[128,0,128,1],red:[255,0,0,1],rosybrown:[188,143,143,1],royalblue:[65,105,225,1],saddlebrown:[139,69,19,1],salmon:[250,128,114,1],sandybrown:[244,164,96,1],seagreen:[46,139,87,1],seashell:[255,245,238,1],sienna:[160,82,45,1],silver:[192,192,192,1],skyblue:[135,206,235,1],slateblue:[106,90,205,1],slategray:[112,128,144,1],slategrey:[112,128,144,1],snow:[255,250,250,1],springgreen:[0,255,127,1],steelblue:[70,130,180,1],tan:[210,180,140,1],teal:[0,128,128,1],thistle:[216,191,216,1],tomato:[255,99,71,1],turquoise:[64,224,208,1],violet:[238,130,238,1],wheat:[245,222,179,1],white:[255,255,255,1],whitesmoke:[245,245,245,1],yellow:[255,255,0,1],yellowgreen:[154,205,50,1]},v=new h.a(20),_=null},function(e,t,n){"use strict";t.a={type:"compositor",nodes:[{name:"source",type:"texture",outputs:{color:{}}},{name:"source_half",shader:"#source(qtek.compositor.downsample)",inputs:{texture:"source"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 2)",height:"expr(height * 1.0 / 2)",type:"HALF_FLOAT"}}},parameters:{textureSize:"expr( [width * 1.0, height * 1.0] )"}},{name:"bright",shader:"#source(qtek.compositor.bright)",inputs:{texture:"source_half"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 2)",height:"expr(height * 1.0 / 2)",type:"HALF_FLOAT"}}},parameters:{threshold:2,scale:4,textureSize:"expr([width * 1.0 / 2, height / 2])"}},{name:"bright_downsample_4",shader:"#source(qtek.compositor.downsample)",inputs:{texture:"bright"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 4)",height:"expr(height * 1.0 / 4)",type:"HALF_FLOAT"}}},parameters:{textureSize:"expr( [width * 1.0 / 2, height / 2] )"}},{name:"bright_downsample_8",shader:"#source(qtek.compositor.downsample)",inputs:{texture:"bright_downsample_4"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 8)",height:"expr(height * 1.0 / 8)",type:"HALF_FLOAT"}}},parameters:{textureSize:"expr( [width * 1.0 / 4, height / 4] )"}},{name:"bright_downsample_16",shader:"#source(qtek.compositor.downsample)",inputs:{texture:"bright_downsample_8"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 16)",height:"expr(height * 1.0 / 16)",type:"HALF_FLOAT"}}},parameters:{textureSize:"expr( [width * 1.0 / 8, height / 8] )"}},{name:"bright_downsample_32",shader:"#source(qtek.compositor.downsample)",inputs:{texture:"bright_downsample_16"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 32)",height:"expr(height * 1.0 / 32)",type:"HALF_FLOAT"}}},parameters:{textureSize:"expr( [width * 1.0 / 16, height / 16] )"}},{name:"bright_upsample_16_blur_h",shader:"#source(qtek.compositor.gaussian_blur)",inputs:{texture:"bright_downsample_32"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 16)",height:"expr(height * 1.0 / 16)",type:"HALF_FLOAT"}}},parameters:{blurSize:1,blurDir:0,textureSize:"expr( [width * 1.0 / 32, height / 32] )"}},{name:"bright_upsample_16_blur_v",shader:"#source(qtek.compositor.gaussian_blur)",inputs:{texture:"bright_upsample_16_blur_h"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 16)",height:"expr(height * 1.0 / 16)",type:"HALF_FLOAT"}}},parameters:{blurSize:1,blurDir:1,textureSize:"expr( [width * 1.0 / 32, height * 1.0 / 32] )"}},{name:"bright_upsample_8_blur_h",shader:"#source(qtek.compositor.gaussian_blur)",inputs:{texture:"bright_downsample_16"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 8)",height:"expr(height * 1.0 / 8)",type:"HALF_FLOAT"}}},parameters:{blurSize:1,blurDir:0,textureSize:"expr( [width * 1.0 / 16, height * 1.0 / 16] )"}},{name:"bright_upsample_8_blur_v",shader:"#source(qtek.compositor.gaussian_blur)",inputs:{texture:"bright_upsample_8_blur_h"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 8)",height:"expr(height * 1.0 / 8)",type:"HALF_FLOAT"}}},parameters:{blurSize:1,blurDir:1,textureSize:"expr( [width * 1.0 / 16, height * 1.0 / 16] )"}},{name:"bright_upsample_8_blend",shader:"#source(qtek.compositor.blend)",inputs:{texture1:"bright_upsample_8_blur_v",texture2:"bright_upsample_16_blur_v"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 8)",height:"expr(height * 1.0 / 8)",type:"HALF_FLOAT"}}},parameters:{weight1:.3,weight2:.7}},{name:"bright_upsample_4_blur_h",shader:"#source(qtek.compositor.gaussian_blur)",inputs:{texture:"bright_downsample_8"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 4)",height:"expr(height * 1.0 / 4)",type:"HALF_FLOAT"}}},parameters:{blurSize:1,blurDir:0,textureSize:"expr( [width * 1.0 / 8, height * 1.0 / 8] )"}},{name:"bright_upsample_4_blur_v",shader:"#source(qtek.compositor.gaussian_blur)",inputs:{texture:"bright_upsample_4_blur_h"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 4)",height:"expr(height * 1.0 / 4)",type:"HALF_FLOAT"}}},parameters:{blurSize:1,blurDir:1,textureSize:"expr( [width * 1.0 / 8, height * 1.0 / 8] )"}},{name:"bright_upsample_4_blend",shader:"#source(qtek.compositor.blend)",inputs:{texture1:"bright_upsample_4_blur_v",texture2:"bright_upsample_8_blend"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 4)",height:"expr(height * 1.0 / 4)",type:"HALF_FLOAT"}}},parameters:{weight1:.3,weight2:.7}},{name:"bright_upsample_2_blur_h",shader:"#source(qtek.compositor.gaussian_blur)",inputs:{texture:"bright_downsample_4"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 2)",height:"expr(height * 1.0 / 2)",type:"HALF_FLOAT"}}},parameters:{blurSize:1,blurDir:0,textureSize:"expr( [width * 1.0 / 4, height * 1.0 / 4] )"}},{name:"bright_upsample_2_blur_v",shader:"#source(qtek.compositor.gaussian_blur)",inputs:{texture:"bright_upsample_2_blur_h"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 2)",height:"expr(height * 1.0 / 2)",type:"HALF_FLOAT"}}},parameters:{blurSize:1,blurDir:1,textureSize:"expr( [width * 1.0 / 4, height * 1.0 / 4] )"}},{name:"bright_upsample_2_blend",shader:"#source(qtek.compositor.blend)",inputs:{texture1:"bright_upsample_2_blur_v",texture2:"bright_upsample_4_blend"},outputs:{color:{parameters:{width:"expr(width * 1.0 / 2)",height:"expr(height * 1.0 / 2)",type:"HALF_FLOAT"}}},parameters:{weight1:.3,weight2:.7}},{name:"bright_upsample_full_blur_h",shader:"#source(qtek.compositor.gaussian_blur)",inputs:{texture:"bright"},outputs:{color:{parameters:{width:"expr(width * 1.0)",height:"expr(height * 1.0)",type:"HALF_FLOAT"}}},parameters:{blurSize:1,blurDir:0,textureSize:"expr( [width * 1.0 / 2, height * 1.0 / 2] )"}},{name:"bright_upsample_full_blur_v",shader:"#source(qtek.compositor.gaussian_blur)",inputs:{texture:"bright_upsample_full_blur_h"},outputs:{color:{parameters:{width:"expr(width * 1.0)",height:"expr(height * 1.0)",type:"HALF_FLOAT"}}},parameters:{blurSize:1,blurDir:1,textureSize:"expr( [width * 1.0 / 2, height * 1.0 / 2] )"}},{name:"bloom_composite",shader:"#source(qtek.compositor.blend)",inputs:{texture1:"bright_upsample_full_blur_v",texture2:"bright_upsample_2_blend"},outputs:{color:{parameters:{width:"expr(width * 1.0)",height:"expr(height * 1.0)",type:"HALF_FLOAT"}}},parameters:{weight1:.3,weight2:.7}},{name:"coc",shader:"#source(ecgl.dof.coc)",outputs:{color:{parameters:{minFilter:"NEAREST",magFilter:"NEAREST",width:"expr(width * 1.0)",height:"expr(height * 1.0)"}}},parameters:{focalDist:50,focalRange:30}},{name:"dof_far_blur",shader:"#source(ecgl.dof.diskBlur)",inputs:{texture:"source",coc:"coc"},outputs:{color:{parameters:{width:"expr(width * 1.0)",height:"expr(height * 1.0)",type:"HALF_FLOAT"}}},parameters:{textureSize:"expr( [width * 1.0, height * 1.0] )"}},{name:"dof_near_blur",shader:"#source(ecgl.dof.diskBlur)",inputs:{texture:"source",coc:"coc"},outputs:{color:{parameters:{width:"expr(width * 1.0)",height:"expr(height * 1.0)",type:"HALF_FLOAT"}}},parameters:{textureSize:"expr( [width * 1.0, height * 1.0] )"},defines:{BLUR_NEARFIELD:null}},{name:"dof_coc_blur",shader:"#source(ecgl.dof.diskBlur)",inputs:{texture:"coc"},outputs:{color:{parameters:{minFilter:"NEAREST",magFilter:"NEAREST",width:"expr(width * 1.0)",height:"expr(height * 1.0)"}}},parameters:{textureSize:"expr( [width * 1.0, height * 1.0] )"},defines:{BLUR_COC:null}},{name:"dof_composite",shader:"#source(ecgl.dof.composite)",inputs:{original:"source",blurred:"dof_far_blur",nearfield:"dof_near_blur",coc:"coc",nearcoc:"dof_coc_blur"},outputs:{color:{parameters:{width:"expr(width * 1.0)",height:"expr(height * 1.0)",type:"HALF_FLOAT"}}}},{name:"composite",shader:"#source(qtek.compositor.hdr.composite)",inputs:{texture:"source",bloom:"bloom_composite"},defines:{}},{name:"FXAA",shader:"#source(qtek.compositor.fxaa)",inputs:{texture:"composite"}}]}},function(e,t,n){"use strict";t.a="@export ecgl.dof.coc\n\nuniform sampler2D depth;\n\nuniform float zNear: 0.1;\nuniform float zFar: 2000;\n\nuniform float focalDistance: 3;\nuniform float focalRange: 1;\nuniform float focalLength: 30;\nuniform float fstop: 2.8;\n\nvarying vec2 v_Texcoord;\n\n@import qtek.util.encode_float\n\nvoid main()\n{\n float z = texture2D(depth, v_Texcoord).r * 2.0 - 1.0;\n\n float dist = 2.0 * zNear * zFar / (zFar + zNear - z * (zFar - zNear));\n\n float aperture = focalLength / fstop;\n\n float coc;\n\n float uppper = focalDistance + focalRange;\n float lower = focalDistance - focalRange;\n if (dist <= uppper && dist >= lower) {\n coc = 0.5;\n }\n else {\n float focalAdjusted = dist > uppper ? uppper : lower;\n\n coc = abs(aperture * (focalLength * (dist - focalAdjusted)) / (dist * (focalAdjusted - focalLength)));\n coc = clamp(coc, 0.0, 2.0) / 2.00001;\n\n if (dist < lower) {\n coc = -coc;\n }\n coc = coc * 0.5 + 0.5;\n }\n\n gl_FragColor = encodeFloat(coc);\n}\n@end\n\n\n@export ecgl.dof.composite\n\n#define DEBUG 0\n\nuniform sampler2D original;\nuniform sampler2D blurred;\nuniform sampler2D nearfield;\nuniform sampler2D coc;\nuniform sampler2D nearcoc;\nvarying vec2 v_Texcoord;\n\n@import qtek.util.rgbm\n@import qtek.util.float\n\nvoid main()\n{\n vec4 blurredColor = decodeHDR(texture2D(blurred, v_Texcoord));\n vec4 originalColor = decodeHDR(texture2D(original, v_Texcoord));\n\n float fCoc = decodeFloat(texture2D(coc, v_Texcoord));\n\n fCoc = abs(fCoc * 2.0 - 1.0);\n\n float weight = smoothstep(0.0, 1.0, fCoc);\n \n#ifdef NEARFIELD_ENABLED\n vec4 nearfieldColor = decodeHDR(texture2D(nearfield, v_Texcoord));\n float fNearCoc = decodeFloat(texture2D(nearcoc, v_Texcoord));\n fNearCoc = abs(fNearCoc * 2.0 - 1.0);\n\n gl_FragColor = encodeHDR(\n mix(\n nearfieldColor, mix(originalColor, blurredColor, weight),\n pow(1.0 - fNearCoc, 4.0)\n )\n );\n#else\n gl_FragColor = encodeHDR(mix(originalColor, blurredColor, weight));\n#endif\n\n}\n\n@end\n\n\n\n@export ecgl.dof.diskBlur\n\n#define POISSON_KERNEL_SIZE 16;\n\nuniform sampler2D texture;\nuniform sampler2D coc;\nvarying vec2 v_Texcoord;\n\nuniform float blurRadius : 10.0;\nuniform vec2 textureSize : [512.0, 512.0];\n\nuniform vec2 poissonKernel[POISSON_KERNEL_SIZE];\n\nuniform float percent;\n\nfloat nrand(const in vec2 n) {\n return fract(sin(dot(n.xy ,vec2(12.9898,78.233))) * 43758.5453);\n}\n\n@import qtek.util.rgbm\n@import qtek.util.float\n\n\nvoid main()\n{\n vec2 offset = blurRadius / textureSize;\n\n float rnd = 6.28318 * nrand(v_Texcoord + 0.07 * percent );\n float cosa = cos(rnd);\n float sina = sin(rnd);\n vec4 basis = vec4(cosa, -sina, sina, cosa);\n\n#if !defined(BLUR_NEARFIELD) && !defined(BLUR_COC)\n offset *= abs(decodeFloat(texture2D(coc, v_Texcoord)) * 2.0 - 1.0);\n#endif\n\n#ifdef BLUR_COC\n float cocSum = 0.0;\n#else\n vec4 color = vec4(0.0);\n#endif\n\n\n float weightSum = 0.0;\n\n for (int i = 0; i < POISSON_KERNEL_SIZE; i++) {\n vec2 ofs = poissonKernel[i];\n\n ofs = vec2(dot(ofs, basis.xy), dot(ofs, basis.zw));\n\n vec2 uv = v_Texcoord + ofs * offset;\n vec4 texel = texture2D(texture, uv);\n\n float w = 1.0;\n#ifdef BLUR_COC\n float fCoc = decodeFloat(texel) * 2.0 - 1.0;\n cocSum += clamp(fCoc, -1.0, 0.0) * w;\n#else\n texel = decodeHDR(texel);\n #if !defined(BLUR_NEARFIELD)\n float fCoc = decodeFloat(texture2D(coc, uv)) * 2.0 - 1.0;\n w *= abs(fCoc);\n #endif\n color += texel * w;\n#endif\n\n weightSum += w;\n }\n\n#ifdef BLUR_COC\n gl_FragColor = encodeFloat(clamp(cocSum / weightSum, -1.0, 0.0) * 0.5 + 0.5);\n#else\n color /= weightSum;\n gl_FragColor = encodeHDR(color);\n#endif\n}\n\n@end"},function(e,t,n){"use strict";t.a="@export ecgl.edge\n\nuniform sampler2D texture;\n\nuniform sampler2D normalTexture;\nuniform sampler2D depthTexture;\n\nuniform mat4 projectionInv;\n\nuniform vec2 textureSize;\n\nuniform vec4 edgeColor: [0,0,0,0.8];\n\nvarying vec2 v_Texcoord;\n\nvec3 packColor(vec2 coord) {\n float z = texture2D(depthTexture, coord).r * 2.0 - 1.0;\n vec4 p = vec4(v_Texcoord * 2.0 - 1.0, z, 1.0);\n vec4 p4 = projectionInv * p;\n\n return vec3(\n texture2D(normalTexture, coord).rg,\n -p4.z / p4.w / 5.0\n );\n}\n\nvoid main() {\n vec2 cc = v_Texcoord;\n vec3 center = packColor(cc);\n\n float size = clamp(1.0 - (center.z - 10.0) / 100.0, 0.0, 1.0) * 0.5;\n float dx = size / textureSize.x;\n float dy = size / textureSize.y;\n\n vec2 coord;\n vec3 topLeft = packColor(cc+vec2(-dx, -dy));\n vec3 top = packColor(cc+vec2(0.0, -dy));\n vec3 topRight = packColor(cc+vec2(dx, -dy));\n vec3 left = packColor(cc+vec2(-dx, 0.0));\n vec3 right = packColor(cc+vec2(dx, 0.0));\n vec3 bottomLeft = packColor(cc+vec2(-dx, dy));\n vec3 bottom = packColor(cc+vec2(0.0, dy));\n vec3 bottomRight = packColor(cc+vec2(dx, dy));\n\n vec3 v = -topLeft-2.0*top-topRight+bottomLeft+2.0*bottom+bottomRight;\n vec3 h = -bottomLeft-2.0*left-topLeft+bottomRight+2.0*right+topRight;\n\n float edge = sqrt(dot(h, h) + dot(v, v));\n\n edge = smoothstep(0.8, 1.0, edge);\n\n gl_FragColor = mix(texture2D(texture, v_Texcoord), vec4(edgeColor.rgb, 1.0), edgeColor.a * edge);\n}\n@end"},function(e,t,n){"use strict";function a(){for(var e=[],t=0;t<30;t++)e.push([Object(i.a)(t,2),Object(i.a)(t,3)]);this._haltonSequence=e,this._frame=0,this._sourceTex=new s.a,this._sourceFb=new o.a,this._sourceFb.attach(this._sourceTex),this._prevFrameTex=new s.a,this._outputTex=new s.a;var n=this._blendPass=new r.a({fragment:c.a.source("qtek.compositor.blend")});n.material.shader.disableTexturesAll(),n.material.shader.enableTexture(["texture1","texture2"]),this._blendFb=new o.a({depthBuffer:!1}),this._outputPass=new r.a({fragment:c.a.source("qtek.compositor.output"),blendWithPrevious:!0}),this._outputPass.material.shader.define("fragment","OUTPUT_ALPHA"),this._outputPass.material.blend=function(e){e.blendEquationSeparate(e.FUNC_ADD,e.FUNC_ADD),e.blendFuncSeparate(e.ONE,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA)}}var i=n(28),r=n(12),o=n(10),s=n(5),c=n(4),l=n(8);a.prototype={constructor:a,jitterProjection:function(e,t){var n=e.viewport,a=n.devicePixelRatio||e.getDevicePixelRatio(),i=n.width*a,r=n.height*a,o=this._haltonSequence[this._frame],s=new l.a;s._array[12]=(2*o[0]-1)/i,s._array[13]=(2*o[1]-1)/r,l.a.mul(t.projectionMatrix,s,t.projectionMatrix),l.a.invert(t.invProjectionMatrix,t.projectionMatrix)},resetFrame:function(){this._frame=0},getFrame:function(){return this._frame},getSourceFrameBuffer:function(){return this._sourceFb},resize:function(e,t){this._sourceTex.width===e&&this._sourceTex.height===t||(this._prevFrameTex.width=e,this._prevFrameTex.height=t,this._outputTex.width=e,this._outputTex.height=t,this._sourceTex.width=e,this._sourceTex.height=t,this._prevFrameTex.dirty(),this._outputTex.dirty(),this._sourceTex.dirty())},isFinished:function(){return this._frame>=this._haltonSequence.length},render:function(e){var t=this._blendPass;0===this._frame?(t.setUniform("weight1",0),t.setUniform("weight2",1)):(t.setUniform("weight1",.9),t.setUniform("weight2",.1)),t.setUniform("texture1",this._prevFrameTex),t.setUniform("texture2",this._sourceTex),this._blendFb.attach(this._outputTex),this._blendFb.bind(e),t.render(e),this._blendFb.unbind(e),this._outputPass.setUniform("texture",this._outputTex),this._outputPass.render(e);var n=this._prevFrameTex;this._prevFrameTex=this._outputTex,this._outputTex=n,this._frame++},dispose:function(e){this._sourceFb.dispose(e),this._blendFb.dispose(e),this._prevFrameTex.dispose(e),this._outputTex.dispose(e),this._sourceTex.dispose(e),this._outputPass.dispose(e),this._blendPass.dispose(e)}},t.a=a},function(e,t,n){"use strict";function a(e){this.setScene(e)}var i=n(29),r=n(36),o=n(35),s=n(2),c=n(60),l=n(131);a.prototype={constructor:a,setScene:function(e){this._scene=e,this._skybox&&this._skybox.attachScene(this._scene)},initLight:function(e){this._lightRoot=e,this.mainLight=new c.a({shadowBias:.005}),this.secondaryLight=new c.a({shadowBias:.005}),this.tertiaryLight=new c.a({shadowBias:.005}),this.ambientLight=new l.a},dispose:function(e){this._lightRoot&&(this._lightRoot.remove(this.mainLight),this._lightRoot.remove(this.ambientLight)),this._currentCubemapLights&&(this._lightRoot.remove(this._currentCubemapLights.diffuse),this._currentCubemapLights.specular&&(this._lightRoot.remove(this._currentCubemapLights.specular),this._currentCubemapLights.specular.cubemap.dispose(e)))},updateMainLight:function(e,t){this._updateDirectionalLight(this.mainLight,e,t)},updateSecondaryLight:function(e,t){this._updateDirectionalLight(this.secondaryLight,e,t)},updateTertiaryLight:function(e,t){this._updateDirectionalLight(this.tertiaryLight,e,t)},_updateDirectionalLight:function(e,t,n){t=t||{},null!=t.intensity&&(e.intensity=t.intensity,this._lightRoot[t.intensity?"add":"remove"](e)),null!=t.color&&(e.color=i.a.parseColor(t.color).slice(0,3));var a=i.a.firstNotNull(t.alpha,45),r=i.a.firstNotNull(t.beta,45);e.position.setArray(i.a.directionFromAlphaBeta(a,r)),e.lookAt(s.a.ZERO);var o={low:512,medium:1024,high:2048,ultra:4096}[t.quality]||1024;e.castShadow=i.a.firstNotNull(t.shadow,!0),e.shadowResolution=o},updateAmbientLight:function(e,t){e=e||{},null!=e.intensity&&(this.ambientLight.intensity=e.intensity,this._lightRoot[e.intensity?"add":"remove"](this.ambientLight)),null!=e.color&&(this.ambientLight.color=i.a.parseColor(e.color).slice(0,3))},updateAmbientCubemapLight:function(e,t){e=e||{};var n=t.getRenderer(),a=e.texture,o=this;if("texture"in e&&(!this._currentCubemapLights||a!==this._currentCubemapLights.textureUrl))if(this._currentCubemapLights&&(this._lightRoot.remove(this._currentCubemapLights.diffuse),this._currentCubemapLights.specular&&(this._lightRoot.remove(this._currentCubemapLights.specular),this._currentCubemapLights.specular.cubemap.dispose(n.gl))),a){var s=i.a.createAmbientCubemap(e,t,function(){s.specular&&o._skybox instanceof r.a&&o._skybox.setEnvironmentMap(s.specular.cubemap),t.refresh()});s.diffuse&&this._lightRoot.add(s.diffuse),s.specular&&this._lightRoot.add(s.specular),this._currentCubemapLights=s,this._currentCubemapLights.textureUrl=a}else this._currentCubemapLights&&(this._lightRoot.remove(this._currentCubemapLights.diffuse),this._lightRoot.remove(this._currentCubemapLights.specular),this._currentCubemapLights=null);this._currentCubemapLights&&(null!=e.specularIntensity&&this._currentCubemapLights.specular&&(this._currentCubemapLights.specular.intensity=e.specularIntensity),null!=e.diffuseIntensity&&this._currentCubemapLights.diffuse&&(this._currentCubemapLights.diffuse.intensity=e.diffuseIntensity))},updateSkybox:function(e,t,n){var a=n.getRenderer(),s=this;if(e&&"none"!==e)if("auto"===e)if(this._currentCubemapLights){var c=function(){return s._skybox instanceof r.a||(s._skybox&&s._skybox.dispose(a),s._skybox=new r.a),s._skybox}();if(this._currentCubemapLights.specular){var l=this._currentCubemapLights.specular.cubemap;c.setEnvironmentMap(l)}this._scene&&c.attachScene(this._scene),c.material.set("lod",2)}else this._skybox&&this._skybox.detachScene();else{var u=function(){return s._skybox instanceof o.a||(s._skybox&&s._skybox.dispose(a),s._skybox=new o.a),s._skybox}(),p=i.a.loadTexture(e,n,{flipY:!1},function(){n.refresh()});u.setEnvironmentMap(p),u.attachScene(this._scene)}else this._skybox&&this._skybox.detachScene(this._scene),this._skybox=null;if(this._skybox)if("auto"===e||e.match&&e.match(/.hdr$/))this._skybox.material.shader.undefine("fragment","SRGB_DECODE");else{var d=t?"define":"undefine";this._skybox.material.shader[d]("fragment","SRGB_DECODE")}}},t.a=a},function(e,t,n){"use strict";var a=n(14),i=a.a.extend({castShadow:!1},{type:"AMBIENT_LIGHT",uniformTemplates:{ambientLightColor:{type:"3f",value:function(e){var t=e.color,n=e.intensity;return[t[0]*n,t[1]*n,t[2]*n]}}}});t.a=i},function(e,t,n){"use strict";t.a={devicePixelRatio:null,preZ:!1,picking:!1,shadow:!0,environment:"",ground:{show:!1},mainLight:{shadow:!0,shadowQuality:"medium",intensity:.8,color:"#fff",alpha:45,beta:45},secondaryLight:{shadow:!1,shadowQuality:"medium",intensity:0,color:"#fff",alpha:60,beta:-50},tertiaryLight:{shadow:!1,shadowQuality:"medium",intensity:0,color:"#fff",alpha:89,beta:0},ambientLight:{intensity:.3,color:"#fff"},ambientCubemapLight:{texture:"",exposure:3,diffuseIntensity:.5,specularIntensity:.5},postEffect:{enable:!1,bloom:{enable:!1,intensity:.1},depthOfField:{enable:!1,focalDistance:5,focalRange:1,blurRadius:5,fstop:2.8,quality:"medium"},screenSpaceAmbientOcculusion:{enable:!1,radius:.5,quality:"medium",intensity:1},screenSpaceReflection:{enable:!1,quality:"medium",maxRoughness:.8},colorCorrection:{enable:!0,exposure:0,brightness:0,contrast:1,saturation:1,lookupTexture:""},FXAA:{enable:!1}}}},function(e,t,n){"use strict";function a(e){if(null==e||"object"!=typeof e)return e;var t=e,n=m.call(e);if("[object Array]"===n){t=[];for(var i=0,r=e.length;i=0&&i[d]>1e-6&&(c.transformMat4(s,n,r[a[d]]),c.scaleAndAdd(o,o,s,i[d]));c.min(v,v,o),c.max(_,_,o)}t.min.setArray(v),t.max.setArray(_)}function i(e,t){t=t||new r.a;var n=new r.a;return e.traverse(function(e){e.geometry&&(e.isSkinnedMesh()?(a(e,n),e.geometry.boundingBox.copy(n)):(n.copy(e.geometry.boundingBox),n.applyTransform(e.worldTransform)),t.union(n))}),t}var r=n(7),o=n(0),s=n.n(o),c=s.a.vec3;t.a=i},function(e,t,n){"use strict";function a(e){return Array.isArray(e)||(e=[e,e]),e}var i=n(1),r=n(24),o=n(2),s=n(136),c=i.a.extend(function(){return{animation:null,domElement:null,target:null,_center:new o.a,minDistance:.1,maxDistance:1e3,minAlpha:-90,maxAlpha:90,minBeta:-1/0,maxBeta:1/0,autoRotateAfterStill:0,autoRotateDirection:"cw",autoRotateSpeed:60,_mode:"rotate",damping:.8,rotateSensitivity:1,zoomSensitivity:1,panSensitivity:1,_needsUpdate:!1,_rotating:!1,_phi:0,_theta:0,_mouseX:0,_mouseY:0,_rotateVelocity:new r.a,_panVelocity:new r.a,_distance:20,_zoomSpeed:0,_stillTimeout:0,_animators:[],_gestureMgr:new s.a}},function(){this._mouseDownHandler=this._mouseDownHandler.bind(this),this._mouseWheelHandler=this._mouseWheelHandler.bind(this),this._mouseMoveHandler=this._mouseMoveHandler.bind(this),this._mouseUpHandler=this._mouseUpHandler.bind(this),this._pinchHandler=this._pinchHandler.bind(this),this.update=this.update.bind(this),this.init()},{init:function(){var e=this.domElement;e.addEventListener("touchstart",this._mouseDownHandler),e.addEventListener("mousedown",this._mouseDownHandler),e.addEventListener("mousewheel",this._mouseWheelHandler),this.animation&&this.animation.on("frame",this.update)},dispose:function(){var e=this.domElement;e.removeEventListener("touchstart",this._mouseDownHandler),e.removeEventListener("touchmove",this._mouseMoveHandler),e.removeEventListener("touchend",this._mouseUpHandler),e.removeEventListener("mousedown",this._mouseDownHandler),e.removeEventListener("mousemove",this._mouseMoveHandler),e.removeEventListener("mouseup",this._mouseUpHandler),e.removeEventListener("mousewheel",this._mouseWheelHandler),this.animation&&this.animation.off("frame",this.update),this.stopAllAnimation()},getDistance:function(){return this._distance},setDistance:function(e){this._distance=e,this._needsUpdate=!0},getAlpha:function(){return this._theta/Math.PI*180},getBeta:function(){return-this._phi/Math.PI*180},getCenter:function(){return this._center.toArray()},setAlpha:function(e){e=Math.max(Math.min(this.maxAlpha,e),this.minAlpha),this._theta=e/180*Math.PI,this._needsUpdate=!0},setBeta:function(e){e=Math.max(Math.min(this.maxBeta,e),this.minBeta),this._phi=-e/180*Math.PI,this._needsUpdate=!0},setCenter:function(e){this._center.setArray(e)},setOption:function(e){e=e||{},["autoRotate","autoRotateAfterStill","autoRotateDirection","autoRotateSpeed","damping","minDistance","maxDistance","minAlpha","maxAlpha","minBeta","maxBeta","rotateSensitivity","zoomSensitivity","panSensitivity"].forEach(function(t){null!=e[t]&&(this[t]=e[t])},this),null!=e.distance&&this.setDistance(e.distance),null!=e.alpha&&this.setAlpha(e.alpha),null!=e.beta&&this.setBeta(e.beta),e.center&&this.setCenter(e.center)},animateTo:function(e){var t=this,n={},a={},i=this.animation;if(i)return null!=e.distance&&(n.distance=this.getDistance(),a.distance=e.distance),null!=e.alpha&&(n.alpha=this.getAlpha(),a.alpha=e.alpha),null!=e.beta&&(n.beta=this.getBeta(),a.beta=e.beta),null!=e.center&&(n.center=this.getCenter(),a.center=e.center),this._addAnimator(i.animate(n).when(e.duration||1e3,a).during(function(){null!=n.alpha&&t.setAlpha(n.alpha),null!=n.beta&&t.setBeta(n.beta),null!=n.distance&&t.setDistance(n.distance),null!=n.center&&t.setCenter(n.center),t._needsUpdate=!0}).done(e.done)).start(e.easing||"linear")},stopAllAnimation:function(){for(var e=0;e0},update:function(e){if(e=e||16,this._rotating){var t=("cw"===this.autoRotateDirection?1:-1)*this.autoRotateSpeed/180*Math.PI;this._phi-=t*e/1e3,this._needsUpdate=!0}else this._rotateVelocity.len()>0&&(this._needsUpdate=!0);(Math.abs(this._zoomSpeed)>.01||this._panVelocity.len()>0)&&(this._needsUpdate=!0),this._needsUpdate&&(this._updateDistance(Math.min(e,50)),this._updatePan(Math.min(e,50)),this._updateRotate(Math.min(e,50)),this._updateTransform(),this.target.update(),this.trigger("update"),this._needsUpdate=!1)},_updateRotate:function(e){var t=this._rotateVelocity;this._phi=t.y*e/20+this._phi,this._theta=t.x*e/20+this._theta,this.setAlpha(this.getAlpha()),this.setBeta(this.getBeta()),this._vectorDamping(t,this.damping)},_updateDistance:function(e){this._setDistance(this._distance+this._zoomSpeed*e/20),this._zoomSpeed*=this.damping},_setDistance:function(e){this._distance=Math.max(Math.min(e,this.maxDistance),this.minDistance)},_updatePan:function(e){var t=this._panVelocity,n=this._distance,a=this.target,i=a.worldTransform.y,r=a.worldTransform.x;this._center.scaleAndAdd(r,-t.x*n/200).scaleAndAdd(i,-t.y*n/200),this._vectorDamping(t,0)},_updateTransform:function(){var e=this.target,t=new o.a,n=this._theta+Math.PI/2,a=this._phi+Math.PI/2,i=Math.sin(n);t.x=i*Math.cos(a),t.y=-Math.cos(n),t.z=i*Math.sin(a),e.position.copy(this._center).scaleAndAdd(t,this._distance),e.rotation.identity().rotateY(-this._phi).rotateX(-this._theta)},_startCountingStill:function(){clearTimeout(this._stillTimeout);var e=this.autoRotateAfterStill,t=this;!isNaN(e)&&e>0&&(this._stillTimeout=setTimeout(function(){t._rotating=!0},1e3*e))},_vectorDamping:function(e,t){var n=e.len();n*=t,n<1e-4&&(n=0),e.normalize().scale(n)},decomposeTransform:function(){if(this.target){var e=new o.a;e.eulerFromQuat(this.target.rotation.normalize(),"ZYX"),this._theta=-e.x,this._phi=-e.y,this.setBeta(this.getBeta()),this.setAlpha(this.getAlpha()),this._setDistance(this.target.position.dist(this._center))}},_mouseDownHandler:function(e){if(!this._isAnimating()){var t=e.clientX,n=e.clientY;if(e.targetTouches){var a=e.targetTouches[0];t=a.clientX,n=a.clientY,this._mode="rotate",this._processGesture(e,"start")}var i=this.domElement;i.addEventListener("touchmove",this._mouseMoveHandler),i.addEventListener("touchend",this._mouseUpHandler),i.addEventListener("mousemove",this._mouseMoveHandler),i.addEventListener("mouseup",this._mouseUpHandler),0===e.button?this._mode="rotate":1===e.button&&(this._mode="pan"),this._rotateVelocity.set(0,0),this._rotating=!1,this.autoRotate&&this._startCountingStill(),this._mouseX=t,this._mouseY=n}},_mouseMoveHandler:function(e){if(!this._isAnimating()){var t,n=e.clientX,i=e.clientY;if(e.targetTouches){var r=e.targetTouches[0];n=r.clientX,i=r.clientY,t=this._processGesture(e,"change")}var o=a(this.panSensitivity),s=a(this.rotateSensitivity);t||("rotate"===this._mode?(this._rotateVelocity.y=(n-this._mouseX)/this.domElement.clientHeight*2*s[0],this._rotateVelocity.x=(i-this._mouseY)/this.domElement.clientWidth*2*s[1]):"pan"===this._mode&&(this._panVelocity.x=(n-this._mouseX)/this.domElement.clientWidth*o[0]*400,this._panVelocity.y=(-i+this._mouseY)/this.domElement.clientHeight*o[1]*400)),this._mouseX=n,this._mouseY=i,e.preventDefault()}},_mouseWheelHandler:function(e){if(!this._isAnimating()){var t=e.wheelDelta||-e.detail;0!==t&&this._zoomHandler(e,t>0?-1:1)}},_pinchHandler:function(e){this._isAnimating()||this._zoomHandler(e,e.pinchScale>1?-.4:.4)},_zoomHandler:function(e,t){var n=Math.max(Math.min(this._distance-this.minDistance,this.maxDistance-this._distance));this._zoomSpeed=t*Math.max(n/40*this.zoomSensitivity,.2),this._rotating=!1,this.autoRotate&&"rotate"===this._mode&&this._startCountingStill(),e.preventDefault()},_mouseUpHandler:function(e){var t=this.domElement;t.removeEventListener("touchmove",this._mouseMoveHandler),t.removeEventListener("touchend",this._mouseUpHandler),t.removeEventListener("mousemove",this._mouseMoveHandler),t.removeEventListener("mouseup",this._mouseUpHandler),this._processGesture(e,"end")},_addAnimator:function(e){var t=this._animators;return t.push(e),e.done(function(){var n=t.indexOf(e);n>=0&&t.splice(n,1)}),e},_processGesture:function(e,t){var n=this._gestureMgr;"start"===t&&n.clear();var a=n.recognize(e,null,this.domElement);if("end"===t&&n.clear(),a){var i=a.type;e.gestureEvent=i,this._pinchHandler(a.event)}return a}});Object.defineProperty(c.prototype,"autoRotate",{get:function(){return this._autoRotate},set:function(e){this._autoRotate=e,this._rotating=e}}),Object.defineProperty(c.prototype,"target",{get:function(){return this._target},set:function(e){e&&e.target&&this.setCenter(e.target.toArray()),this._target=e,this.decomposeTransform()}}),t.a=c},function(e,t,n){"use strict";function a(e){var t=e[1][0]-e[0][0],n=e[1][1]-e[0][1];return Math.sqrt(t*t+n*n)}function i(e){return[(e[0][0]+e[1][0])/2,(e[0][1]+e[1][1])/2]}var r=function(){this._track=[]};r.prototype={constructor:r,recognize:function(e,t,n){return this._doTrack(e,t,n),this._recognize(e)},clear:function(){return this._track.length=0,this},_doTrack:function(e,t,n){var a=e.targetTouches;if(a){for(var i={points:[],touches:[],target:t,event:e},r=0,o=a.length;r1&&r&&r.length>1){var s=a(r)/a(o);!isFinite(s)&&(s=1),t.pinchScale=s;var c=i(r);return t.pinchX=c[0],t.pinchY=c[1],{type:"pinch",target:e[0].target,event:t}}}}};t.a=r},function(e,t,n){"use strict";var a=n(1),i=n(138),r=n(7),o=a.a.extend(function(){return{dom:null,renderer:null,camera:null,_boundingBox:new r.a,_hotspotRoot:null,_hotspots:[]}},function(){if(!this.dom||!this.renderer||!this.camera)throw new Error("Tip manager needs `root`, `camera`, `renderer`");var e=this._hotspotRoot=document.createElement("div");e.style.cssText="position:absolute;top:0;left:0;right:0;bottom:0;overflow:hidden;",this.dom.appendChild(e)},{setBoundingBox:function(e,t){this._boundingBox.min.setArray(e),this._boundingBox.max.setArray(t)},add:function(e,t){if("string"==typeof t){var n=document.createElement("div");n.innerHTML=t,t=n}return t.classList.add("qmv-annotation"),t.style.position="absolute",this._hotspotRoot.appendChild(t),this._hotspots.push({position:e,dom:t}),t},remove:function(e){for(var t=-1,n=0;n=0&&(this._hotspots.splice(t,1),this._hotspotRoot.removeChild(e))},update:function(){var e=new i.a,t=new r.a;this._hotspots.forEach(function(n){var a=n.position;e.set(a[0],a[1],a[2],1),e.transformMat4(this.camera.viewMatrix);var i=e.z;e.transformMat4(this.camera.projectionMatrix),e.scale(1/e.w);var r=.5*(e.x+1)*this.renderer.getWidth(),o=.5*(e.y+1)*this.renderer.getHeight();n.dom.style.left=r+"px",n.dom.style.top=this.renderer.getHeight()-o+"px";var s=null==n.farAlpha?.1:n.farAlpha,c=null==n.nearAlpha?1:n.nearAlpha;t.copy(this._boundingBox),t.applyTransform(this.camera.viewMatrix);var l=(i-t.max.z)/(t.min.z-t.max.z);Math.max(Math.min(l,1),0);n.dom.style.opacity=1,n.onupdate&&n.onupdate(r,o)},this)}});t.a=o},function(e,t,n){"use strict";var a=n(0),i=n.n(a),r=i.a.vec4,o=function(e,t,n,a){e=e||0,t=t||0,n=n||0,a=a||0,this._array=r.fromValues(e,t,n,a),this._dirty=!0};o.prototype={constructor:o,add:function(e){return r.add(this._array,this._array,e._array),this._dirty=!0,this},set:function(e,t,n,a){return this._array[0]=e,this._array[1]=t,this._array[2]=n,this._array[3]=a,this._dirty=!0,this},setArray:function(e){return this._array[0]=e[0],this._array[1]=e[1],this._array[2]=e[2],this._array[3]=e[3],this._dirty=!0,this},clone:function(){return new o(this.x,this.y,this.z,this.w)},copy:function(e){return r.copy(this._array,e._array),this._dirty=!0,this},dist:function(e){return r.dist(this._array,e._array)},distance:function(e){return r.distance(this._array,e._array)},div:function(e){return r.div(this._array,this._array,e._array),this._dirty=!0,this},divide:function(e){return r.divide(this._array,this._array,e._array),this._dirty=!0,this},dot:function(e){return r.dot(this._array,e._array)},len:function(){return r.len(this._array)},length:function(){return r.length(this._array)},lerp:function(e,t,n){return r.lerp(this._array,e._array,t._array,n),this._dirty=!0,this},min:function(e){return r.min(this._array,this._array,e._array),this._dirty=!0,this},max:function(e){return r.max(this._array,this._array,e._array),this._dirty=!0,this},mul:function(e){return r.mul(this._array,this._array,e._array),this._dirty=!0,this},multiply:function(e){return r.multiply(this._array,this._array,e._array),this._dirty=!0,this},negate:function(){return r.negate(this._array,this._array),this._dirty=!0,this},normalize:function(){return r.normalize(this._array,this._array),this._dirty=!0,this},random:function(e){return r.random(this._array,e),this._dirty=!0,this},scale:function(e){return r.scale(this._array,this._array,e),this._dirty=!0,this},scaleAndAdd:function(e,t){return r.scaleAndAdd(this._array,this._array,e._array,t),this._dirty=!0,this},sqrDist:function(e){return r.sqrDist(this._array,e._array)},squaredDistance:function(e){return r.squaredDistance(this._array,e._array)},sqrLen:function(){return r.sqrLen(this._array)},squaredLength:function(){return r.squaredLength(this._array)},sub:function(e){return r.sub(this._array,this._array,e._array),this._dirty=!0,this},subtract:function(e){return r.subtract(this._array,this._array,e._array),this._dirty=!0,this},transformMat4:function(e){return r.transformMat4(this._array,this._array,e._array),this._dirty=!0,this},transformQuat:function(e){return r.transformQuat(this._array,this._array,e._array),this._dirty=!0,this},toString:function(){return"["+Array.prototype.join.call(this._array,",")+"]"},toArray:function(){return Array.prototype.slice.call(this._array)}};var s=Object.defineProperty;if(s){var c=o.prototype;s(c,"x",{get:function(){return this._array[0]},set:function(e){this._array[0]=e,this._dirty=!0}}),s(c,"y",{get:function(){return this._array[1]},set:function(e){this._array[1]=e,this._dirty=!0}}),s(c,"z",{get:function(){return this._array[2]},set:function(e){this._array[2]=e,this._dirty=!0}}),s(c,"w",{get:function(){return this._array[3]},set:function(e){this._array[3]=e,this._dirty=!0}})}o.add=function(e,t,n){return r.add(e._array,t._array,n._array),e._dirty=!0,e},o.set=function(e,t,n,a,i){r.set(e._array,t,n,a,i),e._dirty=!0},o.copy=function(e,t){return r.copy(e._array,t._array),e._dirty=!0,e},o.dist=function(e,t){return r.distance(e._array,t._array)},o.distance=o.dist,o.div=function(e,t,n){return r.divide(e._array,t._array,n._array),e._dirty=!0,e},o.divide=o.div,o.dot=function(e,t){return r.dot(e._array,t._array)},o.len=function(e){return r.length(e._array)},o.lerp=function(e,t,n,a){return r.lerp(e._array,t._array,n._array,a),e._dirty=!0,e},o.min=function(e,t,n){return r.min(e._array,t._array,n._array),e._dirty=!0,e},o.max=function(e,t,n){return r.max(e._array,t._array,n._array),e._dirty=!0,e},o.mul=function(e,t,n){return r.multiply(e._array,t._array,n._array),e._dirty=!0,e},o.multiply=o.mul,o.negate=function(e,t){return r.negate(e._array,t._array),e._dirty=!0,e},o.normalize=function(e,t){return r.normalize(e._array,t._array),e._dirty=!0,e},o.random=function(e,t){return r.random(e._array,t),e._dirty=!0,e},o.scale=function(e,t,n){return r.scale(e._array,t._array,n),e._dirty=!0,e},o.scaleAndAdd=function(e,t,n,a){return r.scaleAndAdd(e._array,t._array,n._array,a),e._dirty=!0,e},o.sqrDist=function(e,t){return r.sqrDist(e._array,t._array)},o.squaredDistance=o.sqrDist,o.sqrLen=function(e){return r.sqrLen(e._array)},o.squaredLength=o.sqrLen,o.sub=function(e,t,n){return r.subtract(e._array,t._array,n._array),e._dirty=!0,e},o.subtract=o.sub,o.transformMat4=function(e,t,n){return r.transformMat4(e._array,t._array,n._array),e._dirty=!0,e},o.transformQuat=function(e,t,n){return r.transformQuat(e._array,t._array,n._array),e._dirty=!0,e},t.a=o},function(e,t,n){"use strict";t.a="@export qmv.ground.vertex\n@import qtek.lambert.vertex\n@end\n\n\n@export qmv.ground.fragment\n\nvarying vec2 v_Texcoord;\nvarying vec3 v_Normal;\nvarying vec3 v_WorldPosition;\n\nuniform vec4 color : [1.0, 1.0, 1.0, 1.0];\nuniform float gridSize: 5;\nuniform float gridSize2: 1;\nuniform vec4 gridColor: [0, 0, 0, 1];\nuniform vec4 gridColor2: [0.3, 0.3, 0.3, 1];\n\nuniform float glossiness: 0.7;\n\n#ifdef SSAOMAP_ENABLED\nuniform sampler2D ssaoMap;\nuniform vec4 viewport : VIEWPORT;\n#endif\n\n#ifdef AMBIENT_LIGHT_COUNT\n@import qtek.header.ambient_light\n#endif\n#ifdef AMBIENT_SH_LIGHT_COUNT\n@import qtek.header.ambient_sh_light\n#endif\n#ifdef DIRECTIONAL_LIGHT_COUNT\n@import qtek.header.directional_light\n#endif\n\n@import qtek.plugin.compute_shadow_map\n\nvoid main()\n{\n gl_FragColor = color;\n\n float wx = v_WorldPosition.x;\n float wz = v_WorldPosition.z;\n float x0 = abs(fract(wx / gridSize - 0.5) - 0.5) / fwidth(wx) * gridSize / 2.0;\n float z0 = abs(fract(wz / gridSize - 0.5) - 0.5) / fwidth(wz) * gridSize / 2.0;\n\n float x1 = abs(fract(wx / gridSize2 - 0.5) - 0.5) / fwidth(wx) * gridSize2;\n float z1 = abs(fract(wz / gridSize2 - 0.5) - 0.5) / fwidth(wz) * gridSize2;\n\n float v0 = 1.0 - clamp(min(x0, z0), 0.0, 1.0);\n float v1 = 1.0 - clamp(min(x1, z1), 0.0, 1.0);\n if (v0 > 0.1) {\n gl_FragColor = mix(gl_FragColor, gridColor, v0);\n }\n else {\n gl_FragColor = mix(gl_FragColor, gridColor2, v1);\n }\n\n vec3 diffuseColor = vec3(0.0, 0.0, 0.0);\n\n#ifdef AMBIENT_LIGHT_COUNT\n for(int _idx_ = 0; _idx_ < AMBIENT_LIGHT_COUNT; _idx_++)\n {\n diffuseColor += ambientLightColor[_idx_];\n }\n#endif\n#ifdef AMBIENT_SH_LIGHT_COUNT\n for(int _idx_ = 0; _idx_ < AMBIENT_SH_LIGHT_COUNT; _idx_++)\n {{\n diffuseColor += calcAmbientSHLight(_idx_, v_Normal) * ambientSHLightColor[_idx_];\n }}\n#endif\n\n#ifdef DIRECTIONAL_LIGHT_COUNT\n#if defined(DIRECTIONAL_LIGHT_SHADOWMAP_COUNT)\n float shadowContribsDir[DIRECTIONAL_LIGHT_COUNT];\n if(shadowEnabled)\n {\n computeShadowOfDirectionalLights(v_WorldPosition, shadowContribsDir);\n }\n#endif\n for(int i = 0; i < DIRECTIONAL_LIGHT_COUNT; i++)\n {\n vec3 lightDirection = -directionalLightDirection[i];\n vec3 lightColor = directionalLightColor[i];\n\n float ndl = dot(v_Normal, normalize(lightDirection));\n\n float shadowContrib = 1.0;\n#if defined(DIRECTIONAL_LIGHT_SHADOWMAP_COUNT)\n if( shadowEnabled )\n {\n shadowContrib = shadowContribsDir[i];\n }\n#endif\n\n diffuseColor += lightColor * clamp(ndl, 0.0, 1.0) * shadowContrib;\n }\n#endif\n\n#ifdef SSAOMAP_ENABLED\n diffuseColor *= texture2D(ssaoMap, (gl_FragCoord.xy - viewport.xy) / viewport.zw).r;\n#endif\n\n gl_FragColor.rgb *= diffuseColor;\n\n gl_FragColor.a *= 1.0 - clamp(length(v_WorldPosition.xz) / 30.0, 0.0, 1.0);\n\n}\n\n@end"},function(e,t,n){"use strict";var a=n(37);t.a=function(){return{preZ:!0,materials:[],takes:[],textureFlipY:!1,zUpToYUp:!1,shadow:!0,environment:"auto",viewControl:{alpha:20,beta:30,distance:18},ground:{show:!0},mainLight:{shadow:!0,shadowQuality:"medium",intensity:.8,color:"#fff",alpha:45,beta:45,$padAngle:[.25,.5]},secondaryLight:{shadow:!1,shadowQuality:"medium",intensity:0,color:"#fff",alpha:60,beta:-50,$padAngle:[-50/180,60/90]},tertiaryLight:{shadow:!1,shadowQuality:"medium",intensity:0,color:"#fff",alpha:89,beta:0,$padAngle:[0,89/90]},ambientLight:{intensity:0,color:"#fff"},ambientCubemapLight:{texture:a.a.ENV_TEXTURE_ROOT+"pisa.hdr",$texture:"pisa",$textureOptions:["pisa","Barce_Rooftop_C","Factory_Catwalk","Grand_Canyon_C","Ice_Lake","Hall","Old_Industrial_Hall"],exposure:3,diffuseIntensity:.5,specularIntensity:.5,$intensity:.5},postEffect:{enable:!0,bloom:{enable:!0,intensity:.1},depthOfField:{enable:!1,focalDistance:4,focalRange:1,blurRadius:5,fstop:10,quality:"medium",$qualityOptions:["low","medium","high","ultra"]},screenSpaceAmbientOcclusion:{enable:!1,radius:1.5,quality:"medium",intensity:1,$qualityOptions:["low","medium","high","ultra"]},screenSpaceReflection:{enable:!1,quality:"medium",maxRoughness:.8,$qualityOptions:["low","medium","high","ultra"]},colorCorrection:{enable:!0,exposure:0,brightness:0,contrast:1,saturation:1,lookupTexture:""},FXAA:{enable:!1}}}}},function(e,t,n){"use strict";t.a=function(){return{name:"",type:"pbrMetallicRoughness",color:"#fff",transparent:!1,alpha:1,alphaCutoff:0,diffuseMap:"",normalMap:"",parallaxOcclusionScale:.01,parallaxOcclusionMap:"",emission:"#fff",emissionIntensity:0,emissiveMap:"",uvRepeat:[1,1],metalness:0,roughness:.5,metalnessMap:"",roughnessMap:"",glossiness:.5,specularColor:"#111",glossinessMap:"",specularMap:"",$alphaRange:[0,1],$alphaCutoffRange:[0,1],$metalnessRange:[0,1],$roughnessRange:[0,1],$glossinessRange:[0,1],$parallaxOcclusionScaleRange:[0,.1],$textureTiling:1}}},function(e,t,n){"use strict";function a(e){var t=e.lastIndexOf(".");return t>=0?e.substr(t+1).toLowerCase():""}function i(e,t){var n=e.split("/");return t=t||"",0===e.indexOf("/")&&n.shift(),n=n.filter(function(e){return!!e}),new Promise(function(e,a){if(!x)return void a(E);var r=n.shift(),o=t+"/"+r;x.mkdir(o,function(t){t&&"EEXIST"!==t.code?a(t.toString()):n.length?i(n.join("/"),o).then(e).catch(a):e()})})}function r(e){return new Promise(function(t,n){if(!x)return void n(E);s(e).then(function(t){return Promise.all(t.map(function(t){return new Promise(function(n,a){var i=e+"/"+t;x.lstat(i,function(e,t){e?a(e.toString()):t.isDirectory()?r(i).then(n,a):x.unlink(i,function(e){e?a(e.toString()):n()})})})}))},n).then(function(){x.rmdir(e,function(e){e?n(e.toString()):t()})},n)})}function o(e,t){return new Promise(function(n,a){x||a(E),FileAPI.readAsArrayBuffer(t,function(i){"load"===i.type&&x.writeFile(e,T.from(i.result),function(e){e&&"EEXIST"!==e.code?a(e):(console.log("Writed file "+t.name+" "+i.result.byteLength),n())})})})}function s(e){return new Promise(function(t,n){x.readdir(e,function(e,a){e?n(e):t(a)})})}function c(e){BrowserFS.install(window),BrowserFS.configure({fs:"IndexedDB",options:{}},function(t){if(t)throw t;x=BrowserFS.BFSRequire("fs"),i("/project").then(function(){Promise.all([d(),p()]).then(function(t){t[0]?e&&e(t[0].glTF,t[0].filesMap,t[1]):e()}).catch(function(t){e()})},function(t){e()})})}function l(e){function t(){return i("/project/model").then(function(){return Promise.all(e.map(function(e){return o("/project/model/"+e.name,e)}))})}return r("/project/model").then(function(){return t()},function(e){return t()})}function u(e){return i("/project").then(function(){return o("/project/scene.json",new File([JSON.stringify(e)],"scene.json",{type:"application/json"}))})}function p(){return new Promise(function(e,t){if(!x)return void t(E);x.readFile("/project/scene.json","utf-8",function(t,n){if(t)e(null);else{var a=null;try{a=JSON.parse(n)}catch(e){console.error(e)}e(a)}})})}function d(){return m().then(function(e){return v(e)})}function f(e){return i("/project/model").then(function(){return o("/project/model/"+e.name,e)})}function h(){return r("/project")}function m(){return s("/project/model").then(function(e){return Promise.all(e.map(function(e){return new Promise(function(t,n){x.readFile("/project/model/"+e,function(i,r){i?n(i):t(new File([r],e,{type:b.a.lookup(a(e))}))})})}))})}function v(e){return new Promise(function(t,n){function a(n,a,o){function s(t){var n=0;e.forEach(function(e){e!==i&&(n++,l[e.name]=URL.createObjectURL(e))}),t&&t(l)}e=e.filter(function(e){return e.name.match(/.(gltf|bin|glb)$/)||e.type.match(/image/)});for(var c in w)URL.revokeObjectURL(w[c]);var l={};w=l,a?s(function(i){e.push(new File([a],n+".gltf",{type:"application/json"}),new File([o],n+".bin",{type:"application/octet-stream"})),t({glTF:JSON.parse(a),filesMap:i,buffers:[o],allFiles:e})}):r?FileAPI.readAsArrayBuffer(r,function(n){"load"===n.type&&s(function(a){t({glTF:n.result,filesMap:a,allFiles:e})})}):i&&FileAPI.readAsText(i,"utf-8",function(n){if("load"===n.type){var a;try{a=JSON.parse(n.result)}catch(e){return void t(null)}s(function(n){t({glTF:a,filesMap:n,allFiles:e})})}})}var i=e.find(function(e){return e.name.endsWith(".gltf")}),r=e.find(function(e){return e.name.endsWith(".glb")});if(i||r)a();else{n("No glTF file found")}})}function _(e,t,n){Promise.all([m(),p()]).then(function(a){var i,r=a[0],o=a[1],s=new JSZip,c={};if(r=(r||[]).filter(function(e){if(!e.name.endsWith(".gltf"))return c[e.name]=e,!0;i=e}),!i)return swal("No glTF file in project!"),void(n&&n());Promise.all(o.materials.map(function(e,t){if(e.metalnessMap||e.roughnessMap){var n=c[e.metalnessMap],a=c[e.roughnessMap];return new Promise(function(i){Object(g.b)(n,a,e.metalness,e.roughness).then(function(n){var a=e.name+"$"+t+"_metallicRoughness.png",r=n.toDataURL();r=r.slice("data:image/png;base64,".length),s.file(a,r,{base64:!0}),e.metalnessMap=e.roughnessMap=a,console.log("Merged %s, %s to %s",e.metalnessMap,e.roughnessMap,a),i()})})}if(e.specularMap||e.glossinessMap){var i=c[e.specularMap],r=c[e.glossinessMap];return new Promise(function(n){Object(g.c)(i,r,e.specularColor,e.glossiness).then(function(a){var i=e.name+"$"+t+"_specularGlossiness.png",r=a.toDataURL();r=r.slice("data:image/png;base64,".length),s.file(i,r,{base64:!0}),e.specularMap=e.glossinessMap=i,console.log("Merged %s, %s to %s",e.specularMap,e.glossinessMap,i),n()})})}return null}).filter(function(e){return null!=e})).then(function(){FileAPI.readAsText(i,"utf-8",function(a){if("load"==a.type){var c=Object(g.d)(JSON.parse(a.result),o);if(c.extensionsUsed=c.extensionsUsed||[],c.extensionsUsed.indexOf("KHR_materials_pbrSpecularGlossiness")<0&&c.extensionsUsed.push("KHR_materials_pbrSpecularGlossiness"),["extensionsUsed","images","textures","samplers","animations"].forEach(function(e){c[e]&&!c[e].length&&delete c[e]}),c.textures||delete c.samplers,r=r.filter(function(e){return e.type.match(/image/)?c.images&&c.images.some(function(t){return t.uri===e.name}):!!e.name.endsWith(".bin")||void 0}),r.forEach(function(e){s.file(e.name,e)}),"glb"===e){var l=[],u=[];s.forEach(function(e,t){(e.endsWith(".bin")?l:u).push({reader:s.file(e).async("arraybuffer"),name:e})}),Promise.all([Promise.all(l.map(function(e){return e.reader})),Promise.all(u.map(function(e){return e.reader}))]).then(function(e){var n=Object(g.a)(c,e[0],e[1].reduce(function(e,t,n){return e[u[n].name]=t,e},{}));saveAs(new Blob([n],{type:"model/json-binary"}),"model.glb"),t&&t()}).catch(n)}else s.file(i.name,JSON.stringify(c,null,2)),s.generateAsync({type:"blob"}).then(function(e){saveAs(e,"model.zip"),t&&t()}).catch(n)}})})}).catch(function(e){swal(e.toString()),n&&n()})}n.d(t,"c",function(){return c}),n.d(t,"e",function(){return l}),n.d(t,"a",function(){return v}),n.d(t,"f",function(){return u}),n.d(t,"g",function(){return f}),n.d(t,"d",function(){return h}),n.d(t,"b",function(){return _});var x,g=(n(37),n(143)),y=(n(144),n(145)),b=n.n(y),T=BrowserFS.BFSRequire("buffer").Buffer,E="File system not prepared yet.",w={}},function(e,t,n){"use strict";function a(e,t){return new Promise(function(t,n){Promise.all(e.map(function(e){var t=e&&URL.createObjectURL(e);return new Promise(function(e,n){if(t){var a=new Image;a.src=t,a.onload=function(){e(a)}}else e(null)})})).then(function(e){var n=e.find(function(e){return null!=e});n||t(null);var a=document.createElement("canvas"),i=a.getContext("2d"),r=a.width=n.width,o=a.height=n.height,s=e.map(function(e){return e?(i.drawImage(e,0,0,r,o),i.getImageData(0,0,r,o).data):null});t({canvas:a,imageDataList:s})})})}function i(e,t,n,i){return new Promise(function(r,o){a([e,t]).then(function(e){for(var t=e.canvas,a=t.getContext("2d"),o=e.imageDataList[0],s=e.imageDataList[1],c=a.createImageData(t.width,t.height),l=0;l<(o||s).length;l+=4){var u=n;if(o){var p=o[l+2]/255;u=Math.min(Math.max(p+2*(u-.5),0),1)}var d=i;if(s){var f=s[l+1]/255;d=Math.min(Math.max(f+2*(d-.5),0),1)}c.data[l]=c.data[l+3]=0,c.data[l+1]=Math.round(255*d),c.data[l+2]=Math.round(255*u)}a.putImageData(c,0,0),r(t)})})}function r(e,t,n,i){return n=d.a.parseColor(n).slice(0,3),new Promise(function(r,o){a([e,t]).then(function(e){for(var t=e.canvas,a=t.getContext("2d"),o=e.imageDataList[0],s=e.imageDataList[1],c=a.createImageData(t.width,t.height),l=0;l<(o||s).length;l+=4){var u=n.slice();o&&(u[0]*=o[l]/255,u[1]*=o[l+1]/255,u[2]*=o[l+2]/255);var p=i;if(s){var d=s[l+3]/255;p=Math.min(Math.max(d+2*(p-.5),0),1)}for(var f=0;f<3;f++)c.data[l+f]=Math.round(255*u[f]);c.data[l+3]=Math.round(255*p)}a.putImageData(c,0,0),r(t)})})}function o(e,t){var n={},a=0;return e.images=[],e.textures=[],e.samplers=[{minFilter:h.a.LINEAR_MIPMAP_LINEAR,magFilter:h.a.LINEAR,wrapS:h.a.REPEAT,wrapT:h.a.REPEAT}],t.materials.forEach(function(t,i){m.forEach(function(i){t[i]&&!n.hasOwnProperty(i)&&(e.images.push({uri:t[i]}),e.textures.push({sampler:0,source:a}),n[t[i]]=a++)})}),n}function s(e,t){var n={baseColorFactor:d.a.parseColor(e.color),metallicFactor:e.metalness,roughnessFactor:e.roughness};return n.baseColorFactor[3]=e.alpha,e.diffuseMap&&(n.baseColorTexture={index:t[e.diffuseMap],texCoord:0}),e.metalnessMap&&(n.metallicRoughnessTexture={index:t[e.metalnessMap],texCoord:0},n.metallicFactor=1,n.roughnessFactor=1),n}function c(e,t){var n={diffuseFactor:d.a.parseColor(e.color),specularFactor:d.a.parseColor(e.specularColor).slice(0,3),glossinessFactor:e.glossiness};return n.diffuseFactor[3]=e.alpha,e.diffuseMap&&(n.diffuseTexture={index:t[e.diffuseMap],texCoord:0}),e.specularMap&&(n.specularGlossinessTexture={index:t[e.specularMap],texCoord:0},n.specularFactor=[1,1,1],n.glossinessFactor=1),n}function l(e,t){if(e.materials){var n=o(e,t),a={};return e.materials=[],e.nodes.forEach(function(t,n){if(null!=t.mesh){var i=e.meshes[t.mesh];1===i.primitives.length?a[t.name]=i.primitives[0]:i.primitives.forEach(function(n,i){a[f.a.generateMeshName(e.meshes,t.mesh,i)]=n})}}),t.materials.forEach(function(t,i){var r={name:t.name,emissiveFactor:d.a.parseColor(t.emission).slice(0,3).map(function(e){return e*t.emissionIntensity})};t.normalMap&&(r.normalTexture={texCoord:0,scale:1,index:n[t.normalMap]}),t.emissiveMap&&(r.emissiveTexture={texCoord:0,index:n[t.emissiveMap]}),"pbrMetallicRoughness"===t.type?r.pbrMetallicRoughness=s(t,n):r.extensions={KHR_materials_pbrSpecularGlossiness:c(t,n)},t.targetMeshes.forEach(function(e){a[e].material=i}),e.materials[i]=r}),e.extras=e.extras||{},e.extras.qtekModelViewerConfig=t,e}}function u(e,t,n){function a(e){return 4*Math.ceil(e/4)}var i=0,r=[],o=t.slice();e.buffers.forEach(function(e){r.push(i),i+=a(e.byteLength),delete e.uri}),e.bufferViews.forEach(function(e){null==e.byteOffset?e.byteOffset=0:e.byteOffset=e.byteOffset+r[e.buffer]}),(e.images||[]).forEach(function(t,s){var c=t.uri,l=n[c];if(delete t.uri,l){var u={buffer:0,byteOffset:i,byteLength:l.byteLength};r.push(i),i+=a(l.byteLength),t.bufferView=e.bufferViews.length,t.mimeType=p(c),e.bufferViews.push(u),o.push(l)}});var s=i;e.buffers=[{byteLength:s}];var c,l=new TextEncoder,u=l.encode(JSON.stringify(e)),d=a(u.length);d!==u.length&&(c=d-u.length);var f=20+d+8+s,h=new ArrayBuffer(f),m=new DataView(h),v=0;m.setUint32(v,1179937895,!0),v+=4,m.setUint32(v,2,!0),v+=4,m.setUint32(v,f,!0),v+=4,m.setUint32(v,d,!0),v+=4,m.setUint32(v,1313821514,!0),v+=4;for(var _=0;_=0;a--){var i=e[a];"."===i?e.splice(a,1):".."===i?(e.splice(a,1),n++):n&&(e.splice(a,1),n--)}if(t)for(;n--;n)e.unshift("..");return e}function a(e,t){if(e.filter)return e.filter(t);for(var n=[],a=0;a=-1&&!i;r--){var o=r>=0?arguments[r]:e.cwd();if("string"!=typeof o)throw new TypeError("Arguments to path.resolve must be strings");o&&(t=o+"/"+t,i="/"===o.charAt(0))}return t=n(a(t.split("/"),function(e){return!!e}),!i).join("/"),(i?"/":"")+t||"."},t.normalize=function(e){var i=t.isAbsolute(e),r="/"===o(e,-1);return e=n(a(e.split("/"),function(e){return!!e}),!i).join("/"),e||i||(e="."),e&&r&&(e+="/"),(i?"/":"")+e},t.isAbsolute=function(e){return"/"===e.charAt(0)},t.join=function(){var e=Array.prototype.slice.call(arguments,0);return t.normalize(a(e,function(e,t){if("string"!=typeof e)throw new TypeError("Arguments to path.join must be strings");return e}).join("/"))},t.relative=function(e,n){function a(e){for(var t=0;t=0&&""===e[n];n--);return t>n?[]:e.slice(t,n-t+1)}e=t.resolve(e).substr(1),n=t.resolve(n).substr(1);for(var i=a(e.split("/")),r=a(n.split("/")),o=Math.min(i.length,r.length),s=o,c=0;c1)for(var n=1;n=0;a--){var i=e[a];"."===i?e.splice(a,1):".."===i?(e.splice(a,1),n++):n&&(e.splice(a,1),n--)}if(t)for(;n--;n)e.unshift("..");return e}function a(e,t){if(e.filter)return e.filter(t);for(var n=[],a=0;a=-1&&!i;r--){var o=r>=0?arguments[r]:e.cwd();if("string"!=typeof o)throw new TypeError("Arguments to path.resolve must be strings");o&&(t=o+"/"+t,i="/"===o.charAt(0))}return t=n(a(t.split("/"),function(e){return!!e}),!i).join("/"),(i?"/":"")+t||"."},t.normalize=function(e){var i=t.isAbsolute(e),r="/"===o(e,-1);return e=n(a(e.split("/"),function(e){return!!e}),!i).join("/"),e||i||(e="."),e&&r&&(e+="/"),(i?"/":"")+e},t.isAbsolute=function(e){return"/"===e.charAt(0)},t.join=function(){var e=Array.prototype.slice.call(arguments,0);return t.normalize(a(e,function(e,t){if("string"!=typeof e)throw new TypeError("Arguments to path.join must be strings");return e}).join("/"))},t.relative=function(e,n){function a(e){for(var t=0;t=0&&""===e[n];n--);return t>n?[]:e.slice(t,n-t+1)}e=t.resolve(e).substr(1),n=t.resolve(n).substr(1);for(var i=a(e.split("/")),r=a(n.split("/")),o=Math.min(i.length,r.length),s=o,c=0;c1)for(var n=1;n