!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 b=r(315),x=n(b),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 b=a*s,x=a*l,w=o*s,_=o*l;t[0]=s*u,t[4]=_-b*c,t[8]=w*c+x,t[1]=c,t[5]=a*u,t[9]=-o*u,t[2]=-l*u,t[6]=x*c+w,t[10]=b-_*c}else if("XZY"===e.order){var b=a*s,x=a*l,w=o*s,_=o*l;t[0]=s*u,t[4]=-c,t[8]=l*u,t[1]=b*c+_,t[5]=a*u,t[9]=x*c-w,t[2]=w*c-x,t[6]=o*u,t[10]=_*c+b}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],b=r[11],x=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],N=n[11],V=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*N,i[12]=a*S+o*A+s*O+l*V,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*N,i[13]=u*S+c*A+f*O+d*V,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*N,i[14]=h*S+p*A+m*O+g*V,i[3]=v*w+y*T+b*C+x*L,i[7]=v*_+y*E+b*I+x*D,i[11]=v*M+y*P+b*R+x*N,i[15]=v*S+y*A+b*O+x*V,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>x.default){var b=Math.sqrt(y),w=Math.atan2(b,g*v);m=Math.sin(m*w)/b,o=Math.sin(o*w)/b}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,b=(l+d)/4,x=(f+h)/4;return m>g&&m>v?m<.01?(r=0,n=.707106781,i=.707106781):(r=Math.sqrt(m),n=y/r,i=b/r):g>v?g<.01?(r=.707106781,n=0,i=.707106781):(n=Math.sqrt(g),r=y/n,i=x/n):v<.01?(r=.707106781,n=.707106781,i=0):(i=Math.sqrt(v),r=b/i,n=x/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(126),a=r(53),o=r(71),s=r(61),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,b=p?i:i[t]||(i[t]={}),x=b.prototype||(b.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),b[u]!=f&&a(b,u,d),g&&x[u]!=f&&(x[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(389),__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(55),o=n(a),s=r(2),l=n(s);t.default=i;var u=r(43),c=n(u),f=r(280),d=n(f),h=r(76),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,q.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,q.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 b=(new G.Vector3).copy(a).multiplyScalar(Math.PI/180);y.makeRotationFromEuler(new G.Euler(b.x,b.y,b.z,i)),d.push(y)}var x=(new G.Vector3).copy(r).multiplyScalar(Math.PI/180),w=(new G.Matrix4).makeRotationFromEuler(new G.Euler(x.x,x.y,x.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),B.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",{}]]}})):B.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","Light","Shape","Vrscene"]},s=a(e,n),l=e.get("sceneGraph");if(!s.length)return console.warn("No match for clone: ",n),B.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 b(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=x(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&&a.dispatch(d({id:t,plug:"Transform",property:"scale"},u))}}function x(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,b=new G.Quaternion;m.decompose(y,b,s);var x=new G.Vector3,w=new G.Quaternion,_=new G.Vector3;if(v.decompose(x,w,_),o){var M=(new G.Matrix4).makeScale((0,O.default)(s.x*_.x),(0,O.default)(s.y*_.y),(0,O.default)(s.z*_.z));v.premultiply(M),g.premultiply(M)}var S=new G.Vector3,T=new G.Quaternion;if(g.decompose(S,T,s),o&&(f=s.clone()),v.decompose(x,w,_),l=y.clone().sub(x).add(S),a){var E=b.multiply(w.inverse());c=(new G.Euler).setFromQuaternion(T.premultiply(E),"ZYX").toVector3().multiplyScalar(180/Math.PI);var P=x.clone().sub(S),A=P.clone().applyQuaternion(E);l.add(P.sub(A))}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,Y.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),B.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)}if("Enable"!==o(e,{id:e.get("sceneGraph").activeSceneId,plug:"Properties",property:"hierarchyVisibility"})){var n=o(e,{id:t,plug:"Properties",property:"visible"});return void 0===n||n}return 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(108),O=n(R),L=r(17),D=n(L),N=r(32),V=n(N),F=r(30),B=n(F),U=r(6),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=b,t.getAttachTransform=x,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(9),W=r(8),X=r(23),q=r(89),Y=r(110),Z=n(Y),J=r(73),K=r(42),Q=(n(K),r(116)),$=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:b},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 x.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(242),l=n(s),u=(r(0),r(14)),c=n(u),f=r(3),d=(n(f),r(550)),h=n(d),p=r(547),m=n(p),g=r(111),v=(n(g),r(44)),y=n(v),b=r(7),x=n(b),w=r(141),_=n(w),M=r(290),S=n(M),T=r(285);r(40);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:x.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 b.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){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function i(e){return{type:xt,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 b(e){return{type:Ut,payload:e}}function x(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}),t.dispatch((0,dt.updateCommand)("fullscreen",{active:e}))),!e&&N(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 N(e){return e.getIn(["player","renderingMode"])===gt.vr}function V(e){return e.getIn(["player","renderingMode"])===gt.lenticular}function F(e){return function(t){var r=t.getIn(["player","tools",e]);if(r){if(r.get("action"))return r.get("action")(t);var n=B(t,r);return r.get("activate")&&!n?r.get("activate")(t):r.get("deactivate")&&n?r.get("deactivate")(t):t.dispatch(i(e))}}}function B(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&&B(e,r)}function k(e){return e.getIn(["player","tools"]).filter(function(t){return B(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:Vt,payload:{trackDevice:r,cameraId:n}})}}function j(){return{type:Nt}}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(V(e)?j():z({}))}}function X(){return{type:Ft,payload:!0}}function q(){return{type:Ft,payload:!1}}function Y(){return function(e){console.log("toggle device tracking",!Z(e)),e.dispatch(Z(e)?q():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:Bt,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 Ye.Vector3,a=new Ye.Quaternion,o=new Ye.Vector3(1,1,1);e.decompose(i,a,o);var s=new Ye.Vector3,l=new Ye.Quaternion;t.decompose(s,l,o);var u=(new Ye.Vector3).setFromMatrixPosition(r),c=u.distanceTo(i),f=(new Ye.Vector3).setFromMatrixPosition(n),d=f.distanceTo(s),h=new Ye.Vector3,p=new Ye.Vector3,m=new Ye.Vector3,g=new Ye.Quaternion,v=new Ye.Matrix4;return function(e,t,r,n){var i=e/n;h.lerpVectors(u,f,i);var s=c*(1-i)+d*i;return Ye.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,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(){n.useTarget=!1;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 n=(0,rt.getWorldTransform)(r,i),a=(0,ft.default)(r,i),o=(0,pt.initCamera)(r,e),u=o.cameraWorldTransform,c=o.lookAtTransform,f=t||300;return new Ge.default(function(e,t){r.dispatch((0,nt.queueAnimation)({autoplay:!0,name:"animateCameraTo",iterations:1,tracks:[{duration:f,value:u,startValue:n,tween:ne(n,u,a,c),set:function(e,t){(0,st.default)(r,i,t)}},{path:{id:i,plug:"Camera",property:"fieldOfView"},duration:f,value:l,startValue:s}],onEnd:e}))})}).then(function(t){return t||r.dispatch(g(e)),n.useTarget=!0,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){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return function(n){var i=S(n);if(i){if(!e&&!t)return void n.dispatch((0,it.merge)([i,"Properties",0],{constrainCameraSphere:!1}));var a=r&&r.nodeList&&r.nodeList.map&&r.nodeList.map(function(e){return(0,rt.find)(n,e)}).filter(function(e){return!!e});(0,it.getCameraController)(n).setConstrainNodeList(a),e=Math.max(e||5,1),t=Math.max(t||1,1),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 be(e){return e.getIn(["player","displayVrSettings"])}function xe(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")];if((qt[t.mode]||qt.sphere)===qt.geometry){for(var o=function(e){if(i){var t=l[e].plugs.Properties,r=t&&t[0];if(r&&r.layer&&r.layer!==i)return}"PolyMesh"!==l[e].type&&"Shape"!==l[e].type||u.push(e)},s=r.get("sceneGraph"),l=s.nodes,u=[],c=0;c=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 b={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:b,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(Fe(null))):"ready"===r.type&&i.dispatch(Ne())}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(Ne())},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(Fe(null))},l.onclose=function(){console.log("Socket closed..."),i.dispatch(Fe(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(Fe(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 Ne(){return function(e){var t=e.getIn(["player","ws"]);t&&1===t.readyState&&t.send((0,ze.default)({type:"request"}))}}function Ve(){return function(e){var t=e.getIn(["player","ws"]);t&&t.close()}}function Fe(e,t){return{type:jt,payload:e}}function Be(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(37),ze=n(ke),je=r(30),Ge=n(je),He=r(2),We=n(He),Xe=r(17),qe=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=b,t.getThree=x,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=N,t.isLenticularMode=V,t.activateTool=F,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=q,t.toggleDeviceTracking=Y,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=be,t.setProgressBar=xe,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=Ne,t.exitVrayMode=Ve,t.onStreamingUpdate=Be;var Ye=r(0),Ze=r(35),Je=r(243),Ke=n(Je),Qe=r(64),$e=n(Qe),et=r(50),tt=n(et),rt=r(4),nt=r(75),it=r(9),at=r(19),ot=r(306),st=n(ot),lt=r(42),ut=n(lt),ct=r(65),ft=n(ct),dt=r(25),ht=r(73),pt=r(308),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"},bt=t.WIREFRAME_MODE={NONE:0,WIREFRAME_AND_FACES:1,WIREFRAME_ONLY:2},xt="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",Nt="REQUEST_NORMAL_MODE",Vt="REQUEST_LENTICULAR_MODE",Ft="SET_DEVICE_TRACKING",Bt="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 Ye.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:bt.NONE,zSpaceCapable:!1,ws:null,streamingUpdateListeners:(0,Ze.List)()}),Xt=(0,tt.default)(Wt,(Ue={},(0,qe.default)(Ue,kt,function(e,t){return e.set("wireframeMode",t)}),(0,qe.default)(Ue,xt,function(e,t){return e.set("activeManipulator",t)}),(0,qe.default)(Ue,wt,function(e,t){var r=t.id,n=t.prevCameraId;return e.set("activeCamera",r).set("prevCamera",n)}),(0,qe.default)(Ue,_t,function(e,t){return e.mergeIn(["camera"],t)}),(0,qe.default)(Ue,St,function(e,t){return e.set("rect",t)}),(0,qe.default)(Ue,Mt,function(e,t){return e.merge(t)}),(0,qe.default)(Ue,Ct,function(e,t){var r=t.playerEl,n=t.canvasEl;return e.set("playerElement",r).set("canvasElement",n)}),(0,qe.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,qe.default)(Ue,Et,function(e,t){return e.set("displayVrSettings",!!t)}),(0,qe.default)(Ue,Pt,function(e,t){return e.set("activeColor",t)}),(0,qe.default)(Ue,At,function(e,t){return e.set("hoverColor",t)}),(0,qe.default)(Ue,Bt,function(e,t){return e.set("fullscreenBackgroundColor",t)}),(0,qe.default)(Ue,Dt,function(e,t){return yt[t]||(t=yt.default),e.set("progressBarOption",t)}),(0,qe.default)(Ue,It,function(e){return e.set("fullScreen",!0)}),(0,qe.default)(Ue,Rt,function(e){return e.set("fullScreen",!1)}),(0,qe.default)(Ue,Ot,function(e,t){return e.set("fullScreen",t)}),(0,qe.default)(Ue,Lt,function(e,t,r){var n=r.createEvent;return e.get("renderingMode")!==t&&n("renderingMode",t),e.set("renderingMode",t)}),(0,qe.default)(Ue,Vt,function(e,t){var r=t.trackDevice,n=t.cameraId;return e.merge({renderingMode:"lenticular",deviceTracking:r,prevCamera:n})}),(0,qe.default)(Ue,Nt,function(e){return e.merge({renderingMode:"normal",deviceTracking:!1})}),(0,qe.default)(Ue,Ft,function(e,t){return e.set("deviceTracking",t)}),(0,qe.default)(Ue,"SET_CONSTRAIN_CAMERA_RADIUS",function(e,t){return e.set("constrainCameraRadius",t)}),(0,qe.default)(Ue,Ut,function(e,t,r){return(0,r.createEvent)("threeinitialized"),e.set("threeObjects",(0,Ze.Map)(t))}),(0,qe.default)(Ue,zt,function(e,t){return e.set("zSpaceCapable",t)}),(0,qe.default)(Ue,jt,function(e,t,r){var n=r.createEvent;return t||n("socketdisconnect"),e.set("ws",t)}),(0,qe.default)(Ue,Gt,function(e,t){return e.updateIn(["streamingUpdateListeners"],(0,Ze.List)(),function(e){return e.push(t)})}),Ue)),qt={sphere:"sphere",box:"box",geometry:"geometry"},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:q,toggleDeviceTracking:Y,requestNormalMode:j,setFullscreenBGColor:$,setCameraRadiusConstraint:fe,updateToolOptions:c,setCamera:y,frameScene:_e,setProgressBar:xe,createExplode:Ee,addGoogleAnalytics:Pe,setWireframeMode:Ce,enterVrayMode:Le,exitVrayMode:Ve,onStreamingUpdate:Be,updateVrayTranslator:De,requestVrayImgUpdate:Ne},selectors:{getCamera:S,getCameraAttrs:p,getInitialCameraPosition:P,getCameraWorldTransform:m,getActiveColor:ee,getCanvasElement:de,isFullscreen:R,isVRMode:N,isLenticularMode:V,getFullscreenBGColor:re,isDeviceTracking:Z,shouldDisplayThumbnail:me,filterNodesFromPosition:oe,filterNodesFromCenter:se,getThreeScene:w,getThreeCamera:_,getProgressBar:we,getThree:x,getWireframeMode:Ae,getZSpaceCapable:Re}};t.default=Yt},function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}function i(e){var t={},r=e.warnings||[],n=e.id,i=e.children,a=e.name,o=e.type,s=e.parent;return(0,le.default)(e.plugs).forEach(function(n){t[n]=e.plugs[n].map(function(e){var t=e.type;return(0,we.lookupOperator)(n,t,r).init(t,e,e.name)})}),{id:n,children:i,name:a,type:o,parent:s,plugs:t,warnings:r,_v:0}}function a(e){return e.hasOwnProperty("_v")||(e._v=0),e}function o(e,t,r){var n=void 0,i=void 0,a=void 0;if(Array.isArray(t)){var o=(0,oe.default)(t,3);n=o[0],i=o[1],a=o[2]}else n=t.type,a=t.name,i=t;return(0,we.lookupOperator)(e,n,r).init(n,i,a)}function s(e){var t=e.id,r=e.name,n=e.type,i=e.children,a=e.parent,s=e.plugs,l=[];return{id:t,name:r,type:n,parent:a,warnings:l,_v:0,children:i||[],plugs:(0,me.default)(function(e,t){return e.map(function(e){return o(t,e,l)})},s)}}function l(e){var t=arguments.length>1&&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[qe]&&!t.force||(e.nodes[qe]=s({id:qe,name:"VIRTUAL TARGET NULL",type:"Null",plugs:{Transform:[["Transform",{}]]}})),e.nodes[Ye]&&!t.force||(e.nodes[Ye]=s({id:Ye,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:xe.ADD_NODE,payload:{id:t,name:r,type:n,plugs:i,parent:a},resolve:t}}function p(e){return{type:xe.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,Ne.getSceneId)(e),"Player",0,"vrCamera"])}function y(e){return function(t){var r=[(0,Ne.getSceneId)(t),"Player",0,"vrCamera"];t.dispatch(b(r,e))}}function b(e,t){return{type:Ve,payload:{path:e,value:t},meta:{remote:!0}}}function x(e,t){return{type:Fe,payload:{path:e,attrs:t}}}function w(e,t){return{type:Be,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,b=(0,ee.default)(p);!(m=(y=b.next()).done);m=!0){var x=y.value,w=_e.default[h][x.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=x[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,N=x[D];N&&r.getIn(["assets","assets",N])&&(a[N]=!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&&b.return&&b.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 b,x=(0,ee.default)(s.fileReferenceKeys);!(g=(b=x.next()).done);g=!0){var w=b.value,_=e[w];_&&a[_]&&(r.plugs[n][o][w]=a[_])}}catch(e){v=!0,y=e}finally{try{!g&&x.return&&x.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:xe.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,be.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(b([t,"Transform",0,"translation"],{x:a.x,y:a.y,z:a.z})),e.dispatch(b([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 N(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,be.addFile)(t))}}),(0,Ce.default)(o,l,s,u,function(t,r){e.dispatch(b(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 V(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(N({toHEAD:e,options:t}))})})}}function F(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(N({toHEAD:e,options:{}})):(t.dispatch(N({toHEAD:n,options:{}})),t.dispatch(N({toHEAD:e,fromHEAD:n,secondHEAD:i,options:{}})))})})}}function B(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(F(i))})}}function q(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=this.numLods)){var s=a\n\t\t\t\t#include \n\t\t\t\t#include \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\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\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 = getHalton1DFast(float(i), 2., 1. / 2.);\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:w.CustomBlending,blendSrc:w.OneFactor,blendDst:w.ZeroFactor,blendSrcAlpha:w.OneFactor,blendDstAlpha:w.ZeroFactor,blendEquation:w.AddEquation})},dispose:function(){for(var e=0,t=this.cubeLods.length;e","#include ","uniform mat4 reflectionTextureMatrix;","varying vec4 mirrorCoord;","varying vec3 vecPosition;","varying vec3 worldNormal;","varying vec3 vNormal;","varying vec2 vUv;","void main() {","vUv = uv;","vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );","vec4 worldPosition = modelMatrix * vec4( position, 1.0 );","vecPosition = cameraPosition - worldPosition.xyz;","worldNormal = (modelMatrix * vec4(normal,0.0)).xyz;","mirrorCoord = reflectionTextureMatrix * worldPosition;","vNormal = transformDirection(normal, modelViewMatrix);","gl_Position = projectionMatrix * mvPosition;","#include ","}"].join("\n"),blending:w.NormalBlending,transparent:!0,fragmentShader:["#include ","#include ","#include ","#include ","#define DITHERING","#define DITHERING_SCALE","#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 vec3 vNormal;","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 = reflection;","if(gl_FragColor.a < EPSILON) { gl_FragColor = vec4(0); return; }","#ifdef PREMULTIPLIED_ALPHA","gl_FragColor.rgb /= gl_FragColor.a;","#endif","#ifdef USE_OIT","if(oitMode != 2) {","gl_FragColor.rgb /= gl_FragColor.a;","}","#endif","float alphaMod = fade * fresnel.r;","gl_FragColor.a *= alphaMod;","#include ","#include ","vec3 normal = vNormal;","#include ","}"].join("\n")},w.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"),w.SAOShader={blending:w.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 w.Vector2(512,512)},cameraNear:{type:"f",value:1},cameraFar:{type:"f",value:100},cameraProjectionMatrix:{type:"m4",value:new w.Matrix4},cameraInverseProjectionMatrix:{type:"m4",value:new w.Matrix4},intensity:{type:"f",value:.1},occlusionSphereWorldRadius:{type:"f",value:100},worldToScreenRatio:{type:"v2",value:new w.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")},w.SAODepthMinifyShader={blending:w.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 w.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")},w.SAOBilaterialFilterShader={blending:w.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 w.Vector2(256,256)},kernelDirection:{type:"v2",value:new w.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")},w.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"),w.SAO2Shader={blending:w.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 w.Vector2(512,512)},cameraNear:{type:"f",value:1},cameraFar:{type:"f",value:100},cameraProjectionMatrix:{type:"m4",value:new w.Matrix4},cameraInverseProjectionMatrix:{type:"m4",value:new w.Matrix4},intensity:{type:"f",value:.1},bias:{type:"f",value:.001},occlusionSphereWorldRadius:{type:"f",value:100},worldToScreenRatio:{type:"v2",value:new w.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")},w.SAO2DepthMinifyShader={blending:w.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 w.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")},w.SAO2BilaterialFilterShader={blending:w.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 w.Vector2(256,256)},kernelDirection:{type:"v2",value:new w.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")},w.BlurShader={defines:{KERNEL_RADIUS:4},uniforms:{tDiffuse:{type:"t",value:null},size:{type:"v2",value:new w.Vector2(512,512)},sampleUvOffsets:{type:"v2v",value:[new w.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")},w.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=w.BlurShaderUtils.createSampleOffsets(t,n),e.uniforms.sampleWeights.value=w.BlurShaderUtils.createSampleWeights(t,r),e.uvIncrement=n,e.stdDev=r,e.needsUpdate=!0)}},w.LuminosityHighPassShader={shaderID:"luminosityHighPass",uniforms:{tDiffuse:{type:"t",value:null},luminosityThreshold:{type:"f",value:1},smoothWidth:{type:"f",value:1},defaultColor:{type:"c",value:new w.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")},w.GeometricRefractionShader={defines:{NUM_BOUNCES:4},extensions:{derivatives:!0},side:w.DoubleSide,uniforms:w.UniformsUtils.merge([w.UniformsLib.common,{normalCubeMap:{value:null},bDebugBounces:{value:!1},rIndexDelta:{value:.03},envMapIntensity:{value:1},crystalIOR:{value:1},absorptionColor:{value:new w.Vector3(0,.8,.8)},boostFactor:{value:1},boostColor:{value:new w.Vector3(1,1,1)},abbeNumber:{value:10},sphereSquish:{value:new w.Vector3(1,1,1)},boundingSphere:{value:new w.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 crystalIOR;","uniform float boostFactor;","uniform vec3 boostColor;","uniform float abbeNumber;","float spectrumSpread;","uniform vec3 absorptionColor;","uniform vec3 sphereSquish;","uniform vec4 boundingSphere;","uniform samplerCube normalCubeMap;","uniform mat4 modelMatrix;","uniform mat4 modelMatrixInverse;","const float airIOR = 1.0;","#include ","#include ","float abbeNumberToIORDispersion(float abbeNumber) {","return (crystalIOR - 1.) / abbeNumber;","}","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/crystalIOR ) );","setRay( reflectedRay, incidentRay.origin, reflect( incidentRay.direction, diamondNormal ) );","reflectance = fresnelReflectance( airIOR, crystalIOR, 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 * absorptionColor );","setRay( refractedRay, pointOnGemStone, refract( incidentRay.direction, inwardDiamondNormal, crystalIOR/airIOR ) );","setRay( reflectedRay, pointOnGemStone, reflect( incidentRay.direction, inwardDiamondNormal ) );","reflectance = fresnelReflectance( crystalIOR, 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, (crystalIOR+spectrumSpread*0.075)/airIOR ) );","refractedColor.r = queryEnvMapLocal( refractedRay.direction ).r;","setRay( refractedRay, pointOnGemStone, refract( incidentRay.direction, inwardDiamondNormal, (crystalIOR-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() {","spectrumSpread = abbeNumberToIORDispersion(abbeNumber);","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")},w.GeometricNormalCaptureShader={side:w.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")},w.FXAAShader={uniforms:{tDiffuse:{value:null},resolution:{value:new w.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 6.0","void main() {","vec4 rgbaNW = texture2D( tDiffuse, ( gl_FragCoord.xy + vec2( -1.0, -1.0 ) ) * resolution );","vec4 rgbaNE = texture2D( tDiffuse, ( gl_FragCoord.xy + vec2( 1.0, -1.0 ) ) * resolution );","vec4 rgbaSW = texture2D( tDiffuse, ( gl_FragCoord.xy + vec2( -1.0, 1.0 ) ) * resolution );","vec4 rgbaSE = texture2D( tDiffuse, ( gl_FragCoord.xy + vec2( 1.0, 1.0 ) ) * resolution );","vec4 rgbaM = texture2D( tDiffuse, gl_FragCoord.xy * resolution );","vec3 rgbM = rgbaM.xyz;","vec4 luma = vec4( 0.299, 0.587, 0.114, 0. );","float lumaNW = dot( rgbaNW, luma );","float lumaNE = dot( rgbaNE, luma );","float lumaSW = dot( rgbaSW, luma );","float lumaSE = dot( rgbaSE, luma );","float lumaM = dot( rgbaM, 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.xyz, 0.0));","if ( ( lumaB < lumaMin ) || ( lumaB > lumaMax ) ) {","gl_FragColor = rgbA;","} else {","gl_FragColor = rgbB;","}","}"].join("\n")},w.ExpandShader={uniforms:{tDiffuse:{value:null},resolution:{value:new w.Vector2(1/1024,1/512)}},defines:{INPUT_HAS_PREMULTIPLIED_ALPHA:1},vertexShader:["void main() {","gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:"\n\n#include \n\nuniform sampler2D tDiffuse;\nuniform vec2 resolution;\n\nvoid premul(inout vec4 c) {\n c.rgb *= c.a;\n}\n\nvoid depremul(inout vec4 c) {\n if(c.a < EPSILON) c = vec4(0);\n else c.rgb /= c.a;\n}\n\nvoid main() {\n // higher = cuts into opaque objects\n // lower = less effective\n const float rad = 1.1;\n\n vec4 texelM = texture2D(tDiffuse, (gl_FragCoord.xy) * resolution);\n\n vec4 texel1 = texture2D(tDiffuse, (gl_FragCoord.xy + vec2(0, -rad)) * resolution);\n vec4 texel2 = texture2D(tDiffuse, (gl_FragCoord.xy + vec2(0, +rad)) * resolution);\n vec4 texel3 = texture2D(tDiffuse, (gl_FragCoord.xy + vec2(-rad, 0)) * resolution);\n vec4 texel4 = texture2D(tDiffuse, (gl_FragCoord.xy + vec2(+rad, 0)) * resolution);\n\n float max_a = max(max(max(texel1.a, texel2.a), texel3.a), texel4.a);\n\n if(max_a - texelM.a <= EPSILON) {\n gl_FragColor = texelM;\n return;\n }\n\n // convert FROM premultiplied alpha\n #if INPUT_HAS_PREMULTIPLIED_ALPHA\n depremul(texelM);\n depremul(texel1);\n depremul(texel2);\n depremul(texel3);\n depremul(texel4);\n #endif\n\n float a1 = max(0., texel1.a - texelM.a);\n float a2 = max(0., texel2.a - texelM.a);\n float a3 = max(0., texel3.a - texelM.a);\n float a4 = max(0., texel4.a - texelM.a);\n\n float total_a = a1 + a2 + a3 + a4;\n\n vec3 avg = (\n (texel1.rgb * a1) +\n (texel2.rgb * a2) +\n (texel3.rgb * a3) +\n (texel4.rgb * a4)\n ) / total_a;\n\n texelM.rgb = avg;\n texelM.a = max_a;\n\n if(texel1.a > texelM.a) texelM = texel1;\n if(texel2.a > texelM.a) texelM = texel2;\n if(texel3.a > texelM.a) texelM = texel3;\n if(texel4.a > texelM.a) texelM = texel4;\n\n // convert TO premultiplied alpha\n #if INPUT_HAS_PREMULTIPLIED_ALPHA\n premul(texelM);\n #endif\n\n gl_FragColor = texelM;\n}\n\n "},w.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")},w.EffectComposer=function(e,t,r){if(this.renderer=e,this.cameraAware=t||!1,void 0===r){var n={minFilter:w.LinearFilter,magFilter:w.LinearFilter,format:w.RGBAFormat,stencilBuffer:!0},i=e.getSize();r=new w.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===w.CopyShader&&console.error("THREE.EffectComposer relies on THREE.CopyShader"),this.copyPass=new w.ShaderPass(w.CopyShader)},(0,y.default)(w.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 w.ShaderMaterial({uniforms:{depthTexture:{value:null},NearFarBlurScale:{value:new w.Vector2(.5,.5)},cameraNearFar:{value:new w.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 w.ShaderMaterial({uniforms:{cocTexture:{value:null},depthTexture:{value:null},NearFarBlurScale:{value:new w.Vector2(.5,.5)},texSize:{value:new w.Vector2(.5,.5)},direction:{value:new w.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 w.ShaderMaterial({uniforms:{colorTexture:{value:null},cocTexture:{value:null},depthTexture:{value:null},texSize:{value:new w.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 w.ShaderMaterial({uniforms:{cocTexture:{value:null},colorTexture:{value:null},texSize:{value:new w.Vector2(.5,.5)},direction:{value:new w.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 w.ShaderMaterial({uniforms:{colorTexture:{value:null},blurTexture:{value:null},cocTexture:{value:null},depthTexture:{value:null},NearFarBlurScale:{value:new w.Vector2(.5,.5)},texSize:{value:new w.Vector2(.5,.5)},cameraNearFar:{value:new w.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}"})}}),w.IndexPass=function(e,t,r){w.Pass.call(this),this.camera=t,this.retrieveIdFunc=r||function(e){return e.uuid},this.meshMatMap={},this.indexColorScene=e},w.IndexPass.prototype=(0,y.default)((0,g.default)(w.Pass.prototype),{constructor:w.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 w.MeshBasicMaterial({color:"#"+i,side:w.DoubleSide}),e.meshMatMap[r]=n}}})}},render:function(e,t,r,n,i,a){if(this.indexColorScene){var o=a||this.camera;e.toneMapping=w.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)}}}),w.RenderPass=function(e,t,r,n,i){w.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===w.CopyShader&&console.error("THREE.SSAARenderPass relies on THREE.CopyShader"),this.overMaterial=new w.ShaderMaterial(w.CopyShader),this.overMaterial.uniforms=w.UniformsUtils.clone(this.overMaterial.uniforms),this.overMaterial.blending=w.NormalBlending,this.overMaterial.premultipliedAlpha=!0,this.overMaterial.transparent=!0,this.overMaterial.depthTest=!1,this.overMaterial.depthWrite=!1,this.camera2=new w.OrthographicCamera(-1,1,1,-1,0,1),this.scene2=new w.Scene,this.quad2=new w.Mesh(new w.PlaneGeometry(2,2),this.copyMaterial),this.quad2.frustumCulled=!1,this.scene2.add(this.quad2)},w.RenderPass.prototype=(0,y.default)((0,g.default)(w.Pass.prototype),{constructor:w.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.visibilityFunc),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.visibilityFunc)),this.clearColor&&e.setClearColor(l,u),this.scene.overrideMaterial=null,e.autoClear=s}}),w.MaskPass=function(e,t){w.Pass.call(this),this.scene=e,this.camera=t,this.clear=!0,this.needsSwap=!1,this.inverse=!1},w.MaskPass.prototype=(0,y.default)((0,g.default)(w.Pass.prototype),{constructor:w.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)}}),w.ClearMaskPass=function(){w.Pass.call(this),this.needsSwap=!1},w.ClearMaskPass.prototype=(0,g.default)(w.Pass.prototype),(0,y.default)(w.ClearMaskPass.prototype,{render:function(e,t,r,n,i){e.state.buffers.stencil.setTest(!1)}}),w.MultiPass=function(e,t,r){w.Pass.call(this),this.scene=t,this.camera=r,this.orthoScene=new w.Scene,this.orthoCamera=new w.OrthographicCamera(-1,1,1,-1,-.01,1e3);var n=new w.PlaneGeometry(2,2),i=new w.Mesh(n,this.currentMaterial);this.orthoScene.add(i),this.needsSwap=!1,this.normalRenderTarget=new w.WebGLRenderTarget(256,256,{minFilter:w.NearestFilter,magFilter:w.NearestFilter,format:w.RGBAFormat}),this.side=w.FrontSide,this.normalTexture=this.normalRenderTarget.texture,this.depthRenderTarget=new w.WebGLRenderTarget(256,256,{minFilter:w.NearestFilter,magFilter:w.NearestFilter,format:w.RGBAFormat}),this.depthTexture=this.depthRenderTarget.texture,this.depthTexture.depthPacking=w.RGBADepthPacking,this.visibilityFunc=function(e){return!e.material.transparent}},w.MultiPass.prototype=(0,y.default)((0,g.default)(w.Pass.prototype),{constructor:w.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;e.setClearColor(new w.Color(.5,.5,1),1),w.MaterialChanger.renderPassNormal(e,this.scene,o,this.normalRenderTarget,this.visibilityFunc),this.depthRenderTarget&&(e.setClearColor(new w.Color(1,1,1),1),w.MaterialChanger.renderPassDepth(e,this.scene,o,this.depthRenderTarget,this.visibilityFunc,{depthPacking:this.depthTexture.depthPacking})),e.autoClear=u,e.setClearColor(s),e.setClearAlpha(l)}}),w.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=w.FloatType:console.log("OIT Needs either Float or Half Float texture support, using general render"):s.type=w.HalfFloatType;!!o.get("WEBGL_depth_texture")||console.warn("OIT Needs support of Depth Texture"),r.transparency=w.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.accumulateRT=new w.WebGLRenderTarget(0,0,s),this.revealageRT=new w.WebGLRenderTarget(0,0,{type:w.UnsignedByteType}),this.depthTexture=new w.DepthTexture,this.accumulateRT.depthTexture=this.depthTexture,this.revealageRT.depthTexture=this.depthTexture,this.mergeRT=new w.WebGLRenderTarget(0,0),this.mergeMaterial=new w.ShaderMaterial({uniforms:{accumulationTexture:{value:null},revealageTexture:{value:null}},vertexShader:"\nvarying vec2 vUv;\nvoid main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}\n ",fragmentShader:"\nvarying vec2 vUv;\nuniform sampler2D accumulationTexture;\nuniform sampler2D revealageTexture;\nvoid main() {\n vec4 accumulationColor = texture2D( accumulationTexture, vUv );\n vec4 revealage = texture2D( revealageTexture, vUv );\n vec3 finalColor = pow(vec3(accumulationColor.rgb / max(accumulationColor.a, 1e-5)), vec3(1.0));\n gl_FragColor = vec4( finalColor, 1. - revealage.r );\n gl_FragColor.rgb *= gl_FragColor.a;\n}\n "}),this.mergeMaterial.uniforms.accumulationTexture.value=this.accumulateRT.texture,this.mergeMaterial.uniforms.revealageTexture.value=this.revealageRT.texture,this.copyMaterial=new w.ShaderMaterial(w.CopyShader),this.copyMaterial.uniforms=w.UniformsUtils.clone(this.copyMaterial.uniforms),this.copyMaterial.depthTest=!1,this.copyMaterial.depthWrite=!1,this.copyMaterial.transparent=!0,this.copyMaterial.blending=w.NormalBlending,this.copyMaterial.premultipliedAlpha=!0,this.copyMaterial.needsUpdate=!0,void 0===w.CopyShader&&console.error("THREE.OITRenderPass relies on THREE.CopyShader"),this.PASS_TYPE_ACCUM=0,this.PASS_TYPE_REVEALAGE=1,this.BlendStates=[],this.BlendStates[this.PASS_TYPE_ACCUM]={blending:w.CustomBlending,blendEquation:w.AddEquation,blendSrc:w.OneFactor,blendDst:w.OneFactor,blendEquationAlpha:w.AddEquation,blendSrcAlpha:w.OneFactor,blendDstAlpha:w.OneFactor,premultipliedAlpha:!1},this.BlendStates[this.PASS_TYPE_REVEALAGE]={blending:w.CustomBlending,blendEquation:w.AddEquation,blendSrc:w.ZeroFactor,blendDst:w.OneMinusSrcAlphaFactor,blendEquationAlpha:w.AddEquation,blendSrcAlpha:w.OneFactor,blendDstAlpha:w.OneFactor,premultipliedAlpha:!1};var l=this.opaqueFilter=function(e,t){return!t.transparent};this.transparentFilter=function(e,t){return!l(e,t)},this.blendFactorsMap={},this.fxaaPass=new w.FXAAPass,this.expandPass=new w.ExpandPass,this.fxaaPreRT=new w.WebGLRenderTarget(1,1),this.traaEnabled=!1},w.OITRenderPass.prototype={constructor:w.OITRenderPass,setSize:function(e,t){this.accumulateRT.setSize(e,t),this.revealageRT.setSize(e,t),this.mergeRT.setSize(e,t),this.fxaaPass.setSize(e,t),this.expandPass.setSize(e,t),this.fxaaPreRT.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=e.getClearColor(),f=e.getClearAlpha(),d=e.getSize(),h=d.width,p=d.height;if(o.view&&this.traaEnabled){var m=o.view.offsetX,g=o.view.offsetY;o.setViewOffset(h,p,0,0,h,p)}e.autoClearColor=!1,e.autoClearDepth=!0,w.MaterialChanger.renderPassDepth(e,this.scene,o,this.accumulateRT,this.opaqueFilter),e.autoClearColor=!0,e.autoClearDepth=!1,this.scene.overrideMaterial=void 0,this.changeBlendState(e,this.PASS_TYPE_ACCUM),e.oitMode=0,e.setClearColor(0,0),e.render(this.scene,o,this.accumulateRT,!0,this.transparentFilter),this.restoreBlendState(e),this.changeBlendState(e,this.PASS_TYPE_REVEALAGE),e.oitMode=1,e.setClearColor(16777215,1),e.render(this.scene,o,this.revealageRT,!0,this.transparentFilter),this.restoreBlendState(e),e.setClearColor(0,0),e.autoClearColor=!0,e.autoClearDepth=!0,e.renderPass(this.mergeMaterial,this.mergeRT,!0),this.traaEnabled&&(this.expandPass.render(e,this.fxaaPreRT,this.mergeRT,n,i,o),this.fxaaPass.render(e,this.mergeRT,this.fxaaPreRT,n,i,o)),e.autoClear=!1,this.copyMaterial.uniforms.tDiffuse.value=this.mergeRT.texture,e.renderPass(this.copyMaterial,r,!1),e.autoClear=s,e.autoClearDepth=l,e.autoClearColor=u,e.setClearColor(c,f),e.oitMode=2,o.view&&this.traaEnabled&&o.setViewOffset(h,p,m,g,h,p)},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");for(var r=0==(0,p.default)(this.blendFactorsMap).length,n=this.BlendStates[t],i=[e.transparentObjects,e.sprites],a=0;a0){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 w.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=w.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=w.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=w.OutlinePass.BlurDirectionX,e.render(this.scene,this.orthoCamera,this.renderTargetBlurBuffer2,!0),this.separableBlurMaterial2.uniforms.colorTexture.value=this.renderTargetBlurBuffer2.texture,this.separableBlurMaterial2.uniforms.direction.value=w.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 w.ShaderMaterial({uniforms:{depthTexture:{value:null},cameraNearFar:{value:new w.Vector2(.5,.5)},textureMatrix:{value:new w.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 w.ShaderMaterial({uniforms:{maskTexture:{value:null},texSize:{value:new w.Vector2(.5,.5)},visibleEdgeColor:{value:new w.Vector3(1,1,1)},hiddenEdgeColor:{value:new w.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 w.ShaderMaterial({defines:{MAX_RADIUS:e},uniforms:{colorTexture:{value:null},texSize:{value:new w.Vector2(.5,.5)},direction:{value:new w.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 w.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})}}),w.OutlinePass.BlurDirectionX=new w.Vector2(1,0),w.OutlinePass.BlurDirectionY=new w.Vector2(0,1),w.ShaderPass=function(e,t){w.Pass.call(this),this.textureID=void 0!==t?t:"tDiffuse",e instanceof w.ShaderMaterial?(this.uniforms=e.uniforms,this.material=e):e&&(this.uniforms=w.UniformsUtils.clone(e.uniforms),this.material=new w.ShaderMaterial({defines:e.defines||{},uniforms:this.uniforms,vertexShader:e.vertexShader,fragmentShader:e.fragmentShader})),this.camera=new w.OrthographicCamera(-1,1,1,-1,0,1),this.scene=new w.Scene,this.quad=new w.Mesh(new w.PlaneBufferGeometry(2,2),null),this.quad.frustumCulled=!1,this.scene.add(this.quad)},w.ShaderPass.prototype=(0,y.default)((0,g.default)(w.Pass.prototype),{constructor:w.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)}}),w.SAOPass=function(e,t){w.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,void 0===w.SAOShader&&console.error("THREE.SAOPass relies on THREE.SAOShader"),void 0===w.CopyShader&&console.error("THREE.SAOPass relies on THREE.CopyShader"),this.depthMinifyMaterial=new w.ShaderMaterial(w.SAODepthMinifyShader),this.depthMinifyMaterial.uniforms=w.UniformsUtils.clone(this.depthMinifyMaterial.uniforms),this.depthMinifyMaterial.defines=(0,y.default)({},this.depthMinifyMaterial.defines),this.depthMinifyMaterial.blending=w.NoBlending,this.saoMaterial=new w.ShaderMaterial(w.SAOShader),this.saoMaterial.uniforms=w.UniformsUtils.clone(this.saoMaterial.uniforms),this.saoMaterial.defines=(0,y.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 w.ShaderMaterial(w.SAOBilaterialFilterShader),this.bilateralFilterMaterial.uniforms=w.UniformsUtils.clone(this.bilateralFilterMaterial.uniforms),this.bilateralFilterMaterial.defines=(0,y.default)({},this.bilateralFilterMaterial.defines),this.bilateralFilterMaterial.blending=w.NoBlending,this.bilateralFilterMaterial.premultipliedAlpha=!0,this.bilateralUpsamplerMaterial=this.getBilateralUpsamplerMaterial(),this.copyMaterial=new w.ShaderMaterial(w.CopyShader),this.copyMaterial.uniforms=w.UniformsUtils.clone(this.copyMaterial.uniforms),this.copyMaterial.uniforms.opacity.value=1,this.copyMaterial.blending=w.NoBlending,this.copyMaterial.premultipliedAlpha=!0,this.copyMaterial.transparent=!0,this.copyMaterial.depthTest=!1,this.copyMaterial.depthWrite=!1},w.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(w.Math.DEG2RAD*e.fov*.5)),r=new w.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 w.WebGLRenderTarget(s,l,{minFilter:w.LinearFilter,magFilter:w.LinearFilter,format:w.RGBAFormat}),this.saoRenderTargetFullRes=new w.WebGLRenderTarget(r.width,r.height,{minFilter:w.LinearFilter,magFilter:w.LinearFilter,format:w.RGBAFormat}),this.blurIntermediateRenderTarget=new w.WebGLRenderTarget(s,l,{minFilter:w.LinearFilter,magFilter:w.LinearFilter,format:w.RGBAFormat}),this.depth1RenderTarget=new w.WebGLRenderTarget(Math.ceil(s/2),Math.ceil(l/2),{minFilter:w.LinearFilter,magFilter:w.LinearFilter,format:w.RGBAFormat}),this.depth2RenderTarget=new w.WebGLRenderTarget(Math.ceil(s/4),Math.ceil(l/4),{minFilter:w.LinearFilter,magFilter:w.LinearFilter,format:w.RGBAFormat}),this.depth3RenderTarget=new w.WebGLRenderTarget(Math.ceil(s/8),Math.ceil(l/8),{minFilter:w.LinearFilter,magFilter:w.LinearFilter,format:w.RGBAFormat}),this.normalRenderTarget=new w.WebGLRenderTarget(s,l,{minFilter:w.LinearFilter,magFilter:w.LinearFilter,format:w.RGBAFormat}),this.normalRenderTargetFullRes=new w.WebGLRenderTarget(r.width,r.height,{minFilter:w.LinearFilter,magFilter:w.LinearFilter,format:w.RGBAFormat})),u||this.depthRenderTarget||(this.depthRenderTarget=new w.WebGLRenderTarget(s,l,{minFilter:w.NearestFilter,magFilter:w.NearestFilter,format:w.RGBAFormat}),this.depthRenderTargetFullRes=new w.WebGLRenderTarget(r.width,r.height,{minFilter:w.NearestFilter,magFilter:w.NearestFilter,format:w.RGBAFormat}));var c=function(e,t){return!e.isPlanarShadow&&!t.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=w.NoBlending,e.renderPass(this.copyMaterial,t,!0)),u)u.depthPacking=w.BasicDepthPacking;else{var p=e.getClearColor().getHex(),m=e.getClearAlpha();if(e.setClearColor(16777215,1),o.view){var g=o.view.offsetX,v=o.view.offsetY;o.setViewOffset(s,l,0,0,s,l)}w.MaterialChanger.renderPassDepth(e,this.scene,o,this.depthRenderTarget,c,{depthPacking:w.RGBADepthPacking}),e.setClearColor(16777215,1),1!==this.downSamplingRatio&&(w.MaterialChanger.renderPassDepth(e,this.scene,o,this.depthRenderTarget,c,{depthPacking:w.RGBADepthPacking}),e.setClearColor(p,m)),u=this.depthRenderTarget.texture,u.depthPacking=w.RGBADepthPacking,o.view&&o.setViewOffset(s,l,g,v,s,l)}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=w.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=w.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=w.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=w.NoBlending,void e.renderPass(this.copyMaterial,this.renderToScreen?null:t,!0);if(!this.implicitNormals){if(o.view){var g=o.view.offsetX,v=o.view.offsetY;o.setViewOffset(s,l,0,0,s,l)}var p=e.getClearColor().getHex(),m=e.getClearAlpha();e.setClearColor(new w.Color(.5,.5,1),1),w.MaterialChanger.renderPassNormal(e,this.scene,o,this.normalRenderTarget,c),1!==this.downSamplingRatio&&(e.setClearColor(new w.Color(.5,.5,1),1),w.MaterialChanger.renderPassNormal(e,this.scene,o,this.normalRenderTarget,c)),e.setClearColor(p,m),o.view&&o.setViewOffset(s,l,g,v,s,l)}if("normal"===this.outputOverride)return this.copyMaterial.uniforms.tDiffuse.value=this.normalRenderTarget.texture,this.copyMaterial.blending=w.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 w.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 w.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 w.Vector2(this.saoRenderTarget.width,this.saoRenderTarget.height),this.bilateralUpsamplerMaterial.uniforms.cameraNearFar.value=new w.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=w.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=w.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 w.ShaderMaterial({uniforms:{inputTexture:{value:null},NormalTextureFullRes:{value:null},DepthTextureFullRes:{value:null},NormalTextureHalfRes:{value:null},DepthTextureHalfRes:{value:null},texSize:{value:new w.Vector2(.5,.5)},cameraNearFar:{value:new w.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}"})}},w.SAO2Pass=function(e,t){w.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===w.SAO2Shader&&console.error("THREE.SAO2Pass relies on THREE.SAO2Shader"),void 0===w.CopyShader&&console.error("THREE.SAO2Pass relies on THREE.CopyShader"),this.depthMinifyMaterial=new w.ShaderMaterial(w.SAO2DepthMinifyShader),this.depthMinifyMaterial.uniforms=w.UniformsUtils.clone(this.depthMinifyMaterial.uniforms),this.depthMinifyMaterial.defines=(0,y.default)({},this.depthMinifyMaterial.defines),this.depthMinifyMaterial.blending=w.NoBlending,this.saoMaterial=new w.ShaderMaterial(w.SAO2Shader),this.saoMaterial.uniforms=w.UniformsUtils.clone(this.saoMaterial.uniforms),this.saoMaterial.defines=(0,y.default)({},this.saoMaterial.defines),this.saoMaterial.defines.DIFFUSE_TEXTURE=0,this.saoMaterial.defines.MODE=2,this.bilateralFilterMaterial=new w.ShaderMaterial(w.SAO2BilaterialFilterShader),this.bilateralFilterMaterial.uniforms=w.UniformsUtils.clone(this.bilateralFilterMaterial.uniforms),this.bilateralFilterMaterial.defines=(0,y.default)({},this.bilateralFilterMaterial.defines),this.bilateralFilterMaterial.blending=w.NoBlending,this.bilateralFilterMaterial.premultipliedAlpha=!0,this.copyMaterial=new w.ShaderMaterial(w.CopyShader),this.copyMaterial.uniforms=w.UniformsUtils.clone(this.copyMaterial.uniforms),this.copyMaterial.uniforms.opacity.value=1,this.copyMaterial.blending=w.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},w.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(w.Math.DEG2RAD*e.fov*.5));new w.Vector2(r/e.aspect,r);this.saoMaterial.uniforms.randomSeed.value=Math.random(),this.saoMaterial.uniforms.worldToScreenRatio.value=new w.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 w.WebGLRenderTarget(s,l,{minFilter:w.LinearFilter,magFilter:w.LinearFilter,format:w.RGBAFormat}),this.blurIntermediateRenderTarget=new w.WebGLRenderTarget(s,l,{minFilter:w.NearestFilter,magFilter:w.NearestFilter,format:w.RGBAFormat}),this.depth1RenderTarget=new w.WebGLRenderTarget(Math.ceil(s/4),Math.ceil(l/4),{minFilter:w.LinearFilter,magFilter:w.LinearFilter,format:w.RGBAFormat}),this.depth2RenderTarget=new w.WebGLRenderTarget(Math.ceil(s/8),Math.ceil(l/8),{minFilter:w.LinearFilter,magFilter:w.LinearFilter,format:w.RGBAFormat}),this.depth3RenderTarget=new w.WebGLRenderTarget(Math.ceil(s/16),Math.ceil(l/16),{minFilter:w.LinearFilter,magFilter:w.LinearFilter,format:w.RGBAFormat}),this.depth4RenderTarget=new w.WebGLRenderTarget(Math.ceil(s/32),Math.ceil(l/32),{minFilter:w.LinearFilter,magFilter:w.LinearFilter,format:w.RGBAFormat}),this.depth5RenderTarget=new w.WebGLRenderTarget(Math.ceil(s/64),Math.ceil(l/64),{minFilter:w.LinearFilter,magFilter:w.LinearFilter,format:w.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=w.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!==w.BasicDepthPacking,this.depthMIPs&&this.depthTexture.depthPacking!==w.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 w.Vector2(1,0):new w.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 w.Vector2(0,1):new w.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=w.MultiplyBlending,this.copyMaterial.premultipliedAlpha=!0,e.renderPass(this.copyMaterial,this.renderToScreen?null:t,!1)),e.autoClear=f,e.setClearColor(u),e.setClearAlpha(c)}},w.SSAARenderPass=function(e,t,r,n){w.Pass.call(this),this.scene=e,this.camera=t,this.sampleLevel=4,this.cameraJitter=new w.CameraJitter,this.unbiased=!0,this.needsSwap=!1,this.clearColor=void 0!==r?r:0,this.clearAlpha=void 0!==n?n:0,void 0===w.CopyShader&&console.error("THREE.SSAARenderPass relies on THREE.CopyShader"),this.overMaterial=new w.ShaderMaterial(w.CopyShader),this.overMaterial.uniforms=w.UniformsUtils.clone(this.overMaterial.uniforms),this.overMaterial.blending=w.NormalBlending,this.overMaterial.premultipliedAlpha=!0,this.overMaterial.transparent=!0,this.overMaterial.depthTest=!1,this.overMaterial.depthWrite=!1,this.addMaterial=new w.ShaderMaterial(w.CopyShader),this.addMaterial.uniforms=w.UniformsUtils.clone(this.addMaterial.uniforms),this.addMaterial.blending=w.AdditiveBlending,this.addMaterial.premultipliedAlpha=!0,this.addMaterial.transparent=!0,this.addMaterial.depthTest=!1,this.addMaterial.depthWrite=!1,this.camera2=new w.OrthographicCamera(-1,1,1,-1,0,1),this.scene2=new w.Scene,this.quad2=new w.Mesh(new w.PlaneGeometry(2,2),this.copyMaterial),this.quad2.frustumCulled=!1,this.scene2.add(this.quad2),this.visibilityFunc=function(e){return!e.material.isGemMaterial}},w.SSAARenderPass.prototype=(0,y.default)((0,g.default)(w.Pass.prototype),{constructor:w.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 w.WebGLRenderTarget(r.width,r.height,{minFilter:w.NearestFilter,magFilter:w.NearestFilter,format:w.RGBAFormat,type:w.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=this.cameraJitter.numJitterSamples,f=1/c;this.addMaterial.uniforms.tDiffuse.value=this.sampleRenderTarget.texture;var d=r.width,h=r.height;e.setClearColor(0,0);var p=e.ditherScale;this.unbiased&&(e.ditherScale=c);for(var m=0;m1&&(g=1/255*((m+.5)/c-.5)),this.addMaterial.uniforms.opacity.value=v,this.addMaterial.uniforms.offset.value=g,e.render(this.scene,o,this.sampleRenderTarget,!0,this.visibilityFunc),e.renderPass(this.addMaterial,t,0===m)}this.cameraJitter.clear(o),e.ditherScale=p,this.overMaterial.uniforms.tDiffuse.value=t.texture,e.setClearColor(this.clearColor,this.clearAlpha),e.renderPass(this.overMaterial,this.renderToScreen?null:r,this.clear),e.autoClear=s,e.setClearColor(l,u)}}),w.SparklePass=function(e,t,r,n){w.Pass.call(this),this.camera=e,this.worldSizeOfSparkle=r,this.sparkleTexture=n,this.sparkleScene=new w.Scene,this.sparkles=[],this.gems={},this.needsSwap=!0,this.noiseTexture=new w.WebGLRenderTarget(256,256,{minFilter:w.LinearFilter,magFilter:w.LinearFilter,format:w.RGBAFormat,name:"Sparkle Noise Texture"});var i=new w.ShaderMaterial(w.NoiseShader);i.uniforms=w.UniformsUtils.clone(i.uniforms),i.blending=w.NoBlending,i.premultipliedAlpha=!0,i.transparent=!0,i.depthTest=!1,i.depthWrite=!1,i.needsUpdate=!0,t.renderPass(i,this.noiseTexture,!0),this.copyMaterial=new w.ShaderMaterial(w.CopyShader),this.copyMaterial.uniforms=w.UniformsUtils.clone(this.copyMaterial.uniforms),this.copyMaterial.uniforms.opacity.value=1,this.copyMaterial.blending=w.NoBlending,this.copyMaterial.premultipliedAlpha=!0,this.copyMaterial.transparent=!0,this.copyMaterial.depthTest=!1,this.copyMaterial.depthWrite=!1},w.SparklePass.prototype=(0,y.default)((0,g.default)(w.Pass.prototype),{constructor:w.SparklePass,setSparkleTexture:function(e){this.sparkleTexture=e},setWorldSizeOfSparkles:function(e){this.worldSizeOfSparkle=e},updateScene:function(e){},addGemstone:function(e,t,r){if(this.sparkleTexture&&!this.gems[t.uuid]){var n=[],i=new w.Object3D,a=new w.Sparkle(this.sparkleTexture),o=new w.Vector3,s=new w.Quaternion,l=new w.Vector3;t.matrixWorld.decompose(o,s,l),a.mesh.scale.set(1,1,1).divide(l),a.setScale(this.worldSizeOfSparkle),this.noiseTexture&&(a.material.uniforms.noiseTexture.value=this.noiseTexture.texture);var u=new w.Vector3;if(e instanceof w.BufferGeometry)for(var c=e.attributes.position.array,f=c.length/3-1,d=0;d","varying vec2 vUv;","uniform sampler2D currentBeauty;","uniform sampler2D previousBeauty;","uniform sampler2D transparentBeauty;","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;","uniform vec2 jitterOffset;","#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));","float a = clamp(p.a, aabb_min.a, aabb_max.a);","if (mv_unit > 1.0) ","return vec4((p_clip + v_clip / mv_unit).rgb, a);","else ","return vec4(p.rgb, a);","}","bool calcMinMax(vec4[9] colors, vec4[9] transp, int count, vec4 truth, inout vec4 cMin, inout vec4 cMax) {","cMin = vec4(2,2,2,2);","cMax = vec4(-2,-2,-2,-2);","bool foundColor = false;","bool foundAlpha = false;","bool centerTransparent = (truth.a > EPSILON);","for(int i = 0; i < 9; i++) {","if(i >= count) break;","bool pixelTransparent = (transp[i].a > EPSILON);","if(centerTransparent == pixelTransparent) {","vec4 min_ = min(cMin, colors[i]);","vec4 max_ = max(cMax, colors[i]);","foundAlpha = true;","if(colors[i].a > .5) {","cMin = min_;","cMax = max_;","foundColor = true;","} else {","cMin.a = min_.a;","cMax.a = max_.a;","}","}","}","return foundColor;","}","void premul(inout vec4 c) {","c.rgb *= c.a;","}","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 = unpackRGToDepth(value.xy);","float vy = unpackRGToDepth(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;","vec2 texelSize = 1./textureSize;","vec4 currentColor = texture2D(currentBeauty, uv - 0.*jitterOffset * texelSize);","premul(currentColor);","vec2 lookBackUV = uv - screenSpaceVelocity;","vec4 previousColor = texture2D(previousBeauty, lookBackUV);","const vec3 offset = vec3(1., -1., 0.);","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 = 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 ttl = texture2D(transparentBeauty, uv + offset.yx * texelSize);","vec4 ttc = texture2D(transparentBeauty, uv + offset.zx * texelSize);","vec4 ttr = texture2D(transparentBeauty, uv + offset.xx * texelSize);","vec4 tml = texture2D(transparentBeauty, uv + offset.yz * texelSize);","vec4 tmc = texture2D(transparentBeauty, uv);","vec4 tmr = texture2D(transparentBeauty, uv + offset.xz * texelSize);","vec4 tbl = texture2D(transparentBeauty, uv + offset.yy * texelSize);","vec4 tbc = texture2D(transparentBeauty, uv + offset.zy * texelSize);","vec4 tbr = texture2D(transparentBeauty, uv + offset.xy * texelSize);","vec4 cmin, cmax, cmin5, cmax5;","vec4 cneighbors[9];","cneighbors[0] = cmc;","cneighbors[1] = ctc;","cneighbors[2] = cbc;","cneighbors[3] = cml;","cneighbors[4] = cmr;","cneighbors[5] = ctl;","cneighbors[6] = ctr;","cneighbors[7] = cbl;","cneighbors[8] = cbr;","vec4 tneighbors[9];","tneighbors[0] = tmc;","tneighbors[1] = ttc;","tneighbors[2] = tbc;","tneighbors[3] = tml;","tneighbors[4] = tmr;","tneighbors[5] = ttl;","tneighbors[6] = ttr;","tneighbors[7] = tbl;","tneighbors[8] = tbr;","if(!calcMinMax(cneighbors, tneighbors, 9, tmc, cmin, cmax))","return currentColor;","if(calcMinMax(cneighbors, tneighbors, 5, tmc, cmin5, cmax5)) {","cmin = (cmin + cmin5) * .5;","cmax = (cmax + cmax5) * .5;","}","vec4 clampedPreviousColor =clip_aabb(cmin, cmax, previousColor);","premul(clampedPreviousColor);","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 );","if( mode == MODE_MOVING ) {","return mix(currentColor, clampedPreviousColor, k_feedback);","}","else if( mode == MODE_STATIC ) {","return mix(currentColor, previousColor, 1.0 - pow( minSampleWeight, 0.75 ) );","}","else { // mode == MODE_RESET","return currentColor;","}","}","void main() {","vec2 screenSpaceVelocity = getScreenSpaceVelocity( vUv );","gl_FragColor = calculateTAA(vUv, screenSpaceVelocity);","}"].join("\n")})}(),this.currentMaterial=this.superSampleTRAAMaterial;var n=new w.PlaneGeometry(2,2),i=new w.Mesh(n,this.currentMaterial);this.orthoScene.add(i),this.oldClearColor=new w.Color,this.oldClearAlpha=1,this.needsSwap=!1,void 0===w.CopyShader&&console.error("THREE.TRAAPass relies on THREE.CopyShader");var a=w.CopyShader;this.copyUniforms=w.UniformsUtils.clone(a.uniforms),this.copyMaterial=new w.ShaderMaterial({uniforms:this.copyUniforms,vertexShader:a.vertexShader,fragmentShader:a.fragmentShader,transparent:!1,depthWrite:!1,blending:w.NoBlending});var o={minFilter:w.LinearFilter,magFilter:w.LinearFilter,format:w.RGBAFormat,stencilBuffer:!0};this.accumulatedBeautyRenderTarget=new w.WebGLRenderTarget(256,256,o),this.transparentRT=new w.WebGLRenderTarget(0,0,o),this.previousProjectionViewMatrix=new w.Matrix4,this.currentProjectionViewMatrix=new w.Matrix4,this.projectionMatrix=new w.Matrix4,this.projectionMatrix.copy(this.camera.projectionMatrix),this.numSamplesPerAccumulation=16,this.staticMode=!1,this.depthTexture=null,this.visibilityFunc=function(e,t){return!t.transparent},this.depthMaterial=new w.ShaderMaterial({defines:[],uniforms:[],side:w.DoubleSide,vertexShader:"\n void main() {\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.);\n }",fragmentShader:"\n void main() {\n gl_FragColor = vec4(0);\n }"})},w.TRAAPass.prototype=(0,y.default)((0,g.default)(w.Pass.prototype),{constructor:w.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.transparentRT.setSize(e,t),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.visibilityFunc),this.scene.overrideMaterial=null,e.autoClear=s,e.setClearColor(a),e.setClearAlpha(o)},render:function(e,t,r,n,i,a){var o=this,s=a||this.camera;this.oldClearColor=e.getClearColor().getHex(),this.oldClearAlpha=e.getClearAlpha();var l=e.autoClear,u=e.autoClearDepth,c=t.width,f=t.height;if(!this.velocityRenderTarget){var d={minFilter:w.LinearFilter,magFilter:w.LinearFilter,format:w.RGBAFormat};this.velocityRenderTarget=new w.WebGLRenderTarget(c,f,d)}this.currentMaterial=this.superSampleTRAAMaterial,this.currentProjectionViewMatrix.multiplyMatrices(this.projectionMatrix,s.matrixWorldInverse),this.oldClearColor=e.getClearColor().getHex(),this.oldClearAlpha=e.getClearAlpha();var l=e.autoClear,u=e.autoClearDepth,h=e.autoClearColor;e.autoClear=!1,e.setClearColor(new w.Color(0,0,0),0),w.MaterialChanger.renderPassVelocity(e,this.scene,s,this.velocityRenderTarget,this.visibilityFunc,this.currentProjectionViewMatrix,this.previousProjectionViewMatrix),this.scene.traverse(function(e){e instanceof w.Object3D&&e.matrixWorldPrevious.copy(e.matrixWorld)}),e.autoClearColor=!0,e.autoClearDepth=!0,e.renderOverride(this.depthMaterial,this.scene,s,this.transparentRT,!0,this.visibilityFunc),e.render(this.scene,s,this.transparentRT,!1,function(e,t){return!o.visibilityFunc(e,t)}),s.view&&this.currentMaterial.uniforms.jitterOffset.value.set(s.view.offsetX,s.view.offsetY),this.currentMaterial.uniforms.transparentBeauty.value=this.transparentRT.texture,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(s.matrixWorld),this.currentMaterial.uniforms.cameraNearFar.value.copy(new w.Vector2(s.near,s.far)),this.currentMaterial.uniforms.textureSize.value.copy(new w.Vector2(c,f)),this.currentMaterial.uniforms.minSampleWeight.value=1/this.numSamplesPerAccumulation,this.orthoScene.overrideMaterial=this.currentMaterial,e.autoClearDepth=!1,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),e.render(this.orthoScene,this.orthoCamera,r,!0),this.orthoScene.overrideMaterial=null,e.setClearColor(this.oldClearColor,this.oldClearAlpha),e.autoClear=l,e.autoClearColor=h,e.autoClearDepth=u,this.previousProjectionViewMatrix.copy(this.currentProjectionViewMatrix)}}),w.UnrealBloomPass=function(e,t,r,n){w.Pass.call(this),this.strength=void 0!==t?t:1,this.radius=r,this.threshold=n,this.resolution=void 0!==e?new w.Vector2(e.x,e.y):new w.Vector2(256,256);var i={minFilter:w.LinearFilter,magFilter:w.LinearFilter,format:w.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 w.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 w.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}"})}}),w.UnrealBloomPass.BlurDirectionX=new w.Vector2(1,0),w.UnrealBloomPass.BlurDirectionY=new w.Vector2(0,1),w.RenderTargetPass=function(e,t,r,n,i){w.Pass.call(this),this.scene=e,this.camera=t,this.renderOver=!1,this.overrideMaterial=r,this.clearColor=n||new w.Color(1,1,1),this.clearAlpha=void 0!==i?i:0,this.autoClearColor=!0,this.autoClearDepth=!0,this.autoClearColorRT=!0,this.autoClearDepthRT=!0,void 0===w.CopyShader&&console.error("THREE.SSAARenderPass relies on THREE.CopyShader"),this.overMaterial=new w.ShaderMaterial(w.CopyShader),this.overMaterial.uniforms=w.UniformsUtils.clone(this.overMaterial.uniforms),this.overMaterial.blending=w.NormalBlending,this.overMaterial.premultipliedAlpha=!0,this.overMaterial.transparent=!0,this.overMaterial.depthTest=!1,this.overMaterial.depthWrite=!1,this.renderTarget=null,this.renderToScreen=!1,this.renderToBuffer=!0,this.needsSwap=!1,this.width=this.height=0,this.copyMaterial=new w.ShaderMaterial(w.CopyShader),this.copyMaterial.uniforms=w.UniformsUtils.clone(this.copyMaterial.uniforms),this.copyMaterial.transparent=!0,this.copyMaterial.depthWrite=!1,this.copyMaterial.depthTest=!1,this.copyMaterial.premultipliedAlpha=!0,this.copyMaterial.needsUpdate=!0,this.copyMaterial.blending=w.NormalBlending,this.depthMaterial=new w.ShaderMaterial({defines:[],uniforms:[],side:w.DoubleSide,vertexShader:"\n void main() {\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.);\n }",fragmentShader:"\n void main() {\n gl_FragColor = vec4(0);\n }"})},w.RenderTargetPass.prototype=(0,y.default)((0,g.default)(w.Pass.prototype),{constructor:w.RenderTargetPass,setSize:function(e,t){this.width=e,this.height=t,this.renderTarget&&this.renderTarget.setSize(e,t)},useRT:function(){return this.renderTarget||(this.renderTarget=new w.WebGLRenderTarget(this.width,this.height)),this.renderTarget},render:function(e,t,r,n,i,a){var o=a||this.camera;this.needsSwap||(t=r),this.needsSwap&&(this.copyMaterial.uniforms.tDiffuse.value=r.texture,e.renderPass(this.copyMaterial,t,!0));var s=e.autoClear,l=e.autoClearDepth,u=e.autoClearColor,c=e.getClearColor(),f=e.getClearAlpha();e.autoClear=!1,e.setClearColor(this.clearColor,this.clearAlpha);var d=this.visibilityFunc;this.depthOnly&&(d=function(e,t){return!(this.visibilityFunc&&!this.visibilityFunc(e,t))&&(this.depthMaterial.side=e.material.side,!0)}),this.renderTarget?(this.autoClearColorRT||this.autoClearDepthRT?(e.setRenderTarget(this.renderTarget),e.clear(this.autoClearColorRT,this.autoClearDepthRT)):r&&(this.overMaterial.uniforms.tDiffuse.value=r.texture,e.renderPass(this.overMaterial,this.renderTarget,!1)),this.depthOnly&&this.changeSide(e),e.renderOverride(this.overrideMaterial,this.scene,o,this.renderTarget,!1,d),this.depthOnly&&this.restoreSide(e),(this.renderToScreen||t&&this.renderToBuffer)&&(e.autoClearColor=this.autoClearColor,e.autoClearDepth=this.autoClearDepth,this.overMaterial.uniforms.tDiffuse.value=this.renderTarget.texture,e.renderPass(this.overMaterial,this.renderToScreen?null:t,!0))):(e.autoClearColor=this.autoClearColor,e.autoClearDepth=this.autoClearDepth,e.renderOverride(this.depthOnly?this.depthMaterial:this.overrideMaterial,this.scene,o,this.renderToScreen?null:t,!0,d)),e.setClearColor(c,f),e.autoClear=s,e.autoClearDepth=l,e.autoClearColor=u}}),w.RefractiveGlassPass=function(e,t,r){w.Pass.call(this),this.camera=t,this.originalScene=e,this.copyMaterial=new w.ShaderMaterial(w.CopyShader),this.copyMaterial.uniforms=w.UniformsUtils.clone(this.copyMaterial.uniforms),this.copyMaterial.transparent=!0,this.copyMaterial.depthWrite=!1,this.copyMaterial.depthTest=!1,this.depthNormalPeeler=new w.DepthNormalPeeler(r),this.needsSwap=!1,this.numPasses=4,this.lqFallback=!1;for(var n=["WEBGL_color_buffer_float","OES_texture_float"],i=0;i\n\nvarying vec4 viewPosition;\nvarying vec3 viewNormal;\n\nvoid main() {\n viewNormal = transformDirection(normal, modelViewMatrix);\n viewPosition = modelViewMatrix * vec4( position, 1.0 );\n gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}",fragmentShader:"\n#include \n#include \n\nvarying vec4 viewPosition;\nvarying vec3 viewNormal;\nuniform sampler2D previousTextureDepth;\nuniform int passNumber;\nuniform vec2 windowSize;\nuniform vec2 cameraNearFar;\n\nfloat unmix(float a, float b, float x) { return (x-a) / (b-a);\n}\n\nfloat getDepth(vec4 texel) {\n /*\n return -mix( cameraNearFar.x, cameraNearFar.y, unpackRGBToDepth(\n texel.xyz\n ) );\n */\n return texel.z;\n}\n\nvec3 packDepth() {\n //return packDepthToRGB(unmix(cameraNearFar.x, cameraNearFar.y, -viewPosition.z));\n return vec3(viewPosition.z, 0, 0);\n}\n\nvoid main() {\n\n float layerOut;\n vec2 normal;\n\n if( passNumber == 0 ) {\n layerOut = .25;\n } else {\n vec4 previousValues = texture2D( previousTextureDepth, gl_FragCoord.xy/windowSize );\n float previousDepth = getDepth( previousValues );\n\n if( (viewPosition.z / previousDepth) > 1.001 ) {\n layerOut = previousValues.w + .25;\n } else\n discard;\n }\n\n vec3 normalizedNormal = normalize(viewNormal);\n if( dot( normalize( viewPosition.xyz ), normalizedNormal ) > 0.0 ) normalizedNormal *= -1.0;\n normal = normalizedNormal.xy;\n\n gl_FragColor = vec4(\n normal,\n packDepth().x,\n layerOut\n );\n}\n"})},render:function(e,t,r,n){this.oldClearColor.copy(e.getClearColor()),this.oldClearAlpha=e.getClearAlpha();var i=e.autoClear,a=e.autoClearDepth;e.autoClear=!0,t.overrideMaterial=this.peelMaterial,this.peelMaterial.uniforms.previousTextureDepth.value=null;for(var o=0;o0?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 v(e){X.set(e.touches[0].pageX,e.touches[0].pageY)}function y(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 x(e){q.set(e.touches[0].pageX,e.touches[0].pageY),Y.subVectors(q,X);var t=D.domElement===document?D.domElement.body:D.domElement;i(2*Math.PI*Y.x/t.clientWidth*D.rotateSpeed),a(2*Math.PI*Y.y/t.clientHeight*D.rotateSpeed),X.copy(q),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=B.ROTATE}else if(e.button===D.mouseButtons.ZOOM){if(!1===D.enableZoom)return;u(e),U=B.DOLLY}else if(e.button===D.mouseButtons.PAN){if(!1===D.enablePan)return;c(e),U=B.PAN}U!==B.NONE&&(document.addEventListener("mousemove",E,!1),document.addEventListener("mouseup",P,!1),D.dispatchEvent(V))}}function E(e){if(!1!==D.enabled)if(e.preventDefault(),U===B.ROTATE){if(!1===D.enableRotate)return;f(e)}else if(U===B.DOLLY){if(!1===D.enableZoom)return;d(e)}else if(U===B.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(F),U=B.NONE)}function A(e){!1===D.enabled||!1===D.enableZoom||U!==B.NONE&&U!==B.ROTATE||(e.preventDefault(),e.stopPropagation(),m(e),D.dispatchEvent(V),D.dispatchEvent(F))}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;v(e),U=B.TOUCH_ROTATE;break;case 2:if(!1===D.enableZoom)return;y(e),U=B.TOUCH_DOLLY;break;case 3:if(!1===D.enablePan)return;b(e),U=B.TOUCH_PAN;break;default:U=B.NONE}U!==B.NONE&&D.dispatchEvent(V)}}function R(e){if(!1!==D.enabled)switch(e.preventDefault(),e.stopPropagation(),e.touches.length){case 1:if(!1===D.enableRotate)return;if(U!==B.TOUCH_ROTATE)return;x(e);break;case 2:if(!1===D.enableZoom)return;if(U!==B.TOUCH_DOLLY)return;_(e);break;case 3:if(!1===D.enablePan)return;if(U!==B.TOUCH_PAN)return;M(e);break;default:U=B.NONE}}function O(e){!1!==D.enabled&&(S(e),D.dispatchEvent(F),U=B.NONE)}function L(e){e.preventDefault()}this.object=e,this.domElement=void 0!==t?t:document,this.enabled=!0,this.target=new w.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:w.MOUSE.LEFT,ZOOM:w.MOUSE.MIDDLE,PAN:w.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(N),D.update(),U=B.NONE},this.update=function(){var t=new w.Vector3,n=(new w.Quaternion).setFromUnitVectors(e.up,new w.Vector3(0,1,0)),a=n.clone().inverse(),o=new w.Vector3,s=new w.Quaternion;return function(){var e=D.object.position;return t.copy(e).sub(D.target),t.applyQuaternion(n),z.setFromVector3(t),D.autoRotate&&U===B.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(N),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,N={type:"change"},V={type:"start"},F={type:"end"},B={NONE:-1,ROTATE:0,DOLLY:1,PAN:2,TOUCH_ROTATE:3,TOUCH_DOLLY:4,TOUCH_PAN:5},U=B.NONE,k=1e-6,z=new w.Spherical,j=new w.Spherical,G=1,H=new w.Vector3,W=!1,X=new w.Vector2,q=new w.Vector2,Y=new w.Vector2,Z=new w.Vector2,J=new w.Vector2,K=new w.Vector2,Q=new w.Vector2,$=new w.Vector2,ee=new w.Vector2,te=function(){var e=new w.Vector3;return function(t,r){e.setFromMatrixColumn(r,0),e.multiplyScalar(-t),H.add(e)}}(),re=function(){var e=new w.Vector3;return function(t,r){e.setFromMatrixColumn(r,1),e.multiplyScalar(t),H.add(e)}}(),ne=function(){var e=new w.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 w.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()},w.OrbitControls.prototype=(0,g.default)(w.EventDispatcher.prototype),w.OrbitControls.prototype.constructor=w.OrbitControls,(0,d.default)(w.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}}}),w.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 w.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}},w.Color.prototype.toJSON=function(){return{r:this.r,g:this.g,b:this.b}},w.EXRLoader=function(e){this.manager=void 0!==e?e:w.DefaultLoadingManager},w.EXRLoader.prototype=(0,g.default)(w.DataTextureLoader.prototype),w.EXRLoader.prototype._parser=function(e){function t(e,t){for(var r=0,n=0;n>3]&1<<(7&n))&&(t[r++]=n);for(var i=r-1;r>r&(1<0;--t){var n=r+Z[t]>>1;Z[t]=r,r=n}for(var t=0;t0&&(e[t]=i|Z[i]++<<6)}}function a(e,t,r,a,o,s,l){for(var u=r,c=0,f=0;o<=s;o++){if(u.value-r.value>a)return!1;n(6,c,f,e,u);var d=Y.l;if(c=Y.c,f=Y.lc,l[o]=d,d==z){if(u.value-r.value>a)throw"Something wrong with hufUnpackEncTable";n(8,c,f,e,u);var h=Y.l+j;if(c=Y.c,f=Y.lc,o+h>s+1)throw"Something wrong with hufUnpackEncTable";for(;h--;)l[o++]=0;o--}else if(d>=k){var h=d-k+2;if(o+h>s+1)throw"Something wrong with hufUnpackEncTable";for(;h--;)l[o++]=0;o--}}i(l)}function o(e){return 63&e}function s(e){return e>>6}function l(e,t,r,n){for(;t<=r;t++){var i=s(e[t]),a=o(e[t]);if(i>>a)throw"Invalid table entry";if(a>V){var l=n[i>>a-V];if(l.len)throw"Invalid table entry";if(l.lit++,l.p){var u=l.p;l.p=new Array(l.lit);for(var c=0;c0;c--){var l=n[(i<>n,f=new Uint8Array([f])[0];if(l.value+f>c)return!1;for(var d=s[l.value-1];f-- >0;)s[l.value++]=d}else{if(!(l.value32767?t-65536:t}function p(e,t){var r=h(e),n=h(t),i=n,a=r+(1&i)+(i>>1),o=a,s=a-i;Q.a=o,Q.b=s}function m(e,t,r,n,i,a,o){for(var s,l=r>i?i:r,u=1;u<=l;)u<<=1;for(u>>=1,s=u,u>>=1;u>=1;){for(var c,f,d,h,m=0,g=m+a*(i-s),v=a*u,y=a*s,b=n*u,x=n*s;m<=g;m+=y){for(var w=m,_=m+n*(r-s);w<=_;w+=x){var M=w+b,S=w+v,T=S+b;p(t[w+e],t[S+e]),c=Q.a,d=Q.b,p(t[M+e],t[T+e]),f=Q.a,h=Q.b,p(c,f),t[w+e]=Q.a,t[M+e]=Q.b,p(d,h),t[S+e]=Q.a,t[T+e]=Q.b}if(r&u){var S=w+v;p(t[w+e],t[S+e]),c=Q.a,t[S+e]=Q.b,t[w+e]=c}}if(i&u)for(var w=m,_=m+n*(r-s);w<=_;w+=x){var M=w+b;p(t[w+e],t[M+e]),c=Q.a,t[M+e]=Q.b,t[w+e]=c}s=u,u>>=1}return m}function g(e,t,r,n,i,a,l,d,h,p){for(var m=0,g=0,v=d,y=(0,c.default)(i.value+(a+7)/8);i.value=V;){var b=m>>g-V&U,x=t[b];if(x.len)g-=x.len,f(x.lit,l,m,g,r,n,i,h,p,v),m=K.c,g=K.lc;else{if(!x.p)throw"hufDecode issues";var w;for(w=0;w=_&&s(e[x.p[w]])==(m>>g-_&(1<<_)-1)){g-=_,f(x.p[w],l,m,g,r,n,i,h,p,v),m=K.c,g=K.lc;break}}if(w==x.lit)throw"hufDecode issues"}}var M=8-a&7;for(m>>=M,g-=M;g>0;){var x=t[m<=F||d<0||d>=F)throw"Something wrong with HUF_ENCSIZE";var p=new Array(F),m=new Array(B);if(r(m),a(e,t,n,i-(n.value-c),f,d,p),h>8*(i-(n.value-c)))throw"Something wrong with hufUncompress";l(p,f,d,m),g(p,m,e,t,n,h,d,u,o,s)}function y(e,t,r){for(var n=0;n>10,r=1023&e;return(e>>15?-1:1)*(t?31===t?r?NaN:1/0:Math.pow(2,t-15)*(1+r/1024):r/1024*6103515625e-14)}function P(e,t){var r=e.getUint16(t.value,!0);return t.value+=X,r}function A(e,t,r,n){for(var i=r.value,a=[];r.value>3,V=14,F=65537,B=1<=N)throw"Something is wrong with PIZ_COMPRESSION BITMAP_SIZE";if(d<=h)for(var p=0;p(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\n\t\t\t\tvarying vec3 localPosition;\n\t\t\t\tuniform sampler2D equirectangularMap;\n\t\t\t\tuniform int i;\n\t\t\t\t\n\t\t\t\tvec2 EquirectangularSampleUV(vec3 v) {\n\t\t\t vec2 uv = vec2(atan(v.z, v.x), asin(v.y));\n\t\t\t uv *= vec2(0.1591, 0.3183); // inverse atan\n\t\t\t uv += 0.5;\n\t\t\t return uv;\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tvoid main() {\n\t\t\t\t\tvec3 v = normalize(localPosition);\n\t\t\t vec2 uv = vec2(atan(v.z, v.x), asin(v.y));\n\t\t\t uv *= vec2(0.1591, 0.3183); // inverse atan\n\t\t\t uv += 0.5;\n \t\t\tvec3 color = texture2D(equirectangularMap, uv).rgb;\n \t\t\t\n\t\t\t\t\tgl_FragColor = vec4( color, 1.0 );\n\t\t\t\t}",blending:w.NoBlending});return e.type="EquirectangularToCubeGenerator",e},dispose:function(){this.boxMesh.geometry.dispose(),this.boxMesh.material.dispose(),this.renderTarget.dispose()}},w.CombinedCamera=function(e,t,r,n,i){w.Camera.call(this),this.fov=r,this.far=i,this.near=n,this.left=-e/2,this.right=e/2,this.top=t/2,this.bottom=-t/2,this.aspect=e/t,this.zoom=1,this.focus=10,this.view=null,this.hyperfocusOffset=0,this.hyperfocusScale=.5,this.cameraO=new w.OrthographicCamera(this.left,this.right,this.top,this.bottom,this.near,this.far),this.cameraP=new w.PerspectiveCamera(this.fov,this.aspect,this.near,this.far),this.toPerspective()},w.CombinedCamera.prototype=(0,g.default)(w.Camera.prototype),w.CombinedCamera.prototype.constructor=w.CombinedCamera,w.CombinedCamera.prototype.toPerspective=function(){this.cameraP.near=this.near,this.cameraP.far=this.far,this.cameraP.aspect=this.aspect,this.cameraP.fov=this.fov,this.cameraP.zoom=this.zoom,this.cameraP.view=this.view,this.cameraP.focus=this.focus,this.cameraP.updateProjectionMatrix(),this.projectionMatrix=this.cameraP.projectionMatrix,this.inPerspectiveMode=!0,this.inOrthographicMode=!1},w.CombinedCamera.prototype.toOrthographic=function(){var e=this.fov,t=this.aspect,r=Math.tan(e*Math.PI/180/2)*(this.hyperfocusOffset+this.hyperfocusScale*(this.near+this.far)),n=r*t;this.cameraO.near=this.near,this.cameraO.far=this.far,this.cameraO.left=-n,this.cameraO.right=n,this.cameraO.top=r,this.cameraO.bottom=-r,this.cameraO.zoom=this.zoom,this.cameraO.view=this.view,this.cameraO.updateProjectionMatrix(),this.projectionMatrix=this.cameraO.projectionMatrix,this.inPerspectiveMode=!1,this.inOrthographicMode=!0},w.CombinedCamera.prototype.setSize=function(e,t){this.aspect=e/t,this.left=-e/2,this.right=e/2,this.top=t/2,this.bottom=-t/2},w.CombinedCamera.prototype.setFov=function(e){this.fov=e,this.inPerspectiveMode?this.toPerspective():this.toOrthographic()},w.CombinedCamera.prototype.copy=function(e){return w.Camera.prototype.copy.call(this,e),this.fov=e.fov,this.far=e.far,this.near=e.near,this.left=e.left,this.right=e.right,this.top=e.top,this.bottom=e.bottom,this.zoom=e.zoom,this.view=null===e.view?null:(0,y.default)({},e.view),this.aspect=e.aspect,this.hyperfocusOffset=e.hyperfocusOffset,this.hyperfocusScale=e.hyperfocusScale,this.cameraO.copy(e.cameraO),this.cameraP.copy(e.cameraP),this.inOrthographicMode=e.inOrthographicMode,this.inPerspectiveMode=e.inPerspectiveMode,this},w.CombinedCamera.prototype.setViewOffset=function(e,t,r,n,i,a){this.view={fullWidth:e,fullHeight:t,offsetX:r,offsetY:n,width:i,height:a},this.inPerspectiveMode?(this.aspect=e/t,this.toPerspective()):this.toOrthographic()},w.CombinedCamera.prototype.clearViewOffset=function(){this.view=null,this.updateProjectionMatrix()},w.CombinedCamera.prototype.updateProjectionMatrix=function(){this.inPerspectiveMode?this.toPerspective():(this.toPerspective(),this.toOrthographic())},w.CombinedCamera.prototype.setLens=function(e,t){void 0===t&&(t=35);var r=.5*t/(e*Math.max(this.cameraP.aspect,1)),n=2*w.Math.RAD2DEG*Math.atan(r);return this.setFov(n),n},w.CombinedCamera.prototype.setZoom=function(e){this.zoom=e,this.inPerspectiveMode?this.toPerspective():this.toOrthographic()},w.CombinedCamera.prototype.toFrontView=function(){this.rotation.x=0,this.rotation.y=0,this.rotation.z=0,this.position.x=0,this.position.y=0,this.position.z=-15},w.CombinedCamera.prototype.toBackView=function(){this.rotation.x=0,this.rotation.y=Math.PI,this.rotation.z=0,this.position.x=0,this.position.y=0,this.position.z=15},w.CombinedCamera.prototype.toLeftView=function(){this.rotation.x=0,this.rotation.y=-Math.PI/2,this.rotation.z=0,this.position.x=-15,this.position.y=0,this.position.z=0},w.CombinedCamera.prototype.toRightView=function(){this.rotation.x=0,this.rotation.y=Math.PI/2,this.rotation.z=0,this.position.x=15,this.position.y=0,this.position.z=0},w.CombinedCamera.prototype.toTopView=function(){this.rotation.x=-Math.PI/2,this.rotation.y=0,this.rotation.z=0,this.position.x=0,this.position.y=15,this.position.z=0},w.CombinedCamera.prototype.toBottomView=function(){this.rotation.x=Math.PI/2,this.rotation.y=0,this.rotation.z=0,this.position.x=0,this.position.y=-15,this.position.z=0},w.CombinedCamera.prototype.toPerspectiveView=function(){this.rotation.x=-Math.PI/4,this.rotation.y=-Math.PI/4,this.rotation.z=0,this.position.x=4,this.position.y=4,this.position.z=4},w.ParallaxBarrierEffect=function(e){var t=new w.OrthographicCamera(-1,1,1,-1,0,1),r=new w.Scene,n=new w.StereoCamera,i={minFilter:w.LinearFilter,magFilter:w.NearestFilter,format:w.RGBAFormat},a=new w.WebGLRenderTarget(512,512,i),o=new w.WebGLRenderTarget(512,512,i),s=new w.ShaderMaterial({uniforms:{mapLeft:{value:a.texture},mapRight:{value:o.texture},resolution:{value:new w.Vector2(512,512)}},vertexShader:["varying vec2 vUv;","void main() {"," vUv = vec2( uv.x, uv.y );"," gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );","}"].join("\n"),fragmentShader:["uniform sampler2D mapLeft;","uniform sampler2D mapRight;","uniform vec2 resolution;","varying vec2 vUv;","void main() {"," vec2 uv = vUv;"," if ( ( mod( gl_FragCoord.x + 1.0, 2.0 ) ) > 1.00 ) {"," gl_FragColor = texture2D( mapLeft, uv );"," } else {"," gl_FragColor = texture2D( mapRight, uv - vec2( resolution.x, 0 ) );"," }","}"].join("\n")}),l=new w.Mesh(new w.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)}},w.StereoEffect=function(e){var t=new w.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)}},w.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||(y=e.getPixelRatio(),g=e.getSize(),e.setPixelRatio(1),e.setSize(2*n,i,!1))}else t&&(e.setPixelRatio(y),e.setSize(g.width,g.height,v))}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 w.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 w.Vector3,h=new w.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(),v=!1,y=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},v=n,m.isPresenting){var i=s.getEyeParameters("left");e.setPixelRatio(1),e.setSize(2*i.renderWidth,i.renderHeight,!1)}else e.setPixelRatio(y),e.setSize(t,r,n)};var b=e.domElement,x=[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 w.Matrix4,S=new w.PerspectiveCamera;S.layers.enable(1);var T=new w.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:x,u=null!==y.rightBounds&&4===y.rightBounds.length?y.rightBounds:_}else l=x,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 b=s.getEyeParameters("left"),w=s.getEyeParameters("right");d.fromArray(b.offset),h.fromArray(w.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(b.fieldOfView,!0,r.near,r.far),T.projectionMatrix=o(w.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)}},w.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++}}}w.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 w.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)}}}},w.VRController.prototype=(0,g.default)(w.Object3D.prototype),w.VRController.prototype.constructor=w.VRController;var _=(i={blending:w.NormalBlending,side:w.DoubleSide,premultipliedAlpha:!0},(0,o.default)(i,"side",w.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 w.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);w.Sparkle=function(e){this.texture=e,this.geometry=new w.PlaneGeometry(1,1,0),this.material=new w.ShaderMaterial(_),this.material.uniforms=w.UniformsUtils.clone(_.uniforms),void 0!==this.texture&&(this.material.uniforms.sparkleTexture.value=e),this.mesh=new w.Mesh(this.geometry,this.material),this.rotationSpeedFactor=5},w.Sparkle.prototype={constructor:w.Sparkle,shallowCopy:function(){var e=new w.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)}},w.NormalCubeMapBaker=function(e,t,r){var n=new w.ShaderMaterial(w.GeometricNormalCaptureShader);n.blending=w.NoBlending;var i=t;i.computeBoundingSphere();var a=(new w.Matrix4).setPosition(i.boundingSphere.center.clone().negate()),o=1/i.boundingSphere.radius,s=(new w.Matrix4).makeScale(o,o,o),l=(new w.Matrix4).multiplyMatrices(s,a),u=new w.Vector3,c=new w.Quaternion,f=new w.Vector3;l.decompose(u,c,f);var d=new w.Mesh(i,n);d.position.copy(u),d.scale.copy(f);var h=new w.Scene;h.add(d);var p=e.extensions.get("OES_texture_float")&&e.extensions.get("OES_texture_float_linear"),m=new w.CubeCamera(.01,100,512);m.renderTarget.texture.generateMipmaps=!1,m.renderTarget.texture.magFilter=r?w.NearestFilter:w.LinearFilter,m.renderTarget.texture.minFilter=r?w.NearestFilter:w.LinearFilter,m.renderTarget.texture.format=w.RGBAFormat,m.renderTarget.texture.type=p&&!r?w.FloatType:w.UnsignedByteType,m.updateCubeMap(e,h),this.texture=m.renderTarget.texture},w.SHADOW_PLANE_STATE=function(){function e(){this.numShadowMipMaps=4,this.shadowMipMaps=[],this.tempRenderTargets=[],this.resolution=new w.Vector2(512,512);for(var e={minFilter:w.LinearFilter,magFilter:w.LinearFilter,format:w.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).a; float f2 = texture2D(shadowSampler2, vUv).a; float f3 = texture2D(shadowSampler3, vUv).a; float f4 = texture2D(shadowSampler4, vUv).a; 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(0), value );\n }"}),this.depthMaterial=new w.MeshDepthMaterial,this.depthMaterial.side=w.DoubleSide,this.depthMaterial.depthPacking=w.RGBADepthPacking,this.depthMaterial.blending=w.NoBlending,this.shadowProjectionMaterial=new w.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(0), 1. - diff);\n }"})}var t;return{getInstance:function(){return null==t&&(t=new e,t.constructor=null),t}}}(),w.ShadowPlane=function(e,t){this.resolution=e||new w.Vector2(512,512),this.shadowPlanePosition=new w.Vector3(0,0,0),this.shadowPlaneNormal=new w.Vector3(0,1,0),this.shadowPlaneSize=new w.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 w.WebGLRenderTarget(this.resolution.x,this.resolution.y),this.depthRT.texture.generateMipmaps=!1,this.shadowRT=new w.WebGLRenderTarget(this.resolution.x,this.resolution.y),this.shadowRT.texture.generateMipmaps=!1,this.camera=new w.OrthographicCamera,this.clipPlane=new w.Plane(new w.Vector3(0,1,0),0),this.originalClipPlane=this.clipPlane.clone(),this.falseClipPlane=new w.Plane(new w.Vector3(0,0,1),1e4);var r=w.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},w.ShadowPlane.prototype={constructor:w.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 w.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;r0];e===s.depthMatSet&&(n.length=2,n[1]=r);var i=e.getMaterial(n);i.alphaTest=t.alphaTest,i.usedSlotsVersion=-1;for(var a=["map","alphaMap","bumpMap","normalMap","displacementMap"],l=0;l=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(18);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,r){"use strict";t.__esModule=!0;var n=r(119),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){e.exports=function(e){return"object"==typeof e?null!==e:"function"==typeof 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){n.trackTiming("playerv2","Fetch Duration",r);var i=n.read(t);n.trackEvent("playerv2","Scene","Fetch Size",t.length);var a=Math.round(t.length/r);n.trackEvent("playerv2","Scene","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:xe}}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(c),clearTimeout(f))}if(a.getIn(["sceneGraph",e]))return ee.default.resolve(!0);if(r.threehub)return a.dispatch(m(e,r));var s=t,l="https://clara.io/api/scenes/"+e+"/published";l+="?wait="+(n?"true":"false"),r.pinned&&(l+="&pinned=true");var u=t?(0,de.fetchText)(t)(a):a.callApi({url:l,contentType:"text",types:["IGN","IGN",be],queryKey:"SCENE"+e,payload:e,onReadyStateChange:o,ignoreCache:!0,ignoreErrorMessage:i,responseURL:function(e){var t=e.split("/");s=t[t.length-1]}}),c=setTimeout(function(){"undefined"==typeof __SERVER_RENDER?a.error(new Error("Slow Load"),null,{sceneId:e}):console.log("Slow Load")},Fe),f=setTimeout(function(){a.error(new Error("Load Failure"),null,{sceneId:e})},Be);return a.dispatch(C(e)),a.dispatch({type:ve,payload:e}),u.then(function(t){return clearTimeout(c),clearTimeout(f),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,be],url:Ve+"/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=V(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 b(e){return function(t){t.get("sceneGraph");return t.dispatch(v(e,null,{threehub:!0})).then(function(){var r=t.getSocketApi();r&&y(t,r,e)})}}function x(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 N(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 V(e,t){function r(e){if(!o(n.nodes[e],n.evaluatedNodes[e]))return!1;a[e]=(0,J.default)({},n.nodes[e]);var t=a[e]&&a[e].children||[];return a[e].children=[].concat(t).filter(r),!0}var n=(0,ce.getEvalSceneGraph)(e),i=s(e),a={},o=t&&"function"==typeof t?t:function(){return!0};return r(i),e.write({id:i,meta:X(e),nodes:(0,Q.default)(a),assets:(0,de.getActiveAssets)(e),clips:e.getIn(["animation","clips"]),bufferClips:e.getIn(["animation","bufferClips"])})}function F(e){return{scene:e.get("sceneGraph").toJS(),assets:(0,de.getActiveAssets)(e).toJS()}}function B(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)v!==t){var w=void 0===g?u.clone().setZ(0):g,_=c.clone().setZ(0);t?l.push({min:b,max:v,minVertex:_,maxVertex:w}):l.push({min:v,max:b,minVertex:w,maxVertex:_}),g=_}else g=void 0;f=u,u=c,c=f,v=b}}return l.sort(n?o:a),l}},{key:"getAttachVector",value:function(e,t,r,n){var i=this,a=new x.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,d=!1,h=void 0;try{for(var p,g=(0,m.default)(o);!(f=(p=g.next()).done);f=!0){for(var v=p.value;u4&&void 0!==arguments[4]?arguments[4]:{},o=a.reverseIndices,f=void 0!==o&&o,d=a.lineSegments,h=void 0===d?2:d,p=[0],m=[],g=[],v=[],y=0,b=0,w=new x.Box3,M=null,S=0,E={x:0,y:0},P=0;P2&&(ie=c(ie,ne,i)),ie}},{key:"mergeShapeSets",value:function(t,r){var n=1,i=0,a=0,o=!0,s=!1,l=void 0;try{for(var u,c=(0,m.default)(t);!(o=(u=c.next()).done);o=!0){var f=u.value;n+=f.loopRangeOffsets.length-1,i+=f.loopValueIndices.length,a+=f.positions.length}}catch(e){s=!0,l=e}finally{try{!o&&c.return&&c.return()}finally{if(s)throw l}}for(var d={loopRangeOffsets:new Uint32Array(n),loopValueIndices:new Uint32Array(i),positions:new _.default(x.Vector3,a),holeOffsets:[]},p=0,g=0,v=0,y=0,b=0,w=new x.Vector3,M=0;M0)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 b(e,t){return e.getIn(["assets","assets",t,"hash"])}function x(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),["outputName","backgroundColor","threshold","turnPolicy","turdSize","alphaMax","longCurve","optTolerance","unit"].forEach(function(e){void 0!==t[e]&&i.append(e,t[e])}),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=n.type.match(/image\/(jpeg|png)/),a={glOption:1,originalBitmapFile:n.id};i&&(a.glBitmapFile=n.id);var o={name:n.name||e.name,type:"Image",parent:(0,Q.find)(r,{name:"Material Library"}),plugs:{Image:[["Image",a]],Properties:[["ImageProperties",{}]]}};return t.imageNodeId&&(o.id=t.imageNodeId),r.dispatch((0,K.addNode)(o)).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,successPayload:!0})}(e).then(i).then(a):function(e){var n=(0,F.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");var l=!1;if(t.targetFormat){var u=e.type.substring(e.type.lastIndexOf("/")+1),c="jpg"===t.targetFormat?"jpeg":t.targetFormat;l=c&&c!==u}return!l&&e.type.match(/image\/(jpeg|png)/)&&e.size<5e6?function(e){return r.dispatch(o({id:(0,Y.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 N,V=r(37),F=n(V),B=r(30),U=n(B),k=r(2),z=n(k),j=r(135),G=n(j),H=r(17),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.getOrFetchText=y,t.getHash=b,t.getUrl=x,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(35),q=r(64),Y=n(q),Z=r(50),J=n(Z),K=r(9),Q=r(4),$=r(67),ee=r(19),te=r(89),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,(N={},(0,W.default)(N,re,function(e,t){var r=t.id;return e.setIn(["assets",r],(0,X.Map)(t))}),(0,W.default)(N,ne,function(e,t){return e.deleteIn(["assets",t])}),(0,W.default)(N,$.LOAD_SCENE,function(e,t){var r=t.assets;return e.set("assets",e.get("assets").merge(r))}),(0,W.default)(N,$.CLEAR_SCENE,function(e){return e.set("assets",(0,X.Map)())}),(0,W.default)(N,se,function(e,t){var r=e.get("fileRoots").slice();return r.unshift(t),e.set("fileRoots",r)}),N)),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:b,getUrl:x,filter:T,find:S,getActiveAssets:P,exportJSON:E,fetchImage:p,fetchBinary:m}};t.default=me},function(e,t){e.exports=function(e){try{return!!e()}catch(e){return!0}}},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 b(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 x(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=b(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(78),P=n(E),A=r(6),C=n(A),I=r(17),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=x,t.updateCommands=w,t.undoUpdateCommands=_;var D=r(35),N=r(50),V=n(N),F=(r(8),r(118)),B=r(176),U=(n(B),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,V.default)({},(M={},(0,R.default)(M,F.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:x,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(215)("wks"),i=r(152),a=r(33).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(344),a=r(132),o=Object.defineProperty;t.f=r(45)?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){e.exports={default:r(674),__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 x(e,t,0)}function b(e,t){return x(e,t,t)}function x(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?B():a(e)?e.toSeq():z(e)}function I(e){return null===e||void 0===e?B().toKeyedSeq():a(e)?o(e)?e.toSeq():e.fromEntrySeq():U(e)}function R(e){return null===e||void 0===e?B():a(e)?o(e)?e.entrySeq():e.toIndexedSeq():k(e)}function O(e){return(null===e||void 0===e?B():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 N(e){this._iterable=e,this.size=e.length||e.size}function V(e){this._iterator=e,this._iteratorCache=[]}function F(e){return!(!e||!e[Sr])}function B(){return Tr||(Tr=new L([]))}function U(e){var t=Array.isArray(e)?new L(e).fromEntrySeq():T(e)?new V(e).fromEntrySeq():S(e)?new N(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 V(e):S(e)?new N(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}):q(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)})):Y(t)?e.call(n,r,I(t).map(function(r,n){return X(e,r,n,t)})):t}function q(e){return Array.isArray(e)?R(e).map(q).toList():Y(e)?I(e).map(q).toMap():e}function Y(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>Nr?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=Br[e];return void 0===t&&(t=se(e),Fr===Vr&&(Fr=0,Br={}),Fr++,Br[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&&xe(e._root)}function be(e,t){return _(e,t[0],t[1])}function xe(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 Ve(e,t,r,n){var i=n?e:h(e);return i[t]=r,i}function Fe(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 Yr;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!==Yr)return e;s=null}if(u===c)return Yr;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=qe(e,t),l.array[o]=c,l)}return s&&e.array[o]===i?e:(f(a),l=qe(e,t),void 0===i&&o===l.array.length-1?l.array.pop():l.array[o]=i,l)}function qe(e,t){return t&&e&&t===e.ownerID?e:new ze(e?e.array.slice():[],t)}function Ye(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]=qe(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(b!==h>>>l&pr)break;b&&(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===xr){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===br?yr:br,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(xr,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(xr,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=b(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&&F(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===br?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(xr,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===xr?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(xr,a),l=!0,u=0;return new w(function(){var e,a,c;do{if(e=s.next(),e.done)return n||i===br?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===xr?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(br,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 F(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(N,R),N.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},N.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(V,R),V.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,b(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 Nr=16,Vr=255,Fr=0,Br={};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(xt(this,e))},fe.prototype.sortBy=function(e,t){return Qe(xt(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[Ne(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?Ve(d,f,p,m):Be(d,f,m):Fe(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=qe(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=qe(this,e);return o.array.splice(n+1),i&&(o.array[n]=i),o};var qr,Yr={};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(br,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(br,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(br,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(br,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(Ft,ne),Ft.of=function(){return this(arguments)},Ft.fromKeys=function(e){return this(r(e).keySeq())},Ft.prototype.toString=function(){return this.__toString("Set {","}")},Ft.prototype.has=function(e){return this._map.has(e)},Ft.prototype.add=function(e){return Ut(this,this._map.set(e,!0))},Ft.prototype.remove=function(e){return Ut(this,this._map.remove(e))},Ft.prototype.clear=function(){return Ut(this,this._map.clear())},Ft.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):Yt(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):Yt(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(b(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):Yt(n,i)},Xt.prototype.__ensureOwner=function(e){return e===this.__ownerID?this:e?Yt(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=qt;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 Ft(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(xr)},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,xt(this,e))},values:function(){return this.__iterator(br)},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,xt(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 F.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 F.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=b(r)),n=new B.Highlighter(r,t),r.dispatch({type:q,payload:{ui:n,type:Z.HIGHLIGHTER}})),n;n&&r.dispatch({type:Y,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 b(e){return e.getIn(["selection","highlightColor"])}function x(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 B.Ghoster(t,e);return t.dispatch({type:q,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:q,payload:{ui:n,type:Z.SUBOBJECT_HIGHLIGHTER}}),n}}function T(e){return{type:Y,payload:e}}function E(e){return{type:Y,payload:e}}Object.defineProperty(t,"__esModule",{value:!0}),t.getGhosters=t.getSubObjectHighlighters=void 0;var P,A=r(2),C=n(A),I=r(17),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=b,t.setHighlightThickness=x,t.getHighlightThickness=w,t.addGhoster=M,t.addSubObjectHighlighter=S,t.removeGhoster=T,t.removeSubObjectHighlighter=E;var O=r(35),L=r(50),D=n(L),N=r(67),V=r(427),F=n(V),B=r(428),U=r(429),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",q="ADD_SELECTION_UI",Y="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,N.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,N.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,q,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,Y,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:x,createSelectionSet:i,setActiveSelectionSet:o,addGhoster:M,removeGhoster:T,addSubObjectHighlighter:S,removeSubObjectHighlighter:E},selectors:{isSelected:f,lastSelectedNode:d,getHighlightColor:b,getHighlightThickness:w,getSelectionSets:u,getActiveSelectionSet:l}});t.default=Q},function(e,t,r){"use strict";var n=r(833),i=n||{name:"unknown",version:"0"};if(i.isIE="ie"===i.name,i.isMobile=!1,i.isIOS=!1,i.isAndroid=!1,i.isAndroidTablet=!1,i.isMac=!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.isMac=/Mac/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,t){for(var r=e.positions.faceRangeOffsets,n=e.positions.faceValueIndices,i=new Uint32Array(n.length),a=new y.default(d.Vector3,n.length),o=0;o-1)){var E=_[T],P=v.adjacentFacesOnVertex(_[T],x),A=[];A.push(E);for(var C=E,I=P[0],R=-1,O=0;O-1||Math.acos(B)>n)break;A.push(I);var U=v.adjacentFacesOnVertex(I,x);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 d.Vector3,z=0;z0&&b++}}for(var G=new y.default(d.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}}Object.defineProperty(t,"__esModule",{value:!0});var i=r(204),a=n(i),o=r(282),s=n(o),l={Empty:(0,a.default)({Array:(0,a.default)(new Array(0)),Float64Array:new Float64Array(0),Float32Array:new Float32Array(0),Uint32Array:new Uint32Array(0),Int32Array:new Int32Array(0)}),rangeCopy:function(e,t,r,n,i){for(var a=0;a!==i;++a)r[n+a]=e[t+a];return r},rangeEquals:function(e,t,r,n,i){for(var a=0;a!==i;++a)if(e[t+a]!==r[n+a])return!1;return!0},stridedCopy:function(e,t,r,n,i,a,o,s){for(var l=0;l!==s;++l)for(var u=0;u!==o;++u)n[i+l*a+u]=e[t+l*r+u];return n},accumulate:function(e){for(var t=1,r=e.length;t>>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;s=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 q(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 b(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:x(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):x(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function x(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 N(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 V(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 F(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 B(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||B(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||B(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 q(e){return J.toByteArray(z(e))}function Y(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(659),K=r(835),Q=r(363);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){N(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||N(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||N(this,e,t,2,65535,0),a.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):V(this,e,t,!0),t+2},a.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||N(this,e,t,2,65535,0),a.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):V(this,e,t,!1),t+2},a.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||N(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):F(this,e,t,!0),t+4},a.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||N(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):F(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);N(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);N(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||N(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||N(this,e,t,2,32767,-32768),a.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):V(this,e,t,!0),t+2},a.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||N(this,e,t,2,32767,-32768),a.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):V(this,e,t,!1),t+2},a.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||N(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):F(this,e,t,!0),t+4},a.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||N(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):F(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;o2&&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(b[e]>b[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,x[this.type]).getIndices(r,x[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 B.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 F.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))}},Ne=function(e,t){return Pe(this,fe.call(Te(this),e,t))},Ve=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})};b?(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 q||"ArrayBuffer"==(l=x(r))||"SharedArrayBuffer"==l))return be 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 q(o);for(d(e,"_d",{b:a,o:h,l:o,e:s,v:new Y(a)});f0,g=_t.default.resolve();return i&&(g=g.then(function(){return t.dispatch(E(i,{id:d}))})),f&&(g=g.then(function(){return t.dispatch(at(f,{id:d}))})),p&&(g=g.then(function(){return t.dispatch(c({id:d,form:p,async:!0}))})),g.then(function(){return t.dispatch(de({id:d}))}).then(function(){return t.dispatch(l({id:d,skipModels:r}))}).then(function(){if(u)return t.dispatch(P(u,{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,t.id),a=t.type;"customevent"!==a&&(0,Dt.filter)(e,n).forEach(function(t){e.dispatch((0,Dt.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,Ut.getSceneId)(t),n=void 0!==e.skipModels?e.skipModels:t.getIn(["configuration","configurators",r,"skipModels"]),i=te(t,{id:r}),a=s(t,i),o="configTool-"+r;if((0,kt.getCommands)(t)[o])t.dispatch((0,kt.updateCommand)(o,{options:{events:a}}));else{if(!i.length)return;t.dispatch((0,kt.addCommand)({options:{events:a},tool:{nodeenter:function(e){var i=this.options.events.nodeenter[e];i&&i.forEach(function(e){return t.dispatch(u(e,{id:r,skipModels:n}))})},nodeleave:function(e){var i=this.options.events.nodeleave[e];i&&i.forEach(function(e){return t.dispatch(u(e,{id:r,skipModels:n}))})},click:function(e){var i=(0,Ft.filterNodesFromPosition)(t,e),a=this.options.events.nodeclick[i[0]];a&&a.forEach(function(e){return t.dispatch(u(e,{id:r,skipModels:n}))})}}},o))}}}function u(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(r){var n=t.id||(0,Ut.getSceneId)(r),i=void 0!==t.skipModels?t.skipModels:r.getIn(["configuration","configurators",n,"skipModels"]),a=re(r,e,t);if(!a)throw new Error("Event with name or id "+e+" not found!");a.actions.length&&r.dispatch(A(a.actions,{},{id:n,skipModels:i})),r.createEvent(a.name)}}function c(e){return function(t){if(e.async)return t.dispatch(f(e));var r=e.id||(0,Ut.getSceneId)(t),n=Ee(t,{id:r,all:!0}),i=e.form&&("object"===(0,St.default)(e.form)?j(e.form,{attributes:J(t,{id:r}),events:te(t,{id:r})}):ie(t,e.form,{id:r}));if(!i)return _t.default.resolve(!1);i.meta&&"all"!==i.meta.displayAs&&(i.steps||[]).forEach(function(e){var n=e.formId;n&&t.dispatch(c({id:r,form:n}))});var a=i.fields.reduce(function(e,t){return t.attribute?(void 0===n[t.attribute.name]&&void 0!==t.attribute.defaultValue&&(e[t.attribute.name]=t.attribute.defaultValue),e):e},{});return t.dispatch(P(a,{id:r})),t.dispatch(de({id:r}))}}function f(e){return function(t){var r=e.id||(0,Ut.getSceneId)(t),n=Ee(t,{id:r,all:!0}),i=e.form&&("object"===(0,St.default)(e.form)?j(e.form,{attributes:J(t,{id:r}),events:te(t,{id:r})}):ie(t,e.form,{id:r}));if(!i)return _t.default.resolve(!1);var a=_t.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(f({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(de({id:r})).then(function(){return t.dispatch(P(e,{id:r}))})})}}function d(e,t,r,n){var i=[];if("string"==typeof t)i=(0,Dt.filter)(e,(0,zt.buildQueryObject)(t,{from:r,skipModels:n}));else if(Array.isArray(t)){var a=t.map(function(t){return""===t?[]:(0,zt.isUuid)(t)?[(0,Dt.find)(e,{id:t})]:(0,Dt.filter)(e,(0,zt.buildQueryObject)(t,{from:r,skipModels:n}))});a.forEach(function(e){return i=i.concat(e)})}return i=i.filter(function(e){return!!e})}function h(e,t){var r=e.tags,n=e.value,i=t.id,a=t.skipModels;return function(e){var t=d(e,r,i,a);return _t.default.all(t.map(function(t){return e.dispatch((0,Dt.set)({id:t,plug:"Properties",property:"visible",skipModels:a},Boolean(n)))}))}}function p(e,t){var r=e.tags,n=e.value,i=t.id;return function(e){var t=(0,zt.isUuid)(r)?(0,Dt.find)(e,{id:r}):(0,Dt.find)(e,{from:i,name:r,type:"Annotation"});return t?e.dispatch(n?(0,Vt.openAnnotation)(t):(0,Vt.closeAnnotation)(t)):_t.default.resolve(!0)}}function m(e,t){var r=e.tags,n=e.value,i=void 0===n?500:n,a=t.id;return function(e){var t=(0,zt.isUuid)(r)?(0,Dt.find)(e,{id:r}):(0,Dt.find)(e,{from:a,name:r,type:"Camera"});return t?e.dispatch((0,Ft.animateCameraTo)(t,Number(i))):_t.default.resolve(!0)}}function g(e,t){var r=e.tags,n=e.value,i=t.id,a=t.skipModels;return function(e){var t=(0,zt.isUuid)(n)?n:(0,Dt.find)(e,{from:i,type:"Material",name:n});if(!t)return _t.default.resolve(!0);var o=d(e,r,i,a);return _t.default.all(o.map(function(r){return e.dispatch((0,Dt.set)({id:r,plug:"Material",property:"reference"},t))}))}}function v(e,t){var r=e.tags;t.id;return function(e){var t=(0,Bt.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 _t.default.all(n.map(function(t){return e.dispatch((0,Bt.queueClip)(t.id,{autoplay:!0}))}))}}function y(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,zt.buildQueryObject)(r,{from:i,skipModels:a});e.dispatch((0,Dt.setAll)(t,n))}}}function b(e,t){var r=e.tags,n=e.value;return P((0,Et.default)({},r,n),t)}function x(e,t){var r=e.tags,n=(e.value,t.id);t.skipModels;return function(e){var t=K(e,r,{id:n});if(t&&("Options"===t.type||"Boolean"===t.type)){var i=Ee(e,{id:n,all:!0})[t.name];if("Boolean"===t.type)return e.dispatch(P((0,Et.default)({},t.name,!i)));var a=t.values.indexOf(i),o=(a+1)%t.values.length;return e.dispatch(P((0,Et.default)({},t.name,t.values[o])))}}}function w(e,t){var r=e.tags,n=e.value;return He({hidden:(0,Et.default)({},r,!n)},t)}function _(e,t){var r=e.tags,n=e.value;return function(e){var i=K(e,r,t);if("object"!==(void 0===n?"undefined":(0,St.default)(n))||!i)return _t.default.resolve(!0);var a=Ee(e,{all:!0})[i.name],o=_t.default.resolve();if(a&&!n[a]){var s=i.values.find(function(e){return n[e]});s&&(o=e.dispatch(P((0,Et.default)({},r,s))))}return o.then(function(){return e.dispatch(He({optionsVisible:(0,Et.default)({},r,n)}))})}}function M(e,t){var r=e.tags,n=e.value;return function(e){if(r[0]&&r[1]&&n){var t=(0,zt.isUuid)(n)?n:(0,Dt.find)(e,{name:n}),i=(0,zt.isUuid)(r[0])?r[0]:(0,Dt.find)(e,{name:r[0]}),a=(0,zt.isUuid)(r[1])?r[1]:(0,Dt.find)(e,{name:r[1]});return e.dispatch((0,Dt.attachModel)(t,i,a,!!r[2]))}}}function S(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return function(n){var i=K(n,e,r);return i?n.dispatch(He({hidden:(0,Et.default)({},i.id,!t)},r)):_t.default.resolve(!1)}}function T(e,t,r){var n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},i=(0,At.default)({},n,{all:!0}),a=void 0==r?Ee(e,i)[t.name]:r;if("Image"===t.type){if(!a||!a.id)return a;var o=(0,Nt.hasFile)(e,a.assetId);return o||(0,Ut.isAssetLoading)(e,a.assetId)||e.dispatch((0,Nt.importImage)(a.assetId,{imageNodeId:a.id})).then(function(n){e.dispatch(P((0,Et.default)({},t.name,r)))}),o?a.id:null}return t.prop.set(a)}function E(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(r){var n=le(r,e,t);J(r,t);if(!n)return _t.default.resolve(!1);var i=n.fields.reduce(function(e,n){var i=K(r,n.attributeId,t);return i&&(e[i.name]=n.value),e},{});return r.dispatch(P(i,t))}}function P(){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,Ut.getSceneId)(r),a=J(r,{id:n}),o=ae(r),s=!o||o.skipModels,l=t.form,u=r.getIn(["configuration","changeListeners"]);return _t.default.all((0,xt.default)(e).map(function(t){var o=a.find(i(t));if(!o)return _t.default.reject(new Error("Attribute: "+t+" does not exist"));var u=T(r,o,e[t],{id:n}),c=l&&l.fields.find(function(e){return e.attributeId===o.id});r.dispatch({type:Qt,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(A(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 _t.default.all(u.map(function(e){return e(r,i,{field:a,id:n})}))})},_t.default.resolve())})}}function A(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,Ut.getSceneId)(n),a=r.skipModels;return _t.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:K(n,l,{id:i})),c=u?T(n,u,null,{id:i}):s,f=yr[r];return f&&""!==o&&n.dispatch(f({tags:o,value:c},{id:i,skipModels:a}))}))}}function C(e){return{type:ir,payload:e}}function I(e){return e.getIn(["configuration","configsState"]).toJS()}function R(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return P((0,Et.default)({},e,t),r)}function O(e,t){return console.log("DEPRECATED, use `executeAttribute`"),P((0,Et.default)({},e,t))}function L(e){return{Number:0,Boolean:!1,Color:{a:1,b:0,g:0,r:0}}[e]}function D(e){var t=("Option"===e.type?"Options":e.type)||"Options",r={id:e.id||(0,It.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||L(t),r.defaultValue=void 0===e.value?n:e.value,r.actions=e.actions||[];var i=Ht.default[t];if(!i)throw new Error("Invalid attribute type for configuration: "+t);return r.prop=i(r),r}function N(e,t){var r=e.header[t],n={};return e.table.map(function(e,t){return[e[r],t]}).filter(function(e){return""!==e[0]&&(!n[e[0]]&&(n[e[0]]=!0,!0))})}function V(e,t,r){var n={},i=e.actions||[];return t.forEach(function(e){var t=(0,yt.default)(e,2),a=t[0],o=t[1];n[a]=i.map(function(e){var t=(0,At.default)({},e),n=br.exec(t.value);if(!n)return t;var i=r.header[n[2]];return void 0!==i&&(t.value=r.table[o][i]),t})}),n}function F(e,t,r,n){r.forEach(function(r){var i=(0,yt.default)(r,2),a=i[0];i[1];(0,xt.default)(n).forEach(function(r){t[a].push({action:"set-attribute-options-visibility",tags:e,value:n[r][a]})})})}function B(e,t,r){if(!e)throw new Error("Invalid dependent attribute: "+e);var n=r.header[e],i=r.header[t];return r.table.reduce(function(e,t,r){return e[t[i]]||(e[t[i]]={}),e[t[i]][t[n]]=!0,e},{})}function U(e,t,r,n,i){var a=t.metadata,o=i.header[t.name];(0,xt.default)(a).forEach(function(n){e[n]||(e[n]={});var s=i.header[a[n]],l=[o];t.dependents&&(l=l.concat(t.dependents.map(function(e){return i.header[r[e]]}))),t.dependentOn&&(l=l.concat(t.dependentOn.map(function(e){return i.header[r[e]]}))),i.table.forEach(function(t){var r=l.map(function(e){return t[e]}).join(":");e[n][r]||(e[n][r]=t[s])})})}function k(e){var t=e[0].reduce(function(e,t,r){return e[t]=r,e},{});return{table:e.slice(1),header:t}}function z(e,t){var r=e.type,n={id:e.id||(0,It.default)(),name:e.name,type:r,metadata:e.metadata||{},templated:e.templated},i="";"Options"===r?(n.values=e.values||[],i=n.values[0],n.valueActions=e.valueActions||{},(e.values||[]).forEach(function(e){n.valueActions[e.name]=e.actions||[]})):"Boolean"===r?(n.values=[!0,!1],n.valueActions=e.valueActions||{true:[],false:[]}):"Number"===r?(n.minValue=e.minValue||0,n.maxValue=e.maxValue||100,n.step=e.step||1):"String"===r&&(n.maxLength=e.maxLength||""),i=i||L(r),n.defaultValue=void 0===e.defaultValue?i:e.defaultValue,n.actions=e.actions||[];var a=Ht.default[r];if(!a)throw new Error("Invalid attribute type for configuration: "+r);return n.prop=a(n),n}function j(){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,It.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=e.eventId,u={bom:r,displayAs:n,attributeId:o,metadata:s,eventId:l};return a&&(u.attributeId=a),u.attributeId&&t.attributes&&(u.attribute=t.attributes.find(i(u.attributeId))),l&&t.events&&(u.event=t.events.find(i(l))),u}),n}function G(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return{id:e.id||(0,It.default)(),name:e.name,type:e.type,node:e.node,actions:e.actions||[]}}function H(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.name,r=e.fields;return{id:e.id||(0,It.default)(),name:t||"",fields:r||[]}}function W(){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 X(){return{attributes:[],forms:[],presets:[],script:""}}function q(e){var t=e.id,r=e.config,n=e.sceneId;return function(e){return e.dispatch({type:ur,payload:{id:t,config:r,sceneId:n}})}}function Y(e){e&&Array.isArray(e)&&(e={options:e}),e.options||e.attributes||(e=X());var t=function(e){return"Display"!==e.type&&"Preset"!==e.type&&"ProductTour"!==e.type},r=e.attributes?e.attributes.map(z):e.options.filter(t).map(D),n=(e.forms||e.options.filter(function(e){return"Display"===e.type})).map(j),i=e.presets||[],a=e.script||"",o=e.image||{},s=(e.events||[]).map(G);return(0,Rt.Map)({attributes:r,events:s,forms:n,presets:i,script:a,image:o})}function Z(e){return e.getIn(["configuration","configs"])}function J(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=t.id||(0,Ut.getSceneId)(e);return e.getIn(["configuration","configs",r,"attributes"])||[]}function K(e,t){return J(e,arguments.length>2&&void 0!==arguments[2]?arguments[2]:{}).find(i(t))}function Q(e,t){return J(e,arguments.length>2&&void 0!==arguments[2]?arguments[2]:{}).filter(function(e){return e.type===t})}function $(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=t.id||(0,Ut.getSceneId)(e),n=e.getIn(["configuration","configs",r,"forms"])||[];if(t.all)return n.map(function(e){return ee(e,t)});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]}).map(function(e){return ee(e,t)})}function ee(e,t){switch(t.fieldType){case"all":return e;case"event":var r=e.fields.filter(function(e){return!!e.eventId});return(0,At.default)({},e,{fields:r});default:var n=e.fields.filter(function(e){return!!e.attributeId});return(0,At.default)({},e,{fields:n})}}function te(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=t.id||(0,Ut.getSceneId)(e);return e.getIn(["configuration","configs",r,"events"])||[]}function re(e,t){return te(e,arguments.length>2&&void 0!==arguments[2]?arguments[2]:{}).find(i(t))}function ne(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=t.id||(0,Ut.getSceneId)(e),n=e.getIn(["configuration","formState",r]);return n?n.toJS():{}}function ie(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=r.id||(0,Ut.getSceneId)(e),a=t&&$(e,{fieldType:r.fieldType,id:n,all:!0}).find(i(t)),o=J(e,{id:n}),s=te(e,{id:n});return(a?a.fields:[]).forEach(function(e){e.attribute=e.attributeId&&o.find(i(e.attributeId)),e.event=e.eventId&&s.find(i(e.eventId))}),a||!0!==t||(a={id:(0,It.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 ae(e,t){var r=t||(0,Ut.getSceneId)(e),n=e.getIn(["configuration","configurators",r]);return n&&n.toJS()}function oe(e){return(0,gt.default)(e.getIn(["configuration","configurators"]).toJS())}function se(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=t.id||(0,Ut.getSceneId)(e);return e.getIn(["configuration","configs",r,"presets"])||[]}function le(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=r.id||(0,Ut.getSceneId)(e);return t&&se(e,{id:n}).find(i(t))}function ue(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=t.id||(0,Ut.getSceneId)(e);return e.getIn(["configuration","configs",r,"script"])||""}function ce(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=t.id||(0,Ut.getSceneId)(e);return e.getIn(["configuration","configs",r,"data"])||[]}function fe(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=t.id||(0,Ut.getSceneId)(e);return e.getIn(["configuration","configsState",r,"scriptError"])}function de(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return function(t){var r=e.id||(0,Ut.getSceneId)(t),n=ue(t,{id:r});return n?t.dispatch(pe(n,{id:r})):_t.default.resolve(!0)}}function he(e,t){return e.getIn(["configuration","configsState",t,"scriptActivated"])}function pe(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(r){var n=t.id||(0,Ut.getSceneId)(r),i=t.reinitialize;if(he(r,n)&&!i)return _t.default.resolve(!0);r.dispatch(me(n)),i&&(r.api.off("configurationChange"),r.dispatch({type:hr}));try{var a=new Function("api",e||"");return _t.default.resolve(a(r.api)).then(function(){return r.dispatch({type:cr,payload:{id:n,scriptError:!1}})})}catch(e){return r.dispatch({type:cr,payload:{id:n,scriptError:e}})}}}function me(e){return{type:fr,payload:e}}function ge(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(r){var n=t.id||(0,Ut.getSceneId)(r);return r.dispatch({type:Kt,payload:{id:n,script:e,key:"script"}}),r.dispatch(pe(e,{id:n,reinitialize:!0})),_t.default.resolve(e)}}function ve(e,t){var r=t.reduce(function(e,t){return t.templated&&t.templated.enabled?(e[t.name]=t.templated.name,e):e},{});return t.map(function(n){if(!n.templated||!n.templated.enabled)return!1;var i=(0,At.default)({},n);i.metadata=n.metadata||{};var a=N(e,n.templated.name);if(i.values=a.map(function(e){return e[0]}),i.valueActions=V(n.templated,a,e),i.defaultValue=i.values[0],n.templated.dependents){var o=i.metadata.dependents={};n.templated.dependents.forEach(function(s){o[s]=B(r[s],n.templated.name,e),F(t.find(function(e){return e.name===s}).id,i.valueActions,a,o)})}return n.templated.metadata&&U(i.metadata,n.templated,r,a,e),i}).filter(function(e){return!!e})}function ye(e,t,r){var n=t.map(function(t){return!(!t.templated||!t.templated.enabled)&&e.header[t.templated.name]}).filter(function(e){return!1!==e});return(0,xt.default)(r).reduce(function(t,i){t[i]={};var a=e.header[r[i].name];return e.table.forEach(function(e){var r=n.map(function(t){return e[t]}).join(":");t[i][r]=e[a]}),t},{})}function be(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(r){var n=k(e),i=t.id||(0,Ut.getSceneId)(r),a=J(r,{id:i}),o=ve(n,a);return _t.default.all(o.map(function(e){return r.dispatch({type:Kt,payload:{attrId:e.id,id:i,attrs:e,key:"attributes"}})}))}}function xe(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=t.id||(0,Ut.getSceneId)(store);return{type:Kt,payload:{id:r,image:e,key:"image"}}}function we(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=t.id||(0,Ut.getSceneId)(e);return e.getIn(["configuration","configs",r,"image"])||{}}function _e(e){var t=e.getIn(["configuration","productTour"]);if(!1===t)return!1;var r=t&&K(e,t);return r&&"Options"===r.type?r:null}function Me(e){return e.getIn(["configuration","products"]).toList().toArray()}function Se(e,t){return e.getIn(["configuration","products",t])}function Te(e){return e.getIn(["configuration","externalEl"])}function Ee(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=t.id||(0,Ut.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,xt.default)(i).reduce(function(r,n){var a=K(e,n,t);return i[n]&&a&&(r[a.name]=!0),r},{});return n.filter(function(e,t){return!a[t]}).toJS()}function Pe(e){var t=(0,Ut.getSceneId)(e),r=e.getIn(["configuration","configsState"]).toJS(),n=e.getIn(["configuration","configuration"]).toJS(),i={sceneId:t,publishedHash:(0,Ut.getFetchedHash)(e,t),configuration:n[t],models:[]};return(0,xt.default)(n).forEach(function(a){if(a!==t){var o=r[a].sceneId,s=(0,Dt.get)(e,{id:a,plug:"Transform",operatorIndex:0}),l=(0,Wt.lookupOperator)("Transform","Transform");i.models.push({sceneId:o,publishedHash:(0,Ut.getFetchedHash)(e,o),transform:l.export(s,{onlyChanged:!0}),configuration:n[a],models:[]})}}),i}function Ae(e){return{type:$t,payload:e}}function Ce(e){return e.getIn(["configuration","history"]).size>0}function Ie(){return{type:er}}function Re(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(r){var n=t.id||(0,Ut.getSceneId)(r),i=z(e);return r.dispatch({type:Zt,payload:{id:n,attrs:i,key:"attributes"}}),_t.default.resolve(i.id)}}function Oe(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return function(n){var i=K(n,e,r),a=Ht.default[i.type];t.prop=a(t);var o=r.id||(0,Ut.getSceneId)(n);return n.dispatch({type:Kt,payload:{attrId:e,id:o,attrs:t,key:"attributes"}})}}function Le(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return function(n){var i=J(n,r).slice(0);i.splice(t,0,i.splice(e,1)[0]);var a=r.id||(0,Ut.getSceneId)(n);return n.dispatch({type:mr,payload:{id:a,attributes:i}})}}function De(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(r){var n=t.id||(0,Ut.getSceneId)(r);return r.dispatch({type:Jt,payload:{id:n,attrId:e,key:"attributes"}})}}function Ne(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(r){var n=t.id||(0,Ut.getSceneId)(r),i=j(e,{});return r.dispatch({type:Zt,payload:{id:n,attrs:i,key:"forms"}}),_t.default.resolve(i.id)}}function Ve(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(r){var n=t.id||(0,Ut.getSceneId)(r);return r.dispatch({type:Jt,payload:{id:n,attrId:e,key:"forms"}})}}function Fe(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return function(n){var i=r.id||(0,Ut.getSceneId)(n);return n.dispatch({type:Kt,payload:{id:i,attrId:e,attrs:t,key:"forms"}})}}function Be(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(r){var n=t.id||(0,Ut.getSceneId)(r),i=G(e);return r.dispatch({type:Zt,payload:{id:n,attrs:i,key:"events"}}).then(function(){return r.dispatch(l({id:n})),i.id})}}function Ue(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(r){var n=t.id||(0,Ut.getSceneId)(r);return r.dispatch({type:Jt,payload:{id:n,attrId:e,key:"events"}}).then(function(e){return r.dispatch(l({id:n})),!0})}}function ke(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return function(n){var i=r.id||(0,Ut.getSceneId)(n);return n.dispatch({type:Kt,payload:{id:i,attrId:e,attrs:t,key:"events"}}).then(function(e){var t=e.attrId;return n.dispatch(l({id:i})),t})}}function ze(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(r){var n=t.id||(0,Ut.getSceneId)(r),i=H(e);return r.dispatch({type:Zt,payload:{id:n,attrs:i,key:"presets"}}),_t.default.resolve(i.id)}}function je(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(r){var n=t.id||(0,Ut.getSceneId)(r);return r.dispatch({type:Jt,payload:{id:n,attrId:e,key:"presets"}})}}function Ge(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return function(n){var i=r.id||(0,Ut.getSceneId)(n);return n.dispatch({type:Kt,payload:{id:i,attrId:e,attrs:t,key:"presets"}})}}function He(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(r){var n=t.id||(0,Ut.getSceneId)(r);return r.dispatch({type:ar,payload:{attrs:e,id:n}})}}function We(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return e.handle?{type:or,payload:W(e)}:_t.default.reject("Required product handle")}function Xe(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return{type:lr,payload:W(e)}}function qe(e){return{type:sr,payload:e}}function Ye(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,Rt.is)(r,n)}function Ze(e){return e.getIn(["configuration","saving"])}function Je(e){return!(Ze(e)||Ye(e)||Ke(e))&&e.getIn(["configuration","savingSceneId"])}function Ke(e){return e.getIn(["configuration","saveError"])}function Qe(e){var t=e.toJS();return delete t.scriptInitialized,delete t.scriptError,t.attributes=t.attributes.map(function(e){var t=(0,At.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,pt.default)(t)}function $e(){var e=this;return function(t){var r=Je(t);if(r){var n=t.getIn(["configuration","configs",r]),i=Qe(n),a=t.getIn(["configuration","savedConfig","configStr"]);if(i!==a){var o=JSON.parse(i),s=t.getIn(["configuration","numSaveErrors"]);t.dispatch({type:tr}),setTimeout((0,dt.default)(ct.default.mark(function a(){return ct.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,t.callApi({types:[tr,rr,nr],url:"https://clara.io/api/scenes/"+r+"/configuration",method:"POST",payload:(0,Rt.Map)({config:n,configStr:i}),successPayload:!0,body:{configuration:o,version:(0,Ut.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,Ut.bumpV1Version)(r));case 10:case"end":return e.stop()}},a,e,[[0,5]])})),1e3*s*s)}}}}function et(e,t){var r=e.find(function(e){return e.handle===t});return r||e.push(W({handle:t})),r||e[e.length-1]}function tt(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=et(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,St.default)(t.value)&&(o=t.value.findItem);var s=et(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,Ut.getSceneId)(e),oe(e)),n=Me(e),i=r.reduce(function(t,r){var n=r.id;return t[n]=rt(e,{id:n}),t},{}),a={products:n,items:[]},o=tt(n,a.items);r.forEach(function(r){var n=r.id,s=Ee(e,{id:n,all:void 0===t.all||t.all});i[n].forEach(function(e){var t=e.attribute;if(t){var r=t.name,n=s[r];(t.actions||[]).concat(t.valueActions&&t.valueActions[n]||[]).forEach(function(e){o[e.action]&&o[e.action](e,t,n)});var i=a.items[a.items.length-1];i&&("skip-display"===i.properties[r]?delete i.properties[r]:i.properties[r]=n)}})}),a.price=nt(a);var s=e.getIn(["configuration","bomChangeHandlers"]);return s.size&&r.forEach(function(r){var n=r.id,i=Ee(e,{id:n,all:void 0===t.all||t.all});s.forEach(function(e){return e(a,i)})}),a.items.forEach(function(e){e.handle!==e.product.handle&&(e.product=et(a.products,e.handle),e.variant=e.product.variants[0])}),a}function at(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(r){var n=t.id||(0,Ut.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?_t.default.resolve(!0):r.dispatch((0,Ut.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 _t.default.all((0,xt.default)(e).map(function(t){return r.dispatch((0,Ut.fetch)(t,e[t]))})).then(function(){return r.dispatch(a({async:!0,configuration:l}))}).then(function(){return _t.default.all(s.map(function(e){var t=e.sceneId,n=e.transform,i=e.configuration;return r.dispatch((0,Dt.cloneModel)({sceneId:t})).then(function(e){var t={id:e,plug:"Transform",operatorIndex:0};return r.dispatch((0,Dt.set)(t,n)),r.dispatch(a({async:!0,id:e,configuration:i}))})}))})})}}function ot(e){return{type:dr,payload:e}}function st(e){return{type:pr,payload:e}}Object.defineProperty(t,"__esModule",{value:!0}),t.errors=void 0;var lt,ut=r(385),ct=n(ut),ft=r(384),dt=n(ft),ht=r(37),pt=n(ht),mt=r(78),gt=n(mt),vt=r(56),yt=n(vt),bt=r(6),xt=n(bt),wt=r(30),_t=n(wt),Mt=r(32),St=n(Mt),Tt=r(17),Et=n(Tt),Pt=r(2),At=n(Pt);t.initConfigurator=a,t.initializeConfigCommand=l,t.triggerEvent=u,t.initConfiguration=c,t.setAttributeVisibility=S,t.applyPreset=E,t.setConfiguration=P,t.removeConfigurator=C,t.getConfigurationState=I,t.executeAttribute=R,t.executeVariant=O,t.convertCSV=k,t.initializeAttribute=z,t.initializePreset=H,t.initializeConfiguration=q,t.initializeConfig=Y,t.getConfigs=Z,t.getAttributes=J,t.getAttribute=K,t.getAttributesByType=Q,t.getForms=$,t.getEvents=te,t.getEvent=re,t.getFormState=ne,t.getForm=ie,t.getConfigurator=ae,t.getConfigurators=oe,t.getPresets=se,t.getPreset=le,t.getScript=ue,t.getTableData=ce,t.getScriptError=fe,t.setScript=ge,t.applyDataToAttributes=ve,t.applyDataToMetadata=ye,t.setTableData=be,t.publishToImage=xe,t.getImageOptions=we,t.getProductTour=_e,t.getProducts=Me,t.getProduct=Se,t.getExternalEl=Te,t.getConfiguration=Ee,t.getConfigurations=Pe,t.setSavingSceneId=Ae,t.canUndo=Ce,t.undo=Ie,t.addAttribute=Re,t.setAttribute=Oe,t.swapAttributes=Le,t.deleteAttribute=De,t.addForm=Ne,t.deleteForm=Ve,t.setForm=Fe,t.addEvent=Be,t.deleteEvent=Ue,t.setEvent=ke,t.addPreset=ze,t.deletePreset=je,t.setPreset=Ge,t.setFormState=He,t.addProduct=We,t.setProduct=Xe,t.deleteProduct=qe,t.isSaved=Ye,t.isSaving=Ze,t.shouldSave=Je,t.hasSaveError=Ke,t.save=$e,t.getBOM=it,t.loadConfigurations=at,t.onChange=ot,t.modifyBOM=st;var Ct=r(64),It=n(Ct),Rt=r(35),Ot=r(50),Lt=n(Ot),Dt=r(4),Nt=r(23),Vt=r(139),Ft=r(8),Bt=r(75),Ut=r(19),kt=r(25),zt=r(89),jt=r(67),Gt=r(176),Ht=n(Gt),Wt=r(110),Xt=t.errors={VERSION_CONFLICT:"VERSION_CONFLICT",UNAUTHORIZED:"UNAUTHORIZED"},qt=(0,Rt.Map)({configuration:(0,Rt.Map)(),configs:(0,Rt.Map)(),configsState:(0,Rt.Map)(),savingSceneId:null,history:(0,Rt.List)(),savedConfig:(0,Rt.Map)(),configurators:(0,Rt.Map)(),formState:(0,Rt.Map)(),productTour:null,products:(0,Rt.Map)(),saving:!1,numSaveErrors:0,saveError:!1,changeListeners:(0,Rt.List)(),bomChangeHandlers:(0,Rt.List)()}),Yt=function(){return(0,Rt.Map)({hidden:{},optionsVisible:{}})},Zt="ADD_CONFIG",Jt="DEL_CONFIG",Kt="SET_CONFIG",Qt="SET_CONFIGURATION",$t="SET_SAVING_SCENE_ID",er="CONFIG_UNDO",tr="CONFIG_SAVING",rr="CONFIG_SAVED",nr="CONFIG_SAVE_ERROR",ir="REMOVE_CONFIGURATOR",ar="SET_CONFIGURATOR_FORM_STATE",or="ADD_PRODUCT",sr="DEL_PRODUCT",lr="SET_PRODUCT",ur="INITIALIZE_CONFIGURATION",cr="SET_SCRIPT_ERROR",fr="SET_SCRIPT_ACTIVATED",dr="ADD_CHANGE_LISTENER",hr="RESET_CHANGE_LISTENERS",pr="ADD_BOM_CHANGE_HANDLER",mr="SET_ATTRIBUTES",gr=(0,Rt.Map)({scriptError:"",scriptActivated:!1}),vr=(0,Lt.default)(qt,(lt={},(0,Et.default)(lt,jt.INITIALIZE_SCENE,function(e,t){var r=t.id,n=t.store,i=(0,Dt.get)(n,{id:r,plug:"Player",property:"configurator"}),a=void 0;try{a=JSON.parse(i)}catch(e){a=X()}a=Y(a);var o=e.setIn(["configs",r],a).setIn(["configsState",r],gr.set("sceneId",r));return r!==e.get("savingSceneId")&&e.get("savingSceneId")||(o=o.set("savedConfig",(0,Rt.Map)({config:a,configStr:i}))),o}),(0,Et.default)(lt,ur,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=Y(a);return e.setIn(["configs",r],o).setIn(["configsState",r],gr.set("sceneId",i))}),(0,Et.default)(lt,cr,function(e,t){var r=t.id,n=t.scriptError;return e.setIn(["configsState",r,"scriptError"],n)}),(0,Et.default)(lt,Qt,function(e,t){var r=t.id,n=t.attribute,i=t.value,a=e.getIn(["configuration",r])||(0,Rt.Map)();return e.setIn(["configuration",r],a.set(n.name,i))}),(0,Et.default)(lt,mr,function(e,t){var r=t.id,n=t.attributes,i=e.getIn(["configs",r]);return(e.get("savingSceneId")!==r?e:e.set("history",e.get("history").push(i))).setIn(["configs",r,"attributes"],n)}),(0,Et.default)(lt,jt.CLEAR_SCENE,function(e){return qt}),(0,Et.default)(lt,Zt,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,Et.default)(lt,Kt,function(e,t){var r=t.attrId,n=t.key,a=t.id,o=t.attrs,s=t.script,l=t.data,u=t.image,c=t.scriptError,f=e.getIn(["configs",a]),d=e.get("savingSceneId")!==a?e:e.set("history",e.get("history").push(f));if("script"===n)return d.setIn(["configs",a],f.set(n,s)).setIn(["configsState",a,"scriptError"],c||"");if("data"===n)return d.setIn(["configs",a],f.set(n,l));if("image"===n)return d.setIn(["configs",a],f.set(n,u));var h=[].concat(f.get(n)),p=h.findIndex(i(r));return h[p]=(0,At.default)({},h[p],o),d.setIn(["configs",a],f.set(n,h))}),(0,Et.default)(lt,Jt,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));if(-1===u)return e;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,At.default)({},e);return t.fields=[].concat((e.fields||[]).filter(function(e){return e.attributeId!==n})),t}));var f=e.getIn(["formState",r]),d=(0,At.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,Et.default)(lt,$t,function(e,t){return e.set("savingSceneId",t).set("history",(0,Rt.List)([]))}),(0,Et.default)(lt,er,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,Et.default)(lt,tr,function(e){return e.set("saving",!0)}),(0,Et.default)(lt,nr,function(e,t,r){var n=r.action;return 400===n.error.status&&"VersionError"===n.error.body.error?e.set("saving",!1).set("saveError",Xt.VERSION_CONFLICT):403===n.error.status?e.set("saving",!1).set("saveError",Xt.UNAUTHORIZED):e.set("saving",!1).set("numSaveErrors",e.get("numSaveErrors")+1)}),(0,Et.default)(lt,rr,function(e,t){return e.set("saving",!1).set("savedConfig",t).set("numSaveErrors",0)}),(0,Et.default)(lt,"INIT_CONFIGURATOR",function(e,t){var r=t.id,n=t.productTour,i=e.getIn(["configurators",r])||(0,Rt.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])||Yt();return e.setIn(["configurators",r],i).set("productTour",n).setIn(["formState",r],a)}),(0,Et.default)(lt,ir,function(e,t){var r=e.getIn(["configurators",t,"el"]);return r&&(r.innerHTML=""),e.deleteIn(["configurators",t]).deleteIn(["configuration",t])}),(0,Et.default)(lt,ar,function(e,t){var r=t.attrs,n=t.id,i=e.getIn(["formState",n])||Yt(),a=r.hidden,o=r.optionsVisible;return e.setIn(["formState",n],(0,Rt.Map)({hidden:(0,At.default)({},i.get("hidden"),a),optionsVisible:(0,At.default)({},i.get("optionsVisible"),o)}))}),(0,Et.default)(lt,or,function(e,t){return e.setIn(["products",t.handle],t)}),(0,Et.default)(lt,lr,function(e,t){var r=e.getIn(["products",t.handle]);return e.setIn(["products",t.handle],(0,At.default)({},r,t))}),(0,Et.default)(lt,sr,function(e,t){return e.deleteIn(["products",t])}),(0,Et.default)(lt,fr,function(e,t){return e.setIn(["configsState",t,"scriptActivated"],!0)}),(0,Et.default)(lt,dr,function(e,t){return e.updateIn(["changeListeners"],(0,Rt.List)(),function(e){return e.push(t)})}),(0,Et.default)(lt,hr,function(e){return e.set("changeListeners",(0,Rt.List)()).set("bomChangeHandlers",(0,Rt.List)())}),(0,Et.default)(lt,pr,function(e,t){return e.updateIn(["bomChangeHandlers"],(0,Rt.List)(),function(e){return e.push(t)})}),lt)),yr={"set-visibility":h,"annotation-visibility":p,"set-property":y,"assign-material":g,"move-camera":m,"play-clip":v,"set-variable":b,"set-form-field-visibility":w,"set-attribute-options-visibility":_,"toggle-attribute":x,"attach-model":M},br=/\$([\$\*])([^\$]*)[\$\*]\$/,xr={reducer:vr,actions:{applyPreset:E,executeAttribute:R,executeVariant:O,initConfiguration:c,initConfigurator:a,addProduct:We,setAttribute:Oe,swapAttributes:Le,setProduct:Xe,deleteProduct:qe,setConfiguration:P,setAttributeVisibility:S,loadConfigurations:at,removeConfigurator:C,onChange:ot,modifyBOM:st,triggerEvent:u},selectors:{getConfigurationState:I,getAttribute:K,getAttributes:J,getAttributesByType:Q,getForm:ie,getForms:$,getConfiguration:Ee,getBOM:it,getExternalEl:Te,getPresets:se,getProduct:Se,getProducts:Me,getProductTour:_e,getFormState:ne,getConfigurations:Pe},private:{actions:{addAttribute:Re,addForm:Ne,deleteAttribute:De,deleteForm:Ve,setForm:Fe,setScript:ge}}};t.default=xr},function(e,t,r){var n=r(209),i=r(206);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 b=!1,x=[],w=(new Date,void 0),_=0;_S:mS?T:P(m-M,L,T,I),N=O(A,D);N&&x.push(N),(y?m>=M:m<=S)&&(b=!0)}}if(x.length&&e.dispatch((0,$.multi)(x)),b)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=b(n,e,{immutable:!0});if(i)return n.dispatch(x((0,q.default)({},i.toJS(),t))).then(function(e){return r.useTimeline&&n.dispatch({type:ge}),e})}}function b(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 x(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){var n=t.getIn(["animation","animations",r]);return n.onEnd&&n.onEnd(!0),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,q.default)({},e,{keyframes:t})}return e}),i=(0,q.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,F.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(875),t.dispatch({type:be,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(x({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 N,V=r(32),F=n(V),B=r(78),U=n(B),k=r(30),z=n(k),j=r(6),G=n(j),H=r(17),W=n(H),X=r(2),q=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=b,t.queueAnimation=x,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 Y=r(64),Z=n(Y),J=r(35),K=r(50),Q=n(K),$=r(9),ee=r(436),te=n(ee),re=r(67),ne=r(118),ie=r(4),ae=r(89),oe=r(25),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",be="INIT_PHYSICS",xe=(0,Q.default)(a(),(N={},(0,W.default)(N,ne.ActionTypes.INIT,function(e){return a()}),(0,W.default)(N,le,function(e,t){var r=t.time,n=t.startTime;return e.set("time",r).set("startTime",n)}),(0,W.default)(N,ue,function(e,t){var r=e.get("frameTime");return e.set("frameTime",r+.1*(t-r))}),(0,W.default)(N,ce,function(e,t){return e.merge({playing:!0,autoplay:!!t})}),(0,W.default)(N,fe,function(e){return e.set("playing",!1)}),(0,W.default)(N,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,q.default)(a,n),e}),(0,W.default)(N,he,function(e,t){var r=t.index,n=t.attrs,i=e.getIn(["animations",r]);return i&&(0,q.default)(i,n),e}),(0,W.default)(N,pe,function(e,t){var r=e;return t===e.get("timelineAnimationIndex")&&(r=r.set("timelineAnimationIndex",-1)),r.deleteIn(["animations",t])}),(0,W.default)(N,me,function(e,t){return e.updateIn(["animations"],(0,J.List)(),function(e){return e.push(t)})}),(0,W.default)(N,ge,function(e,t){return e.set("timelineAnimationIndex",e.get("animations").size-1)}),(0,W.default)(N,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)(N,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)(N,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)(N,re.CLEAR_SCENE,function(e){return a()}),(0,W.default)(N,be,function(e,t){var r=t.dynamicsWorld,n=t.dynamicBodies,i=t.kinematicBodies;return e.set("dynamicsWorld",r).set("dynamicBodies",n).set("kinematicBodies",i)}),N)),we={reducer:xe,actions:{setTime:l,startPlaying:h,stopPlaying:g,removeAnimation:S,queueAnimation:x,addClip:T,queueClip:y,updateAnimationAttrs:w,initializeAutoRotate:O,startAutoRotate:L,stopAutoRotate:D},selectors:{findAnimation:_,findClip:b,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(55),o=n(a),s=r(2),l=n(s);t.default=i;var u=r(279),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(43),o=n(a),s=r(44),l=n(s),u=r(281),c=n(u),f=r(187),d=n(f),h=r(140),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(81);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";function n(e){if(!(this instanceof n))return new n(e);u.call(this,e),c.call(this,e),e&&!1===e.readable&&(this.readable=!1),e&&!1===e.writable&&(this.writable=!1),this.allowHalfOpen=!0,e&&!1===e.allowHalfOpen&&(this.allowHalfOpen=!1),this.once("end",i)}function i(){this.allowHalfOpen||this._writableState.ended||o(a,this)}function a(e){e.end()}var o=r(162),s=Object.keys||function(e){var t=[];for(var r in e)t.push(r);return t};e.exports=n;var l=r(133);l.inherits=r(107);var u=r(364),c=r(244);l.inherits(n,u);for(var f=s(c.prototype),d=0;d1)for(var r=1;r1&&void 0!==arguments[1]?arguments[1]:{};return"string"==typeof e?s(e,t):"object"===(void 0===e?"undefined":(0,y.default)(e))?(0,x.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;n=0&&(n.uvChannel=u),n}function c(e,t,r,n,i){function s(r,n,i){var a=u(e,t,r,v[n]||new b.MaterialMap,n,i);a&&!v[n]&&(v[n]=a)}function l(e,t){if(!t)return null;var r=e.createCanvas(t.width,t.height);return r.getContext("2d").drawImage(t,0,0),r}function f(e,t,r,n,i){var a=u(e,n,t.baseMap,new b.MaterialMap,X.baseMap),o=u(e,n,t.opacityMap,new b.MaterialMap,X.alphaMap);if(a&&o){var s=(0,S.combineChannels)(e,{rgb:l(e,a.texture.image),alpha:l(e,o.texture.image)});a.texture.image=s,a.texture.transparent=!0,a.texture.needsUpdate=!0,r.mapSlot=a,i.push("map"),i.push("alphaMap")}}function h(e,t,r,n,i){var a=1===t.roughness&&!!t.roughnessMap,o=1===t.metallic&&!!t.metallicMap,s=1===t.aoMapIntensity&&!!t.aoMap;if(a===o?a:s){a&&i.push("roughnessMap"),o&&i.push("metallicMap"),s&&i.push("aoMap");var c=u(e,n,t.roughnessMap,new b.MaterialMap,X.roughnessMap),f=u(e,n,t.metallicMap,new b.MaterialMap,X.metallicMap),d=u(e,n,t.aoMap,new b.MaterialMap,X.aoMap),h=d&&d.texture&&d.texture.image||null,p=c&&c.texture&&c.texture.image||null,m=f&&f.texture&&f.texture.image||null,g=(0,S.combineChannels)(e,{red:l(e,h),green:l(e,p),blue:l(e,m)});a&&c?(c.texture.image=g,c.texture.transparent=!0,c.texture.needsUpdate=!0,r.roughnessMapSlot=c):o&&f&&(f.texture.image=g,f.texture.transparent=!0,f.texture.needsUpdate=!0,r.metalnessMap=f)}}var m=arguments.length>5&&void 0!==arguments[5]?arguments[5]:{},v=n&&n instanceof b.MeshPhysicalMaterial?n:new b.MeshPhysicalMaterial,y=null;if(!r)return v;if(v.alphaTest=r.alphaTest?r.alphaTestMinimum+.5/256:0,"Line"===r.type)return v.color=r.color,v.linewidth=r.thickness,v;if("MultiID"===r.type){for(var x=[],M=0;M<30;M++){var T=!!r["material"+M];if(T&&r["material"+M].isMultiMaterial&&(T=!1,console.warn("MultiMaterial submaterial #"+M+" is another MultiMaterial.")),T)x.push(c(e,t,r["material"+M],null,i));else{var P={defaultColor:r.defaultColor};x.push(c(e,t,P,null,i))}}return v=new b.MultiMaterial(x)}if("GemMaterial"===r.type){var A=(0,w.getEvalSceneGraph)(e).evaluatedNodes[m.id];y=r.environment&&r.environment.environmentMap;var C=y&&u(e,t,y.specularCubeMap,new b.MaterialMap,"envMap");if(!A||!C)return v;var I=!1,R=a(e,m.id,A.PolyMesh);if(!R){var O=m.nodeInfo.geometry;O.computeBoundingSphere();R={texture:new b.NormalCubeMapBaker(t,O,!0).texture,geometry:O,dispose:function(){}},o(e,m.id,{_v:A.PolyMesh._v},R),I=!0}if(!R)return v;var L;if(r.mode==E.GemMaterialModes.LEGACY)L=new b.ShaderMaterial(b.GeometricRefractionShader),L.uniforms=b.UniformsUtils.clone(b.GeometricRefractionShader.uniforms),L.defines=(0,g.default)({},b.GeometricRefractionShader.defines),L.side=b.FrontSide,L.uniforms.boundingSphere.value.set(R.geometry.boundingSphere.center.x,R.geometry.boundingSphere.center.y,R.geometry.boundingSphere.center.z,R.geometry.boundingSphere.radius),L.defines.NUM_BOUNCES!==r.bounces&&(L.defines.NUM_BOUNCES=10),L.uniforms.normalCubeMap.value=R.texture,L.uniforms.sphereSquish.value.copy(r.squishFactor),L.needsUpdate=!0;else{L=new b.GemMaterial,L.uniforms=b.UniformsUtils.clone(L.uniforms);for(var D=e.getTranslator().getAllPasses().refractiveGlassPass,N=D.depthNormalPeeler,V=0;V<4;V++)L.uniforms["depthPeelDepth"+(V+1)].value=N.renderTargetsDepth[V].texture,L.uniforms["depthPeelNormal"+(V+1)].value=N.renderTargetsNormal[V].texture;L.uniforms.absorptionFactor.value=r.absorptionFactor;var F=Math.min(2,r.bounces);L.defines.NUM_BOUNCES===F&&L.defines.MODE===(Number(r.mode)||2)||(L.defines.NUM_BOUNCES=F,L.defines.MODE=Number(r.mode)||2,L.needsUpdate=!0);var B=m&&m.sparklePass;if(B){var U=r.enableSparkles?r.sparkleCount:0;m.nodeInfo.visible&&"Mesh"==m.nodeInfo.type&&(I||L.sparkleCount!==U)&&(B.removeGemstone(m.nodeInfo),U&&B.addGemstone(R.geometry,m.nodeInfo,U),L.sparkleCount=U)}}if(L.uniforms.absorptionColor.value.set(10*(1-r.transmissive.r),10*(1-r.transmissive.g),10*(1-r.transmissive.b)),L.uniforms.envMap.value=C,L.envMap=C,y){var k=void 0!==y.intensity?y.intensity:1;L.uniforms.envMapIntensity.value=k,L.envMapIntensity=k,L.uniforms.crystalIOR.value=r.ior,L.uniforms.boostFactor.value=r.boostFactor,L.uniforms.abbeNumber.value=r.abbeNumber}else console.warn("Gem Material relies expects environment map");return L}if(v.side=i?b.DoubleSide:b.FrontSide,r.defaultColor)return v.color=r.defaultColor,v;if(!r.baseColor)return r.diffuseColor&&(v.color=r.diffuseColor),v;var z={color:"baseColor",aoMapIntensity:"aoMapIntensity",bumpScale:"bumpScale",displacementScale:"displacementScale",displacementBias:"displacementBias",emissive:"emissiveColor",falloff:"baseFalloff",falloffColor:"baseFalloffColor",metalness:"metallic",roughness:"roughness",clearCoat:"clearCoat",clearCoatRoughness:"clearCoatRoughness",opacity:"opacityFactor",falloffOpacity:"opacityFalloffFactor",transparent:"baseMapTransparent",anisotropy:"anisotropy",anisotropyRotation:"anisotropyRotation",triplanarEnabledMap:"triplanarEnabledMap",triplanarEnabledNormalMap:"triplanarEnabledNormalMap",triplanarEnabledBumpMap:"triplanarEnabledBumpMap",triplanarEnabledRoughnessMap:"triplanarEnabledRoughnessMap"},j=["depthTest","depthWrite"],G={map:"base",bumpMap:"bump",aoMap:"ao",emissiveMap:"emissive",lightMap:"light",metalnessMap:"metallic",normalMap:"normal",displacementMap:"displacement",alphaMap:"opacity",roughnessMap:"roughness",falloffMap:"baseFalloff",falloffAlphaMap:"opacityFalloff",anisotropyMap:"anisotropy",anisotropyRotationMap:"anisotropyRotation"},H=(0,_.get)(e,{id:m.id,evalPlug:"PolyMesh"}),W=[],X={};if(H&&H.mesh&&H.mesh.uvMaps&&(W=H.mesh.uvMaps.namesByIndex,(0,p.default)(G).forEach(function(e){var t=G[e]+"Map";X[t]=W.indexOf(r[G[e]+"UVChannel"])})),(0,_.get)(e,{id:r.nodeId,plug:"Properties",property:"combineTextures"}))!function(e,t,r,n){var i=[];f(e,t,r,n,i),h(e,t,r,n,i);var a=!0,o=!1,l=void 0;try{for(var u,c=(0,d.default)((0,p.default)(G));!(a=(u=c.next()).done);a=!0){var m=u.value;if(-1===i.indexOf(m)){var g=G[m]+"Map";s(t[g],m+"Slot",X[g])}}}catch(e){o=!0,l=e}finally{try{!a&&c.return&&c.return()}finally{if(o)throw l}}}(e,r,v,t);else{var q=!0,Y=!1,Z=void 0;try{for(var J,K=(0,d.default)((0,p.default)(G));!(q=(J=K.next()).done);q=!0){var Q=J.value,$=G[Q]+"Map";s(r[$],Q+"Slot",X[$])}}catch(e){Y=!0,Z=e}finally{try{!q&&K.return&&K.return()}finally{if(Y)throw Z}}}var ee=!0,te=!1,re=void 0;try{for(var ne,ie=(0,d.default)((0,p.default)(z));!(ee=(ne=ie.next()).done);ee=!0){var ae=ne.value;v[ae]=r[z[ae]]}}catch(e){te=!0,re=e}finally{try{!ee&&ie.return&&ie.return()}finally{if(te)throw re}}var oe=!0,se=!1,le=void 0;try{for(var ue,ce=(0,d.default)(j);!(oe=(ue=ce.next()).done);oe=!0){var fe=ue.value;v[fe]=r[fe]}}catch(e){se=!0,le=e}finally{try{!oe&&ce.return&&ce.return()}finally{if(se)throw le}}r.emissiveScale&&(v.emissive=v.emissive.clone(),v.emissive.multiplyScalar(r.emissiveScale));var de=r.renderCategory;de===E.RenderCategories.OPAQUE?v.transparent=!1:de===E.RenderCategories.TRANSPARENT?v.transparent=!0:r.alphaTest?v.transparent=!1:v.transparent=v.opacity<1||!!r.opacityMap||r.baseMapTransparent||r.opacityFalloffFactor<1||!!r.opacityFalloffMap;var he=r.specularColor;return v.reflectivity=.33333*(he.r+he.g+he.b),v.clearCoat*=.25,v.normalScale.x=(r.normalRedFlip?-1:1)*r.normalFactor,v.normalScale.y=(r.normalGreenFlip?-1:1)*r.normalFactor,v.blending=b.NormalBlending,v.premultipliedAlpha=!0,y=r.environment&&r.environment.environmentMap,y&&(s(y.specularCubeMap,"envMap"),v.envMapIntensity=void 0!==y.intensity?y.intensity:1),void 0!==r.triplanarRepeat&&void 0!==v.triplanarScale&&(v.triplanarScale.set(r.triplanarRepeat,r.triplanarRepeat,r.triplanarRepeat),v.triplanarExponent=Math.exp(b.Math.lerp(5,0,r.triplanarBlend))),v.needsUpdate=!0,v}Object.defineProperty(t,"__esModule",{value:!0});var f=r(13),d=n(f),h=r(6),p=n(h),m=r(2),g=n(m);t.fetchHDRSourceData=i,t.checkTextureCache=a,t.getCubeMapTexture=s,t.getTextureImage=l,t.assignTexture=u,t.primitiveToMaterial=c;var v=r(39),y=r(10),b=function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}(y),x=r(23),w=r(9),_=r(4),M=r(196),S=r(635),T=r(195),E=(n(T),r(186)),P=r(309),A=function(){return v.isIOS||v.isIE}()},function(e,t,r){var n=r(60),i=r(327),a=r(325),o=r(48),s=r(151),l=r(221),u={},c={},t=e.exports=function(e,t,r,f,d){var h,p,m,g,v=d?function(){return e}:l(e),y=n(r,f,t?2:1),b=0;if("function"!=typeof v)throw TypeError(e+" is not iterable!");if(a(v)){for(h=s(e.length);h>b;b++)if((g=t?y(o(p=e[b])[0],p[1]):y(e[b]))===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(333),i=r(208);e.exports=Object.keys||function(e){return n(e,i)}},function(e,t,r){var n=r(206);e.exports=function(e){return Object(n(e))}},function(e,t,r){"use strict";var n=r(695)(!0);r(210)(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(700);for(var n=r(33),i=r(69),a=r(92),o=r(28)("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;$--)Z.update()}function x(e,t){Z="function"==typeof e?e(t):e}function w(e){J=e}function _(){return!!J}function M(){if(!J)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),Y?(Y.error(e,r),e.message?(console.error(e.message),e.stack&&console.log(e.stack)):console.error(e)):console.error(e),k.makeErrorsFatal)throw e}function L(e){G.push(e);var t=!0;return function(){if(t){t=!1;var r=G.indexOf(e);G.splice(r,1)}}}function D(e,t){N(e),H[e]=t,W=(0,u.default)(H)}function N(e){var t=H[e];t&&(t.end&&t.end(!0),delete H[e],W=(0,u.default)(H))}function V(e){if(!(0,d.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(q)throw new Error("Reducers may not dispatch actions.");try{q=!0,j=z(j,e,a,A,P)}catch(e){O(e)}finally{q=!1}return ee(!0),m.default.Promise.resolve(e.resolve?e.resolve:e.payload)}function F(e){this.createCanvas=e}function B(e){z=e,V({type:y.INIT})}var U,k=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},z=e,j=t,G=[],H={},W=[],X=[],q=!1,Y=!1,Z=null,J=null,K=null,Q=16,$=Q;m.default.on("error",O);var ee=function(){function e(e){try{if(e&&($=Q),e){var a=X.splice(0,X.length);G.slice().forEach(function(e){return e(a,n)})}var o=new Date;$=$>-1?$-1:-1,Z&&$>=0&&Z.update();var s=o-i;i=o,W.forEach(function(e){return e(s)})}catch(e){O(e)}r=!1,t()}function t(t){n=n||t,r||(r=!0,g.call(v,function(){var t=n;n=!1,e(t)}))}var r=!1,n=!1,i=new Date;return t}(),te=function(e,t){var r=document.createElement("Canvas");return r.width=e,r.height=t,r};return V({type:y.INIT}),U={dispatch:V,subscribe:L,getState:o,getIn:l,get:c,replaceReducer:B,setTranslator:x,getTranslator:f,getEvaluatedTranslator:p,read:C,write:I,useRollbar:R,error:O,setApi:w,hasApi:_,callApi:M,createEvent:a,setRequestAnimationFrame:i,logPageView:E,setSocketApi:S,getSocketApi:T,createCanvas:te,setCreateCanvas:F},(0,s.default)(U,"createEvent",a),(0,s.default)(U,"trackEvent",A),(0,s.default)(U,"trackTiming",P),(0,s.default)(U,"setTotalRenders",r),(0,s.default)(U,"numRendersRemaining",n),(0,s.default)(U,"renderAll",b),(0,s.default)(U,"addTimer",D),(0,s.default)(U,"killTimer",N),U}Object.defineProperty(t,"__esModule",{value:!0}),t.ActionTypes=void 0;var o=r(17),s=n(o),l=r(78),u=n(l),c=r(655);n(c);t.default=a;var f=r(313),d=n(f),h=r(648),p=r(246),m=n(p),g=void 0,v=void 0;i();var y=t.ActionTypes={INIT:"@@redux/INIT"}},function(e,t,r){e.exports={default:r(391),__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(52).f,i=r(66),a=r(28)("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(61),i=r(229),a=r(84),o=r(34),s=r(733);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),b=n(s,p,3),x=o(y.length),w=0,_=r?h(t,x):l?h(t,0):void 0;x>w;w++)if((d||w in y)&&(m=y[w],g=b(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(85)("meta"),i=r(18),a=r(46),o=r(29).f,s=0,l=Object.isExtensible||function(){return!0},u=!r(24)(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(741),a=r(227),o=r(234)("IE_PROTO"),s=function(){},l=function(){var e,t=r(226)("iframe"),n=a.length;for(t.style.display="none",r(343).appendChild(t),t.src="javascript:",e=t.contentWindow.document,e.open(),e.write("