!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.claraplayer=t():e.claraplayer=t()}(this,function(){return function(e){function t(r){if(n[r])return n[r].exports;var i=n[r]={i:r,l:!1,exports:{}};return e[r].call(i.exports,i,i.exports,t),i.l=!0,i.exports}var r=window.webpackJsonp_name_;window.webpackJsonp_name_=function(t,n,a){for(var o,s,l=0,u=[];l0&&console.error("THREE.Matrix4: the constructor no longer reads arguments. use .set() instead.")}function o(e,t,r,n){this._x=e||0,this._y=t||0,this._z=r||0,this._w=void 0!==n?n:1}function s(e,t,r){this.x=e||0,this.y=t||0,this.z=r||0}function l(e,t,r,n){this.x=e||0,this.y=t||0,this.z=r||0,this.w=void 0!==n?n:1}function u(e,t,r){return void 0===t&&void 0===r?this.set(e):this.setRGB(e,t,r)}function c(){this.elements=new Float32Array([1,0,0,0,1,0,0,0,1]),arguments.length>0&&console.error("THREE.Matrix3: the constructor no longer reads arguments. use .set() instead.")}function f(e,t){this.start=void 0!==e?e:new s,this.end=void 0!==t?t:new s}function d(e,t){this.normal=void 0!==e?e:new s(1,0,0),this.constant=void 0!==t?t:0}function h(e,t,r){this.a=void 0!==e?e:new s,this.b=void 0!==t?t:new s,this.c=void 0!==r?r:new s}function p(e,t){this.center=void 0!==e?e:new s,this.radius=void 0!==t?t:0}function m(e,t){this.min=void 0!==e?e:new s(1/0,1/0,1/0),this.max=void 0!==t?t:new s(-1/0,-1/0,-1/0)}function g(e,t,r,n){this._x=e||0,this._y=t||0,this._z=r||0,this._order=n||g.DefaultOrder}function v(e,t){this.origin=void 0!==e?e:new s,this.direction=void 0!==t?t:new s}function y(e,t,r){return this.radius=void 0!==e?e:1,this.phi=void 0!==t?t:0,this.theta=void 0!==r?r:0,this}var x=r(287),b=n(x),w=r(2),_=n(w);Object.defineProperty(t,"__esModule",{value:!0}),i.prototype={constructor:i,isVector2:!0,get width(){return this.x},set width(e){this.x=e},get height(){return this.y},set height(e){this.y=e},set:function(e,t){return this.x=e,this.y=t,this},setScalar:function(e){return this.x=e,this.y=e,this},setX:function(e){return this.x=e,this},setY:function(e){return this.y=e,this},setComponent:function(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("index is out of range: "+e)}return this},getComponent:function(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("index is out of range: "+e)}},clone:function(){return new this.constructor(this.x,this.y)},copy:function(e){return this.x=e.x,this.y=e.y,this},add:function(e,t){return void 0!==t?(console.warn("THREE.Vector2: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(e,t)):(this.x+=e.x,this.y+=e.y,this)},addScalar:function(e){return this.x+=e,this.y+=e,this},addVectors:function(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this},addScaledVector:function(e,t){return this.x+=e.x*t,this.y+=e.y*t,this},sub:function(e,t){return void 0!==t?(console.warn("THREE.Vector2: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(e,t)):(this.x-=e.x,this.y-=e.y,this)},subScalar:function(e){return this.x-=e,this.y-=e,this},subVectors:function(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this},multiply:function(e){return this.x*=e.x,this.y*=e.y,this},multiplyScalar:function(e){return isFinite(e)?(this.x*=e,this.y*=e):(this.x=0,this.y=0),this},divide:function(e){return this.x/=e.x,this.y/=e.y,this},divideScalar:function(e){return this.multiplyScalar(1/e)},min:function(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this},max:function(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this},clamp:function(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this},clampScalar:function(){var e,t;return function(r,n){return void 0===e&&(e=new i,t=new i),e.set(r,r),t.set(n,n),this.clamp(e,t)}}(),clampLength:function(e,t){var r=this.length();return this.multiplyScalar(Math.max(e,Math.min(t,r))/r)},floor:function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this},ceil:function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this},round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this},roundToZero:function(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this},negate:function(){return this.x=-this.x,this.y=-this.y,this},dot:function(e){return this.x*e.x+this.y*e.y},lengthSq:function(){return this.x*this.x+this.y*this.y},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},lengthManhattan:function(){return Math.abs(this.x)+Math.abs(this.y)},normalize:function(){return this.divideScalar(this.length())},angle:function(){var e=Math.atan2(this.y,this.x);return e<0&&(e+=2*Math.PI),e},distanceTo:function(e){return Math.sqrt(this.distanceToSquared(e))},distanceToSquared:function(e){var t=this.x-e.x,r=this.y-e.y;return t*t+r*r},distanceToManhattan:function(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)},setLength:function(e){return this.multiplyScalar(e/this.length())},lerp:function(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this},lerpVectors:function(e,t,r){return this.subVectors(t,e).multiplyScalar(r).add(e)},equals:function(e){return e.x===this.x&&e.y===this.y},fromArray:function(e,t){return void 0===t&&(t=0),this.x=e[t],this.y=e[t+1],this},toArray:function(e,t){return void 0===e&&(e=[]),void 0===t&&(t=0),e[t]=this.x,e[t+1]=this.y,e},fromBufferAttribute:function(e,t,r){return void 0!==r&&console.warn("THREE.Vector2: offset has been removed from .fromBufferAttribute()."),this.x=e.getX(t),this.y=e.getY(t),this},rotateAround:function(e,t){var r=Math.cos(t),n=Math.sin(t),i=this.x-e.x,a=this.y-e.y;return this.x=i*r-a*n+e.x,this.y=i*n+a*r+e.y,this}};var M={DEG2RAD:Math.PI/180,RAD2DEG:180/Math.PI,generateUUID:function(){var e,t="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split(""),r=new Array(36),n=0;return function(){for(var i=0;i<36;i++)8===i||13===i||18===i||23===i?r[i]="-":14===i?r[i]="4":(n<=2&&(n=33554432+16777216*Math.random()|0),e=15&n,n>>=4,r[i]=t[19===i?3&e|8:e]);return r.join("")}}(),clamp:function(e,t,r){return Math.max(t,Math.min(r,e))},euclideanModulo:function(e,t){return(e%t+t)%t},mapLinear:function(e,t,r,n,i){return n+(e-t)*(i-n)/(r-t)},lerp:function(e,t,r){return(1-r)*e+r*t},smoothstep:function(e,t,r){return e<=t?0:e>=r?1:(e=(e-t)/(r-t))*e*(3-2*e)},smootherstep:function(e,t,r){return e<=t?0:e>=r?1:(e=(e-t)/(r-t))*e*e*(e*(6*e-15)+10)},randInt:function(e,t){return e+Math.floor(Math.random()*(t-e+1))},randFloat:function(e,t){return e+Math.random()*(t-e)},randFloatSpread:function(e){return e*(.5-Math.random())},degToRad:function(e){return e*M.DEG2RAD},radToDeg:function(e){return e*M.RAD2DEG},isPowerOfTwo:function(e){return 0==(e&e-1)&&0!==e},nearestPowerOfTwo:function(e){return Math.pow(2,Math.round(Math.log(e)/Math.LN2))},nextPowerOfTwo:function(e){return e--,e|=e>>1,e|=e>>2,e|=e>>4,e|=e>>8,e|=e>>16,++e}};a.prototype={constructor:a,isMatrix4:!0,set:function(e,t,r,n,i,a,o,s,l,u,c,f,d,h,p,m){var g=this.elements;return g[0]=e,g[4]=t,g[8]=r,g[12]=n,g[1]=i,g[5]=a,g[9]=o,g[13]=s,g[2]=l,g[6]=u,g[10]=c,g[14]=f,g[3]=d,g[7]=h,g[11]=p,g[15]=m,this},identity:function(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this},clone:function(){return(new a).fromArray(this.elements)},copy:function(e){return this.elements.set(e.elements),this},copyPosition:function(e){var t=this.elements,r=e.elements;return t[12]=r[12],t[13]=r[13],t[14]=r[14],this},extractBasis:function(e,t,r){return e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),r.setFromMatrixColumn(this,2),this},makeBasis:function(e,t,r){return this.set(e.x,t.x,r.x,0,e.y,t.y,r.y,0,e.z,t.z,r.z,0,0,0,0,1),this},extractRotation:function(){var e;return function(t){void 0===e&&(e=new s);var r=this.elements,n=t.elements,i=1/e.setFromMatrixColumn(t,0).length(),a=1/e.setFromMatrixColumn(t,1).length(),o=1/e.setFromMatrixColumn(t,2).length();return r[0]=n[0]*i,r[1]=n[1]*i,r[2]=n[2]*i,r[4]=n[4]*a,r[5]=n[5]*a,r[6]=n[6]*a,r[8]=n[8]*o,r[9]=n[9]*o,r[10]=n[10]*o,this}}(),makeRotationFromEuler:function(e){!1===(e&&e.isEuler)&&console.error("THREE.Matrix: .makeRotationFromEuler() now expects a Euler rotation rather than a Vector3 and order.");var t=this.elements,r=e.x,n=e.y,i=e.z,a=Math.cos(r),o=Math.sin(r),s=Math.cos(n),l=Math.sin(n),u=Math.cos(i),c=Math.sin(i);if("XYZ"===e.order){var f=a*u,d=a*c,h=o*u,p=o*c;t[0]=s*u,t[4]=-s*c,t[8]=l,t[1]=d+h*l,t[5]=f-p*l,t[9]=-o*s,t[2]=p-f*l,t[6]=h+d*l,t[10]=a*s}else if("YXZ"===e.order){var m=s*u,g=s*c,v=l*u,y=l*c;t[0]=m+y*o,t[4]=v*o-g,t[8]=a*l,t[1]=a*c,t[5]=a*u,t[9]=-o,t[2]=g*o-v,t[6]=y+m*o,t[10]=a*s}else if("ZXY"===e.order){var m=s*u,g=s*c,v=l*u,y=l*c;t[0]=m-y*o,t[4]=-a*c,t[8]=v+g*o,t[1]=g+v*o,t[5]=a*u,t[9]=y-m*o,t[2]=-a*l,t[6]=o,t[10]=a*s}else if("ZYX"===e.order){var f=a*u,d=a*c,h=o*u,p=o*c;t[0]=s*u,t[4]=h*l-d,t[8]=f*l+p,t[1]=s*c,t[5]=p*l+f,t[9]=d*l-h,t[2]=-l,t[6]=o*s,t[10]=a*s}else if("YZX"===e.order){var x=a*s,b=a*l,w=o*s,_=o*l;t[0]=s*u,t[4]=_-x*c,t[8]=w*c+b,t[1]=c,t[5]=a*u,t[9]=-o*u,t[2]=-l*u,t[6]=b*c+w,t[10]=x-_*c}else if("XZY"===e.order){var x=a*s,b=a*l,w=o*s,_=o*l;t[0]=s*u,t[4]=-c,t[8]=l*u,t[1]=x*c+_,t[5]=a*u,t[9]=b*c-w,t[2]=w*c-b,t[6]=o*u,t[10]=_*c+x}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this},makeRotationFromQuaternion:function(e){var t=this.elements,r=e.x,n=e.y,i=e.z,a=e.w,o=r+r,s=n+n,l=i+i,u=r*o,c=r*s,f=r*l,d=n*s,h=n*l,p=i*l,m=a*o,g=a*s,v=a*l;return t[0]=1-(d+p),t[4]=c-v,t[8]=f+g,t[1]=c+v,t[5]=1-(u+p),t[9]=h-m,t[2]=f-g,t[6]=h+m,t[10]=1-(u+d),t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this},lookAt:function(){var e,t,r;return function(n,i,a){void 0===e&&(e=new s,t=new s,r=new s);var o=this.elements;return r.subVectors(n,i).normalize(),0===r.lengthSq()&&(r.z=1),e.crossVectors(a,r).normalize(),0===e.lengthSq()&&(r.z+=1e-4,e.crossVectors(a,r).normalize()),t.crossVectors(r,e),o[0]=e.x,o[4]=t.x,o[8]=r.x,o[1]=e.y,o[5]=t.y,o[9]=r.y,o[2]=e.z,o[6]=t.z,o[10]=r.z,this}}(),multiply:function(e,t){return void 0!==t?(console.warn("THREE.Matrix4: .multiply() now only accepts one argument. Use .multiplyMatrices( a, b ) instead."),this.multiplyMatrices(e,t)):this.multiplyMatrices(this,e)},premultiply:function(e){return this.multiplyMatrices(e,this)},multiplyMatrices:function(e,t){var r=e.elements,n=t.elements,i=this.elements,a=r[0],o=r[4],s=r[8],l=r[12],u=r[1],c=r[5],f=r[9],d=r[13],h=r[2],p=r[6],m=r[10],g=r[14],v=r[3],y=r[7],x=r[11],b=r[15],w=n[0],_=n[4],M=n[8],S=n[12],T=n[1],E=n[5],P=n[9],A=n[13],C=n[2],I=n[6],R=n[10],O=n[14],L=n[3],D=n[7],V=n[11],N=n[15];return i[0]=a*w+o*T+s*C+l*L,i[4]=a*_+o*E+s*I+l*D,i[8]=a*M+o*P+s*R+l*V,i[12]=a*S+o*A+s*O+l*N,i[1]=u*w+c*T+f*C+d*L,i[5]=u*_+c*E+f*I+d*D,i[9]=u*M+c*P+f*R+d*V,i[13]=u*S+c*A+f*O+d*N,i[2]=h*w+p*T+m*C+g*L,i[6]=h*_+p*E+m*I+g*D,i[10]=h*M+p*P+m*R+g*V,i[14]=h*S+p*A+m*O+g*N,i[3]=v*w+y*T+x*C+b*L,i[7]=v*_+y*E+x*I+b*D,i[11]=v*M+y*P+x*R+b*V,i[15]=v*S+y*A+x*O+b*N,this},multiplyToArray:function(e,t,r){var n=this.elements;return this.multiplyMatrices(e,t),r[0]=n[0],r[1]=n[1],r[2]=n[2],r[3]=n[3],r[4]=n[4],r[5]=n[5],r[6]=n[6],r[7]=n[7],r[8]=n[8],r[9]=n[9],r[10]=n[10],r[11]=n[11],r[12]=n[12],r[13]=n[13],r[14]=n[14],r[15]=n[15],this},multiplyScalar:function(e){var t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this},applyToBufferAttribute:function(){var e;return function(t){void 0===e&&(e=new s);for(var r=0,n=t.count;r0?(t=.5/Math.sqrt(d+1),this._w=.25/t,this._x=(c-l)*t,this._y=(a-u)*t,this._z=(o-i)*t):n>s&&n>f?(t=2*Math.sqrt(1+n-s-f),this._w=(c-l)/t,this._x=.25*t,this._y=(i+o)/t,this._z=(a+u)/t):s>f?(t=2*Math.sqrt(1+s-n-f),this._w=(a-u)/t,this._x=(i+o)/t,this._y=.25*t,this._z=(l+c)/t):(t=2*Math.sqrt(1+f-n-s),this._w=(o-i)/t,this._x=(a+u)/t,this._y=(l+c)/t,this._z=.25*t),this.onChangeCallback(),this},setFromUnitVectors:function(){var e,t;return function(r,n){return void 0===e&&(e=new s),t=r.dot(n)+1,t<1e-6?(t=0,Math.abs(r.x)>Math.abs(r.z)?e.set(-r.y,r.x,0):e.set(0,-r.z,r.y)):e.crossVectors(r,n),this._x=e.x,this._y=e.y,this._z=e.z,this._w=t,this.normalize()}}(),inverse:function(){return this.conjugate().normalize()},conjugate:function(){return this._x*=-1,this._y*=-1,this._z*=-1,this.onChangeCallback(),this},dot:function(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w},lengthSq:function(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w},length:function(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)},normalize:function(){var e=this.length();return 0===e?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this.onChangeCallback(),this},multiply:function(e,t){return void 0!==t?(console.warn("THREE.Quaternion: .multiply() now only accepts one argument. Use .multiplyQuaternions( a, b ) instead."),this.multiplyQuaternions(e,t)):this.multiplyQuaternions(this,e)},premultiply:function(e){return this.multiplyQuaternions(e,this)},multiplyQuaternions:function(e,t){var r=e._x,n=e._y,i=e._z,a=e._w,o=t._x,s=t._y,l=t._z,u=t._w;return this._x=r*u+a*o+n*l-i*s,this._y=n*u+a*s+i*o-r*l,this._z=i*u+a*l+r*s-n*o,this._w=a*u-r*o-n*s-i*l,this.onChangeCallback(),this},slerp:function(e,t){if(0===t)return this;if(1===t)return this.copy(e);var r=this._x,n=this._y,i=this._z,a=this._w,o=a*e._w+r*e._x+n*e._y+i*e._z;if(o<0?(this._w=-e._w,this._x=-e._x,this._y=-e._y,this._z=-e._z,o=-o):this.copy(e),o>=1)return this._w=a,this._x=r,this._y=n,this._z=i,this;var s=Math.sqrt(1-o*o);if(Math.abs(s)<.001)return this._w=.5*(a+this._w),this._x=.5*(r+this._x),this._y=.5*(n+this._y),this._z=.5*(i+this._z),this;var l=Math.atan2(s,o),u=Math.sin((1-t)*l)/s,c=Math.sin(t*l)/s;return this._w=a*u+this._w*c,this._x=r*u+this._x*c,this._y=n*u+this._y*c,this._z=i*u+this._z*c,this.onChangeCallback(),this},equals:function(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w},fromArray:function(e,t){return void 0===t&&(t=0),this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this.onChangeCallback(),this},toArray:function(e,t){return void 0===e&&(e=[]),void 0===t&&(t=0),e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e},onChange:function(e){return this.onChangeCallback=e,this},onChangeCallback:function(){}},(0,_.default)(o,{slerp:function(e,t,r,n){return r.copy(e).slerp(t,n)},slerpFlat:function(e,t,r,n,i,a,o){var s=r[n+0],l=r[n+1],u=r[n+2],c=r[n+3],f=i[a+0],d=i[a+1],h=i[a+2],p=i[a+3];if(c!==p||s!==f||l!==d||u!==h){var m=1-o,g=s*f+l*d+u*h+c*p,v=g>=0?1:-1,y=1-g*g;if(y>b.default){var x=Math.sqrt(y),w=Math.atan2(x,g*v);m=Math.sin(m*w)/x,o=Math.sin(o*w)/x}var _=o*v;if(s=s*m+f*_,l=l*m+d*_,u=u*m+h*_,c=c*m+p*_,m===1-o){var M=1/Math.sqrt(s*s+l*l+u*u+c*c);s*=M,l*=M,u*=M,c*=M}}e[t]=s,e[t+1]=l,e[t+2]=u,e[t+3]=c}}),s.prototype={constructor:s,isVector3:!0,set:function(e,t,r){return this.x=e,this.y=t,this.z=r,this},setScalar:function(e){return this.x=e,this.y=e,this.z=e,this},setX:function(e){return this.x=e,this},setY:function(e){return this.y=e,this},setZ:function(e){return this.z=e,this},setComponent:function(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("index is out of range: "+e)}return this},getComponent:function(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("index is out of range: "+e)}},clone:function(){return new this.constructor(this.x,this.y,this.z)},copy:function(e){return this.x=e.x,this.y=e.y,this.z=e.z,this},add:function(e,t){return void 0!==t?(console.warn("THREE.Vector3: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(e,t)):(this.x+=e.x,this.y+=e.y,this.z+=e.z,this)},addScalar:function(e){return this.x+=e,this.y+=e,this.z+=e,this},addVectors:function(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this},addScaledVector:function(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this},sub:function(e,t){return void 0!==t?(console.warn("THREE.Vector3: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(e,t)):(this.x-=e.x,this.y-=e.y,this.z-=e.z,this)},subScalar:function(e){return this.x-=e,this.y-=e,this.z-=e,this},subVectors:function(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this},multiply:function(e,t){return void 0!==t?(console.warn("THREE.Vector3: .multiply() now only accepts one argument. Use .multiplyVectors( a, b ) instead."),this.multiplyVectors(e,t)):(this.x*=e.x,this.y*=e.y,this.z*=e.z,this)},multiplyScalar:function(e){return isFinite(e)?(this.x*=e,this.y*=e,this.z*=e):(this.x=0,this.y=0,this.z=0),this},multiplyVectors:function(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this},applyEuler:function(){var e;return function(t){return!1===(t&&t.isEuler)&&console.error("THREE.Vector3: .applyEuler() now expects an Euler rotation rather than a Vector3 and order."),void 0===e&&(e=new o),this.applyQuaternion(e.setFromEuler(t))}}(),applyAxisAngle:function(){var e;return function(t,r){return void 0===e&&(e=new o),this.applyQuaternion(e.setFromAxisAngle(t,r))}}(),applyMatrix3:function(e){var t=this.x,r=this.y,n=this.z,i=e.elements;return this.x=i[0]*t+i[3]*r+i[6]*n,this.y=i[1]*t+i[4]*r+i[7]*n,this.z=i[2]*t+i[5]*r+i[8]*n,this},applyMatrix4:function(e){var t=this.x,r=this.y,n=this.z,i=e.elements;this.x=i[0]*t+i[4]*r+i[8]*n+i[12],this.y=i[1]*t+i[5]*r+i[9]*n+i[13],this.z=i[2]*t+i[6]*r+i[10]*n+i[14];var a=i[3]*t+i[7]*r+i[11]*n+i[15];return this.divideScalar(a)},applyQuaternion:function(e){var t=this.x,r=this.y,n=this.z,i=e.x,a=e.y,o=e.z,s=e.w,l=s*t+a*n-o*r,u=s*r+o*t-i*n,c=s*n+i*r-a*t,f=-i*t-a*r-o*n;return this.x=l*s+f*-i+u*-o-c*-a,this.y=u*s+f*-a+c*-i-l*-o,this.z=c*s+f*-o+l*-a-u*-i,this},project:function(){var e;return function(t){return void 0===e&&(e=new a),e.multiplyMatrices(t.projectionMatrix,e.getInverse(t.matrixWorld)),this.applyMatrix4(e)}}(),unproject:function(){var e;return function(t){return void 0===e&&(e=new a),e.multiplyMatrices(t.matrixWorld,e.getInverse(t.projectionMatrix)),this.applyMatrix4(e)}}(),transformDirection:function(e){var t=this.x,r=this.y,n=this.z,i=e.elements;return this.x=i[0]*t+i[4]*r+i[8]*n,this.y=i[1]*t+i[5]*r+i[9]*n,this.z=i[2]*t+i[6]*r+i[10]*n,this.normalize()},divide:function(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this},divideScalar:function(e){return this.multiplyScalar(1/e)},min:function(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this},max:function(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this},clamp:function(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this},clampScalar:function(){var e,t;return function(r,n){return void 0===e&&(e=new s,t=new s),e.set(r,r,r),t.set(n,n,n),this.clamp(e,t)}}(),clampLength:function(e,t){var r=this.length();return this.multiplyScalar(Math.max(e,Math.min(t,r))/r)},floor:function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this},ceil:function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this},round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this},roundToZero:function(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this},negate:function(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this},dot:function(e){return this.x*e.x+this.y*e.y+this.z*e.z},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},lengthManhattan:function(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)},normalize:function(){return this.divideScalar(this.length())},setLength:function(e){return this.multiplyScalar(e/this.length())},lerp:function(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this},lerpVectors:function(e,t,r){return this.subVectors(t,e).multiplyScalar(r).add(e)},cross:function(e,t){if(void 0!==t)return console.warn("THREE.Vector3: .cross() now only accepts one argument. Use .crossVectors( a, b ) instead."),this.crossVectors(e,t);var r=this.x,n=this.y,i=this.z;return this.x=n*e.z-i*e.y,this.y=i*e.x-r*e.z,this.z=r*e.y-n*e.x,this},crossVectors:function(e,t){var r=e.x,n=e.y,i=e.z,a=t.x,o=t.y,s=t.z;return this.x=n*s-i*o,this.y=i*a-r*s,this.z=r*o-n*a,this},projectOnVector:function(e){var t=e.dot(this)/e.lengthSq();return this.copy(e).multiplyScalar(t)},projectOnPlane:function(){var e;return function(t){return void 0===e&&(e=new s),e.copy(this).projectOnVector(t),this.sub(e)}}(),reflect:function(){var e;return function(t){return void 0===e&&(e=new s),this.sub(e.copy(t).multiplyScalar(2*this.dot(t)))}}(),angleTo:function(e){var t=this.dot(e)/Math.sqrt(this.lengthSq()*e.lengthSq());return Math.acos(M.clamp(t,-1,1))},distanceTo:function(e){return Math.sqrt(this.distanceToSquared(e))},distanceToSquared:function(e){var t=this.x-e.x,r=this.y-e.y,n=this.z-e.z;return t*t+r*r+n*n},distanceToManhattan:function(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)},setFromSpherical:function(e){var t=Math.sin(e.phi)*e.radius;return this.x=t*Math.sin(e.theta),this.y=Math.cos(e.phi)*e.radius,this.z=t*Math.cos(e.theta),this},setFromCylindrical:function(e){return this.x=e.radius*Math.sin(e.theta),this.y=e.y,this.z=e.radius*Math.cos(e.theta),this},setFromMatrixPosition:function(e){return this.setFromMatrixColumn(e,3)},setFromMatrixScale:function(e){var t=this.setFromMatrixColumn(e,0).length(),r=this.setFromMatrixColumn(e,1).length(),n=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=r,this.z=n,this},setFromMatrixColumn:function(e,t){if("number"==typeof e){console.warn("THREE.Vector3: setFromMatrixColumn now expects ( matrix, index ).");var r=e;e=t,t=r}return this.fromArray(e.elements,4*t)},equals:function(e){return e.x===this.x&&e.y===this.y&&e.z===this.z},fromArray:function(e,t){return void 0===t&&(t=0),this.x=e[t],this.y=e[t+1],this.z=e[t+2],this},toArray:function(e,t){return void 0===e&&(e=[]),void 0===t&&(t=0),e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e},fromBufferAttribute:function(e,t,r){return void 0!==r&&console.warn("THREE.Vector3: offset has been removed from .fromBufferAttribute()."),this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}},l.prototype={constructor:l,isVector4:!0,set:function(e,t,r,n){return this.x=e,this.y=t,this.z=r,this.w=n,this},setScalar:function(e){return this.x=e,this.y=e,this.z=e,this.w=e,this},setX:function(e){return this.x=e,this},setY:function(e){return this.y=e,this},setZ:function(e){return this.z=e,this},setW:function(e){return this.w=e,this},setComponent:function(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;case 3:this.w=t;break;default:throw new Error("index is out of range: "+e)}return this},getComponent:function(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw new Error("index is out of range: "+e)}},clone:function(){return new this.constructor(this.x,this.y,this.z,this.w)},copy:function(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=void 0!==e.w?e.w:1,this},add:function(e,t){return void 0!==t?(console.warn("THREE.Vector4: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(e,t)):(this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this)},addScalar:function(e){return this.x+=e,this.y+=e,this.z+=e,this.w+=e,this},addVectors:function(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this.w=e.w+t.w,this},addScaledVector:function(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this.w+=e.w*t,this},sub:function(e,t){return void 0!==t?(console.warn("THREE.Vector4: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(e,t)):(this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this)},subScalar:function(e){return this.x-=e,this.y-=e,this.z-=e,this.w-=e,this},subVectors:function(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this.w=e.w-t.w,this},multiplyScalar:function(e){return isFinite(e)?(this.x*=e,this.y*=e,this.z*=e,this.w*=e):(this.x=0,this.y=0,this.z=0,this.w=0),this},applyMatrix4:function(e){var t=this.x,r=this.y,n=this.z,i=this.w,a=e.elements;return this.x=a[0]*t+a[4]*r+a[8]*n+a[12]*i,this.y=a[1]*t+a[5]*r+a[9]*n+a[13]*i,this.z=a[2]*t+a[6]*r+a[10]*n+a[14]*i,this.w=a[3]*t+a[7]*r+a[11]*n+a[15]*i,this},divideScalar:function(e){return this.multiplyScalar(1/e)},setAxisAngleFromQuaternion:function(e){this.w=2*Math.acos(e.w);var t=Math.sqrt(1-e.w*e.w);return t<1e-4?(this.x=1,this.y=0,this.z=0):(this.x=e.x/t,this.y=e.y/t,this.z=e.z/t),this},setAxisAngleFromRotationMatrix:function(e){var t,r,n,i,a=e.elements,o=a[0],s=a[4],l=a[8],u=a[1],c=a[5],f=a[9],d=a[2],h=a[6],p=a[10];if(Math.abs(s-u)<.01&&Math.abs(l-d)<.01&&Math.abs(f-h)<.01){if(Math.abs(s+u)<.1&&Math.abs(l+d)<.1&&Math.abs(f+h)<.1&&Math.abs(o+c+p-3)<.1)return this.set(1,0,0,0),this;t=Math.PI;var m=(o+1)/2,g=(c+1)/2,v=(p+1)/2,y=(s+u)/4,x=(l+d)/4,b=(f+h)/4;return m>g&&m>v?m<.01?(r=0,n=.707106781,i=.707106781):(r=Math.sqrt(m),n=y/r,i=x/r):g>v?g<.01?(r=.707106781,n=0,i=.707106781):(n=Math.sqrt(g),r=y/n,i=b/n):v<.01?(r=.707106781,n=.707106781,i=0):(i=Math.sqrt(v),r=x/i,n=b/i),this.set(r,n,i,t),this}var w=Math.sqrt((h-f)*(h-f)+(l-d)*(l-d)+(u-s)*(u-s));return Math.abs(w)<.001&&(w=1),this.x=(h-f)/w,this.y=(l-d)/w,this.z=(u-s)/w,this.w=Math.acos((o+c+p-1)/2),this},min:function(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this.w=Math.min(this.w,e.w),this},max:function(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this.w=Math.max(this.w,e.w),this},clamp:function(e,t){return this.x=Math.max(e.x,Math.min(t.x,this.x)),this.y=Math.max(e.y,Math.min(t.y,this.y)),this.z=Math.max(e.z,Math.min(t.z,this.z)),this.w=Math.max(e.w,Math.min(t.w,this.w)),this},clampScalar:function(){var e,t;return function(r,n){return void 0===e&&(e=new l,t=new l),e.set(r,r,r,r),t.set(n,n,n,n),this.clamp(e,t)}}(),floor:function(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this.w=Math.floor(this.w),this},ceil:function(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this.w=Math.ceil(this.w),this},round:function(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this.w=Math.round(this.w),this},roundToZero:function(){return this.x=this.x<0?Math.ceil(this.x):Math.floor(this.x),this.y=this.y<0?Math.ceil(this.y):Math.floor(this.y),this.z=this.z<0?Math.ceil(this.z):Math.floor(this.z),this.w=this.w<0?Math.ceil(this.w):Math.floor(this.w),this},negate:function(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this.w=-this.w,this},dot:function(e){return this.x*e.x+this.y*e.y+this.z*e.z+this.w*e.w},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},lengthManhattan:function(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)},normalize:function(){return this.divideScalar(this.length())},setLength:function(e){return this.multiplyScalar(e/this.length())},lerp:function(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this.w+=(e.w-this.w)*t,this},lerpVectors:function(e,t,r){return this.subVectors(t,e).multiplyScalar(r).add(e)},equals:function(e){return e.x===this.x&&e.y===this.y&&e.z===this.z&&e.w===this.w},fromArray:function(e,t){return void 0===t&&(t=0),this.x=e[t],this.y=e[t+1],this.z=e[t+2],this.w=e[t+3],this},toArray:function(e,t){return void 0===e&&(e=[]),void 0===t&&(t=0),e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,e},fromBufferAttribute:function(e,t,r){return void 0!==r&&console.warn("THREE.Vector4: offset has been removed from .fromBufferAttribute()."),this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this.w=e.getW(t),this}},u.prototype={constructor:u,isColor:!0,r:1,g:1,b:1,set:function(e){return e&&e.isColor?this.copy(e):"number"==typeof e?this.setHex(e):"string"==typeof e&&this.setStyle(e),this},setScalar:function(e){return this.r=e,this.g=e,this.b=e,this},setHex:function(e){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(255&e)/255,this},setRGB:function(e,t,r){return this.r=e,this.g=t,this.b=r,this},setHSL:function(){function e(e,t,r){return r<0&&(r+=1),r>1&&(r-=1),r<1/6?e+6*(t-e)*r:r<.5?t:r<2/3?e+6*(t-e)*(2/3-r):e}return function(t,r,n){if(t=M.euclideanModulo(t,1),r=M.clamp(r,0,1),n=M.clamp(n,0,1),0===r)this.r=this.g=this.b=n;else{var i=n<=.5?n*(1+r):n+r-n*r,a=2*n-i;this.r=e(a,i,t+1/3),this.g=e(a,i,t),this.b=e(a,i,t-1/3)}return this}}(),setStyle:function(e){function t(t){void 0!==t&&parseFloat(t)<1&&console.warn("THREE.Color: Alpha component of "+e+" will be ignored.")}var r;if(r=/^((?:rgb|hsl)a?)\(\s*([^\)]*)\)/.exec(e)){var n,i=r[1],a=r[2];switch(i){case"rgb":case"rgba":if(n=/^(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(a))return this.r=Math.min(255,parseInt(n[1],10))/255,this.g=Math.min(255,parseInt(n[2],10))/255,this.b=Math.min(255,parseInt(n[3],10))/255,t(n[5]),this;if(n=/^(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(a))return this.r=Math.min(100,parseInt(n[1],10))/100,this.g=Math.min(100,parseInt(n[2],10))/100,this.b=Math.min(100,parseInt(n[3],10))/100,t(n[5]),this;break;case"hsl":case"hsla":if(n=/^([0-9]*\.?[0-9]+)\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(a)){var o=parseFloat(n[1])/360,s=parseInt(n[2],10)/100,l=parseInt(n[3],10)/100;return t(n[5]),this.setHSL(o,s,l)}}}else if(r=/^\#([A-Fa-f0-9]+)$/.exec(e)){var u=r[1],c=u.length;if(3===c)return this.r=parseInt(u.charAt(0)+u.charAt(0),16)/255,this.g=parseInt(u.charAt(1)+u.charAt(1),16)/255,this.b=parseInt(u.charAt(2)+u.charAt(2),16)/255,this;if(6===c)return this.r=parseInt(u.charAt(0)+u.charAt(1),16)/255,this.g=parseInt(u.charAt(2)+u.charAt(3),16)/255,this.b=parseInt(u.charAt(4)+u.charAt(5),16)/255,this}if(e&&e.length>0){var u=S[e];void 0!==u?this.setHex(u):console.warn("THREE.Color: Unknown color "+e)}return this},clone:function(){return new this.constructor(this.r,this.g,this.b)},copy:function(e){return this.r=e.r,this.g=e.g,this.b=e.b,this},copyGammaToLinear:function(e,t){return void 0===t&&(t=2),this.r=Math.pow(e.r,t),this.g=Math.pow(e.g,t),this.b=Math.pow(e.b,t),this},copyLinearToGamma:function(e,t){void 0===t&&(t=2);var r=t>0?1/t:1;return this.r=Math.pow(e.r,r),this.g=Math.pow(e.g,r),this.b=Math.pow(e.b,r),this},convertGammaToLinear:function(){var e=this.r,t=this.g,r=this.b;return this.r=e*e,this.g=t*t,this.b=r*r,this},convertLinearToGamma:function(){return this.r=Math.sqrt(this.r),this.g=Math.sqrt(this.g),this.b=Math.sqrt(this.b),this},getHex:function(){return 255*this.r<<16^255*this.g<<8^255*this.b<<0},getHexString:function(){return("000000"+this.getHex().toString(16)).slice(-6)},getHSL:function(e){var t,r,n=e||{h:0,s:0,l:0},i=this.r,a=this.g,o=this.b,s=Math.max(i,a,o),l=Math.min(i,a,o),u=(l+s)/2;if(l===s)t=0,r=0;else{var c=s-l;switch(r=u<=.5?c/(s+l):c/(2-s-l),s){case i:t=(a-o)/c+(a1))return n.copy(i).multiplyScalar(o).add(t.start)}else if(0===this.distanceToPoint(t.start))return n.copy(t.start)}}(),intersectsLine:function(e){var t=this.distanceToPoint(e.start),r=this.distanceToPoint(e.end);return t<0&&r>0||r<0&&t>0},intersectsBox:function(e){return e.intersectsPlane(this)},intersectsSphere:function(e){return e.intersectsPlane(this)},coplanarPoint:function(e){return(e||new s).copy(this.normal).multiplyScalar(-this.constant)},applyMatrix4:function(){var e=new s,t=new c;return function(r,n){var i=this.coplanarPoint(e).applyMatrix4(r),a=n||t.getNormalMatrix(r),o=this.normal.applyMatrix3(a).normalize();return this.constant=-i.dot(o),this}}(),translate:function(e){return this.constant=this.constant-e.dot(this.normal),this},equals:function(e){return e.normal.equals(this.normal)&&e.constant===this.constant}},h.normal=function(){var e=new s;return function(t,r,n,i){var a=i||new s;a.subVectors(n,r),e.subVectors(t,r),a.cross(e);var o=a.lengthSq();return o>0?a.multiplyScalar(1/Math.sqrt(o)):a.set(0,0,0)}}(),h.barycoordFromPoint=function(){var e=new s,t=new s,r=new s;return function(n,i,a,o,l){e.subVectors(o,i),t.subVectors(a,i),r.subVectors(n,i);var u=e.dot(e),c=e.dot(t),f=e.dot(r),d=t.dot(t),h=t.dot(r),p=u*d-c*c,m=l||new s;if(0===p)return m.set(-2,-1,-1);var g=1/p,v=(d*f-c*h)*g,y=(u*h-c*f)*g;return m.set(1-v-y,y,v)}}(),h.containsPoint=function(){var e=new s;return function(t,r,n,i){var a=h.barycoordFromPoint(t,r,n,i,e);return a.x>=0&&a.y>=0&&a.x+a.y<=1}}(),h.prototype={constructor:h,set:function(e,t,r){return this.a.copy(e),this.b.copy(t),this.c.copy(r),this},setFromPointsAndIndices:function(e,t,r,n){return this.a.copy(e[t]),this.b.copy(e[r]),this.c.copy(e[n]),this},clone:function(){return(new this.constructor).copy(this)},copy:function(e){return this.a.copy(e.a),this.b.copy(e.b),this.c.copy(e.c),this},area:function(){var e=new s,t=new s;return function(){return e.subVectors(this.c,this.b),t.subVectors(this.a,this.b),.5*e.cross(t).length()}}(),midpoint:function(e){return(e||new s).addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)},normal:function(e){return h.normal(this.a,this.b,this.c,e)},plane:function(e){return(e||new d).setFromCoplanarPoints(this.a,this.b,this.c)},barycoordFromPoint:function(e,t){return h.barycoordFromPoint(e,this.a,this.b,this.c,t)},containsPoint:function(e){return h.containsPoint(e,this.a,this.b,this.c)},closestPointToPoint:function(){var e,t,r,n;return function(i,a){void 0===e&&(e=new d,t=[new f,new f,new f],r=new s,n=new s);var o=a||new s,l=1/0;if(e.setFromCoplanarPoints(this.a,this.b,this.c),e.projectPoint(i,r),!0===this.containsPoint(r))o.copy(r);else{t[0].set(this.a,this.b),t[1].set(this.b,this.c),t[2].set(this.c,this.a);for(var u=0;uthis.radius*this.radius&&(n.sub(this.center).normalize(),n.multiplyScalar(this.radius).add(this.center)),n},getBoundingBox:function(e){var t=e||new m;return t.set(this.center,this.center),t.expandByScalar(this.radius),t},applyMatrix4:function(e){return this.center.applyMatrix4(e),this.radius=this.radius*e.getMaxScaleOnAxis(),this},translate:function(e){return this.center.add(e),this},equals:function(e){return e.center.equals(this.center)&&e.radius===this.radius}},m.prototype={constructor:m,isBox3:!0,set:function(e,t){return this.min.copy(e),this.max.copy(t),this},setFromArray:function(e){for(var t=1/0,r=1/0,n=1/0,i=-1/0,a=-1/0,o=-1/0,s=0,l=e.length;si&&(i=u),c>a&&(a=c),f>o&&(o=f)}this.min.set(t,r,n),this.max.set(i,a,o)},setFromBufferAttribute:function(e){for(var t=1/0,r=1/0,n=1/0,i=-1/0,a=-1/0,o=-1/0,s=0,l=e.count;si&&(i=u),c>a&&(a=c),f>o&&(o=f)}this.min.set(t,r,n),this.max.set(i,a,o)},setFromPoints:function(e){this.makeEmpty();for(var t=0,r=e.length;tthis.max.x||e.ythis.max.y||e.zthis.max.z)},containsBox:function(e){return this.min.x<=e.min.x&&e.max.x<=this.max.x&&this.min.y<=e.min.y&&e.max.y<=this.max.y&&this.min.z<=e.min.z&&e.max.z<=this.max.z},getParameter:function(e,t){return(t||new s).set((e.x-this.min.x)/(this.max.x-this.min.x),(e.y-this.min.y)/(this.max.y-this.min.y),(e.z-this.min.z)/(this.max.z-this.min.z))},intersectsBox:function(e){return!(e.max.xthis.max.x||e.max.ythis.max.y||e.max.zthis.max.z)},intersectsSphere:function(){var e;return function(t){return void 0===e&&(e=new s),this.clampPoint(t.center,e),e.distanceToSquared(t.center)<=t.radius*t.radius}}(),intersectsPlane:function(e){var t,r;return e.normal.x>0?(t=e.normal.x*this.min.x,r=e.normal.x*this.max.x):(t=e.normal.x*this.max.x,r=e.normal.x*this.min.x),e.normal.y>0?(t+=e.normal.y*this.min.y,r+=e.normal.y*this.max.y):(t+=e.normal.y*this.max.y,r+=e.normal.y*this.min.y),e.normal.z>0?(t+=e.normal.z*this.min.z,r+=e.normal.z*this.max.z):(t+=e.normal.z*this.max.z,r+=e.normal.z*this.min.z),t<=-e.constant&&r>=-e.constant},clampPoint:function(e,t){return(t||new s).copy(e).clamp(this.min,this.max)},distanceToPoint:function(){var e=new s;return function(t){return e.copy(t).clamp(this.min,this.max).sub(t).length()}}(),getBoundingSphere:function(){var e=new s;return function(t){var r=t||new p;return this.getCenter(r.center),r.radius=.5*this.getSize(e).length(),r}}(),intersect:function(e){return this.min.max(e.min),this.max.min(e.max),this.isEmpty()&&this.makeEmpty(),this},union:function(e){return this.min.min(e.min),this.max.max(e.max),this},applyMatrix4:function(){var e=[new s,new s,new s,new s,new s,new s,new s,new s];return function(t){return this.isEmpty()?this:(e[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(t),e[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(t),e[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(t),e[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(t),e[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(t),e[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(t),e[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(t),e[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(t),this.setFromPoints(e),this)}}(),translate:function(e){return this.min.add(e),this.max.add(e),this},equals:function(e){return e.min.equals(this.min)&&e.max.equals(this.max)}},g.RotationOrders=["XYZ","YZX","ZXY","XZY","YXZ","ZYX"],g.DefaultOrder="XYZ",g.prototype={constructor:g,isEuler:!0,get x(){return this._x},set x(e){this._x=e,this.onChangeCallback()},get y(){return this._y},set y(e){this._y=e,this.onChangeCallback()},get z(){return this._z},set z(e){this._z=e,this.onChangeCallback()},get order(){return this._order},set order(e){this._order=e,this.onChangeCallback()},set:function(e,t,r,n){return this._x=e,this._y=t,this._z=r,this._order=n||this._order,this.onChangeCallback(),this},clone:function(){return new this.constructor(this._x,this._y,this._z,this._order)},copy:function(e){return this._x=e._x,this._y=e._y,this._z=e._z,this._order=e._order,this.onChangeCallback(),this},setFromRotationMatrix:function(e,t,r){var n=M.clamp,i=e.elements,a=i[0],o=i[4],s=i[8],l=i[1],u=i[5],c=i[9],f=i[2],d=i[6],h=i[10];return t=t||this._order,"XYZ"===t?(this._y=Math.asin(n(s,-1,1)),Math.abs(s)<.99999?(this._x=Math.atan2(-c,h),this._z=Math.atan2(-o,a)):(this._x=Math.atan2(d,u),this._z=0)):"YXZ"===t?(this._x=Math.asin(-n(c,-1,1)),Math.abs(c)<.99999?(this._y=Math.atan2(s,h),this._z=Math.atan2(l,u)):(this._y=Math.atan2(-f,a),this._z=0)):"ZXY"===t?(this._x=Math.asin(n(d,-1,1)),Math.abs(d)<.99999?(this._y=Math.atan2(-f,h),this._z=Math.atan2(-o,u)):(this._y=0,this._z=Math.atan2(l,a))):"ZYX"===t?(this._y=Math.asin(-n(f,-1,1)),Math.abs(f)<.99999?(this._x=Math.atan2(d,h),this._z=Math.atan2(l,a)):(this._x=0,this._z=Math.atan2(-o,u))):"YZX"===t?(this._z=Math.asin(n(l,-1,1)),Math.abs(l)<.99999?(this._x=Math.atan2(-c,u),this._y=Math.atan2(-f,a)):(this._x=0,this._y=Math.atan2(s,h))):"XZY"===t?(this._z=Math.asin(-n(o,-1,1)),Math.abs(o)<.99999?(this._x=Math.atan2(d,u),this._y=Math.atan2(s,a)):(this._x=Math.atan2(-c,h),this._y=0)):console.warn("THREE.Euler: .setFromRotationMatrix() given unsupported order: "+t),this._order=t,!1!==r&&this.onChangeCallback(),this},setFromQuaternion:function(){var e;return function(t,r,n){return void 0===e&&(e=new a),e.makeRotationFromQuaternion(t),this.setFromRotationMatrix(e,r,n)}}(),setFromVector3:function(e,t){return this.set(e.x,e.y,e.z,t||this._order)},reorder:function(){var e=new o;return function(t){return e.setFromEuler(this),this.setFromQuaternion(e,t)}}(),equals:function(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._order===this._order},fromArray:function(e){return this._x=e[0],this._y=e[1],this._z=e[2],void 0!==e[3]&&(this._order=e[3]),this.onChangeCallback(),this},toArray:function(e,t){return void 0===e&&(e=[]),void 0===t&&(t=0),e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._order,e},toVector3:function(e){return e?e.set(this._x,this._y,this._z):new s(this._x,this._y,this._z)},onChange:function(e){return this.onChangeCallback=e,this},onChangeCallback:function(){}},v.prototype={constructor:v,set:function(e,t){return this.origin.copy(e),this.direction.copy(t),this},clone:function(){return(new this.constructor).copy(this)},copy:function(e){return this.origin.copy(e.origin),this.direction.copy(e.direction),this},at:function(e,t){return(t||new s).copy(this.direction).multiplyScalar(e).add(this.origin)},lookAt:function(e){return this.direction.copy(e).sub(this.origin).normalize(),this},recast:function(){var e=new s;return function(t){return this.origin.copy(this.at(t,e)),this}}(),closestPointToPoint:function(e,t){var r=t||new s;r.subVectors(e,this.origin);var n=r.dot(this.direction);return n<0?r.copy(this.origin):r.copy(this.direction).multiplyScalar(n).add(this.origin)},distanceToPoint:function(e){return Math.sqrt(this.distanceSqToPoint(e))},distanceSqToPoint:function(){var e=new s;return function(t){var r=e.subVectors(t,this.origin).dot(this.direction);return r<0?this.origin.distanceToSquared(t):(e.copy(this.direction).multiplyScalar(r).add(this.origin),e.distanceToSquared(t))}}(),distanceSqToSegment:function(){var e=new s,t=new s,r=new s;return function(n,i,a,o){e.copy(n).add(i).multiplyScalar(.5),t.copy(i).sub(n).normalize(),r.copy(this.origin).sub(e);var s,l,u,c,f=.5*n.distanceTo(i),d=-this.direction.dot(t),h=r.dot(this.direction),p=-r.dot(t),m=r.lengthSq(),g=Math.abs(1-d*d);if(g>0)if(s=d*p-h,l=d*h-p,c=f*g,s>=0)if(l>=-c)if(l<=c){var v=1/g;s*=v,l*=v,u=s*(s+d*l+2*h)+l*(d*s+l+2*p)+m}else l=f,s=Math.max(0,-(d*l+h)),u=-s*s+l*(l+2*p)+m;else l=-f,s=Math.max(0,-(d*l+h)),u=-s*s+l*(l+2*p)+m;else l<=-c?(s=Math.max(0,-(-d*f+h)),l=s>0?-f:Math.min(Math.max(-f,-p),f),u=-s*s+l*(l+2*p)+m):l<=c?(s=0,l=Math.min(Math.max(-f,-p),f),u=l*(l+2*p)+m):(s=Math.max(0,-(d*f+h)),l=s>0?f:Math.min(Math.max(-f,-p),f),u=-s*s+l*(l+2*p)+m);else l=d>0?-f:f,s=Math.max(0,-(d*l+h)),u=-s*s+l*(l+2*p)+m;return a&&a.copy(this.direction).multiplyScalar(s).add(this.origin),o&&o.copy(t).multiplyScalar(l).add(e),u}}(),intersectSphere:function(){var e=new s;return function(t,r){e.subVectors(t.center,this.origin);var n=e.dot(this.direction),i=e.dot(e)-n*n,a=t.radius*t.radius;if(i>a)return null;var o=Math.sqrt(a-i),s=n-o,l=n+o;return s<0&&l<0?null:s<0?this.at(l,r):this.at(s,r)}}(),intersectsSphere:function(e){return this.distanceToPoint(e.center)<=e.radius},distanceToPlane:function(e){var t=e.normal.dot(this.direction);if(0===t)return 0===e.distanceToPoint(this.origin)?0:null;var r=-(this.origin.dot(e.normal)+e.constant)/t;return r>=0?r:null},intersectPlane:function(e,t){var r=this.distanceToPlane(e);return null===r?null:this.at(r,t)},intersectsPlane:function(e){var t=e.distanceToPoint(this.origin);return 0===t||e.normal.dot(this.direction)*t<0},intersectBox:function(e,t){var r,n,i,a,o,s,l=1/this.direction.x,u=1/this.direction.y,c=1/this.direction.z,f=this.origin;return l>=0?(r=(e.min.x-f.x)*l,n=(e.max.x-f.x)*l):(r=(e.max.x-f.x)*l,n=(e.min.x-f.x)*l),u>=0?(i=(e.min.y-f.y)*u,a=(e.max.y-f.y)*u):(i=(e.max.y-f.y)*u,a=(e.min.y-f.y)*u),r>a||i>n?null:((i>r||r!==r)&&(r=i),(a=0?(o=(e.min.z-f.z)*c,s=(e.max.z-f.z)*c):(o=(e.max.z-f.z)*c,s=(e.min.z-f.z)*c),r>s||o>n?null:((o>r||r!==r)&&(r=o),(s=0?r:n,t)))},intersectsBox:function(){var e=new s;return function(t){return null!==this.intersectBox(t,e)}}(),intersectTriangle:function(){var e=new s,t=new s,r=new s,n=new s;return function(i,a,o,s,l){t.subVectors(a,i),r.subVectors(o,i),n.crossVectors(t,r);var u,c=this.direction.dot(n);if(c>0){if(s)return null;u=1}else{if(!(c<0))return null;u=-1,c=-c}e.subVectors(this.origin,i);var f=u*this.direction.dot(r.crossVectors(e,r));if(f<0)return null;var d=u*this.direction.dot(t.cross(e));if(d<0)return null;if(f+d>c)return null;var h=-u*e.dot(n);return h<0?null:this.at(h/c,l)}}(),applyMatrix4:function(e){return this.direction.add(this.origin).applyMatrix4(e),this.origin.applyMatrix4(e),this.direction.sub(this.origin),this.direction.normalize(),this},equals:function(e){return e.origin.equals(this.origin)&&e.direction.equals(this.direction)}},y.prototype={constructor:y,set:function(e,t,r){return this.radius=e,this.phi=t,this.theta=r,this},clone:function(){return(new this.constructor).copy(this)},copy:function(e){return this.radius=e.radius,this.phi=e.phi,this.theta=e.theta,this},makeSafe:function(){return this.phi=Math.max(1e-6,Math.min(Math.PI-1e-6,this.phi)),this},setFromVector3:function(e){return this.radius=e.length(),0===this.radius?(this.theta=0,this.phi=0):(this.theta=Math.atan2(e.x,e.z),this.phi=Math.acos(M.clamp(e.y/this.radius,-1,1))),this}};var T={LEFT:0,MIDDLE:1,RIGHT:2};i.InstanceScalarSize=2,s.InstanceScalarSize=3,l.InstanceScalarSize=4,u.InstanceScalarSize=3,o.InstanceScalarSize=4,c.InstanceScalarSize=9,a.InstanceScalarSize=16,u.prototype.toJSON=function(){return{r:this.r,g:this.g,b:this.b}},t.Matrix4=a,t.Matrix3=c,t.Vector2=i,t.Vector3=s,t.Vector4=l,t.Quaternion=o,t.Line3=f,t.Color=u,t.Triangle=h,t.Box3=m,t.Euler=g,t.Math=M,t.Ray=v,t.Spherical=y,t.Sphere=p,t.Plane=d,t.REVISION="84-threekit",t.MOUSE=T,t.CullFaceNone=0,t.CullFaceBack=1,t.CullFaceFront=2,t.CullFaceFrontBack=3,t.FrontFaceDirectionCW=0,t.FrontFaceDirectionCCW=1,t.BasicShadowMap=0,t.PCFShadowMap=1,t.PCFSoftShadowMap=2,t.PCSSSoftShadowMap=3,t.FrontSide=0,t.BackSide=1,t.DoubleSide=2,t.FlatShading=1,t.SmoothShading=2,t.NoColors=0,t.FaceColors=1,t.VertexColors=2,t.NoBlending=0,t.NormalBlending=1,t.AdditiveBlending=2,t.SubtractiveBlending=3,t.MultiplyBlending=4,t.CustomBlending=5,t.AddEquation=100,t.SubtractEquation=101,t.ReverseSubtractEquation=102,t.MinEquation=103,t.MaxEquation=104,t.ZeroFactor=200,t.OneFactor=201,t.SrcColorFactor=202,t.OneMinusSrcColorFactor=203,t.SrcAlphaFactor=204,t.OneMinusSrcAlphaFactor=205,t.DstAlphaFactor=206,t.OneMinusDstAlphaFactor=207,t.DstColorFactor=208,t.OneMinusDstColorFactor=209,t.SrcAlphaSaturateFactor=210,t.NeverDepth=0,t.AlwaysDepth=1,t.LessDepth=2,t.LessEqualDepth=3,t.EqualDepth=4,t.GreaterEqualDepth=5,t.GreaterDepth=6,t.NotEqualDepth=7,t.MultiplyOperation=0,t.MixOperation=1,t.AddOperation=2,t.NoToneMapping=0,t.LinearToneMapping=1,t.ReinhardToneMapping=2,t.Uncharted2ToneMapping=3,t.CineonToneMapping=4,t.UVMapping=300,t.CubeReflectionMapping=301,t.CubeRefractionMapping=302,t.EquirectangularReflectionMapping=303,t.EquirectangularRefractionMapping=304,t.SphericalReflectionMapping=305,t.CubeUVReflectionMapping=306,t.CubeUVRefractionMapping=307,t.RepeatWrapping=1e3,t.ClampToEdgeWrapping=1001,t.MirroredRepeatWrapping=1002,t.NearestFilter=1003,t.NearestMipMapNearestFilter=1004,t.NearestMipMapLinearFilter=1005,t.LinearFilter=1006,t.LinearMipMapNearestFilter=1007,t.LinearMipMapLinearFilter=1008,t.UnsignedByteType=1009,t.ByteType=1010,t.ShortType=1011,t.UnsignedShortType=1012,t.IntType=1013,t.UnsignedIntType=1014,t.FloatType=1015,t.HalfFloatType=1016,t.UnsignedShort4444Type=1017,t.UnsignedShort5551Type=1018,t.UnsignedShort565Type=1019,t.UnsignedInt248Type=1020,t.AlphaFormat=1021,t.RGBFormat=1022,t.RGBAFormat=1023,t.LuminanceFormat=1024,t.LuminanceAlphaFormat=1025,t.RGBEFormat=1023,t.DepthFormat=1026,t.DepthStencilFormat=1027,t.RGB_S3TC_DXT1_Format=2001,t.RGBA_S3TC_DXT1_Format=2002,t.RGBA_S3TC_DXT3_Format=2003,t.RGBA_S3TC_DXT5_Format=2004,t.RGB_PVRTC_4BPPV1_Format=2100,t.RGB_PVRTC_2BPPV1_Format=2101,t.RGBA_PVRTC_4BPPV1_Format=2102,t.RGBA_PVRTC_2BPPV1_Format=2103,t.RGB_ETC1_Format=2151,t.LoopOnce=2200,t.LoopRepeat=2201,t.LoopPingPong=2202,t.InterpolateDiscrete=2300,t.InterpolateLinear=2301,t.InterpolateSmooth=2302,t.ZeroCurvatureEnding=2400,t.ZeroSlopeEnding=2401,t.WrapAroundEnding=2402,t.TrianglesDrawMode=0,t.TriangleStripDrawMode=1,t.TriangleFanDrawMode=2,t.LinearEncoding=3e3,t.sRGBEncoding=3001,t.GammaEncoding=3007,t.RGBEEncoding=3002,t.LogLuvEncoding=3003,t.RGBM7Encoding=3004,t.RGBM16Encoding=3005,t.RGBDEncoding=3006,t.BasicDepthPacking=3200,t.RGBADepthPacking=3201,t.OrderIndependentTransperancy=3300,t.PaintersTransperancy=3301},function(e,t,r){var n=r(16),i=r(120),a=r(51),o=r(69),s=r(58),l=function(e,t,r){var u,c,f,d,h=e&l.F,p=e&l.G,m=e&l.S,g=e&l.P,v=e&l.B,y=p?n:m?n[t]||(n[t]={}):(n[t]||{}).prototype,x=p?i:i[t]||(i[t]={}),b=x.prototype||(x.prototype={});p&&(r=t);for(u in r)c=!h&&y&&void 0!==y[u],f=(c?y:r)[u],d=v&&c?s(f,n):g&&"function"==typeof f?s(Function.call,f):f,y&&o(y,u,f,e&l.U),x[u]!=f&&a(x,u,d),g&&b[u]!=f&&(b[u]=f)};n.core=i,l.F=1,l.G=2,l.S=4,l.P=8,l.B=16,l.W=32,l.U=64,l.R=128,e.exports=l},function(e,t,r){e.exports={default:r(616),__esModule:!0}},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function i(e,t,r,n){var i=e.InstanceScalarSize||n,a=n||i,o=null!==t?t*a:null;if(void 0===i||void 0===a)throw Error("Can't determine element size / stride!");var s=r||Float32Array,l=c.default.maybeCreate(s,o);d.default.call(this,l,t||(l.length+a-i)/a|0),this.type=e,this.stride=a,this.elementSize=i,this.tempBuffer=new Float32Array(i)}Object.defineProperty(t,"__esModule",{value:!0});var a=r(53),o=n(a),s=r(2),l=n(s);t.default=i;var u=r(42),c=n(u),f=r(252),d=n(f),h=r(73),p=n(h);i.prototype=(0,l.default)((0,o.default)(d.default.prototype),{constructor:i,getAt:function(e,t){return(t||new this.type).fromArray(this.data,e*this.stride)},setAt:function(e,t){t.toArray(this.data,e*this.stride)},addAt:function(e,t){t.toArray(this.tempBuffer,0);for(var r=0,n=e*this.stride;r2&&void 0!==arguments[2]?arguments[2]:{},n=(0,Y.buildQueryObject)(t),a=e.get("sceneGraph"),o=n.from?i(e,n.from):a.activeSceneId;if(!o)return[];var s=a.nodes[o];if(!s)throw new Error("Unknown node to filter from");return(0,Y.matchChildren)(e,s,n,n.includeParent&&s,r.onlyNode)}function o(e,t){var r=Array.isArray(t)?t:i(e,t);if(r&&Array.isArray(r)){if(r.length>=2&&"eval"===r[1]){var n=(0,H.getEvalSceneGraph)(e).evaluatedNodes[r[0]],a=n&&n[r[2]];return a&&r[3]?a[r[3]]:a}return(0,H.get)(e,r)}}function s(e,t){var r=Array.isArray(t)?t:a(e,t);return r?r.reduce(function(t,r){return t[r[0]]=(0,H.get)(e,r),t},{}):void 0}function l(e,t,r,n){return o(e,n?[t,r,n]:[t,r])}function u(e,t){var r=o(e,{id:t,evalPlug:"Transform"});if(!r)return null;var n=r.transform,i=e.get("sceneGraph").nodes[t],a=i&&i.parent,s=a&&u(e,a);return s?(new G.Matrix4).copy(s).multiply(n):(new G.Matrix4).copy(n)}function c(e,t,r){var n=e.get("sceneGraph"),i=n.nodes,a=n.evaluatedNodes,o=a[t]&&a[t].Transform;if(!o)return null;if(t===r)return new G.Matrix4;var s=o.transform,l=i[t]&&i[t].parent,u=l&&c(e,l,r);return u?(new G.Matrix4).copy(u).multiply(s):(new G.Matrix4).copy(s)}function f(e){var t=e.translation,r=e.rotation,n=e.scale,i=e.rotateOrder,a=e.preRotation,o=e.rotatePivotOffset,s=e.localRotatePivot,l=e.scalePivotOffset,u=e.localScalePivot,c=e.shear;0===n.x&&(n.x=1e-7),0===n.y&&(n.y=1e-7),0===n.z&&(n.z=1e-7);var f=new G.Vector3(0,0,0),d=[],h=(new G.Matrix4).makeTranslation(t.x,t.y,t.z);d.push(h);var p=new G.Matrix4;f.equals(o)||(p.makeTranslation(o.x,o.y,o.z),d.push(p));var m=new G.Matrix4,g=new G.Matrix4,v=!1;f.equals(s)||(m.makeTranslation(s.x,s.y,s.z),d.push(m),g.getInverse(m,!0),v=!0);var y=new G.Matrix4;if(!f.equals(a)){var x=(new G.Vector3).copy(a).multiplyScalar(Math.PI/180);y.makeRotationFromEuler(new G.Euler(x.x,x.y,x.z,i)),d.push(y)}var b=(new G.Vector3).copy(r).multiplyScalar(Math.PI/180),w=(new G.Matrix4).makeRotationFromEuler(new G.Euler(b.x,b.y,b.z,i));d.push(w),v&&d.push(g);var _=new G.Matrix4;f.equals(l)||(_.makeTranslation(l.x,l.y,l.z),d.push(_));var M=new G.Matrix4,S=new G.Matrix4,T=!1;f.equals(u)||(M.makeTranslation(u.x,u.y,u.z),d.push(M),S.getInverse(M,!0),T=!0);var E=c.x,P=c.y,A=c.z,C=new G.Matrix4;C.set(1,E,P,0,0,1,A,0,0,0,1,0,0,0,0,1),d.push(C);var I=(new G.Matrix4).makeScale(n.x,n.y,n.z);d.push(I),T&&d.push(S);for(var R=new G.Matrix4,O=0;O1&&void 0!==arguments[1]?arguments[1]:{};return void 0===t.cloneDependencies&&(t.cloneDependencies=!0),function(r){var n,o=Array.isArray(e)?e:a(r,e),s=r.get("sceneGraph");if(!o.length)return console.warn("No match for clone: ",e),F.default.resolve(!0);var l=(0,H.findRoot)(r,o[0]),u=t.to||s.activeSceneId,c=i(r,{id:l,child:"Objects"}),f=i(r,{id:u,child:"Objects"}),d=(n={},(0,D.default)(n,c,f),(0,D.default)(n,i(r,{id:l,child:"MaterialLibrary"}),i(r,{id:u,child:"MaterialLibrary"})),n);return(t.withNull?r.dispatch((0,H.addNode)({name:t.withNull,parent:f,type:"Null",plugs:{Null:[["Null",{}]],Transform:[["Transform",{}]],Properties:[["Default",{}]]}})):F.default.resolve(null)).then(function(e){return e&&(d[c]=e),r.dispatch((0,H.clone)(o,d,{cloneDependencies:t.cloneDependencies})).then(function(r){return e&&(r[t.withNull]=e),r})})}}function y(e){var t=e.sceneId,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(e){var n={from:{id:t},child:"Objects",type:["PolyMesh","Null","Shape"]},s=a(e,n),l=e.get("sceneGraph");if(!s.length)return console.warn("No match for clone: ",n),F.default.resolve(!0);var u=(0,H.findRoot)(e,s[0]),c=r.to||l.activeSceneId,f=i(e,{id:u,child:"Objects"}),d=i(e,{id:c,child:"Objects"}),h=i(e,{id:u,child:"MaterialLibrary"}),p=o(e,{id:u,plug:"Player",property:"configurator"}),m=(0,D.default)({},f,d),g=o(e,{id:u,property:"name"});return e.dispatch(C({name:g+" Model",parent:d,type:"Model"})).then(function(r){return e.dispatch((0,J.initializeConfiguration)({id:r,config:p,sceneId:t})),m[f]=r,m[h]=r,e.dispatch((0,H.clone)(s,m,{cloneDependencies:!0})).then(function(e){return r})})}}function x(e,t,r){var n=arguments.length>3&&void 0!==arguments[3]&&arguments[3],i=arguments.length>4&&void 0!==arguments[4]&&arguments[4];return function(a){var o=b(a,e,t,r,n,i),s=o.translation,l=o.rotation,u=o.scale;l&&a.dispatch(d({id:t,plug:"Transform",property:"rotation"},l)),s&&a.dispatch(d({id:t,plug:"Transform",property:"translation"},s)),u&&(console.log("scale",u),a.dispatch(d({id:t,plug:"Transform",property:"scale"},u)))}}function b(e,t,r,n,a,o){var s=new G.Vector3,l=void 0,c=void 0,f=void 0,d=i(e,{id:r,parent:!0}),h=u(e,d)||new G.Matrix4,p=(new G.Matrix4).getInverse(h),m=u(e,t),g=u(e,r),v=u(e,n);if(!m||!g||!v)return{translation:l,rotation:c};m.premultiply(p),g.premultiply(p),v.premultiply(p);var y=new G.Vector3,x=new G.Quaternion;if(m.decompose(y,x,s),o){var b=(new G.Matrix4).makeScale((0,O.default)(s.x),(0,O.default)(s.y),(0,O.default)(s.z));v.premultiply(b),g.premultiply(b)}var w=new G.Vector3,_=new G.Quaternion;g.decompose(w,_,s),o&&(f=s.clone());var M=new G.Vector3,S=new G.Quaternion;if(v.decompose(M,S,s),l=y.clone().sub(M).add(w),a){var T=x.multiply(S.inverse());c=(new G.Euler).setFromQuaternion(_.premultiply(T),"ZYX").toVector3().multiplyScalar(180/Math.PI);var E=M.clone().sub(w),P=E.clone().applyQuaternion(T);l.add(E.sub(P))}return{translation:l,rotation:c,scale:f}}function w(){return function(e){function t(e){var t=r.nodes[e]&&r.nodes[e].plugs,i=!0,a=!1,o=void 0;try{for(var s,l=(0,j.default)((0,k.default)(t||{}));!(i=(s=l.next()).done);i=!0)!function(){var e=s.value;t[e].forEach(function(t,r){var i=(0,q.lookupOperator)(e,t.type,[]),a=!0,o=!1,s=void 0;try{for(var l,u=(0,j.default)(i.fileReferenceKeys);!(a=(l=u.next()).done);a=!0){var c=l.value;t[c]&&(n[t[c]]=!0)}}catch(e){o=!0,s=e}finally{try{!a&&u.return&&u.return()}finally{if(o)throw s}}})}()}catch(e){a=!0,o=e}finally{try{!i&&l.return&&l.return()}finally{if(a)throw o}}}var r=e.get("sceneGraph"),n={};return a(e,{includeParent:!0}).forEach(t),F.default.all((0,X.filter)(e).map(function(t){return!n[t.get("id")]&&e.dispatch((0,X.removeFile)(t.get("id")))}))}}function _(e,t){var r=new G.Box3,n=e.get("sceneGraph").nodes[t].type;if("PolyMesh"===n){var i=o(e,{id:t,evalPlug:"PolyMesh",property:"mesh"});i&&r.copy(i.boundingBox)}else if("Shape"===n){var a=o(e,{id:t,evalPlug:"Shape",property:"shape"});a&&r.copy(a.boundingBox)}return r}function M(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=r.layer||null,i=new G.Box3,a=e.get("sceneGraph"),o=a.nodes;if(r.ignoreChildren){var s=_(e,t);i.union(s)}else(0,H.traverseHierarchy)(e,t,!0,function(r){if(o[r]&&o[r].plugs&&o[r].plugs.Properties){if(n){var a=o[r].plugs.Properties,s=a&&a[0];if(s&&s.layer&&s.layer!==n)return}var l=_(e,r),u=c(e,r,t);l.applyMatrix4(u),i.union(l)}});var l=u(e,t)||new G.Matrix4;return i.applyMatrix4(l),i}function S(e,t){function r(t){var n=e.get("sceneGraph").nodes[t],i=n&&n.parent,a=o(e,{id:t,plug:"Properties",property:"visible"});return!i||void 0===a||a&&r(i)}return"Enable"!==o(e,{id:e.get("sceneGraph").activeSceneId,plug:"Properties",property:"hierarchyVisibility"})?o(e,{id:t,plug:"Properties",property:"visible"}):r(t)}function T(){return Z.default}function E(e,t){if(!t)return null;var r=(0,W.getRect)(e),n=.5*r.width,i=.5*r.height,a=M(e,t),s=new G.Box3,l=new G.Vector3,c=(0,W.getCamera)(e),f=(0,W.getCameraWorldTransform)(e),d=o(e,{id:c,evalPlug:"Camera"}),h=(0,$.default)(d),p={projectionMatrix:h,matrixWorld:f};if(a.isEmpty()){var m=u(e,t);if(!m)return null;var g=(new G.Vector3).setFromMatrixPosition(m);return g.project(p),{top:(g.y-1)*-i,left:(g.x+1)*n,width:0,height:0,x:(g.x+1)*n,y:(g.y-1)*-i}}for(var v=0;v<8;v++)l.set(a[Math.floor(v/4)?"max":"min"].x,a[Math.floor(v/2)%2?"max":"min"].y,a[v%2?"max":"min"].z),l.project(p),s.expandByPoint(l);var y={top:(s.max.y-1)*-i,left:(s.min.x+1)*n,width:(s.max.x-s.min.x)*n,height:(s.max.y-s.min.y)*i};return y.x=y.left+y.width/2,y.y=y.top+y.height/2,y}function P(e,t){return t?o(e,{name:t,evalPlug:"Pass"}):o(e,{id:o(e,{name:"Passes",plug:"GeneralRenderer",property:"curPass"}),evalPlug:"Pass"})||o(e,{type:"Pass",evalPlug:"Pass"})}function A(e,t){var r=t||e.get("sceneGraph").activeSceneId,n=a(e,{from:{id:r},includeParent:!0});return{sceneGraph:(0,H.exportJSON)(e,n),assets:(0,X.exportJSON)(e)}}function C(e){var t=e.name,r=e.type,n=e.parent,i=e.plugs;if(!n)throw new Error("addNode requires parent to be set");if(!r)throw new Error("addNode requires type to be set");if(!t)throw new Error("addNode requires name to be set");if(!ee[r])throw new Error("invalid type: "+r+" for addNode");var a=i||{},o=!0,s=!1,l=void 0;try{for(var u,c=(0,j.default)((0,k.default)(ee[r]));!(o=(u=c.next()).done);o=!0){var f=u.value;if(a[f]||(a[f]=[[ee[r][f],{}]]),!a[f][0][0])throw new Error("Required operator for "+f)}}catch(e){s=!0,l=e}finally{try{!o&&c.return&&c.return()}finally{if(s)throw l}}return(0,H.addNode)({name:t,type:r,plugs:a,parent:n})}function I(e,t,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},i=arguments[4];if(!e)throw new Error("addOperator requires the id for the element receiving the operator");if(!t)throw new Error("addOperator requires the plug to be set");if(!r)throw new Error("addOperator requires the operator type to be set");var a=Z.default[t];if(!a)throw new Error("Unknown plug: "+t);if(!a[r])throw new Error("Unknown operator: "+r);return(0,H.addOperator)(e,t,[r,n,i])}Object.defineProperty(t,"__esModule",{value:!0});var R=r(102),O=n(R),L=r(18),D=n(L),V=r(29),N=n(V),B=r(30),F=n(B),U=r(7),k=n(U),z=r(13),j=n(z);t.find=i,t.filter=a,t.get=o,t.getAll=s,t.getEval=l,t.getWorldTransform=u,t.getRelativeTransform=c,t.getLocalTransform=f,t.set=d,t.setAll=h,t.reparent=p,t.getWarnings=m,t.setVRCamera=g,t.clone=v,t.cloneModel=y,t.attachModel=x,t.getAttachTransform=b,t.pruneAssets=w,t.getLocalBoundingBox=_,t.getNodeBoundingBox=M,t.isVisible=S,t.getAvailableOperators=T,t.getScreenPosition=E,t.getCurrentPass=P,t.exportJSON=A,t.addNode=C,t.addOperator=I;var G=r(0),H=r(10),W=r(8),X=r(23),Y=r(84),q=r(104),Z=n(q),J=r(70),K=r(40),Q=(n(K),r(109)),$=n(Q),ee={PolyMesh:{PolyMesh:"Box",Transform:"Transform",Material:"Reference",Properties:"PolyMeshProperties"},Light:{Light:"PointLight",Transform:"Transform",Properties:"Default"},Camera:{Camera:"Camera",Transform:"Transform",Properties:"Default"},Null:{Null:"Null",Transform:"Transform",Properties:"Default"},Model:{Null:"Null",Transform:"Transform",Mixer:"Mixer",Properties:"ModelProperties"},Material:{Material:"Physical",Properties:"MaterialProperties"},Image:{Image:"Image",Properties:"ImageProperties"},Pass:{Pass:"Pass"},Renderer:{Renderer:"WebGLRenderer"},Bone:{Bone:"Bone",Transform:"BoneTransform",Properties:"Default"},Annotation:{Annotation:"Annotation",Transform:"Transform",Properties:"Default"},Shape:{Shape:"Rectangle",Transform:"Transform",Material:"Reference",Properties:"ShapeProperties"},Helper:{Null:"Helper",Transform:"Transform",Properties:"Default"}},te={actions:{set:d,setAll:h,clone:v,cloneModel:y,pruneAssets:w,setVRCamera:g,addOperator:I,addNode:C,reparent:p,attachModel:x},selectors:{get:o,getAll:s,getWorldTransform:u,find:i,filter:a,getWarnings:m,exportJSON:A,getNodeBoundingBox:M,getCurrentPass:P,getAvailableOperators:T,getScreenPosition:E,isVisible:S}};t.default=te},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function i(e,t){e?(e.colorMaps||console.error("Polymesh must have initialized colorMaps container."),e.uvMaps||console.error("Polymesh must have initialized uvMaps container."),this.faceRangeOffsets=e.faceRangeOffsets,this.positions=e.positions,this.normalMap=e.normalMap,this.uvMaps=c.default.shallowClone(e.uvMaps),e.tangentMap&&(this.tangentMap=e.tangentMap),e.skinning&&(this.skinning=e.skinning),e.edgeCreaseWeights&&(this.edgeCreaseWeights=e.edgeCreaseWeights),e.materialIds&&(this.materialIds=e.materialIds),e.blendShapes&&(this.blendShapes=e.blendShapes),this.colorMaps=c.default.shallowClone(e.colorMaps),this._boundingBox=e.boundingBox,t&&(0,o.default)(this,t)):(this.faceRangeOffsets=new Uint32Array(1),this.positions=new b.default,this.colorMaps=new c.default,this.uvMaps=new c.default),this._cachedVolume=null,this._boundingBox=null,this._faceNormals=null}Object.defineProperty(t,"__esModule",{value:!0});var a=r(2),o=n(a);t.default=i;var s=r(221),l=n(s),u=(r(0),r(14)),c=n(u),f=r(3),d=(n(f),r(494)),h=n(d),p=r(491),m=n(p),g=r(105),v=(n(g),r(43)),y=n(v),x=r(6),b=n(x),w=r(134),_=n(w),M=r(262),S=n(M),T=r(257);r(39);i.prototype={constructor:i,get boundingBox(){return this._boundingBox||(this._boundingBox=(0,h.default)(this.positions)),this._boundingBox},getNumFaces:function(){return this.faceRangeOffsets.length-1},getNumFaceVertices:function(){return this.positions.faceValueIndices.length},getNumVertices:function(){return this.positions.values.length},getMapById:function(e){return y.default.resolveMap(this,e)||null},topologyChanged:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return this.skinning&&(this.skinning=null),this.edgeCreaseWeights&&(this.edgeCreaseWeights=null),this.materialIds&&!e&&(this.materialIds=null),this},getVolume:function(){return null===this._cachedVolume&&(this._cachedVolume=(0,m.default)(this)),this._cachedVolume},get faceNormals(){return this._faceNormals||(this._faceNormals=new _.default(this.positions)),this._faceNormals}},i.fromData=function(e,t,r,n){var a=new i({faceRangeOffsets:e,positions:t.isPolyMap?t:b.default.fromData(e,r||null,t),uvMaps:new c.default,colorMaps:new c.default});return n&&(a.materialIds=n),a},i.fromShapeSet=function(e){for(var t=e.loopRangeOffsets.length-1,r=[0],n=[],a=[],o=0,s=e.loopRangeOffsets[0],u=0;ua&&console.warn("PolyMap has more position indices than face vertices"),n},i.prototype={constructor:i,isPolyMap:!0,findValueIndexOffset:function(e,t){for(var r=this.faceRangeOffsets,n=this.faceValueIndices,i=r[e],a=r[e+1],o=i;o!==a;++o)if(n[o]===t)return o;return-1},get edgeVertexAdjacency(){return this._edgeVertexAdjacency||(this._edgeVertexAdjacency=new m.default(this)),this._edgeVertexAdjacency},get faceEdgeAdjacency(){return this._faceEdgeAdjacency||(this._faceEdgeAdjacency=new v.default(this)),this._faceEdgeAdjacency},get valueAdjacency(){return this._valueAdjacency||(this._valueAdjacency=new x.default(this)),this._valueAdjacency},get valueValueAdjacency(){return this._valueValueAdjacency||(this._valueValueAdjacency=new ValueValueAdjacency(this)),this._valueValueAdjacency},get faceFaceAdjacency(){return this._faceFaceAdjacency||(this._faceFaceAdjacency=new w.default(this)),this._faceFaceAdjacency},updateInverseIndex:function(){if(null===this.valueFaceIndices){for(var e=this.faceRangeOffsets,t=-1,r=e[0],n=this.faceValueIndices,i=this._updateValueFaceIndexOffsets(),a=i.length,o=n.length,s=new Uint32Array(o),l=0;l!==o;++l)l===r&&(r=e[++t+1]),s[i[n[l]]++]=t;if(this.valueFaceIndices=s,0===i.byteOffset)throw Error("Invalid .valueFaceIndexOffsets != null!");this.valueFaceIndexOffsets=new Uint32Array(i.buffer,0,a)}return this},_updateValueFaceIndexOffsets:function(){var e=this.valueFaceIndexOffsets;if(null===e){var t=this.values.length,r=t+2,n=new Uint32Array(r),i=n.subarray(2);e=n.subarray(1),u.default.histogram(this.faceValueIndices,t,i),h.default.accumulate(i),this.valueFaceIndices=null,this.valueFaceIndexOffsets=e}return e},compactValues:function(){var e=this.values,t=e.length;if(0!==t){var r=new Uint32Array(t),n=this._compactFaceIndexOffsets(r);n!==t&&(this._compactData(r,n),this._compactIndices(r))}return this},_compactFaceIndexOffsets:function(e){for(var t=this._updateValueFaceIndexOffsets(),r=e.length,n=0,i=0,a=0;a!==r;++a){var o=t[a+1];e[a]=n,i!==o&&(n!==a&&(t[n]=i),i=o,++n)}if(t[n]=i,n!==r)if(0!==t.byteOffset){var s=new Uint32Array(t.buffer),l=h.default.slice(s,0,n+2);t=l.subarray(1)}else t=h.default.slice(t,0,n+1);return this.valueFaceIndexOffsets=t,n},_compactData:function(e,t){for(var r=this.values,n=r.length,i=new f.default(r.type,t),a=e[0],o=i.newRangeArray(),s=1;s!==n;++s){var l=e[s];a!==l&&(r.rangeToArray(s-1,1,o),i.arrayToRange(o,a,1),a=l)}r.rangeToArray(n-1,1,o),i.arrayToRange(o,a,1),this.values=i},_compactIndices:function(e){var t=this.faceValueIndices,r=t.length,n=new Uint32Array(r);u.default.apply(t,e,n),this.faceValueIndices=n}}},function(e,t,r){e.exports={default:r(622),__esModule:!0}},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function i(e){return{type:bt,payload:e}}function a(e){return e.getIn(["player","activeManipulator"])}function o(e,t){return(0,dt.addCommand)({tool:e,enabled:!0},t)}function s(e){return(0,dt.removeCommand)(e)}function l(e){return(0,dt.updateCommand)(e,{display:{playerTools:!0}})}function u(e){return(0,dt.updateCommand)(e,{display:{playerTools:!1}})}function c(e,t){return{type:UPDATE_COMMAND_OPTIONS,payload:{name:e,options:t}}}function f(e){return e.getIn(["player","rect"])}function d(e){return{type:St,payload:e}}function h(e){return function(t){t.dispatch({type:_t,payload:e}),(0,it.getCameraController)(t).setCameraAttrs(e)}}function p(e){return e.getIn(["player","camera"])}function m(e){return(0,rt.getWorldTransform)(e,S(e))}function g(e){return function(t){return t.dispatch((0,rt.set)({scene:!0,plug:"Player",property:"camera"},e))}}function v(e){return function(t){if(e){var r=t.getIn(["player","activeCamera"]),n=(0,rt.get)(t,{plug:"Player",property:"vrCamera"})||it.virtualCameraId;t.dispatch(y(it.vrCameraId,r));var i=t.get("sceneGraph"),a=i.nodes[n],o=i.nodes[it.vrCameraId],s=(0,it.initNode)(a),l=(0,We.default)({},s.plugs);return t.dispatch((0,it.replace)(it.vrCameraId,(0,We.default)(o,{plugs:l})))}var u=t.getIn(["player","prevCamera"])||it.virtualCameraId;return t.dispatch(y(u,null,!1))}}function y(e,t){var r=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];return function(n){var i=(0,ft.default)(n,t),a=(0,rt.get)(n,{id:t,evalPlug:"Camera"}),o=(0,rt.get)(n,{id:t,evalPlug:"Transform"});o&&!o.target&&(a.targetWorldMatrix=i);var s=(0,rt.get)(n,{id:e,evalPlug:"Camera"});s.targetWorldMatrix&&(n.dispatch((0,it.merge)([it.virtualTargetId,"Transform",0],(0,ut.default)(s.targetWorldMatrix))),s.targetWorldMatrix=null),n.dispatch({type:wt,payload:{id:e,prevCameraId:t}}),(0,it.getCameraController)(n).setActiveCamera(n,e,n.get("sceneGraph").nodes[e],r)}}function x(e){return{type:Ut,payload:e}}function b(e){return e.getIn(["player","threeObjects"]).toJS()}function w(e){return e.getIn(["player","threeObjects","scene"])}function _(e){return e.getIn(["player","threeObjects","camera"])}function M(e,t){var r=t||S(e),n=(0,rt.get)(e,{id:r,plug:"Properties",property:"frameLayer"});return(0,rt.getNodeBoundingBox)(e,(0,rt.find)(e,"Objects"),{layer:n})}function S(e){return e.getIn(["player","activeCamera"])||it.virtualCameraId}function T(e){return e.getIn(["player","tools"])}function E(e){return{type:Mt,payload:e}}function P(e){return{initialCameraWorldMatrix:e.getIn(["player","initialCameraWorldMatrix"]),initialTargetWorldMatrix:e.getIn(["player","initialTargetWorldMatrix"])}}function A(){return function(e){var t=e.getIn(["player","playerElement"]);["requestFullscreen","webkitRequestFullscreen","mozRequestFullScreen","msRequestFullscreen"].forEach(function(e){if(t[e])return t[e]()}),e.dispatch({type:It})}}function C(){return function(e){return["exitFullscreen","webkitExitFullscreen","mozCancelFullScreen","msExitFullscreen"].forEach(function(e){if(document[e])return document[e]()}),e.dispatch({type:Rt})}}function I(){return function(e){return e.dispatch(R(e)?C():A())}}function R(e){return e.getIn(["player","fullScreen"])}function O(e){return function(t){R(t)!==e&&t.dispatch({type:Ot,payload:e}),!e&&V(t)&&t.dispatch((0,dt.deactivateCommand)("vrSettings"))}}function L(e){return e.getIn(["player","renderingMode"])}function D(e){return e.getIn(["player","renderingMode"])===gt.normal}function V(e){return e.getIn(["player","renderingMode"])===gt.vr}function N(e){return e.getIn(["player","renderingMode"])===gt.lenticular}function B(e){return function(t){var r=t.getIn(["player","tools",e]);if(r){if(r.get("action"))return r.get("action")(t);var n=F(t,r);return r.get("activate")&&!n?r.get("activate")(t):r.get("deactivate")&&n?r.get("deactivate")(t):t.dispatch(i(e))}}}function F(e,t){return t.get("isActive")?t.get("isActive")(e):e.getIn(["player","activeManipulator"])===t.get("name")}function U(e,t){var r=e.getIn(["player","tools",t]);return r&&F(e,r)}function k(e){return e.getIn(["player","tools"]).filter(function(t){return F(e,t)})}function z(e){var t=e.fullscreen,r=e.trackDevice;return function(e){t&&e.dispatch(A());var n=S(e);e.dispatch({type:Nt,payload:{trackDevice:r,cameraId:n}})}}function j(){return{type:Vt}}function G(e){return e.getIn(["player","prevCamera"])}function H(e){if(!gt[e])throw new Error("Invalid Render Mode: "+e);return{type:Lt,payload:e}}function W(){return function(e){e.dispatch(N(e)?j():z({}))}}function X(){return{type:Bt,payload:!0}}function Y(){return{type:Bt,payload:!1}}function q(){return function(e){console.log("toggle device tracking",!Z(e)),e.dispatch(Z(e)?Y():X())}}function Z(e){return e.getIn(["player","deviceTracking"])}function J(e,t){return{type:Ct,payload:{playerEl:e,canvasEl:t}}}function K(e){return{type:Pt,payload:e}}function Q(e){return{type:At,payload:e}}function $(e){return{type:Ft,payload:e}}function ee(e){return e.getIn(["player","activeColor"])}function te(e){return e.getIn(["player","hoverColor"])}function re(e){return e.getIn(["player","fullscreenBackgroundColor"])}function ne(e,t,r,n){var i=new qe.Vector3,a=new qe.Quaternion,o=new qe.Vector3(1,1,1);e.decompose(i,a,o);var s=new qe.Vector3,l=new qe.Quaternion;t.decompose(s,l,o);var u=(new qe.Vector3).setFromMatrixPosition(r),c=u.distanceTo(i),f=(new qe.Vector3).setFromMatrixPosition(n),d=f.distanceTo(s),h=new qe.Vector3,p=new qe.Vector3,m=new qe.Vector3,g=new qe.Quaternion,v=new qe.Matrix4;return function(e,t,r,n){var i=e/n;h.lerpVectors(u,f,i);var s=c*(1-i)+d*i;return qe.Quaternion.slerp(a,l,g,i),p.set(0,0,1).applyQuaternion(g),m.copy(h).addScaledVector(p,s),v.compose(m,g,o),v}}function ie(e,t){return function(r){var n=(0,it.getCameraController)(r),i=S(r);if(i&&e){var a=Ge.default.resolve(),o=null;n.useTarget=!1;var s=(0,rt.get)(r,{id:i,plug:"Camera",property:"fieldOfView"}),l=(0,rt.get)(r,{id:e,plug:"Camera",property:"fieldOfView"});return a.then(function(){var e=r.getIn(["animation","animations"]),t=e.filter(function(e){return"animateCameraTo"===e.name});return Ge.default.all(t.map(function(e){return r.dispatch((0,nt.removeAnimation)(e.id))}))}).then(function(){var e=["orbit","pan","zoom"];for(var t in e)(0,dt.isCommandActive)(r,e[t])&&(o=e[t]);return r.dispatch((0,dt.updateCommand)(o,{active:!1}))}).then(function(){var a=(0,rt.getWorldTransform)(r,i),o=(0,ft.default)(r,i),u=(0,pt.initCamera)(r,e),c=u.cameraWorldTransform,f=u.lookAtTransform,d=t||300;return new Ge.default(function(t,u){r.dispatch((0,nt.queueAnimation)({autoplay:!0,name:"animateCameraTo",iterations:1,tracks:[{duration:d,value:c,startValue:a,tween:ne(a,c,o,f),set:function(e,t){(0,st.default)(r,i,t)}},{path:{id:i,plug:"Camera",property:"fieldOfView"},duration:d,value:l,startValue:s}],onEnd:function(){t(r.dispatch(g(e)).then(function(){n.useTarget=!0}))}}))})}).then(function(){return r.dispatch((0,dt.updateCommand)(o,{active:!0}))})}}}function ae(){return function(e){var t=e.getTranslator();t&&t.resize()}}function oe(e,t,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},i=e.getTranslator();if(!i||!i.raycastSelect)return null;var a=t.eventRay?t.eventRay:void 0,o=t.clientX/(t.rect.width/2)-1,s=-(t.clientY/(t.rect.height/2)-1),l=i.raycastSelect({x:o,y:s},r,a,n);return n.subObjects?l.map(function(e){var t=e.data[0];return{id:e.id,index:t.index,subObjectType:t.subObjectType}}):l.map(function(e){return e.id})}function se(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=e.getTranslator();if(!n||!n.raycastSelect)return null;var i=n.raycastSelect({x:0,y:0},t,null,r);return r.subObjects?i.map(function(e){var t=e.data[0];return{id:e.id,index:t.index,subObjectType:t.subObjectType}}):i.map(function(e){return e.id})}function le(e,t){var r=(0,rt.filter)(e,{plug:"Properties",properties:{interactive:!0}}),n=r.map(function(r){var n=r[0],i=(0,rt.getNodeBoundingBox)(e,n),a=t.intersectBox(i);return{hit:!!a,id:n,distance:a?a.distanceTo(t.origin):1/0}}).filter(function(e){return e.hit});return n.sort(function(e,t){return e.distance-t.distance}),n.map(function(e){return e.id})}function ue(e,t){var r=((0,rt.filter)(e,{plug:"Properties",properties:{interactive:!0}}),e.getTranslator());if(!r||!r.getCameraMouseRay)return null;var n=t.clientX/(t.rect.width/2)-1,i=-(t.clientY/(t.rect.height/2)-1);return le(e,r.getCameraMouseRay({x:n,y:i}).ray)}function ce(e){var t=e.getTranslator();return t&&t.getCameraMouseRay?le(e,t.getCameraMouseRay({x:0,y:0}).ray):null}function fe(e,t){return function(r){var n=S(r);if(n){e1&&void 0!==arguments[1]?arguments[1]:{};return{type:Tt,payload:{display:e,options:t}}}function me(e){return e.getIn(["player","displayThumbnail"])}function ge(e){return e.getIn(["player","thumbnailOptions"])}function ve(e,t){var r=e.getIn(["player","thumbnailOptions"]),n=r.get("url");return n||"https://clara.io/api/scenes/"+t+"/"+((0,Ze.is)(r,Ht)?"v2thumbnail":"render?"+Ke.default.stringify(r.toJS()))}function ye(e){return{type:Et,payload:e}}function xe(e){return e.getIn(["player","displayVrSettings"])}function be(e){return{type:Dt,payload:e}}function we(e){return e.getIn(["player","progressBarOption"])}function _e(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(r){var n=t.cameraId||S(r),i=t.layer||(0,rt.get)(r,{id:n,plug:"Properties",property:"frameLayer"}),a=e||[(0,rt.find)(r,"Objects")],o=(new qe.Box3).makeEmpty();a.forEach(function(e){return o.union((0,rt.getNodeBoundingBox)(r,e,{layer:i}))}),o.isEmpty()||(0,pt.frameSphere)(r,o.getBoundingSphere(),n)}}function Me(e){switch(e=e||"xyz"){case"xyz":case"xzy":case"yxz":case"yzx":case"zxy":case"zyx":default:e=0;break;case"xy":case"yx":e=1;break;case"xz":case"zx":e=2;break;case"yz":case"zy":e=3;break;case"x":e=4;break;case"y":e=5;break;case"z":e=6}return e}function Se(e,t,r,n,i,a){var o=e.getTranslator(),s=(0,rt.filter)(e,{type:"PolyMesh"}),l=o.getNodeListBoundingBox(s),u=l.getBoundingSphere(),c={id:(0,$e.default)(),name:"Explode Clip",tracks:[]};return t.forEach(function(t,o){var s=t.id,l=t.boundingSphere,f=(0,rt.get)(e,{id:s,plug:"Transform",property:"translation"}),d=f.clone(),h=l.center.sub(u.center).normalize();switch(a){case 0:if(o<1)break;d.x+=h.x*(u.radius+l.radius)*i,d.y+=h.y*(u.radius+l.radius)*i,d.z+=h.z*(u.radius+l.radius)*i;break;case 1:if(o<1)break;d.x+=h.x*(u.radius+l.radius)*i,d.y+=h.y*(u.radius+l.radius)*i;break;case 2:if(o<1)break;d.x+=h.x*(u.radius+l.radius)*i,d.z+=h.z*(u.radius+l.radius)*i;break;case 3:if(o<1)break;d.y+=h.y*(u.radius+l.radius)*i,d.z+=h.z*(u.radius+l.radius)*i;break;case 4:r-=l.radius*i,d.x=r,r-=l.radius*i;break;case 5:r-=l.radius*i,d.y=r,r-=l.radius*i;break;case 6:r-=l.radius*i,d.z=r,r-=l.radius*i}var p=(0,rt.find)(e,{id:s,plug:"Transform",property:"translation"});c.tracks.push({easing:"linear",type:"Vec3",path:p,start:0,keyframes:{x:{ts:[0,n],vs:[f.x,d.x]},y:{ts:[0,n],vs:[f.y,d.y]},z:{ts:[0,n],vs:[f.z,d.z]}}})}),c}function Te(e,t,r,n){var i=e.getTranslator(),a=(0,rt.filter)(e,{type:"PolyMesh"}),o=i.getNodeListBoundingBox(a),s=o.getBoundingSphere(),l=S(e),u=(0,rt.getWorldTransform)(e,l);t=n<4?4*s.radius*r:2*t;var c=(0,rt.get)(e,{id:l,evalPlug:"Camera"}),f=c.aspectRatio>=1?Math.PI*c.fieldOfView/360:Math.atan(c.aspectRatio*Math.tan(Math.PI*c.fieldOfView/360)),d=t/2/Math.sin(f),h=(0,ut.default)(u),p=h.translation,m=h.rotation,g=(0,rt.find)(e,{name:"Objects"}),v={Camera:[["Camera",{}]],Transform:[["Transform",{translation:p,rotation:m}]],Properties:[["CameraProperties",{}]]},y=p.clone().sub(s.center);y.normalize().multiplyScalar(d).add(s.center);var x={Camera:[["Camera",{}]],Transform:[["Transform",{translation:y,rotation:m}]],Properties:[["CameraProperties",{}]]};return e.dispatch((0,rt.addNode)({name:"srcCamera",type:"Camera",plugs:v,parent:g})).then(function(t){return e.dispatch((0,rt.addNode)({name:"dstCamera",type:"Camera",plugs:x,parent:g})).then(function(e){return{srcCamera:t,dstCamera:e}})})}function Ee(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"Objects",r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],n=arguments[3],i=arguments.length>4&&void 0!==arguments[4]?arguments[4]:3e3;return function(a){n=n>0?n:1;var o=Me(e),s=a.get("sceneGraph"),l=a.getTranslator(),u=r.length?r:(0,rt.filter)(a,{from:{name:t},plug:"Properties",properties:{visible:!0},shallow:!0}).map(function(e){return e[0]}),c=[],f=0;u.forEach(function(e){var t=s.nodes[e],r=l.getNodeListBoundingBox([e].concat(t.children)),n=r.getBoundingSphere();c.push({id:e,boundingSphere:n}),f+=n.radius});var d=f*n;switch(o){case 0:case 1:case 2:case 3:c.sort(function(e,t){return t.boundingSphere.radius-e.boundingSphere.radius});break;case 4:c.sort(function(e,t){return t.boundingSphere.center.x-e.boundingSphere.center.x});break;case 5:c.sort(function(e,t){return t.boundingSphere.center.y-e.boundingSphere.center.y});break;case 6:c.sort(function(e,t){return t.boundingSphere.center.z-e.boundingSphere.center.z})}var h=Se(a,c,d,i,n,o);return a.dispatch((0,nt.addClip)(h,h.id)),Te(a,d,n,o).then(function(e){return{explodeClipId:h.id,srcCamera:e.srcCamera,dstCamera:e.dstCamera}})}}function Pe(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return function(n){if("undefined"==typeof ga)return Ge.default.reject(new Error("Google Analytics is not initialized"));if(!e||!t)return Ge.default.reject(new Error("Google Analytics should have id and name"));if(ga("create",e,"auto",t),ga(t+".require","displayfeatures"),r.configurationChange){var i=function(e,r){return n.trackEvent(t,e.name,r)};n.dispatch((0,ht.onChange)(i))}}}function Ae(e){return e.getIn(["player","wireframeMode"])}function Ce(e){return function(t){t.dispatch({type:kt,payload:e}),(0,rt.filter)(t,{type:["PolyMesh","Shape"]}).forEach(function(e){t.dispatch((0,it.touch)(e))})}}function Ie(e){return{type:zt,payload:e}}function Re(e){return e.getIn(["player","zSpaceCapable"])}function Oe(e){var t=(0,it.getCameraController)(e);if(!t.id){var r=S(e);t.setActiveCamera(e,r,e.get("sceneGraph").nodes[r])}}function Le(e,t,r,n){return function(i){var a=document.getElementById(e);if(!a)return Ge.default.reject(new Error("No element found for vray image"));var o=(0,at.getSceneId)(i),s=n||"wss://clara.io/vray/streaming/"+o+"?width="+t+"&height="+r;console.log("Conneting to "+s);var l=new WebSocket(s);l.binaryType="arraybuffer";var u=function(e){var t=i.getIn(["player","streamingUpdateListeners"]);if("string"==typeof e.data){var r=JSON.parse(e.data);"error"===r.type?(console.log("Websocket error",r.message),(0,at.reportError)(new Error("vray websocket error "+r.message)),i.dispatch(Be(null))):"ready"===r.type&&i.dispatch(Ve())}else{var n=new Uint8Array(e.data),o=new Blob([n],{type:"image/jpeg"}),s=window.URL.createObjectURL(o);a.src=s,a.onload=function(){return i.dispatch(Ve())},t.forEach(function(e){return e(s)})}};l.onmessage=function(e){return u(e)},l.onerror=function(e){console.error("Error",e),(0,at.reportError)(e),i.dispatch(Be(null))},l.onclose=function(){console.log("Socket closed..."),i.dispatch(Be(null))},l.onopen=function(){var e=(0,it.getEvalSceneGraph)(i).nodes,t=(0,mt.getActiveAssets)(i),r=S(i);l.send((0,ze.default)({type:"init",payload:{currentCamera:r,nodes:e,assets:t}}))},i.dispatch(Be(l))}}function De(){return function(e){var t=e.getIn(["player","ws"]);if(t&&1===t.readyState){var r=(0,it.getEvalSceneGraph)(e).nodes,n=(0,mt.getActiveAssets)(e),i=S(e);t.send((0,ze.default)({type:"update",payload:{currentCamera:i,nodes:r,assets:n}}))}}}function Ve(){return function(e){var t=e.getIn(["player","ws"]);t&&1===t.readyState&&t.send((0,ze.default)({type:"request"}))}}function Ne(){return function(e){var t=e.getIn(["player","ws"]);t&&t.close()}}function Be(e,t){return{type:jt,payload:e}}function Fe(e){return{type:Gt,payload:e}}Object.defineProperty(t,"__esModule",{value:!0}),t.WIREFRAME_MODE=t.progressBarOptions=t.manipulators=t.RENDER_MODES=void 0;var Ue,ke=r(36),ze=n(ke),je=r(30),Ge=n(je),He=r(2),We=n(He),Xe=r(18),Ye=n(Xe);t.useManipulator=i,t.getActiveManipulator=a,t.addTool=o,t.removeTool=s,t.showTool=l,t.hideTool=u,t.updateToolOptions=c,t.getRect=f,t.setRect=d,t.setCameraAttrs=h,t.getCameraAttrs=p,t.getCameraWorldTransform=m,t.useCamera=g,t.useVrCamera=v,t.setCamera=y,t.setThree=x,t.getThree=b,t.getThreeScene=w,t.getThreeCamera=_,t.getBoundingBox=M,t.getCamera=S,t.getTools=T,t.setCameraPosition=E,t.getInitialCameraPosition=P,t.requestFullscreen=A,t.exitFullscreen=C,t.toggleFullscreen=I,t.isFullscreen=R,t.setFullscreen=O,t.getRenderingMode=L,t.isNormalRenderingMode=D,t.isVRMode=V,t.isLenticularMode=N,t.activateTool=B,t.isToolActive=U,t.getActiveTools=k,t.requestLenticularMode=z,t.requestNormalMode=j,t.getPrevCamera=G,t.setRenderMode=H,t.toggleLenticularMode=W,t.enableDeviceTracking=X,t.disableDeviceTracking=Y,t.toggleDeviceTracking=q,t.isDeviceTracking=Z,t.setPlayerElement=J,t.setActiveColor=K,t.setHoverColor=Q,t.setFullscreenBGColor=$,t.getActiveColor=ee,t.getHoverColor=te,t.getFullscreenBGColor=re,t.animateCameraTo=ie,t.resize=ae,t.filterNodesFromPosition=oe,t.filterNodesFromCenter=se,t.filterInteractiveBoxesFromPosition=ue,t.filterInteractiveBoxesFromCenter=ce,t.setCameraRadiusConstraint=fe,t.getCanvasElement=de,t.getCameraRadiusConstraint=he,t.displayThumbnail=pe,t.shouldDisplayThumbnail=me,t.getThumbnailOptions=ge,t.getThumbnailURL=ve,t.displayVrSettings=ye,t.shouldDisplayVrSettings=xe,t.setProgressBar=be,t.getProgressBar=we,t.frameScene=_e,t.createExplode=Ee,t.addGoogleAnalytics=Pe,t.getWireframeMode=Ae,t.setWireframeMode=Ce,t.setZSpaceCapable=Ie,t.getZSpaceCapable=Re,t.initStartingCamera=Oe,t.enterVrayMode=Le,t.updateVrayTranslator=De,t.requestVrayImgUpdate=Ve,t.exitVrayMode=Ne,t.onStreamingUpdate=Fe;var qe=r(0),Ze=r(34),Je=r(222),Ke=n(Je),Qe=r(61),$e=n(Qe),et=r(47),tt=n(et),rt=r(4),nt=r(72),it=r(10),at=r(19),ot=r(278),st=n(ot),lt=r(40),ut=n(lt),ct=r(63),ft=n(ct),dt=r(24),ht=r(70),pt=r(280),mt=r(23),gt=t.RENDER_MODES={high:"high",normal:"normal",vr:"vr",ar:"ar",zSpace:"zSpace",lenticular:"lenticular",nowebgl:"nowebgl"},vt=t.manipulators={orbit:"orbit",pan:"pan",zoom:"zoom",nodeRotate:"nodeRotate",nodeMove:"nodeMove",nodeScale:"nodeScale"},yt=t.progressBarOptions={default:"default",circle:"circle",line:"line",none:"none"},xt=t.WIREFRAME_MODE={NONE:0,WIREFRAME_AND_FACES:1,WIREFRAME_ONLY:2},bt="USE_MANIPULATOR",wt="SET_CAMERA",_t="SET_CAMERA_ATTRS",Mt="SET_CAMERA_POSITION",St="SET_RECT",Tt="DISPLAY_THUMBNAIL",Et="DISPLAY_VR_SETTINGS",Pt="SET_ACTIVE_COLOR",At="SET_HOVER_COLOR",Ct="SET_PLAYER_ELEMENT",It="REQUEST_FULL_SCREEN",Rt="EXIT_FULL_SCREEN",Ot="SET_FULL_SCREEN",Lt="SET_RENDER_MODE",Dt="SET_PROGRESS_BAR",Vt="REQUEST_NORMAL_MODE",Nt="REQUEST_LENTICULAR_MODE",Bt="SET_DEVICE_TRACKING",Ft="SET_BACKGROUND_COLOR",Ut="SET_THREE_OBJECTS",kt="SET_WIREFRAME_MODE",zt="SET_ZSPACE_CAPABLE",jt="SET_WEBSOCKET",Gt="ADD_STREAMING_UPDATE_LISTENER",Ht=(0,Ze.Map)({width:1280,height:960,cache:!0,renderer:"webgl"}),Wt=(0,Ze.Map)({activeColor:"#ffc85f",hoverColor:"#C08618",fullscreenBackgroundColor:"#FFF",activeManipulator:vt.orbit,fullScreen:!1,renderingMode:gt.normal,deviceTracking:!1,camera:(0,Ze.Map)({polarAngle:null,azimuthAngle:null,boundingRadius:null,maxZoom:null}),rect:new qe.Vector2(400,300),initialCameraWorldMatrix:null,initialTargetWorldMatrix:null,cameraWorldMatrix:null,displayThumbnail:!0,playerElement:null,canvasElement:null,activeCamera:null,threeObjects:(0,Ze.Map)(),displayVrSettings:!1,prevCamera:null,orientationHandler:null,constrainCameraRadius:null,progressBarOption:yt.default,thumbnailOptions:Ht,wireframeMode:xt.NONE,zSpaceCapable:!1,ws:null,streamingUpdateListeners:(0,Ze.List)()}),Xt=(0,tt.default)(Wt,(Ue={},(0,Ye.default)(Ue,kt,function(e,t){return e.set("wireframeMode",t)}),(0,Ye.default)(Ue,bt,function(e,t){return e.set("activeManipulator",t)}),(0,Ye.default)(Ue,wt,function(e,t){var r=t.id,n=t.prevCameraId;return e.set("activeCamera",r).set("prevCamera",n)}),(0,Ye.default)(Ue,_t,function(e,t){return e.mergeIn(["camera"],t)}),(0,Ye.default)(Ue,St,function(e,t){return e.set("rect",t)}),(0,Ye.default)(Ue,Mt,function(e,t){return e.merge(t)}),(0,Ye.default)(Ue,Ct,function(e,t){var r=t.playerEl,n=t.canvasEl;return e.set("playerElement",r).set("canvasElement",n)}),(0,Ye.default)(Ue,Tt,function(e,t){var r=t.display,n=t.options;return e.set("displayThumbnail",!!r).mergeIn(["thumbnailOptions"],(0,Ze.Map)(n))}),(0,Ye.default)(Ue,Et,function(e,t){return e.set("displayVrSettings",!!t)}),(0,Ye.default)(Ue,Pt,function(e,t){return e.set("activeColor",t)}),(0,Ye.default)(Ue,At,function(e,t){return e.set("hoverColor",t)}),(0,Ye.default)(Ue,Ft,function(e,t){return e.set("fullscreenBackgroundColor",t)}),(0,Ye.default)(Ue,Dt,function(e,t){return yt[t]||(t=yt.default),e.set("progressBarOption",t)}),(0,Ye.default)(Ue,It,function(e){return e.set("fullScreen",!0)}),(0,Ye.default)(Ue,Rt,function(e){return e.set("fullScreen",!1)}),(0,Ye.default)(Ue,Ot,function(e,t){return e.set("fullScreen",t)}),(0,Ye.default)(Ue,Lt,function(e,t,r){var n=r.createEvent;return e.get("renderingMode")!==t&&n("renderingMode",t),e.set("renderingMode",t)}),(0,Ye.default)(Ue,Nt,function(e,t){var r=t.trackDevice,n=t.cameraId;return e.merge({renderingMode:"lenticular",deviceTracking:r,prevCamera:n})}),(0,Ye.default)(Ue,Vt,function(e){return e.merge({renderingMode:"normal",deviceTracking:!1})}),(0,Ye.default)(Ue,Bt,function(e,t){return e.set("deviceTracking",t)}),(0,Ye.default)(Ue,"SET_CONSTRAIN_CAMERA_RADIUS",function(e,t){return e.set("constrainCameraRadius",t)}),(0,Ye.default)(Ue,Ut,function(e,t,r){return(0,r.createEvent)("threeinitialized"),e.set("threeObjects",(0,Ze.Map)(t))}),(0,Ye.default)(Ue,zt,function(e,t){return e.set("zSpaceCapable",t)}),(0,Ye.default)(Ue,jt,function(e,t,r){var n=r.createEvent;return t||n("socketdisconnect"),e.set("ws",t)}),(0,Ye.default)(Ue,Gt,function(e,t){return e.updateIn(["streamingUpdateListeners"],(0,Ze.List)(),function(e){return e.push(t)})}),Ue)),Yt={reducer:Xt,actions:{addTool:o,removeTool:s,showTool:l,hideTool:u,useManipulator:i,setCameraAttrs:h,useCamera:g,setCameraPosition:E,animateCameraTo:ie,resize:ae,displayThumbnail:pe,setActiveColor:K,requestFullscreen:A,exitFullscreen:C,setFullscreen:O,toggleFullscreen:I,setHoverColor:Q,requestLenticularMode:z,enableDeviceTracking:X,disableDeviceTracking:Y,toggleDeviceTracking:q,requestNormalMode:j,setFullscreenBGColor:$,setCameraRadiusConstraint:fe,updateToolOptions:c,setCamera:y,frameScene:_e,setProgressBar:be,createExplode:Ee,addGoogleAnalytics:Pe,setWireframeMode:Ce,enterVrayMode:Le,exitVrayMode:Ne,onStreamingUpdate:Fe,updateVrayTranslator:De,requestVrayImgUpdate:Ve},selectors:{getCamera:S,getCameraAttrs:p,getInitialCameraPosition:P,getCameraWorldTransform:m,getActiveColor:ee,getCanvasElement:de,isFullscreen:R,isVRMode:V,isLenticularMode:N,getFullscreenBGColor:re,isDeviceTracking:Z,shouldDisplayThumbnail:me,filterNodesFromPosition:oe,filterNodesFromCenter:se,getThreeScene:w,getThreeCamera:_,getProgressBar:we,getThree:b,getWireframeMode:Ae,getZSpaceCapable:Re}};t.default=Yt},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}var i,a=r(18),o=n(a),s=r(30),l=n(s),u=r(290),c=n(u),f=r(53),d=n(f),h=r(2),p=n(h),m=r(182),g=n(m),v=r(248);v.PMREMGenerator=function(e,t,r){this.sourceTexture=e,this.resolution=void 0!==r?r:256,this.samplesPerLevel=void 0!==t?t:64,this.samplesPerLevel=Math.min(128,this.samplesPerLevel),this.cubeTextureLod=null;var n=e.encoding===v.LinearEncoding||e.encoding===v.GammaEncoding||e.encoding===v.sRGBEncoding;this.sourceTexture.minFilter=n?v.LinearFilter:v.NearestFilter,this.sourceTexture.magFilter=n?v.LinearFilter:v.NearestFilter,this.sourceTexture.generateMipmaps=this.sourceTexture.generateMipmaps&&n,this.cubeLods=[];var i=this.resolution,a={format:this.sourceTexture.format,magFilter:this.sourceTexture.magFilter,minFilter:this.sourceTexture.minFilter,type:this.sourceTexture.type,generateMipmaps:this.sourceTexture.generateMipmaps,anisotropy:this.sourceTexture.anisotropy,encoding:this.sourceTexture.encoding};this.numLods=Math.log(i)/Math.log(2)-2;for(var o=0;o=this.numLods)){var s=a\n\t\t\t\tvarying vec2 vUv;\n\t\t\t\tuniform int faceIndex;\n\t\t\t\tuniform float roughness;\n\t\t\t\tuniform samplerCube envMap;\n\t\t\t\tuniform float mapSize;\n\t\t\t\tuniform vec3 testColor;\n\t\t\t\tuniform vec3 queryScale;\n\t\t\t\tuniform float seed;\n\t\t\t\tfloat poissonLine[128];\n\t\t\t\tvoid initPoissonTable()\t{\n\t\t\t\t\tpoissonLine[0] = 0.68999;\n\t\t\t\t\tpoissonLine[1] = 0.45883;\n\t\t\t\t\tpoissonLine[2] = 0.1408;\n\t\t\t\t\tpoissonLine[3] = 0.58453;\n\t\t\t\t\tpoissonLine[4] = 0.02776;\n\t\t\t\t\tpoissonLine[5] = 0.3657;\n\t\t\t\t\tpoissonLine[6] = 0.05616;\n\t\t\t\t\tpoissonLine[7] = 0.22111;\n\t\t\t\t\tpoissonLine[8] = 0.16301;\n\t\t\t\t\tpoissonLine[9] = 0.7939;\n\t\t\t\t\tpoissonLine[10] = 0.94334;\n\t\t\t\t\tpoissonLine[11] = 0.93425;\n\t\t\t\t\tpoissonLine[12] = 0.87263;\n\t\t\t\t\tpoissonLine[13] = 0.73582;\n\t\t\t\t\tpoissonLine[14] = 0.12286;\n\t\t\t\t\tpoissonLine[15] = 0.26529;\n\t\t\t\t\tpoissonLine[16] = 0.72647;\n\t\t\t\t\tpoissonLine[17] = 0.83657;\n\t\t\t\t\tpoissonLine[18] = 0.96543;\n\t\t\t\t\tpoissonLine[19] = 0.32305;\n\t\t\t\t\tpoissonLine[20] = 0.25021;\n\t\t\t\t\tpoissonLine[21] = 0.58689;\n\t\t\t\t\tpoissonLine[22] = 0.41629;\n\t\t\t\t\tpoissonLine[23] = 0.12616;\n\t\t\t\t\tpoissonLine[24] = 0.91421;\n\t\t\t\t\tpoissonLine[25] = 0.52287;\n\t\t\t\t\tpoissonLine[26] = 0.20964;\n\t\t\t\t\tpoissonLine[27] = 0.17271;\n\t\t\t\t\tpoissonLine[28] = 0.84766;\n\t\t\t\t\tpoissonLine[29] = 0.0022;\n\t\t\t\t\tpoissonLine[30] = 0.40568;\n\t\t\t\t\tpoissonLine[31] = 0.04687;\n\t\t\t\t\tpoissonLine[32] = 0.11933;\n\t\t\t\t\tpoissonLine[33] = 0.67212;\n\t\t\t\t\tpoissonLine[34] = 0.18933;\n\t\t\t\t\tpoissonLine[35] = 0.86945;\n\t\t\t\t\tpoissonLine[36] = 0.52297;\n\t\t\t\t\tpoissonLine[37] = 0.84475;\n\t\t\t\t\tpoissonLine[38] = 0.74494;\n\t\t\t\t\tpoissonLine[39] = 0.02533;\n\t\t\t\t\tpoissonLine[40] = 0.6232;\n\t\t\t\t\tpoissonLine[41] = 0.96762;\n\t\t\t\t\tpoissonLine[42] = 0.00449;\n\t\t\t\t\tpoissonLine[43] = 0.7535;\n\t\t\t\t\tpoissonLine[44] = 0.48421;\n\t\t\t\t\tpoissonLine[45] = 0.07936;\n\t\t\t\t\tpoissonLine[46] = 0.84871;\n\t\t\t\t\tpoissonLine[47] = 0.47694;\n\t\t\t\t\tpoissonLine[48] = 0.22845;\n\t\t\t\t\tpoissonLine[49] = 0.37711;\n\t\t\t\t\tpoissonLine[50] = 0.49824;\n\t\t\t\t\tpoissonLine[51] = 0.35694;\n\t\t\t\t\tpoissonLine[52] = 0.38277;\n\t\t\t\t\tpoissonLine[53] = 0.83666;\n\t\t\t\t\tpoissonLine[54] = 0.57835;\n\t\t\t\t\tpoissonLine[55] = 0.49536;\n\t\t\t\t\tpoissonLine[56] = 0.0132;\n\t\t\t\t\tpoissonLine[57] = 0.4593;\n\t\t\t\t\tpoissonLine[58] = 0.3938;\n\t\t\t\t\tpoissonLine[59] = 0.61267;\n\t\t\t\t\tpoissonLine[60] = 0.47573;\n\t\t\t\t\tpoissonLine[61] = 0.2202;\n\t\t\t\t\tpoissonLine[62] = 0.11283;\n\t\t\t\t\tpoissonLine[63] = 0.04534;\n\t\t\t\t\tpoissonLine[64] = 0.30502;\n\t\t\t\t\tpoissonLine[65] = 0.40026;\n\t\t\t\t\tpoissonLine[66] = 0.30118;\n\t\t\t\t\tpoissonLine[67] = 0.73927;\n\t\t\t\t\tpoissonLine[68] = 0.82648;\n\t\t\t\t\tpoissonLine[69] = 0.19517;\n\t\t\t\t\tpoissonLine[70] = 0.20144;\n\t\t\t\t\tpoissonLine[71] = 0.72373;\n\t\t\t\t\tpoissonLine[72] = 0.77945;\n\t\t\t\t\tpoissonLine[73] = 0.37953;\n\t\t\t\t\tpoissonLine[74] = 0.67661;\n\t\t\t\t\tpoissonLine[75] = 0.13671;\n\t\t\t\t\tpoissonLine[76] = 0.22514;\n\t\t\t\t\tpoissonLine[77] = 0.45704;\n\t\t\t\t\tpoissonLine[78] = 0.44605;\n\t\t\t\t\tpoissonLine[79] = 0.8856;\n\t\t\t\t\tpoissonLine[80] = 0.88545;\n\t\t\t\t\tpoissonLine[81] = 0.32133;\n\t\t\t\t\tpoissonLine[82] = 0.66175;\n\t\t\t\t\tpoissonLine[83] = 0.01964;\n\t\t\t\t\tpoissonLine[84] = 0.14848;\n\t\t\t\t\tpoissonLine[85] = 0.37481;\n\t\t\t\t\tpoissonLine[86] = 0.39741;\n\t\t\t\t\tpoissonLine[87] = 0.2039;\n\t\t\t\t\tpoissonLine[88] = 0.50282;\n\t\t\t\t\tpoissonLine[89] = 0.00156;\n\t\t\t\t\tpoissonLine[90] = 0.69715;\n\t\t\t\t\tpoissonLine[91] = 0.71233;\n\t\t\t\t\tpoissonLine[92] = 0.76777;\n\t\t\t\t\tpoissonLine[93] = 0.90509;\n\t\t\t\t\tpoissonLine[94] = 0.19425;\n\t\t\t\t\tpoissonLine[95] = 0.64406;\n\t\t\t\t\tpoissonLine[96] = 0.06155;\n\t\t\t\t\tpoissonLine[97] = 0.60422;\n\t\t\t\t\tpoissonLine[98] = 0.65107;\n\t\t\t\t\tpoissonLine[99] = 0.52872;\n\t\t\t\t\tpoissonLine[100] = 0.481;\n\t\t\t\t\tpoissonLine[101] = 0.95757;\n\t\t\t\t\tpoissonLine[102] = 0.53635;\n\t\t\t\t\tpoissonLine[103] = 0.42727;\n\t\t\t\t\tpoissonLine[104] = 0.91034;\n\t\t\t\t\tpoissonLine[105] = 0.24529;\n\t\t\t\t\tpoissonLine[106] = 0.75649;\n\t\t\t\t\tpoissonLine[107] = 0.13242;\n\t\t\t\t\tpoissonLine[108] = 0.75987;\n\t\t\t\t\tpoissonLine[109] = 0.62928;\n\t\t\t\t\tpoissonLine[110] = 0.84537;\n\t\t\t\t\tpoissonLine[111] = 0.95954;\n\t\t\t\t\tpoissonLine[112] = 0.47203;\n\t\t\t\t\tpoissonLine[113] = 0.6294;\n\t\t\t\t\tpoissonLine[114] = 0.67411;\n\t\t\t\t\tpoissonLine[115] = 0.89943;\n\t\t\t\t\tpoissonLine[116] = 0.77134;\n\t\t\t\t\tpoissonLine[117] = 0.77034;\n\t\t\t\t\tpoissonLine[118] = 0.46964;\n\t\t\t\t\tpoissonLine[119] = 0.78511;\n\t\t\t\t\tpoissonLine[120] = 0.74841;\n\t\t\t\t\tpoissonLine[121] = 0.51348;\n\t\t\t\t\tpoissonLine[122] = 0.58248;\n\t\t\t\t\tpoissonLine[123] = 0.00892;\n\t\t\t\t\tpoissonLine[124] = 0.89159;\n\t\t\t\t\tpoissonLine[125] = 0.14869;\n\t\t\t\t\tpoissonLine[126] = 0.39455;\n\t\t\t\t\tpoissonLine[127] = 0.75754;\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tvec3 ImportanceSampleGGX( float radians, float radius, mat3 vecSpace, float roughness )\n\t\t\t\t{\n\t\t\t\t\tfloat rad = radius * roughness;\n\t\t\t\t\tfloat up = sqrt( max( 1.0 - pow2( rad ), 0.0001 ) );\n\t\t\t\t\treturn vecSpace * vec3 (rad * cos( radians ), rad * sin( radians ), up );\n\t\t\t\t}\n\t\t\t\tmat3 matrixFromVector(vec3 n) {\n\t\t\t\t\tfloat a = 1.0 / (1.0 + n.z);\n\t\t\t\t\tfloat b = -n.x * n.y * a;\n\t\t\t\t\tvec3 b1 = vec3(1.0 - n.x * n.x * a, b, -n.x);\n\t\t\t\t\tvec3 b2 = vec3(b, 1.0 - n.y * n.y * a, -n.y);\n\t\t\t\t\treturn mat3(b1, b2, n);\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tfloat unitToRadians( float unit ) { return PI * 2.0 * unit; }\n\t\t\t\t\n\t\t\t\tvoid main() {\n\t\t\t\t\tinitPoissonTable();\n\t\t\t\t\tvec3 sampleDirection;\n\t\t\t\t\tvec2 uv = vUv*2.0 - 1.0;\n\t\t\t\t\tfloat offset = -1.0/mapSize;\n\t\t\t\t\tconst float a = -1.0;\n\t\t\t\t\tconst float b = 1.0;\n\t\t\t\t\tfloat c = -1.0 + offset;\n\t\t\t\t\tfloat d = 1.0 - offset;\n\t\t\t\t\tfloat bminusa = b - a;\n\t\t\t\t\tuv.x = (uv.x - a)/bminusa * d - (uv.x - b)/bminusa * c;\n\t\t\t\t\tuv.y = (uv.y - a)/bminusa * d - (uv.y - b)/bminusa * c;\n\t\t\t\t\tif (faceIndex==0) {\n\t\t\t\t\t\tsampleDirection = vec3(1.0, -uv.y, -uv.x);\n\t\t\t\t\t} else if (faceIndex==1) {\n\t\t\t\t\t\tsampleDirection = vec3(-1.0, -uv.y, uv.x);\n\t\t\t\t\t} else if (faceIndex==2) {\n\t\t\t\t\t\tsampleDirection = vec3(uv.x, 1.0, uv.y);\n\t\t\t\t\t} else if (faceIndex==3) {\n\t\t\t\t\t\tsampleDirection = vec3(uv.x, -1.0, -uv.y);\n\t\t\t\t\t} else if (faceIndex==4) {\n\t\t\t\t\t\tsampleDirection = vec3(uv.x, -uv.y, 1.0);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tsampleDirection = vec3(-uv.x, -uv.y, -1.0);\n\t\t\t\t\t}\n\t\t\t\t\tmat3 vecSpace = matrixFromVector(normalize(sampleDirection * queryScale));\n\t\t\t\t\tvec3 rgbColor = vec3(0.0);\n\t\t\t\t\tconst int NumSamples = SAMPLES_PER_LEVEL;\n\t\t\t\t\tvec3 direction;\n\t\t\t\t\tfloat invNumSamples = 1.0 / float(NumSamples);\n\t\t\t\t\tfor( int i = 0; i < NumSamples; i ++ ) {\n\t\t\t\t\t\tfloat unit = ( float(i) ) * invNumSamples;\n\t\t\t\t\t\tfloat angle = unitToRadians( unit + 0.5 );\n\t\t\t\t\t\tfloat radius = poissonLine[ i ];\n\t\t\t\t\t\tdirection = ImportanceSampleGGX( angle, radius, vecSpace, roughness);\n\t\t\t\t\t\tvec3 color = envMapTexelToLinear(textureCube(envMap,direction)).rgb;\n\t\t\t\t\t\trgbColor.rgb += color;\n\t\t\t\t\t}\n\t\t\t\t\trgbColor *= invNumSamples;\n\t\t\t\t\t//rgbColor = testColorMap( roughness ).rgb;\n\t\t\t\t\tgl_FragColor = linearToOutputTexel( vec4( rgbColor, 1.0 ) );\n\t\t\t\t}",blending:v.CustomBlending,blendSrc:v.OneFactor,blendDst:v.ZeroFactor,blendSrcAlpha:v.OneFactor,blendDstAlpha:v.ZeroFactor,blendEquation:v.AddEquation})}},v.PMREMCubeUVPacker=function(e,t){this.cubeLods=e,this.numLods=t;var r=4*e[0].width,n=e[0].texture,i={format:n.format,magFilter:n.magFilter,minFilter:n.minFilter,type:n.type,generateMipmaps:n.generateMipmaps,anisotropy:n.anisotropy,encoding:n.encoding===v.RGBEEncoding?v.RGBM16Encoding:n.encoding};i.encoding===v.RGBM16Encoding&&(i.magFilter=v.LinearFilter,i.minFilter=v.LinearFilter),this.CubeUVRenderTarget=new v.WebGLRenderTarget(r,r,i),this.CubeUVRenderTarget.texture.name="PMREMCubeUVPacker.cubeUv",this.CubeUVRenderTarget.texture.mapping=v.CubeUVReflectionMapping,this.camera=new v.OrthographicCamera(.5*-r,.5*r,.5*-r,.5*r,0,1e3),this.scene=new v.Scene,this.scene.add(this.camera),this.objects=[];var a=[];a.push(new v.Vector2(0,0)),a.push(new v.Vector2(1,0)),a.push(new v.Vector2(2,0)),a.push(new v.Vector2(0,1)),a.push(new v.Vector2(1,1)),a.push(new v.Vector2(2,1));var o=r;r=e[0].width;var s=0,l=4;this.numLods=Math.log(e[0].width)/Math.log(2)-2;for(var u=0;u","#include ","#include ","uniform float roughness;","#if ROUGHNESS_MAP == 1","uniform sampler2D tRoughness;","#endif","uniform float metalness;","uniform float distanceFade;","uniform float fresnelStrength;","uniform vec3 specularColor;","#if SPECULAR_MAP == 1","uniform sampler2D tSpecular;","#endif","uniform sampler2D tReflection;","#if GLOSSY_REFLECTIONS == 1","uniform sampler2D tReflection1;","uniform sampler2D tReflection2;","uniform sampler2D tReflection3;","uniform sampler2D tReflection4;","uniform sampler2D tReflectionDepth;","#endif","varying vec3 vecPosition;","varying vec3 worldNormal;","varying vec2 vUv;","varying vec4 mirrorCoord;","uniform mat4 mirrorCameraProjectionMatrix;","uniform mat4 mirrorCameraInverseProjectionMatrix;","uniform mat4 mirrorCameraWorldMatrix;","uniform float mirrorCameraNear;","uniform float mirrorCameraFar;","uniform vec2 screenSize;","uniform vec3 mirrorNormal;","uniform vec3 mirrorWorldPosition;","#if GLOSSY_REFLECTIONS == 1","float getReflectionDepth() {","return unpackRGBAToDepth( texture2DProj( tReflectionDepth, mirrorCoord ) );","}","float getReflectionViewZ( const in float reflectionDepth ) {","#if PERSPECTIVE_CAMERA == 1","return perspectiveDepthToViewZ( reflectionDepth, mirrorCameraNear, mirrorCameraFar );","#else","return orthographicDepthToViewZ( reflectionDepth, mirrorCameraNear, mirrorCameraFar );","#endif","}","vec3 getReflectionViewPosition( const in vec2 screenPosition, const in float reflectionDepth, const in float reflectionViewZ ) {","float clipW = mirrorCameraProjectionMatrix[2][3] * reflectionViewZ + mirrorCameraProjectionMatrix[3][3];","vec4 clipPosition = vec4( ( vec3( screenPosition, reflectionDepth ) - 0.5 ) * 2.0, 1.0 );","clipPosition *= clipW;","return ( mirrorCameraInverseProjectionMatrix * clipPosition ).xyz;","}","#endif","vec4 getReflection( const in vec4 mirrorCoord, const in float lodLevel ) {","#if GLOSSY_REFLECTIONS == 0","return texture2DProj( tReflection, mirrorCoord );","#else","vec4 color0, color1;","float alpha;","if( lodLevel < 1.0 ) {","color0 = texture2DProj( tReflection, mirrorCoord );","color1 = texture2DProj( tReflection1, mirrorCoord );","alpha = lodLevel;","}","else if( lodLevel < 2.0) {","color0 = texture2DProj( tReflection1, mirrorCoord );","color1 = texture2DProj( tReflection2, mirrorCoord );","alpha = lodLevel - 1.0;","}","else if( lodLevel < 3.0 ) {","color0 = texture2DProj( tReflection2, mirrorCoord );","color1 = texture2DProj( tReflection3, mirrorCoord );","alpha = lodLevel - 2.0;","}","else {","color0 = texture2DProj( tReflection3, mirrorCoord );","color1 = color0;","alpha = 0.0;","}","return mix( color0, color1, alpha );","#endif","}","void main() {","vec3 specular = specularColor;","#if SPECULAR_MAP == 1","specular *= texture2D( tSpecular, vUv );","#endif","float fade = 1.0;","#if GLOSSY_REFLECTIONS == 1","float localRoughness = roughness;","#if ROUGHNESS_MAP == 1","localRoughness *= texture2D( tRoughness, vUv ).r;","#endif","vec2 screenPosition = gl_FragCoord.xy / screenSize;","float reflectionDepth = getReflectionDepth();","float reflectionViewZ = getReflectionViewZ( reflectionDepth );","vec3 reflectionViewPosition = getReflectionViewPosition( screenPosition, reflectionDepth, reflectionViewZ );","vec3 reflectionWorldPosition = ( mirrorCameraWorldMatrix * vec4( reflectionViewPosition, 1.0 ) ).xyz;","vec3 closestPointOnMirror = projectOnPlane( reflectionWorldPosition, mirrorWorldPosition, mirrorNormal );","vec3 pointOnMirror = linePlaneIntersect( cameraPosition, normalize( reflectionWorldPosition - cameraPosition ), mirrorWorldPosition, mirrorNormal );","float distance = length( closestPointOnMirror - reflectionWorldPosition );","localRoughness = localRoughness * distance * 0.2;","float lodLevel = localRoughness;","fade = 1.0 - smoothstep( 0.0, 1.0, distanceFade * distance * 0.2 );","#else","float lodLevel = 0.0;","#endif","vec4 reflection = getReflection( mirrorCoord, lodLevel );","float dotNV = clamp( dot( normalize( worldNormal ), normalize( vecPosition ) ), EPSILON, 1.0 );","specular = mix( vec3( 0.05 ), specular, metalness );","vec3 fresnel;","if( fresnelStrength < 0.0 ) {","fresnel = mix( specular, specular * pow( dotNV, 2.0 ), -fresnelStrength ) * pow( 1.0 - roughness, 2.0 );","} else {","fresnel = mix( specular, F_Schlick( specular, dotNV ), fresnelStrength ) * pow( 1.0 - roughness, 2.0 );","}","gl_FragColor = vec4( reflection.rgb, fresnel * fade * reflection.a );","}"].join("\n")},v.ShaderChunk.sao=["#include ","float getDepth( const in vec2 screenPosition ) {","#if DEPTH_PACKING == 3201","return unpackRGBAToDepth( texture2D( tDepth, screenPosition ) );","#else","return texture2D( tDepth, screenPosition ).x;","#endif","}","vec4 setDepth( const in float depth ) {","#if DEPTH_PACKING == 3201","return packDepthToRGBA( depth );","#else","return vec4( depth, 0, 0, 0 );","#endif","}","float getViewZ( const in float depth ) {","#if PERSPECTIVE_CAMERA == 1","return perspectiveDepthToViewZ( depth, cameraNear, cameraFar );","#else","return orthographicDepthToViewZ( depth, cameraNear, cameraFar );","#endif","}"].join("\n"),v.SAOShader={blending:v.NoBlending,defines:{NUM_SAMPLES:13,NUM_RINGS:7,NORMAL_TEXTURE:0,DIFFUSE_TEXTURE:1,DEPTH_PACKING:3201,DEPTH_MIPS:0,PERSPECTIVE_CAMERA:1},extensions:{derivatives:!0},uniforms:{tDepth:{type:"t",value:null},tDepth1:{type:"t",value:null},tDepth2:{type:"t",value:null},tDepth3:{type:"t",value:null},tDiffuse:{type:"t",value:null},tNormal:{type:"t",value:null},size:{type:"v2",value:new v.Vector2(512,512)},cameraNear:{type:"f",value:1},cameraFar:{type:"f",value:100},cameraProjectionMatrix:{type:"m4",value:new v.Matrix4},cameraInverseProjectionMatrix:{type:"m4",value:new v.Matrix4},intensity:{type:"f",value:.1},occlusionSphereWorldRadius:{type:"f",value:100},worldToScreenRatio:{type:"v2",value:new v.Vector2(1,1)},randomSeed:{type:"f",value:0}},vertexShader:["varying vec2 vUv;","void main() {","vUv = uv;","gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["#include ","varying vec2 vUv;","#if DIFFUSE_TEXTURE == 1","uniform sampler2D tDiffuse;","#endif","#define MAX_MIP_LEVEL 3","uniform sampler2D tDepth;","#if DEPTH_MIPS == 1","uniform sampler2D tDepth1;","uniform sampler2D tDepth2;","uniform sampler2D tDepth3;","#endif","#if NORMAL_TEXTURE == 1","uniform sampler2D tNormal;","#endif","uniform float cameraNear;","uniform float cameraFar;","uniform mat4 cameraProjectionMatrix;","uniform mat4 cameraInverseProjectionMatrix;","uniform float intensity;","uniform float occlusionSphereWorldRadius;","uniform vec2 size;","uniform vec2 worldToScreenRatio;","uniform float randomSeed;","#include ","vec4 getDefaultColor( const in vec2 screenPosition ) {","#if DIFFUSE_TEXTURE == 1","return texture2D( tDiffuse, vUv );","#else","return vec4( 1.0 );","#endif","}","vec3 getViewPosition( const in vec2 screenPosition, const in float depth, const in float viewZ ) {","float clipW = cameraProjectionMatrix[2][3] * viewZ + cameraProjectionMatrix[3][3];","vec4 clipPosition = vec4( ( vec3( screenPosition, depth ) - 0.5 ) * 2.0, 1.0 );","clipPosition *= clipW;","return ( cameraInverseProjectionMatrix * clipPosition ).xyz;","}","vec3 getViewNormal( const in vec3 viewPosition, const in vec2 screenPosition ) {","#if NORMAL_TEXTURE == 1","return -unpackRGBToNormal( texture2D( tNormal, screenPosition ).xyz );","#else","return normalize( cross( dFdx( viewPosition ), dFdy( viewPosition ) ) );","#endif","}","float getDepthMIP( const in vec2 screenPosition, const int mipLevel ) {","vec4 rawDepth;","#if DEPTH_MIPS == 0","rawDepth = texture2D( tDepth, screenPosition );","#else","if( mipLevel == 0 ) {","rawDepth = texture2D( tDepth, screenPosition );","}","else if( mipLevel == 1 ) {","rawDepth = texture2D( tDepth1, screenPosition );","}","else if( mipLevel == 2 ) {","rawDepth = texture2D( tDepth2, screenPosition );","}","else {","rawDepth = texture2D( tDepth3, screenPosition );","}","#endif","#if DEPTH_PACKING == 3201","return unpackRGBAToDepth( rawDepth );","#else","return rawDepth.x;","#endif","}","float scaleDividedByCameraFar;","float minResolutionMultipliedByCameraFar;","float errorCorrectionFactor;","float getOcclusion( const in vec3 centerViewPosition, const in vec3 centerViewNormal, const in vec3 sampleViewPosition ) {","vec3 viewDelta = sampleViewPosition - centerViewPosition;","float viewDistance2 = dot( viewDelta, viewDelta );","return max( ( dot( centerViewNormal, viewDelta ) + centerViewPosition.z * 0.001 ) / ( viewDistance2 + 0.0001 ), 0.0 );// * smoothstep( pow2( occlusionSphereWorldRadius ), 0.0, viewDistance2 );","}","int getMipLevel( const in vec2 occlusionSphereScreenRadius ) {","return int( clamp( floor( log2( length( occlusionSphereScreenRadius * size ) ) - 4.0 ), 0.0, 3.0 ) );","}","const float ANGLE_STEP = PI2 * float( NUM_RINGS ) / float( NUM_SAMPLES );","const float INV_NUM_SAMPLES = 1.0 / float( NUM_SAMPLES );","float getAmbientOcclusion( const in vec3 centerViewPosition ) {","vec3 centerViewNormal = getViewNormal( centerViewPosition, vUv );","vec2 invSize = 1.0 / size;","vec2 occlusionSphereScreenRadius = occlusionSphereWorldRadius * worldToScreenRatio / centerViewPosition.z;","float random = rand( vUv + randomSeed );","float angle = random * PI2;","float radiusStep = INV_NUM_SAMPLES;","float radius = radiusStep * ( 0.5 + random );","float occlusionSum = 0.0;","for( int i = 0; i < NUM_SAMPLES; i ++ ) {","radius = (float(i) + 0.5) * radiusStep;","vec2 sampleUvOffset = vec2( cos( angle ), sin( angle ) ) * radius * occlusionSphereScreenRadius * 1.0;","sampleUvOffset = floor( sampleUvOffset * size + vec2( 0.5 ) ) * invSize;","if( sampleUvOffset.x == 0.0 && sampleUvOffset.y == 0.0 ) continue;","angle += ANGLE_STEP;","vec2 sampleUv = vUv + sampleUvOffset;","if( sampleUv.x <= 0.0 || sampleUv.y <= 0.0 || sampleUv.x >= 1.0 || sampleUv.y >= 1.0 ) continue;","float sampleDepth = getDepthMIP( sampleUv, int( 4.0 * radius ) );","if( sampleDepth >= ( 1.0 - EPSILON ) ) {","continue;","}","float sampleViewZ = getViewZ( sampleDepth );","vec3 sampleViewPosition = getViewPosition( sampleUv, sampleDepth, sampleViewZ );","occlusionSum += getOcclusion( centerViewPosition, centerViewNormal, sampleViewPosition );","}","return occlusionSum * intensity * 2.0 * occlusionSphereWorldRadius / ( float( NUM_SAMPLES ) );","}","void main() {","float centerDepth = getDepth( vUv );","if( centerDepth >= ( 1.0 - EPSILON ) ) {","discard;","}","float centerViewZ = getViewZ( centerDepth );","vec3 viewPosition = getViewPosition( vUv, centerDepth, centerViewZ );","float ambientOcclusion = getAmbientOcclusion( viewPosition );","gl_FragColor = packDepthToRGBA( centerDepth );","gl_FragColor.x = max( 1.0 - ambientOcclusion, 0.0 );","}"].join("\n")},v.SAODepthMinifyShader={blending:v.NoBlending,defines:{DEPTH_PACKING:3201},uniforms:{tDepth:{type:"t",value:null},cameraNear:{type:"f",value:1},cameraFar:{type:"f",value:100},size:{type:"v2",value:new v.Vector2(256,256)}},vertexShader:["varying vec2 vUv;","void main() {","vUv = uv;","gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["#include ","#include ","varying vec2 vUv;","uniform sampler2D tDepth;","uniform vec2 size;","uniform float cameraNear;","uniform float cameraFar;","void main() {","vec2 uv = vUv;","vec2 invSize = 0.5 / size;","float depth = unpackRGBAToDepth( texture2D( tDepth, vUv + invSize * vec2( -1.0, -1.0 ) ) );","depth += unpackRGBAToDepth( texture2D( tDepth, vUv + invSize * vec2( 1.0, 1.0 ) ) );","depth += unpackRGBAToDepth( texture2D( tDepth, vUv + invSize * vec2( -1.0, 1.0 ) ) );","depth += unpackRGBAToDepth( texture2D( tDepth, vUv + invSize * vec2( 1.0, -1.0 ) ) );","depth *= 0.25;","gl_FragColor = packDepthToRGBA( depth );","}"].join("\n")},v.SAOBilaterialFilterShader={blending:v.NoBlending,defines:{PERSPECTIVE_CAMERA:1,KERNEL_SAMPLE_RADIUS:4},uniforms:{tAODepth:{type:"t",value:null},tAONormal:{type:"t",value:null},size:{type:"v2",value:new v.Vector2(256,256)},kernelDirection:{type:"v2",value:new v.Vector2(1,0)},cameraNear:{type:"f",value:1},cameraFar:{type:"f",value:100},edgeSharpness:{type:"f",value:3},packOutput:{type:"f",value:1}},vertexShader:["varying vec2 vUv;","void main() {","vUv = uv;","gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["#include ","varying vec2 vUv;","uniform sampler2D tAODepth;","uniform sampler2D tAONormal;","uniform vec2 size;","uniform float cameraNear;","uniform float cameraFar;","uniform float edgeSharpness;","uniform int packOutput;","uniform vec2 kernelDirection;","#include ","float getViewZ( const in float depth ) {","#if PERSPECTIVE_CAMERA == 1","return perspectiveDepthToViewZ( depth, cameraNear, cameraFar );","#else","return orthographicDepthToViewZ( depth, cameraNear, cameraFar );","#endif","}","void addTapInfluence( const in vec2 tapUv, const in vec3 centerNormal, const in float centerViewZ, const in float kernelWeight, inout float aoSum, inout float weightSum ) {","vec4 depthTexel = texture2D( tAODepth, tapUv );","float ao = depthTexel.r;","depthTexel.r = 1.0;","float depth = unpackRGBAToDepth( depthTexel );","if( depth >= ( 1.0 - EPSILON ) ) {","return;","}","float tapViewZ = -getViewZ( depth );","float depthWeight = max(0.0, 1.0 - (edgeSharpness * 20.0) * abs(tapViewZ - centerViewZ));","vec3 normal = unpackRGBToNormal(texture2D(tAONormal, tapUv).rgb);","float normalCloseness = dot(normal, centerNormal);","float k_normal = 4.0;","float normalError = (1.0 - pow4( normalCloseness )) * k_normal;","float normalWeight = max((1.0 - edgeSharpness * normalError), 0.00);","float tapWeight = kernelWeight * ( depthWeight + normalWeight );","aoSum += ao * tapWeight;","weightSum += tapWeight;","}","float normpdf(in float x, in float sigma) {","return 0.39894*exp(-0.5*x*x/(sigma*sigma))/sigma;","}","void main() {","vec4 depthTexel = texture2D( tAODepth, vUv );","float ao = depthTexel.r;","depthTexel.r = 1.0;","float depth = unpackRGBAToDepth( depthTexel );","if( depth >= ( 1.0 - EPSILON ) ) {","discard;","}","float centerViewZ = -getViewZ( depth );","float weightSum = normpdf(0.0, 5.0) + 0.1;","float aoSum = ao * weightSum;","vec2 uvIncrement = ( kernelDirection / size );","vec2 rTapUv = vUv, lTapUv = vUv;","vec3 normalCenter = unpackRGBToNormal(texture2D(tAONormal, vUv).rgb);","for( int i = 1; i <= KERNEL_SAMPLE_RADIUS; i ++ ) {","float kernelWeight = normpdf(float(i), 5.0) + 0.1;","rTapUv += uvIncrement;","addTapInfluence( rTapUv, normalCenter, centerViewZ, kernelWeight, aoSum, weightSum );","lTapUv -= uvIncrement;","addTapInfluence( lTapUv, normalCenter, centerViewZ, kernelWeight, aoSum, weightSum );","}","ao = aoSum / weightSum;","if( packOutput == 1 ) {","gl_FragColor = depthTexel;","gl_FragColor.r = ao;","}","else {","gl_FragColor = vec4( vec3( ao ), 1.0 );","}","}"].join("\n")},v.ShaderChunk.sao2=["#include ","float getDepth( const in vec2 screenPosition ) {","#if DEPTH_PACKING == 3201","return unpackRGBAToDepth( texture2D( tDepth, screenPosition ) );","#else","return texture2D( tDepth, screenPosition ).x;","#endif","}","float getViewZ( const in float depth ) {","#if PERSPECTIVE_CAMERA == 1","return perspectiveDepthToViewZ( depth, cameraNear, cameraFar );","#else","return orthographicDepthToViewZ( depth, cameraNear, cameraFar );","#endif","}"].join("\n"),v.SAO2Shader={blending:v.NoBlending,defines:{NUM_SAMPLES:11,NUM_RINGS:3,DIFFUSE_TEXTURE:1,DEPTH_PACKING:3201,DEPTH_MIPS:0,PERSPECTIVE_CAMERA:1},extensions:{derivatives:!0},uniforms:{tDepth:{type:"t",value:null},tDepth1:{type:"t",value:null},tDepth2:{type:"t",value:null},tDepth3:{type:"t",value:null},tDepth4:{type:"t",value:null},tDepth5:{type:"t",value:null},tDiffuse:{type:"t",value:null},tNormal:{type:"t",value:null},size:{type:"v2",value:new v.Vector2(512,512)},cameraNear:{type:"f",value:1},cameraFar:{type:"f",value:100},cameraProjectionMatrix:{type:"m4",value:new v.Matrix4},cameraInverseProjectionMatrix:{type:"m4",value:new v.Matrix4},intensity:{type:"f",value:.1},bias:{type:"f",value:.001},occlusionSphereWorldRadius:{type:"f",value:100},worldToScreenRatio:{type:"v2",value:new v.Vector2(1,1)},randomSeed:{type:"f",value:0}},vertexShader:["varying vec2 vUv;","void main() {","vUv = uv;","gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["#include ","varying vec2 vUv;","#if DIFFUSE_TEXTURE == 1","uniform sampler2D tDiffuse;","#endif","#define MAX_MIP_LEVEL 5","#define LOG_MAX_OFFSET 3","#define _rand1out(_p) _p += dot(_p, _p.yzx + 19.19); return fract((_p.x + _p.y) * _p.z);","uniform sampler2D tDepth;","uniform sampler2D tDepth1;","uniform sampler2D tDepth2;","uniform sampler2D tDepth3;","uniform sampler2D tDepth4;","uniform sampler2D tDepth5;","uniform sampler2D tNormal;","uniform float cameraNear;","uniform float cameraFar;","uniform mat4 cameraProjectionMatrix;","uniform mat4 cameraInverseProjectionMatrix;","uniform float intensity;","uniform float bias;","uniform float supersampleTime;","uniform float occlusionSphereWorldRadius;","uniform vec2 size;","uniform vec2 worldToScreenRatio;","uniform float randomSeed;","#include ","vec3 getViewPosition( const in vec2 screenPosition, const in float depth, const in float viewZ ) {","float clipW = cameraProjectionMatrix[2][3] * viewZ + cameraProjectionMatrix[3][3];","vec4 clipPosition = vec4( ( vec3( screenPosition, depth ) - 0.5 ) * 2.0, 1.0 );","clipPosition *= clipW;","return ( cameraInverseProjectionMatrix * clipPosition ).xyz;","}","vec3 getViewNormal( const in vec3 viewPosition, const in vec2 screenPosition ) {","return -unpackRGBToNormal( texture2D( tNormal, screenPosition ).xyz );","}","const float INV_NUM_SAMPLES = 1.0 / float( NUM_SAMPLES );","vec3 getPositionFromOffsetPixel(","const in vec2 uvOffset,","const in float screenSpaceRadius) {","int mipLevel = int(clamp(floor(log2(screenSpaceRadius)) - float(LOG_MAX_OFFSET), 0.0, float(MAX_MIP_LEVEL)));","float d;","#if DEPTH_MIPS == 1","if (mipLevel == 0) d = unpackRGBAToDepth(texture2D(tDepth, uvOffset));","else if (mipLevel == 1) d = unpackRGBAToDepth(texture2D(tDepth1,uvOffset));","else if (mipLevel == 2) d = unpackRGBAToDepth(texture2D(tDepth2,uvOffset));","else if (mipLevel == 3) d = unpackRGBAToDepth(texture2D(tDepth3,uvOffset));","else if (mipLevel == 4) d = unpackRGBAToDepth(texture2D(tDepth4,uvOffset));","else d = unpackRGBAToDepth(texture2D(tDepth5,uvOffset));","#else","d = getDepth( uvOffset );","#endif","float sampleViewZ = getViewZ( d );","return getViewPosition( uvOffset, d, sampleViewZ );","}","float getSSAO(const in vec2 uv, const in int id, const in float randomAngle, const in float occlusionSphereScreenRadius, const in vec3 cameraSpacePosition, const in vec3 normal) {","float screenSpaceRadius = (float(id) + 0.5) * INV_NUM_SAMPLES; ","float angle = screenSpaceRadius * (float(NUM_RINGS) * 6.28) + randomAngle; ","screenSpaceRadius = max(0.75, screenSpaceRadius * occlusionSphereScreenRadius);","vec2 offsetUnitVec = vec2(cos(angle), sin(angle));","vec2 uvOffset = uv + floor(screenSpaceRadius * offsetUnitVec) / size;","if( uvOffset.x <= 0.0 || uvOffset.y <= 0.0 || uvOffset.x >= 1.0 || uvOffset.y >= 1.0 ) return 0.0;","vec3 occludingPoint = getPositionFromOffsetPixel(uvOffset, screenSpaceRadius);","occludingPoint -= cameraSpacePosition;","float vv = dot(occludingPoint, occludingPoint);","float vn = dot(occludingPoint, normal);","float invRadius2 = 1.0 / (occlusionSphereWorldRadius * occlusionSphereWorldRadius);","return max(1.0 - vv * invRadius2, 0.0) * max((vn - bias) * inversesqrt(vv), 0.0); ","}","float randomOut(vec3 v) { v = fract(v * 443.8975);","v += dot(v, v.yzx + 19.19); return fract((v.x + v.y) * v.z); }","void main() {","float centerDepth = getDepth( vUv );","if( centerDepth >= ( 1.0 - EPSILON ) ) {","discard;","}","float centerViewZ = getViewZ( centerDepth );","vec3 viewPosition = getViewPosition( vUv, centerDepth, centerViewZ );","vec3 centerViewNormal = getViewNormal( viewPosition, vUv );","vec2 occlusionSphereScreenRadius = occlusionSphereWorldRadius * worldToScreenRatio / (-viewPosition.z);","if( occlusionSphereScreenRadius.x < 1. ) {","discard;","}","float nFalloff = mix(1.0, max(0.0, 1.5 * centerViewNormal.z), 0.35);","float randomAngle = 6.23 * randomOut(vec3(vUv, 0.12 * fract(randomSeed)));;//rand_NEW( vUv + vec2( randomSeed, randomSeed * 0.12 ) );","float invRadius2 = 1.0 / (occlusionSphereWorldRadius * occlusionSphereWorldRadius);","float sum = 0.0;","sum += getSSAO(vUv, 0, randomAngle, occlusionSphereScreenRadius.x, viewPosition, centerViewNormal);","sum += getSSAO(vUv, 1, randomAngle, occlusionSphereScreenRadius.x, viewPosition, centerViewNormal);","sum += getSSAO(vUv, 2, randomAngle, occlusionSphereScreenRadius.x, viewPosition, centerViewNormal);","sum += getSSAO(vUv, 3, randomAngle, occlusionSphereScreenRadius.x, viewPosition, centerViewNormal);","sum += getSSAO(vUv, 4, randomAngle, occlusionSphereScreenRadius.x, viewPosition, centerViewNormal);","sum += getSSAO(vUv, 5, randomAngle, occlusionSphereScreenRadius.x, viewPosition, centerViewNormal);","sum += getSSAO(vUv, 6, randomAngle, occlusionSphereScreenRadius.x, viewPosition, centerViewNormal);","sum += getSSAO(vUv, 7, randomAngle, occlusionSphereScreenRadius.x, viewPosition, centerViewNormal);","sum += getSSAO(vUv, 8, randomAngle, occlusionSphereScreenRadius.x, viewPosition, centerViewNormal);","sum += getSSAO(vUv, 9, randomAngle, occlusionSphereScreenRadius.x, viewPosition, centerViewNormal);","sum += getSSAO(vUv, 10, randomAngle, occlusionSphereScreenRadius.x, viewPosition, centerViewNormal);","float aoValue = max(0.0, 1.0 - sqrt(sum * nFalloff * INV_NUM_SAMPLES));","aoValue = pow(aoValue, 10.0 * intensity);","float ambientOcclusion = mix(1.0, aoValue, clamp(occlusionSphereScreenRadius.x - 1.0, 0.0, 1.0));","gl_FragColor = packDepthToRGBA( centerDepth );","gl_FragColor.x = max( ambientOcclusion, 0.0 );","}"].join("\n")},v.SAO2DepthMinifyShader={blending:v.NoBlending,defines:{DEPTH_PACKING:1},uniforms:{tDepth:{type:"t",value:null},cameraNear:{type:"f",value:1},cameraFar:{type:"f",value:100},size:{type:"v2",value:new v.Vector2(256,256)}},vertexShader:["varying vec2 vUv;","void main() {","vUv = uv;","gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["#include ","#include ","varying vec2 vUv;","uniform sampler2D tDepth;","uniform vec2 size;","uniform float cameraNear;","uniform float cameraFar;","void main() {","vec2 uv = vUv;","vec2 invSize = 0.5 / size;","float depth = unpackRGBAToDepth( texture2D( tDepth, vUv + invSize * vec2( 1.0, 1.0 ) ) );","depth += unpackRGBAToDepth( texture2D( tDepth, vUv + invSize * vec2( 1.0, 1.0 ) ) );","depth += unpackRGBAToDepth( texture2D( tDepth, vUv + invSize * vec2( -1.0, 1.0 ) ) );","depth += unpackRGBAToDepth( texture2D( tDepth, vUv + invSize * vec2( 1.0, -1.0 ) ) );","depth *= 0.25;","gl_FragColor = packDepthToRGBA( depth );","}"].join("\n")},v.SAO2BilaterialFilterShader={blending:v.NoBlending,extensions:{derivatives:!0},defines:{PERSPECTIVE_CAMERA:1,KERNEL_SAMPLE_RADIUS:4},uniforms:{tAODepth:{type:"t",value:null},tAONormal:{type:"t",value:null},size:{type:"v2",value:new v.Vector2(256,256)},kernelDirection:{type:"v2",value:new v.Vector2(1,0)},cameraNear:{type:"f",value:1},cameraFar:{type:"f",value:100},edgeSharpness:{type:"f",value:3},packOutput:{type:"f",value:1}},vertexShader:["varying vec2 vUv;","void main() {","vUv = uv;","gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["#include ","varying vec2 vUv;","uniform sampler2D tAODepth;","uniform sampler2D tAONormal;","uniform vec2 size;","uniform float cameraNear;","uniform float cameraFar;","uniform float edgeSharpness;","uniform int packOutput;","uniform vec2 kernelDirection;","#include ","float getViewZ( const in float depth ) {","#if PERSPECTIVE_CAMERA == 1","return perspectiveDepthToViewZ( depth, cameraNear, cameraFar );","#else","return orthographicDepthToViewZ( depth, cameraNear, cameraFar );","#endif","}","void addTapInfluence( const in vec2 tapUv, const in float centerViewZ, const in float kernelWeight, inout float aoSum, inout float weightSum ) {","vec4 depthTexel = texture2D( tAODepth, tapUv );","float ao = depthTexel.r;","depthTexel.r = 1.0;","float depth = unpackRGBAToDepth( depthTexel );","if( depth >= ( 1.0 - EPSILON ) ) {","return;","}","float tapViewZ = -getViewZ( depth );","float depthWeight = max(0.0, 1.0 - (edgeSharpness * 400.0) * abs(tapViewZ - centerViewZ) * kernelWeight );","float tapWeight = ( depthWeight );","aoSum += ao * tapWeight;","weightSum += tapWeight;","}","float normpdf(in float x, in float sigma) {","return 0.39894*exp(-0.5*x*x/(sigma*sigma))/sigma;","}","void main() {","vec4 depthTexel = texture2D( tAODepth, vUv );","float ao = depthTexel.r;","depthTexel.r = 1.0;","float depth = unpackRGBAToDepth( depthTexel );","if( depth >= ( 1.0 - EPSILON ) ) {","discard;","}","float centerViewZ = -getViewZ( depth );","float weights[4];","weights[0] = 0.153170;","weights[1] = 0.144893;","weights[2] = 0.122649;","weights[3] = 0.092902;","float weightSum = weights[0] + 0.3;","float aoSum = ao * weightSum;","vec2 uvIncrement = ( 2.0 * kernelDirection / ( size) );","vec2 rTapUv = vUv, lTapUv = vUv;","for( int i = 1; i <= KERNEL_SAMPLE_RADIUS; i ++ ) {","float kernelWeight = weights[i] + 0.3;","rTapUv += uvIncrement;","addTapInfluence( rTapUv, centerViewZ, kernelWeight, aoSum, weightSum );","lTapUv -= uvIncrement;","addTapInfluence( lTapUv, centerViewZ, kernelWeight, aoSum, weightSum );","}","ao = aoSum / weightSum;","if( packOutput == 1 ) {","gl_FragColor = depthTexel;","gl_FragColor.r = ao;","}","else {","gl_FragColor = vec4( vec3( ao ), 1.0 );","}","}"].join("\n")},v.BlurShader={defines:{KERNEL_RADIUS:4},uniforms:{tDiffuse:{type:"t",value:null},size:{type:"v2",value:new v.Vector2(512,512)},sampleUvOffsets:{type:"v2v",value:[new v.Vector2(0,0)]},sampleWeights:{type:"1fv",value:[1]}},vertexShader:["#include ","varying vec2 vUv;","void main() {","vUv = uv;","gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["uniform sampler2D tDiffuse;","uniform vec2 size;","uniform vec2 sampleUvOffsets[ KERNEL_RADIUS + 1 ];","uniform float sampleWeights[ KERNEL_RADIUS + 1 ];","varying vec2 vUv;","void main() {","vec2 invSize = 1.0 / size;","float weightSum = sampleWeights[0];","vec4 diffuseSum = texture2D( tDiffuse, vUv ) * weightSum;","for( int i = 1; i <= KERNEL_RADIUS; i ++ ) {","float weight = sampleWeights[i];","vec2 sampleUvOffset = sampleUvOffsets[i] * invSize;","diffuseSum += ( texture2D( tDiffuse, vUv + sampleUvOffset ) + texture2D( tDiffuse, vUv - sampleUvOffset ) ) * weight;","weightSum += 2.0 * weight;","}","gl_FragColor =diffuseSum / weightSum;","}"].join("\n")},v.BlurShaderUtils={createSampleWeights:function(e,t){for(var r=[],n=0;n<=e;n++)r.push(function(e,t){return Math.exp(-e*e/(t*t*2))/(Math.sqrt(2*Math.PI)*t)}(n,t));return r},createSampleOffsets:function(e,t){for(var r=[],n=0;n<=e;n++)r.push(t.clone().multiplyScalar(n));return r},configure:function(e,t,r,n){t|=0,e.defines.KERNEL_RADIUS===t&&e.stdDev==r||(e.defines.KERNEL_RADIUS=t,e.uniforms.sampleUvOffsets.value=v.BlurShaderUtils.createSampleOffsets(t,n),e.uniforms.sampleWeights.value=v.BlurShaderUtils.createSampleWeights(t,r),e.uvIncrement=n,e.stdDev=r,e.needsUpdate=!0)}},v.LuminosityHighPassShader={shaderID:"luminosityHighPass",uniforms:{tDiffuse:{type:"t",value:null},luminosityThreshold:{type:"f",value:1},smoothWidth:{type:"f",value:1},defaultColor:{type:"c",value:new v.Color(0)},defaultOpacity:{type:"f",value:0}},vertexShader:["varying vec2 vUv;","void main() {","vUv = uv;","gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["uniform sampler2D tDiffuse;","uniform vec3 defaultColor;","uniform float defaultOpacity;","uniform float luminosityThreshold;","uniform float smoothWidth;","varying vec2 vUv;","void main() {","vec4 texel = texture2D( tDiffuse, vUv );","vec3 luma = vec3( 0.299, 0.587, 0.114 );","float v = dot( texel.xyz, luma );","vec4 outputColor = vec4( defaultColor.rgb, defaultOpacity );","float alpha = smoothstep( luminosityThreshold, luminosityThreshold + smoothWidth, v );","gl_FragColor = mix( outputColor, texel, alpha );","}"].join("\n")},v.GeometricRefractionShader={defines:{NUM_BOUNCES:4},extensions:{derivatives:!0},side:v.DoubleSide,uniforms:v.UniformsUtils.merge([v.UniformsLib.common,{normalCubeMap:{value:null},bDebugBounces:{value:!1},rIndexDelta:{value:.03},envMapIntensity:{value:1},gemIOR:{value:1},absorption:{value:new v.Vector3(0,.8,.8)},boostFactor:{value:1},boostColor:{value:new v.Vector3(1,1,1)},spectrumSpread:{value:0},sphereSquish:{value:new v.Vector3(1,1,1)},boundingSphere:{value:new v.Vector4(0,0,0,1)}}]),vertexShader:["varying vec3 vPosition;","varying vec3 vNormal;","void main() {","vPosition = position;","vNormal = normal;","gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["#include ","#include ","#include ","varying vec3 vPosition;","varying vec3 vNormal;","uniform float gemIOR;","uniform float boostFactor;","uniform vec3 boostColor;","uniform float spectrumSpread;","uniform vec3 absorption;","uniform vec3 sphereSquish;","uniform vec4 boundingSphere;","uniform samplerCube normalCubeMap;","uniform mat4 modelMatrix;","uniform mat4 modelMatrixInverse;","const float airIOR = 1.0;","#include ","#include ","struct Ray3 { vec3 origin; vec3 direction; };","void setRay( out Ray3 resultRay, in vec3 origin, in vec3 direction ) {","resultRay.origin = origin;","resultRay.direction = normalize( direction );","}","vec3 rayIntersectSquishedSphere( in Ray3 ray ) {","vec3 squishedDirection = ray.direction / sphereSquish;","float A = dot( squishedDirection, squishedDirection );","float B = 2.0 * dot( ray.origin, squishedDirection );","float C = dot( ray.origin, ray.origin ) - 1.0;","float disc = pow2( B ) - 4.0 * A * C;","if( disc > 0.0 ) {","disc = sqrt( disc );","float t1 = ( -B + disc ) * 0.5 / A;","float t2 = ( -B - disc ) * 0.5 / A;","float t = ( t1 > t2 ) ? t1 : t2;","return vec3( ray.origin + ray.direction * t );","}","return vec3( 0.0 );","}","vec3 queryEnvMapLocal( vec3 localNormal ) {","vec3 worldNormal = transformDirection( localNormal, modelMatrix );","vec3 queryVec = vec3( flipEnvMap * worldNormal.x, worldNormal.y, flipEnvMap * worldNormal.z );","#ifdef ENVMAP_TYPE_CUBE","vec3 envColor = envMapIntensity * envMapTexelToLinear( textureCube( envMap, queryVec ) ).rgb;","#elif defined( ENVMAP_TYPE_CUBE_UV )","vec3 envColor = envMapIntensity * textureCubeUV(queryVec, localNormal, 0.0).rgb;","#endif","return envColor;","}","float fresnelReflectance( float n0, float n1, vec3 incident, vec3 refracted, vec3 normal ) {","float cosI = dot( incident, normal );","float cosT = dot( refracted, normal );","float Rs = pow2( ( n0 * cosI - n1 * cosT ) / ( abs( n0 * cosI + n1 * cosT ) + 0.000001 ) );","float Rp = pow2( ( n0 * cosT - n1 * cosI ) / ( abs( n0 * cosT + n1 * cosI ) + 0.000001 ) );","return 0.5 * ( Rs + Rp );","}","vec3 traceRay( Ray3 incidentRay, vec3 diamondNormal ) {","float reflectance;","vec3 result = vec3( 0.0 );","vec3 transmittance = vec3( 1.0 );","Ray3 refractedRay, reflectedRay;","setRay( refractedRay, incidentRay.origin, refract( incidentRay.direction, diamondNormal, airIOR/gemIOR ) );","setRay( reflectedRay, incidentRay.origin, reflect( incidentRay.direction, diamondNormal ) );","reflectance = fresnelReflectance( airIOR, gemIOR, incidentRay.direction, refractedRay.direction, diamondNormal );","result += queryEnvMapLocal( reflectedRay.direction ) * reflectance;","transmittance *= ( 1.0 - reflectance );","incidentRay = refractedRay;","for( int bounce = 0; bounce < NUM_BOUNCES; bounce ++ ) {","vec3 pointOnUnitSphere = rayIntersectSquishedSphere( incidentRay );","vec4 gemstoneNormal = textureCube( normalCubeMap, pointOnUnitSphere );","vec3 inwardDiamondNormal = - normalize( unpackRGBToNormal( gemstoneNormal.rgb ) );","vec3 pointOnGemStone = pointOnUnitSphere;// * gemstoneNormal.a;","float raySegmentLength = length( pointOnGemStone - incidentRay.origin );","transmittance *= exp( -raySegmentLength * absorption );","setRay( refractedRay, pointOnGemStone, refract( incidentRay.direction, inwardDiamondNormal, gemIOR/airIOR ) );","setRay( reflectedRay, pointOnGemStone, reflect( incidentRay.direction, inwardDiamondNormal ) );","reflectance = fresnelReflectance( gemIOR, airIOR, -incidentRay.direction, refractedRay.direction, inwardDiamondNormal );","if( reflectance >= 0.0 && reflectance < 0.99 ) {","vec3 refractedColor = vec3( 0 );","refractedColor.g = queryEnvMapLocal( refractedRay.direction ).g;","setRay( refractedRay, pointOnGemStone, refract( incidentRay.direction, inwardDiamondNormal, (gemIOR+spectrumSpread*0.075)/airIOR ) );","refractedColor.r = queryEnvMapLocal( refractedRay.direction ).r;","setRay( refractedRay, pointOnGemStone, refract( incidentRay.direction, inwardDiamondNormal, (gemIOR-spectrumSpread*0.05)/airIOR ) );","refractedColor.b = queryEnvMapLocal( refractedRay.direction ).b;","result += refractedColor * transmittance * ( 1.0 - reflectance ) * boostFactor * boostColor;","}","else {","reflectance = 1.0;","if( bounce == NUM_BOUNCES - 1 ) {","result += queryEnvMapLocal( incidentRay.direction )* transmittance * boostFactor * boostColor;","}","}","transmittance *= reflectance;","incidentRay = reflectedRay;","}","return result;","}","void main() {","vec3 localCameraPosition = transformPosition( cameraPosition, modelMatrixInverse );","vec3 localRayDirection = normalize( vPosition - localCameraPosition );","vec3 unitPosition = ( vPosition - boundingSphere.xyz ) / boundingSphere.w;","Ray3 incidentRay;","setRay( incidentRay, unitPosition, localRayDirection );","vec3 color = traceRay( incidentRay, vNormal );","gl_FragColor = vec4( toneMapping( color.rgb ), 1.0 );","}"].join("\n\n")},v.GeometricNormalCaptureShader={side:v.DoubleSide,vertexShader:["varying vec3 vNormal;","varying vec3 vPosition;","void main() {","vNormal = normal;","vec4 tempPosition = modelViewMatrix * vec4( position, 1.0 );","gl_Position = projectionMatrix * tempPosition;","vPosition = tempPosition.xyz;","}"].join("\n"),fragmentShader:["#include ","varying vec3 vNormal;","varying vec3 vPosition;","void main() {","float offsetDistance = max( length( vPosition ), 0.0 );","gl_FragColor = vec4( packNormalToRGB( vNormal ), offsetDistance );","}"].join("\n")},v.FXAAShader={uniforms:{tDiffuse:{value:null},resolution:{value:new v.Vector2(1/1024,1/512)}},vertexShader:["void main() {","gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["uniform sampler2D tDiffuse;","uniform vec2 resolution;","#define FXAA_REDUCE_MIN (1.0/128.0)","#define FXAA_REDUCE_MUL (1.0/8.0)","#define FXAA_SPAN_MAX 8.0","void main() {","vec3 rgbNW = texture2D( tDiffuse, ( gl_FragCoord.xy + vec2( -1.0, -1.0 ) ) * resolution ).xyz;","vec3 rgbNE = texture2D( tDiffuse, ( gl_FragCoord.xy + vec2( 1.0, -1.0 ) ) * resolution ).xyz;","vec3 rgbSW = texture2D( tDiffuse, ( gl_FragCoord.xy + vec2( -1.0, 1.0 ) ) * resolution ).xyz;","vec3 rgbSE = texture2D( tDiffuse, ( gl_FragCoord.xy + vec2( 1.0, 1.0 ) ) * resolution ).xyz;","vec4 rgbaM = texture2D( tDiffuse, gl_FragCoord.xy * resolution );","vec3 rgbM = rgbaM.xyz;","vec3 luma = vec3( 0.299, 0.587, 0.114 );","float lumaNW = dot( rgbNW, luma );","float lumaNE = dot( rgbNE, luma );","float lumaSW = dot( rgbSW, luma );","float lumaSE = dot( rgbSE, luma );","float lumaM = dot( rgbM, luma );","float lumaMin = min( lumaM, min( min( lumaNW, lumaNE ), min( lumaSW, lumaSE ) ) );","float lumaMax = max( lumaM, max( max( lumaNW, lumaNE) , max( lumaSW, lumaSE ) ) );","vec2 dir;","dir.x = -((lumaNW + lumaNE) - (lumaSW + lumaSE));","dir.y = ((lumaNW + lumaSW) - (lumaNE + lumaSE));","float dirReduce = max( ( lumaNW + lumaNE + lumaSW + lumaSE ) * ( 0.25 * FXAA_REDUCE_MUL ), FXAA_REDUCE_MIN );","float rcpDirMin = 1.0 / ( min( abs( dir.x ), abs( dir.y ) ) + dirReduce );","dir = min( vec2( FXAA_SPAN_MAX, FXAA_SPAN_MAX),","max( vec2(-FXAA_SPAN_MAX, -FXAA_SPAN_MAX),","dir * rcpDirMin)) * resolution;","vec4 rgbA = (1.0/2.0) * (","texture2D(tDiffuse, gl_FragCoord.xy * resolution + dir * (1.0/3.0 - 0.5)) +","texture2D(tDiffuse, gl_FragCoord.xy * resolution + dir * (2.0/3.0 - 0.5)));","vec4 rgbB = rgbA * (1.0/2.0) + (1.0/4.0) * (","texture2D(tDiffuse, gl_FragCoord.xy * resolution + dir * (0.0/3.0 - 0.5)) +","texture2D(tDiffuse, gl_FragCoord.xy * resolution + dir * (3.0/3.0 - 0.5)));","float lumaB = dot(rgbB, vec4(luma, 0.0));","if ( ( lumaB < lumaMin ) || ( lumaB > lumaMax ) ) {","gl_FragColor = rgbA;","} else {","gl_FragColor = rgbB;","}","}"].join("\n")},v.NoiseShader={uniforms:{},vertexShader:["varying vec2 vUv;","void main() {","vUv = uv;","gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);","}"].join("\n"),fragmentShader:["#include ","varying vec2 vUv;","void main() {","gl_FragColor = vec4(rand(vUv), vec3(0.0));","}"].join("\n")},v.EffectComposer=function(e,t,r){if(this.renderer=e,this.cameraAware=t||!1,void 0===r){var n={minFilter:v.LinearFilter,magFilter:v.LinearFilter,format:v.RGBAFormat,stencilBuffer:!0},i=e.getSize();r=new v.WebGLRenderTarget(i.width,i.height,n),r.texture.name="EffectComposer.rt1",r.texture.generateMipmaps=!1}this.renderTarget1=r,this.renderTarget2=r.clone(),this.renderTarget2.texture.name="EffectComposer.rt2",this.renderTarget2.texture.generateMipmaps=!1,this.writeBuffer=this.renderTarget1,this.readBuffer=this.renderTarget2,this.cameraAware&&(this.writeBuffer2=this.renderTarget1.clone(),this.readBuffer2=this.renderTarget2.clone()),this.tempBufferMap={},this.passes=[],void 0===v.CopyShader&&console.error("THREE.EffectComposer relies on THREE.CopyShader"),this.copyPass=new v.ShaderPass(v.CopyShader)},(0,p.default)(v.EffectComposer.prototype,{swapBuffers:function(){var e=this.readBuffer;this.readBuffer=this.writeBuffer,this.writeBuffer=e},swapDualBuffers:function(){var e=this.readBuffer;this.readBuffer=this.writeBuffer,this.writeBuffer=e,e=this.readBuffer2,this.readBuffer2=this.writeBuffer2,this.writeBuffer2=e},requestBuffer:function(e){if(!this.tempBufferMap[e]){var t=this.renderTarget1.clone();t.texture.name="EffectComposer.buffer["+e+"]",t.texture.generateMipmaps=!1,this.tempBufferMap[e]=t}return this.tempBufferMap[e]},addPass:function(e){this.passes.push(e);var t=this.renderer.getSize();e.setSize(t.width,t.height)},insertPass:function(e,t){this.passes.splice(t,0,e)},render:function(e){var t,r,n=!1,i=this.passes.length;for(r=0;r\n\t\t\t\t#include \n\t\t\t\tvarying vec2 vUv;\n\t\t\t\tuniform sampler2D colorTexture;\n\t\t\t\t\t\t\t\tvoid main() {\n\t\t\t\t\tgl_FragColor = texture2D(colorTexture, vUv);\n\t\t\t\t}"})},getCoCMaterial:function(){return new v.ShaderMaterial({uniforms:{depthTexture:{value:null},NearFarBlurScale:{value:new v.Vector2(.5,.5)},cameraNearFar:{value:new v.Vector2(.1,100)},focalDistance:{value:1}},vertexShader:"varying vec2 vUv;\n\t\t\t\tvoid main() {\n\t\t\t\t\tvUv = uv;\n\t\t\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t\t\t}",fragmentShader:"#include \n\t\t\t\t#include \n\t\t\t\tvarying vec2 vUv;\n\t\t\t\tuniform sampler2D depthTexture;\n\t\t\t\tuniform vec2 NearFarBlurScale;\t\t\t\tuniform vec2 cameraNearFar;\t\t\t\tuniform float focalDistance;\t\t\t\tconst float MAXIMUM_BLUR_SIZE = 8.0;\t\t\t\t\t\t\t\tfloat computeCoc() {\t\t\t\t\tvec4 packDepth = texture2D(depthTexture, vUv).rgba;\t\t\t\t\tif(packDepth.x == 1.0) return max(NearFarBlurScale.x, NearFarBlurScale.y);\t\t\t\t\t\tfloat depth = unpackRGBAToDepth(packDepth);\t\t\t\t\t\tdepth = -perspectiveDepthToViewZ(depth, cameraNearFar.x, cameraNearFar.y);\t\t\t\t\t\tfloat coc = (depth - focalDistance)/depth;\t\t\t\t\treturn (coc > 0.0 ? coc * NearFarBlurScale.y : coc * NearFarBlurScale.x);\t\t\t\t}\t\t\t\t\t\t\t\tvoid main() {\n\t\t\t\t\tgl_FragColor = vec4(0.0, 0.0, 0.0, computeCoc());\n\t\t\t\t}"})},getDilateNearCocMaterial:function(){return new v.ShaderMaterial({uniforms:{cocTexture:{value:null},depthTexture:{value:null},NearFarBlurScale:{value:new v.Vector2(.5,.5)},texSize:{value:new v.Vector2(.5,.5)},direction:{value:new v.Vector2(1,0)}},vertexShader:"varying vec2 vUv;\n\t\t\t\tvoid main() {\n\t\t\t\t\tvUv = uv;\n\t\t\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t\t\t}",fragmentShader:"#include \n\t\t\t\tvarying vec2 vUv;\n\t\t\t\tuniform sampler2D cocTexture;\n\t\t\t\tuniform sampler2D depthTexture;\n\t\t\t\tuniform vec2 direction;\t\t\t\tuniform vec2 texSize;\t\t\t\tuniform vec2 NearFarBlurScale;\t\t\t\tconst float MAXIMUM_BLUR_SIZE = 8.0;\t\t\t\t\t\t\t\tfloat expandNear(const in vec2 offset, const in bool isBackground) {\t\t\t\t\tfloat coc = 0.0;\t\t\t\t\tvec2 sampleOffsets = MAXIMUM_BLUR_SIZE * offset / 5.0;\t\t\t\t\tfloat coc0 = texture2D(cocTexture, vUv).a;\t\t\t\t\tfloat coc1 = texture2D(cocTexture, vUv - 5.0 * sampleOffsets).a;\t\t\t\t\tfloat coc2 = texture2D(cocTexture, vUv - 4.0 * sampleOffsets).a;\t\t\t\t\tfloat coc3 = texture2D(cocTexture, vUv - 3.0 * sampleOffsets).a;\t\t\t\t\tfloat coc4 = texture2D(cocTexture, vUv - 2.0 * sampleOffsets).a;\t\t\t\t\tfloat coc5 = texture2D(cocTexture, vUv - 1.0 * sampleOffsets).a;\t\t\t\t\tfloat coc6 = texture2D(cocTexture, vUv + 1.0 * sampleOffsets).a;\t\t\t\t\tfloat coc7 = texture2D(cocTexture, vUv + 2.0 * sampleOffsets).a;\t\t\t\t\tfloat coc8 = texture2D(cocTexture, vUv + 3.0 * sampleOffsets).a;\t\t\t\t\tfloat coc9 = texture2D(cocTexture, vUv + 4.0 * sampleOffsets).a;\t\t\t\t\tfloat coc10 = texture2D(cocTexture, vUv + 5.0 * sampleOffsets).a;\t\t\t\t\t\t\t\t\t\t\tif(isBackground){\t\t\t\t\t\tcoc = abs(coc0) * 0.095474 + \t\t\t\t\t\t(abs(coc1) + abs(coc10)) * 0.084264 + \t\t\t\t\t\t(abs(coc2) + abs(coc9)) * 0.088139 + \t\t\t\t\t\t(abs(coc3) + abs(coc8)) * 0.091276 + \t\t\t\t\t\t(abs(coc4) + abs(coc7)) * 0.093585 + \t\t\t\t\t\t(abs(coc5) + abs(coc6)) * 0.094998;\t\t\t\t\t} else {\t\t\t\t\t\tcoc = min(coc0, 0.0);\t\t\t\t\t\tcoc = min(coc1 * 0.3, coc);\t\t\t\t\t\tcoc = min(coc2 * 0.5, coc);\t\t\t\t\t\tcoc = min(coc3 * 0.75, coc);\t\t\t\t\t\tcoc = min(coc4 * 0.8, coc);\t\t\t\t\t\tcoc = min(coc5 * 0.95, coc);\t\t\t\t\t\tcoc = min(coc6 * 0.95, coc);\t\t\t\t\t\tcoc = min(coc7 * 0.8, coc);\t\t\t\t\t\tcoc = min(coc8 * 0.75, coc);\t\t\t\t\t\tcoc = min(coc9 * 0.5, coc);\t\t\t\t\t\tcoc = min(coc10 * 0.3, coc);\t\t\t\t\t\tif(abs(coc0) > abs(coc))\t\t\t\t\t\t\tcoc = coc0;\t\t\t\t\t}\t\t\t\t\treturn coc;\t\t\t\t}\t\t\t\t\t\t\t\tvoid main() {\n\t\t\t\t\tvec2 offset = direction/texSize;\t\t\t\t\tfloat coc = expandNear(offset, texture2D(depthTexture, vUv).x == 1.0);\t\t\t\t\tgl_FragColor = vec4(0.0, 0.0, 0.0, coc);\n\t\t\t\t}"})},getDofBlurCircularMaterial:function(){return new v.ShaderMaterial({uniforms:{colorTexture:{value:null},cocTexture:{value:null},depthTexture:{value:null},texSize:{value:new v.Vector2(.5,.5)}},vertexShader:"varying vec2 vUv;\n\t\t\t\tvoid main() {\n\t\t\t\t\tvUv = uv;\n\t\t\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t\t\t}",fragmentShader:"#include \n\t\t\t\tvarying vec2 vUv;\n\t\t\t\tuniform sampler2D colorTexture;\n\t\t\t\tuniform sampler2D cocTexture;\n\t\t\t\tuniform sampler2D depthTexture;\n\t\t\t\tuniform vec2 texSize;\t\t\t\tconst float MAXIMUM_BLUR_SIZE = 8.0;\t\t\t\t\t\t\t\tvec4 CircularBlur() {\t\t\t\t\t\t\t\t\t\tconst int NUM_SAMPLES = 16;\t\t\t\t\tvec2 poisson_disk_samples[NUM_SAMPLES];\t\t\t\t\tpoisson_disk_samples[0] = vec2(-0.399691779231, 0.728591545584);\t\t\t\t\tpoisson_disk_samples[1] = vec2(-0.48622557676, -0.84016533712);\t\t\t\t\tpoisson_disk_samples[2] = vec2(0.770309468987, -0.24906070432);\t\t\t\t\tpoisson_disk_samples[3] = vec2(0.556596796154, 0.820359876432);\t\t\t\t\tpoisson_disk_samples[4] = vec2(-0.933902004071, 0.0600539051593);\t\t\t\t\tpoisson_disk_samples[5] = vec2(0.330144964342, 0.207477293384);\t\t\t\t\tpoisson_disk_samples[6] = vec2(0.289013230975, -0.686749271417);\t\t\t\t\tpoisson_disk_samples[7] = vec2(-0.0832470893559, -0.187351643125);\t\t\t\t\tpoisson_disk_samples[8] = vec2(-0.296314525615, 0.254474834305);\t\t\t\t\tpoisson_disk_samples[9] = vec2(-0.850977666059, 0.484642744689);\t\t\t\t\tpoisson_disk_samples[10] = vec2(0.829287915319, 0.2345063545);\t\t\t\t\tpoisson_disk_samples[11] = vec2(-0.773042143899, -0.543741521254);\t\t\t\t\tpoisson_disk_samples[12] = vec2(0.0561133030864, 0.928419742597);\t\t\t\t\tpoisson_disk_samples[13] = vec2(-0.205799249508, -0.562072714492);\t\t\t\t\tpoisson_disk_samples[14] = vec2(-0.526991665882, -0.193690188118);\t\t\t\t\tpoisson_disk_samples[15] = vec2(-0.051789270667, -0.935374050821);\t\t\t\t\t\t\t\t\t\t\tvec4 cocr = texture2D(cocTexture, vUv);\t\t\t\t\t\t\t\t\t\t\tfloat blurDist = MAXIMUM_BLUR_SIZE * coc.a;\t\t\t\t\t\t\t\t\t\t\tfloat rnd = PI2 * rand( vUv );\t\t\t\t\tfloat costheta = cos(rnd);\t\t\t\t\tfloat sintheta = sin(rnd);\t\t\t\t\tvec4 rotationMatrix = vec4(costheta, -sintheta, sintheta, costheta);\t\t\t\t\t\t\t\t\t\t\tvec3 colorSum = vec3(0.0);\t\t\t\t\tfloat weightSum = 0.0;\t\t\t\t\t\t\t\t\t\t\tfor (int i = 0; i < NUM_SAMPLES; i++) {\t\t\t\t\t\tvec2 ofs = poisson_disk_samples[i];\t\t\t\t\t\tofs = vec2(dot(ofs, rotationMatrix.xy), dot(ofs, rotationMatrix.zw) );\t\t\t\t\t\tvec2 texcoord = vUv + blurDist * ofs / texSize.xy;\t\t\t\t\t\tvec4 sample = texture2D(colorTexture, texcoord);\t\t\t\t\t\tfloat cocWeight = abs(sample.a);\t\t\t\t\t\tcocWeight *= cocWeight * cocWeight;\t\t\t\t\t\tcolorSum += sample.rgb * cocWeight;\t\t\t\t\t\tweightSum += cocWeight;\t\t\t\t\t}\t\t\t\t\t\t\t\t\t\t\tcolorSum /= weightSum;\t\t\t\t\t\t\t\t\t\t\treturn vec4(colorSum, 1.0);\t\t\t\t}\t\t\t\t\t\t\t\tvoid main() {\n\t\t\t\t\tgl_FragColor = CircularBlur();\n\t\t\t\t}"})},getDofBlurSeperableMaterial:function(){return new v.ShaderMaterial({uniforms:{cocTexture:{value:null},colorTexture:{value:null},texSize:{value:new v.Vector2(.5,.5)},direction:{value:new v.Vector2(.5,.5)}},vertexShader:"varying vec2 vUv;\n\t\t\t\tvoid main() {\n\t\t\t\t\tvUv = uv;\n\t\t\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t\t\t}",fragmentShader:"#include \n\t\t\t\tvarying vec2 vUv;\n\t\t\t\tuniform sampler2D cocTexture;\n\t\t\t\tuniform sampler2D colorTexture;\n\t\t\t\tuniform vec2 texSize;\t\t\t\tuniform vec2 direction;\t\t\t\tconst float MAXIMUM_BLUR_SIZE = 8.0;\t\t\t\t\t\t\t\tconst float SIGMA = 5.0;\t\t\t\tconst int NUM_SAMPLES = 4;\t\t\t\tfloat normpdf(in float x, in float sigma)\t\t\t\t{\t\t\t\t\treturn 0.39894*exp(-0.5*x*x/(sigma*sigma))/sigma;\t\t\t\t}\t\t\t\t\t\t\t\tvec4 weightedBlur() { \t\t\t\t\tfloat cocIn = texture2D(cocTexture, vUv).a;\t\t\t\t\tfloat kernelRadius = MAXIMUM_BLUR_SIZE * cocIn;\t\t\t\t\tvec2 invSize = 1.0 / texSize;\t\t\t\t\tcocIn *= cocIn * cocIn;\t\t\t\t\tfloat centreSpaceWeight = normpdf(0.0, SIGMA) * abs(cocIn);\t\t\t\t\tfloat weightSum = centreSpaceWeight;\t\t\t\t\tvec4 centreSample = texture2D(colorTexture, vUv);\t\t\t\t\tvec4 diffuseSum = centreSample * weightSum;\t\t\t\t\tvec2 delta = invSize * kernelRadius/float(NUM_SAMPLES);\t\t\t\t\tfor( int i = 1; i <= NUM_SAMPLES; i ++ ) {\t\t\t\t\t\t\tfloat spaceWeight = normpdf(float(i), SIGMA);\t\t\t\t\t\t\tvec2 texcoord = direction * delta * float(i);\t\t\t\t\t\t\tvec4 rightSample = texture2D( colorTexture, vUv + texcoord);\t\t\t\t\t\t\tvec4 leftSample = texture2D( colorTexture, vUv - texcoord);\t\t\t\t\t\t\tfloat leftCocWeight = abs(texture2D( cocTexture, vUv - texcoord).a);\t\t\t\t\t\t\tfloat rightCocWeight = abs(texture2D( cocTexture, vUv + texcoord).a);\t\t\t\t\t\t\tleftCocWeight *= leftCocWeight * leftCocWeight;\t\t\t\t\t\t\trightCocWeight *= rightCocWeight * rightCocWeight;\t\t\t\t\t\t\tdiffuseSum += ( (leftSample * leftCocWeight) + (rightSample * rightCocWeight) ) * spaceWeight;\t\t\t\t\t\t\tweightSum += (spaceWeight * (leftCocWeight + rightCocWeight));\t\t\t\t\t}\t\t\t\t return diffuseSum/weightSum;\t\t\t\t}\t\t\t\t\t\t\t\tvoid main() {\n\t\t\t\t\tgl_FragColor = weightedBlur();\n\t\t\t\t}"})},getDofCombineMaterial:function(){return new v.ShaderMaterial({uniforms:{colorTexture:{value:null},blurTexture:{value:null},cocTexture:{value:null},depthTexture:{value:null},NearFarBlurScale:{value:new v.Vector2(.5,.5)},texSize:{value:new v.Vector2(.5,.5)},cameraNearFar:{value:new v.Vector2(.1,100)},focalDistance:{value:20}},vertexShader:"varying vec2 vUv;\n\t\t\t\tvoid main() {\n\t\t\t\t\tvUv = uv;\n\t\t\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t\t\t}",fragmentShader:"#include \n\t\t\t\t#include \n\t\t\t\tvarying vec2 vUv;\n\t\t\t\tuniform sampler2D colorTexture;\n\t\t\t\tuniform sampler2D blurTexture;\n\t\t\t\tuniform sampler2D cocTexture;\n\t\t\t\tuniform sampler2D depthTexture;\n\t\t\t\tuniform vec2 texSize;\t\t\t\tuniform vec2 NearFarBlurScale;\t\t\t\tuniform vec2 cameraNearFar;\t\t\t\tuniform float focalDistance;\t\t\t\t\t\t\t\tfloat computeCoc() {\t\t\t\t\tvec4 packedDepth = texture2D(depthTexture, vUv);\t\t\t\t\tif(packedDepth.x == 1.0) return max(NearFarBlurScale.x, NearFarBlurScale.y);\t\t\t\t\t\tfloat depth = unpackRGBAToDepth(packedDepth);\t\t\t\t\t\tdepth = -perspectiveDepthToViewZ(depth, cameraNearFar.x, cameraNearFar.y);\t\t\t\t\t\tfloat coc = (depth - focalDistance)/depth;\t\t\t\t\treturn (coc > 0.0 ? coc * NearFarBlurScale.y : coc * NearFarBlurScale.x);\t\t\t\t}\t\t\t\t\t\t\t\tvoid main() {\n\t\t\t\t\tvec4 blur = texture2D(blurTexture, vUv);\t\t\t\t\tblur += texture2D(blurTexture, vUv + vec2(1.5, 0.5) / texSize);\t\t\t\t\tblur += texture2D(blurTexture, vUv + vec2(-0.5, 1.5) / texSize);\t\t\t\t\tblur += texture2D(blurTexture, vUv + vec2(-1.5, -0.5) / texSize);\t\t\t\t\tblur += texture2D(blurTexture, vUv + vec2(0.5, -1.5) / texSize);\t\t\t\t\tblur /= 5.0;\t\t\t\t\tfloat coc = abs(min(texture2D(cocTexture, vUv).a, computeCoc()));\t\t\t\t\tcoc = clamp(coc * coc * 8.0, 0.0, 1.0);\t\t\t\t\tvec4 color = mix(texture2D(colorTexture, vUv), blur, vec4(coc));\t\t\t\t\tgl_FragColor = color;\n\t\t\t\t}"})}}),v.IndexPass=function(e,t,r){v.Pass.call(this),this.camera=t,this.retrieveIdFunc=r||function(e){return e.uuid},this.meshMatMap={},this.indexColorScene=e},v.IndexPass.prototype=(0,p.default)((0,d.default)(v.Pass.prototype),{constructor:v.IndexPass,switchMaterial:function(){if(this.indexColorScene){var e=this;this.indexColorScene.traverse(function(t){if("Mesh"===t.type){var r=e.retrieveIdFunc(t);if(void 0!==r)if(e.meshMatMap[r])t.material!==e.meshMatMap[r].index&&t.material!==e.meshMatMap[r].original&&(e.meshMatMap[r].original=t.material),t.material=e.enabled?e.meshMatMap[r].index:e.meshMatMap[r].original,e.enabled||(t.material.needsUpdate=!0);else{var n={};n.original=t.material;var i=r.slice(0,6);n.index=new v.MeshBasicMaterial({color:"#"+i,side:v.DoubleSide}),e.meshMatMap[r]=n}}})}},render:function(e,t,r,n,i,a){if(this.indexColorScene){var o=a||this.camera;e.toneMapping=v.NoToneMapping,e.gammaInput=!1,e.gammaOutput=!1,e.setClearColor(16777215,0),e.autoClear=!0,this.switchMaterial(),this.renderToScreen?e.render(this.indexColorScene,o):e.render(this.indexColorScene,o,t,this.clear)}}}),v.RenderPass=function(e,t,r,n,i){v.Pass.call(this),this.scene=e,this.camera=t,this.renderOver=!1,this.overrideMaterial=r,this.clearColor=n,this.clearAlpha=void 0!==i?i:0,this.clear=!0,this.clearDepth=!1,this.needsSwap=!1,void 0===v.CopyShader&&console.error("THREE.SSAARenderPass relies on THREE.CopyShader"),this.overMaterial=new v.ShaderMaterial(v.CopyShader),this.overMaterial.uniforms=v.UniformsUtils.clone(this.overMaterial.uniforms),this.overMaterial.blending=v.NormalBlending,this.overMaterial.premultipliedAlpha=!0,this.overMaterial.transparent=!0,this.overMaterial.depthTest=!1,this.overMaterial.depthWrite=!1,this.camera2=new v.OrthographicCamera(-1,1,1,-1,0,1),this.scene2=new v.Scene,this.quad2=new v.Mesh(new v.PlaneGeometry(2,2),this.copyMaterial),this.quad2.frustumCulled=!1,this.scene2.add(this.quad2)},v.RenderPass.prototype=(0,p.default)((0,d.default)(v.Pass.prototype),{constructor:v.RenderPass,render:function(e,t,r,n,i,a){var o=a||this.camera,s=e.autoClear;e.autoClear=!1,this.scene.overrideMaterial=this.overrideMaterial;var l,u;l=e.getClearColor(),u=e.getClearAlpha(),this.clearDepth&&e.clearDepth(),this.renderOver?(e.setClearColor(0,0),e.renderOverride(this.overrideMaterial,this.scene,o,t,!0),this.overMaterial.uniforms.tDiffuse.value=t.texture,void 0!==this.clearColor&&e.setClearColor(this.clearColor,this.clearAlpha),e.renderOverride(this.overMaterial,this.scene2,this.camera2,this.renderToScreen?null:r,this.clear)):(void 0!==this.clearColor&&e.setClearColor(this.clearColor,this.clearAlpha),e.renderOverride(this.overrideMaterial,this.scene,o,this.renderToScreen?null:r,this.clear)),this.clearColor&&e.setClearColor(l,u),this.scene.overrideMaterial=null,e.autoClear=s}}),v.MaskPass=function(e,t){v.Pass.call(this),this.scene=e,this.camera=t,this.clear=!0,this.needsSwap=!1,this.inverse=!1},v.MaskPass.prototype=(0,p.default)((0,d.default)(v.Pass.prototype),{constructor:v.MaskPass,render:function(e,t,r,n,i,a){var o=e.context,s=e.state;s.buffers.color.setMask(!1),s.buffers.depth.setMask(!1),s.buffers.color.setLocked(!0),s.buffers.depth.setLocked(!0);var l,u;this.inverse?(l=0,u=1):(l=1,u=0),s.buffers.stencil.setTest(!0),s.buffers.stencil.setOp(o.REPLACE,o.REPLACE,o.REPLACE),s.buffers.stencil.setFunc(o.ALWAYS,l,4294967295),s.buffers.stencil.setClear(u);var c=a||this.camera;e.render(this.scene,c,r,this.clear),e.render(this.scene,c,t,this.clear),s.buffers.color.setLocked(!1),s.buffers.depth.setLocked(!1),s.buffers.stencil.setFunc(o.EQUAL,1,4294967295),s.buffers.stencil.setOp(o.KEEP,o.KEEP,o.KEEP)}}),v.ClearMaskPass=function(){v.Pass.call(this),this.needsSwap=!1},v.ClearMaskPass.prototype=(0,d.default)(v.Pass.prototype),(0,p.default)(v.ClearMaskPass.prototype,{render:function(e,t,r,n,i){e.state.buffers.stencil.setTest(!1)}}),v.MultiPass=function(e,t,r){v.Pass.call(this),this.scene=t,this.camera=r,this.normalMaterial=new v.MeshNormalMaterial,this.normalMaterial.blending=v.NoBlending,this.orthoScene=new v.Scene,this.orthoCamera=new v.OrthographicCamera(-1,1,1,-1,-.01,1e3);var n=new v.PlaneGeometry(2,2),i=new v.Mesh(n,this.currentMaterial);this.orthoScene.add(i),this.needsSwap=!1,this.normalRenderTarget=new v.WebGLRenderTarget(256,256,{minFilter:v.NearestFilter,magFilter:v.NearestFilter,format:v.RGBAFormat}),this.side=v.FrontSide,this.normalTexture=this.normalRenderTarget.texture,this.depthMaterial=new v.MeshDepthMaterial,this.depthMaterial.blending=v.NoBlending,this.depthRenderTarget=new v.WebGLRenderTarget(256,256,{minFilter:v.NearestFilter,magFilter:v.NearestFilter,format:v.RGBAFormat}),this.depthTexture=this.depthRenderTarget.texture,this.depthTexture.depthPacking=v.RGBADepthPacking},v.MultiPass.prototype=(0,p.default)((0,d.default)(v.Pass.prototype),{constructor:v.MultiPass,dispose:function(){this.normalRenderTarget&&(this.normalRenderTarget.dispose(),this.normalRenderTarget=null),this.depthRenderTarget&&(this.depthRenderTarget.dispose(),this.depthRenderTarget=null)},setSize:function(e,t){this.normalRenderTarget&&this.normalRenderTarget.setSize(e,t),this.depthRenderTarget&&this.depthRenderTarget.setSize(e,t)},render:function(e,t,r,n,i,a){var o=a||this.camera,s=e.getClearColor(),l=e.getClearAlpha(),u=e.autoClear;this.normalMaterial.side=this.side;var c=function(e){return!e.material.transparent};e.setClearColor(new v.Color(.5,.5,1),1),e.renderOverride(this.normalMaterial,this.scene,o,this.normalRenderTarget,!0,c),this.depthRenderTarget&&(this.depthMaterial.depthPacking=this.depthTexture.depthPacking,this.depthMaterial.side=this.side,e.setClearColor(new v.Color(1,1,1),1),e.renderOverride(this.depthMaterial,this.scene,o,this.depthRenderTarget,!0,c)),e.autoClear=u,e.setClearColor(s),e.setClearAlpha(l)}}),v.OITRenderPass=function(e,t,r,n,i,a){var o=r.extensions,s={};!o.get("OES_texture_half_float")?o.get("OES_texture_float")?s.type=v.FloatType:console.log("OIT Needs either Float or Half Float texture support, using general render"):s.type=v.HalfFloatType;!!o.get("WEBGL_depth_texture")||console.warn("OIT Needs support of Depth Texture"),r.transparency=v.OrderIndependentTransperancy,this.scene=e,this.camera=t,this.renderOver=!1,this.overrideMaterial=n,this.clearColor=i,this.clearAlpha=void 0!==a?a:0,this.clear=!1,this.clearDepth=!1,this.needsSwap=!1,this.opaqueRT=new v.WebGLRenderTarget(0,0,{type:v.UnsignedByteType}),this.accumulateRT=new v.WebGLRenderTarget(0,0,s),this.revealageRT=new v.WebGLRenderTarget(0,0,{type:v.UnsignedByteType}),this.depthTexture=new v.DepthTexture,this.opaqueRT.depthTexture=this.depthTexture,this.accumulateRT.depthTexture=this.depthTexture,this.revealageRT.depthTexture=this.depthTexture,this.mergeMaterial=new v.ShaderMaterial({uniforms:{accumulationTexture:{value:null},revealageTexture:{value:null},opaqueTexture:{value:null}},vertexShader:"varying vec2 vUv;\n void main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n }",fragmentShader:"varying vec2 vUv; uniform sampler2D opaqueTexture; uniform sampler2D accumulationTexture; uniform sampler2D revealageTexture; void main() { vec4 accumulationColor = texture2D( accumulationTexture, vUv ); vec4 revealage = texture2D( revealageTexture, vUv ); vec4 opaqueColor = texture2D( opaqueTexture, vUv ); vec3 transparentColor = pow(vec3(accumulationColor.rgb / max(accumulationColor.a, 1e-5)), vec3(1.0)); vec3 finalColor = opaqueColor.rgb * revealage.r + (1.0 - revealage.r) * transparentColor; gl_FragColor = vec4( finalColor, opaqueColor.a + (1.0 - revealage.r) ); } "}),this.mergeMaterial.uniforms.accumulationTexture.value=this.accumulateRT.texture,this.mergeMaterial.uniforms.revealageTexture.value=this.revealageRT.texture,this.mergeMaterial.uniforms.opaqueTexture.value=this.opaqueRT.texture,this.copyMaterial=new v.ShaderMaterial(v.CopyShader),this.copyMaterial.uniforms=v.UniformsUtils.clone(this.copyMaterial.uniforms),void 0===v.CopyShader&&console.error("THREE.OITRenderPass relies on THREE.CopyShader"),this.blendFactorsMap=[],this.PASS_TYPE_ACCUM=0,this.PASS_TYPE_REVEALAGE=1,this.BlendStates=[],this.BlendStates[this.PASS_TYPE_ACCUM]={blending:v.CustomBlending,blendEquation:v.AddEquation,blendSrc:v.OneFactor,blendDst:v.OneFactor,blendEquationAlpha:v.AddEquation,blendSrcAlpha:v.OneFactor,blendDstAlpha:v.OneFactor,premultipliedAlpha:!1},this.BlendStates[this.PASS_TYPE_REVEALAGE]={blending:v.CustomBlending,blendEquation:v.AddEquation,blendSrc:v.ZeroFactor,blendDst:v.OneMinusSrcAlphaFactor,blendEquationAlpha:v.AddEquation,blendSrcAlpha:v.OneFactor,blendDstAlpha:v.OneFactor,premultipliedAlpha:!1}},v.OITRenderPass.prototype={constructor:v.OITRenderPass,setSize:function(e,t){this.opaqueRT.setSize(e,t),this.accumulateRT.setSize(e,t),this.revealageRT.setSize(e,t)},render:function(e,t,r,n,i,a){var o=a||this.camera,s=e.autoClear;e.autoClear=!1;var l=e.autoClearDepth,u=e.autoCleraColor,c=function(e){return!e.material.transparent||e.material.alphaTest},f=function(e){return!c(e)};if(e.projectObject(this.scene,o),0===e.transparentObjects.length)return e.autoClearColor=!1,e.render(this.scene,o,r,!0,!1,!0),void(e.autoClearColor=u);this.copyMaterial.uniforms.tDiffuse.value=r.texture,e.renderPass(this.copyMaterial,this.opaqueRT),e.autoClearColor=!1,e.render(this.scene,o,this.opaqueRT,!0,c),e.autoClearColor=u,e.autoClearDepth=!1,this.changeBlendState(e.transparentObjects,this.PASS_TYPE_ACCUM),e.oitMode=0,e.setClearColor(0,0),e.render(this.scene,o,this.accumulateRT,!0,f),this.changeBlendState(e.transparentObjects,this.PASS_TYPE_REVEALAGE),e.oitMode=1,e.setClearColor(16777215,1),e.render(this.scene,o,this.revealageRT,!0,f),this.restoreBlendState(e.transparentObjects),e.autoClearDepth=l,e.renderPass(this.mergeMaterial,r,!1),e.autoClear=s,e.oitMode=2},changeBlendState:function(e,t){if(void 0===t||t!==this.PASS_TYPE_ACCUM&&t!==this.PASS_TYPE_REVEALAGE)return void console.log("WebGLOrderIndependentTransparency::Invalid passType");this.blendFactorsMap=[];for(var r=this.BlendStates[t],n=0,i=e.length;n0){var f=.625+.75*Math.cos(.01*performance.now()/this.pulsePeriod)/2;this.tempPulseColor1.multiplyScalar(f),this.tempPulseColor2.multiplyScalar(f)}this.quad.material=this.edgeDetectionMaterial,this.edgeDetectionMaterial.uniforms.maskTexture.value=this.renderTargetMaskDownSampleBuffer.texture,this.edgeDetectionMaterial.uniforms.texSize.value=new v.Vector2(this.renderTargetMaskDownSampleBuffer.width,this.renderTargetMaskDownSampleBuffer.height),this.edgeDetectionMaterial.uniforms.visibleEdgeColor.value=this.tempPulseColor1,this.edgeDetectionMaterial.uniforms.hiddenEdgeColor.value=this.tempPulseColor2,e.render(this.scene,this.orthoCamera,this.renderTargetEdgeBuffer1,!0),this.quad.material=this.separableBlurMaterial1,this.separableBlurMaterial1.uniforms.colorTexture.value=this.renderTargetEdgeBuffer1.texture,this.separableBlurMaterial1.uniforms.direction.value=v.OutlinePass.BlurDirectionX,this.separableBlurMaterial1.uniforms.kernelRadius.value=this.edgeThickness,e.render(this.scene,this.orthoCamera,this.renderTargetBlurBuffer1,!0),this.separableBlurMaterial1.uniforms.colorTexture.value=this.renderTargetBlurBuffer1.texture,this.separableBlurMaterial1.uniforms.direction.value=v.OutlinePass.BlurDirectionY,e.render(this.scene,this.orthoCamera,this.renderTargetEdgeBuffer1,!0),this.quad.material=this.separableBlurMaterial2,this.separableBlurMaterial2.uniforms.colorTexture.value=this.renderTargetEdgeBuffer1.texture,this.separableBlurMaterial2.uniforms.direction.value=v.OutlinePass.BlurDirectionX,e.render(this.scene,this.orthoCamera,this.renderTargetBlurBuffer2,!0),this.separableBlurMaterial2.uniforms.colorTexture.value=this.renderTargetBlurBuffer2.texture,this.separableBlurMaterial2.uniforms.direction.value=v.OutlinePass.BlurDirectionY,e.render(this.scene,this.orthoCamera,this.renderTargetEdgeBuffer2,!0),this.quad.material=this.overlayMaterial,this.overlayMaterial.uniforms.maskTexture.value=this.renderTargetMaskBuffer.texture,this.overlayMaterial.uniforms.edgeTexture1.value=this.renderTargetEdgeBuffer1.texture,this.overlayMaterial.uniforms.edgeTexture2.value=this.renderTargetEdgeBuffer2.texture,this.overlayMaterial.uniforms.patternTexture.value=this.patternTexture,this.overlayMaterial.uniforms.edgeStrength.value=this.edgeStrength,this.overlayMaterial.uniforms.edgeGlow.value=this.edgeGlow,this.overlayMaterial.uniforms.usePatternTexture.value=this.usePatternTexture,i&&e.context.enable(e.context.STENCIL_TEST),e.render(this.scene,this.orthoCamera,r,!1),e.setClearColor(this.oldClearColor,this.oldClearAlpha),e.autoClear=c}},getPrepareMaskMaterial:function(){return new v.ShaderMaterial({uniforms:{depthTexture:{value:null},cameraNearFar:{value:new v.Vector2(.5,.5)},textureMatrix:{value:new v.Matrix4}},vertexShader:"varying vec2 vUv;\t\t\t\tvarying vec4 projTexCoord;\t\t\t\tvarying vec4 vPosition;\t\t\t\tuniform mat4 textureMatrix;\t\t\t\tvoid main() {\t\t\t\t\tvUv = uv;\t\t\t\t\tvPosition = modelViewMatrix * vec4( position, 1.0 );\t\t\t\t\tvec4 worldPosition = modelMatrix * vec4( position, 1.0 );\t\t\t\t\tprojTexCoord = textureMatrix * worldPosition;\t\t\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t\t\t}",fragmentShader:"#include \t\t\t\tvarying vec2 vUv;\t\t\t\tvarying vec4 vPosition;\t\t\t\tvarying vec4 projTexCoord;\t\t\t\tuniform sampler2D depthTexture;\t\t\t\tuniform vec2 cameraNearFar;\t\t\t\t\t\t\t\tvoid main() {\t\t\t\t\tfloat depth = unpackRGBAToDepth(texture2DProj( depthTexture, projTexCoord ));\t\t\t\t\tfloat viewZ = -perspectiveDepthToViewZ( depth, cameraNearFar.x, cameraNearFar.y );\t\t\t\t\tfloat depthTest = (-vPosition.z > viewZ) ? 1.0 : 0.0;\t\t\t\t\tgl_FragColor = vec4(0.0, depthTest, 1.0, 1.0);\t\t\t\t}"})},getEdgeDetectionMaterial:function(){return new v.ShaderMaterial({uniforms:{maskTexture:{value:null},texSize:{value:new v.Vector2(.5,.5)},visibleEdgeColor:{value:new v.Vector3(1,1,1)},hiddenEdgeColor:{value:new v.Vector3(1,1,1)}},vertexShader:"varying vec2 vUv;\n\t\t\t\tvoid main() {\n\t\t\t\t\tvUv = uv;\n\t\t\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t\t\t}",fragmentShader:"varying vec2 vUv;\t\t\t\tuniform sampler2D maskTexture;\t\t\t\tuniform vec2 texSize;\t\t\t\tuniform vec3 visibleEdgeColor;\t\t\t\tuniform vec3 hiddenEdgeColor;\t\t\t\t\t\t\t\tvoid main() {\n\t\t\t\t\tvec2 invSize = 1.0 / texSize;\t\t\t\t\tvec4 uvOffset = vec4(1.0, 0.0, 0.0, 1.0) * vec4(invSize, invSize);\t\t\t\t\tvec4 c1 = texture2D( maskTexture, vUv + uvOffset.xy);\t\t\t\t\tvec4 c2 = texture2D( maskTexture, vUv - uvOffset.xy);\t\t\t\t\tvec4 c3 = texture2D( maskTexture, vUv + uvOffset.yw);\t\t\t\t\tvec4 c4 = texture2D( maskTexture, vUv - uvOffset.yw);\t\t\t\t\tfloat diff1 = (c1.r - c2.r)*0.5;\t\t\t\t\tfloat diff2 = (c3.r - c4.r)*0.5;\t\t\t\t\tfloat d = length( vec2(diff1, diff2) );\t\t\t\t\tfloat a1 = min(c1.g, c2.g);\t\t\t\t\tfloat a2 = min(c3.g, c4.g);\t\t\t\t\tfloat visibilityFactor = min(a1, a2);\t\t\t\t\tvec3 edgeColor = 1.0 - visibilityFactor > 0.001 ? visibleEdgeColor : hiddenEdgeColor;\t\t\t\t\tgl_FragColor = vec4(edgeColor, 1.0) * vec4(d);\t\t\t\t}"})},getSeperableBlurMaterial:function(e){return new v.ShaderMaterial({defines:{MAX_RADIUS:e},uniforms:{colorTexture:{value:null},texSize:{value:new v.Vector2(.5,.5)},direction:{value:new v.Vector2(.5,.5)},kernelRadius:{value:1}},vertexShader:"varying vec2 vUv;\n\t\t\t\tvoid main() {\n\t\t\t\t\tvUv = uv;\n\t\t\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t\t\t}",fragmentShader:"#include \t\t\t\tvarying vec2 vUv;\t\t\t\tuniform sampler2D colorTexture;\t\t\t\tuniform vec2 texSize;\t\t\t\tuniform vec2 direction;\t\t\t\tuniform float kernelRadius;\t\t\t\t\t\t\t\tfloat gaussianPdf(in float x, in float sigma) {\t\t\t\t\treturn 0.39894 * exp( -0.5 * x * x/( sigma * sigma))/sigma;\t\t\t\t}\t\t\t\tvoid main() {\t\t\t\t\tvec2 invSize = 1.0 / texSize;\t\t\t\t\tfloat weightSum = gaussianPdf(0.0, kernelRadius);\t\t\t\t\tvec4 diffuseSum = texture2D( colorTexture, vUv)* weightSum;\t\t\t\t\tvec2 delta = direction * invSize * kernelRadius/float(MAX_RADIUS);\t\t\t\t\tvec2 uvOffset = delta;\t\t\t\t\tfor( int i = 1; i <= MAX_RADIUS; i ++ ) {\t\t\t\t\t\tfloat w = gaussianPdf(uvOffset.x, kernelRadius);\t\t\t\t\t\tvec4 sample1 = texture2D( colorTexture, vUv + uvOffset);\t\t\t\t\t\tvec4 sample2 = texture2D( colorTexture, vUv - uvOffset);\t\t\t\t\t\tdiffuseSum += ((sample1 + sample2) * w);\t\t\t\t\t\tweightSum += (2.0 * w);\t\t\t\t\t\tuvOffset += delta;\t\t\t\t\t}\t\t\t\t\tgl_FragColor = diffuseSum/weightSum;\t\t\t\t}"})},getOverlayMaterial:function(){return new v.ShaderMaterial({uniforms:{maskTexture:{value:null},edgeTexture1:{value:null},edgeTexture2:{value:null},patternTexture:{value:null},edgeStrength:{value:1},edgeGlow:{value:1},usePatternTexture:{value:0}},vertexShader:"varying vec2 vUv;\n\t\t\t\tvoid main() {\n\t\t\t\t\tvUv = uv;\n\t\t\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t\t\t}",fragmentShader:"varying vec2 vUv;\t\t\t\tuniform sampler2D maskTexture;\t\t\t\tuniform sampler2D edgeTexture1;\t\t\t\tuniform sampler2D edgeTexture2;\t\t\t\tuniform sampler2D patternTexture;\t\t\t\tuniform float edgeStrength;\t\t\t\tuniform float edgeGlow;\t\t\t\tuniform bool usePatternTexture;\t\t\t\t\t\t\t\tvoid main() {\t\t\t\t\tvec4 edgeValue1 = texture2D(edgeTexture1, vUv);\t\t\t\t\tvec4 edgeValue2 = texture2D(edgeTexture2, vUv);\t\t\t\t\tvec4 maskColor = texture2D(maskTexture, vUv);\t\t\t\t\tvec4 patternColor = texture2D(patternTexture, 6.0 * vUv);\t\t\t\t\tfloat visibilityFactor = 1.0 - maskColor.g > 0.0 ? 1.0 : 0.5;\t\t\t\t\tvec4 edgeValue = edgeValue1 + edgeValue2 * edgeGlow;\t\t\t\t\tvec4 finalColor = edgeStrength * maskColor.r * edgeValue;\t\t\t\t\tif(usePatternTexture)\t\t\t\t\t\tfinalColor += + visibilityFactor * (1.0 - maskColor.r) * (1.0 - patternColor.r);\t\t\t\t\tgl_FragColor = finalColor;\t\t\t\t}",depthTest:!1,depthWrite:!1,transparent:!0})}}),v.OutlinePass.BlurDirectionX=new v.Vector2(1,0),v.OutlinePass.BlurDirectionY=new v.Vector2(0,1),v.ShaderPass=function(e,t){v.Pass.call(this),this.textureID=void 0!==t?t:"tDiffuse",e instanceof v.ShaderMaterial?(this.uniforms=e.uniforms,this.material=e):e&&(this.uniforms=v.UniformsUtils.clone(e.uniforms),this.material=new v.ShaderMaterial({defines:e.defines||{},uniforms:this.uniforms,vertexShader:e.vertexShader,fragmentShader:e.fragmentShader})),this.camera=new v.OrthographicCamera(-1,1,1,-1,0,1),this.scene=new v.Scene,this.quad=new v.Mesh(new v.PlaneBufferGeometry(2,2),null),this.quad.frustumCulled=!1,this.scene.add(this.quad)},v.ShaderPass.prototype=(0,p.default)((0,d.default)(v.Pass.prototype),{constructor:v.ShaderPass,render:function(e,t,r,n,i,a){this.uniforms[this.textureID]&&(this.uniforms[this.textureID].value=r.texture),this.renderToScreen?e.renderPass(this.material):e.renderPass(this.material,t,this.clear)}}),v.SAOPass=function(e,t){v.Pass.call(this),this.scene=e,this.camera=t,this.intensity=.5,this.implicitNormals=!1,this.occlusionSphereWorldRadius=20,this.blurEnabled=!0,this.outputOverride=null,this.depthMIPs=!1,this.downSamplingRatio=2,this.blurKernelSize=1===this.downSamplingRatio?8:6,this.edgeSharpness=1,this.depthMaterial=new v.MeshDepthMaterial,this.depthMaterial.depthPacking=v.RGBADepthPacking,this.depthMaterial.blending=v.NoBlending,this.depthMaterial.side=v.DoubleSide,this.normalMaterial=new v.MeshNormalMaterial,this.normalMaterial.side=this.depthMaterial.side,void 0===v.SAOShader&&console.error("THREE.SAOPass relies on THREE.SAOShader"),void 0===v.CopyShader&&console.error("THREE.SAOPass relies on THREE.CopyShader"),this.depthMinifyMaterial=new v.ShaderMaterial(v.SAODepthMinifyShader),this.depthMinifyMaterial.uniforms=v.UniformsUtils.clone(this.depthMinifyMaterial.uniforms),this.depthMinifyMaterial.defines=(0,p.default)({},this.depthMinifyMaterial.defines),this.depthMinifyMaterial.blending=v.NoBlending,this.saoMaterial=new v.ShaderMaterial(v.SAOShader),this.saoMaterial.uniforms=v.UniformsUtils.clone(this.saoMaterial.uniforms),this.saoMaterial.defines=(0,p.default)({},this.saoMaterial.defines),this.saoMaterial.defines.DIFFUSE_TEXTURE=0,this.saoMaterial.defines.NORMAL_TEXTURE=this.implicitNormals?0:1,this.saoMaterial.defines.MODE=2,this.bilateralFilterMaterial=new v.ShaderMaterial(v.SAOBilaterialFilterShader),this.bilateralFilterMaterial.uniforms=v.UniformsUtils.clone(this.bilateralFilterMaterial.uniforms),this.bilateralFilterMaterial.defines=(0,p.default)({},this.bilateralFilterMaterial.defines),this.bilateralFilterMaterial.blending=v.NoBlending,this.bilateralFilterMaterial.premultipliedAlpha=!0,this.bilateralUpsamplerMaterial=this.getBilateralUpsamplerMaterial(),this.copyMaterial=new v.ShaderMaterial(v.CopyShader),this.copyMaterial.uniforms=v.UniformsUtils.clone(this.copyMaterial.uniforms),this.copyMaterial.uniforms.opacity.value=1,this.copyMaterial.blending=v.NoBlending,this.copyMaterial.premultipliedAlpha=!0,this.copyMaterial.transparent=!0,this.copyMaterial.depthTest=!1,this.copyMaterial.depthWrite=!1},v.SAOPass.prototype={dispose:function(){this.saoRenderTarget&&(this.saoRenderTarget.dispose(),this.saoRenderTarget=null),this.blurIntermediateRenderTarget&&(this.blurIntermediateRenderTarget.dispose(),this.blurIntermediateRenderTarget=null),this.depthRenderTarget&&(this.depthRenderTarget.dispose(),this.depthRenderTarget=null),this.depth1RenderTarget&&(this.depth1RenderTarget.dispose(),this.depth1RenderTarget=null),this.depth2RenderTarget&&(this.depth2RenderTarget.dispose(),this.depth2RenderTarget=null),this.depth3RenderTarget&&(this.depth3RenderTarget.dispose(),this.depth3RenderTarget=null),this.normalRenderTarget&&(this.normalRenderTarget.dispose(),this.normalRenderTarget=null),this.normalRenderTargetFullRes&&(this.normalRenderTargetFullRes.dispose(),this.normalRenderTargetFullRes=null),this.depthRenderTargetFullRes&&(this.depthRenderTargetFullRes.dispose(),this.depthRenderTargetFullRes=null),this.saoRenderTargetFullRes&&(this.saoRenderTargetFullRes.dispose(),this.saoRenderTargetFullRes=null)},setSize:function(e,t){this.saoRenderTargetFullRes&&this.saoRenderTargetFullRes.setSize(e,t),this.depthRenderTargetFullRes&&this.depthRenderTargetFullRes.setSize(e,t),this.normalRenderTargetFullRes&&this.normalRenderTargetFullRes.setSize(e,t),e=Math.ceil(e/this.downSamplingRatio),t=Math.ceil(t/this.downSamplingRatio),this.saoRenderTarget&&this.saoRenderTarget.setSize(e,t),this.blurIntermediateRenderTarget&&this.blurIntermediateRenderTarget.setSize(e,t),this.depthRenderTarget&&this.depthRenderTarget.setSize(e,t),this.depth1RenderTarget&&this.depth1RenderTarget.setSize(Math.ceil(e/2),Math.ceil(t/2)),this.depth2RenderTarget&&this.depth2RenderTarget.setSize(Math.ceil(e/4),Math.ceil(t/4)),this.depth3RenderTarget&&this.depth3RenderTarget.setSize(Math.ceil(e/8),Math.ceil(t/8)),this.normalRenderTarget&&this.normalRenderTarget.setSize(e,t),this.saoMaterial.uniforms.size.value.set(e,t),this.bilateralFilterMaterial.uniforms.size.value.set(e,t)},updateParameters:function(e){var t=1/(2*Math.tan(v.Math.DEG2RAD*e.fov*.5)),r=new v.Vector2(t/e.aspect,t);this.saoMaterial.uniforms.worldToScreenRatio.value=r,this.saoMaterial.uniforms.intensity.value=this.intensity,this.saoMaterial.uniforms.occlusionSphereWorldRadius.value=this.occlusionSphereWorldRadius,this.depthMinifyMaterial.uniforms.cameraNear.value=e.near,this.depthMinifyMaterial.uniforms.cameraFar.value=e.far,this.saoMaterial.uniforms.cameraNear.value=e.near,this.saoMaterial.uniforms.cameraFar.value=e.far,this.saoMaterial.uniforms.cameraProjectionMatrix.value=e.projectionMatrix,this.saoMaterial.uniforms.cameraInverseProjectionMatrix.value.getInverse(e.projectionMatrix),this.bilateralFilterMaterial.uniforms.cameraNear.value=e.near,this.bilateralFilterMaterial.uniforms.cameraFar.value=e.far},render:function(e,t,r,n,i,a){var o=a||this.camera,s=r.width,l=r.height;s=Math.ceil(s/this.downSamplingRatio),l=Math.ceil(l/this.downSamplingRatio);var u=r.depthBuffer&&r.depthTexture?r.depthTexture:null;this.saoRenderTarget||(this.saoRenderTarget=new v.WebGLRenderTarget(s,l,{minFilter:v.LinearFilter,magFilter:v.LinearFilter,format:v.RGBAFormat}),this.saoRenderTargetFullRes=new v.WebGLRenderTarget(r.width,r.height,{minFilter:v.LinearFilter,magFilter:v.LinearFilter,format:v.RGBAFormat}),this.blurIntermediateRenderTarget=new v.WebGLRenderTarget(s,l,{minFilter:v.LinearFilter,magFilter:v.LinearFilter,format:v.RGBAFormat}),this.depth1RenderTarget=new v.WebGLRenderTarget(Math.ceil(s/2),Math.ceil(l/2),{minFilter:v.LinearFilter,magFilter:v.LinearFilter,format:v.RGBAFormat}),this.depth2RenderTarget=new v.WebGLRenderTarget(Math.ceil(s/4),Math.ceil(l/4),{minFilter:v.LinearFilter,magFilter:v.LinearFilter,format:v.RGBAFormat}),this.depth3RenderTarget=new v.WebGLRenderTarget(Math.ceil(s/8),Math.ceil(l/8),{minFilter:v.LinearFilter,magFilter:v.LinearFilter,format:v.RGBAFormat}),this.normalRenderTarget=new v.WebGLRenderTarget(s,l,{minFilter:v.LinearFilter,magFilter:v.LinearFilter,format:v.RGBAFormat}),this.normalRenderTargetFullRes=new v.WebGLRenderTarget(r.width,r.height,{minFilter:v.LinearFilter,magFilter:v.LinearFilter,format:v.RGBAFormat})),u||this.depthRenderTarget||(this.depthRenderTarget=new v.WebGLRenderTarget(s,l,{minFilter:v.NearestFilter,magFilter:v.NearestFilter,format:v.RGBAFormat}),this.depthRenderTargetFullRes=new v.WebGLRenderTarget(r.width,r.height,{minFilter:v.NearestFilter,magFilter:v.NearestFilter,format:v.RGBAFormat}));var c=function(e){return!e.material.transparent};this.updateParameters(o);var f=e.getClearColor().getHex(),d=e.getClearAlpha(),h=e.autoClear;if(e.autoClear=!1,this.renderToScreen||(this.copyMaterial.uniforms.tDiffuse.value=r.texture,this.copyMaterial.blending=v.NoBlending,e.renderPass(this.copyMaterial,t,!0)),u)u.depthPacking=v.BasicDepthPacking;else{var p=e.getClearColor().getHex(),m=e.getClearAlpha();e.setClearColor(16777215,1),e.renderOverride(this.depthMaterial,this.scene,o,this.depthRenderTarget,!0,c),e.setClearColor(16777215,1),1!==this.downSamplingRatio&&(e.renderOverride(this.depthMaterial,this.scene,o,this.depthRenderTargetFullRes,!0,c),e.setClearColor(p,m)),u=this.depthRenderTarget.texture,u.depthPacking=v.RGBADepthPacking}if(this.depthMIPs&&(this.depthMinifyMaterial.uniforms.tDepth.value=u,this.depthMinifyMaterial.uniforms.size.value.set(s,l),e.renderPass(this.depthMinifyMaterial,this.depth1RenderTarget,!0),this.depthMinifyMaterial.uniforms.tDepth.value=this.depth1RenderTarget.texture,this.depthMinifyMaterial.uniforms.size.value.set(Math.ceil(s/2),Math.ceil(l/2)),e.renderPass(this.depthMinifyMaterial,this.depth2RenderTarget,!0),this.depthMinifyMaterial.uniforms.tDepth.value=this.depth2RenderTarget.texture,this.depthMinifyMaterial.uniforms.size.value.set(Math.ceil(s/4),Math.ceil(l/4)),e.renderPass(this.depthMinifyMaterial,this.depth3RenderTarget,!0)),"depth"===this.outputOverride)return this.copyMaterial.uniforms.tDiffuse.value=u,this.copyMaterial.blending=v.NoBlending,void e.renderPass(this.copyMaterial,this.renderToScreen?null:t,!0);if("depth1"===this.outputOverride)return this.copyMaterial.uniforms.tDiffuse.value=this.depth1RenderTarget.texture,this.copyMaterial.blending=v.NoBlending,void e.renderPass(this.copyMaterial,this.renderToScreen?null:t,!0);if("depth2"===this.outputOverride)return this.copyMaterial.uniforms.tDiffuse.value=this.depth2RenderTarget.texture,this.copyMaterial.blending=v.NoBlending,void e.renderPass(this.copyMaterial,this.renderToScreen?null:t,!0);if("depth3"===this.outputOverride)return this.copyMaterial.uniforms.tDiffuse.value=this.depth3RenderTarget.texture,this.copyMaterial.blending=v.NoBlending,void e.renderPass(this.copyMaterial,this.renderToScreen?null:t,!0);if(!this.implicitNormals){var p=e.getClearColor().getHex(),m=e.getClearAlpha();e.setClearColor(new v.Color(.5,.5,1),1),e.renderOverride(this.normalMaterial,this.scene,o,this.normalRenderTarget,!0,c),1!==this.downSamplingRatio&&(e.setClearColor(new v.Color(.5,.5,1),1),e.renderOverride(this.normalMaterial,this.scene,o,this.normalRenderTargetFullRes,!0,c)),e.setClearColor(p,m)}if("normal"===this.outputOverride)return this.copyMaterial.uniforms.tDiffuse.value=this.normalRenderTarget.texture,this.copyMaterial.blending=v.NoBlending,void e.renderPass(this.copyMaterial,this.renderToScreen?null:this.renderToScreen?null:t,!0);this.saoMaterial.defines.DEPTH_PACKING=u.depthPacking,this.saoMaterial.defines.DEPTH_MIPS=this.depthMIPs?1:0,this.saoMaterial.uniforms.tNormal.value=this.normalRenderTarget.texture,this.saoMaterial.uniforms.tDepth.value=u,this.depthMIPs&&(this.saoMaterial.uniforms.tDepth1.value=this.depth1RenderTarget.texture,this.saoMaterial.uniforms.tDepth2.value=this.depth2RenderTarget.texture,this.saoMaterial.uniforms.tDepth3.value=this.depth3RenderTarget.texture);var p=e.getClearColor().getHex(),m=e.getClearAlpha();if(e.setClearColor(16777215,1),e.renderPass(this.saoMaterial,this.saoRenderTarget,!0),this.blurEnabled&&(this.bilateralFilterMaterial.defines.KERNEL_SAMPLE_RADIUS=this.blurKernelSize,this.bilateralFilterMaterial.uniforms.tAODepth.value=this.saoRenderTarget.texture,this.bilateralFilterMaterial.uniforms.tAONormal.value=this.normalRenderTarget.texture,this.bilateralFilterMaterial.uniforms.kernelDirection.value=new v.Vector2(1,0),this.bilateralFilterMaterial.uniforms.packOutput.value=1,this.bilateralFilterMaterial.uniforms.edgeSharpness.value=this.edgeSharpness,e.renderPass(this.bilateralFilterMaterial,this.blurIntermediateRenderTarget,!0),this.bilateralFilterMaterial.uniforms.tAODepth.value=this.blurIntermediateRenderTarget.texture,this.bilateralFilterMaterial.uniforms.kernelDirection.value=new v.Vector2(0,1),this.bilateralFilterMaterial.uniforms.packOutput.value=0,e.renderPass(this.bilateralFilterMaterial,this.saoRenderTarget,!0)),this.downSamplingRatio>1&&(this.bilateralUpsamplerMaterial.uniforms.inputTexture.value=this.saoRenderTarget.texture,this.bilateralUpsamplerMaterial.uniforms.NormalTextureFullRes.value=this.normalRenderTargetFullRes.texture,this.bilateralUpsamplerMaterial.uniforms.DepthTextureFullRes.value=this.depthRenderTargetFullRes.texture,this.bilateralUpsamplerMaterial.uniforms.NormalTextureHalfRes.value=this.normalRenderTarget.texture,this.bilateralUpsamplerMaterial.uniforms.DepthTextureHalfRes.value=this.depthRenderTarget.texture,this.bilateralUpsamplerMaterial.uniforms.texSize.value=new v.Vector2(this.saoRenderTarget.width,this.saoRenderTarget.height),this.bilateralUpsamplerMaterial.uniforms.cameraNearFar.value=new v.Vector2(o.near,o.far),e.renderPass(this.bilateralUpsamplerMaterial,this.saoRenderTargetFullRes,!0)),e.setClearColor(p,m),"sao"===this.outputOverride)return this.copyMaterial.uniforms.tDiffuse.value=this.downSamplingRatio>1?this.saoRenderTargetFullRes.texture:this.saoRenderTarget.texture,this.copyMaterial.blending=v.NoBlending,void e.renderPass(this.copyMaterial,this.renderToScreen?null:t,!0);e.autoClear=!1,this.copyMaterial.uniforms.tDiffuse.value=this.downSamplingRatio>1?this.saoRenderTargetFullRes.texture:this.saoRenderTarget.texture,this.copyMaterial.blending=v.MultiplyBlending,this.copyMaterial.premultipliedAlpha=!0,e.renderPass(this.copyMaterial,this.renderToScreen?null:t,!1),e.autoClear=h,e.setClearColor(f),e.setClearAlpha(d)},getBilateralUpsamplerMaterial:function(e){return new v.ShaderMaterial({uniforms:{inputTexture:{value:null},NormalTextureFullRes:{value:null},DepthTextureFullRes:{value:null},NormalTextureHalfRes:{value:null},DepthTextureHalfRes:{value:null},texSize:{value:new v.Vector2(.5,.5)},cameraNearFar:{value:new v.Vector2(.5,.5)}},vertexShader:"varying vec2 vUv;\n\t\t\t\tvoid main() {\n\t\t\t\t\tvUv = uv;\n\t\t\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t\t\t}",fragmentShader:"#include \n\t\t\t\t#include \n\t\t\t\tvarying vec2 vUv;\n\t\t\t\tuniform sampler2D inputTexture;\n\t\t\t\tuniform sampler2D NormalTextureFullRes;\n\t\t\t\tuniform sampler2D DepthTextureFullRes;\n\t\t\t\tuniform sampler2D NormalTextureHalfRes;\n\t\t\t\tuniform sampler2D DepthTextureHalfRes;\n\t\t\t\tuniform vec2 texSize;\t\t\t\tuniform vec2 cameraNearFar;\t\t\t\t\t\t\t\tvoid main()\t\t\t\t{\t\t\t\t\tvec2 uvOffsets[4];\t\t\t\t\tuvOffsets[0] = vUv + vec2(0.0, 1.0)/texSize;\t\t\t\t\tuvOffsets[1] = vUv + vec2(1.0, 0.0)/texSize;\t\t\t\t\tuvOffsets[2] = vUv + vec2(-1.0, 0.0)/texSize;\t\t\t\t\tuvOffsets[3] = vUv + vec2(0.0, -1.0)/texSize;\t\t\t\t\t\t\t\t\t\tfloat depth_weights[4];\t\t\t\t\tfloat depth_hires = unpackRGBAToDepth(texture2D(DepthTextureFullRes, vUv));\t\t\t\t\tdepth_hires = -perspectiveDepthToViewZ(depth_hires, cameraNearFar.x, cameraNearFar.y);\t\t\t\t\tif(depth_hires == 1.0)\t\t\t\t\t\tdiscard;\t\t\t\t\tfloat depth_coarse1 = unpackRGBAToDepth(texture2D(DepthTextureHalfRes, uvOffsets[0]));\t\t\t\t\tdepth_coarse1 = -perspectiveDepthToViewZ(depth_coarse1, cameraNearFar.x, cameraNearFar.y);\t\t\t\t\tdepth_weights[0] = 1.0 / (0.001 + abs(depth_hires-depth_coarse1));\t\t\t\t\tfloat depth_coarse2 = unpackRGBAToDepth(texture2D(DepthTextureHalfRes, uvOffsets[1]));\t\t\t\t\tdepth_coarse2 = -perspectiveDepthToViewZ(depth_coarse2, cameraNearFar.x, cameraNearFar.y);\t\t\t\t\tdepth_weights[1] = 1.0 / (0.001 + abs(depth_hires-depth_coarse2));\t\t\t\t\tfloat depth_coarse3 = unpackRGBAToDepth(texture2D(DepthTextureHalfRes, uvOffsets[2]));\t\t\t\t\tdepth_coarse3 = -perspectiveDepthToViewZ(depth_coarse3, cameraNearFar.x, cameraNearFar.y);\t\t\t\t\tdepth_weights[2] = 1.0 / (0.001 + abs(depth_hires-depth_coarse3));\t\t\t\t\tfloat depth_coarse4 = unpackRGBAToDepth(texture2D(DepthTextureHalfRes, uvOffsets[3]));\t\t\t\t\tdepth_coarse4 = -perspectiveDepthToViewZ(depth_coarse4, cameraNearFar.x, cameraNearFar.y);\t\t\t\t\tdepth_weights[3] = 1.0 / (0.001 + abs(depth_hires-depth_coarse4));\t\t\t\t\t\t\t\t\t\tfloat norm_weights[4];\t\t\t\t\tvec3 norm_fullRes = unpackRGBToNormal(texture2D(NormalTextureFullRes, vUv).rgb);\t\t\t\t\tvec3 norm_coarse1 = unpackRGBToNormal(texture2D(NormalTextureHalfRes, uvOffsets[0]).rgb);\t\t\t\t\tnorm_weights[0] = pow(abs(dot(norm_coarse1, norm_fullRes)), 32.0);\t\t\t\t\tvec3 norm_coarse2 = unpackRGBToNormal(texture2D(NormalTextureHalfRes, uvOffsets[1]).rgb);\t\t\t\t\tnorm_weights[1] = pow(abs(dot(norm_coarse2, norm_fullRes)), 32.0);\t\t\t\t\tvec3 norm_coarse3 = unpackRGBToNormal(texture2D(NormalTextureHalfRes, uvOffsets[2]).rgb);\t\t\t\t\tnorm_weights[2] = pow(abs(dot(norm_coarse3, norm_fullRes)), 32.0);\t\t\t\t\tvec3 norm_coarse4 = unpackRGBToNormal(texture2D(NormalTextureHalfRes, uvOffsets[3]).rgb);\t\t\t\t\tnorm_weights[3] = pow(abs(dot(norm_coarse4, norm_fullRes)), 32.0);\t\t\t\t\t\t\t\t\t\tvec3 colorOut = vec3(0.0);\t\t\t\t\tfloat weight_sum = 0.0;\t\t\t\t\tfloat weight = norm_weights[0] * depth_weights[0];\t\t\t\t\tcolorOut += texture2D(inputTexture, uvOffsets[0]).rgb*weight;\t\t\t\t\tweight_sum += weight;\t\t\t\t weight = norm_weights[1] * depth_weights[1];\t\t\t\t\tcolorOut += texture2D(inputTexture, uvOffsets[1]).rgb*weight;\t\t\t\t\tweight_sum += weight;\t\t\t\t weight = norm_weights[2] * depth_weights[2];\t\t\t\t\tcolorOut += texture2D(inputTexture, uvOffsets[2]).rgb*weight;\t\t\t\t\tweight_sum += weight;\t\t\t\t weight = norm_weights[3] * depth_weights[3];\t\t\t\t\tcolorOut += texture2D(inputTexture, uvOffsets[3]).rgb*weight;\t\t\t\t\tweight_sum += weight;\t\t\t\t\tcolorOut /= weight_sum;\t\t\t\t\tgl_FragColor = vec4(colorOut, 1.0);\t\t\t\t}"})}},v.SAO2Pass=function(e,t){v.Pass.call(this),this.scene=e,this.camera=t,this.intensity=.15,this.occlusionSphereWorldRadius=.07,this.blurEnabled=!0,this.outputOverride=null,this.depthMIPs=!0,this.downSamplingRatio=1,this.blurKernelSize=3,this.edgeSharpness=1.3,this.bias=.001,void 0===v.SAO2Shader&&console.error("THREE.SAO2Pass relies on THREE.SAO2Shader"),void 0===v.CopyShader&&console.error("THREE.SAO2Pass relies on THREE.CopyShader"),this.depthMinifyMaterial=new v.ShaderMaterial(v.SAO2DepthMinifyShader),this.depthMinifyMaterial.uniforms=v.UniformsUtils.clone(this.depthMinifyMaterial.uniforms),this.depthMinifyMaterial.defines=(0,p.default)({},this.depthMinifyMaterial.defines),this.depthMinifyMaterial.blending=v.NoBlending,this.saoMaterial=new v.ShaderMaterial(v.SAO2Shader),this.saoMaterial.uniforms=v.UniformsUtils.clone(this.saoMaterial.uniforms),this.saoMaterial.defines=(0,p.default)({},this.saoMaterial.defines),this.saoMaterial.defines.DIFFUSE_TEXTURE=0,this.saoMaterial.defines.MODE=2,this.bilateralFilterMaterial=new v.ShaderMaterial(v.SAO2BilaterialFilterShader),this.bilateralFilterMaterial.uniforms=v.UniformsUtils.clone(this.bilateralFilterMaterial.uniforms),this.bilateralFilterMaterial.defines=(0,p.default)({},this.bilateralFilterMaterial.defines),this.bilateralFilterMaterial.blending=v.NoBlending,this.bilateralFilterMaterial.premultipliedAlpha=!0,this.copyMaterial=new v.ShaderMaterial(v.CopyShader),this.copyMaterial.uniforms=v.UniformsUtils.clone(this.copyMaterial.uniforms),this.copyMaterial.uniforms.opacity.value=1,this.copyMaterial.blending=v.NoBlending,this.copyMaterial.premultipliedAlpha=!0,this.copyMaterial.transparent=!0,this.copyMaterial.depthTest=!1,this.copyMaterial.depthWrite=!1,this.randomSeed=0,this.applySao=!0,this.depthTexture=null,this.normalTexture=null},v.SAO2Pass.prototype={dispose:function(){this.saoRenderTarget&&(this.saoRenderTarget.dispose(),this.saoRenderTarget=null),this.blurIntermediateRenderTarget&&(this.blurIntermediateRenderTarget.dispose(),this.blurIntermediateRenderTarget=null),this.depth1RenderTarget&&(this.depth1RenderTarget.dispose(),this.depth1RenderTarget=null),this.depth2RenderTarget&&(this.depth2RenderTarget.dispose(),this.depth2RenderTarget=null),this.depth3RenderTarget&&(this.depth3RenderTarget.dispose(),this.depth3RenderTarget=null),this.depth4RenderTarget&&(this.depth4RenderTarget.dispose(),this.depth4RenderTarget=null),this.depth5RenderTarget&&(this.depth5RenderTarget.dispose(),this.depth5RenderTarget=null)},setSize:function(e,t){this.saoRenderTarget&&this.saoRenderTarget.setSize(e,t),this.blurIntermediateRenderTarget&&this.blurIntermediateRenderTarget.setSize(e,t),this.depth1RenderTarget&&this.depth1RenderTarget.setSize(Math.ceil(e/4),Math.ceil(t/4)),this.depth2RenderTarget&&this.depth2RenderTarget.setSize(Math.ceil(e/8),Math.ceil(t/8)),this.depth3RenderTarget&&this.depth3RenderTarget.setSize(Math.ceil(e/16),Math.ceil(t/16)),this.depth4RenderTarget&&this.depth4RenderTarget.setSize(Math.ceil(e/32),Math.ceil(t/32)),this.depth5RenderTarget&&this.depth5RenderTarget.setSize(Math.ceil(e/64),Math.ceil(t/64)),this.saoMaterial.uniforms.size.value.set(e,t),this.bilateralFilterMaterial.uniforms.size.value.set(e,t)},updateParameters:function(e,t){var r=1/(2*Math.tan(v.Math.DEG2RAD*e.fov*.5));new v.Vector2(r/e.aspect,r);this.saoMaterial.uniforms.randomSeed.value=Math.random(),this.saoMaterial.uniforms.worldToScreenRatio.value=new v.Vector2(t*r,t*r),this.saoMaterial.uniforms.intensity.value=this.intensity,this.saoMaterial.uniforms.bias.value=this.bias,this.saoMaterial.uniforms.occlusionSphereWorldRadius.value=this.occlusionSphereWorldRadius,this.depthMinifyMaterial.uniforms.cameraNear.value=e.near,this.depthMinifyMaterial.uniforms.cameraFar.value=e.far,this.saoMaterial.uniforms.cameraNear.value=e.near,this.saoMaterial.uniforms.cameraFar.value=e.far,this.saoMaterial.uniforms.cameraProjectionMatrix.value=e.projectionMatrix,this.saoMaterial.uniforms.cameraInverseProjectionMatrix.value.getInverse(e.projectionMatrix),this.bilateralFilterMaterial.uniforms.cameraNear.value=e.near,this.bilateralFilterMaterial.uniforms.cameraFar.value=e.far},render:function(e,t,r,n,i,a){var o=a||this.camera,s=r.width,l=r.height;this.saoRenderTarget||(this.saoRenderTarget=new v.WebGLRenderTarget(s,l,{minFilter:v.LinearFilter,magFilter:v.LinearFilter,format:v.RGBAFormat}),this.blurIntermediateRenderTarget=new v.WebGLRenderTarget(s,l,{minFilter:v.NearestFilter,magFilter:v.NearestFilter,format:v.RGBAFormat}),this.depth1RenderTarget=new v.WebGLRenderTarget(Math.ceil(s/4),Math.ceil(l/4),{minFilter:v.LinearFilter,magFilter:v.LinearFilter,format:v.RGBAFormat}),this.depth2RenderTarget=new v.WebGLRenderTarget(Math.ceil(s/8),Math.ceil(l/8),{minFilter:v.LinearFilter,magFilter:v.LinearFilter,format:v.RGBAFormat}),this.depth3RenderTarget=new v.WebGLRenderTarget(Math.ceil(s/16),Math.ceil(l/16),{minFilter:v.LinearFilter,magFilter:v.LinearFilter,format:v.RGBAFormat}),this.depth4RenderTarget=new v.WebGLRenderTarget(Math.ceil(s/32),Math.ceil(l/32),{minFilter:v.LinearFilter,magFilter:v.LinearFilter,format:v.RGBAFormat}),this.depth5RenderTarget=new v.WebGLRenderTarget(Math.ceil(s/64),Math.ceil(l/64),{minFilter:v.LinearFilter,magFilter:v.LinearFilter,format:v.RGBAFormat})),this.updateParameters(o,l);var u=e.getClearColor().getHex(),c=e.getClearAlpha(),f=e.autoClear;e.autoClear=!1,this.renderToScreen||(this.copyMaterial.uniforms.tDiffuse.value=r.texture,this.copyMaterial.blending=v.NoBlending,e.renderPass(this.copyMaterial,t,!0)),this.normalTexture||console.error("SAOPass.normalTexture is required!"),this.depthTexture||console.error("SAOPass.depthTexture is required!"),this.depthMIPs=this.depthMIPs&&this.depthTexture.depthPacking!==v.BasicDepthPacking,this.depthMIPs&&this.depthTexture.depthPacking!==v.BasicDepthPacking&&(this.depthMinifyMaterial.uniforms.tDepth.value=this.depthTexture,this.depthMinifyMaterial.uniforms.size.value.set(s,l),e.renderPass(this.depthMinifyMaterial,this.depth1RenderTarget,!0),this.depthMinifyMaterial.uniforms.tDepth.value=this.depth1RenderTarget.texture,this.depthMinifyMaterial.uniforms.size.value.set(this.depth1RenderTarget.width,this.depth1RenderTarget.height),e.renderPass(this.depthMinifyMaterial,this.depth2RenderTarget,!0),this.depthMinifyMaterial.uniforms.tDepth.value=this.depth2RenderTarget.texture,this.depthMinifyMaterial.uniforms.size.value.set(this.depth2RenderTarget.width,this.depth2RenderTarget.height),e.renderPass(this.depthMinifyMaterial,this.depth3RenderTarget,!0),this.depthMinifyMaterial.uniforms.tDepth.value=this.depth3RenderTarget.texture,this.depthMinifyMaterial.uniforms.size.value.set(this.depth3RenderTarget.width,this.depth3RenderTarget.height),e.renderPass(this.depthMinifyMaterial,this.depth4RenderTarget,!0),this.depthMinifyMaterial.uniforms.tDepth.value=this.depth4RenderTarget.texture,this.depthMinifyMaterial.uniforms.size.value.set(this.depth4RenderTarget.width,this.depth4RenderTarget.height),e.renderPass(this.depthMinifyMaterial,this.depth5RenderTarget,!0)),this.saoMaterial.defines.DEPTH_PACKING=this.depthTexture.depthPacking,this.saoMaterial.defines.DEPTH_MIPS=this.depthMIPs?1:0,this.saoMaterial.uniforms.tNormal.value=this.normalTexture,this.saoMaterial.uniforms.tDepth.value=this.depthTexture,this.depthMIPs&&(this.saoMaterial.uniforms.tDepth1.value=this.depth1RenderTarget.texture,this.saoMaterial.uniforms.tDepth2.value=this.depth2RenderTarget.texture,this.saoMaterial.uniforms.tDepth3.value=this.depth3RenderTarget.texture,this.saoMaterial.uniforms.tDepth4.value=this.depth4RenderTarget.texture,this.saoMaterial.uniforms.tDepth5.value=this.depth5RenderTarget.texture);var d=e.getClearColor().getHex(),h=e.getClearAlpha();if(e.setClearColor(16777215,1),e.renderPass(this.saoMaterial,this.saoRenderTarget,!0),this.blurEnabled){var p=this.randomSeed%2==0;this.bilateralFilterMaterial.defines.KERNEL_SAMPLE_RADIUS=this.blurKernelSize,this.bilateralFilterMaterial.uniforms.tAODepth.value=this.saoRenderTarget.texture,this.bilateralFilterMaterial.uniforms.tAONormal.value=this.normalTexture,this.bilateralFilterMaterial.uniforms.kernelDirection.value=p?new v.Vector2(1,0):new v.Vector2(0,1),this.bilateralFilterMaterial.uniforms.packOutput.value=1,this.bilateralFilterMaterial.uniforms.edgeSharpness.value=this.edgeSharpness,e.renderPass(this.bilateralFilterMaterial,this.blurIntermediateRenderTarget,!0),this.bilateralFilterMaterial.uniforms.tAODepth.value=this.blurIntermediateRenderTarget.texture,this.bilateralFilterMaterial.uniforms.kernelDirection.value=p?new v.Vector2(0,1):new v.Vector2(1,0),this.bilateralFilterMaterial.uniforms.packOutput.value=0,e.renderPass(this.bilateralFilterMaterial,this.saoRenderTarget,!0)}this.applySao&&(e.setClearColor(d,h),e.autoClear=!1,this.copyMaterial.uniforms.tDiffuse.value=this.saoRenderTarget.texture,this.copyMaterial.blending=v.MultiplyBlending,this.copyMaterial.premultipliedAlpha=!0,e.renderPass(this.copyMaterial,this.renderToScreen?null:t,!1)),e.autoClear=f,e.setClearColor(u),e.setClearAlpha(c)}},v.SSAARenderPass=function(e,t,r,n){v.Pass.call(this),this.scene=e,this.camera=t,this.sampleLevel=4,this.cameraJitter=new v.CameraJitter,this.unbiased=!0,this.needsSwap=!1,this.clearColor=void 0!==r?r:0,this.clearAlpha=void 0!==n?n:0,void 0===v.CopyShader&&console.error("THREE.SSAARenderPass relies on THREE.CopyShader"),this.overMaterial=new v.ShaderMaterial(v.CopyShader),this.overMaterial.uniforms=v.UniformsUtils.clone(this.overMaterial.uniforms),this.overMaterial.blending=v.NormalBlending,this.overMaterial.premultipliedAlpha=!0,this.overMaterial.transparent=!0,this.overMaterial.depthTest=!1,this.overMaterial.depthWrite=!1,this.addMaterial=new v.ShaderMaterial(v.CopyShader),this.addMaterial.uniforms=v.UniformsUtils.clone(this.addMaterial.uniforms),this.addMaterial.blending=v.AdditiveBlending,this.addMaterial.premultipliedAlpha=!0,this.addMaterial.transparent=!0,this.addMaterial.depthTest=!1,this.addMaterial.depthWrite=!1,this.camera2=new v.OrthographicCamera(-1,1,1,-1,0,1),this.scene2=new v.Scene,this.quad2=new v.Mesh(new v.PlaneGeometry(2,2),this.copyMaterial),this.quad2.frustumCulled=!1,this.scene2.add(this.quad2)},v.SSAARenderPass.prototype=(0,p.default)((0,d.default)(v.Pass.prototype),{constructor:v.SSAARenderPass,dispose:function(){this.sampleRenderTarget&&(this.sampleRenderTarget.dispose(),this.sampleRenderTarget=null)},setSize:function(e,t){this.sampleRenderTarget&&this.sampleRenderTarget.setSize(e,t)},render:function(e,t,r,n,i,a){this.sampleRenderTarget||(this.sampleRenderTarget=new v.WebGLRenderTarget(r.width,r.height,{minFilter:v.NearestFilter,magFilter:v.NearestFilter,format:v.RGBAFormat,type:v.UnsignedByteType,name:"SSAARenderPass.sample"}));var o=a||this.camera,s=e.autoClear;e.autoClear=!1;var l=e.getClearColor().getHex(),u=e.getClearAlpha();this.cameraJitter.setJitterLevel(this.sampleLevel);var c=1/this.cameraJitter.numJitterSamples;this.addMaterial.uniforms.tDiffuse.value=this.sampleRenderTarget.texture;var f=r.width,d=r.height;e.setClearColor(0,0);var h=e.ditherScale;this.unbiased&&(e.ditherScale=this.cameraJitter.numJitterSamples);for(var p=0;p","varying vec2 vUv;","uniform sampler2D currentBeauty;","uniform sampler2D previousBeauty;","uniform sampler2D tDepth;","uniform sampler2D tVelocity;","uniform vec2 textureSize;","uniform mat4 prevProjectionViewMatrix;","uniform mat4 currentProjectionViewMatrix;","uniform mat4 cameraProjectionMatrix;","uniform mat4 cameraInverseProjectionMatrix;","uniform mat4 cameraInverseViewMatrix;","uniform vec2 cameraNearFar;","uniform float minSampleWeight;","uniform int mode;","#define MODE_MOVING 0","#define MODE_STATIC 1","#include ","float getDepth( const in vec2 screenPosition ) {","\t#if DEPTH_PACKING == 1","\treturn unpackRGBAToDepth( texture2D( tDepth, screenPosition ) );","\t#else","\treturn texture2D( tDepth, screenPosition ).x;","\t#endif","}","vec3 find_closest_fragment_9tap(const in vec2 uv) { ","const vec3 offset = vec3(1.0, -1.0, 0.0);","vec2 texelSize = 1.0/textureSize; ","vec3 dtl = vec3(-1, 1, getDepth( uv + offset.yx * texelSize) ); ","vec3 dtc = vec3( 0, 1, getDepth( uv + offset.zx * texelSize) );","vec3 dtr = vec3( 1, 1, getDepth( uv + offset.xx * texelSize) );","vec3 dml = vec3(-1, 0, getDepth( uv + offset.yz * texelSize) );","vec3 dmc = vec3( 0, 0, getDepth( uv ) );","vec3 dmr = vec3( 1, 0, getDepth( uv + offset.xz * texelSize) );","vec3 dbl = vec3(-1, -1, getDepth( uv + offset.yy * texelSize) );","vec3 dbc = vec3( 0, -1, getDepth( uv + offset.zy * texelSize) );","vec3 dbr = vec3( 1, -1, getDepth( uv + offset.xy * texelSize) );","vec3 dmin = dtl;","if ( dmin.z > dtc.z ) dmin = dtc;","if ( dmin.z > dtr.z ) dmin = dtr;","if ( dmin.z > dml.z ) dmin = dml;","if ( dmin.z > dmc.z ) dmin = dmc;","if ( dmin.z > dmr.z ) dmin = dmr;","if ( dmin.z > dbl.z ) dmin = dbl;","if ( dmin.z > dbc.z ) dmin = dbc;","if ( dmin.z > dbr.z ) dmin = dbr;","return vec3(uv + texelSize.xy * dmin.xy, dmin.z);","}","vec3 find_closest_fragment_5tap(const in vec2 uv) ","{ ","vec2 offset = vec2(1.0, -1.0);","vec2 texelSize = 1.0/textureSize; ","vec3 dtl = vec3(-1, 1, getDepth( uv + offset.yx * texelSize ) ); ","vec3 dtr = vec3( 1, 1, getDepth( uv + offset.xx * texelSize ) );","vec3 dmc = vec3( 0, 0, getDepth( uv) );","vec3 dbl = vec3(-1, -1, getDepth( uv + offset.yy * texelSize ) );","vec3 dbr = vec3( 1, -1, getDepth( uv + offset.xy * texelSize ) );","vec3 dmin = dtl;","if ( dmin.z > dtr.z ) dmin = dtr;","if ( dmin.z > dmc.z ) dmin = dmc;","if ( dmin.z > dbl.z ) dmin = dbl;","if ( dmin.z > dbr.z ) dmin = dbr;","return vec3(uv + texelSize * dmin.xy, dmin.z);","}","vec4 clip_aabb(const in vec4 aabb_min, const in vec4 aabb_max, vec4 p )","{ ","const float FLT_EPS = 1e-8;","vec4 p_clip = 0.5 * (aabb_max + aabb_min); ","vec4 e_clip = 0.5 * (aabb_max - aabb_min) + FLT_EPS; ","vec4 v_clip = p - p_clip;","vec4 v_unit = abs(v_clip / e_clip);","float mv_unit = max(v_unit.x, max(v_unit.y, v_unit.z));","if (mv_unit > 1.0) ","return p_clip + v_clip / mv_unit;","else ","return p;","}","vec2 getScreenSpaceVelocity( vec2 uv ) {","vec4 value = texture2D(tVelocity, uv);","if( value.x == 0.0 && value.y == 0.0 && value.z == 0.0 && value.w == 0.0 ) {","return vec2( 0.0, 0.0 );","}","float vx = unpack16(value.xy);","float vy = unpack16(value.zw);","return vec2(2.*vx - 1., 2.*vy - 1.);","}","vec4 calculateTAA(const in vec2 uv, const in vec2 screenSpaceVelocity) {","float _FeedbackMin = 1.0 - 2.0 * minSampleWeight;","float _FeedbackMax = 1.0 - minSampleWeight;","vec4 currentColor = texture2D(currentBeauty, uv);","vec2 lookBackUV = uv - screenSpaceVelocity;","vec4 previousColor = texture2D(previousBeauty, lookBackUV);","const vec3 offset = vec3(1., -1., 0.);","vec2 texelSize = 1./textureSize;","vec4 ctl = texture2D(currentBeauty, uv + offset.yx * texelSize);","vec4 ctc = texture2D(currentBeauty, uv + offset.zx * texelSize);","vec4 ctr = texture2D(currentBeauty, uv + offset.xx * texelSize);","vec4 cml = texture2D(currentBeauty, uv + offset.yz * texelSize);","vec4 cmc = currentColor;//texture2D(currentBeauty, uv);","vec4 cmr = texture2D(currentBeauty, uv + offset.xz * texelSize);","vec4 cbl = texture2D(currentBeauty, uv + offset.yy * texelSize);","vec4 cbc = texture2D(currentBeauty, uv + offset.zy * texelSize);","vec4 cbr = texture2D(currentBeauty, uv + offset.xy * texelSize);","vec4 cmin = min(ctl, min(ctc, min(ctr, min(cml, min(cmc, min(cmr, min(cbl, min(cbc, cbr))))))));","vec4 cmax = max(ctl, max(ctc, max(ctr, max(cml, max(cmc, max(cmr, max(cbl, max(cbc, cbr))))))));","vec4 cavg = (ctl + ctc + ctr + cml + cmc + cmr + cbl + cbc + cbr) / 9.0;","vec4 cmin5 = min(ctc, min(cml, min(cmc, min(cmr, cbc))));","vec4 cmax5 = max(ctc, max(cml, max(cmc, max(cmr, cbc))));","vec4 cavg5 = (ctc + cml + cmc + cmr + cbc) / 5.0;","cmin = 0.5 * (cmin + cmin5);","cmax = 0.5 * (cmax + cmax5);","cavg = 0.5 * (cavg + cavg5);","vec4 clampedPreviousColor =clip_aabb(cmin, cmax, previousColor);","float lum0 = linearToRelativeLuminance(currentColor.rgb);","float lum1 = linearToRelativeLuminance(clampedPreviousColor.rgb);","float unbiased_diff = abs(lum0 - lum1) / max(lum0, max(lum1, 0.2));","float unbiased_weight = 1.0 - unbiased_diff;","float unbiased_weight_sqr = unbiased_weight * unbiased_weight;","float k_feedback = mix(_FeedbackMin, _FeedbackMax, unbiased_weight_sqr);","vec2 previousVelocity = getScreenSpaceVelocity(lookBackUV);","k_feedback *= 1.0 - saturate( length( ( screenSpaceVelocity - previousVelocity ) / texelSize ) / 10.0 );","k_feedback *= min( currentColor.a, clampedPreviousColor.a );","if( mode == MODE_MOVING ) {","return mix(currentColor, clampedPreviousColor, k_feedback);","}","else if( mode == MODE_STATIC ) {","return mix(currentColor, mix( clampedPreviousColor, previousColor, pow2( previousColor.a ) ), 1.0 - pow( minSampleWeight, 0.75 ) );","}","else { // mode == MODE_RESET","return currentColor;","}","}","void main() {","vec3 c_frag = find_closest_fragment_9tap(vUv);","if( c_frag.z >= 1. ) {","gl_FragColor = texture2D(currentBeauty, vUv);","}","else {","vec2 screenSpaceVelocity = getScreenSpaceVelocity( vUv );","gl_FragColor = calculateTAA(vUv, screenSpaceVelocity);","}","}"].join("\n")})}(),this.velocityMaterial=new v.MeshVelocityMaterial,this.currentMaterial=this.superSampleTRAAMaterial;var n=new v.PlaneGeometry(2,2),i=new v.Mesh(n,this.currentMaterial);this.orthoScene.add(i),this.oldClearColor=new v.Color,this.oldClearAlpha=1,this.needsSwap=!1,void 0===v.CopyShader&&console.error("THREE.TRAAPass relies on THREE.CopyShader");var a=v.CopyShader;this.copyUniforms=v.UniformsUtils.clone(a.uniforms),this.copyMaterial=new v.ShaderMaterial({uniforms:this.copyUniforms,vertexShader:a.vertexShader,fragmentShader:a.fragmentShader});var o={minFilter:v.LinearFilter,magFilter:v.LinearFilter,format:v.RGBAFormat,stencilBuffer:!0};this.accumulatedBeautyRenderTarget=new v.WebGLRenderTarget(256,256,o),this.previousProjectionViewMatrix=new v.Matrix4,this.currentProjectionViewMatrix=new v.Matrix4,this.projectionMatrix=new v.Matrix4,this.projectionMatrix.copy(this.camera.projectionMatrix),this.numSamplesPerAccumulation=16,this.staticMode=!1,this.depthTexture=null},v.TRAAPass.prototype=(0,p.default)((0,d.default)(v.Pass.prototype),{constructor:v.TRAAPass,dispose:function(){this.accumulatedBeautyRenderTarget&&this.accumulatedBeautyRenderTarget.dispose()},setSize:function(e,t){this.accumulatedBeautyRenderTarget&&this.accumulatedBeautyRenderTarget.setSize(e,t),this.velocityRenderTarget&&this.velocityRenderTarget.setSize(e,t),this.projectionMatrix.copy(this.camera.projectionMatrix),this.resetPending=!0},renderOverride:function(e,t,r,n,i){var a=e.getClearColor().getHex(),o=e.getClearAlpha(),s=e.autoClear;e.autoClear=!1,n=t.clearColor||n,i=t.clearAlpha||i;var l=void 0!==n&&null!==n;l&&(e.setClearColor(n),e.setClearAlpha(i||0)),this.scene.overrideMaterial=t,e.render(this.scene,this.camera,r,l),this.scene.overrideMaterial=null,e.autoClear=s,e.setClearColor(a),e.setClearAlpha(o)},render:function(e,t,r,n,i,a){var o=a||this.camera,s=t.width,l=t.height;if(!this.velocityRenderTarget){var u={minFilter:v.LinearFilter,magFilter:v.LinearFilter,format:v.RGBAFormat};this.velocityRenderTarget=new v.WebGLRenderTarget(s,l,u)}this.currentMaterial=this.superSampleTRAAMaterial,this.currentProjectionViewMatrix.multiplyMatrices(this.projectionMatrix,o.matrixWorldInverse),this.oldClearColor=e.getClearColor().getHex(),this.oldClearAlpha=e.getClearAlpha();var c=e.autoClear;e.autoClear=!1,e.setClearColor(new v.Color(0,0,0),0),this.velocityMaterial.currentProjectionViewMatrix.copy(this.currentProjectionViewMatrix),this.velocityMaterial.previousProjectionViewMatrix.copy(this.previousProjectionViewMatrix),this.scene.overrideMaterial=this.velocityMaterial,e.render(this.scene,o,this.velocityRenderTarget,!0),this.scene.overrideMaterial=null,this.scene.traverse(function(e){e instanceof v.Object3D&&e.matrixWorldPrevious.copy(e.matrixWorld)}),this.currentMaterial.uniforms.currentBeauty.value=r.texture,this.currentMaterial.uniforms.previousBeauty.value=this.accumulatedBeautyRenderTarget.texture,this.currentMaterial.defines.DEPTH_PACKING=this.depthTexture.depthPacking,this.currentMaterial.uniforms.tDepth.value=this.depthTexture,this.currentMaterial.uniforms.tVelocity.value=this.velocityRenderTarget.texture,this.resetPending?(this.currentMaterial.uniforms.mode.value=2,this.resetPending=!1):this.staticMode?this.currentMaterial.uniforms.mode.value=1:this.currentMaterial.uniforms.mode.value=0,this.currentMaterial.uniforms.cameraInverseProjectionMatrix.value.getInverse(this.projectionMatrix),this.currentMaterial.uniforms.cameraProjectionMatrix.value.copy(this.projectionMatrix),this.currentMaterial.uniforms.cameraInverseViewMatrix.value.copy(o.matrixWorld),this.currentMaterial.uniforms.cameraNearFar.value.copy(new v.Vector2(o.near,o.far)),this.currentMaterial.uniforms.textureSize.value.copy(new v.Vector2(s,l)),this.currentMaterial.uniforms.minSampleWeight.value=1/this.numSamplesPerAccumulation,this.orthoScene.overrideMaterial=this.currentMaterial,e.render(this.orthoScene,this.orthoCamera,t,!0),this.orthoScene.overrideMaterial=null,this.copyUniforms.tDiffuse.value=t.texture,this.copyUniforms.opacity.value=1,this.orthoScene.overrideMaterial=this.copyMaterial,e.render(this.orthoScene,this.orthoCamera,this.accumulatedBeautyRenderTarget,!0),this.orthoScene.overrideMaterial=null,e.setClearColor(this.oldClearColor,this.oldClearAlpha),e.autoClear=c,this.previousProjectionViewMatrix.copy(this.currentProjectionViewMatrix)}}),v.UnrealBloomPass=function(e,t,r,n){v.Pass.call(this),this.strength=void 0!==t?t:1,this.radius=r,this.threshold=n,this.resolution=void 0!==e?new v.Vector2(e.x,e.y):new v.Vector2(256,256);var i={minFilter:v.LinearFilter,magFilter:v.LinearFilter,format:v.RGBAFormat};this.renderTargetsHorizontal=[],this.renderTargetsVertical=[],this.nMips=5;var a=Math.round(this.resolution.x/2),o=Math.round(this.resolution.y/2);this.renderTargetBright=new v.WebGLRenderTarget(a,o,i),this.renderTargetBright.texture.name="UnrealBloomPass.bright",this.renderTargetBright.texture.generateMipmaps=!1;for(var s=0;s\t\t\t\tvarying vec2 vUv;\n\t\t\t\tuniform sampler2D colorTexture;\n\t\t\t\tuniform vec2 texSize;\t\t\t\tuniform vec2 direction;\t\t\t\t\t\t\t\tfloat gaussianPdf(in float x, in float sigma) {\t\t\t\t\treturn 0.39894 * exp( -0.5 * x * x/( sigma * sigma))/sigma;\t\t\t\t}\t\t\t\tvoid main() {\n\t\t\t\t\tvec2 invSize = 1.0 / texSize;\t\t\t\t\tfloat fSigma = float(SIGMA);\t\t\t\t\tfloat weightSum = gaussianPdf(0.0, fSigma);\t\t\t\t\tvec4 diffuseSum = texture2D( colorTexture, vUv) * weightSum;\t\t\t\t\tfor( int i = 1; i < KERNEL_RADIUS; i ++ ) {\t\t\t\t\t\tfloat x = float(i);\t\t\t\t\t\tfloat w = gaussianPdf(x, fSigma);\t\t\t\t\t\tvec2 uvOffset = direction * invSize * x;\t\t\t\t\t\tvec4 sample1 = texture2D( colorTexture, vUv + uvOffset);\t\t\t\t\t\tvec4 sample2 = texture2D( colorTexture, vUv - uvOffset);\t\t\t\t\t\tdiffuseSum += (sample1 + sample2) * w;\t\t\t\t\t\tweightSum += 2.0 * w;\t\t\t\t\t}\t\t\t\t\tgl_FragColor = diffuseSum/weightSum;\n\t\t\t\t}"})},getCompositeMaterial:function(e){return new v.ShaderMaterial({defines:{NUM_MIPS:e},uniforms:{blurTexture1:{value:null},blurTexture2:{value:null},blurTexture3:{value:null},blurTexture4:{value:null},blurTexture5:{value:null},dirtTexture:{value:null},bloomStrength:{value:1},bloomFactors:{value:null},bloomTintColors:{value:null},bloomRadius:{value:0}},vertexShader:"varying vec2 vUv;\n\t\t\t\tvoid main() {\n\t\t\t\t\tvUv = uv;\n\t\t\t\t\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n\t\t\t\t}",fragmentShader:"varying vec2 vUv;\t\t\t\tuniform sampler2D blurTexture1;\t\t\t\tuniform sampler2D blurTexture2;\t\t\t\tuniform sampler2D blurTexture3;\t\t\t\tuniform sampler2D blurTexture4;\t\t\t\tuniform sampler2D blurTexture5;\t\t\t\tuniform sampler2D dirtTexture;\t\t\t\tuniform float bloomStrength;\t\t\t\tuniform float bloomRadius;\t\t\t\tuniform float bloomFactors[NUM_MIPS];\t\t\t\tuniform vec3 bloomTintColors[NUM_MIPS];\t\t\t\t\t\t\t\tfloat lerpBloomFactor(const in float factor) { \t\t\t\t\tfloat mirrorFactor = 1.2 - factor;\t\t\t\t\treturn mix(factor, mirrorFactor, bloomRadius);\t\t\t\t}\t\t\t\t\t\t\t\tvoid main() {\t\t\t\t\tgl_FragColor = bloomStrength * ( lerpBloomFactor(bloomFactors[0]) * vec4(bloomTintColors[0], 1.0) * texture2D(blurTexture1, vUv) + \t\t\t\t\t \t\t\t\t\t\t\t lerpBloomFactor(bloomFactors[1]) * vec4(bloomTintColors[1], 1.0) * texture2D(blurTexture2, vUv) + \t\t\t\t\t\t\t\t\t\t\t\t lerpBloomFactor(bloomFactors[2]) * vec4(bloomTintColors[2], 1.0) * texture2D(blurTexture3, vUv) + \t\t\t\t\t\t\t\t\t\t\t\t lerpBloomFactor(bloomFactors[3]) * vec4(bloomTintColors[3], 1.0) * texture2D(blurTexture4, vUv) + \t\t\t\t\t\t\t\t\t\t\t\t lerpBloomFactor(bloomFactors[4]) * vec4(bloomTintColors[4], 1.0) * texture2D(blurTexture5, vUv) );\t\t\t\t}"})}}),v.UnrealBloomPass.BlurDirectionX=new v.Vector2(1,0),v.UnrealBloomPass.BlurDirectionY=new v.Vector2(0,1),v.MirrorHelper=function(e){this.scene=new v.Scene,this.cameraOrtho=new v.OrthographicCamera(-1,1,1,-1,0,1),this.quad=new v.Mesh(new v.PlaneGeometry(2,2),null),this.scene.add(this.quad),this.mirror=e,this.numMipMaps=4,this.mirrorTextureMipMaps=[],this.tempRenderTargets=[];for(var t={minFilter:v.LinearFilter,magFilter:v.LinearFilter,format:v.RGBAFormat,stencilBuffer:!1},r=e.mirrorRenderTarget,n=r.width/2,i=r.height/2,a=0;a0?o(n()):ee.y<0&&s(n()),Q.copy($),D.update()}function h(e){J.set(e.clientX,e.clientY),K.subVectors(J,Z),ne(K.x,K.y),Z.copy(J),D.update()}function p(e){}function m(e){e.deltaY<0?s(n()):e.deltaY>0&&o(n()),D.update()}function g(e){switch(e.keyCode){case D.keys.UP:ne(0,D.keyPanSpeed),D.update();break;case D.keys.BOTTOM:ne(0,-D.keyPanSpeed),D.update();break;case D.keys.LEFT:ne(D.keyPanSpeed,0),D.update();break;case D.keys.RIGHT:ne(-D.keyPanSpeed,0),D.update()}}function y(e){X.set(e.touches[0].pageX,e.touches[0].pageY)}function x(e){var t=e.touches[0].pageX-e.touches[1].pageX,r=e.touches[0].pageY-e.touches[1].pageY,n=Math.sqrt(t*t+r*r);Q.set(0,n)}function b(e){Z.set(e.touches[0].pageX,e.touches[0].pageY)}function w(e){Y.set(e.touches[0].pageX,e.touches[0].pageY),q.subVectors(Y,X);var t=D.domElement===document?D.domElement.body:D.domElement;i(2*Math.PI*q.x/t.clientWidth*D.rotateSpeed),a(2*Math.PI*q.y/t.clientHeight*D.rotateSpeed),X.copy(Y),D.update()}function _(e){var t=e.touches[0].pageX-e.touches[1].pageX,r=e.touches[0].pageY-e.touches[1].pageY,i=Math.sqrt(t*t+r*r);$.set(0,i),ee.subVectors($,Q),ee.y>0?s(n()):ee.y<0&&o(n()),Q.copy($),D.update()}function M(e){J.set(e.touches[0].pageX,e.touches[0].pageY),K.subVectors(J,Z),ne(K.x,K.y),Z.copy(J),D.update()}function S(e){}function T(e){if(!1!==D.enabled){if(e.preventDefault(),e.button===D.mouseButtons.ORBIT){if(!1===D.enableRotate)return;l(e),U=F.ROTATE}else if(e.button===D.mouseButtons.ZOOM){if(!1===D.enableZoom)return;u(e),U=F.DOLLY}else if(e.button===D.mouseButtons.PAN){if(!1===D.enablePan)return;c(e),U=F.PAN}U!==F.NONE&&(document.addEventListener("mousemove",E,!1),document.addEventListener("mouseup",P,!1),D.dispatchEvent(N))}}function E(e){if(!1!==D.enabled)if(e.preventDefault(),U===F.ROTATE){if(!1===D.enableRotate)return;f(e)}else if(U===F.DOLLY){if(!1===D.enableZoom)return;d(e)}else if(U===F.PAN){if(!1===D.enablePan)return;h(e)}}function P(e){!1!==D.enabled&&(p(e),document.removeEventListener("mousemove",E,!1),document.removeEventListener("mouseup",P,!1),D.dispatchEvent(B),U=F.NONE)}function A(e){!1===D.enabled||!1===D.enableZoom||U!==F.NONE&&U!==F.ROTATE||(e.preventDefault(),e.stopPropagation(),m(e),D.dispatchEvent(N),D.dispatchEvent(B))}function C(e){!1!==D.enabled&&!1!==D.enableKeys&&!1!==D.enablePan&&g(e)}function I(e){if(!1!==D.enabled){switch(e.touches.length){case 1:if(!1===D.enableRotate)return;y(e),U=F.TOUCH_ROTATE;break;case 2:if(!1===D.enableZoom)return;x(e),U=F.TOUCH_DOLLY;break;case 3:if(!1===D.enablePan)return;b(e),U=F.TOUCH_PAN;break;default:U=F.NONE}U!==F.NONE&&D.dispatchEvent(N)}}function R(e){if(!1!==D.enabled)switch(e.preventDefault(),e.stopPropagation(),e.touches.length){case 1:if(!1===D.enableRotate)return;if(U!==F.TOUCH_ROTATE)return;w(e);break;case 2:if(!1===D.enableZoom)return;if(U!==F.TOUCH_DOLLY)return;_(e);break;case 3:if(!1===D.enablePan)return;if(U!==F.TOUCH_PAN)return;M(e);break;default:U=F.NONE}}function O(e){!1!==D.enabled&&(S(e),D.dispatchEvent(B),U=F.NONE)}function L(e){e.preventDefault()}this.object=e,this.domElement=void 0!==t?t:document,this.enabled=!0,this.target=new v.Vector3,this.minDistance=0,this.maxDistance=1/0,this.minZoom=0,this.maxZoom=1/0,this.minPolarAngle=0,this.maxPolarAngle=Math.PI,this.minAzimuthAngle=-1/0,this.maxAzimuthAngle=1/0,this.enableDamping=!1,this.dampingFactor=.25,this.enableZoom=!0,this.zoomSpeed=1,this.enableRotate=!0,this.rotateSpeed=1,this.enablePan=!0,this.keyPanSpeed=7,this.autoRotate=!1,this.autoRotateSpeed=2,this.enableKeys=!0,this.keys={LEFT:37,UP:38,RIGHT:39,BOTTOM:40},this.mouseButtons={ORBIT:v.MOUSE.LEFT,ZOOM:v.MOUSE.MIDDLE,PAN:v.MOUSE.RIGHT},this.target0=this.target.clone(),this.position0=this.object.position.clone(),this.zoom0=this.object.zoom,this.getPolarAngle=function(){return z.phi},this.getAzimuthalAngle=function(){return z.theta},this.reset=function(){D.target.copy(D.target0),D.object.position.copy(D.position0),D.object.zoom=D.zoom0,D.object.updateProjectionMatrix(),D.dispatchEvent(V),D.update(),U=F.NONE},this.update=function(){var t=new v.Vector3,n=(new v.Quaternion).setFromUnitVectors(e.up,new v.Vector3(0,1,0)),a=n.clone().inverse(),o=new v.Vector3,s=new v.Quaternion;return function(){var e=D.object.position;return t.copy(e).sub(D.target),t.applyQuaternion(n),z.setFromVector3(t),D.autoRotate&&U===F.NONE&&i(r()),z.theta+=j.theta,z.phi+=j.phi,z.theta=Math.max(D.minAzimuthAngle,Math.min(D.maxAzimuthAngle,z.theta)),z.phi=Math.max(D.minPolarAngle,Math.min(D.maxPolarAngle,z.phi)),z.makeSafe(),z.radius*=G,z.radius=Math.max(D.minDistance,Math.min(D.maxDistance,z.radius)),D.target.add(H),t.setFromSpherical(z),t.applyQuaternion(a),e.copy(D.target).add(t),D.object.lookAt(D.target),!0===D.enableDamping?(j.theta*=1-D.dampingFactor,j.phi*=1-D.dampingFactor):j.set(0,0,0),G=1,H.set(0,0,0),!!(W||o.distanceToSquared(D.object.position)>k||8*(1-s.dot(D.object.quaternion))>k)&&(D.dispatchEvent(V),o.copy(D.object.position),s.copy(D.object.quaternion),W=!1,!0)}}(),this.dispose=function(){D.domElement.removeEventListener("contextmenu",L,!1),D.domElement.removeEventListener("mousedown",T,!1),D.domElement.removeEventListener("wheel",A,!1),D.domElement.removeEventListener("touchstart",I,!1),D.domElement.removeEventListener("touchend",O,!1),D.domElement.removeEventListener("touchmove",R,!1),document.removeEventListener("mousemove",E,!1),document.removeEventListener("mouseup",P,!1),window.removeEventListener("keydown",C,!1)};var D=this,V={type:"change"},N={type:"start"},B={type:"end"},F={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_DOLLY:4,TOUCH_PAN:5},U=F.NONE,k=1e-6,z=new v.Spherical,j=new v.Spherical,G=1,H=new v.Vector3,W=!1,X=new v.Vector2,Y=new v.Vector2,q=new v.Vector2,Z=new v.Vector2,J=new v.Vector2,K=new v.Vector2,Q=new v.Vector2,$=new v.Vector2,ee=new v.Vector2,te=function(){var e=new v.Vector3;return function(t,r){e.setFromMatrixColumn(r,0),e.multiplyScalar(-t),H.add(e)}}(),re=function(){var e=new v.Vector3;return function(t,r){e.setFromMatrixColumn(r,1),e.multiplyScalar(t),H.add(e)}}(),ne=function(){var e=new v.Vector3;return function(t,r){var n=D.domElement===document?D.domElement.body:D.domElement;if(D.object.isPerspectiveCamera){var i=D.object.position;e.copy(i).sub(D.target);var a=e.length();a*=Math.tan(D.object.fov/2*Math.PI/180),te(2*t*a/n.clientHeight,D.object.matrix),re(2*r*a/n.clientHeight,D.object.matrix)}else D.object instanceof v.OrthographicCamera?(te(t*(D.object.right-D.object.left)/D.object.zoom/n.clientWidth,D.object.matrix),re(r*(D.object.top-D.object.bottom)/D.object.zoom/n.clientHeight,D.object.matrix)):(console.warn("WARNING: OrbitControls.js encountered an unknown camera type - pan disabled."),D.enablePan=!1)}}();D.domElement.addEventListener("contextmenu",L,!1),D.domElement.addEventListener("mousedown",T,!1),D.domElement.addEventListener("wheel",A,!1),D.domElement.addEventListener("touchstart",I,!1),D.domElement.addEventListener("touchend",O,!1),D.domElement.addEventListener("touchmove",R,!1),window.addEventListener("keydown",C,!1),this.update()},v.OrbitControls.prototype=(0,d.default)(v.EventDispatcher.prototype),v.OrbitControls.prototype.constructor=v.OrbitControls,(0,c.default)(v.OrbitControls.prototype,{center:{get:function(){return console.warn("THREE.OrbitControls: .center has been renamed to .target"),this.target}},noZoom:{get:function(){return console.warn("THREE.OrbitControls: .noZoom has been deprecated. Use .enableZoom instead."),!this.enableZoom},set:function(e){console.warn("THREE.OrbitControls: .noZoom has been deprecated. Use .enableZoom instead."),this.enableZoom=!e}},noRotate:{get:function(){return console.warn("THREE.OrbitControls: .noRotate has been deprecated. Use .enableRotate instead."),!this.enableRotate},set:function(e){console.warn("THREE.OrbitControls: .noRotate has been deprecated. Use .enableRotate instead."),this.enableRotate=!e}},noPan:{get:function(){return console.warn("THREE.OrbitControls: .noPan has been deprecated. Use .enablePan instead."),!this.enablePan},set:function(e){console.warn("THREE.OrbitControls: .noPan has been deprecated. Use .enablePan instead."),this.enablePan=!e}},noKeys:{get:function(){return console.warn("THREE.OrbitControls: .noKeys has been deprecated. Use .enableKeys instead."),!this.enableKeys},set:function(e){console.warn("THREE.OrbitControls: .noKeys has been deprecated. Use .enableKeys instead."),this.enableKeys=!e}},staticMoving:{get:function(){return console.warn("THREE.OrbitControls: .staticMoving has been deprecated. Use .enableDamping instead."),!this.enableDamping},set:function(e){console.warn("THREE.OrbitControls: .staticMoving has been deprecated. Use .enableDamping instead."),this.enableDamping=!e}},dynamicDampingFactor:{get:function(){return console.warn("THREE.OrbitControls: .dynamicDampingFactor has been renamed. Use .dampingFactor instead."),this.dampingFactor},set:function(e){console.warn("THREE.OrbitControls: .dynamicDampingFactor has been renamed. Use .dampingFactor instead."),this.dampingFactor=e}}}),v.VRControls=function(e,t){function r(e){i=e,e.length>0?n=e[0]:t&&t("VR input not available.")}var n,i,a=this,o=new v.Matrix4,s=null;"VRFrameData"in window&&(s=new VRFrameData),navigator.getVRDisplays&&navigator.getVRDisplays().then(r).catch(function(){console.warn("THREE.VRControls: Unable to get VR Displays")}),this.scale=1,this.standing=!1,this.userHeight=1.6,this.getVRDisplay=function(){return n},this.setVRDisplay=function(e){n=e},this.getVRDisplays=function(){return console.warn("THREE.VRControls: getVRDisplays() is being deprecated."),i},this.getStandingMatrix=function(){return o},this.update=function(){if(n){var t;n.getFrameData?(n.getFrameData(s),t=s.pose):n.getPose?t=n.getPose():n.getImmediatePose&&(t=n.getImmediatePose()),null!==t.orientation?e.quaternion.fromArray(t.orientation):e.quaternion.set(0,0,0,1),null!==t.position?e.position.fromArray(t.position):e.position.set(0,0,0),this.standing&&(n.stageParameters?(e.updateMatrix(),o.fromArray(n.stageParameters.sittingToStandingTransform),e.applyMatrix(o)):e.position.setY(e.position.y+this.userHeight)),e.position.multiplyScalar(a.scale)}},this.resetPose=function(){n&&n.resetPose()},this.resetSensor=function(){console.warn("THREE.VRControls: .resetSensor() is now .resetPose()."),this.resetPose()},this.zeroSensor=function(){console.warn("THREE.VRControls: .zeroSensor() is now .resetPose()."),this.resetPose()},this.dispose=function(){n=null}},v.Color.prototype.toJSON=function(){return{r:this.r,g:this.g,b:this.b}},v.HDRLoader=v.RGBELoader=function(e){this.manager=void 0!==e?e:v.DefaultLoadingManager},v.RGBELoader.prototype=(0,d.default)(v.DataTextureLoader.prototype),v.RGBELoader.prototype._parser=function(e){var t=function(e,t){switch(e){case 1:console.error("THREE.RGBELoader Read Error: "+(t||""));break;case 2:console.error("THREE.RGBELoader Write Error: "+(t||""));break;case 3:console.error("THREE.RGBELoader Bad File Format: "+(t||""));break;default:case 4:console.error("THREE.RGBELoader: Error: "+(t||""))}return-1},r=function(e,t,r){t=t||1024;for(var n=e.pos,i=-1,a=0,o="",s=String.fromCharCode.apply(null,new Uint16Array(e.subarray(n,n+128)));0>(i=s.indexOf("\n"))&&a=e.byteLength||!(n=r(e)))return t(1,"no header found");if(!(i=n.match(a)))return t(3,"bad initial token");for(c.valid|=1,c.programtype=i[1],c.string+=n+"\n";;){if(!1===(n=r(e)))break;if(c.string+=n+"\n","#"!==n.charAt(0)){if((i=n.match(o))&&(c.gamma=parseFloat(i[1],10)),(i=n.match(s))&&(c.exposure=parseFloat(i[1],10)),(i=n.match(l))&&(c.valid|=2,c.format=i[1]),(i=n.match(u))&&(c.valid|=4,c.height=parseInt(i[1],10),c.width=parseInt(i[2],10)),2&c.valid&&4&c.valid)break}else c.comments+=n+"\n"}return 2&c.valid?4&c.valid?c:t(3,"missing image size specifier"):t(3,"missing format specifier")}(n);if(-1!==i){var a=i.width,o=i.height,s=function(e,r,n){var i,a,o,s,l,u,c,f,d,h,p,m,g,v=r,y=n;if(v<8||v>32767||2!==e[0]||2!==e[1]||128&e[2])return new Uint8Array(e);if(v!==(e[2]<<8|e[3]))return t(3,"wrong scanline width");if(!(i=new Uint8Array(4*r*n))||!i.length)return t(4,"unable to allocate buffer space");for(a=0,o=0,f=4*v,g=new Uint8Array(4),u=new Uint8Array(f);y>0&&oe.byteLength)return t(1);if(g[0]=e[o++],g[1]=e[o++],g[2]=e[o++],g[3]=e[o++],2!=g[0]||2!=g[1]||(g[2]<<8|g[3])!=v)return t(3,"bad rgbe scanline format");for(c=0;c128,m&&(s-=128),0===s||c+s>f)return t(3,"bad scanline data");if(m)for(l=e[o++],d=0;d 1.00 ) {"," gl_FragColor = texture2D( mapLeft, uv );"," } else {"," gl_FragColor = texture2D( mapRight, uv - vec2( resolution.x, 0 ) );"," }","}"].join("\n")}),l=new v.Mesh(new v.PlaneBufferGeometry(2,2),s);r.add(l),this.setSize=function(t,r){e.setSize(t,r);var n=e.getPixelRatio();s.uniforms.resolution.value.set(1/t,1/r),a.setSize(t*n/2+1,r*n),o.setSize(t*n/2+1,r*n)},this.render=function(i,s){i.updateMatrixWorld(),null===s.parent&&s.updateMatrixWorld(),n.update(s),e.render(i,n.cameraL,a,!0),e.render(i,n.cameraR,o,!0),e.render(r,t)}},v.StereoEffect=function(e){var t=new v.StereoCamera;t.aspect=.5,this.setEyeSeparation=function(e){t.eyeSep=e},this.setSize=function(t,r){e.setSize(t,r)},this.updateStereo=function(e){t.update(e)},this.getCameraL=function(){return t.cameraL},this.getCameraR=function(){return t.cameraR},this.render=function(r,n){r.updateMatrixWorld(),null===n.parent&&n.updateMatrixWorld(),t.update(n);var i=e.getSize();e.autoClear&&e.clear(),e.setScissorTest(!0),e.setScissor(0,0,i.width/2,i.height),e.setViewport(0,0,i.width/2,i.height),e.render(r,t.cameraL),e.setScissor(i.width/2,0,i.width/2,i.height),e.setViewport(i.width/2,0,i.width/2,i.height),e.render(r,t.cameraR),e.setScissorTest(!1)}},v.VREffect=function(e,t){function r(e){u=e,e.length>0?s=e[0]:t&&t("HMD not available")}function n(){var t=m.isPresenting;if(m.isPresenting=void 0!==s&&s.isPresenting,m.isPresenting){var r=s.getEyeParameters("left"),n=r.renderWidth,i=r.renderHeight;t||(x=e.getPixelRatio(),g=e.getSize(),e.setPixelRatio(1),e.setSize(2*n,i,!1))}else t&&(e.setPixelRatio(x),e.setSize(g.width,g.height,y))}function i(e){var t=2/(e.leftTan+e.rightTan),r=(e.leftTan-e.rightTan)*t*.5,n=2/(e.upTan+e.downTan);return{scale:[t,n],offset:[r,(e.upTan-e.downTan)*n*.5]}}function a(e,t,r,n){t=void 0===t||t,r=void 0===r?.01:r,n=void 0===n?1e4:n;var a=t?-1:1,o=new v.Matrix4,s=o.elements,l=i(e);return s[0]=l.scale[0],s[1]=0,s[2]=l.offset[0]*a,s[3]=0,s[4]=0,s[5]=l.scale[1],s[6]=-l.offset[1]*a,s[7]=0,s[8]=0,s[9]=0,s[10]=n/(r-n)*-a,s[11]=n*r/(r-n),s[12]=0,s[13]=0,s[14]=a,s[15]=0,o.transpose(),o}function o(e,t,r,n){var i=Math.PI/180;return a({upTan:Math.tan(e.upDegrees*i),downTan:Math.tan(e.downDegrees*i),leftTan:Math.tan(e.leftDegrees*i),rightTan:Math.tan(e.rightDegrees*i)},t,r,n)}var s,u,c,f,d=new v.Vector3,h=new v.Vector3,p=null;"VRFrameData"in window&&(p=new window.VRFrameData),navigator.getVRDisplays&&navigator.getVRDisplays().then(r).catch(function(){console.warn("THREE.VREffect: Unable to get VR Displays")}),this.isPresenting=!1,this.scale=1;var m=this,g=e.getSize(),y=!1,x=e.getPixelRatio();this.getVRDisplay=function(){return s},this.setVRDisplay=function(e){s=e},this.getVRDisplays=function(){return console.warn("THREE.VREffect: getVRDisplays() is being deprecated."),u},this.setSize=function(t,r,n){if(g={width:t,height:r},y=n,m.isPresenting){var i=s.getEyeParameters("left");e.setPixelRatio(1),e.setSize(2*i.renderWidth,i.renderHeight,!1)}else e.setPixelRatio(x),e.setSize(t,r,n)};var b=e.domElement,w=[0,0,.5,1],_=[.5,0,.5,1];window.addEventListener("vrdisplaypresentchange",n,!1),this.setFullScreen=function(e){return new l.default(function(t,r){return void 0===s?void r(new Error("No VR hardware found.")):m.isPresenting===e?void t():void t(e?s.requestPresent([{source:b}]):s.exitPresent())})},this.requestPresent=function(){return this.setFullScreen(!0)},this.exitPresent=function(){return this.setFullScreen(!1)},this.requestAnimationFrame=function(e){return void 0!==s?s.requestAnimationFrame(e):window.requestAnimationFrame(e)},this.cancelAnimationFrame=function(e){void 0!==s?s.cancelAnimationFrame(e):window.cancelAnimationFrame(e)},this.submitFrame=function(){void 0!==s&&m.isPresenting&&s.submitFrame()},this.autoSubmitFrame=!0;var M=new v.Matrix4,S=new v.PerspectiveCamera;S.layers.enable(1);var T=new v.PerspectiveCamera;T.layers.enable(2),this.getCameraL=function(){return S},this.getCameraR=function(){return T},this.render=function(t,r,n,i){if(s&&m.isPresenting){var a=t.autoUpdate;a&&(t.updateMatrixWorld(),t.autoUpdate=!1),Array.isArray(t)&&(console.warn("THREE.VREffect.render() no longer supports arrays. Use object.layers instead."),t=t[0]);var l,u,g=e.getSize(),v=s.getLayers();if(v.length){var y=v[0];l=null!==y.leftBounds&&4===y.leftBounds.length?y.leftBounds:w,u=null!==y.rightBounds&&4===y.rightBounds.length?y.rightBounds:_}else l=w,u=_;if(c={x:Math.round(g.width*l[0]),y:Math.round(g.height*l[1]),width:Math.round(g.width*l[2]),height:Math.round(g.height*l[3])},f={x:Math.round(g.width*u[0]),y:Math.round(g.height*u[1]),width:Math.round(g.width*u[2]),height:Math.round(g.height*u[3])},n?(e.setRenderTarget(n),n.scissorTest=!0):(e.setRenderTarget(null),e.setScissorTest(!0)),(e.autoClear||i)&&e.clear(),null===r.parent&&r.updateMatrixWorld(),s.getFrameData)s.depthNear=r.near,s.depthFar=r.far,s.getFrameData(p),M.elements.set(p.leftViewMatrix),M.getInverse(M),M.premultiply(r.matrixWorld),M.decompose(S.position,S.quaternion,S.scale),M.elements.set(p.rightViewMatrix),M.getInverse(M),M.premultiply(r.matrixWorld),M.decompose(T.position,T.quaternion,T.scale),S.projectionMatrix.elements.set(p.leftProjectionMatrix),T.projectionMatrix.elements.set(p.rightProjectionMatrix);else{var x=s.getEyeParameters("left"),b=s.getEyeParameters("right");d.fromArray(x.offset),h.fromArray(b.offset),r.matrixWorld.decompose(S.position,S.quaternion,S.scale),T.position.copy(S.position),T.quaternion.copy(S.quaternion),T.scale.copy(S.scale);var E=this.scale;S.translateOnAxis(d,E),T.translateOnAxis(h,E),S.projectionMatrix=o(x.fieldOfView,!0,r.near,r.far),T.projectionMatrix=o(b.fieldOfView,!0,r.near,r.far)}return n?(n.viewport.set(c.x,c.y,c.width,c.height),n.scissor.set(c.x,c.y,c.width,c.height)):(e.setViewport(c.x,c.y,c.width,c.height),e.setScissor(c.x,c.y,c.width,c.height)),e.render(t,S,n,i),n?(n.viewport.set(f.x,f.y,f.width,f.height),n.scissor.set(f.x,f.y,f.width,f.height)):(e.setViewport(f.x,f.y,f.width,f.height),e.setScissor(f.x,f.y,f.width,f.height)),e.render(t,T,n,i),n?(n.viewport.set(0,0,g.width,g.height),n.scissor.set(0,0,g.width,g.height),n.scissorTest=!1,e.setRenderTarget(null)):(e.setViewport(0,0,g.width,g.height),e.setScissorTest(!1)),a&&(t.autoUpdate=!0),void(m.autoSubmitFrame&&m.submitFrame())}e.render(t,r,n,i)},this.dispose=function(){window.removeEventListener("vrdisplaypresentchange",n,!1)}},v.VRController=function(e,t){function r(e){for(var r=navigator.getGamepads(),n=0,i=0;n<4;n++){var a=r[n];if(a&&a.id===e){if(i===t)return a;i++}}}v.Object3D.call(this);var n,i=this,a=[0,0],o=!1,s=!1,l=!1,u=!1;void 0===t&&(t=0),this.matrixAutoUpdate=!1,this.standingMatrix=new v.Matrix4,this.getGamepad=function(){return n},this.getButtonState=function(e){return"thumbpad"===e?o:"trigger"===e?s:"grips"===e?l:"menu"===e?u:void 0},this.update=function(t,c){if(void 0!==(n=r(e))&&n.pose){var f=n.pose;null!==n.pose.position?i.position.fromArray(f.position):i.position.fromArray([0,1,0]),null!==n.pose.orientation?i.quaternion.fromArray(f.orientation):i.quaternion.set(0,0,0,1),i.matrix.compose(i.position,i.quaternion,i.scale),i.matrix.multiplyMatrices(i.standingMatrix,i.matrix),i.matrix.decompose(i.position,i.quaternion,i.scale),i.matrixWorldNeedsUpdate=!0,i.visible=!0}else i.visible=!1;if(n){if(!n.axes||a[0]===n.axes[0]&&a[1]===n.axes[1]||(a[0]=n.axes[0],a[1]=n.axes[1],i.dispatchEvent({type:"axischanged",axes:a})),n.buttons[0]&&o!==n.buttons[0].pressed)if(o=n.buttons[0].pressed,t&&c){var d={which:2,position:i.position,quaternion:i.quaternion};o?t(d):c(d)}else{var h=new Event(o?"thumbpaddown":"thumbpadup");window.dispatchEvent(h)}if(n.buttons[1]&&s!==n.buttons[1].pressed)if(s=n.buttons[1].pressed,t&&c){var d={which:1,position:i.position,quaternion:i.quaternion};s?t(d):c(d)}else{var h=new Event(s?"triggerdown":"triggerup");window.dispatchEvent(h)}if(n.buttons[2]&&l!==n.buttons[2].pressed)if(l=n.buttons[2].pressed,t&&c){var d={which:3,position:i.position,quaternion:i.quaternion};l?t(d):c(d)}else{var h=new Event(l?"gripsdown":"gripsup");window.dispatchEvent(h)}if(n.buttons[3]&&u!==n.buttons[3].pressed)if(u=n.buttons[3].pressed,t&&c){var d={which:4,position:i.position,quaternion:i.quaternion};u?t(d):c(d)}else{var h=new Event(u?"menudown":"menuup");window.dispatchEvent(h)}}}},v.VRController.prototype=(0,d.default)(v.Object3D.prototype),v.VRController.prototype.constructor=v.VRController;var y=(i={blending:v.NormalBlending,side:v.DoubleSide,premultipliedAlpha:!0},(0,o.default)(i,"side",v.DoubleSide),(0,o.default)(i,"depthTest",!1),(0,o.default)(i,"depthWrite",!1),(0,o.default)(i,"transparent",!0),(0,o.default)(i,"uniforms",{ModelViewMatrix:{type:"m4",value:(new v.Matrix4).identity()},sparkleTexture:{type:"t",value:null},screenTexture:{type:"t",value:null},noiseTexture:{type:"t",value:null},scale:{type:"f",value:1},intensity:{type:"f",value:1}}),(0,o.default)(i,"vertexShader","varying vec2 vUv;\n varying vec2 sparkleCentreUV;\n uniform mat4 ModelViewMatrix;\n uniform float scale;\n \n void main() {\n vUv = uv;\n vec2 alignedPosition = position.xy * scale;\n vec4 finalPosition = ModelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );\n finalPosition.xy += alignedPosition;\n finalPosition = projectionMatrix * finalPosition;\n vec4 sparkleProjectedCentre = projectionMatrix * ModelViewMatrix * vec4(0.0,0.0,0.0,1.0);\n sparkleCentreUV = (sparkleProjectedCentre.xy/sparkleProjectedCentre.w + 1.0)*0.5;\n gl_Position = finalPosition;\n }"),(0,o.default)(i,"fragmentShader","#include \n varying vec2 vUv;\n varying vec2 sparkleCentreUV;\n uniform sampler2D sparkleTexture;\n uniform sampler2D screenTexture;\n uniform sampler2D noiseTexture;\n uniform float intensity;\n \n void main() {\n vec4 screenColor = texture2D( screenTexture, sparkleCentreUV );\n float screenIntensity = pow( average( screenColor.xyz ), 3.0 );\n float noise = texture2D( noiseTexture, sparkleCentreUV ).r;\n gl_FragColor = vec4( texture2D( sparkleTexture, vUv ).a * screenIntensity * noise * intensity );\n }"),i);v.Sparkle=function(e){this.texture=e,this.geometry=new v.PlaneGeometry(1,1,0),this.material=new v.ShaderMaterial(y),this.material.uniforms=v.UniformsUtils.clone(y.uniforms),void 0!==this.texture&&(this.material.uniforms.sparkleTexture.value=e),this.mesh=new v.Mesh(this.geometry,this.material),this.rotationSpeedFactor=5},v.Sparkle.prototype={constructor:v.Sparkle,shallowCopy:function(){var e=new v.Sparkle(this.texture);return e.mesh.position.copy(this.mesh.position),e.mesh.quaternion.copy(this.mesh.quaternion),e.mesh.scale.copy(this.mesh.scale),e.material.uniforms.scale.value=this.material.uniforms.scale.value,e.material.uniforms.intensity.value=this.material.uniforms.intensity.value,e.material.uniforms.screenTexture.value=this.material.uniforms.screenTexture.value,e.material.uniforms.noiseTexture.value=this.material.uniforms.noiseTexture.value,e.material.uniforms.ModelViewMatrix.value.copy(this.material.uniforms.ModelViewMatrix.value),e.rotationSpeedFactor=this.rotationSpeedFactor,e},setScale:function(e){this.material.uniforms.scale.value=e},setIntensity:function(e){this.material.uniforms.intensity.value=e},alignWithCamera:function(e,t){this.mesh.modelViewMatrix.multiplyMatrices(e.matrixWorldInverse,t.matrixWorld),this.mesh.modelViewMatrix.multiplyMatrices(this.mesh.modelViewMatrix,this.mesh.matrix),this.material.uniforms.ModelViewMatrix.value.copy(this.mesh.modelViewMatrix)}},v.NormalCubeMapBaker=function(e,t,r){var n=new v.ShaderMaterial(v.GeometricNormalCaptureShader);n.blending=v.NoBlending;var i=t;i.computeBoundingSphere();var a=(new v.Matrix4).setPosition(i.boundingSphere.center.clone().negate()),o=1/i.boundingSphere.radius,s=(new v.Matrix4).makeScale(o,o,o),l=(new v.Matrix4).multiplyMatrices(s,a),u=new v.Vector3,c=new v.Quaternion,f=new v.Vector3;l.decompose(u,c,f);var d=new v.Mesh(i,n);d.position.copy(u),d.scale.copy(f);var h=new v.Scene;h.add(d);var p=e.extensions.get("OES_texture_float")&&e.extensions.get("OES_texture_float_linear"),m=new v.CubeCamera(.01,100,512);m.renderTarget.texture.generateMipmaps=!1,m.renderTarget.texture.magFilter=r?v.NearestFilter:v.LinearFilter,m.renderTarget.texture.minFilter=r?v.NearestFilter:v.LinearFilter,m.renderTarget.texture.format=v.RGBAFormat,m.renderTarget.texture.type=p&&!r?v.FloatType:v.UnsignedByteType,m.updateCubeMap(e,h),this.texture=m.renderTarget.texture},v.SHADOW_PLANE_STATE=function(){function e(){this.numShadowMipMaps=4,this.shadowMipMaps=[],this.tempRenderTargets=[],this.resolution=new v.Vector2(512,512);for(var e={minFilter:v.LinearFilter,magFilter:v.LinearFilter,format:v.RGBAFormat,stencilBuffer:!1},t=Math.ceil(this.resolution.x),r=Math.ceil(this.resolution.y),n=0;n\n varying vec2 vUv;\n uniform sampler2D shadowSampler1;\n uniform sampler2D shadowSampler2;\n uniform sampler2D shadowSampler3;\n uniform sampler2D shadowSampler4;\n uniform vec2 nearFar; uniform float planeDistance; uniform float maxDistance; uniform float lightArea; \n void main() {\n float f1 = texture2D(shadowSampler1, vUv).r; float f2 = texture2D(shadowSampler2, vUv).r; float f3 = texture2D(shadowSampler3, vUv).r; float f4 = texture2D(shadowSampler4, vUv).r; float diff = (f1 + f2 + f3 + f4)*0.25; diff *= lightArea; diff = min(diff, 1.0); float value1 = 0.0; float value2 = 0.0; float t = 0.0; if( diff <= 0.33) { value1 = f1; value2 = f2; t = diff; } else if( diff > 0.33 && diff <= 0.66) { value1 = f2; value2 = f3; t = diff - 0.33; } else { value1 = f3; value2 = f4; t = diff - 0.66; } t *= 3.0; t = t>1.0 ? 1.0: t; float value = mix(value1, value2, t); gl_FragColor = vec4( vec3(value), 1.0);\n }"}),this.depthMaterial=new v.MeshDepthMaterial,this.depthMaterial.side=v.DoubleSide,this.depthMaterial.depthPacking=v.RGBADepthPacking,this.depthMaterial.blending=v.NoBlending,this.shadowProjectionMaterial=new v.ShaderMaterial({uniforms:{planeDistance:{value:0},maxDistance:{value:0},nearFar:{value:null},depthTexture:{value:null}},vertexShader:"varying vec2 vUv;\n void main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n }",fragmentShader:"precision highp float; #include \n varying vec2 vUv;\n uniform sampler2D depthTexture;\n uniform vec2 nearFar; uniform float planeDistance; uniform float maxDistance; \n void main() {\n float orthoDepth = unpackRGBAToDepth(texture2D(depthTexture, vec2(vUv.x, 1.0-vUv.y))); float viewZ = -orthographicDepthToViewZ(orthoDepth, nearFar.x, nearFar.y); float diff = ( viewZ - planeDistance)/maxDistance; gl_FragColor = vec4( vec3(diff), 1.0);\n }"})}var t;return{getInstance:function(){return null==t&&(t=new e,t.constructor=null),t}}}(),v.ShadowPlane=function(e,t){this.resolution=e||new v.Vector2(512,512),this.shadowPlanePosition=new v.Vector3(0,0,0),this.shadowPlaneNormal=new v.Vector3(0,1,0),this.shadowPlaneSize=new v.Vector2(1,1),this.useBlur=!0,this.maxDistance=1,this.lightArea=1,void 0!==t&&(this.shadowPlaneNormal=t.shadowPlaneNormal?this.shadowPlaneNormal.copy(t.shadowPlaneNormal):this.shadowPlaneNormal,this.shadowPlanePosition=t.shadowPlanePosition?this.shadowPlanePosition.copy(t.shadowPlanePosition):this.shadowPlanePosition,this.shadowPlaneSize=t.shadowPlaneSize?this.shadowPlaneSize.copy(t.shadowPlaneSize):this.shadowPlaneSize,this.maxDistance=t.maxDistance||this.maxDistance,this.useBlur=void 0===t.useBlur?this.useBlur:t.useBlur,this.lightArea=t.lightArea||this.lightArea),this.depthRT=new v.WebGLRenderTarget(this.resolution.x,this.resolution.y),this.depthRT.texture.generateMipmaps=!1,this.shadowRT=new v.WebGLRenderTarget(this.resolution.x,this.resolution.y),this.shadowRT.texture.generateMipmaps=!1,this.scene=new v.Scene,this.camera=new v.OrthographicCamera,this.scene.add(this.camera),this.clipPlane=new v.Plane(new v.Vector3(0,1,0),0),this.originalClipPlane=this.clipPlane.clone(),this.falseClipPlane=new v.Plane(new v.Vector3(0,0,1),1e4);var r=v.SHADOW_PLANE_STATE.getInstance();this.depthMaterial=r.depthMaterial,this.shadowProjectionMaterial=r.shadowProjectionMaterial,this.numShadowMipMaps=r.numShadowMipMaps,this.shadowMipMaps=r.shadowMipMaps,this.tempRenderTargets=r.tempRenderTargets,this.vBlurMaterial=r.vBlurMaterial,this.hBlurMaterial=r.hBlurMaterial,this.distanceBlurMaterial=r.distanceBlurMaterial,this.distanceBlurMaterial.uniforms.shadowSampler1.value=this.shadowMipMaps[0].texture,this.distanceBlurMaterial.uniforms.shadowSampler2.value=this.shadowMipMaps[1].texture,this.distanceBlurMaterial.uniforms.shadowSampler3.value=this.shadowMipMaps[2].texture,this.distanceBlurMaterial.uniforms.shadowSampler4.value=this.shadowMipMaps[3].texture},v.ShadowPlane.prototype={constructor:v.ShadowPlane,setCameraParams:function(){this.camera.left=-this.shadowPlaneSize.x/2,this.camera.right=this.shadowPlaneSize.x/2,this.camera.top=this.shadowPlaneSize.y/2,this.camera.bottom=-this.shadowPlaneSize.y/2,this.camera.near=.01,this.camera.far=1e4,this.camera.updateProjectionMatrix();var e=new v.Vector3;e.copy(this.shadowPlanePosition),e.addScaledVector(this.shadowPlaneNormal,-this.maxDistance),this.camera.position.copy(e),this.camera.lookAt(this.shadowPlanePosition)},applyBlur:function(e,t){for(var r=0;r1&&void 0!==arguments[1]?arguments[1]:{};e.nodes[We]&&!t.force||(e.nodes[We]=s({id:We,name:"CAMERA",type:"Camera",plugs:{Camera:[["Camera",{}]],Transform:[["Transform",{}]],Properties:[["CameraProperties",{}]]}})),e.nodes[Xe]&&!t.force||(e.nodes[Xe]=s({id:Xe,name:"VR CAMERA",type:"Camera",plugs:{Camera:[["Camera",{fieldOfView:45}]],Transform:[["Transform",{translation:{x:0,y:1.6,z:1}}]],Properties:[["CameraProperties",{}]]}})),e.nodes[Ye]&&!t.force||(e.nodes[Ye]=s({id:Ye,name:"VIRTUAL TARGET NULL",type:"Null",plugs:{Transform:[["Transform",{}]]}})),e.nodes[qe]&&!t.force||(e.nodes[qe]=s({id:qe,name:"CONTROLER ROOT NULL",type:"Null",plugs:{Transform:[["Transform",{}]]}})),e.nodes[Ze]&&!t.force||(e.nodes[Ze]=s({id:Ze,name:"VIRTUAL PIVOT NULL",type:"Null",plugs:{Transform:[["Transform",{}]]}}))}function u(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return(0,ie.default)(e,{_v:0,nodes:{},fileReferences:{to:{},from:{}},nodeReferences:{to:{},from:{}},cameraReferences:{},worldTransformReferences:{},evaluatedNodes:{},cameraController:new Le.default,loaded:!1,activeSceneId:null,objects:{},refs:{},origin:{},commits:{},_ev:0,_sv:0})}function c(e,t){var r=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];t&&(t._changedPlug?t._changedPlug!==r&&(t._changedPlug=!0):t._changedPlug=r,t._v+=1),e._v+=1}function f(e,t,r){var n=t.path,i=t.value,a=r&&r.ignoreErrors;if(!n.length||n.length<2)throw new Error("SET requires a path with length 2 or 4");var o=(0,oe.default)(n,4),s=o[0],l=o[1],u=o[2],f=o[3],d=e.nodes[s];if(2===n.length&&"name"===n[1])d.name=i,c(e,d);else{var h=d&&d.plugs[l],p=h&&h[u];if(!p){if(a)return;throw new Error("Setting data on unknown operator: "+n.join(","))}_e.default[l][p.type].set(p,f,i)&&c(e,d,l)}return e}function d(e){var t={},r=!0,n=!1,i=void 0;try{for(var a,o=(0,ee.default)((0,le.default)(e.plugs));!(r=(a=o.next()).done);r=!0){var s=a.value;t[s]=e.plugs[s].map(function(e){return(0,ie.default)({},e)})}}catch(e){n=!0,i=e}finally{try{!r&&o.return&&o.return()}finally{if(n)throw i}}return{id:(0,he.default)(),name:e.name,type:e.type,parent:e.parent,children:[].concat(e.children),plugs:t,_v:1}}function h(e){var t=e.id,r=e.name,n=e.type,i=e.plugs,a=e.parent;return t||(t=(0,he.default)()),r=r||t,{type:be.ADD_NODE,payload:{id:t,name:r,type:n,plugs:i,parent:a},resolve:t}}function p(e){return{type:be.DELETE_NODE,payload:e}}function m(e,t,r){return{type:ze,payload:{id:e,plug:t,op:r}}}function g(e,t){if(!Array.isArray(t))throw new Error("Expect path to be an array");var r=e.get("sceneGraph"),n=r.nodes[t[0]];if(t.length>=2){if("name"===t[1]||"type"===t[1])return n&&n[t[1]];n=n&&n.plugs[t[1]]}if(t.length>=3&&(n=n&&n[t[2]]),t.length>=4&&n){n=(0,we.lookupOperator)(t[1],n.type,[]).get(n,t[3])}return n}function v(e){return g(e,[(0,Ve.getSceneId)(e),"Player",0,"vrCamera"])}function y(e){return function(t){var r=[(0,Ve.getSceneId)(t),"Player",0,"vrCamera"];t.dispatch(x(r,e))}}function x(e,t){return{type:Ne,payload:{path:e,value:t},meta:{remote:!0}}}function b(e,t){return{type:Be,payload:{path:e,attrs:t}}}function w(e,t){return{type:Fe,payload:{id:e,node:t}}}function _(e){return{type:Ue,payload:e}}function M(e){var t=Array.isArray(e)?e:[e];return{type:je,payload:t}}function S(e,t){return{type:ke,payload:{parentId:e,childIds:t}}}function T(e,t){var r=e.get("sceneGraph").nodes[t];return r&&r.parent}function E(e,t){var r=e.get("sceneGraph").nodes[t],n=r&&r.parent;return n?E(e,n):t}function P(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=r.cloneDependencies,i=e.reduce(function(e,t){return e[t]=!0,e},{}),a={};return function(r){function o(e){var n=l.nodes[e];n&&n.name;if(n&&n.plugs){var s=!0,u=!1,c=void 0;try{for(var f,d=(0,ee.default)((0,le.default)(n.plugs));!(s=(f=d.next()).done);s=!0){var h=f.value,p=n.plugs[h],m=!0,g=!1,v=void 0;try{for(var y,x=(0,ee.default)(p);!(m=(y=x.next()).done);m=!0){var b=y.value,w=_e.default[h][b.type];if(w){var _=!0,M=!1,S=void 0;try{for(var T,E=(0,ee.default)(w.referenceKeys);!(_=(T=E.next()).done);_=!0){var P=T.value,A=b[P];!A||i[A]||t[A]||(i[A]=!0,o(A))}}catch(e){M=!0,S=e}finally{try{!_&&E.return&&E.return()}finally{if(M)throw S}}var C=!0,I=!1,R=void 0;try{for(var O,L=(0,ee.default)(w.fileReferenceKeys);!(C=(O=L.next()).done);C=!0){var D=O.value,V=b[D];V&&r.getIn(["assets","assets",V])&&(a[V]=!0)}}catch(e){I=!0,R=e}finally{try{!C&&L.return&&L.return()}finally{if(I)throw R}}}}}catch(e){g=!0,v=e}finally{try{!m&&x.return&&x.return()}finally{if(g)throw v}}}}catch(e){u=!0,c=e}finally{try{!s&&d.return&&d.return()}finally{if(u)throw c}}}}function s(e){var r=e,n=!0,o=!1,s=void 0;try{for(var l,u=(0,ee.default)((0,le.default)(e.plugs));!(n=(l=u.next()).done);n=!0)!function(){var n=l.value;e.plugs[n].forEach(function(e,o){var s=_e.default[n][e.type];if(s){var l=!0,u=!1,c=void 0;try{for(var f,d=(0,ee.default)(s.referenceKeys);!(l=(f=d.next()).done);l=!0){var h=f.value,p=e[h],m=p&&(i[p]||t[p]);m&&(r.plugs[n][o][h]=m)}}catch(e){u=!0,c=e}finally{try{!l&&d.return&&d.return()}finally{if(u)throw c}}var g=!0,v=!1,y=void 0;try{for(var x,b=(0,ee.default)(s.fileReferenceKeys);!(g=(x=b.next()).done);g=!0){var w=x.value,_=e[w];_&&a[_]&&(r.plugs[n][o][w]=a[_])}}catch(e){v=!0,y=e}finally{try{!g&&b.return&&b.return()}finally{if(v)throw y}}}})}()}catch(e){o=!0,s=e}finally{try{!n&&u.return&&u.return()}finally{if(o)throw s}}return r}var l=r.get("sceneGraph");n&&e.forEach(o),(0,le.default)(i).forEach(function(e){return i[e]=(0,he.default)()}),(0,le.default)(a).forEach(function(e){return a[e]=(0,he.default)()}),(0,le.default)(i).forEach(function(e){var n=l.nodes[e],a=d(n);a.id=i[e];var o=n.parent,u=o&&(i[o]||t[o]||o);a.parent=u,a.children=[];var c=!0,f=!1,h=void 0;try{for(var p,m=(0,ee.default)(n.children);!(c=(p=m.next()).done);c=!0){var g=p.value;i[g]?a.children.push(i[g]):t[g]&&a.children.push(t[g])}}catch(e){f=!0,h=e}finally{try{!c&&m.return&&m.return()}finally{if(f)throw h}}r.dispatch({type:be.ADD_NODE,payload:{id:i[e],parent:u,node:s(a)}})});var u=E(r,i[(0,le.default)(i)[0]]);return(0,le.default)(a).forEach(function(e){var t=r.getIn(["assets","assets",e]);t&&r.dispatch((0,xe.addFile)(t.set("id",a[e]).set("sceneId",u).toJS()))}),Q.default.resolve(i)}}function A(e){var t=(0,le.default)(e.plugs).map(function(t){return{type:t,operators:e.plugs[t].map(function(e){return(0,we.lookupOperator)(t,e.type,[]).export(e)})}});return{_id:e.id,name:e.name,type:e.type,plugs:t,nodes:[]}}function C(e,t){var r=void 0,n={},i=e.get("sceneGraph");return t.forEach(function(e){var t=i.nodes[e];if(t){var a=A(t);n[a._id]=a,r||(r=a),t.parent&&n[t.parent]&&n[t.parent].nodes.push(a)}}),r}function I(e,t,r){var n=T(e,t),i=(0,De.getWorldTransform)(e,n),a=new fe.Vector3,o=new fe.Quaternion,s=new fe.Vector3,l=new fe.Matrix4;if(l.copy(r),i){var u=new fe.Matrix4;u.getInverse(i,!0),l.multiplyMatrices(u,l)}l.decompose(a,o,s);var c=(new fe.Euler).setFromQuaternion(o,"ZYX");e.dispatch(x([t,"Transform",0,"translation"],{x:a.x,y:a.y,z:a.z})),e.dispatch(x([t,"Transform",0,"rotation"],{x:fe.Math.radToDeg(c.x),y:fe.Math.radToDeg(c.y),z:fe.Math.radToDeg(c.z)}))}function R(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=e.get("sceneGraph");return r._v===r._ev?r:((0,Me.evaluateSceneGraph)(e,r,t),r)}function O(e){return{type:Ge,payload:e}}function L(e,t){var r=e.get("sceneGraph"),n=H(r,t);return r.objects[n.root]?Q.default.resolve(!0):e.callApi({url:"/api/scene/"+r.activeSceneId+"/objects/"+r.refs.HEAD+"/"+t}).then(function(t){return e.dispatch(O(t))})}function D(){arguments.length>0&&void 0!==arguments[0]&&arguments[0];return function(e){var t=e.get("sceneGraph");if(!t.refs.HEAD&&!(0,le.default)(t.nodes).length)return Q.default.resolve();var r=(0,Te.default)(e),n=r.objects,i=r.commit,a=r.commitHash,o=H(t,t.refs.HEAD);if(o&&i.root===o.root)return e.dispatch(O({refs:{INDEX:t.refs.HEAD}}));(0,ie.default)({},t.objects,n);return e.dispatch(O({objects:n,refs:{INDEX:a},commit:i}))}}function V(e){var t=e.toHEAD,r=e.secondHEAD,n=e.fromHEAD,a=e.options;return function(e){var o=e.get("sceneGraph");n||(n=o.refs.INDEX);var s=n&&H(o,n),l=H(o,t),u=r&&H(o,r);(0,Pe.default)(o,l,s,u,{changeNode:function(t){var r=t.id,n=t.plugs,a=o.nodes[r];a.plugs=(0,ie.default)({},a.plugs,n),e.dispatch(w(r,i(a)))},addNode:function(t){return e.dispatch(h(t))},deleteNode:function(t){return e.dispatch(p(t))},addFile:function(t){return e.dispatch((0,xe.addFile)(t))}}),(0,Ce.default)(o,l,s,u,function(t,r){e.dispatch(x(t,r))}),e.dispatch({type:He}),a.detached?e.dispatch({type:Ge,payload:{refs:{DETACHED_HEAD:t}}}):e.dispatch({type:Ge,payload:{refs:{HEAD:t,DETACHED_HEAD:null}}}),e.dispatch({type:je})}}function N(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(r){return r.dispatch(D()).then(function(){return L(r,e).then(function(){return r.dispatch(V({toHEAD:e,options:t}))})})}}function B(e){return function(t){var r=t.get("sceneGraph"),n=r.refs.HEAD;return t.dispatch(D()).then(function(){var i=r.refs.INDEX;return L(t,e).then(function(){return n===i?t.dispatch(V({toHEAD:e,options:{}})):(t.dispatch(V({toHEAD:n,options:{}})),t.dispatch(V({toHEAD:e,fromHEAD:n,secondHEAD:i,options:{}})))})})}}function F(e){return function(t){var r=t.get("sceneGraph"),n=r.history,i=e||n[1];if(!i)return console.log("Nothing to undo");t.dispatch(loadFromContent(i))}}function U(e){var t=e.get("sceneGraph"),r=t.history;return r&&r.length?t.commits[r[r.length-1]]:null}function k(e){for(var t=e.get("sceneGraph"),r=t.refs,n=r.HEAD,i=r.DETACHED_HEAD,a=n,o=[];a;){var s=H(t,a),l=i?a===i:a===n;s?(o.push([a,s,l]),a=1===s.parents.length&&s.parents[0]):a=null}return o}function z(e){return function(t){return t.callApi({url:"/api/scene/"+e+"/commits"}).then(function(e){return t.dispatch(O(e))})}}function j(e,t){return H(e.get("sceneGraph"),t)}function G(){return function(e){console.log("redo")}}function H(e,t){if(!e.commits[t]){if(!e.objects[t])return null;e.commits[t]=JSON.parse(e.objects[t]),e.commits[t].createdAt=new Date(e.commits[t].createdAt)}return e.commits[t]}function W(){return function(e){var t=e.get("sceneGraph"),r=t.activeSceneId;return e.dispatch(D()).then(function(n){var i=n.refs,a=n.commit,o=n.objects;if(a){var s=H(t,t.origin.HEAD),l=s?(0,Re.default)(t,a,s):o;return l[i.INDEX]=o[i.INDEX],e.dispatch({type:Ge,payload:{refs:{HEAD:i.INDEX}}}),e.callApi({url:"https://clara.io/threehub/api/scene/"+r+"/commit",method:"POST",body:{objects:l,ref:i.INDEX}}).then(function(e){console.log("saved commit?",e)}).catch(function(e){console.log("handle api error",e)})}})}}function X(){return function(e){var t=e.get("sceneGraph"),r=t.activeSceneId;return e.callApi({url:"/api/scene/"+r+"/sync/"+t.refs.HEAD}).then(function(r){var n=r.objects,i=r.HEAD;if(i!==t.refs.HEAD)return e.dispatch(O({objects:n,origin:{HEAD:i}})),e.dispatch(B(i))})}}function Y(e,t){var r=arguments.length>2&&void 0!==arguments[2]&&arguments[2],n=arguments[3];if(!n)return void console.error("traverseHierarchy: no callback provided");var i=e.get("sceneGraph"),a=i.activeSceneId,o=i.nodes,s=o[a]&&o[a].plugs.Properties,l=s&&s[0]&&"Enable"===s[0].hierarchyVisibility,u=t||(0,De.find)(e,"Objects"),c=o[u];if(c){var f=(0,De.isVisible)(e,u);if(r&&!f||n(u),!r||!l||l&&f)for(var d=0;d=t.length?(this.name=null,!1):(this.element=e.byName[this.name=t[r]],!0)},add:function(e,t){var r=this.namesByIndex;if(-1!==r.indexOf(e))throw Error("ObjectsByName: Name '"+e+"' not unique!");return r.push(e),this.byName[e]=t,this}},n.shallowClone=function(){var e=new n.Iterator;return function(t){var r=new n;if(!t)return r;var i=r.byName,a=r.namesByIndex;for(a.length=t.namesByIndex.length,e.reset(t);e.next();){var o=e.name;i[o]=e.element,a[e.index]=o}return e.reset(null),r}}()},function(e,t,r){var n=r(17);e.exports=function(e){if(!n(e))throw TypeError(e+" is not an object!");return e}},function(e,t){var r=e.exports="undefined"!=typeof window&&window.Math==Math?window:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")();"number"==typeof __g&&(__g=r)},function(e,t){e.exports=function(e){return"object"==typeof e?null!==e:"function"==typeof e}},function(e,t,r){"use strict";t.__esModule=!0;var n=r(112),i=function(e){return e&&e.__esModule?e:{default:e}}(n);t.default=function(e,t,r){return t in e?(0,i.default)(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function i(e,t){if(e.get("phase")!==Le.RENDERING)return e;var r=e.get("loadingFiles").size,n=e.get("loadedFiles").size,i=r+n,a=0===i?1:(1+n/i)/2;return a<1?(t("loading",a),e.set("progress",a)):(t("loading",1),e.set("progress",1))}function a(e){return{type:Ee,payload:e}}function o(e){return function(t){return t.dispatch({type:me.USE_SCENE,payload:e}),O(t,t.getIn(["sceneIO","postLoadSceneGraphCommands"])),ee.default.resolve(e)}}function s(e){return e.getIn(["sceneIO","id"])}function l(e,t,r){return function(n){var i=n.read(t);n.trackEvent("playerv2","SceneGraph Loaded","Load Time",r),n.trackEvent("playerv2","SceneGraph Loaded","File Size",t.length);var a=Math.round(t.length/r);n.trackEvent("playerv2","SceneGraph Loaded","Download Rate",a),n.logPageView("/player/v2/"+e,r);var o=i.meta&&i.meta.get("owner");return o&&n.trackEvent("playerv2","Scene Owner",o),n.dispatch({type:me.LOAD_SCENE,payload:i}).then(function(){return n.dispatch({type:me.INITIALIZE_SCENE,payload:{id:e,store:n}})}).then(function(){return e})}}function u(e){return a("Error Loading Scene")}function c(){return{type:be}}function f(e){return function(t){(0,ce.touch)(e),t.dispatch({type:we})}}function d(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=r.waitForPublish,i=r.ignoreErrorMessage;return function(a){function o(e){e.readyState>1&&(clearTimeout(u),clearTimeout(c))}if(a.getIn(["sceneGraph",e]))return ee.default.resolve(!0);if(r.threehub)return a.dispatch(m(e,r));var s=t,l=t?(0,de.fetchText)(t)(a):a.callApi({contentType:"text",types:["IGN","IGN",xe],url:"https://clara.io/api/scenes/"+e+"/published?wait="+(n?"true":"false"),queryKey:"SCENE"+e,payload:e,onReadyStateChange:o,ignoreCache:!0,ignoreErrorMessage:i,responseURL:function(e){var t=e.split("/");s=t[t.length-1]}}),u=setTimeout(function(){"undefined"==typeof __SERVER_RENDER?a.error(new Error("Slow Load"),null,{sceneId:e}):console.log("Slow Load")},Be),c=setTimeout(function(){a.error(new Error("Load Failure"),null,{sceneId:e})},Fe);return a.dispatch(C(e)),a.dispatch({type:ve,payload:e}),l.then(function(t){return clearTimeout(u),clearTimeout(c),a.dispatch({type:ye,payload:e}),a.dispatch(I(e)),a.dispatch({type:Ce,payload:{sceneId:e,fetchedHash:s}}),t})}}function h(e,t){return e.getIn(["sceneIO","fetchedHashes",t||s(e)])}function p(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=new Date;return function(i){return i.getIn(["sceneGraph",e])?ee.default.resolve(!0):i.dispatch(d(e,t,r)).then(function(t,r){return i.dispatch(l(e,t,new Date-n))})}}function m(e,t){return function(t){return t.callApi({types:[ve,ye,xe],url:Ne+"/scene/"+e,payload:e}).then(function(r){t.dispatch(o(e));var n=r.HEAD,i=r.objects;return t.dispatch((0,ce.setContentStore)({objects:i,origin:{HEAD:n}})),t.dispatch((0,ce.checkout)(n))})}}function g(){return function(e){var t=N(e),r=s(e);return e.callApi({contentType:"text",url:"https://clara.io/api/scenes/"+r+"/published",method:"PUT",body:(0,Q.default)({content:t})})}}function v(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return function(n){return n.dispatch(p(e,t,r)).then(function(){return n.dispatch(o(e))})}}function y(e,t,r){t.subscribe("notify:"+r).watch(function(t){console.log("notify scene: ",r,t);var n=t.origin;n&&n.HEAD!==sceneGraph.refs.HEAD&&(console.log("sync to latest: ",n.HEAD,"from",sceneGraph.refs.HEAD),e.dispatch((0,ce.syncToLatest)()))})}function x(e){return function(t){t.get("sceneGraph");return console.log("fetch for editing",e),t.dispatch(v(e,null,{threehub:!0})).then(function(){var r=t.getSocketApi();r&&y(t,r,e)})}}function b(e){var t=e.getIn;e.dispatch;return t(["sceneIO","progress"])}function w(e,t){return!!e.getIn(["sceneIO","loadingFiles",t])}function _(e){return e.getIn(["sceneIO","phase"])>=Le.RENDERING&&0===e.getIn(["sceneIO","loadingFiles"]).size}function M(e){return e.getIn(["sceneIO","loaded"])}function S(e){return e.getIn(["sceneIO","phase"])>=Le.RENDERED}function T(){return function(e){(0,pe.initStartingCamera)(e),O(e,e.getIn(["sceneIO","preloadCommands"]),_e,me.PRELOADED_SCENE,{store:e},function(){return z(e,null,!0)})}}function E(e){return{type:Pe,payload:e}}function P(e){return{type:Ae,payload:e}}function A(){return{type:Me}}function C(e){return{type:me.LOADING_FILE,payload:e}}function I(e){return{type:me.LOADED_FILE,payload:e}}function R(){return function(e){O(e,e.getIn(["sceneIO","postRenderCommands"]),Se,Te,{store:e})}}function O(e,t,r,n,i,a){var o=function(){return n?e.dispatch({type:n,payload:{id:s(e),store:e}}):ee.default.resolve(!0)};if(!t.size)return o();r&&e.dispatch({type:r}),ee.default.all(t.map(function(e){return ee.default.resolve(e(i))}).toArray()).then(function(){if(a)return a(i)}).then(function(){return o()}).catch(function(e){return console.log("Caught plugin error: ",e.message),console.log("Caught plugin error, stack: ",e.stack),o()})}function L(e){var t={};return e.forEach(function(e){t[e.type]=e.operators.map(function(e){var t=e.name;return[e.type||t,(0,ue.default)(["_id","primitive","name","type"],e),t]})}),t}function D(e,t){t.forEach(function(t){e.dispatch((0,de.addFile)((0,J.default)({id:t._id},(0,ue.default)(["_id","__v"],t))))})}function V(e){return function(t){Ue(t,e,null)(e),D(t,e.files),t.dispatch(G(e._id,(0,ne.Map)({owner:e.owner,v1version:e.version})));var r=(0,fe.get)(t,{plug:"Timeline",property:"useBufferClips"});(0,se.default)(function(e,n){r||t.dispatch((0,he.addClip)(e,n)),t.dispatch((0,he.makeReducedClip)(e,n))},e.clips)}}function N(e){var t=(0,ce.getEvalSceneGraph)(e),r=s(e);return e.write({id:r,meta:X(e),nodes:(0,Q.default)(t.nodes),assets:(0,de.getActiveAssets)(e),clips:e.getIn(["animation","clips"]),bufferClips:e.getIn(["animation","bufferClips"])})}function B(e){return{scene:e.get("sceneGraph").toJS(),assets:(0,de.getActiveAssets)(e).toJS()}}function F(e){return e.getIn(["sceneIO","errors"]).size}function U(e){return e.getIn(["sceneIO","errors"])}function k(e){return e.getIn(["sceneIO","phase"])}function z(e,t,r){var n=t||function(){},i=0;return new ee.default(function(t,a){e.getEvaluatedTranslator();!function a(){if(!r&&k(e)0)return new h(this.data,this.offset+t).parseStruct(e)},h.prototype.parseListOfLists=function(e){for(var t=this.parseOffset16List(),r=t.length,n=this.relativeOffset,i=new Array(r),a=0;a2&&void 0!==arguments[2]?arguments[2]:{},n=r.resizeImage,i=r.resizeWidth,a=r.resizeHeight,o=r.optimizeFormat;if(!n&&!o)return u(e,t);var s=n?i+"x"+a+"/":"",l=o?"filters:format("+o+")/":"";return["https://cdn.threehub.com/resources","https://clara.io/resources"].map(function(e){return e+"/images/"+s+l+t.get("hash")+"?filename="+t.get("name")})}function u(e,t,r){return e.getIn(["assets","fileRoots"]).map(function(e){return e+"/"+t.get("hash")+(r||t.get("suffix"))+"?filename="+t.get("name")})}function c(e){return function(t){return(0,t.getIn)(["sceneIO","loadingFiles",e])}}function f(e){return images[e]}function d(e,t,r){if(ce[t])return ce[t];e.dispatch((0,ee.markLoadingFile)(t));var n=new Image,i=new FileReader;return i.addEventListener("load",function(){n.src=i.result,n.onload=function(){ce[t]=n,e.dispatch((0,ee.markLoadedFile)(t))}}),i.readAsDataURL(r),null}function h(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return function(n){var i=n.getIn(["assets","assets",e]);if(i){var a=i.get("localFile");if(a)return d(n,e,a);var o=r.optimizeImage?l(n,i,r):[];return o.push.apply(o,(0,G.default)(u(n,i))),n.callApi((0,z.default)({types:[$.LOADING_FILE,$.LOADED_FILE,$.LOADING_FILE_ERROR],url:o,contentType:"img",payload:e,queryKey:"IMAGE"+i.get("hash"),fireAndForget:void 0===t.fireAndForget,successPayload:t.successPayload},t))}}}function p(e,t){return t&&h(t,{fireAndForget:!1,successPayload:!0})(e)}function m(e,t,r){return t&&g(t,(0,z.default)({fireAndForget:!1},r))(e)}function g(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(r){var n=r.getIn(["assets","assets",e]);if(!n)return r.error(new Error("target file not found"),null,{fileId:e}),null;if(n.get("content"))return n.get("content");var i=r.getTranslator(),a=n.get("lzma")&&!(i&&i.externals.isMobile)&&n.get("size")>=fe,o=void 0===t.decompress&&a;return r.callApi((0,z.default)({types:[$.LOADING_FILE,$.LOADED_FILE,$.LOADING_FILE_ERROR],url:u(r,n,a&&"lzma1"),contentType:"binary",payload:e,queryKey:"FILE"+n.get("hash")+o,decompress:o,fireAndForget:void 0===t.fireAndForget},t))}}function v(e){return function(t){var r=t.getIn(["assets","assets",e]);return r?t.callApi({types:[$.LOADING_FILE,$.LOADED_FILE,$.LOADING_FILE_ERROR],url:u(t,r),contentType:"font",payload:e,queryKey:"FILE"+r.get("hash"),fireAndForget:!0}):(t.error(new Error("target file not found"),null,{fileId:e}),null)}}function y(e){return function(t){var r=t.getIn(["assets","assets",e]);return r?t.callApi({types:[$.LOADING_FILE,$.LOADED_FILE,$.LOADING_FILE_ERROR],url:u(t,r),contentType:"text",payload:e,queryKey:"FILE"+r.get("hash"),fireAndForget:!0}):(t.error(new Error("target file not found"),null,{fileId:e}),null)}}function x(e,t){return e.getIn(["assets","assets",t,"hash"])}function b(e,t){var r=e.getIn(["assets","assets",t]);if(r){var n=u(e,r);return n[n.length-1]}return r}function w(e,t,r){var n=e.getIn(["assets","assets",t]);return n?l(e,n,r)[0]:null}function _(e){return function(t){return t.callApi({contentType:"text",url:t.getIn(["assets","fileRoots"]).map(function(t){return t+"/"+e})})}}function M(e){return function(t){return t.callApi({contentType:"text",url:"/api/scenes/"+e})}}function S(e,t){return e.getIn(["assets","assets"]).find(t)}function T(e,t){return e.getIn(["assets","assets"]).filter(t||function(){return!0})}function E(e){return e.getIn(["assets","assets"]).map(function(e){var t=e.toJS();return t._id=t.id,delete t.id,t}).toArray()}function P(e){var t=(0,K.getEvalSceneGraph)(e);return T(e,function(e,r){return!!t.fileReferences.from[r]})}function A(e,t){return Math.log(e)/Math.log(t)}function C(e){return Math.pow(2,Math.ceil(A(e,2)))}function I(e,t,r){return Math.max(t,Math.min(e,r))}function R(e,t){var r={};return r.width=I(C(e.width),1,t.width),r.height=I(C(e.height),1,t.height),r}function O(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(r){function n(e,n){var i=new FormData;return i.append("file",e),i.append("name",e.name),i.append("sceneId",he),i.append("type",e.type),i.append("targetFormat",t.targetFormat||"png"),i.append("quality",t.quality||60),i.append("maxSize",t.resizeTo),i.append("density",t.dpi),i.append("scale",t.scale),n&&i.append("convertToFileId",n),i.append("resize",s),L(r,{body:i,type:e.type})}function i(e){return r.dispatch(o((0,z.default)({id:e._id},e)))}function a(n){var i={name:n.name||e.name,type:"Image",parent:(0,Q.find)(r,{name:"Material Library"}),plugs:{Image:[["Image",{glBitmapFile:n.id,glOption:1}]],Properties:[["ImageProperties",{}]]}};return t.imageNodeId&&(i.id=t.imageNodeId),r.dispatch((0,K.addNode)(i)).then(function(e){return{id:e,imageNodeId:e,assetId:n.id,imageSize:{width:n.height,height:n.width,originalWidth:n.originalWidth,originalHeight:n.originalHeight},url:n.original}})}var s="boolean"!=typeof t.keepAspectRatio||!t.keepAspectRatio;if("string"==typeof e)return(0,te.isUuid)(e)?function(e){return r.callApi({types:[$.LOADING_FILE,$.LOADED_FILE,$.LOADING_FILE_ERROR],url:"https://clara.io/api/files/"+e+"/asset",payload:e})}(e).then(i).then(a):function(e){var n=(0,B.default)((0,z.default)({url:e,maxSize:t.resizeTo||de,targetFormat:t.targetFormat||"png",sceneId:he,resize:s},t));return r.callApi({types:[ie,ae,oe],method:"POST",url:"https://clara.io/api/files/image",body:n})}(e).then(i).then(a).catch(function(e){var t=void 0;return t=e.status&&e.status<500?"Image not imported, bad url":e.status&&e.status>=500?"Image not imported, internal error":e,U.default.reject(t)});if(!e.type)return U.default.reject("Expect a File");if(!pe[e.type])return U.default.reject("File format not supported");return e.type.match(/image\/(jpeg|png)/)&&e.size<5e6?function(e){return r.dispatch(o({id:(0,q.default)(),name:e.name,localFile:e,size:e.size,type:e.type}))}(e).then(a).then(function(t){return n(e,t.assetId).then(function(e){}),t}):n(e).then(i).then(a)}}function L(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r="https://clara.io/api/files";return pe[t.type]&&(r+="/image"),e.callApi((0,z.default)({types:[ie,ae,oe],method:"POST",url:r},t))}function D(e){return{type:se,payload:e}}Object.defineProperty(t,"__esModule",{value:!0}),t.NULL_SCENE_ID=void 0;var V,N=r(36),B=n(N),F=r(30),U=n(F),k=r(2),z=n(k),j=r(127),G=n(j),H=r(18),W=n(H);t.hasFile=i,t.getFile=a,t.addFile=o,t.removeFile=s,t.urlsFor=u,t.isLoading=c,t.getImage=f,t.getOrFetchImage=h,t.fetchImage=p,t.fetchBinary=m,t.getOrFetchBinary=g,t.getOrFetchFont=v,t.getOrFetchIESProfile=y,t.getHash=x,t.getUrl=b,t.getImageUrl=w,t.fetchText=_,t.fetchTransit=M,t.find=S,t.filter=T,t.exportJSON=E,t.getActiveAssets=P,t.importImage=O,t.importFile=L,t.addRoot=D;var X=r(34),Y=r(61),q=n(Y),Z=r(47),J=n(Z),K=r(10),Q=r(4),$=r(64),ee=r(19),te=r(84),re="ADD_FILE",ne="REMOVE_FILE",ie="IMPORTING_FILE",ae="IMPORTED_FILE",oe="IMPORT_FILE_ERROR",se="ADD_ROOT",le=(0,X.Map)({fileRoots:["https://cdn.threehub.com/resources","https://clara.io/resources"],assets:(0,X.Map)()}),ue=(0,J.default)(le,(V={},(0,W.default)(V,re,function(e,t){var r=t.id;return e.setIn(["assets",r],(0,X.Map)(t))}),(0,W.default)(V,ne,function(e,t){return e.deleteIn(["assets",t])}),(0,W.default)(V,$.LOAD_SCENE,function(e,t){var r=t.assets;return e.set("assets",e.get("assets").merge(r))}),(0,W.default)(V,$.CLEAR_SCENE,function(e){return e.set("assets",(0,X.Map)())}),(0,W.default)(V,se,function(e,t){var r=e.get("fileRoots").slice();return r.unshift(t),e.set("fileRoots",r)}),V)),ce={},fe=1e5,de=4096,he=t.NULL_SCENE_ID="00000000-0000-0000-0000-000000000000",pe={"image/jpeg":!0,"image/png":!0,"application/pdf":!0,"image/svg+xml":!0},me={reducer:ue,actions:{addFile:o,removeFile:s,importImage:O,addRoot:D},selectors:{_getHash:x,getUrl:b,filter:T,find:S,getActiveAssets:P,exportJSON:E,fetchImage:p,fetchBinary:m}};t.default=me},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function i(){return(0,D.Map)({all:{},prev:{},allCommands:(0,D.List)(),tools:(0,D.List)(),activeCommand:null,removedCommands:(0,D.Map)()})}function a(e,t){var r=(0,L.default)({},H,e,{name:t});return!0===r.display&&(r.display={playerTools:!0}),r}function o(e,t){return{type:U,payload:{command:e,name:t}}}function s(e){return{type:k,payload:e}}function l(e,t){return{type:z,payload:{name:e,opts:t}}}function u(e){return{type:j,payload:{name:e}}}function c(e,t){return{type:G,payload:{name:e,opts:t}}}function f(e){return e.getIn(["commands","tools"])}function d(e,t){var r=e.getIn(["commands","all"]);return t?(0,C.default)(r).reduce(function(e,n){var i=r[n];return i.enabled&&i.display[t]&&(e[n]=i),e},{}):r}function h(e,t){return e.getIn(["commands","all"])[t]}function p(e,t){return!!t.active||!!t.isActive&&t.isActive(e)}function m(e,t){var r=e.getIn(["commands","all"])[t];return r&&p(e,r)}function g(e){var t=d(e),r={};return(0,P.default)(t).forEach(function(t){t.widget&&p(e,t)&&(r[t.name]=t)}),r}function v(e){return function(t){var r=f(t),n=d(t),i=n[e];i.activate?p(t,i)||(i.activate.call(i),t.dispatch(l(e,{active:!0}))):r.forEach(function(r){var i=n[r];i.active&&i.name!==e&&t.dispatch(l(i.name,{active:!1})),i.name===e&&t.dispatch(l(i.name,{active:!0}))})}}function y(e){return function(t){var r=d(t),n=r[e];n&&(n.active&&t.dispatch(l(n.name,{active:!1})),n.deactivate&&n.deactivate.call(n))}}function x(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r={},n=!0,i=!1,a=void 0;try{for(var o,s=(0,T.default)((0,C.default)(e.schema));!(n=(o=s.next()).done);n=!0){var l=o.value,u=e.schema[l];r[l]=void 0!==t[l]?t[l]:u.defaultValue}}catch(e){i=!0,a=e}finally{try{!n&&s.return&&s.return()}finally{if(i)throw a}}return r}function b(e,t){return function(r){var n=r.getIn(["commands","all"])[e];if(!n||!n.enabled)return void(n||console.warn("No such command '"+e+"'"));if(r.trackEvent("playerv2","Execute Command","Run "+e),n.execute)return n.schema&&(t=x(n,t)),n.execute(r,t);var i=p(r,n);return n.deactivate&&i?r.dispatch(y(e)):r.dispatch(v(e))}}function w(e,t){return function(r){e.forEach(function(e){r.dispatch(l(e,t))})}}function _(e){return function(t){e.forEach(function(e){t.dispatch(u(e))})}}Object.defineProperty(t,"__esModule",{value:!0}),t.MOUSE_CONTROLS=void 0;var M,S=r(13),T=n(S),E=r(113),P=n(E),A=r(7),C=n(A),I=r(18),R=n(I),O=r(2),L=n(O);t.addCommand=o,t.removeCommand=s,t.updateCommand=l,t.undoUpdateCommand=u,t.setCommandOptions=c,t.getTools=f,t.getCommands=d,t.getCommand=h,t.isCommandActive=m,t.getActiveCommandsWithWidgets=g,t.activateCommand=v,t.deactivateCommand=y,t.runCommand=b,t.updateCommands=w,t.undoUpdateCommands=_;var D=r(34),V=r(47),N=n(V),B=(r(8),r(111)),F=r(157),U=(n(F),t.MOUSE_CONTROLS=["orbit","pan","zoom","home","fullscreen","configurator"],"ADD_COMMAND"),k="REMOVE_COMMAND",z="UPDATE_COMMAND",j="UNDO_UPDATE_COMMAND",G="UPDATE_COMMAND_OPTIONS;",H={enabled:!0,display:{},options:{},isEnabled:function(e,t){return t.enabled},isVisible:function(e,t){return t.display},command:null,widget:null},W=(0,N.default)({},(M={},(0,R.default)(M,B.ActionTypes.INIT,function(e){return i()}),(0,R.default)(M,U,function(e,t){var r=t.command,n=t.name;if(e.getIn(["removedCommands",n]))return e;var i=e.get("all");i[n]=(0,L.default)(a(r,n),i[n]||{});var o=e.updateIn(["allCommands"],(0,D.List)(),function(e){return e.push(n)});return i[n].tool&&(o=o.updateIn(["tools"],(0,D.List)(),function(e){return e.push(n)})),o}),(0,R.default)(M,k,function(e,t){delete e.get("all")[t];var r=e.getIn(["tools"]).indexOf(t),n=e.getIn(["allCommands"]).indexOf(t),i=e;return r>=0&&(i=i.deleteIn(["tools",r])),n>=0&&(i=i.deleteIn(["allCommands",n])),i=i.setIn(["removedCommands",t],!0)}),(0,R.default)(M,z,function(e,t){var r=t.name,n=t.opts,i=e.get("all");i[r]||(i[r]=a(n,r));var o=i[r];return e.get("prev")[r]=(0,L.default)({},o),(0,L.default)(o,n),e}),(0,R.default)(M,G,function(e,t){var r=t.name,n=t.opts,i=e.get("all")[r];return e.get("prev")[r]=(0,L.default)({},i),i&&(0,L.default)(i.options,n),e}),(0,R.default)(M,j,function(e,t){var r=t.name,n=e.get("prev")[r];if(n){var i=e.get("all")[r];i&&(0,L.default)(i,n)}return e}),M)),X={reducer:W,actions:{activateCommand:v,addCommand:o,deactivateCommand:y,runCommand:b,setCommandOptions:c,updateCommand:l,undoUpdateCommand:u,updateCommands:w,removeCommand:s},selectors:{getTools:f}};t.default=X},function(e,t,r){"use strict";function n(e){throw new Error(e)}function i(e,t){e||n(t)}Object.defineProperty(t,"__esModule",{value:!0}),t.fail=n,t.argument=i,t.assert=i,t.default={fail:n,argument:i,assert:i}},function(e,t){e.exports=function(e){return"object"==typeof e?null!==e:"function"==typeof e}},function(e,t,r){var n=r(194)("wks"),i=r(146),a=r(32).Symbol,o="function"==typeof a;(e.exports=function(e){return n[e]||(n[e]=o&&a[e]||(o?a:i)("Symbol."+e))}).store=n},function(e,t,r){var n=r(15),i=r(315),a=r(126),o=Object.defineProperty;t.f=r(44)?Object.defineProperty:function(e,t,r){if(n(e),t=a(t,!0),n(r),i)try{return o(e,t,r)}catch(e){}if("get"in r||"set"in r)throw TypeError("Accessors not supported!");return"value"in r&&(e[t]=r.value),e}},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}t.__esModule=!0;var i=r(598),a=n(i),o=r(597),s=n(o),l="function"==typeof s.default&&"symbol"==typeof a.default?function(e){return typeof e}:function(e){return e&&"function"==typeof s.default&&e.constructor===s.default&&e!==s.default.prototype?"symbol":typeof e};t.default="function"==typeof s.default&&"symbol"===l(a.default)?function(e){return void 0===e?"undefined":l(e)}:function(e){return e&&"function"==typeof s.default&&e.constructor===s.default&&e!==s.default.prototype?"symbol":void 0===e?"undefined":l(e)}},function(e,t,r){e.exports={default:r(626),__esModule:!0}},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function i(e,t,r){for(var n=0;n0?i(n(e),9007199254740991):0}},function(e,t,r){!function(t,r){e.exports=r()}(0,function(){"use strict";function e(e,t){t&&(e.prototype=Object.create(t.prototype)),e.prototype.constructor=e}function t(e){return a(e)?e:C(e)}function r(e){return o(e)?e:I(e)}function n(e){return s(e)?e:R(e)}function i(e){return a(e)&&!l(e)?e:O(e)}function a(e){return!(!e||!e[lr])}function o(e){return!(!e||!e[ur])}function s(e){return!(!e||!e[cr])}function l(e){return o(e)||s(e)}function u(e){return!(!e||!e[fr])}function c(e){return e.value=!1,e}function f(e){e&&(e.value=!0)}function d(){}function h(e,t){t=t||0;for(var r=Math.max(0,e.length-t),n=new Array(r),i=0;i>>0;if(""+r!==t||4294967295===r)return NaN;t=r}return t<0?p(e)+t:t}function g(){return!0}function v(e,t,r){return(0===e||void 0!==r&&e<=-r)&&(void 0===t||void 0!==r&&t>=r)}function y(e,t){return b(e,t,0)}function x(e,t){return b(e,t,t)}function b(e,t,r){return void 0===e?r:e<0?Math.max(0,t+e):void 0===t?e:Math.min(t,e)}function w(e){this.next=e}function _(e,t,r,n){var i=0===e?t:1===e?r:[t,r];return n?n.value=i:n={value:i,done:!1},n}function M(){return{value:void 0,done:!0}}function S(e){return!!P(e)}function T(e){return e&&"function"==typeof e.next}function E(e){var t=P(e);return t&&t.call(e)}function P(e){var t=e&&(wr&&e[wr]||e[_r]);if("function"==typeof t)return t}function A(e){return e&&"number"==typeof e.length}function C(e){return null===e||void 0===e?F():a(e)?e.toSeq():z(e)}function I(e){return null===e||void 0===e?F().toKeyedSeq():a(e)?o(e)?e.toSeq():e.fromEntrySeq():U(e)}function R(e){return null===e||void 0===e?F():a(e)?o(e)?e.entrySeq():e.toIndexedSeq():k(e)}function O(e){return(null===e||void 0===e?F():a(e)?o(e)?e.entrySeq():e:k(e)).toSetSeq()}function L(e){this._array=e,this.size=e.length}function D(e){var t=Object.keys(e);this._object=e,this._keys=t,this.size=t.length}function V(e){this._iterable=e,this.size=e.length||e.size}function N(e){this._iterator=e,this._iteratorCache=[]}function B(e){return!(!e||!e[Sr])}function F(){return Tr||(Tr=new L([]))}function U(e){var t=Array.isArray(e)?new L(e).fromEntrySeq():T(e)?new N(e).fromEntrySeq():S(e)?new V(e).fromEntrySeq():"object"==typeof e?new D(e):void 0;if(!t)throw new TypeError("Expected Array or iterable object of [k, v] entries, or keyed object: "+e);return t}function k(e){var t=j(e);if(!t)throw new TypeError("Expected Array or iterable object of values: "+e);return t}function z(e){var t=j(e)||"object"==typeof e&&new D(e);if(!t)throw new TypeError("Expected Array or iterable object of values, or keyed object: "+e);return t}function j(e){return A(e)?new L(e):T(e)?new N(e):S(e)?new V(e):void 0}function G(e,t,r,n){var i=e._cache;if(i){for(var a=i.length-1,o=0;o<=a;o++){var s=i[r?a-o:o];if(!1===t(s[1],n?s[0]:o,e))return o+1}return o}return e.__iterateUncached(t,r)}function H(e,t,r,n){var i=e._cache;if(i){var a=i.length-1,o=0;return new w(function(){var e=i[r?a-o:o];return o++>a?M():_(t,n?e[0]:o-1,e[1])})}return e.__iteratorUncached(t,r)}function W(e,t){return t?X(t,e,"",{"":e}):Y(e)}function X(e,t,r,n){return Array.isArray(t)?e.call(n,r,R(t).map(function(r,n){return X(e,r,n,t)})):q(t)?e.call(n,r,I(t).map(function(r,n){return X(e,r,n,t)})):t}function Y(e){return Array.isArray(e)?R(e).map(Y).toList():q(e)?I(e).map(Y).toMap():e}function q(e){return e&&(e.constructor===Object||void 0===e.constructor)}function Z(e,t){if(e===t||e!==e&&t!==t)return!0;if(!e||!t)return!1;if("function"==typeof e.valueOf&&"function"==typeof t.valueOf){if(e=e.valueOf(),t=t.valueOf(),e===t||e!==e&&t!==t)return!0;if(!e||!t)return!1}return!("function"!=typeof e.equals||"function"!=typeof t.equals||!e.equals(t))}function J(e,t){if(e===t)return!0;if(!a(t)||void 0!==e.size&&void 0!==t.size&&e.size!==t.size||void 0!==e.__hash&&void 0!==t.__hash&&e.__hash!==t.__hash||o(e)!==o(t)||s(e)!==s(t)||u(e)!==u(t))return!1;if(0===e.size&&0===t.size)return!0;var r=!l(e);if(u(e)){var n=e.entries();return t.every(function(e,t){var i=n.next().value;return i&&Z(i[1],e)&&(r||Z(i[0],t))})&&n.next().done}var i=!1;if(void 0===e.size)if(void 0===t.size)"function"==typeof e.cacheResult&&e.cacheResult();else{i=!0;var c=e;e=t,t=c}var f=!0,d=t.__iterate(function(t,n){if(r?!e.has(t):i?!Z(t,e.get(n,mr)):!Z(e.get(n,mr),t))return f=!1,!1});return f&&e.size===d}function K(e,t){if(!(this instanceof K))return new K(e,t);if(this._value=e,this.size=void 0===t?1/0:Math.max(0,t),0===this.size){if(Er)return Er;Er=this}}function Q(e,t){if(!e)throw new Error(t)}function $(e,t,r){if(!(this instanceof $))return new $(e,t,r);if(Q(0!==r,"Cannot step a Range by 0"),e=e||0,void 0===t&&(t=1/0),r=void 0===r?1:Math.abs(r),t>>1&1073741824|3221225471&e}function ae(e){if(!1===e||null===e||void 0===e)return 0;if("function"==typeof e.valueOf&&(!1===(e=e.valueOf())||null===e||void 0===e))return 0;if(!0===e)return 1;var t=typeof e;if("number"===t){if(e!==e||e===1/0)return 0;var r=0|e;for(r!==e&&(r^=4294967295*e);e>4294967295;)e/=4294967295,r^=e;return ie(r)}if("string"===t)return e.length>Vr?oe(e):se(e);if("function"==typeof e.hashCode)return e.hashCode();if("object"===t)return le(e);if("function"==typeof e.toString)return se(e.toString());throw new Error("Value type "+t+" cannot be hashed.")}function oe(e){var t=Fr[e];return void 0===t&&(t=se(e),Br===Nr&&(Br=0,Fr={}),Br++,Fr[e]=t),t}function se(e){for(var t=0,r=0;r0)switch(e.nodeType){case 1:return e.uniqueID;case 9:return e.documentElement&&e.documentElement.uniqueID}}function ce(e){Q(e!==1/0,"Cannot perform this action with an infinite size.")}function fe(e){return null===e||void 0===e?_e():de(e)&&!u(e)?e:_e().withMutations(function(t){var n=r(e);ce(n.size),n.forEach(function(e,r){return t.set(r,e)})})}function de(e){return!(!e||!e[Ur])}function he(e,t){this.ownerID=e,this.entries=t}function pe(e,t,r){this.ownerID=e,this.bitmap=t,this.nodes=r}function me(e,t,r){this.ownerID=e,this.count=t,this.nodes=r}function ge(e,t,r){this.ownerID=e,this.keyHash=t,this.entries=r}function ve(e,t,r){this.ownerID=e,this.keyHash=t,this.entry=r}function ye(e,t,r){this._type=t,this._reverse=r,this._stack=e._root&&be(e._root)}function xe(e,t){return _(e,t[0],t[1])}function be(e,t){return{node:e,index:0,__prev:t}}function we(e,t,r,n){var i=Object.create(kr);return i.size=e,i._root=t,i.__ownerID=r,i.__hash=n,i.__altered=!1,i}function _e(){return zr||(zr=we(0))}function Me(e,t,r){var n,i;if(e._root){var a=c(gr),o=c(vr);if(n=Se(e._root,e.__ownerID,0,void 0,t,r,a,o),!o.value)return e;i=e.size+(a.value?r===mr?-1:1:0)}else{if(r===mr)return e;i=1,n=new he(e.__ownerID,[[t,r]])}return e.__ownerID?(e.size=i,e._root=n,e.__hash=void 0,e.__altered=!0,e):n?we(i,n):_e()}function Se(e,t,r,n,i,a,o,s){return e?e.update(t,r,n,i,a,o,s):a===mr?e:(f(s),f(o),new ve(t,n,[i,a]))}function Te(e){return e.constructor===ve||e.constructor===ge}function Ee(e,t,r,n,i){if(e.keyHash===n)return new ge(t,n,[e.entry,i]);var a,o=(0===r?e.keyHash:e.keyHash>>>r)&pr,s=(0===r?n:n>>>r)≺return new pe(t,1<>>=1)o[s]=1&r?t[a++]:void 0;return o[n]=i,new me(e,a+1,o)}function Ie(e,t,n){for(var i=[],o=0;o>1&1431655765,e=(858993459&e)+(e>>2&858993459),e=e+(e>>4)&252645135,e+=e>>8,127&(e+=e>>16)}function Ne(e,t,r,n){var i=n?e:h(e);return i[t]=r,i}function Be(e,t,r,n){var i=e.length+1;if(n&&t+1===i)return e[t]=r,e;for(var a=new Array(i),o=0,s=0;s0&&ia?0:a-r,u=o-r;return u>hr&&(u=hr),function(){if(i===u)return qr;var e=t?--u:i++;return n&&n[e]}}function i(e,n,i){var s,l=e&&e.array,u=i>a?0:a-i>>n,c=1+(o-i>>n);return c>hr&&(c=hr),function(){for(;;){if(s){var e=s();if(e!==qr)return e;s=null}if(u===c)return qr;var a=t?--c:u++;s=r(l&&l[a],n-dr,i+(a<=e.size||t<0)return e.withMutations(function(e){t<0?Ze(e,t).set(0,r):Ze(e,0,t+1).set(t,r)});t+=e._origin;var n=e._tail,i=e._root,a=c(vr);return t>=Ke(e._capacity)?n=Xe(n,e.__ownerID,0,t,r,a):i=Xe(i,e.__ownerID,e._level,t,r,a),a.value?e.__ownerID?(e._root=i,e._tail=n,e.__hash=void 0,e.__altered=!0,e):Ge(e._origin,e._capacity,e._level,i,n):e}function Xe(e,t,r,n,i,a){var o=n>>>r&pr,s=e&&o0){var u=e&&e.array[o],c=Xe(u,t,r-dr,n,i,a);return c===u?e:(l=Ye(e,t),l.array[o]=c,l)}return s&&e.array[o]===i?e:(f(a),l=Ye(e,t),void 0===i&&o===l.array.length-1?l.array.pop():l.array[o]=i,l)}function Ye(e,t){return t&&e&&t===e.ownerID?e:new ze(e?e.array.slice():[],t)}function qe(e,t){if(t>=Ke(e._capacity))return e._tail;if(t<1<0;)r=r.array[t>>>n&pr],n-=dr;return r}}function Ze(e,t,r){void 0!==t&&(t|=0),void 0!==r&&(r|=0);var n=e.__ownerID||new d,i=e._origin,a=e._capacity,o=i+t,s=void 0===r?a:r<0?a+r:i+r;if(o===i&&s===a)return e;if(o>=s)return e.clear();for(var l=e._level,u=e._root,c=0;o+c<0;)u=new ze(u&&u.array.length?[void 0,u]:[],n),l+=dr,c+=1<=1<f?new ze([],n):p;if(p&&h>f&&odr;v-=dr){var y=f>>>v≺g=g.array[y]=Ye(g.array[y],n)}g.array[f>>>dr&pr]=p}if(s=h)o-=h,s-=h,l=dr,u=null,m=m&&m.removeBefore(n,0,o);else if(o>i||h>>l≺if(x!==h>>>l&pr)break;x&&(c+=(1<i&&(u=u.removeBefore(n,l,o-c)),u&&ho&&(o=u.size),a(l)||(u=u.map(function(e){return W(e)})),i.push(u)}return o>e.size&&(e=e.setSize(o)),Le(e,t,i)}function Ke(e){return e>>dr<=hr&&o.size>=2*a.size?(i=o.filter(function(e,t){return void 0!==e&&s!==t}),n=i.toKeyedSeq().map(function(e){return e[0]}).flip().toMap(),e.__ownerID&&(n.__ownerID=i.__ownerID=e.__ownerID)):(n=a.remove(t),i=s===o.size-1?o.pop():o.set(s,void 0))}else if(l){if(r===o.get(s)[1])return e;n=a,i=o.set(s,[t,r])}else n=a.set(t,o.size),i=o.set(o.size,[t,r]);return e.__ownerID?(e.size=n.size,e._map=n,e._list=i,e.__hash=void 0,e):et(n,i)}function nt(e,t){this._iter=e,this._useKeys=t,this.size=e.size}function it(e){this._iter=e,this.size=e.size}function at(e){this._iter=e,this.size=e.size}function ot(e){this._iter=e,this.size=e.size}function st(e){var t=At(e);return t._iter=e,t.size=e.size,t.flip=function(){return e},t.reverse=function(){var t=e.reverse.apply(this);return t.flip=function(){return e.reverse()},t},t.has=function(t){return e.includes(t)},t.includes=function(t){return e.has(t)},t.cacheResult=Ct,t.__iterateUncached=function(t,r){var n=this;return e.__iterate(function(e,r){return!1!==t(r,e,n)},r)},t.__iteratorUncached=function(t,r){if(t===br){var n=e.__iterator(t,r);return new w(function(){var e=n.next();if(!e.done){var t=e.value[0];e.value[0]=e.value[1],e.value[1]=t}return e})}return e.__iterator(t===xr?yr:xr,r)},t}function lt(e,t,r){var n=At(e);return n.size=e.size,n.has=function(t){return e.has(t)},n.get=function(n,i){var a=e.get(n,mr);return a===mr?i:t.call(r,a,n,e)},n.__iterateUncached=function(n,i){var a=this;return e.__iterate(function(e,i,o){return!1!==n(t.call(r,e,i,o),i,a)},i)},n.__iteratorUncached=function(n,i){var a=e.__iterator(br,i);return new w(function(){var i=a.next();if(i.done)return i;var o=i.value,s=o[0];return _(n,s,t.call(r,o[1],s,e),i)})},n}function ut(e,t){var r=At(e);return r._iter=e,r.size=e.size,r.reverse=function(){return e},e.flip&&(r.flip=function(){var t=st(e);return t.reverse=function(){return e.flip()},t}),r.get=function(r,n){return e.get(t?r:-1-r,n)},r.has=function(r){return e.has(t?r:-1-r)},r.includes=function(t){return e.includes(t)},r.cacheResult=Ct,r.__iterate=function(t,r){var n=this;return e.__iterate(function(e,r){return t(e,r,n)},!r)},r.__iterator=function(t,r){return e.__iterator(t,!r)},r}function ct(e,t,r,n){var i=At(e);return n&&(i.has=function(n){var i=e.get(n,mr);return i!==mr&&!!t.call(r,i,n,e)},i.get=function(n,i){var a=e.get(n,mr);return a!==mr&&t.call(r,a,n,e)?a:i}),i.__iterateUncached=function(i,a){var o=this,s=0;return e.__iterate(function(e,a,l){if(t.call(r,e,a,l))return s++,i(e,n?a:s-1,o)},a),s},i.__iteratorUncached=function(i,a){var o=e.__iterator(br,a),s=0;return new w(function(){for(;;){var a=o.next();if(a.done)return a;var l=a.value,u=l[0],c=l[1];if(t.call(r,c,u,e))return _(i,n?u:s++,c,a)}})},i}function ft(e,t,r){var n=fe().asMutable();return e.__iterate(function(i,a){n.update(t.call(r,i,a,e),0,function(e){return e+1})}),n.asImmutable()}function dt(e,t,r){var n=o(e),i=(u(e)?Qe():fe()).asMutable();e.__iterate(function(a,o){i.update(t.call(r,a,o,e),function(e){return e=e||[],e.push(n?[o,a]:a),e})});var a=Pt(e);return i.map(function(t){return St(e,a(t))})}function ht(e,t,r,n){var i=e.size;if(void 0!==t&&(t|=0),void 0!==r&&(r===1/0?r=i:r|=0),v(t,r,i))return e;var a=y(t,i),o=x(r,i);if(a!==a||o!==o)return ht(e.toSeq().cacheResult(),t,r,n);var s,l=o-a;l===l&&(s=l<0?0:l);var u=At(e);return u.size=0===s?s:e.size&&s||void 0,!n&&B(e)&&s>=0&&(u.get=function(t,r){return t=m(this,t),t>=0&&ts)return M();var e=i.next();return n||t===xr?e:t===yr?_(t,l-1,void 0,e):_(t,l-1,e.value[1],e)})},u}function pt(e,t,r){var n=At(e);return n.__iterateUncached=function(n,i){var a=this;if(i)return this.cacheResult().__iterate(n,i);var o=0;return e.__iterate(function(e,i,s){return t.call(r,e,i,s)&&++o&&n(e,i,a)}),o},n.__iteratorUncached=function(n,i){var a=this;if(i)return this.cacheResult().__iterator(n,i);var o=e.__iterator(br,i),s=!0;return new w(function(){if(!s)return M();var e=o.next();if(e.done)return e;var i=e.value,l=i[0],u=i[1];return t.call(r,u,l,a)?n===br?e:_(n,l,u,e):(s=!1,M())})},n}function mt(e,t,r,n){var i=At(e);return i.__iterateUncached=function(i,a){var o=this;if(a)return this.cacheResult().__iterate(i,a);var s=!0,l=0;return e.__iterate(function(e,a,u){if(!s||!(s=t.call(r,e,a,u)))return l++,i(e,n?a:l-1,o)}),l},i.__iteratorUncached=function(i,a){var o=this;if(a)return this.cacheResult().__iterator(i,a);var s=e.__iterator(br,a),l=!0,u=0;return new w(function(){var e,a,c;do{if(e=s.next(),e.done)return n||i===xr?e:i===yr?_(i,u++,void 0,e):_(i,u++,e.value[1],e);var f=e.value;a=f[0],c=f[1],l&&(l=t.call(r,c,a,o))}while(l);return i===br?e:_(i,a,c,e)})},i}function gt(e,t){var n=o(e),i=[e].concat(t).map(function(e){return a(e)?n&&(e=r(e)):e=n?U(e):k(Array.isArray(e)?e:[e]),e}).filter(function(e){return 0!==e.size});if(0===i.length)return e;if(1===i.length){var l=i[0];if(l===e||n&&o(l)||s(e)&&s(l))return l}var u=new L(i);return n?u=u.toKeyedSeq():s(e)||(u=u.toSetSeq()),u=u.flatten(!0),u.size=i.reduce(function(e,t){if(void 0!==e){var r=t.size;if(void 0!==r)return e+r}},0),u}function vt(e,t,r){var n=At(e);return n.__iterateUncached=function(n,i){function o(e,u){var c=this;e.__iterate(function(e,i){return(!t||u0}function Mt(e,r,n){var i=At(e);return i.size=new L(n).map(function(e){return e.size}).min(),i.__iterate=function(e,t){for(var r,n=this.__iterator(xr,t),i=0;!(r=n.next()).done&&!1!==e(r.value,i++,this););return i},i.__iteratorUncached=function(e,i){var a=n.map(function(e){return e=t(e),E(i?e.reverse():e)}),o=0,s=!1;return new w(function(){var t;return s||(t=a.map(function(e){return e.next()}),s=t.some(function(e){return e.done})),s?M():_(e,o++,r.apply(null,t.map(function(e){return e.value})))})},i}function St(e,t){return B(e)?t:e.constructor(t)}function Tt(e){if(e!==Object(e))throw new TypeError("Expected [K, V] tuple: "+e)}function Et(e){return ce(e.size),p(e)}function Pt(e){return o(e)?r:s(e)?n:i}function At(e){return Object.create((o(e)?I:s(e)?R:O).prototype)}function Ct(){return this._iter.cacheResult?(this._iter.cacheResult(),this.size=this._iter.size,this):C.prototype.cacheResult.call(this)}function It(e,t){return e>t?1:et?-1:0}function ir(e){if(e.size===1/0)return 0;var t=u(e),r=o(e),n=t?1:0;return ar(e.__iterate(r?t?function(e,t){n=31*n+or(ae(e),ae(t))|0}:function(e,t){n=n+or(ae(e),ae(t))|0}:t?function(e){n=31*n+ae(e)|0}:function(e){n=n+ae(e)|0}),n)}function ar(e,t){return t=Cr(t,3432918353),t=Cr(t<<15|t>>>-15,461845907),t=Cr(t<<13|t>>>-13,5),t=(t+3864292196|0)^e,t=Cr(t^t>>>16,2246822507),t=Cr(t^t>>>13,3266489909),t=ie(t^t>>>16)}function or(e,t){return e^t+2654435769+(e<<6)+(e>>2)|0}var sr=Array.prototype.slice;e(r,t),e(n,t),e(i,t),t.isIterable=a,t.isKeyed=o,t.isIndexed=s,t.isAssociative=l,t.isOrdered=u,t.Keyed=r,t.Indexed=n,t.Set=i;var lr="@@__IMMUTABLE_ITERABLE__@@",ur="@@__IMMUTABLE_KEYED__@@",cr="@@__IMMUTABLE_INDEXED__@@",fr="@@__IMMUTABLE_ORDERED__@@",dr=5,hr=1<n?M():_(e,i,r[t?n-i++:i++])})},e(D,I),D.prototype.get=function(e,t){return void 0===t||this.has(e)?this._object[e]:t},D.prototype.has=function(e){return this._object.hasOwnProperty(e)},D.prototype.__iterate=function(e,t){for(var r=this._object,n=this._keys,i=n.length-1,a=0;a<=i;a++){var o=n[t?i-a:a];if(!1===e(r[o],o,this))return a+1}return a},D.prototype.__iterator=function(e,t){var r=this._object,n=this._keys,i=n.length-1,a=0;return new w(function(){var o=n[t?i-a:a];return a++>i?M():_(e,o,r[o])})},D.prototype[fr]=!0,e(V,R),V.prototype.__iterateUncached=function(e,t){if(t)return this.cacheResult().__iterate(e,t);var r=this._iterable,n=E(r),i=0;if(T(n))for(var a;!(a=n.next()).done&&!1!==e(a.value,i++,this););return i},V.prototype.__iteratorUncached=function(e,t){if(t)return this.cacheResult().__iterator(e,t);var r=this._iterable,n=E(r);if(!T(n))return new w(M);var i=0;return new w(function(){var t=n.next();return t.done?t:_(e,i++,t.value)})},e(N,R),N.prototype.__iterateUncached=function(e,t){if(t)return this.cacheResult().__iterate(e,t);for(var r=this._iterator,n=this._iteratorCache,i=0;i=n.length){var t=r.next();if(t.done)return t;n[i]=t.value}return _(e,i,n[i++])})};var Tr;e(K,R),K.prototype.toString=function(){return 0===this.size?"Repeat []":"Repeat [ "+this._value+" "+this.size+" times ]"},K.prototype.get=function(e,t){return this.has(e)?this._value:t},K.prototype.includes=function(e){return Z(this._value,e)},K.prototype.slice=function(e,t){var r=this.size;return v(e,t,r)?this:new K(this._value,x(t,r)-y(e,r))},K.prototype.reverse=function(){return this},K.prototype.indexOf=function(e){return Z(this._value,e)?0:-1},K.prototype.lastIndexOf=function(e){return Z(this._value,e)?this.size:-1},K.prototype.__iterate=function(e,t){for(var r=0;r=0&&t=0&&rr?M():_(e,a++,o)})},$.prototype.equals=function(e){return e instanceof $?this._start===e._start&&this._end===e._end&&this._step===e._step:J(this,e)};var Pr;e(ee,t),e(te,ee),e(re,ee),e(ne,ee),ee.Keyed=te,ee.Indexed=re,ee.Set=ne;var Ar,Cr="function"==typeof Math.imul&&-2===Math.imul(4294967295,2)?Math.imul:function(e,t){e|=0,t|=0;var r=65535&e,n=65535&t;return r*n+((e>>>16)*n+r*(t>>>16)<<16>>>0)|0},Ir=Object.isExtensible,Rr=function(){try{return Object.defineProperty({},"@",{}),!0}catch(e){return!1}}(),Or="function"==typeof WeakMap;Or&&(Ar=new WeakMap);var Lr=0,Dr="__immutablehash__";"function"==typeof Symbol&&(Dr=Symbol(Dr));var Vr=16,Nr=255,Br=0,Fr={};e(fe,te),fe.of=function(){var e=sr.call(arguments,0);return _e().withMutations(function(t){for(var r=0;r=e.length)throw new Error("Missing value for key: "+e[r]);t.set(e[r],e[r+1])}})},fe.prototype.toString=function(){return this.__toString("Map {","}")},fe.prototype.get=function(e,t){return this._root?this._root.get(0,void 0,e,t):t},fe.prototype.set=function(e,t){return Me(this,e,t)},fe.prototype.setIn=function(e,t){return this.updateIn(e,mr,function(){return t})},fe.prototype.remove=function(e){return Me(this,e,mr)},fe.prototype.deleteIn=function(e){return this.updateIn(e,function(){return mr})},fe.prototype.update=function(e,t,r){return 1===arguments.length?e(this):this.updateIn([e],t,r)},fe.prototype.updateIn=function(e,t,r){r||(r=t,t=void 0);var n=De(this,Rt(e),t,r);return n===mr?void 0:n},fe.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._root=null,this.__hash=void 0,this.__altered=!0,this):_e()},fe.prototype.merge=function(){return Ie(this,void 0,arguments)},fe.prototype.mergeWith=function(e){return Ie(this,e,sr.call(arguments,1))},fe.prototype.mergeIn=function(e){var t=sr.call(arguments,1);return this.updateIn(e,_e(),function(e){return"function"==typeof e.merge?e.merge.apply(e,t):t[t.length-1]})},fe.prototype.mergeDeep=function(){return Ie(this,Re,arguments)},fe.prototype.mergeDeepWith=function(e){var t=sr.call(arguments,1);return Ie(this,Oe(e),t)},fe.prototype.mergeDeepIn=function(e){var t=sr.call(arguments,1);return this.updateIn(e,_e(),function(e){return"function"==typeof e.mergeDeep?e.mergeDeep.apply(e,t):t[t.length-1]})},fe.prototype.sort=function(e){return Qe(bt(this,e))},fe.prototype.sortBy=function(e,t){return Qe(bt(this,t,e))},fe.prototype.withMutations=function(e){var t=this.asMutable();return e(t),t.wasAltered()?t.__ensureOwner(this.__ownerID):this},fe.prototype.asMutable=function(){return this.__ownerID?this:this.__ensureOwner(new d)},fe.prototype.asImmutable=function(){return this.__ensureOwner()},fe.prototype.wasAltered=function(){return this.__altered},fe.prototype.__iterator=function(e,t){return new ye(this,e,t)},fe.prototype.__iterate=function(e,t){var r=this,n=0;return this._root&&this._root.iterate(function(t){return n++,e(t[1],t[0],r)},t),n},fe.prototype.__ensureOwner=function(e){return e===this.__ownerID?this:e?we(this.size,this._root,e,this.__hash):(this.__ownerID=e,this.__altered=!1,this)},fe.isMap=de;var Ur="@@__IMMUTABLE_MAP__@@",kr=fe.prototype;kr[Ur]=!0,kr.delete=kr.remove,kr.removeIn=kr.deleteIn,he.prototype.get=function(e,t,r,n){for(var i=this.entries,a=0,o=i.length;a=jr)return Pe(e,l,n,i);var p=e&&e===this.ownerID,m=p?l:h(l);return d?s?u===c-1?m.pop():m[u]=m.pop():m[u]=[n,i]:m.push([n,i]),p?(this.entries=m,this):new he(e,m)}},pe.prototype.get=function(e,t,r,n){void 0===t&&(t=ae(r));var i=1<<((0===e?t:t>>>e)&pr),a=this.bitmap;return 0==(a&i)?n:this.nodes[Ve(a&i-1)].get(e+dr,t,r,n)},pe.prototype.update=function(e,t,r,n,i,a,o){void 0===r&&(r=ae(n));var s=(0===t?r:r>>>t)&pr,l=1<=Gr)return Ce(e,d,u,s,p);if(c&&!p&&2===d.length&&Te(d[1^f]))return d[1^f];if(c&&p&&1===d.length&&Te(p))return p;var m=e&&e===this.ownerID,g=c?p?u:u^l:u|l,v=c?p?Ne(d,f,p,m):Fe(d,f,m):Be(d,f,p,m);return m?(this.bitmap=g,this.nodes=v,this):new pe(e,g,v)},me.prototype.get=function(e,t,r,n){void 0===t&&(t=ae(r));var i=(0===e?t:t>>>e)&pr,a=this.nodes[i];return a?a.get(e+dr,t,r,n):n},me.prototype.update=function(e,t,r,n,i,a,o){void 0===r&&(r=ae(n));var s=(0===t?r:r>>>t)&pr,l=i===mr,u=this.nodes,c=u[s];if(l&&!c)return this;var f=Se(c,e,t+dr,r,n,i,a,o);if(f===c)return this;var d=this.count;if(c){if(!f&&--d=0&&e>>t≺if(n>=this.array.length)return new ze([],e);var i,a=0===n;if(t>0){var o=this.array[n];if((i=o&&o.removeBefore(e,t-dr,r))===o&&a)return this}if(a&&!i)return this;var s=Ye(this,e);if(!a)for(var l=0;l>>t≺if(n>=this.array.length)return this;var i;if(t>0){var a=this.array[n];if((i=a&&a.removeAfter(e,t-dr,r))===a&&n===this.array.length-1)return this}var o=Ye(this,e);return o.array.splice(n+1),i&&(o.array[n]=i),o};var Yr,qr={};e(Qe,fe),Qe.of=function(){return this(arguments)},Qe.prototype.toString=function(){return this.__toString("OrderedMap {","}")},Qe.prototype.get=function(e,t){var r=this._map.get(e);return void 0!==r?this._list.get(r)[1]:t},Qe.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._map.clear(),this._list.clear(),this):tt()},Qe.prototype.set=function(e,t){return rt(this,e,t)},Qe.prototype.remove=function(e){return rt(this,e,mr)},Qe.prototype.wasAltered=function(){return this._map.wasAltered()||this._list.wasAltered()},Qe.prototype.__iterate=function(e,t){var r=this;return this._list.__iterate(function(t){return t&&e(t[1],t[0],r)},t)},Qe.prototype.__iterator=function(e,t){return this._list.fromEntrySeq().__iterator(e,t)},Qe.prototype.__ensureOwner=function(e){if(e===this.__ownerID)return this;var t=this._map.__ensureOwner(e),r=this._list.__ensureOwner(e);return e?et(t,r,e,this.__hash):(this.__ownerID=e,this._map=t,this._list=r,this)},Qe.isOrderedMap=$e,Qe.prototype[fr]=!0,Qe.prototype.delete=Qe.prototype.remove;var Zr;e(nt,I),nt.prototype.get=function(e,t){return this._iter.get(e,t)},nt.prototype.has=function(e){return this._iter.has(e)},nt.prototype.valueSeq=function(){return this._iter.valueSeq()},nt.prototype.reverse=function(){var e=this,t=ut(this,!0);return this._useKeys||(t.valueSeq=function(){return e._iter.toSeq().reverse()}),t},nt.prototype.map=function(e,t){var r=this,n=lt(this,e,t);return this._useKeys||(n.valueSeq=function(){return r._iter.toSeq().map(e,t)}),n},nt.prototype.__iterate=function(e,t){var r,n=this;return this._iter.__iterate(this._useKeys?function(t,r){return e(t,r,n)}:(r=t?Et(this):0,function(i){return e(i,t?--r:r++,n)}),t)},nt.prototype.__iterator=function(e,t){if(this._useKeys)return this._iter.__iterator(e,t);var r=this._iter.__iterator(xr,t),n=t?Et(this):0;return new w(function(){var i=r.next();return i.done?i:_(e,t?--n:n++,i.value,i)})},nt.prototype[fr]=!0,e(it,R),it.prototype.includes=function(e){return this._iter.includes(e)},it.prototype.__iterate=function(e,t){var r=this,n=0;return this._iter.__iterate(function(t){return e(t,n++,r)},t)},it.prototype.__iterator=function(e,t){var r=this._iter.__iterator(xr,t),n=0;return new w(function(){var t=r.next();return t.done?t:_(e,n++,t.value,t)})},e(at,O),at.prototype.has=function(e){return this._iter.includes(e)},at.prototype.__iterate=function(e,t){var r=this;return this._iter.__iterate(function(t){return e(t,t,r)},t)},at.prototype.__iterator=function(e,t){var r=this._iter.__iterator(xr,t);return new w(function(){var t=r.next();return t.done?t:_(e,t.value,t.value,t)})},e(ot,I),ot.prototype.entrySeq=function(){return this._iter.toSeq()},ot.prototype.__iterate=function(e,t){var r=this;return this._iter.__iterate(function(t){if(t){Tt(t);var n=a(t);return e(n?t.get(1):t[1],n?t.get(0):t[0],r)}},t)},ot.prototype.__iterator=function(e,t){var r=this._iter.__iterator(xr,t);return new w(function(){for(;;){var t=r.next();if(t.done)return t;var n=t.value;if(n){Tt(n);var i=a(n);return _(e,i?n.get(0):n[0],i?n.get(1):n[1],t)}}})},it.prototype.cacheResult=nt.prototype.cacheResult=at.prototype.cacheResult=ot.prototype.cacheResult=Ct,e(Ot,te),Ot.prototype.toString=function(){return this.__toString(Dt(this)+" {","}")},Ot.prototype.has=function(e){return this._defaultValues.hasOwnProperty(e)},Ot.prototype.get=function(e,t){if(!this.has(e))return t;var r=this._defaultValues[e];return this._map?this._map.get(e,r):r},Ot.prototype.clear=function(){if(this.__ownerID)return this._map&&this._map.clear(),this;var e=this.constructor;return e._empty||(e._empty=Lt(this,_e()))},Ot.prototype.set=function(e,t){if(!this.has(e))throw new Error('Cannot set unknown key "'+e+'" on '+Dt(this));if(this._map&&!this._map.has(e)){if(t===this._defaultValues[e])return this}var r=this._map&&this._map.set(e,t);return this.__ownerID||r===this._map?this:Lt(this,r)},Ot.prototype.remove=function(e){if(!this.has(e))return this;var t=this._map&&this._map.remove(e);return this.__ownerID||t===this._map?this:Lt(this,t)},Ot.prototype.wasAltered=function(){return this._map.wasAltered()},Ot.prototype.__iterator=function(e,t){var n=this;return r(this._defaultValues).map(function(e,t){return n.get(t)}).__iterator(e,t)},Ot.prototype.__iterate=function(e,t){var n=this;return r(this._defaultValues).map(function(e,t){return n.get(t)}).__iterate(e,t)},Ot.prototype.__ensureOwner=function(e){if(e===this.__ownerID)return this;var t=this._map&&this._map.__ensureOwner(e);return e?Lt(this,t,e):(this.__ownerID=e,this._map=t,this)};var Jr=Ot.prototype;Jr.delete=Jr.remove,Jr.deleteIn=Jr.removeIn=kr.removeIn,Jr.merge=kr.merge,Jr.mergeWith=kr.mergeWith,Jr.mergeIn=kr.mergeIn,Jr.mergeDeep=kr.mergeDeep,Jr.mergeDeepWith=kr.mergeDeepWith,Jr.mergeDeepIn=kr.mergeDeepIn,Jr.setIn=kr.setIn,Jr.update=kr.update,Jr.updateIn=kr.updateIn,Jr.withMutations=kr.withMutations,Jr.asMutable=kr.asMutable,Jr.asImmutable=kr.asImmutable,e(Bt,ne),Bt.of=function(){return this(arguments)},Bt.fromKeys=function(e){return this(r(e).keySeq())},Bt.prototype.toString=function(){return this.__toString("Set {","}")},Bt.prototype.has=function(e){return this._map.has(e)},Bt.prototype.add=function(e){return Ut(this,this._map.set(e,!0))},Bt.prototype.remove=function(e){return Ut(this,this._map.remove(e))},Bt.prototype.clear=function(){return Ut(this,this._map.clear())},Bt.prototype.union=function(){var e=sr.call(arguments,0);return e=e.filter(function(e){return 0!==e.size}),0===e.length?this:0!==this.size||this.__ownerID||1!==e.length?this.withMutations(function(t){for(var r=0;r=0;r--)t={value:arguments[r],next:t};return this.__ownerID?(this.size=e,this._head=t,this.__hash=void 0,this.__altered=!0,this):qt(e,t)},Xt.prototype.pushAll=function(e){if(e=n(e),0===e.size)return this;ce(e.size);var t=this.size,r=this._head;return e.reverse().forEach(function(e){t++,r={value:e,next:r}}),this.__ownerID?(this.size=t,this._head=r,this.__hash=void 0,this.__altered=!0,this):qt(t,r)},Xt.prototype.pop=function(){return this.slice(1)},Xt.prototype.unshift=function(){return this.push.apply(this,arguments)},Xt.prototype.unshiftAll=function(e){return this.pushAll(e)},Xt.prototype.shift=function(){return this.pop.apply(this,arguments)},Xt.prototype.clear=function(){return 0===this.size?this:this.__ownerID?(this.size=0,this._head=void 0,this.__hash=void 0,this.__altered=!0,this):Zt()},Xt.prototype.slice=function(e,t){if(v(e,t,this.size))return this;var r=y(e,this.size);if(x(t,this.size)!==this.size)return re.prototype.slice.call(this,e,t);for(var n=this.size-r,i=this._head;r--;)i=i.next;return this.__ownerID?(this.size=n,this._head=i,this.__hash=void 0,this.__altered=!0,this):qt(n,i)},Xt.prototype.__ensureOwner=function(e){return e===this.__ownerID?this:e?qt(this.size,this._head,e,this.__hash):(this.__ownerID=e,this.__altered=!1,this)},Xt.prototype.__iterate=function(e,t){if(t)return this.reverse().__iterate(e);for(var r=0,n=this._head;n&&!1!==e(n.value,r++,this);)n=n.next;return r},Xt.prototype.__iterator=function(e,t){if(t)return this.reverse().__iterator(e);var r=0,n=this._head;return new w(function(){if(n){var t=n.value;return n=n.next,_(e,r++,t)}return M()})},Xt.isStack=Yt;var rn="@@__IMMUTABLE_STACK__@@",nn=Xt.prototype;nn[rn]=!0,nn.withMutations=kr.withMutations,nn.asMutable=kr.asMutable,nn.asImmutable=kr.asImmutable,nn.wasAltered=kr.wasAltered;var an;t.Iterator=w,Jt(t,{toArray:function(){ce(this.size);var e=new Array(this.size||0);return this.valueSeq().__iterate(function(t,r){e[r]=t}),e},toIndexedSeq:function(){return new it(this)},toJS:function(){return this.toSeq().map(function(e){return e&&"function"==typeof e.toJS?e.toJS():e}).__toJS()},toJSON:function(){return this.toSeq().map(function(e){return e&&"function"==typeof e.toJSON?e.toJSON():e}).__toJS()},toKeyedSeq:function(){return new nt(this,!0)},toMap:function(){return fe(this.toKeyedSeq())},toObject:function(){ce(this.size);var e={};return this.__iterate(function(t,r){e[r]=t}),e},toOrderedMap:function(){return Qe(this.toKeyedSeq())},toOrderedSet:function(){return jt(o(this)?this.valueSeq():this)},toSet:function(){return Bt(o(this)?this.valueSeq():this)},toSetSeq:function(){return new at(this)},toSeq:function(){return s(this)?this.toIndexedSeq():o(this)?this.toKeyedSeq():this.toSetSeq()},toStack:function(){return Xt(o(this)?this.valueSeq():this)},toList:function(){return Ue(o(this)?this.valueSeq():this)},toString:function(){return"[Iterable]"},__toString:function(e,t){return 0===this.size?e+t:e+" "+this.toSeq().map(this.__toStringMapper).join(", ")+" "+t},concat:function(){return St(this,gt(this,sr.call(arguments,0)))},includes:function(e){return this.some(function(t){return Z(t,e)})},entries:function(){return this.__iterator(br)},every:function(e,t){ce(this.size);var r=!0;return this.__iterate(function(n,i,a){if(!e.call(t,n,i,a))return r=!1,!1}),r},filter:function(e,t){return St(this,ct(this,e,t,!0))},find:function(e,t,r){var n=this.findEntry(e,t);return n?n[1]:r},forEach:function(e,t){return ce(this.size),this.__iterate(t?e.bind(t):e)},join:function(e){ce(this.size),e=void 0!==e?""+e:",";var t="",r=!0;return this.__iterate(function(n){r?r=!1:t+=e,t+=null!==n&&void 0!==n?n.toString():""}),t},keys:function(){return this.__iterator(yr)},map:function(e,t){return St(this,lt(this,e,t))},reduce:function(e,t,r){ce(this.size);var n,i;return arguments.length<2?i=!0:n=t,this.__iterate(function(t,a,o){i?(i=!1,n=t):n=e.call(r,n,t,a,o)}),n},reduceRight:function(e,t,r){var n=this.toKeyedSeq().reverse();return n.reduce.apply(n,arguments)},reverse:function(){return St(this,ut(this,!0))},slice:function(e,t){return St(this,ht(this,e,t,!0))},some:function(e,t){return!this.every($t(e),t)},sort:function(e){return St(this,bt(this,e))},values:function(){return this.__iterator(xr)},butLast:function(){return this.slice(0,-1)},isEmpty:function(){return void 0!==this.size?0===this.size:!this.some(function(){return!0})},count:function(e,t){return p(e?this.toSeq().filter(e,t):this)},countBy:function(e,t){return ft(this,e,t)},equals:function(e){return J(this,e)},entrySeq:function(){var e=this;if(e._cache)return new L(e._cache);var t=e.toSeq().map(Qt).toIndexedSeq();return t.fromEntrySeq=function(){return e.toSeq()},t},filterNot:function(e,t){return this.filter($t(e),t)},findEntry:function(e,t,r){var n=r;return this.__iterate(function(r,i,a){if(e.call(t,r,i,a))return n=[i,r],!1}),n},findKey:function(e,t){var r=this.findEntry(e,t);return r&&r[0]},findLast:function(e,t,r){return this.toKeyedSeq().reverse().find(e,t,r)},findLastEntry:function(e,t,r){return this.toKeyedSeq().reverse().findEntry(e,t,r)},findLastKey:function(e,t){return this.toKeyedSeq().reverse().findKey(e,t)},first:function(){return this.find(g)},flatMap:function(e,t){return St(this,yt(this,e,t))},flatten:function(e){return St(this,vt(this,e,!0))},fromEntrySeq:function(){return new ot(this)},get:function(e,t){return this.find(function(t,r){return Z(r,e)},void 0,t)},getIn:function(e,t){for(var r,n=this,i=Rt(e);!(r=i.next()).done;){var a=r.value;if((n=n&&n.get?n.get(a,mr):mr)===mr)return t}return n},groupBy:function(e,t){return dt(this,e,t)},has:function(e){return this.get(e,mr)!==mr},hasIn:function(e){return this.getIn(e,mr)!==mr},isSubset:function(e){return e="function"==typeof e.includes?e:t(e),this.every(function(t){return e.includes(t)})},isSuperset:function(e){return e="function"==typeof e.isSubset?e:t(e),e.isSubset(this)},keyOf:function(e){return this.findKey(function(t){return Z(t,e)})},keySeq:function(){return this.toSeq().map(Kt).toIndexedSeq()},last:function(){return this.toSeq().reverse().first()},lastKeyOf:function(e){return this.toKeyedSeq().reverse().keyOf(e)},max:function(e){return wt(this,e)},maxBy:function(e,t){return wt(this,t,e)},min:function(e){return wt(this,e?er(e):nr)},minBy:function(e,t){return wt(this,t?er(t):nr,e)},rest:function(){return this.slice(1)},skip:function(e){return this.slice(Math.max(0,e))},skipLast:function(e){return St(this,this.toSeq().reverse().skip(e).reverse())},skipWhile:function(e,t){return St(this,mt(this,e,t,!0))},skipUntil:function(e,t){return this.skipWhile($t(e),t)},sortBy:function(e,t){return St(this,bt(this,t,e))},take:function(e){return this.slice(0,Math.max(0,e))},takeLast:function(e){return St(this,this.toSeq().reverse().take(e).reverse())},takeWhile:function(e,t){return St(this,pt(this,e,t))},takeUntil:function(e,t){return this.takeWhile($t(e),t)},valueSeq:function(){return this.toIndexedSeq()},hashCode:function(){return this.__hash||(this.__hash=ir(this))}});var on=t.prototype;on[lr]=!0,on[Mr]=on.values,on.__toJS=on.toArray,on.__toStringMapper=tr,on.inspect=on.toSource=function(){return this.toString()},on.chain=on.flatMap,on.contains=on.includes,Jt(r,{flip:function(){return St(this,st(this))},mapEntries:function(e,t){var r=this,n=0;return St(this,this.toSeq().map(function(i,a){return e.call(t,[a,i],n++,r)}).fromEntrySeq())},mapKeys:function(e,t){var r=this;return St(this,this.toSeq().flip().map(function(n,i){return e.call(t,n,i,r)}).flip())}});var sn=r.prototype;return sn[ur]=!0,sn[Mr]=on.entries,sn.__toJS=on.toObject,sn.__toStringMapper=function(e,t){return JSON.stringify(t)+": "+tr(e)},Jt(n,{toKeyedSeq:function(){return new nt(this,!1)},filter:function(e,t){return St(this,ct(this,e,t,!1))},findIndex:function(e,t){var r=this.findEntry(e,t);return r?r[0]:-1},indexOf:function(e){var t=this.keyOf(e);return void 0===t?-1:t},lastIndexOf:function(e){var t=this.lastKeyOf(e);return void 0===t?-1:t},reverse:function(){return St(this,ut(this,!1))},slice:function(e,t){return St(this,ht(this,e,t,!1))},splice:function(e,t){var r=arguments.length;if(t=Math.max(0|t,0),0===r||2===r&&!t)return this;e=y(e,e<0?this.count():this.size);var n=this.slice(0,e);return St(this,1===r?n:n.concat(h(arguments,2),this.slice(e+t)))},findLastIndex:function(e,t){var r=this.findLastEntry(e,t);return r?r[0]:-1},first:function(){return this.get(0)},flatten:function(e){return St(this,vt(this,e,!1))},get:function(e,t){return e=m(this,e),e<0||this.size===1/0||void 0!==this.size&&e>this.size?t:this.find(function(t,r){return r===e},void 0,t)},has:function(e){return(e=m(this,e))>=0&&(void 0!==this.size?this.size===1/0||e1&&void 0!==arguments[1]?arguments[1]:{};return function(r){var n=new B.default(r,e,t);return r.dispatch({type:G,payload:n}),t.setActive&&r.dispatch({type:X,payload:n.id}),n}}function a(e){return{type:H,payload:e}}function o(e){var t=e instanceof B.default?e.id:e;return{type:X,payload:t}}function s(e){return{type:W,payload:e}}function l(e,t){var r=t||e.getIn(["selection","activeSelectionSetId"]);return e.getIn(["selection","selectionSets",r,"set"])}function u(e){return e.getIn(["selection","selectionSets"]).toArray().map(function(e){return e.get("set")})}function c(e){return function(t){var r=l(t);return r?r.set(e):t.dispatch(i(e,{setActive:!0}))}}function f(e,t){var r=l(e);return!!r&&r.includes(t)}function d(e){var t=l(e);return t?t.ids[t.ids.length-1]:void 0}function h(e){var t=l(e);return t?t.ids:[]}function p(){return function(e){var t=l(e);t&&t.clear()}}function m(e){return e.getIn(["selection","selectionUIs"]).toList().filter(function(e){return e.get("type")===Z.HIGHLIGHTER}).map(function(e){return e.get("ui")})}function g(e){return{type:"TOUCH_SELECTION_UI",payload:e}}function v(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(r){var n=m(r).first();if(e)return n||(t.thickness||(t.thickness=w(r)),t.color||(t.color=x(r)),n=new F.Highlighter(r,t),r.dispatch({type:Y,payload:{ui:n,type:Z.HIGHLIGHTER}})),n;n&&r.dispatch({type:q,payload:n.id})}}function y(e){return function(t){var r=m(t).first();return r&&r.setColor(e),t.dispatch({type:z,payload:e})}}function x(e){return e.getIn(["selection","highlightColor"])}function b(e){return function(t){e>5&&(e=5),e<=0&&(e=.1);var r=m(t).first();return r&&r.setThickness(e),{type:j,payload:e}}}function w(e){return e.getIn(["selection","highlightThickness"])}function _(e){return function(t){return t.getIn(["selection","selectionUIs"]).toList().filter(function(t){return t.get("type")===Z[e]}).map(function(e){return e.get("ui")})}}function M(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return function(t){var r=new F.Ghoster(t,e);return t.dispatch({type:Y,payload:{ui:r,type:Z.GHOSTER}}),r}}function S(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return function(t){var r=t.dispatch(i(e.selection)),n=new k.default(t,(0,C.default)({},e,{selection:r}));return t.dispatch({type:Y,payload:{ui:n,type:Z.SUBOBJECT_HIGHLIGHTER}}),n}}function T(e){return{type:q,payload:e}}function E(e){return{type:q,payload:e}}Object.defineProperty(t,"__esModule",{value:!0}),t.getGhosters=t.getSubObjectHighlighters=void 0;var P,A=r(2),C=n(A),I=r(18),R=n(I);t.createSelectionSet=i,t.removeSelectionSet=a,t.setActiveSelectionSet=o,t.touchSelectionSet=s,t.getActiveSelectionSet=l,t.getSelectionSets=u,t.selectNode=c,t.isSelected=f,t.lastSelectedNode=d,t.getSelectedNodes=h,t.deselectAll=p,t.getHighlighters=m,t.touchSelectionUI=g,t.setHighlighting=v,t.setHighlightColor=y,t.getHighlightColor=x,t.setHighlightThickness=b,t.getHighlightThickness=w,t.addGhoster=M,t.addSubObjectHighlighter=S,t.removeGhoster=T,t.removeSubObjectHighlighter=E;var O=r(34),L=r(47),D=n(L),V=r(64),N=r(376),B=n(N),F=r(377),U=r(378),k=n(U),z=(r(4),"SET_HIGHLIGHT_COLOR"),j="SET_HIGHLIGHT_THICKNESS",G="ADD_SELECTION_SET",H="REMOVE_SELECTION_SET",W="TOUCH_SELECTION_SET",X="MARK_ACTIVE_SELECTION_SET",Y="ADD_SELECTION_UI",q="REMOVE_SELECTION_UI",Z={GHOSTER:"GHOSTER",HIGHLIGHTER:"HIGHLIGHTER",SUBOBJECT_HIGHLIGHTER:"SUBOBJECT_HIGHLIGHTER"},J=(0,O.Map)({highlightColor:"#00ff00",highlightThickness:1,selectionUIs:(0,O.Map)(),selectionSets:(0,O.Map)(),activeSelectionSetId:null}),K=(0,D.default)(J,(P={},(0,R.default)(P,V.DELETE_NODE,function(e,t){var r=e.get("selectionSets").map(function(e){var r=e.get("set"),n=e;return r.includes(t)&&(r._remove(t),n=e.set("v",e.get("v")+1)),n});return e.set("selectionSets",r)}),(0,R.default)(P,V.CLEAR_SCENE,function(e){return e.set("activeSelectionSetId",null)}),(0,R.default)(P,z,function(e,t){return e.set("highlightColor",t)}),(0,R.default)(P,j,function(e,t){return e.set("highlightThickness",t)}),(0,R.default)(P,G,function(e,t){return e.setIn(["selectionSets",t.id],(0,O.Map)({set:t,v:0}))}),(0,R.default)(P,X,function(e,t){return e.set("activeSelectionSetId",t)}),(0,R.default)(P,H,function(e,t){var r=e.deleteIn(["selectionSets",t]);return t===e.get("activeSelectionSetId")&&(r=r.delete("activeSelectionSetId")),r}),(0,R.default)(P,W,function(e,t){var r=e.getIn(["selectionSets",t.id,"v"]);return e.setIn(["selectionSets",t.id,"v"],r+1)}),(0,R.default)(P,Y,function(e,t){var r=t.ui,n=t.type;return e.setIn(["selectionUIs",r.id],(0,O.Map)({ui:r,type:n,v:0}))}),(0,R.default)(P,q,function(e,t){return e.deleteIn(["selectionUIs",t])}),(0,R.default)(P,"TOUCH_SELECTION_UI",function(e,t){var r=e.getIn(["selectionUIs",t.id,"v"]);return e.setIn(["selectionUIs",t.id,"v"],r+1)}),P)),Q=(t.getSubObjectHighlighters=_(Z.SUBOBJECT_HIGHLIGHTER),t.getGhosters=_(Z.GHOSTER),{reducer:K,actions:{selectNode:c,deselectAll:p,setHighlighting:v,setHighlightColor:y,setHighlightThickness:b,createSelectionSet:i,setActiveSelectionSet:o,addGhoster:M,removeGhoster:T,addSubObjectHighlighter:S,removeSubObjectHighlighter:E},selectors:{isSelected:f,lastSelectedNode:d,getHighlightColor:x,getHighlightThickness:w,getSelectionSets:u,getActiveSelectionSet:l}});t.default=Q},function(e,t,r){"use strict";var n=r(788),i=n||{name:"unknown",version:"0"};if(i.isIE="ie"===i.name,i.isMobile=!1,i.isIOS=!1,i.isAndroid=!1,i.isAndroidTablet=!1,window.navigator){var a=window.navigator.userAgent;i.isIOS=/iPad|iPhone|iPod/.test(a),i.isAndroid=/Android/i.test(a);var o=/IEMobile|Windows Phone|Lumia/i.test(a),s=/CrOS/i.test(a),l=/Blackberry|webOS/i.test(a);i.isMobile=i.isIOS||i.isAndroid||o||s||l,i.isAndroidTablet=i.isAndroid&&/^(?!.*Mobile).*$/.test(a)}e.exports=i},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function i(e){for(var t=e.positions.faceRangeOffsets,r=e.positions.faceValueIndices,n=e.positions.values,i=e.positions.valueAdjacency,a=new Uint32Array(r.length),o=new v.default(f.Vector3,r.length),s=new f.Vector3,l=new f.Vector3,u=new f.Vector3,c=0;c-1)){var E=_[T],P=y.adjacentFacesOnVertex(_[T],b),A=[];A.push(E);for(var C=E,I=P[0],R=-1,O=0;O-1||Math.acos(F)>n)break;A.push(I);var U=y.adjacentFacesOnVertex(I,b);if(U.length<2)break;R=U[0]===C?U[1]:U[0],C=I,I=R}C=E,I=P[1],R=-1}for(var k=new f.Vector3,z=0;z0&&x++}}for(var G=new v.default(f.Vector3,u.length),H=0;H1&&void 0!==arguments[1])||arguments[1],r=new i.Vector3,n=new i.Quaternion,a=new i.Vector3;e.decompose(r,n,a);var o=(new i.Vector3).copy((new i.Euler).setFromQuaternion(n,"ZYX"));o.multiplyScalar(180/Math.PI);var s={translation:r,rotation:o};return t||(s.scale=a),s}Object.defineProperty(t,"__esModule",{value:!0}),t.default=n;var i=r(0)},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function i(e,t,r){var n=e.holeOffsets[r];return 0===n.length?e.loopRangeOffsets[r+1]:t+n[0]}function a(e,t){var r=e.min-t.min;return 0===r?e.max-t.max:r}function o(e,t){var r=e.max-t.max;return 0===r?e.min-t.min:r}function s(e,t,r,n){var i=1-n,a=i*i,o=2*i*n,s=n*n;return{x:a*e.x+o*t.x+s*r.x,y:a*e.y+o*t.y+s*r.y}}function l(e,t,r){for(var n=e.partition(),i=n[t],a=(0,w.default)(i.positions),o=new v.Vector3,s=[],l=0;ly!==t){var w=void 0===g?u.clone().setZ(0):g,_=c.clone().setZ(0);t?l.push({min:b,max:y,minVertex:_,maxVertex:w}):l.push({min:y,max:b,minVertex:w,maxVertex:_}),g=_}else g=void 0;f=u,u=c,c=f,y=b}}return l.sort(n?o:a),l}},{key:"getAttachVector",value:function(e,t,r,n){var i=this,a=new v.Vector3,o=i.createAxisInterval(r,!1,a,!1),s=e.createAxisInterval(r,!0,t,!0),l=Number.MAX_VALUE,u=0,c=s.length,f=!0,h=!1,p=void 0;try{for(var m,g=(0,d.default)(o);!(f=(m=g.next()).done);f=!0){for(var y=m.value;u2&&(k=l(k,U,i)),k}},{key:"mergeShapeSets",value:function(t,r){var n=1,i=0,a=0,o=!0,s=!1,l=void 0;try{for(var u,f=(0,d.default)(t);!(o=(u=f.next()).done);o=!0){var h=u.value;n+=h.loopRangeOffsets.length-1,i+=h.loopValueIndices.length,a+=h.positions.length}}catch(e){s=!0,l=e}finally{try{!o&&f.return&&f.return()}finally{if(s)throw l}}for(var p={loopRangeOffsets:new Uint32Array(n),loopValueIndices:new Uint32Array(i),positions:new x.default(v.Vector3,a),holeOffsets:[]},m=0,g=0,y=0,b=0,w=0,_=new v.Vector3,M=0;M>>1;e[s]0&&void 0!==arguments[0]?arguments[0]:"";if(!e.length)return[];for(var t=e.split(","),r=void 0,n=void 0,i=void 0,a=new l.default,s=0;s2&&void 0!==arguments[2]&&arguments[2];(0,s.default)(this,e),this.id=(0,h.default)(),this._store=t,this._type=y[i]||y.Vertex,this._nodeId=n,this._setIndices(a),this._touchNode()}return(0,u.default)(e,[{key:"getIndices",value:function(e){if(!e||e===this.type)return this._indices.slice();if(x[e]>x[this.type])return console.error("Can only convert indices to a smaller subobject type"),null;var t=this._store.get("sceneGraph").nodes[this.nodeId].type;if("PolyMesh"===t){var r=this._store.get("sceneGraph").evaluatedNodes[this.nodeId].PolyMesh.mesh;if(!r)return console.error("Attempting to convert subobject indices for PolyMesh that does not exist"),null;return new v.Selection(this._indices,b[this.type]).getIndices(r,b[e])}if("Shape"===t){var n=this._store.get("sceneGraph").evaluatedNodes[this.nodeId].Shape.shape;if(!n)return console.error("Attempting to convert subobject indices for Shape that does not exist"),null;var i=[],a={};if(this.type===y.Edge)for(var o=n.edgeVertexAdjacency,s=0;sr;)i[r]=t[r++];return i},Ce=function(e,t,r){z(e,t,{get:function(){return this._d[r]}})},Ie=function(e){var t,r,n,i,a,o,s=_(e),l=arguments.length,c=l>1?arguments[1]:void 0,f=void 0!==c,d=P(s);if(void 0!=d&&!M(d)){for(o=d.call(s),n=[],t=0;!(a=o.next()).done;t++)n.push(a.value);s=n}for(f&&l>2&&(c=u(c,arguments[2],2)),t=0,r=m(s.length),i=Ee(this,r);r>t;t++)i[t]=f?c(s[t],t):s[t];return i},Re=function(){for(var e=0,t=arguments.length,r=Ee(this,t);t>e;)r[e]=arguments[e++];return r},Oe=!!W&&a(function(){he.call(new W(1))}),Le=function(){return he.apply(Oe?fe.call(Te(this)):Te(this),arguments)},De={copyWithin:function(e,t){return F.call(Te(this),e,t,arguments.length>2?arguments[2]:void 0)},every:function(e){return Q(Te(this),e,arguments.length>1?arguments[1]:void 0)},fill:function(e){return B.apply(Te(this),arguments)},filter:function(e){return Pe(this,J(Te(this),e,arguments.length>1?arguments[1]:void 0))},find:function(e){return $(Te(this),e,arguments.length>1?arguments[1]:void 0)},findIndex:function(e){return ee(Te(this),e,arguments.length>1?arguments[1]:void 0)},forEach:function(e){Z(Te(this),e,arguments.length>1?arguments[1]:void 0)},indexOf:function(e){return re(Te(this),e,arguments.length>1?arguments[1]:void 0)},includes:function(e){return te(Te(this),e,arguments.length>1?arguments[1]:void 0)},join:function(e){return ue.apply(Te(this),arguments)},lastIndexOf:function(e){return oe.apply(Te(this),arguments)},map:function(e){return we(Te(this),e,arguments.length>1?arguments[1]:void 0)},reduce:function(e){return se.apply(Te(this),arguments)},reduceRight:function(e){return le.apply(Te(this),arguments)},reverse:function(){for(var e,t=this,r=Te(t).length,n=Math.floor(r/2),i=0;i1?arguments[1]:void 0)},sort:function(e){return ce.call(Te(this),e)},subarray:function(e,t){var r=Te(this),n=r.length,i=v(e,n);return new(O(r,r[ve]))(r.buffer,r.byteOffset+i*r.BYTES_PER_ELEMENT,m((void 0===t?n:v(t,n))-i))}},Ve=function(e,t){return Pe(this,fe.call(Te(this),e,t))},Ne=function(e){Te(this);var t=Se(arguments[1],1),r=this.length,n=_(e),i=m(n.length),a=0;if(i+t>r)throw G("Wrong length!");for(;a255?255:255&n),i.v[h](r*t+i.o,n,_e)},C=function(e,t){z(e,t,{get:function(){return P(this,t)},set:function(e){return A(this,t,e)},enumerable:!0})};x?(p=r(function(e,r,n,i){c(e,p,u,"_d");var a,o,s,l,f=0,h=0;if(w(r)){if(!(r instanceof Y||"ArrayBuffer"==(l=b(r))||"SharedArrayBuffer"==l))return xe in r?Ae(p,r):Ie.call(p,r);a=r,h=Se(n,t);var v=r.byteLength;if(void 0===i){if(v%t)throw G("Wrong length!");if((o=v-h)<0)throw G("Wrong length!")}else if((o=m(i)*t)+h>v)throw G("Wrong length!");s=o/t}else s=g(r),o=s*t,a=new Y(o);for(d(e,"_d",{b:a,o:h,l:o,e:s,v:new q(a)});f0,g=st.default.resolve();return i&&(g=g.then(function(){return t.dispatch(T(i,{id:d}))})),f&&(g=g.then(function(){return t.dispatch(Xe(f,{id:d}))})),p&&(g=g.then(function(){return t.dispatch(u({id:d,form:p,async:!0}))})),g.then(function(){return t.dispatch(ne({id:d}))}).then(function(){return t.dispatch(l({id:d,skipModels:r}))}).then(function(){if(c)return t.dispatch(E(c,{id:d}))}).then(function(){return m})}}function s(e,t){var r={nodeenter:{},nodeleave:{},nodeclick:{}};return t.forEach(function(t){var n=t.node,i=t.actions,a=t.type;(0,xt.filter)(e,n).forEach(function(t){e.dispatch((0,xt.set)({id:t,plug:"Properties",property:"interactive"},!0));var n=r[a][t]||[];r[a][t]=n.concat(i)})}),r}function l(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return function(t){var r=e.id||(0,St.getSceneId)(t),n=void 0!==e.skipModels?e.skipModels:t.getIn(["configuration","configurators",r,"skipModels"]),i=Y(t,{id:r}),a=s(t,i),o="configTool-"+r;if((0,Tt.getCommands)(t)[o])t.dispatch((0,Tt.updateCommand)(o,{options:{events:a}}));else{if(!i.length)return;t.dispatch((0,Tt.addCommand)({options:{events:a},tool:{nodeenter:function(e){var i=this.options.events.nodeenter[e];i&&t.dispatch(P(i,{},{id:r,skipModels:n}))},nodeleave:function(e){var i=this.options.events.nodeleave[e];i&&t.dispatch(P(i,{},{id:r,skipModels:n}))},click:function(e){var i=(0,_t.filterNodesFromPosition)(t,e),a=this.options.events.nodeclick[i[0]];a&&t.dispatch(P(a,{},{id:r,skipModels:n}))}}},o))}}}function u(e){return function(t){if(e.async)return t.dispatch(c(e));var r=e.id||(0,St.getSceneId)(t),n=pe(t,{id:r,all:!0}),i=e.form&&("object"===(0,ut.default)(e.form)?V(e.form,{attributes:G(t,{id:r})}):J(t,e.form,{id:r}));if(!i)return st.default.resolve(!1);i.meta&&"all"!==i.meta.displayAs&&(i.steps||[]).forEach(function(e){var n=e.formId;n&&t.dispatch(u({id:r,form:n}))});var a=i.fields.reduce(function(e,t){return void 0===n[t.attribute.name]&&void 0!==t.attribute.defaultValue&&(e[t.attribute.name]=t.attribute.defaultValue),e},{});return t.dispatch(E(a,{id:r})),t.dispatch(ne({id:r}))}}function c(e){return function(t){var r=e.id||(0,St.getSceneId)(t),n=pe(t,{id:r,all:!0}),i=e.form&&("object"===(0,ut.default)(e.form)?V(e.form,{attributes:G(t,{id:r})}):J(t,e.form,{id:r}));if(!i)return st.default.resolve(!1);var a=st.default.resolve();return i.meta&&"all"!==i.meta.displayAs&&(i.steps||[]).forEach(function(e){var n=e.formId;n&&(a=a.then(function(){return t.dispatch(c({id:r,form:n}))}))}),a.then(function(){var e=i.fields.reduce(function(e,t){return void 0===n[t.attribute.name]&&void 0!==t.attribute.defaultValue&&(e[t.attribute.name]=t.attribute.defaultValue),e},{});return t.dispatch(ne({id:r})).then(function(){return t.dispatch(E(e,{id:r}))})})}}function f(e,t,r,n){var i=[];if("string"==typeof t)i=(0,xt.filter)(e,(0,Et.buildQueryObject)(t,{from:r,skipModels:n}));else if(Array.isArray(t)){var a=t.map(function(t){return""===t?[]:(0,Et.isUuid)(t)?[(0,xt.find)(e,{id:t})]:(0,xt.filter)(e,(0,Et.buildQueryObject)(t,{from:r,skipModels:n}))});a.forEach(function(e){return i=i.concat(e)})}return i=i.filter(function(e){return!!e})}function d(e,t){var r=e.tags,n=e.value,i=t.id,a=t.skipModels;return function(e){var t=f(e,r,i,a);return st.default.all(t.map(function(t){return e.dispatch((0,xt.set)({id:t,plug:"Properties",property:"visible",skipModels:a},Boolean(n)))}))}}function h(e,t){var r=e.tags,n=e.value,i=t.id;return function(e){var t=(0,Et.isUuid)(r)?(0,xt.find)(e,{id:r}):(0,xt.find)(e,{from:i,name:r,type:"Annotation"});return t?e.dispatch(n?(0,wt.openAnnotation)(t):(0,wt.closeAnnotation)(t)):st.default.resolve(!0)}}function p(e,t){var r=e.tags,n=e.value,i=void 0===n?500:n,a=t.id;return function(e){var t=(0,Et.isUuid)(r)?(0,xt.find)(e,{id:r}):(0,xt.find)(e,{from:a,name:r,type:"Camera"});return t?e.dispatch((0,_t.animateCameraTo)(t,Number(i))):st.default.resolve(!0)}}function m(e,t){var r=e.tags,n=e.value,i=t.id,a=t.skipModels;return function(e){var t=(0,Et.isUuid)(n)?n:(0,xt.find)(e,{from:i,type:"Material",name:n});if(!t)return st.default.resolve(!0);var o=f(e,r,i,a);return st.default.all(o.map(function(r){return e.dispatch((0,xt.set)({id:r,plug:"Material",property:"reference"},t))}))}}function g(e,t){var r=e.tags;t.id;return function(e){var t=(0,Mt.getClips)(e),n=(Array.isArray(r)?r:[r]).map(function(e){return t.find(function(t){return t.name===e})}).filter(function(e){return!!e});return st.default.all(n.map(function(t){return e.dispatch((0,Mt.queueClip)(t.id,{autoplay:!0}))}))}}function v(e,t){var r=e.tags,n=e.value,i=t.id,a=t.skipModels;return function(e){if(r&&3===r.split("[").length){var t=(0,Et.buildQueryObject)(r,{from:i,skipModels:a});e.dispatch((0,xt.setAll)(t,n))}}}function y(e,t){var r=e.tags,n=e.value;return E((0,ft.default)({},r,n),t)}function x(e,t){var r=e.tags,n=(e.value,t.id);t.skipModels;return function(e){var t=H(e,r,{id:n});if(t&&("Options"===t.type||"Boolean"===t.type)){var i=pe(e,{id:n,all:!0})[t.name];if("Boolean"===t.type)return e.dispatch(E((0,ft.default)({},t.name,!i)));var a=t.values.indexOf(i),o=(a+1)%t.values.length;return e.dispatch(E((0,ft.default)({},t.name,t.values[o])))}}}function b(e,t){var r=e.tags,n=e.value;return Re({hidden:(0,ft.default)({},r,!n)},t)}function w(e,t){var r=e.tags,n=e.value;return function(e){var i=H(e,r,t);if("object"!==(void 0===n?"undefined":(0,ut.default)(n))||!i)return st.default.resolve(!0);var a=pe(e,{all:!0})[i.name],o=st.default.resolve();if(a&&!n[a]){var s=i.values.find(function(e){return n[e]});s&&(o=e.dispatch(E((0,ft.default)({},r,s))))}return o.then(function(){return e.dispatch(Re({optionsVisible:(0,ft.default)({},r,n)}))})}}function _(e,t){var r=e.tags,n=e.value;return function(e){if(r[0]&&r[1]&&n){var t=(0,Et.isUuid)(n)?n:(0,xt.find)(e,{name:n}),i=(0,Et.isUuid)(r[0])?r[0]:(0,xt.find)(e,{name:r[0]}),a=(0,Et.isUuid)(r[1])?r[1]:(0,xt.find)(e,{name:r[1]});return e.dispatch((0,xt.attachModel)(t,i,a,!!r[2]))}}}function M(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return function(n){var i=H(n,e,r);return i?n.dispatch(Re({hidden:(0,ft.default)({},i.id,!t)},r)):st.default.resolve(!1)}}function S(e,t,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},i=(0,ht.default)({},n,{all:!0}),a=void 0==r?pe(e,i)[t.name]:r;if("Image"===t.type){if(!a||!a.id)return a;var o=(0,bt.hasFile)(e,a.assetId);return o||(0,St.isAssetLoading)(e,a.assetId)||e.dispatch((0,bt.importImage)(a.assetId,{imageNodeId:a.id})).then(function(n){e.dispatch(E((0,ft.default)({},t.name,r)))}),o?a.id:null}return t.prop.set(a)}function T(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(r){var n=ee(r,e,t);G(r,t);if(!n)return st.default.resolve(!1);var i=n.fields.reduce(function(e,n){return e[H(r,n.attributeId,t).name]=n.value,e},{});return r.dispatch(E(i,t))}}function E(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(r){var n=t.id||(0,St.getSceneId)(r),a=G(r,{id:n}),o=K(r),s=!o||o.skipModels,l=t.form,u=r.getIn(["configuration","changeListeners"]);return st.default.all((0,at.default)(e).map(function(t){var o=a.find(i(t));if(!o)return st.default.reject(new Error("Attribute: "+t+" does not exist"));var u=S(r,o,e[t],{id:n}),c=l&&l.fields.find(function(e){return e.attributeId===o.id});r.dispatch({type:Bt,payload:{id:n,attribute:o,value:"Image"===o.type?e[t]:u}}),r.createEvent("configurationChange",o,u,{field:c,id:n});var f=(o.actions||[]).concat(o.valueActions&&o.valueActions[u]||[]);return r.dispatch(P(f,o,{id:n,skipModels:s})).then(function(){return{attribute:o,value:u,field:c}})})).then(function(e){return e.reduce(function(e,t){var r=t.attribute,i=t.value,a=t.field;return e.then(function(){return st.default.all(u.map(function(e){return e(r,i,{field:a,id:n})}))})},st.default.resolve())})}}function P(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return function(n){var i=r.id||(0,St.getSceneId)(n),a=r.skipModels;return st.default.all(e.map(function(e){var r=e.action,o=e.tags,s=e.value,l=e.variable,u=l&&(t.id===t?t:H(n,l,{id:i})),c=u?S(n,u,null,{id:i}):s,f=rr[r];return f&&""!==o&&n.dispatch(f({tags:o,value:c},{id:i,skipModels:a}))}))}}function A(e){return{type:Gt,payload:e}}function C(e){return e.getIn(["configuration","configsState"]).toJS()}function I(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return E((0,ft.default)({},e,t),r)}function R(e,t){return console.log("DEPRECATED, use `executeAttribute`"),E((0,ft.default)({},e,t))}function O(e){return{Number:0,Boolean:!1,Color:{a:1,b:0,g:0,r:0}}[e]}function L(e){var t=("Option"===e.type?"Options":e.type)||"Options",r={id:e.id||(0,mt.default)(),name:e.name,type:t},n="";"Options"===t?(r.values=(e.values||[]).map(function(e){return e.name}),n=r.values[0],r.valueActions={},(e.values||[]).forEach(function(e){r.valueActions[e.name]=e.actions||[]})):"Boolean"===t&&(r.values=[!0,!1],r.valueActions=e.valueActions||{true:[],false:[]}),n=n||O(t),r.defaultValue=void 0===e.value?n:e.value,r.actions=e.actions||[];var i=Ct.default[t];if(!i)throw new Error("Invalid attribute type for configuration: "+t);return r.prop=i(r),r}function D(e){var t=e.type,r={id:e.id||(0,mt.default)(),name:e.name,type:t,metadata:e.metadata},n="";"Options"===t?(r.values=e.values||[],n=r.values[0],r.valueActions=e.valueActions||{},(e.values||[]).forEach(function(e){r.valueActions[e.name]=e.actions||[]})):"Boolean"===t?(r.values=[!0,!1],r.valueActions=e.valueActions||{true:[],false:[]}):"Number"===t&&(r.minValue=e.minValue||0,r.maxValue=e.maxValue||100,r.step=e.step||1),n=n||O(t),r.defaultValue=void 0===e.defaultValue?n:e.defaultValue,r.actions=e.actions||[];var i=Ct.default[t];if(!i)throw new Error("Invalid attribute type for configuration: "+t);return r.prop=i(r),r}function V(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=e.meta||{},n={id:e.id||(0,mt.default)(),name:e.name||"Form1",type:"Form",meta:{displayAs:r.displayAs||"all"}},a={title:"Step",description:"",formId:""};return n.steps=(e.steps||[]).map(function(t){return t.formId===e.id?a:{title:t.title||a.title,description:t.description||a.description,formId:t.formId||a.formId}}),n.fields=(e.fields||e.values||[]).map(function(e){var r=e.bom,n=e.displayAs,a=e.optionId,o=e.attributeId,s=e.metadata,l={bom:r,displayAs:n,attributeId:o,metadata:s};return a&&(l.attributeId=a),t.attributes&&(l.attribute=t.attributes.find(i(l.attributeId))),l}),n}function N(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return{id:e.id||(0,mt.default)(),name:e.name,type:e.type,node:e.node,actions:e.actions||[]}}function B(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.name,r=e.fields;return{id:e.id||(0,mt.default)(),name:t||"",fields:r||[]}}function F(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.title,r=e.handle,n=e.price,i=e.options,a=e.variants;return{title:t||r,handle:r,price:n||0,options:i||[],variants:a&&a.length?a:[{}]}}function U(){return{attributes:[],forms:[],presets:[],script:""}}function k(e){var t=e.id,r=e.config,n=e.sceneId;return function(e){return e.dispatch({type:qt,payload:{id:t,config:r,sceneId:n}})}}function z(e){e&&Array.isArray(e)&&(e={options:e}),e.options||e.attributes||(e=U());var t=function(e){return"Display"!==e.type&&"Preset"!==e.type&&"ProductTour"!==e.type},r=e.attributes?e.attributes.map(D):e.options.filter(t).map(L),n=(e.forms||e.options.filter(function(e){return"Display"===e.type})).map(V),i=e.presets||[],a=e.script||"",o=e.image||{},s=(e.events||[]).map(N);return(0,gt.Map)({attributes:r,events:s,forms:n,presets:i,script:a,image:o})}function j(e){return e.getIn(["configuration","configs"])}function G(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=t.id||(0,St.getSceneId)(e);return e.getIn(["configuration","configs",r,"attributes"])||[]}function H(e,t){return G(e,arguments.length>2&&void 0!==arguments[2]?arguments[2]:{}).find(i(t))}function W(e,t){return G(e,arguments.length>2&&void 0!==arguments[2]?arguments[2]:{}).filter(function(e){return e.type===t})}function X(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=t.id||(0,St.getSceneId)(e),n=e.getIn(["configuration","configs",r,"forms"])||[];if(t.all)return n;var i={};return n.forEach(function(e){"all"!==(e.meta||{}).displayAs&&e.steps&&e.steps.forEach(function(e){return i[e.formId]=!0})}),n.filter(function(e){return!i[e.id]})}function Y(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=t.id||(0,St.getSceneId)(e);return e.getIn(["configuration","configs",r,"events"])||[]}function q(e,t){return Y(e,arguments.length>2&&void 0!==arguments[2]?arguments[2]:{}).find(i(t))}function Z(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=t.id||(0,St.getSceneId)(e),n=e.getIn(["configuration","formState",r]);return n?n.toJS():{}}function J(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=r.id||(0,St.getSceneId)(e),a=t&&X(e,{id:n,all:!0}).find(i(t)),o=G(e,{id:n});return(a?a.fields:[]).forEach(function(e){e.attribute=o.find(i(e.attributeId))}),a||!0!==t||(a={id:(0,mt.default)(),name:"All",type:"Form",fields:o.map(function(e){return{name:e.name,attributeId:e.id,attribute:e}}),steps:[],meta:{displayAs:"all"}}),a&&(a.nodeId=n),a}function K(e,t){var r=t||(0,St.getSceneId)(e),n=e.getIn(["configuration","configurators",r]);return n&&n.toJS()}function Q(e){return(0,nt.default)(e.getIn(["configuration","configurators"]).toJS())}function $(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=t.id||(0,St.getSceneId)(e);return e.getIn(["configuration","configs",r,"presets"])||[]}function ee(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=r.id||(0,St.getSceneId)(e);return t&&$(e,{id:n}).find(i(t))}function te(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=t.id||(0,St.getSceneId)(e);return e.getIn(["configuration","configs",r,"script"])||""}function re(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=t.id||(0,St.getSceneId)(e);return e.getIn(["configuration","configsState",r,"scriptError"])}function ne(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return function(t){var r=e.id||(0,St.getSceneId)(t),n=te(t,{id:r});return n?t.dispatch(ae(n,{id:r})):st.default.resolve(!0)}}function ie(e,t){return e.getIn(["configuration","configsState",t,"scriptActivated"])}function ae(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(r){var n=t.id||(0,St.getSceneId)(r),i=t.reinitialize;if(ie(r,n)&&!i)return st.default.resolve(!0);r.dispatch(oe(n)),i&&(r.api.off("configurationChange"),r.dispatch({type:Qt}));try{var a=new Function("api",e||"");return st.default.resolve(a(r.api)).then(function(){return r.dispatch({type:Zt,payload:{id:n,scriptError:!1}})})}catch(e){return r.dispatch({type:Zt,payload:{id:n,scriptError:e}})}}}function oe(e){return{type:Jt,payload:e}}function se(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(r){var n=t.id||(0,St.getSceneId)(r);return r.dispatch({type:Nt,payload:{id:n,script:e,key:"script"}}),r.dispatch(ae(e,{id:n,reinitialize:!0})),st.default.resolve(e)}}function le(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=t.id||(0,St.getSceneId)(store);return{type:Nt,payload:{id:r,image:e,key:"image"}}}function ue(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=t.id||(0,St.getSceneId)(e);return e.getIn(["configuration","configs",r,"image"])||{}}function ce(e){var t=e.getIn(["configuration","productTour"]);if(!1===t)return!1;var r=t&&H(e,t);return r&&"Options"===r.type?r:null}function fe(e){return e.getIn(["configuration","products"]).toList().toArray()}function de(e,t){return e.getIn(["configuration","products",t])}function he(e){return e.getIn(["configuration","externalEl"])}function pe(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=t.id||(0,St.getSceneId)(e),n=e.getIn(["configuration","configuration",r]);if(t.all||!n)return n?n.toJS():{};var i=e.getIn(["configuration","formState",r,"hidden"])||{},a=(0,at.default)(i).reduce(function(r,n){var a=H(e,n,t);return i[n]&&a&&(r[a.name]=!0),r},{});return n.filter(function(e,t){return!a[t]}).toJS()}function me(e){var t=(0,St.getSceneId)(e),r=e.getIn(["configuration","configsState"]).toJS(),n=e.getIn(["configuration","configuration"]).toJS(),i={sceneId:t,publishedHash:(0,St.getFetchedHash)(e,t),configuration:n[t],models:[]};return(0,at.default)(n).forEach(function(a){if(a!==t){var o=r[a].sceneId,s=(0,xt.get)(e,{id:a,plug:"Transform",operatorIndex:0}),l=(0,It.lookupOperator)("Transform","Transform");i.models.push({sceneId:o,publishedHash:(0,St.getFetchedHash)(e,o),transform:l.export(s,{onlyChanged:!0}),configuration:n[a],models:[]})}}),i}function ge(e){return{type:Ft,payload:e}}function ve(e){return e.getIn(["configuration","history"]).size>0}function ye(){return{type:Ut}}function xe(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(r){var n=t.id||(0,St.getSceneId)(r),i=D(e);return r.dispatch({type:Dt,payload:{id:n,attrs:i,key:"attributes"}}),st.default.resolve(i.id)}}function be(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return function(n){var i=H(n,e,r),a=Ct.default[i.type];t.prop=a(t);var o=r.id||(0,St.getSceneId)(n);return n.dispatch({type:Nt,payload:{attrId:e,id:o,attrs:t,key:"attributes"}})}}function we(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(r){var n=t.id||(0,St.getSceneId)(r);return r.dispatch({type:Vt,payload:{id:n,attrId:e,key:"attributes"}})}}function _e(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(r){var n=t.id||(0,St.getSceneId)(r),i=V(e);return r.dispatch({type:Dt,payload:{id:n,attrs:i,key:"forms"}}),st.default.resolve(i.id)}}function Me(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(r){var n=t.id||(0,St.getSceneId)(r);return r.dispatch({type:Vt,payload:{id:n,attrId:e,key:"forms"}})}}function Se(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return function(n){var i=r.id||(0,St.getSceneId)(n);return n.dispatch({type:Nt,payload:{id:i,attrId:e,attrs:t,key:"forms"}})}}function Te(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(r){var n=t.id||(0,St.getSceneId)(r),i=N(e);return r.dispatch({type:Dt,payload:{id:n,attrs:i,key:"events"}}).then(function(){return r.dispatch(l({id:n})),i.id})}}function Ee(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(r){var n=t.id||(0,St.getSceneId)(r);return r.dispatch({type:Vt,payload:{id:n,attrId:e,key:"events"}}).then(function(e){return r.dispatch(l({id:n})),!0})}}function Pe(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return function(n){var i=r.id||(0,St.getSceneId)(n);return n.dispatch({type:Nt,payload:{id:i,attrId:e,attrs:t,key:"events"}}).then(function(e){var t=e.attrId;return n.dispatch(l({id:i})),t})}}function Ae(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(r){var n=t.id||(0,St.getSceneId)(r),i=B(e);return r.dispatch({type:Dt,payload:{id:n,attrs:i,key:"presets"}}),st.default.resolve(i.id)}}function Ce(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(r){var n=t.id||(0,St.getSceneId)(r);return r.dispatch({type:Vt,payload:{id:n,attrId:e,key:"presets"}})}}function Ie(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return function(n){var i=r.id||(0,St.getSceneId)(n);return n.dispatch({type:Nt,payload:{id:i,attrId:e,attrs:t,key:"presets"}})}}function Re(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(r){var n=t.id||(0,St.getSceneId)(r);return r.dispatch({type:Ht,payload:{attrs:e,id:n}})}}function Oe(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return e.handle?{type:Wt,payload:F(e)}:st.default.reject("Required product handle")}function Le(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return{type:Yt,payload:F(e)}}function De(e){return{type:Xt,payload:e}}function Ve(e){var t=e.getIn(["configuration","savingSceneId"]);if(!t)return!0;var r=e.getIn(["configuration","configs",t]),n=e.getIn(["configuration","savedConfig","config"]);return(0,gt.is)(r,n)}function Ne(e){return e.getIn(["configuration","saving"])}function Be(e){return!(Ne(e)||Ve(e)||Fe(e))&&e.getIn(["configuration","savingSceneId"])}function Fe(e){return e.getIn(["configuration","saveError"])}function Ue(e){var t=e.toJS();return delete t.scriptInitialized,delete t.scriptError,t.attributes=t.attributes.map(function(e){var t=(0,ht.default)({},e);return delete t.prop,t}),t.forms=t.forms.map(function(e){return e.fields=e.fields.map(function(e){return e.attribute=void 0,e}),e}),(0,tt.default)(t)}function ke(){var e=this;return function(t){var r=Be(t);if(r){var n=t.getIn(["configuration","configs",r]),i=Ue(n),a=t.getIn(["configuration","savedConfig","configStr"]);if(i!==a){var o=JSON.parse(i),s=t.getIn(["configuration","numSaveErrors"]);t.dispatch({type:kt}),setTimeout((0,$e.default)(Ke.default.mark(function a(){return Ke.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,t.callApi({types:[kt,zt,jt],url:"https://clara.io/api/scenes/"+r+"/configuration",method:"POST",payload:(0,gt.Map)({config:n,configStr:i}),successPayload:!0,body:{configuration:o,version:(0,St.getV1Version)(t,r)}});case 3:e.next=9;break;case 5:return e.prev=5,e.t0=e.catch(0),console.error("SAVE ERROR",e.t0),e.abrupt("return");case 9:t.dispatch((0,St.bumpV1Version)(r));case 10:case"end":return e.stop()}},a,e,[[0,5]])})),1e3*s*s)}}}}function ze(e,t){var r=e.find(function(e){return e.handle===t});return r||e.push(F({handle:t})),r||e[e.length-1]}function je(e,t){function r(e,r){var n=t[t.length-1];if(n&&n.handle===e.handle)return n;if(r)for(var i=t.length-1;i>=0;i--)if(t[i].handle===e.handle)return t[i];return t.push({handle:e.handle,quantity:1,options:[],product:e}),t[t.length-1]}function n(e,t){var n=t.findItem,i=r(e,n);return i.properties||(i.properties={}),i.variant||(i.variant=e.variants[0]),i.options||(i.options=[]),i}return{"set-product":function(r){var n=r.tags;if(n){var i=r.value,a=ze(e,n);t.push({handle:n,quantity:i,variant:a.variants[0],product:a,properties:{}})}},"select-variant":function(t,r,i){var a=t.tags;if(a){var o=!1;"object"===(0,ut.default)(t.value)&&(o=t.value.findItem);var s=ze(e,a),l=n(s,{findItem:o}),u=s.options.findIndex(function(e){return e.name===r.name});u>=0&&(l.options[u]=i);var c=s.variants.find(function(e){for(var t=!0,r=0;r1&&void 0!==arguments[1]?arguments[1]:{},r=(t.id||(0,St.getSceneId)(e),Q(e)),n=fe(e),i=r.reduce(function(t,r){var n=r.id;return t[n]=Ge(e,{id:n}),t},{}),a={products:n,items:[]},o=je(n,a.items);r.forEach(function(t){var r=t.id,n=pe(e,{id:r,all:!0});i[r].forEach(function(e){var t=e.attribute,r=t.name,i=n[r];(t.actions||[]).concat(t.valueActions&&t.valueActions[i]||[]).forEach(function(e){o[e.action]&&o[e.action](e,t,i)});var s=a.items[a.items.length-1];s&&("skip-display"===s.properties[r]?delete s.properties[r]:s.properties[r]=i)})}),a.price=He(a);var s=e.getIn(["configuration","bomChangeHandlers"]);return s.size&&r.forEach(function(t){var r=t.id,n=pe(e,{id:r,all:!0});s.forEach(function(e){return e(a,n)})}),a.items.forEach(function(e){e.handle!==e.product.handle&&(e.product=ze(a.products,e.handle),e.variant=e.product.variants[0])}),a}function Xe(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(r){var n=t.id||(0,St.getSceneId)(r),i=e.sceneId,o=e.publishedHash,s=e.models,l=e.configuration;if(n&&n!==i)throw new Error("Invalid base scene for configurations: "+i+", is "+n);return(n?st.default.resolve(!0):r.dispatch((0,St.fetchAndUse)(i,o))).then(function(){var e=s.reduce(function(e,t){var r=t.sceneId,n=t.publishedHash;return e[r]||(e[r]=n),e},{});return st.default.all((0,at.default)(e).map(function(t){return r.dispatch((0,St.fetch)(t,e[t]))})).then(function(){return r.dispatch(a({async:!0,configuration:l}))}).then(function(){return st.default.all(s.map(function(e){var t=e.sceneId,n=e.transform,i=e.configuration;return r.dispatch((0,xt.cloneModel)({sceneId:t})).then(function(e){var t={id:e,plug:"Transform",operatorIndex:0};return r.dispatch((0,xt.set)(t,n)),r.dispatch(a({async:!0,id:e,configuration:i}))})}))})})}}function Ye(e){return{type:Kt,payload:e}}function qe(e){return{type:$t,payload:e}}Object.defineProperty(t,"__esModule",{value:!0}),t.errors=void 0;var Ze,Je=r(346),Ke=n(Je),Qe=r(345),$e=n(Qe),et=r(36),tt=n(et),rt=r(113),nt=n(rt),it=r(7),at=n(it),ot=r(30),st=n(ot),lt=r(29),ut=n(lt),ct=r(18),ft=n(ct),dt=r(2),ht=n(dt);t.initConfigurator=a,t.initializeConfigCommand=l,t.initConfiguration=u,t.setAttributeVisibility=M,t.applyPreset=T,t.setConfiguration=E,t.removeConfigurator=A,t.getConfigurationState=C,t.executeAttribute=I,t.executeVariant=R,t.initializeAttribute=D,t.initializePreset=B,t.initializeConfiguration=k,t.initializeConfig=z,t.getConfigs=j,t.getAttributes=G,t.getAttribute=H,t.getAttributesByType=W,t.getForms=X,t.getEvents=Y,t.getEvent=q,t.getFormState=Z,t.getForm=J,t.getConfigurator=K,t.getConfigurators=Q,t.getPresets=$,t.getPreset=ee,t.getScript=te,t.getScriptError=re,t.setScript=se,t.publishToImage=le,t.getImageOptions=ue,t.getProductTour=ce,t.getProducts=fe,t.getProduct=de,t.getExternalEl=he,t.getConfiguration=pe,t.getConfigurations=me,t.setSavingSceneId=ge,t.canUndo=ve,t.undo=ye,t.addAttribute=xe,t.setAttribute=be,t.deleteAttribute=we,t.addForm=_e,t.deleteForm=Me,t.setForm=Se,t.addEvent=Te,t.deleteEvent=Ee,t.setEvent=Pe,t.addPreset=Ae,t.deletePreset=Ce,t.setPreset=Ie,t.setFormState=Re,t.addProduct=Oe,t.setProduct=Le,t.deleteProduct=De,t.isSaved=Ve,t.isSaving=Ne,t.shouldSave=Be,t.hasSaveError=Fe,t.save=ke,t.getBOM=We,t.loadConfigurations=Xe,t.onChange=Ye,t.modifyBOM=qe;var pt=r(61),mt=n(pt),gt=r(34),vt=r(47),yt=n(vt),xt=r(4),bt=r(23),wt=r(132),_t=r(8),Mt=r(72),St=r(19),Tt=r(24),Et=r(84),Pt=r(64),At=r(157),Ct=n(At),It=r(104),Rt=t.errors={VERSION_CONFLICT:"VERSION_CONFLICT",UNAUTHORIZED:"UNAUTHORIZED"},Ot=(0,gt.Map)({configuration:(0,gt.Map)(),configs:(0,gt.Map)(),configsState:(0,gt.Map)(),savingSceneId:null,history:(0,gt.List)(),savedConfig:(0,gt.Map)(),configurators:(0,gt.Map)(),formState:(0,gt.Map)(),productTour:null,products:(0,gt.Map)(),saving:!1,numSaveErrors:0,saveError:!1,changeListeners:(0,gt.List)(),bomChangeHandlers:(0,gt.List)()}),Lt=function(){return(0,gt.Map)({hidden:{},optionsVisible:{}})},Dt="ADD_CONFIG",Vt="DEL_CONFIG",Nt="SET_CONFIG",Bt="SET_CONFIGURATION",Ft="SET_SAVING_SCENE_ID",Ut="CONFIG_UNDO",kt="CONFIG_SAVING",zt="CONFIG_SAVED",jt="CONFIG_SAVE_ERROR",Gt="REMOVE_CONFIGURATOR",Ht="SET_CONFIGURATOR_FORM_STATE",Wt="ADD_PRODUCT",Xt="DEL_PRODUCT",Yt="SET_PRODUCT",qt="INITIALIZE_CONFIGURATION",Zt="SET_SCRIPT_ERROR",Jt="SET_SCRIPT_ACTIVATED",Kt="ADD_CHANGE_LISTENER",Qt="RESET_CHANGE_LISTENERS",$t="ADD_BOM_CHANGE_HANDLER",er=(0,gt.Map)({scriptError:"",scriptActivated:!1}),tr=(0,yt.default)(Ot,(Ze={},(0,ft.default)(Ze,Pt.INITIALIZE_SCENE,function(e,t){var r=t.id,n=t.store,i=(0,xt.get)(n,{id:r,plug:"Player",property:"configurator"}),a=void 0;try{a=JSON.parse(i)}catch(e){a=U()}a=z(a);var o=e.setIn(["configs",r],a).setIn(["configsState",r],er.set("sceneId",r));return r!==e.get("savingSceneId")&&e.get("savingSceneId")||(o=o.set("savedConfig",(0,gt.Map)({config:a,configStr:i}))),o}),(0,ft.default)(Ze,qt,function(e,t){var r=t.id,n=t.config,i=t.sceneId,a=n;try{"string"==typeof n&&(a=JSON.parse(n))}catch(e){a={}}var o=z(a);return e.setIn(["configs",r],o).setIn(["configsState",r],er.set("sceneId",i))}),(0,ft.default)(Ze,Zt,function(e,t){var r=t.id,n=t.scriptError;return e.setIn(["configsState",r,"scriptError"],n)}),(0,ft.default)(Ze,Bt,function(e,t){var r=t.id,n=t.attribute,i=t.value,a=e.getIn(["configuration",r])||(0,gt.Map)();return e.setIn(["configuration",r],a.set(n.name,i))}),(0,ft.default)(Ze,Pt.CLEAR_SCENE,function(e){return Ot}),(0,ft.default)(Ze,Dt,function(e,t){var r=t.id,n=t.key,i=t.attrs,a=e.getIn(["configs",r]),o=e.get("savingSceneId")!==r?e:e.set("history",e.get("history").push(a)),s=[].concat(a.get(n));return s.push(i),o.setIn(["configs",r],a.set(n,s))}),(0,ft.default)(Ze,Nt,function(e,t){var r=t.attrId,n=t.key,a=t.id,o=t.attrs,s=t.script,l=t.image,u=t.scriptError,c=e.getIn(["configs",a]),f=e.get("savingSceneId")!==a?e:e.set("history",e.get("history").push(c));if("script"===n)return f.setIn(["configs",a],c.set(n,s)).setIn(["configsState",a,"scriptError"],u||"");if("image"===n)return f.setIn(["configs",a],c.set(n,l));var d=[].concat(c.get(n)),h=d.findIndex(i(r));return d[h]=(0,ht.default)({},d[h],o),f.setIn(["configs",a],c.set(n,d))}),(0,ft.default)(Ze,Vt,function(e,t){var r=t.id,n=t.attrId,a=t.key,o=e.getIn(["configs",r]),s=e.get("savingSceneId")!==r?e:e.set("history",e.get("history").push(o)),l=[].concat(o.get(a)),u=l.findIndex(i(n));l.splice(u,1);var c=o.set(a,l);if("attributes"===a){c=c.set("forms",o.get("forms").map(function(e){var t=(0,ht.default)({},e);return t.fields=[].concat((e.fields||[]).filter(function(e){return e.attributeId!==n})),t}));var f=e.getIn(["formState",r]),d=(0,ht.default)({},f.get("hidden"));delete d[n];var h=f.set("hidden",d);s=s.setIn(["formState",r],h)}return s.setIn(["configs",r],c)}),(0,ft.default)(Ze,Ft,function(e,t){return e.set("savingSceneId",t).set("history",(0,gt.List)([]))}),(0,ft.default)(Ze,Ut,function(e){var t=e.get("savingSceneId"),r=e.get("history");return t&&0!==r.size?e.setIn(["configs",t],r.last()).set("history",r.butLast()):e}),(0,ft.default)(Ze,kt,function(e){return e.set("saving",!0)}),(0,ft.default)(Ze,jt,function(e,t,r){var n=r.action;return 400===n.error.status&&"VersionError"===n.error.body.error?e.set("saving",!1).set("saveError",Rt.VERSION_CONFLICT):403===n.error.status?e.set("saving",!1).set("saveError",Rt.UNAUTHORIZED):e.set("saving",!1).set("numSaveErrors",e.get("numSaveErrors")+1)}),(0,ft.default)(Ze,zt,function(e,t){return e.set("saving",!1).set("savedConfig",t).set("numSaveErrors",0)}),(0,ft.default)(Ze,"INIT_CONFIGURATOR",function(e,t){var r=t.id,n=t.productTour,i=e.getIn(["configurators",r])||(0,gt.Map)({id:r});["form","el","panel","skipModels"].forEach(function(e){void 0!==t[e]&&(i=i.set(e,t[e]))});var a=e.getIn(["formState",r])||Lt();return e.setIn(["configurators",r],i).set("productTour",n).setIn(["formState",r],a)}),(0,ft.default)(Ze,Gt,function(e,t){var r=e.getIn(["configurators",t,"el"]);return r&&(r.innerHTML=""),e.deleteIn(["configurators",t]).deleteIn(["configuration",t])}),(0,ft.default)(Ze,Ht,function(e,t){var r=t.attrs,n=t.id,i=e.getIn(["formState",n])||Lt(),a=r.hidden,o=r.optionsVisible;return e.setIn(["formState",n],(0,gt.Map)({hidden:(0,ht.default)({},i.get("hidden"),a),optionsVisible:(0,ht.default)({},i.get("optionsVisible"),o)}))}),(0,ft.default)(Ze,Wt,function(e,t){return e.setIn(["products",t.handle],t)}),(0,ft.default)(Ze,Yt,function(e,t){var r=e.getIn(["products",t.handle]);return e.setIn(["products",t.handle],(0,ht.default)({},r,t))}),(0,ft.default)(Ze,Xt,function(e,t){return e.deleteIn(["products",t])}),(0,ft.default)(Ze,Jt,function(e,t){return e.setIn(["configsState",t,"scriptActivated"],!0)}),(0,ft.default)(Ze,Kt,function(e,t){return e.updateIn(["changeListeners"],(0,gt.List)(),function(e){return e.push(t)})}),(0,ft.default)(Ze,Qt,function(e){return e.set("changeListeners",(0,gt.List)()).set("bomChangeHandlers",(0,gt.List)())}),(0,ft.default)(Ze,$t,function(e,t){return e.updateIn(["bomChangeHandlers"],(0,gt.List)(),function(e){return e.push(t)})}),Ze)),rr={"set-visibility":d,"annotation-visibility":h,"set-property":v,"assign-material":m,"move-camera":p,"play-clip":g,"set-variable":y,"set-form-field-visibility":b,"set-attribute-options-visibility":w,"toggle-attribute":x,"attach-model":_},nr={reducer:tr,actions:{applyPreset:T,executeAttribute:I,executeVariant:R,initConfiguration:u,initConfigurator:a,addProduct:Oe,setAttribute:be,setProduct:Le,deleteProduct:De,setConfiguration:E,setAttributeVisibility:M,loadConfigurations:Xe,removeConfigurator:A,onChange:Ye,modifyBOM:qe},selectors:{getConfigurationState:C,getAttribute:H,getAttributes:G,getAttributesByType:W,getForm:J,getForms:X,getConfiguration:pe,getBOM:We,getExternalEl:he,getPresets:$,getProduct:de,getProducts:fe,getProductTour:ce,getFormState:Z,getConfigurations:me},private:{actions:{addAttribute:xe,addForm:_e,deleteAttribute:we,deleteForm:Me,setForm:Se,setScript:se}}};t.default=nr},function(e,t,r){var n=r(188),i=r(185);e.exports=function(e){return n(i(e))}},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function i(e){return function(t){return t.id===e||t.name===e}}function a(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:(0,J.Map)();return(0,J.Map)({time:0,startTime:null,playing:!1,autoplay:!1,frameTime:0,animations:(0,J.List)(),clips:e,timelineAnimationIndex:-1,dynamicsWorld:null,dynamicBodies:{},kinematicBodies:{},bufferClips:(0,J.Map)()})}function o(e){return{type:ue,payload:e}}function s(e){return e.getIn(["animation","time"])}function l(e){return function(t){var r=new Date,n=e-t.getIn(["animation","time"]);if(t.getIn(["animation","animations"]).size){var i=0;t.getIn(["animation","animations"]).forEach(function(r,a){f(t,n,e,r,a-i)||i++})}else t.getIn(["animation","autoplay"])&&t.dispatch(g());var a=t.getIn(["animation","dynamicsWorld"]);a&&se.updatePhysics(t,n,e,a,t.getIn(["animation","dynamicBodies"]),t.getIn(["animation","kinematicBodies"])),t.dispatch({type:le,payload:{time:e,startTime:r}})}}function u(e,t,r,n){var i=t.vs,a=t.ts;if(!a.length)return n;var o=a.findIndex(function(t){return e<=t});return-1===o?i[i.length-1]:0===o?i[0]:r(e-a[o-1],i[o-1],i[o],a[o]-a[o-1])}function c(e,t,r,n){if(t.ts)return u(e,t,r,n);for(var i={},a=(0,G.default)(t),o=0;op;v?(h+=t*u(r-p,0,1,f),m=p+h):h&&(m=r-f+h);var y=d<0;1!==d&&(m=(m-p)*d+p,y&&(m+=l));for(var x=!1,b=[],w=(new Date,void 0),_=0;_S:mS?T:P(m-M,L,T,I),V=O(A,D);V&&b.push(V),(y?m>=M:m<=S)&&(x=!0)}}if(b.length&&e.dispatch((0,$.multi)(b)),x)v&&e.dispatch({type:he,payload:{index:i,attrs:{easingTime:h}}});else if(s>1)e.dispatch({type:he,payload:{index:i,attrs:{first:!1,easingTime:0,start:r,iterations:s-1}}});else{if(n.onEnd&&n.onEnd(),i!==e.getIn(["animation","timelineAnimationIndex"]))return null==n.animationTime&&e.dispatch({type:pe,payload:i}),!1;e.dispatch({type:he,payload:{index:i,attrs:{start:r}}}),e.dispatch(g())}return!0}function d(e){return e.getIn(["animation","playing"])}function h(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return function(t){t.dispatch({type:ce,payload:e.autoplay}),I({store:t}).then(function(){t.dispatch(l(t.getIn(["animation","time"])))})}}function p(){return function(e){if(e.getIn(["animation","playing"])){var t=e.getIn(["animation","startTime"]),r=e.getIn(["animation","time"]),n=t?new Date-t:0;e.dispatch(l(r+n))}}}function m(e){if(e.ts)return e.ts.length?e.ts[e.ts.length-1]:0;for(var t=0,r=void 0,n=(0,G.default)(e),i=0;i2&&void 0!==arguments[2]?arguments[2]:{};return function(n){var i=x(n,e,{immutable:!0});if(i)return n.dispatch(b((0,Y.default)({},i.toJS(),t))).then(function(e){return r.useTimeline&&n.dispatch({type:ge}),e})}}function x(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=e.getIn(["animation","bufferClips"]),i=e.getIn(["animation","clips"]),a=function(e){return e.get("name")===t},o=(0,ae.isUuid)(t)?n.get(t)||i.get(t):n.find(a)||i.find(a);return o&&(r.immutable?o:o.toJS())}function b(e){return function(t){var r=t.getIn(["animation","time"]),n=(0,Z.default)(),i=e.name||"Animation",a=e.iterations||1,o=e.start||r,s=e.easing||"linear",u=A(1,s),c=e.easingDuration||0,f=void 0!==e.playSpeed?e.playSpeed:1,p=e.tracks.map(function(e){return v(t,r,e)}).filter(function(e){return!!e}),m=p.reduce(function(e,t){return Math.max(e,t.end)},0),g=e.onEnd||null;return t.dispatch({type:me,payload:{id:n,name:i,start:o,easingTime:0,first:!0,easing:s,easingFn:u,easingDuration:c,iterations:a,tracks:p,onEnd:g,playSpeed:f,duration:m,animationTime:e.animationTime||null}}),e.autoplay&&!d(t)?t.dispatch(h({autoplay:!0})):t.dispatch(l(r)),z.default.resolve(n)}}function w(e,t){return function(r){var n=M(r,e);-1!==n&&(r.dispatch({type:he,payload:{index:n,attrs:t}}),r.dispatch(l(s(r))))}}function _(e,t){return e.getIn(["animation","animations"]).find(i(t))}function M(e,t){return e.getIn(["animation","animations"]).findIndex(i(t))}function S(e){return function(t){var r=M(t,e);if(-1!==r)return t.dispatch({type:pe,payload:r})}}function T(e,t){return{type:ve,payload:{clip:e,id:t}}}function E(e,t){return function(r){var n=e.tracks.map(function(e){var t={};if(e.keyframes){var r=e.keyframes;if(r.ts){t={ts:Float32Array.from(r.ts),vs:Float32Array.from(r.vs)}}else t=(0,G.default)(r).reduce(function(e,t){var n=Float32Array.from(r[t].ts),i=Float32Array.from(r[t].vs);return e[t]={ts:n,vs:i},e},{});return(0,Y.default)({},e,{keyframes:t})}return e}),i=(0,Y.default)({},e,{tracks:n});return r.dispatch({type:ye,payload:{clip:i,id:t}})}}function P(e){return(0,U.default)(e.getIn(["animation","clips"]).toJS())}function A(e,t){var r=te.default[t];if(!r)throw new Error("Unknown easing function: "+t);if("object"!==(void 0===e?"undefined":(0,B.default)(e)))return r;var n=(0,G.default)(e);return function(e,t,i,a){for(var o={},s=0;s0&&!t.getIn(["animation","dynamicsWorld"])?new z.default(function(e){r.e(3).then(function(i){se=r(809),t.dispatch({type:xe,payload:se.initPhysics(t,n)}),e()}.bind(null,r)).catch(r.oe)}):z.default.resolve()}function R(e){var t=void 0,r={start:function(r){if(!t){var n=(0,ie.get)(e,{scene:!0,evalPlug:"Player"}),i=n?1e3*n.autoRotateResumeTime:5e3;n&&n.autoRotate&&(t=setTimeout(function(){e.dispatch(L(n))},r||i))}},stop:function(){e.dispatch(D()),clearTimeout(t),t=null},mousedown:function(){return r.stop()},mouseup:function(){return r.start()}};return{enabled:!0,tool:r}}function O(){return function(e){var t=R(e);e.dispatch((0,oe.addCommand)(t,"autoRotate")),e.api.on("rendered",function(){t.tool.start(1e3)})}}function L(e){return function(t){var r=e||(0,ie.get)(t,{scene:!0,evalPlug:"Player"}),n=r&&r.autoRotateNode;if(!r||!n)return!1;var i="+"===r.autoRotateDirection?360:-360,a=(0,ie.find)(t,{id:n,plug:"Transform",property:"rotation"}),o=(0,ie.get)(t,{id:n,plug:"Transform",property:"rotation"}),s=-1!==M(t,"autoRotate");a&&o&&!s&&t.dispatch(b({name:"autoRotate",autoplay:!0,iterations:1/0,easingDuration:3e3,tracks:[{path:a,start:0,duration:1e3*r.autoRotateSpeed,value:{x:o.x,y:o.y+i,z:o.z}}]}))}}function D(){return S("autoRotate")}Object.defineProperty(t,"__esModule",{value:!0});var V,N=r(29),B=n(N),F=r(113),U=n(F),k=r(30),z=n(k),j=r(7),G=n(j),H=r(18),W=n(H),X=r(2),Y=n(X);t.setFrameTime=o,t.getTime=s,t.setTime=l,t.isPlaying=d,t.startPlaying=h,t.incrementTime=p,t.stopPlaying=g,t.queueClip=y,t.findClip=x,t.queueAnimation=b,t.updateAnimationAttrs=w,t.findAnimation=_,t.findAnimationIndex=M,t.removeAnimation=S,t.addClip=T,t.makeReducedClip=E,t.getClips=P,t.getTimelineAnimation=C,t.initPhysics=I,t.initializeAutoRotate=O,t.startAutoRotate=L,t.stopAutoRotate=D;var q=r(61),Z=n(q),J=r(34),K=r(47),Q=n(K),$=r(10),ee=r(385),te=n(ee),re=r(64),ne=r(111),ie=r(4),ae=r(84),oe=r(24),se=null,le="SET_TIME",ue="SET_FRAME_TIME",ce="START_PLAYING",fe="STOP_PLAYING",de="UPDATE_TRACK",he="UPDATE_ANIMATION",pe="REMOVE_ANIMATION",me="QUEUE_ANIMATION",ge="QUEUE_TIMELINE_ANIMATION",ve="ADD_CLIP",ye="ADD_BUFFER_CLIP",xe="INIT_PHYSICS",be=(0,Q.default)(a(),(V={},(0,W.default)(V,ne.ActionTypes.INIT,function(e){return a()}),(0,W.default)(V,le,function(e,t){var r=t.time,n=t.startTime;return e.set("time",r).set("startTime",n)}),(0,W.default)(V,ue,function(e,t){var r=e.get("frameTime");return e.set("frameTime",r+.1*(t-r))}),(0,W.default)(V,ce,function(e,t){return e.merge({playing:!0,autoplay:!!t})}),(0,W.default)(V,fe,function(e){return e.set("playing",!1)}),(0,W.default)(V,de,function(e,t){var r=t.path,n=t.attrs,i=e.getIn(["animations",r[0]]),a=i&&i.tracks[r[1]];return a&&(0,Y.default)(a,n),e}),(0,W.default)(V,he,function(e,t){var r=t.index,n=t.attrs,i=e.getIn(["animations",r]);return i&&(0,Y.default)(i,n),e}),(0,W.default)(V,pe,function(e,t){var r=e;return t===e.get("timelineAnimationIndex")&&(r=r.set("timelineAnimationIndex",-1)),r.deleteIn(["animations",t])}),(0,W.default)(V,me,function(e,t){return e.updateIn(["animations"],(0,J.List)(),function(e){return e.push(t)})}),(0,W.default)(V,ge,function(e,t){return e.set("timelineAnimationIndex",e.get("animations").size-1)}),(0,W.default)(V,ve,function(e,t){var r=t.clip,n=t.id;return e.setIn(["clips",n],(0,J.Map)(r).set("id",n))}),(0,W.default)(V,ye,function(e,t){var r=t.clip,n=t.id;return e.setIn(["bufferClips",n],(0,J.Map)(r).set("id",n))}),(0,W.default)(V,re.LOAD_SCENE,function(e,t){var r=t.clips,n=t.bufferClips;return r?e.mergeIn(["clips"],r).mergeIn(["bufferClips"],n):e}),(0,W.default)(V,re.CLEAR_SCENE,function(e){return a()}),(0,W.default)(V,xe,function(e,t){var r=t.dynamicsWorld,n=t.dynamicBodies,i=t.kinematicBodies;return e.set("dynamicsWorld",r).set("dynamicBodies",n).set("kinematicBodies",i)}),V)),we={reducer:be,actions:{setTime:l,startPlaying:h,stopPlaying:g,removeAnimation:S,queueAnimation:b,addClip:T,queueClip:y,updateAnimationAttrs:w,initializeAutoRotate:O,startAutoRotate:L,stopAutoRotate:D},selectors:{findAnimation:_,findClip:x,getTime:s,getClips:P,getTimelineAnimation:C,isPlaying:d}};t.default=we},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function i(e,t,r){c.default.call(this,t||Float32Array),this.elementSize=r||e.InstanceScalarSize,this.type=e}Object.defineProperty(t,"__esModule",{value:!0});var a=r(53),o=n(a),s=r(2),l=n(s);t.default=i;var u=r(251),c=n(u),f=r(3),d=n(f);i.prototype=(0,l.default)((0,o.default)(c.default.prototype),{constructor:i,toObjectArrayViewAndClear:function(){return new d.default(this.type,null,this.toArrayAndClear())},getAt:function(e,t){var r=t||new this.type,n=e>>this.intraBlockIndexBits,i=e&this.intraBlockIndexMask;return r.fromArray(this.blocks[n],i*this.elementSize)},setAt:function(e,t){var r=e>>this.intraBlockIndexBits,n=e&this.intraBlockIndexMask;t.toArray(this.blocks[r],n*this.elementSize)},push:function(e){var t=this.length++,r=this.lastBlock,n=t&this.intraBlockIndexMask;if(0===n){var i=this.intraBlockIndexMask+1;r=new this.arrayType(i*this.elementSize),this.lastBlock=r,this.blocks.push(r)}return e.toArray(r,n*this.elementSize),t+1}})},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function i(e,t,r){this.indices=e,this.meaning=t,this.mapId=r||l.default.IdPositions}Object.defineProperty(t,"__esModule",{value:!0}),t.default=i;var a=r(42),o=n(a),s=r(43),l=n(s),u=r(253),c=n(u),f=r(167),d=n(f),h=r(133),p=n(h);i.Faces=0,i.Vertices=1,i.Edges=2,i.prototype={constructor:i,getIndices:function(e,t,r){var n=this.indices,a=i.ConversionTable,o=a[this.meaning][t];return null!==o&&(n=o.call(null,e,n,this.mapId,r||l.default.IdPositions)),n}},i.newRandomSelection=function(e,t,r,n,a){for(var o=i.getNumElements(r,n,a),s=t*o|0,l=new d.default(o).fill(0,s),u=e,c=0,f=o-1;c>>0,l.swap(c,c+(1073741823&u)%(o-c));return new i(l.toIndexArray(),n,a)},i.getIndices=function(e,t,r,n){var a=l.default.IdPositions,o=n;return"string"==typeof r?a=r:o=r,o?o.getIndices(e,t,a):p.default.identityForReading(i.getNumElements(e,t,a))},i.getNumElements=function(e,t,r){switch(t){case i.Faces:return e.getNumFaces();case i.Vertices:return l.default.resolveMap(e,r||l.default.IdPositions).values.length;case i.Edges:return l.default.resolveMap(e,r||l.default.IdPositions).edgeVertexAdjacency.getNumEdges();default:throw Error("Bad meaning argument!")}},i.convFacesToVertices=function(e,t,r,n){for(var i=l.default.resolveMap(e,n),a=new d.default(i.values.length),o=e.faceRangeOffsets,s=i.faceValueIndices,u=0,c=t.length;u!==c;++u){var f=t[u],h=o[f],p=o[f+1];a.includeFromArray(s,h,p)}return a.toIndexArray()},i.convFacesToEdges=function(e,t,r,n){for(var i=l.default.resolveMap(e,n),a=new d.default(i.edgeVertexAdjacency.getNumEdges()),o=e.faceRangeOffsets,s=i.faceValueIndices,u=0,c=t.length;u!==c;++u){var f=t[u],h=o[f],p=o[f+1];if(h!==p)for(var m=s[p-1],g=h;g!==p;++g){var v=s[g];a.include(i.edgeVertexAdjacency.findEdgeId(m,v)),m=v}}return a.toIndexArray()},i.convVerticesToFaces=function(e,t,r,n){for(var i=new c.default(Uint32Array),a=e.faceRangeOffsets,s=l.default.resolveMap(e,r).faceValueIndices,u=e.getNumFaces(),f=0;f!==u;++f){for(var d=a[f],h=a[f+1],p=!0,m=d;m!==h&&p;++m)p=-10?n:r)(e)}},function(e,t,r){var n=r(77);e.exports=function(e){return Object(n(e))}},function(e,t){var r=0,n=Math.random();e.exports=function(e){return"Symbol(".concat(void 0===e?"":e,")_",(++r+n).toString(36))}},function(e,t,r){"use strict";t.__esModule=!0;var n=r(2),i=function(e){return e&&e.__esModule?e:{default:e}}(n);t.default=i.default||function(e){for(var t=1;t=n())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+n().toString(16)+" bytes");return 0|e}function m(e){return+e!=e&&(e=0),a.alloc(+e)}function g(e,t){if(a.isBuffer(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var r=e.length;if(0===r)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return H(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return Y(e).length;default:if(n)return H(e).length;t=(""+t).toLowerCase(),n=!0}}function v(e,t,r){var n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if(r>>>=0,t>>>=0,r<=t)return"";for(e||(e="utf8");;)switch(e){case"hex":return O(this,t,r);case"utf8":case"utf-8":return A(this,t,r);case"ascii":return I(this,t,r);case"latin1":case"binary":return R(this,t,r);case"base64":return P(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return L(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function y(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function x(e,t,r,n,i){if(0===e.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof t&&(t=a.from(t,n)),a.isBuffer(t))return 0===t.length?-1:b(e,t,r,n,i);if("number"==typeof t)return t&=255,a.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):b(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function b(e,t,r,n,i){function a(e,t){return 1===o?e[t]:e.readUInt16BE(t*o)}var o=1,s=e.length,l=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;o=2,s/=2,l/=2,r/=2}var u;if(i){var c=-1;for(u=r;us&&(r=s-l),u=r;u>=0;u--){for(var f=!0,d=0;di&&(n=i):n=i;var a=t.length;if(a%2!=0)throw new TypeError("Invalid hex string");n>a/2&&(n=a/2);for(var o=0;o239?4:a>223?3:a>191?2:1;if(i+s<=r){var l,u,c,f;switch(s){case 1:a<128&&(o=a);break;case 2:l=e[i+1],128==(192&l)&&(f=(31&a)<<6|63&l)>127&&(o=f);break;case 3:l=e[i+1],u=e[i+2],128==(192&l)&&128==(192&u)&&(f=(15&a)<<12|(63&l)<<6|63&u)>2047&&(f<55296||f>57343)&&(o=f);break;case 4:l=e[i+1],u=e[i+2],c=e[i+3],128==(192&l)&&128==(192&u)&&128==(192&c)&&(f=(15&a)<<18|(63&l)<<12|(63&u)<<6|63&c)>65535&&f<1114112&&(o=f)}}null===o?(o=65533,s=1):o>65535&&(o-=65536,n.push(o>>>10&1023|55296),o=56320|1023&o),n.push(o),i+=s}return C(n)}function C(e){var t=e.length;if(t<=$)return String.fromCharCode.apply(String,e);for(var r="",n=0;nn)&&(r=n);for(var i="",a=t;ar)throw new RangeError("Trying to access beyond buffer length")}function V(e,t,r,n,i,o){if(!a.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function N(e,t,r,n){t<0&&(t=65535+t+1);for(var i=0,a=Math.min(e.length-r,2);i>>8*(n?i:1-i)}function B(e,t,r,n){t<0&&(t=4294967295+t+1);for(var i=0,a=Math.min(e.length-r,4);i>>8*(n?i:3-i)&255}function F(e,t,r,n,i,a){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function U(e,t,r,n,i){return i||F(e,t,r,4,3.4028234663852886e38,-3.4028234663852886e38),K.write(e,t,r,n,23,4),r+4}function k(e,t,r,n,i){return i||F(e,t,r,8,1.7976931348623157e308,-1.7976931348623157e308),K.write(e,t,r,n,52,8),r+8}function z(e){if(e=j(e).replace(ee,""),e.length<2)return"";for(;e.length%4!=0;)e+="=";return e}function j(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}function G(e){return e<16?"0"+e.toString(16):e.toString(16)}function H(e,t){t=t||1/0;for(var r,n=e.length,i=null,a=[],o=0;o55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&a.push(239,191,189);continue}if(o+1===n){(t-=3)>-1&&a.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&a.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(t-=3)>-1&&a.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;a.push(r)}else if(r<2048){if((t-=2)<0)break;a.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;a.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;a.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return a}function W(e){for(var t=[],r=0;r>8,i=r%256,a.push(i),a.push(n);return a}function Y(e){return J.toByteArray(z(e))}function q(e,t,r,n){for(var i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function Z(e){return e!==e}/*! * The buffer module from node.js, for the browser. * * @author Feross Aboukhadijeh * @license MIT */ var J=r(600),K=r(790),Q=r(348);t.Buffer=a,t.SlowBuffer=m,t.INSPECT_MAX_BYTES=50,a.TYPED_ARRAY_SUPPORT=void 0!==e.TYPED_ARRAY_SUPPORT?e.TYPED_ARRAY_SUPPORT:function(){try{var e=new Uint8Array(1);return e.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===e.foo()&&"function"==typeof e.subarray&&0===e.subarray(1,1).byteLength}catch(e){return!1}}(),t.kMaxLength=n(),a.poolSize=8192,a._augment=function(e){return e.__proto__=a.prototype,e},a.from=function(e,t,r){return o(null,e,t,r)},a.TYPED_ARRAY_SUPPORT&&(a.prototype.__proto__=Uint8Array.prototype,a.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&a[Symbol.species]===a&&Object.defineProperty(a,Symbol.species,{value:null,configurable:!0})),a.alloc=function(e,t,r){return l(null,e,t,r)},a.allocUnsafe=function(e){return u(null,e)},a.allocUnsafeSlow=function(e){return u(null,e)},a.isBuffer=function(e){return!(null==e||!e._isBuffer)},a.compare=function(e,t){if(!a.isBuffer(e)||!a.isBuffer(t))throw new TypeError("Arguments must be Buffers");if(e===t)return 0;for(var r=e.length,n=t.length,i=0,o=Math.min(r,n);i0&&(e=this.toString("hex",0,r).match(/.{2}/g).join(" "),this.length>r&&(e+=" ... ")),""},a.prototype.compare=function(e,t,r,n,i){if(!a.isBuffer(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),t<0||r>e.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&t>=r)return 0;if(n>=i)return-1;if(t>=r)return 1;if(t>>>=0,r>>>=0,n>>>=0,i>>>=0,this===e)return 0;for(var o=i-n,s=r-t,l=Math.min(o,s),u=this.slice(n,i),c=e.slice(t,r),f=0;fi)&&(r=i),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var a=!1;;)switch(n){case"hex":return w(this,e,t,r);case"utf8":case"utf-8":return _(this,e,t,r);case"ascii":return M(this,e,t,r);case"latin1":case"binary":return S(this,e,t,r);case"base64":return T(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return E(this,e,t,r);default:if(a)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),a=!0}},a.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var $=4096;a.prototype.slice=function(e,t){var r=this.length;e=~~e,t=void 0===t?r:~~t,e<0?(e+=r)<0&&(e=0):e>r&&(e=r),t<0?(t+=r)<0&&(t=0):t>r&&(t=r),t0&&(i*=256);)n+=this[e+--t]*i;return n},a.prototype.readUInt8=function(e,t){return t||D(e,1,this.length),this[e]},a.prototype.readUInt16LE=function(e,t){return t||D(e,2,this.length),this[e]|this[e+1]<<8},a.prototype.readUInt16BE=function(e,t){return t||D(e,2,this.length),this[e]<<8|this[e+1]},a.prototype.readUInt32LE=function(e,t){return t||D(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},a.prototype.readUInt32BE=function(e,t){return t||D(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},a.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||D(e,t,this.length);for(var n=this[e],i=1,a=0;++a=i&&(n-=Math.pow(2,8*t)),n},a.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||D(e,t,this.length);for(var n=t,i=1,a=this[e+--n];n>0&&(i*=256);)a+=this[e+--n]*i;return i*=128,a>=i&&(a-=Math.pow(2,8*t)),a},a.prototype.readInt8=function(e,t){return t||D(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},a.prototype.readInt16LE=function(e,t){t||D(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},a.prototype.readInt16BE=function(e,t){t||D(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},a.prototype.readInt32LE=function(e,t){return t||D(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},a.prototype.readInt32BE=function(e,t){return t||D(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},a.prototype.readFloatLE=function(e,t){return t||D(e,4,this.length),K.read(this,e,!0,23,4)},a.prototype.readFloatBE=function(e,t){return t||D(e,4,this.length),K.read(this,e,!1,23,4)},a.prototype.readDoubleLE=function(e,t){return t||D(e,8,this.length),K.read(this,e,!0,52,8)},a.prototype.readDoubleBE=function(e,t){return t||D(e,8,this.length),K.read(this,e,!1,52,8)},a.prototype.writeUIntLE=function(e,t,r,n){if(e=+e,t|=0,r|=0,!n){V(this,e,t,r,Math.pow(2,8*r)-1,0)}var i=1,a=0;for(this[t]=255&e;++a=0&&(a*=256);)this[t+i]=e/a&255;return t+r},a.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||V(this,e,t,1,255,0),a.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},a.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||V(this,e,t,2,65535,0),a.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):N(this,e,t,!0),t+2},a.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||V(this,e,t,2,65535,0),a.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):N(this,e,t,!1),t+2},a.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||V(this,e,t,4,4294967295,0),a.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):B(this,e,t,!0),t+4},a.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||V(this,e,t,4,4294967295,0),a.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):B(this,e,t,!1),t+4},a.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);V(this,e,t,r,i-1,-i)}var a=0,o=1,s=0;for(this[t]=255&e;++a>0)-s&255;return t+r},a.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);V(this,e,t,r,i-1,-i)}var a=r-1,o=1,s=0;for(this[t+a]=255&e;--a>=0&&(o*=256);)e<0&&0===s&&0!==this[t+a+1]&&(s=1),this[t+a]=(e/o>>0)-s&255;return t+r},a.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||V(this,e,t,1,127,-128),a.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},a.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||V(this,e,t,2,32767,-32768),a.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):N(this,e,t,!0),t+2},a.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||V(this,e,t,2,32767,-32768),a.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):N(this,e,t,!1),t+2},a.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||V(this,e,t,4,2147483647,-2147483648),a.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):B(this,e,t,!0),t+4},a.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||V(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),a.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):B(this,e,t,!1),t+4},a.prototype.writeFloatLE=function(e,t,r){return U(this,e,t,!0,r)},a.prototype.writeFloatBE=function(e,t,r){return U(this,e,t,!1,r)},a.prototype.writeDoubleLE=function(e,t,r){return k(this,e,t,!0,r)},a.prototype.writeDoubleBE=function(e,t,r){return k(this,e,t,!1,r)},a.prototype.copy=function(e,t,r,n){if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t=0;--i)e[i+t]=this[i+r];else if(o<1e3||!a.TYPED_ARRAY_SUPPORT)for(i=0;i>>=0,r=void 0===r?this.length:r>>>0,e||(e=0);var o;if("number"==typeof e)for(o=t;o1&&void 0!==arguments[1]?arguments[1]:{};return"string"==typeof e?s(e,t):"object"===(void 0===e?"undefined":(0,y.default)(e))?(0,b.default)({},e,{name:e.name?a(e.name):void 0,names:e.names&&Array.isArray(e.names)?e.names.map(a):void 0,includeParent:void 0===e.includeParent?!e.from:e.includeParent},t):{}}function u(e,t,r){var n=c(e,t);return n?r?n.id:d(e,t):null}function c(e,t){if(void 0!==t.id&&t.id!==e.id)return null;if(void 0!==t.name&&!t.name.test(e.name))return null;if(void 0!==t.type)if("string"==typeof t.type){if(t.type!==e.type)return null}else if(Array.isArray(t.type)&&-1===t.type.indexOf(e.type))return null;return void 0===t.hasPlug||e.plugs[t.hasPlug]?e:null}function f(e,t){for(var r=(0,g.default)(e),n=0;nx;x++)if((g=t?y(o(p=e[x])[0],p[1]):y(e[x]))===u||g===c)return g}else for(m=v.call(e);!(p=m.next()).done;)if((g=i(m,y,p.value,t))===u||g===c)return g};t.BREAK=u,t.RETURN=c},function(e,t){e.exports={}},function(e,t,r){var n=r(304),i=r(187);e.exports=Object.keys||function(e){return n(e,i)}},function(e,t,r){var n=r(185);e.exports=function(e){return Object(n(e))}},function(e,t,r){"use strict";var n=r(649)(!0);r(189)(String,"String",function(e){this._t=String(e),this._i=0},function(){var e,t=this._t,r=this._i;return r>=t.length?{value:void 0,done:!0}:(e=n(t,r),this._i+=e.length,{value:e,done:!1})})},function(e,t,r){r(654);for(var n=r(32),i=r(67),a=r(87),o=r(27)("toStringTag"),s="CSSRuleList,CSSStyleDeclaration,CSSValueList,ClientRectList,DOMRectList,DOMStringList,DOMTokenList,DataTransferItemList,FileList,HTMLAllCollection,HTMLCollection,HTMLFormElement,HTMLSelectElement,MediaList,MimeTypeArray,NamedNodeMap,NodeList,PaintRequestList,Plugin,PluginArray,SVGLengthList,SVGNumberList,SVGPathSegList,SVGPointList,SVGStringList,SVGTransformList,SourceBufferList,StyleSheetList,TextTrackCueList,TextTrackList,TouchList".split(","),l=0;l=0&&r>0&&(e+=" "),e+=t(n)}return e}e=void 0!==e?e:2;for(var n="",i=0;i0,c=d}return r}function i(e,t,r,n){for(var i=new s.Vector3,a=t.length,o=0;o0){var a=(new s.Vector3,[0]),o=[],l=[];e.holeOffsets=[];for(var u=r[0].min.y,c=0;c1?t-1:0),n=1;n=0;Y--)G.update()}function x(e,t){G="function"==typeof e?e(t):e}function b(e){H=e}function w(){return!!H}function _(){if(!H)throw new Error("No api function defined");for(var e=arguments.length,t=Array(e),r=0;r2&&void 0!==arguments[2]?arguments[2]:{};if(t&&console.error(t),j?(j.error(e,r),e.message?(console.error(e.message),e.stack&&console.log(e.stack)):console.error(e)):console.error(e),N.makeErrorsFatal)throw e}function R(e){U.push(e);var t=!0;return function(){if(t){t=!1;var r=U.indexOf(e);U.splice(r,1)}}}function O(e){if(!(0,c.default)(e))throw console.log("Invalid action",e),new Error("Actions must be plain objects. Use custom middleware for async actions.");if(void 0===e.type)throw console.error("Invalid action: ",e),new Error('Actions may not have an undefined "type" property. Have you misspelled a constant?');if(z)throw new Error("Reducers may not dispatch actions.");try{z=!0,F=B(F,e,a,E)}catch(e){I(e)}finally{z=!1}return q(!0),h.default.Promise.resolve(e.resolve?e.resolve:e.payload)}function L(e){this.createCanvas=e}function D(e){B=e,O({type:g.INIT})}var V,N=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},B=e,F=t,U=[],k=[],z=!1,j=!1,G=null,H=null,W=null,X=16,Y=X;h.default.on("error",I);var q=function(){function e(e){return function(){try{if(e&&(Y=X),e){var i=k.splice(0,k.length);U.slice().forEach(function(e){return e(i,n)})}Y-=1,G&&G.update()}catch(e){I(e)}r=!1,(n||Y>0)&&t()}}function t(t){var i=n||t;r?n=n||t:(r=!0,n=!1,p.call(m,e(i)))}var r=!1,n=!1;return t}(),Z=function(e,t){var r=document.createElement("Canvas");return r.width=e,r.height=t,r};return O({type:g.INIT}),V={dispatch:O,subscribe:R,getState:o,getIn:l,get:u,replaceReducer:D,setTranslator:x,getTranslator:d,getEvaluatedTranslator:v,read:P,write:A,useRollbar:C,error:I,setApi:b,hasApi:w,callApi:_,createEvent:a,setRequestAnimationFrame:i,logPageView:T,setSocketApi:M,getSocketApi:S,createCanvas:Z,setCreateCanvas:L},(0,s.default)(V,"createEvent",a),(0,s.default)(V,"trackEvent",E),(0,s.default)(V,"setTotalRenders",r),(0,s.default)(V,"numRendersRemaining",n),(0,s.default)(V,"renderAll",y),V}Object.defineProperty(t,"__esModule",{value:!0}),t.ActionTypes=void 0;var o=r(18),s=n(o),l=r(596);n(l);t.default=a;var u=r(284),c=n(u),f=r(588),d=r(223),h=n(d),p=void 0,m=void 0;i();var g=t.ActionTypes={INIT:"@@redux/INIT"}},function(e,t,r){e.exports={default:r(619),__esModule:!0}},function(e,t,r){e.exports={default:r(625),__esModule:!0}},function(e,t){e.exports=function(e){if("function"!=typeof e)throw TypeError(e+" is not a function!");return e}},function(e,t){var r={}.toString;e.exports=function(e){return r.call(e).slice(8,-1)}},function(e,t){t.f={}.propertyIsEnumerable},function(e,t){e.exports=function(e,t){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:t}}},function(e,t,r){var n=r(50).f,i=r(66),a=r(27)("toStringTag");e.exports=function(e,t,r){e&&!i(e=r?e:e.prototype,a)&&n(e,a,{configurable:!0,value:t})}},function(e,t,r){var n=r(58),i=r(208),a=r(80),o=r(33),s=r(688);e.exports=function(e,t){var r=1==e,l=2==e,u=3==e,c=4==e,f=6==e,d=5==e||f,h=t||s;return function(t,s,p){for(var m,g,v=a(t),y=i(v),x=n(s,p,3),b=o(y.length),w=0,_=r?h(t,b):l?h(t,0):void 0;b>w;w++)if((d||w in y)&&(m=y[w],g=x(m,w,v),e))if(r)_[w]=g;else if(g)switch(e){case 3:return!0;case 5:return m;case 6:return w;case 2:_.push(m)}else if(c)return!1;return f?-1:u||c?c:_}}},function(e,t){var r=e.exports={version:"2.5.1"};"number"==typeof __e&&(__e=r)},function(e,t,r){var n=r(81)("meta"),i=r(17),a=r(45),o=r(28).f,s=0,l=Object.isExtensible||function(){return!0},u=!r(22)(function(){return l(Object.preventExtensions({}))}),c=function(e){o(e,n,{value:{i:"O"+ ++s,w:{}}})},f=function(e,t){if(!i(e))return"symbol"==typeof e?e:("string"==typeof e?"S":"P")+e;if(!a(e,n)){if(!l(e))return"F";if(!t)return"E";c(e)}return e[n].i},d=function(e,t){if(!a(e,n)){if(!l(e))return!0;if(!t)return!1;c(e)}return e[n].w},h=function(e){return u&&p.NEED&&l(e)&&!a(e,n)&&c(e),e},p=e.exports={KEY:n,NEED:!1,fastKey:f,getWeak:d,onFreeze:h}},function(e,t,r){var n=r(15),i=r(696),a=r(206),o=r(213)("IE_PROTO"),s=function(){},l=function(){var e,t=r(205)("iframe"),n=a.length;for(t.style.display="none",r(314).appendChild(t),t.src="javascript:",e=t.contentWindow.document,e.open(),e.write("